@elyx-code/project-logic-tree 0.0.6359 → 0.0.6360

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.js CHANGED
@@ -33968,7 +33968,7 @@ const ft = class ft extends mr {
33968
33968
  abstract: !1,
33969
33969
  static: !1,
33970
33970
  constant: !1,
33971
- interactive: !1,
33971
+ interactive: !0,
33972
33972
  hidden: !1,
33973
33973
  index: 0,
33974
33974
  required: !1,
@@ -43,7 +43,7 @@ You can update the existing 'literal-value' with the 'update' action, for exampl
43
43
  }
44
44
  }\`\`\`
45
45
  Or 'delete' and then 'post' actions to replace it.`,issue:null})):i.push(new Q({id:`${d.id}--${d.parent}--${q.InvalidParentReference}`,code:q.InvalidParentReference,severity:Z.Error,message:`Entity of type "${d.type}" with id "${d.id}", has a parent reference that isn't pointing to an entity of type 'input-map' or 'data-type'.`,issue:null})):i.push(new Q({id:`${d.id}--${d.parent}--${q.ReferencedEntityNotFound}`,code:q.ReferencedEntityNotFound,severity:Z.Error,message:`Entity of type "${d.type}" with id "${d.id}", is referencing an entity with id "${d.parent}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,issue:null}))}else i.push(new Q({id:`${d.id}--${le.InvalidObjectStructure}`,code:le.InvalidObjectStructure,severity:Z.Error,message:`Entity of type "${d.type}" with id "${d.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'.`,issue:null}));else return i.push(new Q({id:`${d.id}--${le.InvalidObjectStructure}`,code:le.InvalidObjectStructure,severity:Z.Error,message:`Entity of type "${d.type}" with id "${d.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'.`,issue:null})),i;if(d.valueAsTypeSingle){const p=[],t=[],y=d.valueAsTypeSingle;Array.isArray(y)?y.forEach(v=>{typeof v=="string"?t.push(v):p.push(v)}):typeof y=="string"?t.push(y):p.push(y),p.forEach(v=>{const b=wy(v);i.push(...b),b.length===0&&t.push(v.entityId)}),t.forEach(v=>{const b=u.get(v);b?[f.DefinitionEntity,f.BuiltInBaseEntity].includes(b.type)||i.push(new Q({id:`${d.id}--${v}--${q.InvalidImplementsReference}`,code:q.InvalidImplementsReference,severity:Z.Error,message:`Entity of type "${d.type}" with id "${d.id}", has an 'valueAsTypeSingle' reference that isn't pointing to an entity of type 'definition-entity', 'function-declaration' or 'operation'.`,issue:null})):i.push(new Q({id:`${d.id}--${v}--${q.ReferencedEntityNotFound}`,code:q.ReferencedEntityNotFound,severity:Z.Error,message:`Entity of type "${d.type}" with id "${d.id}", is referencing an entity with id "${v}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,issue:null}))})}return i}var U3=(d=>(d.ValueAsTypeSingle="value-as-type-single",d.ValueAsTypeList="value-as-type-list",d))(U3||{});const Et=class Et extends mr{constructor(i,a){super(i);D(this,"initialData");D(this,"type",f.LiteralValue);D(this,"id");D(this,"name");D(this,"autogeneration",null);D(this,"value",null);D(this,"valueAsTypeSingle",null);D(this,"valueAsTypeList",null);D(this,"errors",[]);D(this,"parent");D(this,"standaloneParent");D(this,"project");D(this,"detachedDependents",{});D(this,"knownVersions",null);D(this,"activeVersion",!1);D(this,"initialized",!1);D(this,"startedInitialization",!1);D(this,"standalone",!1);this.initialData=i,this.project=a,this.id=i.id,this.name=i.name,this.autogeneration=i.autogeneration,this.value=i.value}static new(i=null){return{id:P.UUID.uuid(),version:P.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||N().toISOString(),author:(i==null?void 0:i.author)||P.sessionAuthor,previousVersion:null,deleted:!1,type:f.LiteralValue,standaloneParent:null,name:"",autogeneration:null,value:null,valueAsTypeSingle:null,valueAsTypeList:null,parent:null}}static fromGenerationTarget(i,a){const l=W(i.parent),p=a.get(l);let t=null,y=null;i.valueAsTypeList?Array.isArray(i.valueAsTypeList)&&(y=i.valueAsTypeList.map(w=>a.get(w)||a.getBuiltIn(w))):i.valueAsTypeSingle&&(t=a.get(i.valueAsTypeSingle)||a.getBuiltIn(i.valueAsTypeSingle));const v={id:i.id,version:P.UUID.uuid(),createdAt:N().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,type:f.LiteralValue,standaloneParent:null,name:i.name,autogeneration:i.autogeneration,valueAsTypeSingle:t,valueAsTypeList:y,value:i.value||null,parent:p},b=ee(v,a);return b.setParent(p,null),b}static validateGenerationTarget(i,a){let l=JSON.parse(JSON.stringify(i));const p=[],t=dhe(l,a);return p.push(...t,...Tr(l)),{errors:p,modifiedData:l}}get valueAsType(){return this.valueAsTypeSingle?this.valueAsTypeSingle:this.valueAsTypeList?this.valueAsTypeList:null}get isFinal(){var i;return!!(this.parent.type===f.Property&&(this.parent.constant||(i=this.parent.implements)!=null&&i.constant)||this.parent.type===f.Property&&this.parent.parent.type===f.DefinitionEntity&&!Rp(this.parent.parent))}validateGeneratedUpdate(i){const a=[];return i.parent&&a.push(new Q({id:`${this.id}--${q.InvalidParentUpdate}`,code:q.InvalidParentUpdate,severity:Z.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.
46
- 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.`,issue:null})),{errors:a,modifiedData:i}}subscribeDependents(i){return i.forEach(a=>{this.detachedDependents[a.entity.id]||(this.detachedDependents[a.entity.id]=a)}),this}unsubscribeDependents(i){return i.forEach(a=>{this.detachedDependents[a.entity.id]&&delete this.detachedDependents[a.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"sync-dependents"))){const a=[],l=[],p=[],t=[];return Object.values(this.detachedDependents).forEach(y=>{const v=y.entity.afterAllChildrenInitialized(i);a.push(...v.updated),l.push(...v.added),p.push(...v.removed),t.push(...v.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}onDetachedDependencyRemoved(i,a,l){const p=[],t=[],y=[],v=[];return a==="value-as-type-single"&&(this.valueAsTypeSingle=null,l==null||l.add(this,K.Updated)),a==="value-as-type-list"&&(this.valueAsTypeList=(this.valueAsTypeList||[]).filter(b=>b.id!==i.id),l==null||l.add(this,K.Updated)),{updated:R(p),added:R(t),removed:R(y),affected:R(v),self:this}}onDetachedDependencyRestored(i,a,l){const p=[],t=[],y=[],v=[];return a==="value-as-type-single"&&(this.valueAsTypeSingle=i,l==null||l.add(this,K.Updated)),a==="value-as-type-list"&&(this.valueAsTypeList=[...Array.isArray(this.valueAsTypeList||[])?this.valueAsTypeList:[],i],l==null||l.add(this,K.Updated)),{updated:R(p),added:R(t),removed:R(y),affected:R(v),self:this}}unsubscribeFromDependencies(){return this.valueAsTypeSingle&&this.valueAsTypeSingle.type!==f.BuiltInBaseEntity&&this.valueAsTypeSingle.unsubscribeDependents([{entity:this,field:"value-as-type-single"}]),this.valueAsTypeList&&Array.isArray(this.valueAsTypeList)&&this.valueAsTypeList.forEach(i=>{i.type!==f.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!==f.BuiltInBaseEntity&&i.subscribeDependents([{entity:this,field:"value-as-type-list"}])}):this.valueAsTypeSingle&&this.valueAsTypeSingle.type!==f.BuiltInBaseEntity&&this.valueAsTypeSingle.subscribeDependents([{entity:this,field:"value-as-type-single"}]),this)}increaseVersion(i){if(i&&!N(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&N(i).isSame(N(this.createdAt))?this:(this.previousVersion=this.version,this.version=P.UUID.uuid(),this.createdAt=N(i).toISOString()||N().toISOString(),this)}captureVersion(){var a;const i=((a=this.knownVersions)==null?void 0:a.get(this.version))||new Et(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 a=[],l=[],p=[],t=[];if(this.parent){this.parent.increaseVersion(i);const y=this.parent.recursiveCaptureUpstreamVersions(i);a.push(this.parent,...y.updated),l.push(...y.added),p.push(...y.removed)}return{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}async restoreVersion(i){var v;const a=[],l=[],p=[],t=[];if(this.version===i)return{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this};if(!this.knownVersions){const b=new Map;for(const[w,A]of this.knownVersions||new Map){if(b.set(w,A),A.activeVersion=!1,A.knownVersions)for(const[V,L]of A.knownVersions)b.set(V,L);A.knownVersions=null}}let y=(v=this.knownVersions)==null?void 0:v.get(i);if(!y){const b=await this.APILoadVersion({},i);if(!b)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);y=new Et(b,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:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}updateWithShallowTransfer(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"update-with-shallow-transfer"))){if(this.metaSync(i,a),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 l=W(i.parent),p=this.project.get(l),t=this.parent;if(t&&t.id!==(p==null?void 0:p.id)&&this.removeFromParent(a),p)this.setParent(p,null);else throw new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${l}' that isn't found in the project`)}else if(i.standaloneParent){const l=W(i.standaloneParent),p=this.project.get(l);if(p)this.setStandaloneParent(p);else throw new Error(`${this.type} with id '${this.id}' has a 'standaloneParent' reference '${l}' 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(l=>{const p=W(l),t=this.project.get(p);t&&this.valueAsTypeList.push(t)});else if(i.valueAsTypeSingle){const l=W(i.valueAsTypeSingle),p=this.project.get(l);p&&(this.valueAsTypeSingle=p)}return this.captureVersion(),this.subscribeToDependencies(),a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),this}hydrateAncestors(){const i=[],a=[],l=[],p=[];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 t=W(this.initialData.parent),y=this.project.get(t);if(y)this.setParent(y,null),i.push(y);else throw new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${t}' that isn't found in the project`)}else if(this.initialData.standaloneParent){const t=W(this.initialData.standaloneParent),y=this.project.get(t);if(y)this.setStandaloneParent(y);else throw new Error(`${this.type} with id '${this.id}' has a 'standaloneParent' reference '${t}' that isn't found in the project`)}else throw 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(t=>{const y=W(t),v=this.project.get(y);v&&this.valueAsTypeList.push(v)});else if(this.initialData.valueAsTypeSingle){const t=W(this.initialData.valueAsTypeSingle),y=this.project.get(t);y&&(this.valueAsTypeSingle=y)}return{updated:R(i),added:R(a),removed:R(l),affected:R(p),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"after-all-children-initialized"))){const a=[],l=[],p=[],t=[];return this.initialized=!0,this.captureVersion(),i==null||i.attemptAutoclose("after-all-children-initialized",this.id),{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}addSelfToProject(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"add-self-to-project"))){var y,v;const a=[this],l=[],p=[],t=[];return((y=this.parent)==null?void 0:y.type)===f.DataType?this.parent.setEntity(this,i):(v=this.parent)==null||v.setDefaultValue(this,i),t.push(this.parent),this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}setParent(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"set-parent"))){var l;return((l=this.parent)==null?void 0:l.id)!==(i==null?void 0:i.id)&&(this.parent=i,a&&(a==null||a.add(this,K.Updated))),a==null||a.attemptAutoclose("set-parent",this.id),this}setStandaloneParent(i){return this.standaloneParent=i,this}setValueAsTypeSingle(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"set-value-as-type-single"))){return this.valueAsTypeSingle!==i&&(this.valueAsTypeSingle=i,a==null||a.add(this,K.Updated)),a==null||a.attemptAutoclose("set-value-as-type-single",this.id),this}setValueAsTypeList(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"set-value-as-type-list"))){var l,p;return!i&&this.valueAsTypeList?(this.valueAsTypeList=null,a==null||a.add(this,K.Updated)):i&&!this.valueAsTypeList?(this.valueAsTypeList=i,a==null||a.add(this,K.Updated)):i&&this.valueAsTypeList&&((l=this.valueAsTypeList)==null?void 0:l.length)!==i.length?(this.valueAsTypeList=i,a==null||a.add(this,K.Updated)):i&&this.valueAsTypeList&&((p=this.valueAsTypeList)!=null&&p.every((t,y)=>t!==i[y]))&&(this.valueAsTypeList=i,a==null||a.add(this,K.Updated)),a==null||a.attemptAutoclose("set-value-as-type-list",this.id),this}setValueAsType(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"set-value-as-type"))){return i?(Array.isArray(i)?this.setValueAsTypeList(i,a):this.setValueAsTypeSingle(i,a),a==null||a.attemptAutoclose("set-value-as-type",this.id),this):(this.setValueAsTypeSingle(null,a),this.setValueAsTypeList(null,a),this)}initChildren(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().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(a=>{if(a.type===f.GenericReference){const p=this.project.findSubscribedBuiltInInstanceFromReference(a);if(!p)throw new Error(`Standalone entity of type '${this.type}' with id '${this.id}' has a reference to an entity of type '${a.entityType}' with id '${a.entityId}' that is not part of the project state.`);return p}const l=this.project.get(a.id);if(!l)throw new Error(`Standalone entity of type '${this.type}' with id '${this.id}' has a reference to an entity of type '${a.type}' with id '${a.id}' that is not part of the project state.`);return l});else if(this.initialData.valueAsTypeSingle){if(this.initialData.valueAsTypeSingle.type===f.GenericReference){const l=this.project.findSubscribedBuiltInInstanceFromReference(this.initialData.valueAsTypeSingle);if(!l)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=l,this}const a=this.project.get(this.initialData.valueAsTypeSingle.id);if(!a)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=a}return this}if(this.initialData.valueAsTypeList&&Array.isArray(this.initialData.valueAsTypeList))this.valueAsTypeList=this.initialData.valueAsTypeList.map(a=>{if(a.type===f.GenericReference){const p=this.project.findSubscribedBuiltInInstanceFromReference(a);if(!p)throw new Error(`Standalone entity of type '${this.type}' with id '${this.id}' has a reference to an entity of type '${a.entityType}' with id '${a.entityId}' that is not part of the project state.`);return p}const l=this.project.get(a.id);if(!l)throw new Error(`Standalone entity of type '${this.type}' with id '${this.id}' has a reference to an entity of type '${a.type}' with id '${a.id}' that is not part of the project state.`);return l});else if(this.initialData.valueAsTypeSingle){if(this.initialData.valueAsTypeSingle.type===f.GenericReference){const l=W(this.initialData.valueAsTypeSingle),p=l?this.project.get(l):null;if(!p)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=p,this}const a=this.project.get(this.initialData.valueAsTypeSingle.id);if(!a)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=a}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,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"meta-sync"))){const l=br(this,i),p=this.toMeta();return this.name=i.name!==void 0?i.name:p.name,this.autogeneration=i.autogeneration!==void 0?i.autogeneration:p.autogeneration,this.value=i.value!==void 0?i.value:p.value,super.metaSync(i),i.deleted===!0&&!p.deleted?a==null||a.add(this,K.Removed):i.deleted===!1&&p.deleted?a==null||a.add(this,K.Added):l&&(a==null||a.add(this,K.Updated)),a==null||a.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=ye,...a){return await Et.repository.APILoad(this.id,...a),this}async APICreate(i=ye,...a){return await Et.repository.APICreate(this.toShallowJSON(),...a),this}async APIUpdate(i=ye,...a){return await Et.repository.APIUpdate(this.toShallowJSON(),...a),this}async APIDelete(i=ye,...a){return await Et.repository.APIDelete(this.toShallowJSON(),...a),this}async APIClone(i=ye,...a){return await Et.repository.APIClone(this.id,...a),this}async APILoadVersion(i=ye,a,...l){return await Et.repository.APILoadVersion(this.id,a,...l)}removeFromParent(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"remove-from-parent"))){const a=[],l=[],p=[],t=[];return this.parent&&(this.parent.type===f.DataType?this.parent.setEntity(null,i):S0.includes(this.parent.type)&&this.parent.setDefaultValue(null,i),t.push(this.parent)),i==null||i.attemptAutoclose("remove-from-parent",this.id),{added:R(p),updated:R(a),removed:R(l),affected:R(t),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"remove-entity"))){const l=[],p=[],t=[],y=[];if(a!=null&&a.hasRemoved(this.id))return a==null||a.attemptAutoclose("remove-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(p.push(this),this.unsubscribe(),this.unsubscribeFromDependencies(),this.project.subscribeDeletedInstance(this),this.metaSync({deleted:!0},a),Object.values(this.detachedDependents).forEach(v=>{const{updated:b,removed:w,added:A}=v.entity.onDetachedDependencyRemoved(this,v.field,a);l.push(...b),p.push(...w),t.push(...A)}),!i){const v=this.removeFromParent(a);t.push(...v.added),l.push(...v.updated),p.push(...v.removed),y.push(...v.affected)}return a==null||a.attemptAutoclose("remove-entity",this.id),{added:R(t),updated:R(l),removed:R(p),affected:R(y),self:this}}restore({}={},i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"restore-entity"))){const a=[],l=[],p=[],t=[];return i!=null&&i.hasAdded(this.id)?(i==null||i.attemptAutoclose("restore-entity",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:v,removed:b,added:w}=y.entity.onDetachedDependencyRestored(this,y.field,i);l.push(...v),p.push(...b),a.push(...w)}),i==null||i.attemptAutoclose("restore-entity",this.id),{added:R(a),updated:R(l),removed:R(p),affected:R(t),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(l=>l.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(l=>l.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,name:this.name}}toJSON(i=new Set){var a,l,p;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,autogeneration:this.autogeneration,value:this.value,valueAsTypeSingle:((a=this.valueAsTypeSingle)==null?void 0:a.toJSON(i))||null,valueAsTypeList:Array.isArray(this.valueAsTypeSingle)?this.valueAsTypeSingle.map(t=>t.toJSON(i)):null,parent:(l=this.parent)==null?void 0:l.toReference(),standaloneParent:(p=this.standaloneParent)==null?void 0:p.toReference()})}toJSONClone(i=Le){var l,p,t,y,v,b,w;let a;return(l=i.seenEntityMaps)!=null&&l.has(this.id)?a=i.seenEntityMaps.get(this.id):(a=i.newId||wr(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,a)),(p=i.seenEntities)!=null&&p.has(a)||(t=i.seenEntities)!=null&&t.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((y=i.seenEntities)==null||y.add(a),(v=i.seenEntities)==null||v.add(this.id),{id:a,version:P.UUID.uuid(),createdAt:i.timestamp||N().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,type:this.type,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(A=>this.project.getBuiltIn(A.id)?A.toJSON():A.toJSONClone({...i,newId:null})):null,parent:(b=this.parent)==null?void 0:b.toReference({seenEntityMaps:i.seenEntityMaps}),standaloneParent:(w=this.standaloneParent)==null?void 0:w.toReference({seenEntityMaps:i.seenEntityMaps})})}toReference(i=Le){var l;let a=this.id;return(l=i.seenEntityMaps)!=null&&l.has(this.id)&&(a=i.seenEntityMaps.get(this.id)),{id:a+"--"+P.UUID.uuid()+"--ref",type:f.GenericReference,entityId:a,version:this.version,entityType:this.type}}toShallowJSON(i=Le){var l,p,t,y;let a=this.id;return(l=i.seenEntityMaps)!=null&&l.has(this.id)&&(a=i.seenEntityMaps.get(this.id)),{id:a,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,valueAsTypeSingle:((p=this.valueAsTypeSingle)==null?void 0:p.toReference(i))||null,valueAsTypeList:Array.isArray(this.valueAsTypeSingle)?this.valueAsTypeSingle.map(v=>v.toReference(i)):null,value:this.value,autogeneration:this.autogeneration,parent:(t=this.parent)==null?void 0:t.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(l=>l.toFlatJSON(i)):[]])}toGenerationTarget(){var i,a,l;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(p=>p.id):null,value:this.value,autogeneration:this.autogeneration,parent:(a=this.parent)==null?void 0:a.id,standaloneParent:(l=this.standaloneParent)==null?void 0:l.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(l=>l.toFlatGenerationTarget(i)):[]])}clearErrors(){return this.errors=[],this}validate(){const i=M3(this);return this.errors=i,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors]}getShallowErrors(){return this.errors}clone(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"clone-entity")),a=null,l=null,p=!0){let t=Rr(a,this);const y=this.toJSON(),v=l||P.UUID.uuid();y.id=v,y.version=P.UUID.uuid(),y.createdAt=(i==null?void 0:i.timestamp)||N().toISOString(),y.author=(i==null?void 0:i.author)||"1",y.previousVersion=null,y.deleted=!1;const b=St(y,t);return b.initChildren(i),a&&b.setParent(a,null),i==null||i.add(b,K.Added),p&&b.subscribe(),i==null||i.attemptAutoclose("clone-entity",this.id),b}merge(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"merge-literal-value"))){const l=[],p=[],t=[],y=[];return this.valueAsTypeSingle!==(i==null?void 0:i.valueAsTypeSingle)&&(this.setValueAsType(i.valueAsTypeSingle,a),l.push(this)),this.value!==i.value&&(this.metaSync({value:i.value},a),l.push(this)),this.autogeneration!==i.autogeneration&&(this.metaSync({autogeneration:i.autogeneration},a),l.push(this)),this.name!==i.name&&(this.metaSync({name:i.name},a),l.push(this)),a==null||a.attemptAutoclose("merge-literal-value",this.id),{updated:R(l),added:R(p),removed:R(t),affected:R(y),self:this}}};D(Et,"repository",{APICreate:async(i,...a)=>i,APIUpdate:async(i,...a)=>i,APIDelete:async(i,...a)=>i,APIClone:async(i,...a)=>{},APILoad:async(i,...a)=>null,APILoadVersion:async(i,a,...l)=>null}),D(Et,"type",f.LiteralValue),D(Et,"USER_MANAGED_PARENT_TYPES",[f.DataType,f.InputMap,f.Property,f.ArgumentDeclaration,f.ReturnDeclaration,f.VariableDeclaration,f.VariableInstance,f.ValueDescriptor,f.OutputMap]),D(Et,"PARENT_TYPES",[...Et.USER_MANAGED_PARENT_TYPES]),D(Et,"MUTABLE_BASE_PROPERTIES",["name","autogeneration","value"]),D(Et,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),D(Et,"BASE_PROPERTIES",[...Et.MUTABLE_BASE_PROPERTIES,...Et.INMUTABLE_BASE_PROPERTIES]),D(Et,"MUTABLE_META_PROPERTIES",[...Et.MUTABLE_BASE_PROPERTIES]),D(Et,"INMUTABLE_META_PROPERTIES",[...Et.INMUTABLE_BASE_PROPERTIES]),D(Et,"META_PROPERTIES",[...Et.MUTABLE_META_PROPERTIES,...Et.INMUTABLE_META_PROPERTIES]),D(Et,"MUTABLE_UPSTREAM_PROPERTIES",[]),D(Et,"INMUTABLE_UPSTREAM_PROPERTIES",["parent"]),D(Et,"UPSTREAM_PROPERTIES",[...Et.MUTABLE_UPSTREAM_PROPERTIES,...Et.INMUTABLE_UPSTREAM_PROPERTIES]),D(Et,"MUTABLE_DOWNSTREAM_PROPERTIES",["valueAsTypeSingle","valueAsTypeList"]),D(Et,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),D(Et,"DOWNSTREAM_PROPERTIES",[...Et.MUTABLE_DOWNSTREAM_PROPERTIES,...Et.INMUTABLE_DOWNSTREAM_PROPERTIES]),D(Et,"PROPERTIES",[...Et.META_PROPERTIES,...Et.UPSTREAM_PROPERTIES,...Et.DOWNSTREAM_PROPERTIES]);let Ti=Et;function j3(d,u){var t;const i=[],a=[],l=[],p=[];if(((t=d.implements)==null?void 0:t.id)===me["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.properties.database.id){let y=d.defaultValue;if(!d.defaultValue){const v=Ti.new(u);v.name=X.EntityTemplate,v.parent=d.toReference();const b=ee(v,d.project);b.hydrateAncestors(),b.addSelfToProject(u),u==null||u.add(b,K.Added),a.push(b),b.initChildren(u),y=b}if(!y.valueAsTypeSingle){const v=Y6(d.project);v&&y.setValueAsTypeSingle(v,u)}}return{updated:R(i),added:R(a),removed:R(l),affected:R(p),self:d}}var x3=(d=>(d.PropertyImplements="property-implements",d.PropertyExtends="property-extends",d.DataTypeEntity="data-type-entity",d))(x3||{});const yt=class yt extends mr{constructor(i,a){super(i);D(this,"initialData");D(this,"id");D(this,"name");D(this,"codeName",null);D(this,"description",null);D(this,"private");D(this,"abstract");D(this,"index");D(this,"static");D(this,"required");D(this,"constant",!1);D(this,"interactive",!1);D(this,"type",f.Property);D(this,"hidden",!1);D(this,"defaultValue",null);D(this,"dataType",null);D(this,"implements",null);D(this,"extends",null);D(this,"project");D(this,"errors",[]);D(this,"parent");D(this,"detachedDependents",{});D(this,"knownVersions",null);D(this,"activeVersion",!1);D(this,"initialized",!1);D(this,"startedInitialization",!1);D(this,"suggestion",!1);D(this,"_codeNativeValueValidation",null);this.initialData=i,this.project=a,this.id=i.id,this.name=i.name,this.description=i.description,this.private=i.private,this.abstract=i.abstract,this.index=i.index,this.static=i.static,this.required=i.required||!1,this.codeName=i.codeName,this.hidden=i.hidden||!1,this.constant=i.constant||!1,this.interactive=i.interactive||!1,this.onProjectInitialized=this.onProjectInitialized.bind(this)}static new(i=null){return{id:P.UUID.uuid(),version:P.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||N().toISOString(),author:(i==null?void 0:i.author)||P.sessionAuthor,previousVersion:null,deleted:!1,type:f.Property,name:"",codeName:null,description:"",dataType:null,implements:null,extends:null,private:!1,abstract:!1,static:!1,constant:!1,interactive:!1,hidden:!1,index:0,required:!1,defaultValue:null,parent:null}}static fromGenerationTarget(i,a){const l=W(i.parent),p=a.get(l);let t=null;if(i.implements){const w=W(i.implements);t=a.get(w)}let y=null;if(i.extends){const w=W(i.extends);y=a.get(w)}const v={id:i.id,version:P.UUID.uuid(),createdAt:N().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,name:i.name,type:f.Property,index:p.properties.length,private:i.private||!1,abstract:i.abstract||!1,static:i.static||!1,required:i.required||!1,constant:i.constant||!1,interactive:i.interactive||!1,hidden:!1,codeName:i.codeName||null,description:i.description||null,defaultValue:null,implements:t,extends:y,dataType:null,parent:p},b=ee(v,a);return b.setParent(p,null),b}static validateGenerationTarget(i,a){let l=JSON.parse(JSON.stringify(i));const p=[],t=ahe(l,a),y=db(l,a);return p.push(...t,...y,...Tr(l)),{errors:p,modifiedData:l}}get isExtendedProperty(){const i=this.parent.allBasePropertiesFromExtendedAndImplementedEntities.find(a=>{var l;return a.id===((l=this.extends)==null?void 0:l.id)});return!!i&&i.id!==this.id&&!i.abstract}get codeNativeValueValidation(){var i;return this._codeNativeValueValidation||((i=this.implements)==null?void 0:i.codeNativeValueValidation)||null}validateGeneratedUpdate(i){const a=[];return i.parent&&a.push(new Q({id:`${this.id}--${q.InvalidParentUpdate}`,code:q.InvalidParentUpdate,severity:Z.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.
46
+ 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.`,issue:null})),{errors:a,modifiedData:i}}subscribeDependents(i){return i.forEach(a=>{this.detachedDependents[a.entity.id]||(this.detachedDependents[a.entity.id]=a)}),this}unsubscribeDependents(i){return i.forEach(a=>{this.detachedDependents[a.entity.id]&&delete this.detachedDependents[a.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"sync-dependents"))){const a=[],l=[],p=[],t=[];return Object.values(this.detachedDependents).forEach(y=>{const v=y.entity.afterAllChildrenInitialized(i);a.push(...v.updated),l.push(...v.added),p.push(...v.removed),t.push(...v.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}onDetachedDependencyRemoved(i,a,l){const p=[],t=[],y=[],v=[];return a==="value-as-type-single"&&(this.valueAsTypeSingle=null,l==null||l.add(this,K.Updated)),a==="value-as-type-list"&&(this.valueAsTypeList=(this.valueAsTypeList||[]).filter(b=>b.id!==i.id),l==null||l.add(this,K.Updated)),{updated:R(p),added:R(t),removed:R(y),affected:R(v),self:this}}onDetachedDependencyRestored(i,a,l){const p=[],t=[],y=[],v=[];return a==="value-as-type-single"&&(this.valueAsTypeSingle=i,l==null||l.add(this,K.Updated)),a==="value-as-type-list"&&(this.valueAsTypeList=[...Array.isArray(this.valueAsTypeList||[])?this.valueAsTypeList:[],i],l==null||l.add(this,K.Updated)),{updated:R(p),added:R(t),removed:R(y),affected:R(v),self:this}}unsubscribeFromDependencies(){return this.valueAsTypeSingle&&this.valueAsTypeSingle.type!==f.BuiltInBaseEntity&&this.valueAsTypeSingle.unsubscribeDependents([{entity:this,field:"value-as-type-single"}]),this.valueAsTypeList&&Array.isArray(this.valueAsTypeList)&&this.valueAsTypeList.forEach(i=>{i.type!==f.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!==f.BuiltInBaseEntity&&i.subscribeDependents([{entity:this,field:"value-as-type-list"}])}):this.valueAsTypeSingle&&this.valueAsTypeSingle.type!==f.BuiltInBaseEntity&&this.valueAsTypeSingle.subscribeDependents([{entity:this,field:"value-as-type-single"}]),this)}increaseVersion(i){if(i&&!N(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&N(i).isSame(N(this.createdAt))?this:(this.previousVersion=this.version,this.version=P.UUID.uuid(),this.createdAt=N(i).toISOString()||N().toISOString(),this)}captureVersion(){var a;const i=((a=this.knownVersions)==null?void 0:a.get(this.version))||new Et(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 a=[],l=[],p=[],t=[];if(this.parent){this.parent.increaseVersion(i);const y=this.parent.recursiveCaptureUpstreamVersions(i);a.push(this.parent,...y.updated),l.push(...y.added),p.push(...y.removed)}return{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}async restoreVersion(i){var v;const a=[],l=[],p=[],t=[];if(this.version===i)return{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this};if(!this.knownVersions){const b=new Map;for(const[w,A]of this.knownVersions||new Map){if(b.set(w,A),A.activeVersion=!1,A.knownVersions)for(const[V,L]of A.knownVersions)b.set(V,L);A.knownVersions=null}}let y=(v=this.knownVersions)==null?void 0:v.get(i);if(!y){const b=await this.APILoadVersion({},i);if(!b)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);y=new Et(b,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:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}updateWithShallowTransfer(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"update-with-shallow-transfer"))){if(this.metaSync(i,a),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 l=W(i.parent),p=this.project.get(l),t=this.parent;if(t&&t.id!==(p==null?void 0:p.id)&&this.removeFromParent(a),p)this.setParent(p,null);else throw new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${l}' that isn't found in the project`)}else if(i.standaloneParent){const l=W(i.standaloneParent),p=this.project.get(l);if(p)this.setStandaloneParent(p);else throw new Error(`${this.type} with id '${this.id}' has a 'standaloneParent' reference '${l}' 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(l=>{const p=W(l),t=this.project.get(p);t&&this.valueAsTypeList.push(t)});else if(i.valueAsTypeSingle){const l=W(i.valueAsTypeSingle),p=this.project.get(l);p&&(this.valueAsTypeSingle=p)}return this.captureVersion(),this.subscribeToDependencies(),a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),this}hydrateAncestors(){const i=[],a=[],l=[],p=[];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 t=W(this.initialData.parent),y=this.project.get(t);if(y)this.setParent(y,null),i.push(y);else throw new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${t}' that isn't found in the project`)}else if(this.initialData.standaloneParent){const t=W(this.initialData.standaloneParent),y=this.project.get(t);if(y)this.setStandaloneParent(y);else throw new Error(`${this.type} with id '${this.id}' has a 'standaloneParent' reference '${t}' that isn't found in the project`)}else throw 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(t=>{const y=W(t),v=this.project.get(y);v&&this.valueAsTypeList.push(v)});else if(this.initialData.valueAsTypeSingle){const t=W(this.initialData.valueAsTypeSingle),y=this.project.get(t);y&&(this.valueAsTypeSingle=y)}return{updated:R(i),added:R(a),removed:R(l),affected:R(p),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"after-all-children-initialized"))){const a=[],l=[],p=[],t=[];return this.initialized=!0,this.captureVersion(),i==null||i.attemptAutoclose("after-all-children-initialized",this.id),{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}addSelfToProject(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"add-self-to-project"))){var y,v;const a=[this],l=[],p=[],t=[];return((y=this.parent)==null?void 0:y.type)===f.DataType?this.parent.setEntity(this,i):(v=this.parent)==null||v.setDefaultValue(this,i),t.push(this.parent),this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}setParent(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"set-parent"))){var l;return((l=this.parent)==null?void 0:l.id)!==(i==null?void 0:i.id)&&(this.parent=i,a&&(a==null||a.add(this,K.Updated))),a==null||a.attemptAutoclose("set-parent",this.id),this}setStandaloneParent(i){return this.standaloneParent=i,this}setValueAsTypeSingle(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"set-value-as-type-single"))){return this.valueAsTypeSingle!==i&&(this.valueAsTypeSingle=i,a==null||a.add(this,K.Updated)),a==null||a.attemptAutoclose("set-value-as-type-single",this.id),this}setValueAsTypeList(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"set-value-as-type-list"))){var l,p;return!i&&this.valueAsTypeList?(this.valueAsTypeList=null,a==null||a.add(this,K.Updated)):i&&!this.valueAsTypeList?(this.valueAsTypeList=i,a==null||a.add(this,K.Updated)):i&&this.valueAsTypeList&&((l=this.valueAsTypeList)==null?void 0:l.length)!==i.length?(this.valueAsTypeList=i,a==null||a.add(this,K.Updated)):i&&this.valueAsTypeList&&((p=this.valueAsTypeList)!=null&&p.every((t,y)=>t!==i[y]))&&(this.valueAsTypeList=i,a==null||a.add(this,K.Updated)),a==null||a.attemptAutoclose("set-value-as-type-list",this.id),this}setValueAsType(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"set-value-as-type"))){return i?(Array.isArray(i)?this.setValueAsTypeList(i,a):this.setValueAsTypeSingle(i,a),a==null||a.attemptAutoclose("set-value-as-type",this.id),this):(this.setValueAsTypeSingle(null,a),this.setValueAsTypeList(null,a),this)}initChildren(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().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(a=>{if(a.type===f.GenericReference){const p=this.project.findSubscribedBuiltInInstanceFromReference(a);if(!p)throw new Error(`Standalone entity of type '${this.type}' with id '${this.id}' has a reference to an entity of type '${a.entityType}' with id '${a.entityId}' that is not part of the project state.`);return p}const l=this.project.get(a.id);if(!l)throw new Error(`Standalone entity of type '${this.type}' with id '${this.id}' has a reference to an entity of type '${a.type}' with id '${a.id}' that is not part of the project state.`);return l});else if(this.initialData.valueAsTypeSingle){if(this.initialData.valueAsTypeSingle.type===f.GenericReference){const l=this.project.findSubscribedBuiltInInstanceFromReference(this.initialData.valueAsTypeSingle);if(!l)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=l,this}const a=this.project.get(this.initialData.valueAsTypeSingle.id);if(!a)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=a}return this}if(this.initialData.valueAsTypeList&&Array.isArray(this.initialData.valueAsTypeList))this.valueAsTypeList=this.initialData.valueAsTypeList.map(a=>{if(a.type===f.GenericReference){const p=this.project.findSubscribedBuiltInInstanceFromReference(a);if(!p)throw new Error(`Standalone entity of type '${this.type}' with id '${this.id}' has a reference to an entity of type '${a.entityType}' with id '${a.entityId}' that is not part of the project state.`);return p}const l=this.project.get(a.id);if(!l)throw new Error(`Standalone entity of type '${this.type}' with id '${this.id}' has a reference to an entity of type '${a.type}' with id '${a.id}' that is not part of the project state.`);return l});else if(this.initialData.valueAsTypeSingle){if(this.initialData.valueAsTypeSingle.type===f.GenericReference){const l=W(this.initialData.valueAsTypeSingle),p=l?this.project.get(l):null;if(!p)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=p,this}const a=this.project.get(this.initialData.valueAsTypeSingle.id);if(!a)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=a}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,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"meta-sync"))){const l=br(this,i),p=this.toMeta();return this.name=i.name!==void 0?i.name:p.name,this.autogeneration=i.autogeneration!==void 0?i.autogeneration:p.autogeneration,this.value=i.value!==void 0?i.value:p.value,super.metaSync(i),i.deleted===!0&&!p.deleted?a==null||a.add(this,K.Removed):i.deleted===!1&&p.deleted?a==null||a.add(this,K.Added):l&&(a==null||a.add(this,K.Updated)),a==null||a.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=ye,...a){return await Et.repository.APILoad(this.id,...a),this}async APICreate(i=ye,...a){return await Et.repository.APICreate(this.toShallowJSON(),...a),this}async APIUpdate(i=ye,...a){return await Et.repository.APIUpdate(this.toShallowJSON(),...a),this}async APIDelete(i=ye,...a){return await Et.repository.APIDelete(this.toShallowJSON(),...a),this}async APIClone(i=ye,...a){return await Et.repository.APIClone(this.id,...a),this}async APILoadVersion(i=ye,a,...l){return await Et.repository.APILoadVersion(this.id,a,...l)}removeFromParent(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"remove-from-parent"))){const a=[],l=[],p=[],t=[];return this.parent&&(this.parent.type===f.DataType?this.parent.setEntity(null,i):S0.includes(this.parent.type)&&this.parent.setDefaultValue(null,i),t.push(this.parent)),i==null||i.attemptAutoclose("remove-from-parent",this.id),{added:R(p),updated:R(a),removed:R(l),affected:R(t),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"remove-entity"))){const l=[],p=[],t=[],y=[];if(a!=null&&a.hasRemoved(this.id))return a==null||a.attemptAutoclose("remove-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(p.push(this),this.unsubscribe(),this.unsubscribeFromDependencies(),this.project.subscribeDeletedInstance(this),this.metaSync({deleted:!0},a),Object.values(this.detachedDependents).forEach(v=>{const{updated:b,removed:w,added:A}=v.entity.onDetachedDependencyRemoved(this,v.field,a);l.push(...b),p.push(...w),t.push(...A)}),!i){const v=this.removeFromParent(a);t.push(...v.added),l.push(...v.updated),p.push(...v.removed),y.push(...v.affected)}return a==null||a.attemptAutoclose("remove-entity",this.id),{added:R(t),updated:R(l),removed:R(p),affected:R(y),self:this}}restore({}={},i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"restore-entity"))){const a=[],l=[],p=[],t=[];return i!=null&&i.hasAdded(this.id)?(i==null||i.attemptAutoclose("restore-entity",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:v,removed:b,added:w}=y.entity.onDetachedDependencyRestored(this,y.field,i);l.push(...v),p.push(...b),a.push(...w)}),i==null||i.attemptAutoclose("restore-entity",this.id),{added:R(a),updated:R(l),removed:R(p),affected:R(t),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(l=>l.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(l=>l.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,name:this.name}}toJSON(i=new Set){var a,l,p;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,autogeneration:this.autogeneration,value:this.value,valueAsTypeSingle:((a=this.valueAsTypeSingle)==null?void 0:a.toJSON(i))||null,valueAsTypeList:Array.isArray(this.valueAsTypeSingle)?this.valueAsTypeSingle.map(t=>t.toJSON(i)):null,parent:(l=this.parent)==null?void 0:l.toReference(),standaloneParent:(p=this.standaloneParent)==null?void 0:p.toReference()})}toJSONClone(i=Le){var l,p,t,y,v,b,w;let a;return(l=i.seenEntityMaps)!=null&&l.has(this.id)?a=i.seenEntityMaps.get(this.id):(a=i.newId||wr(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,a)),(p=i.seenEntities)!=null&&p.has(a)||(t=i.seenEntities)!=null&&t.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((y=i.seenEntities)==null||y.add(a),(v=i.seenEntities)==null||v.add(this.id),{id:a,version:P.UUID.uuid(),createdAt:i.timestamp||N().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,type:this.type,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(A=>this.project.getBuiltIn(A.id)?A.toJSON():A.toJSONClone({...i,newId:null})):null,parent:(b=this.parent)==null?void 0:b.toReference({seenEntityMaps:i.seenEntityMaps}),standaloneParent:(w=this.standaloneParent)==null?void 0:w.toReference({seenEntityMaps:i.seenEntityMaps})})}toReference(i=Le){var l;let a=this.id;return(l=i.seenEntityMaps)!=null&&l.has(this.id)&&(a=i.seenEntityMaps.get(this.id)),{id:a+"--"+P.UUID.uuid()+"--ref",type:f.GenericReference,entityId:a,version:this.version,entityType:this.type}}toShallowJSON(i=Le){var l,p,t,y;let a=this.id;return(l=i.seenEntityMaps)!=null&&l.has(this.id)&&(a=i.seenEntityMaps.get(this.id)),{id:a,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,valueAsTypeSingle:((p=this.valueAsTypeSingle)==null?void 0:p.toReference(i))||null,valueAsTypeList:Array.isArray(this.valueAsTypeSingle)?this.valueAsTypeSingle.map(v=>v.toReference(i)):null,value:this.value,autogeneration:this.autogeneration,parent:(t=this.parent)==null?void 0:t.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(l=>l.toFlatJSON(i)):[]])}toGenerationTarget(){var i,a,l;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(p=>p.id):null,value:this.value,autogeneration:this.autogeneration,parent:(a=this.parent)==null?void 0:a.id,standaloneParent:(l=this.standaloneParent)==null?void 0:l.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(l=>l.toFlatGenerationTarget(i)):[]])}clearErrors(){return this.errors=[],this}validate(){const i=M3(this);return this.errors=i,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors]}getShallowErrors(){return this.errors}clone(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"clone-entity")),a=null,l=null,p=!0){let t=Rr(a,this);const y=this.toJSON(),v=l||P.UUID.uuid();y.id=v,y.version=P.UUID.uuid(),y.createdAt=(i==null?void 0:i.timestamp)||N().toISOString(),y.author=(i==null?void 0:i.author)||"1",y.previousVersion=null,y.deleted=!1;const b=St(y,t);return b.initChildren(i),a&&b.setParent(a,null),i==null||i.add(b,K.Added),p&&b.subscribe(),i==null||i.attemptAutoclose("clone-entity",this.id),b}merge(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"merge-literal-value"))){const l=[],p=[],t=[],y=[];return this.valueAsTypeSingle!==(i==null?void 0:i.valueAsTypeSingle)&&(this.setValueAsType(i.valueAsTypeSingle,a),l.push(this)),this.value!==i.value&&(this.metaSync({value:i.value},a),l.push(this)),this.autogeneration!==i.autogeneration&&(this.metaSync({autogeneration:i.autogeneration},a),l.push(this)),this.name!==i.name&&(this.metaSync({name:i.name},a),l.push(this)),a==null||a.attemptAutoclose("merge-literal-value",this.id),{updated:R(l),added:R(p),removed:R(t),affected:R(y),self:this}}};D(Et,"repository",{APICreate:async(i,...a)=>i,APIUpdate:async(i,...a)=>i,APIDelete:async(i,...a)=>i,APIClone:async(i,...a)=>{},APILoad:async(i,...a)=>null,APILoadVersion:async(i,a,...l)=>null}),D(Et,"type",f.LiteralValue),D(Et,"USER_MANAGED_PARENT_TYPES",[f.DataType,f.InputMap,f.Property,f.ArgumentDeclaration,f.ReturnDeclaration,f.VariableDeclaration,f.VariableInstance,f.ValueDescriptor,f.OutputMap]),D(Et,"PARENT_TYPES",[...Et.USER_MANAGED_PARENT_TYPES]),D(Et,"MUTABLE_BASE_PROPERTIES",["name","autogeneration","value"]),D(Et,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),D(Et,"BASE_PROPERTIES",[...Et.MUTABLE_BASE_PROPERTIES,...Et.INMUTABLE_BASE_PROPERTIES]),D(Et,"MUTABLE_META_PROPERTIES",[...Et.MUTABLE_BASE_PROPERTIES]),D(Et,"INMUTABLE_META_PROPERTIES",[...Et.INMUTABLE_BASE_PROPERTIES]),D(Et,"META_PROPERTIES",[...Et.MUTABLE_META_PROPERTIES,...Et.INMUTABLE_META_PROPERTIES]),D(Et,"MUTABLE_UPSTREAM_PROPERTIES",[]),D(Et,"INMUTABLE_UPSTREAM_PROPERTIES",["parent"]),D(Et,"UPSTREAM_PROPERTIES",[...Et.MUTABLE_UPSTREAM_PROPERTIES,...Et.INMUTABLE_UPSTREAM_PROPERTIES]),D(Et,"MUTABLE_DOWNSTREAM_PROPERTIES",["valueAsTypeSingle","valueAsTypeList"]),D(Et,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),D(Et,"DOWNSTREAM_PROPERTIES",[...Et.MUTABLE_DOWNSTREAM_PROPERTIES,...Et.INMUTABLE_DOWNSTREAM_PROPERTIES]),D(Et,"PROPERTIES",[...Et.META_PROPERTIES,...Et.UPSTREAM_PROPERTIES,...Et.DOWNSTREAM_PROPERTIES]);let Ti=Et;function j3(d,u){var t;const i=[],a=[],l=[],p=[];if(((t=d.implements)==null?void 0:t.id)===me["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.properties.database.id){let y=d.defaultValue;if(!d.defaultValue){const v=Ti.new(u);v.name=X.EntityTemplate,v.parent=d.toReference();const b=ee(v,d.project);b.hydrateAncestors(),b.addSelfToProject(u),u==null||u.add(b,K.Added),a.push(b),b.initChildren(u),y=b}if(!y.valueAsTypeSingle){const v=Y6(d.project);v&&y.setValueAsTypeSingle(v,u)}}return{updated:R(i),added:R(a),removed:R(l),affected:R(p),self:d}}var x3=(d=>(d.PropertyImplements="property-implements",d.PropertyExtends="property-extends",d.DataTypeEntity="data-type-entity",d))(x3||{});const yt=class yt extends mr{constructor(i,a){super(i);D(this,"initialData");D(this,"id");D(this,"name");D(this,"codeName",null);D(this,"description",null);D(this,"private");D(this,"abstract");D(this,"index");D(this,"static");D(this,"required");D(this,"constant",!1);D(this,"interactive",!1);D(this,"type",f.Property);D(this,"hidden",!1);D(this,"defaultValue",null);D(this,"dataType",null);D(this,"implements",null);D(this,"extends",null);D(this,"project");D(this,"errors",[]);D(this,"parent");D(this,"detachedDependents",{});D(this,"knownVersions",null);D(this,"activeVersion",!1);D(this,"initialized",!1);D(this,"startedInitialization",!1);D(this,"suggestion",!1);D(this,"_codeNativeValueValidation",null);this.initialData=i,this.project=a,this.id=i.id,this.name=i.name,this.description=i.description,this.private=i.private,this.abstract=i.abstract,this.index=i.index,this.static=i.static,this.required=i.required||!1,this.codeName=i.codeName,this.hidden=i.hidden||!1,this.constant=i.constant||!1,this.interactive=i.interactive||!1,this.onProjectInitialized=this.onProjectInitialized.bind(this)}static new(i=null){return{id:P.UUID.uuid(),version:P.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||N().toISOString(),author:(i==null?void 0:i.author)||P.sessionAuthor,previousVersion:null,deleted:!1,type:f.Property,name:"",codeName:null,description:"",dataType:null,implements:null,extends:null,private:!1,abstract:!1,static:!1,constant:!1,interactive:!0,hidden:!1,index:0,required:!1,defaultValue:null,parent:null}}static fromGenerationTarget(i,a){const l=W(i.parent),p=a.get(l);let t=null;if(i.implements){const w=W(i.implements);t=a.get(w)}let y=null;if(i.extends){const w=W(i.extends);y=a.get(w)}const v={id:i.id,version:P.UUID.uuid(),createdAt:N().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,name:i.name,type:f.Property,index:p.properties.length,private:i.private||!1,abstract:i.abstract||!1,static:i.static||!1,required:i.required||!1,constant:i.constant||!1,interactive:i.interactive||!1,hidden:!1,codeName:i.codeName||null,description:i.description||null,defaultValue:null,implements:t,extends:y,dataType:null,parent:p},b=ee(v,a);return b.setParent(p,null),b}static validateGenerationTarget(i,a){let l=JSON.parse(JSON.stringify(i));const p=[],t=ahe(l,a),y=db(l,a);return p.push(...t,...y,...Tr(l)),{errors:p,modifiedData:l}}get isExtendedProperty(){const i=this.parent.allBasePropertiesFromExtendedAndImplementedEntities.find(a=>{var l;return a.id===((l=this.extends)==null?void 0:l.id)});return!!i&&i.id!==this.id&&!i.abstract}get codeNativeValueValidation(){var i;return this._codeNativeValueValidation||((i=this.implements)==null?void 0:i.codeNativeValueValidation)||null}validateGeneratedUpdate(i){const a=[];return i.parent&&a.push(new Q({id:`${this.id}--${q.InvalidParentUpdate}`,code:q.InvalidParentUpdate,severity:Z.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.
47
47
  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.`,issue:null})),(i.readsValue||i.writesValue)&&a.push(new Q({id:`${this.id}--${le.InvalidObjectStructure}`,code:le.InvalidObjectStructure,severity:Z.Error,message:`Entity of type '${this.type}' with id '${this.id}' is not a value reading or writing entity.
48
48
  ${gy}`,issue:null})),{errors:a,modifiedData:i}}onProjectInitialized(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,new Date().toISOString(),this,!0,"on-property-received-project-initialized"))){return j3(this,a),a==null||a.attemptAutoclose("on-property-received-project-initialized",this.id),this}subscribeDependents(i){return i.forEach(a=>{this.detachedDependents[a.entity.id]||(this.detachedDependents[a.entity.id]=a)}),this}unsubscribeDependents(i){return i.forEach(a=>{this.detachedDependents[a.entity.id]&&delete this.detachedDependents[a.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"sync-dependents"))){const a=[],l=[],p=[],t=[];return Object.values(this.detachedDependents).forEach(y=>{const v=y.entity.afterAllChildrenInitialized(i);a.push(...v.updated),l.push(...v.added),p.push(...v.removed),t.push(...v.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}onDetachedDependencyRemoved(i,a,l){const p=[],t=[],y=[],v=[];if(a==="property-implements"&&(this.setImplements(null,l),p.push(this)),a==="property-extends"){const{updated:b,added:w,removed:A,affected:V}=this.remove({ignoreUpstream:!1},l);p.push(...b),t.push(...w),y.push(...A),v.push(...V)}return{updated:R(p),added:R(t),removed:R(y),affected:R(v),self:this}}onDetachedDependencyRestored(i,a,l){const p=[],t=[],y=[],v=[];if(a==="property-implements"&&(this.setImplements(i,l),p.push(this)),a==="property-extends"){const{updated:b,added:w,removed:A,affected:V}=this.restore({},l);p.push(...b),t.push(...w),y.push(...A),v.push(...V)}return{updated:R(p),added:R(t),removed:R(y),affected:R(v),self:this}}unsubscribeFromDependencies(){var i,a,l,p,t,y,v;return(a=(i=this.implements)==null?void 0:i.unsubscribeDependents)==null||a.call(i,[{entity:this,field:"property-implements"}]),(p=(l=this.extends)==null?void 0:l.unsubscribeDependents)==null||p.call(l,[{entity:this,field:"property-extends"}]),(v=(y=(t=this.dataType)==null?void 0:t.entity)==null?void 0:y.unsubscribeDependents)==null||v.call(y,[{entity:this,field:"data-type-entity"}]),this.project.off(vr.PROJECT_INITIALIZED,this.onProjectInitialized),this}subscribeToDependencies(){var i,a,l,p,t,y,v;return(a=(i=this.implements)==null?void 0:i.subscribeDependents)==null||a.call(i,[{entity:this,field:"property-implements"}]),(p=(l=this.extends)==null?void 0:l.subscribeDependents)==null||p.call(l,[{entity:this,field:"property-extends"}]),(v=(y=(t=this.dataType)==null?void 0:t.entity)==null?void 0:y.subscribeDependents)==null||v.call(y,[{entity:this,field:"data-type-entity"}]),this.project.on(vr.PROJECT_INITIALIZED,this.onProjectInitialized),this}increaseVersion(i){if(i&&!N(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&N(i).isSame(N(this.createdAt))?this:(this.previousVersion=this.version,this.version=P.UUID.uuid(),this.createdAt=N(i).toISOString()||N().toISOString(),this)}captureVersion(){var a;const i=((a=this.knownVersions)==null?void 0:a.get(this.version))||new yt(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.defaultValue=this.defaultValue,i.dataType=this.dataType,i.implements=this.implements,i.extends=this.extends,i.parent=this.parent,this}recursiveCaptureUpstreamVersions(i){const a=[],l=[],p=[],t=[];if(this.parent&&this.parent.type!==f.PrimitiveEntity&&this.parent.type!==f.BuiltInBaseEntity){this.parent.increaseVersion(i);const y=this.parent.recursiveCaptureUpstreamVersions(i);a.push(this.parent,...y.updated),l.push(...y.added),p.push(...y.removed)}return{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}async restoreVersion(i){var v;const a=[],l=[],p=[],t=[];if(this.version===i)return{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this};if(!this.knownVersions){const b=new Map;for(const[w,A]of this.knownVersions||new Map){if(b.set(w,A),A.activeVersion=!1,A.knownVersions)for(const[V,L]of A.knownVersions)b.set(V,L);A.knownVersions=null}}let y=(v=this.knownVersions)==null?void 0:v.get(i);if(!y){const b=await this.APILoadVersion({},i);if(!b)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);y=new yt(b,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.defaultValue=y.defaultValue,this.dataType=y.dataType,this.implements=y.implements,this.parent=y.parent,{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}updateWithShallowTransfer(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"update-with-shallow-transfer"))){if(this.metaSync(i,a),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 l=W(i.parent),p=this.project.get(l),t=this.parent;if(t&&t.id!==(p==null?void 0:p.id)&&this.removeFromParent(a),p)this.setParent(p,null);else throw a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${l}' that isn't found in the project`)}else throw a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(i.implements){const l=W(i.implements),p=this.project.get(l);if(p)this.setImplements(p,a);else if(l)throw new Error(`${ei(this.type)} with id '${this.id}' has a 'implements' reference "${l}" which is missing in the project`)}if(i.extends){const l=W(i.extends),p=this.project.get(l);if(p)this.setExtends(p,a);else if(l)throw new Error(`${ei(this.type)} with id '${this.id}' has a 'extends' reference "${l}" which is missing in the project`)}return this.captureVersion(),this.subscribeToDependencies(),a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),this}hydrateAncestors(){const i=[],a=[],l=[],p=[];if(this.initialData.parent){const t=W(this.initialData.parent),y=this.project.get(t);if(y)this.setParent(y,null);else throw new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${t}' that isn't found in the project`)}else throw new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(this.initialData.implements){const t=W(this.initialData.implements),y=this.project.get(t);if(y)this.setImplements(y,null),i.push(y);else if(t)throw new Error(`${ei(this.type)} with id '${this.id}' has a 'implements' reference "${t}" which is missing in the project`)}if(this.initialData.extends){const t=W(this.initialData.extends),y=this.project.get(t);if(y)this.setExtends(y,null),i.push(y);else if(t)throw new Error(`${ei(this.type)} with id '${this.id}' has a 'extends' reference "${t}" which is missing in the project`)}return{updated:R(i),added:R(a),removed:R(l),affected:R(p),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"after-all-children-initialized"))){const a=[],l=[],p=[],t=[];this.initialized=!0;const{updated:y,added:v,removed:b,affected:w}=this.syncWithImplementation(i);a.push(...y),l.push(...v),p.push(...b),t.push(...w);const{updated:A,added:V,removed:L,affected:j}=j3(this,i);return a.push(...A),l.push(...V),p.push(...L),t.push(...j),this.captureVersion(),i==null||i.attemptAutoclose("after-all-children-initialized",this.id),{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}addSelfToProject(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"add-self-to-project"))){const a=[this],l=[],p=[],t=[];return this.parent.addProperty(this),a.push(this.parent),this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}setParent(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"set-parent"))){var l;return((l=this.parent)==null?void 0:l.id)!==(i==null?void 0:i.id)&&(this.parent=i,a&&(a==null||a.add(this,K.Updated))),a==null||a.attemptAutoclose("set-parent",this.id),this}setImplements(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"set-implements"))){var l;return((l=this.implements)==null?void 0:l.id)!==(i==null?void 0:i.id)&&(this.implements=i,a&&(a==null||a.add(this,K.Updated))),a==null||a.attemptAutoclose("set-implements",this.id),this}setExtends(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"set-extends"))){var l;return((l=this.extends)==null?void 0:l.id)!==(i==null?void 0:i.id)&&(this.extends=i,a&&(a==null||a.add(this,K.Updated))),a==null||a.attemptAutoclose("set-extends",this.id),this}initChildren(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"init-children"))){if(this.initialized||this.startedInitialization)return this;if(this.startedInitialization=!0,this.initialData.defaultValue&&(this.defaultValue=ee(this.initialData.defaultValue,this.project),this.defaultValue.setParent(this,null),this.defaultValue.initChildren(i)),this.initialData.dataType){const a=ee(this.initialData.dataType,this.project);a.setParent(this,null),a.initChildren(i),this.dataType=a}if(this.initialData.implements){const a=ee(this.initialData.implements,this.project);this.setImplements(a,null)}if(this.initialData.extends){const a=ee(this.initialData.extends,this.project);this.setExtends(a,null)}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,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"meta-sync"))){const l=br(this,i),p=this.toMeta();return this.name=i.name!==void 0?i.name:p.name,this.codeName=i.codeName!==void 0?i.codeName:p.codeName,this.description=i.description!==void 0?i.description:p.description,this.abstract=i.abstract!==void 0?i.abstract:p.abstract,this.private=i.private!==void 0?i.private:p.private,this.index=i.index||(i.index!==0?p.index:0),this.static=i.static!==void 0?i.static:p.static,this.hidden=i.hidden!==void 0?i.hidden:p.hidden,this.constant=i.constant!==void 0?i.constant:p.constant,this.interactive=i.interactive!==void 0?i.interactive:p.interactive,this.required=i.required!==void 0?i.required:p.required,super.metaSync(i),i.deleted===!0&&!p.deleted?a==null||a.add(this,K.Removed):i.deleted===!1&&p.deleted?a==null||a.add(this,K.Added):l&&(a==null||a.add(this,K.Updated)),a==null||a.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=ye,...a){return await yt.repository.APILoad(this.id,...a),this}async APICreate(i=ye,...a){return await yt.repository.APICreate(this.toShallowJSON(),...a),this}async APIUpdate(i=ye,...a){return await yt.repository.APIUpdate(this.toShallowJSON(),...a),this}async APIDelete(i=ye,...a){return await yt.repository.APIDelete(this.toShallowJSON(),...a),this}async APIClone(i=ye,...a){return await yt.repository.APIClone(this.id,...a),this}async APILoadVersion(i=ye,a,...l){return await yt.repository.APILoadVersion(this.id,a,...l)}removeFromParent(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"remove-from-parent"))){const a=[],l=[],p=[],t=[];return this.parent.type===f.DefinitionEntity&&(this.parent.removeProperty(this),t.push(this.parent)),i==null||i.attemptAutoclose("remove-from-parent",this.id),{added:R(p),updated:R(a),removed:R(l),affected:R(t),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"remove-entity"))){const l=[],p=[],t=[],y=[];if(a!=null&&a.hasRemoved(this.id))return a==null||a.attemptAutoclose("remove-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(p.push(this),this.unsubscribe(),this.unsubscribeFromDependencies(),this.project.subscribeDeletedInstance(this),this.metaSync({deleted:!0},a),Object.values(this.detachedDependents).forEach(v=>{const{updated:b,removed:w,added:A}=v.entity.onDetachedDependencyRemoved(this,v.field,a);l.push(...b),p.push(...w),t.push(...A)}),this.defaultValue){const{updated:v,removed:b}=this.defaultValue.remove({ignoreUpstream:!0},a);l.push(...v),p.push(...b)}if(this.dataType){const{updated:v,removed:b}=this.dataType.remove({ignoreUpstream:!0},a);l.push(...v),p.push(...b)}if(!i){const v=this.removeFromParent(a);t.push(...v.added),l.push(...v.updated),p.push(...v.removed),y.push(...v.affected)}return a==null||a.attemptAutoclose("remove-entity",this.id),{added:R(t),updated:R(l),removed:R(p),affected:R(y),self:this}}restore({}={},i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"restore-entity"))){const a=[],l=[],p=[],t=[];if(i!=null&&i.hasAdded(this.id))return i==null||i.attemptAutoclose("restore-entity",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:v,removed:b,added:w}=y.entity.onDetachedDependencyRestored(this,y.field,i);l.push(...v),p.push(...b),a.push(...w)}),this.defaultValue){const{updated:y}=this.defaultValue.restore({},i);l.push(...y)}if(this.dataType){const{updated:y}=this.dataType.restore({},i);l.push(...y)}return this.parent.type===f.DefinitionEntity&&(this.parent.addProperty(this),t.push(this.parent)),i==null||i.attemptAutoclose("restore-entity",this.id),{added:R(a),updated:R(l),removed:R(p),affected:R(t),self:this}}toFlat(i=new Set){var l,p;return i.has(this.id)?[]:(i.add(this.id),[this,...((l=this.defaultValue)==null?void 0:l.toFlat(i))||[],...((p=this.dataType)==null?void 0:p.toFlat(i))||[],...this.parent.toFlat(i)])}toFlatIds(i=new Set){var l,p;return i.has(this.id)?[]:(i.add(this.id),[this.id,...((l=this.defaultValue)==null?void 0:l.toFlatIds(i))||[],...((p=this.dataType)==null?void 0:p.toFlatIds(i))||[],...this.parent.toFlatIds(i)])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,codeName:this.codeName,description:this.description,index:this.index,hidden:this.hidden,private:this.private,abstract:this.abstract,required:this.required,constant:this.constant,interactive:this.interactive,static:this.static,type:this.type,name:this.name}}toJSON(i=new Set){var a,l,p,t;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,codeName:this.codeName,description:this.description,index:this.index,private:this.private,required:this.required,static:this.static,constant:this.constant,interactive:this.interactive,abstract:this.abstract,hidden:this.hidden,defaultValue:((a=this.defaultValue)==null?void 0:a.toJSON(i))||null,dataType:((l=this.dataType)==null?void 0:l.toJSON(i))||null,implements:((p=this.implements)==null?void 0:p.toJSON(i))||null,extends:((t=this.extends)==null?void 0:t.toJSON(i))||null,parent:this.parent.toReference()})}toJSONClone(i=Le){var l,p,t,y,v,b,w;let a;return(l=i.seenEntityMaps)!=null&&l.has(this.id)?a=i.seenEntityMaps.get(this.id):(a=i.newId||wr(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,a)),(p=i.seenEntities)!=null&&p.has(a)||(t=i.seenEntities)!=null&&t.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((y=i.seenEntities)==null||y.add(a),(v=i.seenEntities)==null||v.add(this.id),{id:a,version:P.UUID.uuid(),createdAt:i.timestamp||N().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,type:this.type,name:this.name,codeName:this.codeName,description:this.description,index:this.index,private:this.private,required:this.required,static:this.static,constant:this.constant,interactive:this.interactive,abstract:this.abstract,hidden:this.hidden,defaultValue:((b=this.defaultValue)==null?void 0:b.toJSONClone({...i,newId:null}))||null,dataType:((w=this.dataType)==null?void 0:w.toJSONClone({...i,newId:null}))||null,implements:(()=>{var A;return this.implements&&this.project.getBuiltIn(this.implements.id)?this.implements.toJSON():((A=this.implements)==null?void 0:A.toJSONClone({...i,newId:null}))||null})(),extends:(()=>{var A;return this.extends&&this.project.getBuiltIn(this.extends.id)?this.extends.toJSON():((A=this.extends)==null?void 0:A.toJSONClone({...i,newId:null}))||null})(),parent:this.parent.toReference({seenEntityMaps:i.seenEntityMaps})})}toReference(i=Le){var l;let a=this.id;return(l=i.seenEntityMaps)!=null&&l.has(this.id)&&(a=i.seenEntityMaps.get(this.id)),{id:a+"--"+P.UUID.uuid()+"--ref",type:f.GenericReference,entityId:a,version:this.version,entityType:this.type}}toShallowJSON(i=Le){var l,p,t,y,v;let a=this.id;return(l=i.seenEntityMaps)!=null&&l.has(this.id)&&(a=i.seenEntityMaps.get(this.id)),{id:a,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,name:this.name,codeName:this.codeName,description:this.description,type:this.type,index:this.index,private:this.private,required:this.required,abstract:this.abstract,static:this.static,constant:this.constant,interactive:this.interactive,hidden:this.hidden,defaultValue:((p=this.defaultValue)==null?void 0:p.toReference(i))||null,dataType:((t=this.dataType)==null?void 0:t.toReference(i))||null,implements:((y=this.implements)==null?void 0:y.toReference(i))||null,extends:((v=this.extends)==null?void 0:v.toReference(i))||null,parent:this.parent.toReference(i)}}toFlatJSON(i=new Set){var l,p,t;return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...((l=this.defaultValue)==null?void 0:l.toFlatJSON(i))||[],...((p=this.dataType)==null?void 0:p.toFlatJSON(i))||[],...((t=this.implements)==null?void 0:t.toFlatJSON(i))||[],...this.parent.toFlatJSON(i)])}toGenerationTarget(){var i,a;return{id:this.id,name:this.name,description:this.description,type:this.type,private:this.private,required:this.required,abstract:this.abstract,static:this.static,implements:(i=this.implements)==null?void 0:i.id,extends:(a=this.extends)==null?void 0:a.id,parent:this.parent.id}}toFlatGenerationTarget(i=new Set){var l,p;return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...((l=this.defaultValue)==null?void 0:l.toFlatGenerationTarget(i))||[],...((p=this.dataType)==null?void 0:p.toFlatGenerationTarget(i))||[]])}clearErrors(){var i,a;return this.errors=[],(i=this.defaultValue)==null||i.clearErrors(),(a=this.dataType)==null||a.clearErrors(),this}validate(){return this.errors=N3(this),this.errors.length,{success:!0,error:null,data:null}}getErrors(){var a,l;return[...this.errors,...((a=this.defaultValue)==null?void 0:a.getErrors())||[],...((l=this.dataType)==null?void 0:l.getErrors())||[]]}getShallowErrors(){return this.errors}implement(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"implement-self-as-property")),l=null){const p=l||P.UUID.uuid(),t=yt.new(a);t.id=p,t.name=this.name,t.description=this.description,t.index=this.index,t.private=this.private,t.required=this.required,t.static=this.static,t.constant=this.constant,t.hidden=this.hidden,t.parent=i.toReference(),t.implements=this.toJSON();const y=ee(t,this.project);return y.hydrateAncestors(),y.addSelfToProject(a),y.initChildren(a),y}clone(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"clone-entity")),a=null,l=null,p=!0){var L,j;let t=Rr(a,this);const y=l||P.UUID.uuid();let v=a||this.parent;const b={hidden:!1,id:y,version:P.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||N().toISOString(),author:(i==null?void 0:i.author)||"1",previousVersion:null,deleted:!1,type:this.type,name:this.name,codeName:this.codeName,description:this.description,index:this.index,private:this.private,constant:this.constant,interactive:this.interactive,required:this.required,abstract:this.abstract,static:this.static,defaultValue:null,dataType:null,implements:this.implements,extends:this.extends,parent:v},w=St(b,t);p&&w.subscribe(),w.hydrateAncestors(),p&&w.addSelfToProject(i),w.setParent(v,null),w.initChildren(i),i==null||i.add(w,K.Added);const A=((L=this.dataType)==null?void 0:L.clone(i,w,P.UUID.uuid(),p))||null;A&&w.setDataType(A,i);const V=(j=this.defaultValue)==null?void 0:j.clone(i,w,P.UUID.uuid(),p);return w.setDefaultValue(V||null,i),this.implements&&w.setImplements(this.implements,i),w.addSelfToProject(null),i==null||i.attemptAutoclose("clone-entity",this.id),w}setDataType(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"set-data-type"))){const l=this.dataType;return(l==null?void 0:l.id)!==(i==null?void 0:i.id)&&(l==null||l.remove({ignoreUpstream:!0},a),this.dataType=i,this.subscribeToDependencies(),a==null||a.add(this,K.Affected)),a==null||a.attemptAutoclose("set-data-type",this.id),this}removeDataType(){return this.dataType=null,this}getDataType(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"get-data-type"))){return i==null||i.attemptAutoclose("get-data-type",this.id),this.dataType}getDefaultValue(){return this.defaultValue}setDefaultValue(i,a=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"set-default-value"))){const l=this.defaultValue;return(l==null?void 0:l.id)!==(i==null?void 0:i.id)&&(l==null||l.remove({ignoreUpstream:!0},a),this.defaultValue=i,a==null||a.add(this,K.Affected)),a==null||a.attemptAutoclose("set-default-value",this.id),this}syncWithImplementation(i=this.project.addChangeSet(new G(this.project,P.sessionAuthor,N().toISOString(),this,!0,"sync-with-implementation"))){var y;const a=[],l=[],p=[],t=[];if(this.implements){const v=this.implements;if(!this.dataType&&v.dataType){const b=v.dataType.clone(i,this,P.UUID.uuid(),!0);this.setDataType(b,i),l.push(b)}if(this.implements.defaultValue&&!this.defaultValue){const b=(y=this.implements.defaultValue)==null?void 0:y.clone(i,this,P.UUID.uuid(),!0);this.setDefaultValue(b||null,i),l.push(b)}}return i==null||i.attemptAutoclose("sync-with-implementation",this.id),{updated:R(a),added:R(l),removed:R(p),affected:R(t),self:this}}};D(yt,"repository",{APICreate:async(i,...a)=>i,APIUpdate:async(i,...a)=>i,APIDelete:async(i,...a)=>i,APIClone:async(i,...a)=>{},APILoad:async(i,...a)=>null,APILoadVersion:async(i,a,...l)=>null}),D(yt,"type",f.Property),D(yt,"USER_MANAGED_PARENT_TYPES",[f.DefinitionEntity]),D(yt,"PARENT_TYPES",[...yt.USER_MANAGED_PARENT_TYPES,f.PrimitiveEntity,f.BuiltInBaseEntity]),D(yt,"MUTABLE_BASE_PROPERTIES",["name","codeName","description","private","abstract","static","required","constant","interactive"]),D(yt,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),D(yt,"BASE_PROPERTIES",[...yt.MUTABLE_BASE_PROPERTIES,...yt.INMUTABLE_BASE_PROPERTIES]),D(yt,"MUTABLE_META_PROPERTIES",[...yt.MUTABLE_BASE_PROPERTIES,"index"]),D(yt,"INMUTABLE_META_PROPERTIES",[...yt.INMUTABLE_BASE_PROPERTIES]),D(yt,"META_PROPERTIES",[...yt.MUTABLE_META_PROPERTIES,...yt.INMUTABLE_META_PROPERTIES]),D(yt,"MUTABLE_UPSTREAM_PROPERTIES",[]),D(yt,"INMUTABLE_UPSTREAM_PROPERTIES",["parent","implements","extends"]),D(yt,"UPSTREAM_PROPERTIES",[...yt.MUTABLE_UPSTREAM_PROPERTIES,...yt.INMUTABLE_UPSTREAM_PROPERTIES]),D(yt,"MUTABLE_DOWNSTREAM_PROPERTIES",["dataType"]),D(yt,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),D(yt,"DOWNSTREAM_PROPERTIES",[...yt.MUTABLE_DOWNSTREAM_PROPERTIES,...yt.INMUTABLE_DOWNSTREAM_PROPERTIES]),D(yt,"PROPERTIES",[...yt.META_PROPERTIES,...yt.UPSTREAM_PROPERTIES,...yt.DOWNSTREAM_PROPERTIES]);let da=yt;function F3(d){const u=Xce(),i=d.toJSON();u.safeParse(i).success;const l=uhe(d),p=che(d),t=Yi(d);d.inputs.forEach(v=>v.validate()),t.forEach(v=>v.validate());const y=[...l,...p];return Qt(d.errors,y)}function uhe(d){const u=[];if(!d.calls.length&&!d.extends){const i=lt({id:`${d.id}--${se.ScopeWithoutLogic}`,message:`Action "${re(d,d.project)}" with id "${d.id}" does not have any logic defined. So it doesn't do anything.`,issue:null,severity:Z.Warning,code:se.ScopeWithoutLogic,entity:d});u.push(i.error)}return Qt(d.errors,u)}function che(d){const u=[];return d.implements,Qt(d.errors,u)}const phe=Object.freeze(Object.defineProperty({__proto__:null,validate:F3},Symbol.toStringTag,{value:"Module"}));var G3=(d=>(d.FunctionDeclarationImplements="function-declaration-implements",d.FunctionDeclarationExtends="function-declaration-extends",d))(G3||{});const Tt=class Tt extends mr{constructor(i,a){super(i);D(this,"initialData");D(this,"id");D(this,"name");D(this,"codeName",null);D(this,"description",null);D(this,"x");D(this,"y");D(this,"collapsed");D(this,"private");D(this,"index",null);D(this,"type",f.FunctionDeclaration);D(this,"implements",null);D(this,"extends",null);D(this,"inputs",[]);D(this,"calls",[]);D(this,"parent");D(this,"detachedChildren",[]);D(this,"errors",[]);D(this,"project");D(this,"detachedDependents",{});D(this,"knownVersions",null);D(this,"activeVersion",!1);D(this,"initialized",!1);D(this,"startedInitialization",!1);D(this,"suggestion",!1);this.initialData=i,this.project=a,this.id=i.id,this.name=i.name,this.description=i.description,this.private=i.private,this.collapsed=i.collapsed,this.x=i.x,this.y=i.y,this.codeName=i.codeName,this.index=i.index}static new(i=null){return{id:P.UUID.uuid(),version:P.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||N().toISOString(),author:(i==null?void 0:i.author)||P.sessionAuthor,previousVersion:null,deleted:!1,type:f.FunctionDeclaration,name:"",codeName:null,description:"",collapsed:!1,private:!1,index:null,implements:null,extends:null,inputs:[],parent:null,calls:[],x:0,y:0}}static fromGenerationTarget(i,a){let l=a;if(i.parent){const b=W(i.parent);l=a.get(b)}let p=null;if(i.implements){const b=W(i.implements);p=a.get(b)}let t=null;if(i.extends){const b=W(i.extends);t=a.get(b)}const y={id:i.id,version:P.UUID.uuid(),createdAt:N().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,name:i.name,type:f.FunctionDeclaration,index:l.type===f.DefinitionEntity?l.methods.length:null,codeName:i.codeName||null,description:i.description||null,collapsed:!1,private:!1,calls:[],inputs:[],implements:p,extends:t,x:0,y:0,parent:l},v=ee(y,a);return v.setParent(l,null),v}static validateGenerationTarget(i,a){var A;let l=JSON.parse(JSON.stringify(i));const p=[],t=Fr(l,{parent:{list:!1,types:[f.Project,f.InstalledProject,f.DefinitionEntity,f.Loop],optional:!0},implements:{list:!1,types:[f.ActionDescriptor],optional:!0}},a);l=t.modifiedData;const y=ob(l,a),v=l.parent?a.get(l.parent):null;if(v&&v.type===f.DefinitionEntity){const V=v,j=Ii(V).filter(S=>!S.interactive),k=V.methods.find(S=>{var H;return((H=S.implements)==null?void 0:H.id)===l.implements});if(k&&p.push(new Q({id:`${l.id}--${le.MethodOverwritesOtherSiblingWithSameImplementation}`,code:le.MethodOverwritesOtherSiblingWithSameImplementation,severity:Z.Error,message:`The '${f.FunctionDeclaration}' with id "${l.id}" is trying to implement the '${f.ActionDescriptor}' with id "${l.implements}", but the parent definition-entity already has a ${f.FunctionDeclaration} with id '${k.id}' that implements the same base method.
49
49
  A ${f.FunctionDeclaration} that has a parent of type '${f.DefinitionEntity}' is considered a method of that entity, and cannot implement the same '${f.ActionDescriptor}' more than once.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elyx-code/project-logic-tree",
3
- "version": "0.0.6359",
3
+ "version": "0.0.6360",
4
4
  "author": "Sergio Herrero",
5
5
  "license": "UNLICENSED",
6
6
  "description": "An installable module which contains the type definitions and ephemeral state management for a projects' logic tree data structure",