@elyx-code/project-logic-tree 0.0.6639 → 0.0.6640
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 +5 -5
- package/dist/index.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -182027,7 +182027,7 @@ function pLi(d, p, i) {
|
|
|
182027
182027
|
if ((d == null ? void 0 : d.id) === (p == null ? void 0 : p.id))
|
|
182028
182028
|
if (cn.includes(d.type)) {
|
|
182029
182029
|
let L = null;
|
|
182030
|
-
return d.type === o.Loop || d.type === o.FunctionDeclaration && d.parent.type === o.Loop ? L = "loop-body" : d.type === o.FunctionDeclaration && (L = "entry"), {
|
|
182030
|
+
return d.type === o.Loop || d.type === o.FunctionDeclaration && d.parent.type === o.Loop ? L = "loop-body" : (d.type === o.FunctionDeclaration || d.type === o.GlobalEvent) && (L = "entry"), {
|
|
182031
182031
|
ancestor: d,
|
|
182032
182032
|
callType: L || "success"
|
|
182033
182033
|
};
|
|
@@ -182128,7 +182128,7 @@ function pLi(d, p, i) {
|
|
|
182128
182128
|
else if (S.some((Y) => Y.callee.id === (p == null ? void 0 : p.id))) {
|
|
182129
182129
|
if ((E == null ? void 0 : E.type) === o.Loop || (E == null ? void 0 : E.type) === o.FunctionDeclaration && (E == null ? void 0 : E.parent.type) === o.Loop)
|
|
182130
182130
|
n.callType = "loop-body";
|
|
182131
|
-
else if ((E == null ? void 0 : E.type) === o.FunctionDeclaration)
|
|
182131
|
+
else if ((E == null ? void 0 : E.type) === o.FunctionDeclaration || (E == null ? void 0 : E.type) === o.GlobalEvent)
|
|
182132
182132
|
n.callType = "entry";
|
|
182133
182133
|
else {
|
|
182134
182134
|
const ne = qo(
|
|
@@ -182145,7 +182145,7 @@ function pLi(d, p, i) {
|
|
|
182145
182145
|
} else if (q.some((Y) => Y.callee.id === (d == null ? void 0 : d.id))) {
|
|
182146
182146
|
if ((E == null ? void 0 : E.type) === o.Loop || (E == null ? void 0 : E.type) === o.FunctionDeclaration && (E == null ? void 0 : E.parent.type) === o.Loop)
|
|
182147
182147
|
n.callType = "loop-body";
|
|
182148
|
-
else if ((E == null ? void 0 : E.type) === o.FunctionDeclaration)
|
|
182148
|
+
else if ((E == null ? void 0 : E.type) === o.FunctionDeclaration || (E == null ? void 0 : E.type) === o.GlobalEvent)
|
|
182149
182149
|
n.callType = "entry";
|
|
182150
182150
|
else {
|
|
182151
182151
|
const ne = qo(
|
|
@@ -182162,7 +182162,7 @@ function pLi(d, p, i) {
|
|
|
182162
182162
|
} else {
|
|
182163
182163
|
if ((E == null ? void 0 : E.type) === o.Loop || (E == null ? void 0 : E.type) === o.FunctionDeclaration && (E == null ? void 0 : E.parent.type) === o.Loop)
|
|
182164
182164
|
n.callType = "loop-body";
|
|
182165
|
-
else if ((E == null ? void 0 : E.type) === o.FunctionDeclaration)
|
|
182165
|
+
else if ((E == null ? void 0 : E.type) === o.FunctionDeclaration || (E == null ? void 0 : E.type) === o.GlobalEvent)
|
|
182166
182166
|
n.callType = "entry";
|
|
182167
182167
|
else {
|
|
182168
182168
|
const ne = qo(
|
|
@@ -182180,7 +182180,7 @@ function pLi(d, p, i) {
|
|
|
182180
182180
|
}
|
|
182181
182181
|
if (!n.ancestor) {
|
|
182182
182182
|
let L = null;
|
|
182183
|
-
return (E == null ? void 0 : E.type) === o.Loop || (E == null ? void 0 : E.type) === o.FunctionDeclaration && (E == null ? void 0 : E.parent.type) === o.Loop ? L = "loop-body" : (E == null ? void 0 : E.type) === o.FunctionDeclaration && (L = "entry"), {
|
|
182183
|
+
return (E == null ? void 0 : E.type) === o.Loop || (E == null ? void 0 : E.type) === o.FunctionDeclaration && (E == null ? void 0 : E.parent.type) === o.Loop ? L = "loop-body" : ((E == null ? void 0 : E.type) === o.FunctionDeclaration || (E == null ? void 0 : E.type) === o.GlobalEvent) && (L = "entry"), {
|
|
182184
182184
|
ancestor: E,
|
|
182185
182185
|
callType: L || "success"
|
|
182186
182186
|
};
|
package/dist/index.umd.cjs
CHANGED
|
@@ -371,7 +371,7 @@ You shouldn't have to manually update a 'parent' property. The equivalent result
|
|
|
371
371
|
parent: `+((he=(ee=k.parent)==null?void 0:ee.parent)==null?void 0:he.id)+" - "+((fe=(de=k.parent)==null?void 0:de.parent)==null?void 0:fe.name):"(not found) "+k.type+" "+k.id})),r.close(),ae.log("AFTER - changeSet.listAdded",r.listAdded.map(k=>{var Z,X,se,ee,he,de,fe;const q=d.get(k.id);return q?q.type+' "'+le(q,d)+'" ('+q.id+")":k.type===o.InputMap?"(not found) "+k.type+" ("+k.id+") - declaration: "+((Z=k.declaration)==null?void 0:Z.type)+" ("+((X=k.declaration)==null?void 0:X.id)+') "'+((se=k.declaration)==null?void 0:se.name)+`"
|
|
372
372
|
parent: "`+((he=(ee=k.parent)==null?void 0:ee.parent)==null?void 0:he.name)+'" ('+((fe=(de=k.parent)==null?void 0:de.parent)==null?void 0:fe.id)+")":"(not found) "+k.type+" "+k.id})),ae.log("-----------------"),ae.log("Old properties: ",xr(i).map(k=>k.name+" ("+k.id+")")),ae.log("New properties: ",xr(p).map(k=>k.name+" ("+k.id+")"));const A=e.methods.find(k=>{var q;return((q=k.implements)==null?void 0:q.id)===Q["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.methods.up.id}),b=e.methods.find(k=>{var q;return((q=k.implements)==null?void 0:q.id)===Q["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.methods.down.id});ae.log(`
|
|
373
373
|
Up inputs: `,A==null?void 0:A.inputs.map(k=>k.name+" ("+k.id+")")),ae.log("Up method return statements:",A==null?void 0:A.returnStatements[0].outputs.map(k=>le(k,d)+" ("+k.id+")")),ae.log(`
|
|
374
|
-
Down inputs: `,b==null?void 0:b.inputs.map(k=>k.name+" ("+k.id+")")),ae.log("Down method return statements:",b==null?void 0:b.returnStatements[0].outputs.map(k=>le(k,d)+" ("+k.id+")"));const w=z2e(r.listAdded.map(k=>d.get(k.id)));let P=p.x;const x=p.y-800;return w.forEach(k=>{var Z;P+=k.x||300*2;let q=k.y||x;k.type===o.ReturnStatement&&((Z=k.parent)==null?void 0:Z.id)===E.id&&(q+=800+70),k.metaSync({x:P,y:q},r)}),(M=y.defaultValue)==null||M.metaSync({editable:!1,deletable:!1},r),y.metaSync({editable:!1,deletable:!1},r),e}function q_(d,p){var i;if(d.type===o.LiteralValue){let r=(i=d.value)==null?void 0:i.toString();try{r=JSON.stringify(d.value,null,2)}catch{}return`${d.type}: ${d.id} (${le(d,p)}) = ${r}`}if(d.type===o.DataType){if(d instanceof dn||d.increaseVersion)return`${d.type}: ${d.id} (${nh(d)})`;try{const r=nh(d);return`${d.type}: ${d.id} (${r})`}catch{}}return`${d.type}: ${d.id} (${le(d,p)})`}function Jy(d,p){const i=Rp(d);if(i.length===0)return{list:[],last:null};let r=null;return{list:i.flatMap(c=>{if(c===p)return r=c,[c];const e=Jy(c,p);return e.last&&(r=e.last),[c,...e.list]}),last:r}}function Ip(d,p){const i=d.calledBy;if(i.length===0)return{list:[],last:null,callType:null};let r=null,l=null;return{list:i.flatMap(e=>{if(e===p)return r=e,Wt.includes(e.type)?e.parent.type===o.Loop?l="loop-body":l="entry":e.successCalls.includes(d)?l="success":e.errorCalls.includes(d)&&(l="error"),[e];if(e.type===o.FunctionDeclaration&&e.parent.type===o.Loop&&e.parent===p)return r=e.parent,l="loop-body",[e];if(!cr.includes(e.type))return[e];const y=Ip(e,p);return y.last&&(r=y.last,l=y.callType),[e,...y.list]}),last:r,callType:l}}function Y$t(d,p){if(d===p)return"same-entity";if(!ir.includes(d.type)||!Po(d).find(l=>l.callee===p))return null;if(Wt.includes(d.type)){if(d.calls.includes(p))return d.type===o.Loop?"loop-body":"entry"}else if(Ci.includes(d.type)&&d.type!==o.InternalCall){if(d.successCalls.includes(p))return"success";if(d.errorCalls.includes(p))return"error"}return null}function MT(d){const p=lr(d,d.project);return p?Wt.includes(p.type)?p:p.type===o.Loop?p.body:null:null}function jLe(d,p){const i=d.calledBy;return!i||!i.length?!1:i.every(r=>r===p?!0:cr.includes(r.type)?!!Ip(r,p).last:!1)}function kLe(d){return d.filter(p=>{const i=MT(p);return!d.filter(c=>c!==p).some(c=>c===i?!1:Pg(c,p))})}function Z_(d){if(!d.calledBy||!d.calledBy.length)return[];const p=d.calledBy.reduce((i,r)=>{if(cr.includes(r.type)){const l=Z_(r);return[...i,r,...l]}return i},[]);return O(p)}function KLe(d){const p=Z_(d);if(!p.length)return{ancestor:null,callType:null};const r=p.filter(c=>!(c===d||!ir.includes(c.type)||!Ot(c).find(v=>v===d))).filter((c,e,y)=>y.findIndex(v=>v===c)===e).filter(c=>jLe(d,c)),l=r.filter(c=>{const e=Ot(c),y=r.filter(E=>E!==c).map(E=>E);return!e.some(E=>!!y.find(b=>b===E))});if(l.length===0)return{ancestor:null,callType:null};if(l.length===1){const c=l[0];if(c.type===o.Loop){if(c.body.calls.includes(d))return{ancestor:c,callType:"loop-body"}}else if(Wt.includes(c.type)){if(c.calls.includes(d))return c.type===o.FunctionDeclaration&&c.parent.type===o.Loop?{ancestor:c,callType:"loop-body"}:{ancestor:c,callType:"entry"}}else if(Ci.includes(c.type)){if(c.successCalls.includes(d))return{ancestor:c,callType:"success"};if(c.errorCalls.includes(d))return{ancestor:c,callType:"error"}}}if(l.length>1)throw new Error(`resolveEarliestSingleCallerAncestor: Multiple callers found for entity ${d.id}.`);return{ancestor:l[0],callType:null}}function SLe(d,p,i){var b,w,P,x;const r={ancestor:null,callType:null};if(!d)throw new Error("[findNextCombinedSingleCallerAncestor] No 'targetA' given");if(!p)throw new Error("[findNextCombinedSingleCallerAncestor] No 'targetB' given");if((d==null?void 0:d.id)===(p==null?void 0:p.id))if(ir.includes(d.type)){let M=null;return d.type===o.Loop||d.type===o.FunctionDeclaration&&d.parent.type===o.Loop?M="loop-body":d.type===o.FunctionDeclaration&&(M="entry"),{ancestor:d,callType:M||"success"}}else{if(cr.includes(d.type))return BT(d,i);throw new Error(`[findNextCombinedSingleCallerAncestor] Invalid 'targetA' and 'targetB' arguments, neither is a callable or caller entity: ${d.type} -- ${d.id}`)}if(i){const M=Po(i),k=M.find(Z=>Z.callee===d),q=M.find(Z=>Z.callee===p);if(!k)throw new Error(`[findNextCombinedSingleCallerAncestor] Invalid 'from' ${i.type} -- ${i.id} argument, doesn't contain 'targetA' entity ${d.type} -- ${d.id}`);if(!q)throw new Error(`[findNextCombinedSingleCallerAncestor] Invalid 'from' ${i.type} -- ${i.id} argument, doesn't contain 'targetB' entity ${p.type} -- ${p.id}`)}const l=jd(d,d.project),c=jd(p,p.project);if((l==null?void 0:l.id)!==(c==null?void 0:c.id))return r;if(!l)return{ancestor:null,callType:null};const e=lr(d,d.project),y=lr(p,p.project);if(!e)throw new Error(`[findNextCombinedSingleCallerAncestor] Invalid 'targetA' argument, doesn't have a scope owner: ${d.type} -- ${d.id}`);if(!y)throw new Error(`[findNextCombinedSingleCallerAncestor] Invalid 'targetB' argument, doesn't have a scope owner: ${p.type} -- ${p.id}`);const v=hs(e,y,d.project);let E;if(v.type==="same-both-local"||v.type==="same-both-global")E=e;else if(v.type==="b-in-a")E=e;else if(v.type==="a-in-b")E=y;else if(v.type==="parallel-in-common-parent")E=l;else if(v.type==="a-is-global-b-is-not"||v.type==="b-is-global-a-is-not"||v.type==="parallel-in-project")return{ancestor:null,callType:null};if(E.type===o.Project)return{ancestor:null,callType:null};let A=i||E;if(!A)return{ancestor:null,callType:null};if(!ir.includes(A.type))throw new Error(`[findNextCombinedSingleCallerAncestor] Invalid 'from' argument, is not a caller entity: ${A.type} -- ${A.id}`);if(cr.includes(d.type)&&cr.includes(p.type)){const M=BT(d,A),k=BT(p,A),q=Po(M.ancestor),Z=Po(k.ancestor);if(((b=k.ancestor)==null?void 0:b.id)===((w=M.ancestor)==null?void 0:w.id))r.ancestor=k.ancestor,r.callType=k.callType;else if(((P=k.ancestor)==null?void 0:P.id)===d.id)r.ancestor=k.ancestor,r.callType=k.callType;else if(((x=M.ancestor)==null?void 0:x.id)===p.id)r.ancestor=M.ancestor,r.callType=M.callType;else if(q.some(X=>X.callee.id===(p==null?void 0:p.id))){if((A==null?void 0:A.type)===o.Loop||(A==null?void 0:A.type)===o.FunctionDeclaration&&(A==null?void 0:A.parent.type)===o.Loop)r.callType="loop-body";else if((A==null?void 0:A.type)===o.FunctionDeclaration)r.callType="entry";else{const se=Po(E).find(ee=>ee.callee.id===(d==null?void 0:d.id));return{ancestor:E,callType:(se==null?void 0:se.callType)||"success"}}r.ancestor=E}else if(Z.some(X=>X.callee.id===(d==null?void 0:d.id))){if((A==null?void 0:A.type)===o.Loop||(A==null?void 0:A.type)===o.FunctionDeclaration&&(A==null?void 0:A.parent.type)===o.Loop)r.callType="loop-body";else if((A==null?void 0:A.type)===o.FunctionDeclaration)r.callType="entry";else{const se=Po(E).find(ee=>ee.callee.id===(p==null?void 0:p.id));return{ancestor:E,callType:(se==null?void 0:se.callType)||"success"}}r.ancestor=E}else{if((A==null?void 0:A.type)===o.Loop||(A==null?void 0:A.type)===o.FunctionDeclaration&&(A==null?void 0:A.parent.type)===o.Loop)r.callType="loop-body";else if((A==null?void 0:A.type)===o.FunctionDeclaration)r.callType="entry";else{const se=Po(E).find(ee=>ee.callee.id===(d==null?void 0:d.id));return{ancestor:E,callType:(se==null?void 0:se.callType)||"success"}}r.ancestor=E}}if(!r.ancestor){let M=null;return(A==null?void 0:A.type)===o.Loop||(A==null?void 0:A.type)===o.FunctionDeclaration&&(A==null?void 0:A.parent.type)===o.Loop?M="loop-body":(A==null?void 0:A.type)===o.FunctionDeclaration&&(M="entry"),{ancestor:A,callType:M||"success"}}return r}function BT(d,p,i=!1){var q;if(!d)throw new Error("findNextSingleCallerAncestor: Target is not defined, cannot find ancestor.");let r=d;(d.type===o.VariableDeclaration||d.type===o.VariableInstance)&&!d.calledBy.length&&!d.successCalls.length&&!d.errorCalls.length&&d.internalCalls.some(Z=>!!Z.calledBy.length)&&(r=d.internalCalls.find(X=>!!X.calledBy.length));const l=lr(r,d.project);let c=p||l;if(!c)return{ancestor:null,callType:null};if(c.type===o.Project&&(c=KLe(r).ancestor,!c))return{ancestor:null,callType:null};const e=Po(c);if(!e.find(Z=>Z.callee===r))return{ancestor:null,callType:null};const v=[...r.calledBy];if(!v.length)return{ancestor:null,callType:null};if(v.length===1){const Z=v[0];if(Z.type===o.Loop){if(Z.body.calls.includes(r))return{ancestor:Z,callType:"loop-body"}}else{if(Wt.includes(Z.type))return Z.type===o.FunctionDeclaration&&Z.parent.type===o.Loop?{ancestor:Z.parent,callType:"loop-body"}:{ancestor:Z,callType:"entry"};if(Ci.includes(Z.type)){if(Z.successCalls.includes(r))return{ancestor:Z,callType:"success"};if(Z.errorCalls.includes(r))return{ancestor:Z,callType:"error"}}}}const E=Gt.includes(r.type)?[]:Ot(r),A=e.filter(Z=>!(Gt.includes(Z.callee.type)||Z.callee===r||!Ot(Z.callee).find(se=>se===r)||E.find(se=>se===Z.callee)));if(i&&(console.log("Flat calls from start point",c.type+" -- "+c.id,e.length,e.map((Z,X)=>X+1+'. "'+le(Z.callee,d.project)+'" '+Z.callee.type+" -- "+Z.callee.id)),console.log("----------------------------------------")),i&&(console.log("Relevant flat calls from start point",c.type+" -- "+c.id,A.length,A.map((Z,X)=>X+1+'. "'+le(Z.callee,d.project)+'" '+Z.callee.type+" -- "+Z.callee.id)),console.log("----------------------------------------")),c.type===o.Loop){if(c.body.calls.includes(r))return{ancestor:c,callType:"loop-body"}}else if(Wt.includes(c.type)){if(c.calls.includes(r))return c.type===o.FunctionDeclaration&&c.parent.type===o.Loop?{ancestor:c.parent,callType:"loop-body"}:{ancestor:c,callType:"entry"}}else if(Ci.includes(c.type)){if(d.calledBy.length===1){if(c.successCalls.includes(r))return{ancestor:c,callType:"success"};if(c.errorCalls.includes(r))return{ancestor:c,callType:"error"}}else if(c.successCalls.includes(r)||c.errorCalls.includes(r))return{ancestor:null,callType:null}}const b=A.filter(Z=>{if(Z.callee===r||!ir.includes(Z.callee.type))return!1;if(!!v.find(de=>de===Z.callee))return!0;const se=Ot(Z.callee),ee=!!se.find(de=>de===r),he=!!v.every(de=>se.find(fe=>fe===de));return!(!ee||!he)}).filter((Z,X,se)=>se.findIndex(ee=>ee.callee===Z.callee)===X);if(i&&(console.log("Remaining calls that reach target",b.length,b.map((Z,X)=>X+1+'. "'+le(Z.callee,d.project)+'" '+Z.callee.type+" -- "+Z.callee.id)),console.log("----------------------------------------")),b.length===0)return{ancestor:null,callType:null};const w=b.filter(Z=>{const X=b.filter(se=>se!==Z).map(se=>se.callee);return Wt.includes(Z.callee.type)&&Z.callee.calls.length===1&&X.find(se=>se===Z.callee.calls[0])||Ci.includes(Z.callee.type)&&Z.callee.successCalls.length===1&&X.find(se=>{var ee;return se.id===((ee=Z.callee.successCalls[0])==null?void 0:ee.id)})?!1:!(Ci.includes(Z.callee.type)&&Z.callee.errorCalls.length===1&&X.find(se=>{var ee;return se.id===((ee=Z.callee.errorCalls[0])==null?void 0:ee.id)}))});if(i&&(console.log("Reduced single callers",w.length,w.map((Z,X)=>X+1+'. "'+le(Z.callee,d.project)+'" '+Z.callee.type+" -- "+Z.callee.id)),console.log("----------------------------------------")),w.length===0)return{ancestor:null,callType:null};if(w.length===1){const Z=w[0];if(Z.callee.type===o.Loop){if(Z.callee.body.calls.includes(r))return{ancestor:Z.callee,callType:"loop-body"}}else{if(Wt.includes(Z.callee.type))return Z.callee.type===o.FunctionDeclaration&&Z.callee.parent.type===o.Loop?{ancestor:Z.callee.parent,callType:"loop-body"}:{ancestor:Z.callee,callType:"entry"};if(Ci.includes(Z.callee.type)){if(Z.callType==="success"&&Z.callee.type===o.InternalCall)return{ancestor:Z.callee,callType:"success"};if(Z.callType==="error"&&Z.callee.type===o.InternalCall)return{ancestor:Z.callee,callType:"error"}}}}let P=c,x=null,M=w[0].callee,k=w.slice(1);for(;k.length;){const Z=SLe(M,k[0].callee,c);if(((q=Z==null?void 0:Z.ancestor)==null?void 0:q.id)===c.id)return{ancestor:c,callType:Z.callType};Z.ancestor?(P=Z.ancestor,M=Z.ancestor,x=Z.callType,i&&console.log('Combined single caller between "'+le(M,r.project)+'" ',M.type+" -- "+M.id,`
|
|
374
|
+
Down inputs: `,b==null?void 0:b.inputs.map(k=>k.name+" ("+k.id+")")),ae.log("Down method return statements:",b==null?void 0:b.returnStatements[0].outputs.map(k=>le(k,d)+" ("+k.id+")"));const w=z2e(r.listAdded.map(k=>d.get(k.id)));let P=p.x;const x=p.y-800;return w.forEach(k=>{var Z;P+=k.x||300*2;let q=k.y||x;k.type===o.ReturnStatement&&((Z=k.parent)==null?void 0:Z.id)===E.id&&(q+=800+70),k.metaSync({x:P,y:q},r)}),(M=y.defaultValue)==null||M.metaSync({editable:!1,deletable:!1},r),y.metaSync({editable:!1,deletable:!1},r),e}function q_(d,p){var i;if(d.type===o.LiteralValue){let r=(i=d.value)==null?void 0:i.toString();try{r=JSON.stringify(d.value,null,2)}catch{}return`${d.type}: ${d.id} (${le(d,p)}) = ${r}`}if(d.type===o.DataType){if(d instanceof dn||d.increaseVersion)return`${d.type}: ${d.id} (${nh(d)})`;try{const r=nh(d);return`${d.type}: ${d.id} (${r})`}catch{}}return`${d.type}: ${d.id} (${le(d,p)})`}function Jy(d,p){const i=Rp(d);if(i.length===0)return{list:[],last:null};let r=null;return{list:i.flatMap(c=>{if(c===p)return r=c,[c];const e=Jy(c,p);return e.last&&(r=e.last),[c,...e.list]}),last:r}}function Ip(d,p){const i=d.calledBy;if(i.length===0)return{list:[],last:null,callType:null};let r=null,l=null;return{list:i.flatMap(e=>{if(e===p)return r=e,Wt.includes(e.type)?e.parent.type===o.Loop?l="loop-body":l="entry":e.successCalls.includes(d)?l="success":e.errorCalls.includes(d)&&(l="error"),[e];if(e.type===o.FunctionDeclaration&&e.parent.type===o.Loop&&e.parent===p)return r=e.parent,l="loop-body",[e];if(!cr.includes(e.type))return[e];const y=Ip(e,p);return y.last&&(r=y.last,l=y.callType),[e,...y.list]}),last:r,callType:l}}function Y$t(d,p){if(d===p)return"same-entity";if(!ir.includes(d.type)||!Po(d).find(l=>l.callee===p))return null;if(Wt.includes(d.type)){if(d.calls.includes(p))return d.type===o.Loop?"loop-body":"entry"}else if(Ci.includes(d.type)&&d.type!==o.InternalCall){if(d.successCalls.includes(p))return"success";if(d.errorCalls.includes(p))return"error"}return null}function MT(d){const p=lr(d,d.project);return p?Wt.includes(p.type)?p:p.type===o.Loop?p.body:null:null}function jLe(d,p){const i=d.calledBy;return!i||!i.length?!1:i.every(r=>r===p?!0:cr.includes(r.type)?!!Ip(r,p).last:!1)}function kLe(d){return d.filter(p=>{const i=MT(p);return!d.filter(c=>c!==p).some(c=>c===i?!1:Pg(c,p))})}function Z_(d){if(!d.calledBy||!d.calledBy.length)return[];const p=d.calledBy.reduce((i,r)=>{if(cr.includes(r.type)){const l=Z_(r);return[...i,r,...l]}return i},[]);return O(p)}function KLe(d){const p=Z_(d);if(!p.length)return{ancestor:null,callType:null};const r=p.filter(c=>!(c===d||!ir.includes(c.type)||!Ot(c).find(v=>v===d))).filter((c,e,y)=>y.findIndex(v=>v===c)===e).filter(c=>jLe(d,c)),l=r.filter(c=>{const e=Ot(c),y=r.filter(E=>E!==c).map(E=>E);return!e.some(E=>!!y.find(b=>b===E))});if(l.length===0)return{ancestor:null,callType:null};if(l.length===1){const c=l[0];if(c.type===o.Loop){if(c.body.calls.includes(d))return{ancestor:c,callType:"loop-body"}}else if(Wt.includes(c.type)){if(c.calls.includes(d))return c.type===o.FunctionDeclaration&&c.parent.type===o.Loop?{ancestor:c,callType:"loop-body"}:{ancestor:c,callType:"entry"}}else if(Ci.includes(c.type)){if(c.successCalls.includes(d))return{ancestor:c,callType:"success"};if(c.errorCalls.includes(d))return{ancestor:c,callType:"error"}}}if(l.length>1)throw new Error(`resolveEarliestSingleCallerAncestor: Multiple callers found for entity ${d.id}.`);return{ancestor:l[0],callType:null}}function SLe(d,p,i){var b,w,P,x;const r={ancestor:null,callType:null};if(!d)throw new Error("[findNextCombinedSingleCallerAncestor] No 'targetA' given");if(!p)throw new Error("[findNextCombinedSingleCallerAncestor] No 'targetB' given");if((d==null?void 0:d.id)===(p==null?void 0:p.id))if(ir.includes(d.type)){let M=null;return d.type===o.Loop||d.type===o.FunctionDeclaration&&d.parent.type===o.Loop?M="loop-body":(d.type===o.FunctionDeclaration||d.type===o.GlobalEvent)&&(M="entry"),{ancestor:d,callType:M||"success"}}else{if(cr.includes(d.type))return BT(d,i);throw new Error(`[findNextCombinedSingleCallerAncestor] Invalid 'targetA' and 'targetB' arguments, neither is a callable or caller entity: ${d.type} -- ${d.id}`)}if(i){const M=Po(i),k=M.find(Z=>Z.callee===d),q=M.find(Z=>Z.callee===p);if(!k)throw new Error(`[findNextCombinedSingleCallerAncestor] Invalid 'from' ${i.type} -- ${i.id} argument, doesn't contain 'targetA' entity ${d.type} -- ${d.id}`);if(!q)throw new Error(`[findNextCombinedSingleCallerAncestor] Invalid 'from' ${i.type} -- ${i.id} argument, doesn't contain 'targetB' entity ${p.type} -- ${p.id}`)}const l=jd(d,d.project),c=jd(p,p.project);if((l==null?void 0:l.id)!==(c==null?void 0:c.id))return r;if(!l)return{ancestor:null,callType:null};const e=lr(d,d.project),y=lr(p,p.project);if(!e)throw new Error(`[findNextCombinedSingleCallerAncestor] Invalid 'targetA' argument, doesn't have a scope owner: ${d.type} -- ${d.id}`);if(!y)throw new Error(`[findNextCombinedSingleCallerAncestor] Invalid 'targetB' argument, doesn't have a scope owner: ${p.type} -- ${p.id}`);const v=hs(e,y,d.project);let E;if(v.type==="same-both-local"||v.type==="same-both-global")E=e;else if(v.type==="b-in-a")E=e;else if(v.type==="a-in-b")E=y;else if(v.type==="parallel-in-common-parent")E=l;else if(v.type==="a-is-global-b-is-not"||v.type==="b-is-global-a-is-not"||v.type==="parallel-in-project")return{ancestor:null,callType:null};if(E.type===o.Project)return{ancestor:null,callType:null};let A=i||E;if(!A)return{ancestor:null,callType:null};if(!ir.includes(A.type))throw new Error(`[findNextCombinedSingleCallerAncestor] Invalid 'from' argument, is not a caller entity: ${A.type} -- ${A.id}`);if(cr.includes(d.type)&&cr.includes(p.type)){const M=BT(d,A),k=BT(p,A),q=Po(M.ancestor),Z=Po(k.ancestor);if(((b=k.ancestor)==null?void 0:b.id)===((w=M.ancestor)==null?void 0:w.id))r.ancestor=k.ancestor,r.callType=k.callType;else if(((P=k.ancestor)==null?void 0:P.id)===d.id)r.ancestor=k.ancestor,r.callType=k.callType;else if(((x=M.ancestor)==null?void 0:x.id)===p.id)r.ancestor=M.ancestor,r.callType=M.callType;else if(q.some(X=>X.callee.id===(p==null?void 0:p.id))){if((A==null?void 0:A.type)===o.Loop||(A==null?void 0:A.type)===o.FunctionDeclaration&&(A==null?void 0:A.parent.type)===o.Loop)r.callType="loop-body";else if((A==null?void 0:A.type)===o.FunctionDeclaration||(A==null?void 0:A.type)===o.GlobalEvent)r.callType="entry";else{const se=Po(E).find(ee=>ee.callee.id===(d==null?void 0:d.id));return{ancestor:E,callType:(se==null?void 0:se.callType)||"success"}}r.ancestor=E}else if(Z.some(X=>X.callee.id===(d==null?void 0:d.id))){if((A==null?void 0:A.type)===o.Loop||(A==null?void 0:A.type)===o.FunctionDeclaration&&(A==null?void 0:A.parent.type)===o.Loop)r.callType="loop-body";else if((A==null?void 0:A.type)===o.FunctionDeclaration||(A==null?void 0:A.type)===o.GlobalEvent)r.callType="entry";else{const se=Po(E).find(ee=>ee.callee.id===(p==null?void 0:p.id));return{ancestor:E,callType:(se==null?void 0:se.callType)||"success"}}r.ancestor=E}else{if((A==null?void 0:A.type)===o.Loop||(A==null?void 0:A.type)===o.FunctionDeclaration&&(A==null?void 0:A.parent.type)===o.Loop)r.callType="loop-body";else if((A==null?void 0:A.type)===o.FunctionDeclaration||(A==null?void 0:A.type)===o.GlobalEvent)r.callType="entry";else{const se=Po(E).find(ee=>ee.callee.id===(d==null?void 0:d.id));return{ancestor:E,callType:(se==null?void 0:se.callType)||"success"}}r.ancestor=E}}if(!r.ancestor){let M=null;return(A==null?void 0:A.type)===o.Loop||(A==null?void 0:A.type)===o.FunctionDeclaration&&(A==null?void 0:A.parent.type)===o.Loop?M="loop-body":((A==null?void 0:A.type)===o.FunctionDeclaration||(A==null?void 0:A.type)===o.GlobalEvent)&&(M="entry"),{ancestor:A,callType:M||"success"}}return r}function BT(d,p,i=!1){var q;if(!d)throw new Error("findNextSingleCallerAncestor: Target is not defined, cannot find ancestor.");let r=d;(d.type===o.VariableDeclaration||d.type===o.VariableInstance)&&!d.calledBy.length&&!d.successCalls.length&&!d.errorCalls.length&&d.internalCalls.some(Z=>!!Z.calledBy.length)&&(r=d.internalCalls.find(X=>!!X.calledBy.length));const l=lr(r,d.project);let c=p||l;if(!c)return{ancestor:null,callType:null};if(c.type===o.Project&&(c=KLe(r).ancestor,!c))return{ancestor:null,callType:null};const e=Po(c);if(!e.find(Z=>Z.callee===r))return{ancestor:null,callType:null};const v=[...r.calledBy];if(!v.length)return{ancestor:null,callType:null};if(v.length===1){const Z=v[0];if(Z.type===o.Loop){if(Z.body.calls.includes(r))return{ancestor:Z,callType:"loop-body"}}else{if(Wt.includes(Z.type))return Z.type===o.FunctionDeclaration&&Z.parent.type===o.Loop?{ancestor:Z.parent,callType:"loop-body"}:{ancestor:Z,callType:"entry"};if(Ci.includes(Z.type)){if(Z.successCalls.includes(r))return{ancestor:Z,callType:"success"};if(Z.errorCalls.includes(r))return{ancestor:Z,callType:"error"}}}}const E=Gt.includes(r.type)?[]:Ot(r),A=e.filter(Z=>!(Gt.includes(Z.callee.type)||Z.callee===r||!Ot(Z.callee).find(se=>se===r)||E.find(se=>se===Z.callee)));if(i&&(console.log("Flat calls from start point",c.type+" -- "+c.id,e.length,e.map((Z,X)=>X+1+'. "'+le(Z.callee,d.project)+'" '+Z.callee.type+" -- "+Z.callee.id)),console.log("----------------------------------------")),i&&(console.log("Relevant flat calls from start point",c.type+" -- "+c.id,A.length,A.map((Z,X)=>X+1+'. "'+le(Z.callee,d.project)+'" '+Z.callee.type+" -- "+Z.callee.id)),console.log("----------------------------------------")),c.type===o.Loop){if(c.body.calls.includes(r))return{ancestor:c,callType:"loop-body"}}else if(Wt.includes(c.type)){if(c.calls.includes(r))return c.type===o.FunctionDeclaration&&c.parent.type===o.Loop?{ancestor:c.parent,callType:"loop-body"}:{ancestor:c,callType:"entry"}}else if(Ci.includes(c.type)){if(d.calledBy.length===1){if(c.successCalls.includes(r))return{ancestor:c,callType:"success"};if(c.errorCalls.includes(r))return{ancestor:c,callType:"error"}}else if(c.successCalls.includes(r)||c.errorCalls.includes(r))return{ancestor:null,callType:null}}const b=A.filter(Z=>{if(Z.callee===r||!ir.includes(Z.callee.type))return!1;if(!!v.find(de=>de===Z.callee))return!0;const se=Ot(Z.callee),ee=!!se.find(de=>de===r),he=!!v.every(de=>se.find(fe=>fe===de));return!(!ee||!he)}).filter((Z,X,se)=>se.findIndex(ee=>ee.callee===Z.callee)===X);if(i&&(console.log("Remaining calls that reach target",b.length,b.map((Z,X)=>X+1+'. "'+le(Z.callee,d.project)+'" '+Z.callee.type+" -- "+Z.callee.id)),console.log("----------------------------------------")),b.length===0)return{ancestor:null,callType:null};const w=b.filter(Z=>{const X=b.filter(se=>se!==Z).map(se=>se.callee);return Wt.includes(Z.callee.type)&&Z.callee.calls.length===1&&X.find(se=>se===Z.callee.calls[0])||Ci.includes(Z.callee.type)&&Z.callee.successCalls.length===1&&X.find(se=>{var ee;return se.id===((ee=Z.callee.successCalls[0])==null?void 0:ee.id)})?!1:!(Ci.includes(Z.callee.type)&&Z.callee.errorCalls.length===1&&X.find(se=>{var ee;return se.id===((ee=Z.callee.errorCalls[0])==null?void 0:ee.id)}))});if(i&&(console.log("Reduced single callers",w.length,w.map((Z,X)=>X+1+'. "'+le(Z.callee,d.project)+'" '+Z.callee.type+" -- "+Z.callee.id)),console.log("----------------------------------------")),w.length===0)return{ancestor:null,callType:null};if(w.length===1){const Z=w[0];if(Z.callee.type===o.Loop){if(Z.callee.body.calls.includes(r))return{ancestor:Z.callee,callType:"loop-body"}}else{if(Wt.includes(Z.callee.type))return Z.callee.type===o.FunctionDeclaration&&Z.callee.parent.type===o.Loop?{ancestor:Z.callee.parent,callType:"loop-body"}:{ancestor:Z.callee,callType:"entry"};if(Ci.includes(Z.callee.type)){if(Z.callType==="success"&&Z.callee.type===o.InternalCall)return{ancestor:Z.callee,callType:"success"};if(Z.callType==="error"&&Z.callee.type===o.InternalCall)return{ancestor:Z.callee,callType:"error"}}}}let P=c,x=null,M=w[0].callee,k=w.slice(1);for(;k.length;){const Z=SLe(M,k[0].callee,c);if(((q=Z==null?void 0:Z.ancestor)==null?void 0:q.id)===c.id)return{ancestor:c,callType:Z.callType};Z.ancestor?(P=Z.ancestor,M=Z.ancestor,x=Z.callType,i&&console.log('Combined single caller between "'+le(M,r.project)+'" ',M.type+" -- "+M.id,`
|
|
375
375
|
`,'AND "'+le(k[0].callee,r.project)+'" ','-> "'+le(P,r.project)+'" ',(P==null?void 0:P.type)+" -- "+(P==null?void 0:P.id)+" ["+x+`]
|
|
376
376
|
`)):i&&console.log('NO combined result "'+le(M,r.project)+'" ',M.type+" -- "+M.id,`
|
|
377
377
|
`,'AND "'+le(k[0].callee,r.project)+'" '),k=k.slice(1)}return{ancestor:P,callType:x}}function X$t(d){if(![...yf,o.OutputMap].includes(d.type))throw new Error("getEarliestSingleCallerAncestorOfValueWriterAndItsValueReaders can only be used with a value writer entity");let p;if(yf.includes(d.type)?p=d:d.type===o.OutputMap&&(p=d.parent),!p)throw new Error("getEarliestSingleCallerAncestorOfValueWriterAndItsValueReaders can only be used with a value writer entity that has a caller");const i=O([d,...Cg(d),...St.includes(d.type)?d.outputs.flatMap(y=>Cg(y)):[]]),r=O(i.map(y=>H_(y)).flatMap(y=>Gt.includes(y==null?void 0:y.type)?y.calledBy:[y]));if(r.length===1){const y=r[0];if(Wt.includes(y.type))return y.parent.type===o.Loop?{ancestor:y.parent,callType:"loop-body"}:{ancestor:y,callType:"entry"};if(p===y)return{ancestor:y,callType:"success"};if(y.successCalls.includes(p))return{ancestor:y,callType:"success"};if(y.errorCalls.includes(p))return{ancestor:y,callType:"error"};throw new Error(`getEarliestSingleCallerAncestorOfValueWriterAndItsValueReaders: Could not be resolved, single caller found, but it is not a valid caller: ${le(y,p.project)}`)}const l=r.map(y=>{var E;if(Wt.includes(y.type))return y.parent.type===o.Loop?{ancestor:y.parent,callType:"loop-body"}:{ancestor:y,callType:"entry"};if(y.parent===d.project&&!((E=p.calledBy)!=null&&E.length)){if(y===p)return{ancestor:y,callType:"success"};const A=Dr(y.successCalls),b=Dr(y.errorCalls);if(A.includes(p))return{ancestor:y,callType:"success"};if(b.includes(p))return{ancestor:y,callType:"error"}}const v=BT(y);if(!v.ancestor)throw new Error(`getEarliestSingleCallerAncestorOfValueWriterAndItsValueReaders: Could not be resolved, no ancestor found for ${le(y,p.project)}`);return v}).filter((y,v,E)=>v===E.findIndex(A=>{var b,w;return((b=A.ancestor)==null?void 0:b.id)===((w=y.ancestor)==null?void 0:w.id)})),c=MT(p),e=l.filter(y=>y!=null&&y.ancestor?c===y.ancestor?!0:!l.filter(A=>A.ancestor!==y.ancestor).map(A=>A.ancestor).some(A=>{const b=Ip(y.ancestor,A);return!!(b!=null&&b.last)}):!1);if(e.length===0)return{ancestor:(c==null?void 0:c.parent.type)===o.Loop?c==null?void 0:c.parent:c,callType:(c==null?void 0:c.parent.type)===o.Loop?"loop-body":"entry"};if(e.length>1)throw new Error(`getEarliestSingleCallerAncestorOfValueWriterAndItsValueReaders: Could not be resolved, multiple candidates found: ${e.map(y=>le(y.ancestor,p.project)).join(", ")}`);return{ancestor:e[0].ancestor,callType:e[0].callType}}function FLe(d,p){if(d===p)return!0;if(Ot(d).includes(p)||!Ot(p).includes(d))return!1;const l=d.calledBy;return l.length===0?!1:l.length===1?l[0]===p:kLe(l).length>1&&l.includes(p)?!1:l.every(e=>d===p?!0:Wt.includes(e.type)?!1:FLe(e,p))}function qLe(d){const p=[];let i=d.calledBySuccess;i=i.filter(l=>!i.filter(y=>y!==l).some(y=>Pg(y,l)));let r=d.calledByError;r=r.filter(l=>!r.filter(y=>y!==l).some(y=>Pg(y,l)));for(const l of i)p.push({ancestor:l,callType:"success"});for(const l of r)p.push({ancestor:l,callType:"error"});return p}function ZLe(d){const p=[];return qLe(d).forEach(r=>{r.ancestor.type===o.Condition&&p.push({condition:r.ancestor,call:d,callType:r.callType});const c=ZLe(r.ancestor).filter(e=>!p.some(y=>y.condition.id===e.condition.id));p.push(...c)}),p}function H_(d){if(!d)return null;if(d.type===o.Condition&&d.parent.type===o.Condition)return UT(d.parent);if(F1.includes(d.type))return d;const p=d.parent;return p?H_(p):null}function Cg(d,p=new Set){return d.writesValues.reduce((i,r)=>p.has(r.id)?i:(p.add(r.id),Wa.includes(r.type)?[...i,r]:An.includes(r.type)?[...i,r,...Cg(r,p)]:i),[])}function GT(d){const p=d.calledBy;if(p.length===0)return d.project;const i=p.reduce((r,l)=>{const c=lr(l,d.project);return!c||c.type===o.Project?r:r.type===o.Project||Jy(c,r).last?c:(Jy(r,c).last,r)},d.project);return i.type===o.FunctionDeclaration&&i.parent.type===o.Loop?i.parent:i}function ht(d,p){let i=GT(d);if(d.type===o.InternalCall)if(d.parent.type===o.VariableInstance){const l=hs(i,d.parent.declaration,d.project);!l.compatible&&l.type!=="b-is-global-a-is-not"?d.parent.remove({ignoreUpstream:!1},p):(d.parent.setParent(i,p),d.parent.addSelfToProject(p))}else d.parent.setParent(i,p),d.parent.addSelfToProject(p);else if((d.type===o.ContinueStatement||d.type===o.BreakStatement)&&i.type!==o.Loop){d.remove({ignoreUpstream:!1},p);return}else if(d.type===o.ReturnStatement&&!bn.includes(i.type)){d.remove({ignoreUpstream:!1},p);return}else if(St.includes(d.type)){const l=d.usedInternalCalls[0];if(l)if(i=GT(l),d.type===o.VariableInstance){const c=hs(i,d.declaration,d.project);!c.compatible&&c.type!=="b-is-global-a-is-not"?d.remove({ignoreUpstream:!1},p):(d.setParent(i,p),d.addSelfToProject(p))}else d.setParent(i,p),d.addSelfToProject(p);else if(d.type===o.VariableInstance){const c=hs(i,d.declaration,d.project);!c.compatible&&c.type!=="b-is-global-a-is-not"?d.remove({ignoreUpstream:!1},p):(d.setParent(i,p),d.addSelfToProject(p))}else d.setParent(i,p),d.addSelfToProject(p)}else d.setParent(i,p),d.addSelfToProject(p);if(Gt.includes(d.type))return;Ot(d).forEach(l=>{let c=GT(l);if(l.type===o.InternalCall)if(l.parent.type===o.VariableInstance){const e=hs(c,l.parent.declaration,d.project);!e.compatible&&e.type!=="b-is-global-a-is-not"?l.parent.remove({ignoreUpstream:!1},p):(l.parent.setParent(c,p),l.parent.addSelfToProject(p))}else l.parent.setParent(c,p),l.parent.addSelfToProject(p);else if((l.type===o.ContinueStatement||l.type===o.BreakStatement)&&c.type!==o.Loop){l.remove({ignoreUpstream:!1},p);return}else if(l.type===o.ReturnStatement&&!bn.includes(c.type)){l.remove({ignoreUpstream:!1},p);return}else if(St.includes(l.type)){const e=l.usedInternalCalls[0];if(e)if(c=GT(e),l.type===o.VariableInstance){const y=hs(c,l.declaration,d.project);!y.compatible&&y.type!=="b-is-global-a-is-not"?l.remove({ignoreUpstream:!1},p):(l.setParent(c,p),l.addSelfToProject(p))}else l.setParent(c,p),l.addSelfToProject(p);else if(l.type===o.VariableInstance){const y=hs(c,l.declaration,d.project);!y.compatible&&y.type!=="b-is-global-a-is-not"?l.remove({ignoreUpstream:!1},p):(l.setParent(c,p),l.addSelfToProject(p))}else l.setParent(c,p),l.addSelfToProject(p)}else l.setParent(c,p),l.addSelfToProject(p)})}function _g(d,p,i=new Set){const r=Ml(d),l=Ml(p),c=r.filter(v=>!l.includes(v)),e=r.filter(v=>l.includes(v)),y=c.reduce((v,E)=>i.has(E.id)?v:(i.add(E.id),O([...v,..._g(E,p,i)])),[]);return O([...e,...y])}function Mc(d,p){const i=Jy(d,p);return i.last===p&&i.list.length>0&&i.list[0]!==p}function W_(d,p){return!!Jy(d,p).last}function Pg(d,p){return!!Ip(d,p).last}function z_(d,p){if(!d||!p)throw new Error("Both entities must be defined to find a common ancestor");if(d===p)return d;const i=d.parent;if(i){if(i===p)return p;if(i.type===o.Project)return null}else return null;const r=p.parent;if(r){if(r===d)return d;if(r.type===o.Project)return null}else return null;return z_(i,r)}function Q$t(d,p,i=!0){if(!d||!p)throw new Error("Both entities must be defined to find a common ancestor");if(d===p)return{ancestor:d,callType:"same-entity"};if(cr.includes(d.type)&&ir.includes(p.type)){const y=Ip(d,p),v=y.last;if(v){if(v===p)return{ancestor:p,callType:y.callType}}else return{ancestor:null,callType:null}}if(cr.includes(p.type)&&ir.includes(d.type)){const y=Ip(p,d),v=y.last;if(v){if(v===d)return{ancestor:d,callType:y.callType}}else return{ancestor:null,callType:null}}const r=MT(d),l=MT(p);if(!r||!l)return{ancestor:null,callType:null};if(r!==l)return{ancestor:null,callType:null};if(r.calls.includes(d)||r.calls.includes(p))return{ancestor:r,callType:"entry"};const c=r.calls.reduce((y,v)=>{if(!ir.includes(v.type))return y;const E=Po(v),A=E.find(w=>w.callee===d),b=E.find(w=>w.callee===p);return A&&b&&(!i||A.callType===b.callType)?[...y,{ancestor:v,callType:A.callType}]:y},[]);if(c.length===0)return{ancestor:null,callType:null};if(c.length===1)return{ancestor:c[0].ancestor,callType:c[0].callType};const e=c.filter(y=>!c.some(v=>v.ancestor!==y.ancestor&&Ip(y.ancestor,v.ancestor).last===v.ancestor));return e.length===1?{ancestor:e[0].ancestor,callType:e[0].callType}:{ancestor:r,callType:"entry"}}function Fi(d){if(Wh.includes(d.type)){if(d.type===o.FunctionDeclaration){const p=d.parent;if(p.type===o.DefinitionEntity)return Fi(p);if(p.type===o.Loop)return p}return d.type===o.DefinitionEntity&&d.parent.type===o.DataType||d.type===o.Condition&&d.parent.type===o.Condition?Fi(d.parent):d}else{const p=d.parent;return p?Fi(p):null}}function Yy(d,p){const i=Xy(d,p);if(!i)return null;if(Wh.includes(i.type)){if(i.type===o.FunctionDeclaration){const r=Xy(i.parent,p);if(r){if(r.type===o.DefinitionEntity)return r;if(r.type===o.Loop)return r}}if(i.parent){const r=Xy(i.parent,p);if(r&&(i.type===o.DefinitionEntity&&r.type===o.DataType||i.type===o.Condition&&r.type===o.Condition))return Yy(r,p)}return i}else{const r=i.parent?Xy(i.parent,p):null;return r?Yy(r,p):null}}function Po(d){if(d.type===o.Loop){const p=[...Dr(d.successCalls).map(l=>({callee:l,callType:"success"})),...Dr(d.errorCalls).map(l=>({callee:l,callType:"error"})),...(d.body?Ot(d.body):[]).map(l=>({callee:l,callType:"loop-body"}))];return O(p.map(l=>l.callee)).map(l=>{var e;const c=(e=p.find(y=>y.callee===l))==null?void 0:e.callType;return{callee:l,callType:c}})}if(Ci.includes(d.type)){const p=[...Dr(d.successCalls).map(l=>({callee:l,callType:"success"})),...Dr(d.errorCalls).map(l=>({callee:l,callType:"error"}))];return O(p.map(l=>l.callee)).map(l=>{var e;const c=(e=p.find(y=>y.callee===l))==null?void 0:e.callType;return{callee:l,callType:c}})}if(Wt.includes(d.type)){const p=[...Dr(d.calls).map(l=>d.parent.type===o.Loop?{callee:l,callType:"loop-body"}:{callee:l,callType:"entry"})];return O(p.map(l=>l.callee)).map(l=>{var e;const c=(e=p.find(y=>y.callee===l))==null?void 0:e.callType;return{callee:l,callType:c}})}return[]}function UT(d){if(!d)return null;if(d.type===o.Condition&&d.parent.type===o.Condition)return UT(d.parent);if(cr.includes(d.type))return d;const p=d.parent;return p?UT(p):null}function HLe(d){if(!d)return null;if(Ci.includes(d.type))return d;const p=d.parent;return p?HLe(p):null}function WLe(d){if(!d)return null;if(ir.includes(d.type))return d;const p=d.parent;return p?WLe(p):null}function eLt(d){return d.type===o.VariableDeclaration?[d]:Ci.includes(d.type)?[...d.inputs,...d.outputs||[]]:Gt.includes(d.type)?d.outputs:Fp.includes(d.type)||d.type===o.FunctionDeclaration?d.inputs:[]}function tLt(d){const p=Ml(d),i=[],r=[];x$.includes(d.type)&&i.push(...Vg(d));const l=p.filter(c=>{const e=i.includes(c);return e?!1:cr.includes(c.type)&&!e?(r.push(c),!1):!0});return i.sort((c,e)=>Mc(e,c)?-1:0),r.sort((c,e)=>Mc(e,c)?-1:0),[...i,...r,...l]}function zLe(d){return[...d].sort((p,i)=>Mc(i,p)?-1:0)}function iLt(d){const p=zLe(d),i=[];return p.forEach(r=>{const l=i[i.length-1];if(l){const c=l[l.length-1];Mc(r,c)?i.push([r]):l.push(r)}else i.push([r])}),i}function Vo(d){const p=d.map(i=>Fi(i));return O(p)}function Vg(d){return Ci.includes(d.type)?[...Vo(d.successCalls),...Vo(d.errorCalls)]:Wt.includes(d.type)?Vo(d.calls):[]}function nLt(d,p){return Vg(d).includes(p)}function Ng(d){return d.writesValues||[]}function rLt(d,p){return Ng(d).includes(p)}function JLe(d){var p;return St.includes((p=d==null?void 0:d.readsValue)==null?void 0:p.type)?d.readsValue:null}function aLt(d){return d.writesValues}function YLe(d=[]){return d.map(JLe).filter(p=>!!p)}function $g(d=[]){return d.map(p=>p.writesValues).flat().filter(p=>St.includes(p.type))}function XLe(d=[]){return d.map(p=>p.readsValue).filter(p=>!!p&&St.includes(p.type))}function QLe(d){return St.includes(d.type)?d:null}function e2e(d){return d.writesValues.map(QLe).filter(p=>!!p)}function t2e(d=[]){return d.reduce((p,i)=>i.type===o.OutputMap?[...p,...e2e(i)]:p,[])}function Ot(d){return d.type===o.Loop?O([...Dr(d.successCalls),...Dr(d.errorCalls),...d.body?Ot(d.body):[]]):Ci.includes(d.type)?O([...Dr(d.successCalls),...Dr(d.errorCalls)]):Wt.includes(d.type)?O(Dr(d.calls)):[]}function sLt(d){return Ci.includes(d.type)?[...Dr(d.successCalls),...Dr(d.errorCalls)]:Wt.includes(d.type)?Dr(d.calls):[]}function i2e(d,p=new Set){return d.writesValues.filter(r=>St.includes(r.type)&&!p.has(r.id)).reduce((r,l)=>p.has(l.id)?r:[...r,...zi(l,p)],[])}function n2e(d,p=new Set){var r;return(((r=d.readsValue)==null?void 0:r.writesValues)||[]).filter(l=>St.includes(l.type)&&!p.has(l.id)).reduce((l,c)=>p.has(c.id)?l:[...l,...zi(c,p)],[])}function zi(d,p=new Set){if(p.has(d.id))return[];if(d.type===o.ReturnStatement)return XLe(d.outputs).reduce((r,l)=>[...r,...zi(l,p)],[]);if(d.type===o.FunctionCall||d.type===o.Operation||d.type===o.Condition)return[...Ot(d).reduce((c,e)=>{const y=Fi(e);return[...c,...zi(y||e,p)]},[]),...YLe(d.inputs),...t2e(d.outputs)].reduce((c,e)=>[...c,...zi(e,p)],[]);if(Fp.includes(d.type)){const i=$g(d.inputs),l=Ot(d).reduce((c,e)=>{const y=Fi(e);return[...c,...zi(y||e,p)]},[]);return i.push(...l),i.reduce((c,e)=>[...c,...zi(e,p)],[])}if(d.type===o.FunctionDeclaration){const i=[...$g(d.inputs)],l=Ot(d).reduce((c,e)=>{const y=Fi(e);return[...c,...zi(y||e,p)]},[]);return i.push(...l),i.reduce((c,e)=>[...c,...zi(e)],[])}if(St.includes(d.type)){p.add(d.id);const r=Ot(d).reduce((l,c)=>{const e=Fi(c);return[...l,...zi(e||c,p)]},[]);return[d,...r,...n2e(d,p),...i2e(d,p)]}return[]}function Ba(d,p=new Set){if(p.has(d.id))return[];p.add(d.id),ae.log("[flattenDerivedCanvasEntities]",d.type,le(d,d.project),d.id);const i=Ml(d);return i.forEach(l=>{p.add(l.id)}),[...i.reduce((l,c)=>(ae.log("[Recursive -- flattenDerivedCanvasEntities]",c.type,le(c,c.project),c.id),[...l,c,...Ba(c,p)]),[])]}function Dr(d){return d.reduce((p,i)=>i.type===o.ReturnStatement||i.type===o.ContinueStatement||i.type===o.BreakStatement?[...p,i]:[...p,i,...Ot(i)],[])}function r2e(d){const p=d.entities||[],i=[...p,...d.functions||[],...d.events||[],...d.projects||[]],r=p.reduce((v,E)=>[...v,...E.properties],[]),l=p.reduce((v,E)=>[...v,...E.methods],[]),c=l.reduce((v,E)=>[...v,...$g(E.inputs),...Dr(Vo(E.calls)),...E.returnStatements],[]),e=d.functions.reduce((v,E)=>[...v,...Dr(Vo(E.calls)),...E.returnStatements],[]),y=d.events.reduce((v,E)=>[...v,...Dr(Vo(E.calls)),...E.returnStatements],[]);return[...i,...r,...l,...c,...e,...y]}function a2e(d,p){return p.filter(r=>{if(!r)return!1;switch(r.type){case o.FunctionCall:return r.inputs.find(l=>l.id===d.id)!==void 0||r.outputs.find(l=>l.id===d.id)!==void 0;case o.Condition:return r.successCalls.find(l=>l.id===d.id)!==void 0||r.errorCalls.find(l=>l.id===d.id)!==void 0||r.inputs.find(l=>l.id===d.id)!==void 0;case o.Operation:return r.outputs.find(l=>l.id===d.id)!==void 0;case o.VariableDeclaration:return Ci.includes(d.type)?N2e(d).find(c=>{var e;return((e=c.readsValue)==null?void 0:e.id)===r.id})!==void 0:!1;case o.DefinitionEntity:return r.properties.find(l=>l.id===d.id)!==void 0||r.methods.find(l=>l.id===d.id)!==void 0;case o.FunctionDeclaration:return r.inputs.find(l=>l.id===d.id)!==void 0||(r.returnStatements.map(l=>l.outputs).flat()||[]).find(l=>l.id===d.id)!==void 0;default:return!1}})}function lLt(d){const p=r2e(d.project);return a2e(d,p)}function Xy(d,p){return d?typeof d=="string"?p[d]:d.type===o.GenericReference?p[d.entityId]:p[d.id]?p[d.id]:null:null}function J_(d={},p){const i={};return Object.keys(d).forEach(r=>{const l=p.get(r)||r,c=d[r];i[l]=c}),i}function Gd(d,p={},i={}){const r={ignoreBuiltInBaseEntities:!1,allBuiltInEntityIds:[],entityMaps:new Map,...i};if(r.ignoreBuiltInBaseEntities&&(aa.includes(d.type)||(r.allBuiltInEntityIds||[]).includes(d.id)))return{upstream:{},downstream:{}};const l=d,c=d,e=d,y=d,v=d,E=d,A=d,b=d,w=d,P=d,x=d,M=d,k=d,q=[...k.readsValue?[k.readsValue]:[],...k.declaration?[k.declaration]:[],...(M.calledByEntry||[]).flatMap(ee=>ee),...(M.calledBySuccess||[]).flatMap(ee=>ee),...(M.calledByError||[]).flatMap(ee=>ee),...P.parent?[P.parent]:[],...c.foreignKeyRef?[c.foreignKeyRef]:[]];Array.isArray(e.implements)?q.push(...e.implements.flatMap(ee=>ee)):y.implements&&q.push(y.implements),Array.isArray(e.extends)?q.push(...e.extends.flatMap(ee=>ee)):w.extends&&q.push(w.extends),v.valueAsTypeList&&Array.isArray(v.valueAsTypeList)&&q.push(...v.valueAsTypeList.flatMap(ee=>ee)),v.valueAsTypeSingle&&q.push(v.valueAsTypeSingle),(k.internalCalls||[]).forEach(ee=>{const he=ye(ee);if(he&&p[he]){const de=p[he];[...de.calledByEntry||[],...de.calledBySuccess||[],...de.calledByError||[]].forEach(fe=>{const Te=ye(fe);Te&&p[Te]&&q.push(p[Te])})}});const Z=[...(l.inputs||[]).flatMap(ee=>ee),...(x.inputsDeclarations||[]).flatMap(ee=>ee),...(x.outputs||[]).flatMap(ee=>ee),...(k.internalCalls||[]).flatMap(ee=>ee),...k.writesValues||[],...M.dataType?[M.dataType]:[],...E.body?[E.body]:[],...M.defaultValue?[M.defaultValue]:[],...(M.successCalls||[]).flatMap(ee=>ee),...(M.errorCalls||[]).flatMap(ee=>ee),...(e.properties||[]).flatMap(ee=>ee),...(e.methods||[]).flatMap(ee=>ee),...(e.abstractMethods||[]).flatMap(ee=>ee),...A.error?[A.error]:[],...P.throws?[P.throws]:[],...(c.andChildrenGroup||[]).flatMap(ee=>ee),...(c.orChildrenGroup||[]).flatMap(ee=>ee),...(b.entities||[]).flatMap(ee=>ee),...(b.functions||[]).flatMap(ee=>ee),...(b.functionCalls||[]).flatMap(ee=>ee),...(b.events||[]).flatMap(ee=>ee),...(b.conditions||[]).flatMap(ee=>ee),...(b.operations||[]).flatMap(ee=>ee),...(b.loops||[]).flatMap(ee=>ee),...(b.variableDeclarations||[]).flatMap(ee=>ee),...(b.variableInstances||[]).flatMap(ee=>ee),...(b.searches||[]).flatMap(ee=>ee),...(b.projects||[]).flatMap(ee=>ee),...(y.calls||[]).flatMap(ee=>ee)];d.type===o.DataType&&(c.entity&&p[ye(c.entity)]&&p[ye(c.entity)].parent&&ye(p[ye(c.entity)].parent)===d.id?Z.push(c.entity):c.entity&&q.push(c.entity)),(k.internalCalls||[]).forEach(ee=>{const he=ye(ee);if(he&&p[he]){const de=p[he];[...de.successCalls||[],...de.errorCalls||[]].forEach(fe=>{const Te=ye(fe);Te&&p[Te]&&Z.push(p[Te])})}});const X={},se={};return q.forEach(ee=>{var fe;const he=ye(ee);if(he&&r.ignoreBuiltInBaseEntities&&(aa.includes(ee.type)||(r.allBuiltInEntityIds||[]).includes(he)))return;const de=ee.version;if(he){const Te=((fe=r.entityMaps)==null?void 0:fe.get(he))||he;X[Te]=de}}),Z.forEach(ee=>{var fe;const he=ye(ee);if(he&&r.ignoreBuiltInBaseEntities&&(aa.includes(ee.type)||(r.allBuiltInEntityIds||[]).includes(he)))return;const de=ee.version;if(he){const Te=((fe=r.entityMaps)==null?void 0:fe.get(he))||he;se[Te]=de}}),{upstream:X,downstream:se}}function oLt(d,p){const i=[];if(cr.includes(d.type)){ys(d).forEach(c=>{const e=Yy(c,p);e&&i.push(e)});const l=[...d.inputs||[],...d.outputs||[]].map(c=>{const e=Xy(c,p);return e?$2e(e,p):null}).filter(c=>c!==null);i.push(...O(l))}if(St.includes(d.type)){const r=Lg(d);r&&i.push(r)}return O(i)}function Rp(d){const p=[];if(cr.includes(d.type)){d.calledBy.forEach(l=>{const c=Fi(l);c&&p.push(c)});const r=[...d.inputs||[],...d.outputs||[]].map(l=>Lg(l)).filter(l=>l!==null);p.push(...O(r))}if(Wa.includes(d.type)){const i=Lg(d);i&&p.push(i)}return O(p)}function ys(d){return[...d.calledByEntry||[],...d.calledByError||[],...d.calledBySuccess||[]].filter(p=>p.type!==o.GenericReference)}function s2e(d,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(d.id))return[];if(p.add(d.id),d.type!==o.ActionDescriptor)throw new Error("Entity must be an action descriptor to be flattened");return[d,...d.inputs.flatMap(r=>Ne(r,p,i)),...d.dataType?Ne(d.dataType,p,i):[],...d.error?Ne(d.error,p,i):[],...d.parent?Ne(d.parent,p,i):[]]}function l2e(d,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(d.id))return[];if(p.add(d.id),d.type!==o.ArgumentDeclaration)throw new Error("Entity must be an argument declaration to be flattened");return[d,...d.defaultValue?Ne(d.defaultValue,p):[],...d.writesValues.flatMap(r=>Ne(r,p,i)),...d.dataType?Ne(d.dataType,p,i):[],...d.parent?Ne(d.parent,p,i):[]]}function o2e(d,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(d.id))return[];if(p.add(d.id),d.type!==o.BreakStatement)throw new Error("Entity must be a break statement to be flattened");return[d,...d.outputs.flatMap(r=>Ne(r,p,i)),...d.throws?Ne(d.throws,p,i):[],...d.dataType?Ne(d.dataType,p,i):[],...d.readsValue?Ne(d.readsValue,p,i):[],...(ys(d)||[]).flatMap(r=>Ne(r,p,i)),...d.parent?Ne(d.parent,p,i):[]]}function d2e(d,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(d.id))return[];if(p.add(d.id),d.type!==o.BuiltInBaseEntity)throw new Error("Entity must be a built-in base entity to be flattened");return[d,...(d.properties||[]).flatMap(r=>Ne(r,p,i)),...(d.methods||[]).flatMap(r=>Ne(r,p,i)),...(d.abstractMethods||[]).flatMap(r=>Ne(r,p,i)),...d.allPropertiesImplement?Ne(d.allPropertiesImplement,p,i):[],...d.additionalPropertiesDataType?Ne(d.additionalPropertiesDataType,p,i):[],...d.extends?Ne(d.extends,p,i):[]]}function u2e(d,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(d.id))return[];if(p.add(d.id),d.type!==o.Condition)throw new Error("Entity must be a condition to be flattened");return[d,...(d.andChildrenGroup||[]).flatMap(r=>Ne(r,p,i)),...(d.orChildrenGroup||[]).flatMap(r=>Ne(r,p,i)),...(d.inputs||[]).flatMap(r=>Ne(r,p,i)),...(d.successCalls||[]).flatMap(r=>Ne(r,p,i)),...(d.errorCalls||[]).flatMap(r=>Ne(r,p,i)),...(ys(d)||[]).flatMap(r=>Ne(r,p,i)),...d.parent?Ne(d.parent,p,i):[]]}function p2e(d,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(d.id))return[];if(p.add(d.id),d.type!==o.ContinueStatement)throw new Error("Entity must be a continue statement to be flattened");return[d,...d.outputs.flatMap(r=>Ne(r,p,i)),...d.readsValue?Ne(d.readsValue,p,i):[],...d.throws?Ne(d.throws,p,i):[],...d.dataType?Ne(d.dataType,p,i):[],...(ys(d)||[]).flatMap(r=>Ne(r,p,i)),...d.parent?Ne(d.parent,p,i):[]]}function c2e(d,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(d.id))return[];if(p.add(d.id),d.type!==o.DefinitionEntity)throw new Error("Entity must be a definition entity to be flattened");return[d,...d.extends?Ne(d.extends,p,i):[],...(d.implements||[]).flatMap(r=>Ne(r,p,i)),...(d.properties||[]).flatMap(r=>Ne(r,p,i)),...(d.methods||[]).flatMap(r=>Ne(r,p,i)),...(d.abstractMethods||[]).flatMap(r=>Ne(r,p,i)),...d.allPropertiesImplement?Ne(d.allPropertiesImplement,p,i):[],...d.additionalPropertiesDataType?Ne(d.additionalPropertiesDataType,p,i):[],...d.parent?Ne(d.parent,p,i):[]]}function f2e(d,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(d.id))return[];if(p.add(d.id),d.type!==o.DataType)throw new Error("Entity must be a data type to be flattened");return[d,...(d.andChildrenGroup||[]).flatMap(r=>Ne(r,p,i)),...(d.orChildrenGroup||[]).flatMap(r=>Ne(r,p,i)),...d.entity?Ne(d.entity,p,i):[],...d.foreignKeyRef?Ne(d.foreignKeyRef,p,i):[],...d.parent?Ne(d.parent,p,i):[]]}function y2e(d,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(d.id))return[];if(p.add(d.id),d.type!==o.FunctionCall)throw new Error("Entity must be a function call to be flattened");return[d,...(d.inputs||[]).flatMap(r=>Ne(r,p,i)),...(d.outputs||[]).flatMap(r=>Ne(r,p,i)),...d.error?Ne(d.error,p,i):[],...(ys(d)||[]).flatMap(r=>Ne(r,p,i)),...(d.successCalls||[]).flatMap(r=>Ne(r,p,i)),...(d.errorCalls||[]).flatMap(r=>Ne(r,p,i)),...(d.writesValues||[]).flatMap(r=>Ne(r,p,i)),...d.parent?Ne(d.parent,p,i):[]]}function h2e(d,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(d.id))return[];if(p.add(d.id),d.type!==o.FunctionDeclaration)throw new Error("Entity must be a function declaration to be flattened");return[d,...(d.inputs||[]).flatMap(r=>Ne(r,p,i)),...(d.calls||[]).flatMap(r=>Ne(r,p,i)),...d.dataType?Ne(d.dataType,p,i):[],...d.implements?Ne(d.implements,p,i):[],...d.parent?Ne(d.parent,p,i):[]]}function m2e(d,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(d.id))return[];if(p.add(d.id),d.type!==o.GlobalEvent)throw new Error("Entity must be a global event to be flattened");return[d,...(d.inputs||[]).flatMap(r=>Ne(r,p,i)),...(d.calls||[]).flatMap(r=>Ne(r,p,i)),...d.implements?Ne(d.implements,p,i):[],...d.parent?Ne(d.parent,p,i):[]]}function T2e(d,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(d.id))return[];if(p.add(d.id),d.type!==o.InputMap)throw new Error("Entity must be an input map to be flattened");return[d,...d.readsValue?Ne(d.readsValue,p,i):[],...d.declaration?Ne(d.declaration,p,i):[],...d.defaultValue?Ne(d.defaultValue,p,i):[],...d.parent?Ne(d.parent,p,i):[]]}function v2e(d,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(d.id))return[];if(p.add(d.id),d.type!==o.InstalledProject)throw new Error("Entity must be an installed project to be flattened");return[d,...(d.functions||[]).flatMap(r=>Ne(r,p,i)),...(d.events||[]).flatMap(r=>Ne(r,p,i)),...d.parent?Ne(d.parent,p,i):[]]}function E2e(d,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(d.id))return[];if(p.add(d.id),d.type!==o.InternalCall)throw new Error("Entity must be an internal call to be flattened");return[d,...(d.successCalls||[]).flatMap(r=>Ne(r,p,i)),...(d.errorCalls||[]).flatMap(r=>Ne(r,p,i)),...(d.inputs||[]).flatMap(r=>Ne(r,p,i)),...(d.outputs||[]).flatMap(r=>Ne(r,p,i)),...(ys(d)||[]).flatMap(r=>Ne(r,p,i)),...d.error?Ne(d.error,p,i):[],...(d.writesValues||[]).flatMap(r=>Ne(r,p,i)),...d.parent?Ne(d.parent,p,i):[]]}function b2e(d,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(d.id))return[];if(p.add(d.id),d.type!==o.LiteralValue)throw new Error("Entity must be a literal value to be flattened");return[d,...d.valueAsTypeSingle?Ne(d.valueAsTypeSingle,p,i):[],...d.valueAsTypeList&&Array.isArray(d.valueAsTypeList)?d.valueAsTypeList.flatMap(r=>Ne(r,p,i)):[],...d.parent?Ne(d.parent,p,i):[]]}function A2e(d,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(d.id))return[];if(p.add(d.id),d.type!==o.Loop)throw new Error("Entity must be a loop to be flattened");return[d,...(d.inputs||[]).flatMap(r=>Ne(r,p,i)),...(d.outputs||[]).flatMap(r=>Ne(r,p,i)),...(d.successCalls||[]).flatMap(r=>Ne(r,p,i)),...(d.errorCalls||[]).flatMap(r=>Ne(r,p,i)),...d.error?Ne(d.error,p,i):[],...d.dataType?Ne(d.dataType,p,i):[],...d.body?Ne(d.body,p,i):[],...(ys(d)||[]).flatMap(r=>Ne(r,p,i)),...(d.writesValues||[]).flatMap(r=>Ne(r,p,i)),...d.parent?Ne(d.parent,p,i):[]]}function g2e(d,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(d.id))return[];if(p.add(d.id),d.type!==o.Operation)throw new Error("Entity must be an operation to be flattened");return[d,...(d.successCalls||[]).flatMap(r=>Ne(r,p,i)),...(d.errorCalls||[]).flatMap(r=>Ne(r,p,i)),...(d.inputs||[]).flatMap(r=>Ne(r,p,i)),...(d.outputs||[]).flatMap(r=>Ne(r,p,i)),...(d.writesValues||[]).flatMap(r=>Ne(r,p,i)),...d.error?Ne(d.error,p,i):[],...(ys(d)||[]).flatMap(r=>Ne(r,p,i)),...d.parent?Ne(d.parent,p,i):[]]}function I2e(d,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(d.id))return[];if(p.add(d.id),d.type!==o.OutputMap)throw new Error("Entity must be an output map to be flattened");return[d,...(d.writesValues||[]).flatMap(r=>Ne(r,p,i)),...d.declaration?Ne(d.declaration,p,i):[],...d.parent?Ne(d.parent,p,i):[]]}function R2e(d,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(d.id))return[];if(p.add(d.id),d.type!==o.PrimitiveEntity)throw new Error("Entity must be a primitive entity to be flattened");return[d,...(d.properties||[]).flatMap(r=>Ne(r,p,i)),...(d.methods||[]).flatMap(r=>Ne(r,p,i)),...(d.abstractMethods||[]).flatMap(r=>Ne(r,p,i))]}function D2e(d,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(d.id))return[];if(p.add(d.id),d.type!==o.Project)throw new Error("Entity must be a project to be flattened");return[d,...(d.entities||[]).flatMap(r=>Ne(r,p,i)),...(d.functions||[]).flatMap(r=>Ne(r,p,i)),...(d.events||[]).flatMap(r=>Ne(r,p,i)),...(d.projects||[]).flatMap(r=>Ne(r,p,i)),...(d.variableDeclarations||[]).flatMap(r=>Ne(r,p,i)),...(d.variableInstances||[]).flatMap(r=>Ne(r,p,i)),...(d.operations||[]).flatMap(r=>Ne(r,p,i)),...(d.conditions||[]).flatMap(r=>Ne(r,p,i)),...(d.functionCalls||[]).flatMap(r=>Ne(r,p,i)),...(d.projects||[]).flatMap(r=>Ne(r,p,i)),...(d.loops||[]).flatMap(r=>Ne(r,p,i)),...(d.searches||[]).flatMap(r=>Ne(r,p,i))]}function O2e(d,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(d.id))return[];if(p.add(d.id),d.type!==o.Property)throw new Error("Entity must be a property to be flattened");return[d,...d.defaultValue?Ne(d.defaultValue,p,i):[],...d.dataType?Ne(d.dataType,p,i):[],...d.parent?Ne(d.parent,p,i):[]]}function w2e(d,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(d.id))return[];if(p.add(d.id),d.type!==o.ReturnStatement)throw new Error("Entity must be a return statement to be flattened");return[d,...(d.outputs||[]).flatMap(r=>Ne(r,p,i)),...d.throws?Ne(d.throws,p,i):[],...d.readsValue?Ne(d.readsValue,p,i):[],...d.dataType?Ne(d.dataType,p,i):[],...(ys(d)||[]).flatMap(r=>Ne(r,p,i)),...d.parent?Ne(d.parent,p,i):[]]}function C2e(d,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(d.id))return[];if(p.add(d.id),d.type!==o.Search)throw new Error("Entity must be a search to be flattened");return[d,...(d.successCalls||[]).flatMap(r=>Ne(r,p,i)),...(d.errorCalls||[]).flatMap(r=>Ne(r,p,i)),...(d.inputsDeclarations||[]).flatMap(r=>Ne(r,p,i)),...(d.inputs||[]).flatMap(r=>Ne(r,p,i)),...(d.writesValues||[]).flatMap(r=>Ne(r,p,i)),...(d.outputs||[]).flatMap(r=>Ne(r,p,i)),...d.error?Ne(d.error,p,i):[],...d.dataType?Ne(d.dataType,p,i):[],...(ys(d)||[]).flatMap(r=>Ne(r,p,i)),...d.parent?Ne(d.parent,p,i):[]]}function _2e(d,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(d.id))return[];if(p.add(d.id),d.type!==o.ValueDescriptor)throw new Error("Entity must be a value descriptor to be flattened");return[d,...d.defaultValue?Ne(d.defaultValue,p,i):[],...d.dataType?Ne(d.dataType,p,i):[],...d.parent?Ne(d.parent,p,i):[]]}function P2e(d,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(d.id))return[];if(p.add(d.id),d.type!==o.VariableDeclaration)throw new Error("Entity must be a variable declaration to be flattened");return[d,...(d.successCalls||[]).flatMap(r=>Ne(r,p,i)),...(d.errorCalls||[]).flatMap(r=>Ne(r,p,i)),...(d.inputs||[]).flatMap(r=>Ne(r,p,i)),...(d.outputs||[]).flatMap(r=>Ne(r,p,i)),...(d.internalCalls||[]).flatMap(r=>Ne(r,p,i)),...(d.writesValues||[]).flatMap(r=>Ne(r,p,i)),...d.readsValue?Ne(d.readsValue,p,i):[],...d.defaultValue?Ne(d.defaultValue,p,i):[],...(ys(d)||[]).flatMap(r=>Ne(r,p,i)),...d.dataType?Ne(d.dataType,p,i):[],...d.parent?Ne(d.parent,p,i):[]]}function V2e(d,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(p.has(d.id))return[];if(p.add(d.id),d.type!==o.VariableInstance)throw new Error("Entity must be a variable instance to be flattened");return[d,...(d.successCalls||[]).flatMap(r=>Ne(r,p,i)),...(d.errorCalls||[]).flatMap(r=>Ne(r,p,i)),...(d.inputs||[]).flatMap(r=>Ne(r,p,i)),...(d.outputs||[]).flatMap(r=>Ne(r,p,i)),...(d.internalCalls||[]).flatMap(r=>Ne(r,p,i)),...(d.writesValues||[]).flatMap(r=>Ne(r,p,i)),...d.readsValue?Ne(d.readsValue,p,i):[],...d.defaultValue?Ne(d.defaultValue,p,i):[],...(ys(d)||[]).flatMap(r=>Ne(r,p,i)),...d.declaration?Ne(d.declaration,p,i):[],...d.parent?Ne(d.parent,p,i):[]]}function rn(){const d=new Set;return jve.flatMap(i=>Ne(i,d)).map(i=>i.id)}function Ne(d,p=new Set,i={ignoreBuiltInBaseEntities:!1}){if(!d)throw new Error("Entity must be defined to be flattened");if(d.type===o.GenericReference)return[];if(i.ignoreBuiltInBaseEntities&&(aa.includes(d.type)||rn().includes(d.id)))return[];if(p.has(d.id))return[];switch(d.type){case o.FunctionCall:return y2e(d,p,i);case o.Operation:return g2e(d,p,i);case o.Condition:return u2e(d,p,i);case o.Loop:return A2e(d,p,i);case o.Search:return C2e(d,p,i);case o.GlobalEvent:return m2e(d,p,i);case o.ReturnStatement:return w2e(d,p,i);case o.ContinueStatement:return p2e(d,p,i);case o.BreakStatement:return o2e(d,p,i);case o.VariableDeclaration:return P2e(d,p,i);case o.DefinitionEntity:return c2e(d,p,i);case o.FunctionDeclaration:return h2e(d,p,i);case o.Project:return D2e(d,p,i);case o.ActionDescriptor:return s2e(d,p,i);case o.ArgumentDeclaration:return l2e(d,p,i);case o.ValueDescriptor:return _2e(d,p,i);case o.InputMap:return T2e(d,p,i);case o.OutputMap:return I2e(d,p,i);case o.DataType:return f2e(d,p,i);case o.InstalledProject:return v2e(d,p,i);case o.InternalCall:return E2e(d,p,i);case o.LiteralValue:return b2e(d,p,i);case o.Property:return O2e(d,p,i);case o.VariableInstance:return V2e(d,p,i);case o.BuiltInBaseEntity:return i.ignoreBuiltInBaseEntities?[]:d2e(d,p,i);case o.PrimitiveEntity:return i.ignoreBuiltInBaseEntities?[]:R2e(d,p,i)}return[]}function Y_(d){return d.type===o.FunctionCall||d.type===o.InternalCall||[o.Operation,o.Condition,o.Loop].includes(d.type)?d.declaration.inputs:d.type===o.FunctionDeclaration||Fp.includes(d.type)?d.inputs:d.type===o.Search?d.inputsDeclarations:[]}function dLt(d,p){return p.type===o.Condition?p.inputs.find(i=>i.declaration.id===d.id):p.type===o.FunctionCall||p.type===o.Operation?p.inputs.find(i=>i.declaration.id===d.id):null}function N2e(d){return Ci.includes(d.type)?d.inputs:[]}function uLt(d){var p;if(d.type===o.FunctionCall)return d.declaration.implements&&d.declaration.implements.dataType&&d.declaration.implements.dataType.entity&&d.declaration.implements.dataType.entity.type===o.DefinitionEntity&&d.declaration.implements.dataType.entity.properties.length?d.declaration.implements.dataType.entity.properties:((p=d.declaration.returnStatements[0])==null?void 0:p.outputs.map(i=>i.declaration).filter(i=>!!i))||[];if([o.Operation,o.Condition,o.Loop].includes(d.type)){const i=d.declaration;return i.dataType&&i.dataType.entity&&i.dataType.entity.type===o.DefinitionEntity&&i.dataType.entity.properties.length?i.dataType.entity.properties:[]}return Gt.includes(d.type)?d.outputs.map(i=>i.declaration).filter(i=>!!i)||[]:[]}function pLt(d,p){return p.type===o.Condition?null:(p.type===o.FunctionCall||p.type===o.Operation)&&p.outputs.find(i=>{var r;return((r=i.declaration)==null?void 0:r.id)===d.id})||null}function cLt(d){return d.type===o.Condition?[]:Ci.includes(d.type)?d.outputs:[]}function Lg(d){const p=d.readsValue;return p?Fi(p):null}function $2e(d,p){const i=d.readsValue;return i?Yy(i,p):null}function L2e(d){const p=d.internalCalls||[];return O(Vo(O(p.flatMap(i=>[...i.successCalls,...i.errorCalls]))))}function x2e(d){const p=d.internalCalls||[];return O(O(p.flatMap(i=>[...i.successCalls,...i.errorCalls])))}function Qy(d){const p=Ng(d),i=[];return p.forEach(r=>{if(Wh.includes(r.type))i.push(r);else if(Wa.includes(r.type)){const l=Fi(r.parent);i.push(l)}}),i}function eh(d){const p=Ng(d),i=[];return p.forEach(r=>{if([...St,...Gt].includes(r.type))i.push(r);else if(Wa.includes(r.type)){const l=r.parent;i.push(l)}}),i}function O(d){const p=new Set;return d.filter(i=>!i||p.has(i.id)?!1:(p.add(i.id),!0))}function M2e(d){return d.type===o.Project?null:F1.includes(d.type)?d:aa.includes(d.type)?null:d.parent?M2e(d.parent):null}function Ml(d,p=!1){ae.log("[getRelatedCanvasElementsOnTheRight]",d.type,le(d,d.project),d.id);const i=[];if(d.type===o.Project&&i.push(...(d==null?void 0:d.entities)||[],...(d==null?void 0:d.functions)||[],...(d==null?void 0:d.variableDeclarations)||[],...(d==null?void 0:d.variableInstances)||[],...(d==null?void 0:d.searches)||[],...(d==null?void 0:d.loops)||[],...(d==null?void 0:d.operations)||[],...(d==null?void 0:d.conditions)||[],...(d==null?void 0:d.functionCalls)||[],...(d==null?void 0:d.events)||[],...(d==null?void 0:d.projects)||[]),bn.includes(d.type)&&i.push(...(d==null?void 0:d.detachedChildren)||[]),d.type===o.DefinitionEntity){const r=[...d.suggestedMethods,...d.methods].flatMap(l=>l.collapsed&&p?[]:(ae.log("[Recursive -- getRelatedCanvasElementsOnTheRight]",l.type,le(l,l.project),l.id),Ml(l,p)));i.push(...r)}if(d.type===o.Condition){const r=d.successCalls.map(c=>Fi(c)),l=d.errorCalls.map(c=>Fi(c));i.push(...r,...l)}if(Fp.includes(d.type)){if(d.collapsed&&p)return[];const r=d.inputs.map(c=>Qy(c)).flat(),l=d.calls.map(c=>Fi(c));i.push(...O(r),...l)}if(Ci.includes(d.type)&&d.type!==o.Condition&&d.type!==o.Loop){const r=d==null?void 0:d.outputs.map(e=>Qy(e)).flat(),l=d.successCalls.map(e=>Fi(e)),c=d.errorCalls.map(e=>Fi(e));i.push(...O(r),...l,...c)}if(St.includes(d.type)){const r=Qy(d),l=L2e(d);i.push(...r,...l)}if(An.includes(d.type)){const r=Qy(d);i.push(...r)}if(d.type===o.Loop){if(d.body){const c=Ml(d.body,p);i.push(...c)}const r=d.errorCalls.map(c=>Fi(c)),l=d.successCalls.map(c=>Fi(c));i.push(...l,...r)}if(d.type===o.FunctionDeclaration){if(d.collapsed&&p)return[];const r=d.inputs.map(c=>Qy(c)).flat(),l=d.calls.map(c=>Fi(c));i.push(...O(r),...l)}return O(i)}function xg(d,p=!1){const i=[];if(d.type===o.Project&&i.push(...(d==null?void 0:d.variableDeclarations)||[],...(d==null?void 0:d.variableInstances)||[],...(d==null?void 0:d.searches)||[],...(d==null?void 0:d.loops)||[],...(d==null?void 0:d.operations)||[],...(d==null?void 0:d.conditions)||[],...(d==null?void 0:d.functionCalls)||[]),bn.includes(d.type)&&i.push(...(d==null?void 0:d.detachedChildren)||[]),d.type===o.DefinitionEntity){const r=[...d.suggestedMethods,...d.methods].flatMap(l=>l.collapsed&&p?[]:xg(l));i.push(...r)}if(d.type===o.Condition){const r=d.successCalls,l=d.errorCalls;i.push(...r,...l)}if(Fp.includes(d.type)){if(d.collapsed&&p)return[];const r=d.inputs.map(c=>eh(c)).flat(),l=d.calls;i.push(...O(r),...l)}if(Ci.includes(d.type)&&d.type!==o.Condition&&d.type!==o.Loop){const r=d==null?void 0:d.outputs.map(e=>eh(e)).flat(),l=d.successCalls,c=d.errorCalls;i.push(...O(r),...l,...c)}if(St.includes(d.type)){const r=eh(d),l=x2e(d);i.push(...r,...l)}if(d.type===o.Loop){const r=d.outputs.map(e=>eh(e)).flat();if(d.body){const e=xg(d.body,p);i.push(...e)}const l=d.errorCalls,c=d.successCalls;i.push(...O(r),...c,...l)}if(d.type===o.FunctionDeclaration){if(d.collapsed&&p)return[];const r=d.inputs.map(c=>eh(c)).flat(),l=d.calls;i.push(...O(r),...l)}return O(i)}function Mg(d,p=!1){const i=Ml(d,p),r=[...i,...i.reduce((l,c)=>[...l,...Mg(c,p)],[])];return O(r)}function B2e(d,p=!1){const i=xg(d,p),r=[...i,...i.reduce((l,c)=>[...l,...B2e(c,p)],[])];return O(r)}function jT(d){if(!d)throw new Error("[flattenDefinitionEntityImplementionTypes] Entity must be defined to flatten implementation types");return d.implements.reduce((p,i)=>i.type===o.DefinitionEntity?[...p,o.DefinitionEntity,...jT(i),...Dp(i)]:(i==null?void 0:i.type)===o.BuiltInBaseEntity?[i==null?void 0:i.name,...Dp(i)]:[...p],[])}function Dp(d){var p;if(!d)throw new Error("[flattenDefinitionEntityExtensionTypes] Entity must be defined to flatten extension types");if(d.extends){if(((p=d.extends)==null?void 0:p.type)===o.DefinitionEntity)return[o.DefinitionEntity,...Dp(d.extends),...jT(d.extends)];if(d.extends.type===o.BuiltInBaseEntity)return[d.extends.name,...Dp(d.extends)]}return[]}function kT(d){var p,i;return d.extends?((p=d.extends)==null?void 0:p.type)===o.DefinitionEntity?[d.extends,...kT(d.extends),...X_(d.extends)]:((i=d.extends)==null?void 0:i.type)===o.BuiltInBaseEntity?[d.extends,...kT(d.extends)]:[]:[]}function X_(d){return d.implements.reduce((p,i)=>i.type===o.DefinitionEntity?[...p,i,...X_(i),...kT(i)]:(i==null?void 0:i.type)===o.BuiltInBaseEntity?[i,...kT(i)]:[...p,i],[])}function th(d){return[...Dp(d),...jT(d)].filter((i,r,l)=>l.indexOf(i)===r)}function qi(d,p){if(!d)throw new Error("checkHasBaseEntity: entity is null or undefined");if(d.type!==o.DefinitionEntity&&d.type!==o.BuiltInBaseEntity)throw new Error(`checkHasBaseEntity: entity is not a '${o.DefinitionEntity}' or '${o.BuiltInBaseEntity}', got ${d.type}`);return d.type===o.BuiltInBaseEntity?!!(d.name===p||[...Dp(d)].includes(p)):!!th(d).includes(p)}function G2e(d,p){if(!d)throw new Error("getFirstBaseEntityWithOwnBase: entity is null or undefined");if(d.type!==o.DefinitionEntity&&d.type!==o.BuiltInBaseEntity)throw new Error(`getBaseEntity: entity is not a '${o.DefinitionEntity}' or '${o.BuiltInBaseEntity}', got ${d.type}`);if(d.type===o.BuiltInBaseEntity){if(qi(d,p))return d;if(d.extends&&d.extends.type!==o.PrimitiveEntity){if(qi(d.extends,p))return d.extends;if(d.extends.type===o.BuiltInBaseEntity)return Ud(d.extends,p)}return null}if(d.extends)return qi(d.extends,p)?d.extends:Ud(d.extends,p);if(d.implements.length>0){for(const i of d.implements)if(i.type===o.BuiltInBaseEntity){if(qi(i,p))return i;const r=Ud(i,p);if(r)return r}else if(i.type===o.DefinitionEntity){const r=Ud(i,p);if(r)return r}}return null}function Ud(d,p){if(!d)throw new Error("getBaseEntity: entity is null or undefined");if(d.type!==o.DefinitionEntity&&d.type!==o.BuiltInBaseEntity)throw new Error(`getBaseEntity: entity is not a '${o.DefinitionEntity}' or '${o.BuiltInBaseEntity}', got ${d.type}`);if(d.type===o.BuiltInBaseEntity){if(d.name===p)return d;if(d.extends){if(d.extends.name===p)return d.extends;if(d.extends.type===o.BuiltInBaseEntity)return Ud(d.extends,p)}return null}if(d.extends)return d.extends.name===p?d.extends:Ud(d.extends,p);if(d.implements.length>0){for(const i of d.implements)if(i.type===o.BuiltInBaseEntity){if(i.name===p)return i;const r=Ud(i,p);if(r)return r}else if(i.type===o.DefinitionEntity){const r=Ud(i,p);if(r)return r}}return null}function U2e(d){const p=Rp(d),i=[...p,...p.reduce((r,l)=>[...r,...U2e(l)],[])];return O(i)}function Q_(d){return d.implements.length===0&&!d.extends?null:d.implements.find(r=>r.type===o.BuiltInBaseEntity&&r.name===De.PERSISTED_ENTITY)?d:[...d.implements,...d.extends?[d.extends]:[]].reduce((r,l)=>{if(l.type===o.DefinitionEntity){const c=Q_(l);if(c)return c}return r},null)}function fLt(d){return d.extends&&d.extends.type===o.BuiltInBaseEntity?d.extends:null}function yLt(d){const p=d.implements.find(i=>i.type===o.BuiltInBaseEntity);return p&&p.type===o.BuiltInBaseEntity?p:null}function Bg(d){return d.extends&&d.extends.type===o.DefinitionEntity?d.extends:null}function qr(d){const p=[...d.implements||[],...d.extends?[d.extends]:[]].reduce((i,r)=>r.type===o.BuiltInBaseEntity?[...i,r,...qr(r)]:r.type===o.DefinitionEntity?[...i,...qr(r)]:i,[]);return O(p)}function Bc(d){var p;if(d.type===o.PrimitiveEntity)return!0;if(d.type===o.BuiltInBaseEntity)return d.interactive;if(d.type===o.DefinitionEntity)return!qr(d).find(l=>!l.interactive);if(d.type===o.Property)if(d.interactive)if(d.implements.every(i=>i.interactive)){if(d.extends&&!d.extends.interactive)return!1}else return!1;else return!1;else if((d.type===o.InputMap||d.type===o.OutputMap)&&((p=d.declaration)==null?void 0:p.type)===o.Property)return Bc(d.declaration);return!0}function hLt(d){return[o.DefinitionEntity,o.BuiltInBaseEntity,o.PrimitiveEntity,o.Property,o.InputMap,o.OutputMap].includes(d.type)?Bc(d):!0}function mLt(d){return d.parent===d.project&&d.project.variableDeclarations.includes(d)}function eP(d){return d.parent!==d.project?!1:o.VariableDeclaration===d.type?d.project.variableDeclarations.includes(d):o.VariableInstance===d.type?d.project.variableInstances.includes(d):o.FunctionCall===d.type?d.project.functionCalls.includes(d):o.Condition===d.type?d.project.conditions.includes(d):o.Operation===d.type?d.project.operations.includes(d):o.Loop===d.type?d.project.loops.includes(d):o.Search===d.type?d.project.searches.includes(d):!1}function j2e(d){if([...Wt,o.DefinitionEntity,o.InstalledProject,o.Project].includes(d.type)||eP(d))return!1;const p=Rp(d);return p.length===0?!0:p.some(i=>j2e(i))}function tP(d){return[...Wt,o.DefinitionEntity,o.InstalledProject,o.Project].includes(d.type)||eP(d)?!1:Rp(d).length===0}function k2e(d,p=0){if(tP(d)){const i=Rp(d);return i.length===0?d:i.map(l=>k2e(l,p+1)).reduce((l,c)=>l?c&&c.x<l.x?c:l:c,null)}return null}function K2e(d){const p=[];if(tP(d))p.push(d);else return[];return Rp(d).forEach(r=>{p.push(...K2e(r))}),p}function iP(d){return d.type===o.FunctionDeclaration&&d.parent!==d.project&&!![o.DefinitionEntity,o.Loop,o.InstalledProject].includes(d.parent.type)}function TLt(d,p){const i=new Map;return d.forEach(r=>{i.set(r.id,r)}),p.forEach(r=>{i.set(r.id,r)}),Array.from(i.values())}function ih(d){switch(d){case o.DefinitionEntity:return ms;case o.FunctionDeclaration:return Io;case o.VariableDeclaration:return pp;case o.VariableInstance:return up;case o.FunctionCall:return gp;case o.Operation:return tp;case o.Condition:return rp;case o.ReturnStatement:return Pd;case o.Loop:return np;case o.Search:return cp;case o.InputMap:return fs;case o.OutputMap:return xl;case o.ArgumentDeclaration:return fa;case o.Property:return Ga;case o.InstalledProject:return fp;case o.Project:return L;case o.DataType:return dn;case o.GlobalEvent:return ip;case o.InternalCall:return yp;case o.ValueDescriptor:return $d;case o.BuiltInBaseEntity:return No;case o.PrimitiveEntity:return ha;case o.ActionDescriptor:return Pi;case o.LiteralValue:return Xn;case o.ContinueStatement:return mp;case o.BreakStatement:return hp;default:return null}}function lr(d,p,i=null){const r=d!=null&&d.parent?ye(d==null?void 0:d.parent):null;let l=r?p.get(r):null,c=i||d;if((d==null?void 0:d.id)===(p==null?void 0:p.id))return p;if(d.type===o.ReturnStatement)return Qn(d,p,c);if(d.type===o.FunctionDeclaration&&(l==null?void 0:l.type)===o.Loop)return l;if(Wt.includes(d.type))return d;if(d.type===o.Loop)return c.id===d.id?l:d;if(aa.includes(d.type))return null;const e=d.parent;if(!e)return null;if(e.type===o.GenericReference){const y=ye(e);if(!y)return null;const v=p.get(y);return v?lr(v,p,c):null}else return e===p?p:lr(e,p,c)}function Qn(d,p,i=null){const r=d!=null&&d.parent?ye(d==null?void 0:d.parent):null;let l=r?p.get(r):null,c=i||d;if(d.type===o.FunctionDeclaration&&(l==null?void 0:l.type)===o.Loop)return Qn(l.parent,p,c);if(Wt.includes(d.type))return d;if(aa.includes(d.type))return null;const e=d.parent;if(!e)return null;if(e.type===o.GenericReference){const y=ye(e);if(!y)return null;const v=p.get(y);return v?Qn(v,p,c):null}else return e===p?p:Qn(e,p,c)}function jd(d,p){if(aa.includes(d.type))return ae.warn(`getRootEntryPointScopeOwner is \`null\` because it was called with a built-in entity type: ${d.type}`),null;if(p.getBuiltIn(d.id))return ae.warn(`getRootEntryPointScopeOwner is \`null\` because it was called with a built-in entity: ${d.id}`),null;const i=Zr(d.parent,p);return i?i===p?bn.includes(d.type)?d:(ae.warn(`getRootEntryPointScopeOwner is \`null\` because it was called with an entity that has the project as parent: ${d.id}`),null):i.type===o.DefinitionEntity?d:jd(i,p):(ae.warn(`getRootEntryPointScopeOwner is \`null\` because it was called with an entity that has no parent: ${d.id}`),null)}function Gg(d,p,i){if(d===p||p===i||d===i||!d||!p)return!1;const r=lr(p.parent,i);return r===i?!1:r===d?!0:Gg(r,p,i)}var Ug=(d=>(d.SameBothLocal="same-both-local",d.AInB="a-in-b",d.BInA="b-in-a",d.ParallelInCommonParent="parallel-in-common-parent",d.ParallelInProject="parallel-in-project",d.AIsGlobalBIsNot="a-is-global-b-is-not",d.BIsGlobalAIsNot="b-is-global-a-is-not",d.SameBothGlobal="same-both-global",d))(Ug||{});function hs(d,p,i){const r=lr(d,i),l=lr(p,i);if(!r)throw new Error("Could not find scope owner for the entity: "+d.id);if(!l)throw new Error("Could not find scope owner for the entity: "+p.id);if(r===l&&r.type!==o.Project)return{compatible:!0,type:"same-both-local",commonAncestorScope:r};if(r===l&&r.type===o.Project)return{compatible:!0,type:"same-both-global",commonAncestorScope:r};if(r.type===o.Project&&l.type!==o.Project)return{compatible:!1,type:"a-is-global-b-is-not",commonAncestorScope:r};if(r.type!==o.Project&&l.type===o.Project)return{compatible:!1,type:"b-is-global-a-is-not",commonAncestorScope:l};if(Gg(r,l,i))return{compatible:!0,type:"b-in-a",commonAncestorScope:r};if(Gg(l,r,i))return{compatible:!0,type:"a-in-b",commonAncestorScope:l};const y=z_(r,l);return y===i?{compatible:!1,type:"parallel-in-project",commonAncestorScope:y}:y?{compatible:!1,type:"parallel-in-common-parent",commonAncestorScope:lr(y,i)}:{compatible:!1,type:"parallel-in-project",commonAncestorScope:i}}function S2e(d,p,i){const r=hs(d,p,i);if(!r.compatible||r.type!=="same-both-local")return null;if(d===p)return d;let l=lr(d.parent,i);if(l){if(l===p)return p;if(l.type===o.Project)return d}else return d;for(;l;){if(l){if(l===p)return p;if(l.type===o.Project)return d}else return d;l=lr(l.parent,i)}let c=lr(p.parent,i);if(c){if(c===d)return d;if(c.type===o.Project)return p}else return p;for(;c;){if(c){if(c===d)return d;if(c.type===o.Project)return p}else return p;c=lr(c.parent,i)}return null}function F2e(d){return d.length===0?null:d.length===1?d[0]:d.reduce((i,r)=>{const l=S2e(i,r,r.project);return!l||l===r?i:r},d[0])}function Zr(d,p){if(!d)return null;let i;return typeof d=="string"?i=d:d.type===o.GenericReference?i=ye(d):i=d.id,i===p.id?p:p.get(i)}function Op(d){if(!d)return null;if(aa.includes(d.type))return d;if(d.type===o.Project)return null;if(d.project.getBuiltIn(d.id))return d;const p=d.parent;return!p||p.type===o.Project?null:Op(p)}function KT(d){const p=[];function i(c,e){return p.some(y=>y.blockedByCaller===c&&y.blockedByCalling===e)}function r(c,e){i(c,e)||p.push({blockedByCaller:c,blockedByCalling:e})}const l=jd(d,d.project);return l?(d.calledBySuccess.forEach(c=>{[...c.successCalls||[]].forEach(v=>{Gt.includes(v.type)&&v.id!==d.id&&(Ot(d).find(b=>b===v)||r(c,v))});let y;if(Ci.includes(c.type)&&(y=c),y){const v=KT(y);v.reachable||Ot(d).find(b=>b===c)||v.blocks.forEach(b=>{r(c,b.blockedByCalling)})}}),d.calledByError.forEach(c=>{[...c.errorCalls||[]].forEach(v=>{Gt.includes(v.type)&&v!==d&&(Ot(d).find(b=>b===v)||r(c,v))});let y;if(Ci.includes(c.type)&&(y=c),y){const v=KT(y);v.reachable||Ot(d).find(b=>b===c)||v.blocks.forEach(b=>{r(c,b.blockedByCalling)})}}),d.calledByEntry.forEach(c=>{if([...c.calls||[]].forEach(v=>{Gt.includes(v.type)&&v!==d&&(Ot(d).find(b=>b===v)||r(c,v))}),c===l)return;let y;if(c.type===o.FunctionDeclaration){const v=Fi(c);if(v.type===o.DefinitionEntity)return;v.type===o.Loop&&(y=v)}if(y){const v=KT(y);v.reachable||v.blocks.forEach(E=>{r(c,E.blockedByCalling)})}}),{reachable:p.length===0,entryPoint:l,blocks:p}):{reachable:!0,entryPoint:null,blocks:[]}}function vLt(d){return Wh.includes(d.type)?d.type===o.FunctionDeclaration?!iP(d):!0:!1}function ELt(d){if(o.ActionDescriptor===d.type){if(d.project.operationDeclarations.find(c=>c.id===d.id))return o.Operation;if(d.project.globalEventActionDescriptors.find(c=>c.id===d.id))return o.GlobalEvent;if(d.project.loopDeclarations.find(c=>c.id===d.id))return o.Loop;if(d.project.conditionDeclarations.find(c=>c.id===d.id))return o.Condition}return d.type}function jg(d,p){return d.type===o.BuiltInBaseEntity?d.name===p:!!Dp(d).includes(p)}function bLt(d,p){return d.type===o.BuiltInBaseEntity?d.name===p:!!jT(d).includes(p)}function ALt(d){const p=[];return d.entities.forEach(i=>{if(jg(i,De.PERSISTED_ENTITY)){p.push(i);return}}),O(p)}function gLt(d){const p=[];return d.entities.forEach(i=>{if(jg(i,De.RELATIONAL_DATABASE)){p.push(i);return}}),O(p)}function q2e(d){return d.type!==o.DefinitionEntity||d.abstract||!jg(d,De.PERSISTED_ENTITY)?null:(d==null?void 0:d.properties.find(i=>i.implements.find(r=>r.id===Q[o.BuiltInBaseEntity][De.PERSISTED_ENTITY].properties.primaryKey.id)&&!i.abstract))||null}function Z2e(d){var r;const p=Q_(d);if(!p)return null;const i=p.properties.find(l=>l.implements.find(c=>c.id===Q[o.BuiltInBaseEntity][De.PERSISTED_ENTITY].properties.database.id));return i?(r=i.getDefaultValue())==null?void 0:r.valueAsType:null}function xr(d){if(d.type!==o.DefinitionEntity)return[];if(d.abstract)return[];if(!qi(d,De.PERSISTED_ENTITY))return[];const p=[],i=d.properties.filter(r=>!r.implements.find(l=>l.id===Q[o.BuiltInBaseEntity][De.PERSISTED_ENTITY].properties.database.id)&&!r.abstract);return p.push(...i),p}function ILt(d){var i;if(!d||d.type!==o.DefinitionEntity||!qi(d,De.PERSISTED_ENTITY))return null;const p=d.properties.find(r=>!!r.implements.find(l=>l.id===Q[o.BuiltInBaseEntity][De.PERSISTED_ENTITY].properties.database.id));return(i=p==null?void 0:p.getDefaultValue())==null?void 0:i.valueAsTypeSingle}function Vn(d,p){var r;if(!U$.includes(p.type)||!d)return p.project||null;let i=p.project;return d.type===o.Project?i=d:(((r=p.project)==null?void 0:r.id)!==d.project.id||p.project!==d.project)&&(i=d.project),i}function RLt(d){switch(d){case o.Project:return L;case o.InstalledProject:return fp;case o.DefinitionEntity:return ms;case o.FunctionDeclaration:return Io;case o.GlobalEvent:return ip;case o.VariableInstance:return up;case o.VariableDeclaration:return pp;case o.InputMap:return fs;case o.OutputMap:return xl;case o.Condition:return rp;case o.Operation:return tp;case o.FunctionCall:return gp;case o.ArgumentDeclaration:return fa;case o.PrimitiveEntity:return ha;case o.DataType:return dn;case o.Property:return Ga;case o.ActionDescriptor:return Pi;case o.ReturnStatement:return Pd;case o.ContinueStatement:return mp;case o.BreakStatement:return hp;case o.Loop:return np;case o.Search:return cp;case o.ValueDescriptor:return $d;case o.InternalCall:return yp;case o.LiteralValue:return Xn}return null}function DLt(d){const p={added:{},updated:{},removed:{},affected:[],seenEntities:[],self:d==null?void 0:d.self};return d==null||d.added.forEach(i=>{p.added[i.id]=i}),d==null||d.updated.forEach(i=>{p.updated[i.id]=i}),d==null||d.removed.forEach(i=>{p.removed[i.id]=i}),p.affected=Array.from(new Set(d==null?void 0:d.affected.map(i=>i.id))),p}function Nn(d,p){const i=ih(d.type);return i?!i.MUTABLE_META_PROPERTIES.every(l=>{const c=d[l],e=p[l];return e===void 0||c===e?!0:Array.isArray(c)&&Array.isArray(e)?c.length!==e.length?!1:c.every((y,v)=>y===e[v]):!1}):!1}function $n(d,p,i){let r={...p};if(!d.checkCanEdit(d,i)){const l=ih(d.type);if(!l)return r;l.MUTABLE_META_PROPERTIES.forEach(c=>{["x","y","collapsed"].includes(c)||delete r[c]})}return r}function ST(d,p={}){if(d.type===o.Project)return[];if(!d.parent)return[];const i=ye(d.parent);if(!i)return[];const r=p[i];return r?[r.id,...ST(r,p)]:[]}function OLt(d){const p=[],i=new Set;return[...d.listAdded,...d.listUpdated,...d.listAffected].forEach(l=>{var y;const c=Fi(l);if(!c||i.has(c.id))return;const e=d.project.get(c.id)||d.project.getDeleted(c.id);if(!e)throw new Error(`[getTouchedCanvasEntitiesFromChangeSet] Could not find active version of ${c.type} ${c.id} in project, which is present in the change set.${c.parent?` With parent ${(y=c.parent)==null?void 0:y.type} ${ye(c.parent)}`:""}`);i.add(c.id),i.add(l.id),p.push(e)}),O(p)}function wLt(d){if(d.type===o.Condition)return null;if(d.type===o.Search)return d.project.getBuiltIn(Q["value-descriptor"][jv.SearchErrorOutputDescriptor].id)||null;if(d.type===o.Operation)return d.declaration.error;if(d.type===o.FunctionCall){const i=d.declaration.returnStatements.find(r=>!!r.throws);return(i==null?void 0:i.throws)||null}return null}function H2e(d){const p=d.entities.filter(l=>!!l.implements.find(c=>c.id===Q["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id)),i=p.find(l=>{const c=l.properties.find(v=>v.implements.find(E=>E.id===Q["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.properties.default.id)),e=c==null?void 0:c.getDefaultValue();return(e==null?void 0:e.value)===!0});return i||p[0]||null}function nP(d,p){const i=Array.from(new Set([...p.getAllBuiltInIds(),...rn()]));return!!(i.includes(d.id)||!ST(d,{...p.instances,...p.builtInInstances}).every(c=>!i.includes(c)))}function W2e(d){if(!d)return null;if(d.type===o.Project)return d.id;const p=d.parent;return p?W2e(p):d.id}function FT(d){if(d.declaration&&d.declaration.type===o.Property){if(d.declaration.interactive)if(d.declaration.implements.every(p=>p.interactive)){if(d.declaration.extends&&!d.declaration.extends.interactive)return!1}else return!1;else return!1;if(d.declaration.private){const p=Fi(d),i=jd(p,d.project);if((i==null?void 0:i.type)===o.FunctionDeclaration&&(i==null?void 0:i.parent.type)===o.DefinitionEntity&&(i==null?void 0:i.parent.id)!==d.declaration.parent.id)return!1}}return!0}function rP(d){if(d.interactive)if(d.implements.every(p=>p.interactive)){if(d.extends&&!d.extends.interactive)return!1}else return!1;else return!1;if(d.private){const p=Fi(d),i=jd(p,d.project);if((i==null?void 0:i.type)===o.FunctionDeclaration&&(i==null?void 0:i.parent.type)===o.DefinitionEntity&&(i==null?void 0:i.parent.id)!==d.parent.id)return!1}return!0}function CLt(d,p,i){const r=p,l=i,c=!!i,e=[];return r.forEach(y=>{var v;if(c){const E=hs(l,y,d);if(!E.compatible&&E.type!=="b-is-global-a-is-not")return;e.push(y)}else{if(((v=y.parent)==null?void 0:v.type)!==o.Project)return;e.push(y)}}),O(e)}function aP(d,p){var i,r,l,c;if(!d||!p)return null;if(d.id===p.id)return d;if(d.type===o.FunctionDeclaration){if(((i=d.implements)==null?void 0:i.id)===p.id)return d;if(((r=d.extends)==null?void 0:r.id)===p.id)return d;if(d.extends){const e=aP(d.extends,p);if(e)return e}}if(p.type===o.FunctionDeclaration){if(((l=p.implements)==null?void 0:l.id)===d.id)return p;if(((c=p.extends)==null?void 0:c.id)===d.id)return p;if(p.extends){const e=aP(p.extends,d);if(e)return e}}return null}function Gc(d){if(d.type!==o.FunctionDeclaration&&d.type!==o.ActionDescriptor)throw new Error(`Entity is not a FunctionDeclaration or ActionDescriptor: ${d.type}`);if(d.type===o.FunctionDeclaration){if(d.implements)return Gc(d.implements);if(d.extends)return Gc(d.extends)}return d}function kd(d){var p;return!!(d.required||(p=d.declaration)!=null&&p.required)}function Kd(d){return d==null||d===""}function Bl(d){return d?d.valueAsType?!1:Kd(d.value):!0}function kg(d,p,i,r=new Set,l=Array.from(new Set([...d.project.getAllBuiltInIds(),...rn()]))){if(r.has(d.id)||l.includes(d.id))return;r.add(d.id),d.editable=i,d.deletable=i,p.add(d,W.Updated);const{downstream:c}=Gd(d,d.project.instances,{ignoreBuiltInBaseEntities:!0,allBuiltInEntityIds:l});Object.keys(c).forEach(e=>{const y=d.project.get(e);y&&kg(y,p,i,r,l)})}function _Lt(d,p,i=new Set,r=Array.from(new Set([...d.project.getAllBuiltInIds(),...rn()]))){kg(d,p,!0,i,r)}function PLt(d,p,i=new Set,r=Array.from(new Set([...d.project.getAllBuiltInIds(),...rn()]))){kg(d,p,!1,i,r)}function z2e(d,p=[]){return O(Vo(d)).filter(r=>!p.includes(r.id))}function qT(d){return d.replace(/["'`]/g,"")}function Ji(d){const i=qT(d).split(/[\s-]+/).filter(e=>e.length>0);if(i.length===0)return"";const r=i[0],l=r[0].toLowerCase()+r.slice(1),c=i.slice(1).map(e=>e[0].toUpperCase()+e.slice(1));return[l,...c].join("")}function Uc(d){return qT(d).split(/[\s-]+/).filter(r=>r.length>0).map(r=>r[0].toUpperCase()+r.slice(1)).join("")}function J2e(d){const p=qT(d).trim();if(!p)return"";const i=p.replace(/[\s_-]+/g," ").split(" ").filter(Boolean),r=[];for(const l of i){let c=l;c=c.replace(/([A-Z]+)([A-Z][a-z]+)/g,"$1-$2"),c=c.replace(/([a-z0-9])([A-Z][a-z0-9]*)/g,"$1-$2"),c=c.replace(/([0-9])([a-zA-Z]+)/g,"$1-$2"),c=c.replace(/([a-zA-Z])([0-9])/g,"$1-$2");for(const e of c.split("-"))e&&r.push(e)}return r.join("-")}function VLt(d){const p=qT(d).trim();if(!p)return"";const i=p.replace(/[\s_-]+/g," ").split(" ").filter(Boolean),r=[];for(const l of i){let c=l;c=c.replace(/([A-Z]+)([A-Z][a-z]+)/g,"$1_$2"),c=c.replace(/([a-z0-9])([A-Z][a-z0-9]*)/g,"$1_$2"),c=c.replace(/([0-9])([a-zA-Z]+)/g,"$1_$2"),c=c.replace(/([a-zA-Z])([0-9])/g,"$1_$2");for(const e of c.split("_"))e&&r.push(e)}return r.join("_")}function Kg(d){return J2e(d).toLowerCase()}function sP(d){const p=qT(d).trim();if(!p)return"";let i=p.replace(/([A-Z]+)([A-Z][a-z]+)/g,"$1 $2").replace(/([a-z0-9])([A-Z][a-z0-9]*)/g,"$1 $2").replace(/[_-]+/g," ").replace(/\s+/g," ").trim();return i.charAt(0).toUpperCase()+i.slice(1)}function nh(d){var i,r,l,c;if(!d)return"Any data type";let p="";if(d.interactiveEntities===!1?p+=` but only definition nodes ${d.asType?"as template ":""}that don't include non-interactive built-in functionality`:d.interactiveEntities===!0&&(p+=` but only definition nodes ${d.asType?"as template ":""}that extend or implement interactive built-in functionality`),d.staticEntities===!1?p?p+=" and that aren't a single global copy instance":p+=` but only definition nodes ${d.asType?"as template ":""}that aren't a single global copy instance`:d.staticEntities===!0&&(p?p+=" and that are a single global copy instance":p+=` but only definition nodes ${d.asType?"as template ":""}that are a single global copy instance`),d.actionEntities===!1?p?p+=" excluding executable/action nodes":p+=` excluding executable/action nodes ${d.asType?"templates ":""}`:d.actionEntities===!0&&(p?p+=" and not executable/action nodes":p+=" but not executable/action nodes"),d.entity&&(p=""),d.asType&&!p&&!((i=d.andChildrenGroup)!=null&&i.length)&&!((r=d.orChildrenGroup)!=null&&r.length)&&(p=" as template"),d.foreignKeyRef){const e=d.isList,y=le(d.foreignKeyRef,d.project),v=le(d.foreignKeyRef.parent,d.project);return e?`List references to "${y}" from "${v}"${p}`:`Reference to "${y}" from "${v}"${p}`}else{if(d.foreignKeyAllowed)return d.isList?`List of foreign key references${p}`:`Foreign key reference${p}`;if(!d.entity){const e=d.isList;if(!((l=d.andChildrenGroup)!=null&&l.length)&&!((c=d.orChildrenGroup)!=null&&c.length))return e?`List of an any data type${p}`:`Any data type${p}`;let y="",v=!1,E=!1;return(d.andChildrenGroup||[]).forEach(A=>{const b=nh(A),w=Ec(b);v&&(y+=" and "),A.isGroup?y+="("+w+")":v?y+=w:y+=b,v=!0,E=!0}),(d.orChildrenGroup||[]).forEach(A=>{const b=nh(A),w=Ec(b);v&&(E&&(y+=","),y+=" or "),A.isGroup?y+="("+w+")":v?y+=w:y+=b,v=!0}),e?`List of ${Ec(y)}`:y}}if(d.entity.type===o.PrimitiveEntity){let e=d.entity.name;switch(d.entity.name){case oe.String:e="Text";break;case oe.KeyValue:e="Data structure";break}return d.isList?`List of ${e}s${p}`:`${e.slice(0,1).toUpperCase()}${e.slice(1)}${p}`}else if(d.entity.type===o.DefinitionEntity){const e=le(d.entity,d.project);return d.isList?`List of ${e} values${p}`:e.slice(0,1).toUpperCase()+e.slice(1)+p}else if(d.entity.type===o.BuiltInBaseEntity){const e=X2e(d.entity);return d.isList?`List of ${e} values${p}`:e.slice(0,1).toUpperCase()+e.slice(1)+p}else if(d.entity.type===o.LiteralValue){if(d.entity.name===oe.Null)return"Empty value";if(d.entity.name===oe.Untyped)return"Untyped value";if(d.entity.name===oe.File)return"File";if(d.entity.name===oe.String)return`"${d.entity.value}" text`;if(d.entity.name===oe.Number)return`Number '${d.entity.value}'`;if(d.entity.name===oe.Boolean)return`${d.entity.value} value`;if(d.entity.name===oe.UUID)return`"${d.entity.value}" unique identifier`;if(d.entity.name===oe.Date)return`"${d.entity.value}" date`}return d.isList?`List of ${le(d.entity,d.project)} values${p}`:`${le(d.entity,d.project).slice(0,1).toUpperCase()+le(d.entity,d.project).slice(1)} value${p}`}function NLt(d){if(!d)return"Any data type";const p=d.getDataType(null);return nh(p)}function Sg(d){switch(d.declaration.id){case $t.PrimitiveEqual:return"is equal to";case $t.PrimitiveNotEqual:return"is not equal to";case $t.Empty:return"is empty";case $t.NotEmpty:return"is present";case te.MoreThan:return"is greater than";case te.MoreThanOrEqual:return"is greater than or equal to";case te.LessThan:return"is less than";case te.LessThanOrEqual:return"is less than or equal to";case F.Contains:return"contains";case F.StartsWith:return"starts with";case F.EndsWith:return"ends with";case zn.BooleanIsFalse:return"is false";case zn.BooleanIsTrue:return"is true";case an.And:return"and";case an.Or:return"or"}}function Y2e(d){if(d.includes(De.HTTP_ENDPOINT))return"HTTP endpoint";if(d.includes(De.PERSISTED_ENTITY))return"Persisted entity";if(d.includes(De.CRON_JOB))return"Scheduled execution";if(d.includes(De.RELATIONAL_DATABASE))return"Relational database";if(d.includes(De.SQL_ROW_TRANSFORMER))return"Row transformer";if(d.includes(De.GOOGLE_AUTH_CONNECTION))return"Google account connection";if(d.includes(De.SLACK_AUTH_CONNECTION))return"Slack account connection";if(d.includes(De.AIRTABLE_AUTH_CONNECTION))return"Airtable account connection";if(d.includes(De.MICROSOFT_AUTH_CONNECTION))return"Microsoft account connection";if(d.includes(De.OPENAI_AUTH_CONNECTION))return"OpenAI account connection";if(d.includes(De.ATLASSIAN_AUTH_CONNECTION))return"Atlassian account connection";if(d.includes(De.JIRA_AUTH_CONNECTION))return"Jira account connection";if(d.includes(De.GOOGLE_DRIVE_AUTH_CONNECTION))return"Google Drive account connection";if(d.includes(De.GOOGLE_MAIL_AUTH_CONNECTION))return"Gmail account connection";if(d.includes(De.GOOGLE_SHEET_AUTH_CONNECTION))return"Google Sheet account connection";if(d.includes(De.GOOGLE_SLIDES_AUTH_CONNECTION))return"Google Slides account connection";if(d.includes(De.GOOGLE_GEMINI_AUTH_CONNECTION))return"Google Gemini account connection";if(d.includes(De.EXTERNAL_INTEGRATION_CONNECTION))return"External integration connection";try{return sP(d[0])}catch(p){return console.error("Error resolving base entity name for base entities:",d,p),"Built-in base entity"}}function X2e(d){switch(d.name){case De.HTTP_ENDPOINT:return"HTTP endpoint";case De.PERSISTED_ENTITY:return"Persisted entity";case De.CRON_JOB:return"Scheduled execution";case De.RELATIONAL_DATABASE:return"Relational database";case De.SQL_ROW_TRANSFORMER:return"Row transformer";case De.GOOGLE_AUTH_CONNECTION:return"Google account connection";case De.SLACK_AUTH_CONNECTION:return"Slack account connection";case De.AIRTABLE_AUTH_CONNECTION:return"Airtable account connection";case De.MICROSOFT_AUTH_CONNECTION:return"Microsoft account connection";case De.OPENAI_AUTH_CONNECTION:return"OpenAI account connection";case De.ATLASSIAN_AUTH_CONNECTION:return"Atlassian account connection";case De.JIRA_AUTH_CONNECTION:return"Jira account connection";case De.GOOGLE_DRIVE_AUTH_CONNECTION:return"Google Drive account connection";case De.GOOGLE_MAIL_AUTH_CONNECTION:return"Gmail account connection";case De.GOOGLE_SHEET_AUTH_CONNECTION:return"Google Sheet account connection";case De.GOOGLE_SLIDES_AUTH_CONNECTION:return"Google Slides account connection";case De.GOOGLE_GEMINI_AUTH_CONNECTION:return"Google Gemini account connection";case De.EXTERNAL_INTEGRATION_CONNECTION:return"External integration connection";case De.EXTERNAL_INTEGRATION_CONNECTION:return"External integration connection"}try{return sP(d.name)}catch(p){return console.error("Error resolving built-in base entity data type label for entity:",d,p),"Built-in base entity"}}function $Lt(d){const p=Bg(d);if(!p){const i=th(d);return i.includes(De.HTTP_ENDPOINT)?"HTTP endpoint":i.includes(De.PERSISTED_ENTITY)?"Persisted entity":i.includes(De.CRON_JOB)?"Scheduled execution":i.includes(De.RELATIONAL_DATABASE)?"Relational database":i.includes(De.SQL_ROW_TRANSFORMER)?"Row transformer":i.includes(De.GOOGLE_AUTH_CONNECTION)?"Google account connection":i.includes(De.SLACK_AUTH_CONNECTION)?"Slack account connection":i.includes(De.AIRTABLE_AUTH_CONNECTION)?"Airtable account connection":i.includes(De.MICROSOFT_AUTH_CONNECTION)?"Microsoft account connection":i.includes(De.OPENAI_AUTH_CONNECTION)?"OpenAI account connection":i.includes(De.ATLASSIAN_AUTH_CONNECTION)?"Atlassian account connection":i.includes(De.JIRA_AUTH_CONNECTION)?"Jira account connection":i.includes(De.EXTERNAL_INTEGRATION_CONNECTION)?"External integration connection":le(d,d.project)+" entity"}return le(p,d.project)+" entity"}function Q2e(d){let p="Find ";return d.outputs.forEach((i,r)=>{const l=tg(i,null),c=Ec(l&&l.entity?le(l.entity,d.project):"unstructured data");r===0?p+=`${c} `:r===d.outputs.length-1?p+=`and ${c} `:p+=`, ${c} `}),p}function exe(d){switch(d.name){case oe.String:return"Text";case oe.Number:return"Number";case oe.Boolean:return"Boolean";case oe.KeyValue:return"Data structure";case oe.UUID:return"Unique identifier";case oe.Date:return"Date";case oe.EntityTemplate:return"Entity as template";case oe.Enum:return"Enumeration";case oe.File:return"File";case oe.Null:return"Empty";case oe.ActionDescriptor:return"Action descriptor";case oe.Untyped:return"Untyped";default:return d.name}}function txe(d){switch(d.id){case lt.List:return"Loop over list items";case lt.ManualFlow:return"Manual flow control loop";case lt.ObjectKeys:return"Loop over object keys";case lt.ObjectValues:return"Loop over object values";case lt.Counted:return"Loop given number of times";case lt.String:return"Loop over text characters";case $t.PrimitiveEqual:return"is equal to";case $t.PrimitiveNotEqual:return"is not equal to";case $t.Empty:return"is empty";case $t.NotEmpty:return"is present";case _e.DeleteKey:return"Delete property from object";case _e.DeleteNestedKey:return"Delete nested property from object";case _e.HasKey:return"Check if object has property";case _e.HasNestedKey:return"Check if object has nested property";case _e.IsInstanceOfType:return"Check if object is instance of type";case _e.KeyValueEquals:return"Check if object property equals value";case _e.NestedKeyValueEquals:return"Check if object nested property equals value";case _e.ReadKey:return"Read property from object";case _e.ReadNestedKey:return"Read nested property from object";case _e.Validate:return"Validate object structure";case _e.WriteKey:return"Write property to object";case _e.WriteNestedKey:return"Write nested property to object";case _e.WriteSafeNestedKeyRecursively:return"Write safe nested property to object recursively";case _e.Merge:return"Merge objects";case _e.Entries:return"Get a list with the object keys, and values";case _e.Keys:return"Get a list with the object keys";case _e.Values:return"Get a list with the object values";case He.DecodeBase64:return"Decode Base64 text to bytes";case He.EncodeBase64:return"Encode bytes to Base64 text";case He.DecodeBase64Url:return"Decode Base64URL text to bytes";case He.EncodeBase64Url:return"Encode bytes to Base64URL text";case He.DecodeHex:return"Decode Hex text to bytes";case He.EncodeHex:return"Encode bytes to Hex text";case He.FromBytesToString:return"Convert bytes to text";case He.ToBytes:return"Convert text to bytes";case He.ToString:return"Convert value to text";case He.GetTypeOf:return"Get data type of value";case He.ToNumber:return"Convert value to number";case te.Addition:return"Sum numbers";case te.Subtraction:return"Subtract numbers";case te.Multiplication:return"Multiply numbers";case te.Division:return"Divide numbers";case te.Remainder:return"Get remainder of numbers";case te.Absolute:return"Get absolute value of numbers";case te.Acos:return"Get arc cosine of numbers";case te.Asin:return"Get arc sine of numbers";case te.Atan:return"Get arc tangent of numbers";case te.Ceil:return"Round numbers up";case te.Cos:return"Get cosine of numbers";case te.Floor:return"Round numbers down";case te.LogNatural:return"Get natural logarithm of numbers";case te.Log10:return"Get base-10 logarithm of numbers";case te.MaxOf:return"Get maximum of numbers";case te.MinOf:return"Get minimum of numbers";case te.Round:return"Round numbers to nearest integer";case te.Sin:return"Get sine of numbers";case te.SquareRoot:return"Get square root of numbers";case te.Tan:return"Get tangent of numbers";case te.Negate:return"Negate numbers";case te.Atan2:return"Get arc tangent of two numbers";case te.Exp:return"Get exponential of numbers";case te.Average:return"Get average of numbers";case te.Clamp:return"Clamp numbers within range";case te.CubeRoot:return"Get cube root of numbers";case te.LessThan:return"Check if numbers are less than";case te.LessThanOrEqual:return"Check if numbers are less than or equal to";case te.MoreThan:return"Check if numbers are more than";case te.MoreThanOrEqual:return"Check if numbers are more than or equal to";case te.MapRange:return"Map numbers from one range to another";case te.Median:return"Get median of numbers";case te.NthRoot:return"Get nth root of numbers";case te.PercentOf:return"Get percentage of numbers";case te.PercentageChange:return"Get percentage change between numbers";case te.RoundToDecimals:return"Round numbers to given decimal places";case te.Sign:return"Get sign of numbers";case te.SnapToStep:return"Snap numbers to nearest step";case te.ToDegrees:return"Convert numbers to degrees";case te.ToRadians:return"Convert numbers to radians";case te.Trunc:return"Truncate numbers";case te.Exponentiation:return"Get exponent of numbers";case F.AddAtIndex:return"Add at index position";case F.DeleteFirstNChars:return"Delete first characters";case F.DeleteLastNChars:return"Delete last characters";case F.DeleteAtIndex:return"Delete at index position";case F.Join:return"Join texts";case F.ReplaceAllMatches:return"Replace all matches";case F.ReplaceFirstNChars:return"Replace first match";case F.ReplaceLastNChars:return"Replace last match";case F.SplitAtIndex:return"Split text";case F.ReplaceAtIndex:return"Replace at index position";case F.ReplaceFirstMatch:return"Replace single match";case F.GetFirstNChars:return"Get first characters";case F.GetLastNChars:return"Get last characters";case F.GetIndexItem:return"Get at index position";case F.GetIndexOf:return"Get the index number of the character";case F.Append:return"Add at the end";case F.Prepend:return"Add at the start";case F.GetLength:return"Get number of characters";case F.ToUpperCase:return"Convert to uppercase";case F.ToLowerCase:return"Convert to lowercase";case F.Trim:return"Trim whitespace";case F.TrimStart:return"Trim starting whitespace";case F.TrimEnd:return"Trim ending whitespace";case F.Contains:return"Check if text contains value";case F.StartsWith:return"Check if text starts with value";case F.EndsWith:return"Check if text ends with value";case F.CountOccurrences:return"Count occurrences of value";case F.EnsurePrefix:return"Ensure text starts with value";case F.EnsureSuffix:return"Ensure text ends with value";case F.Repeat:return"Repeat text multiple times";case F.Slice:return"Get portion of text";case F.GetLastIndexOf:return"Get last index number of the character";case F.RemovePrefix:return"Remove starting value";case F.RemoveSuffix:return"Remove ending value";case F.MatchAllRegex:return"Find all matches with regular expression";case F.MatchRegex:return"Find first match with regular expression";case F.MatchesRegex:return"Check if text matches regular expression";case F.NormalizeUnicode:return"Normalize Unicode characters";case F.PadEnd:return"Pad text at the end";case F.PadStart:return"Pad text at the start";case F.RemoveDiacritics:return"Remove diacritics from text";case F.ReplaceLastMatch:return"Replace last match";case F.ReplaceRegex:return"Replace match with regular expression";case F.Reverse:return"Reverse text";case F.SplitAtAllSeparators:return"Split text at all separators";case F.SplitAtFirstSeparator:return"Split text at first separator";case F.SplitAtLastSeparator:return"Split text at last separator";case F.Substring:return"Get a portion of the text";case F.SearchRegex:return"Search with regular expression";case Li.Wait:return"Wait";case Li.Parallel:return"Run in parallel";case Li.Sequential:return"Run in sequence";case Gr.HttpRequest:return"HTTP request";case Hn.Parse:return"Parse JSON text";case Hn.Stringify:return"Convert to JSON text";case Xt.ConstantTimeEqual:return"Compare values in constant time";case Xt.Hash:return"Hash value";case Xt.Hmac:return"Create HMAC";case Xt.DeriveKeyPBKDF2:return"Derive key with PBKDF2";case Wn.HashPasswordPBKDF2:return"Hash password with PBKDF2";case Wn.VerifyPasswordPBKDF2:return"Verify password with PBKDF2 hash";case Zi.BuildJwtHmac:return"Build JWT with HMAC";case Zi.DecodeJwt:return"Decode JWT";case Zi.VerifyJwtHmac:return"Verify JWT with HMAC";case ie.AddAtIndex:return"Add item at index position";case ie.DeleteFirstNItems:return"Delete first items";case ie.DeleteLastNItems:return"Delete last items";case ie.DeleteAtIndex:return"Delete items at index position";case ie.Join:return"Join lists";case ie.ReplaceFirstNItems:return"Replace first match";case ie.ReplaceLastNItems:return"Replace last match";case ie.Split:return"Split list";case ie.ReplaceAtIndex:return"Replace at index position";case ie.GetFirst:return"Get first item";case ie.GetLast:return"Get last item";case ie.GetIndexItem:return"Get item at index position";case ie.Append:return"Add item at the end";case ie.Prepend:return"Add item at the start";case ie.Chunk:return"Chunk list into smaller lists";case ie.Shuffle:return"Randomize order of list items";case ie.Reverse:return"Reverse order of list items";case ie.GetFirstNItems:return"Get the first given number of items";case ie.GetLastNItems:return"Get the last given number of items";case ie.Sort:return"Order list items";case ie.Unique:return"Get a new list without duplicate values";case ie.Concat:return"Combine lists";case ie.Slice:return"Get a portion of the list";case ie.Contains:return"Check if list contains value";case ie.ContainsAll:return"Check if list contains all values";case ie.ContainsAny:return"Check if list contains any value";case ie.Flatten:return"Flatten nested lists into a single list";case ie.GetIndexOf:return"Get the index position number of the item";case ie.GetLastIndexOf:return"Get the last index position number of the item";case ie.GetLength:return"Get number of items in list";case ie.PadEnd:return"Pad list at the end";case ie.PadStart:return"Pad list at the start";case ie.Repeat:return"Create a list by repeating an item";case ie.ReplaceAll:return"Replace all matches";case K.AddBusinessDays:return"Add business days to date";case K.AddToDate:return"Add to date";case K.DifferenceBetweenDates:return"Get difference between dates";case K.FormatDate:return"Format date to text";case K.GetCurrentTimestamp:return"Get current date and time";case K.FormatDate:return"Format date to text";case K.ParseDate:return"Parse text to date";case K.SubtractFromDate:return"Subtract from date";case K.ClampToRange:return"Clamp date within range";case K.ConvertTimezone:return"Convert date to different time zone";case K.EndOf:return"Get end of date period";case K.StartOf:return"Get start of date period";case K.FromNow:return"Get date from now";case K.FromUnix:return"Get date from Unix timestamp";case K.GetCurrentIanaTimeZone:return"Get current IANA time zone";case K.ToUnix:return"Convert date to Unix timestamp";case K.GetDate:return"Get day from timestamp";case K.GetMonth:return"Get month from timestamp";case K.GetYear:return"Get year from timestamp";case K.GetHour:return"Get hour from timestamp";case K.GetMinute:return"Get minute from timestamp";case K.GetSecond:return"Get second from timestamp";case K.GetDayOfYear:return"Get day of the year from timestamp";case K.GetWeekOfYear:return"Get week of the year from timestamp";case K.GetDaysInMonth:return"Get number of days in month from timestamp";case K.IsLeapYear:return"Check if year from timestamp is a leap year";case K.GetIsoWeekday:return"Get ISO weekday from timestamp";case K.GetMillisecond:return"Get millisecond from timestamp";case K.GetQuarter:return"Get quarter from timestamp";case K.GetTimezoneOffset:return"Get time zone offset from timestamp";case K.HumanizeDiff:return"Humanize difference between dates";case K.IsAfter:return"Check if date is after another date";case K.IsBefore:return"Check if date is before another date";case K.IsSame:return"Check if date is the same as another date";case K.IsBetween:return"Check if date is between two dates";case K.IsSameOrAfter:return"Check if date is the same or after another date";case K.IsSameOrBefore:return"Check if date is the same or before another date";case K.IsValid:return"Check if date is valid";case K.MaxOf:return"Get maximum date";case K.MinOf:return"Get minimum date";case K.NextWeekday:return"Get next weekday date";case K.PreviousWeekday:return"Get previous weekday date";case K.RoundTo:return"Round date to nearest unit";case K.SetDate:return"Set day of the month in date";case K.SetMonth:return"Set month in date";case K.SetYear:return"Set year in date";case K.SetHour:return"Set hour in date";case K.SetMinute:return"Set minute in date";case K.SetSecond:return"Set second in date";case K.SetMillisecond:return"Set millisecond in date";case K.SetIsoWeekday:return"Set ISO weekday in date";case K.SetQuarter:return"Set quarter in date";case K.SetUTCOffset:return"Set UTC offset in date";case K.ToISOString:return"Convert date to ISO string";case K.ToNow:return"Convert date to relative time string";case K.ToUTC:return"Convert date to UTC";case K.ToDate:return"Convert to date";case Qe.GenerateHexadecimalToken:return"Generate hexadecimal token";case Qe.GenerateIdentifier:return"Generate unique identifier";case Qe.GenerateRandomAlphanumeric:return"Generate random alphanumeric text";case Qe.GenerateRandomBase62:return"Generate random Base62 text";case Qe.GenerateRandomBase64:return"Generate random Base64 text";case Qe.GenerateRandomBytes:return"Generate random bytes";case Qe.GenerateRandomFloat:return"Generate random decimal number";case Qe.GenerateRandomInteger:return"Generate random whole number";case Qe.GenerateRandomHexadecimal:return"Generate random hexadecimal text";case Qe.GenerateRandomUUIDv4:return"Generate random UUID v4";case Qe.GenerateShortIdentifier:return"Generate short unique identifier";case Xs.PROJECT_PUBLICATION_COMPLETED:return"Project publication completed";default:return(d.name.slice(0,1).toUpperCase()+d.name.slice(1)).replaceAll("-"," ")}}function le(d,p){var i;if(o.FunctionDeclaration===d.type){const r=d.name;if(Object.values(Bn).includes(r))switch(r){case Bn.AbortExecution:return"Abort ongoing execution";case Bn.DeletePersistedEntity:return"Delete entry from database";case Bn.CreatePersistedEntity:return"Save new data entry in database";case Bn.UpdatePersistedEntity:return"Update entity data to database";case Bn.DownSQLRowTransformer:return"Reverse row";case Bn.UpSQLRowTransformer:return"Transform row";default:return Sn(d.type).replaceAll("-"," ")}return r}if(o.BuiltInBaseEntity===d.type)return Y2e([d.name]);if(G$.includes(d.type)&&d.type!==o.ActionDescriptor)return d.name;switch(d.type){case o.Search:return Q2e(d);case o.GlobalEvent:return d.implements?le(d.implements,p):Sn(d.type).replaceAll("-"," ");case o.Operation:case o.InternalCall:case o.Loop:const r=Zr(d.declaration,p);return le(r,p);case o.ActionDescriptor:return txe(d);case o.BreakStatement:const l=Zr(d.parent,p);return`Stop loop ${le(l,p)}`;case o.ContinueStatement:const c=Zr(d.parent,p);return`Execute next iteration of ${le(c,p)}`;case o.FunctionCall:return Zr(d.declaration,p).name;case o.Condition:{const y=d;if(y.declaration.id===an.And)return"If all conditions are met";if(y.declaration.id===an.Or)return"If any condition is met";if((i=d.inputs)!=null&&i.length){const v=le(y.inputs[0],y.project);if(y.inputs[1]){const E=y.inputs[1].declaration.name;return`If ${v} ${Sg(y)} ${E}`}return`If ${v} ${Sg(y)}`}else return`If ${Sg(y)}`}case o.ReturnStatement:{const y=Zr(d.parent,p);return y?`Output of ${le(y,p)}`:"Return statement"}case o.InputMap:if(d.declaration){const y=Zr(d.declaration,p);return le(y,p)||""}else{if(!d.name)throw new Error(`Input map entity with id "${d.id}" has no name and no declaration.`);return d.name||""}case o.VariableInstance:{const y=Zr(d.declaration,p);return le(y,p)||""}case o.OutputMap:if(d.declaration){const y=Zr(d.declaration,p);return(y==null?void 0:y.name)||""}else return d.parentRelationType===zd.Error?"Undeclared error":"";case o.PrimitiveEntity:case o.LiteralValue:return exe(d);default:return Sn(d.type).replaceAll("-"," ")}}function lP(d,p){const i=[];d.name||i.push(new Oe({id:`${d.id}--${Re.EmptyName}`,message:`Entity with id "${d.id}" and type "${d.type}" has an empty name. Please provide a 'name' string.`,severity:ce.Error,code:Re.EmptyName}));const r=p.entities.filter(l=>l.name===d.name);return r.length&&i.push(new Oe({id:`${d.id}--${Re.NameNotUniqueInScope}`,message:`Entity with id "${d.id}" and type "${d.type}" has a name "${d.name}" that is not unique in the project. Entity with id "${r[0].id}" has the same name.
|
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.6640",
|
|
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",
|