@elyx-code/project-logic-tree 0.0.6739 → 0.0.6741
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 +7 -7
- package/dist/index.js +61 -15
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -41,7 +41,7 @@ If an entity is called by another, they must be in the same scope, which means t
|
|
|
41
41
|
You shouldn't have to manually update a 'parent' property. The equivalent result is to change its callers, the value writters of its inputs, or the value readers of its outputs.`})),{errors:n,modifiedData:i}}subscribeDependents(i){return i.forEach(n=>{this.detachedDependents[n.entity.id]||(this.detachedDependents[n.entity.id]=n)}),this}unsubscribeDependents(i){return i.forEach(n=>{this.detachedDependents[n.entity.id]&&delete this.detachedDependents[n.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"sync-dependents"))){const n=[],s=[],c=[],e=[];return Object.values(this.detachedDependents).forEach(y=>{const m=y.entity.afterAllChildrenInitialized(i);n.push(...m.updated),s.push(...m.added),c.push(...m.removed),e.push(...m.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}onDetachedDependencyRemoved(i,n,s){const c=[],e=[],y=[],m=[];if(n==="parent"){const{updated:v,added:E,removed:b}=this.remove({ignoreUpstream:!1},s);c.push(...v),e.push(...E),y.push(...b)}return{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:this}}onDetachedDependencyRestored(i,n,s){const c=[],e=[],y=[],m=[];if(n==="parent"){const{updated:v,added:E,removed:b}=this.restore({},s);c.push(...v),e.push(...E),y.push(...b)}return{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:this}}unsubscribeFromDependencies(){var i;return(i=this.parent)==null||i.unsubscribeDependents([{entity:this,field:"parent"}]),this}subscribeToDependencies(){var i;return(i=this.parent)==null||i.subscribeDependents([{entity:this,field:"parent"}]),this}increaseVersion(i){if(i&&!M(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&M(i).isSame(M(this.createdAt))?this:(this.previousVersion=this.version,this.version=x.UUID.uuid(),this.createdAt=M(i).toISOString()||M().toISOString(),this)}captureVersion(){var n;const i=((n=this.knownVersions)==null?void 0:n.get(this.version))||new pi(this,this.project);return i.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map([[this.version,i]]),i.inputs=[...this.inputs],i.outputs=[...this.outputs],i.error=this.error,i.successCalls=[...this.successCalls],i.errorCalls=[...this.errorCalls],i.calledBySuccess=[...this.calledBySuccess],i.calledByError=[...this.calledByError],i.calledByEntry=[...this.calledByEntry],i.declaration=this.declaration,i.parent=this.parent,this}recursiveCaptureUpstreamVersions(i){const n=[],s=[],c=[],e=[];if(this.parent){this.parent.increaseVersion(i);const y=this.parent.recursiveCaptureUpstreamVersions(i);n.push(this.parent,...y.updated),s.push(...y.added),c.push(...y.removed)}return{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}async restoreVersion(i){var m;const n=[],s=[],c=[],e=[];if(this.version===i)return{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this};if(!this.knownVersions){const v=new Map;for(const[E,b]of this.knownVersions||new Map){if(v.set(E,b),b.activeVersion=!1,b.knownVersions)for(const[w,V]of b.knownVersions)v.set(w,V);b.knownVersions=null}}let y=(m=this.knownVersions)==null?void 0:m.get(i);if(!y){const v=await this.APILoadVersion({},i);if(!v)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);y=new pi(v,this.project)}return this.metaSync(y.toShallowJSON(),null),this.previousVersion=y.previousVersion,this.version=y.version,this.createdAt=y.createdAt,this.author=y.author,this.deleted=y.deleted,this.inputs=y.inputs,this.outputs=y.outputs,this.error=y.error,this.successCalls=y.successCalls,this.errorCalls=y.errorCalls,this.calledBySuccess=y.calledBySuccess,this.calledByError=y.calledByError,this.calledByEntry=y.calledByEntry,this.declaration=y.declaration,this.parent=y.parent,{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}updateWithShallowTransfer(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.UpdateWithShallowTransfer))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[updateWithShallowTransfer] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),this;if(this.metaSync(i,n),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 s=ne(i.parent),c=this.project.get(s),e=this.parent;if(e&&e.id!==(c==null?void 0:c.id)&&this.removeFromParent(n),c)this.setParent(c,n),this.addSelfToProject(n);else throw n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${s}' that isn't found in the project`)}else throw n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(i.declaration){const s=ne(i.declaration),c=this.project.get(s);c&&this.setDeclaration(c)}return i.calledByEntry.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addEntryCaller(e,n),e.addCall(this,n))}),[...this.calledByEntry].forEach(s=>{i.calledByEntry.find(e=>ne(e)===s.id)||(this.removeCaller(s,n),s.removeCall(this,n))}),i.calledBySuccess.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addSuccessCaller(e,n),e.addSuccessCall(this,n))}),[...this.calledBySuccess].forEach(s=>{i.calledBySuccess.find(e=>ne(e)===s.id)||(this.removeCaller(s,n),s.removeCall(this,n))}),i.calledByError.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addErrorCaller(e,n),e.addErrorCall(this,n))}),[...this.calledByError].forEach(s=>{i.calledByError.find(e=>ne(e)===s.id)||(this.removeCaller(s,n),s.removeCall(this,n))}),i.outputs.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addOutput(e,n),e.setParent(this,n))}),[...this.outputs].forEach(s=>{i.outputs.find(e=>ne(e)===s.id)||(this.removeOutput(s,n),s.removeFromParent(n))}),i.inputs.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addInput(e,n),e.setParent(this,n))}),[...this.inputs].forEach(s=>{i.inputs.find(e=>ne(e)===s.id)||(this.removeInput(s,n),s.removeFromParent(n))}),i.writesValues.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addValueReader(e,n),e.setValueWriter(this,n))}),[...this.writesValues].forEach(s=>{i.writesValues.find(e=>ne(e)===s.id)||(this.removeValueReader(s,n),s.setValueWriter(null,n))}),this.captureVersion(),this.subscribeToDependencies(),n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),this}hydrateAncestors(){const i=[],n=[],s=[],c=[];if(this.initialData.parent){const e=ne(this.initialData.parent),y=this.project.get(e);if(y)this.setParent(y,null),i.push(y);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.declaration){const e=ne(this.initialData.declaration),y=this.project.get(e);y&&(this.setDeclaration(y),i.push(y))}return this.initialData.calledByEntry.forEach(e=>{const y=ne(e),m=this.project.get(y);m&&this.addEntryCaller(m,null)}),this.initialData.calledBySuccess.forEach(e=>{const y=ne(e),m=this.project.get(y);m&&this.addSuccessCaller(m,null)}),this.initialData.calledByError.forEach(e=>{const y=ne(e),m=this.project.get(y);m&&this.addErrorCaller(m,null)}),{updated:D(i),added:D(n),removed:D(s),affected:D(c),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AfterAllChildrenInitialized))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[afterAllChildrenInitialized] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.AfterAllChildrenInitialized,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];this.initialized=!0;const{updated:y,added:m,removed:v}=this.syncInputs(i),{updated:E,added:b,removed:w}=this.syncOutputs(i),{updated:V,added:$,removed:L}=this.declaration.syncOperationInstance(this,i);return n.push(...y,...E,...V),s.push(...m,...b,...V),c.push(...v,...w,...V),this.inputs.sort((k,K)=>{var S,Y;return(k.index??((S=k.declaration)==null?void 0:S.index))-(K.index??((Y=K.declaration)==null?void 0:Y.index))}),this.outputs.sort((k,K)=>{var S,Y;return(k.index??((S=k.declaration)==null?void 0:S.index))-(K.index??((Y=K.declaration)==null?void 0:Y.index))}),this.captureVersion(),i==null||i.attemptAutoclose(_.AfterAllChildrenInitialized,this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}addSelfToProject(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"add-self-to-project"))){const n=[this],s=[],c=[],e=[];return this.parent===this.project&&this.project.addOperation(this),this.successCalls.forEach(y=>{y.addSuccessCaller(this,i),n.push(y)}),this.errorCalls.forEach(y=>{y.addErrorCaller(this,i),n.push(y)}),this.calledBySuccess.forEach(y=>{y.addSuccessCall(this,i),n.push(y)}),this.calledByError.forEach(y=>{y.addErrorCall(this,i),n.push(y)}),this.calledByEntry.forEach(y=>{y.addCall(this,i),n.push(y)}),this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}removeInput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveInput))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[removeInput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.RemoveInput,this.id),this;const s=this.inputs.findIndex(c=>c.id===i.id);return s>-1&&(this.inputs.splice(s,1),n&&(n==null||n.add(this,H.Affected))),n==null||n.attemptAutoclose(_.RemoveInput,this.id),this}addInput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddInput))){return this.checkCanEdit(this,n)?this.inputs.includes(i)?(n==null||n.attemptAutoclose(_.AddInput,this.id),this):(this.inputs.push(i),n==null||n.add(this,H.Affected),n==null||n.attemptAutoclose(_.AddInput,this.id),this):(J.Logger.warn(`[addInput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.AddInput,this.id),this)}addOutput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"add-output"))){return this.checkCanEdit(this,n)?this.outputs.includes(i)?(n==null||n.attemptAutoclose("add-output",this.id),this):(this.outputs.push(i),n==null||n.add(this,H.Affected),n==null||n.attemptAutoclose("add-output",this.id),this):(J.Logger.warn(`[addOutput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("add-output",this.id),this)}removeOutput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-output"))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[removeOutput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("remove-output",this.id),this;const s=this.outputs.findIndex(c=>c.id===i.id);return s>-1&&(this.outputs.splice(s,1),n&&(n==null||n.add(this,H.Affected))),n==null||n.attemptAutoclose("remove-output",this.id),this}addValueReader(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddValueReader))){var e,y,m;if(!this.checkCanEditFromScopeOwnerWithSideEffects(this,_.AddValueReader,n))return this;const s=i.type===d.InputMap&&i.parent.type===d.VariableInstance&&((e=i.declaration)==null?void 0:e.type)===d.Property&&((y=i.declaration)==null?void 0:y.constant),c=i.type===d.VariableInstance&&((m=i.declaration)==null?void 0:m.constant);return(s||c)&&i?(n==null||n.event({id:`${_.SetValueWriter}-${this.id}--${this.id}`,action:_.SetValueWriter,owner:i,counterpart:this,errorReason:Ii.ValueReadingOverridesConstantVariable,rootAction:!1}),n==null||n.attemptAutoclose(_.AddValueReader,this.id),this):this.writesValues.includes(i)?(n==null||n.attemptAutoclose(_.AddValueReader,this.id),this):(this.writesValues.push(i),n==null||n.add(this,H.Affected),this)}removeValueReader(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveValueReader))){return this.checkCanEditFromScopeOwnerWithSideEffects(this,_.RemoveValueReader,n)?this.writesValues.includes(i)?(this.writesValues=this.writesValues.filter(s=>s.id!==i.id),n==null||n.add(this,H.Affected),this):(n==null||n.attemptAutoclose(_.RemoveValueReader,this.id),this):this}addSuccessCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddSuccessCaller)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddSuccessCaller,n)?(this.calledBySuccess.find(c=>c.id===i.id)||(this.calledBySuccess.push(i),n==null||n.add(this,H.Updated),s&&mt(this,n)),n==null||n.attemptAutoclose(_.AddSuccessCaller,this.id),this):this}addErrorCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddErrorCaller)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddErrorCaller,n)?(this.calledByError.find(c=>c.id===i.id)||(this.calledByError.push(i),n==null||n.add(this,H.Updated),s&&mt(this,n)),n==null||n.attemptAutoclose(_.AddErrorCaller,this.id),this):this}addEntryCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddEntryCaller)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddEntryCaller,n)?(this.calledByEntry.find(c=>c.id===i.id)||(this.calledByEntry.push(i),n==null||n.add(this,H.Updated),s&&mt(this,n)),n==null||n.attemptAutoclose(_.AddEntryCaller,this.id),this):this}addErrorCall(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddErrorCall)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddErrorCall,n)?(this.errorCalls.find(c=>c.id===i.id)||(this.errorCalls.push(i),s&&mt(this,n),n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose(_.AddErrorCall,this.id),this):this}addSuccessCall(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddSuccessCall)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddSuccessCall,n)?(this.successCalls.find(c=>c.id===i.id)||(this.successCalls.push(i),s&&mt(this,n),n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose(_.AddSuccessCall,this.id),this):this}removeCall(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveCall)),s=!1){if(!this.checkCanEditWithCounterpartAndSideEffects(this,i,_.RemoveCall,n))return this;const c=this.successCalls.findIndex(y=>y.id===i.id);c>-1&&(this.successCalls.splice(c,1),n==null||n.add(this,H.Affected));const e=this.errorCalls.findIndex(y=>y.id===i.id);return e>-1&&(this.errorCalls.splice(e,1),n==null||n.add(this,H.Affected)),s&&mt(this,n),n==null||n.attemptAutoclose(_.RemoveCall,this.id),this}removeCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-caller")),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.RemoveCaller,n)?(this.calledBySuccess=this.calledBySuccess.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),this.calledByError=this.calledByError.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),this.calledByEntry=this.calledByEntry.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),s&&mt(this,n),n==null||n.attemptAutoclose(_.RemoveCaller,this.id),this):this}setError(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetErrorEntity))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setError] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.SetErrorEntity,this.id),this;const s=this.error;return(s==null?void 0:s.id)!==(i==null?void 0:i.id)&&(s==null||s.remove({ignoreUpstream:!0},n),this.error=i,this.subscribeToDependencies(),n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose(_.SetErrorEntity,this.id),this}setParent(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetParent))){var s;return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.SetParent,n)?(((s=this.parent)==null?void 0:s.id)!==(i==null?void 0:i.id)&&(this.parent=i,n&&(n==null||n.add(this,H.Updated))),n==null||n.attemptAutoclose(_.SetParent,this.id),this):this}setDeclaration(i){return this.declaration=i,this}initChildren(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"init-children"))){return this.initialized||this.startedInitialization?this:(this.startedInitialization=!0,this.declaration=me(this.initialData.declaration,this.project),this.successCalls=this.initialData.successCalls.map(n=>{const s=me(n,this.project);if(s.addSuccessCaller(this,null),[d.BreakStatement,d.ContinueStatement].includes(s.type))s.setParent(this.parent.parent,null);else if(s.type===d.ReturnStatement){const c=tn(this,this.project);s.setParent(c,null),s.initChildren(i)}else s.type!==d.InternalCall&&s.setParent(this.parent,null);return s.initChildren(i),s}),this.errorCalls=this.initialData.errorCalls.map(n=>{const s=me(n,this.project);if(s.addErrorCaller(this,null),[d.BreakStatement,d.ContinueStatement].includes(s.type))s.setParent(this.parent.parent,null),s.initChildren(i);else if(s.type===d.ReturnStatement){const c=tn(this,this.project);s.setParent(c,null),s.initChildren(i)}else s.type!==d.InternalCall&&(s.setParent(this.parent,null),s.initChildren(i));return s}),this.inputs=this.initialData.inputs.map(n=>{const s=me(n,this.project);return s.setParent(this,null),s.initChildren(i),s}),this.outputs=this.initialData.outputs.map(n=>{const s=me(n,this.project);return s.setParent(this,null),s.initChildren(i),s}),this.initialData.error&&(this.error=me(this.initialData.error,this.project),this.error.setParent(this,null),this.error.initChildren(i)),this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this)}subscribe(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"meta-sync"))){const s=Mr(this,i,n),c=Lr(this,s),e=this.toMeta();return this.x=s.x||e.x,this.y=s.y||e.y,this.catchesError=s.catchesError!==void 0?s.catchesError:this.catchesError,super.baseMetaSync(s,this,n),s.deleted===!0&&!e.deleted?n==null||n.add(this,H.Removed):s.deleted===!1&&e.deleted?n==null||n.add(this,H.Added):c&&(n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=ke,...n){return await pi.repository.APILoad(this.id,...n),this}async APICreate(i=ke,...n){return await pi.repository.APICreate(this.toShallowJSON(),...n),this}async APIUpdate(i=ke,...n){return await pi.repository.APIUpdate(this.toShallowJSON(),...n),this}async APIDelete(i=ke,...n){return await pi.repository.APIDelete(this.toShallowJSON(),...n),this}async APIClone(i=ke,...n){return await pi.repository.APIClone(this.id,...n),this}async APILoadVersion(i=ke,n,...s){return await pi.repository.APILoadVersion(this.id,n,...s)}removeFromParent(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveFromParent))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[removeFromParent] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveFromParent,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];return this.parent.type===d.Project?(this.parent.removeOperation(this),e.push(this.parent)):this.parent.detachedChildren.includes(this)&&this.parent.unsubscribeDetachedChild(this),i==null||i.attemptAutoclose(_.RemoveFromParent,this.id),{added:D(c),updated:D(n),removed:D(s),affected:D(e),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveEntity))){var m;if(!this.checkCanDelete(this,n))return J.Logger.warn(`[remove] User is not allowed to delete or edit this ${this.type} entity with id: ${this.id}`),n==null||n.event({id:`${_.RemoveEntity}-${this.id}`,action:_.RemoveEntity,owner:this,errorReason:Ii.ActionOwnerEntityNonDeletable,rootAction:((m=n==null?void 0:n.self)==null?void 0:m.id)===this.id&&(n==null?void 0:n.autoCloseActionName)===_.RemoveEntity}),n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const s=[],c=[],e=[],y=[];if(n!=null&&n.hasRemoved(this.id))return n==null||n.attemptAutoclose(_.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},n),Object.values(this.detachedDependents).forEach(v=>{const{updated:E,removed:b,added:w}=v.entity.onDetachedDependencyRemoved(this,v.field,n);s.push(...E),c.push(...b),e.push(...w)}),this.inputs.forEach(v=>{const{updated:E,removed:b}=v.remove({ignoreUpstream:!0},n);s.push(...E),c.push(...b)}),this.outputs.forEach(v=>{const{updated:E,removed:b}=v.remove({ignoreUpstream:!0},n);s.push(...E),c.push(...b)}),this.error){const{updated:v,removed:E}=this.error.remove({ignoreUpstream:!0},n);s.push(...v),c.push(...E)}if(this.successCalls.forEach(v=>{s.push(v),v.removeCaller(this,n)}),this.errorCalls.forEach(v=>{s.push(v),v.removeCaller(this,n)}),!i){const v=this.removeFromParent(n);e.push(...v.added),s.push(...v.updated),c.push(...v.removed),y.push(...v.affected),this.calledBy.forEach(E=>{s.push(E),E.removeCall(this,n)})}return n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:D(e),updated:D(s),removed:D(c),affected:D(y),self:this}}restore({}={},i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RestoreEntity))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[restore] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];return i!=null&&i.hasAdded(this.id)?(i==null||i.attemptAutoclose(_.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(y=>{const{updated:m,removed:v,added:E}=y.entity.onDetachedDependencyRestored(this,y.field,i);s.push(...m),c.push(...v),n.push(...E)}),this.inputs.forEach(y=>{const{updated:m}=y.restore({},i);s.push(...m)}),this.outputs.forEach(y=>{const{updated:m}=y.restore({},i);s.push(...m)}),this.successCalls.forEach(y=>{s.push(y),y.addSuccessCaller(this,i)}),this.errorCalls.forEach(y=>{s.push(y),y.addErrorCaller(this,i)}),this.calledBySuccess.forEach(y=>{s.push(y),y.addSuccessCall(this,i)}),this.calledByError.forEach(y=>{s.push(y),y.addErrorCall(this,i)}),this.calledByEntry.forEach(y=>{s.push(y),y.addCall(this,i)}),i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this})}toFlat(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this,...this.successCalls.flatMap(s=>s.toFlat(i)),...this.errorCalls.flatMap(s=>s.toFlat(i)),...this.inputs.flatMap(s=>s.toFlat(i)),...this.outputs.flatMap(s=>s.toFlat(i)),...this.calledBy.flatMap(s=>s.toFlat(i)),...this.error?this.error.toFlat(i):[]])}toFlatIds(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.successCalls.flatMap(s=>s.toFlatIds(i)),...this.errorCalls.flatMap(s=>s.toFlatIds(i)),...this.inputs.flatMap(s=>s.toFlatIds(i)),...this.outputs.flatMap(s=>s.toFlatIds(i)),...this.error?this.error.toFlatIds(i):[]])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,x:this.x,y:this.y,type:this.type,editable:this.editable,deletable:this.deletable,catchesError:this.catchesError}}toJSON(i=new Set){var n;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,catchesError:this.catchesError,x:this.x,y:this.y,successCalls:this.successCalls.map(s=>s.toJSON(i)),errorCalls:this.errorCalls.map(s=>s.toJSON(i)),calledBySuccess:this.calledBySuccess.map(s=>s.toReference()),calledByError:this.calledByError.map(s=>s.toReference()),calledByEntry:this.calledByEntry.map(s=>s.toReference()),writesValues:this.writesValues.map(s=>s.toJSON(i)),declaration:this.declaration.toJSON(i),inputs:this.inputs.map(s=>s.toJSON(i)),outputs:this.outputs.map(s=>s.toJSON(i)),parent:this.parent.toReference(),error:(n=this.error)==null?void 0:n.toJSON(i)})}toJSONClone(i=ct){var s,c,e,y,m,v;let n;return(s=i.seenEntityMaps)!=null&&s.has(this.id)?n=i.seenEntityMaps.get(this.id):(n=i.newId||jr(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,n)),(c=i.seenEntities)!=null&&c.has(n)||(e=i.seenEntities)!=null&&e.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((y=i.seenEntities)==null||y.add(n),(m=i.seenEntities)==null||m.add(this.id),{id:n,version:x.UUID.uuid(),createdAt:i.timestamp||M().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,catchesError:this.catchesError,x:this.x,y:this.y,successCalls:this.successCalls.map(E=>E.toJSONClone({...i,newId:null})),errorCalls:this.errorCalls.map(E=>E.toJSONClone({...i,newId:null})),calledBySuccess:this.calledBySuccess.map(E=>E.toReference({seenEntityMaps:i.seenEntityMaps})),calledByError:this.calledByError.map(E=>E.toReference({seenEntityMaps:i.seenEntityMaps})),calledByEntry:this.calledByEntry.map(E=>E.toReference({seenEntityMaps:i.seenEntityMaps})),writesValues:this.writesValues.map(E=>E.toJSONClone({...i,newId:null})),declaration:this.declaration.toJSON(),inputs:this.inputs.map(E=>E.toJSONClone({...i,newId:null})),outputs:this.outputs.map(E=>E.toJSONClone({...i,newId:null})),parent:this.parent.toReference({seenEntityMaps:i.seenEntityMaps}),error:(v=this.error)==null?void 0:v.toJSONClone({...i,newId:null})})}toReference(i=ct){var s;let n=this.id;return(s=i.seenEntityMaps)!=null&&s.has(this.id)&&(n=i.seenEntityMaps.get(this.id)),{id:n+"--"+x.UUID.uuid()+"--ref",type:d.GenericReference,entityId:n,version:this.version,entityType:this.type}}toShallowJSON(i=ct){var s;let n=this.id;return(s=i.seenEntityMaps)!=null&&s.has(this.id)&&(n=i.seenEntityMaps.get(this.id)),{id:n,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,catchesError:this.catchesError,x:this.x,y:this.y,inputs:this.inputs.map(c=>c.toReference(i)),outputs:this.outputs.map(c=>c.toReference(i)),declaration:this.declaration.toReference(i),writesValues:this.writesValues.map(c=>c.toReference(i)),successCalls:this.successCalls.map(c=>c.toReference(i)),errorCalls:this.errorCalls.map(c=>c.toReference(i)),calledBySuccess:this.calledBySuccess.map(c=>c.toReference(i)),calledByError:this.calledByError.map(c=>c.toReference(i)),calledByEntry:this.calledByEntry.map(c=>c.toReference(i)),error:this.error?this.error.toReference(i):null,parent:this.parent.toReference(i)}}toFlatJSON(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...this.successCalls.flatMap(s=>s.toFlatJSON(i)),...this.errorCalls.flatMap(s=>s.toFlatJSON(i)),...this.inputs.flatMap(s=>s.toFlatJSON(i)),...this.outputs.flatMap(s=>s.toFlatJSON(i)),...this.calledBy.flatMap(s=>s.toFlatJSON(i)),...this.error?this.error.toFlatJSON(i):[]])}toGenerationTarget(){const i=this.parent.type===d.Project?void 0:this.parent.id;return{id:this.id,type:this.type,calledByEntry:this.calledByEntry.map(n=>n.id),calledBySuccess:this.calledBySuccess.map(n=>n.id),calledByError:this.calledByError.map(n=>n.id),declaration:this.declaration.id,parent:i}}toFlatGenerationTarget(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...this.successCalls.flatMap(s=>s.toFlatGenerationTarget(i)),...this.errorCalls.flatMap(s=>s.toFlatGenerationTarget(i)),...this.inputs.flatMap(s=>s.toFlatGenerationTarget(i)),...this.outputs.flatMap(s=>s.toFlatGenerationTarget(i)),...this.error?this.error.toFlatGenerationTarget(i):[]])}clearErrors(){var i;return this.errors=[],this.inputs.forEach(n=>n.clearErrors()),this.outputs.forEach(n=>n.clearErrors()),this.successCalls.forEach(n=>n.clearErrors()),this.errorCalls.forEach(n=>n.clearErrors()),(i=this.error)==null||i.clearErrors(),this}validate(){return this.errors=Jwe(this),{success:!0}}async validateAsync(i={}){const n=J.YieldTracker.from(i);return this.errors=await zwe(this,{tracker:n}),{success:!0}}getErrors(){return[...this.errors,...this.inputs.flatMap(n=>n.getErrors()),...this.outputs.flatMap(n=>n.getErrors()),...this.error?this.error.getErrors():[]]}async getErrorsAsync(i={}){const n=J.YieldTracker.from(i),s=[...this.errors];await n.tick();for(const c of this.inputs)s.push(...await c.getErrorsAsync({tracker:n}));for(const c of this.outputs)s.push(...await c.getErrorsAsync({tracker:n}));return this.error&&s.push(...await this.error.getErrorsAsync({tracker:n})),s}getShallowErrors(){return this.errors}clone(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.CloneEntity)),n=null,s=null,c=!0){var $,L;const e=Rr(n,this),y=this.toJSON(),m=s||x.UUID.uuid();y.inputs=[];const v=m.split("-id"),E=v[v.length-1||0]||m;y.id=m,y.version=x.UUID.uuid(),y.createdAt=(i==null?void 0:i.timestamp)||M().toISOString(),y.author=(i==null?void 0:i.author)||"1",y.previousVersion=null,y.deleted=!1,y.deletable=!0,y.editable=!0;const b=Si(y,e);n?b.setParent(n,i):b.setParent(this.parent,null),c&&b.subscribe(),b.initChildren(i),i==null||i.add(b,H.Added);const w=($=this.inputs)==null?void 0:$.map((k,K)=>k.clone(i,b,E+"-input-map-"+K+"-id",c));b.inputs=w;const V=(L=this.outputs)==null?void 0:L.map((k,K)=>k.clone(i,b,E+"-output-map-"+K+"-id",c));return b.outputs=V,this.error&&(b.error=this.error.clone(i,b,E+"-error-map-id",c)),i==null||i.attemptAutoclose(_.CloneEntity,this.id),b}removeUnrecognizedInputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveUnrecognizedInputs))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[removeUnrecognizedInputs] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveUnrecognizedInputs,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];return this.inputs.forEach(m=>{if(!this.declaration.inputs.find(E=>{var b;return E.id===((b=m.declaration)==null?void 0:b.id)})){const E=m.remove({ignoreUpstream:!1},i);c.push(...E.removed),n.push(...E.updated)}}),this.inputs.filter((m,v)=>{const E=this.inputs.findIndex(w=>w.declaration===m.declaration&&w!==m&&m.declaration.parentRelationType!==B.DynamicArgument);if(E===-1)return!1;const b=this.inputs[E];return M(b==null?void 0:b.createdAt).isSame(M(m.createdAt))?v>E:!!M(b==null?void 0:b.createdAt).isAfter(m.createdAt)}).forEach(m=>{const v=m.remove({ignoreUpstream:!1},i);c.push(...v.removed),n.push(...v.updated)}),i==null||i.attemptAutoclose(_.RemoveUnrecognizedInputs,this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}removeUnrecognizedOutputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveUnrecognizedOutputs))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[removeUnrecognizedOutputs] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveUnrecognizedOutputs,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[],y=this.declaration.dataType&&this.declaration.dataType.entity&&this.declaration.dataType.entity.type===d.DefinitionEntity?this.declaration.dataType.entity.properties:[];return this.outputs.forEach(v=>{if(!y.find(b=>{var w;return b.id===((w=v.declaration)==null?void 0:w.id)})){const b=v.remove({ignoreUpstream:!1},i);c.push(...b.removed),n.push(...b.updated)}}),this.outputs.filter((v,E)=>{const b=this.outputs.findIndex(V=>V.declaration===v.declaration&&V!==v);if(b===-1)return!1;const w=this.outputs[b];return M(w==null?void 0:w.createdAt).isSame(M(v.createdAt))?E>b:!!M(w==null?void 0:w.createdAt).isAfter(v.createdAt)}).forEach(v=>{const E=v.remove({ignoreUpstream:!1},i);c.push(...E.removed),n.push(...E.updated)}),i==null||i.attemptAutoclose(_.RemoveUnrecognizedOutputs,this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}syncInputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SyncInputs))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[syncInputs] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.SyncInputs,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[],y=this.declaration.inputs.filter(b=>b.parentRelationType===B.FixedArguments&&!this.inputs.find(w=>{var V;return((V=w.declaration)==null?void 0:V.id)===b.id}));this.inputs.sort((b,w)=>b.index-w.index),y.forEach(b=>{this.inputs.forEach($=>{$.index>=b.index&&$.metaSync({index:$.index+1},i)});const w={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||M().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.InputMap,parentRelationType:null,declaration:b.toJSON(),dataType:null,readsValue:null,defaultValue:null,index:b.index,name:null,codeName:null,description:null,parent:this.toReference()},V=me(w,this.project);V.setParent(this,i),V.initChildren(i),i==null||i.add(V,H.Added),V.addSelfToProject(i)}),this.inputs.sort((b,w)=>b.index-w.index);const{updated:m,added:v,removed:E}=this.removeUnrecognizedInputs(i);return n.push(...m),s.push(...v),c.push(...E),i==null||i.attemptAutoclose(_.SyncInputs,this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}syncOutputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SyncOutputs))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[syncOutputs] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.SyncOutputs,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[],m=(this.declaration.dataType&&this.declaration.dataType.entity&&this.declaration.dataType.entity.type===d.DefinitionEntity?this.declaration.dataType.entity.properties:[]).filter(w=>!this.outputs.find(V=>{var $;return(($=V.declaration)==null?void 0:$.id)===w.id}));this.outputs.sort((w,V)=>w.index-V.index),m.forEach(w=>{this.outputs.forEach(L=>{L.index>=w.index&&L.index++});const V={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||M().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.OutputMap,declaration:w.toJSON(),dataType:null,writesValues:[],index:w.index,parent:this.toReference()},$=me(V,this.project);$.setParent(this,i),$.initChildren(i),i==null||i.add($,H.Added),$.addSelfToProject(i)}),this.outputs.sort((w,V)=>w.index-V.index);const{updated:v,added:E,removed:b}=this.removeUnrecognizedOutputs(i);return n.push(...v),s.push(...E),c.push(...b),i==null||i.attemptAutoclose(_.SyncOutputs,this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}getUnusedInputs(){return this.inputs.filter(i=>i.suggestion||!i.readsValue&&!i.defaultValue)}getUnusedOutputs(){return this.outputs.filter(i=>i.suggestion||!i.writesValues.length)}getUsedInputs(){return this.inputs.filter(i=>!i.suggestion&&(i.readsValue||i.defaultValue))}getUsedOutputs(){return this.outputs.filter(i=>!i.suggestion&&i.writesValues.length)}getDataType(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"get-data-type"))){var s;const n=((s=this.declaration)==null?void 0:s.getDataType(i))||null;return i==null||i.attemptAutoclose("get-data-type",this.id),n}};I(pi,"repository",{APICreate:async(i,...n)=>i,APIUpdate:async(i,...n)=>i,APIDelete:async(i,...n)=>i,APIClone:async(i,...n)=>{},APILoad:async(i,...n)=>null,APILoadVersion:async(i,n,...s)=>null}),I(pi,"type",d.Operation),I(pi,"USER_MANAGED_PARENT_TYPES",[...nr,d.Project]),I(pi,"PARENT_TYPES",[...pi.USER_MANAGED_PARENT_TYPES]),I(pi,"MUTABLE_BASE_PROPERTIES",["catchesError"]),I(pi,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),I(pi,"BASE_PROPERTIES",[...pi.MUTABLE_BASE_PROPERTIES,...pi.INMUTABLE_BASE_PROPERTIES]),I(pi,"MUTABLE_META_PROPERTIES",[...pi.MUTABLE_BASE_PROPERTIES,"x","y"]),I(pi,"INMUTABLE_META_PROPERTIES",[...pi.INMUTABLE_BASE_PROPERTIES]),I(pi,"META_PROPERTIES",[...pi.MUTABLE_META_PROPERTIES,...pi.INMUTABLE_META_PROPERTIES]),I(pi,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry"]),I(pi,"INMUTABLE_UPSTREAM_PROPERTIES",["parent","declaration"]),I(pi,"UPSTREAM_PROPERTIES",[...pi.MUTABLE_UPSTREAM_PROPERTIES,...pi.INMUTABLE_UPSTREAM_PROPERTIES]),I(pi,"MUTABLE_DOWNSTREAM_PROPERTIES",["inputs","outputs","writesValues","successCalls","errorCalls","error"]),I(pi,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),I(pi,"DOWNSTREAM_PROPERTIES",[...pi.MUTABLE_DOWNSTREAM_PROPERTIES,...pi.INMUTABLE_DOWNSTREAM_PROPERTIES]),I(pi,"PROPERTIES",[...pi.META_PROPERTIES,...pi.UPSTREAM_PROPERTIES,...pi.DOWNSTREAM_PROPERTIES]);let Nu=pi;async function Xwe(o,p={}){var c;const i=J.YieldTracker.from(p),n=[];await i.tick();const s=Mt(o.errors,n);for(const e of o.outputs)await e.validateAsync({tracker:i});return await((c=o.throws)==null?void 0:c.validateAsync({tracker:i})),s}function Qwe(o){var i;o.outputs.forEach(n=>n.validate()),(i=o.throws)==null||i.validate();const p=[];return Mt(o.errors,p)}const HTi=Object.freeze(Object.defineProperty({__proto__:null,validate:Qwe,validateAsync:Xwe},Symbol.toStringTag,{value:"Module"}));var MP=(o=>(o.Parent="return-statement-parent-field",o.DataTypeEntity="return-statement-data-type-entity-field",o.DataType="return-statement-data-type-field",o.ParentDataType="return-statement-parent-data-type-field",o.ParentDataTypeEntity="return-statement-parent-data-type-entity-field",o))(MP||{});const Oi=class Oi extends Ur{constructor(i,n){super(i);I(this,"initialData");I(this,"id");I(this,"x");I(this,"y");I(this,"type",d.ReturnStatement);I(this,"outputs",[]);I(this,"readsValue",null);I(this,"dataType",null);I(this,"defaultValue",null);I(this,"calledBySuccess",[]);I(this,"calledByError",[]);I(this,"calledByEntry",[]);I(this,"throws",null);I(this,"project");I(this,"errors",[]);I(this,"parent");I(this,"detachedDependents",{});I(this,"knownVersions",null);I(this,"activeVersion",!1);I(this,"initialized",!1);I(this,"startedInitialization",!1);I(this,"suggestion",!1);I(this,"_codeNativeValueValidation",null);this.initialData=i,this.project=n,this.id=i.id,this.x=i.x,this.y=i.y}static new(i=null){return{id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||M().toISOString(),author:(i==null?void 0:i.author)||x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.ReturnStatement,outputs:[],defaultValue:null,dataType:null,readsValue:null,throws:null,parent:null,calledByEntry:[],calledBySuccess:[],calledByError:[],x:0,y:0}}static fromGenerationTarget(i,n){const s=ne(i.parent),c=n.get(s),e=i.calledByEntry.map(w=>{const V=ne(w);return n.get(V)}),y=i.calledBySuccess.map(w=>{const V=ne(w);return n.get(V)}),m=i.calledByError.map(w=>{const V=ne(w);return n.get(V)});let v=null;if(i.readsValue){const w=ne(i.readsValue);v=n.get(w)}const E={id:i.id,version:x.UUID.uuid(),createdAt:M().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.ReturnStatement,x:0,y:0,outputs:[],defaultValue:null,dataType:null,readsValue:v,calledBySuccess:y,calledByError:m,calledByEntry:e,throws:null,parent:c},b=me(E,n);return b.setParent(c,null),b}static validateGenerationTarget(i,n){let s=JSON.parse(JSON.stringify(i));const c=[],e=bn(s,{parent:{list:!1,types:nr}},n);return s=e.modifiedData,c.push(...e.errors,...$r(s)),{errors:c,modifiedData:s}}get codeNativeValueValidation(){return this._codeNativeValueValidation||null}validateGeneratedUpdate(i){const n=[];let s=JSON.parse(JSON.stringify(i));const c=sf(s,this);return s=c.modifiedData,n.push(...c.errors),i.parent&&n.push(new De({id:`${this.id}--${ae.InvalidParentUpdate}`,code:ae.InvalidParentUpdate,severity:ce.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated. The 'parent' on a callable entity, is its scope. It scope is auto-calculated implicitly by the its caller.
|
|
42
42
|
If an entity is called by another, they must be in the same scope, which means they have the same parent.
|
|
43
43
|
You shouldn't have to manually update a 'parent' property.
|
|
44
|
-
Specifically for return statements the parent needs to always be the 'function-declaration' or 'global-event' that contains it.`})),{errors:n,modifiedData:i}}subscribeDependents(i){return i.forEach(n=>{this.detachedDependents[n.entity.id]||(this.detachedDependents[n.entity.id]=n)}),this}unsubscribeDependents(i){return i.forEach(n=>{this.detachedDependents[n.entity.id]&&delete this.detachedDependents[n.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"sync-dependents"))){const n=[],s=[],c=[],e=[];return Object.values(this.detachedDependents).forEach(y=>{const m=y.entity.afterAllChildrenInitialized(i);n.push(...m.updated),s.push(...m.added),c.push(...m.removed),e.push(...m.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}onDetachedDependencyRemoved(i,n,s){const c=[],e=[],y=[],m=[];if(n==="return-statement-parent-field"){const{updated:v,added:E,removed:b}=this.remove({ignoreUpstream:!1},s);c.push(...v),e.push(...E),y.push(...b)}if(n==="return-statement-parent-data-type-field"){const{updated:v,added:E,removed:b}=this.afterAllChildrenInitialized(s);c.push(...v),e.push(...E),y.push(...b)}if(n==="return-statement-parent-data-type-entity-field"){const{updated:v,added:E,removed:b}=this.afterAllChildrenInitialized(s);c.push(...v),e.push(...E),y.push(...b)}return{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:this}}onDetachedDependencyRestored(i,n,s){const c=[],e=[],y=[],m=[];if(n==="return-statement-parent-field"){const{updated:v,added:E,removed:b}=this.restore({},s);c.push(...v),e.push(...E),y.push(...b)}if(n==="return-statement-parent-data-type-field"){const{updated:v,added:E,removed:b}=this.afterAllChildrenInitialized(s);c.push(...v),e.push(...E),y.push(...b)}if(n==="return-statement-parent-data-type-entity-field"){const{updated:v,added:E,removed:b}=this.afterAllChildrenInitialized(s);c.push(...v),e.push(...E),y.push(...b)}return{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:this}}unsubscribeFromDependencies(){var i,n,s,c,e,y,m,v,E,b,w,V,$;return(i=this.parent)==null||i.unsubscribeDependents([{entity:this,field:"return-statement-parent-field"}]),(c=(s=(n=this.dataType)==null?void 0:n.entity)==null?void 0:s.unsubscribeDependents)==null||c.call(s,[{entity:this,field:"return-statement-data-type-entity-field"}]),(y=(e=this.dataType)==null?void 0:e.unsubscribeDependents)==null||y.call(e,[{entity:this,field:"return-statement-data-type-field"}]),(b=(E=(v=(m=this.parent)==null?void 0:m.dataType)==null?void 0:v.entity)==null?void 0:E.unsubscribeDependents)==null||b.call(E,[{entity:this,field:"return-statement-parent-data-type-entity-field"}]),($=(V=(w=this.parent)==null?void 0:w.dataType)==null?void 0:V.unsubscribeDependents)==null||$.call(V,[{entity:this,field:"return-statement-parent-data-type-field"}]),this}subscribeToDependencies(){var i,n,s,c,e,y,m,v,E,b,w,V,$;return(i=this.parent)==null||i.subscribeDependents([{entity:this,field:"return-statement-parent-field"}]),(c=(s=(n=this.dataType)==null?void 0:n.entity)==null?void 0:s.subscribeDependents)==null||c.call(s,[{entity:this,field:"return-statement-data-type-entity-field"}]),(y=(e=this.dataType)==null?void 0:e.subscribeDependents)==null||y.call(e,[{entity:this,field:"return-statement-data-type-field"}]),(b=(E=(v=(m=this.parent)==null?void 0:m.dataType)==null?void 0:v.entity)==null?void 0:E.subscribeDependents)==null||b.call(E,[{entity:this,field:"return-statement-parent-data-type-entity-field"}]),($=(V=(w=this.parent)==null?void 0:w.dataType)==null?void 0:V.subscribeDependents)==null||$.call(V,[{entity:this,field:"return-statement-parent-data-type-field"}]),this}increaseVersion(i){if(i&&!M(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&M(i).isSame(M(this.createdAt))?this:(this.previousVersion=this.version,this.version=x.UUID.uuid(),this.createdAt=M(i).toISOString()||M().toISOString(),this)}captureVersion(){var n;const i=((n=this.knownVersions)==null?void 0:n.get(this.version))||new Oi(this,this.project);return i.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map([[this.version,i]]),i.outputs=[...this.outputs],i.readsValue=this.readsValue,i.defaultValue=this.defaultValue,i.dataType=this.dataType,i.throws=this.throws,i.calledBySuccess=[...this.calledBySuccess],i.calledByError=[...this.calledByError],i.calledByEntry=[...this.calledByEntry],i.parent=this.parent,this}recursiveCaptureUpstreamVersions(i){const n=[],s=[],c=[],e=[];if(this.parent){this.parent.increaseVersion(i);const y=this.parent.recursiveCaptureUpstreamVersions(i);n.push(this.parent,...y.updated),s.push(...y.added),c.push(...y.removed)}return{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}async restoreVersion(i){var m;const n=[],s=[],c=[],e=[];if(this.version===i)return{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this};if(!this.knownVersions){const v=new Map;for(const[E,b]of this.knownVersions||new Map){if(v.set(E,b),b.activeVersion=!1,b.knownVersions)for(const[w,V]of b.knownVersions)v.set(w,V);b.knownVersions=null}}let y=(m=this.knownVersions)==null?void 0:m.get(i);if(!y){const v=await this.APILoadVersion({},i);if(!v)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);y=new Oi(v,this.project)}return this.metaSync(y.toShallowJSON(),null),this.previousVersion=y.previousVersion,this.version=y.version,this.createdAt=y.createdAt,this.author=y.author,this.deleted=y.deleted,this.outputs=y.outputs,this.readsValue=y.readsValue,this.defaultValue=y.defaultValue,this.dataType=y.dataType,this.throws=y.throws,this.calledBySuccess=y.calledBySuccess,this.calledByError=y.calledByError,this.calledByEntry=y.calledByEntry,this.parent=y.parent,{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}updateWithShallowTransfer(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.UpdateWithShallowTransfer))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[updateWithShallowTransfer] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),this;if(this.metaSync(i,n),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 s=ne(i.parent),c=this.project.get(s),e=this.parent;if(e&&e.id!==(c==null?void 0:c.id)&&this.removeFromParent(n),c)this.setParent(c,n),this.addSelfToProject(n);else throw n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${s}' that isn't found in the project`)}else throw n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(i.readsValue){const s=ne(i.readsValue),c=this.project.get(s),e=this.readsValue;e&&e.id!==(c==null?void 0:c.id)&&this.removeValueWriter(n),c&&this.setValueWriter(c,n)}else this.removeValueWriter(n);if(i.calledByEntry.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addEntryCaller(e,n),e.addCall(this,n))}),[...this.calledByEntry].forEach(s=>{i.calledByEntry.find(e=>ne(e)===s.id)||(this.removeCaller(s,n),s.removeCall(this,n))}),i.calledBySuccess.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addSuccessCaller(e,n),e.addSuccessCall(this,n))}),[...this.calledBySuccess].forEach(s=>{i.calledBySuccess.find(e=>ne(e)===s.id)||(this.removeCaller(s,n),s.removeCall(this,n))}),i.calledByError.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addErrorCaller(e,n),e.addErrorCall(this,n))}),[...this.calledByError].forEach(s=>{i.calledByError.find(e=>ne(e)===s.id)||(this.removeCaller(s,n),s.removeCall(this,n))}),i.outputs.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addOutput(e,n),e.setParent(this,n))}),[...this.outputs].forEach(s=>{i.outputs.find(e=>ne(e)===s.id)||(this.removeOutput(s,n),s.removeFromParent(n))}),i.dataType){const s=ne(i.dataType),c=this.project.get(s);c&&this.setDataType(c,n)}else this.setDataType(null,n);if(i.defaultValue){const s=ne(i.defaultValue),c=this.project.get(s);c&&this.setDefaultValue(c,n)}else this.setDefaultValue(null,n);return this.captureVersion(),this.subscribeToDependencies(),n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),this}hydrateAncestors(){const i=[],n=[],s=[],c=[];if(this.initialData.parent){const e=ne(this.initialData.parent),y=this.project.get(e);if(y)this.setParent(y,null),i.push(y);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.readsValue){const e=ne(this.initialData.readsValue),y=this.project.get(e);y&&(this.setValueWriter(y,null),i.push(y))}return this.initialData.calledByEntry.forEach(e=>{const y=ne(e),m=this.project.get(y);m&&this.addEntryCaller(m,null)}),this.initialData.calledBySuccess.forEach(e=>{const y=ne(e),m=this.project.get(y);m&&this.addSuccessCaller(m,null)}),this.initialData.calledByError.forEach(e=>{const y=ne(e),m=this.project.get(y);m&&this.addErrorCaller(m,null)}),{updated:D(i),added:D(n),removed:D(s),affected:D(c),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AfterAllChildrenInitialized))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[afterAllChildrenInitialized] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.AfterAllChildrenInitialized,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];this.initialized=!0,!this.dataType||this.dataType.inferred;const{updated:y,added:m,removed:v,affected:E}=this.syncInputs(i);return n.push(...y),s.push(...m),c.push(...v),e.push(...E),this.outputs.sort((b,w)=>(b.index||0)-(w.index||0)),this.captureVersion(),i==null||i.attemptAutoclose(_.AfterAllChildrenInitialized,this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}addSelfToProject(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"add-self-to-project"))){var y;const n=[this],s=[],c=[],e=[];return this.readsValue&&(this.readsValue.addValueReader(this,i),n.push(this.readsValue)),this.calledByEntry.forEach(m=>{m.addCall(this,i),n.push(m)}),this.calledBySuccess.forEach(m=>{m.addSuccessCall(this,i),n.push(m)}),this.calledByError.forEach(m=>{m.addErrorCall(this,i),n.push(m)}),this.parent.addReturnStatement(this),e.push(this.parent),i==null||i.add(this.parent,H.Affected),(y=this.parent)==null||y.returnStatements.forEach(m=>{m.id!==this.id&&(e.push(m),i==null||i.add(m,H.Affected))}),this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}addSuccessCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddSuccessCaller)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddSuccessCaller,n)?(this.calledBySuccess.find(c=>c.id===i.id)||(this.calledBySuccess.push(i),n==null||n.add(this,H.Updated),s&&mt(this,n)),n==null||n.attemptAutoclose(_.AddSuccessCaller,this.id),this):this}addErrorCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddErrorCaller)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddErrorCaller,n)?(this.calledByError.find(c=>c.id===i.id)||(this.calledByError.push(i),n==null||n.add(this,H.Updated),s&&mt(this,n)),n==null||n.attemptAutoclose(_.AddErrorCaller,this.id),this):this}addEntryCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddEntryCaller)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddEntryCaller,n)?(this.calledByEntry.find(c=>c.id===i.id)||(this.calledByEntry.push(i),n==null||n.add(this,H.Updated),s&&mt(this,n)),n==null||n.attemptAutoclose(_.AddEntryCaller,this.id),this):this}removeCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-caller")),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.RemoveCaller,n)?(this.calledBySuccess=this.calledBySuccess.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),this.calledByError=this.calledByError.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),this.calledByEntry=this.calledByEntry.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),s&&mt(this,n),n==null||n.attemptAutoclose(_.RemoveCaller,this.id),this):this}setThrows(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"set-throws"))){var s;if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setThrows] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("set-throws",this.id),this;if(i!==null&&i.parentRelationType!==vd.Error)throw new Error("The 'throws' InputMap must have a parentRelationType of 'Error'.");return((s=this.throws)==null?void 0:s.id)!==(i==null?void 0:i.id)&&(this.throws=i,n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose("set-throws",this.id),this}addOutput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"add-output"))){return this.checkCanEdit(this,n)?this.outputs.includes(i)?(n==null||n.attemptAutoclose("add-output",this.id),this):(this.outputs.push(i),n==null||n.add(this,H.Affected),n==null||n.attemptAutoclose("add-output",this.id),this):(J.Logger.warn(`[addOutput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("add-output",this.id),this)}removeOutput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-output"))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[removeOutput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("remove-output",this.id),this;const s=this.outputs.findIndex(c=>c.id===i.id);return s>-1&&(this.outputs.splice(s,1),n&&(n==null||n.add(this,H.Affected))),n==null||n.attemptAutoclose("remove-output",this.id),this}setParent(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetParent))){var s;return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.SetParent,n)?(((s=this.parent)==null?void 0:s.id)!==(i==null?void 0:i.id)&&(this.parent=i,n&&(n==null||n.add(this,H.Updated))),n==null||n.attemptAutoclose(_.SetParent,this.id),this):this}setValueWriter(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetValueWriter))){return this.checkCanEditFromScopeOwnerWithSideEffects(this,_.SetValueWriter,n)?(this.readsValue!==i&&(this.readsValue=i,n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose(_.SetValueWriter,this.id),this):this}removeValueWriter(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveValueWriter))){return this.readsValue&&!this.checkCanEditWithCounterpartAndSideEffects(this,this.readsValue,_.RemoveValueWriter,i)?this:(this.readsValue&&(this.readsValue=null,i==null||i.add(this,H.Updated)),i==null||i.attemptAutoclose(_.RemoveValueWriter,this.id),this)}initChildren(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"init-children"))){return this.initialized||this.startedInitialization?this:(this.startedInitialization=!0,this.initialData.defaultValue&&(this.defaultValue=me(this.initialData.defaultValue,this.project),this.defaultValue.setParent(this,null),this.defaultValue.initChildren(i)),this.initialData.dataType&&(this.setDataType(me(this.initialData.dataType,this.project),i),this.dataType.setParent(this,null),this.dataType.initChildren(i)),lf.initReadsValue(this),this.outputs=this.initialData.outputs.map(n=>{const s=me(n,this.project);return s.setParent(this,null),s.initChildren(i),s}),this.initialData.throws&&(this.throws=me(this.initialData.throws,this.project),this.throws.setParent(this,null),this.throws.initChildren(i)),this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this)}subscribe(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"meta-sync"))){const s=Mr(this,i,n),c=Lr(this,s),e=this.toMeta();return this.x=s.x||e.x,this.y=s.y||e.y,super.baseMetaSync(s,this,n),s.deleted===!0&&!e.deleted?n==null||n.add(this,H.Removed):s.deleted===!1&&e.deleted?n==null||n.add(this,H.Added):c&&(n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=ke,...n){return await Oi.repository.APILoad(this.id,...n),this}async APICreate(i=ke,...n){return await Oi.repository.APICreate(this.toShallowJSON(),...n),this}async APIUpdate(i=ke,...n){return await Oi.repository.APIUpdate(this.toShallowJSON(),...n),this}async APIDelete(i=ke,...n){return await Oi.repository.APIDelete(this.toShallowJSON(),...n),this}async APIClone(i=ke,...n){return await Oi.repository.APIClone(this.id,...n),this}async APILoadVersion(i=ke,n,...s){return await Oi.repository.APILoadVersion(this.id,n,...s)}removeFromParent(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveFromParent))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[removeFromParent] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveFromParent,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];return this.parent.removeReturnStatement(this),e.push(this.parent),i==null||i.attemptAutoclose(_.RemoveFromParent,this.id),{added:D(c),updated:D(n),removed:D(s),affected:D(e),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveEntity))){var m,v;if(!this.checkCanDelete(this,n))return J.Logger.warn(`[remove] User is not allowed to delete or edit this ${this.type} entity with id: ${this.id}`),n==null||n.event({id:`${_.RemoveEntity}-${this.id}`,action:_.RemoveEntity,owner:this,errorReason:Ii.ActionOwnerEntityNonDeletable,rootAction:((m=n==null?void 0:n.self)==null?void 0:m.id)===this.id&&(n==null?void 0:n.autoCloseActionName)===_.RemoveEntity}),n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const s=[],c=[],e=[],y=[];if(n!=null&&n.hasRemoved(this.id))return n==null||n.attemptAutoclose(_.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},n),Object.values(this.detachedDependents).forEach(E=>{const{updated:b,removed:w,added:V}=E.entity.onDetachedDependencyRemoved(this,E.field,n);s.push(...b),c.push(...w),e.push(...V)}),this.readsValue&&(s.push(this.readsValue),this.readsValue.removeValueReader(this,n)),this.outputs.forEach(E=>{const{updated:b,removed:w}=E.remove({ignoreUpstream:!0},n);s.push(...b),c.push(...w)}),this.throws){const{updated:E,removed:b}=this.throws.remove({ignoreUpstream:!0},n);s.push(...E),c.push(...b)}if(this.dataType){const{updated:E,removed:b}=this.dataType.remove({ignoreUpstream:!0},n);s.push(...E),c.push(...b)}if(!i){const E=this.removeFromParent(n);e.push(...E.added),s.push(...E.updated),c.push(...E.removed),y.push(...E.affected),this.calledBy.forEach(b=>{s.push(b),b.removeCall(this,n)})}return n==null||n.add(this.parent,H.Affected),(v=this.parent)==null||v.returnStatements.forEach(E=>{E.id!==this.id&&(y.push(E),n==null||n.add(E,H.Affected))}),n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:D(e),updated:D(s),removed:D(c),affected:D(y),self:this}}restore({}={},i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RestoreEntity))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[restore] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];if(i!=null&&i.hasAdded(this.id))return i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},i),Object.values(this.detachedDependents).forEach(y=>{const{updated:m,removed:v,added:E}=y.entity.onDetachedDependencyRestored(this,y.field,i);s.push(...m),c.push(...v),n.push(...E)}),this.readsValue&&(s.push(this.readsValue),this.readsValue.addValueReader(this,i)),this.outputs.forEach(y=>{const{updated:m}=y.restore({},i);s.push(...m)}),this.throws){const{updated:y}=this.throws.restore({},i);s.push(...y)}if(this.dataType){const{updated:y}=this.dataType.restore({},i);s.push(...y)}return this.parent.addReturnStatement(this),this.calledBySuccess.forEach(y=>{s.push(y),y.addSuccessCall(this,i)}),this.calledByError.forEach(y=>{s.push(y),y.addErrorCall(this,i)}),this.calledByEntry.forEach(y=>{s.push(y),y.addCall(this,i)}),i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this}}toFlat(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this,...this.outputs.flatMap(s=>s.toFlat(i)),...this.throws?this.throws.toFlat(i):[],...this.dataType?this.dataType.toFlat(i):[]])}toFlatIds(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.outputs.flatMap(s=>s.toFlatIds(i)),...this.throws?this.throws.toFlatIds(i):[],...this.dataType?this.dataType.toFlatIds(i):[]])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,x:this.x,y:this.y,type:this.type,editable:this.editable,deletable:this.deletable}}toJSON(i=new Set){var n,s,c,e,y;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,x:this.x,y:this.y,defaultValue:((n=this.defaultValue)==null?void 0:n.toJSON(i))||null,dataType:((s=this.dataType)==null?void 0:s.toJSON(i))||null,readsValue:((c=this.readsValue)==null?void 0:c.toReference())||null,calledBySuccess:this.calledBySuccess.map(m=>m.toReference()),calledByError:this.calledByError.map(m=>m.toReference()),calledByEntry:this.calledByEntry.map(m=>m.toReference()),outputs:this.outputs.map(m=>m.toJSON(i)),parent:((e=this.parent)==null?void 0:e.toReference())||null,throws:((y=this.throws)==null?void 0:y.toJSON(i))||null})}toJSONClone(i=ct){var s,c,e,y,m,v,E,b,w,V;let n;return(s=i.seenEntityMaps)!=null&&s.has(this.id)?n=i.seenEntityMaps.get(this.id):(n=i.newId||jr(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,n)),(c=i.seenEntities)!=null&&c.has(n)||(e=i.seenEntities)!=null&&e.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((y=i.seenEntities)==null||y.add(n),(m=i.seenEntities)==null||m.add(this.id),{id:n,version:x.UUID.uuid(),createdAt:i.timestamp||M().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,x:this.x,y:this.y,defaultValue:((v=this.defaultValue)==null?void 0:v.toJSONClone({...i,newId:null}))||null,dataType:((E=this.dataType)==null?void 0:E.toJSONClone({...i,newId:null}))||null,readsValue:((b=this.readsValue)==null?void 0:b.toReference({seenEntityMaps:i.seenEntityMaps}))||null,calledBySuccess:this.calledBySuccess.map($=>$.toReference({seenEntityMaps:i.seenEntityMaps})),calledByError:this.calledByError.map($=>$.toReference({seenEntityMaps:i.seenEntityMaps})),calledByEntry:this.calledByEntry.map($=>$.toReference({seenEntityMaps:i.seenEntityMaps})),outputs:this.outputs.map($=>$.toJSONClone({...i,newId:null})),parent:((w=this.parent)==null?void 0:w.toReference({seenEntityMaps:i.seenEntityMaps}))||null,throws:((V=this.throws)==null?void 0:V.toJSONClone({...i,newId:null}))||null})}toReference(i=ct){var s;let n=this.id;return(s=i.seenEntityMaps)!=null&&s.has(this.id)&&(n=i.seenEntityMaps.get(this.id)),{id:n+"--"+x.UUID.uuid()+"--ref",type:d.GenericReference,entityId:n,version:this.version,entityType:this.type}}toShallowJSON(i=ct){var s,c,e,y,m,v;let n=this.id;return(s=i.seenEntityMaps)!=null&&s.has(this.id)&&(n=i.seenEntityMaps.get(this.id)),{id:n,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,x:this.x,y:this.y,defaultValue:((c=this.defaultValue)==null?void 0:c.toReference(i))||null,dataType:((e=this.dataType)==null?void 0:e.toReference(i))||null,readsValue:((y=this.readsValue)==null?void 0:y.toReference(i))||null,outputs:this.outputs.map(E=>E.toReference(i)),calledBySuccess:this.calledBySuccess.map(E=>E.toReference(i)),calledByError:this.calledByError.map(E=>E.toReference(i)),calledByEntry:this.calledByEntry.map(E=>E.toReference(i)),throws:((m=this.throws)==null?void 0:m.toReference(i))||null,parent:((v=this.parent)==null?void 0:v.toReference(i))||null}}toFlatJSON(i=new Set){var s,c;return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...((s=this.defaultValue)==null?void 0:s.toFlatJSON(i))||[],...((c=this.dataType)==null?void 0:c.toFlatJSON(i))||[],...this.outputs.flatMap(e=>e.toFlatJSON(i)),...this.throws?this.throws.toFlatJSON(i):[]])}toGenerationTarget(){return{id:this.id,type:this.type,calledByEntry:this.calledByEntry.map(i=>i.id),calledByError:this.calledByError.map(i=>i.id),calledBySuccess:this.calledBySuccess.map(i=>i.id),parent:this.parent.id}}toFlatGenerationTarget(i=new Set){var s,c;return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...((s=this.defaultValue)==null?void 0:s.toFlatGenerationTarget(i))||[],...((c=this.dataType)==null?void 0:c.toFlatGenerationTarget(i))||[],...this.outputs.flatMap(e=>e.toFlatGenerationTarget(i)),...this.throws?this.throws.toFlatGenerationTarget(i):[]])}clearErrors(){var i,n,s;return this.errors=[],(i=this.dataType)==null||i.clearErrors(),(n=this.defaultValue)==null||n.clearErrors(),this.outputs.forEach(c=>c.clearErrors()),(s=this.throws)==null||s.clearErrors(),this}validate(){return this.errors=Qwe(this),{success:!0}}async validateAsync(i={}){const n=J.YieldTracker.from(i);return this.errors=await Xwe(this,{tracker:n}),{success:!0}}getErrors(){var n,s,c;return[...this.errors,...((n=this.defaultValue)==null?void 0:n.getErrors())||[],...((s=this.dataType)==null?void 0:s.getErrors())||[],...this.outputs.flatMap(e=>e.getErrors()),...((c=this.throws)==null?void 0:c.getErrors())||[]]}async getErrorsAsync(i={}){const n=J.YieldTracker.from(i),s=[...this.errors];if(await n.tick(),this.defaultValue){const c=await this.defaultValue.getErrorsAsync({tracker:n});s.push(...c)}if(this.dataType){const c=await this.dataType.getErrorsAsync({tracker:n});s.push(...c)}for(const c of this.outputs){const e=await c.getErrorsAsync({tracker:n});s.push(...e)}if(this.throws){const c=await this.throws.getErrorsAsync({tracker:n});s.push(...c)}return s}getShallowErrors(){return this.errors}getDefaultValue(){return this.defaultValue||null}setDefaultValue(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"set-default-value"))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setDefaultValue] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("set-default-value",this.id),this;const s=this.defaultValue;return(s==null?void 0:s.id)!==(i==null?void 0:i.id)&&(s==null||s.remove({ignoreUpstream:!0},n),this.defaultValue=i,n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose("set-default-value",this.id),this}clone(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.CloneEntity)),n=null,s=null,c=!0){var L,k,K;const e=Rr(n,this),y=this.toJSON(),m=s||x.UUID.uuid();y.outputs=[];const v=m.split("-id"),E=v[v.length-1||0]||m;y.id=m,y.version=x.UUID.uuid(),y.createdAt=(i==null?void 0:i.timestamp)||M().toISOString(),y.author=(i==null?void 0:i.author)||"1",y.previousVersion=null,y.deleted=!1,y.deletable=!0,y.editable=!0;const b=Si(y,e);n?b.setParent(n,i):b.setParent(this.parent,null),c&&b.subscribe(),b.initChildren(i),i==null||i.add(b,H.Added);const w=(L=this.dataType)==null?void 0:L.clone(i,b,x.UUID.uuid(),c);b.setDataType(w||null,i);const V=(k=this.defaultValue)==null?void 0:k.clone(i,b,x.UUID.uuid(),c);b.setDefaultValue(V||null,i);const $=(K=this.outputs)==null?void 0:K.map((S,Y)=>S.clone(i,b,E+"-return-declaration-"+Y+"-id",c));return b.outputs=$,this.throws&&(b.throws=this.throws.clone(i,b,E+"-throws-id",c)),i==null||i.attemptAutoclose(_.CloneEntity,this.id),b}syncInputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"sync-returned-inputs"))){const n=[],s=[],c=[],e=[];if(this.throws&&this.outputs.length&&(!this.parent.implements||this.parent.implements.error))return[...this.outputs].forEach(m=>{var v;if(m.id!==((v=this.throws)==null?void 0:v.id)){const{updated:E,removed:b}=m.remove({ignoreUpstream:!0},i);n.push(...E),c.push(...b),this.removeOutput(m,i)}}),i==null||i.attemptAutoclose("sync-returned-inputs",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this};const y=this.getDataType(i);if(y){const m=[];y!=null&&y.entity&&(y.entity.type===d.DefinitionEntity||y.entity.type===d.BuiltInBaseEntity)&&(y!=null&&y.entity.properties.length)?m.push(y==null?void 0:y.entity):((y==null?void 0:y.orChildrenGroup)||[]).forEach(w=>{w.entity&&(w.entity.type===d.DefinitionEntity||w.entity.type===d.BuiltInBaseEntity)&&w.entity.properties.length&&m.push(w.entity)});const v=m[0],E=(v==null?void 0:v.type)===d.DefinitionEntity||(v==null?void 0:v.type)===d.BuiltInBaseEntity?v.properties:[];return E.filter(w=>Ry(w)&&!this.outputs.find(V=>{var $;return(($=V.declaration)==null?void 0:$.id)===w.id&&(V.declaration.type===d.ValueDescriptor?V.declaration.parentRelationType!==B.ReturnedError:!0)})).forEach(w=>{const V=w.implementAsInputMap(i,this);s.push(V)}),[...this.outputs].forEach(w=>{if(!E.find($=>{var L;return((L=w.declaration)==null?void 0:L.id)===$.id&&(w.declaration.type===d.ValueDescriptor?w.declaration.parentRelationType!==B.ReturnedError:!0)})){const{updated:$,removed:L}=w.remove({ignoreUpstream:!1},i);n.push(...$),c.push(...L),this.removeOutput(w,i)}if(!dA(w)){const{updated:$,removed:L}=w.remove({ignoreUpstream:!1},i);n.push(...$),c.push(...L),this.removeOutput(w,i)}}),i==null||i.attemptAutoclose("sync-returned-inputs",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}return i==null||i.attemptAutoclose("sync-returned-inputs",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}setDataType(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetDataType))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setDataType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.SetDataType,this.id),this;const s=this.dataType;return(s==null?void 0:s.id)!==(i==null?void 0:i.id)&&(s==null||s.remove({ignoreUpstream:!0},n),this.dataType=i,this.subscribeToDependencies(),n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose(_.SetDataType,this.id),this}removeDataType(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveDataType))){return this.checkCanEdit(this,i)?(this.dataType&&(this.dataType.remove({ignoreUpstream:!0},i),i==null||i.add(this,H.Affected),this.dataType=null),i==null||i.attemptAutoclose(_.RemoveDataType,this.id),this):(J.Logger.warn(`[removeDataType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveDataType,this.id),this)}getDataType(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"get-data-type"))){var c,e;if((!this.dataType||this.dataType.inferred)&&this.project.initialized,this.dataType)return i==null||i.attemptAutoclose("get-data-type",this.id),this.dataType;if(this.parent.type===d.GlobalEvent){const y=(c=this.parent.implements)==null?void 0:c.dataType;return i==null||i.attemptAutoclose("get-data-type",this.id),y||null}const n=this.parent.dataType;if(n)return i==null||i.attemptAutoclose("get-data-type",this.id),n;const s=(e=this.parent.implements)==null?void 0:e.dataType;return i==null||i.attemptAutoclose("get-data-type",this.id),s||null}};I(Oi,"repository",{APICreate:async(i,...n)=>i,APIUpdate:async(i,...n)=>i,APIDelete:async(i,...n)=>i,APIClone:async(i,...n)=>{},APILoad:async(i,...n)=>null,APILoadVersion:async(i,n,...s)=>null}),I(Oi,"type",d.ReturnStatement),I(Oi,"USER_MANAGED_PARENT_TYPES",[...nr]),I(Oi,"PARENT_TYPES",[...Oi.USER_MANAGED_PARENT_TYPES]),I(Oi,"MUTABLE_BASE_PROPERTIES",[]),I(Oi,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),I(Oi,"BASE_PROPERTIES",[...Oi.MUTABLE_BASE_PROPERTIES,...Oi.INMUTABLE_BASE_PROPERTIES]),I(Oi,"MUTABLE_META_PROPERTIES",["x","y"]),I(Oi,"INMUTABLE_META_PROPERTIES",[...Oi.INMUTABLE_BASE_PROPERTIES]),I(Oi,"META_PROPERTIES",[...Oi.MUTABLE_META_PROPERTIES,...Oi.INMUTABLE_META_PROPERTIES]),I(Oi,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry","readsValue"]),I(Oi,"INMUTABLE_UPSTREAM_PROPERTIES",["parent"]),I(Oi,"UPSTREAM_PROPERTIES",[...Oi.MUTABLE_UPSTREAM_PROPERTIES,...Oi.INMUTABLE_UPSTREAM_PROPERTIES]),I(Oi,"MUTABLE_DOWNSTREAM_PROPERTIES",["outputs","throws"]),I(Oi,"INMUTABLE_DOWNSTREAM_PROPERTIES",["dataType","defaultValue"]),I(Oi,"DOWNSTREAM_PROPERTIES",[...Oi.MUTABLE_DOWNSTREAM_PROPERTIES,...Oi.INMUTABLE_DOWNSTREAM_PROPERTIES]),I(Oi,"PROPERTIES",[...Oi.META_PROPERTIES,...Oi.UPSTREAM_PROPERTIES,...Oi.DOWNSTREAM_PROPERTIES]);let bd=Oi;async function eOe(o,p={}){const i=J.YieldTracker.from(p),n=iOe(o),s=_v(o),c=[...n,...s],e=Mt(o.errors,c);await i.tick();const y=await qh(o,new Set,{tracker:i});for(const m of o.inputs)await m.validateAsync({tracker:i});for(const m of y)await m.validateAsync({tracker:i});return e}function tOe(o){const p=La(o);o.inputs.forEach(n=>n.validate()),p.forEach(n=>n.validate());const i=[..._v(o),...iOe(o)];return Mt(o.errors,i)}function iOe(o){const p=[];if(!o.calls.length){const i=Ot({id:`${o.id}--${he.ScopeWithoutLogic}`,message:`Action "${se(o,o.project)}" with id "${o.id}" does not have any logic defined. So it doesn't do anything.`,severity:ce.Warning,code:he.ScopeWithoutLogic,entity:o});p.push(i.error)}return Mt(o.errors,p)}const WTi=Object.freeze(Object.defineProperty({__proto__:null,validate:tOe,validateAsync:eOe},Symbol.toStringTag,{value:"Module"})),ci=class ci extends Ur{constructor(i,n){super(i);I(this,"initialData");I(this,"id");I(this,"name");I(this,"description",null);I(this,"x");I(this,"y");I(this,"collapsed");I(this,"type",d.GlobalEvent);I(this,"inputs",[]);I(this,"calls",[]);I(this,"parent");I(this,"implements");I(this,"detachedChildren",[]);I(this,"errors",[]);I(this,"project");I(this,"detachedDependents",{});I(this,"knownVersions",null);I(this,"activeVersion",!1);I(this,"initialized",!1);I(this,"startedInitialization",!1);this.initialData=i,this.project=n,this.id=i.id,this.name=i.name,this.description=i.description,this.x=i.x,this.y=i.y,this.collapsed=i.collapsed}static new(i=null){return{id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||M().toISOString(),author:(i==null?void 0:i.author)||x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.GlobalEvent,name:"",description:"",collapsed:!1,implements:null,inputs:[],parent:null,calls:[],x:0,y:0}}static fromGenerationTarget(i,n){let s=n;if(i.parent){const m=ne(i.parent);s=n.get(m)}let c;i.implements&&(c=n.getBuiltIn(i.implements));const e={id:i.id,version:x.UUID.uuid(),createdAt:M().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,name:i.name,description:i.description||null,deletable:!0,editable:!0,type:d.GlobalEvent,collapsed:!1,calls:[],inputs:[],implements:c,x:0,y:0,parent:s},y=me(e,n);return y.setParent(s,null),y}static validateGenerationTarget(i,n){let s=JSON.parse(JSON.stringify(i));const c=[],e=bn(s,{},n);if(s=e.modifiedData,c.push(...e.errors,...$r(s)),!i.implements)c.push(new De({id:`${i.id}--${Ie.InvalidObjectStructure}`,code:Ie.InvalidObjectStructure,severity:ce.Error,message:`Entity of type '${i.type}' with id '${i.id}' is missing the 'implements' property. This property is required for a '${i.type}' entity and must point to one of the built-in action descriptors reserved for 'global-event' entities.
|
|
44
|
+
Specifically for return statements the parent needs to always be the 'function-declaration' or 'global-event' that contains it.`})),{errors:n,modifiedData:i}}subscribeDependents(i){return i.forEach(n=>{this.detachedDependents[n.entity.id]||(this.detachedDependents[n.entity.id]=n)}),this}unsubscribeDependents(i){return i.forEach(n=>{this.detachedDependents[n.entity.id]&&delete this.detachedDependents[n.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"sync-dependents"))){const n=[],s=[],c=[],e=[];return Object.values(this.detachedDependents).forEach(y=>{const m=y.entity.afterAllChildrenInitialized(i);n.push(...m.updated),s.push(...m.added),c.push(...m.removed),e.push(...m.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}onDetachedDependencyRemoved(i,n,s){const c=[],e=[],y=[],m=[];if(n==="return-statement-parent-field"){const{updated:v,added:E,removed:b}=this.remove({ignoreUpstream:!1},s);c.push(...v),e.push(...E),y.push(...b)}if(n==="return-statement-parent-data-type-field"){const{updated:v,added:E,removed:b}=this.afterAllChildrenInitialized(s);c.push(...v),e.push(...E),y.push(...b)}if(n==="return-statement-parent-data-type-entity-field"){const{updated:v,added:E,removed:b}=this.afterAllChildrenInitialized(s);c.push(...v),e.push(...E),y.push(...b)}return{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:this}}onDetachedDependencyRestored(i,n,s){const c=[],e=[],y=[],m=[];if(n==="return-statement-parent-field"){const{updated:v,added:E,removed:b}=this.restore({},s);c.push(...v),e.push(...E),y.push(...b)}if(n==="return-statement-parent-data-type-field"){const{updated:v,added:E,removed:b}=this.afterAllChildrenInitialized(s);c.push(...v),e.push(...E),y.push(...b)}if(n==="return-statement-parent-data-type-entity-field"){const{updated:v,added:E,removed:b}=this.afterAllChildrenInitialized(s);c.push(...v),e.push(...E),y.push(...b)}return{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:this}}unsubscribeFromDependencies(){var i,n,s,c,e,y,m,v,E,b,w,V,$;return(i=this.parent)==null||i.unsubscribeDependents([{entity:this,field:"return-statement-parent-field"}]),(c=(s=(n=this.dataType)==null?void 0:n.entity)==null?void 0:s.unsubscribeDependents)==null||c.call(s,[{entity:this,field:"return-statement-data-type-entity-field"}]),(y=(e=this.dataType)==null?void 0:e.unsubscribeDependents)==null||y.call(e,[{entity:this,field:"return-statement-data-type-field"}]),(b=(E=(v=(m=this.parent)==null?void 0:m.dataType)==null?void 0:v.entity)==null?void 0:E.unsubscribeDependents)==null||b.call(E,[{entity:this,field:"return-statement-parent-data-type-entity-field"}]),($=(V=(w=this.parent)==null?void 0:w.dataType)==null?void 0:V.unsubscribeDependents)==null||$.call(V,[{entity:this,field:"return-statement-parent-data-type-field"}]),this}subscribeToDependencies(){var i,n,s,c,e,y,m,v,E,b,w,V,$;return(i=this.parent)==null||i.subscribeDependents([{entity:this,field:"return-statement-parent-field"}]),(c=(s=(n=this.dataType)==null?void 0:n.entity)==null?void 0:s.subscribeDependents)==null||c.call(s,[{entity:this,field:"return-statement-data-type-entity-field"}]),(y=(e=this.dataType)==null?void 0:e.subscribeDependents)==null||y.call(e,[{entity:this,field:"return-statement-data-type-field"}]),(b=(E=(v=(m=this.parent)==null?void 0:m.dataType)==null?void 0:v.entity)==null?void 0:E.subscribeDependents)==null||b.call(E,[{entity:this,field:"return-statement-parent-data-type-entity-field"}]),($=(V=(w=this.parent)==null?void 0:w.dataType)==null?void 0:V.subscribeDependents)==null||$.call(V,[{entity:this,field:"return-statement-parent-data-type-field"}]),this}increaseVersion(i){if(i&&!M(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&M(i).isSame(M(this.createdAt))?this:(this.previousVersion=this.version,this.version=x.UUID.uuid(),this.createdAt=M(i).toISOString()||M().toISOString(),this)}captureVersion(){var n;const i=((n=this.knownVersions)==null?void 0:n.get(this.version))||new Oi(this,this.project);return i.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map([[this.version,i]]),i.outputs=[...this.outputs],i.readsValue=this.readsValue,i.defaultValue=this.defaultValue,i.dataType=this.dataType,i.throws=this.throws,i.calledBySuccess=[...this.calledBySuccess],i.calledByError=[...this.calledByError],i.calledByEntry=[...this.calledByEntry],i.parent=this.parent,this}recursiveCaptureUpstreamVersions(i){const n=[],s=[],c=[],e=[];if(this.parent){this.parent.increaseVersion(i);const y=this.parent.recursiveCaptureUpstreamVersions(i);n.push(this.parent,...y.updated),s.push(...y.added),c.push(...y.removed)}return{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}async restoreVersion(i){var m;const n=[],s=[],c=[],e=[];if(this.version===i)return{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this};if(!this.knownVersions){const v=new Map;for(const[E,b]of this.knownVersions||new Map){if(v.set(E,b),b.activeVersion=!1,b.knownVersions)for(const[w,V]of b.knownVersions)v.set(w,V);b.knownVersions=null}}let y=(m=this.knownVersions)==null?void 0:m.get(i);if(!y){const v=await this.APILoadVersion({},i);if(!v)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);y=new Oi(v,this.project)}return this.metaSync(y.toShallowJSON(),null),this.previousVersion=y.previousVersion,this.version=y.version,this.createdAt=y.createdAt,this.author=y.author,this.deleted=y.deleted,this.outputs=y.outputs,this.readsValue=y.readsValue,this.defaultValue=y.defaultValue,this.dataType=y.dataType,this.throws=y.throws,this.calledBySuccess=y.calledBySuccess,this.calledByError=y.calledByError,this.calledByEntry=y.calledByEntry,this.parent=y.parent,{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}updateWithShallowTransfer(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.UpdateWithShallowTransfer))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[updateWithShallowTransfer] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),this;if(this.metaSync(i,n),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 s=ne(i.parent),c=this.project.get(s),e=this.parent;if(e&&e.id!==(c==null?void 0:c.id)&&this.removeFromParent(n),c)this.setParent(c,n),this.addSelfToProject(n);else throw n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${s}' that isn't found in the project`)}else throw n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(i.readsValue){const s=ne(i.readsValue),c=this.project.get(s),e=this.readsValue;e&&e.id!==(c==null?void 0:c.id)&&this.removeValueWriter(n),c&&this.setValueWriter(c,n)}else this.removeValueWriter(n);if(i.calledByEntry.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addEntryCaller(e,n),e.addCall(this,n))}),[...this.calledByEntry].forEach(s=>{i.calledByEntry.find(e=>ne(e)===s.id)||(this.removeCaller(s,n),s.removeCall(this,n))}),i.calledBySuccess.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addSuccessCaller(e,n),e.addSuccessCall(this,n))}),[...this.calledBySuccess].forEach(s=>{i.calledBySuccess.find(e=>ne(e)===s.id)||(this.removeCaller(s,n),s.removeCall(this,n))}),i.calledByError.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addErrorCaller(e,n),e.addErrorCall(this,n))}),[...this.calledByError].forEach(s=>{i.calledByError.find(e=>ne(e)===s.id)||(this.removeCaller(s,n),s.removeCall(this,n))}),i.outputs.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addOutput(e,n),e.setParent(this,n))}),[...this.outputs].forEach(s=>{i.outputs.find(e=>ne(e)===s.id)||(this.removeOutput(s,n),s.removeFromParent(n))}),i.dataType){const s=ne(i.dataType),c=this.project.get(s);c&&this.setDataType(c,n)}else this.setDataType(null,n);if(i.defaultValue){const s=ne(i.defaultValue),c=this.project.get(s);c&&this.setDefaultValue(c,n)}else this.setDefaultValue(null,n);return this.captureVersion(),this.subscribeToDependencies(),n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),this}hydrateAncestors(){const i=[],n=[],s=[],c=[];if(this.initialData.parent){const e=ne(this.initialData.parent),y=this.project.get(e);if(y)this.setParent(y,null),i.push(y);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.readsValue){const e=ne(this.initialData.readsValue),y=this.project.get(e);y&&(this.setValueWriter(y,null),i.push(y))}return this.initialData.calledByEntry.forEach(e=>{const y=ne(e),m=this.project.get(y);m&&this.addEntryCaller(m,null)}),this.initialData.calledBySuccess.forEach(e=>{const y=ne(e),m=this.project.get(y);m&&this.addSuccessCaller(m,null)}),this.initialData.calledByError.forEach(e=>{const y=ne(e),m=this.project.get(y);m&&this.addErrorCaller(m,null)}),{updated:D(i),added:D(n),removed:D(s),affected:D(c),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AfterAllChildrenInitialized))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[afterAllChildrenInitialized] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.AfterAllChildrenInitialized,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];this.initialized=!0,!this.dataType||this.dataType.inferred;const{updated:y,added:m,removed:v,affected:E}=this.syncInputs(i);return n.push(...y),s.push(...m),c.push(...v),e.push(...E),this.outputs.sort((b,w)=>(b.index||0)-(w.index||0)),this.captureVersion(),i==null||i.attemptAutoclose(_.AfterAllChildrenInitialized,this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}addSelfToProject(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"add-self-to-project"))){var y;const n=[this],s=[],c=[],e=[];return this.readsValue&&(this.readsValue.addValueReader(this,i),n.push(this.readsValue)),this.calledByEntry.forEach(m=>{m.addCall(this,i),n.push(m)}),this.calledBySuccess.forEach(m=>{m.addSuccessCall(this,i),n.push(m)}),this.calledByError.forEach(m=>{m.addErrorCall(this,i),n.push(m)}),this.parent.addReturnStatement(this),e.push(this.parent),i==null||i.add(this.parent,H.Affected),(y=this.parent)==null||y.returnStatements.forEach(m=>{m.id!==this.id&&(e.push(m),i==null||i.add(m,H.Affected))}),this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}addSuccessCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddSuccessCaller)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddSuccessCaller,n)?(this.calledBySuccess.find(c=>c.id===i.id)||(this.calledBySuccess.push(i),n==null||n.add(this,H.Updated),s&&mt(this,n)),n==null||n.attemptAutoclose(_.AddSuccessCaller,this.id),this):this}addErrorCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddErrorCaller)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddErrorCaller,n)?(this.calledByError.find(c=>c.id===i.id)||(this.calledByError.push(i),n==null||n.add(this,H.Updated),s&&mt(this,n)),n==null||n.attemptAutoclose(_.AddErrorCaller,this.id),this):this}addEntryCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddEntryCaller)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddEntryCaller,n)?(this.calledByEntry.find(c=>c.id===i.id)||(this.calledByEntry.push(i),n==null||n.add(this,H.Updated),s&&mt(this,n)),n==null||n.attemptAutoclose(_.AddEntryCaller,this.id),this):this}removeCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-caller")),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.RemoveCaller,n)?(this.calledBySuccess=this.calledBySuccess.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),this.calledByError=this.calledByError.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),this.calledByEntry=this.calledByEntry.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),s&&mt(this,n),n==null||n.attemptAutoclose(_.RemoveCaller,this.id),this):this}setThrows(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"set-throws"))){var s;if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setThrows] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("set-throws",this.id),this;if(i!==null&&i.parentRelationType!==vd.Error)throw new Error("The 'throws' InputMap must have a parentRelationType of 'Error'.");return((s=this.throws)==null?void 0:s.id)!==(i==null?void 0:i.id)&&(this.throws=i,n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose("set-throws",this.id),this}addOutput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"add-output"))){return this.checkCanEdit(this,n)?this.outputs.includes(i)?(n==null||n.attemptAutoclose("add-output",this.id),this):(this.outputs.push(i),n==null||n.add(this,H.Affected),n==null||n.attemptAutoclose("add-output",this.id),this):(J.Logger.warn(`[addOutput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("add-output",this.id),this)}removeOutput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-output"))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[removeOutput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("remove-output",this.id),this;const s=this.outputs.findIndex(c=>c.id===i.id);return s>-1&&(this.outputs.splice(s,1),n&&(n==null||n.add(this,H.Affected))),n==null||n.attemptAutoclose("remove-output",this.id),this}setParent(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetParent))){var s;return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.SetParent,n)?(((s=this.parent)==null?void 0:s.id)!==(i==null?void 0:i.id)&&(this.parent=i,n&&(n==null||n.add(this,H.Updated))),n==null||n.attemptAutoclose(_.SetParent,this.id),this):this}setValueWriter(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetValueWriter))){var s;return this.checkCanEditFromScopeOwnerWithSideEffects(this,_.SetValueWriter,n)?(this.readsValue!==i&&(this.readsValue=i,this.readsValue&&((s=this.defaultValue)==null||s.remove({ignoreUpstream:!1},n)),n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose(_.SetValueWriter,this.id),this):this}removeValueWriter(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveValueWriter))){return this.readsValue&&!this.checkCanEditWithCounterpartAndSideEffects(this,this.readsValue,_.RemoveValueWriter,i)?this:(this.readsValue&&(this.readsValue=null,i==null||i.add(this,H.Updated)),i==null||i.attemptAutoclose(_.RemoveValueWriter,this.id),this)}initChildren(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"init-children"))){return this.initialized||this.startedInitialization?this:(this.startedInitialization=!0,this.initialData.defaultValue&&(this.defaultValue=me(this.initialData.defaultValue,this.project),this.defaultValue.setParent(this,null),this.defaultValue.initChildren(i)),this.initialData.dataType&&(this.setDataType(me(this.initialData.dataType,this.project),i),this.dataType.setParent(this,null),this.dataType.initChildren(i)),lf.initReadsValue(this),this.outputs=this.initialData.outputs.map(n=>{const s=me(n,this.project);return s.setParent(this,null),s.initChildren(i),s}),this.initialData.throws&&(this.throws=me(this.initialData.throws,this.project),this.throws.setParent(this,null),this.throws.initChildren(i)),this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this)}subscribe(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"meta-sync"))){const s=Mr(this,i,n),c=Lr(this,s),e=this.toMeta();return this.x=s.x||e.x,this.y=s.y||e.y,super.baseMetaSync(s,this,n),s.deleted===!0&&!e.deleted?n==null||n.add(this,H.Removed):s.deleted===!1&&e.deleted?n==null||n.add(this,H.Added):c&&(n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=ke,...n){return await Oi.repository.APILoad(this.id,...n),this}async APICreate(i=ke,...n){return await Oi.repository.APICreate(this.toShallowJSON(),...n),this}async APIUpdate(i=ke,...n){return await Oi.repository.APIUpdate(this.toShallowJSON(),...n),this}async APIDelete(i=ke,...n){return await Oi.repository.APIDelete(this.toShallowJSON(),...n),this}async APIClone(i=ke,...n){return await Oi.repository.APIClone(this.id,...n),this}async APILoadVersion(i=ke,n,...s){return await Oi.repository.APILoadVersion(this.id,n,...s)}removeFromParent(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveFromParent))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[removeFromParent] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveFromParent,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];return this.parent.removeReturnStatement(this),e.push(this.parent),i==null||i.attemptAutoclose(_.RemoveFromParent,this.id),{added:D(c),updated:D(n),removed:D(s),affected:D(e),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveEntity))){var m,v;if(!this.checkCanDelete(this,n))return J.Logger.warn(`[remove] User is not allowed to delete or edit this ${this.type} entity with id: ${this.id}`),n==null||n.event({id:`${_.RemoveEntity}-${this.id}`,action:_.RemoveEntity,owner:this,errorReason:Ii.ActionOwnerEntityNonDeletable,rootAction:((m=n==null?void 0:n.self)==null?void 0:m.id)===this.id&&(n==null?void 0:n.autoCloseActionName)===_.RemoveEntity}),n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const s=[],c=[],e=[],y=[];if(n!=null&&n.hasRemoved(this.id))return n==null||n.attemptAutoclose(_.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},n),Object.values(this.detachedDependents).forEach(E=>{const{updated:b,removed:w,added:V}=E.entity.onDetachedDependencyRemoved(this,E.field,n);s.push(...b),c.push(...w),e.push(...V)}),this.readsValue&&(s.push(this.readsValue),this.readsValue.removeValueReader(this,n)),this.outputs.forEach(E=>{const{updated:b,removed:w}=E.remove({ignoreUpstream:!0},n);s.push(...b),c.push(...w)}),this.throws){const{updated:E,removed:b}=this.throws.remove({ignoreUpstream:!0},n);s.push(...E),c.push(...b)}if(this.dataType){const{updated:E,removed:b}=this.dataType.remove({ignoreUpstream:!0},n);s.push(...E),c.push(...b)}if(!i){const E=this.removeFromParent(n);e.push(...E.added),s.push(...E.updated),c.push(...E.removed),y.push(...E.affected),this.calledBy.forEach(b=>{s.push(b),b.removeCall(this,n)})}return n==null||n.add(this.parent,H.Affected),(v=this.parent)==null||v.returnStatements.forEach(E=>{E.id!==this.id&&(y.push(E),n==null||n.add(E,H.Affected))}),n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:D(e),updated:D(s),removed:D(c),affected:D(y),self:this}}restore({}={},i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RestoreEntity))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[restore] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];if(i!=null&&i.hasAdded(this.id))return i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},i),Object.values(this.detachedDependents).forEach(y=>{const{updated:m,removed:v,added:E}=y.entity.onDetachedDependencyRestored(this,y.field,i);s.push(...m),c.push(...v),n.push(...E)}),this.readsValue&&(s.push(this.readsValue),this.readsValue.addValueReader(this,i)),this.outputs.forEach(y=>{const{updated:m}=y.restore({},i);s.push(...m)}),this.throws){const{updated:y}=this.throws.restore({},i);s.push(...y)}if(this.dataType){const{updated:y}=this.dataType.restore({},i);s.push(...y)}return this.parent.addReturnStatement(this),this.calledBySuccess.forEach(y=>{s.push(y),y.addSuccessCall(this,i)}),this.calledByError.forEach(y=>{s.push(y),y.addErrorCall(this,i)}),this.calledByEntry.forEach(y=>{s.push(y),y.addCall(this,i)}),i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this}}toFlat(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this,...this.outputs.flatMap(s=>s.toFlat(i)),...this.throws?this.throws.toFlat(i):[],...this.dataType?this.dataType.toFlat(i):[]])}toFlatIds(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.outputs.flatMap(s=>s.toFlatIds(i)),...this.throws?this.throws.toFlatIds(i):[],...this.dataType?this.dataType.toFlatIds(i):[]])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,x:this.x,y:this.y,type:this.type,editable:this.editable,deletable:this.deletable}}toJSON(i=new Set){var n,s,c,e,y;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,x:this.x,y:this.y,defaultValue:((n=this.defaultValue)==null?void 0:n.toJSON(i))||null,dataType:((s=this.dataType)==null?void 0:s.toJSON(i))||null,readsValue:((c=this.readsValue)==null?void 0:c.toReference())||null,calledBySuccess:this.calledBySuccess.map(m=>m.toReference()),calledByError:this.calledByError.map(m=>m.toReference()),calledByEntry:this.calledByEntry.map(m=>m.toReference()),outputs:this.outputs.map(m=>m.toJSON(i)),parent:((e=this.parent)==null?void 0:e.toReference())||null,throws:((y=this.throws)==null?void 0:y.toJSON(i))||null})}toJSONClone(i=ct){var s,c,e,y,m,v,E,b,w,V;let n;return(s=i.seenEntityMaps)!=null&&s.has(this.id)?n=i.seenEntityMaps.get(this.id):(n=i.newId||jr(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,n)),(c=i.seenEntities)!=null&&c.has(n)||(e=i.seenEntities)!=null&&e.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((y=i.seenEntities)==null||y.add(n),(m=i.seenEntities)==null||m.add(this.id),{id:n,version:x.UUID.uuid(),createdAt:i.timestamp||M().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,x:this.x,y:this.y,defaultValue:((v=this.defaultValue)==null?void 0:v.toJSONClone({...i,newId:null}))||null,dataType:((E=this.dataType)==null?void 0:E.toJSONClone({...i,newId:null}))||null,readsValue:((b=this.readsValue)==null?void 0:b.toReference({seenEntityMaps:i.seenEntityMaps}))||null,calledBySuccess:this.calledBySuccess.map($=>$.toReference({seenEntityMaps:i.seenEntityMaps})),calledByError:this.calledByError.map($=>$.toReference({seenEntityMaps:i.seenEntityMaps})),calledByEntry:this.calledByEntry.map($=>$.toReference({seenEntityMaps:i.seenEntityMaps})),outputs:this.outputs.map($=>$.toJSONClone({...i,newId:null})),parent:((w=this.parent)==null?void 0:w.toReference({seenEntityMaps:i.seenEntityMaps}))||null,throws:((V=this.throws)==null?void 0:V.toJSONClone({...i,newId:null}))||null})}toReference(i=ct){var s;let n=this.id;return(s=i.seenEntityMaps)!=null&&s.has(this.id)&&(n=i.seenEntityMaps.get(this.id)),{id:n+"--"+x.UUID.uuid()+"--ref",type:d.GenericReference,entityId:n,version:this.version,entityType:this.type}}toShallowJSON(i=ct){var s,c,e,y,m,v;let n=this.id;return(s=i.seenEntityMaps)!=null&&s.has(this.id)&&(n=i.seenEntityMaps.get(this.id)),{id:n,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,x:this.x,y:this.y,defaultValue:((c=this.defaultValue)==null?void 0:c.toReference(i))||null,dataType:((e=this.dataType)==null?void 0:e.toReference(i))||null,readsValue:((y=this.readsValue)==null?void 0:y.toReference(i))||null,outputs:this.outputs.map(E=>E.toReference(i)),calledBySuccess:this.calledBySuccess.map(E=>E.toReference(i)),calledByError:this.calledByError.map(E=>E.toReference(i)),calledByEntry:this.calledByEntry.map(E=>E.toReference(i)),throws:((m=this.throws)==null?void 0:m.toReference(i))||null,parent:((v=this.parent)==null?void 0:v.toReference(i))||null}}toFlatJSON(i=new Set){var s,c;return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...((s=this.defaultValue)==null?void 0:s.toFlatJSON(i))||[],...((c=this.dataType)==null?void 0:c.toFlatJSON(i))||[],...this.outputs.flatMap(e=>e.toFlatJSON(i)),...this.throws?this.throws.toFlatJSON(i):[]])}toGenerationTarget(){return{id:this.id,type:this.type,calledByEntry:this.calledByEntry.map(i=>i.id),calledByError:this.calledByError.map(i=>i.id),calledBySuccess:this.calledBySuccess.map(i=>i.id),parent:this.parent.id}}toFlatGenerationTarget(i=new Set){var s,c;return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...((s=this.defaultValue)==null?void 0:s.toFlatGenerationTarget(i))||[],...((c=this.dataType)==null?void 0:c.toFlatGenerationTarget(i))||[],...this.outputs.flatMap(e=>e.toFlatGenerationTarget(i)),...this.throws?this.throws.toFlatGenerationTarget(i):[]])}clearErrors(){var i,n,s;return this.errors=[],(i=this.dataType)==null||i.clearErrors(),(n=this.defaultValue)==null||n.clearErrors(),this.outputs.forEach(c=>c.clearErrors()),(s=this.throws)==null||s.clearErrors(),this}validate(){return this.errors=Qwe(this),{success:!0}}async validateAsync(i={}){const n=J.YieldTracker.from(i);return this.errors=await Xwe(this,{tracker:n}),{success:!0}}getErrors(){var n,s,c;return[...this.errors,...((n=this.defaultValue)==null?void 0:n.getErrors())||[],...((s=this.dataType)==null?void 0:s.getErrors())||[],...this.outputs.flatMap(e=>e.getErrors()),...((c=this.throws)==null?void 0:c.getErrors())||[]]}async getErrorsAsync(i={}){const n=J.YieldTracker.from(i),s=[...this.errors];if(await n.tick(),this.defaultValue){const c=await this.defaultValue.getErrorsAsync({tracker:n});s.push(...c)}if(this.dataType){const c=await this.dataType.getErrorsAsync({tracker:n});s.push(...c)}for(const c of this.outputs){const e=await c.getErrorsAsync({tracker:n});s.push(...e)}if(this.throws){const c=await this.throws.getErrorsAsync({tracker:n});s.push(...c)}return s}getShallowErrors(){return this.errors}getDefaultValue(){return this.defaultValue||null}setDefaultValue(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"set-default-value"))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setDefaultValue] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("set-default-value",this.id),this;const s=this.defaultValue;if((s==null?void 0:s.id)!==(i==null?void 0:i.id)){if(s==null||s.remove({ignoreUpstream:!0},n),this.defaultValue=i,this.defaultValue){const c=this.readsValue;this.removeValueWriter(n),c==null||c.removeValueReader(this,n)}n==null||n.add(this,H.Affected)}return n==null||n.attemptAutoclose("set-default-value",this.id),this}clone(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.CloneEntity)),n=null,s=null,c=!0){var L,k,K;const e=Rr(n,this),y=this.toJSON(),m=s||x.UUID.uuid();y.outputs=[];const v=m.split("-id"),E=v[v.length-1||0]||m;y.id=m,y.version=x.UUID.uuid(),y.createdAt=(i==null?void 0:i.timestamp)||M().toISOString(),y.author=(i==null?void 0:i.author)||"1",y.previousVersion=null,y.deleted=!1,y.deletable=!0,y.editable=!0;const b=Si(y,e);n?b.setParent(n,i):b.setParent(this.parent,null),c&&b.subscribe(),b.initChildren(i),i==null||i.add(b,H.Added);const w=(L=this.dataType)==null?void 0:L.clone(i,b,x.UUID.uuid(),c);b.setDataType(w||null,i);const V=(k=this.defaultValue)==null?void 0:k.clone(i,b,x.UUID.uuid(),c);b.setDefaultValue(V||null,i);const $=(K=this.outputs)==null?void 0:K.map((S,Y)=>S.clone(i,b,E+"-return-declaration-"+Y+"-id",c));return b.outputs=$,this.throws&&(b.throws=this.throws.clone(i,b,E+"-throws-id",c)),i==null||i.attemptAutoclose(_.CloneEntity,this.id),b}syncInputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"sync-returned-inputs"))){const n=[],s=[],c=[],e=[];if(this.throws&&this.outputs.length&&(!this.parent.implements||this.parent.implements.error))return[...this.outputs].forEach(m=>{var v;if(m.id!==((v=this.throws)==null?void 0:v.id)){const{updated:E,removed:b}=m.remove({ignoreUpstream:!0},i);n.push(...E),c.push(...b),this.removeOutput(m,i)}}),i==null||i.attemptAutoclose("sync-returned-inputs",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this};const y=this.getDataType(i);if(y){const m=[];y!=null&&y.entity&&(y.entity.type===d.DefinitionEntity||y.entity.type===d.BuiltInBaseEntity)&&(y!=null&&y.entity.properties.length)?m.push(y==null?void 0:y.entity):((y==null?void 0:y.orChildrenGroup)||[]).forEach(w=>{w.entity&&(w.entity.type===d.DefinitionEntity||w.entity.type===d.BuiltInBaseEntity)&&w.entity.properties.length&&m.push(w.entity)});const v=m[0],E=(v==null?void 0:v.type)===d.DefinitionEntity||(v==null?void 0:v.type)===d.BuiltInBaseEntity?v.properties:[];return E.filter(w=>Ry(w)&&!this.outputs.find(V=>{var $;return(($=V.declaration)==null?void 0:$.id)===w.id&&(V.declaration.type===d.ValueDescriptor?V.declaration.parentRelationType!==B.ReturnedError:!0)})).forEach(w=>{const V=w.implementAsInputMap(i,this);s.push(V)}),[...this.outputs].forEach(w=>{if(!E.find($=>{var L;return((L=w.declaration)==null?void 0:L.id)===$.id&&(w.declaration.type===d.ValueDescriptor?w.declaration.parentRelationType!==B.ReturnedError:!0)})){const{updated:$,removed:L}=w.remove({ignoreUpstream:!1},i);n.push(...$),c.push(...L),this.removeOutput(w,i)}if(!dA(w)){const{updated:$,removed:L}=w.remove({ignoreUpstream:!1},i);n.push(...$),c.push(...L),this.removeOutput(w,i)}}),i==null||i.attemptAutoclose("sync-returned-inputs",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}return i==null||i.attemptAutoclose("sync-returned-inputs",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}setDataType(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetDataType))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setDataType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.SetDataType,this.id),this;const s=this.dataType;return(s==null?void 0:s.id)!==(i==null?void 0:i.id)&&(s==null||s.remove({ignoreUpstream:!0},n),this.dataType=i,this.subscribeToDependencies(),n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose(_.SetDataType,this.id),this}removeDataType(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveDataType))){return this.checkCanEdit(this,i)?(this.dataType&&(this.dataType.remove({ignoreUpstream:!0},i),i==null||i.add(this,H.Affected),this.dataType=null),i==null||i.attemptAutoclose(_.RemoveDataType,this.id),this):(J.Logger.warn(`[removeDataType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveDataType,this.id),this)}getDataType(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"get-data-type"))){var c,e;if((!this.dataType||this.dataType.inferred)&&this.project.initialized,this.dataType)return i==null||i.attemptAutoclose("get-data-type",this.id),this.dataType;if(this.parent.type===d.GlobalEvent){const y=(c=this.parent.implements)==null?void 0:c.dataType;return i==null||i.attemptAutoclose("get-data-type",this.id),y||null}const n=this.parent.dataType;if(n)return i==null||i.attemptAutoclose("get-data-type",this.id),n;const s=(e=this.parent.implements)==null?void 0:e.dataType;return i==null||i.attemptAutoclose("get-data-type",this.id),s||null}};I(Oi,"repository",{APICreate:async(i,...n)=>i,APIUpdate:async(i,...n)=>i,APIDelete:async(i,...n)=>i,APIClone:async(i,...n)=>{},APILoad:async(i,...n)=>null,APILoadVersion:async(i,n,...s)=>null}),I(Oi,"type",d.ReturnStatement),I(Oi,"USER_MANAGED_PARENT_TYPES",[...nr]),I(Oi,"PARENT_TYPES",[...Oi.USER_MANAGED_PARENT_TYPES]),I(Oi,"MUTABLE_BASE_PROPERTIES",[]),I(Oi,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),I(Oi,"BASE_PROPERTIES",[...Oi.MUTABLE_BASE_PROPERTIES,...Oi.INMUTABLE_BASE_PROPERTIES]),I(Oi,"MUTABLE_META_PROPERTIES",["x","y"]),I(Oi,"INMUTABLE_META_PROPERTIES",[...Oi.INMUTABLE_BASE_PROPERTIES]),I(Oi,"META_PROPERTIES",[...Oi.MUTABLE_META_PROPERTIES,...Oi.INMUTABLE_META_PROPERTIES]),I(Oi,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry","readsValue"]),I(Oi,"INMUTABLE_UPSTREAM_PROPERTIES",["parent"]),I(Oi,"UPSTREAM_PROPERTIES",[...Oi.MUTABLE_UPSTREAM_PROPERTIES,...Oi.INMUTABLE_UPSTREAM_PROPERTIES]),I(Oi,"MUTABLE_DOWNSTREAM_PROPERTIES",["outputs","throws"]),I(Oi,"INMUTABLE_DOWNSTREAM_PROPERTIES",["dataType","defaultValue"]),I(Oi,"DOWNSTREAM_PROPERTIES",[...Oi.MUTABLE_DOWNSTREAM_PROPERTIES,...Oi.INMUTABLE_DOWNSTREAM_PROPERTIES]),I(Oi,"PROPERTIES",[...Oi.META_PROPERTIES,...Oi.UPSTREAM_PROPERTIES,...Oi.DOWNSTREAM_PROPERTIES]);let bd=Oi;async function eOe(o,p={}){const i=J.YieldTracker.from(p),n=iOe(o),s=_v(o),c=[...n,...s],e=Mt(o.errors,c);await i.tick();const y=await qh(o,new Set,{tracker:i});for(const m of o.inputs)await m.validateAsync({tracker:i});for(const m of y)await m.validateAsync({tracker:i});return e}function tOe(o){const p=La(o);o.inputs.forEach(n=>n.validate()),p.forEach(n=>n.validate());const i=[..._v(o),...iOe(o)];return Mt(o.errors,i)}function iOe(o){const p=[];if(!o.calls.length){const i=Ot({id:`${o.id}--${he.ScopeWithoutLogic}`,message:`Action "${se(o,o.project)}" with id "${o.id}" does not have any logic defined. So it doesn't do anything.`,severity:ce.Warning,code:he.ScopeWithoutLogic,entity:o});p.push(i.error)}return Mt(o.errors,p)}const WTi=Object.freeze(Object.defineProperty({__proto__:null,validate:tOe,validateAsync:eOe},Symbol.toStringTag,{value:"Module"})),ci=class ci extends Ur{constructor(i,n){super(i);I(this,"initialData");I(this,"id");I(this,"name");I(this,"description",null);I(this,"x");I(this,"y");I(this,"collapsed");I(this,"type",d.GlobalEvent);I(this,"inputs",[]);I(this,"calls",[]);I(this,"parent");I(this,"implements");I(this,"detachedChildren",[]);I(this,"errors",[]);I(this,"project");I(this,"detachedDependents",{});I(this,"knownVersions",null);I(this,"activeVersion",!1);I(this,"initialized",!1);I(this,"startedInitialization",!1);this.initialData=i,this.project=n,this.id=i.id,this.name=i.name,this.description=i.description,this.x=i.x,this.y=i.y,this.collapsed=i.collapsed}static new(i=null){return{id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||M().toISOString(),author:(i==null?void 0:i.author)||x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.GlobalEvent,name:"",description:"",collapsed:!1,implements:null,inputs:[],parent:null,calls:[],x:0,y:0}}static fromGenerationTarget(i,n){let s=n;if(i.parent){const m=ne(i.parent);s=n.get(m)}let c;i.implements&&(c=n.getBuiltIn(i.implements));const e={id:i.id,version:x.UUID.uuid(),createdAt:M().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,name:i.name,description:i.description||null,deletable:!0,editable:!0,type:d.GlobalEvent,collapsed:!1,calls:[],inputs:[],implements:c,x:0,y:0,parent:s},y=me(e,n);return y.setParent(s,null),y}static validateGenerationTarget(i,n){let s=JSON.parse(JSON.stringify(i));const c=[],e=bn(s,{},n);if(s=e.modifiedData,c.push(...e.errors,...$r(s)),!i.implements)c.push(new De({id:`${i.id}--${Ie.InvalidObjectStructure}`,code:Ie.InvalidObjectStructure,severity:ce.Error,message:`Entity of type '${i.type}' with id '${i.id}' is missing the 'implements' property. This property is required for a '${i.type}' entity and must point to one of the built-in action descriptors reserved for 'global-event' entities.
|
|
45
45
|
${eA(n)}`}));else if(!n.get(i.implements))c.push(new De({id:`${i.id}--${ae.ReferencedEntityNotFound}`,code:ae.ReferencedEntityNotFound,severity:ce.Error,message:`Entity of type '${i.type}' with id '${i.id}' has an 'implements' property that isn't found in the project. The 'implements' property must point to one of the built-in action descriptors reserved for 'global-event' entities.
|
|
46
46
|
${eA(n)}`}));else if(!n.globalEventActionDescriptors.find(v=>v.id===i.implements))c.push(new De({id:`${i.id}--${ae.InvalidImplementsReference}`,code:ae.InvalidImplementsReference,severity:ce.Error,message:`Entity of type '${i.type}' with id '${i.id}' has an 'implements' property that isn't pointing to an action descriptor reserved for 'global-event' entities.
|
|
47
47
|
${eA(n)}`}));else{const v=n.events.find(E=>E.implements.id===i.implements);v&&c.push(new De({id:`${i.id}--${ae.InvalidImplementsReference}`,code:ae.InvalidImplementsReference,severity:ce.Error,message:`Entity of type '${i.type}' with id '${i.id}' has an 'implements' property that points to an action descriptor that is already implemented by another global event with id '${v.id}' in the project. Each global event must implement a unique action descriptor.
|
|
@@ -84,7 +84,7 @@ You can update the existing 'literal-value' with the 'update' action, for exampl
|
|
|
84
84
|
}
|
|
85
85
|
}\`\`\`
|
|
86
86
|
Or 'delete' and then 'post' actions to replace it.`})):i.push(new De({id:`${o.id}--${o.parent}--${ae.InvalidParentReference}`,code:ae.InvalidParentReference,severity:ce.Error,message:`Entity of type "${o.type}" with id "${o.id}", has a parent reference that isn't pointing to an entity of type 'input-map' or 'data-type'.`})):i.push(new De({id:`${o.id}--${o.parent}--${ae.ReferencedEntityNotFound}`,code:ae.ReferencedEntityNotFound,severity:ce.Error,message:`Entity of type "${o.type}" with id "${o.id}", is referencing an entity with id "${o.parent}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`}))}else i.push(new De({id:`${o.id}--${Ie.InvalidObjectStructure}`,code:Ie.InvalidObjectStructure,severity:ce.Error,message:`Entity of type "${o.type}" with id "${o.id}" is missing a 'parent' reference. The 'parent' of a literal value entity must be a reference to an entity of type 'input-map' or 'data-type'.`}));else return i.push(new De({id:`${o.id}--${Ie.InvalidObjectStructure}`,code:Ie.InvalidObjectStructure,severity:ce.Error,message:`Entity of type "${o.type}" with id "${o.id}" is missing a 'parent' reference. The 'parent' of a literal value entity must be a reference to an entity of type 'input-map' or 'data-type'.`})),i;if(o.valueAsTypeSingle){const c=[],e=[],y=o.valueAsTypeSingle;Array.isArray(y)?y.forEach(m=>{typeof m=="string"?e.push(m):c.push(m)}):typeof y=="string"?e.push(y):c.push(y),c.forEach(m=>{const v=RR(m);i.push(...v),v.length===0&&e.push(m.entityId)}),e.forEach(m=>{const v=p.get(m);v?[d.DefinitionEntity,d.BuiltInBaseEntity].includes(v.type)||i.push(new De({id:`${o.id}--${m}--${ae.InvalidImplementsReference}`,code:ae.InvalidImplementsReference,severity:ce.Error,message:`Entity of type "${o.type}" with id "${o.id}", has an 'valueAsTypeSingle' reference that isn't pointing to an entity of type 'definition-entity', 'function-declaration' or 'operation'.`})):i.push(new De({id:`${o.id}--${m}--${ae.ReferencedEntityNotFound}`,code:ae.ReferencedEntityNotFound,severity:ce.Error,message:`Entity of type "${o.type}" with id "${o.id}", is referencing an entity with id "${m}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`}))})}return i}var cOe=(o=>(o.ValueAsTypeSingle="value-as-type-single",o.ValueAsTypeList="value-as-type-list",o))(cOe||{});const yi=class yi extends Ur{constructor(i,n){super(i);I(this,"initialData");I(this,"type",d.LiteralValue);I(this,"id");I(this,"name");I(this,"autogeneration",null);I(this,"value",null);I(this,"valueAsTypeSingle",null);I(this,"valueAsTypeList",null);I(this,"errors",[]);I(this,"parent");I(this,"standaloneParent");I(this,"project");I(this,"detachedDependents",{});I(this,"knownVersions",null);I(this,"activeVersion",!1);I(this,"initialized",!1);I(this,"startedInitialization",!1);I(this,"standalone",!1);if(this.initialData=i,this.project=n,this.id=i.id,this.name=i.name,this.autogeneration=i.autogeneration,this.value=i.value,!this.name)throw new Error("[LiteralValueState.constructor] Must have a name in the initial data passed to the constructor")}static new(i=null){return{id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||M().toISOString(),author:(i==null?void 0:i.author)||x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.LiteralValue,standaloneParent:null,name:"",autogeneration:null,value:null,valueAsTypeSingle:null,valueAsTypeList:null,parent:null}}static fromGenerationTarget(i,n){const s=ne(i.parent),c=n.get(s);let e=null,y=null;i.valueAsTypeList?Array.isArray(i.valueAsTypeList)&&(y=i.valueAsTypeList.map(E=>n.get(E)||n.getBuiltIn(E))):i.valueAsTypeSingle&&(e=n.get(i.valueAsTypeSingle)||n.getBuiltIn(i.valueAsTypeSingle));const m={id:i.id,version:x.UUID.uuid(),createdAt:M().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.LiteralValue,standaloneParent:null,name:i.name,autogeneration:i.autogeneration,valueAsTypeSingle:e,valueAsTypeList:y,value:i.value||null,parent:c},v=me(m,n);return v.setParent(c,null),v}static validateGenerationTarget(i,n){let s=JSON.parse(JSON.stringify(i));const c=[],e=ivi(s,n);return c.push(...e,...$r(s)),{errors:c,modifiedData:s}}get valueAsType(){return this.valueAsTypeSingle?this.valueAsTypeSingle:this.valueAsTypeList?this.valueAsTypeList:null}get isFinal(){return!!(this.parent.type===d.Property&&(this.parent.constant||this.parent.implements.some(i=>i.constant))||this.parent.type===d.Property&&this.parent.parent.type===d.DefinitionEntity&&!df(this.parent.parent))}validateGeneratedUpdate(i){const n=[];return i.parent&&n.push(new De({id:`${this.id}--${ae.InvalidParentUpdate}`,code:ae.InvalidParentUpdate,severity:ce.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated, as it would mean moving the '${this.type}' entity to another parent entity.
|
|
87
|
-
This is likely an incorrect strategy, either the '${this.type}' entity doesn't need to be updated or it should be deleted and a new one created in the desired parent.`})),{errors:n,modifiedData:i}}subscribeDependents(i){return i.forEach(n=>{this.detachedDependents[n.entity.id]||(this.detachedDependents[n.entity.id]=n)}),this}unsubscribeDependents(i){return i.forEach(n=>{this.detachedDependents[n.entity.id]&&delete this.detachedDependents[n.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"sync-dependents"))){const n=[],s=[],c=[],e=[];return Object.values(this.detachedDependents).forEach(y=>{const m=y.entity.afterAllChildrenInitialized(i);n.push(...m.updated),s.push(...m.added),c.push(...m.removed),e.push(...m.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}onDetachedDependencyRemoved(i,n,s){const c=[],e=[],y=[],m=[];return n==="value-as-type-single"&&(this.valueAsTypeSingle=null,s==null||s.add(this,H.Updated)),n==="value-as-type-list"&&(this.valueAsTypeList=(this.valueAsTypeList||[]).filter(v=>v.id!==i.id),s==null||s.add(this,H.Updated)),{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:this}}onDetachedDependencyRestored(i,n,s){const c=[],e=[],y=[],m=[];return n==="value-as-type-single"&&(this.valueAsTypeSingle=i,s==null||s.add(this,H.Updated)),n==="value-as-type-list"&&(this.valueAsTypeList=[...Array.isArray(this.valueAsTypeList||[])?this.valueAsTypeList:[],i],s==null||s.add(this,H.Updated)),{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:this}}unsubscribeFromDependencies(){return this.valueAsTypeSingle&&this.valueAsTypeSingle.type!==d.BuiltInBaseEntity&&this.valueAsTypeSingle.unsubscribeDependents([{entity:this,field:"value-as-type-single"}]),this.valueAsTypeList&&Array.isArray(this.valueAsTypeList)&&this.valueAsTypeList.forEach(i=>{i.type!==d.BuiltInBaseEntity&&i.unsubscribeDependents([{entity:this,field:"value-as-type-list"}])}),this}subscribeToDependencies(){return!this.valueAsTypeSingle&&!this.valueAsTypeList?this:(this.valueAsTypeList&&Array.isArray(this.valueAsTypeList)?this.valueAsTypeList.forEach(i=>{i.type!==d.BuiltInBaseEntity&&i.subscribeDependents([{entity:this,field:"value-as-type-list"}])}):this.valueAsTypeSingle&&this.valueAsTypeSingle.type!==d.BuiltInBaseEntity&&this.valueAsTypeSingle.subscribeDependents([{entity:this,field:"value-as-type-single"}]),this)}increaseVersion(i){if(i&&!M(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&M(i).isSame(M(this.createdAt))?this:(this.previousVersion=this.version,this.version=x.UUID.uuid(),this.createdAt=M(i).toISOString()||M().toISOString(),this)}captureVersion(){var n;const i=((n=this.knownVersions)==null?void 0:n.get(this.version))||new yi(this,this.project);return i.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map([[this.version,i]]),i.valueAsTypeSingle=this.valueAsTypeSingle,i.valueAsTypeList=this.valueAsTypeList?[...this.valueAsTypeList]:this.valueAsTypeList,i.parent=this.parent,this}recursiveCaptureUpstreamVersions(i){const n=[],s=[],c=[],e=[];if(this.parent){this.parent.increaseVersion(i);const y=this.parent.recursiveCaptureUpstreamVersions(i);n.push(this.parent,...y.updated),s.push(...y.added),c.push(...y.removed)}return{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}async restoreVersion(i){var m;const n=[],s=[],c=[],e=[];if(this.version===i)return{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this};if(!this.knownVersions){const v=new Map;for(const[E,b]of this.knownVersions||new Map){if(v.set(E,b),b.activeVersion=!1,b.knownVersions)for(const[w,V]of b.knownVersions)v.set(w,V);b.knownVersions=null}}let y=(m=this.knownVersions)==null?void 0:m.get(i);if(!y){const v=await this.APILoadVersion({},i);if(!v)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);y=new yi(v,this.project)}return this.metaSync(y.toShallowJSON(),null),this.previousVersion=y.previousVersion,this.version=y.version,this.createdAt=y.createdAt,this.author=y.author,this.deleted=y.deleted,this.valueAsTypeSingle=y.valueAsTypeSingle,this.parent=y.parent,{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}updateWithShallowTransfer(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.UpdateWithShallowTransfer))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[updateWithShallowTransfer] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),this;if(this.metaSync(i,n),this.version=i.version,this.createdAt=i.createdAt,this.author=i.author,this.deleted=i.deleted,this.previousVersion=i.previousVersion,i.parent&&i.standaloneParent)throw new Error(`Entity with id '${this.id}' cannot have both 'parent' and 'standaloneParent' properties set.`);if(i.parent){const s=ne(i.parent),c=this.project.get(s),e=this.parent;if(e&&e.id!==(c==null?void 0:c.id)&&this.removeFromParent(n),c)this.setParent(c,n),this.addSelfToProject(n);else throw new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${s}' that isn't found in the project`)}else if(i.standaloneParent){const s=ne(i.standaloneParent),c=this.project.get(s);if(c)this.setStandaloneParent(c,n);else throw new Error(`${this.type} with id '${this.id}' has a 'standaloneParent' reference '${s}' that isn't found in the project`)}else throw new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(i.valueAsTypeList&&Array.isArray(i.valueAsTypeList))this.valueAsTypeList=this.valueAsTypeList||[],i.valueAsTypeList.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&this.addValueAsTypeToList(e,n)}),[...this.valueAsTypeList].forEach(s=>{(i.valueAsTypeList||[]).find(e=>ne(e)===s.id)||this.removeValueAsTypeFromList(s,n)}),this.setValueAsTypeSingle(null,n),this.metaSync({value:null},n);else if(i.valueAsTypeSingle){const s=ne(i.valueAsTypeSingle),c=this.project.get(s);c&&(this.setValueAsTypeSingle(c,n),this.setValueAsTypeList(null,n),this.metaSync({value:null},n))}else this.setValueAsTypeSingle(null,n),this.setValueAsTypeList(null,n);return this.captureVersion(),this.subscribeToDependencies(),n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),this}hydrateAncestors(){const i=[],n=[],s=[],c=[];if(this.initialData.parent&&this.initialData.standaloneParent)throw new Error(`Entity with id '${this.id}' cannot have both 'parent' and 'standaloneParent' properties set.`);if(this.initialData.parent){const e=ne(this.initialData.parent),y=this.project.get(e);if(J.Logger.log(`[LiteralValueState.hydrateAncestors] Hydrating parent reference '${e}' for entity with id '${this.id}'`),y)J.Logger.log(`[LiteralValueState.hydrateAncestors] Setting parent reference '${y.id}' for entity with id '${this.id}'`),this.setParent(y,null),i.push(y);else throw J.Logger.error(`[LiteralValueState.hydrateAncestors] Parent reference '${e}' for entity with id '${this.id}' not found in the project`),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${e}' that isn't found in the project`)}else if(this.initialData.standaloneParent){const e=ne(this.initialData.standaloneParent),y=this.project.get(e);if(J.Logger.log(`[LiteralValueState.hydrateAncestors] Hydrating standalone parent reference '${e}' for entity with id '${this.id}'`),y)J.Logger.log(`[LiteralValueState.hydrateAncestors] Setting standalone parent reference '${y.id}' for entity with id '${this.id}'`),this.setStandaloneParent(y,null);else throw J.Logger.error(`[LiteralValueState.hydrateAncestors] Standalone parent reference '${e}' for entity with id '${this.id}' not found in the project`),new Error(`${this.type} with id '${this.id}' has a 'standaloneParent' reference '${e}' that isn't found in the project`)}else throw J.Logger.error(`[LiteralValueState.hydrateAncestors] Entity with id '${this.id}' must have a 'parent'`),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(this.initialData.valueAsTypeList&&Array.isArray(this.initialData.valueAsTypeList))this.valueAsTypeList=this.valueAsTypeList||[],this.initialData.valueAsTypeList.forEach(e=>{const y=ne(e),m=this.project.get(y);m&&this.valueAsTypeList.push(m)});else if(this.initialData.valueAsTypeSingle){const e=ne(this.initialData.valueAsTypeSingle),y=this.project.get(e);y&&(this.valueAsTypeSingle=y)}return{updated:D(i),added:D(n),removed:D(s),affected:D(c),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AfterAllChildrenInitialized))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[afterAllChildrenInitialized] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.AfterAllChildrenInitialized,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];return this.initialized=!0,this.captureVersion(),i==null||i.attemptAutoclose(_.AfterAllChildrenInitialized,this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}addSelfToProject(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"add-self-to-project"))){var y,m;const n=[this],s=[],c=[],e=[];return((y=this.parent)==null?void 0:y.type)===d.DataType?this.parent.setEntity(this,i):(m=this.parent)==null||m.setDefaultValue(this,i),e.push(this.parent),this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}setParent(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetParent))){var s;return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.SetParent,n)?(((s=this.parent)==null?void 0:s.id)!==(i==null?void 0:i.id)&&(this.parent=i,n&&(n==null||n.add(this,H.Updated))),n==null||n.attemptAutoclose(_.SetParent,this.id),this):this}setStandaloneParent(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetStandaloneParent))){var s;return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.SetStandaloneParent,n)?(((s=this.standaloneParent)==null?void 0:s.id)!==(i==null?void 0:i.id)&&(this.standaloneParent=i,n&&(n==null||n.add(this,H.Updated))),n==null||n.attemptAutoclose(_.SetStandaloneParent,this.id),this):this}addValueAsTypeToList(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddValueAsTypeToList))){return this.checkCanEdit(this,n)?((this.valueAsTypeList||[]).includes(i)||(this.valueAsTypeList=this.valueAsTypeList||[],this.valueAsTypeList.push(i),this.value!==null&&this.metaSync({value:null},n),this.valueAsTypeSingle!==null&&(this.valueAsTypeSingle=null,n==null||n.add(this,H.Updated)),n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose(_.AddValueAsTypeToList,this.id),this):(J.Logger.warn(`[addValueAsTypeToList] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.AddValueAsTypeToList,this.id),this)}removeValueAsTypeFromList(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveValueAsTypeFromList))){return this.checkCanEdit(this,n)?(this.valueAsTypeList&&Array.isArray(this.valueAsTypeList)&&(this.valueAsTypeList||[]).includes(i)&&(this.valueAsTypeList=this.valueAsTypeList.filter(s=>s.id!==i.id),this.valueAsTypeList.length===0?this.valueAsTypeList=null:(this.value!==null&&this.metaSync({value:null},n),this.valueAsTypeSingle!==null&&(this.valueAsTypeSingle=null,n==null||n.add(this,H.Updated))),n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose(_.RemoveValueAsTypeFromList,this.id),this):(J.Logger.warn(`[removeValueAsTypeFromList] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.RemoveValueAsTypeFromList,this.id),this)}setValueAsTypeSingle(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetValueAsTypeSingle))){return this.checkCanEdit(this,n)?(this.valueAsTypeSingle!==i&&(this.valueAsTypeSingle=i,n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose(_.SetValueAsTypeSingle,this.id),this):(J.Logger.warn(`[setValueAsTypeSingle] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.SetValueAsTypeSingle,this.id),this)}setValueAsTypeList(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetValueAsTypeList))){var s,c;return this.checkCanEdit(this,n)?(!i&&this.valueAsTypeList?(this.valueAsTypeList=null,n==null||n.add(this,H.Updated)):i&&!this.valueAsTypeList?(this.valueAsTypeList=i,n==null||n.add(this,H.Updated)):i&&this.valueAsTypeList&&((s=this.valueAsTypeList)==null?void 0:s.length)!==i.length?(this.valueAsTypeList=i,n==null||n.add(this,H.Updated)):i&&this.valueAsTypeList&&((c=this.valueAsTypeList)!=null&&c.every((e,y)=>e!==i[y]))&&(this.valueAsTypeList=i,n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose(_.SetValueAsTypeList,this.id),this):(J.Logger.warn(`[setValueAsTypeList] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.SetValueAsTypeList,this.id),this)}setValueAsType(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetValueAsType))){return this.checkCanEdit(this,n)?i?(Array.isArray(i)?this.setValueAsTypeList(i,n):this.setValueAsTypeSingle(i,n),n==null||n.attemptAutoclose(_.SetValueAsType,this.id),this):(this.setValueAsTypeSingle(null,n),this.setValueAsTypeList(null,n),this):(J.Logger.warn(`[setValueAsType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.SetValueAsType,this.id),this)}initChildren(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"init-children"))){if(this.initialized||this.startedInitialization)return this;if(this.startedInitialization=!0,this.standalone){if(this.initialData.valueAsTypeList&&Array.isArray(this.initialData.valueAsTypeList))this.valueAsTypeList=this.initialData.valueAsTypeList.map(n=>{if(n.type===d.GenericReference){const c=this.project.findSubscribedBuiltInInstanceFromReference(n);if(!c)throw new Error(`Standalone entity of type '${this.type}' with id '${this.id}' has a reference to an entity of type '${n.entityType}' with id '${n.entityId}' that is not part of the project state.`);return c}const s=this.project.get(n.id);if(!s)throw new Error(`Standalone entity of type '${this.type}' with id '${this.id}' has a reference to an entity of type '${n.type}' with id '${n.id}' that is not part of the project state.`);return s});else if(this.initialData.valueAsTypeSingle){if(this.initialData.valueAsTypeSingle.type===d.GenericReference){const s=this.project.findSubscribedBuiltInInstanceFromReference(this.initialData.valueAsTypeSingle);if(!s)throw new Error(`Standalone entity of type '${this.type}' with id '${this.id}' has a reference to an entity of type '${this.initialData.valueAsTypeSingle.entityType}' with id '${this.initialData.valueAsTypeSingle.entityId}' that is not part of the project state.`);return this.valueAsTypeSingle=s,this}const n=this.project.get(this.initialData.valueAsTypeSingle.id);if(!n)throw new Error(`Standalone entity of type '${this.type}' with id '${this.id}' has a reference to an entity of type '${this.initialData.valueAsTypeSingle.type}' with id '${this.initialData.valueAsTypeSingle.id}' that is not part of the project state.`);this.valueAsTypeSingle=n}return this}if(this.initialData.valueAsTypeList&&Array.isArray(this.initialData.valueAsTypeList))this.valueAsTypeList=this.initialData.valueAsTypeList.map(n=>{if(n.type===d.GenericReference){const c=this.project.findSubscribedBuiltInInstanceFromReference(n);if(!c)throw new Error(`Standalone entity of type '${this.type}' with id '${this.id}' has a reference to an entity of type '${n.entityType}' with id '${n.entityId}' that is not part of the project state.`);return c}const s=this.project.get(n.id);if(!s)throw new Error(`Standalone entity of type '${this.type}' with id '${this.id}' has a reference to an entity of type '${n.type}' with id '${n.id}' that is not part of the project state.`);return s});else if(this.initialData.valueAsTypeSingle){if(this.initialData.valueAsTypeSingle.type===d.GenericReference){const s=ne(this.initialData.valueAsTypeSingle),c=s?this.project.get(s):null;if(!c)throw new Error(`Standalone entity of type '${this.type}' with id '${this.id}' has a reference to an entity of type '${this.initialData.valueAsTypeSingle.entityType}' with id '${this.initialData.valueAsTypeSingle.entityId}' that is not part of the project state.`);return this.valueAsTypeSingle=c,this}const n=this.project.get(this.initialData.valueAsTypeSingle.id);if(!n)throw new Error(`Standalone entity of type '${this.type}' with id '${this.id}' has a reference to an entity of type '${this.initialData.valueAsTypeSingle.type}' with id '${this.initialData.valueAsTypeSingle.id}' that is not part of the project state.`);this.valueAsTypeSingle=n}return this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this}subscribe(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"meta-sync"))){const s=Mr(this,i,n),c=Lr(this,s),e=this.toMeta();return this.name=s.name!==void 0?s.name:e.name,this.autogeneration=s.autogeneration!==void 0?s.autogeneration:e.autogeneration,this.value=s.value!==void 0?s.value:e.value,super.baseMetaSync(s,this,n),s.deleted===!0&&!e.deleted?n==null||n.add(this,H.Removed):s.deleted===!1&&e.deleted?n==null||n.add(this,H.Added):c&&(n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=ke,...n){return await yi.repository.APILoad(this.id,...n),this}async APICreate(i=ke,...n){return await yi.repository.APICreate(this.toShallowJSON(),...n),this}async APIUpdate(i=ke,...n){return await yi.repository.APIUpdate(this.toShallowJSON(),...n),this}async APIDelete(i=ke,...n){return await yi.repository.APIDelete(this.toShallowJSON(),...n),this}async APIClone(i=ke,...n){return await yi.repository.APIClone(this.id,...n),this}async APILoadVersion(i=ke,n,...s){return await yi.repository.APILoadVersion(this.id,n,...s)}removeFromParent(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveFromParent))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[removeFromParent] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveFromParent,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];return this.parent&&(this.parent.type===d.DataType?this.parent.setEntity(null,i):kA.includes(this.parent.type)&&this.parent.setDefaultValue(null,i),e.push(this.parent)),i==null||i.attemptAutoclose(_.RemoveFromParent,this.id),{added:D(c),updated:D(n),removed:D(s),affected:D(e),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveEntity))){var m;if(!this.checkCanDelete(this,n))return J.Logger.warn(`[remove] User is not allowed to delete or edit this ${this.type} entity with id: ${this.id}`),n==null||n.event({id:`${_.RemoveEntity}-${this.id}`,action:_.RemoveEntity,owner:this,errorReason:Ii.ActionOwnerEntityNonDeletable,rootAction:((m=n==null?void 0:n.self)==null?void 0:m.id)===this.id&&(n==null?void 0:n.autoCloseActionName)===_.RemoveEntity}),n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const s=[],c=[],e=[],y=[];if(n!=null&&n.hasRemoved(this.id))return n==null||n.attemptAutoclose(_.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},n),Object.values(this.detachedDependents).forEach(v=>{const{updated:E,removed:b,added:w}=v.entity.onDetachedDependencyRemoved(this,v.field,n);s.push(...E),c.push(...b),e.push(...w)}),!i){const v=this.removeFromParent(n);e.push(...v.added),s.push(...v.updated),c.push(...v.removed),y.push(...v.affected)}return n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:D(e),updated:D(s),removed:D(c),affected:D(y),self:this}}restore({}={},i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RestoreEntity))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[restore] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];return i!=null&&i.hasAdded(this.id)?(i==null||i.attemptAutoclose(_.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(y=>{const{updated:m,removed:v,added:E}=y.entity.onDetachedDependencyRestored(this,y.field,i);s.push(...m),c.push(...v),n.push(...E)}),i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this})}toFlat(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this,...this.valueAsTypeSingle?this.valueAsTypeSingle.toFlat(i):[],...this.valueAsTypeList&&Array.isArray(this.valueAsTypeList)?this.valueAsTypeList.flatMap(s=>s.toFlat(i)):[]])}toFlatIds(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.valueAsTypeSingle?this.valueAsTypeSingle.toFlatIds(i):[],...this.valueAsTypeList&&Array.isArray(this.valueAsTypeList)?this.valueAsTypeList.flatMap(s=>s.toFlatIds(i)):[]])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,value:this.value,autogeneration:this.autogeneration,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name}}toJSON(i=new Set){var n,s,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,autogeneration:this.autogeneration,value:this.value,valueAsTypeSingle:((n=this.valueAsTypeSingle)==null?void 0:n.toJSON(i))||null,valueAsTypeList:Array.isArray(this.valueAsTypeSingle)?this.valueAsTypeSingle.map(e=>e.toJSON(i)):null,parent:(s=this.parent)==null?void 0:s.toReference(),standaloneParent:(c=this.standaloneParent)==null?void 0:c.toReference()})}toJSONClone(i=ct){var s,c,e,y,m,v,E;let n;return(s=i.seenEntityMaps)!=null&&s.has(this.id)?n=i.seenEntityMaps.get(this.id):(n=i.newId||jr(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,n)),(c=i.seenEntities)!=null&&c.has(n)||(e=i.seenEntities)!=null&&e.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((y=i.seenEntities)==null||y.add(n),(m=i.seenEntities)==null||m.add(this.id),{id:n,version:x.UUID.uuid(),createdAt:i.timestamp||M().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name,autogeneration:this.autogeneration,value:this.value,valueAsTypeSingle:this.valueAsTypeSingle?this.project.getBuiltIn(this.valueAsTypeSingle.id)?this.valueAsTypeSingle.toJSON():this.valueAsTypeSingle.toJSONClone({...i,newId:null}):null,valueAsTypeList:this.valueAsTypeSingle&&Array.isArray(this.valueAsTypeSingle)?this.valueAsTypeSingle.map(b=>this.project.getBuiltIn(b.id)?b.toJSON(i.seenEntities):b.toJSONClone({...i,newId:null})):null,parent:(v=this.parent)==null?void 0:v.toReference({seenEntityMaps:i.seenEntityMaps}),standaloneParent:(E=this.standaloneParent)==null?void 0:E.toReference({seenEntityMaps:i.seenEntityMaps})})}toReference(i=ct){var s;let n=this.id;return(s=i.seenEntityMaps)!=null&&s.has(this.id)&&(n=i.seenEntityMaps.get(this.id)),{id:n+"--"+x.UUID.uuid()+"--ref",type:d.GenericReference,entityId:n,version:this.version,entityType:this.type}}toShallowJSON(i=ct){var s,c,e,y;let n=this.id;return(s=i.seenEntityMaps)!=null&&s.has(this.id)&&(n=i.seenEntityMaps.get(this.id)),{id:n,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,valueAsTypeSingle:((c=this.valueAsTypeSingle)==null?void 0:c.toReference(i))||null,valueAsTypeList:Array.isArray(this.valueAsTypeSingle)?this.valueAsTypeSingle.map(m=>m.toReference(i)):null,value:this.value,autogeneration:this.autogeneration,parent:(e=this.parent)==null?void 0:e.toReference(i),standaloneParent:(y=this.standaloneParent)==null?void 0:y.toReference(i)}}toFlatJSON(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...this.valueAsTypeSingle?this.valueAsTypeSingle.toFlatJSON(i):[],...this.valueAsTypeList&&Array.isArray(this.valueAsTypeList)?this.valueAsTypeList.flatMap(s=>s.toFlatJSON(i)):[]])}toGenerationTarget(){var i,n,s;return{id:this.id,type:this.type,name:this.name,valueAsTypeSingle:((i=this.valueAsTypeSingle)==null?void 0:i.id)||null,valueAsTypeList:Array.isArray(this.valueAsTypeSingle)?this.valueAsTypeSingle.map(c=>c.id):null,value:this.value,autogeneration:this.autogeneration,parent:(n=this.parent)==null?void 0:n.id,standaloneParent:(s=this.standaloneParent)==null?void 0:s.id}}toFlatGenerationTarget(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...this.valueAsTypeSingle?this.valueAsTypeSingle.toFlatGenerationTarget(i):[],...this.valueAsTypeList&&Array.isArray(this.valueAsTypeList)?this.valueAsTypeList.flatMap(s=>s.toFlatGenerationTarget(i)):[]])}clearErrors(){return this.errors=[],this}validate(){return this.errors=pOe(this),{success:!0}}async validateAsync(i={}){const n=J.YieldTracker.from(i);return this.errors=await uOe(this,{tracker:n}),{success:!0}}getErrors(){return[...this.errors]}async getErrorsAsync(i={}){const n=J.YieldTracker.from(i),s=[...this.errors];return await n.tick(),s}getShallowErrors(){return this.errors}clone(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.CloneEntity)),n=null,s=null,c=!0){const e=Rr(n,this),y=this.toJSON(),m=s||x.UUID.uuid();y.id=m,y.version=x.UUID.uuid(),y.createdAt=(i==null?void 0:i.timestamp)||M().toISOString(),y.author=(i==null?void 0:i.author)||"1",y.previousVersion=null,y.deleted=!1,y.editable=!0,y.deletable=!0;const v=Si(y,e);return v.hydrateAncestors(),n&&v.setParent(n,i),c&&(v.subscribe(),v.addSelfToProject(i)),i==null||i.add(v,H.Added),v.initChildren(i),i==null||i.attemptAutoclose(_.CloneEntity,this.id),v}merge(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"merge-literal-value"))){const s=[],c=[],e=[],y=[];return this.valueAsTypeSingle!==(i==null?void 0:i.valueAsTypeSingle)&&(this.setValueAsType(i.valueAsTypeSingle,n),s.push(this)),this.valueAsTypeList!==i.valueAsTypeList&&(this.setValueAsTypeList(i.valueAsTypeList,n),s.push(this)),this.value!==i.value&&(this.metaSync({value:i.value},n),s.push(this)),this.autogeneration!==i.autogeneration&&(this.metaSync({autogeneration:i.autogeneration},n),s.push(this)),this.name!==i.name&&(this.metaSync({name:i.name},n),s.push(this)),n==null||n.attemptAutoclose("merge-literal-value",this.id),{updated:D(s),added:D(c),removed:D(e),affected:D(y),self:this}}};I(yi,"repository",{APICreate:async(i,...n)=>i,APIUpdate:async(i,...n)=>i,APIDelete:async(i,...n)=>i,APIClone:async(i,...n)=>{},APILoad:async(i,...n)=>null,APILoadVersion:async(i,n,...s)=>null}),I(yi,"type",d.LiteralValue),I(yi,"USER_MANAGED_PARENT_TYPES",[d.DataType,d.InputMap,d.Property,d.ArgumentDeclaration,d.ReturnStatement,d.BreakStatement,d.ContinueStatement,d.VariableDeclaration,d.VariableInstance,d.ValueDescriptor,d.OutputMap]),I(yi,"PARENT_TYPES",[...yi.USER_MANAGED_PARENT_TYPES]),I(yi,"MUTABLE_BASE_PROPERTIES",["name","autogeneration","value"]),I(yi,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),I(yi,"BASE_PROPERTIES",[...yi.MUTABLE_BASE_PROPERTIES,...yi.INMUTABLE_BASE_PROPERTIES]),I(yi,"MUTABLE_META_PROPERTIES",[...yi.MUTABLE_BASE_PROPERTIES]),I(yi,"INMUTABLE_META_PROPERTIES",[...yi.INMUTABLE_BASE_PROPERTIES]),I(yi,"META_PROPERTIES",[...yi.MUTABLE_META_PROPERTIES,...yi.INMUTABLE_META_PROPERTIES]),I(yi,"MUTABLE_UPSTREAM_PROPERTIES",[]),I(yi,"INMUTABLE_UPSTREAM_PROPERTIES",["parent"]),I(yi,"UPSTREAM_PROPERTIES",[...yi.MUTABLE_UPSTREAM_PROPERTIES,...yi.INMUTABLE_UPSTREAM_PROPERTIES]),I(yi,"MUTABLE_DOWNSTREAM_PROPERTIES",["valueAsTypeSingle","valueAsTypeList"]),I(yi,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),I(yi,"DOWNSTREAM_PROPERTIES",[...yi.MUTABLE_DOWNSTREAM_PROPERTIES,...yi.INMUTABLE_DOWNSTREAM_PROPERTIES]),I(yi,"PROPERTIES",[...yi.META_PROPERTIES,...yi.UPSTREAM_PROPERTIES,...yi.DOWNSTREAM_PROPERTIES]);let Yr=yi;function ef(o){if(typeof crypto<"u"&&typeof crypto.getRandomValues=="function"){const i=new Uint8Array(o);return crypto.getRandomValues(i),i}const{randomBytes:p}=require("crypto");return p(o)}function fOe(o,p){const i=p-o+1,s=KI()*i;return Math.floor(s)+o}function yOe(){const o=ef(4);return(o[0]<<24|o[1]<<16|o[2]<<8|o[3])>>>0}function KI(){return yOe()/2**32}function GP(o){const p=ef(o);return Array.from(p).map(i=>i.toString(16).padStart(2,"0")).join("")}const ZO="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";function kP(o){let p="";const i=ef(o);for(let n=0;n<o;n++)p+=ZO[i[n]%ZO.length];return p}function hOe(o){const p=ef(o);let i;if(typeof Buffer<"u")i=Buffer.from(p).toString("base64");else{const n=String.fromCharCode(...p);i=btoa(n)}return i.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function jP(o){return kP(o)}function UP(o,p=ZO){let i="";const n=ef(o);for(let s=0;s<o;s++)i+=p[n[s]%p.length];return i}function Du(){const o=ef(16);o[6]=o[6]&15|64,o[8]=o[8]&63|128;const p=Array.from(o).map(i=>i.toString(16).padStart(2,"0")).join("");return[p.slice(0,8),p.slice(8,12),p.slice(12,16),p.slice(16,20),p.slice(20,32)].join("-")}function mOe(){return UP(6)}function TOe(){return GP(32)}const rvi=63,nvi=/^[a-z][a-z0-9-]*[a-z0-9]$/;function avi(o){return o.length>=1&&o.length<=rvi&&nvi.test(o)&&!o.includes("--")}function*svi(){yield"";const o="abcdefghijklmnopqrstuvwxyz";for(let p=1;;p++){const i=new Array(p).fill(0);let n=!1;for(;!n;){yield i.map(s=>o[s]).join("");for(let s=p-1;s>=0&&(i[s]++,!(i[s]<o.length));s--)i[s]=0,s===0&&(n=!0)}}}function lvi(o,p){const i=new Set(o.map(s=>s.toLowerCase())),n=p>0?"secondary-db":"main";for(const s of svi()){const c=s?`${n}-${s}`:n;if(avi(c)&&!i.has(c))return c}throw new Error("Unable to generate identifier")}function vOe(o,p){switch(o.id){case Q["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.id:{const i=o.project.entities.filter(m=>!!m.implements.find(v=>v.id===Q["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id)),n=i.find(m=>{const v=m.properties.find(w=>w.implements.find(V=>V.id===Q["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id)),E=v==null?void 0:v.getDefaultValue();return(E==null?void 0:E.value)===!0});if(!n&&i.length){const v=i[0].properties.find(b=>b.implements.find(w=>w.id===Q["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id)),E=v==null?void 0:v.defaultValue;if(E)E.metaSync({value:!0},p);else if(v!=null&&v.dataType){const b={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(p==null?void 0:p.timestamp)||new Date().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.LiteralValue,standaloneParent:null,name:oe.EntityTemplate,autogeneration:null,value:!0,valueAsTypeSingle:null,valueAsTypeList:null,parent:v==null?void 0:v.toReference()},w=me(b,o.project);return w.setParent(v,p),w.initChildren(p),p==null||p.add(w,H.Added),w.addSelfToProject(p),{newEntities:[w]}}return{newEntities:[]}}else if(n)return{newEntities:[]};const s=o.project.get(Q["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id),c=FI(s,"Main database",p);if(c.errors.length>0)return{newEntities:[]};const e=c.properties.find(m=>m.implements.find(v=>v.id===Q["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id)),y=e==null?void 0:e.defaultValue;if(y)y.metaSync({value:!0},p);else if(e!=null&&e.dataType){const m={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(p==null?void 0:p.timestamp)||new Date().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.LiteralValue,standaloneParent:null,name:oe.EntityTemplate,autogeneration:null,value:!0,valueAsTypeSingle:null,valueAsTypeList:null,parent:e==null?void 0:e.toReference()},v=me(m,o.project);v.setParent(e,p),v.initChildren(p),p==null||p.add(v,H.Added),v.addSelfToProject(p)}return{newEntities:[c]}}}return{newEntities:[]}}function EOe(o,p){const i=[],n=[],s=[],c=[];return o.implements.filter(y=>y.type===d.BuiltInBaseEntity).forEach(y=>{var m,v,E,b,w;switch(y.id){case Q["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.id:{const V=o.project.entities.filter(S=>S.implements.find(Y=>Y.id===Q["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id));let $=V.find(S=>!!S.properties.find(Y=>{var re;return Y.implements.find(ee=>ee.id===Q["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id)&&((re=Y.getDefaultValue())==null?void 0:re.value)===!0}));if(!$&&V.length)$=V[0];else if(!$&&!V.length){$=o.project.getBuiltIn(Q["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id).implement("Relational database",p);const Y=$.properties.find(re=>re.implements.find(ee=>ee.id===Q["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id));(m=Y==null?void 0:Y.defaultValue)==null||m.metaSync({value:!0},p),n.push($)}const L=o.properties.find(S=>S.implements.find(Y=>Y.id===Q["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.properties.database.id));if(L&&!(L!=null&&L.defaultValue)){const S={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(p==null?void 0:p.timestamp)||new Date().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.LiteralValue,standaloneParent:null,name:oe.EntityTemplate,autogeneration:null,value:null,valueAsTypeSingle:($==null?void 0:$.toJSON())||null,valueAsTypeList:null,parent:L==null?void 0:L.toReference()},Y=me(S,o.project);Y.hydrateAncestors(),Y.setParent(L,p),Y.addSelfToProject(p),p==null||p.add(Y,H.Added),Y.initChildren(p),(L==null?void 0:L.defaultValue).setValueAsTypeSingle($||null,p),n.push(Y);return}else L!=null&&L.defaultValue&&!(L!=null&&L.defaultValue.valueAsTypeSingle)&&(L==null||L.defaultValue.setValueAsTypeSingle($||null,p));const k=o.properties.find(S=>S.implements.find(Y=>Y.id===Q["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.properties.primaryKey.id));if(!k)throw new Error(`[handleAfterEntityImplementationSideEffects] Primary key property not found for implemented base entity ${Q["built-in-base-entity"]}`);if(!k.dataType){const S=ur.new(p);S.parent=k.toReference();const Y=me(S,o.project);Y.hydrateAncestors(),Y.setParent(k,p),Y.addSelfToProject(p),p==null||p.add(Y,H.Added),Y.initChildren(p)}const K=o.project.getBuiltIn(Q["primitive-entity"].number.id);(v=k.dataType)==null||v.setEntity(K,p);return}case Q["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id:{const V=o.project.entities.filter(re=>re.implements.find(ee=>ee.id===Q["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id)&&re.id!==o.id),$=V.map(re=>{var le;const ee=re.properties.find(fe=>fe.implements.find(ve=>ve.id===Q["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.identifier.id));return(le=ee==null?void 0:ee.getDefaultValue())==null?void 0:le.value}).filter(re=>!!re),L=o.properties.find(re=>re.implements.find(ee=>ee.id===Q["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.identifier.id));if(!V.find(re=>!!re.properties.find(ee=>{var de;return ee.implements.find(le=>le.id===Q["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id)&&((de=ee.getDefaultValue())==null?void 0:de.value)===!0}))){const re=o.properties.find(ee=>ee.implements.find(de=>de.id===Q["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id));if(!re)throw new Error("Default boolean property not found for relational database entity with id: "+o.id);if(!(re!=null&&re.defaultValue)){const ee=Yr.new(p);ee.parent=re.toReference();const de=me(ee,o.project);de.hydrateAncestors(),de.setParent(re,p),de.addSelfToProject(p),p==null||p.add(de,H.Added),de.initChildren(p)}(E=re==null?void 0:re.defaultValue)==null||E.metaSync({value:!0},p)}if(!L)throw new Error("Identifier property not found for relational database entity with id: "+o.id);if(!(L!=null&&L.defaultValue)){const re=Yr.new(p);re.parent=L.toReference();const ee=me(re,o.project);ee.hydrateAncestors(),ee.setParent(L,p),ee.addSelfToProject(p),ee.initChildren(p),p==null||p.add(ee,H.Added)}const K=lvi($,V.length);(b=L.defaultValue)==null||b.metaSync({value:K},p);const S=o.properties.find(re=>re.implements.find(ee=>ee.id===Q["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.password.id));if(!S)throw new Error(`[handleAfterEntityImplementationSideEffects] Password property not found for implemented base entity ${Q["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id} with id ${o.id}`);if(!S.defaultValue){const re=Yr.new(p);re.parent=S.toReference();const ee=me(re,o.project);ee.hydrateAncestors(),ee.setParent(S,p),ee.addSelfToProject(p),ee.initChildren(p),p==null||p.add(ee,H.Added),n.push(ee)}const Y=jP(24);(w=S.defaultValue)==null||w.metaSync({value:Y},p);return}case Q["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.id:{const V=o.properties.find(K=>K.implements.find(S=>S.id===Q["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.properties.time.id));if(!V)throw new Error(`[handleAfterEntityImplementationSideEffects] Time property not found for implemented base entity ${Q["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.id} with id ${o.id}`);let $=V.defaultValue||null;if(!$){const K=Yr.new(p);K.parent=V.toReference(),K.name=oe.Date,K.id=x.UUID.uuid(),$=me(K,o.project),$.hydrateAncestors(),$.setParent(V,p),$.addSelfToProject(p),$.initChildren(p),p==null||p.add($,H.Added)}$.metaSync({value:new Date().toISOString()},p),$.metaSync({editable:!1,deletable:!1},p),V.metaSync({editable:!1,deletable:!1},p);const L=o.properties.find(K=>K.implements.find(S=>S.id===Q["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.properties.definition.id));if(!L)throw new Error(`[handleAfterEntityImplementationSideEffects] Definition property not found for implemented base entity ${Q["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.id} with id ${o.id}`);let k=L.defaultValue||null;if(!k){const K=Yr.new(p);K.name=oe.EntityTemplate,K.parent=L.toReference(),K.id=x.UUID.uuid(),k=me(K,o.project),k.hydrateAncestors(),k.setParent(L,p),k.addSelfToProject(p),k.initChildren(p),p==null||p.add(k,H.Added)}}}}),{self:o,updated:D(i),added:D(n),removed:D(s),affected:D(c)}}function FI(o,p,i,n){const s=n||x.UUID.uuid(),c=us.new(i);c.id=s,c.name=p,c.static=o.static,c.implements=[o.toJSON()],c.parent=o.project.toReference(),c.static=o.static,vOe(o,i);const e=me(c,o.project);return e.hydrateAncestors(),i==null||i.add(e,H.Added),e.addSelfToProject(i),e.initChildren(i),EOe(e,i),e.afterAllChildrenInitialized(i),e}function KP(o,p){return p.entities.find(s=>{const c=s.properties,e=c.map(b=>b.name),y=o.every(b=>e.includes(b)),m=e.filter(b=>!o.includes(b)),v=c.every(b=>!m.includes(b.name)||!b.required);return y&&v})||null}function bOe(o,p,i,n=He.OrDataTypeGroup){const s=[],c=[],e=[],y=[],m=x.UUID.uuid(),v=ur.new(i);v.id=m,v.parent=p.toReference(),v.like=!0,v.parentRelationType=n;const E=me(v,o.project);return c.push(E),E.setParent(p,i),E.initChildren(i),i==null||i.add(E,H.Added),E.setEntity(o,i),E.addSelfToProject(i),{updated:D(s),added:D(c),removed:D(e),affected:D(y),self:E}}function FP(o,p,i,n,s){var v,E,b,w,V,$,L,k;const c=[],e=[],y=[],m=[];switch(typeof o){case"string":let K=!1;const S=new Date(o);if(S instanceof Date&&!isNaN(S.valueOf())&&(K=!0),K){const Y=p.project.getBuiltIn(Q[d.PrimitiveEntity][oe.Date].id);p.setEntity(Y,n);break}else{const Y=p.project.getBuiltIn(Q[d.PrimitiveEntity][oe.String].id);p.setEntity(Y,n);break}case"number":p.setEntity(p.project.getBuiltIn(Q[d.PrimitiveEntity][oe.Number].id),n);break;case"boolean":p.setEntity(p.project.getBuiltIn(Q[d.PrimitiveEntity][oe.Boolean].id),n);break;case"object":if(o===null){p.setEntity(p.project.getBuiltIn(Q[d.PrimitiveEntity][oe.Null].id),n);break}else if(Array.isArray(o))if(p.metaSync({isList:!0},n),o.length>0){const Y=o.slice(0,5).filter(ee=>ee!==void 0);if(Y.every(ee=>typeof ee==typeof Y[0])&&(typeof Y[0]!="object"||Y[0]===null))switch(typeof Y[0]){case"string":p.setEntity(p.project.getBuiltIn(Q[d.PrimitiveEntity][oe.String].id),n);break;case"number":p.setEntity(p.project.getBuiltIn(Q[d.PrimitiveEntity][oe.Number].id),n);break;case"boolean":p.setEntity(p.project.getBuiltIn(Q[d.PrimitiveEntity][oe.Boolean].id),n);break;case"object":p.setEntity(p.project.getBuiltIn(Q[d.PrimitiveEntity][oe.Null].id),n);break}else{const ee=[];let de=!1;Y.forEach(fe=>{var ve,ue,ye,Ve;if(Array.isArray(fe)&&(de=!0),typeof fe=="object"&&!Array.isArray(fe)&&fe!==null){const _e=jb(fe,p.project,{...i,id:x.UUID.uuid()},n,s);_e.hasCreated&&ee.push((ve=_e.changeSet)==null?void 0:ve.self),c.push(...(ue=_e.changeSet)==null?void 0:ue.updated),e.push(...(ye=_e.changeSet)==null?void 0:ye.added),y.push(...(Ve=_e.changeSet)==null?void 0:Ve.removed)}});const le=D(ee);if(!le.length&&!de){Y.forEach(fe=>{const ve=ur.new(n);ve.parentRelationType=He.OrDataTypeGroup,ve.parent=p.toReference();const ue=me(ve,p.project);switch(ue.setParent(p,n),ue.initChildren(n),n==null||n.add(ue,H.Added),ue.addSelfToProject(n),typeof fe){case"string":ue.setEntity(ue.project.getBuiltIn(Q[d.PrimitiveEntity][oe.String].id),n);break;case"number":ue.setEntity(ue.project.getBuiltIn(Q[d.PrimitiveEntity][oe.Number].id),n);break;case"boolean":ue.setEntity(ue.project.getBuiltIn(Q[d.PrimitiveEntity][oe.Boolean].id),n);break;case"object":ue.setEntity(ue.project.getBuiltIn(Q[d.PrimitiveEntity][oe.Null].id),n);break}});break}else le.length===1&&!de?p.setEntity(le[0],n):Y.forEach(fe=>{if(typeof fe=="object"&&!Array.isArray(fe)&&fe!==null){const ve=KP(Object.keys(fe),p.project);if(ve){const ue=bOe(ve||le[0],p,n,He.OrDataTypeGroup);c.push(...ue.updated),e.push(...ue.added),y.push(...ue.removed)}}else{const ve=ur.new(n);ve.parentRelationType=He.OrDataTypeGroup,ve.parent=p.toReference();const ue=me(ve,p.project);ue.setParent(p,n),ue.initChildren(n),n==null||n.add(ue,H.Added),ue.addSelfToProject(n);const ye=FP(fe,ue,{...i,id:x.UUID.uuid()},n,s);c.push(...ye.updated),e.push(...ye.added),y.push(...ye.removed)}})}}else{const Y=jb(o[0],p.project,{...i},n,s);p.setEntity((v=Y.changeSet)==null?void 0:v.self,n),c.push(...(E=Y.changeSet)==null?void 0:E.updated),e.push(...(b=Y.changeSet)==null?void 0:b.added),y.push(...(w=Y.changeSet)==null?void 0:w.removed);break}else{const Y=jb(o,p.project,{...i},n,s);p.setEntity((V=Y.changeSet)==null?void 0:V.self,n),c.push(...($=Y.changeSet)==null?void 0:$.updated),e.push(...(L=Y.changeSet)==null?void 0:L.added),y.push(...(k=Y.changeSet)==null?void 0:k.removed);break}}return{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:p}}function jb(o,p,i,n,s){const c=[],e=[],y=[],m=[],v=Object.keys(o),E=KP(v,p);if(E)return{hasCreated:!1,changeSet:{updated:[],added:[],removed:[],affected:[],self:E}};const b=s?i.name+" of "+s.name:i.name,V={id:i.id||x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(n==null?void 0:n.timestamp)||new Date().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,name:b,codeName:null,deletable:!0,editable:!0,type:d.DefinitionEntity,additionalProperties:!1,additionalPropertiesDataType:null,allPropertiesImplement:null,description:i.description||null,static:i.static||!1,abstract:i.abstract||!1,properties:[],methods:[],abstractMethods:[],extends:null,implements:[],x:0,y:0,parent:p.toReference()},$=me(V,p);return $.setParent(p,n),$.initChildren(n),n==null||n.add($,H.Added),$.addSelfToProject(n),e.push($),v.forEach((L,k)=>{const K=x.UUID.uuid(),S=ja.new(n);S.id=K,S.name=L,S.codeName=L,S.parent=$.toReference(),S.index=k,S.required=!0,S.interactive=!0;const Y=me(S,p);Y.setParent($,n),Y.initChildren(n),n==null||n.add(Y,H.Added),Y.addSelfToProject(n),e.push(Y);const re=o[L],ee=x.UUID.uuid(),de=ur.new(n);de.id=ee,de.parent=Y.toReference(),de.like=!0,de.isList=!1;const le=me(de,p);le.setParent(Y,n),le.initChildren(n),n==null||n.add(le,H.Added),le.addSelfToProject(n),e.push(le);const fe=FP(re,le,{...i,name:L,id:x.UUID.uuid()},n,s||$);c.push(...fe.updated),e.push(...fe.added),y.push(...fe.removed)}),{hasCreated:!0,changeSet:{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:$}}}function pd(o,p,i,n){const s=[];return!o.length||!p.length?{errors:s,overlap:!1}:(o.length>p.length?o.forEach(c=>{const e=p.find(m=>m.name===c.name),y=p.find(m=>{var v,E;return Array.isArray(m.implements)?m.implements.some(b=>!!c.implements.find(w=>w.id===b.id)):((v=m.implements)==null?void 0:v.id)===((E=c.implements)==null?void 0:E.id)});if(e){const m=new ki({id:c.id+"--"+e.id+"--"+n,message:`Entity of type ${c.type} named "${c.name}" with id "${c.id}" overrides a base ${e.type} ${e.name} with id "${e.id}" that has the same name`,severity:ce.Error,code:n,entity:c,firstRelationship:e});s.push(m)}if(y){const m=new ki({id:c.id+"--"+y.id+"--"+i,message:`Entity of type ${c.type} named "${c.name}" with id "${c.id}" overrides a base ${y.type} ${y.name} with id "${y.id}" that implements the same base descriptor`,severity:ce.Error,code:i,entity:c,firstRelationship:y});s.push(m)}}):p.forEach(c=>{var m;const e=o.find(v=>v.name===c.name),y=o.find(v=>{var E,b;return v.implements&&Array.isArray(v.implements)?v.implements.some(w=>!!c.implements.find(V=>V.id===w.id)):((E=v.implements)==null?void 0:E.id)===((b=c.implements)==null?void 0:b.id)});if(e){const v=new ki({id:e.id+"--"+c.id+"--"+n,message:`Entity of type ${e.type} named "${e.name}" with id "${e.id}" overrides a base entity ${c.name} with id "${c.id}" that has the same name`,severity:ce.Error,code:n,entity:e,firstRelationship:c});s.push(v)}if(y){const v=new ki({id:y.id+"--"+c.id+"--"+i,message:`Entity of type ${y.type} named "${y.name}" with id "${y.id}" overrides a base entity ${c.name} with id "${c.id}" that implements the same base ${Array.isArray(y==null?void 0:y.implements)?Ct(y==null?void 0:y.implements.map(E=>E.type),"', '","' and '"):(m=y.implements)==null?void 0:m.id}`,severity:ce.Error,code:i,entity:y,firstRelationship:c});s.push(v)}}),{errors:s,overlap:!!s.length})}function ovi(o,p){return o.abstract||(o.properties.forEach(n=>{n.abstract||n.metaSync({abstract:!0},p)}),Object.values(o.detachedDependents).forEach(n=>{n.field===HN.EntityField&&n.entity.remove({ignoreUpstream:!1},p)}),o.metaSync({abstract:!0},p)),o}function dvi(o,p){return o.abstract&&(o.properties.forEach(n=>{n.abstract&&n.metaSync({abstract:!1},p)}),Object.values(o.detachedDependents).forEach(n=>{(n.field===RA.Implements||n.field===RA.Extends)&&n.entity.onDetachedDependencyRemoved(o,n.field,p)}),o.metaSync({abstract:!1},p)),o}function uvi(o,p){return o.static||(o.properties.forEach(n=>{n.static||n.metaSync({static:!0},p)}),o.metaSync({static:!0},p)),o}function pvi(o,p){return o.static&&o.metaSync({static:!1},p),o}const jm=class jm extends xP{constructor(i,n){super(i);I(this,"initialData");I(this,"id");I(this,"version");I(this,"name");I(this,"description",null);I(this,"type",d.BuiltInBaseEntity);I(this,"abstract",!1);I(this,"static");I(this,"additionalProperties",!1);I(this,"properties",[]);I(this,"allPropertiesImplement",null);I(this,"additionalPropertiesDataType",null);I(this,"methods",[]);I(this,"abstractMethods",[]);I(this,"extends",null);I(this,"interactive",!1);I(this,"errors",[]);I(this,"project");if(this.initialData=this.initialData||i,this.project=this.project||n,this.id=this.id||i.id,this.version=this.version||i.version,this.name=this.name||i.name,this.static=this.static||i.static,this.interactive=this.interactive||i.interactive,this.abstract=i.abstract,this.additionalProperties=i.additionalProperties,this.properties=this.initialData.properties.map(s=>{const c=me(s,this.project);return c.setParent(this,null),c.initChildren(null),c}),this.methods=this.initialData.methods.map(s=>{const c=me(s,this.project);return c.setParent(this,null),c.initChildren(null),c}),this.abstractMethods=this.initialData.abstractMethods.map(s=>{const c=me(s,this.project);return c.setParent(this,null),c.initChildren(null),c}),this.initialData.allPropertiesImplement){const s=me(this.initialData.allPropertiesImplement,this.project);s.setParent(this,null),s.initChildren(null),this.allPropertiesImplement=s}if(this.initialData.additionalPropertiesDataType){const s=me(this.initialData.additionalPropertiesDataType,this.project);s.setParent(this,null),s.initChildren(null),this.additionalPropertiesDataType=s}this.initialData.extends&&(this.extends=me(this.initialData.extends,this.project))}get allMethods(){return D([...this.ownDeclaredMethods,...this.allBaseMethodsFromOriginalParents])}get allProperties(){return D([...this.ownDeclaredProperties,...this.allBasePropertiesFromOriginalParents])}get allBaseMethodsFromOriginalParents(){var s;const i=((s=this.extends)==null?void 0:s.allMethods)||[],n=[...i].filter(c=>!i.some(e=>e.id!==c.id));return D(n)}get allBasePropertiesFromOriginalParents(){var s;const i=((s=this.extends)==null?void 0:s.allProperties)||[],n=[...i].filter(c=>!i.some(e=>{var y;return e.id!==c.id&&(!!e.implements.find(m=>m.id===c.id)||((y=e.extends)==null?void 0:y.id)===c.id)}));return D(n)}get allBasePropertiesFromExtendedAndImplementedEntities(){var s,c;const i=[...((s=this.extends)==null?void 0:s.ownDeclaredProperties)||[],...((c=this.extends)==null?void 0:c.allBasePropertiesFromExtendedAndImplementedEntities)||[]].filter(e=>!e.abstract),n=[...i].filter(e=>!i.some(y=>{var m;return y.id!==e.id&&(!!y.implements.find(v=>v.id===e.id)||((m=y.extends)==null?void 0:m.id)===e.id)}));return D([...n])}get allBaseMethodsFromExtendedAndImplementedEntities(){return D([...(this.extends?[this.extends]:[]).reduce((i,n)=>n.type===d.PrimitiveEntity?i:[...[...n.ownDeclaredMethods,...n.allBaseMethodsFromExtendedAndImplementedEntities].filter(c=>c.type!==d.ActionDescriptor),...i],[])])}get extendedPropertiesFromOriginalParents(){var s,c;const i=[...((s=this.extends)==null?void 0:s.ownDeclaredProperties)||[],...((c=this.extends)==null?void 0:c.extendedPropertiesFromOriginalParents)||[]].filter(e=>!e.abstract),n=[...i].filter(e=>!i.some(y=>{var m;return y.id!==e.id&&(!!y.implements.find(v=>v.id===e.id)||((m=y.extends)==null?void 0:m.id)===e.id)}));return D(n)}get implementedPropertiesFromOriginalParents(){return D([...(this.extends?[this.extends]:[]).reduce((i,n)=>{const s=n.implementedPropertiesFromOriginalParents,c=[...n.ownDeclaredProperties].filter(m=>!!m.abstract),e=[...s,...c,...i];return[...e].filter(m=>!!!e.find(E=>{var b;return((b=E.extends)==null?void 0:b.id)===m.id||!!E.implements.find(w=>w.id===m.id)}))},[])].filter(i=>!!i.abstract))}get extendedProperties(){return this.properties.filter(i=>i.isExtendedProperty)}get ownDeclaredMethods(){return[...this.methods,...this.abstractMethods]}get ownDeclaredProperties(){return this.properties.filter(i=>!i.isExtendedProperty)}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}async APILoad(i=ke,...n){return await jm.repository.APILoad(this.id,...n),this}toFlat(i=new Set){var s;return i.has(this.id)?[]:(i.add(this.id),[this,...this.properties.flatMap(c=>c.toFlat(i)),...this.methods.flatMap(c=>c.toFlat(i)),...this.abstractMethods.flatMap(c=>c.toFlat(i)),...((s=this.extends)==null?void 0:s.toFlat(i))||[]])}toFlatIds(i=new Set){var s;return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.properties.flatMap(c=>c.toFlatIds(i)),...this.methods.flatMap(c=>c.toFlatIds(i)),...this.abstractMethods.flatMap(c=>c.toFlatIds(i)),...((s=this.extends)==null?void 0:s.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,interactive:this.interactive,additionalProperties:this.additionalProperties,abstract:this.abstract,static:this.static,type:this.type,name:this.name}}toJSON(i=new Set){var n,s,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,name:this.name,description:this.description,abstract:this.abstract,static:this.static,additionalProperties:this.additionalProperties,interactive:this.interactive,additionalPropertiesDataType:((n=this.additionalPropertiesDataType)==null?void 0:n.toJSON(i))||null,allPropertiesImplement:((s=this.allPropertiesImplement)==null?void 0:s.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)),extends:((c=this.extends)==null?void 0:c.toJSON(i))||null})}toReference(i=ct){return{id:this.id+"--"+x.UUID.uuid()+"--ref",type:d.GenericReference,entityId:this.id,version:this.version,entityType:this.type}}toShallowJSON(i=ct){var n,s,c;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,interactive:this.interactive,additionalProperties:this.additionalProperties,additionalPropertiesDataType:((n=this.additionalPropertiesDataType)==null?void 0:n.toReference())||null,allPropertiesImplement:((s=this.allPropertiesImplement)==null?void 0:s.toReference())||null,properties:this.properties.map(e=>e.toReference()),methods:this.methods.map(e=>e.toReference()),abstractMethods:this.abstractMethods.map(e=>e.toReference()),extends:((c=this.extends)==null?void 0:c.toReference())||null}}toFlatJSON(i=new Set){var s,c;return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...this.properties.flatMap(e=>e.toFlatJSON(i)),...this.methods.flatMap(e=>e.toFlatJSON(i)),...this.abstractMethods.flatMap(e=>e.toFlatJSON(i)),...((s=this.additionalPropertiesDataType)==null?void 0:s.toFlatJSON(i))||[],...((c=this.allPropertiesImplement)==null?void 0:c.toFlatJSON(i))||[]])}toGenerationTarget(){var i;return{id:this.id,type:this.type,name:this.name,description:this.description,static:this.static,abstract:this.abstract,interactive:this.interactive,additionalProperties:this.additionalProperties,extends:(i=this.extends)==null?void 0:i.id}}toFlatGenerationTarget(i=new Set){var s,c;return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...this.properties.flatMap(e=>e.toFlatGenerationTarget(i)),...this.methods.flatMap(e=>e.toFlatGenerationTarget(i)),...this.abstractMethods.flatMap(e=>e.toFlatGenerationTarget(i)),...((s=this.additionalPropertiesDataType)==null?void 0:s.toFlatGenerationTarget(i))||[],...((c=this.allPropertiesImplement)==null?void 0:c.toFlatGenerationTarget(i))||[]])}clearErrors(){var i,n;return this.errors=[],this.properties.forEach(s=>s.clearErrors()),this.methods.forEach(s=>s.clearErrors()),this.abstractMethods.forEach(s=>s.clearErrors()),(i=this.additionalPropertiesDataType)==null||i.clearErrors(),(n=this.allPropertiesImplement)==null||n.clearErrors(),this}validate(){return this.errors=evi(this),{success:!0}}async validateAsync(i={}){const n=J.YieldTracker.from(i);return this.errors=await QTi(this,{tracker:n}),{success:!0}}getErrors(){var n,s;return[...this.errors,...this.properties.flatMap(c=>c.getErrors()),...this.methods.flatMap(c=>c.getErrors()),...this.abstractMethods.flatMap(c=>c.getErrors()),...((n=this.additionalPropertiesDataType)==null?void 0:n.getErrors())||[],...((s=this.allPropertiesImplement)==null?void 0:s.getErrors())||[]]}async getErrorsAsync(i={}){const n=J.YieldTracker.from(i),s=[...this.errors];await n.tick();for(const c of this.properties){const e=await c.getErrorsAsync({tracker:n});s.push(...e)}for(const c of this.methods){const e=await c.getErrorsAsync({tracker:n});s.push(...e)}for(const c of this.abstractMethods){const e=await c.getErrorsAsync({tracker:n});s.push(...e)}if(this.additionalPropertiesDataType){const c=await this.additionalPropertiesDataType.getErrorsAsync({tracker:n});s.push(...c)}if(this.allPropertiesImplement){const c=await this.allPropertiesImplement.getErrorsAsync({tracker:n});s.push(...c)}return s}getShallowErrors(){return this.errors}implement(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),null,!0,"implement-built-in-base-entity")),s){const c=FI(this,i,n,s);return n==null||n.attemptAutoclose("implement-built-in-base-entity",this.id),c}getAllPropertiesImplements(){var n;const i=[];return this.allPropertiesImplement&&i.push(this.allPropertiesImplement),((n=this.extends)==null?void 0:n.type)===d.BuiltInBaseEntity&&i.push(...this.extends.getAllPropertiesImplements()||[]),i}getAllInteractiveMethods(){const i=[];if(this.interactive){if(i.push(...this.methods,...this.abstractMethods),!this.extends||this.extends.type===d.BuiltInBaseEntity&&this.extends.interactive||this.extends.type===d.PrimitiveEntity)return i;this.extends instanceof jm&&i.push(...this.extends.getAllInteractiveMethods())}return D(i)}};I(jm,"repository",{APILoad:async(i,...n)=>null});let No=jm;class AOe extends No{constructor(i){super(dn,i);I(this,"initialData");I(this,"id",Re.PERSISTED_ENTITY);I(this,"version","1");I(this,"name",Re.PERSISTED_ENTITY);I(this,"description",dn.description);I(this,"type",d.BuiltInBaseEntity);I(this,"abstract",dn.abstract);I(this,"static",dn.static);I(this,"properties",[]);I(this,"methods",[]);I(this,"abstractMethods",[]);I(this,"extends",null);I(this,"errors",[]);I(this,"project");this.initialData=dn,this.project=i,this.id=dn.id,this.version=dn.version,this.name=dn.name,this.static=dn.static,this.abstract=dn.abstract,this.properties=this.initialData.properties.map(n=>{const s=me(n,this.project);return s.setParent(this,null),s.initChildren(null),s}),this.methods=this.initialData.methods.map(n=>{const s=me(n,this.project);return s.parent=this,s}),this.abstractMethods=this.initialData.abstractMethods.map(n=>{const s=me(n,this.project);return s.parent=this,s}),this.initialData.extends&&(this.extends=me(this.initialData.extends,this.project))}}var sa=(o=>(o.StringValueMustNotHaveSpaces="string-value-must-not-have-spaces",o.StringValueMustNotHaveDashes="string-value-must-not-have-dashes",o.MustBeUniqueAmongSameEntities="must-be-unique-among-same-entities",o))(sa||{});function SP(o,p){const i=[],n=p;if(!n)return{errors:i,override:p};if(typeof n!="string")return{errors:[],override:p};if(n.includes(" ")){const s=new ki({id:o.id+"--string-value-must-not-have-spaces",message:`Entity of type ${o.type} with id "${o.id}" has an invalid value "${p}". The value cannot contain spaces.`,severity:ce.Error,code:"string-value-must-not-have-spaces",entity:o});i.push(s)}return{errors:i,override:n.replace(/\s/g,"-")}}function gOe(o,p){const i=[],n=p;if(!n)return{errors:i,override:p};if(typeof n!="string")return{errors:[],override:p};if(n.includes(" ")){const s=new ki({id:o.id+"--string-value-must-not-have-spaces",message:`Entity of type ${o.type} with id "${o.id}" has an invalid value "${p}". The value cannot contain spaces or dashes.`,severity:ce.Error,code:"string-value-must-not-have-spaces",entity:o});i.push(s)}if(n.includes("-")){const s=new ki({id:o.id+"--string-value-must-not-have-dashes",message:`Entity of type ${o.type} with id "${o.id}" has an invalid value "${p}". The value cannot contain spaces or dashes.`,severity:ce.Error,code:"string-value-must-not-have-dashes",entity:o});i.push(s)}return{errors:i,override:n.replace(/\s|-/g,"_")}}var xo=(o=>(o.StatusCodeMustBeNumber="status-code-must-be-number",o.StatusCodeMustBeBetween100And599="status-code-must-be-between-100-and-599",o))(xo||{});function IOe(o,p){const i=[];if(typeof p!="number"){const n=new ki({id:o.id+"--status-code-must-be-number",message:`Entity of type ${o.type} with id "${o.id}" has an invalid value "${p}". The value must be a number.`,severity:ce.Error,code:"status-code-must-be-number",entity:o});return i.push(n),{errors:i,override:p}}if(p<100){const n=new ki({id:o.id+"--status-code-must-be-between-100-and-599",message:`Entity of type ${o.type} with id "${o.id}" has an invalid value "${p}". The value must be a number between 100 and 599.`,severity:ce.Error,code:"status-code-must-be-between-100-and-599",entity:o});i.push(n)}if(p>599){const n=new ki({id:o.id+"--status-code-must-be-between-100-and-599",message:`Entity of type ${o.type} with id "${o.id}" has an invalid value "${p}". The value must be a number between 100 and 599.`,severity:ce.Error,code:"status-code-must-be-between-100-and-599",entity:o});i.push(n)}return{errors:i,override:p}}class ROe extends No{constructor(i){var e,y;super(xa,i);I(this,"initialData");I(this,"id",Re.PERSISTED_ENTITY);I(this,"version","1");I(this,"name",Re.PERSISTED_ENTITY);I(this,"description",xa.description);I(this,"type",d.BuiltInBaseEntity);I(this,"abstract",xa.abstract);I(this,"static",xa.static);I(this,"properties",[]);I(this,"methods",[]);I(this,"abstractMethods",[]);I(this,"extends",null);I(this,"errors",[]);I(this,"project");this.initialData=xa,this.project=i,this.id=xa.id,this.version=xa.version,this.name=xa.name,this.static=xa.static,this.abstract=xa.abstract,this.properties=this.initialData.properties.map(m=>{const v=me(m,this.project);return v.setParent(this,null),v.initChildren(null),v}),this.methods=this.initialData.methods.map(m=>{const v=me(m,this.project);return v.parent=this,v}),this.abstractMethods=this.initialData.abstractMethods.map(m=>{const v=me(m,this.project);return v.parent=this,v}),this.initialData.extends&&(this.extends=me(this.initialData.extends,this.project));const n=this.properties.find(m=>m.id===Q["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.properties.path.id);if(!n)throw new Error("Path property not found in endpoint entity");n._codeNativeValueValidation=(m,v)=>{const E=SP(m,v);if(m.project.entities.filter(w=>Wi(w,Re.HTTP_ENDPOINT)&&w.id!==m.parent.id).map(w=>{const V=w.properties.find(k=>k.implements.find(K=>K.id===Q["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.properties.path.id));if(!V)throw new Error("Path property not found in endpoint entity "+w.name+" ("+w.id+")");const $=V.getDefaultValue();return($==null?void 0:$.value)||""}).includes(v)){const w=new ki({id:m.id+"--"+sa.MustBeUniqueAmongSameEntities,message:`Entity of type ${m.type} with id "${m.id}" has an invalid value "${v}". The value must be unique among all endpoint paths.`,severity:ce.Error,code:sa.MustBeUniqueAmongSameEntities,entity:m});E.errors.push(w)}return E};const s=this.abstractMethods.find(m=>m.id===Q["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.methods.handler.id);if(!s)throw new Error("Handler method not found in endpoint entity");const c=(((y=(e=s.dataType)==null?void 0:e.entity)==null?void 0:y.properties)||[]).find(m=>m.id===Q["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.methods.handler.dataType.entity.properties.statusCode.id);if(!c)throw new Error("Status code output not found in handler method");c._codeNativeValueValidation=(m,v)=>IOe(m,v)}}class DOe extends Bi{constructor(i){super(go,i);I(this,"id",Ki.Parallel);I(this,"name",Ki.Parallel);I(this,"description","Programmatically execute a list of actions one after the other");I(this,"version","1");I(this,"autoexecutable",!0);I(this,"type",d.ActionDescriptor);I(this,"inputs",[]);I(this,"dataType",null);I(this,"error",null);I(this,"project");this.project=i,this.inputs=go.inputs.map(n=>{const s=me(n,this.project);return s.setParent(this,null),s.initChildren(null),s}),this.dataType=me(go.dataType,this.project),this.dataType.setParent(this,null),this.dataType.initChildren(null),this.error=go.error?me(go.error,this.project):null}}class wOe extends Bi{constructor(i){super(rs,i);I(this,"id",rs.id);I(this,"name",rs.name);I(this,"description",rs.description);I(this,"version",rs.version);I(this,"autoexecutable",!1);I(this,"type",d.ActionDescriptor);I(this,"inputs",[]);I(this,"dataType",null);I(this,"error",null);I(this,"project");this.project=i,this.inputs=rs.inputs.map(n=>{const s=me(n,this.project);return s.setParent(this,null),s.initChildren(null),s}),this.dataType=me(rs.dataType,this.project),this.dataType.setParent(this,null),this.dataType.initChildren(null),this.error=rs.error?me(rs.error,this.project):null}}class OOe extends Bi{constructor(i){super(gu,i);I(this,"id",Ki.Sequential);I(this,"name",Ki.Sequential);I(this,"description","Programmatically execute a list of actions one after the other");I(this,"version","1");I(this,"autoexecutable",!0);I(this,"type",d.ActionDescriptor);I(this,"inputs",[]);I(this,"dataType",null);I(this,"error",null);I(this,"project");this.project=i,this.inputs=gu.inputs.map(n=>{const s=me(n,this.project);return s.setParent(this,null),s.initChildren(null),s}),this.dataType=me(gu.dataType,this.project),this.dataType.setParent(this,null),this.dataType.initChildren(null),this.error=gu.error?me(gu.error,this.project):null}}var Ba=(o=>(o.UUIDMustBeString="uuid-must-be-string",o.UUIDMustBeValidFormat="uuid-must-be-valid-format",o.UUIDMustNotContainSpaces="uuid-must-not-contain-spaces",o))(Ba||{});function cvi(o,p){const i=[];if(typeof p!="string"){const s=new ki({id:o.id+"--uuid-must-be-string",message:`Entity of type ${o.type} with id "${o.id}" has an invalid value "${p}". The value must be text.`,severity:ce.Error,code:"uuid-must-be-string",entity:o});return i.push(s),{errors:i,override:p}}const n=SP(o,p);if(n.errors.length>0)return i.push(...n.errors),{errors:i,override:p};if(!NP(p)){const s=new ki({id:o.id+"--uuid-must-be-valid-format",message:`Entity of type ${o.type} with id "${o.id}" has an invalid value "${p}". The value must be a valid UUID format. Eg: "123e4567-e89b-12d3-a456-426614174000".`,severity:ce.Error,code:"uuid-must-be-valid-format",entity:o});i.push(s)}return{errors:i,override:p}}var Pe=(o=>(o.Inherited="inherited",o.DefaultValue="default-value",o.Missing="missing",o.Empty="empty",o.AutoCalculated="auto-calculated",o.QueuedAutocalculation="queued-autocalculation",o.External="external",o.Testing="testing",o.ExecutionResult="execution-result",o))(Pe||{});const COe={initialized:!1,id:"",project:null,values:{},onWriteCallback:()=>{},onRemoveCallback:()=>{},onWrite:()=>{},onRemove:()=>{},init:()=>{},toJSON:()=>({}),writeValue:()=>{},readValue:()=>null,removeValue:()=>{},clear:()=>{}};function fvi(o,p){return{...COe,id:o,project:p}}class Vm{constructor(p,i){I(this,"initialized",!1);I(this,"id");I(this,"project");I(this,"values",{});I(this,"onWriteCallback",()=>{});I(this,"onRemoveCallback",()=>{});this.id=p,this.project=i,this.init()}onWrite(p){this.onWriteCallback=p}onRemove(p){this.onRemoveCallback=p}init(){var n;if(!((n=this.project)!=null&&n.id)||this.initialized)return;const p={},i={};Object.keys(p).forEach(s=>{const c=p[s],e=new Yr(c,this.project);try{if(c.parent){const v=this.project.findSubscribedInstanceFromReference(c.parent);if(!v)return;e.setParent(v,null),e.hydrateAncestors(),e.initChildren(null)}else if(c.standaloneParent){const v=this.project.findSubscribedInstanceFromReference(c.standaloneParent);if(!v)return;e.standalone=!0,e.setStandaloneParent(v,null),e.hydrateAncestors(),e.initChildren(null)}i[s]=e;const y=e.parent||e.standaloneParent,m=POe(e,y,this.project);m?i[s]=m:delete p[s]}catch(y){J.Logger.error("Error hydrating ancestors: ",y),delete p[s]}}),this.values={...this.values,...i},this.initialized=!0}toJSON(){const p={};return Object.keys(this.values).forEach(i=>{p[i]=this.values[i].toJSON()}),p}writeValue(p,i){if(!p)throw new Error("The value owner entity is required when writing a value to a value store");let s=this.values[p.id];if(!s)if(i instanceof Yr)s=i;else if(i)s=Si(i,this.project);else{const c={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:new Date().toISOString(),author:x.sessionAuthor,deleted:!1,previousVersion:null,value:null,deletable:!0,editable:!0,type:d.LiteralValue,standaloneParent:p.toReference(),parent:null,valueAsTypeSingle:null,valueAsTypeList:null,autogeneration:null,name:mc(p.getDataType(null))};s=Si(c,this.project)}s.standalone=!0,s.initialData.standaloneParent||J.Logger.warn("instance.initialData: ",s.initialData),s.setStandaloneParent(p,null),s.hydrateAncestors(),s.initChildren(null),i&&(s.metaSync({...i},null),s.setValueAsType(i.valueAsType,null)),this.values[p.id]=s,this.onWriteCallback(p,s)}readValue(p){return this.values[p]||null}removeValue(p){if(!this.values[p])return;delete this.values[p];const i=this.project.get(p);i&&this.onRemoveCallback(i)}clear(){this.values={}}}function hr(o){return o!==null&&typeof o=="object"&&!Array.isArray(o)}function _Oe(o){if(Array.isArray(o))return o.map(m=>typeof m=="number"?m:e(m)?Number(m):String(m));const p=[];let i=0,n="",s=!1,c=null;for(;i<o.length;){const m=o[i];if(m==="."&&!s){n.length&&(p.push(y(n)),n=""),i++;continue}if(m==="["&&!s){n.length&&(p.push(y(n)),n=""),s=!0,i++;continue}if(s){if(!c&&(m==='"'||m==="'")){c=m,i++;continue}if(c){if(m==="\\"&&i+1<o.length){n+=o[i+1],i+=2;continue}if(m===c){c=null,i++;continue}n+=m,i++;continue}if(m==="]"){p.push(y(n)),n="",s=!1,i++;continue}if(/\s/.test(m)&&!c){i++;continue}n+=m,i++;continue}n+=m,i++}return n.length&&p.push(y(n)),p;function e(m){return/^[0-9]+$/.test(m)}function y(m){const v=m.trim();return e(v)?Number(v):v}}function qP(o,p,i){if(o==null)return i;const n=_Oe(p);let s=o;for(let c=0;c<n.length;c++){const e=n[c];if(s==null)return i;if(Array.isArray(s)&&typeof e=="number"){if(!(e in s))return i;s=s[e]}else{if(!Object.prototype.hasOwnProperty.call(s,e))return i;s=s[e]}}return s}const yvi=new Set(["__proto__","prototype","constructor"]);function hvi(o){return typeof o=="string"&&yvi.has(o)}function VOe(o,p,i,n){const{createMissing:s=!0,coerce:c=!0}=n??{};if(o==null||typeof o!="object")throw new TypeError("set(...) expects a non-null object as target.");const e=_Oe(p);if(e.length===0)throw new Error("set(...) path must not be empty.");let y=o;for(let m=0;m<e.length;m++){const v=e[m];if(hvi(v))throw new Error(`Refusing to set unsafe key "${String(v)}" on object.`);const E=m===e.length-1,w=typeof e[m+1]=="number",V=Array.isArray(y)&&typeof v=="number";if(E){if(V&&y[v]==null&&!s)throw new Error(`set(...) missing array index "${String(v)}" (createMissing=false).`);return y[v]=i,o}else{if(!Object.prototype.hasOwnProperty.call(y,v)||y[v]==null){if(!s)throw new Error(`set(...) missing parent at segment "${String(v)}" (createMissing=false).`);y[v]=w?[]:{}}else{const $=y[v],L=$!==null&&typeof $=="object",k=Array.isArray($);if(w){if(!k){if(!c)throw new Error(`set(...) expected an array at "${String(v)}" but found non-array (coerce=false).`);y[v]=[]}}else if(!L||k){if(!c)throw new Error(`set(...) expected an object at "${String(v)}" but found non-object (coerce=false).`);y[v]={}}}y=y[v]}}return o}function nv(o){return globalThis.structuredClone?structuredClone(o):JSON.parse(JSON.stringify(o))}function mvi(o){if(Array.isArray(o))return o.slice();const p=[];let i="",n=0;for(;n<o.length;){const s=o[n];if(s==="."||s==="["||s==="]"){if(i.length){const c=Number(i);p.push(!Number.isNaN(c)&&/^\d+$/.test(i)?c:i),i=""}if(s==="["){n++;let c="";for(;n<o.length&&o[n]!=="]";)c+=o[n++];const e=Number(c);p.push(!Number.isNaN(e)&&/^\d+$/.test(c)?e:c)}n++;continue}i+=s,n++}if(i.length){const s=Number(i);p.push(!Number.isNaN(s)&&/^\d+$/.test(i)?s:i)}return p}function ZP(o,p,i){const n=mvi(p);if(n.length===0)throw new Error("Path must not be empty.");const s=n[n.length-1];let c=o;for(let e=0;e<n.length-1;e++){const y=n[e],m=typeof n[e+1]=="number",v=c==null?void 0:c[y];if(v==null){if(!i)throw new Error(`Missing parent at segment "${String(y)}" for path "${Array.isArray(p)?JSON.stringify(p):p}".`);c[y]=m?[]:{}}else if(typeof v!="object"||v!==null&&Array.isArray(v)!==m&&typeof n[e+1]=="number"){if(!i)throw new Error(`Parent at "${String(y)}" is not a container suitable for continuing the path.`);c[y]=m?[]:{}}c=c[y]}return{target:c,lastKey:s}}function Qd(o,p,i,n){var y;let s;if(((y=o==null?void 0:o.entity)==null?void 0:y.type)===d.PrimitiveEntity)switch(o.entity.name){case oe.EntityTemplate:s=oe.EntityTemplate;break;case oe.String:s=oe.String;break;case oe.Number:s=oe.Number;break;case oe.Boolean:s=oe.Boolean;break;case oe.Null:s=oe.Null;break;case oe.Enum:s=oe.Enum;break;case oe.KeyValue:s=oe.KeyValue;break;case oe.Untyped:s=oe.Untyped;break;case oe.KeyValue:s=oe.KeyValue;break;case oe.Date:s=oe.Date;break;case oe.UUID:s=oe.UUID;break;case oe.File:s=oe.File;break;case oe.Void:s=oe.Void;break;case oe.ActionDescriptor:s=oe.ActionDescriptor;break;case oe.Bytes:s=oe.Bytes;break;default:throw new Error(`Primitive type ${se(o.entity,i)} is not supported`)}else s=oe.Untyped;const c=Yr.new(n);c.name=s,c.parent=p.toReference();const e=me(c,i);return e.hydrateAncestors(),n==null||n.add(e,H.Added),e.addSelfToProject(n),e.initChildren(n),e}function Oo(o,p,i=new Set){var n,s,c;if(i.has(o.id))return[];if(i.add(o.id),Gt.includes(o.type)){const e=Wn(o);return D([e,...[e].flatMap(y=>Oo(y,p,i))])}else if(o.type===d.OutputMap){if(Gt.includes(o.parent.type)&&((n=o.declaration)==null?void 0:n.type)===d.Property&&o.declaration.static)return D([o,o.declaration,...[o,o.declaration].flatMap(e=>Oo(e,p,i))])}else if(o.type===d.InputMap&&Gt.includes(o.parent.type)&&((s=o.declaration)==null?void 0:s.type)===d.Property&&(c=o.declaration)!=null&&c.static)return D([o.declaration,...[o.declaration].flatMap(e=>Oo(e,p,i))]);return[o]}function POe(o,p,i){return o}function Lh(o,p,i=!1){const n=o.readsValue;let s=null;const c=Mu(n,p,i);if(c){const e={sources:[c],target:o};s={value:c.value,valueOwner:o,type:Pe.Inherited,inheritanceLink:e}}return s}function It(o,p,i){var y;if(!p)return null;let n;if(((y=o==null?void 0:o.entity)==null?void 0:y.type)===d.PrimitiveEntity)switch(o.entity.name){case oe.EntityTemplate:n=oe.EntityTemplate;break;case oe.String:n=oe.String;break;case oe.Number:n=oe.Number;break;case oe.Boolean:n=oe.Boolean;break;case oe.Null:n=oe.Null;break;case oe.Enum:n=oe.Enum;break;case oe.KeyValue:n=oe.KeyValue;break;case oe.Untyped:n=oe.Untyped;break;case oe.KeyValue:n=oe.KeyValue;break;case oe.Date:n=oe.Date;break;case oe.UUID:n=oe.UUID;break;case oe.File:n=oe.File;break;case oe.Void:n=oe.Void;break;case oe.ActionDescriptor:n=oe.ActionDescriptor;break;case oe.Bytes:n=oe.Bytes;break;default:throw new Error(`Primitive type ${se(o.entity,i)} is not supported`)}else n=oe.Untyped;if(!i.get(p.id))return null;const c=Yr.new(null);c.name=n,c.standaloneParent=p.toReference();let e=new Yr(c,i);return e.hydrateAncestors(),e.standalone=!0,e.setStandaloneParent(p,null),e.initChildren(null),e}function NOe(o,p,i=!1){var c,e;if(p.execution&&p.execution.hasEntity(o)&&!i){const y=(c=p.lastExecutionResults)==null?void 0:c.readValue(o.id);if(y)return{value:y,valueOwner:o,type:Pe.ExecutionResult,inheritanceLink:null}}const n=(e=p.localTestValues)==null?void 0:e.readValue(o.id),s=p.getValueTypePreference(o.id);return n&&!i&&(s===null||s!==Pe.DefaultValue)?{value:n,valueOwner:o,type:Pe.Testing,inheritanceLink:null}:{value:null,valueOwner:o,type:Pe.QueuedAutocalculation,inheritanceLink:null}}function Ub(o,p,i,n=!1){var e,y;const s={...o},c=p.type===d.VariableDeclaration?p.inputs:qt.includes(p.type)?p.outputs:[];if(!c||c.length===0)return s;for(const m of c){if(!xv(m))continue;const v=Fm(m,i,n);if(v&&v.value){const E=se(m,i.project),b=m.codeName||((e=m.declaration)==null?void 0:e.codeName)||Hi(E);s[b]=un((v==null?void 0:v.value)||null)?s[b]:(y=v==null?void 0:v.value)==null?void 0:y.value}}return s}function Pm(o,p,i,n=!1){var e,y;const s={...o},c=p.inputs;if(!c)return s;for(const m of c){if(!xv(m))continue;const v=sv(m,i,n);if(v&&v.value){const E=se(m,i.project),b=m.codeName||((e=m.declaration)==null?void 0:e.codeName)||Hi(E);s[b]=(y=v==null?void 0:v.value)==null?void 0:y.value}}return s}function xOe(o,p,i=!1){var E,b,w,V,$,L,k,K;let n={};if(((b=(E=o.getDataType(null))==null?void 0:E.entity)==null?void 0:b.type)===d.DefinitionEntity&&(n={...n,...((w=o.getDataType(null))==null?void 0:w.entity).getActiveRawDefaultValue()}),p.execution&&p.execution.hasEntity(o)&&!i){const S=(V=p.lastExecutionResults)==null?void 0:V.readValue(o.id);if(S){if(hr(S.value)){const re={...n,...S.value},ee={...Pm(re,o,p,i)};S.metaSync({value:ee},null)}return{value:S,valueOwner:o,type:Pe.ExecutionResult,inheritanceLink:null}}}const s=!!(($=p.execution)!=null&&$.entities.length),c=(L=p.execution)==null?void 0:L.hasEntity(o),e=o.readsValue;let y=null;if(e){const S=(k=p.execution)==null?void 0:k.hasEntity(e);if((!s||s&&S&&c||s&&!S&&!c)&&(y=Lh(o,p,i),y&&y.value&&hr(y.value.value))){const re={...n,...y.value.value},ee={...Pm(re,o,p,i)};y.value.metaSync({value:ee},null)}}const m=o.getDefaultValue(),v=p.getValueTypePreference(o.id);if(!y&&m){const S=m;if(S&&S.value===null&&S.autogeneration){const Y=LR(S);if(S.metaSync({value:Y},null),hr(Y)){const re={...Pm(Y,o,p,i)};S.metaSync({value:re},null)}}(i||v===null||v!==Pe.Testing)&&(y={value:S,valueOwner:o,type:un(S)?o.readsValue?Pe.Inherited:Pe.Empty:Pe.DefaultValue,inheritanceLink:null})}if(!y||(y.type===Pe.DefaultValue||y.type===Pe.External)&&!i||v===null||v!==Pe.DefaultValue){const S=(K=p.localTestValues)==null?void 0:K.readValue(o.id);if(S){if(hr(S.value)){const Y={...n,...S.value},re={...Pm(Y,o,p,i)};S.metaSync({value:re},null)}return{value:S,valueOwner:o,type:Pe.Testing,inheritanceLink:null}}}return un((y==null?void 0:y.value)||null)?{value:null,valueOwner:o,type:o.readsValue?Pe.Inherited:Pe.Empty,inheritanceLink:null}:y}function HP(o,p,i=!1){var e,y,m,v,E,b,w,V,$;let n={};if(((y=(e=o.getDataType(null))==null?void 0:e.entity)==null?void 0:y.type)===d.DefinitionEntity&&(n={...n,...((m=o.getDataType(null))==null?void 0:m.entity).getActiveRawDefaultValue()}),p.execution&&p.execution.hasEntity(o)&&!i){const L=(v=p.lastExecutionResults)==null?void 0:v.readValue(o.id);if(L){if(hr(L.value)){const K={...n,...L.value},S=Ub(K,o,p,i);L==null||L.metaSync({value:S},null)}return{value:L,valueOwner:o,type:Pe.ExecutionResult,inheritanceLink:null}}}const s=(E=p.localTestValues)==null?void 0:E.readValue(o.id),c=p.getValueTypePreference(o.id);if(s&&!i&&(c===null||c!==Pe.DefaultValue)){if(hr(s.value)){const k={...n,...s.value},K=Ub(k,o,p,i);s.metaSync({value:K},null)}return{value:s,valueOwner:o,type:Pe.Testing,inheritanceLink:null}}if((b=o.getDataType(null))!=null&&b.entity&&((V=(w=o.getDataType(null))==null?void 0:w.entity)==null?void 0:V.type)===d.DefinitionEntity&&(($=o.getDataType(null))!=null&&$.isObject())){const L=It(o.dataType,o,p.project),k=Ub(n,o,p,i);return L==null||L.metaSync({value:k},null),{value:L,valueOwner:o,type:Pe.DefaultValue,inheritanceLink:null}}return null}function av(o,p,i=!1){var E,b,w,V,$;if((E=o.dataType)!=null&&E.isObject())return xOe(o,p,i);const n=li(o),s=!!((b=p.execution)!=null&&b.entities.length),c=(w=p.execution)==null?void 0:w.hasEntity(n),e=o.readsValue;let y=null;if(e){const L=(V=p.execution)==null?void 0:V.hasEntity(e);(!s||s&&L&&c||s&&!L&&!c)&&(y=Lh(o,p,i))}const m=o.getDefaultValue(),v=p.getValueTypePreference(o.id);if(!y&&m){const L=m;if(L&&L.value===null&&L.autogeneration){const k=LR(L);L.metaSync({value:k},null)}(i||v===null||v!==Pe.Testing)&&(y={value:L,valueOwner:o,type:un(L)?o.readsValue?Pe.Inherited:Pe.Empty:Pe.DefaultValue,inheritanceLink:null})}if(!y||(y.type===Pe.DefaultValue||y.type===Pe.External)&&!i||v===null||v!==Pe.DefaultValue){const L=($=p.localTestValues)==null?void 0:$.readValue(o.id);if(L)return{value:L,valueOwner:o,type:Pe.Testing,inheritanceLink:null}}return un((y==null?void 0:y.value)||null)?{value:null,valueOwner:o,type:o.readsValue?Pe.Inherited:Pe.Empty,inheritanceLink:null}:y}function WP(o,p,i=!1){var e,y,m;if((e=o.dataType)!=null&&e.isObject())return HP(o,p);if(p.execution&&p.execution.hasEntity(o)&&!i){const v=(y=p.lastExecutionResults)==null?void 0:y.readValue(o.id);if(v)return{value:v,valueOwner:o,type:Pe.ExecutionResult,inheritanceLink:null}}const n=(m=p.localTestValues)==null?void 0:m.readValue(o.id),s=p.getValueTypePreference(o.id);return n&&!i&&(s===null||s!==Pe.DefaultValue)?{value:n,valueOwner:o,type:Pe.Testing,inheritanceLink:null}:av(o,p,i)}function zP(o,p,i=!1){var w,V,$,L;const n=!!((w=p.execution)!=null&&w.entities.length),s=(V=p.execution)==null?void 0:V.hasEntity(o);let c=null;const e=o.readsValue;if(e){const k=($=p.execution)==null?void 0:$.hasEntity(e);(!n||n&&k&&s||n&&!k&&!s)&&(c=Lh(o,p,i))}const y=o.declaration;if(!c&&y){const k=av(y,p);k&&k.value&&(c=k)}const m=p.getValueTypePreference(o.id);if(!c||(c.type===Pe.DefaultValue||c.type===Pe.External)&&!i||m===null||m!==Pe.DefaultValue){const k=(L=p.localTestValues)==null?void 0:L.readValue(o.id);if(k)return{value:k,valueOwner:o,type:Pe.Testing,inheritanceLink:null}}const v=$o(o),E=o.getDataType(null);return v&&s&&(!(c!=null&&c.value)||!Il(E)&&eu(c==null?void 0:c.value))?{value:null,valueOwner:o,type:Pe.Missing,inheritanceLink:null}:s&&!v&&un((c==null?void 0:c.value)||null)?{value:null,valueOwner:o,type:o.readsValue?Pe.Inherited:Pe.Empty,inheritanceLink:null}:c||{value:null,valueOwner:o,type:Pe.External,inheritanceLink:null}}function $Oe(o,p,i=!1){return WP(o.declaration,p,i)}function LOe(o,p,i=!1){var w,V,$,L;if(!i&&p.execution&&p.execution.hasEntity(o)){const k=(w=p.lastExecutionResults)==null?void 0:w.readValue(o.id);if(k)return{value:k,valueOwner:o,type:Pe.ExecutionResult,inheritanceLink:null}}const n=li(o),s=o.parent.type===d.FunctionDeclaration&&o.parent.parent.type===d.Loop?o.parent:null,c=!!((V=p.execution)!=null&&V.hasEntity(n))||!!s&&!!(($=p.execution)!=null&&$.hasEntity(s));let e=null;const y=o.getDefaultValue(),m=p.getValueTypePreference(o.id);if(y){const k=y||null;if(k&&k.value===null&&k.autogeneration){const K=LR(k);k.metaSync({value:K},null)}(i||m===null||m!==Pe.Testing)&&(e={value:k,valueOwner:o,type:un(k)?Pe.Empty:Pe.DefaultValue,inheritanceLink:null})}if(!e||(e.type===Pe.DefaultValue||e.type===Pe.External)&&!i||m===null||m!==Pe.DefaultValue){const k=(L=p.localTestValues)==null?void 0:L.readValue(o.id),K=p.getValueTypePreference(o.id);if(k&&!i&&(K===null||K!==Pe.DefaultValue))return{value:k,valueOwner:o,type:Pe.Testing,inheritanceLink:null}}const v=$o(o),E=o.getDataType(null);let b=v&&c&&(!(e!=null&&e.value)||!Il(E)&&eu(e==null?void 0:e.value));return n.type===d.Loop&&c&&(b=!1),b?{value:null,valueOwner:o,type:Pe.Missing,inheritanceLink:null}:c&&!v&&un((e==null?void 0:e.value)||null)?{value:null,valueOwner:o,type:Pe.Empty,inheritanceLink:null}:e||{value:null,valueOwner:o,type:Pe.External,inheritanceLink:null}}function JP(o,p,i=!1){var V,$,L,k,K,S;if((V=o.getDataType(null))!=null&&V.isObject())return HP(o,p);if(p.execution&&p.execution.hasEntity(o)&&!i){const Y=($=p.lastExecutionResults)==null?void 0:$.readValue(o.id);if(Y)return{value:Y,valueOwner:o,type:Pe.ExecutionResult,inheritanceLink:null}}const n=li(o),s=!!((L=p.execution)!=null&&L.entities.length),c=(k=p.execution)==null?void 0:k.hasEntity(n),e=o.readsValue;let y=null;if(e){const Y=(K=p.execution)==null?void 0:K.hasEntity(e);(!s||s&&Y&&c||s&&!Y&&!c)&&(y=Lh(o,p,i))}const m=o.getDefaultValue(),v=p.getValueTypePreference(o.id);if(!y&&m){const Y=m;(i||v===null||v!==Pe.Testing)&&(y={value:Y,valueOwner:o,type:Pe.DefaultValue,inheritanceLink:null})}if(!y||(y.type===Pe.DefaultValue||y.type===Pe.External)&&!i||v===null||v!==Pe.DefaultValue){const Y=(S=p.localTestValues)==null?void 0:S.readValue(o.id);if(Y)return{value:Y,valueOwner:o,type:Pe.Testing,inheritanceLink:null}}const E=$o(o),b=o.getDataType(null);return E&&(!(y!=null&&y.value)||!Il(b)&&eu(y==null?void 0:y.value))?{value:null,valueOwner:o,type:Pe.Missing,inheritanceLink:null}:!E&&un((y==null?void 0:y.value)||null)?{value:null,valueOwner:o,type:o.readsValue?Pe.Inherited:Pe.Empty,inheritanceLink:null}:y}function MOe(o,p,i=!1){var y,m,v,E,b,w,V,$,L,k,K,S,Y;if(p.execution&&p.execution.hasEntity(o)&&!i){const re=(y=p.lastExecutionResults)==null?void 0:y.readValue(o.id);if(re)return{value:re,valueOwner:o,type:Pe.ExecutionResult,inheritanceLink:null}}const n=Ny(o);if(Ty.includes(n.type)){const re=Mu(n,p,i),ee=o.codeName||((m=o.declaration)==null?void 0:m.codeName)||Hi(se(o,p.project));if(re!=null&&re.value&&hr(re.value.value)){const de=re.value.value[ee],le=It(o.getDataType(null),o,p.project);return le==null||le.metaSync({value:de},null),{value:le,valueOwner:o,type:!Gt.includes(n.type)&&re.type===Pe.Empty?Pe.QueuedAutocalculation:re.type,inheritanceLink:{sources:[re],target:o}}}return{value:null,valueOwner:o,type:Gt.includes(n.type)?Pe.Empty:Pe.QueuedAutocalculation,inheritanceLink:null}}const s=(v=p.execution)==null?void 0:v.hasEntity(n),c=((E=p.execution)==null?void 0:E.state)===pN.Running;if((b=p.persistedExecutionResults)!=null&&b.values[o.id]&&!s&&!c&&!i){const re=(w=p.persistedExecutionResults)==null?void 0:w.readValue(o.id);if((re==null?void 0:re.value)!==null||(re==null?void 0:re.valueAsType)!==null)return{value:re,valueOwner:o,type:Pe.ExecutionResult,inheritanceLink:null}}const e=o.parent;if(!e)throw new Error(`Couldn't find the parent that generates the output ${o.id}`);switch(e.type){case d.VariableInstance:{const ee=zP(e,p,i);if(ee&&ee.value){const le=o.declaration;if(hr(ee.value.value)){const fe=ee.value.value[le.name],ve=It(((V=o.declaration)==null?void 0:V.dataType)||null,o,p.project);return ve==null||ve.metaSync({value:fe},null),{value:ve,valueOwner:o,type:Pe.Inherited,inheritanceLink:{sources:[ee],target:o}}}}const de=It((($=o.declaration)==null?void 0:$.dataType)||null,o,p.project);return de==null||de.metaSync({value:null},null),{value:de,valueOwner:o,type:Pe.Inherited,inheritanceLink:{sources:ee?[ee]:[],target:o}}}case d.VariableDeclaration:{const ee=av(e,p,i);if(ee&&ee.value){const le=o.declaration;if(hr(ee.value.value)){const fe=ee.value.value[le.name],ve=It(((L=o.declaration)==null?void 0:L.dataType)||null,o,p.project);return ve==null||ve.metaSync({value:fe},null),{value:ve,valueOwner:o,type:Pe.Inherited,inheritanceLink:{sources:[ee],target:o}}}}const de=It(((k=o.declaration)==null?void 0:k.dataType)||null,o,p.project);return de==null||de.metaSync({value:null},null),{value:de,valueOwner:o,type:Pe.Inherited,inheritanceLink:{sources:ee?[ee]:[],target:o}}}case d.Operation:{const re=e.outputs.map(de=>{var le,fe;if((le=p.persistedExecutionResults)!=null&&le.values[de.id]){const ve=(fe=p.persistedExecutionResults)==null?void 0:fe.values[de.id];if(ve.value!==null||ve.valueAsType!==null)return{value:ve,valueOwner:de,type:Pe.ExecutionResult,inheritanceLink:null}}}).filter(de=>!!de),ee=It(((K=o.declaration)==null?void 0:K.dataType)||null,o,p.project);return ee==null||ee.metaSync({value:null},null),{value:ee,valueOwner:o,type:Pe.QueuedAutocalculation,inheritanceLink:re.length?{sources:re,target:o}:null}}case d.FunctionCall:{const re=e.inputs.map(de=>pA(de,p,i)).filter(de=>!!de),ee=It(((S=o.declaration)==null?void 0:S.dataType)||null,o,p.project);return ee==null||ee.metaSync({value:null},null),{value:ee,valueOwner:o,type:Pe.QueuedAutocalculation,inheritanceLink:re.length?{sources:re,target:o}:null}}case d.Loop:{const re=e.inputs.map(de=>pA(de,p,i)).filter(de=>!!de),ee=It(((Y=o.declaration)==null?void 0:Y.dataType)||null,o,p.project);return ee==null||ee.metaSync({value:null},null),{value:ee,valueOwner:o,type:Pe.QueuedAutocalculation,inheritanceLink:re.length?{sources:re,target:o}:null}}case d.Search:return{value:null,valueOwner:o,type:Pe.QueuedAutocalculation,inheritanceLink:null}}return null}function HO(o,p,i=!1){var b,w,V;if(![...qt,...Gt].includes(o.parent.type)||!xv(o))return null;if(((b=o.declaration)==null?void 0:b.type)===d.Property&&o.declaration.static)return Mu(o.declaration,p);const n=sv(o,p,i);if(n&&n.type!==Pe.Empty&&n.type!==Pe.Missing)return n;const s=Wn(o.parent),c=Ao(s,p,i),e=o.codeName||((w=o.declaration)==null?void 0:w.codeName)||Hi(se(o,p.project)),y=It(o.getDataType(null),o,p.project),m=$o(o),v=(V=c==null?void 0:c.value)==null?void 0:V.value;if(v&&hr(v)){let $=v[e];v[e]===void 0&&($=null),y==null||y.metaSync({value:$},null);const L=$o(o),k=o.getDataType(null);return L&&(!y||!Il(k)&&eu(y))?{value:null,valueOwner:o,type:Pe.Missing,inheritanceLink:null}:{value:y,valueOwner:o,type:c.type,inheritanceLink:{sources:c?[c]:[],target:o}}}return m?{value:null,valueOwner:o,type:Pe.Missing,inheritanceLink:null}:{value:null,valueOwner:o,type:o.readsValue?Pe.Inherited:Pe.Empty,inheritanceLink:null}}function WO(o,p,i=!1){var b,w,V,$,L,k,K,S;if(![...qt,...Gt].includes(o.parent.type)||!xv(o))return null;if(((b=o.declaration)==null?void 0:b.type)===d.Property&&o.declaration.static)return Mu(o.declaration,p,i);const n=qt.includes(o.parent.type)?o.parent:Wn(o.parent),s=Mu(n,p,i);let c=o;n.type===d.VariableDeclaration&&(c=(o.parent===n?o:n.inputs.find(re=>{var ee,de;return((ee=re.declaration)==null?void 0:ee.id)===((de=o.declaration)==null?void 0:de.id)}))||o);const e=Fm(c,p,i),y=o.codeName||((w=o.declaration)==null?void 0:w.codeName)||Hi(se(o,p.project)),m=(n.type===d.VariableDeclaration?o.getDefaultValue():o.defaultValue)||It(o.getDataType(null),o,p.project),v=(V=s==null?void 0:s.value)==null?void 0:V.value;if(((s==null?void 0:s.type)===Pe.ExecutionResult||(s==null?void 0:s.type)===Pe.Testing)&&!i&&v&&hr(v)){let Y=v[y];return v[y]===void 0&&(Y=null),m==null||m.metaSync({value:Y},null),{value:m,valueOwner:o,type:s.type,inheritanceLink:{sources:s?[s]:[],target:o}}}if(e&&e.type!==Pe.Empty&&e.type!==Pe.Missing)return e;if(v&&hr(v)){let Y=v[y];v[y]===void 0&&(Y=null),m!=null&&m.standaloneParent&&(m==null||m.metaSync({value:Y},null));const re=$o(o),ee=o.getDataType(null),de=re&&(!m||!Il(ee)&&eu(m)),le=!!(($=p.execution)!=null&&$.entities.length),fe=(L=p.execution)==null?void 0:L.hasEntity(n),ve=n.readsValue;if(ve){const ue=(k=p.execution)==null?void 0:k.hasEntity(ve);if(de&&(!le||le&&ue&&fe||le&&!ue&&!fe))return{value:null,valueOwner:o,type:Pe.Inherited,inheritanceLink:null}}if(o.readsValue){const ue=(K=p.execution)==null?void 0:K.hasEntity(o.readsValue);if(de&&(!le||le&&ue&&fe||le&&!ue&&!fe))return{value:null,valueOwner:o,type:Pe.Inherited,inheritanceLink:null}}return de?{value:null,valueOwner:o,type:Pe.Missing,inheritanceLink:null}:{value:m,valueOwner:o,type:((S=m==null?void 0:m.parent)==null?void 0:S.id)===(o==null?void 0:o.id)?s.type:Pe.Inherited,inheritanceLink:{sources:s?[s]:[],target:o}}}return Fm(o,p,i)}function sv(o,p,i=!1){var V,$,L,k,K,S;const n=li(o),s=!!((V=p.execution)!=null&&V.entities.length),c=($=p.execution)==null?void 0:$.hasEntity(n),e=o.readsValue;let y=null;if(e){const Y=(L=p.execution)==null?void 0:L.hasEntity(e);(!s||s&&Y&&c||s&&!Y&&!c)&&(y=Lh(o,p,i))}const m=o.getDefaultValue(),v=p.getValueTypePreference(o.id);if(!y&&m&&(i||v===null||v!==Pe.Testing)&&(y={value:m,valueOwner:o,type:un(m)?Pe.Empty:Pe.DefaultValue,inheritanceLink:null}),!y&&o.declaration){const Y=Mu(o.declaration,p,i);Y&&Y.value&&(i||v===null||v!==Pe.Testing)&&(y={...Y,valueOwner:o,type:Pe.DefaultValue})}if(!y||y.type===Pe.DefaultValue||(y==null?void 0:y.type)===Pe.Empty){const Y=(k=p.persistedExecutionResults)==null?void 0:k.readValue(o.id);if(Y&&!i)return{value:Y,valueOwner:o,type:Pe.Testing,inheritanceLink:null};const re=(K=p.localTestValues)==null?void 0:K.readValue(o.id);if(re&&!i&&(v===null||v!==Pe.DefaultValue))return{value:re,valueOwner:o,type:Pe.Testing,inheritanceLink:null}}const E=$o(o),b=o.getDataType(null),w=E&&c&&(!(y!=null&&y.value)||!Il(b)&&eu(y==null?void 0:y.value));if(o.readsValue){const Y=(S=p.execution)==null?void 0:S.hasEntity(o.readsValue);if(w&&(!s||s&&Y&&c||s&&!Y&&!c))return{value:null,valueOwner:o,type:Pe.Inherited,inheritanceLink:null}}return w?{value:null,valueOwner:o,type:Pe.Missing,inheritanceLink:(y==null?void 0:y.inheritanceLink)||null}:!E&&(!y||y.type===Pe.Inherited)&&!(y!=null&&y.inheritanceLink)?{value:null,valueOwner:o,type:o.readsValue?Pe.Inherited:Pe.Empty,inheritanceLink:null}:y}function Fm(o,p,i=!1){var e,y;if(p.execution&&p.execution.hasEntity(o)&&!i){const m=(e=p.lastExecutionResults)==null?void 0:e.readValue(o.id);if(m)return{value:m,valueOwner:o,type:Pe.ExecutionResult,inheritanceLink:null}}const n=(y=p.localTestValues)==null?void 0:y.readValue(o.id),s=p.getValueTypePreference(o.id);return n&&!i&&(s===null||s!==Pe.DefaultValue)?{value:n,valueOwner:o,type:Pe.Testing,inheritanceLink:null}:sv(o,p,i)}function pA(o,p,i=!1){var n,s;return Gt.includes(o.parent.type)&&(n=Wn(o.parent).dataType)!=null&&n.isObject()||qt.includes(o.parent.type)&&(s=o.parent.getDataType(null))!=null&&s.isObject()?HO(o,p,i):sv(o,p,i)}function BOe(o,p,i=!1){var n,s;return Gt.includes(o.parent.type)&&(n=Wn(o.parent).dataType)!=null&&n.isObject()||qt.includes(o.parent.type)&&(s=o.parent.getDataType(null))!=null&&s.isObject()?WO(o,p,i):Fm(o,p,i)}function GOe(o,p,i=!1){var E,b;if(!o.static)return null;if(p.execution){const w=(E=p.lastExecutionResults)==null?void 0:E.readValue(o.id);if(w&&!i)return{value:w,valueOwner:o,type:Pe.ExecutionResult,inheritanceLink:null}}const n=(b=p.localTestValues)==null?void 0:b.readValue(o.id),s=p.getValueTypePreference(o.id);if(n&&!i&&(s===null||s!==Pe.DefaultValue))return{value:n,valueOwner:o,type:Pe.Testing,inheritanceLink:null};const c=o.getDefaultValue();let e=null;c&&(i||s===null||s!==Pe.Testing)&&(e={value:c,valueOwner:o,type:Pe.DefaultValue,inheritanceLink:null});const y=$o(o),m=o.getDataType(null);return y&&(!(e!=null&&e.value)||!Il(m)&&eu(e==null?void 0:e.value))?{value:null,valueOwner:o,type:Pe.Missing,inheritanceLink:null}:un(e==null?void 0:e.value)?{value:null,valueOwner:o,type:Pe.Empty,inheritanceLink:null}:e}function kOe(o,p,i=!1){var E,b;if(p.execution&&p.execution.hasEntity(o)&&!i){const w=(E=p.lastExecutionResults)==null?void 0:E.readValue(o.id);if(w)return{value:w,valueOwner:o,type:Pe.ExecutionResult,inheritanceLink:null}}const n=(b=p.localTestValues)==null?void 0:b.readValue(o.id),s=p.getValueTypePreference(o.id);if(n&&!i&&(s===null||s!==Pe.DefaultValue))return{value:n,valueOwner:o,type:Pe.Testing,inheritanceLink:null};const c=o.getDefaultValue();let e=null;c&&(i||s===null||s!==Pe.Testing)&&(e={value:c,valueOwner:o,type:Pe.DefaultValue,inheritanceLink:null});const y=$o(o),m=o.getDataType(null);return y&&(!(e!=null&&e.value)||!Il(m)&&eu(e==null?void 0:e.value))?{value:null,valueOwner:o,type:Pe.Missing,inheritanceLink:null}:un((e==null?void 0:e.value)||null)?{value:null,valueOwner:o,type:Pe.Empty,inheritanceLink:null}:e}function Mu(o,p,i=!1){switch(o.type){case d.ArgumentDeclaration:return LOe(o,p,i);case d.InputMap:return BOe(o,p,i);case d.VariableDeclaration:return WP(o,p,i);case d.VariableInstance:return $Oe(o,p,i);case d.OutputMap:return MOe(o,p,i);case d.ReturnStatement:case d.BreakStatement:case d.ContinueStatement:return JP(o,p,i);case d.Property:return GOe(o,p,i);case d.ValueDescriptor:return kOe(o,p,i);case d.Operation:case d.FunctionCall:case d.InternalCall:case d.Search:return NOe(o,p,i);default:return null}}function Ao(o,p,i=!1){switch(o.type){case d.InputMap:return pA(o,p,i);case d.VariableDeclaration:return av(o,p,i);case d.VariableInstance:return zP(o,p,i);case d.ReturnStatement:case d.BreakStatement:case d.ContinueStatement:return JP(o,p,i);default:return null}}function Tvi(o){var p;if(o&&o.type===Pe.DefaultValue&&o.value&&o.valueOwner&&(!kA.includes(o.valueOwner.type)||((p=o.valueOwner.getDefaultValue())==null?void 0:p.id)===o.value.id)){const i=It(o.valueOwner.getDataType(null),o.valueOwner,o.valueOwner.project);return{type:Pe.DefaultValue,value:i,valueOwner:o.valueOwner,inheritanceLink:null}}return o}function Rc(o,p,i,n){let s=!1,c=null,e=null;n instanceof Z?(s=!0,c=n,e=null):(c=null,e=n);const y=o.parent;return p.getVariableDeclarations().forEach(v=>{var b,w,V,$,L,k;const E=v.getDataType(null);if(((b=E==null?void 0:E.entity)==null?void 0:b.id)===y.id){let K=s?v.getDefaultValue():e==null?void 0:e.readValue(v.id);K?!s&&K&&K.id===((w=v.getDefaultValue())==null?void 0:w.id)&&(K=It(v.getDataType(null),v,p)):s?K=Qd(v.getDataType(null),v,p,c):K=It(v.getDataType(null),v,p);const S=se(o,p),Y=o.codeName||((V=o.extends)==null?void 0:V.codeName)||(($=o.implements[0])==null?void 0:$.codeName)||Hi(S);let re={};((k=(L=v.dataType)==null?void 0:L.entity)==null?void 0:k.type)===d.DefinitionEntity&&(re={...re,...v.dataType.entity.getActiveRawDefaultValue()}),hr(K==null?void 0:K.value)&&(re={...re,...K.value}),re[Y]=i,K==null||K.metaSync({value:re},c),s||e==null||e.writeValue(v,K);return}}),c}function Sm(o,p,i,n){var V,$,L,k;let s=!1,c=null,e=null;n instanceof Z?(s=!0,c=n,e=null):(c=null,e=n);const y=Wn(o.parent),m=y.getDataType(null);if(!(m!=null&&m.isObject()))return c;let v=s?y.getDefaultValue():e==null?void 0:e.readValue(y.id);v?!s&&v&&v.id===((V=y.getDefaultValue())==null?void 0:V.id)&&(v=It(y.getDataType(null),y,p)):s?v=Qd(y.getDataType(null),y,p,c):v=It(y.getDataType(null),y,p);const E=se(o,p),b=o.codeName||(($=o.declaration)==null?void 0:$.codeName)||Hi(E);let w={};if(((k=(L=y.dataType)==null?void 0:L.entity)==null?void 0:k.type)===d.DefinitionEntity&&(w={...w,...y.dataType.entity.getActiveRawDefaultValue()}),hr(v==null?void 0:v.value)&&(w={...w,...v.value}),w[b]=i,v==null||v.metaSync({value:w},c),s||e==null||e.writeValue(y,v),(i===""||i===null||i===void 0)&&o.type===d.OutputMap){const K=y.inputs.find(S=>{var Y,re;return((Y=S.declaration)==null?void 0:Y.id)===((re=o.declaration)==null?void 0:re.id)||se(S,p)===E});if(K){let S=s?K.getDefaultValue():e==null?void 0:e.readValue(K.id);S&&S.metaSync({value:null},c),s||e==null||e.removeValue(K.id)}}return c}function jOe(o,p,i){var e,y,m,v,E;let n=!1,s=null,c=null;if(i instanceof Z?(n=!0,s=i,c=null):(s=null,c=i),Gt.includes(o.type)){const b=Wn(o);(e=b.dataType)!=null&&e.isObject()&&b.inputs.forEach(w=>{var V,$,L,k,K,S;if(((V=w.declaration)==null?void 0:V.type)===d.Property&&w.declaration.static){let Y=n?(($=w.getDefaultValue)==null?void 0:$.call(w))||null:c==null?void 0:c.readValue(w.declaration.id);Y?!n&&Y&&Y.id===((L=w.declaration.getDefaultValue())==null?void 0:L.id)&&(Y=It(w.declaration.getDataType(null),w.declaration,p)):n?Y=Qd(w.declaration.getDataType(null),w.declaration,p,s):Y=It(w.declaration.getDataType(null),w.declaration,p),Y==null||Y.metaSync({value:null},s),n||c==null||c.removeValue((k=w.declaration)==null?void 0:k.id)}else if(((K=w.declaration)==null?void 0:K.type)===d.Property){let Y=n?((S=w.getDefaultValue)==null?void 0:S.call(w))||null:c==null?void 0:c.readValue(w.id);Y&&Y.metaSync({value:null},s),n||c==null||c.removeValue(w.id)}})}else o.type===d.InputMap?((y=o.declaration)==null?void 0:y.type)===d.Property&&o.declaration.static?Rc(o.declaration,p,null,i):Gt.includes(o.parent.type)&&((m=o.declaration)==null?void 0:m.type)===d.Property&&Sm(o,p,null,i):o.type===d.OutputMap?((v=o.declaration)==null?void 0:v.type)===d.Property&&o.declaration.static?Rc(o.declaration,p,null,i):Gt.includes(o.parent.type)&&((E=o.declaration)==null?void 0:E.type)===d.Property&&Sm(o,p,null,i):o.type===d.Property&&o.static&&Rc(o,p,null,i);return s}function UOe(o,p,i,n){var y,m,v,E,b,w,V;let s=!1,c=null,e=null;if(n instanceof Z?(s=!0,c=n,e=null):(c=null,e=n),Gt.includes(p.type)){const $=Wn(p);if((y=$.dataType)!=null&&y.isObject()){let L={};((v=(m=$.dataType)==null?void 0:m.entity)==null?void 0:v.type)===d.DefinitionEntity&&(L={...L,...$.dataType.entity.getActiveRawDefaultValue()});const k=hr(o)?o:L;$.inputs.forEach(K=>{var S,Y,re,ee,de,le;if(((S=K.declaration)==null?void 0:S.type)===d.Property&&K.declaration.static){let fe=s?((Y=p.getDefaultValue)==null?void 0:Y.call(p))||null:e==null?void 0:e.readValue(K.declaration.id);fe?!s&&fe&&fe.id===((re=K.declaration.getDefaultValue())==null?void 0:re.id)&&(fe=It(K.declaration.getDataType(null),K.declaration,i)):s?fe=Qd(K.declaration.getDataType(null),K.declaration,i,c):fe=It(K.declaration.getDataType(null),K.declaration,i);const ve=se(K,i),ue=K.codeName||((ee=K.declaration)==null?void 0:ee.codeName)||Hi(ve),ye=k[ue];fe==null||fe.metaSync({value:ye},c),s||e==null||e.writeValue(K.declaration,fe)}else if(((de=K.declaration)==null?void 0:de.type)===d.Property){let fe=s?((le=p.getDefaultValue)==null?void 0:le.call(p))||null:e==null?void 0:e.readValue(K.id);fe&&fe.metaSync({value:null},c),s||e==null||e.removeValue(K.id)}})}}else p.type===d.InputMap?((E=p.declaration)==null?void 0:E.type)===d.Property&&p.declaration.static?Rc(p.declaration,i,o,n):Gt.includes(p.parent.type)&&((b=p.declaration)==null?void 0:b.type)===d.Property&&Sm(p,i,o,n):p.type===d.OutputMap?((w=p.declaration)==null?void 0:w.type)===d.Property&&p.declaration.static?Rc(p.declaration,i,null,n):Gt.includes(p.parent.type)&&((V=p.declaration)==null?void 0:V.type)===d.Property&&Sm(p,i,null,n):p.type===d.Property&&p.static&&Rc(p,i,o,n);return c}function vvi(o,p,i){const n=Oo(o,p);let s=!1,c=null,e=null;return i instanceof Z?(s=!0,c=i,e=null):(c=null,e=i),n.forEach(y=>{var v;let m=s?((v=y.getDefaultValue)==null?void 0:v.call(y))||null:e==null?void 0:e.readValue(y.id);s?m==null||m.remove({ignoreUpstream:!1},c):e==null||e.removeValue(y.id),jOe(y,p,i)}),c}function Evi(o,p,i,n){const s=Oo(p,i);let c=!1,e=null,y=null;return n instanceof Z?(c=!0,e=n,y=null):(e=null,y=n),i.diggestedBuiltInBaseEntitiesIds.has(p.id)||s.forEach(m=>{var E,b,w,V;if(i.diggestedBuiltInBaseEntitiesIds.has(m.id))return;let v=null;if(c){const $=((E=m.getDefaultValue)==null?void 0:E.call(m))||null;$&&(i.diggestedBuiltInBaseEntitiesIds.has($.id)||((b=$.parent)==null?void 0:b.id)!==m.id?v=$.clone(e,m):v=$)}else v=y==null?void 0:y.readValue(m.id);v?!c&&v&&v.id===((V=(w=m.getDefaultValue)==null?void 0:w.call(m))==null?void 0:V.id)&&(v=It(m.getDataType(null),m,i)):c?(v=Qd(m.getDataType(null),m,i,e),e==null||e.add(v,H.Added)):v=It(m.getDataType(null),m,i),v==null||v.setValueAsType(null,e),v==null||v.metaSync({value:o},e),c||y==null||y.writeValue(m,v),UOe(o,m,i,n)}),e}function Dc(o,p,i,n){let s=!1,c=null,e=null;n instanceof Z?(s=!0,c=n,e=null):(c=null,e=n);const y=o.parent;return p.getVariableDeclarations().forEach(v=>{var b,w,V,$,L,k;const E=v.getDataType(null);if(((b=E==null?void 0:E.entity)==null?void 0:b.id)===y.id){let K=s?v.getDefaultValue():e==null?void 0:e.readValue(v.id);K?!s&&K&&K.id===((w=v.getDefaultValue())==null?void 0:w.id)&&(K=It(v.getDataType(null),v,p)):s?K=Qd(v.getDataType(null),v,p,c):K=It(v.getDataType(null),v,p);const S=se(o,p),Y=o.codeName||((V=o.extends)==null?void 0:V.codeName)||(($=o.implements[0])==null?void 0:$.codeName)||Hi(S);let re={};((k=(L=v.dataType)==null?void 0:L.entity)==null?void 0:k.type)===d.DefinitionEntity&&(re={...re,...v.dataType.entity.getActiveRawDefaultValue()}),hr(K==null?void 0:K.value)&&(re={...re,...K.value}),Array.isArray(i)?re[Y]=(i==null?void 0:i.map(ee=>ee.toShallowJSON()))||null:re[Y]=(i==null?void 0:i.toShallowJSON())||null,K==null||K.metaSync({value:re},c),s||e==null||e.writeValue(v,K);return}}),c}function qm(o,p,i,n){var V,$,L,k;let s=!1,c=null,e=null;n instanceof Z?(s=!0,c=n,e=null):(c=null,e=n);const y=Wn(o.parent),m=y.getDataType(null);if(!(m!=null&&m.isObject()))return c;let v=s?y.getDefaultValue():e==null?void 0:e.readValue(y.id);v?!s&&v&&v.id===((V=y.getDefaultValue())==null?void 0:V.id)&&(v=It(y.getDataType(null),y,p)):s?v=Qd(y.getDataType(null),y,p,c):v=It(y.getDataType(null),y,p);const E=se(o,p),b=o.codeName||(($=o.declaration)==null?void 0:$.codeName)||Hi(E);let w={};if(((k=(L=y.dataType)==null?void 0:L.entity)==null?void 0:k.type)===d.DefinitionEntity&&(w={...w,...y.dataType.entity.getActiveRawDefaultValue()}),hr(v==null?void 0:v.value)&&(w={...w,...v.value}),Array.isArray(i)?w[b]=(i==null?void 0:i.map(K=>K.toShallowJSON()))||null:w[b]=(i==null?void 0:i.toShallowJSON())||null,v==null||v.metaSync({value:w},c),s||e==null||e.writeValue(y,v),i==null&&o.type===d.OutputMap){const K=y.inputs.find(S=>{var Y,re;return((Y=S.declaration)==null?void 0:Y.id)===((re=o.declaration)==null?void 0:re.id)||se(S,p)===E});if(K){let S=s?K.getDefaultValue():e==null?void 0:e.readValue(K.id);S&&(Array.isArray(i)?S==null||S.setValueAsTypeList(i,c):S==null||S.setValueAsTypeSingle(i,c)),s||e==null||e.removeValue(K.id)}}return c}function KOe(o,p,i){var n,s,c,e;return o.type===d.InputMap?((n=o.declaration)==null?void 0:n.type)===d.Property&&o.declaration.static?Dc(o.declaration,p,null,i):Gt.includes(o.parent.type)&&((s=o.declaration)==null?void 0:s.type)===d.Property&&qm(o,p,null,i):o.type===d.OutputMap?((c=o.declaration)==null?void 0:c.type)===d.Property&&o.declaration.static?Dc(o.declaration,p,null,i):Gt.includes(o.parent.type)&&((e=o.declaration)==null?void 0:e.type)===d.Property&&qm(o,p,null,i):o.type===d.Property&&o.static&&Dc(o,p,null,i),i}function FOe(o,p,i,n){var s,c,e,y;return p.type===d.InputMap?((s=p.declaration)==null?void 0:s.type)===d.Property&&p.declaration.static?Dc(p.declaration,i,o,n):Gt.includes(p.parent.type)&&((c=p.declaration)==null?void 0:c.type)===d.Property&&qm(p,i,o,n):p.type===d.OutputMap?((e=p.declaration)==null?void 0:e.type)===d.Property&&p.declaration.static?Dc(p.declaration,i,null,n):Gt.includes(p.parent.type)&&((y=p.declaration)==null?void 0:y.type)===d.Property&&qm(p,i,null,n):p.type===d.Property&&p.static&&Dc(p,i,o,n),n}function bvi(o,p,i){const n=Oo(o,p);let s=!1,c=null,e=null;return i instanceof Z?(s=!0,c=i,e=null):(c=null,e=i),n.forEach(y=>{var v;let m=s?(v=y.getDefaultValue)==null?void 0:v.call(y):e==null?void 0:e.readValue(y.id);s?m==null||m.remove({ignoreUpstream:!1},c):e==null||e.removeValue(y.id),KOe(y,p,i)}),c}function Avi(o,p,i,n){const s=Oo(p,i);let c=!1,e=null,y=null;return n instanceof Z?(c=!0,e=n,y=null):(e=null,y=n),s.forEach(m=>{var E,b,w;let v=c?(E=m.getDefaultValue)==null?void 0:E.call(m):y==null?void 0:y.readValue(m.id);v?!c&&v&&v.id===((w=(b=m.getDefaultValue)==null?void 0:b.call(m))==null?void 0:w.id)&&(v=It(m.getDataType(null),m,m.project)):c?v=Qd(m.getDataType(null),m,i,e):v=It(m.getDataType(null),m,i),Array.isArray(o)?v==null||v.setValueAsTypeList(o,e):v==null||v.setValueAsTypeSingle(o,e),v==null||v.metaSync({value:null},e),c||y==null||y.writeValue(m,v),FOe(o,m,i,n)}),e}class SI{constructor(p,i){this.extensionsRegistry=p,this.contextType=i,this.off=this.extensionsRegistry.off.bind(this.extensionsRegistry),this.on=this.extensionsRegistry.on.bind(this.extensionsRegistry),this.emit=this.extensionsRegistry.emit.bind(this.extensionsRegistry),this.emitAsync=this.extensionsRegistry.emitAsync.bind(this.extensionsRegistry),this.emitAsyncAll=this.extensionsRegistry.emitAsyncAll.bind(this.extensionsRegistry),this.emitAsyncAllSettled=this.extensionsRegistry.emitAsyncAllSettled.bind(this.extensionsRegistry),this.emitAsyncSequentially=this.extensionsRegistry.emitAsyncSequentially.bind(this.extensionsRegistry),this.emitAsyncSequentiallyAll=this.extensionsRegistry.emitAsyncSequentiallyAll.bind(this.extensionsRegistry),this.emitAsyncSequentiallyAllSettled=this.extensionsRegistry.emitAsyncSequentiallyAllSettled.bind(this.extensionsRegistry)}on(p,i){this.extensionsRegistry.on(p,i)}emit(p,...i){this.extensionsRegistry.emit(p,...i)}off(p,i){this.extensionsRegistry.off(p,i)}emitAsync(p,...i){return this.extensionsRegistry.emitAsync(p,...i)}emitAsyncAll(p,...i){return this.extensionsRegistry.emitAsyncAll(p,...i)}emitAsyncAllSettled(p,...i){return this.extensionsRegistry.emitAsyncAllSettled(p,...i)}emitAsyncSequentially(p,...i){return this.extensionsRegistry.emitAsyncSequentially(p,...i)}emitAsyncSequentiallyAll(p,...i){return this.extensionsRegistry.emitAsyncSequentiallyAll(p,...i)}emitAsyncSequentiallyAllSettled(p,...i){return this.extensionsRegistry.emitAsyncSequentiallyAllSettled(p,...i)}}var Ee=(o=>(o[o.High=1]="High",o[o.Normal=5]="Normal",o[o.Low=10]="Low",o))(Ee||{}),X=(o=>(o.Logic="logic",o.EditorGUI="editor-gui",o.GUI="gui",o.Editor="editor",o.Compile="compile",o.PublicationRun="publication-run",o))(X||{}),be=(o=>(o.All="*",o.OnAll="on:*",o.EmitAll="emit:*",o.ReadAll="read:*",o.WriteAll="write:*",o.UpdateAll="update:*",o.DoAll="do:*",o.OnLogicAll="on:logic:*",o.EmitLogicAll="emit:logic:*",o.ReadLogicAll="read:logic:*",o.WriteLogicAll="write:logic:*",o.UpdateLogicAll="update:logic:*",o.DoLogicAll="do:logic:*",o.OnGUIAll="on:gui:*",o.EmitGUIAll="emit:gui:*",o.ReadGUIAll="read:gui:*",o.WriteGUIAll="write:gui:*",o.UpdateGUIAll="update:gui:*",o.DoGUIAll="do:gui:*",o.OnEditorAll="on:editor:*",o.EmitEditorAll="emit:editor:*",o.ReadEditorAll="read:editor:*",o.WriteEditorAll="write:editor:*",o.UpdateEditorAll="update:editor:*",o.DoEditorAll="do:editor:*",o.OnCompileBefore="on:compile:before:DefinitionEntity",o.OnCompileDefault="on:compile:default:DefinitionEntity",o.OnCompileAfter="on:compile:after:DefinitionEntity",o.EmitCompile="emit:compile:DefinitionEntity",o.DoEditorPublish="do:editor:publish",o.PostGUICanvasSlotNewToolbarButton="write:gui:canvas:slot:toolbar-button",o.ReadGUICanvasSlotToolbarButtons="read:gui:canvas:slot:toolbar-buttons",o.UpdateGUIGlobalTheme="update:gui:global:theme",o))(be||{});class SOe{constructor(p){I(this,"state",new Map);p&&(this.state=new Map(Object.entries(p)))}get(p){return this.state.get(p)}set(p,i){this.state.set(p,i)}delete(p){this.state.delete(p)}}class qOe extends SOe{constructor(p,i){super(i),this.parentExtension=p}}class ge{constructor(p,i){I(this,"manifest");I(this,"module");I(this,"state");this.extensionsRegistry=p,this.state=new qOe(this,i)}}class zO extends SI{constructor(i,n){super(i,X.Logic);I(this,"id");this._project=n,this.id=n.id}get type(){return this._project.type}get name(){return this._project.name}get description(){return this._project.description}get version(){return this._project.version}get createdAt(){return this._project.createdAt}get previousVersion(){return this._project.previousVersion}get author(){return this._project.author}get deleted(){return this._project.deleted}get editable(){return this._project.editable}get deletable(){return this._project.deletable}get entities(){return[...this._project.entities]}get projects(){return[...this._project.projects]}get functions(){return[...this._project.functions]}get events(){return[...this._project.events]}get variableDeclarations(){return[...this._project.variableDeclarations]}get variableInstances(){return[...this._project.variableInstances]}get conditions(){return[...this._project.conditions]}get operations(){return[...this._project.operations]}get functionCalls(){return[...this._project.functionCalls]}get loops(){return[...this._project.loops]}get searches(){return[...this._project.searches]}get primitives(){return[...this._project.primitives]}get builtInBaseEntities(){return[...this._project.builtInBaseEntities]}get operationDeclarations(){return[...this._project.operationDeclarations]}get globalEventActionDescriptors(){return[...this._project.globalEventActionDescriptors]}get loopDeclarations(){return[...this._project.loopDeclarations]}get loopDeclarationsBodies(){return[...this._project.loopDeclarationsBodies]}get conditionDeclarations(){return[...this._project.conditionDeclarations]}get valueDescriptors(){return[...this._project.valueDescriptors]}get dataTypes(){return[...this._project.dataTypes]}get errors(){return[...this._project.errors]}get history(){return[...this._project.history]}get undoableStackValueIndex(){return this._project.undoableStackValueIndex}get knownVersions(){return this._project.knownVersions}get activeVersion(){return this._project.activeVersion}get initialized(){return this._project.initialized}get startedInitialization(){return this._project.startedInitialization}closePersistChangeSetsSequentially(){return this._project.closePersistChangeSetsSequentially()}persistChangeSetSequentially(i){return this._project.persistChangeSetSequentially(i)}toLatestChangeSet(i,n,s,c=!1,e="here-this"){return this._project.toLatestChangeSet(i,n,s,c,e)}addChangeSet(i){return this._project.addChangeSet(i)}discardChangeSet(i){return this._project.discardChangeSet(i)}subscribeDependents(i){return this._project.subscribeDependents(i)}unsubscribeDependents(i){return this._project.unsubscribeDependents(i)}syncDependents(i){return this._project.syncDependents(i)}onDetachedDependencyRemoved(i,n,s){return this._project.onDetachedDependencyRemoved(i,n,s)}onDetachedDependencyRestored(i,n,s){return this._project.onDetachedDependencyRestored(i,n,s)}increaseVersion(i){return this._project.increaseVersion(i)}captureVersion(){return this._project.captureVersion()}restoreVersion(i){return this._project.restoreVersion(i)}updateWithShallowTransfer(i,n){return this._project.updateWithShallowTransfer(i,n)}hydrateAncestors(){return this._project.hydrateAncestors()}afterAllChildrenInitialized(i=null){return this._project.afterAllChildrenInitialized(i)}addSelfToProject(i){return this._project.addSelfToProject(i)}get instancesList(){return[...this._project.instancesList]}isOperationDeclaration(i){return this._project.isOperationDeclaration(i)}isGlobalEventActionDescriptor(i){return this._project.isGlobalEventActionDescriptor(i)}isLoopDeclaration(i){return this._project.isLoopDeclaration(i)}isConditionDeclaration(i){return this._project.isConditionDeclaration(i)}findSubscribedBuiltInInstance(i){return this._project.findSubscribedBuiltInInstance(i)}get(i){return this._project.get(i)}getDeleted(i){return this._project.getDeleted(i)}getManaged(i){return this._project.getManaged(i)}getBuiltIn(i){return this._project.getBuiltIn(i)}findSubscribedInstanceFromReference(i){return this._project.findSubscribedInstanceFromReference(i)}findSubscribedBuiltInInstanceFromReference(i){return this._project.findSubscribedBuiltInInstanceFromReference(i)}metaSync(i,n){return this._project.metaSync(i,n)}getAllBuiltInIds(){return this._project.getAllBuiltInIds()}getAllBuiltIn(){return this._project.getAllBuiltIn()}toFlat(i){return this._project.toFlat(i)}toFlatIds(i){return this._project.toFlatIds(i)}toMeta(){return this._project.toMeta()}toJSON(i){return this._project.toJSON(i)}toJSONClone(i){return this._project.toJSONClone(i)}toReference(i){return this._project.toReference(i)}toShallowJSON(i){return this._project.toShallowJSON(i)}toFlatJSON(i){return this._project.toFlatJSON(i)}toGenerationTarget(){return this._project.toGenerationTarget()}toFlatGenerationTarget(i){return this._project.toFlatGenerationTarget(i)}clearErrors(){return this._project.clearErrors()}validate(){return this._project.validate()}validateChildren(){return this._project.validateChildren()}getErrors(){return this._project.getErrors()}getShallowErrors(){return this._project.getShallowErrors()}getDefinitionEntity(i){return this._project.getDefinitionEntity(i)}addDefinitionEntity(i){return this._project.addDefinitionEntity(i)}addFunctionDeclaration(i){return this._project.addFunctionDeclaration(i)}addFunctionCall(i){return this._project.addFunctionCall(i)}addVariableDeclaration(i){return this._project.addVariableDeclaration(i)}addVariableInstance(i){return this._project.addVariableInstance(i)}addInstalledProject(i){return this._project.addInstalledProject(i)}addGlobalEvent(i){return this._project.addGlobalEvent(i)}addCondition(i){return this._project.addCondition(i)}addOperation(i){return this._project.addOperation(i)}addLoop(i){return this._project.addLoop(i)}addSearch(i){return this._project.addSearch(i)}removeDefinitionEntity(i){return this._project.removeDefinitionEntity(i)}removeCondition(i){return this._project.removeCondition(i)}removeOperation(i){return this._project.removeOperation(i)}removeLoop(i){return this._project.removeLoop(i)}removeSearch(i){return this._project.removeSearch(i)}removeFunctionCall(i){return this._project.removeFunctionCall(i)}removeVariableInstance(i){return this._project.removeVariableInstance(i)}removeVariableDeclaration(i){return this._project.removeVariableDeclaration(i)}removeFunctionDeclaration(i){return this._project.removeFunctionDeclaration(i)}removeInstalledProject(i){return this._project.removeInstalledProject(i)}removeGlobalEvent(i){return this._project.removeGlobalEvent(i)}removeTopLevelVariableDeclaration(i){return this._project.removeTopLevelVariableDeclaration(i)}getEntryPoints(){return this._project.getEntryPoints()}getTerminationStatements(){return this._project.getTerminationStatements()}getFunctionDeclaration(i){return this._project.getFunctionDeclaration(i)}getConditions(){return this._project.getConditions()}getOperations(){return this._project.getOperations()}getVariables(){return this._project.getVariables()}getVariableInstances(){return this._project.getVariableInstances()}getVariableDeclarations(){return this._project.getVariableDeclarations()}getLoops(){return this._project.getLoops()}getSearches(){return this._project.getSearches()}getBuiltInPersistedEntity(){return this._project.getBuiltInPersistedEntity()}requestActiveDynamicValue(i,n=!1){return this._project.requestActiveDynamicValue(i,n)}undo(){return this._project.undo()}redo(){return this._project.redo()}applyExternalChangeSet(i){return this._project.applyExternalChangeSet(i)}toFullProjectTransfer(){return this._project.toFullProjectTransfer()}}function gvi(o,p){return p instanceof zO?p:new zO(o,p)}const uy="built-in-function-implementations__",Oe="operations-implementations__",Na="conditions-implementations__",Ae={UUID:"uuid",SEARCH_NODE_IMPLEMENTATION:"search-node-implementation",BUILT_IN_FUNCTION_IMPLEMENTATIONS__ABORT_EXECUTION:uy+br.AbortExecution,BUILT_IN_FUNCTION_IMPLEMENTATIONS__CREATE_PERSISTED_ENTITY:uy+br.CreatePersistedEntity,BUILT_IN_FUNCTION_IMPLEMENTATIONS__UPDATE_PERSISTED_ENTITY:uy+br.UpdatePersistedEntity,BUILT_IN_FUNCTION_IMPLEMENTATIONS__DELETE_PERSISTED_ENTITY:uy+br.DeletePersistedEntity,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__COMPARISON_EMPTY:Oe+xt.Empty,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__COMPARISON_NOT_EMPTY:Oe+xt.NotEmpty,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__COMPARISON_PRIMITIVE_EQUAL:Oe+xt.PrimitiveEqual,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__COMPARISON_PRIMITIVE_NOT_EQUAL:Oe+xt.PrimitiveNotEqual,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__HTTP_REQUEST:Oe+zn.HttpRequest,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__VALIDATE_ENTITY:Oe+Ce.Validate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__EXECUTE_SEQUENTIAL:Oe+Ki.Sequential,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__EXECUTE_PARALLEL:Oe+Ki.Parallel,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__EXECUTE_WAIT:Oe+Ki.Wait,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_JOIN:Oe+ie.Join,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_SPLIT:Oe+ie.Split,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_DELETE_LAST_N_ITEMS:Oe+ie.DeleteLastNItems,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_DELETE_FIRST_N_ITEMS:Oe+ie.DeleteFirstNItems,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_DELETE_AT_INDEX:Oe+ie.DeleteAtIndex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_ADD_AT_INDEX:Oe+ie.AddAtIndex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_FIRST_N_ITEMS:Oe+ie.ReplaceFirstNItems,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_LAST_N_ITEMS:Oe+ie.ReplaceLastNItems,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_ALL:Oe+ie.ReplaceAll,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_AT_INDEX:Oe+ie.ReplaceAtIndex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_INDEX_ITEM:Oe+ie.GetIndexItem,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_FIRST:Oe+ie.GetFirst,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_LAST:Oe+ie.GetLast,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_APPEND:Oe+ie.Append,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_PREPEND:Oe+ie.Prepend,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REVERSE:Oe+ie.Reverse,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_LENGTH:Oe+ie.GetLength,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_FIRST_N_ITEMS:Oe+ie.GetFirstNItems,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_LAST_N_ITEMS:Oe+ie.GetLastNItems,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_SLICE:Oe+ie.Slice,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CONCAT:Oe+ie.Concat,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_INDEX_OF:Oe+ie.GetIndexOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_LAST_INDEX_OF:Oe+ie.GetLastIndexOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_UNIQUE:Oe+ie.Unique,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_FLATTEN:Oe+ie.Flatten,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_SORT:Oe+ie.Sort,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_SHUFFLE:Oe+ie.Shuffle,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CHUNK:Oe+ie.Chunk,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_PAD_START:Oe+ie.PadStart,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_PAD_END:Oe+ie.PadEnd,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPEAT:Oe+ie.Repeat,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_LENGTH:Oe+q.GetLength,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TO_LOWER_CASE:Oe+q.ToLowerCase,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TO_UPPER_CASE:Oe+q.ToUpperCase,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_JOIN:Oe+q.Join,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CONTAINS:Oe+ie.Contains,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CONTAINS_ALL:Oe+ie.ContainsAll,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CONTAINS_ANY:Oe+ie.ContainsAny,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SPLIT_AT_INDEX:Oe+q.SplitAtIndex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SPLIT_AT_ALL_SEPARATORS:Oe+q.SplitAtAllSeparators,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SPLIT_AT_FIRST_SEPARATOR:Oe+q.SplitAtFirstSeparator,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SPLIT_AT_LAST_SEPARATOR:Oe+q.SplitAtLastSeparator,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_DELETE_LAST_N_CHARS:Oe+q.DeleteLastNChars,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_DELETE_FIRST_N_CHARS:Oe+q.DeleteFirstNChars,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_DELETE_AT_INDEX:Oe+q.DeleteAtIndex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_ADD_AT_INDEX:Oe+q.AddAtIndex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_FIRST_N_CHARS:Oe+q.ReplaceFirstNChars,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_LAST_N_CHARS:Oe+q.ReplaceLastNChars,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_AT_INDEX:Oe+q.ReplaceAtIndex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_FIRST_MATCH:Oe+q.ReplaceFirstMatch,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_LAST_MATCH:Oe+q.ReplaceLastMatch,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_ALL_MATCHES:Oe+q.ReplaceAllMatches,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_INDEX_ITEM:Oe+q.GetIndexItem,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_FIRST_N_CHARS:Oe+q.GetFirstNChars,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_LAST_N_CHARS:Oe+q.GetLastNChars,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_INDEX_OF:Oe+q.GetIndexOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_APPEND:Oe+q.Append,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_PREPEND:Oe+q.Prepend,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REVERSE:Oe+q.Reverse,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TRIM:Oe+q.Trim,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TRIM_START:Oe+q.TrimStart,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TRIM_END:Oe+q.TrimEnd,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SUBSTRING:Oe+q.Substring,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SLICE:Oe+q.Slice,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_PAD_START:Oe+q.PadStart,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_PAD_END:Oe+q.PadEnd,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPEAT:Oe+q.Repeat,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_LAST_INDEX_OF:Oe+q.GetLastIndexOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_MATCH_REGEX:Oe+q.MatchRegex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_MATCH_ALL_REGEX:Oe+q.MatchAllRegex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SEARCH_REGEX:Oe+q.SearchRegex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_REGEX:Oe+q.ReplaceRegex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_NORMALIZE_UNICODE:Oe+q.NormalizeUnicode,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REMOVE_DIACRITICS:Oe+q.RemoveDiacritics,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_COUNT_OCCURRENCES:Oe+q.CountOccurrences,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_ENSURE_PREFIX:Oe+q.EnsurePrefix,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_ENSURE_SUFFIX:Oe+q.EnsureSuffix,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REMOVE_PREFIX:Oe+q.RemovePrefix,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REMOVE_SUFFIX:Oe+q.RemoveSuffix,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ADDITION:Oe+te.Addition,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SUBTRACTION:Oe+te.Subtraction,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MULTIPLICATION:Oe+te.Multiplication,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_DIVISION:Oe+te.Division,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_REMAINDER:Oe+te.Remainder,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_EXPONENTIATION:Oe+te.Exponentiation,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ABSOLUTE:Oe+te.Absolute,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SIGN:Oe+te.Sign,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ROUND:Oe+te.Round,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_NEGATE:Oe+te.Negate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_FLOOR:Oe+te.Floor,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_CEIL:Oe+te.Ceil,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_CLAMP:Oe+te.Clamp,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_TRUNC:Oe+te.Trunc,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ROUND_TO_DECIMALS:Oe+te.RoundToDecimals,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SNAP_TO_STEP:Oe+te.SnapToStep,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MAP_RANGE:Oe+te.MapRange,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_AVERAGE:Oe+te.Average,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MEDIAN:Oe+te.Median,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MIN_OF:Oe+te.MinOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MAX_OF:Oe+te.MaxOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SQUARE_ROOT:Oe+te.SquareRoot,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_CUBE_ROOT:Oe+te.CubeRoot,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_NTH_ROOT:Oe+te.NthRoot,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_EXP:Oe+te.Exp,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_LOG_NATURAL:Oe+te.LogNatural,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_LOG10:Oe+te.Log10,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SIN:Oe+te.Sin,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_COS:Oe+te.Cos,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_TAN:Oe+te.Tan,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ASIN:Oe+te.Asin,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ACOS:Oe+te.Acos,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ATAN:Oe+te.Atan,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ATAN2:Oe+te.Atan2,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_TO_RADIANS:Oe+te.ToRadians,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_TO_DEGREES:Oe+te.ToDegrees,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_PERCENT_OF:Oe+te.PercentOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_PERCENTAGE_CHANGE:Oe+te.PercentageChange,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MORE_THAN:Oe+te.MoreThan,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_LESS_THAN:Oe+te.LessThan,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_LESS_THAN_OR_EQUAL:Oe+te.LessThanOrEqual,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MORE_THAN_OR_EQUAL:Oe+te.MoreThanOrEqual,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_INTEGER:Oe+et.GenerateRandomInteger,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_FLOAT:Oe+et.GenerateRandomFloat,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_HEXADECIMAL:Oe+et.GenerateRandomHexadecimal,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_BASE62:Oe+et.GenerateRandomBase62,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_BASE64:Oe+et.GenerateRandomBase64,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_ALPHANUMERIC:Oe+et.GenerateRandomAlphanumeric,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_IDENTIFIER:Oe+et.GenerateIdentifier,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_UUIDV4:Oe+et.GenerateRandomUUIDv4,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_SHORT_IDENTIFIER:Oe+et.GenerateShortIdentifier,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_HEXADECIMAL_TOKEN:Oe+et.GenerateHexadecimalToken,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_STARTS_WITH:Oe+q.StartsWith,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_ENDS_WITH:Oe+q.EndsWith,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_CONTAINS:Oe+q.Contains,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_MATCHES_REGEX:Oe+q.MatchesRegex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_CURRENT_TIMESTAMP:Oe+U.GetCurrentTimestamp,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_FORMAT_DATE:Oe+U.FormatDate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_PARSE_DATE:Oe+U.ParseDate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_ADD_TO_DATE:Oe+U.AddToDate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SUBTRACT_FROM_DATE:Oe+U.SubtractFromDate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_DIFFERENCE_BETWEEN_DATES:Oe+U.DifferenceBetweenDates,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_DATE:Oe+U.ToDate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_UNIX:Oe+U.ToUnix,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_FROM_UNIX:Oe+U.FromUnix,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_ISO_STRING:Oe+U.ToISOString,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_YEAR:Oe+U.GetYear,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_MONTH:Oe+U.GetMonth,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_DATE:Oe+U.GetDate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_HOUR:Oe+U.GetHour,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_MINUTE:Oe+U.GetMinute,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_SECOND:Oe+U.GetSecond,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_MILLISECOND:Oe+U.GetMillisecond,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_ISO_WEEKDAY:Oe+U.GetIsoWeekday,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_WEEK_OF_YEAR:Oe+U.GetWeekOfYear,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_QUARTER:Oe+U.GetQuarter,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_DAY_OF_YEAR:Oe+U.GetDayOfYear,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_DAYS_IN_MONTH:Oe+U.GetDaysInMonth,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_CURRENT_IANA_TIMEZONE:Oe+U.GetCurrentIanaTimeZone,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_YEAR:Oe+U.SetYear,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_MONTH:Oe+U.SetMonth,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_DATE:Oe+U.SetDate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_HOUR:Oe+U.SetHour,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_MINUTE:Oe+U.SetMinute,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_SECOND:Oe+U.SetSecond,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_MILLISECOND:Oe+U.SetMillisecond,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_ISO_WEEKDAY:Oe+U.SetIsoWeekday,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_QUARTER:Oe+U.SetQuarter,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_START_OF:Oe+U.StartOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_END_OF:Oe+U.EndOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_ROUND_TO:Oe+U.RoundTo,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_BEFORE:Na+U.IsBefore,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_AFTER:Na+U.IsAfter,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_SAME:Na+U.IsSame,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_SAME_OR_BEFORE:Na+U.IsSameOrBefore,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_SAME_OR_AFTER:Na+U.IsSameOrAfter,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_BETWEEN:Na+U.IsBetween,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_VALID:Na+U.IsValid,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_LEAP_YEAR:Na+U.IsLeapYear,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_CLAMP_TO_RANGE:Oe+U.ClampToRange,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_MIN_OF:Oe+U.MinOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_MAX_OF:Oe+U.MaxOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_FROM_NOW:Oe+U.FromNow,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_NOW:Oe+U.ToNow,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_HUMANIZE_DIFF:Oe+U.HumanizeDiff,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_ADD_BUSINESS_DAYS:Oe+U.AddBusinessDays,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_NEXT_WEEKDAY:Oe+U.NextWeekday,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_PREVIOUS_WEEKDAY:Oe+U.PreviousWeekday,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_UTC:Oe+U.ToUTC,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_CONVERT_TIMEZONE:Oe+U.ConvertTimezone,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_TIMEZONE_OFFSET:Oe+U.GetTimezoneOffset,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_UTC_OFFSET:Oe+U.SetUTCOffset,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_READ_KEY:Oe+Ce.ReadKey,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_WRITE_KEY:Oe+Ce.WriteKey,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_DELETE_KEY:Oe+Ce.DeleteKey,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_READ_NESTED_KEY:Oe+Ce.ReadNestedKey,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_WRITE_NESTED_KEY:Oe+Ce.WriteNestedKey,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_DELETE_NESTED_KEY:Oe+Ce.DeleteNestedKey,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_WRITE_SAFE_NESTED_KEY_RECURSIVELY:Oe+Ce.WriteSafeNestedKeyRecursively,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_HAS_KEY:Na+Ce.HasKey,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_HAS_NESTED_KEY:Na+Ce.HasNestedKey,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_KEY_VALUE_EQUALS:Na+Ce.KeyValueEquals,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_NESTED_KEY_VALUE_EQUALS:Na+Ce.NestedKeyValueEquals,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_IS_INSTANCE_OF_TYPE:Na+Ce.IsInstanceOfType,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_MERGE:Oe+Ce.Merge,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_KEYS:Oe+Ce.Keys,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_VALUES:Oe+Ce.Values,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_ENTRIES:Oe+Ce.Entries,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_GET_TYPE_OF:Oe+ze.GetTypeOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_HASH:Oe+si.Hash,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_HMAC:Oe+si.Hmac,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_GENERATE_RANDOM_BYTES:Oe+et.GenerateRandomBytes,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_CONSTANT_TIME_EQUAL:Oe+si.ConstantTimeEqual,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_DERIVE_KEY_PBKDF2:Oe+si.DeriveKeyPBKDF2,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__PASSWORD_HASH_PBKDF2:Oe+Qr.HashPasswordPBKDF2,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__PASSWORD_VERIFY_PBKDF2:Oe+Qr.VerifyPasswordPBKDF2,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__JWT_BUILD_HMAC:Oe+er.BuildJwtHmac,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__JWT_VERIFY_HMAC:Oe+er.VerifyJwtHmac,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__JWT_DECODE:Oe+er.DecodeJwt,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_FROM_BYTES_TO_STRING:Oe+ze.FromBytesToString,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_TO_BYTES:Oe+ze.ToBytes,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_TO_NUMBER:Oe+ze.ToNumber,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_TO_STRING:Oe+ze.ToString,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_ENCODE_BASE64:Oe+ze.EncodeBase64,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_DECODE_BASE64:Oe+ze.DecodeBase64,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_ENCODE_BASE64URL:Oe+ze.EncodeBase64Url,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_DECODE_BASE64URL:Oe+ze.DecodeBase64Url,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_ENCODE_HEX:Oe+ze.EncodeHex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_DECODE_HEX:Oe+ze.DecodeHex,BUILT_IN_OPERATIONS_IMPLEMENTATIONS__JSON_PARSE:Oe+Xr.Parse,BUILT_IN_OPERATIONS_IMPLEMENTATIONS__JSON_STRINGIFY:Oe+Xr.Stringify};class ZOe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_IN_FUNCTION_IMPLEMENTATIONS__ABORT_EXECUTION,version:"1.0.0",description:'Implementation for the built-in function "Abort Execution". It terminates the execution of the current entity being run.',initPriority:Ee.High,permissions:[be.All],contexts:[X.Editor]});I(this,"module",{main:async(i,n)=>({value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,entity:i,error:null,result:null})})}}class HOe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_IN_FUNCTION_IMPLEMENTATIONS__DELETE_PERSISTED_ENTITY,version:"1.0.0",description:'Implementation for the built-in function "Delete Persisted Entity". It deletes the current entity as an entry in the persisted storage.',initPriority:Ee.High,permissions:[be.All],contexts:[X.Editor]});I(this,"module",{main:async(i,n)=>({value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,entity:i,error:null,result:null})})}}class WOe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_IN_FUNCTION_IMPLEMENTATIONS__CREATE_PERSISTED_ENTITY,version:"1.0.0",description:'Implementation for the built-in function "Create Persisted Entity". It saves the current entity state to the persisted storage.',initPriority:Ee.High,permissions:[be.All],contexts:[X.Editor]});I(this,"module",{main:async(i,n)=>({value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,entity:i,error:null,result:null})})}}class zOe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_IN_FUNCTION_IMPLEMENTATIONS__UPDATE_PERSISTED_ENTITY,version:"1.0.0",description:'Implementation for the built-in function "Update Persisted Entity". It saves the current entity state to the persisted storage.',initPriority:Ee.High,permissions:[be.All],contexts:[X.Editor]});I(this,"module",{main:async(i,n)=>({value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,entity:i,error:null,result:null})})}}class JOe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.SEARCH_NODE_IMPLEMENTATION,version:"1.0.0",description:"Implementation for search nodes when they get executed and query data.",initPriority:Ee.High,permissions:[be.All],contexts:[X.Editor]});I(this,"module",{main:async(i,n)=>({error:"Search module not implemented",data:null})})}}class YOe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.UUID,version:"1.0.0",description:"UUID generation module, for all contexts and runtimes",initPriority:Ee.High,permissions:[be.All],contexts:[]});I(this,"module",bC)}}const XOe=o=>o.map(p=>{var i,n;return((i=p.value)==null?void 0:i.valueAsType)??((n=p.value)==null?void 0:n.value)});class QOe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__COMPARISON_EMPTY,version:"1.0.0",description:"Comparison: Empty (!value)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const s=n.get(xt.Empty);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=XOe(n),c=!s;return{value:G.Success,error:null,result:c}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class eCe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__COMPARISON_NOT_EMPTY,version:"1.0.0",description:"Comparison: NotEmpty (!!value)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const s=n.get(xt.NotEmpty);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=XOe(n),c=!!s;return{value:G.Success,error:null,result:c}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}const $A=class $A extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__COMPARISON_PRIMITIVE_EQUAL,version:"1.0.0",description:"Comparison: PrimitiveEqual (typed equality / deep JSON equality)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const s=n.get(xt.PrimitiveEqual);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{var s,c,e,y,m,v;try{const E=(c=(s=n[0])==null?void 0:s.value)==null?void 0:c.name,b=(y=(e=n[0])==null?void 0:e.value)==null?void 0:y.value,w=(v=(m=n[1])==null?void 0:m.value)==null?void 0:v.value;let V=!1;return E&&$A.primitiveSet.has(E)?V=b===w:E===oe.Untyped||E===oe.KeyValue?V=JSON.stringify(b)===JSON.stringify(w):V=!1,{value:G.Success,error:null,result:V}}catch(E){return{value:G.UnhandledError,error:E,result:null}}}})}};I($A,"primitiveSet",new Set([oe.String,oe.Number,oe.Boolean,oe.Null,oe.Enum,oe.Date,oe.UUID]));let cA=$A;const LA=class LA extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__COMPARISON_PRIMITIVE_NOT_EQUAL,version:"1.0.0",description:"Comparison: PrimitiveNotEqual (typed inequality / deep JSON inequality)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const s=n.get(xt.PrimitiveNotEqual);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{var s,c,e,y,m,v;try{const E=(c=(s=n[0])==null?void 0:s.value)==null?void 0:c.name,b=(y=(e=n[0])==null?void 0:e.value)==null?void 0:y.value,w=(v=(m=n[1])==null?void 0:m.value)==null?void 0:v.value;let V=!1;return E&&LA.primitiveSet.has(E)?V=b!==w:E===oe.Untyped||E===oe.KeyValue?V=JSON.stringify(b)!==JSON.stringify(w):V=!1,{value:G.Success,error:null,result:V}}catch(E){return{value:G.UnhandledError,error:E,result:null}}}})}};I(LA,"primitiveSet",new Set([oe.String,oe.Number,oe.Boolean,oe.Null,oe.Enum,oe.Date,oe.UUID]));let fA=LA;var tCe={exports:{}};(function(o,p){(function(i,n){o.exports=n()})(Nr,function(){var i="minute",n=/[+-]\d\d(?::?\d\d)?/g,s=/([+-]|\d\d)/g;return function(c,e,y){var m=e.prototype;y.utc=function(L){var k={date:L,utc:!0,args:arguments};return new e(k)},m.utc=function(L){var k=y(this.toDate(),{locale:this.$L,utc:!0});return L?k.add(this.utcOffset(),i):k},m.local=function(){return y(this.toDate(),{locale:this.$L,utc:!1})};var v=m.parse;m.parse=function(L){L.utc&&(this.$u=!0),this.$utils().u(L.$offset)||(this.$offset=L.$offset),v.call(this,L)};var E=m.init;m.init=function(){if(this.$u){var L=this.$d;this.$y=L.getUTCFullYear(),this.$M=L.getUTCMonth(),this.$D=L.getUTCDate(),this.$W=L.getUTCDay(),this.$H=L.getUTCHours(),this.$m=L.getUTCMinutes(),this.$s=L.getUTCSeconds(),this.$ms=L.getUTCMilliseconds()}else E.call(this)};var b=m.utcOffset;m.utcOffset=function(L,k){var K=this.$utils().u;if(K(L))return this.$u?0:K(this.$offset)?b.call(this):this.$offset;if(typeof L=="string"&&(L=function(ee){ee===void 0&&(ee="");var de=ee.match(n);if(!de)return null;var le=(""+de[0]).match(s)||["-",0,0],fe=le[0],ve=60*+le[1]+ +le[2];return ve===0?0:fe==="+"?ve:-ve}(L),L===null))return this;var S=Math.abs(L)<=16?60*L:L;if(S===0)return this.utc(k);var Y=this.clone();if(k)return Y.$offset=S,Y.$u=!1,Y;var re=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();return(Y=this.local().add(S+re,i)).$offset=S,Y.$x.$localOffset=re,Y};var w=m.format;m.format=function(L){var k=L||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return w.call(this,k)},m.valueOf=function(){var L=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*L},m.isUTC=function(){return!!this.$u},m.toISOString=function(){return this.toDate().toISOString()},m.toString=function(){return this.toDate().toUTCString()};var V=m.toDate;m.toDate=function(L){return L==="s"&&this.$offset?y(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():V.call(this)};var $=m.diff;m.diff=function(L,k,K){if(L&&this.$u===L.$u)return $.call(this,L,k,K);var S=this.local(),Y=y(L).local();return $.call(S,Y,k,K)}}})})(tCe);var Ivi=tCe.exports;const Rvi=Wa(Ivi);var iCe={exports:{}};(function(o,p){(function(i,n){o.exports=n()})(Nr,function(){var i={year:0,month:1,day:2,hour:3,minute:4,second:5},n={};return function(s,c,e){var y,m=function(w,V,$){$===void 0&&($={});var L=new Date(w),k=function(K,S){S===void 0&&(S={});var Y=S.timeZoneName||"short",re=K+"|"+Y,ee=n[re];return ee||(ee=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:K,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:Y}),n[re]=ee),ee}(V,$);return k.formatToParts(L)},v=function(w,V){for(var $=m(w,V),L=[],k=0;k<$.length;k+=1){var K=$[k],S=K.type,Y=K.value,re=i[S];re>=0&&(L[re]=parseInt(Y,10))}var ee=L[3],de=ee===24?0:ee,le=L[0]+"-"+L[1]+"-"+L[2]+" "+de+":"+L[4]+":"+L[5]+":000",fe=+w;return(e.utc(le).valueOf()-(fe-=fe%1e3))/6e4},E=c.prototype;E.tz=function(w,V){w===void 0&&(w=y);var $,L=this.utcOffset(),k=this.toDate(),K=k.toLocaleString("en-US",{timeZone:w}),S=Math.round((k-new Date(K))/1e3/60),Y=15*-Math.round(k.getTimezoneOffset()/15)-S;if(!Number(Y))$=this.utcOffset(0,V);else if($=e(K,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(Y,!0),V){var re=$.utcOffset();$=$.add(L-re,"minute")}return $.$x.$timezone=w,$},E.offsetName=function(w){var V=this.$x.$timezone||e.tz.guess(),$=m(this.valueOf(),V,{timeZoneName:w}).find(function(L){return L.type.toLowerCase()==="timezonename"});return $&&$.value};var b=E.startOf;E.startOf=function(w,V){if(!this.$x||!this.$x.$timezone)return b.call(this,w,V);var $=e(this.format("YYYY-MM-DD HH:mm:ss:SSS"),{locale:this.$L});return b.call($,w,V).tz(this.$x.$timezone,!0)},e.tz=function(w,V,$){var L=$&&V,k=$||V||y,K=v(+e(),k);if(typeof w!="string")return e(w).tz(k);var S=function(de,le,fe){var ve=de-60*le*1e3,ue=v(ve,fe);if(le===ue)return[ve,le];var ye=v(ve-=60*(ue-le)*1e3,fe);return ue===ye?[ve,ue]:[de-60*Math.min(ue,ye)*1e3,Math.max(ue,ye)]}(e.utc(w,L).valueOf(),K,k),Y=S[0],re=S[1],ee=e(Y).utcOffset(re);return ee.$x.$timezone=k,ee},e.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},e.tz.setDefault=function(w){y=w}}})})(iCe);var Dvi=iCe.exports;const wvi=Wa(Dvi);var rCe={exports:{}};(function(o,p){(function(i,n){o.exports=n()})(Nr,function(){return function(i,n,s){n.prototype.isBetween=function(c,e,y,m){var v=s(c),E=s(e),b=(m=m||"()")[0]==="(",w=m[1]===")";return(b?this.isAfter(v,y):!this.isBefore(v,y))&&(w?this.isBefore(E,y):!this.isAfter(E,y))||(b?this.isBefore(v,y):!this.isAfter(v,y))&&(w?this.isAfter(E,y):!this.isBefore(E,y))}}})})(rCe);var Ovi=rCe.exports;const Cvi=Wa(Ovi);var nCe={exports:{}};(function(o,p){(function(i,n){o.exports=n()})(Nr,function(){return function(i,n){n.prototype.isSameOrAfter=function(s,c){return this.isSame(s,c)||this.isAfter(s,c)}}})})(nCe);var _vi=nCe.exports;const Vvi=Wa(_vi);var aCe={exports:{}};(function(o,p){(function(i,n){o.exports=n()})(Nr,function(){return function(i,n){n.prototype.isSameOrBefore=function(s,c){return this.isSame(s,c)||this.isBefore(s,c)}}})})(aCe);var Pvi=aCe.exports;const Nvi=Wa(Pvi);var sCe={exports:{}};(function(o,p){(function(i,n){o.exports=n()})(Nr,function(){var i="week",n="year";return function(s,c,e){var y=c.prototype;y.week=function(m){if(m===void 0&&(m=null),m!==null)return this.add(7*(m-this.week()),"day");var v=this.$locale().yearStart||1;if(this.month()===11&&this.date()>25){var E=e(this).startOf(n).add(1,n).date(v),b=e(this).endOf(i);if(E.isBefore(b))return 1}var w=e(this).startOf(n).date(v).startOf(i).subtract(1,"millisecond"),V=this.diff(w,i,!0);return V<0?e(this).startOf("week").week():Math.ceil(V)},y.weeks=function(m){return m===void 0&&(m=null),this.week(m)}}})})(sCe);var xvi=sCe.exports;const $vi=Wa(xvi);var lCe={exports:{}};(function(o,p){(function(i,n){o.exports=n()})(Nr,function(){var i="day";return function(n,s,c){var e=function(v){return v.add(4-v.isoWeekday(),i)},y=s.prototype;y.isoWeekYear=function(){return e(this).year()},y.isoWeek=function(v){if(!this.$utils().u(v))return this.add(7*(v-this.isoWeek()),i);var E,b,w,V,$=e(this),L=(E=this.isoWeekYear(),b=this.$u,w=(b?c.utc:c)().year(E).startOf("year"),V=4-w.isoWeekday(),w.isoWeekday()>4&&(V+=7),w.add(V,i));return $.diff(L,"week")+1},y.isoWeekday=function(v){return this.$utils().u(v)?this.day()||7:this.day(this.day()%7?v:v-7)};var m=y.startOf;y.startOf=function(v,E){var b=this.$utils(),w=!!b.u(E)||E;return b.p(v)==="isoweek"?w?this.date(this.date()-(this.isoWeekday()-1)).startOf("day"):this.date(this.date()-1-(this.isoWeekday()-1)+7).endOf("day"):m.bind(this)(v,E)}}})})(lCe);var Lvi=lCe.exports;const Mvi=Wa(Lvi);var oCe={exports:{}};(function(o,p){(function(i,n){o.exports=n()})(Nr,function(){var i="month",n="quarter";return function(s,c){var e=c.prototype;e.quarter=function(v){return this.$utils().u(v)?Math.ceil((this.month()+1)/3):this.month(this.month()%3+3*(v-1))};var y=e.add;e.add=function(v,E){return v=Number(v),this.$utils().p(E)===n?this.add(3*v,i):y.bind(this)(v,E)};var m=e.startOf;e.startOf=function(v,E){var b=this.$utils(),w=!!b.u(E)||E;if(b.p(v)===n){var V=this.quarter()-1;return w?this.month(3*V).startOf(i).startOf("day"):this.month(3*V+2).endOf(i).endOf("day")}return m.bind(this)(v,E)}}})})(oCe);var Bvi=oCe.exports;const Gvi=Wa(Bvi);var dCe={exports:{}};(function(o,p){(function(i,n){o.exports=n()})(Nr,function(){return function(i,n,s){n.prototype.dayOfYear=function(c){var e=Math.round((s(this).startOf("day")-s(this).startOf("year"))/864e5)+1;return c==null?e:this.add(c-e,"day")}}})})(dCe);var kvi=dCe.exports;const jvi=Wa(kvi);var uCe={exports:{}};(function(o,p){(function(i,n){o.exports=n()})(Nr,function(){return function(i,n,s){i=i||{};var c=n.prototype,e={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function y(v,E,b,w){return c.fromToBase(v,E,b,w)}s.en.relativeTime=e,c.fromToBase=function(v,E,b,w,V){for(var $,L,k,K=b.$locale().relativeTime||e,S=i.thresholds||[{l:"s",r:44,d:"second"},{l:"m",r:89},{l:"mm",r:44,d:"minute"},{l:"h",r:89},{l:"hh",r:21,d:"hour"},{l:"d",r:35},{l:"dd",r:25,d:"day"},{l:"M",r:45},{l:"MM",r:10,d:"month"},{l:"y",r:17},{l:"yy",d:"year"}],Y=S.length,re=0;re<Y;re+=1){var ee=S[re];ee.d&&($=w?s(v).diff(b,ee.d,!0):b.diff(v,ee.d,!0));var de=(i.rounding||Math.round)(Math.abs($));if(k=$>0,de<=ee.r||!ee.r){de<=1&&re>0&&(ee=S[re-1]);var le=K[ee.l];V&&(de=V(""+de)),L=typeof le=="string"?le.replace("%d",de):le(de,E,ee.l,k);break}}if(E)return L;var fe=k?K.future:K.past;return typeof fe=="function"?fe(L):fe.replace("%s",L)},c.to=function(v,E){return y(v,E,this,!0)},c.from=function(v,E){return y(v,E,this)};var m=function(v){return v.$u?s.utc():s()};c.toNow=function(v){return this.to(m(this),v)},c.fromNow=function(v){return this.from(m(this),v)}}})})(uCe);var Uvi=uCe.exports;const Kvi=Wa(Uvi);var pCe={exports:{}};(function(o,p){(function(i,n){o.exports=n()})(Nr,function(){var i,n,s=1e3,c=6e4,e=36e5,y=864e5,m=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,v=31536e6,E=2628e6,b=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,w={years:v,months:E,days:y,hours:e,minutes:c,seconds:s,milliseconds:1,weeks:6048e5},V=function(de){return de instanceof re},$=function(de,le,fe){return new re(de,fe,le.$l)},L=function(de){return n.p(de)+"s"},k=function(de){return de<0},K=function(de){return k(de)?Math.ceil(de):Math.floor(de)},S=function(de){return Math.abs(de)},Y=function(de,le){return de?k(de)?{negative:!0,format:""+S(de)+le}:{negative:!1,format:""+de+le}:{negative:!1,format:""}},re=function(){function de(fe,ve,ue){var ye=this;if(this.$d={},this.$l=ue,fe===void 0&&(this.$ms=0,this.parseFromMilliseconds()),ve)return $(fe*w[L(ve)],this);if(typeof fe=="number")return this.$ms=fe,this.parseFromMilliseconds(),this;if(typeof fe=="object")return Object.keys(fe).forEach(function($e){ye.$d[L($e)]=fe[$e]}),this.calMilliseconds(),this;if(typeof fe=="string"){var Ve=fe.match(b);if(Ve){var _e=Ve.slice(2).map(function($e){return $e!=null?Number($e):0});return this.$d.years=_e[0],this.$d.months=_e[1],this.$d.weeks=_e[2],this.$d.days=_e[3],this.$d.hours=_e[4],this.$d.minutes=_e[5],this.$d.seconds=_e[6],this.calMilliseconds(),this}}return this}var le=de.prototype;return le.calMilliseconds=function(){var fe=this;this.$ms=Object.keys(this.$d).reduce(function(ve,ue){return ve+(fe.$d[ue]||0)*w[ue]},0)},le.parseFromMilliseconds=function(){var fe=this.$ms;this.$d.years=K(fe/v),fe%=v,this.$d.months=K(fe/E),fe%=E,this.$d.days=K(fe/y),fe%=y,this.$d.hours=K(fe/e),fe%=e,this.$d.minutes=K(fe/c),fe%=c,this.$d.seconds=K(fe/s),fe%=s,this.$d.milliseconds=fe},le.toISOString=function(){var fe=Y(this.$d.years,"Y"),ve=Y(this.$d.months,"M"),ue=+this.$d.days||0;this.$d.weeks&&(ue+=7*this.$d.weeks);var ye=Y(ue,"D"),Ve=Y(this.$d.hours,"H"),_e=Y(this.$d.minutes,"M"),$e=this.$d.seconds||0;this.$d.milliseconds&&($e+=this.$d.milliseconds/1e3,$e=Math.round(1e3*$e)/1e3);var Ne=Y($e,"S"),Be=fe.negative||ve.negative||ye.negative||Ve.negative||_e.negative||Ne.negative,Se=Ve.format||_e.format||Ne.format?"T":"",je=(Be?"-":"")+"P"+fe.format+ve.format+ye.format+Se+Ve.format+_e.format+Ne.format;return je==="P"||je==="-P"?"P0D":je},le.toJSON=function(){return this.toISOString()},le.format=function(fe){var ve=fe||"YYYY-MM-DDTHH:mm:ss",ue={Y:this.$d.years,YY:n.s(this.$d.years,2,"0"),YYYY:n.s(this.$d.years,4,"0"),M:this.$d.months,MM:n.s(this.$d.months,2,"0"),D:this.$d.days,DD:n.s(this.$d.days,2,"0"),H:this.$d.hours,HH:n.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:n.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:n.s(this.$d.seconds,2,"0"),SSS:n.s(this.$d.milliseconds,3,"0")};return ve.replace(m,function(ye,Ve){return Ve||String(ue[ye])})},le.as=function(fe){return this.$ms/w[L(fe)]},le.get=function(fe){var ve=this.$ms,ue=L(fe);return ue==="milliseconds"?ve%=1e3:ve=ue==="weeks"?K(ve/w[ue]):this.$d[ue],ve||0},le.add=function(fe,ve,ue){var ye;return ye=ve?fe*w[L(ve)]:V(fe)?fe.$ms:$(fe,this).$ms,$(this.$ms+ye*(ue?-1:1),this)},le.subtract=function(fe,ve){return this.add(fe,ve,!0)},le.locale=function(fe){var ve=this.clone();return ve.$l=fe,ve},le.clone=function(){return $(this.$ms,this)},le.humanize=function(fe){return i().add(this.$ms,"ms").locale(this.$l).fromNow(!fe)},le.valueOf=function(){return this.asMilliseconds()},le.milliseconds=function(){return this.get("milliseconds")},le.asMilliseconds=function(){return this.as("milliseconds")},le.seconds=function(){return this.get("seconds")},le.asSeconds=function(){return this.as("seconds")},le.minutes=function(){return this.get("minutes")},le.asMinutes=function(){return this.as("minutes")},le.hours=function(){return this.get("hours")},le.asHours=function(){return this.as("hours")},le.days=function(){return this.get("days")},le.asDays=function(){return this.as("days")},le.weeks=function(){return this.get("weeks")},le.asWeeks=function(){return this.as("weeks")},le.months=function(){return this.get("months")},le.asMonths=function(){return this.as("months")},le.years=function(){return this.get("years")},le.asYears=function(){return this.as("years")},de}(),ee=function(de,le,fe){return de.add(le.years()*fe,"y").add(le.months()*fe,"M").add(le.days()*fe,"d").add(le.hours()*fe,"h").add(le.minutes()*fe,"m").add(le.seconds()*fe,"s").add(le.milliseconds()*fe,"ms")};return function(de,le,fe){i=fe,n=fe().$utils(),fe.duration=function(ye,Ve){var _e=fe.locale();return $(ye,{$l:_e},Ve)},fe.isDuration=V;var ve=le.prototype.add,ue=le.prototype.subtract;le.prototype.add=function(ye,Ve){return V(ye)?ee(this,ye,1):ve.bind(this)(ye,Ve)},le.prototype.subtract=function(ye,Ve){return V(ye)?ee(this,ye,-1):ue.bind(this)(ye,Ve)}}})})(pCe);var Fvi=pCe.exports;const Svi=Wa(Fvi);var cCe={exports:{}};(function(o,p){(function(i,n){o.exports=n()})(Nr,function(){return function(i,n){n.prototype.isLeapYear=function(){return this.$y%4==0&&this.$y%100!=0||this.$y%400==0}}})})(cCe);var qvi=cCe.exports;const Zvi=Wa(qvi);M.extend(Rvi);M.extend(wvi);M.extend(Cvi);M.extend(Vvi);M.extend(Nvi);M.extend($vi);M.extend(Mvi);M.extend(Gvi);M.extend(jvi);M.extend(Kvi);M.extend(Svi);M.extend(Zvi);const At=o=>M(o),ir=o=>o.toISOString();function fCe(){return ir(M())}function yCe(o,p){return At(o).format(p)}function hCe(o){return ir(M(o))}function mCe(o){if(o==null)throw new TypeError("ToDate expects a non-null value.");if(typeof o=="string"){const p=M(o);if(!p.isValid())throw new TypeError("Invalid date string.");return p.toISOString()}if(typeof o=="number"&&Number.isFinite(o)){const p=Math.abs(o)<1e12?M.unix(o):M(o);if(!p.isValid())throw new TypeError("Invalid numeric timestamp.");return p.toISOString()}if(o instanceof Date){const p=M(o);if(!p.isValid())throw new TypeError("Invalid Date object.");return p.toISOString()}throw new TypeError("Unsupported value type for ToDate. Provide a string, number, or Date.")}function TCe(o,p,i){return ir(At(o).add(p,i))}function vCe(o,p,i){return ir(At(o).subtract(p,i))}function ECe(o,p,i,n=!1){return At(o).diff(At(p),i,n)}function bCe(o){return At(o).unix()}function ACe(o){return ir(M.unix(o))}function gCe(o){return ir(At(o))}function ICe(o){return At(o).year()}function RCe(o){return At(o).month()}function DCe(o){return At(o).date()}function wCe(o){return At(o).hour()}function OCe(o){return At(o).minute()}function CCe(o){return At(o).second()}function _Ce(o){return At(o).millisecond()}function VCe(o){return At(o).isoWeekday()}function PCe(o){return At(o).week()}function NCe(o){return At(o).quarter()}function xCe(o){return At(o).dayOfYear()}function $Ce(o){return At(o).daysInMonth()}function LCe(o,p){return ir(At(o).year(p))}function MCe(o,p){return ir(At(o).month(p))}function BCe(o,p){return ir(At(o).date(p))}function GCe(o,p){return ir(At(o).hour(p))}function kCe(o,p){return ir(At(o).minute(p))}function jCe(o,p){return ir(At(o).second(p))}function UCe(o,p){return ir(At(o).millisecond(p))}function KCe(o,p){return ir(At(o).isoWeekday(p))}function FCe(o,p){return ir(At(o).quarter(p))}function SCe(o,p){return ir(At(o).startOf(p))}function qCe(o,p){return ir(At(o).endOf(p))}function ZCe(o,p){const i=At(o),n=i.startOf(p),s=i.endOf(p),c=n.valueOf()+(s.valueOf()-n.valueOf())/2;return ir(i.valueOf()<c?n:s)}function HCe(o,p,i){return At(o).isBefore(At(p),i)}function WCe(o,p,i){return At(o).isAfter(At(p),i)}function zCe(o,p,i){return At(o).isSame(At(p),i)}function JCe(o,p,i){return At(o).isSameOrBefore(At(p),i)}function YCe(o,p,i){return At(o).isSameOrAfter(At(p),i)}function XCe(o,p,i,n,s="()"){return At(o).isBetween(At(p),At(i),n,s)}function QCe(o){return M(o).isValid()}function e_e(o){return At(o).isLeapYear()}function t_e(o,p,i){const n=At(o);return n.isBefore(p)?ir(At(p)):n.isAfter(i)?ir(At(i)):ir(n)}function i_e(o){if(o.length===0)throw new Error("minOf requires at least one date");let p=At(o[0]);for(let i=1;i<o.length;i++){const n=At(o[i]);n.isBefore(p)&&(p=n)}return ir(p)}function r_e(o){if(o.length===0)throw new Error("maxOf requires at least one date");let p=At(o[0]);for(let i=1;i<o.length;i++){const n=At(o[i]);n.isAfter(p)&&(p=n)}return ir(p)}function n_e(o,p=!1){return At(o).fromNow(p)}function a_e(o,p=!1){return At(o).toNow(p)}function s_e(o,p,i=!0){const n=At(o).diff(At(p),"millisecond",!0),s=Math.abs(n),e=M.duration(s,"milliseconds").humanize();return i?n>=0?`in ${e}`:`${e} ago`:e}function l_e(o,p,i=["6","7"],n=[]){const s=v=>n.some(E=>At(E).isSame(v,"day")),c=v=>((v.day()+6)%7+1).toString();let e=At(o);const y=p>=0?1:-1;let m=Math.abs(p);for(;m>0;){e=e.add(y,"day");const v=c(e);!i.includes(v)&&!s(e)&&m--}return ir(e)}function o_e(o,p){let i=At(o);const n=p;for(let s=0;s<7;s++)if(i=i.add(1,"day"),i.isoWeekday()===n)return ir(i);return ir(i)}function d_e(o,p){let i=At(o);const n=p;for(let s=0;s<7;s++)if(i=i.subtract(1,"day"),i.isoWeekday()===n)return ir(i);return ir(i)}const u_e="Local";function YP(){try{const o=Intl.DateTimeFormat().resolvedOptions().timeZone;if(o&&typeof o=="string")return o}catch{}try{if(typeof process<"u"&&process.env&&process.env.TZ)return process.env.TZ}catch{}return null}function XP(){const o=YP();if(o)return o;throw new Error("Unable to detect current IANA timezone from host environment.")}function p_e(o,p,i=!1){let n=p;if(n===u_e){const e=YP();if(!e)throw new Error("Unable to detect current timezone from host environment.");n=e}const s=n?M.tz(o,n):At(o),c=i?s.utc(!0):s.utc();return ir(c)}function c_e(o,p,i=!1){const n=At(o);return ir(i?n.tz(p,!0):n.tz(p))}function f_e(o,p){const i=o===u_e?XP():o;return At(p).tz(i).utcOffset()}function y_e(o,p,i=!1){return ir(At(o).utcOffset(p,i))}class h_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_CURRENT_TIMESTAMP,version:"1.0.0",description:"Date get current timestamp operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.GetCurrentTimestamp);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=fCe();return{value:G.Success,error:null,result:s}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class m_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_FORMAT_DATE,version:"1.0.0",description:"Date format operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.FormatDate);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1],y=yCe(c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class T_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_PARSE_DATE,version:"1.0.0",description:"Date parse operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.ParseDate);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)})[0],e=hCe(c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class v_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_ADD_TO_DATE,version:"1.0.0",description:"Date add-to-date operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.AddToDate);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1],y=s[2],m=TCe(c,e,y);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class E_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SUBTRACT_FROM_DATE,version:"1.0.0",description:"Date subtract-from-date operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.SubtractFromDate);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1],y=s[2],m=vCe(c,e,y);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class b_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_DIFFERENCE_BETWEEN_DATES,version:"1.0.0",description:"Date difference-between-dates operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.DifferenceBetweenDates);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(E=>{var b,w;return((b=E.value)==null?void 0:b.valueAsType)||((w=E.value)==null?void 0:w.value)}),c=s[0],e=s[1],y=s[2],m=s[3]??!1,v=ECe(c,e,y,m);return{value:G.Success,error:null,result:v}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class Hvi extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_DATE,version:"1.0.0",description:"Date to-date operation implementation module (coerce to ISO 8601 string)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.ToDate);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)}),c=mCe(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class A_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_UNIX,version:"1.0.0",description:"Date to-unix operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.ToUnix);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)})[0],e=bCe(c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class g_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_FROM_UNIX,version:"1.0.0",description:"Date from-unix operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.FromUnix);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)})[0],e=ACe(c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class I_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_ISO_STRING,version:"1.0.0",description:"Date to-iso-string operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.ToISOString);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)})[0],e=gCe(c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class R_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_YEAR,version:"1.0.0",description:"Date get-year operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.GetYear);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)||((m=e.value)==null?void 0:m.value)}),c=ICe(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class D_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_MONTH,version:"1.0.0",description:"Date get-month (0-based) operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.GetMonth);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)||((m=e.value)==null?void 0:m.value)}),c=RCe(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class w_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_DATE,version:"1.0.0",description:"Date get-date (day of month) operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.GetDate);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)||((m=e.value)==null?void 0:m.value)}),c=DCe(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class O_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_HOUR,version:"1.0.0",description:"Date get-hour operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.GetHour);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)||((m=e.value)==null?void 0:m.value)}),c=wCe(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class C_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_MINUTE,version:"1.0.0",description:"Date get-minute operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.GetMinute);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)||((m=e.value)==null?void 0:m.value)}),c=OCe(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class __e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_SECOND,version:"1.0.0",description:"Date get-second operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.GetSecond);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)||((m=e.value)==null?void 0:m.value)}),c=CCe(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class V_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_MILLISECOND,version:"1.0.0",description:"Date get-millisecond operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.GetMillisecond);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)||((m=e.value)==null?void 0:m.value)}),c=_Ce(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class P_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_ISO_WEEKDAY,version:"1.0.0",description:"Date get-iso-weekday operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.GetIsoWeekday);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)||((m=e.value)==null?void 0:m.value)}),c=VCe(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class N_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_WEEK_OF_YEAR,version:"1.0.0",description:"Date get-week-of-year operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.GetWeekOfYear);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)||((m=e.value)==null?void 0:m.value)}),c=PCe(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class x_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_QUARTER,version:"1.0.0",description:"Date get-quarter operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.GetQuarter);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)||((m=e.value)==null?void 0:m.value)}),c=NCe(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class $_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_DAY_OF_YEAR,version:"1.0.0",description:"Date get-day-of-year operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.GetDayOfYear);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)||((m=e.value)==null?void 0:m.value)}),c=xCe(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class L_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_DAYS_IN_MONTH,version:"1.0.0",description:"Date get-days-in-month operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.GetDaysInMonth);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)||((m=e.value)==null?void 0:m.value)}),c=$Ce(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class M_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_CURRENT_IANA_TIMEZONE,version:"1.0.0",description:"Date get-current-iana-timezone operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.GetCurrentIanaTimeZone);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=XP();return{value:G.Success,error:null,result:s}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class B_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_YEAR,version:"1.0.0",description:"Date set-year operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.SetYear);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1],y=LCe(c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class G_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_MONTH,version:"1.0.0",description:"Date set-month operation implementation module (0-based month)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.SetMonth);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1],y=MCe(c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class k_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_DATE,version:"1.0.0",description:"Date set-date (day of month) operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.SetDate);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1],y=BCe(c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class j_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_HOUR,version:"1.0.0",description:"Date set-hour operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.SetHour);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1],y=GCe(c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class U_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_MINUTE,version:"1.0.0",description:"Date set-minute operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.SetMinute);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1],y=kCe(c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class K_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_SECOND,version:"1.0.0",description:"Date set-second operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.SetSecond);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1],y=jCe(c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class F_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_MILLISECOND,version:"1.0.0",description:"Date set-millisecond operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.SetMillisecond);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1],y=UCe(c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class S_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_ISO_WEEKDAY,version:"1.0.0",description:"Date set-iso-weekday operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.SetIsoWeekday);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1],y=KCe(c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class q_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_QUARTER,version:"1.0.0",description:"Date set-quarter operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.SetQuarter);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1],y=FCe(c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class Z_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_START_OF,version:"1.0.0",description:"Date start-of operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.StartOf);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1],y=SCe(c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class H_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_END_OF,version:"1.0.0",description:"Date end-of operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.EndOf);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1],y=qCe(c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class W_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_ROUND_TO,version:"1.0.0",description:"Date round-to operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.RoundTo);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1],y=ZCe(c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class z_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_BEFORE,version:"1.0.0",description:"Date is-before operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.IsBefore);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1],y=s[2],m=HCe(c,e,y);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class J_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_AFTER,version:"1.0.0",description:"Date is-after operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.IsAfter);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1],y=s[2],m=WCe(c,e,y);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class Y_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_SAME,version:"1.0.0",description:"Date is-same operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.IsSame);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1],y=s[2],m=zCe(c,e,y);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class X_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_SAME_OR_BEFORE,version:"1.0.0",description:"Date is-same-or-before operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.IsSameOrBefore);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1],y=s[2],m=JCe(c,e,y);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class Q_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_SAME_OR_AFTER,version:"1.0.0",description:"Date is-same-or-after operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.IsSameOrAfter);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1],y=s[2],m=YCe(c,e,y);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class eVe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_BETWEEN,version:"1.0.0",description:"Date is-between operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.IsBetween);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(b=>{var w,V;return((w=b.value)==null?void 0:w.valueAsType)||((V=b.value)==null?void 0:V.value)}),c=s[0],e=s[1],y=s[2],m=s[3],v=s[4],E=XCe(c,e,y,m,v??void 0);return{value:G.Success,error:null,result:E}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class tVe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_VALID,version:"1.0.0",description:"Date is-valid operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.IsValid);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)||((m=e.value)==null?void 0:m.value)}),c=QCe(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class iVe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_LEAP_YEAR,version:"1.0.0",description:"Date is-leap-year operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.IsLeapYear);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)||((m=e.value)==null?void 0:m.value)}),c=e_e(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class rVe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_CLAMP_TO_RANGE,version:"1.0.0",description:"Date clamp-to-range operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.ClampToRange);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1],y=s[2],m=t_e(c,e,y);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class nVe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_MIN_OF,version:"1.0.0",description:"Date min-of operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.MinOf);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)}),c=s.length===1&&Array.isArray(s[0])?s[0]:s,e=i_e(c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class aVe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_MAX_OF,version:"1.0.0",description:"Date max-of operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.MaxOf);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)}),c=s.length===1&&Array.isArray(s[0])?s[0]:s,e=r_e(c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class sVe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_FROM_NOW,version:"1.0.0",description:"Date from-now operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.FromNow);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s,c]=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),y=n_e(s,c??!1);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class lVe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_NOW,version:"1.0.0",description:"Date to-now operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.ToNow);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s,c]=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),y=a_e(s,c??!1);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class oVe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_HUMANIZE_DIFF,version:"1.0.0",description:"Date humanize-diff operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.HumanizeDiff);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s,c,e]=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),m=s_e(s,c,e??!0);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class dVe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_ADD_BUSINESS_DAYS,version:"1.1.0",description:"Date add-business-days operation implementation module (ISO-weekend strings)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.AddBusinessDays);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(E=>{var b,w;return((b=E.value)==null?void 0:b.valueAsType)??((w=E.value)==null?void 0:w.value)}),c=s[0],e=s[1],y=s[2]??void 0,m=s[3]??[],v=l_e(c,e,y,m);return{value:G.Success,error:null,result:v}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class uVe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_NEXT_WEEKDAY,version:"1.0.0",description:"Date next-weekday operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.NextWeekday);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)}),e=o_e(s,c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class pVe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_PREVIOUS_WEEKDAY,version:"1.0.0",description:"Date previous-weekday operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.PreviousWeekday);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)}),e=d_e(s,c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class cVe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_UTC,version:"1.1.0",description:"Date to-utc operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.ToUTC);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1]||void 0,y=s[2]??!1,m=p_e(c,e,y);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class fVe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_CONVERT_TIMEZONE,version:"1.0.0",description:"Date convert-timezone operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.ConvertTimezone);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s,c,e]=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),m=c_e(s,c,e??!1);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class yVe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_TIMEZONE_OFFSET,version:"1.0.0",description:"Date get-timezone-offset operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.GetTimezoneOffset);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s,c]=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),m=f_e(s,c);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class hVe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_UTC_OFFSET,version:"1.0.0",description:"Date set-utc-offset operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.SetUTCOffset);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s,c,e]=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),m=y_e(s,c,e??!1);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class mVe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__EXECUTE_PARALLEL,version:"1.0.0",description:"Execution parallel operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(Ki.Parallel);s&&(s.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(b=>{var w,V;return((w=b.value)==null?void 0:w.valueAsType)||((V=b.value)==null?void 0:V.value)})[0];if(!c)return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No list of action entities provided",result:null};if(!Array.isArray(c))return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"Invalid input value. Expected a list of action entities",result:null};const y=this.extensionsRegistry.requestContexts(this,[X.Editor])[0],v=c.map(b=>{const w=new Iu(y.logic,[b],b,null,this.extensionsRegistry);return w.inheritValuesFromContext(y),w}).map(b=>b.execute()),E=await Promise.all(v);return{value:G.Success,error:null,result:E}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class TVe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__EXECUTE_SEQUENTIAL,version:"1.0.0",description:"Execution sequential operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(Ki.Sequential);s&&(s.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)})[0];if(!c)return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No list of action entities provided",result:null};if(!Array.isArray(c))return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"Invalid input value. Expected a list of action entities",result:null};const e=[];for(let y=0;y<c.length;y++){const m=c[y],E=this.extensionsRegistry.requestContexts(this,[X.Editor])[0],b=new Iu(E.logic,[m],m,null,this.extensionsRegistry);b.inheritValuesFromContext(E);const w=await b.execute();e.push(w)}return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class vVe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__EXECUTE_WAIT,version:"1.0.0",description:"Execution wait operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(Ki.Wait);s&&(s.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)||((m=e.value)==null?void 0:m.value)})[0];return typeof c!="number"||c<0?{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"Invalid wait time provided",result:null}:(await new Promise(e=>setTimeout(e,c)),{value:G.Success,error:null,result:null})}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}const Wvi=/^\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d{1,3})?)?(?:Z|[+-]\d{2}:?\d{2})?)?$/,QP=o=>o===null||["string","number","boolean"].includes(typeof o);function Cn(o,p="Input must be an array"){if(!Array.isArray(o))throw new TypeError(p);return o}function Yl(o){const p=Cn(o,"Input must be an array");if(!p||p.length===0)throw new TypeError("No list provided or list is empty");return p}function eN(o){return Array.isArray(o)?o:[]}function os(o){return Number(o)}function EVe(o){if(!o||o.length===0)throw new TypeError("No input lists provided");if(!o.every(n=>Array.isArray(n)))throw new TypeError("All inputs must be arrays");const[p,...i]=o;return i.reduce((n,s)=>n.concat(s),p)}function bVe(o,...p){if(!Array.isArray(o))throw new TypeError("First input must be an array");if(!p.every(i=>Array.isArray(i)))throw new TypeError("All subsequent inputs must be arrays");return o.concat(...p)}function AVe(o,p){const i=Yl(o),n=os(p);return[i.slice(0,n),i.slice(n)]}function gVe(o){return Yl(o).slice().reverse()}function IVe(o){return Yl(o).slice(0,-1)}function RVe(o){return Yl(o).slice(1)}function DVe(o,p,i){const n=Cn(o),s=os(p);if(s<0||s>n.length)throw new TypeError("Index out of bounds");return[...n.slice(0,s),i,...n.slice(s)]}function wVe(o,p,i){const n=Yl(o),s=os(p);if(s<0||s>=n.length)throw new TypeError("Index out of bounds");const c=[...n];return c[s]=i,c}function OVe(o,p,i){const n=Yl(o),s=n.indexOf(p);if(s===-1)return n;const c=[...n];return c[s]=i,c}function CVe(o,p,i){const n=Yl(o),s=n.lastIndexOf(p);if(s===-1)return n;const c=[...n];return c[s]=i,c}function _Ve(o,p,i){return Yl(o).map(s=>s===p?i:s)}function VVe(o,p){const i=Yl(o),n=os(p);if(n<0||n>=i.length)throw new TypeError("Index out of bounds");return i[n]}function PVe(o){return Yl(o)[0]}function NVe(o){const p=Yl(o);return p[p.length-1]}function xVe(o,p,...i){return[...Cn(o),p,...i]}function $Ve(o,p){const i=Cn(o);return[p,...i]}function LVe(o){return Cn(o).length}function MVe(o,p){const i=Cn(o),n=os(p);if(n<0||n>=i.length)throw new TypeError("Index out of bounds");return i.slice(0,n).concat(i.slice(n+1))}function BVe(o,p){const i=Cn(o),n=Math.max(0,os(p)??0);return i.slice(0,n)}function GVe(o,p){const i=Cn(o),n=Math.max(0,os(p)??0);return n===0?[]:i.slice(-n)}function kVe(o,p,i){const n=Cn(o),s=p==null?void 0:os(p),c=i==null?void 0:os(i);return n.slice(s,c)}function jVe(o,p){return Cn(o).indexOf(p)}function UVe(o,p){return Cn(o).lastIndexOf(p)}function KVe(o){const p=Cn(o),i=[],n=new Set;for(const s of p)n.has(s)||(n.add(s),i.push(s));return i}function FVe(o){return Cn(o).reduce((i,n)=>i.concat(n),[])}function SVe(o){const p=Cn(o);if(p.length<=1)return[...p];const i=p[0],n=typeof i=="number"&&p.every(e=>typeof e=="number"&&Number.isFinite(e)),s=typeof i=="string"&&p.every(e=>typeof e=="string");let c=null;if(n?c="number":s&&(c=p.every(y=>Wvi.test(y)&&M(y).isValid())?"date":"string"),!c)throw new TypeError("All items must be of the same supported type: number, string, or ISO date string.");return c==="number"?[...p].sort((e,y)=>e-y):c==="string"?[...p].sort((e,y)=>e.localeCompare(y)):[...p].sort((e,y)=>M(e).valueOf()-M(y).valueOf())}function qVe(o){const i=[...Cn(o)];for(let n=i.length-1;n>0;n--){const s=Math.floor(KI()*(n+1));[i[n],i[s]]=[i[s],i[n]]}return i}function ZVe(o,p){const i=Cn(o),n=Math.max(1,os(p)||1),s=[];for(let c=0;c<i.length;c+=n)s.push(i.slice(c,c+n));return s}function HVe(o,p,i){const n=Cn(o),s=Math.max(0,os(p)||0);if(n.length>=s)return[...n];const c=s-n.length;return Array(c).fill(i).concat(n)}function WVe(o,p,i){const n=Cn(o),s=Math.max(0,os(p)||0);if(n.length>=s)return[...n];const c=s-n.length,e=Array(c).fill(i);return n.concat(e)}function zVe(o,p){const i=Cn(o),n=Math.max(0,os(p)||0),s=[];for(let c=0;c<n;c++)s.push(...i);return s}function JVe(o,p){if(!QP(p))throw new TypeError("Contains expects the needle to be a primitive (string | number | boolean | null).");return eN(o).some(n=>n===p)}function YVe(o,p){const i=eN(o),n=Array.isArray(p)?p:[p];if(n.length===0)return!1;if(!n.every(QP))throw new TypeError("ContainsAll expects all needles to be primitives (string | number | boolean | null).");return n.every(s=>i.includes(s))}function XVe(o,p){const i=eN(o),n=Array.isArray(p)?p:[p];if(n.length===0)return!1;if(!n.every(QP))throw new TypeError("ContainsAny expects all needles to be primitives (string | number | boolean | null).");return n.some(s=>i.includes(s))}class QVe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_JOIN,version:"1.0.0",description:"List join operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(ie.Join);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)}),c=EVe(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class ePe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_SPLIT,version:"1.0.0",description:"List split operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(ie.Split);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1],[y,m]=AVe(c,e);return{value:G.Success,error:null,result:[y,m]}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class tPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REVERSE,version:"1.0.0",description:"List reverse operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(ie.Reverse);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)})[0],e=gVe(c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class iPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_DELETE_LAST_N_ITEMS,version:"1.0.0",description:"List delete last operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(ie.DeleteLastNItems);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)})[0],e=IVe(c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class rPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_DELETE_FIRST_N_ITEMS,version:"1.0.0",description:"List delete first operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(ie.DeleteFirstNItems);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)})[0],e=RVe(c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class nPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_ADD_AT_INDEX,version:"1.0.0",description:"List add index operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(ie.AddAtIndex);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1],y=s[2],m=DVe(c,e,y);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class aPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_AT_INDEX,version:"1.0.0",description:"List replace index operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(ie.ReplaceAtIndex);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1],y=s[2],m=wVe(c,e,y);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class sPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_FIRST_N_ITEMS,version:"1.0.0",description:"List replace first operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(ie.ReplaceFirstNItems);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1],y=s[2],m=OVe(c,e,y);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class lPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_LAST_N_ITEMS,version:"1.0.0",description:"List replace last operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(ie.ReplaceLastNItems);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1],y=s[2],m=CVe(c,e,y);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class oPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_ALL,version:"1.0.0",description:"List replace all operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(ie.ReplaceAll);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1],y=s[2],m=_Ve(c,e,y);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class dPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_INDEX_ITEM,version:"1.0.0",description:"List get index item operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(ie.GetIndexItem);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1],y=VVe(c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class uPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_FIRST,version:"1.0.0",description:"List get first operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(ie.GetFirst);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)})[0],e=PVe(c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class pPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_LAST,version:"1.0.0",description:"List get last operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(ie.GetLast);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)})[0],e=NVe(c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class cPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_APPEND,version:"1.0.0",description:"List append operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(ie.Append);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1],y=s.slice(2),m=xVe(c,e,...y);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class fPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_PREPEND,version:"1.0.0",description:"List prepend operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(ie.Prepend);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1],y=$Ve(c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class yPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_LENGTH,version:"1.0.0",description:"List get length",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ie.GetLength);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=n.map(c=>{var e,y;return((e=c.value)==null?void 0:e.valueAsType)??((y=c.value)==null?void 0:y.value)});return{value:G.Success,error:null,result:LVe(s)}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class hPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_DELETE_AT_INDEX,version:"1.0.0",description:"List delete one item at index (non-mutating)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ie.DeleteAtIndex);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)??((v=y.value)==null?void 0:v.value)}),e=MVe(s,c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class mPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_FIRST_N_ITEMS,version:"1.0.0",description:"List get first N items",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ie.GetFirstNItems);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)??((v=y.value)==null?void 0:v.value)}),e=BVe(s,c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class TPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_LAST_N_ITEMS,version:"1.0.0",description:"List get last N items",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ie.GetLastNItems);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)??((v=y.value)==null?void 0:v.value)}),e=GVe(s,c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class vPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_SLICE,version:"1.0.0",description:"List slice(start, end)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ie.Slice);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c,e]=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)??((E=m.value)==null?void 0:E.value)}),y=kVe(s,c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class EPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CONCAT,version:"1.0.0",description:"List concat(base, ...others)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ie.Concat);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)??((E=m.value)==null?void 0:E.value)}),[c,...e]=s,y=bVe(c,...e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class bPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_INDEX_OF,version:"1.0.0",description:"List listGetIndexOf(value)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ie.GetIndexOf);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)??((v=y.value)==null?void 0:v.value)}),e=jVe(s,c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class APe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_LAST_INDEX_OF,version:"1.0.0",description:"List listGetLastIndexOf(value)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ie.GetLastIndexOf);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)??((v=y.value)==null?void 0:v.value)}),e=UVe(s,c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class gPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_UNIQUE,version:"1.0.0",description:"List unique (stable, by reference/===)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ie.Unique);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)}),c=KVe(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class IPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_FLATTEN,version:"1.0.0",description:"List flatten one level",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ie.Flatten);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)}),c=FVe(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class RPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_SORT,version:"1.0.0",description:"List sort (non-mutating). Supports lists of strings (alphabetic), numbers (numeric), or ISO date strings (chronological).",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ie.Sort);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)}),c=SVe(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class DPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_SHUFFLE,version:"1.0.0",description:"List shuffle (Fisher–Yates, secure RNG helper)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ie.Shuffle);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)}),c=qVe(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class wPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CHUNK,version:"1.0.0",description:"List chunk(size) -> list of lists",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ie.Chunk);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)??((v=y.value)==null?void 0:v.value)}),e=ZVe(s,c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class OPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_PAD_START,version:"1.0.0",description:"List padStart(targetLength, padValue)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ie.PadStart);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c,e]=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)??((E=m.value)==null?void 0:E.value)}),y=HVe(s,c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class CPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_PAD_END,version:"1.0.0",description:"List padEnd(targetLength, padValue)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ie.PadEnd);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c,e]=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)??((E=m.value)==null?void 0:E.value)}),y=WVe(s,c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class _Pe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPEAT,version:"1.0.0",description:"List repeat(count)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ie.Repeat);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)??((v=y.value)==null?void 0:v.value)}),e=zVe(s,c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class VPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CONTAINS,version:"1.0.0",description:"List contains (primitive needles)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ie.Contains);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)??((v=y.value)==null?void 0:v.value)}),e=JVe(s,c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class PPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CONTAINS_ALL,version:"1.0.0",description:"List contains all (primitive needles)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ie.ContainsAll);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)??((v=y.value)==null?void 0:v.value)}),e=YVe(s,c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class NPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CONTAINS_ANY,version:"1.0.0",description:"List contains any (primitive needles)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ie.ContainsAny);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)??((v=y.value)==null?void 0:v.value)}),e=XVe(s,c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class zvi extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_LENGTH,version:"1.0.0",description:"Returns the number of characters in a string",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.GetLength);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)}),c=s.length;return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class xPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_JOIN,version:"1.0.0",description:"String join operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.Join);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{var s,c,e;try{const y=n.find(k=>{var K;return((K=k.valueOwner)==null?void 0:K.id)===Q.operation[q.Join].inputs.separator.id}),m=((s=y==null?void 0:y.value)==null?void 0:s.value)||"",v=n.find(k=>{var K;return((K=k.valueOwner)==null?void 0:K.id)===Q.operation[q.Join].inputs.first.id}),E=((c=v==null?void 0:v.value)==null?void 0:c.value)||"",b=n.find(k=>{var K;return((K=k.valueOwner)==null?void 0:K.id)===Q.operation[q.Join].inputs.second.id}),w=((e=b==null?void 0:b.value)==null?void 0:e.value)||"",$=n.filter(k=>{var K;return((K=k.valueOwner)==null?void 0:K.id)===Q.operation[q.Join].inputs.dynamicString.id}).map(k=>{var K,S;return((K=k.value)==null?void 0:K.valueAsType)||((S=k.value)==null?void 0:S.value)||""}),L=[E,w,...$].join(m);return{value:G.Success,error:null,result:L}}catch(y){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:y,result:null}}}})}}class $Pe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SPLIT_AT_INDEX,version:"1.0.0",description:"String split at index operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.SplitAtIndex);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1],y={firstPart:c.slice(0,e),secondPart:c.slice(e)};return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class LPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SPLIT_AT_ALL_SEPARATORS,version:"1.0.0",description:"String split at all the occurrences of separators operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.SplitAtAllSeparators);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1],y=c.split(e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class MPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SPLIT_AT_FIRST_SEPARATOR,version:"1.0.0",description:"String split at the first occurrence of a separator operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.SplitAtFirstSeparator);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1],y=c.indexOf(e),m={firstPart:c.slice(0,y),secondPart:c.slice(y+e.length)};return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class BPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SPLIT_AT_LAST_SEPARATOR,version:"1.0.0",description:"String split at the last occurrence of a separator operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.SplitAtLastSeparator);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1],y=c.lastIndexOf(e),m={firstPart:c.slice(0,y),secondPart:c.slice(y+e.length)};return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class GPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_DELETE_LAST_N_CHARS,version:"1.0.0",description:"String delete last number of characters operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.DeleteLastNChars);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1]??1;if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No string provided",result:null};const y=c.slice(0,-e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class kPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_DELETE_FIRST_N_CHARS,version:"1.0.0",description:"String delete first number of characters operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.DeleteFirstNChars);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1]??1;if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No string provided",result:null};const y=c.slice(0,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class jPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REVERSE,version:"1.0.0",description:"String reverse operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.Reverse);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)})[0];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No string provided",result:null};const e=c.split("").reverse().join("");return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class UPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TO_LOWER_CASE,version:"1.0.0",description:"String to lower case operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.ToLowerCase);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)})[0];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No string provided",result:null};const e=c.toLowerCase();return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class KPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TO_UPPER_CASE,version:"1.0.0",description:"String to upper case operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.ToUpperCase);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)})[0];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No string provided",result:null};const e=c.toUpperCase();return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class FPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_DELETE_AT_INDEX,version:"1.0.0",description:"String delete index operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.DeleteAtIndex);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(E=>{var b,w;return((b=E.value)==null?void 0:b.valueAsType)||((w=E.value)==null?void 0:w.value)}),c=s[0],e=s[1],y=s[2]??1;if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No string provided",result:null};const m=Math.min(y,c.length-e),v=c.slice(0,e)+c.slice(e+m);return{value:G.Success,error:null,result:v}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class SPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_ADD_AT_INDEX,version:"1.0.0",description:"String add index operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.AddAtIndex);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1],y=s[2];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No string provided",result:null};const m=c.slice(0,e)+y+c.slice(e);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class qPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_FIRST_N_CHARS,version:"1.0.0",description:"String replace first operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.ReplaceFirstNChars);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1]??1,y=s[2];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No string provided",result:null};const m=y+c.slice(e);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class ZPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_LAST_N_CHARS,version:"1.0.0",description:"String replace last operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.ReplaceLastNChars);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1]??1,y=s[2];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No string provided",result:null};const m=c.slice(0,-e)+y;return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class HPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_AT_INDEX,version:"1.0.0",description:"String replace index operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.ReplaceAtIndex);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(E=>{var b,w;return((b=E.value)==null?void 0:b.valueAsType)||((w=E.value)==null?void 0:w.value)}),c=s[0],e=s[1],y=s[2]??1,m=s[3];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No string provided",result:null};const v=(c.slice(0,e)||"")+m+(c.slice(e+y)||"");return{value:G.Success,error:null,result:v}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class WPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_FIRST_MATCH,version:"1.0.0",description:"String replace single match operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.ReplaceFirstMatch);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1],y=s[2];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No string provided",result:null};const m=c.replace(e,y);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class zPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_LAST_MATCH,version:"1.0.0",description:"String replace single match operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.ReplaceLastMatch);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(E=>{var b,w;return((b=E.value)==null?void 0:b.valueAsType)||((w=E.value)==null?void 0:w.value)}),c=s[0],e=s[1],y=s[2];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No string provided",result:null};const m=c.lastIndexOf(e),v=m===-1?c:c.substring(0,m)+y+c.substring(m+e.length);return{value:G.Success,error:null,result:v}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class JPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_ALL_MATCHES,version:"1.0.0",description:"String replace all matches operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.ReplaceAllMatches);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1],y=s[2];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No string provided",result:null};const m=c.split(e).join(y);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class YPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_INDEX_ITEM,version:"1.0.0",description:"String get index operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.GetIndexItem);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No string provided",result:null};const y=c.charAt(e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class XPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_LAST_N_CHARS,version:"1.0.0",description:"String get last N chars operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.GetLastNChars);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No string provided",result:null};const y=c.slice(-e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class QPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_FIRST_N_CHARS,version:"1.0.0",description:"String get first N chars operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.GetFirstNChars);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No string provided",result:null};const y=c.slice(0,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class eNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_INDEX_OF,version:"1.0.0",description:"String get index of operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.GetIndexOf);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No string provided",result:null};if(typeof e!="string")return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No search value provided",result:null};const y=c.indexOf(e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class tNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_APPEND,version:"1.0.0",description:"String append operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.Append);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No string provided",result:null};if(typeof e!="string")return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No value to append provided",result:null};const y=s.slice(2);if(!y.every(v=>typeof v=="string"))return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"All values to append must be strings",result:null};const m=[c,e,...y].join("");return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class iNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_PREPEND,version:"1.0.0",description:"String prepend operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.Prepend);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No string provided",result:null};const y=e+c;return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class rNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TRIM,version:"1.0.0",description:"String trim implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.Trim);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)}),c=s.trim();return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class nNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TRIM_START,version:"1.0.0",description:"String trimStart implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.TrimStart);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)}),c=s.trimStart();return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class aNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TRIM_END,version:"1.0.0",description:"String trimEnd implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.TrimEnd);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)}),c=s.trimEnd();return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class sNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SUBSTRING,version:"1.0.0",description:"String substring(start, end?) implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.Substring);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c,e]=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)??((E=m.value)==null?void 0:E.value)}),y=s.substring(c,e??void 0);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class lNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SLICE,version:"1.0.0",description:"String slice(start, end?) implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.Slice);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c,e]=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)??((E=m.value)==null?void 0:E.value)}),y=s.slice(c,e??void 0);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class oNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_LAST_INDEX_OF,version:"1.0.0",description:"String lastIndexOf(search, fromIndex?) implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.GetLastIndexOf);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c,e]=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)??((E=m.value)==null?void 0:E.value)}),y=s.lastIndexOf(c,e??void 0);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class dNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_PAD_START,version:"1.0.0",description:"String padStart(targetLength, padString?) implementation",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.PadStart);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c,e]=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)??((E=m.value)==null?void 0:E.value)}),y=s.padStart(c,e??void 0);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class uNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_PAD_END,version:"1.0.0",description:"String padEnd(targetLength, padString?) implementation",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.PadEnd);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c,e]=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)??((E=m.value)==null?void 0:E.value)}),y=s.padEnd(c,e??void 0);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class pNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPEAT,version:"1.0.0",description:"String repeat(count) implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.Repeat);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)??((v=y.value)==null?void 0:v.value)}),e=s.repeat(c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class cNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_MATCH_REGEX,version:"1.0.0",description:"String match(regex) -> first match array or null",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.MatchRegex);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c,e]=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)??((b=v.value)==null?void 0:b.value)}),y=new RegExp(String(c??""),e?String(e):void 0),m=String(s??"").match(y);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class fNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_MATCH_ALL_REGEX,version:"1.0.0",description:"String matchAll(regex) -> array of matches",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.MatchAllRegex);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c,e]=n.map(b=>{var w,V;return((w=b.value)==null?void 0:w.valueAsType)??((V=b.value)==null?void 0:V.value)}),y=e?String(e):"",m=y.includes("g")?y:y+"g",v=new RegExp(String(c??""),m),E=Array.from(String(s??"").matchAll(v),b=>Array.from(b));return{value:G.Success,error:null,result:E}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class yNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SEARCH_REGEX,version:"1.0.0",description:"String search(regex) -> index or -1",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.SearchRegex);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c,e]=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)??((E=m.value)==null?void 0:E.value)});let y=-1;try{const m=new RegExp(String(c??""),e?String(e):void 0);y=String(s??"").search(m)}catch{y=-1}return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class hNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_REGEX,version:"1.0.0",description:"String replace using RegExp (pattern, replacement, flags?)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.ReplaceRegex);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c,e,y]=n.map(E=>{var b,w;return((b=E.value)==null?void 0:b.valueAsType)??((w=E.value)==null?void 0:w.value)});let m=String(s??"");const v=new RegExp(String(c??""),y?String(y):void 0);return m=m.replace(v,String(e??"")),{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class mNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_NORMALIZE_UNICODE,version:"1.0.0",description:"String normalize(form?) implementation module (NFC by default)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.NormalizeUnicode);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)??((v=y.value)==null?void 0:v.value)}),e=s.normalize(c||"NFC");return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}const MA=class MA extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REMOVE_DIACRITICS,version:"1.0.0",description:"Remove diacritics via NFD decomposition + strip combining marks",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.RemoveDiacritics);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)}),c=String(s??"").normalize("NFD").replace(MA.COMBINING_MARKS,"");return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}};I(MA,"COMBINING_MARKS",/[\u0300-\u036f]/g);let yA=MA;class TNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_COUNT_OCCURRENCES,version:"1.0.0",description:"Count literal substring occurrences in a string",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.CountOccurrences);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)??((b=v.value)==null?void 0:b.value)}),e=String(s??""),y=String(c??""),m=y===""?0:e.split(y).length-1;return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class vNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_ENSURE_PREFIX,version:"1.0.0",description:"Ensure string starts with given prefix (add if missing)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.EnsurePrefix);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)??((b=v.value)==null?void 0:b.value)}),e=String(s??""),y=String(c??""),m=e.startsWith(y)?e:y+e;return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class ENe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_ENSURE_SUFFIX,version:"1.0.0",description:"Ensure string ends with given suffix (add if missing)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.EnsureSuffix);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)??((b=v.value)==null?void 0:b.value)}),e=String(s??""),y=String(c??""),m=e.endsWith(y)?e:e+y;return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class bNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REMOVE_PREFIX,version:"1.0.0",description:"Remove prefix if present",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.RemovePrefix);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)??((b=v.value)==null?void 0:b.value)}),e=String(s??""),y=String(c??""),m=e.startsWith(y)?e.slice(y.length):e;return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class ANe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REMOVE_SUFFIX,version:"1.0.0",description:"Remove suffix if present",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.RemoveSuffix);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)??((b=v.value)==null?void 0:b.value)}),e=String(s??""),y=String(c??""),m=e.endsWith(y)?e.slice(0,-y.length):e;return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class gNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_STARTS_WITH,version:"1.0.0",description:"String startsWith(needle) -> boolean",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.StartsWith);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)??((v=y.value)==null?void 0:v.value)});if(typeof s!="string"||typeof c!="string")throw new TypeError("StartsWith expects two strings.");const e=s.startsWith(c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class INe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_ENDS_WITH,version:"1.0.0",description:"String endsWith(needle) -> boolean",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.EndsWith);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)??((v=y.value)==null?void 0:v.value)});if(typeof s!="string"||typeof c!="string")throw new TypeError("EndsWith expects two strings.");const e=s.endsWith(c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class RNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_CONTAINS,version:"1.0.0",description:"String includes(needle) -> boolean",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.Contains);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)??((v=y.value)==null?void 0:v.value)});if(typeof s!="string"||typeof c!="string")throw new TypeError("Contains expects two strings.");const e=s.includes(c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class DNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_MATCHES_REGEX,version:"1.0.0",description:"Regex test: new RegExp(pattern, flags?).test(src) -> boolean",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.MatchesRegex);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c,e]=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)??((b=v.value)==null?void 0:b.value)});if(typeof s!="string"||typeof c!="string")throw new TypeError("MatchesRegex expects source and pattern to be strings.");if(!(e===void 0||typeof e=="string"))throw new TypeError("MatchesRegex flags must be a string if provided.");let y=!1;return y=new RegExp(c,e).test(s),{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}function wNe(o,p){const i=Number(o),s=10**Math.max(0,Number(p)||0);return Math.round(i*s)/s}function ONe(o,p){const i=Number(o),n=Math.abs(Number(p)||0);return n===0?i:Math.round(i/n)*n}function CNe(o,p,i){const n=Number(o),s=Number(p),c=Number(i);return Math.min(Math.max(n,s),c)}function _Ne(o,p,i,n,s){const c=Number(o),e=Number(p),y=Number(i),m=Number(n),v=Number(s);if(e===y)throw new Error("Input range cannot be zero");const E=(c-e)/(y-e);return m+E*(v-m)}function VNe(...o){const p=o.map(n=>Number(n));return p.length===0?0:p.reduce((n,s)=>n+s,0)/p.length}function PNe(...o){const p=o.map(n=>Number(n)).sort((n,s)=>n-s);if(p.length===0)return 0;const i=Math.floor(p.length/2);return p.length%2?p[i]:(p[i-1]+p[i])/2}function NNe(o,p){const i=Number(o),n=Number(p);return n===0?NaN:i<0&&n%2===1?-Math.pow(-i,1/n):Math.pow(i,1/n)}function xNe(o,p){const i=Number(o),n=Number(p);return i===0?1/0:(n-i)/i*100}const oi=o=>o.map(p=>{var i,n;return((i=p.value)==null?void 0:i.valueAsType)??((n=p.value)==null?void 0:n.value)});class $Ne extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ADDITION,version:"1.0.0",description:"Number addition operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(te.Addition);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const c=oi(n).reduce((e,y)=>e+y,0);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class LNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SUBTRACTION,version:"1.0.0",description:"Number subtraction operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(te.Subtraction);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const c=oi(n).reduce((e,y)=>e-y,0);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class MNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MULTIPLICATION,version:"1.0.0",description:"Number multiplication operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(te.Multiplication);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const c=oi(n).reduce((e,y)=>e*y,1);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class BNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_DIVISION,version:"1.0.0",description:"Number division operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(te.Division);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s,c]=oi(n);if(c===0)throw new Error("Division by zero is not allowed");const e=s/c;return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class GNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_REMAINDER,version:"1.0.0",description:"Number remainder operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(te.Remainder);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s,c]=oi(n);if(c===0)throw new Error("Division by zero is not allowed");const e=s%c;return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class kNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_EXPONENTIATION,version:"1.0.0",description:"Number exponentiation operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(te.Exponentiation);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s,c]=oi(n),e=Math.pow(s,c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class jNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_NEGATE,version:"1.0.0",description:"Number negate (unary -x)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.Negate);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=oi(n);return{value:G.Success,error:null,result:-s}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class UNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ABSOLUTE,version:"1.0.0",description:"Number absolute (|x|)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.Absolute);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=oi(n);return{value:G.Success,error:null,result:Math.abs(Number(s))}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class KNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SIGN,version:"1.0.0",description:"Number sign (-1 | 0 | 1)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.Sign);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=oi(n);return{value:G.Success,error:null,result:Math.sign(Number(s))}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class FNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ROUND,version:"1.0.0",description:"Number round to nearest integer",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.Round);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=oi(n);return{value:G.Success,error:null,result:Math.round(Number(s))}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class SNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_FLOOR,version:"1.0.0",description:"Number floor (⌊x⌋)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.Floor);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=oi(n);return{value:G.Success,error:null,result:Math.floor(Number(s))}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class qNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_CEIL,version:"1.0.0",description:"Number ceil (⌈x⌉)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.Ceil);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=oi(n);return{value:G.Success,error:null,result:Math.ceil(Number(s))}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class ZNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_TRUNC,version:"1.0.0",description:"Number truncation (drop fractional part)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.Trunc);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=oi(n);return{value:G.Success,error:null,result:Math.trunc(Number(s))}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class HNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ROUND_TO_DECIMALS,version:"1.0.0",description:"Round to N decimals",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.RoundToDecimals);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=oi(n),e=wNe(s,c);return{value:G.Success,error:null,result:e}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class WNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SNAP_TO_STEP,version:"1.0.0",description:"Snap a number to the nearest multiple of step (>=0 step)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.SnapToStep);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=oi(n),e=ONe(s,c);return{value:G.Success,error:null,result:e}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class zNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_CLAMP,version:"1.0.0",description:"Clamp value to [min, max]",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.Clamp);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c,e]=oi(n),y=CNe(s,c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class JNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MAP_RANGE,version:"1.0.0",description:"Map value from [inMin,inMax] to [outMin,outMax]",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.MapRange);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c,e,y,m]=oi(n),v=_Ne(s,c,e,y,m);return{value:G.Success,error:null,result:v}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class YNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_AVERAGE,version:"1.0.0",description:"Average(numbers...)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.Average);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const s=oi(n),c=VNe(...s);return{value:G.Success,error:null,result:c}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class XNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MEDIAN,version:"1.0.0",description:"Median(numbers...)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.Median);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const s=oi(n),c=PNe(...s);return{value:G.Success,error:null,result:c}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class QNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MIN_OF,version:"1.0.0",description:"Min(numbers...)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.MinOf);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const s=oi(n).map(Number),c=s.length?Math.min(...s):1/0;return{value:G.Success,error:null,result:c}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class exe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MAX_OF,version:"1.0.0",description:"Max(numbers...)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.MaxOf);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const s=oi(n).map(Number),c=s.length?Math.max(...s):-1/0;return{value:G.Success,error:null,result:c}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class txe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SQUARE_ROOT,version:"1.0.0",description:"Square root",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.SquareRoot);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=oi(n);return{value:G.Success,error:null,result:Math.sqrt(Number(s))}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class ixe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_CUBE_ROOT,version:"1.0.0",description:"Cube root",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.CubeRoot);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=oi(n);return{value:G.Success,error:null,result:Math.cbrt(Number(s))}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class rxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_NTH_ROOT,version:"1.0.0",description:"Nth root (value, n)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.NthRoot);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=oi(n),e=NNe(s,c);return{value:G.Success,error:null,result:e}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class nxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_EXP,version:"1.0.0",description:"e^x",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.Exp);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=oi(n);return{value:G.Success,error:null,result:Math.exp(Number(s))}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class axe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_LOG_NATURAL,version:"1.0.0",description:"Natural log ln(x)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.LogNatural);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=oi(n);return{value:G.Success,error:null,result:Math.log(Number(s))}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class sxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_LOG10,version:"1.0.0",description:"Log base 10",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.Log10);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=oi(n),c=Number(s),e=Math.log10?Math.log10(c):Math.log(c)/Math.LN10;return{value:G.Success,error:null,result:e}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class lxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SIN,version:"1.0.0",description:"sin(x in radians)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.Sin);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=oi(n);return{value:G.Success,error:null,result:Math.sin(Number(s))}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class oxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_COS,version:"1.0.0",description:"cos(x in radians)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.Cos);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=oi(n);return{value:G.Success,error:null,result:Math.cos(Number(s))}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class dxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_TAN,version:"1.0.0",description:"tan(x in radians)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.Tan);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=oi(n);return{value:G.Success,error:null,result:Math.tan(Number(s))}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class uxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ASIN,version:"1.0.0",description:"asin(x)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.Asin);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=oi(n);return{value:G.Success,error:null,result:Math.asin(Number(s))}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class pxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ACOS,version:"1.0.0",description:"acos(x)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.Acos);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=oi(n);return{value:G.Success,error:null,result:Math.acos(Number(s))}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class cxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ATAN,version:"1.0.0",description:"atan(x)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.Atan);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=oi(n);return{value:G.Success,error:null,result:Math.atan(Number(s))}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class fxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ATAN2,version:"1.0.0",description:"atan2(y, x)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.Atan2);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=oi(n);return{value:G.Success,error:null,result:Math.atan2(Number(s),Number(c))}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class yxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_TO_RADIANS,version:"1.0.0",description:"deg → rad",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.ToRadians);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=oi(n);return{value:G.Success,error:null,result:Number(s)*Math.PI/180}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class hxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_TO_DEGREES,version:"1.0.0",description:"rad → deg",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.ToDegrees);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=oi(n);return{value:G.Success,error:null,result:Number(s)*180/Math.PI}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class mxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_PERCENT_OF,version:"1.0.0",description:"x percent of y",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.PercentOf);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=oi(n),e=Number(s)/100*Number(c);return{value:G.Success,error:null,result:e}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class JO extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_PERCENTAGE_CHANGE,version:"1.0.0",description:"((new-old)/old)*100",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.PercentageChange);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=oi(n),e=xNe(s,c);return{value:G.Success,error:null,result:e}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class Txe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_LESS_THAN,version:"1.0.0",description:"a < b",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.LessThan);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=oi(n);return{value:G.Success,error:null,result:s<c}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class vxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MORE_THAN,version:"1.0.0",description:"a > b",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.MoreThan);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=oi(n);return{value:G.Success,error:null,result:s>c}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class Exe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_LESS_THAN_OR_EQUAL,version:"1.0.0",description:"a <= b",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.LessThanOrEqual);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=oi(n);return{value:G.Success,error:null,result:s<=c}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class bxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MORE_THAN_OR_EQUAL,version:"1.0.0",description:"a >= b",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.MoreThanOrEqual);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=oi(n);return{value:G.Success,error:null,result:s>=c}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}function Axe(o,p){return function(){return o.apply(p,arguments)}}const{toString:Jvi}=Object.prototype,{getPrototypeOf:tN}=Object,{iterator:qI,toStringTag:gxe}=Symbol,ZI=(o=>p=>{const i=Jvi.call(p);return o[i]||(o[i]=i.slice(8,-1).toLowerCase())})(Object.create(null)),Xl=o=>(o=o.toLowerCase(),p=>ZI(p)===o),HI=o=>p=>typeof p===o,{isArray:Mh}=Array,wy=HI("undefined");function lv(o){return o!==null&&!wy(o)&&o.constructor!==null&&!wy(o.constructor)&&Ga(o.constructor.isBuffer)&&o.constructor.isBuffer(o)}const Ixe=Xl("ArrayBuffer");function Yvi(o){let p;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?p=ArrayBuffer.isView(o):p=o&&o.buffer&&Ixe(o.buffer),p}const Xvi=HI("string"),Ga=HI("function"),Rxe=HI("number"),ov=o=>o!==null&&typeof o=="object",Qvi=o=>o===!0||o===!1,Kb=o=>{if(ZI(o)!=="object")return!1;const p=tN(o);return(p===null||p===Object.prototype||Object.getPrototypeOf(p)===null)&&!(gxe in o)&&!(qI in o)},eEi=o=>{if(!ov(o)||lv(o))return!1;try{return Object.keys(o).length===0&&Object.getPrototypeOf(o)===Object.prototype}catch{return!1}},tEi=Xl("Date"),iEi=Xl("File"),rEi=Xl("Blob"),nEi=Xl("FileList"),aEi=o=>ov(o)&&Ga(o.pipe),sEi=o=>{let p;return o&&(typeof FormData=="function"&&o instanceof FormData||Ga(o.append)&&((p=ZI(o))==="formdata"||p==="object"&&Ga(o.toString)&&o.toString()==="[object FormData]"))},lEi=Xl("URLSearchParams"),[oEi,dEi,uEi,pEi]=["ReadableStream","Request","Response","Headers"].map(Xl),cEi=o=>o.trim?o.trim():o.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function dv(o,p,{allOwnKeys:i=!1}={}){if(o===null||typeof o>"u")return;let n,s;if(typeof o!="object"&&(o=[o]),Mh(o))for(n=0,s=o.length;n<s;n++)p.call(null,o[n],n,o);else{if(lv(o))return;const c=i?Object.getOwnPropertyNames(o):Object.keys(o),e=c.length;let y;for(n=0;n<e;n++)y=c[n],p.call(null,o[y],y,o)}}function Dxe(o,p){if(lv(o))return null;p=p.toLowerCase();const i=Object.keys(o);let n=i.length,s;for(;n-- >0;)if(s=i[n],p===s.toLowerCase())return s;return null}const Ac=(()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global)(),wxe=o=>!wy(o)&&o!==Ac;function YO(){const{caseless:o,skipUndefined:p}=wxe(this)&&this||{},i={},n=(s,c)=>{const e=o&&Dxe(i,c)||c;Kb(i[e])&&Kb(s)?i[e]=YO(i[e],s):Kb(s)?i[e]=YO({},s):Mh(s)?i[e]=s.slice():(!p||!wy(s))&&(i[e]=s)};for(let s=0,c=arguments.length;s<c;s++)arguments[s]&&dv(arguments[s],n);return i}const fEi=(o,p,i,{allOwnKeys:n}={})=>(dv(p,(s,c)=>{i&&Ga(s)?o[c]=Axe(s,i):o[c]=s},{allOwnKeys:n}),o),yEi=o=>(o.charCodeAt(0)===65279&&(o=o.slice(1)),o),hEi=(o,p,i,n)=>{o.prototype=Object.create(p.prototype,n),o.prototype.constructor=o,Object.defineProperty(o,"super",{value:p.prototype}),i&&Object.assign(o.prototype,i)},mEi=(o,p,i,n)=>{let s,c,e;const y={};if(p=p||{},o==null)return p;do{for(s=Object.getOwnPropertyNames(o),c=s.length;c-- >0;)e=s[c],(!n||n(e,o,p))&&!y[e]&&(p[e]=o[e],y[e]=!0);o=i!==!1&&tN(o)}while(o&&(!i||i(o,p))&&o!==Object.prototype);return p},TEi=(o,p,i)=>{o=String(o),(i===void 0||i>o.length)&&(i=o.length),i-=p.length;const n=o.indexOf(p,i);return n!==-1&&n===i},vEi=o=>{if(!o)return null;if(Mh(o))return o;let p=o.length;if(!Rxe(p))return null;const i=new Array(p);for(;p-- >0;)i[p]=o[p];return i},EEi=(o=>p=>o&&p instanceof o)(typeof Uint8Array<"u"&&tN(Uint8Array)),bEi=(o,p)=>{const n=(o&&o[qI]).call(o);let s;for(;(s=n.next())&&!s.done;){const c=s.value;p.call(o,c[0],c[1])}},AEi=(o,p)=>{let i;const n=[];for(;(i=o.exec(p))!==null;)n.push(i);return n},gEi=Xl("HTMLFormElement"),IEi=o=>o.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(i,n,s){return n.toUpperCase()+s}),E4=(({hasOwnProperty:o})=>(p,i)=>o.call(p,i))(Object.prototype),REi=Xl("RegExp"),Oxe=(o,p)=>{const i=Object.getOwnPropertyDescriptors(o),n={};dv(i,(s,c)=>{let e;(e=p(s,c,o))!==!1&&(n[c]=e||s)}),Object.defineProperties(o,n)},DEi=o=>{Oxe(o,(p,i)=>{if(Ga(o)&&["arguments","caller","callee"].indexOf(i)!==-1)return!1;const n=o[i];if(Ga(n)){if(p.enumerable=!1,"writable"in p){p.writable=!1;return}p.set||(p.set=()=>{throw Error("Can not rewrite read-only method '"+i+"'")})}})},wEi=(o,p)=>{const i={},n=s=>{s.forEach(c=>{i[c]=!0})};return Mh(o)?n(o):n(String(o).split(p)),i},OEi=()=>{},CEi=(o,p)=>o!=null&&Number.isFinite(o=+o)?o:p;function _Ei(o){return!!(o&&Ga(o.append)&&o[gxe]==="FormData"&&o[qI])}const VEi=o=>{const p=new Array(10),i=(n,s)=>{if(ov(n)){if(p.indexOf(n)>=0)return;if(lv(n))return n;if(!("toJSON"in n)){p[s]=n;const c=Mh(n)?[]:{};return dv(n,(e,y)=>{const m=i(e,s+1);!wy(m)&&(c[y]=m)}),p[s]=void 0,c}}return n};return i(o,0)},PEi=Xl("AsyncFunction"),NEi=o=>o&&(ov(o)||Ga(o))&&Ga(o.then)&&Ga(o.catch),Cxe=((o,p)=>o?setImmediate:p?((i,n)=>(Ac.addEventListener("message",({source:s,data:c})=>{s===Ac&&c===i&&n.length&&n.shift()()},!1),s=>{n.push(s),Ac.postMessage(i,"*")}))(`axios@${Math.random()}`,[]):i=>setTimeout(i))(typeof setImmediate=="function",Ga(Ac.postMessage)),xEi=typeof queueMicrotask<"u"?queueMicrotask.bind(Ac):typeof process<"u"&&process.nextTick||Cxe,$Ei=o=>o!=null&&Ga(o[qI]),Ue={isArray:Mh,isArrayBuffer:Ixe,isBuffer:lv,isFormData:sEi,isArrayBufferView:Yvi,isString:Xvi,isNumber:Rxe,isBoolean:Qvi,isObject:ov,isPlainObject:Kb,isEmptyObject:eEi,isReadableStream:oEi,isRequest:dEi,isResponse:uEi,isHeaders:pEi,isUndefined:wy,isDate:tEi,isFile:iEi,isBlob:rEi,isRegExp:REi,isFunction:Ga,isStream:aEi,isURLSearchParams:lEi,isTypedArray:EEi,isFileList:nEi,forEach:dv,merge:YO,extend:fEi,trim:cEi,stripBOM:yEi,inherits:hEi,toFlatObject:mEi,kindOf:ZI,kindOfTest:Xl,endsWith:TEi,toArray:vEi,forEachEntry:bEi,matchAll:AEi,isHTMLForm:gEi,hasOwnProperty:E4,hasOwnProp:E4,reduceDescriptors:Oxe,freezeMethods:DEi,toObjectSet:wEi,toCamelCase:IEi,noop:OEi,toFiniteNumber:CEi,findKey:Dxe,global:Ac,isContextDefined:wxe,isSpecCompliantForm:_Ei,toJSONObject:VEi,isAsyncFn:PEi,isThenable:NEi,setImmediate:Cxe,asap:xEi,isIterable:$Ei};function ai(o,p,i,n,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=o,this.name="AxiosError",p&&(this.code=p),i&&(this.config=i),n&&(this.request=n),s&&(this.response=s,this.status=s.status?s.status:null)}Ue.inherits(ai,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Ue.toJSONObject(this.config),code:this.code,status:this.status}}});const _xe=ai.prototype,Vxe={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(o=>{Vxe[o]={value:o}});Object.defineProperties(ai,Vxe);Object.defineProperty(_xe,"isAxiosError",{value:!0});ai.from=(o,p,i,n,s,c)=>{const e=Object.create(_xe);Ue.toFlatObject(o,e,function(E){return E!==Error.prototype},v=>v!=="isAxiosError");const y=o&&o.message?o.message:"Error",m=p==null&&o?o.code:p;return ai.call(e,y,m,i,n,s),o&&e.cause==null&&Object.defineProperty(e,"cause",{value:o,configurable:!0}),e.name=o&&o.name||"Error",c&&Object.assign(e,c),e};const LEi=null;function XO(o){return Ue.isPlainObject(o)||Ue.isArray(o)}function Pxe(o){return Ue.endsWith(o,"[]")?o.slice(0,-2):o}function b4(o,p,i){return o?o.concat(p).map(function(s,c){return s=Pxe(s),!i&&c?"["+s+"]":s}).join(i?".":""):p}function MEi(o){return Ue.isArray(o)&&!o.some(XO)}const BEi=Ue.toFlatObject(Ue,{},null,function(p){return/^is[A-Z]/.test(p)});function WI(o,p,i){if(!Ue.isObject(o))throw new TypeError("target must be an object");p=p||new FormData,i=Ue.toFlatObject(i,{metaTokens:!0,dots:!1,indexes:!1},!1,function(L,k){return!Ue.isUndefined(k[L])});const n=i.metaTokens,s=i.visitor||E,c=i.dots,e=i.indexes,m=(i.Blob||typeof Blob<"u"&&Blob)&&Ue.isSpecCompliantForm(p);if(!Ue.isFunction(s))throw new TypeError("visitor must be a function");function v($){if($===null)return"";if(Ue.isDate($))return $.toISOString();if(Ue.isBoolean($))return $.toString();if(!m&&Ue.isBlob($))throw new ai("Blob is not supported. Use a Buffer instead.");return Ue.isArrayBuffer($)||Ue.isTypedArray($)?m&&typeof Blob=="function"?new Blob([$]):Buffer.from($):$}function E($,L,k){let K=$;if($&&!k&&typeof $=="object"){if(Ue.endsWith(L,"{}"))L=n?L:L.slice(0,-2),$=JSON.stringify($);else if(Ue.isArray($)&&MEi($)||(Ue.isFileList($)||Ue.endsWith(L,"[]"))&&(K=Ue.toArray($)))return L=Pxe(L),K.forEach(function(Y,re){!(Ue.isUndefined(Y)||Y===null)&&p.append(e===!0?b4([L],re,c):e===null?L:L+"[]",v(Y))}),!1}return XO($)?!0:(p.append(b4(k,L,c),v($)),!1)}const b=[],w=Object.assign(BEi,{defaultVisitor:E,convertValue:v,isVisitable:XO});function V($,L){if(!Ue.isUndefined($)){if(b.indexOf($)!==-1)throw Error("Circular reference detected in "+L.join("."));b.push($),Ue.forEach($,function(K,S){(!(Ue.isUndefined(K)||K===null)&&s.call(p,K,Ue.isString(S)?S.trim():S,L,w))===!0&&V(K,L?L.concat(S):[S])}),b.pop()}}if(!Ue.isObject(o))throw new TypeError("data must be an object");return V(o),p}function A4(o){const p={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(o).replace(/[!'()~]|%20|%00/g,function(n){return p[n]})}function iN(o,p){this._pairs=[],o&&WI(o,this,p)}const Nxe=iN.prototype;Nxe.append=function(p,i){this._pairs.push([p,i])};Nxe.toString=function(p){const i=p?function(n){return p.call(this,n,A4)}:A4;return this._pairs.map(function(s){return i(s[0])+"="+i(s[1])},"").join("&")};function GEi(o){return encodeURIComponent(o).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function xxe(o,p,i){if(!p)return o;const n=i&&i.encode||GEi;Ue.isFunction(i)&&(i={serialize:i});const s=i&&i.serialize;let c;if(s?c=s(p,i):c=Ue.isURLSearchParams(p)?p.toString():new iN(p,i).toString(n),c){const e=o.indexOf("#");e!==-1&&(o=o.slice(0,e)),o+=(o.indexOf("?")===-1?"?":"&")+c}return o}class kEi{constructor(){this.handlers=[]}use(p,i,n){return this.handlers.push({fulfilled:p,rejected:i,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(p){this.handlers[p]&&(this.handlers[p]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(p){Ue.forEach(this.handlers,function(n){n!==null&&p(n)})}}const g4=kEi,$xe={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},jEi=typeof URLSearchParams<"u"?URLSearchParams:iN,UEi=typeof FormData<"u"?FormData:null,KEi=typeof Blob<"u"?Blob:null,FEi={isBrowser:!0,classes:{URLSearchParams:jEi,FormData:UEi,Blob:KEi},protocols:["http","https","file","blob","url","data"]},rN=typeof window<"u"&&typeof document<"u",QO=typeof navigator=="object"&&navigator||void 0,SEi=rN&&(!QO||["ReactNative","NativeScript","NS"].indexOf(QO.product)<0),qEi=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),ZEi=rN&&window.location.href||"http://localhost",HEi=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:rN,hasStandardBrowserEnv:SEi,hasStandardBrowserWebWorkerEnv:qEi,navigator:QO,origin:ZEi},Symbol.toStringTag,{value:"Module"})),na={...HEi,...FEi};function WEi(o,p){return WI(o,new na.classes.URLSearchParams,{visitor:function(i,n,s,c){return na.isNode&&Ue.isBuffer(i)?(this.append(n,i.toString("base64")),!1):c.defaultVisitor.apply(this,arguments)},...p})}function zEi(o){return Ue.matchAll(/\w+|\[(\w*)]/g,o).map(p=>p[0]==="[]"?"":p[1]||p[0])}function JEi(o){const p={},i=Object.keys(o);let n;const s=i.length;let c;for(n=0;n<s;n++)c=i[n],p[c]=o[c];return p}function Lxe(o){function p(i,n,s,c){let e=i[c++];if(e==="__proto__")return!0;const y=Number.isFinite(+e),m=c>=i.length;return e=!e&&Ue.isArray(s)?s.length:e,m?(Ue.hasOwnProp(s,e)?s[e]=[s[e],n]:s[e]=n,!y):((!s[e]||!Ue.isObject(s[e]))&&(s[e]=[]),p(i,n,s[e],c)&&Ue.isArray(s[e])&&(s[e]=JEi(s[e])),!y)}if(Ue.isFormData(o)&&Ue.isFunction(o.entries)){const i={};return Ue.forEachEntry(o,(n,s)=>{p(zEi(n),s,i,0)}),i}return null}function YEi(o,p,i){if(Ue.isString(o))try{return(p||JSON.parse)(o),Ue.trim(o)}catch(n){if(n.name!=="SyntaxError")throw n}return(i||JSON.stringify)(o)}const nN={transitional:$xe,adapter:["xhr","http","fetch"],transformRequest:[function(p,i){const n=i.getContentType()||"",s=n.indexOf("application/json")>-1,c=Ue.isObject(p);if(c&&Ue.isHTMLForm(p)&&(p=new FormData(p)),Ue.isFormData(p))return s?JSON.stringify(Lxe(p)):p;if(Ue.isArrayBuffer(p)||Ue.isBuffer(p)||Ue.isStream(p)||Ue.isFile(p)||Ue.isBlob(p)||Ue.isReadableStream(p))return p;if(Ue.isArrayBufferView(p))return p.buffer;if(Ue.isURLSearchParams(p))return i.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),p.toString();let y;if(c){if(n.indexOf("application/x-www-form-urlencoded")>-1)return WEi(p,this.formSerializer).toString();if((y=Ue.isFileList(p))||n.indexOf("multipart/form-data")>-1){const m=this.env&&this.env.FormData;return WI(y?{"files[]":p}:p,m&&new m,this.formSerializer)}}return c||s?(i.setContentType("application/json",!1),YEi(p)):p}],transformResponse:[function(p){const i=this.transitional||nN.transitional,n=i&&i.forcedJSONParsing,s=this.responseType==="json";if(Ue.isResponse(p)||Ue.isReadableStream(p))return p;if(p&&Ue.isString(p)&&(n&&!this.responseType||s)){const e=!(i&&i.silentJSONParsing)&&s;try{return JSON.parse(p,this.parseReviver)}catch(y){if(e)throw y.name==="SyntaxError"?ai.from(y,ai.ERR_BAD_RESPONSE,this,null,this.response):y}}return p}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:na.classes.FormData,Blob:na.classes.Blob},validateStatus:function(p){return p>=200&&p<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Ue.forEach(["delete","get","head","post","put","patch"],o=>{nN.headers[o]={}});const aN=nN,XEi=Ue.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),QEi=o=>{const p={};let i,n,s;return o&&o.split(`
|
|
87
|
+
This is likely an incorrect strategy, either the '${this.type}' entity doesn't need to be updated or it should be deleted and a new one created in the desired parent.`})),{errors:n,modifiedData:i}}subscribeDependents(i){return i.forEach(n=>{this.detachedDependents[n.entity.id]||(this.detachedDependents[n.entity.id]=n)}),this}unsubscribeDependents(i){return i.forEach(n=>{this.detachedDependents[n.entity.id]&&delete this.detachedDependents[n.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"sync-dependents"))){const n=[],s=[],c=[],e=[];return Object.values(this.detachedDependents).forEach(y=>{const m=y.entity.afterAllChildrenInitialized(i);n.push(...m.updated),s.push(...m.added),c.push(...m.removed),e.push(...m.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}onDetachedDependencyRemoved(i,n,s){const c=[],e=[],y=[],m=[];return n==="value-as-type-single"&&(this.valueAsTypeSingle=null,s==null||s.add(this,H.Updated)),n==="value-as-type-list"&&(this.valueAsTypeList=(this.valueAsTypeList||[]).filter(v=>v.id!==i.id),s==null||s.add(this,H.Updated)),{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:this}}onDetachedDependencyRestored(i,n,s){const c=[],e=[],y=[],m=[];return n==="value-as-type-single"&&(this.valueAsTypeSingle=i,s==null||s.add(this,H.Updated)),n==="value-as-type-list"&&(this.valueAsTypeList=[...Array.isArray(this.valueAsTypeList||[])?this.valueAsTypeList:[],i],s==null||s.add(this,H.Updated)),{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:this}}unsubscribeFromDependencies(){return this.valueAsTypeSingle&&this.valueAsTypeSingle.type!==d.BuiltInBaseEntity&&this.valueAsTypeSingle.unsubscribeDependents([{entity:this,field:"value-as-type-single"}]),this.valueAsTypeList&&Array.isArray(this.valueAsTypeList)&&this.valueAsTypeList.forEach(i=>{i.type!==d.BuiltInBaseEntity&&i.unsubscribeDependents([{entity:this,field:"value-as-type-list"}])}),this}subscribeToDependencies(){return!this.valueAsTypeSingle&&!this.valueAsTypeList?this:(this.valueAsTypeList&&Array.isArray(this.valueAsTypeList)?this.valueAsTypeList.forEach(i=>{i.type!==d.BuiltInBaseEntity&&i.subscribeDependents([{entity:this,field:"value-as-type-list"}])}):this.valueAsTypeSingle&&this.valueAsTypeSingle.type!==d.BuiltInBaseEntity&&this.valueAsTypeSingle.subscribeDependents([{entity:this,field:"value-as-type-single"}]),this)}increaseVersion(i){if(i&&!M(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&M(i).isSame(M(this.createdAt))?this:(this.previousVersion=this.version,this.version=x.UUID.uuid(),this.createdAt=M(i).toISOString()||M().toISOString(),this)}captureVersion(){var n;const i=((n=this.knownVersions)==null?void 0:n.get(this.version))||new yi(this,this.project);return i.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map([[this.version,i]]),i.valueAsTypeSingle=this.valueAsTypeSingle,i.valueAsTypeList=this.valueAsTypeList?[...this.valueAsTypeList]:this.valueAsTypeList,i.parent=this.parent,this}recursiveCaptureUpstreamVersions(i){const n=[],s=[],c=[],e=[];if(this.parent){this.parent.increaseVersion(i);const y=this.parent.recursiveCaptureUpstreamVersions(i);n.push(this.parent,...y.updated),s.push(...y.added),c.push(...y.removed)}return{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}async restoreVersion(i){var m;const n=[],s=[],c=[],e=[];if(this.version===i)return{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this};if(!this.knownVersions){const v=new Map;for(const[E,b]of this.knownVersions||new Map){if(v.set(E,b),b.activeVersion=!1,b.knownVersions)for(const[w,V]of b.knownVersions)v.set(w,V);b.knownVersions=null}}let y=(m=this.knownVersions)==null?void 0:m.get(i);if(!y){const v=await this.APILoadVersion({},i);if(!v)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);y=new yi(v,this.project)}return this.metaSync(y.toShallowJSON(),null),this.previousVersion=y.previousVersion,this.version=y.version,this.createdAt=y.createdAt,this.author=y.author,this.deleted=y.deleted,this.valueAsTypeSingle=y.valueAsTypeSingle,this.parent=y.parent,{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}updateWithShallowTransfer(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.UpdateWithShallowTransfer))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[updateWithShallowTransfer] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),this;if(this.metaSync(i,n),this.version=i.version,this.createdAt=i.createdAt,this.author=i.author,this.deleted=i.deleted,this.previousVersion=i.previousVersion,i.parent&&i.standaloneParent)throw new Error(`Entity with id '${this.id}' cannot have both 'parent' and 'standaloneParent' properties set.`);if(i.parent){const s=ne(i.parent),c=this.project.get(s),e=this.parent;if(e&&e.id!==(c==null?void 0:c.id)&&this.removeFromParent(n),c)this.setParent(c,n),this.addSelfToProject(n);else throw new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${s}' that isn't found in the project`)}else if(i.standaloneParent){const s=ne(i.standaloneParent),c=this.project.get(s);if(c)this.setStandaloneParent(c,n);else throw new Error(`${this.type} with id '${this.id}' has a 'standaloneParent' reference '${s}' that isn't found in the project`)}else throw new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(i.valueAsTypeList&&Array.isArray(i.valueAsTypeList))this.valueAsTypeList=this.valueAsTypeList||[],i.valueAsTypeList.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&this.addValueAsTypeToList(e,n)}),[...this.valueAsTypeList].forEach(s=>{(i.valueAsTypeList||[]).find(e=>ne(e)===s.id)||this.removeValueAsTypeFromList(s,n)}),this.setValueAsTypeSingle(null,n),this.metaSync({value:null},n);else if(i.valueAsTypeSingle){const s=ne(i.valueAsTypeSingle),c=this.project.get(s);c&&(this.setValueAsTypeSingle(c,n),this.setValueAsTypeList(null,n),this.metaSync({value:null},n))}else this.setValueAsTypeSingle(null,n),this.setValueAsTypeList(null,n);return this.captureVersion(),this.subscribeToDependencies(),n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),this}hydrateAncestors(){const i=[],n=[],s=[],c=[];if(this.initialData.parent&&this.initialData.standaloneParent)throw new Error(`Entity with id '${this.id}' cannot have both 'parent' and 'standaloneParent' properties set.`);if(this.initialData.parent){const e=ne(this.initialData.parent),y=this.project.get(e);if(J.Logger.log(`[LiteralValueState.hydrateAncestors] Hydrating parent reference '${e}' for entity with id '${this.id}'`),y)J.Logger.log(`[LiteralValueState.hydrateAncestors] Setting parent reference '${y.id}' for entity with id '${this.id}'`),this.setParent(y,null),i.push(y);else throw J.Logger.error(`[LiteralValueState.hydrateAncestors] Parent reference '${e}' for entity with id '${this.id}' not found in the project`),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${e}' that isn't found in the project`)}else if(this.initialData.standaloneParent){const e=ne(this.initialData.standaloneParent),y=this.project.get(e);if(J.Logger.log(`[LiteralValueState.hydrateAncestors] Hydrating standalone parent reference '${e}' for entity with id '${this.id}'`),y)J.Logger.log(`[LiteralValueState.hydrateAncestors] Setting standalone parent reference '${y.id}' for entity with id '${this.id}'`),this.setStandaloneParent(y,null);else throw J.Logger.error(`[LiteralValueState.hydrateAncestors] Standalone parent reference '${e}' for entity with id '${this.id}' not found in the project`),new Error(`${this.type} with id '${this.id}' has a 'standaloneParent' reference '${e}' that isn't found in the project`)}else throw J.Logger.error(`[LiteralValueState.hydrateAncestors] Entity with id '${this.id}' must have a 'parent'`),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(this.initialData.valueAsTypeList&&Array.isArray(this.initialData.valueAsTypeList))this.valueAsTypeList=this.valueAsTypeList||[],this.initialData.valueAsTypeList.forEach(e=>{const y=ne(e),m=this.project.get(y);m&&this.valueAsTypeList.push(m)});else if(this.initialData.valueAsTypeSingle){const e=ne(this.initialData.valueAsTypeSingle),y=this.project.get(e);y&&(this.valueAsTypeSingle=y)}return{updated:D(i),added:D(n),removed:D(s),affected:D(c),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AfterAllChildrenInitialized))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[afterAllChildrenInitialized] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.AfterAllChildrenInitialized,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];return this.initialized=!0,this.captureVersion(),i==null||i.attemptAutoclose(_.AfterAllChildrenInitialized,this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}addSelfToProject(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"add-self-to-project"))){var y,m;const n=[this],s=[],c=[],e=[];return((y=this.parent)==null?void 0:y.type)===d.DataType?this.parent.setEntity(this,i):(m=this.parent)==null||m.setDefaultValue(this,i),e.push(this.parent),this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}setParent(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetParent))){var s;return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.SetParent,n)?(((s=this.parent)==null?void 0:s.id)!==(i==null?void 0:i.id)&&(this.parent=i,n&&(n==null||n.add(this,H.Updated))),n==null||n.attemptAutoclose(_.SetParent,this.id),this):this}setStandaloneParent(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetStandaloneParent))){var s;return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.SetStandaloneParent,n)?(((s=this.standaloneParent)==null?void 0:s.id)!==(i==null?void 0:i.id)&&(this.standaloneParent=i,n&&(n==null||n.add(this,H.Updated))),n==null||n.attemptAutoclose(_.SetStandaloneParent,this.id),this):this}addValueAsTypeToList(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddValueAsTypeToList))){return this.checkCanEdit(this,n)?((this.valueAsTypeList||[]).includes(i)||(this.valueAsTypeList=this.valueAsTypeList||[],this.valueAsTypeList.push(i),this.value!==null&&this.metaSync({value:null},n),this.valueAsTypeSingle!==null&&(this.valueAsTypeSingle=null,n==null||n.add(this,H.Updated)),n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose(_.AddValueAsTypeToList,this.id),this):(J.Logger.warn(`[addValueAsTypeToList] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.AddValueAsTypeToList,this.id),this)}removeValueAsTypeFromList(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveValueAsTypeFromList))){return this.checkCanEdit(this,n)?(this.valueAsTypeList&&Array.isArray(this.valueAsTypeList)&&(this.valueAsTypeList||[]).includes(i)&&(this.valueAsTypeList=this.valueAsTypeList.filter(s=>s.id!==i.id),this.valueAsTypeList.length===0?this.valueAsTypeList=null:(this.value!==null&&this.metaSync({value:null},n),this.valueAsTypeSingle!==null&&(this.valueAsTypeSingle=null,n==null||n.add(this,H.Updated))),n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose(_.RemoveValueAsTypeFromList,this.id),this):(J.Logger.warn(`[removeValueAsTypeFromList] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.RemoveValueAsTypeFromList,this.id),this)}setValueAsTypeSingle(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetValueAsTypeSingle))){return this.checkCanEdit(this,n)?(this.valueAsTypeSingle!==i&&(this.valueAsTypeSingle=i,n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose(_.SetValueAsTypeSingle,this.id),this):(J.Logger.warn(`[setValueAsTypeSingle] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.SetValueAsTypeSingle,this.id),this)}setValueAsTypeList(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetValueAsTypeList))){var s,c;return this.checkCanEdit(this,n)?(!i&&this.valueAsTypeList?(this.valueAsTypeList=null,n==null||n.add(this,H.Updated)):i&&!this.valueAsTypeList?(this.valueAsTypeList=i,n==null||n.add(this,H.Updated)):i&&this.valueAsTypeList&&((s=this.valueAsTypeList)==null?void 0:s.length)!==i.length?(this.valueAsTypeList=i,n==null||n.add(this,H.Updated)):i&&this.valueAsTypeList&&((c=this.valueAsTypeList)!=null&&c.every((e,y)=>e!==i[y]))&&(this.valueAsTypeList=i,n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose(_.SetValueAsTypeList,this.id),this):(J.Logger.warn(`[setValueAsTypeList] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.SetValueAsTypeList,this.id),this)}setValueAsType(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetValueAsType))){return this.checkCanEdit(this,n)?i?(Array.isArray(i)?this.setValueAsTypeList(i,n):this.setValueAsTypeSingle(i,n),n==null||n.attemptAutoclose(_.SetValueAsType,this.id),this):(this.setValueAsTypeSingle(null,n),this.setValueAsTypeList(null,n),this):(J.Logger.warn(`[setValueAsType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.SetValueAsType,this.id),this)}initChildren(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"init-children"))){if(this.initialized||this.startedInitialization)return this;if(this.startedInitialization=!0,this.standalone){if(this.initialData.valueAsTypeList&&Array.isArray(this.initialData.valueAsTypeList))this.valueAsTypeList=this.initialData.valueAsTypeList.map(n=>{if(n.type===d.GenericReference){const c=this.project.findSubscribedBuiltInInstanceFromReference(n);if(!c)throw new Error(`Standalone entity of type '${this.type}' with id '${this.id}' has a reference to an entity of type '${n.entityType}' with id '${n.entityId}' that is not part of the project state.`);return c}const s=this.project.get(n.id);if(!s)throw new Error(`Standalone entity of type '${this.type}' with id '${this.id}' has a reference to an entity of type '${n.type}' with id '${n.id}' that is not part of the project state.`);return s});else if(this.initialData.valueAsTypeSingle){if(this.initialData.valueAsTypeSingle.type===d.GenericReference){const s=this.project.findSubscribedBuiltInInstanceFromReference(this.initialData.valueAsTypeSingle);if(!s)throw new Error(`Standalone entity of type '${this.type}' with id '${this.id}' has a reference to an entity of type '${this.initialData.valueAsTypeSingle.entityType}' with id '${this.initialData.valueAsTypeSingle.entityId}' that is not part of the project state.`);return this.valueAsTypeSingle=s,this}const n=this.project.get(this.initialData.valueAsTypeSingle.id);if(!n)throw new Error(`Standalone entity of type '${this.type}' with id '${this.id}' has a reference to an entity of type '${this.initialData.valueAsTypeSingle.type}' with id '${this.initialData.valueAsTypeSingle.id}' that is not part of the project state.`);this.valueAsTypeSingle=n}return this}if(this.initialData.valueAsTypeList&&Array.isArray(this.initialData.valueAsTypeList))this.valueAsTypeList=this.initialData.valueAsTypeList.map(n=>{if(n.type===d.GenericReference){const c=this.project.findSubscribedBuiltInInstanceFromReference(n);if(!c)throw new Error(`Standalone entity of type '${this.type}' with id '${this.id}' has a reference to an entity of type '${n.entityType}' with id '${n.entityId}' that is not part of the project state.`);return c}const s=this.project.get(n.id);if(!s)throw new Error(`Standalone entity of type '${this.type}' with id '${this.id}' has a reference to an entity of type '${n.type}' with id '${n.id}' that is not part of the project state.`);return s});else if(this.initialData.valueAsTypeSingle){if(this.initialData.valueAsTypeSingle.type===d.GenericReference){const s=ne(this.initialData.valueAsTypeSingle),c=s?this.project.get(s):null;if(!c)throw new Error(`Standalone entity of type '${this.type}' with id '${this.id}' has a reference to an entity of type '${this.initialData.valueAsTypeSingle.entityType}' with id '${this.initialData.valueAsTypeSingle.entityId}' that is not part of the project state.`);return this.valueAsTypeSingle=c,this}const n=this.project.get(this.initialData.valueAsTypeSingle.id);if(!n)throw new Error(`Standalone entity of type '${this.type}' with id '${this.id}' has a reference to an entity of type '${this.initialData.valueAsTypeSingle.type}' with id '${this.initialData.valueAsTypeSingle.id}' that is not part of the project state.`);this.valueAsTypeSingle=n}return this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this}subscribe(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"meta-sync"))){const s=Mr(this,i,n),c=Lr(this,s),e=this.toMeta();return this.name=s.name!==void 0?s.name:e.name,this.autogeneration=s.autogeneration!==void 0?s.autogeneration:e.autogeneration,this.value=s.value!==void 0?s.value:e.value,super.baseMetaSync(s,this,n),s.deleted===!0&&!e.deleted?n==null||n.add(this,H.Removed):s.deleted===!1&&e.deleted?n==null||n.add(this,H.Added):c&&(n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=ke,...n){return await yi.repository.APILoad(this.id,...n),this}async APICreate(i=ke,...n){return await yi.repository.APICreate(this.toShallowJSON(),...n),this}async APIUpdate(i=ke,...n){return await yi.repository.APIUpdate(this.toShallowJSON(),...n),this}async APIDelete(i=ke,...n){return await yi.repository.APIDelete(this.toShallowJSON(),...n),this}async APIClone(i=ke,...n){return await yi.repository.APIClone(this.id,...n),this}async APILoadVersion(i=ke,n,...s){return await yi.repository.APILoadVersion(this.id,n,...s)}removeFromParent(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveFromParent))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[removeFromParent] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveFromParent,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];return this.parent&&(this.parent.type===d.DataType?this.parent.setEntity(null,i):kA.includes(this.parent.type)&&this.parent.setDefaultValue(null,i),e.push(this.parent)),i==null||i.attemptAutoclose(_.RemoveFromParent,this.id),{added:D(c),updated:D(n),removed:D(s),affected:D(e),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveEntity))){var m;if(!this.checkCanDelete(this,n))return J.Logger.warn(`[remove] User is not allowed to delete or edit this ${this.type} entity with id: ${this.id}`),n==null||n.event({id:`${_.RemoveEntity}-${this.id}`,action:_.RemoveEntity,owner:this,errorReason:Ii.ActionOwnerEntityNonDeletable,rootAction:((m=n==null?void 0:n.self)==null?void 0:m.id)===this.id&&(n==null?void 0:n.autoCloseActionName)===_.RemoveEntity}),n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const s=[],c=[],e=[],y=[];if(n!=null&&n.hasRemoved(this.id))return n==null||n.attemptAutoclose(_.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},n),Object.values(this.detachedDependents).forEach(v=>{const{updated:E,removed:b,added:w}=v.entity.onDetachedDependencyRemoved(this,v.field,n);s.push(...E),c.push(...b),e.push(...w)}),!i){const v=this.removeFromParent(n);e.push(...v.added),s.push(...v.updated),c.push(...v.removed),y.push(...v.affected)}return n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:D(e),updated:D(s),removed:D(c),affected:D(y),self:this}}restore({}={},i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RestoreEntity))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[restore] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];return i!=null&&i.hasAdded(this.id)?(i==null||i.attemptAutoclose(_.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(y=>{const{updated:m,removed:v,added:E}=y.entity.onDetachedDependencyRestored(this,y.field,i);s.push(...m),c.push(...v),n.push(...E)}),i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this})}toFlat(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this,...this.valueAsTypeSingle?this.valueAsTypeSingle.toFlat(i):[],...this.valueAsTypeList&&Array.isArray(this.valueAsTypeList)?this.valueAsTypeList.flatMap(s=>s.toFlat(i)):[]])}toFlatIds(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.valueAsTypeSingle?this.valueAsTypeSingle.toFlatIds(i):[],...this.valueAsTypeList&&Array.isArray(this.valueAsTypeList)?this.valueAsTypeList.flatMap(s=>s.toFlatIds(i)):[]])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,value:this.value,autogeneration:this.autogeneration,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name}}toJSON(i=new Set){var n,s,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,autogeneration:this.autogeneration,value:this.value,valueAsTypeSingle:((n=this.valueAsTypeSingle)==null?void 0:n.toJSON(i))||null,valueAsTypeList:Array.isArray(this.valueAsTypeSingle)?this.valueAsTypeSingle.map(e=>e.toJSON(i)):null,parent:(s=this.parent)==null?void 0:s.toReference(),standaloneParent:(c=this.standaloneParent)==null?void 0:c.toReference()})}toJSONClone(i=ct){var s,c,e,y,m,v,E;let n;return(s=i.seenEntityMaps)!=null&&s.has(this.id)?n=i.seenEntityMaps.get(this.id):(n=i.newId||jr(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,n)),(c=i.seenEntities)!=null&&c.has(n)||(e=i.seenEntities)!=null&&e.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((y=i.seenEntities)==null||y.add(n),(m=i.seenEntities)==null||m.add(this.id),{id:n,version:x.UUID.uuid(),createdAt:i.timestamp||M().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name,autogeneration:this.autogeneration,value:this.value,valueAsTypeSingle:this.valueAsTypeSingle?this.project.getBuiltIn(this.valueAsTypeSingle.id)?this.valueAsTypeSingle.toJSON():this.valueAsTypeSingle.toJSONClone({...i,newId:null}):null,valueAsTypeList:this.valueAsTypeSingle&&Array.isArray(this.valueAsTypeSingle)?this.valueAsTypeSingle.map(b=>this.project.getBuiltIn(b.id)?b.toJSON(i.seenEntities):b.toJSONClone({...i,newId:null})):null,parent:(v=this.parent)==null?void 0:v.toReference({seenEntityMaps:i.seenEntityMaps}),standaloneParent:(E=this.standaloneParent)==null?void 0:E.toReference({seenEntityMaps:i.seenEntityMaps})})}toReference(i=ct){var s;let n=this.id;return(s=i.seenEntityMaps)!=null&&s.has(this.id)&&(n=i.seenEntityMaps.get(this.id)),{id:n+"--"+x.UUID.uuid()+"--ref",type:d.GenericReference,entityId:n,version:this.version,entityType:this.type}}toShallowJSON(i=ct){var s,c,e,y;let n=this.id;return(s=i.seenEntityMaps)!=null&&s.has(this.id)&&(n=i.seenEntityMaps.get(this.id)),{id:n,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,valueAsTypeSingle:((c=this.valueAsTypeSingle)==null?void 0:c.toReference(i))||null,valueAsTypeList:Array.isArray(this.valueAsTypeSingle)?this.valueAsTypeSingle.map(m=>m.toReference(i)):null,value:this.value,autogeneration:this.autogeneration,parent:(e=this.parent)==null?void 0:e.toReference(i),standaloneParent:(y=this.standaloneParent)==null?void 0:y.toReference(i)}}toFlatJSON(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...this.valueAsTypeSingle?this.valueAsTypeSingle.toFlatJSON(i):[],...this.valueAsTypeList&&Array.isArray(this.valueAsTypeList)?this.valueAsTypeList.flatMap(s=>s.toFlatJSON(i)):[]])}toGenerationTarget(){var i,n,s;return{id:this.id,type:this.type,name:this.name,valueAsTypeSingle:((i=this.valueAsTypeSingle)==null?void 0:i.id)||null,valueAsTypeList:Array.isArray(this.valueAsTypeSingle)?this.valueAsTypeSingle.map(c=>c.id):null,value:this.value,autogeneration:this.autogeneration,parent:(n=this.parent)==null?void 0:n.id,standaloneParent:(s=this.standaloneParent)==null?void 0:s.id}}toFlatGenerationTarget(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...this.valueAsTypeSingle?this.valueAsTypeSingle.toFlatGenerationTarget(i):[],...this.valueAsTypeList&&Array.isArray(this.valueAsTypeList)?this.valueAsTypeList.flatMap(s=>s.toFlatGenerationTarget(i)):[]])}clearErrors(){return this.errors=[],this}validate(){return this.errors=pOe(this),{success:!0}}async validateAsync(i={}){const n=J.YieldTracker.from(i);return this.errors=await uOe(this,{tracker:n}),{success:!0}}getErrors(){return[...this.errors]}async getErrorsAsync(i={}){const n=J.YieldTracker.from(i),s=[...this.errors];return await n.tick(),s}getShallowErrors(){return this.errors}clone(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.CloneEntity)),n=null,s=null,c=!0){const e=Rr(n,this),y=this.toJSON(),m=s||x.UUID.uuid();y.id=m,y.version=x.UUID.uuid(),y.createdAt=(i==null?void 0:i.timestamp)||M().toISOString(),y.author=(i==null?void 0:i.author)||"1",y.previousVersion=null,y.deleted=!1,y.editable=!0,y.deletable=!0;const v=Si(y,e);return v.hydrateAncestors(),n&&v.setParent(n,i),c&&(v.subscribe(),v.addSelfToProject(i)),i==null||i.add(v,H.Added),v.initChildren(i),i==null||i.attemptAutoclose(_.CloneEntity,this.id),v}merge(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"merge-literal-value"))){const s=[],c=[],e=[],y=[];return this.valueAsTypeSingle!==(i==null?void 0:i.valueAsTypeSingle)&&(this.setValueAsType(i.valueAsTypeSingle,n),s.push(this)),this.valueAsTypeList!==i.valueAsTypeList&&(this.setValueAsTypeList(i.valueAsTypeList,n),s.push(this)),this.value!==i.value&&(this.metaSync({value:i.value},n),s.push(this)),this.autogeneration!==i.autogeneration&&(this.metaSync({autogeneration:i.autogeneration},n),s.push(this)),this.name!==i.name&&(this.metaSync({name:i.name},n),s.push(this)),n==null||n.attemptAutoclose("merge-literal-value",this.id),{updated:D(s),added:D(c),removed:D(e),affected:D(y),self:this}}};I(yi,"repository",{APICreate:async(i,...n)=>i,APIUpdate:async(i,...n)=>i,APIDelete:async(i,...n)=>i,APIClone:async(i,...n)=>{},APILoad:async(i,...n)=>null,APILoadVersion:async(i,n,...s)=>null}),I(yi,"type",d.LiteralValue),I(yi,"USER_MANAGED_PARENT_TYPES",[d.DataType,d.InputMap,d.Property,d.ArgumentDeclaration,d.ReturnStatement,d.BreakStatement,d.ContinueStatement,d.VariableDeclaration,d.VariableInstance,d.ValueDescriptor,d.OutputMap]),I(yi,"PARENT_TYPES",[...yi.USER_MANAGED_PARENT_TYPES]),I(yi,"MUTABLE_BASE_PROPERTIES",["name","autogeneration","value"]),I(yi,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),I(yi,"BASE_PROPERTIES",[...yi.MUTABLE_BASE_PROPERTIES,...yi.INMUTABLE_BASE_PROPERTIES]),I(yi,"MUTABLE_META_PROPERTIES",[...yi.MUTABLE_BASE_PROPERTIES]),I(yi,"INMUTABLE_META_PROPERTIES",[...yi.INMUTABLE_BASE_PROPERTIES]),I(yi,"META_PROPERTIES",[...yi.MUTABLE_META_PROPERTIES,...yi.INMUTABLE_META_PROPERTIES]),I(yi,"MUTABLE_UPSTREAM_PROPERTIES",[]),I(yi,"INMUTABLE_UPSTREAM_PROPERTIES",["parent"]),I(yi,"UPSTREAM_PROPERTIES",[...yi.MUTABLE_UPSTREAM_PROPERTIES,...yi.INMUTABLE_UPSTREAM_PROPERTIES]),I(yi,"MUTABLE_DOWNSTREAM_PROPERTIES",["valueAsTypeSingle","valueAsTypeList"]),I(yi,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),I(yi,"DOWNSTREAM_PROPERTIES",[...yi.MUTABLE_DOWNSTREAM_PROPERTIES,...yi.INMUTABLE_DOWNSTREAM_PROPERTIES]),I(yi,"PROPERTIES",[...yi.META_PROPERTIES,...yi.UPSTREAM_PROPERTIES,...yi.DOWNSTREAM_PROPERTIES]);let Yr=yi;function ef(o){if(typeof crypto<"u"&&typeof crypto.getRandomValues=="function"){const i=new Uint8Array(o);return crypto.getRandomValues(i),i}const{randomBytes:p}=require("crypto");return p(o)}function fOe(o,p){const i=p-o+1,s=KI()*i;return Math.floor(s)+o}function yOe(){const o=ef(4);return(o[0]<<24|o[1]<<16|o[2]<<8|o[3])>>>0}function KI(){return yOe()/2**32}function GP(o){const p=ef(o);return Array.from(p).map(i=>i.toString(16).padStart(2,"0")).join("")}const ZO="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";function kP(o){let p="";const i=ef(o);for(let n=0;n<o;n++)p+=ZO[i[n]%ZO.length];return p}function hOe(o){const p=ef(o);let i;if(typeof Buffer<"u")i=Buffer.from(p).toString("base64");else{const n=String.fromCharCode(...p);i=btoa(n)}return i.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function jP(o){return kP(o)}function UP(o,p=ZO){let i="";const n=ef(o);for(let s=0;s<o;s++)i+=p[n[s]%p.length];return i}function Du(){const o=ef(16);o[6]=o[6]&15|64,o[8]=o[8]&63|128;const p=Array.from(o).map(i=>i.toString(16).padStart(2,"0")).join("");return[p.slice(0,8),p.slice(8,12),p.slice(12,16),p.slice(16,20),p.slice(20,32)].join("-")}function mOe(){return UP(6)}function TOe(){return GP(32)}const rvi=63,nvi=/^[a-z][a-z0-9-]*[a-z0-9]$/;function avi(o){return o.length>=1&&o.length<=rvi&&nvi.test(o)&&!o.includes("--")}function*svi(){yield"";const o="abcdefghijklmnopqrstuvwxyz";for(let p=1;;p++){const i=new Array(p).fill(0);let n=!1;for(;!n;){yield i.map(s=>o[s]).join("");for(let s=p-1;s>=0&&(i[s]++,!(i[s]<o.length));s--)i[s]=0,s===0&&(n=!0)}}}function lvi(o,p){const i=new Set(o.map(s=>s.toLowerCase())),n=p>0?"secondary-db":"main";for(const s of svi()){const c=s?`${n}-${s}`:n;if(avi(c)&&!i.has(c))return c}throw new Error("Unable to generate identifier")}function vOe(o,p){switch(o.id){case Q["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.id:{const i=o.project.entities.filter(m=>!!m.implements.find(v=>v.id===Q["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id)),n=i.find(m=>{const v=m.properties.find(w=>w.implements.find(V=>V.id===Q["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id)),E=v==null?void 0:v.getDefaultValue();return(E==null?void 0:E.value)===!0});if(!n&&i.length){const v=i[0].properties.find(b=>b.implements.find(w=>w.id===Q["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id)),E=v==null?void 0:v.defaultValue;if(E)E.metaSync({value:!0},p);else if(v!=null&&v.dataType){const b={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(p==null?void 0:p.timestamp)||new Date().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.LiteralValue,standaloneParent:null,name:oe.EntityTemplate,autogeneration:null,value:!0,valueAsTypeSingle:null,valueAsTypeList:null,parent:v==null?void 0:v.toReference()},w=me(b,o.project);return w.setParent(v,p),w.initChildren(p),p==null||p.add(w,H.Added),w.addSelfToProject(p),{newEntities:[w]}}return{newEntities:[]}}else if(n)return{newEntities:[]};const s=o.project.get(Q["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id),c=FI(s,"Main database",p);if(c.errors.length>0)return{newEntities:[]};const e=c.properties.find(m=>m.implements.find(v=>v.id===Q["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id)),y=e==null?void 0:e.defaultValue;if(y)y.metaSync({value:!0},p);else if(e!=null&&e.dataType){const m={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(p==null?void 0:p.timestamp)||new Date().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.LiteralValue,standaloneParent:null,name:oe.EntityTemplate,autogeneration:null,value:!0,valueAsTypeSingle:null,valueAsTypeList:null,parent:e==null?void 0:e.toReference()},v=me(m,o.project);v.setParent(e,p),v.initChildren(p),p==null||p.add(v,H.Added),v.addSelfToProject(p)}return{newEntities:[c]}}}return{newEntities:[]}}function EOe(o,p){const i=[],n=[],s=[],c=[];return o.implements.filter(y=>y.type===d.BuiltInBaseEntity).forEach(y=>{var m,v,E,b,w;switch(y.id){case Q["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.id:{const V=o.project.entities.filter(S=>S.implements.find(Y=>Y.id===Q["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id));let $=V.find(S=>!!S.properties.find(Y=>{var re;return Y.implements.find(ee=>ee.id===Q["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id)&&((re=Y.getDefaultValue())==null?void 0:re.value)===!0}));if(!$&&V.length)$=V[0];else if(!$&&!V.length){$=o.project.getBuiltIn(Q["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id).implement("Relational database",p);const Y=$.properties.find(re=>re.implements.find(ee=>ee.id===Q["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id));(m=Y==null?void 0:Y.defaultValue)==null||m.metaSync({value:!0},p),n.push($)}const L=o.properties.find(S=>S.implements.find(Y=>Y.id===Q["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.properties.database.id));if(L&&!(L!=null&&L.defaultValue)){const S={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(p==null?void 0:p.timestamp)||new Date().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.LiteralValue,standaloneParent:null,name:oe.EntityTemplate,autogeneration:null,value:null,valueAsTypeSingle:($==null?void 0:$.toJSON())||null,valueAsTypeList:null,parent:L==null?void 0:L.toReference()},Y=me(S,o.project);Y.hydrateAncestors(),Y.setParent(L,p),Y.addSelfToProject(p),p==null||p.add(Y,H.Added),Y.initChildren(p),(L==null?void 0:L.defaultValue).setValueAsTypeSingle($||null,p),n.push(Y);return}else L!=null&&L.defaultValue&&!(L!=null&&L.defaultValue.valueAsTypeSingle)&&(L==null||L.defaultValue.setValueAsTypeSingle($||null,p));const k=o.properties.find(S=>S.implements.find(Y=>Y.id===Q["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.properties.primaryKey.id));if(!k)throw new Error(`[handleAfterEntityImplementationSideEffects] Primary key property not found for implemented base entity ${Q["built-in-base-entity"]}`);if(!k.dataType){const S=ur.new(p);S.parent=k.toReference();const Y=me(S,o.project);Y.hydrateAncestors(),Y.setParent(k,p),Y.addSelfToProject(p),p==null||p.add(Y,H.Added),Y.initChildren(p)}const K=o.project.getBuiltIn(Q["primitive-entity"].number.id);(v=k.dataType)==null||v.setEntity(K,p);return}case Q["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id:{const V=o.project.entities.filter(re=>re.implements.find(ee=>ee.id===Q["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id)&&re.id!==o.id),$=V.map(re=>{var le;const ee=re.properties.find(fe=>fe.implements.find(ve=>ve.id===Q["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.identifier.id));return(le=ee==null?void 0:ee.getDefaultValue())==null?void 0:le.value}).filter(re=>!!re),L=o.properties.find(re=>re.implements.find(ee=>ee.id===Q["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.identifier.id));if(!V.find(re=>!!re.properties.find(ee=>{var de;return ee.implements.find(le=>le.id===Q["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id)&&((de=ee.getDefaultValue())==null?void 0:de.value)===!0}))){const re=o.properties.find(ee=>ee.implements.find(de=>de.id===Q["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id));if(!re)throw new Error("Default boolean property not found for relational database entity with id: "+o.id);if(!(re!=null&&re.defaultValue)){const ee=Yr.new(p);ee.parent=re.toReference();const de=me(ee,o.project);de.hydrateAncestors(),de.setParent(re,p),de.addSelfToProject(p),p==null||p.add(de,H.Added),de.initChildren(p)}(E=re==null?void 0:re.defaultValue)==null||E.metaSync({value:!0},p)}if(!L)throw new Error("Identifier property not found for relational database entity with id: "+o.id);if(!(L!=null&&L.defaultValue)){const re=Yr.new(p);re.parent=L.toReference();const ee=me(re,o.project);ee.hydrateAncestors(),ee.setParent(L,p),ee.addSelfToProject(p),ee.initChildren(p),p==null||p.add(ee,H.Added)}const K=lvi($,V.length);(b=L.defaultValue)==null||b.metaSync({value:K},p);const S=o.properties.find(re=>re.implements.find(ee=>ee.id===Q["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.password.id));if(!S)throw new Error(`[handleAfterEntityImplementationSideEffects] Password property not found for implemented base entity ${Q["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id} with id ${o.id}`);if(!S.defaultValue){const re=Yr.new(p);re.parent=S.toReference();const ee=me(re,o.project);ee.hydrateAncestors(),ee.setParent(S,p),ee.addSelfToProject(p),ee.initChildren(p),p==null||p.add(ee,H.Added),n.push(ee)}const Y=jP(24);(w=S.defaultValue)==null||w.metaSync({value:Y},p);return}case Q["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.id:{const V=o.properties.find(K=>K.implements.find(S=>S.id===Q["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.properties.time.id));if(!V)throw new Error(`[handleAfterEntityImplementationSideEffects] Time property not found for implemented base entity ${Q["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.id} with id ${o.id}`);let $=V.defaultValue||null;if(!$){const K=Yr.new(p);K.parent=V.toReference(),K.name=oe.Date,K.id=x.UUID.uuid(),$=me(K,o.project),$.hydrateAncestors(),$.setParent(V,p),$.addSelfToProject(p),$.initChildren(p),p==null||p.add($,H.Added)}$.metaSync({value:new Date().toISOString()},p),$.metaSync({editable:!1,deletable:!1},p),V.metaSync({editable:!1,deletable:!1},p);const L=o.properties.find(K=>K.implements.find(S=>S.id===Q["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.properties.definition.id));if(!L)throw new Error(`[handleAfterEntityImplementationSideEffects] Definition property not found for implemented base entity ${Q["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.id} with id ${o.id}`);let k=L.defaultValue||null;if(!k){const K=Yr.new(p);K.name=oe.EntityTemplate,K.parent=L.toReference(),K.id=x.UUID.uuid(),k=me(K,o.project),k.hydrateAncestors(),k.setParent(L,p),k.addSelfToProject(p),k.initChildren(p),p==null||p.add(k,H.Added)}}}}),{self:o,updated:D(i),added:D(n),removed:D(s),affected:D(c)}}function FI(o,p,i,n){const s=n||x.UUID.uuid(),c=us.new(i);c.id=s,c.name=p,c.static=o.static,c.implements=[o.toJSON()],c.parent=o.project.toReference(),c.static=o.static,vOe(o,i);const e=me(c,o.project);return e.hydrateAncestors(),i==null||i.add(e,H.Added),e.addSelfToProject(i),e.initChildren(i),EOe(e,i),e.afterAllChildrenInitialized(i),e}function KP(o,p){return p.entities.find(s=>{const c=s.properties,e=c.map(b=>b.name),y=o.every(b=>e.includes(b)),m=e.filter(b=>!o.includes(b)),v=c.every(b=>!m.includes(b.name)||!b.required);return y&&v})||null}function bOe(o,p,i,n=He.OrDataTypeGroup){const s=[],c=[],e=[],y=[],m=x.UUID.uuid(),v=ur.new(i);v.id=m,v.parent=p.toReference(),v.like=!0,v.parentRelationType=n;const E=me(v,o.project);return c.push(E),E.setParent(p,i),E.initChildren(i),i==null||i.add(E,H.Added),E.setEntity(o,i),E.addSelfToProject(i),{updated:D(s),added:D(c),removed:D(e),affected:D(y),self:E}}function FP(o,p,i,n,s){var v,E,b,w,V,$,L,k;const c=[],e=[],y=[],m=[];switch(typeof o){case"string":let K=!1;const S=new Date(o);if(S instanceof Date&&!isNaN(S.valueOf())&&(K=!0),K){const Y=p.project.getBuiltIn(Q[d.PrimitiveEntity][oe.Date].id);p.setEntity(Y,n);break}else{const Y=p.project.getBuiltIn(Q[d.PrimitiveEntity][oe.String].id);p.setEntity(Y,n);break}case"number":p.setEntity(p.project.getBuiltIn(Q[d.PrimitiveEntity][oe.Number].id),n);break;case"boolean":p.setEntity(p.project.getBuiltIn(Q[d.PrimitiveEntity][oe.Boolean].id),n);break;case"object":if(o===null){p.setEntity(p.project.getBuiltIn(Q[d.PrimitiveEntity][oe.Null].id),n);break}else if(Array.isArray(o))if(p.metaSync({isList:!0},n),o.length>0){const Y=o.slice(0,5).filter(ee=>ee!==void 0);if(Y.every(ee=>typeof ee==typeof Y[0])&&(typeof Y[0]!="object"||Y[0]===null))switch(typeof Y[0]){case"string":p.setEntity(p.project.getBuiltIn(Q[d.PrimitiveEntity][oe.String].id),n);break;case"number":p.setEntity(p.project.getBuiltIn(Q[d.PrimitiveEntity][oe.Number].id),n);break;case"boolean":p.setEntity(p.project.getBuiltIn(Q[d.PrimitiveEntity][oe.Boolean].id),n);break;case"object":p.setEntity(p.project.getBuiltIn(Q[d.PrimitiveEntity][oe.Null].id),n);break}else{const ee=[];let de=!1;Y.forEach(fe=>{var ve,ue,ye,Ve;if(Array.isArray(fe)&&(de=!0),typeof fe=="object"&&!Array.isArray(fe)&&fe!==null){const _e=jb(fe,p.project,{...i,id:x.UUID.uuid()},n,s);_e.hasCreated&&ee.push((ve=_e.changeSet)==null?void 0:ve.self),c.push(...(ue=_e.changeSet)==null?void 0:ue.updated),e.push(...(ye=_e.changeSet)==null?void 0:ye.added),y.push(...(Ve=_e.changeSet)==null?void 0:Ve.removed)}});const le=D(ee);if(!le.length&&!de){Y.forEach(fe=>{const ve=ur.new(n);ve.parentRelationType=He.OrDataTypeGroup,ve.parent=p.toReference();const ue=me(ve,p.project);switch(ue.setParent(p,n),ue.initChildren(n),n==null||n.add(ue,H.Added),ue.addSelfToProject(n),typeof fe){case"string":ue.setEntity(ue.project.getBuiltIn(Q[d.PrimitiveEntity][oe.String].id),n);break;case"number":ue.setEntity(ue.project.getBuiltIn(Q[d.PrimitiveEntity][oe.Number].id),n);break;case"boolean":ue.setEntity(ue.project.getBuiltIn(Q[d.PrimitiveEntity][oe.Boolean].id),n);break;case"object":ue.setEntity(ue.project.getBuiltIn(Q[d.PrimitiveEntity][oe.Null].id),n);break}});break}else le.length===1&&!de?p.setEntity(le[0],n):Y.forEach(fe=>{if(typeof fe=="object"&&!Array.isArray(fe)&&fe!==null){const ve=KP(Object.keys(fe),p.project);if(ve){const ue=bOe(ve||le[0],p,n,He.OrDataTypeGroup);c.push(...ue.updated),e.push(...ue.added),y.push(...ue.removed)}}else{const ve=ur.new(n);ve.parentRelationType=He.OrDataTypeGroup,ve.parent=p.toReference();const ue=me(ve,p.project);ue.setParent(p,n),ue.initChildren(n),n==null||n.add(ue,H.Added),ue.addSelfToProject(n);const ye=FP(fe,ue,{...i,id:x.UUID.uuid()},n,s);c.push(...ye.updated),e.push(...ye.added),y.push(...ye.removed)}})}}else{const Y=jb(o[0],p.project,{...i},n,s);p.setEntity((v=Y.changeSet)==null?void 0:v.self,n),c.push(...(E=Y.changeSet)==null?void 0:E.updated),e.push(...(b=Y.changeSet)==null?void 0:b.added),y.push(...(w=Y.changeSet)==null?void 0:w.removed);break}else{const Y=jb(o,p.project,{...i},n,s);p.setEntity((V=Y.changeSet)==null?void 0:V.self,n),c.push(...($=Y.changeSet)==null?void 0:$.updated),e.push(...(L=Y.changeSet)==null?void 0:L.added),y.push(...(k=Y.changeSet)==null?void 0:k.removed);break}}return{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:p}}function jb(o,p,i,n,s){const c=[],e=[],y=[],m=[],v=Object.keys(o),E=KP(v,p);if(E)return{hasCreated:!1,changeSet:{updated:[],added:[],removed:[],affected:[],self:E}};const b=s?i.name+" of "+s.name:i.name,V={id:i.id||x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(n==null?void 0:n.timestamp)||new Date().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,name:b,codeName:null,deletable:!0,editable:!0,type:d.DefinitionEntity,additionalProperties:!1,additionalPropertiesDataType:null,allPropertiesImplement:null,description:i.description||null,static:i.static||!1,abstract:i.abstract||!1,properties:[],methods:[],abstractMethods:[],extends:null,implements:[],x:0,y:0,parent:p.toReference()},$=me(V,p);return $.setParent(p,n),$.initChildren(n),n==null||n.add($,H.Added),$.addSelfToProject(n),e.push($),v.forEach((L,k)=>{const K=x.UUID.uuid(),S=ja.new(n);S.id=K,S.name=L,S.codeName=L,S.parent=$.toReference(),S.index=k,S.required=!0,S.interactive=!0;const Y=me(S,p);Y.setParent($,n),Y.initChildren(n),n==null||n.add(Y,H.Added),Y.addSelfToProject(n),e.push(Y);const re=o[L],ee=x.UUID.uuid(),de=ur.new(n);de.id=ee,de.parent=Y.toReference(),de.like=!0,de.isList=!1;const le=me(de,p);le.setParent(Y,n),le.initChildren(n),n==null||n.add(le,H.Added),le.addSelfToProject(n),e.push(le);const fe=FP(re,le,{...i,name:L,id:x.UUID.uuid()},n,s||$);c.push(...fe.updated),e.push(...fe.added),y.push(...fe.removed)}),{hasCreated:!0,changeSet:{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:$}}}function pd(o,p,i,n){const s=[];return!o.length||!p.length?{errors:s,overlap:!1}:(o.length>p.length?o.forEach(c=>{const e=p.find(m=>m.name===c.name),y=p.find(m=>{var v,E;return Array.isArray(m.implements)?m.implements.some(b=>!!c.implements.find(w=>w.id===b.id)):((v=m.implements)==null?void 0:v.id)===((E=c.implements)==null?void 0:E.id)});if(e){const m=new ki({id:c.id+"--"+e.id+"--"+n,message:`Entity of type ${c.type} named "${c.name}" with id "${c.id}" overrides a base ${e.type} ${e.name} with id "${e.id}" that has the same name`,severity:ce.Error,code:n,entity:c,firstRelationship:e});s.push(m)}if(y){const m=new ki({id:c.id+"--"+y.id+"--"+i,message:`Entity of type ${c.type} named "${c.name}" with id "${c.id}" overrides a base ${y.type} ${y.name} with id "${y.id}" that implements the same base descriptor`,severity:ce.Error,code:i,entity:c,firstRelationship:y});s.push(m)}}):p.forEach(c=>{var m;const e=o.find(v=>v.name===c.name),y=o.find(v=>{var E,b;return v.implements&&Array.isArray(v.implements)?v.implements.some(w=>!!c.implements.find(V=>V.id===w.id)):((E=v.implements)==null?void 0:E.id)===((b=c.implements)==null?void 0:b.id)});if(e){const v=new ki({id:e.id+"--"+c.id+"--"+n,message:`Entity of type ${e.type} named "${e.name}" with id "${e.id}" overrides a base entity ${c.name} with id "${c.id}" that has the same name`,severity:ce.Error,code:n,entity:e,firstRelationship:c});s.push(v)}if(y){const v=new ki({id:y.id+"--"+c.id+"--"+i,message:`Entity of type ${y.type} named "${y.name}" with id "${y.id}" overrides a base entity ${c.name} with id "${c.id}" that implements the same base ${Array.isArray(y==null?void 0:y.implements)?Ct(y==null?void 0:y.implements.map(E=>E.type),"', '","' and '"):(m=y.implements)==null?void 0:m.id}`,severity:ce.Error,code:i,entity:y,firstRelationship:c});s.push(v)}}),{errors:s,overlap:!!s.length})}function ovi(o,p){return o.abstract||(o.properties.forEach(n=>{n.abstract||n.metaSync({abstract:!0},p)}),Object.values(o.detachedDependents).forEach(n=>{n.field===HN.EntityField&&n.entity.remove({ignoreUpstream:!1},p)}),o.metaSync({abstract:!0},p)),o}function dvi(o,p){return o.abstract&&(o.properties.forEach(n=>{n.abstract&&n.metaSync({abstract:!1},p)}),Object.values(o.detachedDependents).forEach(n=>{(n.field===RA.Implements||n.field===RA.Extends)&&n.entity.onDetachedDependencyRemoved(o,n.field,p)}),o.metaSync({abstract:!1},p)),o}function uvi(o,p){return o.static||(o.properties.forEach(n=>{n.static||n.metaSync({static:!0},p)}),o.metaSync({static:!0},p)),o}function pvi(o,p){return o.static&&o.metaSync({static:!1},p),o}const jm=class jm extends xP{constructor(i,n){super(i);I(this,"initialData");I(this,"id");I(this,"version");I(this,"name");I(this,"description",null);I(this,"type",d.BuiltInBaseEntity);I(this,"abstract",!1);I(this,"static");I(this,"additionalProperties",!1);I(this,"properties",[]);I(this,"allPropertiesImplement",null);I(this,"additionalPropertiesDataType",null);I(this,"methods",[]);I(this,"abstractMethods",[]);I(this,"extends",null);I(this,"interactive",!1);I(this,"errors",[]);I(this,"project");if(this.initialData=this.initialData||i,this.project=this.project||n,this.id=this.id||i.id,this.version=this.version||i.version,this.name=this.name||i.name,this.static=this.static||i.static,this.interactive=this.interactive||i.interactive,this.abstract=i.abstract,this.additionalProperties=i.additionalProperties,this.properties=this.initialData.properties.map(s=>{const c=me(s,this.project);return c.setParent(this,null),c.initChildren(null),c}),this.methods=this.initialData.methods.map(s=>{const c=me(s,this.project);return c.setParent(this,null),c.initChildren(null),c}),this.abstractMethods=this.initialData.abstractMethods.map(s=>{const c=me(s,this.project);return c.setParent(this,null),c.initChildren(null),c}),this.initialData.allPropertiesImplement){const s=me(this.initialData.allPropertiesImplement,this.project);s.setParent(this,null),s.initChildren(null),this.allPropertiesImplement=s}if(this.initialData.additionalPropertiesDataType){const s=me(this.initialData.additionalPropertiesDataType,this.project);s.setParent(this,null),s.initChildren(null),this.additionalPropertiesDataType=s}this.initialData.extends&&(this.extends=me(this.initialData.extends,this.project))}get allMethods(){return D([...this.ownDeclaredMethods,...this.allBaseMethodsFromOriginalParents])}get allProperties(){return D([...this.ownDeclaredProperties,...this.allBasePropertiesFromOriginalParents])}get allBaseMethodsFromOriginalParents(){var s;const i=((s=this.extends)==null?void 0:s.allMethods)||[],n=[...i].filter(c=>!i.some(e=>e.id!==c.id));return D(n)}get allBasePropertiesFromOriginalParents(){var s;const i=((s=this.extends)==null?void 0:s.allProperties)||[],n=[...i].filter(c=>!i.some(e=>{var y;return e.id!==c.id&&(!!e.implements.find(m=>m.id===c.id)||((y=e.extends)==null?void 0:y.id)===c.id)}));return D(n)}get allBasePropertiesFromExtendedAndImplementedEntities(){var s,c;const i=[...((s=this.extends)==null?void 0:s.ownDeclaredProperties)||[],...((c=this.extends)==null?void 0:c.allBasePropertiesFromExtendedAndImplementedEntities)||[]].filter(e=>!e.abstract),n=[...i].filter(e=>!i.some(y=>{var m;return y.id!==e.id&&(!!y.implements.find(v=>v.id===e.id)||((m=y.extends)==null?void 0:m.id)===e.id)}));return D([...n])}get allBaseMethodsFromExtendedAndImplementedEntities(){return D([...(this.extends?[this.extends]:[]).reduce((i,n)=>n.type===d.PrimitiveEntity?i:[...[...n.ownDeclaredMethods,...n.allBaseMethodsFromExtendedAndImplementedEntities].filter(c=>c.type!==d.ActionDescriptor),...i],[])])}get extendedPropertiesFromOriginalParents(){var s,c;const i=[...((s=this.extends)==null?void 0:s.ownDeclaredProperties)||[],...((c=this.extends)==null?void 0:c.extendedPropertiesFromOriginalParents)||[]].filter(e=>!e.abstract),n=[...i].filter(e=>!i.some(y=>{var m;return y.id!==e.id&&(!!y.implements.find(v=>v.id===e.id)||((m=y.extends)==null?void 0:m.id)===e.id)}));return D(n)}get implementedPropertiesFromOriginalParents(){return D([...(this.extends?[this.extends]:[]).reduce((i,n)=>{const s=n.implementedPropertiesFromOriginalParents,c=[...n.ownDeclaredProperties].filter(m=>!!m.abstract),e=[...s,...c,...i];return[...e].filter(m=>!!!e.find(E=>{var b;return((b=E.extends)==null?void 0:b.id)===m.id||!!E.implements.find(w=>w.id===m.id)}))},[])].filter(i=>!!i.abstract))}get extendedProperties(){return this.properties.filter(i=>i.isExtendedProperty)}get ownDeclaredMethods(){return[...this.methods,...this.abstractMethods]}get ownDeclaredProperties(){return this.properties.filter(i=>!i.isExtendedProperty)}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}async APILoad(i=ke,...n){return await jm.repository.APILoad(this.id,...n),this}toFlat(i=new Set){var s;return i.has(this.id)?[]:(i.add(this.id),[this,...this.properties.flatMap(c=>c.toFlat(i)),...this.methods.flatMap(c=>c.toFlat(i)),...this.abstractMethods.flatMap(c=>c.toFlat(i)),...((s=this.extends)==null?void 0:s.toFlat(i))||[]])}toFlatIds(i=new Set){var s;return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.properties.flatMap(c=>c.toFlatIds(i)),...this.methods.flatMap(c=>c.toFlatIds(i)),...this.abstractMethods.flatMap(c=>c.toFlatIds(i)),...((s=this.extends)==null?void 0:s.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,interactive:this.interactive,additionalProperties:this.additionalProperties,abstract:this.abstract,static:this.static,type:this.type,name:this.name}}toJSON(i=new Set){var n,s,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,name:this.name,description:this.description,abstract:this.abstract,static:this.static,additionalProperties:this.additionalProperties,interactive:this.interactive,additionalPropertiesDataType:((n=this.additionalPropertiesDataType)==null?void 0:n.toJSON(i))||null,allPropertiesImplement:((s=this.allPropertiesImplement)==null?void 0:s.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)),extends:((c=this.extends)==null?void 0:c.toJSON(i))||null})}toReference(i=ct){return{id:this.id+"--"+x.UUID.uuid()+"--ref",type:d.GenericReference,entityId:this.id,version:this.version,entityType:this.type}}toShallowJSON(i=ct){var n,s,c;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,interactive:this.interactive,additionalProperties:this.additionalProperties,additionalPropertiesDataType:((n=this.additionalPropertiesDataType)==null?void 0:n.toReference())||null,allPropertiesImplement:((s=this.allPropertiesImplement)==null?void 0:s.toReference())||null,properties:this.properties.map(e=>e.toReference()),methods:this.methods.map(e=>e.toReference()),abstractMethods:this.abstractMethods.map(e=>e.toReference()),extends:((c=this.extends)==null?void 0:c.toReference())||null}}toFlatJSON(i=new Set){var s,c;return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...this.properties.flatMap(e=>e.toFlatJSON(i)),...this.methods.flatMap(e=>e.toFlatJSON(i)),...this.abstractMethods.flatMap(e=>e.toFlatJSON(i)),...((s=this.additionalPropertiesDataType)==null?void 0:s.toFlatJSON(i))||[],...((c=this.allPropertiesImplement)==null?void 0:c.toFlatJSON(i))||[]])}toGenerationTarget(){var i;return{id:this.id,type:this.type,name:this.name,description:this.description,static:this.static,abstract:this.abstract,interactive:this.interactive,additionalProperties:this.additionalProperties,extends:(i=this.extends)==null?void 0:i.id}}toFlatGenerationTarget(i=new Set){var s,c;return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...this.properties.flatMap(e=>e.toFlatGenerationTarget(i)),...this.methods.flatMap(e=>e.toFlatGenerationTarget(i)),...this.abstractMethods.flatMap(e=>e.toFlatGenerationTarget(i)),...((s=this.additionalPropertiesDataType)==null?void 0:s.toFlatGenerationTarget(i))||[],...((c=this.allPropertiesImplement)==null?void 0:c.toFlatGenerationTarget(i))||[]])}clearErrors(){var i,n;return this.errors=[],this.properties.forEach(s=>s.clearErrors()),this.methods.forEach(s=>s.clearErrors()),this.abstractMethods.forEach(s=>s.clearErrors()),(i=this.additionalPropertiesDataType)==null||i.clearErrors(),(n=this.allPropertiesImplement)==null||n.clearErrors(),this}validate(){return this.errors=evi(this),{success:!0}}async validateAsync(i={}){const n=J.YieldTracker.from(i);return this.errors=await QTi(this,{tracker:n}),{success:!0}}getErrors(){var n,s;return[...this.errors,...this.properties.flatMap(c=>c.getErrors()),...this.methods.flatMap(c=>c.getErrors()),...this.abstractMethods.flatMap(c=>c.getErrors()),...((n=this.additionalPropertiesDataType)==null?void 0:n.getErrors())||[],...((s=this.allPropertiesImplement)==null?void 0:s.getErrors())||[]]}async getErrorsAsync(i={}){const n=J.YieldTracker.from(i),s=[...this.errors];await n.tick();for(const c of this.properties){const e=await c.getErrorsAsync({tracker:n});s.push(...e)}for(const c of this.methods){const e=await c.getErrorsAsync({tracker:n});s.push(...e)}for(const c of this.abstractMethods){const e=await c.getErrorsAsync({tracker:n});s.push(...e)}if(this.additionalPropertiesDataType){const c=await this.additionalPropertiesDataType.getErrorsAsync({tracker:n});s.push(...c)}if(this.allPropertiesImplement){const c=await this.allPropertiesImplement.getErrorsAsync({tracker:n});s.push(...c)}return s}getShallowErrors(){return this.errors}implement(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),null,!0,"implement-built-in-base-entity")),s){const c=FI(this,i,n,s);return n==null||n.attemptAutoclose("implement-built-in-base-entity",this.id),c}getAllPropertiesImplements(){var n;const i=[];return this.allPropertiesImplement&&i.push(this.allPropertiesImplement),((n=this.extends)==null?void 0:n.type)===d.BuiltInBaseEntity&&i.push(...this.extends.getAllPropertiesImplements()||[]),i}getAllInteractiveMethods(){const i=[];if(this.interactive){if(i.push(...this.methods,...this.abstractMethods),!this.extends||this.extends.type===d.BuiltInBaseEntity&&this.extends.interactive||this.extends.type===d.PrimitiveEntity)return i;this.extends instanceof jm&&i.push(...this.extends.getAllInteractiveMethods())}return D(i)}};I(jm,"repository",{APILoad:async(i,...n)=>null});let No=jm;class AOe extends No{constructor(i){super(dn,i);I(this,"initialData");I(this,"id",Re.PERSISTED_ENTITY);I(this,"version","1");I(this,"name",Re.PERSISTED_ENTITY);I(this,"description",dn.description);I(this,"type",d.BuiltInBaseEntity);I(this,"abstract",dn.abstract);I(this,"static",dn.static);I(this,"properties",[]);I(this,"methods",[]);I(this,"abstractMethods",[]);I(this,"extends",null);I(this,"errors",[]);I(this,"project");this.initialData=dn,this.project=i,this.id=dn.id,this.version=dn.version,this.name=dn.name,this.static=dn.static,this.abstract=dn.abstract,this.properties=this.initialData.properties.map(n=>{const s=me(n,this.project);return s.setParent(this,null),s.initChildren(null),s}),this.methods=this.initialData.methods.map(n=>{const s=me(n,this.project);return s.parent=this,s}),this.abstractMethods=this.initialData.abstractMethods.map(n=>{const s=me(n,this.project);return s.parent=this,s}),this.initialData.extends&&(this.extends=me(this.initialData.extends,this.project))}}var sa=(o=>(o.StringValueMustNotHaveSpaces="string-value-must-not-have-spaces",o.StringValueMustNotHaveDashes="string-value-must-not-have-dashes",o.MustBeUniqueAmongSameEntities="must-be-unique-among-same-entities",o))(sa||{});function SP(o,p){const i=[],n=p;if(!n)return{errors:i,override:p};if(typeof n!="string")return{errors:[],override:p};if(n.includes(" ")){const s=new ki({id:o.id+"--string-value-must-not-have-spaces",message:`Entity of type ${o.type} with id "${o.id}" has an invalid value "${p}". The value cannot contain spaces.`,severity:ce.Error,code:"string-value-must-not-have-spaces",entity:o});i.push(s)}return{errors:i,override:n.replace(/\s/g,"-")}}function gOe(o,p){const i=[],n=p;if(!n)return{errors:i,override:p};if(typeof n!="string")return{errors:[],override:p};if(n.includes(" ")){const s=new ki({id:o.id+"--string-value-must-not-have-spaces",message:`Entity of type ${o.type} with id "${o.id}" has an invalid value "${p}". The value cannot contain spaces or dashes.`,severity:ce.Error,code:"string-value-must-not-have-spaces",entity:o});i.push(s)}if(n.includes("-")){const s=new ki({id:o.id+"--string-value-must-not-have-dashes",message:`Entity of type ${o.type} with id "${o.id}" has an invalid value "${p}". The value cannot contain spaces or dashes.`,severity:ce.Error,code:"string-value-must-not-have-dashes",entity:o});i.push(s)}return{errors:i,override:n.replace(/\s|-/g,"_")}}var xo=(o=>(o.StatusCodeMustBeNumber="status-code-must-be-number",o.StatusCodeMustBeBetween100And599="status-code-must-be-between-100-and-599",o))(xo||{});function IOe(o,p){const i=[];if(typeof p!="number"){const n=new ki({id:o.id+"--status-code-must-be-number",message:`Entity of type ${o.type} with id "${o.id}" has an invalid value "${p}". The value must be a number.`,severity:ce.Error,code:"status-code-must-be-number",entity:o});return i.push(n),{errors:i,override:p}}if(p<100){const n=new ki({id:o.id+"--status-code-must-be-between-100-and-599",message:`Entity of type ${o.type} with id "${o.id}" has an invalid value "${p}". The value must be a number between 100 and 599.`,severity:ce.Error,code:"status-code-must-be-between-100-and-599",entity:o});i.push(n)}if(p>599){const n=new ki({id:o.id+"--status-code-must-be-between-100-and-599",message:`Entity of type ${o.type} with id "${o.id}" has an invalid value "${p}". The value must be a number between 100 and 599.`,severity:ce.Error,code:"status-code-must-be-between-100-and-599",entity:o});i.push(n)}return{errors:i,override:p}}class ROe extends No{constructor(i){var e,y;super(xa,i);I(this,"initialData");I(this,"id",Re.PERSISTED_ENTITY);I(this,"version","1");I(this,"name",Re.PERSISTED_ENTITY);I(this,"description",xa.description);I(this,"type",d.BuiltInBaseEntity);I(this,"abstract",xa.abstract);I(this,"static",xa.static);I(this,"properties",[]);I(this,"methods",[]);I(this,"abstractMethods",[]);I(this,"extends",null);I(this,"errors",[]);I(this,"project");this.initialData=xa,this.project=i,this.id=xa.id,this.version=xa.version,this.name=xa.name,this.static=xa.static,this.abstract=xa.abstract,this.properties=this.initialData.properties.map(m=>{const v=me(m,this.project);return v.setParent(this,null),v.initChildren(null),v}),this.methods=this.initialData.methods.map(m=>{const v=me(m,this.project);return v.parent=this,v}),this.abstractMethods=this.initialData.abstractMethods.map(m=>{const v=me(m,this.project);return v.parent=this,v}),this.initialData.extends&&(this.extends=me(this.initialData.extends,this.project));const n=this.properties.find(m=>m.id===Q["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.properties.path.id);if(!n)throw new Error("Path property not found in endpoint entity");n._codeNativeValueValidation=(m,v)=>{const E=SP(m,v);if(m.project.entities.filter(w=>Wi(w,Re.HTTP_ENDPOINT)&&w.id!==m.parent.id).map(w=>{const V=w.properties.find(k=>k.implements.find(K=>K.id===Q["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.properties.path.id));if(!V)throw new Error("Path property not found in endpoint entity "+w.name+" ("+w.id+")");const $=V.getDefaultValue();return($==null?void 0:$.value)||""}).includes(v)){const w=new ki({id:m.id+"--"+sa.MustBeUniqueAmongSameEntities,message:`Entity of type ${m.type} with id "${m.id}" has an invalid value "${v}". The value must be unique among all endpoint paths.`,severity:ce.Error,code:sa.MustBeUniqueAmongSameEntities,entity:m});E.errors.push(w)}return E};const s=this.abstractMethods.find(m=>m.id===Q["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.methods.handler.id);if(!s)throw new Error("Handler method not found in endpoint entity");const c=(((y=(e=s.dataType)==null?void 0:e.entity)==null?void 0:y.properties)||[]).find(m=>m.id===Q["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.methods.handler.dataType.entity.properties.statusCode.id);if(!c)throw new Error("Status code output not found in handler method");c._codeNativeValueValidation=(m,v)=>IOe(m,v)}}class DOe extends Bi{constructor(i){super(go,i);I(this,"id",Ki.Parallel);I(this,"name",Ki.Parallel);I(this,"description","Programmatically execute a list of actions one after the other");I(this,"version","1");I(this,"autoexecutable",!0);I(this,"type",d.ActionDescriptor);I(this,"inputs",[]);I(this,"dataType",null);I(this,"error",null);I(this,"project");this.project=i,this.inputs=go.inputs.map(n=>{const s=me(n,this.project);return s.setParent(this,null),s.initChildren(null),s}),this.dataType=me(go.dataType,this.project),this.dataType.setParent(this,null),this.dataType.initChildren(null),this.error=go.error?me(go.error,this.project):null}}class wOe extends Bi{constructor(i){super(rs,i);I(this,"id",rs.id);I(this,"name",rs.name);I(this,"description",rs.description);I(this,"version",rs.version);I(this,"autoexecutable",!1);I(this,"type",d.ActionDescriptor);I(this,"inputs",[]);I(this,"dataType",null);I(this,"error",null);I(this,"project");this.project=i,this.inputs=rs.inputs.map(n=>{const s=me(n,this.project);return s.setParent(this,null),s.initChildren(null),s}),this.dataType=me(rs.dataType,this.project),this.dataType.setParent(this,null),this.dataType.initChildren(null),this.error=rs.error?me(rs.error,this.project):null}}class OOe extends Bi{constructor(i){super(gu,i);I(this,"id",Ki.Sequential);I(this,"name",Ki.Sequential);I(this,"description","Programmatically execute a list of actions one after the other");I(this,"version","1");I(this,"autoexecutable",!0);I(this,"type",d.ActionDescriptor);I(this,"inputs",[]);I(this,"dataType",null);I(this,"error",null);I(this,"project");this.project=i,this.inputs=gu.inputs.map(n=>{const s=me(n,this.project);return s.setParent(this,null),s.initChildren(null),s}),this.dataType=me(gu.dataType,this.project),this.dataType.setParent(this,null),this.dataType.initChildren(null),this.error=gu.error?me(gu.error,this.project):null}}var Ba=(o=>(o.UUIDMustBeString="uuid-must-be-string",o.UUIDMustBeValidFormat="uuid-must-be-valid-format",o.UUIDMustNotContainSpaces="uuid-must-not-contain-spaces",o))(Ba||{});function cvi(o,p){const i=[];if(typeof p!="string"){const s=new ki({id:o.id+"--uuid-must-be-string",message:`Entity of type ${o.type} with id "${o.id}" has an invalid value "${p}". The value must be text.`,severity:ce.Error,code:"uuid-must-be-string",entity:o});return i.push(s),{errors:i,override:p}}const n=SP(o,p);if(n.errors.length>0)return i.push(...n.errors),{errors:i,override:p};if(!NP(p)){const s=new ki({id:o.id+"--uuid-must-be-valid-format",message:`Entity of type ${o.type} with id "${o.id}" has an invalid value "${p}". The value must be a valid UUID format. Eg: "123e4567-e89b-12d3-a456-426614174000".`,severity:ce.Error,code:"uuid-must-be-valid-format",entity:o});i.push(s)}return{errors:i,override:p}}var Pe=(o=>(o.Inherited="inherited",o.DefaultValue="default-value",o.Missing="missing",o.Empty="empty",o.AutoCalculated="auto-calculated",o.QueuedAutocalculation="queued-autocalculation",o.External="external",o.Testing="testing",o.ExecutionResult="execution-result",o))(Pe||{});const COe={initialized:!1,id:"",project:null,values:{},onWriteCallback:()=>{},onRemoveCallback:()=>{},onWrite:()=>{},onRemove:()=>{},init:()=>{},toJSON:()=>({}),writeValue:()=>{},readValue:()=>null,removeValue:()=>{},clear:()=>{}};function fvi(o,p){return{...COe,id:o,project:p}}class Vm{constructor(p,i){I(this,"initialized",!1);I(this,"id");I(this,"project");I(this,"values",{});I(this,"onWriteCallback",()=>{});I(this,"onRemoveCallback",()=>{});this.id=p,this.project=i,this.init()}onWrite(p){this.onWriteCallback=p}onRemove(p){this.onRemoveCallback=p}init(){var n;if(!((n=this.project)!=null&&n.id)||this.initialized)return;const p={},i={};Object.keys(p).forEach(s=>{const c=p[s],e=new Yr(c,this.project);try{if(c.parent){const v=this.project.findSubscribedInstanceFromReference(c.parent);if(!v)return;e.setParent(v,null),e.hydrateAncestors(),e.initChildren(null)}else if(c.standaloneParent){const v=this.project.findSubscribedInstanceFromReference(c.standaloneParent);if(!v)return;e.standalone=!0,e.setStandaloneParent(v,null),e.hydrateAncestors(),e.initChildren(null)}i[s]=e;const y=e.parent||e.standaloneParent,m=POe(e,y,this.project);m?i[s]=m:delete p[s]}catch(y){J.Logger.error("Error hydrating ancestors: ",y),delete p[s]}}),this.values={...this.values,...i},this.initialized=!0}toJSON(){const p={};return Object.keys(this.values).forEach(i=>{p[i]=this.values[i].toJSON()}),p}writeValue(p,i){if(!p)throw new Error("The value owner entity is required when writing a value to a value store");let s=this.values[p.id];if(!s)if(i instanceof Yr)s=i;else if(i)s=Si(i,this.project);else{const c={id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:new Date().toISOString(),author:x.sessionAuthor,deleted:!1,previousVersion:null,value:null,deletable:!0,editable:!0,type:d.LiteralValue,standaloneParent:p.toReference(),parent:null,valueAsTypeSingle:null,valueAsTypeList:null,autogeneration:null,name:mc(p.getDataType(null))};s=Si(c,this.project)}s.standalone=!0,s.initialData.standaloneParent||J.Logger.warn("instance.initialData: ",s.initialData),s.setStandaloneParent(p,null),s.hydrateAncestors(),s.initChildren(null),i&&(s.metaSync({...i},null),s.setValueAsType(i.valueAsType,null)),this.values[p.id]=s,this.onWriteCallback(p,s)}readValue(p){return this.values[p]||null}removeValue(p){if(!this.values[p])return;delete this.values[p];const i=this.project.get(p);i&&this.onRemoveCallback(i)}clear(){this.values={}}}function hr(o){return o!==null&&typeof o=="object"&&!Array.isArray(o)}function _Oe(o){if(Array.isArray(o))return o.map(m=>typeof m=="number"?m:e(m)?Number(m):String(m));const p=[];let i=0,n="",s=!1,c=null;for(;i<o.length;){const m=o[i];if(m==="."&&!s){n.length&&(p.push(y(n)),n=""),i++;continue}if(m==="["&&!s){n.length&&(p.push(y(n)),n=""),s=!0,i++;continue}if(s){if(!c&&(m==='"'||m==="'")){c=m,i++;continue}if(c){if(m==="\\"&&i+1<o.length){n+=o[i+1],i+=2;continue}if(m===c){c=null,i++;continue}n+=m,i++;continue}if(m==="]"){p.push(y(n)),n="",s=!1,i++;continue}if(/\s/.test(m)&&!c){i++;continue}n+=m,i++;continue}n+=m,i++}return n.length&&p.push(y(n)),p;function e(m){return/^[0-9]+$/.test(m)}function y(m){const v=m.trim();return e(v)?Number(v):v}}function qP(o,p,i){if(o==null)return i;const n=_Oe(p);let s=o;for(let c=0;c<n.length;c++){const e=n[c];if(s==null)return i;if(Array.isArray(s)&&typeof e=="number"){if(!(e in s))return i;s=s[e]}else{if(!Object.prototype.hasOwnProperty.call(s,e))return i;s=s[e]}}return s}const yvi=new Set(["__proto__","prototype","constructor"]);function hvi(o){return typeof o=="string"&&yvi.has(o)}function VOe(o,p,i,n){const{createMissing:s=!0,coerce:c=!0}=n??{};if(o==null||typeof o!="object")throw new TypeError("set(...) expects a non-null object as target.");const e=_Oe(p);if(e.length===0)throw new Error("set(...) path must not be empty.");let y=o;for(let m=0;m<e.length;m++){const v=e[m];if(hvi(v))throw new Error(`Refusing to set unsafe key "${String(v)}" on object.`);const E=m===e.length-1,w=typeof e[m+1]=="number",V=Array.isArray(y)&&typeof v=="number";if(E){if(V&&y[v]==null&&!s)throw new Error(`set(...) missing array index "${String(v)}" (createMissing=false).`);return y[v]=i,o}else{if(!Object.prototype.hasOwnProperty.call(y,v)||y[v]==null){if(!s)throw new Error(`set(...) missing parent at segment "${String(v)}" (createMissing=false).`);y[v]=w?[]:{}}else{const $=y[v],L=$!==null&&typeof $=="object",k=Array.isArray($);if(w){if(!k){if(!c)throw new Error(`set(...) expected an array at "${String(v)}" but found non-array (coerce=false).`);y[v]=[]}}else if(!L||k){if(!c)throw new Error(`set(...) expected an object at "${String(v)}" but found non-object (coerce=false).`);y[v]={}}}y=y[v]}}return o}function nv(o){return globalThis.structuredClone?structuredClone(o):JSON.parse(JSON.stringify(o))}function mvi(o){if(Array.isArray(o))return o.slice();const p=[];let i="",n=0;for(;n<o.length;){const s=o[n];if(s==="."||s==="["||s==="]"){if(i.length){const c=Number(i);p.push(!Number.isNaN(c)&&/^\d+$/.test(i)?c:i),i=""}if(s==="["){n++;let c="";for(;n<o.length&&o[n]!=="]";)c+=o[n++];const e=Number(c);p.push(!Number.isNaN(e)&&/^\d+$/.test(c)?e:c)}n++;continue}i+=s,n++}if(i.length){const s=Number(i);p.push(!Number.isNaN(s)&&/^\d+$/.test(i)?s:i)}return p}function ZP(o,p,i){const n=mvi(p);if(n.length===0)throw new Error("Path must not be empty.");const s=n[n.length-1];let c=o;for(let e=0;e<n.length-1;e++){const y=n[e],m=typeof n[e+1]=="number",v=c==null?void 0:c[y];if(v==null){if(!i)throw new Error(`Missing parent at segment "${String(y)}" for path "${Array.isArray(p)?JSON.stringify(p):p}".`);c[y]=m?[]:{}}else if(typeof v!="object"||v!==null&&Array.isArray(v)!==m&&typeof n[e+1]=="number"){if(!i)throw new Error(`Parent at "${String(y)}" is not a container suitable for continuing the path.`);c[y]=m?[]:{}}c=c[y]}return{target:c,lastKey:s}}function Qd(o,p,i,n){var y;let s;if(((y=o==null?void 0:o.entity)==null?void 0:y.type)===d.PrimitiveEntity)switch(o.entity.name){case oe.EntityTemplate:s=oe.EntityTemplate;break;case oe.String:s=oe.String;break;case oe.Number:s=oe.Number;break;case oe.Boolean:s=oe.Boolean;break;case oe.Null:s=oe.Null;break;case oe.Enum:s=oe.Enum;break;case oe.KeyValue:s=oe.KeyValue;break;case oe.Untyped:s=oe.Untyped;break;case oe.KeyValue:s=oe.KeyValue;break;case oe.Date:s=oe.Date;break;case oe.UUID:s=oe.UUID;break;case oe.File:s=oe.File;break;case oe.Void:s=oe.Void;break;case oe.ActionDescriptor:s=oe.ActionDescriptor;break;case oe.Bytes:s=oe.Bytes;break;default:throw new Error(`Primitive type ${se(o.entity,i)} is not supported`)}else s=oe.Untyped;const c=Yr.new(n);c.name=s,c.parent=p.toReference();const e=me(c,i);return e.hydrateAncestors(),n==null||n.add(e,H.Added),e.addSelfToProject(n),e.initChildren(n),e}function Oo(o,p,i=new Set){var n,s,c;if(i.has(o.id))return[];if(i.add(o.id),Gt.includes(o.type)){const e=Wn(o);return D([e,...[e].flatMap(y=>Oo(y,p,i))])}else if(o.type===d.OutputMap){if(Gt.includes(o.parent.type)&&((n=o.declaration)==null?void 0:n.type)===d.Property&&o.declaration.static)return D([o,o.declaration,...[o,o.declaration].flatMap(e=>Oo(e,p,i))])}else if(o.type===d.InputMap&&Gt.includes(o.parent.type)&&((s=o.declaration)==null?void 0:s.type)===d.Property&&(c=o.declaration)!=null&&c.static)return D([o.declaration,...[o.declaration].flatMap(e=>Oo(e,p,i))]);return[o]}function POe(o,p,i){return o}function Lh(o,p,i=!1){const n=o.readsValue;let s=null;const c=Mu(n,p,i);if(c){const e={sources:[c],target:o};s={value:c.value,valueOwner:o,type:Pe.Inherited,inheritanceLink:e}}return s}function It(o,p,i){var y;if(!p)return null;let n;if(((y=o==null?void 0:o.entity)==null?void 0:y.type)===d.PrimitiveEntity)switch(o.entity.name){case oe.EntityTemplate:n=oe.EntityTemplate;break;case oe.String:n=oe.String;break;case oe.Number:n=oe.Number;break;case oe.Boolean:n=oe.Boolean;break;case oe.Null:n=oe.Null;break;case oe.Enum:n=oe.Enum;break;case oe.KeyValue:n=oe.KeyValue;break;case oe.Untyped:n=oe.Untyped;break;case oe.KeyValue:n=oe.KeyValue;break;case oe.Date:n=oe.Date;break;case oe.UUID:n=oe.UUID;break;case oe.File:n=oe.File;break;case oe.Void:n=oe.Void;break;case oe.ActionDescriptor:n=oe.ActionDescriptor;break;case oe.Bytes:n=oe.Bytes;break;default:throw new Error(`Primitive type ${se(o.entity,i)} is not supported`)}else n=oe.Untyped;if(!i.get(p.id))return null;const c=Yr.new(null);c.name=n,c.standaloneParent=p.toReference();let e=new Yr(c,i);return e.hydrateAncestors(),e.standalone=!0,e.setStandaloneParent(p,null),e.initChildren(null),e}function NOe(o,p,i=!1){var c,e;if(p.execution&&p.execution.hasEntity(o)&&!i){const y=(c=p.lastExecutionResults)==null?void 0:c.readValue(o.id);if(y)return{value:y,valueOwner:o,type:Pe.ExecutionResult,inheritanceLink:null}}const n=(e=p.localTestValues)==null?void 0:e.readValue(o.id),s=p.getValueTypePreference(o.id);return n&&!i&&(s===null||s!==Pe.DefaultValue)?{value:n,valueOwner:o,type:Pe.Testing,inheritanceLink:null}:{value:null,valueOwner:o,type:Pe.QueuedAutocalculation,inheritanceLink:null}}function Ub(o,p,i,n=!1){var e,y;const s={...o},c=p.type===d.VariableDeclaration?p.inputs:qt.includes(p.type)?p.outputs:[];if(!c||c.length===0)return s;for(const m of c){if(!xv(m))continue;const v=Fm(m,i,n);if(v&&v.value){const E=se(m,i.project),b=m.codeName||((e=m.declaration)==null?void 0:e.codeName)||Hi(E);s[b]=un((v==null?void 0:v.value)||null)?s[b]:(y=v==null?void 0:v.value)==null?void 0:y.value}}return s}function Pm(o,p,i,n=!1){var e,y;const s={...o},c=p.inputs;if(!c)return s;for(const m of c){if(!xv(m))continue;const v=sv(m,i,n);if(v&&v.value){const E=se(m,i.project),b=m.codeName||((e=m.declaration)==null?void 0:e.codeName)||Hi(E);s[b]=(y=v==null?void 0:v.value)==null?void 0:y.value}}return s}function xOe(o,p,i=!1){var E,b,w,V,$,L,k,K;let n={};if(((b=(E=o.getDataType(null))==null?void 0:E.entity)==null?void 0:b.type)===d.DefinitionEntity&&(n={...n,...((w=o.getDataType(null))==null?void 0:w.entity).getActiveRawDefaultValue()}),p.execution&&p.execution.hasEntity(o)&&!i){const S=(V=p.lastExecutionResults)==null?void 0:V.readValue(o.id);if(S){if(hr(S.value)){const re={...n,...S.value},ee={...Pm(re,o,p,i)};S.metaSync({value:ee},null)}return{value:S,valueOwner:o,type:Pe.ExecutionResult,inheritanceLink:null}}}const s=!!(($=p.execution)!=null&&$.entities.length),c=(L=p.execution)==null?void 0:L.hasEntity(o),e=o.readsValue;let y=null;if(e){const S=(k=p.execution)==null?void 0:k.hasEntity(e);if((!s||s&&S&&c||s&&!S&&!c)&&(y=Lh(o,p,i),y&&y.value&&hr(y.value.value))){const re={...n,...y.value.value},ee={...Pm(re,o,p,i)};y.value.metaSync({value:ee},null)}}const m=o.getDefaultValue(),v=p.getValueTypePreference(o.id);if(!y&&m){const S=m;if(S&&S.value===null&&S.autogeneration){const Y=LR(S);if(S.metaSync({value:Y},null),hr(Y)){const re={...Pm(Y,o,p,i)};S.metaSync({value:re},null)}}(i||v===null||v!==Pe.Testing)&&(y={value:S,valueOwner:o,type:un(S)?o.readsValue?Pe.Inherited:Pe.Empty:Pe.DefaultValue,inheritanceLink:null})}if(!y||(y.type===Pe.DefaultValue||y.type===Pe.External)&&!i||v===null||v!==Pe.DefaultValue){const S=(K=p.localTestValues)==null?void 0:K.readValue(o.id);if(S){if(hr(S.value)){const Y={...n,...S.value},re={...Pm(Y,o,p,i)};S.metaSync({value:re},null)}return{value:S,valueOwner:o,type:Pe.Testing,inheritanceLink:null}}}return un((y==null?void 0:y.value)||null)?{value:null,valueOwner:o,type:o.readsValue?Pe.Inherited:Pe.Empty,inheritanceLink:null}:y}function HP(o,p,i=!1){var e,y,m,v,E,b,w,V,$;let n={};if(((y=(e=o.getDataType(null))==null?void 0:e.entity)==null?void 0:y.type)===d.DefinitionEntity&&(n={...n,...((m=o.getDataType(null))==null?void 0:m.entity).getActiveRawDefaultValue()}),p.execution&&p.execution.hasEntity(o)&&!i){const L=(v=p.lastExecutionResults)==null?void 0:v.readValue(o.id);if(L){if(hr(L.value)){const K={...n,...L.value},S=Ub(K,o,p,i);L==null||L.metaSync({value:S},null)}return{value:L,valueOwner:o,type:Pe.ExecutionResult,inheritanceLink:null}}}const s=(E=p.localTestValues)==null?void 0:E.readValue(o.id),c=p.getValueTypePreference(o.id);if(s&&!i&&(c===null||c!==Pe.DefaultValue)){if(hr(s.value)){const k={...n,...s.value},K=Ub(k,o,p,i);s.metaSync({value:K},null)}return{value:s,valueOwner:o,type:Pe.Testing,inheritanceLink:null}}if((b=o.getDataType(null))!=null&&b.entity&&((V=(w=o.getDataType(null))==null?void 0:w.entity)==null?void 0:V.type)===d.DefinitionEntity&&(($=o.getDataType(null))!=null&&$.isObject())){const L=It(o.dataType,o,p.project),k=Ub(n,o,p,i);return L==null||L.metaSync({value:k},null),{value:L,valueOwner:o,type:Pe.DefaultValue,inheritanceLink:null}}return null}function av(o,p,i=!1){var E,b,w,V,$;if((E=o.dataType)!=null&&E.isObject())return xOe(o,p,i);const n=li(o),s=!!((b=p.execution)!=null&&b.entities.length),c=(w=p.execution)==null?void 0:w.hasEntity(n),e=o.readsValue;let y=null;if(e){const L=(V=p.execution)==null?void 0:V.hasEntity(e);(!s||s&&L&&c||s&&!L&&!c)&&(y=Lh(o,p,i))}const m=o.getDefaultValue(),v=p.getValueTypePreference(o.id);if(!y&&m){const L=m;if(L&&L.value===null&&L.autogeneration){const k=LR(L);L.metaSync({value:k},null)}(i||v===null||v!==Pe.Testing)&&(y={value:L,valueOwner:o,type:un(L)?o.readsValue?Pe.Inherited:Pe.Empty:Pe.DefaultValue,inheritanceLink:null})}if(!y||(y.type===Pe.DefaultValue||y.type===Pe.External)&&!i||v===null||v!==Pe.DefaultValue){const L=($=p.localTestValues)==null?void 0:$.readValue(o.id);if(L)return{value:L,valueOwner:o,type:Pe.Testing,inheritanceLink:null}}return un((y==null?void 0:y.value)||null)?{value:null,valueOwner:o,type:o.readsValue?Pe.Inherited:Pe.Empty,inheritanceLink:null}:y}function WP(o,p,i=!1){var e,y,m;if((e=o.dataType)!=null&&e.isObject())return HP(o,p);if(p.execution&&p.execution.hasEntity(o)&&!i){const v=(y=p.lastExecutionResults)==null?void 0:y.readValue(o.id);if(v)return{value:v,valueOwner:o,type:Pe.ExecutionResult,inheritanceLink:null}}const n=(m=p.localTestValues)==null?void 0:m.readValue(o.id),s=p.getValueTypePreference(o.id);return n&&!i&&(s===null||s!==Pe.DefaultValue)?{value:n,valueOwner:o,type:Pe.Testing,inheritanceLink:null}:av(o,p,i)}function zP(o,p,i=!1){var w,V,$,L;const n=!!((w=p.execution)!=null&&w.entities.length),s=(V=p.execution)==null?void 0:V.hasEntity(o);let c=null;const e=o.readsValue;if(e){const k=($=p.execution)==null?void 0:$.hasEntity(e);(!n||n&&k&&s||n&&!k&&!s)&&(c=Lh(o,p,i))}const y=o.declaration;if(!c&&y){const k=av(y,p);k&&k.value&&(c=k)}const m=p.getValueTypePreference(o.id);if(!c||(c.type===Pe.DefaultValue||c.type===Pe.External)&&!i||m===null||m!==Pe.DefaultValue){const k=(L=p.localTestValues)==null?void 0:L.readValue(o.id);if(k)return{value:k,valueOwner:o,type:Pe.Testing,inheritanceLink:null}}const v=$o(o),E=o.getDataType(null);return v&&s&&(!(c!=null&&c.value)||!Il(E)&&eu(c==null?void 0:c.value))?{value:null,valueOwner:o,type:Pe.Missing,inheritanceLink:null}:s&&!v&&un((c==null?void 0:c.value)||null)?{value:null,valueOwner:o,type:o.readsValue?Pe.Inherited:Pe.Empty,inheritanceLink:null}:c||{value:null,valueOwner:o,type:Pe.External,inheritanceLink:null}}function $Oe(o,p,i=!1){return WP(o.declaration,p,i)}function LOe(o,p,i=!1){var w,V,$,L;if(!i&&p.execution&&p.execution.hasEntity(o)){const k=(w=p.lastExecutionResults)==null?void 0:w.readValue(o.id);if(k)return{value:k,valueOwner:o,type:Pe.ExecutionResult,inheritanceLink:null}}const n=li(o),s=o.parent.type===d.FunctionDeclaration&&o.parent.parent.type===d.Loop?o.parent:null,c=!!((V=p.execution)!=null&&V.hasEntity(n))||!!s&&!!(($=p.execution)!=null&&$.hasEntity(s));let e=null;const y=o.getDefaultValue(),m=p.getValueTypePreference(o.id);if(y){const k=y||null;if(k&&k.value===null&&k.autogeneration){const K=LR(k);k.metaSync({value:K},null)}(i||m===null||m!==Pe.Testing)&&(e={value:k,valueOwner:o,type:un(k)?Pe.Empty:Pe.DefaultValue,inheritanceLink:null})}if(!e||(e.type===Pe.DefaultValue||e.type===Pe.External)&&!i||m===null||m!==Pe.DefaultValue){const k=(L=p.localTestValues)==null?void 0:L.readValue(o.id),K=p.getValueTypePreference(o.id);if(k&&!i&&(K===null||K!==Pe.DefaultValue))return{value:k,valueOwner:o,type:Pe.Testing,inheritanceLink:null}}const v=$o(o),E=o.getDataType(null);let b=v&&c&&(!(e!=null&&e.value)||!Il(E)&&eu(e==null?void 0:e.value));return n.type===d.Loop&&c&&(b=!1),b?{value:null,valueOwner:o,type:Pe.Missing,inheritanceLink:null}:c&&!v&&un((e==null?void 0:e.value)||null)?{value:null,valueOwner:o,type:Pe.Empty,inheritanceLink:null}:e||{value:null,valueOwner:o,type:Pe.External,inheritanceLink:null}}function JP(o,p,i=!1){var V,$,L,k,K,S;if((V=o.getDataType(null))!=null&&V.isObject())return HP(o,p);if(p.execution&&p.execution.hasEntity(o)&&!i){const Y=($=p.lastExecutionResults)==null?void 0:$.readValue(o.id);if(Y)return{value:Y,valueOwner:o,type:Pe.ExecutionResult,inheritanceLink:null}}const n=li(o),s=!!((L=p.execution)!=null&&L.entities.length),c=(k=p.execution)==null?void 0:k.hasEntity(n),e=o.readsValue;let y=null;if(e){const Y=(K=p.execution)==null?void 0:K.hasEntity(e);(!s||s&&Y&&c||s&&!Y&&!c)&&(y=Lh(o,p,i))}const m=o.getDefaultValue(),v=p.getValueTypePreference(o.id);if(!y&&m){const Y=m;(i||v===null||v!==Pe.Testing)&&(y={value:Y,valueOwner:o,type:Pe.DefaultValue,inheritanceLink:null})}if(!y||(y.type===Pe.DefaultValue||y.type===Pe.External)&&!i||v===null||v!==Pe.DefaultValue){const Y=(S=p.localTestValues)==null?void 0:S.readValue(o.id);if(Y)return{value:Y,valueOwner:o,type:Pe.Testing,inheritanceLink:null}}const E=$o(o),b=o.getDataType(null);return E&&(!(y!=null&&y.value)||!Il(b)&&eu(y==null?void 0:y.value))?{value:null,valueOwner:o,type:Pe.Missing,inheritanceLink:null}:!E&&un((y==null?void 0:y.value)||null)?{value:null,valueOwner:o,type:o.readsValue?Pe.Inherited:Pe.Empty,inheritanceLink:null}:y}function MOe(o,p,i=!1){var y,m,v,E,b,w,V,$,L,k,K,S,Y;if(p.execution&&p.execution.hasEntity(o)&&!i){const re=(y=p.lastExecutionResults)==null?void 0:y.readValue(o.id);if(re)return{value:re,valueOwner:o,type:Pe.ExecutionResult,inheritanceLink:null}}const n=Ny(o);if(Ty.includes(n.type)){const re=Mu(n,p,i),ee=o.codeName||((m=o.declaration)==null?void 0:m.codeName)||Hi(se(o,p.project));if(re!=null&&re.value&&hr(re.value.value)){const de=re.value.value[ee],le=It(o.getDataType(null),o,p.project);return le==null||le.metaSync({value:de},null),{value:le,valueOwner:o,type:!Gt.includes(n.type)&&re.type===Pe.Empty?Pe.QueuedAutocalculation:re.type,inheritanceLink:{sources:[re],target:o}}}return{value:null,valueOwner:o,type:Gt.includes(n.type)?Pe.Empty:Pe.QueuedAutocalculation,inheritanceLink:null}}const s=(v=p.execution)==null?void 0:v.hasEntity(n),c=((E=p.execution)==null?void 0:E.state)===pN.Running;if((b=p.persistedExecutionResults)!=null&&b.values[o.id]&&!s&&!c&&!i){const re=(w=p.persistedExecutionResults)==null?void 0:w.readValue(o.id);if((re==null?void 0:re.value)!==null||(re==null?void 0:re.valueAsType)!==null)return{value:re,valueOwner:o,type:Pe.ExecutionResult,inheritanceLink:null}}const e=o.parent;if(!e)throw new Error(`Couldn't find the parent that generates the output ${o.id}`);switch(e.type){case d.VariableInstance:{const ee=zP(e,p,i);if(ee&&ee.value){const le=o.declaration;if(hr(ee.value.value)){const fe=ee.value.value[le.name],ve=It(((V=o.declaration)==null?void 0:V.dataType)||null,o,p.project);return ve==null||ve.metaSync({value:fe},null),{value:ve,valueOwner:o,type:Pe.Inherited,inheritanceLink:{sources:[ee],target:o}}}}const de=It((($=o.declaration)==null?void 0:$.dataType)||null,o,p.project);return de==null||de.metaSync({value:null},null),{value:de,valueOwner:o,type:Pe.Inherited,inheritanceLink:{sources:ee?[ee]:[],target:o}}}case d.VariableDeclaration:{const ee=av(e,p,i);if(ee&&ee.value){const le=o.declaration;if(hr(ee.value.value)){const fe=ee.value.value[le.name],ve=It(((L=o.declaration)==null?void 0:L.dataType)||null,o,p.project);return ve==null||ve.metaSync({value:fe},null),{value:ve,valueOwner:o,type:Pe.Inherited,inheritanceLink:{sources:[ee],target:o}}}}const de=It(((k=o.declaration)==null?void 0:k.dataType)||null,o,p.project);return de==null||de.metaSync({value:null},null),{value:de,valueOwner:o,type:Pe.Inherited,inheritanceLink:{sources:ee?[ee]:[],target:o}}}case d.Operation:{const re=e.outputs.map(de=>{var le,fe;if((le=p.persistedExecutionResults)!=null&&le.values[de.id]){const ve=(fe=p.persistedExecutionResults)==null?void 0:fe.values[de.id];if(ve.value!==null||ve.valueAsType!==null)return{value:ve,valueOwner:de,type:Pe.ExecutionResult,inheritanceLink:null}}}).filter(de=>!!de),ee=It(((K=o.declaration)==null?void 0:K.dataType)||null,o,p.project);return ee==null||ee.metaSync({value:null},null),{value:ee,valueOwner:o,type:Pe.QueuedAutocalculation,inheritanceLink:re.length?{sources:re,target:o}:null}}case d.FunctionCall:{const re=e.inputs.map(de=>pA(de,p,i)).filter(de=>!!de),ee=It(((S=o.declaration)==null?void 0:S.dataType)||null,o,p.project);return ee==null||ee.metaSync({value:null},null),{value:ee,valueOwner:o,type:Pe.QueuedAutocalculation,inheritanceLink:re.length?{sources:re,target:o}:null}}case d.Loop:{const re=e.inputs.map(de=>pA(de,p,i)).filter(de=>!!de),ee=It(((Y=o.declaration)==null?void 0:Y.dataType)||null,o,p.project);return ee==null||ee.metaSync({value:null},null),{value:ee,valueOwner:o,type:Pe.QueuedAutocalculation,inheritanceLink:re.length?{sources:re,target:o}:null}}case d.Search:return{value:null,valueOwner:o,type:Pe.QueuedAutocalculation,inheritanceLink:null}}return null}function HO(o,p,i=!1){var b,w,V;if(![...qt,...Gt].includes(o.parent.type)||!xv(o))return null;if(((b=o.declaration)==null?void 0:b.type)===d.Property&&o.declaration.static)return Mu(o.declaration,p);const n=sv(o,p,i);if(n&&n.type!==Pe.Empty&&n.type!==Pe.Missing)return n;const s=Wn(o.parent),c=Ao(s,p,i),e=o.codeName||((w=o.declaration)==null?void 0:w.codeName)||Hi(se(o,p.project)),y=It(o.getDataType(null),o,p.project),m=$o(o),v=(V=c==null?void 0:c.value)==null?void 0:V.value;if(v&&hr(v)){let $=v[e];v[e]===void 0&&($=null),y==null||y.metaSync({value:$},null);const L=$o(o),k=o.getDataType(null);return L&&(!y||!Il(k)&&eu(y))?{value:null,valueOwner:o,type:Pe.Missing,inheritanceLink:null}:{value:y,valueOwner:o,type:c.type,inheritanceLink:{sources:c?[c]:[],target:o}}}return m?{value:null,valueOwner:o,type:Pe.Missing,inheritanceLink:null}:{value:null,valueOwner:o,type:o.readsValue?Pe.Inherited:Pe.Empty,inheritanceLink:null}}function WO(o,p,i=!1){var b,w,V,$,L,k,K,S;if(![...qt,...Gt].includes(o.parent.type)||!xv(o))return null;if(((b=o.declaration)==null?void 0:b.type)===d.Property&&o.declaration.static)return Mu(o.declaration,p,i);const n=qt.includes(o.parent.type)?o.parent:Wn(o.parent),s=Mu(n,p,i);let c=o;n.type===d.VariableDeclaration&&(c=(o.parent===n?o:n.inputs.find(re=>{var ee,de;return((ee=re.declaration)==null?void 0:ee.id)===((de=o.declaration)==null?void 0:de.id)}))||o);const e=Fm(c,p,i),y=o.codeName||((w=o.declaration)==null?void 0:w.codeName)||Hi(se(o,p.project)),m=(n.type===d.VariableDeclaration?o.getDefaultValue():o.defaultValue)||It(o.getDataType(null),o,p.project),v=(V=s==null?void 0:s.value)==null?void 0:V.value;if(((s==null?void 0:s.type)===Pe.ExecutionResult||(s==null?void 0:s.type)===Pe.Testing)&&!i&&v&&hr(v)){let Y=v[y];return v[y]===void 0&&(Y=null),m==null||m.metaSync({value:Y},null),{value:m,valueOwner:o,type:s.type,inheritanceLink:{sources:s?[s]:[],target:o}}}if(e&&e.type!==Pe.Empty&&e.type!==Pe.Missing)return e;if(v&&hr(v)){let Y=v[y];v[y]===void 0&&(Y=null),m!=null&&m.standaloneParent&&(m==null||m.metaSync({value:Y},null));const re=$o(o),ee=o.getDataType(null),de=re&&(!m||!Il(ee)&&eu(m)),le=!!(($=p.execution)!=null&&$.entities.length),fe=(L=p.execution)==null?void 0:L.hasEntity(n),ve=n.readsValue;if(ve){const ue=(k=p.execution)==null?void 0:k.hasEntity(ve);if(de&&(!le||le&&ue&&fe||le&&!ue&&!fe))return{value:null,valueOwner:o,type:Pe.Inherited,inheritanceLink:null}}if(o.readsValue){const ue=(K=p.execution)==null?void 0:K.hasEntity(o.readsValue);if(de&&(!le||le&&ue&&fe||le&&!ue&&!fe))return{value:null,valueOwner:o,type:Pe.Inherited,inheritanceLink:null}}return de?{value:null,valueOwner:o,type:Pe.Missing,inheritanceLink:null}:{value:m,valueOwner:o,type:((S=m==null?void 0:m.parent)==null?void 0:S.id)===(o==null?void 0:o.id)?s.type:Pe.Inherited,inheritanceLink:{sources:s?[s]:[],target:o}}}return Fm(o,p,i)}function sv(o,p,i=!1){var V,$,L,k,K,S;const n=li(o),s=!!((V=p.execution)!=null&&V.entities.length),c=($=p.execution)==null?void 0:$.hasEntity(n),e=o.readsValue;let y=null;if(e){const Y=(L=p.execution)==null?void 0:L.hasEntity(e);(!s||s&&Y&&c||s&&!Y&&!c)&&(y=Lh(o,p,i))}const m=o.getDefaultValue(),v=p.getValueTypePreference(o.id);if(!y&&m&&(i||v===null||v!==Pe.Testing)&&(y={value:m,valueOwner:o,type:un(m)?Pe.Empty:Pe.DefaultValue,inheritanceLink:null}),!y&&o.declaration){const Y=Mu(o.declaration,p,i);Y&&Y.value&&(i||v===null||v!==Pe.Testing)&&(y={...Y,valueOwner:o,type:Pe.DefaultValue})}if(!y||y.type===Pe.DefaultValue||(y==null?void 0:y.type)===Pe.Empty){const Y=(k=p.persistedExecutionResults)==null?void 0:k.readValue(o.id);if(Y&&!i)return{value:Y,valueOwner:o,type:Pe.Testing,inheritanceLink:null};const re=(K=p.localTestValues)==null?void 0:K.readValue(o.id);if(re&&!i&&(v===null||v!==Pe.DefaultValue))return{value:re,valueOwner:o,type:Pe.Testing,inheritanceLink:null}}const E=$o(o),b=o.getDataType(null),w=E&&(!(y!=null&&y.value)||!Il(b)&&eu(y==null?void 0:y.value));if(o.readsValue){const Y=(S=p.execution)==null?void 0:S.hasEntity(o.readsValue);if(w&&(!s||s&&Y&&c||s&&!Y&&!c))return{value:null,valueOwner:o,type:Pe.Inherited,inheritanceLink:null}}return w?{value:null,valueOwner:o,type:Pe.Missing,inheritanceLink:(y==null?void 0:y.inheritanceLink)||null}:!E&&(!y||y.type===Pe.Inherited)&&!(y!=null&&y.inheritanceLink)?{value:null,valueOwner:o,type:o.readsValue?Pe.Inherited:Pe.Empty,inheritanceLink:null}:y}function Fm(o,p,i=!1){var e,y;if(p.execution&&p.execution.hasEntity(o)&&!i){const m=(e=p.lastExecutionResults)==null?void 0:e.readValue(o.id);if(m)return{value:m,valueOwner:o,type:Pe.ExecutionResult,inheritanceLink:null}}const n=(y=p.localTestValues)==null?void 0:y.readValue(o.id),s=p.getValueTypePreference(o.id);return n&&!i&&(s===null||s!==Pe.DefaultValue)?{value:n,valueOwner:o,type:Pe.Testing,inheritanceLink:null}:sv(o,p,i)}function pA(o,p,i=!1){var n,s;return Gt.includes(o.parent.type)&&(n=Wn(o.parent).dataType)!=null&&n.isObject()||qt.includes(o.parent.type)&&(s=o.parent.getDataType(null))!=null&&s.isObject()?HO(o,p,i):sv(o,p,i)}function BOe(o,p,i=!1){var n,s;return Gt.includes(o.parent.type)&&(n=Wn(o.parent).dataType)!=null&&n.isObject()||qt.includes(o.parent.type)&&(s=o.parent.getDataType(null))!=null&&s.isObject()?WO(o,p,i):Fm(o,p,i)}function GOe(o,p,i=!1){var E,b;if(!o.static)return null;if(p.execution){const w=(E=p.lastExecutionResults)==null?void 0:E.readValue(o.id);if(w&&!i)return{value:w,valueOwner:o,type:Pe.ExecutionResult,inheritanceLink:null}}const n=(b=p.localTestValues)==null?void 0:b.readValue(o.id),s=p.getValueTypePreference(o.id);if(n&&!i&&(s===null||s!==Pe.DefaultValue))return{value:n,valueOwner:o,type:Pe.Testing,inheritanceLink:null};const c=o.getDefaultValue();let e=null;c&&(i||s===null||s!==Pe.Testing)&&(e={value:c,valueOwner:o,type:Pe.DefaultValue,inheritanceLink:null});const y=$o(o),m=o.getDataType(null);return y&&(!(e!=null&&e.value)||!Il(m)&&eu(e==null?void 0:e.value))?{value:null,valueOwner:o,type:Pe.Missing,inheritanceLink:null}:un(e==null?void 0:e.value)?{value:null,valueOwner:o,type:Pe.Empty,inheritanceLink:null}:e}function kOe(o,p,i=!1){var E,b;if(p.execution&&p.execution.hasEntity(o)&&!i){const w=(E=p.lastExecutionResults)==null?void 0:E.readValue(o.id);if(w)return{value:w,valueOwner:o,type:Pe.ExecutionResult,inheritanceLink:null}}const n=(b=p.localTestValues)==null?void 0:b.readValue(o.id),s=p.getValueTypePreference(o.id);if(n&&!i&&(s===null||s!==Pe.DefaultValue))return{value:n,valueOwner:o,type:Pe.Testing,inheritanceLink:null};const c=o.getDefaultValue();let e=null;c&&(i||s===null||s!==Pe.Testing)&&(e={value:c,valueOwner:o,type:Pe.DefaultValue,inheritanceLink:null});const y=$o(o),m=o.getDataType(null);return y&&(!(e!=null&&e.value)||!Il(m)&&eu(e==null?void 0:e.value))?{value:null,valueOwner:o,type:Pe.Missing,inheritanceLink:null}:un((e==null?void 0:e.value)||null)?{value:null,valueOwner:o,type:Pe.Empty,inheritanceLink:null}:e}function Mu(o,p,i=!1){switch(o.type){case d.ArgumentDeclaration:return LOe(o,p,i);case d.InputMap:return BOe(o,p,i);case d.VariableDeclaration:return WP(o,p,i);case d.VariableInstance:return $Oe(o,p,i);case d.OutputMap:return MOe(o,p,i);case d.ReturnStatement:case d.BreakStatement:case d.ContinueStatement:return JP(o,p,i);case d.Property:return GOe(o,p,i);case d.ValueDescriptor:return kOe(o,p,i);case d.Operation:case d.FunctionCall:case d.InternalCall:case d.Search:return NOe(o,p,i);default:return null}}function Ao(o,p,i=!1){switch(o.type){case d.InputMap:return pA(o,p,i);case d.VariableDeclaration:return av(o,p,i);case d.VariableInstance:return zP(o,p,i);case d.ReturnStatement:case d.BreakStatement:case d.ContinueStatement:return JP(o,p,i);default:return null}}function Tvi(o){var p;if(o&&o.type===Pe.DefaultValue&&o.value&&o.valueOwner&&(!kA.includes(o.valueOwner.type)||((p=o.valueOwner.getDefaultValue())==null?void 0:p.id)===o.value.id)){const i=It(o.valueOwner.getDataType(null),o.valueOwner,o.valueOwner.project);return{type:Pe.DefaultValue,value:i,valueOwner:o.valueOwner,inheritanceLink:null}}return o}function Rc(o,p,i,n){let s=!1,c=null,e=null;n instanceof Z?(s=!0,c=n,e=null):(c=null,e=n);const y=o.parent;return p.getVariableDeclarations().forEach(v=>{var b,w,V,$,L,k;const E=v.getDataType(null);if(((b=E==null?void 0:E.entity)==null?void 0:b.id)===y.id){let K=s?v.getDefaultValue():e==null?void 0:e.readValue(v.id);K?!s&&K&&K.id===((w=v.getDefaultValue())==null?void 0:w.id)&&(K=It(v.getDataType(null),v,p)):s?K=Qd(v.getDataType(null),v,p,c):K=It(v.getDataType(null),v,p);const S=se(o,p),Y=o.codeName||((V=o.extends)==null?void 0:V.codeName)||(($=o.implements[0])==null?void 0:$.codeName)||Hi(S);let re={};((k=(L=v.dataType)==null?void 0:L.entity)==null?void 0:k.type)===d.DefinitionEntity&&(re={...re,...v.dataType.entity.getActiveRawDefaultValue()}),hr(K==null?void 0:K.value)&&(re={...re,...K.value}),re[Y]=i,K==null||K.metaSync({value:re},c),s||e==null||e.writeValue(v,K);return}}),c}function Sm(o,p,i,n){var V,$,L,k;let s=!1,c=null,e=null;n instanceof Z?(s=!0,c=n,e=null):(c=null,e=n);const y=Wn(o.parent),m=y.getDataType(null);if(!(m!=null&&m.isObject()))return c;let v=s?y.getDefaultValue():e==null?void 0:e.readValue(y.id);v?!s&&v&&v.id===((V=y.getDefaultValue())==null?void 0:V.id)&&(v=It(y.getDataType(null),y,p)):s?v=Qd(y.getDataType(null),y,p,c):v=It(y.getDataType(null),y,p);const E=se(o,p),b=o.codeName||(($=o.declaration)==null?void 0:$.codeName)||Hi(E);let w={};if(((k=(L=y.dataType)==null?void 0:L.entity)==null?void 0:k.type)===d.DefinitionEntity&&(w={...w,...y.dataType.entity.getActiveRawDefaultValue()}),hr(v==null?void 0:v.value)&&(w={...w,...v.value}),w[b]=i,v==null||v.metaSync({value:w},c),s||e==null||e.writeValue(y,v),(i===""||i===null||i===void 0)&&o.type===d.OutputMap){const K=y.inputs.find(S=>{var Y,re;return((Y=S.declaration)==null?void 0:Y.id)===((re=o.declaration)==null?void 0:re.id)||se(S,p)===E});if(K){let S=s?K.getDefaultValue():e==null?void 0:e.readValue(K.id);S&&S.metaSync({value:null},c),s||e==null||e.removeValue(K.id)}}return c}function jOe(o,p,i){var e,y,m,v,E;let n=!1,s=null,c=null;if(i instanceof Z?(n=!0,s=i,c=null):(s=null,c=i),Gt.includes(o.type)){const b=Wn(o);(e=b.dataType)!=null&&e.isObject()&&b.inputs.forEach(w=>{var V,$,L,k,K,S;if(((V=w.declaration)==null?void 0:V.type)===d.Property&&w.declaration.static){let Y=n?(($=w.getDefaultValue)==null?void 0:$.call(w))||null:c==null?void 0:c.readValue(w.declaration.id);Y?!n&&Y&&Y.id===((L=w.declaration.getDefaultValue())==null?void 0:L.id)&&(Y=It(w.declaration.getDataType(null),w.declaration,p)):n?Y=Qd(w.declaration.getDataType(null),w.declaration,p,s):Y=It(w.declaration.getDataType(null),w.declaration,p),Y==null||Y.metaSync({value:null},s),n||c==null||c.removeValue((k=w.declaration)==null?void 0:k.id)}else if(((K=w.declaration)==null?void 0:K.type)===d.Property){let Y=n?((S=w.getDefaultValue)==null?void 0:S.call(w))||null:c==null?void 0:c.readValue(w.id);Y&&Y.metaSync({value:null},s),n||c==null||c.removeValue(w.id)}})}else o.type===d.InputMap?((y=o.declaration)==null?void 0:y.type)===d.Property&&o.declaration.static?Rc(o.declaration,p,null,i):Gt.includes(o.parent.type)&&((m=o.declaration)==null?void 0:m.type)===d.Property&&Sm(o,p,null,i):o.type===d.OutputMap?((v=o.declaration)==null?void 0:v.type)===d.Property&&o.declaration.static?Rc(o.declaration,p,null,i):Gt.includes(o.parent.type)&&((E=o.declaration)==null?void 0:E.type)===d.Property&&Sm(o,p,null,i):o.type===d.Property&&o.static&&Rc(o,p,null,i);return s}function UOe(o,p,i,n){var y,m,v,E,b,w,V;let s=!1,c=null,e=null;if(n instanceof Z?(s=!0,c=n,e=null):(c=null,e=n),Gt.includes(p.type)){const $=Wn(p);if((y=$.dataType)!=null&&y.isObject()){let L={};((v=(m=$.dataType)==null?void 0:m.entity)==null?void 0:v.type)===d.DefinitionEntity&&(L={...L,...$.dataType.entity.getActiveRawDefaultValue()});const k=hr(o)?o:L;$.inputs.forEach(K=>{var S,Y,re,ee,de,le;if(((S=K.declaration)==null?void 0:S.type)===d.Property&&K.declaration.static){let fe=s?((Y=p.getDefaultValue)==null?void 0:Y.call(p))||null:e==null?void 0:e.readValue(K.declaration.id);fe?!s&&fe&&fe.id===((re=K.declaration.getDefaultValue())==null?void 0:re.id)&&(fe=It(K.declaration.getDataType(null),K.declaration,i)):s?fe=Qd(K.declaration.getDataType(null),K.declaration,i,c):fe=It(K.declaration.getDataType(null),K.declaration,i);const ve=se(K,i),ue=K.codeName||((ee=K.declaration)==null?void 0:ee.codeName)||Hi(ve),ye=k[ue];fe==null||fe.metaSync({value:ye},c),s||e==null||e.writeValue(K.declaration,fe)}else if(((de=K.declaration)==null?void 0:de.type)===d.Property){let fe=s?((le=p.getDefaultValue)==null?void 0:le.call(p))||null:e==null?void 0:e.readValue(K.id);fe&&fe.metaSync({value:null},c),s||e==null||e.removeValue(K.id)}})}}else p.type===d.InputMap?((E=p.declaration)==null?void 0:E.type)===d.Property&&p.declaration.static?Rc(p.declaration,i,o,n):Gt.includes(p.parent.type)&&((b=p.declaration)==null?void 0:b.type)===d.Property&&Sm(p,i,o,n):p.type===d.OutputMap?((w=p.declaration)==null?void 0:w.type)===d.Property&&p.declaration.static?Rc(p.declaration,i,null,n):Gt.includes(p.parent.type)&&((V=p.declaration)==null?void 0:V.type)===d.Property&&Sm(p,i,null,n):p.type===d.Property&&p.static&&Rc(p,i,o,n);return c}function vvi(o,p,i){const n=Oo(o,p);let s=!1,c=null,e=null;return i instanceof Z?(s=!0,c=i,e=null):(c=null,e=i),n.forEach(y=>{var v;let m=s?((v=y.getDefaultValue)==null?void 0:v.call(y))||null:e==null?void 0:e.readValue(y.id);s?m==null||m.remove({ignoreUpstream:!1},c):e==null||e.removeValue(y.id),jOe(y,p,i)}),c}function Evi(o,p,i,n){const s=Oo(p,i);let c=!1,e=null,y=null;return n instanceof Z?(c=!0,e=n,y=null):(e=null,y=n),i.diggestedBuiltInBaseEntitiesIds.has(p.id)||s.forEach(m=>{var E,b,w,V;if(i.diggestedBuiltInBaseEntitiesIds.has(m.id))return;let v=null;if(c){const $=((E=m.getDefaultValue)==null?void 0:E.call(m))||null;$&&(i.diggestedBuiltInBaseEntitiesIds.has($.id)||((b=$.parent)==null?void 0:b.id)!==m.id?v=$.clone(e,m):v=$)}else v=y==null?void 0:y.readValue(m.id);v?!c&&v&&v.id===((V=(w=m.getDefaultValue)==null?void 0:w.call(m))==null?void 0:V.id)&&(v=It(m.getDataType(null),m,i)):c?(v=Qd(m.getDataType(null),m,i,e),e==null||e.add(v,H.Added)):v=It(m.getDataType(null),m,i),v==null||v.setValueAsType(null,e),v==null||v.metaSync({value:o},e),c||y==null||y.writeValue(m,v),UOe(o,m,i,n)}),e}function Dc(o,p,i,n){let s=!1,c=null,e=null;n instanceof Z?(s=!0,c=n,e=null):(c=null,e=n);const y=o.parent;return p.getVariableDeclarations().forEach(v=>{var b,w,V,$,L,k;const E=v.getDataType(null);if(((b=E==null?void 0:E.entity)==null?void 0:b.id)===y.id){let K=s?v.getDefaultValue():e==null?void 0:e.readValue(v.id);K?!s&&K&&K.id===((w=v.getDefaultValue())==null?void 0:w.id)&&(K=It(v.getDataType(null),v,p)):s?K=Qd(v.getDataType(null),v,p,c):K=It(v.getDataType(null),v,p);const S=se(o,p),Y=o.codeName||((V=o.extends)==null?void 0:V.codeName)||(($=o.implements[0])==null?void 0:$.codeName)||Hi(S);let re={};((k=(L=v.dataType)==null?void 0:L.entity)==null?void 0:k.type)===d.DefinitionEntity&&(re={...re,...v.dataType.entity.getActiveRawDefaultValue()}),hr(K==null?void 0:K.value)&&(re={...re,...K.value}),Array.isArray(i)?re[Y]=(i==null?void 0:i.map(ee=>ee.toShallowJSON()))||null:re[Y]=(i==null?void 0:i.toShallowJSON())||null,K==null||K.metaSync({value:re},c),s||e==null||e.writeValue(v,K);return}}),c}function qm(o,p,i,n){var V,$,L,k;let s=!1,c=null,e=null;n instanceof Z?(s=!0,c=n,e=null):(c=null,e=n);const y=Wn(o.parent),m=y.getDataType(null);if(!(m!=null&&m.isObject()))return c;let v=s?y.getDefaultValue():e==null?void 0:e.readValue(y.id);v?!s&&v&&v.id===((V=y.getDefaultValue())==null?void 0:V.id)&&(v=It(y.getDataType(null),y,p)):s?v=Qd(y.getDataType(null),y,p,c):v=It(y.getDataType(null),y,p);const E=se(o,p),b=o.codeName||(($=o.declaration)==null?void 0:$.codeName)||Hi(E);let w={};if(((k=(L=y.dataType)==null?void 0:L.entity)==null?void 0:k.type)===d.DefinitionEntity&&(w={...w,...y.dataType.entity.getActiveRawDefaultValue()}),hr(v==null?void 0:v.value)&&(w={...w,...v.value}),Array.isArray(i)?w[b]=(i==null?void 0:i.map(K=>K.toShallowJSON()))||null:w[b]=(i==null?void 0:i.toShallowJSON())||null,v==null||v.metaSync({value:w},c),s||e==null||e.writeValue(y,v),i==null&&o.type===d.OutputMap){const K=y.inputs.find(S=>{var Y,re;return((Y=S.declaration)==null?void 0:Y.id)===((re=o.declaration)==null?void 0:re.id)||se(S,p)===E});if(K){let S=s?K.getDefaultValue():e==null?void 0:e.readValue(K.id);S&&(Array.isArray(i)?S==null||S.setValueAsTypeList(i,c):S==null||S.setValueAsTypeSingle(i,c)),s||e==null||e.removeValue(K.id)}}return c}function KOe(o,p,i){var n,s,c,e;return o.type===d.InputMap?((n=o.declaration)==null?void 0:n.type)===d.Property&&o.declaration.static?Dc(o.declaration,p,null,i):Gt.includes(o.parent.type)&&((s=o.declaration)==null?void 0:s.type)===d.Property&&qm(o,p,null,i):o.type===d.OutputMap?((c=o.declaration)==null?void 0:c.type)===d.Property&&o.declaration.static?Dc(o.declaration,p,null,i):Gt.includes(o.parent.type)&&((e=o.declaration)==null?void 0:e.type)===d.Property&&qm(o,p,null,i):o.type===d.Property&&o.static&&Dc(o,p,null,i),i}function FOe(o,p,i,n){var s,c,e,y;return p.type===d.InputMap?((s=p.declaration)==null?void 0:s.type)===d.Property&&p.declaration.static?Dc(p.declaration,i,o,n):Gt.includes(p.parent.type)&&((c=p.declaration)==null?void 0:c.type)===d.Property&&qm(p,i,o,n):p.type===d.OutputMap?((e=p.declaration)==null?void 0:e.type)===d.Property&&p.declaration.static?Dc(p.declaration,i,null,n):Gt.includes(p.parent.type)&&((y=p.declaration)==null?void 0:y.type)===d.Property&&qm(p,i,null,n):p.type===d.Property&&p.static&&Dc(p,i,o,n),n}function bvi(o,p,i){const n=Oo(o,p);let s=!1,c=null,e=null;return i instanceof Z?(s=!0,c=i,e=null):(c=null,e=i),n.forEach(y=>{var v;let m=s?(v=y.getDefaultValue)==null?void 0:v.call(y):e==null?void 0:e.readValue(y.id);s?m==null||m.remove({ignoreUpstream:!1},c):e==null||e.removeValue(y.id),KOe(y,p,i)}),c}function Avi(o,p,i,n){const s=Oo(p,i);let c=!1,e=null,y=null;return n instanceof Z?(c=!0,e=n,y=null):(e=null,y=n),s.forEach(m=>{var E,b,w;let v=c?(E=m.getDefaultValue)==null?void 0:E.call(m):y==null?void 0:y.readValue(m.id);v?!c&&v&&v.id===((w=(b=m.getDefaultValue)==null?void 0:b.call(m))==null?void 0:w.id)&&(v=It(m.getDataType(null),m,m.project)):c?v=Qd(m.getDataType(null),m,i,e):v=It(m.getDataType(null),m,i),Array.isArray(o)?v==null||v.setValueAsTypeList(o,e):v==null||v.setValueAsTypeSingle(o,e),v==null||v.metaSync({value:null},e),c||y==null||y.writeValue(m,v),FOe(o,m,i,n)}),e}class SI{constructor(p,i){this.extensionsRegistry=p,this.contextType=i,this.off=this.extensionsRegistry.off.bind(this.extensionsRegistry),this.on=this.extensionsRegistry.on.bind(this.extensionsRegistry),this.emit=this.extensionsRegistry.emit.bind(this.extensionsRegistry),this.emitAsync=this.extensionsRegistry.emitAsync.bind(this.extensionsRegistry),this.emitAsyncAll=this.extensionsRegistry.emitAsyncAll.bind(this.extensionsRegistry),this.emitAsyncAllSettled=this.extensionsRegistry.emitAsyncAllSettled.bind(this.extensionsRegistry),this.emitAsyncSequentially=this.extensionsRegistry.emitAsyncSequentially.bind(this.extensionsRegistry),this.emitAsyncSequentiallyAll=this.extensionsRegistry.emitAsyncSequentiallyAll.bind(this.extensionsRegistry),this.emitAsyncSequentiallyAllSettled=this.extensionsRegistry.emitAsyncSequentiallyAllSettled.bind(this.extensionsRegistry)}on(p,i){this.extensionsRegistry.on(p,i)}emit(p,...i){this.extensionsRegistry.emit(p,...i)}off(p,i){this.extensionsRegistry.off(p,i)}emitAsync(p,...i){return this.extensionsRegistry.emitAsync(p,...i)}emitAsyncAll(p,...i){return this.extensionsRegistry.emitAsyncAll(p,...i)}emitAsyncAllSettled(p,...i){return this.extensionsRegistry.emitAsyncAllSettled(p,...i)}emitAsyncSequentially(p,...i){return this.extensionsRegistry.emitAsyncSequentially(p,...i)}emitAsyncSequentiallyAll(p,...i){return this.extensionsRegistry.emitAsyncSequentiallyAll(p,...i)}emitAsyncSequentiallyAllSettled(p,...i){return this.extensionsRegistry.emitAsyncSequentiallyAllSettled(p,...i)}}var Ee=(o=>(o[o.High=1]="High",o[o.Normal=5]="Normal",o[o.Low=10]="Low",o))(Ee||{}),X=(o=>(o.Logic="logic",o.EditorGUI="editor-gui",o.GUI="gui",o.Editor="editor",o.Compile="compile",o.PublicationRun="publication-run",o))(X||{}),be=(o=>(o.All="*",o.OnAll="on:*",o.EmitAll="emit:*",o.ReadAll="read:*",o.WriteAll="write:*",o.UpdateAll="update:*",o.DoAll="do:*",o.OnLogicAll="on:logic:*",o.EmitLogicAll="emit:logic:*",o.ReadLogicAll="read:logic:*",o.WriteLogicAll="write:logic:*",o.UpdateLogicAll="update:logic:*",o.DoLogicAll="do:logic:*",o.OnGUIAll="on:gui:*",o.EmitGUIAll="emit:gui:*",o.ReadGUIAll="read:gui:*",o.WriteGUIAll="write:gui:*",o.UpdateGUIAll="update:gui:*",o.DoGUIAll="do:gui:*",o.OnEditorAll="on:editor:*",o.EmitEditorAll="emit:editor:*",o.ReadEditorAll="read:editor:*",o.WriteEditorAll="write:editor:*",o.UpdateEditorAll="update:editor:*",o.DoEditorAll="do:editor:*",o.OnCompileBefore="on:compile:before:DefinitionEntity",o.OnCompileDefault="on:compile:default:DefinitionEntity",o.OnCompileAfter="on:compile:after:DefinitionEntity",o.EmitCompile="emit:compile:DefinitionEntity",o.DoEditorPublish="do:editor:publish",o.PostGUICanvasSlotNewToolbarButton="write:gui:canvas:slot:toolbar-button",o.ReadGUICanvasSlotToolbarButtons="read:gui:canvas:slot:toolbar-buttons",o.UpdateGUIGlobalTheme="update:gui:global:theme",o))(be||{});class SOe{constructor(p){I(this,"state",new Map);p&&(this.state=new Map(Object.entries(p)))}get(p){return this.state.get(p)}set(p,i){this.state.set(p,i)}delete(p){this.state.delete(p)}}class qOe extends SOe{constructor(p,i){super(i),this.parentExtension=p}}class ge{constructor(p,i){I(this,"manifest");I(this,"module");I(this,"state");this.extensionsRegistry=p,this.state=new qOe(this,i)}}class zO extends SI{constructor(i,n){super(i,X.Logic);I(this,"id");this._project=n,this.id=n.id}get type(){return this._project.type}get name(){return this._project.name}get description(){return this._project.description}get version(){return this._project.version}get createdAt(){return this._project.createdAt}get previousVersion(){return this._project.previousVersion}get author(){return this._project.author}get deleted(){return this._project.deleted}get editable(){return this._project.editable}get deletable(){return this._project.deletable}get entities(){return[...this._project.entities]}get projects(){return[...this._project.projects]}get functions(){return[...this._project.functions]}get events(){return[...this._project.events]}get variableDeclarations(){return[...this._project.variableDeclarations]}get variableInstances(){return[...this._project.variableInstances]}get conditions(){return[...this._project.conditions]}get operations(){return[...this._project.operations]}get functionCalls(){return[...this._project.functionCalls]}get loops(){return[...this._project.loops]}get searches(){return[...this._project.searches]}get primitives(){return[...this._project.primitives]}get builtInBaseEntities(){return[...this._project.builtInBaseEntities]}get operationDeclarations(){return[...this._project.operationDeclarations]}get globalEventActionDescriptors(){return[...this._project.globalEventActionDescriptors]}get loopDeclarations(){return[...this._project.loopDeclarations]}get loopDeclarationsBodies(){return[...this._project.loopDeclarationsBodies]}get conditionDeclarations(){return[...this._project.conditionDeclarations]}get valueDescriptors(){return[...this._project.valueDescriptors]}get dataTypes(){return[...this._project.dataTypes]}get errors(){return[...this._project.errors]}get history(){return[...this._project.history]}get undoableStackValueIndex(){return this._project.undoableStackValueIndex}get knownVersions(){return this._project.knownVersions}get activeVersion(){return this._project.activeVersion}get initialized(){return this._project.initialized}get startedInitialization(){return this._project.startedInitialization}closePersistChangeSetsSequentially(){return this._project.closePersistChangeSetsSequentially()}persistChangeSetSequentially(i){return this._project.persistChangeSetSequentially(i)}toLatestChangeSet(i,n,s,c=!1,e="here-this"){return this._project.toLatestChangeSet(i,n,s,c,e)}addChangeSet(i){return this._project.addChangeSet(i)}discardChangeSet(i){return this._project.discardChangeSet(i)}subscribeDependents(i){return this._project.subscribeDependents(i)}unsubscribeDependents(i){return this._project.unsubscribeDependents(i)}syncDependents(i){return this._project.syncDependents(i)}onDetachedDependencyRemoved(i,n,s){return this._project.onDetachedDependencyRemoved(i,n,s)}onDetachedDependencyRestored(i,n,s){return this._project.onDetachedDependencyRestored(i,n,s)}increaseVersion(i){return this._project.increaseVersion(i)}captureVersion(){return this._project.captureVersion()}restoreVersion(i){return this._project.restoreVersion(i)}updateWithShallowTransfer(i,n){return this._project.updateWithShallowTransfer(i,n)}hydrateAncestors(){return this._project.hydrateAncestors()}afterAllChildrenInitialized(i=null){return this._project.afterAllChildrenInitialized(i)}addSelfToProject(i){return this._project.addSelfToProject(i)}get instancesList(){return[...this._project.instancesList]}isOperationDeclaration(i){return this._project.isOperationDeclaration(i)}isGlobalEventActionDescriptor(i){return this._project.isGlobalEventActionDescriptor(i)}isLoopDeclaration(i){return this._project.isLoopDeclaration(i)}isConditionDeclaration(i){return this._project.isConditionDeclaration(i)}findSubscribedBuiltInInstance(i){return this._project.findSubscribedBuiltInInstance(i)}get(i){return this._project.get(i)}getDeleted(i){return this._project.getDeleted(i)}getManaged(i){return this._project.getManaged(i)}getBuiltIn(i){return this._project.getBuiltIn(i)}findSubscribedInstanceFromReference(i){return this._project.findSubscribedInstanceFromReference(i)}findSubscribedBuiltInInstanceFromReference(i){return this._project.findSubscribedBuiltInInstanceFromReference(i)}metaSync(i,n){return this._project.metaSync(i,n)}getAllBuiltInIds(){return this._project.getAllBuiltInIds()}getAllBuiltIn(){return this._project.getAllBuiltIn()}toFlat(i){return this._project.toFlat(i)}toFlatIds(i){return this._project.toFlatIds(i)}toMeta(){return this._project.toMeta()}toJSON(i){return this._project.toJSON(i)}toJSONClone(i){return this._project.toJSONClone(i)}toReference(i){return this._project.toReference(i)}toShallowJSON(i){return this._project.toShallowJSON(i)}toFlatJSON(i){return this._project.toFlatJSON(i)}toGenerationTarget(){return this._project.toGenerationTarget()}toFlatGenerationTarget(i){return this._project.toFlatGenerationTarget(i)}clearErrors(){return this._project.clearErrors()}validate(){return this._project.validate()}validateChildren(){return this._project.validateChildren()}getErrors(){return this._project.getErrors()}getShallowErrors(){return this._project.getShallowErrors()}getDefinitionEntity(i){return this._project.getDefinitionEntity(i)}addDefinitionEntity(i){return this._project.addDefinitionEntity(i)}addFunctionDeclaration(i){return this._project.addFunctionDeclaration(i)}addFunctionCall(i){return this._project.addFunctionCall(i)}addVariableDeclaration(i){return this._project.addVariableDeclaration(i)}addVariableInstance(i){return this._project.addVariableInstance(i)}addInstalledProject(i){return this._project.addInstalledProject(i)}addGlobalEvent(i){return this._project.addGlobalEvent(i)}addCondition(i){return this._project.addCondition(i)}addOperation(i){return this._project.addOperation(i)}addLoop(i){return this._project.addLoop(i)}addSearch(i){return this._project.addSearch(i)}removeDefinitionEntity(i){return this._project.removeDefinitionEntity(i)}removeCondition(i){return this._project.removeCondition(i)}removeOperation(i){return this._project.removeOperation(i)}removeLoop(i){return this._project.removeLoop(i)}removeSearch(i){return this._project.removeSearch(i)}removeFunctionCall(i){return this._project.removeFunctionCall(i)}removeVariableInstance(i){return this._project.removeVariableInstance(i)}removeVariableDeclaration(i){return this._project.removeVariableDeclaration(i)}removeFunctionDeclaration(i){return this._project.removeFunctionDeclaration(i)}removeInstalledProject(i){return this._project.removeInstalledProject(i)}removeGlobalEvent(i){return this._project.removeGlobalEvent(i)}removeTopLevelVariableDeclaration(i){return this._project.removeTopLevelVariableDeclaration(i)}getEntryPoints(){return this._project.getEntryPoints()}getTerminationStatements(){return this._project.getTerminationStatements()}getFunctionDeclaration(i){return this._project.getFunctionDeclaration(i)}getConditions(){return this._project.getConditions()}getOperations(){return this._project.getOperations()}getVariables(){return this._project.getVariables()}getVariableInstances(){return this._project.getVariableInstances()}getVariableDeclarations(){return this._project.getVariableDeclarations()}getLoops(){return this._project.getLoops()}getSearches(){return this._project.getSearches()}getBuiltInPersistedEntity(){return this._project.getBuiltInPersistedEntity()}requestActiveDynamicValue(i,n=!1){return this._project.requestActiveDynamicValue(i,n)}undo(){return this._project.undo()}redo(){return this._project.redo()}applyExternalChangeSet(i){return this._project.applyExternalChangeSet(i)}toFullProjectTransfer(){return this._project.toFullProjectTransfer()}}function gvi(o,p){return p instanceof zO?p:new zO(o,p)}const uy="built-in-function-implementations__",Oe="operations-implementations__",Na="conditions-implementations__",Ae={UUID:"uuid",SEARCH_NODE_IMPLEMENTATION:"search-node-implementation",BUILT_IN_FUNCTION_IMPLEMENTATIONS__ABORT_EXECUTION:uy+br.AbortExecution,BUILT_IN_FUNCTION_IMPLEMENTATIONS__CREATE_PERSISTED_ENTITY:uy+br.CreatePersistedEntity,BUILT_IN_FUNCTION_IMPLEMENTATIONS__UPDATE_PERSISTED_ENTITY:uy+br.UpdatePersistedEntity,BUILT_IN_FUNCTION_IMPLEMENTATIONS__DELETE_PERSISTED_ENTITY:uy+br.DeletePersistedEntity,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__COMPARISON_EMPTY:Oe+xt.Empty,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__COMPARISON_NOT_EMPTY:Oe+xt.NotEmpty,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__COMPARISON_PRIMITIVE_EQUAL:Oe+xt.PrimitiveEqual,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__COMPARISON_PRIMITIVE_NOT_EQUAL:Oe+xt.PrimitiveNotEqual,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__HTTP_REQUEST:Oe+zn.HttpRequest,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__VALIDATE_ENTITY:Oe+Ce.Validate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__EXECUTE_SEQUENTIAL:Oe+Ki.Sequential,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__EXECUTE_PARALLEL:Oe+Ki.Parallel,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__EXECUTE_WAIT:Oe+Ki.Wait,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_JOIN:Oe+ie.Join,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_SPLIT:Oe+ie.Split,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_DELETE_LAST_N_ITEMS:Oe+ie.DeleteLastNItems,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_DELETE_FIRST_N_ITEMS:Oe+ie.DeleteFirstNItems,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_DELETE_AT_INDEX:Oe+ie.DeleteAtIndex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_ADD_AT_INDEX:Oe+ie.AddAtIndex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_FIRST_N_ITEMS:Oe+ie.ReplaceFirstNItems,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_LAST_N_ITEMS:Oe+ie.ReplaceLastNItems,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_ALL:Oe+ie.ReplaceAll,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_AT_INDEX:Oe+ie.ReplaceAtIndex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_INDEX_ITEM:Oe+ie.GetIndexItem,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_FIRST:Oe+ie.GetFirst,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_LAST:Oe+ie.GetLast,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_APPEND:Oe+ie.Append,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_PREPEND:Oe+ie.Prepend,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REVERSE:Oe+ie.Reverse,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_LENGTH:Oe+ie.GetLength,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_FIRST_N_ITEMS:Oe+ie.GetFirstNItems,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_LAST_N_ITEMS:Oe+ie.GetLastNItems,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_SLICE:Oe+ie.Slice,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CONCAT:Oe+ie.Concat,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_INDEX_OF:Oe+ie.GetIndexOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_LAST_INDEX_OF:Oe+ie.GetLastIndexOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_UNIQUE:Oe+ie.Unique,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_FLATTEN:Oe+ie.Flatten,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_SORT:Oe+ie.Sort,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_SHUFFLE:Oe+ie.Shuffle,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CHUNK:Oe+ie.Chunk,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_PAD_START:Oe+ie.PadStart,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_PAD_END:Oe+ie.PadEnd,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPEAT:Oe+ie.Repeat,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_LENGTH:Oe+q.GetLength,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TO_LOWER_CASE:Oe+q.ToLowerCase,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TO_UPPER_CASE:Oe+q.ToUpperCase,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_JOIN:Oe+q.Join,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CONTAINS:Oe+ie.Contains,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CONTAINS_ALL:Oe+ie.ContainsAll,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CONTAINS_ANY:Oe+ie.ContainsAny,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SPLIT_AT_INDEX:Oe+q.SplitAtIndex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SPLIT_AT_ALL_SEPARATORS:Oe+q.SplitAtAllSeparators,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SPLIT_AT_FIRST_SEPARATOR:Oe+q.SplitAtFirstSeparator,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SPLIT_AT_LAST_SEPARATOR:Oe+q.SplitAtLastSeparator,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_DELETE_LAST_N_CHARS:Oe+q.DeleteLastNChars,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_DELETE_FIRST_N_CHARS:Oe+q.DeleteFirstNChars,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_DELETE_AT_INDEX:Oe+q.DeleteAtIndex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_ADD_AT_INDEX:Oe+q.AddAtIndex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_FIRST_N_CHARS:Oe+q.ReplaceFirstNChars,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_LAST_N_CHARS:Oe+q.ReplaceLastNChars,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_AT_INDEX:Oe+q.ReplaceAtIndex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_FIRST_MATCH:Oe+q.ReplaceFirstMatch,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_LAST_MATCH:Oe+q.ReplaceLastMatch,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_ALL_MATCHES:Oe+q.ReplaceAllMatches,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_INDEX_ITEM:Oe+q.GetIndexItem,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_FIRST_N_CHARS:Oe+q.GetFirstNChars,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_LAST_N_CHARS:Oe+q.GetLastNChars,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_INDEX_OF:Oe+q.GetIndexOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_APPEND:Oe+q.Append,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_PREPEND:Oe+q.Prepend,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REVERSE:Oe+q.Reverse,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TRIM:Oe+q.Trim,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TRIM_START:Oe+q.TrimStart,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TRIM_END:Oe+q.TrimEnd,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SUBSTRING:Oe+q.Substring,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SLICE:Oe+q.Slice,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_PAD_START:Oe+q.PadStart,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_PAD_END:Oe+q.PadEnd,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPEAT:Oe+q.Repeat,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_LAST_INDEX_OF:Oe+q.GetLastIndexOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_MATCH_REGEX:Oe+q.MatchRegex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_MATCH_ALL_REGEX:Oe+q.MatchAllRegex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SEARCH_REGEX:Oe+q.SearchRegex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_REGEX:Oe+q.ReplaceRegex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_NORMALIZE_UNICODE:Oe+q.NormalizeUnicode,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REMOVE_DIACRITICS:Oe+q.RemoveDiacritics,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_COUNT_OCCURRENCES:Oe+q.CountOccurrences,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_ENSURE_PREFIX:Oe+q.EnsurePrefix,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_ENSURE_SUFFIX:Oe+q.EnsureSuffix,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REMOVE_PREFIX:Oe+q.RemovePrefix,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REMOVE_SUFFIX:Oe+q.RemoveSuffix,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ADDITION:Oe+te.Addition,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SUBTRACTION:Oe+te.Subtraction,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MULTIPLICATION:Oe+te.Multiplication,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_DIVISION:Oe+te.Division,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_REMAINDER:Oe+te.Remainder,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_EXPONENTIATION:Oe+te.Exponentiation,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ABSOLUTE:Oe+te.Absolute,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SIGN:Oe+te.Sign,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ROUND:Oe+te.Round,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_NEGATE:Oe+te.Negate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_FLOOR:Oe+te.Floor,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_CEIL:Oe+te.Ceil,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_CLAMP:Oe+te.Clamp,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_TRUNC:Oe+te.Trunc,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ROUND_TO_DECIMALS:Oe+te.RoundToDecimals,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SNAP_TO_STEP:Oe+te.SnapToStep,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MAP_RANGE:Oe+te.MapRange,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_AVERAGE:Oe+te.Average,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MEDIAN:Oe+te.Median,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MIN_OF:Oe+te.MinOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MAX_OF:Oe+te.MaxOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SQUARE_ROOT:Oe+te.SquareRoot,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_CUBE_ROOT:Oe+te.CubeRoot,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_NTH_ROOT:Oe+te.NthRoot,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_EXP:Oe+te.Exp,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_LOG_NATURAL:Oe+te.LogNatural,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_LOG10:Oe+te.Log10,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SIN:Oe+te.Sin,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_COS:Oe+te.Cos,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_TAN:Oe+te.Tan,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ASIN:Oe+te.Asin,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ACOS:Oe+te.Acos,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ATAN:Oe+te.Atan,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ATAN2:Oe+te.Atan2,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_TO_RADIANS:Oe+te.ToRadians,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_TO_DEGREES:Oe+te.ToDegrees,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_PERCENT_OF:Oe+te.PercentOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_PERCENTAGE_CHANGE:Oe+te.PercentageChange,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MORE_THAN:Oe+te.MoreThan,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_LESS_THAN:Oe+te.LessThan,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_LESS_THAN_OR_EQUAL:Oe+te.LessThanOrEqual,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MORE_THAN_OR_EQUAL:Oe+te.MoreThanOrEqual,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_INTEGER:Oe+et.GenerateRandomInteger,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_FLOAT:Oe+et.GenerateRandomFloat,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_HEXADECIMAL:Oe+et.GenerateRandomHexadecimal,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_BASE62:Oe+et.GenerateRandomBase62,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_BASE64:Oe+et.GenerateRandomBase64,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_ALPHANUMERIC:Oe+et.GenerateRandomAlphanumeric,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_IDENTIFIER:Oe+et.GenerateIdentifier,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_UUIDV4:Oe+et.GenerateRandomUUIDv4,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_SHORT_IDENTIFIER:Oe+et.GenerateShortIdentifier,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_HEXADECIMAL_TOKEN:Oe+et.GenerateHexadecimalToken,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_STARTS_WITH:Oe+q.StartsWith,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_ENDS_WITH:Oe+q.EndsWith,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_CONTAINS:Oe+q.Contains,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_MATCHES_REGEX:Oe+q.MatchesRegex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_CURRENT_TIMESTAMP:Oe+U.GetCurrentTimestamp,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_FORMAT_DATE:Oe+U.FormatDate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_PARSE_DATE:Oe+U.ParseDate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_ADD_TO_DATE:Oe+U.AddToDate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SUBTRACT_FROM_DATE:Oe+U.SubtractFromDate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_DIFFERENCE_BETWEEN_DATES:Oe+U.DifferenceBetweenDates,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_DATE:Oe+U.ToDate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_UNIX:Oe+U.ToUnix,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_FROM_UNIX:Oe+U.FromUnix,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_ISO_STRING:Oe+U.ToISOString,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_YEAR:Oe+U.GetYear,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_MONTH:Oe+U.GetMonth,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_DATE:Oe+U.GetDate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_HOUR:Oe+U.GetHour,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_MINUTE:Oe+U.GetMinute,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_SECOND:Oe+U.GetSecond,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_MILLISECOND:Oe+U.GetMillisecond,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_ISO_WEEKDAY:Oe+U.GetIsoWeekday,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_WEEK_OF_YEAR:Oe+U.GetWeekOfYear,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_QUARTER:Oe+U.GetQuarter,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_DAY_OF_YEAR:Oe+U.GetDayOfYear,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_DAYS_IN_MONTH:Oe+U.GetDaysInMonth,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_CURRENT_IANA_TIMEZONE:Oe+U.GetCurrentIanaTimeZone,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_YEAR:Oe+U.SetYear,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_MONTH:Oe+U.SetMonth,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_DATE:Oe+U.SetDate,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_HOUR:Oe+U.SetHour,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_MINUTE:Oe+U.SetMinute,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_SECOND:Oe+U.SetSecond,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_MILLISECOND:Oe+U.SetMillisecond,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_ISO_WEEKDAY:Oe+U.SetIsoWeekday,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_QUARTER:Oe+U.SetQuarter,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_START_OF:Oe+U.StartOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_END_OF:Oe+U.EndOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_ROUND_TO:Oe+U.RoundTo,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_BEFORE:Na+U.IsBefore,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_AFTER:Na+U.IsAfter,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_SAME:Na+U.IsSame,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_SAME_OR_BEFORE:Na+U.IsSameOrBefore,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_SAME_OR_AFTER:Na+U.IsSameOrAfter,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_BETWEEN:Na+U.IsBetween,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_VALID:Na+U.IsValid,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_LEAP_YEAR:Na+U.IsLeapYear,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_CLAMP_TO_RANGE:Oe+U.ClampToRange,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_MIN_OF:Oe+U.MinOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_MAX_OF:Oe+U.MaxOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_FROM_NOW:Oe+U.FromNow,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_NOW:Oe+U.ToNow,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_HUMANIZE_DIFF:Oe+U.HumanizeDiff,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_ADD_BUSINESS_DAYS:Oe+U.AddBusinessDays,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_NEXT_WEEKDAY:Oe+U.NextWeekday,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_PREVIOUS_WEEKDAY:Oe+U.PreviousWeekday,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_UTC:Oe+U.ToUTC,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_CONVERT_TIMEZONE:Oe+U.ConvertTimezone,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_TIMEZONE_OFFSET:Oe+U.GetTimezoneOffset,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_UTC_OFFSET:Oe+U.SetUTCOffset,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_READ_KEY:Oe+Ce.ReadKey,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_WRITE_KEY:Oe+Ce.WriteKey,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_DELETE_KEY:Oe+Ce.DeleteKey,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_READ_NESTED_KEY:Oe+Ce.ReadNestedKey,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_WRITE_NESTED_KEY:Oe+Ce.WriteNestedKey,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_DELETE_NESTED_KEY:Oe+Ce.DeleteNestedKey,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_WRITE_SAFE_NESTED_KEY_RECURSIVELY:Oe+Ce.WriteSafeNestedKeyRecursively,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_HAS_KEY:Na+Ce.HasKey,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_HAS_NESTED_KEY:Na+Ce.HasNestedKey,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_KEY_VALUE_EQUALS:Na+Ce.KeyValueEquals,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_NESTED_KEY_VALUE_EQUALS:Na+Ce.NestedKeyValueEquals,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_IS_INSTANCE_OF_TYPE:Na+Ce.IsInstanceOfType,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_MERGE:Oe+Ce.Merge,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_KEYS:Oe+Ce.Keys,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_VALUES:Oe+Ce.Values,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_ENTRIES:Oe+Ce.Entries,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_GET_TYPE_OF:Oe+ze.GetTypeOf,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_HASH:Oe+si.Hash,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_HMAC:Oe+si.Hmac,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_GENERATE_RANDOM_BYTES:Oe+et.GenerateRandomBytes,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_CONSTANT_TIME_EQUAL:Oe+si.ConstantTimeEqual,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_DERIVE_KEY_PBKDF2:Oe+si.DeriveKeyPBKDF2,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__PASSWORD_HASH_PBKDF2:Oe+Qr.HashPasswordPBKDF2,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__PASSWORD_VERIFY_PBKDF2:Oe+Qr.VerifyPasswordPBKDF2,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__JWT_BUILD_HMAC:Oe+er.BuildJwtHmac,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__JWT_VERIFY_HMAC:Oe+er.VerifyJwtHmac,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__JWT_DECODE:Oe+er.DecodeJwt,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_FROM_BYTES_TO_STRING:Oe+ze.FromBytesToString,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_TO_BYTES:Oe+ze.ToBytes,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_TO_NUMBER:Oe+ze.ToNumber,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_TO_STRING:Oe+ze.ToString,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_ENCODE_BASE64:Oe+ze.EncodeBase64,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_DECODE_BASE64:Oe+ze.DecodeBase64,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_ENCODE_BASE64URL:Oe+ze.EncodeBase64Url,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_DECODE_BASE64URL:Oe+ze.DecodeBase64Url,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_ENCODE_HEX:Oe+ze.EncodeHex,BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_DECODE_HEX:Oe+ze.DecodeHex,BUILT_IN_OPERATIONS_IMPLEMENTATIONS__JSON_PARSE:Oe+Xr.Parse,BUILT_IN_OPERATIONS_IMPLEMENTATIONS__JSON_STRINGIFY:Oe+Xr.Stringify};class ZOe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_IN_FUNCTION_IMPLEMENTATIONS__ABORT_EXECUTION,version:"1.0.0",description:'Implementation for the built-in function "Abort Execution". It terminates the execution of the current entity being run.',initPriority:Ee.High,permissions:[be.All],contexts:[X.Editor]});I(this,"module",{main:async(i,n)=>({value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,entity:i,error:null,result:null})})}}class HOe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_IN_FUNCTION_IMPLEMENTATIONS__DELETE_PERSISTED_ENTITY,version:"1.0.0",description:'Implementation for the built-in function "Delete Persisted Entity". It deletes the current entity as an entry in the persisted storage.',initPriority:Ee.High,permissions:[be.All],contexts:[X.Editor]});I(this,"module",{main:async(i,n)=>({value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,entity:i,error:null,result:null})})}}class WOe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_IN_FUNCTION_IMPLEMENTATIONS__CREATE_PERSISTED_ENTITY,version:"1.0.0",description:'Implementation for the built-in function "Create Persisted Entity". It saves the current entity state to the persisted storage.',initPriority:Ee.High,permissions:[be.All],contexts:[X.Editor]});I(this,"module",{main:async(i,n)=>({value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,entity:i,error:null,result:null})})}}class zOe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_IN_FUNCTION_IMPLEMENTATIONS__UPDATE_PERSISTED_ENTITY,version:"1.0.0",description:'Implementation for the built-in function "Update Persisted Entity". It saves the current entity state to the persisted storage.',initPriority:Ee.High,permissions:[be.All],contexts:[X.Editor]});I(this,"module",{main:async(i,n)=>({value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,entity:i,error:null,result:null})})}}class JOe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.SEARCH_NODE_IMPLEMENTATION,version:"1.0.0",description:"Implementation for search nodes when they get executed and query data.",initPriority:Ee.High,permissions:[be.All],contexts:[X.Editor]});I(this,"module",{main:async(i,n)=>({error:"Search module not implemented",data:null})})}}class YOe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.UUID,version:"1.0.0",description:"UUID generation module, for all contexts and runtimes",initPriority:Ee.High,permissions:[be.All],contexts:[]});I(this,"module",bC)}}const XOe=o=>o.map(p=>{var i,n;return((i=p.value)==null?void 0:i.valueAsType)??((n=p.value)==null?void 0:n.value)});class QOe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__COMPARISON_EMPTY,version:"1.0.0",description:"Comparison: Empty (!value)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const s=n.get(xt.Empty);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=XOe(n),c=!s;return{value:G.Success,error:null,result:c}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class eCe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__COMPARISON_NOT_EMPTY,version:"1.0.0",description:"Comparison: NotEmpty (!!value)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const s=n.get(xt.NotEmpty);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=XOe(n),c=!!s;return{value:G.Success,error:null,result:c}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}const $A=class $A extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__COMPARISON_PRIMITIVE_EQUAL,version:"1.0.0",description:"Comparison: PrimitiveEqual (typed equality / deep JSON equality)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const s=n.get(xt.PrimitiveEqual);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{var s,c,e,y,m,v;try{const E=(c=(s=n[0])==null?void 0:s.value)==null?void 0:c.name,b=(y=(e=n[0])==null?void 0:e.value)==null?void 0:y.value,w=(v=(m=n[1])==null?void 0:m.value)==null?void 0:v.value;let V=!1;return E&&$A.primitiveSet.has(E)?V=b===w:E===oe.Untyped||E===oe.KeyValue?V=JSON.stringify(b)===JSON.stringify(w):V=!1,{value:G.Success,error:null,result:V}}catch(E){return{value:G.UnhandledError,error:E,result:null}}}})}};I($A,"primitiveSet",new Set([oe.String,oe.Number,oe.Boolean,oe.Null,oe.Enum,oe.Date,oe.UUID]));let cA=$A;const LA=class LA extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__COMPARISON_PRIMITIVE_NOT_EQUAL,version:"1.0.0",description:"Comparison: PrimitiveNotEqual (typed inequality / deep JSON inequality)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const s=n.get(xt.PrimitiveNotEqual);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{var s,c,e,y,m,v;try{const E=(c=(s=n[0])==null?void 0:s.value)==null?void 0:c.name,b=(y=(e=n[0])==null?void 0:e.value)==null?void 0:y.value,w=(v=(m=n[1])==null?void 0:m.value)==null?void 0:v.value;let V=!1;return E&&LA.primitiveSet.has(E)?V=b!==w:E===oe.Untyped||E===oe.KeyValue?V=JSON.stringify(b)!==JSON.stringify(w):V=!1,{value:G.Success,error:null,result:V}}catch(E){return{value:G.UnhandledError,error:E,result:null}}}})}};I(LA,"primitiveSet",new Set([oe.String,oe.Number,oe.Boolean,oe.Null,oe.Enum,oe.Date,oe.UUID]));let fA=LA;var tCe={exports:{}};(function(o,p){(function(i,n){o.exports=n()})(Nr,function(){var i="minute",n=/[+-]\d\d(?::?\d\d)?/g,s=/([+-]|\d\d)/g;return function(c,e,y){var m=e.prototype;y.utc=function(L){var k={date:L,utc:!0,args:arguments};return new e(k)},m.utc=function(L){var k=y(this.toDate(),{locale:this.$L,utc:!0});return L?k.add(this.utcOffset(),i):k},m.local=function(){return y(this.toDate(),{locale:this.$L,utc:!1})};var v=m.parse;m.parse=function(L){L.utc&&(this.$u=!0),this.$utils().u(L.$offset)||(this.$offset=L.$offset),v.call(this,L)};var E=m.init;m.init=function(){if(this.$u){var L=this.$d;this.$y=L.getUTCFullYear(),this.$M=L.getUTCMonth(),this.$D=L.getUTCDate(),this.$W=L.getUTCDay(),this.$H=L.getUTCHours(),this.$m=L.getUTCMinutes(),this.$s=L.getUTCSeconds(),this.$ms=L.getUTCMilliseconds()}else E.call(this)};var b=m.utcOffset;m.utcOffset=function(L,k){var K=this.$utils().u;if(K(L))return this.$u?0:K(this.$offset)?b.call(this):this.$offset;if(typeof L=="string"&&(L=function(ee){ee===void 0&&(ee="");var de=ee.match(n);if(!de)return null;var le=(""+de[0]).match(s)||["-",0,0],fe=le[0],ve=60*+le[1]+ +le[2];return ve===0?0:fe==="+"?ve:-ve}(L),L===null))return this;var S=Math.abs(L)<=16?60*L:L;if(S===0)return this.utc(k);var Y=this.clone();if(k)return Y.$offset=S,Y.$u=!1,Y;var re=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();return(Y=this.local().add(S+re,i)).$offset=S,Y.$x.$localOffset=re,Y};var w=m.format;m.format=function(L){var k=L||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return w.call(this,k)},m.valueOf=function(){var L=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*L},m.isUTC=function(){return!!this.$u},m.toISOString=function(){return this.toDate().toISOString()},m.toString=function(){return this.toDate().toUTCString()};var V=m.toDate;m.toDate=function(L){return L==="s"&&this.$offset?y(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():V.call(this)};var $=m.diff;m.diff=function(L,k,K){if(L&&this.$u===L.$u)return $.call(this,L,k,K);var S=this.local(),Y=y(L).local();return $.call(S,Y,k,K)}}})})(tCe);var Ivi=tCe.exports;const Rvi=Wa(Ivi);var iCe={exports:{}};(function(o,p){(function(i,n){o.exports=n()})(Nr,function(){var i={year:0,month:1,day:2,hour:3,minute:4,second:5},n={};return function(s,c,e){var y,m=function(w,V,$){$===void 0&&($={});var L=new Date(w),k=function(K,S){S===void 0&&(S={});var Y=S.timeZoneName||"short",re=K+"|"+Y,ee=n[re];return ee||(ee=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:K,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:Y}),n[re]=ee),ee}(V,$);return k.formatToParts(L)},v=function(w,V){for(var $=m(w,V),L=[],k=0;k<$.length;k+=1){var K=$[k],S=K.type,Y=K.value,re=i[S];re>=0&&(L[re]=parseInt(Y,10))}var ee=L[3],de=ee===24?0:ee,le=L[0]+"-"+L[1]+"-"+L[2]+" "+de+":"+L[4]+":"+L[5]+":000",fe=+w;return(e.utc(le).valueOf()-(fe-=fe%1e3))/6e4},E=c.prototype;E.tz=function(w,V){w===void 0&&(w=y);var $,L=this.utcOffset(),k=this.toDate(),K=k.toLocaleString("en-US",{timeZone:w}),S=Math.round((k-new Date(K))/1e3/60),Y=15*-Math.round(k.getTimezoneOffset()/15)-S;if(!Number(Y))$=this.utcOffset(0,V);else if($=e(K,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(Y,!0),V){var re=$.utcOffset();$=$.add(L-re,"minute")}return $.$x.$timezone=w,$},E.offsetName=function(w){var V=this.$x.$timezone||e.tz.guess(),$=m(this.valueOf(),V,{timeZoneName:w}).find(function(L){return L.type.toLowerCase()==="timezonename"});return $&&$.value};var b=E.startOf;E.startOf=function(w,V){if(!this.$x||!this.$x.$timezone)return b.call(this,w,V);var $=e(this.format("YYYY-MM-DD HH:mm:ss:SSS"),{locale:this.$L});return b.call($,w,V).tz(this.$x.$timezone,!0)},e.tz=function(w,V,$){var L=$&&V,k=$||V||y,K=v(+e(),k);if(typeof w!="string")return e(w).tz(k);var S=function(de,le,fe){var ve=de-60*le*1e3,ue=v(ve,fe);if(le===ue)return[ve,le];var ye=v(ve-=60*(ue-le)*1e3,fe);return ue===ye?[ve,ue]:[de-60*Math.min(ue,ye)*1e3,Math.max(ue,ye)]}(e.utc(w,L).valueOf(),K,k),Y=S[0],re=S[1],ee=e(Y).utcOffset(re);return ee.$x.$timezone=k,ee},e.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},e.tz.setDefault=function(w){y=w}}})})(iCe);var Dvi=iCe.exports;const wvi=Wa(Dvi);var rCe={exports:{}};(function(o,p){(function(i,n){o.exports=n()})(Nr,function(){return function(i,n,s){n.prototype.isBetween=function(c,e,y,m){var v=s(c),E=s(e),b=(m=m||"()")[0]==="(",w=m[1]===")";return(b?this.isAfter(v,y):!this.isBefore(v,y))&&(w?this.isBefore(E,y):!this.isAfter(E,y))||(b?this.isBefore(v,y):!this.isAfter(v,y))&&(w?this.isAfter(E,y):!this.isBefore(E,y))}}})})(rCe);var Ovi=rCe.exports;const Cvi=Wa(Ovi);var nCe={exports:{}};(function(o,p){(function(i,n){o.exports=n()})(Nr,function(){return function(i,n){n.prototype.isSameOrAfter=function(s,c){return this.isSame(s,c)||this.isAfter(s,c)}}})})(nCe);var _vi=nCe.exports;const Vvi=Wa(_vi);var aCe={exports:{}};(function(o,p){(function(i,n){o.exports=n()})(Nr,function(){return function(i,n){n.prototype.isSameOrBefore=function(s,c){return this.isSame(s,c)||this.isBefore(s,c)}}})})(aCe);var Pvi=aCe.exports;const Nvi=Wa(Pvi);var sCe={exports:{}};(function(o,p){(function(i,n){o.exports=n()})(Nr,function(){var i="week",n="year";return function(s,c,e){var y=c.prototype;y.week=function(m){if(m===void 0&&(m=null),m!==null)return this.add(7*(m-this.week()),"day");var v=this.$locale().yearStart||1;if(this.month()===11&&this.date()>25){var E=e(this).startOf(n).add(1,n).date(v),b=e(this).endOf(i);if(E.isBefore(b))return 1}var w=e(this).startOf(n).date(v).startOf(i).subtract(1,"millisecond"),V=this.diff(w,i,!0);return V<0?e(this).startOf("week").week():Math.ceil(V)},y.weeks=function(m){return m===void 0&&(m=null),this.week(m)}}})})(sCe);var xvi=sCe.exports;const $vi=Wa(xvi);var lCe={exports:{}};(function(o,p){(function(i,n){o.exports=n()})(Nr,function(){var i="day";return function(n,s,c){var e=function(v){return v.add(4-v.isoWeekday(),i)},y=s.prototype;y.isoWeekYear=function(){return e(this).year()},y.isoWeek=function(v){if(!this.$utils().u(v))return this.add(7*(v-this.isoWeek()),i);var E,b,w,V,$=e(this),L=(E=this.isoWeekYear(),b=this.$u,w=(b?c.utc:c)().year(E).startOf("year"),V=4-w.isoWeekday(),w.isoWeekday()>4&&(V+=7),w.add(V,i));return $.diff(L,"week")+1},y.isoWeekday=function(v){return this.$utils().u(v)?this.day()||7:this.day(this.day()%7?v:v-7)};var m=y.startOf;y.startOf=function(v,E){var b=this.$utils(),w=!!b.u(E)||E;return b.p(v)==="isoweek"?w?this.date(this.date()-(this.isoWeekday()-1)).startOf("day"):this.date(this.date()-1-(this.isoWeekday()-1)+7).endOf("day"):m.bind(this)(v,E)}}})})(lCe);var Lvi=lCe.exports;const Mvi=Wa(Lvi);var oCe={exports:{}};(function(o,p){(function(i,n){o.exports=n()})(Nr,function(){var i="month",n="quarter";return function(s,c){var e=c.prototype;e.quarter=function(v){return this.$utils().u(v)?Math.ceil((this.month()+1)/3):this.month(this.month()%3+3*(v-1))};var y=e.add;e.add=function(v,E){return v=Number(v),this.$utils().p(E)===n?this.add(3*v,i):y.bind(this)(v,E)};var m=e.startOf;e.startOf=function(v,E){var b=this.$utils(),w=!!b.u(E)||E;if(b.p(v)===n){var V=this.quarter()-1;return w?this.month(3*V).startOf(i).startOf("day"):this.month(3*V+2).endOf(i).endOf("day")}return m.bind(this)(v,E)}}})})(oCe);var Bvi=oCe.exports;const Gvi=Wa(Bvi);var dCe={exports:{}};(function(o,p){(function(i,n){o.exports=n()})(Nr,function(){return function(i,n,s){n.prototype.dayOfYear=function(c){var e=Math.round((s(this).startOf("day")-s(this).startOf("year"))/864e5)+1;return c==null?e:this.add(c-e,"day")}}})})(dCe);var kvi=dCe.exports;const jvi=Wa(kvi);var uCe={exports:{}};(function(o,p){(function(i,n){o.exports=n()})(Nr,function(){return function(i,n,s){i=i||{};var c=n.prototype,e={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function y(v,E,b,w){return c.fromToBase(v,E,b,w)}s.en.relativeTime=e,c.fromToBase=function(v,E,b,w,V){for(var $,L,k,K=b.$locale().relativeTime||e,S=i.thresholds||[{l:"s",r:44,d:"second"},{l:"m",r:89},{l:"mm",r:44,d:"minute"},{l:"h",r:89},{l:"hh",r:21,d:"hour"},{l:"d",r:35},{l:"dd",r:25,d:"day"},{l:"M",r:45},{l:"MM",r:10,d:"month"},{l:"y",r:17},{l:"yy",d:"year"}],Y=S.length,re=0;re<Y;re+=1){var ee=S[re];ee.d&&($=w?s(v).diff(b,ee.d,!0):b.diff(v,ee.d,!0));var de=(i.rounding||Math.round)(Math.abs($));if(k=$>0,de<=ee.r||!ee.r){de<=1&&re>0&&(ee=S[re-1]);var le=K[ee.l];V&&(de=V(""+de)),L=typeof le=="string"?le.replace("%d",de):le(de,E,ee.l,k);break}}if(E)return L;var fe=k?K.future:K.past;return typeof fe=="function"?fe(L):fe.replace("%s",L)},c.to=function(v,E){return y(v,E,this,!0)},c.from=function(v,E){return y(v,E,this)};var m=function(v){return v.$u?s.utc():s()};c.toNow=function(v){return this.to(m(this),v)},c.fromNow=function(v){return this.from(m(this),v)}}})})(uCe);var Uvi=uCe.exports;const Kvi=Wa(Uvi);var pCe={exports:{}};(function(o,p){(function(i,n){o.exports=n()})(Nr,function(){var i,n,s=1e3,c=6e4,e=36e5,y=864e5,m=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,v=31536e6,E=2628e6,b=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,w={years:v,months:E,days:y,hours:e,minutes:c,seconds:s,milliseconds:1,weeks:6048e5},V=function(de){return de instanceof re},$=function(de,le,fe){return new re(de,fe,le.$l)},L=function(de){return n.p(de)+"s"},k=function(de){return de<0},K=function(de){return k(de)?Math.ceil(de):Math.floor(de)},S=function(de){return Math.abs(de)},Y=function(de,le){return de?k(de)?{negative:!0,format:""+S(de)+le}:{negative:!1,format:""+de+le}:{negative:!1,format:""}},re=function(){function de(fe,ve,ue){var ye=this;if(this.$d={},this.$l=ue,fe===void 0&&(this.$ms=0,this.parseFromMilliseconds()),ve)return $(fe*w[L(ve)],this);if(typeof fe=="number")return this.$ms=fe,this.parseFromMilliseconds(),this;if(typeof fe=="object")return Object.keys(fe).forEach(function($e){ye.$d[L($e)]=fe[$e]}),this.calMilliseconds(),this;if(typeof fe=="string"){var Ve=fe.match(b);if(Ve){var _e=Ve.slice(2).map(function($e){return $e!=null?Number($e):0});return this.$d.years=_e[0],this.$d.months=_e[1],this.$d.weeks=_e[2],this.$d.days=_e[3],this.$d.hours=_e[4],this.$d.minutes=_e[5],this.$d.seconds=_e[6],this.calMilliseconds(),this}}return this}var le=de.prototype;return le.calMilliseconds=function(){var fe=this;this.$ms=Object.keys(this.$d).reduce(function(ve,ue){return ve+(fe.$d[ue]||0)*w[ue]},0)},le.parseFromMilliseconds=function(){var fe=this.$ms;this.$d.years=K(fe/v),fe%=v,this.$d.months=K(fe/E),fe%=E,this.$d.days=K(fe/y),fe%=y,this.$d.hours=K(fe/e),fe%=e,this.$d.minutes=K(fe/c),fe%=c,this.$d.seconds=K(fe/s),fe%=s,this.$d.milliseconds=fe},le.toISOString=function(){var fe=Y(this.$d.years,"Y"),ve=Y(this.$d.months,"M"),ue=+this.$d.days||0;this.$d.weeks&&(ue+=7*this.$d.weeks);var ye=Y(ue,"D"),Ve=Y(this.$d.hours,"H"),_e=Y(this.$d.minutes,"M"),$e=this.$d.seconds||0;this.$d.milliseconds&&($e+=this.$d.milliseconds/1e3,$e=Math.round(1e3*$e)/1e3);var Ne=Y($e,"S"),Be=fe.negative||ve.negative||ye.negative||Ve.negative||_e.negative||Ne.negative,Se=Ve.format||_e.format||Ne.format?"T":"",je=(Be?"-":"")+"P"+fe.format+ve.format+ye.format+Se+Ve.format+_e.format+Ne.format;return je==="P"||je==="-P"?"P0D":je},le.toJSON=function(){return this.toISOString()},le.format=function(fe){var ve=fe||"YYYY-MM-DDTHH:mm:ss",ue={Y:this.$d.years,YY:n.s(this.$d.years,2,"0"),YYYY:n.s(this.$d.years,4,"0"),M:this.$d.months,MM:n.s(this.$d.months,2,"0"),D:this.$d.days,DD:n.s(this.$d.days,2,"0"),H:this.$d.hours,HH:n.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:n.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:n.s(this.$d.seconds,2,"0"),SSS:n.s(this.$d.milliseconds,3,"0")};return ve.replace(m,function(ye,Ve){return Ve||String(ue[ye])})},le.as=function(fe){return this.$ms/w[L(fe)]},le.get=function(fe){var ve=this.$ms,ue=L(fe);return ue==="milliseconds"?ve%=1e3:ve=ue==="weeks"?K(ve/w[ue]):this.$d[ue],ve||0},le.add=function(fe,ve,ue){var ye;return ye=ve?fe*w[L(ve)]:V(fe)?fe.$ms:$(fe,this).$ms,$(this.$ms+ye*(ue?-1:1),this)},le.subtract=function(fe,ve){return this.add(fe,ve,!0)},le.locale=function(fe){var ve=this.clone();return ve.$l=fe,ve},le.clone=function(){return $(this.$ms,this)},le.humanize=function(fe){return i().add(this.$ms,"ms").locale(this.$l).fromNow(!fe)},le.valueOf=function(){return this.asMilliseconds()},le.milliseconds=function(){return this.get("milliseconds")},le.asMilliseconds=function(){return this.as("milliseconds")},le.seconds=function(){return this.get("seconds")},le.asSeconds=function(){return this.as("seconds")},le.minutes=function(){return this.get("minutes")},le.asMinutes=function(){return this.as("minutes")},le.hours=function(){return this.get("hours")},le.asHours=function(){return this.as("hours")},le.days=function(){return this.get("days")},le.asDays=function(){return this.as("days")},le.weeks=function(){return this.get("weeks")},le.asWeeks=function(){return this.as("weeks")},le.months=function(){return this.get("months")},le.asMonths=function(){return this.as("months")},le.years=function(){return this.get("years")},le.asYears=function(){return this.as("years")},de}(),ee=function(de,le,fe){return de.add(le.years()*fe,"y").add(le.months()*fe,"M").add(le.days()*fe,"d").add(le.hours()*fe,"h").add(le.minutes()*fe,"m").add(le.seconds()*fe,"s").add(le.milliseconds()*fe,"ms")};return function(de,le,fe){i=fe,n=fe().$utils(),fe.duration=function(ye,Ve){var _e=fe.locale();return $(ye,{$l:_e},Ve)},fe.isDuration=V;var ve=le.prototype.add,ue=le.prototype.subtract;le.prototype.add=function(ye,Ve){return V(ye)?ee(this,ye,1):ve.bind(this)(ye,Ve)},le.prototype.subtract=function(ye,Ve){return V(ye)?ee(this,ye,-1):ue.bind(this)(ye,Ve)}}})})(pCe);var Fvi=pCe.exports;const Svi=Wa(Fvi);var cCe={exports:{}};(function(o,p){(function(i,n){o.exports=n()})(Nr,function(){return function(i,n){n.prototype.isLeapYear=function(){return this.$y%4==0&&this.$y%100!=0||this.$y%400==0}}})})(cCe);var qvi=cCe.exports;const Zvi=Wa(qvi);M.extend(Rvi);M.extend(wvi);M.extend(Cvi);M.extend(Vvi);M.extend(Nvi);M.extend($vi);M.extend(Mvi);M.extend(Gvi);M.extend(jvi);M.extend(Kvi);M.extend(Svi);M.extend(Zvi);const At=o=>M(o),ir=o=>o.toISOString();function fCe(){return ir(M())}function yCe(o,p){return At(o).format(p)}function hCe(o){return ir(M(o))}function mCe(o){if(o==null)throw new TypeError("ToDate expects a non-null value.");if(typeof o=="string"){const p=M(o);if(!p.isValid())throw new TypeError("Invalid date string.");return p.toISOString()}if(typeof o=="number"&&Number.isFinite(o)){const p=Math.abs(o)<1e12?M.unix(o):M(o);if(!p.isValid())throw new TypeError("Invalid numeric timestamp.");return p.toISOString()}if(o instanceof Date){const p=M(o);if(!p.isValid())throw new TypeError("Invalid Date object.");return p.toISOString()}throw new TypeError("Unsupported value type for ToDate. Provide a string, number, or Date.")}function TCe(o,p,i){return ir(At(o).add(p,i))}function vCe(o,p,i){return ir(At(o).subtract(p,i))}function ECe(o,p,i,n=!1){return At(o).diff(At(p),i,n)}function bCe(o){return At(o).unix()}function ACe(o){return ir(M.unix(o))}function gCe(o){return ir(At(o))}function ICe(o){return At(o).year()}function RCe(o){return At(o).month()}function DCe(o){return At(o).date()}function wCe(o){return At(o).hour()}function OCe(o){return At(o).minute()}function CCe(o){return At(o).second()}function _Ce(o){return At(o).millisecond()}function VCe(o){return At(o).isoWeekday()}function PCe(o){return At(o).week()}function NCe(o){return At(o).quarter()}function xCe(o){return At(o).dayOfYear()}function $Ce(o){return At(o).daysInMonth()}function LCe(o,p){return ir(At(o).year(p))}function MCe(o,p){return ir(At(o).month(p))}function BCe(o,p){return ir(At(o).date(p))}function GCe(o,p){return ir(At(o).hour(p))}function kCe(o,p){return ir(At(o).minute(p))}function jCe(o,p){return ir(At(o).second(p))}function UCe(o,p){return ir(At(o).millisecond(p))}function KCe(o,p){return ir(At(o).isoWeekday(p))}function FCe(o,p){return ir(At(o).quarter(p))}function SCe(o,p){return ir(At(o).startOf(p))}function qCe(o,p){return ir(At(o).endOf(p))}function ZCe(o,p){const i=At(o),n=i.startOf(p),s=i.endOf(p),c=n.valueOf()+(s.valueOf()-n.valueOf())/2;return ir(i.valueOf()<c?n:s)}function HCe(o,p,i){return At(o).isBefore(At(p),i)}function WCe(o,p,i){return At(o).isAfter(At(p),i)}function zCe(o,p,i){return At(o).isSame(At(p),i)}function JCe(o,p,i){return At(o).isSameOrBefore(At(p),i)}function YCe(o,p,i){return At(o).isSameOrAfter(At(p),i)}function XCe(o,p,i,n,s="()"){return At(o).isBetween(At(p),At(i),n,s)}function QCe(o){return M(o).isValid()}function e_e(o){return At(o).isLeapYear()}function t_e(o,p,i){const n=At(o);return n.isBefore(p)?ir(At(p)):n.isAfter(i)?ir(At(i)):ir(n)}function i_e(o){if(o.length===0)throw new Error("minOf requires at least one date");let p=At(o[0]);for(let i=1;i<o.length;i++){const n=At(o[i]);n.isBefore(p)&&(p=n)}return ir(p)}function r_e(o){if(o.length===0)throw new Error("maxOf requires at least one date");let p=At(o[0]);for(let i=1;i<o.length;i++){const n=At(o[i]);n.isAfter(p)&&(p=n)}return ir(p)}function n_e(o,p=!1){return At(o).fromNow(p)}function a_e(o,p=!1){return At(o).toNow(p)}function s_e(o,p,i=!0){const n=At(o).diff(At(p),"millisecond",!0),s=Math.abs(n),e=M.duration(s,"milliseconds").humanize();return i?n>=0?`in ${e}`:`${e} ago`:e}function l_e(o,p,i=["6","7"],n=[]){const s=v=>n.some(E=>At(E).isSame(v,"day")),c=v=>((v.day()+6)%7+1).toString();let e=At(o);const y=p>=0?1:-1;let m=Math.abs(p);for(;m>0;){e=e.add(y,"day");const v=c(e);!i.includes(v)&&!s(e)&&m--}return ir(e)}function o_e(o,p){let i=At(o);const n=p;for(let s=0;s<7;s++)if(i=i.add(1,"day"),i.isoWeekday()===n)return ir(i);return ir(i)}function d_e(o,p){let i=At(o);const n=p;for(let s=0;s<7;s++)if(i=i.subtract(1,"day"),i.isoWeekday()===n)return ir(i);return ir(i)}const u_e="Local";function YP(){try{const o=Intl.DateTimeFormat().resolvedOptions().timeZone;if(o&&typeof o=="string")return o}catch{}try{if(typeof process<"u"&&process.env&&process.env.TZ)return process.env.TZ}catch{}return null}function XP(){const o=YP();if(o)return o;throw new Error("Unable to detect current IANA timezone from host environment.")}function p_e(o,p,i=!1){let n=p;if(n===u_e){const e=YP();if(!e)throw new Error("Unable to detect current timezone from host environment.");n=e}const s=n?M.tz(o,n):At(o),c=i?s.utc(!0):s.utc();return ir(c)}function c_e(o,p,i=!1){const n=At(o);return ir(i?n.tz(p,!0):n.tz(p))}function f_e(o,p){const i=o===u_e?XP():o;return At(p).tz(i).utcOffset()}function y_e(o,p,i=!1){return ir(At(o).utcOffset(p,i))}class h_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_CURRENT_TIMESTAMP,version:"1.0.0",description:"Date get current timestamp operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.GetCurrentTimestamp);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=fCe();return{value:G.Success,error:null,result:s}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class m_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_FORMAT_DATE,version:"1.0.0",description:"Date format operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.FormatDate);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1],y=yCe(c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class T_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_PARSE_DATE,version:"1.0.0",description:"Date parse operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.ParseDate);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)})[0],e=hCe(c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class v_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_ADD_TO_DATE,version:"1.0.0",description:"Date add-to-date operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.AddToDate);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1],y=s[2],m=TCe(c,e,y);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class E_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SUBTRACT_FROM_DATE,version:"1.0.0",description:"Date subtract-from-date operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.SubtractFromDate);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1],y=s[2],m=vCe(c,e,y);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class b_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_DIFFERENCE_BETWEEN_DATES,version:"1.0.0",description:"Date difference-between-dates operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.DifferenceBetweenDates);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(E=>{var b,w;return((b=E.value)==null?void 0:b.valueAsType)||((w=E.value)==null?void 0:w.value)}),c=s[0],e=s[1],y=s[2],m=s[3]??!1,v=ECe(c,e,y,m);return{value:G.Success,error:null,result:v}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class Hvi extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_DATE,version:"1.0.0",description:"Date to-date operation implementation module (coerce to ISO 8601 string)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.ToDate);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)}),c=mCe(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class A_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_UNIX,version:"1.0.0",description:"Date to-unix operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.ToUnix);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)})[0],e=bCe(c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class g_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_FROM_UNIX,version:"1.0.0",description:"Date from-unix operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.FromUnix);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)})[0],e=ACe(c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class I_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_ISO_STRING,version:"1.0.0",description:"Date to-iso-string operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.ToISOString);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)})[0],e=gCe(c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class R_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_YEAR,version:"1.0.0",description:"Date get-year operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.GetYear);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)||((m=e.value)==null?void 0:m.value)}),c=ICe(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class D_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_MONTH,version:"1.0.0",description:"Date get-month (0-based) operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.GetMonth);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)||((m=e.value)==null?void 0:m.value)}),c=RCe(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class w_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_DATE,version:"1.0.0",description:"Date get-date (day of month) operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.GetDate);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)||((m=e.value)==null?void 0:m.value)}),c=DCe(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class O_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_HOUR,version:"1.0.0",description:"Date get-hour operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.GetHour);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)||((m=e.value)==null?void 0:m.value)}),c=wCe(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class C_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_MINUTE,version:"1.0.0",description:"Date get-minute operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.GetMinute);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)||((m=e.value)==null?void 0:m.value)}),c=OCe(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class __e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_SECOND,version:"1.0.0",description:"Date get-second operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.GetSecond);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)||((m=e.value)==null?void 0:m.value)}),c=CCe(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class V_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_MILLISECOND,version:"1.0.0",description:"Date get-millisecond operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.GetMillisecond);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)||((m=e.value)==null?void 0:m.value)}),c=_Ce(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class P_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_ISO_WEEKDAY,version:"1.0.0",description:"Date get-iso-weekday operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.GetIsoWeekday);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)||((m=e.value)==null?void 0:m.value)}),c=VCe(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class N_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_WEEK_OF_YEAR,version:"1.0.0",description:"Date get-week-of-year operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.GetWeekOfYear);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)||((m=e.value)==null?void 0:m.value)}),c=PCe(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class x_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_QUARTER,version:"1.0.0",description:"Date get-quarter operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.GetQuarter);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)||((m=e.value)==null?void 0:m.value)}),c=NCe(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class $_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_DAY_OF_YEAR,version:"1.0.0",description:"Date get-day-of-year operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.GetDayOfYear);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)||((m=e.value)==null?void 0:m.value)}),c=xCe(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class L_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_DAYS_IN_MONTH,version:"1.0.0",description:"Date get-days-in-month operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.GetDaysInMonth);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)||((m=e.value)==null?void 0:m.value)}),c=$Ce(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class M_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_CURRENT_IANA_TIMEZONE,version:"1.0.0",description:"Date get-current-iana-timezone operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.GetCurrentIanaTimeZone);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=XP();return{value:G.Success,error:null,result:s}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class B_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_YEAR,version:"1.0.0",description:"Date set-year operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.SetYear);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1],y=LCe(c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class G_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_MONTH,version:"1.0.0",description:"Date set-month operation implementation module (0-based month)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.SetMonth);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1],y=MCe(c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class k_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_DATE,version:"1.0.0",description:"Date set-date (day of month) operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.SetDate);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1],y=BCe(c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class j_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_HOUR,version:"1.0.0",description:"Date set-hour operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.SetHour);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1],y=GCe(c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class U_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_MINUTE,version:"1.0.0",description:"Date set-minute operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.SetMinute);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1],y=kCe(c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class K_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_SECOND,version:"1.0.0",description:"Date set-second operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.SetSecond);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1],y=jCe(c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class F_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_MILLISECOND,version:"1.0.0",description:"Date set-millisecond operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.SetMillisecond);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1],y=UCe(c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class S_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_ISO_WEEKDAY,version:"1.0.0",description:"Date set-iso-weekday operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.SetIsoWeekday);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1],y=KCe(c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class q_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_QUARTER,version:"1.0.0",description:"Date set-quarter operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.SetQuarter);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1],y=FCe(c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class Z_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_START_OF,version:"1.0.0",description:"Date start-of operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.StartOf);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1],y=SCe(c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class H_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_END_OF,version:"1.0.0",description:"Date end-of operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.EndOf);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1],y=qCe(c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class W_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_ROUND_TO,version:"1.0.0",description:"Date round-to operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.RoundTo);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1],y=ZCe(c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class z_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_BEFORE,version:"1.0.0",description:"Date is-before operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.IsBefore);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1],y=s[2],m=HCe(c,e,y);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class J_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_AFTER,version:"1.0.0",description:"Date is-after operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.IsAfter);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1],y=s[2],m=WCe(c,e,y);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class Y_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_SAME,version:"1.0.0",description:"Date is-same operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.IsSame);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1],y=s[2],m=zCe(c,e,y);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class X_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_SAME_OR_BEFORE,version:"1.0.0",description:"Date is-same-or-before operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.IsSameOrBefore);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1],y=s[2],m=JCe(c,e,y);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class Q_e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_SAME_OR_AFTER,version:"1.0.0",description:"Date is-same-or-after operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.IsSameOrAfter);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1],y=s[2],m=YCe(c,e,y);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class eVe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_BETWEEN,version:"1.0.0",description:"Date is-between operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.IsBetween);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(b=>{var w,V;return((w=b.value)==null?void 0:w.valueAsType)||((V=b.value)==null?void 0:V.value)}),c=s[0],e=s[1],y=s[2],m=s[3],v=s[4],E=XCe(c,e,y,m,v??void 0);return{value:G.Success,error:null,result:E}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class tVe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_VALID,version:"1.0.0",description:"Date is-valid operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.IsValid);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)||((m=e.value)==null?void 0:m.value)}),c=QCe(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class iVe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_IS_LEAP_YEAR,version:"1.0.0",description:"Date is-leap-year operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.IsLeapYear);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)||((m=e.value)==null?void 0:m.value)}),c=e_e(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class rVe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_CLAMP_TO_RANGE,version:"1.0.0",description:"Date clamp-to-range operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.ClampToRange);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1],y=s[2],m=t_e(c,e,y);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class nVe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_MIN_OF,version:"1.0.0",description:"Date min-of operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.MinOf);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)}),c=s.length===1&&Array.isArray(s[0])?s[0]:s,e=i_e(c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class aVe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_MAX_OF,version:"1.0.0",description:"Date max-of operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.MaxOf);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)}),c=s.length===1&&Array.isArray(s[0])?s[0]:s,e=r_e(c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class sVe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_FROM_NOW,version:"1.0.0",description:"Date from-now operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.FromNow);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s,c]=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),y=n_e(s,c??!1);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class lVe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_NOW,version:"1.0.0",description:"Date to-now operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.ToNow);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s,c]=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),y=a_e(s,c??!1);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class oVe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_HUMANIZE_DIFF,version:"1.0.0",description:"Date humanize-diff operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.HumanizeDiff);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s,c,e]=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),m=s_e(s,c,e??!0);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class dVe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_ADD_BUSINESS_DAYS,version:"1.1.0",description:"Date add-business-days operation implementation module (ISO-weekend strings)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.AddBusinessDays);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(E=>{var b,w;return((b=E.value)==null?void 0:b.valueAsType)??((w=E.value)==null?void 0:w.value)}),c=s[0],e=s[1],y=s[2]??void 0,m=s[3]??[],v=l_e(c,e,y,m);return{value:G.Success,error:null,result:v}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class uVe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_NEXT_WEEKDAY,version:"1.0.0",description:"Date next-weekday operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.NextWeekday);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)}),e=o_e(s,c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class pVe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_PREVIOUS_WEEKDAY,version:"1.0.0",description:"Date previous-weekday operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.PreviousWeekday);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)}),e=d_e(s,c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class cVe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_TO_UTC,version:"1.1.0",description:"Date to-utc operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.ToUTC);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1]||void 0,y=s[2]??!1,m=p_e(c,e,y);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class fVe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_CONVERT_TIMEZONE,version:"1.0.0",description:"Date convert-timezone operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.ConvertTimezone);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s,c,e]=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),m=c_e(s,c,e??!1);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class yVe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_GET_TIMEZONE_OFFSET,version:"1.0.0",description:"Date get-timezone-offset operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.GetTimezoneOffset);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s,c]=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),m=f_e(s,c);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class hVe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATE_SET_UTC_OFFSET,version:"1.0.0",description:"Date set-utc-offset operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(U.SetUTCOffset);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s,c,e]=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),m=y_e(s,c,e??!1);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class mVe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__EXECUTE_PARALLEL,version:"1.0.0",description:"Execution parallel operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(Ki.Parallel);s&&(s.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(b=>{var w,V;return((w=b.value)==null?void 0:w.valueAsType)||((V=b.value)==null?void 0:V.value)})[0];if(!c)return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No list of action entities provided",result:null};if(!Array.isArray(c))return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"Invalid input value. Expected a list of action entities",result:null};const y=this.extensionsRegistry.requestContexts(this,[X.Editor])[0],v=c.map(b=>{const w=new Iu(y.logic,[b],b,null,this.extensionsRegistry);return w.inheritValuesFromContext(y),w}).map(b=>b.execute()),E=await Promise.all(v);return{value:G.Success,error:null,result:E}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class TVe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__EXECUTE_SEQUENTIAL,version:"1.0.0",description:"Execution sequential operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(Ki.Sequential);s&&(s.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)})[0];if(!c)return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No list of action entities provided",result:null};if(!Array.isArray(c))return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"Invalid input value. Expected a list of action entities",result:null};const e=[];for(let y=0;y<c.length;y++){const m=c[y],E=this.extensionsRegistry.requestContexts(this,[X.Editor])[0],b=new Iu(E.logic,[m],m,null,this.extensionsRegistry);b.inheritValuesFromContext(E);const w=await b.execute();e.push(w)}return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class vVe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__EXECUTE_WAIT,version:"1.0.0",description:"Execution wait operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(Ki.Wait);s&&(s.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)||((m=e.value)==null?void 0:m.value)})[0];return typeof c!="number"||c<0?{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"Invalid wait time provided",result:null}:(await new Promise(e=>setTimeout(e,c)),{value:G.Success,error:null,result:null})}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}const Wvi=/^\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d{1,3})?)?(?:Z|[+-]\d{2}:?\d{2})?)?$/,QP=o=>o===null||["string","number","boolean"].includes(typeof o);function Cn(o,p="Input must be an array"){if(!Array.isArray(o))throw new TypeError(p);return o}function Yl(o){const p=Cn(o,"Input must be an array");if(!p||p.length===0)throw new TypeError("No list provided or list is empty");return p}function eN(o){return Array.isArray(o)?o:[]}function os(o){return Number(o)}function EVe(o){if(!o||o.length===0)throw new TypeError("No input lists provided");if(!o.every(n=>Array.isArray(n)))throw new TypeError("All inputs must be arrays");const[p,...i]=o;return i.reduce((n,s)=>n.concat(s),p)}function bVe(o,...p){if(!Array.isArray(o))throw new TypeError("First input must be an array");if(!p.every(i=>Array.isArray(i)))throw new TypeError("All subsequent inputs must be arrays");return o.concat(...p)}function AVe(o,p){const i=Yl(o),n=os(p);return[i.slice(0,n),i.slice(n)]}function gVe(o){return Yl(o).slice().reverse()}function IVe(o){return Yl(o).slice(0,-1)}function RVe(o){return Yl(o).slice(1)}function DVe(o,p,i){const n=Cn(o),s=os(p);if(s<0||s>n.length)throw new TypeError("Index out of bounds");return[...n.slice(0,s),i,...n.slice(s)]}function wVe(o,p,i){const n=Yl(o),s=os(p);if(s<0||s>=n.length)throw new TypeError("Index out of bounds");const c=[...n];return c[s]=i,c}function OVe(o,p,i){const n=Yl(o),s=n.indexOf(p);if(s===-1)return n;const c=[...n];return c[s]=i,c}function CVe(o,p,i){const n=Yl(o),s=n.lastIndexOf(p);if(s===-1)return n;const c=[...n];return c[s]=i,c}function _Ve(o,p,i){return Yl(o).map(s=>s===p?i:s)}function VVe(o,p){const i=Yl(o),n=os(p);if(n<0||n>=i.length)throw new TypeError("Index out of bounds");return i[n]}function PVe(o){return Yl(o)[0]}function NVe(o){const p=Yl(o);return p[p.length-1]}function xVe(o,p,...i){return[...Cn(o),p,...i]}function $Ve(o,p){const i=Cn(o);return[p,...i]}function LVe(o){return Cn(o).length}function MVe(o,p){const i=Cn(o),n=os(p);if(n<0||n>=i.length)throw new TypeError("Index out of bounds");return i.slice(0,n).concat(i.slice(n+1))}function BVe(o,p){const i=Cn(o),n=Math.max(0,os(p)??0);return i.slice(0,n)}function GVe(o,p){const i=Cn(o),n=Math.max(0,os(p)??0);return n===0?[]:i.slice(-n)}function kVe(o,p,i){const n=Cn(o),s=p==null?void 0:os(p),c=i==null?void 0:os(i);return n.slice(s,c)}function jVe(o,p){return Cn(o).indexOf(p)}function UVe(o,p){return Cn(o).lastIndexOf(p)}function KVe(o){const p=Cn(o),i=[],n=new Set;for(const s of p)n.has(s)||(n.add(s),i.push(s));return i}function FVe(o){return Cn(o).reduce((i,n)=>i.concat(n),[])}function SVe(o){const p=Cn(o);if(p.length<=1)return[...p];const i=p[0],n=typeof i=="number"&&p.every(e=>typeof e=="number"&&Number.isFinite(e)),s=typeof i=="string"&&p.every(e=>typeof e=="string");let c=null;if(n?c="number":s&&(c=p.every(y=>Wvi.test(y)&&M(y).isValid())?"date":"string"),!c)throw new TypeError("All items must be of the same supported type: number, string, or ISO date string.");return c==="number"?[...p].sort((e,y)=>e-y):c==="string"?[...p].sort((e,y)=>e.localeCompare(y)):[...p].sort((e,y)=>M(e).valueOf()-M(y).valueOf())}function qVe(o){const i=[...Cn(o)];for(let n=i.length-1;n>0;n--){const s=Math.floor(KI()*(n+1));[i[n],i[s]]=[i[s],i[n]]}return i}function ZVe(o,p){const i=Cn(o),n=Math.max(1,os(p)||1),s=[];for(let c=0;c<i.length;c+=n)s.push(i.slice(c,c+n));return s}function HVe(o,p,i){const n=Cn(o),s=Math.max(0,os(p)||0);if(n.length>=s)return[...n];const c=s-n.length;return Array(c).fill(i).concat(n)}function WVe(o,p,i){const n=Cn(o),s=Math.max(0,os(p)||0);if(n.length>=s)return[...n];const c=s-n.length,e=Array(c).fill(i);return n.concat(e)}function zVe(o,p){const i=Cn(o),n=Math.max(0,os(p)||0),s=[];for(let c=0;c<n;c++)s.push(...i);return s}function JVe(o,p){if(!QP(p))throw new TypeError("Contains expects the needle to be a primitive (string | number | boolean | null).");return eN(o).some(n=>n===p)}function YVe(o,p){const i=eN(o),n=Array.isArray(p)?p:[p];if(n.length===0)return!1;if(!n.every(QP))throw new TypeError("ContainsAll expects all needles to be primitives (string | number | boolean | null).");return n.every(s=>i.includes(s))}function XVe(o,p){const i=eN(o),n=Array.isArray(p)?p:[p];if(n.length===0)return!1;if(!n.every(QP))throw new TypeError("ContainsAny expects all needles to be primitives (string | number | boolean | null).");return n.some(s=>i.includes(s))}class QVe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_JOIN,version:"1.0.0",description:"List join operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(ie.Join);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)}),c=EVe(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class ePe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_SPLIT,version:"1.0.0",description:"List split operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(ie.Split);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1],[y,m]=AVe(c,e);return{value:G.Success,error:null,result:[y,m]}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class tPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REVERSE,version:"1.0.0",description:"List reverse operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(ie.Reverse);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)})[0],e=gVe(c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class iPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_DELETE_LAST_N_ITEMS,version:"1.0.0",description:"List delete last operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(ie.DeleteLastNItems);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)})[0],e=IVe(c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class rPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_DELETE_FIRST_N_ITEMS,version:"1.0.0",description:"List delete first operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(ie.DeleteFirstNItems);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)})[0],e=RVe(c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class nPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_ADD_AT_INDEX,version:"1.0.0",description:"List add index operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(ie.AddAtIndex);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1],y=s[2],m=DVe(c,e,y);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class aPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_AT_INDEX,version:"1.0.0",description:"List replace index operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(ie.ReplaceAtIndex);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1],y=s[2],m=wVe(c,e,y);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class sPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_FIRST_N_ITEMS,version:"1.0.0",description:"List replace first operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(ie.ReplaceFirstNItems);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1],y=s[2],m=OVe(c,e,y);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class lPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_LAST_N_ITEMS,version:"1.0.0",description:"List replace last operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(ie.ReplaceLastNItems);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1],y=s[2],m=CVe(c,e,y);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class oPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPLACE_ALL,version:"1.0.0",description:"List replace all operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(ie.ReplaceAll);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1],y=s[2],m=_Ve(c,e,y);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class dPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_INDEX_ITEM,version:"1.0.0",description:"List get index item operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(ie.GetIndexItem);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1],y=VVe(c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class uPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_FIRST,version:"1.0.0",description:"List get first operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(ie.GetFirst);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)})[0],e=PVe(c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class pPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_LAST,version:"1.0.0",description:"List get last operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(ie.GetLast);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)})[0],e=NVe(c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class cPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_APPEND,version:"1.0.0",description:"List append operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(ie.Append);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1],y=s.slice(2),m=xVe(c,e,...y);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class fPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_PREPEND,version:"1.0.0",description:"List prepend operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(ie.Prepend);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1],y=$Ve(c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class yPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_LENGTH,version:"1.0.0",description:"List get length",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ie.GetLength);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=n.map(c=>{var e,y;return((e=c.value)==null?void 0:e.valueAsType)??((y=c.value)==null?void 0:y.value)});return{value:G.Success,error:null,result:LVe(s)}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class hPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_DELETE_AT_INDEX,version:"1.0.0",description:"List delete one item at index (non-mutating)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ie.DeleteAtIndex);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)??((v=y.value)==null?void 0:v.value)}),e=MVe(s,c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class mPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_FIRST_N_ITEMS,version:"1.0.0",description:"List get first N items",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ie.GetFirstNItems);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)??((v=y.value)==null?void 0:v.value)}),e=BVe(s,c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class TPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_LAST_N_ITEMS,version:"1.0.0",description:"List get last N items",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ie.GetLastNItems);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)??((v=y.value)==null?void 0:v.value)}),e=GVe(s,c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class vPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_SLICE,version:"1.0.0",description:"List slice(start, end)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ie.Slice);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c,e]=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)??((E=m.value)==null?void 0:E.value)}),y=kVe(s,c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class EPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CONCAT,version:"1.0.0",description:"List concat(base, ...others)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ie.Concat);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)??((E=m.value)==null?void 0:E.value)}),[c,...e]=s,y=bVe(c,...e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class bPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_INDEX_OF,version:"1.0.0",description:"List listGetIndexOf(value)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ie.GetIndexOf);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)??((v=y.value)==null?void 0:v.value)}),e=jVe(s,c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class APe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_GET_LAST_INDEX_OF,version:"1.0.0",description:"List listGetLastIndexOf(value)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ie.GetLastIndexOf);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)??((v=y.value)==null?void 0:v.value)}),e=UVe(s,c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class gPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_UNIQUE,version:"1.0.0",description:"List unique (stable, by reference/===)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ie.Unique);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)}),c=KVe(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class IPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_FLATTEN,version:"1.0.0",description:"List flatten one level",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ie.Flatten);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)}),c=FVe(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class RPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_SORT,version:"1.0.0",description:"List sort (non-mutating). Supports lists of strings (alphabetic), numbers (numeric), or ISO date strings (chronological).",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ie.Sort);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)}),c=SVe(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class DPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_SHUFFLE,version:"1.0.0",description:"List shuffle (Fisher–Yates, secure RNG helper)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ie.Shuffle);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)}),c=qVe(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class wPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CHUNK,version:"1.0.0",description:"List chunk(size) -> list of lists",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ie.Chunk);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)??((v=y.value)==null?void 0:v.value)}),e=ZVe(s,c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class OPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_PAD_START,version:"1.0.0",description:"List padStart(targetLength, padValue)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ie.PadStart);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c,e]=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)??((E=m.value)==null?void 0:E.value)}),y=HVe(s,c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class CPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_PAD_END,version:"1.0.0",description:"List padEnd(targetLength, padValue)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ie.PadEnd);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c,e]=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)??((E=m.value)==null?void 0:E.value)}),y=WVe(s,c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class _Pe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_REPEAT,version:"1.0.0",description:"List repeat(count)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ie.Repeat);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)??((v=y.value)==null?void 0:v.value)}),e=zVe(s,c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class VPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CONTAINS,version:"1.0.0",description:"List contains (primitive needles)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ie.Contains);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)??((v=y.value)==null?void 0:v.value)}),e=JVe(s,c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class PPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CONTAINS_ALL,version:"1.0.0",description:"List contains all (primitive needles)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ie.ContainsAll);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)??((v=y.value)==null?void 0:v.value)}),e=YVe(s,c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class NPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__LIST_CONTAINS_ANY,version:"1.0.0",description:"List contains any (primitive needles)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ie.ContainsAny);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)??((v=y.value)==null?void 0:v.value)}),e=XVe(s,c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class zvi extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_LENGTH,version:"1.0.0",description:"Returns the number of characters in a string",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.GetLength);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)}),c=s.length;return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class xPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_JOIN,version:"1.0.0",description:"String join operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.Join);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{var s,c,e;try{const y=n.find(k=>{var K;return((K=k.valueOwner)==null?void 0:K.id)===Q.operation[q.Join].inputs.separator.id}),m=((s=y==null?void 0:y.value)==null?void 0:s.value)||"",v=n.find(k=>{var K;return((K=k.valueOwner)==null?void 0:K.id)===Q.operation[q.Join].inputs.first.id}),E=((c=v==null?void 0:v.value)==null?void 0:c.value)||"",b=n.find(k=>{var K;return((K=k.valueOwner)==null?void 0:K.id)===Q.operation[q.Join].inputs.second.id}),w=((e=b==null?void 0:b.value)==null?void 0:e.value)||"",$=n.filter(k=>{var K;return((K=k.valueOwner)==null?void 0:K.id)===Q.operation[q.Join].inputs.dynamicString.id}).map(k=>{var K,S;return((K=k.value)==null?void 0:K.valueAsType)||((S=k.value)==null?void 0:S.value)||""}),L=[E,w,...$].join(m);return{value:G.Success,error:null,result:L}}catch(y){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:y,result:null}}}})}}class $Pe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SPLIT_AT_INDEX,version:"1.0.0",description:"String split at index operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.SplitAtIndex);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1],y={firstPart:c.slice(0,e),secondPart:c.slice(e)};return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class LPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SPLIT_AT_ALL_SEPARATORS,version:"1.0.0",description:"String split at all the occurrences of separators operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.SplitAtAllSeparators);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1],y=c.split(e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class MPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SPLIT_AT_FIRST_SEPARATOR,version:"1.0.0",description:"String split at the first occurrence of a separator operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.SplitAtFirstSeparator);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1],y=c.indexOf(e),m={firstPart:c.slice(0,y),secondPart:c.slice(y+e.length)};return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class BPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SPLIT_AT_LAST_SEPARATOR,version:"1.0.0",description:"String split at the last occurrence of a separator operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.SplitAtLastSeparator);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1],y=c.lastIndexOf(e),m={firstPart:c.slice(0,y),secondPart:c.slice(y+e.length)};return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class GPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_DELETE_LAST_N_CHARS,version:"1.0.0",description:"String delete last number of characters operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.DeleteLastNChars);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1]??1;if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No string provided",result:null};const y=c.slice(0,-e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class kPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_DELETE_FIRST_N_CHARS,version:"1.0.0",description:"String delete first number of characters operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.DeleteFirstNChars);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1]??1;if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No string provided",result:null};const y=c.slice(0,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class jPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REVERSE,version:"1.0.0",description:"String reverse operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.Reverse);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)})[0];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No string provided",result:null};const e=c.split("").reverse().join("");return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class UPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TO_LOWER_CASE,version:"1.0.0",description:"String to lower case operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.ToLowerCase);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)})[0];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No string provided",result:null};const e=c.toLowerCase();return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class KPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TO_UPPER_CASE,version:"1.0.0",description:"String to upper case operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.ToUpperCase);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)})[0];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No string provided",result:null};const e=c.toUpperCase();return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class FPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_DELETE_AT_INDEX,version:"1.0.0",description:"String delete index operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.DeleteAtIndex);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(E=>{var b,w;return((b=E.value)==null?void 0:b.valueAsType)||((w=E.value)==null?void 0:w.value)}),c=s[0],e=s[1],y=s[2]??1;if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No string provided",result:null};const m=Math.min(y,c.length-e),v=c.slice(0,e)+c.slice(e+m);return{value:G.Success,error:null,result:v}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class SPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_ADD_AT_INDEX,version:"1.0.0",description:"String add index operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.AddAtIndex);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1],y=s[2];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No string provided",result:null};const m=c.slice(0,e)+y+c.slice(e);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class qPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_FIRST_N_CHARS,version:"1.0.0",description:"String replace first operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.ReplaceFirstNChars);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1]??1,y=s[2];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No string provided",result:null};const m=y+c.slice(e);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class ZPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_LAST_N_CHARS,version:"1.0.0",description:"String replace last operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.ReplaceLastNChars);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1]??1,y=s[2];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No string provided",result:null};const m=c.slice(0,-e)+y;return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class HPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_AT_INDEX,version:"1.0.0",description:"String replace index operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.ReplaceAtIndex);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(E=>{var b,w;return((b=E.value)==null?void 0:b.valueAsType)||((w=E.value)==null?void 0:w.value)}),c=s[0],e=s[1],y=s[2]??1,m=s[3];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No string provided",result:null};const v=(c.slice(0,e)||"")+m+(c.slice(e+y)||"");return{value:G.Success,error:null,result:v}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class WPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_FIRST_MATCH,version:"1.0.0",description:"String replace single match operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.ReplaceFirstMatch);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1],y=s[2];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No string provided",result:null};const m=c.replace(e,y);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class zPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_LAST_MATCH,version:"1.0.0",description:"String replace single match operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.ReplaceLastMatch);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(E=>{var b,w;return((b=E.value)==null?void 0:b.valueAsType)||((w=E.value)==null?void 0:w.value)}),c=s[0],e=s[1],y=s[2];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No string provided",result:null};const m=c.lastIndexOf(e),v=m===-1?c:c.substring(0,m)+y+c.substring(m+e.length);return{value:G.Success,error:null,result:v}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class JPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_ALL_MATCHES,version:"1.0.0",description:"String replace all matches operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.ReplaceAllMatches);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1],y=s[2];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No string provided",result:null};const m=c.split(e).join(y);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class YPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_INDEX_ITEM,version:"1.0.0",description:"String get index operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.GetIndexItem);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No string provided",result:null};const y=c.charAt(e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class XPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_LAST_N_CHARS,version:"1.0.0",description:"String get last N chars operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.GetLastNChars);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No string provided",result:null};const y=c.slice(-e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class QPe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_FIRST_N_CHARS,version:"1.0.0",description:"String get first N chars operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.GetFirstNChars);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No string provided",result:null};const y=c.slice(0,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class eNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_INDEX_OF,version:"1.0.0",description:"String get index of operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.GetIndexOf);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No string provided",result:null};if(typeof e!="string")return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No search value provided",result:null};const y=c.indexOf(e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class tNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_APPEND,version:"1.0.0",description:"String append operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.Append);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)||((b=v.value)==null?void 0:b.value)}),c=s[0],e=s[1];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No string provided",result:null};if(typeof e!="string")return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No value to append provided",result:null};const y=s.slice(2);if(!y.every(v=>typeof v=="string"))return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"All values to append must be strings",result:null};const m=[c,e,...y].join("");return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class iNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_PREPEND,version:"1.0.0",description:"String prepend operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(q.Prepend);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1];if(typeof c!="string")return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:"No string provided",result:null};const y=e+c;return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class rNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TRIM,version:"1.0.0",description:"String trim implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.Trim);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)}),c=s.trim();return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class nNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TRIM_START,version:"1.0.0",description:"String trimStart implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.TrimStart);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)}),c=s.trimStart();return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class aNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_TRIM_END,version:"1.0.0",description:"String trimEnd implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.TrimEnd);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)}),c=s.trimEnd();return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class sNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SUBSTRING,version:"1.0.0",description:"String substring(start, end?) implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.Substring);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c,e]=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)??((E=m.value)==null?void 0:E.value)}),y=s.substring(c,e??void 0);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class lNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SLICE,version:"1.0.0",description:"String slice(start, end?) implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.Slice);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c,e]=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)??((E=m.value)==null?void 0:E.value)}),y=s.slice(c,e??void 0);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class oNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_GET_LAST_INDEX_OF,version:"1.0.0",description:"String lastIndexOf(search, fromIndex?) implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.GetLastIndexOf);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c,e]=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)??((E=m.value)==null?void 0:E.value)}),y=s.lastIndexOf(c,e??void 0);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class dNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_PAD_START,version:"1.0.0",description:"String padStart(targetLength, padString?) implementation",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.PadStart);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c,e]=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)??((E=m.value)==null?void 0:E.value)}),y=s.padStart(c,e??void 0);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class uNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_PAD_END,version:"1.0.0",description:"String padEnd(targetLength, padString?) implementation",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.PadEnd);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c,e]=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)??((E=m.value)==null?void 0:E.value)}),y=s.padEnd(c,e??void 0);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class pNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPEAT,version:"1.0.0",description:"String repeat(count) implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.Repeat);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)??((v=y.value)==null?void 0:v.value)}),e=s.repeat(c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class cNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_MATCH_REGEX,version:"1.0.0",description:"String match(regex) -> first match array or null",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.MatchRegex);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c,e]=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)??((b=v.value)==null?void 0:b.value)}),y=new RegExp(String(c??""),e?String(e):void 0),m=String(s??"").match(y);return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class fNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_MATCH_ALL_REGEX,version:"1.0.0",description:"String matchAll(regex) -> array of matches",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.MatchAllRegex);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c,e]=n.map(b=>{var w,V;return((w=b.value)==null?void 0:w.valueAsType)??((V=b.value)==null?void 0:V.value)}),y=e?String(e):"",m=y.includes("g")?y:y+"g",v=new RegExp(String(c??""),m),E=Array.from(String(s??"").matchAll(v),b=>Array.from(b));return{value:G.Success,error:null,result:E}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class yNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_SEARCH_REGEX,version:"1.0.0",description:"String search(regex) -> index or -1",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.SearchRegex);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c,e]=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)??((E=m.value)==null?void 0:E.value)});let y=-1;try{const m=new RegExp(String(c??""),e?String(e):void 0);y=String(s??"").search(m)}catch{y=-1}return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class hNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REPLACE_REGEX,version:"1.0.0",description:"String replace using RegExp (pattern, replacement, flags?)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.ReplaceRegex);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c,e,y]=n.map(E=>{var b,w;return((b=E.value)==null?void 0:b.valueAsType)??((w=E.value)==null?void 0:w.value)});let m=String(s??"");const v=new RegExp(String(c??""),y?String(y):void 0);return m=m.replace(v,String(e??"")),{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class mNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_NORMALIZE_UNICODE,version:"1.0.0",description:"String normalize(form?) implementation module (NFC by default)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.NormalizeUnicode);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)??((v=y.value)==null?void 0:v.value)}),e=s.normalize(c||"NFC");return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}const MA=class MA extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REMOVE_DIACRITICS,version:"1.0.0",description:"Remove diacritics via NFD decomposition + strip combining marks",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.RemoveDiacritics);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)}),c=String(s??"").normalize("NFD").replace(MA.COMBINING_MARKS,"");return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}};I(MA,"COMBINING_MARKS",/[\u0300-\u036f]/g);let yA=MA;class TNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_COUNT_OCCURRENCES,version:"1.0.0",description:"Count literal substring occurrences in a string",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.CountOccurrences);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)??((b=v.value)==null?void 0:b.value)}),e=String(s??""),y=String(c??""),m=y===""?0:e.split(y).length-1;return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class vNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_ENSURE_PREFIX,version:"1.0.0",description:"Ensure string starts with given prefix (add if missing)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.EnsurePrefix);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)??((b=v.value)==null?void 0:b.value)}),e=String(s??""),y=String(c??""),m=e.startsWith(y)?e:y+e;return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class ENe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_ENSURE_SUFFIX,version:"1.0.0",description:"Ensure string ends with given suffix (add if missing)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.EnsureSuffix);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)??((b=v.value)==null?void 0:b.value)}),e=String(s??""),y=String(c??""),m=e.endsWith(y)?e:e+y;return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class bNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REMOVE_PREFIX,version:"1.0.0",description:"Remove prefix if present",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.RemovePrefix);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)??((b=v.value)==null?void 0:b.value)}),e=String(s??""),y=String(c??""),m=e.startsWith(y)?e.slice(y.length):e;return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class ANe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_REMOVE_SUFFIX,version:"1.0.0",description:"Remove suffix if present",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.RemoveSuffix);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)??((b=v.value)==null?void 0:b.value)}),e=String(s??""),y=String(c??""),m=e.endsWith(y)?e.slice(0,-y.length):e;return{value:G.Success,error:null,result:m}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class gNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_STARTS_WITH,version:"1.0.0",description:"String startsWith(needle) -> boolean",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.StartsWith);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)??((v=y.value)==null?void 0:v.value)});if(typeof s!="string"||typeof c!="string")throw new TypeError("StartsWith expects two strings.");const e=s.startsWith(c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class INe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_ENDS_WITH,version:"1.0.0",description:"String endsWith(needle) -> boolean",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.EndsWith);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)??((v=y.value)==null?void 0:v.value)});if(typeof s!="string"||typeof c!="string")throw new TypeError("EndsWith expects two strings.");const e=s.endsWith(c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class RNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_CONTAINS,version:"1.0.0",description:"String includes(needle) -> boolean",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.Contains);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)??((v=y.value)==null?void 0:v.value)});if(typeof s!="string"||typeof c!="string")throw new TypeError("Contains expects two strings.");const e=s.includes(c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class DNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__STRING_MATCHES_REGEX,version:"1.0.0",description:"Regex test: new RegExp(pattern, flags?).test(src) -> boolean",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(q.MatchesRegex);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c,e]=n.map(v=>{var E,b;return((E=v.value)==null?void 0:E.valueAsType)??((b=v.value)==null?void 0:b.value)});if(typeof s!="string"||typeof c!="string")throw new TypeError("MatchesRegex expects source and pattern to be strings.");if(!(e===void 0||typeof e=="string"))throw new TypeError("MatchesRegex flags must be a string if provided.");let y=!1;return y=new RegExp(c,e).test(s),{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}function wNe(o,p){const i=Number(o),s=10**Math.max(0,Number(p)||0);return Math.round(i*s)/s}function ONe(o,p){const i=Number(o),n=Math.abs(Number(p)||0);return n===0?i:Math.round(i/n)*n}function CNe(o,p,i){const n=Number(o),s=Number(p),c=Number(i);return Math.min(Math.max(n,s),c)}function _Ne(o,p,i,n,s){const c=Number(o),e=Number(p),y=Number(i),m=Number(n),v=Number(s);if(e===y)throw new Error("Input range cannot be zero");const E=(c-e)/(y-e);return m+E*(v-m)}function VNe(...o){const p=o.map(n=>Number(n));return p.length===0?0:p.reduce((n,s)=>n+s,0)/p.length}function PNe(...o){const p=o.map(n=>Number(n)).sort((n,s)=>n-s);if(p.length===0)return 0;const i=Math.floor(p.length/2);return p.length%2?p[i]:(p[i-1]+p[i])/2}function NNe(o,p){const i=Number(o),n=Number(p);return n===0?NaN:i<0&&n%2===1?-Math.pow(-i,1/n):Math.pow(i,1/n)}function xNe(o,p){const i=Number(o),n=Number(p);return i===0?1/0:(n-i)/i*100}const oi=o=>o.map(p=>{var i,n;return((i=p.value)==null?void 0:i.valueAsType)??((n=p.value)==null?void 0:n.value)});class $Ne extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ADDITION,version:"1.0.0",description:"Number addition operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(te.Addition);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const c=oi(n).reduce((e,y)=>e+y,0);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class LNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SUBTRACTION,version:"1.0.0",description:"Number subtraction operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(te.Subtraction);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const c=oi(n).reduce((e,y)=>e-y,0);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class MNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MULTIPLICATION,version:"1.0.0",description:"Number multiplication operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(te.Multiplication);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const c=oi(n).reduce((e,y)=>e*y,1);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class BNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_DIVISION,version:"1.0.0",description:"Number division operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(te.Division);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s,c]=oi(n);if(c===0)throw new Error("Division by zero is not allowed");const e=s/c;return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class GNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_REMAINDER,version:"1.0.0",description:"Number remainder operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(te.Remainder);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s,c]=oi(n);if(c===0)throw new Error("Division by zero is not allowed");const e=s%c;return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class kNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_EXPONENTIATION,version:"1.0.0",description:"Number exponentiation operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(te.Exponentiation);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s,c]=oi(n),e=Math.pow(s,c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class jNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_NEGATE,version:"1.0.0",description:"Number negate (unary -x)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.Negate);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=oi(n);return{value:G.Success,error:null,result:-s}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class UNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ABSOLUTE,version:"1.0.0",description:"Number absolute (|x|)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.Absolute);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=oi(n);return{value:G.Success,error:null,result:Math.abs(Number(s))}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class KNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SIGN,version:"1.0.0",description:"Number sign (-1 | 0 | 1)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.Sign);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=oi(n);return{value:G.Success,error:null,result:Math.sign(Number(s))}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class FNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ROUND,version:"1.0.0",description:"Number round to nearest integer",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.Round);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=oi(n);return{value:G.Success,error:null,result:Math.round(Number(s))}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class SNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_FLOOR,version:"1.0.0",description:"Number floor (⌊x⌋)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.Floor);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=oi(n);return{value:G.Success,error:null,result:Math.floor(Number(s))}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class qNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_CEIL,version:"1.0.0",description:"Number ceil (⌈x⌉)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.Ceil);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=oi(n);return{value:G.Success,error:null,result:Math.ceil(Number(s))}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class ZNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_TRUNC,version:"1.0.0",description:"Number truncation (drop fractional part)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.Trunc);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=oi(n);return{value:G.Success,error:null,result:Math.trunc(Number(s))}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class HNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ROUND_TO_DECIMALS,version:"1.0.0",description:"Round to N decimals",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.RoundToDecimals);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=oi(n),e=wNe(s,c);return{value:G.Success,error:null,result:e}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class WNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SNAP_TO_STEP,version:"1.0.0",description:"Snap a number to the nearest multiple of step (>=0 step)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.SnapToStep);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=oi(n),e=ONe(s,c);return{value:G.Success,error:null,result:e}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class zNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_CLAMP,version:"1.0.0",description:"Clamp value to [min, max]",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.Clamp);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c,e]=oi(n),y=CNe(s,c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class JNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MAP_RANGE,version:"1.0.0",description:"Map value from [inMin,inMax] to [outMin,outMax]",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.MapRange);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c,e,y,m]=oi(n),v=_Ne(s,c,e,y,m);return{value:G.Success,error:null,result:v}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class YNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_AVERAGE,version:"1.0.0",description:"Average(numbers...)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.Average);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const s=oi(n),c=VNe(...s);return{value:G.Success,error:null,result:c}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class XNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MEDIAN,version:"1.0.0",description:"Median(numbers...)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.Median);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const s=oi(n),c=PNe(...s);return{value:G.Success,error:null,result:c}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class QNe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MIN_OF,version:"1.0.0",description:"Min(numbers...)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.MinOf);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const s=oi(n).map(Number),c=s.length?Math.min(...s):1/0;return{value:G.Success,error:null,result:c}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class exe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MAX_OF,version:"1.0.0",description:"Max(numbers...)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.MaxOf);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const s=oi(n).map(Number),c=s.length?Math.max(...s):-1/0;return{value:G.Success,error:null,result:c}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class txe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SQUARE_ROOT,version:"1.0.0",description:"Square root",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.SquareRoot);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=oi(n);return{value:G.Success,error:null,result:Math.sqrt(Number(s))}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class ixe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_CUBE_ROOT,version:"1.0.0",description:"Cube root",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.CubeRoot);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=oi(n);return{value:G.Success,error:null,result:Math.cbrt(Number(s))}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class rxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_NTH_ROOT,version:"1.0.0",description:"Nth root (value, n)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.NthRoot);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=oi(n),e=NNe(s,c);return{value:G.Success,error:null,result:e}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class nxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_EXP,version:"1.0.0",description:"e^x",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.Exp);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=oi(n);return{value:G.Success,error:null,result:Math.exp(Number(s))}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class axe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_LOG_NATURAL,version:"1.0.0",description:"Natural log ln(x)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.LogNatural);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=oi(n);return{value:G.Success,error:null,result:Math.log(Number(s))}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class sxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_LOG10,version:"1.0.0",description:"Log base 10",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.Log10);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=oi(n),c=Number(s),e=Math.log10?Math.log10(c):Math.log(c)/Math.LN10;return{value:G.Success,error:null,result:e}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class lxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_SIN,version:"1.0.0",description:"sin(x in radians)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.Sin);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=oi(n);return{value:G.Success,error:null,result:Math.sin(Number(s))}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class oxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_COS,version:"1.0.0",description:"cos(x in radians)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.Cos);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=oi(n);return{value:G.Success,error:null,result:Math.cos(Number(s))}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class dxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_TAN,version:"1.0.0",description:"tan(x in radians)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.Tan);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=oi(n);return{value:G.Success,error:null,result:Math.tan(Number(s))}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class uxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ASIN,version:"1.0.0",description:"asin(x)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.Asin);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=oi(n);return{value:G.Success,error:null,result:Math.asin(Number(s))}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class pxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ACOS,version:"1.0.0",description:"acos(x)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.Acos);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=oi(n);return{value:G.Success,error:null,result:Math.acos(Number(s))}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class cxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ATAN,version:"1.0.0",description:"atan(x)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.Atan);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=oi(n);return{value:G.Success,error:null,result:Math.atan(Number(s))}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class fxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_ATAN2,version:"1.0.0",description:"atan2(y, x)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.Atan2);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=oi(n);return{value:G.Success,error:null,result:Math.atan2(Number(s),Number(c))}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class yxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_TO_RADIANS,version:"1.0.0",description:"deg → rad",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.ToRadians);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=oi(n);return{value:G.Success,error:null,result:Number(s)*Math.PI/180}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class hxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_TO_DEGREES,version:"1.0.0",description:"rad → deg",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.ToDegrees);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=oi(n);return{value:G.Success,error:null,result:Number(s)*180/Math.PI}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class mxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_PERCENT_OF,version:"1.0.0",description:"x percent of y",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.PercentOf);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=oi(n),e=Number(s)/100*Number(c);return{value:G.Success,error:null,result:e}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class JO extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_PERCENTAGE_CHANGE,version:"1.0.0",description:"((new-old)/old)*100",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.PercentageChange);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=oi(n),e=xNe(s,c);return{value:G.Success,error:null,result:e}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class Txe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_LESS_THAN,version:"1.0.0",description:"a < b",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.LessThan);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=oi(n);return{value:G.Success,error:null,result:s<c}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class vxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MORE_THAN,version:"1.0.0",description:"a > b",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.MoreThan);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=oi(n);return{value:G.Success,error:null,result:s>c}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class Exe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_LESS_THAN_OR_EQUAL,version:"1.0.0",description:"a <= b",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.LessThanOrEqual);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=oi(n);return{value:G.Success,error:null,result:s<=c}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class bxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__NUMBER_MORE_THAN_OR_EQUAL,version:"1.0.0",description:"a >= b",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(te.MoreThanOrEqual);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=oi(n);return{value:G.Success,error:null,result:s>=c}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}function Axe(o,p){return function(){return o.apply(p,arguments)}}const{toString:Jvi}=Object.prototype,{getPrototypeOf:tN}=Object,{iterator:qI,toStringTag:gxe}=Symbol,ZI=(o=>p=>{const i=Jvi.call(p);return o[i]||(o[i]=i.slice(8,-1).toLowerCase())})(Object.create(null)),Xl=o=>(o=o.toLowerCase(),p=>ZI(p)===o),HI=o=>p=>typeof p===o,{isArray:Mh}=Array,wy=HI("undefined");function lv(o){return o!==null&&!wy(o)&&o.constructor!==null&&!wy(o.constructor)&&Ga(o.constructor.isBuffer)&&o.constructor.isBuffer(o)}const Ixe=Xl("ArrayBuffer");function Yvi(o){let p;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?p=ArrayBuffer.isView(o):p=o&&o.buffer&&Ixe(o.buffer),p}const Xvi=HI("string"),Ga=HI("function"),Rxe=HI("number"),ov=o=>o!==null&&typeof o=="object",Qvi=o=>o===!0||o===!1,Kb=o=>{if(ZI(o)!=="object")return!1;const p=tN(o);return(p===null||p===Object.prototype||Object.getPrototypeOf(p)===null)&&!(gxe in o)&&!(qI in o)},eEi=o=>{if(!ov(o)||lv(o))return!1;try{return Object.keys(o).length===0&&Object.getPrototypeOf(o)===Object.prototype}catch{return!1}},tEi=Xl("Date"),iEi=Xl("File"),rEi=Xl("Blob"),nEi=Xl("FileList"),aEi=o=>ov(o)&&Ga(o.pipe),sEi=o=>{let p;return o&&(typeof FormData=="function"&&o instanceof FormData||Ga(o.append)&&((p=ZI(o))==="formdata"||p==="object"&&Ga(o.toString)&&o.toString()==="[object FormData]"))},lEi=Xl("URLSearchParams"),[oEi,dEi,uEi,pEi]=["ReadableStream","Request","Response","Headers"].map(Xl),cEi=o=>o.trim?o.trim():o.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function dv(o,p,{allOwnKeys:i=!1}={}){if(o===null||typeof o>"u")return;let n,s;if(typeof o!="object"&&(o=[o]),Mh(o))for(n=0,s=o.length;n<s;n++)p.call(null,o[n],n,o);else{if(lv(o))return;const c=i?Object.getOwnPropertyNames(o):Object.keys(o),e=c.length;let y;for(n=0;n<e;n++)y=c[n],p.call(null,o[y],y,o)}}function Dxe(o,p){if(lv(o))return null;p=p.toLowerCase();const i=Object.keys(o);let n=i.length,s;for(;n-- >0;)if(s=i[n],p===s.toLowerCase())return s;return null}const Ac=(()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global)(),wxe=o=>!wy(o)&&o!==Ac;function YO(){const{caseless:o,skipUndefined:p}=wxe(this)&&this||{},i={},n=(s,c)=>{const e=o&&Dxe(i,c)||c;Kb(i[e])&&Kb(s)?i[e]=YO(i[e],s):Kb(s)?i[e]=YO({},s):Mh(s)?i[e]=s.slice():(!p||!wy(s))&&(i[e]=s)};for(let s=0,c=arguments.length;s<c;s++)arguments[s]&&dv(arguments[s],n);return i}const fEi=(o,p,i,{allOwnKeys:n}={})=>(dv(p,(s,c)=>{i&&Ga(s)?o[c]=Axe(s,i):o[c]=s},{allOwnKeys:n}),o),yEi=o=>(o.charCodeAt(0)===65279&&(o=o.slice(1)),o),hEi=(o,p,i,n)=>{o.prototype=Object.create(p.prototype,n),o.prototype.constructor=o,Object.defineProperty(o,"super",{value:p.prototype}),i&&Object.assign(o.prototype,i)},mEi=(o,p,i,n)=>{let s,c,e;const y={};if(p=p||{},o==null)return p;do{for(s=Object.getOwnPropertyNames(o),c=s.length;c-- >0;)e=s[c],(!n||n(e,o,p))&&!y[e]&&(p[e]=o[e],y[e]=!0);o=i!==!1&&tN(o)}while(o&&(!i||i(o,p))&&o!==Object.prototype);return p},TEi=(o,p,i)=>{o=String(o),(i===void 0||i>o.length)&&(i=o.length),i-=p.length;const n=o.indexOf(p,i);return n!==-1&&n===i},vEi=o=>{if(!o)return null;if(Mh(o))return o;let p=o.length;if(!Rxe(p))return null;const i=new Array(p);for(;p-- >0;)i[p]=o[p];return i},EEi=(o=>p=>o&&p instanceof o)(typeof Uint8Array<"u"&&tN(Uint8Array)),bEi=(o,p)=>{const n=(o&&o[qI]).call(o);let s;for(;(s=n.next())&&!s.done;){const c=s.value;p.call(o,c[0],c[1])}},AEi=(o,p)=>{let i;const n=[];for(;(i=o.exec(p))!==null;)n.push(i);return n},gEi=Xl("HTMLFormElement"),IEi=o=>o.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(i,n,s){return n.toUpperCase()+s}),E4=(({hasOwnProperty:o})=>(p,i)=>o.call(p,i))(Object.prototype),REi=Xl("RegExp"),Oxe=(o,p)=>{const i=Object.getOwnPropertyDescriptors(o),n={};dv(i,(s,c)=>{let e;(e=p(s,c,o))!==!1&&(n[c]=e||s)}),Object.defineProperties(o,n)},DEi=o=>{Oxe(o,(p,i)=>{if(Ga(o)&&["arguments","caller","callee"].indexOf(i)!==-1)return!1;const n=o[i];if(Ga(n)){if(p.enumerable=!1,"writable"in p){p.writable=!1;return}p.set||(p.set=()=>{throw Error("Can not rewrite read-only method '"+i+"'")})}})},wEi=(o,p)=>{const i={},n=s=>{s.forEach(c=>{i[c]=!0})};return Mh(o)?n(o):n(String(o).split(p)),i},OEi=()=>{},CEi=(o,p)=>o!=null&&Number.isFinite(o=+o)?o:p;function _Ei(o){return!!(o&&Ga(o.append)&&o[gxe]==="FormData"&&o[qI])}const VEi=o=>{const p=new Array(10),i=(n,s)=>{if(ov(n)){if(p.indexOf(n)>=0)return;if(lv(n))return n;if(!("toJSON"in n)){p[s]=n;const c=Mh(n)?[]:{};return dv(n,(e,y)=>{const m=i(e,s+1);!wy(m)&&(c[y]=m)}),p[s]=void 0,c}}return n};return i(o,0)},PEi=Xl("AsyncFunction"),NEi=o=>o&&(ov(o)||Ga(o))&&Ga(o.then)&&Ga(o.catch),Cxe=((o,p)=>o?setImmediate:p?((i,n)=>(Ac.addEventListener("message",({source:s,data:c})=>{s===Ac&&c===i&&n.length&&n.shift()()},!1),s=>{n.push(s),Ac.postMessage(i,"*")}))(`axios@${Math.random()}`,[]):i=>setTimeout(i))(typeof setImmediate=="function",Ga(Ac.postMessage)),xEi=typeof queueMicrotask<"u"?queueMicrotask.bind(Ac):typeof process<"u"&&process.nextTick||Cxe,$Ei=o=>o!=null&&Ga(o[qI]),Ue={isArray:Mh,isArrayBuffer:Ixe,isBuffer:lv,isFormData:sEi,isArrayBufferView:Yvi,isString:Xvi,isNumber:Rxe,isBoolean:Qvi,isObject:ov,isPlainObject:Kb,isEmptyObject:eEi,isReadableStream:oEi,isRequest:dEi,isResponse:uEi,isHeaders:pEi,isUndefined:wy,isDate:tEi,isFile:iEi,isBlob:rEi,isRegExp:REi,isFunction:Ga,isStream:aEi,isURLSearchParams:lEi,isTypedArray:EEi,isFileList:nEi,forEach:dv,merge:YO,extend:fEi,trim:cEi,stripBOM:yEi,inherits:hEi,toFlatObject:mEi,kindOf:ZI,kindOfTest:Xl,endsWith:TEi,toArray:vEi,forEachEntry:bEi,matchAll:AEi,isHTMLForm:gEi,hasOwnProperty:E4,hasOwnProp:E4,reduceDescriptors:Oxe,freezeMethods:DEi,toObjectSet:wEi,toCamelCase:IEi,noop:OEi,toFiniteNumber:CEi,findKey:Dxe,global:Ac,isContextDefined:wxe,isSpecCompliantForm:_Ei,toJSONObject:VEi,isAsyncFn:PEi,isThenable:NEi,setImmediate:Cxe,asap:xEi,isIterable:$Ei};function ai(o,p,i,n,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=o,this.name="AxiosError",p&&(this.code=p),i&&(this.config=i),n&&(this.request=n),s&&(this.response=s,this.status=s.status?s.status:null)}Ue.inherits(ai,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Ue.toJSONObject(this.config),code:this.code,status:this.status}}});const _xe=ai.prototype,Vxe={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(o=>{Vxe[o]={value:o}});Object.defineProperties(ai,Vxe);Object.defineProperty(_xe,"isAxiosError",{value:!0});ai.from=(o,p,i,n,s,c)=>{const e=Object.create(_xe);Ue.toFlatObject(o,e,function(E){return E!==Error.prototype},v=>v!=="isAxiosError");const y=o&&o.message?o.message:"Error",m=p==null&&o?o.code:p;return ai.call(e,y,m,i,n,s),o&&e.cause==null&&Object.defineProperty(e,"cause",{value:o,configurable:!0}),e.name=o&&o.name||"Error",c&&Object.assign(e,c),e};const LEi=null;function XO(o){return Ue.isPlainObject(o)||Ue.isArray(o)}function Pxe(o){return Ue.endsWith(o,"[]")?o.slice(0,-2):o}function b4(o,p,i){return o?o.concat(p).map(function(s,c){return s=Pxe(s),!i&&c?"["+s+"]":s}).join(i?".":""):p}function MEi(o){return Ue.isArray(o)&&!o.some(XO)}const BEi=Ue.toFlatObject(Ue,{},null,function(p){return/^is[A-Z]/.test(p)});function WI(o,p,i){if(!Ue.isObject(o))throw new TypeError("target must be an object");p=p||new FormData,i=Ue.toFlatObject(i,{metaTokens:!0,dots:!1,indexes:!1},!1,function(L,k){return!Ue.isUndefined(k[L])});const n=i.metaTokens,s=i.visitor||E,c=i.dots,e=i.indexes,m=(i.Blob||typeof Blob<"u"&&Blob)&&Ue.isSpecCompliantForm(p);if(!Ue.isFunction(s))throw new TypeError("visitor must be a function");function v($){if($===null)return"";if(Ue.isDate($))return $.toISOString();if(Ue.isBoolean($))return $.toString();if(!m&&Ue.isBlob($))throw new ai("Blob is not supported. Use a Buffer instead.");return Ue.isArrayBuffer($)||Ue.isTypedArray($)?m&&typeof Blob=="function"?new Blob([$]):Buffer.from($):$}function E($,L,k){let K=$;if($&&!k&&typeof $=="object"){if(Ue.endsWith(L,"{}"))L=n?L:L.slice(0,-2),$=JSON.stringify($);else if(Ue.isArray($)&&MEi($)||(Ue.isFileList($)||Ue.endsWith(L,"[]"))&&(K=Ue.toArray($)))return L=Pxe(L),K.forEach(function(Y,re){!(Ue.isUndefined(Y)||Y===null)&&p.append(e===!0?b4([L],re,c):e===null?L:L+"[]",v(Y))}),!1}return XO($)?!0:(p.append(b4(k,L,c),v($)),!1)}const b=[],w=Object.assign(BEi,{defaultVisitor:E,convertValue:v,isVisitable:XO});function V($,L){if(!Ue.isUndefined($)){if(b.indexOf($)!==-1)throw Error("Circular reference detected in "+L.join("."));b.push($),Ue.forEach($,function(K,S){(!(Ue.isUndefined(K)||K===null)&&s.call(p,K,Ue.isString(S)?S.trim():S,L,w))===!0&&V(K,L?L.concat(S):[S])}),b.pop()}}if(!Ue.isObject(o))throw new TypeError("data must be an object");return V(o),p}function A4(o){const p={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(o).replace(/[!'()~]|%20|%00/g,function(n){return p[n]})}function iN(o,p){this._pairs=[],o&&WI(o,this,p)}const Nxe=iN.prototype;Nxe.append=function(p,i){this._pairs.push([p,i])};Nxe.toString=function(p){const i=p?function(n){return p.call(this,n,A4)}:A4;return this._pairs.map(function(s){return i(s[0])+"="+i(s[1])},"").join("&")};function GEi(o){return encodeURIComponent(o).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function xxe(o,p,i){if(!p)return o;const n=i&&i.encode||GEi;Ue.isFunction(i)&&(i={serialize:i});const s=i&&i.serialize;let c;if(s?c=s(p,i):c=Ue.isURLSearchParams(p)?p.toString():new iN(p,i).toString(n),c){const e=o.indexOf("#");e!==-1&&(o=o.slice(0,e)),o+=(o.indexOf("?")===-1?"?":"&")+c}return o}class kEi{constructor(){this.handlers=[]}use(p,i,n){return this.handlers.push({fulfilled:p,rejected:i,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(p){this.handlers[p]&&(this.handlers[p]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(p){Ue.forEach(this.handlers,function(n){n!==null&&p(n)})}}const g4=kEi,$xe={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},jEi=typeof URLSearchParams<"u"?URLSearchParams:iN,UEi=typeof FormData<"u"?FormData:null,KEi=typeof Blob<"u"?Blob:null,FEi={isBrowser:!0,classes:{URLSearchParams:jEi,FormData:UEi,Blob:KEi},protocols:["http","https","file","blob","url","data"]},rN=typeof window<"u"&&typeof document<"u",QO=typeof navigator=="object"&&navigator||void 0,SEi=rN&&(!QO||["ReactNative","NativeScript","NS"].indexOf(QO.product)<0),qEi=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),ZEi=rN&&window.location.href||"http://localhost",HEi=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:rN,hasStandardBrowserEnv:SEi,hasStandardBrowserWebWorkerEnv:qEi,navigator:QO,origin:ZEi},Symbol.toStringTag,{value:"Module"})),na={...HEi,...FEi};function WEi(o,p){return WI(o,new na.classes.URLSearchParams,{visitor:function(i,n,s,c){return na.isNode&&Ue.isBuffer(i)?(this.append(n,i.toString("base64")),!1):c.defaultVisitor.apply(this,arguments)},...p})}function zEi(o){return Ue.matchAll(/\w+|\[(\w*)]/g,o).map(p=>p[0]==="[]"?"":p[1]||p[0])}function JEi(o){const p={},i=Object.keys(o);let n;const s=i.length;let c;for(n=0;n<s;n++)c=i[n],p[c]=o[c];return p}function Lxe(o){function p(i,n,s,c){let e=i[c++];if(e==="__proto__")return!0;const y=Number.isFinite(+e),m=c>=i.length;return e=!e&&Ue.isArray(s)?s.length:e,m?(Ue.hasOwnProp(s,e)?s[e]=[s[e],n]:s[e]=n,!y):((!s[e]||!Ue.isObject(s[e]))&&(s[e]=[]),p(i,n,s[e],c)&&Ue.isArray(s[e])&&(s[e]=JEi(s[e])),!y)}if(Ue.isFormData(o)&&Ue.isFunction(o.entries)){const i={};return Ue.forEachEntry(o,(n,s)=>{p(zEi(n),s,i,0)}),i}return null}function YEi(o,p,i){if(Ue.isString(o))try{return(p||JSON.parse)(o),Ue.trim(o)}catch(n){if(n.name!=="SyntaxError")throw n}return(i||JSON.stringify)(o)}const nN={transitional:$xe,adapter:["xhr","http","fetch"],transformRequest:[function(p,i){const n=i.getContentType()||"",s=n.indexOf("application/json")>-1,c=Ue.isObject(p);if(c&&Ue.isHTMLForm(p)&&(p=new FormData(p)),Ue.isFormData(p))return s?JSON.stringify(Lxe(p)):p;if(Ue.isArrayBuffer(p)||Ue.isBuffer(p)||Ue.isStream(p)||Ue.isFile(p)||Ue.isBlob(p)||Ue.isReadableStream(p))return p;if(Ue.isArrayBufferView(p))return p.buffer;if(Ue.isURLSearchParams(p))return i.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),p.toString();let y;if(c){if(n.indexOf("application/x-www-form-urlencoded")>-1)return WEi(p,this.formSerializer).toString();if((y=Ue.isFileList(p))||n.indexOf("multipart/form-data")>-1){const m=this.env&&this.env.FormData;return WI(y?{"files[]":p}:p,m&&new m,this.formSerializer)}}return c||s?(i.setContentType("application/json",!1),YEi(p)):p}],transformResponse:[function(p){const i=this.transitional||nN.transitional,n=i&&i.forcedJSONParsing,s=this.responseType==="json";if(Ue.isResponse(p)||Ue.isReadableStream(p))return p;if(p&&Ue.isString(p)&&(n&&!this.responseType||s)){const e=!(i&&i.silentJSONParsing)&&s;try{return JSON.parse(p,this.parseReviver)}catch(y){if(e)throw y.name==="SyntaxError"?ai.from(y,ai.ERR_BAD_RESPONSE,this,null,this.response):y}}return p}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:na.classes.FormData,Blob:na.classes.Blob},validateStatus:function(p){return p>=200&&p<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Ue.forEach(["delete","get","head","post","put","patch"],o=>{nN.headers[o]={}});const aN=nN,XEi=Ue.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),QEi=o=>{const p={};let i,n,s;return o&&o.split(`
|
|
88
88
|
`).forEach(function(e){s=e.indexOf(":"),i=e.substring(0,s).trim().toLowerCase(),n=e.substring(s+1).trim(),!(!i||p[i]&&XEi[i])&&(i==="set-cookie"?p[i]?p[i].push(n):p[i]=[n]:p[i]=p[i]?p[i]+", "+n:n)}),p},I4=Symbol("internals");function U0(o){return o&&String(o).trim().toLowerCase()}function Fb(o){return o===!1||o==null?o:Ue.isArray(o)?o.map(Fb):String(o)}function ebi(o){const p=Object.create(null),i=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=i.exec(o);)p[n[1]]=n[2];return p}const tbi=o=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(o.trim());function TO(o,p,i,n,s){if(Ue.isFunction(n))return n.call(this,p,i);if(s&&(p=i),!!Ue.isString(p)){if(Ue.isString(n))return p.indexOf(n)!==-1;if(Ue.isRegExp(n))return n.test(p)}}function ibi(o){return o.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(p,i,n)=>i.toUpperCase()+n)}function rbi(o,p){const i=Ue.toCamelCase(" "+p);["get","set","has"].forEach(n=>{Object.defineProperty(o,n+i,{value:function(s,c,e){return this[n].call(this,p,s,c,e)},configurable:!0})})}class zI{constructor(p){p&&this.set(p)}set(p,i,n){const s=this;function c(y,m,v){const E=U0(m);if(!E)throw new Error("header name must be a non-empty string");const b=Ue.findKey(s,E);(!b||s[b]===void 0||v===!0||v===void 0&&s[b]!==!1)&&(s[b||m]=Fb(y))}const e=(y,m)=>Ue.forEach(y,(v,E)=>c(v,E,m));if(Ue.isPlainObject(p)||p instanceof this.constructor)e(p,i);else if(Ue.isString(p)&&(p=p.trim())&&!tbi(p))e(QEi(p),i);else if(Ue.isObject(p)&&Ue.isIterable(p)){let y={},m,v;for(const E of p){if(!Ue.isArray(E))throw TypeError("Object iterator must return a key-value pair");y[v=E[0]]=(m=y[v])?Ue.isArray(m)?[...m,E[1]]:[m,E[1]]:E[1]}e(y,i)}else p!=null&&c(i,p,n);return this}get(p,i){if(p=U0(p),p){const n=Ue.findKey(this,p);if(n){const s=this[n];if(!i)return s;if(i===!0)return ebi(s);if(Ue.isFunction(i))return i.call(this,s,n);if(Ue.isRegExp(i))return i.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(p,i){if(p=U0(p),p){const n=Ue.findKey(this,p);return!!(n&&this[n]!==void 0&&(!i||TO(this,this[n],n,i)))}return!1}delete(p,i){const n=this;let s=!1;function c(e){if(e=U0(e),e){const y=Ue.findKey(n,e);y&&(!i||TO(n,n[y],y,i))&&(delete n[y],s=!0)}}return Ue.isArray(p)?p.forEach(c):c(p),s}clear(p){const i=Object.keys(this);let n=i.length,s=!1;for(;n--;){const c=i[n];(!p||TO(this,this[c],c,p,!0))&&(delete this[c],s=!0)}return s}normalize(p){const i=this,n={};return Ue.forEach(this,(s,c)=>{const e=Ue.findKey(n,c);if(e){i[e]=Fb(s),delete i[c];return}const y=p?ibi(c):String(c).trim();y!==c&&delete i[c],i[y]=Fb(s),n[y]=!0}),this}concat(...p){return this.constructor.concat(this,...p)}toJSON(p){const i=Object.create(null);return Ue.forEach(this,(n,s)=>{n!=null&&n!==!1&&(i[s]=p&&Ue.isArray(n)?n.join(", "):n)}),i}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([p,i])=>p+": "+i).join(`
|
|
89
89
|
`)}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 n=new this(p);return i.forEach(s=>n.set(s)),n}static accessor(p){const n=(this[I4]=this[I4]={accessors:{}}).accessors,s=this.prototype;function c(e){const y=U0(e);n[y]||(rbi(s,e),n[y]=!0)}return Ue.isArray(p)?p.forEach(c):c(p),this}}zI.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);Ue.reduceDescriptors(zI.prototype,({value:o},p)=>{let i=p[0].toUpperCase()+p.slice(1);return{get:()=>o,set(n){this[i]=n}}});Ue.freezeMethods(zI);const El=zI;function vO(o,p){const i=this||aN,n=p||i,s=El.from(n.headers);let c=n.data;return Ue.forEach(o,function(y){c=y.call(i,c,s.normalize(),p?p.status:void 0)}),s.normalize(),c}function Mxe(o){return!!(o&&o.__CANCEL__)}function Bh(o,p,i){ai.call(this,o??"canceled",ai.ERR_CANCELED,p,i),this.name="CanceledError"}Ue.inherits(Bh,ai,{__CANCEL__:!0});function Bxe(o,p,i){const n=i.config.validateStatus;!i.status||!n||n(i.status)?o(i):p(new ai("Request failed with status code "+i.status,[ai.ERR_BAD_REQUEST,ai.ERR_BAD_RESPONSE][Math.floor(i.status/100)-4],i.config,i.request,i))}function nbi(o){const p=/^([-+\w]{1,25})(:?\/\/|:)/.exec(o);return p&&p[1]||""}function abi(o,p){o=o||10;const i=new Array(o),n=new Array(o);let s=0,c=0,e;return p=p!==void 0?p:1e3,function(m){const v=Date.now(),E=n[c];e||(e=v),i[s]=m,n[s]=v;let b=c,w=0;for(;b!==s;)w+=i[b++],b=b%o;if(s=(s+1)%o,s===c&&(c=(c+1)%o),v-e<p)return;const V=E&&v-E;return V?Math.round(w*1e3/V):void 0}}function sbi(o,p){let i=0,n=1e3/p,s,c;const e=(v,E=Date.now())=>{i=E,s=null,c&&(clearTimeout(c),c=null),o(...v)};return[(...v)=>{const E=Date.now(),b=E-i;b>=n?e(v,E):(s=v,c||(c=setTimeout(()=>{c=null,e(s)},n-b)))},()=>s&&e(s)]}const hA=(o,p,i=3)=>{let n=0;const s=abi(50,250);return sbi(c=>{const e=c.loaded,y=c.lengthComputable?c.total:void 0,m=e-n,v=s(m),E=e<=y;n=e;const b={loaded:e,total:y,progress:y?e/y:void 0,bytes:m,rate:v||void 0,estimated:v&&y&&E?(y-e)/v:void 0,event:c,lengthComputable:y!=null,[p?"download":"upload"]:!0};o(b)},i)},R4=(o,p)=>{const i=o!=null;return[n=>p[0]({lengthComputable:i,total:o,loaded:n}),p[1]]},D4=o=>(...p)=>Ue.asap(()=>o(...p)),lbi=na.hasStandardBrowserEnv?((o,p)=>i=>(i=new URL(i,na.origin),o.protocol===i.protocol&&o.host===i.host&&(p||o.port===i.port)))(new URL(na.origin),na.navigator&&/(msie|trident)/i.test(na.navigator.userAgent)):()=>!0,obi=na.hasStandardBrowserEnv?{write(o,p,i,n,s,c,e){if(typeof document>"u")return;const y=[`${o}=${encodeURIComponent(p)}`];Ue.isNumber(i)&&y.push(`expires=${new Date(i).toUTCString()}`),Ue.isString(n)&&y.push(`path=${n}`),Ue.isString(s)&&y.push(`domain=${s}`),c===!0&&y.push("secure"),Ue.isString(e)&&y.push(`SameSite=${e}`),document.cookie=y.join("; ")},read(o){if(typeof document>"u")return null;const p=document.cookie.match(new RegExp("(?:^|; )"+o+"=([^;]*)"));return p?decodeURIComponent(p[1]):null},remove(o){this.write(o,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function dbi(o){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(o)}function ubi(o,p){return p?o.replace(/\/?\/$/,"")+"/"+p.replace(/^\/+/,""):o}function Gxe(o,p,i){let n=!dbi(p);return o&&(n||i==!1)?ubi(o,p):p}const w4=o=>o instanceof El?{...o}:o;function Cc(o,p){p=p||{};const i={};function n(v,E,b,w){return Ue.isPlainObject(v)&&Ue.isPlainObject(E)?Ue.merge.call({caseless:w},v,E):Ue.isPlainObject(E)?Ue.merge({},E):Ue.isArray(E)?E.slice():E}function s(v,E,b,w){if(Ue.isUndefined(E)){if(!Ue.isUndefined(v))return n(void 0,v,b,w)}else return n(v,E,b,w)}function c(v,E){if(!Ue.isUndefined(E))return n(void 0,E)}function e(v,E){if(Ue.isUndefined(E)){if(!Ue.isUndefined(v))return n(void 0,v)}else return n(void 0,E)}function y(v,E,b){if(b in p)return n(v,E);if(b in o)return n(void 0,v)}const m={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:y,headers:(v,E,b)=>s(w4(v),w4(E),b,!0)};return Ue.forEach(Object.keys({...o,...p}),function(E){const b=m[E]||s,w=b(o[E],p[E],E);Ue.isUndefined(w)&&b!==y||(i[E]=w)}),i}const kxe=o=>{const p=Cc({},o);let{data:i,withXSRFToken:n,xsrfHeaderName:s,xsrfCookieName:c,headers:e,auth:y}=p;if(p.headers=e=El.from(e),p.url=xxe(Gxe(p.baseURL,p.url,p.allowAbsoluteUrls),o.params,o.paramsSerializer),y&&e.set("Authorization","Basic "+btoa((y.username||"")+":"+(y.password?unescape(encodeURIComponent(y.password)):""))),Ue.isFormData(i)){if(na.hasStandardBrowserEnv||na.hasStandardBrowserWebWorkerEnv)e.setContentType(void 0);else if(Ue.isFunction(i.getHeaders)){const m=i.getHeaders(),v=["content-type","content-length"];Object.entries(m).forEach(([E,b])=>{v.includes(E.toLowerCase())&&e.set(E,b)})}}if(na.hasStandardBrowserEnv&&(n&&Ue.isFunction(n)&&(n=n(p)),n||n!==!1&&lbi(p.url))){const m=s&&c&&obi.read(c);m&&e.set(s,m)}return p},pbi=typeof XMLHttpRequest<"u",cbi=pbi&&function(o){return new Promise(function(i,n){const s=kxe(o);let c=s.data;const e=El.from(s.headers).normalize();let{responseType:y,onUploadProgress:m,onDownloadProgress:v}=s,E,b,w,V,$;function L(){V&&V(),$&&$(),s.cancelToken&&s.cancelToken.unsubscribe(E),s.signal&&s.signal.removeEventListener("abort",E)}let k=new XMLHttpRequest;k.open(s.method.toUpperCase(),s.url,!0),k.timeout=s.timeout;function K(){if(!k)return;const Y=El.from("getAllResponseHeaders"in k&&k.getAllResponseHeaders()),ee={data:!y||y==="text"||y==="json"?k.responseText:k.response,status:k.status,statusText:k.statusText,headers:Y,config:o,request:k};Bxe(function(le){i(le),L()},function(le){n(le),L()},ee),k=null}"onloadend"in k?k.onloadend=K:k.onreadystatechange=function(){!k||k.readyState!==4||k.status===0&&!(k.responseURL&&k.responseURL.indexOf("file:")===0)||setTimeout(K)},k.onabort=function(){k&&(n(new ai("Request aborted",ai.ECONNABORTED,o,k)),k=null)},k.onerror=function(re){const ee=re&&re.message?re.message:"Network Error",de=new ai(ee,ai.ERR_NETWORK,o,k);de.event=re||null,n(de),k=null},k.ontimeout=function(){let re=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const ee=s.transitional||$xe;s.timeoutErrorMessage&&(re=s.timeoutErrorMessage),n(new ai(re,ee.clarifyTimeoutError?ai.ETIMEDOUT:ai.ECONNABORTED,o,k)),k=null},c===void 0&&e.setContentType(null),"setRequestHeader"in k&&Ue.forEach(e.toJSON(),function(re,ee){k.setRequestHeader(ee,re)}),Ue.isUndefined(s.withCredentials)||(k.withCredentials=!!s.withCredentials),y&&y!=="json"&&(k.responseType=s.responseType),v&&([w,$]=hA(v,!0),k.addEventListener("progress",w)),m&&k.upload&&([b,V]=hA(m),k.upload.addEventListener("progress",b),k.upload.addEventListener("loadend",V)),(s.cancelToken||s.signal)&&(E=Y=>{k&&(n(!Y||Y.type?new Bh(null,o,k):Y),k.abort(),k=null)},s.cancelToken&&s.cancelToken.subscribe(E),s.signal&&(s.signal.aborted?E():s.signal.addEventListener("abort",E)));const S=nbi(s.url);if(S&&na.protocols.indexOf(S)===-1){n(new ai("Unsupported protocol "+S+":",ai.ERR_BAD_REQUEST,o));return}k.send(c||null)})},fbi=(o,p)=>{const{length:i}=o=o?o.filter(Boolean):[];if(p||i){let n=new AbortController,s;const c=function(v){if(!s){s=!0,y();const E=v instanceof Error?v:this.reason;n.abort(E instanceof ai?E:new Bh(E instanceof Error?E.message:E))}};let e=p&&setTimeout(()=>{e=null,c(new ai(`timeout ${p} of ms exceeded`,ai.ETIMEDOUT))},p);const y=()=>{o&&(e&&clearTimeout(e),e=null,o.forEach(v=>{v.unsubscribe?v.unsubscribe(c):v.removeEventListener("abort",c)}),o=null)};o.forEach(v=>v.addEventListener("abort",c));const{signal:m}=n;return m.unsubscribe=()=>Ue.asap(y),m}},ybi=fbi,hbi=function*(o,p){let i=o.byteLength;if(!p||i<p){yield o;return}let n=0,s;for(;n<i;)s=n+p,yield o.slice(n,s),n=s},mbi=async function*(o,p){for await(const i of Tbi(o))yield*hbi(i,p)},Tbi=async function*(o){if(o[Symbol.asyncIterator]){yield*o;return}const p=o.getReader();try{for(;;){const{done:i,value:n}=await p.read();if(i)break;yield n}}finally{await p.cancel()}},O4=(o,p,i,n)=>{const s=mbi(o,p);let c=0,e,y=m=>{e||(e=!0,n&&n(m))};return new ReadableStream({async pull(m){try{const{done:v,value:E}=await s.next();if(v){y(),m.close();return}let b=E.byteLength;if(i){let w=c+=b;i(w)}m.enqueue(new Uint8Array(E))}catch(v){throw y(v),v}},cancel(m){return y(m),s.return()}},{highWaterMark:2})},C4=64*1024,{isFunction:$b}=Ue,vbi=(({Request:o,Response:p})=>({Request:o,Response:p}))(Ue.global),{ReadableStream:_4,TextEncoder:V4}=Ue.global,P4=(o,...p)=>{try{return!!o(...p)}catch{return!1}},Ebi=o=>{o=Ue.merge.call({skipUndefined:!0},vbi,o);const{fetch:p,Request:i,Response:n}=o,s=p?$b(p):typeof fetch=="function",c=$b(i),e=$b(n);if(!s)return!1;const y=s&&$b(_4),m=s&&(typeof V4=="function"?($=>L=>$.encode(L))(new V4):async $=>new Uint8Array(await new i($).arrayBuffer())),v=c&&y&&P4(()=>{let $=!1;const L=new i(na.origin,{body:new _4,method:"POST",get duplex(){return $=!0,"half"}}).headers.has("Content-Type");return $&&!L}),E=e&&y&&P4(()=>Ue.isReadableStream(new n("").body)),b={stream:E&&($=>$.body)};s&&["text","arrayBuffer","blob","formData","stream"].forEach($=>{!b[$]&&(b[$]=(L,k)=>{let K=L&&L[$];if(K)return K.call(L);throw new ai(`Response type '${$}' is not supported`,ai.ERR_NOT_SUPPORT,k)})});const w=async $=>{if($==null)return 0;if(Ue.isBlob($))return $.size;if(Ue.isSpecCompliantForm($))return(await new i(na.origin,{method:"POST",body:$}).arrayBuffer()).byteLength;if(Ue.isArrayBufferView($)||Ue.isArrayBuffer($))return $.byteLength;if(Ue.isURLSearchParams($)&&($=$+""),Ue.isString($))return(await m($)).byteLength},V=async($,L)=>{const k=Ue.toFiniteNumber($.getContentLength());return k??w(L)};return async $=>{let{url:L,method:k,data:K,signal:S,cancelToken:Y,timeout:re,onDownloadProgress:ee,onUploadProgress:de,responseType:le,headers:fe,withCredentials:ve="same-origin",fetchOptions:ue}=kxe($),ye=p||fetch;le=le?(le+"").toLowerCase():"text";let Ve=ybi([S,Y&&Y.toAbortSignal()],re),_e=null;const $e=Ve&&Ve.unsubscribe&&(()=>{Ve.unsubscribe()});let Ne;try{if(de&&v&&k!=="get"&&k!=="head"&&(Ne=await V(fe,K))!==0){let lt=new i(L,{method:"POST",body:K,duplex:"half"}),ot;if(Ue.isFormData(K)&&(ot=lt.headers.get("content-type"))&&fe.setContentType(ot),lt.body){const[Rt,Pt]=R4(Ne,hA(D4(de)));K=O4(lt.body,C4,Rt,Pt)}}Ue.isString(ve)||(ve=ve?"include":"omit");const Be=c&&"credentials"in i.prototype,Se={...ue,signal:Ve,method:k.toUpperCase(),headers:fe.normalize().toJSON(),body:K,duplex:"half",credentials:Be?ve:void 0};_e=c&&new i(L,Se);let je=await(c?ye(_e,ue):ye(L,Se));const Ze=E&&(le==="stream"||le==="response");if(E&&(ee||Ze&&$e)){const lt={};["status","statusText","headers"].forEach(Di=>{lt[Di]=je[Di]});const ot=Ue.toFiniteNumber(je.headers.get("content-length")),[Rt,Pt]=ee&&R4(ot,hA(D4(ee),!0))||[];je=new n(O4(je.body,C4,Rt,()=>{Pt&&Pt(),$e&&$e()}),lt)}le=le||"text";let Ye=await b[Ue.findKey(b,le)||"text"](je,$);return!Ze&&$e&&$e(),await new Promise((lt,ot)=>{Bxe(lt,ot,{data:Ye,headers:El.from(je.headers),status:je.status,statusText:je.statusText,config:$,request:_e})})}catch(Be){throw $e&&$e(),Be&&Be.name==="TypeError"&&/Load failed|fetch/i.test(Be.message)?Object.assign(new ai("Network Error",ai.ERR_NETWORK,$,_e),{cause:Be.cause||Be}):ai.from(Be,Be&&Be.code,$,_e)}}},bbi=new Map,jxe=o=>{let p=o&&o.env||{};const{fetch:i,Request:n,Response:s}=p,c=[n,s,i];let e=c.length,y=e,m,v,E=bbi;for(;y--;)m=c[y],v=E.get(m),v===void 0&&E.set(m,v=y?new Map:Ebi(p)),E=v;return v};jxe();const sN={http:LEi,xhr:cbi,fetch:{get:jxe}};Ue.forEach(sN,(o,p)=>{if(o){try{Object.defineProperty(o,"name",{value:p})}catch{}Object.defineProperty(o,"adapterName",{value:p})}});const N4=o=>`- ${o}`,Abi=o=>Ue.isFunction(o)||o===null||o===!1;function gbi(o,p){o=Ue.isArray(o)?o:[o];const{length:i}=o;let n,s;const c={};for(let e=0;e<i;e++){n=o[e];let y;if(s=n,!Abi(n)&&(s=sN[(y=String(n)).toLowerCase()],s===void 0))throw new ai(`Unknown adapter '${y}'`);if(s&&(Ue.isFunction(s)||(s=s.get(p))))break;c[y||"#"+e]=s}if(!s){const e=Object.entries(c).map(([m,v])=>`adapter ${m} `+(v===!1?"is not supported by the environment":"is not available in the build"));let y=i?e.length>1?`since :
|
|
90
90
|
`+e.map(N4).join(`
|
|
@@ -92,10 +92,10 @@ This is likely an incorrect strategy, either the '${this.type}' entity doesn't n
|
|
|
92
92
|
`+c):n.stack=c}catch{}}throw n}}_request(p,i){typeof p=="string"?(i=i||{},i.url=p):i=p||{},i=Cc(this.defaults,i);const{transitional:n,paramsSerializer:s,headers:c}=i;n!==void 0&&Sb.assertOptions(n,{silentJSONParsing:Eo.transitional(Eo.boolean),forcedJSONParsing:Eo.transitional(Eo.boolean),clarifyTimeoutError:Eo.transitional(Eo.boolean)},!1),s!=null&&(Ue.isFunction(s)?i.paramsSerializer={serialize:s}:Sb.assertOptions(s,{encode:Eo.function,serialize:Eo.function},!0)),i.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?i.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:i.allowAbsoluteUrls=!0),Sb.assertOptions(i,{baseUrl:Eo.spelling("baseURL"),withXsrfToken:Eo.spelling("withXSRFToken")},!0),i.method=(i.method||this.defaults.method||"get").toLowerCase();let e=c&&Ue.merge(c.common,c[i.method]);c&&Ue.forEach(["delete","get","head","post","put","patch","common"],$=>{delete c[$]}),i.headers=El.concat(e,c);const y=[];let m=!0;this.interceptors.request.forEach(function(L){typeof L.runWhen=="function"&&L.runWhen(i)===!1||(m=m&&L.synchronous,y.unshift(L.fulfilled,L.rejected))});const v=[];this.interceptors.response.forEach(function(L){v.push(L.fulfilled,L.rejected)});let E,b=0,w;if(!m){const $=[x4.bind(this),void 0];for($.unshift(...y),$.push(...v),w=$.length,E=Promise.resolve(i);b<w;)E=E.then($[b++],$[b++]);return E}w=y.length;let V=i;for(;b<w;){const $=y[b++],L=y[b++];try{V=$(V)}catch(k){L.call(this,k);break}}try{E=x4.call(this,V)}catch($){return Promise.reject($)}for(b=0,w=v.length;b<w;)E=E.then(v[b++],v[b++]);return E}getUri(p){p=Cc(this.defaults,p);const i=Gxe(p.baseURL,p.url,p.allowAbsoluteUrls);return xxe(i,p.params,p.paramsSerializer)}}Ue.forEach(["delete","get","head","options"],function(p){mA.prototype[p]=function(i,n){return this.request(Cc(n||{},{method:p,url:i,data:(n||{}).data}))}});Ue.forEach(["post","put","patch"],function(p){function i(n){return function(c,e,y){return this.request(Cc(y||{},{method:p,headers:n?{"Content-Type":"multipart/form-data"}:{},url:c,data:e}))}}mA.prototype[p]=i(),mA.prototype[p+"Form"]=i(!0)});const qb=mA;class lN{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 n=this;this.promise.then(s=>{if(!n._listeners)return;let c=n._listeners.length;for(;c-- >0;)n._listeners[c](s);n._listeners=null}),this.promise.then=s=>{let c;const e=new Promise(y=>{n.subscribe(y),c=y}).then(s);return e.cancel=function(){n.unsubscribe(c)},e},p(function(c,e,y){n.reason||(n.reason=new Bh(c,e,y),i(n.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=n=>{p.abort(n)};return this.subscribe(i),p.signal.unsubscribe=()=>this.unsubscribe(i),p.signal}static source(){let p;return{token:new lN(function(s){p=s}),cancel:p}}}const Rbi=lN;function Dbi(o){return function(i){return o.apply(null,i)}}function wbi(o){return Ue.isObject(o)&&o.isAxiosError===!0}const eC={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(eC).forEach(([o,p])=>{eC[p]=o});const Obi=eC;function Fxe(o){const p=new qb(o),i=Axe(qb.prototype.request,p);return Ue.extend(i,qb.prototype,p,{allOwnKeys:!0}),Ue.extend(i,p,null,{allOwnKeys:!0}),i.create=function(s){return Fxe(Cc(o,s))},i}const En=Fxe(aN);En.Axios=qb;En.CanceledError=Bh;En.CancelToken=Rbi;En.isCancel=Mxe;En.VERSION=Kxe;En.toFormData=WI;En.AxiosError=ai;En.Cancel=En.CanceledError;En.all=function(p){return Promise.all(p)};En.spread=Dbi;En.isAxiosError=wbi;En.mergeConfig=Cc;En.AxiosHeaders=El;En.formToJSON=o=>Lxe(Ue.isHTMLForm(o)?new FormData(o):o);En.getAdapter=Uxe.getAdapter;En.HttpStatusCode=Obi;En.default=En;const Cbi=En;class Sxe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__HTTP_REQUEST,version:"1.0.0",description:"HTTP request operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(zn.HttpRequest);s&&(s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[3]||{},e={method:s[0],url:s[1],params:s[2],headers:c,data:s[4]};J.Logger.log("Axios request config: ",e);const y=await Cbi(e);return{value:G.Success,error:null,result:{status:y.status,headers:y.headers,data:y.data}}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}const L4=Symbol("missing"),_bi=o=>o!=null&&typeof o=="object";function uv(o,p){if(typeof o!="string")throw new TypeError(`${p} expects the key to be a string.`);return o}function Gh(o,p){if(typeof o!="string"&&!Array.isArray(o))throw new TypeError(`${p} expects the path to be string or array.`);return o}function tf(o,p){if(!hr(o))throw new TypeError(`${p} expects the first argument to be an object.`);return o??{}}function qxe(o,p){const i=uv(p,"ReadKey");return(o??{})[i]}function Zxe(o,p,i){const n=uv(p,"WriteKey"),s=nv(o??{});return s[n]=i,s}function Hxe(o,p){const i=uv(p,"DeleteKey"),n=nv(o??{});return delete n[i],n}function Wxe(o,p,i){const n=tf(o,"ReadNestedKey"),s=Gh(p,"ReadNestedKey");return qP(n,s,i)}function zxe(o,p,i){const n=tf(o,"WriteNestedKey"),s=Gh(p,"WriteNestedKey"),c=nv(n);return ZP(c,s,!1),VOe(c,s,i,{createMissing:!1})}function Jxe(o,p,i){const n=tf(o,"WriteSafeNestedKeyRecursively"),s=Gh(p,"WriteSafeNestedKeyRecursively"),c=nv(n);return ZP(c,s,!0),VOe(c,s,i,{createMissing:!0})}function Yxe(o,p){const i=tf(o,"DeleteNestedKey"),n=Gh(p,"DeleteNestedKey"),s=nv(i),{target:c,lastKey:e}=ZP(s,n,!1);return delete c[e],s}function Xxe(o,p){const i=uv(p,"HasKey"),n=o;return n!=null&&_bi(n)&&Object.prototype.hasOwnProperty.call(n,i)}function Qxe(o,p,i){const n=uv(p,"KeyValueEquals");return o==null||typeof o!="object"?!1:o[n]===i}function e$e(o,p){const i=o,n=Gh(p,"HasNestedKey");return qP(i,n,L4)!==L4}function t$e(o,p,i){const n=Gh(p,"NestedKeyValueEquals");return qP(o,n)===i}function i$e(...o){const p={};for(let i=0;i<o.length;i++){const n=o[i];if(n!=null){if(!hr(n))throw new TypeError("MergeObjects expects every argument to be an object (or null/undefined).");Object.assign(p,n)}}return p}function r$e(o){const p=tf(o,"ObjectKeys");return Object.keys(p)}function n$e(o){const p=tf(o,"ObjectValues");return Object.values(p)}function a$e(o){const p=tf(o,"ObjectEntries");return Object.entries(p)}class s$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__VALIDATE_ENTITY,version:"1.0.0",description:"Entity validate operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(Ce.Validate);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)});J.Logger.log("Inputs for entity validation: ",s);const e=$R(s[1]).safeParse(s[0]);return e.success?{value:G.Success,error:null,result:{data:s[0]}}:{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:e.error.errors,result:null}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}const Ia=o=>o.map(p=>{var i,n;return((i=p.value)==null?void 0:i.valueAsType)??((n=p.value)==null?void 0:n.value)});class l$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_READ_KEY,version:"1.0.0",description:"Entity read-key operation implementation module (top-level)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(Ce.ReadKey);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s,c]=Ia(n),e=qxe(s,c);return{value:G.Success,error:null,result:e}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class o$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_WRITE_KEY,version:"1.0.0",description:"Entity write-key operation implementation module (top-level, immutable)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(Ce.WriteKey);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s,c,e]=Ia(n),y=Zxe(s,c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class d$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_DELETE_KEY,version:"1.0.0",description:"Entity delete-key operation implementation module (top-level, immutable)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(Ce.DeleteKey);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s,c]=Ia(n),e=Hxe(s,c);return{value:G.Success,error:null,result:e}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class u$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_READ_NESTED_KEY,version:"1.0.0",description:"Entity read-nested-key operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(Ce.ReadNestedKey);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s,c,e]=Ia(n),y=Wxe(s,c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class p$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.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:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(Ce.WriteNestedKey);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s,c,e]=Ia(n),y=zxe(s,c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class c$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.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:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(Ce.WriteSafeNestedKeyRecursively);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s,c,e]=Ia(n),y=Jxe(s,c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class f$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__ENTITY_DELETE_NESTED_KEY,version:"1.0.0",description:"Entity delete-nested-key operation implementation module (immutable)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(Ce.DeleteNestedKey);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const[s,c]=Ia(n),e=Yxe(s,c);return{value:G.Success,error:null,result:e}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class y$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_HAS_KEY,version:"1.0.0",description:"Object has-key (top-level property present?)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(Ce.HasKey);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=Ia(n),e=Xxe(s,c);return{value:G.Success,error:null,result:e}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class h$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_KEY_VALUE_EQUALS,version:"1.0.0",description:"Object key-value-equals (top-level property strict equality)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(Ce.KeyValueEquals);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c,e]=Ia(n),y=Qxe(s,c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class m$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_HAS_NESTED_KEY,version:"1.0.0",description:"Object has-nested-key (path present?)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(Ce.HasNestedKey);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=Ia(n),e=e$e(s,c);return{value:G.Success,error:null,result:e}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class T$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_NESTED_KEY_VALUE_EQUALS,version:"1.0.0",description:"Object nested-key-value-equals (path strict equality)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(Ce.NestedKeyValueEquals);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c,e]=Ia(n),y=t$e(s,c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class v$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_IS_INSTANCE_OF_TYPE,version:"1.0.0",description:"Object is-instance-of-type (DefinitionEntity-based runtime check)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(Ce.IsInstanceOfType);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{var s,c,e,y,m,v,E,b,w,V;try{const $=((c=(s=n[0])==null?void 0:s.value)==null?void 0:c.parent)||((y=(e=n[0])==null?void 0:e.value)==null?void 0:y.standaloneParent),L=(v=(m=n[0])==null?void 0:m.value)==null?void 0:v.value,k=(b=(E=n[1])==null?void 0:E.value)==null?void 0:b.valueAsTypeSingle;if(!L)throw new TypeError("IsInstanceOfType expects a non-null input value.");if(!k)throw new TypeError("IsInstanceOfType expects a valid expectedType input.");if(!$)throw new TypeError("IsInstanceOfType cannot determine the value owner.");if(k.type!==d.DefinitionEntity)throw new TypeError("IsInstanceOfType expects expectedType to be a DefinitionEntity.");const K=$.getDataType(null);if(((w=K==null?void 0:K.entity)==null?void 0:w.type)!==d.DefinitionEntity)throw new TypeError("IsInstanceOfType cannot determine the data type of the input value.");let S=!1;return((V=K==null?void 0:K.entity)==null?void 0:V.id)!==(k==null?void 0:k.id)?S=!1:$R(K==null?void 0:K.entity).safeParse(L).success?S=!0:S=!1,{value:G.Success,error:null,result:S}}catch($){return{value:G.UnhandledError,error:$,result:null}}}})}}class E$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_MERGE,version:"1.0.0",description:"Object merge operation implementation module (immutable, shallow merge with right-precedence)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const s=n.get(Ce.Merge);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const s=Ia(n),c=i$e(...s);return{value:G.Success,error:null,result:c}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class b$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_KEYS,version:"1.0.0",description:"Object keys operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const s=n.get(Ce.Keys);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=Ia(n),c=r$e(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class A$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_VALUES,version:"1.0.0",description:"Object values operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const s=n.get(Ce.Values);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=Ia(n),c=n$e(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}class g$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__OBJECT_ENTRIES,version:"1.0.0",description:"Object entries operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic);if(!n)return;const s=n.get(Ce.Entries);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=Ia(n),c=a$e(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:G.UnhandledError,error:s,result:null}}}})}}let ss=null;try{ss=require("crypto")}catch{}const Mm=typeof globalThis<"u"&&globalThis.crypto&&globalThis.crypto.subtle?globalThis.crypto:ss&&ss.webcrypto?ss.webcrypto:null,wu=Mm?Mm.subtle:null;function Zm(o){const p=new ArrayBuffer(o.byteLength);return new Uint8Array(p).set(o),p}function Hr(o,p="utf8"){if(o instanceof Uint8Array)return o;const i=String(o);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 n=i.replace(/-/g,"+").replace(/_/g,"/").replace(/=+$/,"");if(typeof Buffer<"u")return new Uint8Array(Buffer.from(n,"base64"));const s=typeof atob=="function"?atob(n):"",c=new Uint8Array(s.length);for(let e=0;e<s.length;e++)c[e]=s.charCodeAt(e);return c}throw new Error(`Unsupported environment/encoding combo for toBytes(${p})`)}function Ql(o,p="utf8"){if(p==="utf8"){if(typeof TextDecoder<"u")return new TextDecoder().decode(o);if(typeof Buffer<"u")return Buffer.from(o).toString("utf8")}else if(p==="hex"){if(typeof Buffer<"u")return Buffer.from(o).toString("hex")}else if(p==="base64"){if(typeof Buffer<"u")return Buffer.from(o).toString("base64")}else if(p==="base64url"&&typeof Buffer<"u")return Buffer.from(o).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");throw new Error(`Unsupported environment/encoding combo for fromBytes(${p})`)}const I$e=o=>Hr(o,"base64"),R$e=(o,p)=>{const i=o instanceof Uint8Array?o:Hr(String(o),p||"utf8");return Ql(i,"base64")},Oy=(o,p)=>{const i=o instanceof Uint8Array?o:Hr(String(o),p||"utf8");return Ql(i,"base64url")},_c=o=>Hr(o,"base64url"),D$e=(o,p)=>{const i=o instanceof Uint8Array?o:Hr(String(o),p||"utf8");return Ql(i,"hex")},w$e=o=>Hr(o,"hex");function oN(o){if(Mm&&Mm.getRandomValues){const p=new Uint8Array(o);return Mm.getRandomValues(p),p}if(ss&&ss.randomBytes)return new Uint8Array(ss.randomBytes(o));throw new Error("Secure random not available")}function YI(o,p){if(!(o instanceof Uint8Array)||!(p instanceof Uint8Array)||o.length!==p.length)return!1;let i=0;for(let n=0;n<o.length;n++)i|=o[n]^p[n];return i===0}function O$e(o,p,i,n){if((typeof o!="string"||typeof p!="string")&&typeof o!="string"&&typeof p!="string")throw new Error("Invalid input types");const s=i??"utf8",c=n??"utf8",e=Hr(o??"",s),y=Hr(p??"",c);return YI(e,y)}async function C$e(o,p){if(wu){const i=await wu.digest({name:o},Zm(p));return new Uint8Array(i)}if(ss){const i=o.replace("SHA-","sha"),n=ss.createHash(i);return n.update(Buffer.from(p)),new Uint8Array(n.digest())}throw new Error("Hash not available")}async function _$e(o,p,i,n){if(typeof p!="string")throw new Error("Invalid input type for data; expected string");const s=String(o??"SHA-256"),c=i??"utf8",e=n??"base64url",y=Hr(p??"",c),m=await C$e(s,y);return Ql(m,e)}async function XI(o,p,i){if(wu){const n=await wu.importKey("raw",Zm(p),{name:"HMAC",hash:{name:o}},!1,["sign"]),s=await wu.sign("HMAC",n,Zm(i));return new Uint8Array(s)}if(ss){const n=`sha${o.split("-")[1]}`,s=ss.createHmac(n,Buffer.from(p));return s.update(Buffer.from(i)),new Uint8Array(s.digest())}throw new Error("HMAC not available")}async function V$e(o,p,i,n,s,c){if(typeof o!="string"||typeof p!="string")throw new Error("Invalid input types for key or data; expected strings");const e=String(i??"SHA-256"),y=n??"utf8",m=s??"utf8",v=c??"base64url",E=Hr(o??"",y),b=Hr(p??"",m),w=await XI(e,E,b);return Ql(w,v)}async function QI(o,p,{iterations:i,length:n,hashAlg:s="SHA-256"}){if(wu){const c=await wu.importKey("raw",Zm(o),"PBKDF2",!1,["deriveBits"]),e=await wu.deriveBits({name:"PBKDF2",salt:Zm(p),iterations:i,hash:s},c,n*8);return new Uint8Array(e)}if(ss){const c=s==="SHA-512"?"sha512":"sha256";return await new Promise((e,y)=>{ss.pbkdf2(Buffer.from(o),Buffer.from(p),i,n,c,(m,v)=>{m?y(m):e(new Uint8Array(v))})})}throw new Error("PBKDF2 not available")}async function P$e(o,p,i,n,s,c,e,y){if(typeof o!="string"||typeof p!="string")throw new Error("Invalid input types for password or salt; expected strings");const m=c??"utf8",v=e??"utf8",E=y??"base64url",b=Math.max(1,Number(i)||21e4),w=Math.max(1,Number(n)||32),V=s??"SHA-256",$=Hr(o??"",m),L=Hr(p??"",v),k=await QI($,L,{iterations:b,length:w,hashAlg:V});return Ql(k,E)}async function N$e(o,p=oN(16),i=21e4,n=32,s="SHA-256"){const c=Hr(o,"utf8"),e=await QI(c,p,{iterations:i,length:n,hashAlg:s}),y=Oy(p),m=Oy(e);return`pbkdf2$${s.toLowerCase()}$${i}$${y}$${m}`}async function x$e(o,p){const i=String(p).split("$");if(i.length!==5||i[0]!=="pbkdf2")return!1;const n=i[1].toLowerCase(),s=parseInt(i[2],10),c=_c(i[3]),e=_c(i[4]),y=n.includes("512")?"SHA-512":"SHA-256",m=await QI(Hr(o,"utf8"),c,{iterations:s,length:e.length,hashAlg:y});return YI(m,e)}async function $$e(o,p,i,n,s,c){const e=p!=null?Math.max(1,Number(p)||0):void 0,y=i!=null?Math.max(1,Number(i)||0):void 0,m=n??void 0,v=c??"base64url",E=s!=null?Hr(s,v):void 0;return await N$e(String(o??""),E,e,y,m)}function M4(o){return Oy(Hr(JSON.stringify(o),"utf8"))}function TA(o){try{return JSON.parse(Ql(_c(o),"utf8"))}catch{return null}}async function L$e(o,p,{alg:i="HS256",includeIat:n=!0,expiresInSeconds:s,notBeforeSeconds:c,issuer:e,subject:y,audience:m,jwtid:v,header:E={}}={}){const b={alg:i,typ:"JWT",...E},w=Math.floor(Date.now()/1e3),V={...o||{}};n&&(V.iat=w),typeof s=="number"&&(V.exp=w+s),typeof c=="number"&&(V.nbf=w+c),e&&(V.iss=e),y&&(V.sub=y),m&&(V.aud=m),v&&(V.jti=v);const $=M4(b),L=M4(V),k=Hr(`${$}.${L}`,"utf8"),S=await XI(i==="HS512"?"SHA-512":i==="HS384"?"SHA-384":"SHA-256",p,k),Y=Oy(S);return`${$}.${L}.${Y}`}async function M$e(o,p,i,n,s,c,e,y,m,v,E,b){if(typeof p!="string")throw new Error("Invalid input type for secret; expected string");if(o!=null&&typeof o!="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(v!=null&&typeof v!="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(y!=null&&typeof y!="string")throw new Error("Invalid input type for subject; expected string");if(m!=null&&typeof m!="string"&&!Array.isArray(m))throw new Error("Invalid input type for audience; expected string or string[]");const V=Hr(p??"",b??"utf8");return await L$e(o??{},V,{alg:i??"HS256",includeIat:n==null?!0:!!n,expiresInSeconds:s!=null?Number(s):void 0,notBeforeSeconds:c!=null?Number(c):void 0,issuer:e??void 0,subject:y??void 0,audience:m??void 0,jwtid:v??void 0,header:E??void 0})}async function B$e(o,p,{alg:i="HS256",issuer:n,audience:s,maxAgeSeconds:c,clockSkewSeconds:e=60}={}){try{const[y,m,v]=String(o).split(".");if(!y||!m||!v)return{valid:!1,header:null,payload:null,reason:"Malformed"};const E=TA(y),b=TA(m);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 w=Hr(`${y}.${m}`,"utf8"),$=await XI(i==="HS512"?"SHA-512":i==="HS384"?"SHA-384":"SHA-256",p,w),L=_c(v);if(!YI($,L))return{valid:!1,header:E,payload:b,reason:"Bad signature"};const k=Math.floor(Date.now()/1e3),K=Math.max(0,Number(e)||0);if(b.nbf!=null&&k+K<Number(b.nbf))return{valid:!1,header:E,payload:b,reason:"Not before"};if(b.exp!=null&&k-K>=Number(b.exp))return{valid:!1,header:E,payload:b,reason:"Expired"};if(n&&b.iss!==n)return{valid:!1,header:E,payload:b,reason:"Issuer mismatch"};if(s){const S=b.aud;if(!(Array.isArray(S)?S.includes(s):S===s))return{valid:!1,header:E,payload:b,reason:"Audience mismatch"}}return c!=null&&b.iat!=null&&k-Number(b.iat)>Number(c)+K?{valid:!1,header:E,payload:b,reason:"MaxAge exceeded"}:{valid:!0,header:E,payload:b}}catch(y){return{valid:!1,header:null,payload:null,reason:String((y==null?void 0:y.message)??y)}}}async function G$e(o,p,i,n,s,c,e,y){if(typeof o!="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 n!="string")throw new Error("Invalid input type for issuer; expected string");if(s!=null&&typeof s!="string")throw new Error("Invalid input type for audience; expected string");const v=Hr(p??"",y??"utf8");return await B$e(String(o??""),v,{alg:i??"HS256",issuer:n??void 0,audience:s??void 0,maxAgeSeconds:c!=null?Number(c):void 0,clockSkewSeconds:e!=null?Number(e):void 0})}function k$e(o){const[p,i,n]=String(o).split(".");return{header:p?TA(p):null,payload:i?TA(i):null,signature:n?_c(n):new Uint8Array}}function j$e(o,p){if(!o)throw new Error("Token is required for decoding");if(typeof o!="string")throw new Error("Invalid input type for token; expected string");const i=p??"base64url",{header:n,payload:s,signature:c}=k$e(String(o??"")),e=Ql(c,i);return{header:n,payload:s,signature:e}}class U$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_GENERATE_RANDOM_BYTES,version:"1.0.0",description:"Randomness generate random bytes operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(et.GenerateRandomBytes);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(E=>{var b,w;return((b=E.value)==null?void 0:b.valueAsType)??((w=E.value)==null?void 0:w.value)}),e=Math.max(0,Number(s)||0),y=c??"base64url",m=oN(e),v=Ql(m,y);return{value:G.Success,error:null,result:v}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class K$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_INTEGER,version:"1.0.0",description:"Randomness generate random integer operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(et.GenerateRandomInteger);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1],y=fOe(c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class F$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_FLOAT,version:"1.0.0",description:"Randomness generate random float operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(et.GenerateRandomFloat);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=KI();return{value:G.Success,error:null,result:s}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class S$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_HEXADECIMAL,version:"1.0.0",description:"Randomness generate random hexadecimal operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(et.GenerateRandomHexadecimal);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)})[0],e=GP(c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class q$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_BASE62,version:"1.0.0",description:"Randomness generate random base62 operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(et.GenerateRandomBase62);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)})[0],e=kP(c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class Z$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_BASE64,version:"1.0.0",description:"Randomness generate random base64 operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(et.GenerateRandomBase64);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)})[0],e=hOe(c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class H$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_ALPHANUMERIC,version:"1.0.0",description:"Randomness generate random alphanumeric operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(et.GenerateRandomAlphanumeric);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)||((v=y.value)==null?void 0:v.value)})[0],e=jP(c);return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class W$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_IDENTIFIER,version:"1.0.0",description:"Generate identifier operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(et.GenerateIdentifier);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)||((E=m.value)==null?void 0:E.value)}),c=s[0],e=s[1],y=UP(c,e);return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class z$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_RANDOM_UUIDV4,version:"1.0.0",description:"Generate UUID v4 operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(et.GenerateRandomUUIDv4);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=Du();return{value:G.Success,error:null,result:s}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class J$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_SHORT_IDENTIFIER,version:"1.0.0",description:"Generate short identifier operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{J.Logger.log("Initializing Random Generate Short Identifier Module");const n=i.find(s=>s.contextType===X.Logic);if(n){J.Logger.log("Project state found, setting up operation");const s=n.get(et.GenerateShortIdentifier);s?(J.Logger.log("Operation found, setting autoexecutable and implementation"),s.autoexecutable=!0,s.implementation=this.module.main):J.Logger.warn("Operation generate-short-identifier not found in project state")}else J.Logger.warn("Project state not found in contexts for Random Generate Short Identifier Module")},main:async(i,n)=>{try{const s=mOe();return{value:G.Success,error:null,result:s}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class Y$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__RANDOMNESS_GENERATE_HEXADECIMAL_TOKEN,version:"1.0.0",description:"Generate hexadecimal token operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(et.GenerateHexadecimalToken);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const s=TOe();return{value:G.Success,error:null,result:s}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}function Vbi(o){let p;if(o===null?p="null":Array.isArray(o)?p="array":p=typeof o,!["string","number","boolean","null","object","array"].includes(p))throw new TypeError("GetTypeOf cannot determine type of the given value.");return p}class X$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_GET_TYPE_OF,version:"1.0.0",description:"Data type get type of operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(ze.GetTypeOf);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{try{const c=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)||((m=e.value)==null?void 0:m.value)})[0];return{value:G.Success,error:null,result:Vbi(c)}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class Q$e extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_TO_STRING,version:"1.0.0",description:"Coerce any value to string via JS String(value)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ze.ToString);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)}),c=String(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class eLe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_TO_NUMBER,version:"1.0.0",description:"Coerce to number via JS Number(value)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ze.ToNumber);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)}),c=Number(s);return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class tLe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_TO_BYTES,version:"1.0.0",description:"Convert string/bytes-like to Uint8Array (utf8|hex|base64|base64url)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ze.ToBytes);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)??((E=m.value)==null?void 0:E.value)}),y=Hr(s,c||"utf8");return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class iLe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_FROM_BYTES_TO_STRING,version:"1.0.0",description:"Convert Uint8Array to string (utf8|hex|base64|base64url)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ze.FromBytesToString);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)??((E=m.value)==null?void 0:E.value)}),y=Ql(s,c||"utf8");return{value:G.Success,error:null,result:y}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class rLe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_ENCODE_BASE64,version:"1.0.0",description:"Bytes -> base64 string (accepts string input by converting from utf8)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ze.EncodeBase64);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)});return{value:G.Success,error:null,result:R$e(s,c)}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class nLe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_DECODE_BASE64,version:"1.0.0",description:"base64 string -> bytes (Uint8Array)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ze.DecodeBase64);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)}),c=I$e(String(s));return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class aLe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_ENCODE_BASE64URL,version:"1.0.0",description:"Bytes -> base64url string (accepts string input by converting from utf8)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ze.EncodeBase64Url);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)??((v=y.value)==null?void 0:v.value)}),e=Oy(s,c||"utf8");return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class sLe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_DECODE_BASE64URL,version:"1.0.0",description:"base64url string -> bytes (Uint8Array)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ze.DecodeBase64Url);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)}),c=_c(String(s));return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class lLe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_ENCODE_HEX,version:"1.0.0",description:"Bytes -> hex string (accepts string input by converting from utf8)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ze.EncodeHex);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)??((v=y.value)==null?void 0:v.value)}),e=D$e(s,c||"utf8");return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class oLe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__DATA_TYPE_DECODE_HEX,version:"1.0.0",description:"hex string -> bytes (Uint8Array)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(ze.DecodeHex);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)}),c=w$e(String(s));return{value:G.Success,error:null,result:c}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class dLe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_HASH,version:"1.0.0",description:"Crypto: Hash (SHA-256/384/512)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(si.Hash);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c,e,y]=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)??((E=m.value)==null?void 0:E.value)});return{value:G.Success,error:null,result:_$e(s,c,e,y)}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class uLe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_HMAC,version:"1.0.0",description:"Crypto: HMAC (SHA-256/384/512)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(si.Hmac);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c,e,y,m,v]=n.map(E=>{var b,w;return((b=E.value)==null?void 0:b.valueAsType)??((w=E.value)==null?void 0:w.value)});return{value:G.Success,error:null,result:V$e(c,e,s,y,m,v)}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class pLe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_CONSTANT_TIME_EQUAL,version:"1.0.0",description:"Crypto: constant-time equality for byte sequences",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(si.ConstantTimeEqual);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c,e,y]=n.map(m=>{var v,E;return((v=m.value)==null?void 0:v.valueAsType)??((E=m.value)==null?void 0:E.value)});return{value:G.Success,error:null,result:O$e(s,c,e,y)}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class cLe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__CRYPTO_DERIVE_KEY_PBKDF2,version:"1.0.0",description:"Crypto: derive key with PBKDF2 (SHA-256/512)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(si.DeriveKeyPBKDF2);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c,e,y,m,v,E,b]=n.map(w=>{var V,$;return((V=w.value)==null?void 0:V.valueAsType)??(($=w.value)==null?void 0:$.value)});return{value:G.Success,error:null,result:P$e(s,c,e,y,m,v,E,b)}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class fLe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_IN_OPERATIONS_IMPLEMENTATIONS__JSON_PARSE,version:"1.0.0",description:"Json parse string into object operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(Xr.Parse);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{var s;try{const c=(s=n[0].value)==null?void 0:s.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:G.Success,error:null,result:e}}catch(c){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:c,result:null}}}})}}class yLe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_IN_OPERATIONS_IMPLEMENTATIONS__JSON_STRINGIFY,version:"1.0.0",description:"Json stringify object into string operation implementation module",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(s=>s.contextType===X.Logic);if(n){const s=n.get(Xr.Stringify);s&&(s.autoexecutable=!0,s.implementation=this.module.main)}},main:async(i,n)=>{var s,c;try{const e=(s=n[0].value)==null?void 0:s.value,y=(c=n[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(!y&&y!==0){const v=JSON.stringify(e);return{value:G.Success,error:null,result:v}}const m=JSON.stringify(e,null,y);return{value:G.Success,error:null,result:m}}catch(e){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:e,result:null}}}})}}class hLe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__JWT_BUILD_HMAC,version:"1.0.0",description:"JWT: build (HS256/384/512)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(er.BuildJwtHmac);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c,e,y,m,v,E,b,w,V,$,L]=n.map(k=>{var K,S;return((K=k.value)==null?void 0:K.valueAsType)??((S=k.value)==null?void 0:S.value)});return{value:G.Success,error:null,result:await M$e(s,c,e,y,m,v,E,b,w,V,$,L)}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class mLe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__JWT_VERIFY_HMAC,version:"1.0.0",description:"JWT: verify (HS256/384/512)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(er.VerifyJwtHmac);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c,e,y,m,v,E,b]=n.map(w=>{var V,$;return((V=w.value)==null?void 0:V.valueAsType)??(($=w.value)==null?void 0:$.value)});return{value:G.Success,error:null,result:await G$e(s,c,e,y,m,v,E,b)}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class TLe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__JWT_DECODE,version:"1.0.0",description:"JWT: decode (no verification)",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(er.DecodeJwt);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(e=>{var y,m;return((y=e.value)==null?void 0:y.valueAsType)??((m=e.value)==null?void 0:m.value)});return{value:G.Success,error:null,result:j$e(s,c)}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class vLe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__PASSWORD_HASH_PBKDF2,version:"1.0.0",description:"Password: hash (PBKDF2) -> envelope string",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(Qr.HashPasswordPBKDF2);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c,e,y,m,v]=n.map(E=>{var b,w;return((b=E.value)==null?void 0:b.valueAsType)??((w=E.value)==null?void 0:w.value)});return{value:G.Success,error:null,result:await $$e(s,c,e,y,m,v)}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class ELe extends ge{constructor(){super(...arguments);I(this,"manifest",{id:Ae.BUILT_INT_OPERATIONS_IMPLEMENTATIONS__PASSWORD_VERIFY_PBKDF2,version:"1.0.0",description:"Password: verify (PBKDF2) -> boolean",initPriority:Ee.High,permissions:[be.All],contexts:[X.Logic]});I(this,"module",{init:i=>{const n=i.find(c=>c.contextType===X.Logic),s=n==null?void 0:n.get(Qr.VerifyPasswordPBKDF2);s&&(s.autoexecutable=!0,s.implementation=this.module.main)},main:async(i,n)=>{try{const[s,c]=n.map(y=>{var m,v;return((m=y.value)==null?void 0:m.valueAsType)??((v=y.value)==null?void 0:v.value)}),e=await x$e(String(s??""),String(c??""));return{value:G.Success,error:null,result:e}}catch(s){return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,error:s,result:null}}}})}}class tC extends SI{constructor(p,i,n=i.projectId){super(p,X.Editor),this._editor=i,this.id=n}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()}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){return this._editor.copyEntities(p)}resolveInitialChildrenPositions(p,i,n){return this._editor.resolveInitialChildrenPositions(p,i,n)}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)}}function Pbi(o,p){return p instanceof tC?p:new tC(o,p)}class iC extends SI{constructor(p,i){super(p,X.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 Nbi(o,p){return p instanceof iC?p:new iC(o,p)}function xbi(o){o.register(new YOe(o)),o.register(new JOe(o)),o.register(new ZOe(o)),o.register(new WOe(o)),o.register(new zOe(o)),o.register(new HOe(o)),o.register(new $Ne(o)),o.register(new LNe(o)),o.register(new MNe(o)),o.register(new GNe(o)),o.register(new BNe(o)),o.register(new kNe(o)),o.register(new K$e(o)),o.register(new F$e(o)),o.register(new S$e(o)),o.register(new q$e(o)),o.register(new Z$e(o)),o.register(new H$e(o)),o.register(new W$e(o)),o.register(new z$e(o)),o.register(new J$e(o)),o.register(new Y$e(o)),o.register(new xPe(o)),o.register(new $Pe(o)),o.register(new LPe(o)),o.register(new MPe(o)),o.register(new BPe(o)),o.register(new GPe(o)),o.register(new kPe(o)),o.register(new jPe(o)),o.register(new UPe(o)),o.register(new KPe(o)),o.register(new FPe(o)),o.register(new SPe(o)),o.register(new qPe(o)),o.register(new ZPe(o)),o.register(new HPe(o)),o.register(new WPe(o)),o.register(new zPe(o)),o.register(new JPe(o)),o.register(new YPe(o)),o.register(new eNe(o)),o.register(new tNe(o)),o.register(new iNe(o)),o.register(new QVe(o)),o.register(new ePe(o)),o.register(new tPe(o)),o.register(new iPe(o)),o.register(new rPe(o)),o.register(new nPe(o)),o.register(new aPe(o)),o.register(new sPe(o)),o.register(new lPe(o)),o.register(new dPe(o)),o.register(new uPe(o)),o.register(new pPe(o)),o.register(new cPe(o)),o.register(new fPe(o)),o.register(new mVe(o)),o.register(new TVe(o)),o.register(new vVe(o)),o.register(new s$e(o)),o.register(new Sxe(o)),o.register(new h_e(o)),o.register(new m_e(o)),o.register(new T_e(o)),o.register(new v_e(o)),o.register(new E_e(o)),o.register(new b_e(o)),o.register(new A_e(o)),o.register(new g_e(o)),o.register(new I_e(o)),o.register(new M_e(o)),o.register(new fVe(o)),o.register(new yVe(o)),o.register(new hVe(o)),o.register(new R_e(o)),o.register(new D_e(o)),o.register(new w_e(o)),o.register(new O_e(o)),o.register(new C_e(o)),o.register(new __e(o)),o.register(new V_e(o)),o.register(new P_e(o)),o.register(new N_e(o)),o.register(new x_e(o)),o.register(new $_e(o)),o.register(new L_e(o)),o.register(new B_e(o)),o.register(new G_e(o)),o.register(new k_e(o)),o.register(new j_e(o)),o.register(new U_e(o)),o.register(new K_e(o)),o.register(new F_e(o)),o.register(new S_e(o)),o.register(new q_e(o)),o.register(new Z_e(o)),o.register(new H_e(o)),o.register(new W_e(o)),o.register(new rVe(o)),o.register(new nVe(o)),o.register(new aVe(o)),o.register(new z_e(o)),o.register(new J_e(o)),o.register(new Y_e(o)),o.register(new X_e(o)),o.register(new Q_e(o)),o.register(new eVe(o)),o.register(new tVe(o)),o.register(new iVe(o)),o.register(new u$e(o)),o.register(new p$e(o)),o.register(new c$e(o)),o.register(new f$e(o)),o.register(new l$e(o)),o.register(new o$e(o)),o.register(new d$e(o)),o.register(new y$e(o)),o.register(new m$e(o)),o.register(new v$e(o)),o.register(new h$e(o)),o.register(new T$e(o)),o.register(new E$e(o)),o.register(new g$e(o)),o.register(new b$e(o)),o.register(new A$e(o)),o.register(new yPe(o)),o.register(new vPe(o)),o.register(new EPe(o)),o.register(new gPe(o)),o.register(new IPe(o)),o.register(new RPe(o)),o.register(new DPe(o)),o.register(new wPe(o)),o.register(new OPe(o)),o.register(new CPe(o)),o.register(new _Pe(o)),o.register(new bPe(o)),o.register(new APe(o)),o.register(new mPe(o)),o.register(new TPe(o)),o.register(new hPe(o)),o.register(new oPe(o)),o.register(new PPe(o)),o.register(new NPe(o)),o.register(new VPe(o)),o.register(new UNe(o)),o.register(new pxe(o)),o.register(new uxe(o)),o.register(new cxe(o)),o.register(new fxe(o)),o.register(new SNe(o)),o.register(new qNe(o)),o.register(new YNe(o)),o.register(new zNe(o)),o.register(new oxe(o)),o.register(new ixe(o)),o.register(new nxe(o)),o.register(new sxe(o)),o.register(new axe(o)),o.register(new JNe(o)),o.register(new QNe(o)),o.register(new exe(o)),o.register(new XNe(o)),o.register(new jNe(o)),o.register(new ZNe(o)),o.register(new rxe(o)),o.register(new mxe(o)),o.register(new JO(o)),o.register(new FNe(o)),o.register(new HNe(o)),o.register(new KNe(o)),o.register(new lxe(o)),o.register(new WNe(o)),o.register(new txe(o)),o.register(new dxe(o)),o.register(new hxe(o)),o.register(new yxe(o)),o.register(new Txe(o)),o.register(new JO(o)),o.register(new Exe(o)),o.register(new vxe(o)),o.register(new bxe(o)),o.register(new TNe(o)),o.register(new vNe(o)),o.register(new ENe(o)),o.register(new nNe(o)),o.register(new QPe(o)),o.register(new oNe(o)),o.register(new cNe(o)),o.register(new XPe(o)),o.register(new fNe(o)),o.register(new mNe(o)),o.register(new uNe(o)),o.register(new dNe(o)),o.register(new yA(o)),o.register(new bNe(o)),o.register(new ANe(o)),o.register(new pNe(o)),o.register(new hNe(o)),o.register(new yNe(o)),o.register(new lNe(o)),o.register(new sNe(o)),o.register(new aNe(o)),o.register(new rNe(o)),o.register(new RNe(o)),o.register(new INe(o)),o.register(new DNe(o)),o.register(new gNe(o)),o.register(new dVe(o)),o.register(new sVe(o)),o.register(new oVe(o)),o.register(new uVe(o)),o.register(new pVe(o)),o.register(new lVe(o)),o.register(new cVe(o)),o.register(new X$e(o)),o.register(new nLe(o)),o.register(new sLe(o)),o.register(new oLe(o)),o.register(new rLe(o)),o.register(new aLe(o)),o.register(new lLe(o)),o.register(new iLe(o)),o.register(new tLe(o)),o.register(new eLe(o)),o.register(new Q$e(o)),o.register(new fLe(o)),o.register(new yLe(o)),o.register(new pLe(o)),o.register(new cLe(o)),o.register(new U$e(o)),o.register(new dLe(o)),o.register(new uLe(o)),o.register(new mLe(o)),o.register(new hLe(o)),o.register(new TLe(o)),o.register(new vLe(o)),o.register(new ELe(o)),o.register(new QOe(o)),o.register(new eCe(o)),o.register(new cA(o)),o.register(new fA(o))}class dN{constructor(p=new J.Events("extensions-registry-fallback-events")){I(this,"extensionsRegistry",new Map);I(this,"initialized",new Set);I(this,"initializedContexts",new Set);I(this,"onResolveEditorContextCallback",()=>null);I(this,"onResolveProjectLogicContextCallback",()=>null);I(this,"onResolveEditorGUIContextCallback",()=>null);I(this,"onResolveGUIContextCallback",()=>null);I(this,"onResolveCompileContextCallback",()=>null);I(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||Ee.Normal)-(i.manifest.initPriority||Ee.Normal))}async setup(){xbi(this),J.Logger.log("Initializing extensions without context..."),this.initForReady()}requestContext(p){switch(p){case X.Editor:return this.onResolveEditorContextCallback();case X.Logic:return this.onResolveProjectLogicContextCallback();case X.EditorGUI:return this.onResolveEditorGUIContextCallback();case X.Compile:return this.onResolveCompileContextCallback();case X.PublicationRun:return this.onResolvePublicationRunContextCallback();case X.GUI:return this.onResolveGUIContextCallback();case X.EditorGUI:return this.onResolveEditorGUIContextCallback();default:throw new Error(`Unknown context type: ${p}`)}}requestContexts(p,i=[]){const n=[];i.length===0&&(i=p.manifest.contexts);for(const s of i){const c=this.requestContext(s);c&&n.push(c)}return n}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 n of this.extensionInOrder)if(n.module.init&&!this.initialized.has(n.manifest.id)){const s=n.manifest.contexts.map(c=>this.requestContext(c)).filter(c=>c!==null);s.length&&(await((i=(p=n.module).init)==null?void 0:i.call(p,s)),this.initialized.add(n.manifest.id))}else!n.module.init&&!this.initialized.has(n.manifest.id)&&this.initialized.add(n.manifest.id)}async initForReady(){J.Logger.log("Initializing extensions for ready contexts...");for(const p of this.extensionInOrder)if(p.module.init&&!this.initialized.has(p.manifest.id)){J.Logger.log("Initializing "+p.manifest.id+" extension...");const i=this.requestContexts(p);p.manifest.contexts.every(s=>!!i.find(c=>c.contextType===s))?(await p.module.init(i),this.initialized.add(p.manifest.id)):J.Logger.warn(`Skipping initialization of ${p.manifest.id} extension, not all contexts are ready.`,`Required contexts: ${p.manifest.contexts.join(", ")}`,`Available contexts: ${i.map(s=>s.contextType).join(", ")}`)}else!p.module.init&&!this.initialized.has(p.manifest.id)?(J.Logger.log("Set "+p.manifest.id+" extension as initialized by default..."),this.initialized.add(p.manifest.id)):J.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)){J.Logger.warn(`Context ${p} is already initialized. Skipping re-initialization.`);return}switch(this.initializedContexts.add(p),p){case X.Editor:{if(!this.onResolveEditorContextCallback)throw new Error("No editor context resolver callback set. Call onResolveEditorContext first.");break}case X.Logic:{if(!this.onResolveProjectLogicContextCallback)throw new Error("No project logic context resolver callback set. Call onResolveProjectLogicContext first.");break}}J.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 Lb=null;const uN={requestExtension:o=>(Lb||(Lb=new dN,Lb.setup()),Lb.requestExtension(o))},Eu={onBeforeEntityExecution:async()=>{},onEntityExecuted:async()=>{}};var pN=(o=>(o.FinishedSuccess="finished-success",o.FinishedError="finished-error",o.Running="running",o.Paused="paused",o.Stopped="stopped",o.NotStarted="not-started",o))(pN||{});const bLe={...uN,getValueTypePreference:()=>null,setValueTypePreference:()=>{}};class Iu extends J.Events{constructor(i,n,s,c=null,e=bLe){super();I(this,"project");I(this,"entryPoint");I(this,"state","not-started");I(this,"events",new J.Events("fe-exec-inst-events"));I(this,"entities",[]);I(this,"parentExecution",null);I(this,"executing",[]);I(this,"executed",[]);I(this,"skipped",[]);I(this,"scheduled",[]);I(this,"localTestValues");I(this,"resolvedValues");I(this,"persistedExecutionResults");I(this,"lastExecutionResults");I(this,"onAddToSkippedListCallback",null);I(this,"onRemoveFromSkippedListCallback",null);I(this,"onAddEntityCallback",null);I(this,"onRemoveEntityCallback",null);I(this,"onAbortExecutionCallback",null);this.parentContext=e,this.entities=n,this.entryPoint=s,this.project=i,this.parentExecution=c,this.localTestValues=new Vm(x.UUID.uuid(),this.project),this.resolvedValues=new Vm(x.UUID.uuid(),this.project),this.persistedExecutionResults=new Vm(x.UUID.uuid(),this.project),this.lastExecutionResults=new Vm(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),Zr.includes(i.type)&&wt(i).forEach(n=>this.skip(n))))}async schedule(i,n,s){if(this.hasExecuted(i))return null;if(Yt.includes(i.type))return this.executeBranch(i,s,n);if(qr.includes(i.type)){if(i.calledBy.every(e=>this.hasExecuted(e)||!this.hasEntity(e)))return this.executeBranch(i,s,n);this.scheduled.includes(i)||this.scheduled.push(i)}return null}mergeExernalValuesWithInternalInputs(i,n){const s=[];return[...Qt,...Yt].includes(n.type)?s.push(...n.inputs):qt.includes(n.type)&&s.push(...n.outputs),s.map(e=>{var m;let y=i.find(v=>v.valueOwner.id===e.id);if(y)return y;if(!y&&Yt.includes(n.type)&&(y=i.find(v=>{var E;return((E=v.valueOwner.declaration)==null?void 0:E.id)===e.id})),y){const v=(m=y.value)==null?void 0:m.clone(null);return v==null||v.setStandaloneParent(e,null),{...y,valueOwner:e,value:v||null,inheritanceLink:{sources:[y],target:e}}}return Ma.includes(e.type)?Ao(e,this.valueResolutionContext):Mu(e,this.valueResolutionContext)}).reduce((e,y)=>{const m=Oo(y==null?void 0:y.valueOwner,this.project),v=y?[y]:[];return m.forEach(E=>{var V,$,L;if(E.id===(y==null?void 0:y.valueOwner.id))return;const b=It(E.getDataType(null),E,this.project);b==null||b.metaSync({value:(V=y==null?void 0:y.value)==null?void 0:V.value},null),b==null||b.setValueAsTypeList((($=y==null?void 0:y.value)==null?void 0:$.valueAsTypeList)||null),b==null||b.setValueAsTypeSingle(((L=y==null?void 0:y.value)==null?void 0:L.valueAsTypeSingle)||null);const w={...y,valueOwner:E,value:b};v.push(w)}),[...e,...v]},[]).sort((e,y)=>e.valueOwner.index-y.valueOwner.index)}inheritValuesFromContext(i){this.localTestValues=i.localTestValues,this.resolvedValues=i.resolvedValues,this.persistedExecutionResults=i.persistedExecutionResults}async executeInternalCall(i,n,s,c={}){var y,m;const e={...Eu,...c};try{let v={value:G.Success,error:null,result:null};if(n.sort((E,b)=>E.valueOwner.index-b.valueOwner.index),Object.values(br).includes(i.declaration.id)){const E=this.parentContext.requestExtension(uy+i.declaration.id).module.main;E?v=await E(i,n):J.Logger.warn(`No implementation found for built-in function: ${i.declaration.id}`)}else{v=await this.executeDetachedFullFunctionDeclarationLogic(i.declaration,n,s,e);let E=null;if(v.error){J.Logger.warn("Raw error executing entity: ",v.error);const b=(y=i.error)==null?void 0:y.getDataType(null),w=It(b||null,i.error,s);b!=null&&b.asType?w==null||w.setValueAsTypeSingle(v.error):w==null||w.metaSync({value:v.error},null),E={valueOwner:i.error,type:Pe.ExecutionResult,inheritanceLink:null,value:w}}return{value:v.value,entity:i,error:E,result:{value:v.result||null,valueOwner:i,type:Pe.ExecutionResult,inheritanceLink:null}}}return{...v,entity:i}}catch(v){J.Logger.warn("Internal call execution error: ",v);let E=null;if(i.error){const b=(m=i.error)==null?void 0:m.getDataType(null),w=It(b,i.error,s);b!=null&&b.asType?w==null||w.setValueAsTypeSingle(v):w==null||w.metaSync({value:v},null),E={valueOwner:i.error,type:Pe.ExecutionResult,inheritanceLink:null,value:w}}return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,entity:i,error:E,result:null}}}static async executeOperation(i,n,s){var c,e;try{let y={value:G.Success,error:null,result:null};n.sort((b,w)=>b.valueOwner.index-w.valueOwner.index),i.declaration.implementation&&(y=await i.declaration.implementation(i,n));let m=null;if(y.error&&i.error){J.Logger.warn("Raw error executing entity: ",y.error);const b=((c=i.error)==null?void 0:c.getDataType(null))||null,w=It(b,i.error,s);b!=null&&b.asType?w==null||w.setValueAsTypeSingle(y.error):w==null||w.metaSync({value:y.error},null),m={valueOwner:i.error,type:Pe.ExecutionResult,inheritanceLink:null,value:w}}const v=i==null?void 0:i.getDataType(null),E=It(v,i,s);return v!=null&&v.asType?E==null||E.setValueAsTypeSingle(y.result):E==null||E.metaSync({value:y.result},null),{value:y.value,entity:i,error:m,result:{value:E||null,valueOwner:i,type:Pe.ExecutionResult,inheritanceLink:null}}}catch(y){J.Logger.warn("Operation execution error: ",y);let m=null;if(i.error){const v=(e=i.error)==null?void 0:e.getDataType(null),E=It(v,i.error,s);v!=null&&v.asType?E==null||E.setValueAsTypeSingle(y):E==null||E.metaSync({value:y},null),m={valueOwner:i.error,type:Pe.ExecutionResult,inheritanceLink:null,value:E}}return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,entity:i,error:m,result:null}}}async executeSearch(i,n,s){var c;try{let e={value:G.Success,error:null,result:null};const y=await(await this.parentContext.requestExtension(Ae.SEARCH_NODE_IMPLEMENTATION)).module.main(i,n),m=i==null?void 0:i.getDataType(null),v=It(m,i,s);return v==null||v.metaSync({value:y},null),y.error?{value:G.UnhandledError,entity:i,error:{valueOwner:i,type:Pe.ExecutionResult,inheritanceLink:null,value:v},result:null}:{value:e.value,entity:i,error:null,result:{value:v,valueOwner:i,type:Pe.ExecutionResult,inheritanceLink:null}}}catch(e){if(J.Logger.warn(`Search node execution error: ${e}`),!i.error)return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,entity:i,error:null,result:null};const y=(c=i.error)==null?void 0:c.getDataType(null),m=It(y,i.error,s);return m==null||m.metaSync({value:e},null),{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,entity:i,error:{valueOwner:i.error,type:Pe.ExecutionResult,inheritanceLink:null,value:m},result:null}}}async executeLoop(i,n,s,c={}){var y,m,v,E,b,w;const e={...Eu,...c};try{let V={value:G.Success,error:null,result:null};const $=n.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 L={};i.getUniqueInputMaps().forEach(re=>{const ee=i.body.inputs.find(ve=>se(ve,s)===se(re,s)),de=re==null?void 0:re.getDataType(null),le=It(de,ee,s);de!=null&&de.asType?le==null||le.setValueAsTypeList([]):le==null||le.metaSync({value:[]},null),this.lastExecutionResults.writeValue(ee,le);const fe={value:le,valueOwner:ee,type:Pe.ExecutionResult,inheritanceLink:null};L[ee.id]=fe});let K={value:G.Success,entity:i.body,error:null,result:null};switch(i.declaration.id){case Q.loop["counted-loop"].id:{const re=$[0];let ee=1;for(;ee<=re&&ee<=50;){const de=i.body.inputs.map(le=>{if(le===i.currentIterationNumberArgumentDeclaration){const fe=i.currentIterationNumberArgumentDeclaration.getDataType(null),ve=mc(fe),ue=this.lastExecutionResults.readValue(le.id);if(ue){ue.metaSync({value:ee},null),this.lastExecutionResults.writeValue(le,ue);const $e={value:ue,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Pe.ExecutionResult,inheritanceLink:null};return L[le.id]=$e,$e}const ye={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:ve,standaloneParent:le.toReference()},Ve=Si(ye,s);this.lastExecutionResults.writeValue(le,Ve);const _e={value:Ve,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Pe.ExecutionResult,inheritanceLink:null};return L[le.id]=_e,_e}else return L[le.id]}).filter(le=>!!le);if(K=await this.executeFullFunctionDeclarationLogic(i.body,de,e),(K.results||[]).forEach(le=>{var ye,Ve,_e,$e;if(le.valueOwner.type!==d.InputMap||qt.includes(le.valueOwner.parent.type))return;const fe=i.body.inputs.find(Ne=>se(Ne,s)===se(le.valueOwner,s)),ue=[...((Ve=(ye=L==null?void 0:L[fe.id])==null?void 0:ye.value)==null?void 0:Ve.value)||[],((_e=le==null?void 0:le.value)==null?void 0:_e.value)||null];($e=L[fe.id].value)==null||$e.metaSync({value:ue},null),this.lastExecutionResults.writeValue(fe,L[fe.id].value)}),[G.CaughtError,G.Break,G.Return].includes(K.value))break;ee++}break}case Q.loop["manual-flow-loop"].id:{let re=1;for(;re<=50;){const ee=i.body.inputs.map(de=>{if(de===i.currentIterationNumberArgumentDeclaration){const le=this.lastExecutionResults.readValue(de.id);if(le){le.metaSync({value:re},null),this.lastExecutionResults.writeValue(de,le);const ye={value:le,valueOwner:de,type:Pe.ExecutionResult,inheritanceLink:null};return L[de.id]=ye,ye}const fe=i.currentIterationNumberArgumentDeclaration.getDataType(null),ve=It(fe,de,s);return ve==null||ve.metaSync({value:re},null),this.lastExecutionResults.writeValue(de,ve),{value:ve,valueOwner:de,type:Pe.ExecutionResult,inheritanceLink:null}}else return L[de.id]}).filter(de=>!!de);if(K=await this.executeFullFunctionDeclarationLogic(i.body,ee,e),(K.results||[]).forEach(de=>{var ue,ye,Ve;if(de.valueOwner.type!==d.InputMap||qt.includes(de.valueOwner.parent.type))return;const le=i.body.inputs.find(_e=>se(_e,s)===se(de.valueOwner,s)),ve=[...(ue=L[le.id].value)==null?void 0:ue.value,((ye=de.value)==null?void 0:ye.value)||null];(Ve=L[le.id].value)==null||Ve.metaSync({value:ve},null),this.lastExecutionResults.writeValue(le,L[le.id].value)}),[G.CaughtError,G.Break,G.Return].includes(K.value))break;re++}break}case Q.loop["list-loop"].id:{const re=$[0];let ee=1;const de=re;for(let le=0;le<de.length;le++){const fe=de[le],ve=i.body.inputs.map(ue=>{if(ue===i.currentIterationNumberArgumentDeclaration){const ye=this.lastExecutionResults.readValue(ue.id);if(ye)return ye.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ue,ye),{value:ye,valueOwner:ue,type:Pe.ExecutionResult,inheritanceLink:null};const Ve=i.currentIterationNumberArgumentDeclaration.getDataType(null),_e=It(Ve,ue,s);return _e==null||_e.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ue,_e),{value:_e,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Pe.ExecutionResult,inheritanceLink:null}}else if(ue===i.currentValueArgumentDeclaration){const ye=i.currentValueArgumentDeclaration.getDataType(null),Ve=mc(ye),_e=this.lastExecutionResults.readValue(ue.id);if(_e)return _e.metaSync({value:fe},null),this.lastExecutionResults.writeValue(ue,_e),{value:_e,valueOwner:ue,type:Pe.ExecutionResult,inheritanceLink:null};const $e={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:fe,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:Ve,standaloneParent:ue.toReference()},Ne=Si($e,s);return this.lastExecutionResults.writeValue(ue,Ne),{value:Ne,valueOwner:i.currentValueArgumentDeclaration,type:Pe.ExecutionResult,inheritanceLink:null}}else return L[ue.id]}).filter(ue=>!!ue);if(K=await this.executeFullFunctionDeclarationLogic(i.body,ve,e),(K.results||[]).forEach(ue=>{var $e,Ne,Be;if(ue.valueOwner.type!==d.InputMap||qt.includes(ue.valueOwner.parent.type))return;const ye=i.body.inputs.find(Se=>se(Se,s)===se(ue.valueOwner,s)),_e=[...($e=L[ye.id].value)==null?void 0:$e.value,((Ne=ue.value)==null?void 0:Ne.value)||null];(Be=L[ye.id].value)==null||Be.metaSync({value:_e},null),this.lastExecutionResults.writeValue(ye,L[ye.id].value)}),[G.CaughtError,G.Break,G.Return].includes(K.value))break;ee++}break}case Q.loop["object-keys-loop"].id:{const re=$[0];let ee=1;const de=re?Object.keys(re):[];for(let le=0;le<de.length;le++){const fe=de[le],ve=i.body.inputs.map(ue=>{if(ue===i.currentIterationNumberArgumentDeclaration){const ye=this.lastExecutionResults.readValue(ue.id);if(ye)return ye.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ue,ye),{value:ye,valueOwner:ue,type:Pe.ExecutionResult,inheritanceLink:null};const Ve=i.currentIterationNumberArgumentDeclaration.getDataType(null),_e=It(Ve,ue,s);return _e==null||_e.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ue,_e),{value:_e,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Pe.ExecutionResult,inheritanceLink:null}}else if(ue===i.currentValueArgumentDeclaration){const ye=i.currentValueArgumentDeclaration.getDataType(null),Ve=mc(ye),_e=this.lastExecutionResults.readValue(ue.id);if(_e)return _e.metaSync({value:fe},null),this.lastExecutionResults.writeValue(ue,_e),{value:_e,valueOwner:ue,type:Pe.ExecutionResult,inheritanceLink:null};const $e={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:fe,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:Ve,standaloneParent:ue.toReference()},Ne=Si($e,s);return this.lastExecutionResults.writeValue(ue,Ne),{value:Ne,valueOwner:i.currentValueArgumentDeclaration,type:Pe.ExecutionResult,inheritanceLink:null}}else return L[ue.id]}).filter(ue=>!!ue);if(K=await this.executeFullFunctionDeclarationLogic(i.body,ve,e),(K.results||[]).forEach(ue=>{var $e,Ne,Be;if(ue.valueOwner.type!==d.InputMap||qt.includes(ue.valueOwner.parent.type))return;const ye=i.body.inputs.find(Se=>se(Se,s)===se(ue.valueOwner,s)),_e=[...($e=L[ye.id].value)==null?void 0:$e.value,((Ne=ue.value)==null?void 0:Ne.value)||null];(Be=L[ye.id].value)==null||Be.metaSync({value:_e},null),this.lastExecutionResults.writeValue(ye,L[ye.id].value)}),[G.CaughtError,G.Break,G.Return].includes(K.value))break;ee++}break}case Q.loop["object-values-loop"].id:{const re=$[0];let ee=1;const de=re?Object.values(re):[];for(let le=0;le<de.length;le++){const fe=de[le],ve=i.body.inputs.map(ue=>{if(ue===i.currentIterationNumberArgumentDeclaration){const ye=this.lastExecutionResults.readValue(ue.id);if(ye)return ye.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ue,ye),{value:ye,valueOwner:ue,type:Pe.ExecutionResult,inheritanceLink:null};const Ve=i.currentIterationNumberArgumentDeclaration.getDataType(null),_e=It(Ve,ue,s);return _e==null||_e.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ue,_e),{value:_e,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Pe.ExecutionResult,inheritanceLink:null}}else if(ue===i.currentValueArgumentDeclaration){const ye=i.currentValueArgumentDeclaration.getDataType(null),Ve=mc(ye),_e=this.lastExecutionResults.readValue(ue.id);if(_e)return _e.metaSync({value:fe},null),this.lastExecutionResults.writeValue(ue,_e),{value:_e,valueOwner:ue,type:Pe.ExecutionResult,inheritanceLink:null};const $e={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:fe,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:Ve,standaloneParent:ue.toReference()},Ne=Si($e,s);return this.lastExecutionResults.writeValue(ue,Ne),{value:Ne,valueOwner:i.currentValueArgumentDeclaration,type:Pe.ExecutionResult,inheritanceLink:null}}else return L[ue.id]}).filter(ue=>!!ue);if(K=await this.executeFullFunctionDeclarationLogic(i.body,ve,e),(K.results||[]).forEach(ue=>{var $e,Ne,Be;if(ue.valueOwner.type!==d.InputMap||qt.includes(ue.valueOwner.parent.type))return;const ye=i.body.inputs.find(Se=>se(Se,s)===se(ue.valueOwner,s)),_e=[...($e=L[ye.id].value)==null?void 0:$e.value,((Ne=ue.value)==null?void 0:Ne.value)||null];(Be=L[ye.id].value)==null||Be.metaSync({value:_e},null),this.lastExecutionResults.writeValue(ye,L[ye.id].value)}),[G.CaughtError,G.Break,G.Return].includes(K.value))break;ee++}break}case Q.loop["string-loop"].id:{const re=$[0];let ee=1;const de=re.split("");for(let le=0;le<de.length;le++){const fe=de[le],ve=i.body.inputs.map(ue=>{if(ue===i.currentIterationNumberArgumentDeclaration){const ye=this.lastExecutionResults.readValue(ue.id);if(ye)return ye.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ue,ye),{value:ye,valueOwner:ue,type:Pe.ExecutionResult,inheritanceLink:null};const Ve=i.currentIterationNumberArgumentDeclaration.getDataType(null),_e=It(Ve,ue,s);return _e==null||_e.metaSync({value:ee},null),this.lastExecutionResults.writeValue(ue,_e),{value:_e,valueOwner:i.currentIterationNumberArgumentDeclaration,type:Pe.ExecutionResult,inheritanceLink:null}}else if(ue===i.currentValueArgumentDeclaration){const ye=i.currentValueArgumentDeclaration.getDataType(null),Ve=mc(ye),_e=this.lastExecutionResults.readValue(ue.id);if(_e)return _e.metaSync({value:fe},null),this.lastExecutionResults.writeValue(ue,_e),{value:_e,valueOwner:ue,type:Pe.ExecutionResult,inheritanceLink:null};const $e={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:fe,valueAsTypeSingle:null,valueAsTypeList:null,parent:null,name:Ve,standaloneParent:ue.toReference()},Ne=Si($e,s);return this.lastExecutionResults.writeValue(ue,Ne),{value:Ne,valueOwner:i.currentValueArgumentDeclaration,type:Pe.ExecutionResult,inheritanceLink:null}}else return L[ue.id]}).filter(ue=>!!ue);if(K=await this.executeFullFunctionDeclarationLogic(i.body,ve,e),(K.results||[]).forEach(ue=>{var $e,Ne,Be;if(ue.valueOwner.type!==d.InputMap||qt.includes(ue.valueOwner.parent.type))return;const ye=i.body.inputs.find(Se=>se(Se,s)===se(ue.valueOwner,s)),_e=[...($e=L[ye.id].value)==null?void 0:$e.value,((Ne=ue.value)==null?void 0:Ne.value)||null];(Be=L[ye.id].value)==null||Be.metaSync({value:_e},null),this.lastExecutionResults.writeValue(ye,L[ye.id].value)}),[G.CaughtError,G.Break,G.Return].includes(K.value))break;ee++}break}}if(V={value:[G.CaughtError,G.Return].includes(K.value)?K.value:G.Success,error:((m=(y=K.error)==null?void 0:y.value)==null?void 0:m.value)||null,result:((E=(v=K==null?void 0:K.result)==null?void 0:v.value)==null?void 0:E.value)||null},V.error&&i.error){const re=(b=i.error)==null?void 0:b.getDataType(null),ee=It(re||null,i.error,s);re!=null&&re.asType?ee==null||ee.setValueAsTypeSingle(V.error):ee==null||ee.metaSync({value:V.error},null);const de={valueOwner:i.error,type:Pe.ExecutionResult,inheritanceLink:null,value:ee};return{value:V.value,entity:i,error:de,result:null}}const S=i==null?void 0:i.getDataType(null),Y=It(S,i,s);return S!=null&&S.asType?Y==null||Y.setValueAsTypeSingle(V.result):Y==null||Y.metaSync({value:V.result},null),{value:V.value,entity:i,error:null,result:{value:Y||null,valueOwner:i,type:Pe.ExecutionResult,inheritanceLink:null}}}catch(V){if(J.Logger.warn("Error executing loop: ",V),i.error){const $=(w=i.error)==null?void 0:w.getDataType(null),L=It($,i.error,s);return $!=null&&$.asType?L==null||L.setValueAsTypeSingle(V):L==null||L.metaSync({value:V},null),{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,entity:i,error:{valueOwner:i.error,type:Pe.ExecutionResult,inheritanceLink:null,value:L},result:null}}else return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,entity:i,error:null,result:null}}}async executeFunctionCall(i,n,s,c={}){var y,m,v,E,b,w,V,$,L,k,K,S,Y,re,ee,de,le,fe,ve,ue,ye,Ve,_e,$e,Ne,Be;const e={...Eu,...c};try{const Se=await this.executeDetachedFullFunctionDeclarationLogic(i.declaration,n,s,e);let je=null;if(Se.error&&i.error){J.Logger.warn("Raw error executing entity: ",Se.error);const ot=(y=i.error)==null?void 0:y.getDataType(null),Rt=It(ot||null,i.error,s);ot!=null&&ot.asType?(v=(m=Se.error)==null?void 0:m.value)!=null&&v.valueAsTypeSingle?Rt==null||Rt.setValueAsTypeSingle((b=(E=Se.error)==null?void 0:E.value)==null?void 0:b.valueAsTypeSingle):(V=(w=Se.error)==null?void 0:w.value)!=null&&V.valueAsTypeList&&Array.isArray((L=($=Se.error)==null?void 0:$.value)==null?void 0:L.valueAsTypeList)&&(Rt==null||Rt.setValueAsTypeList((K=(k=Se.error)==null?void 0:k.value)==null?void 0:K.valueAsTypeList)):Rt==null||Rt.metaSync({value:(Y=(S=Se.error)==null?void 0:S.value)==null?void 0:Y.value},null),je={valueOwner:i.error,type:Pe.ExecutionResult,inheritanceLink:null,value:Rt}}let Ze=G.Success;Se.value===G.UnhandledError&&(i.catchesError||i.errorCalls.length?Ze=G.CaughtError:Ze=G.UnhandledError);const Ye=i==null?void 0:i.getDataType(null),lt=It(Ye,i,s);return Ye!=null&&Ye.asType?(ee=(re=Se.result)==null?void 0:re.value)!=null&&ee.valueAsTypeSingle?lt==null||lt.setValueAsTypeSingle((le=(de=Se.result)==null?void 0:de.value)==null?void 0:le.valueAsTypeSingle):(ve=(fe=Se.result)==null?void 0:fe.value)!=null&&ve.valueAsTypeList&&Array.isArray((ye=(ue=Se.result)==null?void 0:ue.value)==null?void 0:ye.valueAsTypeList)&&(lt==null||lt.setValueAsTypeList((_e=(Ve=Se.result)==null?void 0:Ve.value)==null?void 0:_e.valueAsTypeList)):lt==null||lt.metaSync({value:((Ne=($e=Se.result)==null?void 0:$e.value)==null?void 0:Ne.value)||null},null),{value:Ze,entity:i,error:je,result:{value:lt||null,valueOwner:i,type:Pe.ExecutionResult,inheritanceLink:null}}}catch(Se){if(!i.error)return{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,entity:i,error:null,result:null};const je=(Be=i.error)==null?void 0:Be.getDataType(null),Ze=It(je,i.error,s);return je!=null&&je.asType?Ze==null||Ze.setValueAsTypeSingle(Se):Ze==null||Ze.metaSync({value:Se},null),{value:i.catchesError||i.errorCalls.length?G.CaughtError:G.UnhandledError,entity:i,error:{valueOwner:i.error,type:Pe.ExecutionResult,inheritanceLink:null,value:Ze},result:null}}}async executeCondition(i,n){var c,e,y,m;let s=!1;switch(i.declaration.id){case en.BooleanIsTrue:{const v=(e=(c=n[0])==null?void 0:c.value)==null?void 0:e.value;if(typeof v!="boolean")throw new TypeError("BooleanIsTrue expects a boolean input.");s=v===!0;break}case en.BooleanIsFalse:{const v=(m=(y=n[0])==null?void 0:y.value)==null?void 0:m.value;if(typeof v!="boolean")throw new TypeError("BooleanIsFalse expects a boolean input.");s=v===!1;break}case dr.And:{s=(await Promise.all(i.andChildrenGroup.map(async E=>{const b=this.mergeExernalValuesWithInternalInputs(n,E);return(await this.executeCondition(E,b)).value===G.Success}))).every(E=>E);break}case dr.Or:{s=(await Promise.all(i.orChildrenGroup.map(async E=>{const b=this.mergeExernalValuesWithInternalInputs(n,E);return(await this.executeCondition(E,b)).value===G.Success}))).some(E=>E);break}default:throw new Error(`Condition declaration ${i.declaration.name} does not have an implementation.`)}return{value:s?G.Success:G.ConditionNotMet,entity:i,error:null,result:null}}async executeDetachedFullFunctionDeclarationLogic(i,n,s,c={}){const e={...Eu,...c,onBeforeEntityExecution:(v,E,b)=>{var w;return((w=c==null?void 0:c.onBeforeEntityExecution)==null?void 0:w.call(c,v,E,{...b,detached:!0}))||Promise.resolve()},onEntityExecuted:(v,E,b)=>{var w;return((w=c==null?void 0:c.onEntityExecuted)==null?void 0:w.call(c,v,E,{...b,detached:!0}))||Promise.resolve()}},y=new Iu(s,[i,...VA(i)],i,this,this.parentContext);return y.inheritValuesFromContext(this),await y.execute(e,n)}async executeFullFunctionDeclarationLogic(i,n,s={}){const c={...Eu,...s},e=VA(i);e.forEach(v=>{this.addEntity(v)}),e.reduce((v,E)=>qt.includes(E.type)?[...v,...E.outputs]:Qt.includes(E.type)&&E.type!==d.Condition?[...v,...E.outputs,...E.inputs]:E.type===d.Condition?[...v,...E.inputs]:v,[]).forEach(v=>{this.lastExecutionResults.removeValue(v.id)});const m=await this.executeBranch(i,c,n);return{...m||{},value:(m==null?void 0:m.value)||G.Success,entity:i,error:(m==null?void 0:m.error)||null,result:(m==null?void 0:m.result)||null}}static async executeEntryPointEntity(i,n){return{value:G.Success,entity:i,error:null,result:null}}async executeReturnStatement(i,n){var y,m,v,E,b,w,V;if((y=i.throws)!=null&&y.readsValue){const $=Ao(i.throws,this.valueResolutionContext);return{value:G.UnhandledError,entity:i,error:{valueOwner:i.throws,type:Pe.ExecutionResult,inheritanceLink:null,value:($==null?void 0:$.value)||null},result:null}}let s=Ao(i,this.valueResolutionContext);const c=i.getDataType(null);if(c!=null&&c.isObject()){let $={};if(((m=c==null?void 0:c.entity)==null?void 0:m.type)===d.DefinitionEntity&&($={...$,...c.entity.getActiveRawDefaultValue()}),s!=null&&s.value)hr((v=s==null?void 0:s.value)==null?void 0:v.value)&&($={...$,...(E=s==null?void 0:s.value)==null?void 0:E.value}),s==null||s.value.metaSync({value:$},null);else{const L=It(c,i,this.project);L==null||L.metaSync({value:$},null),s={valueOwner:i,type:Pe.ExecutionResult,inheritanceLink:null,value:L}}this.lastExecutionResults.writeValue(i,s.value),i.outputs.forEach(L=>{var k,K;if(((k=L.declaration)==null?void 0:k.type)===d.Property&&L.declaration.static){const S=this.lastExecutionResults.readValue(L.declaration.id),Y=se(L,this.project),re=L.codeName||((K=L.declaration)==null?void 0:K.codeName)||Hi(Y);if(S)S.metaSync({value:$[re]},null),this.lastExecutionResults.writeValue(L.declaration,S);else{const ee=It(L.getDataType(null),L,this.project);ee==null||ee.metaSync({value:$[re]},null),this.lastExecutionResults.writeValue(L.declaration,ee)}}})}else this.lastExecutionResults.writeValue(i,s==null?void 0:s.value);const e=(b=s==null?void 0:s.value)!=null&&b.value&&hr((w=s.value)==null?void 0:w.value)?((V=s.value)==null?void 0:V.value)||{}:{};return i.outputs.map($=>{var S;const L=$.codeName||((S=$.declaration)==null?void 0:S.codeName)||Hi(se($,this.project)),k=e[L],K=It($.getDataType(null),$,this.project);K==null||K.metaSync({value:k},null),Pe.ExecutionResult}),s.type=Pe.ExecutionResult,{value:G.Return,entity:i,error:null,result:s}}async executeContinueStatement(i,n){var y,m,v,E,b,w,V;if((y=i.throws)!=null&&y.readsValue){const $=Ao(i.throws,this.valueResolutionContext);return{value:G.UnhandledError,entity:i,error:{valueOwner:i.throws,type:Pe.ExecutionResult,inheritanceLink:null,value:($==null?void 0:$.value)||null},result:null}}let s=Ao(i,this.valueResolutionContext);const c=i.getDataType(null);if(c!=null&&c.isObject()){let $={};if(((m=c==null?void 0:c.entity)==null?void 0:m.type)===d.DefinitionEntity&&($={...$,...c.entity.getActiveRawDefaultValue()}),s!=null&&s.value)hr((v=s==null?void 0:s.value)==null?void 0:v.value)&&($={...$,...(E=s==null?void 0:s.value)==null?void 0:E.value}),s==null||s.value.metaSync({value:$},null);else{const L=It(c,i,this.project);L==null||L.metaSync({value:$},null),s={valueOwner:i,type:Pe.ExecutionResult,inheritanceLink:null,value:L}}this.lastExecutionResults.writeValue(i,s.value),i.outputs.forEach(L=>{var k,K;if(((k=L.declaration)==null?void 0:k.type)===d.Property&&L.declaration.static){const S=this.lastExecutionResults.readValue(L.declaration.id),Y=se(L,this.project),re=L.codeName||((K=L.declaration)==null?void 0:K.codeName)||Hi(Y);if(S)S.metaSync({value:$[re]},null),this.lastExecutionResults.writeValue(L.declaration,S);else{const ee=It(L.getDataType(null),L,this.project);ee==null||ee.metaSync({value:$[re]},null),this.lastExecutionResults.writeValue(L.declaration,ee)}}})}else this.lastExecutionResults.writeValue(i,s==null?void 0:s.value);const e=(b=s==null?void 0:s.value)!=null&&b.value&&hr((w=s.value)==null?void 0:w.value)?((V=s.value)==null?void 0:V.value)||{}:{};return i.outputs.map($=>{var S;const L=$.codeName||((S=$.declaration)==null?void 0:S.codeName)||Hi(se($,this.project)),k=e[L],K=It($.getDataType(null),$,this.project);K==null||K.metaSync({value:k},null),Pe.ExecutionResult}),s.type=Pe.ExecutionResult,{value:G.Continue,entity:i,error:null,result:s}}async executeBreakStatement(i,n){var y,m,v,E,b,w,V;if((y=i.throws)!=null&&y.readsValue){const $=Ao(i.throws,this.valueResolutionContext);return{value:G.UnhandledError,entity:i,error:{valueOwner:i.throws,type:Pe.ExecutionResult,inheritanceLink:null,value:($==null?void 0:$.value)||null},result:null}}let s=Ao(i,this.valueResolutionContext);const c=i.getDataType(null);if(c!=null&&c.isObject()){let $={};if(((m=c==null?void 0:c.entity)==null?void 0:m.type)===d.DefinitionEntity&&($={...$,...c.entity.getActiveRawDefaultValue()}),s!=null&&s.value)hr((v=s==null?void 0:s.value)==null?void 0:v.value)&&($={...$,...(E=s==null?void 0:s.value)==null?void 0:E.value}),s==null||s.value.metaSync({value:$},null);else{const L=It(c,i,this.project);L==null||L.metaSync({value:$},null),s={valueOwner:i,type:Pe.ExecutionResult,inheritanceLink:null,value:L}}this.lastExecutionResults.writeValue(i,s.value),i.outputs.forEach(L=>{var k,K;if(((k=L.declaration)==null?void 0:k.type)===d.Property&&L.declaration.static){const S=this.lastExecutionResults.readValue(L.declaration.id),Y=se(L,this.project),re=L.codeName||((K=L.declaration)==null?void 0:K.codeName)||Hi(Y);if(S)S.metaSync({value:$[re]},null),this.lastExecutionResults.writeValue(L.declaration,S);else{const ee=It(L.getDataType(null),L,this.project);ee==null||ee.metaSync({value:$[re]},null),this.lastExecutionResults.writeValue(L.declaration,ee)}}})}else this.lastExecutionResults.writeValue(i,s==null?void 0:s.value);const e=(b=s==null?void 0:s.value)!=null&&b.value&&hr((w=s.value)==null?void 0:w.value)?((V=s.value)==null?void 0:V.value)||{}:{};return i.outputs.map($=>{var S;const L=$.codeName||((S=$.declaration)==null?void 0:S.codeName)||Hi(se($,this.project)),k=e[L],K=It($.getDataType(null),$,this.project);K==null||K.metaSync({value:k},null),Pe.ExecutionResult}),s.type=Pe.ExecutionResult,{value:G.Break,entity:i,error:null,result:s}}async executeVariable(i,n){var m,v,E,b,w,V;let s=Ao(i,this.valueResolutionContext);const c=Wn(i),e=c.getDataType(null);if(e!=null&&e.isObject()){let $={};if(((m=e==null?void 0:e.entity)==null?void 0:m.type)===d.DefinitionEntity&&($={...$,...e.entity.getActiveRawDefaultValue()}),s!=null&&s.value)hr((v=s==null?void 0:s.value)==null?void 0:v.value)&&($={...$,...(E=s==null?void 0:s.value)==null?void 0:E.value}),s==null||s.value.metaSync({value:$},null);else{const L=It(e,i,this.project);L==null||L.metaSync({value:$},null),s={valueOwner:c,type:Pe.ExecutionResult,inheritanceLink:null,value:L}}this.lastExecutionResults.writeValue(c,s.value),c.inputs.forEach(L=>{var k,K;if(((k=L.declaration)==null?void 0:k.type)===d.Property&&L.declaration.static){const S=this.lastExecutionResults.readValue(L.declaration.id),Y=se(L,this.project),re=L.codeName||((K=L.declaration)==null?void 0:K.codeName)||Hi(Y);if(S)S.metaSync({value:$[re]},null),this.lastExecutionResults.writeValue(L.declaration,S);else{const ee=It(L.getDataType(null),L,this.project);ee==null||ee.metaSync({value:$[re]},null),this.lastExecutionResults.writeValue(L.declaration,ee)}}})}else this.lastExecutionResults.writeValue(c,s==null?void 0:s.value);const y=(b=s==null?void 0:s.value)!=null&&b.value&&hr((w=s.value)==null?void 0:w.value)?((V=s.value)==null?void 0:V.value)||{}:{};return i.outputs.map($=>{var S;const L=$.codeName||((S=$.declaration)==null?void 0:S.codeName)||Hi(se($,this.project)),k=y[L],K=It($.getDataType(null),$,this.project);K==null||K.metaSync({value:k},null),Pe.ExecutionResult}),s.type=Pe.ExecutionResult,{value:G.Success,entity:i,error:null,result:s}}mergeValues(i,n){const s=[];for(let c=0;c<n.length;c++)i!=null&&i[c]?s.push(i[c]):s.push(n[c]);return s}async executeEntity(i,n=[],s={}){var y,m,v,E,b,w,V,$,L,k,K;const c={...Eu,...s},e={detached:!1};switch(i.type){case d.Condition:{const S=this.mergeExernalValuesWithInternalInputs(n,i);return await((y=c.onBeforeEntityExecution)==null?void 0:y.call(c,i,S,e)),this.executeCondition(i,S)}case d.InternalCall:{const S=this.mergeExernalValuesWithInternalInputs(n,i);return await((m=c.onBeforeEntityExecution)==null?void 0:m.call(c,i,S,e)),this.executeInternalCall(i,S,this.project)}case d.Operation:{const S=this.mergeExernalValuesWithInternalInputs(n,i);return await((v=c.onBeforeEntityExecution)==null?void 0:v.call(c,i,S,e)),Iu.executeOperation(i,S,this.project)}case d.VariableInstance:case d.VariableDeclaration:return this.executeVariable(i,n);case d.FunctionCall:{const S=this.mergeExernalValuesWithInternalInputs(n,i);return await((E=c.onBeforeEntityExecution)==null?void 0:E.call(c,i,S,e)),this.executeFunctionCall(i,S,this.project)}case d.FunctionDeclaration:{const S=this.mergeExernalValuesWithInternalInputs(n,i);return await((b=c.onBeforeEntityExecution)==null?void 0:b.call(c,i,S,e)),Iu.executeEntryPointEntity(i,S)}case d.Search:{const S=this.mergeExernalValuesWithInternalInputs(n,i);return await((w=c.onBeforeEntityExecution)==null?void 0:w.call(c,i,S,e)),this.executeSearch(i,S,this.project)}case d.Loop:{const S=this.mergeExernalValuesWithInternalInputs(n,i);return await((V=c.onBeforeEntityExecution)==null?void 0:V.call(c,i,S,e)),this.executeLoop(i,S,this.project,c)}case d.ReturnStatement:{const S=this.mergeExernalValuesWithInternalInputs(n,i);return await(($=c.onBeforeEntityExecution)==null?void 0:$.call(c,i,S,e)),this.executeReturnStatement(i,S)}case d.ContinueStatement:{const S=this.mergeExernalValuesWithInternalInputs(n,i);return await((L=c.onBeforeEntityExecution)==null?void 0:L.call(c,i,S,e)),this.executeContinueStatement(i,S)}case d.BreakStatement:{const S=this.mergeExernalValuesWithInternalInputs(n,i);return await((k=c.onBeforeEntityExecution)==null?void 0:k.call(c,i,S,e)),this.executeBreakStatement(i,S)}case d.GlobalEvent:{const S=this.mergeExernalValuesWithInternalInputs(n,i);return await((K=c.onBeforeEntityExecution)==null?void 0:K.call(c,i,S,e)),Iu.executeEntryPointEntity(i,S)}default:throw new Error(`Entity type ${i==null?void 0:i.type} is not recognized for execution.`)}}storeLastExecutionValues(i){var s,c,e;if(i.error&&i.error.valueOwner&&this.lastExecutionResults.writeValue(i.error.valueOwner,i.error.value),!i.result||!((s=i.result)!=null&&s.valueOwner))return;const n=Oo((c=i.result)==null?void 0:c.valueOwner,this.project);(e=i.result)!=null&&e.value?n.forEach(y=>{var m;this.lastExecutionResults.writeValue(y,(m=i.result)==null?void 0:m.value)}):n.forEach(y=>{this.lastExecutionResults.removeValue(y.id)})}async executeBranch(i,n={},s=[]){var v;const c={...Eu,...n},e={detached:!1};if(!this.hasEntity(i)||this.hasSkipped(i))return null;this.addToExecutingList(i),this.hasScheduled(i)&&this.removeScheduled(i);const m=await this.executeEntity(i,s,c);if(this.removeFromExecutingList(i),this.addToAlreadyExecutedList(i),this.storeLastExecutionValues(m),await((v=c.onEntityExecuted)==null?void 0:v.call(c,i,m,e)),m.value===G.Success){const E=(i.successCalls||i.calls||[]).filter(L=>this.hasEntity(L));(i.errorCalls||[]).forEach(L=>{this.skip(L)});let w=[];const V=(await Promise.all(E.map(L=>this.schedule(L,[],c)))).filter(L=>!!L),$=V.filter(L=>!!L).find(L=>L.value===G.CaughtError||L.value===G.Return||L.value===G.Break||L.value===G.Continue);return $||(w=[...w,...V],m)}else if(m.value===G.CaughtError||m.value===G.ConditionNotMet){const E=(i.errorCalls||[]).filter(L=>this.hasEntity(L));(i.successCalls||i.calls||[]).forEach(L=>{this.skip(L)});let w=[];const V=(await Promise.all(E.map(L=>this.schedule(L,[],c)))).filter(L=>!!L),$=V.filter(L=>!!L).find(L=>L.value===G.CaughtError||L.value===G.UnhandledError||L.value===G.Return||L.value===G.Break||L.value===G.Continue);return $||(w=[...w,...V],m)}else{if(m.value===G.UnhandledError)return this.executing.forEach(E=>{this.skip(E)}),this.scheduled.forEach(E=>{this.skip(E)}),Zr.includes(m.entity.type)&&wt(m.entity).forEach(E=>{this.skip(E)}),m;if(m.value===G.Return)return m;if(m.value===G.Break)return m;if(m.value===G.Continue)return m}return m}async execute(i={},n=[]){const s={...Eu,...i};this.state="running";const c=await this.executeBranch(this.entryPoint,s,n);return this.state="finished-success",c}addEntity(i){var n;this.entities.includes(i)||(this.entities.push(i),(n=this.onAddEntityCallback)==null||n.call(this,i,{}))}async addEntityAsync(i,n={}){var s;this.entities.includes(i)||(this.entities.push(i),await((s=this.onAddEntityCallback)==null?void 0:s.call(this,i,n)))}addEntities(i){i.forEach(n=>this.addEntity(n))}async addEntitiesAsync(i,n={}){const s=J.YieldTracker.from(n),c=[];for(const e of i)c.push(this.addEntityAsync(e,n)),await s.tick();await Promise.all(c)}removeEntity(i){var n;if(i!==this.entryPoint){const s=this.entities.indexOf(i);s>-1&&(this.entities.splice(s,1),(n=this.onRemoveEntityCallback)==null||n.call(this,i,{}))}}hasEntity(i){var c,e,y;if(this.entities.includes(i))return!0;if(((c=i.parent)==null?void 0:c.type)===d.FunctionDeclaration&&((y=(e=i.parent)==null?void 0:e.parent)==null?void 0:y.type)===d.DefinitionEntity)return this.entities.includes(i.parent);const n=li(i);if(!n)return!1;const s=n.type===d.Loop&&i.parent===n.body?n.body:null;return s?this.entities.includes(s)||this.entities.includes(n):this.entities.includes(n)}removeScheduled(i){const n=this.scheduled.indexOf(i);n>-1&&this.scheduled.splice(n,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 n=this.project.get(i);return n?this.hasEntity(n):!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 n=this.scheduled.indexOf(i);n>-1&&this.scheduled.splice(n,1)}removeFromExecutingList(i){var s;const n=this.executing.indexOf(i);n>-1&&(this.executing.splice(n,1),(s=this.onAbortExecutionCallback)==null||s.call(this,i,{}))}removeFromAlreadyExecutedList(i){const n=this.executed.indexOf(i);n>-1&&this.executed.splice(n,1)}removeFromSkippedList(i){var s;const n=this.skipped.indexOf(i);n>-1&&(this.skipped.splice(n,1),(s=this.onRemoveFromSkippedListCallback)==null||s.call(this,i,{}))}addToAlreadyExecutedList(i){this.executed.includes(i)||this.executed.push(i)}addToSkippedList(i){var n;this.skipped.includes(i)||(this.skipped.push(i),(n=this.onAddToSkippedListCallback)==null||n.call(this,i,{}))}getValueTypePreference(i){return this.parentContext.getValueTypePreference(i)||null}setValueTypePreference(i,n){this.parentContext.setValueTypePreference(i,n),this.emit(i,{})}}function $bi(o){var p,i;if(o.isList)return"list";if(((p=o.entity)==null?void 0:p.type)===d.DefinitionEntity)return"definition-entity";switch((i=o.entity)==null?void 0:i.name){case oe.Number:return"number";case oe.String:return"text";case oe.Boolean:return"boolean";case oe.UUID:return"uuid";case oe.Date:return"date-time";default:return"definition-entity"}}const as={[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 cN(o){const p=PR(o);if(!p){const n=$y(o);if(n.includes(Re.HTTP_ENDPOINT))return"HTTP endpoint";if(n.includes(Re.PERSISTED_ENTITY))return"Persisted entity";if(n.includes(Re.CRON_JOB))return"Scheduled execution";if(n.includes(Re.RELATIONAL_DATABASE))return"Relational database"}if(p){let n="Extension of "+se(p,p.project)+" entity",s=wo(n);const c=$y(o);return c.includes(Re.HTTP_ENDPOINT)?"HTTP endpoint"+(s?", "+s:""):c.includes(Re.PERSISTED_ENTITY)?"Persisted entity"+(s?", "+s:""):c.includes(Re.CRON_JOB)?"Scheduled execution"+(s?", "+s:""):c.includes(Re.RELATIONAL_DATABASE)?"Relational database"+(s?", "+s:""):n}let i="";return o.abstract&&(i="Template "),o.static&&(i+=i?" single copy ":"Single copy "),i?i+"definition":"Definition"}function ALe(o){return o.parent.type===d.DefinitionEntity||o.parent.type===d.InstalledProject?"Internal action of "+se(o.parent,o.project):o.parent.type===d.Loop?"Action repeated on every iteration":"Internal action of entity"}function fN(o){return ux(o)?ALe(o):"Custom trigger"}function Lbi(o){var p;switch(o.type){case d.DefinitionEntity:return cN(o);case d.FunctionDeclaration:return fN(o)}return(p=as[o.type])==null?void 0:p.singular}function Mbi(o){var p;switch(o.type){case d.DefinitionEntity:return cN(o);case d.FunctionDeclaration:return fN(o)}return(p=as[o.type])==null?void 0:p.singular}const yN=4e4,gLe=280,Bbi=300,hN=65,py=32,Zb=39,ILe=26,RLe=49,vA=44,Gbi=35,Hb=52,mN=10,ud=mN*2,EA=38,Wb=90,rC=270,DLe=yN/2+120,wLe=yN/2+180;function OLe(o){let i=py+vA+EA+mN;const n=[...o.inputs];return n.length&&(i+=ud,n.forEach(()=>{i+=ILe})),{height:i,width:280}}function CLe(o){let i=hN;const n=[];if([d.DefinitionEntity].includes(o.type)){const m=[...o.suggestedProperties||[],...o.properties||[]];m.length&&(i+=ud,m.forEach(v=>{i+=v.static?RLe:Zb}))}if([d.DefinitionEntity,d.InstalledProject,d.Loop].includes(o.type)){const m=[...(o==null?void 0:o.suggestedMethods)||[],...o.methods||[],...o.functions||[],...o.body?[o.body]:[]];m.length&&(i+=ud,m.forEach(v=>{const E=OLe(v);i+=E.height}))}Qt.includes(o.type)?(Gt.includes(o.type)?n.push(...(o.usedInputs||[]).flatMap(m=>[m])||[]):n.push(...(o.inputs||[]).flatMap(m=>[m])||[]),o.error&&(i+=Hb)):[d.ReturnStatement,d.BreakStatement,d.ContinueStatement].includes(o.type)?(n.push(...o.outputs||[]),o.throws&&(i+=Hb)):o.type===d.Condition&&(n.push(o.inputs[0]),o.inputs[1]&&n.push(o.inputs[1]));const s=n.length;s&&(i+=s*Zb,i+=ud);const c=[];if(o.type===d.FunctionDeclaration||o.type===d.GlobalEvent?c.push(...o.inputs||[]):Qt.includes(o.type)&&(Gt.includes(o.type)?c.push(...o.usedOutputs||[]):c.push(...o.outputs||[])),Gt.includes(o.type)){o.readsValue&&(i+=ud,i+=vA),o.writesValues.length&&(i+=ud,i+=vA),o.internalCalls.length&&o.usedInternalCalls.forEach(()=>i+=Hb+ud);const m=o.getDataType(null);(!m||m.inferred)&&(i+=EA)}const e=c.length;return e&&(i+=e*Zb,i+=ud),[d.DefinitionEntity,d.FunctionDeclaration,d.ReturnStatement,d.BreakStatement,d.ContinueStatement].includes(o.type)&&(i+=EA),{height:i,width:280}}function pv(o){return`${o.split("-").map((n,s)=>s===0?n.charAt(0).toUpperCase()+n.slice(1):n.toLowerCase()).join(" ")}.`}function kbi(o){switch(o.code){case he.AbstractEntityWithNonAbstractMethods:return"This template entity has non-template actions";case he.AbstractEntityWithNonAbstractProperties:return"This template entity has non-template properties";case he.IncorrectEntityImplementation:return"This entity incorrectly implements a template entity";case he.IncorrectMethodImplementation:return"This action incorrectly implements the template action it's based on";case he.IncorrectPropertyImplementation:return"This property incorrectly implements the template property it's based on";case he.AbstractMethodInNonAbstractEntity:return"This action is a template action in a non-template entity";case he.AbstractPropertyInNonAbstractEntity:return"This property is a template property in a non-template entity";case Ie.MethodOverwritesOtherSiblingWithSameName:return"An action in this entity overwrites an action in the template entity with the same name";case Ie.PropertyOverwritesOtherSiblingWithSameName:return"A property in this entity overwrites a property in the template entity with the same name";case he.MissingMethodImplementation:return"This entity is missing an action implementation from the template entity";case he.MissingPropertyImplementation:return"This entity is missing a property implementation from the template entity";case Ie.NameNotUniqueInScope:return"Invalid name. There is another entity with the same name in the same scope";case he.NoProperties:return"This entity has no properties, so it doesn't do anything";case he.NonStaticPropertyInStaticEntity:return"This property is not static in a static entity";case he.StaticEntityWithNonStaticProperties:return"This static entity has non-static properties";case he.ReadingFromIncompatibleType:return"This entity reads data from a value of a different data type";case he.WritingToIncompatibleType:return"This entity writes data to a value of a different data type";case he.ScopeWithoutLogic:return"This action has no logic, so it doesn't do anything";case he.NonStaticPropertyImplementsStatic:return"This property is static in a non-static entity";case he.PropertyImplementsIncompatibleType:return"This property implements a property of a different data type";case he.PropertyImplementsNonAbstact:return"This property implements a non-template property";case he.StaticPropertyImplementsNonStatic:return"This static property implements a non-static property";case he.VariableCallsOthersAndHasInternalCall:return"This variable calls other entities while being used to execute internal logic";case he.VariableHasInputsAndInternalCall:return"This variable has inputs while being used to execute internal logic";case he.VariableHasOutputsAndInternalCall:return"This variable has outputs while being used to execute internal logic";case he.VariableIsCalledAndHasInternalCall:return"This variable is called while being used to execute internal logic";case Ie.InternalCallDeclarationIsInvalidType:return"This internal call is not an action";case Ie.InternalCallDeclarationNotFoundInParentDatatypeEntity:return"This internal call is not found in the parent entity";case Ie.InternalCallParentDeclarationEntityInvalidType:return"This internal call parent entity is not a data type";case Ie.InternalCallParentMissingDataType:return"This internal call parent entity has no data type";case Ie.UnreachableEntity:return"This entity is unreachable";case he.DisconnectedCallableEntity:return"This entity is disconnected and won't be executed by anything after publishing";case he.AbstractEntityImplements:return"This template entity implements a non-template entity";case he.AbstractExtendingNonAbstractEntity:return"This template entity extends a non-template entity";case he.InvalidPropertiesCombination:return"This entity has an invalid combination of properties";case he.ExtendingNonInteractiveEntity:return"This entity extends a non-interactive entity";case he.ExtendsIncompatibleEntities:return"This entity extends incompatible entities";case he.ImplementingNonAbstractEntity:return"This entity implements a non-template entity";case he.ImplementsIncompatibleEntities:return"This entity implements incompatible entities";case he.LackingReturnStatementOnSomeBranches:return"This action is missing a termination on some branches";case he.LastCalledEntityMustBeReturnEntity:return"The last called entity in this action must be a termination node";case he.MissingRequiredValue:return"This action is missing a required value";case he.NoPrimaryKeyProperty:return"This entity has no primary key property";case he.NonAbstractExtendingAbstractEntity:return"This non-template entity extends a template entity";case he.NonStaticExtendingStaticEntity:return"This non-static entity extends a static entity";case he.NonStaticImplementingStaticEntity:return"This non-static entity implements a static entity";case he.StaticExtendingNonStaticEntity:return"This static entity extends a non-static entity";case he.StaticImplementingNonStaticEntity:return"This static entity implements a non-static entity";case he.VariableReadsValueAndInternalCall:return"This variable reads a value while being used to execute internal logic";case he.VariableWritesValuesAndInternalCall:return"This variable writes values while being used to execute internal logic";case Ie.InternalCallDeclarationNotInParentDatatypeEntity:return"This internal call declaration is not in the parent entity";case Ie.EmptyName:return"This entity has no name";case Ie.InvalidObjectStructure:return"This entity has an invalid structure";case Ie.LoopBodyFunctionOverwrite:return"This loop body action overwrites an action in the template entity with the same name";case Ie.MethodOverwritesBaseMethodWithSameImplementation:return"This action overwrites a base action with the same implementation";case Ie.MethodOverwritesOtherExtendedEntitysMethodWithSameImplementation:return"This action overwrites an action in an extended entity with the same implementation";case Ie.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation:return"This action overwrites an action in an implemented entity with the same implementation";case Ie.MissingCaller:return"This action is missing a caller";case Ie.NameAsResolvedCodeNameNotUniqueInScope:return"This entity has a name that is not unique in the scope of the code it is used in";case Ie.NameCanOnlyContainLettersNumbersUnderscoreAndSpaces:return"This entity name can only contain letters, numbers, underscores and spaces";case Ie.NameMustStartWithLetterOrUnderscore:return"This entity name must start with a letter or an underscore";case Ie.NoOverlapWithImplementedSignature:return"This action does not overlap with the implemented action signature";case Ie.PropertyOverwritesBasePropertyWithSameImplementation:return"This property overwrites a base property with the same implementation";case Ie.PropertyOverwritesOtherExtendedEntitysPropertyWithSameImplementation:return"This property overwrites a property in an extended entity with the same implementation";case Ie.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation:return"This property overwrites a property in an implemented entity with the same implementation";case Ie.ReaderWriterIncompatibleDataType:return"This reader/writer has an incompatible data type with the value it is reading/writing";case xo.StatusCodeMustBeBetween100And599:return"HTTP status code must be between 100 and 599";case xo.StatusCodeMustBeNumber:return"HTTP status code must be a number, between 100 and 599";case Ba.UUIDMustBeString:return`UUID must be a string, eg: "${Du()}"`;case Ba.UUIDMustNotContainSpaces:return`UUID must not contain spaces, eg: "${Du()}"`;case Ba.UUIDMustBeValidFormat:return`UUID must be in a valid format. Eg: "${Du()}"`;case sa.MustBeUniqueAmongSameEntities:return"This value must be unique among the same kind";case sa.StringValueMustNotHaveDashes:return"This value must not contain dashes";case sa.StringValueMustNotHaveSpaces:return"This value must not contain spaces";default:return pv(o.code)}}function jbi(o){switch(o.code){case he.AbstractEntityWithNonAbstractMethods:return"Non-template actions";case he.AbstractEntityWithNonAbstractProperties:return"Non-template properties";case he.IncorrectEntityImplementation:return"Incorrect implementation";case he.IncorrectMethodImplementation:return"Incorrect action implementation";case he.IncorrectPropertyImplementation:return"Incorrect property implementation";case he.AbstractMethodInNonAbstractEntity:return"Template action in non-template entity";case he.AbstractPropertyInNonAbstractEntity:return"Template property in non-template entity";case Ie.MethodOverwritesOtherSiblingWithSameName:return"Action overwrite";case Ie.PropertyOverwritesOtherSiblingWithSameName:return"Property overwrite";case he.MissingMethodImplementation:return"Missing action";case he.MissingPropertyImplementation:return"Missing property";case Ie.NameNotUniqueInScope:return"Duplicate name";case he.NoProperties:return"No properties";case he.NonStaticPropertyInStaticEntity:return"Non-static property";case he.StaticEntityWithNonStaticProperties:return"Non-static properties";case he.ReadingFromIncompatibleType:return"Read from different type";case he.WritingToIncompatibleType:return"Write to different type";case he.ScopeWithoutLogic:return"No logic";case he.NonStaticPropertyImplementsStatic:return"Invalid static property";case he.PropertyImplementsIncompatibleType:return"Incompatible data type";case he.PropertyImplementsNonAbstact:return"Non-template property";case he.StaticPropertyImplementsNonStatic:return"Non-static property";case he.VariableCallsOthersAndHasInternalCall:return"Bad internal call";case he.VariableHasInputsAndInternalCall:return"Bad internal call";case he.VariableHasOutputsAndInternalCall:return"Bad internal call";case he.VariableIsCalledAndHasInternalCall:return"Bad internal call";case Ie.InternalCallDeclarationIsInvalidType:return"Declaration not an action";case Ie.InternalCallDeclarationNotFoundInParentDatatypeEntity:return"Declaration not found in parent";case Ie.InternalCallParentDeclarationEntityInvalidType:return"Invalid parent declaration type";case Ie.InternalCallParentMissingDataType:return"Parent has no data type";case Ie.InternalCallDeclarationNotInParentDatatypeEntity:return"Declaration not in parent";case Ie.UnreachableEntity:return"Unreachable entity";case he.DisconnectedCallableEntity:return"Disconnected entity";case he.AbstractEntityImplements:return"Abstract entity implements a non-template entity";case he.AbstractExtendingNonAbstractEntity:return"Abstract entity extends a non-template entity";case he.InvalidPropertiesCombination:return"Invalid properties combination";case he.ExtendingNonInteractiveEntity:return"Extending non-interactive entity";case he.ExtendsIncompatibleEntities:return"Extends incompatible entities";case he.ImplementingNonAbstractEntity:return"Implementing non-template entity";case he.ImplementsIncompatibleEntities:return"Implements incompatible entities";case he.LackingReturnStatementOnSomeBranches:return"Missing termination on some branches";case he.LastCalledEntityMustBeReturnEntity:return"Last called entity must be a termination node";case he.MissingRequiredValue:return"Missing required value";case he.NoPrimaryKeyProperty:return"No primary key property";case he.NonAbstractExtendingAbstractEntity:return"Non-template entity extending a template entity";case he.NonStaticExtendingStaticEntity:return"Non-static entity extending a static entity";case he.NonStaticImplementingStaticEntity:return"Non-static entity implementing a static entity";case he.StaticExtendingNonStaticEntity:return"Static entity extending a non-static entity";case he.StaticImplementingNonStaticEntity:return"Static entity implementing a non-static entity";case he.VariableReadsValueAndInternalCall:return"Variable reads value and has internal call";case he.VariableWritesValuesAndInternalCall:return"Variable writes values and has internal call";case Ie.EmptyName:return"Empty name";case Ie.InvalidObjectStructure:return"Invalid object structure";case Ie.LoopBodyFunctionOverwrite:return"Loop body action overwrites action with same name";case Ie.MethodOverwritesBaseMethodWithSameImplementation:return"Action overwrites base action with same implementation";case Ie.MethodOverwritesOtherExtendedEntitysMethodWithSameImplementation:return"Action overwrites another with same implementation";case Ie.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation:return"Action overwrites another with same implementation";case Ie.MissingCaller:return"Missing caller";case Ie.NameAsResolvedCodeNameNotUniqueInScope:return"Name not unique in scope";case Ie.NameCanOnlyContainLettersNumbersUnderscoreAndSpaces:return"Name can only contain letters, numbers, underscores and spaces";case Ie.NameMustStartWithLetterOrUnderscore:return"Name must start with letter or underscore";case Ie.NoOverlapWithImplementedSignature:return"No overlap with implemented signature";case Ie.PropertyOverwritesBasePropertyWithSameImplementation:return"Property overwrites base property with same implementation";case Ie.PropertyOverwritesOtherExtendedEntitysPropertyWithSameImplementation:return"Property overwrites another with same implementation";case Ie.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation:return"Property overwrites another with same implementation";case Ie.ReaderWriterIncompatibleDataType:return"Reader/writer incompatible data type";case xo.StatusCodeMustBeBetween100And599:return"HTTP status code must be between 100 and 599";case xo.StatusCodeMustBeNumber:return"HTTP status code must be a number";case Ba.UUIDMustBeString:return"UUID must be a string";case Ba.UUIDMustNotContainSpaces:return"UUID must not contain spaces";case Ba.UUIDMustBeValidFormat:return"UUID must be in a valid format";case sa.MustBeUniqueAmongSameEntities:return"This value must be unique among the same kind";case sa.StringValueMustNotHaveDashes:return"This value must not contain dashes";case sa.StringValueMustNotHaveSpaces:return"This value must not contain spaces";default:return pv(o.code)}}function Ubi(o){switch(o.code){case he.AbstractEntityWithNonAbstractMethods:return`${se(o.entity,o.entity.project)} has non-template actions`;case he.AbstractEntityWithNonAbstractProperties:return`${se(o.entity,o.entity.project)} has non-template properties`;case he.IncorrectEntityImplementation:return`${se(o.entity,o.entity.project)} incorrectly implements template`;case he.IncorrectMethodImplementation:return`${se(o.entity,o.entity.project)} incorrectly implements the template`;case he.IncorrectPropertyImplementation:return`${se(o.entity,o.entity.project)} incorrectly implements the template`;case he.AbstractMethodInNonAbstractEntity:return`${se(o.entity,o.entity.project)} can't be a template`;case he.AbstractPropertyInNonAbstractEntity:return`${se(o.entity,o.entity.project)} can't be a template`;case Ie.MethodOverwritesOtherSiblingWithSameName:return`${se(o.entity,o.entity.project)} overwrites action`;case Ie.PropertyOverwritesOtherSiblingWithSameName:return`${se(o.entity,o.entity.project)} overwrites property`;case he.MissingMethodImplementation:return`${se(o.entity,o.entity.project)} is missing action`;case he.MissingPropertyImplementation:return`${se(o.entity,o.entity.project)} is missing property`;case Ie.NameNotUniqueInScope:return`${se(o.entity,o.entity.project)} name is not unique`;case he.NoProperties:return`${se(o.entity,o.entity.project)} has no properties`;case he.NonStaticPropertyInStaticEntity:return`${se(o.entity,o.entity.project)} has non-static property`;case he.StaticEntityWithNonStaticProperties:return`${se(o.entity,o.entity.project)} has non-static properties`;case he.ReadingFromIncompatibleType:return`${se(o.entity,o.entity.project)} reads from different type`;case he.WritingToIncompatibleType:return`${se(o.entity,o.entity.project)} writes to different type`;case he.ScopeWithoutLogic:return`${se(o.entity,o.entity.project)} has no logic`;case he.NonStaticPropertyImplementsStatic:return`${se(o.entity,o.entity.project)} has invalid static property`;case he.PropertyImplementsIncompatibleType:return`${se(o.entity,o.entity.project)} has incompatible data type`;case he.PropertyImplementsNonAbstact:return`${se(o.entity,o.entity.project)} has non-template property`;case he.StaticPropertyImplementsNonStatic:return`${se(o.entity,o.entity.project)} has non-static property`;case he.VariableCallsOthersAndHasInternalCall:return`${se(o.entity,o.entity.project)} has bad internal call`;case he.VariableHasInputsAndInternalCall:return`${se(o.entity,o.entity.project)} has bad internal call`;case he.VariableHasOutputsAndInternalCall:return`${se(o.entity,o.entity.project)} has bad internal call`;case he.VariableIsCalledAndHasInternalCall:return`${se(o.entity,o.entity.project)} has bad internal call`;case Ie.InternalCallDeclarationIsInvalidType:return`${se(o.entity,o.entity.project)} has declaration that is not an action`;case Ie.InternalCallDeclarationNotFoundInParentDatatypeEntity:return`${se(o.entity,o.entity.project)} has declaration that is not found in parent`;case Ie.InternalCallParentDeclarationEntityInvalidType:return`${se(o.entity,o.entity.project)} has invalid parent declaration type`;case Ie.InternalCallParentMissingDataType:return`${se(o.entity,o.entity.project)}'s parent has no data type`;case Ie.InternalCallDeclarationNotInParentDatatypeEntity:return`${se(o.entity,o.entity.project)} has declaration that is not in parent`;case Ie.UnreachableEntity:return`${se(o.entity,o.entity.project)} is unreachable`;case he.DisconnectedCallableEntity:return`${se(o.entity,o.entity.project)} is not executed by any entity`;case he.AbstractEntityImplements:return`${se(o.entity,o.entity.project)} implements a non-template entity`;case he.AbstractExtendingNonAbstractEntity:return`${se(o.entity,o.entity.project)} extends a non-template entity`;case he.InvalidPropertiesCombination:return`${se(o.entity,o.entity.project)} has invalid properties combination`;case he.ExtendingNonInteractiveEntity:return`${se(o.entity,o.entity.project)} extends a non-interactive entity`;case he.ExtendsIncompatibleEntities:return`${se(o.entity,o.entity.project)} extends incompatible entities`;case he.ImplementingNonAbstractEntity:return`${se(o.entity,o.entity.project)} implements a non-template entity`;case he.ImplementsIncompatibleEntities:return`${se(o.entity,o.entity.project)} implements incompatible entities`;case he.LackingReturnStatementOnSomeBranches:return`${se(o.entity,o.entity.project)} is missing termination on some branches`;case he.LastCalledEntityMustBeReturnEntity:return`${se(o.entity,o.entity.project)}'s last called entity must be a termination node`;case he.MissingRequiredValue:return`${se(o.entity,o.entity.project)} is missing a required value`;case he.NoPrimaryKeyProperty:return`${se(o.entity,o.entity.project)} has no primary key property`;case he.NonAbstractExtendingAbstractEntity:return`${se(o.entity,o.entity.project)} extends a template entity`;case he.NonStaticExtendingStaticEntity:return`${se(o.entity,o.entity.project)} extends a static entity`;case he.NonStaticImplementingStaticEntity:return`${se(o.entity,o.entity.project)} implements a static entity`;case he.StaticExtendingNonStaticEntity:return`${se(o.entity,o.entity.project)} extends a non-static entity`;case he.StaticImplementingNonStaticEntity:return`${se(o.entity,o.entity.project)} implements a non-static entity`;case he.VariableReadsValueAndInternalCall:return`${se(o.entity,o.entity.project)} reads a value and has internal call`;case he.VariableWritesValuesAndInternalCall:return`${se(o.entity,o.entity.project)} writes values and has internal call`;case Ie.EmptyName:return`${as[o.entity.type]} has no name`;case Ie.InvalidObjectStructure:return`${se(o.entity,o.entity.project)} has invalid structure`;case Ie.LoopBodyFunctionOverwrite:return`${se(o.entity,o.entity.project)}'s loop body action overwrites an action`;case Ie.MethodOverwritesBaseMethodWithSameImplementation:return`${se(o.entity,o.entity.project)} overwrites base action`;case Ie.MethodOverwritesOtherExtendedEntitysMethodWithSameImplementation:return`${se(o.entity,o.entity.project)} overwrites another action with same implementation`;case Ie.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation:return`${se(o.entity,o.entity.project)} overwrites another action with same implementation`;case Ie.MissingCaller:return`${se(o.entity,o.entity.project)} is missing a caller`;case Ie.NameAsResolvedCodeNameNotUniqueInScope:return`${se(o.entity,o.entity.project)} has a name not unique in the scope`;case Ie.NameCanOnlyContainLettersNumbersUnderscoreAndSpaces:return`${se(o.entity,o.entity.project)} name can only contain letters, numbers, underscores and spaces`;case Ie.NameMustStartWithLetterOrUnderscore:return`${se(o.entity,o.entity.project)} name must start with letter or underscore`;case Ie.NoOverlapWithImplementedSignature:return`${se(o.entity,o.entity.project)} has no overlap with implemented signature`;case Ie.PropertyOverwritesBasePropertyWithSameImplementation:return`${se(o.entity,o.entity.project)} overwrites base property`;case Ie.PropertyOverwritesOtherExtendedEntitysPropertyWithSameImplementation:return`${se(o.entity,o.entity.project)} overwrites another property with same implementation`;case Ie.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation:return`${se(o.entity,o.entity.project)} overwrites another property with same implementation`;case Ie.ReaderWriterIncompatibleDataType:return`${se(o.entity,o.entity.project)} has reader/writer with incompatible data type`;case xo.StatusCodeMustBeBetween100And599:return`${se(o.entity,o.entity.project)} HTTP status code must be between 100 and 599`;case xo.StatusCodeMustBeNumber:return`${se(o.entity,o.entity.project)} HTTP status code must be a number`;case Ba.UUIDMustBeString:return`${se(o.entity,o.entity.project)} UUID must be a string`;case Ba.UUIDMustNotContainSpaces:return`${se(o.entity,o.entity.project)} UUID must not contain spaces`;case Ba.UUIDMustBeValidFormat:return`${se(o.entity,o.entity.project)} UUID must be in a valid format`;case sa.MustBeUniqueAmongSameEntities:return`${se(o.entity,o.entity.project)} value must be unique among the same kind`;case sa.StringValueMustNotHaveDashes:return`${se(o.entity,o.entity.project)} value must not contain dashes`;case sa.StringValueMustNotHaveSpaces:return`${se(o.entity,o.entity.project)} value must not contain spaces`;default:return`${se(o.entity,o.entity.project)} Error: ${pv(o.code)}`}}function Kbi(o){var p,i,n,s;switch(o.code){case he.AbstractEntityWithNonAbstractMethods:return`${se(o.entity,o.entity.project)} has non-template actions`;case he.AbstractEntityWithNonAbstractProperties:return`${se(o.entity,o.entity.project)} has non-template properties`;case he.IncorrectEntityImplementation:return`${se(o.entity,o.entity.project)} incorrectly implements the template entity`;case he.IncorrectMethodImplementation:return`${se(o.entity,o.entity.project)} incorrectly implements the template action it's based on`;case he.IncorrectPropertyImplementation:return`${se(o.entity,o.entity.project)} incorrectly implements the template property it's based on`;case he.AbstractMethodInNonAbstractEntity:return`${se(o.entity,o.entity.project)} is a template action in a non-template entity`;case he.AbstractPropertyInNonAbstractEntity:return`${se(o.entity,o.entity.project)} is a template property in a non-template entity`;case Ie.MethodOverwritesOtherSiblingWithSameName:return`${se(o.entity,o.entity.project)} overwrites an action in the template entity`;case Ie.PropertyOverwritesOtherSiblingWithSameName:return`${se(o.entity,o.entity.project)} overwrites a property in the template entity`;case he.MissingMethodImplementation:return`${se(o.entity,o.entity.project)} is missing an action implementation from the template entity`;case he.MissingPropertyImplementation:return`${se(o.entity,o.entity.project)} is missing a property implementation from the template entity`;case Ie.NameNotUniqueInScope:return`${se(o.entity,o.entity.project)} has a duplicate name in the same scope`;case he.NoProperties:return`${se(o.entity,o.entity.project)} has no properties, so it doesn't do anything`;case he.NonStaticPropertyInStaticEntity:return`${se(o.entity,o.entity.project)} has a non-static property in a static entity`;case he.StaticEntityWithNonStaticProperties:return`${se(o.entity,o.entity.project)} has non-static properties in a static entity`;case he.ReadingFromIncompatibleType:return`${se(o.entity,o.entity.project)} reads data from a value of a different data type`;case he.WritingToIncompatibleType:return`${se(o.entity,o.entity.project)} writes data to a value of a different data type`;case he.ScopeWithoutLogic:return`${se(o.entity,o.entity.project)} has no logic`;case he.NonStaticPropertyImplementsStatic:return`${se(o.entity,o.entity.project)} has a static property in a non-static entity`;case he.PropertyImplementsIncompatibleType:return`${se(o.entity,o.entity.project)} implements a property of a different data type`;case he.PropertyImplementsNonAbstact:return`${se(o.entity,o.entity.project)} implements a non-template property`;case he.StaticPropertyImplementsNonStatic:return`${se(o.entity,o.entity.project)} has a static property in a non-static entity`;case he.VariableCallsOthersAndHasInternalCall:return`${se(o.entity,o.entity.project)} calls other entities while being used to execute internal logic`;case he.VariableHasInputsAndInternalCall:return`${se(o.entity,o.entity.project)} has inputs while being used to execute internal logic`;case he.VariableHasOutputsAndInternalCall:return`${se(o.entity,o.entity.project)} has outputs while being used to execute internal logic`;case he.VariableIsCalledAndHasInternalCall:return`${se(o.entity,o.entity.project)} is called while being used to execute internal logic`;case Ie.InternalCallDeclarationIsInvalidType:return`${se(o.entity,o.entity.project)} has a declaration that is not an action`;case Ie.InternalCallDeclarationNotFoundInParentDatatypeEntity:return`${se(o.entity,o.entity.project)} has a declaration that is not found in ${(p=o.entity.parent.getDataType(null))!=null&&p.entity?se((i=o.entity.parent.getDataType(null))==null?void 0:i.entity,o.entity.project):"the variable's data-type entity"}`;case Ie.InternalCallParentDeclarationEntityInvalidType:return`${se(o.entity,o.entity.project)} is part of a variable whos data-type entity can't have actions`;case Ie.InternalCallParentMissingDataType:return`${se(o.entity,o.entity.project)} is part of a variable with no data-type entity`;case Ie.InternalCallDeclarationNotInParentDatatypeEntity:return`${se(o.entity,o.entity.project)} has a declaration doesn't belong to ${(n=o.entity.parent.getDataType(null))!=null&&n.entity?se((s=o.entity.parent.getDataType(null))==null?void 0:s.entity,o.entity.project):"the variable's data-type entity"}`;case Ie.UnreachableEntity:return`${se(o.entity,o.entity.project)} is unreachable`;case he.DisconnectedCallableEntity:return`${se(o.entity,o.entity.project)} is disconnected and won't be executed by anything after publishing`;case he.AbstractEntityImplements:return`${se(o.entity,o.entity.project)} implements a non-template entity`;case he.AbstractExtendingNonAbstractEntity:return`${se(o.entity,o.entity.project)} extends a non-template entity`;case he.InvalidPropertiesCombination:return`${se(o.entity,o.entity.project)} has an invalid combination of properties`;case he.ExtendingNonInteractiveEntity:return`${se(o.entity,o.entity.project)} extends a non-interactive entity`;case he.ExtendsIncompatibleEntities:return`${se(o.entity,o.entity.project)} extends incompatible entities`;case he.ImplementingNonAbstractEntity:return`${se(o.entity,o.entity.project)} implements a non-template entity`;case he.ImplementsIncompatibleEntities:return`${se(o.entity,o.entity.project)} implements incompatible entities`;case he.LackingReturnStatementOnSomeBranches:return`${se(o.entity,o.entity.project)} has branches that don't terminate`;case he.LastCalledEntityMustBeReturnEntity:return`${se(o.entity,o.entity.project)} must end with a termination node`;case he.MissingRequiredValue:return`${se(o.entity,o.entity.project)} is missing a required value`;case he.NoPrimaryKeyProperty:return`${se(o.entity,o.entity.project)} has no primary key property`;case he.NonAbstractExtendingAbstractEntity:return`${se(o.entity,o.entity.project)} is a non-template entity extending a template entity`;case he.NonStaticExtendingStaticEntity:return`${se(o.entity,o.entity.project)} is a non-static entity extending a static entity`;case he.NonStaticImplementingStaticEntity:return`${se(o.entity,o.entity.project)} is a non-static entity implementing a static entity`;case he.StaticExtendingNonStaticEntity:return`${se(o.entity,o.entity.project)} is a static entity extending a non-static entity`;case he.StaticImplementingNonStaticEntity:return`${se(o.entity,o.entity.project)} is a static entity implementing a non-static entity`;case he.VariableReadsValueAndInternalCall:return`${se(o.entity,o.entity.project)} reads a value and has an internal call`;case he.VariableWritesValuesAndInternalCall:return`${se(o.entity,o.entity.project)} writes values and has an internal call`;case Ie.EmptyName:return`${as[o.entity.type]} has no name`;case Ie.InvalidObjectStructure:return`${se(o.entity,o.entity.project)} has an invalid structure`;case Ie.LoopBodyFunctionOverwrite:return`${se(o.entity,o.entity.project)}'s loop body action overwrites`;case Ie.MethodOverwritesBaseMethodWithSameImplementation:return`${se(o.entity,o.entity.project)} overwrites a base action with same implementation`;case Ie.MethodOverwritesOtherExtendedEntitysMethodWithSameImplementation:return`${se(o.entity,o.entity.project)} overwrites another action with same implementation`;case Ie.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation:return`${se(o.entity,o.entity.project)} overwrites another action with same implementation`;case Ie.MissingCaller:return`${se(o.entity,o.entity.project)} is missing a caller`;case Ie.NameAsResolvedCodeNameNotUniqueInScope:return`${se(o.entity,o.entity.project)} has a name that is not unique in the scope`;case Ie.NameCanOnlyContainLettersNumbersUnderscoreAndSpaces:return`${se(o.entity,o.entity.project)} name can only contain letters, numbers, underscores and spaces`;case Ie.NameMustStartWithLetterOrUnderscore:return`${se(o.entity,o.entity.project)} name must start with letter or underscore`;case Ie.NoOverlapWithImplementedSignature:return`${se(o.entity,o.entity.project)} has no overlap with implemented signature`;case Ie.PropertyOverwritesBasePropertyWithSameImplementation:return`${se(o.entity,o.entity.project)} overwrites a base property with same implementation`;case Ie.PropertyOverwritesOtherExtendedEntitysPropertyWithSameImplementation:return`${se(o.entity,o.entity.project)} overwrites another property with same implementation`;case Ie.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation:return`${se(o.entity,o.entity.project)} overwrites another property with same implementation`;case Ie.ReaderWriterIncompatibleDataType:return`${se(o.entity,o.entity.project)} has a reader/writer with incompatible data type`;case xo.StatusCodeMustBeBetween100And599:return`${se(o.entity,o.entity.project)} HTTP status code must be between 100 and 599`;case xo.StatusCodeMustBeNumber:return`${se(o.entity,o.entity.project)} HTTP status code must be a number, between 100 and 599`;case Ba.UUIDMustBeString:return`${se(o.entity,o.entity.project)} UUID must be a string, eg: "${Du()}"`;case Ba.UUIDMustNotContainSpaces:return`${se(o.entity,o.entity.project)} UUID must not contain spaces, eg: "${Du()}"`;case Ba.UUIDMustBeValidFormat:return`${se(o.entity,o.entity.project)} UUID must be in a valid format. Eg: "${Du()}"`;case sa.MustBeUniqueAmongSameEntities:return`${se(o.entity,o.entity.project)} value must be unique among the same kind`;case sa.StringValueMustNotHaveDashes:return`${se(o.entity,o.entity.project)} value must not contain dashes`;case sa.StringValueMustNotHaveSpaces:return`${se(o.entity,o.entity.project)} value must not contain spaces`;default:return`${se(o.entity,o.entity.project)} Error: ${pv(o.code)}`}}var TN=(o=>(o.ValuesAlreadyConnected="values-already-connected",o.CannotReadMoreThanOneValue="cannot-read-more-than-one-value",o.CannotReadValueFromChildren="cannot-read-value-from-children",o.CannotWriteValueToChildren="cannot-write-value-to-children",o.CannotBeCalledByChildren="cannot-be-called-by-children",o.ExecutionsAlreadyConnected="executions-already-connected",o.DataTypesNotCompatible="data-types-not-compatible",o.CannotCallAncestor="cannot-call-ancestor",o.CannotConnectToItself="cannot-connect-to-itself",o.CannotWriteValueToAncestor="cannot-write-value-to-ancestor",o.NotInScope="not-in-scope",o.IsNotValueWrittingEntity="is-not-value-writting-entity",o.IsNotValueReadingEntity="is-not-value-reading-entity",o.ContinueOrBreakStatementCalledFromOutsideLoop="continue-or-break-statement-called-from-outside-loop",o.ElementInLoopBodyCallingOutsideLoop="element-in-loop-body-calling-outside-loop",o.CallerIsInHigherScope="caller-is-in-higher-scope",o.CallerIsInLowerScope="caller-is-in-lower-scope",o.CallIsInHigherScope="call-is-in-higher-scope",o.CallIsInLowerScope="call-is-in-lower-scope",o.OtherIncompatibleScopeReason="other-incompatible-scope-reason",o.SiblingInternalCallAlreadyUsedInParentVariable="sibling-internal-call-already-used-in-parent-variable",o.ErrorOututMapCannotBeConnectedToParentSuccessBranchCallees="error-output-map-cannot-be-connected-to-parent-success-branch-callees",o.SuccessOutputMapCannotBeConnectedToParentErrorBranchCallees="success-output-map-cannot-be-connected-to-parent-error-branch-callees",o))(TN||{});const Fbi=Object.values(TN);var vN=(o=>(o.NotPartOfOngoingTest="not-part-of-ongoing-test",o.CannotBeAddedToTest="cannot-be-added-to-test",o))(vN||{});const Sbi=Object.values(vN);var EN=(o=>(o.Suggestion="suggestion",o.CanvasGloballyDisabled="canvas-globally-disabled",o.CannotInteractWithInputInVariableWithInternalCalls="cannot-interact-with-input-in-variable-with-internal-calls",o.CannotInteractWithOutputInVariableWithInternalCalls="cannot-interact-with-output-in-variable-with-internal-calls",o.PropertyIsConstantItsValueCantBeReset="property-is-constant-its-value-cant-be-reset",o.CannotWriteValueOfGlobalVariableDeclaration="cannot-write-value-of-global-variable-declaration",o.CannotReSetValueOfConstantVariable="cannot-reset-value-of-constant-variable",o))(EN||{});const qbi=Object.values(EN);function Zbi(o,p){const i=[...o,...p];return Array.from(new Set(i))}function Hbi(o,p){const i=[...o,...p],n=Array.from(new Set(i));return{hasChanged:n.length!==o.length,reasons:n}}function Wbi(o,p){const i=o.filter(s=>!p.includes(s));return{hasChanged:i.length!==o.length,reasons:i}}function zbi(o,p){return o.find(i=>i.entity.id===p)||null}function B4(o){return o.filter((p,i)=>o.indexOf(p)===i)}class gn{constructor(p,i,n=null,s){I(this,"ids",[]);I(this,"entity");I(this,"entityCardHeight");I(this,"entityCardWidth");I(this,"index");I(this,"childEntities",[]);I(this,"children",[]);I(this,"parents",[]);I(this,"calculationEntryPoint");I(this,"_onlyEntities",null);I(this,"_changeSet",null);if(this.index=i,this.entity=p,this.calculationEntryPoint=n||this,this===this.calculationEntryPoint&&!s)throw new Error("Change set must be provided for the calculation entry point");this.calculateCardSize(),this.getSortedChildren()}static autoGenerateLayout(p,i,n){const s=DLe-rC-gLe,c=wLe-Wb-hN;p.metaSync({x:p.x||s,y:p.y||c},i);const e=new gn(p,0,null,i);e._onlyEntities=n||[],e.ids=["0"];const y=[];e.next(v=>{y.push(...v)}),gn.recursivelyAssembleChildrenAreas(y),e.resolveChildrenOverlaps();const m=e.flattenChildEntities();return e._onlyEntities?m.filter(v=>(e._onlyEntities||[]).includes(v)):m}static recursivelyAssembleChildrenAreas(p){const i=[];p.forEach(n=>{n.next(s=>{i.push(...s)})}),i.length>0&&gn.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(s=>s.entity===p);return i||this.children.reduce((s,c)=>s||c.findAreaInChildrenFromEntity(p),null)}findAreaFromEntity(p){if(this.entity===p)return this;const i=this.calculationEntryPoint.children,n=i.find(c=>c.entity===p);return n||i.reduce((c,e)=>c||e.findAreaInChildrenFromEntity(p),null)}addParent(p){if(!this.parents.includes(p)){const i=gn.resolveIds(p,this.index);this.ids.push(...i),this.parents.push(p)}}static resolveIds(p,i){return p?p.ids.map(n=>`${n}-${i}`):[`${i}`]}getSortedChildren(){if(this.entity.collapsed){this.childEntities=[];return}const p=Al(this.entity,!0);if(this.entity.type===d.Project){const i=[],n=[],s=[];p.forEach(e=>{if(d.DefinitionEntity===e.type){n.push(e);return}else if(Yt.includes(e.type)){s.push(e);return}i.push(e)});const c=i.sort((e,y)=>{const m=!!wA(e,y).length,v=Al(e),E=Al(y);return m?0:v.length&&!E.length?-1:!v.length&&E.length?1:0}).filter(e=>!Fp(e).length);this.childEntities=[...n,...s,...c]}else{const i=[],n=[],s=[],c=[],e=[];Zr.includes(this.entity.type)&&_R(this.entity).forEach(v=>{if(Gt.includes(v.type)){s.push(v);return}const E=li(v);i.push(E)}),nr.includes(this.entity.type)&&n.push(...this.entity.detachedChildren);const y=p.filter(m=>{const v=i.includes(m);return v||s.includes(m)||n.includes(m)?!1:Gt.includes(m.type)?(s.push(m),!1):qr.includes(m.type)&&!v?(c.push(m),!1):m.type===d.DefinitionEntity?(e.push(m),!1):!0});i.sort((m,v)=>Vc(m,v)?-1:0),c.sort((m,v)=>Vc(m,v)?-1:0),s.sort((m,v)=>vC(m,v)?1:vC(v,m)?-1:0),this.childEntities=[...e,...i,...c,...y,...s,...n]}}calculateCardSize(){const p=CLe(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 n=p.filter(c=>!i.includes(c));return n.reduce((c,e)=>i.includes(e)?c:gn.getBoundriesOfTwoAreas(c,e.fullBranchArea),n[0].fullBranchArea)}getFullAreaUntilAny(p){const i=this.ownEntityPlusBufferArea;return this.children.filter(e=>!p.includes(e)).map(e=>e.getFullAreaUntilAny(p)).reduce((e,y)=>gn.getBoundriesOfTwoAreas(e,y),i)}getFullAreaUntilAreaOrAnyChildren(p){const i=[p,...p.flattenChildren()],n=this.ownEntityPlusBufferArea;return this.children.filter(e=>i.includes(e)).map(e=>e.getFullAreaUntil(p)).reduce((e,y)=>gn.getBoundriesOfTwoAreas(e,y),n)}getFullAreaUntil(p){const i=this.ownEntityPlusBufferArea;return this.children.filter(c=>c!==p).map(c=>c.getFullAreaUntil(p)).reduce((c,e)=>gn.getBoundriesOfTwoAreas(c,e),i)}get fullBranchArea(){const p=this.ownEntityPlusBufferArea;return this.children.map(s=>s.fullBranchArea).reduce((s,c)=>gn.getBoundriesOfTwoAreas(s,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+Wb,right:p.right+rC}}static filterOutRepeatedAreas(p){return p.filter((i,n)=>p.indexOf(i)===n)}getEarliestId(p,i){const n=p.split("-"),s=i.split("-");return n.length<s.length?p:n.length>s.length?i:n.reduce((e,y,m)=>y<s[m]?p:i,p)}getEarliestLevel(){return this.ids.reduce((n,s)=>this.getEarliestId(n,s),this.ids[0]).split("-").length}countColumns(){let p=0;if(this!==this.calculationEntryPoint)p++;else return p;if(!this.parents.length)return p;const n=this.parents.reduce((s,c)=>c.getEarliestLevel()>s.getEarliestLevel()?c:s,this.parents[0]).countColumns();return p+=n,p}getLatestId(p,i){if(p===i)return p;const n=p.split("-"),s=i.split("-");return n.length<s.length?i:n.length>s.length?p:n.reduce((e,y,m)=>y>s[m]?p:i,p)}getLatestLevel(){return this.ids.length===1?this.ids[0].split("-").length:this.ids.reduce((n,s)=>this.getLatestId(n,s),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(n=>{n!==this.calculationEntryPoint&&n.shiftDownAlone(i)})}else if([...Yt].includes(this.entity.type)&&this.children.length)this.centerHeaderVerticallyOverCombinedAllChildrenHeaderHeight();else if(!this.children.length&&this.parents.length>1){const i=p.filter(n=>!this.parents.includes(n));i.length?i.every(s=>{const c=this.countColumns(),e=s.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 n=[...p,this];return this.children.forEach(s=>{if(gn.getEarliestParentInChain(s)!==this)return;const e=zbi(n,s.entity.id);n=gn.filterOutRepeatedAreas([...n]),e||(n=n.filter(m=>m!==s));const y=s.shiftDownUntilAny(n,i);n.push(...y)}),n}shiftRightUntilAny(p,i){p.includes(this)||(this.move(this.entity,{x:this.entity.x+i}),this.children.forEach(n=>{const s=gn.filterOutRepeatedAreas([...this.flattenSiblings(),...p]);gn.getEarliestParentInChain(n)===this&&n.shiftRightUntilAny(s,i)}))}shiftRight(p){this.move(this.entity,{x:this.entity.x+p}),this.children.forEach(i=>{const s=i.flattenSiblings().filter(c=>c!==i);i.shiftRightUntilAny(s,p)})}shiftDownAlone(p){this.move(this.entity,{y:this.entity.y+p})}centerHeaderVerticallyOverCombinedAllParentsHeaderHeight(){const p=this.parents.reduce((s,c)=>{const e=c.ownEntityArea,y=e.top+py,m={top:y,left:e.left,bottom:y,right:e.right};return gn.getBoundriesOfTwoAreas(s,m)},{top:1/0,left:1/0,bottom:-1/0,right:-1/0}),n=(p.bottom-p.top)/2-py;this.shiftDownAlone(n)}centerHeaderVerticallyOverCombinedAllChildrenHeaderHeight(){const p=this.children.reduce((s,c)=>{const e=c.ownEntityArea,y=e.top+py,m={top:y,left:e.left,bottom:y,right:e.right};return gn.getBoundriesOfTwoAreas(s,m)},{top:1/0,left:1/0,bottom:-1/0,right:-1/0}),n=(p.bottom-p.top)/2-py;return this.shiftDownAlone(n),n}resolveChildrenOverlaps(){const p=this.flattenChildren();let i=[];p.forEach(n=>{const s=n.adjustVerticallyToAvoidOverlaps();i.push(...s)}),p.forEach(n=>{n.smoothPosition()})}static getEarliestParentInChain(p){let i=p.parents[0];return p.parents.length&&(i=p.parents.sort((n,s)=>{if(!n.ids.length)return-1;if(!s.ids.length)return 1;const c=n.ids.sort((y,m)=>y.length<m.length?-1:0),e=s.ids.sort((y,m)=>y.length<m.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((n,s)=>{if(p.has(s.entity.id))return n;p.add(s.entity.id);const e=s.children.slice(0,s.children.indexOf(this)).reduce((y,m)=>[...y,m,...m.flattenChildren(p)],[]);return[...n,...e]},[])}flattenSiblings(p=new Set){return p.add(this.entity.id),this.parents.reduce((n,s)=>{if(p.has(s.entity.id))return n;p.add(s.entity.id);const e=s.children.filter(y=>y!==this).reduce((y,m)=>[...y,m,...m.flattenChildren(p)],[]);return[...n,...e]},[])}flattenChildren(p=new Set){return this.children.reduce((i,n)=>p.has(n.entity.id)?i:(p.add(n.entity.id),[...i,n,...n.flattenChildren(p)]),[])}flattenParents(p=new Set){return this.parents.reduce((n,s)=>p.has(s.entity.id)?n:(p.add(s.entity.id),[...n,s,...s.flattenParents(p)]),[])}getAreaIfRendered(p){return this.calculationEntryPoint.flattenChildren().find(s=>s.entity.id===p.id)||null}getLowerSiblings(){const p=this.parents.reduce((i,n)=>{const s=n.children.indexOf(this),c=n.children.slice(s+1);return[...i,...c]},[]);return B4(p)}getLowerAreas(){const p=this.getLowerSiblings(),i=this.parents.reduce((n,s)=>[...n,...s.getLowerAreas()],[]);return B4([...p,...i])}adjustVerticallyToAvoidOverlaps(p=[]){const n=gn.getEarliestParentInChain(this).children[this.index-1];if(!n)return p;const s=this.flattenEarlierSiblings(),c=this.flattenParents(),e=[...s,...c,n],v=D(e.flatMap(V=>wA(this.entity,V.entity))).filter(V=>V.id!==this.entity.id).map(V=>this.findAreaFromEntity(V)).filter(V=>!!V),E=this.getFullAreaUntilAny(v),b=n.getFullAreaUntilAny(v),w=e.reduce((V,$)=>$===this||$.fullBranchArea.left!==E.left?V:Math.max(V,$.fullBranchArea.bottom),b.bottom);if(E.top<w){const V=w-E.top+Wb;return this.shiftDownUntilAny(p,V)}return p}move(p,i){(this.onlyEntities||[]).includes(p)&&p.metaSync(i,this.changeSet)}addChild(p){const i=this.childEntities[p];let n=null;i.x&&i.y?n=this.getAreaIfRendered(i):!i.x&&!i.y&&this.move(i,{x:this.entity.x,y:this.entity.y}),n||(n=new gn(i,p,this.calculationEntryPoint));const s=this.ownEntityPlusBufferArea;this.children.includes(n)||(this.children.push(n),n.addParent(this));const c=n.fullBranchArea;if(c.left<s.right){const e=s.right-c.left;n.shiftRight(e)}return n}flattenChildEntities(p=new Set){return this.children.reduce((i,n)=>p.has(n.entity.id)?i:(p.add(n.entity.id),[...i,n.entity,...n.flattenChildEntities(p)]),[])}next(p){const i=[];this.childEntities.forEach((n,s)=>{const c=this.addChild(s);c&&i.push(c)}),p(i)}}var Nm=(o=>(o.Amazon="amazon",o.Google="google",o.Microsoft="microsoft",o))(Nm||{}),mr=(o=>(o.RelationalDatabase="relational-database",o.CompiledLocalCodebase="compiled-local-codebase",o.CloudHostedCodebase="cloud-hosted-codebase",o.HttpApi="http-api",o.HttpEndpoint="http-endpoint",o.ServerlessFunction="serverless-function",o))(mr||{}),nC=(o=>(o.Post="post",o.Get="get",o.Acknowledgement="acknowledgment",o.Progress="progress",o.Error="error",o.Complete="complete",o))(nC||{}),Tc=(o=>(o.Queued="queued",o.Running="running",o.Success="success",o.Failed="failed",o.CleanedUp="cleaned-up",o.Skipped="skipped",o.AbortedByUser="aborted-by-user",o.UnrecoverableFailure="unrecoverable-failure",o.Reverted="reverted",o.UnpublishingStarted="unpublishing-started",o.Unpublished="unpublished",o))(Tc||{}),aC=(o=>(o.Queued="queued",o.Running="running",o.Success="success",o.Failed="failed",o.CleanedUp="cleaned-up",o.UnrecoverableFailure="unrecoverable-failure",o.Reverted="reverted",o.UnpublishingStarted="unpublishing-started",o.Unpublished="unpublished",o))(aC||{}),Lt=(o=>(o.ProjectNotFound="project-not-found",o.ProjectPublishRequestAcknowledged="project-publish-request-acknowledged",o.PublicationStepFailedReasonUnknown="publication-step-failed-reason-unknown",o.DeploymentCompleted="deployment-completed",o.DeploymentStarted="deployment-started",o.DeploymentFailed="deployment-failed",o.AllInfrastructureSuccessfullyProvisioned="all-infrastucture-successfully-provisioned",o.RequestPayloadValidationFailed="request-payload-validation-failed",o.ProjectStateValidationFailedMissingName="project-state-validation-failed-missing-name",o.ProjectStateValidationFailedMissingAnyFunctionality="project-state-validation-failed-missing-any-functionality",o.ProjectAlreadyBeingPublished="project-already-being-published",o.BillingSubscriptionUpdateFailed="billing-subscription-update-failed",o.RelationalDatabaseDeploymentStarted="relational-database-deployment-started",o.RelationalDatabaseDeploymentCompleted="relational-database-deployment-completed",o.RelationalDatabaseDeploymentFailed="relational-database-deployment-failed",o.CreatingNewRelationalDatabase="creating-new-relational-database",o.WaitingForPreviousRelationalDatabaseDeployment="waiting-for-previous-relationa-database-deployment",o.RelationalDatabaseAlreadyExists="relational-database-already-exists",o.RelationalDatabaseDeletionStarted="relational-database-deletion-started",o.RelationalDatabaseDeletionCompleted="relational-database-deletion-completed",o.RelationalDatabaseDeletionFailed="relational-database-deletion-failed",o.WaitingForPreviousRelationalDatabaseDeletion="waiting-for-previous-relationa-database-deletion",o.HttpApiDeploymentStarted="http-api-deployment-started",o.HttpApiDeploymentCompleted="http-api-deployment-completed",o.HttpApiDeploymentFailed="http-api-deployment-failed",o.CreatingNewHttpApi="creating-new-http-api",o.HttpApiAlreadyExists="http-api-already-exists",o.HttpApiDeletionStarted="http-api-deletion-started",o.HttpApiDeletionCompleted="http-api-deletion-completed",o.HttpApiDeletionFailed="http-api-deletion-failed",o.WaitingForPreviousHttpApiDeletion="waiting-for-previous-http-api-deletion",o.BusinessLogicCodebaseDeploymentStarted="business-logic-codebase-deployment-started",o.BusinessLogicCodebaseDeploymentCompleted="business-logic-codebase-deployment-completed",o.BusinessLogicCodebaseDeploymentFailed="business-logic-codebase-deployment-failed",o.BundlingCodebaseForDownload="bundling-codebase-for-download",o.UploadingCodebaseToCloudStorage="uploading-codebase-to-cloud-storage",o.UploadingCodebaseToCloudStorageCompleted="uploading-codebase-to-cloud-storage-completed",o.UploadingCodebaseToCloudStorageFailed="uploading-codebase-to-cloud-storage-failed",o.InfrastructureValuesCodebaseInterpolationStarted="infrastructure-values-codebase-interpolation-started",o.InfrastructureValuesCodebaseInterpolationCompleted="infrastructure-values-codebase-interpolation-completed",o.InfrastructureValuesCodebaseInterpolationFailed="infrastructure-values-codebase-interpolation-failed",o.CodeCompilationStarted="code-compilation-started",o.CodeCompilationCompleted="code-compilation-completed",o.CodeCompilationFailed="code-compilation-failed",o.BundleCodebaseStarted="bundle-codebase-started",o.BundleCodebaseCompleted="bundle-codebase-completed",o.BundleCodebaseFailed="bundle-codebase-failed",o.InstallingCodebaseDependenciesStarted="installing-codebase-dependencies-started",o.InstallingCodebaseDependenciesCompleted="installing-codebase-dependencies-completed",o.InstallingCodebaseDependenciesFailed="installing-codebase-dependencies-failed",o.MigrateRelationalDatabaseStarted="migrate-relational-database-started",o.MigrateRelationalDatabaseCompleted="migrate-relational-database-completed",o.MigrateRelationalDatabaseFailed="migrate-relational-database-failed",o.ExecutePublicationCompletedEventStarted="execute-publication-completed-event-started",o.ExecutePublicationCompletedEventCompleted="execute-publication-completed-event-completed",o.ExecutePublicationCompletedEventFailed="execute-publication-completed-event-failed",o.ExecutePublicationCompletedEventTimedOut="execute-publication-completed-event-timed-out",o))(Lt||{}),ml=(o=>(o.CodeCompilation="code-compilation",o.RelationalDatabaseDeployment="relational-database-deployment",o.RelationalDatabaseDeletion="relational-database-deletion",o.HttpApiDeployment="http-api-deployment",o.HttpApiDeletion="http-api-deletion",o.InfrastructureValuesCodebaseInterpolation="infrastructure-values-codebase-interpolation",o.BundleCodebase="bundle-codebase",o.MigrateRelationalDatabase="migrate-relational-database",o.BusinessLogicCodebaseDeployment="business-logic-codebase-deployment",o.ExecutePublicationCompletedEvent="execute-publication-completed-event",o.CodebaseCleanup="codebase-cleanup",o))(ml||{});mr.CloudHostedCodebase,mr.HttpApi,mr.RelationalDatabase,mr.CloudHostedCodebase,mr.CloudHostedCodebase,mr.RelationalDatabase,mr.CloudHostedCodebase,mr.CloudHostedCodebase;function _Le(o){return`project-${o}-http-api`}function eR(o){return`entity-${o}-database`}class VLe{constructor(p,i,n,s,c,e,y,m,v){I(this,"stepType");I(this,"id");I(this,"resourceType");I(this,"index");I(this,"dependency",[]);I(this,"lastEvent",null);I(this,"lastEventTimestamp",null);I(this,"status",Tc.Queued);I(this,"publicationRun");I(this,"resource");this.stepType=p,this.id=i,this.resourceType=n,this.status=s,this.dependency=c,this.index=e,this.lastEventTimestamp=y,this.publicationRun=m,this.resource=v}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,n;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,(n=this.resource)==null||n.setDetails((i=p.resource)==null?void 0:i.details)}}var PLe=(o=>(o.Ready="ready",o.Provisioning="provisioning",o.Queued="queued",o.ProvisioningFailed="provisioning-failed",o.Deleting="deleting",o.DeletingFailed="deleting-failed",o.Deleted="deleted",o))(PLe||{});class rf{constructor(p,i,n){I(this,"provisionedBy");I(this,"publicationRun");I(this,"resourceType");I(this,"provider");I(this,"resourceId");I(this,"details",null);I(this,"name",null);I(this,"status","queued");this.publicationRun=p,this.resourceType=i,this.provider=n}setDetails(p){this.details=p}setStatus(p){this.status=p}setProvisionedBy(p){this.provisionedBy=p}}class Jbi extends rf{constructor(i,n,s){super(i,mr.HttpEndpoint,s);I(this,"resourceType",mr.HttpEndpoint);I(this,"owners",new Map);I(this,"details",null);I(this,"status","queued");n.forEach(c=>{this.owners.set(c.id,c)}),this.resolveDeterministicResourceId()}resolveDeterministicResourceId(){var i,n;return this.resourceId=eR((n=(i=Array.from(this.owners.values()))==null?void 0:i[0])==null?void 0:n.id),this.resourceId}}class Ybi extends rf{constructor(i,n,s){super(i,mr.ServerlessFunction,s);I(this,"resourceType",mr.ServerlessFunction);I(this,"owners",new Map);I(this,"details",null);I(this,"status","queued");n.forEach(c=>{this.owners.set(c.id,c)}),this.resolveDeterministicResourceId()}resolveDeterministicResourceId(){var i,n;return this.resourceId=eR((n=(i=Array.from(this.owners.values()))==null?void 0:i[0])==null?void 0:n.id),this.resourceId}}class NLe extends rf{constructor(i,n,s){super(i,mr.HttpApi,s);I(this,"resourceType",mr.HttpApi);I(this,"owners",new Map);I(this,"details",null);I(this,"status","queued");n.forEach(c=>{this.owners.set(c.id,c)}),this.resolveDeterministicResourceId()}resolveDeterministicResourceId(){return this.resourceId=_Le(this.publicationRun.project.id),this.resourceId}}class xLe extends rf{constructor(i,n,s){super(i,mr.RelationalDatabase,s);I(this,"resourceType",mr.RelationalDatabase);I(this,"owners",new Map);I(this,"details",null);I(this,"status","queued");n.forEach(c=>{this.owners.set(c.id,c)}),this.resolveDeterministicResourceId()}resolveDeterministicResourceId(){var i,n;return this.resourceId=eR((n=(i=Array.from(this.owners.values()))==null?void 0:i[0])==null?void 0:n.id),this.resourceId}}class $Le extends rf{constructor(i,n){super(i,mr.CloudHostedCodebase,n);I(this,"resourceType",mr.CloudHostedCodebase);I(this,"details",null);I(this,"status","queued");this.resolveDeterministicResourceId()}resolveDeterministicResourceId(){return this.resourceId=`cloud-hosted-codebase--${this.publicationRun.project.id}--${this.publicationRun.project.version}`,this.resourceId}}class LLe extends rf{constructor(i,n){super(i,mr.CompiledLocalCodebase,n);I(this,"resourceType",mr.CompiledLocalCodebase);I(this,"details",null);I(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 Xbi{constructor(p,i){I(this,"id");I(this,"projectAutoIncrementPublicationCount");I(this,"projectPublishedSemanticVersion");I(this,"projectVersion");I(this,"projectId");I(this,"triggeredBy");I(this,"createdAt");I(this,"updatedAt");I(this,"status");I(this,"steps",[]);I(this,"editor");I(this,"explicitResources",new Map);I(this,"implicitGlobalResources",new Map);I(this,"finalGlobalEvent",null);I(this,"finalStatus",null);I(this,"contextType",X.PublicationRun);I(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(n=>n.owners.has(p.id));return i||null}async init(){await this.initResources()}async initResources(){this.implicitGlobalResources.set(mr.CompiledLocalCodebase,new LLe(this,Nm.Amazon)),this.implicitGlobalResources.set(mr.CloudHostedCodebase,new $Le(this,Nm.Amazon));const p=this.project.entities.filter(n=>Wi(n,Re.HTTP_ENDPOINT)),i=this.project.entities.filter(n=>Wi(n,Re.RELATIONAL_DATABASE));if(i.length&&i.forEach(n=>{const s=new xLe(this,[n],Nm.Amazon);this.explicitResources.set(s.resourceId,s)}),p.length){const n=new NLe(this,p,Nm.Amazon);this.explicitResources.set(n.resourceId,n)}}setSteps(p,i){p.forEach(n=>{this.addStep(n,i)}),this.editor.events.emit(Lt.ProjectPublishRequestAcknowledged,{})}addStep(p,i){const n=p.dependency||[];if(n.length){const c=n.filter(e=>!this.steps.find(y=>y.id===e));if(c.length)throw new Error(`Missing dependencies: ${c.join(", ")}`)}if(!this.steps.find(c=>c.id===p.id)){const c=new VLe(p.stepType,p.id,p.resourceType,p.status,n,p.index,i,this,null);this.steps.push(c)}}onUpdate(p){var i;if(J.Logger.log("onUpdate",p),(i=p.payload)!=null&&i.stepType){const n=this.steps.find(s=>{var c;return s.id===((c=p.payload)==null?void 0:c.id)});n&&M(p.emittedAt).isAfter(M(n.lastEventTimestamp))&&n.update(p.payload)}this.editor.events.emit("publication-updated",{}),p.type===nC.Error?(this.finalStatus=aC.Failed,this.finalGlobalEvent=p.event,this.editor.events.emit("project-publication-error",p)):p.type===nC.Complete&&(this.finalStatus=aC.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 dN(this.editor.events),await this.extensionsRegistry.setup(),this.extensionsRegistry.onResolvePublicationRunContext(()=>this),await this.extensionsRegistry.contextAvailable(X.PublicationRun),this.extensionsRegistry}}function Qbi(o){switch(o){case ml.CodeCompilation:return"Code generation";case ml.RelationalDatabaseDeployment:return"Database creation";case ml.HttpApiDeployment:return"HTTP gateway creation";case ml.InfrastructureValuesCodebaseInterpolation:return"Link code with resources";case ml.BundleCodebase:return"Bundle code";case ml.MigrateRelationalDatabase:return"Database structure migration";case ml.BusinessLogicCodebaseDeployment:return"Update servers with new code";case ml.CodebaseCleanup:return"Code cleanup";case ml.HttpApiDeletion:return"HTTP gateway deletion";case ml.RelationalDatabaseDeletion:return"Database deletion";default:return"Publication finished"}}function eAi(o){switch(o){case Lt.DeploymentCompleted:return"Successfully published";case Lt.DeploymentStarted:return"Publication started";case Lt.DeploymentFailed:return"Publication failed";case Lt.AllInfrastructureSuccessfullyProvisioned:return"All infrastructure successfully provisioned";case Lt.RequestPayloadValidationFailed:return"Request payload validation failed";case Lt.ProjectStateValidationFailedMissingName:return"Project state validation failed: missing name";case Lt.ProjectStateValidationFailedMissingAnyFunctionality:return"Project state validation failed: missing any functionality";case Lt.RelationalDatabaseDeploymentStarted:return"Database creation started";case Lt.RelationalDatabaseDeploymentCompleted:return"Database creation completed";case Lt.RelationalDatabaseDeploymentFailed:return"Database creation failed";case Lt.CreatingNewRelationalDatabase:return"Creating new database (up to 5 mins)";case Lt.WaitingForPreviousRelationalDatabaseDeployment:return"Waiting for previous database creation";case Lt.RelationalDatabaseAlreadyExists:return"Database already exists";case Lt.HttpApiDeploymentStarted:return"HTTP gateway creation started";case Lt.HttpApiDeploymentCompleted:return"HTTP gateway creation completed";case Lt.HttpApiDeploymentFailed:return"HTTP gateway creation failed";case Lt.CreatingNewHttpApi:return"Creating new HTTP gateway";case Lt.HttpApiAlreadyExists:return"HTTP gateway already exists";case Lt.BusinessLogicCodebaseDeploymentStarted:return"Update servers with new code started";case Lt.BusinessLogicCodebaseDeploymentCompleted:return"Update servers with new code completed";case Lt.BusinessLogicCodebaseDeploymentFailed:return"Update servers with new code failed";case Lt.BundlingCodebaseForDownload:return"Bundling code for download";case Lt.UploadingCodebaseToCloudStorage:return"Uploading code to cloud storage";case Lt.InfrastructureValuesCodebaseInterpolationStarted:return"Linking code with resources started";case Lt.InfrastructureValuesCodebaseInterpolationCompleted:return"Linking code with resources completed";case Lt.InfrastructureValuesCodebaseInterpolationFailed:return"Linking code with resources failed";case Lt.CodeCompilationStarted:return"Code generation started";case Lt.CodeCompilationCompleted:return"Code generation completed";case Lt.CodeCompilationFailed:return"Code generation failed";case Lt.BundleCodebaseStarted:return"Code bundling started";case Lt.BundleCodebaseCompleted:return"Code bundling completed";case Lt.BundleCodebaseFailed:return"Code bundling failed";case Lt.InstallingCodebaseDependenciesStarted:return"Installing code dependencies";case Lt.InstallingCodebaseDependenciesCompleted:return"Installing code dependencies completed";case Lt.InstallingCodebaseDependenciesFailed:return"Installing code dependencies failed";case Lt.MigrateRelationalDatabaseStarted:return"Database structure migration started";case Lt.MigrateRelationalDatabaseCompleted:return"Database structure migration completed";case Lt.MigrateRelationalDatabaseFailed:return"Database structure migration failed";case Lt.ProjectAlreadyBeingPublished:return"Project already being published. You need to wait for the previous publication to complete";case Lt.ProjectPublishRequestAcknowledged:return"Project publish request acknowledged";case Lt.UploadingCodebaseToCloudStorageCompleted:return"Uploading code to cloud storage completed";case Lt.UploadingCodebaseToCloudStorageFailed:return"Uploading code to cloud storage failed";case Lt.BillingSubscriptionUpdateFailed:return"Billing subscription update failed";case Lt.ProjectNotFound:return"Project not found";case Lt.HttpApiDeletionCompleted:return"HTTP gateway deletion completed";case Lt.HttpApiDeletionFailed:return"HTTP gateway deletion failed";case Lt.HttpApiDeletionStarted:return"HTTP gateway deletion started";case Lt.PublicationStepFailedReasonUnknown:return"Publication step failed: reason unknown";case Lt.WaitingForPreviousHttpApiDeletion:return"Waiting for previous HTTP gateway deletion";case Lt.RelationalDatabaseDeletionStarted:return"Database deletion started";case Lt.RelationalDatabaseDeletionCompleted:return"Database deletion completed";case Lt.RelationalDatabaseDeletionFailed:return"Database deletion failed";case Lt.WaitingForPreviousRelationalDatabaseDeletion:return"Waiting for previous database deletion"}return"Unknown event"}var MLe=(o=>(o.NO_LOGIC="NO_LOGIC",o.NO_NAME="NO_NAME",o.NO_CHANGES="NO_CHANGES",o.PROJECT_PUBLICATION_ALREADY_ONGOING="PROJECT_PUBLICATION_ALREADY_ONGOING",o))(MLe||{});function tAi(o){switch(o){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 iAi(o){switch(o){case mr.RelationalDatabase:return"Relational database";case mr.HttpEndpoint:case mr.HttpApi:return"HTTP endpoints";case mr.ServerlessFunction:case mr.CloudHostedCodebase:return"Server code functions";default:return"Resources"}}function rAi(o){switch(o){case Tc.Running:return"In progress";case Tc.Failed:return"Failed";case Tc.Success:return"Succeeded";case Tc.Skipped:return"Skipped";case Tc.Queued:default:return"Queued"}}function BLe(o){var n;if(!Wi(o,Re.EXTERNAL_INTEGRATION_CONNECTION))return null;let p=null;const i=Q["built-in-base-entity"].BUILT_IN_EXTERNAL_INTEGRATION_CONNECTION_ENTITY.properties.integration.id;if(o.type===d.BuiltInBaseEntity?Wi(o,Re.EXTERNAL_INTEGRATION_CONNECTION)&&(p=sC(o.name)):o.type===d.DefinitionEntity&&o.implements.forEach(s=>{if(Wi(s,Re.EXTERNAL_INTEGRATION_CONNECTION)){const c=sC(s==null?void 0:s.name);if(c)return p=c,!0}}),!p){const s=o.properties.find(c=>!!c.implements.find(e=>e.id===i)||!!c.implements.find(e=>{var y;return((y=e.extends)==null?void 0:y.id)===i}));p=(n=s==null?void 0:s.getDefaultValue())==null?void 0:n.value}return p}function nAi(o){return yhe[o]}function sC(o){return o.includes("BUILT_IN_EXTERNAL_INTEGRATION_CONNECTION_")?o.replace("BUILT_IN_EXTERNAL_INTEGRATION_CONNECTION_","").toLocaleLowerCase().replace("_auth",""):null}function GLe(o){if(o.type!==d.ActionDescriptor&&o.type!==d.Operation)throw new Error("Only ActionDescriptorState or OperationState can be used to resolve an external integration ID");if(o.type===d.ActionDescriptor){const p=o;if(p.id.startsWith("external-integration--"))return p.id.split("--")[1]}if(o.type===d.Operation){const p=o.declaration;if(Object.values(ei).includes(p.id))return p.id.split("--")[1]||null}return null}function aAi(o){if(!o)throw new Error("The integrationName parameter is required to resolve the base built-in name.");return Object.values(Re).find(i=>!!(i.startsWith("BUILT_IN_EXTERNAL_INTEGRATION_CONNECTION_")&&i.endsWith("_AUTH")&&i.replace("BUILT_IN_EXTERNAL_INTEGRATION_CONNECTION_","").replace("_AUTH","").toLowerCase()===o.toLowerCase()))||null}function sAi(o){return o.type===d.BuiltInBaseEntity||o.type===d.DefinitionEntity?BLe(o):o.type===d.ActionDescriptor||o.type===d.Operation?GLe(o):null}function kLe(o){var s,c,e;if(!Wi(o,Re.EXTERNAL_INTEGRATION_CONNECTION))return null;let p=null;const i=J4e(o,Re.EXTERNAL_INTEGRATION_CONNECTION);if(!i)return null;const n=Q["built-in-base-entity"][i.id].properties.connectionId.id;if(o.type===d.BuiltInBaseEntity){if(Wi(o,Re.EXTERNAL_INTEGRATION_CONNECTION)){const y=o.properties.find(m=>{var v;return((v=m.extends)==null?void 0:v.id)===n});y&&(p=(s=y.getDefaultValue())==null?void 0:s.value)}}else if(o.type===d.DefinitionEntity){const y=o.properties.find(m=>!!m.implements.find(v=>v.id===n)||!!m.implements.find(v=>{var E;return((E=v.extends)==null?void 0:E.id)===n}));if(!y&&((c=o.extends)==null?void 0:c.type)===d.DefinitionEntity)return kLe(o.extends);p=(e=y==null?void 0:y.getDefaultValue())==null?void 0:e.value}return p}async function jLe(o,p={}){var y;const i=J.YieldTracker.from(p),s=[...ta(o),...Rs(o),...bN(o),...ia(o),...AN(o)],c=Cv(o);s.push(...c);const e=Mt(o.errors,s);await i.tick();for(const m of o.inputs)await m.validateAsync({tracker:i});for(const m of o.outputs)await m.validateAsync({tracker:i});for(const m of o.internalCalls)await m.validateAsync({tracker:i});return await((y=o.dataType)==null?void 0:y.validateAsync({tracker:i})),e}function ULe(o){var s;(s=o.dataType)==null||s.validate(),o.inputs.forEach(c=>c.validate()),o.outputs.forEach(c=>c.validate()),o.internalCalls.forEach(c=>c.validate());const i=[...ta(o),...Rs(o),...bN(o),...ia(o),...AN(o)],n=Cv(o);return i.push(...n),Mt(o.errors,i)}function bN(o,p){const n=[...o.project.getVariableDeclarations()].filter(s=>s.id!==o.id);return Vv(o,[Hi],n,p)}function AN(o){const p=[];if(o.parent!==o.project)return p;if(o.catchesError){const i=Ot({id:`${o.id}--${Ie.GlobalVariableDeclarationCannotCatchError}`,message:`${as[o.type].singular} "${se(o,o.project)}" with id "${o.id}" cannot catch an error because it is globally declared. Global variable declarations must crash the project if an error occurs.`,severity:ce.Error,code:Ie.GlobalVariableDeclarationCannotCatchError,entity:o});p.push(i.error)}if(o.errorCalls.length){const i=Ot({id:`${o.id}--${Ie.GlobalVariableDeclarationCannotCallOnError}`,message:`${as[o.type].singular} "${se(o,o.project)}" with id "${o.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:ce.Error,code:Ie.GlobalVariableDeclarationCannotCallOnError,entity:o});p.push(i.error)}if(o.calledBy.length){const i=Ot({id:`${o.id}--${Ie.GlobalVariableDeclarationCannotBeCalled}`,message:`${as[o.type].singular} "${se(o,o.project)}" with id "${o.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:ce.Error,code:Ie.GlobalVariableDeclarationCannotBeCalled,entity:o});p.push(i.error)}return[]}const lAi=Object.freeze(Object.defineProperty({__proto__:null,validate:ULe,validateAsync:jLe,validateGlobalVariableDeclaration:AN,validateVariableDeclarationName:bN},Symbol.toStringTag,{value:"Module"}));async function KLe(o,p={}){const i=J.YieldTracker.from(p),s=[...ta(o),...Rs(o),...ia(o)],c=Cv(o);s.push(...c);const e=Mt(o.errors,s);await i.tick();for(const y of o.inputs)await y.validateAsync({tracker:i});for(const y of o.outputs)await y.validateAsync({tracker:i});for(const y of o.internalCalls)await y.validateAsync({tracker:i});return e}function FLe(o){o.inputs.forEach(s=>s.validate()),o.outputs.forEach(s=>s.validate()),o.internalCalls.forEach(s=>s.validate());const i=[...ta(o),...Rs(o),...ia(o)],n=Cv(o);return i.push(...n),Mt(o.errors,i)}function oAi(o){const p=[],i=o.declaration.constant;if(i&&o.readsValue){const n=Ot({id:`${o.id}--${he.ValueReadingOverridesConstantVariable}`,message:`The '${o.type}' entity "${se(o,o.project)}" with id "${o.id}" is a constant variable whose value cannot be overriden, but reads a value.`,severity:ce.Error,code:he.ValueReadingOverridesConstantVariable,entity:o});p.push(n.error)}if(i&&o.defaultValue){const n=Ot({id:`${o.id}--${he.DefaultValueOverridesConstantVariable}`,message:`The '${o.type}' entity "${se(o,o.project)}" with id "${o.id}" is a constant variable whose value cannot be overridden, but has a 'defaultValue'.`,severity:ce.Error,code:he.DefaultValueOverridesConstantVariable,entity:o});p.push(n.error)}return p}const dAi=Object.freeze(Object.defineProperty({__proto__:null,validate:FLe,validateAsync:KLe,validateConstantValueOverride:oAi},Symbol.toStringTag,{value:"Module"}));var gN=(o=>(o.Parent="parent",o.DataTypeEntity="data-type-entity",o.VarDeclaration="var-declaration",o))(gN||{});const hi=class hi extends Ur{constructor(i,n){super(i);I(this,"initialData");I(this,"id");I(this,"x");I(this,"y");I(this,"type",d.VariableInstance);I(this,"catchesError",!1);I(this,"defaultValue",null);I(this,"writesValues",[]);I(this,"readsValue",null);I(this,"declaration");I(this,"inputs",[]);I(this,"outputs",[]);I(this,"error",null);I(this,"calledBySuccess",[]);I(this,"calledByError",[]);I(this,"calledByEntry",[]);I(this,"successCalls",[]);I(this,"errorCalls",[]);I(this,"internalCalls",[]);I(this,"project");I(this,"errors",[]);I(this,"parent");I(this,"detachedDependents",{});I(this,"knownVersions",null);I(this,"activeVersion",!1);I(this,"initialized",!1);I(this,"startedInitialization",!1);I(this,"suggestion",!1);I(this,"_codeNativeValueValidation",null);this.initialData=i,this.project=n,this.id=i.id,this.x=i.x,this.y=i.y,this.catchesError=i.catchesError||!1}static new(i=null){return{id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||M().toISOString(),author:(i==null?void 0:i.author)||x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.VariableInstance,catchesError:!1,declaration:null,internalCalls:[],successCalls:[],errorCalls:[],readsValue:null,writesValues:[],defaultValue:null,inputs:[],outputs:[],parent:null,calledByEntry:[],calledBySuccess:[],calledByError:[],error:null,x:0,y:0}}static fromGenerationTarget(i,n){let s=n;if(i.parent){const V=ne(i.parent);s=n.get(V)}const c=ne(i.declaration),e=n.get(c),y=i.calledByEntry.map(V=>{const $=ne(V);return n.get($)}),m=i.calledBySuccess.map(V=>{const $=ne(V);return n.get($)}),v=i.calledByError.map(V=>{const $=ne(V);return n.get($)});let E=null;if(i.readsValue){const V=ne(i.readsValue);E=n.get(V)}const b={id:i.id,version:x.UUID.uuid(),createdAt:M().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.VariableInstance,catchesError:i.catchesError||!1,declaration:e.toReference(),calledByEntry:y,calledBySuccess:m,calledByError:v,defaultValue:null,errorCalls:[],successCalls:[],internalCalls:[],readsValue:E,inputs:[],outputs:[],writesValues:[],error:null,x:0,y:0,parent:s},w=me(b,n);return w.setParent(s,null),w}static validateGenerationTarget(i,n){let s=JSON.parse(JSON.stringify(i));const c=[],e=bn(s,{parent:{list:!1,types:[...nr,d.Project],optional:!0},declaration:{list:!1,types:[d.VariableDeclaration]}},n);return s=e.modifiedData,c.push(...e.errors,...$r(s)),{errors:c,modifiedData:s}}get codeName(){var i;return(i=this.declaration)==null?void 0:i.codeName}get codeNativeValueValidation(){var i;return this._codeNativeValueValidation||((i=this.declaration)==null?void 0:i.codeNativeValueValidation)||null}validateGeneratedUpdate(i){const n=[];let s=JSON.parse(JSON.stringify(i));const c=sf(s,this);return s=c.modifiedData,n.push(...c.errors),i.parent&&n.push(new De({id:`${this.id}--${ae.InvalidParentUpdate}`,code:ae.InvalidParentUpdate,severity:ce.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated. The 'parent' on a callable entity, is its scope. It scope is auto-calculated implicitly by the its caller.
|
|
93
93
|
If an entity is called by another, they must be in the same scope, which means they have the same parent.
|
|
94
94
|
Specifically for variables, their scope is also calculated from their value readers and value writters.
|
|
95
|
-
You shouldn't have to manually update a 'parent' property. The equivalent result is to change its value readers, value writters, or callers.`})),{errors:n,modifiedData:s}}subscribeDependents(i){return i.forEach(n=>{this.detachedDependents[n.entity.id]||(this.detachedDependents[n.entity.id]=n)}),this}unsubscribeDependents(i){return i.forEach(n=>{this.detachedDependents[n.entity.id]&&delete this.detachedDependents[n.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"sync-dependents"))){const n=[],s=[],c=[],e=[];return Object.values(this.detachedDependents).forEach(y=>{const m=y.entity.afterAllChildrenInitialized(i);n.push(...m.updated),s.push(...m.added),c.push(...m.removed),e.push(...m.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}onDetachedDependencyRemoved(i,n,s){const c=[],e=[],y=[],m=[];if(n==="parent"){const{updated:v,added:E,removed:b}=this.remove({ignoreUpstream:!1},s);c.push(...v),e.push(...E),y.push(...b)}if(n==="var-declaration"){const{updated:v,added:E,removed:b}=this.remove({ignoreUpstream:!1},s);c.push(...v),e.push(...E),y.push(...b)}return{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:this}}onDetachedDependencyRestored(i,n,s){const c=[],e=[],y=[],m=[];if(n==="parent"){const{updated:v,added:E,removed:b}=this.restore({},s);c.push(...v),e.push(...E),y.push(...b)}if(n==="var-declaration"){const{updated:v,added:E,removed:b}=this.restore({},s);c.push(...v),e.push(...E),y.push(...b)}return{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:this}}unsubscribeFromDependencies(){var i,n,s,c,e,y,m;return(n=(i=this.parent)==null?void 0:i.unsubscribeDependents)==null||n.call(i,[{entity:this,field:"parent"}]),(e=(c=(s=this.declaration.dataType)==null?void 0:s.entity)==null?void 0:c.unsubscribeDependents)==null||e.call(c,[{entity:this,field:"data-type-entity"}]),(m=(y=this.declaration)==null?void 0:y.unsubscribeDependents)==null||m.call(y,[{entity:this,field:"var-declaration"}]),this}subscribeToDependencies(){var i,n,s,c;return(i=this.parent)==null||i.subscribeDependents([{entity:this,field:"parent"}]),(c=(s=(n=this.declaration.dataType)==null?void 0:n.entity)==null?void 0:s.subscribeDependents)==null||c.call(s,[{entity:this,field:"data-type-entity"}]),this.declaration.subscribeDependents([{entity:this,field:"var-declaration"}]),this}increaseVersion(i){if(i&&!M(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&M(i).isSame(M(this.createdAt))?this:(this.previousVersion=this.version,this.version=x.UUID.uuid(),this.createdAt=M(i).toISOString()||M().toISOString(),this)}captureVersion(){var n;const i=((n=this.knownVersions)==null?void 0:n.get(this.version))||new hi(this,this.project);return i.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map([[this.version,i]]),i.inputs=[...this.inputs],i.outputs=[...this.outputs],i.internalCalls=[...this.internalCalls],i.successCalls=[...this.successCalls],i.errorCalls=[...this.errorCalls],i.writesValues=[...this.writesValues],i.readsValue=this.readsValue,i.defaultValue=this.defaultValue,i.declaration=this.declaration,i.calledBySuccess=[...this.calledBySuccess],i.calledByError=[...this.calledByError],i.calledByEntry=[...this.calledByEntry],i.error=this.error,i.parent=this.parent,this}recursiveCaptureUpstreamVersions(i){const n=[],s=[],c=[],e=[];if(this.parent){this.parent.increaseVersion(i);const y=this.parent.recursiveCaptureUpstreamVersions(i);n.push(this.parent,...y.updated),s.push(...y.added),c.push(...y.removed)}return{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}async restoreVersion(i){var m;const n=[],s=[],c=[],e=[];if(this.version===i)return{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this};if(!this.knownVersions){const v=new Map;for(const[E,b]of this.knownVersions||new Map){if(v.set(E,b),b.activeVersion=!1,b.knownVersions)for(const[w,V]of b.knownVersions)v.set(w,V);b.knownVersions=null}}let y=(m=this.knownVersions)==null?void 0:m.get(i);if(!y){const v=await this.APILoadVersion({},i);if(!v)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);y=new hi(v,this.project)}return this.metaSync(y.toShallowJSON(),null),this.previousVersion=y.previousVersion,this.version=y.version,this.createdAt=y.createdAt,this.author=y.author,this.deleted=y.deleted,this.inputs=y.inputs,this.outputs=y.outputs,this.internalCalls=y.internalCalls,this.successCalls=y.successCalls,this.errorCalls=y.errorCalls,this.writesValues=y.writesValues,this.readsValue=y.readsValue,this.defaultValue=y.defaultValue,this.declaration=y.declaration,this.calledBySuccess=y.calledBySuccess,this.calledByError=y.calledByError,this.calledByEntry=y.calledByEntry,this.error=y.error,this.parent=y.parent,{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}updateWithShallowTransfer(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.UpdateWithShallowTransfer))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[updateWithShallowTransfer] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),this;if(this.metaSync(i,n),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 s=ne(i.parent),c=this.project.get(s),e=this.parent;if(e&&e.id!==(c==null?void 0:c.id)&&this.removeFromParent(n),c)this.setParent(c,n),this.addSelfToProject(n);else throw n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${s}' that isn't found in the project`)}else throw n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(i.readsValue){const s=ne(i.readsValue),c=this.project.get(s),e=this.readsValue;e&&e.id!==(c==null?void 0:c.id)&&this.removeValueWriter(n),c&&this.setValueWriter(c,n)}else this.removeValueWriter(n);if(i.declaration){const s=ne(i.declaration),c=this.project.get(s);c&&this.setDeclaration(c)}if(i.calledByEntry.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addEntryCaller(e,n),e.addCall(this,n))}),[...this.calledByEntry].forEach(s=>{i.calledByEntry.find(e=>ne(e)===s.id)||(this.removeCaller(s,n),s.removeCall(this,n))}),i.calledBySuccess.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addSuccessCaller(e,n),e.addSuccessCall(this,n))}),[...this.calledBySuccess].forEach(s=>{i.calledBySuccess.find(e=>ne(e)===s.id)||(this.removeCaller(s,n),s.removeCall(this,n))}),i.calledByError.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addErrorCaller(e,n),e.addErrorCall(this,n))}),[...this.calledByError].forEach(s=>{i.calledByError.find(e=>ne(e)===s.id)||(this.removeCaller(s,n),s.removeCall(this,n))}),i.outputs.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addOutput(e,n),e.setParent(this,n))}),[...this.outputs].forEach(s=>{i.outputs.find(e=>ne(e)===s.id)||(this.removeOutput(s,n),s.removeFromParent(n))}),i.inputs.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addInput(e,n),e.setParent(this,n))}),[...this.inputs].forEach(s=>{i.inputs.find(e=>ne(e)===s.id)||(this.removeInput(s,n),s.removeFromParent(n))}),i.defaultValue){const s=ne(i.defaultValue),c=this.project.get(s);c&&this.setDefaultValue(c,n)}else this.setDefaultValue(null,n);return i.writesValues.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addValueReader(e,n),e.setValueWriter(this,n))}),[...this.writesValues].forEach(s=>{i.writesValues.find(e=>ne(e)===s.id)||(this.removeValueReader(s,n),s.setValueWriter(null,n))}),this.captureVersion(),this.subscribeToDependencies(),n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),this}hydrateAncestors(){const i=[],n=[],s=[],c=[];if(this.initialData.parent){const e=ne(this.initialData.parent),y=this.project.get(e);if(y)this.setParent(y,null),i.push(y);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.readsValue){const e=ne(this.initialData.readsValue),y=this.project.get(e);y&&(this.setValueWriter(y,null),i.push(y))}if(this.initialData.declaration){const e=ne(this.initialData.declaration),y=this.project.get(e);y&&(this.setDeclaration(y),i.push(y))}return this.initialData.calledByEntry.forEach(e=>{const y=ne(e),m=this.project.get(y);m&&this.addEntryCaller(m,null)}),this.initialData.calledBySuccess.forEach(e=>{const y=ne(e),m=this.project.get(y);m&&this.addSuccessCaller(m,null)}),this.initialData.calledByError.forEach(e=>{const y=ne(e),m=this.project.get(y);m&&this.addErrorCaller(m,null)}),{updated:D(i),added:D(n),removed:D(s),affected:D(c),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AfterAllChildrenInitialized))){var Ne;if(!this.checkCanEdit(this,i))return J.Logger.warn(`[afterAllChildrenInitialized] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.AfterAllChildrenInitialized,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];if(this.initialized=!0,!this.declaration.dataType||(Ne=this.declaration.dataType)!=null&&Ne.inferred){const{added:Be,updated:Se,removed:je,affected:Ze}=this.declaration.inferDataTypeAndSyncInstancesInputsAndOutputs(i);s.push(...Be),n.push(...Se),c.push(...je),e.push(...Ze)}const{added:y,updated:m,removed:v,affected:E}=this.syncInputs(i);s.push(...y),n.push(...m),c.push(...v),e.push(...E);const{added:b,updated:w,removed:V,affected:$}=this.syncOutputs(i);s.push(...b),n.push(...w),c.push(...V),e.push(...$);const{added:L,updated:k,removed:K,affected:S}=this.generateUnusedInternalCalls(i);s.push(...L),n.push(...k),c.push(...K),e.push(...S);const{added:Y,updated:re,removed:ee,affected:de}=this.removeUnrecognizedInputs(i);s.push(...Y),n.push(...re),c.push(...ee),e.push(...de);const{added:le,updated:fe,removed:ve,affected:ue}=this.removeUnrecognizedOutputs(i);s.push(...le),n.push(...fe),c.push(...ve),e.push(...ue);const{added:ye,updated:Ve,removed:_e,affected:$e}=this.removeUnrecognizedInternalCalls(i);return s.push(...ye),n.push(...Ve),c.push(..._e),e.push(...$e),this.inputs.sort((Be,Se)=>{var je,Ze;return(Be.index??((je=Be.declaration)==null?void 0:je.index))-(Se.index??((Ze=Se.declaration)==null?void 0:Ze.index))}),this.outputs.sort((Be,Se)=>{var je,Ze;return(Be.index??((je=Be.declaration)==null?void 0:je.index))-(Se.index??((Ze=Se.declaration)==null?void 0:Ze.index))}),this.declaration.constant&&this.readsValue&&(this.readsValue.removeValueReader(this,i),this.removeValueWriter(i)),this.declaration.constant&&this.defaultValue&&this.defaultValue.remove({ignoreUpstream:!1},i),this.captureVersion(),i==null||i.attemptAutoclose(_.AfterAllChildrenInitialized,this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}addSelfToProject(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"add-self-to-project"))){const n=[this],s=[],c=[],e=[];return this.parent===this.project&&this.project.addVariableInstance(this),this.readsValue&&(this.readsValue.addValueReader(this,i),n.push(this.readsValue)),this.writesValues.forEach(y=>{y.setValueWriter(this,i),n.push(y)}),this.successCalls.forEach(y=>{y.addSuccessCaller(this,i),n.push(y)}),this.errorCalls.forEach(y=>{y.addErrorCaller(this,i),n.push(y)}),this.calledBySuccess.forEach(y=>{y.addSuccessCall(this,i),n.push(y)}),this.calledByError.forEach(y=>{y.addErrorCall(this,i),n.push(y)}),this.calledByEntry.forEach(y=>{y.addCall(this,i),n.push(y)}),this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}get usedInputs(){return this.inputs.filter(i=>i.readsValue||i.defaultValue)}get unusedInputs(){return this.inputs.filter(i=>!i.readsValue&&!i.defaultValue)}get usedOutputs(){return this.outputs.filter(i=>i.writesValues.length)}get unusedOutputs(){return this.outputs.filter(i=>!i.writesValues.length)}get usedInternalCalls(){return this.internalCalls.filter(i=>!!i.calledBy.length||!!i.writesValues.length||!!i.successCalls.length||!!i.errorCalls.length)}get unusedInternalCalls(){const i=this.usedInternalCalls;return this.internalCalls.filter(s=>!(i.find(y=>y.id===s.id)||i.find(y=>y.declaration===s.declaration)))}removeInternalCall(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-variable-instance-internal-call"))){const s=this.internalCalls.findIndex(c=>c.id===i.id);return s>-1&&(this.internalCalls.splice(s,1),n&&(n==null||n.add(this,H.Affected))),n==null||n.attemptAutoclose("remove-variable-instance-internal-call",this.id),this}removeInput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveInput))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[removeInput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.RemoveInput,this.id),this;const s=this.inputs.findIndex(c=>c.id===i.id);return s>-1&&(this.inputs.splice(s,1),n&&(n==null||n.add(this,H.Affected))),n==null||n.attemptAutoclose(_.RemoveInput,this.id),this}addInput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddInput))){return this.checkCanEdit(this,n)?this.inputs.includes(i)?(n==null||n.attemptAutoclose(_.AddInput,this.id),this):(this.inputs.push(i),n==null||n.add(this,H.Affected),n==null||n.attemptAutoclose(_.AddInput,this.id),this):(J.Logger.warn(`[addInput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.AddInput,this.id),this)}addOutput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"add-output"))){return this.checkCanEdit(this,n)?this.outputs.includes(i)?(n==null||n.attemptAutoclose("add-output",this.id),this):(this.outputs.push(i),n==null||n.add(this,H.Affected),n==null||n.attemptAutoclose("add-output",this.id),this):(J.Logger.warn(`[addOutput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("add-output",this.id),this)}removeOutput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-output"))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[removeOutput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("remove-output",this.id),this;const s=this.outputs.findIndex(c=>c.id===i.id);return s>-1&&(this.outputs.splice(s,1),n&&(n==null||n.add(this,H.Affected))),n==null||n.attemptAutoclose("remove-output",this.id),this}addSuccessCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddSuccessCaller)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddSuccessCaller,n)?(this.calledBySuccess.find(c=>c.id===i.id)||(this.calledBySuccess.push(i),n==null||n.add(this,H.Updated),s&&mt(this,n)),n==null||n.attemptAutoclose(_.AddSuccessCaller,this.id),this):this}addErrorCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddErrorCaller)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddErrorCaller,n)?(this.calledByError.find(c=>c.id===i.id)||(this.calledByError.push(i),n==null||n.add(this,H.Updated),s&&mt(this,n)),n==null||n.attemptAutoclose(_.AddErrorCaller,this.id),this):this}addEntryCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddEntryCaller)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddEntryCaller,n)?(this.calledByEntry.find(c=>c.id===i.id)||(this.calledByEntry.push(i),n==null||n.add(this,H.Updated),s&&mt(this,n)),n==null||n.attemptAutoclose(_.AddEntryCaller,this.id),this):this}addErrorCall(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddErrorCall)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddErrorCall,n)?(this.errorCalls.find(c=>c.id===i.id)||(this.errorCalls.push(i),s&&mt(this,n),n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose(_.AddErrorCall,this.id),this):this}addSuccessCall(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddSuccessCall)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddSuccessCall,n)?(this.successCalls.find(c=>c.id===i.id)||(this.successCalls.push(i),s&&mt(this,n),n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose(_.AddSuccessCall,this.id),this):this}removeCall(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveCall)),s=!1){if(!this.checkCanEditWithCounterpartAndSideEffects(this,i,_.RemoveCall,n))return this;const c=this.successCalls.findIndex(y=>y.id===i.id);c>-1&&(this.successCalls.splice(c,1),n==null||n.add(this,H.Affected));const e=this.errorCalls.findIndex(y=>y.id===i.id);return e>-1&&(this.errorCalls.splice(e,1),n==null||n.add(this,H.Affected)),s&&mt(this,n),n==null||n.attemptAutoclose(_.RemoveCall,this.id),this}removeCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-caller")),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.RemoveCaller,n)?(this.calledBySuccess=this.calledBySuccess.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),this.calledByError=this.calledByError.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),this.calledByEntry=this.calledByEntry.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),s&&mt(this,n),n==null||n.attemptAutoclose(_.RemoveCaller,this.id),this):this}addValueReader(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddValueReader))){var e,y,m;if(!this.checkCanEditFromScopeOwnerWithSideEffects(this,_.AddValueReader,n))return this;const s=i.type===d.InputMap&&i.parent.type===d.VariableInstance&&((e=i.declaration)==null?void 0:e.type)===d.Property&&((y=i.declaration)==null?void 0:y.constant),c=i.type===d.VariableInstance&&((m=i.declaration)==null?void 0:m.constant);return(s||c)&&i?(n==null||n.event({id:`${_.SetValueWriter}-${this.id}--${this.id}`,action:_.SetValueWriter,owner:i,counterpart:this,errorReason:Ii.ValueReadingOverridesConstantVariable,rootAction:!1}),n==null||n.attemptAutoclose(_.AddValueReader,this.id),this):this.writesValues.includes(i)?(n==null||n.attemptAutoclose(_.AddValueReader,this.id),this):(this.writesValues.push(i),n==null||n.add(this,H.Affected),this)}setError(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetErrorEntity))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setError] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.SetErrorEntity,this.id),this;const s=this.error;return(s==null?void 0:s.id)!==(i==null?void 0:i.id)&&(s==null||s.remove({ignoreUpstream:!0},n),this.error=i,this.subscribeToDependencies(),n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose(_.SetErrorEntity,this.id),this}setParent(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetParent))){var s;return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.SetParent,n)?(((s=this.parent)==null?void 0:s.id)!==(i==null?void 0:i.id)&&(this.parent=i,n&&(n==null||n.add(this,H.Updated))),n==null||n.attemptAutoclose(_.SetParent,this.id),this):this}initChildren(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"init-children"))){if(this.initialized||this.startedInitialization)return this;if(this.startedInitialization=!0,this.initialData.defaultValue&&(this.defaultValue=me(this.initialData.defaultValue,this.project),this.defaultValue.setParent(this,null),this.defaultValue.initChildren(i)),this.initialData.declaration.type===d.GenericReference){const n=this.project.findSubscribedInstanceFromReference(this.initialData.declaration);if(!n)return this;this.declaration=n}else this.declaration=me(this.initialData.declaration,this.project),this.declaration.initChildren(i);return Pv.initWritesValues(this,this.parent),lf.initReadsValue(this),this.initialData.inputs.forEach(n=>{const s=me(n,this.project);return s.setParent(this,null),s.initChildren(i),this.addInput(s,null),s}),this.initialData.outputs.forEach(n=>{const s=me(n,this.project);return s.setParent(this,null),s.initChildren(i),this.addOutput(s,i),s}),this.successCalls=this.initialData.successCalls.map(n=>{const s=me(n,this.project);if(s.addSuccessCaller(this,null),[d.BreakStatement,d.ContinueStatement].includes(s.type))s.setParent(this.parent.parent,null),s.initChildren(i);else if(s.type===d.ReturnStatement){const c=tn(this,this.project);s.setParent(c,null),s.initChildren(i)}else s.type!==d.InternalCall&&(s.setParent(this.parent,null),s.initChildren(i));return s}),this.errorCalls=this.initialData.errorCalls.map(n=>{const s=me(n,this.project);if(s.addErrorCaller(this,null),[d.BreakStatement,d.ContinueStatement].includes(s.type))s.setParent(this.parent.parent,null),s.initChildren(i);else if(s.type===d.ReturnStatement){const c=tn(this,this.project);s.setParent(c,null),s.initChildren(i)}else s.type!==d.InternalCall&&(s.setParent(this.parent,null),s.initChildren(i));return s}),this.internalCalls=this.initialData.internalCalls.reduce((n,s)=>{if(s.type===d.GenericReference){const c=this.project.findSubscribedInstanceFromReference(s);if(!c)return n;const e=c;return e.setParent(this,null),[...n,e]}else{const c=me(s,this.project);return c.setParent(this,null),c.initChildren(i),[...n,c]}},[]),this.initialData.error&&(this.error=me(this.initialData.error,this.project),this.error.setParent(this,null),this.error.initChildren(i)),this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this}setValueWriter(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetValueWriter))){var s,c;return this.checkCanEditFromScopeOwnerWithSideEffects(this,_.SetValueWriter,n)?(s=this.declaration)!=null&&s.constant&&i?(n==null||n.event({id:`${_.SetValueWriter}-${this.id}--${i.id}`,action:_.SetValueWriter,owner:this,counterpart:i,errorReason:Ii.ValueReadingOverridesConstantVariable,rootAction:((c=n==null?void 0:n.self)==null?void 0:c.id)===this.id&&(n==null?void 0:n.autoCloseActionName)===_.SetValueWriter}),n==null||n.attemptAutoclose(_.SetValueWriter,this.id),this):(this.readsValue!==i&&(this.readsValue=i,n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose(_.SetValueWriter,this.id),this):this}removeValueWriter(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveValueWriter))){return this.readsValue&&!this.checkCanEditWithCounterpartAndSideEffects(this,this.readsValue,_.RemoveValueWriter,i)?this:(this.readsValue&&(this.readsValue=null,i==null||i.add(this,H.Updated)),i==null||i.attemptAutoclose(_.RemoveValueWriter,this.id),this)}removeValueReader(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveValueReader))){return this.checkCanEditFromScopeOwnerWithSideEffects(this,_.RemoveValueReader,n)?this.writesValues.includes(i)?(this.writesValues=this.writesValues.filter(s=>s.id!==i.id),n==null||n.add(this,H.Affected),this):(n==null||n.attemptAutoclose(_.RemoveValueReader,this.id),this):this}subscribe(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"meta-sync"))){const s=Mr(this,i,n),c=Lr(this,s),e=this.toMeta();return this.x=s.x||e.x,this.y=s.y||e.y,this.catchesError=s.catchesError!==void 0?s.catchesError:this.catchesError,super.baseMetaSync(s,this,n),s.deleted===!0&&!e.deleted?n==null||n.add(this,H.Removed):s.deleted===!1&&e.deleted?n==null||n.add(this,H.Added):c&&(n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=ke,...n){return await hi.repository.APILoad(this.id,...n),this}async APICreate(i=ke,...n){return await hi.repository.APICreate(this.toShallowJSON(),...n),this}async APIUpdate(i=ke,...n){return await hi.repository.APIUpdate(this.toShallowJSON(),...n),this}async APIDelete(i=ke,...n){return await hi.repository.APIDelete(this.toShallowJSON(),...n),this}async APIClone(i=ke,...n){return await hi.repository.APIClone(this.id,...n),this}async APILoadVersion(i=ke,n,...s){return await hi.repository.APILoadVersion(this.id,n,...s)}removeFromParent(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveFromParent))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[removeFromParent] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveFromParent,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];return this.parent.type===d.Project?(this.parent.removeVariableInstance(this),e.push(this.parent)):this.parent.detachedChildren.includes(this)&&this.parent.unsubscribeDetachedChild(this),i==null||i.attemptAutoclose(_.RemoveFromParent,this.id),{added:D(c),updated:D(n),removed:D(s),affected:D(e),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveEntity))){var m;if(!this.checkCanDelete(this,n))return J.Logger.warn(`[remove] User is not allowed to delete or edit this ${this.type} entity with id: ${this.id}`),n==null||n.event({id:`${_.RemoveEntity}-${this.id}`,action:_.RemoveEntity,owner:this,errorReason:Ii.ActionOwnerEntityNonDeletable,rootAction:((m=n==null?void 0:n.self)==null?void 0:m.id)===this.id&&(n==null?void 0:n.autoCloseActionName)===_.RemoveEntity}),n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const s=[],c=[],e=[],y=[];if(n!=null&&n.hasRemoved(this.id))return n==null||n.attemptAutoclose(_.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},n),Object.values(this.detachedDependents).forEach(v=>{const{updated:E,removed:b,added:w}=v.entity.onDetachedDependencyRemoved(this,v.field,n);s.push(...E),c.push(...b),e.push(...w)}),this.defaultValue){const{updated:v,removed:E}=this.defaultValue.remove({ignoreUpstream:!0},n);s.push(...v),c.push(...E)}if(this.readsValue&&(s.push(this.readsValue),this.readsValue.removeValueReader(this,n)),this.writesValues.forEach(v=>{s.push(v),v.setValueWriter(null,n)}),this.inputs.forEach(v=>{const{updated:E,removed:b}=v.remove({ignoreUpstream:!0},n);s.push(...E),c.push(...b)}),this.outputs.forEach(v=>{const{updated:E,removed:b}=v.remove({ignoreUpstream:!0},n);s.push(...E),c.push(...b)}),this.successCalls.forEach(v=>{s.push(v),v.removeCaller(this,n)}),this.errorCalls.forEach(v=>{s.push(v),v.removeCaller(this,n)}),this.internalCalls.forEach(v=>{const{updated:E,removed:b}=v.remove({ignoreUpstream:!0},n);s.push(...E),c.push(...b)}),!i){const v=this.removeFromParent(n);e.push(...v.added),s.push(...v.updated),c.push(...v.removed),y.push(...v.affected),this.calledBy.forEach(E=>{s.push(E),E.removeCall(this,n)})}return n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:D(e),updated:D(s),removed:D(c),affected:D(y),self:this}}restore({}={},i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RestoreEntity))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[restore] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];if(i!=null&&i.hasAdded(this.id))return i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},i),Object.values(this.detachedDependents).forEach(y=>{const{updated:m,removed:v,added:E}=y.entity.onDetachedDependencyRestored(this,y.field,i);s.push(...m),c.push(...v),n.push(...E)}),this.defaultValue){const{updated:y}=this.defaultValue.restore({},i);s.push(...y)}return this.readsValue&&(s.push(this.readsValue),this.readsValue.addValueReader(this,i)),this.writesValues.forEach(y=>{s.push(y),y.setValueWriter(this,i)}),this.inputs.forEach(y=>{const{updated:m}=y.restore({},i);s.push(...m)}),this.outputs.forEach(y=>{const{updated:m}=y.restore({},i);s.push(...m)}),this.successCalls.forEach(y=>{s.push(y),y.addSuccessCaller(this,i)}),this.errorCalls.forEach(y=>{s.push(y),y.addErrorCaller(this,i)}),this.internalCalls.forEach(y=>{const{updated:m}=y.restore({},i);s.push(...m)}),this.calledBySuccess.forEach(y=>{s.push(y),y.addSuccessCall(this,i)}),this.calledByError.forEach(y=>{s.push(y),y.addErrorCall(this,i)}),this.calledByEntry.forEach(y=>{s.push(y),y.addCall(this,i)}),i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this}}toFlat(i=new Set){var s,c;return i.has(this.id)?[]:(i.add(this.id),[this,...((s=this.defaultValue)==null?void 0:s.toFlat(i))||[],...this.writesValues.flatMap(e=>e.toFlat(i)),...((c=this.readsValue)==null?void 0:c.toFlat(i))||[],...this.successCalls.flatMap(e=>e.toFlat(i)),...this.errorCalls.flatMap(e=>e.toFlat(i)),...this.inputs.flatMap(e=>e.toFlat(i)),...this.outputs.flatMap(e=>e.toFlat(i)),...this.internalCalls.flatMap(e=>e.toFlat(i))])}toFlatIds(i=new Set){var s;return i.has(this.id)?[]:(i.add(this.id),[this.id,...((s=this.defaultValue)==null?void 0:s.toFlatIds(i))||[],...this.writesValues.flatMap(c=>c.toFlatIds(i)),...this.successCalls.flatMap(c=>c.toFlatIds(i)),...this.errorCalls.flatMap(c=>c.toFlatIds(i)),...this.inputs.flatMap(c=>c.toFlatIds(i)),...this.outputs.flatMap(c=>c.toFlatIds(i)),...this.internalCalls.flatMap(c=>c.toFlatIds(i))])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,catchesError:this.catchesError,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,x:this.x,y:this.y,type:this.type,editable:this.editable,deletable:this.deletable}}toJSON(i=new Set){var n,s,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,catchesError:this.catchesError,type:this.type,editable:this.editable,deletable:this.deletable,declaration:this.declaration.toJSON(i),defaultValue:((n=this.defaultValue)==null?void 0:n.toJSON(i))||null,readsValue:((s=this.readsValue)==null?void 0:s.toReference())||null,writesValues:this.writesValues.map(e=>e.toJSON(i)),inputs:this.inputs.map(e=>e.toJSON(i)),outputs:this.outputs.map(e=>e.toJSON(i)),successCalls:this.successCalls.map(e=>e.toJSON(i)),errorCalls:this.errorCalls.map(e=>e.toJSON(i)),internalCalls:this.internalCalls.map(e=>e.toJSON(i)),calledBySuccess:this.calledBySuccess.map(e=>e.toReference()),calledByError:this.calledByError.map(e=>e.toReference()),calledByEntry:this.calledByEntry.map(e=>e.toReference()),parent:this.parent.toReference(),error:((c=this.error)==null?void 0:c.toJSON(i))||null,x:this.x,y:this.y})}toJSONClone(i=ct){var s,c,e,y,m,v,E,b;let n;return(s=i.seenEntityMaps)!=null&&s.has(this.id)?n=i.seenEntityMaps.get(this.id):(n=i.newId||jr(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,n)),(c=i.seenEntities)!=null&&c.has(n)||(e=i.seenEntities)!=null&&e.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((y=i.seenEntities)==null||y.add(n),(m=i.seenEntities)==null||m.add(this.id),{id:n,version:x.UUID.uuid(),createdAt:i.timestamp||M().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,catchesError:this.catchesError,type:this.type,editable:this.editable,deletable:this.deletable,defaultValue:((v=this.defaultValue)==null?void 0:v.toJSONClone({...i,newId:null}))||null,declaration:this.declaration.toReference({seenEntityMaps:i.seenEntityMaps}),readsValue:((E=this.readsValue)==null?void 0:E.toReference({seenEntityMaps:i.seenEntityMaps}))||null,writesValues:this.writesValues.map(w=>w.toJSONClone({...i,newId:null})),inputs:this.inputs.map(w=>w.toJSONClone({...i,newId:null})),outputs:this.outputs.map(w=>w.toJSONClone({...i,newId:null})),successCalls:this.successCalls.map(w=>w.toJSONClone({...i,newId:null})),errorCalls:this.errorCalls.map(w=>w.toJSONClone({...i,newId:null})),internalCalls:this.internalCalls.map(w=>this.calledBy.length||this.readsValue?w.toJSONClone({...i,newId:null}):w.toReference({seenEntityMaps:i.seenEntityMaps})),calledBySuccess:this.calledBySuccess.map(w=>w.toReference({seenEntityMaps:i.seenEntityMaps})),calledByError:this.calledByError.map(w=>w.toReference({seenEntityMaps:i.seenEntityMaps})),calledByEntry:this.calledByEntry.map(w=>w.toReference({seenEntityMaps:i.seenEntityMaps})),error:((b=this.error)==null?void 0:b.toJSONClone({...i,newId:null}))||null,parent:this.parent.toReference({seenEntityMaps:i.seenEntityMaps}),x:this.x,y:this.y})}toReference(i=ct){var s;let n=this.id;return(s=i.seenEntityMaps)!=null&&s.has(this.id)&&(n=i.seenEntityMaps.get(this.id)),{id:n+"--"+x.UUID.uuid()+"--ref",type:d.GenericReference,entityId:n,version:this.version,entityType:this.type}}toShallowJSON(i=ct){var s,c,e,y,m;let n=this.id;return(s=i.seenEntityMaps)!=null&&s.has(this.id)&&(n=i.seenEntityMaps.get(this.id)),{id:n,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,catchesError:this.catchesError,type:this.type,editable:this.editable,deletable:this.deletable,x:this.x,y:this.y,defaultValue:((c=this.defaultValue)==null?void 0:c.toReference(i))||null,declaration:((e=this.declaration)==null?void 0:e.toReference(i))||null,readsValue:((y=this.readsValue)==null?void 0:y.toReference(i))||null,writesValues:this.writesValues.map(v=>v.toReference(i)),inputs:this.inputs.map(v=>v.toReference(i)),outputs:this.outputs.map(v=>v.toReference(i)),successCalls:this.successCalls.map(v=>v.toReference(i)),errorCalls:this.errorCalls.map(v=>v.toReference(i)),calledBySuccess:this.calledBySuccess.map(v=>v.toReference(i)),calledByError:this.calledByError.map(v=>v.toReference(i)),calledByEntry:this.calledByEntry.map(v=>v.toReference(i)),internalCalls:this.internalCalls.map(v=>v.toReference(i)),error:((m=this.error)==null?void 0:m.toReference(i))||null,parent:this.parent.toReference(i)}}toFlatJSON(i=new Set){var s,c;return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...((s=this.defaultValue)==null?void 0:s.toFlatJSON(i))||[],...((c=this.declaration)==null?void 0:c.toFlatJSON(i))||[],...this.writesValues.flatMap(e=>e.toFlatJSON(i)),...this.successCalls.flatMap(e=>e.toFlatJSON(i)),...this.errorCalls.flatMap(e=>e.toFlatJSON(i)),...this.inputs.flatMap(e=>e.toFlatJSON(i)),...this.outputs.flatMap(e=>e.toFlatJSON(i)),...this.internalCalls.flatMap(e=>e.toFlatJSON(i)),...this.calledBy.flatMap(e=>e.toFlatJSON(i))])}toGenerationTarget(){const i=this.parent.type===d.Project?void 0:this.parent.id;return{id:this.id,type:this.type,declaration:this.declaration.id,calledByEntry:this.calledByEntry.map(n=>n.id),calledBySuccess:this.calledBySuccess.map(n=>n.id),calledByError:this.calledByError.map(n=>n.id),parent:i}}toFlatGenerationTarget(i=new Set){var s,c,e;return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...((s=this.defaultValue)==null?void 0:s.toFlatGenerationTarget(i))||[],...((c=this.declaration)==null?void 0:c.toFlatGenerationTarget(i))||[],...((e=this.readsValue)==null?void 0:e.toFlatGenerationTarget(i))||[],...this.writesValues.flatMap(y=>y.toFlatGenerationTarget(i)),...this.successCalls.flatMap(y=>y.toFlatGenerationTarget(i)),...this.errorCalls.flatMap(y=>y.toFlatGenerationTarget(i)),...this.inputs.flatMap(y=>y.toFlatGenerationTarget(i)),...this.outputs.flatMap(y=>y.toFlatGenerationTarget(i)),...this.internalCalls.flatMap(y=>y.toFlatGenerationTarget(i))])}clearErrors(){var i;return this.errors=[],(i=this.defaultValue)==null||i.clearErrors(),this.inputs.forEach(n=>n.clearErrors()),this.outputs.forEach(n=>n.clearErrors()),this.successCalls.forEach(n=>n.clearErrors()),this.errorCalls.forEach(n=>n.clearErrors()),this.internalCalls.forEach(n=>n.clearErrors()),this}validate(){return this.errors=FLe(this),{success:!0}}async validateAsync(i={}){const n=J.YieldTracker.from(i);return this.errors=await KLe(this,{tracker:n}),{success:!0}}getErrors(){var n;return[...this.errors,...((n=this.defaultValue)==null?void 0:n.getErrors())||[],...this.inputs.flatMap(s=>s.getErrors()),...this.internalCalls.flatMap(s=>s.getErrors()),...this.outputs.flatMap(s=>s.getErrors())]}async getErrorsAsync(i={}){var e;const n=J.YieldTracker.from(i),s=[...this.errors];await n.tick();const c=await((e=this.defaultValue)==null?void 0:e.getErrorsAsync({tracker:n}));c&&s.push(...c);for(const y of this.inputs){const m=await y.getErrorsAsync({tracker:n});s.push(...m)}for(const y of this.internalCalls){const m=await y.getErrorsAsync({tracker:n});s.push(...m)}for(const y of this.outputs){const m=await y.getErrorsAsync({tracker:n});s.push(...m)}return s}getShallowErrors(){return this.errors}getDefaultValue(){var i;return this.defaultValue||((i=this.declaration)==null?void 0:i.defaultValue)||null}setDefaultValue(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"set-default-value"))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setDefaultValue] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("set-default-value",this.id),this;const s=this.defaultValue;return(s==null?void 0:s.id)!==(i==null?void 0:i.id)&&(s==null||s.remove({ignoreUpstream:!0},n),this.defaultValue=i,n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose("set-default-value",this.id),this}clone(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.CloneEntity)),n=null,s=null,c=!0){var $,L,k,K;const e=Rr(n,this),y=this.toJSON(),m=s||x.UUID.uuid();y.inputs=[],y.id=m,y.version=x.UUID.uuid(),y.createdAt=(i==null?void 0:i.timestamp)||M().toISOString(),y.author=(i==null?void 0:i.author)||"1",y.previousVersion=null,y.deleted=!1,y.deletable=!0,y.editable=!0;const v=Si(y,e);n?v.setParent(n,i):v.setParent(this.parent,null),c&&v.subscribe(),v.initChildren(i),i==null||i.add(v,H.Added);const E=($=this.defaultValue)==null?void 0:$.clone(i,v,x.UUID.uuid(),c);v.defaultValue=E||null;const b=(L=this.inputs)==null?void 0:L.map(S=>S.clone(i,v,x.UUID.uuid(),c));v.inputs=b;const w=(k=this.outputs)==null?void 0:k.map(S=>S.clone(i,v,x.UUID.uuid(),c));v.outputs=w;const V=(K=this.internalCalls)==null?void 0:K.map(S=>S.clone(i,v,x.UUID.uuid(),c));return v.internalCalls=V,i==null||i.attemptAutoclose(_.CloneEntity,this.id),v}addInternalCall(i){return this.internalCalls.find(n=>n===i)||this.internalCalls.push(i),this}setDeclaration(i){return this.declaration!==i&&(this.declaration=i),this}removeUnrecognizedInputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveUnrecognizedInputs))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[removeUnrecognizedInputs] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveUnrecognizedInputs,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];return this.declaration.dataType&&!this.declaration.dataType.isObject()?[...this.inputs].forEach(y=>{const m=y.remove({ignoreUpstream:!1},i);c.push(...m.removed),n.push(...m.updated)}):this.declaration.dataType&&this.declaration.dataType.hasStrictObjectStructure()&&[...this.inputs].forEach(y=>{var v;if(!y.declaration){const E=y.remove({ignoreUpstream:!1},i);c.push(...E.removed),n.push(...E.updated);return}if(![...((v=this.declaration.dataType)==null?void 0:v.entity).allProperties].find(E=>y.declaration===E)){const E=y.remove({ignoreUpstream:!1},i);c.push(...E.removed),n.push(...E.updated)}}),i==null||i.attemptAutoclose(_.RemoveUnrecognizedInputs,this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}removeUnrecognizedOutputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-unrecognized-variable-instance-outputs"))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[removeUnrecognizedOutputs] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveUnrecognizedOutputs,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];return this.declaration.dataType&&!this.declaration.dataType.isObject()?[...this.outputs].forEach(y=>{const m=y.remove({ignoreUpstream:!1},i);c.push(...m.removed),n.push(...m.updated)}):this.declaration.dataType&&this.declaration.dataType.hasStrictObjectStructure()&&[...this.outputs].forEach(y=>{var v;if(!y.declaration){const E=y.remove({ignoreUpstream:!1},i);c.push(...E.removed),n.push(...E.updated);return}if(![...((v=this.declaration.dataType)==null?void 0:v.entity).allProperties].find(E=>y.declaration===E)){const E=y.remove({ignoreUpstream:!1},i);c.push(...E.removed),n.push(...E.updated)}}),i==null||i.attemptAutoclose("remove-unrecognized-variable-instance-outputs",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}removeUnrecognizedInternalCalls(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-unrecognized-variable-declaration-internal-calls"))){const n=[],s=[],c=[],e=[];if(!this.declaration.dataType||!this.declaration.dataType.entity||![d.DefinitionEntity,d.PrimitiveEntity,d.BuiltInBaseEntity].includes(this.declaration.dataType.entity.type))[...this.internalCalls].forEach(m=>{const v=m.remove({ignoreUpstream:!1},i);c.push(...v.removed),n.push(...v.updated)});else if(this.declaration.dataType&&this.declaration.dataType.entity&&[d.DefinitionEntity,d.PrimitiveEntity,d.BuiltInBaseEntity].includes(this.declaration.dataType.entity.type)){const m=[...this.declaration.dataType.entity.getAllInteractiveMethods()],v=[...m].filter(E=>!m.some(b=>{var w,V;return b.id!==E.id&&(((w=b.implements)==null?void 0:w.id)===E.id||((V=b.extends)==null?void 0:V.id)===E.id)})&&!E.deleted);[...this.internalCalls].forEach(E=>{if(!E.declaration){const w=E.remove({ignoreUpstream:!1},i);c.push(...w.removed),n.push(...w.updated);return}if(!v.find(w=>E.declaration===w)){const w=E.remove({ignoreUpstream:!1},i);c.push(...w.removed),n.push(...w.updated);return}})}return this.internalCalls.filter((m,v)=>{const E=this.internalCalls.findIndex(w=>w.declaration===m.declaration&&w!==m);if(E===-1)return!1;const b=this.internalCalls[E];return M(b==null?void 0:b.createdAt).isSame(M(m.createdAt))?v>E:!!M(b==null?void 0:b.createdAt).isAfter(m.createdAt)}).forEach(m=>{const v=m.remove({ignoreUpstream:!1},i);c.push(...v.removed),n.push(...v.updated)}),i==null||i.attemptAutoclose("remove-unrecognized-variable-declaration-internal-calls",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}syncInputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"sync-variable-instance-inputs"))){const n=[],s=[],c=[],e=[];if(this.declaration.dataType)if(this.declaration.dataType.entity){if([d.DefinitionEntity,d.PrimitiveEntity,d.BuiltInBaseEntity].includes(this.declaration.dataType.entity.type)&&!this.declaration.dataType.isList){const y=[...this.declaration.dataType.entity.properties];y.filter(b=>!b.getDataType(i)).forEach(b=>{const w=this.inputs.find(L=>se(L,this.project)===se(b,this.project));if(!w)return;const V=this.declaration.getMasterInputWithValueWritterFromAllInstances(w);if(!V)return;const $=md(V);b.setDataType($,i),w.setDeclaration(b,i)}),y.filter(b=>!this.inputs.find(w=>{var V;return((V=w.declaration)==null?void 0:V.id)===b.id})).forEach(b=>{const w={dataType:null,id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||M().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.InputMap,parentRelationType:null,parent:this.toReference(),name:null,description:null,codeName:null,declaration:b,defaultValue:null,index:b.index,readsValue:null},V=me(w,this.project);return V.setParent(this,i),V.initChildren(i),i==null||i.add(V,H.Added),this.addInput(V,i),V}),this.inputs.filter(b=>!b.declaration).forEach(b=>{const w=y.find(V=>se(V,this.project)===se(b,this.project));w&&b.setDeclaration(w,i)})}}else return i==null||i.attemptAutoclose("sync-variable-instance-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};else return i==null||i.attemptAutoclose("sync-variable-instance-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};return i==null||i.attemptAutoclose("sync-variable-instance-inputs",this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this}}syncOutputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SyncOutputs))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[syncOutputs] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.SyncOutputs,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];if(this.declaration.dataType)if(this.declaration.dataType.entity)[d.DefinitionEntity,d.PrimitiveEntity,d.BuiltInBaseEntity].includes(this.declaration.dataType.entity.type)&&!this.declaration.dataType.isList&&[...this.declaration.dataType.entity.properties].filter(v=>!this.outputs.find(E=>E.declaration===v)).map(v=>{const E={dataType:null,id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||M().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.OutputMap,parent:this.toReference(),declaration:v,index:v.index,writesValues:[]},b=me(E,this.project);return b.setParent(this,i),b.initChildren(i),i==null||i.add(b,H.Added),this.addOutput(b,i),b});else return i==null||i.attemptAutoclose(_.SyncOutputs,this.id),{added:[],updated:[],removed:[],affected:[],self:this};else return i==null||i.attemptAutoclose(_.SyncOutputs,this.id),{added:[],updated:[],removed:[],affected:[],self:this};return i==null||i.attemptAutoclose(_.SyncOutputs,this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this}}generateUnusedInternalCalls(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"generate-unused-internal-calls"))){const n=[],s=[],c=[],e=[];if(this.declaration.dataType)if(this.declaration.dataType.entity){if([d.DefinitionEntity,d.PrimitiveEntity,d.BuiltInBaseEntity].includes(this.declaration.dataType.entity.type)&&!this.declaration.dataType.isList){const y=[...this.declaration.dataType.entity.getAllInteractiveMethods()];[...y].filter(E=>!y.some(b=>{var w,V;return b.id!==E.id&&(((w=b.implements)==null?void 0:w.id)===E.id||((V=b.extends)==null?void 0:V.id)===E.id)})&&!E.deleted).filter(E=>!this.internalCalls.find(w=>{var $,L,k,K,S;return((($=w.declaration)==null?void 0:$.id)||((k=(L=w.initialData)==null?void 0:L.declaration)==null?void 0:k.entityId)||((S=(K=w.initialData)==null?void 0:K.declaration)==null?void 0:S.id))===E.id})).forEach(E=>{const b=this.internalCalls.find(w=>{const V=Pc(w.declaration),$=Pc(E);return V.id===$.id});if(b)b.setDeclaration(E),b.subscribeToDependencies();else{const w=E.createInternalCall(i,this);i==null||i.add(w,H.Added),this.addInternalCall(w)}})}}else return i==null||i.attemptAutoclose("generate-unused-internal-calls",this.id),{added:[],updated:[],removed:[],affected:[],self:this};else return i==null||i.attemptAutoclose("generate-unused-internal-calls",this.id),{added:[],updated:[],removed:[],affected:[],self:this};return i==null||i.attemptAutoclose("generate-unused-internal-calls",this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this}}getDataType(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"get-data-type"))){var s;const n=((s=this.declaration)==null?void 0:s.getDataType(i))||null;return i==null||i.attemptAutoclose("get-data-type",this.id),n}getUnusedInputs(){return this.inputs.filter(i=>i.suggestion||!i.readsValue&&!i.defaultValue)}getUnusedOutputs(){return this.outputs.filter(i=>i.suggestion||!i.writesValues.length)}getUsedInputs(){return this.inputs.filter(i=>!i.suggestion&&(i.readsValue||i.defaultValue))}getUsedOutputs(){return this.outputs.filter(i=>!i.suggestion&&i.writesValues.length)}};I(hi,"repository",{APICreate:async(i,...n)=>i,APIUpdate:async(i,...n)=>i,APIDelete:async(i,...n)=>i,APIClone:async(i,...n)=>{},APILoad:async(i,...n)=>null,APILoadVersion:async(i,n,...s)=>null}),I(hi,"type",d.VariableInstance),I(hi,"USER_MANAGED_PARENT_TYPES",[...nr,d.Project]),I(hi,"PARENT_TYPES",[...hi.USER_MANAGED_PARENT_TYPES]),I(hi,"MUTABLE_BASE_PROPERTIES",["catchesError"]),I(hi,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),I(hi,"BASE_PROPERTIES",[...hi.MUTABLE_BASE_PROPERTIES,...hi.INMUTABLE_BASE_PROPERTIES]),I(hi,"MUTABLE_META_PROPERTIES",[...hi.MUTABLE_BASE_PROPERTIES,"x","y"]),I(hi,"INMUTABLE_META_PROPERTIES",[...hi.INMUTABLE_BASE_PROPERTIES]),I(hi,"META_PROPERTIES",[...hi.MUTABLE_META_PROPERTIES,...hi.INMUTABLE_META_PROPERTIES]),I(hi,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry","readsValue"]),I(hi,"INMUTABLE_UPSTREAM_PROPERTIES",["declaration","parent"]),I(hi,"UPSTREAM_PROPERTIES",[...hi.MUTABLE_UPSTREAM_PROPERTIES,...hi.INMUTABLE_UPSTREAM_PROPERTIES]),I(hi,"MUTABLE_DOWNSTREAM_PROPERTIES",["writesValues","inputs","outputs","successCalls","errorCalls","internalCalls"]),I(hi,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),I(hi,"DOWNSTREAM_PROPERTIES",[...hi.MUTABLE_DOWNSTREAM_PROPERTIES,...hi.INMUTABLE_DOWNSTREAM_PROPERTIES]),I(hi,"PROPERTIES",[...hi.META_PROPERTIES,...hi.UPSTREAM_PROPERTIES,...hi.DOWNSTREAM_PROPERTIES]);let Bu=hi;var SLe=(o=>(o.Parent="variable-declaration-parent",o.DataTypeEntity="variable-declaration-data-type-entity",o.DataType="variable-declaration-data-type",o))(SLe||{});const mi=class mi extends Ur{constructor(i,n){super(i);I(this,"initialData");I(this,"id");I(this,"name");I(this,"codeName",null);I(this,"description",null);I(this,"required",!1);I(this,"constant",!1);I(this,"x");I(this,"y");I(this,"type",d.VariableDeclaration);I(this,"catchesError",!1);I(this,"defaultValue",null);I(this,"dataType",null);I(this,"writesValues",[]);I(this,"readsValue",null);I(this,"inputs",[]);I(this,"outputs",[]);I(this,"error",null);I(this,"calledBySuccess",[]);I(this,"calledByError",[]);I(this,"calledByEntry",[]);I(this,"successCalls",[]);I(this,"errorCalls",[]);I(this,"internalCalls",[]);I(this,"parent");I(this,"errors",[]);I(this,"project");I(this,"detachedDependents",{});I(this,"knownVersions",null);I(this,"activeVersion",!1);I(this,"initialized",!1);I(this,"startedInitialization",!1);I(this,"suggestion",!1);I(this,"codeNativeValueValidation",null);this.initialData=i,this.project=n,this.id=i.id,this.name=i.name,this.description=i.description,this.constant=i.constant,this.codeName=i.codeName,this.required=i.required,this.x=i.x,this.y=i.y,this.catchesError=i.catchesError||!1}static new(i=null){return{id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||M().toISOString(),author:(i==null?void 0:i.author)||x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.VariableDeclaration,catchesError:!1,name:"",codeName:null,description:"",dataType:null,internalCalls:[],successCalls:[],errorCalls:[],readsValue:null,writesValues:[],defaultValue:null,constant:!1,required:!1,inputs:[],outputs:[],parent:null,calledByEntry:[],calledBySuccess:[],calledByError:[],error:null,x:0,y:0}}static fromGenerationTarget(i,n){let s=n;if(i.parent){const b=ne(i.parent);s=n.get(b)}const c=i.calledByEntry.map(b=>{const w=ne(b);return n.get(w)}),e=i.calledBySuccess.map(b=>{const w=ne(b);return n.get(w)}),y=i.calledByError.map(b=>{const w=ne(b);return n.get(w)});let m=null;if(i.readsValue){const b=ne(i.readsValue);m=n.get(b)}const v={id:i.id,version:x.UUID.uuid(),createdAt:M().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.VariableDeclaration,catchesError:i.catchesError||!1,name:i.name,defaultValue:null,codeName:i.codeName||null,description:i.description||null,constant:i.constant||!1,required:i.required||!1,calledByEntry:c,calledBySuccess:e,calledByError:y,dataType:null,errorCalls:[],successCalls:[],internalCalls:[],readsValue:m,inputs:[],outputs:[],writesValues:[],error:null,x:0,y:0,parent:s},E=me(v,n);return E.setParent(s,null),E}static validateGenerationTarget(i,n){let s=JSON.parse(JSON.stringify(i));const c=[],e=bn(s,{parent:{list:!1,types:[...nr,d.Project],optional:!0}},n);s=e.modifiedData;const y=CP(s,n);return c.push(...e.errors,...y,...$r(s)),{errors:c,modifiedData:s}}get variableInstances(){const i=[];return Object.values(this.detachedDependents).forEach(n=>{n.field===gN.VarDeclaration&&!i.includes(n.entity)&&i.push(n.entity)}),i}validateGeneratedUpdate(i){const n=[];let s=JSON.parse(JSON.stringify(i));const c=sf(s,this);return s=c.modifiedData,n.push(...c.errors),i.parent&&n.push(new De({id:`${this.id}--${ae.InvalidParentUpdate}`,code:ae.InvalidParentUpdate,severity:ce.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated. The 'parent' on a callable entity, is its scope. It scope is auto-calculated implicitly by the its caller.
|
|
95
|
+
You shouldn't have to manually update a 'parent' property. The equivalent result is to change its value readers, value writters, or callers.`})),{errors:n,modifiedData:s}}subscribeDependents(i){return i.forEach(n=>{this.detachedDependents[n.entity.id]||(this.detachedDependents[n.entity.id]=n)}),this}unsubscribeDependents(i){return i.forEach(n=>{this.detachedDependents[n.entity.id]&&delete this.detachedDependents[n.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"sync-dependents"))){const n=[],s=[],c=[],e=[];return Object.values(this.detachedDependents).forEach(y=>{const m=y.entity.afterAllChildrenInitialized(i);n.push(...m.updated),s.push(...m.added),c.push(...m.removed),e.push(...m.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}onDetachedDependencyRemoved(i,n,s){const c=[],e=[],y=[],m=[];if(n==="parent"){const{updated:v,added:E,removed:b}=this.remove({ignoreUpstream:!1},s);c.push(...v),e.push(...E),y.push(...b)}if(n==="var-declaration"){const{updated:v,added:E,removed:b}=this.remove({ignoreUpstream:!1},s);c.push(...v),e.push(...E),y.push(...b)}return{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:this}}onDetachedDependencyRestored(i,n,s){const c=[],e=[],y=[],m=[];if(n==="parent"){const{updated:v,added:E,removed:b}=this.restore({},s);c.push(...v),e.push(...E),y.push(...b)}if(n==="var-declaration"){const{updated:v,added:E,removed:b}=this.restore({},s);c.push(...v),e.push(...E),y.push(...b)}return{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:this}}unsubscribeFromDependencies(){var i,n,s,c,e,y,m;return(n=(i=this.parent)==null?void 0:i.unsubscribeDependents)==null||n.call(i,[{entity:this,field:"parent"}]),(e=(c=(s=this.declaration.dataType)==null?void 0:s.entity)==null?void 0:c.unsubscribeDependents)==null||e.call(c,[{entity:this,field:"data-type-entity"}]),(m=(y=this.declaration)==null?void 0:y.unsubscribeDependents)==null||m.call(y,[{entity:this,field:"var-declaration"}]),this}subscribeToDependencies(){var i,n,s,c;return(i=this.parent)==null||i.subscribeDependents([{entity:this,field:"parent"}]),(c=(s=(n=this.declaration.dataType)==null?void 0:n.entity)==null?void 0:s.subscribeDependents)==null||c.call(s,[{entity:this,field:"data-type-entity"}]),this.declaration.subscribeDependents([{entity:this,field:"var-declaration"}]),this}increaseVersion(i){if(i&&!M(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&M(i).isSame(M(this.createdAt))?this:(this.previousVersion=this.version,this.version=x.UUID.uuid(),this.createdAt=M(i).toISOString()||M().toISOString(),this)}captureVersion(){var n;const i=((n=this.knownVersions)==null?void 0:n.get(this.version))||new hi(this,this.project);return i.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map([[this.version,i]]),i.inputs=[...this.inputs],i.outputs=[...this.outputs],i.internalCalls=[...this.internalCalls],i.successCalls=[...this.successCalls],i.errorCalls=[...this.errorCalls],i.writesValues=[...this.writesValues],i.readsValue=this.readsValue,i.defaultValue=this.defaultValue,i.declaration=this.declaration,i.calledBySuccess=[...this.calledBySuccess],i.calledByError=[...this.calledByError],i.calledByEntry=[...this.calledByEntry],i.error=this.error,i.parent=this.parent,this}recursiveCaptureUpstreamVersions(i){const n=[],s=[],c=[],e=[];if(this.parent){this.parent.increaseVersion(i);const y=this.parent.recursiveCaptureUpstreamVersions(i);n.push(this.parent,...y.updated),s.push(...y.added),c.push(...y.removed)}return{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}async restoreVersion(i){var m;const n=[],s=[],c=[],e=[];if(this.version===i)return{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this};if(!this.knownVersions){const v=new Map;for(const[E,b]of this.knownVersions||new Map){if(v.set(E,b),b.activeVersion=!1,b.knownVersions)for(const[w,V]of b.knownVersions)v.set(w,V);b.knownVersions=null}}let y=(m=this.knownVersions)==null?void 0:m.get(i);if(!y){const v=await this.APILoadVersion({},i);if(!v)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);y=new hi(v,this.project)}return this.metaSync(y.toShallowJSON(),null),this.previousVersion=y.previousVersion,this.version=y.version,this.createdAt=y.createdAt,this.author=y.author,this.deleted=y.deleted,this.inputs=y.inputs,this.outputs=y.outputs,this.internalCalls=y.internalCalls,this.successCalls=y.successCalls,this.errorCalls=y.errorCalls,this.writesValues=y.writesValues,this.readsValue=y.readsValue,this.defaultValue=y.defaultValue,this.declaration=y.declaration,this.calledBySuccess=y.calledBySuccess,this.calledByError=y.calledByError,this.calledByEntry=y.calledByEntry,this.error=y.error,this.parent=y.parent,{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}updateWithShallowTransfer(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.UpdateWithShallowTransfer))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[updateWithShallowTransfer] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),this;if(this.metaSync(i,n),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 s=ne(i.parent),c=this.project.get(s),e=this.parent;if(e&&e.id!==(c==null?void 0:c.id)&&this.removeFromParent(n),c)this.setParent(c,n),this.addSelfToProject(n);else throw n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${s}' that isn't found in the project`)}else throw n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(i.readsValue){const s=ne(i.readsValue),c=this.project.get(s),e=this.readsValue;e&&e.id!==(c==null?void 0:c.id)&&this.removeValueWriter(n),c&&this.setValueWriter(c,n)}else this.removeValueWriter(n);if(i.declaration){const s=ne(i.declaration),c=this.project.get(s);c&&this.setDeclaration(c)}if(i.calledByEntry.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addEntryCaller(e,n),e.addCall(this,n))}),[...this.calledByEntry].forEach(s=>{i.calledByEntry.find(e=>ne(e)===s.id)||(this.removeCaller(s,n),s.removeCall(this,n))}),i.calledBySuccess.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addSuccessCaller(e,n),e.addSuccessCall(this,n))}),[...this.calledBySuccess].forEach(s=>{i.calledBySuccess.find(e=>ne(e)===s.id)||(this.removeCaller(s,n),s.removeCall(this,n))}),i.calledByError.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addErrorCaller(e,n),e.addErrorCall(this,n))}),[...this.calledByError].forEach(s=>{i.calledByError.find(e=>ne(e)===s.id)||(this.removeCaller(s,n),s.removeCall(this,n))}),i.outputs.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addOutput(e,n),e.setParent(this,n))}),[...this.outputs].forEach(s=>{i.outputs.find(e=>ne(e)===s.id)||(this.removeOutput(s,n),s.removeFromParent(n))}),i.inputs.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addInput(e,n),e.setParent(this,n))}),[...this.inputs].forEach(s=>{i.inputs.find(e=>ne(e)===s.id)||(this.removeInput(s,n),s.removeFromParent(n))}),i.defaultValue){const s=ne(i.defaultValue),c=this.project.get(s);c&&this.setDefaultValue(c,n)}else this.setDefaultValue(null,n);return i.writesValues.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addValueReader(e,n),e.setValueWriter(this,n))}),[...this.writesValues].forEach(s=>{i.writesValues.find(e=>ne(e)===s.id)||(this.removeValueReader(s,n),s.setValueWriter(null,n))}),this.captureVersion(),this.subscribeToDependencies(),n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),this}hydrateAncestors(){const i=[],n=[],s=[],c=[];if(this.initialData.parent){const e=ne(this.initialData.parent),y=this.project.get(e);if(y)this.setParent(y,null),i.push(y);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.readsValue){const e=ne(this.initialData.readsValue),y=this.project.get(e);y&&(this.setValueWriter(y,null),i.push(y))}if(this.initialData.declaration){const e=ne(this.initialData.declaration),y=this.project.get(e);y&&(this.setDeclaration(y),i.push(y))}return this.initialData.calledByEntry.forEach(e=>{const y=ne(e),m=this.project.get(y);m&&this.addEntryCaller(m,null)}),this.initialData.calledBySuccess.forEach(e=>{const y=ne(e),m=this.project.get(y);m&&this.addSuccessCaller(m,null)}),this.initialData.calledByError.forEach(e=>{const y=ne(e),m=this.project.get(y);m&&this.addErrorCaller(m,null)}),{updated:D(i),added:D(n),removed:D(s),affected:D(c),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AfterAllChildrenInitialized))){var Ne;if(!this.checkCanEdit(this,i))return J.Logger.warn(`[afterAllChildrenInitialized] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.AfterAllChildrenInitialized,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];if(this.initialized=!0,!this.declaration.dataType||(Ne=this.declaration.dataType)!=null&&Ne.inferred){const{added:Be,updated:Se,removed:je,affected:Ze}=this.declaration.inferDataTypeAndSyncInstancesInputsAndOutputs(i);s.push(...Be),n.push(...Se),c.push(...je),e.push(...Ze)}const{added:y,updated:m,removed:v,affected:E}=this.syncInputs(i);s.push(...y),n.push(...m),c.push(...v),e.push(...E);const{added:b,updated:w,removed:V,affected:$}=this.syncOutputs(i);s.push(...b),n.push(...w),c.push(...V),e.push(...$);const{added:L,updated:k,removed:K,affected:S}=this.generateUnusedInternalCalls(i);s.push(...L),n.push(...k),c.push(...K),e.push(...S);const{added:Y,updated:re,removed:ee,affected:de}=this.removeUnrecognizedInputs(i);s.push(...Y),n.push(...re),c.push(...ee),e.push(...de);const{added:le,updated:fe,removed:ve,affected:ue}=this.removeUnrecognizedOutputs(i);s.push(...le),n.push(...fe),c.push(...ve),e.push(...ue);const{added:ye,updated:Ve,removed:_e,affected:$e}=this.removeUnrecognizedInternalCalls(i);return s.push(...ye),n.push(...Ve),c.push(..._e),e.push(...$e),this.inputs.sort((Be,Se)=>{var je,Ze;return(Be.index??((je=Be.declaration)==null?void 0:je.index))-(Se.index??((Ze=Se.declaration)==null?void 0:Ze.index))}),this.outputs.sort((Be,Se)=>{var je,Ze;return(Be.index??((je=Be.declaration)==null?void 0:je.index))-(Se.index??((Ze=Se.declaration)==null?void 0:Ze.index))}),this.declaration.constant&&this.readsValue&&(this.readsValue.removeValueReader(this,i),this.removeValueWriter(i)),this.declaration.constant&&this.defaultValue&&this.defaultValue.remove({ignoreUpstream:!1},i),this.captureVersion(),i==null||i.attemptAutoclose(_.AfterAllChildrenInitialized,this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}addSelfToProject(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"add-self-to-project"))){const n=[this],s=[],c=[],e=[];return this.parent===this.project&&this.project.addVariableInstance(this),this.readsValue&&(this.readsValue.addValueReader(this,i),n.push(this.readsValue)),this.writesValues.forEach(y=>{y.setValueWriter(this,i),n.push(y)}),this.successCalls.forEach(y=>{y.addSuccessCaller(this,i),n.push(y)}),this.errorCalls.forEach(y=>{y.addErrorCaller(this,i),n.push(y)}),this.calledBySuccess.forEach(y=>{y.addSuccessCall(this,i),n.push(y)}),this.calledByError.forEach(y=>{y.addErrorCall(this,i),n.push(y)}),this.calledByEntry.forEach(y=>{y.addCall(this,i),n.push(y)}),this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}get usedInputs(){return this.inputs.filter(i=>i.readsValue||i.defaultValue)}get unusedInputs(){return this.inputs.filter(i=>!i.readsValue&&!i.defaultValue)}get usedOutputs(){return this.outputs.filter(i=>i.writesValues.length)}get unusedOutputs(){return this.outputs.filter(i=>!i.writesValues.length)}get usedInternalCalls(){return this.internalCalls.filter(i=>!!i.calledBy.length||!!i.writesValues.length||!!i.successCalls.length||!!i.errorCalls.length)}get unusedInternalCalls(){const i=this.usedInternalCalls;return this.internalCalls.filter(s=>!(i.find(y=>y.id===s.id)||i.find(y=>y.declaration===s.declaration)))}removeInternalCall(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-variable-instance-internal-call"))){const s=this.internalCalls.findIndex(c=>c.id===i.id);return s>-1&&(this.internalCalls.splice(s,1),n&&(n==null||n.add(this,H.Affected))),n==null||n.attemptAutoclose("remove-variable-instance-internal-call",this.id),this}removeInput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveInput))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[removeInput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.RemoveInput,this.id),this;const s=this.inputs.findIndex(c=>c.id===i.id);return s>-1&&(this.inputs.splice(s,1),n&&(n==null||n.add(this,H.Affected))),n==null||n.attemptAutoclose(_.RemoveInput,this.id),this}addInput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddInput))){return this.checkCanEdit(this,n)?this.inputs.includes(i)?(n==null||n.attemptAutoclose(_.AddInput,this.id),this):(this.inputs.push(i),n==null||n.add(this,H.Affected),n==null||n.attemptAutoclose(_.AddInput,this.id),this):(J.Logger.warn(`[addInput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.AddInput,this.id),this)}addOutput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"add-output"))){return this.checkCanEdit(this,n)?this.outputs.includes(i)?(n==null||n.attemptAutoclose("add-output",this.id),this):(this.outputs.push(i),n==null||n.add(this,H.Affected),n==null||n.attemptAutoclose("add-output",this.id),this):(J.Logger.warn(`[addOutput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("add-output",this.id),this)}removeOutput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-output"))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[removeOutput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("remove-output",this.id),this;const s=this.outputs.findIndex(c=>c.id===i.id);return s>-1&&(this.outputs.splice(s,1),n&&(n==null||n.add(this,H.Affected))),n==null||n.attemptAutoclose("remove-output",this.id),this}addSuccessCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddSuccessCaller)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddSuccessCaller,n)?(this.calledBySuccess.find(c=>c.id===i.id)||(this.calledBySuccess.push(i),n==null||n.add(this,H.Updated),s&&mt(this,n)),n==null||n.attemptAutoclose(_.AddSuccessCaller,this.id),this):this}addErrorCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddErrorCaller)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddErrorCaller,n)?(this.calledByError.find(c=>c.id===i.id)||(this.calledByError.push(i),n==null||n.add(this,H.Updated),s&&mt(this,n)),n==null||n.attemptAutoclose(_.AddErrorCaller,this.id),this):this}addEntryCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddEntryCaller)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddEntryCaller,n)?(this.calledByEntry.find(c=>c.id===i.id)||(this.calledByEntry.push(i),n==null||n.add(this,H.Updated),s&&mt(this,n)),n==null||n.attemptAutoclose(_.AddEntryCaller,this.id),this):this}addErrorCall(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddErrorCall)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddErrorCall,n)?(this.errorCalls.find(c=>c.id===i.id)||(this.errorCalls.push(i),s&&mt(this,n),n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose(_.AddErrorCall,this.id),this):this}addSuccessCall(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddSuccessCall)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddSuccessCall,n)?(this.successCalls.find(c=>c.id===i.id)||(this.successCalls.push(i),s&&mt(this,n),n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose(_.AddSuccessCall,this.id),this):this}removeCall(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveCall)),s=!1){if(!this.checkCanEditWithCounterpartAndSideEffects(this,i,_.RemoveCall,n))return this;const c=this.successCalls.findIndex(y=>y.id===i.id);c>-1&&(this.successCalls.splice(c,1),n==null||n.add(this,H.Affected));const e=this.errorCalls.findIndex(y=>y.id===i.id);return e>-1&&(this.errorCalls.splice(e,1),n==null||n.add(this,H.Affected)),s&&mt(this,n),n==null||n.attemptAutoclose(_.RemoveCall,this.id),this}removeCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-caller")),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.RemoveCaller,n)?(this.calledBySuccess=this.calledBySuccess.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),this.calledByError=this.calledByError.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),this.calledByEntry=this.calledByEntry.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),s&&mt(this,n),n==null||n.attemptAutoclose(_.RemoveCaller,this.id),this):this}addValueReader(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddValueReader))){var e,y,m;if(!this.checkCanEditFromScopeOwnerWithSideEffects(this,_.AddValueReader,n))return this;const s=i.type===d.InputMap&&i.parent.type===d.VariableInstance&&((e=i.declaration)==null?void 0:e.type)===d.Property&&((y=i.declaration)==null?void 0:y.constant),c=i.type===d.VariableInstance&&((m=i.declaration)==null?void 0:m.constant);return(s||c)&&i?(n==null||n.event({id:`${_.SetValueWriter}-${this.id}--${this.id}`,action:_.SetValueWriter,owner:i,counterpart:this,errorReason:Ii.ValueReadingOverridesConstantVariable,rootAction:!1}),n==null||n.attemptAutoclose(_.AddValueReader,this.id),this):this.writesValues.includes(i)?(n==null||n.attemptAutoclose(_.AddValueReader,this.id),this):(this.writesValues.push(i),n==null||n.add(this,H.Affected),this)}setError(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetErrorEntity))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setError] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.SetErrorEntity,this.id),this;const s=this.error;return(s==null?void 0:s.id)!==(i==null?void 0:i.id)&&(s==null||s.remove({ignoreUpstream:!0},n),this.error=i,this.subscribeToDependencies(),n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose(_.SetErrorEntity,this.id),this}setParent(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetParent))){var s;return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.SetParent,n)?(((s=this.parent)==null?void 0:s.id)!==(i==null?void 0:i.id)&&(this.parent=i,n&&(n==null||n.add(this,H.Updated))),n==null||n.attemptAutoclose(_.SetParent,this.id),this):this}initChildren(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"init-children"))){if(this.initialized||this.startedInitialization)return this;if(this.startedInitialization=!0,this.initialData.defaultValue&&(this.defaultValue=me(this.initialData.defaultValue,this.project),this.defaultValue.setParent(this,null),this.defaultValue.initChildren(i)),this.initialData.declaration.type===d.GenericReference){const n=this.project.findSubscribedInstanceFromReference(this.initialData.declaration);if(!n)return this;this.declaration=n}else this.declaration=me(this.initialData.declaration,this.project),this.declaration.initChildren(i);return Pv.initWritesValues(this,this.parent),lf.initReadsValue(this),this.initialData.inputs.forEach(n=>{const s=me(n,this.project);return s.setParent(this,null),s.initChildren(i),this.addInput(s,null),s}),this.initialData.outputs.forEach(n=>{const s=me(n,this.project);return s.setParent(this,null),s.initChildren(i),this.addOutput(s,i),s}),this.successCalls=this.initialData.successCalls.map(n=>{const s=me(n,this.project);if(s.addSuccessCaller(this,null),[d.BreakStatement,d.ContinueStatement].includes(s.type))s.setParent(this.parent.parent,null),s.initChildren(i);else if(s.type===d.ReturnStatement){const c=tn(this,this.project);s.setParent(c,null),s.initChildren(i)}else s.type!==d.InternalCall&&(s.setParent(this.parent,null),s.initChildren(i));return s}),this.errorCalls=this.initialData.errorCalls.map(n=>{const s=me(n,this.project);if(s.addErrorCaller(this,null),[d.BreakStatement,d.ContinueStatement].includes(s.type))s.setParent(this.parent.parent,null),s.initChildren(i);else if(s.type===d.ReturnStatement){const c=tn(this,this.project);s.setParent(c,null),s.initChildren(i)}else s.type!==d.InternalCall&&(s.setParent(this.parent,null),s.initChildren(i));return s}),this.internalCalls=this.initialData.internalCalls.reduce((n,s)=>{if(s.type===d.GenericReference){const c=this.project.findSubscribedInstanceFromReference(s);if(!c)return n;const e=c;return e.setParent(this,null),[...n,e]}else{const c=me(s,this.project);return c.setParent(this,null),c.initChildren(i),[...n,c]}},[]),this.initialData.error&&(this.error=me(this.initialData.error,this.project),this.error.setParent(this,null),this.error.initChildren(i)),this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this}setValueWriter(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetValueWriter))){var s,c,e;return this.checkCanEditFromScopeOwnerWithSideEffects(this,_.SetValueWriter,n)?(s=this.declaration)!=null&&s.constant&&i?(n==null||n.event({id:`${_.SetValueWriter}-${this.id}--${i.id}`,action:_.SetValueWriter,owner:this,counterpart:i,errorReason:Ii.ValueReadingOverridesConstantVariable,rootAction:((c=n==null?void 0:n.self)==null?void 0:c.id)===this.id&&(n==null?void 0:n.autoCloseActionName)===_.SetValueWriter}),n==null||n.attemptAutoclose(_.SetValueWriter,this.id),this):(this.readsValue!==i&&(this.readsValue=i,this.readsValue&&((e=this.defaultValue)==null||e.remove({ignoreUpstream:!1},n)),n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose(_.SetValueWriter,this.id),this):this}removeValueWriter(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveValueWriter))){return this.readsValue&&!this.checkCanEditWithCounterpartAndSideEffects(this,this.readsValue,_.RemoveValueWriter,i)?this:(this.readsValue&&(this.readsValue=null,i==null||i.add(this,H.Updated)),i==null||i.attemptAutoclose(_.RemoveValueWriter,this.id),this)}removeValueReader(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveValueReader))){return this.checkCanEditFromScopeOwnerWithSideEffects(this,_.RemoveValueReader,n)?this.writesValues.includes(i)?(this.writesValues=this.writesValues.filter(s=>s.id!==i.id),n==null||n.add(this,H.Affected),this):(n==null||n.attemptAutoclose(_.RemoveValueReader,this.id),this):this}subscribe(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"meta-sync"))){const s=Mr(this,i,n),c=Lr(this,s),e=this.toMeta();return this.x=s.x||e.x,this.y=s.y||e.y,this.catchesError=s.catchesError!==void 0?s.catchesError:this.catchesError,super.baseMetaSync(s,this,n),s.deleted===!0&&!e.deleted?n==null||n.add(this,H.Removed):s.deleted===!1&&e.deleted?n==null||n.add(this,H.Added):c&&(n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=ke,...n){return await hi.repository.APILoad(this.id,...n),this}async APICreate(i=ke,...n){return await hi.repository.APICreate(this.toShallowJSON(),...n),this}async APIUpdate(i=ke,...n){return await hi.repository.APIUpdate(this.toShallowJSON(),...n),this}async APIDelete(i=ke,...n){return await hi.repository.APIDelete(this.toShallowJSON(),...n),this}async APIClone(i=ke,...n){return await hi.repository.APIClone(this.id,...n),this}async APILoadVersion(i=ke,n,...s){return await hi.repository.APILoadVersion(this.id,n,...s)}removeFromParent(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveFromParent))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[removeFromParent] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveFromParent,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];return this.parent.type===d.Project?(this.parent.removeVariableInstance(this),e.push(this.parent)):this.parent.detachedChildren.includes(this)&&this.parent.unsubscribeDetachedChild(this),i==null||i.attemptAutoclose(_.RemoveFromParent,this.id),{added:D(c),updated:D(n),removed:D(s),affected:D(e),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveEntity))){var m;if(!this.checkCanDelete(this,n))return J.Logger.warn(`[remove] User is not allowed to delete or edit this ${this.type} entity with id: ${this.id}`),n==null||n.event({id:`${_.RemoveEntity}-${this.id}`,action:_.RemoveEntity,owner:this,errorReason:Ii.ActionOwnerEntityNonDeletable,rootAction:((m=n==null?void 0:n.self)==null?void 0:m.id)===this.id&&(n==null?void 0:n.autoCloseActionName)===_.RemoveEntity}),n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const s=[],c=[],e=[],y=[];if(n!=null&&n.hasRemoved(this.id))return n==null||n.attemptAutoclose(_.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},n),Object.values(this.detachedDependents).forEach(v=>{const{updated:E,removed:b,added:w}=v.entity.onDetachedDependencyRemoved(this,v.field,n);s.push(...E),c.push(...b),e.push(...w)}),this.defaultValue){const{updated:v,removed:E}=this.defaultValue.remove({ignoreUpstream:!0},n);s.push(...v),c.push(...E)}if(this.readsValue&&(s.push(this.readsValue),this.readsValue.removeValueReader(this,n)),this.writesValues.forEach(v=>{s.push(v),v.setValueWriter(null,n)}),this.inputs.forEach(v=>{const{updated:E,removed:b}=v.remove({ignoreUpstream:!0},n);s.push(...E),c.push(...b)}),this.outputs.forEach(v=>{const{updated:E,removed:b}=v.remove({ignoreUpstream:!0},n);s.push(...E),c.push(...b)}),this.successCalls.forEach(v=>{s.push(v),v.removeCaller(this,n)}),this.errorCalls.forEach(v=>{s.push(v),v.removeCaller(this,n)}),this.internalCalls.forEach(v=>{const{updated:E,removed:b}=v.remove({ignoreUpstream:!0},n);s.push(...E),c.push(...b)}),!i){const v=this.removeFromParent(n);e.push(...v.added),s.push(...v.updated),c.push(...v.removed),y.push(...v.affected),this.calledBy.forEach(E=>{s.push(E),E.removeCall(this,n)})}return n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:D(e),updated:D(s),removed:D(c),affected:D(y),self:this}}restore({}={},i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RestoreEntity))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[restore] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];if(i!=null&&i.hasAdded(this.id))return i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},i),Object.values(this.detachedDependents).forEach(y=>{const{updated:m,removed:v,added:E}=y.entity.onDetachedDependencyRestored(this,y.field,i);s.push(...m),c.push(...v),n.push(...E)}),this.defaultValue){const{updated:y}=this.defaultValue.restore({},i);s.push(...y)}return this.readsValue&&(s.push(this.readsValue),this.readsValue.addValueReader(this,i)),this.writesValues.forEach(y=>{s.push(y),y.setValueWriter(this,i)}),this.inputs.forEach(y=>{const{updated:m}=y.restore({},i);s.push(...m)}),this.outputs.forEach(y=>{const{updated:m}=y.restore({},i);s.push(...m)}),this.successCalls.forEach(y=>{s.push(y),y.addSuccessCaller(this,i)}),this.errorCalls.forEach(y=>{s.push(y),y.addErrorCaller(this,i)}),this.internalCalls.forEach(y=>{const{updated:m}=y.restore({},i);s.push(...m)}),this.calledBySuccess.forEach(y=>{s.push(y),y.addSuccessCall(this,i)}),this.calledByError.forEach(y=>{s.push(y),y.addErrorCall(this,i)}),this.calledByEntry.forEach(y=>{s.push(y),y.addCall(this,i)}),i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this}}toFlat(i=new Set){var s,c;return i.has(this.id)?[]:(i.add(this.id),[this,...((s=this.defaultValue)==null?void 0:s.toFlat(i))||[],...this.writesValues.flatMap(e=>e.toFlat(i)),...((c=this.readsValue)==null?void 0:c.toFlat(i))||[],...this.successCalls.flatMap(e=>e.toFlat(i)),...this.errorCalls.flatMap(e=>e.toFlat(i)),...this.inputs.flatMap(e=>e.toFlat(i)),...this.outputs.flatMap(e=>e.toFlat(i)),...this.internalCalls.flatMap(e=>e.toFlat(i))])}toFlatIds(i=new Set){var s;return i.has(this.id)?[]:(i.add(this.id),[this.id,...((s=this.defaultValue)==null?void 0:s.toFlatIds(i))||[],...this.writesValues.flatMap(c=>c.toFlatIds(i)),...this.successCalls.flatMap(c=>c.toFlatIds(i)),...this.errorCalls.flatMap(c=>c.toFlatIds(i)),...this.inputs.flatMap(c=>c.toFlatIds(i)),...this.outputs.flatMap(c=>c.toFlatIds(i)),...this.internalCalls.flatMap(c=>c.toFlatIds(i))])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,catchesError:this.catchesError,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,x:this.x,y:this.y,type:this.type,editable:this.editable,deletable:this.deletable}}toJSON(i=new Set){var n,s,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,catchesError:this.catchesError,type:this.type,editable:this.editable,deletable:this.deletable,declaration:this.declaration.toJSON(i),defaultValue:((n=this.defaultValue)==null?void 0:n.toJSON(i))||null,readsValue:((s=this.readsValue)==null?void 0:s.toReference())||null,writesValues:this.writesValues.map(e=>e.toJSON(i)),inputs:this.inputs.map(e=>e.toJSON(i)),outputs:this.outputs.map(e=>e.toJSON(i)),successCalls:this.successCalls.map(e=>e.toJSON(i)),errorCalls:this.errorCalls.map(e=>e.toJSON(i)),internalCalls:this.internalCalls.map(e=>e.toJSON(i)),calledBySuccess:this.calledBySuccess.map(e=>e.toReference()),calledByError:this.calledByError.map(e=>e.toReference()),calledByEntry:this.calledByEntry.map(e=>e.toReference()),parent:this.parent.toReference(),error:((c=this.error)==null?void 0:c.toJSON(i))||null,x:this.x,y:this.y})}toJSONClone(i=ct){var s,c,e,y,m,v,E,b;let n;return(s=i.seenEntityMaps)!=null&&s.has(this.id)?n=i.seenEntityMaps.get(this.id):(n=i.newId||jr(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,n)),(c=i.seenEntities)!=null&&c.has(n)||(e=i.seenEntities)!=null&&e.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((y=i.seenEntities)==null||y.add(n),(m=i.seenEntities)==null||m.add(this.id),{id:n,version:x.UUID.uuid(),createdAt:i.timestamp||M().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,catchesError:this.catchesError,type:this.type,editable:this.editable,deletable:this.deletable,defaultValue:((v=this.defaultValue)==null?void 0:v.toJSONClone({...i,newId:null}))||null,declaration:this.declaration.toReference({seenEntityMaps:i.seenEntityMaps}),readsValue:((E=this.readsValue)==null?void 0:E.toReference({seenEntityMaps:i.seenEntityMaps}))||null,writesValues:this.writesValues.map(w=>w.toJSONClone({...i,newId:null})),inputs:this.inputs.map(w=>w.toJSONClone({...i,newId:null})),outputs:this.outputs.map(w=>w.toJSONClone({...i,newId:null})),successCalls:this.successCalls.map(w=>w.toJSONClone({...i,newId:null})),errorCalls:this.errorCalls.map(w=>w.toJSONClone({...i,newId:null})),internalCalls:this.internalCalls.map(w=>this.calledBy.length||this.readsValue?w.toJSONClone({...i,newId:null}):w.toReference({seenEntityMaps:i.seenEntityMaps})),calledBySuccess:this.calledBySuccess.map(w=>w.toReference({seenEntityMaps:i.seenEntityMaps})),calledByError:this.calledByError.map(w=>w.toReference({seenEntityMaps:i.seenEntityMaps})),calledByEntry:this.calledByEntry.map(w=>w.toReference({seenEntityMaps:i.seenEntityMaps})),error:((b=this.error)==null?void 0:b.toJSONClone({...i,newId:null}))||null,parent:this.parent.toReference({seenEntityMaps:i.seenEntityMaps}),x:this.x,y:this.y})}toReference(i=ct){var s;let n=this.id;return(s=i.seenEntityMaps)!=null&&s.has(this.id)&&(n=i.seenEntityMaps.get(this.id)),{id:n+"--"+x.UUID.uuid()+"--ref",type:d.GenericReference,entityId:n,version:this.version,entityType:this.type}}toShallowJSON(i=ct){var s,c,e,y,m;let n=this.id;return(s=i.seenEntityMaps)!=null&&s.has(this.id)&&(n=i.seenEntityMaps.get(this.id)),{id:n,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,catchesError:this.catchesError,type:this.type,editable:this.editable,deletable:this.deletable,x:this.x,y:this.y,defaultValue:((c=this.defaultValue)==null?void 0:c.toReference(i))||null,declaration:((e=this.declaration)==null?void 0:e.toReference(i))||null,readsValue:((y=this.readsValue)==null?void 0:y.toReference(i))||null,writesValues:this.writesValues.map(v=>v.toReference(i)),inputs:this.inputs.map(v=>v.toReference(i)),outputs:this.outputs.map(v=>v.toReference(i)),successCalls:this.successCalls.map(v=>v.toReference(i)),errorCalls:this.errorCalls.map(v=>v.toReference(i)),calledBySuccess:this.calledBySuccess.map(v=>v.toReference(i)),calledByError:this.calledByError.map(v=>v.toReference(i)),calledByEntry:this.calledByEntry.map(v=>v.toReference(i)),internalCalls:this.internalCalls.map(v=>v.toReference(i)),error:((m=this.error)==null?void 0:m.toReference(i))||null,parent:this.parent.toReference(i)}}toFlatJSON(i=new Set){var s,c;return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...((s=this.defaultValue)==null?void 0:s.toFlatJSON(i))||[],...((c=this.declaration)==null?void 0:c.toFlatJSON(i))||[],...this.writesValues.flatMap(e=>e.toFlatJSON(i)),...this.successCalls.flatMap(e=>e.toFlatJSON(i)),...this.errorCalls.flatMap(e=>e.toFlatJSON(i)),...this.inputs.flatMap(e=>e.toFlatJSON(i)),...this.outputs.flatMap(e=>e.toFlatJSON(i)),...this.internalCalls.flatMap(e=>e.toFlatJSON(i)),...this.calledBy.flatMap(e=>e.toFlatJSON(i))])}toGenerationTarget(){const i=this.parent.type===d.Project?void 0:this.parent.id;return{id:this.id,type:this.type,declaration:this.declaration.id,calledByEntry:this.calledByEntry.map(n=>n.id),calledBySuccess:this.calledBySuccess.map(n=>n.id),calledByError:this.calledByError.map(n=>n.id),parent:i}}toFlatGenerationTarget(i=new Set){var s,c,e;return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...((s=this.defaultValue)==null?void 0:s.toFlatGenerationTarget(i))||[],...((c=this.declaration)==null?void 0:c.toFlatGenerationTarget(i))||[],...((e=this.readsValue)==null?void 0:e.toFlatGenerationTarget(i))||[],...this.writesValues.flatMap(y=>y.toFlatGenerationTarget(i)),...this.successCalls.flatMap(y=>y.toFlatGenerationTarget(i)),...this.errorCalls.flatMap(y=>y.toFlatGenerationTarget(i)),...this.inputs.flatMap(y=>y.toFlatGenerationTarget(i)),...this.outputs.flatMap(y=>y.toFlatGenerationTarget(i)),...this.internalCalls.flatMap(y=>y.toFlatGenerationTarget(i))])}clearErrors(){var i;return this.errors=[],(i=this.defaultValue)==null||i.clearErrors(),this.inputs.forEach(n=>n.clearErrors()),this.outputs.forEach(n=>n.clearErrors()),this.successCalls.forEach(n=>n.clearErrors()),this.errorCalls.forEach(n=>n.clearErrors()),this.internalCalls.forEach(n=>n.clearErrors()),this}validate(){return this.errors=FLe(this),{success:!0}}async validateAsync(i={}){const n=J.YieldTracker.from(i);return this.errors=await KLe(this,{tracker:n}),{success:!0}}getErrors(){var n;return[...this.errors,...((n=this.defaultValue)==null?void 0:n.getErrors())||[],...this.inputs.flatMap(s=>s.getErrors()),...this.internalCalls.flatMap(s=>s.getErrors()),...this.outputs.flatMap(s=>s.getErrors())]}async getErrorsAsync(i={}){var e;const n=J.YieldTracker.from(i),s=[...this.errors];await n.tick();const c=await((e=this.defaultValue)==null?void 0:e.getErrorsAsync({tracker:n}));c&&s.push(...c);for(const y of this.inputs){const m=await y.getErrorsAsync({tracker:n});s.push(...m)}for(const y of this.internalCalls){const m=await y.getErrorsAsync({tracker:n});s.push(...m)}for(const y of this.outputs){const m=await y.getErrorsAsync({tracker:n});s.push(...m)}return s}getShallowErrors(){return this.errors}getDefaultValue(){var i;return this.defaultValue||((i=this.declaration)==null?void 0:i.defaultValue)||null}setDefaultValue(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"set-default-value"))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setDefaultValue] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("set-default-value",this.id),this;const s=this.defaultValue;if((s==null?void 0:s.id)!==(i==null?void 0:i.id)){if(s==null||s.remove({ignoreUpstream:!0},n),this.defaultValue=i,this.defaultValue){const c=this.readsValue;this.removeValueWriter(n),c==null||c.removeValueReader(this,n)}n==null||n.add(this,H.Affected)}return n==null||n.attemptAutoclose("set-default-value",this.id),this}clone(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.CloneEntity)),n=null,s=null,c=!0){var $,L,k,K;const e=Rr(n,this),y=this.toJSON(),m=s||x.UUID.uuid();y.inputs=[],y.id=m,y.version=x.UUID.uuid(),y.createdAt=(i==null?void 0:i.timestamp)||M().toISOString(),y.author=(i==null?void 0:i.author)||"1",y.previousVersion=null,y.deleted=!1,y.deletable=!0,y.editable=!0;const v=Si(y,e);n?v.setParent(n,i):v.setParent(this.parent,null),c&&v.subscribe(),v.initChildren(i),i==null||i.add(v,H.Added);const E=($=this.defaultValue)==null?void 0:$.clone(i,v,x.UUID.uuid(),c);v.defaultValue=E||null;const b=(L=this.inputs)==null?void 0:L.map(S=>S.clone(i,v,x.UUID.uuid(),c));v.inputs=b;const w=(k=this.outputs)==null?void 0:k.map(S=>S.clone(i,v,x.UUID.uuid(),c));v.outputs=w;const V=(K=this.internalCalls)==null?void 0:K.map(S=>S.clone(i,v,x.UUID.uuid(),c));return v.internalCalls=V,i==null||i.attemptAutoclose(_.CloneEntity,this.id),v}addInternalCall(i){return this.internalCalls.find(n=>n===i)||this.internalCalls.push(i),this}setDeclaration(i){return this.declaration!==i&&(this.declaration=i),this}removeUnrecognizedInputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveUnrecognizedInputs))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[removeUnrecognizedInputs] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveUnrecognizedInputs,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];return this.declaration.dataType&&!this.declaration.dataType.isObject()?[...this.inputs].forEach(y=>{const m=y.remove({ignoreUpstream:!1},i);c.push(...m.removed),n.push(...m.updated)}):this.declaration.dataType&&this.declaration.dataType.hasStrictObjectStructure()&&[...this.inputs].forEach(y=>{var v;if(!y.declaration){const E=y.remove({ignoreUpstream:!1},i);c.push(...E.removed),n.push(...E.updated);return}if(![...((v=this.declaration.dataType)==null?void 0:v.entity).allProperties].find(E=>y.declaration===E)){const E=y.remove({ignoreUpstream:!1},i);c.push(...E.removed),n.push(...E.updated)}}),i==null||i.attemptAutoclose(_.RemoveUnrecognizedInputs,this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}removeUnrecognizedOutputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-unrecognized-variable-instance-outputs"))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[removeUnrecognizedOutputs] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveUnrecognizedOutputs,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];return this.declaration.dataType&&!this.declaration.dataType.isObject()?[...this.outputs].forEach(y=>{const m=y.remove({ignoreUpstream:!1},i);c.push(...m.removed),n.push(...m.updated)}):this.declaration.dataType&&this.declaration.dataType.hasStrictObjectStructure()&&[...this.outputs].forEach(y=>{var v;if(!y.declaration){const E=y.remove({ignoreUpstream:!1},i);c.push(...E.removed),n.push(...E.updated);return}if(![...((v=this.declaration.dataType)==null?void 0:v.entity).allProperties].find(E=>y.declaration===E)){const E=y.remove({ignoreUpstream:!1},i);c.push(...E.removed),n.push(...E.updated)}}),i==null||i.attemptAutoclose("remove-unrecognized-variable-instance-outputs",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}removeUnrecognizedInternalCalls(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-unrecognized-variable-declaration-internal-calls"))){const n=[],s=[],c=[],e=[];if(!this.declaration.dataType||!this.declaration.dataType.entity||![d.DefinitionEntity,d.PrimitiveEntity,d.BuiltInBaseEntity].includes(this.declaration.dataType.entity.type))[...this.internalCalls].forEach(m=>{const v=m.remove({ignoreUpstream:!1},i);c.push(...v.removed),n.push(...v.updated)});else if(this.declaration.dataType&&this.declaration.dataType.entity&&[d.DefinitionEntity,d.PrimitiveEntity,d.BuiltInBaseEntity].includes(this.declaration.dataType.entity.type)){const m=[...this.declaration.dataType.entity.getAllInteractiveMethods()],v=[...m].filter(E=>!m.some(b=>{var w,V;return b.id!==E.id&&(((w=b.implements)==null?void 0:w.id)===E.id||((V=b.extends)==null?void 0:V.id)===E.id)})&&!E.deleted);[...this.internalCalls].forEach(E=>{if(!E.declaration){const w=E.remove({ignoreUpstream:!1},i);c.push(...w.removed),n.push(...w.updated);return}if(!v.find(w=>E.declaration===w)){const w=E.remove({ignoreUpstream:!1},i);c.push(...w.removed),n.push(...w.updated);return}})}return this.internalCalls.filter((m,v)=>{const E=this.internalCalls.findIndex(w=>w.declaration===m.declaration&&w!==m);if(E===-1)return!1;const b=this.internalCalls[E];return M(b==null?void 0:b.createdAt).isSame(M(m.createdAt))?v>E:!!M(b==null?void 0:b.createdAt).isAfter(m.createdAt)}).forEach(m=>{const v=m.remove({ignoreUpstream:!1},i);c.push(...v.removed),n.push(...v.updated)}),i==null||i.attemptAutoclose("remove-unrecognized-variable-declaration-internal-calls",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}syncInputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"sync-variable-instance-inputs"))){const n=[],s=[],c=[],e=[];if(this.declaration.dataType)if(this.declaration.dataType.entity){if([d.DefinitionEntity,d.PrimitiveEntity,d.BuiltInBaseEntity].includes(this.declaration.dataType.entity.type)&&!this.declaration.dataType.isList){const y=[...this.declaration.dataType.entity.properties];y.filter(b=>!b.getDataType(i)).forEach(b=>{const w=this.inputs.find(L=>se(L,this.project)===se(b,this.project));if(!w)return;const V=this.declaration.getMasterInputWithValueWritterFromAllInstances(w);if(!V)return;const $=md(V);b.setDataType($,i),w.setDeclaration(b,i)}),y.filter(b=>!this.inputs.find(w=>{var V;return((V=w.declaration)==null?void 0:V.id)===b.id})).forEach(b=>{const w={dataType:null,id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||M().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.InputMap,parentRelationType:null,parent:this.toReference(),name:null,description:null,codeName:null,declaration:b,defaultValue:null,index:b.index,readsValue:null},V=me(w,this.project);return V.setParent(this,i),V.initChildren(i),i==null||i.add(V,H.Added),this.addInput(V,i),V}),this.inputs.filter(b=>!b.declaration).forEach(b=>{const w=y.find(V=>se(V,this.project)===se(b,this.project));w&&b.setDeclaration(w,i)})}}else return i==null||i.attemptAutoclose("sync-variable-instance-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};else return i==null||i.attemptAutoclose("sync-variable-instance-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};return i==null||i.attemptAutoclose("sync-variable-instance-inputs",this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this}}syncOutputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SyncOutputs))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[syncOutputs] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.SyncOutputs,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];if(this.declaration.dataType)if(this.declaration.dataType.entity)[d.DefinitionEntity,d.PrimitiveEntity,d.BuiltInBaseEntity].includes(this.declaration.dataType.entity.type)&&!this.declaration.dataType.isList&&[...this.declaration.dataType.entity.properties].filter(v=>!this.outputs.find(E=>E.declaration===v)).map(v=>{const E={dataType:null,id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||M().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.OutputMap,parent:this.toReference(),declaration:v,index:v.index,writesValues:[]},b=me(E,this.project);return b.setParent(this,i),b.initChildren(i),i==null||i.add(b,H.Added),this.addOutput(b,i),b});else return i==null||i.attemptAutoclose(_.SyncOutputs,this.id),{added:[],updated:[],removed:[],affected:[],self:this};else return i==null||i.attemptAutoclose(_.SyncOutputs,this.id),{added:[],updated:[],removed:[],affected:[],self:this};return i==null||i.attemptAutoclose(_.SyncOutputs,this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this}}generateUnusedInternalCalls(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"generate-unused-internal-calls"))){const n=[],s=[],c=[],e=[];if(this.declaration.dataType)if(this.declaration.dataType.entity){if([d.DefinitionEntity,d.PrimitiveEntity,d.BuiltInBaseEntity].includes(this.declaration.dataType.entity.type)&&!this.declaration.dataType.isList){const y=[...this.declaration.dataType.entity.getAllInteractiveMethods()];[...y].filter(E=>!y.some(b=>{var w,V;return b.id!==E.id&&(((w=b.implements)==null?void 0:w.id)===E.id||((V=b.extends)==null?void 0:V.id)===E.id)})&&!E.deleted).filter(E=>!this.internalCalls.find(w=>{var $,L,k,K,S;return((($=w.declaration)==null?void 0:$.id)||((k=(L=w.initialData)==null?void 0:L.declaration)==null?void 0:k.entityId)||((S=(K=w.initialData)==null?void 0:K.declaration)==null?void 0:S.id))===E.id})).forEach(E=>{const b=this.internalCalls.find(w=>{const V=Pc(w.declaration),$=Pc(E);return V.id===$.id});if(b)b.setDeclaration(E),b.subscribeToDependencies();else{const w=E.createInternalCall(i,this);i==null||i.add(w,H.Added),this.addInternalCall(w)}})}}else return i==null||i.attemptAutoclose("generate-unused-internal-calls",this.id),{added:[],updated:[],removed:[],affected:[],self:this};else return i==null||i.attemptAutoclose("generate-unused-internal-calls",this.id),{added:[],updated:[],removed:[],affected:[],self:this};return i==null||i.attemptAutoclose("generate-unused-internal-calls",this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this}}getDataType(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"get-data-type"))){var s;const n=((s=this.declaration)==null?void 0:s.getDataType(i))||null;return i==null||i.attemptAutoclose("get-data-type",this.id),n}getUnusedInputs(){return this.inputs.filter(i=>i.suggestion||!i.readsValue&&!i.defaultValue)}getUnusedOutputs(){return this.outputs.filter(i=>i.suggestion||!i.writesValues.length)}getUsedInputs(){return this.inputs.filter(i=>!i.suggestion&&(i.readsValue||i.defaultValue))}getUsedOutputs(){return this.outputs.filter(i=>!i.suggestion&&i.writesValues.length)}};I(hi,"repository",{APICreate:async(i,...n)=>i,APIUpdate:async(i,...n)=>i,APIDelete:async(i,...n)=>i,APIClone:async(i,...n)=>{},APILoad:async(i,...n)=>null,APILoadVersion:async(i,n,...s)=>null}),I(hi,"type",d.VariableInstance),I(hi,"USER_MANAGED_PARENT_TYPES",[...nr,d.Project]),I(hi,"PARENT_TYPES",[...hi.USER_MANAGED_PARENT_TYPES]),I(hi,"MUTABLE_BASE_PROPERTIES",["catchesError"]),I(hi,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),I(hi,"BASE_PROPERTIES",[...hi.MUTABLE_BASE_PROPERTIES,...hi.INMUTABLE_BASE_PROPERTIES]),I(hi,"MUTABLE_META_PROPERTIES",[...hi.MUTABLE_BASE_PROPERTIES,"x","y"]),I(hi,"INMUTABLE_META_PROPERTIES",[...hi.INMUTABLE_BASE_PROPERTIES]),I(hi,"META_PROPERTIES",[...hi.MUTABLE_META_PROPERTIES,...hi.INMUTABLE_META_PROPERTIES]),I(hi,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry","readsValue"]),I(hi,"INMUTABLE_UPSTREAM_PROPERTIES",["declaration","parent"]),I(hi,"UPSTREAM_PROPERTIES",[...hi.MUTABLE_UPSTREAM_PROPERTIES,...hi.INMUTABLE_UPSTREAM_PROPERTIES]),I(hi,"MUTABLE_DOWNSTREAM_PROPERTIES",["writesValues","inputs","outputs","successCalls","errorCalls","internalCalls"]),I(hi,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),I(hi,"DOWNSTREAM_PROPERTIES",[...hi.MUTABLE_DOWNSTREAM_PROPERTIES,...hi.INMUTABLE_DOWNSTREAM_PROPERTIES]),I(hi,"PROPERTIES",[...hi.META_PROPERTIES,...hi.UPSTREAM_PROPERTIES,...hi.DOWNSTREAM_PROPERTIES]);let Bu=hi;var SLe=(o=>(o.Parent="variable-declaration-parent",o.DataTypeEntity="variable-declaration-data-type-entity",o.DataType="variable-declaration-data-type",o))(SLe||{});const mi=class mi extends Ur{constructor(i,n){super(i);I(this,"initialData");I(this,"id");I(this,"name");I(this,"codeName",null);I(this,"description",null);I(this,"required",!1);I(this,"constant",!1);I(this,"x");I(this,"y");I(this,"type",d.VariableDeclaration);I(this,"catchesError",!1);I(this,"defaultValue",null);I(this,"dataType",null);I(this,"writesValues",[]);I(this,"readsValue",null);I(this,"inputs",[]);I(this,"outputs",[]);I(this,"error",null);I(this,"calledBySuccess",[]);I(this,"calledByError",[]);I(this,"calledByEntry",[]);I(this,"successCalls",[]);I(this,"errorCalls",[]);I(this,"internalCalls",[]);I(this,"parent");I(this,"errors",[]);I(this,"project");I(this,"detachedDependents",{});I(this,"knownVersions",null);I(this,"activeVersion",!1);I(this,"initialized",!1);I(this,"startedInitialization",!1);I(this,"suggestion",!1);I(this,"codeNativeValueValidation",null);this.initialData=i,this.project=n,this.id=i.id,this.name=i.name,this.description=i.description,this.constant=i.constant,this.codeName=i.codeName,this.required=i.required,this.x=i.x,this.y=i.y,this.catchesError=i.catchesError||!1}static new(i=null){return{id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||M().toISOString(),author:(i==null?void 0:i.author)||x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.VariableDeclaration,catchesError:!1,name:"",codeName:null,description:"",dataType:null,internalCalls:[],successCalls:[],errorCalls:[],readsValue:null,writesValues:[],defaultValue:null,constant:!1,required:!1,inputs:[],outputs:[],parent:null,calledByEntry:[],calledBySuccess:[],calledByError:[],error:null,x:0,y:0}}static fromGenerationTarget(i,n){let s=n;if(i.parent){const b=ne(i.parent);s=n.get(b)}const c=i.calledByEntry.map(b=>{const w=ne(b);return n.get(w)}),e=i.calledBySuccess.map(b=>{const w=ne(b);return n.get(w)}),y=i.calledByError.map(b=>{const w=ne(b);return n.get(w)});let m=null;if(i.readsValue){const b=ne(i.readsValue);m=n.get(b)}const v={id:i.id,version:x.UUID.uuid(),createdAt:M().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.VariableDeclaration,catchesError:i.catchesError||!1,name:i.name,defaultValue:null,codeName:i.codeName||null,description:i.description||null,constant:i.constant||!1,required:i.required||!1,calledByEntry:c,calledBySuccess:e,calledByError:y,dataType:null,errorCalls:[],successCalls:[],internalCalls:[],readsValue:m,inputs:[],outputs:[],writesValues:[],error:null,x:0,y:0,parent:s},E=me(v,n);return E.setParent(s,null),E}static validateGenerationTarget(i,n){let s=JSON.parse(JSON.stringify(i));const c=[],e=bn(s,{parent:{list:!1,types:[...nr,d.Project],optional:!0}},n);s=e.modifiedData;const y=CP(s,n);return c.push(...e.errors,...y,...$r(s)),{errors:c,modifiedData:s}}get variableInstances(){const i=[];return Object.values(this.detachedDependents).forEach(n=>{n.field===gN.VarDeclaration&&!i.includes(n.entity)&&i.push(n.entity)}),i}validateGeneratedUpdate(i){const n=[];let s=JSON.parse(JSON.stringify(i));const c=sf(s,this);return s=c.modifiedData,n.push(...c.errors),i.parent&&n.push(new De({id:`${this.id}--${ae.InvalidParentUpdate}`,code:ae.InvalidParentUpdate,severity:ce.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated. The 'parent' on a callable entity, is its scope. It scope is auto-calculated implicitly by the its caller.
|
|
96
96
|
If an entity is called by another, they must be in the same scope, which means they have the same parent.
|
|
97
97
|
Specifically for variables, their scope is also calculated from their value readers and value writters.
|
|
98
|
-
You shouldn't have to manually update a 'parent' property. The equivalent result is to change its value readers, value writters, or callers.`})),{errors:n,modifiedData:s}}subscribeDependents(i){return i.forEach(n=>{this.detachedDependents[n.entity.id]||(this.detachedDependents[n.entity.id]=n)}),this}unsubscribeDependents(i){return i.forEach(n=>{this.detachedDependents[n.entity.id]&&delete this.detachedDependents[n.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"sync-dependents"))){const n=[],s=[],c=[],e=[];return Object.values(this.detachedDependents).forEach(y=>{const m=y.entity.afterAllChildrenInitialized(i);n.push(...m.updated),s.push(...m.added),c.push(...m.removed),e.push(...m.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}onDetachedDependencyRemoved(i,n,s){const c=[],e=[],y=[],m=[];if(n==="variable-declaration-parent"){const{updated:v,added:E,removed:b}=this.remove({ignoreUpstream:!1},s);c.push(...v),e.push(...E),y.push(...b)}return{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:this}}onDetachedDependencyRestored(i,n,s){const c=[],e=[],y=[],m=[];if(n==="variable-declaration-parent"){const{updated:v,added:E,removed:b}=this.restore({},s);c.push(...v),e.push(...E),y.push(...b)}return{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:this}}unsubscribeFromDependencies(){var i,n,s,c,e,y;return(i=this.parent)==null||i.unsubscribeDependents([{entity:this,field:"variable-declaration-parent"}]),(c=(s=(n=this.dataType)==null?void 0:n.entity)==null?void 0:s.unsubscribeDependents)==null||c.call(s,[{entity:this,field:"variable-declaration-data-type-entity"}]),(y=(e=this.dataType)==null?void 0:e.unsubscribeDependents)==null||y.call(e,[{entity:this,field:"variable-declaration-data-type"}]),this}subscribeToDependencies(){var i,n,s,c,e,y;return(i=this.parent)==null||i.subscribeDependents([{entity:this,field:"variable-declaration-parent"}]),(c=(s=(n=this.dataType)==null?void 0:n.entity)==null?void 0:s.subscribeDependents)==null||c.call(s,[{entity:this,field:"variable-declaration-data-type-entity"}]),(y=(e=this.dataType)==null?void 0:e.subscribeDependents)==null||y.call(e,[{entity:this,field:"variable-declaration-data-type"}]),this}increaseVersion(i){if(i&&!M(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&M(i).isSame(M(this.createdAt))?this:(this.previousVersion=this.version,this.version=x.UUID.uuid(),this.createdAt=M(i).toISOString()||M().toISOString(),this)}captureVersion(){var n;const i=((n=this.knownVersions)==null?void 0:n.get(this.version))||new mi(this,this.project);return i.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map([[this.version,i]]),i.inputs=[...this.inputs],i.outputs=[...this.outputs],i.internalCalls=[...this.internalCalls],i.successCalls=[...this.successCalls],i.errorCalls=[...this.errorCalls],i.writesValues=[...this.writesValues],i.readsValue=this.readsValue,i.defaultValue=this.defaultValue,i.dataType=this.dataType,i.calledBySuccess=[...this.calledBySuccess],i.calledByError=[...this.calledByError],i.calledByEntry=[...this.calledByEntry],i.error=this.error,i.parent=this.parent,this}recursiveCaptureUpstreamVersions(i){const n=[],s=[],c=[],e=[];if(this.parent){this.parent.increaseVersion(i);const y=this.parent.recursiveCaptureUpstreamVersions(i);n.push(this.parent,...y.updated),s.push(...y.added),c.push(...y.removed)}return{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}async restoreVersion(i){var m;const n=[],s=[],c=[],e=[];if(this.version===i)return{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this};if(!this.knownVersions){const v=new Map;for(const[E,b]of this.knownVersions||new Map){if(v.set(E,b),b.activeVersion=!1,b.knownVersions)for(const[w,V]of b.knownVersions)v.set(w,V);b.knownVersions=null}}let y=(m=this.knownVersions)==null?void 0:m.get(i);if(!y){const v=await this.APILoadVersion({},i);if(!v)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);y=new mi(v,this.project)}return this.metaSync(y.toShallowJSON(),null),this.previousVersion=y.previousVersion,this.version=y.version,this.createdAt=y.createdAt,this.author=y.author,this.deleted=y.deleted,this.inputs=y.inputs,this.outputs=y.outputs,this.internalCalls=y.internalCalls,this.successCalls=y.successCalls,this.errorCalls=y.errorCalls,this.writesValues=y.writesValues,this.readsValue=y.readsValue,this.defaultValue=y.defaultValue,this.dataType=y.dataType,this.calledBySuccess=y.calledBySuccess,this.calledByError=y.calledByError,this.calledByEntry=y.calledByEntry,this.error=y.error,this.parent=y.parent,{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}updateWithShallowTransfer(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.UpdateWithShallowTransfer))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[updateWithShallowTransfer] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),this;if(this.metaSync(i,n),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 s=ne(i.parent),c=this.project.get(s),e=this.parent;if(e&&e.id!==(c==null?void 0:c.id)&&this.removeFromParent(n),c)this.setParent(c,n),this.addSelfToProject(n);else throw n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${s}' that isn't found in the project`)}else throw n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(i.readsValue){const s=ne(i.readsValue),c=this.project.get(s),e=this.readsValue;e&&e.id!==(c==null?void 0:c.id)&&this.removeValueWriter(n),c&&this.setValueWriter(c,n)}else this.removeValueWriter(n);if(i.calledByEntry.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addEntryCaller(e,n),e.addCall(this,n))}),[...this.calledByEntry].forEach(s=>{i.calledByEntry.find(e=>ne(e)===s.id)||(this.removeCaller(s,n),s.removeCall(this,n))}),i.calledBySuccess.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addSuccessCaller(e,n),e.addSuccessCall(this,n))}),[...this.calledBySuccess].forEach(s=>{i.calledBySuccess.find(e=>ne(e)===s.id)||(this.removeCaller(s,n),s.removeCall(this,n))}),i.calledByError.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addErrorCaller(e,n),e.addErrorCall(this,n))}),[...this.calledByError].forEach(s=>{i.calledByError.find(e=>ne(e)===s.id)||(this.removeCaller(s,n),s.removeCall(this,n))}),i.outputs.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addOutput(e,n),e.setParent(this,n))}),[...this.outputs].forEach(s=>{i.outputs.find(e=>ne(e)===s.id)||(this.removeOutput(s,n),s.removeFromParent(n))}),i.inputs.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addInput(e,n),e.setParent(this,n))}),[...this.inputs].forEach(s=>{i.inputs.find(e=>ne(e)===s.id)||(this.removeInput(s,n),s.removeFromParent(n))}),i.dataType){const s=ne(i.dataType),c=this.project.get(s);c&&this.setDataType(c,n)}else this.setDataType(null,n);if(i.defaultValue){const s=ne(i.defaultValue),c=this.project.get(s);c&&this.setDefaultValue(c,n)}else this.setDefaultValue(null,n);return i.writesValues.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addValueReader(e,n),e.setValueWriter(this,n))}),[...this.writesValues].forEach(s=>{i.writesValues.find(e=>ne(e)===s.id)||(this.removeValueReader(s,n),s.setValueWriter(null,n))}),this.captureVersion(),this.subscribeToDependencies(),n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),this}hydrateAncestors(){const i=[],n=[],s=[],c=[];if(this.initialData.parent){const e=ne(this.initialData.parent),y=this.project.get(e);if(y)this.setParent(y,null),i.push(y);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.readsValue){const e=ne(this.initialData.readsValue),y=this.project.get(e);y&&(this.setValueWriter(y,null),i.push(y))}return this.initialData.calledByEntry.forEach(e=>{const y=ne(e),m=this.project.get(y);m&&this.addEntryCaller(m,null)}),this.initialData.calledBySuccess.forEach(e=>{const y=ne(e),m=this.project.get(y);m&&this.addSuccessCaller(m,null)}),this.initialData.calledByError.forEach(e=>{const y=ne(e),m=this.project.get(y);m&&this.addErrorCaller(m,null)}),{updated:D(i),added:D(n),removed:D(s),affected:D(c),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AfterAllChildrenInitialized))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[afterAllChildrenInitialized] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.AfterAllChildrenInitialized,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];if(this.initialized=!0,!this.dataType||this.dataType.inferred){const{added:Ne,updated:Be,removed:Se,affected:je}=this.inferDataTypeAndSyncInstancesInputsAndOutputs(i);s.push(...Ne),n.push(...Be),c.push(...Se),e.push(...je)}const{added:y,updated:m,removed:v,affected:E}=this.syncInputs(i);s.push(...y),n.push(...m),c.push(...v),e.push(...E);const{added:b,updated:w,removed:V,affected:$}=this.syncOutputs(i);s.push(...b),n.push(...w),c.push(...V),e.push(...$);const{added:L,updated:k,removed:K,affected:S}=this.generateUnusedInternalCalls(i);s.push(...L),n.push(...k),c.push(...K),e.push(...S);const{added:Y,updated:re,removed:ee,affected:de}=this.removeUnrecognizedInputs(i);s.push(...Y),n.push(...re),c.push(...ee),e.push(...de);const{added:le,updated:fe,removed:ve,affected:ue}=this.removeUnrecognizedOutputs(i);s.push(...le),n.push(...fe),c.push(...ve),e.push(...ue);const{added:ye,updated:Ve,removed:_e,affected:$e}=this.removeUnrecognizedInternalCalls(i);return s.push(...ye),n.push(...Ve),c.push(..._e),e.push(...$e),this.parent===this.project&&(this.catchesError&&(i==null||i.event({id:`${_.RemoveErrorCatching}-${this.id}`,action:_.RemoveErrorCatching,owner:this,errorReason:Ii.GlobalVariableDeclarationCannnotCatchError,rootAction:!1}),this.metaSync({catchesError:!1},i)),this.errorCalls.length&&(i==null||i.event({id:`${_.RemoveAllErrorCalls}-${this.id}`,action:_.RemoveAllErrorCalls,owner:this,errorReason:Ii.GlobalVariableDeclarationCannotCallFromError,rootAction:!1}),[...this.errorCalls].forEach(Ne=>{this.removeCall(Ne,i),Ne.removeCaller(this,i)})),this.calledBy.length&&(i==null||i.event({id:`${_.RemoveAllCallers}-${this.id}`,action:_.RemoveAllCallers,owner:this,errorReason:Ii.GlobalVariableDeclarationCannotBeCalled,rootAction:!1}),[...this.calledBy].forEach(Ne=>{this.removeCaller(Ne,i),Ne.removeCall(this,i)}))),this.inputs.sort((Ne,Be)=>{var Se,je;return(Ne.index??((Se=Ne.declaration)==null?void 0:Se.index))-(Be.index??((je=Be.declaration)==null?void 0:je.index))}),this.outputs.sort((Ne,Be)=>{var Se,je;return(Ne.index??((Se=Ne.declaration)==null?void 0:Se.index))-(Be.index??((je=Be.declaration)==null?void 0:je.index))}),this.captureVersion(),i==null||i.attemptAutoclose(_.AfterAllChildrenInitialized,this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}addSelfToProject(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"add-self-to-project"))){const n=[this],s=[],c=[],e=[];return this.parent===this.project&&this.project.addVariableDeclaration(this),this.readsValue&&(this.readsValue.addValueReader(this,i),n.push(this.readsValue)),this.writesValues.forEach(y=>{y.setValueWriter(this,i),n.push(y)}),this.successCalls.forEach(y=>{y.addSuccessCaller(this,i),n.push(y)}),this.errorCalls.forEach(y=>{y.addErrorCaller(this,i),n.push(y)}),this.calledBySuccess.forEach(y=>{y.addSuccessCall(this,i),n.push(y)}),this.calledByError.forEach(y=>{y.addErrorCall(this,i),n.push(y)}),this.calledByEntry.forEach(y=>{y.addCall(this,i),n.push(y)}),this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}get usedInputs(){return this.inputs.filter(i=>i.readsValue||i.defaultValue)}get unusedInputs(){return this.inputs.filter(i=>!i.readsValue&&!i.defaultValue)}get usedOutputs(){return this.outputs.filter(i=>i.writesValues.length)}get unusedOutputs(){return this.outputs.filter(i=>!i.writesValues.length)}get usedInternalCalls(){return this.internalCalls.filter(i=>!!i.calledBy.length)}get unusedInternalCalls(){return this.internalCalls.filter(i=>!i.calledBy.length)}removeInternalCall(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-variable-declaration-internal-call"))){const s=this.internalCalls.findIndex(c=>c.id===i.id);return s>-1&&(this.internalCalls.splice(s,1),n&&(n==null||n.add(this,H.Affected))),n==null||n.attemptAutoclose("remove-variable-declaration-internal-call",this.id),this}removeInput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveInput))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[removeInput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.RemoveInput,this.id),this;const s=this.inputs.findIndex(c=>c.id===i.id);return s>-1&&(this.inputs.splice(s,1),n&&(n==null||n.add(this,H.Affected))),n==null||n.attemptAutoclose(_.RemoveInput,this.id),this}addInput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddInput))){return this.checkCanEdit(this,n)?this.inputs.includes(i)?(n==null||n.attemptAutoclose(_.AddInput,this.id),this):(this.inputs.push(i),n==null||n.add(this,H.Affected),n==null||n.attemptAutoclose(_.AddInput,this.id),this):(J.Logger.warn(`[addInput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.AddInput,this.id),this)}addOutput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"add-output"))){return this.checkCanEdit(this,n)?this.outputs.includes(i)?(n==null||n.attemptAutoclose("add-output",this.id),this):(this.outputs.push(i),n==null||n.add(this,H.Affected),n==null||n.attemptAutoclose("add-output",this.id),this):(J.Logger.warn(`[addOutput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("add-output",this.id),this)}removeOutput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-output"))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[removeOutput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("remove-output",this.id),this;const s=this.outputs.findIndex(c=>c.id===i.id);return s>-1&&(this.outputs.splice(s,1),n&&(n==null||n.add(this,H.Affected))),n==null||n.attemptAutoclose("remove-output",this.id),this}addSuccessCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddSuccessCaller)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddSuccessCaller,n)?(this.calledBySuccess.find(c=>c.id===i.id)||(this.calledBySuccess.push(i),n==null||n.add(this,H.Updated),s&&mt(this,n)),n==null||n.attemptAutoclose(_.AddSuccessCaller,this.id),this):this}addErrorCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddErrorCaller)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddErrorCaller,n)?(this.calledByError.find(c=>c.id===i.id)||(this.calledByError.push(i),n==null||n.add(this,H.Updated),s&&mt(this,n)),n==null||n.attemptAutoclose(_.AddErrorCaller,this.id),this):this}addEntryCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddEntryCaller)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddEntryCaller,n)?(this.calledByEntry.find(c=>c.id===i.id)||(this.calledByEntry.push(i),n==null||n.add(this,H.Updated),s&&mt(this,n)),n==null||n.attemptAutoclose(_.AddEntryCaller,this.id),this):this}addErrorCall(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddErrorCall)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddErrorCall,n)?(this.errorCalls.find(c=>c.id===i.id)||(this.errorCalls.push(i),s&&mt(this,n),n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose(_.AddErrorCall,this.id),this):this}addSuccessCall(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddSuccessCall)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddSuccessCall,n)?(this.successCalls.find(c=>c.id===i.id)||(this.successCalls.push(i),s&&mt(this,n),n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose(_.AddSuccessCall,this.id),this):this}removeCall(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveCall)),s=!1){if(!this.checkCanEditWithCounterpartAndSideEffects(this,i,_.RemoveCall,n))return this;const c=this.successCalls.findIndex(y=>y.id===i.id);c>-1&&(this.successCalls.splice(c,1),n==null||n.add(this,H.Affected));const e=this.errorCalls.findIndex(y=>y.id===i.id);return e>-1&&(this.errorCalls.splice(e,1),n==null||n.add(this,H.Affected)),s&&mt(this,n),n==null||n.attemptAutoclose(_.RemoveCall,this.id),this}removeCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-caller")),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.RemoveCaller,n)?(this.calledBySuccess=this.calledBySuccess.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),this.calledByError=this.calledByError.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),this.calledByEntry=this.calledByEntry.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),s&&mt(this,n),n==null||n.attemptAutoclose(_.RemoveCaller,this.id),this):this}addValueReader(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddValueReader))){var e,y,m;if(!this.checkCanEditFromScopeOwnerWithSideEffects(this,_.AddValueReader,n))return this;const s=i.type===d.InputMap&&i.parent.type===d.VariableInstance&&((e=i.declaration)==null?void 0:e.type)===d.Property&&((y=i.declaration)==null?void 0:y.constant),c=i.type===d.VariableInstance&&((m=i.declaration)==null?void 0:m.constant);return(s||c)&&i?(n==null||n.event({id:`${_.SetValueWriter}-${this.id}--${this.id}`,action:_.SetValueWriter,owner:i,counterpart:this,errorReason:Ii.ValueReadingOverridesConstantVariable,rootAction:!1}),n==null||n.attemptAutoclose(_.AddValueReader,this.id),this):this.writesValues.includes(i)?(n==null||n.attemptAutoclose(_.AddValueReader,this.id),this):(this.writesValues.push(i),n==null||n.add(this,H.Affected),this)}removeValueReader(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveValueReader))){return this.checkCanEditFromScopeOwnerWithSideEffects(this,_.RemoveValueReader,n)?this.writesValues.includes(i)?(this.writesValues=this.writesValues.filter(s=>s.id!==i.id),n==null||n.add(this,H.Affected),this):(n==null||n.attemptAutoclose(_.RemoveValueReader,this.id),this):this}setError(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetErrorEntity))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setError] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.SetErrorEntity,this.id),this;const s=this.error;return(s==null?void 0:s.id)!==(i==null?void 0:i.id)&&(s==null||s.remove({ignoreUpstream:!0},n),this.error=i,this.subscribeToDependencies(),n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose(_.SetErrorEntity,this.id),this}setParent(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetParent))){var s;return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.SetParent,n)?(((s=this.parent)==null?void 0:s.id)!==(i==null?void 0:i.id)&&(this.parent=i,n&&(n==null||n.add(this,H.Updated))),n==null||n.attemptAutoclose(_.SetParent,this.id),this):this}initChildren(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"init-children"))){if(this.initialized||this.startedInitialization)return this;if(this.startedInitialization=!0,this.initialData.defaultValue&&(this.defaultValue=me(this.initialData.defaultValue,this.project),this.defaultValue.setParent(this,null),this.defaultValue.initChildren(i)),this.initialData.dataType){const n=me(this.initialData.dataType,this.project);this.setDataType(n,i),this.dataType.setParent(this,null),this.dataType.initChildren(i)}return Pv.initWritesValues(this,this.parent),lf.initReadsValue(this),this.successCalls=this.initialData.successCalls.map(n=>{const s=me(n,this.project);if(s.addSuccessCaller(this,null),[d.BreakStatement,d.ContinueStatement].includes(s.type))s.setParent(this.parent.parent,null),s.initChildren(i);else if(s.type===d.ReturnStatement){const c=tn(this,this.project);s.setParent(c,null),s.initChildren(i)}else s.type!==d.InternalCall&&(s.setParent(this.parent,null),s.initChildren(i));return s}),this.errorCalls=this.initialData.errorCalls.map(n=>{const s=me(n,this.project);if(s.addErrorCaller(this,null),[d.BreakStatement,d.ContinueStatement].includes(s.type))s.setParent(this.parent.parent,null),s.initChildren(i);else if(s.type===d.ReturnStatement){const c=tn(this,this.project);s.setParent(c,null),s.initChildren(i)}else s.type!==d.InternalCall&&(s.setParent(this.parent,null),s.initChildren(i));return s}),this.initialData.inputs.forEach(n=>{const s=me(n,this.project);return s.setParent(this,null),s.initChildren(i),this.addInput(s,null),s}),this.initialData.outputs.forEach(n=>{const s=me(n,this.project);return s.setParent(this,null),s.initChildren(i),this.addOutput(s,null),s}),this.initialData.internalCalls.forEach(n=>{if(n.type===d.GenericReference){const c=this.project.findSubscribedInstanceFromReference(n);if(!c)return;c.setParent(this,null),c.initChildren(i),this.addInternalCall(c);return}const s=me(n,this.project);return s.setParent(this,null),s.initChildren(i),this.addInternalCall(s),s}),this.initialData.error&&(this.error=me(this.initialData.error,this.project),this.error.setParent(this,null),this.error.initChildren(i)),this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this}setValueWriter(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetValueWriter))){return this.checkCanEditFromScopeOwnerWithSideEffects(this,_.SetValueWriter,n)?(this.readsValue!==i&&(this.readsValue=i,n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose(_.SetValueWriter,this.id),this):this}removeValueWriter(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveValueWriter))){return this.readsValue&&!this.checkCanEditWithCounterpartAndSideEffects(this,this.readsValue,_.RemoveValueWriter,i)?this:(this.readsValue&&(this.readsValue=null,i==null||i.add(this,H.Updated)),i==null||i.attemptAutoclose(_.RemoveValueWriter,this.id),this)}subscribe(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}getMasterInputWithValueWritterFromAllInstances(i){return D([...this.inputs,...this.variableInstances.flatMap(c=>c.inputs)]).find(c=>se(c,this.project)===se(i,this.project)&&!!c.readsValue)||i}inferDataTypeAndSyncInstancesInputsAndOutputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"infer-data-type-and-sync-instances-inputs-and-outputs"))){var K,S,Y,re,ee,de,le;const n=[],s=[],c=[],e=[];if(!this.dataType){const fe=ur.new(i);fe.parent=this.toReference(),fe.inferred=!0;const ve=me(fe,this.project);ve.hydrateAncestors(),ve.addSelfToProject(i),this.setDataType(ve,i),ve.setParent(this,i),ve.initChildren(i),i==null||i.add(ve,H.Added),ve.metaSync({inferred:!0,like:!0},i)}if(this.readsValue&&((K=this.dataType)!=null&&K.inferred)){const fe=this.readsValue.getDataType(null);fe&&((S=this.dataType)==null||S.merge(fe,i),this.dataType.metaSync({inferred:!0,like:!0},i))}const y=D([...this.inputs,...this.variableInstances.flatMap(fe=>fe.inputs)]),m=[];if(y.forEach(fe=>{m.find(ue=>se(ue,this.project)===se(fe,this.project))||m.push(fe)}),(!((Y=this.dataType)!=null&&Y.entity)||((ee=(re=this.dataType)==null?void 0:re.entity)==null?void 0:ee.type)===d.DefinitionEntity&&((de=this.dataType)==null?void 0:de.entity.parent)===this.dataType)&&((le=this.dataType)==null||le.inferFromInputs(m,i)),!this.dataType)return i==null||i.attemptAutoclose("infer-data-type-and-sync-instances-inputs-and-outputs",this.id),{updated:D(s),added:D(n),removed:D(c),affected:D(e),self:this};const{updated:v,added:E,removed:b,affected:w}=this.syncInputs(i);n.push(...E),s.push(...v),c.push(...b),e.push(...w);const{updated:V,added:$,removed:L,affected:k}=this.syncOutputs(i);return n.push(...$),s.push(...V),c.push(...L),e.push(...k),this.variableInstances.forEach(fe=>{const{updated:ve,added:ue,removed:ye,affected:Ve}=fe.syncInputs(i);n.push(...ue),s.push(...ve),c.push(...ye),e.push(...Ve);const{updated:_e,added:$e,removed:Ne,affected:Be}=fe.syncOutputs(i);n.push(...$e),s.push(..._e),c.push(...Ne),e.push(...Be)}),i==null||i.attemptAutoclose("infer-data-type-and-sync-instances-inputs-and-outputs",this.id),{updated:D(s),added:D(n),removed:D(c),affected:D(e),self:this}}metaSync(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"meta-sync"))){const s=Mr(this,i,n),c=Lr(this,s),e=this.toMeta();return this.name=s.name!==void 0?s.name:e.name,this.codeName=s.codeName!==void 0?s.codeName:e.codeName,this.description=s.description!==void 0?s.description:e.description,this.x=s.x||e.x,this.y=s.y||e.y,this.constant=s.constant!==void 0?s.constant:e.constant,this.required=s.required!==void 0?s.required:e.required,this.catchesError=s.catchesError!==void 0?s.catchesError:this.catchesError,super.baseMetaSync(s,this,n),s.deleted===!0&&!e.deleted?n==null||n.add(this,H.Removed):s.deleted===!1&&e.deleted?n==null||n.add(this,H.Added):c&&(n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=ke,...n){return await mi.repository.APILoad(this.id,...n),this}async APICreate(i=ke,...n){return await mi.repository.APICreate(this.toShallowJSON(),...n),this}async APIUpdate(i=ke,...n){return await mi.repository.APIUpdate(this.toShallowJSON(),...n),this}async APIDelete(i=ke,...n){return await mi.repository.APIDelete(this.toShallowJSON(),...n),this}async APIClone(i=ke,...n){return await mi.repository.APIClone(this.id,...n),this}async APILoadVersion(i=ke,n,...s){return await mi.repository.APILoadVersion(this.id,n,...s)}removeFromParent(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveFromParent))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[removeFromParent] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveFromParent,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];return this.parent.type===d.Project?(this.parent.removeVariableDeclaration(this),e.push(this.parent)):this.parent.detachedChildren.includes(this)&&this.parent.unsubscribeDetachedChild(this),i==null||i.attemptAutoclose(_.RemoveFromParent,this.id),{added:D(c),updated:D(n),removed:D(s),affected:D(e),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveEntity))){var m;if(!this.checkCanDelete(this,n))return J.Logger.warn(`[remove] User is not allowed to delete or edit this ${this.type} entity with id: ${this.id}`),n==null||n.event({id:`${_.RemoveEntity}-${this.id}`,action:_.RemoveEntity,owner:this,errorReason:Ii.ActionOwnerEntityNonDeletable,rootAction:((m=n==null?void 0:n.self)==null?void 0:m.id)===this.id&&(n==null?void 0:n.autoCloseActionName)===_.RemoveEntity}),n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const s=[],c=[],e=[],y=[];if(n!=null&&n.hasRemoved(this.id))return n==null||n.attemptAutoclose(_.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},n),Object.values(this.detachedDependents).forEach(v=>{const{updated:E,removed:b,added:w}=v.entity.onDetachedDependencyRemoved(this,v.field,n);s.push(...E),c.push(...b),e.push(...w)}),this.defaultValue){const{updated:v,removed:E}=this.defaultValue.remove({ignoreUpstream:!0},n);s.push(...v),c.push(...E)}if(this.readsValue&&(s.push(this.readsValue),this.readsValue.removeValueReader(this,n)),this.writesValues.forEach(v=>{s.push(v),v.setValueWriter(null,n)}),this.inputs.forEach(v=>{const{updated:E,removed:b}=v.remove({ignoreUpstream:!0},n);s.push(...E),c.push(...b)}),this.outputs.forEach(v=>{const{updated:E,removed:b}=v.remove({ignoreUpstream:!0},n);s.push(...E),c.push(...b)}),this.successCalls.forEach(v=>{s.push(v),v.removeCaller(this,n)}),this.errorCalls.forEach(v=>{s.push(v),v.removeCaller(this,n)}),this.internalCalls.forEach(v=>{const{updated:E,removed:b}=v.remove({ignoreUpstream:!0},n);s.push(...E),c.push(...b)}),this.dataType){const{updated:v,removed:E}=this.dataType.remove({ignoreUpstream:!0},n);s.push(...v),c.push(...E)}if(!i){const v=this.removeFromParent(n);e.push(...v.added),s.push(...v.updated),c.push(...v.removed),y.push(...v.affected),this.calledBy.forEach(E=>{s.push(E),E.removeCall(this,n)})}return n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:D(e),updated:D(s),removed:D(c),affected:D(y),self:this}}restore({}={},i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RestoreEntity))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[restore] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];if(i!=null&&i.hasAdded(this.id))return i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},i),Object.values(this.detachedDependents).forEach(y=>{const{updated:m,removed:v,added:E}=y.entity.onDetachedDependencyRestored(this,y.field,i);s.push(...m),c.push(...v),n.push(...E)}),this.defaultValue){const{updated:y}=this.defaultValue.restore({},i);s.push(...y)}if(this.readsValue&&(s.push(this.readsValue),this.readsValue.addValueReader(this,i)),this.writesValues.forEach(y=>{s.push(y),y.setValueWriter(this,i)}),this.inputs.forEach(y=>{const{updated:m}=y.restore({},i);s.push(...m)}),this.outputs.forEach(y=>{const{updated:m}=y.restore({},i);s.push(...m)}),this.successCalls.forEach(y=>{s.push(y),y.addSuccessCaller(this,i)}),this.errorCalls.forEach(y=>{s.push(y),y.addErrorCaller(this,i)}),this.internalCalls.forEach(y=>{const{updated:m}=y.restore({},i);s.push(...m)}),this.dataType){const{updated:y}=this.dataType.restore({},i);s.push(...y)}return this.calledBySuccess.forEach(y=>{s.push(y),y.addSuccessCall(this,i)}),this.calledByError.forEach(y=>{s.push(y),y.addErrorCall(this,i)}),this.calledByEntry.forEach(y=>{s.push(y),y.addCall(this,i)}),i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this}}toFlat(i=new Set){var s,c,e;return i.has(this.id)?[]:(i.add(this.id),[this,...((s=this.defaultValue)==null?void 0:s.toFlat(i))||[],...((c=this.dataType)==null?void 0:c.toFlat(i))||[],...((e=this.readsValue)==null?void 0:e.toFlat(i))||[],...this.writesValues.flatMap(y=>y.toFlat(i)),...this.successCalls.flatMap(y=>y.toFlat(i)),...this.errorCalls.flatMap(y=>y.toFlat(i)),...this.inputs.flatMap(y=>y.toFlat(i)),...this.outputs.flatMap(y=>y.toFlat(i)),...this.internalCalls.flatMap(y=>y.toFlat(i)),...this.calledBy.flatMap(y=>y.toFlat(i)),...this.variableInstances.flatMap(y=>y.toFlat(i))])}toFlatIds(i=new Set){var s,c;return i.has(this.id)?[]:(i.add(this.id),[this.id,...((s=this.defaultValue)==null?void 0:s.toFlatIds(i))||[],...((c=this.dataType)==null?void 0:c.toFlatIds(i))||[],...this.writesValues.flatMap(e=>e.toFlatIds(i)),...this.successCalls.flatMap(e=>e.toFlatIds(i)),...this.errorCalls.flatMap(e=>e.toFlatIds(i)),...this.inputs.flatMap(e=>e.toFlatIds(i)),...this.outputs.flatMap(e=>e.toFlatIds(i)),...this.internalCalls.flatMap(e=>e.toFlatIds(i)),...this.variableInstances.flatMap(e=>e.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,catchesError:this.catchesError,description:this.description,required:this.required,constant:this.constant,x:this.x,y:this.y,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name}}toJSON(i=new Set){var n,s,c,e;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,catchesError:this.catchesError,constant:this.constant,required:this.required,defaultValue:((n=this.defaultValue)==null?void 0:n.toJSON(i))||null,dataType:((s=this.dataType)==null?void 0:s.toJSON(i))||null,readsValue:((c=this.readsValue)==null?void 0:c.toReference())||null,writesValues:this.writesValues.map(y=>y.toJSON(i)),inputs:this.inputs.map(y=>y.toJSON(i)),outputs:this.outputs.map(y=>y.toJSON(i)),successCalls:this.successCalls.map(y=>y.toJSON(i)),errorCalls:this.errorCalls.map(y=>y.toJSON(i)),internalCalls:this.internalCalls.map(y=>y.toJSON(i)),calledBySuccess:this.calledBySuccess.map(y=>y.toReference()),calledByError:this.calledByError.map(y=>y.toReference()),calledByEntry:this.calledByEntry.map(y=>y.toReference()),error:((e=this.error)==null?void 0:e.toJSON(i))||null,parent:this.parent.toReference(),x:this.x,y:this.y})}toJSONClone(i=ct){var s,c,e,y,m,v,E,b,w;let n;return(s=i.seenEntityMaps)!=null&&s.has(this.id)?n=i.seenEntityMaps.get(this.id):(n=i.newId||jr(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,n)),(c=i.seenEntities)!=null&&c.has(n)||(e=i.seenEntities)!=null&&e.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((y=i.seenEntities)==null||y.add(n),(m=i.seenEntities)==null||m.add(this.id),{id:n,version:x.UUID.uuid(),createdAt:i.timestamp||M().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,codeName:this.codeName,constant:this.constant,required:this.required,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name,description:this.description,catchesError:this.catchesError,defaultValue:((v=this.defaultValue)==null?void 0:v.toJSONClone({...i,newId:null}))||null,dataType:((E=this.dataType)==null?void 0:E.toJSONClone({...i,newId:null}))||null,readsValue:((b=this.readsValue)==null?void 0:b.toReference({seenEntityMaps:i.seenEntityMaps}))||null,writesValues:this.writesValues.map(V=>V.toJSONClone({...i,newId:null})),inputs:this.inputs.map(V=>V.toJSONClone({...i,newId:null})),outputs:this.outputs.map(V=>V.toJSONClone({...i,newId:null})),successCalls:this.successCalls.map(V=>V.toJSONClone({...i,newId:null})),errorCalls:this.errorCalls.map(V=>V.toJSONClone({...i,newId:null})),internalCalls:this.internalCalls.map(V=>this.calledBy.length||this.readsValue?V.toJSONClone({...i,newId:null}):V.toReference({seenEntityMaps:i.seenEntityMaps})),calledBySuccess:this.calledBySuccess.map(V=>V.toReference({seenEntityMaps:i.seenEntityMaps})),calledByError:this.calledByError.map(V=>V.toReference({seenEntityMaps:i.seenEntityMaps})),calledByEntry:this.calledByEntry.map(V=>V.toReference({seenEntityMaps:i.seenEntityMaps})),error:((w=this.error)==null?void 0:w.toJSONClone({...i,newId:null}))||null,parent:this.parent.toReference({seenEntityMaps:i.seenEntityMaps}),x:this.x,y:this.y})}toReference(i=ct){var s;let n=this.id;return(s=i.seenEntityMaps)!=null&&s.has(this.id)&&(n=i.seenEntityMaps.get(this.id)),{id:n+"--"+x.UUID.uuid()+"--ref",type:d.GenericReference,entityId:n,version:this.version,entityType:this.type}}toShallowJSON(i=ct){var s,c,e,y,m;let n=this.id;return(s=i.seenEntityMaps)!=null&&s.has(this.id)&&(n=i.seenEntityMaps.get(this.id)),{id:n,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,catchesError:this.catchesError,required:this.required,constant:this.constant,x:this.x,y:this.y,defaultValue:((c=this.defaultValue)==null?void 0:c.toReference(i))||null,dataType:((e=this.dataType)==null?void 0:e.toReference(i))||null,readsValue:((y=this.readsValue)==null?void 0:y.toReference(i))||null,writesValues:this.writesValues.map(v=>v.toReference(i)),inputs:this.inputs.map(v=>v.toReference(i)),outputs:this.outputs.map(v=>v.toReference(i)),successCalls:this.successCalls.map(v=>v.toReference(i)),errorCalls:this.errorCalls.map(v=>v.toReference(i)),calledBySuccess:this.calledBySuccess.map(v=>v.toReference(i)),calledByError:this.calledByError.map(v=>v.toReference(i)),calledByEntry:this.calledByEntry.map(v=>v.toReference(i)),internalCalls:this.internalCalls.map(v=>v.toReference(i)),error:((m=this.error)==null?void 0:m.toReference(i))||null,parent:this.parent.toReference(i)}}toFlatJSON(i=new Set){var s,c;return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...((s=this.defaultValue)==null?void 0:s.toFlatJSON(i))||[],...((c=this.dataType)==null?void 0:c.toFlatJSON(i))||[],...this.writesValues.flatMap(e=>e.toFlatJSON(i)),...this.successCalls.flatMap(e=>e.toFlatJSON(i)),...this.errorCalls.flatMap(e=>e.toFlatJSON(i)),...this.inputs.flatMap(e=>e.toFlatJSON(i)),...this.outputs.flatMap(e=>e.toFlatJSON(i)),...this.internalCalls.flatMap(e=>e.toFlatJSON(i))])}toGenerationTarget(){const i=this.parent.type===d.Project?void 0:this.parent.id;return{id:this.id,type:this.type,name:this.name,description:this.description,calledByEntry:this.calledByEntry.map(n=>n.id),calledBySuccess:this.calledBySuccess.map(n=>n.id),calledByError:this.calledByError.map(n=>n.id),parent:i}}toFlatGenerationTarget(i=new Set){var s,c;return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...((s=this.defaultValue)==null?void 0:s.toFlatGenerationTarget(i))||[],...((c=this.dataType)==null?void 0:c.toFlatGenerationTarget(i))||[],...this.writesValues.flatMap(e=>e.toFlatGenerationTarget(i)),...this.successCalls.flatMap(e=>e.toFlatGenerationTarget(i)),...this.errorCalls.flatMap(e=>e.toFlatGenerationTarget(i)),...this.inputs.flatMap(e=>e.toFlatGenerationTarget(i)),...this.outputs.flatMap(e=>e.toFlatGenerationTarget(i)),...this.internalCalls.flatMap(e=>e.toFlatGenerationTarget(i))])}clearErrors(){var i,n;return this.errors=[],this.inputs.forEach(s=>s.clearErrors()),this.outputs.forEach(s=>s.clearErrors()),this.successCalls.forEach(s=>s.clearErrors()),this.errorCalls.forEach(s=>s.clearErrors()),this.internalCalls.forEach(s=>s.clearErrors()),(i=this.dataType)==null||i.clearErrors(),(n=this.defaultValue)==null||n.clearErrors(),this}validate(){return this.errors=ULe(this),{success:!0}}async validateAsync(i={}){const n=J.YieldTracker.from(i);return this.errors=await jLe(this,{tracker:n}),{success:!0}}getErrors(){var n,s;return[...this.errors,...((n=this.defaultValue)==null?void 0:n.getErrors())||[],...((s=this.dataType)==null?void 0:s.getErrors())||[],...this.inputs.flatMap(c=>c.getErrors()),...this.internalCalls.flatMap(c=>c.getErrors()),...this.outputs.flatMap(c=>c.getErrors())]}async getErrorsAsync(i={}){const n=J.YieldTracker.from(i),s=[...this.errors];if(await n.tick(),this.defaultValue){const c=await this.defaultValue.getErrorsAsync({tracker:n});s.push(...c)}if(this.dataType){const c=await this.dataType.getErrorsAsync({tracker:n});s.push(...c)}for(const c of this.inputs){const e=await c.getErrorsAsync({tracker:n});s.push(...e)}for(const c of this.internalCalls){const e=await c.getErrorsAsync({tracker:n});s.push(...e)}for(const c of this.outputs){const e=await c.getErrorsAsync({tracker:n});s.push(...e)}return s}getShallowErrors(){return this.errors}getDefaultValue(){return this.defaultValue||null}setDefaultValue(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"set-default-value"))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setDefaultValue] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("set-default-value",this.id),this;const s=this.defaultValue;return(s==null?void 0:s.id)!==(i==null?void 0:i.id)&&(s==null||s.remove({ignoreUpstream:!0},n),this.defaultValue=i,n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose("set-default-value",this.id),this}clone(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.CloneEntity)),n=null,s=null,c=!0){var L,k,K,S,Y;const e=Rr(n,this),y=this.toJSON(),m=s||x.UUID.uuid();y.inputs=[],y.id=m,y.version=x.UUID.uuid(),y.createdAt=(i==null?void 0:i.timestamp)||M().toISOString(),y.author=(i==null?void 0:i.author)||"1",y.previousVersion=null,y.deleted=!1,y.deletable=!0,y.editable=!0;const v=Si(y,e);n?v.setParent(n,i):v.setParent(this.parent,null),c&&v.subscribe(),v.initChildren(i),i==null||i.add(v,H.Added);const E=(L=this.dataType)==null?void 0:L.clone(i,v,x.UUID.uuid(),c);v.setDataType(E||null,i);const b=(k=this.defaultValue)==null?void 0:k.clone(i,v,x.UUID.uuid(),c);v.setDefaultValue(b||null,i);const w=(K=this.inputs)==null?void 0:K.map(re=>re.clone(i,v,x.UUID.uuid(),c));v.inputs=w;const V=(S=this.outputs)==null?void 0:S.map(re=>re.clone(i,v,x.UUID.uuid(),c));v.outputs=V;const $=(Y=this.internalCalls)==null?void 0:Y.map(re=>re.clone(i,v,x.UUID.uuid(),c));return v.internalCalls=$,i==null||i.attemptAutoclose(_.CloneEntity,this.id),v}addInternalCall(i){return this.internalCalls.find(n=>n===i)||this.internalCalls.push(i),this}createInstance(i=this.project,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"create-instance")),s={}){const c={id:s.id||x.UUID.uuid(),version:s.version||x.UUID.uuid(),createdAt:(n==null?void 0:n.timestamp)||M().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.VariableInstance,parent:i.toReference(),catchesError:s.catchesError||!1,defaultValue:s.defaultValue||null,successCalls:s.successCalls||[],errorCalls:s.errorCalls||[],inputs:s.inputs||[],outputs:s.outputs||[],writesValues:s.writesValues||[],internalCalls:s.internalCalls||[],readsValue:s.readsValue||null,calledByEntry:s.calledByEntry||[],calledBySuccess:s.calledBySuccess||[],calledByError:s.calledByError||[],error:s.error||null,declaration:this.toReference(),x:0,y:0},e=me(c,this.project);return e.hydrateAncestors(),e.setParent(i,n),n==null||n.add(e,H.Added),e.addSelfToProject(n),e.initChildren(n),i===this.project&&this.project.addVariableInstance(e),n==null||n.attemptAutoclose("create-instance",this.id),e}removeUnrecognizedInputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveUnrecognizedInputs))){var m;if(!this.checkCanEdit(this,i))return J.Logger.warn(`[removeUnrecognizedInputs] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveUnrecognizedInputs,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];if(this.dataType&&!this.dataType.isObject())[...this.inputs].forEach(v=>{const E=v.remove({ignoreUpstream:!1},i);c.push(...E.removed),n.push(...E.updated)});else if(this.dataType&&this.dataType.hasStrictObjectStructure()){const v=[...((m=this.dataType)==null?void 0:m.entity).properties];[...this.inputs].forEach(E=>{if(!E.declaration){const w=E.remove({ignoreUpstream:!1},i);c.push(...w.removed),n.push(...w.updated);return}if(!v.find(w=>E.declaration===w)){const w=E.remove({ignoreUpstream:!1},i);c.push(...w.removed),n.push(...w.updated)}if(!dA(E)){const w=E.remove({ignoreUpstream:!1},i);c.push(...w.removed),n.push(...w.updated)}})}return this.inputs.filter((v,E)=>{const b=this.inputs.findIndex(V=>V.declaration===v.declaration&&V!==v);if(b===-1)return!1;const w=this.inputs[b];return M(w==null?void 0:w.createdAt).isSame(M(v.createdAt))?E>b:!!M(w==null?void 0:w.createdAt).isAfter(v.createdAt)}).forEach(v=>{const E=v.remove({ignoreUpstream:!1},i);c.push(...E.removed),n.push(...E.updated)}),i==null||i.attemptAutoclose(_.RemoveUnrecognizedInputs,this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}removeUnrecognizedOutputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-unrecognized-variable-declaration-outputs"))){var m;if(!this.checkCanEdit(this,i))return J.Logger.warn(`[removeUnrecognizedOutputs] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveUnrecognizedOutputs,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];if(this.dataType&&!this.dataType.isObject())[...this.outputs].forEach(v=>{const E=v.remove({ignoreUpstream:!1},i);c.push(...E.removed),n.push(...E.updated)});else if(this.dataType&&this.dataType.hasStrictObjectStructure()){const v=[...((m=this.dataType)==null?void 0:m.entity).properties];[...this.outputs].forEach(E=>{if(!E.declaration){const w=E.remove({ignoreUpstream:!1},i);c.push(...w.removed),n.push(...w.updated);return}if(!v.find(w=>{var V;return((V=E.declaration)==null?void 0:V.id)===(w==null?void 0:w.id)})){const w=E.remove({ignoreUpstream:!1},i);c.push(...w.removed),n.push(...w.updated);return}if(!dA(E)){const w=E.remove({ignoreUpstream:!1},i);c.push(...w.removed),n.push(...w.updated)}})}return this.outputs.filter((v,E)=>{const b=this.outputs.findIndex(V=>V.declaration===v.declaration&&V!==v);if(b===-1)return!1;const w=this.outputs[b];return M(w==null?void 0:w.createdAt).isSame(M(v.createdAt))?E>b:!!M(w==null?void 0:w.createdAt).isAfter(v.createdAt)}).forEach(v=>{const E=v.remove({ignoreUpstream:!1},i);c.push(...E.removed),n.push(...E.updated)}),i==null||i.attemptAutoclose("remove-unrecognized-variable-declaration-outputs",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}removeUnrecognizedInternalCalls(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-unrecognized-variable-declaration-internal-calls"))){const n=[],s=[],c=[],e=[];if(!this.dataType||!this.dataType.entity||![d.DefinitionEntity,d.PrimitiveEntity,d.BuiltInBaseEntity].includes(this.dataType.entity.type))[...this.internalCalls].forEach(m=>{const v=m.remove({ignoreUpstream:!1},i);c.push(...v.removed),n.push(...v.updated)});else if(this.dataType&&this.dataType.entity&&[d.DefinitionEntity,d.PrimitiveEntity,d.BuiltInBaseEntity].includes(this.dataType.entity.type)){const m=[...this.dataType.entity.getAllInteractiveMethods()],v=[...m].filter(E=>!m.some(b=>{var w,V;return b.id!==E.id&&(((w=b.implements)==null?void 0:w.id)===E.id||((V=b.extends)==null?void 0:V.id)===E.id)})&&!E.deleted);[...this.internalCalls].forEach(E=>{if(!E.declaration){const w=E.remove({ignoreUpstream:!1},i);c.push(...w.removed),n.push(...w.updated);return}if(!v.find(w=>E.declaration===w)){const w=E.remove({ignoreUpstream:!1},i);c.push(...w.removed),n.push(...w.updated);return}})}return this.internalCalls.filter((m,v)=>{const E=this.internalCalls.findIndex(w=>w.declaration===m.declaration&&w!==m);if(E===-1)return!1;const b=this.internalCalls[E];return M(b==null?void 0:b.createdAt).isSame(M(m.createdAt))?v>E:!!M(b==null?void 0:b.createdAt).isAfter(m.createdAt)}).forEach(m=>{const v=m.remove({ignoreUpstream:!1},i);c.push(...v.removed),n.push(...v.updated)}),i==null||i.attemptAutoclose("remove-unrecognized-variable-declaration-internal-calls",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}syncInputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"sync-variable-declaration-inputs"))){const n=[],s=[],c=[],e=[];if(this.dataType)if(this.dataType.entity){if(this.dataType.isObject()){const y=[...this.dataType.entity.properties];y.filter(E=>Ry(E)?!this.inputs.find(b=>{var w;return((w=b.declaration)==null?void 0:w.id)===E.id}):!1).forEach(E=>{const b={dataType:null,id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||M().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.InputMap,parentRelationType:null,parent:this.toReference(),name:null,description:null,codeName:null,declaration:E.toJSON(),defaultValue:null,index:E.index,readsValue:null},w=me(b,this.project);return w.hydrateAncestors(),i==null||i.add(w,H.Added),w.setParent(this,i),w.initChildren(i),this.addInput(w,i),w}),this.inputs.filter(E=>!E.declaration).forEach(E=>{const b=y.find(w=>se(w,this.project)===se(E,this.project));b&&E.setDeclaration(b,i)})}}else return i==null||i.attemptAutoclose("sync-variable-declaration-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};else return i==null||i.attemptAutoclose("sync-variable-declaration-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};return i==null||i.attemptAutoclose("sync-variable-declaration-inputs",this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this}}syncOutputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SyncOutputs))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[syncOutputs] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.SyncOutputs,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];if(this.dataType)if(this.dataType.entity){if(this.dataType.isObject()){const y=[...this.dataType.entity.properties];y.filter(E=>Ry(E)?!this.outputs.find(b=>{var w;return((w=b.declaration)==null?void 0:w.id)===(E==null?void 0:E.id)}):!1).map(E=>{const b={dataType:null,id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||M().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.OutputMap,parent:this.toReference(),declaration:E==null?void 0:E.toJSON(),index:E.index,writesValues:[]},w=me(b,this.project);return w.hydrateAncestors(),i==null||i.add(w,H.Added),w.setParent(this,i),w.initChildren(i),this.addOutput(w,i),w}),this.outputs.filter(E=>!E.declaration).forEach(E=>{const b=y.find(w=>se(w,this.project)===se(E,this.project));b&&E.setDeclaration(b,i)})}}else return i==null||i.attemptAutoclose(_.SyncOutputs,this.id),{added:[],updated:[],removed:[],affected:[],self:this};else return i==null||i.attemptAutoclose(_.SyncOutputs,this.id),{added:[],updated:[],removed:[],affected:[],self:this};return i==null||i.attemptAutoclose(_.SyncOutputs,this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this}}generateUnusedInternalCalls(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"generate-unused-internal-calls"))){const n=[],s=[],c=[],e=[];if(this.dataType)if(this.dataType.entity){if([d.DefinitionEntity,d.PrimitiveEntity,d.BuiltInBaseEntity].includes(this.dataType.entity.type)){const y=[...this.dataType.entity.getAllInteractiveMethods()];[...y].filter(E=>!y.some(b=>{var w,V;return b.id!==E.id&&(((w=b.implements)==null?void 0:w.id)===E.id||((V=b.extends)==null?void 0:V.id)===E.id)})&&!E.deleted).filter(E=>!this.internalCalls.find(w=>{var $,L,k,K,S;return((($=w.declaration)==null?void 0:$.id)||((k=(L=w.initialData)==null?void 0:L.declaration)==null?void 0:k.entityId)||((S=(K=w.initialData)==null?void 0:K.declaration)==null?void 0:S.id))===E.id})).forEach(E=>{var w;const b=this.internalCalls.find(V=>{const $=Pc(V.declaration),L=Pc(E);return $.id===L.id});if(b&&((w=b.declaration)==null?void 0:w.id)!==E.id)b.setDeclaration(E);else{const V=E.createInternalCall(i,this);i==null||i.add(V,H.Added),this.addInternalCall(V)}})}}else return i==null||i.attemptAutoclose("generate-unused-internal-calls",this.id),{added:[],updated:[],removed:[],affected:[],self:this};else return i==null||i.attemptAutoclose("generate-unused-internal-calls",this.id),{added:[],updated:[],removed:[],affected:[],self:this};return i==null||i.attemptAutoclose("generate-unused-internal-calls",this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this}}setDataType(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetDataType))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setDataType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.SetDataType,this.id),this;const s=this.dataType;return(s==null?void 0:s.id)!==(i==null?void 0:i.id)&&(s==null||s.remove({ignoreUpstream:!0},n),this.dataType=i,this.subscribeToDependencies(),n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose(_.SetDataType,this.id),this}removeDataType(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveDataType))){return this.checkCanEdit(this,i)?(this.dataType&&(this.dataType.remove({ignoreUpstream:!0},i),i==null||i.add(this,H.Affected),this.dataType=null),i==null||i.attemptAutoclose(_.RemoveDataType,this.id),this):(J.Logger.warn(`[removeDataType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveDataType,this.id),this)}getDataType(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"get-data-type"))){return(!this.dataType||this.dataType.inferred)&&this.project.initialized&&this.inferDataTypeAndSyncInstancesInputsAndOutputs(i),i==null||i.attemptAutoclose("get-data-type",this.id),this.dataType||null}getUnusedInputs(){return this.inputs.filter(i=>i.suggestion||!i.readsValue&&!i.defaultValue)}getUnusedOutputs(){return this.outputs.filter(i=>i.suggestion||!i.writesValues.length)}getUsedInputs(){return this.inputs.filter(i=>!i.suggestion&&(i.readsValue||i.defaultValue))}getUsedOutputs(){return this.outputs.filter(i=>!i.suggestion&&i.writesValues.length)}};I(mi,"repository",{APICreate:async(i,...n)=>i,APIUpdate:async(i,...n)=>i,APIDelete:async(i,...n)=>i,APIClone:async(i,...n)=>{},APILoad:async(i,...n)=>null,APILoadVersion:async(i,n,...s)=>null}),I(mi,"type",d.VariableDeclaration),I(mi,"USER_MANAGED_PARENT_TYPES",[...nr,d.Project]),I(mi,"PARENT_TYPES",[...mi.USER_MANAGED_PARENT_TYPES]),I(mi,"MUTABLE_BASE_PROPERTIES",["name","codeName","description","constant","required","catchesError"]),I(mi,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),I(mi,"BASE_PROPERTIES",[...mi.MUTABLE_BASE_PROPERTIES,...mi.INMUTABLE_BASE_PROPERTIES]),I(mi,"MUTABLE_META_PROPERTIES",[...mi.MUTABLE_BASE_PROPERTIES,"x","y"]),I(mi,"INMUTABLE_META_PROPERTIES",[...mi.INMUTABLE_BASE_PROPERTIES]),I(mi,"META_PROPERTIES",[...mi.MUTABLE_META_PROPERTIES,...mi.INMUTABLE_META_PROPERTIES]),I(mi,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry","readsValue"]),I(mi,"INMUTABLE_UPSTREAM_PROPERTIES",["parent"]),I(mi,"UPSTREAM_PROPERTIES",[...mi.MUTABLE_UPSTREAM_PROPERTIES,...mi.INMUTABLE_UPSTREAM_PROPERTIES]),I(mi,"MUTABLE_DOWNSTREAM_PROPERTIES",["writesValues","inputs","outputs","successCalls","errorCalls","internalCalls"]),I(mi,"INMUTABLE_DOWNSTREAM_PROPERTIES",["dataType","defaultValue"]),I(mi,"DOWNSTREAM_PROPERTIES",[...mi.MUTABLE_DOWNSTREAM_PROPERTIES,...mi.INMUTABLE_DOWNSTREAM_PROPERTIES]),I(mi,"PROPERTIES",[...mi.META_PROPERTIES,...mi.UPSTREAM_PROPERTIES,...mi.DOWNSTREAM_PROPERTIES]);let Gu=mi;async function qLe(o,p={}){var y,m;const i=J.YieldTracker.from(p),n=ta(o),s=ia(o),c=[...n,...s],e=Mt(o.errors,c);await i.tick();for(const v of o.inputsDeclarations)await v.validateAsync({tracker:i});for(const v of o.inputs)await v.validateAsync({tracker:i});for(const v of o.outputs)await v.validateAsync({tracker:i});return await((y=o.error)==null?void 0:y.validateAsync({tracker:i})),await((m=o.dataType)==null?void 0:m.validateAsync({tracker:i})),e}function ZLe(o){var n,s;o.inputsDeclarations.forEach(c=>c.validate()),o.inputs.forEach(c=>c.validate()),o.outputs.forEach(c=>c.validate()),(n=o.error)==null||n.validate(),(s=o.dataType)==null||s.validate();const i=[...ta(o),...ia(o)];return Mt(o.errors,i)}const uAi=Object.freeze(Object.defineProperty({__proto__:null,validate:ZLe,validateAsync:qLe},Symbol.toStringTag,{value:"Module"}));var Cy={},HLe={},WLe={};Object.defineProperty(WLe,"__esModule",{value:!0});var zLe={};Object.defineProperty(zLe,"__esModule",{value:!0});var JLe={};Object.defineProperty(JLe,"__esModule",{value:!0});var YLe={};Object.defineProperty(YLe,"__esModule",{value:!0});var XLe={};Object.defineProperty(XLe,"__esModule",{value:!0});var QLe={};Object.defineProperty(QLe,"__esModule",{value:!0});var e2e={};Object.defineProperty(e2e,"__esModule",{value:!0});var t2e={};Object.defineProperty(t2e,"__esModule",{value:!0});var i2e={};Object.defineProperty(i2e,"__esModule",{value:!0});var r2e={};Object.defineProperty(r2e,"__esModule",{value:!0});var n2e={};Object.defineProperty(n2e,"__esModule",{value:!0});var a2e={};Object.defineProperty(a2e,"__esModule",{value:!0});var s2e={};Object.defineProperty(s2e,"__esModule",{value:!0});var l2e={};Object.defineProperty(l2e,"__esModule",{value:!0});var o2e={};Object.defineProperty(o2e,"__esModule",{value:!0});var d2e={};Object.defineProperty(d2e,"__esModule",{value:!0});var u2e={};Object.defineProperty(u2e,"__esModule",{value:!0});var p2e={};Object.defineProperty(p2e,"__esModule",{value:!0});var c2e={};Object.defineProperty(c2e,"__esModule",{value:!0});var f2e={};Object.defineProperty(f2e,"__esModule",{value:!0});var y2e={};Object.defineProperty(y2e,"__esModule",{value:!0});var h2e={};Object.defineProperty(h2e,"__esModule",{value:!0});var m2e={};Object.defineProperty(m2e,"__esModule",{value:!0});var T2e={};Object.defineProperty(T2e,"__esModule",{value:!0});var v2e={};Object.defineProperty(v2e,"__esModule",{value:!0});var E2e={};Object.defineProperty(E2e,"__esModule",{value:!0});var b2e={};Object.defineProperty(b2e,"__esModule",{value:!0});var A2e={};Object.defineProperty(A2e,"__esModule",{value:!0});var g2e={};Object.defineProperty(g2e,"__esModule",{value:!0});var I2e={};Object.defineProperty(I2e,"__esModule",{value:!0});var R2e={};Object.defineProperty(R2e,"__esModule",{value:!0});var D2e={};Object.defineProperty(D2e,"__esModule",{value:!0});var w2e={};Object.defineProperty(w2e,"__esModule",{value:!0});var O2e={};Object.defineProperty(O2e,"__esModule",{value:!0});var C2e={};Object.defineProperty(C2e,"__esModule",{value:!0});var _2e={};Object.defineProperty(_2e,"__esModule",{value:!0});var V2e={};Object.defineProperty(V2e,"__esModule",{value:!0});var P2e={};Object.defineProperty(P2e,"__esModule",{value:!0});var N2e={};Object.defineProperty(N2e,"__esModule",{value:!0});var x2e={};Object.defineProperty(x2e,"__esModule",{value:!0});var $2e={};Object.defineProperty($2e,"__esModule",{value:!0});var L2e={};Object.defineProperty(L2e,"__esModule",{value:!0});var M2e={};Object.defineProperty(M2e,"__esModule",{value:!0});(function(o){var p=Nr&&Nr.__createBinding||(Object.create?function(n,s,c,e){e===void 0&&(e=c);var y=Object.getOwnPropertyDescriptor(s,c);(!y||("get"in y?!s.__esModule:y.writable||y.configurable))&&(y={enumerable:!0,get:function(){return s[c]}}),Object.defineProperty(n,e,y)}:function(n,s,c,e){e===void 0&&(e=c),n[e]=s[c]}),i=Nr&&Nr.__exportStar||function(n,s){for(var c in n)c!=="default"&&!Object.prototype.hasOwnProperty.call(s,c)&&p(s,n,c)};Object.defineProperty(o,"__esModule",{value:!0}),i(WLe,o),i(zLe,o),i(JLe,o),i(YLe,o),i(XLe,o),i(QLe,o),i(e2e,o),i(t2e,o),i(i2e,o),i(r2e,o),i(n2e,o),i(a2e,o),i(s2e,o),i(l2e,o),i(o2e,o),i(d2e,o),i(u2e,o),i(p2e,o),i(c2e,o),i(f2e,o),i(y2e,o),i(h2e,o),i(m2e,o),i(T2e,o),i(v2e,o),i(E2e,o),i(b2e,o),i(A2e,o),i(g2e,o),i(I2e,o),i(R2e,o),i(D2e,o),i(w2e,o),i(O2e,o),i(C2e,o),i(_2e,o),i(V2e,o),i(P2e,o),i(N2e,o),i(x2e,o),i($2e,o),i(L2e,o),i(M2e,o)})(HLe);var B2e={},aa={};Object.defineProperty(aa,"__esModule",{value:!0});aa.isObject=aa.isString=aa.isDefined=aa.last=aa.identity=void 0;const pAi=o=>o;aa.identity=pAi;const cAi=o=>o[o.length-1];aa.last=cAi;const fAi=o=>o!==void 0;aa.isDefined=fAi;const yAi=o=>typeof o=="string";aa.isString=yAi;const hAi=o=>typeof o=="object"&&o!==null&&!(o instanceof Array);aa.isObject=hAi;(function(o){Object.defineProperty(o,"__esModule",{value:!0}),o.cstVisitor=o.VisitorAction=void 0;const p=aa;var i;(function(c){c[c.SKIP=1]="SKIP"})(i=o.VisitorAction||(o.VisitorAction={}));function n(c){const e=y=>{const m=c[y.type];if((m==null?void 0:m(y))!==i.SKIP)for(const E of Object.values(y))s(E)?e(E):E instanceof Array&&E.filter(s).forEach(b=>e(b))};return e}o.cstVisitor=n;const s=c=>(0,p.isObject)(c)&&(0,p.isString)(c.type)})(B2e);var cv={};Object.defineProperty(cv,"__esModule",{value:!0});cv.cstTransformer=void 0;function mAi(o){return p=>{const i=o[p.type];if(!i)throw p.type?new Error(`No transform map entry for ${p.type}`):new Error(`No type field on node: ${JSON.stringify(p)}`);return i(p)}}cv.cstTransformer=mAi;var G2e={},fv={};Object.defineProperty(fv,"__esModule",{value:!0});fv.bigqueryKeywords=void 0;fv.bigqueryKeywords={ALL:!0,AND:!0,ANY:!0,ARRAY:!0,AS:!0,ASC:!0,ASSERT_ROWS_MODIFIED:!0,AT:!0,BETWEEN:!0,BY:!0,CASE:!0,CAST:!0,COLLATE:!0,CONTAINS:!0,CREATE:!0,CROSS:!0,CUBE:!0,CURRENT:!0,DEFAULT:!0,DEFINE:!0,DESC:!0,DISTINCT:!0,ELSE:!0,END:!0,ENUM:!0,ESCAPE:!0,EXCEPT:!0,EXCLUDE:!0,EXISTS:!0,EXTRACT:!0,FALSE:!0,FETCH:!0,FOLLOWING:!0,FOR:!0,FROM:!0,FULL:!0,GROUP:!0,GROUPING:!0,GROUPS:!0,HASH:!0,HAVING:!0,IF:!0,IGNORE:!0,IN:!0,INNER:!0,INTERSECT:!0,INTERVAL:!0,INTO:!0,IS:!0,JOIN:!0,LATERAL:!0,LEFT:!0,LIKE:!0,LIMIT:!0,LOOKUP:!0,MERGE:!0,NATURAL:!0,NEW:!0,NO:!0,NOT:!0,NULL:!0,NULLS:!0,OF:!0,ON:!0,OR:!0,ORDER:!0,OUTER:!0,OVER:!0,PARTITION:!0,PRECEDING:!0,PROTO:!0,QUALIFY:!0,RANGE:!0,RECURSIVE:!0,RESPECT:!0,RIGHT:!0,ROLLUP:!0,ROWS:!0,SELECT:!0,SET:!0,SOME:!0,STRUCT:!0,TABLESAMPLE:!0,THEN:!0,TO:!0,TREAT:!0,TRUE:!0,UNBOUNDED:!0,UNION:!0,UNNEST:!0,USING:!0,WHEN:!0,WHERE:!0,WINDOW:!0,WITH:!0,WITHIN:!0};var yv={};Object.defineProperty(yv,"__esModule",{value:!0});yv.mariadbKeywords=void 0;yv.mariadbKeywords={ACCESSIBLE:!0,ADD:!0,ALL:!0,ALTER:!0,ANALYZE:!0,AND:!0,AS:!0,ASC:!0,ASENSITIVE:!0,BEFORE:!0,BETWEEN:!0,BIGINT:!0,BINARY:!0,BLOB:!0,BOTH:!0,BY:!0,CALL:!0,CASCADE:!0,CASE:!0,CHANGE:!0,CHAR:!0,CHARACTER:!0,CHECK:!0,COLLATE:!0,COLUMN:!0,CONDITION:!0,CONSTRAINT:!0,CONTINUE:!0,CONVERT:!0,CREATE:!0,CROSS:!0,CURRENT_DATE:!0,CURRENT_ROLE:!0,CURRENT_TIME:!0,CURRENT_TIMESTAMP:!0,CURRENT_USER:!0,CURSOR:!0,DATABASE:!0,DATABASES:!0,DAY_HOUR:!0,DAY_MICROSECOND:!0,DAY_MINUTE:!0,DAY_SECOND:!0,DEC:!0,DECIMAL:!0,DECLARE:!0,DEFAULT:!0,DELAYED:!0,DELETE:!0,DELETE_DOMAIN_ID:!0,DESC:!0,DESCRIBE:!0,DETERMINISTIC:!0,DISTINCT:!0,DISTINCTROW:!0,DIV:!0,DO_DOMAIN_IDS:!0,DOUBLE:!0,DROP:!0,DUAL:!0,EACH:!0,ELSE:!0,ELSEIF:!0,ENCLOSED:!0,ESCAPED:!0,EXCEPT:!0,EXISTS:!0,EXIT:!0,EXPLAIN:!0,FALSE:!0,FETCH:!0,FLOAT:!0,FLOAT4:!0,FLOAT8:!0,FOR:!0,FORCE:!0,FOREIGN:!0,FROM:!0,FULLTEXT:!0,GENERAL:!0,GRANT:!0,GROUP:!0,HAVING:!0,HIGH_PRIORITY:!0,HOUR_MICROSECOND:!0,HOUR_MINUTE:!0,HOUR_SECOND:!0,IF:!0,IGNORE:!0,IGNORE_DOMAIN_IDS:!0,IGNORE_SERVER_IDS:!0,IN:!0,INDEX:!0,INFILE:!0,INNER:!0,INOUT:!0,INSENSITIVE:!0,INSERT:!0,INT:!0,INT1:!0,INT2:!0,INT3:!0,INT4:!0,INT8:!0,INTEGER:!0,INTERSECT:!0,INTERVAL:!0,INTO:!0,IS:!0,ITERATE:!0,JOIN:!0,KEY:!0,KEYS:!0,KILL:!0,LEADING:!0,LEAVE:!0,LEFT:!0,LIKE:!0,LIMIT:!0,LINEAR:!0,LINES:!0,LOAD:!0,LOCALTIME:!0,LOCALTIMESTAMP:!0,LOCK:!0,LONG:!0,LONGBLOB:!0,LONGTEXT:!0,LOOP:!0,LOW_PRIORITY:!0,MASTER_HEARTBEAT_PERIOD:!0,MASTER_SSL_VERIFY_SERVER_CERT:!0,MATCH:!0,MAXVALUE:!0,MEDIUMBLOB:!0,MEDIUMINT:!0,MEDIUMTEXT:!0,MIDDLEINT:!0,MINUTE_MICROSECOND:!0,MINUTE_SECOND:!0,MOD:!0,MODIFIES:!0,NATURAL:!0,NOT:!0,NO_WRITE_TO_BINLOG:!0,NULL:!0,NUMERIC:!0,OFFSET:!0,ON:!0,OPTIMIZE:!0,OPTION:!0,OPTIONALLY:!0,OR:!0,ORDER:!0,OUT:!0,OUTER:!0,OUTFILE:!0,OVER:!0,PAGE_CHECKSUM:!0,PARSE_VCOL_EXPR:!0,PARTITION:!0,POSITION:!0,PRECISION:!0,PRIMARY:!0,PROCEDURE:!0,PURGE:!0,RANGE:!0,READ:!0,READS:!0,READ_WRITE:!0,REAL:!0,RECURSIVE:!0,REF_SYSTEM_ID:!0,REFERENCES:!0,REGEXP:!0,RELEASE:!0,RENAME:!0,REPEAT:!0,REPLACE:!0,REQUIRE:!0,RESIGNAL:!0,RESTRICT:!0,RETURN:!0,RETURNING:!0,REVOKE:!0,RIGHT:!0,RLIKE:!0,ROWS:!0,SCHEMA:!0,SCHEMAS:!0,SECOND_MICROSECOND:!0,SELECT:!0,SENSITIVE:!0,SEPARATOR:!0,SET:!0,SHOW:!0,SIGNAL:!0,SLOW:!0,SMALLINT:!0,SPATIAL:!0,SPECIFIC:!0,SQL:!0,SQLEXCEPTION:!0,SQLSTATE:!0,SQLWARNING:!0,SQL_BIG_RESULT:!0,SQL_CALC_FOUND_ROWS:!0,SQL_SMALL_RESULT:!0,SSL:!0,STARTING:!0,STATS_AUTO_RECALC:!0,STATS_PERSISTENT:!0,STATS_SAMPLE_PAGES:!0,STRAIGHT_JOIN:!0,TABLE:!0,TERMINATED:!0,THEN:!0,TINYBLOB:!0,TINYINT:!0,TINYTEXT:!0,TO:!0,TRAILING:!0,TRIGGER:!0,TRUE:!0,UNDO:!0,UNION:!0,UNIQUE:!0,UNLOCK:!0,UNSIGNED:!0,UPDATE:!0,USAGE:!0,USE:!0,USING:!0,UTC_DATE:!0,UTC_TIME:!0,UTC_TIMESTAMP:!0,VALUES:!0,VARBINARY:!0,VARCHAR:!0,VARCHARACTER:!0,VARYING:!0,WHEN:!0,WHERE:!0,WHILE:!0,WINDOW:!0,WITH:!0,WRITE:!0,XOR:!0,YEAR_MONTH:!0,ZEROFILL:!0};var hv={};Object.defineProperty(hv,"__esModule",{value:!0});hv.mysqlKeywords=void 0;hv.mysqlKeywords={ACCESSIBLE:!0,ADD:!0,ALL:!0,ALTER:!0,ANALYZE:!0,AND:!0,AS:!0,ASC:!0,ASENSITIVE:!0,BEFORE:!0,BETWEEN:!0,BIGINT:!0,BINARY:!0,BLOB:!0,BOTH:!0,BY:!0,CALL:!0,CASCADE:!0,CASE:!0,CHANGE:!0,CHAR:!0,CHARACTER:!0,CHECK:!0,COLLATE:!0,COLUMN:!0,CONDITION:!0,CONSTRAINT:!0,CONTINUE:!0,CONVERT:!0,CREATE:!0,CROSS:!0,CUBE:!0,CUME_DIST:!0,CURRENT_DATE:!0,CURRENT_TIME:!0,CURRENT_TIMESTAMP:!0,CURRENT_USER:!0,CURSOR:!0,DATABASE:!0,DATABASES:!0,DAY_HOUR:!0,DAY_MICROSECOND:!0,DAY_MINUTE:!0,DAY_SECOND:!0,DEC:!0,DECIMAL:!0,DECLARE:!0,DEFAULT:!0,DELAYED:!0,DELETE:!0,DENSE_RANK:!0,DESC:!0,DESCRIBE:!0,DETERMINISTIC:!0,DISTINCT:!0,DISTINCTROW:!0,DIV:!0,DOUBLE:!0,DROP:!0,DUAL:!0,EACH:!0,ELSE:!0,ELSEIF:!0,EMPTY:!0,ENCLOSED:!0,ESCAPED:!0,EXCEPT:!0,EXISTS:!0,EXIT:!0,EXPLAIN:!0,FALSE:!0,FETCH:!0,FIRST_VALUE:!0,FLOAT:!0,FLOAT4:!0,FLOAT8:!0,FOR:!0,FORCE:!0,FOREIGN:!0,FROM:!0,FULLTEXT:!0,FUNCTION:!0,GENERATED:!0,GET:!0,GRANT:!0,GROUP:!0,GROUPING:!0,GROUPS:!0,HAVING:!0,HIGH_PRIORITY:!0,HOUR_MICROSECOND:!0,HOUR_MINUTE:!0,HOUR_SECOND:!0,IF:!0,IGNORE:!0,IN:!0,INDEX:!0,INFILE:!0,INNER:!0,INOUT:!0,INSENSITIVE:!0,INSERT:!0,INT:!0,INT1:!0,INT2:!0,INT3:!0,INT4:!0,INT8:!0,INTEGER:!0,INTERSECT:!0,INTERVAL:!0,INTO:!0,IO_AFTER_GTIDS:!0,IO_BEFORE_GTIDS:!0,IS:!0,ITERATE:!0,JOIN:!0,JSON_TABLE:!0,KEY:!0,KEYS:!0,KILL:!0,LAG:!0,LAST_VALUE:!0,LATERAL:!0,LEAD:!0,LEADING:!0,LEAVE:!0,LEFT:!0,LIKE:!0,LIMIT:!0,LINEAR:!0,LINES:!0,LOAD:!0,LOCALTIME:!0,LOCALTIMESTAMP:!0,LOCK:!0,LONG:!0,LONGBLOB:!0,LONGTEXT:!0,LOOP:!0,LOW_PRIORITY:!0,MASTER_BIND:!0,MASTER_SSL_VERIFY_SERVER_CERT:!0,MATCH:!0,MAXVALUE:!0,MEDIUMBLOB:!0,MEDIUMINT:!0,MEDIUMTEXT:!0,MIDDLEINT:!0,MINUTE_MICROSECOND:!0,MINUTE_SECOND:!0,MOD:!0,MODIFIES:!0,NATURAL:!0,NOT:!0,NO_WRITE_TO_BINLOG:!0,NTH_VALUE:!0,NTILE:!0,NULL:!0,NUMERIC:!0,OF:!0,ON:!0,OPTIMIZE:!0,OPTIMIZER_COSTS:!0,OPTION:!0,OPTIONALLY:!0,OR:!0,ORDER:!0,OUT:!0,OUTER:!0,OUTFILE:!0,OVER:!0,PARTITION:!0,PERCENT_RANK:!0,PRECISION:!0,PRIMARY:!0,PROCEDURE:!0,PURGE:!0,RANGE:!0,RANK:!0,READ:!0,READS:!0,READ_WRITE:!0,REAL:!0,RECURSIVE:!0,REFERENCES:!0,REGEXP:!0,RELEASE:!0,RENAME:!0,REPEAT:!0,REPLACE:!0,REQUIRE:!0,RESIGNAL:!0,RESTRICT:!0,RETURN:!0,REVOKE:!0,RIGHT:!0,RLIKE:!0,ROW:!0,ROWS:!0,ROW_NUMBER:!0,SCHEMA:!0,SCHEMAS:!0,SECOND_MICROSECOND:!0,SELECT:!0,SENSITIVE:!0,SEPARATOR:!0,SET:!0,SHOW:!0,SIGNAL:!0,SMALLINT:!0,SPATIAL:!0,SPECIFIC:!0,SQL:!0,SQLEXCEPTION:!0,SQLSTATE:!0,SQLWARNING:!0,SQL_BIG_RESULT:!0,SQL_CALC_FOUND_ROWS:!0,SQL_SMALL_RESULT:!0,SSL:!0,STARTING:!0,STORED:!0,STRAIGHT_JOIN:!0,SYSTEM:!0,TABLE:!0,TERMINATED:!0,THEN:!0,TINYBLOB:!0,TINYINT:!0,TINYTEXT:!0,TO:!0,TRAILING:!0,TRIGGER:!0,TRUE:!0,UNDO:!0,UNION:!0,UNIQUE:!0,UNLOCK:!0,UNSIGNED:!0,UPDATE:!0,USAGE:!0,USE:!0,USING:!0,UTC_DATE:!0,UTC_TIME:!0,UTC_TIMESTAMP:!0,VALUES:!0,VARBINARY:!0,VARCHAR:!0,VARCHARACTER:!0,VARYING:!0,VIRTUAL:!0,WHEN:!0,WHERE:!0,WHILE:!0,WINDOW:!0,WITH:!0,WRITE:!0,XOR:!0,YEAR_MONTH:!0,ZEROFILL:!0};var mv={};Object.defineProperty(mv,"__esModule",{value:!0});mv.sqliteKeywords=void 0;mv.sqliteKeywords={ABORT:!0,ACTION:!0,ADD:!0,AFTER:!0,ALL:!0,ALTER:!0,ALWAYS:!0,ANALYZE:!0,AND:!0,AS:!0,ASC:!0,ATTACH:!0,AUTOINCREMENT:!0,BEFORE:!0,BEGIN:!0,BETWEEN:!0,BY:!0,CASCADE:!0,CASE:!0,CAST:!0,CHECK:!0,COLLATE:!0,COMMIT:!0,CONFLICT:!0,CONSTRAINT:!0,CREATE:!0,CROSS:!0,CURRENT:!0,CURRENT_DATE:!0,CURRENT_TIME:!0,CURRENT_TIMESTAMP:!0,DATABASE:!0,DEFAULT:!0,DEFERRABLE:!0,DEFERRED:!0,DELETE:!0,DESC:!0,DETACH:!0,DISTINCT:!0,DO:!0,DROP:!0,EACH:!0,ELSE:!0,END:!0,ESCAPE:!0,EXCEPT:!0,EXCLUDE:!0,EXCLUSIVE:!0,EXISTS:!0,EXPLAIN:!0,FAIL:!0,FILTER:!0,FIRST:!0,FOLLOWING:!0,FOR:!0,FOREIGN:!0,FROM:!0,FULL:!0,GENERATED:!0,GLOB:!0,GROUP:!0,GROUPS:!0,HAVING:!0,IF:!0,IGNORE:!0,IMMEDIATE:!0,IN:!0,INDEX:!0,INDEXED:!0,INITIALLY:!0,INNER:!0,INSERT:!0,INSTEAD:!0,INTERSECT:!0,INTO:!0,IS:!0,ISNULL:!0,JOIN:!0,LAST:!0,LEFT:!0,LIKE:!0,LIMIT:!0,MATCH:!0,MATERIALIZED:!0,NATURAL:!0,NO:!0,NOT:!0,NOTHING:!0,NOTNULL:!0,NULL:!0,NULLS:!0,OF:!0,OFFSET:!0,ON:!0,OR:!0,ORDER:!0,OTHERS:!0,OUTER:!0,OVER:!0,PARTITION:!0,PLAN:!0,PRAGMA:!0,PRECEDING:!0,PRIMARY:!0,QUERY:!0,RAISE:!0,RANGE:!0,RECURSIVE:!0,REFERENCES:!0,REGEXP:!0,REINDEX:!0,RELEASE:!0,RENAME:!0,REPLACE:!0,RESTRICT:!0,RETURNING:!0,RIGHT:!0,ROLLBACK:!0,ROW:!0,ROWS:!0,SAVEPOINT:!0,SELECT:!0,SET:!0,TABLE:!0,TEMP:!0,TEMPORARY:!0,THEN:!0,TIES:!0,TO:!0,TRANSACTION:!0,TRIGGER:!0,UNBOUNDED:!0,UNION:!0,UNIQUE:!0,UPDATE:!0,USING:!0,VACUUM:!0,VALUES:!0,VIEW:!0,VIRTUAL:!0,WHEN:!0,WHERE:!0,WINDOW:!0,WITH:!0,WITHOUT:!0};var Tv={};Object.defineProperty(Tv,"__esModule",{value:!0});Tv.postgresqlKeywords=void 0;Tv.postgresqlKeywords={ALL:!0,ANALYSE:!0,ANALYZE:!0,AND:!0,ANY:!0,ARRAY:!0,AS:!0,ASC:!0,ASYMMETRIC:!0,AUTHORIZATION:!0,BOTH:!0,CASE:!0,CAST:!0,CHECK:!0,COLLATE:!0,COLUMN:!0,CONSTRAINT:!0,CREATE:!0,CROSS:!0,CURRENT_CATALOG:!0,CURRENT_DATE:!0,CURRENT_ROLE:!0,CURRENT_SCHEMA:!0,CURRENT_TIME:!0,CURRENT_TIMESTAMP:!0,CURRENT_USER:!0,DAY:!0,DEFAULT:!0,DEFERRABLE:!0,DESC:!0,DISTINCT:!0,DO:!0,ELSE:!0,END:!0,EXCEPT:!0,FALSE:!0,FETCH:!0,FILTER:!0,FOR:!0,FOREIGN:!0,FREEZE:!0,FROM:!0,FULL:!0,GRANT:!0,GROUP:!0,HAVING:!0,HOUR:!0,ILIKE:!0,IN:!0,INITIALLY:!0,INNER:!0,INTERSECT:!0,INTO:!0,IS:!0,ISNULL:!0,JOIN:!0,LATERAL:!0,LEADING:!0,LEFT:!0,LIKE:!0,LIMIT:!0,LOCALTIME:!0,LOCALTIMESTAMP:!0,MINUTE:!0,MONTH:!0,NATURAL:!0,NOT:!0,NOTNULL:!0,NULL:!0,OFFSET:!0,ON:!0,ONLY:!0,OR:!0,ORDER:!0,OUTER:!0,OVER:!0,OVERLAPS:!0,PLACING:!0,PRECISION:!0,PRIMARY:!0,REFERENCES:!0,RETURNING:!0,RIGHT:!0,SECOND:!0,SELECT:!0,SESSION_USER:!0,SIMILAR:!0,SOME:!0,SYMMETRIC:!0,SYSTEM_USER:!0,TABLE:!0,TABLESAMPLE:!0,THEN:!0,TO:!0,TRAILING:!0,TRUE:!0,UNION:!0,UNIQUE:!0,USER:!0,USING:!0,VARIADIC:!0,VARYING:!0,VERBOSE:!0,WHEN:!0,WHERE:!0,WINDOW:!0,WITH:!0,WITHIN:!0,WITHOUT:!0,YEAR:!0,SET:!0};(function(o){var p=Nr&&Nr.__createBinding||(Object.create?function(n,s,c,e){e===void 0&&(e=c);var y=Object.getOwnPropertyDescriptor(s,c);(!y||("get"in y?!s.__esModule:y.writable||y.configurable))&&(y={enumerable:!0,get:function(){return s[c]}}),Object.defineProperty(n,e,y)}:function(n,s,c,e){e===void 0&&(e=c),n[e]=s[c]}),i=Nr&&Nr.__exportStar||function(n,s){for(var c in n)c!=="default"&&!Object.prototype.hasOwnProperty.call(s,c)&&p(s,n,c)};Object.defineProperty(o,"__esModule",{value:!0}),i(fv,o),i(yv,o),i(hv,o),i(mv,o),i(Tv,o)})(G2e);var Hm={};Object.defineProperty(Hm,"__esModule",{value:!0});Hm.FormattedSyntaxError=void 0;class TAi extends Error{constructor(p,i,n){super(vAi(p,i,n))}}Hm.FormattedSyntaxError=TAi;function vAi(o,p,i){const n=o.location.start.line,s=o.location.start.column,c=p.split(/\r\n|\n|\r/)[n-1],e="".padStart(String(n).length),y=bAi(EAi(o.found,s,c)),m=AAi(o.expected);return`Syntax Error: Unexpected ${y}
|
|
98
|
+
You shouldn't have to manually update a 'parent' property. The equivalent result is to change its value readers, value writters, or callers.`})),{errors:n,modifiedData:s}}subscribeDependents(i){return i.forEach(n=>{this.detachedDependents[n.entity.id]||(this.detachedDependents[n.entity.id]=n)}),this}unsubscribeDependents(i){return i.forEach(n=>{this.detachedDependents[n.entity.id]&&delete this.detachedDependents[n.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"sync-dependents"))){const n=[],s=[],c=[],e=[];return Object.values(this.detachedDependents).forEach(y=>{const m=y.entity.afterAllChildrenInitialized(i);n.push(...m.updated),s.push(...m.added),c.push(...m.removed),e.push(...m.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}onDetachedDependencyRemoved(i,n,s){const c=[],e=[],y=[],m=[];if(n==="variable-declaration-parent"){const{updated:v,added:E,removed:b}=this.remove({ignoreUpstream:!1},s);c.push(...v),e.push(...E),y.push(...b)}return{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:this}}onDetachedDependencyRestored(i,n,s){const c=[],e=[],y=[],m=[];if(n==="variable-declaration-parent"){const{updated:v,added:E,removed:b}=this.restore({},s);c.push(...v),e.push(...E),y.push(...b)}return{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:this}}unsubscribeFromDependencies(){var i,n,s,c,e,y;return(i=this.parent)==null||i.unsubscribeDependents([{entity:this,field:"variable-declaration-parent"}]),(c=(s=(n=this.dataType)==null?void 0:n.entity)==null?void 0:s.unsubscribeDependents)==null||c.call(s,[{entity:this,field:"variable-declaration-data-type-entity"}]),(y=(e=this.dataType)==null?void 0:e.unsubscribeDependents)==null||y.call(e,[{entity:this,field:"variable-declaration-data-type"}]),this}subscribeToDependencies(){var i,n,s,c,e,y;return(i=this.parent)==null||i.subscribeDependents([{entity:this,field:"variable-declaration-parent"}]),(c=(s=(n=this.dataType)==null?void 0:n.entity)==null?void 0:s.subscribeDependents)==null||c.call(s,[{entity:this,field:"variable-declaration-data-type-entity"}]),(y=(e=this.dataType)==null?void 0:e.subscribeDependents)==null||y.call(e,[{entity:this,field:"variable-declaration-data-type"}]),this}increaseVersion(i){if(i&&!M(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&M(i).isSame(M(this.createdAt))?this:(this.previousVersion=this.version,this.version=x.UUID.uuid(),this.createdAt=M(i).toISOString()||M().toISOString(),this)}captureVersion(){var n;const i=((n=this.knownVersions)==null?void 0:n.get(this.version))||new mi(this,this.project);return i.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map([[this.version,i]]),i.inputs=[...this.inputs],i.outputs=[...this.outputs],i.internalCalls=[...this.internalCalls],i.successCalls=[...this.successCalls],i.errorCalls=[...this.errorCalls],i.writesValues=[...this.writesValues],i.readsValue=this.readsValue,i.defaultValue=this.defaultValue,i.dataType=this.dataType,i.calledBySuccess=[...this.calledBySuccess],i.calledByError=[...this.calledByError],i.calledByEntry=[...this.calledByEntry],i.error=this.error,i.parent=this.parent,this}recursiveCaptureUpstreamVersions(i){const n=[],s=[],c=[],e=[];if(this.parent){this.parent.increaseVersion(i);const y=this.parent.recursiveCaptureUpstreamVersions(i);n.push(this.parent,...y.updated),s.push(...y.added),c.push(...y.removed)}return{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}async restoreVersion(i){var m;const n=[],s=[],c=[],e=[];if(this.version===i)return{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this};if(!this.knownVersions){const v=new Map;for(const[E,b]of this.knownVersions||new Map){if(v.set(E,b),b.activeVersion=!1,b.knownVersions)for(const[w,V]of b.knownVersions)v.set(w,V);b.knownVersions=null}}let y=(m=this.knownVersions)==null?void 0:m.get(i);if(!y){const v=await this.APILoadVersion({},i);if(!v)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);y=new mi(v,this.project)}return this.metaSync(y.toShallowJSON(),null),this.previousVersion=y.previousVersion,this.version=y.version,this.createdAt=y.createdAt,this.author=y.author,this.deleted=y.deleted,this.inputs=y.inputs,this.outputs=y.outputs,this.internalCalls=y.internalCalls,this.successCalls=y.successCalls,this.errorCalls=y.errorCalls,this.writesValues=y.writesValues,this.readsValue=y.readsValue,this.defaultValue=y.defaultValue,this.dataType=y.dataType,this.calledBySuccess=y.calledBySuccess,this.calledByError=y.calledByError,this.calledByEntry=y.calledByEntry,this.error=y.error,this.parent=y.parent,{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}updateWithShallowTransfer(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.UpdateWithShallowTransfer))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[updateWithShallowTransfer] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),this;if(this.metaSync(i,n),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 s=ne(i.parent),c=this.project.get(s),e=this.parent;if(e&&e.id!==(c==null?void 0:c.id)&&this.removeFromParent(n),c)this.setParent(c,n),this.addSelfToProject(n);else throw n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${s}' that isn't found in the project`)}else throw n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(i.readsValue){const s=ne(i.readsValue),c=this.project.get(s),e=this.readsValue;e&&e.id!==(c==null?void 0:c.id)&&this.removeValueWriter(n),c&&this.setValueWriter(c,n)}else this.removeValueWriter(n);if(i.calledByEntry.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addEntryCaller(e,n),e.addCall(this,n))}),[...this.calledByEntry].forEach(s=>{i.calledByEntry.find(e=>ne(e)===s.id)||(this.removeCaller(s,n),s.removeCall(this,n))}),i.calledBySuccess.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addSuccessCaller(e,n),e.addSuccessCall(this,n))}),[...this.calledBySuccess].forEach(s=>{i.calledBySuccess.find(e=>ne(e)===s.id)||(this.removeCaller(s,n),s.removeCall(this,n))}),i.calledByError.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addErrorCaller(e,n),e.addErrorCall(this,n))}),[...this.calledByError].forEach(s=>{i.calledByError.find(e=>ne(e)===s.id)||(this.removeCaller(s,n),s.removeCall(this,n))}),i.outputs.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addOutput(e,n),e.setParent(this,n))}),[...this.outputs].forEach(s=>{i.outputs.find(e=>ne(e)===s.id)||(this.removeOutput(s,n),s.removeFromParent(n))}),i.inputs.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addInput(e,n),e.setParent(this,n))}),[...this.inputs].forEach(s=>{i.inputs.find(e=>ne(e)===s.id)||(this.removeInput(s,n),s.removeFromParent(n))}),i.dataType){const s=ne(i.dataType),c=this.project.get(s);c&&this.setDataType(c,n)}else this.setDataType(null,n);if(i.defaultValue){const s=ne(i.defaultValue),c=this.project.get(s);c&&this.setDefaultValue(c,n)}else this.setDefaultValue(null,n);return i.writesValues.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addValueReader(e,n),e.setValueWriter(this,n))}),[...this.writesValues].forEach(s=>{i.writesValues.find(e=>ne(e)===s.id)||(this.removeValueReader(s,n),s.setValueWriter(null,n))}),this.captureVersion(),this.subscribeToDependencies(),n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),this}hydrateAncestors(){const i=[],n=[],s=[],c=[];if(this.initialData.parent){const e=ne(this.initialData.parent),y=this.project.get(e);if(y)this.setParent(y,null),i.push(y);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.readsValue){const e=ne(this.initialData.readsValue),y=this.project.get(e);y&&(this.setValueWriter(y,null),i.push(y))}return this.initialData.calledByEntry.forEach(e=>{const y=ne(e),m=this.project.get(y);m&&this.addEntryCaller(m,null)}),this.initialData.calledBySuccess.forEach(e=>{const y=ne(e),m=this.project.get(y);m&&this.addSuccessCaller(m,null)}),this.initialData.calledByError.forEach(e=>{const y=ne(e),m=this.project.get(y);m&&this.addErrorCaller(m,null)}),{updated:D(i),added:D(n),removed:D(s),affected:D(c),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AfterAllChildrenInitialized))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[afterAllChildrenInitialized] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.AfterAllChildrenInitialized,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];if(this.initialized=!0,!this.dataType||this.dataType.inferred){const{added:Ne,updated:Be,removed:Se,affected:je}=this.inferDataTypeAndSyncInstancesInputsAndOutputs(i);s.push(...Ne),n.push(...Be),c.push(...Se),e.push(...je)}const{added:y,updated:m,removed:v,affected:E}=this.syncInputs(i);s.push(...y),n.push(...m),c.push(...v),e.push(...E);const{added:b,updated:w,removed:V,affected:$}=this.syncOutputs(i);s.push(...b),n.push(...w),c.push(...V),e.push(...$);const{added:L,updated:k,removed:K,affected:S}=this.generateUnusedInternalCalls(i);s.push(...L),n.push(...k),c.push(...K),e.push(...S);const{added:Y,updated:re,removed:ee,affected:de}=this.removeUnrecognizedInputs(i);s.push(...Y),n.push(...re),c.push(...ee),e.push(...de);const{added:le,updated:fe,removed:ve,affected:ue}=this.removeUnrecognizedOutputs(i);s.push(...le),n.push(...fe),c.push(...ve),e.push(...ue);const{added:ye,updated:Ve,removed:_e,affected:$e}=this.removeUnrecognizedInternalCalls(i);return s.push(...ye),n.push(...Ve),c.push(..._e),e.push(...$e),this.parent===this.project&&(this.catchesError&&(i==null||i.event({id:`${_.RemoveErrorCatching}-${this.id}`,action:_.RemoveErrorCatching,owner:this,errorReason:Ii.GlobalVariableDeclarationCannnotCatchError,rootAction:!1}),this.metaSync({catchesError:!1},i)),this.errorCalls.length&&(i==null||i.event({id:`${_.RemoveAllErrorCalls}-${this.id}`,action:_.RemoveAllErrorCalls,owner:this,errorReason:Ii.GlobalVariableDeclarationCannotCallFromError,rootAction:!1}),[...this.errorCalls].forEach(Ne=>{this.removeCall(Ne,i),Ne.removeCaller(this,i)})),this.calledBy.length&&(i==null||i.event({id:`${_.RemoveAllCallers}-${this.id}`,action:_.RemoveAllCallers,owner:this,errorReason:Ii.GlobalVariableDeclarationCannotBeCalled,rootAction:!1}),[...this.calledBy].forEach(Ne=>{this.removeCaller(Ne,i),Ne.removeCall(this,i)}))),this.inputs.sort((Ne,Be)=>{var Se,je;return(Ne.index??((Se=Ne.declaration)==null?void 0:Se.index))-(Be.index??((je=Be.declaration)==null?void 0:je.index))}),this.outputs.sort((Ne,Be)=>{var Se,je;return(Ne.index??((Se=Ne.declaration)==null?void 0:Se.index))-(Be.index??((je=Be.declaration)==null?void 0:je.index))}),this.captureVersion(),i==null||i.attemptAutoclose(_.AfterAllChildrenInitialized,this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}addSelfToProject(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"add-self-to-project"))){const n=[this],s=[],c=[],e=[];return this.parent===this.project&&this.project.addVariableDeclaration(this),this.readsValue&&(this.readsValue.addValueReader(this,i),n.push(this.readsValue)),this.writesValues.forEach(y=>{y.setValueWriter(this,i),n.push(y)}),this.successCalls.forEach(y=>{y.addSuccessCaller(this,i),n.push(y)}),this.errorCalls.forEach(y=>{y.addErrorCaller(this,i),n.push(y)}),this.calledBySuccess.forEach(y=>{y.addSuccessCall(this,i),n.push(y)}),this.calledByError.forEach(y=>{y.addErrorCall(this,i),n.push(y)}),this.calledByEntry.forEach(y=>{y.addCall(this,i),n.push(y)}),this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}get usedInputs(){return this.inputs.filter(i=>i.readsValue||i.defaultValue)}get unusedInputs(){return this.inputs.filter(i=>!i.readsValue&&!i.defaultValue)}get usedOutputs(){return this.outputs.filter(i=>i.writesValues.length)}get unusedOutputs(){return this.outputs.filter(i=>!i.writesValues.length)}get usedInternalCalls(){return this.internalCalls.filter(i=>!!i.calledBy.length)}get unusedInternalCalls(){return this.internalCalls.filter(i=>!i.calledBy.length)}removeInternalCall(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-variable-declaration-internal-call"))){const s=this.internalCalls.findIndex(c=>c.id===i.id);return s>-1&&(this.internalCalls.splice(s,1),n&&(n==null||n.add(this,H.Affected))),n==null||n.attemptAutoclose("remove-variable-declaration-internal-call",this.id),this}removeInput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveInput))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[removeInput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.RemoveInput,this.id),this;const s=this.inputs.findIndex(c=>c.id===i.id);return s>-1&&(this.inputs.splice(s,1),n&&(n==null||n.add(this,H.Affected))),n==null||n.attemptAutoclose(_.RemoveInput,this.id),this}addInput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddInput))){return this.checkCanEdit(this,n)?this.inputs.includes(i)?(n==null||n.attemptAutoclose(_.AddInput,this.id),this):(this.inputs.push(i),n==null||n.add(this,H.Affected),n==null||n.attemptAutoclose(_.AddInput,this.id),this):(J.Logger.warn(`[addInput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.AddInput,this.id),this)}addOutput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"add-output"))){return this.checkCanEdit(this,n)?this.outputs.includes(i)?(n==null||n.attemptAutoclose("add-output",this.id),this):(this.outputs.push(i),n==null||n.add(this,H.Affected),n==null||n.attemptAutoclose("add-output",this.id),this):(J.Logger.warn(`[addOutput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("add-output",this.id),this)}removeOutput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-output"))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[removeOutput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("remove-output",this.id),this;const s=this.outputs.findIndex(c=>c.id===i.id);return s>-1&&(this.outputs.splice(s,1),n&&(n==null||n.add(this,H.Affected))),n==null||n.attemptAutoclose("remove-output",this.id),this}addSuccessCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddSuccessCaller)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddSuccessCaller,n)?(this.calledBySuccess.find(c=>c.id===i.id)||(this.calledBySuccess.push(i),n==null||n.add(this,H.Updated),s&&mt(this,n)),n==null||n.attemptAutoclose(_.AddSuccessCaller,this.id),this):this}addErrorCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddErrorCaller)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddErrorCaller,n)?(this.calledByError.find(c=>c.id===i.id)||(this.calledByError.push(i),n==null||n.add(this,H.Updated),s&&mt(this,n)),n==null||n.attemptAutoclose(_.AddErrorCaller,this.id),this):this}addEntryCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddEntryCaller)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddEntryCaller,n)?(this.calledByEntry.find(c=>c.id===i.id)||(this.calledByEntry.push(i),n==null||n.add(this,H.Updated),s&&mt(this,n)),n==null||n.attemptAutoclose(_.AddEntryCaller,this.id),this):this}addErrorCall(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddErrorCall)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddErrorCall,n)?(this.errorCalls.find(c=>c.id===i.id)||(this.errorCalls.push(i),s&&mt(this,n),n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose(_.AddErrorCall,this.id),this):this}addSuccessCall(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddSuccessCall)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddSuccessCall,n)?(this.successCalls.find(c=>c.id===i.id)||(this.successCalls.push(i),s&&mt(this,n),n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose(_.AddSuccessCall,this.id),this):this}removeCall(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveCall)),s=!1){if(!this.checkCanEditWithCounterpartAndSideEffects(this,i,_.RemoveCall,n))return this;const c=this.successCalls.findIndex(y=>y.id===i.id);c>-1&&(this.successCalls.splice(c,1),n==null||n.add(this,H.Affected));const e=this.errorCalls.findIndex(y=>y.id===i.id);return e>-1&&(this.errorCalls.splice(e,1),n==null||n.add(this,H.Affected)),s&&mt(this,n),n==null||n.attemptAutoclose(_.RemoveCall,this.id),this}removeCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-caller")),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.RemoveCaller,n)?(this.calledBySuccess=this.calledBySuccess.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),this.calledByError=this.calledByError.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),this.calledByEntry=this.calledByEntry.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),s&&mt(this,n),n==null||n.attemptAutoclose(_.RemoveCaller,this.id),this):this}addValueReader(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddValueReader))){var e,y,m;if(!this.checkCanEditFromScopeOwnerWithSideEffects(this,_.AddValueReader,n))return this;const s=i.type===d.InputMap&&i.parent.type===d.VariableInstance&&((e=i.declaration)==null?void 0:e.type)===d.Property&&((y=i.declaration)==null?void 0:y.constant),c=i.type===d.VariableInstance&&((m=i.declaration)==null?void 0:m.constant);return(s||c)&&i?(n==null||n.event({id:`${_.SetValueWriter}-${this.id}--${this.id}`,action:_.SetValueWriter,owner:i,counterpart:this,errorReason:Ii.ValueReadingOverridesConstantVariable,rootAction:!1}),n==null||n.attemptAutoclose(_.AddValueReader,this.id),this):this.writesValues.includes(i)?(n==null||n.attemptAutoclose(_.AddValueReader,this.id),this):(this.writesValues.push(i),n==null||n.add(this,H.Affected),this)}removeValueReader(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveValueReader))){return this.checkCanEditFromScopeOwnerWithSideEffects(this,_.RemoveValueReader,n)?this.writesValues.includes(i)?(this.writesValues=this.writesValues.filter(s=>s.id!==i.id),n==null||n.add(this,H.Affected),this):(n==null||n.attemptAutoclose(_.RemoveValueReader,this.id),this):this}setError(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetErrorEntity))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setError] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.SetErrorEntity,this.id),this;const s=this.error;return(s==null?void 0:s.id)!==(i==null?void 0:i.id)&&(s==null||s.remove({ignoreUpstream:!0},n),this.error=i,this.subscribeToDependencies(),n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose(_.SetErrorEntity,this.id),this}setParent(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetParent))){var s;return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.SetParent,n)?(((s=this.parent)==null?void 0:s.id)!==(i==null?void 0:i.id)&&(this.parent=i,n&&(n==null||n.add(this,H.Updated))),n==null||n.attemptAutoclose(_.SetParent,this.id),this):this}initChildren(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"init-children"))){if(this.initialized||this.startedInitialization)return this;if(this.startedInitialization=!0,this.initialData.defaultValue&&(this.defaultValue=me(this.initialData.defaultValue,this.project),this.defaultValue.setParent(this,null),this.defaultValue.initChildren(i)),this.initialData.dataType){const n=me(this.initialData.dataType,this.project);this.setDataType(n,i),this.dataType.setParent(this,null),this.dataType.initChildren(i)}return Pv.initWritesValues(this,this.parent),lf.initReadsValue(this),this.successCalls=this.initialData.successCalls.map(n=>{const s=me(n,this.project);if(s.addSuccessCaller(this,null),[d.BreakStatement,d.ContinueStatement].includes(s.type))s.setParent(this.parent.parent,null),s.initChildren(i);else if(s.type===d.ReturnStatement){const c=tn(this,this.project);s.setParent(c,null),s.initChildren(i)}else s.type!==d.InternalCall&&(s.setParent(this.parent,null),s.initChildren(i));return s}),this.errorCalls=this.initialData.errorCalls.map(n=>{const s=me(n,this.project);if(s.addErrorCaller(this,null),[d.BreakStatement,d.ContinueStatement].includes(s.type))s.setParent(this.parent.parent,null),s.initChildren(i);else if(s.type===d.ReturnStatement){const c=tn(this,this.project);s.setParent(c,null),s.initChildren(i)}else s.type!==d.InternalCall&&(s.setParent(this.parent,null),s.initChildren(i));return s}),this.initialData.inputs.forEach(n=>{const s=me(n,this.project);return s.setParent(this,null),s.initChildren(i),this.addInput(s,null),s}),this.initialData.outputs.forEach(n=>{const s=me(n,this.project);return s.setParent(this,null),s.initChildren(i),this.addOutput(s,null),s}),this.initialData.internalCalls.forEach(n=>{if(n.type===d.GenericReference){const c=this.project.findSubscribedInstanceFromReference(n);if(!c)return;c.setParent(this,null),c.initChildren(i),this.addInternalCall(c);return}const s=me(n,this.project);return s.setParent(this,null),s.initChildren(i),this.addInternalCall(s),s}),this.initialData.error&&(this.error=me(this.initialData.error,this.project),this.error.setParent(this,null),this.error.initChildren(i)),this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this}setValueWriter(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetValueWriter))){var s;return this.checkCanEditFromScopeOwnerWithSideEffects(this,_.SetValueWriter,n)?(this.readsValue!==i&&(this.readsValue=i,this.readsValue&&((s=this.defaultValue)==null||s.remove({ignoreUpstream:!1},n)),n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose(_.SetValueWriter,this.id),this):this}removeValueWriter(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveValueWriter))){return this.readsValue&&!this.checkCanEditWithCounterpartAndSideEffects(this,this.readsValue,_.RemoveValueWriter,i)?this:(this.readsValue&&(this.readsValue=null,i==null||i.add(this,H.Updated)),i==null||i.attemptAutoclose(_.RemoveValueWriter,this.id),this)}subscribe(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}getMasterInputWithValueWritterFromAllInstances(i){return D([...this.inputs,...this.variableInstances.flatMap(c=>c.inputs)]).find(c=>se(c,this.project)===se(i,this.project)&&!!c.readsValue)||i}inferDataTypeAndSyncInstancesInputsAndOutputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"infer-data-type-and-sync-instances-inputs-and-outputs"))){var K,S,Y,re,ee,de,le;const n=[],s=[],c=[],e=[];if(!this.dataType){const fe=ur.new(i);fe.parent=this.toReference(),fe.inferred=!0;const ve=me(fe,this.project);ve.hydrateAncestors(),ve.addSelfToProject(i),this.setDataType(ve,i),ve.setParent(this,i),ve.initChildren(i),i==null||i.add(ve,H.Added),ve.metaSync({inferred:!0,like:!0},i)}if(this.readsValue&&((K=this.dataType)!=null&&K.inferred)){const fe=this.readsValue.getDataType(null);fe&&((S=this.dataType)==null||S.merge(fe,i),this.dataType.metaSync({inferred:!0,like:!0},i))}const y=D([...this.inputs,...this.variableInstances.flatMap(fe=>fe.inputs)]),m=[];if(y.forEach(fe=>{m.find(ue=>se(ue,this.project)===se(fe,this.project))||m.push(fe)}),(!((Y=this.dataType)!=null&&Y.entity)||((ee=(re=this.dataType)==null?void 0:re.entity)==null?void 0:ee.type)===d.DefinitionEntity&&((de=this.dataType)==null?void 0:de.entity.parent)===this.dataType)&&((le=this.dataType)==null||le.inferFromInputs(m,i)),!this.dataType)return i==null||i.attemptAutoclose("infer-data-type-and-sync-instances-inputs-and-outputs",this.id),{updated:D(s),added:D(n),removed:D(c),affected:D(e),self:this};const{updated:v,added:E,removed:b,affected:w}=this.syncInputs(i);n.push(...E),s.push(...v),c.push(...b),e.push(...w);const{updated:V,added:$,removed:L,affected:k}=this.syncOutputs(i);return n.push(...$),s.push(...V),c.push(...L),e.push(...k),this.variableInstances.forEach(fe=>{const{updated:ve,added:ue,removed:ye,affected:Ve}=fe.syncInputs(i);n.push(...ue),s.push(...ve),c.push(...ye),e.push(...Ve);const{updated:_e,added:$e,removed:Ne,affected:Be}=fe.syncOutputs(i);n.push(...$e),s.push(..._e),c.push(...Ne),e.push(...Be)}),i==null||i.attemptAutoclose("infer-data-type-and-sync-instances-inputs-and-outputs",this.id),{updated:D(s),added:D(n),removed:D(c),affected:D(e),self:this}}metaSync(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"meta-sync"))){const s=Mr(this,i,n),c=Lr(this,s),e=this.toMeta();return this.name=s.name!==void 0?s.name:e.name,this.codeName=s.codeName!==void 0?s.codeName:e.codeName,this.description=s.description!==void 0?s.description:e.description,this.x=s.x||e.x,this.y=s.y||e.y,this.constant=s.constant!==void 0?s.constant:e.constant,this.required=s.required!==void 0?s.required:e.required,this.catchesError=s.catchesError!==void 0?s.catchesError:this.catchesError,super.baseMetaSync(s,this,n),s.deleted===!0&&!e.deleted?n==null||n.add(this,H.Removed):s.deleted===!1&&e.deleted?n==null||n.add(this,H.Added):c&&(n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=ke,...n){return await mi.repository.APILoad(this.id,...n),this}async APICreate(i=ke,...n){return await mi.repository.APICreate(this.toShallowJSON(),...n),this}async APIUpdate(i=ke,...n){return await mi.repository.APIUpdate(this.toShallowJSON(),...n),this}async APIDelete(i=ke,...n){return await mi.repository.APIDelete(this.toShallowJSON(),...n),this}async APIClone(i=ke,...n){return await mi.repository.APIClone(this.id,...n),this}async APILoadVersion(i=ke,n,...s){return await mi.repository.APILoadVersion(this.id,n,...s)}removeFromParent(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveFromParent))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[removeFromParent] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveFromParent,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];return this.parent.type===d.Project?(this.parent.removeVariableDeclaration(this),e.push(this.parent)):this.parent.detachedChildren.includes(this)&&this.parent.unsubscribeDetachedChild(this),i==null||i.attemptAutoclose(_.RemoveFromParent,this.id),{added:D(c),updated:D(n),removed:D(s),affected:D(e),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveEntity))){var m;if(!this.checkCanDelete(this,n))return J.Logger.warn(`[remove] User is not allowed to delete or edit this ${this.type} entity with id: ${this.id}`),n==null||n.event({id:`${_.RemoveEntity}-${this.id}`,action:_.RemoveEntity,owner:this,errorReason:Ii.ActionOwnerEntityNonDeletable,rootAction:((m=n==null?void 0:n.self)==null?void 0:m.id)===this.id&&(n==null?void 0:n.autoCloseActionName)===_.RemoveEntity}),n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const s=[],c=[],e=[],y=[];if(n!=null&&n.hasRemoved(this.id))return n==null||n.attemptAutoclose(_.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},n),Object.values(this.detachedDependents).forEach(v=>{const{updated:E,removed:b,added:w}=v.entity.onDetachedDependencyRemoved(this,v.field,n);s.push(...E),c.push(...b),e.push(...w)}),this.defaultValue){const{updated:v,removed:E}=this.defaultValue.remove({ignoreUpstream:!0},n);s.push(...v),c.push(...E)}if(this.readsValue&&(s.push(this.readsValue),this.readsValue.removeValueReader(this,n)),this.writesValues.forEach(v=>{s.push(v),v.setValueWriter(null,n)}),this.inputs.forEach(v=>{const{updated:E,removed:b}=v.remove({ignoreUpstream:!0},n);s.push(...E),c.push(...b)}),this.outputs.forEach(v=>{const{updated:E,removed:b}=v.remove({ignoreUpstream:!0},n);s.push(...E),c.push(...b)}),this.successCalls.forEach(v=>{s.push(v),v.removeCaller(this,n)}),this.errorCalls.forEach(v=>{s.push(v),v.removeCaller(this,n)}),this.internalCalls.forEach(v=>{const{updated:E,removed:b}=v.remove({ignoreUpstream:!0},n);s.push(...E),c.push(...b)}),this.dataType){const{updated:v,removed:E}=this.dataType.remove({ignoreUpstream:!0},n);s.push(...v),c.push(...E)}if(!i){const v=this.removeFromParent(n);e.push(...v.added),s.push(...v.updated),c.push(...v.removed),y.push(...v.affected),this.calledBy.forEach(E=>{s.push(E),E.removeCall(this,n)})}return n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:D(e),updated:D(s),removed:D(c),affected:D(y),self:this}}restore({}={},i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RestoreEntity))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[restore] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];if(i!=null&&i.hasAdded(this.id))return i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},i),Object.values(this.detachedDependents).forEach(y=>{const{updated:m,removed:v,added:E}=y.entity.onDetachedDependencyRestored(this,y.field,i);s.push(...m),c.push(...v),n.push(...E)}),this.defaultValue){const{updated:y}=this.defaultValue.restore({},i);s.push(...y)}if(this.readsValue&&(s.push(this.readsValue),this.readsValue.addValueReader(this,i)),this.writesValues.forEach(y=>{s.push(y),y.setValueWriter(this,i)}),this.inputs.forEach(y=>{const{updated:m}=y.restore({},i);s.push(...m)}),this.outputs.forEach(y=>{const{updated:m}=y.restore({},i);s.push(...m)}),this.successCalls.forEach(y=>{s.push(y),y.addSuccessCaller(this,i)}),this.errorCalls.forEach(y=>{s.push(y),y.addErrorCaller(this,i)}),this.internalCalls.forEach(y=>{const{updated:m}=y.restore({},i);s.push(...m)}),this.dataType){const{updated:y}=this.dataType.restore({},i);s.push(...y)}return this.calledBySuccess.forEach(y=>{s.push(y),y.addSuccessCall(this,i)}),this.calledByError.forEach(y=>{s.push(y),y.addErrorCall(this,i)}),this.calledByEntry.forEach(y=>{s.push(y),y.addCall(this,i)}),i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this}}toFlat(i=new Set){var s,c,e;return i.has(this.id)?[]:(i.add(this.id),[this,...((s=this.defaultValue)==null?void 0:s.toFlat(i))||[],...((c=this.dataType)==null?void 0:c.toFlat(i))||[],...((e=this.readsValue)==null?void 0:e.toFlat(i))||[],...this.writesValues.flatMap(y=>y.toFlat(i)),...this.successCalls.flatMap(y=>y.toFlat(i)),...this.errorCalls.flatMap(y=>y.toFlat(i)),...this.inputs.flatMap(y=>y.toFlat(i)),...this.outputs.flatMap(y=>y.toFlat(i)),...this.internalCalls.flatMap(y=>y.toFlat(i)),...this.calledBy.flatMap(y=>y.toFlat(i)),...this.variableInstances.flatMap(y=>y.toFlat(i))])}toFlatIds(i=new Set){var s,c;return i.has(this.id)?[]:(i.add(this.id),[this.id,...((s=this.defaultValue)==null?void 0:s.toFlatIds(i))||[],...((c=this.dataType)==null?void 0:c.toFlatIds(i))||[],...this.writesValues.flatMap(e=>e.toFlatIds(i)),...this.successCalls.flatMap(e=>e.toFlatIds(i)),...this.errorCalls.flatMap(e=>e.toFlatIds(i)),...this.inputs.flatMap(e=>e.toFlatIds(i)),...this.outputs.flatMap(e=>e.toFlatIds(i)),...this.internalCalls.flatMap(e=>e.toFlatIds(i)),...this.variableInstances.flatMap(e=>e.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,catchesError:this.catchesError,description:this.description,required:this.required,constant:this.constant,x:this.x,y:this.y,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name}}toJSON(i=new Set){var n,s,c,e;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,catchesError:this.catchesError,constant:this.constant,required:this.required,defaultValue:((n=this.defaultValue)==null?void 0:n.toJSON(i))||null,dataType:((s=this.dataType)==null?void 0:s.toJSON(i))||null,readsValue:((c=this.readsValue)==null?void 0:c.toReference())||null,writesValues:this.writesValues.map(y=>y.toJSON(i)),inputs:this.inputs.map(y=>y.toJSON(i)),outputs:this.outputs.map(y=>y.toJSON(i)),successCalls:this.successCalls.map(y=>y.toJSON(i)),errorCalls:this.errorCalls.map(y=>y.toJSON(i)),internalCalls:this.internalCalls.map(y=>y.toJSON(i)),calledBySuccess:this.calledBySuccess.map(y=>y.toReference()),calledByError:this.calledByError.map(y=>y.toReference()),calledByEntry:this.calledByEntry.map(y=>y.toReference()),error:((e=this.error)==null?void 0:e.toJSON(i))||null,parent:this.parent.toReference(),x:this.x,y:this.y})}toJSONClone(i=ct){var s,c,e,y,m,v,E,b,w;let n;return(s=i.seenEntityMaps)!=null&&s.has(this.id)?n=i.seenEntityMaps.get(this.id):(n=i.newId||jr(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,n)),(c=i.seenEntities)!=null&&c.has(n)||(e=i.seenEntities)!=null&&e.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((y=i.seenEntities)==null||y.add(n),(m=i.seenEntities)==null||m.add(this.id),{id:n,version:x.UUID.uuid(),createdAt:i.timestamp||M().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,codeName:this.codeName,constant:this.constant,required:this.required,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name,description:this.description,catchesError:this.catchesError,defaultValue:((v=this.defaultValue)==null?void 0:v.toJSONClone({...i,newId:null}))||null,dataType:((E=this.dataType)==null?void 0:E.toJSONClone({...i,newId:null}))||null,readsValue:((b=this.readsValue)==null?void 0:b.toReference({seenEntityMaps:i.seenEntityMaps}))||null,writesValues:this.writesValues.map(V=>V.toJSONClone({...i,newId:null})),inputs:this.inputs.map(V=>V.toJSONClone({...i,newId:null})),outputs:this.outputs.map(V=>V.toJSONClone({...i,newId:null})),successCalls:this.successCalls.map(V=>V.toJSONClone({...i,newId:null})),errorCalls:this.errorCalls.map(V=>V.toJSONClone({...i,newId:null})),internalCalls:this.internalCalls.map(V=>this.calledBy.length||this.readsValue?V.toJSONClone({...i,newId:null}):V.toReference({seenEntityMaps:i.seenEntityMaps})),calledBySuccess:this.calledBySuccess.map(V=>V.toReference({seenEntityMaps:i.seenEntityMaps})),calledByError:this.calledByError.map(V=>V.toReference({seenEntityMaps:i.seenEntityMaps})),calledByEntry:this.calledByEntry.map(V=>V.toReference({seenEntityMaps:i.seenEntityMaps})),error:((w=this.error)==null?void 0:w.toJSONClone({...i,newId:null}))||null,parent:this.parent.toReference({seenEntityMaps:i.seenEntityMaps}),x:this.x,y:this.y})}toReference(i=ct){var s;let n=this.id;return(s=i.seenEntityMaps)!=null&&s.has(this.id)&&(n=i.seenEntityMaps.get(this.id)),{id:n+"--"+x.UUID.uuid()+"--ref",type:d.GenericReference,entityId:n,version:this.version,entityType:this.type}}toShallowJSON(i=ct){var s,c,e,y,m;let n=this.id;return(s=i.seenEntityMaps)!=null&&s.has(this.id)&&(n=i.seenEntityMaps.get(this.id)),{id:n,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,catchesError:this.catchesError,required:this.required,constant:this.constant,x:this.x,y:this.y,defaultValue:((c=this.defaultValue)==null?void 0:c.toReference(i))||null,dataType:((e=this.dataType)==null?void 0:e.toReference(i))||null,readsValue:((y=this.readsValue)==null?void 0:y.toReference(i))||null,writesValues:this.writesValues.map(v=>v.toReference(i)),inputs:this.inputs.map(v=>v.toReference(i)),outputs:this.outputs.map(v=>v.toReference(i)),successCalls:this.successCalls.map(v=>v.toReference(i)),errorCalls:this.errorCalls.map(v=>v.toReference(i)),calledBySuccess:this.calledBySuccess.map(v=>v.toReference(i)),calledByError:this.calledByError.map(v=>v.toReference(i)),calledByEntry:this.calledByEntry.map(v=>v.toReference(i)),internalCalls:this.internalCalls.map(v=>v.toReference(i)),error:((m=this.error)==null?void 0:m.toReference(i))||null,parent:this.parent.toReference(i)}}toFlatJSON(i=new Set){var s,c;return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...((s=this.defaultValue)==null?void 0:s.toFlatJSON(i))||[],...((c=this.dataType)==null?void 0:c.toFlatJSON(i))||[],...this.writesValues.flatMap(e=>e.toFlatJSON(i)),...this.successCalls.flatMap(e=>e.toFlatJSON(i)),...this.errorCalls.flatMap(e=>e.toFlatJSON(i)),...this.inputs.flatMap(e=>e.toFlatJSON(i)),...this.outputs.flatMap(e=>e.toFlatJSON(i)),...this.internalCalls.flatMap(e=>e.toFlatJSON(i))])}toGenerationTarget(){const i=this.parent.type===d.Project?void 0:this.parent.id;return{id:this.id,type:this.type,name:this.name,description:this.description,calledByEntry:this.calledByEntry.map(n=>n.id),calledBySuccess:this.calledBySuccess.map(n=>n.id),calledByError:this.calledByError.map(n=>n.id),parent:i}}toFlatGenerationTarget(i=new Set){var s,c;return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...((s=this.defaultValue)==null?void 0:s.toFlatGenerationTarget(i))||[],...((c=this.dataType)==null?void 0:c.toFlatGenerationTarget(i))||[],...this.writesValues.flatMap(e=>e.toFlatGenerationTarget(i)),...this.successCalls.flatMap(e=>e.toFlatGenerationTarget(i)),...this.errorCalls.flatMap(e=>e.toFlatGenerationTarget(i)),...this.inputs.flatMap(e=>e.toFlatGenerationTarget(i)),...this.outputs.flatMap(e=>e.toFlatGenerationTarget(i)),...this.internalCalls.flatMap(e=>e.toFlatGenerationTarget(i))])}clearErrors(){var i,n;return this.errors=[],this.inputs.forEach(s=>s.clearErrors()),this.outputs.forEach(s=>s.clearErrors()),this.successCalls.forEach(s=>s.clearErrors()),this.errorCalls.forEach(s=>s.clearErrors()),this.internalCalls.forEach(s=>s.clearErrors()),(i=this.dataType)==null||i.clearErrors(),(n=this.defaultValue)==null||n.clearErrors(),this}validate(){return this.errors=ULe(this),{success:!0}}async validateAsync(i={}){const n=J.YieldTracker.from(i);return this.errors=await jLe(this,{tracker:n}),{success:!0}}getErrors(){var n,s;return[...this.errors,...((n=this.defaultValue)==null?void 0:n.getErrors())||[],...((s=this.dataType)==null?void 0:s.getErrors())||[],...this.inputs.flatMap(c=>c.getErrors()),...this.internalCalls.flatMap(c=>c.getErrors()),...this.outputs.flatMap(c=>c.getErrors())]}async getErrorsAsync(i={}){const n=J.YieldTracker.from(i),s=[...this.errors];if(await n.tick(),this.defaultValue){const c=await this.defaultValue.getErrorsAsync({tracker:n});s.push(...c)}if(this.dataType){const c=await this.dataType.getErrorsAsync({tracker:n});s.push(...c)}for(const c of this.inputs){const e=await c.getErrorsAsync({tracker:n});s.push(...e)}for(const c of this.internalCalls){const e=await c.getErrorsAsync({tracker:n});s.push(...e)}for(const c of this.outputs){const e=await c.getErrorsAsync({tracker:n});s.push(...e)}return s}getShallowErrors(){return this.errors}getDefaultValue(){return this.defaultValue||null}setDefaultValue(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"set-default-value"))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setDefaultValue] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("set-default-value",this.id),this;const s=this.defaultValue;if((s==null?void 0:s.id)!==(i==null?void 0:i.id)){if(s==null||s.remove({ignoreUpstream:!0},n),this.defaultValue=i,this.defaultValue){const c=this.readsValue;this.removeValueWriter(n),c==null||c.removeValueReader(this,n)}n==null||n.add(this,H.Affected)}return n==null||n.attemptAutoclose("set-default-value",this.id),this}clone(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.CloneEntity)),n=null,s=null,c=!0){var L,k,K,S,Y;const e=Rr(n,this),y=this.toJSON(),m=s||x.UUID.uuid();y.inputs=[],y.id=m,y.version=x.UUID.uuid(),y.createdAt=(i==null?void 0:i.timestamp)||M().toISOString(),y.author=(i==null?void 0:i.author)||"1",y.previousVersion=null,y.deleted=!1,y.deletable=!0,y.editable=!0;const v=Si(y,e);n?v.setParent(n,i):v.setParent(this.parent,null),c&&v.subscribe(),v.initChildren(i),i==null||i.add(v,H.Added);const E=(L=this.dataType)==null?void 0:L.clone(i,v,x.UUID.uuid(),c);v.setDataType(E||null,i);const b=(k=this.defaultValue)==null?void 0:k.clone(i,v,x.UUID.uuid(),c);v.setDefaultValue(b||null,i);const w=(K=this.inputs)==null?void 0:K.map(re=>re.clone(i,v,x.UUID.uuid(),c));v.inputs=w;const V=(S=this.outputs)==null?void 0:S.map(re=>re.clone(i,v,x.UUID.uuid(),c));v.outputs=V;const $=(Y=this.internalCalls)==null?void 0:Y.map(re=>re.clone(i,v,x.UUID.uuid(),c));return v.internalCalls=$,i==null||i.attemptAutoclose(_.CloneEntity,this.id),v}addInternalCall(i){return this.internalCalls.find(n=>n===i)||this.internalCalls.push(i),this}createInstance(i=this.project,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"create-instance")),s={}){const c={id:s.id||x.UUID.uuid(),version:s.version||x.UUID.uuid(),createdAt:(n==null?void 0:n.timestamp)||M().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.VariableInstance,parent:i.toReference(),catchesError:s.catchesError||!1,defaultValue:s.defaultValue||null,successCalls:s.successCalls||[],errorCalls:s.errorCalls||[],inputs:s.inputs||[],outputs:s.outputs||[],writesValues:s.writesValues||[],internalCalls:s.internalCalls||[],readsValue:s.readsValue||null,calledByEntry:s.calledByEntry||[],calledBySuccess:s.calledBySuccess||[],calledByError:s.calledByError||[],error:s.error||null,declaration:this.toReference(),x:0,y:0},e=me(c,this.project);return e.hydrateAncestors(),e.setParent(i,n),n==null||n.add(e,H.Added),e.addSelfToProject(n),e.initChildren(n),i===this.project&&this.project.addVariableInstance(e),n==null||n.attemptAutoclose("create-instance",this.id),e}removeUnrecognizedInputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveUnrecognizedInputs))){var m;if(!this.checkCanEdit(this,i))return J.Logger.warn(`[removeUnrecognizedInputs] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveUnrecognizedInputs,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];if(this.dataType&&!this.dataType.isObject())[...this.inputs].forEach(v=>{const E=v.remove({ignoreUpstream:!1},i);c.push(...E.removed),n.push(...E.updated)});else if(this.dataType&&this.dataType.hasStrictObjectStructure()){const v=[...((m=this.dataType)==null?void 0:m.entity).properties];[...this.inputs].forEach(E=>{if(!E.declaration){const w=E.remove({ignoreUpstream:!1},i);c.push(...w.removed),n.push(...w.updated);return}if(!v.find(w=>E.declaration===w)){const w=E.remove({ignoreUpstream:!1},i);c.push(...w.removed),n.push(...w.updated)}if(!dA(E)){const w=E.remove({ignoreUpstream:!1},i);c.push(...w.removed),n.push(...w.updated)}})}return this.inputs.filter((v,E)=>{const b=this.inputs.findIndex(V=>V.declaration===v.declaration&&V!==v);if(b===-1)return!1;const w=this.inputs[b];return M(w==null?void 0:w.createdAt).isSame(M(v.createdAt))?E>b:!!M(w==null?void 0:w.createdAt).isAfter(v.createdAt)}).forEach(v=>{const E=v.remove({ignoreUpstream:!1},i);c.push(...E.removed),n.push(...E.updated)}),i==null||i.attemptAutoclose(_.RemoveUnrecognizedInputs,this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}removeUnrecognizedOutputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-unrecognized-variable-declaration-outputs"))){var m;if(!this.checkCanEdit(this,i))return J.Logger.warn(`[removeUnrecognizedOutputs] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveUnrecognizedOutputs,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];if(this.dataType&&!this.dataType.isObject())[...this.outputs].forEach(v=>{const E=v.remove({ignoreUpstream:!1},i);c.push(...E.removed),n.push(...E.updated)});else if(this.dataType&&this.dataType.hasStrictObjectStructure()){const v=[...((m=this.dataType)==null?void 0:m.entity).properties];[...this.outputs].forEach(E=>{if(!E.declaration){const w=E.remove({ignoreUpstream:!1},i);c.push(...w.removed),n.push(...w.updated);return}if(!v.find(w=>{var V;return((V=E.declaration)==null?void 0:V.id)===(w==null?void 0:w.id)})){const w=E.remove({ignoreUpstream:!1},i);c.push(...w.removed),n.push(...w.updated);return}if(!dA(E)){const w=E.remove({ignoreUpstream:!1},i);c.push(...w.removed),n.push(...w.updated)}})}return this.outputs.filter((v,E)=>{const b=this.outputs.findIndex(V=>V.declaration===v.declaration&&V!==v);if(b===-1)return!1;const w=this.outputs[b];return M(w==null?void 0:w.createdAt).isSame(M(v.createdAt))?E>b:!!M(w==null?void 0:w.createdAt).isAfter(v.createdAt)}).forEach(v=>{const E=v.remove({ignoreUpstream:!1},i);c.push(...E.removed),n.push(...E.updated)}),i==null||i.attemptAutoclose("remove-unrecognized-variable-declaration-outputs",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}removeUnrecognizedInternalCalls(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-unrecognized-variable-declaration-internal-calls"))){const n=[],s=[],c=[],e=[];if(!this.dataType||!this.dataType.entity||![d.DefinitionEntity,d.PrimitiveEntity,d.BuiltInBaseEntity].includes(this.dataType.entity.type))[...this.internalCalls].forEach(m=>{const v=m.remove({ignoreUpstream:!1},i);c.push(...v.removed),n.push(...v.updated)});else if(this.dataType&&this.dataType.entity&&[d.DefinitionEntity,d.PrimitiveEntity,d.BuiltInBaseEntity].includes(this.dataType.entity.type)){const m=[...this.dataType.entity.getAllInteractiveMethods()],v=[...m].filter(E=>!m.some(b=>{var w,V;return b.id!==E.id&&(((w=b.implements)==null?void 0:w.id)===E.id||((V=b.extends)==null?void 0:V.id)===E.id)})&&!E.deleted);[...this.internalCalls].forEach(E=>{if(!E.declaration){const w=E.remove({ignoreUpstream:!1},i);c.push(...w.removed),n.push(...w.updated);return}if(!v.find(w=>E.declaration===w)){const w=E.remove({ignoreUpstream:!1},i);c.push(...w.removed),n.push(...w.updated);return}})}return this.internalCalls.filter((m,v)=>{const E=this.internalCalls.findIndex(w=>w.declaration===m.declaration&&w!==m);if(E===-1)return!1;const b=this.internalCalls[E];return M(b==null?void 0:b.createdAt).isSame(M(m.createdAt))?v>E:!!M(b==null?void 0:b.createdAt).isAfter(m.createdAt)}).forEach(m=>{const v=m.remove({ignoreUpstream:!1},i);c.push(...v.removed),n.push(...v.updated)}),i==null||i.attemptAutoclose("remove-unrecognized-variable-declaration-internal-calls",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}syncInputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"sync-variable-declaration-inputs"))){const n=[],s=[],c=[],e=[];if(this.dataType)if(this.dataType.entity){if(this.dataType.isObject()){const y=[...this.dataType.entity.properties];y.filter(E=>Ry(E)?!this.inputs.find(b=>{var w;return((w=b.declaration)==null?void 0:w.id)===E.id}):!1).forEach(E=>{const b={dataType:null,id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||M().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.InputMap,parentRelationType:null,parent:this.toReference(),name:null,description:null,codeName:null,declaration:E.toJSON(),defaultValue:null,index:E.index,readsValue:null},w=me(b,this.project);return w.hydrateAncestors(),i==null||i.add(w,H.Added),w.setParent(this,i),w.initChildren(i),this.addInput(w,i),w}),this.inputs.filter(E=>!E.declaration).forEach(E=>{const b=y.find(w=>se(w,this.project)===se(E,this.project));b&&E.setDeclaration(b,i)})}}else return i==null||i.attemptAutoclose("sync-variable-declaration-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};else return i==null||i.attemptAutoclose("sync-variable-declaration-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};return i==null||i.attemptAutoclose("sync-variable-declaration-inputs",this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this}}syncOutputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SyncOutputs))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[syncOutputs] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.SyncOutputs,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];if(this.dataType)if(this.dataType.entity){if(this.dataType.isObject()){const y=[...this.dataType.entity.properties];y.filter(E=>Ry(E)?!this.outputs.find(b=>{var w;return((w=b.declaration)==null?void 0:w.id)===(E==null?void 0:E.id)}):!1).map(E=>{const b={dataType:null,id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||M().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.OutputMap,parent:this.toReference(),declaration:E==null?void 0:E.toJSON(),index:E.index,writesValues:[]},w=me(b,this.project);return w.hydrateAncestors(),i==null||i.add(w,H.Added),w.setParent(this,i),w.initChildren(i),this.addOutput(w,i),w}),this.outputs.filter(E=>!E.declaration).forEach(E=>{const b=y.find(w=>se(w,this.project)===se(E,this.project));b&&E.setDeclaration(b,i)})}}else return i==null||i.attemptAutoclose(_.SyncOutputs,this.id),{added:[],updated:[],removed:[],affected:[],self:this};else return i==null||i.attemptAutoclose(_.SyncOutputs,this.id),{added:[],updated:[],removed:[],affected:[],self:this};return i==null||i.attemptAutoclose(_.SyncOutputs,this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this}}generateUnusedInternalCalls(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"generate-unused-internal-calls"))){const n=[],s=[],c=[],e=[];if(this.dataType)if(this.dataType.entity){if([d.DefinitionEntity,d.PrimitiveEntity,d.BuiltInBaseEntity].includes(this.dataType.entity.type)){const y=[...this.dataType.entity.getAllInteractiveMethods()];[...y].filter(E=>!y.some(b=>{var w,V;return b.id!==E.id&&(((w=b.implements)==null?void 0:w.id)===E.id||((V=b.extends)==null?void 0:V.id)===E.id)})&&!E.deleted).filter(E=>!this.internalCalls.find(w=>{var $,L,k,K,S;return((($=w.declaration)==null?void 0:$.id)||((k=(L=w.initialData)==null?void 0:L.declaration)==null?void 0:k.entityId)||((S=(K=w.initialData)==null?void 0:K.declaration)==null?void 0:S.id))===E.id})).forEach(E=>{var w;const b=this.internalCalls.find(V=>{const $=Pc(V.declaration),L=Pc(E);return $.id===L.id});if(b&&((w=b.declaration)==null?void 0:w.id)!==E.id)b.setDeclaration(E);else{const V=E.createInternalCall(i,this);i==null||i.add(V,H.Added),this.addInternalCall(V)}})}}else return i==null||i.attemptAutoclose("generate-unused-internal-calls",this.id),{added:[],updated:[],removed:[],affected:[],self:this};else return i==null||i.attemptAutoclose("generate-unused-internal-calls",this.id),{added:[],updated:[],removed:[],affected:[],self:this};return i==null||i.attemptAutoclose("generate-unused-internal-calls",this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this}}setDataType(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetDataType))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setDataType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.SetDataType,this.id),this;const s=this.dataType;return(s==null?void 0:s.id)!==(i==null?void 0:i.id)&&(s==null||s.remove({ignoreUpstream:!0},n),this.dataType=i,this.subscribeToDependencies(),n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose(_.SetDataType,this.id),this}removeDataType(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveDataType))){return this.checkCanEdit(this,i)?(this.dataType&&(this.dataType.remove({ignoreUpstream:!0},i),i==null||i.add(this,H.Affected),this.dataType=null),i==null||i.attemptAutoclose(_.RemoveDataType,this.id),this):(J.Logger.warn(`[removeDataType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveDataType,this.id),this)}getDataType(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"get-data-type"))){return(!this.dataType||this.dataType.inferred)&&this.project.initialized&&this.inferDataTypeAndSyncInstancesInputsAndOutputs(i),i==null||i.attemptAutoclose("get-data-type",this.id),this.dataType||null}getUnusedInputs(){return this.inputs.filter(i=>i.suggestion||!i.readsValue&&!i.defaultValue)}getUnusedOutputs(){return this.outputs.filter(i=>i.suggestion||!i.writesValues.length)}getUsedInputs(){return this.inputs.filter(i=>!i.suggestion&&(i.readsValue||i.defaultValue))}getUsedOutputs(){return this.outputs.filter(i=>!i.suggestion&&i.writesValues.length)}};I(mi,"repository",{APICreate:async(i,...n)=>i,APIUpdate:async(i,...n)=>i,APIDelete:async(i,...n)=>i,APIClone:async(i,...n)=>{},APILoad:async(i,...n)=>null,APILoadVersion:async(i,n,...s)=>null}),I(mi,"type",d.VariableDeclaration),I(mi,"USER_MANAGED_PARENT_TYPES",[...nr,d.Project]),I(mi,"PARENT_TYPES",[...mi.USER_MANAGED_PARENT_TYPES]),I(mi,"MUTABLE_BASE_PROPERTIES",["name","codeName","description","constant","required","catchesError"]),I(mi,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),I(mi,"BASE_PROPERTIES",[...mi.MUTABLE_BASE_PROPERTIES,...mi.INMUTABLE_BASE_PROPERTIES]),I(mi,"MUTABLE_META_PROPERTIES",[...mi.MUTABLE_BASE_PROPERTIES,"x","y"]),I(mi,"INMUTABLE_META_PROPERTIES",[...mi.INMUTABLE_BASE_PROPERTIES]),I(mi,"META_PROPERTIES",[...mi.MUTABLE_META_PROPERTIES,...mi.INMUTABLE_META_PROPERTIES]),I(mi,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry","readsValue"]),I(mi,"INMUTABLE_UPSTREAM_PROPERTIES",["parent"]),I(mi,"UPSTREAM_PROPERTIES",[...mi.MUTABLE_UPSTREAM_PROPERTIES,...mi.INMUTABLE_UPSTREAM_PROPERTIES]),I(mi,"MUTABLE_DOWNSTREAM_PROPERTIES",["writesValues","inputs","outputs","successCalls","errorCalls","internalCalls"]),I(mi,"INMUTABLE_DOWNSTREAM_PROPERTIES",["dataType","defaultValue"]),I(mi,"DOWNSTREAM_PROPERTIES",[...mi.MUTABLE_DOWNSTREAM_PROPERTIES,...mi.INMUTABLE_DOWNSTREAM_PROPERTIES]),I(mi,"PROPERTIES",[...mi.META_PROPERTIES,...mi.UPSTREAM_PROPERTIES,...mi.DOWNSTREAM_PROPERTIES]);let Gu=mi;async function qLe(o,p={}){var y,m;const i=J.YieldTracker.from(p),n=ta(o),s=ia(o),c=[...n,...s],e=Mt(o.errors,c);await i.tick();for(const v of o.inputsDeclarations)await v.validateAsync({tracker:i});for(const v of o.inputs)await v.validateAsync({tracker:i});for(const v of o.outputs)await v.validateAsync({tracker:i});return await((y=o.error)==null?void 0:y.validateAsync({tracker:i})),await((m=o.dataType)==null?void 0:m.validateAsync({tracker:i})),e}function ZLe(o){var n,s;o.inputsDeclarations.forEach(c=>c.validate()),o.inputs.forEach(c=>c.validate()),o.outputs.forEach(c=>c.validate()),(n=o.error)==null||n.validate(),(s=o.dataType)==null||s.validate();const i=[...ta(o),...ia(o)];return Mt(o.errors,i)}const uAi=Object.freeze(Object.defineProperty({__proto__:null,validate:ZLe,validateAsync:qLe},Symbol.toStringTag,{value:"Module"}));var Cy={},HLe={},WLe={};Object.defineProperty(WLe,"__esModule",{value:!0});var zLe={};Object.defineProperty(zLe,"__esModule",{value:!0});var JLe={};Object.defineProperty(JLe,"__esModule",{value:!0});var YLe={};Object.defineProperty(YLe,"__esModule",{value:!0});var XLe={};Object.defineProperty(XLe,"__esModule",{value:!0});var QLe={};Object.defineProperty(QLe,"__esModule",{value:!0});var e2e={};Object.defineProperty(e2e,"__esModule",{value:!0});var t2e={};Object.defineProperty(t2e,"__esModule",{value:!0});var i2e={};Object.defineProperty(i2e,"__esModule",{value:!0});var r2e={};Object.defineProperty(r2e,"__esModule",{value:!0});var n2e={};Object.defineProperty(n2e,"__esModule",{value:!0});var a2e={};Object.defineProperty(a2e,"__esModule",{value:!0});var s2e={};Object.defineProperty(s2e,"__esModule",{value:!0});var l2e={};Object.defineProperty(l2e,"__esModule",{value:!0});var o2e={};Object.defineProperty(o2e,"__esModule",{value:!0});var d2e={};Object.defineProperty(d2e,"__esModule",{value:!0});var u2e={};Object.defineProperty(u2e,"__esModule",{value:!0});var p2e={};Object.defineProperty(p2e,"__esModule",{value:!0});var c2e={};Object.defineProperty(c2e,"__esModule",{value:!0});var f2e={};Object.defineProperty(f2e,"__esModule",{value:!0});var y2e={};Object.defineProperty(y2e,"__esModule",{value:!0});var h2e={};Object.defineProperty(h2e,"__esModule",{value:!0});var m2e={};Object.defineProperty(m2e,"__esModule",{value:!0});var T2e={};Object.defineProperty(T2e,"__esModule",{value:!0});var v2e={};Object.defineProperty(v2e,"__esModule",{value:!0});var E2e={};Object.defineProperty(E2e,"__esModule",{value:!0});var b2e={};Object.defineProperty(b2e,"__esModule",{value:!0});var A2e={};Object.defineProperty(A2e,"__esModule",{value:!0});var g2e={};Object.defineProperty(g2e,"__esModule",{value:!0});var I2e={};Object.defineProperty(I2e,"__esModule",{value:!0});var R2e={};Object.defineProperty(R2e,"__esModule",{value:!0});var D2e={};Object.defineProperty(D2e,"__esModule",{value:!0});var w2e={};Object.defineProperty(w2e,"__esModule",{value:!0});var O2e={};Object.defineProperty(O2e,"__esModule",{value:!0});var C2e={};Object.defineProperty(C2e,"__esModule",{value:!0});var _2e={};Object.defineProperty(_2e,"__esModule",{value:!0});var V2e={};Object.defineProperty(V2e,"__esModule",{value:!0});var P2e={};Object.defineProperty(P2e,"__esModule",{value:!0});var N2e={};Object.defineProperty(N2e,"__esModule",{value:!0});var x2e={};Object.defineProperty(x2e,"__esModule",{value:!0});var $2e={};Object.defineProperty($2e,"__esModule",{value:!0});var L2e={};Object.defineProperty(L2e,"__esModule",{value:!0});var M2e={};Object.defineProperty(M2e,"__esModule",{value:!0});(function(o){var p=Nr&&Nr.__createBinding||(Object.create?function(n,s,c,e){e===void 0&&(e=c);var y=Object.getOwnPropertyDescriptor(s,c);(!y||("get"in y?!s.__esModule:y.writable||y.configurable))&&(y={enumerable:!0,get:function(){return s[c]}}),Object.defineProperty(n,e,y)}:function(n,s,c,e){e===void 0&&(e=c),n[e]=s[c]}),i=Nr&&Nr.__exportStar||function(n,s){for(var c in n)c!=="default"&&!Object.prototype.hasOwnProperty.call(s,c)&&p(s,n,c)};Object.defineProperty(o,"__esModule",{value:!0}),i(WLe,o),i(zLe,o),i(JLe,o),i(YLe,o),i(XLe,o),i(QLe,o),i(e2e,o),i(t2e,o),i(i2e,o),i(r2e,o),i(n2e,o),i(a2e,o),i(s2e,o),i(l2e,o),i(o2e,o),i(d2e,o),i(u2e,o),i(p2e,o),i(c2e,o),i(f2e,o),i(y2e,o),i(h2e,o),i(m2e,o),i(T2e,o),i(v2e,o),i(E2e,o),i(b2e,o),i(A2e,o),i(g2e,o),i(I2e,o),i(R2e,o),i(D2e,o),i(w2e,o),i(O2e,o),i(C2e,o),i(_2e,o),i(V2e,o),i(P2e,o),i(N2e,o),i(x2e,o),i($2e,o),i(L2e,o),i(M2e,o)})(HLe);var B2e={},aa={};Object.defineProperty(aa,"__esModule",{value:!0});aa.isObject=aa.isString=aa.isDefined=aa.last=aa.identity=void 0;const pAi=o=>o;aa.identity=pAi;const cAi=o=>o[o.length-1];aa.last=cAi;const fAi=o=>o!==void 0;aa.isDefined=fAi;const yAi=o=>typeof o=="string";aa.isString=yAi;const hAi=o=>typeof o=="object"&&o!==null&&!(o instanceof Array);aa.isObject=hAi;(function(o){Object.defineProperty(o,"__esModule",{value:!0}),o.cstVisitor=o.VisitorAction=void 0;const p=aa;var i;(function(c){c[c.SKIP=1]="SKIP"})(i=o.VisitorAction||(o.VisitorAction={}));function n(c){const e=y=>{const m=c[y.type];if((m==null?void 0:m(y))!==i.SKIP)for(const E of Object.values(y))s(E)?e(E):E instanceof Array&&E.filter(s).forEach(b=>e(b))};return e}o.cstVisitor=n;const s=c=>(0,p.isObject)(c)&&(0,p.isString)(c.type)})(B2e);var cv={};Object.defineProperty(cv,"__esModule",{value:!0});cv.cstTransformer=void 0;function mAi(o){return p=>{const i=o[p.type];if(!i)throw p.type?new Error(`No transform map entry for ${p.type}`):new Error(`No type field on node: ${JSON.stringify(p)}`);return i(p)}}cv.cstTransformer=mAi;var G2e={},fv={};Object.defineProperty(fv,"__esModule",{value:!0});fv.bigqueryKeywords=void 0;fv.bigqueryKeywords={ALL:!0,AND:!0,ANY:!0,ARRAY:!0,AS:!0,ASC:!0,ASSERT_ROWS_MODIFIED:!0,AT:!0,BETWEEN:!0,BY:!0,CASE:!0,CAST:!0,COLLATE:!0,CONTAINS:!0,CREATE:!0,CROSS:!0,CUBE:!0,CURRENT:!0,DEFAULT:!0,DEFINE:!0,DESC:!0,DISTINCT:!0,ELSE:!0,END:!0,ENUM:!0,ESCAPE:!0,EXCEPT:!0,EXCLUDE:!0,EXISTS:!0,EXTRACT:!0,FALSE:!0,FETCH:!0,FOLLOWING:!0,FOR:!0,FROM:!0,FULL:!0,GROUP:!0,GROUPING:!0,GROUPS:!0,HASH:!0,HAVING:!0,IF:!0,IGNORE:!0,IN:!0,INNER:!0,INTERSECT:!0,INTERVAL:!0,INTO:!0,IS:!0,JOIN:!0,LATERAL:!0,LEFT:!0,LIKE:!0,LIMIT:!0,LOOKUP:!0,MERGE:!0,NATURAL:!0,NEW:!0,NO:!0,NOT:!0,NULL:!0,NULLS:!0,OF:!0,ON:!0,OR:!0,ORDER:!0,OUTER:!0,OVER:!0,PARTITION:!0,PRECEDING:!0,PROTO:!0,QUALIFY:!0,RANGE:!0,RECURSIVE:!0,RESPECT:!0,RIGHT:!0,ROLLUP:!0,ROWS:!0,SELECT:!0,SET:!0,SOME:!0,STRUCT:!0,TABLESAMPLE:!0,THEN:!0,TO:!0,TREAT:!0,TRUE:!0,UNBOUNDED:!0,UNION:!0,UNNEST:!0,USING:!0,WHEN:!0,WHERE:!0,WINDOW:!0,WITH:!0,WITHIN:!0};var yv={};Object.defineProperty(yv,"__esModule",{value:!0});yv.mariadbKeywords=void 0;yv.mariadbKeywords={ACCESSIBLE:!0,ADD:!0,ALL:!0,ALTER:!0,ANALYZE:!0,AND:!0,AS:!0,ASC:!0,ASENSITIVE:!0,BEFORE:!0,BETWEEN:!0,BIGINT:!0,BINARY:!0,BLOB:!0,BOTH:!0,BY:!0,CALL:!0,CASCADE:!0,CASE:!0,CHANGE:!0,CHAR:!0,CHARACTER:!0,CHECK:!0,COLLATE:!0,COLUMN:!0,CONDITION:!0,CONSTRAINT:!0,CONTINUE:!0,CONVERT:!0,CREATE:!0,CROSS:!0,CURRENT_DATE:!0,CURRENT_ROLE:!0,CURRENT_TIME:!0,CURRENT_TIMESTAMP:!0,CURRENT_USER:!0,CURSOR:!0,DATABASE:!0,DATABASES:!0,DAY_HOUR:!0,DAY_MICROSECOND:!0,DAY_MINUTE:!0,DAY_SECOND:!0,DEC:!0,DECIMAL:!0,DECLARE:!0,DEFAULT:!0,DELAYED:!0,DELETE:!0,DELETE_DOMAIN_ID:!0,DESC:!0,DESCRIBE:!0,DETERMINISTIC:!0,DISTINCT:!0,DISTINCTROW:!0,DIV:!0,DO_DOMAIN_IDS:!0,DOUBLE:!0,DROP:!0,DUAL:!0,EACH:!0,ELSE:!0,ELSEIF:!0,ENCLOSED:!0,ESCAPED:!0,EXCEPT:!0,EXISTS:!0,EXIT:!0,EXPLAIN:!0,FALSE:!0,FETCH:!0,FLOAT:!0,FLOAT4:!0,FLOAT8:!0,FOR:!0,FORCE:!0,FOREIGN:!0,FROM:!0,FULLTEXT:!0,GENERAL:!0,GRANT:!0,GROUP:!0,HAVING:!0,HIGH_PRIORITY:!0,HOUR_MICROSECOND:!0,HOUR_MINUTE:!0,HOUR_SECOND:!0,IF:!0,IGNORE:!0,IGNORE_DOMAIN_IDS:!0,IGNORE_SERVER_IDS:!0,IN:!0,INDEX:!0,INFILE:!0,INNER:!0,INOUT:!0,INSENSITIVE:!0,INSERT:!0,INT:!0,INT1:!0,INT2:!0,INT3:!0,INT4:!0,INT8:!0,INTEGER:!0,INTERSECT:!0,INTERVAL:!0,INTO:!0,IS:!0,ITERATE:!0,JOIN:!0,KEY:!0,KEYS:!0,KILL:!0,LEADING:!0,LEAVE:!0,LEFT:!0,LIKE:!0,LIMIT:!0,LINEAR:!0,LINES:!0,LOAD:!0,LOCALTIME:!0,LOCALTIMESTAMP:!0,LOCK:!0,LONG:!0,LONGBLOB:!0,LONGTEXT:!0,LOOP:!0,LOW_PRIORITY:!0,MASTER_HEARTBEAT_PERIOD:!0,MASTER_SSL_VERIFY_SERVER_CERT:!0,MATCH:!0,MAXVALUE:!0,MEDIUMBLOB:!0,MEDIUMINT:!0,MEDIUMTEXT:!0,MIDDLEINT:!0,MINUTE_MICROSECOND:!0,MINUTE_SECOND:!0,MOD:!0,MODIFIES:!0,NATURAL:!0,NOT:!0,NO_WRITE_TO_BINLOG:!0,NULL:!0,NUMERIC:!0,OFFSET:!0,ON:!0,OPTIMIZE:!0,OPTION:!0,OPTIONALLY:!0,OR:!0,ORDER:!0,OUT:!0,OUTER:!0,OUTFILE:!0,OVER:!0,PAGE_CHECKSUM:!0,PARSE_VCOL_EXPR:!0,PARTITION:!0,POSITION:!0,PRECISION:!0,PRIMARY:!0,PROCEDURE:!0,PURGE:!0,RANGE:!0,READ:!0,READS:!0,READ_WRITE:!0,REAL:!0,RECURSIVE:!0,REF_SYSTEM_ID:!0,REFERENCES:!0,REGEXP:!0,RELEASE:!0,RENAME:!0,REPEAT:!0,REPLACE:!0,REQUIRE:!0,RESIGNAL:!0,RESTRICT:!0,RETURN:!0,RETURNING:!0,REVOKE:!0,RIGHT:!0,RLIKE:!0,ROWS:!0,SCHEMA:!0,SCHEMAS:!0,SECOND_MICROSECOND:!0,SELECT:!0,SENSITIVE:!0,SEPARATOR:!0,SET:!0,SHOW:!0,SIGNAL:!0,SLOW:!0,SMALLINT:!0,SPATIAL:!0,SPECIFIC:!0,SQL:!0,SQLEXCEPTION:!0,SQLSTATE:!0,SQLWARNING:!0,SQL_BIG_RESULT:!0,SQL_CALC_FOUND_ROWS:!0,SQL_SMALL_RESULT:!0,SSL:!0,STARTING:!0,STATS_AUTO_RECALC:!0,STATS_PERSISTENT:!0,STATS_SAMPLE_PAGES:!0,STRAIGHT_JOIN:!0,TABLE:!0,TERMINATED:!0,THEN:!0,TINYBLOB:!0,TINYINT:!0,TINYTEXT:!0,TO:!0,TRAILING:!0,TRIGGER:!0,TRUE:!0,UNDO:!0,UNION:!0,UNIQUE:!0,UNLOCK:!0,UNSIGNED:!0,UPDATE:!0,USAGE:!0,USE:!0,USING:!0,UTC_DATE:!0,UTC_TIME:!0,UTC_TIMESTAMP:!0,VALUES:!0,VARBINARY:!0,VARCHAR:!0,VARCHARACTER:!0,VARYING:!0,WHEN:!0,WHERE:!0,WHILE:!0,WINDOW:!0,WITH:!0,WRITE:!0,XOR:!0,YEAR_MONTH:!0,ZEROFILL:!0};var hv={};Object.defineProperty(hv,"__esModule",{value:!0});hv.mysqlKeywords=void 0;hv.mysqlKeywords={ACCESSIBLE:!0,ADD:!0,ALL:!0,ALTER:!0,ANALYZE:!0,AND:!0,AS:!0,ASC:!0,ASENSITIVE:!0,BEFORE:!0,BETWEEN:!0,BIGINT:!0,BINARY:!0,BLOB:!0,BOTH:!0,BY:!0,CALL:!0,CASCADE:!0,CASE:!0,CHANGE:!0,CHAR:!0,CHARACTER:!0,CHECK:!0,COLLATE:!0,COLUMN:!0,CONDITION:!0,CONSTRAINT:!0,CONTINUE:!0,CONVERT:!0,CREATE:!0,CROSS:!0,CUBE:!0,CUME_DIST:!0,CURRENT_DATE:!0,CURRENT_TIME:!0,CURRENT_TIMESTAMP:!0,CURRENT_USER:!0,CURSOR:!0,DATABASE:!0,DATABASES:!0,DAY_HOUR:!0,DAY_MICROSECOND:!0,DAY_MINUTE:!0,DAY_SECOND:!0,DEC:!0,DECIMAL:!0,DECLARE:!0,DEFAULT:!0,DELAYED:!0,DELETE:!0,DENSE_RANK:!0,DESC:!0,DESCRIBE:!0,DETERMINISTIC:!0,DISTINCT:!0,DISTINCTROW:!0,DIV:!0,DOUBLE:!0,DROP:!0,DUAL:!0,EACH:!0,ELSE:!0,ELSEIF:!0,EMPTY:!0,ENCLOSED:!0,ESCAPED:!0,EXCEPT:!0,EXISTS:!0,EXIT:!0,EXPLAIN:!0,FALSE:!0,FETCH:!0,FIRST_VALUE:!0,FLOAT:!0,FLOAT4:!0,FLOAT8:!0,FOR:!0,FORCE:!0,FOREIGN:!0,FROM:!0,FULLTEXT:!0,FUNCTION:!0,GENERATED:!0,GET:!0,GRANT:!0,GROUP:!0,GROUPING:!0,GROUPS:!0,HAVING:!0,HIGH_PRIORITY:!0,HOUR_MICROSECOND:!0,HOUR_MINUTE:!0,HOUR_SECOND:!0,IF:!0,IGNORE:!0,IN:!0,INDEX:!0,INFILE:!0,INNER:!0,INOUT:!0,INSENSITIVE:!0,INSERT:!0,INT:!0,INT1:!0,INT2:!0,INT3:!0,INT4:!0,INT8:!0,INTEGER:!0,INTERSECT:!0,INTERVAL:!0,INTO:!0,IO_AFTER_GTIDS:!0,IO_BEFORE_GTIDS:!0,IS:!0,ITERATE:!0,JOIN:!0,JSON_TABLE:!0,KEY:!0,KEYS:!0,KILL:!0,LAG:!0,LAST_VALUE:!0,LATERAL:!0,LEAD:!0,LEADING:!0,LEAVE:!0,LEFT:!0,LIKE:!0,LIMIT:!0,LINEAR:!0,LINES:!0,LOAD:!0,LOCALTIME:!0,LOCALTIMESTAMP:!0,LOCK:!0,LONG:!0,LONGBLOB:!0,LONGTEXT:!0,LOOP:!0,LOW_PRIORITY:!0,MASTER_BIND:!0,MASTER_SSL_VERIFY_SERVER_CERT:!0,MATCH:!0,MAXVALUE:!0,MEDIUMBLOB:!0,MEDIUMINT:!0,MEDIUMTEXT:!0,MIDDLEINT:!0,MINUTE_MICROSECOND:!0,MINUTE_SECOND:!0,MOD:!0,MODIFIES:!0,NATURAL:!0,NOT:!0,NO_WRITE_TO_BINLOG:!0,NTH_VALUE:!0,NTILE:!0,NULL:!0,NUMERIC:!0,OF:!0,ON:!0,OPTIMIZE:!0,OPTIMIZER_COSTS:!0,OPTION:!0,OPTIONALLY:!0,OR:!0,ORDER:!0,OUT:!0,OUTER:!0,OUTFILE:!0,OVER:!0,PARTITION:!0,PERCENT_RANK:!0,PRECISION:!0,PRIMARY:!0,PROCEDURE:!0,PURGE:!0,RANGE:!0,RANK:!0,READ:!0,READS:!0,READ_WRITE:!0,REAL:!0,RECURSIVE:!0,REFERENCES:!0,REGEXP:!0,RELEASE:!0,RENAME:!0,REPEAT:!0,REPLACE:!0,REQUIRE:!0,RESIGNAL:!0,RESTRICT:!0,RETURN:!0,REVOKE:!0,RIGHT:!0,RLIKE:!0,ROW:!0,ROWS:!0,ROW_NUMBER:!0,SCHEMA:!0,SCHEMAS:!0,SECOND_MICROSECOND:!0,SELECT:!0,SENSITIVE:!0,SEPARATOR:!0,SET:!0,SHOW:!0,SIGNAL:!0,SMALLINT:!0,SPATIAL:!0,SPECIFIC:!0,SQL:!0,SQLEXCEPTION:!0,SQLSTATE:!0,SQLWARNING:!0,SQL_BIG_RESULT:!0,SQL_CALC_FOUND_ROWS:!0,SQL_SMALL_RESULT:!0,SSL:!0,STARTING:!0,STORED:!0,STRAIGHT_JOIN:!0,SYSTEM:!0,TABLE:!0,TERMINATED:!0,THEN:!0,TINYBLOB:!0,TINYINT:!0,TINYTEXT:!0,TO:!0,TRAILING:!0,TRIGGER:!0,TRUE:!0,UNDO:!0,UNION:!0,UNIQUE:!0,UNLOCK:!0,UNSIGNED:!0,UPDATE:!0,USAGE:!0,USE:!0,USING:!0,UTC_DATE:!0,UTC_TIME:!0,UTC_TIMESTAMP:!0,VALUES:!0,VARBINARY:!0,VARCHAR:!0,VARCHARACTER:!0,VARYING:!0,VIRTUAL:!0,WHEN:!0,WHERE:!0,WHILE:!0,WINDOW:!0,WITH:!0,WRITE:!0,XOR:!0,YEAR_MONTH:!0,ZEROFILL:!0};var mv={};Object.defineProperty(mv,"__esModule",{value:!0});mv.sqliteKeywords=void 0;mv.sqliteKeywords={ABORT:!0,ACTION:!0,ADD:!0,AFTER:!0,ALL:!0,ALTER:!0,ALWAYS:!0,ANALYZE:!0,AND:!0,AS:!0,ASC:!0,ATTACH:!0,AUTOINCREMENT:!0,BEFORE:!0,BEGIN:!0,BETWEEN:!0,BY:!0,CASCADE:!0,CASE:!0,CAST:!0,CHECK:!0,COLLATE:!0,COMMIT:!0,CONFLICT:!0,CONSTRAINT:!0,CREATE:!0,CROSS:!0,CURRENT:!0,CURRENT_DATE:!0,CURRENT_TIME:!0,CURRENT_TIMESTAMP:!0,DATABASE:!0,DEFAULT:!0,DEFERRABLE:!0,DEFERRED:!0,DELETE:!0,DESC:!0,DETACH:!0,DISTINCT:!0,DO:!0,DROP:!0,EACH:!0,ELSE:!0,END:!0,ESCAPE:!0,EXCEPT:!0,EXCLUDE:!0,EXCLUSIVE:!0,EXISTS:!0,EXPLAIN:!0,FAIL:!0,FILTER:!0,FIRST:!0,FOLLOWING:!0,FOR:!0,FOREIGN:!0,FROM:!0,FULL:!0,GENERATED:!0,GLOB:!0,GROUP:!0,GROUPS:!0,HAVING:!0,IF:!0,IGNORE:!0,IMMEDIATE:!0,IN:!0,INDEX:!0,INDEXED:!0,INITIALLY:!0,INNER:!0,INSERT:!0,INSTEAD:!0,INTERSECT:!0,INTO:!0,IS:!0,ISNULL:!0,JOIN:!0,LAST:!0,LEFT:!0,LIKE:!0,LIMIT:!0,MATCH:!0,MATERIALIZED:!0,NATURAL:!0,NO:!0,NOT:!0,NOTHING:!0,NOTNULL:!0,NULL:!0,NULLS:!0,OF:!0,OFFSET:!0,ON:!0,OR:!0,ORDER:!0,OTHERS:!0,OUTER:!0,OVER:!0,PARTITION:!0,PLAN:!0,PRAGMA:!0,PRECEDING:!0,PRIMARY:!0,QUERY:!0,RAISE:!0,RANGE:!0,RECURSIVE:!0,REFERENCES:!0,REGEXP:!0,REINDEX:!0,RELEASE:!0,RENAME:!0,REPLACE:!0,RESTRICT:!0,RETURNING:!0,RIGHT:!0,ROLLBACK:!0,ROW:!0,ROWS:!0,SAVEPOINT:!0,SELECT:!0,SET:!0,TABLE:!0,TEMP:!0,TEMPORARY:!0,THEN:!0,TIES:!0,TO:!0,TRANSACTION:!0,TRIGGER:!0,UNBOUNDED:!0,UNION:!0,UNIQUE:!0,UPDATE:!0,USING:!0,VACUUM:!0,VALUES:!0,VIEW:!0,VIRTUAL:!0,WHEN:!0,WHERE:!0,WINDOW:!0,WITH:!0,WITHOUT:!0};var Tv={};Object.defineProperty(Tv,"__esModule",{value:!0});Tv.postgresqlKeywords=void 0;Tv.postgresqlKeywords={ALL:!0,ANALYSE:!0,ANALYZE:!0,AND:!0,ANY:!0,ARRAY:!0,AS:!0,ASC:!0,ASYMMETRIC:!0,AUTHORIZATION:!0,BOTH:!0,CASE:!0,CAST:!0,CHECK:!0,COLLATE:!0,COLUMN:!0,CONSTRAINT:!0,CREATE:!0,CROSS:!0,CURRENT_CATALOG:!0,CURRENT_DATE:!0,CURRENT_ROLE:!0,CURRENT_SCHEMA:!0,CURRENT_TIME:!0,CURRENT_TIMESTAMP:!0,CURRENT_USER:!0,DAY:!0,DEFAULT:!0,DEFERRABLE:!0,DESC:!0,DISTINCT:!0,DO:!0,ELSE:!0,END:!0,EXCEPT:!0,FALSE:!0,FETCH:!0,FILTER:!0,FOR:!0,FOREIGN:!0,FREEZE:!0,FROM:!0,FULL:!0,GRANT:!0,GROUP:!0,HAVING:!0,HOUR:!0,ILIKE:!0,IN:!0,INITIALLY:!0,INNER:!0,INTERSECT:!0,INTO:!0,IS:!0,ISNULL:!0,JOIN:!0,LATERAL:!0,LEADING:!0,LEFT:!0,LIKE:!0,LIMIT:!0,LOCALTIME:!0,LOCALTIMESTAMP:!0,MINUTE:!0,MONTH:!0,NATURAL:!0,NOT:!0,NOTNULL:!0,NULL:!0,OFFSET:!0,ON:!0,ONLY:!0,OR:!0,ORDER:!0,OUTER:!0,OVER:!0,OVERLAPS:!0,PLACING:!0,PRECISION:!0,PRIMARY:!0,REFERENCES:!0,RETURNING:!0,RIGHT:!0,SECOND:!0,SELECT:!0,SESSION_USER:!0,SIMILAR:!0,SOME:!0,SYMMETRIC:!0,SYSTEM_USER:!0,TABLE:!0,TABLESAMPLE:!0,THEN:!0,TO:!0,TRAILING:!0,TRUE:!0,UNION:!0,UNIQUE:!0,USER:!0,USING:!0,VARIADIC:!0,VARYING:!0,VERBOSE:!0,WHEN:!0,WHERE:!0,WINDOW:!0,WITH:!0,WITHIN:!0,WITHOUT:!0,YEAR:!0,SET:!0};(function(o){var p=Nr&&Nr.__createBinding||(Object.create?function(n,s,c,e){e===void 0&&(e=c);var y=Object.getOwnPropertyDescriptor(s,c);(!y||("get"in y?!s.__esModule:y.writable||y.configurable))&&(y={enumerable:!0,get:function(){return s[c]}}),Object.defineProperty(n,e,y)}:function(n,s,c,e){e===void 0&&(e=c),n[e]=s[c]}),i=Nr&&Nr.__exportStar||function(n,s){for(var c in n)c!=="default"&&!Object.prototype.hasOwnProperty.call(s,c)&&p(s,n,c)};Object.defineProperty(o,"__esModule",{value:!0}),i(fv,o),i(yv,o),i(hv,o),i(mv,o),i(Tv,o)})(G2e);var Hm={};Object.defineProperty(Hm,"__esModule",{value:!0});Hm.FormattedSyntaxError=void 0;class TAi extends Error{constructor(p,i,n){super(vAi(p,i,n))}}Hm.FormattedSyntaxError=TAi;function vAi(o,p,i){const n=o.location.start.line,s=o.location.start.column,c=p.split(/\r\n|\n|\r/)[n-1],e="".padStart(String(n).length),y=bAi(EAi(o.found,s,c)),m=AAi(o.expected);return`Syntax Error: Unexpected ${y}
|
|
99
99
|
Was expecting to see: ${m}
|
|
100
100
|
--> ${i||"undefined"}:${n}:${s}
|
|
101
101
|
${e} |
|
|
@@ -161,7 +161,7 @@ The parent ${y.type} has a data-type that references an entity with `;k.length?K
|
|
|
161
161
|
The entity is ${TC($,n)}`,K+="Technically, an implemented variable-declaration or variable-instance will be generated with all ",c.push(new De({id:`${s.id}--${Ie.NoOverlapWithImplementedSignature}`,code:Ie.NoOverlapWithImplementedSignature,severity:ce.Error,message:`Entity of type '${d.InputMap}' with id '${s.id}' cannot be added to the parent entity of type '${y.type}' with id '${y.id}'. The 'declaration' with '${m.id}' of the 'input-map' does not exist in 'entity' field implemented the parent ${y.type}'s 'data-type'.${K}`}))}}else if(Qt.filter(b=>Gt.includes(b)).includes(y.type)){const w=rx(y),V=w.find(L=>L.id===s.declaration),$=`The parent entity has the following argument declarations that can be referenced by input-maps, ids: '${Ct(w.map(L=>L.id),"', '","' and '")}'`;V||c.push(new De({id:`${s.id}--${Ie.NoOverlapWithImplementedSignature}`,code:Ie.NoOverlapWithImplementedSignature,severity:ce.Error,message:`Entity of type '${d.InputMap}' with id '${s.id}' cannot be added to the parent entity of type '${y.type}' with id '${y.id}'. The parent entity does not have an 'argument-declaration' with id '${s.declaration}'.
|
|
162
162
|
You can't add an input-map to an entity that doesn't have a matching 'argument-declaration'.
|
|
163
163
|
${$}`}))}}return c.push(...e.errors,...$r(s)),{errors:c,modifiedData:s}}get codeNativeValueValidation(){var i;return this._codeNativeValueValidation||((i=this.declaration)==null?void 0:i.codeNativeValueValidation)||null}validateGeneratedUpdate(i){const n=[];let s=JSON.parse(JSON.stringify(i));const c=sf(s,this);return s=c.modifiedData,n.push(...c.errors),s.parent&&n.push(new De({id:`${this.id}--${ae.InvalidParentUpdate}`,code:ae.InvalidParentUpdate,severity:ce.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated, as it would mean moving the '${this.type}' entity to another parent entity.
|
|
164
|
-
This is likely an incorrect strategy, either the '${this.type}' entity doesn't need to be updated or it should be deleted and a new one created in the desired parent.`})),{errors:n,modifiedData:s}}subscribeDependents(i){return i.forEach(n=>{this.detachedDependents[n.entity.id]||(this.detachedDependents[n.entity.id]=n)}),this}unsubscribeDependents(i){return i.forEach(n=>{this.detachedDependents[n.entity.id]&&delete this.detachedDependents[n.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"sync-dependents"))){const n=[],s=[],c=[],e=[];return Object.values(this.detachedDependents).forEach(y=>{const m=y.entity.afterAllChildrenInitialized(i);n.push(...m.updated),s.push(...m.added),c.push(...m.removed),e.push(...m.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}onDetachedDependencyRemoved(i,n,s){const c=[],e=[],y=[],m=[];if(n==="declaration"){const{updated:v,added:E,removed:b}=this.remove({ignoreUpstream:!1},s);c.push(...v),e.push(...E),y.push(...b)}return{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:this}}onDetachedDependencyRestored(i,n,s){const c=[],e=[],y=[],m=[];if(n==="declaration"){const{updated:v,added:E,removed:b}=this.restore({},s);c.push(...v),e.push(...E),y.push(...b)}return{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:this}}unsubscribeFromDependencies(){var i,n,s,c,e;return(n=(i=this.declaration)==null?void 0:i.unsubscribeDependents)==null||n.call(i,[{entity:this,field:"declaration"}]),(e=(c=(s=this.dataType)==null?void 0:s.entity)==null?void 0:c.unsubscribeDependents)==null||e.call(c,[{entity:this,field:"data-type-entity"}]),this}subscribeToDependencies(){var i,n,s,c,e;return(n=(i=this.declaration)==null?void 0:i.subscribeDependents)==null||n.call(i,[{entity:this,field:"declaration"}]),(e=(c=(s=this.dataType)==null?void 0:s.entity)==null?void 0:c.subscribeDependents)==null||e.call(c,[{entity:this,field:"data-type-entity"}]),this}increaseVersion(i){if(i&&!M(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&M(i).isSame(M(this.createdAt))?this:(this.previousVersion=this.version,this.version=x.UUID.uuid(),this.createdAt=M(i).toISOString()||M().toISOString(),this)}captureVersion(){var n;const i=((n=this.knownVersions)==null?void 0:n.get(this.version))||new Ei(this,this.project);return i.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map([[this.version,i]]),i.declaration=this.declaration,i.defaultValue=this.defaultValue,i.readsValue=this.readsValue,i.dataType=this.dataType,i.parent=this.parent,this}recursiveCaptureUpstreamVersions(i){const n=[],s=[],c=[],e=[];if(this.parent){this.parent.increaseVersion(i);const y=this.parent.recursiveCaptureUpstreamVersions(i);n.push(this.parent,...y.updated),s.push(...y.added),c.push(...y.removed)}return{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}async restoreVersion(i){var m;const n=[],s=[],c=[],e=[];if(this.version===i)return{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this};if(!this.knownVersions){const v=new Map;for(const[E,b]of this.knownVersions||new Map){if(v.set(E,b),b.activeVersion=!1,b.knownVersions)for(const[w,V]of b.knownVersions)v.set(w,V);b.knownVersions=null}}let y=(m=this.knownVersions)==null?void 0:m.get(i);if(!y){const v=await this.APILoadVersion({},i);if(!v)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);y=new Ei(v,this.project)}return this.metaSync(y.toShallowJSON(),null),this.previousVersion=y.previousVersion,this.version=y.version,this.createdAt=y.createdAt,this.author=y.author,this.deleted=y.deleted,this.declaration=y.declaration,this.defaultValue=y.defaultValue,this.readsValue=y.readsValue,this.dataType=y.dataType,this.parent=y.parent,{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}updateWithShallowTransfer(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.UpdateWithShallowTransfer))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[updateWithShallowTransfer] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),this;if(this.metaSync(i,n),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 s=ne(i.parent),c=this.project.get(s),e=this.parent;if(e&&e.id!==(c==null?void 0:c.id)&&this.removeFromParent(n),c)this.setParent(c,n),this.addSelfToProject(n);else throw n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${s}' that isn't found in the project`)}else throw n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(i.readsValue){const s=ne(i.readsValue),c=this.project.get(s),e=this.readsValue;e&&e.id!==(c==null?void 0:c.id)&&this.removeValueWriter(n),c&&this.setValueWriter(c,n)}else this.removeValueWriter(n);if(i.declaration){const s=ne(this.initialData.declaration),c=this.project.get(s);c&&this.setDeclaration(c,n)}else this.setDeclaration(null,n);if(i.dataType){const s=ne(this.initialData.dataType),c=this.project.get(s);c&&this.setDataType(c,n)}else this.setDataType(null,n);if(i.defaultValue){const s=ne(i.defaultValue),c=this.project.get(s);c&&this.setDefaultValue(c,n)}else this.setDefaultValue(null,n);return this.captureVersion(),this.subscribeToDependencies(),n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),this}hydrateAncestors(){const i=[],n=[],s=[],c=[];if(this.initialData.parent){const e=ne(this.initialData.parent),y=this.project.get(e);if(y)this.setParent(y,null),i.push(y);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.readsValue){const e=ne(this.initialData.readsValue),y=this.project.get(e);y&&(this.setValueWriter(y,null),i.push(y))}if(this.initialData.declaration){const e=ne(this.initialData.declaration),y=this.project.get(e);y&&(this.setDeclaration(y,null),i.push(y))}return{updated:D(i),added:D(n),removed:D(s),affected:D(c),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AfterAllChildrenInitialized))){var b,w;if(!this.checkCanEdit(this,i))return J.Logger.warn(`[afterAllChildrenInitialized] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.AfterAllChildrenInitialized,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];this.initialized=!0;let y=this.index||0;const m=(qt.includes(this.parent.type)?this.parent.outputs:this.parent.inputs).filter(V=>!V.deleted&&V.id!==this.id);m.length&&(y>m.length+1?y=m.length:y<0&&(y=0)),m.find(V=>(V.index||0)===y&&!V.deleted)&&m.filter(V=>(V.index||0)>=y&&!V.deleted).forEach(V=>{V.metaSync({index:(V.index||0)+1},i),i==null||i.add(V,H.Updated),n.push(V)});const E=this.parent.type===d.VariableInstance&&((b=this.declaration)==null?void 0:b.type)===d.Property&&((w=this.declaration)==null?void 0:w.constant);return E&&this.readsValue&&(this.readsValue.removeValueReader(this,i),this.removeValueWriter(i)),E&&this.defaultValue&&this.defaultValue.remove({ignoreUpstream:!1},i),this.metaSync({index:y},i),this.captureVersion(),i==null||i.attemptAutoclose(_.AfterAllChildrenInitialized,this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}addSelfToProject(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"add-self-to-project"))){var y;const n=[this],s=[],c=[],e=[];return qt.includes(this.parent.type)?this.parentRelationType===vd.Error?this.parent.setThrows(this,i):this.parent.addOutput(this,i):this.parent.addInput(this,i),e.push(this.parent),(y=this.readsValue)==null||y.addValueReader(this,i),this.readsValue&&n.push(this.readsValue),this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}setParent(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetParent))){var s;return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.SetParent,n)?(((s=this.parent)==null?void 0:s.id)!==(i==null?void 0:i.id)&&(this.parent=i,n&&(n==null||n.add(this,H.Updated))),n==null||n.attemptAutoclose(_.SetParent,this.id),this):this}setDataType(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetDataType))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setDataType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.SetDataType,this.id),this;const s=this.dataType;return(s==null?void 0:s.id)!==(i==null?void 0:i.id)&&(s==null||s.remove({ignoreUpstream:!0},n),this.dataType=i,this.subscribeToDependencies(),n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose(_.SetDataType,this.id),this}removeDataType(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveDataType))){return this.checkCanEdit(this,i)?(this.dataType&&(this.dataType.remove({ignoreUpstream:!0},i),i==null||i.add(this,H.Affected),this.dataType=null),i==null||i.attemptAutoclose(_.RemoveDataType,this.id),this):(J.Logger.warn(`[removeDataType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveDataType,this.id),this)}setDeclaration(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"set-declaration"))){var s;return((s=this.declaration)==null?void 0:s.id)!==(i==null?void 0:i.id)&&(this.declaration=i,this.subscribeToDependencies(),n&&(n==null||n.add(this,H.Updated))),n==null||n.attemptAutoclose("set-declaration",this.id),this}initChildren(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"init-children"))){return this.initialized||this.startedInitialization?this:(this.startedInitialization=!0,this.initialData.defaultValue&&(this.defaultValue=me(this.initialData.defaultValue,this.project),this.defaultValue.setParent(this,null),this.defaultValue.initChildren(i)),this.initialData.declaration&&(this.declaration=me(this.initialData.declaration,this.project)),lf.initReadsValue(this),this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this)}setValueWriter(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetValueWriter))){var c,e,y;return this.checkCanEditFromScopeOwnerWithSideEffects(this,_.SetValueWriter,n)?this.parent.type===d.VariableInstance&&((c=this.declaration)==null?void 0:c.type)===d.Property&&((e=this.declaration)==null?void 0:e.constant)&&i?(n==null||n.event({id:`${_.SetValueWriter}-${this.id}--${i.id}`,action:_.SetValueWriter,owner:this,counterpart:i,errorReason:Ii.ValueReadingOverridesConstantVariable,rootAction:((y=n==null?void 0:n.self)==null?void 0:y.id)===this.id&&(n==null?void 0:n.autoCloseActionName)===_.SetValueWriter}),n==null||n.attemptAutoclose(_.SetValueWriter,this.id),this):(this.readsValue!==i&&(this.readsValue=i,n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose(_.SetValueWriter,this.id),this):this}removeValueWriter(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveValueWriter))){return this.readsValue&&!this.checkCanEditWithCounterpartAndSideEffects(this,this.readsValue,_.RemoveValueWriter,i)?this:(this.readsValue&&(this.readsValue=null,i==null||i.add(this,H.Updated)),i==null||i.attemptAutoclose(_.RemoveValueWriter,this.id),this)}subscribe(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"meta-sync"))){const s=Mr(this,i,n),c=Lr(this,s),e=this.toMeta();return this.index=s.index||(s.index!==0?e.index:0),this.name=s.name!==void 0?s.name:e.name,this.codeName=s.codeName!==void 0?s.codeName:e.codeName,this.description=s.description!==void 0?s.description:e.description,this.parentRelationType=s.parentRelationType!==void 0?s.parentRelationType:this.parentRelationType,super.baseMetaSync(s,this,n),s.deleted===!0&&!e.deleted?n==null||n.add(this,H.Removed):s.deleted===!1&&e.deleted?n==null||n.add(this,H.Added):c&&(n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=ke,...n){return await Ei.repository.APILoad(this.id,...n),this}async APICreate(i=ke,...n){return await Ei.repository.APICreate(this.toShallowJSON(),...n),this}async APIUpdate(i=ke,...n){return await Ei.repository.APIUpdate(this.toShallowJSON(),...n),this}async APIDelete(i=ke,...n){return await Ei.repository.APIDelete(this.toShallowJSON(),...n),this}async APIClone(i=ke,...n){return await Ei.repository.APIClone(this.id,...n),this}async APILoadVersion(i=ke,n,...s){return await Ei.repository.APILoadVersion(this.id,n,...s)}removeFromParent(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveFromParent))){var y;if(!this.checkCanEdit(this,i))return J.Logger.warn(`[removeFromParent] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveFromParent,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];return qt.includes((y=this.parent)==null?void 0:y.type)?(this.parent.removeOutput(this,i),e.push(this.parent)):(this.parent.removeInput(this,i),e.push(this.parent)),i==null||i.attemptAutoclose(_.RemoveFromParent,this.id),{added:D(c),updated:D(n),removed:D(s),affected:D(e),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveEntity))){var m,v,E,b,w;if(this.deleted)return n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(!this.checkCanDelete(this,n))return J.Logger.warn(`[remove] User is not allowed to delete or edit this ${this.type} entity with id: ${this.id}`),n==null||n.event({id:`${_.RemoveEntity}-${this.id}`,action:_.RemoveEntity,owner:this,errorReason:Ii.ActionOwnerEntityNonDeletable,rootAction:((m=n==null?void 0:n.self)==null?void 0:m.id)===this.id&&(n==null?void 0:n.autoCloseActionName)===_.RemoveEntity}),n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const s=[],c=[],e=[],y=[];if(n!=null&&n.hasRemoved(this.id))return n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(c.push(this),this.unsubscribe(),this.unsubscribeFromDependencies(),this.metaSync({deleted:!0},n),n!=null&&n.hasAdded(this.id)||this.project.subscribeDeletedInstance(this),Object.values(this.detachedDependents).forEach(V=>{const{updated:$,removed:L,added:k}=V.entity.onDetachedDependencyRemoved(this,V.field,n);s.push(...$),c.push(...L),e.push(...k)}),this.defaultValue){const{updated:V,removed:$}=this.defaultValue.remove({ignoreUpstream:!0},n);s.push(...V),c.push(...$)}if(this.readsValue&&(s.push(this.readsValue),this.readsValue.removeValueReader(this,n)),this.defaultValue&&(s.push(this.defaultValue),this.defaultValue.remove({ignoreUpstream:!0},n)),this.declaration){if(this.declaration.type===d.Property&&((v=this.declaration.parent)==null?void 0:v.type)===d.DefinitionEntity&&((b=(E=this.declaration.parent)==null?void 0:E.parent)==null?void 0:b.type)===d.DataType&&!(n!=null&&n.hasRemoved(this.declaration.id))&&!this.declaration.deleted){const{updated:V,removed:$}=this.declaration.remove({ignoreUpstream:!1},n);s.push(...V),c.push(...$)}else if(this.declaration.type===d.ValueDescriptor&&((w=this.declaration.parent)==null?void 0:w.type)===d.Search&&!(n!=null&&n.hasRemoved(this.declaration.id))&&!this.declaration.deleted){const{updated:V,removed:$}=this.declaration.remove({ignoreUpstream:!1},n);s.push(...V),c.push(...$)}}if(!i){const V=this.removeFromParent(n);e.push(...V.added),s.push(...V.updated),c.push(...V.removed),y.push(...V.affected)}if(!i&&this.parent&&[d.BreakStatement,d.ContinueStatement].includes(this.parent.type)&&this.parent.parent&&this.parent.parent.type===d.Loop&&this.parent.initialized&&this.parent.parent.syncFromDataType(n),this.parentRelationType===vd.Error&&this.parent.type===d.ReturnStatement){const{updated:V,added:$,removed:L,affected:k}=this.parent.syncInputs(n);s.push(...V),e.push(...$),c.push(...L),y.push(...k)}return n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:D(e),updated:D(s),removed:D(c),affected:D(y),self:this}}restore({}={},i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RestoreEntity))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[restore] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];if(i!=null&&i.hasAdded(this.id))return i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},i),Object.values(this.detachedDependents).forEach(y=>{const{updated:m,removed:v,added:E}=y.entity.onDetachedDependencyRestored(this,y.field,i);s.push(...m),c.push(...v),n.push(...E)}),this.defaultValue){const{updated:y}=this.defaultValue.restore({},i);s.push(...y)}return this.readsValue&&(s.push(this.readsValue),this.readsValue.addValueReader(this,i)),this.defaultValue&&(s.push(this.defaultValue),this.defaultValue.restore({},i)),e.push(this.parent),this.parent.addInput(this,i),i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this}}toFlat(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this,...this.defaultValue?this.defaultValue.toFlat(i):[],...this.dataType?this.dataType.toFlat(i):[],...this.declaration?this.declaration.toFlat(i):[],...this.readsValue?this.readsValue.toFlat(i):[]])}toFlatIds(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.defaultValue?this.defaultValue.toFlatIds(i):[],...this.dataType?this.dataType.toFlatIds(i):[],...this.declaration?this.declaration.toFlatIds(i):[],...this.readsValue?this.readsValue.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,parentRelationType:this.parentRelationType,index:this.index,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name}}toJSON(i=new Set){var n,s,c,e;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,index:this.index,name:this.name,codeName:this.codeName,description:this.description,parentRelationType:this.parentRelationType,defaultValue:((n=this.defaultValue)==null?void 0:n.toJSON(i))||null,dataType:((s=this.dataType)==null?void 0:s.toJSON(i))||null,declaration:((c=this.declaration)==null?void 0:c.toJSON(i))||null,readsValue:((e=this.readsValue)==null?void 0:e.toReference())||null,parent:this.parent.toReference()})}toJSONClone(i=ct){var s,c,e,y,m,v,E,b,w,V,$,L;let n;return(s=i.seenEntityMaps)!=null&&s.has(this.id)?n=i.seenEntityMaps.get(this.id):(n=i.newId||jr(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,n)),(c=i.seenEntities)!=null&&c.has(n)||(e=i.seenEntities)!=null&&e.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((y=i.seenEntities)==null||y.add(n),(m=i.seenEntities)==null||m.add(this.id),{id:n,version:x.UUID.uuid(),createdAt:i.timestamp||M().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,index:this.index,name:this.name,codeName:this.codeName,description:this.description,parentRelationType:this.parentRelationType,defaultValue:((v=this.defaultValue)==null?void 0:v.toJSONClone({...i,newId:null}))||null,dataType:((E=this.dataType)==null?void 0:E.toJSONClone({...i,newId:null}))||null,declaration:(b=this.declaration)!=null&&b.id&&this.project.getBuiltIn((w=this.declaration)==null?void 0:w.id)?(V=this.declaration)==null?void 0:V.toJSON(i.seenEntities):(($=this.declaration)==null?void 0:$.toJSONClone({...i,newId:null}))||null,readsValue:((L=this.readsValue)==null?void 0:L.toReference({seenEntityMaps:i.seenEntityMaps}))||null,parent:this.parent.toReference({seenEntityMaps:i.seenEntityMaps})})}toReference(i=ct){var s;let n=this.id;return(s=i.seenEntityMaps)!=null&&s.has(this.id)&&(n=i.seenEntityMaps.get(this.id)),{id:n+"--"+x.UUID.uuid()+"--ref",type:d.GenericReference,entityId:n,version:this.version,entityType:this.type}}toShallowJSON(i=ct){var s,c,e,y,m;let n=this.id;return(s=i.seenEntityMaps)!=null&&s.has(this.id)&&(n=i.seenEntityMaps.get(this.id)),{id:n,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,parentRelationType:this.parentRelationType,index:this.index,dataType:((c=this.dataType)==null?void 0:c.toReference(i))||null,defaultValue:((e=this.defaultValue)==null?void 0:e.toReference(i))||null,declaration:((y=this.declaration)==null?void 0:y.toReference(i))||null,readsValue:((m=this.readsValue)==null?void 0:m.toReference(i))||null,parent:this.parent.toReference(i)}}toFlatJSON(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...this.defaultValue?this.defaultValue.toFlatJSON(i):[],...this.dataType?this.dataType.toFlatJSON(i):[],...this.declaration?this.declaration.toFlatJSON(i):[],...this.readsValue?this.readsValue.toFlatJSON(i):[]])}toGenerationTarget(){var i;return{id:this.id,name:this.name||void 0,description:this.description||void 0,type:this.type,declaration:((i=this.declaration)==null?void 0:i.id)||null,parent:this.parent.id}}toFlatGenerationTarget(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...this.defaultValue?this.defaultValue.toFlatGenerationTarget(i):[],...this.dataType?this.dataType.toFlatGenerationTarget(i):[],...this.readsValue?this.readsValue.toFlatGenerationTarget(i):[],...this.declaration?this.declaration.toFlatGenerationTarget(i):[]])}clearErrors(){var i;return this.errors=[],(i=this.defaultValue)==null||i.clearErrors(),this}validate(){return this.errors=bMe(this),{success:!0}}async validateAsync(i={}){const n=J.YieldTracker.from(i);return this.errors=await EMe(this,{tracker:n}),{success:!0}}getErrors(){var n;return[...this.errors,...((n=this.defaultValue)==null?void 0:n.getErrors())||[]]}async getErrorsAsync(i={}){var e;const n=J.YieldTracker.from(i),s=[...this.errors];await n.tick();const c=await((e=this.defaultValue)==null?void 0:e.getErrorsAsync({tracker:n}));return c&&s.push(...c),s}getShallowErrors(){return this.errors}getDefaultValue(){var i;return this.defaultValue||((i=this.declaration)==null?void 0:i.getDefaultValue())||null}setDefaultValue(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"set-default-value"))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setDefaultValue] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("set-default-value",this.id),this;const s=this.defaultValue;return(s==null?void 0:s.id)!==(i==null?void 0:i.id)&&(s==null||s.remove({ignoreUpstream:!0},n),this.defaultValue=i,n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose("set-default-value",this.id),this}clone(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.CloneEntity)),n=null,s=null,c=!0){var b;const e=Rr(n,this),y=this.toJSON(),m=s||x.UUID.uuid();y.defaultValue=null,y.id=m,y.version=x.UUID.uuid(),y.createdAt=(i==null?void 0:i.timestamp)||M().toISOString(),y.author=(i==null?void 0:i.author)||"1",y.previousVersion=null,y.deleted=!1,y.deletable=!0,y.editable=!0;const v=Si(y,e);v.hydrateAncestors(),n&&v.setParent(n,i),c&&(v.subscribe(),v.addSelfToProject(i)),v.initChildren(i),i==null||i.add(v,H.Added);const E=(b=this.defaultValue)==null?void 0:b.clone(i,v,x.UUID.uuid(),c);return v.defaultValue=E||null,i==null||i.attemptAutoclose(_.CloneEntity,this.id),v}getDataType(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"get-data-type"))){var s;if(this.parent.type===d.Operation){const c=this.parent.declaration.inferInputMapDataType(this,i);return i==null||i.attemptAutoclose("get-data-type",this.id),c.self}else Gt.includes(this.parent.type)&&Wn(this.parent).getDataType(i);const n=(s=this.declaration)==null?void 0:s.getDataType(i);if(!n){const c=md(this,i);if(c)return i==null||i.attemptAutoclose("get-data-type",this.id),c}return i==null||i.attemptAutoclose("get-data-type",this.id),n||null}getCounterparts(){let i=[];if([d.BreakStatement,d.ContinueStatement].includes(this.parent.type)){const n=this.parent.parent;i=[...n.breakStatements,...n.continueStatements].flatMap(e=>e.outputs).filter(e=>se(e,this.project)===se(this,this.project)&&e.id!==this.id)}else if(this.parent.type===d.ReturnStatement&&[d.FunctionDeclaration,d.GlobalEvent].includes(this.parent.parent.type)&&this.parent.parent.implements){const s=this.parent.parent.returnStatements.flatMap(c=>c.outputs);this.declaration?i=s.filter(e=>{var y;return this.declaration.id===((y=e.declaration)==null?void 0:y.id)&&e.id!==this.id}):i=s.filter(e=>se(e,this.project)===se(this,this.project)&&e.id!==this.id)}return i}};I(Ei,"repository",{APICreate:async(i,...n)=>i,APIUpdate:async(i,...n)=>i,APIDelete:async(i,...n)=>i,APIClone:async(i,...n)=>{},APILoad:async(i,...n)=>null,APILoadVersion:async(i,n,...s)=>null}),I(Ei,"type",d.InputMap),I(Ei,"USER_MANAGED_PARENT_TYPES",[...Qt,...qt]),I(Ei,"PARENT_TYPES",[...Ei.USER_MANAGED_PARENT_TYPES]),I(Ei,"MUTABLE_BASE_PROPERTIES",["name","codeName","description"]),I(Ei,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion","parentRelationType"]),I(Ei,"BASE_PROPERTIES",[...Ei.MUTABLE_BASE_PROPERTIES,...Ei.INMUTABLE_BASE_PROPERTIES]),I(Ei,"MUTABLE_META_PROPERTIES",[...Ei.MUTABLE_BASE_PROPERTIES,"index"]),I(Ei,"INMUTABLE_META_PROPERTIES",[...Ei.INMUTABLE_BASE_PROPERTIES]),I(Ei,"META_PROPERTIES",[...Ei.MUTABLE_META_PROPERTIES,...Ei.INMUTABLE_META_PROPERTIES]),I(Ei,"MUTABLE_UPSTREAM_PROPERTIES",["readsValue"]),I(Ei,"INMUTABLE_UPSTREAM_PROPERTIES",["parent","declaration"]),I(Ei,"UPSTREAM_PROPERTIES",[...Ei.MUTABLE_UPSTREAM_PROPERTIES,...Ei.INMUTABLE_UPSTREAM_PROPERTIES]),I(Ei,"MUTABLE_DOWNSTREAM_PROPERTIES",["defaultValue"]),I(Ei,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),I(Ei,"DOWNSTREAM_PROPERTIES",[...Ei.MUTABLE_DOWNSTREAM_PROPERTIES,...Ei.INMUTABLE_DOWNSTREAM_PROPERTIES]),I(Ei,"PROPERTIES",[...Ei.META_PROPERTIES,...Ei.UPSTREAM_PROPERTIES,...Ei.DOWNSTREAM_PROPERTIES]);let ds=Ei;class aIi extends ds{constructor(i,n){super(i,n);I(this,"parentRelationType",null);I(this,"errors",[])}toJSON(i=new Set){return super.toJSON(i)}}class sIi extends ds{constructor(i,n){super(i,n);I(this,"parentRelationType",null);I(this,"errors",[])}toJSON(i=new Set){return super.toJSON(i)}}class lIi extends ds{constructor(i,n){super(i,n);I(this,"parentRelationType",null);I(this,"name",null);I(this,"description",null);I(this,"errors",[])}toJSON(i=new Set){return super.toJSON(i)}}async function IMe(o,p={}){const i=J.YieldTracker.from(p),n=[...Rs(o)],s=Mt(o.errors,n);return await i.tick(),s}function RMe(o){const p=[...Rs(o)];return Mt(o.errors,p)}const oIi=Object.freeze(Object.defineProperty({__proto__:null,validate:RMe,validateAsync:IMe},Symbol.toStringTag,{value:"Module"}));var DMe=(o=>(o.Declaration="declaration",o.DataTypeEntity="data-type-entity",o))(DMe||{});const bi=class bi extends Ur{constructor(i,n){super(i);I(this,"initialData");I(this,"id");I(this,"index");I(this,"type",d.OutputMap);I(this,"parentRelationType");I(this,"declaration",null);I(this,"writesValues",[]);I(this,"dataType",null);I(this,"project");I(this,"errors",[]);I(this,"parent");I(this,"detachedDependents",{});I(this,"knownVersions",null);I(this,"activeVersion",!1);I(this,"initialized",!1);I(this,"startedInitialization",!1);I(this,"suggestion",!1);I(this,"_codeNativeValueValidation",null);this.initialData=i,this.project=n,this.id=i.id,this.index=i.index,this.parentRelationType=i.parentRelationType}static new(i=null){return{id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||M().toISOString(),author:(i==null?void 0:i.author)||x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,dataType:null,type:d.OutputMap,declaration:null,writesValues:[],index:0,parent:null}}static fromGenerationTarget(i,n){const s=ne(i.parent),c=n.get(s);let e;if(i.declaration){const v=ne(i.declaration);e=n.get(v)}const y={id:i.id,version:x.UUID.uuid(),createdAt:M().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.OutputMap,dataType:null,index:(c.outputs||[]).length,declaration:e,writesValues:[],parent:c},m=me(y,n);return m.setParent(c,null),m}static validateGenerationTarget(i,n){var m;let s=JSON.parse(JSON.stringify(i));const c=[],e=bn(s,{parent:{list:!1,types:Qt.filter(v=>v!==d.Condition)},declaration:{list:!1,types:[d.ValueDescriptor,d.Property]}},n);s=e.modifiedData;const y=n.get(s.parent);if(y&&Qt.filter(v=>v!==d.Condition).includes(y.type)){const v=y.outputs.find(E=>{var b;return((b=E.declaration)==null?void 0:b.id)===(s.declaration?ne(s.declaration):null)});if(v)c.push(new De({id:`${s.id}--${ae.OutputOverwrite}`,code:ae.OutputOverwrite,severity:ce.Error,message:`Entity of type '${d.OutputMap}' with id '${s.id}' cannot be added to the parent entity of type '${y.type}' with id '${y.id}'. The parent already has an output-map with id '${v.id}' that points to the same base 'return-declaration'.
|
|
164
|
+
This is likely an incorrect strategy, either the '${this.type}' entity doesn't need to be updated or it should be deleted and a new one created in the desired parent.`})),{errors:n,modifiedData:s}}subscribeDependents(i){return i.forEach(n=>{this.detachedDependents[n.entity.id]||(this.detachedDependents[n.entity.id]=n)}),this}unsubscribeDependents(i){return i.forEach(n=>{this.detachedDependents[n.entity.id]&&delete this.detachedDependents[n.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"sync-dependents"))){const n=[],s=[],c=[],e=[];return Object.values(this.detachedDependents).forEach(y=>{const m=y.entity.afterAllChildrenInitialized(i);n.push(...m.updated),s.push(...m.added),c.push(...m.removed),e.push(...m.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}onDetachedDependencyRemoved(i,n,s){const c=[],e=[],y=[],m=[];if(n==="declaration"){const{updated:v,added:E,removed:b}=this.remove({ignoreUpstream:!1},s);c.push(...v),e.push(...E),y.push(...b)}return{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:this}}onDetachedDependencyRestored(i,n,s){const c=[],e=[],y=[],m=[];if(n==="declaration"){const{updated:v,added:E,removed:b}=this.restore({},s);c.push(...v),e.push(...E),y.push(...b)}return{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:this}}unsubscribeFromDependencies(){var i,n,s,c,e;return(n=(i=this.declaration)==null?void 0:i.unsubscribeDependents)==null||n.call(i,[{entity:this,field:"declaration"}]),(e=(c=(s=this.dataType)==null?void 0:s.entity)==null?void 0:c.unsubscribeDependents)==null||e.call(c,[{entity:this,field:"data-type-entity"}]),this}subscribeToDependencies(){var i,n,s,c,e;return(n=(i=this.declaration)==null?void 0:i.subscribeDependents)==null||n.call(i,[{entity:this,field:"declaration"}]),(e=(c=(s=this.dataType)==null?void 0:s.entity)==null?void 0:c.subscribeDependents)==null||e.call(c,[{entity:this,field:"data-type-entity"}]),this}increaseVersion(i){if(i&&!M(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&M(i).isSame(M(this.createdAt))?this:(this.previousVersion=this.version,this.version=x.UUID.uuid(),this.createdAt=M(i).toISOString()||M().toISOString(),this)}captureVersion(){var n;const i=((n=this.knownVersions)==null?void 0:n.get(this.version))||new Ei(this,this.project);return i.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map([[this.version,i]]),i.declaration=this.declaration,i.defaultValue=this.defaultValue,i.readsValue=this.readsValue,i.dataType=this.dataType,i.parent=this.parent,this}recursiveCaptureUpstreamVersions(i){const n=[],s=[],c=[],e=[];if(this.parent){this.parent.increaseVersion(i);const y=this.parent.recursiveCaptureUpstreamVersions(i);n.push(this.parent,...y.updated),s.push(...y.added),c.push(...y.removed)}return{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}async restoreVersion(i){var m;const n=[],s=[],c=[],e=[];if(this.version===i)return{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this};if(!this.knownVersions){const v=new Map;for(const[E,b]of this.knownVersions||new Map){if(v.set(E,b),b.activeVersion=!1,b.knownVersions)for(const[w,V]of b.knownVersions)v.set(w,V);b.knownVersions=null}}let y=(m=this.knownVersions)==null?void 0:m.get(i);if(!y){const v=await this.APILoadVersion({},i);if(!v)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);y=new Ei(v,this.project)}return this.metaSync(y.toShallowJSON(),null),this.previousVersion=y.previousVersion,this.version=y.version,this.createdAt=y.createdAt,this.author=y.author,this.deleted=y.deleted,this.declaration=y.declaration,this.defaultValue=y.defaultValue,this.readsValue=y.readsValue,this.dataType=y.dataType,this.parent=y.parent,{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}updateWithShallowTransfer(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.UpdateWithShallowTransfer))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[updateWithShallowTransfer] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),this;if(this.metaSync(i,n),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 s=ne(i.parent),c=this.project.get(s),e=this.parent;if(e&&e.id!==(c==null?void 0:c.id)&&this.removeFromParent(n),c)this.setParent(c,n),this.addSelfToProject(n);else throw n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${s}' that isn't found in the project`)}else throw n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(i.readsValue){const s=ne(i.readsValue),c=this.project.get(s),e=this.readsValue;e&&e.id!==(c==null?void 0:c.id)&&this.removeValueWriter(n),c&&this.setValueWriter(c,n)}else this.removeValueWriter(n);if(i.declaration){const s=ne(this.initialData.declaration),c=this.project.get(s);c&&this.setDeclaration(c,n)}else this.setDeclaration(null,n);if(i.dataType){const s=ne(this.initialData.dataType),c=this.project.get(s);c&&this.setDataType(c,n)}else this.setDataType(null,n);if(i.defaultValue){const s=ne(i.defaultValue),c=this.project.get(s);c&&this.setDefaultValue(c,n)}else this.setDefaultValue(null,n);return this.captureVersion(),this.subscribeToDependencies(),n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),this}hydrateAncestors(){const i=[],n=[],s=[],c=[];if(this.initialData.parent){const e=ne(this.initialData.parent),y=this.project.get(e);if(y)this.setParent(y,null),i.push(y);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.readsValue){const e=ne(this.initialData.readsValue),y=this.project.get(e);y&&(this.setValueWriter(y,null),i.push(y))}if(this.initialData.declaration){const e=ne(this.initialData.declaration),y=this.project.get(e);y&&(this.setDeclaration(y,null),i.push(y))}return{updated:D(i),added:D(n),removed:D(s),affected:D(c),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AfterAllChildrenInitialized))){var b,w;if(!this.checkCanEdit(this,i))return J.Logger.warn(`[afterAllChildrenInitialized] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.AfterAllChildrenInitialized,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];this.initialized=!0;let y=this.index||0;const m=(qt.includes(this.parent.type)?this.parent.outputs:this.parent.inputs).filter(V=>!V.deleted&&V.id!==this.id);m.length&&(y>m.length+1?y=m.length:y<0&&(y=0)),m.find(V=>(V.index||0)===y&&!V.deleted)&&m.filter(V=>(V.index||0)>=y&&!V.deleted).forEach(V=>{V.metaSync({index:(V.index||0)+1},i),i==null||i.add(V,H.Updated),n.push(V)});const E=this.parent.type===d.VariableInstance&&((b=this.declaration)==null?void 0:b.type)===d.Property&&((w=this.declaration)==null?void 0:w.constant);return E&&this.readsValue&&(this.readsValue.removeValueReader(this,i),this.removeValueWriter(i)),E&&this.defaultValue&&this.defaultValue.remove({ignoreUpstream:!1},i),this.metaSync({index:y},i),this.captureVersion(),i==null||i.attemptAutoclose(_.AfterAllChildrenInitialized,this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}addSelfToProject(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"add-self-to-project"))){var y;const n=[this],s=[],c=[],e=[];return qt.includes(this.parent.type)?this.parentRelationType===vd.Error?this.parent.setThrows(this,i):this.parent.addOutput(this,i):this.parent.addInput(this,i),e.push(this.parent),(y=this.readsValue)==null||y.addValueReader(this,i),this.readsValue&&n.push(this.readsValue),this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}setParent(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetParent))){var s;return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.SetParent,n)?(((s=this.parent)==null?void 0:s.id)!==(i==null?void 0:i.id)&&(this.parent=i,n&&(n==null||n.add(this,H.Updated))),n==null||n.attemptAutoclose(_.SetParent,this.id),this):this}setDataType(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetDataType))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setDataType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.SetDataType,this.id),this;const s=this.dataType;return(s==null?void 0:s.id)!==(i==null?void 0:i.id)&&(s==null||s.remove({ignoreUpstream:!0},n),this.dataType=i,this.subscribeToDependencies(),n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose(_.SetDataType,this.id),this}removeDataType(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveDataType))){return this.checkCanEdit(this,i)?(this.dataType&&(this.dataType.remove({ignoreUpstream:!0},i),i==null||i.add(this,H.Affected),this.dataType=null),i==null||i.attemptAutoclose(_.RemoveDataType,this.id),this):(J.Logger.warn(`[removeDataType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveDataType,this.id),this)}setDeclaration(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"set-declaration"))){var s;return((s=this.declaration)==null?void 0:s.id)!==(i==null?void 0:i.id)&&(this.declaration=i,this.subscribeToDependencies(),n&&(n==null||n.add(this,H.Updated))),n==null||n.attemptAutoclose("set-declaration",this.id),this}initChildren(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"init-children"))){return this.initialized||this.startedInitialization?this:(this.startedInitialization=!0,this.initialData.defaultValue&&(this.defaultValue=me(this.initialData.defaultValue,this.project),this.defaultValue.setParent(this,null),this.defaultValue.initChildren(i)),this.initialData.declaration&&(this.declaration=me(this.initialData.declaration,this.project)),lf.initReadsValue(this),this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this)}setValueWriter(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetValueWriter))){var c,e,y,m;return this.checkCanEditFromScopeOwnerWithSideEffects(this,_.SetValueWriter,n)?this.parent.type===d.VariableInstance&&((c=this.declaration)==null?void 0:c.type)===d.Property&&((e=this.declaration)==null?void 0:e.constant)&&i?(n==null||n.event({id:`${_.SetValueWriter}-${this.id}--${i.id}`,action:_.SetValueWriter,owner:this,counterpart:i,errorReason:Ii.ValueReadingOverridesConstantVariable,rootAction:((y=n==null?void 0:n.self)==null?void 0:y.id)===this.id&&(n==null?void 0:n.autoCloseActionName)===_.SetValueWriter}),n==null||n.attemptAutoclose(_.SetValueWriter,this.id),this):(this.readsValue!==i&&(this.readsValue=i,this.readsValue&&((m=this.defaultValue)==null||m.remove({ignoreUpstream:!1},n)),n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose(_.SetValueWriter,this.id),this):this}removeValueWriter(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveValueWriter))){return this.readsValue&&!this.checkCanEditWithCounterpartAndSideEffects(this,this.readsValue,_.RemoveValueWriter,i)?this:(this.readsValue&&(this.readsValue=null,i==null||i.add(this,H.Updated)),i==null||i.attemptAutoclose(_.RemoveValueWriter,this.id),this)}subscribe(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"meta-sync"))){const s=Mr(this,i,n),c=Lr(this,s),e=this.toMeta();return this.index=s.index||(s.index!==0?e.index:0),this.name=s.name!==void 0?s.name:e.name,this.codeName=s.codeName!==void 0?s.codeName:e.codeName,this.description=s.description!==void 0?s.description:e.description,this.parentRelationType=s.parentRelationType!==void 0?s.parentRelationType:this.parentRelationType,super.baseMetaSync(s,this,n),s.deleted===!0&&!e.deleted?n==null||n.add(this,H.Removed):s.deleted===!1&&e.deleted?n==null||n.add(this,H.Added):c&&(n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=ke,...n){return await Ei.repository.APILoad(this.id,...n),this}async APICreate(i=ke,...n){return await Ei.repository.APICreate(this.toShallowJSON(),...n),this}async APIUpdate(i=ke,...n){return await Ei.repository.APIUpdate(this.toShallowJSON(),...n),this}async APIDelete(i=ke,...n){return await Ei.repository.APIDelete(this.toShallowJSON(),...n),this}async APIClone(i=ke,...n){return await Ei.repository.APIClone(this.id,...n),this}async APILoadVersion(i=ke,n,...s){return await Ei.repository.APILoadVersion(this.id,n,...s)}removeFromParent(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveFromParent))){var y;if(!this.checkCanEdit(this,i))return J.Logger.warn(`[removeFromParent] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveFromParent,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];return qt.includes((y=this.parent)==null?void 0:y.type)?(this.parent.removeOutput(this,i),e.push(this.parent)):(this.parent.removeInput(this,i),e.push(this.parent)),i==null||i.attemptAutoclose(_.RemoveFromParent,this.id),{added:D(c),updated:D(n),removed:D(s),affected:D(e),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveEntity))){var m,v,E,b,w;if(this.deleted)return n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(!this.checkCanDelete(this,n))return J.Logger.warn(`[remove] User is not allowed to delete or edit this ${this.type} entity with id: ${this.id}`),n==null||n.event({id:`${_.RemoveEntity}-${this.id}`,action:_.RemoveEntity,owner:this,errorReason:Ii.ActionOwnerEntityNonDeletable,rootAction:((m=n==null?void 0:n.self)==null?void 0:m.id)===this.id&&(n==null?void 0:n.autoCloseActionName)===_.RemoveEntity}),n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const s=[],c=[],e=[],y=[];if(n!=null&&n.hasRemoved(this.id))return n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(c.push(this),this.unsubscribe(),this.unsubscribeFromDependencies(),this.metaSync({deleted:!0},n),n!=null&&n.hasAdded(this.id)||this.project.subscribeDeletedInstance(this),Object.values(this.detachedDependents).forEach(V=>{const{updated:$,removed:L,added:k}=V.entity.onDetachedDependencyRemoved(this,V.field,n);s.push(...$),c.push(...L),e.push(...k)}),this.defaultValue){const{updated:V,removed:$}=this.defaultValue.remove({ignoreUpstream:!0},n);s.push(...V),c.push(...$)}if(this.readsValue&&(s.push(this.readsValue),this.readsValue.removeValueReader(this,n)),this.defaultValue&&(s.push(this.defaultValue),this.defaultValue.remove({ignoreUpstream:!0},n)),this.declaration){if(this.declaration.type===d.Property&&((v=this.declaration.parent)==null?void 0:v.type)===d.DefinitionEntity&&((b=(E=this.declaration.parent)==null?void 0:E.parent)==null?void 0:b.type)===d.DataType&&!(n!=null&&n.hasRemoved(this.declaration.id))&&!this.declaration.deleted){const{updated:V,removed:$}=this.declaration.remove({ignoreUpstream:!1},n);s.push(...V),c.push(...$)}else if(this.declaration.type===d.ValueDescriptor&&((w=this.declaration.parent)==null?void 0:w.type)===d.Search&&!(n!=null&&n.hasRemoved(this.declaration.id))&&!this.declaration.deleted){const{updated:V,removed:$}=this.declaration.remove({ignoreUpstream:!1},n);s.push(...V),c.push(...$)}}if(!i){const V=this.removeFromParent(n);e.push(...V.added),s.push(...V.updated),c.push(...V.removed),y.push(...V.affected)}if(!i&&this.parent&&[d.BreakStatement,d.ContinueStatement].includes(this.parent.type)&&this.parent.parent&&this.parent.parent.type===d.Loop&&this.parent.initialized&&this.parent.parent.syncFromDataType(n),this.parentRelationType===vd.Error&&this.parent.type===d.ReturnStatement){const{updated:V,added:$,removed:L,affected:k}=this.parent.syncInputs(n);s.push(...V),e.push(...$),c.push(...L),y.push(...k)}return n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:D(e),updated:D(s),removed:D(c),affected:D(y),self:this}}restore({}={},i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RestoreEntity))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[restore] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];if(i!=null&&i.hasAdded(this.id))return i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},i),Object.values(this.detachedDependents).forEach(y=>{const{updated:m,removed:v,added:E}=y.entity.onDetachedDependencyRestored(this,y.field,i);s.push(...m),c.push(...v),n.push(...E)}),this.defaultValue){const{updated:y}=this.defaultValue.restore({},i);s.push(...y)}return this.readsValue&&(s.push(this.readsValue),this.readsValue.addValueReader(this,i)),this.defaultValue&&(s.push(this.defaultValue),this.defaultValue.restore({},i)),e.push(this.parent),this.parent.addInput(this,i),i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this}}toFlat(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this,...this.defaultValue?this.defaultValue.toFlat(i):[],...this.dataType?this.dataType.toFlat(i):[],...this.declaration?this.declaration.toFlat(i):[],...this.readsValue?this.readsValue.toFlat(i):[]])}toFlatIds(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.defaultValue?this.defaultValue.toFlatIds(i):[],...this.dataType?this.dataType.toFlatIds(i):[],...this.declaration?this.declaration.toFlatIds(i):[],...this.readsValue?this.readsValue.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,parentRelationType:this.parentRelationType,index:this.index,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name}}toJSON(i=new Set){var n,s,c,e;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,index:this.index,name:this.name,codeName:this.codeName,description:this.description,parentRelationType:this.parentRelationType,defaultValue:((n=this.defaultValue)==null?void 0:n.toJSON(i))||null,dataType:((s=this.dataType)==null?void 0:s.toJSON(i))||null,declaration:((c=this.declaration)==null?void 0:c.toJSON(i))||null,readsValue:((e=this.readsValue)==null?void 0:e.toReference())||null,parent:this.parent.toReference()})}toJSONClone(i=ct){var s,c,e,y,m,v,E,b,w,V,$,L;let n;return(s=i.seenEntityMaps)!=null&&s.has(this.id)?n=i.seenEntityMaps.get(this.id):(n=i.newId||jr(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,n)),(c=i.seenEntities)!=null&&c.has(n)||(e=i.seenEntities)!=null&&e.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((y=i.seenEntities)==null||y.add(n),(m=i.seenEntities)==null||m.add(this.id),{id:n,version:x.UUID.uuid(),createdAt:i.timestamp||M().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,index:this.index,name:this.name,codeName:this.codeName,description:this.description,parentRelationType:this.parentRelationType,defaultValue:((v=this.defaultValue)==null?void 0:v.toJSONClone({...i,newId:null}))||null,dataType:((E=this.dataType)==null?void 0:E.toJSONClone({...i,newId:null}))||null,declaration:(b=this.declaration)!=null&&b.id&&this.project.getBuiltIn((w=this.declaration)==null?void 0:w.id)?(V=this.declaration)==null?void 0:V.toJSON(i.seenEntities):(($=this.declaration)==null?void 0:$.toJSONClone({...i,newId:null}))||null,readsValue:((L=this.readsValue)==null?void 0:L.toReference({seenEntityMaps:i.seenEntityMaps}))||null,parent:this.parent.toReference({seenEntityMaps:i.seenEntityMaps})})}toReference(i=ct){var s;let n=this.id;return(s=i.seenEntityMaps)!=null&&s.has(this.id)&&(n=i.seenEntityMaps.get(this.id)),{id:n+"--"+x.UUID.uuid()+"--ref",type:d.GenericReference,entityId:n,version:this.version,entityType:this.type}}toShallowJSON(i=ct){var s,c,e,y,m;let n=this.id;return(s=i.seenEntityMaps)!=null&&s.has(this.id)&&(n=i.seenEntityMaps.get(this.id)),{id:n,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,parentRelationType:this.parentRelationType,index:this.index,dataType:((c=this.dataType)==null?void 0:c.toReference(i))||null,defaultValue:((e=this.defaultValue)==null?void 0:e.toReference(i))||null,declaration:((y=this.declaration)==null?void 0:y.toReference(i))||null,readsValue:((m=this.readsValue)==null?void 0:m.toReference(i))||null,parent:this.parent.toReference(i)}}toFlatJSON(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...this.defaultValue?this.defaultValue.toFlatJSON(i):[],...this.dataType?this.dataType.toFlatJSON(i):[],...this.declaration?this.declaration.toFlatJSON(i):[],...this.readsValue?this.readsValue.toFlatJSON(i):[]])}toGenerationTarget(){var i;return{id:this.id,name:this.name||void 0,description:this.description||void 0,type:this.type,declaration:((i=this.declaration)==null?void 0:i.id)||null,parent:this.parent.id}}toFlatGenerationTarget(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...this.defaultValue?this.defaultValue.toFlatGenerationTarget(i):[],...this.dataType?this.dataType.toFlatGenerationTarget(i):[],...this.readsValue?this.readsValue.toFlatGenerationTarget(i):[],...this.declaration?this.declaration.toFlatGenerationTarget(i):[]])}clearErrors(){var i;return this.errors=[],(i=this.defaultValue)==null||i.clearErrors(),this}validate(){return this.errors=bMe(this),{success:!0}}async validateAsync(i={}){const n=J.YieldTracker.from(i);return this.errors=await EMe(this,{tracker:n}),{success:!0}}getErrors(){var n;return[...this.errors,...((n=this.defaultValue)==null?void 0:n.getErrors())||[]]}async getErrorsAsync(i={}){var e;const n=J.YieldTracker.from(i),s=[...this.errors];await n.tick();const c=await((e=this.defaultValue)==null?void 0:e.getErrorsAsync({tracker:n}));return c&&s.push(...c),s}getShallowErrors(){return this.errors}getDefaultValue(){var i;return this.defaultValue||((i=this.declaration)==null?void 0:i.getDefaultValue())||null}setDefaultValue(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"set-default-value"))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setDefaultValue] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("set-default-value",this.id),this;const s=this.defaultValue;if((s==null?void 0:s.id)!==(i==null?void 0:i.id)){if(s==null||s.remove({ignoreUpstream:!0},n),this.defaultValue=i,this.defaultValue){const c=this.readsValue;this.removeValueWriter(n),c==null||c.removeValueReader(this,n)}n==null||n.add(this,H.Affected)}return n==null||n.attemptAutoclose("set-default-value",this.id),this}clone(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.CloneEntity)),n=null,s=null,c=!0){var b;const e=Rr(n,this),y=this.toJSON(),m=s||x.UUID.uuid();y.defaultValue=null,y.id=m,y.version=x.UUID.uuid(),y.createdAt=(i==null?void 0:i.timestamp)||M().toISOString(),y.author=(i==null?void 0:i.author)||"1",y.previousVersion=null,y.deleted=!1,y.deletable=!0,y.editable=!0;const v=Si(y,e);v.hydrateAncestors(),n&&v.setParent(n,i),c&&(v.subscribe(),v.addSelfToProject(i)),v.initChildren(i),i==null||i.add(v,H.Added);const E=(b=this.defaultValue)==null?void 0:b.clone(i,v,x.UUID.uuid(),c);return v.defaultValue=E||null,i==null||i.attemptAutoclose(_.CloneEntity,this.id),v}getDataType(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"get-data-type"))){var s;if(this.parent.type===d.Operation){const c=this.parent.declaration.inferInputMapDataType(this,i);return i==null||i.attemptAutoclose("get-data-type",this.id),c.self}else Gt.includes(this.parent.type)&&Wn(this.parent).getDataType(i);const n=(s=this.declaration)==null?void 0:s.getDataType(i);if(!n){const c=md(this,i);if(c)return i==null||i.attemptAutoclose("get-data-type",this.id),c}return i==null||i.attemptAutoclose("get-data-type",this.id),n||null}getCounterparts(){let i=[];if([d.BreakStatement,d.ContinueStatement].includes(this.parent.type)){const n=this.parent.parent;i=[...n.breakStatements,...n.continueStatements].flatMap(e=>e.outputs).filter(e=>se(e,this.project)===se(this,this.project)&&e.id!==this.id)}else if(this.parent.type===d.ReturnStatement&&[d.FunctionDeclaration,d.GlobalEvent].includes(this.parent.parent.type)&&this.parent.parent.implements){const s=this.parent.parent.returnStatements.flatMap(c=>c.outputs);this.declaration?i=s.filter(e=>{var y;return this.declaration.id===((y=e.declaration)==null?void 0:y.id)&&e.id!==this.id}):i=s.filter(e=>se(e,this.project)===se(this,this.project)&&e.id!==this.id)}return i}};I(Ei,"repository",{APICreate:async(i,...n)=>i,APIUpdate:async(i,...n)=>i,APIDelete:async(i,...n)=>i,APIClone:async(i,...n)=>{},APILoad:async(i,...n)=>null,APILoadVersion:async(i,n,...s)=>null}),I(Ei,"type",d.InputMap),I(Ei,"USER_MANAGED_PARENT_TYPES",[...Qt,...qt]),I(Ei,"PARENT_TYPES",[...Ei.USER_MANAGED_PARENT_TYPES]),I(Ei,"MUTABLE_BASE_PROPERTIES",["name","codeName","description"]),I(Ei,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion","parentRelationType"]),I(Ei,"BASE_PROPERTIES",[...Ei.MUTABLE_BASE_PROPERTIES,...Ei.INMUTABLE_BASE_PROPERTIES]),I(Ei,"MUTABLE_META_PROPERTIES",[...Ei.MUTABLE_BASE_PROPERTIES,"index"]),I(Ei,"INMUTABLE_META_PROPERTIES",[...Ei.INMUTABLE_BASE_PROPERTIES]),I(Ei,"META_PROPERTIES",[...Ei.MUTABLE_META_PROPERTIES,...Ei.INMUTABLE_META_PROPERTIES]),I(Ei,"MUTABLE_UPSTREAM_PROPERTIES",["readsValue"]),I(Ei,"INMUTABLE_UPSTREAM_PROPERTIES",["parent","declaration"]),I(Ei,"UPSTREAM_PROPERTIES",[...Ei.MUTABLE_UPSTREAM_PROPERTIES,...Ei.INMUTABLE_UPSTREAM_PROPERTIES]),I(Ei,"MUTABLE_DOWNSTREAM_PROPERTIES",["defaultValue"]),I(Ei,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),I(Ei,"DOWNSTREAM_PROPERTIES",[...Ei.MUTABLE_DOWNSTREAM_PROPERTIES,...Ei.INMUTABLE_DOWNSTREAM_PROPERTIES]),I(Ei,"PROPERTIES",[...Ei.META_PROPERTIES,...Ei.UPSTREAM_PROPERTIES,...Ei.DOWNSTREAM_PROPERTIES]);let ds=Ei;class aIi extends ds{constructor(i,n){super(i,n);I(this,"parentRelationType",null);I(this,"errors",[])}toJSON(i=new Set){return super.toJSON(i)}}class sIi extends ds{constructor(i,n){super(i,n);I(this,"parentRelationType",null);I(this,"errors",[])}toJSON(i=new Set){return super.toJSON(i)}}class lIi extends ds{constructor(i,n){super(i,n);I(this,"parentRelationType",null);I(this,"name",null);I(this,"description",null);I(this,"errors",[])}toJSON(i=new Set){return super.toJSON(i)}}async function IMe(o,p={}){const i=J.YieldTracker.from(p),n=[...Rs(o)],s=Mt(o.errors,n);return await i.tick(),s}function RMe(o){const p=[...Rs(o)];return Mt(o.errors,p)}const oIi=Object.freeze(Object.defineProperty({__proto__:null,validate:RMe,validateAsync:IMe},Symbol.toStringTag,{value:"Module"}));var DMe=(o=>(o.Declaration="declaration",o.DataTypeEntity="data-type-entity",o))(DMe||{});const bi=class bi extends Ur{constructor(i,n){super(i);I(this,"initialData");I(this,"id");I(this,"index");I(this,"type",d.OutputMap);I(this,"parentRelationType");I(this,"declaration",null);I(this,"writesValues",[]);I(this,"dataType",null);I(this,"project");I(this,"errors",[]);I(this,"parent");I(this,"detachedDependents",{});I(this,"knownVersions",null);I(this,"activeVersion",!1);I(this,"initialized",!1);I(this,"startedInitialization",!1);I(this,"suggestion",!1);I(this,"_codeNativeValueValidation",null);this.initialData=i,this.project=n,this.id=i.id,this.index=i.index,this.parentRelationType=i.parentRelationType}static new(i=null){return{id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||M().toISOString(),author:(i==null?void 0:i.author)||x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,dataType:null,type:d.OutputMap,declaration:null,writesValues:[],index:0,parent:null}}static fromGenerationTarget(i,n){const s=ne(i.parent),c=n.get(s);let e;if(i.declaration){const v=ne(i.declaration);e=n.get(v)}const y={id:i.id,version:x.UUID.uuid(),createdAt:M().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.OutputMap,dataType:null,index:(c.outputs||[]).length,declaration:e,writesValues:[],parent:c},m=me(y,n);return m.setParent(c,null),m}static validateGenerationTarget(i,n){var m;let s=JSON.parse(JSON.stringify(i));const c=[],e=bn(s,{parent:{list:!1,types:Qt.filter(v=>v!==d.Condition)},declaration:{list:!1,types:[d.ValueDescriptor,d.Property]}},n);s=e.modifiedData;const y=n.get(s.parent);if(y&&Qt.filter(v=>v!==d.Condition).includes(y.type)){const v=y.outputs.find(E=>{var b;return((b=E.declaration)==null?void 0:b.id)===(s.declaration?ne(s.declaration):null)});if(v)c.push(new De({id:`${s.id}--${ae.OutputOverwrite}`,code:ae.OutputOverwrite,severity:ce.Error,message:`Entity of type '${d.OutputMap}' with id '${s.id}' cannot be added to the parent entity of type '${y.type}' with id '${y.id}'. The parent already has an output-map with id '${v.id}' that points to the same base 'return-declaration'.
|
|
165
165
|
Any value reads can be done with that output-map instead.
|
|
166
166
|
You can't edit output-map entities as they need to match their return declarations, so you can only choose to read their outputted value if you need it.`}));else{const E=s.declaration?n.get(s.declaration):null;if(E&&Gt.includes(y.type)){const b=Wn(y),w=b.dataType,V=(m=b.dataType)==null?void 0:m.entity;w?V?V.type===d.ActionDescriptor?c.push(new De({id:`${s.id}--${Ie.NoOverlapWithImplementedSignature}`,code:Ie.NoOverlapWithImplementedSignature,severity:ce.Error,message:`Entity of type '${d.OutputMap}' with id '${s.id}' cannot be added to the parent entity of type '${y.type}' with id '${y.id}'. The data type of the 'variable-declaration' is a 'action-descriptor' entity.
|
|
167
167
|
This means it can hold a function-call or operation as its value, to be executed programatically.
|
|
@@ -174,10 +174,10 @@ You can't edit output-map entities as they need to match their return declaratio
|
|
|
174
174
|
This is likely an incorrect strategy, either the '${this.type}' entity doesn't need to be updated or it should be deleted and a new one created in the desired parent.`})),{errors:n,modifiedData:i}}subscribeDependents(i){return i.forEach(n=>{this.detachedDependents[n.entity.id]||(this.detachedDependents[n.entity.id]=n)}),this}unsubscribeDependents(i){return i.forEach(n=>{this.detachedDependents[n.entity.id]&&delete this.detachedDependents[n.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"sync-dependents"))){const n=[],s=[],c=[],e=[];return Object.values(this.detachedDependents).forEach(y=>{const m=y.entity.afterAllChildrenInitialized(i);n.push(...m.updated),s.push(...m.added),c.push(...m.removed),e.push(...m.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}onDetachedDependencyRemoved(i,n,s){const c=[],e=[],y=[],m=[];if(n==="declaration"){const{updated:v,added:E,removed:b}=this.remove({ignoreUpstream:!1},s);c.push(...v),e.push(...E),y.push(...b)}return{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:this}}onDetachedDependencyRestored(i,n,s){const c=[],e=[],y=[],m=[];if(n==="declaration"){const{updated:v,added:E,removed:b}=this.restore({},s);c.push(...v),e.push(...E),y.push(...b)}return{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:this}}unsubscribeFromDependencies(){var i,n,s,c,e;return(n=(i=this.declaration)==null?void 0:i.unsubscribeDependents)==null||n.call(i,[{entity:this,field:"declaration"}]),(e=(c=(s=this.dataType)==null?void 0:s.entity)==null?void 0:c.unsubscribeDependents)==null||e.call(c,[{entity:this,field:"data-type-entity"}]),this}subscribeToDependencies(){var i,n,s,c,e;return(n=(i=this.declaration)==null?void 0:i.subscribeDependents)==null||n.call(i,[{entity:this,field:"declaration"}]),(e=(c=(s=this.dataType)==null?void 0:s.entity)==null?void 0:c.subscribeDependents)==null||e.call(c,[{entity:this,field:"data-type-entity"}]),this}increaseVersion(i){if(i&&!M(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&M(i).isSame(M(this.createdAt))?this:(this.previousVersion=this.version,this.version=x.UUID.uuid(),this.createdAt=M(i).toISOString()||M().toISOString(),this)}captureVersion(){var n;const i=((n=this.knownVersions)==null?void 0:n.get(this.version))||new bi(this,this.project);return i.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map([[this.version,i]]),i.declaration=this.declaration,i.writesValues=[...this.writesValues],i.dataType=this.dataType,i.parent=this.parent,this}recursiveCaptureUpstreamVersions(i){const n=[],s=[],c=[],e=[];if(this.parent){this.parent.increaseVersion(i);const y=this.parent.recursiveCaptureUpstreamVersions(i);n.push(this.parent,...y.updated),s.push(...y.added),c.push(...y.removed)}return{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}async restoreVersion(i){var m;const n=[],s=[],c=[],e=[];if(this.version===i)return{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this};if(!this.knownVersions){const v=new Map;for(const[E,b]of this.knownVersions||new Map){if(v.set(E,b),b.activeVersion=!1,b.knownVersions)for(const[w,V]of b.knownVersions)v.set(w,V);b.knownVersions=null}}let y=(m=this.knownVersions)==null?void 0:m.get(i);if(!y){const v=await this.APILoadVersion({},i);if(!v)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);y=new bi(v,this.project)}return this.metaSync(y.toShallowJSON(),null),this.previousVersion=y.previousVersion,this.version=y.version,this.createdAt=y.createdAt,this.author=y.author,this.deleted=y.deleted,this.declaration=y.declaration,this.writesValues=y.writesValues,this.dataType=y.dataType,this.parent=y.parent,{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}updateWithShallowTransfer(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.UpdateWithShallowTransfer))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[updateWithShallowTransfer] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),this;if(this.metaSync(i,n),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 s=ne(i.parent),c=this.project.get(s),e=this.parent;if(e&&e.id!==(c==null?void 0:c.id)&&this.removeFromParent(n),c)this.setParent(c,n),this.addSelfToProject(n);else throw n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${s}' that isn't found in the project`)}else throw n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(i.declaration){const s=ne(i.declaration),c=this.project.get(s);if(c)this.setDeclaration(c,n);else throw new Error(`${this.type} with id '${this.id}' has a 'declaration' reference '${s}' that isn't found in the project`)}else{if(this.parentRelationType!==cd.Error)throw n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' must have a 'declaration' if it is not an error output map`);this.declaration=null}if(i.dataType){const s=ne(this.initialData.dataType),c=this.project.get(s);c&&this.setDataType(c,n)}else this.setDataType(null,n);return i.writesValues.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addValueReader(e,n),e.setValueWriter(this,n))}),[...this.writesValues].forEach(s=>{i.writesValues.find(e=>ne(e)===s.id)||(this.removeValueReader(s,n),s.setValueWriter(null,n))}),this.captureVersion(),this.subscribeToDependencies(),n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),this}hydrateAncestors(){const i=[],n=[],s=[],c=[];if(this.initialData.parent){const e=ne(this.initialData.parent),y=this.project.get(e);if(y)this.setParent(y,null),i.push(y);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.declaration){const e=ne(this.initialData.declaration),y=this.project.get(e);if(y)this.setDeclaration(y,null),i.push(y);else throw new Error(`${this.type} with id '${this.id}' has a 'declaration' reference '${e}' that isn't found in the project`)}else this.initialData.parentRelationType,cd.Error;return{updated:D(i),added:D(n),removed:D(s),affected:D(c),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AfterAllChildrenInitialized))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[afterAllChildrenInitialized] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.AfterAllChildrenInitialized,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];this.initialized=!0;let y=this.index||0;const m=this.parent.outputs.filter(E=>!E.deleted&&E.id!==this.id);return m.length&&(y>m.length+1?y=m.length:y<0&&(y=0)),m.find(E=>(E.index||0)===y&&!E.deleted)&&m.filter(E=>(E.index||0)>=y&&!E.deleted).forEach(E=>{E.metaSync({index:(E.index||0)+1},i),i==null||i.add(E,H.Updated),n.push(E)}),this.metaSync({index:y},i),this.captureVersion(),i==null||i.attemptAutoclose(_.AfterAllChildrenInitialized,this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}addSelfToProject(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"add-self-to-project"))){const n=[this],s=[],c=[],e=[];return this.parentRelationType===cd.Error?this.parent.error=this:this.parent.addOutput(this,i),this.writesValues.forEach(y=>{y.setValueWriter(this,i),n.push(y)}),this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}addValueReader(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddValueReader))){var e,y,m;if(!this.checkCanEditFromScopeOwnerWithSideEffects(this,_.AddValueReader,n))return this;const s=i.type===d.InputMap&&i.parent.type===d.VariableInstance&&((e=i.declaration)==null?void 0:e.type)===d.Property&&((y=i.declaration)==null?void 0:y.constant),c=i.type===d.VariableInstance&&((m=i.declaration)==null?void 0:m.constant);return(s||c)&&i?(n==null||n.event({id:`${_.SetValueWriter}-${this.id}--${this.id}`,action:_.SetValueWriter,owner:i,counterpart:this,errorReason:Ii.ValueReadingOverridesConstantVariable,rootAction:!1}),n==null||n.attemptAutoclose(_.AddValueReader,this.id),this):this.writesValues.includes(i)?(n==null||n.attemptAutoclose(_.AddValueReader,this.id),this):(this.writesValues.push(i),n==null||n.add(this,H.Affected),this)}removeValueReader(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveValueReader))){return this.checkCanEditFromScopeOwnerWithSideEffects(this,_.RemoveValueReader,n)?this.writesValues.includes(i)?(this.writesValues=this.writesValues.filter(s=>s.id!==i.id),n==null||n.add(this,H.Affected),this):(n==null||n.attemptAutoclose(_.RemoveValueReader,this.id),this):this}setParent(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetParent))){var s;return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.SetParent,n)?(((s=this.parent)==null?void 0:s.id)!==(i==null?void 0:i.id)&&(this.parent=i,n&&(n==null||n.add(this,H.Updated))),n==null||n.attemptAutoclose(_.SetParent,this.id),this):this}setDataType(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetDataType))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setDataType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.SetDataType,this.id),this;const s=this.dataType;return(s==null?void 0:s.id)!==(i==null?void 0:i.id)&&(s==null||s.remove({ignoreUpstream:!0},n),this.dataType=i,this.subscribeToDependencies(),n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose(_.SetDataType,this.id),this}removeDataType(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveDataType))){return this.checkCanEdit(this,i)?(this.dataType&&(this.dataType.remove({ignoreUpstream:!0},i),i==null||i.add(this,H.Affected),this.dataType=null),i==null||i.attemptAutoclose(_.RemoveDataType,this.id),this):(J.Logger.warn(`[removeDataType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveDataType,this.id),this)}setDeclaration(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"set-declaration"))){var s;return((s=this.declaration)==null?void 0:s.id)!==(i==null?void 0:i.id)&&(this.declaration=i,this.subscribeToDependencies(),n&&(n==null||n.add(this,H.Updated))),n==null||n.attemptAutoclose("set-declaration",this.id),this}initChildren(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"init-children"))){return this.initialized||this.startedInitialization?this:(this.startedInitialization=!0,Pv.initWritesValues(this,this.parent.parent),this.initialData.declaration&&(this.declaration=me(this.initialData.declaration,this.project)),this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this)}subscribe(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"meta-sync"))){const s=Mr(this,i,n),c=Lr(this,s),e=this.toMeta();return this.index=s.index||(s.index!==0?e.index:0),this.parentRelationType=s.parentRelationType!==void 0?s.parentRelationType:this.parentRelationType,super.baseMetaSync(s,this,n),s.deleted===!0&&!e.deleted?n==null||n.add(this,H.Removed):s.deleted===!1&&e.deleted?n==null||n.add(this,H.Added):c&&(n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=ke,...n){return await bi.repository.APILoad(this.id,...n),this}async APICreate(i=ke,...n){return await bi.repository.APICreate(this.toShallowJSON(),...n),this}async APIUpdate(i=ke,...n){return await bi.repository.APIUpdate(this.toShallowJSON(),...n),this}async APIDelete(i=ke,...n){return await bi.repository.APIDelete(this.toShallowJSON(),...n),this}async APIClone(i=ke,...n){return await bi.repository.APIClone(this.id,...n),this}async APILoadVersion(i=ke,n,...s){return await bi.repository.APILoadVersion(this.id,n,...s)}removeFromParent(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveFromParent))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[removeFromParent] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveFromParent,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];return i==null||i.attemptAutoclose(_.RemoveFromParent,this.id),{added:D(c),updated:D(n),removed:D(s),affected:D(e),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveEntity))){var m;if(!this.checkCanDelete(this,n))return J.Logger.warn(`[remove] User is not allowed to delete or edit this ${this.type} entity with id: ${this.id}`),n==null||n.event({id:`${_.RemoveEntity}-${this.id}`,action:_.RemoveEntity,owner:this,errorReason:Ii.ActionOwnerEntityNonDeletable,rootAction:((m=n==null?void 0:n.self)==null?void 0:m.id)===this.id&&(n==null?void 0:n.autoCloseActionName)===_.RemoveEntity}),n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const s=[],c=[],e=[],y=[];if(n!=null&&n.hasRemoved(this.id))return n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(this.parent.id==="test-loop-122333"&&se(this,this.project)==="Current iteration number")throw new Error(`The ${this.type} with id '${this.id}' cannot be removed.`);if(c.push(this),this.unsubscribe(),this.unsubscribeFromDependencies(),this.project.subscribeDeletedInstance(this),this.metaSync({deleted:!0},n),Object.values(this.detachedDependents).forEach(v=>{const{updated:E,removed:b,added:w}=v.entity.onDetachedDependencyRemoved(this,v.field,n);s.push(...E),c.push(...b),e.push(...w)}),this.writesValues.forEach(v=>{s.push(v),v.readsValue=null}),!i){const v=this.removeFromParent(n);e.push(...v.added),s.push(...v.updated),c.push(...v.removed),y.push(...v.affected),y.push(this.parent),this.parentRelationType===cd.Error?this.parent.error=null:this.parent.removeOutput(this,n)}return n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:D(e),updated:D(s),removed:D(c),affected:D(y),self:this}}restore({}={},i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RestoreEntity))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[restore] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];return i!=null&&i.hasAdded(this.id)?(i==null||i.attemptAutoclose(_.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(y=>{const{updated:m,removed:v,added:E}=y.entity.onDetachedDependencyRestored(this,y.field,i);s.push(...m),c.push(...v),n.push(...E)}),this.writesValues.forEach(y=>{s.push(y),y.setValueWriter(this,i)}),e.push(this.parent),this.parentRelationType===cd.Error?this.parent.error=this:this.parent.addOutput(this,i),i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this})}toFlat(i=new Set){var s;return i.has(this.id)?[]:(i.add(this.id),[this,...((s=this.dataType)==null?void 0:s.toFlat(i))||[],...this.writesValues.flatMap(c=>c.toFlat(i)),...this.declaration?this.declaration.toFlat(i):[]])}toFlatIds(i=new Set){var s;return i.has(this.id)?[]:(i.add(this.id),[this.id,...((s=this.dataType)==null?void 0:s.toFlatIds(i))||[],...this.writesValues.flatMap(c=>c.toFlatIds(i)),...this.declaration?this.declaration.toFlatIds(i):[]])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,index:this.index,type:this.type,editable:this.editable,deletable:this.deletable}}toJSON(i=new Set){var n,s;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,index:this.index,parentRelationType:this.parentRelationType,dataType:((n=this.dataType)==null?void 0:n.toJSON(i))||null,writesValues:this.writesValues.map(c=>c.toJSON(i)),declaration:((s=this.declaration)==null?void 0:s.toJSON(i))||null,parent:this.parent.toReference()})}toJSONClone(i=ct){var s,c,e,y,m,v,E,b,w,V;let n;return(s=i.seenEntityMaps)!=null&&s.has(this.id)?n=i.seenEntityMaps.get(this.id):(n=i.newId||jr(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,n)),(c=i.seenEntities)!=null&&c.has(n)||(e=i.seenEntities)!=null&&e.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((y=i.seenEntities)==null||y.add(n),(m=i.seenEntities)==null||m.add(this.id),{id:n,version:x.UUID.uuid(),createdAt:i.timestamp||M().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,index:this.index,parentRelationType:this.parentRelationType,writesValues:this.writesValues.map($=>$.toJSONClone({...i,newId:null})),dataType:((v=this.dataType)==null?void 0:v.toJSONClone({...i,newId:null}))||null,declaration:(E=this.declaration)!=null&&E.id&&this.project.getBuiltIn((b=this.declaration)==null?void 0:b.id)?(w=this.declaration)==null?void 0:w.toJSON(i.seenEntities):((V=this.declaration)==null?void 0:V.toJSONClone({...i,newId:null}))||null,parent:this.parent.toReference({seenEntityMaps:i.seenEntityMaps})})}toReference(i=ct){var s;let n=this.id;return(s=i.seenEntityMaps)!=null&&s.has(this.id)&&(n=i.seenEntityMaps.get(this.id)),{id:n+"--"+x.UUID.uuid()+"--ref",type:d.GenericReference,entityId:n,version:this.version,entityType:this.type}}toShallowJSON(i=ct){var s,c,e;let n=this.id;return(s=i.seenEntityMaps)!=null&&s.has(this.id)&&(n=i.seenEntityMaps.get(this.id)),{id:n,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,index:this.index,parentRelationType:this.parentRelationType,dataType:((c=this.dataType)==null?void 0:c.toReference(i))||null,declaration:((e=this.declaration)==null?void 0:e.toReference(i))||null,writesValues:this.writesValues.map(y=>y.toReference(i)),parent:this.parent.toReference(i)}}toFlatJSON(i=new Set){var s;return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...((s=this.dataType)==null?void 0:s.toFlatJSON(i))||[],...this.writesValues.flatMap(c=>c.toFlatJSON(i)),...this.declaration?this.declaration.toFlatJSON(i):[]])}toGenerationTarget(){var i;return{id:this.id,type:this.type,declaration:((i=this.declaration)==null?void 0:i.id)||null,parentRelationType:this.parentRelationType,parent:this.parent.id}}toFlatGenerationTarget(i=new Set){var s;return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...((s=this.dataType)==null?void 0:s.toFlatGenerationTarget(i))||[],...this.writesValues.flatMap(c=>c.toFlatGenerationTarget(i)),...this.declaration?this.declaration.toFlatGenerationTarget(i):[]])}clearErrors(){return this.errors=[],this}validate(){return this.errors=RMe(this),{success:!0}}async validateAsync(i={}){const n=J.YieldTracker.from(i);return this.errors=await IMe(this,{tracker:n}),{success:!0}}getErrors(){return[...this.errors]}async getErrorsAsync(i={}){const n=J.YieldTracker.from(i),s=[...this.errors];return await n.tick(),s}getShallowErrors(){return this.errors}clone(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.CloneEntity)),n=null,s=null,c=!0){var b;const e=Rr(n,this),y=this.toJSON(),m=s||x.UUID.uuid();y.id=m,y.version=x.UUID.uuid(),y.createdAt=(i==null?void 0:i.timestamp)||M().toISOString(),y.author=(i==null?void 0:i.author)||"1",y.previousVersion=null,y.deleted=!1,y.deletable=!0,y.editable=!0;const v=Si(y,e);n?v.setParent(n,i):v.setParent(this.parent,null),c&&v.subscribe(),v.initChildren(i),i==null||i.add(v,H.Added);const E=(b=this.dataType)==null?void 0:b.clone(i,v,x.UUID.uuid(),c);return v.setDataType(E||null,i),i==null||i.attemptAutoclose(_.CloneEntity,this.id),v}getDataType(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"get-data-type"))){var s;if(this.parent.type===d.Operation){const c=this.parent.declaration.inferOutputMapDataType(this,i);return i==null||i.attemptAutoclose("get-data-type",this.id),c.self}const n=((s=this.declaration)==null?void 0:s.getDataType(i))||null;return i==null||i.attemptAutoclose("get-data-type",this.id),n}};I(bi,"repository",{APICreate:async(i,...n)=>i,APIUpdate:async(i,...n)=>i,APIDelete:async(i,...n)=>i,APIClone:async(i,...n)=>{},APILoad:async(i,...n)=>null,APILoadVersion:async(i,n,...s)=>null}),I(bi,"type",d.OutputMap),I(bi,"USER_MANAGED_PARENT_TYPES",[...Ty]),I(bi,"PARENT_TYPES",[...bi.USER_MANAGED_PARENT_TYPES]),I(bi,"MUTABLE_BASE_PROPERTIES",[]),I(bi,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion","parentRelationType"]),I(bi,"BASE_PROPERTIES",[...bi.MUTABLE_BASE_PROPERTIES,...bi.INMUTABLE_BASE_PROPERTIES]),I(bi,"MUTABLE_META_PROPERTIES",[...bi.MUTABLE_BASE_PROPERTIES,"index"]),I(bi,"INMUTABLE_META_PROPERTIES",[...bi.INMUTABLE_BASE_PROPERTIES]),I(bi,"META_PROPERTIES",[...bi.MUTABLE_META_PROPERTIES,...bi.INMUTABLE_META_PROPERTIES]),I(bi,"MUTABLE_UPSTREAM_PROPERTIES",[]),I(bi,"INMUTABLE_UPSTREAM_PROPERTIES",["parent","declaration"]),I(bi,"UPSTREAM_PROPERTIES",[...bi.MUTABLE_UPSTREAM_PROPERTIES,...bi.INMUTABLE_UPSTREAM_PROPERTIES]),I(bi,"MUTABLE_DOWNSTREAM_PROPERTIES",["writesValues"]),I(bi,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),I(bi,"DOWNSTREAM_PROPERTIES",[...bi.MUTABLE_DOWNSTREAM_PROPERTIES,...bi.INMUTABLE_DOWNSTREAM_PROPERTIES]),I(bi,"PROPERTIES",[...bi.META_PROPERTIES,...bi.UPSTREAM_PROPERTIES,...bi.DOWNSTREAM_PROPERTIES]);let Rl=bi;class dIi extends Rl{constructor(i,n){super(i,n);I(this,"errors",[])}toJSON(i=new Set){return super.toJSON(i)}}class uIi extends Rl{constructor(i,n){super(i,n);I(this,"declaration",null);I(this,"errors",[])}toJSON(i=new Set){return super.toJSON(i)}}async function wMe(o,p={}){var c;const i=J.YieldTracker.from(p),n=[];await i.tick();const s=Mt(o.errors,n);for(const e of o.outputs)await e.validateAsync({tracker:i});return await((c=o.throws)==null?void 0:c.validateAsync({tracker:i})),s}function OMe(o){var i;o.outputs.forEach(n=>n.validate()),(i=o.throws)==null||i.validate();const p=[];return Mt(o.errors,p)}const pIi=Object.freeze(Object.defineProperty({__proto__:null,validate:OMe,validateAsync:wMe},Symbol.toStringTag,{value:"Module"}));var CMe=(o=>(o.Parent="break-statement-parent-field",o.DataTypeEntity="break-statement-data-type-entity-field",o.DataType="break-statement-data-type-field",o.ParentDataType="break-statement-parent-data-type-field",o.ParentDataTypeEntity="break-statement-parent-data-type-entity-field",o))(CMe||{});const Vi=class Vi extends Ur{constructor(i,n){super(i);I(this,"initialData");I(this,"id");I(this,"x");I(this,"y");I(this,"type",d.BreakStatement);I(this,"outputs",[]);I(this,"readsValue",null);I(this,"dataType",null);I(this,"defaultValue",null);I(this,"calledBySuccess",[]);I(this,"calledByError",[]);I(this,"calledByEntry",[]);I(this,"throws",null);I(this,"project");I(this,"errors",[]);I(this,"parent");I(this,"detachedDependents",{});I(this,"knownVersions",null);I(this,"activeVersion",!1);I(this,"initialized",!1);I(this,"startedInitialization",!1);I(this,"suggestion",!1);I(this,"_codeNativeValueValidation",null);this.initialData=i,this.project=n,this.id=i.id,this.x=i.x,this.y=i.y}static new(i=null){return{id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||M().toISOString(),author:(i==null?void 0:i.author)||x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.BreakStatement,outputs:[],defaultValue:null,dataType:null,readsValue:null,calledBySuccess:[],calledByError:[],calledByEntry:[],throws:null,parent:null,x:0,y:0}}static fromGenerationTarget(i,n){const s=ne(i.parent),c=n.get(s),e=i.calledByEntry.map(w=>{const V=ne(w);return n.get(V)}),y=i.calledBySuccess.map(w=>{const V=ne(w);return n.get(V)}),m=i.calledByError.map(w=>{const V=ne(w);return n.get(V)});let v=null;if(i.readsValue){const w=ne(i.readsValue);v=n.get(w)}const E={id:i.id,version:x.UUID.uuid(),createdAt:M().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.BreakStatement,x:0,y:0,outputs:[],defaultValue:null,dataType:null,readsValue:v,calledBySuccess:y,calledByError:m,calledByEntry:e,throws:null,parent:c},b=me(E,n);return b.setParent(c,null),b}static validateGenerationTarget(i,n){let s=JSON.parse(JSON.stringify(i));const c=[],e=bn(s,{parent:{list:!1,types:[d.Loop]}},n);return s=e.modifiedData,c.push(...e.errors,...$r(s)),{errors:c,modifiedData:s}}get codeNativeValueValidation(){return this._codeNativeValueValidation||null}validateGeneratedUpdate(i){const n=[];let s=JSON.parse(JSON.stringify(i));const c=sf(s,this);return s=c.modifiedData,n.push(...c.errors),i.parent&&n.push(new De({id:`${this.id}--${ae.InvalidParentUpdate}`,code:ae.InvalidParentUpdate,severity:ce.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated. The 'parent' on a callable entity, is its scope. It scope is auto-calculated implicitly by the its caller.
|
|
175
175
|
If an entity is called by another, they must be in the same scope, which means they have the same parent.
|
|
176
176
|
You shouldn't have to manually update a 'parent' property.
|
|
177
|
-
Specifically for break statements the parent needs to always be the 'loop' entity that contains it.`})),{errors:n,modifiedData:i}}subscribeDependents(i){return i.forEach(n=>{this.detachedDependents[n.entity.id]||(this.detachedDependents[n.entity.id]=n)}),this}unsubscribeDependents(i){return i.forEach(n=>{this.detachedDependents[n.entity.id]&&delete this.detachedDependents[n.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"sync-dependents"))){const n=[],s=[],c=[],e=[];return Object.values(this.detachedDependents).forEach(y=>{const m=y.entity.afterAllChildrenInitialized(i);n.push(...m.updated),s.push(...m.added),c.push(...m.removed),e.push(...m.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}onDetachedDependencyRemoved(i,n,s){const c=[],e=[],y=[],m=[];if(n==="break-statement-parent-field"){const{updated:v,added:E,removed:b}=this.remove({ignoreUpstream:!1},s);c.push(...v),e.push(...E),y.push(...b)}if(n==="break-statement-parent-data-type-field"){const{updated:v,added:E,removed:b}=this.afterAllChildrenInitialized(s);c.push(...v),e.push(...E),y.push(...b)}if(n==="break-statement-parent-data-type-entity-field"){const{updated:v,added:E,removed:b}=this.afterAllChildrenInitialized(s);c.push(...v),e.push(...E),y.push(...b)}return{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:this}}onDetachedDependencyRestored(i,n,s){const c=[],e=[],y=[],m=[];if(n==="break-statement-parent-field"){const{updated:v,added:E,removed:b}=this.restore({},s);c.push(...v),e.push(...E),y.push(...b)}if(n==="break-statement-parent-data-type-field"){const{updated:v,added:E,removed:b}=this.afterAllChildrenInitialized(s);c.push(...v),e.push(...E),y.push(...b)}if(n==="break-statement-parent-data-type-entity-field"){const{updated:v,added:E,removed:b}=this.afterAllChildrenInitialized(s);c.push(...v),e.push(...E),y.push(...b)}return{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:this}}unsubscribeFromDependencies(){var i,n,s,c,e,y,m,v,E,b,w,V;return this.parent.unsubscribeDependents([{entity:this,field:"break-statement-parent-field"}]),(s=(n=(i=this.dataType)==null?void 0:i.entity)==null?void 0:n.unsubscribeDependents)==null||s.call(n,[{entity:this,field:"break-statement-data-type-entity-field"}]),(e=(c=this.dataType)==null?void 0:c.unsubscribeDependents)==null||e.call(c,[{entity:this,field:"break-statement-data-type-field"}]),(E=(v=(m=(y=this.parent)==null?void 0:y.dataType)==null?void 0:m.entity)==null?void 0:v.unsubscribeDependents)==null||E.call(v,[{entity:this,field:"break-statement-parent-data-type-entity-field"}]),(V=(w=(b=this.parent)==null?void 0:b.dataType)==null?void 0:w.unsubscribeDependents)==null||V.call(w,[{entity:this,field:"break-statement-parent-data-type-field"}]),this}subscribeToDependencies(){var i,n,s,c,e,y,m,v,E,b,w,V,$;return(i=this.parent)==null||i.subscribeDependents([{entity:this,field:"break-statement-parent-field"}]),(c=(s=(n=this.dataType)==null?void 0:n.entity)==null?void 0:s.subscribeDependents)==null||c.call(s,[{entity:this,field:"break-statement-data-type-entity-field"}]),(y=(e=this.dataType)==null?void 0:e.subscribeDependents)==null||y.call(e,[{entity:this,field:"break-statement-data-type-field"}]),(b=(E=(v=(m=this.parent)==null?void 0:m.dataType)==null?void 0:v.entity)==null?void 0:E.subscribeDependents)==null||b.call(E,[{entity:this,field:"break-statement-parent-data-type-entity-field"}]),($=(V=(w=this.parent)==null?void 0:w.dataType)==null?void 0:V.subscribeDependents)==null||$.call(V,[{entity:this,field:"break-statement-parent-data-type-field"}]),this}increaseVersion(i){if(i&&!M(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&M(i).isSame(M(this.createdAt))?this:(this.previousVersion=this.version,this.version=x.UUID.uuid(),this.createdAt=M(i).toISOString()||M().toISOString(),this)}captureVersion(){var n;const i=((n=this.knownVersions)==null?void 0:n.get(this.version))||new Vi(this,this.project);return i.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map([[this.version,i]]),i.outputs=[...this.outputs],i.readsValue=this.readsValue,i.defaultValue=this.defaultValue,i.dataType=this.dataType,i.throws=this.throws,i.calledBySuccess=[...this.calledBySuccess],i.calledByError=[...this.calledByError],i.calledByEntry=[...this.calledByEntry],i.parent=this.parent,this}recursiveCaptureUpstreamVersions(i){const n=[],s=[],c=[],e=[];if(this.parent){this.parent.increaseVersion(i);const y=this.parent.recursiveCaptureUpstreamVersions(i);n.push(this.parent,...y.updated),s.push(...y.added),c.push(...y.removed)}return{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}async restoreVersion(i){var m;const n=[],s=[],c=[],e=[];if(this.version===i)return{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this};if(!this.knownVersions){const v=new Map;for(const[E,b]of this.knownVersions||new Map){if(v.set(E,b),b.activeVersion=!1,b.knownVersions)for(const[w,V]of b.knownVersions)v.set(w,V);b.knownVersions=null}}let y=(m=this.knownVersions)==null?void 0:m.get(i);if(!y){const v=await this.APILoadVersion({},i);if(!v)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);y=new Vi(v,this.project)}return this.metaSync(y.toShallowJSON(),null),this.previousVersion=y.previousVersion,this.version=y.version,this.createdAt=y.createdAt,this.author=y.author,this.deleted=y.deleted,this.outputs=y.outputs,this.readsValue=y.readsValue,this.defaultValue=y.defaultValue,this.dataType=y.dataType,this.throws=y.throws,this.calledBySuccess=y.calledBySuccess,this.calledByError=y.calledByError,this.calledByEntry=y.calledByEntry,this.parent=y.parent,{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}updateWithShallowTransfer(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.UpdateWithShallowTransfer))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[updateWithShallowTransfer] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),this;if(this.metaSync(i,n),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 s=ne(i.parent),c=this.project.get(s),e=this.parent;if(e&&e.id!==(c==null?void 0:c.id)&&this.removeFromParent(n),c)this.setParent(c,n),this.addSelfToProject(n);else throw n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${s}' that isn't found in the project`)}else throw n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(i.readsValue){const s=ne(i.readsValue),c=this.project.get(s),e=this.readsValue;e&&e.id!==(c==null?void 0:c.id)&&this.removeValueWriter(n),c&&this.setValueWriter(c,n)}else this.removeValueWriter(n);if(i.calledByEntry.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addEntryCaller(e,n),e.addCall(this,n))}),[...this.calledByEntry].forEach(s=>{i.calledByEntry.find(e=>ne(e)===s.id)||(this.removeCaller(s,n),s.removeCall(this,n))}),i.calledBySuccess.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addSuccessCaller(e,n),e.addSuccessCall(this,n))}),[...this.calledBySuccess].forEach(s=>{i.calledBySuccess.find(e=>ne(e)===s.id)||(this.removeCaller(s,n),s.removeCall(this,n))}),i.calledByError.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addErrorCaller(e,n),e.addErrorCall(this,n))}),[...this.calledByError].forEach(s=>{i.calledByError.find(e=>ne(e)===s.id)||(this.removeCaller(s,n),s.removeCall(this,n))}),i.outputs.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addOutput(e,n),e.setParent(this,n))}),[...this.outputs].forEach(s=>{i.outputs.find(e=>ne(e)===s.id)||(this.removeOutput(s,n),s.removeFromParent(n))}),i.dataType){const s=ne(i.dataType),c=this.project.get(s);c&&this.setDataType(c,n)}else this.setDataType(null,n);if(i.defaultValue){const s=ne(i.defaultValue),c=this.project.get(s);c&&this.setDefaultValue(c,n)}else this.setDefaultValue(null,n);return this.captureVersion(),this.subscribeToDependencies(),n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),this}hydrateAncestors(){const i=[],n=[],s=[],c=[];if(this.initialData.parent){const e=ne(this.initialData.parent),y=this.project.get(e);if(y)this.setParent(y,null),i.push(y);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.readsValue){const e=ne(this.initialData.readsValue),y=this.project.get(e);y&&(this.setValueWriter(y,null),i.push(y))}return this.initialData.calledByEntry.forEach(e=>{const y=ne(e),m=this.project.get(y);m&&(this.addEntryCaller(m,null),i.push(m))}),this.initialData.calledBySuccess.forEach(e=>{const y=ne(e),m=this.project.get(y);m&&(this.addSuccessCaller(m,null),i.push(m))}),this.initialData.calledByError.forEach(e=>{const y=ne(e),m=this.project.get(y);m&&(this.addErrorCaller(m,null),i.push(m))}),{updated:D(i),added:D(n),removed:D(s),affected:D(c),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AfterAllChildrenInitialized))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[afterAllChildrenInitialized] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.AfterAllChildrenInitialized,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];this.initialized=!0,!this.dataType||this.dataType.inferred;const{added:y,updated:m,removed:v,affected:E}=this.syncInputs(i);return s.push(...y),n.push(...m),c.push(...v),e.push(...E),this.parent.syncTerminationStatements(i),this.outputs.sort((b,w)=>{var V,$;return(b.index??((V=b.declaration)==null?void 0:V.index))-(w.index??(($=w.declaration)==null?void 0:$.index))}),this.captureVersion(),i==null||i.attemptAutoclose(_.AfterAllChildrenInitialized,this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}addSelfToProject(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"add-self-to-project"))){var y,m;const n=[this],s=[],c=[],e=[];return this.readsValue&&(this.readsValue.addValueReader(this,i),n.push(this.readsValue)),this.calledByEntry.forEach(v=>{v.addCall(this,i),n.push(v)}),this.calledBySuccess.forEach(v=>{v.addSuccessCall(this,i),n.push(v)}),this.calledByError.forEach(v=>{v.addErrorCall(this,i),n.push(v)}),this.parent.addBreakStatement(this),e.push(this.parent),i==null||i.add(this.parent,H.Affected),(y=this.parent)==null||y.breakStatements.forEach(v=>{v.id!==this.id&&(e.push(v),i==null||i.add(v,H.Affected))}),(m=this.parent)==null||m.continueStatements.forEach(v=>{v.id!==this.id&&(e.push(v),i==null||i.add(v,H.Affected))}),this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}addSuccessCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddSuccessCaller)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddSuccessCaller,n)?(this.calledBySuccess.find(c=>c.id===i.id)||(this.calledBySuccess.push(i),n==null||n.add(this,H.Updated),s&&mt(this,n)),n==null||n.attemptAutoclose(_.AddSuccessCaller,this.id),this):this}addErrorCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddErrorCaller)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddErrorCaller,n)?(this.calledByError.find(c=>c.id===i.id)||(this.calledByError.push(i),n==null||n.add(this,H.Updated),s&&mt(this,n)),n==null||n.attemptAutoclose(_.AddErrorCaller,this.id),this):this}addEntryCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddEntryCaller)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddEntryCaller,n)?(this.calledByEntry.find(c=>c.id===i.id)||(this.calledByEntry.push(i),n==null||n.add(this,H.Updated),s&&mt(this,n)),n==null||n.attemptAutoclose(_.AddEntryCaller,this.id),this):this}removeCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-caller")),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.RemoveCaller,n)?(this.calledBySuccess=this.calledBySuccess.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),this.calledByError=this.calledByError.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),this.calledByEntry=this.calledByEntry.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),s&&mt(this,n),n==null||n.attemptAutoclose(_.RemoveCaller,this.id),this):this}setThrows(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"set-throws"))){var s;if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setThrows] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("set-throws",this.id),this;if(i!==null&&i.parentRelationType!==vd.Error)throw new Error("The 'throws' InputMap must have a parentRelationType of 'Error'.");return((s=this.throws)==null?void 0:s.id)!==(i==null?void 0:i.id)&&(this.throws=i,n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose("set-throws",this.id),this}addOutput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"add-output"))){return this.checkCanEdit(this,n)?this.outputs.includes(i)?(n==null||n.attemptAutoclose("add-output",this.id),this):(this.outputs.push(i),n==null||n.add(this,H.Affected),n==null||n.attemptAutoclose("add-output",this.id),this):(J.Logger.warn(`[addOutput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("add-output",this.id),this)}removeOutput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-output"))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[removeOutput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("remove-output",this.id),this;const s=this.outputs.findIndex(c=>c.id===i.id);return s>-1&&(this.outputs.splice(s,1),n&&(n==null||n.add(this,H.Affected))),n==null||n.attemptAutoclose("remove-output",this.id),this}setParent(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetParent))){var s;return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.SetParent,n)?(((s=this.parent)==null?void 0:s.id)!==(i==null?void 0:i.id)&&(this.parent=i,n&&(n==null||n.add(this,H.Updated))),n==null||n.attemptAutoclose(_.SetParent,this.id),this):this}setValueWriter(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetValueWriter))){return this.checkCanEditFromScopeOwnerWithSideEffects(this,_.SetValueWriter,n)?(this.readsValue!==i&&(this.readsValue=i,n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose(_.SetValueWriter,this.id),this):this}removeValueWriter(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveValueWriter))){return this.readsValue&&!this.checkCanEditWithCounterpartAndSideEffects(this,this.readsValue,_.RemoveValueWriter,i)?this:(this.readsValue&&(this.readsValue=null,i==null||i.add(this,H.Updated)),i==null||i.attemptAutoclose(_.RemoveValueWriter,this.id),this)}initChildren(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"init-children"))){return this.initialized||this.startedInitialization?this:(this.startedInitialization=!0,this.initialData.defaultValue&&(this.defaultValue=me(this.initialData.defaultValue,this.project),this.defaultValue.setParent(this,null),this.defaultValue.initChildren(i)),this.initialData.dataType&&(this.dataType=me(this.initialData.dataType,this.project),this.dataType.setParent(this,null),this.dataType.initChildren(i)),lf.initReadsValue(this),this.outputs=this.initialData.outputs.map(n=>{const s=me(n,this.project);return s.setParent(this,null),s.initChildren(i),s}),this.initialData.throws&&(this.throws=me(this.initialData.throws,this.project),this.throws.setParent(this,null),this.throws.initChildren(i)),this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this)}subscribe(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"meta-sync"))){const s=Mr(this,i,n),c=Lr(this,s),e=this.toMeta();return this.x=s.x||e.x,this.y=s.y||e.y,super.baseMetaSync(s,this,n),s.deleted===!0&&!e.deleted?n==null||n.add(this,H.Removed):s.deleted===!1&&e.deleted?n==null||n.add(this,H.Added):c&&(n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=ke,...n){return await Vi.repository.APILoad(this.id,...n),this}async APICreate(i=ke,...n){return await Vi.repository.APICreate(this.toShallowJSON(),...n),this}async APIUpdate(i=ke,...n){return await Vi.repository.APIUpdate(this.toShallowJSON(),...n),this}async APIDelete(i=ke,...n){return await Vi.repository.APIDelete(this.toShallowJSON(),...n),this}async APIClone(i=ke,...n){return await Vi.repository.APIClone(this.id,...n),this}async APILoadVersion(i=ke,n,...s){return await Vi.repository.APILoadVersion(this.id,n,...s)}removeFromParent(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveFromParent))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[removeFromParent] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveFromParent,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];return this.parent.removeBreakStatement(this),e.push(this.parent),i==null||i.attemptAutoclose(_.RemoveFromParent,this.id),{added:D(c),updated:D(n),removed:D(s),affected:D(e),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveEntity))){var m,v,E;if(!this.checkCanDelete(this,n))return J.Logger.warn(`[remove] User is not allowed to delete or edit this ${this.type} entity with id: ${this.id}`),n==null||n.event({id:`${_.RemoveEntity}-${this.id}`,action:_.RemoveEntity,owner:this,errorReason:Ii.ActionOwnerEntityNonDeletable,rootAction:((m=n==null?void 0:n.self)==null?void 0:m.id)===this.id&&(n==null?void 0:n.autoCloseActionName)===_.RemoveEntity}),n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const s=[],c=[],e=[],y=[];if(n!=null&&n.hasRemoved(this.id))return n==null||n.attemptAutoclose(_.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},n),Object.values(this.detachedDependents).forEach(b=>{const{updated:w,removed:V,added:$}=b.entity.onDetachedDependencyRemoved(this,b.field,n);s.push(...w),c.push(...V),e.push(...$)}),this.readsValue&&(s.push(this.readsValue),this.readsValue.removeValueReader(this,n)),this.outputs.forEach(b=>{const{updated:w,removed:V}=b.remove({ignoreUpstream:!0},n);s.push(...w),c.push(...V)}),this.throws){const{updated:b,removed:w}=this.throws.remove({ignoreUpstream:!0},n);s.push(...b),c.push(...w)}if(this.dataType){const{updated:b,removed:w}=this.dataType.remove({ignoreUpstream:!0},n);s.push(...b),c.push(...w)}if(!i){const b=this.removeFromParent(n);e.push(...b.added),s.push(...b.updated),c.push(...b.removed),y.push(...b.affected),this.calledBy.forEach(w=>{s.push(w),w.removeCall(this,n)})}return n==null||n.add(this.parent,H.Affected),(v=this.parent)==null||v.breakStatements.forEach(b=>{b.id!==this.id&&(y.push(b),n==null||n.add(b,H.Affected))}),(E=this.parent)==null||E.continueStatements.forEach(b=>{b.id!==this.id&&(y.push(b),n==null||n.add(b,H.Affected))}),n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:D(e),updated:D(s),removed:D(c),affected:D(y),self:this}}restore({}={},i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RestoreEntity))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[restore] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];if(i!=null&&i.hasAdded(this.id))return i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},i),Object.values(this.detachedDependents).forEach(y=>{const{updated:m,removed:v,added:E}=y.entity.onDetachedDependencyRestored(this,y.field,i);s.push(...m),c.push(...v),n.push(...E)}),this.readsValue&&(s.push(this.readsValue),this.readsValue.addValueReader(this,i)),this.outputs.forEach(y=>{const{updated:m}=y.restore({},i);s.push(...m)}),this.throws){const{updated:y}=this.throws.restore({},i);s.push(...y)}if(this.dataType){const{updated:y}=this.dataType.restore({},i);s.push(...y)}return this.parent.addBreakStatement(this),this.calledBySuccess.forEach(y=>{s.push(y),y.addSuccessCall(this,i)}),this.calledByError.forEach(y=>{s.push(y),y.addErrorCall(this,i)}),this.calledByEntry.forEach(y=>{s.push(y),y.addCall(this,i)}),i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this}}toFlat(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this,...this.outputs.flatMap(s=>s.toFlat(i)),...this.throws?this.throws.toFlat(i):[],...this.dataType?this.dataType.toFlat(i):[]])}toFlatIds(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.outputs.flatMap(s=>s.toFlatIds(i)),...this.throws?this.throws.toFlatIds(i):[],...this.dataType?this.dataType.toFlatIds(i):[]])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,x:this.x,y:this.y,type:this.type,editable:this.editable,deletable:this.deletable}}toJSON(i=new Set){var n,s,c,e,y;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,x:this.x,y:this.y,defaultValue:((n=this.defaultValue)==null?void 0:n.toJSON(i))||null,dataType:((s=this.dataType)==null?void 0:s.toJSON(i))||null,readsValue:((c=this.readsValue)==null?void 0:c.toReference())||null,outputs:this.outputs.map(m=>m.toJSON(i)),calledBySuccess:this.calledBySuccess.map(m=>m.toReference()),calledByError:this.calledByError.map(m=>m.toReference()),calledByEntry:this.calledByEntry.map(m=>m.toReference()),parent:((e=this.parent)==null?void 0:e.toReference())||null,throws:((y=this.throws)==null?void 0:y.toJSON(i))||null})}toJSONClone(i=ct){var s,c,e,y,m,v,E,b,w,V;let n;return(s=i.seenEntityMaps)!=null&&s.has(this.id)?n=i.seenEntityMaps.get(this.id):(n=i.newId||jr(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,n)),(c=i.seenEntities)!=null&&c.has(n)||(e=i.seenEntities)!=null&&e.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((y=i.seenEntities)==null||y.add(n),(m=i.seenEntities)==null||m.add(this.id),{id:n,version:x.UUID.uuid(),createdAt:i.timestamp||M().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,x:this.x,y:this.y,defaultValue:((v=this.defaultValue)==null?void 0:v.toJSONClone({...i,newId:null}))||null,dataType:((E=this.dataType)==null?void 0:E.toJSONClone({...i,newId:null}))||null,readsValue:((b=this.readsValue)==null?void 0:b.toReference({seenEntityMaps:i.seenEntityMaps}))||null,outputs:this.outputs.map($=>$.toJSONClone({...i,newId:null})),calledBySuccess:this.calledBySuccess.map($=>$.toReference({seenEntityMaps:i.seenEntityMaps})),calledByError:this.calledByError.map($=>$.toReference({seenEntityMaps:i.seenEntityMaps})),calledByEntry:this.calledByEntry.map($=>$.toReference({seenEntityMaps:i.seenEntityMaps})),parent:((w=this.parent)==null?void 0:w.toReference({seenEntityMaps:i.seenEntityMaps}))||null,throws:((V=this.throws)==null?void 0:V.toJSONClone({...i,newId:null}))||null})}toReference(i=ct){var s;let n=this.id;return(s=i.seenEntityMaps)!=null&&s.has(this.id)&&(n=i.seenEntityMaps.get(this.id)),{id:n+"--"+x.UUID.uuid()+"--ref",type:d.GenericReference,entityId:n,version:this.version,entityType:this.type}}toShallowJSON(i=ct){var s,c,e,y,m,v;let n=this.id;return(s=i.seenEntityMaps)!=null&&s.has(this.id)&&(n=i.seenEntityMaps.get(this.id)),{id:n,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,x:this.x,y:this.y,defaultValue:((c=this.defaultValue)==null?void 0:c.toReference(i))||null,dataType:((e=this.dataType)==null?void 0:e.toReference(i))||null,readsValue:((y=this.readsValue)==null?void 0:y.toReference(i))||null,outputs:this.outputs.map(E=>E.toReference(i)),calledBySuccess:this.calledBySuccess.map(E=>E.toReference(i)),calledByError:this.calledByError.map(E=>E.toReference(i)),calledByEntry:this.calledByEntry.map(E=>E.toReference(i)),throws:((m=this.throws)==null?void 0:m.toReference(i))||null,parent:((v=this.parent)==null?void 0:v.toReference(i))||null}}toFlatJSON(i=new Set){var s,c;return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...((s=this.defaultValue)==null?void 0:s.toFlatJSON(i))||[],...((c=this.dataType)==null?void 0:c.toFlatJSON(i))||[],...this.outputs.flatMap(e=>e.toFlatJSON(i)),...this.throws?this.throws.toFlatJSON(i):[]])}toGenerationTarget(){return{id:this.id,type:this.type,calledByEntry:this.calledByEntry.map(i=>i.id),calledByError:this.calledByError.map(i=>i.id),calledBySuccess:this.calledBySuccess.map(i=>i.id),parent:this.parent.id}}toFlatGenerationTarget(i=new Set){var s,c;return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...((s=this.defaultValue)==null?void 0:s.toFlatGenerationTarget(i))||[],...((c=this.dataType)==null?void 0:c.toFlatGenerationTarget(i))||[],...this.outputs.flatMap(e=>e.toFlatGenerationTarget(i)),...this.throws?this.throws.toFlatGenerationTarget(i):[]])}clearErrors(){var i,n,s;return this.errors=[],(i=this.dataType)==null||i.clearErrors(),(n=this.defaultValue)==null||n.clearErrors(),this.outputs.forEach(c=>c.clearErrors()),(s=this.throws)==null||s.clearErrors(),this}validate(){return this.errors=OMe(this),{success:!0}}async validateAsync(i={}){const n=J.YieldTracker.from(i);return this.errors=await wMe(this,{tracker:n}),{success:!0}}getErrors(){var n,s;return[...this.errors,...((n=this.defaultValue)==null?void 0:n.getErrors())||[],...((s=this.dataType)==null?void 0:s.getErrors())||[],...this.outputs.flatMap(c=>c.getErrors()),...this.throws?this.throws.getErrors():[]]}async getErrorsAsync(i={}){const n=J.YieldTracker.from(i),s=[...this.errors];if(await n.tick(),this.defaultValue){const c=await this.defaultValue.getErrorsAsync({tracker:n});s.push(...c)}if(this.dataType){const c=await this.dataType.getErrorsAsync({tracker:n});s.push(...c)}for(const c of this.outputs){const e=await c.getErrorsAsync({tracker:n});s.push(...e)}if(this.throws){const c=await this.throws.getErrorsAsync({tracker:n});s.push(...c)}return s}getShallowErrors(){return this.errors}getDefaultValue(){return this.defaultValue||null}setDefaultValue(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"set-default-value"))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setDefaultValue] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("set-default-value",this.id),this;const s=this.defaultValue;return(s==null?void 0:s.id)!==(i==null?void 0:i.id)&&(s==null||s.remove({ignoreUpstream:!0},n),this.defaultValue=i,n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose("set-default-value",this.id),this}clone(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.CloneEntity)),n=null,s=null,c=!0){var L,k,K;const e=Rr(n,this),y=this.toJSON(),m=s||x.UUID.uuid();y.outputs=[];const v=m.split("-id"),E=v[v.length-1||0]||m;y.id=m,y.version=x.UUID.uuid(),y.createdAt=(i==null?void 0:i.timestamp)||M().toISOString(),y.author=(i==null?void 0:i.author)||"1",y.previousVersion=null,y.deleted=!1,y.deletable=!0,y.editable=!0;const b=Si(y,e);n?b.setParent(n,i):b.setParent(this.parent,null),c&&b.subscribe(),b.initChildren(i),i==null||i.add(b,H.Added);const w=(L=this.dataType)==null?void 0:L.clone(i,b,x.UUID.uuid(),c);b.setDataType(w||null,i);const V=(k=this.defaultValue)==null?void 0:k.clone(i,b,x.UUID.uuid(),c);b.setDefaultValue(V||null,i);const $=(K=this.outputs)==null?void 0:K.map((S,Y)=>S.clone(i,b,E+"-return-declaration-"+Y+"-id",c));return b.outputs=$,this.throws&&(b.throws=this.throws.clone(i,b,E+"-throws-id",c)),i==null||i.attemptAutoclose(_.CloneEntity,this.id),b}getMasterInputWithValueWritterFromAllInstances(i){return D([...this.outputs,...this.parent.breakStatements.filter(c=>c.id!==this.id).flatMap(c=>c.outputs),...this.parent.continueStatements.flatMap(c=>c.outputs)]).find(c=>se(c,this.project)===se(i,this.project)&&!!c.readsValue)||i}syncInputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"sync-break-statement-inputs"))){const n=[],s=[],c=[],e=[],y=this.getDataType(i);if(y)if(y.entity){if(y.isObject()){const m=[...y.entity.properties];this.outputs.filter(b=>!b.declaration||!m.find(w=>{var V;return w.id===((V=b.declaration)==null?void 0:V.id)})).forEach(b=>{const w=m.find(V=>se(V,this.project)===se(b,this.project));w&&b.setDeclaration(w,i)}),m.filter(b=>!this.outputs.find(w=>{var V;return((V=w.declaration)==null?void 0:V.id)===b.id})).forEach(b=>{const w={dataType:null,id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||M().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.InputMap,parentRelationType:null,parent:this.toReference(),name:null,description:null,codeName:null,declaration:b,defaultValue:null,index:b.index,readsValue:null},V=me(w,this.project);return V.hydrateAncestors(),i==null||i.add(V,H.Added),V.setParent(this,i),V.initChildren(i),this.addOutput(V,i),V})}}else return i==null||i.attemptAutoclose("sync-break-statement-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};else return i==null||i.attemptAutoclose("sync-break-statement-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};return i==null||i.attemptAutoclose("sync-break-statement-inputs",this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this}}setDataType(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetDataType))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setDataType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.SetDataType,this.id),this;const s=this.dataType;return(s==null?void 0:s.id)!==(i==null?void 0:i.id)&&(s==null||s.remove({ignoreUpstream:!0},n),this.dataType=i,this.subscribeToDependencies(),n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose(_.SetDataType,this.id),this}removeDataType(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveDataType))){return this.checkCanEdit(this,i)?(this.dataType&&(this.dataType.remove({ignoreUpstream:!0},i),i==null||i.add(this,H.Affected),this.dataType=null),i==null||i.attemptAutoclose(_.RemoveDataType,this.id),this):(J.Logger.warn(`[removeDataType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveDataType,this.id),this)}getDataType(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"get-data-type"))){if((!this.dataType||this.dataType.inferred)&&this.project.initialized,this.dataType)return i==null||i.attemptAutoclose("get-data-type",this.id),this.dataType;const n=this.parent.getDataType(i);return n?(i==null||i.attemptAutoclose("get-data-type",this.id),n):(i==null||i.attemptAutoclose("get-data-type",this.id),null)}};I(Vi,"repository",{APICreate:async(i,...n)=>i,APIUpdate:async(i,...n)=>i,APIDelete:async(i,...n)=>i,APIClone:async(i,...n)=>{},APILoad:async(i,...n)=>null,APILoadVersion:async(i,n,...s)=>null}),I(Vi,"type",d.BreakStatement),I(Vi,"USER_MANAGED_PARENT_TYPES",[d.Loop]),I(Vi,"PARENT_TYPES",[...Vi.USER_MANAGED_PARENT_TYPES]),I(Vi,"MUTABLE_BASE_PROPERTIES",[]),I(Vi,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),I(Vi,"BASE_PROPERTIES",[...Vi.MUTABLE_BASE_PROPERTIES,...Vi.INMUTABLE_BASE_PROPERTIES]),I(Vi,"MUTABLE_META_PROPERTIES",["x","y"]),I(Vi,"INMUTABLE_META_PROPERTIES",[...Vi.INMUTABLE_BASE_PROPERTIES]),I(Vi,"META_PROPERTIES",[...Vi.MUTABLE_META_PROPERTIES,...Vi.INMUTABLE_META_PROPERTIES]),I(Vi,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry","readsValue"]),I(Vi,"INMUTABLE_UPSTREAM_PROPERTIES",["parent"]),I(Vi,"UPSTREAM_PROPERTIES",[...Vi.MUTABLE_UPSTREAM_PROPERTIES,...Vi.INMUTABLE_UPSTREAM_PROPERTIES]),I(Vi,"MUTABLE_DOWNSTREAM_PROPERTIES",["outputs","throws"]),I(Vi,"INMUTABLE_DOWNSTREAM_PROPERTIES",["dataType","defaultValue"]),I(Vi,"DOWNSTREAM_PROPERTIES",[...Vi.MUTABLE_DOWNSTREAM_PROPERTIES,...Vi.INMUTABLE_DOWNSTREAM_PROPERTIES]),I(Vi,"PROPERTIES",[...Vi.META_PROPERTIES,...Vi.UPSTREAM_PROPERTIES,...Vi.DOWNSTREAM_PROPERTIES]);let Ku=Vi;async function _Me(o,p={}){var c;const i=J.YieldTracker.from(p),n=[];await i.tick();const s=Mt(o.errors,n);for(const e of o.outputs)await e.validateAsync({tracker:i});return await((c=o.throws)==null?void 0:c.validateAsync({tracker:i})),s}function VMe(o){var i;o.outputs.forEach(n=>n.validate()),(i=o.throws)==null||i.validate();const p=[];return Mt(o.errors,p)}const cIi=Object.freeze(Object.defineProperty({__proto__:null,validate:VMe,validateAsync:_Me},Symbol.toStringTag,{value:"Module"}));var PMe=(o=>(o.Parent="continue-statement-parent-field",o.DataTypeEntity="continue-statement-data-type-entity-field",o.DataType="continue-statement-data-type-field",o.ParentDataType="continue-statement-parent-data-type-field",o.ParentDataTypeEntity="continue-statement-parent-data-type-entity-field",o))(PMe||{});const Pi=class Pi extends Ur{constructor(i,n){super(i);I(this,"initialData");I(this,"id");I(this,"x");I(this,"y");I(this,"type",d.ContinueStatement);I(this,"outputs",[]);I(this,"readsValue",null);I(this,"dataType",null);I(this,"defaultValue",null);I(this,"calledBySuccess",[]);I(this,"calledByError",[]);I(this,"calledByEntry",[]);I(this,"throws",null);I(this,"project");I(this,"errors",[]);I(this,"parent");I(this,"detachedDependents",{});I(this,"knownVersions",null);I(this,"activeVersion",!1);I(this,"initialized",!1);I(this,"startedInitialization",!1);I(this,"suggestion",!1);I(this,"_codeNativeValueValidation",null);this.initialData=i,this.project=n,this.id=i.id,this.x=i.x,this.y=i.y}static new(i=null){return{id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||M().toISOString(),author:(i==null?void 0:i.author)||x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.ContinueStatement,outputs:[],defaultValue:null,dataType:null,readsValue:null,throws:null,parent:null,calledByEntry:[],calledBySuccess:[],calledByError:[],x:0,y:0}}static fromGenerationTarget(i,n){const s=ne(i.parent),c=n.get(s),e=i.calledByEntry.map(w=>{const V=ne(w);return n.get(V)}),y=i.calledBySuccess.map(w=>{const V=ne(w);return n.get(V)}),m=i.calledByError.map(w=>{const V=ne(w);return n.get(V)});let v=null;if(i.readsValue){const w=ne(i.readsValue);v=n.get(w)}const E={id:i.id,version:x.UUID.uuid(),createdAt:M().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.ContinueStatement,x:0,y:0,outputs:[],defaultValue:null,dataType:null,readsValue:v,calledBySuccess:y,calledByError:m,calledByEntry:e,throws:null,parent:c},b=me(E,n);return b.setParent(c,null),b}static validateGenerationTarget(i,n){let s=JSON.parse(JSON.stringify(i));const c=[],e=bn(s,{parent:{list:!1,types:[d.Loop]}},n);return s=e.modifiedData,c.push(...e.errors,...$r(s)),{errors:c,modifiedData:s}}get codeNativeValueValidation(){return this._codeNativeValueValidation||null}validateGeneratedUpdate(i){const n=[];let s=JSON.parse(JSON.stringify(i));const c=sf(s,this);return s=c.modifiedData,n.push(...c.errors),i.parent&&n.push(new De({id:`${this.id}--${ae.InvalidParentUpdate}`,code:ae.InvalidParentUpdate,severity:ce.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated. The 'parent' on a callable entity, is its scope. It scope is auto-calculated implicitly by the its caller.
|
|
177
|
+
Specifically for break statements the parent needs to always be the 'loop' entity that contains it.`})),{errors:n,modifiedData:i}}subscribeDependents(i){return i.forEach(n=>{this.detachedDependents[n.entity.id]||(this.detachedDependents[n.entity.id]=n)}),this}unsubscribeDependents(i){return i.forEach(n=>{this.detachedDependents[n.entity.id]&&delete this.detachedDependents[n.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"sync-dependents"))){const n=[],s=[],c=[],e=[];return Object.values(this.detachedDependents).forEach(y=>{const m=y.entity.afterAllChildrenInitialized(i);n.push(...m.updated),s.push(...m.added),c.push(...m.removed),e.push(...m.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}onDetachedDependencyRemoved(i,n,s){const c=[],e=[],y=[],m=[];if(n==="break-statement-parent-field"){const{updated:v,added:E,removed:b}=this.remove({ignoreUpstream:!1},s);c.push(...v),e.push(...E),y.push(...b)}if(n==="break-statement-parent-data-type-field"){const{updated:v,added:E,removed:b}=this.afterAllChildrenInitialized(s);c.push(...v),e.push(...E),y.push(...b)}if(n==="break-statement-parent-data-type-entity-field"){const{updated:v,added:E,removed:b}=this.afterAllChildrenInitialized(s);c.push(...v),e.push(...E),y.push(...b)}return{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:this}}onDetachedDependencyRestored(i,n,s){const c=[],e=[],y=[],m=[];if(n==="break-statement-parent-field"){const{updated:v,added:E,removed:b}=this.restore({},s);c.push(...v),e.push(...E),y.push(...b)}if(n==="break-statement-parent-data-type-field"){const{updated:v,added:E,removed:b}=this.afterAllChildrenInitialized(s);c.push(...v),e.push(...E),y.push(...b)}if(n==="break-statement-parent-data-type-entity-field"){const{updated:v,added:E,removed:b}=this.afterAllChildrenInitialized(s);c.push(...v),e.push(...E),y.push(...b)}return{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:this}}unsubscribeFromDependencies(){var i,n,s,c,e,y,m,v,E,b,w,V;return this.parent.unsubscribeDependents([{entity:this,field:"break-statement-parent-field"}]),(s=(n=(i=this.dataType)==null?void 0:i.entity)==null?void 0:n.unsubscribeDependents)==null||s.call(n,[{entity:this,field:"break-statement-data-type-entity-field"}]),(e=(c=this.dataType)==null?void 0:c.unsubscribeDependents)==null||e.call(c,[{entity:this,field:"break-statement-data-type-field"}]),(E=(v=(m=(y=this.parent)==null?void 0:y.dataType)==null?void 0:m.entity)==null?void 0:v.unsubscribeDependents)==null||E.call(v,[{entity:this,field:"break-statement-parent-data-type-entity-field"}]),(V=(w=(b=this.parent)==null?void 0:b.dataType)==null?void 0:w.unsubscribeDependents)==null||V.call(w,[{entity:this,field:"break-statement-parent-data-type-field"}]),this}subscribeToDependencies(){var i,n,s,c,e,y,m,v,E,b,w,V,$;return(i=this.parent)==null||i.subscribeDependents([{entity:this,field:"break-statement-parent-field"}]),(c=(s=(n=this.dataType)==null?void 0:n.entity)==null?void 0:s.subscribeDependents)==null||c.call(s,[{entity:this,field:"break-statement-data-type-entity-field"}]),(y=(e=this.dataType)==null?void 0:e.subscribeDependents)==null||y.call(e,[{entity:this,field:"break-statement-data-type-field"}]),(b=(E=(v=(m=this.parent)==null?void 0:m.dataType)==null?void 0:v.entity)==null?void 0:E.subscribeDependents)==null||b.call(E,[{entity:this,field:"break-statement-parent-data-type-entity-field"}]),($=(V=(w=this.parent)==null?void 0:w.dataType)==null?void 0:V.subscribeDependents)==null||$.call(V,[{entity:this,field:"break-statement-parent-data-type-field"}]),this}increaseVersion(i){if(i&&!M(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&M(i).isSame(M(this.createdAt))?this:(this.previousVersion=this.version,this.version=x.UUID.uuid(),this.createdAt=M(i).toISOString()||M().toISOString(),this)}captureVersion(){var n;const i=((n=this.knownVersions)==null?void 0:n.get(this.version))||new Vi(this,this.project);return i.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map([[this.version,i]]),i.outputs=[...this.outputs],i.readsValue=this.readsValue,i.defaultValue=this.defaultValue,i.dataType=this.dataType,i.throws=this.throws,i.calledBySuccess=[...this.calledBySuccess],i.calledByError=[...this.calledByError],i.calledByEntry=[...this.calledByEntry],i.parent=this.parent,this}recursiveCaptureUpstreamVersions(i){const n=[],s=[],c=[],e=[];if(this.parent){this.parent.increaseVersion(i);const y=this.parent.recursiveCaptureUpstreamVersions(i);n.push(this.parent,...y.updated),s.push(...y.added),c.push(...y.removed)}return{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}async restoreVersion(i){var m;const n=[],s=[],c=[],e=[];if(this.version===i)return{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this};if(!this.knownVersions){const v=new Map;for(const[E,b]of this.knownVersions||new Map){if(v.set(E,b),b.activeVersion=!1,b.knownVersions)for(const[w,V]of b.knownVersions)v.set(w,V);b.knownVersions=null}}let y=(m=this.knownVersions)==null?void 0:m.get(i);if(!y){const v=await this.APILoadVersion({},i);if(!v)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);y=new Vi(v,this.project)}return this.metaSync(y.toShallowJSON(),null),this.previousVersion=y.previousVersion,this.version=y.version,this.createdAt=y.createdAt,this.author=y.author,this.deleted=y.deleted,this.outputs=y.outputs,this.readsValue=y.readsValue,this.defaultValue=y.defaultValue,this.dataType=y.dataType,this.throws=y.throws,this.calledBySuccess=y.calledBySuccess,this.calledByError=y.calledByError,this.calledByEntry=y.calledByEntry,this.parent=y.parent,{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}updateWithShallowTransfer(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.UpdateWithShallowTransfer))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[updateWithShallowTransfer] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),this;if(this.metaSync(i,n),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 s=ne(i.parent),c=this.project.get(s),e=this.parent;if(e&&e.id!==(c==null?void 0:c.id)&&this.removeFromParent(n),c)this.setParent(c,n),this.addSelfToProject(n);else throw n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${s}' that isn't found in the project`)}else throw n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(i.readsValue){const s=ne(i.readsValue),c=this.project.get(s),e=this.readsValue;e&&e.id!==(c==null?void 0:c.id)&&this.removeValueWriter(n),c&&this.setValueWriter(c,n)}else this.removeValueWriter(n);if(i.calledByEntry.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addEntryCaller(e,n),e.addCall(this,n))}),[...this.calledByEntry].forEach(s=>{i.calledByEntry.find(e=>ne(e)===s.id)||(this.removeCaller(s,n),s.removeCall(this,n))}),i.calledBySuccess.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addSuccessCaller(e,n),e.addSuccessCall(this,n))}),[...this.calledBySuccess].forEach(s=>{i.calledBySuccess.find(e=>ne(e)===s.id)||(this.removeCaller(s,n),s.removeCall(this,n))}),i.calledByError.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addErrorCaller(e,n),e.addErrorCall(this,n))}),[...this.calledByError].forEach(s=>{i.calledByError.find(e=>ne(e)===s.id)||(this.removeCaller(s,n),s.removeCall(this,n))}),i.outputs.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addOutput(e,n),e.setParent(this,n))}),[...this.outputs].forEach(s=>{i.outputs.find(e=>ne(e)===s.id)||(this.removeOutput(s,n),s.removeFromParent(n))}),i.dataType){const s=ne(i.dataType),c=this.project.get(s);c&&this.setDataType(c,n)}else this.setDataType(null,n);if(i.defaultValue){const s=ne(i.defaultValue),c=this.project.get(s);c&&this.setDefaultValue(c,n)}else this.setDefaultValue(null,n);return this.captureVersion(),this.subscribeToDependencies(),n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),this}hydrateAncestors(){const i=[],n=[],s=[],c=[];if(this.initialData.parent){const e=ne(this.initialData.parent),y=this.project.get(e);if(y)this.setParent(y,null),i.push(y);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.readsValue){const e=ne(this.initialData.readsValue),y=this.project.get(e);y&&(this.setValueWriter(y,null),i.push(y))}return this.initialData.calledByEntry.forEach(e=>{const y=ne(e),m=this.project.get(y);m&&(this.addEntryCaller(m,null),i.push(m))}),this.initialData.calledBySuccess.forEach(e=>{const y=ne(e),m=this.project.get(y);m&&(this.addSuccessCaller(m,null),i.push(m))}),this.initialData.calledByError.forEach(e=>{const y=ne(e),m=this.project.get(y);m&&(this.addErrorCaller(m,null),i.push(m))}),{updated:D(i),added:D(n),removed:D(s),affected:D(c),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AfterAllChildrenInitialized))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[afterAllChildrenInitialized] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.AfterAllChildrenInitialized,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];this.initialized=!0,!this.dataType||this.dataType.inferred;const{added:y,updated:m,removed:v,affected:E}=this.syncInputs(i);return s.push(...y),n.push(...m),c.push(...v),e.push(...E),this.parent.syncTerminationStatements(i),this.outputs.sort((b,w)=>{var V,$;return(b.index??((V=b.declaration)==null?void 0:V.index))-(w.index??(($=w.declaration)==null?void 0:$.index))}),this.captureVersion(),i==null||i.attemptAutoclose(_.AfterAllChildrenInitialized,this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}addSelfToProject(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"add-self-to-project"))){var y,m;const n=[this],s=[],c=[],e=[];return this.readsValue&&(this.readsValue.addValueReader(this,i),n.push(this.readsValue)),this.calledByEntry.forEach(v=>{v.addCall(this,i),n.push(v)}),this.calledBySuccess.forEach(v=>{v.addSuccessCall(this,i),n.push(v)}),this.calledByError.forEach(v=>{v.addErrorCall(this,i),n.push(v)}),this.parent.addBreakStatement(this),e.push(this.parent),i==null||i.add(this.parent,H.Affected),(y=this.parent)==null||y.breakStatements.forEach(v=>{v.id!==this.id&&(e.push(v),i==null||i.add(v,H.Affected))}),(m=this.parent)==null||m.continueStatements.forEach(v=>{v.id!==this.id&&(e.push(v),i==null||i.add(v,H.Affected))}),this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}addSuccessCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddSuccessCaller)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddSuccessCaller,n)?(this.calledBySuccess.find(c=>c.id===i.id)||(this.calledBySuccess.push(i),n==null||n.add(this,H.Updated),s&&mt(this,n)),n==null||n.attemptAutoclose(_.AddSuccessCaller,this.id),this):this}addErrorCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddErrorCaller)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddErrorCaller,n)?(this.calledByError.find(c=>c.id===i.id)||(this.calledByError.push(i),n==null||n.add(this,H.Updated),s&&mt(this,n)),n==null||n.attemptAutoclose(_.AddErrorCaller,this.id),this):this}addEntryCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddEntryCaller)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddEntryCaller,n)?(this.calledByEntry.find(c=>c.id===i.id)||(this.calledByEntry.push(i),n==null||n.add(this,H.Updated),s&&mt(this,n)),n==null||n.attemptAutoclose(_.AddEntryCaller,this.id),this):this}removeCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-caller")),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.RemoveCaller,n)?(this.calledBySuccess=this.calledBySuccess.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),this.calledByError=this.calledByError.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),this.calledByEntry=this.calledByEntry.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),s&&mt(this,n),n==null||n.attemptAutoclose(_.RemoveCaller,this.id),this):this}setThrows(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"set-throws"))){var s;if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setThrows] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("set-throws",this.id),this;if(i!==null&&i.parentRelationType!==vd.Error)throw new Error("The 'throws' InputMap must have a parentRelationType of 'Error'.");return((s=this.throws)==null?void 0:s.id)!==(i==null?void 0:i.id)&&(this.throws=i,n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose("set-throws",this.id),this}addOutput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"add-output"))){return this.checkCanEdit(this,n)?this.outputs.includes(i)?(n==null||n.attemptAutoclose("add-output",this.id),this):(this.outputs.push(i),n==null||n.add(this,H.Affected),n==null||n.attemptAutoclose("add-output",this.id),this):(J.Logger.warn(`[addOutput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("add-output",this.id),this)}removeOutput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-output"))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[removeOutput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("remove-output",this.id),this;const s=this.outputs.findIndex(c=>c.id===i.id);return s>-1&&(this.outputs.splice(s,1),n&&(n==null||n.add(this,H.Affected))),n==null||n.attemptAutoclose("remove-output",this.id),this}setParent(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetParent))){var s;return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.SetParent,n)?(((s=this.parent)==null?void 0:s.id)!==(i==null?void 0:i.id)&&(this.parent=i,n&&(n==null||n.add(this,H.Updated))),n==null||n.attemptAutoclose(_.SetParent,this.id),this):this}setValueWriter(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetValueWriter))){var s;return this.checkCanEditFromScopeOwnerWithSideEffects(this,_.SetValueWriter,n)?(this.readsValue!==i&&(this.readsValue=i,this.readsValue&&((s=this.defaultValue)==null||s.remove({ignoreUpstream:!1},n)),n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose(_.SetValueWriter,this.id),this):this}removeValueWriter(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveValueWriter))){return this.readsValue&&!this.checkCanEditWithCounterpartAndSideEffects(this,this.readsValue,_.RemoveValueWriter,i)?this:(this.readsValue&&(this.readsValue=null,i==null||i.add(this,H.Updated)),i==null||i.attemptAutoclose(_.RemoveValueWriter,this.id),this)}initChildren(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"init-children"))){return this.initialized||this.startedInitialization?this:(this.startedInitialization=!0,this.initialData.defaultValue&&(this.defaultValue=me(this.initialData.defaultValue,this.project),this.defaultValue.setParent(this,null),this.defaultValue.initChildren(i)),this.initialData.dataType&&(this.dataType=me(this.initialData.dataType,this.project),this.dataType.setParent(this,null),this.dataType.initChildren(i)),lf.initReadsValue(this),this.outputs=this.initialData.outputs.map(n=>{const s=me(n,this.project);return s.setParent(this,null),s.initChildren(i),s}),this.initialData.throws&&(this.throws=me(this.initialData.throws,this.project),this.throws.setParent(this,null),this.throws.initChildren(i)),this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this)}subscribe(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"meta-sync"))){const s=Mr(this,i,n),c=Lr(this,s),e=this.toMeta();return this.x=s.x||e.x,this.y=s.y||e.y,super.baseMetaSync(s,this,n),s.deleted===!0&&!e.deleted?n==null||n.add(this,H.Removed):s.deleted===!1&&e.deleted?n==null||n.add(this,H.Added):c&&(n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=ke,...n){return await Vi.repository.APILoad(this.id,...n),this}async APICreate(i=ke,...n){return await Vi.repository.APICreate(this.toShallowJSON(),...n),this}async APIUpdate(i=ke,...n){return await Vi.repository.APIUpdate(this.toShallowJSON(),...n),this}async APIDelete(i=ke,...n){return await Vi.repository.APIDelete(this.toShallowJSON(),...n),this}async APIClone(i=ke,...n){return await Vi.repository.APIClone(this.id,...n),this}async APILoadVersion(i=ke,n,...s){return await Vi.repository.APILoadVersion(this.id,n,...s)}removeFromParent(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveFromParent))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[removeFromParent] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveFromParent,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];return this.parent.removeBreakStatement(this),e.push(this.parent),i==null||i.attemptAutoclose(_.RemoveFromParent,this.id),{added:D(c),updated:D(n),removed:D(s),affected:D(e),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveEntity))){var m,v,E;if(!this.checkCanDelete(this,n))return J.Logger.warn(`[remove] User is not allowed to delete or edit this ${this.type} entity with id: ${this.id}`),n==null||n.event({id:`${_.RemoveEntity}-${this.id}`,action:_.RemoveEntity,owner:this,errorReason:Ii.ActionOwnerEntityNonDeletable,rootAction:((m=n==null?void 0:n.self)==null?void 0:m.id)===this.id&&(n==null?void 0:n.autoCloseActionName)===_.RemoveEntity}),n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const s=[],c=[],e=[],y=[];if(n!=null&&n.hasRemoved(this.id))return n==null||n.attemptAutoclose(_.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},n),Object.values(this.detachedDependents).forEach(b=>{const{updated:w,removed:V,added:$}=b.entity.onDetachedDependencyRemoved(this,b.field,n);s.push(...w),c.push(...V),e.push(...$)}),this.readsValue&&(s.push(this.readsValue),this.readsValue.removeValueReader(this,n)),this.outputs.forEach(b=>{const{updated:w,removed:V}=b.remove({ignoreUpstream:!0},n);s.push(...w),c.push(...V)}),this.throws){const{updated:b,removed:w}=this.throws.remove({ignoreUpstream:!0},n);s.push(...b),c.push(...w)}if(this.dataType){const{updated:b,removed:w}=this.dataType.remove({ignoreUpstream:!0},n);s.push(...b),c.push(...w)}if(!i){const b=this.removeFromParent(n);e.push(...b.added),s.push(...b.updated),c.push(...b.removed),y.push(...b.affected),this.calledBy.forEach(w=>{s.push(w),w.removeCall(this,n)})}return n==null||n.add(this.parent,H.Affected),(v=this.parent)==null||v.breakStatements.forEach(b=>{b.id!==this.id&&(y.push(b),n==null||n.add(b,H.Affected))}),(E=this.parent)==null||E.continueStatements.forEach(b=>{b.id!==this.id&&(y.push(b),n==null||n.add(b,H.Affected))}),n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:D(e),updated:D(s),removed:D(c),affected:D(y),self:this}}restore({}={},i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RestoreEntity))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[restore] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];if(i!=null&&i.hasAdded(this.id))return i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},i),Object.values(this.detachedDependents).forEach(y=>{const{updated:m,removed:v,added:E}=y.entity.onDetachedDependencyRestored(this,y.field,i);s.push(...m),c.push(...v),n.push(...E)}),this.readsValue&&(s.push(this.readsValue),this.readsValue.addValueReader(this,i)),this.outputs.forEach(y=>{const{updated:m}=y.restore({},i);s.push(...m)}),this.throws){const{updated:y}=this.throws.restore({},i);s.push(...y)}if(this.dataType){const{updated:y}=this.dataType.restore({},i);s.push(...y)}return this.parent.addBreakStatement(this),this.calledBySuccess.forEach(y=>{s.push(y),y.addSuccessCall(this,i)}),this.calledByError.forEach(y=>{s.push(y),y.addErrorCall(this,i)}),this.calledByEntry.forEach(y=>{s.push(y),y.addCall(this,i)}),i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this}}toFlat(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this,...this.outputs.flatMap(s=>s.toFlat(i)),...this.throws?this.throws.toFlat(i):[],...this.dataType?this.dataType.toFlat(i):[]])}toFlatIds(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.outputs.flatMap(s=>s.toFlatIds(i)),...this.throws?this.throws.toFlatIds(i):[],...this.dataType?this.dataType.toFlatIds(i):[]])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,x:this.x,y:this.y,type:this.type,editable:this.editable,deletable:this.deletable}}toJSON(i=new Set){var n,s,c,e,y;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,x:this.x,y:this.y,defaultValue:((n=this.defaultValue)==null?void 0:n.toJSON(i))||null,dataType:((s=this.dataType)==null?void 0:s.toJSON(i))||null,readsValue:((c=this.readsValue)==null?void 0:c.toReference())||null,outputs:this.outputs.map(m=>m.toJSON(i)),calledBySuccess:this.calledBySuccess.map(m=>m.toReference()),calledByError:this.calledByError.map(m=>m.toReference()),calledByEntry:this.calledByEntry.map(m=>m.toReference()),parent:((e=this.parent)==null?void 0:e.toReference())||null,throws:((y=this.throws)==null?void 0:y.toJSON(i))||null})}toJSONClone(i=ct){var s,c,e,y,m,v,E,b,w,V;let n;return(s=i.seenEntityMaps)!=null&&s.has(this.id)?n=i.seenEntityMaps.get(this.id):(n=i.newId||jr(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,n)),(c=i.seenEntities)!=null&&c.has(n)||(e=i.seenEntities)!=null&&e.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((y=i.seenEntities)==null||y.add(n),(m=i.seenEntities)==null||m.add(this.id),{id:n,version:x.UUID.uuid(),createdAt:i.timestamp||M().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,x:this.x,y:this.y,defaultValue:((v=this.defaultValue)==null?void 0:v.toJSONClone({...i,newId:null}))||null,dataType:((E=this.dataType)==null?void 0:E.toJSONClone({...i,newId:null}))||null,readsValue:((b=this.readsValue)==null?void 0:b.toReference({seenEntityMaps:i.seenEntityMaps}))||null,outputs:this.outputs.map($=>$.toJSONClone({...i,newId:null})),calledBySuccess:this.calledBySuccess.map($=>$.toReference({seenEntityMaps:i.seenEntityMaps})),calledByError:this.calledByError.map($=>$.toReference({seenEntityMaps:i.seenEntityMaps})),calledByEntry:this.calledByEntry.map($=>$.toReference({seenEntityMaps:i.seenEntityMaps})),parent:((w=this.parent)==null?void 0:w.toReference({seenEntityMaps:i.seenEntityMaps}))||null,throws:((V=this.throws)==null?void 0:V.toJSONClone({...i,newId:null}))||null})}toReference(i=ct){var s;let n=this.id;return(s=i.seenEntityMaps)!=null&&s.has(this.id)&&(n=i.seenEntityMaps.get(this.id)),{id:n+"--"+x.UUID.uuid()+"--ref",type:d.GenericReference,entityId:n,version:this.version,entityType:this.type}}toShallowJSON(i=ct){var s,c,e,y,m,v;let n=this.id;return(s=i.seenEntityMaps)!=null&&s.has(this.id)&&(n=i.seenEntityMaps.get(this.id)),{id:n,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,x:this.x,y:this.y,defaultValue:((c=this.defaultValue)==null?void 0:c.toReference(i))||null,dataType:((e=this.dataType)==null?void 0:e.toReference(i))||null,readsValue:((y=this.readsValue)==null?void 0:y.toReference(i))||null,outputs:this.outputs.map(E=>E.toReference(i)),calledBySuccess:this.calledBySuccess.map(E=>E.toReference(i)),calledByError:this.calledByError.map(E=>E.toReference(i)),calledByEntry:this.calledByEntry.map(E=>E.toReference(i)),throws:((m=this.throws)==null?void 0:m.toReference(i))||null,parent:((v=this.parent)==null?void 0:v.toReference(i))||null}}toFlatJSON(i=new Set){var s,c;return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...((s=this.defaultValue)==null?void 0:s.toFlatJSON(i))||[],...((c=this.dataType)==null?void 0:c.toFlatJSON(i))||[],...this.outputs.flatMap(e=>e.toFlatJSON(i)),...this.throws?this.throws.toFlatJSON(i):[]])}toGenerationTarget(){return{id:this.id,type:this.type,calledByEntry:this.calledByEntry.map(i=>i.id),calledByError:this.calledByError.map(i=>i.id),calledBySuccess:this.calledBySuccess.map(i=>i.id),parent:this.parent.id}}toFlatGenerationTarget(i=new Set){var s,c;return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...((s=this.defaultValue)==null?void 0:s.toFlatGenerationTarget(i))||[],...((c=this.dataType)==null?void 0:c.toFlatGenerationTarget(i))||[],...this.outputs.flatMap(e=>e.toFlatGenerationTarget(i)),...this.throws?this.throws.toFlatGenerationTarget(i):[]])}clearErrors(){var i,n,s;return this.errors=[],(i=this.dataType)==null||i.clearErrors(),(n=this.defaultValue)==null||n.clearErrors(),this.outputs.forEach(c=>c.clearErrors()),(s=this.throws)==null||s.clearErrors(),this}validate(){return this.errors=OMe(this),{success:!0}}async validateAsync(i={}){const n=J.YieldTracker.from(i);return this.errors=await wMe(this,{tracker:n}),{success:!0}}getErrors(){var n,s;return[...this.errors,...((n=this.defaultValue)==null?void 0:n.getErrors())||[],...((s=this.dataType)==null?void 0:s.getErrors())||[],...this.outputs.flatMap(c=>c.getErrors()),...this.throws?this.throws.getErrors():[]]}async getErrorsAsync(i={}){const n=J.YieldTracker.from(i),s=[...this.errors];if(await n.tick(),this.defaultValue){const c=await this.defaultValue.getErrorsAsync({tracker:n});s.push(...c)}if(this.dataType){const c=await this.dataType.getErrorsAsync({tracker:n});s.push(...c)}for(const c of this.outputs){const e=await c.getErrorsAsync({tracker:n});s.push(...e)}if(this.throws){const c=await this.throws.getErrorsAsync({tracker:n});s.push(...c)}return s}getShallowErrors(){return this.errors}getDefaultValue(){return this.defaultValue||null}setDefaultValue(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"set-default-value"))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setDefaultValue] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("set-default-value",this.id),this;const s=this.defaultValue;if((s==null?void 0:s.id)!==(i==null?void 0:i.id)){if(s==null||s.remove({ignoreUpstream:!0},n),this.defaultValue=i,this.defaultValue){const c=this.readsValue;this.removeValueWriter(n),c==null||c.removeValueReader(this,n)}n==null||n.add(this,H.Affected)}return n==null||n.attemptAutoclose("set-default-value",this.id),this}clone(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.CloneEntity)),n=null,s=null,c=!0){var L,k,K;const e=Rr(n,this),y=this.toJSON(),m=s||x.UUID.uuid();y.outputs=[];const v=m.split("-id"),E=v[v.length-1||0]||m;y.id=m,y.version=x.UUID.uuid(),y.createdAt=(i==null?void 0:i.timestamp)||M().toISOString(),y.author=(i==null?void 0:i.author)||"1",y.previousVersion=null,y.deleted=!1,y.deletable=!0,y.editable=!0;const b=Si(y,e);n?b.setParent(n,i):b.setParent(this.parent,null),c&&b.subscribe(),b.initChildren(i),i==null||i.add(b,H.Added);const w=(L=this.dataType)==null?void 0:L.clone(i,b,x.UUID.uuid(),c);b.setDataType(w||null,i);const V=(k=this.defaultValue)==null?void 0:k.clone(i,b,x.UUID.uuid(),c);b.setDefaultValue(V||null,i);const $=(K=this.outputs)==null?void 0:K.map((S,Y)=>S.clone(i,b,E+"-return-declaration-"+Y+"-id",c));return b.outputs=$,this.throws&&(b.throws=this.throws.clone(i,b,E+"-throws-id",c)),i==null||i.attemptAutoclose(_.CloneEntity,this.id),b}getMasterInputWithValueWritterFromAllInstances(i){return D([...this.outputs,...this.parent.breakStatements.filter(c=>c.id!==this.id).flatMap(c=>c.outputs),...this.parent.continueStatements.flatMap(c=>c.outputs)]).find(c=>se(c,this.project)===se(i,this.project)&&!!c.readsValue)||i}syncInputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"sync-break-statement-inputs"))){const n=[],s=[],c=[],e=[],y=this.getDataType(i);if(y)if(y.entity){if(y.isObject()){const m=[...y.entity.properties];this.outputs.filter(b=>!b.declaration||!m.find(w=>{var V;return w.id===((V=b.declaration)==null?void 0:V.id)})).forEach(b=>{const w=m.find(V=>se(V,this.project)===se(b,this.project));w&&b.setDeclaration(w,i)}),m.filter(b=>!this.outputs.find(w=>{var V;return((V=w.declaration)==null?void 0:V.id)===b.id})).forEach(b=>{const w={dataType:null,id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||M().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.InputMap,parentRelationType:null,parent:this.toReference(),name:null,description:null,codeName:null,declaration:b,defaultValue:null,index:b.index,readsValue:null},V=me(w,this.project);return V.hydrateAncestors(),i==null||i.add(V,H.Added),V.setParent(this,i),V.initChildren(i),this.addOutput(V,i),V})}}else return i==null||i.attemptAutoclose("sync-break-statement-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};else return i==null||i.attemptAutoclose("sync-break-statement-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};return i==null||i.attemptAutoclose("sync-break-statement-inputs",this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this}}setDataType(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetDataType))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setDataType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.SetDataType,this.id),this;const s=this.dataType;return(s==null?void 0:s.id)!==(i==null?void 0:i.id)&&(s==null||s.remove({ignoreUpstream:!0},n),this.dataType=i,this.subscribeToDependencies(),n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose(_.SetDataType,this.id),this}removeDataType(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveDataType))){return this.checkCanEdit(this,i)?(this.dataType&&(this.dataType.remove({ignoreUpstream:!0},i),i==null||i.add(this,H.Affected),this.dataType=null),i==null||i.attemptAutoclose(_.RemoveDataType,this.id),this):(J.Logger.warn(`[removeDataType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveDataType,this.id),this)}getDataType(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"get-data-type"))){if((!this.dataType||this.dataType.inferred)&&this.project.initialized,this.dataType)return i==null||i.attemptAutoclose("get-data-type",this.id),this.dataType;const n=this.parent.getDataType(i);return n?(i==null||i.attemptAutoclose("get-data-type",this.id),n):(i==null||i.attemptAutoclose("get-data-type",this.id),null)}};I(Vi,"repository",{APICreate:async(i,...n)=>i,APIUpdate:async(i,...n)=>i,APIDelete:async(i,...n)=>i,APIClone:async(i,...n)=>{},APILoad:async(i,...n)=>null,APILoadVersion:async(i,n,...s)=>null}),I(Vi,"type",d.BreakStatement),I(Vi,"USER_MANAGED_PARENT_TYPES",[d.Loop]),I(Vi,"PARENT_TYPES",[...Vi.USER_MANAGED_PARENT_TYPES]),I(Vi,"MUTABLE_BASE_PROPERTIES",[]),I(Vi,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),I(Vi,"BASE_PROPERTIES",[...Vi.MUTABLE_BASE_PROPERTIES,...Vi.INMUTABLE_BASE_PROPERTIES]),I(Vi,"MUTABLE_META_PROPERTIES",["x","y"]),I(Vi,"INMUTABLE_META_PROPERTIES",[...Vi.INMUTABLE_BASE_PROPERTIES]),I(Vi,"META_PROPERTIES",[...Vi.MUTABLE_META_PROPERTIES,...Vi.INMUTABLE_META_PROPERTIES]),I(Vi,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry","readsValue"]),I(Vi,"INMUTABLE_UPSTREAM_PROPERTIES",["parent"]),I(Vi,"UPSTREAM_PROPERTIES",[...Vi.MUTABLE_UPSTREAM_PROPERTIES,...Vi.INMUTABLE_UPSTREAM_PROPERTIES]),I(Vi,"MUTABLE_DOWNSTREAM_PROPERTIES",["outputs","throws"]),I(Vi,"INMUTABLE_DOWNSTREAM_PROPERTIES",["dataType","defaultValue"]),I(Vi,"DOWNSTREAM_PROPERTIES",[...Vi.MUTABLE_DOWNSTREAM_PROPERTIES,...Vi.INMUTABLE_DOWNSTREAM_PROPERTIES]),I(Vi,"PROPERTIES",[...Vi.META_PROPERTIES,...Vi.UPSTREAM_PROPERTIES,...Vi.DOWNSTREAM_PROPERTIES]);let Ku=Vi;async function _Me(o,p={}){var c;const i=J.YieldTracker.from(p),n=[];await i.tick();const s=Mt(o.errors,n);for(const e of o.outputs)await e.validateAsync({tracker:i});return await((c=o.throws)==null?void 0:c.validateAsync({tracker:i})),s}function VMe(o){var i;o.outputs.forEach(n=>n.validate()),(i=o.throws)==null||i.validate();const p=[];return Mt(o.errors,p)}const cIi=Object.freeze(Object.defineProperty({__proto__:null,validate:VMe,validateAsync:_Me},Symbol.toStringTag,{value:"Module"}));var PMe=(o=>(o.Parent="continue-statement-parent-field",o.DataTypeEntity="continue-statement-data-type-entity-field",o.DataType="continue-statement-data-type-field",o.ParentDataType="continue-statement-parent-data-type-field",o.ParentDataTypeEntity="continue-statement-parent-data-type-entity-field",o))(PMe||{});const Pi=class Pi extends Ur{constructor(i,n){super(i);I(this,"initialData");I(this,"id");I(this,"x");I(this,"y");I(this,"type",d.ContinueStatement);I(this,"outputs",[]);I(this,"readsValue",null);I(this,"dataType",null);I(this,"defaultValue",null);I(this,"calledBySuccess",[]);I(this,"calledByError",[]);I(this,"calledByEntry",[]);I(this,"throws",null);I(this,"project");I(this,"errors",[]);I(this,"parent");I(this,"detachedDependents",{});I(this,"knownVersions",null);I(this,"activeVersion",!1);I(this,"initialized",!1);I(this,"startedInitialization",!1);I(this,"suggestion",!1);I(this,"_codeNativeValueValidation",null);this.initialData=i,this.project=n,this.id=i.id,this.x=i.x,this.y=i.y}static new(i=null){return{id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||M().toISOString(),author:(i==null?void 0:i.author)||x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.ContinueStatement,outputs:[],defaultValue:null,dataType:null,readsValue:null,throws:null,parent:null,calledByEntry:[],calledBySuccess:[],calledByError:[],x:0,y:0}}static fromGenerationTarget(i,n){const s=ne(i.parent),c=n.get(s),e=i.calledByEntry.map(w=>{const V=ne(w);return n.get(V)}),y=i.calledBySuccess.map(w=>{const V=ne(w);return n.get(V)}),m=i.calledByError.map(w=>{const V=ne(w);return n.get(V)});let v=null;if(i.readsValue){const w=ne(i.readsValue);v=n.get(w)}const E={id:i.id,version:x.UUID.uuid(),createdAt:M().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.ContinueStatement,x:0,y:0,outputs:[],defaultValue:null,dataType:null,readsValue:v,calledBySuccess:y,calledByError:m,calledByEntry:e,throws:null,parent:c},b=me(E,n);return b.setParent(c,null),b}static validateGenerationTarget(i,n){let s=JSON.parse(JSON.stringify(i));const c=[],e=bn(s,{parent:{list:!1,types:[d.Loop]}},n);return s=e.modifiedData,c.push(...e.errors,...$r(s)),{errors:c,modifiedData:s}}get codeNativeValueValidation(){return this._codeNativeValueValidation||null}validateGeneratedUpdate(i){const n=[];let s=JSON.parse(JSON.stringify(i));const c=sf(s,this);return s=c.modifiedData,n.push(...c.errors),i.parent&&n.push(new De({id:`${this.id}--${ae.InvalidParentUpdate}`,code:ae.InvalidParentUpdate,severity:ce.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated. The 'parent' on a callable entity, is its scope. It scope is auto-calculated implicitly by the its caller.
|
|
178
178
|
If an entity is called by another, they must be in the same scope, which means they have the same parent.
|
|
179
179
|
You shouldn't have to manually update a 'parent' property.
|
|
180
|
-
Specifically for continue statements the parent needs to always be the 'loop' entity that contains it.`})),{errors:n,modifiedData:i}}subscribeDependents(i){return i.forEach(n=>{this.detachedDependents[n.entity.id]||(this.detachedDependents[n.entity.id]=n)}),this}unsubscribeDependents(i){return i.forEach(n=>{this.detachedDependents[n.entity.id]&&delete this.detachedDependents[n.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"sync-dependents"))){const n=[],s=[],c=[],e=[];return Object.values(this.detachedDependents).forEach(y=>{const m=y.entity.afterAllChildrenInitialized(i);n.push(...m.updated),s.push(...m.added),c.push(...m.removed),e.push(...m.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}onDetachedDependencyRemoved(i,n,s){const c=[],e=[],y=[],m=[];if(n==="continue-statement-parent-field"){const{updated:v,added:E,removed:b}=this.remove({ignoreUpstream:!1},s);c.push(...v),e.push(...E),y.push(...b)}if(n==="continue-statement-parent-data-type-field"){const{updated:v,added:E,removed:b}=this.afterAllChildrenInitialized(s);c.push(...v),e.push(...E),y.push(...b)}if(n==="continue-statement-parent-data-type-entity-field"){const{updated:v,added:E,removed:b}=this.afterAllChildrenInitialized(s);c.push(...v),e.push(...E),y.push(...b)}return{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:this}}onDetachedDependencyRestored(i,n,s){const c=[],e=[],y=[],m=[];if(n==="continue-statement-parent-field"){const{updated:v,added:E,removed:b}=this.restore({},s);c.push(...v),e.push(...E),y.push(...b)}if(n==="continue-statement-parent-data-type-field"){const{updated:v,added:E,removed:b}=this.afterAllChildrenInitialized(s);c.push(...v),e.push(...E),y.push(...b)}if(n==="continue-statement-parent-data-type-entity-field"){const{updated:v,added:E,removed:b}=this.afterAllChildrenInitialized(s);c.push(...v),e.push(...E),y.push(...b)}return{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:this}}unsubscribeFromDependencies(){var i,n,s,c,e,y,m,v,E,b,w,V,$;return(i=this.parent)==null||i.unsubscribeDependents([{entity:this,field:"continue-statement-parent-field"}]),(c=(s=(n=this.dataType)==null?void 0:n.entity)==null?void 0:s.unsubscribeDependents)==null||c.call(s,[{entity:this,field:"continue-statement-data-type-entity-field"}]),(y=(e=this.dataType)==null?void 0:e.unsubscribeDependents)==null||y.call(e,[{entity:this,field:"continue-statement-data-type-field"}]),(b=(E=(v=(m=this.parent)==null?void 0:m.dataType)==null?void 0:v.entity)==null?void 0:E.unsubscribeDependents)==null||b.call(E,[{entity:this,field:"continue-statement-parent-data-type-entity-field"}]),($=(V=(w=this.parent)==null?void 0:w.dataType)==null?void 0:V.unsubscribeDependents)==null||$.call(V,[{entity:this,field:"continue-statement-parent-data-type-field"}]),this}subscribeToDependencies(){var i,n,s,c,e,y,m,v,E,b,w,V,$;return(i=this.parent)==null||i.subscribeDependents([{entity:this,field:"continue-statement-parent-field"}]),(c=(s=(n=this.dataType)==null?void 0:n.entity)==null?void 0:s.subscribeDependents)==null||c.call(s,[{entity:this,field:"continue-statement-data-type-entity-field"}]),(y=(e=this.dataType)==null?void 0:e.subscribeDependents)==null||y.call(e,[{entity:this,field:"continue-statement-data-type-field"}]),(b=(E=(v=(m=this.parent)==null?void 0:m.dataType)==null?void 0:v.entity)==null?void 0:E.subscribeDependents)==null||b.call(E,[{entity:this,field:"continue-statement-parent-data-type-entity-field"}]),($=(V=(w=this.parent)==null?void 0:w.dataType)==null?void 0:V.subscribeDependents)==null||$.call(V,[{entity:this,field:"continue-statement-parent-data-type-field"}]),this}increaseVersion(i){if(i&&!M(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&M(i).isSame(M(this.createdAt))?this:(this.previousVersion=this.version,this.version=x.UUID.uuid(),this.createdAt=M(i).toISOString()||M().toISOString(),this)}captureVersion(){var n;const i=((n=this.knownVersions)==null?void 0:n.get(this.version))||new Pi(this,this.project);return i.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map([[this.version,i]]),i.outputs=[...this.outputs],i.readsValue=this.readsValue,i.defaultValue=this.defaultValue,i.dataType=this.dataType,i.throws=this.throws,i.calledBySuccess=[...this.calledBySuccess],i.calledByError=[...this.calledByError],i.calledByEntry=[...this.calledByEntry],i.parent=this.parent,this}recursiveCaptureUpstreamVersions(i){const n=[],s=[],c=[],e=[];if(this.parent){this.parent.increaseVersion(i);const y=this.parent.recursiveCaptureUpstreamVersions(i);n.push(this.parent,...y.updated),s.push(...y.added),c.push(...y.removed)}return{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}async restoreVersion(i){var m;const n=[],s=[],c=[],e=[];if(this.version===i)return{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this};if(!this.knownVersions){const v=new Map;for(const[E,b]of this.knownVersions||new Map){if(v.set(E,b),b.activeVersion=!1,b.knownVersions)for(const[w,V]of b.knownVersions)v.set(w,V);b.knownVersions=null}}let y=(m=this.knownVersions)==null?void 0:m.get(i);if(!y){const v=await this.APILoadVersion({},i);if(!v)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);y=new Pi(v,this.project)}return this.metaSync(y.toShallowJSON(),null),this.previousVersion=y.previousVersion,this.version=y.version,this.createdAt=y.createdAt,this.author=y.author,this.deleted=y.deleted,this.outputs=y.outputs,this.readsValue=y.readsValue,this.defaultValue=y.defaultValue,this.dataType=y.dataType,this.throws=y.throws,this.calledBySuccess=y.calledBySuccess,this.calledByError=y.calledByError,this.calledByEntry=y.calledByEntry,this.parent=y.parent,{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}updateWithShallowTransfer(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.UpdateWithShallowTransfer))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[updateWithShallowTransfer] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),this;if(this.metaSync(i,n),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 s=ne(i.parent),c=this.project.get(s),e=this.parent;if(e&&e.id!==(c==null?void 0:c.id)&&this.removeFromParent(n),c)this.setParent(c,n),this.addSelfToProject(n);else throw n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${s}' that isn't found in the project`)}else throw n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(i.readsValue){const s=ne(i.readsValue),c=this.project.get(s),e=this.readsValue;e&&e.id!==(c==null?void 0:c.id)&&this.removeValueWriter(n),c&&this.setValueWriter(c,n)}else this.removeValueWriter(n);if(i.calledByEntry.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addEntryCaller(e,n),e.addCall(this,n))}),[...this.calledByEntry].forEach(s=>{i.calledByEntry.find(e=>ne(e)===s.id)||(this.removeCaller(s,n),s.removeCall(this,n))}),i.calledBySuccess.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addSuccessCaller(e,n),e.addSuccessCall(this,n))}),[...this.calledBySuccess].forEach(s=>{i.calledBySuccess.find(e=>ne(e)===s.id)||(this.removeCaller(s,n),s.removeCall(this,n))}),i.calledByError.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addErrorCaller(e,n),e.addErrorCall(this,n))}),[...this.calledByError].forEach(s=>{i.calledByError.find(e=>ne(e)===s.id)||(this.removeCaller(s,n),s.removeCall(this,n))}),i.outputs.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addOutput(e,n),e.setParent(this,n))}),[...this.outputs].forEach(s=>{i.outputs.find(e=>ne(e)===s.id)||(this.removeOutput(s,n),s.removeFromParent(n))}),i.dataType){const s=ne(i.dataType),c=this.project.get(s);c&&this.setDataType(c,n)}else this.setDataType(null,n);if(i.defaultValue){const s=ne(i.defaultValue),c=this.project.get(s);c&&this.setDefaultValue(c,n)}else this.setDefaultValue(null,n);return this.captureVersion(),this.subscribeToDependencies(),n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),this}hydrateAncestors(){const i=[],n=[],s=[],c=[];if(this.initialData.parent){const e=ne(this.initialData.parent),y=this.project.get(e);if(y)this.setParent(y,null),i.push(y);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.readsValue){const e=ne(this.initialData.readsValue),y=this.project.get(e);y&&(this.setValueWriter(y,null),i.push(y))}return this.initialData.calledByEntry.forEach(e=>{const y=ne(e),m=this.project.get(y);m&&this.addEntryCaller(m,null)}),this.initialData.calledBySuccess.forEach(e=>{const y=ne(e),m=this.project.get(y);m&&this.addSuccessCaller(m,null)}),this.initialData.calledByError.forEach(e=>{const y=ne(e),m=this.project.get(y);m&&this.addErrorCaller(m,null)}),{updated:D(i),added:D(n),removed:D(s),affected:D(c),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AfterAllChildrenInitialized))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[afterAllChildrenInitialized] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.AfterAllChildrenInitialized,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];this.initialized=!0,!this.dataType||this.dataType.inferred;const{added:y,updated:m,removed:v,affected:E}=this.syncInputs(i);return s.push(...y),n.push(...m),c.push(...v),e.push(...E),this.parent.syncTerminationStatements(i),this.outputs.sort((b,w)=>{var V,$;return(b.index??((V=b.declaration)==null?void 0:V.index))-(w.index??(($=w.declaration)==null?void 0:$.index))}),this.captureVersion(),i==null||i.attemptAutoclose(_.AfterAllChildrenInitialized,this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}addSelfToProject(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"add-self-to-project"))){var y,m;const n=[this],s=[],c=[],e=[];return this.readsValue&&(this.readsValue.addValueReader(this,i),n.push(this.readsValue)),this.calledByEntry.forEach(v=>{v.addCall(this,i),n.push(v)}),this.calledBySuccess.forEach(v=>{v.addSuccessCall(this,i),n.push(v)}),this.calledByError.forEach(v=>{v.addErrorCall(this,i),n.push(v)}),this.parent.addContinueStatement(this),n.push(this),i==null||i.add(this.parent,H.Affected),(y=this.parent)==null||y.breakStatements.forEach(v=>{v.id!==this.id&&(e.push(v),i==null||i.add(v,H.Affected))}),(m=this.parent)==null||m.continueStatements.forEach(v=>{v.id!==this.id&&(e.push(v),i==null||i.add(v,H.Affected))}),this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}addSuccessCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddSuccessCaller)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddSuccessCaller,n)?(this.calledBySuccess.find(c=>c.id===i.id)||(this.calledBySuccess.push(i),n==null||n.add(this,H.Updated),s&&mt(this,n)),n==null||n.attemptAutoclose(_.AddSuccessCaller,this.id),this):this}addErrorCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddErrorCaller)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddErrorCaller,n)?(this.calledByError.find(c=>c.id===i.id)||(this.calledByError.push(i),n==null||n.add(this,H.Updated),s&&mt(this,n)),n==null||n.attemptAutoclose(_.AddErrorCaller,this.id),this):this}addEntryCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddEntryCaller)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddEntryCaller,n)?(this.calledByEntry.find(c=>c.id===i.id)||(this.calledByEntry.push(i),n==null||n.add(this,H.Updated),s&&mt(this,n)),n==null||n.attemptAutoclose(_.AddEntryCaller,this.id),this):this}removeCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-caller")),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.RemoveCaller,n)?(this.calledBySuccess=this.calledBySuccess.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),this.calledByError=this.calledByError.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),this.calledByEntry=this.calledByEntry.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),s&&mt(this,n),n==null||n.attemptAutoclose(_.RemoveCaller,this.id),this):this}setThrows(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"set-throws"))){var s;if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setThrows] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("set-throws",this.id),this;if(i!==null&&i.parentRelationType!==vd.Error)throw new Error("The 'throws' InputMap must have a parentRelationType of 'Error'.");return((s=this.throws)==null?void 0:s.id)!==(i==null?void 0:i.id)&&(this.throws=i,n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose("set-throws",this.id),this}addOutput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"add-output"))){return this.checkCanEdit(this,n)?this.outputs.includes(i)?(n==null||n.attemptAutoclose("add-output",this.id),this):(this.outputs.push(i),n==null||n.add(this,H.Affected),n==null||n.attemptAutoclose("add-output",this.id),this):(J.Logger.warn(`[addOutput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("add-output",this.id),this)}removeOutput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-output"))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[removeOutput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("remove-output",this.id),this;const s=this.outputs.findIndex(c=>c.id===i.id);return s>-1&&(this.outputs.splice(s,1),n&&(n==null||n.add(this,H.Affected))),n==null||n.attemptAutoclose("remove-output",this.id),this}setParent(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetParent))){var s;return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.SetParent,n)?(((s=this.parent)==null?void 0:s.id)!==(i==null?void 0:i.id)&&(this.parent=i,n&&(n==null||n.add(this,H.Updated))),n==null||n.attemptAutoclose(_.SetParent,this.id),this):this}setValueWriter(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetValueWriter))){return this.checkCanEditFromScopeOwnerWithSideEffects(this,_.SetValueWriter,n)?(this.readsValue!==i&&(this.readsValue=i,n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose(_.SetValueWriter,this.id),this):this}removeValueWriter(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveValueWriter))){return this.readsValue&&!this.checkCanEditWithCounterpartAndSideEffects(this,this.readsValue,_.RemoveValueWriter,i)?this:(this.readsValue&&(this.readsValue=null,i==null||i.add(this,H.Updated)),i==null||i.attemptAutoclose(_.RemoveValueWriter,this.id),this)}initChildren(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"init-children"))){return this.initialized||this.startedInitialization?this:(this.startedInitialization=!0,this.initialData.defaultValue&&(this.defaultValue=me(this.initialData.defaultValue,this.project),this.defaultValue.setParent(this,null),this.defaultValue.initChildren(i)),this.initialData.dataType&&(this.dataType=me(this.initialData.dataType,this.project),this.dataType.setParent(this,null),this.dataType.initChildren(i)),lf.initReadsValue(this),this.outputs=this.initialData.outputs.map(n=>{const s=me(n,this.project);return s.setParent(this,null),s.initChildren(i),s}),this.initialData.throws&&(this.throws=me(this.initialData.throws,this.project),this.throws.setParent(this,null),this.throws.initChildren(i)),this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this)}subscribe(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"meta-sync"))){const s=Mr(this,i,n),c=Lr(this,s),e=this.toMeta();return this.x=s.x||e.x,this.y=s.y||e.y,super.baseMetaSync(s,this,n),s.deleted===!0&&!e.deleted?n==null||n.add(this,H.Removed):s.deleted===!1&&e.deleted?n==null||n.add(this,H.Added):c&&(n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=ke,...n){return await Pi.repository.APILoad(this.id,...n),this}async APICreate(i=ke,...n){return await Pi.repository.APICreate(this.toShallowJSON(),...n),this}async APIUpdate(i=ke,...n){return await Pi.repository.APIUpdate(this.toShallowJSON(),...n),this}async APIDelete(i=ke,...n){return await Pi.repository.APIDelete(this.toShallowJSON(),...n),this}async APIClone(i=ke,...n){return await Pi.repository.APIClone(this.id,...n),this}async APILoadVersion(i=ke,n,...s){return await Pi.repository.APILoadVersion(this.id,n,...s)}removeFromParent(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveFromParent))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[removeFromParent] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveFromParent,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];return this.parent.removeContinueStatement(this),this.parent.detachedChildren.includes(this)&&this.parent.unsubscribeDetachedChild(this),i==null||i.attemptAutoclose(_.RemoveFromParent,this.id),{added:D(c),updated:D(n),removed:D(s),affected:D(e),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveEntity))){var m,v,E;if(!this.checkCanDelete(this,n))return J.Logger.warn(`[remove] User is not allowed to delete or edit this ${this.type} entity with id: ${this.id}`),n==null||n.event({id:`${_.RemoveEntity}-${this.id}`,action:_.RemoveEntity,owner:this,errorReason:Ii.ActionOwnerEntityNonDeletable,rootAction:((m=n==null?void 0:n.self)==null?void 0:m.id)===this.id&&(n==null?void 0:n.autoCloseActionName)===_.RemoveEntity}),n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const s=[],c=[],e=[],y=[];if(n!=null&&n.hasRemoved(this.id))return n==null||n.attemptAutoclose(_.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},n),Object.values(this.detachedDependents).forEach(b=>{const{updated:w,removed:V,added:$}=b.entity.onDetachedDependencyRemoved(this,b.field,n);s.push(...w),c.push(...V),e.push(...$)}),this.readsValue&&(s.push(this.readsValue),this.readsValue.removeValueReader(this,n)),this.outputs.forEach(b=>{const{updated:w,removed:V}=b.remove({ignoreUpstream:!0},n);s.push(...w),c.push(...V)}),this.throws){const{updated:b,removed:w}=this.throws.remove({ignoreUpstream:!0},n);s.push(...b),c.push(...w)}if(this.dataType){const{updated:b,removed:w}=this.dataType.remove({ignoreUpstream:!0},n);s.push(...b),c.push(...w)}if(!i){const b=this.removeFromParent(n);e.push(...b.added),s.push(...b.updated),c.push(...b.removed),y.push(...b.affected),this.calledBy.forEach(w=>{s.push(w),w.removeCall(this,n)})}return n==null||n.add(this.parent,H.Affected),(v=this.parent)==null||v.breakStatements.forEach(b=>{b.id!==this.id&&(y.push(b),n==null||n.add(b,H.Affected))}),(E=this.parent)==null||E.continueStatements.forEach(b=>{b.id!==this.id&&(y.push(b),n==null||n.add(b,H.Affected))}),n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:D(e),updated:D(s),removed:D(c),affected:D(y),self:this}}restore({}={},i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RestoreEntity))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[restore] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];if(i!=null&&i.hasAdded(this.id))return i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},i),Object.values(this.detachedDependents).forEach(y=>{const{updated:m,removed:v,added:E}=y.entity.onDetachedDependencyRestored(this,y.field,i);s.push(...m),c.push(...v),n.push(...E)}),this.readsValue&&(s.push(this.readsValue),this.readsValue.addValueReader(this,i)),this.outputs.forEach(y=>{const{updated:m}=y.restore({},i);s.push(...m)}),this.throws){const{updated:y}=this.throws.restore({},i);s.push(...y)}if(this.dataType){const{updated:y}=this.dataType.restore({},i);s.push(...y)}return this.parent.addContinueStatement(this),this.calledBySuccess.forEach(y=>{s.push(y),y.addSuccessCall(this,i)}),this.calledByError.forEach(y=>{s.push(y),y.addErrorCall(this,i)}),this.calledByEntry.forEach(y=>{s.push(y),y.addCall(this,i)}),i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this}}toFlat(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this,...this.outputs.flatMap(s=>s.toFlat(i)),...this.calledBy.flatMap(s=>s.toFlat(i)),...this.throws?this.throws.toFlat(i):[],...this.dataType?this.dataType.toFlat(i):[]])}toFlatIds(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.outputs.flatMap(s=>s.toFlatIds(i)),...this.calledBy.flatMap(s=>s.toFlatIds(i)),...this.throws?this.throws.toFlatIds(i):[],...this.dataType?this.dataType.toFlatIds(i):[]])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,x:this.x,y:this.y,type:this.type,editable:this.editable,deletable:this.deletable}}toJSON(i=new Set){var n,s,c,e,y;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,x:this.x,y:this.y,defaultValue:((n=this.defaultValue)==null?void 0:n.toJSON(i))||null,dataType:((s=this.dataType)==null?void 0:s.toJSON(i))||null,readsValue:((c=this.readsValue)==null?void 0:c.toReference())||null,calledBySuccess:this.calledBySuccess.map(m=>m.toReference()),calledByError:this.calledByError.map(m=>m.toReference()),calledByEntry:this.calledByEntry.map(m=>m.toReference()),outputs:this.outputs.map(m=>m.toJSON(i)),throws:((e=this.throws)==null?void 0:e.toJSON(i))||null,parent:((y=this.parent)==null?void 0:y.toReference())||null})}toJSONClone(i=ct){var s,c,e,y,m,v,E,b,w,V;let n;return(s=i.seenEntityMaps)!=null&&s.has(this.id)?n=i.seenEntityMaps.get(this.id):(n=i.newId||jr(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,n)),(c=i.seenEntities)!=null&&c.has(n)||(e=i.seenEntities)!=null&&e.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((y=i.seenEntities)==null||y.add(n),(m=i.seenEntities)==null||m.add(this.id),{id:n,version:x.UUID.uuid(),createdAt:i.timestamp||M().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,x:this.x,y:this.y,defaultValue:((v=this.defaultValue)==null?void 0:v.toJSONClone({...i,newId:null}))||null,dataType:((E=this.dataType)==null?void 0:E.toJSONClone({...i,newId:null}))||null,readsValue:((b=this.readsValue)==null?void 0:b.toReference({seenEntityMaps:i.seenEntityMaps}))||null,calledBySuccess:this.calledBySuccess.map($=>$.toReference({seenEntityMaps:i.seenEntityMaps})),calledByError:this.calledByError.map($=>$.toReference({seenEntityMaps:i.seenEntityMaps})),calledByEntry:this.calledByEntry.map($=>$.toReference({seenEntityMaps:i.seenEntityMaps})),outputs:this.outputs.map($=>$.toJSONClone({...i,newId:null})),throws:((w=this.throws)==null?void 0:w.toJSONClone({...i,newId:null}))||null,parent:((V=this.parent)==null?void 0:V.toReference({seenEntityMaps:i.seenEntityMaps}))||null})}toReference(i=ct){var s;let n=this.id;return(s=i.seenEntityMaps)!=null&&s.has(this.id)&&(n=i.seenEntityMaps.get(this.id)),{id:n+"--"+x.UUID.uuid()+"--ref",type:d.GenericReference,entityId:n,version:this.version,entityType:this.type}}toShallowJSON(i=ct){var s,c,e,y,m;let n=this.id;return(s=i.seenEntityMaps)!=null&&s.has(this.id)&&(n=i.seenEntityMaps.get(this.id)),{id:n,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,x:this.x,y:this.y,defaultValue:((c=this.defaultValue)==null?void 0:c.toReference(i))||null,dataType:((e=this.dataType)==null?void 0:e.toReference(i))||null,readsValue:((y=this.readsValue)==null?void 0:y.toReference(i))||null,outputs:this.outputs.map(v=>v.toReference(i)),calledBySuccess:this.calledBySuccess.map(v=>v.toReference(i)),calledByError:this.calledByError.map(v=>v.toReference(i)),calledByEntry:this.calledByEntry.map(v=>v.toReference(i)),throws:((m=this.throws)==null?void 0:m.toReference(i))||null,parent:this.parent.toReference(i)}}toFlatJSON(i=new Set){var s,c,e;return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...((s=this.defaultValue)==null?void 0:s.toFlatJSON(i))||[],...((c=this.dataType)==null?void 0:c.toFlatJSON(i))||[],...this.outputs.flatMap(y=>y.toFlatJSON(i)),...this.calledBy.flatMap(y=>y.toFlatJSON(i)),...((e=this.throws)==null?void 0:e.toFlatJSON(i))||[]])}toGenerationTarget(){return{id:this.id,type:this.type,calledByEntry:this.calledByEntry.map(i=>i.id),calledByError:this.calledByError.map(i=>i.id),calledBySuccess:this.calledBySuccess.map(i=>i.id),parent:this.parent.id}}toFlatGenerationTarget(i=new Set){var s,c;return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...((s=this.defaultValue)==null?void 0:s.toFlatGenerationTarget(i))||[],...((c=this.dataType)==null?void 0:c.toFlatGenerationTarget(i))||[],...this.outputs.flatMap(e=>e.toFlatGenerationTarget(i)),...this.throws?this.throws.toFlatGenerationTarget(i):[]])}clearErrors(){var i,n,s;return this.errors=[],(i=this.dataType)==null||i.clearErrors(),(n=this.defaultValue)==null||n.clearErrors(),this.outputs.forEach(c=>c.clearErrors()),(s=this.throws)==null||s.clearErrors(),this}validate(){return this.errors=VMe(this),{success:!0}}async validateAsync(i={}){const n=J.YieldTracker.from(i);return this.errors=await _Me(this,{tracker:n}),{success:!0}}getErrors(){var n,s;return[...this.errors,...((n=this.defaultValue)==null?void 0:n.getErrors())||[],...((s=this.dataType)==null?void 0:s.getErrors())||[],...this.outputs.flatMap(c=>c.getErrors()),...this.throws?this.throws.getErrors():[]]}async getErrorsAsync(i={}){const n=J.YieldTracker.from(i),s=[...this.errors];if(await n.tick(),this.defaultValue){const c=await this.defaultValue.getErrorsAsync({tracker:n});s.push(...c)}if(this.dataType){const c=await this.dataType.getErrorsAsync({tracker:n});s.push(...c)}for(const c of this.outputs){const e=await c.getErrorsAsync({tracker:n});s.push(...e)}if(this.throws){const c=await this.throws.getErrorsAsync({tracker:n});s.push(...c)}return s}getShallowErrors(){return this.errors}getDefaultValue(){return this.defaultValue||null}setDefaultValue(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"set-default-value"))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setDefaultValue] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("set-default-value",this.id),this;const s=this.defaultValue;return(s==null?void 0:s.id)!==(i==null?void 0:i.id)&&(s==null||s.remove({ignoreUpstream:!0},n),this.defaultValue=i,n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose("set-default-value",this.id),this}clone(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.CloneEntity)),n=null,s=null,c=!0){var L,k,K;const e=Rr(n,this),y=this.toJSON(),m=s||x.UUID.uuid();y.outputs=[];const v=m.split("-id"),E=v[v.length-1||0]||m;y.id=m,y.version=x.UUID.uuid(),y.createdAt=(i==null?void 0:i.timestamp)||M().toISOString(),y.author=(i==null?void 0:i.author)||"1",y.previousVersion=null,y.deleted=!1,y.deletable=!0,y.editable=!0;const b=Si(y,e);n?b.setParent(n,i):b.setParent(this.parent,null),c&&b.subscribe(),b.initChildren(i),i==null||i.add(b,H.Added);const w=(L=this.dataType)==null?void 0:L.clone(i,b,x.UUID.uuid(),c);b.setDataType(w||null,i);const V=(k=this.defaultValue)==null?void 0:k.clone(i,b,x.UUID.uuid(),c);b.setDefaultValue(V||null,i);const $=(K=this.outputs)==null?void 0:K.map((S,Y)=>S.clone(i,b,E+"-return-declaration-"+Y+"-id",c));return b.outputs=$,this.throws&&(b.throws=this.throws.clone(i,b,E+"-throws-id",c)),i==null||i.attemptAutoclose(_.CloneEntity,this.id),b}getMasterInputWithValueWritterFromAllInstances(i){return D([...this.outputs,...this.parent.breakStatements.filter(c=>c.id!==this.id).flatMap(c=>c.outputs),...this.parent.continueStatements.flatMap(c=>c.outputs)]).find(c=>se(c,this.project)===se(i,this.project)&&!!c.readsValue)||i}syncInputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"sync-continue-statement-inputs"))){const n=[],s=[],c=[],e=[],y=this.getDataType(i);if(y)if(y.entity){if(y.isObject()){const m=[...y.entity.properties];this.outputs.filter(b=>!b.declaration||!m.find(w=>{var V;return w.id===((V=b.declaration)==null?void 0:V.id)})).forEach(b=>{const w=m.find(V=>se(V,this.project)===se(b,this.project));w&&b.setDeclaration(w,i)}),m.filter(b=>!this.outputs.find(w=>{var V;return((V=w.declaration)==null?void 0:V.id)===b.id})).forEach(b=>{const w={dataType:null,id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||M().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.InputMap,parentRelationType:null,parent:this.toReference(),name:null,description:null,codeName:null,declaration:b,defaultValue:null,index:b.index,readsValue:null},V=me(w,this.project);return V.hydrateAncestors(),i==null||i.add(V,H.Added),V.setParent(this,i),V.initChildren(i),this.addOutput(V,i),V})}}else return i==null||i.attemptAutoclose("sync-continue-statement-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};else return i==null||i.attemptAutoclose("sync-continue-statement-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};return i==null||i.attemptAutoclose("sync-continue-statement-inputs",this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this}}setDataType(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetDataType))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setDataType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.SetDataType,this.id),this;const s=this.dataType;return(s==null?void 0:s.id)!==(i==null?void 0:i.id)&&(s==null||s.remove({ignoreUpstream:!0},n),this.dataType=i,this.subscribeToDependencies(),n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose(_.SetDataType,this.id),this}removeDataType(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveDataType))){return this.checkCanEdit(this,i)?(this.dataType&&(this.dataType.remove({ignoreUpstream:!0},i),i==null||i.add(this,H.Affected),this.dataType=null),i==null||i.attemptAutoclose(_.RemoveDataType,this.id),this):(J.Logger.warn(`[removeDataType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveDataType,this.id),this)}getDataType(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"get-data-type"))){if((!this.dataType||this.dataType.inferred)&&this.project.initialized,this.dataType)return i==null||i.attemptAutoclose("get-data-type",this.id),this.dataType;const n=this.parent.getDataType(i);return n?(i==null||i.attemptAutoclose("get-data-type",this.id),n):(i==null||i.attemptAutoclose("get-data-type",this.id),null)}};I(Pi,"repository",{APICreate:async(i,...n)=>i,APIUpdate:async(i,...n)=>i,APIDelete:async(i,...n)=>i,APIClone:async(i,...n)=>{},APILoad:async(i,...n)=>null,APILoadVersion:async(i,n,...s)=>null}),I(Pi,"type",d.ContinueStatement),I(Pi,"USER_MANAGED_PARENT_TYPES",[d.Loop]),I(Pi,"PARENT_TYPES",[...Pi.USER_MANAGED_PARENT_TYPES]),I(Pi,"MUTABLE_BASE_PROPERTIES",[]),I(Pi,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),I(Pi,"BASE_PROPERTIES",[...Pi.MUTABLE_BASE_PROPERTIES,...Pi.INMUTABLE_BASE_PROPERTIES]),I(Pi,"MUTABLE_META_PROPERTIES",["x","y"]),I(Pi,"INMUTABLE_META_PROPERTIES",[...Pi.INMUTABLE_BASE_PROPERTIES]),I(Pi,"META_PROPERTIES",[...Pi.MUTABLE_META_PROPERTIES,...Pi.INMUTABLE_META_PROPERTIES]),I(Pi,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry","readsValue"]),I(Pi,"INMUTABLE_UPSTREAM_PROPERTIES",["parent"]),I(Pi,"UPSTREAM_PROPERTIES",[...Pi.MUTABLE_UPSTREAM_PROPERTIES,...Pi.INMUTABLE_UPSTREAM_PROPERTIES]),I(Pi,"MUTABLE_DOWNSTREAM_PROPERTIES",["outputs","throws"]),I(Pi,"INMUTABLE_DOWNSTREAM_PROPERTIES",["dataType","defaultValue"]),I(Pi,"DOWNSTREAM_PROPERTIES",[...Pi.MUTABLE_DOWNSTREAM_PROPERTIES,...Pi.INMUTABLE_DOWNSTREAM_PROPERTIES]),I(Pi,"PROPERTIES",[...Pi.META_PROPERTIES,...Pi.UPSTREAM_PROPERTIES,...Pi.DOWNSTREAM_PROPERTIES]);let Fu=Pi;async function NMe(o,p={}){var s;const i=J.YieldTracker.from(p),n=[];return await i.tick(),await((s=o.dataType)==null?void 0:s.validateAsync({tracker:i})),Mt(o.errors,n)}function xMe(o){var i;(i=o.dataType)==null||i.validate();const p=[];return Mt(o.errors,p)}const fIi=Object.freeze(Object.defineProperty({__proto__:null,validate:xMe,validateAsync:NMe},Symbol.toStringTag,{value:"Module"}));var $Me=(o=>(o.DataTypeEntity="data-type-entity",o))($Me||{});const Ai=class Ai extends Ur{constructor(i,n){super(i);I(this,"initialData");I(this,"id");I(this,"name");I(this,"codeName",null);I(this,"description",null);I(this,"index");I(this,"required");I(this,"parentRelationType");I(this,"type",d.ValueDescriptor);I(this,"defaultValue",null);I(this,"dataType",null);I(this,"project");I(this,"errors",[]);I(this,"parent");I(this,"detachedDependents",{});I(this,"knownVersions",null);I(this,"activeVersion",!1);I(this,"initialized",!1);I(this,"startedInitialization",!1);I(this,"codeNativeValueValidation",null);this.initialData=i,this.project=n,this.id=i.id,this.name=i.name,this.description=i.description,this.index=i.index,this.codeName=i.codeName,this.required=i.required,this.parentRelationType=i.parentRelationType}static new(i=null){return{id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||M().toISOString(),author:(i==null?void 0:i.author)||x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.ValueDescriptor,name:"",codeName:null,description:"",dataType:null,index:0,required:!1,parentRelationType:B.FixedArguments,defaultValue:null,parent:null}}static fromGenerationTarget(i,n){const s=i.parent?ne(i.parent):null,c=s?n.get(s):null,e=i.parentRelationType===B.FixedArguments?c==null?void 0:c.inputs.length:null,y={id:i.id,version:x.UUID.uuid(),createdAt:M().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,name:i.name,deletable:!0,editable:!0,type:d.ValueDescriptor,index:e||0,codeName:i.codeName,description:i.description,required:i.required,defaultValue:null,parentRelationType:i.parentRelationType,dataType:null,parent:c},m=me(y,n);return c&&m.setParent(c,null),m}static validateGenerationTarget(i,n){let s=JSON.parse(JSON.stringify(i));const c=[],e=bn(s,{parent:{list:!1,types:[d.ActionDescriptor]}},n);s=e.modifiedData,c.push(...e.errors,...$r(s));const y=s.parent&&n.get(s.parent),m=y&&Hu(y);return m&&m.type===d.ActionDescriptor&&c.push(new De({id:`${i.id}--${ae.BuiltInEntityParent}`,code:ae.BuiltInEntityParent,severity:ce.Error,message:`Entity of type "${i.type}" with id "${i.id}", has a parent that is a built-in entity "${m.name}" of type '${m.type}' with id '${m.id}'.
|
|
180
|
+
Specifically for continue statements the parent needs to always be the 'loop' entity that contains it.`})),{errors:n,modifiedData:i}}subscribeDependents(i){return i.forEach(n=>{this.detachedDependents[n.entity.id]||(this.detachedDependents[n.entity.id]=n)}),this}unsubscribeDependents(i){return i.forEach(n=>{this.detachedDependents[n.entity.id]&&delete this.detachedDependents[n.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"sync-dependents"))){const n=[],s=[],c=[],e=[];return Object.values(this.detachedDependents).forEach(y=>{const m=y.entity.afterAllChildrenInitialized(i);n.push(...m.updated),s.push(...m.added),c.push(...m.removed),e.push(...m.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}onDetachedDependencyRemoved(i,n,s){const c=[],e=[],y=[],m=[];if(n==="continue-statement-parent-field"){const{updated:v,added:E,removed:b}=this.remove({ignoreUpstream:!1},s);c.push(...v),e.push(...E),y.push(...b)}if(n==="continue-statement-parent-data-type-field"){const{updated:v,added:E,removed:b}=this.afterAllChildrenInitialized(s);c.push(...v),e.push(...E),y.push(...b)}if(n==="continue-statement-parent-data-type-entity-field"){const{updated:v,added:E,removed:b}=this.afterAllChildrenInitialized(s);c.push(...v),e.push(...E),y.push(...b)}return{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:this}}onDetachedDependencyRestored(i,n,s){const c=[],e=[],y=[],m=[];if(n==="continue-statement-parent-field"){const{updated:v,added:E,removed:b}=this.restore({},s);c.push(...v),e.push(...E),y.push(...b)}if(n==="continue-statement-parent-data-type-field"){const{updated:v,added:E,removed:b}=this.afterAllChildrenInitialized(s);c.push(...v),e.push(...E),y.push(...b)}if(n==="continue-statement-parent-data-type-entity-field"){const{updated:v,added:E,removed:b}=this.afterAllChildrenInitialized(s);c.push(...v),e.push(...E),y.push(...b)}return{updated:D(c),added:D(e),removed:D(y),affected:D(m),self:this}}unsubscribeFromDependencies(){var i,n,s,c,e,y,m,v,E,b,w,V,$;return(i=this.parent)==null||i.unsubscribeDependents([{entity:this,field:"continue-statement-parent-field"}]),(c=(s=(n=this.dataType)==null?void 0:n.entity)==null?void 0:s.unsubscribeDependents)==null||c.call(s,[{entity:this,field:"continue-statement-data-type-entity-field"}]),(y=(e=this.dataType)==null?void 0:e.unsubscribeDependents)==null||y.call(e,[{entity:this,field:"continue-statement-data-type-field"}]),(b=(E=(v=(m=this.parent)==null?void 0:m.dataType)==null?void 0:v.entity)==null?void 0:E.unsubscribeDependents)==null||b.call(E,[{entity:this,field:"continue-statement-parent-data-type-entity-field"}]),($=(V=(w=this.parent)==null?void 0:w.dataType)==null?void 0:V.unsubscribeDependents)==null||$.call(V,[{entity:this,field:"continue-statement-parent-data-type-field"}]),this}subscribeToDependencies(){var i,n,s,c,e,y,m,v,E,b,w,V,$;return(i=this.parent)==null||i.subscribeDependents([{entity:this,field:"continue-statement-parent-field"}]),(c=(s=(n=this.dataType)==null?void 0:n.entity)==null?void 0:s.subscribeDependents)==null||c.call(s,[{entity:this,field:"continue-statement-data-type-entity-field"}]),(y=(e=this.dataType)==null?void 0:e.subscribeDependents)==null||y.call(e,[{entity:this,field:"continue-statement-data-type-field"}]),(b=(E=(v=(m=this.parent)==null?void 0:m.dataType)==null?void 0:v.entity)==null?void 0:E.subscribeDependents)==null||b.call(E,[{entity:this,field:"continue-statement-parent-data-type-entity-field"}]),($=(V=(w=this.parent)==null?void 0:w.dataType)==null?void 0:V.subscribeDependents)==null||$.call(V,[{entity:this,field:"continue-statement-parent-data-type-field"}]),this}increaseVersion(i){if(i&&!M(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&M(i).isSame(M(this.createdAt))?this:(this.previousVersion=this.version,this.version=x.UUID.uuid(),this.createdAt=M(i).toISOString()||M().toISOString(),this)}captureVersion(){var n;const i=((n=this.knownVersions)==null?void 0:n.get(this.version))||new Pi(this,this.project);return i.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map([[this.version,i]]),i.outputs=[...this.outputs],i.readsValue=this.readsValue,i.defaultValue=this.defaultValue,i.dataType=this.dataType,i.throws=this.throws,i.calledBySuccess=[...this.calledBySuccess],i.calledByError=[...this.calledByError],i.calledByEntry=[...this.calledByEntry],i.parent=this.parent,this}recursiveCaptureUpstreamVersions(i){const n=[],s=[],c=[],e=[];if(this.parent){this.parent.increaseVersion(i);const y=this.parent.recursiveCaptureUpstreamVersions(i);n.push(this.parent,...y.updated),s.push(...y.added),c.push(...y.removed)}return{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}async restoreVersion(i){var m;const n=[],s=[],c=[],e=[];if(this.version===i)return{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this};if(!this.knownVersions){const v=new Map;for(const[E,b]of this.knownVersions||new Map){if(v.set(E,b),b.activeVersion=!1,b.knownVersions)for(const[w,V]of b.knownVersions)v.set(w,V);b.knownVersions=null}}let y=(m=this.knownVersions)==null?void 0:m.get(i);if(!y){const v=await this.APILoadVersion({},i);if(!v)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);y=new Pi(v,this.project)}return this.metaSync(y.toShallowJSON(),null),this.previousVersion=y.previousVersion,this.version=y.version,this.createdAt=y.createdAt,this.author=y.author,this.deleted=y.deleted,this.outputs=y.outputs,this.readsValue=y.readsValue,this.defaultValue=y.defaultValue,this.dataType=y.dataType,this.throws=y.throws,this.calledBySuccess=y.calledBySuccess,this.calledByError=y.calledByError,this.calledByEntry=y.calledByEntry,this.parent=y.parent,{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}updateWithShallowTransfer(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.UpdateWithShallowTransfer))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[updateWithShallowTransfer] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),this;if(this.metaSync(i,n),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 s=ne(i.parent),c=this.project.get(s),e=this.parent;if(e&&e.id!==(c==null?void 0:c.id)&&this.removeFromParent(n),c)this.setParent(c,n),this.addSelfToProject(n);else throw n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${s}' that isn't found in the project`)}else throw n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(i.readsValue){const s=ne(i.readsValue),c=this.project.get(s),e=this.readsValue;e&&e.id!==(c==null?void 0:c.id)&&this.removeValueWriter(n),c&&this.setValueWriter(c,n)}else this.removeValueWriter(n);if(i.calledByEntry.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addEntryCaller(e,n),e.addCall(this,n))}),[...this.calledByEntry].forEach(s=>{i.calledByEntry.find(e=>ne(e)===s.id)||(this.removeCaller(s,n),s.removeCall(this,n))}),i.calledBySuccess.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addSuccessCaller(e,n),e.addSuccessCall(this,n))}),[...this.calledBySuccess].forEach(s=>{i.calledBySuccess.find(e=>ne(e)===s.id)||(this.removeCaller(s,n),s.removeCall(this,n))}),i.calledByError.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addErrorCaller(e,n),e.addErrorCall(this,n))}),[...this.calledByError].forEach(s=>{i.calledByError.find(e=>ne(e)===s.id)||(this.removeCaller(s,n),s.removeCall(this,n))}),i.outputs.forEach(s=>{const c=ne(s),e=this.project.get(c);e&&(this.addOutput(e,n),e.setParent(this,n))}),[...this.outputs].forEach(s=>{i.outputs.find(e=>ne(e)===s.id)||(this.removeOutput(s,n),s.removeFromParent(n))}),i.dataType){const s=ne(i.dataType),c=this.project.get(s);c&&this.setDataType(c,n)}else this.setDataType(null,n);if(i.defaultValue){const s=ne(i.defaultValue),c=this.project.get(s);c&&this.setDefaultValue(c,n)}else this.setDefaultValue(null,n);return this.captureVersion(),this.subscribeToDependencies(),n==null||n.attemptAutoclose(_.UpdateWithShallowTransfer,this.id),this}hydrateAncestors(){const i=[],n=[],s=[],c=[];if(this.initialData.parent){const e=ne(this.initialData.parent),y=this.project.get(e);if(y)this.setParent(y,null),i.push(y);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.readsValue){const e=ne(this.initialData.readsValue),y=this.project.get(e);y&&(this.setValueWriter(y,null),i.push(y))}return this.initialData.calledByEntry.forEach(e=>{const y=ne(e),m=this.project.get(y);m&&this.addEntryCaller(m,null)}),this.initialData.calledBySuccess.forEach(e=>{const y=ne(e),m=this.project.get(y);m&&this.addSuccessCaller(m,null)}),this.initialData.calledByError.forEach(e=>{const y=ne(e),m=this.project.get(y);m&&this.addErrorCaller(m,null)}),{updated:D(i),added:D(n),removed:D(s),affected:D(c),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AfterAllChildrenInitialized))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[afterAllChildrenInitialized] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.AfterAllChildrenInitialized,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];this.initialized=!0,!this.dataType||this.dataType.inferred;const{added:y,updated:m,removed:v,affected:E}=this.syncInputs(i);return s.push(...y),n.push(...m),c.push(...v),e.push(...E),this.parent.syncTerminationStatements(i),this.outputs.sort((b,w)=>{var V,$;return(b.index??((V=b.declaration)==null?void 0:V.index))-(w.index??(($=w.declaration)==null?void 0:$.index))}),this.captureVersion(),i==null||i.attemptAutoclose(_.AfterAllChildrenInitialized,this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}addSelfToProject(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"add-self-to-project"))){var y,m;const n=[this],s=[],c=[],e=[];return this.readsValue&&(this.readsValue.addValueReader(this,i),n.push(this.readsValue)),this.calledByEntry.forEach(v=>{v.addCall(this,i),n.push(v)}),this.calledBySuccess.forEach(v=>{v.addSuccessCall(this,i),n.push(v)}),this.calledByError.forEach(v=>{v.addErrorCall(this,i),n.push(v)}),this.parent.addContinueStatement(this),n.push(this),i==null||i.add(this.parent,H.Affected),(y=this.parent)==null||y.breakStatements.forEach(v=>{v.id!==this.id&&(e.push(v),i==null||i.add(v,H.Affected))}),(m=this.parent)==null||m.continueStatements.forEach(v=>{v.id!==this.id&&(e.push(v),i==null||i.add(v,H.Affected))}),this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:D(n),added:D(s),removed:D(c),affected:D(e),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}addSuccessCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddSuccessCaller)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddSuccessCaller,n)?(this.calledBySuccess.find(c=>c.id===i.id)||(this.calledBySuccess.push(i),n==null||n.add(this,H.Updated),s&&mt(this,n)),n==null||n.attemptAutoclose(_.AddSuccessCaller,this.id),this):this}addErrorCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddErrorCaller)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddErrorCaller,n)?(this.calledByError.find(c=>c.id===i.id)||(this.calledByError.push(i),n==null||n.add(this,H.Updated),s&&mt(this,n)),n==null||n.attemptAutoclose(_.AddErrorCaller,this.id),this):this}addEntryCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.AddEntryCaller)),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.AddEntryCaller,n)?(this.calledByEntry.find(c=>c.id===i.id)||(this.calledByEntry.push(i),n==null||n.add(this,H.Updated),s&&mt(this,n)),n==null||n.attemptAutoclose(_.AddEntryCaller,this.id),this):this}removeCaller(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-caller")),s=!1){return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.RemoveCaller,n)?(this.calledBySuccess=this.calledBySuccess.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),this.calledByError=this.calledByError.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),this.calledByEntry=this.calledByEntry.filter(c=>c.id!==i.id?!0:(n==null||n.add(this,H.Updated),n==null||n.add(c,H.Affected),!1)),s&&mt(this,n),n==null||n.attemptAutoclose(_.RemoveCaller,this.id),this):this}setThrows(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"set-throws"))){var s;if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setThrows] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("set-throws",this.id),this;if(i!==null&&i.parentRelationType!==vd.Error)throw new Error("The 'throws' InputMap must have a parentRelationType of 'Error'.");return((s=this.throws)==null?void 0:s.id)!==(i==null?void 0:i.id)&&(this.throws=i,n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose("set-throws",this.id),this}addOutput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"add-output"))){return this.checkCanEdit(this,n)?this.outputs.includes(i)?(n==null||n.attemptAutoclose("add-output",this.id),this):(this.outputs.push(i),n==null||n.add(this,H.Affected),n==null||n.attemptAutoclose("add-output",this.id),this):(J.Logger.warn(`[addOutput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("add-output",this.id),this)}removeOutput(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"remove-output"))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[removeOutput] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("remove-output",this.id),this;const s=this.outputs.findIndex(c=>c.id===i.id);return s>-1&&(this.outputs.splice(s,1),n&&(n==null||n.add(this,H.Affected))),n==null||n.attemptAutoclose("remove-output",this.id),this}setParent(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetParent))){var s;return this.checkCanEditWithCounterpartAndSideEffects(this,i,_.SetParent,n)?(((s=this.parent)==null?void 0:s.id)!==(i==null?void 0:i.id)&&(this.parent=i,n&&(n==null||n.add(this,H.Updated))),n==null||n.attemptAutoclose(_.SetParent,this.id),this):this}setValueWriter(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetValueWriter))){var s;return this.checkCanEditFromScopeOwnerWithSideEffects(this,_.SetValueWriter,n)?(this.readsValue!==i&&(this.readsValue=i,this.readsValue&&((s=this.defaultValue)==null||s.remove({ignoreUpstream:!1},n)),n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose(_.SetValueWriter,this.id),this):this}removeValueWriter(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveValueWriter))){return this.readsValue&&!this.checkCanEditWithCounterpartAndSideEffects(this,this.readsValue,_.RemoveValueWriter,i)?this:(this.readsValue&&(this.readsValue=null,i==null||i.add(this,H.Updated)),i==null||i.attemptAutoclose(_.RemoveValueWriter,this.id),this)}initChildren(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"init-children"))){return this.initialized||this.startedInitialization?this:(this.startedInitialization=!0,this.initialData.defaultValue&&(this.defaultValue=me(this.initialData.defaultValue,this.project),this.defaultValue.setParent(this,null),this.defaultValue.initChildren(i)),this.initialData.dataType&&(this.dataType=me(this.initialData.dataType,this.project),this.dataType.setParent(this,null),this.dataType.initChildren(i)),lf.initReadsValue(this),this.outputs=this.initialData.outputs.map(n=>{const s=me(n,this.project);return s.setParent(this,null),s.initChildren(i),s}),this.initialData.throws&&(this.throws=me(this.initialData.throws,this.project),this.throws.setParent(this,null),this.throws.initChildren(i)),this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this)}subscribe(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"meta-sync"))){const s=Mr(this,i,n),c=Lr(this,s),e=this.toMeta();return this.x=s.x||e.x,this.y=s.y||e.y,super.baseMetaSync(s,this,n),s.deleted===!0&&!e.deleted?n==null||n.add(this,H.Removed):s.deleted===!1&&e.deleted?n==null||n.add(this,H.Added):c&&(n==null||n.add(this,H.Updated)),n==null||n.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=ke,...n){return await Pi.repository.APILoad(this.id,...n),this}async APICreate(i=ke,...n){return await Pi.repository.APICreate(this.toShallowJSON(),...n),this}async APIUpdate(i=ke,...n){return await Pi.repository.APIUpdate(this.toShallowJSON(),...n),this}async APIDelete(i=ke,...n){return await Pi.repository.APIDelete(this.toShallowJSON(),...n),this}async APIClone(i=ke,...n){return await Pi.repository.APIClone(this.id,...n),this}async APILoadVersion(i=ke,n,...s){return await Pi.repository.APILoadVersion(this.id,n,...s)}removeFromParent(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveFromParent))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[removeFromParent] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveFromParent,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];return this.parent.removeContinueStatement(this),this.parent.detachedChildren.includes(this)&&this.parent.unsubscribeDetachedChild(this),i==null||i.attemptAutoclose(_.RemoveFromParent,this.id),{added:D(c),updated:D(n),removed:D(s),affected:D(e),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveEntity))){var m,v,E;if(!this.checkCanDelete(this,n))return J.Logger.warn(`[remove] User is not allowed to delete or edit this ${this.type} entity with id: ${this.id}`),n==null||n.event({id:`${_.RemoveEntity}-${this.id}`,action:_.RemoveEntity,owner:this,errorReason:Ii.ActionOwnerEntityNonDeletable,rootAction:((m=n==null?void 0:n.self)==null?void 0:m.id)===this.id&&(n==null?void 0:n.autoCloseActionName)===_.RemoveEntity}),n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const s=[],c=[],e=[],y=[];if(n!=null&&n.hasRemoved(this.id))return n==null||n.attemptAutoclose(_.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},n),Object.values(this.detachedDependents).forEach(b=>{const{updated:w,removed:V,added:$}=b.entity.onDetachedDependencyRemoved(this,b.field,n);s.push(...w),c.push(...V),e.push(...$)}),this.readsValue&&(s.push(this.readsValue),this.readsValue.removeValueReader(this,n)),this.outputs.forEach(b=>{const{updated:w,removed:V}=b.remove({ignoreUpstream:!0},n);s.push(...w),c.push(...V)}),this.throws){const{updated:b,removed:w}=this.throws.remove({ignoreUpstream:!0},n);s.push(...b),c.push(...w)}if(this.dataType){const{updated:b,removed:w}=this.dataType.remove({ignoreUpstream:!0},n);s.push(...b),c.push(...w)}if(!i){const b=this.removeFromParent(n);e.push(...b.added),s.push(...b.updated),c.push(...b.removed),y.push(...b.affected),this.calledBy.forEach(w=>{s.push(w),w.removeCall(this,n)})}return n==null||n.add(this.parent,H.Affected),(v=this.parent)==null||v.breakStatements.forEach(b=>{b.id!==this.id&&(y.push(b),n==null||n.add(b,H.Affected))}),(E=this.parent)==null||E.continueStatements.forEach(b=>{b.id!==this.id&&(y.push(b),n==null||n.add(b,H.Affected))}),n==null||n.attemptAutoclose(_.RemoveEntity,this.id),{added:D(e),updated:D(s),removed:D(c),affected:D(y),self:this}}restore({}={},i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RestoreEntity))){if(!this.checkCanEdit(this,i))return J.Logger.warn(`[restore] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const n=[],s=[],c=[],e=[];if(i!=null&&i.hasAdded(this.id))return i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},i),Object.values(this.detachedDependents).forEach(y=>{const{updated:m,removed:v,added:E}=y.entity.onDetachedDependencyRestored(this,y.field,i);s.push(...m),c.push(...v),n.push(...E)}),this.readsValue&&(s.push(this.readsValue),this.readsValue.addValueReader(this,i)),this.outputs.forEach(y=>{const{updated:m}=y.restore({},i);s.push(...m)}),this.throws){const{updated:y}=this.throws.restore({},i);s.push(...y)}if(this.dataType){const{updated:y}=this.dataType.restore({},i);s.push(...y)}return this.parent.addContinueStatement(this),this.calledBySuccess.forEach(y=>{s.push(y),y.addSuccessCall(this,i)}),this.calledByError.forEach(y=>{s.push(y),y.addErrorCall(this,i)}),this.calledByEntry.forEach(y=>{s.push(y),y.addCall(this,i)}),i==null||i.attemptAutoclose(_.RestoreEntity,this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this}}toFlat(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this,...this.outputs.flatMap(s=>s.toFlat(i)),...this.calledBy.flatMap(s=>s.toFlat(i)),...this.throws?this.throws.toFlat(i):[],...this.dataType?this.dataType.toFlat(i):[]])}toFlatIds(i=new Set){return i.has(this.id)?[]:(i.add(this.id),[this.id,...this.outputs.flatMap(s=>s.toFlatIds(i)),...this.calledBy.flatMap(s=>s.toFlatIds(i)),...this.throws?this.throws.toFlatIds(i):[],...this.dataType?this.dataType.toFlatIds(i):[]])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,x:this.x,y:this.y,type:this.type,editable:this.editable,deletable:this.deletable}}toJSON(i=new Set){var n,s,c,e,y;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,x:this.x,y:this.y,defaultValue:((n=this.defaultValue)==null?void 0:n.toJSON(i))||null,dataType:((s=this.dataType)==null?void 0:s.toJSON(i))||null,readsValue:((c=this.readsValue)==null?void 0:c.toReference())||null,calledBySuccess:this.calledBySuccess.map(m=>m.toReference()),calledByError:this.calledByError.map(m=>m.toReference()),calledByEntry:this.calledByEntry.map(m=>m.toReference()),outputs:this.outputs.map(m=>m.toJSON(i)),throws:((e=this.throws)==null?void 0:e.toJSON(i))||null,parent:((y=this.parent)==null?void 0:y.toReference())||null})}toJSONClone(i=ct){var s,c,e,y,m,v,E,b,w,V;let n;return(s=i.seenEntityMaps)!=null&&s.has(this.id)?n=i.seenEntityMaps.get(this.id):(n=i.newId||jr(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,n)),(c=i.seenEntities)!=null&&c.has(n)||(e=i.seenEntities)!=null&&e.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((y=i.seenEntities)==null||y.add(n),(m=i.seenEntities)==null||m.add(this.id),{id:n,version:x.UUID.uuid(),createdAt:i.timestamp||M().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,x:this.x,y:this.y,defaultValue:((v=this.defaultValue)==null?void 0:v.toJSONClone({...i,newId:null}))||null,dataType:((E=this.dataType)==null?void 0:E.toJSONClone({...i,newId:null}))||null,readsValue:((b=this.readsValue)==null?void 0:b.toReference({seenEntityMaps:i.seenEntityMaps}))||null,calledBySuccess:this.calledBySuccess.map($=>$.toReference({seenEntityMaps:i.seenEntityMaps})),calledByError:this.calledByError.map($=>$.toReference({seenEntityMaps:i.seenEntityMaps})),calledByEntry:this.calledByEntry.map($=>$.toReference({seenEntityMaps:i.seenEntityMaps})),outputs:this.outputs.map($=>$.toJSONClone({...i,newId:null})),throws:((w=this.throws)==null?void 0:w.toJSONClone({...i,newId:null}))||null,parent:((V=this.parent)==null?void 0:V.toReference({seenEntityMaps:i.seenEntityMaps}))||null})}toReference(i=ct){var s;let n=this.id;return(s=i.seenEntityMaps)!=null&&s.has(this.id)&&(n=i.seenEntityMaps.get(this.id)),{id:n+"--"+x.UUID.uuid()+"--ref",type:d.GenericReference,entityId:n,version:this.version,entityType:this.type}}toShallowJSON(i=ct){var s,c,e,y,m;let n=this.id;return(s=i.seenEntityMaps)!=null&&s.has(this.id)&&(n=i.seenEntityMaps.get(this.id)),{id:n,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,x:this.x,y:this.y,defaultValue:((c=this.defaultValue)==null?void 0:c.toReference(i))||null,dataType:((e=this.dataType)==null?void 0:e.toReference(i))||null,readsValue:((y=this.readsValue)==null?void 0:y.toReference(i))||null,outputs:this.outputs.map(v=>v.toReference(i)),calledBySuccess:this.calledBySuccess.map(v=>v.toReference(i)),calledByError:this.calledByError.map(v=>v.toReference(i)),calledByEntry:this.calledByEntry.map(v=>v.toReference(i)),throws:((m=this.throws)==null?void 0:m.toReference(i))||null,parent:this.parent.toReference(i)}}toFlatJSON(i=new Set){var s,c,e;return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...((s=this.defaultValue)==null?void 0:s.toFlatJSON(i))||[],...((c=this.dataType)==null?void 0:c.toFlatJSON(i))||[],...this.outputs.flatMap(y=>y.toFlatJSON(i)),...this.calledBy.flatMap(y=>y.toFlatJSON(i)),...((e=this.throws)==null?void 0:e.toFlatJSON(i))||[]])}toGenerationTarget(){return{id:this.id,type:this.type,calledByEntry:this.calledByEntry.map(i=>i.id),calledByError:this.calledByError.map(i=>i.id),calledBySuccess:this.calledBySuccess.map(i=>i.id),parent:this.parent.id}}toFlatGenerationTarget(i=new Set){var s,c;return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...((s=this.defaultValue)==null?void 0:s.toFlatGenerationTarget(i))||[],...((c=this.dataType)==null?void 0:c.toFlatGenerationTarget(i))||[],...this.outputs.flatMap(e=>e.toFlatGenerationTarget(i)),...this.throws?this.throws.toFlatGenerationTarget(i):[]])}clearErrors(){var i,n,s;return this.errors=[],(i=this.dataType)==null||i.clearErrors(),(n=this.defaultValue)==null||n.clearErrors(),this.outputs.forEach(c=>c.clearErrors()),(s=this.throws)==null||s.clearErrors(),this}validate(){return this.errors=VMe(this),{success:!0}}async validateAsync(i={}){const n=J.YieldTracker.from(i);return this.errors=await _Me(this,{tracker:n}),{success:!0}}getErrors(){var n,s;return[...this.errors,...((n=this.defaultValue)==null?void 0:n.getErrors())||[],...((s=this.dataType)==null?void 0:s.getErrors())||[],...this.outputs.flatMap(c=>c.getErrors()),...this.throws?this.throws.getErrors():[]]}async getErrorsAsync(i={}){const n=J.YieldTracker.from(i),s=[...this.errors];if(await n.tick(),this.defaultValue){const c=await this.defaultValue.getErrorsAsync({tracker:n});s.push(...c)}if(this.dataType){const c=await this.dataType.getErrorsAsync({tracker:n});s.push(...c)}for(const c of this.outputs){const e=await c.getErrorsAsync({tracker:n});s.push(...e)}if(this.throws){const c=await this.throws.getErrorsAsync({tracker:n});s.push(...c)}return s}getShallowErrors(){return this.errors}getDefaultValue(){return this.defaultValue||null}setDefaultValue(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"set-default-value"))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setDefaultValue] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose("set-default-value",this.id),this;const s=this.defaultValue;if((s==null?void 0:s.id)!==(i==null?void 0:i.id)){if(s==null||s.remove({ignoreUpstream:!0},n),this.defaultValue=i,this.defaultValue){const c=this.readsValue;this.removeValueWriter(n),c==null||c.removeValueReader(this,n)}n==null||n.add(this,H.Affected)}return n==null||n.attemptAutoclose("set-default-value",this.id),this}clone(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.CloneEntity)),n=null,s=null,c=!0){var L,k,K;const e=Rr(n,this),y=this.toJSON(),m=s||x.UUID.uuid();y.outputs=[];const v=m.split("-id"),E=v[v.length-1||0]||m;y.id=m,y.version=x.UUID.uuid(),y.createdAt=(i==null?void 0:i.timestamp)||M().toISOString(),y.author=(i==null?void 0:i.author)||"1",y.previousVersion=null,y.deleted=!1,y.deletable=!0,y.editable=!0;const b=Si(y,e);n?b.setParent(n,i):b.setParent(this.parent,null),c&&b.subscribe(),b.initChildren(i),i==null||i.add(b,H.Added);const w=(L=this.dataType)==null?void 0:L.clone(i,b,x.UUID.uuid(),c);b.setDataType(w||null,i);const V=(k=this.defaultValue)==null?void 0:k.clone(i,b,x.UUID.uuid(),c);b.setDefaultValue(V||null,i);const $=(K=this.outputs)==null?void 0:K.map((S,Y)=>S.clone(i,b,E+"-return-declaration-"+Y+"-id",c));return b.outputs=$,this.throws&&(b.throws=this.throws.clone(i,b,E+"-throws-id",c)),i==null||i.attemptAutoclose(_.CloneEntity,this.id),b}getMasterInputWithValueWritterFromAllInstances(i){return D([...this.outputs,...this.parent.breakStatements.filter(c=>c.id!==this.id).flatMap(c=>c.outputs),...this.parent.continueStatements.flatMap(c=>c.outputs)]).find(c=>se(c,this.project)===se(i,this.project)&&!!c.readsValue)||i}syncInputs(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"sync-continue-statement-inputs"))){const n=[],s=[],c=[],e=[],y=this.getDataType(i);if(y)if(y.entity){if(y.isObject()){const m=[...y.entity.properties];this.outputs.filter(b=>!b.declaration||!m.find(w=>{var V;return w.id===((V=b.declaration)==null?void 0:V.id)})).forEach(b=>{const w=m.find(V=>se(V,this.project)===se(b,this.project));w&&b.setDeclaration(w,i)}),m.filter(b=>!this.outputs.find(w=>{var V;return((V=w.declaration)==null?void 0:V.id)===b.id})).forEach(b=>{const w={dataType:null,id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||M().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.InputMap,parentRelationType:null,parent:this.toReference(),name:null,description:null,codeName:null,declaration:b,defaultValue:null,index:b.index,readsValue:null},V=me(w,this.project);return V.hydrateAncestors(),i==null||i.add(V,H.Added),V.setParent(this,i),V.initChildren(i),this.addOutput(V,i),V})}}else return i==null||i.attemptAutoclose("sync-continue-statement-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};else return i==null||i.attemptAutoclose("sync-continue-statement-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};return i==null||i.attemptAutoclose("sync-continue-statement-inputs",this.id),{added:D(n),updated:D(s),removed:D(c),affected:D(e),self:this}}setDataType(i,n=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.SetDataType))){if(!this.checkCanEdit(this,n))return J.Logger.warn(`[setDataType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),n==null||n.attemptAutoclose(_.SetDataType,this.id),this;const s=this.dataType;return(s==null?void 0:s.id)!==(i==null?void 0:i.id)&&(s==null||s.remove({ignoreUpstream:!0},n),this.dataType=i,this.subscribeToDependencies(),n==null||n.add(this,H.Affected)),n==null||n.attemptAutoclose(_.SetDataType,this.id),this}removeDataType(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,_.RemoveDataType))){return this.checkCanEdit(this,i)?(this.dataType&&(this.dataType.remove({ignoreUpstream:!0},i),i==null||i.add(this,H.Affected),this.dataType=null),i==null||i.attemptAutoclose(_.RemoveDataType,this.id),this):(J.Logger.warn(`[removeDataType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(_.RemoveDataType,this.id),this)}getDataType(i=this.project.addChangeSet(new Z(this.project,x.sessionAuthor,M().toISOString(),this,!0,"get-data-type"))){if((!this.dataType||this.dataType.inferred)&&this.project.initialized,this.dataType)return i==null||i.attemptAutoclose("get-data-type",this.id),this.dataType;const n=this.parent.getDataType(i);return n?(i==null||i.attemptAutoclose("get-data-type",this.id),n):(i==null||i.attemptAutoclose("get-data-type",this.id),null)}};I(Pi,"repository",{APICreate:async(i,...n)=>i,APIUpdate:async(i,...n)=>i,APIDelete:async(i,...n)=>i,APIClone:async(i,...n)=>{},APILoad:async(i,...n)=>null,APILoadVersion:async(i,n,...s)=>null}),I(Pi,"type",d.ContinueStatement),I(Pi,"USER_MANAGED_PARENT_TYPES",[d.Loop]),I(Pi,"PARENT_TYPES",[...Pi.USER_MANAGED_PARENT_TYPES]),I(Pi,"MUTABLE_BASE_PROPERTIES",[]),I(Pi,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),I(Pi,"BASE_PROPERTIES",[...Pi.MUTABLE_BASE_PROPERTIES,...Pi.INMUTABLE_BASE_PROPERTIES]),I(Pi,"MUTABLE_META_PROPERTIES",["x","y"]),I(Pi,"INMUTABLE_META_PROPERTIES",[...Pi.INMUTABLE_BASE_PROPERTIES]),I(Pi,"META_PROPERTIES",[...Pi.MUTABLE_META_PROPERTIES,...Pi.INMUTABLE_META_PROPERTIES]),I(Pi,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry","readsValue"]),I(Pi,"INMUTABLE_UPSTREAM_PROPERTIES",["parent"]),I(Pi,"UPSTREAM_PROPERTIES",[...Pi.MUTABLE_UPSTREAM_PROPERTIES,...Pi.INMUTABLE_UPSTREAM_PROPERTIES]),I(Pi,"MUTABLE_DOWNSTREAM_PROPERTIES",["outputs","throws"]),I(Pi,"INMUTABLE_DOWNSTREAM_PROPERTIES",["dataType","defaultValue"]),I(Pi,"DOWNSTREAM_PROPERTIES",[...Pi.MUTABLE_DOWNSTREAM_PROPERTIES,...Pi.INMUTABLE_DOWNSTREAM_PROPERTIES]),I(Pi,"PROPERTIES",[...Pi.META_PROPERTIES,...Pi.UPSTREAM_PROPERTIES,...Pi.DOWNSTREAM_PROPERTIES]);let Fu=Pi;async function NMe(o,p={}){var s;const i=J.YieldTracker.from(p),n=[];return await i.tick(),await((s=o.dataType)==null?void 0:s.validateAsync({tracker:i})),Mt(o.errors,n)}function xMe(o){var i;(i=o.dataType)==null||i.validate();const p=[];return Mt(o.errors,p)}const fIi=Object.freeze(Object.defineProperty({__proto__:null,validate:xMe,validateAsync:NMe},Symbol.toStringTag,{value:"Module"}));var $Me=(o=>(o.DataTypeEntity="data-type-entity",o))($Me||{});const Ai=class Ai extends Ur{constructor(i,n){super(i);I(this,"initialData");I(this,"id");I(this,"name");I(this,"codeName",null);I(this,"description",null);I(this,"index");I(this,"required");I(this,"parentRelationType");I(this,"type",d.ValueDescriptor);I(this,"defaultValue",null);I(this,"dataType",null);I(this,"project");I(this,"errors",[]);I(this,"parent");I(this,"detachedDependents",{});I(this,"knownVersions",null);I(this,"activeVersion",!1);I(this,"initialized",!1);I(this,"startedInitialization",!1);I(this,"codeNativeValueValidation",null);this.initialData=i,this.project=n,this.id=i.id,this.name=i.name,this.description=i.description,this.index=i.index,this.codeName=i.codeName,this.required=i.required,this.parentRelationType=i.parentRelationType}static new(i=null){return{id:x.UUID.uuid(),version:x.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||M().toISOString(),author:(i==null?void 0:i.author)||x.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:d.ValueDescriptor,name:"",codeName:null,description:"",dataType:null,index:0,required:!1,parentRelationType:B.FixedArguments,defaultValue:null,parent:null}}static fromGenerationTarget(i,n){const s=i.parent?ne(i.parent):null,c=s?n.get(s):null,e=i.parentRelationType===B.FixedArguments?c==null?void 0:c.inputs.length:null,y={id:i.id,version:x.UUID.uuid(),createdAt:M().toISOString(),author:x.sessionAuthor,previousVersion:null,deleted:!1,name:i.name,deletable:!0,editable:!0,type:d.ValueDescriptor,index:e||0,codeName:i.codeName,description:i.description,required:i.required,defaultValue:null,parentRelationType:i.parentRelationType,dataType:null,parent:c},m=me(y,n);return c&&m.setParent(c,null),m}static validateGenerationTarget(i,n){let s=JSON.parse(JSON.stringify(i));const c=[],e=bn(s,{parent:{list:!1,types:[d.ActionDescriptor]}},n);s=e.modifiedData,c.push(...e.errors,...$r(s));const y=s.parent&&n.get(s.parent),m=y&&Hu(y);return m&&m.type===d.ActionDescriptor&&c.push(new De({id:`${i.id}--${ae.BuiltInEntityParent}`,code:ae.BuiltInEntityParent,severity:ce.Error,message:`Entity of type "${i.type}" with id "${i.id}", has a parent that is a built-in entity "${m.name}" of type '${m.type}' with id '${m.id}'.
|
|
181
181
|
You can't modify system entities that are built-in.`})),y&&y.type===d.ActionDescriptor&&(!s.parentRelationType||!(s.parentRelationType===B.FixedArguments||s.parentRelationType===B.ReturnedError||s.parentRelationType===B.DynamicArgument)?c.push(new De({id:`${i.id}--${ae.InvalidParentRelationType}`,code:ae.InvalidParentRelationType,severity:ce.Error,message:`The entity with id '${i.id}' and type '${i.type}', must have a 'parentRelationType' property set to either '${B.FixedArguments}' or '${B.ReturnedError}' when being added as a child to an entity of type 'action-descriptor'.`})):s.parentRelationType===B.ReturnedError&&y.error&&c.push(new De({id:`${i.id}--${ae.NewEntityWouldOverriteExisting}`,code:ae.NewEntityWouldOverriteExisting,severity:ce.Error,message:`The entity with id '${i.id}' and type '${i.type}', is being added as an error value-descriptor to an entity of type 'action-descriptor' with id '${y.id}', which already has an error value descriptor with id '${y.error.id}'.
|
|
182
182
|
An action descriptor can only have one error value descriptor child.
|
|
183
183
|
Either remove the existing error value descriptor or update it with the 'update' action.
|