@elyx-code/project-logic-tree 0.0.6316 → 0.0.6317
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 +8 -10
- package/dist/index.umd.cjs +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -30722,7 +30722,7 @@ function ZD(u, d, n) {
|
|
|
30722
30722
|
n
|
|
30723
30723
|
);
|
|
30724
30724
|
if (u === d)
|
|
30725
|
-
throw new Error(
|
|
30725
|
+
throw console.error("From: ", u), console.error("To: ", d), new Error(
|
|
30726
30726
|
"Cannot generate transitional change set between the same two versions or change-sets"
|
|
30727
30727
|
);
|
|
30728
30728
|
let c;
|
|
@@ -95085,7 +95085,7 @@ const Ue = class Ue extends aB {
|
|
|
95085
95085
|
discardChangeSet(n) {
|
|
95086
95086
|
var l;
|
|
95087
95087
|
const a = this.history.findIndex((c) => c.id === (n == null ? void 0 : n.id));
|
|
95088
|
-
return a !== -1 && ((l = this.onDiscardChangeSetCallback) == null || l.call(this, n)
|
|
95088
|
+
return a !== -1 && (this.history.splice(a, 1), this.undoableStackValueIndex = this.undoableStackValueIndex - 1, (l = this.onDiscardChangeSetCallback) == null || l.call(this, n)), this;
|
|
95089
95089
|
}
|
|
95090
95090
|
async inject(...n) {
|
|
95091
95091
|
return await Promise.all(
|
|
@@ -96501,21 +96501,19 @@ const Ue = class Ue extends aB {
|
|
|
96501
96501
|
undo() {
|
|
96502
96502
|
console.log("Undoing, from: ", this.undoableStackValueIndex), this.undoableStackValueIndex = this.undoableStackValueIndex - 1, console.log("To: ", this.undoableStackValueIndex);
|
|
96503
96503
|
const n = this.history[this.undoableStackValueIndex + 1], a = this.history[this.undoableStackValueIndex];
|
|
96504
|
-
return (
|
|
96504
|
+
return console.log("Current change set: ", n), console.log("Change set to restore: ", a), // @ts-ignore
|
|
96505
|
+
ZD(
|
|
96505
96506
|
// @ts-ignore
|
|
96506
|
-
|
|
96507
|
-
|
|
96508
|
-
|
|
96509
|
-
a || "initial",
|
|
96510
|
-
this
|
|
96511
|
-
)
|
|
96507
|
+
n || "initial",
|
|
96508
|
+
a || "initial",
|
|
96509
|
+
this
|
|
96512
96510
|
);
|
|
96513
96511
|
}
|
|
96514
96512
|
// The currently active change-set is the one with one index lower than the given 'newActiveIndex'
|
|
96515
96513
|
redo() {
|
|
96516
96514
|
console.log("Undoing, from: ", this.undoableStackValueIndex), this.undoableStackValueIndex = this.undoableStackValueIndex + 1, console.log("To: ", this.undoableStackValueIndex);
|
|
96517
96515
|
const n = this.history[this.undoableStackValueIndex - 1], a = this.history[this.undoableStackValueIndex];
|
|
96518
|
-
return ZD(
|
|
96516
|
+
return console.log("Current change set: ", n), console.log("Change set to restore: ", a), ZD(
|
|
96519
96517
|
// @ts-ignore
|
|
96520
96518
|
n || "initial",
|
|
96521
96519
|
a || "initial",
|
package/dist/index.umd.cjs
CHANGED
|
@@ -17,7 +17,7 @@ Please provide a unique 'name' string.`,severity:S.Error,code:le.NameNotUniqueIn
|
|
|
17
17
|
Please provide a unique 'name' string.`,severity:S.Error,code:le.NameNotUniqueInScope,issue:null}))}}return n}function MT(u,d){const n=[];u.name||n.push(new Y({id:`${u.id}--${le.EmptyName}`,message:`Entity with id "${u.id}" and type "${u.type}" has an empty name. Please provide a 'name' string.`,severity:S.Error,code:le.EmptyName,issue:null}));const a=W(u.parent);if(!a)n.push(new Y({id:`${u.id}--parent-reference--${k.InvalidReferenceObjectStructure}`,message:`Reference object at 'parent' property for entity with id "${u.id}" and type "${u.type}" is not a valid reference. A reference needs to be a 'id' string of an existing entity in the project.`,severity:S.Error,code:k.InvalidReferenceObjectStructure,issue:null}));else{const l=d.get(a);if(!l)n.push(new Y({id:`${u.id}--parent-reference--${k.ReferencedEntityNotFound}`,message:`The entity with id '${a}' that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,severity:S.Error,code:k.ReferencedEntityNotFound,issue:null}));else{const t=Rb(l).filter(m=>m.name===u.name);t.length&&n.push(new Y({id:`${u.id}--${le.NameNotUniqueInScope}`,message:`Entity with id "${u.id}" and type "${u.type}" has a name "${u.name}" that is not unique among all inputs declared in the parent entity. Entity with id "${t[0].id}" has the same name.
|
|
18
18
|
Please provide a unique 'name' string.`,severity:S.Error,code:le.NameNotUniqueInScope,issue:null}))}}return n}function BT(u,d){const n=[];u.name||n.push(new Y({id:`${u.id}--${le.EmptyName}`,message:`Entity with id "${u.id}" and type "${u.type}" has an empty name. Please provide a 'name' string.`,severity:S.Error,code:le.EmptyName,issue:null}));const a=W(u.parent);if(!a)n.push(new Y({id:`${u.id}--parent-reference--${k.InvalidReferenceObjectStructure}`,message:`Reference object at 'parent' property for entity with id "${u.id}" and type "${u.type}" is not a valid reference. A reference needs to be a 'id' string of an existing entity in the project.`,severity:S.Error,code:k.InvalidReferenceObjectStructure,issue:null}));else{const l=d.get(a);if(!l)n.push(new Y({id:`${u.id}--parent-reference--${k.ReferencedEntityNotFound}`,message:`The entity with id '${a}' that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,severity:S.Error,code:k.ReferencedEntityNotFound,issue:null}));else{const t=sj(l).filter(m=>m.name===u.name);t.length&&n.push(new Y({id:`${u.id}--${le.NameNotUniqueInScope}`,message:`Entity with id "${u.id}" and type "${u.type}" has a name "${u.name}" that is not unique among all outputs declared in the parent entity. Entity with id "${t[0].id}" has the same name.
|
|
19
19
|
Please provide a unique 'name' string.`,severity:S.Error,code:le.NameNotUniqueInScope,issue:null}))}}return n}function zce(u,d){switch(u.type){case f.DefinitionEntity:return PT(u,d);case f.FunctionDeclaration:return VT(u,d);case f.VariableDeclaration:return NT(u,d);case f.Property:return LT(u,d);case f.ArgumentDeclaration:return MT(u,d);case f.ReturnDeclaration:return BT(u,d);default:return[]}}function JL(u,d,n){const l=`${qh(u)}-${d}-id`;return n.instances[l]?P.UUID.uuid():l}function UT(u,d){let n="",a=null;if(u.parent){const p=d.get(u.parent);p&&(a=p)}let l="";return a&&(l=`${qh(ce(a,d))}-`),n=`${l}${qh(ce(u,d))}-id`,d.instances[n]?P.UUID.uuid():n}function hr(u,d,n="uuid"){return n==="semantic"?JL(ce(u,d),u.type,d):P.UUID.uuid()}function WL(u){var t;const d=$oe(),n=u.toJSON();d.safeParse(n).success;const l=YL(u);(t=u.dataType)==null||t.validate();const p=[...l];if(u.id==="80c86e1b-caca-4ba5-9b1f-38f72d10e4a3"){const m=et({id:`${u.id}--${he.PropertyImplementsNonAbstact}`,message:`Property "${ce(u,u.project)}" with id "${u.id}" implements a non-abstract property "${ce(u,u.project)}" with id "${u.id}".`,issue:null,severity:S.Error,code:he.PropertyImplementsNonAbstact,entity:u});p.push(m.error)}return p}function YL(u){const d=[];if(!u.implements)return d;const n=u.implements;if(!n.abstract){const l=et({id:`${u.id}--${he.PropertyImplementsNonAbstact}`,message:`Property "${ce(u,u.project)}" with id "${u.id}" implements a non-abstract property "${ce(n,u.project)}" with id "${n.id}".`,issue:null,severity:S.Error,code:he.PropertyImplementsNonAbstact,entity:u});d.push(l.error)}if(u.static&&!n.static){const l=et({id:`${u.id}--${he.NonStaticPropertyImplementsStatic}`,message:`Static property "${ce(u,u.project)}" with id "${u.id}" implements a non-static property "${ce(n,u.project)}" with id "${n.id}".`,issue:null,severity:S.Error,code:he.NonStaticPropertyImplementsStatic,entity:u});d.push(l.error)}if(!u.static&&n.static){const l=et({id:`${u.id}--${he.StaticPropertyImplementsNonStatic}`,message:`Non-static property "${ce(u,u.project)}" with id "${u.id}" implements a static property "${ce(n,u.project)}" with id "${n.id}".`,issue:null,severity:S.Error,code:he.StaticPropertyImplementsNonStatic,entity:u});d.push(l.error)}if(!vs(u.dataType,n.dataType)){const l=et({id:`${u.id}--${he.PropertyImplementsIncompatibleType}`,message:`Property "${ce(u,u.project)}" with id "${u.id}" implements a property "${ce(n,u.project)}" with id "${n.id}" that has an incompatible data type.`,issue:null,severity:S.Error,code:he.PropertyImplementsIncompatibleType,entity:u});d.push(l.error)}return qt(u.errors,d)}const Hce=Object.freeze(Object.defineProperty({__proto__:null,validate:WL,validateImplementation:YL},Symbol.toStringTag,{value:"Module"}));function Xce(u,d){const n=[];if(u.parent){const l=d.get(u.parent);if(!l)n.push(new Y({id:`${u.id}--${u.parent}--${k.ReferencedEntityNotFound}`,code:k.ReferencedEntityNotFound,severity:S.Error,message:`Entity of type "${u.type}" with id "${u.id}", is referencing an entity with id "${u.parent}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,issue:null}));else{const p=ka(l);if(p){const t=l!==p?`The entity of type '${u.type}' with id '${u.id}' have 'parent' with id '${u.parent}' because the entity belongs to a built-in '${p.type}' entity with id '${p.id}' (${ce(p,l.project)}) higher up in the tree.`:`The entity of type '${u.type}' with id '${u.id}' have 'parent' with id '${u.parent}' because it is a built-in entity of type ${p.type}.`;n.push(new Y({id:`${u.id}--${k.InvalidBuiltInEntityReference}`,code:k.InvalidBuiltInEntityReference,severity:S.Error,message:t,issue:null}))}else if(![f.DefinitionEntity].includes(l.type))n.push(new Y({id:`${u.id}--${u.parent}--${k.InvalidParentReference}`,code:k.InvalidParentReference,severity:S.Error,message:`Entity of type "${u.type}" with id "${u.id}", has a parent reference that isn't pointing to an entity of type 'definition-entity'.`,issue:null}));else{const m=hi(l).filter(E=>!E.interactive);if(m.length){let E=m.length>1?`The entity of type '${u.type}' with id '${u.id}' can't be added to the 'parent' entity with id '${l.id}' because it extends or implements multiple '${f.BuiltInBaseEntity}' entities that are non-interactive ("${Ke(m.map(b=>ce(b,b.project)),'", "','" and "')}").`:`The entity of type '${u.type}' with id '${u.id}' can't be added to the 'parent' entity with id '${l.id}' because it extends or implements a '${f.BuiltInBaseEntity}' entity that is non-interactive ("${ce(m[0],m[0].project)}").`;E+=`
|
|
20
|
-
${xa}`,n.push(new Y({id:`${u.id}--${k.NonInteractiveEntityReferenced}`,code:k.NonInteractiveEntityReferenced,severity:S.Error,message:E,issue:null}))}else if(u.implements){const E=d.get(u.implements);if(u.id===u.implements)return n.push(new Y({id:`${u.id}--${u.implements}--${k.SelfReference}`,code:k.SelfReference,severity:S.Error,message:`Entity of type "${u.type}" with id "${u.id}", has a reference to itself at 'implements'. This is not allowed. Change the reference string or the 'entityId' property of the reference object.`,issue:null})),n;if(!E)n.push(new Y({id:`${u.id}--${u.implements}--${k.ReferencedEntityNotFound}`,code:k.ReferencedEntityNotFound,severity:S.Error,message:`Entity of type "${u.type}" with id "${u.id}", is referencing an entity with id "${u.implements}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,issue:null}));else{const b=l.properties.find(_=>{var w;return((w=_.implements)==null?void 0:w.id)===u.implements});b?n.push(new Y({id:`${u.id}--${le.PropertyOverwritesOtherSiblingWithSameImplementation}`,code:le.PropertyOverwritesOtherSiblingWithSameImplementation,severity:S.Error,message:`The property with id "${u.id}" is trying to implement the property with id "${u.implements}", but the parent entity already has a property with id '${b.id}' that implements the same base property.`,issue:null})):[f.Property].includes(E.type)?E.abstract||n.push(new Y({id:`${u.id}--${u.implements}--${k.InvalidImplementsReference}`,code:k.InvalidImplementsReference,severity:S.Error,message:`Entity of type "${u.type}" with id "${u.id}", has an 'implements' reference that isn't pointing to an abstract entity.`,issue:null})):n.push(new Y({id:`${u.id}--${u.implements}--${k.InvalidImplementsReference}`,code:k.InvalidImplementsReference,severity:S.Error,message:`Entity of type "${u.type}" with id "${u.id}", has an 'implements' reference that isn't pointing to an entity of type 'property'.`,issue:null}))}}}}}const a=Cr(u,{},d);return n.push(...a.errors),n}class nr{constructor(d){g(this,"version");g(this,"previousVersion",null);g(this,"createdAt");g(this,"deleted",!1);g(this,"author");this.version=d.version,this.previousVersion=d.previousVersion,this.createdAt=N(d.createdAt).toISOString(),this.deleted=d.deleted,this.author=d.author}metaSync(d){this.deleted=d.deleted!==void 0?d.deleted:this.deleted}}function Qce(u){return u.listAdded.forEach(d=>{const n=u.project.get(d.id);(n==null?void 0:n.type)===f.DefinitionEntity&&n.parent.type!==f.DataType&&(u.project.emit(ar.EXPLICIT_DEFINITION_ENTITY_ADDED,n,u),As(n,ge.PERSISTED_ENTITY)?u.project.emit(ar.PERSISTED_DEFINITION_ENTITY_ADDED,n,u):As(n,ge.RELATIONAL_DATABASE)&&u.project.emit(ar.RELATIONAL_DATABASE_DEFINITION_ENTITY_ADDED,n,u))}),u.listUpdated.forEach(d=>{const n=u.project.get(d.id);(n==null?void 0:n.type)===f.DefinitionEntity&&n.parent.type!==f.DataType&&(u.project.emit(ar.EXPLICIT_DEFINITION_ENTITY_UPDATED,n,u),As(n,ge.PERSISTED_ENTITY)?u.project.emit(ar.PERSISTED_DEFINITION_ENTITY_UPDATED,n,u):As(n,ge.RELATIONAL_DATABASE)&&u.project.emit(ar.RELATIONAL_DATABASE_DEFINITION_ENTITY_UPDATED,n,u))}),u.listRemoved.forEach(d=>{const n=u.project.get(d.id)||u.project.getDeleted(d.id);(n==null?void 0:n.type)===f.DefinitionEntity&&n.parent.type!==f.DataType&&(u.project.emit(ar.EXPLICIT_DEFINITION_ENTITY_REMOVED,n,u),As(n,ge.PERSISTED_ENTITY)?u.project.emit(ar.PERSISTED_DEFINITION_ENTITY_REMOVED,n,u):As(n,ge.RELATIONAL_DATABASE)&&u.project.emit(ar.RELATIONAL_DATABASE_DEFINITION_ENTITY_REMOVED,n,u))}),u}var jT=(u=>(u.Manual="manual",u.Automatic="automatic",u))(jT||{}),G=(u=>(u.Added="added",u.Updated="updated",u.Removed="removed",u.Affected="affected",u))(G||{});class F{constructor(d,n,a,l,p=!1,t=""){g(this,"id",P.UUID.uuid());g(this,"seenEntities",[]);g(this,"added",{});g(this,"updated",{});g(this,"removed",{});g(this,"affected",{});g(this,"self",null);g(this,"author");g(this,"timestamp");g(this,"open",!0);g(this,"dirty",!0);g(this,"startedClose",!1);g(this,"type","manual");g(this,"autoclose",!1);g(this,"autoCloseActionName","");g(this,"project");if(this.project=d,this.author=n||P.sessionAuthor||"",this.timestamp=a,this.self=l,this.autoclose=p,this.autoCloseActionName=t,this.autoclose&&!this.autoCloseActionName)throw new Error("Auto-close change-set must have an auto-close action name.")}get index(){const d=this.project.history.indexOf(this);return d===-1?null:d}get isEmpty(){return Object.keys(this.added).length===0&&Object.keys(this.updated).length===0&&Object.keys(this.removed).length===0}get isValid(){var d;return!(this.isEmpty&&this.self&&!this.affected[(d=this.self)==null?void 0:d.id])}get list(){return[...Object.values(this.added),...Object.values(this.updated),...Object.values(this.removed)]}get listAdded(){return Object.values(this.added)}get listUpdated(){return Object.values(this.updated)}get listRemoved(){return Object.values(this.removed)}get listAffected(){return Object.values(this.affected)}get addedIds(){return Object.keys(this.added)}get updatedIds(){return Object.keys(this.updated)}get removedIds(){return Object.keys(this.removed)}get affectedIds(){return Object.keys(this.affected)}discardOrphans(){this.added[this.project.id]&&(this.updatedIds.forEach(t=>{const m=this.updated[t];this.added[t]=m,delete this.updated[t]}),this.removedIds.forEach(t=>{this.remove(t)}));const d=[...this.addedIds,...this.updatedIds],n=this.project.toFlatIds(),a=bs(),l=n.filter(t=>!a.includes(t));if(d.filter(t=>!l.includes(t)).forEach(t=>{this.remove(t)}),this.added[this.project.id]){const t=[...this.addedIds,...this.updatedIds],m=this.project.toFlatIds(),E=[...bs(),...this.project.getAllBuiltInIds()];m.filter(w=>!E.includes(w)).filter(w=>!t.includes(w)).forEach(w=>{const V=this.project.get(w);this.add(V,"added")})}}captureAllChangesInVersionInstances(){[...this.addedIds,...this.updatedIds].forEach(n=>{const a=this.project.get(n);if(!a)throw new Error(`Entity with id "${n}" not found in the project state when capturing version for change-set.`);const l=this.get(n);a.version===l.version&&a.captureVersion()}),this.removedIds.forEach(n=>{const a=this.project.getDeleted(n);if(!a)throw new Error(`Entity with id "${n}" not found in the project state when capturing version for change-set.`);const l=this.get(n);a.version===l.version&&a.captureVersion()})}async attemptAutocloseAsync(d,n){var a;return this.autoclose&&this.autoCloseActionName&&this.autoCloseActionName===d&&(this.self&&n===((a=this.self)==null?void 0:a.id)||!this.self)&&await this.closeAsync(),this}async closeAsync(){return this.startedClose||(this.startedClose=!0,this.beforeClose()),!this.isValid&&this.self&&!this.added[this.self.id]&&!this.updated[this.self.id]&&this.removed[this.self.id],this.discardOrphans(),this.sanitize(),this.recursiveCaptureUpstreamVersions(),this.captureAllChangesInVersionInstances(),this.recursiveCaptureUpstreamVersions(),this.open=!1,this.isEmpty?(console.warn(`Empty change-set (${this.id}) discarded upon closing.`),this.project.discardChangeSet(this),this.project.closePendingChangeSets(),this):(await this.project.closeChangeSet(this),this)}attemptAutoclose(d,n){var a;return this.autoclose&&this.autoCloseActionName&&this.autoCloseActionName===d&&(this.self&&n===((a=this.self)==null?void 0:a.id)||!this.self)&&this.close(),this}recursiveCaptureUpstreamVersions(){[...this.addedIds,...this.updatedIds,...this.removedIds].forEach(n=>{const a=this.get(n),{added:l,updated:p,removed:t,affected:m}=a.recursiveCaptureUpstreamVersions(this.timestamp);for(const E of l)this.add(E,"added");for(const E of p)this.add(E,"updated");for(const E of t)this.add(E,"removed");for(const E of m)this.add(E,"affected")})}sanitize(){this.listAdded.forEach(d=>{d.previousVersion=null})}syncDependents(){return[...this.list,...this.listAffected].forEach(d=>{const n=this.project.get(d.id);!n||n.deleted||Vb(n,this.project)||n==null||n.syncDependents(this)}),this}beforeClose(){this.syncDependents(),this.emitSideEffects()}emitSideEffects(){Qce(this)}close(){if(this.startedClose||(this.startedClose=!0,this.beforeClose()),!this.isValid&&this.self&&!this.added[this.self.id]&&!this.updated[this.self.id]&&this.removed[this.self.id],this.discardOrphans(),this.sanitize(),this.captureAllChangesInVersionInstances(),this.recursiveCaptureUpstreamVersions(),this.captureAllChangesInVersionInstances(),this.open=!1,this.isEmpty)return console.warn(`Empty change-set (${this.id}) discarded upon closing.`),this.project.discardChangeSet(this),this.project.closePendingChangeSets(),this;if(this.added[this.project.id]&&this.updatedIds.length)throw new Error("No 'updated' entities should be present in the change-set when the project entity is in the 'added' list. New projects can only have newly added entities");if(this.added[this.project.id]&&this.removedIds.length)throw new Error("No 'removed' entities should be present in the change-set when the project entity is in the 'added' list. New projects can only have newly added entities");if(!this.updated[this.project.id]&&!this.added[this.project.id])throw new Error("Change-set must also have the project entity as 'updated' or 'added'. All changes must propagate upstream until the root project entity.");return this.project.closeChangeSet(this),this}addDependentsToAffected(d){Object.values(d.detachedDependents).forEach(n=>{const{entity:a,field:l}=n;this.has(a.id)||this.add(a,"affected")})}get(d){return this.added[d]?this.added[d]:this.updated[d]?this.updated[d]:this.removed[d]?this.removed[d]:null}remove(d){return this.has(d)&&(delete this.added[d],delete this.updated[d],delete this.removed[d],delete this.affected[d],this.seenEntities=this.seenEntities.filter(n=>n!==d)),this}add(d,n,a={preventRecursion:!1}){var p,t,m;if(!this.open||!this.dirty)return this;if(Vb(d,this.project))return this;if(this.seenEntities.indexOf(d.id)===-1&&this.seenEntities.push(d.id),n==="removed"){if(this.added[d.id])return delete this.added[d.id],this.seenEntities=this.seenEntities.filter(b=>b!==d.id),delete this.project.deletedInstances[d.id],this;if(this.updated[d.id]&&delete this.updated[d.id],this.affected[d.id]&&delete this.affected[d.id],!this.hasRemoved(d.id)&&(d.increaseVersion(this.timestamp),!a.preventRecursion)){const{added:b,updated:_,removed:w,affected:V}=d.recursiveCaptureUpstreamVersions(this.timestamp);for(const B of b)this.add(B,"added");for(const B of _)this.add(B,"updated");for(const B of w)this.add(B,"removed");for(const B of V)this.add(B,"affected")}d.captureVersion();const E=(p=d.knownVersions)==null?void 0:p.get(d.version);if(!E)throw Error(`Version ${d.version} should have a cached version instance but it wasn't found when adding entity to change-set`);return this.removed[d.id]=E,this}if(n==="added"){if(this.removed[d.id])return this;if(this.updated[d.id]&&delete this.updated[d.id],this.affected[d.id]&&delete this.affected[d.id],!this.hasAdded(d.id)&&!a.preventRecursion){const{added:b,updated:_,removed:w,affected:V}=d.recursiveCaptureUpstreamVersions(this.timestamp);for(const B of b)this.add(B,"added");for(const B of _)this.add(B,"updated");for(const B of w)this.add(B,"removed");for(const B of V)this.add(B,"affected")}d.previousVersion=null,d.captureVersion();const E=(t=d.knownVersions)==null?void 0:t.get(d.version);if(!E)throw Error(`Version ${d.version} should have a cached version instance but it wasn't found when adding entity to change-set`);return this.added[d.id]=E,delete this.affected[d.id],this.addDependentsToAffected(d),this}if(n==="updated"){if(this.removed[d.id])return this;if(this.added[d.id])return d.captureVersion(),this.addDependentsToAffected(d),this;if(this.affected[d.id]&&delete this.affected[d.id],!this.hasUpdated(d.id)&&(d.increaseVersion(this.timestamp),!a.preventRecursion)){const{added:b,updated:_,removed:w,affected:V}=d.recursiveCaptureUpstreamVersions(this.timestamp);for(const B of b)this.add(B,"added");for(const B of _)this.add(B,"updated");for(const B of w)this.add(B,"removed");for(const B of V)this.add(B,"affected")}d.captureVersion();const E=(m=d.knownVersions)==null?void 0:m.get(d.version);if(!E)throw Error(`Version ${d.version} should have a cached version instance but it wasn't found when adding entity to change-set`);return this.updated[d.id]=E,this.addDependentsToAffected(d),this}if(n==="affected"){if(this.removed[d.id])return this;if(this.added[d.id])return this;if(this.updated[d.id])return this;this.affected[d.id]=d}return this}toJSON(){const d={},n={},a={},l=new Set;for(const p of Object.values(this.added))d[p.id]=p.toShallowJSON();for(const p of Object.values(this.updated))n[p.id]=p.toShallowJSON();for(const p of Object.values(this.removed))a[p.id]=p.toShallowJSON();for(const p of Object.values(this.affected))l.add(p.id);return{added:d,updated:n,removed:a,affected:Array.from(l),self:this.self?this.self.toShallowJSON():null,seenEntities:this.seenEntities}}has(d){return!!this.added[d]||!!this.removed[d]||!!this.updated[d]||!!this.affected[d]}hasAdded(d){return!!this.added[d]}hasUpdated(d){return!!this.updated[d]}hasRemoved(d){return!!this.removed[d]}hasAffected(d){return!!this.affected[d]}}function epe(u){return new Set([...Object.keys(u.added),...Object.keys(u.updated),...Object.keys(u.removed),...Array.from(u.affected)])}function zL(u,d,n){var m;const a=new Date().toISOString(),l=new F(n,P.sessionAuthor,a,n);if(u===d)throw new Error("Cannot generate transitional change set between the same two versions or change-sets");let p;if(u==="initial"?p=!0:d==="initial"?p=!1:N(u.timestamp).isBefore(N(d.timestamp))?p=!0:p=!1,console.log("Transitioning from ",u==="initial"?"initial":u.index),console.log("Transitioning to ",d==="initial"?"initial":d.index),console.log("Is forward: ",p),p){const b=d.index,_=u==="initial"?0:u.index;console.log("ownIndex: ",b),console.log("startIndex: ",_);const w=b===_?[n.history[b]]:n.history.slice(_+1,b+1);if(w.sort((V,B)=>N(V.timestamp).isAfter(N(B.timestamp))?1:-1),!w.length)throw new Error("No change sets in the history between the history indexes provided");console.log("REDO change-set: ",w[0].id," ",w[0].timestamp),w.forEach(V=>{HL(V,B=>{const K=n.instances[B.id]||n.deletedInstances[B.id];let q="";try{q=ce(B,n)}catch{}if(!K)throw new Error(`Entity ${B.type} ${q?`"${q}" `:""}with id "${B.id}" doesn't have an 'activeVersion' set.`);if(!K.knownVersions)throw new Error(`Entity ${B.type} ${q?`"${q}" `:""}with id "${B.id}" has an active version instance missing the 'knownVersions' property value.`);if(!K.knownVersions.get(B.version))throw new Error(`Entity ${B.type} ${q?`"${q}" `:""}with id "${B.id}" has an active version instance missing the 'knownVersions' property value for version "${B.version}".`);K.restoreVersion(B.version),l.timestamp=K.createdAt,l.add(K,G.Added,{preventRecursion:!0})},B=>{const K=n.instances[B.id]||n.deletedInstances[B.id];let q="";try{q=ce(B,n)}catch{}if(!K)throw new Error(`Entity ${B.type} ${q?`"${q}" `:""}with id "${B.id}" doesn't have an 'activeVersion' set.`);if(!K.knownVersions)throw new Error(`Entity ${B.type} ${q?`"${q}" `:""}with id "${B.id}" has an active version instance missing the 'knownVersions' property value.`);if(!K.knownVersions.get(B.version))throw new Error(`Entity ${B.type} ${q?`"${q}" `:""}with id "${B.id}" has an active version instance missing the 'knownVersions' property value for version "${B.version}".`);K.restoreVersion(B.version),l.timestamp=K.createdAt,l.add(K,G.Updated,{preventRecursion:!0})},B=>{const K=n.instances[B.id]||n.deletedInstances[B.id];let q="";try{q=ce(B,n)}catch{}if(!K)throw new Error(`Entity ${B.type} ${q?`"${q}" `:""}with id "${B.id}" doesn't have an 'activeVersion' set.`);if(!K.knownVersions)throw new Error(`Entity ${B.type} ${q?`"${q}" `:""}with id "${B.id}" has an active version instance missing the 'knownVersions' property value.`);if(!K.knownVersions.get(B.version))throw new Error(`Entity ${B.type} ${q?`"${q}" `:""}with id "${B.id}" has an active version instance missing the 'knownVersions' property value for version "${B.version}".`);K.restoreVersion(B.version),l.timestamp=K.createdAt,l.add(K,G.Removed,{preventRecursion:!0})})})}else{const b=u.index,_=d==="initial"?0:d.index,w=b===_?[n.history[b]]:n.history.slice(_+1,b+1);if(w.sort((V,B)=>N(B.timestamp).isAfter(N(V.timestamp))?1:-1),!w.length)throw new Error("No change sets in the history between the history indexes provided");console.log("UNDO change-set: ",w[0].id," ",w[0].timestamp),w.forEach(V=>{HL(V,B=>{const K=n.instances[B.id]||n.deletedInstances[B.id];let q="";try{q=ce(B,n)}catch{}if(!K)throw new Error(`Entity ${B.type} ${q?`"${q}" `:""}with id "${B.id}" doesn't have an 'activeVersion' set.`);if(!K.knownVersions)throw new Error(`Entity ${B.type} ${q?`"${q}" `:""}with id "${B.id}" has an active version instance missing the 'knownVersions' property value.`);if(!K.knownVersions.get(B.version))throw new Error(`Entity ${B.type} ${q?`"${q}" `:""}with id "${B.id}" has an active version instance missing the 'knownVersions' property value for version "${B.version}".`);B.previousVersion&&K.restoreVersion(B.previousVersion),l.timestamp=K.createdAt,l.add(K,G.Removed,{preventRecursion:!0})},B=>{const K=n.instances[B.id]||n.deletedInstances[B.id];let q="";try{q=ce(B,n)}catch{}if(!K)throw new Error(`Entity ${B.type} ${q?`"${q}" `:""}with id "${B.id}" doesn't have an 'activeVersion' set.`);if(!K.knownVersions)throw new Error(`Entity ${B.type} ${q?`"${q}" `:""}with id "${B.id}" has an active version instance missing the 'knownVersions' property value.`);if(!K.knownVersions.get(B.version))throw new Error(`Entity ${B.type} ${q?`"${q}" `:""}with id "${B.id}" has an active version instance missing the 'knownVersions' property value for version "${B.version}".`);K.restoreVersion(B.previousVersion),l.timestamp=K.createdAt,l.add(K,G.Updated,{preventRecursion:!0})},B=>{const K=n.instances[B.id]||n.deletedInstances[B.id];let q="";try{q=ce(B,n)}catch{}if(!K)throw new Error(`Entity ${B.type} ${q?`"${q}" `:""}with id "${B.id}" doesn't have an 'activeVersion' set.`);if(!K.knownVersions)throw new Error(`Entity ${B.type} ${q?`"${q}" `:""}with id "${B.id}" has an active version instance missing the 'knownVersions' property value.`);if(!K.knownVersions.get(B.version))throw new Error(`Entity ${B.type} ${q?`"${q}" `:""}with id "${B.id}" has an active version instance missing the 'knownVersions' property value for version "${B.version}".`);K.restoreVersion(B.previousVersion),l.timestamp=K.createdAt,l.add(K,G.Added,{preventRecursion:!0})})})}let t;if(d==="initial"){const E=Array.from(((m=n.knownVersions)==null?void 0:m.values())||[]).reduce((b,_)=>!b||N(_.createdAt).isBefore(N(b.createdAt))?_:b,null);if(!E)throw new Error("No oldest version found");t=E.createdAt}else t=d.timestamp;return l.open=!1,{transitionalChangeSet:l,transitionTime:a,timeOfOriginalTargetChanges:t}}function HL(u,d,n,a){if(!(u!=null&&u.self))throw new Error("Change set must have a valid `self` entity state to be traversed");const l=new Ga(u.self);console.log("changeSet.added: ",Object.keys(u.added).length),console.log("changeSet.updated: ",Object.keys(u.updated).length),console.log("changeSet.removed: ",Object.keys(u.removed).length);const p={...u.added,...u.updated,...u.removed};l.order=Object.keys(p),l.flatRecord=p,l.orderEntities(),console.log("All entities: ",l.order.map((t,m)=>`${m+1}: ${p[t].type} - ${t}`).join(`,
|
|
20
|
+
${xa}`,n.push(new Y({id:`${u.id}--${k.NonInteractiveEntityReferenced}`,code:k.NonInteractiveEntityReferenced,severity:S.Error,message:E,issue:null}))}else if(u.implements){const E=d.get(u.implements);if(u.id===u.implements)return n.push(new Y({id:`${u.id}--${u.implements}--${k.SelfReference}`,code:k.SelfReference,severity:S.Error,message:`Entity of type "${u.type}" with id "${u.id}", has a reference to itself at 'implements'. This is not allowed. Change the reference string or the 'entityId' property of the reference object.`,issue:null})),n;if(!E)n.push(new Y({id:`${u.id}--${u.implements}--${k.ReferencedEntityNotFound}`,code:k.ReferencedEntityNotFound,severity:S.Error,message:`Entity of type "${u.type}" with id "${u.id}", is referencing an entity with id "${u.implements}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,issue:null}));else{const b=l.properties.find(_=>{var w;return((w=_.implements)==null?void 0:w.id)===u.implements});b?n.push(new Y({id:`${u.id}--${le.PropertyOverwritesOtherSiblingWithSameImplementation}`,code:le.PropertyOverwritesOtherSiblingWithSameImplementation,severity:S.Error,message:`The property with id "${u.id}" is trying to implement the property with id "${u.implements}", but the parent entity already has a property with id '${b.id}' that implements the same base property.`,issue:null})):[f.Property].includes(E.type)?E.abstract||n.push(new Y({id:`${u.id}--${u.implements}--${k.InvalidImplementsReference}`,code:k.InvalidImplementsReference,severity:S.Error,message:`Entity of type "${u.type}" with id "${u.id}", has an 'implements' reference that isn't pointing to an abstract entity.`,issue:null})):n.push(new Y({id:`${u.id}--${u.implements}--${k.InvalidImplementsReference}`,code:k.InvalidImplementsReference,severity:S.Error,message:`Entity of type "${u.type}" with id "${u.id}", has an 'implements' reference that isn't pointing to an entity of type 'property'.`,issue:null}))}}}}}const a=Cr(u,{},d);return n.push(...a.errors),n}class nr{constructor(d){g(this,"version");g(this,"previousVersion",null);g(this,"createdAt");g(this,"deleted",!1);g(this,"author");this.version=d.version,this.previousVersion=d.previousVersion,this.createdAt=N(d.createdAt).toISOString(),this.deleted=d.deleted,this.author=d.author}metaSync(d){this.deleted=d.deleted!==void 0?d.deleted:this.deleted}}function Qce(u){return u.listAdded.forEach(d=>{const n=u.project.get(d.id);(n==null?void 0:n.type)===f.DefinitionEntity&&n.parent.type!==f.DataType&&(u.project.emit(ar.EXPLICIT_DEFINITION_ENTITY_ADDED,n,u),As(n,ge.PERSISTED_ENTITY)?u.project.emit(ar.PERSISTED_DEFINITION_ENTITY_ADDED,n,u):As(n,ge.RELATIONAL_DATABASE)&&u.project.emit(ar.RELATIONAL_DATABASE_DEFINITION_ENTITY_ADDED,n,u))}),u.listUpdated.forEach(d=>{const n=u.project.get(d.id);(n==null?void 0:n.type)===f.DefinitionEntity&&n.parent.type!==f.DataType&&(u.project.emit(ar.EXPLICIT_DEFINITION_ENTITY_UPDATED,n,u),As(n,ge.PERSISTED_ENTITY)?u.project.emit(ar.PERSISTED_DEFINITION_ENTITY_UPDATED,n,u):As(n,ge.RELATIONAL_DATABASE)&&u.project.emit(ar.RELATIONAL_DATABASE_DEFINITION_ENTITY_UPDATED,n,u))}),u.listRemoved.forEach(d=>{const n=u.project.get(d.id)||u.project.getDeleted(d.id);(n==null?void 0:n.type)===f.DefinitionEntity&&n.parent.type!==f.DataType&&(u.project.emit(ar.EXPLICIT_DEFINITION_ENTITY_REMOVED,n,u),As(n,ge.PERSISTED_ENTITY)?u.project.emit(ar.PERSISTED_DEFINITION_ENTITY_REMOVED,n,u):As(n,ge.RELATIONAL_DATABASE)&&u.project.emit(ar.RELATIONAL_DATABASE_DEFINITION_ENTITY_REMOVED,n,u))}),u}var jT=(u=>(u.Manual="manual",u.Automatic="automatic",u))(jT||{}),G=(u=>(u.Added="added",u.Updated="updated",u.Removed="removed",u.Affected="affected",u))(G||{});class F{constructor(d,n,a,l,p=!1,t=""){g(this,"id",P.UUID.uuid());g(this,"seenEntities",[]);g(this,"added",{});g(this,"updated",{});g(this,"removed",{});g(this,"affected",{});g(this,"self",null);g(this,"author");g(this,"timestamp");g(this,"open",!0);g(this,"dirty",!0);g(this,"startedClose",!1);g(this,"type","manual");g(this,"autoclose",!1);g(this,"autoCloseActionName","");g(this,"project");if(this.project=d,this.author=n||P.sessionAuthor||"",this.timestamp=a,this.self=l,this.autoclose=p,this.autoCloseActionName=t,this.autoclose&&!this.autoCloseActionName)throw new Error("Auto-close change-set must have an auto-close action name.")}get index(){const d=this.project.history.indexOf(this);return d===-1?null:d}get isEmpty(){return Object.keys(this.added).length===0&&Object.keys(this.updated).length===0&&Object.keys(this.removed).length===0}get isValid(){var d;return!(this.isEmpty&&this.self&&!this.affected[(d=this.self)==null?void 0:d.id])}get list(){return[...Object.values(this.added),...Object.values(this.updated),...Object.values(this.removed)]}get listAdded(){return Object.values(this.added)}get listUpdated(){return Object.values(this.updated)}get listRemoved(){return Object.values(this.removed)}get listAffected(){return Object.values(this.affected)}get addedIds(){return Object.keys(this.added)}get updatedIds(){return Object.keys(this.updated)}get removedIds(){return Object.keys(this.removed)}get affectedIds(){return Object.keys(this.affected)}discardOrphans(){this.added[this.project.id]&&(this.updatedIds.forEach(t=>{const m=this.updated[t];this.added[t]=m,delete this.updated[t]}),this.removedIds.forEach(t=>{this.remove(t)}));const d=[...this.addedIds,...this.updatedIds],n=this.project.toFlatIds(),a=bs(),l=n.filter(t=>!a.includes(t));if(d.filter(t=>!l.includes(t)).forEach(t=>{this.remove(t)}),this.added[this.project.id]){const t=[...this.addedIds,...this.updatedIds],m=this.project.toFlatIds(),E=[...bs(),...this.project.getAllBuiltInIds()];m.filter(w=>!E.includes(w)).filter(w=>!t.includes(w)).forEach(w=>{const V=this.project.get(w);this.add(V,"added")})}}captureAllChangesInVersionInstances(){[...this.addedIds,...this.updatedIds].forEach(n=>{const a=this.project.get(n);if(!a)throw new Error(`Entity with id "${n}" not found in the project state when capturing version for change-set.`);const l=this.get(n);a.version===l.version&&a.captureVersion()}),this.removedIds.forEach(n=>{const a=this.project.getDeleted(n);if(!a)throw new Error(`Entity with id "${n}" not found in the project state when capturing version for change-set.`);const l=this.get(n);a.version===l.version&&a.captureVersion()})}async attemptAutocloseAsync(d,n){var a;return this.autoclose&&this.autoCloseActionName&&this.autoCloseActionName===d&&(this.self&&n===((a=this.self)==null?void 0:a.id)||!this.self)&&await this.closeAsync(),this}async closeAsync(){return this.startedClose||(this.startedClose=!0,this.beforeClose()),!this.isValid&&this.self&&!this.added[this.self.id]&&!this.updated[this.self.id]&&this.removed[this.self.id],this.discardOrphans(),this.sanitize(),this.recursiveCaptureUpstreamVersions(),this.captureAllChangesInVersionInstances(),this.recursiveCaptureUpstreamVersions(),this.open=!1,this.isEmpty?(console.warn(`Empty change-set (${this.id}) discarded upon closing.`),this.project.discardChangeSet(this),this.project.closePendingChangeSets(),this):(await this.project.closeChangeSet(this),this)}attemptAutoclose(d,n){var a;return this.autoclose&&this.autoCloseActionName&&this.autoCloseActionName===d&&(this.self&&n===((a=this.self)==null?void 0:a.id)||!this.self)&&this.close(),this}recursiveCaptureUpstreamVersions(){[...this.addedIds,...this.updatedIds,...this.removedIds].forEach(n=>{const a=this.get(n),{added:l,updated:p,removed:t,affected:m}=a.recursiveCaptureUpstreamVersions(this.timestamp);for(const E of l)this.add(E,"added");for(const E of p)this.add(E,"updated");for(const E of t)this.add(E,"removed");for(const E of m)this.add(E,"affected")})}sanitize(){this.listAdded.forEach(d=>{d.previousVersion=null})}syncDependents(){return[...this.list,...this.listAffected].forEach(d=>{const n=this.project.get(d.id);!n||n.deleted||Vb(n,this.project)||n==null||n.syncDependents(this)}),this}beforeClose(){this.syncDependents(),this.emitSideEffects()}emitSideEffects(){Qce(this)}close(){if(this.startedClose||(this.startedClose=!0,this.beforeClose()),!this.isValid&&this.self&&!this.added[this.self.id]&&!this.updated[this.self.id]&&this.removed[this.self.id],this.discardOrphans(),this.sanitize(),this.captureAllChangesInVersionInstances(),this.recursiveCaptureUpstreamVersions(),this.captureAllChangesInVersionInstances(),this.open=!1,this.isEmpty)return console.warn(`Empty change-set (${this.id}) discarded upon closing.`),this.project.discardChangeSet(this),this.project.closePendingChangeSets(),this;if(this.added[this.project.id]&&this.updatedIds.length)throw new Error("No 'updated' entities should be present in the change-set when the project entity is in the 'added' list. New projects can only have newly added entities");if(this.added[this.project.id]&&this.removedIds.length)throw new Error("No 'removed' entities should be present in the change-set when the project entity is in the 'added' list. New projects can only have newly added entities");if(!this.updated[this.project.id]&&!this.added[this.project.id])throw new Error("Change-set must also have the project entity as 'updated' or 'added'. All changes must propagate upstream until the root project entity.");return this.project.closeChangeSet(this),this}addDependentsToAffected(d){Object.values(d.detachedDependents).forEach(n=>{const{entity:a,field:l}=n;this.has(a.id)||this.add(a,"affected")})}get(d){return this.added[d]?this.added[d]:this.updated[d]?this.updated[d]:this.removed[d]?this.removed[d]:null}remove(d){return this.has(d)&&(delete this.added[d],delete this.updated[d],delete this.removed[d],delete this.affected[d],this.seenEntities=this.seenEntities.filter(n=>n!==d)),this}add(d,n,a={preventRecursion:!1}){var p,t,m;if(!this.open||!this.dirty)return this;if(Vb(d,this.project))return this;if(this.seenEntities.indexOf(d.id)===-1&&this.seenEntities.push(d.id),n==="removed"){if(this.added[d.id])return delete this.added[d.id],this.seenEntities=this.seenEntities.filter(b=>b!==d.id),delete this.project.deletedInstances[d.id],this;if(this.updated[d.id]&&delete this.updated[d.id],this.affected[d.id]&&delete this.affected[d.id],!this.hasRemoved(d.id)&&(d.increaseVersion(this.timestamp),!a.preventRecursion)){const{added:b,updated:_,removed:w,affected:V}=d.recursiveCaptureUpstreamVersions(this.timestamp);for(const B of b)this.add(B,"added");for(const B of _)this.add(B,"updated");for(const B of w)this.add(B,"removed");for(const B of V)this.add(B,"affected")}d.captureVersion();const E=(p=d.knownVersions)==null?void 0:p.get(d.version);if(!E)throw Error(`Version ${d.version} should have a cached version instance but it wasn't found when adding entity to change-set`);return this.removed[d.id]=E,this}if(n==="added"){if(this.removed[d.id])return this;if(this.updated[d.id]&&delete this.updated[d.id],this.affected[d.id]&&delete this.affected[d.id],!this.hasAdded(d.id)&&!a.preventRecursion){const{added:b,updated:_,removed:w,affected:V}=d.recursiveCaptureUpstreamVersions(this.timestamp);for(const B of b)this.add(B,"added");for(const B of _)this.add(B,"updated");for(const B of w)this.add(B,"removed");for(const B of V)this.add(B,"affected")}d.previousVersion=null,d.captureVersion();const E=(t=d.knownVersions)==null?void 0:t.get(d.version);if(!E)throw Error(`Version ${d.version} should have a cached version instance but it wasn't found when adding entity to change-set`);return this.added[d.id]=E,delete this.affected[d.id],this.addDependentsToAffected(d),this}if(n==="updated"){if(this.removed[d.id])return this;if(this.added[d.id])return d.captureVersion(),this.addDependentsToAffected(d),this;if(this.affected[d.id]&&delete this.affected[d.id],!this.hasUpdated(d.id)&&(d.increaseVersion(this.timestamp),!a.preventRecursion)){const{added:b,updated:_,removed:w,affected:V}=d.recursiveCaptureUpstreamVersions(this.timestamp);for(const B of b)this.add(B,"added");for(const B of _)this.add(B,"updated");for(const B of w)this.add(B,"removed");for(const B of V)this.add(B,"affected")}d.captureVersion();const E=(m=d.knownVersions)==null?void 0:m.get(d.version);if(!E)throw Error(`Version ${d.version} should have a cached version instance but it wasn't found when adding entity to change-set`);return this.updated[d.id]=E,this.addDependentsToAffected(d),this}if(n==="affected"){if(this.removed[d.id])return this;if(this.added[d.id])return this;if(this.updated[d.id])return this;this.affected[d.id]=d}return this}toJSON(){const d={},n={},a={},l=new Set;for(const p of Object.values(this.added))d[p.id]=p.toShallowJSON();for(const p of Object.values(this.updated))n[p.id]=p.toShallowJSON();for(const p of Object.values(this.removed))a[p.id]=p.toShallowJSON();for(const p of Object.values(this.affected))l.add(p.id);return{added:d,updated:n,removed:a,affected:Array.from(l),self:this.self?this.self.toShallowJSON():null,seenEntities:this.seenEntities}}has(d){return!!this.added[d]||!!this.removed[d]||!!this.updated[d]||!!this.affected[d]}hasAdded(d){return!!this.added[d]}hasUpdated(d){return!!this.updated[d]}hasRemoved(d){return!!this.removed[d]}hasAffected(d){return!!this.affected[d]}}function epe(u){return new Set([...Object.keys(u.added),...Object.keys(u.updated),...Object.keys(u.removed),...Array.from(u.affected)])}function zL(u,d,n){var m;const a=new Date().toISOString(),l=new F(n,P.sessionAuthor,a,n);if(u===d)throw console.error("From: ",u),console.error("To: ",d),new Error("Cannot generate transitional change set between the same two versions or change-sets");let p;if(u==="initial"?p=!0:d==="initial"?p=!1:N(u.timestamp).isBefore(N(d.timestamp))?p=!0:p=!1,console.log("Transitioning from ",u==="initial"?"initial":u.index),console.log("Transitioning to ",d==="initial"?"initial":d.index),console.log("Is forward: ",p),p){const b=d.index,_=u==="initial"?0:u.index;console.log("ownIndex: ",b),console.log("startIndex: ",_);const w=b===_?[n.history[b]]:n.history.slice(_+1,b+1);if(w.sort((V,B)=>N(V.timestamp).isAfter(N(B.timestamp))?1:-1),!w.length)throw new Error("No change sets in the history between the history indexes provided");console.log("REDO change-set: ",w[0].id," ",w[0].timestamp),w.forEach(V=>{HL(V,B=>{const K=n.instances[B.id]||n.deletedInstances[B.id];let q="";try{q=ce(B,n)}catch{}if(!K)throw new Error(`Entity ${B.type} ${q?`"${q}" `:""}with id "${B.id}" doesn't have an 'activeVersion' set.`);if(!K.knownVersions)throw new Error(`Entity ${B.type} ${q?`"${q}" `:""}with id "${B.id}" has an active version instance missing the 'knownVersions' property value.`);if(!K.knownVersions.get(B.version))throw new Error(`Entity ${B.type} ${q?`"${q}" `:""}with id "${B.id}" has an active version instance missing the 'knownVersions' property value for version "${B.version}".`);K.restoreVersion(B.version),l.timestamp=K.createdAt,l.add(K,G.Added,{preventRecursion:!0})},B=>{const K=n.instances[B.id]||n.deletedInstances[B.id];let q="";try{q=ce(B,n)}catch{}if(!K)throw new Error(`Entity ${B.type} ${q?`"${q}" `:""}with id "${B.id}" doesn't have an 'activeVersion' set.`);if(!K.knownVersions)throw new Error(`Entity ${B.type} ${q?`"${q}" `:""}with id "${B.id}" has an active version instance missing the 'knownVersions' property value.`);if(!K.knownVersions.get(B.version))throw new Error(`Entity ${B.type} ${q?`"${q}" `:""}with id "${B.id}" has an active version instance missing the 'knownVersions' property value for version "${B.version}".`);K.restoreVersion(B.version),l.timestamp=K.createdAt,l.add(K,G.Updated,{preventRecursion:!0})},B=>{const K=n.instances[B.id]||n.deletedInstances[B.id];let q="";try{q=ce(B,n)}catch{}if(!K)throw new Error(`Entity ${B.type} ${q?`"${q}" `:""}with id "${B.id}" doesn't have an 'activeVersion' set.`);if(!K.knownVersions)throw new Error(`Entity ${B.type} ${q?`"${q}" `:""}with id "${B.id}" has an active version instance missing the 'knownVersions' property value.`);if(!K.knownVersions.get(B.version))throw new Error(`Entity ${B.type} ${q?`"${q}" `:""}with id "${B.id}" has an active version instance missing the 'knownVersions' property value for version "${B.version}".`);K.restoreVersion(B.version),l.timestamp=K.createdAt,l.add(K,G.Removed,{preventRecursion:!0})})})}else{const b=u.index,_=d==="initial"?0:d.index,w=b===_?[n.history[b]]:n.history.slice(_+1,b+1);if(w.sort((V,B)=>N(B.timestamp).isAfter(N(V.timestamp))?1:-1),!w.length)throw new Error("No change sets in the history between the history indexes provided");console.log("UNDO change-set: ",w[0].id," ",w[0].timestamp),w.forEach(V=>{HL(V,B=>{const K=n.instances[B.id]||n.deletedInstances[B.id];let q="";try{q=ce(B,n)}catch{}if(!K)throw new Error(`Entity ${B.type} ${q?`"${q}" `:""}with id "${B.id}" doesn't have an 'activeVersion' set.`);if(!K.knownVersions)throw new Error(`Entity ${B.type} ${q?`"${q}" `:""}with id "${B.id}" has an active version instance missing the 'knownVersions' property value.`);if(!K.knownVersions.get(B.version))throw new Error(`Entity ${B.type} ${q?`"${q}" `:""}with id "${B.id}" has an active version instance missing the 'knownVersions' property value for version "${B.version}".`);B.previousVersion&&K.restoreVersion(B.previousVersion),l.timestamp=K.createdAt,l.add(K,G.Removed,{preventRecursion:!0})},B=>{const K=n.instances[B.id]||n.deletedInstances[B.id];let q="";try{q=ce(B,n)}catch{}if(!K)throw new Error(`Entity ${B.type} ${q?`"${q}" `:""}with id "${B.id}" doesn't have an 'activeVersion' set.`);if(!K.knownVersions)throw new Error(`Entity ${B.type} ${q?`"${q}" `:""}with id "${B.id}" has an active version instance missing the 'knownVersions' property value.`);if(!K.knownVersions.get(B.version))throw new Error(`Entity ${B.type} ${q?`"${q}" `:""}with id "${B.id}" has an active version instance missing the 'knownVersions' property value for version "${B.version}".`);K.restoreVersion(B.previousVersion),l.timestamp=K.createdAt,l.add(K,G.Updated,{preventRecursion:!0})},B=>{const K=n.instances[B.id]||n.deletedInstances[B.id];let q="";try{q=ce(B,n)}catch{}if(!K)throw new Error(`Entity ${B.type} ${q?`"${q}" `:""}with id "${B.id}" doesn't have an 'activeVersion' set.`);if(!K.knownVersions)throw new Error(`Entity ${B.type} ${q?`"${q}" `:""}with id "${B.id}" has an active version instance missing the 'knownVersions' property value.`);if(!K.knownVersions.get(B.version))throw new Error(`Entity ${B.type} ${q?`"${q}" `:""}with id "${B.id}" has an active version instance missing the 'knownVersions' property value for version "${B.version}".`);K.restoreVersion(B.previousVersion),l.timestamp=K.createdAt,l.add(K,G.Added,{preventRecursion:!0})})})}let t;if(d==="initial"){const E=Array.from(((m=n.knownVersions)==null?void 0:m.values())||[]).reduce((b,_)=>!b||N(_.createdAt).isBefore(N(b.createdAt))?_:b,null);if(!E)throw new Error("No oldest version found");t=E.createdAt}else t=d.timestamp;return l.open=!1,{transitionalChangeSet:l,transitionTime:a,timeOfOriginalTargetChanges:t}}function HL(u,d,n,a){if(!(u!=null&&u.self))throw new Error("Change set must have a valid `self` entity state to be traversed");const l=new Ga(u.self);console.log("changeSet.added: ",Object.keys(u.added).length),console.log("changeSet.updated: ",Object.keys(u.updated).length),console.log("changeSet.removed: ",Object.keys(u.removed).length);const p={...u.added,...u.updated,...u.removed};l.order=Object.keys(p),l.flatRecord=p,l.orderEntities(),console.log("All entities: ",l.order.map((t,m)=>`${m+1}: ${p[t].type} - ${t}`).join(`,
|
|
21
21
|
`)),console.log("Traversing new additions"),l.visit(async t=>{if(u.added[t.id])try{console.log("Adding: ",t.id),d(t)}catch(m){console.error("Error: ",m),console.error("Errored entity: ",t)}}),console.log("Traversing updates"),l.visit(async t=>{if(u.updated[t.id])try{console.log("Updating: ",t.id),n(t)}catch(m){console.error("Error: ",m),console.error("Errored entity: ",t)}}),console.log("Traversing removals"),l.visit(async(t,m)=>{if(u.removed[t.id])try{console.log("Removing: ",t.id),a(t)}catch(E){console.error("Error: ",E),console.error("Errored entity: ",t)}})}function XL(u,d,n){const a=u+1;return d.splice(a,d.length-a,n),d.length-1}function QL(u){const d=KE(),n=u.toJSON();d.safeParse(n).success;const l=[];return qt(u.errors,l)}const tpe=Object.freeze(Object.defineProperty({__proto__:null,validate:QL},Symbol.toStringTag,{value:"Module"}));function rpe(u,d){var a,l;const n=[];if(u.parent)if(u.parent){const p=d.get(u.parent);p?[f.InputMap,f.DataType].includes(p.type)?p.type===f.DataType&&p.entity?n.push(new Y({id:`${u.id}--${u.parent}--${k.NewEntityWouldOverriteExisting}`,code:k.NewEntityWouldOverriteExisting,severity:S.Error,message:`Entity of type "${u.type}" with id "${u.id}", has a 'parent' of type 'data-type' which already has an existing default value entity with id "${p.entity.id}".
|
|
22
22
|
Data types can only have one 'literal-value' entity as 'entity'.
|
|
23
23
|
You can update the existing 'literal-value' with the 'update' action, for example, like so:
|
|
@@ -397,5 +397,5 @@ If an entity is called by another, they must be in the same scope, which means t
|
|
|
397
397
|
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.`,issue:null})),{errors:a,modifiedData:n}}subscribeDependents(n){return n.forEach(a=>{this.detachedDependents[a.entity.id]||(this.detachedDependents[a.entity.id]=a)}),this}unsubscribeDependents(n){return n.forEach(a=>{this.detachedDependents[a.entity.id]&&delete this.detachedDependents[a.entity.id]}),this}syncDependents(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"sync-dependents"))){const a=[],l=[],p=[],t=[];return Object.values(this.detachedDependents).forEach(m=>{const E=m.entity.afterAllChildrenInitialized(n);a.push(...E.updated),l.push(...E.added),p.push(...E.removed),t.push(...E.affected)}),n==null||n.attemptAutoclose("sync-dependents",this.id),{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this}}onDetachedDependencyRemoved(n,a,l){const p=[],t=[],m=[],E=[];if(a==="declaration"){const{updated:b,added:_,removed:w}=this.remove({ignoreUpstream:!1},l);p.push(...b),t.push(..._),m.push(...w)}if(a==="parent"){const{updated:b,added:_,removed:w}=this.remove({ignoreUpstream:!1},l);p.push(...b),t.push(..._),m.push(...w)}return{updated:I(p),added:I(t),removed:I(m),affected:I(E),self:this}}onDetachedDependencyRestored(n,a,l){const p=[],t=[],m=[],E=[];if(a==="declaration"){const{updated:b,added:_,removed:w}=this.restore({},l);p.push(...b),t.push(..._),m.push(...w)}if(a==="parent"){const{updated:b,added:_,removed:w}=this.restore({},l);p.push(...b),t.push(..._),m.push(...w)}return{updated:I(p),added:I(t),removed:I(m),affected:I(E),self:this}}unsubscribeFromDependencies(){var n;return(n=this.parent)==null||n.unsubscribeDependents([{entity:this,field:"parent"}]),this.declaration.unsubscribeDependents([{entity:this,field:"declaration"}]),this}subscribeToDependencies(){var n;return(n=this.parent)==null||n.subscribeDependents([{entity:this,field:"parent"}]),this.declaration.subscribeDependents([{entity:this,field:"declaration"}]),this}increaseVersion(n){if(n&&!N(n).isValid())throw new Error(`The shared timestamp '${n}' is not a valid ISO 8601 date string.`);return n&&N(n).isSame(N(this.createdAt))?this:(this.previousVersion=this.version,this.version=P.UUID.uuid(),this.createdAt=N(n).toISOString()||N().toISOString(),this)}captureVersion(){var a;const n=((a=this.knownVersions)==null?void 0:a.get(this.version))||new Vt(this,this.project);return n.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,n):new Map([[this.version,n]]),n.inputs=[...this.inputs],n.outputs=[...this.outputs],n.error=this.error,n.successCalls=[...this.successCalls],n.errorCalls=[...this.errorCalls],n.process=this.process,n.declaration=this.declaration,n.calledBySuccess=[...this.calledBySuccess],n.calledByError=[...this.calledByError],n.calledByEntry=[...this.calledByEntry],n.parent=this.parent,this}recursiveCaptureUpstreamVersions(n){const a=[],l=[],p=[],t=[];if(this.parent){this.parent.increaseVersion(n);const m=this.parent.recursiveCaptureUpstreamVersions(n);a.push(this.parent,...m.updated),l.push(...m.added),p.push(...m.removed)}return{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this}}async restoreVersion(n){var E;const a=[],l=[],p=[],t=[];if(this.version===n)return{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this};if(!this.knownVersions){const b=new Map;for(const[_,w]of this.knownVersions||new Map){if(b.set(_,w),w.activeVersion=!1,w.knownVersions)for(const[V,B]of w.knownVersions)b.set(V,B);w.knownVersions=null}}let m=(E=this.knownVersions)==null?void 0:E.get(n);if(!m){const b=await this.APILoadVersion({},n);if(!b)throw new Error(`Version with id '${n}' for entity with id '${this.id}' not found.`);m=new Vt(b,this.project)}return this.metaSync(m.toShallowJSON(),null),this.previousVersion=m.previousVersion,this.version=m.version,this.createdAt=m.createdAt,this.author=m.author,this.deleted=m.deleted,this.inputs=m.inputs,this.outputs=m.outputs,this.error=m.error,this.successCalls=m.successCalls,this.errorCalls=m.errorCalls,this.process=m.process,this.declaration=m.declaration,this.calledBySuccess=m.calledBySuccess,this.calledByError=m.calledByError,this.calledByEntry=m.calledByEntry,this.parent=m.parent,{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this}}updateWithShallowTransfer(n,a=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"update-with-shallow-transfer"))){if(this.metaSync(n,a),this.version=n.version,this.createdAt=n.createdAt,this.author=n.author,this.deleted=n.deleted,this.previousVersion=n.previousVersion,this.unsubscribeFromDependencies(),n.parent){const l=W(n.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,a);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(n.declaration){const l=W(n.declaration),p=this.project.get(l);p&&this.setDeclaration(p)}return n.calledByEntry.forEach(l=>{const p=W(l),t=this.project.get(p);t&&(this.addEntryCaller(t,a),t.addCall(this,a))}),[...this.calledByEntry].forEach(l=>{n.calledByEntry.find(t=>t.id===l.id)||(this.removeCaller(l,a),l.removeCall(this,a))}),n.calledBySuccess.forEach(l=>{const p=W(l),t=this.project.get(p);t&&(this.addSuccessCaller(t,a),t.addSuccessCall(this,a))}),[...this.calledBySuccess].forEach(l=>{n.calledBySuccess.find(t=>t.id===l.id)||(this.removeCaller(l,a),l.removeCall(this,a))}),n.calledByError.forEach(l=>{const p=W(l),t=this.project.get(p);t&&(this.addErrorCaller(t,a),t.addErrorCall(this,a))}),[...this.calledBySuccess].forEach(l=>{n.calledBySuccess.find(t=>t.id===l.id)||(this.removeCaller(l,a),l.removeCall(this,a))}),this.captureVersion(),this.subscribeToDependencies(),a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),this}hydrateAncestors(){const n=[],a=[],l=[],p=[];if(this.initialData.parent){const t=W(this.initialData.parent),m=this.project.get(t);if(m)this.setParent(m,null),n.push(m);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.declaration){const t=W(this.initialData.declaration),m=this.project.get(t);m&&(this.setDeclaration(m),n.push(m))}return this.initialData.calledByEntry.forEach(t=>{const m=W(t),E=this.project.get(m);E&&this.addEntryCaller(E,null)}),this.initialData.calledBySuccess.forEach(t=>{const m=W(t),E=this.project.get(m);E&&this.addSuccessCaller(E,null)}),this.initialData.calledByError.forEach(t=>{const m=W(t),E=this.project.get(m);E&&this.addErrorCaller(E,null)}),{updated:I(n),added:I(a),removed:I(l),affected:I(p),self:this}}afterAllChildrenInitialized(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"after-all-children-initialized"))){const a=[],l=[],p=[],t=[];this.initialized=!0;const{updated:m,added:E,removed:b}=this.syncMissingFixedInputs(n),{updated:_,added:w,removed:V}=this.syncMissingFixedOutputs(n);return a.push(...m,..._),l.push(...E,...w),p.push(...b,...V),this.captureVersion(),n==null||n.attemptAutoclose("after-all-children-initialized",this.id),{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this}}addSelfToProject(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"add-self-to-project"))){var m;const a=[this],l=[],p=[],t=[];return this.parent===this.project&&this.project.addFunctionCall(this),(m=this.process)==null||m.writesValues.forEach(E=>{E.setValueWriter(this.process,n),a.push(E)}),this.successCalls.forEach(E=>{E.addSuccessCaller(this,n),a.push(E)}),this.errorCalls.forEach(E=>{E.addErrorCaller(this,n),a.push(E)}),this.calledBySuccess.forEach(E=>{E.addSuccessCall(this,n),a.push(E)}),this.calledByError.forEach(E=>{E.addErrorCall(this,n),a.push(E)}),this.calledByEntry.forEach(E=>{E.addCall(this,n),a.push(E)}),this.subscribe(),this.subscribeToDependencies(),n==null||n.attemptAutoclose("add-self-to-project",this.id),{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}removeInput(n,a=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"remove-input"))){const l=this.inputs.findIndex(p=>p.id===n.id);return l>-1&&(this.inputs.splice(l,1),a&&(a==null||a.add(this,G.Affected))),a==null||a.attemptAutoclose("remove-input",this.id),this}addInput(n,a=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"add-input"))){return this.inputs.includes(n)?(a==null||a.attemptAutoclose("add-input",this.id),this):(this.inputs.push(n),a==null||a.add(this,G.Affected),a==null||a.attemptAutoclose("add-input",this.id),this)}addOutput(n,a=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"add-output"))){return this.outputs.includes(n)?(a==null||a.attemptAutoclose("add-output",this.id),this):(this.outputs.push(n),a==null||a.add(this,G.Affected),a==null||a.attemptAutoclose("add-output",this.id),this)}removeOutput(n,a=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"remove-output"))){const l=this.outputs.findIndex(p=>p.id===n.id);return l>-1&&(this.outputs.splice(l,1),a&&(a==null||a.add(this,G.Affected))),a==null||a.attemptAutoclose("remove-output",this.id),this}addValueReader(n,a=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"add-value-reader"))){var l;return this.process&&!this.process.writesValues.includes(n)&&((l=this.process)==null||l.addValueReader(n,a),a==null||a.add(this,G.Affected)),a==null||a.attemptAutoclose("add-value-reader",this.id),this}removeValueReader(n,a=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"remove-value-reader"))){var l;return this.process&&this.process.writesValues.includes(n)&&((l=this.process)==null||l.removeValueReader(n,a),a==null||a.add(this,G.Affected)),a==null||a.attemptAutoclose("remove-value-reader",this.id),this}addSuccessCaller(n,a=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"add-success-caller")),l=!1){return this.calledBySuccess.find(p=>p.id===n.id)||(this.calledBySuccess.push(n),a==null||a.add(this,G.Updated),l&&Me(this,a)),a==null||a.attemptAutoclose("add-success-caller",this.id),this}addErrorCaller(n,a=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"add-error-caller")),l=!1){return this.calledByError.find(p=>p.id===n.id)||(this.calledByError.push(n),a==null||a.add(this,G.Updated),l&&Me(this,a)),a==null||a.attemptAutoclose("add-error-caller",this.id),this}addEntryCaller(n,a=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"add-entry-caller")),l=!1){return this.calledByEntry.find(p=>p.id===n.id)||(this.calledByEntry.push(n),a==null||a.add(this,G.Updated),l&&Me(this,a)),a==null||a.attemptAutoclose("add-entry-caller",this.id),this}addErrorCall(n,a=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"add-error-call")),l=!1){return this.errorCalls.find(p=>p.id===n.id)||(this.errorCalls.push(n),l&&Me(this,a),a==null||a.add(this,G.Affected)),a==null||a.attemptAutoclose("add-error-call",this.id),this}addSuccessCall(n,a=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"add-success-call")),l=!1){return this.successCalls.find(p=>p.id===n.id)||(this.successCalls.push(n),l&&Me(this,a),a==null||a.add(this,G.Affected)),a==null||a.attemptAutoclose("add-success-call",this.id),this}removeCall(n,a=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"remove-call")),l=!1){const p=this.successCalls.findIndex(m=>m.id===n.id);p>-1&&(this.successCalls.splice(p,1),a==null||a.add(this,G.Affected));const t=this.errorCalls.findIndex(m=>m.id===n.id);return t>-1&&(this.errorCalls.splice(t,1),a==null||a.add(this,G.Affected)),l&&Me(this,a),a==null||a.attemptAutoclose("remove-call",this.id),this}removeCaller(n,a=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"remove-caller")),l=!1){return this.calledBySuccess=this.calledBySuccess.filter(p=>p.id!==n.id?!0:(a==null||a.add(this,G.Updated),a==null||a.add(p,G.Affected),!1)),this.calledByError=this.calledByError.filter(p=>p.id!==n.id?!0:(a==null||a.add(this,G.Updated),a==null||a.add(p,G.Affected),!1)),this.calledByEntry=this.calledByEntry.filter(p=>p.id!==n.id?!0:(a==null||a.add(this,G.Updated),a==null||a.add(p,G.Affected),!1)),l&&Me(this,a),a==null||a.attemptAutoclose("remove-caller",this.id),this}setParent(n,a=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"set-parent"))){var l;return((l=this.parent)==null?void 0:l.id)!==(n==null?void 0:n.id)&&(this.parent=n,a&&(a==null||a.add(this,G.Updated))),a==null||a.attemptAutoclose("set-parent",this.id),this}setDeclaration(n){return this.declaration=n,this}initChildren(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"init-children"))){if(this.initialized||this.startedInitialization)return this;if(this.startedInitialization=!0,this.initialData.declaration.type===f.FunctionDeclaration){const a=z(this.initialData.declaration,this.project);this.declaration=a}else{const a=W(this.initialData.declaration),l=this.project.get(a);this.declaration=l}return this.successCalls=this.initialData.successCalls.map(a=>{const l=z(a,this.project);if(l.addSuccessCaller(this),[f.BreakStatement,f.ContinueStatement].includes(l.type))l.setParent(this.parent.parent,null),l.initChildren(n);else if(l.type===f.ReturnStatement){const p=Rr(this,this.project);l.setParent(p,null),l.initChildren(n)}else l.type!==f.InternalCall&&(l.setParent(this.parent,null),l.initChildren(n));return l}),this.errorCalls=this.initialData.errorCalls.map(a=>{const l=z(a,this.project);if(l.addErrorCaller(this),[f.BreakStatement,f.ContinueStatement].includes(l.type))l.setParent(this.parent.parent,null),l.initChildren(n);else if(l.type===f.ReturnStatement){const p=Rr(this,this.project);l.setParent(p,null),l.initChildren(n)}else l.type!==f.InternalCall&&(l.setParent(this.parent,null),l.initChildren(n));return l}),this.inputs=this.initialData.inputs.map(a=>{const l=z(a,this.project);return l.setParent(this,null),l.initChildren(n),l}),this.initialData.process&&(this.process=z(this.initialData.process,this.project),this.process.setParent(this,null),this.process.initChildren(n)),this.initialData.error&&(this.error=z(this.initialData.error,this.project),this.error.setParent(this,null),this.error.initChildren(n)),this.subscribeToDependencies(),this.afterAllChildrenInitialized(n),n==null||n.attemptAutoclose("init-children",this.id),this}subscribe(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(n,a=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"meta-sync"))){const l=cr(this,n),p=this.toMeta();return this.x=n.x||p.x,this.y=n.y||p.y,super.metaSync(n),n.deleted===!0&&!p.deleted?a==null||a.add(this,G.Removed):n.deleted===!1&&p.deleted?a==null||a.add(this,G.Added):l&&(a==null||a.add(this,G.Updated)),a==null||a.attemptAutoclose("meta-sync",this.id),this}async APILoad(n=oe,...a){return await Vt.repository.APILoad(this.id,...a),this}async APICreate(n=oe,...a){return await Vt.repository.APICreate(this.toShallowJSON(),...a),this}async APIUpdate(n=oe,...a){return await Vt.repository.APIUpdate(this.toShallowJSON(),...a),this}async APIDelete(n=oe,...a){return await Vt.repository.APIDelete(this.toShallowJSON(),...a),this}async APIClone(n=oe,...a){return await Vt.repository.APIClone(this.id,...a),this}async APILoadVersion(n=oe,a,...l){return await Vt.repository.APILoadVersion(this.id,a,...l)}removeFromParent(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"remove-from-parent"))){const a=[],l=[],p=[],t=[];return this.parent.type===f.Project?(this.parent.removeFunctionCall(this),t.push(this.parent)):this.parent.detachedChildren.includes(this)&&this.parent.unsubscribeDetachedChild(this),n==null||n.attemptAutoclose("remove-from-parent",this.id),{added:I(p),updated:I(a),removed:I(l),affected:I(t),self:this}}remove({ignoreUpstream:n}={ignoreUpstream:!1},a=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"remove-entity"))){var E;const l=[],p=[],t=[],m=[];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(b=>{const{updated:_,removed:w,added:V}=b.entity.onDetachedDependencyRemoved(this,b.field,a);l.push(..._),p.push(...w),t.push(...V)}),this.process){const{updated:b,removed:_}=(E=this.process)==null?void 0:E.remove({ignoreUpstream:!0},a);l.push(...b),p.push(..._)}if(this.inputs.forEach(b=>{const{updated:_,removed:w}=b.remove({ignoreUpstream:!0},a);l.push(..._),p.push(...w)}),this.outputs.forEach(b=>{const{updated:_,removed:w}=b.remove({ignoreUpstream:!0},a);l.push(..._),p.push(...w)}),this.error){const{updated:b,removed:_}=this.error.remove({ignoreUpstream:!0},a);l.push(...b),p.push(..._)}if(this.successCalls.forEach(b=>{l.push(b),b.removeCaller(this,a)}),this.errorCalls.forEach(b=>{l.push(b),b.removeCaller(this,a)}),!n){const b=this.removeFromParent(a);t.push(...b.added),l.push(...b.updated),p.push(...b.removed),m.push(...b.affected),this.calledBy.forEach(_=>{l.push(_),_.removeCall(this,a)})}return a==null||a.attemptAutoclose("remove-entity",this.id),{added:I(t),updated:I(l),removed:I(p),affected:I(m),self:this}}restore({}={},n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"restore-entity"))){const a=[],l=[],p=[],t=[];if(n!=null&&n.hasAdded(this.id))return n==null||n.attemptAutoclose("restore-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},n),Object.values(this.detachedDependents).forEach(m=>{const{updated:E,removed:b,added:_}=m.entity.onDetachedDependencyRestored(this,m.field,n);l.push(...E),p.push(...b),a.push(..._)}),this.process){const{updated:m}=this.process.restore({},n);l.push(...m)}return this.inputs.forEach(m=>{const{updated:E}=m.restore({},n);l.push(...E)}),this.outputs.forEach(m=>{const{updated:E}=m.restore({},n);l.push(...E)}),this.successCalls.forEach(m=>{l.push(m),m.addSuccessCaller(this,n)}),this.errorCalls.forEach(m=>{l.push(m),m.addErrorCaller(this,n)}),this.calledBySuccess.forEach(m=>{l.push(m),m.addSuccessCall(this,n)}),this.calledByError.forEach(m=>{l.push(m),m.addErrorCall(this,n)}),this.calledByEntry.forEach(m=>{l.push(m),m.addCall(this,n)}),n==null||n.attemptAutoclose("restore-entity",this.id),{added:I(a),updated:I(l),removed:I(p),affected:I(t),self:this}}toFlat(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[this,...this.successCalls.flatMap(l=>l.toFlat(n)),...this.errorCalls.flatMap(l=>l.toFlat(n)),...this.inputs.flatMap(l=>l.toFlat(n)),...this.outputs.flatMap(l=>l.toFlat(n)),...this.process?this.process.toFlat(n):[],...this.error?this.error.toFlat(n):[],...this.calledBy.flatMap(l=>l.toFlat(n))])}toFlatIds(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[this.id,...this.successCalls.flatMap(l=>l.toFlatIds(n)),...this.errorCalls.flatMap(l=>l.toFlatIds(n)),...this.inputs.flatMap(l=>l.toFlatIds(n)),...this.outputs.flatMap(l=>l.toFlatIds(n))])}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}}toJSON(n=new Set){var a,l;return n.has(this.id)?this.toReference():(n.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,x:this.x,y:this.y,successCalls:this.successCalls.map(p=>p.toJSON(n)),errorCalls:this.errorCalls.map(p=>p.toJSON(n)),calledBySuccess:this.calledBySuccess.map(p=>p.toReference()),calledByError:this.calledByError.map(p=>p.toReference()),calledByEntry:this.calledByEntry.map(p=>p.toReference()),process:(a=this.process)==null?void 0:a.toJSON(n),declaration:this.declaration.toJSON(n),inputs:this.inputs.map(p=>p.toJSON(n)),outputs:this.outputs.map(p=>p.toJSON(n)),parent:this.parent.toReference(),error:(l=this.error)==null?void 0:l.toJSON(n)})}toJSONClone(n=Oe){var l,p,t,m,E,b,_;let a;return(l=n.seenEntityMaps)!=null&&l.has(this.id)?a=n.seenEntityMaps.get(this.id):(a=n.newId||hr(this,this.project,n.uuidStrategy),n.seenEntityMaps&&n.seenEntityMaps.set(this.id,a)),(p=n.seenEntities)!=null&&p.has(a)||(t=n.seenEntities)!=null&&t.has(this.id)?this.toReference({seenEntityMaps:n.seenEntityMaps}):((m=n.seenEntities)==null||m.add(a),(E=n.seenEntities)==null||E.add(this.id),{id:a,version:P.UUID.uuid(),createdAt:n.timestamp||N().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,type:this.type,x:this.x,y:this.y,successCalls:this.successCalls.map(w=>w.toJSONClone({...n,newId:null})),errorCalls:this.errorCalls.map(w=>w.toJSONClone({...n,newId:null})),calledBySuccess:this.calledBySuccess.map(w=>w.toReference({seenEntityMaps:n.seenEntityMaps})),calledByError:this.calledByError.map(w=>w.toReference({seenEntityMaps:n.seenEntityMaps})),calledByEntry:this.calledByEntry.map(w=>w.toReference({seenEntityMaps:n.seenEntityMaps})),process:(b=this.process)==null?void 0:b.toJSONClone({...n,newId:null}),declaration:this.declaration.toJSONClone({...n,newId:null}),inputs:this.inputs.map(w=>w.toJSONClone({...n,newId:null})),outputs:this.outputs.map(w=>w.toJSONClone({...n,newId:null})),error:(_=this.error)==null?void 0:_.toJSONClone({...n,newId:null}),parent:this.parent.toReference({seenEntityMaps:n.seenEntityMaps})})}toReference(n=Oe){var l;let a=this.id;return(l=n.seenEntityMaps)!=null&&l.has(this.id)&&(a=n.seenEntityMaps.get(this.id)),{id:a+"--"+P.UUID.uuid()+"--ref",type:f.GenericReference,entityId:a,version:this.version,entityType:this.type}}toShallowJSON(n=Oe){var l;let a=this.id;return(l=n.seenEntityMaps)!=null&&l.has(this.id)&&(a=n.seenEntityMaps.get(this.id)),{id:a,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,x:this.x,y:this.y,process:this.process?this.process.toReference(n):null,inputs:this.inputs.map(p=>p.toReference(n)),outputs:this.outputs.map(p=>p.toReference(n)),declaration:this.declaration.toReference(n),successCalls:this.successCalls.map(p=>p.toReference(n)),errorCalls:this.errorCalls.map(p=>p.toReference(n)),calledBySuccess:this.calledBySuccess.map(p=>p.toReference(n)),calledByError:this.calledByError.map(p=>p.toReference(n)),calledByEntry:this.calledByEntry.map(p=>p.toReference(n)),error:this.error?this.error.toReference(n):null,parent:this.parent.toReference(n)}}toFlatJSON(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[this.toShallowJSON(),...this.successCalls.flatMap(l=>l.toFlatJSON(n)),...this.errorCalls.flatMap(l=>l.toFlatJSON(n)),...this.inputs.flatMap(l=>l.toFlatJSON(n)),...this.outputs.flatMap(l=>l.toFlatJSON(n)),...this.process?this.process.toFlatJSON(n):[],...this.error?this.error.toFlatJSON(n):[]])}toGenerationTarget(){const n=this.parent.type===f.Project?void 0:this.parent.id;return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,calledByEntry:this.calledByEntry.map(a=>a.id),calledBySuccess:this.calledBySuccess.map(a=>a.id),calledByError:this.calledByError.map(a=>a.id),declaration:this.declaration.id,parent:n}}toFlatGenerationTarget(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[this.toGenerationTarget(),...this.successCalls.flatMap(l=>l.toFlatGenerationTarget(n)),...this.errorCalls.flatMap(l=>l.toFlatGenerationTarget(n)),...this.inputs.flatMap(l=>l.toFlatGenerationTarget(n)),...this.outputs.flatMap(l=>l.toFlatGenerationTarget(n)),...this.process?this.process.toFlatGenerationTarget(n):[],...this.error?this.error.toFlatGenerationTarget(n):[]])}clearErrors(){var n,a;return this.errors=[],this.inputs.forEach(l=>l.clearErrors()),this.outputs.forEach(l=>l.clearErrors()),this.successCalls.forEach(l=>l.clearErrors()),this.errorCalls.forEach(l=>l.clearErrors()),(n=this.process)==null||n.clearErrors(),(a=this.error)==null||a.clearErrors(),this}validate(){const n=aU(this);return this.errors=n,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors,...this.inputs.flatMap(a=>a.getErrors()),...this.outputs.flatMap(a=>a.getErrors()),...this.error?this.error.getErrors():[],...this.process?this.process.getErrors():[]]}getShallowErrors(){return this.errors}clone(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"clone-entity")),a=null,l=null,p=!0){var K,q;let t=yr(a,this);const m=this.toJSON(),E=l||P.UUID.uuid();m.inputs=[];const b=E.split("-id"),_=b[b.length-1||0]||E;m.id=E,m.version=P.UUID.uuid(),m.createdAt=(n==null?void 0:n.timestamp)||N().toISOString(),m.author=(n==null?void 0:n.author)||"1",m.previousVersion=null,m.deleted=!1;const w=er(m,t);a?w.setParent(a,null):w.setParent(this.parent,null),p&&w.subscribe(),w.initChildren(n),n==null||n.add(w,G.Added);const V=(K=this.inputs)==null?void 0:K.map((Z,Q)=>Z.clone(n,w,_+"-input-map-"+Q+"-id",p));w.inputs=V;const B=(q=this.outputs)==null?void 0:q.map((Z,Q)=>Z.clone(n,w,_+"-output-map-"+Q+"-id",p));return w.outputs=B,this.error&&(w.error=this.error.clone(n,w,_+"-error-map-id",p)),this.process&&(w.process=this.process.clone(n,w,_+"-process-id",p)),n==null||n.attemptAutoclose("clone-entity",this.id),w}removeUnrecognizedInputs(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"remove-unrecognized-inputs"))){const a=[],l=[],p=[],t=[];return this.inputs.forEach(m=>{if(!this.declaration.inputs.find(b=>{var _;return b.id===((_=m.declaration)==null?void 0:_.id)})){const b=m.remove({ignoreUpstream:!1},n);p.push(...b.removed),a.push(...b.updated)}}),n==null||n.attemptAutoclose("remove-unrecognized-inputs",this.id),{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this}}removeUnrecognizedOutputs(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"remove-unrecognized-outputs"))){const a=[],l=[],p=[],t=[];return this.outputs.forEach(m=>{if(!this.declaration.getUniqueReturnDeclarations().find(b=>{var _;return b.id===((_=m.declaration)==null?void 0:_.id)})){const b=m.remove({ignoreUpstream:!1},n);p.push(...b.removed),a.push(...b.updated)}}),n==null||n.attemptAutoclose("remove-unrecognized-outputs",this.id),{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this}}syncMissingFixedInputs(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"sync-missing-fixed-inputs"))){const a=[],l=[],p=[],t=[],m=this.declaration.inputs.filter(w=>!this.inputs.find(V=>V.declaration.id===w.id));this.inputs.sort((w,V)=>w.index-V.index),m.forEach(w=>{this.inputs.forEach(K=>{K.index>=w.index&&K.metaSync({index:K.index+1},n)});const V={id:P.UUID.uuid(),version:P.UUID.uuid(),createdAt:(n==null?void 0:n.timestamp)||N().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,type:f.InputMap,declaration:w.toJSON(),readsValue:null,defaultValue:null,index:w.index,name:null,description:null,parent:this.toReference()},B=z(V,this.project);B.setParent(this,n),B.initChildren(n),n==null||n.add(B,G.Added),B.addSelfToProject(n),l.push(B)}),this.inputs.sort((w,V)=>w.index-V.index);const{updated:E,added:b,removed:_}=this.removeUnrecognizedInputs(n);return a.push(...E),l.push(...b),p.push(..._),n==null||n.attemptAutoclose("sync-missing-fixed-inputs",this.id),{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this}}syncMissingFixedOutputs(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"sync-missing-fixed-outputs"))){const a=[],l=[],p=[],t=[],m=[];this.outputs=this.initialData.outputs.reduce((V,B)=>{if(B.type===f.GenericReference){const q=ss(B,this.project);return q?[...V,q]:V}const K=z(B,this.project);return m.push(K.index),K.setParent(this,null),K.initChildren(n),[...V,K]},[]);const E=this.declaration.getUniqueReturnDeclarations().filter(V=>!this.outputs.find(B=>B.declaration.id===V.id));this.outputs.sort((V,B)=>V.index-B.index),E.forEach((V,B)=>{this.outputs.forEach(Q=>{Q.index>=V.index&&Q.index++});const K=m.includes(V.index)?this.outputs.length-1+B:V.index,q={id:P.UUID.uuid(),version:P.UUID.uuid(),createdAt:(n==null?void 0:n.timestamp)||N().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,type:f.OutputMap,declaration:V.toJSON(),defaultValue:null,writesValues:[],index:K,parent:this.toReference()},Z=z(q,this.project);Z.setParent(this,n),Z.initChildren(n),n==null||n.add(Z,G.Added),Z.addSelfToProject(n)}),this.outputs.sort((V,B)=>V.index-B.index);const{updated:b,added:_,removed:w}=this.removeUnrecognizedOutputs(n);return a.push(...b),l.push(..._),p.push(...w),n==null||n.attemptAutoclose("sync-missing-fixed-outputs",this.id),{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this}}};g(Vt,"repository",{APICreate:async(n,...a)=>n,APIUpdate:async(n,...a)=>n,APIDelete:async(n,...a)=>n,APIClone:async(n,...a)=>{},APILoad:async(n,...a)=>null,APILoadVersion:async(n,a,...l)=>null}),g(Vt,"type",f.FunctionCall),g(Vt,"USER_MANAGED_PARENT_TYPES",[...br,f.Project]),g(Vt,"PARENT_TYPES",[...Vt.USER_MANAGED_PARENT_TYPES]),g(Vt,"MUTABLE_BASE_PROPERTIES",[]),g(Vt,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),g(Vt,"BASE_PROPERTIES",[...Vt.MUTABLE_BASE_PROPERTIES,...Vt.INMUTABLE_BASE_PROPERTIES]),g(Vt,"MUTABLE_META_PROPERTIES",["x","y"]),g(Vt,"INMUTABLE_META_PROPERTIES",[...Vt.INMUTABLE_BASE_PROPERTIES]),g(Vt,"META_PROPERTIES",[...Vt.MUTABLE_META_PROPERTIES,...Vt.INMUTABLE_META_PROPERTIES]),g(Vt,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry"]),g(Vt,"INMUTABLE_UPSTREAM_PROPERTIES",["declaration","parent"]),g(Vt,"UPSTREAM_PROPERTIES",[...Vt.MUTABLE_UPSTREAM_PROPERTIES,...Vt.INMUTABLE_UPSTREAM_PROPERTIES]),g(Vt,"MUTABLE_DOWNSTREAM_PROPERTIES",["successCalls","errorCalls","writesValues","inputs","outputs","error"]),g(Vt,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),g(Vt,"DOWNSTREAM_PROPERTIES",[...Vt.MUTABLE_DOWNSTREAM_PROPERTIES,...Vt.INMUTABLE_DOWNSTREAM_PROPERTIES]),g(Vt,"PROPERTIES",[...Vt.META_PROPERTIES,...Vt.UPSTREAM_PROPERTIES,...Vt.DOWNSTREAM_PROPERTIES]);let Fa=Vt;function vb(u){return u&&typeof u.then=="function"}class Ga{constructor(d){g(this,"order",[]);g(this,"flatRecord",{});g(this,"allBuiltInEntityIds",bs());g(this,"onGoingVisits",{});this.flatten(d),this.orderEntities()}flatten(d){const n=new Set(bs()),a=I(ae(d,n,{ignoreBuiltInBaseEntities:!0})),l=new Set;for(const p of a)this.flatRecord[p.id]=p,l.add(p.id);this.order=Array.from(l)}moveEntityAfterDependencies(d){const{upstream:n}=rp(d,this.flatRecord,{ignoreBuiltInBaseEntities:!0,allBuiltInEntityIds:this.allBuiltInEntityIds});for(const a of Object.keys(n)){const l=this.order.indexOf(a),p=this.order.indexOf(d.id);if(l>p)return this.order.splice(p,1),this.order.splice(l,0,d.id),!0}return!1}orderEntities(){let d=!1;for(let n=0;n<this.order.length;n++){const a=this.order[n],l=this.flatRecord[a];if(l||console.warn(`Entity with id ${a} not found in flatRecord. Skipping...`),this.moveEntityAfterDependencies(l)){d=!0;break}}d&&this.orderEntities()}getUpstreamOngoingDependenciesVisits(d,n){const{upstream:a}=rp(this.flatRecord[d],this.flatRecord,{ignoreBuiltInBaseEntities:!0,allBuiltInEntityIds:this.allBuiltInEntityIds}),l={};return Object.entries(this.onGoingVisits[n]||{}).forEach(([p,t])=>{Object.keys(a).includes(p)&&(l[p]=t)}),l}getDownstreamOngoingDependenciesVisits(d,n){const a=Object.keys(this.onGoingVisits[n]||{}),l=new Set(a.flatMap(t=>Object.keys(rp(this.flatRecord[t],this.flatRecord,{ignoreBuiltInBaseEntities:!0,allBuiltInEntityIds:this.allBuiltInEntityIds}).downstream))),p={};return Array.from(l).forEach(t=>{t===d&&(p[t]=this.onGoingVisits[n][t])}),p}async settlePromises(d,n){const a=Object.values(d);a.length&&await Promise.all(a),Object.keys(d).forEach(l=>{delete this.onGoingVisits[n][l]})}visit(d){const n=this.order;for(const a of n)d(this.flatRecord[a],this.flatRecord);return this}reverseVisit(d){const n=this.order.slice().reverse();for(const a of n)d(this.flatRecord[a],this.flatRecord);return this}async visitAsync(d){const n=this.order,a=Math.random().toString(36).substring(7);this.onGoingVisits[a]={};for(const l of n){const p=this.getUpstreamOngoingDependenciesVisits(l,a);Object.keys(p).length&&await this.settlePromises(p,a);const t=d(this.flatRecord[l],this.flatRecord);vb(t)&&(this.onGoingVisits[a][l]=t)}return await this.settlePromises(this.onGoingVisits[a],a),this.onGoingVisits[a]={},this}async reverseVisitAsync(d){const n=this.order.slice().reverse(),a=Math.random().toString(36).substring(7);this.onGoingVisits[a]={};for(const l of n){const p=this.getDownstreamOngoingDependenciesVisits(l,a);Object.keys(p).length&&await this.settlePromises(p,a);const t=d(this.flatRecord[l],this.flatRecord);vb(t)&&(this.onGoingVisits[a][l]=t)}return await this.settlePromises(this.onGoingVisits[a],a),this.onGoingVisits[a]={},this}}function lU(u,d){switch(u.id){case pe["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.id:{const n=u.project.entities.filter(E=>!!E.implements.find(b=>b.id===pe["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id)),a=n.find(E=>{const b=E.properties.find(V=>V.implements&&V.implements.id===pe["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id),_=b==null?void 0:b.getDefaultValue();return(_==null?void 0:_.value)===!0});if(!a&&n.length){const b=n[0].properties.find(w=>w.implements&&w.implements.id===pe["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id),_=b==null?void 0:b.defaultValue;if(_)_.metaSync({value:!0},d);else if(b!=null&&b.dataType){const w={id:P.UUID.uuid(),version:P.UUID.uuid(),createdAt:(d==null?void 0:d.timestamp)||new Date().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,type:f.LiteralValue,name:te.EntityTemplate,autogeneration:null,value:!0,valueAsTypeSingle:null,valueAsTypeList:null,parent:b==null?void 0:b.toReference()},V=z(w,u.project);return V.setParent(b,d),V.initChildren(d),d==null||d.add(V,G.Added),V.addSelfToProject(d),{newEntities:[V]}}return{newEntities:[]}}else if(a)return{newEntities:[]};const l=u.project.get(pe["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id),p=hy(l,"Main database",d);if(p.errors.length>0)return{newEntities:[]};const t=p.properties.find(E=>E.implements&&E.implements.id===pe["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id),m=t==null?void 0:t.defaultValue;if(m)m.metaSync({value:!0},d);else if(t!=null&&t.dataType){const E={id:P.UUID.uuid(),version:P.UUID.uuid(),createdAt:(d==null?void 0:d.timestamp)||new Date().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,type:f.LiteralValue,name:te.EntityTemplate,autogeneration:null,value:!0,valueAsTypeSingle:null,valueAsTypeList:null,parent:t==null?void 0:t.toReference()},b=z(E,u.project);b.setParent(t,d),b.initChildren(d),d==null||d.add(b,G.Added),b.addSelfToProject(d)}return{newEntities:[p]}}}return{newEntities:[]}}function dU(u,d){const n=[],a=[],l=[],p=[];return u.implements.filter(m=>m.type===f.BuiltInBaseEntity).forEach(m=>{var E;switch(m.id){case pe["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.id:{const b=u.project.entities.filter(B=>B.implements.find(K=>K.id===pe["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id));let _=b.find(B=>!!B.properties.find(K=>{var q;return K.implements&&K.implements.id===pe["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id&&((q=K.getDefaultValue())==null?void 0:q.value)===!0}));if(!_&&b.length)_=b[0];else if(!_&&!b.length){_=u.project.getBuiltIn(pe["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id).implement("Relational database",d);const K=_.properties.find(q=>{var Z;return((Z=q.implements)==null?void 0:Z.id)===pe["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id});(E=K==null?void 0:K.defaultValue)==null||E.metaSync({value:!0},d),a.push(_)}const w=u.properties.find(B=>B.implements&&B.implements.id===pe["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.properties.database.id),V=w==null?void 0:w.defaultValue;if(w&&!V){const B={id:P.UUID.uuid(),version:P.UUID.uuid(),createdAt:(d==null?void 0:d.timestamp)||new Date().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,type:f.LiteralValue,name:te.EntityTemplate,autogeneration:null,value:null,valueAsTypeSingle:(_==null?void 0:_.toJSON())||null,valueAsTypeList:null,parent:w==null?void 0:w.toReference()},K=z(B,u.project);K.hydrateAncestors(),K.setParent(w,d),K.addSelfToProject(d),K.initChildren(d),d==null||d.add(K,G.Added),a.push(K);return}else V&&!V.valueAsTypeSingle&&V.setValueAsTypeSingle(_||null,d);return}}}),{self:u,updated:I(n),added:I(a),removed:I(l),affected:I(p)}}function hy(u,d,n,a){const l=a||P.UUID.uuid(),p=P.UUID.uuid(),t={id:l,version:p,createdAt:(n==null?void 0:n.timestamp)||new Date().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,name:d,type:f.DefinitionEntity,description:null,static:u.static,abstract:!1,properties:[],methods:[],abstractMethods:[],extends:[],implements:[u.toJSON()],x:0,y:0,parent:u.project.toReference()};lU(u,n);const m=z(t,u.project);return m.hydrateAncestors(),n==null||n.add(m,G.Added),m.addSelfToProject(n),m.addImplementation(u),m.setParent(u.project,n),m.initChildren(n),dU(m,n),m}function Eb(u,d){return d.entities.find(l=>{const p=l.properties,t=p.map(w=>w.name),m=u.every(w=>t.includes(w)),E=t.filter(w=>!u.includes(w)),b=p.every(w=>!E.includes(w.name)||!w.required);return m&&b})||null}function uU(u,d,n,a=Fr.OrDataTypeGroup){const l=[],p=[],t=[],m=[],b={id:P.UUID.uuid(),version:P.UUID.uuid(),createdAt:(n==null?void 0:n.timestamp)||new Date().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,type:f.DataType,options:null,implementationChooseOne:!1,entity:u.toJSON(),isList:!1,asType:null,andChildrenGroup:null,orChildrenGroup:null,staticEntities:null,interactiveEntities:null,actionEntities:null,like:!0,inferred:!1,parentRelationType:a,parent:d.toReference()},_=z(b,u.project);return p.push(_),_.setParent(d,n),_.initChildren(n),n==null||n.add(_,G.Added),_.setEntity(u,n),_.addSelfToProject(n),{updated:I(l),added:I(p),removed:I(t),affected:I(m),self:_}}function Tb(u,d,n,a,l){var b,_,w,V,B,K,q,Z;const p=[],t=[],m=[],E=[];switch(typeof u){case"string":let Q=!1;const ie=new Date(u);if(ie instanceof Date&&!isNaN(ie.valueOf())&&(Q=!0),Q){const H=d.project.getBuiltIn(pe[f.PrimitiveEntity][te.Date].id);d.setEntity(H,a);break}else{const H=d.project.getBuiltIn(pe[f.PrimitiveEntity][te.String].id);d.setEntity(H,a);break}case"number":d.setEntity(d.project.getBuiltIn(pe[f.PrimitiveEntity][te.Number].id),a);break;case"boolean":d.setEntity(d.project.getBuiltIn(pe[f.PrimitiveEntity][te.Boolean].id),a);break;case"object":if(u===null){d.setEntity(d.project.getBuiltIn(pe[f.PrimitiveEntity][te.Null].id),a);break}else if(Array.isArray(u))if(d.metaSync({isList:!0},a),u.length>0){const H=u.slice(0,5).filter(re=>re!==void 0);if(H.every(re=>typeof re==typeof H[0])&&(typeof H[0]!="object"||H[0]===null))switch(typeof H[0]){case"string":d.setEntity(d.project.getBuiltIn(pe[f.PrimitiveEntity][te.String].id),a);break;case"number":d.setEntity(d.project.getBuiltIn(pe[f.PrimitiveEntity][te.Number].id),a);break;case"boolean":d.setEntity(d.project.getBuiltIn(pe[f.PrimitiveEntity][te.Boolean].id),a);break;case"object":d.setEntity(d.project.getBuiltIn(pe[f.PrimitiveEntity][te.Null].id),a);break}else{const re=[];let Te=!1;H.forEach(ue=>{var ve,X,de,$e;if(Array.isArray(ue)&&(Te=!0),typeof ue=="object"&&!Array.isArray(ue)&&ue!==null){const at=yy(ue,d.project,{...n,id:P.UUID.uuid()},a,l);at.hasCreated&&re.push((ve=at.changeSet)==null?void 0:ve.self),p.push(...(X=at.changeSet)==null?void 0:X.updated),t.push(...(de=at.changeSet)==null?void 0:de.added),m.push(...($e=at.changeSet)==null?void 0:$e.removed)}});const Ve=I(re);if(!Ve.length&&!Te){H.forEach(ue=>{const ve={id:P.UUID.uuid(),version:P.UUID.uuid(),createdAt:(a==null?void 0:a.timestamp)||new Date().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,type:f.DataType,options:null,implementationChooseOne:!1,entity:null,isList:!1,asType:null,andChildrenGroup:null,orChildrenGroup:null,staticEntities:!1,interactiveEntities:!0,actionEntities:!1,like:!0,inferred:!1,parentRelationType:Fr.OrDataTypeGroup,parent:d.toReference()},X=z(ve,d.project);switch(X.setParent(d,a),X.initChildren(a),a==null||a.add(X,G.Added),X.addSelfToProject(a),typeof ue){case"string":X.setEntity(X.project.getBuiltIn(pe[f.PrimitiveEntity][te.String].id),a);break;case"number":X.setEntity(X.project.getBuiltIn(pe[f.PrimitiveEntity][te.Number].id),a);break;case"boolean":X.setEntity(X.project.getBuiltIn(pe[f.PrimitiveEntity][te.Boolean].id),a);break;case"object":X.setEntity(X.project.getBuiltIn(pe[f.PrimitiveEntity][te.Null].id),a);break}});break}else Ve.length===1&&!Te?d.setEntity(Ve[0],a):H.forEach(ue=>{if(typeof ue=="object"&&!Array.isArray(ue)&&ue!==null){const ve=Eb(Object.keys(ue),d.project);if(ve){const X=uU(ve||Ve[0],d,a,Fr.OrDataTypeGroup);p.push(...X.updated),t.push(...X.added),m.push(...X.removed)}}else{const ve={id:P.UUID.uuid(),version:P.UUID.uuid(),createdAt:(a==null?void 0:a.timestamp)||new Date().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,type:f.DataType,options:null,implementationChooseOne:!1,entity:null,isList:Array.isArray(ue),asType:null,andChildrenGroup:null,orChildrenGroup:null,staticEntities:!1,interactiveEntities:!0,actionEntities:!1,like:!0,inferred:!1,parentRelationType:Fr.OrDataTypeGroup,parent:d.toReference()},X=z(ve,d.project);X.setParent(d,a),X.initChildren(a),a==null||a.add(X,G.Added),X.addSelfToProject(a);const de=Tb(ue,X,{...n,id:P.UUID.uuid()},a,l);p.push(...de.updated),t.push(...de.added),m.push(...de.removed)}})}}else{const H=yy(u[0],d.project,{...n},a,l);d.setEntity((b=H.changeSet)==null?void 0:b.self,a),p.push(...(_=H.changeSet)==null?void 0:_.updated),t.push(...(w=H.changeSet)==null?void 0:w.added),m.push(...(V=H.changeSet)==null?void 0:V.removed);break}else{const H=yy(u,d.project,{...n},a,l);d.setEntity((B=H.changeSet)==null?void 0:B.self,a),p.push(...(K=H.changeSet)==null?void 0:K.updated),t.push(...(q=H.changeSet)==null?void 0:q.added),m.push(...(Z=H.changeSet)==null?void 0:Z.removed);break}}return{updated:I(p),added:I(t),removed:I(m),affected:I(E),self:d}}function yy(u,d,n,a,l){const p=[],t=[],m=[],E=[],b=Object.keys(u),_=Eb(b,d);if(_)return{hasCreated:!1,changeSet:{updated:[],added:[],removed:[],affected:[],self:_}};const w=l?n.name+" of "+l.name:n.name,B={id:n.id||P.UUID.uuid(),version:P.UUID.uuid(),createdAt:(a==null?void 0:a.timestamp)||new Date().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,name:w,type:f.DefinitionEntity,description:n.description||null,static:n.static||!1,abstract:n.abstract||!1,properties:[],methods:[],abstractMethods:[],extends:[],implements:[],x:0,y:0,parent:d.toReference()},K=z(B,d);return K.setParent(d,a),K.initChildren(a),a==null||a.add(K,G.Added),K.addSelfToProject(a),t.push(K),b.forEach((q,Z)=>{const ie={id:P.UUID.uuid(),version:P.UUID.uuid(),createdAt:(a==null?void 0:a.timestamp)||new Date().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,name:q,type:f.Property,description:null,static:!1,abstract:!1,defaultValue:null,constant:!1,dataType:null,implements:null,extends:null,index:Z,hidden:!1,private:!1,required:!0,parent:K.toReference()},H=z(ie,d);H.setParent(K,a),H.initChildren(a),a==null||a.add(H,G.Added),H.addSelfToProject(a),t.push(H);const Ie=u[q],Te={id:P.UUID.uuid(),version:P.UUID.uuid(),createdAt:(a==null?void 0:a.timestamp)||new Date().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,type:f.DataType,parentRelationType:null,options:null,implementationChooseOne:!1,entity:null,isList:!1,asType:null,andChildrenGroup:null,orChildrenGroup:null,staticEntities:!1,interactiveEntities:!0,actionEntities:!1,like:!0,inferred:!1,parent:H.toReference()},Ve=z(Te,d);Ve.setParent(H,a),Ve.initChildren(a),a==null||a.add(Ve,G.Added),Ve.addSelfToProject(a),t.push(Ve);const ue=Tb(Ie,Ve,{...n,name:q,id:P.UUID.uuid()},a,l||K);p.push(...ue.updated),t.push(...ue.added),m.push(...ue.removed)}),{hasCreated:!0,changeSet:{updated:I(p),added:I(t),removed:I(m),affected:I(E),self:K}}}function ra(u,d,n,a){const l=[];return!u.length||!d.length?{errors:l,overlap:!1}:(u.length>d.length?u.forEach(p=>{const t=d.find(E=>E.name===p.name),m=d.find(E=>{var b,_;return!!p.implements&&((b=E.implements)==null?void 0:b.id)===((_=p.implements)==null?void 0:_.id)});if(t){const E=new xt({id:p.id+"--"+t.id+"--"+a,message:`Entity of type ${p.type} named "${p.name}" with id "${p.id}" overrides a base ${t.type} ${t.name} with id "${t.id}" that has the same name`,issue:null,severity:S.Error,code:a,entity:p,firstRelationship:t});l.push(E)}if(m){const E=new xt({id:p.id+"--"+m.id+"--"+n,message:`Entity of type ${p.type} named "${p.name}" with id "${p.id}" overrides a base ${m.type} ${m.name} with id "${m.id}" that implements the same base descriptor`,issue:null,severity:S.Error,code:n,entity:p,firstRelationship:m});l.push(E)}}):d.forEach(p=>{var E;const t=u.find(b=>b.name===p.name),m=u.find(b=>{var _,w;return!!b.implements&&((_=b.implements)==null?void 0:_.id)===((w=p.implements)==null?void 0:w.id)});if(t){const b=new xt({id:t.id+"--"+p.id+"--"+a,message:`Entity of type ${t.type} named "${t.name}" with id "${t.id}" overrides a base entity ${p.name} with id "${p.id}" that has the same name`,issue:null,severity:S.Error,code:a,entity:t,firstRelationship:p});l.push(b)}if(m){const b=new xt({id:m.id+"--"+p.id+"--"+n,message:`Entity of type ${m.type} named "${m.name}" with id "${m.id}" overrides a base entity ${p.name} with id "${p.id}" that implements the same base ${(E=m==null?void 0:m.implements)==null?void 0:E.type}`,issue:null,severity:S.Error,code:n,entity:m,firstRelationship:p});l.push(b)}}),{errors:l,overlap:!!l.length})}function Mhe(u,d){return u.abstract||(u.properties.forEach(a=>{a.abstract||a.metaSync({abstract:!0},d)}),Object.values(u.detachedDependents).forEach(a=>{a.field===xT.Entity&&a.entity.remove({ignoreUpstream:!1},d)}),u.metaSync({abstract:!0},d)),u}function Bhe(u,d){return u.abstract&&(u.properties.forEach(a=>{a.abstract&&a.metaSync({abstract:!1},d)}),Object.values(u.detachedDependents).forEach(a=>{(a.field===Ry.Implements||a.field===Ry.Extends)&&a.entity.onDetachedDependencyRemoved(u,a.field,d)}),u.metaSync({abstract:!1},d)),u}function Uhe(u,d){return u.static||(u.properties.forEach(a=>{a.static||a.metaSync({static:!0},d)}),u.metaSync({static:!0},d)),u}function jhe(u,d){return u.static&&u.metaSync({static:!1},d),u}var cU=(u=>(u.StringValueMustNotHaveSpaces="string-value-must-not-have-spaces",u.StringValueMustNotHaveDashes="string-value-must-not-have-dashes",u))(cU||{});function pU(u,d){const n=[],a=d;if(!a)return{errors:n,override:d};if(typeof a!="string")return{errors:[],override:d};if(a.includes(" ")){const l=new xt({id:u.id+"--string-value-must-not-have-spaces",message:`Entity of type ${u.type} with id "${u.id}" has an invalid value "${d}". The value cannot contain spaces.`,issue:null,severity:S.Error,code:"string-value-must-not-have-spaces",entity:u});n.push(l)}return{errors:n,override:a.replace(/\s/g,"-")}}function fU(u,d){const n=[],a=d;if(!a)return{errors:n,override:d};if(typeof a!="string")return{errors:[],override:d};if(a.includes(" ")){const l=new xt({id:u.id+"--string-value-must-not-have-spaces",message:`Entity of type ${u.type} with id "${u.id}" has an invalid value "${d}". The value cannot contain spaces or dashes.`,issue:null,severity:S.Error,code:"string-value-must-not-have-spaces",entity:u});n.push(l)}if(a.includes("-")){const l=new xt({id:u.id+"--string-value-must-not-have-dashes",message:`Entity of type ${u.type} with id "${u.id}" has an invalid value "${d}". The value cannot contain spaces or dashes.`,issue:null,severity:S.Error,code:"string-value-must-not-have-dashes",entity:u});n.push(l)}return{errors:n,override:a.replace(/\s|-/g,"_")}}function nd(u,d){const n=Uo(u);if(n.length===0)return{list:[],last:null};let a=null;return{list:n.flatMap(p=>{if(p===d)return a=p,[p];const t=nd(p,d);return t.last&&(a=t.last),[p,...t.list]}),last:a}}function bb(u){const d=u.calledBy;if(d.length===0)return u.project;const n=d.reduce((a,l)=>{const p=yi(l,u.project);return!p||p.type===f.Project?a:a.type===f.Project||nd(p,a).last?p:(nd(a,p).last,a)},u.project);return n.type===f.FunctionDeclaration&&n.parent.type===f.Loop?n.parent:n}function Me(u,d){var l,p;let n=bb(u);if(u.type===f.InternalCall)(l=u.parent)==null||l.setParent(n,d),(p=u.parent)==null||p.addSelfToProject(d);else if((u.type===f.ContinueStatement||u.type===f.BreakStatement)&&n.type!==f.Loop){u.remove({ignoreUpstream:!1},d);return}else if(u.type===f.ReturnStatement&&!br.includes(n.type)){u.remove({ignoreUpstream:!1},d);return}else u.setParent(n,d),u.addSelfToProject(d);if(sr.includes(u.type))return;nt(u).forEach(t=>{var E,b;const m=bb(t);if(t.type===f.InternalCall)(E=t.parent)==null||E.setParent(m,d),(b=t.parent)==null||b.addSelfToProject(d);else if((t.type===f.ContinueStatement||t.type===f.BreakStatement)&&m.type!==f.Loop){t.remove({ignoreUpstream:!1},d);return}else if(t.type===f.ReturnStatement&&!br.includes(m.type)){t.remove({ignoreUpstream:!1},d);return}else t.setParent(m,d),t.addSelfToProject(d)})}function hU(u,d,n=new Set){const a=Ka(u),l=Ka(d),p=a.filter(E=>!l.includes(E)),t=a.filter(E=>l.includes(E)),m=p.reduce((E,b)=>n.has(b.id)?E:(n.add(b.id),I([...E,...hU(b,d,n)])),[]);return I([...t,...m])}function ep(u,d){const n=nd(u,d);return n.last===d&&n.list.length>0&&n.list[0]!==d}function xhe(u,d){return!!nd(u,d).last}function Fhe(u){if(Xt.includes(u.type))return u;if([...rn,f.VariableDeclaration].includes(u.type)){const d=u.parent;return Xt.includes(d.type)?d:null}return null}function Ab(u,d){if(!u||!d)throw new Error("Both entities must be defined to find a common ancestor");if(u===d)return u;const n=u.parent;if(n){if(n===d)return d;if(n.type===f.Project)return null}else return null;const a=d.parent;if(a){if(a===u)return u;if(a.type===f.Project)return null}else return null;return Ab(n,a)}function Pr(u){if(sf.includes(u.type)){if(u.type===f.FunctionDeclaration){const d=u.parent;if(d.type===f.DefinitionEntity)return Pr(d);if(d.type===f.Loop)return d}return u.type===f.DefinitionEntity&&u.parent.type===f.DataType?Pr(u.parent):u}else{const d=u.parent;return d?Pr(d):null}}function my(u,d){const n=tp(u,d);if(!n)return null;if(sf.includes(n.type)){if(n.type===f.FunctionDeclaration){const a=tp(n.parent,d);if(a){if(a.type===f.DefinitionEntity)return a;if(a.type===f.Loop)return a}}return n}else{const a=n.parent?tp(n.parent,d):null;return a?my(a,d):null}}function yU(u){if(!u)return null;if(rn.includes(u.type))return u;const d=u.parent;return d?yU(d):null}function mU(u){if(!u)return null;if(dr.includes(u.type))return u;const d=u.parent;return d?mU(d):null}function vU(u){if(!u)return null;if(sn.includes(u.type))return u;const d=u.parent;return d?vU(d):null}function Ghe(u){return u.type===f.VariableDeclaration?[u]:dr.includes(u.type)?[...u.inputs,...u.outputs||[]]:sr.includes(u.type)?u.outputs:cl.includes(u.type)||u.type===f.FunctionDeclaration?u.inputs:[]}function Khe(u){const d=Ka(u),n=[],a=[];e1.includes(u.type)&&n.push(...Ib(u));const l=d.filter(p=>{const t=n.includes(p);return t?!1:rn.includes(p.type)&&!t?(a.push(p),!1):!0});return n.sort((p,t)=>ep(t,p)?-1:0),a.sort((p,t)=>ep(t,p)?-1:0),[...n,...a,...l]}function EU(u){return[...u].sort((d,n)=>ep(n,d)?-1:0)}function khe(u){const d=EU(u),n=[];return d.forEach(a=>{const l=n[n.length-1];if(l){const p=l[l.length-1];ep(a,p)?n.push([a]):l.push(a)}else n.push([a])}),n}function ei(u){const d=u.map(n=>Pr(n));return I(d)}function Ib(u){return dr.includes(u.type)?[...ei(u.successCalls),...ei(u.errorCalls)]:Xt.includes(u.type)?ei(u.calls):[]}function qhe(u,d){return Ib(u).includes(d)}function wb(u){return u.writesValues||[]}function She(u,d){return wb(u).includes(d)}function TU(u){var d;return lr.includes((d=u==null?void 0:u.readsValue)==null?void 0:d.type)?u.readsValue:null}function Zhe(u){return u.writesValues}function bU(u=[]){return u.map(TU).filter(d=>!!d)}function vy(u=[]){return u.map(d=>d.writesValues).flat().filter(d=>lr.includes(d.type))}function AU(u=[]){return u.map(d=>d.readsValue).filter(d=>!!d&&lr.includes(d.type))}function IU(u){return lr.includes(u.type)?u:null}function wU(u){return u.writesValues.map(IU).filter(d=>!!d)}function RU(u=[]){return u.reduce((d,n)=>n.type===f.OutputMap?[...d,...wU(n)]:d,[])}function nt(u){return u.type===f.Loop?I([...Ts(ei(u.successCalls)),...Ts(ei(u.errorCalls)),...u.body?nt(u.body):[]]):dr.includes(u.type)?I([...Ts(ei(u.successCalls)),...Ts(ei(u.errorCalls))]):Xt.includes(u.type)?I(Ts(ei(u.calls))):[]}function Jhe(u){return dr.includes(u.type)?[...Ts(ei(u.successCalls)),...Ts(ei(u.errorCalls))]:Xt.includes(u.type)?Ts(ei(u.calls)):[]}function _U(u,d=new Set){return u.writesValues.filter(a=>lr.includes(a.type)&&!d.has(a.id)).reduce((a,l)=>d.has(l.id)?a:[...a,...kt(l,d)],[])}function DU(u,d=new Set){var a;return(((a=u.readsValue)==null?void 0:a.writesValues)||[]).filter(l=>lr.includes(l.type)&&!d.has(l.id)).reduce((l,p)=>d.has(p.id)?l:[...l,...kt(p,d)],[])}function kt(u,d=new Set){if(d.has(u.id))return[];if(u.type===f.ReturnStatement)return AU(u.outputs).reduce((a,l)=>[...a,...kt(l,d)],[]);if(u.type===f.FunctionCall||u.type===f.Operation||u.type===f.Condition)return[...nt(u).reduce((p,t)=>{const m=Pr(t);return[...p,...kt(m||t,d)]},[]),...bU(u.inputs),...RU(u.outputs)].reduce((p,t)=>[...p,...kt(t,d)],[]);if(cl.includes(u.type)){const n=vy(u.inputs),l=nt(u).reduce((p,t)=>{const m=Pr(t);return[...p,...kt(m||t,d)]},[]);return n.push(...l),n.reduce((p,t)=>[...p,...kt(t,d)],[])}if(u.type===f.FunctionDeclaration){const n=[...vy(u.inputs)],l=nt(u).reduce((p,t)=>{const m=Pr(t);return[...p,...kt(m||t,d)]},[]);return n.push(...l),n.reduce((p,t)=>[...p,...kt(t)],[])}if(lr.includes(u.type)){d.add(u.id);const a=nt(u).reduce((l,p)=>{const t=Pr(p);return[...l,...kt(t||p,d)]},[]);return[u,...a,...DU(u,d),..._U(u,d)]}return[]}function xi(u,d=new Set){return d.has(u.id)?[]:(d.add(u.id),[...Ka(u).reduce((l,p)=>[...l,p,...xi(p,d)],[])])}function Ts(u){return u.reduce((d,n)=>n.type===f.ReturnStatement||n.type===f.ContinueStatement||n.type===f.BreakStatement?[...d,n]:[...d,n,...nt(n)],[])}function gU(u){const d=u.entities||[],n=[...d,...u.functions||[],...u.events||[],...u.projects||[]],a=d.reduce((E,b)=>[...E,...b.properties],[]),l=d.reduce((E,b)=>[...E,...b.methods],[]),p=l.reduce((E,b)=>[...E,...vy(b.inputs),...Ts(ei(b.calls)),...b.returnStatements],[]),t=u.functions.reduce((E,b)=>[...E,...Ts(ei(b.calls)),...b.returnStatements],[]),m=u.events.reduce((E,b)=>[...E,...Ts(ei(b.calls)),...b.returnStatements],[]);return[...n,...a,...l,...p,...t,...m]}function $U(u,d){return d.filter(a=>{if(!a)return!1;switch(a.type){case f.FunctionCall:return a.inputs.find(l=>l.id===u.id)!==void 0||a.outputs.find(l=>l.id===u.id)!==void 0;case f.Condition:return a.successCalls.find(l=>l.id===u.id)!==void 0||a.errorCalls.find(l=>l.id===u.id)!==void 0||a.inputs.find(l=>l.id===u.id)!==void 0;case f.Operation:return a.outputs.find(l=>l.id===u.id)!==void 0;case f.VariableDeclaration:return dr.includes(u.type)?ij(u).find(p=>{var t;return((t=p.readsValue)==null?void 0:t.id)===a.id})!==void 0:!1;case f.DefinitionEntity:return a.properties.find(l=>l.id===u.id)!==void 0||a.methods.find(l=>l.id===u.id)!==void 0;case f.FunctionDeclaration:return a.inputs.find(l=>l.id===u.id)!==void 0||(a.returnStatements.map(l=>l.outputs).flat()||[]).find(l=>l.id===u.id)!==void 0;default:return!1}})}function Whe(u){const d=gU(u.project);return $U(u,d)}function tp(u,d){return u?typeof u=="string"?d[u]:u.type===f.GenericReference?d[u.entityId]:d[u.id]?d[u.id]:null:null}function OU(u={},d){const n={};return Object.keys(u).forEach(a=>{const l=d.get(a)||a,p=u[a];n[l]=p}),n}function rp(u,d={},n={}){const a={ignoreBuiltInBaseEntities:!1,allBuiltInEntityIds:[],entityMaps:new Map,...n};if(a.ignoreBuiltInBaseEntities&&(Pi.includes(u.type)||(a.allBuiltInEntityIds||[]).includes(u.id)))return{upstream:{},downstream:{}};const l=u,p=u,t=u,m=u,E=u,b=u,_=u,w=u,V=u,B=u,K=u,q=u,Z=u,Q=[...Z.readsValue?[Z.readsValue]:[],...Z.declaration?[Z.declaration]:[],...(q.calledByEntry||[]).flatMap(re=>re),...(q.calledBySuccess||[]).flatMap(re=>re),...(q.calledByError||[]).flatMap(re=>re),...B.parent?[B.parent]:[]];Array.isArray(t.implements)?Q.push(...t.implements.flatMap(re=>re)):V.implements&&Q.push(V.implements),Array.isArray(t.extends)?Q.push(...t.extends.flatMap(re=>re)):V.extends&&Q.push(V.extends),E.valueAsTypeList&&Array.isArray(E.valueAsTypeList)&&Q.push(...E.valueAsTypeList.flatMap(re=>re)),E.valueAsTypeSingle&&Q.push(E.valueAsTypeSingle);const ie=[...(l.inputs||[]).flatMap(re=>re),...(K.inputsDeclarations||[]).flatMap(re=>re),...(l.outputs||[]).flatMap(re=>re),...(K.outputsDeclarations||[]).flatMap(re=>re),...(Z.internalCalls||[]).flatMap(re=>re),...Z.writesValues||[],...q.dataType?[q.dataType]:[],...b.body?[b.body]:[],...q.defaultValue?[q.defaultValue]:[],...(q.successCalls||[]).flatMap(re=>re),...(q.errorCalls||[]).flatMap(re=>re),...(t.properties||[]).flatMap(re=>re),...(t.methods||[]).flatMap(re=>re),...(t.abstractMethods||[]).flatMap(re=>re),..._.error?[_.error]:[],..._.process?[_.process]:[],...B.throws?[B.throws]:[],...(p.andChildrenGroup||[]).flatMap(re=>re),...(p.orChildrenGroup||[]).flatMap(re=>re),...(w.entities||[]).flatMap(re=>re),...(w.functions||[]).flatMap(re=>re),...(w.functionCalls||[]).flatMap(re=>re),...(w.events||[]).flatMap(re=>re),...(w.conditions||[]).flatMap(re=>re),...(w.operations||[]).flatMap(re=>re),...(w.loops||[]).flatMap(re=>re),...(w.variableDeclarations||[]).flatMap(re=>re),...(w.variableInstances||[]).flatMap(re=>re),...(w.searches||[]).flatMap(re=>re),...(w.projects||[]).flatMap(re=>re),...(m.calls||[]).flatMap(re=>re)];u.type===f.DataType&&(p.entity&&d[W(p.entity)]&&d[W(p.entity)].parent&&W(d[W(p.entity)].parent)===u.id?ie.push(p.entity):p.entity&&Q.push(p.entity));const H={},Ie={};return Q.forEach(re=>{var ue;const Te=W(re);if(Te&&a.ignoreBuiltInBaseEntities&&(Pi.includes(re.type)||(a.allBuiltInEntityIds||[]).includes(Te)))return;const Ve=re.version;if(Te){const ve=((ue=a.entityMaps)==null?void 0:ue.get(Te))||Te;H[ve]=Ve}}),ie.forEach(re=>{var ue;const Te=W(re);if(Te&&a.ignoreBuiltInBaseEntities&&(Pi.includes(re.type)||(a.allBuiltInEntityIds||[]).includes(Te)))return;const Ve=re.version;if(Te){const ve=((ue=a.entityMaps)==null?void 0:ue.get(Te))||Te;Ie[ve]=Ve}}),{upstream:H,downstream:Ie}}function Yhe(u,d){const n=[];if(rn.includes(u.type)){is(u).forEach(p=>{const t=my(p,d);t&&n.push(t)});const l=[...u.inputs||[],...u.outputs||[]].map(p=>{const t=tp(p,d);return t?nj(t,d):null}).filter(p=>p!==null);n.push(...I(l))}if(lr.includes(u.type)){const a=Ey(u);a&&n.push(a)}return I(n)}function Uo(u){const d=[];if(rn.includes(u.type)){u.calledBy.forEach(l=>{const p=Pr(l);p&&d.push(p)});const a=[...u.inputs||[],...u.outputs||[]].map(l=>Ey(l)).filter(l=>l!==null);d.push(...I(a))}if(lr.includes(u.type)){const n=Ey(u);n&&d.push(n)}return I(d)}function is(u){return[...u.calledByEntry||[],...u.calledByError||[],...u.calledBySuccess||[]].filter(d=>d.type!==f.GenericReference)}function CU(u,d=new Set,n={ignoreBuiltInBaseEntities:!1}){if(d.has(u.id))return[];if(d.add(u.id),u.type!==f.ActionDescriptor)throw new Error("Entity must be an action descriptor to be flattened");return[u,...u.inputs.flatMap(a=>ae(a,d,n)),...u.outputs.flatMap(a=>ae(a,d,n)),...u.error?ae(u.error,d,n):[],...u.parent?ae(u.parent,d,n):[]]}function PU(u,d=new Set,n={ignoreBuiltInBaseEntities:!1}){if(d.has(u.id))return[];if(d.add(u.id),u.type!==f.ArgumentDeclaration)throw new Error("Entity must be an argument declaration to be flattened");return[u,...u.defaultValue?ae(u.defaultValue,d):[],...u.writesValues.flatMap(a=>ae(a,d,n)),...u.dataType?ae(u.dataType,d,n):[],...u.parent?ae(u.parent,d,n):[]]}function VU(u,d=new Set,n={ignoreBuiltInBaseEntities:!1}){if(d.has(u.id))return[];if(d.add(u.id),u.type!==f.BreakStatement)throw new Error("Entity must be a break statement to be flattened");return[u,...u.outputs.flatMap(a=>ae(a,d,n)),...u.throws?ae(u.throws,d,n):[],...(is(u)||[]).flatMap(a=>ae(a,d,n)),...u.parent?ae(u.parent,d,n):[]]}function NU(u,d=new Set,n={ignoreBuiltInBaseEntities:!1}){if(d.has(u.id))return[];if(d.add(u.id),u.type!==f.BuiltInBaseEntity)throw new Error("Entity must be a built-in base entity to be flattened");return[u,...(u.properties||[]).flatMap(a=>ae(a,d,n)),...(u.methods||[]).flatMap(a=>ae(a,d,n)),...(u.abstractMethods||[]).flatMap(a=>ae(a,d,n)),...(u.extends||[]).flatMap(a=>ae(a,d,n))]}function LU(u,d=new Set,n={ignoreBuiltInBaseEntities:!1}){if(d.has(u.id))return[];if(d.add(u.id),u.type!==f.Condition)throw new Error("Entity must be a condition to be flattened");return[u,...(u.inputs||[]).flatMap(a=>ae(a,d,n)),...(u.successCalls||[]).flatMap(a=>ae(a,d,n)),...(u.errorCalls||[]).flatMap(a=>ae(a,d,n)),...(is(u)||[]).flatMap(a=>ae(a,d,n)),...u.parent?ae(u.parent,d,n):[]]}function MU(u,d=new Set,n={ignoreBuiltInBaseEntities:!1}){if(d.has(u.id))return[];if(d.add(u.id),u.type!==f.ContinueStatement)throw new Error("Entity must be a continue statement to be flattened");return[u,...u.outputs.flatMap(a=>ae(a,d,n)),...u.throws?ae(u.throws,d,n):[],...(is(u)||[]).flatMap(a=>ae(a,d,n)),...u.parent?ae(u.parent,d,n):[]]}function BU(u,d=new Set,n={ignoreBuiltInBaseEntities:!1}){if(d.has(u.id))return[];if(d.add(u.id),u.type!==f.DefinitionEntity)throw new Error("Entity must be a definition entity to be flattened");return[u,...(u.extends||[]).flatMap(a=>ae(a,d,n)),...(u.implements||[]).flatMap(a=>ae(a,d,n)),...(u.properties||[]).flatMap(a=>ae(a,d,n)),...(u.methods||[]).flatMap(a=>ae(a,d,n)),...(u.abstractMethods||[]).flatMap(a=>ae(a,d,n)),...u.parent?ae(u.parent,d,n):[]]}function UU(u,d=new Set,n={ignoreBuiltInBaseEntities:!1}){if(d.has(u.id))return[];if(d.add(u.id),u.type!==f.DataType)throw new Error("Entity must be a data type to be flattened");return[u,...(u.andChildrenGroup||[]).flatMap(a=>ae(a,d,n)),...(u.orChildrenGroup||[]).flatMap(a=>ae(a,d,n)),...u.entity?ae(u.entity,d,n):[],...u.parent?ae(u.parent,d,n):[]]}function jU(u,d=new Set,n={ignoreBuiltInBaseEntities:!1}){if(d.has(u.id))return[];if(d.add(u.id),u.type!==f.FunctionCall)throw new Error("Entity must be a function call to be flattened");return[u,...(u.inputs||[]).flatMap(a=>ae(a,d,n)),...(u.outputs||[]).flatMap(a=>ae(a,d,n)),...u.error?ae(u.error,d,n):[],...u.process?ae(u.process,d,n):[],...(is(u)||[]).flatMap(a=>ae(a,d,n)),...(u.successCalls||[]).flatMap(a=>ae(a,d,n)),...(u.errorCalls||[]).flatMap(a=>ae(a,d,n)),...u.parent?ae(u.parent,d,n):[]]}function xU(u,d=new Set,n={ignoreBuiltInBaseEntities:!1}){if(d.has(u.id))return[];if(d.add(u.id),u.type!==f.FunctionDeclaration)throw new Error("Entity must be a function declaration to be flattened");return[u,...(u.inputs||[]).flatMap(a=>ae(a,d,n)),...(u.calls||[]).flatMap(a=>ae(a,d,n)),...u.implements?ae(u.implements,d,n):[],...u.parent?ae(u.parent,d,n):[]]}function FU(u,d=new Set,n={ignoreBuiltInBaseEntities:!1}){if(d.has(u.id))return[];if(d.add(u.id),u.type!==f.GlobalEvent)throw new Error("Entity must be a global event to be flattened");return[u,...(u.inputs||[]).flatMap(a=>ae(a,d,n)),...(u.calls||[]).flatMap(a=>ae(a,d,n)),...u.implements?ae(u.implements,d,n):[],...u.parent?ae(u.parent,d,n):[]]}function GU(u,d=new Set,n={ignoreBuiltInBaseEntities:!1}){if(d.has(u.id))return[];if(d.add(u.id),u.type!==f.InputMap)throw new Error("Entity must be an input map to be flattened");return[u,...u.readsValue?ae(u.readsValue,d,n):[],...u.declaration?ae(u.declaration,d,n):[],...u.defaultValue?ae(u.defaultValue,d,n):[],...u.parent?ae(u.parent,d,n):[]]}function KU(u,d=new Set,n={ignoreBuiltInBaseEntities:!1}){if(d.has(u.id))return[];if(d.add(u.id),u.type!==f.InstalledProject)throw new Error("Entity must be an installed project to be flattened");return[u,...(u.functions||[]).flatMap(a=>ae(a,d,n)),...(u.events||[]).flatMap(a=>ae(a,d,n)),...u.parent?ae(u.parent,d,n):[]]}function kU(u,d=new Set,n={ignoreBuiltInBaseEntities:!1}){if(d.has(u.id))return[];if(d.add(u.id),u.type!==f.InternalCall)throw new Error("Entity must be an internal call to be flattened");return[u,...(u.successCalls||[]).flatMap(a=>ae(a,d,n)),...(u.errorCalls||[]).flatMap(a=>ae(a,d,n)),...(u.inputs||[]).flatMap(a=>ae(a,d,n)),...(u.outputs||[]).flatMap(a=>ae(a,d,n)),...(is(u)||[]).flatMap(a=>ae(a,d,n)),...u.error?ae(u.error,d,n):[],...u.process?ae(u.process,d,n):[],...u.parent?ae(u.parent,d,n):[]]}function qU(u,d=new Set,n={ignoreBuiltInBaseEntities:!1}){if(d.has(u.id))return[];if(d.add(u.id),u.type!==f.LiteralValue)throw new Error("Entity must be a literal value to be flattened");return[u,...u.valueAsTypeSingle?ae(u.valueAsTypeSingle,d,n):[],...u.valueAsTypeList&&Array.isArray(u.valueAsTypeList)?u.valueAsTypeList.flatMap(a=>ae(a,d,n)):[],...u.parent?ae(u.parent,d,n):[]]}function SU(u,d=new Set,n={ignoreBuiltInBaseEntities:!1}){if(d.has(u.id))return[];if(d.add(u.id),u.type!==f.Loop)throw new Error("Entity must be a loop to be flattened");return[u,...(u.inputs||[]).flatMap(a=>ae(a,d,n)),...(u.outputs||[]).flatMap(a=>ae(a,d,n)),...(u.successCalls||[]).flatMap(a=>ae(a,d,n)),...(u.errorCalls||[]).flatMap(a=>ae(a,d,n)),...u.error?ae(u.error,d,n):[],...u.process?ae(u.process,d,n):[],...u.body?ae(u.body,d,n):[],...(is(u)||[]).flatMap(a=>ae(a,d,n)),...u.parent?ae(u.parent,d,n):[]]}function ZU(u,d=new Set,n={ignoreBuiltInBaseEntities:!1}){if(d.has(u.id))return[];if(d.add(u.id),u.type!==f.Operation)throw new Error("Entity must be an operation to be flattened");return[u,...(u.successCalls||[]).flatMap(a=>ae(a,d,n)),...(u.errorCalls||[]).flatMap(a=>ae(a,d,n)),...(u.inputs||[]).flatMap(a=>ae(a,d,n)),...(u.outputs||[]).flatMap(a=>ae(a,d,n)),...u.error?ae(u.error,d,n):[],...u.process?ae(u.process,d,n):[],...(is(u)||[]).flatMap(a=>ae(a,d,n)),...u.parent?ae(u.parent,d,n):[]]}function JU(u,d=new Set,n={ignoreBuiltInBaseEntities:!1}){if(d.has(u.id))return[];if(d.add(u.id),u.type!==f.OutputMap)throw new Error("Entity must be an output map to be flattened");return[u,...(u.writesValues||[]).flatMap(a=>ae(a,d,n)),...u.declaration?ae(u.declaration,d,n):[],...u.defaultValue?ae(u.defaultValue,d,n):[],...u.parent?ae(u.parent,d,n):[]]}function WU(u,d=new Set,n={ignoreBuiltInBaseEntities:!1}){if(d.has(u.id))return[];if(d.add(u.id),u.type!==f.PrimitiveEntity)throw new Error("Entity must be a primitive entity to be flattened");return[u,...(u.properties||[]).flatMap(a=>ae(a,d,n)),...(u.methods||[]).flatMap(a=>ae(a,d,n)),...(u.abstractMethods||[]).flatMap(a=>ae(a,d,n))]}function YU(u,d=new Set,n={ignoreBuiltInBaseEntities:!1}){if(d.has(u.id))return[];if(d.add(u.id),u.type!==f.Project)throw new Error("Entity must be a project to be flattened");return[u,...(u.entities||[]).flatMap(a=>ae(a,d,n)),...(u.functions||[]).flatMap(a=>ae(a,d,n)),...(u.events||[]).flatMap(a=>ae(a,d,n)),...(u.projects||[]).flatMap(a=>ae(a,d,n)),...(u.variableDeclarations||[]).flatMap(a=>ae(a,d,n)),...(u.variableInstances||[]).flatMap(a=>ae(a,d,n)),...(u.operations||[]).flatMap(a=>ae(a,d,n)),...(u.conditions||[]).flatMap(a=>ae(a,d,n)),...(u.functionCalls||[]).flatMap(a=>ae(a,d,n)),...(u.projects||[]).flatMap(a=>ae(a,d,n)),...(u.loops||[]).flatMap(a=>ae(a,d,n)),...(u.searches||[]).flatMap(a=>ae(a,d,n))]}function zU(u,d=new Set,n={ignoreBuiltInBaseEntities:!1}){if(d.has(u.id))return[];if(d.add(u.id),u.type!==f.Property)throw new Error("Entity must be a property to be flattened");return[u,...u.defaultValue?ae(u.defaultValue,d,n):[],...u.dataType?ae(u.dataType,d,n):[],...u.parent?ae(u.parent,d,n):[]]}function HU(u,d=new Set,n={ignoreBuiltInBaseEntities:!1}){if(d.has(u.id))return[];if(d.add(u.id),u.type!==f.ReturnDeclaration)throw new Error("Entity must be a return declaration to be flattened");return[u,...u.readsValue?ae(u.readsValue,d,n):[],...u.defaultValue?ae(u.defaultValue,d,n):[],...u.dataType?ae(u.dataType,d,n):[],...u.parent?ae(u.parent,d,n):[]]}function XU(u,d=new Set,n={ignoreBuiltInBaseEntities:!1}){if(d.has(u.id))return[];if(d.add(u.id),u.type!==f.ReturnStatement)throw new Error("Entity must be a return statement to be flattened");return[u,...(u.outputs||[]).flatMap(a=>ae(a,d,n)),...u.throws?ae(u.throws,d,n):[],...(is(u)||[]).flatMap(a=>ae(a,d,n)),...u.parent?ae(u.parent,d,n):[]]}function QU(u,d=new Set,n={ignoreBuiltInBaseEntities:!1}){if(d.has(u.id))return[];if(d.add(u.id),u.type!==f.Search)throw new Error("Entity must be a search to be flattened");return[u,...(u.successCalls||[]).flatMap(a=>ae(a,d,n)),...(u.errorCalls||[]).flatMap(a=>ae(a,d,n)),...(u.inputsDeclarations||[]).flatMap(a=>ae(a,d,n)),...(u.inputs||[]).flatMap(a=>ae(a,d,n)),...(u.outputsDeclarations||[]).flatMap(a=>ae(a,d,n)),...(u.outputs||[]).flatMap(a=>ae(a,d,n)),...u.error?ae(u.error,d,n):[],...(is(u)||[]).flatMap(a=>ae(a,d,n)),...u.parent?ae(u.parent,d,n):[]]}function ej(u,d=new Set,n={ignoreBuiltInBaseEntities:!1}){if(d.has(u.id))return[];if(d.add(u.id),u.type!==f.ValueDescriptor)throw new Error("Entity must be a value descriptor to be flattened");return[u,...u.defaultValue?ae(u.defaultValue,d,n):[],...u.dataType?ae(u.dataType,d,n):[],...u.parent?ae(u.parent,d,n):[]]}function tj(u,d=new Set,n={ignoreBuiltInBaseEntities:!1}){if(d.has(u.id))return[];if(d.add(u.id),u.type!==f.VariableDeclaration)throw new Error("Entity must be a variable declaration to be flattened");return[u,...(u.successCalls||[]).flatMap(a=>ae(a,d,n)),...(u.errorCalls||[]).flatMap(a=>ae(a,d,n)),...(u.inputs||[]).flatMap(a=>ae(a,d,n)),...(u.outputs||[]).flatMap(a=>ae(a,d,n)),...(u.internalCalls||[]).flatMap(a=>ae(a,d,n)),...(u.writesValues||[]).flatMap(a=>ae(a,d,n)),...u.readsValue?ae(u.readsValue,d,n):[],...u.defaultValue?ae(u.defaultValue,d,n):[],...(is(u)||[]).flatMap(a=>ae(a,d,n)),...u.dataType?ae(u.dataType,d,n):[],...u.parent?ae(u.parent,d,n):[]]}function rj(u,d=new Set,n={ignoreBuiltInBaseEntities:!1}){if(d.has(u.id))return[];if(d.add(u.id),u.type!==f.VariableInstance)throw new Error("Entity must be a variable instance to be flattened");return[u,...(u.successCalls||[]).flatMap(a=>ae(a,d,n)),...(u.errorCalls||[]).flatMap(a=>ae(a,d,n)),...(u.inputs||[]).flatMap(a=>ae(a,d,n)),...(u.outputs||[]).flatMap(a=>ae(a,d,n)),...(u.internalCalls||[]).flatMap(a=>ae(a,d,n)),...(u.writesValues||[]).flatMap(a=>ae(a,d,n)),...u.readsValue?ae(u.readsValue,d,n):[],...u.defaultValue?ae(u.defaultValue,d,n):[],...(is(u)||[]).flatMap(a=>ae(a,d,n)),...u.declaration?ae(u.declaration,d,n):[],...u.parent?ae(u.parent,d,n):[]]}function bs(){const u=new Set,d=iP.flatMap(n=>ae(n,u)).map(n=>n.id);if(!d.includes("http-request-error-return-delaration-id"))throw new Error("Built-in base entities must be included in the list");return d}function ae(u,d=new Set,n={ignoreBuiltInBaseEntities:!1}){if(!u)throw new Error("Entity must be defined to be flattened");if(u.type===f.GenericReference)return[];if(n.ignoreBuiltInBaseEntities&&(Pi.includes(u.type)||bs().includes(u.id)))return[];if(d.has(u.id))return[];switch(u.type){case f.FunctionCall:return jU(u,d,n);case f.Operation:return ZU(u,d,n);case f.Condition:return LU(u,d,n);case f.Loop:return SU(u,d,n);case f.Search:return QU(u,d,n);case f.GlobalEvent:return FU(u,d,n);case f.ReturnStatement:return XU(u,d,n);case f.ContinueStatement:return MU(u,d,n);case f.BreakStatement:return VU(u,d,n);case f.VariableDeclaration:return tj(u,d,n);case f.DefinitionEntity:return BU(u,d,n);case f.FunctionDeclaration:return xU(u,d,n);case f.Project:return YU(u,d,n);case f.ActionDescriptor:return CU(u,d,n);case f.ArgumentDeclaration:return PU(u,d,n);case f.ReturnDeclaration:return HU(u,d,n);case f.ValueDescriptor:return ej(u,d,n);case f.InputMap:return GU(u,d,n);case f.OutputMap:return JU(u,d,n);case f.DataType:return UU(u,d,n);case f.InstalledProject:return KU(u,d,n);case f.InternalCall:return kU(u,d,n);case f.LiteralValue:return qU(u,d,n);case f.Property:return zU(u,d,n);case f.VariableInstance:return rj(u,d,n);case f.BuiltInBaseEntity:return n.ignoreBuiltInBaseEntities?[]:NU(u,d,n);case f.PrimitiveEntity:return n.ignoreBuiltInBaseEntities?[]:WU(u,d,n)}return[]}function Rb(u){return u.type===f.FunctionCall||u.type===f.InternalCall||[f.Operation,f.Condition,f.Loop].includes(u.type)?u.declaration.inputs:u.type===f.FunctionDeclaration||cl.includes(u.type)?u.inputs:u.type===f.Search?u.inputsDeclarations:[]}function zhe(u,d){return d.type===f.Condition?d.inputs.find(n=>n.declaration.id===u.id):d.type===f.FunctionCall||d.type===f.Operation?d.inputs.find(n=>n.declaration.id===u.id):null}function ij(u){return dr.includes(u.type)?u.inputs:[]}function sj(u){var d;return u.type===f.FunctionCall?((d=u.declaration.returnStatements[0])==null?void 0:d.outputs)||[]:[f.Operation,f.Condition,f.Loop].includes(u.type)?u.declaration.outputs:u.type===f.Search?u.outputsDeclarations:sr.includes(u.type)?u.outputs:[]}function Hhe(u,d){return d.type===f.Condition?null:d.type===f.FunctionCall||d.type===f.Operation?d.outputs.find(n=>n.declaration.id===u.id):null}function Xhe(u){return u.type===f.Condition?[]:dr.includes(u.type)?u.outputs:[]}function Ey(u){const d=u.readsValue;return d?Pr(d):null}function nj(u,d){const n=u.readsValue;return n?my(n,d):null}function aj(u){const d=u.internalCalls||[];return I(ei(I(d.flatMap(n=>[...n.successCalls,...n.errorCalls]))))}function ad(u){const d=wb(u),n=[];return d.forEach(a=>{if(lr.includes(a.type))n.push(a);else if(ua.includes(a.type)){const l=a.parent;n.push(l)}}),n}function I(u){const d=new Set;return u.filter(n=>!n||d.has(n.id)?!1:(d.add(n.id),!0))}function Ka(u,d=!1){const n=[];if(u.type===f.Project&&n.push(...(u==null?void 0:u.entities)||[],...(u==null?void 0:u.functions)||[],...(u==null?void 0:u.variableDeclarations)||[],...(u==null?void 0:u.variableInstances)||[],...(u==null?void 0:u.searches)||[],...(u==null?void 0:u.loops)||[],...(u==null?void 0:u.operations)||[],...(u==null?void 0:u.conditions)||[],...(u==null?void 0:u.functionCalls)||[],...(u==null?void 0:u.events)||[],...(u==null?void 0:u.projects)||[]),br.includes(u.type)&&n.push(...(u==null?void 0:u.detachedChildren)||[]),u.type===f.DefinitionEntity){const a=[...u.suggestedMethods,...u.methods].flatMap(l=>l.collapsed&&d?[]:Ka(l));n.push(...a)}if(u.type===f.Condition){const a=u.successCalls.map(p=>Pr(p)),l=u.errorCalls.map(p=>Pr(p));n.push(...a,...l)}if(cl.includes(u.type)){if(u.collapsed&&d)return[];const a=u.inputs.map(p=>ad(p)).flat(),l=u.calls.map(p=>Pr(p));n.push(...I(a),...l)}if(dr.includes(u.type)&&u.type!==f.Condition&&u.type!==f.Loop){const a=u==null?void 0:u.outputs.map(t=>ad(t)).flat(),l=u.successCalls.map(t=>Pr(t)),p=u.errorCalls.map(t=>Pr(t));n.push(...I(a),...l,...p)}if(lr.includes(u.type)){const a=ad(u),l=aj(u);n.push(...a,...l)}if(u.type===f.Loop){const a=u.outputs.map(t=>ad(t)).flat();if(u.body){const t=Ka(u.body,d);n.push(...t)}const l=u.errorCalls.map(t=>Pr(t)),p=u.successCalls.map(t=>Pr(t));n.push(...I(a),...p,...l)}if(u.type===f.FunctionDeclaration){if(u.collapsed&&d)return[];const a=u.inputs.map(p=>ad(p)).flat(),l=u.calls.map(p=>Pr(p));n.push(...I(a),...l)}return I(n)}function oj(u,d=!1){const n=Ka(u,d),a=[...n,...n.reduce((l,p)=>[...l,...oj(p,d)],[])];return I(a)}function lj(u){const d=Uo(u),n=[...d,...d.reduce((a,l)=>[...a,...lj(l)],[])];return I(n)}function ip(u){return u.implements.reduce((d,n)=>n.type===f.DefinitionEntity?[...d,f.DefinitionEntity,...ip(n),...sp(n)]:[...d,n.name],[])}function sp(u){return u.extends.reduce((d,n)=>n.type===f.DefinitionEntity?[...d,f.DefinitionEntity,...sp(n),...ip(n)]:[...d,n.name],[])}function _b(u){return u.extends.reduce((d,n)=>n.type===f.DefinitionEntity?[...d,n,..._b(n),...Db(n)]:[...d,n],[])}function Db(u){return u.implements.reduce((d,n)=>n.type===f.DefinitionEntity?[...d,n,...Db(n),..._b(n)]:[...d,n],[])}function Ty(u){return[...sp(u),...ip(u)].filter((n,a,l)=>l.indexOf(n)===a)}function gb(u){return u.implements.length===0&&u.extends.length===0?null:u.implements.find(a=>a.type===f.BuiltInBaseEntity&&a.name===ge.PERSISTED_ENTITY)?u:[...u.implements,...u.extends].reduce((a,l)=>{if(l.type===f.DefinitionEntity){const p=gb(l);if(p)return p}return a},null)}function Qhe(u){const d=u.extends.find(n=>n.type===f.BuiltInBaseEntity);return d&&d.type===f.BuiltInBaseEntity?d:null}function eye(u){const d=u.implements.find(n=>n.type===f.BuiltInBaseEntity);return d&&d.type===f.BuiltInBaseEntity?d:null}function $b(u){const d=u.extends.find(n=>n.type===f.DefinitionEntity);return d&&d.type===f.DefinitionEntity?d:null}function hi(u){if(u.type===f.BuiltInBaseEntity)return[u];const d=[...u.implements,...u.extends].reduce((n,a)=>a.type===f.BuiltInBaseEntity?[...n,a]:a.type===f.DefinitionEntity?[...n,...hi(a)]:n,[]);return I(d)}function np(u){return u.type===f.PrimitiveEntity?!0:u.type===f.BuiltInBaseEntity?u.interactive:!hi(u).find(a=>!a.interactive)}function tye(u){return u.parent===u.project&&u.project.variableDeclarations.includes(u)}function Ob(u){return u.parent!==u.project?!1:f.VariableDeclaration===u.type?u.project.variableDeclarations.includes(u):f.VariableInstance===u.type?u.project.variableInstances.includes(u):f.FunctionCall===u.type?u.project.functionCalls.includes(u):f.Condition===u.type?u.project.conditions.includes(u):f.Operation===u.type?u.project.operations.includes(u):f.Loop===u.type?u.project.loops.includes(u):f.Search===u.type?u.project.searches.includes(u):!1}function dj(u){if([...Xt,f.DefinitionEntity,f.InstalledProject,f.Project].includes(u.type)||Ob(u))return!1;const d=Uo(u);return d.length===0?!0:d.some(n=>dj(n))}function Cb(u){return[...Xt,f.DefinitionEntity,f.InstalledProject,f.Project].includes(u.type)||Ob(u)?!1:Uo(u).length===0}function uj(u,d=0){if(Cb(u)){const n=Uo(u);return n.length===0?u:n.map(l=>uj(l,d+1)).reduce((l,p)=>l?p&&p.x<l.x?p:l:p,null)}return null}function cj(u){const d=[];if(Cb(u))d.push(u);else return[];return Uo(u).forEach(a=>{d.push(...cj(a))}),d}function pj(u){return u.type===f.FunctionDeclaration&&u.parent!==u.project&&!![f.DefinitionEntity,f.Loop,f.InstalledProject].includes(u.parent.type)}function rye(u,d){const n=new Map;return u.forEach(a=>{n.set(a.id,a)}),d.forEach(a=>{n.set(a.id,a)}),Array.from(n.values())}function ap(u){switch(u){case f.DefinitionEntity:return ia;case f.FunctionDeclaration:return _a;case f.VariableDeclaration:return Va;case f.VariableInstance:return Pa;case f.FunctionCall:return Fa;case f.Operation:return Da;case f.Condition:return Ca;case f.ReturnStatement:return ga;case f.Loop:return Oa;case f.Search:return Na;case f.InputMap:return Es;case f.OutputMap:return Ks;case f.ArgumentDeclaration:return ea;case f.ReturnDeclaration:return wi;case f.Property:return Xn;case f.InstalledProject:return La;case f.Project:return P;case f.DataType:return ts;case f.GlobalEvent:return $a;case f.InternalCall:return Ma;case f.ValueDescriptor:return ks;case f.BuiltInBaseEntity:return qs;case f.PrimitiveEntity:return Ri;case f.ActionDescriptor:return Lt;case f.LiteralValue:return Fs;case f.ContinueStatement:return Qr;case f.BreakStatement:return Ba;default:return null}}function yi(u,d,n=null){const a=u!=null&&u.parent?W(u==null?void 0:u.parent):null;let l=a?d.get(a):null,p=n||u;if(u.type===f.ReturnStatement)return Rr(u,d,p);if(u.type===f.FunctionDeclaration&&(l==null?void 0:l.type)===f.Loop)return l;if(Xt.includes(u.type))return u;if(u.type===f.Loop)return p.id===u.id?l:u;if(Pi.includes(u.type))return null;const t=u.parent;if(!t)return null;if(t.type===f.GenericReference){const m=W(t);if(!m)return null;const E=d.get(m);return E?yi(E,d,p):null}else return t===d?d:yi(t,d,p)}function Rr(u,d,n=null){const a=u!=null&&u.parent?W(u==null?void 0:u.parent):null;let l=a?d.get(a):null,p=n||u;if(u.type===f.FunctionDeclaration&&(l==null?void 0:l.type)===f.Loop)return Rr(l.parent,d,p);if(Xt.includes(u.type))return u;if(Pi.includes(u.type))return null;const t=u.parent;if(!t)return null;if(t.type===f.GenericReference){const m=W(t);if(!m)return null;const E=d.get(m);return E?Rr(E,d,p):null}else return t===d?d:Rr(t,d,p)}function Pb(u,d){if(Pi.includes(u.type)||d.getBuiltIn(u.id))return null;const n=ss(u.parent,d);return n?n===d?br.includes(u.type)?u:null:n.type===f.DefinitionEntity?u:Pb(n,d):null}function by(u,d,n){if(u===d||d===n||u===n)return!1;const a=yi(d.parent,n);return a===u?!0:by(a,d,n)}var Ay=(u=>(u.SameBothLocal="same-both-local",u.AInB="a-in-b",u.BInA="b-in-a",u.ParallelInCommonParent="parallel-in-common-parent",u.ParallelInProject="parallel-in-project",u.AIsGlobalBIsNot="a-is-global-b-is-not",u.BIsGlobalAIsNot="b-is-global-a-is-not",u.SameBothGlobal="same-both-global",u))(Ay||{});function op(u,d,n){const a=yi(u,n),l=yi(d,n);if(!a)throw new Error("Could not find scope owner for the entity: "+u.id);if(!l)throw new Error("Could not find scope owner for the entity: "+d.id);if(a===l&&a.type!==f.Project)return{compatible:!0,type:"same-both-local",commonAncestorScope:a};if(a===l&&a.type===f.Project)return{compatible:!0,type:"same-both-global",commonAncestorScope:a};if(a.type===f.Project&&l.type!==f.Project)return{compatible:!1,type:"a-is-global-b-is-not",commonAncestorScope:a};if(a.type!==f.Project&&l.type===f.Project)return{compatible:!1,type:"b-is-global-a-is-not",commonAncestorScope:l};if(by(a,l,n))return{compatible:!0,type:"b-in-a",commonAncestorScope:a};if(by(l,a,n))return{compatible:!0,type:"a-in-b",commonAncestorScope:l};const m=Ab(a,l);return m===n?{compatible:!1,type:"parallel-in-project",commonAncestorScope:m}:m?{compatible:!1,type:"parallel-in-common-parent",commonAncestorScope:yi(m,n)}:{compatible:!1,type:"parallel-in-project",commonAncestorScope:n}}function fj(u,d,n){const a=op(u,d,n);if(!a.compatible||a.type!=="same-both-local")return null;if(u===d)return u;let l=yi(u.parent,n);if(l){if(l===d)return d;if(l.type===f.Project)return u}else return u;for(;l;){if(l){if(l===d)return d;if(l.type===f.Project)return u}else return u;l=yi(l.parent,n)}let p=yi(d.parent,n);if(p){if(p===u)return u;if(p.type===f.Project)return d}else return d;for(;p;){if(p){if(p===u)return u;if(p.type===f.Project)return d}else return d;p=yi(p.parent,n)}return null}function hj(u){return u.length===0?null:u.length===1?u[0]:u.reduce((n,a)=>{const l=fj(n,a,a.project);return!l||l===a?n:a},u[0])}function ss(u,d){if(!u)return null;let n;return typeof u=="string"?n=u:u.type===f.GenericReference?n=W(u):n=u.id,n===d.id?d:d.get(n)}function ka(u){if(!u)return null;if(Pi.includes(u.type))return u;if(u.type===f.Project)return null;if(u.project.getBuiltIn(u.id))return u;const d=u.parent;return!d||d.type===f.Project?null:ka(d)}function lp(u){const d=[];function n(p,t){return d.some(m=>m.blockedByCaller===p&&m.blockedByCalling===t)}function a(p,t){n(p,t)||d.push({blockedByCaller:p,blockedByCalling:t})}const l=Pb(u,u.project);return u.calledBySuccess.forEach(p=>{[...p.successCalls||[]].forEach(E=>{sr.includes(E.type)&&E!==u&&(nt(u).find(w=>w===E)||a(p,E))});let m;if(dr.includes(p.type)&&(m=p),m){const E=lp(m);E.reachable||nt(u).find(w=>w===p)||E.blocks.forEach(w=>{a(p,w.blockedByCalling)})}}),u.calledByError.forEach(p=>{[...p.errorCalls||[]].forEach(E=>{sr.includes(E.type)&&E!==u&&(nt(u).find(w=>w===E)||a(p,E))});let m;if(dr.includes(p.type)&&(m=p),m){const E=lp(m);E.reachable||nt(u).find(w=>w===p)||E.blocks.forEach(w=>{a(p,w.blockedByCalling)})}}),u.calledByEntry.forEach(p=>{if([...p.calls||[]].forEach(E=>{sr.includes(E.type)&&E!==u&&(nt(u).find(w=>w===E)||a(p,E))}),p===l)return;let m;if(p.type===f.FunctionDeclaration){const E=Pr(p);if(E.type===f.DefinitionEntity)return;E.type===f.Loop&&(m=E)}if(m){const E=lp(m);E.reachable||E.blocks.forEach(b=>{a(p,b.blockedByCalling)})}}),{reachable:d.length===0,entryPoint:l,blocks:d}}function iye(u){return sf.includes(u.type)?u.type===f.FunctionDeclaration?!pj(u):!0:!1}function sye(u){if(f.ActionDescriptor===u.type){if(u.project.operationDeclarations.find(p=>p.id===u.id))return f.Operation;if(u.project.globalEventActionDescriptors.find(p=>p.id===u.id))return f.GlobalEvent;if(u.project.loopDeclarations.find(p=>p.id===u.id))return f.Loop;if(u.project.conditionDeclarations.find(p=>p.id===u.id))return f.Condition}return u.type}function Iy(u,d){return u.type===f.BuiltInBaseEntity?u.name===d:!!sp(u).includes(d)}function nye(u,d){return u.type===f.BuiltInBaseEntity?u.name===d:!!ip(u).includes(d)}function As(u,d){return u.type===f.BuiltInBaseEntity?u.name===d:!!Ty(u).includes(d)}function aye(u){const d=[];return u.entities.forEach(n=>{if(Iy(n,ge.PERSISTED_ENTITY)){d.push(n);return}}),I(d)}function oye(u){const d=[];return u.entities.forEach(n=>{if(Iy(n,ge.RELATIONAL_DATABASE)){d.push(n);return}}),I(d)}function lye(u){return u.type!==f.DefinitionEntity||u.abstract||!Iy(u,ge.PERSISTED_ENTITY)?null:(u==null?void 0:u.properties.find(n=>{var a;return((a=n.implements)==null?void 0:a.id)===pe[f.BuiltInBaseEntity][ge.PERSISTED_ENTITY].properties.primaryKey.id&&!n.abstract}))||null}function yj(u){var a;const d=gb(u);if(!d)return null;const n=d.properties.find(l=>{var p;return((p=l.implements)==null?void 0:p.id)===pe[f.BuiltInBaseEntity][ge.PERSISTED_ENTITY].properties.database.id});return n?(a=n.getDefaultValue())==null?void 0:a.valueAsType:null}function od(u){if(u.type!==f.DefinitionEntity)return[];if(u.abstract)return[];if(!As(u,ge.PERSISTED_ENTITY))return[];const d=[],n=u.properties.filter(a=>{var l;return((l=a.implements)==null?void 0:l.id)!==pe[f.BuiltInBaseEntity][ge.PERSISTED_ENTITY].properties.database.id&&!a.abstract});return d.push(...n),d}function dye(u){var n;if(!u||u.type!==f.DefinitionEntity||!As(u,ge.PERSISTED_ENTITY))return null;const d=u.properties.find(a=>{var l;return((l=a.implements)==null?void 0:l.id)===pe[f.BuiltInBaseEntity][ge.PERSISTED_ENTITY].properties.database.id});return(n=d==null?void 0:d.getDefaultValue())==null?void 0:n.valueAsTypeSingle}function yr(u,d){var a;if(!r1.includes(d.type)||!u)return d.project||null;let n=d.project;return u.type===f.Project?n=u:((a=d.project)==null?void 0:a.id)!==u.project.id&&(n=u.project),n}function uye(u){switch(u){case f.Project:return P;case f.InstalledProject:return La;case f.DefinitionEntity:return ia;case f.FunctionDeclaration:return _a;case f.GlobalEvent:return $a;case f.VariableInstance:return Pa;case f.VariableDeclaration:return Va;case f.InputMap:return Es;case f.OutputMap:return Ks;case f.Condition:return Ca;case f.Operation:return Da;case f.FunctionCall:return Fa;case f.ReturnDeclaration:return wi;case f.ArgumentDeclaration:return ea;case f.PrimitiveEntity:return Ri;case f.DataType:return ts;case f.Property:return Xn;case f.ActionDescriptor:return Lt;case f.ReturnStatement:return ga;case f.ContinueStatement:return Qr;case f.BreakStatement:return Ba;case f.Loop:return Oa;case f.Search:return Na;case f.ValueDescriptor:return ks;case f.InternalCall:return Ma;case f.LiteralValue:return Fs}return null}function cye(u){const d={added:{},updated:{},removed:{},affected:[],seenEntities:[],self:u==null?void 0:u.self};return u==null||u.added.forEach(n=>{d.added[n.id]=n}),u==null||u.updated.forEach(n=>{d.updated[n.id]=n}),u==null||u.removed.forEach(n=>{d.removed[n.id]=n}),d.affected=Array.from(new Set(u==null?void 0:u.affected.map(n=>n.id))),d}function cr(u,d){const n=ap(u.type);return n?!n.MUTABLE_META_PROPERTIES.every(l=>{const p=u[l],t=d[l];return t===void 0||p===t?!0:Array.isArray(p)&&Array.isArray(t)?p.length!==t.length?!1:p.every((m,E)=>m===t[E]):!1}):!1}function wy(u,d={}){if(u.type===f.Project)return[];if(!u.parent)return[];const n=W(u.parent);if(!n)return[];const a=d[n];return a?[a.id,...wy(a,d)]:[]}function pye(u){const d=[],n=new Set;return[...u.listAdded,...u.listUpdated,...u.listAffected].forEach(a=>{const l=Pr(a);!l||n.has(l.id)||(n.add(l.id),d.push(l))}),I(d)}function fye(u){if(u.type===f.Condition)return null;if(u.type===f.Search)return u.project.getBuiltIn(pe["value-descriptor"][pl.SearchErrorOutputDescriptor].id)||null;if(u.type===f.Operation)return u.declaration.error;if(u.type===f.FunctionCall){const n=u.declaration.returnStatements.find(a=>!!a.throws);return(n==null?void 0:n.throws)||null}return null}function mj(u){const d=u.entities.filter(l=>!!l.implements.find(p=>p.id===pe["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id)),n=d.find(l=>{const p=l.properties.find(E=>E.implements&&E.implements.id===pe["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id),t=p==null?void 0:p.getDefaultValue();return(t==null?void 0:t.value)===!0});return n||d[0]||null}function Vb(u,d){const n=Array.from(new Set([...d.getAllBuiltInIds(),...bs()]));return!!(n.includes(u.id)||!wy(u,{...d.instances,...d.builtInInstances}).every(p=>!n.includes(p)))}function vj(u){const d=eue(),n=u.toJSON();d.safeParse(n).success;const l=u.implements.flatMap(_=>hye(u,_)),p=u.extends.flatMap(_=>yye(u,_)),t=vye(u),m=mye(u);u.methods.flatMap(_=>_.validate());const E=[...l,...p,...t,...m];return qt(u.errors,E)}function Ej(u,d){const n=d.properties.filter(p=>p.abstract),a=[];let l=[...u.properties];return n.forEach(p=>{const t=l.find(m=>{var E;return((E=m.implements)==null?void 0:E.id)===p.id});t?l=l.filter(m=>m.id!==t.id):a.push(p)}),a}function Tj(u,d){const n=d.abstractMethods,a=[];let l=[...u.methods];return n.forEach(p=>{const t=l.find(m=>{var E;return((E=m.implements)==null?void 0:E.id)===p.id});t?l=l.filter(m=>m.id!==t.id):a.push(p)}),a}function hye(u,d){const n=[];if(!d.abstract){const _=et({id:u.id+"--"+he.ImplementingNonAbstractEntity,message:`Entity "${u.name}" with id "${u.id}" is implementing a non-abstract entity "${d.name}" with id "${d.id}"`,issue:null,severity:S.Error,code:he.ImplementingNonAbstractEntity,entity:u});return n.push(_.error),n}const a=d.properties.filter(_=>_.abstract),l=[];let p=[...u.properties];a.forEach(_=>{const w=p.find(V=>{var B;return((B=V.implements)==null?void 0:B.id)===_.id});w?p=p.filter(V=>V.id!==w.id):l.push(_)}),l.length&&l.forEach(_=>{const w=et({id:u.id+"--"+he.MissingPropertyImplementation+"--"+_.id,message:`Property "${_.name}" with id "${_.id}" of entity "${d.name}" with id "${d.id}" is not implemented when entity "${u.name}" with id "${u.id}" implements it`,issue:null,severity:S.Error,code:he.MissingPropertyImplementation,entity:u});n.push(w.error)});const t=[];let m=[...u.methods];d.abstractMethods.forEach(_=>{const w=m.find(V=>{var B;return((B=V.implements)==null?void 0:B.id)===_.id});w?m=m.filter(V=>V.id!==w.id):t.push(_)}),t.length&&t.forEach(_=>{const w=et({id:u.id+"--"+he.MissingMethodImplementation+"--"+_.id,message:`Method "${_.name}" with id "${_.id}" of entity "${d.name}" with id "${d.id}" is not implemented when entity "${u.name}" with id "${u.id}" implements it`,issue:null,severity:S.Error,code:he.MissingMethodImplementation,entity:u});n.push(w.error)});const E=[];d.properties.forEach(_=>{const w=p.find(V=>V.name===_.name);w&&E.push([w,_])}),E.length&&E.forEach(([_])=>{const w=et({id:u.id+"--"+le.PropertyOverwritesOtherSiblingWithSameName+"--"+_.id,message:`Property "${_.name}" with id "${_.id}" of entity "${u.name}" with id "${u.id}" overwrites the property with the same name from the base entity "${d.name}" with id "${d.id}"`,issue:null,severity:S.Error,code:le.PropertyOverwritesOtherSiblingWithSameName,entity:u});n.push(w.error)});const b=[];return d.methods.forEach(_=>{const w=m.find(V=>V.name===_.name);w&&b.push([w,_])}),b.length&&b.forEach(([_])=>{const w=et({id:u.id+"--"+le.MethodOverwritesOtherSiblingWithSameName+"--"+_.id,message:`Method "${_.name}" with id "${_.id}" of entity "${u.name}" with id "${u.id}" overwrites the method with the same name from the base entity "${d.name}" with id "${d.id}"`,issue:null,severity:S.Error,code:le.MethodOverwritesOtherSiblingWithSameName,entity:u});n.push(w.error)}),n}function yye(u,d){const n=[],a=[];if(!u.abstract&&d.abstract){const p=et({id:u.id+"--"+d.id+"--"+he.NonAbstractExtendingAbstractEntity,message:`Entity "${u.name}" with id "${u.id}" is not-abstract but is extending an abstract entity "${d.name}" with id "${d.id}"`,issue:null,severity:S.Error,code:he.NonAbstractExtendingAbstractEntity,entity:u,firstRelationship:d});return n.push(p.error),n}if(u.abstract&&!d.abstract){const p=et({id:u.id+"--"+d.id+"--"+he.AbstractExtendingNonAbstractEntity,message:`Entity "${u.name}" with id "${u.id}" is abstract but is extending an non-abstract entity "${d.name}" with id "${d.id}"`,issue:null,severity:S.Error,code:he.AbstractExtendingNonAbstractEntity,entity:u,firstRelationship:d});return n.push(p.error),n}u.properties.forEach(p=>{var m;const t=d.properties.find(E=>{var b;return E.name===p.name&&((b=p.extends)==null?void 0:b.id)!==E.id});((m=p.implements)==null?void 0:m.id)!==(t==null?void 0:t.id)&&t&&a.push(p)}),a.length&&a.forEach(p=>{const t=et({id:u.id+"--"+le.PropertyOverwritesOtherSiblingWithSameName,message:`Property "${p.name}" with id "${p.id}" of entity "${u.name}" with id "${u.id}" overwrites the property with the same name from the extended entity "${d.name}" with id "${d.id}"`,issue:null,severity:S.Error,code:le.PropertyOverwritesOtherSiblingWithSameName,entity:u});n.push(t.error)});const l=[];return u.methods.forEach(p=>{var m;const t=d.methods.find(E=>{var b;return E.name===p.name&&((b=p.extends)==null?void 0:b.id)!==E.id});((m=p.implements)==null?void 0:m.id)!==(t==null?void 0:t.id)&&t&&l.push(p)}),l.length&&l.forEach(p=>{const t=et({id:u.id+"--"+le.MethodOverwritesOtherSiblingWithSameName,message:`Method "${p.name}" with id "${p.id}" of entity "${u.name}" with id "${u.id}" overwrites the method with the same name from the extended entity "${d.name}" with id "${d.id}"`,issue:null,severity:S.Error,code:le.MethodOverwritesOtherSiblingWithSameName,entity:u});n.push(t.error)}),n}function mye(u){const d=[];if(!u.properties.length){const n=et({id:u.id+"--"+he.NoProperties,message:"No properties implemented",issue:null,severity:S.Warning,code:he.NoProperties,entity:u});d.push(n.error)}return u.properties.forEach(n=>{n.validate()}),d}function vye(u){const d=[];if(u.abstract){if(u.methods.length){const n=et({id:u.id+"--"+he.AbstractEntityWithNonAbstractMethods,message:`Entity "${u.name}" with id "${u.id}" is marked as abstract but has non-abstract methods`,issue:null,severity:S.Error,code:he.AbstractEntityWithNonAbstractMethods,entity:u});d.push(n.error)}if(u.properties.some(n=>!n.abstract)){const n=et({id:u.id+"--"+he.AbstractEntityWithNonAbstractProperties,message:`Entity "${u.name}" with id "${u.id}" is marked as abstract but has non-abstract properties`,issue:null,severity:S.Error,code:he.AbstractEntityWithNonAbstractProperties,entity:u});d.push(n.error),u.properties.forEach(a=>{if(!a.abstract){const l=et({id:u.id+"--"+he.StaticEntityWithNonStaticProperties+"--"+a.id,message:`Property "${a.name}" with id "${a.id}" of entity "${u.name}" with id "${u.id}" is not marked as abstract but the entity is marked as abstract`,issue:null,severity:S.Error,code:he.StaticEntityWithNonStaticProperties,entity:u});d.push(l.error)}})}}else{if(u.abstractMethods.length){const n=et({id:u.id+"--"+he.AbstractPropertyInNonAbstractEntity,message:`Entity "${u.name}" with id "${u.id}" is not marked as abstract but has abstract methods`,issue:null,severity:S.Error,code:he.AbstractPropertyInNonAbstractEntity,entity:u});d.push(n.error)}u.properties.some(n=>n.abstract)&&u.properties.forEach(n=>{if(n.abstract){const a=et({id:u.id+"--"+he.AbstractPropertyInNonAbstractEntity+"--"+n.id,message:`Property "${n.name}" with id "${n.id}" of entity "${u.name}" with id "${u.id}" is marked as abstract but the entity is not marked as abstract`,issue:null,severity:S.Error,code:he.AbstractPropertyInNonAbstractEntity,entity:u,firstRelationship:n});d.push(a.error)}})}return u.static&&u.properties.some(n=>!n.static)&&u.properties.forEach(n=>{if(!n.static){const a=et({id:u.id+"--"+he.NonStaticPropertyInStaticEntity+"--"+n.id,message:`Property "${n.name}" with id "${n.id}" of entity "${u.name}" with id "${u.id}" is not marked as static but the entity is marked as static`,issue:null,severity:S.Error,code:he.NonStaticPropertyInStaticEntity,entity:u,firstRelationship:n});d.push(a.error)}}),d}function Eye(u,d){const n=[],a=hi(d);if(!d.abstract){const t=new xt({id:u.id+"--"+d.id+"--"+he.ImplementingNonAbstractEntity,message:`Entity "${u.name}" with id "${u.id}" is implementing a non-abstract built-in entity "${d.name}" with id "${d.id}"`,issue:null,severity:S.Error,code:he.ImplementingNonAbstractEntity,entity:u,firstRelationship:d});n.push(t)}const l=u.implements.filter(t=>t.id!==d.id);if(u.abstract){const t=new xt({id:u.id+"--"+d.id+"--"+he.AbstractEntityImplements,message:`Entity "${u.name}" with id "${u.id}" is marked as abstract and cannot implement built-in entity "${d.name}" with id "${d.id}"`,issue:null,severity:S.Error,code:he.AbstractEntityImplements,entity:u,firstRelationship:d});n.push(t)}if(u.static&&!d.static){const t=new xt({id:u.id+"--"+d.id+"--"+he.StaticImplementingNonStaticEntity,message:`Entity "${u.name}" with id "${u.id}" is marked as static and cannot implement non-static built-in entity "${d.name}" with id "${d.id}"`,issue:null,severity:S.Error,code:he.StaticImplementingNonStaticEntity,entity:u,firstRelationship:d});n.push(t)}if(!u.static&&d.static){const t=new xt({id:u.id+"--"+d.id+"--"+he.NonStaticImplementingStaticEntity,message:`Entity "${u.name}" with id "${u.id}" is not marked as static and cannot implement static built-in entity "${d.name}" with id "${d.id}"`,issue:null,severity:S.Error,code:he.NonStaticImplementingStaticEntity,entity:u,firstRelationship:d});n.push(t)}return l.length&&l.forEach(t=>{if(t.type===f.BuiltInBaseEntity){const m=a.filter(E=>E.id!==t.id);m.length&&m.forEach(E=>{if(E.id!==t.id){const b=new xt({id:u.id+"--"+E.id+"--"+t.id+"--"+he.ImplementsIncompatibleEntities,message:`Entity "${u.name}" with id "${u.id}" is implementing built-in entity "${E.name}" with id "${E.id}" but also implements entity "${t.name}" with id "${t.id}" which is incompatible`,issue:null,severity:S.Error,code:he.ImplementsIncompatibleEntities,entity:u,firstRelationship:E,secondRelationship:t});n.push(b)}})}else{hi(t).forEach(_=>{const w=a.filter(V=>V.id!==_.id);w.length&&w.forEach(V=>{if(V.id!==_.id){const B=new xt({id:u.id+"--"+V.id+"--"+_.id+"--"+he.ImplementsIncompatibleEntities,message:`Entity "${u.name}" with id "${u.id}" is implementing built-in entity "${V.name}" with id "${V.id}" but also implements entity "${_.name}" with id "${_.id}" which is incompatible`,issue:null,severity:S.Error,code:he.ImplementsIncompatibleEntities,entity:u,firstRelationship:V,secondRelationship:_});n.push(B)}})});const E=ra(d.ownDeclaredProperties,t.ownDeclaredProperties,le.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation,le.PropertyOverwritesOtherImplementedEntitysPropertyWithSameName);n.push(...E.errors);const b=ra(d.abstractMethods,[...t.abstractMethods,...t.methods],le.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation,le.MethodOverwritesOtherImplementedEntitysMethodWithSameName);n.push(...b.errors)}}),I(u.extends.flatMap(t=>hi(t))).forEach(t=>{if(!a.find(m=>m.id===t.id)){const m=new xt({id:u.id+"--"+d.id+"--"+t.id+"--"+he.ExtendsIncompatibleEntities,message:`Entity "${u.name}" with id "${u.id}" is implementing built-in entity "${d.name}" with id "${d.id}" but also extends entity "${t.name}" with id "${t.id}" which is incompatible`,issue:null,severity:S.Error,code:he.ExtendsIncompatibleEntities,entity:u,firstRelationship:d,secondRelationship:t});n.push(m)}}),n}function Tye(u,d,n=!1){const a=[],l=hi(d);if(!u.abstract&&d.abstract){const _=et({id:u.id+"--"+d.id+"--"+he.NonAbstractExtendingAbstractEntity,message:`Entity "${u.name}" with id "${u.id}" is not-abstract but is extending an abstract entity "${d.name}" with id "${d.id}"`,issue:null,severity:S.Error,code:he.NonAbstractExtendingAbstractEntity,entity:u,firstRelationship:d});a.push(_.error)}if(u.abstract&&!d.abstract){const _=et({id:u.id+"--"+d.id+"--"+he.AbstractExtendingNonAbstractEntity,message:`Entity "${u.name}" with id "${u.id}" is abstract but is extending an non-abstract entity "${d.name}" with id "${d.id}"`,issue:null,severity:S.Error,code:he.AbstractExtendingNonAbstractEntity,entity:u,firstRelationship:d});a.push(_.error)}if(!u.static&&d.static){const _=et({id:u.id+"--"+d.id+"--"+he.NonStaticExtendingStaticEntity,message:`Entity "${u.name}" with id "${u.id}" is not static but is extending a static entity "${d.name}" with id "${d.id}"`,issue:null,severity:S.Error,code:he.NonStaticExtendingStaticEntity,entity:u,firstRelationship:d});a.push(_.error)}if(u.static&&!d.static){const _=et({id:u.id+"--"+d.id+"--"+he.StaticExtendingNonStaticEntity,message:`Entity "${u.name}" with id "${u.id}" is static but is extending an non-static entity "${d.name}" with id "${d.id}"`,issue:null,severity:S.Error,code:he.StaticExtendingNonStaticEntity,entity:u,firstRelationship:d});a.push(_.error)}if(!np(d)){const _=et({id:u.id+"--"+d.id+"--"+he.ExtendingNonInteractiveEntity,message:`Entity "${u.name}" with id "${u.id}" is extending an non-interactive entity "${d.name}" with id "${d.id}"`,issue:null,severity:S.Error,code:he.ExtendingNonInteractiveEntity,entity:u,firstRelationship:d});a.push(_.error)}const t=u.extends.filter(_=>_.id!==d.id);t.length&&t.forEach(_=>{if(_.type===f.BuiltInBaseEntity){const w=l.filter(V=>V.id!==_.id);w.length&&w.forEach(V=>{if(V.id!==_.id){const B=et({id:u.id+"--"+V.id+"--"+_.id+"--"+he.ExtendsIncompatibleEntities,message:`Entity "${u.name}" with id "${u.id}" is extending built-in entity "${V.name}" with id "${V.id}" but also extends entity "${_.name}" with id "${_.id}" which is incompatible`,issue:null,severity:S.Error,code:he.ExtendsIncompatibleEntities,entity:u,firstRelationship:V,secondRelationship:_});a.push(B.error)}})}else{hi(_).forEach(Q=>{const ie=l.filter(H=>H.id!==Q.id);ie.length&&ie.forEach(H=>{if(H.id!==Q.id){const Ie=new xt({id:u.id+"--"+H.id+"--"+Q.id+"--"+he.ImplementsIncompatibleEntities,message:`Entity "${u.name}" with id "${u.id}" is extending built-in entity "${H.name}" with id "${H.id}" but also extends or implements entity "${Q.name}" with id "${Q.id}" which is incompatible`,issue:null,severity:S.Error,code:he.ImplementsIncompatibleEntities,entity:u,firstRelationship:H,secondRelationship:Q});a.push(Ie)}})});const V=!!hi(_).find(Q=>Q.id===d.id);let B=[..._.properties];V&&(B=B.filter(Q=>!d.properties.find(ie=>{var H;return ie.id===Q.id||ie.name===Q.name||ie.id===((H=Q.implements)==null?void 0:H.id)})));let K=[..._.methods];V&&(K=K.filter(Q=>!d.methods.find(ie=>{var H;return ie.id===Q.id||ie.name===Q.name||ie.id===((H=Q.implements)==null?void 0:H.id)})));const q=ra(d.ownDeclaredProperties,B,le.PropertyOverwritesOtherExtendedEntitysPropertyWithSameImplementation,le.PropertyOverwritesOtherExtendedEntitysPropertyWithSameName);a.push(...q.errors);const Z=ra(d.abstractMethods,K,le.MethodOverwritesOtherExtendedEntitysMethodWithSameImplementation,le.MethodOverwritesOtherExtendedEntitysMethodWithSameName);a.push(...Z.errors)}}),n&&console.log("self.implements.length",u.implements.length),u.implements.length&&u.implements.forEach(_=>{if(_.type===f.BuiltInBaseEntity){const w=l.filter(V=>V.id!==_.id);w.length&&w.forEach(V=>{if(V.id!==_.id){const B=new xt({id:u.id+"--"+V.id+"--"+_.id+"--"+he.ImplementsIncompatibleEntities,message:`Entity "${u.name}" with id "${u.id}" is implementing built-in entity "${V.name}" with id "${V.id}" but also implements entity "${_.name}" with id "${_.id}" which is incompatible`,issue:null,severity:S.Error,code:he.ImplementsIncompatibleEntities,entity:u,firstRelationship:V,secondRelationship:_});a.push(B)}})}else{hi(_).forEach(K=>{const q=l.filter(Z=>Z.id!==K.id);q.length&&q.forEach(Z=>{if(Z.id!==K.id){const Q=new xt({id:u.id+"--"+Z.id+"--"+K.id+"--"+he.ImplementsIncompatibleEntities,message:`Entity "${u.name}" with id "${u.id}" is implementing built-in entity "${Z.name}" with id "${Z.id}" but also implements entity "${K.name}" with id "${K.id}" which is incompatible`,issue:null,severity:S.Error,code:he.ImplementsIncompatibleEntities,entity:u,firstRelationship:Z,secondRelationship:K});a.push(Q)}})});const V=ra(d.ownDeclaredProperties,_.ownDeclaredProperties,le.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation,le.PropertyOverwritesOtherImplementedEntitysPropertyWithSameName);a.push(...V.errors);const B=ra(d.abstractMethods,[..._.abstractMethods,..._.methods],le.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation,le.MethodOverwritesOtherImplementedEntitysMethodWithSameName);a.push(...B.errors)}});const m=ra(u.ownDeclaredProperties,d.ownDeclaredProperties,le.PropertyOverwritesOtherSiblingWithSameImplementation,le.PropertyOverwritesOtherSiblingWithSameName);a.push(...m.errors);const E=ra(d.methods,d.abstractMethods,le.MethodOverwritesOtherSiblingWithSameImplementation,le.MethodOverwritesOtherSiblingWithSameName);return a.push(...E.errors),I(u.extends.flatMap(_=>hi(_))).forEach(_=>{if(!l.find(w=>w.id===_.id)){const w=new xt({id:u.id+"--"+d.id+"--"+_.id+"--"+he.ImplementsIncompatibleEntities,message:`Entity "${u.name}" with id "${u.id}" is extending built-in entity "${d.name}" with id "${d.id}" but also extends entity "${_.name}" with id "${_.id}" which is incompatible`,issue:null,severity:S.Error,code:he.ImplementsIncompatibleEntities,entity:u,firstRelationship:d,secondRelationship:_});a.push(w)}}),a}function bye(u){const d=[];return u.implements.forEach(n=>{if(!n.static){const a=new xt({id:u.id+"--"+n.id+"--"+he.StaticImplementingNonStaticEntity,message:`Entity "${u.name}" with id "${u.id}" is static but implements entity "${n.name}" with id "${n.id}" which is non-static`,issue:null,severity:S.Error,code:he.StaticImplementingNonStaticEntity,entity:u,firstRelationship:n});d.push(a)}}),u.extends.forEach(n=>{if(!n.static){const a=new xt({id:u.id+"--"+n.id+"--"+he.StaticExtendingNonStaticEntity,message:`Entity "${u.name}" with id "${u.id}" is static but extends entity "${n.name}" with id "${n.id}" which is non-static`,issue:null,severity:S.Error,code:he.StaticExtendingNonStaticEntity,entity:u,firstRelationship:n});d.push(a)}}),d}function Aye(u){const d=[];if(u.implements.length){const n=new xt({id:u.id+"--"+he.AbstractEntityImplements,message:`Entity "${u.name}" with id "${u.id}" cannot be marked as abstract because it implements other entities`,issue:null,severity:S.Error,code:he.AbstractEntityImplements,entity:u});d.push(n)}return u.extends.forEach(n=>{if(!n.abstract){const a=new xt({id:u.id+"--"+n.id+"--"+he.AbstractExtendingNonAbstractEntity,message:`Entity "${u.name}" with id "${u.id}" is abstract but extends entity "${n.name}" with id "${n.id}" which is non-abstract`,issue:null,severity:S.Error,code:he.AbstractExtendingNonAbstractEntity,entity:u,firstRelationship:n});d.push(a)}}),d}function Iye(u){const d=[];return u.extends.forEach(n=>{if(n.static){const a=new xt({id:u.id+"--"+n.id+"--"+he.NonStaticExtendingStaticEntity,message:`Entity "${u.name}" with id "${u.id}" is non-static but extends entity "${n.name}" with id "${n.id}" which is static`,issue:null,severity:S.Error,code:he.NonStaticExtendingStaticEntity,entity:u,firstRelationship:n});d.push(a)}}),d}function wye(u){const d=[];return u.extends.forEach(n=>{if(n.abstract){const a=new xt({id:u.id+"--"+n.id+"--"+he.NonAbstractExtendingAbstractEntity,message:`Entity "${u.name}" with id "${u.id}" is non-abstract but extends entity "${n.name}" with id "${n.id}" which is abstract`,issue:null,severity:S.Error,code:he.NonAbstractExtendingAbstractEntity,entity:u,firstRelationship:n});d.push(a)}}),d}const Rye=Object.freeze(Object.defineProperty({__proto__:null,getBaseMethodsNotImplemented:Tj,getBasePropertiesNotImplemented:Ej,validate:vj,validateCanBecomeAbstract:Aye,validateCanBecomeNonAbstract:wye,validateCanBecomeNonStatic:Iye,validateCanBecomeStatic:bye,validateCanExtendEntity:Tye,validateCanImplementEntity:Eye},Symbol.toStringTag,{value:"Module"}));function _ye(u,d){const n=[];if(u.parent)if(u.id===u.parent)n.push(new Y({id:`${u.id}--${u.parent}--${k.SelfReference}`,code:k.SelfReference,severity:S.Error,message:`Entity of type "${u.type}" with id "${u.id}", has a reference to itself at 'parent'. This is not allowed. Change the reference string or the 'entityId' property of the reference object.`,issue:null}));else{const a=d.get(u.parent);a?[f.Project,f.DataType].includes(a.type)||n.push(new Y({id:`${u.id}--${u.parent}--${k.InvalidParentReference}`,code:k.InvalidParentReference,severity:S.Error,message:`Entity of type "${u.type}" with id "${u.id}", has a parent reference that isn't pointing to an entity of type 'project' or 'data-type'.`,issue:null})):n.push(new Y({id:`${u.id}--${u.parent}--${k.ReferencedEntityNotFound}`,code:k.ReferencedEntityNotFound,severity:S.Error,message:`Entity of type "${u.type}" with id "${u.id}", is referencing an entity with id "${u.parent}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,issue:null}))}return u.implements&&Array.isArray(u.implements)?u.implements.forEach(a=>{if(u.id===a){n.push(new Y({id:`${u.id}--${a}--${k.SelfReference}`,code:k.SelfReference,severity:S.Error,message:`Entity of type "${u.type}" with id "${u.id}", has a reference to itself at one of the 'implements' references. This is not allowed. Change the reference string or the 'entityId' property of the reference object.`,issue:null}));return}const l=d.get(a);l?[f.DefinitionEntity,f.BuiltInBaseEntity].includes(l.type)?l.abstract||n.push(new Y({id:`${u.id}--${a}--${k.InvalidImplementsReference}`,code:k.InvalidImplementsReference,severity:S.Error,message:`Entity of type "${u.type}" with id "${u.id}", has an 'implements' reference that isn't pointing to an abstract entity.`,issue:null})):n.push(new Y({id:`${u.id}--${a}--${k.InvalidImplementsReference}`,code:k.InvalidImplementsReference,severity:S.Error,message:`Entity of type "${u.type}" with id "${u.id}", has an 'implements' reference that isn't pointing to an entity of type 'definition-entity' or 'built-in-base-entity'.`,issue:null})):n.push(new Y({id:`${u.id}--${a}--${k.ReferencedEntityNotFound}`,code:k.ReferencedEntityNotFound,severity:S.Error,message:`Entity of type "${u.type}" with id "${u.id}", is referencing an entity with id "${a}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,issue:null}))}):n.push(new Y({id:`${u.id}--${le.InvalidObjectStructure}`,code:le.InvalidObjectStructure,severity:S.Error,message:`Entity of type "${u.type}" with id "${u.id}", has an 'implements' property that isn't an array.`,issue:null})),u.extends&&Array.isArray(u.extends)&&u.extends.forEach(a=>{const l=d.get(a);l?[f.DefinitionEntity,f.BuiltInBaseEntity].includes(l.type)?l.abstract&&n.push(new Y({id:`${u.id}--${a}--${k.InvalidExtendsReference}`,code:k.InvalidExtendsReference,severity:S.Error,message:`Entity of type "${u.type}" with id "${u.id}", has an 'extends' reference that isn't pointing to a non-abstract entity. Did you want to use the property 'implements', which holds a list of references to absract entities, instead?`,issue:null})):n.push(new Y({id:`${u.id}--${a}--${k.InvalidExtendsReference}`,code:k.InvalidExtendsReference,severity:S.Error,message:`Entity of type "${u.type}" with id "${u.id}", has an 'extends' reference that isn't pointing to an entity of type 'definition-entity' or 'built-in-base-entity'.`,issue:null})):n.push(new Y({id:`${u.id}--${a}--${k.ReferencedEntityNotFound}`,code:k.ReferencedEntityNotFound,severity:S.Error,message:`Entity of type "${u.type}" with id "${u.id}", is referencing an entity with id "${a}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,issue:null}))}),n}var Ry=(u=>(u.Extends="extends",u.Implements="implements",u))(Ry||{});const _t=class _t extends nr{constructor(n,a){super(n);g(this,"initialData");g(this,"id");g(this,"name");g(this,"description",null);g(this,"x");g(this,"y");g(this,"static");g(this,"abstract");g(this,"type",f.DefinitionEntity);g(this,"properties",[]);g(this,"methods",[]);g(this,"abstractMethods",[]);g(this,"extends",[]);g(this,"implements",[]);g(this,"project");g(this,"errors",[]);g(this,"parent");g(this,"detachedDependents",{});g(this,"knownVersions",null);g(this,"activeVersion",!1);g(this,"initialized",!1);g(this,"startedInitialization",!1);g(this,"suggestedProperties",[]);g(this,"suggestedMethods",[]);this.initialData=n,this.project=a,this.id=n.id,this.name=n.name,this.description=n.description,this.x=n.x,this.y=n.y,this.static=n.static,this.abstract=n.abstract}static new(n=null){return{id:P.UUID.uuid(),version:P.UUID.uuid(),createdAt:(n==null?void 0:n.timestamp)||N().toISOString(),author:(n==null?void 0:n.author)||P.sessionAuthor,previousVersion:null,deleted:!1,type:f.DefinitionEntity,name:"",description:"",static:!1,abstract:!1,properties:[],methods:[],abstractMethods:[],extends:[],implements:[],x:0,y:0,parent:null}}static fromGenerationTarget(n,a){let l=a;if(n.parent){const b=W(n.parent);l=a.get(b)}const p=[];n.implements&&n.implements.forEach(b=>{p.push(a.get(b)||a.getBuiltIn(b))});const t=[];n.extends&&n.extends.forEach(b=>{t.push(a.get(b)||a.getBuiltIn(b))});const m={id:n.id,version:P.UUID.uuid(),createdAt:N().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,name:n.name,type:f.DefinitionEntity,description:n.description,static:n.static,abstract:n.abstract,properties:[],methods:[],abstractMethods:[],extends:t,implements:p,x:0,y:0,parent:l},E=z(m,a);return E.setParent(l,null),E.initChildren(null),E}static validateGenerationTarget(n,a){let l=JSON.parse(JSON.stringify(n));const p=[],t=_ye(l,a),m=PT(l,a);p.push(...t,...m,...ur(l));const E=l.parent?a.get(l.parent):null;if(E&&E.type===f.DataType){const b=E;b.entity&&p.push(new Y({id:`${n.id}--${k.NewEntityWouldOverriteExisting}`,code:k.NewEntityWouldOverriteExisting,severity:S.Error,message:`The entity of type '${n.type}' with id '${n.id}' can't be added to the 'parent' entity with id '${b.id}' because it already has an 'entity' child. Data type entities can only have one 'entity' as children.
|
|
398
398
|
You can inspect the existing 'entity' field with the 'describe_entity' action. Like so:
|
|
399
399
|
${En({describe_entity:b.entity.id})}
|
|
400
|
-
Alternatively you can update the parent data-type entity with 'update' action to remove the existing value of the field.`,issue:null}))}return{errors:p,modifiedData:l}}get interactive(){return this.implements.length?this.implements.every(n=>n.interactive):!0}get allMethods(){return I([...this.ownDeclaredMethods,...this.allBaseMethodsFromOriginalParents])}get allProperties(){return I([...this.ownDeclaredProperties,...this.allBasePropertiesFromOriginalParents])}get allBaseMethodsFromOriginalParents(){return I([...this.extends.flatMap(n=>n.allMethods,[]),...this.implements.flatMap(n=>n.allMethods,[])])}get allBasePropertiesFromOriginalParents(){return I([...this.extends.flatMap(n=>n.allProperties,[]),...this.implements.flatMap(n=>n.allProperties,[])])}get allBasePropertiesFromExtendedAndImplementedEntities(){return I([...this.extends.reduce((n,a)=>[...[...a.ownDeclaredProperties,...a.allBasePropertiesFromExtendedAndImplementedEntities].filter(p=>!p.abstract),...n],[]),...this.implements.reduce((n,a)=>[...[...a.ownDeclaredProperties,...a.allBasePropertiesFromExtendedAndImplementedEntities].filter(p=>!p.abstract),...n],[])])}get allBaseMethodsFromExtendedAndImplementedEntities(){return I([...this.extends.reduce((n,a)=>a.type!==f.DefinitionEntity?[]:[...[...a.ownDeclaredMethods,...a.allBaseMethodsFromExtendedAndImplementedEntities].filter(p=>p.type!==f.ActionDescriptor),...n],[]),...this.implements.reduce((n,a)=>a.type!==f.DefinitionEntity?a.abstractMethods:[...[...a.ownDeclaredMethods,...a.allBaseMethodsFromExtendedAndImplementedEntities].filter(p=>p.type!==f.ActionDescriptor),...n],[])])}get extendedPropertiesFromOriginalParents(){return I(this.extends.reduce((n,a)=>{const l=[...a.ownDeclaredProperties,...a.extendedPropertiesFromOriginalParents].filter(p=>!p.abstract);return[...n,...l]},[]))}get implementedPropertiesFromOriginalParents(){return I([...this.extends.reduce((n,a)=>{const l=a.implementedPropertiesFromOriginalParents,p=[...a.ownDeclaredProperties].filter(t=>!!t.abstract&&!l.find(m=>m.name===t.name));return[...l,...p,...n]},[]),...this.implements.reduce((n,a)=>{const l=a.implementedPropertiesFromOriginalParents,p=[...a.ownDeclaredProperties].filter(t=>!!t.abstract&&!l.find(m=>m.name===t.name));return[...l,...p,...n]},[])].filter(n=>!!n.abstract))}get extendedMethodsFromOriginalParents(){return I(this.extends.reduce((n,a)=>{if(a.type!==f.DefinitionEntity)return[];const l=[...a.ownDeclaredMethods,...a.extendedMethodsFromOriginalParents].filter(p=>p.type!==f.ActionDescriptor);return[...n,...l]},[]))}get implementedMethodsFromOriginalParents(){return I([...this.extends.reduce((n,a)=>{const l=a.type===f.DefinitionEntity?a.methods:[],p=[...a.abstractMethods].filter(t=>!l.find(m=>m.name===t.name));return[...l,...p,...n]},[]),...this.implements.reduce((n,a)=>[...a.abstractMethods,...n],[])].filter(n=>n.type===f.ActionDescriptor))}get extendedProperties(){return this.properties.filter(n=>n.isExtendedProperty)}get ownDeclaredProperties(){return this.properties.filter(n=>!n.isExtendedProperty)}get extendedMethods(){return this.methods.filter(n=>n.isExtendedMethod)}get ownDeclaredMethods(){return this.methods.filter(n=>!n.isExtendedMethod)}validateGeneratedUpdate(n){const a=[];return n.parent&&a.push(new Y({id:`${this.id}--${k.InvalidParentUpdate}`,code:k.InvalidParentUpdate,severity:S.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated. The 'parent' on an '${this.type}', must be the root project as it is a globally declared entity.`,issue:null})),{errors:a,modifiedData:n}}subscribeDependents(n){return n.forEach(a=>{this.detachedDependents[a.entity.id]||(this.detachedDependents[a.entity.id]=a)}),this}unsubscribeDependents(n){return n.forEach(a=>{this.detachedDependents[a.entity.id]&&delete this.detachedDependents[a.entity.id]}),this}syncDependents(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"sync-dependents"))){const a=[],l=[],p=[],t=[];return Object.values(this.detachedDependents).forEach(m=>{const E=m.entity.afterAllChildrenInitialized(n);a.push(...E.updated),l.push(...E.added),p.push(...E.removed),t.push(...E.affected)}),n==null||n.attemptAutoclose("sync-dependents",this.id),{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this}}onDetachedDependencyRemoved(n,a,l){const p=[],t=[],m=[],E=[];return a==="implements"&&this.removeImplementation(n),a==="extends"&&this.removeExtension(n),{updated:I(p),added:I(t),removed:I(m),affected:I(E),self:this}}onDetachedDependencyRestored(n,a,l){const p=[],t=[],m=[],E=[];return a==="implements"&&this.addImplementation(n),a==="extends"&&this.addExtension(n),{updated:I(p),added:I(t),removed:I(m),affected:I(E),self:this}}unsubscribeFromDependencies(){return this.implements.forEach(n=>{Pi.includes(n.type)||n.unsubscribeDependents([{entity:this,field:"implements"}])}),this}subscribeToDependencies(){return this.implements.forEach(n=>{Pi.includes(n.type)||n.subscribeDependents([{entity:this,field:"implements"}])}),this.extends.forEach(n=>{Pi.includes(n.type)||n.subscribeDependents([{entity:this,field:"extends"}])}),this}increaseVersion(n){if(n&&!N(n).isValid())throw new Error(`The shared timestamp '${n}' is not a valid ISO 8601 date string.`);return n&&N(n).isSame(N(this.createdAt))?this:(this.previousVersion=this.version,this.version=P.UUID.uuid(),this.createdAt=N(n).toISOString()||N().toISOString(),this)}captureVersion(){var a;const n=((a=this.knownVersions)==null?void 0:a.get(this.version))||new _t(this,this.project);return n.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,n):new Map([[this.version,n]]),n.properties=[...this.properties],n.methods=[...this.methods],n.abstractMethods=[...this.abstractMethods],n.extends=[...this.extends],n.implements=[...this.implements],n.parent=this.parent,this}recursiveCaptureUpstreamVersions(n){const a=[],l=[],p=[],t=[];if(this.parent){this.parent.increaseVersion(n);const m=this.parent.recursiveCaptureUpstreamVersions(n);a.push(this.parent,...m.updated),l.push(...m.added),p.push(...m.removed)}return{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this}}async restoreVersion(n){var E;const a=[],l=[],p=[],t=[];if(this.version===n)return{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this};if(!this.knownVersions){const b=new Map;for(const[_,w]of this.knownVersions||new Map){if(b.set(_,w),w.activeVersion=!1,w.knownVersions)for(const[V,B]of w.knownVersions)b.set(V,B);w.knownVersions=null}}let m=(E=this.knownVersions)==null?void 0:E.get(n);if(!m){const b=await this.APILoadVersion({},n);if(!b)throw new Error(`Version with id '${n}' for entity with id '${this.id}' not found.`);m=new _t(b,this.project)}return this.metaSync(m.toShallowJSON(),null),this.previousVersion=m.previousVersion,this.version=m.version,this.createdAt=m.createdAt,this.author=m.author,this.deleted=m.deleted,this.properties=m.properties,this.methods=m.methods,this.abstractMethods=m.abstractMethods,this.extends=m.extends,this.implements=m.implements,this.parent=m.parent,{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this}}updateWithShallowTransfer(n,a=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"update-with-shallow-transfer"))){if(this.metaSync(n,a),this.version=n.version,this.createdAt=n.createdAt,this.author=n.author,this.deleted=n.deleted,this.previousVersion=n.previousVersion,this.unsubscribeFromDependencies(),n.parent){const l=W(n.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,a);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'`);return n.extends.forEach(l=>{const p=W(l),t=this.project.get(p);t&&this.addExtension(t)}),n.implements.forEach(l=>{const p=W(l),t=this.project.get(p);t&&this.addImplementation(t)}),this.captureVersion(),this.subscribeToDependencies(),a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),this}hydrateAncestors(){const n=[],a=[],l=[],p=[];if(this.initialData.parent){const t=W(this.initialData.parent),m=this.project.get(t);if(m)this.setParent(m,null),n.push(m);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'`);return this.initialData.extends.forEach(t=>{const m=W(t),E=this.project.get(m);E&&(this.addExtension(E),E.type!==f.BuiltInBaseEntity&&n.push(E))}),this.initialData.implements.forEach(t=>{const m=W(t),E=this.project.get(m);E&&(this.addImplementation(E),E.type!==f.BuiltInBaseEntity&&n.push(E))}),{updated:I(n),added:I(a),removed:I(l),affected:I(p),self:this}}afterAllChildrenInitialized(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"after-all-children-initialized"))){const a=[],l=[],p=[],t=[];this.initialized=!0;const{updated:m,added:E,removed:b,affected:_}=this.syncImplementationProperties(n);a.push(...m),l.push(...E),p.push(...b),t.push(..._);const{updated:w,added:V,removed:B,affected:K}=this.addExtendedProperties(n);a.push(...w),l.push(...V),p.push(...B),t.push(...K);const{updated:q,added:Z,removed:Q}=this.removeUnrecognizedProperties(n);a.push(...q),l.push(...Z),p.push(...Q);const{updated:ie,added:H,removed:Ie,affected:re}=this.syncImplementationMethods(n);a.push(...ie),l.push(...H),p.push(...Ie),t.push(...re);const{updated:Te,added:Ve,removed:ue,affected:ve}=this.addExtendedMethods(n);a.push(...Te),l.push(...Ve),p.push(...ue),t.push(...ve);const{updated:X,added:de,removed:$e}=this.removeUnrecognizedMethods(n);return a.push(...X),l.push(...de),p.push(...$e),this.addSuggestions(),this.captureVersion(),n==null||n.attemptAutoclose("after-all-children-initialized",this.id),{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this}}addSelfToProject(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"add-self-to-project"))){const a=[this],l=[],p=[],t=[];if(this.parent.type===f.DataType){const m=this.parent;m.entity=this,a.push(m)}else this.project.addDefinitionEntity(this);return this.subscribe(),this.subscribeToDependencies(),n==null||n.attemptAutoclose("add-self-to-project",this.id),{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this}}setParent(n,a=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"set-parent"))){var l;return((l=this.parent)==null?void 0:l.id)!==(n==null?void 0:n.id)&&(this.parent=n,a&&(a==null||a.add(this,G.Updated))),a==null||a.attemptAutoclose("set-parent",this.id),this}addExtension(n){return this.extends.includes(n)||this.extends.push(n),this}removeExtension(n){return this.extends=this.extends.filter(a=>a.id!==n.id),this}addImplementation(n){return this.implements.includes(n)||this.implements.push(n),this}removeImplementation(n){return this.implements=this.implements.filter(a=>a.id!==n.id),this}removeProperty(n){return this.properties=this.properties.filter(a=>a.id!==n.id),this}addMethod(n){return this.methods.includes(n)||(this.methods.push(n),this.suggestedMethods=this.suggestedMethods.filter(a=>a.name!==n.name)),this}removeMethod(n){return this.methods=this.methods.filter(a=>a.id!==n.id),this}addProperty(n){return this.properties.includes(n)||(this.properties.push(n),this.suggestedProperties=this.suggestedProperties.filter(a=>a.name!==n.name)),this}addSuggestedProperty(n){return this.suggestedProperties.includes(n)||this.suggestedProperties.push(n),this}addSuggestedMethod(n){return this.suggestedMethods.includes(n)||this.suggestedMethods.push(n),this}removeSuggestedProperty(n){return this.suggestedProperties=this.suggestedProperties.filter(a=>a.id!==n.id),this}removeSuggestedMethod(n){return this.suggestedMethods=this.suggestedMethods.filter(a=>a.id!==n.id),this}addAbstractMethod(n){return this.abstractMethods.includes(n)||this.abstractMethods.push(n),this}removeAbstractMethod(n){return this.abstractMethods=this.abstractMethods.filter(a=>a.id!==n.id),this}initChildren(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"init-children"))){return this.initialized||this.startedInitialization?this:(this.startedInitialization=!0,this.properties=this.initialData.properties.map(a=>{const l=z(a,this.project);return l.setParent(this,null),l.initChildren(n),l}),this.methods=this.initialData.methods.map(a=>{const l=z(a,this.project);return l.setParent(this,null),l.initChildren(n),l}),this.abstractMethods=this.initialData.abstractMethods.map(a=>{const l=z(a,this.project);return l.setParent(this,null),l.initChildren(n),l}),this.extends=this.initialData.extends.map(a=>z(a,this.project)),this.implements=this.initialData.implements.map(a=>z(a,this.project)),this.subscribeToDependencies(),this.afterAllChildrenInitialized(n),n==null||n.attemptAutoclose("init-children",this.id),this)}removeUnrecognizedProperties(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"remove-unrecognized-properties"))){const a=[],l=[],p=[],t=[];let m=[...this.properties];m=m.filter(b=>b.parent.id===this.id),m=m.filter(b=>!b.isExtendedProperty);const E=this.implementedPropertiesFromOriginalParents;return m=m.filter(b=>this.interactive&&!b.implements?!1:!E.find(_=>{var w;return _.id===((w=b.implements)==null?void 0:w.id)})),m.forEach(b=>{const _=b.remove({ignoreUpstream:!1},n);p.push(..._.removed),a.push(..._.updated)}),n==null||n.attemptAutoclose("remove-unrecognized-properties",this.id),{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this}}removeUnrecognizedMethods(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"remove-unrecognized-methods"))){const a=[],l=[],p=[],t=[];let m=[...this.methods];m=m.filter(b=>b.parent.id===this.id),m=m.filter(b=>!b.isExtendedMethod);const E=this.implementedMethodsFromOriginalParents;return m=m.filter(b=>this.interactive&&!b.implements?!1:!E.find(_=>{var w;return _.id===((w=b.implements)==null?void 0:w.id)})),m.forEach(b=>{const _=b.remove({ignoreUpstream:!1},n);p.push(..._.removed),a.push(..._.updated)}),n==null||n.attemptAutoclose("remove-unrecognized-methods",this.id),{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this}}syncImplementationMethods(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"sync-implementation-methods"))){const a=[],l=[],p=[],t=[],m=this.methods,E=this.implementedMethodsFromOriginalParents,b=[...this.allBaseMethodsFromExtendedAndImplementedEntities,...m];return E.filter(w=>!b.find(B=>{var K;return((K=B.implements)==null?void 0:K.id)===w.id})).forEach(w=>{if(this.methods.find(q=>{var Z;return((Z=q.implements)==null?void 0:Z.id)===w.id}))return;const B=this.methods.find(q=>{var Ie,re;if(q.name===w.name&&!q.implements)return!0;const Z=As(this,ge.CRON_JOB),Q=As(this,ge.HTTP_ENDPOINT),ie=((Ie=q.implements)==null?void 0:Ie.id)===pe["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.methods.handler.id,H=((re=q.implements)==null?void 0:re.id)===pe["built-in-base-entity"].BUILT_IN_CRON_JOB_ENTITY.methods.handler.id;return!!(Z&&!H&&!Q&&ie||Q&&!ie&&!Z&&H)});if(B&&B.type===f.FunctionDeclaration){B.setImplements(w),B.metaSync({name:w.name},n),n==null||n.add(B,G.Updated),n==null||n.add(this,G.Updated);return}const K=w.implementAsFunctionDeclaration(n,this);l.push(K),n==null||n.add(K,G.Added),this.addMethod(K)}),n==null||n.attemptAutoclose("sync-implementation-methods",this.id),{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this}}syncImplementationProperties(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"sync-implementation-properties"))){const a=[],l=[],p=[],t=[],m=this.properties,E=this.implementedPropertiesFromOriginalParents,b=[...this.allBasePropertiesFromExtendedAndImplementedEntities,...m];return E.filter(w=>!b.find(B=>{var K;return((K=B.implements)==null?void 0:K.id)===w.id})).forEach(w=>{if(this.properties.find(q=>{var Z;return((Z=q.implements)==null?void 0:Z.id)===w.id}))return;const B=this.properties.find(q=>q.name===w.name&&!!q.abstract&&!q.implements);if(B){B.setImplements(w,n),B.metaSync({abstract:!1},n),B.afterAllChildrenInitialized(n);return}const K=w.implement(this,n,P.UUID.uuid());l.push(K),n==null||n.add(K,G.Added)}),n==null||n.attemptAutoclose("sync-implementation-properties",this.id),{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this}}addExtendedMethods(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"add-extended-methods"))){const a=[],l=[],p=[],t=[],m=this.methods,b=this.extendedMethodsFromOriginalParents.filter(w=>w.type===f.FunctionDeclaration),_=new Set(m.filter(w=>{var V;return!!((V=w.extends)!=null&&V.id)}).map(w=>w.extends.id));return b.forEach(w=>{if(_.has(w.id))return;_.add(w.id);const V=w.clone(n,this,P.UUID.uuid());V.setExtends(w,n),V.initChildren(n),l.push(V),n==null||n.add(V,G.Added),this.addMethod(V)}),n==null||n.attemptAutoclose("add-extended-methods",this.id),{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this}}addExtendedProperties(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"add-extended-properties"))){const a=[],l=[],p=[],t=[],m=this.properties,E=this.extendedPropertiesFromOriginalParents,b=E.filter(w=>E.find(B=>{var K;return((K=B.implements)==null?void 0:K.id)===w.id})?!1:!w.abstract),_=new Set(m.filter(w=>{var V;return!!((V=w.extends)!=null&&V.id)}).map(w=>w.extends.id));return b.forEach(w=>{if(_.has(w.id))return;_.add(w.id);const V=w.clone(n,this,P.UUID.uuid());V.setExtends(w,n),V.initChildren(n),l.push(V),n==null||n.add(V,G.Added),this.addProperty(V)}),n==null||n.attemptAutoclose("add-extended-properties",this.id),{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this}}addSuggestions(){return this.implements.forEach(n=>{Ej(this,n).forEach(p=>{const t=p.toJSON();t.id=`_suggestion--parent--${this.id}--${p.id}`;const m=z(t,this.project);m.suggestion=!0,m.setParent(this,null),m.initChildren(null),this.addSuggestedProperty(m)}),Tj(this,n).forEach(p=>{const t=`_suggestion--parent--${this.id}--${p.id}`,m=p.implementAsFunctionDeclaration(null,this,t),E=z(m,this.project);if(E.suggestion=!0,E.setParent(this,null),E.initChildren(null),this.methods=this.methods.filter(b=>b.id!==t),E.inputs.forEach(b=>{b.suggestion=!0}),E.returnStatements.length){const b=E.returnStatements[0];b.suggestion=!0,b.outputs.forEach(_=>{_.suggestion=!0})}this.addSuggestedMethod(E)})}),this}subscribe(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(n,a=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"meta-sync"))){const l=cr(this,n),p=this.toMeta();return this.name=n.name!==void 0?n.name:p.name,this.description=n.description!==void 0?n.description:p.description,this.x=n.x||p.x,this.y=n.y||p.y,this.static=n.static!==void 0?n.static:this.static,this.abstract=n.abstract!==void 0?n.abstract:this.abstract,super.metaSync(n),n.deleted===!0&&!p.deleted?a==null||a.add(this,G.Removed):n.deleted===!1&&p.deleted?a==null||a.add(this,G.Added):l&&(a==null||a.add(this,G.Updated)),a==null||a.attemptAutoclose("meta-sync",this.id),this}async APILoad(n=oe,...a){return await _t.repository.APILoad(this.id,...a),this}async APICreate(n=oe,...a){return await _t.repository.APICreate(this.toShallowJSON(),...a),this}async APIUpdate(n=oe,...a){return await _t.repository.APIUpdate(this.toShallowJSON(),...a),this}async APIDelete(n=oe,...a){return await _t.repository.APIDelete(this.toShallowJSON(),...a),this}async APIClone(n=oe,...a){return await _t.repository.APIClone(this.id,...a),this}async APILoadVersion(n=oe,a,...l){return await _t.repository.APILoadVersion(this.id,a,...l)}removeFromParent(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"remove-from-parent"))){const a=[],l=[],p=[],t=[];if(this.parent.type===f.Project)this.parent.removeDefinitionEntity(this);else if(this.parent.type===f.DataType&&this.parent.entity&&this.parent.entity.id===this.id){const m=this.parent.setEntity(null,n);a.push(m)}return n==null||n.attemptAutoclose("remove-from-parent",this.id),{added:I(p),updated:I(a),removed:I(l),affected:I(t),self:this}}remove({ignoreUpstream:n}={ignoreUpstream:!1},a=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"remove-entity"))){const l=[],p=[],t=[],m=[];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(E=>{const{updated:b,removed:_,added:w}=E.entity.onDetachedDependencyRemoved(this,E.field,a);l.push(...b),p.push(..._),t.push(...w)}),this.properties.forEach(E=>{const{updated:b,removed:_}=E.remove({ignoreUpstream:!0},a);l.push(...b),p.push(..._)}),this.methods.forEach(E=>{const{updated:b,removed:_}=E.remove({ignoreUpstream:!0},a);l.push(...b),p.push(..._)}),this.abstractMethods.forEach(E=>{const{updated:b,removed:_}=E.remove({ignoreUpstream:!0},a);l.push(...b),p.push(..._)}),this.suggestedProperties.forEach(E=>{const{updated:b,removed:_}=E.remove({ignoreUpstream:!0},a);l.push(...b),p.push(..._)}),this.suggestedMethods.forEach(E=>{const{updated:b,removed:_}=E.remove({ignoreUpstream:!0},a);l.push(...b),p.push(..._)}),!n){const E=this.removeFromParent(a);t.push(...E.added),l.push(...E.updated),p.push(...E.removed),m.push(...E.affected)}return a==null||a.attemptAutoclose("remove-entity",this.id),{added:I(t),updated:I(l),removed:I(p),affected:I(m),self:this}}restore({}={},n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"restore-entity"))){const a=[],l=[],p=[],t=[];return n!=null&&n.hasAdded(this.id)?(n==null||n.attemptAutoclose("restore-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this}):(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},n),Object.values(this.detachedDependents).forEach(m=>{const{updated:E,removed:b,added:_}=m.entity.onDetachedDependencyRestored(this,m.field,n);l.push(...E),p.push(...b),a.push(..._)}),this.properties.forEach(m=>{const{updated:E}=m.restore({},n);l.push(...E)}),this.methods.forEach(m=>{const{updated:E}=m.restore({},n);l.push(...E)}),this.abstractMethods.forEach(m=>{const{updated:E}=m.restore({},n);l.push(...E)}),this.suggestedProperties.forEach(m=>{const{updated:E}=m.restore({},n);l.push(...E)}),this.suggestedMethods.forEach(m=>{const{updated:E}=m.restore({},n);l.push(...E)}),n==null||n.attemptAutoclose("restore-entity",this.id),{added:I(a),updated:I(l),removed:I(p),affected:I(t),self:this})}toFlat(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[this,...this.extends.flatMap(l=>l.toFlat(n)),...this.implements.flatMap(l=>l.toFlat(n)),...this.properties.flatMap(l=>l.toFlat(n)),...this.methods.flatMap(l=>l.toFlat(n)),...this.abstractMethods.flatMap(l=>l.toFlat(n)),...this.parent.toFlat(n)])}toFlatIds(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[this.id,...this.extends.flatMap(l=>l.toFlatIds(n)),...this.implements.flatMap(l=>l.toFlatIds(n)),...this.properties.flatMap(l=>l.toFlatIds(n)),...this.methods.flatMap(l=>l.toFlatIds(n)),...this.abstractMethods.flatMap(l=>l.toFlatIds(n)),...this.parent.toFlatIds(n)])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,description:this.description,static:this.static,abstract:this.abstract,x:this.x,y:this.y,type:this.type,name:this.name}}toJSON(n=new Set){return n.has(this.id)?this.toReference():(n.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,x:this.x,y:this.y,static:this.static,abstract:this.abstract,properties:this.properties.map(a=>a.toJSON(n)),methods:this.methods.map(a=>a.toJSON(n)),abstractMethods:this.abstractMethods.map(a=>a.toJSON(n)),implements:this.implements.map(a=>a.toJSON(n)),extends:this.extends.map(a=>a.toJSON(n)),parent:this.parent.toReference()})}toJSONClone(n=Oe){var l,p,t,m,E;let a;return(l=n.seenEntityMaps)!=null&&l.has(this.id)?a=n.seenEntityMaps.get(this.id):(a=n.newId||hr(this,this.project,n.uuidStrategy),n.seenEntityMaps&&n.seenEntityMaps.set(this.id,a)),(p=n.seenEntities)!=null&&p.has(a)||(t=n.seenEntities)!=null&&t.has(this.id)?this.toReference({seenEntityMaps:n.seenEntityMaps}):((m=n.seenEntities)==null||m.add(a),(E=n.seenEntities)==null||E.add(this.id),{id:a,version:P.UUID.uuid(),createdAt:n.timestamp||N().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,type:this.type,name:this.name,description:this.description,x:this.x,y:this.y,static:this.static,abstract:this.abstract,properties:this.properties.map(b=>b.toJSONClone({...n,newId:null})),methods:this.methods.map(b=>b.toJSONClone({...n,newId:null})),abstractMethods:this.abstractMethods.map(b=>b.toJSONClone({...n,newId:null})),implements:this.implements.map(b=>b.type===f.BuiltInBaseEntity?b.toJSON():b.toJSONClone({...n,newId:null})),extends:this.extends.map(b=>b.type===f.BuiltInBaseEntity?b.toJSON():b.toJSONClone({...n,newId:null})),parent:this.parent.toReference({seenEntityMaps:n.seenEntityMaps})})}toReference(n=Oe){var l;let a=this.id;return(l=n.seenEntityMaps)!=null&&l.has(this.id)&&(a=n.seenEntityMaps.get(this.id)),{id:a+"--"+P.UUID.uuid()+"--ref",type:f.GenericReference,entityId:a,version:this.version,entityType:this.type}}toShallowJSON(n=Oe){var l;let a=this.id;return(l=n.seenEntityMaps)!=null&&l.has(this.id)&&(a=n.seenEntityMaps.get(this.id)),{id:a,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,name:this.name,description:this.description,type:this.type,x:this.x,y:this.y,static:this.static,abstract:this.abstract,properties:this.properties.map(p=>p.toReference(n)),methods:this.methods.map(p=>p.toReference(n)),abstractMethods:this.abstractMethods.map(p=>p.toReference(n)),implements:this.implements.map(p=>p.toReference(n)),extends:this.extends.map(p=>p.toReference(n)),parent:this.parent.toReference(n)}}toFlatJSON(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[this.toShallowJSON(),...this.properties.flatMap(l=>l.toFlatJSON(n)),...this.methods.flatMap(l=>l.toFlatJSON(n)),...this.abstractMethods.flatMap(l=>l.toFlatJSON(n)),...this.implements.flatMap(l=>l.toFlatJSON(n)),...this.extends.flatMap(l=>l.toFlatJSON(n)),...this.parent.toFlatJSON(n)])}toGenerationTarget(){const n=this.parent.type===f.Project?void 0:this.parent.id;return{id:this.id,name:this.name,description:this.description,type:this.type,static:this.static,abstract:this.abstract,extends:this.extends.map(a=>a.id),implements:this.implements.map(a=>a.id),parent:n}}toFlatGenerationTarget(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[this.toGenerationTarget(),...this.properties.flatMap(l=>l.toFlatGenerationTarget(n)),...this.methods.flatMap(l=>l.toFlatGenerationTarget(n)),...this.abstractMethods.flatMap(l=>l.toFlatGenerationTarget(n)),...this.implements.filter(l=>l.type===f.DefinitionEntity).flatMap(l=>l.toFlatGenerationTarget(n)),...this.implements.filter(l=>l.type===f.DefinitionEntity).flatMap(l=>l.toFlatGenerationTarget(n)),...this.parent.toFlatGenerationTarget(n)])}clearErrors(){return this.errors=[],this.properties.forEach(n=>n.clearErrors()),this.methods.forEach(n=>n.clearErrors()),this.abstractMethods.forEach(n=>n.clearErrors()),this}validate(){return this.errors=vj(this),{success:!0,error:null,data:null}}getErrors(){return[...this.errors,...this.properties.flatMap(a=>a.getErrors()),...this.methods.flatMap(a=>a.getErrors()),...this.abstractMethods.flatMap(a=>a.getErrors())]}getShallowErrors(){return this.errors}clone(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"clone-entity")),a=null,l=null,p=!0){var q,Z,Q;let t=yr(a,this);const m=this.toJSON(),E=l||P.UUID.uuid();m.properties=[],m.methods=[],m.abstractMethods=[];const b=E.split("-id"),_=b[b.length-1||0]||E;m.id=E,m.version=P.UUID.uuid(),m.createdAt=(n==null?void 0:n.timestamp)||N().toISOString(),m.author=(n==null?void 0:n.author)||"1",m.previousVersion=null,m.deleted=!1;const w=er(m,t);a&&w.setParent(a,null),p&&w.subscribe(),w.initChildren(n),n==null||n.add(w,G.Added);const V=(q=this.properties)==null?void 0:q.map(ie=>ie.clone(n,w,P.UUID.uuid(),p));w.properties=V;const B=(Z=this.methods)==null?void 0:Z.map((ie,H)=>ie.clone(n,w,_+"-method-"+H+"-id",p));w.methods=B;const K=(Q=this.abstractMethods)==null?void 0:Q.map((ie,H)=>ie.clone(n,w,_+"-abstract-method-"+H+"-id",p));return w.abstractMethods=K,n==null||n.attemptAutoclose("clone-entity",this.id),w}getFunctionDeclaration(n){return this.methods.find(a=>a.id===n)}implement(n,a=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"implement-definition-entity")),l){const p=hy(this,n,a,l);return a==null||a.attemptAutoclose("implement-definition-entity",this.id),p}getAllInteractiveMethods(){const n=this.implements.filter(l=>l.type===f.DefinitionEntity||l.type===f.BuiltInBaseEntity&&l.interactive);return I([...this.methods,...this.extends.flatMap(l=>l.getAllInteractiveMethods()),...n.flatMap(l=>l.getAllInteractiveMethods())])}inferFromInputs(n,a=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"infer-definition-entity-from-inputs"))){const l=[],p=[],t=[],m=[];if(this.parent.type!==f.DataType||!this.parent.inferred)return a==null||a.attemptAutoclose("infer-definition-entity-from-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};const E=[];n.forEach(w=>{E.find(B=>ce(B,this.project)===ce(w,this.project))||E.push(w)});const b=this.properties.filter(w=>!w.dataType);E.forEach(w=>{var Q,ie;const V=b.find(H=>ce(H,this.project)===ce(w,this.project));if(!V)return;const K=Mo(w.parent).getMasterInputWithValueWritterFromAllInstances(w),q=xs(K,a),Z=q==null?void 0:q.clone(a,V,P.UUID.uuid(),!0);Z&&((Q=V.dataType)==null||Q.merge(Z,a),Z.id!==((ie=V.dataType)==null?void 0:ie.id)&&Z.remove({ignoreUpstream:!1},a),V.dataType&&(V.dataType.metaSync({inferred:!0,like:!0},a),V.setDataType(V.dataType,a),a==null||a.add(V,G.Affected))),w.setDeclaration(V),a==null||a.add(w,G.Updated)});const _=[];return E.forEach(w=>{if(!w.declaration){_.push(w);return}}),_.length===0?(a==null||a.attemptAutoclose("infer-definition-entity-from-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this}):(_.forEach(w=>{var H,Ie,re,Te;const V=this.properties.find(Ve=>ce(Ve,this.project)===ce(w,this.project));if(V){if(w.setDeclaration(V),!V.getDataType(a)){const ue=Mo(w.parent).getMasterInputWithValueWritterFromAllInstances(w),ve=xs(ue),X=ve==null?void 0:ve.clone(a,V,P.UUID.uuid(),!0);X&&((H=V.dataType)==null||H.merge(X,a),X.id!==((Ie=V.dataType)==null?void 0:Ie.id)&&X.remove({ignoreUpstream:!1},a),V.dataType&&(V.dataType.metaSync({inferred:!0,like:!0},a),V.setDataType(V.dataType,a),a==null||a.add(V,G.Affected)))}return}const B={id:P.UUID.uuid(),type:f.Property,version:P.UUID.uuid(),createdAt:(a==null?void 0:a.timestamp)||N().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,name:ce(w,this.project),description:w.description,defaultValue:null,static:!0,abstract:!1,private:!1,hidden:!1,required:!1,constant:!0,index:w.index,implements:null,extends:null,dataType:null,parent:this.toReference()},K=z(B,this.project);K.setParent(this,a),K.initChildren(a),a==null||a.add(K,G.Added);const Z=Mo(w.parent).getMasterInputWithValueWritterFromAllInstances(w),Q=xs(Z),ie=Q==null?void 0:Q.clone(a,K,P.UUID.uuid(),!0);return ie&&((re=K.dataType)==null||re.merge(ie,a),ie.id!==((Te=K.dataType)==null?void 0:Te.id)&&ie.remove({ignoreUpstream:!1},a),K.dataType&&(K.dataType.metaSync({inferred:!0,like:!0},a),K.setDataType(K.dataType,a),a==null||a.add(K,G.Affected))),this.addProperty(K),w.setDeclaration(K),a==null||a.add(w,G.Updated),K}),a==null||a.attemptAutoclose("infer-definition-entity-from-inputs",this.id),{added:I(l),updated:I(p),removed:I(t),affected:I(m),self:this})}getRawDefaultValue(){const n={};return this.properties.forEach(a=>{var p;const l=Ra(a.name);n[l]=((p=a.getDefaultValue())==null?void 0:p.value)||null}),n}getActiveRawDefaultValue(){const n={};return this.properties.forEach(a=>{const l=Ra(a.name),p=this.project.requestActiveValue(a);n[l]=(p==null?void 0:p.value)||null}),n}};g(_t,"repository",{APICreate:async(n,...a)=>n,APIUpdate:async(n,...a)=>n,APIDelete:async(n,...a)=>n,APIClone:async(n,...a)=>{},APILoad:async(n,...a)=>null,APILoadVersion:async(n,a,...l)=>null}),g(_t,"type",f.DefinitionEntity),g(_t,"USER_MANAGED_PARENT_TYPES",[f.Project,f.DataType]),g(_t,"PARENT_TYPES",[..._t.USER_MANAGED_PARENT_TYPES]),g(_t,"MUTABLE_BASE_PROPERTIES",["name","description","static","abstract"]),g(_t,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),g(_t,"BASE_PROPERTIES",[..._t.MUTABLE_BASE_PROPERTIES,..._t.INMUTABLE_BASE_PROPERTIES]),g(_t,"MUTABLE_META_PROPERTIES",[..._t.MUTABLE_BASE_PROPERTIES,"x","y"]),g(_t,"INMUTABLE_META_PROPERTIES",[..._t.INMUTABLE_BASE_PROPERTIES]),g(_t,"META_PROPERTIES",[..._t.MUTABLE_META_PROPERTIES,..._t.INMUTABLE_META_PROPERTIES]),g(_t,"MUTABLE_UPSTREAM_PROPERTIES",["extends","implements"]),g(_t,"INMUTABLE_UPSTREAM_PROPERTIES",["parent"]),g(_t,"UPSTREAM_PROPERTIES",[..._t.MUTABLE_UPSTREAM_PROPERTIES,..._t.INMUTABLE_UPSTREAM_PROPERTIES]),g(_t,"MUTABLE_DOWNSTREAM_PROPERTIES",["properties","methods","abstractMethods"]),g(_t,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),g(_t,"DOWNSTREAM_PROPERTIES",[..._t.MUTABLE_DOWNSTREAM_PROPERTIES,..._t.INMUTABLE_DOWNSTREAM_PROPERTIES]),g(_t,"PROPERTIES",[..._t.META_PROPERTIES,..._t.UPSTREAM_PROPERTIES,..._t.DOWNSTREAM_PROPERTIES]);let ia=_t;function Dye(u){const d=Noe(),n=u.toJSON();d.safeParse(n).success;const l=[];return qt(u.errors,l)}const pp=class pp extends nr{constructor(n,a){super(n);g(this,"initialData");g(this,"id");g(this,"version");g(this,"name");g(this,"description",null);g(this,"type",f.BuiltInBaseEntity);g(this,"abstract",!1);g(this,"static");g(this,"properties",[]);g(this,"methods",[]);g(this,"abstractMethods",[]);g(this,"extends",[]);g(this,"interactive",!1);g(this,"errors",[]);g(this,"project");this.initialData=this.initialData||n,this.project=this.project||a,this.id=this.id||n.id,this.version=this.version||n.version,this.name=this.name||n.name,this.static=this.static||n.static,this.interactive=this.interactive||n.interactive,this.abstract=n.abstract,this.properties=this.initialData.properties.map(l=>{const p=z(l,this.project);return p.setParent(this,null),p.initChildren(null),p}),this.methods=this.initialData.methods.map(l=>{const p=z(l,this.project);return p.setParent(this,null),p.initChildren(null),p}),this.abstractMethods=this.initialData.abstractMethods.map(l=>{const p=z(l,this.project);return p.setParent(this,null),p.initChildren(null),p}),this.extends=this.initialData.extends.map(l=>z(l,this.project))}get allMethods(){return I([...this.ownDeclaredMethods,...this.allBaseMethodsFromOriginalParents])}get allProperties(){return I([...this.ownDeclaredProperties,...this.allBasePropertiesFromOriginalParents])}get allBaseMethodsFromOriginalParents(){return I([...this.extends.flatMap(n=>n.allMethods,[])])}get allBasePropertiesFromOriginalParents(){return I([...this.extends.flatMap(n=>n.allProperties,[])])}get allBasePropertiesFromExtendedAndImplementedEntities(){return I(this.extends.reduce((n,a)=>{const l=[...a.ownDeclaredProperties,...a.allBasePropertiesFromExtendedAndImplementedEntities].filter(p=>!p.abstract);return[...n,...l]},[]))}get extendedPropertiesFromOriginalParents(){return I(this.extends.reduce((n,a)=>{const l=[...a.ownDeclaredProperties,...a.extendedPropertiesFromOriginalParents].filter(p=>!p.abstract);return[...n,...l]},[]))}get implementedPropertiesFromOriginalParents(){return I([...this.extends.reduce((n,a)=>{const l=a.implementedPropertiesFromOriginalParents,p=[...a.ownDeclaredProperties].filter(t=>!!t.abstract&&!l.find(m=>m.name===t.name));return[...l,...p,...n]},[])])}get extendedProperties(){return this.properties.filter(n=>n.isExtendedProperty)}get ownDeclaredMethods(){return this.methods.filter(n=>!n.isExtendedMethod)}get ownDeclaredProperties(){return this.properties.filter(n=>!n.isExtendedProperty)}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}async APILoad(n=oe,...a){return await pp.repository.APILoad(this.id,...a),this}toFlat(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[this,...this.properties.flatMap(l=>l.toFlat(n)),...this.methods.flatMap(l=>l.toFlat(n)),...this.abstractMethods.flatMap(l=>l.toFlat(n)),...this.extends.flatMap(l=>l.toFlat(n))])}toFlatIds(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[this.id,...this.properties.flatMap(l=>l.toFlatIds(n)),...this.methods.flatMap(l=>l.toFlatIds(n)),...this.abstractMethods.flatMap(l=>l.toFlatIds(n)),...this.extends.flatMap(l=>l.toFlatIds(n))])}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,abstract:this.abstract,static:this.static,type:this.type,name:this.name}}toJSON(n=new Set){return n.has(this.id)?this.toReference():(n.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,interactive:this.interactive,properties:this.properties.map(a=>a.toJSON(n)),methods:this.methods.map(a=>a.toJSON(n)),abstractMethods:this.abstractMethods.map(a=>a.toJSON(n)),extends:this.extends.map(a=>a.toJSON(n))})}toReference(n=Oe){return{id:this.id+"--"+P.UUID.uuid()+"--ref",type:f.GenericReference,entityId:this.id,version:this.version,entityType:this.type}}toShallowJSON(n=Oe){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,properties:this.properties.map(a=>a.toReference()),methods:this.methods.map(a=>a.toReference()),abstractMethods:this.abstractMethods.map(a=>a.toReference()),extends:this.extends.map(a=>a.toReference())}}toFlatJSON(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[this.toShallowJSON(),...this.properties.flatMap(l=>l.toFlatJSON(n)),...this.methods.flatMap(l=>l.toFlatJSON(n)),...this.abstractMethods.flatMap(l=>l.toFlatJSON(n))])}toGenerationTarget(){return{id:this.id,type:this.type,name:this.name,description:this.description,static:this.static,abstract:this.abstract,interactive:this.interactive,extends:this.extends.map(n=>n.id)}}toFlatGenerationTarget(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[this.toGenerationTarget(),...this.properties.flatMap(l=>l.toFlatGenerationTarget(n)),...this.methods.flatMap(l=>l.toFlatGenerationTarget(n)),...this.abstractMethods.flatMap(l=>l.toFlatGenerationTarget(n))])}clearErrors(){return this.errors=[],this.properties.forEach(n=>n.clearErrors()),this.methods.forEach(n=>n.clearErrors()),this.abstractMethods.forEach(n=>n.clearErrors()),this}validate(){const n=Dye(this);return this.errors=n,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors,...this.properties.flatMap(a=>a.getErrors()),...this.methods.flatMap(a=>a.getErrors()),...this.abstractMethods.flatMap(a=>a.getErrors())]}getShallowErrors(){return this.errors}implement(n,a=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),null,!0,"implement-built-in-base-entity")),l){const p=hy(this,n,a,l);return a==null||a.attemptAutoclose("implement-built-in-base-entity",this.id),p}getAllInteractiveMethods(){const n=[];return this.interactive&&(n.push(...this.methods),this.extends.filter(l=>l.type===f.BuiltInBaseEntity&&l.interactive||l.type===f.PrimitiveEntity).forEach(l=>{l instanceof pp&&n.push(...l.getAllInteractiveMethods())})),I(n)}};g(pp,"repository",{APILoad:async(n,...a)=>null});let qs=pp;function gye(u){const d=Roe(),n=u.toJSON();d.safeParse(n).success;const l=[];return qt(u.errors,l)}const $y=class $y extends nr{constructor(n,a){super(n);g(this,"initialData");g(this,"id");g(this,"name");g(this,"description",null);g(this,"type",f.PrimitiveEntity);g(this,"static");g(this,"abstract");g(this,"properties",[]);g(this,"methods",[]);g(this,"abstractMethods",[]);g(this,"extends",[]);g(this,"errors",[]);g(this,"project");this.initialData=n,this.project=a,this.id=n.id,this.name=n.name,this.static=n.static,this.abstract=n.abstract,this.properties=this.initialData.properties.map(l=>{const p=z(l,this.project);return p.setParent(this,null),p.initChildren(null),p}),this.methods=this.initialData.methods.map(l=>{const p=z(l,this.project);return p.parent=this,p}),this.abstractMethods=this.initialData.abstractMethods.map(l=>{const p=z(l,this.project);return p.parent=this,p})}get allMethods(){return I([...this.ownDeclaredMethods,...this.allBaseMethodsFromOriginalParents])}get allProperties(){return I([...this.ownDeclaredProperties,...this.allBasePropertiesFromOriginalParents])}get allBaseMethodsFromOriginalParents(){return I([...this.extends.flatMap(n=>n.allMethods,[])])}get allBasePropertiesFromOriginalParents(){return I([...this.extends.flatMap(n=>n.allProperties,[])])}get allBasePropertiesFromExtendedAndImplementedEntities(){return I(this.extends.reduce((n,a)=>{const l=[...a.ownDeclaredProperties,...a.allBasePropertiesFromExtendedAndImplementedEntities].filter(p=>!p.abstract);return[...n,...l]},[]))}get extendedPropertiesFromOriginalParents(){return I(this.extends.reduce((n,a)=>{const l=[...a.ownDeclaredProperties,...a.extendedPropertiesFromOriginalParents].filter(p=>!p.abstract);return[...n,...l]},[]))}get implementedPropertiesFromOriginalParents(){return I([...this.extends.reduce((n,a)=>{const l=a.implementedPropertiesFromOriginalParents,p=[...a.ownDeclaredProperties].filter(t=>!!t.abstract&&!l.find(m=>m.name===t.name));return[...l,...p,...n]},[])])}get extendedProperties(){return this.properties.filter(n=>n.isExtendedProperty)}get ownDeclaredMethods(){return this.methods.filter(n=>!n.isExtendedMethod)}get ownDeclaredProperties(){return this.properties.filter(n=>!n.isExtendedProperty)}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}async APILoad(n=oe,...a){return await $y.repository.APILoad(this.id,...a),this}toFlat(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[this,...this.properties.flatMap(l=>l.toFlat(n)),...this.methods.flatMap(l=>l.toFlat(n)),...this.abstractMethods.flatMap(l=>l.toFlat(n))])}toFlatIds(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[this.id,...this.properties.flatMap(l=>l.toFlatIds(n)),...this.methods.flatMap(l=>l.toFlatIds(n)),...this.abstractMethods.flatMap(l=>l.toFlatIds(n))])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,description:this.description,static:this.static,abstract:this.abstract,type:this.type,name:this.name}}toJSON(n=new Set){return n.has(this.id)?this.toReference():(n.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,static:this.static,abstract:this.abstract,properties:this.properties.map(a=>a.toJSON(n)),methods:this.methods.map(a=>a.toJSON(n)),abstractMethods:this.abstractMethods.map(a=>a.toJSON(n)),extends:this.extends.map(a=>a.toJSON(n))})}toReference(n=Oe){return{id:this.id+"--"+P.UUID.uuid()+"--ref",type:f.GenericReference,entityId:this.id,version:this.version,entityType:this.type}}toShallowJSON(n=Oe){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,abstract:this.abstract,static:this.static,properties:this.properties.map(a=>a.toReference()),methods:this.methods.map(a=>a.toReference()),abstractMethods:this.abstractMethods.map(a=>a.toReference()),extends:this.extends.map(a=>a.toReference())}}toFlatJSON(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[this.toShallowJSON(),...this.properties.flatMap(l=>l.toFlatJSON(n)),...this.methods.flatMap(l=>l.toFlatJSON(n)),...this.abstractMethods.flatMap(l=>l.toFlatJSON(n))])}toGenerationTarget(){return{id:this.id,type:this.type,name:this.name,description:this.description,static:this.static,abstract:this.abstract,extends:this.extends.map(n=>n.id)}}toFlatGenerationTarget(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[this.toGenerationTarget(),...this.properties.flatMap(l=>l.toFlatGenerationTarget(n)),...this.methods.flatMap(l=>l.toFlatGenerationTarget(n)),...this.abstractMethods.flatMap(l=>l.toFlatGenerationTarget(n))])}clearErrors(){return this.errors=[],this.properties.forEach(n=>n.clearErrors()),this.methods.forEach(n=>n.clearErrors()),this.abstractMethods.forEach(n=>n.clearErrors()),this}validate(){const n=gye(this);return this.errors=n,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors,...this.properties.flatMap(a=>a.getErrors()),...this.methods.flatMap(a=>a.getErrors()),...this.abstractMethods.flatMap(a=>a.getErrors())]}getShallowErrors(){return this.errors}getAllInteractiveMethods(){const n=[];return n.push(...this.methods),this.extends.filter(l=>l.type===f.BuiltInBaseEntity&&l.interactive||l.type===f.PrimitiveEntity).forEach(l=>{l instanceof qs&&n.push(...l.getAllInteractiveMethods())}),I(n)}};g($y,"repository",{APILoad:async(n,...a)=>null});let Ri=$y;function er(u,d){if(!u)throw new Error("Entity is null");const n=d.get(u.id);switch(u.type){case f.LiteralValue:return n||new Fs(u,d);case f.DefinitionEntity:return n||new ia(u,d);case f.PrimitiveEntity:return n||new Ri(u,d);case f.FunctionDeclaration:return n||new _a(u,d);case f.GlobalEvent:return n||new $a(u,d);case f.DataType:return n||new ts(u,d);case f.Property:return n||new Xn(u,d);case f.FunctionCall:return n||new Fa(u,d);case f.Condition:return n||new Ca(u,d);case f.Operation:return n||new Da(u,d);case f.VariableDeclaration:return n||new Va(u,d);case f.VariableInstance:return n||new Pa(u,d);case f.OutputMap:return n||new Ks(u,d);case f.ReturnDeclaration:return n||new wi(u,d);case f.ArgumentDeclaration:return n||new ea(u,d);case f.InputMap:return n||new Es(u,d);case f.Project:return n||new P(u);case f.InstalledProject:return n||new La(u,d);case f.ActionDescriptor:return n||new Lt(u,d);case f.ReturnStatement:return n||new ga(u,d);case f.Loop:return n||new Oa(u,d);case f.Search:return n||new Na(u,d);case f.ValueDescriptor:return n||new ks(u,d);case f.BuiltInBaseEntity:return n||new qs(u,d);case f.InternalCall:return n||new Ma(u,d);case f.ContinueStatement:return n||new Qr(u,d);case f.BreakStatement:return n||new Ba(u,d);case f.GenericReference:return d.get(u.entityId);default:throw new Error("Invalid entity type: "+u.type)}}function z(u,d){if(!u)throw new Error("Entity is null");const n=er(u,d);return n.subscribe(),n}function $ye(u,d){if(!u)throw new Error("Entity is null");switch(u.type){case f.LiteralValue:return Fs.fromGenerationTarget(u,d);case f.DefinitionEntity:return ia.fromGenerationTarget(u,d);case f.FunctionDeclaration:return _a.fromGenerationTarget(u,d);case f.GlobalEvent:return $a.fromGenerationTarget(u,d);case f.DataType:return ts.fromGenerationTarget(u,d);case f.Property:return Xn.fromGenerationTarget(u,d);case f.FunctionCall:return Fa.fromGenerationTarget(u,d);case f.Condition:return Ca.fromGenerationTarget(u,d);case f.Operation:return Da.fromGenerationTarget(u,d);case f.VariableDeclaration:return Va.fromGenerationTarget(u,d);case f.VariableInstance:return Pa.fromGenerationTarget(u,d);case f.OutputMap:return Ks.fromGenerationTarget(u,d);case f.ReturnDeclaration:return wi.fromGenerationTarget(u,d);case f.ArgumentDeclaration:return ea.fromGenerationTarget(u,d);case f.InputMap:return Es.fromGenerationTarget(u,d);case f.InstalledProject:return La.fromGenerationTarget(u,d);case f.ReturnStatement:return ga.fromGenerationTarget(u,d);case f.Loop:return Oa.fromGenerationTarget(u,d);case f.Search:return Na.fromGenerationTarget(u,d);case f.ActionDescriptor:return Lt.fromGenerationTarget(u,d);case f.ValueDescriptor:return ks.fromGenerationTarget(u,d);case f.InternalCall:return Ma.fromGenerationTarget(u,d);case f.ContinueStatement:return Qr.fromGenerationTarget(u,d);case f.BreakStatement:return Ba.fromGenerationTarget(u,d);default:throw new Error("Invalid entity type: "+u.type)}}const Oe={seenEntityMaps:new Map,seenEntities:new Set,timestamp:N().toISOString()};class bj{constructor(){g(this,"initialData")}}const oe={cascade:!1},Aj={APILoad:async(u,...d)=>null},Oye={APICreate:async(u,...d)=>u,APIUpdate:async(u,...d)=>u,APIDelete:async(u,...d)=>u,APIClone:async(u,...d)=>{},APILoadVersion:async(u,d,...n)=>null,...Aj};class Cye{}class Pye extends bj{}class Vye{}class Nye{}class Lye{}class Nb{}class Mye extends Nb{}class Bye extends Nb{}class Uye{}class dp{static initReadsValue(d){if(d.initialData.readsValue&&d.initialData.readsValue.type!==f.GenericReference)d.readsValue=z(d.initialData.readsValue,d.project);else if(d.initialData.readsValue&&d.initialData.readsValue.type===f.GenericReference){const n=ss(d.initialData.readsValue,d.project);n&&(d.readsValue=n)}if(d.readsValue){if(lr.includes(d.readsValue.type)){let n=d.parent;br.includes(n.type)||(n=n.parent);const a=d.type===f.InputMap&&d.parent.type===f.Loop;a&&(n=d.parent.parent),d.readsValue.setParent(n,null),d.readsValue.initChildren(null),n&&n.type!==f.Project&&!a&&n.detachedChildren.includes(d)?n.replaceDetachedChild(d,d.readsValue):n&&n.type!==f.Project&&!a&&n.subscribeDetachedChild(d.readsValue)}d.readsValue.addValueReader(d,null)}return d.readsValue}}class up{static initWritesValues(d,n){const a=d.initialData.writesValues.reduce((p,t)=>{if(t.type===f.GenericReference||d.writesValues.some(E=>E.id===t.id))return p;const m=z(t,d.project);return m.setValueWriter(d,null),lr.includes(m.type)&&(m.setParent(n,null),m.initChildren(null)),[...p,m]},[]),l=[...d.writesValues];return d.writesValues=I([...l,...a]),d.writesValues}}class jye{}class xye{constructor(d){g(this,"eventName");g(this,"callbacks",[]);this.eventName=d}on(d){if(typeof d!="function")throw new Error("Event callback must be a function");this.callbacks.includes(d)||this.callbacks.push(d)}off(d){if(typeof d!="function")throw new Error("Event callback must be a function");this.callbacks=this.callbacks.filter(n=>n!==d)}destroy(){this.callbacks=[]}}class Lb{constructor(){g(this,"subscribedEvents",{});g(this,"on",this._on);g(this,"emit",this._emit);g(this,"off",this._off);g(this,"destroy",this._destroy)}getEvent(d){return this.subscribedEvents[d]||(this.subscribedEvents[d]=new xye(d)),this.subscribedEvents[d]}_on(d,n){this.getEvent(d).on(n)}_emit(d,...n){const a=this.getEvent(d);a&&a.callbacks.forEach(l=>{l.apply(null,n)})}_off(d,n){const a=this.getEvent(d);a&&(n?a.off(n):(a.destroy(),delete this.subscribedEvents[d]))}_destroy(){Object.keys(this.subscribedEvents).forEach(d=>{this._off(d)}),this.subscribedEvents={}}}var ar=(u=>(u.PROJECT_INITIALIZED="project-initialized",u.CHANGE_SET_CLOSED="change-set-closed",u.EXPLICIT_DEFINITION_ENTITY_ADDED="explicit-definition-entity-added",u.EXPLICIT_DEFINITION_ENTITY_REMOVED="explicit-definition-entity-removed",u.EXPLICIT_DEFINITION_ENTITY_UPDATED="explicit-definition-entity-updated",u.PERSISTED_DEFINITION_ENTITY_ADDED="persisted-definition-entity-added",u.PERSISTED_DEFINITION_ENTITY_REMOVED="persisted-definition-entity-removed",u.PERSISTED_DEFINITION_ENTITY_UPDATED="persisted-definition-entity-updated",u.RELATIONAL_DATABASE_DEFINITION_ENTITY_ADDED="relational-database-definition-entity-added",u.RELATIONAL_DATABASE_DEFINITION_ENTITY_REMOVED="relational-database-definition-entity-removed",u.RELATIONAL_DATABASE_DEFINITION_ENTITY_UPDATED="relational-database-definition-entity-updated",u))(ar||{});function Fye(u,d){d.forEach(n=>{Object.getOwnPropertyNames(n.prototype).forEach(a=>{a!=="constructor"&&Object.defineProperty(u.prototype,a,Object.getOwnPropertyDescriptor(n.prototype,a))})})}class Ij extends nr{constructor(...d){super(...d),Object.assign(this,new Lb)}}Fye(Ij,[Lb]);const Fe=class Fe extends Ij{constructor(n){super(n);g(this,"initialData");g(this,"id");g(this,"type",f.Project);g(this,"name",null);g(this,"description",null);g(this,"x");g(this,"y");g(this,"entities",[]);g(this,"projects",[]);g(this,"functions",[]);g(this,"events",[]);g(this,"variableDeclarations",[]);g(this,"variableInstances",[]);g(this,"conditions",[]);g(this,"operations",[]);g(this,"functionCalls",[]);g(this,"loops",[]);g(this,"searches",[]);g(this,"primitives",[]);g(this,"builtInBaseEntities",[]);g(this,"operationDeclarations",[]);g(this,"globalEventActionDescriptors",[]);g(this,"loopDeclarations",[]);g(this,"loopDeclarationsBodies",[]);g(this,"conditionDeclarations",[]);g(this,"valueDescriptors",[]);g(this,"dataTypes",[]);g(this,"project");g(this,"instances",{});g(this,"builtInInstances",{});g(this,"deletedInstances",{});g(this,"errors",[]);g(this,"references",[]);g(this,"history",[]);g(this,"undoableStackValueIndex",-1);g(this,"detachedDependents",{});g(this,"knownVersions",null);g(this,"activeVersion",!1);g(this,"initialized",!1);g(this,"startedInitialization",!1);g(this,"onCloseChangeSetCallback",null);g(this,"onAddChangeSetCallback",null);g(this,"onDiscardChangeSetCallback",null);g(this,"onRequestActiveValueCallback",null);this.initialData=n,this.id=n.id,this.name=n.name,this.description=n.description,this.x=0,this.y=0,this.instances[this.id]=this;try{(!Fe.UUID||Fe.UUID.isBackup)&&(Fe.UUID=Qf==null?void 0:Qf()),Fe.UUID||(Fe.UUID={isBackup:!0,uuid:()=>Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15),fromUUID:a=>a})}catch(a){console.error("Error initializing UUID module",a),Fe.UUID={isBackup:!0,uuid:()=>Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15),fromUUID:l=>l}}}static injectUUIDModule(n){Fe.UUID=n}static new(n=null){return{id:Fe.UUID.uuid(),version:Fe.UUID.uuid(),createdAt:(n==null?void 0:n.timestamp)||N().toISOString(),author:(n==null?void 0:n.author)||Fe.sessionAuthor,previousVersion:null,deleted:!1,type:f.Project,name:"",description:"",entities:[],functions:[],events:[],projects:[],variableDeclarations:[],variableInstances:[],conditions:[],operations:[],functionCalls:[],loops:[],searches:[]}}static validateGenerationTarget(n,a){let l=JSON.parse(JSON.stringify(n));const p=[];return p.push(...ur(l)),{errors:p,modifiedData:l}}async closePendingChangeSets(){const n=this.history.find(a=>a.dirty&&!a.open);n&&await this.closeChangeSet(n)}onRequestActiveValue(n){this.onRequestActiveValueCallback=n}async onCloseChangeSet(n){this.onCloseChangeSetCallback=n,await this.closePendingChangeSets()}onAddChangeSet(n){this.onAddChangeSetCallback=n}onDiscardChangeSet(n){this.onDiscardChangeSetCallback=n}async closeChangeSet(n){const a=this.history.findIndex(t=>t.id===n.id),l=this.history.slice(0,a),p=l[l.length-1];if(!(p!=null&&p.dirty)&&this.onCloseChangeSetCallback){(await this.onCloseChangeSetCallback(n)).success&&(n.dirty=!1,this.emit("change-set-closed",n),this.closePendingChangeSets());return}}toLatestChangeSet(n,a,l,p=!1,t="here-this"){if(!this.history.length)return new F(this,n,a,l,p,t);const m=this.history[this.history.length-1];return m.open?m:this.addChangeSet(new F(this,n,a,l,p,t))}addChangeSet(n){var p,t;if(!this.history.length)return this.undoableStackValueIndex=XL(this.undoableStackValueIndex,this.history,n),(p=this.onAddChangeSetCallback)==null||p.call(this,n,this.undoableStackValueIndex),n;const a=this.history.find(m=>m.id===(n==null?void 0:n.id));if(a)return a;const l=this.history.find(m=>m.open);if(l)throw console.warn("Previous still open: ",l),console.warn("New change set: ",n),new Error(`There is already an open change-set with id '${l.id}'.`);return this.undoableStackValueIndex=XL(this.undoableStackValueIndex,this.history,n),(t=this.onAddChangeSetCallback)==null||t.call(this,n,this.undoableStackValueIndex),n}discardChangeSet(n){var l;const a=this.history.findIndex(p=>p.id===(n==null?void 0:n.id));return a!==-1&&((l=this.onDiscardChangeSetCallback)==null||l.call(this,n),this.history.splice(a,1)),this}async inject(...n){return await Promise.all(n.map(a=>new Promise(async l=>{await a.init(this),l(null)}))),this}validateGeneratedUpdate(n){return{errors:[],modifiedData:n}}subscribeDependents(n){return n.forEach(a=>{this.detachedDependents[a.entity.id]||(this.detachedDependents[a.entity.id]=a)}),this}unsubscribeDependents(n){return n.forEach(a=>{this.detachedDependents[a.entity.id]&&delete this.detachedDependents[a.entity.id]}),this}syncDependents(n=this.project.addChangeSet(new F(this.project,Fe.sessionAuthor,N().toISOString(),this,!0,"sync-dependents"))){const a=[],l=[],p=[],t=[];return Object.values(this.detachedDependents).forEach(m=>{const E=m.entity.afterAllChildrenInitialized(n);a.push(...E.updated),l.push(...E.added),p.push(...E.removed),t.push(...E.affected)}),n==null||n.attemptAutoclose("sync-dependents",this.id),{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this}}onDetachedDependencyRemoved(n,a,l){const p=[],t=[],m=[],E=[];return{updated:I(p),added:I(t),removed:I(m),affected:I(E),self:this}}onDetachedDependencyRestored(n,a,l){const p=[],t=[],m=[],E=[];return{updated:I(p),added:I(t),removed:I(m),affected:I(E),self:this}}unsubscribeFromDependencies(){return this}subscribeToDependencies(){return this}increaseVersion(n){if(n&&!N(n).isValid())throw new Error(`The shared timestamp '${n}' is not a valid ISO 8601 date string.`);return n&&N(n).isSame(N(this.createdAt))?this:(this.previousVersion=this.version,this.version=Fe.UUID.uuid(),this.createdAt=N(n).toISOString()||N().toISOString(),this)}captureVersion(){var a;const n=((a=this.knownVersions)==null?void 0:a.get(this.version))||new Fe(this);return n.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,n):new Map([[this.version,n]]),n.entities=[...this.entities],n.projects=[...this.projects],n.functions=[...this.functions],n.events=[...this.events],n.variableDeclarations=[...this.variableDeclarations],n.variableInstances=[...this.variableInstances],n.conditions=[...this.conditions],n.operations=[...this.operations],n.functionCalls=[...this.functionCalls],n.loops=[...this.loops],n.searches=[...this.searches],this}recursiveCaptureUpstreamVersions(n){const a=[],l=[],p=[],t=[];return{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this}}async restoreVersion(n){var E;const a=[],l=[],p=[],t=[];if(this.version===n)return{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this};if(!this.knownVersions){const b=new Map;for(const[_,w]of this.knownVersions||new Map){if(b.set(_,w),w.activeVersion=!1,w.knownVersions)for(const[V,B]of w.knownVersions)b.set(V,B);w.knownVersions=null}}let m=(E=this.knownVersions)==null?void 0:E.get(n);if(!m){const b=await this.APILoadVersion({},n);if(!b)throw new Error(`Version with id '${n}' for entity with id '${this.id}' not found.`);m=new Fe(b)}return this.metaSync(m.toShallowJSON(),null),this.previousVersion=m.previousVersion,this.version=m.version,this.createdAt=m.createdAt,this.author=m.author,this.deleted=m.deleted,this.entities=m.entities,this.projects=m.projects,this.functions=m.functions,this.events=m.events,this.variableDeclarations=m.variableDeclarations,this.variableInstances=m.variableInstances,this.conditions=m.conditions,this.operations=m.operations,this.functionCalls=m.functionCalls,this.loops=m.loops,this.searches=m.searches,{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this}}updateWithShallowTransfer(n,a=this.project.addChangeSet(new F(this.project,Fe.sessionAuthor,N().toISOString(),this,!0,"update-with-shallow-transfer"))){return this.metaSync(n,a),this.version=n.version,this.createdAt=n.createdAt,this.author=n.author,this.deleted=n.deleted,this.previousVersion=n.previousVersion,this.captureVersion(),this.subscribeToDependencies(),a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),this}hydrateAncestors(){const n=[],a=[],l=[],p=[];return{updated:I(n),added:I(a),removed:I(l),affected:I(p),self:this}}afterAllChildrenInitialized(n=null){const a=[],l=[],p=[],t=[];return this.initialized||(this.initialized=!0,this.emit("project-initialized",this,n)),this.validate(),this.captureVersion(),{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this}}addSelfToProject(n){const a=[],l=[],p=[],t=[];return this.subscribe(),this.subscribeToDependencies(),{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this}}get instancesList(){return Object.values(this.instances)}isOperationDeclaration(n){return this.operationDeclarations.includes(n)}isGlobalEventActionDescriptor(n){return this.globalEventActionDescriptors.includes(n)}isLoopDeclaration(n){return this.loopDeclarations.includes(n)}isConditionDeclaration(n){return this.conditionDeclarations.includes(n)}initChildren(n=this.project.addChangeSet(new F(this.project,Fe.sessionAuthor,N().toISOString(),this,!0,"init-children"))){return this.initialized||this.startedInitialization?this:(this.startedInitialization=!0,this.entities=this.initialData.entities.map(a=>{const l=z(a,this);return l.setParent(this,null),l.initChildren(n),l}),this.projects=this.initialData.projects.map(a=>{const l=z(a,this);return l.setParent(this,null),l.initChildren(n),l}),this.variableDeclarations=this.initialData.variableDeclarations.map(a=>{const l=z(a,this);return l.setParent(this,null),l.initChildren(n),l}),this.variableInstances=this.initialData.variableInstances.map(a=>{const l=z(a,this);return l.setParent(this,null),l.initChildren(n),l}),this.conditions=this.initialData.conditions.map(a=>{const l=z(a,this);return l.setParent(this,null),l.initChildren(n),l}),this.operations=this.initialData.operations.map(a=>{const l=z(a,this);return l.setParent(this,null),l.initChildren(n),l}),this.functions=this.initialData.functions.map(a=>{const l=z(a,this);return l.setParent(this,null),l.initChildren(n),l}),this.events=this.initialData.events.map(a=>{const l=z(a,this);return l.setParent(this,null),l.initChildren(n),l}),this.functionCalls=this.initialData.functionCalls.map(a=>{const l=z(a,this);return l.setParent(this,null),l.initChildren(n),l}),this.loops=this.initialData.loops.map(a=>{const l=z(a,this);return l.setParent(this,null),l.initChildren(n),l}),this.searches=this.initialData.searches.map(a=>{const l=z(a,this);return l.setParent(this,null),l.initChildren(n),l}),this.attachOrphanReferences(),this.subscribeToDependencies(),this.afterAllChildrenInitialized(n),n==null||n.attemptAutoclose("init-children",this.id),this)}subscribeInstance(n){return(!this.instances[n.id]||this.instances[n.id]!==n)&&(this.instances[n.id]=n),this}subscribeDeletedInstance(n){return(!this.deletedInstances[n.id]||this.deletedInstances[n.id]!==n)&&(this.deletedInstances[n.id]=n),this}subscribeBuiltInInstance(n){return(!this.builtInInstances[n.id]||this.builtInInstances[n.id]!==n)&&(this.builtInInstances[n.id]=n),this}subscribe(){return this}unsubscribe(){return this}unsubscribeInstance(n){return delete this.instances[n.id],this}unsubscribeDeletedInstance(n){return delete this.deletedInstances[n.id],this}findSubscribedBuiltInInstance(n){return this.builtInInstances[n.id]||null}get(n){return this.instances[n]||this.builtInInstances[n]||null}getDeleted(n){return this.deletedInstances[n]||null}getManaged(n){return this.getBuiltIn(n)?null:this.instances[n]||null}getBuiltIn(n){return this.builtInInstances[n]||null}findSubscribedInstanceFromReference(n){return this.instances[n.entityId]||null}findSubscribedBuiltInInstanceFromReference(n){return this.builtInInstances[n.entityId]||null}metaSync(n,a=this.project.addChangeSet(new F(this.project,Fe.sessionAuthor,N().toISOString(),this,!0,"meta-sync"))){const l=cr(this,n),p=this.toMeta();return this.name=n.name!==void 0?n.name:p.name,this.description=n.description!==void 0?n.description:p.description,this.x=n.x||p.x,this.y=n.y||p.y,super.metaSync(n),n.deleted===!0&&!p.deleted?a==null||a.add(this,G.Removed):n.deleted===!1&&p.deleted?a==null||a.add(this,G.Added):l&&(a==null||a.add(this,G.Updated)),a==null||a.attemptAutoclose("meta-sync",this.id),this}async APILoad(n=oe,...a){return await Fe.repository.APILoad(this.id,...a),this}async APICreate(n=oe,...a){return await Fe.repository.APICreate(this.toShallowJSON(),...a),this}async APIUpdate(n=oe,...a){return await Fe.repository.APIUpdate(this.toShallowJSON(),...a),this}async APIDelete(n=oe,...a){return await Fe.repository.APIDelete(this.toShallowJSON(),...a),this}async APIClone(n=oe,...a){return await Fe.repository.APIClone(this.id,...a),this}async APILoadVersion(n=oe,a,...l){return await Fe.repository.APILoadVersion(this.id,a,...l)}remove({ignoreUpstream:n}={ignoreUpstream:!1},a=this.project.addChangeSet(new F(this.project,Fe.sessionAuthor,N().toISOString(),this,!0,"remove-entity"))){return{added:[],updated:[],removed:[],affected:[],self:this}}restore({}={},n=this.project.addChangeSet(new F(this.project,Fe.sessionAuthor,N().toISOString(),this,!0,"restore-entity"))){return{added:[],updated:[],removed:[],affected:[],self:this}}getAllBuiltInIds(){const n=new Set;return[...this.primitives.flatMap(a=>a.toFlatIds(n)),...this.builtInBaseEntities.flatMap(a=>a.toFlatIds(n)),...this.operationDeclarations.flatMap(a=>a.toFlatIds(n)),...this.globalEventActionDescriptors.flatMap(a=>a.toFlatIds(n)),...this.loopDeclarations.flatMap(a=>a.toFlatIds(n)),...this.conditionDeclarations.flatMap(a=>a.toFlatIds(n)),...this.valueDescriptors.flatMap(a=>a.toFlatIds(n)),...this.dataTypes.flatMap(a=>a.toFlatIds(n))]}getAllBuiltIn(){const n=new Set;return[...this.primitives.flatMap(a=>a.toFlat(n)),...this.builtInBaseEntities.flatMap(a=>a.toFlat(n)),...this.operationDeclarations.flatMap(a=>a.toFlat(n)),...this.globalEventActionDescriptors.flatMap(a=>a.toFlat(n)),...this.loopDeclarations.flatMap(a=>a.toFlat(n)),...this.conditionDeclarations.flatMap(a=>a.toFlat(n)),...this.valueDescriptors.flatMap(a=>a.toFlat(n)),...this.dataTypes.flatMap(a=>a.toFlat(n))]}toFlat(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[this,...this.entities.flatMap(l=>l.toFlat(n)),...this.functions.flatMap(l=>l.toFlat(n)),...this.events.flatMap(l=>l.toFlat(n)),...this.projects.flatMap(l=>l.toFlat(n)),...this.variableDeclarations.flatMap(l=>l.toFlat(n)),...this.variableInstances.flatMap(l=>l.toFlat(n)),...this.conditions.flatMap(l=>l.toFlat(n)),...this.operations.flatMap(l=>l.toFlat(n)),...this.functionCalls.flatMap(l=>l.toFlat(n)),...this.loops.flatMap(l=>l.toFlat(n)),...this.searches.flatMap(l=>l.toFlat(n))])}toFlatIds(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[this.id,...this.entities.flatMap(l=>l.toFlatIds(n)),...this.functions.flatMap(l=>l.toFlatIds(n)),...this.events.flatMap(l=>l.toFlatIds(n)),...this.projects.flatMap(l=>l.toFlatIds(n)),...this.variableDeclarations.flatMap(l=>l.toFlatIds(n)),...this.variableInstances.flatMap(l=>l.toFlatIds(n)),...this.conditions.flatMap(l=>l.toFlatIds(n)),...this.operations.flatMap(l=>l.toFlatIds(n)),...this.functionCalls.flatMap(l=>l.toFlatIds(n)),...this.loops.flatMap(l=>l.toFlatIds(n)),...this.searches.flatMap(l=>l.toFlatIds(n))])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,description:this.description,type:this.type,name:this.name}}toJSON(n=new Set){return n.has(this.id)?this.toReference():(n.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,entities:this.entities.map(a=>a.toJSON(n)),variableDeclarations:this.variableDeclarations.map(a=>a.toJSON(n)),variableInstances:this.variableInstances.map(a=>a.toJSON(n)),conditions:this.conditions.map(a=>a.toJSON(n)),operations:this.operations.map(a=>a.toJSON(n)),loops:this.loops.map(a=>a.toJSON(n)),searches:this.searches.map(a=>a.toJSON(n)),functions:this.functions.map(a=>a.toJSON(n)),events:this.events.map(a=>a.toJSON(n)),projects:this.projects.map(a=>a.toJSON(n)),functionCalls:this.functionCalls.map(a=>a.toJSON(n))})}toJSONClone(n={uuidStrategy:"uuid"}){const a=new Map,l=new Set,p=this.getAllBuiltInIds();return Object.keys(this.instances).forEach(t=>{if(p.includes(t)){a.set(t,t);return}a.set(t,Fe.UUID.uuid())}),l.add(this.id),{id:a.get(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,entities:this.entities.map(t=>t.toJSONClone({...n,seenEntityMaps:a,seenEntities:l,newId:null})),projects:this.projects.map(t=>t.toJSONClone({...n,seenEntityMaps:a,seenEntities:l,newId:null})),variableDeclarations:this.variableDeclarations.map(t=>t.toJSONClone({...n,seenEntityMaps:a,seenEntities:l,newId:null})),variableInstances:this.variableInstances.map(t=>t.toJSONClone({...n,seenEntityMaps:a,seenEntities:l,newId:null})),conditions:this.conditions.map(t=>t.toJSONClone({...n,seenEntityMaps:a,seenEntities:l,newId:null})),operations:this.operations.map(t=>t.toJSONClone({...n,seenEntityMaps:a,seenEntities:l,newId:null})),functions:this.functions.map(t=>t.toJSONClone({...n,seenEntityMaps:a,seenEntities:l,newId:null})),events:this.events.map(t=>t.toJSONClone({...n,seenEntityMaps:a,seenEntities:l,newId:null})),functionCalls:this.functionCalls.map(t=>t.toJSONClone({...n,seenEntityMaps:a,seenEntities:l,newId:null})),loops:this.loops.map(t=>t.toJSONClone({...n,seenEntityMaps:a,seenEntities:l,newId:null})),searches:this.searches.map(t=>t.toJSONClone({...n,seenEntityMaps:a,seenEntities:l,newId:null}))}}toReference(n=Oe){var l;let a=this.id;return(l=n.seenEntityMaps)!=null&&l.has(this.id)&&(a=n.seenEntityMaps.get(this.id)),{id:a+"--"+Fe.UUID.uuid()+"--ref",type:f.GenericReference,entityId:a,version:this.version,entityType:this.type}}toShallowJSON(n=Oe){var l;let a=this.id;return(l=n.seenEntityMaps)!=null&&l.has(this.id)&&(a=n.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,description:this.description,entities:this.entities.map(p=>p.toReference(n)),functions:this.functions.map(p=>p.toReference(n)),events:this.events.map(p=>p.toReference(n)),projects:this.projects.map(p=>p.toReference(n)),variableDeclarations:this.variableDeclarations.map(p=>p.toReference(n)),variableInstances:this.variableInstances.map(p=>p.toReference(n)),conditions:this.conditions.map(p=>p.toReference(n)),operations:this.operations.map(p=>p.toReference(n)),functionCalls:this.functionCalls.map(p=>p.toReference(n)),loops:this.loops.map(p=>p.toReference(n)),searches:this.searches.map(p=>p.toReference(n))}}toFlatJSON(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[this.toShallowJSON(),...this.entities.flatMap(l=>l.toFlatJSON(n)),...this.functions.flatMap(l=>l.toFlatJSON(n)),...this.events.flatMap(l=>l.toFlatJSON(n)),...this.projects.flatMap(l=>l.toFlatJSON(n)),...this.variableDeclarations.flatMap(l=>l.toFlatJSON(n)),...this.variableInstances.flatMap(l=>l.toFlatJSON(n)),...this.conditions.flatMap(l=>l.toFlatJSON(n)),...this.operations.flatMap(l=>l.toFlatJSON(n)),...this.functionCalls.flatMap(l=>l.toFlatJSON(n)),...this.loops.flatMap(l=>l.toFlatJSON(n)),...this.searches.flatMap(l=>l.toFlatJSON(n))])}toGenerationTarget(){return{id:this.id,type:this.type,name:this.name,description:this.description}}toFlatGenerationTarget(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[...this.entities.flatMap(l=>l.toFlatGenerationTarget(n)),...this.functions.flatMap(l=>l.toFlatGenerationTarget(n)),...this.events.flatMap(l=>l.toFlatGenerationTarget(n)),...this.projects.flatMap(l=>l.toFlatGenerationTarget(n)),...this.variableDeclarations.flatMap(l=>l.toFlatGenerationTarget(n)),...this.variableInstances.flatMap(l=>l.toFlatGenerationTarget(n)),...this.conditions.flatMap(l=>l.toFlatGenerationTarget(n)),...this.operations.flatMap(l=>l.toFlatGenerationTarget(n)),...this.functionCalls.flatMap(l=>l.toFlatGenerationTarget(n)),...this.loops.flatMap(l=>l.toFlatGenerationTarget(n)),...this.searches.flatMap(l=>l.toFlatGenerationTarget(n))])}clearErrors(){return this.errors=[],this.entities.forEach(n=>n.clearErrors()),this.projects.forEach(n=>n.clearErrors()),this.functions.forEach(n=>n.clearErrors()),this.events.forEach(n=>n.clearErrors()),this.variableDeclarations.forEach(n=>n.clearErrors()),this.variableInstances.forEach(n=>n.clearErrors()),this.conditions.forEach(n=>n.clearErrors()),this.operations.forEach(n=>n.clearErrors()),this.functionCalls.forEach(n=>n.clearErrors()),this.loops.forEach(n=>n.clearErrors()),this.searches.forEach(n=>n.clearErrors()),this}validate(){const n=Yde(),a=this.toJSON();return n.safeParse(a),this.validateChildren(),{success:!0,error:null,data:a}}validateChildren(){this.entities.forEach(n=>n.validate()),this.projects.forEach(n=>n.validate()),this.functions.forEach(n=>n.validate()),this.events.forEach(n=>n.validate()),this.variableDeclarations.forEach(n=>n.validate()),this.variableInstances.forEach(n=>n.validate()),this.conditions.forEach(n=>n.validate()),this.operations.forEach(n=>n.validate()),this.functionCalls.forEach(n=>n.validate()),this.loops.forEach(n=>n.validate()),this.searches.forEach(n=>n.validate())}getErrors(){return[...this.errors,...this.entities.flatMap(a=>a.getErrors()),...this.projects.flatMap(a=>a.getErrors()),...this.functions.flatMap(a=>a.getErrors()),...this.events.flatMap(a=>a.getErrors()),...this.variableDeclarations.flatMap(a=>a.getErrors()),...this.variableInstances.flatMap(a=>a.getErrors()),...this.conditions.flatMap(a=>a.getErrors()),...this.operations.flatMap(a=>a.getErrors()),...this.functionCalls.flatMap(a=>a.getErrors()),...this.loops.flatMap(a=>a.getErrors()),...this.searches.flatMap(a=>a.getErrors())]}getShallowErrors(){return this.errors}clone(){return this}getDefinitionEntity(n){return this.entities.find(a=>a.id===n)||null}addDefinitionEntity(n){return this.entities.includes(n)||this.entities.push(n),n}addFunctionDeclaration(n){return this.functions.includes(n)||this.functions.push(n),n}addFunctionCall(n){return this.functionCalls.includes(n)||this.functionCalls.push(n),n}addVariableDeclaration(n){return this.variableDeclarations.includes(n)||this.variableDeclarations.push(n),n}addVariableInstance(n){return this.variableInstances.includes(n)||this.variableInstances.push(n),n}addInstalledProject(n){return this.projects.includes(n)||this.projects.push(n),this}addGlobalEvent(n){return this.events.includes(n)||this.events.push(n),this}addCondition(n){return this.conditions.includes(n)||this.conditions.push(n),this}addOperation(n){return this.operations.includes(n)||this.operations.push(n),this}addLoop(n){return this.loops.includes(n)||this.loops.push(n),this}addSearch(n){return this.searches.includes(n)||this.searches.push(n),this}removeDefinitionEntity(n){const a=this.entities.findIndex(l=>l.id===n.id);if(a>-1){const l=this.entities[a];return this.entities.splice(a,1),l}return null}removeCondition(n){const a=this.conditions.findIndex(l=>l.id===n.id);if(a>-1){const l=this.conditions[a];return this.conditions.splice(a,1),l}return null}removeOperation(n){const a=this.operations.findIndex(l=>l.id===n.id);if(a>-1){const l=this.operations[a];return this.operations.splice(a,1),l}return null}removeLoop(n){const a=this.loops.findIndex(l=>l.id===n.id);if(a>-1){const l=this.loops[a];return this.loops.splice(a,1),l}return null}removeSearch(n){const a=this.searches.findIndex(l=>l.id===n.id);if(a>-1){const l=this.searches[a];return this.searches.splice(a,1),l}return null}removeFunctionCall(n){const a=this.functionCalls.findIndex(l=>l.id===n.id);if(a>-1){const l=this.functionCalls[a];return this.functionCalls.splice(a,1),l}return null}removeVariableInstance(n){const a=this.variableInstances.findIndex(l=>l.id===n.id);if(a>-1){const l=this.variableInstances[a];return this.variableInstances.splice(a,1),l}return null}removeVariableDeclaration(n){const a=this.variableDeclarations.findIndex(l=>l.id===n.id);if(a>-1){const l=this.variableDeclarations[a];return this.variableDeclarations.splice(a,1),l}return null}removeFunctionDeclaration(n){const a=this.functions.findIndex(l=>l.id===n.id);if(a>-1){const l=this.functions[a];return this.functions.splice(a,1),l}return null}removeInstalledProject(n){const a=this.projects.findIndex(l=>l.id===n.id);if(a>-1){const l=this.projects[a];return this.projects.splice(a,1),l}return null}removeGlobalEvent(n){const a=this.events.findIndex(l=>l.id===n.id);if(a>-1){const l=this.events[a];return this.events.splice(a,1),l}return null}removeTopLevelVariableDeclaration(n){if(n.type!==f.VariableDeclaration)return null;const a=this.variableDeclarations.findIndex(l=>l.id===n.id);if(a>-1){const l=this.variableDeclarations[a];return this.variableDeclarations.splice(a,1),l}return null}getEntryPoints(){return[...this.functions,...this.events,...this.entities.flatMap(a=>a.methods)]}getTerminationStatements(){return[...this.getEntryPoints().reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.ReturnStatement||t.type===f.ContinueStatement||t.type===f.BreakStatement)]},[])]}getFunctionDeclaration(n){return this.functions.find(a=>a.id===n)||null}getConditions(){return[...this.conditions,...this.getEntryPoints().reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.Condition)]},[]),...this.functionCalls.reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.Condition)]},[]),...this.operations.reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.Condition)]},[]),...this.loops.reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.Condition)]},[]),...this.searches.reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.Condition)]},[])]}getOperations(){return[...this.operations,...this.getEntryPoints().reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.Operation)]},[]),...this.functionCalls.reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.Operation)]},[]),...this.conditions.reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.Operation)]},[]),...this.loops.reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.Operation)]},[]),...this.searches.reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.Operation)]},[])]}getFunctionCalls(){return[...this.functionCalls,...this.getEntryPoints().reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.FunctionCall)]},[]),...this.conditions.reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.FunctionCall)]},[]),...this.operations.reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.FunctionCall)]},[]),...this.loops.reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.FunctionCall)]},[]),...this.searches.reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.FunctionCall)]},[])]}getVariables(){return[...this.variableDeclarations,...this.getEntryPoints().reduce((a,l)=>{const p=kt(l);return[...a,...p]},[]),...this.functionCalls.reduce((a,l)=>{const p=kt(l);return[...a,...p]},[]),...this.conditions.reduce((a,l)=>{const p=kt(l);return[...a,...p]},[]),...this.operations.reduce((a,l)=>{const p=kt(l);return[...a,...p]},[]),...this.loops.reduce((a,l)=>{const p=kt(l);return[...a,...p]},[]),...this.searches.reduce((a,l)=>{const p=kt(l);return[...a,...p]},[])]}getVariableInstances(){return[...this.variableInstances,...this.getEntryPoints().reduce((a,l)=>{const t=kt(l).filter(m=>m.type===f.VariableInstance);return[...a,...t]},[]),...this.functionCalls.reduce((a,l)=>{const t=kt(l).filter(m=>m.type===f.VariableInstance);return[...a,...t]},[]),...this.conditions.reduce((a,l)=>{const t=kt(l).filter(m=>m.type===f.VariableInstance);return[...a,...t]},[]),...this.operations.reduce((a,l)=>{const t=kt(l).filter(m=>m.type===f.VariableInstance);return[...a,...t]},[]),...this.loops.reduce((a,l)=>{const t=kt(l).filter(m=>m.type===f.VariableInstance);return[...a,...t]},[]),...this.searches.reduce((a,l)=>{const t=kt(l).filter(m=>m.type===f.VariableInstance);return[...a,...t]},[])]}getVariableDeclarations(){return I([...this.variableDeclarations,...this.getEntryPoints().reduce((a,l)=>{const t=kt(l).filter(m=>m.type===f.VariableDeclaration);return[...a,...t]},[]),...this.functionCalls.reduce((a,l)=>{const t=kt(l).filter(m=>m.type===f.VariableDeclaration);return[...a,...t]},[]),...this.conditions.reduce((a,l)=>{const t=kt(l).filter(m=>m.type===f.VariableDeclaration);return[...a,...t]},[]),...this.operations.reduce((a,l)=>{const t=kt(l).filter(m=>m.type===f.VariableDeclaration);return[...a,...t]},[]),...this.loops.reduce((a,l)=>{const t=kt(l).filter(m=>m.type===f.VariableDeclaration);return[...a,...t]},[]),...this.searches.reduce((a,l)=>{const t=kt(l).filter(m=>m.type===f.VariableDeclaration);return[...a,...t]},[])])}getLoops(){return[...this.loops,...this.getEntryPoints().reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.Loop)]},[]),...this.functionCalls.reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.Loop)]},[]),...this.conditions.reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.Loop)]},[]),...this.operations.reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.Loop)]},[]),...this.searches.reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.Loop)]},[])]}getSearches(){return[...this.searches,...this.getEntryPoints().reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.Search)]},[]),...this.functionCalls.reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.Search)]},[]),...this.conditions.reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.Search)]},[]),...this.operations.reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.Search)]},[]),...this.loops.reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.Search)]},[])]}attachOrphanReferences(){const n=this.getVariableInstances(),a=this.getVariableDeclarations();return n.forEach(l=>{if(!l.declaration){const p=l.initialData,t=p.declaration.entityId||p.declaration.id,m=a.find(E=>E.id===t);m&&l.setDeclaration(m)}}),this}getBuiltInPersistedEntity(){return this.builtInBaseEntities.find(n=>n.name===ge.PERSISTED_ENTITY)||null}requestActiveValue(n){var l;const a=(l=this.onRequestActiveValueCallback)==null?void 0:l.call(this,n);return a?a||null:n.getDefaultValue()}undo(){console.log("Undoing, from: ",this.undoableStackValueIndex),this.undoableStackValueIndex=this.undoableStackValueIndex-1,console.log("To: ",this.undoableStackValueIndex);const n=this.history[this.undoableStackValueIndex+1],a=this.history[this.undoableStackValueIndex];return zL(n||"initial",a||"initial",this)}redo(){console.log("Undoing, from: ",this.undoableStackValueIndex),this.undoableStackValueIndex=this.undoableStackValueIndex+1,console.log("To: ",this.undoableStackValueIndex);const n=this.history[this.undoableStackValueIndex-1],a=this.history[this.undoableStackValueIndex];return zL(n||"initial",a||"initial",this)}applyExternalChangeSet(n){const a=n.payload,l=this.addChangeSet(new F(this,n.author,n.timestamp,this)),p=a.updated[this.id];if(!p)throw new Error("Project root not found in change set transfer. Cannot apply changes.");const t={...a.added,...a.updated,...a.removed},m=a.seenEntities.filter(b=>!a.affected.includes(b));m.forEach(b=>{var _;if(!t[b]){console.warn(`Entity '${b}' not found in change set transfer. Cannot apply changes.`);const w=(_=this.get(b))==null?void 0:_.toShallowJSON();throw w?console.warn("Entity in project: ",w):console.warn("Entity not in project"),new Error(`Entity '${b}' not found in change set transfer. Cannot apply changes.`)}});const E=new Ga(p);return E.flatRecord=t,E.order=m,E.orderEntities(),console.log("All entities: ",E.order.map((b,_)=>`${_+1}: ${t[b].type} - ${b}`).join(`,
|
|
400
|
+
Alternatively you can update the parent data-type entity with 'update' action to remove the existing value of the field.`,issue:null}))}return{errors:p,modifiedData:l}}get interactive(){return this.implements.length?this.implements.every(n=>n.interactive):!0}get allMethods(){return I([...this.ownDeclaredMethods,...this.allBaseMethodsFromOriginalParents])}get allProperties(){return I([...this.ownDeclaredProperties,...this.allBasePropertiesFromOriginalParents])}get allBaseMethodsFromOriginalParents(){return I([...this.extends.flatMap(n=>n.allMethods,[]),...this.implements.flatMap(n=>n.allMethods,[])])}get allBasePropertiesFromOriginalParents(){return I([...this.extends.flatMap(n=>n.allProperties,[]),...this.implements.flatMap(n=>n.allProperties,[])])}get allBasePropertiesFromExtendedAndImplementedEntities(){return I([...this.extends.reduce((n,a)=>[...[...a.ownDeclaredProperties,...a.allBasePropertiesFromExtendedAndImplementedEntities].filter(p=>!p.abstract),...n],[]),...this.implements.reduce((n,a)=>[...[...a.ownDeclaredProperties,...a.allBasePropertiesFromExtendedAndImplementedEntities].filter(p=>!p.abstract),...n],[])])}get allBaseMethodsFromExtendedAndImplementedEntities(){return I([...this.extends.reduce((n,a)=>a.type!==f.DefinitionEntity?[]:[...[...a.ownDeclaredMethods,...a.allBaseMethodsFromExtendedAndImplementedEntities].filter(p=>p.type!==f.ActionDescriptor),...n],[]),...this.implements.reduce((n,a)=>a.type!==f.DefinitionEntity?a.abstractMethods:[...[...a.ownDeclaredMethods,...a.allBaseMethodsFromExtendedAndImplementedEntities].filter(p=>p.type!==f.ActionDescriptor),...n],[])])}get extendedPropertiesFromOriginalParents(){return I(this.extends.reduce((n,a)=>{const l=[...a.ownDeclaredProperties,...a.extendedPropertiesFromOriginalParents].filter(p=>!p.abstract);return[...n,...l]},[]))}get implementedPropertiesFromOriginalParents(){return I([...this.extends.reduce((n,a)=>{const l=a.implementedPropertiesFromOriginalParents,p=[...a.ownDeclaredProperties].filter(t=>!!t.abstract&&!l.find(m=>m.name===t.name));return[...l,...p,...n]},[]),...this.implements.reduce((n,a)=>{const l=a.implementedPropertiesFromOriginalParents,p=[...a.ownDeclaredProperties].filter(t=>!!t.abstract&&!l.find(m=>m.name===t.name));return[...l,...p,...n]},[])].filter(n=>!!n.abstract))}get extendedMethodsFromOriginalParents(){return I(this.extends.reduce((n,a)=>{if(a.type!==f.DefinitionEntity)return[];const l=[...a.ownDeclaredMethods,...a.extendedMethodsFromOriginalParents].filter(p=>p.type!==f.ActionDescriptor);return[...n,...l]},[]))}get implementedMethodsFromOriginalParents(){return I([...this.extends.reduce((n,a)=>{const l=a.type===f.DefinitionEntity?a.methods:[],p=[...a.abstractMethods].filter(t=>!l.find(m=>m.name===t.name));return[...l,...p,...n]},[]),...this.implements.reduce((n,a)=>[...a.abstractMethods,...n],[])].filter(n=>n.type===f.ActionDescriptor))}get extendedProperties(){return this.properties.filter(n=>n.isExtendedProperty)}get ownDeclaredProperties(){return this.properties.filter(n=>!n.isExtendedProperty)}get extendedMethods(){return this.methods.filter(n=>n.isExtendedMethod)}get ownDeclaredMethods(){return this.methods.filter(n=>!n.isExtendedMethod)}validateGeneratedUpdate(n){const a=[];return n.parent&&a.push(new Y({id:`${this.id}--${k.InvalidParentUpdate}`,code:k.InvalidParentUpdate,severity:S.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated. The 'parent' on an '${this.type}', must be the root project as it is a globally declared entity.`,issue:null})),{errors:a,modifiedData:n}}subscribeDependents(n){return n.forEach(a=>{this.detachedDependents[a.entity.id]||(this.detachedDependents[a.entity.id]=a)}),this}unsubscribeDependents(n){return n.forEach(a=>{this.detachedDependents[a.entity.id]&&delete this.detachedDependents[a.entity.id]}),this}syncDependents(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"sync-dependents"))){const a=[],l=[],p=[],t=[];return Object.values(this.detachedDependents).forEach(m=>{const E=m.entity.afterAllChildrenInitialized(n);a.push(...E.updated),l.push(...E.added),p.push(...E.removed),t.push(...E.affected)}),n==null||n.attemptAutoclose("sync-dependents",this.id),{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this}}onDetachedDependencyRemoved(n,a,l){const p=[],t=[],m=[],E=[];return a==="implements"&&this.removeImplementation(n),a==="extends"&&this.removeExtension(n),{updated:I(p),added:I(t),removed:I(m),affected:I(E),self:this}}onDetachedDependencyRestored(n,a,l){const p=[],t=[],m=[],E=[];return a==="implements"&&this.addImplementation(n),a==="extends"&&this.addExtension(n),{updated:I(p),added:I(t),removed:I(m),affected:I(E),self:this}}unsubscribeFromDependencies(){return this.implements.forEach(n=>{Pi.includes(n.type)||n.unsubscribeDependents([{entity:this,field:"implements"}])}),this}subscribeToDependencies(){return this.implements.forEach(n=>{Pi.includes(n.type)||n.subscribeDependents([{entity:this,field:"implements"}])}),this.extends.forEach(n=>{Pi.includes(n.type)||n.subscribeDependents([{entity:this,field:"extends"}])}),this}increaseVersion(n){if(n&&!N(n).isValid())throw new Error(`The shared timestamp '${n}' is not a valid ISO 8601 date string.`);return n&&N(n).isSame(N(this.createdAt))?this:(this.previousVersion=this.version,this.version=P.UUID.uuid(),this.createdAt=N(n).toISOString()||N().toISOString(),this)}captureVersion(){var a;const n=((a=this.knownVersions)==null?void 0:a.get(this.version))||new _t(this,this.project);return n.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,n):new Map([[this.version,n]]),n.properties=[...this.properties],n.methods=[...this.methods],n.abstractMethods=[...this.abstractMethods],n.extends=[...this.extends],n.implements=[...this.implements],n.parent=this.parent,this}recursiveCaptureUpstreamVersions(n){const a=[],l=[],p=[],t=[];if(this.parent){this.parent.increaseVersion(n);const m=this.parent.recursiveCaptureUpstreamVersions(n);a.push(this.parent,...m.updated),l.push(...m.added),p.push(...m.removed)}return{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this}}async restoreVersion(n){var E;const a=[],l=[],p=[],t=[];if(this.version===n)return{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this};if(!this.knownVersions){const b=new Map;for(const[_,w]of this.knownVersions||new Map){if(b.set(_,w),w.activeVersion=!1,w.knownVersions)for(const[V,B]of w.knownVersions)b.set(V,B);w.knownVersions=null}}let m=(E=this.knownVersions)==null?void 0:E.get(n);if(!m){const b=await this.APILoadVersion({},n);if(!b)throw new Error(`Version with id '${n}' for entity with id '${this.id}' not found.`);m=new _t(b,this.project)}return this.metaSync(m.toShallowJSON(),null),this.previousVersion=m.previousVersion,this.version=m.version,this.createdAt=m.createdAt,this.author=m.author,this.deleted=m.deleted,this.properties=m.properties,this.methods=m.methods,this.abstractMethods=m.abstractMethods,this.extends=m.extends,this.implements=m.implements,this.parent=m.parent,{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this}}updateWithShallowTransfer(n,a=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"update-with-shallow-transfer"))){if(this.metaSync(n,a),this.version=n.version,this.createdAt=n.createdAt,this.author=n.author,this.deleted=n.deleted,this.previousVersion=n.previousVersion,this.unsubscribeFromDependencies(),n.parent){const l=W(n.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,a);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'`);return n.extends.forEach(l=>{const p=W(l),t=this.project.get(p);t&&this.addExtension(t)}),n.implements.forEach(l=>{const p=W(l),t=this.project.get(p);t&&this.addImplementation(t)}),this.captureVersion(),this.subscribeToDependencies(),a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),this}hydrateAncestors(){const n=[],a=[],l=[],p=[];if(this.initialData.parent){const t=W(this.initialData.parent),m=this.project.get(t);if(m)this.setParent(m,null),n.push(m);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'`);return this.initialData.extends.forEach(t=>{const m=W(t),E=this.project.get(m);E&&(this.addExtension(E),E.type!==f.BuiltInBaseEntity&&n.push(E))}),this.initialData.implements.forEach(t=>{const m=W(t),E=this.project.get(m);E&&(this.addImplementation(E),E.type!==f.BuiltInBaseEntity&&n.push(E))}),{updated:I(n),added:I(a),removed:I(l),affected:I(p),self:this}}afterAllChildrenInitialized(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"after-all-children-initialized"))){const a=[],l=[],p=[],t=[];this.initialized=!0;const{updated:m,added:E,removed:b,affected:_}=this.syncImplementationProperties(n);a.push(...m),l.push(...E),p.push(...b),t.push(..._);const{updated:w,added:V,removed:B,affected:K}=this.addExtendedProperties(n);a.push(...w),l.push(...V),p.push(...B),t.push(...K);const{updated:q,added:Z,removed:Q}=this.removeUnrecognizedProperties(n);a.push(...q),l.push(...Z),p.push(...Q);const{updated:ie,added:H,removed:Ie,affected:re}=this.syncImplementationMethods(n);a.push(...ie),l.push(...H),p.push(...Ie),t.push(...re);const{updated:Te,added:Ve,removed:ue,affected:ve}=this.addExtendedMethods(n);a.push(...Te),l.push(...Ve),p.push(...ue),t.push(...ve);const{updated:X,added:de,removed:$e}=this.removeUnrecognizedMethods(n);return a.push(...X),l.push(...de),p.push(...$e),this.addSuggestions(),this.captureVersion(),n==null||n.attemptAutoclose("after-all-children-initialized",this.id),{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this}}addSelfToProject(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"add-self-to-project"))){const a=[this],l=[],p=[],t=[];if(this.parent.type===f.DataType){const m=this.parent;m.entity=this,a.push(m)}else this.project.addDefinitionEntity(this);return this.subscribe(),this.subscribeToDependencies(),n==null||n.attemptAutoclose("add-self-to-project",this.id),{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this}}setParent(n,a=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"set-parent"))){var l;return((l=this.parent)==null?void 0:l.id)!==(n==null?void 0:n.id)&&(this.parent=n,a&&(a==null||a.add(this,G.Updated))),a==null||a.attemptAutoclose("set-parent",this.id),this}addExtension(n){return this.extends.includes(n)||this.extends.push(n),this}removeExtension(n){return this.extends=this.extends.filter(a=>a.id!==n.id),this}addImplementation(n){return this.implements.includes(n)||this.implements.push(n),this}removeImplementation(n){return this.implements=this.implements.filter(a=>a.id!==n.id),this}removeProperty(n){return this.properties=this.properties.filter(a=>a.id!==n.id),this}addMethod(n){return this.methods.includes(n)||(this.methods.push(n),this.suggestedMethods=this.suggestedMethods.filter(a=>a.name!==n.name)),this}removeMethod(n){return this.methods=this.methods.filter(a=>a.id!==n.id),this}addProperty(n){return this.properties.includes(n)||(this.properties.push(n),this.suggestedProperties=this.suggestedProperties.filter(a=>a.name!==n.name)),this}addSuggestedProperty(n){return this.suggestedProperties.includes(n)||this.suggestedProperties.push(n),this}addSuggestedMethod(n){return this.suggestedMethods.includes(n)||this.suggestedMethods.push(n),this}removeSuggestedProperty(n){return this.suggestedProperties=this.suggestedProperties.filter(a=>a.id!==n.id),this}removeSuggestedMethod(n){return this.suggestedMethods=this.suggestedMethods.filter(a=>a.id!==n.id),this}addAbstractMethod(n){return this.abstractMethods.includes(n)||this.abstractMethods.push(n),this}removeAbstractMethod(n){return this.abstractMethods=this.abstractMethods.filter(a=>a.id!==n.id),this}initChildren(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"init-children"))){return this.initialized||this.startedInitialization?this:(this.startedInitialization=!0,this.properties=this.initialData.properties.map(a=>{const l=z(a,this.project);return l.setParent(this,null),l.initChildren(n),l}),this.methods=this.initialData.methods.map(a=>{const l=z(a,this.project);return l.setParent(this,null),l.initChildren(n),l}),this.abstractMethods=this.initialData.abstractMethods.map(a=>{const l=z(a,this.project);return l.setParent(this,null),l.initChildren(n),l}),this.extends=this.initialData.extends.map(a=>z(a,this.project)),this.implements=this.initialData.implements.map(a=>z(a,this.project)),this.subscribeToDependencies(),this.afterAllChildrenInitialized(n),n==null||n.attemptAutoclose("init-children",this.id),this)}removeUnrecognizedProperties(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"remove-unrecognized-properties"))){const a=[],l=[],p=[],t=[];let m=[...this.properties];m=m.filter(b=>b.parent.id===this.id),m=m.filter(b=>!b.isExtendedProperty);const E=this.implementedPropertiesFromOriginalParents;return m=m.filter(b=>this.interactive&&!b.implements?!1:!E.find(_=>{var w;return _.id===((w=b.implements)==null?void 0:w.id)})),m.forEach(b=>{const _=b.remove({ignoreUpstream:!1},n);p.push(..._.removed),a.push(..._.updated)}),n==null||n.attemptAutoclose("remove-unrecognized-properties",this.id),{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this}}removeUnrecognizedMethods(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"remove-unrecognized-methods"))){const a=[],l=[],p=[],t=[];let m=[...this.methods];m=m.filter(b=>b.parent.id===this.id),m=m.filter(b=>!b.isExtendedMethod);const E=this.implementedMethodsFromOriginalParents;return m=m.filter(b=>this.interactive&&!b.implements?!1:!E.find(_=>{var w;return _.id===((w=b.implements)==null?void 0:w.id)})),m.forEach(b=>{const _=b.remove({ignoreUpstream:!1},n);p.push(..._.removed),a.push(..._.updated)}),n==null||n.attemptAutoclose("remove-unrecognized-methods",this.id),{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this}}syncImplementationMethods(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"sync-implementation-methods"))){const a=[],l=[],p=[],t=[],m=this.methods,E=this.implementedMethodsFromOriginalParents,b=[...this.allBaseMethodsFromExtendedAndImplementedEntities,...m];return E.filter(w=>!b.find(B=>{var K;return((K=B.implements)==null?void 0:K.id)===w.id})).forEach(w=>{if(this.methods.find(q=>{var Z;return((Z=q.implements)==null?void 0:Z.id)===w.id}))return;const B=this.methods.find(q=>{var Ie,re;if(q.name===w.name&&!q.implements)return!0;const Z=As(this,ge.CRON_JOB),Q=As(this,ge.HTTP_ENDPOINT),ie=((Ie=q.implements)==null?void 0:Ie.id)===pe["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.methods.handler.id,H=((re=q.implements)==null?void 0:re.id)===pe["built-in-base-entity"].BUILT_IN_CRON_JOB_ENTITY.methods.handler.id;return!!(Z&&!H&&!Q&&ie||Q&&!ie&&!Z&&H)});if(B&&B.type===f.FunctionDeclaration){B.setImplements(w),B.metaSync({name:w.name},n),n==null||n.add(B,G.Updated),n==null||n.add(this,G.Updated);return}const K=w.implementAsFunctionDeclaration(n,this);l.push(K),n==null||n.add(K,G.Added),this.addMethod(K)}),n==null||n.attemptAutoclose("sync-implementation-methods",this.id),{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this}}syncImplementationProperties(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"sync-implementation-properties"))){const a=[],l=[],p=[],t=[],m=this.properties,E=this.implementedPropertiesFromOriginalParents,b=[...this.allBasePropertiesFromExtendedAndImplementedEntities,...m];return E.filter(w=>!b.find(B=>{var K;return((K=B.implements)==null?void 0:K.id)===w.id})).forEach(w=>{if(this.properties.find(q=>{var Z;return((Z=q.implements)==null?void 0:Z.id)===w.id}))return;const B=this.properties.find(q=>q.name===w.name&&!!q.abstract&&!q.implements);if(B){B.setImplements(w,n),B.metaSync({abstract:!1},n),B.afterAllChildrenInitialized(n);return}const K=w.implement(this,n,P.UUID.uuid());l.push(K),n==null||n.add(K,G.Added)}),n==null||n.attemptAutoclose("sync-implementation-properties",this.id),{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this}}addExtendedMethods(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"add-extended-methods"))){const a=[],l=[],p=[],t=[],m=this.methods,b=this.extendedMethodsFromOriginalParents.filter(w=>w.type===f.FunctionDeclaration),_=new Set(m.filter(w=>{var V;return!!((V=w.extends)!=null&&V.id)}).map(w=>w.extends.id));return b.forEach(w=>{if(_.has(w.id))return;_.add(w.id);const V=w.clone(n,this,P.UUID.uuid());V.setExtends(w,n),V.initChildren(n),l.push(V),n==null||n.add(V,G.Added),this.addMethod(V)}),n==null||n.attemptAutoclose("add-extended-methods",this.id),{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this}}addExtendedProperties(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"add-extended-properties"))){const a=[],l=[],p=[],t=[],m=this.properties,E=this.extendedPropertiesFromOriginalParents,b=E.filter(w=>E.find(B=>{var K;return((K=B.implements)==null?void 0:K.id)===w.id})?!1:!w.abstract),_=new Set(m.filter(w=>{var V;return!!((V=w.extends)!=null&&V.id)}).map(w=>w.extends.id));return b.forEach(w=>{if(_.has(w.id))return;_.add(w.id);const V=w.clone(n,this,P.UUID.uuid());V.setExtends(w,n),V.initChildren(n),l.push(V),n==null||n.add(V,G.Added),this.addProperty(V)}),n==null||n.attemptAutoclose("add-extended-properties",this.id),{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this}}addSuggestions(){return this.implements.forEach(n=>{Ej(this,n).forEach(p=>{const t=p.toJSON();t.id=`_suggestion--parent--${this.id}--${p.id}`;const m=z(t,this.project);m.suggestion=!0,m.setParent(this,null),m.initChildren(null),this.addSuggestedProperty(m)}),Tj(this,n).forEach(p=>{const t=`_suggestion--parent--${this.id}--${p.id}`,m=p.implementAsFunctionDeclaration(null,this,t),E=z(m,this.project);if(E.suggestion=!0,E.setParent(this,null),E.initChildren(null),this.methods=this.methods.filter(b=>b.id!==t),E.inputs.forEach(b=>{b.suggestion=!0}),E.returnStatements.length){const b=E.returnStatements[0];b.suggestion=!0,b.outputs.forEach(_=>{_.suggestion=!0})}this.addSuggestedMethod(E)})}),this}subscribe(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(n,a=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"meta-sync"))){const l=cr(this,n),p=this.toMeta();return this.name=n.name!==void 0?n.name:p.name,this.description=n.description!==void 0?n.description:p.description,this.x=n.x||p.x,this.y=n.y||p.y,this.static=n.static!==void 0?n.static:this.static,this.abstract=n.abstract!==void 0?n.abstract:this.abstract,super.metaSync(n),n.deleted===!0&&!p.deleted?a==null||a.add(this,G.Removed):n.deleted===!1&&p.deleted?a==null||a.add(this,G.Added):l&&(a==null||a.add(this,G.Updated)),a==null||a.attemptAutoclose("meta-sync",this.id),this}async APILoad(n=oe,...a){return await _t.repository.APILoad(this.id,...a),this}async APICreate(n=oe,...a){return await _t.repository.APICreate(this.toShallowJSON(),...a),this}async APIUpdate(n=oe,...a){return await _t.repository.APIUpdate(this.toShallowJSON(),...a),this}async APIDelete(n=oe,...a){return await _t.repository.APIDelete(this.toShallowJSON(),...a),this}async APIClone(n=oe,...a){return await _t.repository.APIClone(this.id,...a),this}async APILoadVersion(n=oe,a,...l){return await _t.repository.APILoadVersion(this.id,a,...l)}removeFromParent(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"remove-from-parent"))){const a=[],l=[],p=[],t=[];if(this.parent.type===f.Project)this.parent.removeDefinitionEntity(this);else if(this.parent.type===f.DataType&&this.parent.entity&&this.parent.entity.id===this.id){const m=this.parent.setEntity(null,n);a.push(m)}return n==null||n.attemptAutoclose("remove-from-parent",this.id),{added:I(p),updated:I(a),removed:I(l),affected:I(t),self:this}}remove({ignoreUpstream:n}={ignoreUpstream:!1},a=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"remove-entity"))){const l=[],p=[],t=[],m=[];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(E=>{const{updated:b,removed:_,added:w}=E.entity.onDetachedDependencyRemoved(this,E.field,a);l.push(...b),p.push(..._),t.push(...w)}),this.properties.forEach(E=>{const{updated:b,removed:_}=E.remove({ignoreUpstream:!0},a);l.push(...b),p.push(..._)}),this.methods.forEach(E=>{const{updated:b,removed:_}=E.remove({ignoreUpstream:!0},a);l.push(...b),p.push(..._)}),this.abstractMethods.forEach(E=>{const{updated:b,removed:_}=E.remove({ignoreUpstream:!0},a);l.push(...b),p.push(..._)}),this.suggestedProperties.forEach(E=>{const{updated:b,removed:_}=E.remove({ignoreUpstream:!0},a);l.push(...b),p.push(..._)}),this.suggestedMethods.forEach(E=>{const{updated:b,removed:_}=E.remove({ignoreUpstream:!0},a);l.push(...b),p.push(..._)}),!n){const E=this.removeFromParent(a);t.push(...E.added),l.push(...E.updated),p.push(...E.removed),m.push(...E.affected)}return a==null||a.attemptAutoclose("remove-entity",this.id),{added:I(t),updated:I(l),removed:I(p),affected:I(m),self:this}}restore({}={},n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"restore-entity"))){const a=[],l=[],p=[],t=[];return n!=null&&n.hasAdded(this.id)?(n==null||n.attemptAutoclose("restore-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this}):(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},n),Object.values(this.detachedDependents).forEach(m=>{const{updated:E,removed:b,added:_}=m.entity.onDetachedDependencyRestored(this,m.field,n);l.push(...E),p.push(...b),a.push(..._)}),this.properties.forEach(m=>{const{updated:E}=m.restore({},n);l.push(...E)}),this.methods.forEach(m=>{const{updated:E}=m.restore({},n);l.push(...E)}),this.abstractMethods.forEach(m=>{const{updated:E}=m.restore({},n);l.push(...E)}),this.suggestedProperties.forEach(m=>{const{updated:E}=m.restore({},n);l.push(...E)}),this.suggestedMethods.forEach(m=>{const{updated:E}=m.restore({},n);l.push(...E)}),n==null||n.attemptAutoclose("restore-entity",this.id),{added:I(a),updated:I(l),removed:I(p),affected:I(t),self:this})}toFlat(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[this,...this.extends.flatMap(l=>l.toFlat(n)),...this.implements.flatMap(l=>l.toFlat(n)),...this.properties.flatMap(l=>l.toFlat(n)),...this.methods.flatMap(l=>l.toFlat(n)),...this.abstractMethods.flatMap(l=>l.toFlat(n)),...this.parent.toFlat(n)])}toFlatIds(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[this.id,...this.extends.flatMap(l=>l.toFlatIds(n)),...this.implements.flatMap(l=>l.toFlatIds(n)),...this.properties.flatMap(l=>l.toFlatIds(n)),...this.methods.flatMap(l=>l.toFlatIds(n)),...this.abstractMethods.flatMap(l=>l.toFlatIds(n)),...this.parent.toFlatIds(n)])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,description:this.description,static:this.static,abstract:this.abstract,x:this.x,y:this.y,type:this.type,name:this.name}}toJSON(n=new Set){return n.has(this.id)?this.toReference():(n.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,x:this.x,y:this.y,static:this.static,abstract:this.abstract,properties:this.properties.map(a=>a.toJSON(n)),methods:this.methods.map(a=>a.toJSON(n)),abstractMethods:this.abstractMethods.map(a=>a.toJSON(n)),implements:this.implements.map(a=>a.toJSON(n)),extends:this.extends.map(a=>a.toJSON(n)),parent:this.parent.toReference()})}toJSONClone(n=Oe){var l,p,t,m,E;let a;return(l=n.seenEntityMaps)!=null&&l.has(this.id)?a=n.seenEntityMaps.get(this.id):(a=n.newId||hr(this,this.project,n.uuidStrategy),n.seenEntityMaps&&n.seenEntityMaps.set(this.id,a)),(p=n.seenEntities)!=null&&p.has(a)||(t=n.seenEntities)!=null&&t.has(this.id)?this.toReference({seenEntityMaps:n.seenEntityMaps}):((m=n.seenEntities)==null||m.add(a),(E=n.seenEntities)==null||E.add(this.id),{id:a,version:P.UUID.uuid(),createdAt:n.timestamp||N().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,type:this.type,name:this.name,description:this.description,x:this.x,y:this.y,static:this.static,abstract:this.abstract,properties:this.properties.map(b=>b.toJSONClone({...n,newId:null})),methods:this.methods.map(b=>b.toJSONClone({...n,newId:null})),abstractMethods:this.abstractMethods.map(b=>b.toJSONClone({...n,newId:null})),implements:this.implements.map(b=>b.type===f.BuiltInBaseEntity?b.toJSON():b.toJSONClone({...n,newId:null})),extends:this.extends.map(b=>b.type===f.BuiltInBaseEntity?b.toJSON():b.toJSONClone({...n,newId:null})),parent:this.parent.toReference({seenEntityMaps:n.seenEntityMaps})})}toReference(n=Oe){var l;let a=this.id;return(l=n.seenEntityMaps)!=null&&l.has(this.id)&&(a=n.seenEntityMaps.get(this.id)),{id:a+"--"+P.UUID.uuid()+"--ref",type:f.GenericReference,entityId:a,version:this.version,entityType:this.type}}toShallowJSON(n=Oe){var l;let a=this.id;return(l=n.seenEntityMaps)!=null&&l.has(this.id)&&(a=n.seenEntityMaps.get(this.id)),{id:a,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,name:this.name,description:this.description,type:this.type,x:this.x,y:this.y,static:this.static,abstract:this.abstract,properties:this.properties.map(p=>p.toReference(n)),methods:this.methods.map(p=>p.toReference(n)),abstractMethods:this.abstractMethods.map(p=>p.toReference(n)),implements:this.implements.map(p=>p.toReference(n)),extends:this.extends.map(p=>p.toReference(n)),parent:this.parent.toReference(n)}}toFlatJSON(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[this.toShallowJSON(),...this.properties.flatMap(l=>l.toFlatJSON(n)),...this.methods.flatMap(l=>l.toFlatJSON(n)),...this.abstractMethods.flatMap(l=>l.toFlatJSON(n)),...this.implements.flatMap(l=>l.toFlatJSON(n)),...this.extends.flatMap(l=>l.toFlatJSON(n)),...this.parent.toFlatJSON(n)])}toGenerationTarget(){const n=this.parent.type===f.Project?void 0:this.parent.id;return{id:this.id,name:this.name,description:this.description,type:this.type,static:this.static,abstract:this.abstract,extends:this.extends.map(a=>a.id),implements:this.implements.map(a=>a.id),parent:n}}toFlatGenerationTarget(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[this.toGenerationTarget(),...this.properties.flatMap(l=>l.toFlatGenerationTarget(n)),...this.methods.flatMap(l=>l.toFlatGenerationTarget(n)),...this.abstractMethods.flatMap(l=>l.toFlatGenerationTarget(n)),...this.implements.filter(l=>l.type===f.DefinitionEntity).flatMap(l=>l.toFlatGenerationTarget(n)),...this.implements.filter(l=>l.type===f.DefinitionEntity).flatMap(l=>l.toFlatGenerationTarget(n)),...this.parent.toFlatGenerationTarget(n)])}clearErrors(){return this.errors=[],this.properties.forEach(n=>n.clearErrors()),this.methods.forEach(n=>n.clearErrors()),this.abstractMethods.forEach(n=>n.clearErrors()),this}validate(){return this.errors=vj(this),{success:!0,error:null,data:null}}getErrors(){return[...this.errors,...this.properties.flatMap(a=>a.getErrors()),...this.methods.flatMap(a=>a.getErrors()),...this.abstractMethods.flatMap(a=>a.getErrors())]}getShallowErrors(){return this.errors}clone(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"clone-entity")),a=null,l=null,p=!0){var q,Z,Q;let t=yr(a,this);const m=this.toJSON(),E=l||P.UUID.uuid();m.properties=[],m.methods=[],m.abstractMethods=[];const b=E.split("-id"),_=b[b.length-1||0]||E;m.id=E,m.version=P.UUID.uuid(),m.createdAt=(n==null?void 0:n.timestamp)||N().toISOString(),m.author=(n==null?void 0:n.author)||"1",m.previousVersion=null,m.deleted=!1;const w=er(m,t);a&&w.setParent(a,null),p&&w.subscribe(),w.initChildren(n),n==null||n.add(w,G.Added);const V=(q=this.properties)==null?void 0:q.map(ie=>ie.clone(n,w,P.UUID.uuid(),p));w.properties=V;const B=(Z=this.methods)==null?void 0:Z.map((ie,H)=>ie.clone(n,w,_+"-method-"+H+"-id",p));w.methods=B;const K=(Q=this.abstractMethods)==null?void 0:Q.map((ie,H)=>ie.clone(n,w,_+"-abstract-method-"+H+"-id",p));return w.abstractMethods=K,n==null||n.attemptAutoclose("clone-entity",this.id),w}getFunctionDeclaration(n){return this.methods.find(a=>a.id===n)}implement(n,a=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"implement-definition-entity")),l){const p=hy(this,n,a,l);return a==null||a.attemptAutoclose("implement-definition-entity",this.id),p}getAllInteractiveMethods(){const n=this.implements.filter(l=>l.type===f.DefinitionEntity||l.type===f.BuiltInBaseEntity&&l.interactive);return I([...this.methods,...this.extends.flatMap(l=>l.getAllInteractiveMethods()),...n.flatMap(l=>l.getAllInteractiveMethods())])}inferFromInputs(n,a=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"infer-definition-entity-from-inputs"))){const l=[],p=[],t=[],m=[];if(this.parent.type!==f.DataType||!this.parent.inferred)return a==null||a.attemptAutoclose("infer-definition-entity-from-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this};const E=[];n.forEach(w=>{E.find(B=>ce(B,this.project)===ce(w,this.project))||E.push(w)});const b=this.properties.filter(w=>!w.dataType);E.forEach(w=>{var Q,ie;const V=b.find(H=>ce(H,this.project)===ce(w,this.project));if(!V)return;const K=Mo(w.parent).getMasterInputWithValueWritterFromAllInstances(w),q=xs(K,a),Z=q==null?void 0:q.clone(a,V,P.UUID.uuid(),!0);Z&&((Q=V.dataType)==null||Q.merge(Z,a),Z.id!==((ie=V.dataType)==null?void 0:ie.id)&&Z.remove({ignoreUpstream:!1},a),V.dataType&&(V.dataType.metaSync({inferred:!0,like:!0},a),V.setDataType(V.dataType,a),a==null||a.add(V,G.Affected))),w.setDeclaration(V),a==null||a.add(w,G.Updated)});const _=[];return E.forEach(w=>{if(!w.declaration){_.push(w);return}}),_.length===0?(a==null||a.attemptAutoclose("infer-definition-entity-from-inputs",this.id),{added:[],updated:[],removed:[],affected:[],self:this}):(_.forEach(w=>{var H,Ie,re,Te;const V=this.properties.find(Ve=>ce(Ve,this.project)===ce(w,this.project));if(V){if(w.setDeclaration(V),!V.getDataType(a)){const ue=Mo(w.parent).getMasterInputWithValueWritterFromAllInstances(w),ve=xs(ue),X=ve==null?void 0:ve.clone(a,V,P.UUID.uuid(),!0);X&&((H=V.dataType)==null||H.merge(X,a),X.id!==((Ie=V.dataType)==null?void 0:Ie.id)&&X.remove({ignoreUpstream:!1},a),V.dataType&&(V.dataType.metaSync({inferred:!0,like:!0},a),V.setDataType(V.dataType,a),a==null||a.add(V,G.Affected)))}return}const B={id:P.UUID.uuid(),type:f.Property,version:P.UUID.uuid(),createdAt:(a==null?void 0:a.timestamp)||N().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,name:ce(w,this.project),description:w.description,defaultValue:null,static:!0,abstract:!1,private:!1,hidden:!1,required:!1,constant:!0,index:w.index,implements:null,extends:null,dataType:null,parent:this.toReference()},K=z(B,this.project);K.setParent(this,a),K.initChildren(a),a==null||a.add(K,G.Added);const Z=Mo(w.parent).getMasterInputWithValueWritterFromAllInstances(w),Q=xs(Z),ie=Q==null?void 0:Q.clone(a,K,P.UUID.uuid(),!0);return ie&&((re=K.dataType)==null||re.merge(ie,a),ie.id!==((Te=K.dataType)==null?void 0:Te.id)&&ie.remove({ignoreUpstream:!1},a),K.dataType&&(K.dataType.metaSync({inferred:!0,like:!0},a),K.setDataType(K.dataType,a),a==null||a.add(K,G.Affected))),this.addProperty(K),w.setDeclaration(K),a==null||a.add(w,G.Updated),K}),a==null||a.attemptAutoclose("infer-definition-entity-from-inputs",this.id),{added:I(l),updated:I(p),removed:I(t),affected:I(m),self:this})}getRawDefaultValue(){const n={};return this.properties.forEach(a=>{var p;const l=Ra(a.name);n[l]=((p=a.getDefaultValue())==null?void 0:p.value)||null}),n}getActiveRawDefaultValue(){const n={};return this.properties.forEach(a=>{const l=Ra(a.name),p=this.project.requestActiveValue(a);n[l]=(p==null?void 0:p.value)||null}),n}};g(_t,"repository",{APICreate:async(n,...a)=>n,APIUpdate:async(n,...a)=>n,APIDelete:async(n,...a)=>n,APIClone:async(n,...a)=>{},APILoad:async(n,...a)=>null,APILoadVersion:async(n,a,...l)=>null}),g(_t,"type",f.DefinitionEntity),g(_t,"USER_MANAGED_PARENT_TYPES",[f.Project,f.DataType]),g(_t,"PARENT_TYPES",[..._t.USER_MANAGED_PARENT_TYPES]),g(_t,"MUTABLE_BASE_PROPERTIES",["name","description","static","abstract"]),g(_t,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),g(_t,"BASE_PROPERTIES",[..._t.MUTABLE_BASE_PROPERTIES,..._t.INMUTABLE_BASE_PROPERTIES]),g(_t,"MUTABLE_META_PROPERTIES",[..._t.MUTABLE_BASE_PROPERTIES,"x","y"]),g(_t,"INMUTABLE_META_PROPERTIES",[..._t.INMUTABLE_BASE_PROPERTIES]),g(_t,"META_PROPERTIES",[..._t.MUTABLE_META_PROPERTIES,..._t.INMUTABLE_META_PROPERTIES]),g(_t,"MUTABLE_UPSTREAM_PROPERTIES",["extends","implements"]),g(_t,"INMUTABLE_UPSTREAM_PROPERTIES",["parent"]),g(_t,"UPSTREAM_PROPERTIES",[..._t.MUTABLE_UPSTREAM_PROPERTIES,..._t.INMUTABLE_UPSTREAM_PROPERTIES]),g(_t,"MUTABLE_DOWNSTREAM_PROPERTIES",["properties","methods","abstractMethods"]),g(_t,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),g(_t,"DOWNSTREAM_PROPERTIES",[..._t.MUTABLE_DOWNSTREAM_PROPERTIES,..._t.INMUTABLE_DOWNSTREAM_PROPERTIES]),g(_t,"PROPERTIES",[..._t.META_PROPERTIES,..._t.UPSTREAM_PROPERTIES,..._t.DOWNSTREAM_PROPERTIES]);let ia=_t;function Dye(u){const d=Noe(),n=u.toJSON();d.safeParse(n).success;const l=[];return qt(u.errors,l)}const pp=class pp extends nr{constructor(n,a){super(n);g(this,"initialData");g(this,"id");g(this,"version");g(this,"name");g(this,"description",null);g(this,"type",f.BuiltInBaseEntity);g(this,"abstract",!1);g(this,"static");g(this,"properties",[]);g(this,"methods",[]);g(this,"abstractMethods",[]);g(this,"extends",[]);g(this,"interactive",!1);g(this,"errors",[]);g(this,"project");this.initialData=this.initialData||n,this.project=this.project||a,this.id=this.id||n.id,this.version=this.version||n.version,this.name=this.name||n.name,this.static=this.static||n.static,this.interactive=this.interactive||n.interactive,this.abstract=n.abstract,this.properties=this.initialData.properties.map(l=>{const p=z(l,this.project);return p.setParent(this,null),p.initChildren(null),p}),this.methods=this.initialData.methods.map(l=>{const p=z(l,this.project);return p.setParent(this,null),p.initChildren(null),p}),this.abstractMethods=this.initialData.abstractMethods.map(l=>{const p=z(l,this.project);return p.setParent(this,null),p.initChildren(null),p}),this.extends=this.initialData.extends.map(l=>z(l,this.project))}get allMethods(){return I([...this.ownDeclaredMethods,...this.allBaseMethodsFromOriginalParents])}get allProperties(){return I([...this.ownDeclaredProperties,...this.allBasePropertiesFromOriginalParents])}get allBaseMethodsFromOriginalParents(){return I([...this.extends.flatMap(n=>n.allMethods,[])])}get allBasePropertiesFromOriginalParents(){return I([...this.extends.flatMap(n=>n.allProperties,[])])}get allBasePropertiesFromExtendedAndImplementedEntities(){return I(this.extends.reduce((n,a)=>{const l=[...a.ownDeclaredProperties,...a.allBasePropertiesFromExtendedAndImplementedEntities].filter(p=>!p.abstract);return[...n,...l]},[]))}get extendedPropertiesFromOriginalParents(){return I(this.extends.reduce((n,a)=>{const l=[...a.ownDeclaredProperties,...a.extendedPropertiesFromOriginalParents].filter(p=>!p.abstract);return[...n,...l]},[]))}get implementedPropertiesFromOriginalParents(){return I([...this.extends.reduce((n,a)=>{const l=a.implementedPropertiesFromOriginalParents,p=[...a.ownDeclaredProperties].filter(t=>!!t.abstract&&!l.find(m=>m.name===t.name));return[...l,...p,...n]},[])])}get extendedProperties(){return this.properties.filter(n=>n.isExtendedProperty)}get ownDeclaredMethods(){return this.methods.filter(n=>!n.isExtendedMethod)}get ownDeclaredProperties(){return this.properties.filter(n=>!n.isExtendedProperty)}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}async APILoad(n=oe,...a){return await pp.repository.APILoad(this.id,...a),this}toFlat(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[this,...this.properties.flatMap(l=>l.toFlat(n)),...this.methods.flatMap(l=>l.toFlat(n)),...this.abstractMethods.flatMap(l=>l.toFlat(n)),...this.extends.flatMap(l=>l.toFlat(n))])}toFlatIds(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[this.id,...this.properties.flatMap(l=>l.toFlatIds(n)),...this.methods.flatMap(l=>l.toFlatIds(n)),...this.abstractMethods.flatMap(l=>l.toFlatIds(n)),...this.extends.flatMap(l=>l.toFlatIds(n))])}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,abstract:this.abstract,static:this.static,type:this.type,name:this.name}}toJSON(n=new Set){return n.has(this.id)?this.toReference():(n.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,interactive:this.interactive,properties:this.properties.map(a=>a.toJSON(n)),methods:this.methods.map(a=>a.toJSON(n)),abstractMethods:this.abstractMethods.map(a=>a.toJSON(n)),extends:this.extends.map(a=>a.toJSON(n))})}toReference(n=Oe){return{id:this.id+"--"+P.UUID.uuid()+"--ref",type:f.GenericReference,entityId:this.id,version:this.version,entityType:this.type}}toShallowJSON(n=Oe){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,properties:this.properties.map(a=>a.toReference()),methods:this.methods.map(a=>a.toReference()),abstractMethods:this.abstractMethods.map(a=>a.toReference()),extends:this.extends.map(a=>a.toReference())}}toFlatJSON(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[this.toShallowJSON(),...this.properties.flatMap(l=>l.toFlatJSON(n)),...this.methods.flatMap(l=>l.toFlatJSON(n)),...this.abstractMethods.flatMap(l=>l.toFlatJSON(n))])}toGenerationTarget(){return{id:this.id,type:this.type,name:this.name,description:this.description,static:this.static,abstract:this.abstract,interactive:this.interactive,extends:this.extends.map(n=>n.id)}}toFlatGenerationTarget(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[this.toGenerationTarget(),...this.properties.flatMap(l=>l.toFlatGenerationTarget(n)),...this.methods.flatMap(l=>l.toFlatGenerationTarget(n)),...this.abstractMethods.flatMap(l=>l.toFlatGenerationTarget(n))])}clearErrors(){return this.errors=[],this.properties.forEach(n=>n.clearErrors()),this.methods.forEach(n=>n.clearErrors()),this.abstractMethods.forEach(n=>n.clearErrors()),this}validate(){const n=Dye(this);return this.errors=n,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors,...this.properties.flatMap(a=>a.getErrors()),...this.methods.flatMap(a=>a.getErrors()),...this.abstractMethods.flatMap(a=>a.getErrors())]}getShallowErrors(){return this.errors}implement(n,a=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),null,!0,"implement-built-in-base-entity")),l){const p=hy(this,n,a,l);return a==null||a.attemptAutoclose("implement-built-in-base-entity",this.id),p}getAllInteractiveMethods(){const n=[];return this.interactive&&(n.push(...this.methods),this.extends.filter(l=>l.type===f.BuiltInBaseEntity&&l.interactive||l.type===f.PrimitiveEntity).forEach(l=>{l instanceof pp&&n.push(...l.getAllInteractiveMethods())})),I(n)}};g(pp,"repository",{APILoad:async(n,...a)=>null});let qs=pp;function gye(u){const d=Roe(),n=u.toJSON();d.safeParse(n).success;const l=[];return qt(u.errors,l)}const $y=class $y extends nr{constructor(n,a){super(n);g(this,"initialData");g(this,"id");g(this,"name");g(this,"description",null);g(this,"type",f.PrimitiveEntity);g(this,"static");g(this,"abstract");g(this,"properties",[]);g(this,"methods",[]);g(this,"abstractMethods",[]);g(this,"extends",[]);g(this,"errors",[]);g(this,"project");this.initialData=n,this.project=a,this.id=n.id,this.name=n.name,this.static=n.static,this.abstract=n.abstract,this.properties=this.initialData.properties.map(l=>{const p=z(l,this.project);return p.setParent(this,null),p.initChildren(null),p}),this.methods=this.initialData.methods.map(l=>{const p=z(l,this.project);return p.parent=this,p}),this.abstractMethods=this.initialData.abstractMethods.map(l=>{const p=z(l,this.project);return p.parent=this,p})}get allMethods(){return I([...this.ownDeclaredMethods,...this.allBaseMethodsFromOriginalParents])}get allProperties(){return I([...this.ownDeclaredProperties,...this.allBasePropertiesFromOriginalParents])}get allBaseMethodsFromOriginalParents(){return I([...this.extends.flatMap(n=>n.allMethods,[])])}get allBasePropertiesFromOriginalParents(){return I([...this.extends.flatMap(n=>n.allProperties,[])])}get allBasePropertiesFromExtendedAndImplementedEntities(){return I(this.extends.reduce((n,a)=>{const l=[...a.ownDeclaredProperties,...a.allBasePropertiesFromExtendedAndImplementedEntities].filter(p=>!p.abstract);return[...n,...l]},[]))}get extendedPropertiesFromOriginalParents(){return I(this.extends.reduce((n,a)=>{const l=[...a.ownDeclaredProperties,...a.extendedPropertiesFromOriginalParents].filter(p=>!p.abstract);return[...n,...l]},[]))}get implementedPropertiesFromOriginalParents(){return I([...this.extends.reduce((n,a)=>{const l=a.implementedPropertiesFromOriginalParents,p=[...a.ownDeclaredProperties].filter(t=>!!t.abstract&&!l.find(m=>m.name===t.name));return[...l,...p,...n]},[])])}get extendedProperties(){return this.properties.filter(n=>n.isExtendedProperty)}get ownDeclaredMethods(){return this.methods.filter(n=>!n.isExtendedMethod)}get ownDeclaredProperties(){return this.properties.filter(n=>!n.isExtendedProperty)}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}async APILoad(n=oe,...a){return await $y.repository.APILoad(this.id,...a),this}toFlat(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[this,...this.properties.flatMap(l=>l.toFlat(n)),...this.methods.flatMap(l=>l.toFlat(n)),...this.abstractMethods.flatMap(l=>l.toFlat(n))])}toFlatIds(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[this.id,...this.properties.flatMap(l=>l.toFlatIds(n)),...this.methods.flatMap(l=>l.toFlatIds(n)),...this.abstractMethods.flatMap(l=>l.toFlatIds(n))])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,description:this.description,static:this.static,abstract:this.abstract,type:this.type,name:this.name}}toJSON(n=new Set){return n.has(this.id)?this.toReference():(n.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,static:this.static,abstract:this.abstract,properties:this.properties.map(a=>a.toJSON(n)),methods:this.methods.map(a=>a.toJSON(n)),abstractMethods:this.abstractMethods.map(a=>a.toJSON(n)),extends:this.extends.map(a=>a.toJSON(n))})}toReference(n=Oe){return{id:this.id+"--"+P.UUID.uuid()+"--ref",type:f.GenericReference,entityId:this.id,version:this.version,entityType:this.type}}toShallowJSON(n=Oe){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,abstract:this.abstract,static:this.static,properties:this.properties.map(a=>a.toReference()),methods:this.methods.map(a=>a.toReference()),abstractMethods:this.abstractMethods.map(a=>a.toReference()),extends:this.extends.map(a=>a.toReference())}}toFlatJSON(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[this.toShallowJSON(),...this.properties.flatMap(l=>l.toFlatJSON(n)),...this.methods.flatMap(l=>l.toFlatJSON(n)),...this.abstractMethods.flatMap(l=>l.toFlatJSON(n))])}toGenerationTarget(){return{id:this.id,type:this.type,name:this.name,description:this.description,static:this.static,abstract:this.abstract,extends:this.extends.map(n=>n.id)}}toFlatGenerationTarget(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[this.toGenerationTarget(),...this.properties.flatMap(l=>l.toFlatGenerationTarget(n)),...this.methods.flatMap(l=>l.toFlatGenerationTarget(n)),...this.abstractMethods.flatMap(l=>l.toFlatGenerationTarget(n))])}clearErrors(){return this.errors=[],this.properties.forEach(n=>n.clearErrors()),this.methods.forEach(n=>n.clearErrors()),this.abstractMethods.forEach(n=>n.clearErrors()),this}validate(){const n=gye(this);return this.errors=n,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors,...this.properties.flatMap(a=>a.getErrors()),...this.methods.flatMap(a=>a.getErrors()),...this.abstractMethods.flatMap(a=>a.getErrors())]}getShallowErrors(){return this.errors}getAllInteractiveMethods(){const n=[];return n.push(...this.methods),this.extends.filter(l=>l.type===f.BuiltInBaseEntity&&l.interactive||l.type===f.PrimitiveEntity).forEach(l=>{l instanceof qs&&n.push(...l.getAllInteractiveMethods())}),I(n)}};g($y,"repository",{APILoad:async(n,...a)=>null});let Ri=$y;function er(u,d){if(!u)throw new Error("Entity is null");const n=d.get(u.id);switch(u.type){case f.LiteralValue:return n||new Fs(u,d);case f.DefinitionEntity:return n||new ia(u,d);case f.PrimitiveEntity:return n||new Ri(u,d);case f.FunctionDeclaration:return n||new _a(u,d);case f.GlobalEvent:return n||new $a(u,d);case f.DataType:return n||new ts(u,d);case f.Property:return n||new Xn(u,d);case f.FunctionCall:return n||new Fa(u,d);case f.Condition:return n||new Ca(u,d);case f.Operation:return n||new Da(u,d);case f.VariableDeclaration:return n||new Va(u,d);case f.VariableInstance:return n||new Pa(u,d);case f.OutputMap:return n||new Ks(u,d);case f.ReturnDeclaration:return n||new wi(u,d);case f.ArgumentDeclaration:return n||new ea(u,d);case f.InputMap:return n||new Es(u,d);case f.Project:return n||new P(u);case f.InstalledProject:return n||new La(u,d);case f.ActionDescriptor:return n||new Lt(u,d);case f.ReturnStatement:return n||new ga(u,d);case f.Loop:return n||new Oa(u,d);case f.Search:return n||new Na(u,d);case f.ValueDescriptor:return n||new ks(u,d);case f.BuiltInBaseEntity:return n||new qs(u,d);case f.InternalCall:return n||new Ma(u,d);case f.ContinueStatement:return n||new Qr(u,d);case f.BreakStatement:return n||new Ba(u,d);case f.GenericReference:return d.get(u.entityId);default:throw new Error("Invalid entity type: "+u.type)}}function z(u,d){if(!u)throw new Error("Entity is null");const n=er(u,d);return n.subscribe(),n}function $ye(u,d){if(!u)throw new Error("Entity is null");switch(u.type){case f.LiteralValue:return Fs.fromGenerationTarget(u,d);case f.DefinitionEntity:return ia.fromGenerationTarget(u,d);case f.FunctionDeclaration:return _a.fromGenerationTarget(u,d);case f.GlobalEvent:return $a.fromGenerationTarget(u,d);case f.DataType:return ts.fromGenerationTarget(u,d);case f.Property:return Xn.fromGenerationTarget(u,d);case f.FunctionCall:return Fa.fromGenerationTarget(u,d);case f.Condition:return Ca.fromGenerationTarget(u,d);case f.Operation:return Da.fromGenerationTarget(u,d);case f.VariableDeclaration:return Va.fromGenerationTarget(u,d);case f.VariableInstance:return Pa.fromGenerationTarget(u,d);case f.OutputMap:return Ks.fromGenerationTarget(u,d);case f.ReturnDeclaration:return wi.fromGenerationTarget(u,d);case f.ArgumentDeclaration:return ea.fromGenerationTarget(u,d);case f.InputMap:return Es.fromGenerationTarget(u,d);case f.InstalledProject:return La.fromGenerationTarget(u,d);case f.ReturnStatement:return ga.fromGenerationTarget(u,d);case f.Loop:return Oa.fromGenerationTarget(u,d);case f.Search:return Na.fromGenerationTarget(u,d);case f.ActionDescriptor:return Lt.fromGenerationTarget(u,d);case f.ValueDescriptor:return ks.fromGenerationTarget(u,d);case f.InternalCall:return Ma.fromGenerationTarget(u,d);case f.ContinueStatement:return Qr.fromGenerationTarget(u,d);case f.BreakStatement:return Ba.fromGenerationTarget(u,d);default:throw new Error("Invalid entity type: "+u.type)}}const Oe={seenEntityMaps:new Map,seenEntities:new Set,timestamp:N().toISOString()};class bj{constructor(){g(this,"initialData")}}const oe={cascade:!1},Aj={APILoad:async(u,...d)=>null},Oye={APICreate:async(u,...d)=>u,APIUpdate:async(u,...d)=>u,APIDelete:async(u,...d)=>u,APIClone:async(u,...d)=>{},APILoadVersion:async(u,d,...n)=>null,...Aj};class Cye{}class Pye extends bj{}class Vye{}class Nye{}class Lye{}class Nb{}class Mye extends Nb{}class Bye extends Nb{}class Uye{}class dp{static initReadsValue(d){if(d.initialData.readsValue&&d.initialData.readsValue.type!==f.GenericReference)d.readsValue=z(d.initialData.readsValue,d.project);else if(d.initialData.readsValue&&d.initialData.readsValue.type===f.GenericReference){const n=ss(d.initialData.readsValue,d.project);n&&(d.readsValue=n)}if(d.readsValue){if(lr.includes(d.readsValue.type)){let n=d.parent;br.includes(n.type)||(n=n.parent);const a=d.type===f.InputMap&&d.parent.type===f.Loop;a&&(n=d.parent.parent),d.readsValue.setParent(n,null),d.readsValue.initChildren(null),n&&n.type!==f.Project&&!a&&n.detachedChildren.includes(d)?n.replaceDetachedChild(d,d.readsValue):n&&n.type!==f.Project&&!a&&n.subscribeDetachedChild(d.readsValue)}d.readsValue.addValueReader(d,null)}return d.readsValue}}class up{static initWritesValues(d,n){const a=d.initialData.writesValues.reduce((p,t)=>{if(t.type===f.GenericReference||d.writesValues.some(E=>E.id===t.id))return p;const m=z(t,d.project);return m.setValueWriter(d,null),lr.includes(m.type)&&(m.setParent(n,null),m.initChildren(null)),[...p,m]},[]),l=[...d.writesValues];return d.writesValues=I([...l,...a]),d.writesValues}}class jye{}class xye{constructor(d){g(this,"eventName");g(this,"callbacks",[]);this.eventName=d}on(d){if(typeof d!="function")throw new Error("Event callback must be a function");this.callbacks.includes(d)||this.callbacks.push(d)}off(d){if(typeof d!="function")throw new Error("Event callback must be a function");this.callbacks=this.callbacks.filter(n=>n!==d)}destroy(){this.callbacks=[]}}class Lb{constructor(){g(this,"subscribedEvents",{});g(this,"on",this._on);g(this,"emit",this._emit);g(this,"off",this._off);g(this,"destroy",this._destroy)}getEvent(d){return this.subscribedEvents[d]||(this.subscribedEvents[d]=new xye(d)),this.subscribedEvents[d]}_on(d,n){this.getEvent(d).on(n)}_emit(d,...n){const a=this.getEvent(d);a&&a.callbacks.forEach(l=>{l.apply(null,n)})}_off(d,n){const a=this.getEvent(d);a&&(n?a.off(n):(a.destroy(),delete this.subscribedEvents[d]))}_destroy(){Object.keys(this.subscribedEvents).forEach(d=>{this._off(d)}),this.subscribedEvents={}}}var ar=(u=>(u.PROJECT_INITIALIZED="project-initialized",u.CHANGE_SET_CLOSED="change-set-closed",u.EXPLICIT_DEFINITION_ENTITY_ADDED="explicit-definition-entity-added",u.EXPLICIT_DEFINITION_ENTITY_REMOVED="explicit-definition-entity-removed",u.EXPLICIT_DEFINITION_ENTITY_UPDATED="explicit-definition-entity-updated",u.PERSISTED_DEFINITION_ENTITY_ADDED="persisted-definition-entity-added",u.PERSISTED_DEFINITION_ENTITY_REMOVED="persisted-definition-entity-removed",u.PERSISTED_DEFINITION_ENTITY_UPDATED="persisted-definition-entity-updated",u.RELATIONAL_DATABASE_DEFINITION_ENTITY_ADDED="relational-database-definition-entity-added",u.RELATIONAL_DATABASE_DEFINITION_ENTITY_REMOVED="relational-database-definition-entity-removed",u.RELATIONAL_DATABASE_DEFINITION_ENTITY_UPDATED="relational-database-definition-entity-updated",u))(ar||{});function Fye(u,d){d.forEach(n=>{Object.getOwnPropertyNames(n.prototype).forEach(a=>{a!=="constructor"&&Object.defineProperty(u.prototype,a,Object.getOwnPropertyDescriptor(n.prototype,a))})})}class Ij extends nr{constructor(...d){super(...d),Object.assign(this,new Lb)}}Fye(Ij,[Lb]);const Fe=class Fe extends Ij{constructor(n){super(n);g(this,"initialData");g(this,"id");g(this,"type",f.Project);g(this,"name",null);g(this,"description",null);g(this,"x");g(this,"y");g(this,"entities",[]);g(this,"projects",[]);g(this,"functions",[]);g(this,"events",[]);g(this,"variableDeclarations",[]);g(this,"variableInstances",[]);g(this,"conditions",[]);g(this,"operations",[]);g(this,"functionCalls",[]);g(this,"loops",[]);g(this,"searches",[]);g(this,"primitives",[]);g(this,"builtInBaseEntities",[]);g(this,"operationDeclarations",[]);g(this,"globalEventActionDescriptors",[]);g(this,"loopDeclarations",[]);g(this,"loopDeclarationsBodies",[]);g(this,"conditionDeclarations",[]);g(this,"valueDescriptors",[]);g(this,"dataTypes",[]);g(this,"project");g(this,"instances",{});g(this,"builtInInstances",{});g(this,"deletedInstances",{});g(this,"errors",[]);g(this,"references",[]);g(this,"history",[]);g(this,"undoableStackValueIndex",-1);g(this,"detachedDependents",{});g(this,"knownVersions",null);g(this,"activeVersion",!1);g(this,"initialized",!1);g(this,"startedInitialization",!1);g(this,"onCloseChangeSetCallback",null);g(this,"onAddChangeSetCallback",null);g(this,"onDiscardChangeSetCallback",null);g(this,"onRequestActiveValueCallback",null);this.initialData=n,this.id=n.id,this.name=n.name,this.description=n.description,this.x=0,this.y=0,this.instances[this.id]=this;try{(!Fe.UUID||Fe.UUID.isBackup)&&(Fe.UUID=Qf==null?void 0:Qf()),Fe.UUID||(Fe.UUID={isBackup:!0,uuid:()=>Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15),fromUUID:a=>a})}catch(a){console.error("Error initializing UUID module",a),Fe.UUID={isBackup:!0,uuid:()=>Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15),fromUUID:l=>l}}}static injectUUIDModule(n){Fe.UUID=n}static new(n=null){return{id:Fe.UUID.uuid(),version:Fe.UUID.uuid(),createdAt:(n==null?void 0:n.timestamp)||N().toISOString(),author:(n==null?void 0:n.author)||Fe.sessionAuthor,previousVersion:null,deleted:!1,type:f.Project,name:"",description:"",entities:[],functions:[],events:[],projects:[],variableDeclarations:[],variableInstances:[],conditions:[],operations:[],functionCalls:[],loops:[],searches:[]}}static validateGenerationTarget(n,a){let l=JSON.parse(JSON.stringify(n));const p=[];return p.push(...ur(l)),{errors:p,modifiedData:l}}async closePendingChangeSets(){const n=this.history.find(a=>a.dirty&&!a.open);n&&await this.closeChangeSet(n)}onRequestActiveValue(n){this.onRequestActiveValueCallback=n}async onCloseChangeSet(n){this.onCloseChangeSetCallback=n,await this.closePendingChangeSets()}onAddChangeSet(n){this.onAddChangeSetCallback=n}onDiscardChangeSet(n){this.onDiscardChangeSetCallback=n}async closeChangeSet(n){const a=this.history.findIndex(t=>t.id===n.id),l=this.history.slice(0,a),p=l[l.length-1];if(!(p!=null&&p.dirty)&&this.onCloseChangeSetCallback){(await this.onCloseChangeSetCallback(n)).success&&(n.dirty=!1,this.emit("change-set-closed",n),this.closePendingChangeSets());return}}toLatestChangeSet(n,a,l,p=!1,t="here-this"){if(!this.history.length)return new F(this,n,a,l,p,t);const m=this.history[this.history.length-1];return m.open?m:this.addChangeSet(new F(this,n,a,l,p,t))}addChangeSet(n){var p,t;if(!this.history.length)return this.undoableStackValueIndex=XL(this.undoableStackValueIndex,this.history,n),(p=this.onAddChangeSetCallback)==null||p.call(this,n,this.undoableStackValueIndex),n;const a=this.history.find(m=>m.id===(n==null?void 0:n.id));if(a)return a;const l=this.history.find(m=>m.open);if(l)throw console.warn("Previous still open: ",l),console.warn("New change set: ",n),new Error(`There is already an open change-set with id '${l.id}'.`);return this.undoableStackValueIndex=XL(this.undoableStackValueIndex,this.history,n),(t=this.onAddChangeSetCallback)==null||t.call(this,n,this.undoableStackValueIndex),n}discardChangeSet(n){var l;const a=this.history.findIndex(p=>p.id===(n==null?void 0:n.id));return a!==-1&&(this.history.splice(a,1),this.undoableStackValueIndex=this.undoableStackValueIndex-1,(l=this.onDiscardChangeSetCallback)==null||l.call(this,n)),this}async inject(...n){return await Promise.all(n.map(a=>new Promise(async l=>{await a.init(this),l(null)}))),this}validateGeneratedUpdate(n){return{errors:[],modifiedData:n}}subscribeDependents(n){return n.forEach(a=>{this.detachedDependents[a.entity.id]||(this.detachedDependents[a.entity.id]=a)}),this}unsubscribeDependents(n){return n.forEach(a=>{this.detachedDependents[a.entity.id]&&delete this.detachedDependents[a.entity.id]}),this}syncDependents(n=this.project.addChangeSet(new F(this.project,Fe.sessionAuthor,N().toISOString(),this,!0,"sync-dependents"))){const a=[],l=[],p=[],t=[];return Object.values(this.detachedDependents).forEach(m=>{const E=m.entity.afterAllChildrenInitialized(n);a.push(...E.updated),l.push(...E.added),p.push(...E.removed),t.push(...E.affected)}),n==null||n.attemptAutoclose("sync-dependents",this.id),{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this}}onDetachedDependencyRemoved(n,a,l){const p=[],t=[],m=[],E=[];return{updated:I(p),added:I(t),removed:I(m),affected:I(E),self:this}}onDetachedDependencyRestored(n,a,l){const p=[],t=[],m=[],E=[];return{updated:I(p),added:I(t),removed:I(m),affected:I(E),self:this}}unsubscribeFromDependencies(){return this}subscribeToDependencies(){return this}increaseVersion(n){if(n&&!N(n).isValid())throw new Error(`The shared timestamp '${n}' is not a valid ISO 8601 date string.`);return n&&N(n).isSame(N(this.createdAt))?this:(this.previousVersion=this.version,this.version=Fe.UUID.uuid(),this.createdAt=N(n).toISOString()||N().toISOString(),this)}captureVersion(){var a;const n=((a=this.knownVersions)==null?void 0:a.get(this.version))||new Fe(this);return n.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,n):new Map([[this.version,n]]),n.entities=[...this.entities],n.projects=[...this.projects],n.functions=[...this.functions],n.events=[...this.events],n.variableDeclarations=[...this.variableDeclarations],n.variableInstances=[...this.variableInstances],n.conditions=[...this.conditions],n.operations=[...this.operations],n.functionCalls=[...this.functionCalls],n.loops=[...this.loops],n.searches=[...this.searches],this}recursiveCaptureUpstreamVersions(n){const a=[],l=[],p=[],t=[];return{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this}}async restoreVersion(n){var E;const a=[],l=[],p=[],t=[];if(this.version===n)return{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this};if(!this.knownVersions){const b=new Map;for(const[_,w]of this.knownVersions||new Map){if(b.set(_,w),w.activeVersion=!1,w.knownVersions)for(const[V,B]of w.knownVersions)b.set(V,B);w.knownVersions=null}}let m=(E=this.knownVersions)==null?void 0:E.get(n);if(!m){const b=await this.APILoadVersion({},n);if(!b)throw new Error(`Version with id '${n}' for entity with id '${this.id}' not found.`);m=new Fe(b)}return this.metaSync(m.toShallowJSON(),null),this.previousVersion=m.previousVersion,this.version=m.version,this.createdAt=m.createdAt,this.author=m.author,this.deleted=m.deleted,this.entities=m.entities,this.projects=m.projects,this.functions=m.functions,this.events=m.events,this.variableDeclarations=m.variableDeclarations,this.variableInstances=m.variableInstances,this.conditions=m.conditions,this.operations=m.operations,this.functionCalls=m.functionCalls,this.loops=m.loops,this.searches=m.searches,{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this}}updateWithShallowTransfer(n,a=this.project.addChangeSet(new F(this.project,Fe.sessionAuthor,N().toISOString(),this,!0,"update-with-shallow-transfer"))){return this.metaSync(n,a),this.version=n.version,this.createdAt=n.createdAt,this.author=n.author,this.deleted=n.deleted,this.previousVersion=n.previousVersion,this.captureVersion(),this.subscribeToDependencies(),a==null||a.attemptAutoclose("update-with-shallow-transfer",this.id),this}hydrateAncestors(){const n=[],a=[],l=[],p=[];return{updated:I(n),added:I(a),removed:I(l),affected:I(p),self:this}}afterAllChildrenInitialized(n=null){const a=[],l=[],p=[],t=[];return this.initialized||(this.initialized=!0,this.emit("project-initialized",this,n)),this.validate(),this.captureVersion(),{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this}}addSelfToProject(n){const a=[],l=[],p=[],t=[];return this.subscribe(),this.subscribeToDependencies(),{updated:I(a),added:I(l),removed:I(p),affected:I(t),self:this}}get instancesList(){return Object.values(this.instances)}isOperationDeclaration(n){return this.operationDeclarations.includes(n)}isGlobalEventActionDescriptor(n){return this.globalEventActionDescriptors.includes(n)}isLoopDeclaration(n){return this.loopDeclarations.includes(n)}isConditionDeclaration(n){return this.conditionDeclarations.includes(n)}initChildren(n=this.project.addChangeSet(new F(this.project,Fe.sessionAuthor,N().toISOString(),this,!0,"init-children"))){return this.initialized||this.startedInitialization?this:(this.startedInitialization=!0,this.entities=this.initialData.entities.map(a=>{const l=z(a,this);return l.setParent(this,null),l.initChildren(n),l}),this.projects=this.initialData.projects.map(a=>{const l=z(a,this);return l.setParent(this,null),l.initChildren(n),l}),this.variableDeclarations=this.initialData.variableDeclarations.map(a=>{const l=z(a,this);return l.setParent(this,null),l.initChildren(n),l}),this.variableInstances=this.initialData.variableInstances.map(a=>{const l=z(a,this);return l.setParent(this,null),l.initChildren(n),l}),this.conditions=this.initialData.conditions.map(a=>{const l=z(a,this);return l.setParent(this,null),l.initChildren(n),l}),this.operations=this.initialData.operations.map(a=>{const l=z(a,this);return l.setParent(this,null),l.initChildren(n),l}),this.functions=this.initialData.functions.map(a=>{const l=z(a,this);return l.setParent(this,null),l.initChildren(n),l}),this.events=this.initialData.events.map(a=>{const l=z(a,this);return l.setParent(this,null),l.initChildren(n),l}),this.functionCalls=this.initialData.functionCalls.map(a=>{const l=z(a,this);return l.setParent(this,null),l.initChildren(n),l}),this.loops=this.initialData.loops.map(a=>{const l=z(a,this);return l.setParent(this,null),l.initChildren(n),l}),this.searches=this.initialData.searches.map(a=>{const l=z(a,this);return l.setParent(this,null),l.initChildren(n),l}),this.attachOrphanReferences(),this.subscribeToDependencies(),this.afterAllChildrenInitialized(n),n==null||n.attemptAutoclose("init-children",this.id),this)}subscribeInstance(n){return(!this.instances[n.id]||this.instances[n.id]!==n)&&(this.instances[n.id]=n),this}subscribeDeletedInstance(n){return(!this.deletedInstances[n.id]||this.deletedInstances[n.id]!==n)&&(this.deletedInstances[n.id]=n),this}subscribeBuiltInInstance(n){return(!this.builtInInstances[n.id]||this.builtInInstances[n.id]!==n)&&(this.builtInInstances[n.id]=n),this}subscribe(){return this}unsubscribe(){return this}unsubscribeInstance(n){return delete this.instances[n.id],this}unsubscribeDeletedInstance(n){return delete this.deletedInstances[n.id],this}findSubscribedBuiltInInstance(n){return this.builtInInstances[n.id]||null}get(n){return this.instances[n]||this.builtInInstances[n]||null}getDeleted(n){return this.deletedInstances[n]||null}getManaged(n){return this.getBuiltIn(n)?null:this.instances[n]||null}getBuiltIn(n){return this.builtInInstances[n]||null}findSubscribedInstanceFromReference(n){return this.instances[n.entityId]||null}findSubscribedBuiltInInstanceFromReference(n){return this.builtInInstances[n.entityId]||null}metaSync(n,a=this.project.addChangeSet(new F(this.project,Fe.sessionAuthor,N().toISOString(),this,!0,"meta-sync"))){const l=cr(this,n),p=this.toMeta();return this.name=n.name!==void 0?n.name:p.name,this.description=n.description!==void 0?n.description:p.description,this.x=n.x||p.x,this.y=n.y||p.y,super.metaSync(n),n.deleted===!0&&!p.deleted?a==null||a.add(this,G.Removed):n.deleted===!1&&p.deleted?a==null||a.add(this,G.Added):l&&(a==null||a.add(this,G.Updated)),a==null||a.attemptAutoclose("meta-sync",this.id),this}async APILoad(n=oe,...a){return await Fe.repository.APILoad(this.id,...a),this}async APICreate(n=oe,...a){return await Fe.repository.APICreate(this.toShallowJSON(),...a),this}async APIUpdate(n=oe,...a){return await Fe.repository.APIUpdate(this.toShallowJSON(),...a),this}async APIDelete(n=oe,...a){return await Fe.repository.APIDelete(this.toShallowJSON(),...a),this}async APIClone(n=oe,...a){return await Fe.repository.APIClone(this.id,...a),this}async APILoadVersion(n=oe,a,...l){return await Fe.repository.APILoadVersion(this.id,a,...l)}remove({ignoreUpstream:n}={ignoreUpstream:!1},a=this.project.addChangeSet(new F(this.project,Fe.sessionAuthor,N().toISOString(),this,!0,"remove-entity"))){return{added:[],updated:[],removed:[],affected:[],self:this}}restore({}={},n=this.project.addChangeSet(new F(this.project,Fe.sessionAuthor,N().toISOString(),this,!0,"restore-entity"))){return{added:[],updated:[],removed:[],affected:[],self:this}}getAllBuiltInIds(){const n=new Set;return[...this.primitives.flatMap(a=>a.toFlatIds(n)),...this.builtInBaseEntities.flatMap(a=>a.toFlatIds(n)),...this.operationDeclarations.flatMap(a=>a.toFlatIds(n)),...this.globalEventActionDescriptors.flatMap(a=>a.toFlatIds(n)),...this.loopDeclarations.flatMap(a=>a.toFlatIds(n)),...this.conditionDeclarations.flatMap(a=>a.toFlatIds(n)),...this.valueDescriptors.flatMap(a=>a.toFlatIds(n)),...this.dataTypes.flatMap(a=>a.toFlatIds(n))]}getAllBuiltIn(){const n=new Set;return[...this.primitives.flatMap(a=>a.toFlat(n)),...this.builtInBaseEntities.flatMap(a=>a.toFlat(n)),...this.operationDeclarations.flatMap(a=>a.toFlat(n)),...this.globalEventActionDescriptors.flatMap(a=>a.toFlat(n)),...this.loopDeclarations.flatMap(a=>a.toFlat(n)),...this.conditionDeclarations.flatMap(a=>a.toFlat(n)),...this.valueDescriptors.flatMap(a=>a.toFlat(n)),...this.dataTypes.flatMap(a=>a.toFlat(n))]}toFlat(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[this,...this.entities.flatMap(l=>l.toFlat(n)),...this.functions.flatMap(l=>l.toFlat(n)),...this.events.flatMap(l=>l.toFlat(n)),...this.projects.flatMap(l=>l.toFlat(n)),...this.variableDeclarations.flatMap(l=>l.toFlat(n)),...this.variableInstances.flatMap(l=>l.toFlat(n)),...this.conditions.flatMap(l=>l.toFlat(n)),...this.operations.flatMap(l=>l.toFlat(n)),...this.functionCalls.flatMap(l=>l.toFlat(n)),...this.loops.flatMap(l=>l.toFlat(n)),...this.searches.flatMap(l=>l.toFlat(n))])}toFlatIds(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[this.id,...this.entities.flatMap(l=>l.toFlatIds(n)),...this.functions.flatMap(l=>l.toFlatIds(n)),...this.events.flatMap(l=>l.toFlatIds(n)),...this.projects.flatMap(l=>l.toFlatIds(n)),...this.variableDeclarations.flatMap(l=>l.toFlatIds(n)),...this.variableInstances.flatMap(l=>l.toFlatIds(n)),...this.conditions.flatMap(l=>l.toFlatIds(n)),...this.operations.flatMap(l=>l.toFlatIds(n)),...this.functionCalls.flatMap(l=>l.toFlatIds(n)),...this.loops.flatMap(l=>l.toFlatIds(n)),...this.searches.flatMap(l=>l.toFlatIds(n))])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,description:this.description,type:this.type,name:this.name}}toJSON(n=new Set){return n.has(this.id)?this.toReference():(n.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,entities:this.entities.map(a=>a.toJSON(n)),variableDeclarations:this.variableDeclarations.map(a=>a.toJSON(n)),variableInstances:this.variableInstances.map(a=>a.toJSON(n)),conditions:this.conditions.map(a=>a.toJSON(n)),operations:this.operations.map(a=>a.toJSON(n)),loops:this.loops.map(a=>a.toJSON(n)),searches:this.searches.map(a=>a.toJSON(n)),functions:this.functions.map(a=>a.toJSON(n)),events:this.events.map(a=>a.toJSON(n)),projects:this.projects.map(a=>a.toJSON(n)),functionCalls:this.functionCalls.map(a=>a.toJSON(n))})}toJSONClone(n={uuidStrategy:"uuid"}){const a=new Map,l=new Set,p=this.getAllBuiltInIds();return Object.keys(this.instances).forEach(t=>{if(p.includes(t)){a.set(t,t);return}a.set(t,Fe.UUID.uuid())}),l.add(this.id),{id:a.get(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,entities:this.entities.map(t=>t.toJSONClone({...n,seenEntityMaps:a,seenEntities:l,newId:null})),projects:this.projects.map(t=>t.toJSONClone({...n,seenEntityMaps:a,seenEntities:l,newId:null})),variableDeclarations:this.variableDeclarations.map(t=>t.toJSONClone({...n,seenEntityMaps:a,seenEntities:l,newId:null})),variableInstances:this.variableInstances.map(t=>t.toJSONClone({...n,seenEntityMaps:a,seenEntities:l,newId:null})),conditions:this.conditions.map(t=>t.toJSONClone({...n,seenEntityMaps:a,seenEntities:l,newId:null})),operations:this.operations.map(t=>t.toJSONClone({...n,seenEntityMaps:a,seenEntities:l,newId:null})),functions:this.functions.map(t=>t.toJSONClone({...n,seenEntityMaps:a,seenEntities:l,newId:null})),events:this.events.map(t=>t.toJSONClone({...n,seenEntityMaps:a,seenEntities:l,newId:null})),functionCalls:this.functionCalls.map(t=>t.toJSONClone({...n,seenEntityMaps:a,seenEntities:l,newId:null})),loops:this.loops.map(t=>t.toJSONClone({...n,seenEntityMaps:a,seenEntities:l,newId:null})),searches:this.searches.map(t=>t.toJSONClone({...n,seenEntityMaps:a,seenEntities:l,newId:null}))}}toReference(n=Oe){var l;let a=this.id;return(l=n.seenEntityMaps)!=null&&l.has(this.id)&&(a=n.seenEntityMaps.get(this.id)),{id:a+"--"+Fe.UUID.uuid()+"--ref",type:f.GenericReference,entityId:a,version:this.version,entityType:this.type}}toShallowJSON(n=Oe){var l;let a=this.id;return(l=n.seenEntityMaps)!=null&&l.has(this.id)&&(a=n.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,description:this.description,entities:this.entities.map(p=>p.toReference(n)),functions:this.functions.map(p=>p.toReference(n)),events:this.events.map(p=>p.toReference(n)),projects:this.projects.map(p=>p.toReference(n)),variableDeclarations:this.variableDeclarations.map(p=>p.toReference(n)),variableInstances:this.variableInstances.map(p=>p.toReference(n)),conditions:this.conditions.map(p=>p.toReference(n)),operations:this.operations.map(p=>p.toReference(n)),functionCalls:this.functionCalls.map(p=>p.toReference(n)),loops:this.loops.map(p=>p.toReference(n)),searches:this.searches.map(p=>p.toReference(n))}}toFlatJSON(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[this.toShallowJSON(),...this.entities.flatMap(l=>l.toFlatJSON(n)),...this.functions.flatMap(l=>l.toFlatJSON(n)),...this.events.flatMap(l=>l.toFlatJSON(n)),...this.projects.flatMap(l=>l.toFlatJSON(n)),...this.variableDeclarations.flatMap(l=>l.toFlatJSON(n)),...this.variableInstances.flatMap(l=>l.toFlatJSON(n)),...this.conditions.flatMap(l=>l.toFlatJSON(n)),...this.operations.flatMap(l=>l.toFlatJSON(n)),...this.functionCalls.flatMap(l=>l.toFlatJSON(n)),...this.loops.flatMap(l=>l.toFlatJSON(n)),...this.searches.flatMap(l=>l.toFlatJSON(n))])}toGenerationTarget(){return{id:this.id,type:this.type,name:this.name,description:this.description}}toFlatGenerationTarget(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[...this.entities.flatMap(l=>l.toFlatGenerationTarget(n)),...this.functions.flatMap(l=>l.toFlatGenerationTarget(n)),...this.events.flatMap(l=>l.toFlatGenerationTarget(n)),...this.projects.flatMap(l=>l.toFlatGenerationTarget(n)),...this.variableDeclarations.flatMap(l=>l.toFlatGenerationTarget(n)),...this.variableInstances.flatMap(l=>l.toFlatGenerationTarget(n)),...this.conditions.flatMap(l=>l.toFlatGenerationTarget(n)),...this.operations.flatMap(l=>l.toFlatGenerationTarget(n)),...this.functionCalls.flatMap(l=>l.toFlatGenerationTarget(n)),...this.loops.flatMap(l=>l.toFlatGenerationTarget(n)),...this.searches.flatMap(l=>l.toFlatGenerationTarget(n))])}clearErrors(){return this.errors=[],this.entities.forEach(n=>n.clearErrors()),this.projects.forEach(n=>n.clearErrors()),this.functions.forEach(n=>n.clearErrors()),this.events.forEach(n=>n.clearErrors()),this.variableDeclarations.forEach(n=>n.clearErrors()),this.variableInstances.forEach(n=>n.clearErrors()),this.conditions.forEach(n=>n.clearErrors()),this.operations.forEach(n=>n.clearErrors()),this.functionCalls.forEach(n=>n.clearErrors()),this.loops.forEach(n=>n.clearErrors()),this.searches.forEach(n=>n.clearErrors()),this}validate(){const n=Yde(),a=this.toJSON();return n.safeParse(a),this.validateChildren(),{success:!0,error:null,data:a}}validateChildren(){this.entities.forEach(n=>n.validate()),this.projects.forEach(n=>n.validate()),this.functions.forEach(n=>n.validate()),this.events.forEach(n=>n.validate()),this.variableDeclarations.forEach(n=>n.validate()),this.variableInstances.forEach(n=>n.validate()),this.conditions.forEach(n=>n.validate()),this.operations.forEach(n=>n.validate()),this.functionCalls.forEach(n=>n.validate()),this.loops.forEach(n=>n.validate()),this.searches.forEach(n=>n.validate())}getErrors(){return[...this.errors,...this.entities.flatMap(a=>a.getErrors()),...this.projects.flatMap(a=>a.getErrors()),...this.functions.flatMap(a=>a.getErrors()),...this.events.flatMap(a=>a.getErrors()),...this.variableDeclarations.flatMap(a=>a.getErrors()),...this.variableInstances.flatMap(a=>a.getErrors()),...this.conditions.flatMap(a=>a.getErrors()),...this.operations.flatMap(a=>a.getErrors()),...this.functionCalls.flatMap(a=>a.getErrors()),...this.loops.flatMap(a=>a.getErrors()),...this.searches.flatMap(a=>a.getErrors())]}getShallowErrors(){return this.errors}clone(){return this}getDefinitionEntity(n){return this.entities.find(a=>a.id===n)||null}addDefinitionEntity(n){return this.entities.includes(n)||this.entities.push(n),n}addFunctionDeclaration(n){return this.functions.includes(n)||this.functions.push(n),n}addFunctionCall(n){return this.functionCalls.includes(n)||this.functionCalls.push(n),n}addVariableDeclaration(n){return this.variableDeclarations.includes(n)||this.variableDeclarations.push(n),n}addVariableInstance(n){return this.variableInstances.includes(n)||this.variableInstances.push(n),n}addInstalledProject(n){return this.projects.includes(n)||this.projects.push(n),this}addGlobalEvent(n){return this.events.includes(n)||this.events.push(n),this}addCondition(n){return this.conditions.includes(n)||this.conditions.push(n),this}addOperation(n){return this.operations.includes(n)||this.operations.push(n),this}addLoop(n){return this.loops.includes(n)||this.loops.push(n),this}addSearch(n){return this.searches.includes(n)||this.searches.push(n),this}removeDefinitionEntity(n){const a=this.entities.findIndex(l=>l.id===n.id);if(a>-1){const l=this.entities[a];return this.entities.splice(a,1),l}return null}removeCondition(n){const a=this.conditions.findIndex(l=>l.id===n.id);if(a>-1){const l=this.conditions[a];return this.conditions.splice(a,1),l}return null}removeOperation(n){const a=this.operations.findIndex(l=>l.id===n.id);if(a>-1){const l=this.operations[a];return this.operations.splice(a,1),l}return null}removeLoop(n){const a=this.loops.findIndex(l=>l.id===n.id);if(a>-1){const l=this.loops[a];return this.loops.splice(a,1),l}return null}removeSearch(n){const a=this.searches.findIndex(l=>l.id===n.id);if(a>-1){const l=this.searches[a];return this.searches.splice(a,1),l}return null}removeFunctionCall(n){const a=this.functionCalls.findIndex(l=>l.id===n.id);if(a>-1){const l=this.functionCalls[a];return this.functionCalls.splice(a,1),l}return null}removeVariableInstance(n){const a=this.variableInstances.findIndex(l=>l.id===n.id);if(a>-1){const l=this.variableInstances[a];return this.variableInstances.splice(a,1),l}return null}removeVariableDeclaration(n){const a=this.variableDeclarations.findIndex(l=>l.id===n.id);if(a>-1){const l=this.variableDeclarations[a];return this.variableDeclarations.splice(a,1),l}return null}removeFunctionDeclaration(n){const a=this.functions.findIndex(l=>l.id===n.id);if(a>-1){const l=this.functions[a];return this.functions.splice(a,1),l}return null}removeInstalledProject(n){const a=this.projects.findIndex(l=>l.id===n.id);if(a>-1){const l=this.projects[a];return this.projects.splice(a,1),l}return null}removeGlobalEvent(n){const a=this.events.findIndex(l=>l.id===n.id);if(a>-1){const l=this.events[a];return this.events.splice(a,1),l}return null}removeTopLevelVariableDeclaration(n){if(n.type!==f.VariableDeclaration)return null;const a=this.variableDeclarations.findIndex(l=>l.id===n.id);if(a>-1){const l=this.variableDeclarations[a];return this.variableDeclarations.splice(a,1),l}return null}getEntryPoints(){return[...this.functions,...this.events,...this.entities.flatMap(a=>a.methods)]}getTerminationStatements(){return[...this.getEntryPoints().reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.ReturnStatement||t.type===f.ContinueStatement||t.type===f.BreakStatement)]},[])]}getFunctionDeclaration(n){return this.functions.find(a=>a.id===n)||null}getConditions(){return[...this.conditions,...this.getEntryPoints().reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.Condition)]},[]),...this.functionCalls.reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.Condition)]},[]),...this.operations.reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.Condition)]},[]),...this.loops.reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.Condition)]},[]),...this.searches.reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.Condition)]},[])]}getOperations(){return[...this.operations,...this.getEntryPoints().reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.Operation)]},[]),...this.functionCalls.reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.Operation)]},[]),...this.conditions.reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.Operation)]},[]),...this.loops.reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.Operation)]},[]),...this.searches.reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.Operation)]},[])]}getFunctionCalls(){return[...this.functionCalls,...this.getEntryPoints().reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.FunctionCall)]},[]),...this.conditions.reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.FunctionCall)]},[]),...this.operations.reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.FunctionCall)]},[]),...this.loops.reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.FunctionCall)]},[]),...this.searches.reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.FunctionCall)]},[])]}getVariables(){return[...this.variableDeclarations,...this.getEntryPoints().reduce((a,l)=>{const p=kt(l);return[...a,...p]},[]),...this.functionCalls.reduce((a,l)=>{const p=kt(l);return[...a,...p]},[]),...this.conditions.reduce((a,l)=>{const p=kt(l);return[...a,...p]},[]),...this.operations.reduce((a,l)=>{const p=kt(l);return[...a,...p]},[]),...this.loops.reduce((a,l)=>{const p=kt(l);return[...a,...p]},[]),...this.searches.reduce((a,l)=>{const p=kt(l);return[...a,...p]},[])]}getVariableInstances(){return[...this.variableInstances,...this.getEntryPoints().reduce((a,l)=>{const t=kt(l).filter(m=>m.type===f.VariableInstance);return[...a,...t]},[]),...this.functionCalls.reduce((a,l)=>{const t=kt(l).filter(m=>m.type===f.VariableInstance);return[...a,...t]},[]),...this.conditions.reduce((a,l)=>{const t=kt(l).filter(m=>m.type===f.VariableInstance);return[...a,...t]},[]),...this.operations.reduce((a,l)=>{const t=kt(l).filter(m=>m.type===f.VariableInstance);return[...a,...t]},[]),...this.loops.reduce((a,l)=>{const t=kt(l).filter(m=>m.type===f.VariableInstance);return[...a,...t]},[]),...this.searches.reduce((a,l)=>{const t=kt(l).filter(m=>m.type===f.VariableInstance);return[...a,...t]},[])]}getVariableDeclarations(){return I([...this.variableDeclarations,...this.getEntryPoints().reduce((a,l)=>{const t=kt(l).filter(m=>m.type===f.VariableDeclaration);return[...a,...t]},[]),...this.functionCalls.reduce((a,l)=>{const t=kt(l).filter(m=>m.type===f.VariableDeclaration);return[...a,...t]},[]),...this.conditions.reduce((a,l)=>{const t=kt(l).filter(m=>m.type===f.VariableDeclaration);return[...a,...t]},[]),...this.operations.reduce((a,l)=>{const t=kt(l).filter(m=>m.type===f.VariableDeclaration);return[...a,...t]},[]),...this.loops.reduce((a,l)=>{const t=kt(l).filter(m=>m.type===f.VariableDeclaration);return[...a,...t]},[]),...this.searches.reduce((a,l)=>{const t=kt(l).filter(m=>m.type===f.VariableDeclaration);return[...a,...t]},[])])}getLoops(){return[...this.loops,...this.getEntryPoints().reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.Loop)]},[]),...this.functionCalls.reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.Loop)]},[]),...this.conditions.reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.Loop)]},[]),...this.operations.reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.Loop)]},[]),...this.searches.reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.Loop)]},[])]}getSearches(){return[...this.searches,...this.getEntryPoints().reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.Search)]},[]),...this.functionCalls.reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.Search)]},[]),...this.conditions.reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.Search)]},[]),...this.operations.reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.Search)]},[]),...this.loops.reduce((a,l)=>{const p=nt(l);return[...a,...p.filter(t=>t.type===f.Search)]},[])]}attachOrphanReferences(){const n=this.getVariableInstances(),a=this.getVariableDeclarations();return n.forEach(l=>{if(!l.declaration){const p=l.initialData,t=p.declaration.entityId||p.declaration.id,m=a.find(E=>E.id===t);m&&l.setDeclaration(m)}}),this}getBuiltInPersistedEntity(){return this.builtInBaseEntities.find(n=>n.name===ge.PERSISTED_ENTITY)||null}requestActiveValue(n){var l;const a=(l=this.onRequestActiveValueCallback)==null?void 0:l.call(this,n);return a?a||null:n.getDefaultValue()}undo(){console.log("Undoing, from: ",this.undoableStackValueIndex),this.undoableStackValueIndex=this.undoableStackValueIndex-1,console.log("To: ",this.undoableStackValueIndex);const n=this.history[this.undoableStackValueIndex+1],a=this.history[this.undoableStackValueIndex];return console.log("Current change set: ",n),console.log("Change set to restore: ",a),zL(n||"initial",a||"initial",this)}redo(){console.log("Undoing, from: ",this.undoableStackValueIndex),this.undoableStackValueIndex=this.undoableStackValueIndex+1,console.log("To: ",this.undoableStackValueIndex);const n=this.history[this.undoableStackValueIndex-1],a=this.history[this.undoableStackValueIndex];return console.log("Current change set: ",n),console.log("Change set to restore: ",a),zL(n||"initial",a||"initial",this)}applyExternalChangeSet(n){const a=n.payload,l=this.addChangeSet(new F(this,n.author,n.timestamp,this)),p=a.updated[this.id];if(!p)throw new Error("Project root not found in change set transfer. Cannot apply changes.");const t={...a.added,...a.updated,...a.removed},m=a.seenEntities.filter(b=>!a.affected.includes(b));m.forEach(b=>{var _;if(!t[b]){console.warn(`Entity '${b}' not found in change set transfer. Cannot apply changes.`);const w=(_=this.get(b))==null?void 0:_.toShallowJSON();throw w?console.warn("Entity in project: ",w):console.warn("Entity not in project"),new Error(`Entity '${b}' not found in change set transfer. Cannot apply changes.`)}});const E=new Ga(p);return E.flatRecord=t,E.order=m,E.orderEntities(),console.log("All entities: ",E.order.map((b,_)=>`${_+1}: ${t[b].type} - ${b}`).join(`,
|
|
401
401
|
`)),console.log("Persisting new additions"),E.visit(async(b,_)=>{if(a.added[b.id]){console.log("Adding: ",b.id);try{const w=z(b,this);if(w.hydrateAncestors(),w.addSelfToProject(l),!this.get(b.id))throw new Error(`Entity ${b.id} was not added to the project`)}catch(w){console.error("Error: ",w),console.error("Errored entity: ",b)}}}),console.log("Persisting updates"),E.visit(async(b,_)=>{if(a.updated[b.id]){console.log("Updating: ",b.id);try{const w=this.get(b.id);w&&w.updateWithShallowTransfer(b,l)}catch(w){console.error("Error: ",w),console.error("Errored entity: ",b)}}}),console.log("Persisting removals"),E.visit(async(b,_)=>{if(a.removed[b.id]){console.log("Removing: ",b.id);try{const w=this.get(b.id);w&&w.remove({ignoreUpstream:!1},l)}catch(w){console.error("Error: ",w),console.error("Errored entity: ",b)}}}),this}toFullProjectTransfer(){const n=new Ga(this),a={};return n.visit(l=>{const p=l.toShallowJSON();a[l.id]=p}),{order:n.order,size:n.order.length,record:a}}};g(Fe,"sessionAuthor","1"),g(Fe,"UUID",{isBackup:!0,uuid:()=>Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15),fromUUID:n=>n}),g(Fe,"repository",{APICreate:async(n,...a)=>n,APIUpdate:async(n,...a)=>n,APIDelete:async(n,...a)=>n,APIClone:async(n,...a)=>{},APILoad:async(n,...a)=>null,APILoadVersion:async(n,a,...l)=>null}),g(Fe,"type",f.Project),g(Fe,"USER_MANAGED_PARENT_TYPES",[]),g(Fe,"PARENT_TYPES",[...Fe.USER_MANAGED_PARENT_TYPES]),g(Fe,"MUTABLE_BASE_PROPERTIES",["name","description"]),g(Fe,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),g(Fe,"BASE_PROPERTIES",[...Fe.MUTABLE_BASE_PROPERTIES,...Fe.INMUTABLE_BASE_PROPERTIES]),g(Fe,"MUTABLE_META_PROPERTIES",[...Fe.MUTABLE_BASE_PROPERTIES,"x","y"]),g(Fe,"INMUTABLE_META_PROPERTIES",[...Fe.INMUTABLE_BASE_PROPERTIES]),g(Fe,"META_PROPERTIES",[...Fe.MUTABLE_META_PROPERTIES,...Fe.INMUTABLE_META_PROPERTIES]),g(Fe,"MUTABLE_UPSTREAM_PROPERTIES",[]),g(Fe,"INMUTABLE_UPSTREAM_PROPERTIES",["primitives","builtInBaseEntities","operationDeclarations","globalEventActionDescriptors","loopDeclarations","builtInInstances"]),g(Fe,"UPSTREAM_PROPERTIES",[...Fe.MUTABLE_UPSTREAM_PROPERTIES,...Fe.INMUTABLE_UPSTREAM_PROPERTIES]),g(Fe,"MUTABLE_DOWNSTREAM_PROPERTIES",["entities","projects","functions","events","variableDeclarations","variableInstances","conditions","operations","functionCalls","loops","searches"]),g(Fe,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),g(Fe,"DOWNSTREAM_PROPERTIES",[...Fe.MUTABLE_DOWNSTREAM_PROPERTIES,...Fe.INMUTABLE_DOWNSTREAM_PROPERTIES]),g(Fe,"PROPERTIES",[...Fe.META_PROPERTIES,...Fe.UPSTREAM_PROPERTIES,...Fe.DOWNSTREAM_PROPERTIES]);let P=Fe;var wj=(u=>(u.PersistChangeSet="persist-change-set",u.CreateSingle="create-single",u.CreateBulk="create-bulk",u.CreateSingleNested="create-single-nested",u.CreateBulkNested="create-bulk-nested",u.Update="update",u.Clone="clone",u.Delete="delete",u.Load="load",u.LoadNested="load-nested",u.LoadVersion="load-version",u))(wj||{});class Rj extends Lt{constructor(n){super(Vs,n);g(this,"id",Jt.Parallel);g(this,"name",Jt.Parallel);g(this,"description","Execute a list of actions one after the other");g(this,"version","1");g(this,"autoexecutable",!0);g(this,"initialData",Vs);g(this,"type",f.ActionDescriptor);g(this,"inputs",[]);g(this,"outputs",[]);g(this,"error",null);g(this,"project");this.project=n,this.inputs=Vs.inputs.map(a=>{const l=z(a,this.project);return l.setParent(this,null),l.initChildren(null),l}),this.outputs=Vs.outputs.map(a=>{const l=z(a,this.project);return l.setParent(this,null),l.initChildren(null),l}),this.error=Vs.error?z(Vs.error,this.project):null}}class _j extends Lt{constructor(n){super(mi,n);g(this,"id",mi.id);g(this,"name",mi.name);g(this,"description",mi.description);g(this,"version",mi.version);g(this,"autoexecutable",!1);g(this,"initialData",mi);g(this,"type",f.ActionDescriptor);g(this,"inputs",[]);g(this,"outputs",[]);g(this,"error",null);g(this,"project");this.project=n,this.inputs=mi.inputs.map(a=>{const l=z(a,this.project);return l.setParent(this,null),l.initChildren(null),l}),this.outputs=mi.outputs.map(a=>{const l=z(a,this.project);return l.setParent(this,null),l.initChildren(null),l}),this.error=mi.error?z(mi.error,this.project):null}}class Dj extends Lt{constructor(n){super(Fn,n);g(this,"id",Jt.Sequential);g(this,"name",Jt.Sequential);g(this,"description","Execute a list of actions one after the other");g(this,"version","1");g(this,"autoexecutable",!0);g(this,"initialData",Fn);g(this,"type",f.ActionDescriptor);g(this,"inputs",[]);g(this,"outputs",[]);g(this,"error",null);g(this,"project");this.project=n,this.inputs=Fn.inputs.map(a=>{const l=z(a,this.project);return l.setParent(this,null),l.initChildren(null),l}),this.outputs=Fn.outputs.map(a=>{const l=z(a,this.project);return l.setParent(this,null),l.initChildren(null),l}),this.error=Fn.error?z(Fn.error,this.project):null}}class Gye extends Lt{constructor(d){super(eu,d)}}class Kye extends Lt{constructor(d){super(lo,d)}}class kye extends Lt{constructor(n){super(uo,n);g(this,"autoexecutable",!0)}getEntityToMatchInputMap(n){return n.inputs.find(a=>{var l;return((l=a.declaration)==null?void 0:l.id)===pe.operation[Wt.Validate].inputs.entityToMatch.id})||null}getDataToValidateInputMap(n){return n.inputs.find(a=>{var l;return((l=a.declaration)==null?void 0:l.id)===pe.operation[Wt.Validate].inputs.dataToValidate.id})||null}getOutputDataOutputMap(n){return n.outputs.find(a=>{var l;return((l=a.declaration)==null?void 0:l.id)===pe.operation[Wt.Validate].outputs.outputEntity.id})||null}getEntityToMatch(n,a=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"get-entity-to-match-validate-data"))){const l=this.project.requestActiveValue(n),p=l==null?void 0:l.valueAsTypeSingle;return a==null||a.attemptAutoclose("get-entity-to-match-validate-data",this.id),p}syncOperationInstance(n,a=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"sync-operation-instance-validate-data"))){const l=[],p=[],t=[],m=[],E=this.getEntityToMatchInputMap(n);if(E){const{added:w,updated:V,removed:B,affected:K}=this.syncEntityToMatchInputMapDataType(E,a);l.push(...V),p.push(...w),t.push(...B),m.push(...K)}const b=this.getDataToValidateInputMap(n);if(b){const{added:w,updated:V,removed:B,affected:K}=this.syncDataToValidateInputMapDataType(b,a);l.push(...V),p.push(...w),t.push(...B),m.push(...K)}const _=this.getOutputDataOutputMap(n);if(_){const{added:w,updated:V,removed:B,affected:K}=this.syncOutputDataOutputMapDataType(_,a);l.push(...V),p.push(...w),t.push(...B),m.push(...K)}return a==null||a.attemptAutoclose("sync-operation-instance-validate-data",this.id),{updated:I(l),added:I(p),removed:I(t),affected:I(m),self:n}}syncEntityToMatchInputMapDataType(n,a=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"sync-entity-to-match-input-map-data-type"))){var _,w,V,B,K,q,Z,Q,ie,H,Ie,re,Te,Ve,ue;const l=[],p=[],t=[],m=[];if(((_=n.declaration)==null?void 0:_.id)!==pe.operation[Wt.Validate].inputs.entityToMatch.id)return a==null||a.attemptAutoclose("sync-entity-to-match-input-map-data-type",this.id),{updated:[],added:[],removed:[],affected:[],self:null};const E=this.project.requestActiveValue(n),b=E==null?void 0:E.valueAsTypeSingle;if(!n.dataType){const ve={id:P.UUID.uuid(),version:P.UUID.uuid(),createdAt:(a==null?void 0:a.timestamp)||new Date().toISOString(),author:(a==null?void 0:a.author)||P.sessionAuthor,previousVersion:null,deleted:!1,type:f.DataType,parentRelationType:null,options:((w=n.declaration.dataType)==null?void 0:w.options)||null,implementationChooseOne:((V=n.declaration.dataType)==null?void 0:V.implementationChooseOne)||!1,staticEntities:((B=n.declaration.dataType)==null?void 0:B.staticEntities)??null,interactiveEntities:((K=n.declaration.dataType)==null?void 0:K.interactiveEntities)??null,actionEntities:((q=n.declaration.dataType)==null?void 0:q.actionEntities)??null,isList:((Z=n.declaration.dataType)==null?void 0:Z.isList)||!1,andChildrenGroup:null,orChildrenGroup:null,asType:!0,entity:(b==null?void 0:b.toJSON())||null,like:!0,inferred:!0,parent:n.toReference()},X=z(ve,n.project);X.hydrateAncestors(),X.setParent(n,a),X.initChildren(a),X.setEntity(b,a),a==null||a.add(X,G.Added),l.push(X),n.setDataType(X,a)}return(Ve=n.dataType)==null||Ve.metaSync({inferred:!0,like:!1,asType:!0,options:((Q=n.declaration.dataType)==null?void 0:Q.options)||null,implementationChooseOne:((ie=n.declaration.dataType)==null?void 0:ie.implementationChooseOne)||!1,staticEntities:((H=n.declaration.dataType)==null?void 0:H.staticEntities)??null,interactiveEntities:((Ie=n.declaration.dataType)==null?void 0:Ie.interactiveEntities)??null,actionEntities:((re=n.declaration.dataType)==null?void 0:re.actionEntities)??null,isList:((Te=n.declaration.dataType)==null?void 0:Te.isList)||!1},a),(ue=n.dataType)==null||ue.setEntity(b,a),n.dataType&&p.push(n.dataType),a==null||a.attemptAutoclose("sync-entity-to-match-input-map-data-type",this.id),{updated:I(p),added:I(l),removed:I(t),affected:I(m),self:n.dataType}}syncDataToValidateInputMapDataType(n,a=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"sync-data-to-validate-input-map-data-type"))){var w,V,B;const l=[],p=[],t=[],m=[];if(((w=n.declaration)==null?void 0:w.id)!==pe.operation[Wt.Validate].inputs.dataToValidate.id)return a==null||a.attemptAutoclose("sync-data-to-validate-input-map-data-type",this.id),{updated:[],added:[],removed:[],affected:[],self:null};const E=this.getEntityToMatchInputMap(n.parent);if(!E)return a==null||a.attemptAutoclose("sync-data-to-validate-input-map-data-type",this.id),{updated:[],added:[],removed:[],affected:[],self:null};if(!this.getEntityToMatch(E,a))return a==null||a.attemptAutoclose("sync-data-to-validate-input-map-data-type",this.id),{updated:[],added:[],removed:[],affected:[],self:null};if(!n.dataType){const K={id:P.UUID.uuid(),version:P.UUID.uuid(),createdAt:(a==null?void 0:a.timestamp)||new Date().toISOString(),author:(a==null?void 0:a.author)||P.sessionAuthor,previousVersion:null,deleted:!1,type:f.DataType,parentRelationType:null,options:null,implementationChooseOne:!1,isList:!1,andChildrenGroup:null,orChildrenGroup:null,staticEntities:null,interactiveEntities:null,actionEntities:null,asType:!1,entity:null,like:!0,inferred:!0,parent:n.toReference()},q=z(K,n.project);q.setParent(n,a),q.initChildren(a),a==null||a.add(q,G.Added),l.push(q),n.setDataType(q,a)}(V=n.dataType)==null||V.metaSync({inferred:!0,like:!0,asType:!1},a);const _=this.getEntityToMatch(E,a);return(B=n.dataType)==null||B.setEntity(_,a),n.dataType&&p.push(n.dataType),a==null||a.attemptAutoclose("sync-data-to-validate-input-map-data-type",this.id),{updated:I(p),added:I(l),removed:I(t),affected:I(m),self:n.dataType}}syncOutputDataOutputMapDataType(n,a=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"sync-output-data-output-map-data-type"))){var V,B,K;const l=[],p=[],t=[],m=[];if(((V=n.declaration)==null?void 0:V.id)!==pe.operation[Wt.Validate].outputs.outputEntity.id)return a==null||a.attemptAutoclose("sync-output-data-output-map-data-type",this.id),{updated:[],added:[],removed:[],affected:[],self:null};const E=this.getEntityToMatchInputMap(n.parent);if(!E)return a==null||a.attemptAutoclose("sync-output-data-output-map-data-type",this.id),{updated:[],added:[],removed:[],affected:[],self:null};if(!this.getEntityToMatch(E,a))return a==null||a.attemptAutoclose("sync-output-data-output-map-data-type",this.id),{updated:[],added:[],removed:[],affected:[],self:null};const _=this.project.requestActiveValue(E),w=(_==null?void 0:_.valueAsTypeSingle)||null;if(!n.dataType){const q={id:P.UUID.uuid(),version:P.UUID.uuid(),createdAt:(a==null?void 0:a.timestamp)||new Date().toISOString(),author:(a==null?void 0:a.author)||P.sessionAuthor,previousVersion:null,deleted:!1,type:f.DataType,parentRelationType:null,options:null,implementationChooseOne:!1,staticEntities:null,interactiveEntities:null,actionEntities:null,isList:!1,andChildrenGroup:null,orChildrenGroup:null,asType:!1,entity:(w==null?void 0:w.toJSON())||null,like:!0,inferred:!0,parent:n.toReference()},Z=z(q,n.project);Z.hydrateAncestors(),Z.setParent(n,a),Z.initChildren(a),Z.setEntity(w,a),a==null||a.add(Z,G.Added),l.push(Z),n.setDataType(Z,a)}return(B=n.dataType)==null||B.metaSync({inferred:!0,like:!0,asType:!1},a),(K=n.dataType)==null||K.setEntity(w,a),n.dataType&&p.push(n.dataType),a==null||a.attemptAutoclose("sync-output-data-output-map-data-type",this.id),{updated:I(p),added:I(l),removed:I(t),affected:I(m),self:n.dataType}}inferInputMapDataType(n,a=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"infer-input-map-data-type-validate-data"))){var p,t,m;if(((p=n.declaration)==null?void 0:p.id)===pe.operation[Wt.Validate].inputs.entityToMatch.id){const{added:E,updated:b,removed:_,affected:w}=this.syncEntityToMatchInputMapDataType(n,a);return a==null||a.attemptAutoclose("infer-input-map-data-type",this.id),{updated:I(b),added:I(E),removed:I(_),affected:I(w),self:n.dataType}}if(((t=n.declaration)==null?void 0:t.id)===pe.operation[Wt.Validate].inputs.dataToValidate.id){const{added:E,updated:b,removed:_,affected:w}=this.syncDataToValidateInputMapDataType(n,a);return a==null||a.attemptAutoclose("infer-input-map-data-type",this.id),{updated:I(b),added:I(E),removed:I(_),affected:I(w),self:n.dataType}}const l=(m=n.declaration)==null?void 0:m.getDataType(a);if(l&&l.isResolved)return a==null||a.attemptAutoclose("infer-input-map-data-type-validate-data",this.id),{updated:[],added:[],removed:[],affected:[],self:l};if(n.readsValue){const E=xs(n.readsValue,a);return a==null||a.attemptAutoclose("infer-input-map-data-type-validate-data",this.id),{updated:[],added:[],removed:[],affected:[],self:E}}return a==null||a.attemptAutoclose("infer-input-map-data-type-validate-data",this.id),{updated:[],added:[],removed:[],affected:[],self:null}}inferOutputMapDataType(n,a=this.project.addChangeSet(new F(this.project,P.sessionAuthor,N().toISOString(),this,!0,"infer-output-map-data-type-validate-data"))){var l;if(((l=n.declaration)==null?void 0:l.id)===pe.operation[Wt.Validate].outputs.outputEntity.id){const{added:p,updated:t,removed:m,affected:E}=this.syncOutputDataOutputMapDataType(n,a);return a==null||a.attemptAutoclose("infer-output-map-data-type-validate-data",this.id),{updated:I(t),added:I(p),removed:I(m),affected:I(E),self:n.dataType}}return{updated:[],added:[],removed:[],affected:[],self:null}}}class qye extends Lt{constructor(d){super($m,d)}}class Sye extends Lt{constructor(d){super(Cm,d)}}class Zye extends Lt{constructor(d){super(Pm,d)}}class Jye extends Lt{constructor(d){super(lf,d)}}class Wye extends Lt{constructor(d){super(nf,d)}}class Yye extends Lt{constructor(d){super(Qd,d)}}function zye(u){const d=[new Dj(u),new Rj(u),new _j(u),new Gye(u),new Kye(u),new kye(u),new Jye(u),new qye(u),new Zye(u),new Sye(u),new Wye(u),new Yye(u),new Lt(gm,u),new Lt(Dm,u)];return d.forEach(n=>{n.initChildren(null),u.subscribeBuiltInInstance(n)}),u.operationDeclarations=d,d}class gj extends qs{constructor(n){super(Jr,n);g(this,"initialData");g(this,"id",ge.PERSISTED_ENTITY);g(this,"version","1");g(this,"name",ge.PERSISTED_ENTITY);g(this,"description",Jr.description);g(this,"type",f.BuiltInBaseEntity);g(this,"abstract",Jr.abstract);g(this,"static",Jr.static);g(this,"properties",[]);g(this,"methods",[]);g(this,"abstractMethods",[]);g(this,"extends",[]);g(this,"errors",[]);g(this,"project");this.initialData=Jr,this.project=n,this.id=Jr.id,this.version=Jr.version,this.name=Jr.name,this.static=Jr.static,this.abstract=Jr.abstract,this.properties=this.initialData.properties.map(a=>{const l=z(a,this.project);return l.setParent(this,null),l.initChildren(null),l}),this.methods=this.initialData.methods.map(a=>{const l=z(a,this.project);return l.parent=this,l}),this.abstractMethods=this.initialData.abstractMethods.map(a=>{const l=z(a,this.project);return l.parent=this,l}),this.extends=this.initialData.extends.map(a=>z(a,this.project))}}var $j=(u=>(u.StatusCodeMustBeNumber="status-code-must-be-number",u.StatusCodeMustBeBetween100And599="status-code-must-be-between-100-and-599",u))($j||{});function Oj(u,d){const n=[];if(typeof d!="number"){const a=new xt({id:u.id+"--status-code-must-be-number",message:`Entity of type ${u.type} with id "${u.id}" has an invalid value "${d}". The value must be a number.`,issue:null,severity:S.Error,code:"status-code-must-be-number",entity:u});return n.push(a),{errors:n,override:d}}if(d<100){const a=new xt({id:u.id+"--status-code-must-be-between-100-and-599",message:`Entity of type ${u.type} with id "${u.id}" has an invalid value "${d}". The value must be a number between 100 and 599.`,issue:null,severity:S.Error,code:"status-code-must-be-between-100-and-599",entity:u});n.push(a)}if(d>599){const a=new xt({id:u.id+"--status-code-must-be-between-100-and-599",message:`Entity of type ${u.type} with id "${u.id}" has an invalid value "${d}". The value must be a number between 100 and 599.`,issue:null,severity:S.Error,code:"status-code-must-be-between-100-and-599",entity:u});n.push(a)}return{errors:n,override:d}}class Cj extends qs{constructor(n){super(Vi,n);g(this,"initialData");g(this,"id",ge.PERSISTED_ENTITY);g(this,"version","1");g(this,"name",ge.PERSISTED_ENTITY);g(this,"description",Vi.description);g(this,"type",f.BuiltInBaseEntity);g(this,"abstract",Vi.abstract);g(this,"static",Vi.static);g(this,"properties",[]);g(this,"methods",[]);g(this,"abstractMethods",[]);g(this,"extends",[]);g(this,"errors",[]);g(this,"project");this.initialData=Vi,this.project=n,this.id=Vi.id,this.version=Vi.version,this.name=Vi.name,this.static=Vi.static,this.abstract=Vi.abstract,this.properties=this.initialData.properties.map(t=>{const m=z(t,this.project);return m.setParent(this,null),m.initChildren(null),m}),this.methods=this.initialData.methods.map(t=>{const m=z(t,this.project);return m.parent=this,m}),this.abstractMethods=this.initialData.abstractMethods.map(t=>{const m=z(t,this.project);return m.parent=this,m}),this.extends=this.initialData.extends.map(t=>z(t,this.project));const a=this.properties.find(t=>t.id===pe["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.properties.path.id);if(!a)throw new Error("Path property not found in endpoint entity");a._codeNativeValueValidation=(t,m)=>pU(t,m);const l=this.abstractMethods.find(t=>t.id===pe["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.methods.handler.id);if(!l)throw new Error("Handler method not found in endpoint entity");const p=l.outputs.find(t=>t.id===pe["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.methods.handler.outputs.statusCode.id);if(!p)throw new Error("Status code output not found in handler method");p.codeNativeValueValidation=(t,m)=>Oj(t,m)}}const Hye="test_primitive_entities_export";class Xye extends qs{constructor(n){super(Br,n);g(this,"initialData");g(this,"id",ge.PERSISTED_ENTITY);g(this,"version","1");g(this,"name",ge.PERSISTED_ENTITY);g(this,"description",Br.description);g(this,"type",f.BuiltInBaseEntity);g(this,"abstract",Br.abstract);g(this,"static",Br.static);g(this,"properties",[]);g(this,"methods",[]);g(this,"abstractMethods",[]);g(this,"extends",[]);g(this,"errors",[]);g(this,"project");this.initialData=Br,this.project=n,this.id=Br.id,this.version=Br.version,this.name=Br.name,this.static=Br.static,this.abstract=Br.abstract,this.properties=this.initialData.properties.map(l=>{const p=z(l,this.project);return p.setParent(this,null),p.initChildren(null),p}),this.methods=this.initialData.methods.map(l=>{const p=z(l,this.project);return p.parent=this,p}),this.abstractMethods=this.initialData.abstractMethods.map(l=>{const p=z(l,this.project);return p.parent=this,p}),this.extends=this.initialData.extends.map(l=>z(l,this.project));const a=this.properties.find(l=>l.id===pe["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.identifier.id);if(!a)throw new Error("Path property not found in endpoint entity");a._codeNativeValueValidation=(l,p)=>fU(l,p)}}function Qye(u){const d=[new gj(u),new Cj(u),new Xye(u),new qs(Br,u),new qs(_f,u)];return d.forEach(n=>{u.subscribeBuiltInInstance(n)}),u.builtInBaseEntities=d,d}function e0e(u){const d=[new Ri(ke,u),new Ri(Bn,u),new Ri(st,u),new Ri(bm,u),new Ri(Gr,u),new Ri(Un,u),new Ri(nn,u),new Ri(jn,u),new Ri(fl,u)];return d.forEach(n=>{u.subscribeBuiltInInstance(n)}),u.primitives=d,d}function t0e(u){const d=[new Lt(gf,u)];return d.forEach(n=>{n.initChildren(null),u.subscribeBuiltInInstance(n)}),u.globalEventActionDescriptors=d,d}function r0e(u){const d=[new Lt(su,u),new Lt(ca,u),new Lt(ru,u),new Lt(ml,u),new Lt(vl,u),new Lt(mf,u)];d.forEach(a=>{a.initChildren(null),u.subscribeBuiltInInstance(a)}),u.loopDeclarations=d;const n=[new Lt(bf,u),new Lt(iu,u),new Lt(Ef,u),new Lt(qm,u),new Lt(Zm,u),new Lt(vf,u)];return n.forEach(a=>{a.initChildren(null),u.subscribeBuiltInInstance(a)}),u.loopDeclarationsBodies=n,d}function i0e(u){const d=[new ks($f,u),new ks(pv,u)];return d.forEach(n=>{n.initChildren(null),u.subscribeBuiltInInstance(n)}),u.valueDescriptors=d,d}function s0e(u){const d=[new Lt(yo,u),new Lt(Il,u)];return d.forEach(n=>{n.initChildren(null),u.subscribeBuiltInInstance(n)}),u.conditionDeclarations=d,d}const jo={},_y={},cp={empty:!1,enrich:!0,mock:!1,ignoreCache:!1,onFetch:async()=>null,manuallyInit:!1};function Pj(u,{enrich:d}={enrich:!0}){const n=u.project,a=u.record,l=new Ga(n),p=new Set;a[n.id]=n,p.add(n.id);const t=N().toISOString();Object.values(a).forEach(b=>{!b||l.allBuiltInEntityIds.includes(b.id)||p.add(b.id)}),l.order=Array.from(p),l.flatRecord=a,l.orderEntities();const m=Dy(u.project);m.instances[n.id]=m;const E=d?m.addChangeSet(new F(m,P.sessionAuthor,t,m,!0,"project-init-from-fetch-result")):null;return l.visit(b=>{if(b.id===m.id)return;const _=z(b,m);_.hydrateAncestors(),_.addSelfToProject(null)}),d?(l.visit(b=>{if(b.id===m.id)return;const _=m.get(b.id);_&&_.afterAllChildrenInitialized(E)}),m.afterAllChildrenInitialized(E)):gy(m,t).forEach(_=>{_.remove({ignoreUpstream:!0},null)}),m.instancesList.forEach(b=>{b.previousVersion=null}),E==null||E.attemptAutoclose("project-init-from-fetch-result",m.id),m}async function n0e(u,d=cp){const n={...cp,...d};if(n.empty)return{data:{project:{id:u.id,type:f.Project,version:P.UUID.uuid(),createdAt:N().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,name:null,description:null,projects:[],entities:[],operations:[],functions:[],variableDeclarations:[],variableInstances:[],functionCalls:[],conditions:[],loops:[],searches:[],events:[]},record:{}}};if(n.mock){const l={...bE};return l.id=u.id,{data:{project:l,record:{}}}}return console.log("Fetching project from external API"),new Promise(async l=>{try{if(n.onFetch){const p=await n.onFetch(u.id);if(p){l({data:p});return}}else l({data:null})}catch(p){console.error("Error fetching project: ",p),l({data:null})}})}function Dy(u){const d=new P(u);return e0e(d),Qye(d),zye(d),t0e(d),r0e(d),i0e(d),s0e(d),Array.from(new Set([...d.getAllBuiltInIds(),...bs()])).forEach(a=>{if(!d.builtInInstances[a]&&d.instances[a])d.builtInInstances[a]=d.instances[a],delete d.instances[a];else if(!d.builtInInstances[a])throw new Error(`Built in entity was not properly initialized: ${a}`)}),d.instances[d.id]=d,d}function gy(u,d){return u.instancesList.filter(a=>N(a.createdAt).isAfter(N(d)||!!a.previousVersion))}function a0e(u,{enrich:d}={enrich:!0}){const n=new Map,a=new Map,l=Array.from(new Set([...u.getAllBuiltInIds(),...bs()]));Object.keys(u.instances).forEach(_=>{if(l.includes(_)){n.set(_,_),a.set(_,_);return}const w=u.get(_);if(!wy(w,{...u.instances,...u.builtInInstances}).every(q=>!l.includes(q))){n.set(_,_),a.set(_,_);return}const K=P.UUID.uuid();n.set(_,K),a.set(K,_)});const p=N().toISOString(),t=u.toShallowJSON({seenEntityMaps:n});t.previousVersion=null,t.createdAt=p,t.version=P.UUID.uuid();const m=Dy(t);m.instances[m.id]=m;const E=d?m.addChangeSet(new F(m,P.sessionAuthor,p,m,!0,"project-clone")):null,b=new Ga(u);return b.visit(_=>{const w=_.toShallowJSON({seenEntityMaps:n});w.previousVersion=null,w.createdAt=p,w.version=P.UUID.uuid();const V=rp(w,OU(b.flatRecord,n));if(Object.keys(V.upstream).length){let K=!1;if(Object.keys(V.upstream).forEach(q=>{if(!K&&(!m.get(q)||m.getDeleted(q))){K=!0;return}}),K)return}const B=z(w,m);B.hydrateAncestors(),B.addSelfToProject(E),E==null||E.add(B,G.Added)}),d?(b.visit(_=>{if(_.id===m.id)return;const w=m.get(n.get(_.id));w&&w.afterAllChildrenInitialized(E)}),m.afterAllChildrenInitialized(E)):gy(m,p).forEach(w=>{w.remove({ignoreUpstream:!0},null)}),m.instancesList.forEach(_=>{_.previousVersion=null}),E==null||E.attemptAutoclose("project-clone",m.id),m}function Vj(u,{enrich:d}={enrich:!0}){const n=Dy(u),a=N().toISOString(),l=d?n.addChangeSet(new F(n,P.sessionAuthor,a,n,!0,"project-init")):null;l&&(l.type=jT.Automatic);const p=new Ga(u);return p.visit(t=>{const m=z(t,n);m.hydrateAncestors(),m.addSelfToProject(l)}),d?(p.visit(t=>{if(t.id===n.id)return;const m=n.get(t.id);m&&m.afterAllChildrenInitialized(l)}),n.afterAllChildrenInitialized(l)):(gy(n,a).forEach(E=>{E.remove({ignoreUpstream:!0},null)}),new Ga(n).visit(E=>{E.initialized=!0,E.captureVersion()})),n.initialized=!0,l==null||l.attemptAutoclose("project-init",n.id),n}async function o0e(u,d=cp){const n={...cp,...d};if(u.id&&jo[u.id]&&!n.ignoreCache)return jo[u.id];if(u.id&&_y[u.id]&&!n.ignoreCache)return await _y[u.id],jo[u.id];const a=n0e(u,n);u.id&&(_y[u.id]=a);const l=await a;if(l.data){let p;return n.mock?p=Vj(bE,{enrich:!!n.enrich}):l.data instanceof P?p=l.data:p=Pj(l.data,{enrich:!!n.enrich}),jo[u.id]=p,u.id&&delete _y[u.id],p}return null}function l0e(u){return jo[u.id]&&delete jo[u.id],null}C.AI_VALUE_CONNECTION_GENERATION_ACTION_EXPLANATION=hb,C.ALL_BUILT_IN_BASE_ENTITIES=MC,C.ALL_BUILT_IN_CONDITION_ENTITIES=YC,C.ALL_BUILT_IN_GLOBAL_EVENT_ENTITIES=HC,C.ALL_BUILT_IN_LOOP_BODY_ENTITIES=dO,C.ALL_BUILT_IN_LOOP_ENTITIES=lO,C.ALL_BUILT_IN_OPERATION_ENTITIES=bg,C.ALL_BUILT_IN_PRIMITIVE_ENTITIES=l1,C.ALL_BUILT_IN_TOP_LEVEL_ENTITIES=iP,C.ALL_BUILT_IN_VALUE_DESCRIPTORS=rP,C.ActionDescriptorState=Lt,C.ActionInputMapState=yhe,C.ActionOutputMapState=Ehe,C.AppendToListOperationInputIds=m_,C.AppendToListOperationOutputIds=v_,C.ArgumentDeclarationDependencyField=k3,C.ArgumentDeclarationState=ea,C.BREAK_AND_CONTINUE_STATEMENTS_RETURN_DECLARATIONS_EXPLANATION=ub,C.BUILT_IN_BASE_ENTITY_IDS=pe,C.BUILT_IN_ENTITY_TYPES=Pi,C.BaseCanvasDraggableState=Vye,C.BaseEntityNames=ge,C.BaseState=Pye,C.BaseValueDescriptorIds=pl,C.BreakStatementDependencyField=S3,C.BreakStatementState=Ba,C.BuiltInBaseEntityState=qs,C.CACHED_PROJECTS_BY_ID=jo,C.CALLABLE_ENTITIES_EXPLANATION=_he,C.CALLABLE_TYPES=rn,C.CALLER_ENTITIES_EXPLANATION=z3,C.CALLER_TYPES=sn,C.CALLS_UPDATE_EXPLANATION=ja,C.CHILDREN_TYPES=s7,C.COMPARISON_CONDITIONS=JC,C.CONDITIONS=WC,C.CUSTOM_ENTITY_OPERATIONS=jD,C.CallableEntityClass=Lye,C.CallerEntityClass=Nb,C.ChangeSet=F,C.ChangeSetChangeCaptureType=jT,C.ChangeSetEntityChangeType=G,C.ChildEntityBaseClass=Nye,C.CommonStringValidationErrorCodes=cU,C.ComparisonOperatorTypes=fr,C.ConditionDependencyField=EM,C.ConditionState=Ca,C.ContinueStatementDependencyField=pM,C.ContinueStatementState=Qr,C.CreateNewInputIds=pD,C.CreateNewOutputIds=fD,C.DRAGGABLE_CALLABLE_TYPES=Tm,C.DRAGGABLE_CALLER_TYPES=e1,C.DRAGGABLE_ELEMENT_TYPES=sf,C.DRAGGABLE_EXECUTABLE_TYPES=r7,C.DRAGGABLE_PASS_THROUGH_CALLABLE_TYPES=rf,C.DRAGGABLE_PASS_THROUGH_CALLABLE_TYPES_WITH_OUTPUTS=Em,C.DataTypeCompatibilityTypes=ms,C.DataTypeDependencyField=xT,C.DataTypeParentChildRelation=Fr,C.DataTypeState=ts,C.DefinitionEntityDependencyField=Ry,C.DefinitionEntityState=ia,C.EDITABLE_PERSISTANCE_REPOSITORY_DEFAULTS=Oye,C.ENTITIES_WITH_VALLUES_EXPLANATION=dy,C.ENTITY_PERSISTANCE_OPTIONS_DEFAULTS=oe,C.ENTITY_RECUSION_OPTIONS_DEFAULTS=Oe,C.ENTITY_TYPES=i7,C.ENTITY_WITH_DECLARATION_TYPES=e7,C.ENTITY_WITH_LOGIC_SCOPE_TYPES=br,C.ENTITY_WITH_NAMES_TYPES=t1,C.ENTITY_WITH_PARENT_TYPES=XK,C.ENTITY_WITH_USER_MANAGED_DECLARATION_TYPES=Xw,C.ENTITY_WITH_USER_MANAGED_SINGLE_IMPLEMENTS_TYPES=QK,C.ENTITY_WITH_VALUE_TYPES=vm,C.ENTRY_POINT_ENTITIES_EXPLANATION=Xc,C.ENTRY_POINT_TYPES=Xt,C.EVENT_TYPES=cl,C.EXECUTABLE_TYPES=t7,C.EXECUTION_OPERATIONS=cD,C.EndpointEntity=Cj,C.EntityAction=wj,C.EntityError=xt,C.EntityErrorSeverity=S,C.EntityGenerationError=Y,C.EntityGenerationErrorCode=k,C.EntityInstanceErrorCode=he,C.EntityOperations=Wt,C.EntityType=f,C.EntityWithLogicScopeClass=jye,C.EntityWithValueClass=Uye,C.EntryPointEntityClass=Mye,C.Events=Lb,C.ExecutionOperations=Jt,C.ExecutionTerminationType=yM,C.FunctionCallDependencyField=oU,C.FunctionCallState=Fa,C.FunctionDeclarationDependencyField=sM,C.FunctionDeclarationState=_a,C.GET_PROJECT_OPTIONS_DEFAULTS=cp,C.GLOBAL_EVENT_DECLARATIONS=zC,C.GetLastInListOperationInputIds=s_,C.GetLastInListOperationOutputIds=n_,C.GlobalEventNames=Mn,C.GlobalEventState=$a,C.HTTPOperations=Hr,C.HTTPStatucCodeValidationErrorCodes=$j,C.HTTP_OPERATIONS=Eg,C.InputMapDependencyField=x3,C.InputMapState=Es,C.InstalledProjectState=La,C.InternalCallDependencyField=U3,C.InternalCallState=Ma,C.JoinListOperationInputIds=RR,C.JoinListOperationOutputIds=_R,C.LIST_OPERATIONS=C_,C.ListOperations=rt,C.LiteralValueDependencyField=eM,C.LiteralValueState=Fs,C.LoopDependencyField=mM,C.LoopState=Oa,C.LoopTypes=xe,C.NON_INTERACTIVE_BASE_ENTITIES_EXPLANATION=xa,C.NUMBER_OPERATIONS=j1,C.NumberOperations=Ht,C.OPERATION_DECLARATIONS=Tg,C.OperationDependencyField=oM,C.OperationState=Da,C.OutputMapDependencyField=G3,C.OutputMapParentChildRelation=ul,C.OutputMapState=Ks,C.PARENT_AUTO_CALCULATION_FROM_CALLER_EXPLANATION=uy,C.PASS_THROUGH_CALLABLE_ENTITIES_EXPLANATION=Ua,C.PASS_THROUGH_CALLABLE_TYPES=dr,C.PASS_THROUGH_CALLABLE_TYPES_WITH_OUTPUTS=Qw,C.PROPERTY_NOT_VALUE_READER_WRITTER_EXPLANATION=fb,C.ParallelExecutionOperation=Rj,C.PassThroughCallableEntityClass=Bye,C.PersistedEntity=gj,C.PersistedEntityMethods=Ji,C.PrimitiveEntityState=Ri,C.PrimitiveTypes=te,C.ProjectState=P,C.ProjectStateEvents=ar,C.PropertyDependencyField=rM,C.PropertyState=Xn,C.READ_ONLY_ENTITY_PERSISTANCE_REPOSITORY=Aj,C.RETURN_STATEMENT_RETURN_DECLARATIONS_EXPLANATION=Dhe,C.ReturnDeclarationDependencyField=dM,C.ReturnDeclarationState=wi,C.ReturnStatementDependencyField=FT,C.ReturnStatementState=ga,C.SQLAST=ohe,C.STANDALONE_CONDITIONS=jC,C.STRING_OPERATIONS=wR,C.ScopeCompatibilityType=Ay,C.SearchDependencyField=N3,C.SearchState=Na,C.SequentialExecutionOperation=Dj,C.SequentialExecutionOperationInputIds=X_,C.SequentialExecutionOperationOutputIds=Q_,C.SharedEntityErrorCode=le,C.SharedStateFunctionality=bj,C.SplitListOperationInputIds=FR,C.SplitListOperationOutputIds=GR,C.StandaloneOperatorTypes=ps,C.StringOperations=ut,C.TERMINATION_TYPES=sr,C.Traverser=Ga,C.USER_MANAGED_ENTITY_TYPES=r1,C.UserManagedEntityStateTemplate=Cye,C.VALUE_READING_ENTITIES_EXPLANATION=pb,C.VALUE_READING_TYPES=ua,C.VALUE_WRITING_ENTITIES_EXPLANATION=H3,C.VALUE_WRITING_TYPES=Tr,C.VARIABLE_DATA_TYPE_INFERRANCE_EXPLANATION=cb,C.VARIABLE_TYPES=lr,C.ValueAutogenerationType=Er,C.ValueDescriptorDependencyField=J3,C.ValueDescriptorParentChildRelation=se,C.ValueDescriptorState=ks,C.ValueReadingEntityClass=dp,C.ValueWritingEntityClass=up,C.VariableDeclarationDependencyField=AM,C.VariableDeclarationState=Va,C.VariableInputMapState=hhe,C.VariableInstanceDependencyField=KT,C.VariableInstanceState=Pa,C.VariableOutputMapState=vhe,C.WaitOperation=_j,C.WaitOperationInputIds=S_,C.WaitOperationOutputIds=Z_,C.actionDescriptorValidation=mpe,C.appendToListOperation=lf,C.appendToListOperationElementToAppendArgument=Nm,C.appendToListOperationElementToAppendArgumentParentRef=__,C.appendToListOperationElementToAppendArgumentRef=b_,C.appendToListOperationError=O_,C.appendToListOperationErrorParentRef=$_,C.appendToListOperationListArgument=Vm,C.appendToListOperationListArgumentParentRef=R_,C.appendToListOperationListArgumentRef=E_,C.appendToListOperationListDataType=T_,C.appendToListOperationResultListDataType=w_,C.appendToListOperationResultListReturn=g_,C.appendToListOperationResultListReturnParentRef=D_,C.appendToListOperationResultListReturnRef=I_,C.appendToListOperationSecondListDataType=A_,C.applyNewScope=Me,C.argumentDeclarationValidation=The,C.asGenerationActionExample=En,C.booleanPrototype=Bn,C.breakStatementValidation=bhe,C.calculateNewParentBasedOnCallers=bb,C.capitalizeFirstLetter=kr,C.changeSetJSONRecordToUniqueIds=epe,C.checkAreDataTypesCompatible=vs,C.checkAreDefinitionEntitiesCompatibleAsDataType=ML,C.checkArePropertiesCompatibleAsDataType=LL,C.checkExtendsBaseEntity=Iy,C.checkHasBaseEntity=As,C.checkHasMetadataChanged=cr,C.checkImplementationsOverlap=ra,C.checkImplementsBaseEntity=nye,C.checkIsBranchDependentButNotDirectlyOnBranch=ep,C.checkIsBranchDependentOnBranch=xhe,C.checkIsBuiltIn=Vb,C.checkIsCallableEntityReachable=lp,C.checkIsCanvasEntity=iye,C.checkIsDefEntityInlineDeclaredForSearchOutputType=nb,C.checkIsDetachedBranch=dj,C.checkIsDetachedBranchShallow=Cb,C.checkIsGlobalVariable=tye,C.checkIsGloballyDeclared=Ob,C.checkIsMethod=pj,C.checkIsNestedScope=by,C.checkScopeCompatibility=op,C.cloneProject=a0e,C.conditionValidation=vpe,C.continueStatementValidation=ppe,C.convertToAbstract=Mhe,C.convertToNonAbstract=Bhe,C.convertToNonStatic=jhe,C.convertToStatic=Uhe,C.countedLoopActionDescriptor=su,C.countedLoopActionDescriptorDynamicReturnDeclaration=eO,C.countedLoopActionDescriptorDynamicReturnDeclarationParentRef=Q$,C.countedLoopActionDescriptorStringArgumentDeclaration=X$,C.countedLoopActionDescriptorStringArgumentDeclarationDataType=z$,C.countedLoopActionDescriptorStringArgumentDeclarationDataTypeDefaultValue=W$,C.countedLoopActionDescriptorStringArgumentDeclarationDataTypeDefaultValueParentRef=J$,C.countedLoopActionDescriptorStringArgumentDeclarationDataTypeParentRef=Y$,C.countedLoopActionDescriptorStringArgumentDeclarationParentRef=H$,C.countedLoopBodyActionDescriptor=bf,C.countedLoopBodyActionDescriptorAnyDynamicArgument=nO,C.countedLoopBodyActionDescriptorAnyDynamicArgumentParentRef=sO,C.countedLoopBodyActionDescriptorAnyDynamicReturn=oO,C.countedLoopBodyActionDescriptorAnyDynamicReturnParentRef=aO,C.countedLoopBodyActionDescriptorIterationNumberArgumentDeclaration=Wm,C.countedLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataType=rO,C.countedLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataTypeParentRef=tO,C.countedLoopBodyActionDescriptorIterationNumberArgumentDeclarationParentRef=iO,C.createDefinitionEntityFromJSONObject=yy,C.createEntityError=et,C.createNestedDataTypeForEntity=uU,C.createNewInstanceOperation=lo,C.createNewInstanceOperationEntityToInstanciateArgument=AD,C.createNewInstanceOperationEntityToInstanciateArgumentRef=ED,C.createNewInstanceOperationEntityToInstanciateDataType=TD,C.createNewInstanceOperationError=_D,C.createNewInstanceOperationErrorParentRef=RD,C.createNewInstanceOperationNewEntityDataArgument=vD,C.createNewInstanceOperationNewEntityDataArgumentDataType=mD,C.createNewInstanceOperationNewEntityDataArgumentDataTypeParentRef=yD,C.createNewInstanceOperationNewEntityDataArgumentParentRef=hD,C.createNewInstanceOperationOutputEntityDeclaration=wD,C.createNewInstanceOperationOutputEntityDeclarationParentRef=ID,C.createNewInstanceOperationRef=bD,C.createSemanticId=JL,C.createStateFromGenerationTargetType=$ye,C.createStateFromType=er,C.createStateFromTypeAndSubscribe=z,C.cronJobBuiltInBaseEntity=_f,C.cronJobBuiltInBaseEntityExpressionProperty=NC,C.cronJobBuiltInBaseEntityExpressionPropertyDataTypeRef=p7,C.cronJobBuiltInBaseEntityExpressionPropertyRef=PC,C.cronJobBuiltInBaseEntityRef=VC,C.cronJobTriggeredFunctionDeclarationBlueprint=lv,C.cronJobTriggeredFunctionDeclarationBlueprintParentRef=OC,C.dataTypeCompatibilityToErrorExplanation=nU,C.dataTypeValidation=ape,C.datePrototype=nn,C.dateValueAutogenerationSchema=_E,C.definitionEntityToZodSchema=TP,C.definitionEntityValidation=Rye,C.deletePersistedEntityMethod=ov,C.deletePersistedEntityMethodParentRef=hC,C.deleteRootProject=l0e,C.endpointBuiltInBaseEntity=Vi,C.endpointBuiltInBaseEntityRef=fO,C.endpointBuiltInBaseEntityRefFour=YO,C.endpointBuiltInBaseEntityRefThree=IO,C.endpointBuiltInBaseEntityRefTwo=EO,C.endpointBuiltInCorsProperty=hO,C.endpointBuiltInCorsPropertyDataType=pO,C.endpointBuiltInCorsPropertyDataTypeRef=uO,C.endpointBuiltInCorsPropertyRef=cO,C.endpointBuiltInMethodProperty=zm,C.endpointBuiltInMethodPropertyDataType=AO,C.endpointBuiltInMethodPropertyDataTypeRef=TO,C.endpointBuiltInMethodPropertyRef=bO,C.endpointBuiltInPathProperty=Ym,C.endpointBuiltInPathPropertyDataType=vO,C.endpointBuiltInPathPropertyDataTypeRef=yO,C.endpointBuiltInPathPropertyRef=mO,C.endpointPathParamsArgumentDeclaration=Xm,C.endpointPathParamsArgumentDeclarationRef=VO,C.endpointPathParamsVariableDataType=NO,C.endpointPathParamsVariableDataTypeRef=PO,C.endpointReachedTriggerActionDescriptor=sv,C.endpointReachedTriggerActionDescriptorRef=LO,C.endpointReachedTriggerActionDescriptorRefFour=UO,C.endpointReachedTriggerActionDescriptorRefThree=BO,C.endpointReachedTriggerActionDescriptorRefTwo=MO,C.endpointRequestBodyArgumentDeclaration=ev,C.endpointRequestBodyArgumentDeclarationRef=DO,C.endpointRequestBodyVariableDataType=gO,C.endpointRequestHeadersArgumentDeclaration=Hm,C.endpointRequestHeadersArgumentDeclarationRef=RO,C.endpointRequestHeadersVariableDataType=_O,C.endpointRequestHeadersVariableDataTypeRef=wO,C.endpointRequestQueryParamsArgumentDeclaration=Qm,C.endpointRequestQueryParamsArgumentDeclarationRef=OO,C.endpointRequestQueryParamsVariableDataType=CO,C.endpointRequestQueryParamsVariableDataTypeRef=$O,C.endpointResponseBodyDataType=JO,C.endpointResponseBodyReturnDeclaration=iv,C.endpointResponseBodyReturnDeclarationRef=ZO,C.endpointResponseCodeDataType=xO,C.endpointResponseCodeReturnDeclaration=tv,C.endpointResponseCodeReturnDeclarationDefaultValueParentRef=GO,C.endpointResponseCodeReturnDeclarationRef=jO,C.endpointResponseHeadersDataType=qO,C.endpointResponseHeadersDataTypeRef=KO,C.endpointResponseHeadersReturnDeclaration=rv,C.endpointResponseHeadersReturnDeclarationRef=kO,C.endpointReturnStatementRef=FO,C.endpointReturnStatementRefThree=WO,C.endpointReturnStatementRefTwo=SO,C.enrichFromKnownEntities=tp,C.enumOptionsProperty=o1,C.enumOptionsPropertyDataType=n1,C.enumOptionsPropertyDataTypeRef=i1,C.enumOptionsPropertyRef=s1,C.enumPrototype=Un,C.enumPrototypeRef=a1,C.executionBuiltInBaseEntity=Df,C.executionBuiltInEntityAbortMethod=dv,C.executionBuiltInEntityAbortMethodParentRef=LC,C.filterOutDuplicateEntities=I,C.filterOutDuplicateErrors=yoe,C.findEntityFromKeys=Eb,C.findReferenceToSelfInList=$U,C.findReferencesToSelfInProject=Whe,C.flattenActionDescriptor=CU,C.flattenArgumentDeclaration=PU,C.flattenBreakStatement=VU,C.flattenBuiltInBaseEntity=NU,C.flattenCalls=Ts,C.flattenCanvasAncestorsUntil=nd,C.flattenCondition=LU,C.flattenContinueStatement=MU,C.flattenDataType=UU,C.flattenDefinitionEntity=BU,C.flattenDefinitionEntityExtensionAndImplementationTypes=Ty,C.flattenDefinitionEntityExtensionTypes=sp,C.flattenDefinitionEntityExtensions=_b,C.flattenDefinitionEntityImplementations=Db,C.flattenDefinitionEntityImplementionTypes=ip,C.flattenDerivedCanvasEntities=xi,C.flattenDetachedBranch=cj,C.flattenElementCalls=nt,C.flattenElementCallsOnTheSameScope=Jhe,C.flattenEntity=ae,C.flattenFunctionCall=jU,C.flattenFunctionDeclaration=xU,C.flattenGlobalEvent=FU,C.flattenInputMap=GU,C.flattenInstalledProject=KU,C.flattenInternalCall=kU,C.flattenLiteralValue=qU,C.flattenLoop=SU,C.flattenOperation=ZU,C.flattenOutputMap=JU,C.flattenPrimitiveEntity=WU,C.flattenProject=YU,C.flattenProjectElements=gU,C.flattenProperty=zU,C.flattenRelatedCanvasElementsOnTheLeft=lj,C.flattenRelatedCanvasElementsOnTheRight=oj,C.flattenReturnDeclaration=HU,C.flattenReturnStatement=XU,C.flattenSearch=QU,C.flattenValueDescriptor=ej,C.flattenVariableDeclaration=tj,C.flattenVariableInstance=rj,C.flattenVariableReads=DU,C.flattenVariableWrites=_U,C.flattenVariables=kt,C.fromChangeSetToRecordChangeSet=cye,C.fromLiteralValueTypeToPrimitiveType=ib,C.fromZodParseToEntityGenerationErrors=ob,C.functionCallValidation=Lhe,C.functionDeclarationValidation=npe,C.generate=y9,C.generateActionExample=ghe,C.generateExecutionDataType=Zce,C.generateIdFromStrategy=hr,C.generateMutablePropertiesExplanation=ay,C.generateRandomBoolean=SP,C.generateRandomDate=wP,C.generateRandomDateAfter=bP,C.generateRandomDateBefore=AP,C.generateRandomDateBetweenRange=IP,C.generateRandomNumber=FP,C.generateRandomNumberAfter=UP,C.generateRandomNumberBefore=jP,C.generateRandomNumberBetweenRange=xP,C.generateRandomText=qP,C.generateRandomTextAfter=GP,C.generateRandomTextBefore=KP,C.generateRandomTextBetweenRange=kP,C.generateUniqueUUID=BP,C.getAllActionDescriptorsForConditions=fy,C.getAllActionDescriptorsForGlobalEvents=cy,C.getAllActionDescriptorsForLoops=py,C.getAllActionDescriptorsForOperations=Phe,C.getAllBuiltInEntityIds=bs,C.getAllGloballyDeclaredFunctionDeclarationsExplanation=rU,C.getBaseBuiltInEntities=hi,C.getBaseSchemaBasedOnType=W3,C.getBuiltInEntityOwner=ka,C.getCallableEntityReferenceSchema=Kr,C.getCallableEntityTypeSchema=IN,C.getCalledBy=is,C.getCallerEntityReferenceSchema=Tde,C.getCallerEntityTypeSchema=Ede,C.getCalls=Ib,C.getCanvasEntitiesDerivedFromInternalCalls=aj,C.getCanvasEntitiesDerivedFromWrites=ad,C.getCanvasEntityDerivedFromValueReadingEntity=Ey,C.getCanvasEntityDerivedFromValueReadingEntityFromTransfer=nj,C.getCanvasEntityReferenceSchema=Bde,C.getCanvasEntityTypeSchema=Mde,C.getChildrenEntityWithValues=Ghe,C.getColumnProperties=od,C.getCommonAncestor=Ab,C.getCommonChildren=hU,C.getDatabaseEntities=oye,C.getDatabaseEntity=dye,C.getDeclaration=Mo,C.getDeclarationOutputedError=fye,C.getDeepestScope=hj,C.getDefaultRelationalDatabaseEntityOrFirst=mj,C.getDraggableCallableEntityReferenceSchema=RN,C.getDraggableCallableEntityTypeSchema=wN,C.getDraggableCallerEntityReferenceSchema=Ade,C.getDraggableCallerEntityTypeSchema=bde,C.getDraggableExecutableEntityReferenceSchema=_de,C.getDraggableExecutableEntityTypeSchema=Rde,C.getDraggablePassThroughCallableEntityReferenceSchema=Mh,C.getDraggablePassThroughCallableEntityTypeSchema=Lh,C.getDraggablePlayableEntityReferenceSchema=Cde,C.getDraggablePlayableEntityTypeSchema=Ode,C.getEntitiesCreatedSinceInitialization=gy,C.getEntityArgumentDeclarations=Rb,C.getEntityInputMaps=ij,C.getEntityOutputMaps=Xhe,C.getEntityReferenceSchema=Lde,C.getEntityReturnDeclarations=sj,C.getEntityTypeSchema=Nde,C.getEntityWithLogicScopeReferenceSchema=Yn,C.getEntityWithLogicScopeTypeSchema=Dde,C.getEntityWithValueReferenceSchema=AN,C.getEntityWithValueTypeSchema=vde,C.getEntryPointEntityReferenceSchema=Ur,C.getEntryPointEntityTypeSchema=Ia,C.getEventEntityReferenceSchema=Vh,C.getEventEntityTypeSchema=Ph,C.getExecutableEntityReferenceSchema=wde,C.getExecutableEntityTypeSchema=Ide,C.getExtendedBuiltInEntity=Qhe,C.getExtendedDefinitionEntity=$b,C.getFirstNonLoopScopeOwner=Rr,C.getGenerationTargetSchemaBasedOnType=Y3,C.getHeadIfPartOfDetachedBranch=uj,C.getHighestScope=fj,C.getImplementedBuiltInEntity=eye,C.getIsInteractive=np,C.getLastInListOperation=Pm,C.getLastInListOperationError=y_,C.getLastInListOperationErrorParentRef=h_,C.getLastInListOperationInputListArgument=c_,C.getLastInListOperationInputListArgumentParentRef=u_,C.getLastInListOperationInputListArgumentRef=a_,C.getLastInListOperationInputListDataType=o_,C.getLastInListOperationOutputElementDataType=d_,C.getLastInListOperationOutputElementReturn=f_,C.getLastInListOperationOutputElementReturnParentRef=p_,C.getLastInListOperationOutputElementReturnRef=l_,C.getLinkedEntitiesFromArgumentDeclaration=Zhe,C.getLowestPersistedEntityImplementation=gb,C.getParentCallableEntity=yU,C.getParentCallerEntity=vU,C.getParentCanvasEntities=ei,C.getParentCanvasEntity=Pr,C.getParentCanvasEntityFromTransfer=my,C.getParentEntryPoint=Fhe,C.getParentPassthroughCallableEntity=mU,C.getPassThroughCallableEntityReferenceSchema=Qt,C.getPassThroughCallableEntityTypeSchema=Nh,C.getPeristedEntities=aye,C.getPlayableEntityReferenceSchema=$de,C.getPlayableEntityTypeSchema=gde,C.getProject=o0e,C.getPrototypeByType=ap,C.getRecusriveParentsIds=wy,C.getReferenceEntityId=W,C.getReferencedEntitiesStateOrErrors=ly,C.getReferencedEntityStateOrErrors=lb,C.getReferencedIds=rp,C.getRelatedCanvasElementsOnTheLeft=Uo,C.getRelatedCanvasElementsOnTheLeftFromTransfer=Yhe,C.getRelatedCanvasElementsOnTheRight=Ka,C.getRootEntryPointScopeOwner=Pb,C.getScopeOwner=yi,C.getStateClassFromType=uye,C.getTerminationReferenceSchema=Vde,C.getTerminationTypeSchema=Pde,C.getTouchedCanvasEntitiesFromChangeSet=pye,C.getUsedArgFromDeclaration=zhe,C.getUsedReturnFromDeclaration=Hhe,C.getValueReadingEntityReferenceSchema=bN,C.getValueReadingEntityTypeSchema=Wn,C.getValueWritingEntityReferenceSchema=mde,C.getValueWritingEntityTypeSchema=Ku,C.getVariableFromInputMapping=TU,C.getVariableFromReturnVariablePointer=IU,C.getVariableReferenceSchema=Aa,C.getVariableTypeSchema=Oo,C.getVariablesFromArgumentDeclarations=vy,C.getVariablesFromInputMaps=bU,C.getVariablesFromOutputMapping=wU,C.getVariablesFromOutputMaps=RU,C.getVariablesFromReturnDeclarations=AU,C.getVariablesInSameOrHigherScope=CT,C.getWrites=wb,C.globalEventValidation=fpe,C.groupCallsBasedOnParallelizableExecution=khe,C.handleAfterEntityImplementationSideEffects=dU,C.handleBeforeEntityImplementationSideEffects=lU,C.httpRequestBodyArgument=pf,C.httpRequestBodyArgumentRef=HD,C.httpRequestBodyDataType=XD,C.httpRequestHeadersArgument=cf,C.httpRequestHeadersArgumentRef=YD,C.httpRequestHeadersDataType=zD,C.httpRequestMethodArgument=df,C.httpRequestMethodArgumentRef=JD,C.httpRequestMethodDataType=WD,C.httpRequestMethodDataTypeRef=SD,C.httpRequestOperation=eu,C.httpRequestOperationErrorValueDescriptor=xm,C.httpRequestOperationErrorValueDescriptorDatatype=vg,C.httpRequestOperationErrorValueDescriptorRef=mg,C.httpRequestOperationRef=pg,C.httpRequestOperationRefEight=hg,C.httpRequestOperationRefFive=ug,C.httpRequestOperationRefFour=dg,C.httpRequestOperationRefNine=yg,C.httpRequestOperationRefSeven=fg,C.httpRequestOperationRefSix=cg,C.httpRequestOperationRefThree=lg,C.httpRequestOperationRefTwo=og,C.httpRequestQueryParamsArgument=jm,C.httpRequestQueryParamsArgumentRef=kD,C.httpRequestQueryParamsDataType=qD,C.httpRequestVariableURLArgument=uf,C.httpRequestVariableURLArgumentRef=GD,C.httpRequestVariableURLDataType=KD,C.httpRequestVariableURLDataTypeRef=xD,C.httpResponseBodyReturnDataType=ag,C.httpResponseBodyReturnDataTypeRef=sg,C.httpResponseBodyReturnReturn=yf,C.httpResponseBodyReturnReturnRef=ng,C.httpResponseCodeDataType=eg,C.httpResponseCodeReturn=ff,C.httpResponseCodeReturnRef=QD,C.httpResponseHeadersDataType=ig,C.httpResponseHeadersDataTypeRef=tg,C.httpResponseHeadersReturn=hf,C.httpResponseHeadersReturnRef=rg,C.httpStatusCodeValueValidation=Oj,C.implement=hy,C.inferArgumentDeclarationDataType=BL,C.inferDataType=xs,C.inferInputMapDataType=gT,C.inferOutputMapDataType=OT,C.inferPropertyDataType=xL,C.inferReturnDeclarationDataType=$T,C.inferValueDescriptorDataType=FL,C.inferVariableDeclarationDataType=jL,C.inferVariableInstanceDataType=UL,C.initBaseProjectEntity=Dy,C.initProject=Vj,C.initProjectFromFetchResult=Pj,C.inputMapValidation=fhe,C.installedProjectValidation=che,C.internalCallValidation=phe,C.isPromise=vb,C.iterateOverListActionDescriptorListArgumentDeclaration=Hg,C.iterateOverListActionDescriptorListArgumentDeclarationDataType=Yg,C.iterateOverListActionDescriptorListArgumentDeclarationDataTypeParentRef=Wg,C.iterateOverListActionDescriptorListArgumentDeclarationParentRef=zg,C.iterateOverListLoopActionDescriptor=ca,C.iterateOverListLoopActionDescriptorDynamicReturnDeclaration=Qg,C.iterateOverListLoopActionDescriptorDynamicReturnDeclarationParentRef=Xg,C.iterateOverListLoopBodyActionDescriptor=iu,C.iterateOverListLoopBodyActionDescriptorAnyDynamicArgument=l$,C.iterateOverListLoopBodyActionDescriptorAnyDynamicArgumentParentRef=o$,C.iterateOverListLoopBodyActionDescriptorAnyDynamicReturn=u$,C.iterateOverListLoopBodyActionDescriptorAnyDynamicReturnParentRef=d$,C.iterateOverListLoopBodyActionDescriptorCurrentValueArgumentDeclaration=Tf,C.iterateOverListLoopBodyActionDescriptorCurrentValueArgumentDeclarationDataType=t$,C.iterateOverListLoopBodyActionDescriptorCurrentValueArgumentDeclarationDataTypeParentRef=e$,C.iterateOverListLoopBodyActionDescriptorCurrentValueArgumentDeclarationParentRef=r$,C.iterateOverListLoopBodyActionDescriptorIterationNumberArgumentDeclaration=a$,C.iterateOverListLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataType=s$,C.iterateOverListLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataTypeParentRef=i$,C.iterateOverListLoopBodyActionDescriptorIterationNumberArgumentDeclarationParentRef=n$,C.iterateOverObjectKeysActionDescriptorObjectArgumentDeclaration=y$,C.iterateOverObjectKeysActionDescriptorObjectArgumentDeclarationDataType=f$,C.iterateOverObjectKeysActionDescriptorObjectArgumentDeclarationDataTypeParentRef=p$,C.iterateOverObjectKeysActionDescriptorObjectArgumentDeclarationParentRef=h$,C.iterateOverObjectKeysLoopActionDescriptor=ml,C.iterateOverObjectKeysLoopActionDescriptorDynamicReturnDeclaration=v$,C.iterateOverObjectKeysLoopActionDescriptorDynamicReturnDeclarationParentRef=m$,C.iterateOverObjectKeysLoopBodyActionDescriptor=qm,C.iterateOverObjectKeysLoopBodyActionDescriptorAnyDynamicArgument=D$,C.iterateOverObjectKeysLoopBodyActionDescriptorAnyDynamicArgumentParentRef=_$,C.iterateOverObjectKeysLoopBodyActionDescriptorAnyDynamicReturn=$$,C.iterateOverObjectKeysLoopBodyActionDescriptorAnyDynamicReturnParentRef=g$,C.iterateOverObjectKeysLoopBodyActionDescriptorCurrentValueArgumentDeclaration=km,C.iterateOverObjectKeysLoopBodyActionDescriptorCurrentValueArgumentDeclarationDataType=T$,C.iterateOverObjectKeysLoopBodyActionDescriptorCurrentValueArgumentDeclarationDataTypeParentRef=E$,C.iterateOverObjectKeysLoopBodyActionDescriptorCurrentValueArgumentDeclarationParentRef=b$,C.iterateOverObjectKeysLoopBodyActionDescriptorIterationNumberArgumentDeclaration=R$,C.iterateOverObjectKeysLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataType=I$,C.iterateOverObjectKeysLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataTypeParentRef=A$,C.iterateOverObjectKeysLoopBodyActionDescriptorIterationNumberArgumentDeclarationParentRef=w$,C.iterateOverObjectValuesActionDescriptorObjectArgumentDeclaration=N$,C.iterateOverObjectValuesActionDescriptorObjectArgumentDeclarationDataType=P$,C.iterateOverObjectValuesActionDescriptorObjectArgumentDeclarationDataTypeParentRef=C$,C.iterateOverObjectValuesActionDescriptorObjectArgumentDeclarationParentRef=V$,C.iterateOverObjectValuesLoopActionDescriptor=vl,C.iterateOverObjectValuesLoopActionDescriptorDynamicReturnDeclaration=M$,C.iterateOverObjectValuesLoopActionDescriptorDynamicReturnDeclarationParentRef=L$,C.iterateOverObjectValuesLoopBodyActionDescriptor=Zm,C.iterateOverObjectValuesLoopBodyActionDescriptorAnyDynamicArgument=q$,C.iterateOverObjectValuesLoopBodyActionDescriptorAnyDynamicArgumentParentRef=k$,C.iterateOverObjectValuesLoopBodyActionDescriptorAnyDynamicReturn=Z$,C.iterateOverObjectValuesLoopBodyActionDescriptorAnyDynamicReturnParentRef=S$,C.iterateOverObjectValuesLoopBodyActionDescriptorCurrentValueArgumentDeclaration=Sm,C.iterateOverObjectValuesLoopBodyActionDescriptorCurrentValueArgumentDeclarationDataType=U$,C.iterateOverObjectValuesLoopBodyActionDescriptorCurrentValueArgumentDeclarationDataTypeParentRef=B$,C.iterateOverObjectValuesLoopBodyActionDescriptorCurrentValueArgumentDeclarationParentRef=j$,C.iterateOverObjectValuesLoopBodyActionDescriptorIterationNumberArgumentDeclaration=K$,C.iterateOverObjectValuesLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataType=F$,C.iterateOverObjectValuesLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataTypeParentRef=x$,C.iterateOverObjectValuesLoopBodyActionDescriptorIterationNumberArgumentDeclarationParentRef=G$,C.iterateOverStringActionDescriptorDynamicReturnDeclaration=Bg,C.iterateOverStringActionDescriptorDynamicReturnDeclarationParentRef=Mg,C.iterateOverStringActionDescriptorStringArgumentDeclaration=Lg,C.iterateOverStringActionDescriptorStringArgumentDeclarationDataType=Vg,C.iterateOverStringActionDescriptorStringArgumentDeclarationDataTypeParentRef=Pg,C.iterateOverStringActionDescriptorStringArgumentDeclarationParentRef=Ng,C.iterateOverStringLoopActionDescriptor=ru,C.iterateOverStringLoopBodyActionDescriptor=Ef,C.iterateOverStringLoopBodyActionDescriptorAnyDynamicArgument=qg,C.iterateOverStringLoopBodyActionDescriptorAnyDynamicArgumentParentRef=kg,C.iterateOverStringLoopBodyActionDescriptorAnyDynamicReturn=Zg,C.iterateOverStringLoopBodyActionDescriptorAnyDynamicReturnParentRef=Sg,C.iterateOverStringLoopBodyActionDescriptorCurrentValueArgumentDeclaration=Gm,C.iterateOverStringLoopBodyActionDescriptorCurrentValueArgumentDeclarationDataType=jg,C.iterateOverStringLoopBodyActionDescriptorCurrentValueArgumentDeclarationDataTypeParentRef=Ug,C.iterateOverStringLoopBodyActionDescriptorCurrentValueArgumentDeclarationParentRef=xg,C.iterateOverStringLoopBodyActionDescriptorIterationNumberArgumentDeclaration=Km,C.iterateOverStringLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataType=Gg,C.iterateOverStringLoopBodyActionDescriptorIterationNumberArgumentDeclarationDataTypeParentRef=Fg,C.iterateOverStringLoopBodyActionDescriptorIterationNumberArgumentDeclarationParentRef=Kg,C.joinListOperation=$m,C.joinListOperationError=xR,C.joinListOperationErrorParentRef=jR,C.joinListOperationFirstListArgument=NR,C.joinListOperationFirstListArgumentParentRef=VR,C.joinListOperationFirstListArgumentRef=DR,C.joinListOperationFirstListDataType=gR,C.joinListOperationResultListDataType=PR,C.joinListOperationResultListReturn=UR,C.joinListOperationResultListReturnParentRef=BR,C.joinListOperationResultListReturnRef=CR,C.joinListOperationSecondListArgument=MR,C.joinListOperationSecondListArgumentParentRef=LR,C.joinListOperationSecondListArgumentRef=$R,C.joinListOperationSecondListDataType=OR,C.joinListWithLastSeparator=Ke,C.joinStringsOperation=Qd,C.joinStringsOperationDynamicStringArgument=nR,C.joinStringsOperationDynamicStringArgumentParentRef=sR,C.joinStringsOperationDynamicStringArgumentRef=rR,C.joinStringsOperationDynamicStringDataType=iR,C.joinStringsOperationError=tR,C.joinStringsOperationErrorParentRef=eR,C.joinStringsOperationFirstStringArgument=af,C.joinStringsOperationFirstStringArgumentParentRef=S1,C.joinStringsOperationFirstStringArgumentRef=x1,C.joinStringsOperationFirstStringDataType=F1,C.joinStringsOperationResultStringDataType=q1,C.joinStringsOperationResultStringReturn=Xd,C.joinStringsOperationResultStringReturnParentRef=Q1,C.joinStringsOperationResultStringReturnRef=k1,C.joinStringsOperationSecondStringArgument=of,C.joinStringsOperationSecondStringArgumentParentRef=X1,C.joinStringsOperationSecondStringArgumentRef=G1,C.joinStringsOperationSecondStringDataType=K1,C.joinStringsOperationSeparatorStringArgument=H1,C.joinStringsOperationSeparatorStringArgumentParentRef=z1,C.joinStringsOperationSeparatorStringArgumentRef=Z1,C.joinStringsOperationSeparatorStringDataType=Y1,C.joinStringsOperationSeparatorStringDataTypeDefaultValue=W1,C.joinStringsOperationSeparatorStringDataTypeDefaultValueParentRef=J1,C.keyValuePrototype=fl,C.literalValudValidation=tpe,C.loopValidation=ype,C.lowercaseFirstLetter=Xu,C.manualFlowActionDescriptorDeclarationArgumentDeclaration=Fm,C.manualFlowActionDescriptorDeclarationArgumentDeclarationDataType=Rg,C.manualFlowActionDescriptorDeclarationArgumentDeclarationDataTypeParentRef=wg,C.manualFlowActionDescriptorDeclarationArgumentDeclarationParentRef=_g,C.manualFlowLoopActionDescriptor=mf,C.manualFlowLoopActionDescriptorDynamicReturnDeclaration=Ig,C.manualFlowLoopActionDescriptorDynamicReturnDeclarationParentRef=Ag,C.manualFlowLoopBodyActionDescriptor=vf,C.manualFlowLoopBodyActionDescriptorAnyDynamicArgument=gg,C.manualFlowLoopBodyActionDescriptorAnyDynamicArgumentParentRef=Dg,C.manualFlowLoopBodyActionDescriptorAnyDynamicReturn=Og,C.manualFlowLoopBodyActionDescriptorAnyDynamicReturnParentRef=$g,C.mapActionDescriptorToTypeItRepresents=sye,C.mapRecord=OU,C.mergeEntityErrorsList=moe,C.mergeListOfEntities=rye,C.methodDefaultValue=ZD,C.mockClientProject=bE,C.moreThanOrEqualCondition=Il,C.moreThanOrEqualConditionLeftHandArgument=KC,C.moreThanOrEqualConditionLeftHandArgumentDataType=FC,C.moreThanOrEqualConditionLeftHandArgumentDataTypeParentRef=xC,C.moreThanOrEqualConditionLeftHandArgumentParentRef=GC,C.moreThanOrEqualConditionRightHandArgument=ZC,C.moreThanOrEqualConditionRightHandArgumentDataType=qC,C.moreThanOrEqualConditionRightHandArgumentDataTypeParentRef=kC,C.moreThanOrEqualConditionRightHandArgumentParentRef=SC,C.noSpacesOrDashesValueValidation=fU,C.noSpacesValueValidation=pU,C.notEmptyCondition=yo,C.notEmptyConditionArgument=UC,C.notEmptyConditionRef=BC,C.nullPrototype=bm,C.numberAdditionOperation=nf,C.numberAdditionOperationDynamicSummandArgument=A1,C.numberAdditionOperationDynamicSummandArgumentType=b1,C.numberAdditionOperationDynamicSummandArgumentTypeParentRef=T1,C.numberAdditionOperationError=E1,C.numberAdditionOperationErrorParentRef=v1,C.numberAdditionOperationFirstNumberArgument=Am,C.numberAdditionOperationFirstNumberArgumentRef=d1,C.numberAdditionOperationFirstNumberDataType=u1,C.numberAdditionOperationRef=y1,C.numberAdditionOperationRefThree=wm,C.numberAdditionOperationRefTwo=m1,C.numberAdditionOperationResultNumberDataType=h1,C.numberAdditionOperationResultNumberReturn=Rm,C.numberAdditionOperationResultNumberReturnRef=f1,C.numberAdditionOperationSecondNumberArgument=Im,C.numberAdditionOperationSecondNumberArgumentRef=c1,C.numberAdditionOperationSecondNumberDataType=p1,C.numberPrototype=st,C.numberSubtractionOperation=Dm,C.numberSubtractionOperationDynamicSubtrahendArgument=U1,C.numberSubtractionOperationDynamicSubtrahendArgumentType=B1,C.numberSubtractionOperationDynamicSubtrahendArgumentTypeParentRef=M1,C.numberSubtractionOperationError=L1,C.numberSubtractionOperationErrorParentRef=N1,C.numberSubtractionOperationFirstNumberArgument=$1,C.numberSubtractionOperationFirstNumberArgumentRef=I1,C.numberSubtractionOperationFirstNumberDataType=w1,C.numberSubtractionOperationRef=_m,C.numberSubtractionOperationRefThree=P1,C.numberSubtractionOperationRefTwo=O1,C.numberSubtractionOperationResultNumberDataType=g1,C.numberSubtractionOperationResultNumberReturn=V1,C.numberSubtractionOperationResultNumberReturnRef=D1,C.numberSubtractionOperationSecondNumberArgument=C1,C.numberSubtractionOperationSecondNumberArgumentRef=R1,C.numberSubtractionOperationSecondNumberDataType=_1,C.numberValueAutogenerationSchema=RE,C.operationValidation=dpe,C.outputMapValidation=mhe,C.parallelExecutionOperation=Vs,C.parallelExecutionOperationError=q_,C.parallelExecutionOperationErrorParentRef=k_,C.parallelExecutionOperationListOfExecutionResultsDataType=F_,C.parallelExecutionOperationListOfExecutionResultsReturn=Mm,C.parallelExecutionOperationListOfExecutionResultsReturnRef=x_,C.parallelExecutionOperationListOfFunctionsArgument=Lm,C.parallelExecutionOperationListOfFunctionsArgumentDatatype=j_,C.parallelExecutionOperationListOfFunctionsArgumentRef=U_,C.parallelExecutionOperationListOfFunctionsBlueprint=B_,C.parallelExecutionOperationListOfFunctionsBlueprintDynamicInput=L_,C.parallelExecutionOperationListOfFunctionsBlueprintDynamicInputParentRef=N_,C.parallelExecutionOperationListOfFunctionsBlueprintDynamicOutput=V_,C.parallelExecutionOperationListOfFunctionsBlueprintDynamicOutputParentRef=P_,C.parallelExecutionOperationListOfFunctionsBlueprintParentRef=M_,C.parallelExecutionOperationRef=G_,C.parallelExecutionOperationRefThree=K_,C.persistedBuiltInBaseEntity=Jr,C.persistedBuiltInBaseEntityDatabaseProperty=Tl,C.persistedBuiltInBaseEntityDatabasePropertyDataType=vC,C.persistedBuiltInBaseEntityDatabasePropertyDataTypeRef=d7,C.persistedBuiltInBaseEntityDatabasePropertyParentRef=EC,C.persistedBuiltInBaseEntityDatabasePropertyRef=mC,C.persistedBuiltInBaseEntityPrimaryKeyProperty=bl,C.persistedBuiltInBaseEntityPrimaryKeyPropertyDataType=DC,C.persistedBuiltInBaseEntityPrimaryKeyPropertyNumberDataTypeOption=bC,C.persistedBuiltInBaseEntityPrimaryKeyPropertyNumberDataTypeOptionParentRef=TC,C.persistedBuiltInBaseEntityPrimaryKeyPropertyParentRef=gC,C.persistedBuiltInBaseEntityPrimaryKeyPropertyRef=_C,C.persistedBuiltInBaseEntityPrimaryKeyPropertyStringDataTypeOption=IC,C.persistedBuiltInBaseEntityPrimaryKeyPropertyStringDataTypeOptionParentRef=AC,C.persistedBuiltInBaseEntityPrimaryKeyPropertyUUIDDataTypeOption=RC,C.persistedBuiltInBaseEntityPrimaryKeyPropertyUUIDDataTypeOptionParentRef=wC,C.processOutputGlobalValueDescriptorDataType=QC,C.processOutputGlobalValueDescriptorReturn=$f,C.processOutputGlobalValueDescriptorReturnRef=XC,C.projectPublicationCompletedGlobalEvent=gf,C.propertyToZodSchema=EP,C.propertyValidation=Hce,C.relationalDatabaseBuiltInBaseEntity=Br,C.relationalDatabaseBuiltInBaseEntityAutoscalingProperty=av,C.relationalDatabaseBuiltInBaseEntityAutoscalingPropertyDataType=pC,C.relationalDatabaseBuiltInBaseEntityAutoscalingPropertyDataTypeRef=cC,C.relationalDatabaseBuiltInBaseEntityAutoscalingPropertyParentRef=fC,C.relationalDatabaseBuiltInBaseEntityAutoscalingPropertyRef=uC,C.relationalDatabaseBuiltInBaseEntityDefaultProperty=nv,C.relationalDatabaseBuiltInBaseEntityDefaultPropertyDataType=dC,C.relationalDatabaseBuiltInBaseEntityDefaultPropertyDataTypeRef=oC,C.relationalDatabaseBuiltInBaseEntityDefaultPropertyRef=lC,C.relationalDatabaseBuiltInBaseEntityIdentifierProperty=Af,C.relationalDatabaseBuiltInBaseEntityIdentifierPropertyDataType=XO,C.relationalDatabaseBuiltInBaseEntityIdentifierPropertyDataTypeRef=zO,C.relationalDatabaseBuiltInBaseEntityIdentifierPropertyRef=HO,C.relationalDatabaseBuiltInBaseEntityMinSizeProperty=Rf,C.relationalDatabaseBuiltInBaseEntityMinSizePropertyDataType=aC,C.relationalDatabaseBuiltInBaseEntityMinSizePropertyDataTypeRef=sC,C.relationalDatabaseBuiltInBaseEntityMinSizePropertyRef=nC,C.relationalDatabaseBuiltInBaseEntityPasswordProperty=wf,C.relationalDatabaseBuiltInBaseEntityPasswordPropertyDataType=rC,C.relationalDatabaseBuiltInBaseEntityPasswordPropertyDataTypeRef=l7,C.relationalDatabaseBuiltInBaseEntityPasswordPropertyDefaultValueParentRef=iC,C.relationalDatabaseBuiltInBaseEntityPasswordPropertyRef=tC,C.relationalDatabaseBuiltInBaseEntityRef=El,C.relationalDatabaseBuiltInBaseEntityUsernameProperty=If,C.relationalDatabaseBuiltInBaseEntityUsernamePropertyDataType=eC,C.relationalDatabaseBuiltInBaseEntityUsernamePropertyDataTypeRef=o7,C.relationalDatabaseBuiltInBaseEntityUsernamePropertyRef=QO,C.resolveActionDescriptorName=ZL,C.resolveBaseEntityName=KL,C.resolveBuiltInBaseEntityDataTypeLabel=kL,C.resolveClonedEntityProject=yr,C.resolveConditionOperatorLabel=Zh,C.resolveDataType=kh,C.resolveDataTypeEntityOrNestedChildrenFromLiteralValue=Tb,C.resolveDataTypeLabel=Sh,C.resolveDefinitionEntityDataTypeLabel=Yce,C.resolveEntityDataTypeLabel=Wce,C.resolveEntityName=ce,C.resolveFirstCallsSecond=qhe,C.resolveFirstWritesSecond=She,C.resolvePersistedDefinitionEntityDatabaseEntity=yj,C.resolvePrimaryKeyProperty=lye,C.resolvePrimitiveEntityForSearchLiteralValueType=sb,C.resolvePrimitiveEntityName=SL,C.resolveSearchName=qL,C.resolveVariableScope=Jce,C.returnDeclarationValidation=upe,C.returnStatementValidation=cpe,C.searchStatementErrorGlobalValueDescriptor=pv,C.searchStatementErrorGlobalValueDescriptorDataType=tP,C.searchStatementErrorGlobalValueDescriptorRef=eP,C.searchStatementState=lhe,C.searchStatementUtils=uhe,C.searchValidation=bpe,C.sequentialExecutionOperation=Fn,C.sequentialExecutionOperationError=uD,C.sequentialExecutionOperationErrorParentRef=dD,C.sequentialExecutionOperationListOfExecutionResultsDataType=aD,C.sequentialExecutionOperationListOfExecutionResultsReturn=Um,C.sequentialExecutionOperationListOfExecutionResultsReturnParentRef=lD,C.sequentialExecutionOperationListOfExecutionResultsReturnRef=nD,C.sequentialExecutionOperationListOfFunctionsArgument=Bm,C.sequentialExecutionOperationListOfFunctionsArgumentDatatype=sD,C.sequentialExecutionOperationListOfFunctionsArgumentParentRef=oD,C.sequentialExecutionOperationListOfFunctionsArgumentRef=iD,C.sequentialExecutionOperationListOfFunctionsBlueprint=rD,C.sequentialExecutionOperationListOfFunctionsBlueprintDynamicInput=tD,C.sequentialExecutionOperationListOfFunctionsBlueprintDynamicOutput=eD,C.softDeletePersistedEntityMethod=u7,C.softDeletePersistedEntityMethodParentRef=$C,C.sortCallsBasedOnExecutionDependencies=EU,C.sortChildrenEntitiesBasedOnExecutionDependencies=Khe,C.splitListOperation=Cm,C.splitListOperationError=i_,C.splitListOperationErrorParentRef=r_,C.splitListOperationFirstOutputListDataType=ZR,C.splitListOperationFirstOutputListReturn=XR,C.splitListOperationFirstOutputListReturnParentRef=HR,C.splitListOperationFirstOutputListReturnRef=Om,C.splitListOperationInputListArgument=WR,C.splitListOperationInputListArgumentParentRef=JR,C.splitListOperationInputListArgumentRef=KR,C.splitListOperationInputListDataType=kR,C.splitListOperationSecondOutputListDataType=QR,C.splitListOperationSecondOutputListReturn=t_,C.splitListOperationSecondOutputListReturnParentRef=e_,C.splitListOperationSplitIndexArgument=zR,C.splitListOperationSplitIndexArgumentParentRef=YR,C.splitListOperationSplitIndexArgumentRef=qR,C.splitListOperationSplitIndexDataType=SR,C.splitStringOperation=gm,C.splitStringOperationError=IR,C.splitStringOperationErrorParentRef=AR,C.splitStringOperationFirstPartResultStringDataType=cR,C.splitStringOperationFirstPartResultStringReturn=bR,C.splitStringOperationFirstPartResultStringReturnParentRef=TR,C.splitStringOperationFirstPartResultStringReturnRef=uR,C.splitStringOperationIndexArgument=vR,C.splitStringOperationIndexArgumentParentRef=mR,C.splitStringOperationIndexArgumentRef=lR,C.splitStringOperationIndexDataType=dR,C.splitStringOperationSecondPartResultStringDataType=fR,C.splitStringOperationSecondPartResultStringReturn=n7,C.splitStringOperationSecondPartResultStringReturnParentRef=ER,C.splitStringOperationSecondPartResultStringReturnRef=pR,C.splitStringOperationStringArgument=yR,C.splitStringOperationStringArgumentParentRef=hR,C.splitStringOperationStringArgumentRef=aR,C.splitStringOperationStringDataType=oR,C.stringPrototype=ke,C.stringValueAutogenerationSchema=wE,C.suggestNewIdForEntity=UT,C.syncSearchEntityOutput=ab,C.test_primitive_entities_export=Hye,C.toCamelCase=Ra,C.toEntityState=ss,C.toKebabCase=GL,C.toLowerCaseKebabCase=qh,C.toPascalCase=Hl,C.untypedDataPrototype=Gr,C.updateErrorsList=qt,C.urlDefaultValue=FD,C.uuidPrototype=jn,C.validateArgumentDeclarationName=MT,C.validateCalledByErrorIdInAction=Ohe,C.validateCalledByIdInAction=$he,C.validateCallers=tU,C.validateConditionEntityDeclaration=Vhe,C.validateDataOperation=uo,C.validateDataOperationDataToValidateArgument=OD,C.validateDataOperationDataToValidateArgumentParentRef=$D,C.validateDataOperationDataToValidateArgumentRef=DD,C.validateDataOperationDataToValidateDataType=gD,C.validateDataOperationEntityToMatchTypeArgument=ND,C.validateDataOperationEntityToMatchTypeArgumentParentRef=VD,C.validateDataOperationEntityToMatchTypeArgumentRef=CD,C.validateDataOperationEntityToMatchTypeDataType=PD,C.validateDataOperationError=UD,C.validateDataOperationErrorParentRef=BD,C.validateDataOperationOutputEntityDeclaration=MD,C.validateDataOperationOutputEntityDeclarationParentRef=LD,C.validateDefinitionEntityName=PT,C.validateEntryCaller=eU,C.validateErrorCaller=Q3,C.validateFunctionCallDeclaration=iU,C.validateFunctionDeclarationName=VT,C.validateGeneratedEntityParentIsNotBuiltInEntity=Rhe,C.validateGeneration=Ihe,C.validateGenerationTarget=ur,C.validateGenerationUpdate=whe,C.validateLoopEntityDeclaration=Nhe,C.validateName=zce,C.validateOperationEntityDeclaration=sU,C.validatePropertyName=LT,C.validateReachability=ta,C.validateReadsValueInActionPayload=Che,C.validateReferenceObject=oy,C.validateReferenceToOne=db,C.validateReferences=Cr,C.validateReturnDeclarationName=BT,C.validateSuccessCaller=X3,C.validateValueReaderGenerationUpdate=Qc,C.validateValueWritter=yb,C.validateVariableDeclarationName=NT,C.validateVariableInternalCallUse=mb,C.valueAutogenerationCurrentDateAndTimeSchema=Q4,C.valueAutogenerationGenericSchema=mh,C.valueAutogenerationOptions=DE,C.valueAutogenerationOptionsSchema=X4,C.valueAutogenerationRandomBooleanSchema=IE,C.valueAutogenerationRandomDateBetweenSchema=lN,C.valueAutogenerationRandomDateFromSchema=aN,C.valueAutogenerationRandomDateSchema=Th,C.valueAutogenerationRandomDateUntilSchema=oN,C.valueAutogenerationRandomNumberBetweenSchema=rN,C.valueAutogenerationRandomNumberFromSchema=eN,C.valueAutogenerationRandomNumberSchema=vh,C.valueAutogenerationRandomNumberUntilSchema=tN,C.valueAutogenerationRandomSchema=Mu,C.valueAutogenerationRandomTextBetweenSchema=nN,C.valueAutogenerationRandomTextFromSchema=iN,C.valueAutogenerationRandomTextSchema=Eh,C.valueAutogenerationRandomTextUntilSchema=sN,C.valueAutogenerationRangeValueTypesSchema=Lu,C.valueAutogenerationUniqueSchema=AE,C.valueDescriptorValidation=Ahe,C.variableDeclarationValidation=Epe,C.variableInstanceValidation=Tpe,C.waitOperation=mi,C.waitOperationMillisecondsNumberArgument=oo,C.waitOperationMillisecondsNumberArgumentRef=J_,C.waitOperationMillisecondsNumberDataType=W_,C.waitOperationOperationError=H_,C.waitOperationOperationErrorParentRef=z_,C.waitOperationRef=Y_,Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elyx-code/project-logic-tree",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6317",
|
|
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",
|