@elyx-code/project-logic-tree 0.0.6879 → 0.0.6882

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/dist/index.cjs CHANGED
@@ -51,7 +51,7 @@ This is likely an incorrect strategy, either the '${this.type}' entity doesn't n
51
51
  `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(p){return p instanceof this?p:new this(p)}static concat(p,...i){const r=new this(p);return i.forEach(a=>r.set(a)),r}static accessor(p){const r=(this[xk]=this[xk]={accessors:{}}).accessors,a=this.prototype;function c(e){const f=x0(e);r[f]||(wgi(a,e),r[f]=!0)}return qe.isArray(p)?p.forEach(c):c(p),this}}f1.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);qe.reduceDescriptors(f1.prototype,({value:l},p)=>{let i=p[0].toUpperCase()+p.slice(1);return{get:()=>l,set(r){this[i]=r}}});qe.freezeMethods(f1);const zl=f1;function qO(l,p){const i=this||Zx,r=p||i,a=zl.from(r.headers);let c=r.data;return qe.forEach(l,function(f){c=f.call(i,c,a.normalize(),p?p.status:void 0)}),a.normalize(),c}function QLe(l){return!!(l&&l.__CANCEL__)}class Cgi extends Ji{constructor(p,i,r){super(p??"canceled",Ji.ERR_CANCELED,i,r),this.name="CanceledError",this.__CANCEL__=!0}}const hE=Cgi;function XLe(l,p,i){const r=i.config.validateStatus;!i.status||!r||r(i.status)?l(i):p(new Ji("Request failed with status code "+i.status,[Ji.ERR_BAD_REQUEST,Ji.ERR_BAD_RESPONSE][Math.floor(i.status/100)-4],i.config,i.request,i))}function Ogi(l){const p=/^([-+\w]{1,25})(:?\/\/|:)/.exec(l);return p&&p[1]||""}function _gi(l,p){l=l||10;const i=new Array(l),r=new Array(l);let a=0,c=0,e;return p=p!==void 0?p:1e3,function(h){const m=Date.now(),E=r[c];e||(e=m),i[a]=h,r[a]=m;let b=c,A=0;for(;b!==a;)A+=i[b++],b=b%l;if(a=(a+1)%l,a===c&&(c=(c+1)%l),m-e<p)return;const _=E&&m-E;return _?Math.round(A*1e3/_):void 0}}function Vgi(l,p){let i=0,r=1e3/p,a,c;const e=(m,E=Date.now())=>{i=E,a=null,c&&(clearTimeout(c),c=null),l(...m)};return[(...m)=>{const E=Date.now(),b=E-i;b>=r?e(m,E):(a=m,c||(c=setTimeout(()=>{c=null,e(a)},r-b)))},()=>a&&e(a)]}const DI=(l,p,i=3)=>{let r=0;const a=_gi(50,250);return Vgi(c=>{const e=c.loaded,f=c.lengthComputable?c.total:void 0,h=e-r,m=a(h),E=e<=f;r=e;const b={loaded:e,total:f,progress:f?e/f:void 0,bytes:h,rate:m||void 0,estimated:m&&f&&E?(f-e)/m:void 0,event:c,lengthComputable:f!=null,[p?"download":"upload"]:!0};l(b)},i)},$k=(l,p)=>{const i=l!=null;return[r=>p[0]({lengthComputable:i,total:l,loaded:r}),p[1]]},Lk=l=>(...p)=>qe.asap(()=>l(...p)),Pgi=Ta.hasStandardBrowserEnv?((l,p)=>i=>(i=new URL(i,Ta.origin),l.protocol===i.protocol&&l.host===i.host&&(p||l.port===i.port)))(new URL(Ta.origin),Ta.navigator&&/(msie|trident)/i.test(Ta.navigator.userAgent)):()=>!0,Ngi=Ta.hasStandardBrowserEnv?{write(l,p,i,r,a,c,e){if(typeof document>"u")return;const f=[`${l}=${encodeURIComponent(p)}`];qe.isNumber(i)&&f.push(`expires=${new Date(i).toUTCString()}`),qe.isString(r)&&f.push(`path=${r}`),qe.isString(a)&&f.push(`domain=${a}`),c===!0&&f.push("secure"),qe.isString(e)&&f.push(`SameSite=${e}`),document.cookie=f.join("; ")},read(l){if(typeof document>"u")return null;const p=document.cookie.match(new RegExp("(?:^|; )"+l+"=([^;]*)"));return p?decodeURIComponent(p[1]):null},remove(l){this.write(l,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function xgi(l){return typeof l!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(l)}function $gi(l,p){return p?l.replace(/\/?\/$/,"")+"/"+p.replace(/^\/+/,""):l}function e2e(l,p,i){let r=!xgi(p);return l&&(r||i==!1)?$gi(l,p):p}const Bk=l=>l instanceof zl?{...l}:l;function Tf(l,p){p=p||{};const i={};function r(m,E,b,A){return qe.isPlainObject(m)&&qe.isPlainObject(E)?qe.merge.call({caseless:A},m,E):qe.isPlainObject(E)?qe.merge({},E):qe.isArray(E)?E.slice():E}function a(m,E,b,A){if(qe.isUndefined(E)){if(!qe.isUndefined(m))return r(void 0,m,b,A)}else return r(m,E,b,A)}function c(m,E){if(!qe.isUndefined(E))return r(void 0,E)}function e(m,E){if(qe.isUndefined(E)){if(!qe.isUndefined(m))return r(void 0,m)}else return r(void 0,E)}function f(m,E,b){if(b in p)return r(m,E);if(b in l)return r(void 0,m)}const h={url:c,method:c,data:c,baseURL:e,transformRequest:e,transformResponse:e,paramsSerializer:e,timeout:e,timeoutMessage:e,withCredentials:e,withXSRFToken:e,adapter:e,responseType:e,xsrfCookieName:e,xsrfHeaderName:e,onUploadProgress:e,onDownloadProgress:e,decompress:e,maxContentLength:e,maxBodyLength:e,beforeRedirect:e,transport:e,httpAgent:e,httpsAgent:e,cancelToken:e,socketPath:e,responseEncoding:e,validateStatus:f,headers:(m,E,b)=>a(Bk(m),Bk(E),b,!0)};return qe.forEach(Object.keys({...l,...p}),function(E){if(E==="__proto__"||E==="constructor"||E==="prototype")return;const b=qe.hasOwnProp(h,E)?h[E]:a,A=b(l[E],p[E],E);qe.isUndefined(A)&&b!==f||(i[E]=A)}),i}const t2e=l=>{const p=Tf({},l);let{data:i,withXSRFToken:r,xsrfHeaderName:a,xsrfCookieName:c,headers:e,auth:f}=p;if(p.headers=e=zl.from(e),p.url=YLe(e2e(p.baseURL,p.url,p.allowAbsoluteUrls),l.params,l.paramsSerializer),f&&e.set("Authorization","Basic "+btoa((f.username||"")+":"+(f.password?unescape(encodeURIComponent(f.password)):""))),qe.isFormData(i)){if(Ta.hasStandardBrowserEnv||Ta.hasStandardBrowserWebWorkerEnv)e.setContentType(void 0);else if(qe.isFunction(i.getHeaders)){const h=i.getHeaders(),m=["content-type","content-length"];Object.entries(h).forEach(([E,b])=>{m.includes(E.toLowerCase())&&e.set(E,b)})}}if(Ta.hasStandardBrowserEnv&&(r&&qe.isFunction(r)&&(r=r(p)),r||r!==!1&&Pgi(p.url))){const h=a&&c&&Ngi.read(c);h&&e.set(a,h)}return p},Lgi=typeof XMLHttpRequest<"u",Bgi=Lgi&&function(l){return new Promise(function(i,r){const a=t2e(l);let c=a.data;const e=zl.from(a.headers).normalize();let{responseType:f,onUploadProgress:h,onDownloadProgress:m}=a,E,b,A,_,N;function V(){_&&_(),N&&N(),a.cancelToken&&a.cancelToken.unsubscribe(E),a.signal&&a.signal.removeEventListener("abort",E)}let j=new XMLHttpRequest;j.open(a.method.toUpperCase(),a.url,!0),j.timeout=a.timeout;function M(){if(!j)return;const q=zl.from("getAllResponseHeaders"in j&&j.getAllResponseHeaders()),ee={data:!f||f==="text"||f==="json"?j.responseText:j.response,status:j.status,statusText:j.statusText,headers:q,config:l,request:j};XLe(function(ie){i(ie),V()},function(ie){r(ie),V()},ee),j=null}"onloadend"in j?j.onloadend=M:j.onreadystatechange=function(){!j||j.readyState!==4||j.status===0&&!(j.responseURL&&j.responseURL.indexOf("file:")===0)||setTimeout(M)},j.onabort=function(){j&&(r(new Ji("Request aborted",Ji.ECONNABORTED,l,j)),j=null)},j.onerror=function(re){const ee=re&&re.message?re.message:"Network Error",de=new Ji(ee,Ji.ERR_NETWORK,l,j);de.event=re||null,r(de),j=null},j.ontimeout=function(){let re=a.timeout?"timeout of "+a.timeout+"ms exceeded":"timeout exceeded";const ee=a.transitional||Kx;a.timeoutErrorMessage&&(re=a.timeoutErrorMessage),r(new Ji(re,ee.clarifyTimeoutError?Ji.ETIMEDOUT:Ji.ECONNABORTED,l,j)),j=null},c===void 0&&e.setContentType(null),"setRequestHeader"in j&&qe.forEach(e.toJSON(),function(re,ee){j.setRequestHeader(ee,re)}),qe.isUndefined(a.withCredentials)||(j.withCredentials=!!a.withCredentials),f&&f!=="json"&&(j.responseType=a.responseType),m&&([A,N]=DI(m,!0),j.addEventListener("progress",A)),h&&j.upload&&([b,_]=DI(h),j.upload.addEventListener("progress",b),j.upload.addEventListener("loadend",_)),(a.cancelToken||a.signal)&&(E=q=>{j&&(r(!q||q.type?new hE(null,l,j):q),j.abort(),j=null)},a.cancelToken&&a.cancelToken.subscribe(E),a.signal&&(a.signal.aborted?E():a.signal.addEventListener("abort",E)));const G=Ogi(a.url);if(G&&Ta.protocols.indexOf(G)===-1){r(new Ji("Unsupported protocol "+G+":",Ji.ERR_BAD_REQUEST,l));return}j.send(c||null)})},Mgi=(l,p)=>{const{length:i}=l=l?l.filter(Boolean):[];if(p||i){let r=new AbortController,a;const c=function(m){if(!a){a=!0,f();const E=m instanceof Error?m:this.reason;r.abort(E instanceof Ji?E:new hE(E instanceof Error?E.message:E))}};let e=p&&setTimeout(()=>{e=null,c(new Ji(`timeout of ${p}ms exceeded`,Ji.ETIMEDOUT))},p);const f=()=>{l&&(e&&clearTimeout(e),e=null,l.forEach(m=>{m.unsubscribe?m.unsubscribe(c):m.removeEventListener("abort",c)}),l=null)};l.forEach(m=>m.addEventListener("abort",c));const{signal:h}=r;return h.unsubscribe=()=>qe.asap(f),h}},Ggi=Mgi,jgi=function*(l,p){let i=l.byteLength;if(!p||i<p){yield l;return}let r=0,a;for(;r<i;)a=r+p,yield l.slice(r,a),r=a},kgi=async function*(l,p){for await(const i of Ugi(l))yield*jgi(i,p)},Ugi=async function*(l){if(l[Symbol.asyncIterator]){yield*l;return}const p=l.getReader();try{for(;;){const{done:i,value:r}=await p.read();if(i)break;yield r}}finally{await p.cancel()}},Mk=(l,p,i,r)=>{const a=kgi(l,p);let c=0,e,f=h=>{e||(e=!0,r&&r(h))};return new ReadableStream({async pull(h){try{const{done:m,value:E}=await a.next();if(m){f(),h.close();return}let b=E.byteLength;if(i){let A=c+=b;i(A)}h.enqueue(new Uint8Array(E))}catch(m){throw f(m),m}},cancel(h){return f(h),a.return()}},{highWaterMark:2})},Gk=64*1024,{isFunction:SA}=qe,Fgi=(({Request:l,Response:p})=>({Request:l,Response:p}))(qe.global),{ReadableStream:jk,TextEncoder:kk}=qe.global,Uk=(l,...p)=>{try{return!!l(...p)}catch{return!1}},Kgi=l=>{l=qe.merge.call({skipUndefined:!0},Fgi,l);const{fetch:p,Request:i,Response:r}=l,a=p?SA(p):typeof fetch=="function",c=SA(i),e=SA(r);if(!a)return!1;const f=a&&SA(jk),h=a&&(typeof kk=="function"?(N=>V=>N.encode(V))(new kk):async N=>new Uint8Array(await new i(N).arrayBuffer())),m=c&&f&&Uk(()=>{let N=!1;const V=new i(Ta.origin,{body:new jk,method:"POST",get duplex(){return N=!0,"half"}}).headers.has("Content-Type");return N&&!V}),E=e&&f&&Uk(()=>qe.isReadableStream(new r("").body)),b={stream:E&&(N=>N.body)};a&&["text","arrayBuffer","blob","formData","stream"].forEach(N=>{!b[N]&&(b[N]=(V,j)=>{let M=V&&V[N];if(M)return M.call(V);throw new Ji(`Response type '${N}' is not supported`,Ji.ERR_NOT_SUPPORT,j)})});const A=async N=>{if(N==null)return 0;if(qe.isBlob(N))return N.size;if(qe.isSpecCompliantForm(N))return(await new i(Ta.origin,{method:"POST",body:N}).arrayBuffer()).byteLength;if(qe.isArrayBufferView(N)||qe.isArrayBuffer(N))return N.byteLength;if(qe.isURLSearchParams(N)&&(N=N+""),qe.isString(N))return(await h(N)).byteLength},_=async(N,V)=>{const j=qe.toFiniteNumber(N.getContentLength());return j??A(V)};return async N=>{let{url:V,method:j,data:M,signal:G,cancelToken:q,timeout:re,onDownloadProgress:ee,onUploadProgress:de,responseType:ie,headers:se,withCredentials:ue="same-origin",fetchOptions:z}=t2e(N),X=p||fetch;ie=ie?(ie+"").toLowerCase():"text";let ce=Ggi([G,q&&q.toAbortSignal()],re),oe=null;const me=ce&&ce.unsubscribe&&(()=>{ce.unsubscribe()});let ve;try{if(de&&m&&j!=="get"&&j!=="head"&&(ve=await _(se,M))!==0){let et=new i(V,{method:"POST",body:M,duplex:"half"}),Ze;if(qe.isFormData(M)&&(Ze=et.headers.get("content-type"))&&se.setContentType(Ze),et.body){const[Xe,Dt]=$k(ve,DI(Lk(de)));M=Mk(et.body,Gk,Xe,Dt)}}qe.isString(ue)||(ue=ue?"include":"omit");const we=c&&"credentials"in i.prototype,Re={...z,signal:ce,method:j.toUpperCase(),headers:se.normalize().toJSON(),body:M,duplex:"half",credentials:we?ue:void 0};oe=c&&new i(V,Re);let xe=await(c?X(oe,z):X(V,Re));const je=E&&(ie==="stream"||ie==="response");if(E&&(ee||je&&me)){const et={};["status","statusText","headers"].forEach(Mt=>{et[Mt]=xe[Mt]});const Ze=qe.toFiniteNumber(xe.headers.get("content-length")),[Xe,Dt]=ee&&$k(Ze,DI(Lk(ee),!0))||[];xe=new r(Mk(xe.body,Gk,Xe,()=>{Dt&&Dt(),me&&me()}),et)}ie=ie||"text";let Se=await b[qe.findKey(b,ie)||"text"](xe,N);return!je&&me&&me(),await new Promise((et,Ze)=>{XLe(et,Ze,{data:Se,headers:zl.from(xe.headers),status:xe.status,statusText:xe.statusText,config:N,request:oe})})}catch(we){throw me&&me(),we&&we.name==="TypeError"&&/Load failed|fetch/i.test(we.message)?Object.assign(new Ji("Network Error",Ji.ERR_NETWORK,N,oe,we&&we.response),{cause:we.cause||we}):Ji.from(we,we&&we.code,N,oe,we&&we.response)}}},qgi=new Map,i2e=l=>{let p=l&&l.env||{};const{fetch:i,Request:r,Response:a}=p,c=[r,a,i];let e=c.length,f=e,h,m,E=qgi;for(;f--;)h=c[f],m=E.get(h),m===void 0&&E.set(h,m=f?new Map:Kgi(p)),E=m;return m};i2e();const Hx={http:ngi,xhr:Bgi,fetch:{get:i2e}};qe.forEach(Hx,(l,p)=>{if(l){try{Object.defineProperty(l,"name",{value:p})}catch{}Object.defineProperty(l,"adapterName",{value:p})}});const Fk=l=>`- ${l}`,Sgi=l=>qe.isFunction(l)||l===null||l===!1;function Zgi(l,p){l=qe.isArray(l)?l:[l];const{length:i}=l;let r,a;const c={};for(let e=0;e<i;e++){r=l[e];let f;if(a=r,!Sgi(r)&&(a=Hx[(f=String(r)).toLowerCase()],a===void 0))throw new Ji(`Unknown adapter '${f}'`);if(a&&(qe.isFunction(a)||(a=a.get(p))))break;c[f||"#"+e]=a}if(!a){const e=Object.entries(c).map(([h,m])=>`adapter ${h} `+(m===!1?"is not supported by the environment":"is not available in the build"));let f=i?e.length>1?`since :
52
52
  `+e.map(Fk).join(`
53
53
  `):" "+Fk(e[0]):"as no adapter specified";throw new Ji("There is no suitable adapter to dispatch the request "+f,"ERR_NOT_SUPPORT")}return a}const r2e={getAdapter:Zgi,adapters:Hx};function SO(l){if(l.cancelToken&&l.cancelToken.throwIfRequested(),l.signal&&l.signal.aborted)throw new hE(null,l)}function Kk(l){return SO(l),l.headers=zl.from(l.headers),l.data=qO.call(l,l.transformRequest),["post","put","patch"].indexOf(l.method)!==-1&&l.headers.setContentType("application/x-www-form-urlencoded",!1),r2e.getAdapter(l.adapter||Zx.adapter,l)(l).then(function(r){return SO(l),r.data=qO.call(l,l.transformResponse,r),r.headers=zl.from(r.headers),r},function(r){return QLe(r)||(SO(l),r&&r.response&&(r.response.data=qO.call(l,l.transformResponse,r.response),r.response.headers=zl.from(r.response.headers))),Promise.reject(r)})}const n2e="1.13.6",y1={};["object","boolean","number","function","string","symbol"].forEach((l,p)=>{y1[l]=function(r){return typeof r===l||"a"+(p<1?"n ":" ")+l}});const qk={};y1.transitional=function(p,i,r){function a(c,e){return"[Axios v"+n2e+"] Transitional option '"+c+"'"+e+(r?". "+r:"")}return(c,e,f)=>{if(p===!1)throw new Ji(a(e," has been removed"+(i?" in "+i:"")),Ji.ERR_DEPRECATED);return i&&!qk[e]&&(qk[e]=!0,console.warn(a(e," has been deprecated since v"+i+" and will be removed in the near future"))),p?p(c,e,f):!0}};y1.spelling=function(p){return(i,r)=>(console.warn(`${r} is likely a misspelling of ${p}`),!0)};function Hgi(l,p,i){if(typeof l!="object")throw new Ji("options must be an object",Ji.ERR_BAD_OPTION_VALUE);const r=Object.keys(l);let a=r.length;for(;a-- >0;){const c=r[a],e=p[c];if(e){const f=l[c],h=f===void 0||e(f,c,l);if(h!==!0)throw new Ji("option "+c+" must be "+h,Ji.ERR_BAD_OPTION_VALUE);continue}if(i!==!0)throw new Ji("Unknown option "+c,Ji.ERR_BAD_OPTION)}}const tI={assertOptions:Hgi,validators:y1},ll=tI.validators;class wI{constructor(p){this.defaults=p||{},this.interceptors={request:new Nk,response:new Nk}}async request(p,i){try{return await this._request(p,i)}catch(r){if(r instanceof Error){let a={};Error.captureStackTrace?Error.captureStackTrace(a):a=new Error;const c=a.stack?a.stack.replace(/^.+\n/,""):"";try{r.stack?c&&!String(r.stack).endsWith(c.replace(/^.+\n.+\n/,""))&&(r.stack+=`
54
- `+c):r.stack=c}catch{}}throw r}}_request(p,i){typeof p=="string"?(i=i||{},i.url=p):i=p||{},i=Tf(this.defaults,i);const{transitional:r,paramsSerializer:a,headers:c}=i;r!==void 0&&tI.assertOptions(r,{silentJSONParsing:ll.transitional(ll.boolean),forcedJSONParsing:ll.transitional(ll.boolean),clarifyTimeoutError:ll.transitional(ll.boolean),legacyInterceptorReqResOrdering:ll.transitional(ll.boolean)},!1),a!=null&&(qe.isFunction(a)?i.paramsSerializer={serialize:a}:tI.assertOptions(a,{encode:ll.function,serialize:ll.function},!0)),i.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?i.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:i.allowAbsoluteUrls=!0),tI.assertOptions(i,{baseUrl:ll.spelling("baseURL"),withXsrfToken:ll.spelling("withXSRFToken")},!0),i.method=(i.method||this.defaults.method||"get").toLowerCase();let e=c&&qe.merge(c.common,c[i.method]);c&&qe.forEach(["delete","get","head","post","put","patch","common"],N=>{delete c[N]}),i.headers=zl.concat(e,c);const f=[];let h=!0;this.interceptors.request.forEach(function(V){if(typeof V.runWhen=="function"&&V.runWhen(i)===!1)return;h=h&&V.synchronous;const j=i.transitional||Kx;j&&j.legacyInterceptorReqResOrdering?f.unshift(V.fulfilled,V.rejected):f.push(V.fulfilled,V.rejected)});const m=[];this.interceptors.response.forEach(function(V){m.push(V.fulfilled,V.rejected)});let E,b=0,A;if(!h){const N=[Kk.bind(this),void 0];for(N.unshift(...f),N.push(...m),A=N.length,E=Promise.resolve(i);b<A;)E=E.then(N[b++],N[b++]);return E}A=f.length;let _=i;for(;b<A;){const N=f[b++],V=f[b++];try{_=N(_)}catch(j){V.call(this,j);break}}try{E=Kk.call(this,_)}catch(N){return Promise.reject(N)}for(b=0,A=m.length;b<A;)E=E.then(m[b++],m[b++]);return E}getUri(p){p=Tf(this.defaults,p);const i=e2e(p.baseURL,p.url,p.allowAbsoluteUrls);return YLe(i,p.params,p.paramsSerializer)}}qe.forEach(["delete","get","head","options"],function(p){wI.prototype[p]=function(i,r){return this.request(Tf(r||{},{method:p,url:i,data:(r||{}).data}))}});qe.forEach(["post","put","patch"],function(p){function i(r){return function(c,e,f){return this.request(Tf(f||{},{method:p,headers:r?{"Content-Type":"multipart/form-data"}:{},url:c,data:e}))}}wI.prototype[p]=i(),wI.prototype[p+"Form"]=i(!0)});const iI=wI;class Wx{constructor(p){if(typeof p!="function")throw new TypeError("executor must be a function.");let i;this.promise=new Promise(function(c){i=c});const r=this;this.promise.then(a=>{if(!r._listeners)return;let c=r._listeners.length;for(;c-- >0;)r._listeners[c](a);r._listeners=null}),this.promise.then=a=>{let c;const e=new Promise(f=>{r.subscribe(f),c=f}).then(a);return e.cancel=function(){r.unsubscribe(c)},e},p(function(c,e,f){r.reason||(r.reason=new hE(c,e,f),i(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(p){if(this.reason){p(this.reason);return}this._listeners?this._listeners.push(p):this._listeners=[p]}unsubscribe(p){if(!this._listeners)return;const i=this._listeners.indexOf(p);i!==-1&&this._listeners.splice(i,1)}toAbortSignal(){const p=new AbortController,i=r=>{p.abort(r)};return this.subscribe(i),p.signal.unsubscribe=()=>this.unsubscribe(i),p.signal}static source(){let p;return{token:new Wx(function(a){p=a}),cancel:p}}}const Wgi=Wx;function zgi(l){return function(i){return l.apply(null,i)}}function Ygi(l){return qe.isObject(l)&&l.isAxiosError===!0}const P_={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(P_).forEach(([l,p])=>{P_[p]=l});const Jgi=P_;function a2e(l){const p=new iI(l),i=kLe(iI.prototype.request,p);return qe.extend(i,iI.prototype,p,{allOwnKeys:!0}),qe.extend(i,p,null,{allOwnKeys:!0}),i.create=function(a){return a2e(Tf(l,a))},i}const Mn=a2e(Zx);Mn.Axios=iI;Mn.CanceledError=hE;Mn.CancelToken=Wgi;Mn.isCancel=QLe;Mn.VERSION=n2e;Mn.toFormData=c1;Mn.AxiosError=Ji;Mn.Cancel=Mn.CanceledError;Mn.all=function(p){return Promise.all(p)};Mn.spread=zgi;Mn.isAxiosError=Ygi;Mn.mergeConfig=Tf;Mn.AxiosHeaders=zl;Mn.formToJSON=l=>JLe(qe.isHTMLForm(l)?new FormData(l):l);Mn.getAdapter=r2e.getAdapter;Mn.HttpStatusCode=Jgi;Mn.default=Mn;const Qgi=Mn;class s2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__HTTP_REQUEST,version:"1.0.0",description:"HTTP request operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(da.HttpRequest);a&&(a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[3]||{},e={method:a[0],url:a[1],params:a[2],headers:c,data:a[4]};Y.Logger.log("Axios request config: ",e);const f=await Qgi(e);return{value:U.Success,error:null,result:{status:f.status,headers:f.headers,data:f.data}}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class l2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__VALIDATE_ENTITY,version:"1.0.0",description:"Entity validate operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(Le.Validate);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)||((m=f.value)==null?void 0:m.value)});Y.Logger.log("Inputs for entity validation: ",a);const e=aD(a[1]).safeParse(a[0]);return e.success?{value:U.Success,error:null,result:{data:a[0]}}:{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:e.error.errors,result:null}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}const Ka=l=>l.map(p=>{var i,r;return((i=p.value)==null?void 0:i.valueAsType)??((r=p.value)==null?void 0:r.value)});class o2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_READ_KEY,version:"1.0.0",description:"Entity read-key operation implementation module (top-level)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(Le.ReadKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c]=Ka(r),e=M_e(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class d2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_WRITE_KEY,version:"1.0.0",description:"Entity write-key operation implementation module (top-level, immutable)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(Le.WriteKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c,e]=Ka(r),f=G_e(a,c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class u2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_DELETE_KEY,version:"1.0.0",description:"Entity delete-key operation implementation module (top-level, immutable)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(Le.DeleteKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c]=Ka(r),e=j_e(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class p2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_READ_NESTED_KEY,version:"1.0.0",description:"Entity read-nested-key operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(Le.ReadNestedKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c,e]=Ka(r),f=k_e(a,c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class c2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_WRITE_NESTED_KEY,version:"1.0.0",description:"Entity write-nested-key operation implementation module (immutable, no auto-create)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(Le.WriteNestedKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c,e]=Ka(r),f=U_e(a,c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class f2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_WRITE_SAFE_NESTED_KEY_RECURSIVELY,version:"1.0.0",description:"Entity write-safe-nested-key-recursively operation implementation module (immutable, auto-create)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(Le.WriteSafeNestedKeyRecursively);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c,e]=Ka(r),f=F_e(a,c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class y2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_DELETE_NESTED_KEY,version:"1.0.0",description:"Entity delete-nested-key operation implementation module (immutable)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(Le.DeleteNestedKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c]=Ka(r),e=K_e(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class h2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_HAS_KEY,version:"1.0.0",description:"Object has-key (top-level property present?)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(Le.HasKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=Ka(r),e=q_e(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class m2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_KEY_VALUE_EQUALS,version:"1.0.0",description:"Object key-value-equals (top-level property strict equality)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(Le.KeyValueEquals);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e]=Ka(r),f=S_e(a,c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class T2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_HAS_NESTED_KEY,version:"1.0.0",description:"Object has-nested-key (path present?)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(Le.HasNestedKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=Ka(r),e=Z_e(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class v2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_NESTED_KEY_VALUE_EQUALS,version:"1.0.0",description:"Object nested-key-value-equals (path strict equality)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(Le.NestedKeyValueEquals);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e]=Ka(r),f=H_e(a,c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class E2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_IS_INSTANCE_OF_TYPE,version:"1.0.0",description:"Object is-instance-of-type (DefinitionEntity-based runtime check)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(Le.IsInstanceOfType);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e,f,h,m,E,b,A,_;try{const N=((c=(a=r[0])==null?void 0:a.value)==null?void 0:c.parent)||((f=(e=r[0])==null?void 0:e.value)==null?void 0:f.standaloneParent),V=(m=(h=r[0])==null?void 0:h.value)==null?void 0:m.value,j=(b=(E=r[1])==null?void 0:E.value)==null?void 0:b.valueAsTypeSingle;if(!V)throw new TypeError("IsInstanceOfType expects a non-null input value.");if(!j)throw new TypeError("IsInstanceOfType expects a valid expectedType input.");if(!N)throw new TypeError("IsInstanceOfType cannot determine the value owner.");if(j.type!==d.DefinitionEntity)throw new TypeError("IsInstanceOfType expects expectedType to be a DefinitionEntity.");const M=N.getDataType(null);if(((A=M==null?void 0:M.entity)==null?void 0:A.type)!==d.DefinitionEntity)throw new TypeError("IsInstanceOfType cannot determine the data type of the input value.");let G=!1;return((_=M==null?void 0:M.entity)==null?void 0:_.id)!==(j==null?void 0:j.id)?G=!1:aD(M==null?void 0:M.entity).safeParse(V).success?G=!0:G=!1,{value:U.Success,error:null,result:G}}catch(N){return{value:U.UnhandledError,error:N,result:null}}}})}}class b2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_MERGE,version:"1.0.0",description:"Object merge operation implementation module (immutable, shallow merge with right-precedence)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(Le.Merge);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const a=Ka(r),c=W_e(...a);return{value:U.Success,error:null,result:c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class A2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_KEYS,version:"1.0.0",description:"Object keys operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(Le.Keys);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=Ka(r),c=z_e(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class I2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_VALUES,version:"1.0.0",description:"Object values operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(Le.Values);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=Ka(r),c=Y_e(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class g2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_ENTRIES,version:"1.0.0",description:"Object entries operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(Le.Entries);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=Ka(r),c=J_e(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}let Ns=null;try{Ns=require("crypto")}catch{}const xT=typeof globalThis<"u"&&globalThis.crypto&&globalThis.crypto.subtle?globalThis.crypto:Ns&&Ns.webcrypto?Ns.webcrypto:null,dp=xT?xT.subtle:null;function ZT(l){const p=new ArrayBuffer(l.byteLength);return new Uint8Array(p).set(l),p}function dn(l,p="utf8"){if(l instanceof Uint8Array)return l;const i=String(l);if(p==="utf8"){if(typeof TextEncoder<"u")return new TextEncoder().encode(i);if(typeof Buffer<"u")return new Uint8Array(Buffer.from(i,"utf8"))}else if(p==="hex"){if(typeof Buffer<"u")return new Uint8Array(Buffer.from(i,"hex"))}else if(p==="base64"){if(typeof Buffer<"u")return new Uint8Array(Buffer.from(i,"base64"))}else if(p==="base64url"){const r=i.replace(/-/g,"+").replace(/_/g,"/").replace(/=+$/,"");if(typeof Buffer<"u")return new Uint8Array(Buffer.from(r,"base64"));const a=typeof atob=="function"?atob(r):"",c=new Uint8Array(a.length);for(let e=0;e<a.length;e++)c[e]=a.charCodeAt(e);return c}throw new Error(`Unsupported environment/encoding combo for toBytes(${p})`)}function Po(l,p="utf8"){if(p==="utf8"){if(typeof TextDecoder<"u")return new TextDecoder().decode(l);if(typeof Buffer<"u")return Buffer.from(l).toString("utf8")}else if(p==="hex"){if(typeof Buffer<"u")return Buffer.from(l).toString("hex")}else if(p==="base64"){if(typeof Buffer<"u")return Buffer.from(l).toString("base64")}else if(p==="base64url"&&typeof Buffer<"u")return Buffer.from(l).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");throw new Error(`Unsupported environment/encoding combo for fromBytes(${p})`)}const R2e=l=>dn(l,"base64"),D2e=(l,p)=>{const i=l instanceof Uint8Array?l:dn(String(l),p||"utf8");return Po(i,"base64")},Th=(l,p)=>{const i=l instanceof Uint8Array?l:dn(String(l),p||"utf8");return Po(i,"base64url")},vf=l=>dn(l,"base64url"),w2e=(l,p)=>{const i=l instanceof Uint8Array?l:dn(String(l),p||"utf8");return Po(i,"hex")},C2e=l=>dn(l,"hex");function zx(l){if(xT&&xT.getRandomValues){const p=new Uint8Array(l);return xT.getRandomValues(p),p}if(Ns&&Ns.randomBytes)return new Uint8Array(Ns.randomBytes(l));throw new Error("Secure random not available")}function h1(l,p){if(!(l instanceof Uint8Array)||!(p instanceof Uint8Array)||l.length!==p.length)return!1;let i=0;for(let r=0;r<l.length;r++)i|=l[r]^p[r];return i===0}function O2e(l,p,i,r){if((typeof l!="string"||typeof p!="string")&&typeof l!="string"&&typeof p!="string")throw new Error("Invalid input types");const a=i??"utf8",c=r??"utf8",e=dn(l??"",a),f=dn(p??"",c);return h1(e,f)}async function _2e(l,p){if(dp){const i=await dp.digest({name:l},ZT(p));return new Uint8Array(i)}if(Ns){const i=l.replace("SHA-","sha"),r=Ns.createHash(i);return r.update(Buffer.from(p)),new Uint8Array(r.digest())}throw new Error("Hash not available")}async function V2e(l,p,i,r){if(typeof p!="string")throw new Error("Invalid input type for data; expected string");const a=String(l??"SHA-256"),c=i??"utf8",e=r??"base64url",f=dn(p??"",c),h=await _2e(a,f);return Po(h,e)}async function m1(l,p,i){if(dp){const r=await dp.importKey("raw",ZT(p),{name:"HMAC",hash:{name:l}},!1,["sign"]),a=await dp.sign("HMAC",r,ZT(i));return new Uint8Array(a)}if(Ns){const r=`sha${l.split("-")[1]}`,a=Ns.createHmac(r,Buffer.from(p));return a.update(Buffer.from(i)),new Uint8Array(a.digest())}throw new Error("HMAC not available")}async function P2e(l,p,i,r,a,c){if(typeof l!="string"||typeof p!="string")throw new Error("Invalid input types for key or data; expected strings");const e=String(i??"SHA-256"),f=r??"utf8",h=a??"utf8",m=c??"base64url",E=dn(l??"",f),b=dn(p??"",h),A=await m1(e,E,b);return Po(A,m)}async function T1(l,p,{iterations:i,length:r,hashAlg:a="SHA-256"}){if(dp){const c=await dp.importKey("raw",ZT(l),"PBKDF2",!1,["deriveBits"]),e=await dp.deriveBits({name:"PBKDF2",salt:ZT(p),iterations:i,hash:a},c,r*8);return new Uint8Array(e)}if(Ns){const c=a==="SHA-512"?"sha512":"sha256";return await new Promise((e,f)=>{Ns.pbkdf2(Buffer.from(l),Buffer.from(p),i,r,c,(h,m)=>{h?f(h):e(new Uint8Array(m))})})}throw new Error("PBKDF2 not available")}async function N2e(l,p,i,r,a,c,e,f){if(typeof l!="string"||typeof p!="string")throw new Error("Invalid input types for password or salt; expected strings");const h=c??"utf8",m=e??"utf8",E=f??"base64url",b=Math.max(1,Number(i)||21e4),A=Math.max(1,Number(r)||32),_=a??"SHA-256",N=dn(l??"",h),V=dn(p??"",m),j=await T1(N,V,{iterations:b,length:A,hashAlg:_});return Po(j,E)}async function x2e(l,p=zx(16),i=21e4,r=32,a="SHA-256"){const c=dn(l,"utf8"),e=await T1(c,p,{iterations:i,length:r,hashAlg:a}),f=Th(p),h=Th(e);return`pbkdf2$${a.toLowerCase()}$${i}$${f}$${h}`}async function $2e(l,p){const i=String(p).split("$");if(i.length!==5||i[0]!=="pbkdf2")return!1;const r=i[1].toLowerCase(),a=parseInt(i[2],10),c=vf(i[3]),e=vf(i[4]),f=r.includes("512")?"SHA-512":"SHA-256",h=await T1(dn(l,"utf8"),c,{iterations:a,length:e.length,hashAlg:f});return h1(h,e)}async function L2e(l,p,i,r,a,c){const e=p!=null?Math.max(1,Number(p)||0):void 0,f=i!=null?Math.max(1,Number(i)||0):void 0,h=r??void 0,m=c??"base64url",E=a!=null?dn(a,m):void 0;return await x2e(String(l??""),E,e,f,h)}function Sk(l){return Th(dn(JSON.stringify(l),"utf8"))}function CI(l){try{return JSON.parse(Po(vf(l),"utf8"))}catch{return null}}async function B2e(l,p,{alg:i="HS256",includeIat:r=!0,expiresInSeconds:a,notBeforeSeconds:c,issuer:e,subject:f,audience:h,jwtid:m,header:E={}}={}){const b={alg:i,typ:"JWT",...E},A=Math.floor(Date.now()/1e3),_={...l||{}};r&&(_.iat=A),typeof a=="number"&&(_.exp=A+a),typeof c=="number"&&(_.nbf=A+c),e&&(_.iss=e),f&&(_.sub=f),h&&(_.aud=h),m&&(_.jti=m);const N=Sk(b),V=Sk(_),j=dn(`${N}.${V}`,"utf8"),G=await m1(i==="HS512"?"SHA-512":i==="HS384"?"SHA-384":"SHA-256",p,j),q=Th(G);return`${N}.${V}.${q}`}async function M2e(l,p,i,r,a,c,e,f,h,m,E,b){if(typeof p!="string")throw new Error("Invalid input type for secret; expected string");if(l!=null&&typeof l!="object")throw new Error("Invalid input type for payload; expected object");if(E!=null&&typeof E!="object")throw new Error("Invalid input type for header; expected object");if(m!=null&&typeof m!="string")throw new Error("Invalid input type for jwtid; expected string");if(e!=null&&typeof e!="string")throw new Error("Invalid input type for issuer; expected string");if(f!=null&&typeof f!="string")throw new Error("Invalid input type for subject; expected string");if(h!=null&&typeof h!="string"&&!Array.isArray(h))throw new Error("Invalid input type for audience; expected string or string[]");const _=dn(p??"",b??"utf8");return await B2e(l??{},_,{alg:i??"HS256",includeIat:r==null?!0:!!r,expiresInSeconds:a!=null?Number(a):void 0,notBeforeSeconds:c!=null?Number(c):void 0,issuer:e??void 0,subject:f??void 0,audience:h??void 0,jwtid:m??void 0,header:E??void 0})}async function G2e(l,p,{alg:i="HS256",issuer:r,audience:a,maxAgeSeconds:c,clockSkewSeconds:e=60}={}){try{const[f,h,m]=String(l).split(".");if(!f||!h||!m)return{valid:!1,header:null,payload:null,reason:"Malformed"};const E=CI(f),b=CI(h);if(!E||!b)return{valid:!1,header:E,payload:b,reason:"Bad base64/json"};if(E.alg!==i)return{valid:!1,header:E,payload:b,reason:"Alg mismatch"};const A=dn(`${f}.${h}`,"utf8"),N=await m1(i==="HS512"?"SHA-512":i==="HS384"?"SHA-384":"SHA-256",p,A),V=vf(m);if(!h1(N,V))return{valid:!1,header:E,payload:b,reason:"Bad signature"};const j=Math.floor(Date.now()/1e3),M=Math.max(0,Number(e)||0);if(b.nbf!=null&&j+M<Number(b.nbf))return{valid:!1,header:E,payload:b,reason:"Not before"};if(b.exp!=null&&j-M>=Number(b.exp))return{valid:!1,header:E,payload:b,reason:"Expired"};if(r&&b.iss!==r)return{valid:!1,header:E,payload:b,reason:"Issuer mismatch"};if(a){const G=b.aud;if(!(Array.isArray(G)?G.includes(a):G===a))return{valid:!1,header:E,payload:b,reason:"Audience mismatch"}}return c!=null&&b.iat!=null&&j-Number(b.iat)>Number(c)+M?{valid:!1,header:E,payload:b,reason:"MaxAge exceeded"}:{valid:!0,header:E,payload:b}}catch(f){return{valid:!1,header:null,payload:null,reason:String((f==null?void 0:f.message)??f)}}}async function j2e(l,p,i,r,a,c,e,f){if(typeof l!="string")throw new Error("Invalid input type for token; expected string");if(typeof p!="string")throw new Error("Invalid input type for secret; expected string");if(typeof r!="string")throw new Error("Invalid input type for issuer; expected string");if(a!=null&&typeof a!="string")throw new Error("Invalid input type for audience; expected string");const m=dn(p??"",f??"utf8");return await G2e(String(l??""),m,{alg:i??"HS256",issuer:r??void 0,audience:a??void 0,maxAgeSeconds:c!=null?Number(c):void 0,clockSkewSeconds:e!=null?Number(e):void 0})}function k2e(l){const[p,i,r]=String(l).split(".");return{header:p?CI(p):null,payload:i?CI(i):null,signature:r?vf(r):new Uint8Array}}function U2e(l,p){if(!l)throw new Error("Token is required for decoding");if(typeof l!="string")throw new Error("Invalid input type for token; expected string");const i=p??"base64url",{header:r,payload:a,signature:c}=k2e(String(l??"")),e=Po(c,i);return{header:r,payload:a,signature:e}}class F2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_GENERATE_RANDOM_BYTES,version:"1.0.0",description:"Randomness generate random bytes operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(nt.GenerateRandomBytes);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(E=>{var b,A;return((b=E.value)==null?void 0:b.valueAsType)??((A=E.value)==null?void 0:A.value)}),e=Math.max(0,Number(a)||0),f=c??"base64url",h=zx(e),m=Po(h,f);return{value:U.Success,error:null,result:m}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class K2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_INTEGER,version:"1.0.0",description:"Randomness generate random integer operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(nt.GenerateRandomInteger);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1],f=E_e(c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class q2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_FLOAT,version:"1.0.0",description:"Randomness generate random float operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(nt.GenerateRandomFloat);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=n1();return{value:U.Success,error:null,result:a}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class S2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_HEXADECIMAL,version:"1.0.0",description:"Randomness generate random hexadecimal operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(nt.GenerateRandomHexadecimal);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)||((m=f.value)==null?void 0:m.value)})[0],e=Rx(c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class Z2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_BASE62,version:"1.0.0",description:"Randomness generate random base62 operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(nt.GenerateRandomBase62);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)||((m=f.value)==null?void 0:m.value)})[0],e=Dx(c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class H2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_BASE64,version:"1.0.0",description:"Randomness generate random base64 operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(nt.GenerateRandomBase64);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)||((m=f.value)==null?void 0:m.value)})[0],e=A_e(c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class W2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_ALPHANUMERIC,version:"1.0.0",description:"Randomness generate random alphanumeric operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(nt.GenerateRandomAlphanumeric);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)||((m=f.value)==null?void 0:m.value)})[0],e=wx(c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class z2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_IDENTIFIER,version:"1.0.0",description:"Generate identifier operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(nt.GenerateIdentifier);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1],f=Cx(c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class Y2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_UUIDV4,version:"1.0.0",description:"Generate UUID v4 operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(nt.GenerateRandomUUIDv4);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=op();return{value:U.Success,error:null,result:a}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class J2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_SHORT_IDENTIFIER,version:"1.0.0",description:"Generate short identifier operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{Y.Logger.log("Initializing Random Generate Short Identifier Module");const r=i.find(a=>a.contextType===ae.Logic);if(r){Y.Logger.log("Project state found, setting up operation");const a=r.get(nt.GenerateShortIdentifier);a?(Y.Logger.log("Operation found, setting autoexecutable and implementation"),a.autoexecutable=!0,a.implementation=this.module.main):Y.Logger.warn("Operation generate-short-identifier not found in project state")}else Y.Logger.warn("Project state not found in contexts for Random Generate Short Identifier Module")},main:async(i,r)=>{try{const a=I_e();return{value:U.Success,error:null,result:a}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class Q2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_HEXADECIMAL_TOKEN,version:"1.0.0",description:"Generate hexadecimal token operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(nt.GenerateHexadecimalToken);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=g_e();return{value:U.Success,error:null,result:a}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}function Xgi(l){let p;if(l===null?p="null":Array.isArray(l)?p="array":p=typeof l,!["string","number","boolean","null","object","array"].includes(p))throw new TypeError("GetTypeOf cannot determine type of the given value.");return p}class X2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_GET_TYPE_OF,version:"1.0.0",description:"Data type get type of operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(Qe.GetTypeOf);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)||((h=e.value)==null?void 0:h.value)})[0];return{value:U.Success,error:null,result:Xgi(c)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class eBe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_TO_STRING,version:"1.0.0",description:"Coerce any value to string via JS String(value)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(Qe.ToString);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)??((h=e.value)==null?void 0:h.value)}),c=String(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class tBe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_TO_NUMBER,version:"1.0.0",description:"Coerce to number via JS Number(value)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(Qe.ToNumber);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)??((h=e.value)==null?void 0:h.value)}),c=Number(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class iBe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_TO_BYTES,version:"1.0.0",description:"Convert string/bytes-like to Uint8Array (utf8|hex|base64|base64url)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(Qe.ToBytes);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)??((E=h.value)==null?void 0:E.value)}),f=dn(a,c||"utf8");return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class rBe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_FROM_BYTES_TO_STRING,version:"1.0.0",description:"Convert Uint8Array to string (utf8|hex|base64|base64url)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(Qe.FromBytesToString);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)??((E=h.value)==null?void 0:E.value)}),f=Po(a,c||"utf8");return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class nBe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_ENCODE_BASE64,version:"1.0.0",description:"Bytes -> base64 string (accepts string input by converting from utf8)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(Qe.EncodeBase64);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)??((h=e.value)==null?void 0:h.value)});return{value:U.Success,error:null,result:D2e(a,c)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class aBe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_DECODE_BASE64,version:"1.0.0",description:"base64 string -> bytes (Uint8Array)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(Qe.DecodeBase64);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)??((h=e.value)==null?void 0:h.value)}),c=R2e(String(a));return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class sBe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_ENCODE_BASE64URL,version:"1.0.0",description:"Bytes -> base64url string (accepts string input by converting from utf8)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(Qe.EncodeBase64Url);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)??((m=f.value)==null?void 0:m.value)}),e=Th(a,c||"utf8");return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class lBe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_DECODE_BASE64URL,version:"1.0.0",description:"base64url string -> bytes (Uint8Array)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(Qe.DecodeBase64Url);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)??((h=e.value)==null?void 0:h.value)}),c=vf(String(a));return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class oBe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_ENCODE_HEX,version:"1.0.0",description:"Bytes -> hex string (accepts string input by converting from utf8)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(Qe.EncodeHex);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)??((m=f.value)==null?void 0:m.value)}),e=w2e(a,c||"utf8");return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class dBe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_DECODE_HEX,version:"1.0.0",description:"hex string -> bytes (Uint8Array)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(Qe.DecodeHex);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)??((h=e.value)==null?void 0:h.value)}),c=C2e(String(a));return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class uBe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_HASH,version:"1.0.0",description:"Crypto: Hash (SHA-256/384/512)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(Pi.Hash);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e,f]=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)??((E=h.value)==null?void 0:E.value)});return{value:U.Success,error:null,result:V2e(a,c,e,f)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class pBe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_HMAC,version:"1.0.0",description:"Crypto: HMAC (SHA-256/384/512)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(Pi.Hmac);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e,f,h,m]=r.map(E=>{var b,A;return((b=E.value)==null?void 0:b.valueAsType)??((A=E.value)==null?void 0:A.value)});return{value:U.Success,error:null,result:P2e(c,e,a,f,h,m)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class cBe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_CONSTANT_TIME_EQUAL,version:"1.0.0",description:"Crypto: constant-time equality for byte sequences",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(Pi.ConstantTimeEqual);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e,f]=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)??((E=h.value)==null?void 0:E.value)});return{value:U.Success,error:null,result:O2e(a,c,e,f)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class fBe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_DERIVE_KEY_PBKDF2,version:"1.0.0",description:"Crypto: derive key with PBKDF2 (SHA-256/512)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(Pi.DeriveKeyPBKDF2);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e,f,h,m,E,b]=r.map(A=>{var _,N;return((_=A.value)==null?void 0:_.valueAsType)??((N=A.value)==null?void 0:N.value)});return{value:U.Success,error:null,result:N2e(a,c,e,f,h,m,E,b)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class yBe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_IN_OPERATIONS_IMPLEMENTATIONS__JSON_PARSE,version:"1.0.0",description:"Json parse string into object operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(fn.Parse);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{var a;try{const c=(a=r[0].value)==null?void 0:a.value;if(typeof c!="string")throw new Error(`Invalid input type for JSON.parse operation: expected string, got ${typeof c}`);const e=JSON.parse(c);return{value:U.Success,error:null,result:e}}catch(c){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:c,result:null}}}})}}class hBe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_IN_OPERATIONS_IMPLEMENTATIONS__JSON_STRINGIFY,version:"1.0.0",description:"Json stringify object into string operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(fn.Stringify);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{var a,c;try{const e=(a=r[0].value)==null?void 0:a.value,f=(c=r[1].value)==null?void 0:c.value;if(!e||typeof e!="object"&&!Array.isArray(e))throw new Error(`Invalid input type for JSON.stringify operation: expected object or array, got ${typeof e}`);if(!f&&f!==0){const m=JSON.stringify(e);return{value:U.Success,error:null,result:m}}const h=JSON.stringify(e,null,f);return{value:U.Success,error:null,result:h}}catch(e){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:e,result:null}}}})}}class mBe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__JWT_BUILD_HMAC,version:"1.0.0",description:"JWT: build (HS256/384/512)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ur.BuildJwtHmac);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e,f,h,m,E,b,A,_,N,V]=r.map(j=>{var M,G;return((M=j.value)==null?void 0:M.valueAsType)??((G=j.value)==null?void 0:G.value)});return{value:U.Success,error:null,result:await M2e(a,c,e,f,h,m,E,b,A,_,N,V)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class TBe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__JWT_VERIFY_HMAC,version:"1.0.0",description:"JWT: verify (HS256/384/512)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ur.VerifyJwtHmac);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e,f,h,m,E,b]=r.map(A=>{var _,N;return((_=A.value)==null?void 0:_.valueAsType)??((N=A.value)==null?void 0:N.value)});return{value:U.Success,error:null,result:await j2e(a,c,e,f,h,m,E,b)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class vBe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__JWT_DECODE,version:"1.0.0",description:"JWT: decode (no verification)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ur.DecodeJwt);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)??((h=e.value)==null?void 0:h.value)});return{value:U.Success,error:null,result:U2e(a,c)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class EBe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__PASSWORD_HASH_PBKDF2,version:"1.0.0",description:"Password: hash (PBKDF2) -> envelope string",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(yn.HashPasswordPBKDF2);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e,f,h,m]=r.map(E=>{var b,A;return((b=E.value)==null?void 0:b.valueAsType)??((A=E.value)==null?void 0:A.value)});return{value:U.Success,error:null,result:await L2e(a,c,e,f,h,m)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class bBe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__PASSWORD_VERIFY_PBKDF2,version:"1.0.0",description:"Password: verify (PBKDF2) -> boolean",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(yn.VerifyPasswordPBKDF2);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)??((m=f.value)==null?void 0:m.value)}),e=await $2e(String(a??""),String(c??""));return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class N_ extends o1{constructor(p,i,r=i.projectId){super(p,ae.Editor),this._editor=i,this.id=r}get ready(){return this._editor.ready}get hasLoadedLogic(){return this._editor.hasLoadedLogic}get destroyed(){return this._editor.destroyed}get logicLoadingPromise(){return this._editor.logicLoadingPromise}get logic(){return this._editor.logic}get lastPublishedProjectState(){return this._editor.lastPublishedProjectState}get branch(){return this._editor.branch}get projectId(){return this._editor.projectId}get sessionId(){return this._editor.sessionId}get userAuthorId(){return this._editor.userAuthorId}get peerConnections(){return this._editor.peerConnections}get test(){return this._editor.test}get localTestValues(){return this._editor.localTestValues}get resolvedValues(){return this._editor.resolvedValues}get persistedExecutionResults(){return this._editor.persistedExecutionResults}get publication(){return this._editor.publication}get livePublishedVersions(){return this._editor.livePublishedVersions}get publications(){return this._editor.publications}get liveResources(){return this._editor.liveResources}get execution(){return this._editor.execution}get project(){return this._editor.logic}get lastExecutionResults(){return this._editor.lastExecutionResults}get undoableStackValueIndex(){return this._editor.undoableStackValueIndex}set undoableStackValueIndex(p){this._editor.undoableStackValueIndex=p}get PROJECT_NOTIFICATIONS_CHANNEL(){return this._editor.PROJECT_NOTIFICATIONS_CHANNEL}getAccessToken(){return this._editor.getAccessToken()}getRefreshToken(){return this._editor.getRefreshToken()}removeValueByOwnerId(p){return this._editor.removeValueByOwnerId(p)}removeValue(p){return this._editor.removeValue(p)}undo(){return this._editor.undo()}redo(){return this._editor.redo()}initTest(p,i){return this._editor.initTest(p,i)}removeTest(p){return this._editor.removeTest(p)}async copyEntities(p,i={}){return this._editor.copyEntities(p,i)}resolveInitialChildrenPositions(p,i,r){return this._editor.resolveInitialChildrenPositions(p,i,r)}publish(){return this._editor.publish()}loadGivenPublication(p){return this._editor.loadGivenPublication(p)}validateProjectState(p){return this._editor.validateProjectState(p)}requestActiveDynamicValue(p,i=!1){return this._editor.requestActiveDynamicValue(p,i)}getValueTypePreference(p){return this._editor.getValueTypePreference(p)}setValueTypePreference(p,i){return this._editor.setValueTypePreference(p,i)}implementFeature(p){return this._editor.implementFeature(p)}}function eRi(l,p){return p instanceof N_?p:new N_(l,p)}class x_ extends o1{constructor(p,i){super(p,ae.PublicationRun),this._publicationRun=i}get id(){return this._publicationRun.id}get projectAutoIncrementPublicationCount(){return this._publicationRun.projectAutoIncrementPublicationCount}get projectPublishedSemanticVersion(){return this._publicationRun.projectPublishedSemanticVersion}get projectVersion(){return this._publicationRun.projectVersion}get projectId(){return this._publicationRun.projectId}get triggeredBy(){return this._publicationRun.triggeredBy}get createdAt(){return this._publicationRun.createdAt}get updatedAt(){return this._publicationRun.updatedAt}get status(){return this._publicationRun.status}get steps(){return this._publicationRun.steps}get editor(){return this._publicationRun.editor}get explicitResources(){return this._publicationRun.explicitResources}get implicitGlobalResources(){return this._publicationRun.implicitGlobalResources}get finalGlobalEvent(){return this._publicationRun.finalGlobalEvent}get finalStatus(){return this._publicationRun.finalStatus}}function tRi(l,p){return p instanceof x_?p:new x_(l,p)}function iRi(l){l.register(new vVe(l)),l.register(new TVe(l)),l.register(new fVe(l)),l.register(new hVe(l)),l.register(new mVe(l)),l.register(new yVe(l)),l.register(new X$e(l)),l.register(new eLe(l)),l.register(new tLe(l)),l.register(new rLe(l)),l.register(new iLe(l)),l.register(new nLe(l)),l.register(new K2e(l)),l.register(new q2e(l)),l.register(new S2e(l)),l.register(new Z2e(l)),l.register(new H2e(l)),l.register(new W2e(l)),l.register(new z2e(l)),l.register(new Y2e(l)),l.register(new J2e(l)),l.register(new Q2e(l)),l.register(new Qxe(l)),l.register(new Xxe(l)),l.register(new e$e(l)),l.register(new t$e(l)),l.register(new i$e(l)),l.register(new r$e(l)),l.register(new n$e(l)),l.register(new a$e(l)),l.register(new s$e(l)),l.register(new l$e(l)),l.register(new o$e(l)),l.register(new d$e(l)),l.register(new u$e(l)),l.register(new p$e(l)),l.register(new c$e(l)),l.register(new f$e(l)),l.register(new y$e(l)),l.register(new h$e(l)),l.register(new m$e(l)),l.register(new E$e(l)),l.register(new b$e(l)),l.register(new A$e(l)),l.register(new vxe(l)),l.register(new Exe(l)),l.register(new bxe(l)),l.register(new Axe(l)),l.register(new Ixe(l)),l.register(new gxe(l)),l.register(new Rxe(l)),l.register(new Dxe(l)),l.register(new wxe(l)),l.register(new Oxe(l)),l.register(new _xe(l)),l.register(new Vxe(l)),l.register(new Pxe(l)),l.register(new Nxe(l)),l.register(new MNe(l)),l.register(new l2e(l)),l.register(new s2e(l)),l.register(new BPe(l)),l.register(new MPe(l)),l.register(new GPe(l)),l.register(new jPe(l)),l.register(new kPe(l)),l.register(new UPe(l)),l.register(new FPe(l)),l.register(new KPe(l)),l.register(new qPe(l)),l.register(new rNe(l)),l.register(new $Ne(l)),l.register(new LNe(l)),l.register(new BNe(l)),l.register(new SPe(l)),l.register(new ZPe(l)),l.register(new HPe(l)),l.register(new WPe(l)),l.register(new zPe(l)),l.register(new YPe(l)),l.register(new JPe(l)),l.register(new QPe(l)),l.register(new XPe(l)),l.register(new eNe(l)),l.register(new tNe(l)),l.register(new iNe(l)),l.register(new nNe(l)),l.register(new aNe(l)),l.register(new sNe(l)),l.register(new lNe(l)),l.register(new oNe(l)),l.register(new dNe(l)),l.register(new uNe(l)),l.register(new pNe(l)),l.register(new cNe(l)),l.register(new fNe(l)),l.register(new yNe(l)),l.register(new hNe(l)),l.register(new RNe(l)),l.register(new DNe(l)),l.register(new wNe(l)),l.register(new mNe(l)),l.register(new TNe(l)),l.register(new vNe(l)),l.register(new ENe(l)),l.register(new bNe(l)),l.register(new ANe(l)),l.register(new INe(l)),l.register(new gNe(l)),l.register(new p2e(l)),l.register(new c2e(l)),l.register(new f2e(l)),l.register(new y2e(l)),l.register(new o2e(l)),l.register(new d2e(l)),l.register(new u2e(l)),l.register(new h2e(l)),l.register(new T2e(l)),l.register(new E2e(l)),l.register(new m2e(l)),l.register(new v2e(l)),l.register(new b2e(l)),l.register(new g2e(l)),l.register(new A2e(l)),l.register(new I2e(l)),l.register(new xxe(l)),l.register(new Mxe(l)),l.register(new Gxe(l)),l.register(new Uxe(l)),l.register(new Fxe(l)),l.register(new Kxe(l)),l.register(new qxe(l)),l.register(new Sxe(l)),l.register(new Zxe(l)),l.register(new Hxe(l)),l.register(new Wxe(l)),l.register(new jxe(l)),l.register(new kxe(l)),l.register(new Lxe(l)),l.register(new Bxe(l)),l.register(new $xe(l)),l.register(new Cxe(l)),l.register(new Yxe(l)),l.register(new Jxe(l)),l.register(new zxe(l)),l.register(new sLe(l)),l.register(new VLe(l)),l.register(new _Le(l)),l.register(new PLe(l)),l.register(new NLe(l)),l.register(new dLe(l)),l.register(new uLe(l)),l.register(new mLe(l)),l.register(new yLe(l)),l.register(new CLe(l)),l.register(new ALe(l)),l.register(new gLe(l)),l.register(new DLe(l)),l.register(new RLe(l)),l.register(new hLe(l)),l.register(new vLe(l)),l.register(new ELe(l)),l.register(new TLe(l)),l.register(new aLe(l)),l.register(new pLe(l)),l.register(new ILe(l)),l.register(new LLe(l)),l.register(new C_(l)),l.register(new oLe(l)),l.register(new cLe(l)),l.register(new lLe(l)),l.register(new wLe(l)),l.register(new fLe(l)),l.register(new bLe(l)),l.register(new OLe(l)),l.register(new $Le(l)),l.register(new xLe(l)),l.register(new BLe(l)),l.register(new C_(l)),l.register(new GLe(l)),l.register(new MLe(l)),l.register(new jLe(l)),l.register(new B$e(l)),l.register(new M$e(l)),l.register(new G$e(l)),l.register(new g$e(l)),l.register(new v$e(l)),l.register(new C$e(l)),l.register(new P$e(l)),l.register(new T$e(l)),l.register(new N$e(l)),l.register(new L$e(l)),l.register(new _$e(l)),l.register(new O$e(l)),l.register(new RI(l)),l.register(new j$e(l)),l.register(new k$e(l)),l.register(new V$e(l)),l.register(new $$e(l)),l.register(new x$e(l)),l.register(new w$e(l)),l.register(new D$e(l)),l.register(new R$e(l)),l.register(new I$e(l)),l.register(new K$e(l)),l.register(new F$e(l)),l.register(new q$e(l)),l.register(new U$e(l)),l.register(new VNe(l)),l.register(new CNe(l)),l.register(new _Ne(l)),l.register(new PNe(l)),l.register(new NNe(l)),l.register(new ONe(l)),l.register(new xNe(l)),l.register(new X2e(l)),l.register(new aBe(l)),l.register(new lBe(l)),l.register(new dBe(l)),l.register(new nBe(l)),l.register(new sBe(l)),l.register(new oBe(l)),l.register(new rBe(l)),l.register(new iBe(l)),l.register(new tBe(l)),l.register(new eBe(l)),l.register(new yBe(l)),l.register(new hBe(l)),l.register(new cBe(l)),l.register(new fBe(l)),l.register(new F2e(l)),l.register(new uBe(l)),l.register(new pBe(l)),l.register(new TBe(l)),l.register(new mBe(l)),l.register(new vBe(l)),l.register(new EBe(l)),l.register(new bBe(l)),l.register(new bVe(l)),l.register(new AVe(l)),l.register(new II(l)),l.register(new gI(l))}class Yx{constructor(p=new Y.Events("extensions-registry-fallback-events")){R(this,"extensionsRegistry",new Map);R(this,"initialized",new Set);R(this,"initializedContexts",new Set);R(this,"onResolveEditorContextCallback",()=>null);R(this,"onResolveProjectLogicContextCallback",()=>null);R(this,"onResolveEditorGUIContextCallback",()=>null);R(this,"onResolveGUIContextCallback",()=>null);R(this,"onResolveCompileContextCallback",()=>null);R(this,"onResolvePublicationRunContextCallback",()=>null);this.events=p,this.off=this.events.off.bind(this.events),this.on=this.events.on.bind(this.events),this.emit=this.events.emit.bind(this.events),this.emitAsync=this.events.emitAsync.bind(this.events),this.emitAsyncAll=this.events.emitAsyncAll.bind(this.events),this.emitAsyncAllSettled=this.events.emitAsyncAllSettled.bind(this.events),this.emitAsyncSequentially=this.events.emitAsyncSequentially.bind(this.events),this.emitAsyncSequentiallyAll=this.events.emitAsyncSequentiallyAll.bind(this.events),this.emitAsyncSequentiallyAllSettled=this.events.emitAsyncSequentiallyAllSettled.bind(this.events)}onResolveEditorContext(p){this.onResolveEditorContextCallback=p}onResolveProjectLogicContext(p){this.onResolveProjectLogicContextCallback=p}onResolveGUIContext(p){this.onResolveGUIContextCallback=p}onResolveEditorGUIContext(p){this.onResolveEditorGUIContextCallback=p}onResolveCompileContext(p){this.onResolveCompileContextCallback=p}onResolvePublicationRunContext(p){this.onResolvePublicationRunContextCallback=p}get extensionInOrder(){return Array.from(this.extensionsRegistry.values()).sort((p,i)=>(p.manifest.initPriority||Oe.Normal)-(i.manifest.initPriority||Oe.Normal))}async setup(){iRi(this),Y.Logger.log("Initializing extensions without context..."),this.initForReady()}requestContext(p){switch(p){case ae.Editor:return this.onResolveEditorContextCallback();case ae.Logic:return this.onResolveProjectLogicContextCallback();case ae.EditorGUI:return this.onResolveEditorGUIContextCallback();case ae.Compile:return this.onResolveCompileContextCallback();case ae.PublicationRun:return this.onResolvePublicationRunContextCallback();case ae.GUI:return this.onResolveGUIContextCallback();case ae.EditorGUI:return this.onResolveEditorGUIContextCallback();default:throw new Error(`Unknown context type: ${p}`)}}requestContexts(p,i=[]){const r=[];i.length===0&&(i=p.manifest.contexts);for(const a of i){const c=this.requestContext(a);c&&r.push(c)}return r}requestExtension(p){const i=this.extensionsRegistry.get(p);if(i)return i;throw new Error(`Unknown extension: ${p}`)}register(p){this.extensionsRegistry.set(p.manifest.id,p)}async initAll(){var p,i;for(const r of this.extensionInOrder)if(r.module.init&&!this.initialized.has(r.manifest.id)){const a=r.manifest.contexts.map(c=>this.requestContext(c)).filter(c=>c!==null);a.length&&(await((i=(p=r.module).init)==null?void 0:i.call(p,a)),this.initialized.add(r.manifest.id))}else!r.module.init&&!this.initialized.has(r.manifest.id)&&this.initialized.add(r.manifest.id)}async initForReady(){Y.Logger.log("Initializing extensions for ready contexts...");for(const p of this.extensionInOrder)if(p.module.init&&!this.initialized.has(p.manifest.id)){Y.Logger.log("Initializing "+p.manifest.id+" extension...");const i=this.requestContexts(p);p.manifest.contexts.every(a=>!!i.find(c=>c.contextType===a))?(await p.module.init(i),this.initialized.add(p.manifest.id)):Y.Logger.warn(`Skipping initialization of ${p.manifest.id} extension, not all contexts are ready.`,`Required contexts: ${p.manifest.contexts.join(", ")}`,`Available contexts: ${i.map(a=>a.contextType).join(", ")}`)}else!p.module.init&&!this.initialized.has(p.manifest.id)?(Y.Logger.log("Set "+p.manifest.id+" extension as initialized by default..."),this.initialized.add(p.manifest.id)):Y.Logger.log(`Skipping initialization of ${p.manifest.id} extension, already initialized or no init method defined.`)}async destroyAll(){for(const p of[...this.extensionInOrder].reverse())p.module.destroy&&await p.module.destroy();this.events.destroy()}on(p,i){this.events.on(p,i)}emit(p,...i){this.events.emit(p,...i)}off(p,i){this.events.off(p,i)}emitAsync(p,...i){return this.events.emitAsync(p,...i)}emitAsyncAll(p,...i){return this.events.emitAsyncAll(p,...i)}emitAsyncAllSettled(p,...i){return this.events.emitAsyncAllSettled(p,...i)}emitAsyncSequentially(p,...i){return this.events.emitAsyncSequentially(p,...i)}emitAsyncSequentiallyAll(p,...i){return this.events.emitAsyncSequentiallyAll(p,...i)}emitAsyncSequentiallyAllSettled(p,...i){return this.events.emitAsyncSequentiallyAllSettled(p,...i)}async contextAvailable(p){if(this.initializedContexts.has(p)){Y.Logger.warn(`Context ${p} is already initialized. Skipping re-initialization.`);return}switch(this.initializedContexts.add(p),p){case ae.Editor:{if(!this.onResolveEditorContextCallback)throw new Error("No editor context resolver callback set. Call onResolveEditorContext first.");break}case ae.Logic:{if(!this.onResolveProjectLogicContextCallback)throw new Error("No project logic context resolver callback set. Call onResolveProjectLogicContext first.");break}}Y.Logger.log(`Context ${p} is now available. Initializing extensions for this context...`),await this.initForReady()}getValueTypePreference(p){return window.localStorage.getItem("dynamic-value-type-preference--"+p)||null}setValueTypePreference(p,i){window.localStorage.setItem("dynamic-value-type-preference--"+p,(i==null?void 0:i.toString())||""),this.emit(p,{})}}let ZA=null;const Jx={requestExtension:l=>(ZA||(ZA=new Yx,ZA.setup()),ZA.requestExtension(l))},Yu={onBeforeEntityExecution:async()=>{},onEntityExecuted:async()=>{}};var Qx=(l=>(l.FinishedSuccess="finished-success",l.FinishedError="finished-error",l.Running="running",l.Paused="paused",l.Stopped="stopped",l.NotStarted="not-started",l))(Qx||{});const ABe={...Jx,getValueTypePreference:()=>null,setValueTypePreference:()=>{}};class th extends Y.Events{constructor(i,r,a,c=null,e=ABe){super();R(this,"project");R(this,"entryPoint");R(this,"state","not-started");R(this,"events",new Y.Events("fe-exec-inst-events"));R(this,"entities",[]);R(this,"parentExecution",null);R(this,"executing",[]);R(this,"executed",[]);R(this,"skipped",[]);R(this,"scheduled",[]);R(this,"localTestValues");R(this,"resolvedValues");R(this,"persistedExecutionResults");R(this,"lastExecutionResults");R(this,"onAddToSkippedListCallback",null);R(this,"onRemoveFromSkippedListCallback",null);R(this,"onAddEntityCallback",null);R(this,"onRemoveEntityCallback",null);R(this,"onAbortExecutionCallback",null);this.parentContext=e,this.entities=r,this.entryPoint=a,this.project=i,this.parentExecution=c,this.localTestValues=new gT(x.UUID.uuid(),this.project),this.resolvedValues=new gT(x.UUID.uuid(),this.project),this.persistedExecutionResults=new gT(x.UUID.uuid(),this.project),this.lastExecutionResults=new gT(x.UUID.uuid(),this.project)}get valueResolutionContext(){return{execution:this,project:this.project,localTestValues:this.localTestValues,resolvedValues:this.resolvedValues,persistedExecutionResults:this.persistedExecutionResults,lastExecutionResults:this.lastExecutionResults,getValueTypePreference:this.parentContext.getValueTypePreference,setValueTypePreference:this.parentContext.setValueTypePreference}}skip(i){this.hasEntity(i)&&(this.removeFromScheduledList(i),!this.skipped.includes(i)&&(this.skipped.push(i),this.onAddToSkippedListCallback&&this.onAddToSkippedListCallback(i),Wi.includes(i.type)&&pt(i).forEach(r=>this.skip(r))))}async schedule(i,r,a){if(this.hasExecuted(i))return null;if(Bt.includes(i.type))return this.executeBranch(i,a,r);if(er.includes(i.type)){if(i.calledBy.every(e=>this.hasExecuted(e)||!this.hasEntity(e)))return this.executeBranch(i,a,r);this.scheduled.includes(i)||this.scheduled.push(i)}return null}mergeExernalValuesWithInternalInputs(i,r){const a=[];return[...wt,...Bt].includes(r.type)?a.push(...r.inputs):At.includes(r.type)&&a.push(...r.outputs),a.map(e=>{var h;let f=i.find(m=>m.valueOwner.id===e.id);if(f)return f;if(!f&&Bt.includes(r.type)&&(f=i.find(m=>{var E;return((E=m.valueOwner.declaration)==null?void 0:E.id)===e.id})),f){const m=(h=f.value)==null?void 0:h.clone(null);return m==null||m.setStandaloneParent(e,null),{...f,valueOwner:e,value:m||null,inheritanceLink:{sources:[f],target:e}}}return Sr.includes(e.type)?Yo(e,this.valueResolutionContext):mf(e,this.valueResolutionContext)}).reduce((e,f)=>{const h=id(f==null?void 0:f.valueOwner,this.project),m=f?[f]:[];return h.forEach(E=>{var _,N,V;if(E.id===(f==null?void 0:f.valueOwner.id))return;const b=Nt(E.getDataType(null),E,this.project);b==null||b.metaSync({value:(_=f==null?void 0:f.value)==null?void 0:_.value},null),b==null||b.setValueAsTypeList(((N=f==null?void 0:f.value)==null?void 0:N.valueAsTypeList)||null),b==null||b.setValueAsTypeSingle(((V=f==null?void 0:f.value)==null?void 0:V.valueAsTypeSingle)||null);const A={...f,valueOwner:E,value:b};m.push(A)}),[...e,...m]},[]).sort((e,f)=>e.valueOwner.index-f.valueOwner.index)}inheritValuesFromContext(i){this.localTestValues=i.localTestValues,this.resolvedValues=i.resolvedValues,this.persistedExecutionResults=i.persistedExecutionResults}async executeInternalCall(i,r,a,c={}){var f,h;const e={...Yu,...c};try{let m={value:U.Success,error:null,result:null};if(r.sort((E,b)=>E.valueOwner.index-b.valueOwner.index),Object.values(xr).includes(i.declaration.id)){const E=this.parentContext.requestExtension(eh+i.declaration.id).module.main;E?m=await E(i,r):Y.Logger.warn(`No implementation found for built-in function: ${i.declaration.id}`)}else{m=await this.executeDetachedFullFunctionDeclarationLogic(i.declaration,r,a,e);let E=null;if(m.error){Y.Logger.warn("Raw error executing entity: ",m.error);const b=(f=i.error)==null?void 0:f.getDataType(null),A=Nt(b||null,i.error,a);b!=null&&b.asType?A==null||A.setValueAsTypeSingle(m.error):A==null||A.metaSync({value:m.error},null),E={valueOwner:i.error,type:Me.ExecutionResult,inheritanceLink:null,value:A}}return{value:m.value,entity:i,error:E,result:{value:m.result||null,valueOwner:i,type:Me.ExecutionResult,inheritanceLink:null}}}return{...m,entity:i}}catch(m){Y.Logger.warn("Internal call execution error: ",m);let E=null;if(i.error){const b=(h=i.error)==null?void 0:h.getDataType(null),A=Nt(b,i.error,a);b!=null&&b.asType?A==null||A.setValueAsTypeSingle(m):A==null||A.metaSync({value:m},null),E={valueOwner:i.error,type:Me.ExecutionResult,inheritanceLink:null,value:A}}return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,entity:i,error:E,result:null}}}static async executeOperation(i,r,a){var c,e;try{let f={value:U.Success,error:null,result:null};r.sort((b,A)=>b.valueOwner.index-A.valueOwner.index),i.declaration.implementation&&(f=await i.declaration.implementation(i,r));let h=null;if(f.error&&i.error){Y.Logger.warn("Raw error executing entity: ",f.error);const b=((c=i.error)==null?void 0:c.getDataType(null))||null,A=Nt(b,i.error,a);b!=null&&b.asType?A==null||A.setValueAsTypeSingle(f.error):A==null||A.metaSync({value:f.error},null),h={valueOwner:i.error,type:Me.ExecutionResult,inheritanceLink:null,value:A}}const m=i==null?void 0:i.getDataType(null),E=Nt(m,i,a);return m!=null&&m.asType?E==null||E.setValueAsTypeSingle(f.result):E==null||E.metaSync({value:f.result},null),{value:f.value,entity:i,error:h,result:{value:E||null,valueOwner:i,type:Me.ExecutionResult,inheritanceLink:null}}}catch(f){Y.Logger.warn("Operation execution error: ",f);let h=null;if(i.error){const m=(e=i.error)==null?void 0:e.getDataType(null),E=Nt(m,i.error,a);m!=null&&m.asType?E==null||E.setValueAsTypeSingle(f):E==null||E.metaSync({value:f},null),h={valueOwner:i.error,type:Me.ExecutionResult,inheritanceLink:null,value:E}}return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,entity:i,error:h,result:null}}}async executeSearch(i,r,a){var c;try{let e={value:U.Success,error:null,result:null};const f=await(await this.parentContext.requestExtension(Ve.SEARCH_NODE_IMPLEMENTATION)).module.main(i,r),h=i==null?void 0:i.getDataType(null),m=Nt(h,i,a);return m==null||m.metaSync({value:f},null),f.error?{value:U.UnhandledError,entity:i,error:{valueOwner:i,type:Me.ExecutionResult,inheritanceLink:null,value:m},result:null}:{value:e.value,entity:i,error:null,result:{value:m,valueOwner:i,type:Me.ExecutionResult,inheritanceLink:null}}}catch(e){if(Y.Logger.warn(`Search node execution error: ${e}`),!i.error)return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,entity:i,error:null,result:null};const f=(c=i.error)==null?void 0:c.getDataType(null),h=Nt(f,i.error,a);return h==null||h.metaSync({value:e},null),{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,entity:i,error:{valueOwner:i.error,type:Me.ExecutionResult,inheritanceLink:null,value:h},result:null}}}async executeLoop(i,r,a,c={}){var f,h,m,E,b,A;const e={...Yu,...c};try{let _={value:U.Success,error:null,result:null};const N=r.map(re=>{var ee,de;return((ee=re==null?void 0:re.value)==null?void 0:ee.valueAsType)||((de=re==null?void 0:re.value)==null?void 0:de.value)});let V={};i.getUniqueInputMaps().forEach(re=>{const ee=i.body.inputs.find(ue=>le(ue,a)===le(re,a)),de=re==null?void 0:re.getDataType(null),ie=Nt(de,ee,a);de!=null&&de.asType?ie==null||ie.setValueAsTypeList([]):ie==null||ie.metaSync({value:[]},null),this.lastExecutionResults.writeValue(ee,ie);const se={value:ie,valueOwner:ee,type:Me.ExecutionResult,inheritanceLink:null};V[ee.id]=se});let M={value:U.Success,entity:i.body,error:null,result:null};switch(i.declaration.id){case ne.loop["counted-loop"].id:{const re=N[0];let ee=1;for(;ee<=re&&ee<=50;){const de=i.body.inputs.map(ie=>{if(ie===i.currentIterationNumberArgumentDeclaration){const se=i.currentIterationNumberArgumentDeclaration.getDataType(null),ue=rf(se),z=this.lastExecutionResults.readValue(ie.id);if(z){z.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ie,z);const me={value:z,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Me.ExecutionResult,inheritanceLink:null};return V[ie.id]=me,me}const X={id:x.UUID.uuid(),deletable:!0,editable:!0,type:d.LiteralValue,autogeneration:null,version:x.UUID.uuid(),createdAt:new Date().toISOString(),author:x.sessionAuthor,deleted:!1,previousVersion:null,value:ee,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:ue,standaloneParent:ie.toReference()},ce=tr(X,a);this.lastExecutionResults.writeValue(ie,ce);const oe={value:ce,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Me.ExecutionResult,inheritanceLink:null};return V[ie.id]=oe,oe}else return V[ie.id]}).filter(ie=>!!ie);if(M=await this.executeFullFunctionDeclarationLogic(i.body,de,e),(M.results||[]).forEach(ie=>{var X,ce,oe,me;if(ie.valueOwner.type!==d.InputMap||At.includes(ie.valueOwner.parent.type))return;const se=i.body.inputs.find(ve=>le(ve,a)===le(ie.valueOwner,a)),z=[...((ce=(X=V==null?void 0:V[se.id])==null?void 0:X.value)==null?void 0:ce.value)||[],((oe=ie==null?void 0:ie.value)==null?void 0:oe.value)||null];(me=V[se.id].value)==null||me.metaSync({value:z},null),this.lastExecutionResults.writeValue(se,V[se.id].value)}),[U.CaughtError,U.Break,U.Return].includes(M.value))break;ee++}break}case ne.loop["manual-flow-loop"].id:{let re=1;for(;re<=50;){const ee=i.body.inputs.map(de=>{if(de===i.currentIterationNumberArgumentDeclaration){const ie=this.lastExecutionResults.readValue(de.id);if(ie){ie.metaSync({value:re},null),this.lastExecutionResults.writeValue(de,ie);const X={value:ie,valueOwner:de,type:Me.ExecutionResult,inheritanceLink:null};return V[de.id]=X,X}const se=i.currentIterationNumberArgumentDeclaration.getDataType(null),ue=Nt(se,de,a);return ue==null||ue.metaSync({value:re},null),this.lastExecutionResults.writeValue(de,ue),{value:ue,valueOwner:de,type:Me.ExecutionResult,inheritanceLink:null}}else return V[de.id]}).filter(de=>!!de);if(M=await this.executeFullFunctionDeclarationLogic(i.body,ee,e),(M.results||[]).forEach(de=>{var z,X,ce;if(de.valueOwner.type!==d.InputMap||At.includes(de.valueOwner.parent.type))return;const ie=i.body.inputs.find(oe=>le(oe,a)===le(de.valueOwner,a)),ue=[...(z=V[ie.id].value)==null?void 0:z.value,((X=de.value)==null?void 0:X.value)||null];(ce=V[ie.id].value)==null||ce.metaSync({value:ue},null),this.lastExecutionResults.writeValue(ie,V[ie.id].value)}),[U.CaughtError,U.Break,U.Return].includes(M.value))break;re++}break}case ne.loop["list-loop"].id:{const re=N[0];let ee=1;const de=re;for(let ie=0;ie<de.length;ie++){const se=de[ie],ue=i.body.inputs.map(z=>{if(z===i.currentIterationNumberArgumentDeclaration){const X=this.lastExecutionResults.readValue(z.id);if(X)return X.metaSync({value:ee},null),this.lastExecutionResults.writeValue(z,X),{value:X,valueOwner:z,type:Me.ExecutionResult,inheritanceLink:null};const ce=i.currentIterationNumberArgumentDeclaration.getDataType(null),oe=Nt(ce,z,a);return oe==null||oe.metaSync({value:ee},null),this.lastExecutionResults.writeValue(z,oe),{value:oe,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Me.ExecutionResult,inheritanceLink:null}}else if(z===i.currentValueArgumentDeclaration){const X=i.currentValueArgumentDeclaration.getDataType(null),ce=rf(X),oe=this.lastExecutionResults.readValue(z.id);if(oe)return oe.metaSync({value:se},null),this.lastExecutionResults.writeValue(z,oe),{value:oe,valueOwner:z,type:Me.ExecutionResult,inheritanceLink:null};const me={id:x.UUID.uuid(),deletable:!0,editable:!0,type:d.LiteralValue,autogeneration:null,version:x.UUID.uuid(),createdAt:new Date().toISOString(),author:x.sessionAuthor,deleted:!1,previousVersion:null,value:se,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:ce,standaloneParent:z.toReference()},ve=tr(me,a);return this.lastExecutionResults.writeValue(z,ve),{value:ve,valueOwner:i.currentValueArgumentDeclaration,type:Me.ExecutionResult,inheritanceLink:null}}else return V[z.id]}).filter(z=>!!z);if(M=await this.executeFullFunctionDeclarationLogic(i.body,ue,e),(M.results||[]).forEach(z=>{var me,ve,we;if(z.valueOwner.type!==d.InputMap||At.includes(z.valueOwner.parent.type))return;const X=i.body.inputs.find(Re=>le(Re,a)===le(z.valueOwner,a)),oe=[...(me=V[X.id].value)==null?void 0:me.value,((ve=z.value)==null?void 0:ve.value)||null];(we=V[X.id].value)==null||we.metaSync({value:oe},null),this.lastExecutionResults.writeValue(X,V[X.id].value)}),[U.CaughtError,U.Break,U.Return].includes(M.value))break;ee++}break}case ne.loop["object-keys-loop"].id:{const re=N[0];let ee=1;const de=re?Object.keys(re):[];for(let ie=0;ie<de.length;ie++){const se=de[ie],ue=i.body.inputs.map(z=>{if(z===i.currentIterationNumberArgumentDeclaration){const X=this.lastExecutionResults.readValue(z.id);if(X)return X.metaSync({value:ee},null),this.lastExecutionResults.writeValue(z,X),{value:X,valueOwner:z,type:Me.ExecutionResult,inheritanceLink:null};const ce=i.currentIterationNumberArgumentDeclaration.getDataType(null),oe=Nt(ce,z,a);return oe==null||oe.metaSync({value:ee},null),this.lastExecutionResults.writeValue(z,oe),{value:oe,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Me.ExecutionResult,inheritanceLink:null}}else if(z===i.currentValueArgumentDeclaration){const X=i.currentValueArgumentDeclaration.getDataType(null),ce=rf(X),oe=this.lastExecutionResults.readValue(z.id);if(oe)return oe.metaSync({value:se},null),this.lastExecutionResults.writeValue(z,oe),{value:oe,valueOwner:z,type:Me.ExecutionResult,inheritanceLink:null};const me={id:x.UUID.uuid(),deletable:!0,editable:!0,type:d.LiteralValue,autogeneration:null,version:x.UUID.uuid(),createdAt:new Date().toISOString(),author:x.sessionAuthor,deleted:!1,previousVersion:null,value:se,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:ce,standaloneParent:z.toReference()},ve=tr(me,a);return this.lastExecutionResults.writeValue(z,ve),{value:ve,valueOwner:i.currentValueArgumentDeclaration,type:Me.ExecutionResult,inheritanceLink:null}}else return V[z.id]}).filter(z=>!!z);if(M=await this.executeFullFunctionDeclarationLogic(i.body,ue,e),(M.results||[]).forEach(z=>{var me,ve,we;if(z.valueOwner.type!==d.InputMap||At.includes(z.valueOwner.parent.type))return;const X=i.body.inputs.find(Re=>le(Re,a)===le(z.valueOwner,a)),oe=[...(me=V[X.id].value)==null?void 0:me.value,((ve=z.value)==null?void 0:ve.value)||null];(we=V[X.id].value)==null||we.metaSync({value:oe},null),this.lastExecutionResults.writeValue(X,V[X.id].value)}),[U.CaughtError,U.Break,U.Return].includes(M.value))break;ee++}break}case ne.loop["object-values-loop"].id:{const re=N[0];let ee=1;const de=re?Object.values(re):[];for(let ie=0;ie<de.length;ie++){const se=de[ie],ue=i.body.inputs.map(z=>{if(z===i.currentIterationNumberArgumentDeclaration){const X=this.lastExecutionResults.readValue(z.id);if(X)return X.metaSync({value:ee},null),this.lastExecutionResults.writeValue(z,X),{value:X,valueOwner:z,type:Me.ExecutionResult,inheritanceLink:null};const ce=i.currentIterationNumberArgumentDeclaration.getDataType(null),oe=Nt(ce,z,a);return oe==null||oe.metaSync({value:ee},null),this.lastExecutionResults.writeValue(z,oe),{value:oe,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Me.ExecutionResult,inheritanceLink:null}}else if(z===i.currentValueArgumentDeclaration){const X=i.currentValueArgumentDeclaration.getDataType(null),ce=rf(X),oe=this.lastExecutionResults.readValue(z.id);if(oe)return oe.metaSync({value:se},null),this.lastExecutionResults.writeValue(z,oe),{value:oe,valueOwner:z,type:Me.ExecutionResult,inheritanceLink:null};const me={id:x.UUID.uuid(),deletable:!0,editable:!0,type:d.LiteralValue,autogeneration:null,version:x.UUID.uuid(),createdAt:new Date().toISOString(),author:x.sessionAuthor,deleted:!1,previousVersion:null,value:se,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:ce,standaloneParent:z.toReference()},ve=tr(me,a);return this.lastExecutionResults.writeValue(z,ve),{value:ve,valueOwner:i.currentValueArgumentDeclaration,type:Me.ExecutionResult,inheritanceLink:null}}else return V[z.id]}).filter(z=>!!z);if(M=await this.executeFullFunctionDeclarationLogic(i.body,ue,e),(M.results||[]).forEach(z=>{var me,ve,we;if(z.valueOwner.type!==d.InputMap||At.includes(z.valueOwner.parent.type))return;const X=i.body.inputs.find(Re=>le(Re,a)===le(z.valueOwner,a)),oe=[...(me=V[X.id].value)==null?void 0:me.value,((ve=z.value)==null?void 0:ve.value)||null];(we=V[X.id].value)==null||we.metaSync({value:oe},null),this.lastExecutionResults.writeValue(X,V[X.id].value)}),[U.CaughtError,U.Break,U.Return].includes(M.value))break;ee++}break}case ne.loop["string-loop"].id:{const re=N[0];let ee=1;const de=re.split("");for(let ie=0;ie<de.length;ie++){const se=de[ie],ue=i.body.inputs.map(z=>{if(z===i.currentIterationNumberArgumentDeclaration){const X=this.lastExecutionResults.readValue(z.id);if(X)return X.metaSync({value:ee},null),this.lastExecutionResults.writeValue(z,X),{value:X,valueOwner:z,type:Me.ExecutionResult,inheritanceLink:null};const ce=i.currentIterationNumberArgumentDeclaration.getDataType(null),oe=Nt(ce,z,a);return oe==null||oe.metaSync({value:ee},null),this.lastExecutionResults.writeValue(z,oe),{value:oe,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Me.ExecutionResult,inheritanceLink:null}}else if(z===i.currentValueArgumentDeclaration){const X=i.currentValueArgumentDeclaration.getDataType(null),ce=rf(X),oe=this.lastExecutionResults.readValue(z.id);if(oe)return oe.metaSync({value:se},null),this.lastExecutionResults.writeValue(z,oe),{value:oe,valueOwner:z,type:Me.ExecutionResult,inheritanceLink:null};const me={id:x.UUID.uuid(),deletable:!0,editable:!0,type:d.LiteralValue,autogeneration:null,version:x.UUID.uuid(),createdAt:new Date().toISOString(),author:x.sessionAuthor,deleted:!1,previousVersion:null,value:se,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:ce,standaloneParent:z.toReference()},ve=tr(me,a);return this.lastExecutionResults.writeValue(z,ve),{value:ve,valueOwner:i.currentValueArgumentDeclaration,type:Me.ExecutionResult,inheritanceLink:null}}else return V[z.id]}).filter(z=>!!z);if(M=await this.executeFullFunctionDeclarationLogic(i.body,ue,e),(M.results||[]).forEach(z=>{var me,ve,we;if(z.valueOwner.type!==d.InputMap||At.includes(z.valueOwner.parent.type))return;const X=i.body.inputs.find(Re=>le(Re,a)===le(z.valueOwner,a)),oe=[...(me=V[X.id].value)==null?void 0:me.value,((ve=z.value)==null?void 0:ve.value)||null];(we=V[X.id].value)==null||we.metaSync({value:oe},null),this.lastExecutionResults.writeValue(X,V[X.id].value)}),[U.CaughtError,U.Break,U.Return].includes(M.value))break;ee++}break}}if(_={value:[U.CaughtError,U.Return].includes(M.value)?M.value:U.Success,error:((h=(f=M.error)==null?void 0:f.value)==null?void 0:h.value)||null,result:((E=(m=M==null?void 0:M.result)==null?void 0:m.value)==null?void 0:E.value)||null},_.error&&i.error){const re=(b=i.error)==null?void 0:b.getDataType(null),ee=Nt(re||null,i.error,a);re!=null&&re.asType?ee==null||ee.setValueAsTypeSingle(_.error):ee==null||ee.metaSync({value:_.error},null);const de={valueOwner:i.error,type:Me.ExecutionResult,inheritanceLink:null,value:ee};return{value:_.value,entity:i,error:de,result:null}}const G=i==null?void 0:i.getDataType(null),q=Nt(G,i,a);return G!=null&&G.asType?q==null||q.setValueAsTypeSingle(_.result):q==null||q.metaSync({value:_.result},null),{value:_.value,entity:i,error:null,result:{value:q||null,valueOwner:i,type:Me.ExecutionResult,inheritanceLink:null}}}catch(_){if(Y.Logger.warn("Error executing loop: ",_),i.error){const N=(A=i.error)==null?void 0:A.getDataType(null),V=Nt(N,i.error,a);return N!=null&&N.asType?V==null||V.setValueAsTypeSingle(_):V==null||V.metaSync({value:_},null),{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,entity:i,error:{valueOwner:i.error,type:Me.ExecutionResult,inheritanceLink:null,value:V},result:null}}else return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,entity:i,error:null,result:null}}}async executeFunctionCall(i,r,a,c={}){var f,h,m,E,b,A,_,N,V,j,M,G,q,re,ee,de,ie,se,ue,z,X,ce,oe,me,ve,we;const e={...Yu,...c};try{const Re=await this.executeDetachedFullFunctionDeclarationLogic(i.declaration,r,a,e);let xe=null;if(Re.error&&i.error){Y.Logger.warn("Raw error executing entity: ",Re.error);const Ze=(f=i.error)==null?void 0:f.getDataType(null),Xe=Nt(Ze||null,i.error,a);Ze!=null&&Ze.asType?(m=(h=Re.error)==null?void 0:h.value)!=null&&m.valueAsTypeSingle?Xe==null||Xe.setValueAsTypeSingle((b=(E=Re.error)==null?void 0:E.value)==null?void 0:b.valueAsTypeSingle):(_=(A=Re.error)==null?void 0:A.value)!=null&&_.valueAsTypeList&&Array.isArray((V=(N=Re.error)==null?void 0:N.value)==null?void 0:V.valueAsTypeList)&&(Xe==null||Xe.setValueAsTypeList((M=(j=Re.error)==null?void 0:j.value)==null?void 0:M.valueAsTypeList)):Xe==null||Xe.metaSync({value:(q=(G=Re.error)==null?void 0:G.value)==null?void 0:q.value},null),xe={valueOwner:i.error,type:Me.ExecutionResult,inheritanceLink:null,value:Xe}}let je=U.Success;Re.value===U.UnhandledError&&(i.catchesError||i.errorCalls.length?je=U.CaughtError:je=U.UnhandledError);const Se=i==null?void 0:i.getDataType(null),et=Nt(Se,i,a);return Se!=null&&Se.asType?(ee=(re=Re.result)==null?void 0:re.value)!=null&&ee.valueAsTypeSingle?et==null||et.setValueAsTypeSingle((ie=(de=Re.result)==null?void 0:de.value)==null?void 0:ie.valueAsTypeSingle):(ue=(se=Re.result)==null?void 0:se.value)!=null&&ue.valueAsTypeList&&Array.isArray((X=(z=Re.result)==null?void 0:z.value)==null?void 0:X.valueAsTypeList)&&(et==null||et.setValueAsTypeList((oe=(ce=Re.result)==null?void 0:ce.value)==null?void 0:oe.valueAsTypeList)):et==null||et.metaSync({value:((ve=(me=Re.result)==null?void 0:me.value)==null?void 0:ve.value)||null},null),{value:je,entity:i,error:xe,result:{value:et||null,valueOwner:i,type:Me.ExecutionResult,inheritanceLink:null}}}catch(Re){if(!i.error)return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,entity:i,error:null,result:null};const xe=(we=i.error)==null?void 0:we.getDataType(null),je=Nt(xe,i.error,a);return xe!=null&&xe.asType?je==null||je.setValueAsTypeSingle(Re):je==null||je.metaSync({value:Re},null),{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,entity:i,error:{valueOwner:i.error,type:Me.ExecutionResult,inheritanceLink:null,value:je},result:null}}}async executeCondition(i,r){var c,e,f,h;let a=!1;switch(i.declaration.id){case hn.BooleanIsTrue:{const m=(e=(c=r[0])==null?void 0:c.value)==null?void 0:e.value;if(typeof m!="boolean")throw new TypeError("BooleanIsTrue expects a boolean input.");a=m===!0;break}case hn.BooleanIsFalse:{const m=(h=(f=r[0])==null?void 0:f.value)==null?void 0:h.value;if(typeof m!="boolean")throw new TypeError("BooleanIsFalse expects a boolean input.");a=m===!1;break}case Dr.And:{a=(await Promise.all(i.andChildrenGroup.map(async E=>{const b=this.mergeExernalValuesWithInternalInputs(r,E);return(await this.executeCondition(E,b)).value===U.Success}))).every(E=>E);break}case Dr.Or:{a=(await Promise.all(i.orChildrenGroup.map(async E=>{const b=this.mergeExernalValuesWithInternalInputs(r,E);return(await this.executeCondition(E,b)).value===U.Success}))).some(E=>E);break}default:throw new Error(`Condition declaration ${i.declaration.name} does not have an implementation.`)}return{value:a?U.Success:U.ConditionNotMet,entity:i,error:null,result:null}}async executeDetachedFullFunctionDeclarationLogic(i,r,a,c={}){const e={...Yu,...c,onBeforeEntityExecution:(m,E,b)=>{var A;return((A=c==null?void 0:c.onBeforeEntityExecution)==null?void 0:A.call(c,m,E,{...b,detached:!0}))||Promise.resolve()},onEntityExecuted:(m,E,b)=>{var A;return((A=c==null?void 0:c.onEntityExecuted)==null?void 0:A.call(c,m,E,{...b,detached:!0}))||Promise.resolve()}},f=new th(a,[i,...SI(i)],i,this,this.parentContext);return f.inheritValuesFromContext(this),await f.execute(e,r)}async executeFullFunctionDeclarationLogic(i,r,a={}){const c={...Yu,...a},e=SI(i);e.forEach(m=>{this.addEntity(m)}),e.reduce((m,E)=>At.includes(E.type)?[...m,...E.outputs]:wt.includes(E.type)&&E.type!==d.Condition?[...m,...E.outputs,...E.inputs]:E.type===d.Condition?[...m,...E.inputs]:m,[]).forEach(m=>{this.lastExecutionResults.removeValue(m.id)});const h=await this.executeBranch(i,c,r);return{...h||{},value:(h==null?void 0:h.value)||U.Success,entity:i,error:(h==null?void 0:h.error)||null,result:(h==null?void 0:h.result)||null}}static async executeEntryPointEntity(i,r){return{value:U.Success,entity:i,error:null,result:null}}async executeReturnStatement(i,r){var f,h,m,E,b,A,_;if((f=i.throws)!=null&&f.readsValue){const N=Yo(i.throws,this.valueResolutionContext);return{value:U.UnhandledError,entity:i,error:{valueOwner:i.throws,type:Me.ExecutionResult,inheritanceLink:null,value:(N==null?void 0:N.value)||null},result:null}}let a=Yo(i,this.valueResolutionContext);const c=i.getDataType(null);if(c!=null&&c.isObject()){let N={};if(((h=c==null?void 0:c.entity)==null?void 0:h.type)===d.DefinitionEntity&&(N={...N,...c.entity.getActiveRawDefaultValue()}),a!=null&&a.value)Rr((m=a==null?void 0:a.value)==null?void 0:m.value)&&(N={...N,...(E=a==null?void 0:a.value)==null?void 0:E.value}),a==null||a.value.metaSync({value:N},null);else{const V=Nt(c,i,this.project);V==null||V.metaSync({value:N},null),a={valueOwner:i,type:Me.ExecutionResult,inheritanceLink:null,value:V}}this.lastExecutionResults.writeValue(i,a.value),i.outputs.forEach(V=>{var j,M;if(((j=V.declaration)==null?void 0:j.type)===d.Property&&V.declaration.static){const G=this.lastExecutionResults.readValue(V.declaration.id),q=le(V,this.project),re=V.codeName||((M=V.declaration)==null?void 0:M.codeName)||Qi(q);if(G)G.metaSync({value:N[re]},null),this.lastExecutionResults.writeValue(V.declaration,G);else{const ee=Nt(V.getDataType(null),V,this.project);ee==null||ee.metaSync({value:N[re]},null),this.lastExecutionResults.writeValue(V.declaration,ee)}}})}else this.lastExecutionResults.writeValue(i,a==null?void 0:a.value);const e=(b=a==null?void 0:a.value)!=null&&b.value&&Rr((A=a.value)==null?void 0:A.value)?((_=a.value)==null?void 0:_.value)||{}:{};return i.outputs.map(N=>{var G;const V=N.codeName||((G=N.declaration)==null?void 0:G.codeName)||Qi(le(N,this.project)),j=e[V],M=Nt(N.getDataType(null),N,this.project);M==null||M.metaSync({value:j},null),Me.ExecutionResult}),a.type=Me.ExecutionResult,{value:U.Return,entity:i,error:null,result:a}}async executeContinueStatement(i,r){var f,h,m,E,b,A,_;if((f=i.throws)!=null&&f.readsValue){const N=Yo(i.throws,this.valueResolutionContext);return{value:U.UnhandledError,entity:i,error:{valueOwner:i.throws,type:Me.ExecutionResult,inheritanceLink:null,value:(N==null?void 0:N.value)||null},result:null}}let a=Yo(i,this.valueResolutionContext);const c=i.getDataType(null);if(c!=null&&c.isObject()){let N={};if(((h=c==null?void 0:c.entity)==null?void 0:h.type)===d.DefinitionEntity&&(N={...N,...c.entity.getActiveRawDefaultValue()}),a!=null&&a.value)Rr((m=a==null?void 0:a.value)==null?void 0:m.value)&&(N={...N,...(E=a==null?void 0:a.value)==null?void 0:E.value}),a==null||a.value.metaSync({value:N},null);else{const V=Nt(c,i,this.project);V==null||V.metaSync({value:N},null),a={valueOwner:i,type:Me.ExecutionResult,inheritanceLink:null,value:V}}this.lastExecutionResults.writeValue(i,a.value),i.outputs.forEach(V=>{var j,M;if(((j=V.declaration)==null?void 0:j.type)===d.Property&&V.declaration.static){const G=this.lastExecutionResults.readValue(V.declaration.id),q=le(V,this.project),re=V.codeName||((M=V.declaration)==null?void 0:M.codeName)||Qi(q);if(G)G.metaSync({value:N[re]},null),this.lastExecutionResults.writeValue(V.declaration,G);else{const ee=Nt(V.getDataType(null),V,this.project);ee==null||ee.metaSync({value:N[re]},null),this.lastExecutionResults.writeValue(V.declaration,ee)}}})}else this.lastExecutionResults.writeValue(i,a==null?void 0:a.value);const e=(b=a==null?void 0:a.value)!=null&&b.value&&Rr((A=a.value)==null?void 0:A.value)?((_=a.value)==null?void 0:_.value)||{}:{};return i.outputs.map(N=>{var G;const V=N.codeName||((G=N.declaration)==null?void 0:G.codeName)||Qi(le(N,this.project)),j=e[V],M=Nt(N.getDataType(null),N,this.project);M==null||M.metaSync({value:j},null),Me.ExecutionResult}),a.type=Me.ExecutionResult,{value:U.Continue,entity:i,error:null,result:a}}async executeBreakStatement(i,r){var f,h,m,E,b,A,_;if((f=i.throws)!=null&&f.readsValue){const N=Yo(i.throws,this.valueResolutionContext);return{value:U.UnhandledError,entity:i,error:{valueOwner:i.throws,type:Me.ExecutionResult,inheritanceLink:null,value:(N==null?void 0:N.value)||null},result:null}}let a=Yo(i,this.valueResolutionContext);const c=i.getDataType(null);if(c!=null&&c.isObject()){let N={};if(((h=c==null?void 0:c.entity)==null?void 0:h.type)===d.DefinitionEntity&&(N={...N,...c.entity.getActiveRawDefaultValue()}),a!=null&&a.value)Rr((m=a==null?void 0:a.value)==null?void 0:m.value)&&(N={...N,...(E=a==null?void 0:a.value)==null?void 0:E.value}),a==null||a.value.metaSync({value:N},null);else{const V=Nt(c,i,this.project);V==null||V.metaSync({value:N},null),a={valueOwner:i,type:Me.ExecutionResult,inheritanceLink:null,value:V}}this.lastExecutionResults.writeValue(i,a.value),i.outputs.forEach(V=>{var j,M;if(((j=V.declaration)==null?void 0:j.type)===d.Property&&V.declaration.static){const G=this.lastExecutionResults.readValue(V.declaration.id),q=le(V,this.project),re=V.codeName||((M=V.declaration)==null?void 0:M.codeName)||Qi(q);if(G)G.metaSync({value:N[re]},null),this.lastExecutionResults.writeValue(V.declaration,G);else{const ee=Nt(V.getDataType(null),V,this.project);ee==null||ee.metaSync({value:N[re]},null),this.lastExecutionResults.writeValue(V.declaration,ee)}}})}else this.lastExecutionResults.writeValue(i,a==null?void 0:a.value);const e=(b=a==null?void 0:a.value)!=null&&b.value&&Rr((A=a.value)==null?void 0:A.value)?((_=a.value)==null?void 0:_.value)||{}:{};return i.outputs.map(N=>{var G;const V=N.codeName||((G=N.declaration)==null?void 0:G.codeName)||Qi(le(N,this.project)),j=e[V],M=Nt(N.getDataType(null),N,this.project);M==null||M.metaSync({value:j},null),Me.ExecutionResult}),a.type=Me.ExecutionResult,{value:U.Break,entity:i,error:null,result:a}}async executeVariable(i,r){var h,m,E,b,A,_;let a=Yo(i,this.valueResolutionContext);const c=Tr(i),e=c.getDataType(null);if(e!=null&&e.isObject()){let N={};if(((h=e==null?void 0:e.entity)==null?void 0:h.type)===d.DefinitionEntity&&(N={...N,...e.entity.getActiveRawDefaultValue()}),a!=null&&a.value)Rr((m=a==null?void 0:a.value)==null?void 0:m.value)&&(N={...N,...(E=a==null?void 0:a.value)==null?void 0:E.value}),a==null||a.value.metaSync({value:N},null);else{const V=Nt(e,i,this.project);V==null||V.metaSync({value:N},null),a={valueOwner:c,type:Me.ExecutionResult,inheritanceLink:null,value:V}}this.lastExecutionResults.writeValue(c,a.value),c.inputs.forEach(V=>{var j,M;if(((j=V.declaration)==null?void 0:j.type)===d.Property&&V.declaration.static){const G=this.lastExecutionResults.readValue(V.declaration.id),q=le(V,this.project),re=V.codeName||((M=V.declaration)==null?void 0:M.codeName)||Qi(q);if(G)G.metaSync({value:N[re]},null),this.lastExecutionResults.writeValue(V.declaration,G);else{const ee=Nt(V.getDataType(null),V,this.project);ee==null||ee.metaSync({value:N[re]},null),this.lastExecutionResults.writeValue(V.declaration,ee)}}})}else this.lastExecutionResults.writeValue(c,a==null?void 0:a.value);const f=(b=a==null?void 0:a.value)!=null&&b.value&&Rr((A=a.value)==null?void 0:A.value)?((_=a.value)==null?void 0:_.value)||{}:{};return i.outputs.map(N=>{var G;const V=N.codeName||((G=N.declaration)==null?void 0:G.codeName)||Qi(le(N,this.project)),j=f[V],M=Nt(N.getDataType(null),N,this.project);M==null||M.metaSync({value:j},null),Me.ExecutionResult}),a.type=Me.ExecutionResult,{value:U.Success,entity:i,error:null,result:a}}mergeValues(i,r){const a=[];for(let c=0;c<r.length;c++)i!=null&&i[c]?a.push(i[c]):a.push(r[c]);return a}async executeEntity(i,r=[],a={}){var f,h,m,E,b,A,_,N,V,j,M;const c={...Yu,...a},e={detached:!1};switch(i.type){case d.Condition:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await((f=c.onBeforeEntityExecution)==null?void 0:f.call(c,i,G,e)),this.executeCondition(i,G)}case d.InternalCall:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await((h=c.onBeforeEntityExecution)==null?void 0:h.call(c,i,G,e)),this.executeInternalCall(i,G,this.project)}case d.Operation:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await((m=c.onBeforeEntityExecution)==null?void 0:m.call(c,i,G,e)),th.executeOperation(i,G,this.project)}case d.VariableInstance:case d.VariableDeclaration:return this.executeVariable(i,r);case d.FunctionCall:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await((E=c.onBeforeEntityExecution)==null?void 0:E.call(c,i,G,e)),this.executeFunctionCall(i,G,this.project)}case d.FunctionDeclaration:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await((b=c.onBeforeEntityExecution)==null?void 0:b.call(c,i,G,e)),th.executeEntryPointEntity(i,G)}case d.Search:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await((A=c.onBeforeEntityExecution)==null?void 0:A.call(c,i,G,e)),this.executeSearch(i,G,this.project)}case d.Loop:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await((_=c.onBeforeEntityExecution)==null?void 0:_.call(c,i,G,e)),this.executeLoop(i,G,this.project,c)}case d.ReturnStatement:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await((N=c.onBeforeEntityExecution)==null?void 0:N.call(c,i,G,e)),this.executeReturnStatement(i,G)}case d.ContinueStatement:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await((V=c.onBeforeEntityExecution)==null?void 0:V.call(c,i,G,e)),this.executeContinueStatement(i,G)}case d.BreakStatement:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await((j=c.onBeforeEntityExecution)==null?void 0:j.call(c,i,G,e)),this.executeBreakStatement(i,G)}case d.GlobalEvent:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await((M=c.onBeforeEntityExecution)==null?void 0:M.call(c,i,G,e)),th.executeEntryPointEntity(i,G)}default:throw new Error(`Entity type ${i==null?void 0:i.type} is not recognized for execution.`)}}storeLastExecutionValues(i){var a,c,e;if(i.error&&i.error.valueOwner&&this.lastExecutionResults.writeValue(i.error.valueOwner,i.error.value),!i.result||!((a=i.result)!=null&&a.valueOwner))return;const r=id((c=i.result)==null?void 0:c.valueOwner,this.project);(e=i.result)!=null&&e.value?r.forEach(f=>{var h;this.lastExecutionResults.writeValue(f,(h=i.result)==null?void 0:h.value)}):r.forEach(f=>{this.lastExecutionResults.removeValue(f.id)})}async executeBranch(i,r={},a=[]){var m;const c={...Yu,...r},e={detached:!1};if(!this.hasEntity(i)||this.hasSkipped(i))return null;this.addToExecutingList(i),this.hasScheduled(i)&&this.removeScheduled(i);const h=await this.executeEntity(i,a,c);if(this.removeFromExecutingList(i),this.addToAlreadyExecutedList(i),this.storeLastExecutionValues(h),await((m=c.onEntityExecuted)==null?void 0:m.call(c,i,h,e)),h.value===U.Success){const E=(i.successCalls||i.calls||[]).filter(V=>this.hasEntity(V));(i.errorCalls||[]).forEach(V=>{this.skip(V)});let A=[];const _=(await Promise.all(E.map(V=>this.schedule(V,[],c)))).filter(V=>!!V),N=_.filter(V=>!!V).find(V=>V.value===U.CaughtError||V.value===U.Return||V.value===U.Break||V.value===U.Continue);return N||(A=[...A,..._],h)}else if(h.value===U.CaughtError||h.value===U.ConditionNotMet){const E=(i.errorCalls||[]).filter(V=>this.hasEntity(V));(i.successCalls||i.calls||[]).forEach(V=>{this.skip(V)});let A=[];const _=(await Promise.all(E.map(V=>this.schedule(V,[],c)))).filter(V=>!!V),N=_.filter(V=>!!V).find(V=>V.value===U.CaughtError||V.value===U.UnhandledError||V.value===U.Return||V.value===U.Break||V.value===U.Continue);return N||(A=[...A,..._],h)}else{if(h.value===U.UnhandledError)return this.executing.forEach(E=>{this.skip(E)}),this.scheduled.forEach(E=>{this.skip(E)}),Wi.includes(h.entity.type)&&pt(h.entity).forEach(E=>{this.skip(E)}),h;if(h.value===U.Return)return h;if(h.value===U.Break)return h;if(h.value===U.Continue)return h}return h}async execute(i={},r=[]){const a={...Yu,...i};this.state="running";const c=await this.executeBranch(this.entryPoint,a,r);return this.state="finished-success",c}addEntity(i){var r;this.entities.includes(i)||(this.entities.push(i),(r=this.onAddEntityCallback)==null||r.call(this,i,{}))}async addEntityAsync(i,r={}){var a;this.entities.includes(i)||(this.entities.push(i),await((a=this.onAddEntityCallback)==null?void 0:a.call(this,i,r)))}addEntities(i){i.forEach(r=>this.addEntity(r))}async addEntitiesAsync(i,r={}){const a=Y.YieldTracker.from(r),c=[];for(const e of i)c.push(this.addEntityAsync(e,r)),await a.tick();await Promise.all(c)}removeEntity(i){var r;if(i!==this.entryPoint){const a=this.entities.indexOf(i);a>-1&&(this.entities.splice(a,1),(r=this.onRemoveEntityCallback)==null||r.call(this,i,{}))}}hasEntity(i){var c,e,f;if(this.entities.includes(i))return!0;if(((c=i.parent)==null?void 0:c.type)===d.FunctionDeclaration&&((f=(e=i.parent)==null?void 0:e.parent)==null?void 0:f.type)===d.DefinitionEntity)return this.entities.includes(i.parent);const r=yt(i);if(!r)return!1;const a=r.type===d.Loop&&i.parent===r.body?r.body:null;return a?this.entities.includes(a)||this.entities.includes(r):this.entities.includes(r)}removeScheduled(i){const r=this.scheduled.indexOf(i);r>-1&&this.scheduled.splice(r,1)}hasScheduled(i){return!!this.scheduled.includes(i)}hasSkipped(i){return!!this.skipped.includes(i)}hasExecuted(i){return!!this.executed.includes(i)}hasEntityWithId(i){const r=this.project.get(i);return r?this.hasEntity(r):!1}onAddToSkippedList(i){this.onAddToSkippedListCallback=i}onAbortExecution(i){this.onAbortExecutionCallback=i}onAddEntity(i){this.onAddEntityCallback=i}onRemoveFromSkippedList(i){this.onRemoveFromSkippedListCallback=i}onRemoveEntity(i){this.onRemoveEntityCallback=i}addToExecutingList(i){this.executing.includes(i)||this.executing.push(i)}addToScheduledList(i){this.scheduled.includes(i)||this.scheduled.push(i)}removeFromScheduledList(i){const r=this.scheduled.indexOf(i);r>-1&&this.scheduled.splice(r,1)}removeFromExecutingList(i){var a;const r=this.executing.indexOf(i);r>-1&&(this.executing.splice(r,1),(a=this.onAbortExecutionCallback)==null||a.call(this,i,{}))}removeFromAlreadyExecutedList(i){const r=this.executed.indexOf(i);r>-1&&this.executed.splice(r,1)}removeFromSkippedList(i){var a;const r=this.skipped.indexOf(i);r>-1&&(this.skipped.splice(r,1),(a=this.onRemoveFromSkippedListCallback)==null||a.call(this,i,{}))}addToAlreadyExecutedList(i){this.executed.includes(i)||this.executed.push(i)}addToSkippedList(i){var r;this.skipped.includes(i)||(this.skipped.push(i),(r=this.onAddToSkippedListCallback)==null||r.call(this,i,{}))}getValueTypePreference(i){return this.parentContext.getValueTypePreference(i)||null}setValueTypePreference(i,r){this.parentContext.setValueTypePreference(i,r),this.emit(i,{})}}function rRi(l){var p,i;if(l.isList)return"list";if(((p=l.entity)==null?void 0:p.type)===d.DefinitionEntity)return"definition-entity";switch((i=l.entity)==null?void 0:i.name){case fe.Number:return"number";case fe.String:return"text";case fe.Boolean:return"boolean";case fe.UUID:return"uuid";case fe.Date:return"date-time";default:return"definition-entity"}}const is={[d.PrimitiveEntity]:{singular:"Primitive",plural:"Primitives",shortSingular:"Primitive",shortPlural:"Primitives"},[d.DefinitionEntity]:{singular:"Definition",plural:"Definitions",shortSingular:"Definition",shortPlural:"Definitions"},[d.BuiltInBaseEntity]:{singular:"Base",plural:"Bases",shortSingular:"Base definition",shortPlural:"Base definitions"},[d.Property]:{singular:"Property",plural:"Properties",shortSingular:"Property",shortPlural:"Properties"},[d.FunctionDeclaration]:{singular:"Custom trigger",plural:"Custom triggers",shortSingular:"Trigger",shortPlural:"Triggers"},[d.FunctionCall]:{singular:"Execute trigger",plural:"Execute trigger",shortSingular:"Execute",shortPlural:"Execute"},[d.GlobalEvent]:{singular:"System trigger",plural:"System triggers",shortSingular:"Trigger",shortPlural:"Triggers"},[d.Project]:{singular:"Project",plural:"Projects",shortSingular:"Project",shortPlural:"Projects"},[d.VariableDeclaration]:{singular:"Variable",plural:"Variables",shortSingular:"Variable",shortPlural:"Variables"},[d.VariableInstance]:{singular:"Variable",plural:"Variables",shortSingular:"Variable",shortPlural:"Variables"},[d.Condition]:{singular:"Condition",plural:"Conditions",shortSingular:"Condition",shortPlural:"Conditions"},[d.Operation]:{singular:"Operation",plural:"Operations",shortSingular:"Operation",shortPlural:"Operations"},[d.ReturnStatement]:{singular:"Termination",plural:"Terminations",shortSingular:"Termination",shortPlural:"Terminations"},[d.InstalledProject]:{singular:"Installed project",plural:"Installed projects",shortSingular:"Project",shortPlural:"Projects"},[d.Search]:{singular:"Search",plural:"Searches",shortSingular:"Search",shortPlural:"Searches"},[d.Loop]:{singular:"Loop",plural:"Loops",shortSingular:"Loop",shortPlural:"Loops"},[d.ActionDescriptor]:{singular:"Action descriptor",plural:"Action descriptors",shortSingular:"Action descriptor",shortPlural:"Action descriptors"},[d.InternalCall]:{singular:"Internal call",plural:"Internal calls",shortSingular:"Internal call",shortPlural:"Internal calls"},[d.BreakStatement]:{singular:"Loop exit",plural:"Loop exists",shortSingular:"Exit",shortPlural:"Exits"},[d.ContinueStatement]:{singular:"Next iteration",plural:"Next iterations",shortSingular:"Next",shortPlural:"Nexts"},[d.ArgumentDeclaration]:{singular:"Input definition",plural:"Input definitions",shortSingular:"Input",shortPlural:"Inputs"},[d.InputMap]:{singular:"Input",plural:"Inputs",shortSingular:"Input",shortPlural:"Inputs"},[d.OutputMap]:{singular:"Output",plural:"Outputs",shortSingular:"Output",shortPlural:"Outputs"},[d.ValueDescriptor]:{singular:"Value descriptor",plural:"Value descriptors",shortSingular:"Value descriptor",shortPlural:"Value descriptors"},[d.DataType]:{singular:"Data type",plural:"Data types",shortSingular:"Data type",shortPlural:"Data types"},[d.LiteralValue]:{singular:"Literal value",plural:"Literal values",shortSingular:"Value",shortPlural:"Values"}};function Xx(l){const p=tD(l);if(!p){const r=Dh(l);if(r.includes(Ie.HTTP_ENDPOINT))return"HTTP endpoint";if(r.includes(Ie.PERSISTED_ENTITY))return"Persisted entity";if(r.includes(Ie.CRON_JOB))return"Scheduled execution";if(r.includes(Ie.RELATIONAL_DATABASE))return"Relational database"}if(p){let r="Extension of "+le(p,p.project)+" entity",a=Ps(r);const c=Dh(l);return c.includes(Ie.HTTP_ENDPOINT)?"HTTP endpoint"+(a?", "+a:""):c.includes(Ie.PERSISTED_ENTITY)?"Persisted entity"+(a?", "+a:""):c.includes(Ie.CRON_JOB)?"Scheduled execution"+(a?", "+a:""):c.includes(Ie.RELATIONAL_DATABASE)?"Relational database"+(a?", "+a:""):r}let i="";return l.abstract&&(i="Template "),l.static&&(i+=i?" single copy ":"Single copy "),i?i+"definition":"Definition"}function IBe(l){return l.parent.type===d.DefinitionEntity||l.parent.type===d.InstalledProject?"Internal action of "+le(l.parent,l.project):l.parent.type===d.Loop?"Action repeated on every iteration":"Internal action of entity"}function e$(l){return bL(l)?IBe(l):"Custom trigger"}function nRi(l){var p;switch(l.type){case d.DefinitionEntity:return Xx(l);case d.FunctionDeclaration:return e$(l)}return(p=is[l.type])==null?void 0:p.singular}function aRi(l){var p;switch(l.type){case d.DefinitionEntity:return Xx(l);case d.FunctionDeclaration:return e$(l)}return(p=is[l.type])==null?void 0:p.singular}const t$=4e4,i$=280,sRi=300,r$=65,of=32,nh=39,HT=26,gBe=49,WT=44,lRi=35,rI=52,v1=10,Na=v1*2,ap=38,nI=90,OI=270,RBe=t$/2+120,DBe=t$/2+180;function n$(l){let i=of+WT+ap+v1;const r=[...l.inputs];return r.length&&(i+=Na,r.forEach(()=>{i+=HT})),{height:i,width:280}}function zT(l){var a,c;let i=of+WT+ap+v1;const r=[...l.inputs];return r.length&&(i+=Na,r.forEach(()=>{i+=HT})),l.andChildrenGroup&&(i+=Na,l.andChildrenGroup.forEach(e=>{i+=zT(e).height})),l.orChildrenGroup&&(i+=Na,l.orChildrenGroup.forEach(e=>{i+=zT(e).height})),(((a=l.declaration)==null?void 0:a.id)===ne.condition["condition-group-and"].id||((c=l.declaration)==null?void 0:c.id)===ne.condition["condition-group-or"].id)&&(i+=ap),{height:i,width:280}}function wBe(l){var h,m;let i=r$;const r=[];if([d.DefinitionEntity].includes(l.type)){const E=[...l.suggestedProperties||[],...l.properties||[]];E.length&&(i+=Na,E.forEach(b=>{i+=b.static?gBe:nh}))}if([d.DefinitionEntity,d.InstalledProject,d.Loop].includes(l.type)){const E=[...(l==null?void 0:l.suggestedMethods)||[],...l.methods||[],...l.functions||[],...l.body?[l.body]:[]];E.length&&(i+=Na,E.forEach(b=>{const A=n$(b);i+=A.height}))}wt.includes(l.type)?(r.push(...(l.inputs||[]).flatMap(E=>[E])||[]),i+=Na,i+=WT,l.error&&(i+=rI)):[d.ReturnStatement,d.BreakStatement,d.ContinueStatement].includes(l.type)?(r.push(...l.outputs||[]),l.throws&&(i+=rI)):l.type===d.Condition&&(r.push(l.inputs[0]),l.inputs[1]&&r.push(l.inputs[1]),(((h=l.declaration)==null?void 0:h.id)===ne.condition["condition-group-and"].id||((m=l.declaration)==null?void 0:m.id)===ne.condition["condition-group-or"].id)&&(i+=ap),l.andChildrenGroup&&(i+=Na,l.andChildrenGroup.forEach(E=>{i+=zT(E).height})),l.orChildrenGroup&&(i+=Na,l.orChildrenGroup.forEach(E=>{i+=zT(E).height})));const a=r.length;a&&(i+=a*nh,i+=Na);const c=[];if(l.type===d.FunctionDeclaration||l.type===d.GlobalEvent?c.push(...l.inputs||[]):wt.includes(l.type)&&c.push(...l.outputs||[]),xt.includes(l.type)){i+=Na,i+=WT,l.usedInternalCalls.length&&l.usedInternalCalls.forEach(b=>{i+=rI+Na,i+=b.inputs.length*HT,i+=b.outputs.length*HT});const E=l.getDataType(null);(!E||E.canModifyObjectStructure())&&(i+=ap)}l.type===d.Search&&(i+=ap);const e=c.length;return e&&(i+=e*nh,i+=Na),[d.DefinitionEntity,d.FunctionDeclaration,d.ReturnStatement,d.BreakStatement,d.ContinueStatement].includes(l.type)&&(i+=ap),{height:i,width:280}}function CBe(l){let p=0;if(l.parent.type!==d.DefinitionEntity)return{offset:p};const i=l.parent,r=i.methods.findIndex(c=>c.id===l.id);return i.methods.slice(0,r).forEach(c=>{const e=n$(c);p+=e.height}),(i.properties.length||i.suggestedProperties.length)&&(p+=Na,i.suggestedProperties.forEach(()=>{p+=nh}),i.properties.forEach(()=>{p+=nh})),{offset:p}}function mE(l){return`${l.split("-").map((r,a)=>a===0?r.charAt(0).toUpperCase()+r.slice(1):r.toLowerCase()).join(" ")}.`}function oRi(l){switch(l.code){case be.AbstractEntityWithNonAbstractMethods:return"This template entity has non-template actions";case be.AbstractEntityWithNonAbstractProperties:return"This template entity has non-template properties";case be.IncorrectEntityImplementation:return"This entity incorrectly implements a template entity";case be.IncorrectMethodImplementation:return"This action incorrectly implements the template action it's based on";case be.IncorrectPropertyImplementation:return"This property incorrectly implements the template property it's based on";case be.AbstractMethodInNonAbstractEntity:return"This action is a template action in a non-template entity";case be.AbstractPropertyInNonAbstractEntity:return"This property is a template property in a non-template entity";case Ce.MethodOverwritesOtherSiblingWithSameName:return"An action in this entity overwrites an action in the template entity with the same name";case Ce.PropertyOverwritesOtherSiblingWithSameName:return"A property in this entity overwrites a property in the template entity with the same name";case be.MissingMethodImplementation:return"This entity is missing an action implementation from the template entity";case be.MissingPropertyImplementation:return"This entity is missing a property implementation from the template entity";case Ce.NameNotUniqueInScope:return"Invalid name. There is another entity with the same name in the same scope";case be.NoProperties:return"This entity has no properties, so it doesn't do anything";case be.NonStaticPropertyInStaticEntity:return"This property is not static in a static entity";case be.StaticEntityWithNonStaticProperties:return"This static entity has non-static properties";case be.ReadingFromIncompatibleType:return"This entity reads data from a value of a different data type";case be.WritingToIncompatibleType:return"This entity writes data to a value of a different data type";case be.ScopeWithoutLogic:return"This action has no logic, so it doesn't do anything";case be.NonStaticPropertyImplementsStatic:return"This property is static in a non-static entity";case be.PropertyImplementsIncompatibleType:return"This property implements a property of a different data type";case be.PropertyImplementsNonAbstact:return"This property implements a non-template property";case be.StaticPropertyImplementsNonStatic:return"This static property implements a non-static property";case be.VariableCallsOthersAndHasInternalCall:return"This variable calls other entities while being used to execute internal logic";case be.VariableHasInputsAndInternalCall:return"This variable has inputs while being used to execute internal logic";case be.VariableHasOutputsAndInternalCall:return"This variable has outputs while being used to execute internal logic";case be.VariableIsCalledAndHasInternalCall:return"This variable is called while being used to execute internal logic";case Ce.InternalCallDeclarationIsInvalidType:return"This internal call is not an action";case Ce.InternalCallDeclarationNotFoundInParentDatatypeEntity:return"This internal call is not found in the parent entity";case Ce.InternalCallParentDeclarationEntityInvalidType:return"This internal call parent entity is not a data type";case Ce.InternalCallParentMissingDataType:return"This internal call parent entity has no data type";case Ce.UnreachableEntity:return"This entity is unreachable";case be.DisconnectedCallableEntity:return"This entity is disconnected and won't be executed by anything after publishing";case be.AbstractEntityImplements:return"This template entity implements a non-template entity";case be.AbstractExtendingNonAbstractEntity:return"This template entity extends a non-template entity";case be.InvalidPropertiesCombination:return"This entity has an invalid combination of properties";case be.ExtendingNonInteractiveEntity:return"This entity extends a non-interactive entity";case be.ExtendsIncompatibleEntities:return"This entity extends incompatible entities";case be.ImplementingNonAbstractEntity:return"This entity implements a non-template entity";case be.ImplementsIncompatibleEntities:return"This entity implements incompatible entities";case be.LackingReturnStatementOnSomeBranches:return"This action is missing a termination on some branches";case be.LastCalledEntityMustBeReturnEntity:return"The last called entity in this action must be a termination node";case be.MissingRequiredValue:return"This action is missing a required value";case be.NoPrimaryKeyProperty:return"This entity has no primary key property";case be.NonAbstractExtendingAbstractEntity:return"This non-template entity extends a template entity";case be.NonStaticExtendingStaticEntity:return"This non-static entity extends a static entity";case be.NonStaticImplementingStaticEntity:return"This non-static entity implements a static entity";case be.StaticExtendingNonStaticEntity:return"This static entity extends a non-static entity";case be.StaticImplementingNonStaticEntity:return"This static entity implements a non-static entity";case be.VariableReadsValueAndInternalCall:return"This variable reads a value while being used to execute internal logic";case be.VariableWritesValuesAndInternalCall:return"This variable writes values while being used to execute internal logic";case Ce.InternalCallDeclarationNotInParentDatatypeEntity:return"This internal call declaration is not in the parent entity";case Ce.EmptyName:return"This entity has no name";case Ce.InvalidObjectStructure:return"This entity has an invalid structure";case Ce.LoopBodyFunctionOverwrite:return"This loop body action overwrites an action in the template entity with the same name";case Ce.MethodOverwritesBaseMethodWithSameImplementation:return"This action overwrites a base action with the same implementation";case Ce.MethodOverwritesOtherExtendedEntitysMethodWithSameImplementation:return"This action overwrites an action in an extended entity with the same implementation";case Ce.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation:return"This action overwrites an action in an implemented entity with the same implementation";case Ce.MissingCaller:return"This action is missing a caller";case Ce.NameAsResolvedCodeNameNotUniqueInScope:return"This entity has a name that is not unique in the scope of the code it is used in";case Ce.NameCanOnlyContainLettersNumbersUnderscoreAndSpaces:return"This entity name can only contain letters, numbers, underscores and spaces";case Ce.NameMustStartWithLetterOrUnderscore:return"This entity name must start with a letter or an underscore";case Ce.NoOverlapWithImplementedSignature:return"This action does not overlap with the implemented action signature";case Ce.PropertyOverwritesBasePropertyWithSameImplementation:return"This property overwrites a base property with the same implementation";case Ce.PropertyOverwritesOtherExtendedEntitysPropertyWithSameImplementation:return"This property overwrites a property in an extended entity with the same implementation";case Ce.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation:return"This property overwrites a property in an implemented entity with the same implementation";case Ce.ReaderWriterIncompatibleDataType:return"This reader/writer has an incompatible data type with the value it is reading/writing";case dd.StatusCodeMustBeBetween100And599:return"HTTP status code must be between 100 and 599";case dd.StatusCodeMustBeNumber:return"HTTP status code must be a number, between 100 and 599";case as.UUIDMustBeString:return`UUID must be a string, eg: "${op()}"`;case as.UUIDMustNotContainSpaces:return`UUID must not contain spaces, eg: "${op()}"`;case as.UUIDMustBeValidFormat:return`UUID must be in a valid format. Eg: "${op()}"`;case wn.MustBeUniqueAmongSameEntities:return"This value must be unique among the same kind";case wn.StringValueMustNotHaveDashes:return"This value must not contain dashes";case wn.StringValueMustNotHaveSpaces:return"This value must not contain spaces";case wn.ValueMustBeString:return"This value must be a string";case NT.DayOfMonthAndWeekConflict:return"Cron expression cannot have both day of month and day of week";case NT.InvalidCharacters:return"Cron expression has invalid characters";case NT.MustHaveSixFields:return"Cron expression must have six fields";default:return mE(l.code)}}function dRi(l){switch(l.code){case be.AbstractEntityWithNonAbstractMethods:return"Non-template actions";case be.AbstractEntityWithNonAbstractProperties:return"Non-template properties";case be.IncorrectEntityImplementation:return"Incorrect implementation";case be.IncorrectMethodImplementation:return"Incorrect action implementation";case be.IncorrectPropertyImplementation:return"Incorrect property implementation";case be.AbstractMethodInNonAbstractEntity:return"Template action in non-template entity";case be.AbstractPropertyInNonAbstractEntity:return"Template property in non-template entity";case Ce.MethodOverwritesOtherSiblingWithSameName:return"Action overwrite";case Ce.PropertyOverwritesOtherSiblingWithSameName:return"Property overwrite";case be.MissingMethodImplementation:return"Missing action";case be.MissingPropertyImplementation:return"Missing property";case Ce.NameNotUniqueInScope:return"Duplicate name";case be.NoProperties:return"No properties";case be.NonStaticPropertyInStaticEntity:return"Non-static property";case be.StaticEntityWithNonStaticProperties:return"Non-static properties";case be.ReadingFromIncompatibleType:return"Read from different type";case be.WritingToIncompatibleType:return"Write to different type";case be.ScopeWithoutLogic:return"No logic";case be.NonStaticPropertyImplementsStatic:return"Invalid static property";case be.PropertyImplementsIncompatibleType:return"Incompatible data type";case be.PropertyImplementsNonAbstact:return"Non-template property";case be.StaticPropertyImplementsNonStatic:return"Non-static property";case be.VariableCallsOthersAndHasInternalCall:return"Bad internal call";case be.VariableHasInputsAndInternalCall:return"Bad internal call";case be.VariableHasOutputsAndInternalCall:return"Bad internal call";case be.VariableIsCalledAndHasInternalCall:return"Bad internal call";case Ce.InternalCallDeclarationIsInvalidType:return"Declaration not an action";case Ce.InternalCallDeclarationNotFoundInParentDatatypeEntity:return"Declaration not found in parent";case Ce.InternalCallParentDeclarationEntityInvalidType:return"Invalid parent declaration type";case Ce.InternalCallParentMissingDataType:return"Parent has no data type";case Ce.InternalCallDeclarationNotInParentDatatypeEntity:return"Declaration not in parent";case Ce.UnreachableEntity:return"Unreachable entity";case be.DisconnectedCallableEntity:return"Disconnected entity";case be.AbstractEntityImplements:return"Abstract entity implements a non-template entity";case be.AbstractExtendingNonAbstractEntity:return"Abstract entity extends a non-template entity";case be.InvalidPropertiesCombination:return"Invalid properties combination";case be.ExtendingNonInteractiveEntity:return"Extending non-interactive entity";case be.ExtendsIncompatibleEntities:return"Extends incompatible entities";case be.ImplementingNonAbstractEntity:return"Implementing non-template entity";case be.ImplementsIncompatibleEntities:return"Implements incompatible entities";case be.LackingReturnStatementOnSomeBranches:return"Missing termination on some branches";case be.LastCalledEntityMustBeReturnEntity:return"Last called entity must be a termination node";case be.MissingRequiredValue:return"Missing required value";case be.NoPrimaryKeyProperty:return"No primary key property";case be.NonAbstractExtendingAbstractEntity:return"Non-template entity extending a template entity";case be.NonStaticExtendingStaticEntity:return"Non-static entity extending a static entity";case be.NonStaticImplementingStaticEntity:return"Non-static entity implementing a static entity";case be.StaticExtendingNonStaticEntity:return"Static entity extending a non-static entity";case be.StaticImplementingNonStaticEntity:return"Static entity implementing a non-static entity";case be.VariableReadsValueAndInternalCall:return"Variable reads value and has internal call";case be.VariableWritesValuesAndInternalCall:return"Variable writes values and has internal call";case Ce.EmptyName:return"Empty name";case Ce.InvalidObjectStructure:return"Invalid object structure";case Ce.LoopBodyFunctionOverwrite:return"Loop body action overwrites action with same name";case Ce.MethodOverwritesBaseMethodWithSameImplementation:return"Action overwrites base action with same implementation";case Ce.MethodOverwritesOtherExtendedEntitysMethodWithSameImplementation:return"Action overwrites another with same implementation";case Ce.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation:return"Action overwrites another with same implementation";case Ce.MissingCaller:return"Missing caller";case Ce.NameAsResolvedCodeNameNotUniqueInScope:return"Name not unique in scope";case Ce.NameCanOnlyContainLettersNumbersUnderscoreAndSpaces:return"Name can only contain letters, numbers, underscores and spaces";case Ce.NameMustStartWithLetterOrUnderscore:return"Name must start with letter or underscore";case Ce.NoOverlapWithImplementedSignature:return"No overlap with implemented signature";case Ce.PropertyOverwritesBasePropertyWithSameImplementation:return"Property overwrites base property with same implementation";case Ce.PropertyOverwritesOtherExtendedEntitysPropertyWithSameImplementation:return"Property overwrites another with same implementation";case Ce.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation:return"Property overwrites another with same implementation";case Ce.ReaderWriterIncompatibleDataType:return"Reader/writer incompatible data type";case dd.StatusCodeMustBeBetween100And599:return"HTTP status code must be between 100 and 599";case dd.StatusCodeMustBeNumber:return"HTTP status code must be a number";case as.UUIDMustBeString:return"UUID must be a string";case as.UUIDMustNotContainSpaces:return"UUID must not contain spaces";case as.UUIDMustBeValidFormat:return"UUID must be in a valid format";case wn.MustBeUniqueAmongSameEntities:return"This value must be unique among the same kind";case wn.StringValueMustNotHaveDashes:return"This value must not contain dashes";case wn.StringValueMustNotHaveSpaces:return"This value must not contain spaces";default:return mE(l.code)}}function uRi(l){switch(l.code){case be.AbstractEntityWithNonAbstractMethods:return`${le(l.entity,l.entity.project)} has non-template actions`;case be.AbstractEntityWithNonAbstractProperties:return`${le(l.entity,l.entity.project)} has non-template properties`;case be.IncorrectEntityImplementation:return`${le(l.entity,l.entity.project)} incorrectly implements template`;case be.IncorrectMethodImplementation:return`${le(l.entity,l.entity.project)} incorrectly implements the template`;case be.IncorrectPropertyImplementation:return`${le(l.entity,l.entity.project)} incorrectly implements the template`;case be.AbstractMethodInNonAbstractEntity:return`${le(l.entity,l.entity.project)} can't be a template`;case be.AbstractPropertyInNonAbstractEntity:return`${le(l.entity,l.entity.project)} can't be a template`;case Ce.MethodOverwritesOtherSiblingWithSameName:return`${le(l.entity,l.entity.project)} overwrites action`;case Ce.PropertyOverwritesOtherSiblingWithSameName:return`${le(l.entity,l.entity.project)} overwrites property`;case be.MissingMethodImplementation:return`${le(l.entity,l.entity.project)} is missing action`;case be.MissingPropertyImplementation:return`${le(l.entity,l.entity.project)} is missing property`;case Ce.NameNotUniqueInScope:return`${le(l.entity,l.entity.project)} name is not unique`;case be.NoProperties:return`${le(l.entity,l.entity.project)} has no properties`;case be.NonStaticPropertyInStaticEntity:return`${le(l.entity,l.entity.project)} has non-static property`;case be.StaticEntityWithNonStaticProperties:return`${le(l.entity,l.entity.project)} has non-static properties`;case be.ReadingFromIncompatibleType:return`${le(l.entity,l.entity.project)} reads from different type`;case be.WritingToIncompatibleType:return`${le(l.entity,l.entity.project)} writes to different type`;case be.ScopeWithoutLogic:return`${le(l.entity,l.entity.project)} has no logic`;case be.NonStaticPropertyImplementsStatic:return`${le(l.entity,l.entity.project)} has invalid static property`;case be.PropertyImplementsIncompatibleType:return`${le(l.entity,l.entity.project)} has incompatible data type`;case be.PropertyImplementsNonAbstact:return`${le(l.entity,l.entity.project)} has non-template property`;case be.StaticPropertyImplementsNonStatic:return`${le(l.entity,l.entity.project)} has non-static property`;case be.VariableCallsOthersAndHasInternalCall:return`${le(l.entity,l.entity.project)} has bad internal call`;case be.VariableHasInputsAndInternalCall:return`${le(l.entity,l.entity.project)} has bad internal call`;case be.VariableHasOutputsAndInternalCall:return`${le(l.entity,l.entity.project)} has bad internal call`;case be.VariableIsCalledAndHasInternalCall:return`${le(l.entity,l.entity.project)} has bad internal call`;case Ce.InternalCallDeclarationIsInvalidType:return`${le(l.entity,l.entity.project)} has declaration that is not an action`;case Ce.InternalCallDeclarationNotFoundInParentDatatypeEntity:return`${le(l.entity,l.entity.project)} has declaration that is not found in parent`;case Ce.InternalCallParentDeclarationEntityInvalidType:return`${le(l.entity,l.entity.project)} has invalid parent declaration type`;case Ce.InternalCallParentMissingDataType:return`${le(l.entity,l.entity.project)}'s parent has no data type`;case Ce.InternalCallDeclarationNotInParentDatatypeEntity:return`${le(l.entity,l.entity.project)} has declaration that is not in parent`;case Ce.UnreachableEntity:return`${le(l.entity,l.entity.project)} is unreachable`;case be.DisconnectedCallableEntity:return`${le(l.entity,l.entity.project)} is not executed by any entity`;case be.AbstractEntityImplements:return`${le(l.entity,l.entity.project)} implements a non-template entity`;case be.AbstractExtendingNonAbstractEntity:return`${le(l.entity,l.entity.project)} extends a non-template entity`;case be.InvalidPropertiesCombination:return`${le(l.entity,l.entity.project)} has invalid properties combination`;case be.ExtendingNonInteractiveEntity:return`${le(l.entity,l.entity.project)} extends a non-interactive entity`;case be.ExtendsIncompatibleEntities:return`${le(l.entity,l.entity.project)} extends incompatible entities`;case be.ImplementingNonAbstractEntity:return`${le(l.entity,l.entity.project)} implements a non-template entity`;case be.ImplementsIncompatibleEntities:return`${le(l.entity,l.entity.project)} implements incompatible entities`;case be.LackingReturnStatementOnSomeBranches:return`${le(l.entity,l.entity.project)} is missing termination on some branches`;case be.LastCalledEntityMustBeReturnEntity:return`${le(l.entity,l.entity.project)}'s last called entity must be a termination node`;case be.MissingRequiredValue:return`${le(l.entity,l.entity.project)} is missing a required value`;case be.NoPrimaryKeyProperty:return`${le(l.entity,l.entity.project)} has no primary key property`;case be.NonAbstractExtendingAbstractEntity:return`${le(l.entity,l.entity.project)} extends a template entity`;case be.NonStaticExtendingStaticEntity:return`${le(l.entity,l.entity.project)} extends a static entity`;case be.NonStaticImplementingStaticEntity:return`${le(l.entity,l.entity.project)} implements a static entity`;case be.StaticExtendingNonStaticEntity:return`${le(l.entity,l.entity.project)} extends a non-static entity`;case be.StaticImplementingNonStaticEntity:return`${le(l.entity,l.entity.project)} implements a non-static entity`;case be.VariableReadsValueAndInternalCall:return`${le(l.entity,l.entity.project)} reads a value and has internal call`;case be.VariableWritesValuesAndInternalCall:return`${le(l.entity,l.entity.project)} writes values and has internal call`;case Ce.EmptyName:return`${is[l.entity.type]} has no name`;case Ce.InvalidObjectStructure:return`${le(l.entity,l.entity.project)} has invalid structure`;case Ce.LoopBodyFunctionOverwrite:return`${le(l.entity,l.entity.project)}'s loop body action overwrites an action`;case Ce.MethodOverwritesBaseMethodWithSameImplementation:return`${le(l.entity,l.entity.project)} overwrites base action`;case Ce.MethodOverwritesOtherExtendedEntitysMethodWithSameImplementation:return`${le(l.entity,l.entity.project)} overwrites another action with same implementation`;case Ce.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation:return`${le(l.entity,l.entity.project)} overwrites another action with same implementation`;case Ce.MissingCaller:return`${le(l.entity,l.entity.project)} is missing a caller`;case Ce.NameAsResolvedCodeNameNotUniqueInScope:return`${le(l.entity,l.entity.project)} has a name not unique in the scope`;case Ce.NameCanOnlyContainLettersNumbersUnderscoreAndSpaces:return`${le(l.entity,l.entity.project)} name can only contain letters, numbers, underscores and spaces`;case Ce.NameMustStartWithLetterOrUnderscore:return`${le(l.entity,l.entity.project)} name must start with letter or underscore`;case Ce.NoOverlapWithImplementedSignature:return`${le(l.entity,l.entity.project)} has no overlap with implemented signature`;case Ce.PropertyOverwritesBasePropertyWithSameImplementation:return`${le(l.entity,l.entity.project)} overwrites base property`;case Ce.PropertyOverwritesOtherExtendedEntitysPropertyWithSameImplementation:return`${le(l.entity,l.entity.project)} overwrites another property with same implementation`;case Ce.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation:return`${le(l.entity,l.entity.project)} overwrites another property with same implementation`;case Ce.ReaderWriterIncompatibleDataType:return`${le(l.entity,l.entity.project)} has reader/writer with incompatible data type`;case dd.StatusCodeMustBeBetween100And599:return`${le(l.entity,l.entity.project)} HTTP status code must be between 100 and 599`;case dd.StatusCodeMustBeNumber:return`${le(l.entity,l.entity.project)} HTTP status code must be a number`;case as.UUIDMustBeString:return`${le(l.entity,l.entity.project)} UUID must be a string`;case as.UUIDMustNotContainSpaces:return`${le(l.entity,l.entity.project)} UUID must not contain spaces`;case as.UUIDMustBeValidFormat:return`${le(l.entity,l.entity.project)} UUID must be in a valid format`;case wn.MustBeUniqueAmongSameEntities:return`${le(l.entity,l.entity.project)} value must be unique among the same kind`;case wn.StringValueMustNotHaveDashes:return`${le(l.entity,l.entity.project)} value must not contain dashes`;case wn.StringValueMustNotHaveSpaces:return`${le(l.entity,l.entity.project)} value must not contain spaces`;default:return`${le(l.entity,l.entity.project)} Error: ${mE(l.code)}`}}function pRi(l){var p,i,r,a;switch(l.code){case be.AbstractEntityWithNonAbstractMethods:return`${le(l.entity,l.entity.project)} has non-template actions`;case be.AbstractEntityWithNonAbstractProperties:return`${le(l.entity,l.entity.project)} has non-template properties`;case be.IncorrectEntityImplementation:return`${le(l.entity,l.entity.project)} incorrectly implements the template entity`;case be.IncorrectMethodImplementation:return`${le(l.entity,l.entity.project)} incorrectly implements the template action it's based on`;case be.IncorrectPropertyImplementation:return`${le(l.entity,l.entity.project)} incorrectly implements the template property it's based on`;case be.AbstractMethodInNonAbstractEntity:return`${le(l.entity,l.entity.project)} is a template action in a non-template entity`;case be.AbstractPropertyInNonAbstractEntity:return`${le(l.entity,l.entity.project)} is a template property in a non-template entity`;case Ce.MethodOverwritesOtherSiblingWithSameName:return`${le(l.entity,l.entity.project)} overwrites an action in the template entity`;case Ce.PropertyOverwritesOtherSiblingWithSameName:return`${le(l.entity,l.entity.project)} overwrites a property in the template entity`;case be.MissingMethodImplementation:return`${le(l.entity,l.entity.project)} is missing an action implementation from the template entity`;case be.MissingPropertyImplementation:return`${le(l.entity,l.entity.project)} is missing a property implementation from the template entity`;case Ce.NameNotUniqueInScope:return`${le(l.entity,l.entity.project)} has a duplicate name in the same scope`;case be.NoProperties:return`${le(l.entity,l.entity.project)} has no properties, so it doesn't do anything`;case be.NonStaticPropertyInStaticEntity:return`${le(l.entity,l.entity.project)} has a non-static property in a static entity`;case be.StaticEntityWithNonStaticProperties:return`${le(l.entity,l.entity.project)} has non-static properties in a static entity`;case be.ReadingFromIncompatibleType:return`${le(l.entity,l.entity.project)} reads data from a value of a different data type`;case be.WritingToIncompatibleType:return`${le(l.entity,l.entity.project)} writes data to a value of a different data type`;case be.ScopeWithoutLogic:return`${le(l.entity,l.entity.project)} has no logic`;case be.NonStaticPropertyImplementsStatic:return`${le(l.entity,l.entity.project)} has a static property in a non-static entity`;case be.PropertyImplementsIncompatibleType:return`${le(l.entity,l.entity.project)} implements a property of a different data type`;case be.PropertyImplementsNonAbstact:return`${le(l.entity,l.entity.project)} implements a non-template property`;case be.StaticPropertyImplementsNonStatic:return`${le(l.entity,l.entity.project)} has a static property in a non-static entity`;case be.VariableCallsOthersAndHasInternalCall:return`${le(l.entity,l.entity.project)} calls other entities while being used to execute internal logic`;case be.VariableHasInputsAndInternalCall:return`${le(l.entity,l.entity.project)} has inputs while being used to execute internal logic`;case be.VariableHasOutputsAndInternalCall:return`${le(l.entity,l.entity.project)} has outputs while being used to execute internal logic`;case be.VariableIsCalledAndHasInternalCall:return`${le(l.entity,l.entity.project)} is called while being used to execute internal logic`;case Ce.InternalCallDeclarationIsInvalidType:return`${le(l.entity,l.entity.project)} has a declaration that is not an action`;case Ce.InternalCallDeclarationNotFoundInParentDatatypeEntity:return`${le(l.entity,l.entity.project)} has a declaration that is not found in ${(p=l.entity.parent.getDataType(null))!=null&&p.entity?le((i=l.entity.parent.getDataType(null))==null?void 0:i.entity,l.entity.project):"the variable's data-type entity"}`;case Ce.InternalCallParentDeclarationEntityInvalidType:return`${le(l.entity,l.entity.project)} is part of a variable whos data-type entity can't have actions`;case Ce.InternalCallParentMissingDataType:return`${le(l.entity,l.entity.project)} is part of a variable with no data-type entity`;case Ce.InternalCallDeclarationNotInParentDatatypeEntity:return`${le(l.entity,l.entity.project)} has a declaration doesn't belong to ${(r=l.entity.parent.getDataType(null))!=null&&r.entity?le((a=l.entity.parent.getDataType(null))==null?void 0:a.entity,l.entity.project):"the variable's data-type entity"}`;case Ce.UnreachableEntity:return`${le(l.entity,l.entity.project)} is unreachable`;case be.DisconnectedCallableEntity:return`${le(l.entity,l.entity.project)} is disconnected and won't be executed by anything after publishing`;case be.AbstractEntityImplements:return`${le(l.entity,l.entity.project)} implements a non-template entity`;case be.AbstractExtendingNonAbstractEntity:return`${le(l.entity,l.entity.project)} extends a non-template entity`;case be.InvalidPropertiesCombination:return`${le(l.entity,l.entity.project)} has an invalid combination of properties`;case be.ExtendingNonInteractiveEntity:return`${le(l.entity,l.entity.project)} extends a non-interactive entity`;case be.ExtendsIncompatibleEntities:return`${le(l.entity,l.entity.project)} extends incompatible entities`;case be.ImplementingNonAbstractEntity:return`${le(l.entity,l.entity.project)} implements a non-template entity`;case be.ImplementsIncompatibleEntities:return`${le(l.entity,l.entity.project)} implements incompatible entities`;case be.LackingReturnStatementOnSomeBranches:return`${le(l.entity,l.entity.project)} has branches that don't terminate`;case be.LastCalledEntityMustBeReturnEntity:return`${le(l.entity,l.entity.project)} must end with a termination node`;case be.MissingRequiredValue:return`${le(l.entity,l.entity.project)} is missing a required value`;case be.NoPrimaryKeyProperty:return`${le(l.entity,l.entity.project)} has no primary key property`;case be.NonAbstractExtendingAbstractEntity:return`${le(l.entity,l.entity.project)} is a non-template entity extending a template entity`;case be.NonStaticExtendingStaticEntity:return`${le(l.entity,l.entity.project)} is a non-static entity extending a static entity`;case be.NonStaticImplementingStaticEntity:return`${le(l.entity,l.entity.project)} is a non-static entity implementing a static entity`;case be.StaticExtendingNonStaticEntity:return`${le(l.entity,l.entity.project)} is a static entity extending a non-static entity`;case be.StaticImplementingNonStaticEntity:return`${le(l.entity,l.entity.project)} is a static entity implementing a non-static entity`;case be.VariableReadsValueAndInternalCall:return`${le(l.entity,l.entity.project)} reads a value and has an internal call`;case be.VariableWritesValuesAndInternalCall:return`${le(l.entity,l.entity.project)} writes values and has an internal call`;case Ce.EmptyName:return`${is[l.entity.type]} has no name`;case Ce.InvalidObjectStructure:return`${le(l.entity,l.entity.project)} has an invalid structure`;case Ce.LoopBodyFunctionOverwrite:return`${le(l.entity,l.entity.project)}'s loop body action overwrites`;case Ce.MethodOverwritesBaseMethodWithSameImplementation:return`${le(l.entity,l.entity.project)} overwrites a base action with same implementation`;case Ce.MethodOverwritesOtherExtendedEntitysMethodWithSameImplementation:return`${le(l.entity,l.entity.project)} overwrites another action with same implementation`;case Ce.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation:return`${le(l.entity,l.entity.project)} overwrites another action with same implementation`;case Ce.MissingCaller:return`${le(l.entity,l.entity.project)} is missing a caller`;case Ce.NameAsResolvedCodeNameNotUniqueInScope:return`${le(l.entity,l.entity.project)} has a name that is not unique in the scope`;case Ce.NameCanOnlyContainLettersNumbersUnderscoreAndSpaces:return`${le(l.entity,l.entity.project)} name can only contain letters, numbers, underscores and spaces`;case Ce.NameMustStartWithLetterOrUnderscore:return`${le(l.entity,l.entity.project)} name must start with letter or underscore`;case Ce.NoOverlapWithImplementedSignature:return`${le(l.entity,l.entity.project)} has no overlap with implemented signature`;case Ce.PropertyOverwritesBasePropertyWithSameImplementation:return`${le(l.entity,l.entity.project)} overwrites a base property with same implementation`;case Ce.PropertyOverwritesOtherExtendedEntitysPropertyWithSameImplementation:return`${le(l.entity,l.entity.project)} overwrites another property with same implementation`;case Ce.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation:return`${le(l.entity,l.entity.project)} overwrites another property with same implementation`;case Ce.ReaderWriterIncompatibleDataType:return`${le(l.entity,l.entity.project)} has a reader/writer with incompatible data type`;case dd.StatusCodeMustBeBetween100And599:return`${le(l.entity,l.entity.project)} HTTP status code must be between 100 and 599`;case dd.StatusCodeMustBeNumber:return`${le(l.entity,l.entity.project)} HTTP status code must be a number, between 100 and 599`;case as.UUIDMustBeString:return`${le(l.entity,l.entity.project)} UUID must be a string, eg: "${op()}"`;case as.UUIDMustNotContainSpaces:return`${le(l.entity,l.entity.project)} UUID must not contain spaces, eg: "${op()}"`;case as.UUIDMustBeValidFormat:return`${le(l.entity,l.entity.project)} UUID must be in a valid format. Eg: "${op()}"`;case wn.MustBeUniqueAmongSameEntities:return`${le(l.entity,l.entity.project)} value must be unique among the same kind`;case wn.StringValueMustNotHaveDashes:return`${le(l.entity,l.entity.project)} value must not contain dashes`;case wn.StringValueMustNotHaveSpaces:return`${le(l.entity,l.entity.project)} value must not contain spaces`;default:return`${le(l.entity,l.entity.project)} Error: ${mE(l.code)}`}}function TE(l){const p=(l||"").startsWith("error-caller-only--");switch(p?l.replace("error-caller-only--",""):l){case Wt.CallIsInHigherScope:return"In a higher scope";case Wt.CallIsInLowerScope:return"In a lower scope";case Wt.CallerIsInHigherScope:return"Caller is in a higher scope";case Wt.CallerIsInLowerScope:return"Caller is in a lower scope";case Wt.CannotBeCalledByChildren:return"Cannot be called by children";case Wt.CannotCallAncestor:return"Cannot call ancestor";case Wt.CannotConnectToItself:return"Cannot connect to itself";case Wt.CannotReadMoreThanOneValue:return"Cannot read more than one value";case Wt.CannotReadValueFromChildren:return"Cannot read value from entities executed after itself";case Wt.CannotWriteValueToAncestor:return"Cannot write value to ancestor";case nv.Suggestion:return"Suggestion";case Wt.ContinueOrBreakStatementCalledFromOutsideLoop:return"Cannot be called from outside loop";case Wt.DataTypesNotCompatible:return"Data types not compatible";case Wt.ElementInLoopBodyCallingOutsideLoop:return"Cannot call outside loop";case Wt.ErrorOututMapCannotBeConnectedToParentSuccessBranchCallees:return"Error cannot be connected to success branch";case Wt.ExecutionsAlreadyConnected:return"Executions already connected";case Wt.IsNotValueReadingEntity:return"Is not a value reading entity";case Wt.IsNotValueWritingEntity:return"Is not a value writing entity";case Wt.NotInScope:return"Not in a compatible scope";case Wt.OtherIncompatibleScopeReason:return"Incompatible scope";case Wt.SiblingInternalCallAlreadyUsedInParentVariable:return"Internal call already used in parent variable";case Wt.SuccessOutputMapCannotBeConnectedToParentErrorBranchCallees:return"Success cannot be connected to error branch";case Wt.ValuesAlreadyConnected:return"Values already connected";case Wt.CannotInteractWithInputInVariableWithInternalCalls:return"Cannot interact with input in variable with internal calls";case Wt.CannotInteractWithOutputInVariableWithInternalCalls:return"Cannot interact with output in variable with internal calls";case nv.CanvasGloballyDisabled:return"Canvas is globally disabled";case Wt.PropertyIsConstantItsValueCantBeReset:return"Property is constant, its value can't be reset";case Wt.CannotWriteValueOfGlobalVariableDeclaration:return"Cannot write value of global variable declaration";case Wt.CannotReSetValueOfConstantVariable:return"Cannot re-set value of constant variable";case Wt.CannotConnectToOwnNode:return"It is part of the same node";case Wt.CalledByErrorMustBePassThroughCallable:return"Called by error must be pass-through callable";case Wt.CannotChangeScopeBecauseItCallsOtherEntities:return"Cannot change scope because it calls other entities in its current scope";case Wt.CannotChangeScopeBecauseItIsAlreadyCalledByOtherEntitiesInDifferentScope:return"Cannot change scope because it is already called by other entities in different scope";case Wt.VariableDeclarationCannotBeMovedToLowerScopeBecauseInstancesUsage:return"Variable declaration cannot be moved to lower scope because its instances are used in the current or different incompatible lower scope";case Wt.CalledBySourceMustBeCallerEntity:return"Not a caller type";case Wt.CalledByErrorCannotBeConnectedToEntitiesCalledByOwnSuccessBranch:return"Already connected to the success branch from a common origin caller";case Wt.CalledBySuccessCannotBeConnectedToEntitiesCalledByOwnErrorBranch:return"Already connected to the error branch from a common origin caller";case Wt.RedundantCall:return"Redundant call. Already connected further down the execution path";case Wt.CannotBeCalledBeforeDeclaration:return"Cannot be called before declaration";case Wt.CannotBeCalledInParallelBranchToDeclaration:return"Cannot be called in parallel branch to declaration";case Wt.CannotBeHigherScopeThanDeclaration:return"Cannot be in a higher scope than declaration";case Wt.CannotCallGlobalVariableDeclaration:return"Cannot call global variable declaration";case Wt.EntityAlreadyCalledBySuccessCannotBeConnectedToUnrelatedErrorBranch:return p?"Cannot connect error: Already connected to a success branch from a common origin caller":"Already connected to a success branch from a common origin caller";case Wt.CannotInteractWithInputInGlobalVariableDeclaration:return"Cannot interact with input in global variable declaration";case Wt.IsNotCallableEntity:return"Is not a callable node type";case Wt.IsNotCallerEntity:return"Is not a caller node type";case Wt.IsNotPassThroughCallableEntity:return"Is not a pass-through callable node type that has an error branch";case Wt.NotAConnectableEntityType:return"Not a connectable node type";case Wt.WouldMakeAnEarlierNodeBeCalledBeforeItsDeclaration:return"Would make an earlier node be called before its declaration";default:return Rc(l||"")}}function cRi(l,p){const i=[...l,...p],r=Array.from(new Set(i));return{hasChanged:r.length!==l.length,reasons:r}}function fRi(l,p){const i=l.filter(a=>!p.includes(a));return{hasChanged:i.length!==l.length,reasons:i}}function yRi(l,p){return l.find(i=>i.entity.id===p)||null}function Zk(l){return l.filter((p,i)=>l.indexOf(p)===i)}class Xr{constructor(p,i,r=null,a){R(this,"ids",[]);R(this,"entity");R(this,"entityCardHeight");R(this,"entityCardWidth");R(this,"index");R(this,"childEntities",[]);R(this,"children",[]);R(this,"parents",[]);R(this,"calculationEntryPoint");R(this,"_onlyEntities",null);R(this,"_changeSet",null);if(this.index=i,this.entity=p,this.calculationEntryPoint=r||this,this._changeSet=a||null,this===this.calculationEntryPoint&&!a)throw new Error("Change-set must be provided for the calculation entry point");this.calculateCardSize(),this.getSortedChildren()}static autoGenerateLayout(p,i,r){const a=RBe-OI-i$,c=DBe-nI-r$;p.type===d.Project?(p.x=a,p.y=c):p.metaSync({x:p.x||a,y:p.y||c},i);const e=new Xr(p,0,null,i);e.calculationEntryPoint=e,e._onlyEntities=r||[],e.ids=["0"];const f=[];e.next(m=>{f.push(...m)}),Xr.recursivelyAssembleChildrenAreas(f),e.resolveChildrenOverlaps();const h=e.flattenChildEntities();return e._onlyEntities?h.filter(m=>{var E;return(E=e._onlyEntities)==null?void 0:E.includes(m)}):h}static recursivelyAssembleChildrenAreas(p){const i=[];p.forEach(r=>{r.next(a=>{i.push(...a)})}),i.length>0&&Xr.recursivelyAssembleChildrenAreas(i)}get onlyEntities(){return this.calculationEntryPoint._onlyEntities||[]}get changeSet(){return this.calculationEntryPoint._changeSet}set changeSet(p){this.calculationEntryPoint._changeSet=p}findAreaInChildrenFromEntity(p){if(this.entity===p)return this;const i=this.children.find(a=>a.entity===p);return i||this.children.reduce((a,c)=>a||c.findAreaInChildrenFromEntity(p),null)}findAreaFromEntity(p){if(this.entity===p)return this;const i=this.calculationEntryPoint.children,r=i.find(c=>c.entity===p);return r||i.reduce((c,e)=>c||e.findAreaInChildrenFromEntity(p),null)}addParent(p){if(!this.parents.includes(p)){const i=Xr.resolveIds(p,this.index);this.ids.push(...i),this.parents.push(p)}}static resolveIds(p,i){return p?p.ids.map(r=>`${r}-${i}`):[`${i}`]}getSortedChildren(){if(this.entity.collapsed){this.childEntities=[];return}const p=Ql(this.entity,!0);if(this.entity.type===d.Project){const i=[],r=[],a=[];p.forEach(e=>{if(d.DefinitionEntity===e.type){r.push(e);return}else if(Bt.includes(e.type)){a.push(e);return}i.push(e)});const c=i.sort((e,f)=>{const h=!!UI(e,f).length,m=Ql(e),E=Ql(f);return h?0:m.length&&!E.length?-1:!m.length&&E.length?1:0}).filter(e=>!_c(e).length);this.childEntities=[...r,...a,...c]}else{const i=[],r=[],a=[],c=[],e=[];Wi.includes(this.entity.type)&&Q1(this.entity).forEach(m=>{if(xt.includes(m.type)){a.push(m);return}const E=yt(m);i.push(E)}),br.includes(this.entity.type)&&r.push(...this.entity.detachedChildren);const f=p.filter(h=>{const m=i.includes(h);return m||a.includes(h)||r.includes(h)?!1:xt.includes(h.type)?(a.push(h),!1):er.includes(h.type)&&!m?(c.push(h),!1):h.type===d.DefinitionEntity?(e.push(h),!1):!0});i.sort((h,m)=>Wl(h,m)?-1:0),c.sort((h,m)=>Wl(h,m)?-1:0),a.sort((h,m)=>sV(h,m)?1:sV(m,h)?-1:0),this.childEntities=[...e,...i,...c,...f,...a,...r]}}calculateCardSize(){const p=wBe(this.entity);this.entityCardWidth=p.width,this.entityCardHeight=p.height}static getBoundriesOfTwoAreas(p,i){return{top:Math.min(p.top,i.top),left:Math.min(p.left,i.left),bottom:Math.max(p.bottom,i.bottom),right:Math.max(p.right,i.right)}}static getBoundriedOfCombinedAreas(p,i){const r=p.filter(c=>!i.includes(c));return r.reduce((c,e)=>i.includes(e)?c:Xr.getBoundriesOfTwoAreas(c,e.fullBranchArea),r[0].fullBranchArea)}getFullAreaUntilAny(p){const i=this.ownEntityPlusBufferArea;return this.children.filter(e=>!p.includes(e)).map(e=>e.getFullAreaUntilAny(p)).reduce((e,f)=>Xr.getBoundriesOfTwoAreas(e,f),i)}getFullAreaUntilAreaOrAnyChildren(p){const i=[p,...p.flattenChildren()],r=this.ownEntityPlusBufferArea;return this.children.filter(e=>i.includes(e)).map(e=>e.getFullAreaUntil(p)).reduce((e,f)=>Xr.getBoundriesOfTwoAreas(e,f),r)}getFullAreaUntil(p){const i=this.ownEntityPlusBufferArea;return this.children.filter(c=>c!==p).map(c=>c.getFullAreaUntil(p)).reduce((c,e)=>Xr.getBoundriesOfTwoAreas(c,e),i)}get fullBranchArea(){const p=this.ownEntityPlusBufferArea;return this.children.map(a=>a.fullBranchArea).reduce((a,c)=>Xr.getBoundriesOfTwoAreas(a,c),p)}get ownEntityArea(){return{top:this.entity.y,left:this.entity.x,bottom:this.entity.y+this.entityCardHeight,right:this.entity.x+this.entityCardWidth}}get ownEntityPlusBufferArea(){const p=this.ownEntityArea;return{top:p.top,left:p.left,bottom:p.bottom+nI,right:p.right+OI}}static filterOutRepeatedAreas(p){return p.filter((i,r)=>p.indexOf(i)===r)}getEarliestId(p,i){const r=p.split("-"),a=i.split("-");return r.length<a.length?p:r.length>a.length?i:r.reduce((e,f,h)=>f<a[h]?p:i,p)}getEarliestLevel(){return this.ids.reduce((r,a)=>this.getEarliestId(r,a),this.ids[0]).split("-").length}countColumns(){let p=0;if(this!==this.calculationEntryPoint)p++;else return p;if(!this.parents.length)return p;const r=this.parents.reduce((a,c)=>c.getEarliestLevel()>a.getEarliestLevel()?c:a,this.parents[0]).countColumns();return p+=r,p}getLatestId(p,i){if(p===i)return p;const r=p.split("-"),a=i.split("-");return r.length<a.length?i:r.length>a.length?p:r.reduce((e,f,h)=>f>a[h]?p:i,p)}getLatestLevel(){return this.ids.length===1?this.ids[0].split("-").length:this.ids.reduce((r,a)=>this.getLatestId(r,a),this.ids[0]).split("-").length}smoothPosition(){const p=this.flattenSiblings();if(!p.length&&this.parents.length<=1&&this.children.length){const i=this.centerHeaderVerticallyOverCombinedAllChildrenHeaderHeight();this.parents.forEach(r=>{r!==this.calculationEntryPoint&&r.shiftDownAlone(i)})}else if([...Bt].includes(this.entity.type)&&this.children.length)this.centerHeaderVerticallyOverCombinedAllChildrenHeaderHeight();else if(!this.children.length&&this.parents.length>1){const i=p.filter(r=>!this.parents.includes(r));i.length?i.every(a=>{const c=this.countColumns(),e=a.countColumns();return c>e})&&this.centerHeaderVerticallyOverCombinedAllParentsHeaderHeight():i.length||this.centerHeaderVerticallyOverCombinedAllParentsHeaderHeight()}}shiftDownUntilAny(p,i){if(p.includes(this))return p;this.move(this.entity,{y:this.entity.y+i});let r=[...p,this];return this.children.forEach(a=>{if(Xr.getEarliestParentInChain(a)!==this)return;const e=yRi(r,a.entity.id);r=Xr.filterOutRepeatedAreas([...r]),e||(r=r.filter(h=>h!==a));const f=a.shiftDownUntilAny(r,i);r.push(...f)}),r}shiftRightUntilAny(p,i){p.includes(this)||(this.move(this.entity,{x:this.entity.x+i}),this.children.forEach(r=>{const a=Xr.filterOutRepeatedAreas([...this.flattenSiblings(),...p]);Xr.getEarliestParentInChain(r)===this&&r.shiftRightUntilAny(a,i)}))}shiftRight(p){this.move(this.entity,{x:this.entity.x+p}),this.children.forEach(i=>{const a=i.flattenSiblings().filter(c=>c!==i);i.shiftRightUntilAny(a,p)})}shiftDownAlone(p){this.move(this.entity,{y:this.entity.y+p})}centerHeaderVerticallyOverCombinedAllParentsHeaderHeight(){const p=this.parents.reduce((a,c)=>{const e=c.ownEntityArea,f=e.top+of,h={top:f,left:e.left,bottom:f,right:e.right};return Xr.getBoundriesOfTwoAreas(a,h)},{top:1/0,left:1/0,bottom:-1/0,right:-1/0}),r=(p.bottom-p.top)/2-of;this.shiftDownAlone(r)}centerHeaderVerticallyOverCombinedAllChildrenHeaderHeight(){const p=this.children.reduce((a,c)=>{const e=c.ownEntityArea,f=e.top+of,h={top:f,left:e.left,bottom:f,right:e.right};return Xr.getBoundriesOfTwoAreas(a,h)},{top:1/0,left:1/0,bottom:-1/0,right:-1/0}),r=(p.bottom-p.top)/2-of;return this.shiftDownAlone(r),r}resolveChildrenOverlaps(){const p=this.flattenChildren();let i=[];p.forEach(r=>{const a=r.adjustVerticallyToAvoidOverlaps();i.push(...a)}),p.forEach(r=>{r.smoothPosition()})}static getEarliestParentInChain(p){let i=p.parents[0];return p.parents.length&&(i=p.parents.sort((r,a)=>{if(!r.ids.length)return-1;if(!a.ids.length)return 1;const c=r.ids.sort((f,h)=>f.length<h.length?-1:0),e=a.ids.sort((f,h)=>f.length<h.length?-1:0);return c[0].length-e[0].length})[0]),i}flattenEarlierSiblings(p=new Set){return p.add(this.entity.id),this.parents.reduce((r,a)=>{if(p.has(a.entity.id))return r;p.add(a.entity.id);const e=a.children.slice(0,a.children.indexOf(this)).reduce((f,h)=>[...f,h,...h.flattenChildren(p)],[]);return[...r,...e]},[])}flattenSiblings(p=new Set){return p.add(this.entity.id),this.parents.reduce((r,a)=>{if(p.has(a.entity.id))return r;p.add(a.entity.id);const e=a.children.filter(f=>f!==this).reduce((f,h)=>[...f,h,...h.flattenChildren(p)],[]);return[...r,...e]},[])}flattenChildren(p=new Set){return this.children.reduce((i,r)=>p.has(r.entity.id)?i:(p.add(r.entity.id),[...i,r,...r.flattenChildren(p)]),[])}flattenParents(p=new Set){return this.parents.reduce((r,a)=>p.has(a.entity.id)?r:(p.add(a.entity.id),[...r,a,...a.flattenParents(p)]),[])}getAreaIfRendered(p){return this.calculationEntryPoint.flattenChildren().find(a=>a.entity.id===p.id)||null}getLowerSiblings(){const p=this.parents.reduce((i,r)=>{const a=r.children.indexOf(this),c=r.children.slice(a+1);return[...i,...c]},[]);return Zk(p)}getLowerAreas(){const p=this.getLowerSiblings(),i=this.parents.reduce((r,a)=>[...r,...a.getLowerAreas()],[]);return Zk([...p,...i])}adjustVerticallyToAvoidOverlaps(p=[]){const r=Xr.getEarliestParentInChain(this).children[this.index-1];if(!r)return p;const a=this.flattenEarlierSiblings(),c=this.flattenParents(),e=[...a,...c,r],m=C(e.flatMap(_=>UI(this.entity,_.entity))).filter(_=>_.id!==this.entity.id).map(_=>this.findAreaFromEntity(_)).filter(_=>!!_),E=this.getFullAreaUntilAny(m),b=r.getFullAreaUntilAny(m),A=e.reduce((_,N)=>N===this||N.fullBranchArea.left!==E.left?_:Math.max(_,N.fullBranchArea.bottom),b.bottom);if(E.top<A){const _=A-E.top+nI;return this.shiftDownUntilAny(p,_)}return p}move(p,i){if(this.onlyEntities.includes(p)){if(!this.changeSet)throw new Error("Change set is not defined for this area, cannot move entity");p.metaSync(i,this.changeSet)}}addChild(p){const i=this.childEntities[p];let r=null;i.x&&i.y?r=this.getAreaIfRendered(i):!i.x&&!i.y&&this.move(i,{x:this.entity.x,y:this.entity.y}),r||(r=new Xr(i,p,this.calculationEntryPoint));const a=this.ownEntityPlusBufferArea;this.children.includes(r)||(this.children.push(r),r.addParent(this));const c=r.fullBranchArea;if(c.left<a.right){const e=a.right-c.left;r.shiftRight(e)}return r}flattenChildEntities(p=new Set){return this.children.reduce((i,r)=>p.has(r.entity.id)?i:(p.add(r.entity.id),[...i,r.entity,...r.flattenChildEntities(p)]),[])}next(p){const i=[];this.childEntities.forEach((r,a)=>{const c=this.addChild(a);c&&i.push(c)}),p(i)}}async function hRi(l,p,i={}){var c;const r=Y.YieldTracker.from(i),a=[];console.log("Generating layout for project...");for(const e of l.instancesList){if(l.diggestedBuiltInBaseEntitiesIds.has(e.id)||!Af.includes(e.type)||((c=yt(e))==null?void 0:c.id)!==e.id)continue;let f=Gt(e,l);if(!f){console.log("No top scope owner for instance: ",e," in project: ",l);continue}if(!(Bt.includes(f.type)&&f.collapsed&&f.id!==e.id)){for(;f.parent&&f.parent!==l;)f=f.parent,Bt.includes(f.type)&&f.collapsed&&(f.id,e.id);e.x=0,e.y=0,p==null||p.add(e,W.Updated),a.push(e),await r.tick()}}Xr.autoGenerateLayout(l,p,a)}async function mRi(l,p,i={}){const r=Y.YieldTracker.from(i),a=[],c=[l,...pt(l)].map(e=>yt(e)).filter(Boolean);for(const e of c){if(l.project.diggestedBuiltInBaseEntitiesIds.has(e.id))continue;let f=Gt(e,l.project);if(f&&!(Bt.includes(f.type)&&f.collapsed&&f.id!==e.id)){for(;f.parent&&f.parent!==l.project;)f=f.parent,Bt.includes(f.type)&&f.collapsed&&(f.id,e.id);e.x=0,e.y=0,p==null||p.add(e,W.Updated),a.push(e),await r.tick()}}Xr.autoGenerateLayout(l.project,p,a)}async function TRi(l,p,i={}){const r=Y.YieldTracker.from(i),a=[],c=new Set;bFe(p,{shallowMissingActivesError:!0,excludeAffected:!0}).forEach(m=>{var b;if((!m.x||!m.y)&&!c.has(m.id)&&!l.diggestedBuiltInBaseEntitiesIds.has(m.id)&&(a.push(m),c.add(m.id)),to(m,l)){const A=yt(m);A&&!c.has(A.id)&&!l.diggestedBuiltInBaseEntitiesIds.has(A.id)&&(a.push(A),c.add(A.id))}if(Wi.includes(m.type)){const A=m;[A,...pt(A)].forEach(N=>{const V=yt(N);V&&!c.has(V.id)&&!l.diggestedBuiltInBaseEntitiesIds.has(V.id)&&(a.push(V),c.add(V.id))})}m.type===d.DefinitionEntity&&m.methods.forEach(A=>{pt(A).forEach(N=>{const V=yt(N);V&&!c.has(V.id)&&!l.diggestedBuiltInBaseEntitiesIds.has(V.id)&&(a.push(V),c.add(V.id))})}),((b=m.parent)==null?void 0:b.type)===d.Project&&(a.push(m),c.add(m.id),Wi.includes(m.type)&&pt(m).forEach(N=>{const V=yt(N);V&&!c.has(V.id)&&!l.diggestedBuiltInBaseEntitiesIds.has(V.id)&&(a.push(V),c.add(V.id))}))});let f=[];for(const m of a)l.diggestedBuiltInBaseEntitiesIds.has(m.id)||(m.x=0,m.y=0,p==null||p.add(m,W.Updated),f.push(m),await r.tick());f=C(f),Xr.autoGenerateLayout(l,p,f);const h=C([...f,...l.variableDeclarations,...l.variableInstances,...l.loops,...l.conditions,...l.operations,...l.searches]).filter(m=>m.x===0||m.y===0);Xr.autoGenerateLayout(l,p,h)}var DT=(l=>(l.Amazon="amazon",l.Google="google",l.Microsoft="microsoft",l))(DT||{}),vr=(l=>(l.RelationalDatabase="relational-database",l.CompiledLocalCodebase="compiled-local-codebase",l.CloudHostedCodebase="cloud-hosted-codebase",l.HttpApi="http-api",l.HttpEndpoint="http-endpoint",l.ServerlessFunction="serverless-function",l.CronJob="cron-job",l.AWSTenantAccount="aws-tenant-account",l))(vr||{}),$_=(l=>(l.Post="post",l.Get="get",l.Acknowledgement="acknowledgment",l.Progress="progress",l.Error="error",l.Complete="complete",l))($_||{}),nf=(l=>(l.Queued="queued",l.Running="running",l.Success="success",l.Failed="failed",l.CleanedUp="cleaned-up",l.Skipped="skipped",l.AbortedByUser="aborted-by-user",l.UnrecoverableFailure="unrecoverable-failure",l.Reverted="reverted",l.UnpublishingStarted="unpublishing-started",l.Unpublished="unpublished",l))(nf||{}),L_=(l=>(l.Queued="queued",l.Running="running",l.Success="success",l.Failed="failed",l.CleanedUp="cleaned-up",l.UnrecoverableFailure="unrecoverable-failure",l.Reverted="reverted",l.UnpublishingStarted="unpublishing-started",l.Unpublished="unpublished",l))(L_||{}),Kt=(l=>(l.ProjectNotFound="project-not-found",l.ProjectPublishRequestAcknowledged="project-publish-request-acknowledged",l.PublicationStepFailedReasonUnknown="publication-step-failed-reason-unknown",l.DeploymentCompleted="deployment-completed",l.DeploymentStarted="deployment-started",l.DeploymentFailed="deployment-failed",l.AllInfrastructureSuccessfullyProvisioned="all-infrastucture-successfully-provisioned",l.RequestPayloadValidationFailed="request-payload-validation-failed",l.ProjectStateValidationFailedMissingName="project-state-validation-failed-missing-name",l.ProjectStateValidationFailedMissingAnyFunctionality="project-state-validation-failed-missing-any-functionality",l.ProjectAlreadyBeingPublished="project-already-being-published",l.BillingSubscriptionUpdateFailed="billing-subscription-update-failed",l.RelationalDatabaseDeploymentStarted="relational-database-deployment-started",l.RelationalDatabaseDeploymentCompleted="relational-database-deployment-completed",l.RelationalDatabaseDeploymentFailed="relational-database-deployment-failed",l.CreatingNewRelationalDatabase="creating-new-relational-database",l.WaitingForPreviousRelationalDatabaseDeployment="waiting-for-previous-relationa-database-deployment",l.RelationalDatabaseAlreadyExists="relational-database-already-exists",l.RelationalDatabaseDeletionStarted="relational-database-deletion-started",l.RelationalDatabaseDeletionCompleted="relational-database-deletion-completed",l.RelationalDatabaseDeletionFailed="relational-database-deletion-failed",l.WaitingForPreviousRelationalDatabaseDeletion="waiting-for-previous-relationa-database-deletion",l.HttpApiDeploymentStarted="http-api-deployment-started",l.HttpApiDeploymentCompleted="http-api-deployment-completed",l.HttpApiDeploymentFailed="http-api-deployment-failed",l.CreatingNewHttpApi="creating-new-http-api",l.HttpApiAlreadyExists="http-api-already-exists",l.HttpApiDeletionStarted="http-api-deletion-started",l.HttpApiDeletionCompleted="http-api-deletion-completed",l.HttpApiDeletionFailed="http-api-deletion-failed",l.WaitingForPreviousHttpApiDeletion="waiting-for-previous-http-api-deletion",l.BusinessLogicCodebaseDeploymentStarted="business-logic-codebase-deployment-started",l.BusinessLogicCodebaseDeploymentCompleted="business-logic-codebase-deployment-completed",l.BusinessLogicCodebaseDeploymentFailed="business-logic-codebase-deployment-failed",l.BundlingCodebaseForDownload="bundling-codebase-for-download",l.UploadingCodebaseToCloudStorage="uploading-codebase-to-cloud-storage",l.UploadingCodebaseToCloudStorageCompleted="uploading-codebase-to-cloud-storage-completed",l.UploadingCodebaseToCloudStorageFailed="uploading-codebase-to-cloud-storage-failed",l.InfrastructureValuesCodebaseInterpolationStarted="infrastructure-values-codebase-interpolation-started",l.InfrastructureValuesCodebaseInterpolationCompleted="infrastructure-values-codebase-interpolation-completed",l.InfrastructureValuesCodebaseInterpolationFailed="infrastructure-values-codebase-interpolation-failed",l.CodeCompilationStarted="code-compilation-started",l.CodeCompilationCompleted="code-compilation-completed",l.CodeCompilationFailed="code-compilation-failed",l.BundleCodebaseStarted="bundle-codebase-started",l.BundleCodebaseCompleted="bundle-codebase-completed",l.BundleCodebaseFailed="bundle-codebase-failed",l.InstallingCodebaseDependenciesStarted="installing-codebase-dependencies-started",l.InstallingCodebaseDependenciesCompleted="installing-codebase-dependencies-completed",l.InstallingCodebaseDependenciesFailed="installing-codebase-dependencies-failed",l.MigrateRelationalDatabaseStarted="migrate-relational-database-started",l.MigrateRelationalDatabaseCompleted="migrate-relational-database-completed",l.MigrateRelationalDatabaseFailed="migrate-relational-database-failed",l.ExecutePublicationCompletedEventStarted="execute-publication-completed-event-started",l.ExecutePublicationCompletedEventCompleted="execute-publication-completed-event-completed",l.ExecutePublicationCompletedEventFailed="execute-publication-completed-event-failed",l.ExecutePublicationCompletedEventTimedOut="execute-publication-completed-event-timed-out",l.AWSTenantAccountProvisioningStarted="aws-tenant-account-provisioning-started",l.AWSTenantAccountProvisioningCompleted="aws-tenant-account-provisioning-completed",l.AWSTenantAccountProvisioningFailed="aws-tenant-account-provisioning-failed",l))(Kt||{}),Sl=(l=>(l.CodeCompilation="code-compilation",l.RelationalDatabaseDeployment="relational-database-deployment",l.RelationalDatabaseDeletion="relational-database-deletion",l.HttpApiDeployment="http-api-deployment",l.HttpApiDeletion="http-api-deletion",l.InfrastructureValuesCodebaseInterpolation="infrastructure-values-codebase-interpolation",l.BundleCodebase="bundle-codebase",l.MigrateRelationalDatabase="migrate-relational-database",l.BusinessLogicCodebaseDeployment="business-logic-codebase-deployment",l.ExecutePublicationCompletedEvent="execute-publication-completed-event",l.CodebaseCleanup="codebase-cleanup",l.AWSTenantAccountProvisioning="aws-tenant-account-provisioning",l))(Sl||{});vr.CloudHostedCodebase,vr.HttpApi,vr.RelationalDatabase,vr.CloudHostedCodebase,vr.CloudHostedCodebase,vr.RelationalDatabase,vr.CloudHostedCodebase,vr.CloudHostedCodebase;function OBe(l){return`project-${l}-http-api`}function E1(l){return`entity-${l}-database`}class _Be{constructor(p,i,r,a,c,e,f,h,m){R(this,"stepType");R(this,"id");R(this,"resourceType");R(this,"index");R(this,"dependency",[]);R(this,"lastEvent",null);R(this,"lastEventTimestamp",null);R(this,"status",nf.Queued);R(this,"publicationRun");R(this,"resource");this.stepType=p,this.id=i,this.resourceType=r,this.status=a,this.dependency=c,this.index=e,this.lastEventTimestamp=f,this.publicationRun=h,this.resource=m}toJSON(){return{stepType:this.stepType,id:this.id,resourceType:this.resourceType,index:this.index,status:this.status,dependency:this.dependency,lastEvent:this.lastEvent,resource:{resourceId:this.resource.resourceId,resourceType:this.resource.resourceType,provider:this.resource.provider,details:this.resource.details,status:this.resource.status,name:this.resource.name}}}async update(p){var i,r;this.status=p.status,this.dependency=p.dependency,this.index=p.index,this.stepType=p.stepType,this.resourceType=p.resourceType,this.lastEvent=p.lastEvent,this.id=p.id,(r=this.resource)==null||r.setDetails((i=p.resource)==null?void 0:i.details)}}var VBe=(l=>(l.Ready="ready",l.Provisioning="provisioning",l.Queued="queued",l.ProvisioningFailed="provisioning-failed",l.Deleting="deleting",l.DeletingFailed="deleting-failed",l.Deleted="deleted",l))(VBe||{});class Dc{constructor(p,i,r){R(this,"provisionedBy");R(this,"publicationRun");R(this,"resourceType");R(this,"provider");R(this,"resourceId");R(this,"details",null);R(this,"name",null);R(this,"status","queued");this.publicationRun=p,this.resourceType=i,this.provider=r}setDetails(p){this.details=p}setStatus(p){this.status=p}setProvisionedBy(p){this.provisionedBy=p}}class vRi extends Dc{constructor(i,r,a){super(i,vr.HttpEndpoint,a);R(this,"resourceType",vr.HttpEndpoint);R(this,"owners",new Map);R(this,"details",null);R(this,"status","queued");r.forEach(c=>{this.owners.set(c.id,c)}),this.resolveDeterministicResourceId()}resolveDeterministicResourceId(){var i,r;return this.resourceId=E1((r=(i=Array.from(this.owners.values()))==null?void 0:i[0])==null?void 0:r.id),this.resourceId}}class ERi extends Dc{constructor(i,r,a){super(i,vr.ServerlessFunction,a);R(this,"resourceType",vr.ServerlessFunction);R(this,"owners",new Map);R(this,"details",null);R(this,"status","queued");r.forEach(c=>{this.owners.set(c.id,c)}),this.resolveDeterministicResourceId()}resolveDeterministicResourceId(){var i,r;return this.resourceId=E1((r=(i=Array.from(this.owners.values()))==null?void 0:i[0])==null?void 0:r.id),this.resourceId}}class PBe extends Dc{constructor(i,r,a){super(i,vr.HttpApi,a);R(this,"resourceType",vr.HttpApi);R(this,"owners",new Map);R(this,"details",null);R(this,"status","queued");r.forEach(c=>{this.owners.set(c.id,c)}),this.resolveDeterministicResourceId()}resolveDeterministicResourceId(){return this.resourceId=OBe(this.publicationRun.project.id),this.resourceId}}class NBe extends Dc{constructor(i,r,a){super(i,vr.RelationalDatabase,a);R(this,"resourceType",vr.RelationalDatabase);R(this,"owners",new Map);R(this,"details",null);R(this,"status","queued");r.forEach(c=>{this.owners.set(c.id,c)}),this.resolveDeterministicResourceId()}resolveDeterministicResourceId(){var i,r;return this.resourceId=E1((r=(i=Array.from(this.owners.values()))==null?void 0:i[0])==null?void 0:r.id),this.resourceId}}class xBe extends Dc{constructor(i,r){super(i,vr.CloudHostedCodebase,r);R(this,"resourceType",vr.CloudHostedCodebase);R(this,"details",null);R(this,"status","queued");this.resolveDeterministicResourceId()}resolveDeterministicResourceId(){return this.resourceId=`cloud-hosted-codebase--${this.publicationRun.project.id}--${this.publicationRun.project.version}`,this.resourceId}}class $Be extends Dc{constructor(i,r){super(i,vr.CompiledLocalCodebase,r);R(this,"resourceType",vr.CompiledLocalCodebase);R(this,"details",null);R(this,"status","queued");this.resolveDeterministicResourceId()}resolveDeterministicResourceId(){return this.resourceId=`compiled-codebase--${this.publicationRun.project.id}--${this.publicationRun.project.version}--${this.publicationRun.id}`,this.resourceId}}class bRi extends Dc{constructor(i,r){super(i,vr.AWSTenantAccount,r);R(this,"resourceType",vr.AWSTenantAccount);R(this,"status","queued");this.resolveDeterministicResourceId()}resolveDeterministicResourceId(){return this.resourceId=`aws-tenant-account--${this.publicationRun.project.id}`,this.resourceId}}class ARi{constructor(p,i){R(this,"id");R(this,"projectAutoIncrementPublicationCount");R(this,"projectPublishedSemanticVersion");R(this,"projectVersion");R(this,"projectId");R(this,"triggeredBy");R(this,"createdAt");R(this,"updatedAt");R(this,"status");R(this,"steps",[]);R(this,"editor");R(this,"explicitResources",new Map);R(this,"implicitGlobalResources",new Map);R(this,"finalGlobalEvent",null);R(this,"finalStatus",null);R(this,"contextType",ae.PublicationRun);R(this,"extensionsRegistry");this.id=p.id,this.projectAutoIncrementPublicationCount=p.projectAutoIncrementPublicationCount,this.projectPublishedSemanticVersion=p.projectPublishedSemanticVersion,this.projectVersion=p.projectVersion,this.projectId=p.projectId,this.triggeredBy=p.triggeredBy,this.createdAt=p.createdAt,this.updatedAt=p.updatedAt,this.status=p.status,this.editor=i,this.initRegistry()}get off(){return this.extensionsRegistry.off}get on(){return this.extensionsRegistry.on}get emit(){return this.extensionsRegistry.emit}get emitAsync(){return this.extensionsRegistry.emitAsync}get emitAsyncAll(){return this.extensionsRegistry.emitAsyncAll}get emitAsyncAllSettled(){return this.extensionsRegistry.emitAsyncAllSettled}get emitAsyncSequentially(){return this.extensionsRegistry.emitAsyncSequentially}get emitAsyncSequentiallyAll(){return this.extensionsRegistry.emitAsyncSequentiallyAll}get emitAsyncSequentiallyAllSettled(){return this.extensionsRegistry.emitAsyncSequentiallyAllSettled}get project(){return this.editor.project}getInfraTypes(p){return this.steps.filter(i=>p.includes(i.resourceType))}getStepsTypes(p){return this.steps.filter(i=>p.includes(i.stepType))}toIds(p){return p.map(i=>i.id)}getResourceForEntity(p){const i=Array.from(this.explicitResources.values()).find(r=>r.owners.has(p.id));return i||null}async init(){await this.initResources()}async initResources(){this.implicitGlobalResources.set(vr.CompiledLocalCodebase,new $Be(this,DT.Amazon)),this.implicitGlobalResources.set(vr.CloudHostedCodebase,new xBe(this,DT.Amazon));const p=this.project.entities.filter(r=>ai(r,Ie.HTTP_ENDPOINT)),i=this.project.entities.filter(r=>ai(r,Ie.RELATIONAL_DATABASE));if(i.length&&i.forEach(r=>{const a=new NBe(this,[r],DT.Amazon);this.explicitResources.set(a.resourceId,a)}),p.length){const r=new PBe(this,p,DT.Amazon);this.explicitResources.set(r.resourceId,r)}}setSteps(p,i){p.forEach(r=>{this.addStep(r,i)}),this.editor.events.emit(Kt.ProjectPublishRequestAcknowledged,{})}addStep(p,i){const r=p.dependency||[];if(r.length){const c=r.filter(e=>!this.steps.find(f=>f.id===e));if(c.length)throw new Error(`Missing dependencies: ${c.join(", ")}`)}if(!this.steps.find(c=>c.id===p.id)){const c=new _Be(p.stepType,p.id,p.resourceType,p.status,r,p.index,i,this,null);this.steps.push(c)}}onUpdate(p){var i;if(Y.Logger.log("onUpdate",p),(i=p.payload)!=null&&i.stepType){const r=this.steps.find(a=>{var c;return a.id===((c=p.payload)==null?void 0:c.id)});r&&B(p.emittedAt).isAfter(B(r.lastEventTimestamp))&&r.update(p.payload)}this.editor.events.emit("publication-updated",{}),p.type===$_.Error?(this.finalStatus=L_.Failed,this.finalGlobalEvent=p.event,this.editor.events.emit("project-publication-error",p)):p.type===$_.Complete&&(this.finalStatus=L_.Success,this.finalGlobalEvent=p.event,this.editor.events.emit("project-publication-completed",p))}requestExtension(p){return this.extensionsRegistry.requestExtension(p)}async initRegistry(){return this.extensionsRegistry=new Yx(this.editor.events),await this.extensionsRegistry.setup(),this.extensionsRegistry.onResolvePublicationRunContext(()=>this),await this.extensionsRegistry.contextAvailable(ae.PublicationRun),this.extensionsRegistry}}function IRi(l){switch(l){case Sl.CodeCompilation:return"Code generation";case Sl.RelationalDatabaseDeployment:return"Database creation";case Sl.HttpApiDeployment:return"HTTP gateway creation";case Sl.InfrastructureValuesCodebaseInterpolation:return"Link code with resources";case Sl.BundleCodebase:return"Bundle code";case Sl.MigrateRelationalDatabase:return"Database structure migration";case Sl.BusinessLogicCodebaseDeployment:return"Update servers with new code";case Sl.CodebaseCleanup:return"Code cleanup";case Sl.HttpApiDeletion:return"HTTP gateway deletion";case Sl.RelationalDatabaseDeletion:return"Database deletion";default:return"Publication finished"}}function gRi(l){switch(l){case Kt.DeploymentCompleted:return"Successfully published";case Kt.DeploymentStarted:return"Publication started";case Kt.DeploymentFailed:return"Publication failed";case Kt.AllInfrastructureSuccessfullyProvisioned:return"All infrastructure successfully provisioned";case Kt.RequestPayloadValidationFailed:return"Request payload validation failed";case Kt.ProjectStateValidationFailedMissingName:return"Project state validation failed: missing name";case Kt.ProjectStateValidationFailedMissingAnyFunctionality:return"Project state validation failed: missing any functionality";case Kt.RelationalDatabaseDeploymentStarted:return"Database creation started";case Kt.RelationalDatabaseDeploymentCompleted:return"Database creation completed";case Kt.RelationalDatabaseDeploymentFailed:return"Database creation failed";case Kt.CreatingNewRelationalDatabase:return"Creating new database (up to 5 mins)";case Kt.WaitingForPreviousRelationalDatabaseDeployment:return"Waiting for previous database creation";case Kt.RelationalDatabaseAlreadyExists:return"Database already exists";case Kt.HttpApiDeploymentStarted:return"HTTP gateway creation started";case Kt.HttpApiDeploymentCompleted:return"HTTP gateway creation completed";case Kt.HttpApiDeploymentFailed:return"HTTP gateway creation failed";case Kt.CreatingNewHttpApi:return"Creating new HTTP gateway";case Kt.HttpApiAlreadyExists:return"HTTP gateway already exists";case Kt.BusinessLogicCodebaseDeploymentStarted:return"Update servers with new code started";case Kt.BusinessLogicCodebaseDeploymentCompleted:return"Update servers with new code completed";case Kt.BusinessLogicCodebaseDeploymentFailed:return"Update servers with new code failed";case Kt.BundlingCodebaseForDownload:return"Bundling code for download";case Kt.UploadingCodebaseToCloudStorage:return"Uploading code to cloud storage";case Kt.InfrastructureValuesCodebaseInterpolationStarted:return"Linking code with resources started";case Kt.InfrastructureValuesCodebaseInterpolationCompleted:return"Linking code with resources completed";case Kt.InfrastructureValuesCodebaseInterpolationFailed:return"Linking code with resources failed";case Kt.CodeCompilationStarted:return"Code generation started";case Kt.CodeCompilationCompleted:return"Code generation completed";case Kt.CodeCompilationFailed:return"Code generation failed";case Kt.BundleCodebaseStarted:return"Code bundling started";case Kt.BundleCodebaseCompleted:return"Code bundling completed";case Kt.BundleCodebaseFailed:return"Code bundling failed";case Kt.InstallingCodebaseDependenciesStarted:return"Installing code dependencies";case Kt.InstallingCodebaseDependenciesCompleted:return"Installing code dependencies completed";case Kt.InstallingCodebaseDependenciesFailed:return"Installing code dependencies failed";case Kt.MigrateRelationalDatabaseStarted:return"Database structure migration started";case Kt.MigrateRelationalDatabaseCompleted:return"Database structure migration completed";case Kt.MigrateRelationalDatabaseFailed:return"Database structure migration failed";case Kt.ProjectAlreadyBeingPublished:return"Project already being published. You need to wait for the previous publication to complete";case Kt.ProjectPublishRequestAcknowledged:return"Project publish request acknowledged";case Kt.UploadingCodebaseToCloudStorageCompleted:return"Uploading code to cloud storage completed";case Kt.UploadingCodebaseToCloudStorageFailed:return"Uploading code to cloud storage failed";case Kt.BillingSubscriptionUpdateFailed:return"Billing subscription update failed";case Kt.ProjectNotFound:return"Project not found";case Kt.HttpApiDeletionCompleted:return"HTTP gateway deletion completed";case Kt.HttpApiDeletionFailed:return"HTTP gateway deletion failed";case Kt.HttpApiDeletionStarted:return"HTTP gateway deletion started";case Kt.PublicationStepFailedReasonUnknown:return"Publication step failed: reason unknown";case Kt.WaitingForPreviousHttpApiDeletion:return"Waiting for previous HTTP gateway deletion";case Kt.RelationalDatabaseDeletionStarted:return"Database deletion started";case Kt.RelationalDatabaseDeletionCompleted:return"Database deletion completed";case Kt.RelationalDatabaseDeletionFailed:return"Database deletion failed";case Kt.WaitingForPreviousRelationalDatabaseDeletion:return"Waiting for previous database deletion"}return"Unknown event"}var LBe=(l=>(l.NO_LOGIC="NO_LOGIC",l.NO_NAME="NO_NAME",l.NO_CHANGES="NO_CHANGES",l.PROJECT_PUBLICATION_ALREADY_ONGOING="PROJECT_PUBLICATION_ALREADY_ONGOING",l))(LBe||{});function RRi(l){switch(l){case"NO_LOGIC":return"This project has no logic";case"NO_NAME":return"This project has no name";case"NO_CHANGES":return"This version has already been published";case"PROJECT_PUBLICATION_ALREADY_ONGOING":return"This project is already being published";default:return"Publishing is currently not available. Try again later"}}function DRi(l){switch(l){case vr.RelationalDatabase:return"Relational database";case vr.HttpEndpoint:case vr.HttpApi:return"HTTP endpoints";case vr.ServerlessFunction:case vr.CloudHostedCodebase:return"Server code functions";default:return"Resources"}}function wRi(l){switch(l){case nf.Running:return"In progress";case nf.Failed:return"Failed";case nf.Success:return"Succeeded";case nf.Skipped:return"Skipped";case nf.Queued:default:return"Queued"}}function BBe(l){var r;if(!ai(l,Ie.EXTERNAL_INTEGRATION_CONNECTION))return null;let p=null;const i=ne["built-in-base-entity"].BUILT_IN_EXTERNAL_INTEGRATION_CONNECTION_ENTITY.properties.integration.id;if(l.type===d.BuiltInBaseEntity?ai(l,Ie.EXTERNAL_INTEGRATION_CONNECTION)&&(p=B_(l.name)):l.type===d.DefinitionEntity&&l.implements.forEach(a=>{if(ai(a,Ie.EXTERNAL_INTEGRATION_CONNECTION)){const c=B_(a==null?void 0:a.name);if(c)return p=c,!0}}),!p){const a=l.properties.find(c=>!!c.implements.find(e=>e.id===i)||!!c.implements.find(e=>{var f;return((f=e.extends)==null?void 0:f.id)===i}));p=(r=a==null?void 0:a.getDefaultValue())==null?void 0:r.value}return p}function CRi(l){return I0e[l]}function B_(l){return l.includes("BUILT_IN_EXTERNAL_INTEGRATION_CONNECTION_")?l.replace("BUILT_IN_EXTERNAL_INTEGRATION_CONNECTION_","").toLocaleLowerCase().replace("_auth",""):null}function MBe(l){if(l.type!==d.ActionDescriptor&&l.type!==d.Operation)throw new Error("Only ActionDescriptorState or OperationState can be used to resolve an external integration ID");if(l.type===d.ActionDescriptor){const p=l;if(p.id.startsWith("external-integration--"))return p.id.split("--")[1]}if(l.type===d.Operation){const p=l.declaration;if(Object.values(fi).includes(p.id))return p.id.split("--")[1]||null}return null}function ORi(l){if(!l)throw new Error("The integrationName parameter is required to resolve the base built-in name.");return Object.values(Ie).find(i=>!!(i.startsWith("BUILT_IN_EXTERNAL_INTEGRATION_CONNECTION_")&&i.endsWith("_AUTH")&&i.replace("BUILT_IN_EXTERNAL_INTEGRATION_CONNECTION_","").replace("_AUTH","").toLowerCase()===l.toLowerCase()))||null}function _Ri(l){return l.type===d.BuiltInBaseEntity||l.type===d.DefinitionEntity?BBe(l):l.type===d.ActionDescriptor||l.type===d.Operation?MBe(l):null}function GBe(l){var a,c,e;if(!ai(l,Ie.EXTERNAL_INTEGRATION_CONNECTION))return null;let p=null;const i=uFe(l,Ie.EXTERNAL_INTEGRATION_CONNECTION);if(!i)return null;const r=ne["built-in-base-entity"][i.id].properties.connectionId.id;if(l.type===d.BuiltInBaseEntity){if(ai(l,Ie.EXTERNAL_INTEGRATION_CONNECTION)){const f=l.properties.find(h=>{var m;return((m=h.extends)==null?void 0:m.id)===r});f&&(p=(a=f.getDefaultValue())==null?void 0:a.value)}}else if(l.type===d.DefinitionEntity){const f=l.properties.find(h=>!!h.implements.find(m=>m.id===r)||!!h.implements.find(m=>{var E;return((E=m.extends)==null?void 0:E.id)===r}));if(!f&&((c=l.extends)==null?void 0:c.type)===d.DefinitionEntity)return GBe(l.extends);p=(e=f==null?void 0:f.getDefaultValue())==null?void 0:e.value}return p}async function jBe(l,p={}){var f;const i=Y.YieldTracker.from(p),a=[...ya(l),...vn(l),...a$(l),...ha(l),...s$(l)],c=ME(l);a.push(...c);const e=qt(l.errors,a);await i.tick();for(const h of l.inputs)await h.validateAsync({tracker:i});for(const h of l.outputs)await h.validateAsync({tracker:i});for(const h of l.internalCalls)await h.validateAsync({tracker:i});return await((f=l.dataType)==null?void 0:f.validateAsync({tracker:i})),e}function kBe(l){var a;(a=l.dataType)==null||a.validate(),l.inputs.forEach(c=>c.validate()),l.outputs.forEach(c=>c.validate()),l.internalCalls.forEach(c=>c.validate());const i=[...ya(l),...vn(l),...a$(l),...ha(l),...s$(l)],r=ME(l);return i.push(...r),qt(l.errors,i)}function a$(l,p){const r=[...l.project.getVariableDeclarations()].filter(a=>a.id!==l.id);return jE(l,[Qi],r,p)}function s$(l){const p=[];if(l.parent!==l.project)return p;if(l.catchesError){const i=It({id:`${l.id}--${Ce.GlobalVariableDeclarationCannotCatchError}`,message:`${is[l.type].singular} "${le(l,l.project)}" with id "${l.id}" cannot catch an error because it is globally declared. Global variable declarations must crash the project if an error occurs.`,severity:Te.Error,code:Ce.GlobalVariableDeclarationCannotCatchError,entity:l});p.push(i.error)}if(l.errorCalls.length){const i=It({id:`${l.id}--${Ce.GlobalVariableDeclarationCannotCallOnError}`,message:`${is[l.type].singular} "${le(l,l.project)}" with id "${l.id}" cannot call other entities from its error branch because it is globally declared. Global variable declarations must crash the project if an error occurs.`,severity:Te.Error,code:Ce.GlobalVariableDeclarationCannotCallOnError,entity:l});p.push(i.error)}if(l.calledBy.length){const i=It({id:`${l.id}--${Ce.GlobalVariableDeclarationCannotBeCalled}`,message:`${is[l.type].singular} "${le(l,l.project)}" with id "${l.id}" cannot be called because it is globally declared. Global variable declarations must be self initialized when the project is loaded, and not be called for initialization.`,severity:Te.Error,code:Ce.GlobalVariableDeclarationCannotBeCalled,entity:l});p.push(i.error)}return[]}const VRi=Object.freeze(Object.defineProperty({__proto__:null,validate:kBe,validateAsync:jBe,validateGlobalVariableDeclaration:s$,validateVariableDeclarationName:a$},Symbol.toStringTag,{value:"Module"}));async function UBe(l,p={}){const i=Y.YieldTracker.from(p),a=[...ya(l),...vn(l),...ha(l),...Jo(l),...KBe(l)],c=ME(l);a.push(...c);const e=qt(l.errors,a);await i.tick();for(const f of l.inputs)await f.validateAsync({tracker:i});for(const f of l.outputs)await f.validateAsync({tracker:i});for(const f of l.internalCalls)await f.validateAsync({tracker:i});return e}function FBe(l){l.inputs.forEach(a=>a.validate()),l.outputs.forEach(a=>a.validate()),l.internalCalls.forEach(a=>a.validate());const i=[...ya(l),...vn(l),...ha(l)],r=ME(l);return i.push(...r),qt(l.errors,i)}function KBe(l){const p=[],i=l.declaration.constant;if(i&&l.readsValue){const r=It({id:`${l.id}--${be.ValueReadingOverridesConstantVariable}`,message:`The '${l.type}' entity "${le(l,l.project)}" with id "${l.id}" is a constant variable whose value cannot be overriden, but reads a value.`,severity:Te.Error,code:be.ValueReadingOverridesConstantVariable,entity:l});p.push(r.error)}if(i&&l.defaultValue){const r=It({id:`${l.id}--${be.DefaultValueOverridesConstantVariable}`,message:`The '${l.type}' entity "${le(l,l.project)}" with id "${l.id}" is a constant variable whose value cannot be overridden, but has a 'defaultValue'.`,severity:Te.Error,code:be.DefaultValueOverridesConstantVariable,entity:l});p.push(r.error)}return p}function Jo(l){var h;const p=[],i=l.declaration;if((i==null?void 0:i.id)===((h=l.parent)==null?void 0:h.id)||!l.calledBy.length&&l.successCalls.length&&l.errorCalls.length)return p;const r=pt(l),a=pt(i);!!r.find(m=>m.id===i.id)&&p.push(It({id:`${l.id}--${be.CalledBeforeDeclaration}`,code:be.CalledBeforeDeclaration,severity:Te.Error,message:`Entity of type "${l.type}" with id "${l.id}" is called before its 'variable-declaration' '${i.name}' with id "${i.id}".
54
+ `+c):r.stack=c}catch{}}throw r}}_request(p,i){typeof p=="string"?(i=i||{},i.url=p):i=p||{},i=Tf(this.defaults,i);const{transitional:r,paramsSerializer:a,headers:c}=i;r!==void 0&&tI.assertOptions(r,{silentJSONParsing:ll.transitional(ll.boolean),forcedJSONParsing:ll.transitional(ll.boolean),clarifyTimeoutError:ll.transitional(ll.boolean),legacyInterceptorReqResOrdering:ll.transitional(ll.boolean)},!1),a!=null&&(qe.isFunction(a)?i.paramsSerializer={serialize:a}:tI.assertOptions(a,{encode:ll.function,serialize:ll.function},!0)),i.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?i.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:i.allowAbsoluteUrls=!0),tI.assertOptions(i,{baseUrl:ll.spelling("baseURL"),withXsrfToken:ll.spelling("withXSRFToken")},!0),i.method=(i.method||this.defaults.method||"get").toLowerCase();let e=c&&qe.merge(c.common,c[i.method]);c&&qe.forEach(["delete","get","head","post","put","patch","common"],N=>{delete c[N]}),i.headers=zl.concat(e,c);const f=[];let h=!0;this.interceptors.request.forEach(function(V){if(typeof V.runWhen=="function"&&V.runWhen(i)===!1)return;h=h&&V.synchronous;const j=i.transitional||Kx;j&&j.legacyInterceptorReqResOrdering?f.unshift(V.fulfilled,V.rejected):f.push(V.fulfilled,V.rejected)});const m=[];this.interceptors.response.forEach(function(V){m.push(V.fulfilled,V.rejected)});let E,b=0,A;if(!h){const N=[Kk.bind(this),void 0];for(N.unshift(...f),N.push(...m),A=N.length,E=Promise.resolve(i);b<A;)E=E.then(N[b++],N[b++]);return E}A=f.length;let _=i;for(;b<A;){const N=f[b++],V=f[b++];try{_=N(_)}catch(j){V.call(this,j);break}}try{E=Kk.call(this,_)}catch(N){return Promise.reject(N)}for(b=0,A=m.length;b<A;)E=E.then(m[b++],m[b++]);return E}getUri(p){p=Tf(this.defaults,p);const i=e2e(p.baseURL,p.url,p.allowAbsoluteUrls);return YLe(i,p.params,p.paramsSerializer)}}qe.forEach(["delete","get","head","options"],function(p){wI.prototype[p]=function(i,r){return this.request(Tf(r||{},{method:p,url:i,data:(r||{}).data}))}});qe.forEach(["post","put","patch"],function(p){function i(r){return function(c,e,f){return this.request(Tf(f||{},{method:p,headers:r?{"Content-Type":"multipart/form-data"}:{},url:c,data:e}))}}wI.prototype[p]=i(),wI.prototype[p+"Form"]=i(!0)});const iI=wI;class Wx{constructor(p){if(typeof p!="function")throw new TypeError("executor must be a function.");let i;this.promise=new Promise(function(c){i=c});const r=this;this.promise.then(a=>{if(!r._listeners)return;let c=r._listeners.length;for(;c-- >0;)r._listeners[c](a);r._listeners=null}),this.promise.then=a=>{let c;const e=new Promise(f=>{r.subscribe(f),c=f}).then(a);return e.cancel=function(){r.unsubscribe(c)},e},p(function(c,e,f){r.reason||(r.reason=new hE(c,e,f),i(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(p){if(this.reason){p(this.reason);return}this._listeners?this._listeners.push(p):this._listeners=[p]}unsubscribe(p){if(!this._listeners)return;const i=this._listeners.indexOf(p);i!==-1&&this._listeners.splice(i,1)}toAbortSignal(){const p=new AbortController,i=r=>{p.abort(r)};return this.subscribe(i),p.signal.unsubscribe=()=>this.unsubscribe(i),p.signal}static source(){let p;return{token:new Wx(function(a){p=a}),cancel:p}}}const Wgi=Wx;function zgi(l){return function(i){return l.apply(null,i)}}function Ygi(l){return qe.isObject(l)&&l.isAxiosError===!0}const P_={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(P_).forEach(([l,p])=>{P_[p]=l});const Jgi=P_;function a2e(l){const p=new iI(l),i=kLe(iI.prototype.request,p);return qe.extend(i,iI.prototype,p,{allOwnKeys:!0}),qe.extend(i,p,null,{allOwnKeys:!0}),i.create=function(a){return a2e(Tf(l,a))},i}const Mn=a2e(Zx);Mn.Axios=iI;Mn.CanceledError=hE;Mn.CancelToken=Wgi;Mn.isCancel=QLe;Mn.VERSION=n2e;Mn.toFormData=c1;Mn.AxiosError=Ji;Mn.Cancel=Mn.CanceledError;Mn.all=function(p){return Promise.all(p)};Mn.spread=zgi;Mn.isAxiosError=Ygi;Mn.mergeConfig=Tf;Mn.AxiosHeaders=zl;Mn.formToJSON=l=>JLe(qe.isHTMLForm(l)?new FormData(l):l);Mn.getAdapter=r2e.getAdapter;Mn.HttpStatusCode=Jgi;Mn.default=Mn;const Qgi=Mn;class s2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__HTTP_REQUEST,version:"1.0.0",description:"HTTP request operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(da.HttpRequest);a&&(a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[3]||{},e={method:a[0],url:a[1],params:a[2],headers:c,data:a[4]};Y.Logger.log("Axios request config: ",e);const f=await Qgi(e);return{value:U.Success,error:null,result:{status:f.status,headers:f.headers,data:f.data}}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class l2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__VALIDATE_ENTITY,version:"1.0.0",description:"Entity validate operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(Le.Validate);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)||((m=f.value)==null?void 0:m.value)});Y.Logger.log("Inputs for entity validation: ",a);const e=aD(a[1]).safeParse(a[0]);return e.success?{value:U.Success,error:null,result:{data:a[0]}}:{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:e.error.errors,result:null}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}const Ka=l=>l.map(p=>{var i,r;return((i=p.value)==null?void 0:i.valueAsType)??((r=p.value)==null?void 0:r.value)});class o2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_READ_KEY,version:"1.0.0",description:"Entity read-key operation implementation module (top-level)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(Le.ReadKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c]=Ka(r),e=M_e(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class d2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_WRITE_KEY,version:"1.0.0",description:"Entity write-key operation implementation module (top-level, immutable)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(Le.WriteKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c,e]=Ka(r),f=G_e(a,c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class u2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_DELETE_KEY,version:"1.0.0",description:"Entity delete-key operation implementation module (top-level, immutable)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(Le.DeleteKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c]=Ka(r),e=j_e(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class p2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_READ_NESTED_KEY,version:"1.0.0",description:"Entity read-nested-key operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(Le.ReadNestedKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c,e]=Ka(r),f=k_e(a,c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class c2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_WRITE_NESTED_KEY,version:"1.0.0",description:"Entity write-nested-key operation implementation module (immutable, no auto-create)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(Le.WriteNestedKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c,e]=Ka(r),f=U_e(a,c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class f2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_WRITE_SAFE_NESTED_KEY_RECURSIVELY,version:"1.0.0",description:"Entity write-safe-nested-key-recursively operation implementation module (immutable, auto-create)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(Le.WriteSafeNestedKeyRecursively);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c,e]=Ka(r),f=F_e(a,c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class y2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_DELETE_NESTED_KEY,version:"1.0.0",description:"Entity delete-nested-key operation implementation module (immutable)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(Le.DeleteNestedKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const[a,c]=Ka(r),e=K_e(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class h2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_HAS_KEY,version:"1.0.0",description:"Object has-key (top-level property present?)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(Le.HasKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=Ka(r),e=q_e(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class m2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_KEY_VALUE_EQUALS,version:"1.0.0",description:"Object key-value-equals (top-level property strict equality)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(Le.KeyValueEquals);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e]=Ka(r),f=S_e(a,c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class T2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_HAS_NESTED_KEY,version:"1.0.0",description:"Object has-nested-key (path present?)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(Le.HasNestedKey);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=Ka(r),e=Z_e(a,c);return{value:U.Success,error:null,result:e}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class v2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_NESTED_KEY_VALUE_EQUALS,version:"1.0.0",description:"Object nested-key-value-equals (path strict equality)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(Le.NestedKeyValueEquals);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e]=Ka(r),f=H_e(a,c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class E2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_IS_INSTANCE_OF_TYPE,version:"1.0.0",description:"Object is-instance-of-type (DefinitionEntity-based runtime check)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(Le.IsInstanceOfType);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{var a,c,e,f,h,m,E,b,A,_;try{const N=((c=(a=r[0])==null?void 0:a.value)==null?void 0:c.parent)||((f=(e=r[0])==null?void 0:e.value)==null?void 0:f.standaloneParent),V=(m=(h=r[0])==null?void 0:h.value)==null?void 0:m.value,j=(b=(E=r[1])==null?void 0:E.value)==null?void 0:b.valueAsTypeSingle;if(!V)throw new TypeError("IsInstanceOfType expects a non-null input value.");if(!j)throw new TypeError("IsInstanceOfType expects a valid expectedType input.");if(!N)throw new TypeError("IsInstanceOfType cannot determine the value owner.");if(j.type!==d.DefinitionEntity)throw new TypeError("IsInstanceOfType expects expectedType to be a DefinitionEntity.");const M=N.getDataType(null);if(((A=M==null?void 0:M.entity)==null?void 0:A.type)!==d.DefinitionEntity)throw new TypeError("IsInstanceOfType cannot determine the data type of the input value.");let G=!1;return((_=M==null?void 0:M.entity)==null?void 0:_.id)!==(j==null?void 0:j.id)?G=!1:aD(M==null?void 0:M.entity).safeParse(V).success?G=!0:G=!1,{value:U.Success,error:null,result:G}}catch(N){return{value:U.UnhandledError,error:N,result:null}}}})}}class b2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_MERGE,version:"1.0.0",description:"Object merge operation implementation module (immutable, shallow merge with right-precedence)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(Le.Merge);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const a=Ka(r),c=W_e(...a);return{value:U.Success,error:null,result:c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class A2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_KEYS,version:"1.0.0",description:"Object keys operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(Le.Keys);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=Ka(r),c=z_e(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class I2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_VALUES,version:"1.0.0",description:"Object values operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(Le.Values);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=Ka(r),c=Y_e(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}class g2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_ENTRIES,version:"1.0.0",description:"Object entries operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic);if(!r)return;const a=r.get(Le.Entries);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=Ka(r),c=J_e(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:U.UnhandledError,error:a,result:null}}}})}}let Ns=null;try{Ns=require("crypto")}catch{}const xT=typeof globalThis<"u"&&globalThis.crypto&&globalThis.crypto.subtle?globalThis.crypto:Ns&&Ns.webcrypto?Ns.webcrypto:null,dp=xT?xT.subtle:null;function ZT(l){const p=new ArrayBuffer(l.byteLength);return new Uint8Array(p).set(l),p}function dn(l,p="utf8"){if(l instanceof Uint8Array)return l;const i=String(l);if(p==="utf8"){if(typeof TextEncoder<"u")return new TextEncoder().encode(i);if(typeof Buffer<"u")return new Uint8Array(Buffer.from(i,"utf8"))}else if(p==="hex"){if(typeof Buffer<"u")return new Uint8Array(Buffer.from(i,"hex"))}else if(p==="base64"){if(typeof Buffer<"u")return new Uint8Array(Buffer.from(i,"base64"))}else if(p==="base64url"){const r=i.replace(/-/g,"+").replace(/_/g,"/").replace(/=+$/,"");if(typeof Buffer<"u")return new Uint8Array(Buffer.from(r,"base64"));const a=typeof atob=="function"?atob(r):"",c=new Uint8Array(a.length);for(let e=0;e<a.length;e++)c[e]=a.charCodeAt(e);return c}throw new Error(`Unsupported environment/encoding combo for toBytes(${p})`)}function Po(l,p="utf8"){if(p==="utf8"){if(typeof TextDecoder<"u")return new TextDecoder().decode(l);if(typeof Buffer<"u")return Buffer.from(l).toString("utf8")}else if(p==="hex"){if(typeof Buffer<"u")return Buffer.from(l).toString("hex")}else if(p==="base64"){if(typeof Buffer<"u")return Buffer.from(l).toString("base64")}else if(p==="base64url"&&typeof Buffer<"u")return Buffer.from(l).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");throw new Error(`Unsupported environment/encoding combo for fromBytes(${p})`)}const R2e=l=>dn(l,"base64"),D2e=(l,p)=>{const i=l instanceof Uint8Array?l:dn(String(l),p||"utf8");return Po(i,"base64")},Th=(l,p)=>{const i=l instanceof Uint8Array?l:dn(String(l),p||"utf8");return Po(i,"base64url")},vf=l=>dn(l,"base64url"),w2e=(l,p)=>{const i=l instanceof Uint8Array?l:dn(String(l),p||"utf8");return Po(i,"hex")},C2e=l=>dn(l,"hex");function zx(l){if(xT&&xT.getRandomValues){const p=new Uint8Array(l);return xT.getRandomValues(p),p}if(Ns&&Ns.randomBytes)return new Uint8Array(Ns.randomBytes(l));throw new Error("Secure random not available")}function h1(l,p){if(!(l instanceof Uint8Array)||!(p instanceof Uint8Array)||l.length!==p.length)return!1;let i=0;for(let r=0;r<l.length;r++)i|=l[r]^p[r];return i===0}function O2e(l,p,i,r){if((typeof l!="string"||typeof p!="string")&&typeof l!="string"&&typeof p!="string")throw new Error("Invalid input types");const a=i??"utf8",c=r??"utf8",e=dn(l??"",a),f=dn(p??"",c);return h1(e,f)}async function _2e(l,p){if(dp){const i=await dp.digest({name:l},ZT(p));return new Uint8Array(i)}if(Ns){const i=l.replace("SHA-","sha"),r=Ns.createHash(i);return r.update(Buffer.from(p)),new Uint8Array(r.digest())}throw new Error("Hash not available")}async function V2e(l,p,i,r){if(typeof p!="string")throw new Error("Invalid input type for data; expected string");const a=String(l??"SHA-256"),c=i??"utf8",e=r??"base64url",f=dn(p??"",c),h=await _2e(a,f);return Po(h,e)}async function m1(l,p,i){if(dp){const r=await dp.importKey("raw",ZT(p),{name:"HMAC",hash:{name:l}},!1,["sign"]),a=await dp.sign("HMAC",r,ZT(i));return new Uint8Array(a)}if(Ns){const r=`sha${l.split("-")[1]}`,a=Ns.createHmac(r,Buffer.from(p));return a.update(Buffer.from(i)),new Uint8Array(a.digest())}throw new Error("HMAC not available")}async function P2e(l,p,i,r,a,c){if(typeof l!="string"||typeof p!="string")throw new Error("Invalid input types for key or data; expected strings");const e=String(i??"SHA-256"),f=r??"utf8",h=a??"utf8",m=c??"base64url",E=dn(l??"",f),b=dn(p??"",h),A=await m1(e,E,b);return Po(A,m)}async function T1(l,p,{iterations:i,length:r,hashAlg:a="SHA-256"}){if(dp){const c=await dp.importKey("raw",ZT(l),"PBKDF2",!1,["deriveBits"]),e=await dp.deriveBits({name:"PBKDF2",salt:ZT(p),iterations:i,hash:a},c,r*8);return new Uint8Array(e)}if(Ns){const c=a==="SHA-512"?"sha512":"sha256";return await new Promise((e,f)=>{Ns.pbkdf2(Buffer.from(l),Buffer.from(p),i,r,c,(h,m)=>{h?f(h):e(new Uint8Array(m))})})}throw new Error("PBKDF2 not available")}async function N2e(l,p,i,r,a,c,e,f){if(typeof l!="string"||typeof p!="string")throw new Error("Invalid input types for password or salt; expected strings");const h=c??"utf8",m=e??"utf8",E=f??"base64url",b=Math.max(1,Number(i)||21e4),A=Math.max(1,Number(r)||32),_=a??"SHA-256",N=dn(l??"",h),V=dn(p??"",m),j=await T1(N,V,{iterations:b,length:A,hashAlg:_});return Po(j,E)}async function x2e(l,p=zx(16),i=21e4,r=32,a="SHA-256"){const c=dn(l,"utf8"),e=await T1(c,p,{iterations:i,length:r,hashAlg:a}),f=Th(p),h=Th(e);return`pbkdf2$${a.toLowerCase()}$${i}$${f}$${h}`}async function $2e(l,p){const i=String(p).split("$");if(i.length!==5||i[0]!=="pbkdf2")return!1;const r=i[1].toLowerCase(),a=parseInt(i[2],10),c=vf(i[3]),e=vf(i[4]),f=r.includes("512")?"SHA-512":"SHA-256",h=await T1(dn(l,"utf8"),c,{iterations:a,length:e.length,hashAlg:f});return h1(h,e)}async function L2e(l,p,i,r,a,c){const e=p!=null?Math.max(1,Number(p)||0):void 0,f=i!=null?Math.max(1,Number(i)||0):void 0,h=r??void 0,m=c??"base64url",E=a!=null?dn(a,m):void 0;return await x2e(String(l??""),E,e,f,h)}function Sk(l){return Th(dn(JSON.stringify(l),"utf8"))}function CI(l){try{return JSON.parse(Po(vf(l),"utf8"))}catch{return null}}async function B2e(l,p,{alg:i="HS256",includeIat:r=!0,expiresInSeconds:a,notBeforeSeconds:c,issuer:e,subject:f,audience:h,jwtid:m,header:E={}}={}){const b={alg:i,typ:"JWT",...E},A=Math.floor(Date.now()/1e3),_={...l||{}};r&&(_.iat=A),typeof a=="number"&&(_.exp=A+a),typeof c=="number"&&(_.nbf=A+c),e&&(_.iss=e),f&&(_.sub=f),h&&(_.aud=h),m&&(_.jti=m);const N=Sk(b),V=Sk(_),j=dn(`${N}.${V}`,"utf8"),G=await m1(i==="HS512"?"SHA-512":i==="HS384"?"SHA-384":"SHA-256",p,j),q=Th(G);return`${N}.${V}.${q}`}async function M2e(l,p,i,r,a,c,e,f,h,m,E,b){if(typeof p!="string")throw new Error("Invalid input type for secret; expected string");if(l!=null&&typeof l!="object")throw new Error("Invalid input type for payload; expected object");if(E!=null&&typeof E!="object")throw new Error("Invalid input type for header; expected object");if(m!=null&&typeof m!="string")throw new Error("Invalid input type for jwtid; expected string");if(e!=null&&typeof e!="string")throw new Error("Invalid input type for issuer; expected string");if(f!=null&&typeof f!="string")throw new Error("Invalid input type for subject; expected string");if(h!=null&&typeof h!="string"&&!Array.isArray(h))throw new Error("Invalid input type for audience; expected string or string[]");const _=dn(p??"",b??"utf8");return await B2e(l??{},_,{alg:i??"HS256",includeIat:r==null?!0:!!r,expiresInSeconds:a!=null?Number(a):void 0,notBeforeSeconds:c!=null?Number(c):void 0,issuer:e??void 0,subject:f??void 0,audience:h??void 0,jwtid:m??void 0,header:E??void 0})}async function G2e(l,p,{alg:i="HS256",issuer:r,audience:a,maxAgeSeconds:c,clockSkewSeconds:e=60}={}){try{const[f,h,m]=String(l).split(".");if(!f||!h||!m)return{valid:!1,header:null,payload:null,reason:"Malformed"};const E=CI(f),b=CI(h);if(!E||!b)return{valid:!1,header:E,payload:b,reason:"Bad base64/json"};if(E.alg!==i)return{valid:!1,header:E,payload:b,reason:"Alg mismatch"};const A=dn(`${f}.${h}`,"utf8"),N=await m1(i==="HS512"?"SHA-512":i==="HS384"?"SHA-384":"SHA-256",p,A),V=vf(m);if(!h1(N,V))return{valid:!1,header:E,payload:b,reason:"Bad signature"};const j=Math.floor(Date.now()/1e3),M=Math.max(0,Number(e)||0);if(b.nbf!=null&&j+M<Number(b.nbf))return{valid:!1,header:E,payload:b,reason:"Not before"};if(b.exp!=null&&j-M>=Number(b.exp))return{valid:!1,header:E,payload:b,reason:"Expired"};if(r&&b.iss!==r)return{valid:!1,header:E,payload:b,reason:"Issuer mismatch"};if(a){const G=b.aud;if(!(Array.isArray(G)?G.includes(a):G===a))return{valid:!1,header:E,payload:b,reason:"Audience mismatch"}}return c!=null&&b.iat!=null&&j-Number(b.iat)>Number(c)+M?{valid:!1,header:E,payload:b,reason:"MaxAge exceeded"}:{valid:!0,header:E,payload:b}}catch(f){return{valid:!1,header:null,payload:null,reason:String((f==null?void 0:f.message)??f)}}}async function j2e(l,p,i,r,a,c,e,f){if(typeof l!="string")throw new Error("Invalid input type for token; expected string");if(typeof p!="string")throw new Error("Invalid input type for secret; expected string");if(typeof r!="string")throw new Error("Invalid input type for issuer; expected string");if(a!=null&&typeof a!="string")throw new Error("Invalid input type for audience; expected string");const m=dn(p??"",f??"utf8");return await G2e(String(l??""),m,{alg:i??"HS256",issuer:r??void 0,audience:a??void 0,maxAgeSeconds:c!=null?Number(c):void 0,clockSkewSeconds:e!=null?Number(e):void 0})}function k2e(l){const[p,i,r]=String(l).split(".");return{header:p?CI(p):null,payload:i?CI(i):null,signature:r?vf(r):new Uint8Array}}function U2e(l,p){if(!l)throw new Error("Token is required for decoding");if(typeof l!="string")throw new Error("Invalid input type for token; expected string");const i=p??"base64url",{header:r,payload:a,signature:c}=k2e(String(l??"")),e=Po(c,i);return{header:r,payload:a,signature:e}}class F2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_GENERATE_RANDOM_BYTES,version:"1.0.0",description:"Randomness generate random bytes operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(nt.GenerateRandomBytes);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(E=>{var b,A;return((b=E.value)==null?void 0:b.valueAsType)??((A=E.value)==null?void 0:A.value)}),e=Math.max(0,Number(a)||0),f=c??"base64url",h=zx(e),m=Po(h,f);return{value:U.Success,error:null,result:m}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class K2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_INTEGER,version:"1.0.0",description:"Randomness generate random integer operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(nt.GenerateRandomInteger);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1],f=E_e(c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class q2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_FLOAT,version:"1.0.0",description:"Randomness generate random float operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(nt.GenerateRandomFloat);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=n1();return{value:U.Success,error:null,result:a}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class S2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_HEXADECIMAL,version:"1.0.0",description:"Randomness generate random hexadecimal operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(nt.GenerateRandomHexadecimal);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)||((m=f.value)==null?void 0:m.value)})[0],e=Rx(c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class Z2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_BASE62,version:"1.0.0",description:"Randomness generate random base62 operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(nt.GenerateRandomBase62);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)||((m=f.value)==null?void 0:m.value)})[0],e=Dx(c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class H2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_BASE64,version:"1.0.0",description:"Randomness generate random base64 operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(nt.GenerateRandomBase64);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)||((m=f.value)==null?void 0:m.value)})[0],e=A_e(c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class W2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_ALPHANUMERIC,version:"1.0.0",description:"Randomness generate random alphanumeric operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(nt.GenerateRandomAlphanumeric);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)||((m=f.value)==null?void 0:m.value)})[0],e=wx(c);return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class z2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_IDENTIFIER,version:"1.0.0",description:"Generate identifier operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(nt.GenerateIdentifier);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)||((E=h.value)==null?void 0:E.value)}),c=a[0],e=a[1],f=Cx(c,e);return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class Y2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_UUIDV4,version:"1.0.0",description:"Generate UUID v4 operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(nt.GenerateRandomUUIDv4);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=op();return{value:U.Success,error:null,result:a}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class J2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_SHORT_IDENTIFIER,version:"1.0.0",description:"Generate short identifier operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{Y.Logger.log("Initializing Random Generate Short Identifier Module");const r=i.find(a=>a.contextType===ae.Logic);if(r){Y.Logger.log("Project state found, setting up operation");const a=r.get(nt.GenerateShortIdentifier);a?(Y.Logger.log("Operation found, setting autoexecutable and implementation"),a.autoexecutable=!0,a.implementation=this.module.main):Y.Logger.warn("Operation generate-short-identifier not found in project state")}else Y.Logger.warn("Project state not found in contexts for Random Generate Short Identifier Module")},main:async(i,r)=>{try{const a=I_e();return{value:U.Success,error:null,result:a}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class Q2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_HEXADECIMAL_TOKEN,version:"1.0.0",description:"Generate hexadecimal token operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(nt.GenerateHexadecimalToken);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const a=g_e();return{value:U.Success,error:null,result:a}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}function Xgi(l){let p;if(l===null?p="null":Array.isArray(l)?p="array":p=typeof l,!["string","number","boolean","null","object","array"].includes(p))throw new TypeError("GetTypeOf cannot determine type of the given value.");return p}class X2e extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_GET_TYPE_OF,version:"1.0.0",description:"Data type get type of operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(Qe.GetTypeOf);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{try{const c=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)||((h=e.value)==null?void 0:h.value)})[0];return{value:U.Success,error:null,result:Xgi(c)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class eBe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_TO_STRING,version:"1.0.0",description:"Coerce any value to string via JS String(value)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(Qe.ToString);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)??((h=e.value)==null?void 0:h.value)}),c=String(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class tBe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_TO_NUMBER,version:"1.0.0",description:"Coerce to number via JS Number(value)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(Qe.ToNumber);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)??((h=e.value)==null?void 0:h.value)}),c=Number(a);return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class iBe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_TO_BYTES,version:"1.0.0",description:"Convert string/bytes-like to Uint8Array (utf8|hex|base64|base64url)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(Qe.ToBytes);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)??((E=h.value)==null?void 0:E.value)}),f=dn(a,c||"utf8");return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class rBe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_FROM_BYTES_TO_STRING,version:"1.0.0",description:"Convert Uint8Array to string (utf8|hex|base64|base64url)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(Qe.FromBytesToString);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)??((E=h.value)==null?void 0:E.value)}),f=Po(a,c||"utf8");return{value:U.Success,error:null,result:f}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class nBe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_ENCODE_BASE64,version:"1.0.0",description:"Bytes -> base64 string (accepts string input by converting from utf8)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(Qe.EncodeBase64);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)??((h=e.value)==null?void 0:h.value)});return{value:U.Success,error:null,result:D2e(a,c)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class aBe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_DECODE_BASE64,version:"1.0.0",description:"base64 string -> bytes (Uint8Array)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(Qe.DecodeBase64);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)??((h=e.value)==null?void 0:h.value)}),c=R2e(String(a));return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class sBe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_ENCODE_BASE64URL,version:"1.0.0",description:"Bytes -> base64url string (accepts string input by converting from utf8)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(Qe.EncodeBase64Url);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)??((m=f.value)==null?void 0:m.value)}),e=Th(a,c||"utf8");return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class lBe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_DECODE_BASE64URL,version:"1.0.0",description:"base64url string -> bytes (Uint8Array)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(Qe.DecodeBase64Url);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)??((h=e.value)==null?void 0:h.value)}),c=vf(String(a));return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class oBe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_ENCODE_HEX,version:"1.0.0",description:"Bytes -> hex string (accepts string input by converting from utf8)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(Qe.EncodeHex);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)??((m=f.value)==null?void 0:m.value)}),e=w2e(a,c||"utf8");return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class dBe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_DECODE_HEX,version:"1.0.0",description:"hex string -> bytes (Uint8Array)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(Qe.DecodeHex);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)??((h=e.value)==null?void 0:h.value)}),c=C2e(String(a));return{value:U.Success,error:null,result:c}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class uBe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_HASH,version:"1.0.0",description:"Crypto: Hash (SHA-256/384/512)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(Pi.Hash);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e,f]=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)??((E=h.value)==null?void 0:E.value)});return{value:U.Success,error:null,result:V2e(a,c,e,f)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class pBe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_HMAC,version:"1.0.0",description:"Crypto: HMAC (SHA-256/384/512)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(Pi.Hmac);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e,f,h,m]=r.map(E=>{var b,A;return((b=E.value)==null?void 0:b.valueAsType)??((A=E.value)==null?void 0:A.value)});return{value:U.Success,error:null,result:P2e(c,e,a,f,h,m)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class cBe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_CONSTANT_TIME_EQUAL,version:"1.0.0",description:"Crypto: constant-time equality for byte sequences",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(Pi.ConstantTimeEqual);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e,f]=r.map(h=>{var m,E;return((m=h.value)==null?void 0:m.valueAsType)??((E=h.value)==null?void 0:E.value)});return{value:U.Success,error:null,result:O2e(a,c,e,f)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class fBe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_DERIVE_KEY_PBKDF2,version:"1.0.0",description:"Crypto: derive key with PBKDF2 (SHA-256/512)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(Pi.DeriveKeyPBKDF2);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e,f,h,m,E,b]=r.map(A=>{var _,N;return((_=A.value)==null?void 0:_.valueAsType)??((N=A.value)==null?void 0:N.value)});return{value:U.Success,error:null,result:N2e(a,c,e,f,h,m,E,b)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class yBe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_IN_OPERATIONS_IMPLEMENTATIONS__JSON_PARSE,version:"1.0.0",description:"Json parse string into object operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(fn.Parse);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{var a;try{const c=(a=r[0].value)==null?void 0:a.value;if(typeof c!="string")throw new Error(`Invalid input type for JSON.parse operation: expected string, got ${typeof c}`);const e=JSON.parse(c);return{value:U.Success,error:null,result:e}}catch(c){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:c,result:null}}}})}}class hBe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_IN_OPERATIONS_IMPLEMENTATIONS__JSON_STRINGIFY,version:"1.0.0",description:"Json stringify object into string operation implementation module",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(a=>a.contextType===ae.Logic);if(r){const a=r.get(fn.Stringify);a&&(a.autoexecutable=!0,a.implementation=this.module.main)}},main:async(i,r)=>{var a,c;try{const e=(a=r[0].value)==null?void 0:a.value,f=(c=r[1].value)==null?void 0:c.value;if(!e||typeof e!="object"&&!Array.isArray(e))throw new Error(`Invalid input type for JSON.stringify operation: expected object or array, got ${typeof e}`);if(!f&&f!==0){const m=JSON.stringify(e);return{value:U.Success,error:null,result:m}}const h=JSON.stringify(e,null,f);return{value:U.Success,error:null,result:h}}catch(e){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:e,result:null}}}})}}class mBe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__JWT_BUILD_HMAC,version:"1.0.0",description:"JWT: build (HS256/384/512)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ur.BuildJwtHmac);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e,f,h,m,E,b,A,_,N,V]=r.map(j=>{var M,G;return((M=j.value)==null?void 0:M.valueAsType)??((G=j.value)==null?void 0:G.value)});return{value:U.Success,error:null,result:await M2e(a,c,e,f,h,m,E,b,A,_,N,V)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class TBe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__JWT_VERIFY_HMAC,version:"1.0.0",description:"JWT: verify (HS256/384/512)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ur.VerifyJwtHmac);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e,f,h,m,E,b]=r.map(A=>{var _,N;return((_=A.value)==null?void 0:_.valueAsType)??((N=A.value)==null?void 0:N.value)});return{value:U.Success,error:null,result:await j2e(a,c,e,f,h,m,E,b)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class vBe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__JWT_DECODE,version:"1.0.0",description:"JWT: decode (no verification)",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(ur.DecodeJwt);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(e=>{var f,h;return((f=e.value)==null?void 0:f.valueAsType)??((h=e.value)==null?void 0:h.value)});return{value:U.Success,error:null,result:U2e(a,c)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class EBe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__PASSWORD_HASH_PBKDF2,version:"1.0.0",description:"Password: hash (PBKDF2) -> envelope string",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(yn.HashPasswordPBKDF2);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c,e,f,h,m]=r.map(E=>{var b,A;return((b=E.value)==null?void 0:b.valueAsType)??((A=E.value)==null?void 0:A.value)});return{value:U.Success,error:null,result:await L2e(a,c,e,f,h,m)}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class bBe extends Pe{constructor(){super(...arguments);R(this,"manifest",{id:Ve.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__PASSWORD_VERIFY_PBKDF2,version:"1.0.0",description:"Password: verify (PBKDF2) -> boolean",initPriority:Oe.High,permissions:[_e.All],contexts:[ae.Logic]});R(this,"module",{init:i=>{const r=i.find(c=>c.contextType===ae.Logic),a=r==null?void 0:r.get(yn.VerifyPasswordPBKDF2);a&&(a.autoexecutable=!0,a.implementation=this.module.main)},main:async(i,r)=>{try{const[a,c]=r.map(f=>{var h,m;return((h=f.value)==null?void 0:h.valueAsType)??((m=f.value)==null?void 0:m.value)}),e=await $2e(String(a??""),String(c??""));return{value:U.Success,error:null,result:e}}catch(a){return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,error:a,result:null}}}})}}class N_ extends o1{constructor(p,i,r=i.projectId){super(p,ae.Editor),this._editor=i,this.id=r}get ready(){return this._editor.ready}get hasLoadedLogic(){return this._editor.hasLoadedLogic}get destroyed(){return this._editor.destroyed}get logicLoadingPromise(){return this._editor.logicLoadingPromise}get logic(){return this._editor.logic}get lastPublishedProjectState(){return this._editor.lastPublishedProjectState}get branch(){return this._editor.branch}get projectId(){return this._editor.projectId}get sessionId(){return this._editor.sessionId}get userAuthorId(){return this._editor.userAuthorId}get peerConnections(){return this._editor.peerConnections}get test(){return this._editor.test}get localTestValues(){return this._editor.localTestValues}get resolvedValues(){return this._editor.resolvedValues}get persistedExecutionResults(){return this._editor.persistedExecutionResults}get publication(){return this._editor.publication}get livePublishedVersions(){return this._editor.livePublishedVersions}get publications(){return this._editor.publications}get liveResources(){return this._editor.liveResources}get execution(){return this._editor.execution}get project(){return this._editor.logic}get lastExecutionResults(){return this._editor.lastExecutionResults}get undoableStackValueIndex(){return this._editor.undoableStackValueIndex}set undoableStackValueIndex(p){this._editor.undoableStackValueIndex=p}get PROJECT_NOTIFICATIONS_CHANNEL(){return this._editor.PROJECT_NOTIFICATIONS_CHANNEL}getAccessToken(){return this._editor.getAccessToken()}getRefreshToken(){return this._editor.getRefreshToken()}removeValueByOwnerId(p){return this._editor.removeValueByOwnerId(p)}removeValue(p){return this._editor.removeValue(p)}undo(){return this._editor.undo()}redo(){return this._editor.redo()}initTest(p,i){return this._editor.initTest(p,i)}removeTest(p){return this._editor.removeTest(p)}async copyEntities(p,i={}){return this._editor.copyEntities(p,i)}resolveInitialChildrenPositions(p,i,r){return this._editor.resolveInitialChildrenPositions(p,i,r)}publish(){return this._editor.publish()}loadGivenPublication(p){return this._editor.loadGivenPublication(p)}validateProjectState(p){return this._editor.validateProjectState(p)}requestActiveDynamicValue(p,i=!1){return this._editor.requestActiveDynamicValue(p,i)}getValueTypePreference(p){return this._editor.getValueTypePreference(p)}setValueTypePreference(p,i){return this._editor.setValueTypePreference(p,i)}implementFeature(p){return this._editor.implementFeature(p)}}function eRi(l,p){return p instanceof N_?p:new N_(l,p)}class x_ extends o1{constructor(p,i){super(p,ae.PublicationRun),this._publicationRun=i}get id(){return this._publicationRun.id}get projectAutoIncrementPublicationCount(){return this._publicationRun.projectAutoIncrementPublicationCount}get projectPublishedSemanticVersion(){return this._publicationRun.projectPublishedSemanticVersion}get projectVersion(){return this._publicationRun.projectVersion}get projectId(){return this._publicationRun.projectId}get triggeredBy(){return this._publicationRun.triggeredBy}get createdAt(){return this._publicationRun.createdAt}get updatedAt(){return this._publicationRun.updatedAt}get status(){return this._publicationRun.status}get steps(){return this._publicationRun.steps}get editor(){return this._publicationRun.editor}get explicitResources(){return this._publicationRun.explicitResources}get implicitGlobalResources(){return this._publicationRun.implicitGlobalResources}get finalGlobalEvent(){return this._publicationRun.finalGlobalEvent}get finalStatus(){return this._publicationRun.finalStatus}}function tRi(l,p){return p instanceof x_?p:new x_(l,p)}function iRi(l){l.register(new vVe(l)),l.register(new TVe(l)),l.register(new fVe(l)),l.register(new hVe(l)),l.register(new mVe(l)),l.register(new yVe(l)),l.register(new X$e(l)),l.register(new eLe(l)),l.register(new tLe(l)),l.register(new rLe(l)),l.register(new iLe(l)),l.register(new nLe(l)),l.register(new K2e(l)),l.register(new q2e(l)),l.register(new S2e(l)),l.register(new Z2e(l)),l.register(new H2e(l)),l.register(new W2e(l)),l.register(new z2e(l)),l.register(new Y2e(l)),l.register(new J2e(l)),l.register(new Q2e(l)),l.register(new Qxe(l)),l.register(new Xxe(l)),l.register(new e$e(l)),l.register(new t$e(l)),l.register(new i$e(l)),l.register(new r$e(l)),l.register(new n$e(l)),l.register(new a$e(l)),l.register(new s$e(l)),l.register(new l$e(l)),l.register(new o$e(l)),l.register(new d$e(l)),l.register(new u$e(l)),l.register(new p$e(l)),l.register(new c$e(l)),l.register(new f$e(l)),l.register(new y$e(l)),l.register(new h$e(l)),l.register(new m$e(l)),l.register(new E$e(l)),l.register(new b$e(l)),l.register(new A$e(l)),l.register(new vxe(l)),l.register(new Exe(l)),l.register(new bxe(l)),l.register(new Axe(l)),l.register(new Ixe(l)),l.register(new gxe(l)),l.register(new Rxe(l)),l.register(new Dxe(l)),l.register(new wxe(l)),l.register(new Oxe(l)),l.register(new _xe(l)),l.register(new Vxe(l)),l.register(new Pxe(l)),l.register(new Nxe(l)),l.register(new MNe(l)),l.register(new l2e(l)),l.register(new s2e(l)),l.register(new BPe(l)),l.register(new MPe(l)),l.register(new GPe(l)),l.register(new jPe(l)),l.register(new kPe(l)),l.register(new UPe(l)),l.register(new FPe(l)),l.register(new KPe(l)),l.register(new qPe(l)),l.register(new rNe(l)),l.register(new $Ne(l)),l.register(new LNe(l)),l.register(new BNe(l)),l.register(new SPe(l)),l.register(new ZPe(l)),l.register(new HPe(l)),l.register(new WPe(l)),l.register(new zPe(l)),l.register(new YPe(l)),l.register(new JPe(l)),l.register(new QPe(l)),l.register(new XPe(l)),l.register(new eNe(l)),l.register(new tNe(l)),l.register(new iNe(l)),l.register(new nNe(l)),l.register(new aNe(l)),l.register(new sNe(l)),l.register(new lNe(l)),l.register(new oNe(l)),l.register(new dNe(l)),l.register(new uNe(l)),l.register(new pNe(l)),l.register(new cNe(l)),l.register(new fNe(l)),l.register(new yNe(l)),l.register(new hNe(l)),l.register(new RNe(l)),l.register(new DNe(l)),l.register(new wNe(l)),l.register(new mNe(l)),l.register(new TNe(l)),l.register(new vNe(l)),l.register(new ENe(l)),l.register(new bNe(l)),l.register(new ANe(l)),l.register(new INe(l)),l.register(new gNe(l)),l.register(new p2e(l)),l.register(new c2e(l)),l.register(new f2e(l)),l.register(new y2e(l)),l.register(new o2e(l)),l.register(new d2e(l)),l.register(new u2e(l)),l.register(new h2e(l)),l.register(new T2e(l)),l.register(new E2e(l)),l.register(new m2e(l)),l.register(new v2e(l)),l.register(new b2e(l)),l.register(new g2e(l)),l.register(new A2e(l)),l.register(new I2e(l)),l.register(new xxe(l)),l.register(new Mxe(l)),l.register(new Gxe(l)),l.register(new Uxe(l)),l.register(new Fxe(l)),l.register(new Kxe(l)),l.register(new qxe(l)),l.register(new Sxe(l)),l.register(new Zxe(l)),l.register(new Hxe(l)),l.register(new Wxe(l)),l.register(new jxe(l)),l.register(new kxe(l)),l.register(new Lxe(l)),l.register(new Bxe(l)),l.register(new $xe(l)),l.register(new Cxe(l)),l.register(new Yxe(l)),l.register(new Jxe(l)),l.register(new zxe(l)),l.register(new sLe(l)),l.register(new VLe(l)),l.register(new _Le(l)),l.register(new PLe(l)),l.register(new NLe(l)),l.register(new dLe(l)),l.register(new uLe(l)),l.register(new mLe(l)),l.register(new yLe(l)),l.register(new CLe(l)),l.register(new ALe(l)),l.register(new gLe(l)),l.register(new DLe(l)),l.register(new RLe(l)),l.register(new hLe(l)),l.register(new vLe(l)),l.register(new ELe(l)),l.register(new TLe(l)),l.register(new aLe(l)),l.register(new pLe(l)),l.register(new ILe(l)),l.register(new LLe(l)),l.register(new C_(l)),l.register(new oLe(l)),l.register(new cLe(l)),l.register(new lLe(l)),l.register(new wLe(l)),l.register(new fLe(l)),l.register(new bLe(l)),l.register(new OLe(l)),l.register(new $Le(l)),l.register(new xLe(l)),l.register(new BLe(l)),l.register(new C_(l)),l.register(new GLe(l)),l.register(new MLe(l)),l.register(new jLe(l)),l.register(new B$e(l)),l.register(new M$e(l)),l.register(new G$e(l)),l.register(new g$e(l)),l.register(new v$e(l)),l.register(new C$e(l)),l.register(new P$e(l)),l.register(new T$e(l)),l.register(new N$e(l)),l.register(new L$e(l)),l.register(new _$e(l)),l.register(new O$e(l)),l.register(new RI(l)),l.register(new j$e(l)),l.register(new k$e(l)),l.register(new V$e(l)),l.register(new $$e(l)),l.register(new x$e(l)),l.register(new w$e(l)),l.register(new D$e(l)),l.register(new R$e(l)),l.register(new I$e(l)),l.register(new K$e(l)),l.register(new F$e(l)),l.register(new q$e(l)),l.register(new U$e(l)),l.register(new VNe(l)),l.register(new CNe(l)),l.register(new _Ne(l)),l.register(new PNe(l)),l.register(new NNe(l)),l.register(new ONe(l)),l.register(new xNe(l)),l.register(new X2e(l)),l.register(new aBe(l)),l.register(new lBe(l)),l.register(new dBe(l)),l.register(new nBe(l)),l.register(new sBe(l)),l.register(new oBe(l)),l.register(new rBe(l)),l.register(new iBe(l)),l.register(new tBe(l)),l.register(new eBe(l)),l.register(new yBe(l)),l.register(new hBe(l)),l.register(new cBe(l)),l.register(new fBe(l)),l.register(new F2e(l)),l.register(new uBe(l)),l.register(new pBe(l)),l.register(new TBe(l)),l.register(new mBe(l)),l.register(new vBe(l)),l.register(new EBe(l)),l.register(new bBe(l)),l.register(new bVe(l)),l.register(new AVe(l)),l.register(new II(l)),l.register(new gI(l))}class Yx{constructor(p=new Y.Events("extensions-registry-fallback-events")){R(this,"extensionsRegistry",new Map);R(this,"initialized",new Set);R(this,"initializedContexts",new Set);R(this,"onResolveEditorContextCallback",()=>null);R(this,"onResolveProjectLogicContextCallback",()=>null);R(this,"onResolveEditorGUIContextCallback",()=>null);R(this,"onResolveGUIContextCallback",()=>null);R(this,"onResolveCompileContextCallback",()=>null);R(this,"onResolvePublicationRunContextCallback",()=>null);this.events=p,this.off=this.events.off.bind(this.events),this.on=this.events.on.bind(this.events),this.emit=this.events.emit.bind(this.events),this.emitAsync=this.events.emitAsync.bind(this.events),this.emitAsyncAll=this.events.emitAsyncAll.bind(this.events),this.emitAsyncAllSettled=this.events.emitAsyncAllSettled.bind(this.events),this.emitAsyncSequentially=this.events.emitAsyncSequentially.bind(this.events),this.emitAsyncSequentiallyAll=this.events.emitAsyncSequentiallyAll.bind(this.events),this.emitAsyncSequentiallyAllSettled=this.events.emitAsyncSequentiallyAllSettled.bind(this.events)}onResolveEditorContext(p){this.onResolveEditorContextCallback=p}onResolveProjectLogicContext(p){this.onResolveProjectLogicContextCallback=p}onResolveGUIContext(p){this.onResolveGUIContextCallback=p}onResolveEditorGUIContext(p){this.onResolveEditorGUIContextCallback=p}onResolveCompileContext(p){this.onResolveCompileContextCallback=p}onResolvePublicationRunContext(p){this.onResolvePublicationRunContextCallback=p}get extensionInOrder(){return Array.from(this.extensionsRegistry.values()).sort((p,i)=>(p.manifest.initPriority||Oe.Normal)-(i.manifest.initPriority||Oe.Normal))}async setup(){iRi(this),Y.Logger.log("Initializing extensions without context..."),this.initForReady()}requestContext(p){switch(p){case ae.Editor:return this.onResolveEditorContextCallback();case ae.Logic:return this.onResolveProjectLogicContextCallback();case ae.EditorGUI:return this.onResolveEditorGUIContextCallback();case ae.Compile:return this.onResolveCompileContextCallback();case ae.PublicationRun:return this.onResolvePublicationRunContextCallback();case ae.GUI:return this.onResolveGUIContextCallback();case ae.EditorGUI:return this.onResolveEditorGUIContextCallback();default:throw new Error(`Unknown context type: ${p}`)}}requestContexts(p,i=[]){const r=[];i.length===0&&(i=p.manifest.contexts);for(const a of i){const c=this.requestContext(a);c&&r.push(c)}return r}requestExtension(p){const i=this.extensionsRegistry.get(p);if(i)return i;throw new Error(`Unknown extension: ${p}`)}register(p){this.extensionsRegistry.set(p.manifest.id,p)}async initAll(){var p,i;for(const r of this.extensionInOrder)if(r.module.init&&!this.initialized.has(r.manifest.id)){const a=r.manifest.contexts.map(c=>this.requestContext(c)).filter(c=>c!==null);a.length&&(await((i=(p=r.module).init)==null?void 0:i.call(p,a)),this.initialized.add(r.manifest.id))}else!r.module.init&&!this.initialized.has(r.manifest.id)&&this.initialized.add(r.manifest.id)}async initForReady(){Y.Logger.log("Initializing extensions for ready contexts...");for(const p of this.extensionInOrder)if(p.module.init&&!this.initialized.has(p.manifest.id)){Y.Logger.log("Initializing "+p.manifest.id+" extension...");const i=this.requestContexts(p);p.manifest.contexts.every(a=>!!i.find(c=>c.contextType===a))?(await p.module.init(i),this.initialized.add(p.manifest.id)):Y.Logger.warn(`Skipping initialization of ${p.manifest.id} extension, not all contexts are ready.`,`Required contexts: ${p.manifest.contexts.join(", ")}`,`Available contexts: ${i.map(a=>a.contextType).join(", ")}`)}else!p.module.init&&!this.initialized.has(p.manifest.id)?(Y.Logger.log("Set "+p.manifest.id+" extension as initialized by default..."),this.initialized.add(p.manifest.id)):Y.Logger.log(`Skipping initialization of ${p.manifest.id} extension, already initialized or no init method defined.`)}async destroyAll(){for(const p of[...this.extensionInOrder].reverse())p.module.destroy&&await p.module.destroy();this.events.destroy()}on(p,i){this.events.on(p,i)}emit(p,...i){this.events.emit(p,...i)}off(p,i){this.events.off(p,i)}emitAsync(p,...i){return this.events.emitAsync(p,...i)}emitAsyncAll(p,...i){return this.events.emitAsyncAll(p,...i)}emitAsyncAllSettled(p,...i){return this.events.emitAsyncAllSettled(p,...i)}emitAsyncSequentially(p,...i){return this.events.emitAsyncSequentially(p,...i)}emitAsyncSequentiallyAll(p,...i){return this.events.emitAsyncSequentiallyAll(p,...i)}emitAsyncSequentiallyAllSettled(p,...i){return this.events.emitAsyncSequentiallyAllSettled(p,...i)}async contextAvailable(p){if(this.initializedContexts.has(p)){Y.Logger.warn(`Context ${p} is already initialized. Skipping re-initialization.`);return}switch(this.initializedContexts.add(p),p){case ae.Editor:{if(!this.onResolveEditorContextCallback)throw new Error("No editor context resolver callback set. Call onResolveEditorContext first.");break}case ae.Logic:{if(!this.onResolveProjectLogicContextCallback)throw new Error("No project logic context resolver callback set. Call onResolveProjectLogicContext first.");break}}Y.Logger.log(`Context ${p} is now available. Initializing extensions for this context...`),await this.initForReady()}getValueTypePreference(p){return window.localStorage.getItem("dynamic-value-type-preference--"+p)||null}setValueTypePreference(p,i){window.localStorage.setItem("dynamic-value-type-preference--"+p,(i==null?void 0:i.toString())||""),this.emit(p,{})}}let ZA=null;const Jx={requestExtension:l=>(ZA||(ZA=new Yx,ZA.setup()),ZA.requestExtension(l))},Yu={onBeforeEntityExecution:async()=>{},onEntityExecuted:async()=>{}};var Qx=(l=>(l.FinishedSuccess="finished-success",l.FinishedError="finished-error",l.Running="running",l.Paused="paused",l.Stopped="stopped",l.NotStarted="not-started",l))(Qx||{});const ABe={...Jx,getValueTypePreference:()=>null,setValueTypePreference:()=>{}};class th extends Y.Events{constructor(i,r,a,c=null,e=ABe){super();R(this,"project");R(this,"entryPoint");R(this,"state","not-started");R(this,"events",new Y.Events("fe-exec-inst-events"));R(this,"entities",[]);R(this,"parentExecution",null);R(this,"executing",[]);R(this,"executed",[]);R(this,"skipped",[]);R(this,"scheduled",[]);R(this,"localTestValues");R(this,"resolvedValues");R(this,"persistedExecutionResults");R(this,"lastExecutionResults");R(this,"onAddToSkippedListCallback",null);R(this,"onRemoveFromSkippedListCallback",null);R(this,"onAddEntityCallback",null);R(this,"onRemoveEntityCallback",null);R(this,"onAbortExecutionCallback",null);this.parentContext=e,this.entities=r,this.entryPoint=a,this.project=i,this.parentExecution=c,this.localTestValues=new gT(x.UUID.uuid(),this.project),this.resolvedValues=new gT(x.UUID.uuid(),this.project),this.persistedExecutionResults=new gT(x.UUID.uuid(),this.project),this.lastExecutionResults=new gT(x.UUID.uuid(),this.project)}get valueResolutionContext(){return{execution:this,project:this.project,localTestValues:this.localTestValues,resolvedValues:this.resolvedValues,persistedExecutionResults:this.persistedExecutionResults,lastExecutionResults:this.lastExecutionResults,getValueTypePreference:this.parentContext.getValueTypePreference,setValueTypePreference:this.parentContext.setValueTypePreference}}skip(i){this.hasEntity(i)&&(this.removeFromScheduledList(i),!this.skipped.includes(i)&&(this.skipped.push(i),this.onAddToSkippedListCallback&&this.onAddToSkippedListCallback(i),Wi.includes(i.type)&&pt(i).forEach(r=>this.skip(r))))}async schedule(i,r,a){if(this.hasExecuted(i))return null;if(Bt.includes(i.type))return this.executeBranch(i,a,r);if(er.includes(i.type)){if(i.calledBy.every(e=>this.hasExecuted(e)||!this.hasEntity(e)))return this.executeBranch(i,a,r);this.scheduled.includes(i)||this.scheduled.push(i)}return null}mergeExernalValuesWithInternalInputs(i,r){const a=[];return[...wt,...Bt].includes(r.type)?a.push(...r.inputs):At.includes(r.type)&&a.push(...r.outputs),a.map(e=>{var h;let f=i.find(m=>m.valueOwner.id===e.id);if(f)return f;if(!f&&Bt.includes(r.type)&&(f=i.find(m=>{var E;return((E=m.valueOwner.declaration)==null?void 0:E.id)===e.id})),f){const m=(h=f.value)==null?void 0:h.clone(null);return m==null||m.setStandaloneParent(e,null),{...f,valueOwner:e,value:m||null,inheritanceLink:{sources:[f],target:e}}}return Sr.includes(e.type)?Yo(e,this.valueResolutionContext):mf(e,this.valueResolutionContext)}).reduce((e,f)=>{const h=id(f==null?void 0:f.valueOwner,this.project),m=f?[f]:[];return h.forEach(E=>{var _,N,V;if(E.id===(f==null?void 0:f.valueOwner.id))return;const b=Nt(E.getDataType(null),E,this.project);b==null||b.metaSync({value:(_=f==null?void 0:f.value)==null?void 0:_.value},null),b==null||b.setValueAsTypeList(((N=f==null?void 0:f.value)==null?void 0:N.valueAsTypeList)||null),b==null||b.setValueAsTypeSingle(((V=f==null?void 0:f.value)==null?void 0:V.valueAsTypeSingle)||null);const A={...f,valueOwner:E,value:b};m.push(A)}),[...e,...m]},[]).sort((e,f)=>e.valueOwner.index-f.valueOwner.index)}inheritValuesFromContext(i){this.localTestValues=i.localTestValues,this.resolvedValues=i.resolvedValues,this.persistedExecutionResults=i.persistedExecutionResults}async executeInternalCall(i,r,a,c={}){var f,h;const e={...Yu,...c};try{let m={value:U.Success,error:null,result:null};if(r.sort((E,b)=>E.valueOwner.index-b.valueOwner.index),Object.values(xr).includes(i.declaration.id)){const E=this.parentContext.requestExtension(eh+i.declaration.id).module.main;E?m=await E(i,r):Y.Logger.warn(`No implementation found for built-in function: ${i.declaration.id}`)}else{m=await this.executeDetachedFullFunctionDeclarationLogic(i.declaration,r,a,e);let E=null;if(m.error){Y.Logger.warn("Raw error executing entity: ",m.error);const b=(f=i.error)==null?void 0:f.getDataType(null),A=Nt(b||null,i.error,a);b!=null&&b.asType?A==null||A.setValueAsTypeSingle(m.error):A==null||A.metaSync({value:m.error},null),E={valueOwner:i.error,type:Me.ExecutionResult,inheritanceLink:null,value:A}}return{value:m.value,entity:i,error:E,result:{value:m.result||null,valueOwner:i,type:Me.ExecutionResult,inheritanceLink:null}}}return{...m,entity:i}}catch(m){Y.Logger.warn("Internal call execution error: ",m);let E=null;if(i.error){const b=(h=i.error)==null?void 0:h.getDataType(null),A=Nt(b,i.error,a);b!=null&&b.asType?A==null||A.setValueAsTypeSingle(m):A==null||A.metaSync({value:m},null),E={valueOwner:i.error,type:Me.ExecutionResult,inheritanceLink:null,value:A}}return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,entity:i,error:E,result:null}}}static async executeOperation(i,r,a){var c,e;try{let f={value:U.Success,error:null,result:null};r.sort((b,A)=>b.valueOwner.index-A.valueOwner.index),i.declaration.implementation&&(f=await i.declaration.implementation(i,r));let h=null;if(f.error&&i.error){Y.Logger.warn("Raw error executing entity: ",f.error);const b=((c=i.error)==null?void 0:c.getDataType(null))||null,A=Nt(b,i.error,a);b!=null&&b.asType?A==null||A.setValueAsTypeSingle(f.error):A==null||A.metaSync({value:f.error},null),h={valueOwner:i.error,type:Me.ExecutionResult,inheritanceLink:null,value:A}}const m=i==null?void 0:i.getDataType(null),E=Nt(m,i,a);return m!=null&&m.asType?E==null||E.setValueAsTypeSingle(f.result):E==null||E.metaSync({value:f.result},null),{value:f.value,entity:i,error:h,result:{value:E||null,valueOwner:i,type:Me.ExecutionResult,inheritanceLink:null}}}catch(f){Y.Logger.warn("Operation execution error: ",f);let h=null;if(i.error){const m=(e=i.error)==null?void 0:e.getDataType(null),E=Nt(m,i.error,a);m!=null&&m.asType?E==null||E.setValueAsTypeSingle(f):E==null||E.metaSync({value:f},null),h={valueOwner:i.error,type:Me.ExecutionResult,inheritanceLink:null,value:E}}return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,entity:i,error:h,result:null}}}async executeSearch(i,r,a){var c;try{let e={value:U.Success,error:null,result:null};const f=await(await this.parentContext.requestExtension(Ve.SEARCH_NODE_IMPLEMENTATION)).module.main(i,r),h=i==null?void 0:i.getDataType(null),m=Nt(h,i,a);return m==null||m.metaSync({value:f},null),f.error?{value:U.UnhandledError,entity:i,error:{valueOwner:i,type:Me.ExecutionResult,inheritanceLink:null,value:m},result:null}:{value:e.value,entity:i,error:null,result:{value:m,valueOwner:i,type:Me.ExecutionResult,inheritanceLink:null}}}catch(e){if(Y.Logger.warn(`Search node execution error: ${e}`),!i.error)return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,entity:i,error:null,result:null};const f=(c=i.error)==null?void 0:c.getDataType(null),h=Nt(f,i.error,a);return h==null||h.metaSync({value:e},null),{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,entity:i,error:{valueOwner:i.error,type:Me.ExecutionResult,inheritanceLink:null,value:h},result:null}}}async executeLoop(i,r,a,c={}){var f,h,m,E,b,A;const e={...Yu,...c};try{let _={value:U.Success,error:null,result:null};const N=r.map(re=>{var ee,de;return((ee=re==null?void 0:re.value)==null?void 0:ee.valueAsType)||((de=re==null?void 0:re.value)==null?void 0:de.value)});let V={};i.getUniqueInputMaps().forEach(re=>{const ee=i.body.inputs.find(ue=>le(ue,a)===le(re,a)),de=re==null?void 0:re.getDataType(null),ie=Nt(de,ee,a);de!=null&&de.asType?ie==null||ie.setValueAsTypeList([]):ie==null||ie.metaSync({value:[]},null),this.lastExecutionResults.writeValue(ee,ie);const se={value:ie,valueOwner:ee,type:Me.ExecutionResult,inheritanceLink:null};V[ee.id]=se});let M={value:U.Success,entity:i.body,error:null,result:null};switch(i.declaration.id){case ne.loop["counted-loop"].id:{const re=N[0];let ee=1;for(;ee<=re&&ee<=50;){const de=i.body.inputs.map(ie=>{if(ie===i.currentIterationNumberArgumentDeclaration){const se=i.currentIterationNumberArgumentDeclaration.getDataType(null),ue=rf(se),z=this.lastExecutionResults.readValue(ie.id);if(z){z.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ie,z);const me={value:z,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Me.ExecutionResult,inheritanceLink:null};return V[ie.id]=me,me}const X={id:x.UUID.uuid(),deletable:!0,editable:!0,type:d.LiteralValue,autogeneration:null,version:x.UUID.uuid(),createdAt:new Date().toISOString(),author:x.sessionAuthor,deleted:!1,previousVersion:null,value:ee,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:ue,standaloneParent:ie.toReference()},ce=tr(X,a);this.lastExecutionResults.writeValue(ie,ce);const oe={value:ce,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Me.ExecutionResult,inheritanceLink:null};return V[ie.id]=oe,oe}else return V[ie.id]}).filter(ie=>!!ie);if(M=await this.executeFullFunctionDeclarationLogic(i.body,de,e),(M.results||[]).forEach(ie=>{var X,ce,oe,me;if(ie.valueOwner.type!==d.InputMap||At.includes(ie.valueOwner.parent.type))return;const se=i.body.inputs.find(ve=>le(ve,a)===le(ie.valueOwner,a)),z=[...((ce=(X=V==null?void 0:V[se.id])==null?void 0:X.value)==null?void 0:ce.value)||[],((oe=ie==null?void 0:ie.value)==null?void 0:oe.value)||null];(me=V[se.id].value)==null||me.metaSync({value:z},null),this.lastExecutionResults.writeValue(se,V[se.id].value)}),[U.CaughtError,U.Break,U.Return].includes(M.value))break;ee++}break}case ne.loop["manual-flow-loop"].id:{let re=1;for(;re<=50;){const ee=i.body.inputs.map(de=>{if(de===i.currentIterationNumberArgumentDeclaration){const ie=this.lastExecutionResults.readValue(de.id);if(ie){ie.metaSync({value:re},null),this.lastExecutionResults.writeValue(de,ie);const X={value:ie,valueOwner:de,type:Me.ExecutionResult,inheritanceLink:null};return V[de.id]=X,X}const se=i.currentIterationNumberArgumentDeclaration.getDataType(null),ue=Nt(se,de,a);return ue==null||ue.metaSync({value:re},null),this.lastExecutionResults.writeValue(de,ue),{value:ue,valueOwner:de,type:Me.ExecutionResult,inheritanceLink:null}}else return V[de.id]}).filter(de=>!!de);if(M=await this.executeFullFunctionDeclarationLogic(i.body,ee,e),(M.results||[]).forEach(de=>{var z,X,ce;if(de.valueOwner.type!==d.InputMap||At.includes(de.valueOwner.parent.type))return;const ie=i.body.inputs.find(oe=>le(oe,a)===le(de.valueOwner,a)),ue=[...(z=V[ie.id].value)==null?void 0:z.value,((X=de.value)==null?void 0:X.value)||null];(ce=V[ie.id].value)==null||ce.metaSync({value:ue},null),this.lastExecutionResults.writeValue(ie,V[ie.id].value)}),[U.CaughtError,U.Break,U.Return].includes(M.value))break;re++}break}case ne.loop["list-loop"].id:{const re=N[0];let ee=1;const de=re;for(let ie=0;ie<de.length;ie++){const se=de[ie],ue=i.body.inputs.map(z=>{if(z===i.currentIterationNumberArgumentDeclaration){const X=this.lastExecutionResults.readValue(z.id);if(X)return X.metaSync({value:ee},null),this.lastExecutionResults.writeValue(z,X),{value:X,valueOwner:z,type:Me.ExecutionResult,inheritanceLink:null};const ce=i.currentIterationNumberArgumentDeclaration.getDataType(null),oe=Nt(ce,z,a);return oe==null||oe.metaSync({value:ee},null),this.lastExecutionResults.writeValue(z,oe),{value:oe,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Me.ExecutionResult,inheritanceLink:null}}else if(z===i.currentValueArgumentDeclaration){const X=i.currentValueArgumentDeclaration.getDataType(null),ce=rf(X),oe=this.lastExecutionResults.readValue(z.id);if(oe)return oe.metaSync({value:se},null),this.lastExecutionResults.writeValue(z,oe),{value:oe,valueOwner:z,type:Me.ExecutionResult,inheritanceLink:null};const me={id:x.UUID.uuid(),deletable:!0,editable:!0,type:d.LiteralValue,autogeneration:null,version:x.UUID.uuid(),createdAt:new Date().toISOString(),author:x.sessionAuthor,deleted:!1,previousVersion:null,value:se,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:ce,standaloneParent:z.toReference()},ve=tr(me,a);return this.lastExecutionResults.writeValue(z,ve),{value:ve,valueOwner:i.currentValueArgumentDeclaration,type:Me.ExecutionResult,inheritanceLink:null}}else return V[z.id]}).filter(z=>!!z);if(M=await this.executeFullFunctionDeclarationLogic(i.body,ue,e),(M.results||[]).forEach(z=>{var me,ve,we;if(z.valueOwner.type!==d.InputMap||At.includes(z.valueOwner.parent.type))return;const X=i.body.inputs.find(Re=>le(Re,a)===le(z.valueOwner,a)),oe=[...(me=V[X.id].value)==null?void 0:me.value,((ve=z.value)==null?void 0:ve.value)||null];(we=V[X.id].value)==null||we.metaSync({value:oe},null),this.lastExecutionResults.writeValue(X,V[X.id].value)}),[U.CaughtError,U.Break,U.Return].includes(M.value))break;ee++}break}case ne.loop["object-keys-loop"].id:{const re=N[0];let ee=1;const de=re?Object.keys(re):[];for(let ie=0;ie<de.length;ie++){const se=de[ie],ue=i.body.inputs.map(z=>{if(z===i.currentIterationNumberArgumentDeclaration){const X=this.lastExecutionResults.readValue(z.id);if(X)return X.metaSync({value:ee},null),this.lastExecutionResults.writeValue(z,X),{value:X,valueOwner:z,type:Me.ExecutionResult,inheritanceLink:null};const ce=i.currentIterationNumberArgumentDeclaration.getDataType(null),oe=Nt(ce,z,a);return oe==null||oe.metaSync({value:ee},null),this.lastExecutionResults.writeValue(z,oe),{value:oe,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Me.ExecutionResult,inheritanceLink:null}}else if(z===i.currentValueArgumentDeclaration){const X=i.currentValueArgumentDeclaration.getDataType(null),ce=rf(X),oe=this.lastExecutionResults.readValue(z.id);if(oe)return oe.metaSync({value:se},null),this.lastExecutionResults.writeValue(z,oe),{value:oe,valueOwner:z,type:Me.ExecutionResult,inheritanceLink:null};const me={id:x.UUID.uuid(),deletable:!0,editable:!0,type:d.LiteralValue,autogeneration:null,version:x.UUID.uuid(),createdAt:new Date().toISOString(),author:x.sessionAuthor,deleted:!1,previousVersion:null,value:se,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:ce,standaloneParent:z.toReference()},ve=tr(me,a);return this.lastExecutionResults.writeValue(z,ve),{value:ve,valueOwner:i.currentValueArgumentDeclaration,type:Me.ExecutionResult,inheritanceLink:null}}else return V[z.id]}).filter(z=>!!z);if(M=await this.executeFullFunctionDeclarationLogic(i.body,ue,e),(M.results||[]).forEach(z=>{var me,ve,we;if(z.valueOwner.type!==d.InputMap||At.includes(z.valueOwner.parent.type))return;const X=i.body.inputs.find(Re=>le(Re,a)===le(z.valueOwner,a)),oe=[...(me=V[X.id].value)==null?void 0:me.value,((ve=z.value)==null?void 0:ve.value)||null];(we=V[X.id].value)==null||we.metaSync({value:oe},null),this.lastExecutionResults.writeValue(X,V[X.id].value)}),[U.CaughtError,U.Break,U.Return].includes(M.value))break;ee++}break}case ne.loop["object-values-loop"].id:{const re=N[0];let ee=1;const de=re?Object.values(re):[];for(let ie=0;ie<de.length;ie++){const se=de[ie],ue=i.body.inputs.map(z=>{if(z===i.currentIterationNumberArgumentDeclaration){const X=this.lastExecutionResults.readValue(z.id);if(X)return X.metaSync({value:ee},null),this.lastExecutionResults.writeValue(z,X),{value:X,valueOwner:z,type:Me.ExecutionResult,inheritanceLink:null};const ce=i.currentIterationNumberArgumentDeclaration.getDataType(null),oe=Nt(ce,z,a);return oe==null||oe.metaSync({value:ee},null),this.lastExecutionResults.writeValue(z,oe),{value:oe,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Me.ExecutionResult,inheritanceLink:null}}else if(z===i.currentValueArgumentDeclaration){const X=i.currentValueArgumentDeclaration.getDataType(null),ce=rf(X),oe=this.lastExecutionResults.readValue(z.id);if(oe)return oe.metaSync({value:se},null),this.lastExecutionResults.writeValue(z,oe),{value:oe,valueOwner:z,type:Me.ExecutionResult,inheritanceLink:null};const me={id:x.UUID.uuid(),deletable:!0,editable:!0,type:d.LiteralValue,autogeneration:null,version:x.UUID.uuid(),createdAt:new Date().toISOString(),author:x.sessionAuthor,deleted:!1,previousVersion:null,value:se,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:ce,standaloneParent:z.toReference()},ve=tr(me,a);return this.lastExecutionResults.writeValue(z,ve),{value:ve,valueOwner:i.currentValueArgumentDeclaration,type:Me.ExecutionResult,inheritanceLink:null}}else return V[z.id]}).filter(z=>!!z);if(M=await this.executeFullFunctionDeclarationLogic(i.body,ue,e),(M.results||[]).forEach(z=>{var me,ve,we;if(z.valueOwner.type!==d.InputMap||At.includes(z.valueOwner.parent.type))return;const X=i.body.inputs.find(Re=>le(Re,a)===le(z.valueOwner,a)),oe=[...(me=V[X.id].value)==null?void 0:me.value,((ve=z.value)==null?void 0:ve.value)||null];(we=V[X.id].value)==null||we.metaSync({value:oe},null),this.lastExecutionResults.writeValue(X,V[X.id].value)}),[U.CaughtError,U.Break,U.Return].includes(M.value))break;ee++}break}case ne.loop["string-loop"].id:{const re=N[0];let ee=1;const de=re.split("");for(let ie=0;ie<de.length;ie++){const se=de[ie],ue=i.body.inputs.map(z=>{if(z===i.currentIterationNumberArgumentDeclaration){const X=this.lastExecutionResults.readValue(z.id);if(X)return X.metaSync({value:ee},null),this.lastExecutionResults.writeValue(z,X),{value:X,valueOwner:z,type:Me.ExecutionResult,inheritanceLink:null};const ce=i.currentIterationNumberArgumentDeclaration.getDataType(null),oe=Nt(ce,z,a);return oe==null||oe.metaSync({value:ee},null),this.lastExecutionResults.writeValue(z,oe),{value:oe,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Me.ExecutionResult,inheritanceLink:null}}else if(z===i.currentValueArgumentDeclaration){const X=i.currentValueArgumentDeclaration.getDataType(null),ce=rf(X),oe=this.lastExecutionResults.readValue(z.id);if(oe)return oe.metaSync({value:se},null),this.lastExecutionResults.writeValue(z,oe),{value:oe,valueOwner:z,type:Me.ExecutionResult,inheritanceLink:null};const me={id:x.UUID.uuid(),deletable:!0,editable:!0,type:d.LiteralValue,autogeneration:null,version:x.UUID.uuid(),createdAt:new Date().toISOString(),author:x.sessionAuthor,deleted:!1,previousVersion:null,value:se,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:ce,standaloneParent:z.toReference()},ve=tr(me,a);return this.lastExecutionResults.writeValue(z,ve),{value:ve,valueOwner:i.currentValueArgumentDeclaration,type:Me.ExecutionResult,inheritanceLink:null}}else return V[z.id]}).filter(z=>!!z);if(M=await this.executeFullFunctionDeclarationLogic(i.body,ue,e),(M.results||[]).forEach(z=>{var me,ve,we;if(z.valueOwner.type!==d.InputMap||At.includes(z.valueOwner.parent.type))return;const X=i.body.inputs.find(Re=>le(Re,a)===le(z.valueOwner,a)),oe=[...(me=V[X.id].value)==null?void 0:me.value,((ve=z.value)==null?void 0:ve.value)||null];(we=V[X.id].value)==null||we.metaSync({value:oe},null),this.lastExecutionResults.writeValue(X,V[X.id].value)}),[U.CaughtError,U.Break,U.Return].includes(M.value))break;ee++}break}}if(_={value:[U.CaughtError,U.Return].includes(M.value)?M.value:U.Success,error:((h=(f=M.error)==null?void 0:f.value)==null?void 0:h.value)||null,result:((E=(m=M==null?void 0:M.result)==null?void 0:m.value)==null?void 0:E.value)||null},_.error&&i.error){const re=(b=i.error)==null?void 0:b.getDataType(null),ee=Nt(re||null,i.error,a);re!=null&&re.asType?ee==null||ee.setValueAsTypeSingle(_.error):ee==null||ee.metaSync({value:_.error},null);const de={valueOwner:i.error,type:Me.ExecutionResult,inheritanceLink:null,value:ee};return{value:_.value,entity:i,error:de,result:null}}const G=i==null?void 0:i.getDataType(null),q=Nt(G,i,a);return G!=null&&G.asType?q==null||q.setValueAsTypeSingle(_.result):q==null||q.metaSync({value:_.result},null),{value:_.value,entity:i,error:null,result:{value:q||null,valueOwner:i,type:Me.ExecutionResult,inheritanceLink:null}}}catch(_){if(Y.Logger.warn("Error executing loop: ",_),i.error){const N=(A=i.error)==null?void 0:A.getDataType(null),V=Nt(N,i.error,a);return N!=null&&N.asType?V==null||V.setValueAsTypeSingle(_):V==null||V.metaSync({value:_},null),{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,entity:i,error:{valueOwner:i.error,type:Me.ExecutionResult,inheritanceLink:null,value:V},result:null}}else return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,entity:i,error:null,result:null}}}async executeFunctionCall(i,r,a,c={}){var f,h,m,E,b,A,_,N,V,j,M,G,q,re,ee,de,ie,se,ue,z,X,ce,oe,me,ve,we;const e={...Yu,...c};try{const Re=await this.executeDetachedFullFunctionDeclarationLogic(i.declaration,r,a,e);let xe=null;if(Re.error&&i.error){Y.Logger.warn("Raw error executing entity: ",Re.error);const Ze=(f=i.error)==null?void 0:f.getDataType(null),Xe=Nt(Ze||null,i.error,a);Ze!=null&&Ze.asType?(m=(h=Re.error)==null?void 0:h.value)!=null&&m.valueAsTypeSingle?Xe==null||Xe.setValueAsTypeSingle((b=(E=Re.error)==null?void 0:E.value)==null?void 0:b.valueAsTypeSingle):(_=(A=Re.error)==null?void 0:A.value)!=null&&_.valueAsTypeList&&Array.isArray((V=(N=Re.error)==null?void 0:N.value)==null?void 0:V.valueAsTypeList)&&(Xe==null||Xe.setValueAsTypeList((M=(j=Re.error)==null?void 0:j.value)==null?void 0:M.valueAsTypeList)):Xe==null||Xe.metaSync({value:(q=(G=Re.error)==null?void 0:G.value)==null?void 0:q.value},null),xe={valueOwner:i.error,type:Me.ExecutionResult,inheritanceLink:null,value:Xe}}let je=U.Success;Re.value===U.UnhandledError&&(i.catchesError||i.errorCalls.length?je=U.CaughtError:je=U.UnhandledError);const Se=i==null?void 0:i.getDataType(null),et=Nt(Se,i,a);return Se!=null&&Se.asType?(ee=(re=Re.result)==null?void 0:re.value)!=null&&ee.valueAsTypeSingle?et==null||et.setValueAsTypeSingle((ie=(de=Re.result)==null?void 0:de.value)==null?void 0:ie.valueAsTypeSingle):(ue=(se=Re.result)==null?void 0:se.value)!=null&&ue.valueAsTypeList&&Array.isArray((X=(z=Re.result)==null?void 0:z.value)==null?void 0:X.valueAsTypeList)&&(et==null||et.setValueAsTypeList((oe=(ce=Re.result)==null?void 0:ce.value)==null?void 0:oe.valueAsTypeList)):et==null||et.metaSync({value:((ve=(me=Re.result)==null?void 0:me.value)==null?void 0:ve.value)||null},null),{value:je,entity:i,error:xe,result:{value:et||null,valueOwner:i,type:Me.ExecutionResult,inheritanceLink:null}}}catch(Re){if(!i.error)return{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,entity:i,error:null,result:null};const xe=(we=i.error)==null?void 0:we.getDataType(null),je=Nt(xe,i.error,a);return xe!=null&&xe.asType?je==null||je.setValueAsTypeSingle(Re):je==null||je.metaSync({value:Re},null),{value:i.catchesError||i.errorCalls.length?U.CaughtError:U.UnhandledError,entity:i,error:{valueOwner:i.error,type:Me.ExecutionResult,inheritanceLink:null,value:je},result:null}}}async executeCondition(i,r){var c,e,f,h;let a=!1;switch(i.declaration.id){case hn.BooleanIsTrue:{const m=(e=(c=r[0])==null?void 0:c.value)==null?void 0:e.value;if(typeof m!="boolean")throw new TypeError("BooleanIsTrue expects a boolean input.");a=m===!0;break}case hn.BooleanIsFalse:{const m=(h=(f=r[0])==null?void 0:f.value)==null?void 0:h.value;if(typeof m!="boolean")throw new TypeError("BooleanIsFalse expects a boolean input.");a=m===!1;break}case Dr.And:{a=(await Promise.all(i.andChildrenGroup.map(async E=>{const b=this.mergeExernalValuesWithInternalInputs(r,E);return(await this.executeCondition(E,b)).value===U.Success}))).every(E=>E);break}case Dr.Or:{a=(await Promise.all(i.orChildrenGroup.map(async E=>{const b=this.mergeExernalValuesWithInternalInputs(r,E);return(await this.executeCondition(E,b)).value===U.Success}))).some(E=>E);break}default:throw new Error(`Condition declaration ${i.declaration.name} does not have an implementation.`)}return{value:a?U.Success:U.ConditionNotMet,entity:i,error:null,result:null}}async executeDetachedFullFunctionDeclarationLogic(i,r,a,c={}){const e={...Yu,...c,onBeforeEntityExecution:(m,E,b)=>{var A;return((A=c==null?void 0:c.onBeforeEntityExecution)==null?void 0:A.call(c,m,E,{...b,detached:!0}))||Promise.resolve()},onEntityExecuted:(m,E,b)=>{var A;return((A=c==null?void 0:c.onEntityExecuted)==null?void 0:A.call(c,m,E,{...b,detached:!0}))||Promise.resolve()}},f=new th(a,[i,...SI(i)],i,this,this.parentContext);return f.inheritValuesFromContext(this),await f.execute(e,r)}async executeFullFunctionDeclarationLogic(i,r,a={}){const c={...Yu,...a},e=SI(i);e.forEach(m=>{this.addEntity(m)}),e.reduce((m,E)=>At.includes(E.type)?[...m,...E.outputs]:wt.includes(E.type)&&E.type!==d.Condition?[...m,...E.outputs,...E.inputs]:E.type===d.Condition?[...m,...E.inputs]:m,[]).forEach(m=>{this.lastExecutionResults.removeValue(m.id)});const h=await this.executeBranch(i,c,r);return{...h||{},value:(h==null?void 0:h.value)||U.Success,entity:i,error:(h==null?void 0:h.error)||null,result:(h==null?void 0:h.result)||null}}static async executeEntryPointEntity(i,r){return{value:U.Success,entity:i,error:null,result:null}}async executeReturnStatement(i,r){var f,h,m,E,b,A,_;if((f=i.throws)!=null&&f.readsValue){const N=Yo(i.throws,this.valueResolutionContext);return{value:U.UnhandledError,entity:i,error:{valueOwner:i.throws,type:Me.ExecutionResult,inheritanceLink:null,value:(N==null?void 0:N.value)||null},result:null}}let a=Yo(i,this.valueResolutionContext);const c=i.getDataType(null);if(c!=null&&c.isObject()){let N={};if(((h=c==null?void 0:c.entity)==null?void 0:h.type)===d.DefinitionEntity&&(N={...N,...c.entity.getActiveRawDefaultValue()}),a!=null&&a.value)Rr((m=a==null?void 0:a.value)==null?void 0:m.value)&&(N={...N,...(E=a==null?void 0:a.value)==null?void 0:E.value}),a==null||a.value.metaSync({value:N},null);else{const V=Nt(c,i,this.project);V==null||V.metaSync({value:N},null),a={valueOwner:i,type:Me.ExecutionResult,inheritanceLink:null,value:V}}this.lastExecutionResults.writeValue(i,a.value),i.outputs.forEach(V=>{var j,M;if(((j=V.declaration)==null?void 0:j.type)===d.Property&&V.declaration.static){const G=this.lastExecutionResults.readValue(V.declaration.id),q=le(V,this.project),re=V.codeName||((M=V.declaration)==null?void 0:M.codeName)||Qi(q);if(G)G.metaSync({value:N[re]},null),this.lastExecutionResults.writeValue(V.declaration,G);else{const ee=Nt(V.getDataType(null),V,this.project);ee==null||ee.metaSync({value:N[re]},null),this.lastExecutionResults.writeValue(V.declaration,ee)}}})}else this.lastExecutionResults.writeValue(i,a==null?void 0:a.value);const e=(b=a==null?void 0:a.value)!=null&&b.value&&Rr((A=a.value)==null?void 0:A.value)?((_=a.value)==null?void 0:_.value)||{}:{};return i.outputs.map(N=>{var G;const V=N.codeName||((G=N.declaration)==null?void 0:G.codeName)||Qi(le(N,this.project)),j=e[V],M=Nt(N.getDataType(null),N,this.project);M==null||M.metaSync({value:j},null),Me.ExecutionResult}),a.type=Me.ExecutionResult,{value:U.Return,entity:i,error:null,result:a}}async executeContinueStatement(i,r){var f,h,m,E,b,A,_;if((f=i.throws)!=null&&f.readsValue){const N=Yo(i.throws,this.valueResolutionContext);return{value:U.UnhandledError,entity:i,error:{valueOwner:i.throws,type:Me.ExecutionResult,inheritanceLink:null,value:(N==null?void 0:N.value)||null},result:null}}let a=Yo(i,this.valueResolutionContext);const c=i.getDataType(null);if(c!=null&&c.isObject()){let N={};if(((h=c==null?void 0:c.entity)==null?void 0:h.type)===d.DefinitionEntity&&(N={...N,...c.entity.getActiveRawDefaultValue()}),a!=null&&a.value)Rr((m=a==null?void 0:a.value)==null?void 0:m.value)&&(N={...N,...(E=a==null?void 0:a.value)==null?void 0:E.value}),a==null||a.value.metaSync({value:N},null);else{const V=Nt(c,i,this.project);V==null||V.metaSync({value:N},null),a={valueOwner:i,type:Me.ExecutionResult,inheritanceLink:null,value:V}}this.lastExecutionResults.writeValue(i,a.value),i.outputs.forEach(V=>{var j,M;if(((j=V.declaration)==null?void 0:j.type)===d.Property&&V.declaration.static){const G=this.lastExecutionResults.readValue(V.declaration.id),q=le(V,this.project),re=V.codeName||((M=V.declaration)==null?void 0:M.codeName)||Qi(q);if(G)G.metaSync({value:N[re]},null),this.lastExecutionResults.writeValue(V.declaration,G);else{const ee=Nt(V.getDataType(null),V,this.project);ee==null||ee.metaSync({value:N[re]},null),this.lastExecutionResults.writeValue(V.declaration,ee)}}})}else this.lastExecutionResults.writeValue(i,a==null?void 0:a.value);const e=(b=a==null?void 0:a.value)!=null&&b.value&&Rr((A=a.value)==null?void 0:A.value)?((_=a.value)==null?void 0:_.value)||{}:{};return i.outputs.map(N=>{var G;const V=N.codeName||((G=N.declaration)==null?void 0:G.codeName)||Qi(le(N,this.project)),j=e[V],M=Nt(N.getDataType(null),N,this.project);M==null||M.metaSync({value:j},null),Me.ExecutionResult}),a.type=Me.ExecutionResult,{value:U.Continue,entity:i,error:null,result:a}}async executeBreakStatement(i,r){var f,h,m,E,b,A,_;if((f=i.throws)!=null&&f.readsValue){const N=Yo(i.throws,this.valueResolutionContext);return{value:U.UnhandledError,entity:i,error:{valueOwner:i.throws,type:Me.ExecutionResult,inheritanceLink:null,value:(N==null?void 0:N.value)||null},result:null}}let a=Yo(i,this.valueResolutionContext);const c=i.getDataType(null);if(c!=null&&c.isObject()){let N={};if(((h=c==null?void 0:c.entity)==null?void 0:h.type)===d.DefinitionEntity&&(N={...N,...c.entity.getActiveRawDefaultValue()}),a!=null&&a.value)Rr((m=a==null?void 0:a.value)==null?void 0:m.value)&&(N={...N,...(E=a==null?void 0:a.value)==null?void 0:E.value}),a==null||a.value.metaSync({value:N},null);else{const V=Nt(c,i,this.project);V==null||V.metaSync({value:N},null),a={valueOwner:i,type:Me.ExecutionResult,inheritanceLink:null,value:V}}this.lastExecutionResults.writeValue(i,a.value),i.outputs.forEach(V=>{var j,M;if(((j=V.declaration)==null?void 0:j.type)===d.Property&&V.declaration.static){const G=this.lastExecutionResults.readValue(V.declaration.id),q=le(V,this.project),re=V.codeName||((M=V.declaration)==null?void 0:M.codeName)||Qi(q);if(G)G.metaSync({value:N[re]},null),this.lastExecutionResults.writeValue(V.declaration,G);else{const ee=Nt(V.getDataType(null),V,this.project);ee==null||ee.metaSync({value:N[re]},null),this.lastExecutionResults.writeValue(V.declaration,ee)}}})}else this.lastExecutionResults.writeValue(i,a==null?void 0:a.value);const e=(b=a==null?void 0:a.value)!=null&&b.value&&Rr((A=a.value)==null?void 0:A.value)?((_=a.value)==null?void 0:_.value)||{}:{};return i.outputs.map(N=>{var G;const V=N.codeName||((G=N.declaration)==null?void 0:G.codeName)||Qi(le(N,this.project)),j=e[V],M=Nt(N.getDataType(null),N,this.project);M==null||M.metaSync({value:j},null),Me.ExecutionResult}),a.type=Me.ExecutionResult,{value:U.Break,entity:i,error:null,result:a}}async executeVariable(i,r){var h,m,E,b,A,_;let a=Yo(i,this.valueResolutionContext);const c=Tr(i),e=c.getDataType(null);if(e!=null&&e.isObject()){let N={};if(((h=e==null?void 0:e.entity)==null?void 0:h.type)===d.DefinitionEntity&&(N={...N,...e.entity.getActiveRawDefaultValue()}),a!=null&&a.value)Rr((m=a==null?void 0:a.value)==null?void 0:m.value)&&(N={...N,...(E=a==null?void 0:a.value)==null?void 0:E.value}),a==null||a.value.metaSync({value:N},null);else{const V=Nt(e,i,this.project);V==null||V.metaSync({value:N},null),a={valueOwner:c,type:Me.ExecutionResult,inheritanceLink:null,value:V}}this.lastExecutionResults.writeValue(c,a.value),c.inputs.forEach(V=>{var j,M;if(((j=V.declaration)==null?void 0:j.type)===d.Property&&V.declaration.static){const G=this.lastExecutionResults.readValue(V.declaration.id),q=le(V,this.project),re=V.codeName||((M=V.declaration)==null?void 0:M.codeName)||Qi(q);if(G)G.metaSync({value:N[re]},null),this.lastExecutionResults.writeValue(V.declaration,G);else{const ee=Nt(V.getDataType(null),V,this.project);ee==null||ee.metaSync({value:N[re]},null),this.lastExecutionResults.writeValue(V.declaration,ee)}}})}else this.lastExecutionResults.writeValue(c,a==null?void 0:a.value);const f=(b=a==null?void 0:a.value)!=null&&b.value&&Rr((A=a.value)==null?void 0:A.value)?((_=a.value)==null?void 0:_.value)||{}:{};return i.outputs.map(N=>{var G;const V=N.codeName||((G=N.declaration)==null?void 0:G.codeName)||Qi(le(N,this.project)),j=f[V],M=Nt(N.getDataType(null),N,this.project);M==null||M.metaSync({value:j},null),Me.ExecutionResult}),a.type=Me.ExecutionResult,{value:U.Success,entity:i,error:null,result:a}}mergeValues(i,r){const a=[];for(let c=0;c<r.length;c++)i!=null&&i[c]?a.push(i[c]):a.push(r[c]);return a}async executeEntity(i,r=[],a={}){var f,h,m,E,b,A,_,N,V,j,M;const c={...Yu,...a},e={detached:!1};switch(i.type){case d.Condition:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await((f=c.onBeforeEntityExecution)==null?void 0:f.call(c,i,G,e)),this.executeCondition(i,G)}case d.InternalCall:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await((h=c.onBeforeEntityExecution)==null?void 0:h.call(c,i,G,e)),this.executeInternalCall(i,G,this.project)}case d.Operation:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await((m=c.onBeforeEntityExecution)==null?void 0:m.call(c,i,G,e)),th.executeOperation(i,G,this.project)}case d.VariableInstance:case d.VariableDeclaration:return this.executeVariable(i,r);case d.FunctionCall:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await((E=c.onBeforeEntityExecution)==null?void 0:E.call(c,i,G,e)),this.executeFunctionCall(i,G,this.project)}case d.FunctionDeclaration:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await((b=c.onBeforeEntityExecution)==null?void 0:b.call(c,i,G,e)),th.executeEntryPointEntity(i,G)}case d.Search:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await((A=c.onBeforeEntityExecution)==null?void 0:A.call(c,i,G,e)),this.executeSearch(i,G,this.project)}case d.Loop:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await((_=c.onBeforeEntityExecution)==null?void 0:_.call(c,i,G,e)),this.executeLoop(i,G,this.project,c)}case d.ReturnStatement:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await((N=c.onBeforeEntityExecution)==null?void 0:N.call(c,i,G,e)),this.executeReturnStatement(i,G)}case d.ContinueStatement:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await((V=c.onBeforeEntityExecution)==null?void 0:V.call(c,i,G,e)),this.executeContinueStatement(i,G)}case d.BreakStatement:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await((j=c.onBeforeEntityExecution)==null?void 0:j.call(c,i,G,e)),this.executeBreakStatement(i,G)}case d.GlobalEvent:{const G=this.mergeExernalValuesWithInternalInputs(r,i);return await((M=c.onBeforeEntityExecution)==null?void 0:M.call(c,i,G,e)),th.executeEntryPointEntity(i,G)}default:throw new Error(`Entity type ${i==null?void 0:i.type} is not recognized for execution.`)}}storeLastExecutionValues(i){var a,c,e;if(i.error&&i.error.valueOwner&&this.lastExecutionResults.writeValue(i.error.valueOwner,i.error.value),!i.result||!((a=i.result)!=null&&a.valueOwner))return;const r=id((c=i.result)==null?void 0:c.valueOwner,this.project);(e=i.result)!=null&&e.value?r.forEach(f=>{var h;this.lastExecutionResults.writeValue(f,(h=i.result)==null?void 0:h.value)}):r.forEach(f=>{this.lastExecutionResults.removeValue(f.id)})}async executeBranch(i,r={},a=[]){var m;const c={...Yu,...r},e={detached:!1};if(!this.hasEntity(i)||this.hasSkipped(i))return null;this.addToExecutingList(i),this.hasScheduled(i)&&this.removeScheduled(i);const h=await this.executeEntity(i,a,c);if(this.removeFromExecutingList(i),this.addToAlreadyExecutedList(i),this.storeLastExecutionValues(h),await((m=c.onEntityExecuted)==null?void 0:m.call(c,i,h,e)),h.value===U.Success){const E=(i.successCalls||i.calls||[]).filter(V=>this.hasEntity(V));(i.errorCalls||[]).forEach(V=>{this.skip(V)});let A=[];const _=(await Promise.all(E.map(V=>this.schedule(V,[],c)))).filter(V=>!!V),N=_.filter(V=>!!V).find(V=>V.value===U.CaughtError||V.value===U.Return||V.value===U.Break||V.value===U.Continue);return N||(A=[...A,..._],h)}else if(h.value===U.CaughtError||h.value===U.ConditionNotMet){const E=(i.errorCalls||[]).filter(V=>this.hasEntity(V));(i.successCalls||i.calls||[]).forEach(V=>{this.skip(V)});let A=[];const _=(await Promise.all(E.map(V=>this.schedule(V,[],c)))).filter(V=>!!V),N=_.filter(V=>!!V).find(V=>V.value===U.CaughtError||V.value===U.UnhandledError||V.value===U.Return||V.value===U.Break||V.value===U.Continue);return N||(A=[...A,..._],h)}else{if(h.value===U.UnhandledError)return this.executing.forEach(E=>{this.skip(E)}),this.scheduled.forEach(E=>{this.skip(E)}),Wi.includes(h.entity.type)&&pt(h.entity).forEach(E=>{this.skip(E)}),h;if(h.value===U.Return)return h;if(h.value===U.Break)return h;if(h.value===U.Continue)return h}return h}async execute(i={},r=[]){const a={...Yu,...i};this.state="running";const c=await this.executeBranch(this.entryPoint,a,r);return this.state="finished-success",c}addEntity(i){var r;this.entities.includes(i)||(this.entities.push(i),(r=this.onAddEntityCallback)==null||r.call(this,i,{}))}async addEntityAsync(i,r={}){var a;this.entities.includes(i)||(this.entities.push(i),await((a=this.onAddEntityCallback)==null?void 0:a.call(this,i,r)))}addEntities(i){i.forEach(r=>this.addEntity(r))}async addEntitiesAsync(i,r={}){const a=Y.YieldTracker.from(r),c=[];for(const e of i)c.push(this.addEntityAsync(e,r)),await a.tick();await Promise.all(c)}removeEntity(i){var r;if(i!==this.entryPoint){const a=this.entities.indexOf(i);a>-1&&(this.entities.splice(a,1),(r=this.onRemoveEntityCallback)==null||r.call(this,i,{}))}}hasEntity(i){var c,e,f;if(this.entities.includes(i))return!0;if(((c=i.parent)==null?void 0:c.type)===d.FunctionDeclaration&&((f=(e=i.parent)==null?void 0:e.parent)==null?void 0:f.type)===d.DefinitionEntity)return this.entities.includes(i.parent);const r=yt(i);if(!r)return!1;const a=r.type===d.Loop&&i.parent===r.body?r.body:null;return a?this.entities.includes(a)||this.entities.includes(r):this.entities.includes(r)}removeScheduled(i){const r=this.scheduled.indexOf(i);r>-1&&this.scheduled.splice(r,1)}hasScheduled(i){return!!this.scheduled.includes(i)}hasSkipped(i){return!!this.skipped.includes(i)}hasExecuted(i){return!!this.executed.includes(i)}hasEntityWithId(i){const r=this.project.get(i);return r?this.hasEntity(r):!1}onAddToSkippedList(i){this.onAddToSkippedListCallback=i}onAbortExecution(i){this.onAbortExecutionCallback=i}onAddEntity(i){this.onAddEntityCallback=i}onRemoveFromSkippedList(i){this.onRemoveFromSkippedListCallback=i}onRemoveEntity(i){this.onRemoveEntityCallback=i}addToExecutingList(i){this.executing.includes(i)||this.executing.push(i)}addToScheduledList(i){this.scheduled.includes(i)||this.scheduled.push(i)}removeFromScheduledList(i){const r=this.scheduled.indexOf(i);r>-1&&this.scheduled.splice(r,1)}removeFromExecutingList(i){var a;const r=this.executing.indexOf(i);r>-1&&(this.executing.splice(r,1),(a=this.onAbortExecutionCallback)==null||a.call(this,i,{}))}removeFromAlreadyExecutedList(i){const r=this.executed.indexOf(i);r>-1&&this.executed.splice(r,1)}removeFromSkippedList(i){var a;const r=this.skipped.indexOf(i);r>-1&&(this.skipped.splice(r,1),(a=this.onRemoveFromSkippedListCallback)==null||a.call(this,i,{}))}addToAlreadyExecutedList(i){this.executed.includes(i)||this.executed.push(i)}addToSkippedList(i){var r;this.skipped.includes(i)||(this.skipped.push(i),(r=this.onAddToSkippedListCallback)==null||r.call(this,i,{}))}getValueTypePreference(i){return this.parentContext.getValueTypePreference(i)||null}setValueTypePreference(i,r){this.parentContext.setValueTypePreference(i,r),this.emit(i,{})}}function rRi(l){var p,i;if(l.isList)return"list";if(((p=l.entity)==null?void 0:p.type)===d.DefinitionEntity)return"definition-entity";switch((i=l.entity)==null?void 0:i.name){case fe.Number:return"number";case fe.String:return"text";case fe.Boolean:return"boolean";case fe.UUID:return"uuid";case fe.Date:return"date-time";default:return"definition-entity"}}const is={[d.PrimitiveEntity]:{singular:"Primitive",plural:"Primitives",shortSingular:"Primitive",shortPlural:"Primitives"},[d.DefinitionEntity]:{singular:"Definition",plural:"Definitions",shortSingular:"Definition",shortPlural:"Definitions"},[d.BuiltInBaseEntity]:{singular:"Base",plural:"Bases",shortSingular:"Base definition",shortPlural:"Base definitions"},[d.Property]:{singular:"Property",plural:"Properties",shortSingular:"Property",shortPlural:"Properties"},[d.FunctionDeclaration]:{singular:"Custom trigger",plural:"Custom triggers",shortSingular:"Trigger",shortPlural:"Triggers"},[d.FunctionCall]:{singular:"Execute trigger",plural:"Execute trigger",shortSingular:"Execute",shortPlural:"Execute"},[d.GlobalEvent]:{singular:"System trigger",plural:"System triggers",shortSingular:"Trigger",shortPlural:"Triggers"},[d.Project]:{singular:"Project",plural:"Projects",shortSingular:"Project",shortPlural:"Projects"},[d.VariableDeclaration]:{singular:"Variable",plural:"Variables",shortSingular:"Variable",shortPlural:"Variables"},[d.VariableInstance]:{singular:"Variable",plural:"Variables",shortSingular:"Variable",shortPlural:"Variables"},[d.Condition]:{singular:"Condition",plural:"Conditions",shortSingular:"Condition",shortPlural:"Conditions"},[d.Operation]:{singular:"Operation",plural:"Operations",shortSingular:"Operation",shortPlural:"Operations"},[d.ReturnStatement]:{singular:"Termination",plural:"Terminations",shortSingular:"Termination",shortPlural:"Terminations"},[d.InstalledProject]:{singular:"Installed project",plural:"Installed projects",shortSingular:"Project",shortPlural:"Projects"},[d.Search]:{singular:"Search",plural:"Searches",shortSingular:"Search",shortPlural:"Searches"},[d.Loop]:{singular:"Loop",plural:"Loops",shortSingular:"Loop",shortPlural:"Loops"},[d.ActionDescriptor]:{singular:"Action descriptor",plural:"Action descriptors",shortSingular:"Action descriptor",shortPlural:"Action descriptors"},[d.InternalCall]:{singular:"Internal call",plural:"Internal calls",shortSingular:"Internal call",shortPlural:"Internal calls"},[d.BreakStatement]:{singular:"Loop exit",plural:"Loop exists",shortSingular:"Exit",shortPlural:"Exits"},[d.ContinueStatement]:{singular:"Next iteration",plural:"Next iterations",shortSingular:"Next",shortPlural:"Nexts"},[d.ArgumentDeclaration]:{singular:"Input definition",plural:"Input definitions",shortSingular:"Input",shortPlural:"Inputs"},[d.InputMap]:{singular:"Input",plural:"Inputs",shortSingular:"Input",shortPlural:"Inputs"},[d.OutputMap]:{singular:"Output",plural:"Outputs",shortSingular:"Output",shortPlural:"Outputs"},[d.ValueDescriptor]:{singular:"Value descriptor",plural:"Value descriptors",shortSingular:"Value descriptor",shortPlural:"Value descriptors"},[d.DataType]:{singular:"Data type",plural:"Data types",shortSingular:"Data type",shortPlural:"Data types"},[d.LiteralValue]:{singular:"Literal value",plural:"Literal values",shortSingular:"Value",shortPlural:"Values"}};function Xx(l){const p=tD(l);if(!p){const r=Dh(l);if(r.includes(Ie.HTTP_ENDPOINT))return"HTTP endpoint";if(r.includes(Ie.PERSISTED_ENTITY))return"Persisted entity";if(r.includes(Ie.CRON_JOB))return"Scheduled execution";if(r.includes(Ie.RELATIONAL_DATABASE))return"Relational database"}if(p){let r="Extension of "+le(p,p.project)+" entity",a=Ps(r);const c=Dh(l);return c.includes(Ie.HTTP_ENDPOINT)?"HTTP endpoint"+(a?", "+a:""):c.includes(Ie.PERSISTED_ENTITY)?"Persisted entity"+(a?", "+a:""):c.includes(Ie.CRON_JOB)?"Scheduled execution"+(a?", "+a:""):c.includes(Ie.RELATIONAL_DATABASE)?"Relational database"+(a?", "+a:""):r}let i="";return l.abstract&&(i="Template "),l.static&&(i+=i?" single copy ":"Single copy "),i?i+"definition":"Definition"}function IBe(l){return l.parent.type===d.DefinitionEntity||l.parent.type===d.InstalledProject?"Internal action of "+le(l.parent,l.project):l.parent.type===d.Loop?"Action repeated on every iteration":"Internal action of entity"}function e$(l){return bL(l)?IBe(l):"Custom trigger"}function nRi(l){var p;switch(l.type){case d.DefinitionEntity:return Xx(l);case d.FunctionDeclaration:return e$(l)}return(p=is[l.type])==null?void 0:p.singular}function aRi(l){var p;switch(l.type){case d.DefinitionEntity:return Xx(l);case d.FunctionDeclaration:return e$(l)}return(p=is[l.type])==null?void 0:p.singular}const t$=4e4,i$=280,sRi=300,r$=65,of=32,nh=39,HT=26,gBe=49,WT=44,lRi=35,rI=52,v1=10,Na=v1*2,ap=38,nI=90,OI=270,RBe=t$/2+120,DBe=t$/2+180;function n$(l){let i=of+WT+ap+v1;const r=[...l.inputs];return r.length&&(i+=Na,r.forEach(()=>{i+=HT})),{height:i,width:280}}function zT(l){var a,c;let i=of+WT+ap+v1;const r=[...l.inputs];return r.length&&(i+=Na,r.forEach(()=>{i+=HT})),l.andChildrenGroup&&(i+=Na,l.andChildrenGroup.forEach(e=>{i+=zT(e).height})),l.orChildrenGroup&&(i+=Na,l.orChildrenGroup.forEach(e=>{i+=zT(e).height})),(((a=l.declaration)==null?void 0:a.id)===ne.condition["condition-group-and"].id||((c=l.declaration)==null?void 0:c.id)===ne.condition["condition-group-or"].id)&&(i+=ap),{height:i,width:280}}function wBe(l){var h,m;let i=r$;const r=[];if([d.DefinitionEntity].includes(l.type)){const E=[...l.suggestedProperties||[],...l.properties||[]];E.length&&(i+=Na,E.forEach(b=>{i+=b.static?gBe:nh}))}if([d.DefinitionEntity,d.InstalledProject,d.Loop].includes(l.type)){const E=[...(l==null?void 0:l.suggestedMethods)||[],...l.methods||[],...l.functions||[],...l.body?[l.body]:[]];E.length&&(i+=Na,E.forEach(b=>{const A=n$(b);i+=A.height}))}wt.includes(l.type)?(r.push(...(l.inputs||[]).flatMap(E=>[E])||[]),i+=Na,i+=WT,l.error&&(i+=rI)):[d.ReturnStatement,d.BreakStatement,d.ContinueStatement].includes(l.type)?(r.push(...l.outputs||[]),l.throws&&(i+=rI)):l.type===d.Condition&&(r.push(l.inputs[0]),l.inputs[1]&&r.push(l.inputs[1]),(((h=l.declaration)==null?void 0:h.id)===ne.condition["condition-group-and"].id||((m=l.declaration)==null?void 0:m.id)===ne.condition["condition-group-or"].id)&&(i+=ap),l.andChildrenGroup&&(i+=Na,l.andChildrenGroup.forEach(E=>{i+=zT(E).height})),l.orChildrenGroup&&(i+=Na,l.orChildrenGroup.forEach(E=>{i+=zT(E).height})));const a=r.length;a&&(i+=a*nh,i+=Na);const c=[];if(l.type===d.FunctionDeclaration||l.type===d.GlobalEvent?c.push(...l.inputs||[]):wt.includes(l.type)&&c.push(...l.outputs||[]),xt.includes(l.type)){i+=Na,i+=WT,l.usedInternalCalls.length&&l.usedInternalCalls.forEach(b=>{i+=rI+Na,i+=b.inputs.length*HT,i+=b.outputs.length*HT});const E=l.getDataType(null);(!E||E.canModifyObjectStructure())&&(i+=ap)}l.type===d.Search&&(i+=ap);const e=c.length;return e&&(i+=e*nh,i+=Na),[d.DefinitionEntity,d.FunctionDeclaration,d.ReturnStatement,d.BreakStatement,d.ContinueStatement].includes(l.type)&&(i+=ap),{height:i,width:280}}function CBe(l){let p=0;if(l.parent.type!==d.DefinitionEntity)return{offset:p};const i=l.parent,r=i.methods.findIndex(c=>c.id===l.id);return i.methods.slice(0,r).forEach(c=>{const e=n$(c);p+=e.height}),(i.properties.length||i.suggestedProperties.length)&&(p+=Na,i.suggestedProperties.forEach(()=>{p+=nh}),i.properties.forEach(()=>{p+=nh})),{offset:p}}function mE(l){return`${l.split("-").map((r,a)=>a===0?r.charAt(0).toUpperCase()+r.slice(1):r.toLowerCase()).join(" ")}.`}function oRi(l){switch(l.code){case be.AbstractEntityWithNonAbstractMethods:return"This template entity has non-template actions";case be.AbstractEntityWithNonAbstractProperties:return"This template entity has non-template properties";case be.IncorrectEntityImplementation:return"This entity incorrectly implements a template entity";case be.IncorrectMethodImplementation:return"This action incorrectly implements the template action it's based on";case be.IncorrectPropertyImplementation:return"This property incorrectly implements the template property it's based on";case be.AbstractMethodInNonAbstractEntity:return"This action is a template action in a non-template entity";case be.AbstractPropertyInNonAbstractEntity:return"This property is a template property in a non-template entity";case Ce.MethodOverwritesOtherSiblingWithSameName:return"An action in this entity overwrites an action in the template entity with the same name";case Ce.PropertyOverwritesOtherSiblingWithSameName:return"A property in this entity overwrites a property in the template entity with the same name";case be.MissingMethodImplementation:return"This entity is missing an action implementation from the template entity";case be.MissingPropertyImplementation:return"This entity is missing a property implementation from the template entity";case Ce.NameNotUniqueInScope:return"Invalid name. There is another entity with the same name in the same scope";case be.NoProperties:return"This entity has no properties, so it doesn't do anything";case be.NonStaticPropertyInStaticEntity:return"This property is not static in a static entity";case be.StaticEntityWithNonStaticProperties:return"This static entity has non-static properties";case be.ReadingFromIncompatibleType:return"This entity reads data from a value of a different data type";case be.WritingToIncompatibleType:return"This entity writes data to a value of a different data type";case be.ScopeWithoutLogic:return"This action has no logic, so it doesn't do anything";case be.NonStaticPropertyImplementsStatic:return"This property is static in a non-static entity";case be.PropertyImplementsIncompatibleType:return"This property implements a property of a different data type";case be.PropertyImplementsNonAbstact:return"This property implements a non-template property";case be.StaticPropertyImplementsNonStatic:return"This static property implements a non-static property";case be.VariableCallsOthersAndHasInternalCall:return"This variable calls other entities while being used to execute internal logic";case be.VariableHasInputsAndInternalCall:return"This variable has inputs while being used to execute internal logic";case be.VariableHasOutputsAndInternalCall:return"This variable has outputs while being used to execute internal logic";case be.VariableIsCalledAndHasInternalCall:return"This variable is called while being used to execute internal logic";case Ce.InternalCallDeclarationIsInvalidType:return"This internal call is not an action";case Ce.InternalCallDeclarationNotFoundInParentDatatypeEntity:return"This internal call is not found in the parent entity";case Ce.InternalCallParentDeclarationEntityInvalidType:return"This internal call parent entity is not a data type";case Ce.InternalCallParentMissingDataType:return"This internal call parent entity has no data type";case Ce.UnreachableEntity:return"This entity is unreachable";case be.DisconnectedCallableEntity:return"This entity is disconnected and won't be executed by anything after publishing";case be.AbstractEntityImplements:return"This template entity implements a non-template entity";case be.AbstractExtendingNonAbstractEntity:return"This template entity extends a non-template entity";case be.InvalidPropertiesCombination:return"This entity has an invalid combination of properties";case be.ExtendingNonInteractiveEntity:return"This entity extends a non-interactive entity";case be.ExtendsIncompatibleEntities:return"This entity extends incompatible entities";case be.ImplementingNonAbstractEntity:return"This entity implements a non-template entity";case be.ImplementsIncompatibleEntities:return"This entity implements incompatible entities";case be.LackingReturnStatementOnSomeBranches:return"This action is missing a termination on some branches";case be.LastCalledEntityMustBeReturnEntity:return"The last called entity in this action must be a termination node";case be.MissingRequiredValue:return"This action is missing a required value";case be.NoPrimaryKeyProperty:return"This entity has no primary key property";case be.NonAbstractExtendingAbstractEntity:return"This non-template entity extends a template entity";case be.NonStaticExtendingStaticEntity:return"This non-static entity extends a static entity";case be.NonStaticImplementingStaticEntity:return"This non-static entity implements a static entity";case be.StaticExtendingNonStaticEntity:return"This static entity extends a non-static entity";case be.StaticImplementingNonStaticEntity:return"This static entity implements a non-static entity";case be.VariableReadsValueAndInternalCall:return"This variable reads a value while being used to execute internal logic";case be.VariableWritesValuesAndInternalCall:return"This variable writes values while being used to execute internal logic";case Ce.InternalCallDeclarationNotInParentDatatypeEntity:return"This internal call declaration is not in the parent entity";case Ce.EmptyName:return"This entity has no name";case Ce.InvalidObjectStructure:return"This entity has an invalid structure";case Ce.LoopBodyFunctionOverwrite:return"This loop body action overwrites an action in the template entity with the same name";case Ce.MethodOverwritesBaseMethodWithSameImplementation:return"This action overwrites a base action with the same implementation";case Ce.MethodOverwritesOtherExtendedEntitysMethodWithSameImplementation:return"This action overwrites an action in an extended entity with the same implementation";case Ce.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation:return"This action overwrites an action in an implemented entity with the same implementation";case Ce.MissingCaller:return"This action is missing a caller";case Ce.NameAsResolvedCodeNameNotUniqueInScope:return"This entity has a name that is not unique in the scope of the code it is used in";case Ce.NameCanOnlyContainLettersNumbersUnderscoreAndSpaces:return"This entity name can only contain letters, numbers, underscores and spaces";case Ce.NameMustStartWithLetterOrUnderscore:return"This entity name must start with a letter or an underscore";case Ce.NoOverlapWithImplementedSignature:return"This action does not overlap with the implemented action signature";case Ce.PropertyOverwritesBasePropertyWithSameImplementation:return"This property overwrites a base property with the same implementation";case Ce.PropertyOverwritesOtherExtendedEntitysPropertyWithSameImplementation:return"This property overwrites a property in an extended entity with the same implementation";case Ce.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation:return"This property overwrites a property in an implemented entity with the same implementation";case Ce.ReaderWriterIncompatibleDataType:return"This reader/writer has an incompatible data type with the value it is reading/writing";case dd.StatusCodeMustBeBetween100And599:return"HTTP status code must be between 100 and 599";case dd.StatusCodeMustBeNumber:return"HTTP status code must be a number, between 100 and 599";case as.UUIDMustBeString:return`UUID must be a string, eg: "${op()}"`;case as.UUIDMustNotContainSpaces:return`UUID must not contain spaces, eg: "${op()}"`;case as.UUIDMustBeValidFormat:return`UUID must be in a valid format. Eg: "${op()}"`;case wn.MustBeUniqueAmongSameEntities:return"This value must be unique among the same kind";case wn.StringValueMustNotHaveDashes:return"This value must not contain dashes";case wn.StringValueMustNotHaveSpaces:return"This value must not contain spaces";case wn.ValueMustBeString:return"This value must be a string";case NT.DayOfMonthAndWeekConflict:return"Cron expression cannot have both day of month and day of week";case NT.InvalidCharacters:return"Cron expression has invalid characters";case NT.MustHaveSixFields:return"Cron expression must have six fields";default:return mE(l.code)}}function dRi(l){switch(l.code){case be.AbstractEntityWithNonAbstractMethods:return"Non-template actions";case be.AbstractEntityWithNonAbstractProperties:return"Non-template properties";case be.IncorrectEntityImplementation:return"Incorrect implementation";case be.IncorrectMethodImplementation:return"Incorrect action implementation";case be.IncorrectPropertyImplementation:return"Incorrect property implementation";case be.AbstractMethodInNonAbstractEntity:return"Template action in non-template entity";case be.AbstractPropertyInNonAbstractEntity:return"Template property in non-template entity";case Ce.MethodOverwritesOtherSiblingWithSameName:return"Action overwrite";case Ce.PropertyOverwritesOtherSiblingWithSameName:return"Property overwrite";case be.MissingMethodImplementation:return"Missing action";case be.MissingPropertyImplementation:return"Missing property";case Ce.NameNotUniqueInScope:return"Duplicate name";case be.NoProperties:return"No properties";case be.NonStaticPropertyInStaticEntity:return"Non-static property";case be.StaticEntityWithNonStaticProperties:return"Non-static properties";case be.ReadingFromIncompatibleType:return"Read from different type";case be.WritingToIncompatibleType:return"Write to different type";case be.ScopeWithoutLogic:return"No logic";case be.NonStaticPropertyImplementsStatic:return"Invalid static property";case be.PropertyImplementsIncompatibleType:return"Incompatible data type";case be.PropertyImplementsNonAbstact:return"Non-template property";case be.StaticPropertyImplementsNonStatic:return"Non-static property";case be.VariableCallsOthersAndHasInternalCall:return"Bad internal call";case be.VariableHasInputsAndInternalCall:return"Bad internal call";case be.VariableHasOutputsAndInternalCall:return"Bad internal call";case be.VariableIsCalledAndHasInternalCall:return"Bad internal call";case Ce.InternalCallDeclarationIsInvalidType:return"Declaration not an action";case Ce.InternalCallDeclarationNotFoundInParentDatatypeEntity:return"Declaration not found in parent";case Ce.InternalCallParentDeclarationEntityInvalidType:return"Invalid parent declaration type";case Ce.InternalCallParentMissingDataType:return"Parent has no data type";case Ce.InternalCallDeclarationNotInParentDatatypeEntity:return"Declaration not in parent";case Ce.UnreachableEntity:return"Unreachable entity";case be.DisconnectedCallableEntity:return"Disconnected entity";case be.AbstractEntityImplements:return"Abstract entity implements a non-template entity";case be.AbstractExtendingNonAbstractEntity:return"Abstract entity extends a non-template entity";case be.InvalidPropertiesCombination:return"Invalid properties combination";case be.ExtendingNonInteractiveEntity:return"Extending non-interactive entity";case be.ExtendsIncompatibleEntities:return"Extends incompatible entities";case be.ImplementingNonAbstractEntity:return"Implementing non-template entity";case be.ImplementsIncompatibleEntities:return"Implements incompatible entities";case be.LackingReturnStatementOnSomeBranches:return"Missing termination on some branches";case be.LastCalledEntityMustBeReturnEntity:return"Last called entity must be a termination node";case be.MissingRequiredValue:return"Missing required value";case be.NoPrimaryKeyProperty:return"No primary key property";case be.NonAbstractExtendingAbstractEntity:return"Non-template entity extending a template entity";case be.NonStaticExtendingStaticEntity:return"Non-static entity extending a static entity";case be.NonStaticImplementingStaticEntity:return"Non-static entity implementing a static entity";case be.StaticExtendingNonStaticEntity:return"Static entity extending a non-static entity";case be.StaticImplementingNonStaticEntity:return"Static entity implementing a non-static entity";case be.VariableReadsValueAndInternalCall:return"Variable reads value and has internal call";case be.VariableWritesValuesAndInternalCall:return"Variable writes values and has internal call";case Ce.EmptyName:return"Empty name";case Ce.InvalidObjectStructure:return"Invalid object structure";case Ce.LoopBodyFunctionOverwrite:return"Loop body action overwrites action with same name";case Ce.MethodOverwritesBaseMethodWithSameImplementation:return"Action overwrites base action with same implementation";case Ce.MethodOverwritesOtherExtendedEntitysMethodWithSameImplementation:return"Action overwrites another with same implementation";case Ce.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation:return"Action overwrites another with same implementation";case Ce.MissingCaller:return"Missing caller";case Ce.NameAsResolvedCodeNameNotUniqueInScope:return"Name not unique in scope";case Ce.NameCanOnlyContainLettersNumbersUnderscoreAndSpaces:return"Name can only contain letters, numbers, underscores and spaces";case Ce.NameMustStartWithLetterOrUnderscore:return"Name must start with letter or underscore";case Ce.NoOverlapWithImplementedSignature:return"No overlap with implemented signature";case Ce.PropertyOverwritesBasePropertyWithSameImplementation:return"Property overwrites base property with same implementation";case Ce.PropertyOverwritesOtherExtendedEntitysPropertyWithSameImplementation:return"Property overwrites another with same implementation";case Ce.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation:return"Property overwrites another with same implementation";case Ce.ReaderWriterIncompatibleDataType:return"Reader/writer incompatible data type";case dd.StatusCodeMustBeBetween100And599:return"HTTP status code must be between 100 and 599";case dd.StatusCodeMustBeNumber:return"HTTP status code must be a number";case as.UUIDMustBeString:return"UUID must be a string";case as.UUIDMustNotContainSpaces:return"UUID must not contain spaces";case as.UUIDMustBeValidFormat:return"UUID must be in a valid format";case wn.MustBeUniqueAmongSameEntities:return"This value must be unique among the same kind";case wn.StringValueMustNotHaveDashes:return"This value must not contain dashes";case wn.StringValueMustNotHaveSpaces:return"This value must not contain spaces";default:return mE(l.code)}}function uRi(l){switch(l.code){case be.AbstractEntityWithNonAbstractMethods:return`${le(l.entity,l.entity.project)} has non-template actions`;case be.AbstractEntityWithNonAbstractProperties:return`${le(l.entity,l.entity.project)} has non-template properties`;case be.IncorrectEntityImplementation:return`${le(l.entity,l.entity.project)} incorrectly implements template`;case be.IncorrectMethodImplementation:return`${le(l.entity,l.entity.project)} incorrectly implements the template`;case be.IncorrectPropertyImplementation:return`${le(l.entity,l.entity.project)} incorrectly implements the template`;case be.AbstractMethodInNonAbstractEntity:return`${le(l.entity,l.entity.project)} can't be a template`;case be.AbstractPropertyInNonAbstractEntity:return`${le(l.entity,l.entity.project)} can't be a template`;case Ce.MethodOverwritesOtherSiblingWithSameName:return`${le(l.entity,l.entity.project)} overwrites action`;case Ce.PropertyOverwritesOtherSiblingWithSameName:return`${le(l.entity,l.entity.project)} overwrites property`;case be.MissingMethodImplementation:return`${le(l.entity,l.entity.project)} is missing action`;case be.MissingPropertyImplementation:return`${le(l.entity,l.entity.project)} is missing property`;case Ce.NameNotUniqueInScope:return`${le(l.entity,l.entity.project)} name is not unique`;case be.NoProperties:return`${le(l.entity,l.entity.project)} has no properties`;case be.NonStaticPropertyInStaticEntity:return`${le(l.entity,l.entity.project)} has non-static property`;case be.StaticEntityWithNonStaticProperties:return`${le(l.entity,l.entity.project)} has non-static properties`;case be.ReadingFromIncompatibleType:return`${le(l.entity,l.entity.project)} reads from different type`;case be.WritingToIncompatibleType:return`${le(l.entity,l.entity.project)} writes to different type`;case be.ScopeWithoutLogic:return`${le(l.entity,l.entity.project)} has no logic`;case be.NonStaticPropertyImplementsStatic:return`${le(l.entity,l.entity.project)} has invalid static property`;case be.PropertyImplementsIncompatibleType:return`${le(l.entity,l.entity.project)} has incompatible data type`;case be.PropertyImplementsNonAbstact:return`${le(l.entity,l.entity.project)} has non-template property`;case be.StaticPropertyImplementsNonStatic:return`${le(l.entity,l.entity.project)} has non-static property`;case be.VariableCallsOthersAndHasInternalCall:return`${le(l.entity,l.entity.project)} has bad internal call`;case be.VariableHasInputsAndInternalCall:return`${le(l.entity,l.entity.project)} has bad internal call`;case be.VariableHasOutputsAndInternalCall:return`${le(l.entity,l.entity.project)} has bad internal call`;case be.VariableIsCalledAndHasInternalCall:return`${le(l.entity,l.entity.project)} has bad internal call`;case Ce.InternalCallDeclarationIsInvalidType:return`${le(l.entity,l.entity.project)} has declaration that is not an action`;case Ce.InternalCallDeclarationNotFoundInParentDatatypeEntity:return`${le(l.entity,l.entity.project)} has declaration that is not found in parent`;case Ce.InternalCallParentDeclarationEntityInvalidType:return`${le(l.entity,l.entity.project)} has invalid parent declaration type`;case Ce.InternalCallParentMissingDataType:return`${le(l.entity,l.entity.project)}'s parent has no data type`;case Ce.InternalCallDeclarationNotInParentDatatypeEntity:return`${le(l.entity,l.entity.project)} has declaration that is not in parent`;case Ce.UnreachableEntity:return`${le(l.entity,l.entity.project)} is unreachable`;case be.DisconnectedCallableEntity:return`${le(l.entity,l.entity.project)} is not executed by any entity`;case be.AbstractEntityImplements:return`${le(l.entity,l.entity.project)} implements a non-template entity`;case be.AbstractExtendingNonAbstractEntity:return`${le(l.entity,l.entity.project)} extends a non-template entity`;case be.InvalidPropertiesCombination:return`${le(l.entity,l.entity.project)} has invalid properties combination`;case be.ExtendingNonInteractiveEntity:return`${le(l.entity,l.entity.project)} extends a non-interactive entity`;case be.ExtendsIncompatibleEntities:return`${le(l.entity,l.entity.project)} extends incompatible entities`;case be.ImplementingNonAbstractEntity:return`${le(l.entity,l.entity.project)} implements a non-template entity`;case be.ImplementsIncompatibleEntities:return`${le(l.entity,l.entity.project)} implements incompatible entities`;case be.LackingReturnStatementOnSomeBranches:return`${le(l.entity,l.entity.project)} is missing termination on some branches`;case be.LastCalledEntityMustBeReturnEntity:return`${le(l.entity,l.entity.project)}'s last called entity must be a termination node`;case be.MissingRequiredValue:return`${le(l.entity,l.entity.project)} is missing a required value`;case be.NoPrimaryKeyProperty:return`${le(l.entity,l.entity.project)} has no primary key property`;case be.NonAbstractExtendingAbstractEntity:return`${le(l.entity,l.entity.project)} extends a template entity`;case be.NonStaticExtendingStaticEntity:return`${le(l.entity,l.entity.project)} extends a static entity`;case be.NonStaticImplementingStaticEntity:return`${le(l.entity,l.entity.project)} implements a static entity`;case be.StaticExtendingNonStaticEntity:return`${le(l.entity,l.entity.project)} extends a non-static entity`;case be.StaticImplementingNonStaticEntity:return`${le(l.entity,l.entity.project)} implements a non-static entity`;case be.VariableReadsValueAndInternalCall:return`${le(l.entity,l.entity.project)} reads a value and has internal call`;case be.VariableWritesValuesAndInternalCall:return`${le(l.entity,l.entity.project)} writes values and has internal call`;case Ce.EmptyName:return`${is[l.entity.type]} has no name`;case Ce.InvalidObjectStructure:return`${le(l.entity,l.entity.project)} has invalid structure`;case Ce.LoopBodyFunctionOverwrite:return`${le(l.entity,l.entity.project)}'s loop body action overwrites an action`;case Ce.MethodOverwritesBaseMethodWithSameImplementation:return`${le(l.entity,l.entity.project)} overwrites base action`;case Ce.MethodOverwritesOtherExtendedEntitysMethodWithSameImplementation:return`${le(l.entity,l.entity.project)} overwrites another action with same implementation`;case Ce.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation:return`${le(l.entity,l.entity.project)} overwrites another action with same implementation`;case Ce.MissingCaller:return`${le(l.entity,l.entity.project)} is missing a caller`;case Ce.NameAsResolvedCodeNameNotUniqueInScope:return`${le(l.entity,l.entity.project)} has a name not unique in the scope`;case Ce.NameCanOnlyContainLettersNumbersUnderscoreAndSpaces:return`${le(l.entity,l.entity.project)} name can only contain letters, numbers, underscores and spaces`;case Ce.NameMustStartWithLetterOrUnderscore:return`${le(l.entity,l.entity.project)} name must start with letter or underscore`;case Ce.NoOverlapWithImplementedSignature:return`${le(l.entity,l.entity.project)} has no overlap with implemented signature`;case Ce.PropertyOverwritesBasePropertyWithSameImplementation:return`${le(l.entity,l.entity.project)} overwrites base property`;case Ce.PropertyOverwritesOtherExtendedEntitysPropertyWithSameImplementation:return`${le(l.entity,l.entity.project)} overwrites another property with same implementation`;case Ce.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation:return`${le(l.entity,l.entity.project)} overwrites another property with same implementation`;case Ce.ReaderWriterIncompatibleDataType:return`${le(l.entity,l.entity.project)} has reader/writer with incompatible data type`;case dd.StatusCodeMustBeBetween100And599:return`${le(l.entity,l.entity.project)} HTTP status code must be between 100 and 599`;case dd.StatusCodeMustBeNumber:return`${le(l.entity,l.entity.project)} HTTP status code must be a number`;case as.UUIDMustBeString:return`${le(l.entity,l.entity.project)} UUID must be a string`;case as.UUIDMustNotContainSpaces:return`${le(l.entity,l.entity.project)} UUID must not contain spaces`;case as.UUIDMustBeValidFormat:return`${le(l.entity,l.entity.project)} UUID must be in a valid format`;case wn.MustBeUniqueAmongSameEntities:return`${le(l.entity,l.entity.project)} value must be unique among the same kind`;case wn.StringValueMustNotHaveDashes:return`${le(l.entity,l.entity.project)} value must not contain dashes`;case wn.StringValueMustNotHaveSpaces:return`${le(l.entity,l.entity.project)} value must not contain spaces`;default:return`${le(l.entity,l.entity.project)} Error: ${mE(l.code)}`}}function pRi(l){var p,i,r,a;switch(l.code){case be.AbstractEntityWithNonAbstractMethods:return`${le(l.entity,l.entity.project)} has non-template actions`;case be.AbstractEntityWithNonAbstractProperties:return`${le(l.entity,l.entity.project)} has non-template properties`;case be.IncorrectEntityImplementation:return`${le(l.entity,l.entity.project)} incorrectly implements the template entity`;case be.IncorrectMethodImplementation:return`${le(l.entity,l.entity.project)} incorrectly implements the template action it's based on`;case be.IncorrectPropertyImplementation:return`${le(l.entity,l.entity.project)} incorrectly implements the template property it's based on`;case be.AbstractMethodInNonAbstractEntity:return`${le(l.entity,l.entity.project)} is a template action in a non-template entity`;case be.AbstractPropertyInNonAbstractEntity:return`${le(l.entity,l.entity.project)} is a template property in a non-template entity`;case Ce.MethodOverwritesOtherSiblingWithSameName:return`${le(l.entity,l.entity.project)} overwrites an action in the template entity`;case Ce.PropertyOverwritesOtherSiblingWithSameName:return`${le(l.entity,l.entity.project)} overwrites a property in the template entity`;case be.MissingMethodImplementation:return`${le(l.entity,l.entity.project)} is missing an action implementation from the template entity`;case be.MissingPropertyImplementation:return`${le(l.entity,l.entity.project)} is missing a property implementation from the template entity`;case Ce.NameNotUniqueInScope:return`${le(l.entity,l.entity.project)} has a duplicate name in the same scope`;case be.NoProperties:return`${le(l.entity,l.entity.project)} has no properties, so it doesn't do anything`;case be.NonStaticPropertyInStaticEntity:return`${le(l.entity,l.entity.project)} has a non-static property in a static entity`;case be.StaticEntityWithNonStaticProperties:return`${le(l.entity,l.entity.project)} has non-static properties in a static entity`;case be.ReadingFromIncompatibleType:return`${le(l.entity,l.entity.project)} reads data from a value of a different data type`;case be.WritingToIncompatibleType:return`${le(l.entity,l.entity.project)} writes data to a value of a different data type`;case be.ScopeWithoutLogic:return`${le(l.entity,l.entity.project)} has no logic`;case be.NonStaticPropertyImplementsStatic:return`${le(l.entity,l.entity.project)} has a static property in a non-static entity`;case be.PropertyImplementsIncompatibleType:return`${le(l.entity,l.entity.project)} implements a property of a different data type`;case be.PropertyImplementsNonAbstact:return`${le(l.entity,l.entity.project)} implements a non-template property`;case be.StaticPropertyImplementsNonStatic:return`${le(l.entity,l.entity.project)} has a static property in a non-static entity`;case be.VariableCallsOthersAndHasInternalCall:return`${le(l.entity,l.entity.project)} calls other entities while being used to execute internal logic`;case be.VariableHasInputsAndInternalCall:return`${le(l.entity,l.entity.project)} has inputs while being used to execute internal logic`;case be.VariableHasOutputsAndInternalCall:return`${le(l.entity,l.entity.project)} has outputs while being used to execute internal logic`;case be.VariableIsCalledAndHasInternalCall:return`${le(l.entity,l.entity.project)} is called while being used to execute internal logic`;case Ce.InternalCallDeclarationIsInvalidType:return`${le(l.entity,l.entity.project)} has a declaration that is not an action`;case Ce.InternalCallDeclarationNotFoundInParentDatatypeEntity:return`${le(l.entity,l.entity.project)} has a declaration that is not found in ${(p=l.entity.parent.getDataType(null))!=null&&p.entity?le((i=l.entity.parent.getDataType(null))==null?void 0:i.entity,l.entity.project):"the variable's data-type entity"}`;case Ce.InternalCallParentDeclarationEntityInvalidType:return`${le(l.entity,l.entity.project)} is part of a variable whos data-type entity can't have actions`;case Ce.InternalCallParentMissingDataType:return`${le(l.entity,l.entity.project)} is part of a variable with no data-type entity`;case Ce.InternalCallDeclarationNotInParentDatatypeEntity:return`${le(l.entity,l.entity.project)} has a declaration doesn't belong to ${(r=l.entity.parent.getDataType(null))!=null&&r.entity?le((a=l.entity.parent.getDataType(null))==null?void 0:a.entity,l.entity.project):"the variable's data-type entity"}`;case Ce.UnreachableEntity:return`${le(l.entity,l.entity.project)} is unreachable`;case be.DisconnectedCallableEntity:return`${le(l.entity,l.entity.project)} is disconnected and won't be executed by anything after publishing`;case be.AbstractEntityImplements:return`${le(l.entity,l.entity.project)} implements a non-template entity`;case be.AbstractExtendingNonAbstractEntity:return`${le(l.entity,l.entity.project)} extends a non-template entity`;case be.InvalidPropertiesCombination:return`${le(l.entity,l.entity.project)} has an invalid combination of properties`;case be.ExtendingNonInteractiveEntity:return`${le(l.entity,l.entity.project)} extends a non-interactive entity`;case be.ExtendsIncompatibleEntities:return`${le(l.entity,l.entity.project)} extends incompatible entities`;case be.ImplementingNonAbstractEntity:return`${le(l.entity,l.entity.project)} implements a non-template entity`;case be.ImplementsIncompatibleEntities:return`${le(l.entity,l.entity.project)} implements incompatible entities`;case be.LackingReturnStatementOnSomeBranches:return`${le(l.entity,l.entity.project)} has branches that don't terminate`;case be.LastCalledEntityMustBeReturnEntity:return`${le(l.entity,l.entity.project)} must end with a termination node`;case be.MissingRequiredValue:return`${le(l.entity,l.entity.project)} is missing a required value`;case be.NoPrimaryKeyProperty:return`${le(l.entity,l.entity.project)} has no primary key property`;case be.NonAbstractExtendingAbstractEntity:return`${le(l.entity,l.entity.project)} is a non-template entity extending a template entity`;case be.NonStaticExtendingStaticEntity:return`${le(l.entity,l.entity.project)} is a non-static entity extending a static entity`;case be.NonStaticImplementingStaticEntity:return`${le(l.entity,l.entity.project)} is a non-static entity implementing a static entity`;case be.StaticExtendingNonStaticEntity:return`${le(l.entity,l.entity.project)} is a static entity extending a non-static entity`;case be.StaticImplementingNonStaticEntity:return`${le(l.entity,l.entity.project)} is a static entity implementing a non-static entity`;case be.VariableReadsValueAndInternalCall:return`${le(l.entity,l.entity.project)} reads a value and has an internal call`;case be.VariableWritesValuesAndInternalCall:return`${le(l.entity,l.entity.project)} writes values and has an internal call`;case Ce.EmptyName:return`${is[l.entity.type]} has no name`;case Ce.InvalidObjectStructure:return`${le(l.entity,l.entity.project)} has an invalid structure`;case Ce.LoopBodyFunctionOverwrite:return`${le(l.entity,l.entity.project)}'s loop body action overwrites`;case Ce.MethodOverwritesBaseMethodWithSameImplementation:return`${le(l.entity,l.entity.project)} overwrites a base action with same implementation`;case Ce.MethodOverwritesOtherExtendedEntitysMethodWithSameImplementation:return`${le(l.entity,l.entity.project)} overwrites another action with same implementation`;case Ce.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation:return`${le(l.entity,l.entity.project)} overwrites another action with same implementation`;case Ce.MissingCaller:return`${le(l.entity,l.entity.project)} is missing a caller`;case Ce.NameAsResolvedCodeNameNotUniqueInScope:return`${le(l.entity,l.entity.project)} has a name that is not unique in the scope`;case Ce.NameCanOnlyContainLettersNumbersUnderscoreAndSpaces:return`${le(l.entity,l.entity.project)} name can only contain letters, numbers, underscores and spaces`;case Ce.NameMustStartWithLetterOrUnderscore:return`${le(l.entity,l.entity.project)} name must start with letter or underscore`;case Ce.NoOverlapWithImplementedSignature:return`${le(l.entity,l.entity.project)} has no overlap with implemented signature`;case Ce.PropertyOverwritesBasePropertyWithSameImplementation:return`${le(l.entity,l.entity.project)} overwrites a base property with same implementation`;case Ce.PropertyOverwritesOtherExtendedEntitysPropertyWithSameImplementation:return`${le(l.entity,l.entity.project)} overwrites another property with same implementation`;case Ce.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation:return`${le(l.entity,l.entity.project)} overwrites another property with same implementation`;case Ce.ReaderWriterIncompatibleDataType:return`${le(l.entity,l.entity.project)} has a reader/writer with incompatible data type`;case dd.StatusCodeMustBeBetween100And599:return`${le(l.entity,l.entity.project)} HTTP status code must be between 100 and 599`;case dd.StatusCodeMustBeNumber:return`${le(l.entity,l.entity.project)} HTTP status code must be a number, between 100 and 599`;case as.UUIDMustBeString:return`${le(l.entity,l.entity.project)} UUID must be a string, eg: "${op()}"`;case as.UUIDMustNotContainSpaces:return`${le(l.entity,l.entity.project)} UUID must not contain spaces, eg: "${op()}"`;case as.UUIDMustBeValidFormat:return`${le(l.entity,l.entity.project)} UUID must be in a valid format. Eg: "${op()}"`;case wn.MustBeUniqueAmongSameEntities:return`${le(l.entity,l.entity.project)} value must be unique among the same kind`;case wn.StringValueMustNotHaveDashes:return`${le(l.entity,l.entity.project)} value must not contain dashes`;case wn.StringValueMustNotHaveSpaces:return`${le(l.entity,l.entity.project)} value must not contain spaces`;default:return`${le(l.entity,l.entity.project)} Error: ${mE(l.code)}`}}function TE(l){const p=(l||"").startsWith("error-caller-only--");switch(p?l.replace("error-caller-only--",""):l){case Wt.CallIsInHigherScope:return"In a higher scope";case Wt.CallIsInLowerScope:return"In a lower scope";case Wt.CallerIsInHigherScope:return"Caller is in a higher scope";case Wt.CallerIsInLowerScope:return"Caller is in a lower scope";case Wt.CannotBeCalledByChildren:return"Cannot be called by children";case Wt.CannotCallAncestor:return"Cannot call ancestor";case Wt.CannotConnectToItself:return"Cannot connect to itself";case Wt.CannotReadMoreThanOneValue:return"Cannot read more than one value";case Wt.CannotReadValueFromChildren:return"Cannot read value from entities executed after itself";case Wt.CannotWriteValueToAncestor:return"Cannot write value to ancestor";case nv.Suggestion:return"Suggestion";case Wt.ContinueOrBreakStatementCalledFromOutsideLoop:return"Cannot be called from outside loop";case Wt.DataTypesNotCompatible:return"Data types not compatible";case Wt.ElementInLoopBodyCallingOutsideLoop:return"Cannot call outside loop";case Wt.ErrorOututMapCannotBeConnectedToParentSuccessBranchCallees:return"Error cannot be connected to success branch";case Wt.ExecutionsAlreadyConnected:return"Executions already connected";case Wt.IsNotValueReadingEntity:return"Is not a value reading entity";case Wt.IsNotValueWritingEntity:return"Is not a value writing entity";case Wt.NotInScope:return"Not in a compatible scope";case Wt.OtherIncompatibleScopeReason:return"Incompatible scope";case Wt.SiblingInternalCallAlreadyUsedInParentVariable:return"Internal call already used in parent variable";case Wt.SuccessOutputMapCannotBeConnectedToParentErrorBranchCallees:return"Success cannot be connected to error branch";case Wt.ValuesAlreadyConnected:return"Values already connected";case Wt.CannotInteractWithInputInVariableWithInternalCalls:return"Cannot interact with input in variable with internal calls";case Wt.CannotInteractWithOutputInVariableWithInternalCalls:return"Cannot interact with output in variable with internal calls";case nv.CanvasGloballyDisabled:return"Canvas is globally disabled";case Wt.PropertyIsConstantItsValueCantBeReset:return"Property is constant, its value can't be reset";case Wt.CannotWriteValueOfGlobalVariableDeclaration:return"Cannot write value of global variable declaration";case Wt.CannotReSetValueOfConstantVariable:return"Cannot re-set value of constant variable";case Wt.CannotConnectToOwnNode:return"It is part of the same node";case Wt.CalledByErrorMustBePassThroughCallable:return"Called by error must be pass-through callable";case Wt.CannotChangeScopeBecauseItCallsOtherEntities:return"Cannot change scope because it calls other entities in its current scope";case Wt.CannotChangeScopeBecauseItIsAlreadyCalledByOtherEntitiesInDifferentScope:return"Cannot change scope because it is already called by other entities in different scope";case Wt.VariableDeclarationCannotBeMovedToLowerScopeBecauseInstancesUsage:return"Variable declaration cannot be moved to lower scope because its instances are used in the current or different incompatible lower scope";case Wt.CalledBySourceMustBeCallerEntity:return"Not a caller type";case Wt.CalledByErrorCannotBeConnectedToEntitiesCalledByOwnSuccessBranch:return"Already connected to the success branch from a common origin caller";case Wt.CalledBySuccessCannotBeConnectedToEntitiesCalledByOwnErrorBranch:return"Already connected to the error branch from a common origin caller";case Wt.RedundantCall:return"Redundant call. Already connected further down the execution path";case Wt.CannotBeCalledBeforeDeclaration:return"Cannot be called before declaration";case Wt.CannotBeCalledInParallelBranchToDeclaration:return"Cannot be called in parallel branch to declaration";case Wt.CannotBeHigherScopeThanDeclaration:return"Cannot be in a higher scope than declaration";case Wt.CannotCallGlobalVariableDeclaration:return"Cannot call global variable declaration";case Wt.EntityAlreadyCalledBySuccessCannotBeConnectedToUnrelatedErrorBranch:return p?"Cannot connect error: Already connected to a success branch from a common origin caller":"Already connected to a success branch from a common origin caller";case Wt.CannotInteractWithInputInGlobalVariableDeclaration:return"Cannot interact with input in global variable declaration";case Wt.IsNotCallableEntity:return"Is not a callable node type";case Wt.IsNotCallerEntity:return"Is not a caller node type";case Wt.IsNotPassThroughCallableEntity:return"Is not a pass-through callable node type that has an error branch";case Wt.NotAConnectableEntityType:return"Not a connectable node type";case Wt.WouldMakeAnEarlierNodeBeCalledBeforeItsDeclaration:return"Would make an earlier node be called before its declaration";default:return Rc(l||"")}}function cRi(l,p){const i=[...l,...p],r=Array.from(new Set(i));return{hasChanged:r.length!==l.length,reasons:r}}function fRi(l,p){const i=l.filter(a=>!p.includes(a));return{hasChanged:i.length!==l.length,reasons:i}}function yRi(l,p){return l.find(i=>i.entity.id===p)||null}function Zk(l){return l.filter((p,i)=>l.indexOf(p)===i)}class Xr{constructor(p,i,r=null,a){R(this,"ids",[]);R(this,"entity");R(this,"entityCardHeight");R(this,"entityCardWidth");R(this,"index");R(this,"childEntities",[]);R(this,"children",[]);R(this,"parents",[]);R(this,"calculationEntryPoint");R(this,"_onlyEntities",null);R(this,"_changeSet",null);if(this.index=i,this.entity=p,this.calculationEntryPoint=r||this,this._changeSet=a||null,this===this.calculationEntryPoint&&!a)throw new Error("Change-set must be provided for the calculation entry point");this.calculateCardSize(),this.getSortedChildren()}static autoGenerateLayout(p,i,r){const a=RBe-OI-i$,c=DBe-nI-r$;p.type===d.Project?(p.x=a,p.y=c):p.metaSync({x:p.x||a,y:p.y||c},i);const e=new Xr(p,0,null,i);e.calculationEntryPoint=e,e._onlyEntities=r||[],e.ids=["0"];const f=[];e.next(m=>{f.push(...m)}),Xr.recursivelyAssembleChildrenAreas(f),e.resolveChildrenOverlaps();const h=e.flattenChildEntities();return e._onlyEntities?h.filter(m=>{var E;return(E=e._onlyEntities)==null?void 0:E.includes(m)}):h}static recursivelyAssembleChildrenAreas(p){const i=[];p.forEach(r=>{r.next(a=>{i.push(...a)})}),i.length>0&&Xr.recursivelyAssembleChildrenAreas(i)}get onlyEntities(){return this.calculationEntryPoint._onlyEntities||[]}get changeSet(){return this.calculationEntryPoint._changeSet}set changeSet(p){this.calculationEntryPoint._changeSet=p}findAreaInChildrenFromEntity(p){if(this.entity===p)return this;const i=this.children.find(a=>a.entity===p);return i||this.children.reduce((a,c)=>a||c.findAreaInChildrenFromEntity(p),null)}findAreaFromEntity(p){if(this.entity===p)return this;const i=this.calculationEntryPoint.children,r=i.find(c=>c.entity===p);return r||i.reduce((c,e)=>c||e.findAreaInChildrenFromEntity(p),null)}addParent(p){if(!this.parents.includes(p)){const i=Xr.resolveIds(p,this.index);this.ids.push(...i),this.parents.push(p)}}static resolveIds(p,i){return p?p.ids.map(r=>`${r}-${i}`):[`${i}`]}getSortedChildren(){if(this.entity.collapsed){this.childEntities=[];return}const p=Ql(this.entity,!0);if(this.entity.type===d.Project){const i=[],r=[],a=[];p.forEach(e=>{if(d.DefinitionEntity===e.type){r.push(e);return}else if(Bt.includes(e.type)){a.push(e);return}i.push(e)});const c=i.sort((e,f)=>{const h=!!UI(e,f).length,m=Ql(e),E=Ql(f);return h?0:m.length&&!E.length?-1:!m.length&&E.length?1:0}).filter(e=>!_c(e).length);this.childEntities=[...r,...a,...c]}else{const i=[],r=[],a=[],c=[],e=[];Wi.includes(this.entity.type)&&Q1(this.entity).forEach(m=>{if(xt.includes(m.type)){a.push(m);return}const E=yt(m);i.push(E)}),br.includes(this.entity.type)&&r.push(...this.entity.detachedChildren);const f=p.filter(h=>{const m=i.includes(h);return m||a.includes(h)||r.includes(h)?!1:xt.includes(h.type)?(a.push(h),!1):er.includes(h.type)&&!m?(c.push(h),!1):h.type===d.DefinitionEntity?(e.push(h),!1):!0});i.sort((h,m)=>Wl(h,m)?-1:0),c.sort((h,m)=>Wl(h,m)?-1:0),a.sort((h,m)=>sV(h,m)?1:sV(m,h)?-1:0),this.childEntities=[...e,...i,...c,...f,...a,...r]}}calculateCardSize(){const p=wBe(this.entity);this.entityCardWidth=p.width,this.entityCardHeight=p.height}static getBoundriesOfTwoAreas(p,i){return{top:Math.min(p.top,i.top),left:Math.min(p.left,i.left),bottom:Math.max(p.bottom,i.bottom),right:Math.max(p.right,i.right)}}static getBoundriedOfCombinedAreas(p,i){const r=p.filter(c=>!i.includes(c));return r.reduce((c,e)=>i.includes(e)?c:Xr.getBoundriesOfTwoAreas(c,e.fullBranchArea),r[0].fullBranchArea)}getFullAreaUntilAny(p){const i=this.ownEntityPlusBufferArea;return this.children.filter(e=>!p.includes(e)).map(e=>e.getFullAreaUntilAny(p)).reduce((e,f)=>Xr.getBoundriesOfTwoAreas(e,f),i)}getFullAreaUntilAreaOrAnyChildren(p){const i=[p,...p.flattenChildren()],r=this.ownEntityPlusBufferArea;return this.children.filter(e=>i.includes(e)).map(e=>e.getFullAreaUntil(p)).reduce((e,f)=>Xr.getBoundriesOfTwoAreas(e,f),r)}getFullAreaUntil(p){const i=this.ownEntityPlusBufferArea;return this.children.filter(c=>c!==p).map(c=>c.getFullAreaUntil(p)).reduce((c,e)=>Xr.getBoundriesOfTwoAreas(c,e),i)}get fullBranchArea(){const p=this.ownEntityPlusBufferArea;return this.children.map(a=>a.fullBranchArea).reduce((a,c)=>Xr.getBoundriesOfTwoAreas(a,c),p)}get ownEntityArea(){return{top:this.entity.y,left:this.entity.x,bottom:this.entity.y+this.entityCardHeight,right:this.entity.x+this.entityCardWidth}}get ownEntityPlusBufferArea(){const p=this.ownEntityArea;return{top:p.top,left:p.left,bottom:p.bottom+nI,right:p.right+OI}}static filterOutRepeatedAreas(p){return p.filter((i,r)=>p.indexOf(i)===r)}getEarliestId(p,i){const r=p.split("-"),a=i.split("-");return r.length<a.length?p:r.length>a.length?i:r.reduce((e,f,h)=>f<a[h]?p:i,p)}getEarliestLevel(){return this.ids.reduce((r,a)=>this.getEarliestId(r,a),this.ids[0]).split("-").length}countColumns(){let p=0;if(this!==this.calculationEntryPoint)p++;else return p;if(!this.parents.length)return p;const r=this.parents.reduce((a,c)=>c.getEarliestLevel()>a.getEarliestLevel()?c:a,this.parents[0]).countColumns();return p+=r,p}getLatestId(p,i){if(p===i)return p;const r=p.split("-"),a=i.split("-");return r.length<a.length?i:r.length>a.length?p:r.reduce((e,f,h)=>f>a[h]?p:i,p)}getLatestLevel(){return this.ids.length===1?this.ids[0].split("-").length:this.ids.reduce((r,a)=>this.getLatestId(r,a),this.ids[0]).split("-").length}smoothPosition(){const p=this.flattenSiblings();if(!p.length&&this.parents.length<=1&&this.children.length){const i=this.centerHeaderVerticallyOverCombinedAllChildrenHeaderHeight();this.parents.forEach(r=>{r!==this.calculationEntryPoint&&r.shiftDownAlone(i)})}else if([...Bt].includes(this.entity.type)&&this.children.length)this.centerHeaderVerticallyOverCombinedAllChildrenHeaderHeight();else if(!this.children.length&&this.parents.length>1){const i=p.filter(r=>!this.parents.includes(r));i.length?i.every(a=>{const c=this.countColumns(),e=a.countColumns();return c>e})&&this.centerHeaderVerticallyOverCombinedAllParentsHeaderHeight():i.length||this.centerHeaderVerticallyOverCombinedAllParentsHeaderHeight()}}shiftDownUntilAny(p,i){if(p.includes(this))return p;this.move(this.entity,{y:this.entity.y+i});let r=[...p,this];return this.children.forEach(a=>{if(Xr.getEarliestParentInChain(a)!==this)return;const e=yRi(r,a.entity.id);r=Xr.filterOutRepeatedAreas([...r]),e||(r=r.filter(h=>h!==a));const f=a.shiftDownUntilAny(r,i);r.push(...f)}),r}shiftRightUntilAny(p,i){p.includes(this)||(this.move(this.entity,{x:this.entity.x+i}),this.children.forEach(r=>{const a=Xr.filterOutRepeatedAreas([...this.flattenSiblings(),...p]);Xr.getEarliestParentInChain(r)===this&&r.shiftRightUntilAny(a,i)}))}shiftRight(p){this.move(this.entity,{x:this.entity.x+p}),this.children.forEach(i=>{const a=i.flattenSiblings().filter(c=>c!==i);i.shiftRightUntilAny(a,p)})}shiftDownAlone(p){this.move(this.entity,{y:this.entity.y+p})}centerHeaderVerticallyOverCombinedAllParentsHeaderHeight(){const p=this.parents.reduce((a,c)=>{const e=c.ownEntityArea,f=e.top+of,h={top:f,left:e.left,bottom:f,right:e.right};return Xr.getBoundriesOfTwoAreas(a,h)},{top:1/0,left:1/0,bottom:-1/0,right:-1/0}),r=(p.bottom-p.top)/2-of;this.shiftDownAlone(r)}centerHeaderVerticallyOverCombinedAllChildrenHeaderHeight(){const p=this.children.reduce((a,c)=>{const e=c.ownEntityArea,f=e.top+of,h={top:f,left:e.left,bottom:f,right:e.right};return Xr.getBoundriesOfTwoAreas(a,h)},{top:1/0,left:1/0,bottom:-1/0,right:-1/0}),r=(p.bottom-p.top)/2-of;return this.shiftDownAlone(r),r}resolveChildrenOverlaps(){const p=this.flattenChildren();let i=[];p.forEach(r=>{const a=r.adjustVerticallyToAvoidOverlaps();i.push(...a)}),p.forEach(r=>{r.smoothPosition()})}static getEarliestParentInChain(p){let i=p.parents[0];return p.parents.length&&(i=p.parents.sort((r,a)=>{if(!r.ids.length)return-1;if(!a.ids.length)return 1;const c=r.ids.sort((f,h)=>f.length<h.length?-1:0),e=a.ids.sort((f,h)=>f.length<h.length?-1:0);return c[0].length-e[0].length})[0]),i}flattenEarlierSiblings(p=new Set){return p.add(this.entity.id),this.parents.reduce((r,a)=>{if(p.has(a.entity.id))return r;p.add(a.entity.id);const e=a.children.slice(0,a.children.indexOf(this)).reduce((f,h)=>[...f,h,...h.flattenChildren(p)],[]);return[...r,...e]},[])}flattenSiblings(p=new Set){return p.add(this.entity.id),this.parents.reduce((r,a)=>{if(p.has(a.entity.id))return r;p.add(a.entity.id);const e=a.children.filter(f=>f!==this).reduce((f,h)=>[...f,h,...h.flattenChildren(p)],[]);return[...r,...e]},[])}flattenChildren(p=new Set){return this.children.reduce((i,r)=>p.has(r.entity.id)?i:(p.add(r.entity.id),[...i,r,...r.flattenChildren(p)]),[])}flattenParents(p=new Set){return this.parents.reduce((r,a)=>p.has(a.entity.id)?r:(p.add(a.entity.id),[...r,a,...a.flattenParents(p)]),[])}getAreaIfRendered(p){return this.calculationEntryPoint.flattenChildren().find(a=>a.entity.id===p.id)||null}getLowerSiblings(){const p=this.parents.reduce((i,r)=>{const a=r.children.indexOf(this),c=r.children.slice(a+1);return[...i,...c]},[]);return Zk(p)}getLowerAreas(){const p=this.getLowerSiblings(),i=this.parents.reduce((r,a)=>[...r,...a.getLowerAreas()],[]);return Zk([...p,...i])}adjustVerticallyToAvoidOverlaps(p=[]){const r=Xr.getEarliestParentInChain(this).children[this.index-1];if(!r)return p;const a=this.flattenEarlierSiblings(),c=this.flattenParents(),e=[...a,...c,r],m=C(e.flatMap(_=>UI(this.entity,_.entity))).filter(_=>_.id!==this.entity.id).map(_=>this.findAreaFromEntity(_)).filter(_=>!!_),E=this.getFullAreaUntilAny(m),b=r.getFullAreaUntilAny(m),A=e.reduce((_,N)=>N===this||N.fullBranchArea.left!==E.left?_:Math.max(_,N.fullBranchArea.bottom),b.bottom);if(E.top<A){const _=A-E.top+nI;return this.shiftDownUntilAny(p,_)}return p}move(p,i){if(this.onlyEntities.includes(p)){if(!this.changeSet)throw new Error("Change set is not defined for this area, cannot move entity");p.metaSync(i,this.changeSet)}}addChild(p){const i=this.childEntities[p];let r=null;i.x&&i.y?r=this.getAreaIfRendered(i):!i.x&&!i.y&&this.move(i,{x:this.entity.x,y:this.entity.y}),r||(r=new Xr(i,p,this.calculationEntryPoint));const a=this.ownEntityPlusBufferArea;this.children.includes(r)||(this.children.push(r),r.addParent(this));const c=r.fullBranchArea;if(c.left<a.right){const e=a.right-c.left;r.shiftRight(e)}return r}flattenChildEntities(p=new Set){return this.children.reduce((i,r)=>p.has(r.entity.id)?i:(p.add(r.entity.id),[...i,r.entity,...r.flattenChildEntities(p)]),[])}next(p){const i=[];this.childEntities.forEach((r,a)=>{const c=this.addChild(a);c&&i.push(c)}),p(i)}}async function hRi(l,p,i={}){var c;const r=Y.YieldTracker.from(i),a=[];console.log("Generating layout for project...");for(const e of l.instancesList){if(l.diggestedBuiltInBaseEntitiesIds.has(e.id)||!Af.includes(e.type)||((c=yt(e))==null?void 0:c.id)!==e.id)continue;let f=Gt(e,l);if(!f){console.log("No top scope owner for instance: ",e," in project: ",l);continue}if(!(Bt.includes(f.type)&&f.collapsed&&f.id!==e.id)){for(;f.parent&&f.parent!==l;)f=f.parent,Bt.includes(f.type)&&f.collapsed&&(f.id,e.id);e.x=0,e.y=0,p==null||p.add(e,W.Updated),a.push(e),await r.tick()}}Xr.autoGenerateLayout(l,p,a)}async function mRi(l,p,i={}){const r=Y.YieldTracker.from(i),a=[],c=[l,...pt(l)].map(e=>yt(e)).filter(Boolean);for(const e of c){if(l.project.diggestedBuiltInBaseEntitiesIds.has(e.id))continue;let f=Gt(e,l.project);if(f&&!(Bt.includes(f.type)&&f.collapsed&&f.id!==e.id)){for(;f.parent&&f.parent!==l.project;)f=f.parent,Bt.includes(f.type)&&f.collapsed&&(f.id,e.id);e.x=0,e.y=0,p==null||p.add(e,W.Updated),a.push(e),await r.tick()}}Xr.autoGenerateLayout(l.project,p,a)}async function TRi(l,p,i={}){const r=Y.YieldTracker.from(i),a=[],c=new Set;bFe(p,{shallowMissingActivesError:!0,excludeAffected:!0}).forEach(m=>{var b;if((!m.x||!m.y)&&!c.has(m.id)&&!l.diggestedBuiltInBaseEntitiesIds.has(m.id)&&(a.push(m),c.add(m.id)),to(m,l)){const A=yt(m);A&&!c.has(A.id)&&!l.diggestedBuiltInBaseEntitiesIds.has(A.id)&&(a.push(A),c.add(A.id))}if(Wi.includes(m.type)){const A=m;[A,...pt(A)].forEach(N=>{const V=yt(N);V&&!c.has(V.id)&&!l.diggestedBuiltInBaseEntitiesIds.has(V.id)&&(a.push(V),c.add(V.id))})}m.type===d.DefinitionEntity&&m.methods.forEach(A=>{pt(A).forEach(N=>{const V=yt(N);V&&!c.has(V.id)&&!l.diggestedBuiltInBaseEntitiesIds.has(V.id)&&(a.push(V),c.add(V.id))})}),((b=m.parent)==null?void 0:b.type)===d.Project&&(a.push(m),c.add(m.id),Wi.includes(m.type)&&pt(m).forEach(N=>{const V=yt(N);V&&!c.has(V.id)&&!l.diggestedBuiltInBaseEntitiesIds.has(V.id)&&(a.push(V),c.add(V.id))}))});let f=[];for(const m of a)l.diggestedBuiltInBaseEntitiesIds.has(m.id)||(m.x=0,m.y=0,p==null||p.add(m,W.Updated),f.push(m),await r.tick());f=C(f),Xr.autoGenerateLayout(l,p,f);const h=C([...f,...l.variableDeclarations,...l.variableInstances,...l.loops,...l.conditions,...l.operations,...l.searches]).filter(m=>m.x===0||m.y===0);Xr.autoGenerateLayout(l,p,h)}var DT=(l=>(l.Amazon="amazon",l.Google="google",l.Microsoft="microsoft",l))(DT||{}),vr=(l=>(l.RelationalDatabase="relational-database",l.CompiledLocalCodebase="compiled-local-codebase",l.CloudHostedCodebase="cloud-hosted-codebase",l.HttpApi="http-api",l.HttpEndpoint="http-endpoint",l.ServerlessFunction="serverless-function",l.CronJob="cron-job",l.AWSTenantAccount="aws-tenant-account",l))(vr||{}),$_=(l=>(l.Post="post",l.Get="get",l.Acknowledgement="acknowledgment",l.Progress="progress",l.Error="error",l.Complete="complete",l))($_||{}),nf=(l=>(l.Queued="queued",l.Running="running",l.Success="success",l.Failed="failed",l.CleanedUp="cleaned-up",l.Skipped="skipped",l.AbortedByUser="aborted-by-user",l.UnrecoverableFailure="unrecoverable-failure",l.Reverted="reverted",l.UnpublishingStarted="unpublishing-started",l.Unpublished="unpublished",l))(nf||{}),L_=(l=>(l.Queued="queued",l.Running="running",l.Success="success",l.Failed="failed",l.CleanedUp="cleaned-up",l.UnrecoverableFailure="unrecoverable-failure",l.Reverted="reverted",l.UnpublishingStarted="unpublishing-started",l.Unpublished="unpublished",l))(L_||{}),Kt=(l=>(l.ProjectNotFound="project-not-found",l.ProjectPublishRequestAcknowledged="project-publish-request-acknowledged",l.PublicationStepFailedReasonUnknown="publication-step-failed-reason-unknown",l.DeploymentCompleted="deployment-completed",l.DeploymentStarted="deployment-started",l.DeploymentFailed="deployment-failed",l.AllInfrastructureSuccessfullyProvisioned="all-infrastucture-successfully-provisioned",l.RequestPayloadValidationFailed="request-payload-validation-failed",l.ProjectStateValidationFailedMissingName="project-state-validation-failed-missing-name",l.ProjectStateValidationFailedMissingAnyFunctionality="project-state-validation-failed-missing-any-functionality",l.ProjectAlreadyBeingPublished="project-already-being-published",l.BillingSubscriptionUpdateFailed="billing-subscription-update-failed",l.RelationalDatabaseDeploymentStarted="relational-database-deployment-started",l.RelationalDatabaseDeploymentCompleted="relational-database-deployment-completed",l.RelationalDatabaseDeploymentFailed="relational-database-deployment-failed",l.CreatingNewRelationalDatabase="creating-new-relational-database",l.WaitingForPreviousRelationalDatabaseDeployment="waiting-for-previous-relationa-database-deployment",l.RelationalDatabaseAlreadyExists="relational-database-already-exists",l.RelationalDatabaseDeletionStarted="relational-database-deletion-started",l.RelationalDatabaseDeletionCompleted="relational-database-deletion-completed",l.RelationalDatabaseDeletionFailed="relational-database-deletion-failed",l.WaitingForPreviousRelationalDatabaseDeletion="waiting-for-previous-relationa-database-deletion",l.HttpApiDeploymentStarted="http-api-deployment-started",l.HttpApiDeploymentCompleted="http-api-deployment-completed",l.HttpApiDeploymentFailed="http-api-deployment-failed",l.CreatingNewHttpApi="creating-new-http-api",l.HttpApiAlreadyExists="http-api-already-exists",l.HttpApiDeletionStarted="http-api-deletion-started",l.HttpApiDeletionCompleted="http-api-deletion-completed",l.HttpApiDeletionFailed="http-api-deletion-failed",l.WaitingForPreviousHttpApiDeletion="waiting-for-previous-http-api-deletion",l.BusinessLogicCodebaseDeploymentStarted="business-logic-codebase-deployment-started",l.BusinessLogicCodebaseDeploymentCompleted="business-logic-codebase-deployment-completed",l.BusinessLogicCodebaseDeploymentFailed="business-logic-codebase-deployment-failed",l.BundlingCodebaseForDownload="bundling-codebase-for-download",l.UploadingCodebaseToCloudStorage="uploading-codebase-to-cloud-storage",l.UploadingCodebaseToCloudStorageCompleted="uploading-codebase-to-cloud-storage-completed",l.UploadingCodebaseToCloudStorageFailed="uploading-codebase-to-cloud-storage-failed",l.InfrastructureValuesCodebaseInterpolationStarted="infrastructure-values-codebase-interpolation-started",l.InfrastructureValuesCodebaseInterpolationCompleted="infrastructure-values-codebase-interpolation-completed",l.InfrastructureValuesCodebaseInterpolationFailed="infrastructure-values-codebase-interpolation-failed",l.CodeCompilationStarted="code-compilation-started",l.CodeCompilationCompleted="code-compilation-completed",l.CodeCompilationFailed="code-compilation-failed",l.BundleCodebaseStarted="bundle-codebase-started",l.BundleCodebaseCompleted="bundle-codebase-completed",l.BundleCodebaseFailed="bundle-codebase-failed",l.InstallingCodebaseDependenciesStarted="installing-codebase-dependencies-started",l.InstallingCodebaseDependenciesCompleted="installing-codebase-dependencies-completed",l.InstallingCodebaseDependenciesFailed="installing-codebase-dependencies-failed",l.MigrateRelationalDatabaseStarted="migrate-relational-database-started",l.MigrateRelationalDatabaseCompleted="migrate-relational-database-completed",l.MigrateRelationalDatabaseFailed="migrate-relational-database-failed",l.ExecutePublicationCompletedEventStarted="execute-publication-completed-event-started",l.ExecutePublicationCompletedEventCompleted="execute-publication-completed-event-completed",l.ExecutePublicationCompletedEventFailed="execute-publication-completed-event-failed",l.ExecutePublicationCompletedEventTimedOut="execute-publication-completed-event-timed-out",l.AWSTenantAccountProvisioningStarted="aws-tenant-account-provisioning-started",l.AWSTenantAccountProvisioningCompleted="aws-tenant-account-provisioning-completed",l.AWSTenantAccountProvisioningFailed="aws-tenant-account-provisioning-failed",l))(Kt||{}),Sl=(l=>(l.CodeCompilation="code-compilation",l.RelationalDatabaseDeployment="relational-database-deployment",l.RelationalDatabaseDeletion="relational-database-deletion",l.HttpApiDeployment="http-api-deployment",l.HttpApiDeletion="http-api-deletion",l.InfrastructureValuesCodebaseInterpolation="infrastructure-values-codebase-interpolation",l.BundleCodebase="bundle-codebase",l.MigrateRelationalDatabase="migrate-relational-database",l.BusinessLogicCodebaseDeployment="business-logic-codebase-deployment",l.ExecutePublicationCompletedEvent="execute-publication-completed-event",l.CodebaseCleanup="codebase-cleanup",l.AWSTenantAccountProvisioning="aws-tenant-account-provisioning",l))(Sl||{});vr.CloudHostedCodebase,vr.HttpApi,vr.RelationalDatabase,vr.CloudHostedCodebase,vr.CloudHostedCodebase,vr.RelationalDatabase,vr.CloudHostedCodebase,vr.CloudHostedCodebase;function OBe(l){return`project-${l}-http-api`}function E1(l){return`entity-${l}-database`}class _Be{constructor(p,i,r,a,c,e,f,h,m){R(this,"stepType");R(this,"id");R(this,"resourceType");R(this,"index");R(this,"dependency",[]);R(this,"lastEvent",null);R(this,"lastEventTimestamp",null);R(this,"status",nf.Queued);R(this,"publicationRun");R(this,"resource");this.stepType=p,this.id=i,this.resourceType=r,this.status=a,this.dependency=c,this.index=e,this.lastEventTimestamp=f,this.publicationRun=h,this.resource=m}toJSON(){return{stepType:this.stepType,id:this.id,resourceType:this.resourceType,index:this.index,status:this.status,dependency:this.dependency,lastEvent:this.lastEvent,resource:{resourceId:this.resource.resourceId,resourceType:this.resource.resourceType,provider:this.resource.provider,details:this.resource.details,status:this.resource.status,name:this.resource.name}}}async update(p){var i,r;this.status=p.status,this.dependency=p.dependency,this.index=p.index,this.stepType=p.stepType,this.resourceType=p.resourceType,this.lastEvent=p.lastEvent,this.id=p.id,(r=this.resource)==null||r.setDetails((i=p.resource)==null?void 0:i.details)}}var VBe=(l=>(l.Ready="ready",l.Provisioning="provisioning",l.Queued="queued",l.ProvisioningFailed="provisioning-failed",l.Deleting="deleting",l.DeletingFailed="deleting-failed",l.Deleted="deleted",l))(VBe||{});class Dc{constructor(p,i,r){R(this,"provisionedBy");R(this,"publicationRun");R(this,"resourceType");R(this,"provider");R(this,"resourceId");R(this,"details",null);R(this,"name",null);R(this,"status","queued");this.publicationRun=p,this.resourceType=i,this.provider=r}setDetails(p){this.details=p}setStatus(p){this.status=p}setProvisionedBy(p){this.provisionedBy=p}}class vRi extends Dc{constructor(i,r,a){super(i,vr.HttpEndpoint,a);R(this,"resourceType",vr.HttpEndpoint);R(this,"owners",new Map);R(this,"details",null);R(this,"status","queued");r.forEach(c=>{this.owners.set(c.id,c)}),this.resolveDeterministicResourceId()}resolveDeterministicResourceId(){var i,r;return this.resourceId=E1((r=(i=Array.from(this.owners.values()))==null?void 0:i[0])==null?void 0:r.id),this.resourceId}}class ERi extends Dc{constructor(i,r,a){super(i,vr.ServerlessFunction,a);R(this,"resourceType",vr.ServerlessFunction);R(this,"owners",new Map);R(this,"details",null);R(this,"status","queued");r.forEach(c=>{this.owners.set(c.id,c)}),this.resolveDeterministicResourceId()}resolveDeterministicResourceId(){var i,r;return this.resourceId=E1((r=(i=Array.from(this.owners.values()))==null?void 0:i[0])==null?void 0:r.id),this.resourceId}}class PBe extends Dc{constructor(i,r,a){super(i,vr.HttpApi,a);R(this,"resourceType",vr.HttpApi);R(this,"owners",new Map);R(this,"details",null);R(this,"status","queued");r.forEach(c=>{this.owners.set(c.id,c)}),this.resolveDeterministicResourceId()}resolveDeterministicResourceId(){return this.resourceId=OBe(this.publicationRun.project.id),this.resourceId}}class NBe extends Dc{constructor(i,r,a){super(i,vr.RelationalDatabase,a);R(this,"resourceType",vr.RelationalDatabase);R(this,"owners",new Map);R(this,"details",null);R(this,"status","queued");r.forEach(c=>{this.owners.set(c.id,c)}),this.resolveDeterministicResourceId()}resolveDeterministicResourceId(){var i,r;return this.resourceId=E1((r=(i=Array.from(this.owners.values()))==null?void 0:i[0])==null?void 0:r.id),this.resourceId}}class xBe extends Dc{constructor(i,r){super(i,vr.CloudHostedCodebase,r);R(this,"resourceType",vr.CloudHostedCodebase);R(this,"details",null);R(this,"status","queued");this.resolveDeterministicResourceId()}resolveDeterministicResourceId(){return this.resourceId=`cloud-hosted-codebase--${this.publicationRun.project.id}--${this.publicationRun.project.version}`,this.resourceId}}class $Be extends Dc{constructor(i,r){super(i,vr.CompiledLocalCodebase,r);R(this,"resourceType",vr.CompiledLocalCodebase);R(this,"details",null);R(this,"status","queued");this.resolveDeterministicResourceId()}resolveDeterministicResourceId(){return this.resourceId=`compiled-codebase--${this.publicationRun.project.id}--${this.publicationRun.project.version}--${this.publicationRun.id}`,this.resourceId}}class bRi extends Dc{constructor(i,r){super(i,vr.AWSTenantAccount,r);R(this,"resourceType",vr.AWSTenantAccount);R(this,"status","queued");this.resolveDeterministicResourceId()}resolveDeterministicResourceId(){return this.resourceId=`aws-tenant-account--${this.publicationRun.project.id}`,this.resourceId}}class ARi{constructor(p,i){R(this,"id");R(this,"projectAutoIncrementPublicationCount");R(this,"projectPublishedSemanticVersion");R(this,"projectVersion");R(this,"projectId");R(this,"triggeredBy");R(this,"createdAt");R(this,"updatedAt");R(this,"status");R(this,"steps",[]);R(this,"editor");R(this,"explicitResources",new Map);R(this,"implicitGlobalResources",new Map);R(this,"finalGlobalEvent",null);R(this,"finalStatus",null);R(this,"contextType",ae.PublicationRun);R(this,"extensionsRegistry");this.id=p.id,this.projectAutoIncrementPublicationCount=p.projectAutoIncrementPublicationCount,this.projectPublishedSemanticVersion=p.projectPublishedSemanticVersion,this.projectVersion=p.projectVersion,this.projectId=p.projectId,this.triggeredBy=p.triggeredBy,this.createdAt=p.createdAt,this.updatedAt=p.updatedAt,this.status=p.status,this.editor=i,this.initRegistry()}get off(){return this.extensionsRegistry.off}get on(){return this.extensionsRegistry.on}get emit(){return this.extensionsRegistry.emit}get emitAsync(){return this.extensionsRegistry.emitAsync}get emitAsyncAll(){return this.extensionsRegistry.emitAsyncAll}get emitAsyncAllSettled(){return this.extensionsRegistry.emitAsyncAllSettled}get emitAsyncSequentially(){return this.extensionsRegistry.emitAsyncSequentially}get emitAsyncSequentiallyAll(){return this.extensionsRegistry.emitAsyncSequentiallyAll}get emitAsyncSequentiallyAllSettled(){return this.extensionsRegistry.emitAsyncSequentiallyAllSettled}get project(){return this.editor.project}getInfraTypes(p){return this.steps.filter(i=>p.includes(i.resourceType))}getStepsTypes(p){return this.steps.filter(i=>p.includes(i.stepType))}toIds(p){return p.map(i=>i.id)}getResourceForEntity(p){const i=Array.from(this.explicitResources.values()).find(r=>r.owners.has(p.id));return i||null}async init(){await this.initResources()}async initResources(){this.implicitGlobalResources.set(vr.CompiledLocalCodebase,new $Be(this,DT.Amazon)),this.implicitGlobalResources.set(vr.CloudHostedCodebase,new xBe(this,DT.Amazon));const p=this.project.entities.filter(r=>ai(r,Ie.HTTP_ENDPOINT)),i=this.project.entities.filter(r=>ai(r,Ie.RELATIONAL_DATABASE));if(i.length&&i.forEach(r=>{const a=new NBe(this,[r],DT.Amazon);this.explicitResources.set(a.resourceId,a)}),p.length){const r=new PBe(this,p,DT.Amazon);this.explicitResources.set(r.resourceId,r)}}setSteps(p,i){p.forEach(r=>{this.addStep(r,i)}),this.editor.events.emit(Kt.ProjectPublishRequestAcknowledged,{})}addStep(p,i){const r=p.dependency||[];if(r.length){const c=r.filter(e=>!this.steps.find(f=>f.id===e));if(c.length)throw new Error(`Missing dependencies: ${c.join(", ")}`)}if(!this.steps.find(c=>c.id===p.id)){const c=new _Be(p.stepType,p.id,p.resourceType,p.status,r,p.index,i,this,null);this.steps.push(c)}}onUpdate(p){var i;if(Y.Logger.log("onUpdate",p),(i=p.payload)!=null&&i.stepType){const r=this.steps.find(a=>{var c;return a.id===((c=p.payload)==null?void 0:c.id)});r&&B(p.emittedAt).isAfter(B(r.lastEventTimestamp))&&r.update(p.payload)}this.editor.events.emit("publication-updated",{}),p.type===$_.Error?(this.finalStatus=L_.Failed,this.finalGlobalEvent=p.event,this.editor.events.emit("project-publication-error",p)):p.type===$_.Complete&&(this.finalStatus=L_.Success,this.finalGlobalEvent=p.event,this.editor.events.emit("project-publication-completed",p))}requestExtension(p){return this.extensionsRegistry.requestExtension(p)}async initRegistry(){return this.extensionsRegistry=new Yx(this.editor.events),await this.extensionsRegistry.setup(),this.extensionsRegistry.onResolvePublicationRunContext(()=>this),await this.extensionsRegistry.contextAvailable(ae.PublicationRun),this.extensionsRegistry}}function IRi(l){switch(l){case Sl.CodeCompilation:return"Code generation";case Sl.RelationalDatabaseDeployment:return"Database creation";case Sl.HttpApiDeployment:return"HTTP gateway creation";case Sl.InfrastructureValuesCodebaseInterpolation:return"Link code with resources";case Sl.BundleCodebase:return"Bundle code";case Sl.MigrateRelationalDatabase:return"Database structure migration";case Sl.BusinessLogicCodebaseDeployment:return"Update servers with new code";case Sl.CodebaseCleanup:return"Code cleanup";case Sl.HttpApiDeletion:return"HTTP gateway deletion";case Sl.RelationalDatabaseDeletion:return"Database deletion";default:return"Publication finished"}}function gRi(l){switch(l){case Kt.DeploymentCompleted:return"Successfully published";case Kt.DeploymentStarted:return"Publication started";case Kt.DeploymentFailed:return"Publication failed";case Kt.AllInfrastructureSuccessfullyProvisioned:return"All infrastructure successfully provisioned";case Kt.RequestPayloadValidationFailed:return"Request payload validation failed";case Kt.ProjectStateValidationFailedMissingName:return"Project state validation failed: missing name";case Kt.ProjectStateValidationFailedMissingAnyFunctionality:return"Project state validation failed: missing any functionality";case Kt.RelationalDatabaseDeploymentStarted:return"Database creation started";case Kt.RelationalDatabaseDeploymentCompleted:return"Database creation completed";case Kt.RelationalDatabaseDeploymentFailed:return"Database creation failed";case Kt.CreatingNewRelationalDatabase:return"Creating new database (up to 5 mins)";case Kt.WaitingForPreviousRelationalDatabaseDeployment:return"Waiting for previous database creation";case Kt.RelationalDatabaseAlreadyExists:return"Database already exists";case Kt.HttpApiDeploymentStarted:return"HTTP gateway creation started";case Kt.HttpApiDeploymentCompleted:return"HTTP gateway creation completed";case Kt.HttpApiDeploymentFailed:return"HTTP gateway creation failed";case Kt.CreatingNewHttpApi:return"Creating new HTTP gateway";case Kt.HttpApiAlreadyExists:return"HTTP gateway already exists";case Kt.BusinessLogicCodebaseDeploymentStarted:return"Update servers with new code started";case Kt.BusinessLogicCodebaseDeploymentCompleted:return"Update servers with new code completed";case Kt.BusinessLogicCodebaseDeploymentFailed:return"Update servers with new code failed";case Kt.BundlingCodebaseForDownload:return"Bundling code for download";case Kt.UploadingCodebaseToCloudStorage:return"Uploading code to cloud storage";case Kt.InfrastructureValuesCodebaseInterpolationStarted:return"Linking code with resources started";case Kt.InfrastructureValuesCodebaseInterpolationCompleted:return"Linking code with resources completed";case Kt.InfrastructureValuesCodebaseInterpolationFailed:return"Linking code with resources failed";case Kt.CodeCompilationStarted:return"Code generation started";case Kt.CodeCompilationCompleted:return"Code generation completed";case Kt.CodeCompilationFailed:return"Code generation failed";case Kt.BundleCodebaseStarted:return"Code bundling started";case Kt.BundleCodebaseCompleted:return"Code bundling completed";case Kt.BundleCodebaseFailed:return"Code bundling failed";case Kt.InstallingCodebaseDependenciesStarted:return"Installing code dependencies";case Kt.InstallingCodebaseDependenciesCompleted:return"Installing code dependencies completed";case Kt.InstallingCodebaseDependenciesFailed:return"Installing code dependencies failed";case Kt.MigrateRelationalDatabaseStarted:return"Database structure migration started";case Kt.MigrateRelationalDatabaseCompleted:return"Database structure migration completed";case Kt.MigrateRelationalDatabaseFailed:return"Database structure migration failed";case Kt.ProjectAlreadyBeingPublished:return"Project already being published. You need to wait for the previous publication to complete";case Kt.ProjectPublishRequestAcknowledged:return"Project publish request acknowledged";case Kt.UploadingCodebaseToCloudStorageCompleted:return"Uploading code to cloud storage completed";case Kt.UploadingCodebaseToCloudStorageFailed:return"Uploading code to cloud storage failed";case Kt.BillingSubscriptionUpdateFailed:return"Billing subscription update failed";case Kt.ProjectNotFound:return"Project not found";case Kt.HttpApiDeletionCompleted:return"HTTP gateway deletion completed";case Kt.HttpApiDeletionFailed:return"HTTP gateway deletion failed";case Kt.HttpApiDeletionStarted:return"HTTP gateway deletion started";case Kt.PublicationStepFailedReasonUnknown:return"Publication step failed: reason unknown";case Kt.WaitingForPreviousHttpApiDeletion:return"Waiting for previous HTTP gateway deletion";case Kt.RelationalDatabaseDeletionStarted:return"Database deletion started";case Kt.RelationalDatabaseDeletionCompleted:return"Database deletion completed";case Kt.RelationalDatabaseDeletionFailed:return"Database deletion failed";case Kt.WaitingForPreviousRelationalDatabaseDeletion:return"Waiting for previous database deletion"}return"Unknown event"}var LBe=(l=>(l.NO_LOGIC="NO_LOGIC",l.NO_NAME="NO_NAME",l.NO_CHANGES="NO_CHANGES",l.PROJECT_PUBLICATION_ALREADY_ONGOING="PROJECT_PUBLICATION_ALREADY_ONGOING",l))(LBe||{});function RRi(l){switch(l){case"NO_LOGIC":return"This project has no logic";case"NO_NAME":return"This project has no name";case"NO_CHANGES":return"This version has already been published";case"PROJECT_PUBLICATION_ALREADY_ONGOING":return"This project is already being published";default:return"Publishing is currently not available. Try again later"}}function DRi(l){switch(l){case vr.RelationalDatabase:return"Relational database";case vr.HttpEndpoint:case vr.HttpApi:return"HTTP endpoints";case vr.ServerlessFunction:case vr.CloudHostedCodebase:return"Server code functions";default:return"Resources"}}function wRi(l){switch(l){case nf.Running:return"In progress";case nf.Failed:return"Failed";case nf.Success:return"Succeeded";case nf.Skipped:return"Skipped";case nf.Queued:default:return"Queued"}}function BBe(l){var r;if(!ai(l,Ie.EXTERNAL_INTEGRATION_CONNECTION))return null;let p=null;const i=ne["built-in-base-entity"].BUILT_IN_EXTERNAL_INTEGRATION_CONNECTION_ENTITY.properties.integration.id;if(l.type===d.BuiltInBaseEntity?ai(l,Ie.EXTERNAL_INTEGRATION_CONNECTION)&&(p=B_(l.name)):l.type===d.DefinitionEntity&&l.implements.forEach(a=>{if(ai(a,Ie.EXTERNAL_INTEGRATION_CONNECTION)){const c=B_(a==null?void 0:a.name);if(c)return p=c,!0}}),!p){const a=l.properties.find(c=>!!c.implements.find(e=>e.id===i)||!!c.implements.find(e=>{var f;return((f=e.extends)==null?void 0:f.id)===i}));p=(r=a==null?void 0:a.getDefaultValue())==null?void 0:r.value}return p}function CRi(l){return I0e[l]}function B_(l){return l.includes("BUILT_IN_EXTERNAL_INTEGRATION_CONNECTION_")?l.replace("BUILT_IN_EXTERNAL_INTEGRATION_CONNECTION_","").toLocaleLowerCase().replace("_auth",""):null}function MBe(l){if(l.type!==d.ActionDescriptor&&l.type!==d.Operation)throw new Error("Only ActionDescriptorState or OperationState can be used to resolve an external integration ID");if(l.type===d.ActionDescriptor){const p=l;if(p.id.startsWith("external-integration--"))return p.id.split("--")[1]}if(l.type===d.Operation){const p=l.declaration;if(Object.values(fi).includes(p.id))return p.id.split("--")[1]||null}return null}function ORi(l){if(!l)throw new Error("The integrationName parameter is required to resolve the base built-in name.");return Object.values(Ie).find(i=>!!(i.startsWith("BUILT_IN_EXTERNAL_INTEGRATION_CONNECTION_")&&i.endsWith("_AUTH")&&i.replace("BUILT_IN_EXTERNAL_INTEGRATION_CONNECTION_","").replace("_AUTH","").toLowerCase()===l.toLowerCase()))||null}function _Ri(l){return l.type===d.BuiltInBaseEntity||l.type===d.DefinitionEntity?BBe(l):l.type===d.ActionDescriptor||l.type===d.Operation?MBe(l):null}function GBe(l){var a,c,e;if(!ai(l,Ie.EXTERNAL_INTEGRATION_CONNECTION))return null;let p=null;const i=uFe(l,Ie.EXTERNAL_INTEGRATION_CONNECTION);if(!i)return null;const r=ne["built-in-base-entity"][i.id].properties.connectionId.id;if(l.type===d.BuiltInBaseEntity){if(ai(l,Ie.EXTERNAL_INTEGRATION_CONNECTION)){const f=l.properties.find(h=>{var m;return((m=h.extends)==null?void 0:m.id)===r});f&&(p=(a=f.getDefaultValue())==null?void 0:a.value)}}else if(l.type===d.DefinitionEntity){const f=l.properties.find(h=>!!h.implements.find(m=>m.id===r)||!!h.implements.find(m=>{var E;return((E=m.extends)==null?void 0:E.id)===r}));if(!f&&((c=l.extends)==null?void 0:c.type)===d.DefinitionEntity)return GBe(l.extends);p=(e=f==null?void 0:f.getDefaultValue())==null?void 0:e.value}return p}async function jBe(l,p={}){var f;const i=Y.YieldTracker.from(p),a=[...ya(l),...vn(l),...a$(l),...ha(l),...s$(l)],c=ME(l);a.push(...c);const e=qt(l.errors,a);await i.tick();for(const h of l.inputs)await h.validateAsync({tracker:i});for(const h of l.outputs)await h.validateAsync({tracker:i});for(const h of l.internalCalls)await h.validateAsync({tracker:i});return await((f=l.dataType)==null?void 0:f.validateAsync({tracker:i})),e}function kBe(l){var a;(a=l.dataType)==null||a.validate(),l.inputs.forEach(c=>c.validate()),l.outputs.forEach(c=>c.validate()),l.internalCalls.forEach(c=>c.validate());const i=[...ya(l),...vn(l),...a$(l),...ha(l),...s$(l)],r=ME(l);return i.push(...r),qt(l.errors,i)}function a$(l,p){const r=[...l.project.getVariableDeclarations()].filter(a=>a.id!==l.id);return jE(l,[Qi],r,p)}function s$(l){const p=[];if(l.parent!==l.project)return p;if(l.catchesError){const i=It({id:`${l.id}--${Ce.GlobalVariableDeclarationCannotCatchError}`,message:`${is[l.type].singular} "${le(l,l.project)}" with id "${l.id}" cannot catch an error because it is globally declared. Global variable declarations must crash the project if an error occurs.`,severity:Te.Error,code:Ce.GlobalVariableDeclarationCannotCatchError,entity:l});p.push(i.error)}if(l.errorCalls.length){const i=It({id:`${l.id}--${Ce.GlobalVariableDeclarationCannotCallOnError}`,message:`${is[l.type].singular} "${le(l,l.project)}" with id "${l.id}" cannot call other entities from its error branch because it is globally declared. Global variable declarations must crash the project if an error occurs.`,severity:Te.Error,code:Ce.GlobalVariableDeclarationCannotCallOnError,entity:l});p.push(i.error)}if(l.calledBy.length){const i=It({id:`${l.id}--${Ce.GlobalVariableDeclarationCannotBeCalled}`,message:`${is[l.type].singular} "${le(l,l.project)}" with id "${l.id}" cannot be called because it is globally declared. Global variable declarations must be self initialized when the project is loaded, and not be called for initialization.`,severity:Te.Error,code:Ce.GlobalVariableDeclarationCannotBeCalled,entity:l});p.push(i.error)}return[]}const VRi=Object.freeze(Object.defineProperty({__proto__:null,validate:kBe,validateAsync:jBe,validateGlobalVariableDeclaration:s$,validateVariableDeclarationName:a$},Symbol.toStringTag,{value:"Module"}));async function UBe(l,p={}){const i=Y.YieldTracker.from(p),a=[...ya(l),...vn(l),...ha(l),...Jo(l),...KBe(l)],c=ME(l);a.push(...c);const e=qt(l.errors,a);await i.tick();for(const f of l.inputs)await f.validateAsync({tracker:i});for(const f of l.outputs)await f.validateAsync({tracker:i});for(const f of l.internalCalls)await f.validateAsync({tracker:i});return e}function FBe(l){l.inputs.forEach(a=>a.validate()),l.outputs.forEach(a=>a.validate()),l.internalCalls.forEach(a=>a.validate());const i=[...ya(l),...vn(l),...ha(l)],r=ME(l);return i.push(...r),qt(l.errors,i)}function KBe(l){const p=[],i=l.declaration.constant;if(i&&l.readsValue){const r=It({id:`${l.id}--${be.ValueReadingOverridesConstantVariable}`,message:`The '${l.type}' entity "${le(l,l.project)}" with id "${l.id}" is a constant variable whose value cannot be overriden, but reads a value.`,severity:Te.Error,code:be.ValueReadingOverridesConstantVariable,entity:l});p.push(r.error)}if(i&&l.defaultValue){const r=It({id:`${l.id}--${be.DefaultValueOverridesConstantVariable}`,message:`The '${l.type}' entity "${le(l,l.project)}" with id "${l.id}" is a constant variable whose value cannot be overridden, but has a 'defaultValue'.`,severity:Te.Error,code:be.DefaultValueOverridesConstantVariable,entity:l});p.push(r.error)}return p}function Jo(l){var h;const p=[],i=l.declaration;if((i==null?void 0:i.id)===((h=l.parent)==null?void 0:h.id)||!l.calledBy.length&&!l.successCalls.length&&!l.errorCalls.length&&l.usedInternalCalls.length)return p;const r=pt(l),a=pt(i);!!r.find(m=>m.id===i.id)&&p.push(It({id:`${l.id}--${be.CalledBeforeDeclaration}`,code:be.CalledBeforeDeclaration,severity:Te.Error,message:`Entity of type "${l.type}" with id "${l.id}" is called before its 'variable-declaration' '${i.name}' with id "${i.id}".
55
55
  The 'variable-declaration' must be called before any internal call that references it can be called.`,entity:l}).error);const e=Gt(i,l.project),f=Gt(l,l.project);if((e==null?void 0:e.type)!==d.Project&&e&&f){const m=!!a.find(E=>E.id===l.id);if((e==null?void 0:e.id)===(f==null?void 0:f.id))m||p.push(It({id:`${l.id}--${be.CalledInParallelBranchToDeclaration}`,code:be.CalledInParallelBranchToDeclaration,severity:Te.Error,message:`Entity of type "${l.type}" with id "${l.id}" is called in a parallel branch to its 'variable-declaration' '${i.name}' with id "${i.id}".
56
56
  The 'variable-declaration' must be called in a different branch that executes before any internal call that references it can be called.`,entity:l}).error);else if($a(f,e,l.project))p.push(It({id:`${l.id}--${be.HigherScopeThanDeclaration}`,code:be.HigherScopeThanDeclaration,severity:Te.Error,message:`Entity of type "${l.type}" with id "${l.id}" is called in a higher scope than its 'variable-declaration' '${i.name}' with id "${i.id}".
57
57
  The 'variable-declaration' must be called in the same scope or in a higher scope than any internal call that references it.`,entity:l}).error);else if($a(e,f,l.project)){let E=f;for(;E.id!==e.id&&E.id!==l.project.id;){const A=Gt(E,l.project);if(A.id===e.id)break;E=A}const b=Gm(E);if(b){const _=!!pt(b).find(V=>V.id===i.id),N=!!a.find(V=>V.id===b.id);_?p.push(It({id:`${l.id}--${be.CalledBeforeDeclaration}`,code:be.CalledBeforeDeclaration,severity:Te.Error,message:`Entity of type "${l.type}" with id "${l.id}" is called before its 'variable-declaration' '${i.name}' with id "${i.id}".
@@ -71,7 +71,7 @@ This variable's data-type 'entity' is a ${r.type} which doesn't have any methods
71
71
  Built-in entity types can't have methods attached to them by the user. They are predefined entities that can't be modified. You can reference them as the 'declaration' property on a new 'internal-call' entity in a variable`):r.type===d.DefinitionEntity?e=`
72
72
  This variable's data-type 'entity' is a definition entity which extends or implements a non-interactive 'built-in-base-entity'.s`:r.type===d.BuiltInBaseEntity&&(e=`
73
73
  This variable's data-type 'entity' is a non-interactive 'built-in-base-entity'.s`),!l.declaration)p.push(It({id:`${l.id}--${Ce.InternalCallDeclarationNotFound}`,code:Ce.InternalCallDeclarationNotFound,severity:Te.Error,message:`Entity of type "${l.type}" with id "${l.id}" doesn't have a declaration method ('${d.FunctionDeclaration}' or '${d.ActionDescriptor}') attached to it.${e}`,entity:l}).error);else{const f=c.find(h=>h.id===l.declaration.id);f?f.type!==d.FunctionDeclaration&&f.type!==d.ActionDescriptor&&p.push(It({id:`${l.id}--${Ce.InternalCallDeclarationIsInvalidType}`,code:Ce.InternalCallDeclarationIsInvalidType,severity:Te.Error,message:`Entity of type "${l.type}" with id "${l.id}", points to a 'declaration' that isn't a '${d.FunctionDeclaration}' or '${d.ActionDescriptor}' entity.
74
- The declaration of the internal-call must be a '${d.FunctionDeclaration}' entity which exists as a method in the entity of the data-type of the parent variable.${e}`,entity:l}).error):p.push(It({id:`${l.id}--${Ce.InternalCallDeclarationNotFoundInParentDatatypeEntity}`,code:Ce.InternalCallDeclarationNotFoundInParentDatatypeEntity,severity:Te.Error,message:`Entity of type "${l.type}" with id "${l.id}", belongs to a variable whose data type entity doesn't contain its declaration method ('${d.FunctionDeclaration}' or '${d.ActionDescriptor}') with id "${l.declaration}".${e}`,entity:l}).error)}}return p}function Qo(l){var h;const p=[],i=Tr(l.parent);if((i==null?void 0:i.id)===((h=l.parent)==null?void 0:h.id)||!l.calledBy.length&&l.successCalls.length&&l.errorCalls.length)return p;const r=pt(l),a=pt(i);!!r.find(m=>m.id===i.id)&&p.push(It({id:`${l.id}--${be.CalledBeforeDeclaration}`,code:be.CalledBeforeDeclaration,severity:Te.Error,message:`Entity of type "${l.type}" with id "${l.id}" is called before its 'variable-declaration' '${i.name}' with id "${i.id}".
74
+ The declaration of the internal-call must be a '${d.FunctionDeclaration}' entity which exists as a method in the entity of the data-type of the parent variable.${e}`,entity:l}).error):p.push(It({id:`${l.id}--${Ce.InternalCallDeclarationNotFoundInParentDatatypeEntity}`,code:Ce.InternalCallDeclarationNotFoundInParentDatatypeEntity,severity:Te.Error,message:`Entity of type "${l.type}" with id "${l.id}", belongs to a variable whose data type entity doesn't contain its declaration method ('${d.FunctionDeclaration}' or '${d.ActionDescriptor}') with id "${l.declaration}".${e}`,entity:l}).error)}}return p}function Qo(l){var h;const p=[],i=Tr(l.parent);if((i==null?void 0:i.id)===((h=l.parent)==null?void 0:h.id)||!l.calledBy.length&&!l.successCalls.length&&!l.errorCalls.length)return p;const r=pt(l),a=pt(i);!!r.find(m=>m.id===i.id)&&p.push(It({id:`${l.id}--${be.CalledBeforeDeclaration}`,code:be.CalledBeforeDeclaration,severity:Te.Error,message:`Entity of type "${l.type}" with id "${l.id}" is called before its 'variable-declaration' '${i.name}' with id "${i.id}".
75
75
  The 'variable-declaration' must be called before any internal call that references it can be called.`,entity:l}).error);const e=Gt(i,l.project),f=Gt(l,l.project);if((e==null?void 0:e.type)!==d.Project&&e&&f){const m=!!a.find(E=>E.id===l.id);if((e==null?void 0:e.id)===(f==null?void 0:f.id))m||p.push(It({id:`${l.id}--${be.CalledInParallelBranchToDeclaration}`,code:be.CalledInParallelBranchToDeclaration,severity:Te.Error,message:`Entity of type "${l.type}" with id "${l.id}" is called in a parallel branch to its 'variable-declaration' '${i.name}' with id "${i.id}".
76
76
  The 'variable-declaration' must be called in a different branch that executes before any internal call that references it can be called.`,entity:l}).error);else if($a(f,e,l.project))p.push(It({id:`${l.id}--${be.HigherScopeThanDeclaration}`,code:be.HigherScopeThanDeclaration,severity:Te.Error,message:`Entity of type "${l.type}" with id "${l.id}" is called in a higher scope than its 'variable-declaration' '${i.name}' with id "${i.id}".
77
77
  The 'variable-declaration' must be called in the same scope or in a higher scope than any internal call that references it.`,entity:l}).error);else if($a(e,f,l.project)){let E=f;for(;E.id!==e.id&&E.id!==l.project.id;){const A=Gt(E,l.project);if(A.id===e.id)break;E=A}const b=Gm(E);if(b){const _=!!pt(b).find(V=>V.id===i.id),N=!!a.find(V=>V.id===b.id);_?p.push(It({id:`${l.id}--${be.CalledBeforeDeclaration}`,code:be.CalledBeforeDeclaration,severity:Te.Error,message:`Entity of type "${l.type}" with id "${l.id}" is called before its 'variable-declaration' '${i.name}' with id "${i.id}".
@@ -536,7 +536,7 @@ This is likely an incorrect strategy, either the '${this.type}' entity doesn't n
536
536
  You can inspect the existing 'entity' field with the 'describe_entity' action. Like so:
537
537
  ${rp({describe_entity:A.entity.id})}
538
538
  Alternatively you can update the parent data-type entity with 'update' action to remove the existing value of the field.`}))}return{errors:e,explanations:c,modifiedData:a}}get interactive(){return this.implements.length?this.implements.every(i=>i.interactive):!0}get allMethods(){return C([...this.ownDeclaredMethods,...this.allBaseMethodsFromOriginalParents])}get allProperties(){return C([...this.ownDeclaredProperties,...this.allBasePropertiesFromOriginalParents])}get allBaseMethodsFromOriginalParents(){var a;const i=((a=this.extends)==null?void 0:a.type)===d.DefinitionEntity?this.extends.allMethods:[],r=[...i].filter(c=>!i.some(e=>{var f,h;return e.id!==c.id&&(((f=e.implements)==null?void 0:f.id)===c.id||((h=e.extends)==null?void 0:h.id)===c.id)}));return C([...r,...this.implements.flatMap(c=>{const e=c.type===d.DefinitionEntity?[...c.allMethods]:[];return[...e].filter(h=>!e.some(m=>{var E,b;return m.id!==h.id&&(((E=m.implements)==null?void 0:E.id)===h.id||((b=m.extends)==null?void 0:b.id)===h.id)}))})])}get allBasePropertiesFromOriginalParents(){var c;const i=((c=this.extends)==null?void 0:c.allProperties)||[],r=[...i].filter(e=>!i.some(f=>{var h;return f.id!==e.id&&(!!f.implements.find(m=>m.id===e.id)||((h=f.extends)==null?void 0:h.id)===e.id)}));return C([...r,...this.implements.flatMap(e=>{const f=[...e.allProperties];return[...f].filter(m=>!f.some(E=>{var b;return E.id!==m.id&&(!!E.implements.find(A=>A.id===m.id)||((b=E.extends)==null?void 0:b.id)===m.id)}))})])}get allBasePropertiesFromExtendedAndImplementedEntities(){var c,e;const i=[...((c=this.extends)==null?void 0:c.ownDeclaredProperties)||[],...((e=this.extends)==null?void 0:e.allBasePropertiesFromExtendedAndImplementedEntities)||[]].filter(f=>!f.abstract),r=[...i].filter(f=>!i.some(h=>{var m;return h.id!==f.id&&(!!h.implements.find(E=>E.id===f.id)||((m=h.extends)==null?void 0:m.id)===f.id)})),a=this.implements.reduce((f,h)=>{const m=h.implementedPropertiesFromOriginalParents,E=[...h.ownDeclaredProperties].filter(_=>!_.abstract),b=[...m,...E,...f];return[...b].filter(_=>!!!b.find(V=>{var j;return!!V.implements.find(M=>M.id===_.id)||((j=V.extends)==null?void 0:j.id)===_.id}))},[]);return C([...r,...a])}get allBaseMethodsFromExtendedAndImplementedEntities(){return C([...(this.extends?[this.extends]:[]).reduce((i,r)=>r.type!==d.DefinitionEntity?[]:[...[...r.ownDeclaredMethods,...r.allBaseMethodsFromExtendedAndImplementedEntities].filter(c=>c.type!==d.ActionDescriptor),...i],[]),...this.implements.reduce((i,r)=>r.type!==d.DefinitionEntity?r.abstractMethods:[...[...r.ownDeclaredMethods,...r.allBaseMethodsFromExtendedAndImplementedEntities].filter(c=>c.type!==d.ActionDescriptor),...i],[])])}get extendedPropertiesFromOriginalParents(){var a,c;const i=[...((a=this.extends)==null?void 0:a.ownDeclaredProperties)||[],...((c=this.extends)==null?void 0:c.extendedPropertiesFromOriginalParents)||[]].filter(e=>!e.abstract),r=[...i].filter(e=>!i.some(f=>{var h;return f.id!==e.id&&(!!f.implements.find(m=>m.id===e.id)||((h=f.extends)==null?void 0:h.id)===e.id)}));return C(r)}get implementedPropertiesFromOriginalParents(){return C([...(this.extends?[this.extends]:[]).reduce((i,r)=>{const a=r.implementedPropertiesFromOriginalParents,c=[...r.ownDeclaredProperties].filter(h=>!!h.abstract),e=[...a,...c,...i];return[...e].filter(h=>!!!e.find(E=>{var b;return((b=E.extends)==null?void 0:b.id)===h.id||!!E.implements.find(A=>A.id===h.id)}))},[]),...this.implements.reduce((i,r)=>{const a=r.implementedPropertiesFromOriginalParents,c=[...r.ownDeclaredProperties].filter(h=>!!h.abstract),e=[...a,...c,...i];return[...e].filter(h=>!!!e.find(E=>{var b;return!!E.implements.find(A=>A.id===h.id)||((b=E.extends)==null?void 0:b.id)===h.id}))},[])].filter(i=>!!i.abstract))}get extendedMethodsFromOriginalParents(){return C((this.extends?[this.extends]:[]).reduce((i,r)=>{if(r.type!==d.DefinitionEntity)return[];const a=[...r.ownDeclaredMethods,...r.extendedMethodsFromOriginalParents].filter(c=>c.type!==d.ActionDescriptor);return[...i,...a]},[]))}get implementedMethodsFromOriginalParents(){return C([...(this.extends?[this.extends]:[]).reduce((i,r)=>{const a=r.type===d.DefinitionEntity?r.methods:[],c=[...r.abstractMethods].filter(e=>!a.find(f=>f.name===e.name));return[...a,...c,...i]},[]),...this.implements.reduce((i,r)=>[...r.abstractMethods,...i],[])].filter(i=>i.type===d.ActionDescriptor))}get extendedProperties(){return this.properties.filter(i=>i.isExtendedProperty)}get ownDeclaredProperties(){return this.properties.filter(r=>!r.isExtendedProperty)}get extendedMethods(){return this.methods.filter(i=>i.isExtendedMethod)}get ownDeclaredMethods(){return this.methods.filter(i=>!i.isExtendedMethod)}validateGeneratedUpdate(i){const r=[],a=[];return i.parent&&r.push(new De({id:`${this.id}--${he.InvalidParentUpdate}`,code:he.InvalidParentUpdate,severity:Te.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated. The 'parent' on an '${this.type}', must be the root project as it is a globally declared entity.`})),{errors:r,explanations:a,modifiedData:i}}subscribeDependents(i){return i.forEach(r=>{this.detachedDependents[r.entity.id]||(this.detachedDependents[r.entity.id]=r)}),this}unsubscribeDependents(i){return i.forEach(r=>{this.detachedDependents[r.entity.id]&&delete this.detachedDependents[r.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-dependents"))){const r=[],a=[],c=[],e=[];return Object.values(this.detachedDependents).forEach(f=>{const h=f.entity.afterAllChildrenInitialized(i);r.push(...h.updated),a.push(...h.added),c.push(...h.removed),e.push(...h.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}onDetachedDependencyRemoved(i,r,a){const c=[],e=[],f=[],h=[];return r==="implements"&&(this.removeImplementation(i,a),c.push(this)),r==="extends"&&(this.setExtension(null,a),c.push(this)),{updated:C(c),added:C(e),removed:C(f),affected:C(h),self:this}}onDetachedDependencyRestored(i,r,a){const c=[],e=[],f=[],h=[];return r==="implements"&&(this.addImplementation(i,a),c.push(this)),r==="extends"&&(this.setExtension(i,a),c.push(this)),{updated:C(c),added:C(e),removed:C(f),affected:C(h),self:this}}unsubscribeFromDependencies(){return this.implements.forEach(i=>{oa.includes(i.type)||i.unsubscribeDependents([{entity:this,field:"implements"}])}),this.extends&&(oa.includes(this.extends.type)||this.extends.unsubscribeDependents([{entity:this,field:"extends"}])),this}subscribeToDependencies(){return this.implements.forEach(i=>{oa.includes(i.type)||i.subscribeDependents([{entity:this,field:"implements"}])}),this.extends&&(oa.includes(this.extends.type)||this.extends.subscribeDependents([{entity:this,field:"extends"}])),this}increaseVersion(i){var r;if(this.project.diggestedBuiltInBaseEntitiesIds.has(this.id))return this;if(i&&!B(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);if(i&&B(i).isSame(B(this.createdAt)))return this;if(!((r=this.knownVersions)!=null&&r.has(this.version))&&this.project.initialized)throw new Error(`The current ${this.type} ${this.id} version '${this.version}' is not captured in the 'knownVersions' map. Capture the current version before increasing it to avoid losing data.`);if(!this.activeVersion)throw new Error(`Only active versions can be increased. Entity with id '${this.id}' and version '${this.version}' is not active.`);return this.previousVersion=this.version,this.version=x.UUID.uuid(),this.createdAt=B(i).toISOString()||B().toISOString(),this}captureVersion(){var r;const i=((r=this.knownVersions)==null?void 0:r.get(this.version))||new _i(this,this.project);if(!this.activeVersion)throw new Error(`Only active versions can be captured. Entity of type ${this.type} with id '${this.id}' and version '${this.version}' is not active.`);if(this.version!==i.version)throw new Error(`Captured ${this.type} with id '${this.id}', version '${i.version}' does not match current entity version '${this.version}'.`);return this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map().set(this.version,i),this.apply(i),this}snapshot(){const i=new _i(this,this.project);return this.apply(i)}apply(i){const r=this.toMeta();return i.metaSync(r,null),i.properties=[...this.properties],i.methods=[...this.methods],i.abstractMethods=[...this.abstractMethods],i.extends=this.extends,i.implements=[...this.implements],i.allPropertiesImplement=this.allPropertiesImplement,i.additionalPropertiesDataType=this.additionalPropertiesDataType,i.parent=this.parent,i}recursiveCaptureUpstreamVersions(i){const r=[],a=[],c=[],e=[];if(this.parent){this.parent.increaseVersion(i);const f=this.parent.recursiveCaptureUpstreamVersions(i);r.push(this.parent,...f.updated),a.push(...f.added),c.push(...f.removed)}return{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}async restoreVersion(i,r){var m;const a=[],c=[],e=[],f=[];if(this.version===i&&(r!=null&&r.skipIfSameVersion))return{updated:C(a),added:C(c),removed:C(e),affected:C(f),self:this};if(!this.knownVersions){const E=new Map;for(const[b,A]of this.knownVersions||new Map){if(E.set(b,A),A.activeVersion=!1,A.knownVersions)for(const[_,N]of A.knownVersions)E.set(_,N);A.knownVersions=null}}let h=(m=this.knownVersions)==null?void 0:m.get(i);if(!h){const E=await this.APILoadVersion({},i);if(!E)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);h=new _i(E,this.project)}return this.metaSync(h.toShallowJSON(),null),this.previousVersion=h.previousVersion,this.version=h.version,this.createdAt=h.createdAt,this.author=h.author,this.deleted=h.deleted,this.properties=[...h.properties],this.methods=[...h.methods],this.abstractMethods=[...h.abstractMethods],this.extends=h.extends,this.implements=[...h.implements],this.allPropertiesImplement=h.allPropertiesImplement,this.additionalPropertiesDataType=h.additionalPropertiesDataType,this.parent=h.parent,{updated:C(a),added:C(c),removed:C(e),affected:C(f),self:this}}updateWithShallowTransfer(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.UpdateWithShallowTransfer))){if(!this.checkCanEdit(this,r))return Y.Logger.warn(`[updateWithShallowTransfer] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),this;if(this.metaSync(i,r),this.version=i.version,this.createdAt=i.createdAt,this.author=i.author,this.deleted=i.deleted,this.previousVersion=i.previousVersion,this.unsubscribeFromDependencies(),i.parent){const f=te(i.parent),h=this.project.get(f),m=this.parent;if(m&&m.id!==(h==null?void 0:h.id)&&this.removeFromParent(r),h)this.setParent(h,r),this.addSelfToProject(r);else throw r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${f}' that isn't found in the project`)}else throw r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(i.extends){const f=te(i.extends),h=this.project.get(f);h&&this.setExtension(h,r)}else this.setExtension(null,r);if(i.implements.forEach(f=>{const h=te(f),m=this.project.get(h);if(m)this.addImplementation(m,r);else throw new Error(`${dr(this.type)} with id '${this.id}' has a 'implements' reference "${h}" which is missing in the project`)}),this.implements.filter(f=>{const h=te(f);return!i.implements.find(m=>te(m)===h)}).forEach(f=>{this.removeImplementation(f,r)}),i.methods.forEach(f=>{const h=te(f),m=this.project.get(h);m&&this.addMethod(m,r)}),this.methods.filter(f=>{const h=te(f);return!i.methods.find(m=>te(m)===h)}).forEach(f=>{this.removeMethod(f,r)}),i.properties.forEach(f=>{const h=te(f),m=this.project.get(h);m&&this.addProperty(m,r)}),this.properties.filter(f=>{const h=te(f);return!i.properties.find(m=>te(m)===h)}).forEach(f=>{this.removeProperty(f,r)}),i.allPropertiesImplement){const f=te(i.allPropertiesImplement),h=this.project.get(f);h&&this.setAllPropertiesImplement(h,r)}else this.setAllPropertiesImplement(null,r);if(i.additionalPropertiesDataType){const f=te(i.additionalPropertiesDataType),h=this.project.get(f);h&&this.setAdditionalPropertiesDataType(h,r)}else this.setAdditionalPropertiesDataType(null,r);return this.captureVersion(),this.subscribeToDependencies(),r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),this}updateWithGenerationTarget(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.UpdateWithGenerationTarget))){var a;if(!this.checkCanEdit(this,r))return Y.Logger.warn(`[updateWithGenerationTarget] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.UpdateWithGenerationTarget,this.id),this;if(this.metaSync(i,r),i.parent){const c=te(i.parent),e=this.project.get(c),f=this.parent;if(f&&f.id!==(e==null?void 0:e.id)&&this.removeFromParent(r),e)this.setParent(e,r),this.addSelfToProject(r);else throw r==null||r.attemptAutoclose(w.UpdateWithGenerationTarget,this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${c}' that isn't found in the project`)}if(i.extends){const c=te(i.extends),e=this.project.get(c);if(e)this.setExtension(e,r);else throw new Error(`${dr(this.type)} with id '${this.id}' has an 'extends' reference "${c}" which is missing in the project`)}else i.extends===null&&this.setExtension(null,r);return(a=i.implements)==null||a.forEach(c=>{const e=te(c),f=this.project.get(e);if(f)this.addImplementation(f,r);else throw new Error(`${dr(this.type)} with id '${this.id}' has a 'implements' reference "${e}" which is missing in the project`)}),i.implements&&this.implements.filter(e=>{const f=te(e);return!(i.implements||[]).find(h=>te(h)===f)}).forEach(e=>{this.removeImplementation(e,r)}),this.captureVersion(),this.subscribeToDependencies(),r==null||r.attemptAutoclose(w.UpdateWithGenerationTarget,this.id),this}hydrateAncestors(){const i=[],r=[],a=[],c=[];if(this.initialData.parent){const e=te(this.initialData.parent),f=this.project.get(e);if(f)this.setParent(f,null),i.push(f);else throw new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${e}' that isn't found in the project`)}else throw new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(this.initialData.extends){const e=te(this.initialData.extends),f=this.project.get(e);f&&(this.setExtension(f,null),f.type!==d.BuiltInBaseEntity&&i.push(f))}return this.initialData.implements.forEach(e=>{const f=te(e),h=this.project.get(f);if(h)this.addImplementation(h,null),h.type!==d.BuiltInBaseEntity&&i.push(h);else throw new Error(`${dr(this.type)} with id '${this.id}' has a 'implements' reference "${f}" which is missing in the project`)}),{updated:C(i),added:C(r),removed:C(a),affected:C(c),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AfterAllChildrenInitialized))){if(!this.checkCanEdit(this,i))return Y.Logger.warn(`[afterAllChildrenInitialized] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.AfterAllChildrenInitialized,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const r=[],a=[],c=[],e=[];this.initialized=!0;const{updated:f,added:h,removed:m,affected:E}=this.syncImplementationProperties(i);r.push(...f),a.push(...h),c.push(...m),e.push(...E);const{updated:b,added:A,removed:_,affected:N}=this.addExtendedProperties(i);r.push(...b),a.push(...A),c.push(..._),e.push(...N);const{updated:V,added:j,removed:M}=this.removeUnrecognizedProperties(i);r.push(...V),a.push(...j),c.push(...M);const{updated:G,added:q,removed:re,affected:ee}=this.syncImplementationMethods(i);r.push(...G),a.push(...q),c.push(...re),e.push(...ee);const{updated:de,added:ie,removed:se,affected:ue}=this.addExtendedMethods(i);r.push(...de),a.push(...ie),c.push(...se),e.push(...ue);const{updated:z,added:X,removed:ce}=this.removeUnrecognizedMethods(i);r.push(...z),a.push(...X),c.push(...ce),this.addSuggestions(),this.properties.sort((me,ve)=>me.index-ve.index);const oe=this.project.getDefinitionEntities(new Set([this.id]));if(oe.some(me=>me.id!==this.id&&me.name.toLowerCase()===this.name.toLowerCase())){const me=hh(this.name,oe);this.metaSync({name:me},i)}return i==null||i.attemptAutoclose(w.AfterAllChildrenInitialized,this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}addSelfToProject(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"add-self-to-project"))){const r=[this],a=[],c=[],e=[];if(this.parent.type===d.DataType){const f=this.parent;f.entity=this,r.push(f)}else this.project.addDefinitionEntity(this);return this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}setParent(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.SetParent))){var a;return this.checkCanEditWithCounterpartAndSideEffects(this,i,w.SetParent,r)?(((a=this.parent)==null?void 0:a.id)!==(i==null?void 0:i.id)&&(this.parent=i,r&&(r==null||r.add(this,W.Updated))),r==null||r.attemptAutoclose(w.SetParent,this.id),this):this}setExtension(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.SetExtension))){var a;return this.checkCanEdit(this,r)?(((a=this.extends)==null?void 0:a.id)!==(i==null?void 0:i.id)&&(this.extends=i,this.subscribeToDependencies(),r&&(r==null||r.add(this,W.Updated))),r==null||r.attemptAutoclose(w.SetExtension,this.id),this):(Y.Logger.warn(`[setExtension] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.SetExtension,this.id),this)}addImplementation(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AddImplementation))){return this.checkCanEdit(this,r)?(this.implements.includes(i)||(this.implements.push(i),this.subscribeToDependencies(),r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose(w.AddImplementation,this.id),this):(Y.Logger.warn(`[addImplementation] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.AddImplementation,this.id),this)}removeImplementation(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveImplementation))){return this.checkCanEdit(this,r)?(this.implements.includes(i)&&(this.implements=this.implements.filter(a=>a.id!==i.id),r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose(w.RemoveImplementation,this.id),this):(Y.Logger.warn(`[removeImplementation] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.RemoveImplementation,this.id),this)}removeProperty(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveProperty))){return this.checkCanEdit(this,r)?(this.properties.includes(i)&&(this.properties=this.properties.filter(a=>a.id!==i.id),r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose(w.RemoveProperty,this.id),this):(Y.Logger.warn(`[removeProperty] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.RemoveProperty,this.id),this)}addMethod(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AddMethod))){return this.checkCanEdit(this,r)?(this.methods.includes(i)||(this.methods.push(i),this.suggestedMethods=this.suggestedMethods.filter(a=>a.name!==i.name),r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose(w.AddMethod,this.id),this):(Y.Logger.warn(`[addMethod] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.AddMethod,this.id),this)}removeMethod(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveMethod))){return this.checkCanEdit(this,r)?(this.methods.includes(i)&&(this.methods=this.methods.filter(a=>a.id!==i.id),r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose(w.RemoveMethod,this.id),this):(Y.Logger.warn(`[removeMethod] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.RemoveMethod,this.id),this)}addProperty(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AddProperty))){return this.checkCanEdit(this,r)?(this.properties.includes(i)||(this.properties.push(i),this.suggestedProperties=this.suggestedProperties.filter(a=>a.name!==i.name),r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose(w.AddProperty,this.id),this):(Y.Logger.warn(`[addProperty] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.AddProperty,this.id),this)}addSuggestedProperty(i){return this.suggestedProperties.includes(i)||this.suggestedProperties.push(i),this}addSuggestedMethod(i){return this.suggestedMethods.includes(i)||this.suggestedMethods.push(i),this}removeSuggestedProperty(i){return this.suggestedProperties=this.suggestedProperties.filter(r=>r.id!==i.id),this}removeSuggestedMethod(i){return this.suggestedMethods=this.suggestedMethods.filter(r=>r.id!==i.id),this}addAbstractMethod(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.AddAbstractMethod))){return this.checkCanEdit(this,r)?(this.abstractMethods.includes(i)||(this.abstractMethods.push(i),r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose(w.AddAbstractMethod,this.id),this):(Y.Logger.warn(`[addAbstractMethod] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.AddAbstractMethod,this.id),this)}removeAbstractMethod(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveAbstractMethod))){return this.checkCanEdit(this,r)?(this.abstractMethods.includes(i)&&(this.abstractMethods=this.abstractMethods.filter(a=>a.id!==i.id),r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose(w.RemoveAbstractMethod,this.id),this):(Y.Logger.warn(`[removeAbstractMethod] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.RemoveAbstractMethod,this.id),this)}initChildren(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"init-children"))){if(this.initialized||this.startedInitialization)return this;if(this.startedInitialization=!0,this.properties=this.initialData.properties.map(r=>{const a=Ae(r,this.project);return a.setParent(this,null),a.initChildren(i),a}),this.methods=this.initialData.methods.map(r=>{const a=Ae(r,this.project);return a.setParent(this,null),a.initChildren(i),a}),this.abstractMethods=this.initialData.abstractMethods.map(r=>{const a=Ae(r,this.project);return a.setParent(this,null),a.initChildren(i),a}),this.initialData.extends&&(this.extends=Ae(this.initialData.extends,this.project)),this.implements=this.initialData.implements.map(r=>Ae(r,this.project)),this.initialData.allPropertiesImplement){const r=Ae(this.initialData.allPropertiesImplement,this.project);r.setParent(this,null),r.initChildren(null),this.setAllPropertiesImplement(r,i)}if(this.initialData.additionalPropertiesDataType){const r=Ae(this.initialData.additionalPropertiesDataType,this.project);r.setParent(this,null),r.initChildren(null),this.setAdditionalPropertiesDataType(r,i)}return this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this}removeUnrecognizedProperties(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"remove-unrecognized-properties"))){const r=[],a=[],c=[],e=[];let f=[...this.properties];f=f.filter(b=>b.parent.id===this.id),f=f.filter(b=>!b.isExtendedProperty);const h=this.implementedPropertiesFromOriginalParents,m=this.getAllPropertiesImplements();return f.filter(b=>this.interactive&&!b.implements.length?!1:!b.implements.find(_=>!!h.find(N=>N.id===_.id)||!!m.find(N=>N.id===_.id))).forEach(b=>{const A=b.remove({ignoreUpstream:!1},i);c.push(...A.removed),r.push(...A.updated)}),i==null||i.attemptAutoclose("remove-unrecognized-properties",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}removeUnrecognizedMethods(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"remove-unrecognized-methods"))){const r=[],a=[],c=[],e=[];let f=[...this.methods];f=f.filter(m=>m.parent.id===this.id),f=f.filter(m=>!m.isExtendedMethod);const h=this.implementedMethodsFromOriginalParents;return f=f.filter(m=>this.interactive&&!m.implements?!1:!h.find(E=>{var b;return E.id===((b=m.implements)==null?void 0:b.id)})),f.forEach(m=>{const E=m.remove({ignoreUpstream:!1},i);c.push(...E.removed),r.push(...E.updated)}),i==null||i.attemptAutoclose("remove-unrecognized-methods",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}syncImplementationMethods(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-implementation-methods"))){const r=[],a=[],c=[],e=[],f=this.methods,h=this.implementedMethodsFromOriginalParents,m=[...this.allBaseMethodsFromExtendedAndImplementedEntities,...f];return h.filter(b=>!m.find(_=>{var N;return((N=_.implements)==null?void 0:N.id)===b.id})).forEach(b=>{if(this.methods.find(V=>{var j;return((j=V.implements)==null?void 0:j.id)===b.id}))return;const _=this.methods.find(V=>{var re,ee;if(V.name===b.name&&!V.implements)return!0;const j=ai(this,Ie.CRON_JOB),M=ai(this,Ie.HTTP_ENDPOINT),G=((re=V.implements)==null?void 0:re.id)===ne["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.methods.handler.id,q=((ee=V.implements)==null?void 0:ee.id)===ne["built-in-base-entity"].BUILT_IN_CRON_JOB_ENTITY.methods.handler.id;return!!(j&&!q&&!M&&G||M&&!G&&!j&&q)});if(_&&_.type===d.FunctionDeclaration){_.setImplements(b,i),_.metaSync({name:b.name},i),i==null||i.add(_,W.Updated),i==null||i.add(this,W.Updated);return}const N=b.implementAsFunctionDeclaration(i,this);a.push(N),i==null||i.add(N,W.Added),this.addMethod(N,i)}),this.methods.sort((b,A)=>b.index-A.index).forEach(b=>{b.afterAllChildrenInitialized(i)}),i==null||i.attemptAutoclose("sync-implementation-methods",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}syncImplementationProperties(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-implementation-properties"))){const r=[],a=[],c=[],e=[],f=this.properties,h=this.implementedPropertiesFromOriginalParents.filter(E=>!this.allBasePropertiesFromExtendedAndImplementedEntities.find(A=>!!A.implements.find(_=>_.id===E.id))),m=[...this.allBasePropertiesFromExtendedAndImplementedEntities,...f];return h.forEach(E=>{const b=m.find(V=>!!V.implements.find(j=>j.id===E.id));if(b){const{updated:V,added:j,removed:M,affected:G}=b.syncWithImplementation(i);r.push(...V),a.push(...j),c.push(...M),e.push(...G);return}if(this.properties.find(V=>!!V.implements.find(j=>j.id===E.id)))return;const _=this.properties.find(V=>V.name===E.name&&!!V.abstract&&!V.implements);if(_){_.addImplementation(E,i),_.metaSync({abstract:!1},i),_.afterAllChildrenInitialized(i);return}const N=E.implement(this,i,x.UUID.uuid());a.push(N),i==null||i.add(N,W.Added)}),this.properties.find(E=>{var b;return E.id===((b=this.allPropertiesImplement)==null?void 0:b.id)})&&this.removeAllPropertiesImplement(i),i==null||i.attemptAutoclose("sync-implementation-properties",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}addExtendedMethods(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"add-extended-methods"))){const r=[],a=[],c=[],e=[],f=this.methods,m=this.extendedMethodsFromOriginalParents.filter(b=>b.type===d.FunctionDeclaration),E=new Set(f.filter(b=>{var A;return!!((A=b.extends)!=null&&A.id)}).map(b=>b.extends.id));return m.forEach(b=>{if(E.has(b.id))return;E.add(b.id);const A=b.clone(i,this,x.UUID.uuid());A.setExtends(b,i),A.initChildren(i),a.push(A),i==null||i.add(A,W.Added),this.addMethod(A,i)}),i==null||i.attemptAutoclose("add-extended-methods",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}addExtendedProperties(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"add-extended-properties"))){const r=[],a=[],c=[],e=[],f=this.properties,h=this.extendedPropertiesFromOriginalParents,m=h.filter(b=>h.find(_=>!!_.implements.find(N=>N.id===b.id))?!1:!b.abstract),E=new Set(f.filter(b=>{var A;return!!((A=b.extends)!=null&&A.id)}).map(b=>b.extends.id));return m.forEach(b=>{if(E.has(b.id))return;E.add(b.id);const A=b.clone(i,this,x.UUID.uuid());A.setExtends(b,i),A.initChildren(i),a.push(A),i==null||i.add(A,W.Added),this.addProperty(A,i)}),[...this.properties].forEach(b=>{if(b.extends)return;if(m.find(_=>_.name===b.name&&_.implements.every(N=>!!b.implements.find(V=>V.id===N.id)))){const _=b.remove({ignoreUpstream:!1},i);c.push(..._.removed),r.push(..._.updated)}}),this.properties.forEach(b=>{const A=b.afterAllChildrenInitialized(i);r.push(...A.updated),e.push(...A.affected),a.push(...A.added),c.push(...A.removed)}),i==null||i.attemptAutoclose("add-extended-properties",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}addSuggestions(){return this.implements.forEach(i=>{Yje(this,i).forEach(c=>{const e=c.toJSON();e.id=`_suggestion--parent--${this.id}--${c.id}`;const f=Ae(e,this.project);f.suggestion=!0,f.setParent(this,null),f.initChildren(null),this.addSuggestedProperty(f)}),Jje(this,i).forEach(c=>{const e=`_suggestion--parent--${this.id}--${c.id}`,f=c.implementAsFunctionDeclaration(null,this,e),h=Ae(f,this.project);if(h.suggestion=!0,h.setParent(this,null),h.initChildren(null),this.methods=this.methods.filter(m=>m.id!==e),h.inputs.forEach(m=>{m.suggestion=!0}),h.returnStatements.length){const m=h.returnStatements[0];m.suggestion=!0,m.outputs.forEach(E=>{E.suggestion=!0})}this.addSuggestedMethod(h)})}),this}subscribe(){var i;return this.activeVersion=!0,(i=this.knownVersions)==null||i.forEach(r=>{r.version!==this.version&&(r.activeVersion=!1)}),this.project.subscribeInstance(this),this.project.subscribedDefinitionEntities.add(this.id),this}unsubscribe(){return this.project.unsubscribeInstance(this),this.project.subscribedDefinitionEntities.delete(this.id),this}metaSync(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"meta-sync"))){const a=Yr(this,i,r),c=zr(this,a),e=this.toMeta();return this.name=a.name!==void 0?a.name:e.name,this.codeName=a.codeName!==void 0?a.codeName:e.codeName,this.description=a.description!==void 0?a.description:e.description,this.x=a.x||e.x,this.y=a.y||e.y,this.static=a.static!==void 0?a.static:this.static,this.abstract=a.abstract!==void 0?a.abstract:this.abstract,this.additionalProperties=a.additionalProperties!==void 0?a.additionalProperties:e.additionalProperties,super.baseMetaSync(a,this,r),a.deleted===!0&&!e.deleted?r==null||r.add(this,W.Removed):a.deleted===!1&&e.deleted?r==null||r.add(this,W.Added):c&&(r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=Ke,...r){return await _i.repository.APILoad(this.id,...r),this}async APICreate(i=Ke,...r){return await _i.repository.APICreate(this.toShallowJSON(),...r),this}async APIUpdate(i=Ke,...r){return await _i.repository.APIUpdate(this.toShallowJSON(),...r),this}async APIDelete(i=Ke,...r){return await _i.repository.APIDelete(this.toShallowJSON(),...r),this}async APIClone(i=Ke,...r){return await _i.repository.APIClone(this.id,...r),this}async APILoadVersion(i=Ke,r,...a){return await _i.repository.APILoadVersion(this.id,r,...a)}removeFromParent(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveFromParent))){if(!this.checkCanEdit(this,i))return Y.Logger.warn(`[removeFromParent] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.RemoveFromParent,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const r=[],a=[],c=[],e=[];if(this.parent.type===d.Project)this.parent.removeDefinitionEntity(this);else if(this.parent.type===d.DataType&&this.parent.entity&&this.parent.entity.id===this.id){const f=this.parent.setEntity(null,i);r.push(f)}return i==null||i.attemptAutoclose(w.RemoveFromParent,this.id),{added:C(c),updated:C(r),removed:C(a),affected:C(e),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveEntity))){var h;if(!this.checkCanDelete(this,r))return Y.Logger.warn(`[remove] User is not allowed to delete or edit this ${this.type} entity with id: ${this.id}`),r==null||r.event({id:`${w.RemoveEntity}-${this.id}--${Be.ActionOwnerEntityNonDeletable}`,action:w.RemoveEntity,owner:this,errorReason:Be.ActionOwnerEntityNonDeletable,rootAction:((h=r==null?void 0:r.self)==null?void 0:h.id)===this.id&&(r==null?void 0:r.autoCloseActionName)===w.RemoveEntity}),r==null||r.attemptAutoclose(w.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const a=[],c=[],e=[],f=[];if(r!=null&&r.hasRemoved(this.id))return r==null||r.attemptAutoclose(w.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(c.push(this),this.unsubscribe(),this.unsubscribeFromDependencies(),this.project.subscribeDeletedInstance(this),this.metaSync({deleted:!0},r),Object.values(this.detachedDependents).forEach(m=>{const{updated:E,removed:b,added:A}=m.entity.onDetachedDependencyRemoved(this,m.field,r);a.push(...E),c.push(...b),e.push(...A)}),this.properties.forEach(m=>{const{updated:E,removed:b}=m.remove({ignoreUpstream:!0},r);a.push(...E),c.push(...b)}),this.methods.forEach(m=>{const{updated:E,removed:b}=m.remove({ignoreUpstream:!0},r);a.push(...E),c.push(...b)}),this.abstractMethods.forEach(m=>{const{updated:E,removed:b}=m.remove({ignoreUpstream:!0},r);a.push(...E),c.push(...b)}),this.suggestedProperties.forEach(m=>{const{updated:E,removed:b}=m.remove({ignoreUpstream:!0},r);a.push(...E),c.push(...b)}),this.suggestedMethods.forEach(m=>{const{updated:E,removed:b}=m.remove({ignoreUpstream:!0},r);a.push(...E),c.push(...b)}),!i){const m=this.removeFromParent(r);e.push(...m.added),a.push(...m.updated),c.push(...m.removed),f.push(...m.affected)}return r==null||r.attemptAutoclose(w.RemoveEntity,this.id),{added:C(e),updated:C(a),removed:C(c),affected:C(f),self:this}}restore({}={},i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RestoreEntity))){if(!this.checkCanEdit(this,i))return Y.Logger.warn(`[restore] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const r=[],a=[],c=[],e=[];return i!=null&&i.hasAdded(this.id)?(i==null||i.attemptAutoclose(w.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this}):(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},i),Object.values(this.detachedDependents).forEach(f=>{const{updated:h,removed:m,added:E}=f.entity.onDetachedDependencyRestored(this,f.field,i);a.push(...h),c.push(...m),r.push(...E)}),this.properties.forEach(f=>{const{updated:h}=f.restore({},i);a.push(...h)}),this.methods.forEach(f=>{const{updated:h}=f.restore({},i);a.push(...h)}),this.abstractMethods.forEach(f=>{const{updated:h}=f.restore({},i);a.push(...h)}),this.suggestedProperties.forEach(f=>{const{updated:h}=f.restore({},i);a.push(...h)}),this.suggestedMethods.forEach(f=>{const{updated:h}=f.restore({},i);a.push(...h)}),i==null||i.attemptAutoclose(w.RestoreEntity,this.id),{added:C(r),updated:C(a),removed:C(c),affected:C(e),self:this})}toFlat(i=new Set){var a;return i.has(this.id)?[]:(i.add(this.id),[this,...((a=this.extends)==null?void 0:a.toFlat(i))||[],...this.implements.flatMap(c=>c.toFlat(i)),...this.properties.flatMap(c=>c.toFlat(i)),...this.methods.flatMap(c=>c.toFlat(i)),...this.abstractMethods.flatMap(c=>c.toFlat(i)),...this.parent.toFlat(i)])}toFlatIds(i=new Set){var a;return i.has(this.id)?[]:(i.add(this.id),[this.id,...((a=this.extends)==null?void 0:a.toFlatIds(i))||[],...this.implements.flatMap(c=>c.toFlatIds(i)),...this.properties.flatMap(c=>c.toFlatIds(i)),...this.methods.flatMap(c=>c.toFlatIds(i)),...this.abstractMethods.flatMap(c=>c.toFlatIds(i)),...this.parent.toFlatIds(i)])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,codeName:this.codeName,description:this.description,static:this.static,abstract:this.abstract,x:this.x,y:this.y,type:this.type,editable:this.editable,deletable:this.deletable,additionalProperties:this.additionalProperties,name:this.name}}toJSON(i=new Set){var r,a,c;return i.has(this.id)?this.toReference():(i.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name,codeName:this.codeName,description:this.description,x:this.x,y:this.y,static:this.static,abstract:this.abstract,additionalProperties:this.additionalProperties,allPropertiesImplement:((r=this.allPropertiesImplement)==null?void 0:r.toJSON(i))||null,additionalPropertiesDataType:((a=this.additionalPropertiesDataType)==null?void 0:a.toJSON(i))||null,properties:this.properties.map(e=>e.toJSON(i)),methods:this.methods.map(e=>e.toJSON(i)),abstractMethods:this.abstractMethods.map(e=>e.toJSON(i)),implements:this.implements.map(e=>e.toJSON(i)),extends:((c=this.extends)==null?void 0:c.toJSON(i))||null,parent:this.parent.toReference()})}toJSONClone(i=at){var a,c,e,f,h,m,E,b,A,_;let r;return(a=i.seenEntityMaps)!=null&&a.has(this.id)?r=i.seenEntityMaps.get(this.id):(r=i.newId||rn(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,r)),(c=i.seenEntities)!=null&&c.has(r)||(e=i.seenEntities)!=null&&e.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((f=i.seenEntities)==null||f.add(r),(h=i.seenEntities)==null||h.add(this.id),{id:r,version:x.UUID.uuid(),createdAt:i.timestamp||B().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name,codeName:this.codeName,description:this.description,x:this.x,y:this.y,static:this.static,abstract:this.abstract,additionalProperties:this.additionalProperties,allPropertiesImplement:((m=this.allPropertiesImplement)==null?void 0:m.toJSONClone(i))||null,additionalPropertiesDataType:((E=this.additionalPropertiesDataType)==null?void 0:E.toJSONClone(i))||null,properties:this.properties.map(N=>N.toJSONClone({...i,newId:null})),methods:this.methods.map(N=>N.toJSONClone({...i,newId:null})),abstractMethods:this.abstractMethods.map(N=>N.toJSONClone({...i,newId:null})),implements:this.implements.map(N=>N.type===d.BuiltInBaseEntity?N.toJSON(i.seenEntities):N.toJSONClone({...i,newId:null})),extends:((b=this.extends)==null?void 0:b.type)===d.BuiltInBaseEntity?(A=this.extends)==null?void 0:A.toJSON(i.seenEntities):(_=this.extends)==null?void 0:_.toJSONClone({...i,newId:null}),parent:this.parent.toReference({seenEntityMaps:i.seenEntityMaps})})}toReference(i=at){var a;let r=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r+"--"+x.UUID.uuid()+"--ref",type:d.GenericReference,entityId:r,version:this.version,entityType:this.type}}toShallowJSON(i=at){var a,c,e,f;let r=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,name:this.name,codeName:this.codeName,description:this.description,type:this.type,editable:this.editable,deletable:this.deletable,x:this.x,y:this.y,static:this.static,abstract:this.abstract,additionalProperties:this.additionalProperties,allPropertiesImplement:((c=this.allPropertiesImplement)==null?void 0:c.toReference(i))||null,additionalPropertiesDataType:((e=this.additionalPropertiesDataType)==null?void 0:e.toReference(i))||null,properties:this.properties.map(h=>h.toReference(i)),methods:this.methods.map(h=>h.toReference(i)),abstractMethods:this.abstractMethods.map(h=>h.toReference(i)),implements:this.implements.map(h=>h.toReference(i)),extends:((f=this.extends)==null?void 0:f.toReference(i))||null,parent:this.parent.toReference(i)}}toFlatJSON(i=new Set){var a,c,e;return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...this.properties.flatMap(f=>f.toFlatJSON(i)),...this.methods.flatMap(f=>f.toFlatJSON(i)),...this.abstractMethods.flatMap(f=>f.toFlatJSON(i)),...this.implements.flatMap(f=>f.toFlatJSON(i)),...((a=this.extends)==null?void 0:a.toFlatJSON(i))||[],...this.parent.toFlatJSON(i),...((c=this.additionalPropertiesDataType)==null?void 0:c.toFlatJSON(i))||[],...((e=this.allPropertiesImplement)==null?void 0:e.toFlatJSON(i))||[]])}toGenerationTarget(i=at){var c,e,f;const r=this.parent.type===d.Project?void 0:(c=i.seenEntityMaps)!=null&&c.has(this.parent.id)?i.seenEntityMaps.get(this.parent.id):this.parent.id;let a=this.id;return(e=i.seenEntityMaps)!=null&&e.has(this.id)&&(a=i.seenEntityMaps.get(this.id)),{id:a,name:this.name,description:this.description,type:this.type,static:this.static,abstract:this.abstract,extends:(f=this.extends)==null?void 0:f.id,additionalProperties:this.additionalProperties,implements:this.implements.map(h=>h.id),parent:r}}toFlatGenerationTarget(i=new Set){var a,c,e;return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...this.properties.flatMap(f=>f.toFlatGenerationTarget(i)),...this.methods.flatMap(f=>f.toFlatGenerationTarget(i)),...this.abstractMethods.flatMap(f=>f.toFlatGenerationTarget(i)),...this.implements.filter(f=>f.type===d.DefinitionEntity).flatMap(f=>f.toFlatGenerationTarget(i)),...((a=this.extends)==null?void 0:a.toFlatGenerationTarget(i))||[],...this.parent.toFlatGenerationTarget(i),...((c=this.additionalPropertiesDataType)==null?void 0:c.toFlatGenerationTarget(i))||[],...((e=this.allPropertiesImplement)==null?void 0:e.toFlatGenerationTarget(i))||[]])}clearErrors(){var i,r;return this.errors=[],this.properties.forEach(a=>a.clearErrors()),this.methods.forEach(a=>a.clearErrors()),this.abstractMethods.forEach(a=>a.clearErrors()),(i=this.additionalPropertiesDataType)==null||i.clearErrors(),(r=this.allPropertiesImplement)==null||r.clearErrors(),this}validate(){return this.errors=zje(this),{success:!0}}async validateAsync(i={}){const r=Y.YieldTracker.from(i);return this.errors=await Wje(this,{tracker:r}),{success:!0}}getErrors(){var r,a;return[...this.errors,...this.properties.flatMap(c=>c.getErrors()),...this.methods.flatMap(c=>c.getErrors()),...this.abstractMethods.flatMap(c=>c.getErrors()),...((r=this.additionalPropertiesDataType)==null?void 0:r.getErrors())||[],...((a=this.allPropertiesImplement)==null?void 0:a.getErrors())||[]]}async getErrorsAsync(i={}){const r=Y.YieldTracker.from(i),a=[...this.errors];await r.tick();for(const c of this.properties)a.push(...await c.getErrorsAsync({tracker:r}));for(const c of this.methods)a.push(...await c.getErrorsAsync({tracker:r}));for(const c of this.abstractMethods)a.push(...await c.getErrorsAsync({tracker:r}));return this.additionalPropertiesDataType&&a.push(...await this.additionalPropertiesDataType.getErrorsAsync({tracker:r})),this.allPropertiesImplement&&a.push(...await this.allPropertiesImplement.getErrorsAsync({tracker:r})),a}getShallowErrors(){return this.errors}clone(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.CloneEntity)),r=null,a=null,c=!0){var j,M,G;const e=Mr(r,this),f=this.toJSON(),h=a||x.UUID.uuid(),m=r||this.parent;f.properties=[],f.methods=[],f.abstractMethods=[];const E=h.split("-id"),b=E[E.length-1||0]||h;f.id=h,f.version=x.UUID.uuid(),f.createdAt=(i==null?void 0:i.timestamp)||B().toISOString(),f.author=(i==null?void 0:i.author)||"1",f.previousVersion=null,f.deleted=!1,f.editable=!0,f.deletable=!0,f.parent=m.toReference();const A=tr(f,e);A.hydrateAncestors(),A.setParent(m,i),c&&(A.subscribe(),A.addSelfToProject(i)),A.initChildren(i),i==null||i.add(A,W.Added);const _=(j=this.properties)==null?void 0:j.map(q=>this.project.diggestedBuiltInBaseEntitiesIds.has(q.id)?q:q.clone(i,A,x.UUID.uuid(),c));A.properties=_;const N=(M=this.methods)==null?void 0:M.map((q,re)=>this.project.diggestedBuiltInBaseEntitiesIds.has(q.id)?q:q.clone(i,A,b+"-method-"+re+"-id",c));A.methods=N;const V=(G=this.abstractMethods)==null?void 0:G.map((q,re)=>this.project.diggestedBuiltInBaseEntitiesIds.has(q.id)?q:q.clone(i,A,b+"-abstract-method-"+re+"-id",c));if(A.abstractMethods=V,this.additionalPropertiesDataType)if(this.project.diggestedBuiltInBaseEntitiesIds.has(this.additionalPropertiesDataType.id))A.setAdditionalPropertiesDataType(this.additionalPropertiesDataType,i);else{const q=this.additionalPropertiesDataType.clone(i,A,x.UUID.uuid(),c);A.setAdditionalPropertiesDataType(q,i)}if(this.allPropertiesImplement)if(this.project.diggestedBuiltInBaseEntitiesIds.has(this.allPropertiesImplement.id))A.setAllPropertiesImplement(this.allPropertiesImplement,i);else{const q=this.allPropertiesImplement.clone(i,A,x.UUID.uuid(),c);A.setAllPropertiesImplement(q,i)}return i||A.captureVersion(),i==null||i.attemptAutoclose(w.CloneEntity,this.id),A}getFunctionDeclaration(i){return this.methods.find(r=>r.id===i)}implement(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"implement-definition-entity")),a){const c=a1(this,i,r,a);return r==null||r.attemptAutoclose("implement-definition-entity",this.id),c}getAllPropertiesImplements(){var r;const i=[];return this.allPropertiesImplement&&i.push(this.allPropertiesImplement),i.push(...((r=this.extends)==null?void 0:r.getAllPropertiesImplements())||[],...this.implements.flatMap(a=>a.getAllPropertiesImplements())),i}getAllInteractiveMethods(){var e;const i=this.implements.filter(f=>f.type===d.DefinitionEntity||f.type===d.BuiltInBaseEntity&&f.interactive),r=((e=this.extends)==null?void 0:e.getAllInteractiveMethods())||[],a=i.flatMap(f=>f.getAllInteractiveMethods());return C([...this.methods,...r,...a])}inferFromInputs(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"infer-definition-entity-from-inputs"))){const a=[],c=[],e=[],f=[];if(this.parent.type!==d.DataType||!this.parent.inferred)return r==null||r.attemptAutoclose("infer-definition-entity-from-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};const h=[];i.forEach(b=>{h.find(_=>le(_,this.project)===le(b,this.project))||h.push(b)});const m=this.properties.filter(b=>!b.dataType);h.forEach(b=>{var G,q,re;const A=m.find(ee=>le(ee,this.project)===le(b,this.project));if(!A)return;const N=Tr(b.parent).getMasterInputWithValueWriterFromAllInstances(b),V=Sd(N,r),j=V==null?void 0:V.clone(r,A,x.UUID.uuid(),!0);j&&((G=A.dataType)==null||G.merge(j,r),j.id!==((q=A.dataType)==null?void 0:q.id)&&j.remove({ignoreUpstream:!1},r),A.dataType&&(A.dataType.metaSync({inferred:!0,like:!0},r),A.setDataType(A.dataType,r),r==null||r.add(A,W.Affected)));let M=null;if(b.declaration&&A.id!==((re=b.declaration)==null?void 0:re.id)&&(M=b.declaration),b.setDeclaration(A,r),r==null||r.add(b,W.Updated),M){const{updated:ee,removed:de}=M.remove({ignoreUpstream:!1},r);c.push(...ee),e.push(...de)}});const E=[];return h.forEach(b=>{if(!b.declaration){E.push(b);return}}),E.length===0?(r==null||r.attemptAutoclose("infer-definition-entity-from-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this}):(E.forEach(b=>{var re,ee,de,ie,se;const A=this.properties.find(ue=>le(ue,this.project)===le(b,this.project));if(A){if(b.setDeclaration(A,r),!A.getDataType(r)){const z=Tr(b.parent).getMasterInputWithValueWriterFromAllInstances(b),X=Sd(z),ce=X==null?void 0:X.clone(r,A,x.UUID.uuid(),!0);ce&&((re=A.dataType)==null||re.merge(ce,r),ce.id!==((ee=A.dataType)==null?void 0:ee.id)&&ce.remove({ignoreUpstream:!1},r),A.dataType&&(A.dataType.metaSync({inferred:!0,like:!0},r),A.setDataType(A.dataType,r),r==null||r.add(A,W.Affected)))}return}const _=le(b,this.project),N=b.codeName||pf(b,this.project)||Ps(Qi(_)),V=ps.new(r);V.parent=this.toReference(),V.index=b.index,V.name=_,V.codeName=N,V.description=b.description;const j=Ae(V,this.project);j.hydrateAncestors(),j.addSelfToProject(r),r==null||r.add(j,W.Added),j.setParent(this,r),j.initChildren(r),r||j.captureVersion();const G=Tr(b.parent).getMasterInputWithValueWriterFromAllInstances(b),q=Sd(G);if(q&&q.id!==((de=j.dataType)==null?void 0:de.id)){const ue=q==null?void 0:q.clone(r,j,x.UUID.uuid(),!0);ue&&((ie=j.dataType)==null||ie.merge(ue,r),ue.id!==((se=j.dataType)==null?void 0:se.id)&&ue.remove({ignoreUpstream:!1},r),j.dataType&&(j.dataType.metaSync({inferred:!0,like:!0},r),j.setDataType(j.dataType,r),r==null||r.add(j,W.Affected)))}return this.addProperty(j,r),b.setDeclaration(j,r),r==null||r.add(b,W.Updated),j}),r==null||r.attemptAutoclose("infer-definition-entity-from-inputs",this.id),{added:C(a),updated:C(c),removed:C(e),affected:C(f),self:this})}getRawDefaultValue(){const i={};return this.properties.forEach(r=>{var e;if(!HI(r))return;const a=le(r,this.project),c=r.codeName||pf(r,this.project)||Ps(Qi(a));i[c]=((e=r.getDefaultValue())==null?void 0:e.value)||null}),i}getActiveRawDefaultValue(){const i={};return this.properties.forEach(r=>{var f;if(!HI(r))return;const a=le(r,this.project),c=r.codeName||pf(r,this.project)||Ps(Qi(a)),e=(f=this.project.requestActiveDynamicValue(r,!0))==null?void 0:f.value;i[c]=(e==null?void 0:e.value)||null}),i}setAdditionalPropertiesDataType(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.SetAdditionalPropertiesDataType))){if(!this.checkCanEdit(this,r))return Y.Logger.warn(`[setAdditionalPropertiesDataType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.SetAdditionalPropertiesDataType,this.id),this;const a=this.additionalPropertiesDataType;return(a==null?void 0:a.id)!==(i==null?void 0:i.id)&&(a==null||a.remove({ignoreUpstream:!0},r),this.additionalPropertiesDataType=i,this.subscribeToDependencies(),r==null||r.add(this,W.Affected)),r==null||r.attemptAutoclose(w.SetAdditionalPropertiesDataType,this.id),this}removeAdditionalPropertiesDataType(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveAllPropertiesImplement))){return this.checkCanEdit(this,i)?(this.additionalPropertiesDataType&&(this.additionalPropertiesDataType.remove({ignoreUpstream:!0},i),i==null||i.add(this,W.Affected),this.additionalPropertiesDataType=null),i==null||i.attemptAutoclose(w.RemoveAllPropertiesImplement,this.id),this):(Y.Logger.warn(`[removeAdditionalPropertiesDataType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.RemoveAllPropertiesImplement,this.id),this)}setAllPropertiesImplement(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.SetAllPropertiesImplement))){if(!this.checkCanEdit(this,r))return Y.Logger.warn(`[setAllPropertiesImplement] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.SetAllPropertiesImplement,this.id),this;const a=this.allPropertiesImplement;return(a==null?void 0:a.id)!==(i==null?void 0:i.id)&&(a==null||a.remove({ignoreUpstream:!0},r),this.allPropertiesImplement=i,this.subscribeToDependencies(),r==null||r.add(this,W.Affected)),r==null||r.attemptAutoclose(w.SetAllPropertiesImplement,this.id),this}removeAllPropertiesImplement(i=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,w.RemoveAllPropertiesImplement))){return this.checkCanEdit(this,i)?(this.allPropertiesImplement&&(this.properties.find(r=>{var a;return r.id===((a=this.allPropertiesImplement)==null?void 0:a.id)})||this.allPropertiesImplement.remove({ignoreUpstream:!0},i),i==null||i.add(this,W.Affected),this.allPropertiesImplement=null),i==null||i.attemptAutoclose(w.RemoveAllPropertiesImplement,this.id),this):(Y.Logger.warn(`[removeAllPropertiesImplement] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(w.RemoveAllPropertiesImplement,this.id),this)}};R(_i,"repository",{APICreate:async(i,...r)=>i,APIUpdate:async(i,...r)=>i,APIDelete:async(i,...r)=>i,APIClone:async(i,...r)=>{},APILoad:async(i,...r)=>null,APILoadVersion:async(i,r,...a)=>null}),R(_i,"type",d.DefinitionEntity),R(_i,"USER_MANAGED_PARENT_TYPES",[d.Project,d.DataType]),R(_i,"PARENT_TYPES",[..._i.USER_MANAGED_PARENT_TYPES]),R(_i,"MUTABLE_BASE_PROPERTIES",["name","codeName","description","static","abstract","additionalProperties"]),R(_i,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),R(_i,"BASE_PROPERTIES",[..._i.MUTABLE_BASE_PROPERTIES,..._i.INMUTABLE_BASE_PROPERTIES]),R(_i,"MUTABLE_META_PROPERTIES",[..._i.MUTABLE_BASE_PROPERTIES,"x","y"]),R(_i,"INMUTABLE_META_PROPERTIES",[..._i.INMUTABLE_BASE_PROPERTIES]),R(_i,"META_PROPERTIES",[..._i.MUTABLE_META_PROPERTIES,..._i.INMUTABLE_META_PROPERTIES]),R(_i,"MUTABLE_UPSTREAM_PROPERTIES",["extends","implements"]),R(_i,"INMUTABLE_UPSTREAM_PROPERTIES",["parent"]),R(_i,"UPSTREAM_PROPERTIES",[..._i.MUTABLE_UPSTREAM_PROPERTIES,..._i.INMUTABLE_UPSTREAM_PROPERTIES]),R(_i,"MUTABLE_DOWNSTREAM_PROPERTIES",["properties","methods","abstractMethods","allPropertiesImplement","additionalPropertiesDataType"]),R(_i,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),R(_i,"DOWNSTREAM_PROPERTIES",[..._i.MUTABLE_DOWNSTREAM_PROPERTIES,..._i.INMUTABLE_DOWNSTREAM_PROPERTIES]),R(_i,"PROPERTIES",[..._i.META_PROPERTIES,..._i.UPSTREAM_PROPERTIES,..._i.DOWNSTREAM_PROPERTIES]);let Ls=_i;async function y_i(l,p={}){const i=Y.YieldTracker.from(p),r=[],a=qt(l.errors,r);return await i.tick(),a}function h_i(l){const p=[];return qt(l.errors,p)}const QI=class QI extends Ex{constructor(i,r){super(i);R(this,"initialData");R(this,"id");R(this,"name");R(this,"description",null);R(this,"type",d.PrimitiveEntity);R(this,"static");R(this,"abstract");R(this,"properties",[]);R(this,"methods",[]);R(this,"abstractMethods",[]);R(this,"extends",null);R(this,"errors",[]);R(this,"project");this.initialData=i,this.project=r,this.id=i.id,this.name=i.name,this.description=i.description,this.static=i.static,this.abstract=i.abstract,this.properties=this.initialData.properties.map(a=>{const c=Ae(a,this.project);return c.setParent(this,null),c.initChildren(null),c}),this.methods=this.initialData.methods.map(a=>{const c=Ae(a,this.project);return c.parent=this,c}),this.abstractMethods=this.initialData.abstractMethods.map(a=>{const c=Ae(a,this.project);return c.parent=this,c}),this.initialData.extends&&(this.extends=Ae(this.initialData.extends,this.project))}get allMethods(){return C([...this.ownDeclaredMethods,...this.allBaseMethodsFromOriginalParents])}get allProperties(){return C([...this.ownDeclaredProperties,...this.allBasePropertiesFromOriginalParents])}get allBaseMethodsFromOriginalParents(){var a;const i=((a=this.extends)==null?void 0:a.allMethods)||[],r=[...i].filter(c=>!i.some(e=>e.id!==c.id));return C(r)}get allBasePropertiesFromOriginalParents(){var a;const i=((a=this.extends)==null?void 0:a.allProperties)||[],r=[...i].filter(c=>!i.some(e=>{var f;return e.id!==c.id&&(e.implements.find(h=>h.id===c.id)||((f=e.extends)==null?void 0:f.id)===c.id)}));return C(r)}get allBasePropertiesFromExtendedAndImplementedEntities(){var a,c;const i=[...((a=this.extends)==null?void 0:a.ownDeclaredProperties)||[],...((c=this.extends)==null?void 0:c.allBasePropertiesFromExtendedAndImplementedEntities)||[]].filter(e=>!e.abstract),r=[...i].filter(e=>!i.some(f=>{var h;return f.id!==e.id&&(f.implements.find(m=>m.id===e.id)||((h=f.extends)==null?void 0:h.id)===e.id)}));return C(r)}get extendedPropertiesFromOriginalParents(){var a,c;const i=[...((a=this.extends)==null?void 0:a.ownDeclaredProperties)||[],...((c=this.extends)==null?void 0:c.extendedPropertiesFromOriginalParents)||[]].filter(e=>!e.abstract),r=[...i].filter(e=>!i.some(f=>{var h;return f.id!==e.id&&(f.implements.find(m=>m.id===e.id)||((h=f.extends)==null?void 0:h.id)===e.id)}));return C(r)}get implementedPropertiesFromOriginalParents(){return C([...(this.extends?[this.extends]:[]).reduce((i,r)=>{const a=r.implementedPropertiesFromOriginalParents,c=[...r.ownDeclaredProperties].filter(h=>!!h.abstract),e=[...a,...c,...i];return[...e].filter(h=>!!!e.find(E=>{var b;return((b=E.extends)==null?void 0:b.id)===h.id||E.implements.find(A=>A.id===h.id)}))},[])])}get extendedProperties(){return this.properties.filter(i=>i.isExtendedProperty)}get ownDeclaredMethods(){return[...this.methods]}get ownDeclaredProperties(){return this.properties.filter(i=>!i.isExtendedProperty)}subscribe(){return this.project.subscribeBuiltInInstance(this),this}unsubscribe(){return this.project.unsubscribeBuiltInInstance(this),this}async APILoad(i=Ke,...r){return await QI.repository.APILoad(this.id,...r),this}toFlat(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this,...this.properties.flatMap(a=>a.toFlat(i)),...this.methods.flatMap(a=>a.toFlat(i)),...this.abstractMethods.flatMap(a=>a.toFlat(i))])}toFlatIds(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.properties.flatMap(a=>a.toFlatIds(i)),...this.methods.flatMap(a=>a.toFlatIds(i)),...this.abstractMethods.flatMap(a=>a.toFlatIds(i))])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,description:this.description,static:this.static,abstract:this.abstract,type:this.type,name:this.name}}toJSON(i=new Set){var r;return i.has(this.id)?this.toReference():(i.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,static:this.static,abstract:this.abstract,properties:this.properties.map(a=>a.toJSON(i)),methods:this.methods.map(a=>a.toJSON(i)),abstractMethods:this.abstractMethods.map(a=>a.toJSON(i)),extends:((r=this.extends)==null?void 0:r.toJSON(i))||null})}toReference(i=at){return{id:this.id+"--"+x.UUID.uuid()+"--ref",type:d.GenericReference,entityId:this.id,version:this.version,entityType:this.type}}toShallowJSON(i=at){var r;return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,abstract:this.abstract,static:this.static,properties:this.properties.map(a=>a.toReference()),methods:this.methods.map(a=>a.toReference()),abstractMethods:this.abstractMethods.map(a=>a.toReference()),extends:((r=this.extends)==null?void 0:r.toReference())||null}}toFlatJSON(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...this.properties.flatMap(a=>a.toFlatJSON(i)),...this.methods.flatMap(a=>a.toFlatJSON(i)),...this.abstractMethods.flatMap(a=>a.toFlatJSON(i))])}toGenerationTarget(i=at){var r;return{id:this.id,type:this.type,name:this.name,description:this.description,static:this.static,abstract:this.abstract,extends:(r=this.extends)==null?void 0:r.id}}toFlatGenerationTarget(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...this.properties.flatMap(a=>a.toFlatGenerationTarget(i)),...this.methods.flatMap(a=>a.toFlatGenerationTarget(i)),...this.abstractMethods.flatMap(a=>a.toFlatGenerationTarget(i))])}clearErrors(){return this.errors=[],this.properties.forEach(i=>i.clearErrors()),this.methods.forEach(i=>i.clearErrors()),this.abstractMethods.forEach(i=>i.clearErrors()),this}validate(){return this.errors=h_i(this),{success:!0}}async validateAsync(i={}){const r=Y.YieldTracker.from(i);return this.errors=await y_i(this,{tracker:r}),{success:!0}}getErrors(){return[...this.errors,...this.properties.flatMap(r=>r.getErrors()),...this.methods.flatMap(r=>r.getErrors()),...this.abstractMethods.flatMap(r=>r.getErrors())]}async getErrorsAsync(i={}){const r=Y.YieldTracker.from(i),a=[...this.errors];await r.tick();for(const c of this.properties){const e=await c.getErrorsAsync({tracker:r});a.push(...e)}for(const c of this.methods){const e=await c.getErrorsAsync({tracker:r});a.push(...e)}for(const c of this.abstractMethods){const e=await c.getErrorsAsync({tracker:r});a.push(...e)}return a}getShallowErrors(){return this.errors}getAllInteractiveMethods(){const i=[];return i.push(...this.methods),!this.extends||this.extends.type===d.PrimitiveEntity?i:C(i)}};R(QI,"repository",{APILoad:async(i,...r)=>null});let xa=QI;function tr(l,p){if(!l)throw new Error("Entity is null");const i=p.get(l.id);switch(l.type){case d.LiteralValue:return i||new Vr(l,p);case d.DefinitionEntity:return i||new Ls(l,p);case d.PrimitiveEntity:return i||new xa(l,p);case d.FunctionDeclaration:return i||new ld(l,p);case d.GlobalEvent:return i||new Tp(l,p);case d.DataType:return i||new yr(l,p);case d.Property:return i||new ps(l,p);case d.FunctionCall:return i||new hp(l,p);case d.Condition:return i||new Ep(l,p);case d.Operation:return i||new mp(l,p);case d.VariableDeclaration:return i||new Ap(l,p);case d.VariableInstance:return i||new bp(l,p);case d.OutputMap:return i||new eo(l,p);case d.ArgumentDeclaration:return i||new Ga(l,p);case d.InputMap:return i||new ds(l,p);case d.Project:return i||new x(l);case d.InstalledProject:return i||new gp(l,p);case d.ActionDescriptor:return i||new Hi(l,p);case d.ReturnStatement:return i||new zd(l,p);case d.Loop:return i||new vp(l,p);case d.Search:return i||new Ip(l,p);case d.ValueDescriptor:return i||new ud(l,p);case d.BuiltInBaseEntity:return i||new od(l,p);case d.InternalCall:return i||new Rp(l,p);case d.ContinueStatement:return i||new wp(l,p);case d.BreakStatement:return i||new Dp(l,p);case d.GenericReference:return p.get(l.entityId);default:throw new Error("Invalid entity type: "+l.type)}}function Ae(l,p){if(!l)throw new Error("Entity is null");const i=tr(l,p);return i.subscribe(),i}function m_i(l,p,i){if(!l)throw new Error("Entity is null");switch(l.type){case d.LiteralValue:return Vr.fromGenerationTarget(l,p,i);case d.DefinitionEntity:return Ls.fromGenerationTarget(l,p,i);case d.FunctionDeclaration:return ld.fromGenerationTarget(l,p,i);case d.GlobalEvent:return Tp.fromGenerationTarget(l,p,i);case d.DataType:return yr.fromGenerationTarget(l,p,i);case d.Property:return ps.fromGenerationTarget(l,p,i);case d.FunctionCall:return hp.fromGenerationTarget(l,p,i);case d.Condition:return Ep.fromGenerationTarget(l,p,i);case d.Operation:return mp.fromGenerationTarget(l,p,i);case d.VariableDeclaration:return Ap.fromGenerationTarget(l,p,i);case d.VariableInstance:return bp.fromGenerationTarget(l,p,i);case d.OutputMap:return eo.fromGenerationTarget(l,p,i);case d.ArgumentDeclaration:return Ga.fromGenerationTarget(l,p,i);case d.InputMap:return ds.fromGenerationTarget(l,p,i);case d.InstalledProject:return gp.fromGenerationTarget(l,p,i);case d.ReturnStatement:return zd.fromGenerationTarget(l,p,i);case d.Loop:return vp.fromGenerationTarget(l,p,i);case d.Search:return Ip.fromGenerationTarget(l,p,i);case d.ActionDescriptor:return Hi.fromGenerationTarget(l,p,i);case d.ValueDescriptor:return ud.fromGenerationTarget(l,p,i);case d.InternalCall:return Rp.fromGenerationTarget(l,p,i);case d.ContinueStatement:return wp.fromGenerationTarget(l,p,i);case d.BreakStatement:return Dp.fromGenerationTarget(l,p,i);default:throw new Error("Invalid entity type: "+l.type)}}const at={seenEntityMaps:new Map,seenEntities:new Set,timestamp:B().toISOString()};class ike{constructor(){R(this,"initialData")}}const Ke={cascade:!1},rke={APILoad:async(l,...p)=>null},T_i={APICreate:async(l,...p)=>l,APIUpdate:async(l,...p)=>l,APIDelete:async(l,...p)=>l,APIClone:async(l,...p)=>{},APILoadVersion:async(l,p,...i)=>null,...rke};class v_i{}class nke extends ike{}class E_i extends nke{}class b_i{}class A_i{}class I_i{}class aL{}class g_i extends aL{}class R_i extends aL{}class D_i{}class Jf{static initReadsValue(p){if(p.initialData.readsValue&&p.initialData.readsValue.type!==d.GenericReference)p.readsValue=Ae(p.initialData.readsValue,p.project);else if(p.initialData.readsValue&&p.initialData.readsValue.type===d.GenericReference){const i=ma(p.initialData.readsValue,p.project);i&&(p.readsValue=i)}if(p.readsValue){if(xt.includes(p.readsValue.type)){let i=p.parent;!br.includes(i.type)&&i.type!==d.Project&&(i=i.parent);const r=p.type===d.InputMap&&p.parent.type===d.Loop;r&&(i=p.parent.parent),p.readsValue.setParent(i,null),p.readsValue.initChildren(null),i&&i.type!==d.Project&&!r&&i.detachedChildren.includes(p)?i.replaceDetachedChild(p,p.readsValue):i&&i.type!==d.Project&&!r&&i.subscribeDetachedChild(p.readsValue)}p.readsValue.addValueReader(p,null)}return p.readsValue}}class kE{static initWritesValues(p,i){const r=p.initialData.writesValues.reduce((c,e)=>{if(e.type===d.GenericReference||p.writesValues.some(h=>h.id===e.id))return c;const f=Ae(e,p.project);return f.setValueWriter(p,null),xt.includes(f.type)&&(f.setParent(i,null),f.initChildren(null)),[...c,f]},[]),a=[...p.writesValues];return p.writesValues=C([...a,...r]),p.writesValues}}class w_i{}var si=(l=>(l.PROJECT_INITIALIZED="project-initialized",l.BEFORE_CHANGE_SET_CLOSE_BEFORE_SIDE_EFFECTS="before-change-set-close-before-side-effects",l.BEFORE_CHANGE_SET_CLOSE_AFTER_SIDE_EFFECTS="before-change-set-close-after-side-effects",l.CHANGE_SET_CLOSED_BEFORE_PERSIST="change-set-closed-before-persist",l.CHANGE_SET_PERSISTED="change-set-persisted",l.BEFORE_CHANGE_SET_PERSIST="before-change-set-persist",l.EXPLICIT_DEFINITION_ENTITY_ADDED="explicit-definition-entity-added",l.EXPLICIT_DEFINITION_ENTITY_REMOVED="explicit-definition-entity-removed",l.EXPLICIT_DEFINITION_ENTITY_UPDATED="explicit-definition-entity-updated",l.PERSISTED_DEFINITION_ENTITY_ADDED="persisted-definition-entity-added",l.PERSISTED_DEFINITION_ENTITY_REMOVED="persisted-definition-entity-removed",l.PERSISTED_DEFINITION_ENTITY_UPDATED="persisted-definition-entity-updated",l.RELATIONAL_DATABASE_DEFINITION_ENTITY_ADDED="relational-database-definition-entity-added",l.RELATIONAL_DATABASE_DEFINITION_ENTITY_REMOVED="relational-database-definition-entity-removed",l.RELATIONAL_DATABASE_DEFINITION_ENTITY_UPDATED="relational-database-definition-entity-updated",l))(si||{});const sL={...Jx,events:new Y.Events("def-proj-static-p-ctx-events")},ake={requestActiveDynamicValue:(l,p=!1)=>null,...sL},$t=class $t extends nn{constructor(i,r={...ake,events:new Y.Events("def-proj-inst-p-ctx-events")}){super(i);R(this,"initialData");R(this,"id");R(this,"type",d.Project);R(this,"name",null);R(this,"description",null);R(this,"x");R(this,"y");R(this,"entities",[]);R(this,"projects",[]);R(this,"functions",[]);R(this,"events",[]);R(this,"variableDeclarations",[]);R(this,"variableInstances",[]);R(this,"conditions",[]);R(this,"operations",[]);R(this,"functionCalls",[]);R(this,"loops",[]);R(this,"searches",[]);R(this,"primitives",[]);R(this,"builtInBaseEntities",[]);R(this,"operationDeclarations",[]);R(this,"globalEventActionDescriptors",[]);R(this,"loopDeclarations",[]);R(this,"loopDeclarationsBodies",[]);R(this,"conditionDeclarations",[]);R(this,"valueDescriptors",[]);R(this,"dataTypes",[]);R(this,"project");R(this,"instances",{});R(this,"builtInInstances",{});R(this,"deletedInstances",{});R(this,"subscribedDefinitionEntities",new Set);R(this,"errors",[]);R(this,"references",[]);R(this,"history",[]);R(this,"undoableStackValueIndex",-1);R(this,"detachedDependents",{});R(this,"knownVersions",null);R(this,"activeVersion",!1);R(this,"initialized",!1);R(this,"startedInitialization",!1);R(this,"diggestedBuiltInBaseEntitiesIds",new Set);R(this,"rejectParallelCS",!1);R(this,"onPersistChangeSetSequentiallyCallback",null);R(this,"onPersistChangeSetInParallelCallback",null);R(this,"onAddChangeSetCallback",null);R(this,"onDiscardChangeSetCallback",null);if(this.parentContext=r,this.initialData=i,this.id=i.id,this.name=i.name,this.description=i.description,this.x=0,this.y=0,this.instances[this.id]=this,!$t.UUID)throw new Error("UUID module is already initialized. Please inject a valid UUID module.")}static get UUID(){var i;return(i=this.parentContext.requestExtension("uuid"))==null?void 0:i.module}static new(i=null){return{id:$t.UUID.uuid(),version:$t.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:(i==null?void 0:i.author)||$t.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.Project,name:"",description:"",entities:[],functions:[],events:[],projects:[],variableDeclarations:[],variableInstances:[],conditions:[],operations:[],functionCalls:[],loops:[],searches:[]}}static validateGenerationTarget(i,r){let a=JSON.parse(JSON.stringify(i));const c=[],e=[],f=Wr(a);return e.push(...f.errors),c.push(...f.explanations),{errors:e,explanations:c,modifiedData:a}}get off(){return this.parentContext.events.off}get on(){return this.parentContext.events.on}get emit(){return this.parentContext.events.emit}get emitAsync(){return this.parentContext.events.emitAsync}get emitAsyncAll(){return this.parentContext.events.emitAsyncAll}get emitAsyncAllSettled(){return this.parentContext.events.emitAsyncAllSettled}get emitAsyncSequentially(){return this.parentContext.events.emitAsyncSequentially}get emitAsyncSequentiallyAll(){return this.parentContext.events.emitAsyncSequentiallyAll}get emitAsyncSequentiallyAllSettled(){return this.parentContext.events.emitAsyncSequentiallyAllSettled}async closePersistChangeSetsSequentially(){Y.Logger.log("[ProjectState.closePersistChangeSetsSequentially] called");const i=this.history.find(r=>r.dirty&&!r.open&&!r.submitting);i&&(Y.Logger.log(`[ProjectState.closePersistChangeSetsSequentially] closing pending change-set ${i.id} - ${i.autoCloseActionName}`),await this.persistChangeSetSequentially(i))}async onPersistChangeSetSequentially(i){this.onPersistChangeSetSequentiallyCallback=i,Y.Logger.log("[ProjectState.onPersistChangeSetSequentially] onPersistChangeSetSequentiallyCallback has been set. Checking for pending change-sets."),await this.closePersistChangeSetsSequentially()}offPersistChangeSetSequentially(){this.onPersistChangeSetSequentiallyCallback=null}async onPersistChangeSetInParallel(i){this.onPersistChangeSetInParallelCallback=i,Y.Logger.log("[ProjectState.onPersistChangeSetInParallel] onPersistChangeSetInParallelCallback has been set. Checking for pending change-sets.");for(const r of this.history)this.persistChangeSetInParallel(r),await new Promise(a=>setTimeout(a,27))}offPersistChangeSetInParallel(){this.onPersistChangeSetInParallelCallback=null}onAddChangeSet(i){this.onAddChangeSetCallback=i}offAddChangeSet(){this.onAddChangeSetCallback=null}onDiscardChangeSet(i){this.onDiscardChangeSetCallback=i}offDiscardChangeSet(){this.onDiscardChangeSetCallback=null}async persistChangeSetSequentially(i){if(Y.Logger.log(`[ProjectState.persistChangeSetSequentially] called for change-set ${i.id} - ${i.autoCloseActionName}`),!i.dirty||i.open||i.submitting){Y.Logger.log(`[ProjectState.persistChangeSetSequentially] change-set ${i.id} - ${i.autoCloseActionName} is not dirty, or is open, or is already being submitted, skipping.`);return}const r=this.history.findIndex(e=>e.id===i.id),a=this.history.slice(0,r),c=a[a.length-1];if(c!=null&&c.dirty){Y.Logger.log(`[ProjectState.persistChangeSetSequentially] lastBeforeSelf is dirty: ${c.id} - ${c.autoCloseActionName}, closing it first.`);return}this.onPersistChangeSetSequentiallyCallback&&(Y.Logger.log(`[ProjectState.persistChangeSetSequentially] invoking onPersistChangeSetSequentiallyCallback for change-set ${i.id} - ${i.autoCloseActionName}`),this.emit("before-change-set-persist",i),i.submitting=!0,(await this.onPersistChangeSetSequentiallyCallback(i)).success&&(i.dirty=!1,this.emit("change-set-persisted",i),Y.Logger.log(`[ProjectState.persistChangeSetSequentially] change-set ${i.id} - ${i.autoCloseActionName} closed successfully, checking for pending change-sets to close.`),this.closePersistChangeSetsSequentially()))}async persistChangeSetInParallel(i){if(Y.Logger.log(`[ProjectState.persistChangeSetInParallel] called for change-set ${i.id} - ${i.autoCloseActionName}`),!i.dirty||i.open||i.submitting){Y.Logger.log(`[ProjectState.persistChangeSetInParallel] change-set ${i.id} - ${i.autoCloseActionName} is not dirty, or is open, or is already being submitted, skipping.`);return}this.onPersistChangeSetInParallelCallback&&(Y.Logger.log(`[ProjectState.persistChangeSetInParallel] invoking onPersistChangeSetInParallelCallback for change-set ${i.id} - ${i.autoCloseActionName}`),this.emit("before-change-set-persist",i),i.submitting=!0,(await this.onPersistChangeSetInParallelCallback(i)).success&&(i.dirty=!1,this.emit("change-set-persisted",i)))}toLatestChangeSet(i,r,a,c=!1,e="here-this"){if(!this.history.length)return new S(this,i,r,a,c,e);const f=this.history[this.history.length-1];return f.open?f:this.addChangeSet(new S(this,i,r,a,c,e))}addChangeSet(i){var a,c;if(!this.history.length)return this.undoableStackValueIndex=I_(this.undoableStackValueIndex,this.history,i),(a=this.onAddChangeSetCallback)==null||a.call(this,i,this.undoableStackValueIndex),i;const r=this.history.find(e=>e.id===(i==null?void 0:i.id));if(r)return r;if(this.rejectParallelCS){const e=this.history.find(f=>f.open);if(e)throw Y.Logger.warn("Previous still open: ",e),Y.Logger.warn("New change set: ",i),new Error(`There is already an open change-set with id '${e.id}'${e.autoCloseActionName?` auto-close: ${e.autoCloseActionName}`:""}${e.self?` root: ${e.self.type} ${le(e.self,this)}`:""}.`)}return this.undoableStackValueIndex=I_(this.undoableStackValueIndex,this.history,i),(c=this.onAddChangeSetCallback)==null||c.call(this,i,this.undoableStackValueIndex),i}discardChangeSet(i){var a;Y.Logger.log(`[ProjectState.discardChangeSet] called for change-set ${i.id} - ${i.autoCloseActionName}`);const r=this.history.findIndex(c=>c.id===(i==null?void 0:i.id));return r!==-1&&(this.history.splice(r,1),Y.Logger.log(`[ProjectState.discardChangeSet] Removed change-set ${i.id} - ${i.autoCloseActionName} from history.`),this.undoableStackValueIndex=this.undoableStackValueIndex-1,(a=this.onDiscardChangeSetCallback)==null||a.call(this,i),i==null||i.teardown()),this}validateGeneratedUpdate(i){return{errors:[],explanations:[],modifiedData:i}}subscribeDependents(i){return i.forEach(r=>{this.detachedDependents[r.entity.id]||(this.detachedDependents[r.entity.id]=r)}),this}unsubscribeDependents(i){return i.forEach(r=>{this.detachedDependents[r.entity.id]&&delete this.detachedDependents[r.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new S(this.project,$t.sessionAuthor,B().toISOString(),this,!0,"sync-dependents"))){const r=[],a=[],c=[],e=[];return Object.values(this.detachedDependents).forEach(f=>{const h=f.entity.afterAllChildrenInitialized(i);r.push(...h.updated),a.push(...h.added),c.push(...h.removed),e.push(...h.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}onDetachedDependencyRemoved(i,r,a){const c=[],e=[],f=[],h=[];return{updated:C(c),added:C(e),removed:C(f),affected:C(h),self:this}}onDetachedDependencyRestored(i,r,a){const c=[],e=[],f=[],h=[];return{updated:C(c),added:C(e),removed:C(f),affected:C(h),self:this}}unsubscribeFromDependencies(){return this}subscribeToDependencies(){return this}increaseVersion(i){var r;if(i&&!B(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);if(i&&B(i).isSame(B(this.createdAt)))return this;if(!((r=this.knownVersions)!=null&&r.has(this.version))&&this.initialized)throw new Error(`The current ${this.type} ${this.id} version '${this.version}' is not captured in the 'knownVersions' map. Capture the current version before increasing it to avoid losing data.`);if(!this.activeVersion)throw new Error(`Only active versions can be increased. Entity with id '${this.id}' and version '${this.version}' is not active.`);return this.previousVersion=this.version,this.version=$t.UUID.uuid(),this.createdAt=B(i).toISOString()||B().toISOString(),this}captureVersion(){var r;const i=((r=this.knownVersions)==null?void 0:r.get(this.version))||new $t(this);if(!this.activeVersion)throw new Error(`Only active versions can be captured. Entity of type ${this.type} with id '${this.id}' and version '${this.version}' is not active.`);if(this.version!==i.version)throw new Error(`Captured ${this.type} with id '${this.id}', version '${i.version}' does not match current entity version '${this.version}'.`);return this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map().set(this.version,i),this.apply(i),this}snapshot(){const i=new $t(this);return this.apply(i)}apply(i){const r=this.toMeta();return i.metaSync(r,null),i.entities=[...this.entities],i.projects=[...this.projects],i.functions=[...this.functions],i.events=[...this.events],i.variableDeclarations=[...this.variableDeclarations],i.variableInstances=[...this.variableInstances],i.conditions=[...this.conditions],i.operations=[...this.operations],i.functionCalls=[...this.functionCalls],i.loops=[...this.loops],i.searches=[...this.searches],i}recursiveCaptureUpstreamVersions(i){const r=[],a=[],c=[],e=[];return{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}async restoreVersion(i,r){var m;const a=[],c=[],e=[],f=[];if(this.version===i&&(r!=null&&r.skipIfSameVersion))return{updated:C(a),added:C(c),removed:C(e),affected:C(f),self:this};if(!this.knownVersions){const E=new Map;for(const[b,A]of this.knownVersions||new Map){if(E.set(b,A),A.activeVersion=!1,A.knownVersions)for(const[_,N]of A.knownVersions)E.set(_,N);A.knownVersions=null}}let h=(m=this.knownVersions)==null?void 0:m.get(i);if(!h){const E=await this.APILoadVersion({},i);if(!E)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);h=new $t(E)}return this.metaSync(h.toShallowJSON(),null),this.previousVersion=h.previousVersion,this.version=h.version,this.createdAt=h.createdAt,this.author=h.author,this.deleted=h.deleted,this.entities=[...h.entities],this.projects=[...h.projects],this.functions=[...h.functions],this.events=[...h.events],this.variableDeclarations=[...h.variableDeclarations],this.variableInstances=[...h.variableInstances],this.conditions=[...h.conditions],this.operations=[...h.operations],this.functionCalls=[...h.functionCalls],this.loops=[...h.loops],this.searches=[...h.searches],{updated:C(a),added:C(c),removed:C(e),affected:C(f),self:this}}updateWithShallowTransfer(i,r=this.project.addChangeSet(new S(this.project,$t.sessionAuthor,B().toISOString(),this,!0,w.UpdateWithShallowTransfer))){return this.checkCanEdit(this,r)?(this.metaSync(i,r),this.version=i.version,this.createdAt=i.createdAt,this.author=i.author,this.deleted=i.deleted,this.previousVersion=i.previousVersion,this.captureVersion(),this.subscribeToDependencies(),r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),this):(Y.Logger.warn(`[updateWithShallowTransfer] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.UpdateWithShallowTransfer,this.id),this)}updateWithGenerationTarget(i,r=this.project.addChangeSet(new S(this.project,$t.sessionAuthor,B().toISOString(),this,!0,w.UpdateWithGenerationTarget))){return this.checkCanEdit(this,r)?(this.metaSync(i,r),this.captureVersion(),this.subscribeToDependencies(),r==null||r.attemptAutoclose(w.UpdateWithGenerationTarget,this.id),this):(Y.Logger.warn(`[updateWithGenerationTarget] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(w.UpdateWithGenerationTarget,this.id),this)}hydrateAncestors(){const i=[],r=[],a=[],c=[];return{updated:C(i),added:C(r),removed:C(a),affected:C(c),self:this}}afterAllChildrenInitialized(i=null){const r=[],a=[],c=[],e=[];return this.initialized||(this.initialized=!0,this.emit("project-initialized",this,i)),this.validate(),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}addSelfToProject(i){const r=[],a=[],c=[],e=[];return this.subscribe(),this.subscribeToDependencies(),{updated:C(r),added:C(a),removed:C(c),affected:C(e),self:this}}get instancesList(){return Object.values(this.instances)}get builtInInstancesList(){return Object.values(this.builtInInstances)}isOperationDeclaration(i){return this.operationDeclarations.includes(i)}isGlobalEventActionDescriptor(i){return this.globalEventActionDescriptors.includes(i)}isLoopDeclaration(i){return this.loopDeclarations.includes(i)}isConditionDeclaration(i){return this.conditionDeclarations.includes(i)}initChildren(i=this.project.addChangeSet(new S(this.project,$t.sessionAuthor,B().toISOString(),this,!0,"init-children"))){return this.initialized||this.startedInitialization?this:(this.startedInitialization=!0,this.entities=this.initialData.entities.map(r=>{const a=Ae(r,this);return a.setParent(this,null),a.initChildren(i),a}),this.projects=this.initialData.projects.map(r=>{const a=Ae(r,this);return a.setParent(this,null),a.initChildren(i),a}),this.variableDeclarations=this.initialData.variableDeclarations.map(r=>{const a=Ae(r,this);return a.setParent(this,null),a.initChildren(i),a}),this.variableInstances=this.initialData.variableInstances.map(r=>{const a=Ae(r,this);return a.setParent(this,null),a.initChildren(i),a}),this.conditions=this.initialData.conditions.map(r=>{const a=Ae(r,this);return a.setParent(this,null),a.initChildren(i),a}),this.operations=this.initialData.operations.map(r=>{const a=Ae(r,this);return a.setParent(this,null),a.initChildren(i),a}),this.functions=this.initialData.functions.map(r=>{const a=Ae(r,this);return a.setParent(this,null),a.initChildren(i),a}),this.events=this.initialData.events.map(r=>{const a=Ae(r,this);return a.setParent(this,null),a.initChildren(i),a}),this.functionCalls=this.initialData.functionCalls.map(r=>{const a=Ae(r,this);return a.setParent(this,null),a.initChildren(i),a}),this.loops=this.initialData.loops.map(r=>{const a=Ae(r,this);return a.setParent(this,null),a.initChildren(i),a}),this.searches=this.initialData.searches.map(r=>{const a=Ae(r,this);return a.setParent(this,null),a.initChildren(i),a}),this.attachOrphanReferences(),this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this)}subscribeInstance(i){return(!this.instances[i.id]||this.instances[i.id]!==i)&&(this.instances[i.id]=i),this}subscribeDeletedInstance(i){return(!this.deletedInstances[i.id]||this.deletedInstances[i.id]!==i)&&(this.deletedInstances[i.id]=i),this}subscribeBuiltInInstance(i){return(!this.builtInInstances[i.id]||this.builtInInstances[i.id]!==i)&&(this.builtInInstances[i.id]=i),this}subscribe(){var i;return this.activeVersion=!0,(i=this.knownVersions)==null||i.forEach(r=>{r.version!==this.version&&(r.activeVersion=!1)}),this.subscribeInstance(this),this}unsubscribe(){return this}unsubscribeInstance(i){return delete this.instances[i.id],this}unsubscribeDeletedInstance(i){return delete this.deletedInstances[i.id],this}unsubscribeBuiltInInstance(i){return delete this.builtInInstances[i.id],this}findSubscribedBuiltInInstance(i){return this.builtInInstances[i.id]||null}get(i){return this.instances[i]||this.builtInInstances[i]||null}getDeleted(i){return this.deletedInstances[i]||null}getManaged(i){return this.getBuiltIn(i)?null:this.instances[i]||null}getBuiltIn(i){return this.builtInInstances[i]||null}findSubscribedInstanceFromReference(i){return this.instances[i.entityId]||null}findSubscribedBuiltInInstanceFromReference(i){return this.builtInInstances[i.entityId]||null}metaSync(i,r=this.project.addChangeSet(new S(this.project,$t.sessionAuthor,B().toISOString(),this,!0,"meta-sync"))){const a=Yr(this,i,r),c=zr(this,a),e=this.toMeta();return this.name=a.name!==void 0?a.name:e.name,this.description=a.description!==void 0?a.description:e.description,this.x=a.x||e.x,this.y=a.y||e.y,super.baseMetaSync(a,this,r),a.deleted===!0&&!e.deleted?r==null||r.add(this,W.Removed):a.deleted===!1&&e.deleted?r==null||r.add(this,W.Added):c&&(r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=Ke,...r){return await $t.repository.APILoad(this.id,...r),this}async APICreate(i=Ke,...r){return await $t.repository.APICreate(this.toShallowJSON(),...r),this}async APIUpdate(i=Ke,...r){return await $t.repository.APIUpdate(this.toShallowJSON(),...r),this}async APIDelete(i=Ke,...r){return await $t.repository.APIDelete(this.toShallowJSON(),...r),this}async APIClone(i=Ke,...r){return await $t.repository.APIClone(this.id,...r),this}async APILoadVersion(i=Ke,r,...a){return await $t.repository.APILoadVersion(this.id,r,...a)}remove({ignoreUpstream:i}={ignoreUpstream:!1},r=this.project.addChangeSet(new S(this.project,$t.sessionAuthor,B().toISOString(),this,!0,w.RemoveEntity))){return{added:[],updated:[],removed:[],affected:[],self:this}}restore({}={},i=this.project.addChangeSet(new S(this.project,$t.sessionAuthor,B().toISOString(),this,!0,w.RestoreEntity))){return{added:[],updated:[],removed:[],affected:[],self:this}}getAllBuiltInIds(){const i=new Set;return[...this.primitives.flatMap(r=>r.toFlatIds(i)),...this.builtInBaseEntities.flatMap(r=>r.toFlatIds(i)),...this.operationDeclarations.flatMap(r=>r.toFlatIds(i)),...this.globalEventActionDescriptors.flatMap(r=>r.toFlatIds(i)),...this.loopDeclarations.flatMap(r=>r.toFlatIds(i)),...this.conditionDeclarations.flatMap(r=>r.toFlatIds(i)),...this.valueDescriptors.flatMap(r=>r.toFlatIds(i)),...this.dataTypes.flatMap(r=>r.toFlatIds(i))]}getAllBuiltIn(){const i=new Set;return[...this.primitives.flatMap(r=>r.toFlat(i)),...this.builtInBaseEntities.flatMap(r=>r.toFlat(i)),...this.operationDeclarations.flatMap(r=>r.toFlat(i)),...this.globalEventActionDescriptors.flatMap(r=>r.toFlat(i)),...this.loopDeclarations.flatMap(r=>r.toFlat(i)),...this.conditionDeclarations.flatMap(r=>r.toFlat(i)),...this.valueDescriptors.flatMap(r=>r.toFlat(i)),...this.dataTypes.flatMap(r=>r.toFlat(i))]}toFlat(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this,...this.entities.flatMap(a=>a.toFlat(i)),...this.functions.flatMap(a=>a.toFlat(i)),...this.events.flatMap(a=>a.toFlat(i)),...this.projects.flatMap(a=>a.toFlat(i)),...this.variableDeclarations.flatMap(a=>a.toFlat(i)),...this.variableInstances.flatMap(a=>a.toFlat(i)),...this.conditions.flatMap(a=>a.toFlat(i)),...this.operations.flatMap(a=>a.toFlat(i)),...this.functionCalls.flatMap(a=>a.toFlat(i)),...this.loops.flatMap(a=>a.toFlat(i)),...this.searches.flatMap(a=>a.toFlat(i))])}toFlatIds(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.entities.flatMap(a=>a.toFlatIds(i)),...this.functions.flatMap(a=>a.toFlatIds(i)),...this.events.flatMap(a=>a.toFlatIds(i)),...this.projects.flatMap(a=>a.toFlatIds(i)),...this.variableDeclarations.flatMap(a=>a.toFlatIds(i)),...this.variableInstances.flatMap(a=>a.toFlatIds(i)),...this.conditions.flatMap(a=>a.toFlatIds(i)),...this.operations.flatMap(a=>a.toFlatIds(i)),...this.functionCalls.flatMap(a=>a.toFlatIds(i)),...this.loops.flatMap(a=>a.toFlatIds(i)),...this.searches.flatMap(a=>a.toFlatIds(i))])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,description:this.description,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name}}toJSON(i=new Set){return i.has(this.id)?this.toReference():(i.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name,description:this.description,entities:this.entities.map(r=>r.toJSON(i)),variableDeclarations:this.variableDeclarations.map(r=>r.toJSON(i)),variableInstances:this.variableInstances.map(r=>r.toJSON(i)),conditions:this.conditions.map(r=>r.toJSON(i)),operations:this.operations.map(r=>r.toJSON(i)),loops:this.loops.map(r=>r.toJSON(i)),searches:this.searches.map(r=>r.toJSON(i)),functions:this.functions.map(r=>r.toJSON(i)),events:this.events.map(r=>r.toJSON(i)),projects:this.projects.map(r=>r.toJSON(i)),functionCalls:this.functionCalls.map(r=>r.toJSON(i))})}toJSONClone(i={uuidStrategy:"uuid"}){const r=new Map,a=new Set,c=this.getAllBuiltInIds();return Object.keys(this.instances).forEach(e=>{if(c.includes(e)){r.set(e,e);return}r.set(e,$t.UUID.uuid())}),a.add(this.id),{id:r.get(this.id),version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name,description:this.description,entities:this.entities.map(e=>e.toJSONClone({...i,seenEntityMaps:r,seenEntities:a,newId:null})),projects:this.projects.map(e=>e.toJSONClone({...i,seenEntityMaps:r,seenEntities:a,newId:null})),variableDeclarations:this.variableDeclarations.map(e=>e.toJSONClone({...i,seenEntityMaps:r,seenEntities:a,newId:null})),variableInstances:this.variableInstances.map(e=>e.toJSONClone({...i,seenEntityMaps:r,seenEntities:a,newId:null})),conditions:this.conditions.map(e=>e.toJSONClone({...i,seenEntityMaps:r,seenEntities:a,newId:null})),operations:this.operations.map(e=>e.toJSONClone({...i,seenEntityMaps:r,seenEntities:a,newId:null})),functions:this.functions.map(e=>e.toJSONClone({...i,seenEntityMaps:r,seenEntities:a,newId:null})),events:this.events.map(e=>e.toJSONClone({...i,seenEntityMaps:r,seenEntities:a,newId:null})),functionCalls:this.functionCalls.map(e=>e.toJSONClone({...i,seenEntityMaps:r,seenEntities:a,newId:null})),loops:this.loops.map(e=>e.toJSONClone({...i,seenEntityMaps:r,seenEntities:a,newId:null})),searches:this.searches.map(e=>e.toJSONClone({...i,seenEntityMaps:r,seenEntities:a,newId:null}))}}toReference(i=at){var a;let r=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r+"--"+$t.UUID.uuid()+"--ref",type:d.GenericReference,entityId:r,version:this.version,entityType:this.type}}toShallowJSON(i=at){var a;let r=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name,description:this.description,entities:this.entities.map(c=>c.toReference(i)),functions:this.functions.map(c=>c.toReference(i)),events:this.events.map(c=>c.toReference(i)),projects:this.projects.map(c=>c.toReference(i)),variableDeclarations:this.variableDeclarations.map(c=>c.toReference(i)),variableInstances:this.variableInstances.map(c=>c.toReference(i)),conditions:this.conditions.map(c=>c.toReference(i)),operations:this.operations.map(c=>c.toReference(i)),functionCalls:this.functionCalls.map(c=>c.toReference(i)),loops:this.loops.map(c=>c.toReference(i)),searches:this.searches.map(c=>c.toReference(i))}}toFlatJSON(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...this.entities.flatMap(a=>a.toFlatJSON(i)),...this.functions.flatMap(a=>a.toFlatJSON(i)),...this.events.flatMap(a=>a.toFlatJSON(i)),...this.projects.flatMap(a=>a.toFlatJSON(i)),...this.variableDeclarations.flatMap(a=>a.toFlatJSON(i)),...this.variableInstances.flatMap(a=>a.toFlatJSON(i)),...this.conditions.flatMap(a=>a.toFlatJSON(i)),...this.operations.flatMap(a=>a.toFlatJSON(i)),...this.functionCalls.flatMap(a=>a.toFlatJSON(i)),...this.loops.flatMap(a=>a.toFlatJSON(i)),...this.searches.flatMap(a=>a.toFlatJSON(i))])}toGenerationTarget(i=at){var a;let r=this.id;return(a=i.seenEntityMaps)!=null&&a.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r,type:this.type,name:this.name,description:this.description}}toFlatGenerationTarget(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[...this.entities.flatMap(a=>a.toFlatGenerationTarget(i)),...this.functions.flatMap(a=>a.toFlatGenerationTarget(i)),...this.events.flatMap(a=>a.toFlatGenerationTarget(i)),...this.projects.flatMap(a=>a.toFlatGenerationTarget(i)),...this.variableDeclarations.flatMap(a=>a.toFlatGenerationTarget(i)),...this.variableInstances.flatMap(a=>a.toFlatGenerationTarget(i)),...this.conditions.flatMap(a=>a.toFlatGenerationTarget(i)),...this.operations.flatMap(a=>a.toFlatGenerationTarget(i)),...this.functionCalls.flatMap(a=>a.toFlatGenerationTarget(i)),...this.loops.flatMap(a=>a.toFlatGenerationTarget(i)),...this.searches.flatMap(a=>a.toFlatGenerationTarget(i))])}clearErrors(){return this.errors=[],this.entities.forEach(i=>i.clearErrors()),this.projects.forEach(i=>i.clearErrors()),this.functions.forEach(i=>i.clearErrors()),this.events.forEach(i=>i.clearErrors()),this.variableDeclarations.forEach(i=>i.clearErrors()),this.variableInstances.forEach(i=>i.clearErrors()),this.conditions.forEach(i=>i.clearErrors()),this.operations.forEach(i=>i.clearErrors()),this.functionCalls.forEach(i=>i.clearErrors()),this.loops.forEach(i=>i.clearErrors()),this.searches.forEach(i=>i.clearErrors()),this}validate(){return this.validateChildren(),oE([...this.errors]),{success:!0}}async validateAsync(i={}){const r=Y.YieldTracker.from(i);return await this.validateChildrenAsync({tracker:r}),await xOe([...this.errors]),{success:!0}}validateChildren(){this.entities.forEach(i=>i.validate()),this.projects.forEach(i=>i.validate()),this.functions.forEach(i=>i.validate()),this.events.forEach(i=>i.validate()),this.variableDeclarations.forEach(i=>i.validate()),this.variableInstances.forEach(i=>i.validate()),this.conditions.forEach(i=>i.validate()),this.operations.forEach(i=>i.validate()),this.functionCalls.forEach(i=>i.validate()),this.loops.forEach(i=>i.validate()),this.searches.forEach(i=>i.validate())}async validateChildrenAsync(i={}){const r=Y.YieldTracker.from(i);for(let a=0;a<this.entities.length;a++)await this.entities[a].validateAsync({tracker:r});for(let a=0;a<this.projects.length;a++)await this.projects[a].validateAsync({tracker:r});for(let a=0;a<this.functions.length;a++)await this.functions[a].validateAsync({tracker:r});for(let a=0;a<this.events.length;a++)await this.events[a].validateAsync({tracker:r});for(let a=0;a<this.variableDeclarations.length;a++)await this.variableDeclarations[a].validateAsync({tracker:r});for(let a=0;a<this.variableInstances.length;a++)await this.variableInstances[a].validateAsync({tracker:r});for(let a=0;a<this.conditions.length;a++)await this.conditions[a].validateAsync({tracker:r});for(let a=0;a<this.operations.length;a++)await this.operations[a].validateAsync({tracker:r});for(let a=0;a<this.functionCalls.length;a++)await this.functionCalls[a].validateAsync({tracker:r});for(let a=0;a<this.loops.length;a++)await this.loops[a].validateAsync({tracker:r});for(let a=0;a<this.searches.length;a++)await this.searches[a].validateAsync({tracker:r})}getErrors(){return[...this.errors,...this.entities.flatMap(r=>r.getErrors()),...this.projects.flatMap(r=>r.getErrors()),...this.functions.flatMap(r=>r.getErrors()),...this.events.flatMap(r=>r.getErrors()),...this.variableDeclarations.flatMap(r=>r.getErrors()),...this.variableInstances.flatMap(r=>r.getErrors()),...this.conditions.flatMap(r=>r.getErrors()),...this.operations.flatMap(r=>r.getErrors()),...this.functionCalls.flatMap(r=>r.getErrors()),...this.loops.flatMap(r=>r.getErrors()),...this.searches.flatMap(r=>r.getErrors())]}async getErrorsAsync(i={}){const r=Y.YieldTracker.from(i),a=[...this.errors];await r.tick();for(let c=0;c<this.entities.length;c++){const e=await this.entities[c].getErrorsAsync({tracker:r});a.push(...e)}for(let c=0;c<this.projects.length;c++){const e=await this.projects[c].getErrorsAsync({tracker:r});a.push(...e)}for(let c=0;c<this.functions.length;c++){const e=await this.functions[c].getErrorsAsync({tracker:r});a.push(...e)}for(let c=0;c<this.events.length;c++){const e=await this.events[c].getErrorsAsync({tracker:r});a.push(...e)}for(let c=0;c<this.variableDeclarations.length;c++){const e=await this.variableDeclarations[c].getErrorsAsync({tracker:r});a.push(...e)}for(let c=0;c<this.variableInstances.length;c++){const e=await this.variableInstances[c].getErrorsAsync({tracker:r});a.push(...e)}for(let c=0;c<this.conditions.length;c++){const e=await this.conditions[c].getErrorsAsync({tracker:r});a.push(...e)}for(let c=0;c<this.operations.length;c++){const e=await this.operations[c].getErrorsAsync({tracker:r});a.push(...e)}for(let c=0;c<this.functionCalls.length;c++){const e=await this.functionCalls[c].getErrorsAsync({tracker:r});a.push(...e)}for(let c=0;c<this.loops.length;c++){const e=await this.loops[c].getErrorsAsync({tracker:r});a.push(...e)}for(let c=0;c<this.searches.length;c++){const e=await this.searches[c].getErrorsAsync({tracker:r});a.push(...e)}return a}getShallowErrors(){return this.errors}clone(){return this}addDefinitionEntity(i){return this.entities.includes(i)||this.entities.push(i),i}addFunctionDeclaration(i){return this.functions.includes(i)||this.functions.push(i),i}addFunctionCall(i){return this.functionCalls.includes(i)||this.functionCalls.push(i),i}addVariableDeclaration(i){return this.variableDeclarations.includes(i)||this.variableDeclarations.push(i),i}addVariableInstance(i){return this.variableInstances.includes(i)||this.variableInstances.push(i),i}addInstalledProject(i){return this.projects.includes(i)||this.projects.push(i),this}addGlobalEvent(i){return this.events.includes(i)||this.events.push(i),this}addCondition(i){return this.conditions.includes(i)||this.conditions.push(i),this}addOperation(i){return this.operations.includes(i)||this.operations.push(i),this}addLoop(i){return this.loops.includes(i)||this.loops.push(i),this}addSearch(i){return this.searches.includes(i)||this.searches.push(i),this}removeDefinitionEntity(i){const r=this.entities.findIndex(a=>a.id===i.id);if(r>-1){const a=this.entities[r];return this.entities.splice(r,1),a}return null}removeCondition(i){const r=this.conditions.findIndex(a=>a.id===i.id);if(r>-1){const a=this.conditions[r];return this.conditions.splice(r,1),a}return null}removeOperation(i){const r=this.operations.findIndex(a=>a.id===i.id);if(r>-1){const a=this.operations[r];return this.operations.splice(r,1),a}return null}removeLoop(i){const r=this.loops.findIndex(a=>a.id===i.id);if(r>-1){const a=this.loops[r];return this.loops.splice(r,1),a}return null}removeSearch(i){const r=this.searches.findIndex(a=>a.id===i.id);if(r>-1){const a=this.searches[r];return this.searches.splice(r,1),a}return null}removeFunctionCall(i){const r=this.functionCalls.findIndex(a=>a.id===i.id);if(r>-1){const a=this.functionCalls[r];return this.functionCalls.splice(r,1),a}return null}removeVariableInstance(i){const r=this.variableInstances.findIndex(a=>a.id===i.id);if(r>-1){const a=this.variableInstances[r];return this.variableInstances.splice(r,1),a}return null}removeVariableDeclaration(i){const r=this.variableDeclarations.findIndex(a=>a.id===i.id);if(r>-1){const a=this.variableDeclarations[r];return this.variableDeclarations.splice(r,1),a}return null}removeFunctionDeclaration(i){const r=this.functions.findIndex(a=>a.id===i.id);if(r>-1){const a=this.functions[r];return this.functions.splice(r,1),a}return null}removeInstalledProject(i){const r=this.projects.findIndex(a=>a.id===i.id);if(r>-1){const a=this.projects[r];return this.projects.splice(r,1),a}return null}removeGlobalEvent(i){const r=this.events.findIndex(a=>a.id===i.id);if(r>-1){const a=this.events[r];return this.events.splice(r,1),a}return null}removeTopLevelVariableDeclaration(i){if(i.type!==d.VariableDeclaration)return null;const r=this.variableDeclarations.findIndex(a=>a.id===i.id);if(r>-1){const a=this.variableDeclarations[r];return this.variableDeclarations.splice(r,1),a}return null}getEntryPoints(){return[...this.functions,...this.events,...this.entities.flatMap(r=>r.methods)]}getTerminationStatements(){return[...this.getEntryPoints().reduce((r,a)=>{const c=pt(a);return[...r,...c.filter(e=>e.type===d.ReturnStatement||e.type===d.ContinueStatement||e.type===d.BreakStatement)]},[])]}getFunctionDeclaration(i){return this.functions.find(r=>r.id===i)||null}getConditions(){return[...this.conditions,...this.getEntryPoints().reduce((r,a)=>{const c=pt(a);return[...r,...c.filter(e=>e.type===d.Condition)]},[]),...this.functionCalls.reduce((r,a)=>{const c=pt(a);return[...r,...c.filter(e=>e.type===d.Condition)]},[]),...this.operations.reduce((r,a)=>{const c=pt(a);return[...r,...c.filter(e=>e.type===d.Condition)]},[]),...this.loops.reduce((r,a)=>{const c=pt(a);return[...r,...c.filter(e=>e.type===d.Condition)]},[]),...this.searches.reduce((r,a)=>{const c=pt(a);return[...r,...c.filter(e=>e.type===d.Condition)]},[])]}getOperations(){return[...this.operations,...this.getEntryPoints().reduce((r,a)=>{const c=pt(a);return[...r,...c.filter(e=>e.type===d.Operation)]},[]),...this.functionCalls.reduce((r,a)=>{const c=pt(a);return[...r,...c.filter(e=>e.type===d.Operation)]},[]),...this.conditions.reduce((r,a)=>{const c=pt(a);return[...r,...c.filter(e=>e.type===d.Operation)]},[]),...this.loops.reduce((r,a)=>{const c=pt(a);return[...r,...c.filter(e=>e.type===d.Operation)]},[]),...this.searches.reduce((r,a)=>{const c=pt(a);return[...r,...c.filter(e=>e.type===d.Operation)]},[])]}getFunctionCalls(){return[...this.functionCalls,...this.getEntryPoints().reduce((r,a)=>{const c=pt(a);return[...r,...c.filter(e=>e.type===d.FunctionCall)]},[]),...this.conditions.reduce((r,a)=>{const c=pt(a);return[...r,...c.filter(e=>e.type===d.FunctionCall)]},[]),...this.operations.reduce((r,a)=>{const c=pt(a);return[...r,...c.filter(e=>e.type===d.FunctionCall)]},[]),...this.loops.reduce((r,a)=>{const c=pt(a);return[...r,...c.filter(e=>e.type===d.FunctionCall)]},[]),...this.searches.reduce((r,a)=>{const c=pt(a);return[...r,...c.filter(e=>e.type===d.FunctionCall)]},[])]}getDefinitionEntities(i=new Set){return Array.from(this.subscribedDefinitionEntities).filter(a=>!i.has(a)).map(a=>this.get(a))}getVariables(){return[...this.variableDeclarations,...this.getEntryPoints().reduce((r,a)=>{const c=lr(a);return[...r,...c]},[]),...this.functionCalls.reduce((r,a)=>{const c=lr(a);return[...r,...c]},[]),...this.conditions.reduce((r,a)=>{const c=lr(a);return[...r,...c]},[]),...this.operations.reduce((r,a)=>{const c=lr(a);return[...r,...c]},[]),...this.loops.reduce((r,a)=>{const c=lr(a);return[...r,...c]},[]),...this.searches.reduce((r,a)=>{const c=lr(a);return[...r,...c]},[])]}getVariableInstances(){return[...this.variableInstances,...this.entities.reduce((r,a)=>[...r,...a.methods.flatMap(c=>{const f=pt(c).filter(h=>h.type===d.VariableInstance);return[...r,...f]})],[]),...this.getEntryPoints().reduce((r,a)=>{const e=lr(a).filter(f=>f.type===d.VariableInstance);return[...r,...e]},[]),...this.functionCalls.reduce((r,a)=>{const e=lr(a).filter(f=>f.type===d.VariableInstance);return[...r,...e]},[]),...this.conditions.reduce((r,a)=>{const e=lr(a).filter(f=>f.type===d.VariableInstance);return[...r,...e]},[]),...this.operations.reduce((r,a)=>{const e=lr(a).filter(f=>f.type===d.VariableInstance);return[...r,...e]},[]),...this.loops.reduce((r,a)=>{const e=lr(a).filter(f=>f.type===d.VariableInstance);return[...r,...e]},[]),...this.searches.reduce((r,a)=>{const e=lr(a).filter(f=>f.type===d.VariableInstance);return[...r,...e]},[])]}getVariableDeclarations(){return C([...this.variableDeclarations,...this.entities.reduce((r,a)=>[...r,...a.methods.flatMap(c=>{const f=pt(c).filter(h=>h.type===d.VariableDeclaration);return[...r,...f]})],[]),...this.getEntryPoints().reduce((r,a)=>{const e=lr(a).filter(f=>f.type===d.VariableDeclaration);return[...r,...e]},[]),...this.functionCalls.reduce((r,a)=>{const e=lr(a).filter(f=>f.type===d.VariableDeclaration);return[...r,...e]},[]),...this.conditions.reduce((r,a)=>{const e=lr(a).filter(f=>f.type===d.VariableDeclaration);return[...r,...e]},[]),...this.operations.reduce((r,a)=>{const e=lr(a).filter(f=>f.type===d.VariableDeclaration);return[...r,...e]},[]),...this.loops.reduce((r,a)=>{const e=lr(a).filter(f=>f.type===d.VariableDeclaration);return[...r,...e]},[]),...this.searches.reduce((r,a)=>{const e=lr(a).filter(f=>f.type===d.VariableDeclaration);return[...r,...e]},[])])}getLoops(){return[...this.loops,...this.getEntryPoints().reduce((r,a)=>{const c=pt(a);return[...r,...c.filter(e=>e.type===d.Loop)]},[]),...this.functionCalls.reduce((r,a)=>{const c=pt(a);return[...r,...c.filter(e=>e.type===d.Loop)]},[]),...this.conditions.reduce((r,a)=>{const c=pt(a);return[...r,...c.filter(e=>e.type===d.Loop)]},[]),...this.operations.reduce((r,a)=>{const c=pt(a);return[...r,...c.filter(e=>e.type===d.Loop)]},[]),...this.searches.reduce((r,a)=>{const c=pt(a);return[...r,...c.filter(e=>e.type===d.Loop)]},[])]}getSearches(){return[...this.searches,...this.getEntryPoints().reduce((r,a)=>{const c=pt(a);return[...r,...c.filter(e=>e.type===d.Search)]},[]),...this.functionCalls.reduce((r,a)=>{const c=pt(a);return[...r,...c.filter(e=>e.type===d.Search)]},[]),...this.conditions.reduce((r,a)=>{const c=pt(a);return[...r,...c.filter(e=>e.type===d.Search)]},[]),...this.operations.reduce((r,a)=>{const c=pt(a);return[...r,...c.filter(e=>e.type===d.Search)]},[]),...this.loops.reduce((r,a)=>{const c=pt(a);return[...r,...c.filter(e=>e.type===d.Search)]},[])]}attachOrphanReferences(){const i=this.getVariableInstances(),r=this.getVariableDeclarations();return i.forEach(a=>{if(!a.declaration){const c=a.initialData,e=c.declaration.entityId||c.declaration.id,f=r.find(h=>h.id===e);f&&a.setDeclaration(f)}}),this}getBuiltInPersistedEntity(){return this.builtInBaseEntities.find(i=>i.name===Ie.PERSISTED_ENTITY)||null}requestActiveDynamicValue(i,r=!1){var c,e;const a=(e=(c=this.parentContext).requestActiveDynamicValue)==null?void 0:e.call(c,i,r);if(!a&&ig.includes(i.type)){const f=i.getDefaultValue();return f?{value:f,type:Me.DefaultValue,inheritanceLink:null,valueOwner:i}:null}return a||null}requestExtension(i){if(this.parentContext.requestExtension){const r=this.parentContext.requestExtension(i);if(r&&!r.module)throw new Error(`Module ${i} is not registered properly.`);return r.module||null}return null}undo(){Y.Logger.log("Undoing, from: ",this.undoableStackValueIndex),this.undoableStackValueIndex=this.undoableStackValueIndex-1,Y.Logger.log("To: ",this.undoableStackValueIndex);const i=this.history[this.undoableStackValueIndex+1],r=this.history[this.undoableStackValueIndex];return Y.Logger.log("Current change set: ",i==null?void 0:i.toJSON()),Y.Logger.log("Change set to restore: ",r==null?void 0:r.toJSON()),b_(i||"initial",r||"initial",this)}redo(){Y.Logger.log("Undoing, from: ",this.undoableStackValueIndex),this.undoableStackValueIndex=this.undoableStackValueIndex+1,Y.Logger.log("To: ",this.undoableStackValueIndex);const i=this.history[this.undoableStackValueIndex-1],r=this.history[this.undoableStackValueIndex];return Y.Logger.log("Current change set: ",i==null?void 0:i.toJSON()),Y.Logger.log("Change set to restore: ",r.toJSON()),b_(i||"initial",r||"initial",this)}applyExternalChangeSet(i){const r=i.payload,a=this.addChangeSet(new S(this,i.userAuthor,i.emittedAt,this));a.ignoreNonEditable=!0,a.ignoreNonDeletable=!0;const c=r.updated[this.id];if(!c)throw new Error("Project root not found in change set transfer. Cannot apply changes.");const e={...r.added,...r.updated,...r.removed},f=[...Object.keys(r.added),...Object.keys(r.updated),...Object.keys(r.removed)];f.forEach(m=>{var E;if(!e[m]){Y.Logger.warn(`Entity '${m}' not found in change set transfer. Cannot apply changes.`);const b=(E=this.get(m))==null?void 0:E.toShallowJSON();throw b?Y.Logger.warn("Entity in project: ",b):Y.Logger.warn("Entity not in project"),new Error(`Entity '${m}' not found in change set transfer. Cannot apply changes.`)}});const h=new Bn(c,{allBuiltInEntityIds:this.diggestedBuiltInBaseEntitiesIds});return h.flatRecord=e,h.order=f,h.orderEntities(),Y.Logger.log("All entities: ",h.order.map((m,E)=>`${E+1}: ${e[m].type} - ${m}`).join(`,
539
- `)),Y.Logger.log("Persisting new additions"),h.visit(async(m,E)=>{if(r.added[m.id]){Y.Logger.log("Adding: ",m.id);try{const b=Ae(m,this);if(b.hydrateAncestors(),b.addSelfToProject(a),a.add(b,W.Added),a||b.captureVersion(),!this.get(m.id))throw new Error(`Entity ${m.id} was not added to the project`)}catch(b){Y.Logger.error("Error: ",b),Y.Logger.error("Errored entity: ",m)}}}),Y.Logger.log("Persisting updates"),h.visit(async(m,E)=>{if(r.updated[m.id]){Y.Logger.log("Updating: ",m.id);try{const b=this.get(m.id);b?(b.updateWithShallowTransfer(m,a),a.add(b,W.Updated),a||b.captureVersion()):Y.Logger.warn(`Active version of ${m.id} not found when applying external changes`)}catch(b){Y.Logger.error("Error: ",b),Y.Logger.error("Errored entity: ",m)}}}),Y.Logger.log("Persisting removals"),h.visit(async(m,E)=>{if(r.removed[m.id]){Y.Logger.log("Removing: ",m.id);try{const b=this.get(m.id);b&&(b.remove({ignoreUpstream:!1},a),a.add(b,W.Removed),a||b.captureVersion())}catch(b){Y.Logger.error("Error: ",b),Y.Logger.error("Errored entity: ",m)}}}),a.open=!1,a}toBuiltInShallowRecord(){const i={};return Object.values(this.builtInInstances).forEach(r=>{const a=r.toShallowJSON();i[r.id]=a}),i}toShallowRecord(){const i={};return Object.values(this.instances).forEach(r=>{const a=r.toShallowJSON();i[r.id]=a}),i}toFullProjectTransfer(i){const r={shallowErrors:!1,...i},a=new Bn(void 0,{allBuiltInEntityIds:this.diggestedBuiltInBaseEntitiesIds});a.flatRecord={};for(const f of Object.values(this.instances))this.diggestedBuiltInBaseEntitiesIds.has(f.id)||(a.flatRecord[f.id]=f);a.order=Object.keys(a.flatRecord),a.orderEntities();const c={},e=[];return a.visit(f=>{try{const h=f.toShallowJSON();c[f.id]=h,e.push(f.id)}catch(h){if(Y.Logger.error(`[toFullProjectTransfer] Error serializing ${f.type} ${f.id}`,h),!r.shallowErrors)throw h}}),{order:e,size:e.length,record:c}}async toFullProjectTransferAsync(i={}){const r={shallowErrors:!1,...i},a=Y.YieldTracker.from(r),c=new Bn(void 0,{allBuiltInEntityIds:this.diggestedBuiltInBaseEntitiesIds});c.flatRecord={};for(const h of Object.values(this.instances))await a.tick(),!this.diggestedBuiltInBaseEntitiesIds.has(h.id)&&(c.flatRecord[h.id]=h);c.order=Object.keys(c.flatRecord);const e=[];if(r.seenEntityMaps)for(const h of c.order){const m=r.seenEntityMaps.get(h)??h;this.diggestedBuiltInBaseEntitiesIds.has(m)}await c.orderEntitiesAsync({tracker:a});const f={};return await c.visitAsync(async h=>{try{if(this.diggestedBuiltInBaseEntitiesIds.has(h.id))return;const m=h.toShallowJSON({seenEntityMaps:r.seenEntityMaps});r.resetVersionOptions&&(m.version=$t.UUID.uuid(),m.createdAt=r.resetVersionOptions.commonTimestamp||B().toISOString(),m.author=r.resetVersionOptions.author||$t.sessionAuthor||"1",m.previousVersion=null),f[m.id]=m,e.push(m.id),r!=null&&r.onVisit&&await r.onVisit(m)}catch(m){if(Y.Logger.error(`[toFullProjectTransferAsync] Error serializing ${h.type} ${h.id}`,m),!r.shallowErrors)throw m}},{tracker:a}),{order:e,size:e.length,record:f}}async toFullProjectGenerationTargetAsync(i={}){const r={shallowErrors:!1,...i},a=Y.YieldTracker.from(r),c=new Bn(void 0,{allBuiltInEntityIds:this.diggestedBuiltInBaseEntitiesIds});c.flatRecord={};for(const h of Object.values(this.instances))await a.tick(),!this.diggestedBuiltInBaseEntitiesIds.has(h.id)&&(c.flatRecord[h.id]=h);c.order=Object.keys(c.flatRecord);const e=[];if(r.seenEntityMaps)for(const h of c.order){const m=r.seenEntityMaps.get(h)??h;this.diggestedBuiltInBaseEntitiesIds.has(m)}await c.orderEntitiesAsync({tracker:a});const f={};return await c.visitAsync(async h=>{try{if(this.diggestedBuiltInBaseEntitiesIds.has(h.id))return;const m=h.toGenerationTarget({seenEntityMaps:r.seenEntityMaps});f[m.id]=m,e.push(m.id),r!=null&&r.onVisit&&await r.onVisit(m)}catch(m){if(Y.Logger.error(`[toFullProjectTransferAsync] Error serializing ${h.type} ${h.id}`,m),!r.shallowErrors)throw m}},{tracker:a}),{order:e,size:e.length,record:f}}};R($t,"parentContext",sL),R($t,"sessionAuthor","1"),R($t,"repository",{APICreate:async(i,...r)=>i,APIUpdate:async(i,...r)=>i,APIDelete:async(i,...r)=>i,APIClone:async(i,...r)=>{},APILoad:async(i,...r)=>null,APILoadVersion:async(i,r,...a)=>null}),R($t,"type",d.Project),R($t,"USER_MANAGED_PARENT_TYPES",[]),R($t,"PARENT_TYPES",[...$t.USER_MANAGED_PARENT_TYPES]),R($t,"MUTABLE_BASE_PROPERTIES",["name","description"]),R($t,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),R($t,"BASE_PROPERTIES",[...$t.MUTABLE_BASE_PROPERTIES,...$t.INMUTABLE_BASE_PROPERTIES]),R($t,"MUTABLE_META_PROPERTIES",[...$t.MUTABLE_BASE_PROPERTIES,"x","y"]),R($t,"INMUTABLE_META_PROPERTIES",[...$t.INMUTABLE_BASE_PROPERTIES]),R($t,"META_PROPERTIES",[...$t.MUTABLE_META_PROPERTIES,...$t.INMUTABLE_META_PROPERTIES]),R($t,"MUTABLE_UPSTREAM_PROPERTIES",[]),R($t,"INMUTABLE_UPSTREAM_PROPERTIES",["primitives","builtInBaseEntities","operationDeclarations","globalEventActionDescriptors","loopDeclarations","builtInInstances"]),R($t,"UPSTREAM_PROPERTIES",[...$t.MUTABLE_UPSTREAM_PROPERTIES,...$t.INMUTABLE_UPSTREAM_PROPERTIES]),R($t,"MUTABLE_DOWNSTREAM_PROPERTIES",["entities","projects","functions","events","variableDeclarations","variableInstances","conditions","operations","functionCalls","loops","searches"]),R($t,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),R($t,"DOWNSTREAM_PROPERTIES",[...$t.MUTABLE_DOWNSTREAM_PROPERTIES,...$t.INMUTABLE_DOWNSTREAM_PROPERTIES]),R($t,"PROPERTIES",[...$t.META_PROPERTIES,...$t.UPSTREAM_PROPERTIES,...$t.DOWNSTREAM_PROPERTIES]);let x=$t;class C_i extends Hi{constructor(p){super(Yv,p)}}class O_i extends Hi{constructor(i){super(zh,i);R(this,"autoexecutable",!0)}getEntityToMatchInputMap(i){return i.inputs.find(r=>{var a;return((a=r.declaration)==null?void 0:a.id)===ne.operation[Le.Validate].inputs.entityToMatch.id})||null}getDataToValidateInputMap(i){return i.inputs.find(r=>{var a;return((a=r.declaration)==null?void 0:a.id)===ne.operation[Le.Validate].inputs.dataToValidate.id})||null}getOutputDataOutputMap(i){return i.outputs.find(r=>{var a;return((a=r.declaration)==null?void 0:a.id)===ne.operation[Le.Validate].dataType.entity.properties.outputEntity.id})||null}getEntityToMatch(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"get-entity-to-match-validate-data"))){var e;const a=((e=this.project.requestActiveDynamicValue(i))==null?void 0:e.value)||null,c=a==null?void 0:a.valueAsTypeSingle;return r==null||r.attemptAutoclose("get-entity-to-match-validate-data",this.id),c}syncOperationInstance(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-operation-instance-validate-data"))){const a=[],c=[],e=[],f=[],h=this.getEntityToMatchInputMap(i);if(h){const{added:b,updated:A,removed:_,affected:N}=this.syncEntityToMatchInputMapDataType(h,r);a.push(...A),c.push(...b),e.push(..._),f.push(...N)}const m=this.getDataToValidateInputMap(i);if(m){const{added:b,updated:A,removed:_,affected:N}=this.syncDataToValidateInputMapDataType(m,r);a.push(...A),c.push(...b),e.push(..._),f.push(...N)}const E=this.getOutputDataOutputMap(i);if(E){const{added:b,updated:A,removed:_,affected:N}=this.syncOutputDataOutputMapDataType(E,r);a.push(...A),c.push(...b),e.push(..._),f.push(...N)}return r==null||r.attemptAutoclose("sync-operation-instance-validate-data",this.id),{updated:C(a),added:C(c),removed:C(e),affected:C(f),self:i}}syncEntityToMatchInputMapDataType(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-entity-to-match-input-map-data-type"))){var E,b,A,_,N,V,j,M,G,q,re,ee,de,ie,se,ue,z,X;const a=[],c=[],e=[],f=[];if(((E=i.declaration)==null?void 0:E.id)!==ne.operation[Le.Validate].inputs.entityToMatch.id)return r==null||r.attemptAutoclose("sync-entity-to-match-input-map-data-type",this.id),{updated:[],added:[],removed:[],affected:[],self:null};const h=((b=this.project.requestActiveDynamicValue(i))==null?void 0:b.value)||null,m=h==null?void 0:h.valueAsTypeSingle;if(!i.dataType){console.log("Creating new data type for entity to match input map with entity to match: ",i.id);const ce={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(r==null?void 0:r.timestamp)||new Date().toISOString(),author:(r==null?void 0:r.author)||x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.DataType,parentRelationType:null,options:((A=i.declaration.dataType)==null?void 0:A.options)||null,implementationChooseOne:((_=i.declaration.dataType)==null?void 0:_.implementationChooseOne)||!1,staticEntities:((N=i.declaration.dataType)==null?void 0:N.staticEntities)??null,interactiveEntities:((V=i.declaration.dataType)==null?void 0:V.interactiveEntities)??null,actionEntities:((j=i.declaration.dataType)==null?void 0:j.actionEntities)??null,index:((M=i.declaration.dataType)==null?void 0:M.index)??null,isList:((G=i.declaration.dataType)==null?void 0:G.isList)||!1,foreignKeyAllowed:((q=i.declaration.dataType)==null?void 0:q.foreignKeyAllowed)??null,andChildrenGroup:null,orChildrenGroup:null,foreignKeyRef:null,asType:!0,entity:(m==null?void 0:m.toJSON())||null,like:!0,inferred:!0,parent:i.toReference()},oe=Ae(ce,i.project);oe.hydrateAncestors(),oe.addSelfToProject(r),r==null||r.add(oe,W.Added),oe.setParent(i,r),oe.initChildren(r),oe.setEntity(m,r),a.push(oe),i.setDataType(oe,r),r||oe.captureVersion()}return(z=i.dataType)==null||z.metaSync({inferred:!0,like:!1,asType:!0,options:((re=i.declaration.dataType)==null?void 0:re.options)||null,implementationChooseOne:((ee=i.declaration.dataType)==null?void 0:ee.implementationChooseOne)||!1,staticEntities:((de=i.declaration.dataType)==null?void 0:de.staticEntities)??null,interactiveEntities:((ie=i.declaration.dataType)==null?void 0:ie.interactiveEntities)??null,actionEntities:((se=i.declaration.dataType)==null?void 0:se.actionEntities)??null,isList:((ue=i.declaration.dataType)==null?void 0:ue.isList)||!1},r),(X=i.dataType)==null||X.setEntity(m,r),i.dataType&&c.push(i.dataType),r==null||r.attemptAutoclose("sync-entity-to-match-input-map-data-type",this.id),{updated:C(c),added:C(a),removed:C(e),affected:C(f),self:i.dataType}}syncDataToValidateInputMapDataType(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-data-to-validate-input-map-data-type"))){var b,A,_;const a=[],c=[],e=[],f=[];if(((b=i.declaration)==null?void 0:b.id)!==ne.operation[Le.Validate].inputs.dataToValidate.id)return r==null||r.attemptAutoclose("sync-data-to-validate-input-map-data-type",this.id),{updated:[],added:[],removed:[],affected:[],self:null};const h=this.getEntityToMatchInputMap(i.parent);if(!h)return r==null||r.attemptAutoclose("sync-data-to-validate-input-map-data-type",this.id),{updated:[],added:[],removed:[],affected:[],self:null};if(!this.getEntityToMatch(h,r))return r==null||r.attemptAutoclose("sync-data-to-validate-input-map-data-type",this.id),{updated:[],added:[],removed:[],affected:[],self:null};if(!i.dataType){console.log("Creating new data type for data to validate input map with entity to match");const N={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(r==null?void 0:r.timestamp)||new Date().toISOString(),author:(r==null?void 0:r.author)||x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.DataType,index:null,parentRelationType:null,options:null,implementationChooseOne:!1,foreignKeyAllowed:null,isList:!1,foreignKeyRef:null,andChildrenGroup:null,orChildrenGroup:null,staticEntities:null,interactiveEntities:null,actionEntities:null,asType:!1,entity:null,like:!0,inferred:!0,parent:i.toReference()},V=Ae(N,i.project);V.hydrateAncestors(),V.addSelfToProject(r),r==null||r.add(V,W.Added),V.setParent(i,r),V.initChildren(r),a.push(V),i.setDataType(V,r),r||V.captureVersion()}(A=i.dataType)==null||A.metaSync({inferred:!0,like:!0,asType:!1},r);const E=this.getEntityToMatch(h,r);return(_=i.dataType)==null||_.setEntity(E,r),i.dataType&&c.push(i.dataType),r==null||r.attemptAutoclose("sync-data-to-validate-input-map-data-type",this.id),{updated:C(c),added:C(a),removed:C(e),affected:C(f),self:i.dataType}}syncOutputDataOutputMapDataType(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-output-data-output-map-data-type"))){var A,_,N,V;const a=[],c=[],e=[],f=[];if(((A=i.declaration)==null?void 0:A.id)!==ne.operation[Le.Validate].dataType.entity.properties.outputEntity.id)return r==null||r.attemptAutoclose("sync-output-data-output-map-data-type",this.id),{updated:[],added:[],removed:[],affected:[],self:null};const h=this.getEntityToMatchInputMap(i.parent);if(!h)return r==null||r.attemptAutoclose("sync-output-data-output-map-data-type",this.id),{updated:[],added:[],removed:[],affected:[],self:null};if(!this.getEntityToMatch(h,r))return r==null||r.attemptAutoclose("sync-output-data-output-map-data-type",this.id),{updated:[],added:[],removed:[],affected:[],self:null};const E=((_=this.project.requestActiveDynamicValue(h))==null?void 0:_.value)||null,b=(E==null?void 0:E.valueAsTypeSingle)||null;if(!i.dataType){console.log("Creating new data type for output data output map with entity to match");const j={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(r==null?void 0:r.timestamp)||new Date().toISOString(),author:(r==null?void 0:r.author)||x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.DataType,parentRelationType:null,options:null,foreignKeyRef:null,implementationChooseOne:!1,foreignKeyAllowed:null,staticEntities:null,interactiveEntities:null,index:null,actionEntities:null,isList:!1,andChildrenGroup:null,orChildrenGroup:null,asType:!1,entity:(b==null?void 0:b.toJSON())||null,like:!0,inferred:!0,parent:i.toReference()},M=Ae(j,i.project);M.hydrateAncestors(),M.addSelfToProject(r),r==null||r.add(M,W.Added),M.setParent(i,r),M.initChildren(r),M.setEntity(b,r),a.push(M),i.setDataType(M,r),r||M.captureVersion()}return(N=i.dataType)==null||N.metaSync({inferred:!0,like:!0,asType:!1},r),(V=i.dataType)==null||V.setEntity(b,r),i.dataType&&c.push(i.dataType),r==null||r.attemptAutoclose("sync-output-data-output-map-data-type",this.id),{updated:C(c),added:C(a),removed:C(e),affected:C(f),self:i.dataType}}inferInputMapDataType(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"infer-input-map-data-type-validate-data"))){var c,e,f;if(((c=i.declaration)==null?void 0:c.id)===ne.operation[Le.Validate].inputs.entityToMatch.id){const{added:h,updated:m,removed:E,affected:b}=r?this.syncEntityToMatchInputMapDataType(i,r):{added:[],updated:[],removed:[],affected:[]};return r==null||r.attemptAutoclose("infer-input-map-data-type",this.id),{updated:C(m),added:C(h),removed:C(E),affected:C(b),self:i.dataType}}if(((e=i.declaration)==null?void 0:e.id)===ne.operation[Le.Validate].inputs.dataToValidate.id){const{added:h,updated:m,removed:E,affected:b}=this.syncDataToValidateInputMapDataType(i,r);return r==null||r.attemptAutoclose("infer-input-map-data-type",this.id),{updated:C(m),added:C(h),removed:C(E),affected:C(b),self:i.dataType}}const a=(f=i.declaration)==null?void 0:f.getDataType(r);if(a&&a.isResolved)return r==null||r.attemptAutoclose("infer-input-map-data-type-validate-data",this.id),{updated:[],added:[],removed:[],affected:[],self:a};if(i.readsValue){const h=Sd(i.readsValue,r);return r==null||r.attemptAutoclose("infer-input-map-data-type-validate-data",this.id),{updated:[],added:[],removed:[],affected:[],self:h}}return r==null||r.attemptAutoclose("infer-input-map-data-type-validate-data",this.id),{updated:[],added:[],removed:[],affected:[],self:null}}inferOutputMapDataType(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"infer-output-map-data-type-validate-data"))){var a;if(((a=i.declaration)==null?void 0:a.id)===ne.operation[Le.Validate].dataType.entity.properties.outputEntity.id){const{added:c,updated:e,removed:f,affected:h}=this.syncOutputDataOutputMapDataType(i,r);return r==null||r.attemptAutoclose("infer-output-map-data-type-validate-data",this.id),{updated:C(e),added:C(c),removed:C(f),affected:C(h),self:i.dataType}}return{updated:[],added:[],removed:[],affected:[],self:null}}}class __i extends Hi{constructor(p){super(iP,p)}}class V_i extends Hi{constructor(p){super(rP,p)}}class P_i extends Hi{constructor(p){super(nP,p)}}class N_i extends Hi{constructor(p){super(kg,p)}}class x_i extends Hi{constructor(p){super(ag,p)}}class $_i extends Hi{constructor(p){super(pv,p)}}function ske(l){const p=[new $_e(l),new C_i(l),new O_i(l),new N_i(l),new __i(l),new P_i(l),new V_i(l),new x_i(l),new $_i(l)];return DN.forEach(i=>{p.some(r=>r.id===i.id)||p.push(new Hi(i,l))}),p.forEach(i=>{i.initChildren(null),l.subscribeBuiltInInstance(i)}),l.operationDeclarations=p,p}const L_i=[];function lke(l){const p=[new C_e(l),new V_e(l),new N_e(l),new x_e(l)];return YN.forEach(i=>{!p.some(r=>r.id===i.id)&&!L_i.includes(i.id)&&p.push(new od(i,l))}),p.forEach(i=>{l.subscribeBuiltInInstance(i)}),l.builtInBaseEntities=p,p}function oke(l){const p=[new xa(Ee,l),new xa(ct,l),new xa(Ne,l),new xa(Aa,l),new xa(Rt,l),new xa(Pt,l),new xa(ut,l),new xa(ro,l),new xa(nr,l)];return p.forEach(i=>{l.subscribeBuiltInInstance(i)}),l.primitives=p,p}function dke(l){const p=[new Hi(i1,l)];return p.forEach(i=>{i.initChildren(null),l.subscribeBuiltInInstance(i)}),l.globalEventActionDescriptors=p,p}function uke(l){const p=[new Hi(lE,l),new Hi(Ff,l),new Hi(aE,l),new Hi(vm,l),new Hi(Em,l),new Hi(BR,l)];p.forEach(r=>{r.initChildren(null),l.subscribeBuiltInInstance(r)}),l.loopDeclarations=p;const i=[new Hi(ZR,l),new Hi(sE,l),new Hi(kR,l),new Hi(PN,l),new Hi($N,l),new Hi(MR,l)];return i.forEach(r=>{r.initChildren(null),l.subscribeBuiltInInstance(r)}),l.loopDeclarationsBodies=i,p}function pke(l){const p=[new ud(rx,l)];return p.forEach(i=>{i.initChildren(null),l.subscribeBuiltInInstance(i)}),l.valueDescriptors=p,p}function cke(l){const p=[new Hi(QN,l),new Hi(JN,l),new Hi(XN,l),new Hi(ex,l)];return tx.forEach(i=>{p.some(r=>r.id===i.id)||p.push(new Hi(i,l))}),p.forEach(i=>{i.initChildren(null),l.subscribeBuiltInInstance(i)}),l.conditionDeclarations=p,p}function OT(l){return l&&typeof l.then=="function"}function B_i(l,p){const i=new Bn(l[0],{allBuiltInEntityIds:p.allBuiltInEntityIds}),r=l.map(c=>c.id),a={};return l.forEach(c=>{a[c.id]=c}),i.order=r,i.flatRecord=a,i.orderEntities(),i.order.map(c=>i.flatRecord[c])}function M_i(l,p){const i=new Bn(Object.values(l)[0],{allBuiltInEntityIds:p.allBuiltInEntityIds}),r=Object.keys(l);return i.order=r,i.flatRecord=l,i.orderEntities(),i.order}async function G_i(l,p){const i=Y.YieldTracker.from(p),r=new Bn(l[0],{allBuiltInEntityIds:p.allBuiltInEntityIds}),a=l.map(e=>e.id),c={};for(const e of l)c[e.id]=e,await i.tick();return r.order=a,r.flatRecord=c,await r.orderEntitiesAsync({tracker:i}),r.order.map(e=>r.flatRecord[e])}async function j_i(l,p){const i=Y.YieldTracker.from(p),r=new Bn(Object.values(l)[0],{allBuiltInEntityIds:p.allBuiltInEntityIds}),a=Object.keys(l);return r.order=a,r.flatRecord=l,await r.orderEntitiesAsync({tracker:i}),r.order}class Bn{constructor(p,i={}){R(this,"order",[]);R(this,"flatRecord",{});R(this,"allBuiltInEntityIds");R(this,"onGoingVisits",{});R(this,"cachedReferences",{});if(i.allBuiltInEntityIds&&(this.allBuiltInEntityIds=i.allBuiltInEntityIds),!p)return;const r={asyncInitialOrder:!1,...i};r.asyncInitialOrder?this.flattenAsync(p).then(()=>{this.orderEntitiesAsync({...r}).then(()=>{var a;(a=r.onOrdered)==null||a.call(r)})}):(this.flatten(p),this.orderEntities())}flatten(p){this.allBuiltInEntityIds||(this.allBuiltInEntityIds=new Set(z1()));const i=C(Ue(p,new Set(this.allBuiltInEntityIds),{ignoreBuiltInBaseEntities:!0,diggestedBuiltInBaseEntitiesIds:this.allBuiltInEntityIds})),r=new Set;for(const a of i)this.flatRecord[a.id]=a,r.add(a.id);this.order=Array.from(r)}async flattenAsync(p,i={}){const r=Y.YieldTracker.from(i);this.allBuiltInEntityIds||(this.allBuiltInEntityIds=await Y1({tracker:r}));const a=await pp(await ke(p,new Set(this.allBuiltInEntityIds),{ignoreBuiltInBaseEntities:!0,diggestedBuiltInBaseEntitiesIds:this.allBuiltInEntityIds,tracker:r}),{tracker:r}),c=new Set;for(const e of a)this.flatRecord[e.id]=e,c.add(e.id),await r.tick();this.order=Array.from(c)}moveEntityAfterDependencies(p){const i=this.cachedReferences[p.id]||Jl(p,this.flatRecord,{ignoreBuiltInBaseEntities:!0,allBuiltInEntityIds:this.allBuiltInEntityIds});this.cachedReferences[p.id]=i;const{upstream:r}=i;for(const a of Object.keys(r)){const c=this.order.indexOf(a),e=this.order.indexOf(p.id);if(c>e)return this.order.splice(e,1),this.order.splice(c,0,p.id),!0}return!1}orderEntities(){let p=!1;for(let i=0;i<this.order.length;i++){const r=this.order[i],a=this.flatRecord[r];if(a||Y.Logger.warn(`Entity with id ${r} not found in flatRecord. Skipping...`),this.moveEntityAfterDependencies(a)){p=!0;break}}p&&this.orderEntities()}async orderEntitiesAsync(p={}){let i=!1;const r=Y.YieldTracker.from(p);for(let a=0;a<this.order.length;a++){const c=this.order[a],e=this.flatRecord[c];if(e||Y.Logger.warn(`Entity with id ${c} not found in flatRecord. Skipping...`),this.moveEntityAfterDependencies(e)){i=!0;break}await r.tick()}i&&await this.orderEntitiesAsync({tracker:r})}getUpstreamOngoingDependenciesVisits(p,i){const r=this.cachedReferences[p]||Jl(this.flatRecord[p],this.flatRecord,{ignoreBuiltInBaseEntities:!0,allBuiltInEntityIds:this.allBuiltInEntityIds});this.cachedReferences[p]=r;const{upstream:a}=r,c={};return Object.entries(this.onGoingVisits[i]||{}).forEach(([e,f])=>{Object.keys(a).includes(e)&&(c[e]=f)}),c}getDownstreamOngoingDependenciesVisits(p,i){const r=Object.keys(this.onGoingVisits[i]||{}),a=new Set(r.flatMap(e=>{const f=this.cachedReferences[e]||Jl(this.flatRecord[e],this.flatRecord,{ignoreBuiltInBaseEntities:!0,allBuiltInEntityIds:this.allBuiltInEntityIds});return this.cachedReferences[e]=f,Object.keys(f.downstream)})),c={};return Array.from(a).forEach(e=>{e===p&&(c[e]=this.onGoingVisits[i][e])}),c}async settlePromises(p,i){const r=Object.values(p);r.length&&await Promise.all(r),Object.keys(p).forEach(a=>{delete this.onGoingVisits[i][a]})}visit(p){const i=this.order;for(const r of i)p(this.flatRecord[r],this.flatRecord);return this}reverseVisit(p){const i=this.order.slice().reverse();for(const r of i)p(this.flatRecord[r],this.flatRecord);return this}async visitAsync(p,i={}){const{parallelise:r}={parallelise:!0,...i},a=Y.YieldTracker.from(i),c=this.order;if(!r){for(const f of c){const h=p(this.flatRecord[f],this.flatRecord);OT(h)&&await h,await a.tick()}return this}const e=Math.random().toString(36).substring(7);this.onGoingVisits[e]={};for(const f of c){const h=this.getUpstreamOngoingDependenciesVisits(f,e);Object.keys(h).length&&await this.settlePromises(h,e);const m=p(this.flatRecord[f],this.flatRecord);OT(m)&&(this.onGoingVisits[e][f]=m),await a.tick()}return await this.settlePromises(this.onGoingVisits[e],e),this.onGoingVisits[e]={},this}async reverseVisitAsync(p,i={}){const{parallelise:r}={parallelise:!0,...i},a=Y.YieldTracker.from(i),c=this.order.slice().reverse();if(!r){for(const f of c){const h=p(this.flatRecord[f],this.flatRecord);OT(h)&&await h,await a.tick()}return this}const e=Math.random().toString(36).substring(7);this.onGoingVisits[e]={};for(const f of c){const h=this.getDownstreamOngoingDependenciesVisits(f,e);Object.keys(h).length&&await this.settlePromises(h,e);const m=p(this.flatRecord[f],this.flatRecord);OT(m)&&(this.onGoingVisits[e][f]=m),await a.tick()}return await this.settlePromises(this.onGoingVisits[e],e),this.onGoingVisits[e]={},this}}const uf={},HA={},iv={empty:!1,enrich:!0,mock:!1,ignoreCache:!1,onFetch:async()=>null,manuallyInit:!1};function fke(l,p={enrich:!0,shallowErrors:!1},i){const r={enrich:!0,shallowErrors:!1,...p},{enrich:a,shallowErrors:c}=r,e=l.project,f=l.record,h=K1(l.project,{shallowErrors:c},i);h.instances[e.id]=h;const m=new Bn(e,{allBuiltInEntityIds:h.diggestedBuiltInBaseEntitiesIds}),E=new Set;f[e.id]=e,E.add(e.id);const b=B().toISOString();Object.values(f).forEach(_=>{!_||m.allBuiltInEntityIds.has(_.id)||E.add(_.id)}),m.order=Array.from(E),m.flatRecord=f,m.orderEntities();const A=a?h.addChangeSet(new S(h,x.sessionAuthor,b,h,!0,"project-init-from-fetch-result")):null;return m.visit(_=>{if(_.id===h.id)return;const N=Ae(_,h);try{N.hydrateAncestors(),N.addSelfToProject(null);const V=Jl(_);Object.keys(V.downstream).forEach(j=>{const M=h.get(j);M&&M.hydrateAncestors()})}catch(V){if(c)Y.Logger.error("Error hydrating ancestors: ",V);else throw V}}),a?(m.visit(_=>{if(_.id===h.id)return;const N=h.get(_.id);if(N)try{N.afterAllChildrenInitialized(A),N.captureVersion()}catch(V){if(c)Y.Logger.error("Error in afterAllChildrenInitialized: ",V);else throw V}}),h.afterAllChildrenInitialized(A),h.subscribe(),h.captureVersion()):(Pu(h,b).forEach(N=>{N.remove({ignoreUpstream:!0},null)}),m.visit(N=>{if(N.id===h.id)return;const V=h.get(N.id);V&&(V.initialized=!0,V.captureVersion())}),h.initialized=!0,h.subscribe(),h.captureVersion()),h.initialized=!0,h.emit(si.PROJECT_INITIALIZED,h,A),A==null||A.attemptAutoclose("project-init-from-fetch-result",h.id),h}async function k_i(l,p={enrich:!0,shallowErrors:!1,yieldEvery:100},i){const r={enrich:!0,shallowErrors:!1,yieldEvery:100,...p},{enrich:a,shallowErrors:c,yieldEvery:e}=r,f=Y.YieldTracker.from({yieldEvery:e}),h=l.project,m=l.record,E=await q1(l.project,{shallowErrors:c,tracker:f},i);E.instances[h.id]=E;const b=new Bn(void 0,{allBuiltInEntityIds:E.diggestedBuiltInBaseEntitiesIds});await b.flattenAsync(h,{tracker:f}),await b.orderEntitiesAsync({tracker:f});const A=new Set;m[h.id]=h,A.add(h.id);const _=B().toISOString();for(const[V,j]of Object.entries(m))!j||b.allBuiltInEntityIds.has(j.id)||(A.add(j.id),await f.tick());b.order=Array.from(A),b.flatRecord=m,await b.orderEntitiesAsync({tracker:f});const N=a?E.addChangeSet(new S(E,x.sessionAuthor,_,E,!0,"project-init-from-fetch-result")):null;if(await b.visitAsync(V=>{if(V.id===E.id)return;const j=Ae(V,E);try{j.hydrateAncestors(),j.addSelfToProject(null);const M=Jl(V);Object.keys(M.downstream).forEach(G=>{const q=E.get(G);q&&q.hydrateAncestors()})}catch(M){if(c)Y.Logger.error("Error hydrating ancestors: ",M);else throw Y.Logger.log("Error hydrating ancestors: ",M),M}},{tracker:f}),a){try{await b.visitAsync(V=>{if(V.id===E.id)return;const j=E.get(V.id);j&&(j.afterAllChildrenInitialized(N),j.captureVersion())},{tracker:f})}catch(V){if(c)Y.Logger.error("Error in afterAllChildrenInitialized: ",V);else throw Y.Logger.log("Error in afterAllChildrenInitialized: ",V),V}E.afterAllChildrenInitialized(N),E.subscribe(),E.captureVersion()}else Pu(E,_).forEach(j=>{j.remove({ignoreUpstream:!0},null)}),await b.visitAsync(j=>{if(j.id===E.id)return;const M=E.get(j.id);M&&(M.initialized=!0,M.captureVersion())},{tracker:f}),E.initialized=!0,E.subscribe(),E.captureVersion();return E.initialized=!0,E.emit(si.PROJECT_INITIALIZED,E,N),N==null||N.attemptAutoclose("project-init-from-fetch-result",E.id),E}async function U_i(l,p=iv){const i={...iv,...p};if(i.empty)return{data:{project:{id:l.id,deletable:!0,editable:!0,type:d.Project,version:x.UUID.uuid(),createdAt:B().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,name:null,description:null,projects:[],entities:[],operations:[],functions:[],variableDeclarations:[],variableInstances:[],functionCalls:[],conditions:[],loops:[],searches:[],events:[]},record:{}}};if(i.mock){const a={...r2};return a.id=l.id,{data:{project:a,record:{}}}}return Y.Logger.log("Fetching project from external API"),new Promise(async a=>{try{if(i.onFetch){const c=await i.onFetch(l.id);if(c){a({data:c});return}}else a({data:null})}catch(c){Y.Logger.error("Error fetching project: ",c),a({data:null})}})}function K1(l,p={shallowErrors:!1},i){const r=new x(l,i);oke(r),lke(r),ske(r),dke(r),uke(r),pke(r),cke(r);const a=p.allBuiltInIds??new Set([...r.getAllBuiltInIds(),...z1()]);return r.diggestedBuiltInBaseEntitiesIds=a,a.forEach(c=>{if(!r.builtInInstances[c]&&r.instances[c])r.builtInInstances[c]=r.instances[c],delete r.instances[c];else if(!r.builtInInstances[c]&&!p.shallowErrors)throw new Error(`Built in entity was not properly initialized: ${c}`)}),r.instances[r.id]=r,r.activeVersion=!0,r}async function q1(l,p={shallowErrors:!1},i){const r=Y.YieldTracker.from(p),a=new x(l,i);oke(a),lke(a),await Y.yieldToEventLoop(),ske(a),await Y.yieldToEventLoop(),dke(a),uke(a),pke(a),cke(a),await Y.yieldToEventLoop();const c=p.allBuiltInIds??new Set([...a.getAllBuiltInIds(),...await Y1()]);a.diggestedBuiltInBaseEntitiesIds=c;for(const e of c){if(!a.builtInInstances[e]&&a.instances[e])a.builtInInstances[e]=a.instances[e],delete a.instances[e];else if(!a.builtInInstances[e]&&!p.shallowErrors)throw new Error(`Built in entity was not properly initialized: ${e}`);a.instances[e]&&delete a.instances[e],await r.tick()}return a.instances[a.id]=a,a.activeVersion=!0,a}function Pu(l,p){return l.instancesList.filter(r=>B(r.createdAt).isAfter(B(p)||!!r.previousVersion))}function F_i(l,{enrich:p,shallowErrors:i,...r}={enrich:!0,shallowErrors:!1},a){var _,N;const c=new Map,e=new Map;Object.keys(l.instances).forEach(V=>{if(l.diggestedBuiltInBaseEntitiesIds.has(V)){c.set(V,V),e.set(V,V);return}const j=l.get(V);if(!rD(j,{...l.instances,...l.builtInInstances}).every(re=>!l.diggestedBuiltInBaseEntitiesIds.has(re))){c.set(V,V),e.set(V,V);return}const q=x.UUID.uuid();c.set(V,q),e.set(q,V)});const f=((_=r.resetVersionOptions)==null?void 0:_.commonTimestamp)??B().toISOString(),h=l.toShallowJSON({seenEntityMaps:c});h.previousVersion=null,h.createdAt=f,h.version=x.UUID.uuid(),h.author=((N=r.resetVersionOptions)==null?void 0:N.author)??(x.sessionAuthor||"1");const m=K1(h,{shallowErrors:i,allBuiltInIds:l.diggestedBuiltInBaseEntitiesIds},a);m.instances[m.id]=m;const E=p?m.addChangeSet(new S(m,x.sessionAuthor,f,m,!0,"project-clone")):null,b=new Bn(l,{allBuiltInEntityIds:l.diggestedBuiltInBaseEntitiesIds}),A=uL(b.flatRecord,c);return b.visit(V=>{var q;const j=V.toShallowJSON({seenEntityMaps:c});j.previousVersion=null,j.createdAt=f,j.version=x.UUID.uuid(),j.author=((q=r.resetVersionOptions)==null?void 0:q.author)??(x.sessionAuthor||"1");const M=Jl(j,A);if(Object.keys(M.upstream).length){let re=!1;if(Object.keys(M.upstream).forEach(ee=>{if(!re&&(!m.get(ee)||m.getDeleted(ee))){re=!0;return}}),re)return}const G=Ae(j,m);G.hydrateAncestors(),G.addSelfToProject(E),E==null||E.add(G,W.Added),r.onVisit&&r.onVisit(j)}),p?(b.visit(V=>{if(V.id===m.id)return;const j=m.get(c.get(V.id));j&&(j.afterAllChildrenInitialized(E),j.captureVersion())}),m.afterAllChildrenInitialized(E),m.subscribe(),m.captureVersion()):(Pu(m,f).forEach(j=>{j.remove({ignoreUpstream:!0},null)}),b.visit(j=>{if(j.id===m.id)return;const M=m.get(j.id);M&&(M.initialized=!0,M.captureVersion())}),m.initialized=!0,m.subscribe(),m.captureVersion()),m.instancesList.forEach(V=>{V.previousVersion=null}),E==null||E.attemptAutoclose("project-clone",m.id),{project:m,maps:c}}async function K_i(l,{shallowErrors:p,...i}={shallowErrors:!1,yieldEvery:100}){var m,E;const r=Y.YieldTracker.from(i),a=new Map,c=new Map;Object.keys(l.instances).forEach(b=>{if(l.diggestedBuiltInBaseEntitiesIds.has(b)){a.set(b,b),c.set(b,b);return}const A=x.UUID.uuid();a.set(b,A),c.set(A,b)});const e=((m=i.resetVersionOptions)==null?void 0:m.commonTimestamp)??B().toISOString(),f=l.toShallowJSON({seenEntityMaps:a});f.previousVersion=null,f.createdAt=e,f.version=x.UUID.uuid(),f.author=((E=i.resetVersionOptions)==null?void 0:E.author)??(x.sessionAuthor||"1");const h=await l.toFullProjectTransferAsync({tracker:r,seenEntityMaps:a,resetVersionOptions:i.resetVersionOptions,onVisit:i.onVisit});return{project:f,record:h.record,order:h.order,maps:a}}async function q_i(l,{enrich:p,shallowErrors:i,...r}={enrich:!0,shallowErrors:!1,yieldEvery:100},a){var N,V;const c=Y.YieldTracker.from(r),e=new Map,f=new Map;for(const j of Object.keys(l.instances)){if(l.diggestedBuiltInBaseEntitiesIds.has(j)){e.set(j,j),f.set(j,j),await c.tick();continue}const M=x.UUID.uuid();e.set(j,M),f.set(M,j),await c.tick()}const h=((N=r.resetVersionOptions)==null?void 0:N.commonTimestamp)??B().toISOString(),m=l.toShallowJSON({seenEntityMaps:e});m.previousVersion=null,m.createdAt=h,m.version=x.UUID.uuid(),m.author=((V=r.resetVersionOptions)==null?void 0:V.author)??(x.sessionAuthor||"1");const E=await q1(m,{shallowErrors:i,tracker:c},a);E.diggestedBuiltInBaseEntitiesIds=l.diggestedBuiltInBaseEntitiesIds,E.instances[E.id]=E;const b=p?E.addChangeSet(new S(E,x.sessionAuthor,h,E,!0,"project-clone")):null,A=new Bn(void 0,{allBuiltInEntityIds:l.diggestedBuiltInBaseEntitiesIds}),_=await l.toFullProjectTransferAsync({tracker:c,seenEntityMaps:e,resetVersionOptions:r.resetVersionOptions,onVisit:r.onVisit,shallowErrors:i});A.flatRecord=_.record,A.order=_.order,await A.visitAsync(j=>{var re;if(l.diggestedBuiltInBaseEntitiesIds.has(j.id))return;const M=j;M.previousVersion=null,M.createdAt=h,M.version=x.UUID.uuid(),M.author=((re=r.resetVersionOptions)==null?void 0:re.author)??(x.sessionAuthor||"1");const G=Jl(M,A.flatRecord);if(Object.keys(G.upstream).length){let ee=!1;if(Object.keys(G.upstream).forEach(de=>{if(!ee&&(!E.get(de)||E.getDeleted(de))){ee=!0;return}}),ee)return}const q=Ae(M,E);q.hydrateAncestors(),q.addSelfToProject(b),b==null||b.add(q,W.Added)},{tracker:c}),p?(await A.visitAsync(j=>{if(j.id===E.id||l.diggestedBuiltInBaseEntitiesIds.has(j.id))return;const M=E.get(e.get(j.id));M&&(M.afterAllChildrenInitialized(b),M.captureVersion())},{tracker:c}),E.afterAllChildrenInitialized(b),E.subscribe(),E.captureVersion()):(Pu(E,h).forEach(M=>{M.remove({ignoreUpstream:!0},null)}),await A.visitAsync(M=>{if(M.id===E.id)return;const G=E.get(M.id);G&&(G.initialized=!0,G.captureVersion())},{tracker:c}),E.initialized=!0,E.subscribe(),E.captureVersion());for(const j of E.instancesList)j.previousVersion=null,await c.tick();return b==null||b.attemptAutoclose("project-clone",E.id),{project:E,maps:e}}function S_i(l,p,i=p.addChangeSet(new S(p,x.sessionAuthor,B().toISOString(),p,!0,w.AfterAllChildrenInitialized)),{enrich:r,shallowErrors:a,...c}={shallowErrors:!1,enrich:!0}){var A,_;const e=new Map,f=new Map;Object.keys(l.instances).forEach(N=>{if(l.diggestedBuiltInBaseEntitiesIds.has(N)){e.set(N,N),f.set(N,N);return}if(N===l.id){e.set(N,p.id),f.set(p.id,N);return}const V=l.get(N);if(!rD(V,{...l.instances,...l.builtInInstances}).every(q=>!l.diggestedBuiltInBaseEntitiesIds.has(q))){e.set(N,N),f.set(N,N);return}const G=x.UUID.uuid();e.set(N,G),f.set(G,N)});const h=((A=c.resetVersionOptions)==null?void 0:A.commonTimestamp)??B().toISOString(),m=l.toShallowJSON({seenEntityMaps:e});m.previousVersion=null,m.createdAt=h,m.version=x.UUID.uuid(),m.author=((_=c.resetVersionOptions)==null?void 0:_.author)??(x.sessionAuthor||"1");const E=new Bn(l,{allBuiltInEntityIds:l.diggestedBuiltInBaseEntitiesIds}),b=uL(E.flatRecord,e);return E.visit(N=>{var M;if(N.id===p.id)return;const V=N.toShallowJSON({seenEntityMaps:e});V.previousVersion=null,V.createdAt=h,V.version=x.UUID.uuid(),V.author=((M=c.resetVersionOptions)==null?void 0:M.author)??(x.sessionAuthor||"1");const j=Jl(V,b);if(Object.keys(j.upstream).length){let G=!1;if(Object.keys(j.upstream).forEach(q=>{if(!G&&(!p.get(q)||p.getDeleted(q))){G=!0;return}}),G)return}try{const G=Ae(V,p);G.hydrateAncestors(),G.addSelfToProject(i),i==null||i.add(G,W.Added),c.onVisit&&c.onVisit(V)}catch(G){if(a)Y.Logger.error("Error cloning entity onto existing project: ",G);else throw Y.Logger.log("Error cloning entity onto existing project: ",G),G}}),r?(E.visit(N=>{if(N.id===p.id)return;const V=p.get(e.get(N.id));V&&(V.afterAllChildrenInitialized(i),V.previousVersion=null,V.captureVersion())}),p.afterAllChildrenInitialized(i),p.subscribe(),p.captureVersion()):(Pu(p,h).forEach(V=>{V.remove({ignoreUpstream:!0},null)}),E.visit(V=>{if(V.id===p.id)return;const j=p.get(V.id);j&&(j.initialized=!0,j.previousVersion=null,j.captureVersion())}),p.initialized=!0,p.subscribe(),p.captureVersion()),p.afterAllChildrenInitialized(i),p.captureVersion(),{project:p,maps:e,changeSet:i}}async function Z_i(l,p,i=p.addChangeSet(new S(p,x.sessionAuthor,B().toISOString(),p,!0,w.AfterAllChildrenInitialized)),{enrich:r,shallowErrors:a,...c}={enrich:!0,shallowErrors:!1,yieldEvery:100}){var _,N;const e=Y.YieldTracker.from(c),f=new Map,h=new Map;for(const V of Object.keys(l.instances)){if(l.diggestedBuiltInBaseEntitiesIds.has(V)){f.set(V,V),h.set(V,V),await e.tick();continue}if(V===l.id){f.set(V,p.id),h.set(p.id,V),await e.tick();continue}const j=x.UUID.uuid();f.set(V,j),h.set(j,V),await e.tick()}const m=((_=c.resetVersionOptions)==null?void 0:_.commonTimestamp)??B().toISOString(),E=l.toShallowJSON({seenEntityMaps:f});E.previousVersion=null,E.createdAt=m,E.version=x.UUID.uuid(),E.author=((N=c.resetVersionOptions)==null?void 0:N.author)??(x.sessionAuthor||"1"),p.diggestedBuiltInBaseEntitiesIds=l.diggestedBuiltInBaseEntitiesIds;const b=new Bn(void 0,{allBuiltInEntityIds:l.diggestedBuiltInBaseEntitiesIds}),A=await l.toFullProjectTransferAsync({tracker:e,seenEntityMaps:f,resetVersionOptions:c.resetVersionOptions,onVisit:c.onVisit,shallowErrors:a});return b.flatRecord=A.record,b.order=A.order,await b.visitAsync(V=>{var G;if(l.diggestedBuiltInBaseEntitiesIds.has(V.id)||V.id===p.id)return;const j=V;j.previousVersion=null,j.createdAt=m,j.version=x.UUID.uuid(),j.author=((G=c.resetVersionOptions)==null?void 0:G.author)??(x.sessionAuthor||"1");const M=Jl(j,b.flatRecord);if(Object.keys(M.upstream).length){let q=!1;if(Object.keys(M.upstream).forEach(re=>{if(!q&&(!p.get(re)||p.getDeleted(re))){q=!0;return}}),q)return}try{const q=Ae(j,p);q.hydrateAncestors(),q.addSelfToProject(i),i==null||i.add(q,W.Added)}catch(q){if(a)Y.Logger.error("Error cloning entity onto existing project: ",q);else throw Y.Logger.log("Error cloning entity onto existing project: ",q),q}},{tracker:e}),r?(await b.visitAsync(V=>{if(V.id===p.id||l.diggestedBuiltInBaseEntitiesIds.has(V.id))return;const j=p.get(f.get(V.id));j&&(j.afterAllChildrenInitialized(i),j.previousVersion=null,j.captureVersion())},{tracker:e}),p.afterAllChildrenInitialized(i),p.subscribe(),p.captureVersion()):(Pu(p,m).forEach(j=>{j.remove({ignoreUpstream:!0},null)}),await b.visitAsync(j=>{if(j.id===p.id)return;const M=p.get(j.id);M&&(M.initialized=!0,M.previousVersion=null,M.captureVersion())},{tracker:e}),p.initialized=!0,p.subscribe(),p.captureVersion()),p.afterAllChildrenInitialized(i),p.captureVersion(),{project:p,maps:f,changeSet:i}}function yke(l,{enrich:p,shallowErrors:i}={enrich:!0,shallowErrors:!1},r){const a=K1(l,{shallowErrors:i},r);a.activeVersion=!0;const c=B().toISOString(),e=p?a.addChangeSet(new S(a,x.sessionAuthor,c,a,!0,"project-init")):null;e&&(e.type=r1.Automatic);const f=new Bn(l,{allBuiltInEntityIds:a.diggestedBuiltInBaseEntitiesIds});return f.visit(h=>{const m=Ae(h,a);m.hydrateAncestors(),m.addSelfToProject(e)}),p?(f.visit(h=>{if(h.id===a.id)return;const m=a.get(h.id);m&&(m.afterAllChildrenInitialized(e),m.captureVersion())}),a.afterAllChildrenInitialized(e),a.subscribe(),a.captureVersion()):(Pu(a,c).forEach(m=>{m.remove({ignoreUpstream:!0},null)}),f.visit(m=>{if(m.id===a.id)return;const E=a.get(m.id);E&&(E.initialized=!0,E.captureVersion())}),a.initialized=!0,a.subscribe(),a.captureVersion()),a.initialized=!0,a.emit(si.PROJECT_INITIALIZED,a,e),e==null||e.attemptAutoclose("project-init",a.id),a}async function H_i(l,{enrich:p,shallowErrors:i,yieldEvery:r}={enrich:!0,shallowErrors:!1,yieldEvery:100},a){const c=Y.YieldTracker.from({yieldEvery:r}),e=await q1(l,{shallowErrors:i,tracker:c},a),f=B().toISOString(),h=p?e.addChangeSet(new S(e,x.sessionAuthor,f,e,!0,"project-init")):null;h&&(h.type=r1.Automatic);const m=new Bn(void 0,{allBuiltInEntityIds:e.diggestedBuiltInBaseEntitiesIds});return await m.flattenAsync(l,{tracker:c}),await m.orderEntitiesAsync({tracker:c}),await m.visitAsync(E=>{const b=Ae(E,e);b.hydrateAncestors(),b.addSelfToProject(h)},{tracker:c}),p?(await m.visitAsync(E=>{if(E.id===e.id)return;const b=e.get(E.id);b&&(b.afterAllChildrenInitialized(h),b.captureVersion())},{tracker:c}),e.afterAllChildrenInitialized(h),e.subscribe(),e.captureVersion()):(Pu(e,f).forEach(b=>{b.remove({ignoreUpstream:!0},null)}),await m.visitAsync(b=>{if(b.id===e.id)return;const A=e.get(b.id);A&&(A.initialized=!0,A.captureVersion())},{tracker:c}),e.initialized=!0,e.subscribe(),e.captureVersion()),e.initialized=!0,e.emit(si.PROJECT_INITIALIZED,e,h),h==null||h.attemptAutoclose("project-init",e.id),e}async function W_i(l,p=iv,i){const r={...iv,...p};if(l.id&&uf[l.id]&&!r.ignoreCache)return uf[l.id];if(l.id&&HA[l.id]&&!r.ignoreCache)return await HA[l.id],uf[l.id];const a=U_i(l,r);l.id&&(HA[l.id]=a);const c=await a;if(c.data){let e;return r.mock?e=yke(r2,{enrich:!!r.enrich},i):c.data instanceof x?e=c.data:e=fke(c.data,{enrich:!!r.enrich},i),uf[l.id]=e,l.id&&delete HA[l.id],e}return null}function z_i(l){return uf[l.id]&&delete uf[l.id],null}const rv=Tt([He(),ba(),fr(),Wd()]),hke=Dm([en.CurrentDateAndTime,en.Random,en.Unique]),S1=st({type:hke,rangeStart:rv.nullable(),rangeEnd:rv.nullable()}),UE=S1.extend({type:rt(en.Random),rangeStart:rv,rangeEnd:rv}),mke=S1.extend({type:rt(en.Unique),rangeStart:os(),rangeEnd:os()}),Tke=S1.extend({type:rt(en.CurrentDateAndTime),rangeStart:os(),rangeEnd:os()}),Z1=UE.extend({rangeStart:ba().nullable(),rangeEnd:ba().nullable()}),vke=Z1.extend({rangeStart:ba(),rangeEnd:os()}),Eke=Z1.extend({rangeStart:os(),rangeEnd:ba()}),bke=Z1.extend({rangeStart:ba(),rangeEnd:ba()}),H1=UE.extend({rangeStart:ba().nullable(),rangeEnd:ba().nullable()}),Ake=H1.extend({rangeStart:ba(),rangeEnd:os()}),Ike=H1.extend({rangeStart:os(),rangeEnd:ba()}),gke=H1.extend({rangeStart:ba(),rangeEnd:ba()}),W1=UE.extend({rangeStart:Wd().nullable(),rangeEnd:Wd().nullable()}),Rke=W1.extend({rangeStart:Wd(),rangeEnd:os()}),Dke=W1.extend({rangeStart:os(),rangeEnd:Wd()}),wke=W1.extend({rangeStart:Wd(),rangeEnd:Wd()}),Cke=UE.extend({rangeStart:os(),rangeEnd:os()}),Oke=Tt([Ake,Ike,gke]),_ke=Tt([vke,Eke,bke]),Vke=Tt([Rke,Dke,wke,Tke]),Y_i=Tt([Oke,_ke,Vke,mke,Cke]);function z1(){const l=new Set;return new Set(nx.flatMap(i=>Ue(i,l)).map(i=>i.id))}function No(l){return[...l.calledByEntry||[],...l.calledByError||[],...l.calledBySuccess||[]].filter(p=>p.type!==d.GenericReference)}function Pke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.ActionDescriptor)throw new Error("Entity must be an action descriptor to be flattened");return[l,...l.inputs.flatMap(r=>Ue(r,p,i)),...l.dataType?Ue(l.dataType,p,i):[],...l.error?Ue(l.error,p,i):[],...l.parent?Ue(l.parent,p,i):[]]}function Nke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.ArgumentDeclaration)throw new Error("Entity must be an argument declaration to be flattened");return[l,...l.defaultValue?Ue(l.defaultValue,p):[],...l.writesValues.flatMap(r=>Ue(r,p,i)),...l.implements.flatMap(r=>Ue(r,p,i)),...l.dataType?Ue(l.dataType,p,i):[],...l.parent?Ue(l.parent,p,i):[]]}function xke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.BreakStatement)throw new Error("Entity must be a break statement to be flattened");return[l,...l.outputs.flatMap(r=>Ue(r,p,i)),...l.throws?Ue(l.throws,p,i):[],...l.dataType?Ue(l.dataType,p,i):[],...l.readsValue?Ue(l.readsValue,p,i):[],...(No(l)||[]).flatMap(r=>Ue(r,p,i)),...l.parent?Ue(l.parent,p,i):[]]}function $ke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.BuiltInBaseEntity)throw new Error("Entity must be a built-in base entity to be flattened");return[l,...(l.properties||[]).flatMap(r=>Ue(r,p,i)),...(l.methods||[]).flatMap(r=>Ue(r,p,i)),...(l.abstractMethods||[]).flatMap(r=>Ue(r,p,i)),...l.allPropertiesImplement?Ue(l.allPropertiesImplement,p,i):[],...l.additionalPropertiesDataType?Ue(l.additionalPropertiesDataType,p,i):[],...l.extends?Ue(l.extends,p,i):[]]}function Lke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.Condition)throw new Error("Entity must be a condition to be flattened");return[l,...(l.andChildrenGroup||[]).flatMap(r=>Ue(r,p,i)),...(l.orChildrenGroup||[]).flatMap(r=>Ue(r,p,i)),...(l.inputs||[]).flatMap(r=>Ue(r,p,i)),...(l.successCalls||[]).flatMap(r=>Ue(r,p,i)),...(l.errorCalls||[]).flatMap(r=>Ue(r,p,i)),...(No(l)||[]).flatMap(r=>Ue(r,p,i)),...l.parent?Ue(l.parent,p,i):[]]}function Bke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.ContinueStatement)throw new Error("Entity must be a continue statement to be flattened");return[l,...l.outputs.flatMap(r=>Ue(r,p,i)),...l.readsValue?Ue(l.readsValue,p,i):[],...l.throws?Ue(l.throws,p,i):[],...l.dataType?Ue(l.dataType,p,i):[],...(No(l)||[]).flatMap(r=>Ue(r,p,i)),...l.parent?Ue(l.parent,p,i):[]]}function Mke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.DefinitionEntity)throw new Error("Entity must be a definition entity to be flattened");return[l,...l.extends?Ue(l.extends,p,i):[],...(l.implements||[]).flatMap(r=>Ue(r,p,i)),...(l.properties||[]).flatMap(r=>Ue(r,p,i)),...(l.methods||[]).flatMap(r=>Ue(r,p,i)),...(l.abstractMethods||[]).flatMap(r=>Ue(r,p,i)),...l.allPropertiesImplement?Ue(l.allPropertiesImplement,p,i):[],...l.additionalPropertiesDataType?Ue(l.additionalPropertiesDataType,p,i):[],...l.parent?Ue(l.parent,p,i):[]]}function Gke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.DataType)throw new Error("Entity must be a data type to be flattened");return[l,...(l.andChildrenGroup||[]).flatMap(r=>Ue(r,p,i)),...(l.orChildrenGroup||[]).flatMap(r=>Ue(r,p,i)),...l.entity?Ue(l.entity,p,i):[],...l.foreignKeyRef?Ue(l.foreignKeyRef,p,i):[],...l.parent?Ue(l.parent,p,i):[]]}function jke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.FunctionCall)throw new Error("Entity must be a function call to be flattened");return[l,...(l.inputs||[]).flatMap(r=>Ue(r,p,i)),...(l.outputs||[]).flatMap(r=>Ue(r,p,i)),...l.error?Ue(l.error,p,i):[],...(No(l)||[]).flatMap(r=>Ue(r,p,i)),...(l.successCalls||[]).flatMap(r=>Ue(r,p,i)),...(l.errorCalls||[]).flatMap(r=>Ue(r,p,i)),...(l.writesValues||[]).flatMap(r=>Ue(r,p,i)),...l.parent?Ue(l.parent,p,i):[]]}function kke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.FunctionDeclaration)throw new Error("Entity must be a function declaration to be flattened");return[l,...(l.inputs||[]).flatMap(r=>Ue(r,p,i)),...(l.calls||[]).flatMap(r=>Ue(r,p,i)),...l.dataType?Ue(l.dataType,p,i):[],...l.implements?Ue(l.implements,p,i):[],...l.parent?Ue(l.parent,p,i):[]]}function Uke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.GlobalEvent)throw new Error("Entity must be a global event to be flattened");return[l,...(l.inputs||[]).flatMap(r=>Ue(r,p,i)),...(l.calls||[]).flatMap(r=>Ue(r,p,i)),...l.implements?Ue(l.implements,p,i):[],...l.parent?Ue(l.parent,p,i):[]]}function Fke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.InputMap)throw new Error("Entity must be an input map to be flattened");return[l,...l.readsValue?Ue(l.readsValue,p,i):[],...l.declaration?Ue(l.declaration,p,i):[],...l.defaultValue?Ue(l.defaultValue,p,i):[],...l.parent?Ue(l.parent,p,i):[]]}function Kke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.InstalledProject)throw new Error("Entity must be an installed project to be flattened");return[l,...(l.functions||[]).flatMap(r=>Ue(r,p,i)),...(l.events||[]).flatMap(r=>Ue(r,p,i)),...l.parent?Ue(l.parent,p,i):[]]}function qke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.InternalCall)throw new Error("Entity must be an internal call to be flattened");return[l,...(l.successCalls||[]).flatMap(r=>Ue(r,p,i)),...(l.errorCalls||[]).flatMap(r=>Ue(r,p,i)),...(l.inputs||[]).flatMap(r=>Ue(r,p,i)),...(l.outputs||[]).flatMap(r=>Ue(r,p,i)),...(No(l)||[]).flatMap(r=>Ue(r,p,i)),...l.error?Ue(l.error,p,i):[],...(l.writesValues||[]).flatMap(r=>Ue(r,p,i)),...l.parent?Ue(l.parent,p,i):[]]}function Ske(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.LiteralValue)throw new Error("Entity must be a literal value to be flattened");return[l,...l.valueAsTypeSingle?Ue(l.valueAsTypeSingle,p,i):[],...l.valueAsTypeList&&Array.isArray(l.valueAsTypeList)?l.valueAsTypeList.flatMap(r=>Ue(r,p,i)):[],...l.parent?Ue(l.parent,p,i):[]]}function Zke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.Loop)throw new Error("Entity must be a loop to be flattened");return[l,...(l.inputs||[]).flatMap(r=>Ue(r,p,i)),...(l.outputs||[]).flatMap(r=>Ue(r,p,i)),...(l.successCalls||[]).flatMap(r=>Ue(r,p,i)),...(l.errorCalls||[]).flatMap(r=>Ue(r,p,i)),...l.error?Ue(l.error,p,i):[],...l.dataType?Ue(l.dataType,p,i):[],...l.body?Ue(l.body,p,i):[],...(No(l)||[]).flatMap(r=>Ue(r,p,i)),...(l.writesValues||[]).flatMap(r=>Ue(r,p,i)),...l.parent?Ue(l.parent,p,i):[]]}function Hke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.Operation)throw new Error("Entity must be an operation to be flattened");return[l,...(l.successCalls||[]).flatMap(r=>Ue(r,p,i)),...(l.errorCalls||[]).flatMap(r=>Ue(r,p,i)),...(l.inputs||[]).flatMap(r=>Ue(r,p,i)),...(l.outputs||[]).flatMap(r=>Ue(r,p,i)),...(l.writesValues||[]).flatMap(r=>Ue(r,p,i)),...l.error?Ue(l.error,p,i):[],...(No(l)||[]).flatMap(r=>Ue(r,p,i)),...l.parent?Ue(l.parent,p,i):[]]}function Wke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.OutputMap)throw new Error("Entity must be an output map to be flattened");return[l,...(l.writesValues||[]).flatMap(r=>Ue(r,p,i)),...l.declaration?Ue(l.declaration,p,i):[],...l.parent?Ue(l.parent,p,i):[]]}function zke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.PrimitiveEntity)throw new Error("Entity must be a primitive entity to be flattened");return[l,...(l.properties||[]).flatMap(r=>Ue(r,p,i)),...(l.methods||[]).flatMap(r=>Ue(r,p,i)),...(l.abstractMethods||[]).flatMap(r=>Ue(r,p,i))]}function Yke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.Project)throw new Error("Entity must be a project to be flattened");return[l,...(l.entities||[]).flatMap(r=>Ue(r,p,i)),...(l.functions||[]).flatMap(r=>Ue(r,p,i)),...(l.events||[]).flatMap(r=>Ue(r,p,i)),...(l.projects||[]).flatMap(r=>Ue(r,p,i)),...(l.variableDeclarations||[]).flatMap(r=>Ue(r,p,i)),...(l.variableInstances||[]).flatMap(r=>Ue(r,p,i)),...(l.operations||[]).flatMap(r=>Ue(r,p,i)),...(l.conditions||[]).flatMap(r=>Ue(r,p,i)),...(l.functionCalls||[]).flatMap(r=>Ue(r,p,i)),...(l.projects||[]).flatMap(r=>Ue(r,p,i)),...(l.loops||[]).flatMap(r=>Ue(r,p,i)),...(l.searches||[]).flatMap(r=>Ue(r,p,i))]}function Jke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.Property)throw new Error("Entity must be a property to be flattened");return[l,...l.defaultValue?Ue(l.defaultValue,p,i):[],...l.dataType?Ue(l.dataType,p,i):[],...l.parent?Ue(l.parent,p,i):[]]}function Qke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.ReturnStatement)throw new Error("Entity must be a return statement to be flattened");return[l,...(l.outputs||[]).flatMap(r=>Ue(r,p,i)),...l.throws?Ue(l.throws,p,i):[],...l.readsValue?Ue(l.readsValue,p,i):[],...l.dataType?Ue(l.dataType,p,i):[],...(No(l)||[]).flatMap(r=>Ue(r,p,i)),...l.parent?Ue(l.parent,p,i):[]]}function Xke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.Search)throw new Error("Entity must be a search to be flattened");return[l,...(l.successCalls||[]).flatMap(r=>Ue(r,p,i)),...(l.errorCalls||[]).flatMap(r=>Ue(r,p,i)),...(l.inputsDeclarations||[]).flatMap(r=>Ue(r,p,i)),...(l.inputs||[]).flatMap(r=>Ue(r,p,i)),...(l.writesValues||[]).flatMap(r=>Ue(r,p,i)),...(l.outputs||[]).flatMap(r=>Ue(r,p,i)),...l.error?Ue(l.error,p,i):[],...l.dataType?Ue(l.dataType,p,i):[],...(No(l)||[]).flatMap(r=>Ue(r,p,i)),...l.parent?Ue(l.parent,p,i):[]]}function eUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.ValueDescriptor)throw new Error("Entity must be a value descriptor to be flattened");return[l,...l.defaultValue?Ue(l.defaultValue,p,i):[],...l.dataType?Ue(l.dataType,p,i):[],...l.parent?Ue(l.parent,p,i):[]]}function tUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.VariableDeclaration)throw new Error("Entity must be a variable declaration to be flattened");return[l,...(l.successCalls||[]).flatMap(r=>Ue(r,p,i)),...(l.errorCalls||[]).flatMap(r=>Ue(r,p,i)),...(l.inputs||[]).flatMap(r=>Ue(r,p,i)),...(l.outputs||[]).flatMap(r=>Ue(r,p,i)),...(l.internalCalls||[]).flatMap(r=>Ue(r,p,i)),...(l.writesValues||[]).flatMap(r=>Ue(r,p,i)),...l.readsValue?Ue(l.readsValue,p,i):[],...l.defaultValue?Ue(l.defaultValue,p,i):[],...(No(l)||[]).flatMap(r=>Ue(r,p,i)),...l.dataType?Ue(l.dataType,p,i):[],...l.parent?Ue(l.parent,p,i):[]]}function iUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.VariableInstance)throw new Error("Entity must be a variable instance to be flattened");return[l,...(l.successCalls||[]).flatMap(r=>Ue(r,p,i)),...(l.errorCalls||[]).flatMap(r=>Ue(r,p,i)),...(l.inputs||[]).flatMap(r=>Ue(r,p,i)),...(l.outputs||[]).flatMap(r=>Ue(r,p,i)),...(l.internalCalls||[]).flatMap(r=>Ue(r,p,i)),...(l.writesValues||[]).flatMap(r=>Ue(r,p,i)),...l.readsValue?Ue(l.readsValue,p,i):[],...l.defaultValue?Ue(l.defaultValue,p,i):[],...(No(l)||[]).flatMap(r=>Ue(r,p,i)),...l.declaration?Ue(l.declaration,p,i):[],...l.parent?Ue(l.parent,p,i):[]]}function Ue(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(!l)throw new Error("Entity must be defined to be flattened");if(l.type===d.GenericReference)return[];const r=i.ignoreBuiltInBaseEntities?i.diggestedBuiltInBaseEntitiesIds??new Set(z1()):new Set;if(i.diggestedBuiltInBaseEntitiesIds=r,i.ignoreBuiltInBaseEntities&&(oa.includes(l.type)||r.has(l.id)))return[];if(p.has(l.id))return[];switch(l.type){case d.FunctionCall:return jke(l,p,i);case d.Operation:return Hke(l,p,i);case d.Condition:return Lke(l,p,i);case d.Loop:return Zke(l,p,i);case d.Search:return Xke(l,p,i);case d.GlobalEvent:return Uke(l,p,i);case d.ReturnStatement:return Qke(l,p,i);case d.ContinueStatement:return Bke(l,p,i);case d.BreakStatement:return xke(l,p,i);case d.VariableDeclaration:return tUe(l,p,i);case d.DefinitionEntity:return Mke(l,p,i);case d.FunctionDeclaration:return kke(l,p,i);case d.Project:return Yke(l,p,i);case d.ActionDescriptor:return Pke(l,p,i);case d.ArgumentDeclaration:return Nke(l,p,i);case d.ValueDescriptor:return eUe(l,p,i);case d.InputMap:return Fke(l,p,i);case d.OutputMap:return Wke(l,p,i);case d.DataType:return Gke(l,p,i);case d.InstalledProject:return Kke(l,p,i);case d.InternalCall:return qke(l,p,i);case d.LiteralValue:return Ske(l,p,i);case d.Property:return Jke(l,p,i);case d.VariableInstance:return iUe(l,p,i);case d.BuiltInBaseEntity:return i.ignoreBuiltInBaseEntities?[]:$ke(l,p,i);case d.PrimitiveEntity:return i.ignoreBuiltInBaseEntities?[]:zke(l,p,i)}return[]}async function Y1(l={}){const p=new Set,i=Y.YieldTracker.from(l),r=new Set;for(const a of nx){const c=await ke(a,p,{ignoreBuiltInBaseEntities:!1,tracker:i});for(const e of c)r.add(e.id),await i.tick()}return r}function xo(l){return[...l.calledByEntry||[],...l.calledByError||[],...l.calledBySuccess||[]].filter(p=>p.type!==d.GenericReference)}async function rUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.ActionDescriptor)throw new Error("Entity must be an action descriptor to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const e of l.inputs)a.push(...await ke(e,p,c));return l.dataType&&a.push(...await ke(l.dataType,p,c)),l.error&&a.push(...await ke(l.error,p,c)),l.parent&&a.push(...await ke(l.parent,p,c)),a}async function nUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.ArgumentDeclaration)throw new Error("Entity must be an argument declaration to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};delete c.yieldEvery,l.dataType&&a.push(...await ke(l.dataType,p,c)),l.parent&&a.push(...await ke(l.parent,p,c)),l.defaultValue&&a.push(...await ke(l.defaultValue,p,c));for(const e of l.writesValues||[])a.push(...await ke(e,p,c));for(const e of l.implements||[])a.push(...await ke(e,p,c));return a}async function aUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.BreakStatement)throw new Error("Entity must be a break statement to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const f of l.outputs)a.push(...await ke(f,p,c));l.parent&&a.push(...await ke(l.parent,p,c)),l.throws&&a.push(...await ke(l.throws,p,c)),l.dataType&&a.push(...await ke(l.dataType,p,c)),l.readsValue&&a.push(...await ke(l.readsValue,p,c));const e=xo(l);for(const f of e)a.push(...await ke(f,p,c));return a}async function sUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.BuiltInBaseEntity)throw new Error("Entity must be a built-in base entity to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const e of l.properties||[])a.push(...await ke(e,p,c));for(const e of l.methods||[])a.push(...await ke(e,p,c));for(const e of l.abstractMethods||[])a.push(...await ke(e,p,c));return l.allPropertiesImplement&&a.push(...await ke(l.allPropertiesImplement,p,c)),l.additionalPropertiesDataType&&a.push(...await ke(l.additionalPropertiesDataType,p,c)),l.extends&&a.push(...await ke(l.extends,p,c)),a}async function lUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.Condition)throw new Error("Entity must be a condition to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};if(delete c.yieldEvery,l.andChildrenGroup&&Array.isArray(l.andChildrenGroup))for(const f of l.andChildrenGroup)a.push(...await ke(f,p,c));if(l.orChildrenGroup&&Array.isArray(l.orChildrenGroup))for(const f of l.orChildrenGroup)a.push(...await ke(f,p,c));for(const f of l.inputs)a.push(...await ke(f,p,c));for(const f of l.successCalls)a.push(...await ke(f,p,c));for(const f of l.errorCalls)a.push(...await ke(f,p,c));const e=xo(l);for(const f of e)a.push(...await ke(f,p,c));return l.parent&&a.push(...await ke(l.parent,p,c)),a}async function oUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.ContinueStatement)throw new Error("Entity must be a continue statement to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const f of l.outputs)a.push(...await ke(f,p,c));const e=xo(l);for(const f of e)a.push(...await ke(f,p,c));return l.parent&&a.push(...await ke(l.parent,p,c)),l.throws&&a.push(...await ke(l.throws,p,c)),l.dataType&&a.push(...await ke(l.dataType,p,c)),l.readsValue&&a.push(...await ke(l.readsValue,p,c)),a}async function dUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.DefinitionEntity)throw new Error("Entity must be a definition entity to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const e of l.properties)a.push(...await ke(e,p,c));for(const e of l.methods)a.push(...await ke(e,p,c));for(const e of l.abstractMethods)a.push(...await ke(e,p,c));for(const e of l.implements)a.push(...await ke(e,p,c));return l.extends&&a.push(...await ke(l.extends,p,c)),l.parent&&a.push(...await ke(l.parent,p,c)),l.additionalPropertiesDataType&&a.push(...await ke(l.additionalPropertiesDataType,p,c)),l.allPropertiesImplement&&a.push(...await ke(l.allPropertiesImplement,p,c)),a}async function uUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.DataType)throw new Error("Entity must be a data type to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};if(delete c.yieldEvery,l.parent&&a.push(...await ke(l.parent,p,c)),l.foreignKeyRef&&a.push(...await ke(l.foreignKeyRef,p,c)),l.entity&&a.push(...await ke(l.entity,p,c)),l.orChildrenGroup)for(const e of l.orChildrenGroup)a.push(...await ke(e,p,c));if(l.andChildrenGroup)for(const e of l.andChildrenGroup)a.push(...await ke(e,p,c));return a}async function pUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.FunctionCall)throw new Error("Entity must be a function call to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const f of l.inputs)a.push(...await ke(f,p,c));for(const f of l.outputs)a.push(...await ke(f,p,c));l.error&&a.push(...await ke(l.error,p,c));const e=xo(l);for(const f of e)a.push(...await ke(f,p,c));for(const f of l.successCalls)a.push(...await ke(f,p,c));for(const f of l.errorCalls)a.push(...await ke(f,p,c));for(const f of l.writesValues)a.push(...await ke(f,p,c));return l.parent&&a.push(...await ke(l.parent,p,c)),a}async function cUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.FunctionDeclaration)throw new Error("Entity must be a function declaration to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};delete c.yieldEvery,l.parent&&a.push(...await ke(l.parent,p,c)),l.implements&&a.push(...await ke(l.implements,p,c)),l.dataType&&a.push(...await ke(l.dataType,p,c));for(const e of l.inputs)a.push(...await ke(e,p,c));for(const e of l.calls)a.push(...await ke(e,p,c));return a}async function fUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.GlobalEvent)throw new Error("Entity must be a global event to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};delete c.yieldEvery,l.parent&&a.push(...await ke(l.parent,p,c)),l.implements&&a.push(...await ke(l.implements,p,c));for(const e of l.inputs)a.push(...await ke(e,p,c));for(const e of l.calls)a.push(...await ke(e,p,c));return a}async function yUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.InputMap)throw new Error("Entity must be an input map to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};return delete c.yieldEvery,l.parent&&a.push(...await ke(l.parent,p,c)),l.declaration&&a.push(...await ke(l.declaration,p,c)),l.readsValue&&a.push(...await ke(l.readsValue,p,c)),l.dataType&&a.push(...await ke(l.dataType,p,c)),l.defaultValue&&a.push(...await ke(l.defaultValue,p,c)),a}async function hUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.InstalledProject)throw new Error("Entity must be an installed project to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const e of l.functions)a.push(...await ke(e,p,c));for(const e of l.events)a.push(...await ke(e,p,c));return l.parent&&a.push(...await ke(l.parent,p,c)),a}async function mUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.InternalCall)throw new Error("Entity must be an internal call to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const f of l.inputs)a.push(...await ke(f,p,c));for(const f of l.outputs)a.push(...await ke(f,p,c));l.error&&a.push(...await ke(l.error,p,c));const e=xo(l);for(const f of e)a.push(...await ke(f,p,c));for(const f of l.successCalls)a.push(...await ke(f,p,c));for(const f of l.errorCalls)a.push(...await ke(f,p,c));for(const f of l.writesValues)a.push(...await ke(f,p,c));return l.parent&&a.push(...await ke(l.parent,p,c)),a}async function TUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.LiteralValue)throw new Error("Entity must be a literal value to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};if(delete c.yieldEvery,l.valueAsTypeSingle&&a.push(...await ke(l.valueAsTypeSingle,p,c)),l.valueAsTypeList&&Array.isArray(l.valueAsTypeList))for(const e of l.valueAsTypeList)a.push(...await ke(e,p,c));return l.parent&&a.push(...await ke(l.parent,p,c)),a}async function vUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.Loop)throw new Error("Entity must be a loop to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const f of l.inputs)a.push(...await ke(f,p,c));for(const f of l.outputs)a.push(...await ke(f,p,c));l.error&&a.push(...await ke(l.error,p,c));const e=xo(l);for(const f of e)a.push(...await ke(f,p,c));for(const f of l.successCalls)a.push(...await ke(f,p,c));for(const f of l.errorCalls)a.push(...await ke(f,p,c));for(const f of l.writesValues)a.push(...await ke(f,p,c));return l.parent&&a.push(...await ke(l.parent,p,c)),l.body&&a.push(...await ke(l.body,p,c)),l.dataType&&a.push(...await ke(l.dataType,p,c)),a}async function EUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.Operation)throw new Error("Entity must be an operation to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const f of l.inputs)a.push(...await ke(f,p,c));for(const f of l.outputs)a.push(...await ke(f,p,c));l.error&&a.push(...await ke(l.error,p,c));const e=xo(l);for(const f of e)a.push(...await ke(f,p,c));for(const f of l.successCalls)a.push(...await ke(f,p,c));for(const f of l.errorCalls)a.push(...await ke(f,p,c));for(const f of l.writesValues)a.push(...await ke(f,p,c));return l.parent&&a.push(...await ke(l.parent,p,c)),a}async function bUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.OutputMap)throw new Error("Entity must be an output map to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const e of l.writesValues)a.push(...await ke(e,p,c));return l.declaration&&a.push(...await ke(l.declaration,p,c)),l.dataType&&a.push(...await ke(l.dataType,p,c)),l.parent&&a.push(...await ke(l.parent,p,c)),a}async function AUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.PrimitiveEntity)throw new Error("Entity must be a primitive entity to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const e of l.properties)a.push(...await ke(e,p,c));for(const e of l.methods)a.push(...await ke(e,p,c));for(const e of l.abstractMethods)a.push(...await ke(e,p,c));return a}async function IUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.Project)throw new Error("Entity must be a project to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const e of l.entities)a.push(...await ke(e,p,c));for(const e of l.functions)a.push(...await ke(e,p,c));for(const e of l.events)a.push(...await ke(e,p,c));for(const e of l.projects)a.push(...await ke(e,p,c));for(const e of l.variableDeclarations)a.push(...await ke(e,p,c));for(const e of l.variableInstances)a.push(...await ke(e,p,c));for(const e of l.operations)a.push(...await ke(e,p,c));for(const e of l.conditions)a.push(...await ke(e,p,c));for(const e of l.functionCalls)a.push(...await ke(e,p,c));for(const e of l.projects)a.push(...await ke(e,p,c));for(const e of l.loops)a.push(...await ke(e,p,c));for(const e of l.searches)a.push(...await ke(e,p,c));return a}async function gUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.Property)throw new Error("Entity must be a property to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};return delete c.yieldEvery,l.defaultValue&&a.push(...await ke(l.defaultValue,p,c)),l.dataType&&a.push(...await ke(l.dataType,p,c)),l.parent&&a.push(...await ke(l.parent,p,c)),a}async function RUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.ReturnStatement)throw new Error("Entity must be a return statement to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const f of l.outputs)a.push(...await ke(f,p,c));for(const f of l.outputs)a.push(...await ke(f,p,c));l.throws&&a.push(...await ke(l.throws,p,c)),l.readsValue&&a.push(...await ke(l.readsValue,p,c)),l.dataType&&a.push(...await ke(l.dataType,p,c));const e=xo(l);for(const f of e)a.push(...await ke(f,p,c));return l.parent&&a.push(...await ke(l.parent,p,c)),a}async function DUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.Search)throw new Error("Entity must be a search to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const f of l.inputs)a.push(...await ke(f,p,c));for(const f of l.outputs)a.push(...await ke(f,p,c));l.error&&a.push(...await ke(l.error,p,c)),l.dataType&&a.push(...await ke(l.dataType,p,c));for(const f of l.inputsDeclarations)a.push(...await ke(f,p,c));const e=xo(l);for(const f of e)a.push(...await ke(f,p,c));for(const f of l.successCalls)a.push(...await ke(f,p,c));for(const f of l.errorCalls)a.push(...await ke(f,p,c));for(const f of l.writesValues)a.push(...await ke(f,p,c));return l.parent&&a.push(...await ke(l.parent,p,c)),a}async function wUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.ValueDescriptor)throw new Error("Entity must be a value descriptor to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};return delete c.yieldEvery,l.defaultValue&&a.push(...await ke(l.defaultValue,p,c)),l.dataType&&a.push(...await ke(l.dataType,p,c)),l.parent&&a.push(...await ke(l.parent,p,c)),a}async function CUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.VariableDeclaration)throw new Error("Entity must be a variable declaration to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const f of l.inputs)a.push(...await ke(f,p,c));for(const f of l.outputs)a.push(...await ke(f,p,c));l.error&&a.push(...await ke(l.error,p,c)),l.dataType&&a.push(...await ke(l.dataType,p,c)),l.readsValue&&a.push(...await ke(l.readsValue,p,c)),l.defaultValue&&a.push(...await ke(l.defaultValue,p,c));const e=xo(l);for(const f of e)a.push(...await ke(f,p,c));for(const f of l.successCalls)a.push(...await ke(f,p,c));for(const f of l.errorCalls)a.push(...await ke(f,p,c));for(const f of l.writesValues)a.push(...await ke(f,p,c));for(const f of l.internalCalls)a.push(...await ke(f,p,c));return l.parent&&a.push(...await ke(l.parent,p,c)),a}async function OUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.VariableInstance)throw new Error("Entity must be a variable instance to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const f of l.inputs)a.push(...await ke(f,p,c));for(const f of l.outputs)a.push(...await ke(f,p,c));l.error&&a.push(...await ke(l.error,p,c)),l.readsValue&&a.push(...await ke(l.readsValue,p,c)),l.defaultValue&&a.push(...await ke(l.defaultValue,p,c));const e=xo(l);for(const f of e)a.push(...await ke(f,p,c));for(const f of l.successCalls)a.push(...await ke(f,p,c));for(const f of l.errorCalls)a.push(...await ke(f,p,c));for(const f of l.writesValues)a.push(...await ke(f,p,c));for(const f of l.internalCalls)a.push(...await ke(f,p,c));return l.parent&&a.push(...await ke(l.parent,p,c)),l.declaration&&a.push(...await ke(l.declaration,p,c)),a}async function ke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1,yieldEvery:100}){const r={...i,ignoreBuiltInBaseEntities:i.ignoreBuiltInBaseEntities??!1};if(!l)throw new Error("Entity must be defined to be flattened");if(l.type===d.GenericReference)return[];const a=Y.YieldTracker.from(r);r.tracker=a,r.yieldEvery!==void 0&&delete r.yieldEvery;const c=r.ignoreBuiltInBaseEntities?r.diggestedBuiltInBaseEntitiesIds??new Set(await Y1(r)):new Set;if(r.diggestedBuiltInBaseEntitiesIds=c,r.ignoreBuiltInBaseEntities&&(oa.includes(l.type)||c.has(l.id)))return[];if(p.has(l.id))return[];switch(l.type){case d.FunctionCall:return pUe(l,p,r);case d.Operation:return EUe(l,p,r);case d.Condition:return lUe(l,p,r);case d.Loop:return vUe(l,p,r);case d.Search:return DUe(l,p,r);case d.GlobalEvent:return fUe(l,p,r);case d.ReturnStatement:return RUe(l,p,r);case d.ContinueStatement:return oUe(l,p,r);case d.BreakStatement:return aUe(l,p,r);case d.VariableDeclaration:return CUe(l,p,r);case d.DefinitionEntity:return dUe(l,p,r);case d.FunctionDeclaration:return cUe(l,p,r);case d.Project:return IUe(l,p,r);case d.ActionDescriptor:return rUe(l,p,r);case d.ArgumentDeclaration:return nUe(l,p,r);case d.ValueDescriptor:return wUe(l,p,r);case d.InputMap:return yUe(l,p,r);case d.OutputMap:return bUe(l,p,r);case d.DataType:return uUe(l,p,r);case d.InstalledProject:return hUe(l,p,r);case d.InternalCall:return mUe(l,p,r);case d.LiteralValue:return TUe(l,p,r);case d.Property:return gUe(l,p,r);case d.VariableInstance:return OUe(l,p,r);case d.BuiltInBaseEntity:return r.ignoreBuiltInBaseEntities?[]:sUe(l,p,r);case d.PrimitiveEntity:return r.ignoreBuiltInBaseEntities?[]:AUe(l,p,r)}return[]}function _Ue(l){return l==null||l===""}function J_i(l){return l===null}function Ln(l){return l!=null&&l.valueAsType?!1:_Ue(l==null?void 0:l.value)}function Xd(l){return l?l.valueAsType===null&&l.value===null:!1}function VUe(l,p){if(l===p||!l&&!p)return!0;if(!l||!p||l.name===fe.EntityTemplate&&p.name!==fe.EntityTemplate||p.name===fe.EntityTemplate&&l.name!==fe.EntityTemplate)return!1;if(l.name===fe.ActionDescriptor&&p.name!==fe.ActionDescriptor||p.name===fe.ActionDescriptor&&l.name!==fe.ActionDescriptor)return!1;if(l.valueAsTypeSingle&&!p.valueAsTypeSingle||p.valueAsTypeSingle&&!l.valueAsTypeSingle)return!1;if(l.valueAsTypeList&&!p.valueAsTypeList||p.valueAsTypeList&&!l.valueAsTypeList)return!1;if(l.valueAsTypeSingle&&p.valueAsTypeSingle){if(l.valueAsTypeSingle.id!==p.valueAsTypeSingle.id)return!1}else if(l.valueAsTypeList&&p.valueAsTypeList){if(l.valueAsTypeList.length!==p.valueAsTypeList.length)return!1;for(let i=0;i<l.valueAsTypeList.length;i++)if(l.valueAsTypeList[i].id!==p.valueAsTypeList[i].id)return!1}else if(!l.valueAsType&&!p.valueAsType&&l.value!==p.value)return!1;return!0}function PUe(l,p,i){if(!i)throw new Error("[checkIsRowTransformerUpToDate] 'lastPublishedEntityVersion' argument is required");if(!p)throw new Error("[checkIsRowTransformerUpToDate] 'entity' argument is required");if(!l)throw new Error("[checkIsRowTransformerUpToDate] 'newestOpenRowTransformer' argument is required");let r=!0;const a=l.methods.find(c=>{var e;return((e=c.implements)==null?void 0:e.id)===ne["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.methods.up.id});if(a?(on(i).forEach(c=>{const e=a.inputs.find(f=>f.name===c.name);e&&oi(e.getDataType(null),c.getDataType(null)).compatible||(r=!1)}),a.returnStatements.forEach(c=>{!c.dataType||!c.dataType.entity||c.dataType.entity.type!==d.DefinitionEntity?r=!1:FT(c.dataType.entity,p)||(r=!1)})):r=!1,r===null||r){const c=l.methods.find(e=>{var f;return((f=e.implements)==null?void 0:f.id)===ne["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.methods.down.id});c?(on(p).forEach(e=>{const f=c.inputs.find(h=>h.name===e.name);f&&oi(f.getDataType(null),e.getDataType(null)).compatible||(r=!1)}),c.returnStatements.forEach(e=>{!e.dataType||!e.dataType.entity||e.dataType.entity.type!==d.DefinitionEntity?r=!1:FT(e.dataType.entity,i)||(r=!1)})):r=!1}return{isPreexistingRowTransformerUpToDate:r}}function NUe(l,p,i){const r={changesSinceLastPublication:!1,rowTransformerNeeded:!1,newRowTransformerNeeded:!1,newestOpenRowTransformer:null,newRequiredProperties:[],newNonRequiredProperties:[],deletedProperties:[],lastPublishedEntityVersion:null,updatedEntityVersion:i,propChanges:new Map,isPreexistingRowTransformerUpToDate:null,extendedEntities:[]},c=l.entities.filter(M=>{var re;if(M.id===i.id)return!1;let G=!1,q=M;for(;q;){if(((re=q.extends)==null?void 0:re.id)===i.id){G=!0;break}if(q.extends&&q.extends.type===d.DefinitionEntity)q=q.extends;else break}return G}).map(M=>NUe(l,p,M));if(!p)return{...r,changesSinceLastPublication:!0,extendedEntities:c};const e=p.get(i.id);if(!e)return{...r,changesSinceLastPublication:!0,extendedEntities:c};const f=p.entities.filter(M=>ai(M,Ie.SQL_ROW_TRANSFORMER)),m=l.entities.filter(M=>{var ee;if(!ai(M,Ie.SQL_ROW_TRANSFORMER)||f.find(de=>de.id===M.id))return!1;const q=M.properties.find(de=>!!de.implements.find(ie=>ne["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.properties.definition.id===ie.id));if(!q)return!1;const re=(ee=q.defaultValue)==null?void 0:ee.valueAsType;return re?re.id===i.id:!1}).sort((M,G)=>B(M.createdAt).isAfter(B(G.createdAt))?-1:1)[0]||null,E=new Map;let b=!1;const A=on(i).filter(M=>on(e).find(re=>re.id===M.id)?!1:!ns(M.getDataType(null))),_=on(i).filter(M=>on(e).find(re=>re.id===M.id)?!1:!!ns(M.getDataType(null))),N=on(e).filter(M=>!on(i).find(q=>q.id===M.id));on(i).filter(M=>{var z,X,ce,oe,me,ve,we,Re,xe,je,Se;const G=on(e).find(et=>et.id===M.id);let q=!1;if(!G)return!1;const re=Ma(M.dataType,!0,`[resolveSQLMigrationsDiffs] Unsupported data-type structure on current property '${M.name}' (${M.id}). 'andChildrenGroup' with more than one child is not supported for SQL column properties.`),ee=Ma(G.dataType,!0,`[resolveSQLMigrationsDiffs] Unsupported data-type structure on last published property '${M.name}' (${M.id}). 'andChildrenGroup' with more than one child is not supported for SQL column properties.`),de=vI(re,!0,`[resolveSQLMigrationsDiffs] Unsupported data-type structure on current property '${M.name}' (${M.id}). 'orChildrenGroup' with multiple non-null children is not supported for SQL column properties.`),ie=vI(ee,!0,`[resolveSQLMigrationsDiffs] Unsupported data-type structure on last published property '${M.name}' (${M.id}). 'orChildrenGroup' with multiple non-null children is not supported for SQL column properties.`);if(((z=de==null?void 0:de.foreignKeyRef)==null?void 0:z.id)!==((X=ie==null?void 0:ie.foreignKeyRef)==null?void 0:X.id)){const et=de==null?void 0:de.foreignKeyRef,Ze=ie==null?void 0:ie.foreignKeyRef;E.set(M.id,{...E.get(M.id)||{},newForeignKeyRef:et||void 0,oldForeignKeyRef:Ze||void 0,property:M,oldProperty:G}),q=!0,b=!0}else((ce=de==null?void 0:de.entity)==null?void 0:ce.id)!==((oe=ie==null?void 0:ie.entity)==null?void 0:oe.id)&&(((me=de==null?void 0:de.entity)==null?void 0:me.id)===ne["primitive-entity"].string.id||((ve=ie==null?void 0:ie.entity)==null?void 0:ve.id)===ne["primitive-entity"].date.id&&((we=de==null?void 0:de.entity)==null?void 0:we.id)===ne["primitive-entity"].number.id?E.set(M.id,{...E.get(M.id)||{},castableDataTypeEntity:{fromId:((Re=ie==null?void 0:ie.entity)==null?void 0:Re.id)||"",toId:((xe=de==null?void 0:de.entity)==null?void 0:xe.id)||""},property:M,oldProperty:G}):(E.set(M.id,{...E.get(M.id)||{property:M},nonCastableDataTypeEntity:{fromId:((je=ie==null?void 0:ie.entity)==null?void 0:je.id)||"",toId:((Se=de==null?void 0:de.entity)==null?void 0:Se.id)||""},property:M,oldProperty:G}),b=!0),q=!0);M.name!==(G==null?void 0:G.name)&&(E.set(M.id,{...E.get(M.id)||{},nameChange:{from:(G==null?void 0:G.name)||"",to:M.name},property:M,oldProperty:G}),q=!0);const se=ns(G.getDataType(null)),ue=ns(M.getDataType(null));return ue!==se&&(E.set(M.id,{...E.get(M.id)||{},requiredChange:{from:!se,to:!ue},property:M,oldProperty:G}),ue||(b=!0),q=!0),q}),A.length>0&&(b=!0);let V=null;m&&b&&(V=PUe(m,i,e).isPreexistingRowTransformerUpToDate);const j=i.name!==e.name?{from:e.name,to:i.name}:void 0;return{...r,changesSinceLastPublication:E.size>0||!!N.length||!!A.length||!!_.length||b,rowTransformerNeeded:b,newestOpenRowTransformer:m,nameChange:j,newRequiredProperties:A,newNonRequiredProperties:_,deletedProperties:N,lastPublishedEntityVersion:e,propChanges:E,newRowTransformerNeeded:b&&!m,isPreexistingRowTransformerUpToDate:V,extendedEntities:c}}function lL(l,p,i,r,a){if(!l)throw new Error("[addDifferencesToRowTransformer] 'project' argument is required");if(!p)throw new Error("[addDifferencesToRowTransformer] 'transformer' argument is required");if(!i)throw new Error("[addDifferencesToRowTransformer] 'newEntityState' argument is required");if(!r)throw new Error("[addDifferencesToRowTransformer] 'oldEntityState' argument is required");const c=on(i),e=on(r);p.afterAllChildrenInitialized(a);const f=p.methods.find(m=>{var E;return((E=m.implements)==null?void 0:E.id)===ne["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.methods.up.id}),h=p.methods.find(m=>{var E;return((E=m.implements)==null?void 0:E.id)===ne["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.methods.down.id});if(!f)throw new Error("[addDifferencesToRowTransformer] The 'up' transformer trigger is missing from the parent");if(!h)throw new Error("[addDifferencesToRowTransformer] The 'down' transformer trigger is missing from the parent");e.forEach(m=>{var j;const E=f.inputs.find(M=>M.name===m.name),b=m.getDataType(null);let A=E,_,N=!1,V=!1;if(E)A.editable=!0;else{const M=Ga.new(a);M.parent=f.toReference(),M.name=m.name,M.index=m.index,M.implements=[...m.implements.map(q=>q.toJSON())];const G=Ae(M,l);G.hydrateAncestors(),G.addSelfToProject(a),a.add(G,W.Added),G.initChildren(a),N=!0,A=G}if(!A.dataType||A.dataType&&l.diggestedBuiltInBaseEntitiesIds.has(A.dataType.id)){const M=yr.new(a);M.parent=A.toReference();const G=Ae(M,l);G.hydrateAncestors(),G.addSelfToProject(a),a.add(G,W.Added),G.initChildren(a),V=!0,_=G}else _=A.dataType,_.editable=!0;b&&_.merge(m.getDataType(null),a),_.metaSync({editable:!1,deletable:!1},a),A.metaSync({editable:!1,deletable:!1},a),V&&(a||(j=A.dataType)==null||j.captureVersion()),N&&(a||A.captureVersion())}),[...f.inputs].forEach(m=>{e.find(b=>b.name===m.name)||(m.editable=!0,m.remove({ignoreUpstream:!1},a),m.editable=!1)}),[...f.returnStatements].forEach(m=>{var b,A,_;let E=!1;if(!m.dataType||m.dataType&&l.diggestedBuiltInBaseEntitiesIds.has(m.dataType.id)){const N=yr.new(a);N.entity=i.toReference(),N.parent=m.toReference();const V=Ae(N,l);V.hydrateAncestors(),a.add(V,W.Added),V.addSelfToProject(a),V.initChildren(a),E=!0}(!((b=m.dataType)!=null&&b.entity)||m.dataType.entity.type!==d.DefinitionEntity||m.dataType.entity.parent.id!==m.dataType.id)&&(i.clone(a,m.dataType),E=!0),lx((A=m.dataType)==null?void 0:A.entity,i,a),m.afterAllChildrenInitialized(a),m.outputs.forEach(N=>{const V=f.inputs.find(j=>le(N,l)===le(j,l));N.setValueWriter(V,a),V==null||V.addValueReader(N,a)}),E&&(a||(_=m.dataType)==null||_.captureVersion())}),c.forEach(m=>{var M,G;let E=!1,b=!1;const A=(M=m.knownVersions)==null?void 0:M.get(m.previousVersion),_=h.inputs.find(q=>q.name===m.name||!!A&&A.name===q.name),N=m.getDataType(null);let V=_,j;if(_)V.editable=!0,V.metaSync({name:m.name,codeName:m.codeName,description:m.description},a);else{const q=Ga.new(a);q.parent=h.toReference(),q.name=m.name,q.codeName=m.codeName,q.description=m.description,q.index=m.index,q.implements=[m.toJSON(),...m.implements.map(ee=>ee.toJSON())];const re=Ae(q,l);re.hydrateAncestors(),re.addSelfToProject(a),a.add(re,W.Added),re.initChildren(a),E=!0,V=re}if(V.dataType)j=V.dataType,j.editable=!0,j.merge(V.dataType,a);else{const q=yr.new(a);q.parent=V.toReference();const re=Ae(q,l);re.hydrateAncestors(),re.addSelfToProject(a),a.add(re,W.Added),re.initChildren(a),b=!0,j=re}N&&j.merge(m.getDataType(null),a),j.metaSync({editable:!1,deletable:!1},a),V.metaSync({editable:!1,deletable:!1},a),b&&(a||(G=V.dataType)==null||G.captureVersion()),E&&(a||V.captureVersion())}),[...h.inputs].forEach(m=>{c.find(b=>{var _;if(b.name===m.name)return!0;const A=(_=b.knownVersions)==null?void 0:_.get(b.previousVersion);if(A&&A.name===m.name)return!0})||(m.editable=!0,m.remove({ignoreUpstream:!1},a),m.editable=!1)}),[...h.returnStatements].forEach(m=>{var A,_,N,V,j;let E=!1;if(!m.dataType||m.dataType&&l.diggestedBuiltInBaseEntitiesIds.has(m.dataType.id)){const M=yr.new(a);M.parent=m.toReference();const G=Ae(M,l);G.hydrateAncestors(),G.addSelfToProject(a),a.add(G,W.Added),G.initChildren(a),E=!0}let b=(A=m.dataType)==null?void 0:A.entity;(!b||(b==null?void 0:b.id)===ne["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.id)&&(Y.Logger.log("Cloning old entity state into new project with data-ype as parent: ",(_=m.dataType)==null?void 0:_.id," from new project: ",((N=m.dataType)==null?void 0:N.project.version)===l.version&&((V=m.dataType)==null?void 0:V.project.entities.length)===3),b=r.clone(a,m.dataType)),m.dataType.setEntity(b,a),m.afterAllChildrenInitialized(a),m.outputs.forEach(M=>{const G=h.inputs.find(q=>le(M,l)===le(q,l));M.setValueWriter(G,a),G==null||G.addValueReader(M,a)}),E&&(a||(j=m.dataType)==null||j.captureVersion())})}function xUe(l,p,i,r,a={}){var M;const c=l.getBuiltIn(Ie.SQL_ROW_TRANSFORMER),e=hh(le(p,l)+" row transformer",l.entities),f=c.implement(e,r),h=f.ownDeclaredProperties.find(G=>{var q;return(q=G.implements)==null?void 0:q.find(re=>re.id===ne["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.properties.definition.id)}),m=f.methods.find(G=>{var q;return((q=G.implements)==null?void 0:q.id)===ne["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.methods.up.id}),E=f.methods.find(G=>{var q;return((q=G.implements)==null?void 0:q.id)===ne["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.methods.down.id});if(!h||!m||!E)throw new Error("Cannot find definition property on the new row transformer entity");if(h.defaultValue)h.defaultValue.setValueAsTypeSingle(p,r);else{const G=Vr.new(r);G.name=fe.EntityTemplate,G.valueAsTypeSingle=p.toJSON(),G.parent=h.toReference();const q=Ae(G,l);q.hydrateAncestors(),q.addSelfToProject(r),r.add(q,W.Added),q.initChildren(r),r||q.captureVersion()}lL(l,f,p,i,r),Y.Logger.log("BEFORE - changeSet.listAdded",r.listAdded.map(G=>{var re,ee,de,ie,se,ue,z;const q=l.get(G.id);return q?le(q,l):G.type===d.InputMap?"(not found) "+G.type+" "+G.id+" - declaration: "+((re=G.declaration)==null?void 0:re.type)+" "+((ee=G.declaration)==null?void 0:ee.id)+' "'+((de=G.declaration)==null?void 0:de.name)+`"
539
+ `)),Y.Logger.log("Persisting new additions"),h.visit(async(m,E)=>{if(r.added[m.id]){Y.Logger.log("Adding: ",m.id);try{const b=Ae(m,this);if(b.hydrateAncestors(),b.addSelfToProject(a),a.add(b,W.Added),a||b.captureVersion(),!this.get(m.id))throw new Error(`Entity ${m.id} was not added to the project`)}catch(b){Y.Logger.error("Error: ",b),Y.Logger.error("Errored entity: ",m)}}}),Y.Logger.log("Persisting updates"),h.visit(async(m,E)=>{if(r.updated[m.id]){Y.Logger.log("Updating: ",m.id);try{const b=this.get(m.id);b?(b.updateWithShallowTransfer(m,a),a.add(b,W.Updated),a||b.captureVersion()):Y.Logger.warn(`Active version of ${m.id} not found when applying external changes`)}catch(b){Y.Logger.error("Error: ",b),Y.Logger.error("Errored entity: ",m)}}}),Y.Logger.log("Persisting removals"),h.visit(async(m,E)=>{if(r.removed[m.id]){Y.Logger.log("Removing: ",m.id);try{const b=this.get(m.id);b&&(b.remove({ignoreUpstream:!1},a),a.add(b,W.Removed),a||b.captureVersion())}catch(b){Y.Logger.error("Error: ",b),Y.Logger.error("Errored entity: ",m)}}}),a.open=!1,a}toBuiltInShallowRecord(){const i={};return Object.values(this.builtInInstances).forEach(r=>{const a=r.toShallowJSON();i[r.id]=a}),i}toShallowRecord(){const i={};return Object.values(this.instances).forEach(r=>{const a=r.toShallowJSON();i[r.id]=a}),i}toFullProjectTransfer(i){const r={shallowErrors:!1,...i},a=new Bn(void 0,{allBuiltInEntityIds:this.diggestedBuiltInBaseEntitiesIds});a.flatRecord={};for(const f of Object.values(this.instances))this.diggestedBuiltInBaseEntitiesIds.has(f.id)||(a.flatRecord[f.id]=f);a.order=Object.keys(a.flatRecord),a.orderEntities();const c={},e=[];return a.visit(f=>{try{const h=f.toShallowJSON();c[f.id]=h,e.push(f.id)}catch(h){if(Y.Logger.error(`[toFullProjectTransfer] Error serializing ${f.type} ${f.id}`,h),!r.shallowErrors)throw h}}),{order:e,size:e.length,record:c}}async toFullProjectTransferAsync(i={}){const r={shallowErrors:!1,...i},a=Y.YieldTracker.from(r),c=new Bn(void 0,{allBuiltInEntityIds:this.diggestedBuiltInBaseEntitiesIds});c.flatRecord={};for(const h of Object.values(this.instances))await a.tick(),!this.diggestedBuiltInBaseEntitiesIds.has(h.id)&&(c.flatRecord[h.id]=h);c.order=Object.keys(c.flatRecord);const e=[];if(r.seenEntityMaps)for(const h of c.order){const m=r.seenEntityMaps.get(h)??h;this.diggestedBuiltInBaseEntitiesIds.has(m)}await c.orderEntitiesAsync({tracker:a});const f={};return await c.visitAsync(async h=>{try{if(this.diggestedBuiltInBaseEntitiesIds.has(h.id))return;const m=h.toShallowJSON({seenEntityMaps:r.seenEntityMaps});r.resetVersionOptions&&(m.version=$t.UUID.uuid(),m.createdAt=r.resetVersionOptions.commonTimestamp||B().toISOString(),m.author=r.resetVersionOptions.author||$t.sessionAuthor||"1",m.previousVersion=null),f[m.id]=m,e.push(m.id),r!=null&&r.onVisit&&await r.onVisit(m)}catch(m){if(Y.Logger.error(`[toFullProjectTransferAsync] Error serializing ${h.type} ${h.id}`,m),!r.shallowErrors)throw m}},{tracker:a}),{order:e,size:e.length,record:f}}async toFullProjectGenerationTargetAsync(i={}){const r={shallowErrors:!1,...i},a=Y.YieldTracker.from(r),c=new Bn(void 0,{allBuiltInEntityIds:this.diggestedBuiltInBaseEntitiesIds});c.flatRecord={};for(const h of Object.values(this.instances))await a.tick(),!this.diggestedBuiltInBaseEntitiesIds.has(h.id)&&(c.flatRecord[h.id]=h);c.order=Object.keys(c.flatRecord);const e=[];if(r.seenEntityMaps)for(const h of c.order){const m=r.seenEntityMaps.get(h)??h;this.diggestedBuiltInBaseEntitiesIds.has(m)}await c.orderEntitiesAsync({tracker:a});const f={};return await c.visitAsync(async h=>{try{if(this.diggestedBuiltInBaseEntitiesIds.has(h.id))return;const m=h.toGenerationTarget({seenEntityMaps:r.seenEntityMaps});f[m.id]=m,e.push(m.id),r!=null&&r.onVisit&&await r.onVisit(m)}catch(m){if(Y.Logger.error(`[toFullProjectTransferAsync] Error serializing ${h.type} ${h.id}`,m),!r.shallowErrors)throw m}},{tracker:a}),{order:e,size:e.length,record:f}}};R($t,"parentContext",sL),R($t,"sessionAuthor","1"),R($t,"repository",{APICreate:async(i,...r)=>i,APIUpdate:async(i,...r)=>i,APIDelete:async(i,...r)=>i,APIClone:async(i,...r)=>{},APILoad:async(i,...r)=>null,APILoadVersion:async(i,r,...a)=>null}),R($t,"type",d.Project),R($t,"USER_MANAGED_PARENT_TYPES",[]),R($t,"PARENT_TYPES",[...$t.USER_MANAGED_PARENT_TYPES]),R($t,"MUTABLE_BASE_PROPERTIES",["name","description"]),R($t,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),R($t,"BASE_PROPERTIES",[...$t.MUTABLE_BASE_PROPERTIES,...$t.INMUTABLE_BASE_PROPERTIES]),R($t,"MUTABLE_META_PROPERTIES",[...$t.MUTABLE_BASE_PROPERTIES,"x","y"]),R($t,"INMUTABLE_META_PROPERTIES",[...$t.INMUTABLE_BASE_PROPERTIES]),R($t,"META_PROPERTIES",[...$t.MUTABLE_META_PROPERTIES,...$t.INMUTABLE_META_PROPERTIES]),R($t,"MUTABLE_UPSTREAM_PROPERTIES",[]),R($t,"INMUTABLE_UPSTREAM_PROPERTIES",["primitives","builtInBaseEntities","operationDeclarations","globalEventActionDescriptors","loopDeclarations","builtInInstances"]),R($t,"UPSTREAM_PROPERTIES",[...$t.MUTABLE_UPSTREAM_PROPERTIES,...$t.INMUTABLE_UPSTREAM_PROPERTIES]),R($t,"MUTABLE_DOWNSTREAM_PROPERTIES",["entities","projects","functions","events","variableDeclarations","variableInstances","conditions","operations","functionCalls","loops","searches"]),R($t,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),R($t,"DOWNSTREAM_PROPERTIES",[...$t.MUTABLE_DOWNSTREAM_PROPERTIES,...$t.INMUTABLE_DOWNSTREAM_PROPERTIES]),R($t,"PROPERTIES",[...$t.META_PROPERTIES,...$t.UPSTREAM_PROPERTIES,...$t.DOWNSTREAM_PROPERTIES]);let x=$t;class C_i extends Hi{constructor(p){super(Yv,p)}}class O_i extends Hi{constructor(i){super(zh,i);R(this,"autoexecutable",!0)}getEntityToMatchInputMap(i){return i.inputs.find(r=>{var a;return((a=r.declaration)==null?void 0:a.id)===ne.operation[Le.Validate].inputs.entityToMatch.id})||null}getDataToValidateInputMap(i){return i.inputs.find(r=>{var a;return((a=r.declaration)==null?void 0:a.id)===ne.operation[Le.Validate].inputs.dataToValidate.id})||null}getOutputDataOutputMap(i){return i.outputs.find(r=>{var a;return((a=r.declaration)==null?void 0:a.id)===ne.operation[Le.Validate].dataType.entity.properties.outputEntity.id})||null}getEntityToMatch(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"get-entity-to-match-validate-data"))){var e;const a=((e=this.project.requestActiveDynamicValue(i))==null?void 0:e.value)||null,c=a==null?void 0:a.valueAsTypeSingle;return r==null||r.attemptAutoclose("get-entity-to-match-validate-data",this.id),c}syncOperationInstance(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-operation-instance-validate-data"))){const a=[],c=[],e=[],f=[],h=this.getEntityToMatchInputMap(i);if(h){const{added:b,updated:A,removed:_,affected:N}=this.syncEntityToMatchInputMapDataType(h,r);a.push(...A),c.push(...b),e.push(..._),f.push(...N)}const m=this.getDataToValidateInputMap(i);if(m){const{added:b,updated:A,removed:_,affected:N}=this.syncDataToValidateInputMapDataType(m,r);a.push(...A),c.push(...b),e.push(..._),f.push(...N)}const E=this.getOutputDataOutputMap(i);if(E){const{added:b,updated:A,removed:_,affected:N}=this.syncOutputDataOutputMapDataType(E,r);a.push(...A),c.push(...b),e.push(..._),f.push(...N)}return r==null||r.attemptAutoclose("sync-operation-instance-validate-data",this.id),{updated:C(a),added:C(c),removed:C(e),affected:C(f),self:i}}syncEntityToMatchInputMapDataType(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-entity-to-match-input-map-data-type"))){var E,b,A,_,N,V,j,M,G,q,re,ee,de,ie,se,ue,z,X;const a=[],c=[],e=[],f=[];if(((E=i.declaration)==null?void 0:E.id)!==ne.operation[Le.Validate].inputs.entityToMatch.id)return r==null||r.attemptAutoclose("sync-entity-to-match-input-map-data-type",this.id),{updated:[],added:[],removed:[],affected:[],self:null};const h=((b=this.project.requestActiveDynamicValue(i))==null?void 0:b.value)||null,m=h==null?void 0:h.valueAsTypeSingle;if(!i.dataType){const ce={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(r==null?void 0:r.timestamp)||new Date().toISOString(),author:(r==null?void 0:r.author)||x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.DataType,parentRelationType:null,options:((A=i.declaration.dataType)==null?void 0:A.options)||null,implementationChooseOne:((_=i.declaration.dataType)==null?void 0:_.implementationChooseOne)||!1,staticEntities:((N=i.declaration.dataType)==null?void 0:N.staticEntities)??null,interactiveEntities:((V=i.declaration.dataType)==null?void 0:V.interactiveEntities)??null,actionEntities:((j=i.declaration.dataType)==null?void 0:j.actionEntities)??null,index:((M=i.declaration.dataType)==null?void 0:M.index)??null,isList:((G=i.declaration.dataType)==null?void 0:G.isList)||!1,foreignKeyAllowed:((q=i.declaration.dataType)==null?void 0:q.foreignKeyAllowed)??null,andChildrenGroup:null,orChildrenGroup:null,foreignKeyRef:null,asType:!0,entity:(m==null?void 0:m.toJSON())||null,like:!0,inferred:!0,parent:i.toReference()},oe=Ae(ce,i.project);oe.hydrateAncestors(),oe.addSelfToProject(r),r==null||r.add(oe,W.Added),oe.setParent(i,r),oe.initChildren(r),oe.setEntity(m,r),a.push(oe),i.setDataType(oe,r),r||oe.captureVersion()}return(z=i.dataType)==null||z.metaSync({inferred:!0,like:!1,asType:!0,options:((re=i.declaration.dataType)==null?void 0:re.options)||null,implementationChooseOne:((ee=i.declaration.dataType)==null?void 0:ee.implementationChooseOne)||!1,staticEntities:((de=i.declaration.dataType)==null?void 0:de.staticEntities)??null,interactiveEntities:((ie=i.declaration.dataType)==null?void 0:ie.interactiveEntities)??null,actionEntities:((se=i.declaration.dataType)==null?void 0:se.actionEntities)??null,isList:((ue=i.declaration.dataType)==null?void 0:ue.isList)||!1},r),(X=i.dataType)==null||X.setEntity(m,r),i.dataType&&c.push(i.dataType),r==null||r.attemptAutoclose("sync-entity-to-match-input-map-data-type",this.id),{updated:C(c),added:C(a),removed:C(e),affected:C(f),self:i.dataType}}syncDataToValidateInputMapDataType(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-data-to-validate-input-map-data-type"))){var b,A,_;const a=[],c=[],e=[],f=[];if(((b=i.declaration)==null?void 0:b.id)!==ne.operation[Le.Validate].inputs.dataToValidate.id)return r==null||r.attemptAutoclose("sync-data-to-validate-input-map-data-type",this.id),{updated:[],added:[],removed:[],affected:[],self:null};const h=this.getEntityToMatchInputMap(i.parent);if(!h)return r==null||r.attemptAutoclose("sync-data-to-validate-input-map-data-type",this.id),{updated:[],added:[],removed:[],affected:[],self:null};if(!this.getEntityToMatch(h,r))return r==null||r.attemptAutoclose("sync-data-to-validate-input-map-data-type",this.id),{updated:[],added:[],removed:[],affected:[],self:null};if(!i.dataType){const N={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(r==null?void 0:r.timestamp)||new Date().toISOString(),author:(r==null?void 0:r.author)||x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.DataType,index:null,parentRelationType:null,options:null,implementationChooseOne:!1,foreignKeyAllowed:null,isList:!1,foreignKeyRef:null,andChildrenGroup:null,orChildrenGroup:null,staticEntities:null,interactiveEntities:null,actionEntities:null,asType:!1,entity:null,like:!0,inferred:!0,parent:i.toReference()},V=Ae(N,i.project);V.hydrateAncestors(),V.addSelfToProject(r),r==null||r.add(V,W.Added),V.setParent(i,r),V.initChildren(r),a.push(V),i.setDataType(V,r),r||V.captureVersion()}(A=i.dataType)==null||A.metaSync({inferred:!0,like:!0,asType:!1},r);const E=this.getEntityToMatch(h,r);return(_=i.dataType)==null||_.setEntity(E,r),i.dataType&&c.push(i.dataType),r==null||r.attemptAutoclose("sync-data-to-validate-input-map-data-type",this.id),{updated:C(c),added:C(a),removed:C(e),affected:C(f),self:i.dataType}}syncOutputDataOutputMapDataType(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"sync-output-data-output-map-data-type"))){var A,_,N,V;const a=[],c=[],e=[],f=[];if(((A=i.declaration)==null?void 0:A.id)!==ne.operation[Le.Validate].dataType.entity.properties.outputEntity.id)return r==null||r.attemptAutoclose("sync-output-data-output-map-data-type",this.id),{updated:[],added:[],removed:[],affected:[],self:null};const h=this.getEntityToMatchInputMap(i.parent);if(!h)return r==null||r.attemptAutoclose("sync-output-data-output-map-data-type",this.id),{updated:[],added:[],removed:[],affected:[],self:null};if(!this.getEntityToMatch(h,r))return r==null||r.attemptAutoclose("sync-output-data-output-map-data-type",this.id),{updated:[],added:[],removed:[],affected:[],self:null};const E=((_=this.project.requestActiveDynamicValue(h))==null?void 0:_.value)||null,b=(E==null?void 0:E.valueAsTypeSingle)||null;if(!i.dataType){const j={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(r==null?void 0:r.timestamp)||new Date().toISOString(),author:(r==null?void 0:r.author)||x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.DataType,parentRelationType:null,options:null,foreignKeyRef:null,implementationChooseOne:!1,foreignKeyAllowed:null,staticEntities:null,interactiveEntities:null,index:null,actionEntities:null,isList:!1,andChildrenGroup:null,orChildrenGroup:null,asType:!1,entity:(b==null?void 0:b.toJSON())||null,like:!0,inferred:!0,parent:i.toReference()},M=Ae(j,i.project);M.hydrateAncestors(),M.addSelfToProject(r),r==null||r.add(M,W.Added),M.setParent(i,r),M.initChildren(r),M.setEntity(b,r),a.push(M),i.setDataType(M,r),r||M.captureVersion()}return(N=i.dataType)==null||N.metaSync({inferred:!0,like:!0,asType:!1},r),(V=i.dataType)==null||V.setEntity(b,r),i.dataType&&c.push(i.dataType),r==null||r.attemptAutoclose("sync-output-data-output-map-data-type",this.id),{updated:C(c),added:C(a),removed:C(e),affected:C(f),self:i.dataType}}inferInputMapDataType(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"infer-input-map-data-type-validate-data"))){var c,e,f;if(((c=i.declaration)==null?void 0:c.id)===ne.operation[Le.Validate].inputs.entityToMatch.id){const{added:h,updated:m,removed:E,affected:b}=r?this.syncEntityToMatchInputMapDataType(i,r):{added:[],updated:[],removed:[],affected:[]};return r==null||r.attemptAutoclose("infer-input-map-data-type",this.id),{updated:C(m),added:C(h),removed:C(E),affected:C(b),self:i.dataType}}if(((e=i.declaration)==null?void 0:e.id)===ne.operation[Le.Validate].inputs.dataToValidate.id){const{added:h,updated:m,removed:E,affected:b}=this.syncDataToValidateInputMapDataType(i,r);return r==null||r.attemptAutoclose("infer-input-map-data-type",this.id),{updated:C(m),added:C(h),removed:C(E),affected:C(b),self:i.dataType}}const a=(f=i.declaration)==null?void 0:f.getDataType(r);if(a&&a.isResolved)return r==null||r.attemptAutoclose("infer-input-map-data-type-validate-data",this.id),{updated:[],added:[],removed:[],affected:[],self:a};if(i.readsValue){const h=Sd(i.readsValue,r);return r==null||r.attemptAutoclose("infer-input-map-data-type-validate-data",this.id),{updated:[],added:[],removed:[],affected:[],self:h}}return r==null||r.attemptAutoclose("infer-input-map-data-type-validate-data",this.id),{updated:[],added:[],removed:[],affected:[],self:null}}inferOutputMapDataType(i,r=this.project.addChangeSet(new S(this.project,x.sessionAuthor,B().toISOString(),this,!0,"infer-output-map-data-type-validate-data"))){var a;if(((a=i.declaration)==null?void 0:a.id)===ne.operation[Le.Validate].dataType.entity.properties.outputEntity.id){const{added:c,updated:e,removed:f,affected:h}=this.syncOutputDataOutputMapDataType(i,r);return r==null||r.attemptAutoclose("infer-output-map-data-type-validate-data",this.id),{updated:C(e),added:C(c),removed:C(f),affected:C(h),self:i.dataType}}return{updated:[],added:[],removed:[],affected:[],self:null}}}class __i extends Hi{constructor(p){super(iP,p)}}class V_i extends Hi{constructor(p){super(rP,p)}}class P_i extends Hi{constructor(p){super(nP,p)}}class N_i extends Hi{constructor(p){super(kg,p)}}class x_i extends Hi{constructor(p){super(ag,p)}}class $_i extends Hi{constructor(p){super(pv,p)}}function ske(l){const p=[new $_e(l),new C_i(l),new O_i(l),new N_i(l),new __i(l),new P_i(l),new V_i(l),new x_i(l),new $_i(l)];return DN.forEach(i=>{p.some(r=>r.id===i.id)||p.push(new Hi(i,l))}),p.forEach(i=>{i.initChildren(null),l.subscribeBuiltInInstance(i)}),l.operationDeclarations=p,p}const L_i=[];function lke(l){const p=[new C_e(l),new V_e(l),new N_e(l),new x_e(l)];return YN.forEach(i=>{!p.some(r=>r.id===i.id)&&!L_i.includes(i.id)&&p.push(new od(i,l))}),p.forEach(i=>{l.subscribeBuiltInInstance(i)}),l.builtInBaseEntities=p,p}function oke(l){const p=[new xa(Ee,l),new xa(ct,l),new xa(Ne,l),new xa(Aa,l),new xa(Rt,l),new xa(Pt,l),new xa(ut,l),new xa(ro,l),new xa(nr,l)];return p.forEach(i=>{l.subscribeBuiltInInstance(i)}),l.primitives=p,p}function dke(l){const p=[new Hi(i1,l)];return p.forEach(i=>{i.initChildren(null),l.subscribeBuiltInInstance(i)}),l.globalEventActionDescriptors=p,p}function uke(l){const p=[new Hi(lE,l),new Hi(Ff,l),new Hi(aE,l),new Hi(vm,l),new Hi(Em,l),new Hi(BR,l)];p.forEach(r=>{r.initChildren(null),l.subscribeBuiltInInstance(r)}),l.loopDeclarations=p;const i=[new Hi(ZR,l),new Hi(sE,l),new Hi(kR,l),new Hi(PN,l),new Hi($N,l),new Hi(MR,l)];return i.forEach(r=>{r.initChildren(null),l.subscribeBuiltInInstance(r)}),l.loopDeclarationsBodies=i,p}function pke(l){const p=[new ud(rx,l)];return p.forEach(i=>{i.initChildren(null),l.subscribeBuiltInInstance(i)}),l.valueDescriptors=p,p}function cke(l){const p=[new Hi(QN,l),new Hi(JN,l),new Hi(XN,l),new Hi(ex,l)];return tx.forEach(i=>{p.some(r=>r.id===i.id)||p.push(new Hi(i,l))}),p.forEach(i=>{i.initChildren(null),l.subscribeBuiltInInstance(i)}),l.conditionDeclarations=p,p}function OT(l){return l&&typeof l.then=="function"}function B_i(l,p){const i=new Bn(l[0],{allBuiltInEntityIds:p.allBuiltInEntityIds}),r=l.map(c=>c.id),a={};return l.forEach(c=>{a[c.id]=c}),i.order=r,i.flatRecord=a,i.orderEntities(),i.order.map(c=>i.flatRecord[c])}function M_i(l,p){const i=new Bn(Object.values(l)[0],{allBuiltInEntityIds:p.allBuiltInEntityIds}),r=Object.keys(l);return i.order=r,i.flatRecord=l,i.orderEntities(),i.order}async function G_i(l,p){const i=Y.YieldTracker.from(p),r=new Bn(l[0],{allBuiltInEntityIds:p.allBuiltInEntityIds}),a=l.map(e=>e.id),c={};for(const e of l)c[e.id]=e,await i.tick();return r.order=a,r.flatRecord=c,await r.orderEntitiesAsync({tracker:i}),r.order.map(e=>r.flatRecord[e])}async function j_i(l,p){const i=Y.YieldTracker.from(p),r=new Bn(Object.values(l)[0],{allBuiltInEntityIds:p.allBuiltInEntityIds}),a=Object.keys(l);return r.order=a,r.flatRecord=l,await r.orderEntitiesAsync({tracker:i}),r.order}class Bn{constructor(p,i={}){R(this,"order",[]);R(this,"flatRecord",{});R(this,"allBuiltInEntityIds");R(this,"onGoingVisits",{});R(this,"cachedReferences",{});if(i.allBuiltInEntityIds&&(this.allBuiltInEntityIds=i.allBuiltInEntityIds),!p)return;const r={asyncInitialOrder:!1,...i};r.asyncInitialOrder?this.flattenAsync(p).then(()=>{this.orderEntitiesAsync({...r}).then(()=>{var a;(a=r.onOrdered)==null||a.call(r)})}):(this.flatten(p),this.orderEntities())}flatten(p){this.allBuiltInEntityIds||(this.allBuiltInEntityIds=new Set(z1()));const i=C(Ue(p,new Set(this.allBuiltInEntityIds),{ignoreBuiltInBaseEntities:!0,diggestedBuiltInBaseEntitiesIds:this.allBuiltInEntityIds})),r=new Set;for(const a of i)this.flatRecord[a.id]=a,r.add(a.id);this.order=Array.from(r)}async flattenAsync(p,i={}){const r=Y.YieldTracker.from(i);this.allBuiltInEntityIds||(this.allBuiltInEntityIds=await Y1({tracker:r}));const a=await pp(await ke(p,new Set(this.allBuiltInEntityIds),{ignoreBuiltInBaseEntities:!0,diggestedBuiltInBaseEntitiesIds:this.allBuiltInEntityIds,tracker:r}),{tracker:r}),c=new Set;for(const e of a)this.flatRecord[e.id]=e,c.add(e.id),await r.tick();this.order=Array.from(c)}moveEntityAfterDependencies(p){const i=this.cachedReferences[p.id]||Jl(p,this.flatRecord,{ignoreBuiltInBaseEntities:!0,allBuiltInEntityIds:this.allBuiltInEntityIds});this.cachedReferences[p.id]=i;const{upstream:r}=i;for(const a of Object.keys(r)){const c=this.order.indexOf(a),e=this.order.indexOf(p.id);if(c>e)return this.order.splice(e,1),this.order.splice(c,0,p.id),!0}return!1}orderEntities(){let p=!1;for(let i=0;i<this.order.length;i++){const r=this.order[i],a=this.flatRecord[r];if(a||Y.Logger.warn(`Entity with id ${r} not found in flatRecord. Skipping...`),this.moveEntityAfterDependencies(a)){p=!0;break}}p&&this.orderEntities()}async orderEntitiesAsync(p={}){let i=!1;const r=Y.YieldTracker.from(p);for(let a=0;a<this.order.length;a++){const c=this.order[a],e=this.flatRecord[c];if(e||Y.Logger.warn(`Entity with id ${c} not found in flatRecord. Skipping...`),this.moveEntityAfterDependencies(e)){i=!0;break}await r.tick()}i&&await this.orderEntitiesAsync({tracker:r})}getUpstreamOngoingDependenciesVisits(p,i){const r=this.cachedReferences[p]||Jl(this.flatRecord[p],this.flatRecord,{ignoreBuiltInBaseEntities:!0,allBuiltInEntityIds:this.allBuiltInEntityIds});this.cachedReferences[p]=r;const{upstream:a}=r,c={};return Object.entries(this.onGoingVisits[i]||{}).forEach(([e,f])=>{Object.keys(a).includes(e)&&(c[e]=f)}),c}getDownstreamOngoingDependenciesVisits(p,i){const r=Object.keys(this.onGoingVisits[i]||{}),a=new Set(r.flatMap(e=>{const f=this.cachedReferences[e]||Jl(this.flatRecord[e],this.flatRecord,{ignoreBuiltInBaseEntities:!0,allBuiltInEntityIds:this.allBuiltInEntityIds});return this.cachedReferences[e]=f,Object.keys(f.downstream)})),c={};return Array.from(a).forEach(e=>{e===p&&(c[e]=this.onGoingVisits[i][e])}),c}async settlePromises(p,i){const r=Object.values(p);r.length&&await Promise.all(r),Object.keys(p).forEach(a=>{delete this.onGoingVisits[i][a]})}visit(p){const i=this.order;for(const r of i)p(this.flatRecord[r],this.flatRecord);return this}reverseVisit(p){const i=this.order.slice().reverse();for(const r of i)p(this.flatRecord[r],this.flatRecord);return this}async visitAsync(p,i={}){const{parallelise:r}={parallelise:!0,...i},a=Y.YieldTracker.from(i),c=this.order;if(!r){for(const f of c){const h=p(this.flatRecord[f],this.flatRecord);OT(h)&&await h,await a.tick()}return this}const e=Math.random().toString(36).substring(7);this.onGoingVisits[e]={};for(const f of c){const h=this.getUpstreamOngoingDependenciesVisits(f,e);Object.keys(h).length&&await this.settlePromises(h,e);const m=p(this.flatRecord[f],this.flatRecord);OT(m)&&(this.onGoingVisits[e][f]=m),await a.tick()}return await this.settlePromises(this.onGoingVisits[e],e),this.onGoingVisits[e]={},this}async reverseVisitAsync(p,i={}){const{parallelise:r}={parallelise:!0,...i},a=Y.YieldTracker.from(i),c=this.order.slice().reverse();if(!r){for(const f of c){const h=p(this.flatRecord[f],this.flatRecord);OT(h)&&await h,await a.tick()}return this}const e=Math.random().toString(36).substring(7);this.onGoingVisits[e]={};for(const f of c){const h=this.getDownstreamOngoingDependenciesVisits(f,e);Object.keys(h).length&&await this.settlePromises(h,e);const m=p(this.flatRecord[f],this.flatRecord);OT(m)&&(this.onGoingVisits[e][f]=m),await a.tick()}return await this.settlePromises(this.onGoingVisits[e],e),this.onGoingVisits[e]={},this}}const uf={},HA={},iv={empty:!1,enrich:!0,mock:!1,ignoreCache:!1,onFetch:async()=>null,manuallyInit:!1};function fke(l,p={enrich:!0,shallowErrors:!1},i){const r={enrich:!0,shallowErrors:!1,...p},{enrich:a,shallowErrors:c}=r,e=l.project,f=l.record,h=K1(l.project,{shallowErrors:c},i);h.instances[e.id]=h;const m=new Bn(e,{allBuiltInEntityIds:h.diggestedBuiltInBaseEntitiesIds}),E=new Set;f[e.id]=e,E.add(e.id);const b=B().toISOString();Object.values(f).forEach(_=>{!_||m.allBuiltInEntityIds.has(_.id)||E.add(_.id)}),m.order=Array.from(E),m.flatRecord=f,m.orderEntities();const A=a?h.addChangeSet(new S(h,x.sessionAuthor,b,h,!0,"project-init-from-fetch-result")):null;return m.visit(_=>{if(_.id===h.id)return;const N=Ae(_,h);try{N.hydrateAncestors(),N.addSelfToProject(null);const V=Jl(_);Object.keys(V.downstream).forEach(j=>{const M=h.get(j);M&&M.hydrateAncestors()})}catch(V){if(c)Y.Logger.error("Error hydrating ancestors: ",V);else throw V}}),a?(m.visit(_=>{if(_.id===h.id)return;const N=h.get(_.id);if(N)try{N.afterAllChildrenInitialized(A),N.captureVersion()}catch(V){if(c)Y.Logger.error("Error in afterAllChildrenInitialized: ",V);else throw V}}),h.afterAllChildrenInitialized(A),h.subscribe(),h.captureVersion()):(Pu(h,b).forEach(N=>{N.remove({ignoreUpstream:!0},null)}),m.visit(N=>{if(N.id===h.id)return;const V=h.get(N.id);V&&(V.initialized=!0,V.captureVersion())}),h.initialized=!0,h.subscribe(),h.captureVersion()),h.initialized=!0,h.emit(si.PROJECT_INITIALIZED,h,A),A==null||A.attemptAutoclose("project-init-from-fetch-result",h.id),h}async function k_i(l,p={enrich:!0,shallowErrors:!1,yieldEvery:100},i){const r={enrich:!0,shallowErrors:!1,yieldEvery:100,...p},{enrich:a,shallowErrors:c,yieldEvery:e}=r,f=Y.YieldTracker.from({yieldEvery:e}),h=l.project,m=l.record,E=await q1(l.project,{shallowErrors:c,tracker:f},i);E.instances[h.id]=E;const b=new Bn(void 0,{allBuiltInEntityIds:E.diggestedBuiltInBaseEntitiesIds});await b.flattenAsync(h,{tracker:f}),await b.orderEntitiesAsync({tracker:f});const A=new Set;m[h.id]=h,A.add(h.id);const _=B().toISOString();for(const[V,j]of Object.entries(m))!j||b.allBuiltInEntityIds.has(j.id)||(A.add(j.id),await f.tick());b.order=Array.from(A),b.flatRecord=m,await b.orderEntitiesAsync({tracker:f});const N=a?E.addChangeSet(new S(E,x.sessionAuthor,_,E,!0,"project-init-from-fetch-result")):null;if(await b.visitAsync(V=>{if(V.id===E.id)return;const j=Ae(V,E);try{j.hydrateAncestors(),j.addSelfToProject(null);const M=Jl(V);Object.keys(M.downstream).forEach(G=>{const q=E.get(G);q&&q.hydrateAncestors()})}catch(M){if(c)Y.Logger.error("Error hydrating ancestors: ",M);else throw Y.Logger.log("Error hydrating ancestors: ",M),M}},{tracker:f}),a){try{await b.visitAsync(V=>{if(V.id===E.id)return;const j=E.get(V.id);j&&(j.afterAllChildrenInitialized(N),j.captureVersion())},{tracker:f})}catch(V){if(c)Y.Logger.error("Error in afterAllChildrenInitialized: ",V);else throw Y.Logger.log("Error in afterAllChildrenInitialized: ",V),V}E.afterAllChildrenInitialized(N),E.subscribe(),E.captureVersion()}else Pu(E,_).forEach(j=>{j.remove({ignoreUpstream:!0},null)}),await b.visitAsync(j=>{if(j.id===E.id)return;const M=E.get(j.id);M&&(M.initialized=!0,M.captureVersion())},{tracker:f}),E.initialized=!0,E.subscribe(),E.captureVersion();return E.initialized=!0,E.emit(si.PROJECT_INITIALIZED,E,N),N==null||N.attemptAutoclose("project-init-from-fetch-result",E.id),E}async function U_i(l,p=iv){const i={...iv,...p};if(i.empty)return{data:{project:{id:l.id,deletable:!0,editable:!0,type:d.Project,version:x.UUID.uuid(),createdAt:B().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,name:null,description:null,projects:[],entities:[],operations:[],functions:[],variableDeclarations:[],variableInstances:[],functionCalls:[],conditions:[],loops:[],searches:[],events:[]},record:{}}};if(i.mock){const a={...r2};return a.id=l.id,{data:{project:a,record:{}}}}return Y.Logger.log("Fetching project from external API"),new Promise(async a=>{try{if(i.onFetch){const c=await i.onFetch(l.id);if(c){a({data:c});return}}else a({data:null})}catch(c){Y.Logger.error("Error fetching project: ",c),a({data:null})}})}function K1(l,p={shallowErrors:!1},i){const r=new x(l,i);oke(r),lke(r),ske(r),dke(r),uke(r),pke(r),cke(r);const a=p.allBuiltInIds??new Set([...r.getAllBuiltInIds(),...z1()]);return r.diggestedBuiltInBaseEntitiesIds=a,a.forEach(c=>{if(!r.builtInInstances[c]&&r.instances[c])r.builtInInstances[c]=r.instances[c],delete r.instances[c];else if(!r.builtInInstances[c]&&!p.shallowErrors)throw new Error(`Built in entity was not properly initialized: ${c}`)}),r.instances[r.id]=r,r.activeVersion=!0,r}async function q1(l,p={shallowErrors:!1},i){const r=Y.YieldTracker.from(p),a=new x(l,i);oke(a),lke(a),await Y.yieldToEventLoop(),ske(a),await Y.yieldToEventLoop(),dke(a),uke(a),pke(a),cke(a),await Y.yieldToEventLoop();const c=p.allBuiltInIds??new Set([...a.getAllBuiltInIds(),...await Y1()]);a.diggestedBuiltInBaseEntitiesIds=c;for(const e of c){if(!a.builtInInstances[e]&&a.instances[e])a.builtInInstances[e]=a.instances[e],delete a.instances[e];else if(!a.builtInInstances[e]&&!p.shallowErrors)throw new Error(`Built in entity was not properly initialized: ${e}`);a.instances[e]&&delete a.instances[e],await r.tick()}return a.instances[a.id]=a,a.activeVersion=!0,a}function Pu(l,p){return l.instancesList.filter(r=>B(r.createdAt).isAfter(B(p)||!!r.previousVersion))}function F_i(l,{enrich:p,shallowErrors:i,...r}={enrich:!0,shallowErrors:!1},a){var _,N;const c=new Map,e=new Map;Object.keys(l.instances).forEach(V=>{if(l.diggestedBuiltInBaseEntitiesIds.has(V)){c.set(V,V),e.set(V,V);return}const j=l.get(V);if(!rD(j,{...l.instances,...l.builtInInstances}).every(re=>!l.diggestedBuiltInBaseEntitiesIds.has(re))){c.set(V,V),e.set(V,V);return}const q=x.UUID.uuid();c.set(V,q),e.set(q,V)});const f=((_=r.resetVersionOptions)==null?void 0:_.commonTimestamp)??B().toISOString(),h=l.toShallowJSON({seenEntityMaps:c});h.previousVersion=null,h.createdAt=f,h.version=x.UUID.uuid(),h.author=((N=r.resetVersionOptions)==null?void 0:N.author)??(x.sessionAuthor||"1");const m=K1(h,{shallowErrors:i,allBuiltInIds:l.diggestedBuiltInBaseEntitiesIds},a);m.instances[m.id]=m;const E=p?m.addChangeSet(new S(m,x.sessionAuthor,f,m,!0,"project-clone")):null,b=new Bn(l,{allBuiltInEntityIds:l.diggestedBuiltInBaseEntitiesIds}),A=uL(b.flatRecord,c);return b.visit(V=>{var q;const j=V.toShallowJSON({seenEntityMaps:c});j.previousVersion=null,j.createdAt=f,j.version=x.UUID.uuid(),j.author=((q=r.resetVersionOptions)==null?void 0:q.author)??(x.sessionAuthor||"1");const M=Jl(j,A);if(Object.keys(M.upstream).length){let re=!1;if(Object.keys(M.upstream).forEach(ee=>{if(!re&&(!m.get(ee)||m.getDeleted(ee))){re=!0;return}}),re)return}const G=Ae(j,m);G.hydrateAncestors(),G.addSelfToProject(E),E==null||E.add(G,W.Added),r.onVisit&&r.onVisit(j)}),p?(b.visit(V=>{if(V.id===m.id)return;const j=m.get(c.get(V.id));j&&(j.afterAllChildrenInitialized(E),j.captureVersion())}),m.afterAllChildrenInitialized(E),m.subscribe(),m.captureVersion()):(Pu(m,f).forEach(j=>{j.remove({ignoreUpstream:!0},null)}),b.visit(j=>{if(j.id===m.id)return;const M=m.get(j.id);M&&(M.initialized=!0,M.captureVersion())}),m.initialized=!0,m.subscribe(),m.captureVersion()),m.instancesList.forEach(V=>{V.previousVersion=null}),E==null||E.attemptAutoclose("project-clone",m.id),{project:m,maps:c}}async function K_i(l,{shallowErrors:p,...i}={shallowErrors:!1,yieldEvery:100}){var m,E;const r=Y.YieldTracker.from(i),a=new Map,c=new Map;Object.keys(l.instances).forEach(b=>{if(l.diggestedBuiltInBaseEntitiesIds.has(b)){a.set(b,b),c.set(b,b);return}const A=x.UUID.uuid();a.set(b,A),c.set(A,b)});const e=((m=i.resetVersionOptions)==null?void 0:m.commonTimestamp)??B().toISOString(),f=l.toShallowJSON({seenEntityMaps:a});f.previousVersion=null,f.createdAt=e,f.version=x.UUID.uuid(),f.author=((E=i.resetVersionOptions)==null?void 0:E.author)??(x.sessionAuthor||"1");const h=await l.toFullProjectTransferAsync({tracker:r,seenEntityMaps:a,resetVersionOptions:i.resetVersionOptions,onVisit:i.onVisit});return{project:f,record:h.record,order:h.order,maps:a}}async function q_i(l,{enrich:p,shallowErrors:i,...r}={enrich:!0,shallowErrors:!1,yieldEvery:100},a){var N,V;const c=Y.YieldTracker.from(r),e=new Map,f=new Map;for(const j of Object.keys(l.instances)){if(l.diggestedBuiltInBaseEntitiesIds.has(j)){e.set(j,j),f.set(j,j),await c.tick();continue}const M=x.UUID.uuid();e.set(j,M),f.set(M,j),await c.tick()}const h=((N=r.resetVersionOptions)==null?void 0:N.commonTimestamp)??B().toISOString(),m=l.toShallowJSON({seenEntityMaps:e});m.previousVersion=null,m.createdAt=h,m.version=x.UUID.uuid(),m.author=((V=r.resetVersionOptions)==null?void 0:V.author)??(x.sessionAuthor||"1");const E=await q1(m,{shallowErrors:i,tracker:c},a);E.diggestedBuiltInBaseEntitiesIds=l.diggestedBuiltInBaseEntitiesIds,E.instances[E.id]=E;const b=p?E.addChangeSet(new S(E,x.sessionAuthor,h,E,!0,"project-clone")):null,A=new Bn(void 0,{allBuiltInEntityIds:l.diggestedBuiltInBaseEntitiesIds}),_=await l.toFullProjectTransferAsync({tracker:c,seenEntityMaps:e,resetVersionOptions:r.resetVersionOptions,onVisit:r.onVisit,shallowErrors:i});A.flatRecord=_.record,A.order=_.order,await A.visitAsync(j=>{var re;if(l.diggestedBuiltInBaseEntitiesIds.has(j.id))return;const M=j;M.previousVersion=null,M.createdAt=h,M.version=x.UUID.uuid(),M.author=((re=r.resetVersionOptions)==null?void 0:re.author)??(x.sessionAuthor||"1");const G=Jl(M,A.flatRecord);if(Object.keys(G.upstream).length){let ee=!1;if(Object.keys(G.upstream).forEach(de=>{if(!ee&&(!E.get(de)||E.getDeleted(de))){ee=!0;return}}),ee)return}const q=Ae(M,E);q.hydrateAncestors(),q.addSelfToProject(b),b==null||b.add(q,W.Added)},{tracker:c}),p?(await A.visitAsync(j=>{if(j.id===E.id||l.diggestedBuiltInBaseEntitiesIds.has(j.id))return;const M=E.get(e.get(j.id));M&&(M.afterAllChildrenInitialized(b),M.captureVersion())},{tracker:c}),E.afterAllChildrenInitialized(b),E.subscribe(),E.captureVersion()):(Pu(E,h).forEach(M=>{M.remove({ignoreUpstream:!0},null)}),await A.visitAsync(M=>{if(M.id===E.id)return;const G=E.get(M.id);G&&(G.initialized=!0,G.captureVersion())},{tracker:c}),E.initialized=!0,E.subscribe(),E.captureVersion());for(const j of E.instancesList)j.previousVersion=null,await c.tick();return b==null||b.attemptAutoclose("project-clone",E.id),{project:E,maps:e}}function S_i(l,p,i=p.addChangeSet(new S(p,x.sessionAuthor,B().toISOString(),p,!0,w.AfterAllChildrenInitialized)),{enrich:r,shallowErrors:a,...c}={shallowErrors:!1,enrich:!0}){var A,_;const e=new Map,f=new Map;Object.keys(l.instances).forEach(N=>{if(l.diggestedBuiltInBaseEntitiesIds.has(N)){e.set(N,N),f.set(N,N);return}if(N===l.id){e.set(N,p.id),f.set(p.id,N);return}const V=l.get(N);if(!rD(V,{...l.instances,...l.builtInInstances}).every(q=>!l.diggestedBuiltInBaseEntitiesIds.has(q))){e.set(N,N),f.set(N,N);return}const G=x.UUID.uuid();e.set(N,G),f.set(G,N)});const h=((A=c.resetVersionOptions)==null?void 0:A.commonTimestamp)??B().toISOString(),m=l.toShallowJSON({seenEntityMaps:e});m.previousVersion=null,m.createdAt=h,m.version=x.UUID.uuid(),m.author=((_=c.resetVersionOptions)==null?void 0:_.author)??(x.sessionAuthor||"1");const E=new Bn(l,{allBuiltInEntityIds:l.diggestedBuiltInBaseEntitiesIds}),b=uL(E.flatRecord,e);return E.visit(N=>{var M;if(N.id===p.id)return;const V=N.toShallowJSON({seenEntityMaps:e});V.previousVersion=null,V.createdAt=h,V.version=x.UUID.uuid(),V.author=((M=c.resetVersionOptions)==null?void 0:M.author)??(x.sessionAuthor||"1");const j=Jl(V,b);if(Object.keys(j.upstream).length){let G=!1;if(Object.keys(j.upstream).forEach(q=>{if(!G&&(!p.get(q)||p.getDeleted(q))){G=!0;return}}),G)return}try{const G=Ae(V,p);G.hydrateAncestors(),G.addSelfToProject(i),i==null||i.add(G,W.Added),c.onVisit&&c.onVisit(V)}catch(G){if(a)Y.Logger.error("Error cloning entity onto existing project: ",G);else throw Y.Logger.log("Error cloning entity onto existing project: ",G),G}}),r?(E.visit(N=>{if(N.id===p.id)return;const V=p.get(e.get(N.id));V&&(V.afterAllChildrenInitialized(i),V.previousVersion=null,V.captureVersion())}),p.afterAllChildrenInitialized(i),p.subscribe(),p.captureVersion()):(Pu(p,h).forEach(V=>{V.remove({ignoreUpstream:!0},null)}),E.visit(V=>{if(V.id===p.id)return;const j=p.get(V.id);j&&(j.initialized=!0,j.previousVersion=null,j.captureVersion())}),p.initialized=!0,p.subscribe(),p.captureVersion()),p.afterAllChildrenInitialized(i),p.captureVersion(),{project:p,maps:e,changeSet:i}}async function Z_i(l,p,i=p.addChangeSet(new S(p,x.sessionAuthor,B().toISOString(),p,!0,w.AfterAllChildrenInitialized)),{enrich:r,shallowErrors:a,...c}={enrich:!0,shallowErrors:!1,yieldEvery:100}){var _,N;const e=Y.YieldTracker.from(c),f=new Map,h=new Map;for(const V of Object.keys(l.instances)){if(l.diggestedBuiltInBaseEntitiesIds.has(V)){f.set(V,V),h.set(V,V),await e.tick();continue}if(V===l.id){f.set(V,p.id),h.set(p.id,V),await e.tick();continue}const j=x.UUID.uuid();f.set(V,j),h.set(j,V),await e.tick()}const m=((_=c.resetVersionOptions)==null?void 0:_.commonTimestamp)??B().toISOString(),E=l.toShallowJSON({seenEntityMaps:f});E.previousVersion=null,E.createdAt=m,E.version=x.UUID.uuid(),E.author=((N=c.resetVersionOptions)==null?void 0:N.author)??(x.sessionAuthor||"1"),p.diggestedBuiltInBaseEntitiesIds=l.diggestedBuiltInBaseEntitiesIds;const b=new Bn(void 0,{allBuiltInEntityIds:l.diggestedBuiltInBaseEntitiesIds}),A=await l.toFullProjectTransferAsync({tracker:e,seenEntityMaps:f,resetVersionOptions:c.resetVersionOptions,onVisit:c.onVisit,shallowErrors:a});return b.flatRecord=A.record,b.order=A.order,await b.visitAsync(V=>{var G;if(l.diggestedBuiltInBaseEntitiesIds.has(V.id)||V.id===p.id)return;const j=V;j.previousVersion=null,j.createdAt=m,j.version=x.UUID.uuid(),j.author=((G=c.resetVersionOptions)==null?void 0:G.author)??(x.sessionAuthor||"1");const M=Jl(j,b.flatRecord);if(Object.keys(M.upstream).length){let q=!1;if(Object.keys(M.upstream).forEach(re=>{if(!q&&(!p.get(re)||p.getDeleted(re))){q=!0;return}}),q)return}try{const q=Ae(j,p);q.hydrateAncestors(),q.addSelfToProject(i),i==null||i.add(q,W.Added)}catch(q){if(a)Y.Logger.error("Error cloning entity onto existing project: ",q);else throw Y.Logger.log("Error cloning entity onto existing project: ",q),q}},{tracker:e}),r?(await b.visitAsync(V=>{if(V.id===p.id||l.diggestedBuiltInBaseEntitiesIds.has(V.id))return;const j=p.get(f.get(V.id));j&&(j.afterAllChildrenInitialized(i),j.previousVersion=null,j.captureVersion())},{tracker:e}),p.afterAllChildrenInitialized(i),p.subscribe(),p.captureVersion()):(Pu(p,m).forEach(j=>{j.remove({ignoreUpstream:!0},null)}),await b.visitAsync(j=>{if(j.id===p.id)return;const M=p.get(j.id);M&&(M.initialized=!0,M.previousVersion=null,M.captureVersion())},{tracker:e}),p.initialized=!0,p.subscribe(),p.captureVersion()),p.afterAllChildrenInitialized(i),p.captureVersion(),{project:p,maps:f,changeSet:i}}function yke(l,{enrich:p,shallowErrors:i}={enrich:!0,shallowErrors:!1},r){const a=K1(l,{shallowErrors:i},r);a.activeVersion=!0;const c=B().toISOString(),e=p?a.addChangeSet(new S(a,x.sessionAuthor,c,a,!0,"project-init")):null;e&&(e.type=r1.Automatic);const f=new Bn(l,{allBuiltInEntityIds:a.diggestedBuiltInBaseEntitiesIds});return f.visit(h=>{const m=Ae(h,a);m.hydrateAncestors(),m.addSelfToProject(e)}),p?(f.visit(h=>{if(h.id===a.id)return;const m=a.get(h.id);m&&(m.afterAllChildrenInitialized(e),m.captureVersion())}),a.afterAllChildrenInitialized(e),a.subscribe(),a.captureVersion()):(Pu(a,c).forEach(m=>{m.remove({ignoreUpstream:!0},null)}),f.visit(m=>{if(m.id===a.id)return;const E=a.get(m.id);E&&(E.initialized=!0,E.captureVersion())}),a.initialized=!0,a.subscribe(),a.captureVersion()),a.initialized=!0,a.emit(si.PROJECT_INITIALIZED,a,e),e==null||e.attemptAutoclose("project-init",a.id),a}async function H_i(l,{enrich:p,shallowErrors:i,yieldEvery:r}={enrich:!0,shallowErrors:!1,yieldEvery:100},a){const c=Y.YieldTracker.from({yieldEvery:r}),e=await q1(l,{shallowErrors:i,tracker:c},a),f=B().toISOString(),h=p?e.addChangeSet(new S(e,x.sessionAuthor,f,e,!0,"project-init")):null;h&&(h.type=r1.Automatic);const m=new Bn(void 0,{allBuiltInEntityIds:e.diggestedBuiltInBaseEntitiesIds});return await m.flattenAsync(l,{tracker:c}),await m.orderEntitiesAsync({tracker:c}),await m.visitAsync(E=>{const b=Ae(E,e);b.hydrateAncestors(),b.addSelfToProject(h)},{tracker:c}),p?(await m.visitAsync(E=>{if(E.id===e.id)return;const b=e.get(E.id);b&&(b.afterAllChildrenInitialized(h),b.captureVersion())},{tracker:c}),e.afterAllChildrenInitialized(h),e.subscribe(),e.captureVersion()):(Pu(e,f).forEach(b=>{b.remove({ignoreUpstream:!0},null)}),await m.visitAsync(b=>{if(b.id===e.id)return;const A=e.get(b.id);A&&(A.initialized=!0,A.captureVersion())},{tracker:c}),e.initialized=!0,e.subscribe(),e.captureVersion()),e.initialized=!0,e.emit(si.PROJECT_INITIALIZED,e,h),h==null||h.attemptAutoclose("project-init",e.id),e}async function W_i(l,p=iv,i){const r={...iv,...p};if(l.id&&uf[l.id]&&!r.ignoreCache)return uf[l.id];if(l.id&&HA[l.id]&&!r.ignoreCache)return await HA[l.id],uf[l.id];const a=U_i(l,r);l.id&&(HA[l.id]=a);const c=await a;if(c.data){let e;return r.mock?e=yke(r2,{enrich:!!r.enrich},i):c.data instanceof x?e=c.data:e=fke(c.data,{enrich:!!r.enrich},i),uf[l.id]=e,l.id&&delete HA[l.id],e}return null}function z_i(l){return uf[l.id]&&delete uf[l.id],null}const rv=Tt([He(),ba(),fr(),Wd()]),hke=Dm([en.CurrentDateAndTime,en.Random,en.Unique]),S1=st({type:hke,rangeStart:rv.nullable(),rangeEnd:rv.nullable()}),UE=S1.extend({type:rt(en.Random),rangeStart:rv,rangeEnd:rv}),mke=S1.extend({type:rt(en.Unique),rangeStart:os(),rangeEnd:os()}),Tke=S1.extend({type:rt(en.CurrentDateAndTime),rangeStart:os(),rangeEnd:os()}),Z1=UE.extend({rangeStart:ba().nullable(),rangeEnd:ba().nullable()}),vke=Z1.extend({rangeStart:ba(),rangeEnd:os()}),Eke=Z1.extend({rangeStart:os(),rangeEnd:ba()}),bke=Z1.extend({rangeStart:ba(),rangeEnd:ba()}),H1=UE.extend({rangeStart:ba().nullable(),rangeEnd:ba().nullable()}),Ake=H1.extend({rangeStart:ba(),rangeEnd:os()}),Ike=H1.extend({rangeStart:os(),rangeEnd:ba()}),gke=H1.extend({rangeStart:ba(),rangeEnd:ba()}),W1=UE.extend({rangeStart:Wd().nullable(),rangeEnd:Wd().nullable()}),Rke=W1.extend({rangeStart:Wd(),rangeEnd:os()}),Dke=W1.extend({rangeStart:os(),rangeEnd:Wd()}),wke=W1.extend({rangeStart:Wd(),rangeEnd:Wd()}),Cke=UE.extend({rangeStart:os(),rangeEnd:os()}),Oke=Tt([Ake,Ike,gke]),_ke=Tt([vke,Eke,bke]),Vke=Tt([Rke,Dke,wke,Tke]),Y_i=Tt([Oke,_ke,Vke,mke,Cke]);function z1(){const l=new Set;return new Set(nx.flatMap(i=>Ue(i,l)).map(i=>i.id))}function No(l){return[...l.calledByEntry||[],...l.calledByError||[],...l.calledBySuccess||[]].filter(p=>p.type!==d.GenericReference)}function Pke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.ActionDescriptor)throw new Error("Entity must be an action descriptor to be flattened");return[l,...l.inputs.flatMap(r=>Ue(r,p,i)),...l.dataType?Ue(l.dataType,p,i):[],...l.error?Ue(l.error,p,i):[],...l.parent?Ue(l.parent,p,i):[]]}function Nke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.ArgumentDeclaration)throw new Error("Entity must be an argument declaration to be flattened");return[l,...l.defaultValue?Ue(l.defaultValue,p):[],...l.writesValues.flatMap(r=>Ue(r,p,i)),...l.implements.flatMap(r=>Ue(r,p,i)),...l.dataType?Ue(l.dataType,p,i):[],...l.parent?Ue(l.parent,p,i):[]]}function xke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.BreakStatement)throw new Error("Entity must be a break statement to be flattened");return[l,...l.outputs.flatMap(r=>Ue(r,p,i)),...l.throws?Ue(l.throws,p,i):[],...l.dataType?Ue(l.dataType,p,i):[],...l.readsValue?Ue(l.readsValue,p,i):[],...(No(l)||[]).flatMap(r=>Ue(r,p,i)),...l.parent?Ue(l.parent,p,i):[]]}function $ke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.BuiltInBaseEntity)throw new Error("Entity must be a built-in base entity to be flattened");return[l,...(l.properties||[]).flatMap(r=>Ue(r,p,i)),...(l.methods||[]).flatMap(r=>Ue(r,p,i)),...(l.abstractMethods||[]).flatMap(r=>Ue(r,p,i)),...l.allPropertiesImplement?Ue(l.allPropertiesImplement,p,i):[],...l.additionalPropertiesDataType?Ue(l.additionalPropertiesDataType,p,i):[],...l.extends?Ue(l.extends,p,i):[]]}function Lke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.Condition)throw new Error("Entity must be a condition to be flattened");return[l,...(l.andChildrenGroup||[]).flatMap(r=>Ue(r,p,i)),...(l.orChildrenGroup||[]).flatMap(r=>Ue(r,p,i)),...(l.inputs||[]).flatMap(r=>Ue(r,p,i)),...(l.successCalls||[]).flatMap(r=>Ue(r,p,i)),...(l.errorCalls||[]).flatMap(r=>Ue(r,p,i)),...(No(l)||[]).flatMap(r=>Ue(r,p,i)),...l.parent?Ue(l.parent,p,i):[]]}function Bke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.ContinueStatement)throw new Error("Entity must be a continue statement to be flattened");return[l,...l.outputs.flatMap(r=>Ue(r,p,i)),...l.readsValue?Ue(l.readsValue,p,i):[],...l.throws?Ue(l.throws,p,i):[],...l.dataType?Ue(l.dataType,p,i):[],...(No(l)||[]).flatMap(r=>Ue(r,p,i)),...l.parent?Ue(l.parent,p,i):[]]}function Mke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.DefinitionEntity)throw new Error("Entity must be a definition entity to be flattened");return[l,...l.extends?Ue(l.extends,p,i):[],...(l.implements||[]).flatMap(r=>Ue(r,p,i)),...(l.properties||[]).flatMap(r=>Ue(r,p,i)),...(l.methods||[]).flatMap(r=>Ue(r,p,i)),...(l.abstractMethods||[]).flatMap(r=>Ue(r,p,i)),...l.allPropertiesImplement?Ue(l.allPropertiesImplement,p,i):[],...l.additionalPropertiesDataType?Ue(l.additionalPropertiesDataType,p,i):[],...l.parent?Ue(l.parent,p,i):[]]}function Gke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.DataType)throw new Error("Entity must be a data type to be flattened");return[l,...(l.andChildrenGroup||[]).flatMap(r=>Ue(r,p,i)),...(l.orChildrenGroup||[]).flatMap(r=>Ue(r,p,i)),...l.entity?Ue(l.entity,p,i):[],...l.foreignKeyRef?Ue(l.foreignKeyRef,p,i):[],...l.parent?Ue(l.parent,p,i):[]]}function jke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.FunctionCall)throw new Error("Entity must be a function call to be flattened");return[l,...(l.inputs||[]).flatMap(r=>Ue(r,p,i)),...(l.outputs||[]).flatMap(r=>Ue(r,p,i)),...l.error?Ue(l.error,p,i):[],...(No(l)||[]).flatMap(r=>Ue(r,p,i)),...(l.successCalls||[]).flatMap(r=>Ue(r,p,i)),...(l.errorCalls||[]).flatMap(r=>Ue(r,p,i)),...(l.writesValues||[]).flatMap(r=>Ue(r,p,i)),...l.parent?Ue(l.parent,p,i):[]]}function kke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.FunctionDeclaration)throw new Error("Entity must be a function declaration to be flattened");return[l,...(l.inputs||[]).flatMap(r=>Ue(r,p,i)),...(l.calls||[]).flatMap(r=>Ue(r,p,i)),...l.dataType?Ue(l.dataType,p,i):[],...l.implements?Ue(l.implements,p,i):[],...l.parent?Ue(l.parent,p,i):[]]}function Uke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.GlobalEvent)throw new Error("Entity must be a global event to be flattened");return[l,...(l.inputs||[]).flatMap(r=>Ue(r,p,i)),...(l.calls||[]).flatMap(r=>Ue(r,p,i)),...l.implements?Ue(l.implements,p,i):[],...l.parent?Ue(l.parent,p,i):[]]}function Fke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.InputMap)throw new Error("Entity must be an input map to be flattened");return[l,...l.readsValue?Ue(l.readsValue,p,i):[],...l.declaration?Ue(l.declaration,p,i):[],...l.defaultValue?Ue(l.defaultValue,p,i):[],...l.parent?Ue(l.parent,p,i):[]]}function Kke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.InstalledProject)throw new Error("Entity must be an installed project to be flattened");return[l,...(l.functions||[]).flatMap(r=>Ue(r,p,i)),...(l.events||[]).flatMap(r=>Ue(r,p,i)),...l.parent?Ue(l.parent,p,i):[]]}function qke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.InternalCall)throw new Error("Entity must be an internal call to be flattened");return[l,...(l.successCalls||[]).flatMap(r=>Ue(r,p,i)),...(l.errorCalls||[]).flatMap(r=>Ue(r,p,i)),...(l.inputs||[]).flatMap(r=>Ue(r,p,i)),...(l.outputs||[]).flatMap(r=>Ue(r,p,i)),...(No(l)||[]).flatMap(r=>Ue(r,p,i)),...l.error?Ue(l.error,p,i):[],...(l.writesValues||[]).flatMap(r=>Ue(r,p,i)),...l.parent?Ue(l.parent,p,i):[]]}function Ske(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.LiteralValue)throw new Error("Entity must be a literal value to be flattened");return[l,...l.valueAsTypeSingle?Ue(l.valueAsTypeSingle,p,i):[],...l.valueAsTypeList&&Array.isArray(l.valueAsTypeList)?l.valueAsTypeList.flatMap(r=>Ue(r,p,i)):[],...l.parent?Ue(l.parent,p,i):[]]}function Zke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.Loop)throw new Error("Entity must be a loop to be flattened");return[l,...(l.inputs||[]).flatMap(r=>Ue(r,p,i)),...(l.outputs||[]).flatMap(r=>Ue(r,p,i)),...(l.successCalls||[]).flatMap(r=>Ue(r,p,i)),...(l.errorCalls||[]).flatMap(r=>Ue(r,p,i)),...l.error?Ue(l.error,p,i):[],...l.dataType?Ue(l.dataType,p,i):[],...l.body?Ue(l.body,p,i):[],...(No(l)||[]).flatMap(r=>Ue(r,p,i)),...(l.writesValues||[]).flatMap(r=>Ue(r,p,i)),...l.parent?Ue(l.parent,p,i):[]]}function Hke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.Operation)throw new Error("Entity must be an operation to be flattened");return[l,...(l.successCalls||[]).flatMap(r=>Ue(r,p,i)),...(l.errorCalls||[]).flatMap(r=>Ue(r,p,i)),...(l.inputs||[]).flatMap(r=>Ue(r,p,i)),...(l.outputs||[]).flatMap(r=>Ue(r,p,i)),...(l.writesValues||[]).flatMap(r=>Ue(r,p,i)),...l.error?Ue(l.error,p,i):[],...(No(l)||[]).flatMap(r=>Ue(r,p,i)),...l.parent?Ue(l.parent,p,i):[]]}function Wke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.OutputMap)throw new Error("Entity must be an output map to be flattened");return[l,...(l.writesValues||[]).flatMap(r=>Ue(r,p,i)),...l.declaration?Ue(l.declaration,p,i):[],...l.parent?Ue(l.parent,p,i):[]]}function zke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.PrimitiveEntity)throw new Error("Entity must be a primitive entity to be flattened");return[l,...(l.properties||[]).flatMap(r=>Ue(r,p,i)),...(l.methods||[]).flatMap(r=>Ue(r,p,i)),...(l.abstractMethods||[]).flatMap(r=>Ue(r,p,i))]}function Yke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.Project)throw new Error("Entity must be a project to be flattened");return[l,...(l.entities||[]).flatMap(r=>Ue(r,p,i)),...(l.functions||[]).flatMap(r=>Ue(r,p,i)),...(l.events||[]).flatMap(r=>Ue(r,p,i)),...(l.projects||[]).flatMap(r=>Ue(r,p,i)),...(l.variableDeclarations||[]).flatMap(r=>Ue(r,p,i)),...(l.variableInstances||[]).flatMap(r=>Ue(r,p,i)),...(l.operations||[]).flatMap(r=>Ue(r,p,i)),...(l.conditions||[]).flatMap(r=>Ue(r,p,i)),...(l.functionCalls||[]).flatMap(r=>Ue(r,p,i)),...(l.projects||[]).flatMap(r=>Ue(r,p,i)),...(l.loops||[]).flatMap(r=>Ue(r,p,i)),...(l.searches||[]).flatMap(r=>Ue(r,p,i))]}function Jke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.Property)throw new Error("Entity must be a property to be flattened");return[l,...l.defaultValue?Ue(l.defaultValue,p,i):[],...l.dataType?Ue(l.dataType,p,i):[],...l.parent?Ue(l.parent,p,i):[]]}function Qke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.ReturnStatement)throw new Error("Entity must be a return statement to be flattened");return[l,...(l.outputs||[]).flatMap(r=>Ue(r,p,i)),...l.throws?Ue(l.throws,p,i):[],...l.readsValue?Ue(l.readsValue,p,i):[],...l.dataType?Ue(l.dataType,p,i):[],...(No(l)||[]).flatMap(r=>Ue(r,p,i)),...l.parent?Ue(l.parent,p,i):[]]}function Xke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.Search)throw new Error("Entity must be a search to be flattened");return[l,...(l.successCalls||[]).flatMap(r=>Ue(r,p,i)),...(l.errorCalls||[]).flatMap(r=>Ue(r,p,i)),...(l.inputsDeclarations||[]).flatMap(r=>Ue(r,p,i)),...(l.inputs||[]).flatMap(r=>Ue(r,p,i)),...(l.writesValues||[]).flatMap(r=>Ue(r,p,i)),...(l.outputs||[]).flatMap(r=>Ue(r,p,i)),...l.error?Ue(l.error,p,i):[],...l.dataType?Ue(l.dataType,p,i):[],...(No(l)||[]).flatMap(r=>Ue(r,p,i)),...l.parent?Ue(l.parent,p,i):[]]}function eUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.ValueDescriptor)throw new Error("Entity must be a value descriptor to be flattened");return[l,...l.defaultValue?Ue(l.defaultValue,p,i):[],...l.dataType?Ue(l.dataType,p,i):[],...l.parent?Ue(l.parent,p,i):[]]}function tUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.VariableDeclaration)throw new Error("Entity must be a variable declaration to be flattened");return[l,...(l.successCalls||[]).flatMap(r=>Ue(r,p,i)),...(l.errorCalls||[]).flatMap(r=>Ue(r,p,i)),...(l.inputs||[]).flatMap(r=>Ue(r,p,i)),...(l.outputs||[]).flatMap(r=>Ue(r,p,i)),...(l.internalCalls||[]).flatMap(r=>Ue(r,p,i)),...(l.writesValues||[]).flatMap(r=>Ue(r,p,i)),...l.readsValue?Ue(l.readsValue,p,i):[],...l.defaultValue?Ue(l.defaultValue,p,i):[],...(No(l)||[]).flatMap(r=>Ue(r,p,i)),...l.dataType?Ue(l.dataType,p,i):[],...l.parent?Ue(l.parent,p,i):[]]}function iUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.VariableInstance)throw new Error("Entity must be a variable instance to be flattened");return[l,...(l.successCalls||[]).flatMap(r=>Ue(r,p,i)),...(l.errorCalls||[]).flatMap(r=>Ue(r,p,i)),...(l.inputs||[]).flatMap(r=>Ue(r,p,i)),...(l.outputs||[]).flatMap(r=>Ue(r,p,i)),...(l.internalCalls||[]).flatMap(r=>Ue(r,p,i)),...(l.writesValues||[]).flatMap(r=>Ue(r,p,i)),...l.readsValue?Ue(l.readsValue,p,i):[],...l.defaultValue?Ue(l.defaultValue,p,i):[],...(No(l)||[]).flatMap(r=>Ue(r,p,i)),...l.declaration?Ue(l.declaration,p,i):[],...l.parent?Ue(l.parent,p,i):[]]}function Ue(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(!l)throw new Error("Entity must be defined to be flattened");if(l.type===d.GenericReference)return[];const r=i.ignoreBuiltInBaseEntities?i.diggestedBuiltInBaseEntitiesIds??new Set(z1()):new Set;if(i.diggestedBuiltInBaseEntitiesIds=r,i.ignoreBuiltInBaseEntities&&(oa.includes(l.type)||r.has(l.id)))return[];if(p.has(l.id))return[];switch(l.type){case d.FunctionCall:return jke(l,p,i);case d.Operation:return Hke(l,p,i);case d.Condition:return Lke(l,p,i);case d.Loop:return Zke(l,p,i);case d.Search:return Xke(l,p,i);case d.GlobalEvent:return Uke(l,p,i);case d.ReturnStatement:return Qke(l,p,i);case d.ContinueStatement:return Bke(l,p,i);case d.BreakStatement:return xke(l,p,i);case d.VariableDeclaration:return tUe(l,p,i);case d.DefinitionEntity:return Mke(l,p,i);case d.FunctionDeclaration:return kke(l,p,i);case d.Project:return Yke(l,p,i);case d.ActionDescriptor:return Pke(l,p,i);case d.ArgumentDeclaration:return Nke(l,p,i);case d.ValueDescriptor:return eUe(l,p,i);case d.InputMap:return Fke(l,p,i);case d.OutputMap:return Wke(l,p,i);case d.DataType:return Gke(l,p,i);case d.InstalledProject:return Kke(l,p,i);case d.InternalCall:return qke(l,p,i);case d.LiteralValue:return Ske(l,p,i);case d.Property:return Jke(l,p,i);case d.VariableInstance:return iUe(l,p,i);case d.BuiltInBaseEntity:return i.ignoreBuiltInBaseEntities?[]:$ke(l,p,i);case d.PrimitiveEntity:return i.ignoreBuiltInBaseEntities?[]:zke(l,p,i)}return[]}async function Y1(l={}){const p=new Set,i=Y.YieldTracker.from(l),r=new Set;for(const a of nx){const c=await ke(a,p,{ignoreBuiltInBaseEntities:!1,tracker:i});for(const e of c)r.add(e.id),await i.tick()}return r}function xo(l){return[...l.calledByEntry||[],...l.calledByError||[],...l.calledBySuccess||[]].filter(p=>p.type!==d.GenericReference)}async function rUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.ActionDescriptor)throw new Error("Entity must be an action descriptor to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const e of l.inputs)a.push(...await ke(e,p,c));return l.dataType&&a.push(...await ke(l.dataType,p,c)),l.error&&a.push(...await ke(l.error,p,c)),l.parent&&a.push(...await ke(l.parent,p,c)),a}async function nUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.ArgumentDeclaration)throw new Error("Entity must be an argument declaration to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};delete c.yieldEvery,l.dataType&&a.push(...await ke(l.dataType,p,c)),l.parent&&a.push(...await ke(l.parent,p,c)),l.defaultValue&&a.push(...await ke(l.defaultValue,p,c));for(const e of l.writesValues||[])a.push(...await ke(e,p,c));for(const e of l.implements||[])a.push(...await ke(e,p,c));return a}async function aUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.BreakStatement)throw new Error("Entity must be a break statement to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const f of l.outputs)a.push(...await ke(f,p,c));l.parent&&a.push(...await ke(l.parent,p,c)),l.throws&&a.push(...await ke(l.throws,p,c)),l.dataType&&a.push(...await ke(l.dataType,p,c)),l.readsValue&&a.push(...await ke(l.readsValue,p,c));const e=xo(l);for(const f of e)a.push(...await ke(f,p,c));return a}async function sUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.BuiltInBaseEntity)throw new Error("Entity must be a built-in base entity to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const e of l.properties||[])a.push(...await ke(e,p,c));for(const e of l.methods||[])a.push(...await ke(e,p,c));for(const e of l.abstractMethods||[])a.push(...await ke(e,p,c));return l.allPropertiesImplement&&a.push(...await ke(l.allPropertiesImplement,p,c)),l.additionalPropertiesDataType&&a.push(...await ke(l.additionalPropertiesDataType,p,c)),l.extends&&a.push(...await ke(l.extends,p,c)),a}async function lUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.Condition)throw new Error("Entity must be a condition to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};if(delete c.yieldEvery,l.andChildrenGroup&&Array.isArray(l.andChildrenGroup))for(const f of l.andChildrenGroup)a.push(...await ke(f,p,c));if(l.orChildrenGroup&&Array.isArray(l.orChildrenGroup))for(const f of l.orChildrenGroup)a.push(...await ke(f,p,c));for(const f of l.inputs)a.push(...await ke(f,p,c));for(const f of l.successCalls)a.push(...await ke(f,p,c));for(const f of l.errorCalls)a.push(...await ke(f,p,c));const e=xo(l);for(const f of e)a.push(...await ke(f,p,c));return l.parent&&a.push(...await ke(l.parent,p,c)),a}async function oUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.ContinueStatement)throw new Error("Entity must be a continue statement to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const f of l.outputs)a.push(...await ke(f,p,c));const e=xo(l);for(const f of e)a.push(...await ke(f,p,c));return l.parent&&a.push(...await ke(l.parent,p,c)),l.throws&&a.push(...await ke(l.throws,p,c)),l.dataType&&a.push(...await ke(l.dataType,p,c)),l.readsValue&&a.push(...await ke(l.readsValue,p,c)),a}async function dUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.DefinitionEntity)throw new Error("Entity must be a definition entity to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const e of l.properties)a.push(...await ke(e,p,c));for(const e of l.methods)a.push(...await ke(e,p,c));for(const e of l.abstractMethods)a.push(...await ke(e,p,c));for(const e of l.implements)a.push(...await ke(e,p,c));return l.extends&&a.push(...await ke(l.extends,p,c)),l.parent&&a.push(...await ke(l.parent,p,c)),l.additionalPropertiesDataType&&a.push(...await ke(l.additionalPropertiesDataType,p,c)),l.allPropertiesImplement&&a.push(...await ke(l.allPropertiesImplement,p,c)),a}async function uUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.DataType)throw new Error("Entity must be a data type to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};if(delete c.yieldEvery,l.parent&&a.push(...await ke(l.parent,p,c)),l.foreignKeyRef&&a.push(...await ke(l.foreignKeyRef,p,c)),l.entity&&a.push(...await ke(l.entity,p,c)),l.orChildrenGroup)for(const e of l.orChildrenGroup)a.push(...await ke(e,p,c));if(l.andChildrenGroup)for(const e of l.andChildrenGroup)a.push(...await ke(e,p,c));return a}async function pUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.FunctionCall)throw new Error("Entity must be a function call to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const f of l.inputs)a.push(...await ke(f,p,c));for(const f of l.outputs)a.push(...await ke(f,p,c));l.error&&a.push(...await ke(l.error,p,c));const e=xo(l);for(const f of e)a.push(...await ke(f,p,c));for(const f of l.successCalls)a.push(...await ke(f,p,c));for(const f of l.errorCalls)a.push(...await ke(f,p,c));for(const f of l.writesValues)a.push(...await ke(f,p,c));return l.parent&&a.push(...await ke(l.parent,p,c)),a}async function cUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.FunctionDeclaration)throw new Error("Entity must be a function declaration to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};delete c.yieldEvery,l.parent&&a.push(...await ke(l.parent,p,c)),l.implements&&a.push(...await ke(l.implements,p,c)),l.dataType&&a.push(...await ke(l.dataType,p,c));for(const e of l.inputs)a.push(...await ke(e,p,c));for(const e of l.calls)a.push(...await ke(e,p,c));return a}async function fUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.GlobalEvent)throw new Error("Entity must be a global event to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};delete c.yieldEvery,l.parent&&a.push(...await ke(l.parent,p,c)),l.implements&&a.push(...await ke(l.implements,p,c));for(const e of l.inputs)a.push(...await ke(e,p,c));for(const e of l.calls)a.push(...await ke(e,p,c));return a}async function yUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.InputMap)throw new Error("Entity must be an input map to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};return delete c.yieldEvery,l.parent&&a.push(...await ke(l.parent,p,c)),l.declaration&&a.push(...await ke(l.declaration,p,c)),l.readsValue&&a.push(...await ke(l.readsValue,p,c)),l.dataType&&a.push(...await ke(l.dataType,p,c)),l.defaultValue&&a.push(...await ke(l.defaultValue,p,c)),a}async function hUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.InstalledProject)throw new Error("Entity must be an installed project to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const e of l.functions)a.push(...await ke(e,p,c));for(const e of l.events)a.push(...await ke(e,p,c));return l.parent&&a.push(...await ke(l.parent,p,c)),a}async function mUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.InternalCall)throw new Error("Entity must be an internal call to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const f of l.inputs)a.push(...await ke(f,p,c));for(const f of l.outputs)a.push(...await ke(f,p,c));l.error&&a.push(...await ke(l.error,p,c));const e=xo(l);for(const f of e)a.push(...await ke(f,p,c));for(const f of l.successCalls)a.push(...await ke(f,p,c));for(const f of l.errorCalls)a.push(...await ke(f,p,c));for(const f of l.writesValues)a.push(...await ke(f,p,c));return l.parent&&a.push(...await ke(l.parent,p,c)),a}async function TUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.LiteralValue)throw new Error("Entity must be a literal value to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};if(delete c.yieldEvery,l.valueAsTypeSingle&&a.push(...await ke(l.valueAsTypeSingle,p,c)),l.valueAsTypeList&&Array.isArray(l.valueAsTypeList))for(const e of l.valueAsTypeList)a.push(...await ke(e,p,c));return l.parent&&a.push(...await ke(l.parent,p,c)),a}async function vUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.Loop)throw new Error("Entity must be a loop to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const f of l.inputs)a.push(...await ke(f,p,c));for(const f of l.outputs)a.push(...await ke(f,p,c));l.error&&a.push(...await ke(l.error,p,c));const e=xo(l);for(const f of e)a.push(...await ke(f,p,c));for(const f of l.successCalls)a.push(...await ke(f,p,c));for(const f of l.errorCalls)a.push(...await ke(f,p,c));for(const f of l.writesValues)a.push(...await ke(f,p,c));return l.parent&&a.push(...await ke(l.parent,p,c)),l.body&&a.push(...await ke(l.body,p,c)),l.dataType&&a.push(...await ke(l.dataType,p,c)),a}async function EUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.Operation)throw new Error("Entity must be an operation to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const f of l.inputs)a.push(...await ke(f,p,c));for(const f of l.outputs)a.push(...await ke(f,p,c));l.error&&a.push(...await ke(l.error,p,c));const e=xo(l);for(const f of e)a.push(...await ke(f,p,c));for(const f of l.successCalls)a.push(...await ke(f,p,c));for(const f of l.errorCalls)a.push(...await ke(f,p,c));for(const f of l.writesValues)a.push(...await ke(f,p,c));return l.parent&&a.push(...await ke(l.parent,p,c)),a}async function bUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.OutputMap)throw new Error("Entity must be an output map to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const e of l.writesValues)a.push(...await ke(e,p,c));return l.declaration&&a.push(...await ke(l.declaration,p,c)),l.dataType&&a.push(...await ke(l.dataType,p,c)),l.parent&&a.push(...await ke(l.parent,p,c)),a}async function AUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.PrimitiveEntity)throw new Error("Entity must be a primitive entity to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const e of l.properties)a.push(...await ke(e,p,c));for(const e of l.methods)a.push(...await ke(e,p,c));for(const e of l.abstractMethods)a.push(...await ke(e,p,c));return a}async function IUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.Project)throw new Error("Entity must be a project to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const e of l.entities)a.push(...await ke(e,p,c));for(const e of l.functions)a.push(...await ke(e,p,c));for(const e of l.events)a.push(...await ke(e,p,c));for(const e of l.projects)a.push(...await ke(e,p,c));for(const e of l.variableDeclarations)a.push(...await ke(e,p,c));for(const e of l.variableInstances)a.push(...await ke(e,p,c));for(const e of l.operations)a.push(...await ke(e,p,c));for(const e of l.conditions)a.push(...await ke(e,p,c));for(const e of l.functionCalls)a.push(...await ke(e,p,c));for(const e of l.projects)a.push(...await ke(e,p,c));for(const e of l.loops)a.push(...await ke(e,p,c));for(const e of l.searches)a.push(...await ke(e,p,c));return a}async function gUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.Property)throw new Error("Entity must be a property to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};return delete c.yieldEvery,l.defaultValue&&a.push(...await ke(l.defaultValue,p,c)),l.dataType&&a.push(...await ke(l.dataType,p,c)),l.parent&&a.push(...await ke(l.parent,p,c)),a}async function RUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.ReturnStatement)throw new Error("Entity must be a return statement to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const f of l.outputs)a.push(...await ke(f,p,c));for(const f of l.outputs)a.push(...await ke(f,p,c));l.throws&&a.push(...await ke(l.throws,p,c)),l.readsValue&&a.push(...await ke(l.readsValue,p,c)),l.dataType&&a.push(...await ke(l.dataType,p,c));const e=xo(l);for(const f of e)a.push(...await ke(f,p,c));return l.parent&&a.push(...await ke(l.parent,p,c)),a}async function DUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.Search)throw new Error("Entity must be a search to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const f of l.inputs)a.push(...await ke(f,p,c));for(const f of l.outputs)a.push(...await ke(f,p,c));l.error&&a.push(...await ke(l.error,p,c)),l.dataType&&a.push(...await ke(l.dataType,p,c));for(const f of l.inputsDeclarations)a.push(...await ke(f,p,c));const e=xo(l);for(const f of e)a.push(...await ke(f,p,c));for(const f of l.successCalls)a.push(...await ke(f,p,c));for(const f of l.errorCalls)a.push(...await ke(f,p,c));for(const f of l.writesValues)a.push(...await ke(f,p,c));return l.parent&&a.push(...await ke(l.parent,p,c)),a}async function wUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.ValueDescriptor)throw new Error("Entity must be a value descriptor to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};return delete c.yieldEvery,l.defaultValue&&a.push(...await ke(l.defaultValue,p,c)),l.dataType&&a.push(...await ke(l.dataType,p,c)),l.parent&&a.push(...await ke(l.parent,p,c)),a}async function CUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.VariableDeclaration)throw new Error("Entity must be a variable declaration to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const f of l.inputs)a.push(...await ke(f,p,c));for(const f of l.outputs)a.push(...await ke(f,p,c));l.error&&a.push(...await ke(l.error,p,c)),l.dataType&&a.push(...await ke(l.dataType,p,c)),l.readsValue&&a.push(...await ke(l.readsValue,p,c)),l.defaultValue&&a.push(...await ke(l.defaultValue,p,c));const e=xo(l);for(const f of e)a.push(...await ke(f,p,c));for(const f of l.successCalls)a.push(...await ke(f,p,c));for(const f of l.errorCalls)a.push(...await ke(f,p,c));for(const f of l.writesValues)a.push(...await ke(f,p,c));for(const f of l.internalCalls)a.push(...await ke(f,p,c));return l.parent&&a.push(...await ke(l.parent,p,c)),a}async function OUe(l,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(l.id))return[];if(p.add(l.id),l.type!==d.VariableInstance)throw new Error("Entity must be a variable instance to be flattened");const r=Y.YieldTracker.from(i),a=[l];await r.tick();const c={...i,tracker:r};delete c.yieldEvery;for(const f of l.inputs)a.push(...await ke(f,p,c));for(const f of l.outputs)a.push(...await ke(f,p,c));l.error&&a.push(...await ke(l.error,p,c)),l.readsValue&&a.push(...await ke(l.readsValue,p,c)),l.defaultValue&&a.push(...await ke(l.defaultValue,p,c));const e=xo(l);for(const f of e)a.push(...await ke(f,p,c));for(const f of l.successCalls)a.push(...await ke(f,p,c));for(const f of l.errorCalls)a.push(...await ke(f,p,c));for(const f of l.writesValues)a.push(...await ke(f,p,c));for(const f of l.internalCalls)a.push(...await ke(f,p,c));return l.parent&&a.push(...await ke(l.parent,p,c)),l.declaration&&a.push(...await ke(l.declaration,p,c)),a}async function ke(l,p=new Set,i={ignoreBuiltInBaseEntities:!1,yieldEvery:100}){const r={...i,ignoreBuiltInBaseEntities:i.ignoreBuiltInBaseEntities??!1};if(!l)throw new Error("Entity must be defined to be flattened");if(l.type===d.GenericReference)return[];const a=Y.YieldTracker.from(r);r.tracker=a,r.yieldEvery!==void 0&&delete r.yieldEvery;const c=r.ignoreBuiltInBaseEntities?r.diggestedBuiltInBaseEntitiesIds??new Set(await Y1(r)):new Set;if(r.diggestedBuiltInBaseEntitiesIds=c,r.ignoreBuiltInBaseEntities&&(oa.includes(l.type)||c.has(l.id)))return[];if(p.has(l.id))return[];switch(l.type){case d.FunctionCall:return pUe(l,p,r);case d.Operation:return EUe(l,p,r);case d.Condition:return lUe(l,p,r);case d.Loop:return vUe(l,p,r);case d.Search:return DUe(l,p,r);case d.GlobalEvent:return fUe(l,p,r);case d.ReturnStatement:return RUe(l,p,r);case d.ContinueStatement:return oUe(l,p,r);case d.BreakStatement:return aUe(l,p,r);case d.VariableDeclaration:return CUe(l,p,r);case d.DefinitionEntity:return dUe(l,p,r);case d.FunctionDeclaration:return cUe(l,p,r);case d.Project:return IUe(l,p,r);case d.ActionDescriptor:return rUe(l,p,r);case d.ArgumentDeclaration:return nUe(l,p,r);case d.ValueDescriptor:return wUe(l,p,r);case d.InputMap:return yUe(l,p,r);case d.OutputMap:return bUe(l,p,r);case d.DataType:return uUe(l,p,r);case d.InstalledProject:return hUe(l,p,r);case d.InternalCall:return mUe(l,p,r);case d.LiteralValue:return TUe(l,p,r);case d.Property:return gUe(l,p,r);case d.VariableInstance:return OUe(l,p,r);case d.BuiltInBaseEntity:return r.ignoreBuiltInBaseEntities?[]:sUe(l,p,r);case d.PrimitiveEntity:return r.ignoreBuiltInBaseEntities?[]:AUe(l,p,r)}return[]}function _Ue(l){return l==null||l===""}function J_i(l){return l===null}function Ln(l){return l!=null&&l.valueAsType?!1:_Ue(l==null?void 0:l.value)}function Xd(l){return l?l.valueAsType===null&&l.value===null:!1}function VUe(l,p){if(l===p||!l&&!p)return!0;if(!l||!p||l.name===fe.EntityTemplate&&p.name!==fe.EntityTemplate||p.name===fe.EntityTemplate&&l.name!==fe.EntityTemplate)return!1;if(l.name===fe.ActionDescriptor&&p.name!==fe.ActionDescriptor||p.name===fe.ActionDescriptor&&l.name!==fe.ActionDescriptor)return!1;if(l.valueAsTypeSingle&&!p.valueAsTypeSingle||p.valueAsTypeSingle&&!l.valueAsTypeSingle)return!1;if(l.valueAsTypeList&&!p.valueAsTypeList||p.valueAsTypeList&&!l.valueAsTypeList)return!1;if(l.valueAsTypeSingle&&p.valueAsTypeSingle){if(l.valueAsTypeSingle.id!==p.valueAsTypeSingle.id)return!1}else if(l.valueAsTypeList&&p.valueAsTypeList){if(l.valueAsTypeList.length!==p.valueAsTypeList.length)return!1;for(let i=0;i<l.valueAsTypeList.length;i++)if(l.valueAsTypeList[i].id!==p.valueAsTypeList[i].id)return!1}else if(!l.valueAsType&&!p.valueAsType&&l.value!==p.value)return!1;return!0}function PUe(l,p,i){if(!i)throw new Error("[checkIsRowTransformerUpToDate] 'lastPublishedEntityVersion' argument is required");if(!p)throw new Error("[checkIsRowTransformerUpToDate] 'entity' argument is required");if(!l)throw new Error("[checkIsRowTransformerUpToDate] 'newestOpenRowTransformer' argument is required");let r=!0;const a=l.methods.find(c=>{var e;return((e=c.implements)==null?void 0:e.id)===ne["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.methods.up.id});if(a?(on(i).forEach(c=>{const e=a.inputs.find(f=>f.name===c.name);e&&oi(e.getDataType(null),c.getDataType(null)).compatible||(r=!1)}),a.returnStatements.forEach(c=>{!c.dataType||!c.dataType.entity||c.dataType.entity.type!==d.DefinitionEntity?r=!1:FT(c.dataType.entity,p)||(r=!1)})):r=!1,r===null||r){const c=l.methods.find(e=>{var f;return((f=e.implements)==null?void 0:f.id)===ne["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.methods.down.id});c?(on(p).forEach(e=>{const f=c.inputs.find(h=>h.name===e.name);f&&oi(f.getDataType(null),e.getDataType(null)).compatible||(r=!1)}),c.returnStatements.forEach(e=>{!e.dataType||!e.dataType.entity||e.dataType.entity.type!==d.DefinitionEntity?r=!1:FT(e.dataType.entity,i)||(r=!1)})):r=!1}return{isPreexistingRowTransformerUpToDate:r}}function NUe(l,p,i){const r={changesSinceLastPublication:!1,rowTransformerNeeded:!1,newRowTransformerNeeded:!1,newestOpenRowTransformer:null,newRequiredProperties:[],newNonRequiredProperties:[],deletedProperties:[],lastPublishedEntityVersion:null,updatedEntityVersion:i,propChanges:new Map,isPreexistingRowTransformerUpToDate:null,extendedEntities:[]},c=l.entities.filter(M=>{var re;if(M.id===i.id)return!1;let G=!1,q=M;for(;q;){if(((re=q.extends)==null?void 0:re.id)===i.id){G=!0;break}if(q.extends&&q.extends.type===d.DefinitionEntity)q=q.extends;else break}return G}).map(M=>NUe(l,p,M));if(!p)return{...r,changesSinceLastPublication:!0,extendedEntities:c};const e=p.get(i.id);if(!e)return{...r,changesSinceLastPublication:!0,extendedEntities:c};const f=p.entities.filter(M=>ai(M,Ie.SQL_ROW_TRANSFORMER)),m=l.entities.filter(M=>{var ee;if(!ai(M,Ie.SQL_ROW_TRANSFORMER)||f.find(de=>de.id===M.id))return!1;const q=M.properties.find(de=>!!de.implements.find(ie=>ne["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.properties.definition.id===ie.id));if(!q)return!1;const re=(ee=q.defaultValue)==null?void 0:ee.valueAsType;return re?re.id===i.id:!1}).sort((M,G)=>B(M.createdAt).isAfter(B(G.createdAt))?-1:1)[0]||null,E=new Map;let b=!1;const A=on(i).filter(M=>on(e).find(re=>re.id===M.id)?!1:!ns(M.getDataType(null))),_=on(i).filter(M=>on(e).find(re=>re.id===M.id)?!1:!!ns(M.getDataType(null))),N=on(e).filter(M=>!on(i).find(q=>q.id===M.id));on(i).filter(M=>{var z,X,ce,oe,me,ve,we,Re,xe,je,Se;const G=on(e).find(et=>et.id===M.id);let q=!1;if(!G)return!1;const re=Ma(M.dataType,!0,`[resolveSQLMigrationsDiffs] Unsupported data-type structure on current property '${M.name}' (${M.id}). 'andChildrenGroup' with more than one child is not supported for SQL column properties.`),ee=Ma(G.dataType,!0,`[resolveSQLMigrationsDiffs] Unsupported data-type structure on last published property '${M.name}' (${M.id}). 'andChildrenGroup' with more than one child is not supported for SQL column properties.`),de=vI(re,!0,`[resolveSQLMigrationsDiffs] Unsupported data-type structure on current property '${M.name}' (${M.id}). 'orChildrenGroup' with multiple non-null children is not supported for SQL column properties.`),ie=vI(ee,!0,`[resolveSQLMigrationsDiffs] Unsupported data-type structure on last published property '${M.name}' (${M.id}). 'orChildrenGroup' with multiple non-null children is not supported for SQL column properties.`);if(((z=de==null?void 0:de.foreignKeyRef)==null?void 0:z.id)!==((X=ie==null?void 0:ie.foreignKeyRef)==null?void 0:X.id)){const et=de==null?void 0:de.foreignKeyRef,Ze=ie==null?void 0:ie.foreignKeyRef;E.set(M.id,{...E.get(M.id)||{},newForeignKeyRef:et||void 0,oldForeignKeyRef:Ze||void 0,property:M,oldProperty:G}),q=!0,b=!0}else((ce=de==null?void 0:de.entity)==null?void 0:ce.id)!==((oe=ie==null?void 0:ie.entity)==null?void 0:oe.id)&&(((me=de==null?void 0:de.entity)==null?void 0:me.id)===ne["primitive-entity"].string.id||((ve=ie==null?void 0:ie.entity)==null?void 0:ve.id)===ne["primitive-entity"].date.id&&((we=de==null?void 0:de.entity)==null?void 0:we.id)===ne["primitive-entity"].number.id?E.set(M.id,{...E.get(M.id)||{},castableDataTypeEntity:{fromId:((Re=ie==null?void 0:ie.entity)==null?void 0:Re.id)||"",toId:((xe=de==null?void 0:de.entity)==null?void 0:xe.id)||""},property:M,oldProperty:G}):(E.set(M.id,{...E.get(M.id)||{property:M},nonCastableDataTypeEntity:{fromId:((je=ie==null?void 0:ie.entity)==null?void 0:je.id)||"",toId:((Se=de==null?void 0:de.entity)==null?void 0:Se.id)||""},property:M,oldProperty:G}),b=!0),q=!0);M.name!==(G==null?void 0:G.name)&&(E.set(M.id,{...E.get(M.id)||{},nameChange:{from:(G==null?void 0:G.name)||"",to:M.name},property:M,oldProperty:G}),q=!0);const se=ns(G.getDataType(null)),ue=ns(M.getDataType(null));return ue!==se&&(E.set(M.id,{...E.get(M.id)||{},requiredChange:{from:!se,to:!ue},property:M,oldProperty:G}),ue||(b=!0),q=!0),q}),A.length>0&&(b=!0);let V=null;m&&b&&(V=PUe(m,i,e).isPreexistingRowTransformerUpToDate);const j=i.name!==e.name?{from:e.name,to:i.name}:void 0;return{...r,changesSinceLastPublication:E.size>0||!!N.length||!!A.length||!!_.length||b,rowTransformerNeeded:b,newestOpenRowTransformer:m,nameChange:j,newRequiredProperties:A,newNonRequiredProperties:_,deletedProperties:N,lastPublishedEntityVersion:e,propChanges:E,newRowTransformerNeeded:b&&!m,isPreexistingRowTransformerUpToDate:V,extendedEntities:c}}function lL(l,p,i,r,a){if(!l)throw new Error("[addDifferencesToRowTransformer] 'project' argument is required");if(!p)throw new Error("[addDifferencesToRowTransformer] 'transformer' argument is required");if(!i)throw new Error("[addDifferencesToRowTransformer] 'newEntityState' argument is required");if(!r)throw new Error("[addDifferencesToRowTransformer] 'oldEntityState' argument is required");const c=on(i),e=on(r);p.afterAllChildrenInitialized(a);const f=p.methods.find(m=>{var E;return((E=m.implements)==null?void 0:E.id)===ne["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.methods.up.id}),h=p.methods.find(m=>{var E;return((E=m.implements)==null?void 0:E.id)===ne["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.methods.down.id});if(!f)throw new Error("[addDifferencesToRowTransformer] The 'up' transformer trigger is missing from the parent");if(!h)throw new Error("[addDifferencesToRowTransformer] The 'down' transformer trigger is missing from the parent");e.forEach(m=>{var j;const E=f.inputs.find(M=>M.name===m.name),b=m.getDataType(null);let A=E,_,N=!1,V=!1;if(E)A.editable=!0;else{const M=Ga.new(a);M.parent=f.toReference(),M.name=m.name,M.index=m.index,M.implements=[...m.implements.map(q=>q.toJSON())];const G=Ae(M,l);G.hydrateAncestors(),G.addSelfToProject(a),a.add(G,W.Added),G.initChildren(a),N=!0,A=G}if(!A.dataType||A.dataType&&l.diggestedBuiltInBaseEntitiesIds.has(A.dataType.id)){const M=yr.new(a);M.parent=A.toReference();const G=Ae(M,l);G.hydrateAncestors(),G.addSelfToProject(a),a.add(G,W.Added),G.initChildren(a),V=!0,_=G}else _=A.dataType,_.editable=!0;b&&_.merge(m.getDataType(null),a),_.metaSync({editable:!1,deletable:!1},a),A.metaSync({editable:!1,deletable:!1},a),V&&(a||(j=A.dataType)==null||j.captureVersion()),N&&(a||A.captureVersion())}),[...f.inputs].forEach(m=>{e.find(b=>b.name===m.name)||(m.editable=!0,m.remove({ignoreUpstream:!1},a),m.editable=!1)}),[...f.returnStatements].forEach(m=>{var b,A,_;let E=!1;if(!m.dataType||m.dataType&&l.diggestedBuiltInBaseEntitiesIds.has(m.dataType.id)){const N=yr.new(a);N.entity=i.toReference(),N.parent=m.toReference();const V=Ae(N,l);V.hydrateAncestors(),a.add(V,W.Added),V.addSelfToProject(a),V.initChildren(a),E=!0}(!((b=m.dataType)!=null&&b.entity)||m.dataType.entity.type!==d.DefinitionEntity||m.dataType.entity.parent.id!==m.dataType.id)&&(i.clone(a,m.dataType),E=!0),lx((A=m.dataType)==null?void 0:A.entity,i,a),m.afterAllChildrenInitialized(a),m.outputs.forEach(N=>{const V=f.inputs.find(j=>le(N,l)===le(j,l));N.setValueWriter(V,a),V==null||V.addValueReader(N,a)}),E&&(a||(_=m.dataType)==null||_.captureVersion())}),c.forEach(m=>{var M,G;let E=!1,b=!1;const A=(M=m.knownVersions)==null?void 0:M.get(m.previousVersion),_=h.inputs.find(q=>q.name===m.name||!!A&&A.name===q.name),N=m.getDataType(null);let V=_,j;if(_)V.editable=!0,V.metaSync({name:m.name,codeName:m.codeName,description:m.description},a);else{const q=Ga.new(a);q.parent=h.toReference(),q.name=m.name,q.codeName=m.codeName,q.description=m.description,q.index=m.index,q.implements=[m.toJSON(),...m.implements.map(ee=>ee.toJSON())];const re=Ae(q,l);re.hydrateAncestors(),re.addSelfToProject(a),a.add(re,W.Added),re.initChildren(a),E=!0,V=re}if(V.dataType)j=V.dataType,j.editable=!0,j.merge(V.dataType,a);else{const q=yr.new(a);q.parent=V.toReference();const re=Ae(q,l);re.hydrateAncestors(),re.addSelfToProject(a),a.add(re,W.Added),re.initChildren(a),b=!0,j=re}N&&j.merge(m.getDataType(null),a),j.metaSync({editable:!1,deletable:!1},a),V.metaSync({editable:!1,deletable:!1},a),b&&(a||(G=V.dataType)==null||G.captureVersion()),E&&(a||V.captureVersion())}),[...h.inputs].forEach(m=>{c.find(b=>{var _;if(b.name===m.name)return!0;const A=(_=b.knownVersions)==null?void 0:_.get(b.previousVersion);if(A&&A.name===m.name)return!0})||(m.editable=!0,m.remove({ignoreUpstream:!1},a),m.editable=!1)}),[...h.returnStatements].forEach(m=>{var A,_,N,V,j;let E=!1;if(!m.dataType||m.dataType&&l.diggestedBuiltInBaseEntitiesIds.has(m.dataType.id)){const M=yr.new(a);M.parent=m.toReference();const G=Ae(M,l);G.hydrateAncestors(),G.addSelfToProject(a),a.add(G,W.Added),G.initChildren(a),E=!0}let b=(A=m.dataType)==null?void 0:A.entity;(!b||(b==null?void 0:b.id)===ne["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.id)&&(Y.Logger.log("Cloning old entity state into new project with data-ype as parent: ",(_=m.dataType)==null?void 0:_.id," from new project: ",((N=m.dataType)==null?void 0:N.project.version)===l.version&&((V=m.dataType)==null?void 0:V.project.entities.length)===3),b=r.clone(a,m.dataType)),m.dataType.setEntity(b,a),m.afterAllChildrenInitialized(a),m.outputs.forEach(M=>{const G=h.inputs.find(q=>le(M,l)===le(q,l));M.setValueWriter(G,a),G==null||G.addValueReader(M,a)}),E&&(a||(j=m.dataType)==null||j.captureVersion())})}function xUe(l,p,i,r,a={}){var M;const c=l.getBuiltIn(Ie.SQL_ROW_TRANSFORMER),e=hh(le(p,l)+" row transformer",l.entities),f=c.implement(e,r),h=f.ownDeclaredProperties.find(G=>{var q;return(q=G.implements)==null?void 0:q.find(re=>re.id===ne["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.properties.definition.id)}),m=f.methods.find(G=>{var q;return((q=G.implements)==null?void 0:q.id)===ne["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.methods.up.id}),E=f.methods.find(G=>{var q;return((q=G.implements)==null?void 0:q.id)===ne["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.methods.down.id});if(!h||!m||!E)throw new Error("Cannot find definition property on the new row transformer entity");if(h.defaultValue)h.defaultValue.setValueAsTypeSingle(p,r);else{const G=Vr.new(r);G.name=fe.EntityTemplate,G.valueAsTypeSingle=p.toJSON(),G.parent=h.toReference();const q=Ae(G,l);q.hydrateAncestors(),q.addSelfToProject(r),r.add(q,W.Added),q.initChildren(r),r||q.captureVersion()}lL(l,f,p,i,r),Y.Logger.log("BEFORE - changeSet.listAdded",r.listAdded.map(G=>{var re,ee,de,ie,se,ue,z;const q=l.get(G.id);return q?le(q,l):G.type===d.InputMap?"(not found) "+G.type+" "+G.id+" - declaration: "+((re=G.declaration)==null?void 0:re.type)+" "+((ee=G.declaration)==null?void 0:ee.id)+' "'+((de=G.declaration)==null?void 0:de.name)+`"
540
540
  parent: `+((se=(ie=G.parent)==null?void 0:ie.parent)==null?void 0:se.id)+" - "+((z=(ue=G.parent)==null?void 0:ue.parent)==null?void 0:z.name):"(not found) "+G.type+" "+G.id})),Y.Logger.log("AFTER - changeSet.listAdded",r.listAdded.map(G=>{var re,ee,de,ie,se,ue,z;const q=l.get(G.id);return q?q.type+' "'+le(q,l)+'" ('+q.id+")":G.type===d.InputMap?"(not found) "+G.type+" ("+G.id+") - declaration: "+((re=G.declaration)==null?void 0:re.type)+" ("+((ee=G.declaration)==null?void 0:ee.id)+') "'+((de=G.declaration)==null?void 0:de.name)+`"
541
541
  parent: "`+((se=(ie=G.parent)==null?void 0:ie.parent)==null?void 0:se.name)+'" ('+((z=(ue=G.parent)==null?void 0:ue.parent)==null?void 0:z.id)+")":"(not found) "+G.type+" "+G.id})),Y.Logger.log("-----------------"),Y.Logger.log("Old properties: ",on(i).map(G=>G.name+" ("+G.id+")")),Y.Logger.log("New properties: ",on(p).map(G=>G.name+" ("+G.id+")"));const b=f.methods.find(G=>{var q;return((q=G.implements)==null?void 0:q.id)===ne["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.methods.up.id}),A=f.methods.find(G=>{var q;return((q=G.implements)==null?void 0:q.id)===ne["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.methods.down.id});Y.Logger.log(`
542
542
  Up inputs: `,b==null?void 0:b.inputs.map(G=>G.name+" ("+G.id+")")),Y.Logger.log("Up method return statements:",b==null?void 0:b.returnStatements[0].outputs.map(G=>le(G,l)+" ("+G.id+")")),Y.Logger.log(`