@elyx-code/project-logic-tree 0.0.6667 → 0.0.6669
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -2
- package/dist/index.js +31 -28
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -371,10 +371,10 @@ You shouldn't have to manually update a 'parent' property. The equivalent result
|
|
|
371
371
|
parent: `+((fe=(Q=U.parent)==null?void 0:Q.parent)==null?void 0:fe.id)+" - "+((ce=(oe=U.parent)==null?void 0:oe.parent)==null?void 0:ce.name):"(not found) "+U.type+" "+U.id})),ie.Logger.log("AFTER - changeSet.listAdded",n.listAdded.map(U=>{var Z,X,ae,Q,fe,oe,ce;const S=d.get(U.id);return S?S.type+' "'+se(S,d)+'" ('+S.id+")":U.type===o.InputMap?"(not found) "+U.type+" ("+U.id+") - declaration: "+((Z=U.declaration)==null?void 0:Z.type)+" ("+((X=U.declaration)==null?void 0:X.id)+') "'+((ae=U.declaration)==null?void 0:ae.name)+`"
|
|
372
372
|
parent: "`+((fe=(Q=U.parent)==null?void 0:Q.parent)==null?void 0:fe.name)+'" ('+((ce=(oe=U.parent)==null?void 0:oe.parent)==null?void 0:ce.id)+")":"(not found) "+U.type+" "+U.id})),ie.Logger.log("-----------------"),ie.Logger.log("Old properties: ",hn(i).map(U=>U.name+" ("+U.id+")")),ie.Logger.log("New properties: ",hn(p).map(U=>U.name+" ("+U.id+")"));const E=e.methods.find(U=>{var S;return((S=U.implements)==null?void 0:S.id)===Y["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.methods.up.id}),b=e.methods.find(U=>{var S;return((S=U.implements)==null?void 0:S.id)===Y["built-in-base-entity"].BUILT_IN_SQL_ROW_TRANSFORMER_ENTITY.methods.down.id});ie.Logger.log(`
|
|
373
373
|
Up inputs: `,E==null?void 0:E.inputs.map(U=>U.name+" ("+U.id+")")),ie.Logger.log("Up method return statements:",E==null?void 0:E.returnStatements[0].outputs.map(U=>se(U,d)+" ("+U.id+")")),ie.Logger.log(`
|
|
374
|
-
Down inputs: `,b==null?void 0:b.inputs.map(U=>U.name+" ("+U.id+")")),ie.Logger.log("Down method return statements:",b==null?void 0:b.returnStatements[0].outputs.map(U=>se(U,d)+" ("+U.id+")"));const O=Vje(n.listAdded.map(U=>d.get(U.id)));let _=p.x;const $=p.y-800;return O.forEach(U=>{var Z;_+=U.x||300*2;let S=U.y||$;U.type===o.ReturnStatement&&((Z=U.parent)==null?void 0:Z.id)===v.id&&(S+=800+70),U.metaSync({x:_,y:S},n)}),(L=y.defaultValue)==null||L.metaSync({editable:!1,deletable:!1},n),y.metaSync({editable:!1,deletable:!1},n),e}function sUi(d,p,i){const{updatedEntityVersion:n,newestOpenRowTransformer:l,lastPublishedEntityVersion:c}=p;return l?(lx(d,l,n,c,i),{rowTransformer:l}):{rowTransformer:ZUe(d,n,c,i)}}function iC(d,p){var i;if(d.type===o.LiteralValue){let n=(i=d.value)==null?void 0:i.toString();try{n=JSON.stringify(d.value,null,2)}catch{}return`${d.type}: ${d.id} (${se(d,p)}) = ${n}`}if(d.type===o.DataType){if(d instanceof lr||d.increaseVersion)return`${d.type}: ${d.id} (${Oy(d)})`;try{const n=Oy(d);return`${d.type}: ${d.id} (${n})`}catch{}}return`${d.type}: ${d.id} (${se(d,p)})`}function Ry(d,p){const i=Mp(d);if(i.length===0)return{list:[],last:null};let n=null;return{list:i.flatMap(c=>{if(c===p)return n=c,[c];const e=Ry(c,p);return e.last&&(n=e.last),[c,...e.list]}),last:n}}function vu(d,p){const i=d.calledBy;if(i.length===0)return{list:[],last:null,callType:null};let n=null,l=null;return{list:i.flatMap(e=>{if(e===p)return n=e,zt.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 n=e.parent,l="loop-body",[e];if(!zr.includes(e.type))return[e];const y=vu(e,p);return y.last&&(n=y.last,l=y.callType),[e,...y.list]}),last:n,callType:l}}function lUi(d,p){if(d===p)return"same-entity";if(!Fr.includes(d.type)||!$s(d).find(l=>l.callee===p))return null;if(zt.includes(d.type)){if(d.calls.includes(p))return d.type===o.Loop?"loop-body":"entry"}else if(Vi.includes(d.type)&&d.type!==o.InternalCall){if(d.successCalls.includes(p))return"success";if(d.errorCalls.includes(p))return"error"}return null}function Sm(d){const p=dn(d,d.project);return p?zt.includes(p.type)?p:p.type===o.Loop?p.body:null:null}function HUe(d,p){const i=d.calledBy;return!i||!i.length?!1:i.every(n=>n===p?!0:zr.includes(n.type)?!!vu(n,p).last:!1)}function WUe(d){return d.filter(p=>{const i=Sm(p);return!d.filter(c=>c!==p).some(c=>c===i?!1:cA(c,p))})}function ox(d){if(!d.calledBy||!d.calledBy.length)return[];const p=d.calledBy.reduce((i,n)=>{if(zr.includes(n.type)){const l=ox(n);return[...i,n,...l]}return i},[]);return D(p)}function zUe(d){const p=ox(d);if(!p.length)return{ancestor:null,callType:null};const n=p.filter(c=>!(c===d||!Fr.includes(c.type)||!Rt(c).find(T=>T===d))).filter((c,e,y)=>y.findIndex(T=>T===c)===e).filter(c=>HUe(d,c)),l=n.filter(c=>{const e=Rt(c),y=n.filter(v=>v!==c).map(v=>v);return!e.some(v=>!!y.find(b=>b===v))});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(zt.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(Vi.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 JUe(d,p,i){var b,O,_,$;const n={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(Fr.includes(d.type)){let L=null;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"),{ancestor:d,callType:L||"success"}}else{if(zr.includes(d.type))return uc(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 L=$s(i),U=L.find(Z=>Z.callee===d),S=L.find(Z=>Z.callee===p);if(!U)throw new Error(`[findNextCombinedSingleCallerAncestor] Invalid 'from' ${i.type} -- ${i.id} argument, doesn't contain 'targetA' entity ${d.type} -- ${d.id}`);if(!S)throw new Error(`[findNextCombinedSingleCallerAncestor] Invalid 'from' ${i.type} -- ${i.id} argument, doesn't contain 'targetB' entity ${p.type} -- ${p.id}`)}const l=cd(d,d.project),c=cd(p,p.project);if((l==null?void 0:l.id)!==(c==null?void 0:c.id))return n;if(!l)return{ancestor:null,callType:null};const e=dn(d,d.project),y=dn(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=es(d,p,d.project).commonAncestorScope;if(v.type===o.Project)return{ancestor:null,callType:null};let E=i||v;if(!E)return{ancestor:null,callType:null};if(!Fr.includes(E.type))throw new Error(`[findNextCombinedSingleCallerAncestor] Invalid 'from' argument, is not a caller entity: ${E.type} -- ${E.id}`);if(E.id===d.id){const U=$s(p).find(S=>S.callee.id===(d==null?void 0:d.id));if(U)return{ancestor:E,callType:U.callType};if(Fr.includes(d.type)){let S=null;return d.type===o.Loop||d.type===o.FunctionDeclaration&&d.parent.type===o.Loop?S="loop-body":(d.type===o.FunctionDeclaration||d.type===o.GlobalEvent)&&(S="entry"),{ancestor:d,callType:S||"success"}}else if(zr.includes(d.type))return uc(d,i);return{ancestor:null,callType:null}}if(E.id===p.id){const U=$s(d).find(S=>S.callee.id===(p==null?void 0:p.id));if(U)return{ancestor:E,callType:U.callType};if(Fr.includes(p.type)){let S=null;return p.type===o.Loop||p.type===o.FunctionDeclaration&&p.parent.type===o.Loop?S="loop-body":(p.type===o.FunctionDeclaration||p.type===o.GlobalEvent)&&(S="entry"),{ancestor:p,callType:S||"success"}}else if(zr.includes(p.type))return uc(p,i);return{ancestor:null,callType:null}}if(zr.includes(d.type)&&zr.includes(p.type)){const L=uc(d,E),U=uc(p,E),S=$s(L.ancestor),Z=$s(U.ancestor);if(((b=U.ancestor)==null?void 0:b.id)===((O=L.ancestor)==null?void 0:O.id))n.ancestor=U.ancestor,n.callType=U.callType;else if(((_=U.ancestor)==null?void 0:_.id)===d.id)n.ancestor=U.ancestor,n.callType=U.callType;else if((($=L.ancestor)==null?void 0:$.id)===p.id)n.ancestor=L.ancestor,n.callType=L.callType;else if(S.some(X=>X.callee.id===(p==null?void 0:p.id))){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)n.callType="loop-body";else if((E==null?void 0:E.type)===o.FunctionDeclaration||(E==null?void 0:E.type)===o.GlobalEvent)n.callType="entry";else{const ae=$s(v).find(Q=>Q.callee.id===(d==null?void 0:d.id));return{ancestor:v,callType:(ae==null?void 0:ae.callType)||"success"}}n.ancestor=v}else if(Z.some(X=>X.callee.id===(d==null?void 0:d.id))){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)n.callType="loop-body";else if((E==null?void 0:E.type)===o.FunctionDeclaration||(E==null?void 0:E.type)===o.GlobalEvent)n.callType="entry";else{const ae=$s(v).find(Q=>Q.callee.id===(p==null?void 0:p.id));return{ancestor:v,callType:(ae==null?void 0:ae.callType)||"success"}}n.ancestor=v}else{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)n.callType="loop-body";else if((E==null?void 0:E.type)===o.FunctionDeclaration||(E==null?void 0:E.type)===o.GlobalEvent)n.callType="entry";else{const ae=$s(v).find(Q=>Q.callee.id===(d==null?void 0:d.id));return{ancestor:v,callType:(ae==null?void 0:ae.callType)||"success"}}n.ancestor=v}}if(!n.ancestor){let L=null;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"),{ancestor:E,callType:L||"success"}}return n}function uc(d,p,i=!1){var S;if(!d)throw new Error("findNextSingleCallerAncestor: Target is not defined, cannot find ancestor.");let n=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)&&(n=d.internalCalls.find(X=>!!X.calledBy.length));const l=dn(n,d.project);let c=p||l;if(!c)return{ancestor:null,callType:null};if(c.type===o.Project&&(c=zUe(n).ancestor,!c))return{ancestor:null,callType:null};const e=$s(c);if(!e.find(Z=>Z.callee===n))return{ancestor:null,callType:null};const T=[...n.calledBy];if(!T.length)return{ancestor:null,callType:null};if(T.length===1){const Z=T[0];if(Z.type===o.Loop){if(Z.body.calls.includes(n))return{ancestor:Z,callType:"loop-body"}}else{if(zt.includes(Z.type))return Z.type===o.FunctionDeclaration&&Z.parent.type===o.Loop?{ancestor:Z.parent,callType:"loop-body"}:{ancestor:Z,callType:"entry"};if(Vi.includes(Z.type)){if(Z.successCalls.includes(n))return{ancestor:Z,callType:"success"};if(Z.errorCalls.includes(n))return{ancestor:Z,callType:"error"}}}}const v=jt.includes(n.type)?[]:Rt(n),E=e.filter(Z=>!(jt.includes(Z.callee.type)||Z.callee===n||!Rt(Z.callee).find(ae=>ae===n)||v.find(ae=>ae===Z.callee)));if(i&&(ie.Logger.log("Flat calls from start point",c.type+" -- "+c.id,e.length,e.map((Z,X)=>X+1+'. "'+se(Z.callee,d.project)+'" '+Z.callee.type+" -- "+Z.callee.id)),ie.Logger.log("----------------------------------------")),i&&(ie.Logger.log("Relevant flat calls from start point",c.type+" -- "+c.id,E.length,E.map((Z,X)=>X+1+'. "'+se(Z.callee,d.project)+'" '+Z.callee.type+" -- "+Z.callee.id)),ie.Logger.log("----------------------------------------")),c.type===o.Loop){if(c.body.calls.includes(n))return{ancestor:c,callType:"loop-body"}}else if(zt.includes(c.type)){if(c.calls.includes(n))return c.type===o.FunctionDeclaration&&c.parent.type===o.Loop?{ancestor:c.parent,callType:"loop-body"}:{ancestor:c,callType:"entry"}}else if(Vi.includes(c.type)){if(d.calledBy.length===1){if(c.successCalls.includes(n))return{ancestor:c,callType:"success"};if(c.errorCalls.includes(n))return{ancestor:c,callType:"error"}}else if(c.successCalls.includes(n)||c.errorCalls.includes(n))return{ancestor:null,callType:null}}const b=E.filter(Z=>{if(Z.callee===n||!Fr.includes(Z.callee.type))return!1;if(!!T.find(oe=>oe===Z.callee))return!0;const ae=Rt(Z.callee),Q=!!ae.find(oe=>oe===n),fe=!!T.every(oe=>ae.find(ce=>ce===oe));return!(!Q||!fe)}).filter((Z,X,ae)=>ae.findIndex(Q=>Q.callee===Z.callee)===X);if(i&&(ie.Logger.log("Remaining calls that reach target",b.length,b.map((Z,X)=>X+1+'. "'+se(Z.callee,d.project)+'" '+Z.callee.type+" -- "+Z.callee.id)),ie.Logger.log("----------------------------------------")),b.length===0)return{ancestor:null,callType:null};const O=b.filter(Z=>{const X=b.filter(ae=>ae!==Z).map(ae=>ae.callee);return zt.includes(Z.callee.type)&&Z.callee.calls.length===1&&X.find(ae=>ae===Z.callee.calls[0])||Vi.includes(Z.callee.type)&&Z.callee.successCalls.length===1&&X.find(ae=>{var Q;return ae.id===((Q=Z.callee.successCalls[0])==null?void 0:Q.id)})?!1:!(Vi.includes(Z.callee.type)&&Z.callee.errorCalls.length===1&&X.find(ae=>{var Q;return ae.id===((Q=Z.callee.errorCalls[0])==null?void 0:Q.id)}))});if(i&&(ie.Logger.log("Reduced single callers",O.length,O.map((Z,X)=>X+1+'. "'+se(Z.callee,d.project)+'" '+Z.callee.type+" -- "+Z.callee.id)),ie.Logger.log("----------------------------------------")),O.length===0)return{ancestor:null,callType:null};if(O.length===1){const Z=O[0];if(Z.callee.type===o.Loop){if(Z.callee.body.calls.includes(n))return{ancestor:Z.callee,callType:"loop-body"}}else{if(zt.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(Vi.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 _=c,$=null,L=O[0].callee,U=O.slice(1);for(;U.length;){const Z=JUe(L,U[0].callee,c);if(((S=Z==null?void 0:Z.ancestor)==null?void 0:S.id)===c.id)return{ancestor:c,callType:Z.callType};Z.ancestor?(_=Z.ancestor,L=Z.ancestor,$=Z.callType,i&&ie.Logger.log('Combined single caller between "'+se(L,n.project)+'" ',L.type+" -- "+L.id,`
|
|
374
|
+
Down inputs: `,b==null?void 0:b.inputs.map(U=>U.name+" ("+U.id+")")),ie.Logger.log("Down method return statements:",b==null?void 0:b.returnStatements[0].outputs.map(U=>se(U,d)+" ("+U.id+")"));const O=Vje(n.listAdded.map(U=>d.get(U.id)));let _=p.x;const $=p.y-800;return O.forEach(U=>{var Z;_+=U.x||300*2;let S=U.y||$;U.type===o.ReturnStatement&&((Z=U.parent)==null?void 0:Z.id)===v.id&&(S+=800+70),U.metaSync({x:_,y:S},n)}),(L=y.defaultValue)==null||L.metaSync({editable:!1,deletable:!1},n),y.metaSync({editable:!1,deletable:!1},n),e}function sUi(d,p,i){const{updatedEntityVersion:n,newestOpenRowTransformer:l,lastPublishedEntityVersion:c}=p;return l?(lx(d,l,n,c,i),{rowTransformer:l}):{rowTransformer:ZUe(d,n,c,i)}}function iC(d,p){var i;if(d.type===o.LiteralValue){let n=(i=d.value)==null?void 0:i.toString();try{n=JSON.stringify(d.value,null,2)}catch{}return`${d.type}: ${d.id} (${se(d,p)}) = ${n}`}if(d.type===o.DataType){if(d instanceof lr||d.increaseVersion)return`${d.type}: ${d.id} (${Oy(d)})`;try{const n=Oy(d);return`${d.type}: ${d.id} (${n})`}catch{}}return`${d.type}: ${d.id} (${se(d,p)})`}function Ry(d,p){const i=Mp(d);if(i.length===0)return{list:[],last:null};let n=null;return{list:i.flatMap(c=>{if(c===p)return n=c,[c];const e=Ry(c,p);return e.last&&(n=e.last),[c,...e.list]}),last:n}}function vu(d,p){const i=d.calledBy;if(i.length===0)return{list:[],last:null,callType:null};let n=null,l=null;return{list:i.flatMap(e=>{if(e===p)return n=e,zt.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 n=e.parent,l="loop-body",[e];if(!zr.includes(e.type))return[e];const y=vu(e,p);return y.last&&(n=y.last,l=y.callType),[e,...y.list]}),last:n,callType:l}}function lUi(d,p){if(d===p)return"same-entity";if(!Fr.includes(d.type)||!$s(d).find(l=>l.callee===p))return null;if(zt.includes(d.type)){if(d.calls.includes(p))return d.type===o.Loop?"loop-body":"entry"}else if(Vi.includes(d.type)&&d.type!==o.InternalCall){if(d.successCalls.includes(p))return"success";if(d.errorCalls.includes(p))return"error"}return null}function Sm(d){const p=dn(d,d.project);return p?zt.includes(p.type)?p:p.type===o.Loop?p.body:null:null}function HUe(d,p){const i=d.calledBy;return!i||!i.length?!1:i.every(n=>n===p?!0:zr.includes(n.type)?!!vu(n,p).last:!1)}function WUe(d){return d.filter(p=>{const i=Sm(p);return!d.filter(c=>c!==p).some(c=>c===i?!1:cA(c,p))})}function ox(d){if(!d.calledBy||!d.calledBy.length)return[];const p=d.calledBy.reduce((i,n)=>{if(zr.includes(n.type)){const l=ox(n);return[...i,n,...l]}return i},[]);return D(p)}function zUe(d){const p=ox(d);if(!p.length)return{ancestor:null,callType:null};const n=p.filter(c=>!(c===d||!Fr.includes(c.type)||!Rt(c).find(T=>T===d))).filter((c,e,y)=>y.findIndex(T=>T===c)===e).filter(c=>HUe(d,c)),l=n.filter(c=>{const e=Rt(c),y=n.filter(v=>v!==c).map(v=>v);return!e.some(v=>!!y.find(b=>b===v))});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(zt.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(Vi.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 JUe(d,p,i){var b,O,_,$;const n={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(Fr.includes(d.type)){let L=null;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"),{ancestor:d,callType:L||"success"}}else{if(zr.includes(d.type))return uc(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 L=$s(i),U=L.find(Z=>Z.callee===d),S=L.find(Z=>Z.callee===p);if(!U)throw new Error(`[findNextCombinedSingleCallerAncestor] Invalid 'from' ${i.type} -- ${i.id} argument, doesn't contain 'targetA' entity ${d.type} -- ${d.id}`);if(!S)throw new Error(`[findNextCombinedSingleCallerAncestor] Invalid 'from' ${i.type} -- ${i.id} argument, doesn't contain 'targetB' entity ${p.type} -- ${p.id}`)}const l=cd(d,d.project),c=cd(p,p.project);if((l==null?void 0:l.id)!==(c==null?void 0:c.id))return n;if(!l)return{ancestor:null,callType:null};const e=dn(d,d.project),y=dn(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=es(d,p,d.project).commonAncestorScope;if(v.type===o.Project)return{ancestor:null,callType:null};let E=i||v;if(!E)return{ancestor:null,callType:null};if(!Fr.includes(E.type))throw new Error(`[findNextCombinedSingleCallerAncestor] Invalid 'from' argument, is not a caller entity: ${E.type} -- ${E.id}`);if(E.id===d.id){const U=$s(p).find(S=>S.callee.id===(d==null?void 0:d.id));if(U)return{ancestor:E,callType:U.callType};if(Fr.includes(d.type)){let S=null;return d.type===o.Loop||d.type===o.FunctionDeclaration&&d.parent.type===o.Loop?S="loop-body":(d.type===o.FunctionDeclaration||d.type===o.GlobalEvent)&&(S="entry"),{ancestor:d,callType:S||"success"}}else if(zr.includes(d.type))return uc(d,i);return{ancestor:null,callType:null}}if(E.id===p.id){const U=$s(d).find(S=>S.callee.id===(p==null?void 0:p.id));if(U)return{ancestor:E,callType:U.callType};if(Fr.includes(p.type)){let S=null;return p.type===o.Loop||p.type===o.FunctionDeclaration&&p.parent.type===o.Loop?S="loop-body":(p.type===o.FunctionDeclaration||p.type===o.GlobalEvent)&&(S="entry"),{ancestor:p,callType:S||"success"}}else if(zr.includes(p.type))return uc(p,i);return{ancestor:null,callType:null}}if(zr.includes(d.type)&&zr.includes(p.type)){const L=uc(d,E),U=uc(p,E),S=$s(L.ancestor),Z=$s(U.ancestor);if(((b=U.ancestor)==null?void 0:b.id)===((O=L.ancestor)==null?void 0:O.id))n.ancestor=U.ancestor,n.callType=U.callType;else if(((_=U.ancestor)==null?void 0:_.id)===d.id)n.ancestor=U.ancestor,n.callType=U.callType;else if((($=L.ancestor)==null?void 0:$.id)===p.id)n.ancestor=L.ancestor,n.callType=L.callType;else if(S.some(X=>X.callee.id===(p==null?void 0:p.id))){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)n.callType="loop-body";else if((E==null?void 0:E.type)===o.FunctionDeclaration||(E==null?void 0:E.type)===o.GlobalEvent)n.callType="entry";else{const ae=$s(v).find(Q=>Q.callee.id===(d==null?void 0:d.id));return{ancestor:v,callType:(ae==null?void 0:ae.callType)||"success"}}n.ancestor=v}else if(Z.some(X=>X.callee.id===(d==null?void 0:d.id))){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)n.callType="loop-body";else if((E==null?void 0:E.type)===o.FunctionDeclaration||(E==null?void 0:E.type)===o.GlobalEvent)n.callType="entry";else{const ae=$s(v).find(Q=>Q.callee.id===(p==null?void 0:p.id));return{ancestor:v,callType:(ae==null?void 0:ae.callType)||"success"}}n.ancestor=v}else{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)n.callType="loop-body";else if((E==null?void 0:E.type)===o.FunctionDeclaration||(E==null?void 0:E.type)===o.GlobalEvent)n.callType="entry";else{const ae=$s(v).find(Q=>Q.callee.id===(d==null?void 0:d.id));return{ancestor:v,callType:(ae==null?void 0:ae.callType)||"success"}}n.ancestor=v}}if(!n.ancestor){let L=null;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"),{ancestor:E,callType:L||"success"}}return n}function uc(d,p,i=!1){var S;if(!d)throw new Error("findNextSingleCallerAncestor: Target is not defined, cannot find ancestor.");let n=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)&&(n=d.internalCalls.find(X=>!!X.calledBy.length));const l=dn(n,d.project);let c=p||l;if(!c)return{ancestor:null,callType:null};if(c.type===o.Project&&(c=zUe(n).ancestor,!c))return{ancestor:null,callType:null};const e=$s(c);if(!e.find(Z=>Z.callee===n))return{ancestor:null,callType:null};const T=[...n.calledBy];if(!T.length)return{ancestor:null,callType:null};if(T.length===1){const Z=T[0];if(Z.type===o.Loop&&Z.body.calls.includes(n))return{ancestor:Z,callType:"loop-body"};if(zt.includes(Z.type))return Z.type===o.FunctionDeclaration&&Z.parent.type===o.Loop?{ancestor:Z.parent,callType:"loop-body"}:{ancestor:Z,callType:"entry"};if(Vi.includes(Z.type)){if(Z.successCalls.includes(n))return{ancestor:Z,callType:"success"};if(Z.errorCalls.includes(n))return{ancestor:Z,callType:"error"}}}const v=jt.includes(n.type)?[]:Rt(n),E=e.filter(Z=>!(jt.includes(Z.callee.type)||Z.callee===n||!Rt(Z.callee).find(ae=>ae===n)||v.find(ae=>ae===Z.callee)));if(i&&(ie.Logger.log("Flat calls from start point",c.type+" -- "+c.id,e.length,e.map((Z,X)=>X+1+'. "'+se(Z.callee,d.project)+'" '+Z.callee.type+" -- "+Z.callee.id)),ie.Logger.log("----------------------------------------")),i&&(ie.Logger.log("Relevant flat calls from start point",c.type+" -- "+c.id,E.length,E.map((Z,X)=>X+1+'. "'+se(Z.callee,d.project)+'" '+Z.callee.type+" -- "+Z.callee.id)),ie.Logger.log("----------------------------------------")),c.type===o.Loop){if(c.body.calls.includes(n))return{ancestor:c,callType:"loop-body"}}else if(zt.includes(c.type)){if(c.calls.includes(n))return c.type===o.FunctionDeclaration&&c.parent.type===o.Loop?{ancestor:c.parent,callType:"loop-body"}:{ancestor:c,callType:"entry"}}else if(Vi.includes(c.type)){if(d.calledBy.length===1){if(c.successCalls.includes(n))return{ancestor:c,callType:"success"};if(c.errorCalls.includes(n))return{ancestor:c,callType:"error"}}else if(c.successCalls.includes(n)||c.errorCalls.includes(n))return{ancestor:null,callType:null}}const b=E.filter(Z=>{if(Z.callee===n||!Fr.includes(Z.callee.type))return!1;if(!!T.find(oe=>oe===Z.callee))return!0;const ae=Rt(Z.callee),Q=!!ae.find(oe=>oe===n),fe=!!T.every(oe=>ae.find(ce=>ce===oe));return!(!Q||!fe)}).filter((Z,X,ae)=>ae.findIndex(Q=>Q.callee===Z.callee)===X);if(i&&(ie.Logger.log("Remaining calls that reach target",b.length,b.map((Z,X)=>X+1+'. "'+se(Z.callee,d.project)+'" '+Z.callee.type+" -- "+Z.callee.id)),ie.Logger.log("----------------------------------------")),b.length===0)return{ancestor:null,callType:null};const O=b.filter(Z=>{const X=b.filter(ae=>ae!==Z).map(ae=>ae.callee);return zt.includes(Z.callee.type)&&Z.callee.calls.length===1&&X.find(ae=>ae===Z.callee.calls[0])||Vi.includes(Z.callee.type)&&Z.callee.successCalls.length===1&&X.find(ae=>{var Q;return ae.id===((Q=Z.callee.successCalls[0])==null?void 0:Q.id)})?!1:!(Vi.includes(Z.callee.type)&&Z.callee.errorCalls.length===1&&X.find(ae=>{var Q;return ae.id===((Q=Z.callee.errorCalls[0])==null?void 0:Q.id)}))});if(i&&(ie.Logger.log("Reduced single callers",O.length,O.map((Z,X)=>X+1+'. "'+se(Z.callee,d.project)+'" '+Z.callee.type+" -- "+Z.callee.id)),ie.Logger.log("----------------------------------------")),O.length===0)return{ancestor:null,callType:null};if(O.length===1){const Z=O[0];if(Z.callee.type===o.Loop){if(Z.callee.body.calls.includes(n))return{ancestor:Z.callee,callType:"loop-body"}}else{if(zt.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(Vi.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 _=c,$=null,L=O[0].callee,U=O.slice(1);for(;U.length;){const Z=JUe(L,U[0].callee,c);if(((S=Z==null?void 0:Z.ancestor)==null?void 0:S.id)===c.id)return{ancestor:c,callType:Z.callType};Z.ancestor?(_=Z.ancestor,L=Z.ancestor,$=Z.callType,i&&ie.Logger.log('Combined single caller between "'+se(L,n.project)+'" ',L.type+" -- "+L.id,`
|
|
375
375
|
`,'AND "'+se(U[0].callee,n.project)+'" ','-> "'+se(_,n.project)+'" ',(_==null?void 0:_.type)+" -- "+(_==null?void 0:_.id)+" ["+$+`]
|
|
376
376
|
`)):i&&ie.Logger.log('NO combined result "'+se(L,n.project)+'" ',L.type+" -- "+L.id,`
|
|
377
|
-
`,'AND "'+se(U[0].callee,n.project)+'" '),U=U.slice(1)}return{ancestor:_,callType:$}}function oUi(d){if(![...cy,o.OutputMap].includes(d.type))throw new Error(`[getEarliestSingleCallerAncestorOfValueWriterAndItsValueReaders] Entity: ${d.id} - ${se(d,d.project)} - Can only be used with a value writer entity`);let p;if(cy.includes(d.type)?p=d:d.type===o.OutputMap&&(p=d.parent),!p)throw new Error(`[getEarliestSingleCallerAncestorOfValueWriterAndItsValueReaders] Entity: ${d.id} - ${se(d,d.project)} - Can only be used with a value writer entity that has a caller`);const i=D([d,...uA(d),...Ft.includes(d.type)?d.outputs.flatMap(y=>uA(y)):[]]),n=D(i.map(y=>dx(y)).flatMap(y=>jt.includes(y==null?void 0:y.type)?y.calledBy:[y]));if(n.length===1){const y=n[0];if(zt.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] Entity: ${d.id} - ${se(d,d.project)} - Could not be resolved, single caller found, but it is not a valid caller: ${y.id} - ${se(y,p.project)}`)}const l=n.map(y=>{var v;if(zt.includes(y.type))return y.parent.type===o.Loop?{ancestor:y.parent,callType:"loop-body"}:{ancestor:y,callType:"entry"};if(y.parent===d.project&&!((v=p.calledBy)!=null&&v.length)){if(y===p)return{ancestor:y,callType:"success"};const E=gn(y.successCalls),b=gn(y.errorCalls);if(E.includes(p))return{ancestor:y,callType:"success"};if(b.includes(p))return{ancestor:y,callType:"error"}}const T=uc(y);if(!T.ancestor)throw new Error(`[getEarliestSingleCallerAncestorOfValueWriterAndItsValueReaders] Could not be resolved, no ancestor found for entity ${y.id} -- ${se(y,p.project)}`);return T}).filter((y,T,v)=>T===v.findIndex(E=>{var b,O;return((b=E.ancestor)==null?void 0:b.id)===((O=y.ancestor)==null?void 0:O.id)})),c=Sm(p),e=l.filter(y=>y!=null&&y.ancestor?c===y.ancestor?!0:!l.filter(E=>E.ancestor!==y.ancestor).map(E=>E.ancestor).some(E=>{const b=vu(y.ancestor,E);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=>se(y.ancestor,p.project)).join(", ")}`);return{ancestor:e[0].ancestor,callType:e[0].callType}}function YUe(d,p){if(d===p)return!0;if(Rt(d).includes(p)||!Rt(p).includes(d))return!1;const l=d.calledBy;return l.length===0?!1:l.length===1?l[0]===p:WUe(l).length>1&&l.includes(p)?!1:l.every(e=>d===p?!0:zt.includes(e.type)?!1:YUe(e,p))}function XUe(d){const p=[];let i=d.calledBySuccess;i=i.filter(l=>!i.filter(y=>y!==l).some(y=>cA(y,l)));let n=d.calledByError;n=n.filter(l=>!n.filter(y=>y!==l).some(y=>cA(y,l)));for(const l of i)p.push({ancestor:l,callType:"success"});for(const l of n)p.push({ancestor:l,callType:"error"});return p}function QUe(d){const p=[];return XUe(d).forEach(n=>{n.ancestor.type===o.Condition&&p.push({condition:n.ancestor,call:d,callType:n.callType});const c=QUe(n.ancestor).filter(e=>!p.some(y=>y.condition.id===e.condition.id));p.push(...c)}),p}function dx(d){if(!d)return null;if(d.type===o.Condition&&d.parent.type===o.Condition)return Fm(d.parent);if(pC.includes(d.type))return d;const p=d.parent;return p?dx(p):null}function uA(d,p=new Set){return d.writesValues.reduce((i,n)=>p.has(n.id)?i:(p.add(n.id),is.includes(n.type)?[...i,n]:Ar.includes(n.type)?[...i,n,...uA(n,p)]:i),[])}function Om(d){const p=d.calledBy;if(p.length===0)return d.project;const i=p.reduce((n,l)=>{const c=dn(l,d.project);return!c||c.type===o.Project?n:n.type===o.Project||Ry(c,n).last?c:(Ry(n,c).last,n)},d.project);return i.type===o.FunctionDeclaration&&i.parent.type===o.Loop?i.parent:i}function ht(d,p){let i=Om(d);if(d.type===o.InternalCall)if(d.parent.type===o.VariableInstance){const l=es(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&&!yr.includes(i.type)){d.remove({ignoreUpstream:!1},p);return}else if(Ft.includes(d.type)){const l=d.usedInternalCalls[0];if(l)if(i=Om(l),d.type===o.VariableInstance){const c=es(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=es(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(jt.includes(d.type))return;Rt(d).forEach(l=>{let c=Om(l);if(l.type===o.InternalCall)if(l.parent.type===o.VariableInstance){const e=es(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&&!yr.includes(c.type)){l.remove({ignoreUpstream:!1},p);return}else if(Ft.includes(l.type)){const e=l.usedInternalCalls[0];if(e)if(c=Om(e),l.type===o.VariableInstance){const y=es(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=es(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 pA(d,p,i=new Set){const n=Tl(d),l=Tl(p),c=n.filter(T=>!l.includes(T)),e=n.filter(T=>l.includes(T)),y=c.reduce((T,v)=>i.has(v.id)?T:(i.add(v.id),D([...T,...pA(v,p,i)])),[]);return D([...e,...y])}function Ac(d,p){const i=Ry(d,p);return i.last===p&&i.list.length>0&&i.list[0]!==p}function rC(d,p){return!!Ry(d,p).last}function cA(d,p){return!!vu(d,p).last}function ux(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 n=p.parent;if(n){if(n===d)return d;if(n.type===o.Project)return null}else return null;return ux(i,n)}function dUi(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(zr.includes(d.type)&&Fr.includes(p.type)){const y=vu(d,p),T=y.last;if(T){if(T===p)return{ancestor:p,callType:y.callType}}else return{ancestor:null,callType:null}}if(zr.includes(p.type)&&Fr.includes(d.type)){const y=vu(p,d),T=y.last;if(T){if(T===d)return{ancestor:d,callType:y.callType}}else return{ancestor:null,callType:null}}const n=Sm(d),l=Sm(p);if(!n||!l)return{ancestor:null,callType:null};if(n!==l)return{ancestor:null,callType:null};if(n.calls.includes(d)||n.calls.includes(p))return{ancestor:n,callType:"entry"};const c=n.calls.reduce((y,T)=>{if(!Fr.includes(T.type))return y;const v=$s(T),E=v.find(O=>O.callee===d),b=v.find(O=>O.callee===p);return E&&b&&(!i||E.callType===b.callType)?[...y,{ancestor:T,callType:E.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(T=>T.ancestor!==y.ancestor&&vu(y.ancestor,T.ancestor).last===T.ancestor));return e.length===1?{ancestor:e[0].ancestor,callType:e[0].callType}:{ancestor:n,callType:"entry"}}function ki(d){if(Hm.includes(d.type)){if(d.type===o.FunctionDeclaration){const p=d.parent;if(p.type===o.DefinitionEntity)return ki(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?ki(d.parent):d}else{const p=d.parent;return p?ki(p):null}}function py(d,p){const i=oy(d,p);if(!i)return null;if(Hm.includes(i.type)){if(i.type===o.FunctionDeclaration){const n=oy(i.parent,p);if(n){if(n.type===o.DefinitionEntity)return n;if(n.type===o.Loop)return n}}if(i.parent){const n=oy(i.parent,p);if(n&&(i.type===o.DefinitionEntity&&n.type===o.DataType||i.type===o.Condition&&n.type===o.Condition))return py(n,p)}return i}else{const n=i.parent?oy(i.parent,p):null;return n?py(n,p):null}}function $s(d){if(d.type===o.Loop){const p=[...gn(d.successCalls).map(l=>({callee:l,callType:"success"})),...gn(d.errorCalls).map(l=>({callee:l,callType:"error"})),...(d.body?Rt(d.body):[]).map(l=>({callee:l,callType:"loop-body"}))];return D(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(Vi.includes(d.type)){const p=[...gn(d.successCalls).map(l=>({callee:l,callType:"success"})),...gn(d.errorCalls).map(l=>({callee:l,callType:"error"}))];return D(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(zt.includes(d.type)){const p=[...gn(d.calls).map(l=>d.parent.type===o.Loop?{callee:l,callType:"loop-body"}:{callee:l,callType:"entry"})];return D(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 Fm(d){if(!d)return null;if(d.type===o.Condition&&d.parent.type===o.Condition)return Fm(d.parent);if(zr.includes(d.type))return d;const p=d.parent;return p?Fm(p):null}function eje(d){if(!d)return null;if(Vi.includes(d.type))return d;const p=d.parent;return p?eje(p):null}function tje(d){if(!d)return null;if(Fr.includes(d.type))return d;const p=d.parent;return p?tje(p):null}function uUi(d){return d.type===o.VariableDeclaration?[d]:Vi.includes(d.type)?[...d.inputs,...d.outputs||[]]:jt.includes(d.type)?d.outputs:Rc.includes(d.type)||d.type===o.FunctionDeclaration?d.inputs:[]}function pUi(d){const p=Tl(d),i=[],n=[];WU.includes(d.type)&&i.push(...C1(d));const l=p.filter(c=>{const e=i.includes(c);return e?!1:zr.includes(c.type)&&!e?(n.push(c),!1):!0});return i.sort((c,e)=>Ac(e,c)?-1:0),n.sort((c,e)=>Ac(e,c)?-1:0),[...i,...n,...l]}function ije(d){return[...d].sort((p,i)=>Ac(i,p)?-1:0)}function cUi(d){const p=ije(d),i=[];return p.forEach(n=>{const l=i[i.length-1];if(l){const c=l[l.length-1];Ac(n,c)?i.push([n]):l.push(n)}else i.push([n])}),i}function Ao(d){const p=d.map(i=>ki(i));return D(p)}function C1(d){return Vi.includes(d.type)?[...Ao(d.successCalls),...Ao(d.errorCalls)]:zt.includes(d.type)?Ao(d.calls):[]}function fUi(d,p){return C1(d).includes(p)}function _1(d){return d.writesValues||[]}function yUi(d,p){return _1(d).includes(p)}function rje(d){var p;return Ft.includes((p=d==null?void 0:d.readsValue)==null?void 0:p.type)?d.readsValue:null}function hUi(d){return d.writesValues}function nje(d=[]){return d.map(rje).filter(p=>!!p)}function fA(d=[]){return d.map(p=>p.writesValues).flat().filter(p=>Ft.includes(p.type))}function aje(d=[]){return d.map(p=>p.readsValue).filter(p=>!!p&&Ft.includes(p.type))}function sje(d){return Ft.includes(d.type)?d:null}function lje(d){return d.writesValues.map(sje).filter(p=>!!p)}function oje(d=[]){return d.reduce((p,i)=>i.type===o.OutputMap?[...p,...lje(i)]:p,[])}function Rt(d){return d.type===o.Loop?D([...gn(d.successCalls),...gn(d.errorCalls),...d.body?Rt(d.body):[]]):Vi.includes(d.type)?D([...gn(d.successCalls),...gn(d.errorCalls)]):zt.includes(d.type)?D(gn(d.calls)):[]}function mUi(d){return Vi.includes(d.type)?[...gn(d.successCalls),...gn(d.errorCalls)]:zt.includes(d.type)?gn(d.calls):[]}function dje(d,p=new Set){return d.writesValues.filter(n=>Ft.includes(n.type)&&!p.has(n.id)).reduce((n,l)=>p.has(l.id)?n:[...n,...Zi(l,p)],[])}function uje(d,p=new Set){var n;return(((n=d.readsValue)==null?void 0:n.writesValues)||[]).filter(l=>Ft.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 aje(d.outputs).reduce((n,l)=>[...n,...Zi(l,p)],[]);if(d.type===o.FunctionCall||d.type===o.Operation||d.type===o.Condition)return[...Rt(d).reduce((c,e)=>{const y=ki(e);return[...c,...Zi(y||e,p)]},[]),...nje(d.inputs),...oje(d.outputs)].reduce((c,e)=>[...c,...Zi(e,p)],[]);if(Rc.includes(d.type)){const i=fA(d.inputs),l=Rt(d).reduce((c,e)=>{const y=ki(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=[...fA(d.inputs)],l=Rt(d).reduce((c,e)=>{const y=ki(e);return[...c,...Zi(y||e,p)]},[]);return i.push(...l),i.reduce((c,e)=>[...c,...Zi(e)],[])}if(Ft.includes(d.type)){p.add(d.id);const n=Rt(d).reduce((l,c)=>{const e=ki(c);return[...l,...Zi(e||c,p)]},[]);return[d,...n,...uje(d,p),...dje(d,p)]}return[]}function Va(d,p=new Set){if(p.has(d.id))return[];p.add(d.id),ie.Logger.log("[flattenDerivedCanvasEntities]",d.type,se(d,d.project),d.id);const i=Tl(d);return i.forEach(l=>{p.add(l.id)}),[...i.reduce((l,c)=>(ie.Logger.log("[Recursive -- flattenDerivedCanvasEntities]",c.type,se(c,c.project),c.id),[...l,c,...Va(c,p)]),[])]}function gn(d){return d.reduce((p,i)=>i.type===o.ReturnStatement||i.type===o.ContinueStatement||i.type===o.BreakStatement?[...p,i]:[...p,i,...Rt(i)],[])}function pje(d){const p=d.entities||[],i=[...p,...d.functions||[],...d.events||[],...d.projects||[]],n=p.reduce((T,v)=>[...T,...v.properties],[]),l=p.reduce((T,v)=>[...T,...v.methods],[]),c=l.reduce((T,v)=>[...T,...fA(v.inputs),...gn(Ao(v.calls)),...v.returnStatements],[]),e=d.functions.reduce((T,v)=>[...T,...gn(Ao(v.calls)),...v.returnStatements],[]),y=d.events.reduce((T,v)=>[...T,...gn(Ao(v.calls)),...v.returnStatements],[]);return[...i,...n,...l,...c,...e,...y]}function cje(d,p){return p.filter(n=>{if(!n)return!1;switch(n.type){case o.FunctionCall:return n.inputs.find(l=>l.id===d.id)!==void 0||n.outputs.find(l=>l.id===d.id)!==void 0;case o.Condition:return n.successCalls.find(l=>l.id===d.id)!==void 0||n.errorCalls.find(l=>l.id===d.id)!==void 0||n.inputs.find(l=>l.id===d.id)!==void 0;case o.Operation:return n.outputs.find(l=>l.id===d.id)!==void 0;case o.VariableDeclaration:return Vi.includes(d.type)?yje(d).find(c=>{var e;return((e=c.readsValue)==null?void 0:e.id)===n.id})!==void 0:!1;case o.DefinitionEntity:return n.properties.find(l=>l.id===d.id)!==void 0||n.methods.find(l=>l.id===d.id)!==void 0;case o.FunctionDeclaration:return n.inputs.find(l=>l.id===d.id)!==void 0||(n.returnStatements.map(l=>l.outputs).flat()||[]).find(l=>l.id===d.id)!==void 0;default:return!1}})}function TUi(d){const p=pje(d.project);return cje(d,p)}function oy(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 px(d={},p){const i={};return Object.keys(d).forEach(n=>{const l=p.get(n)||n,c=d[n];i[l]=c}),i}function ld(d,p={},i={}){const n={ignoreBuiltInBaseEntities:!1,allBuiltInEntityIds:[],entityMaps:new Map,...i};if(n.ignoreBuiltInBaseEntities&&(ea.includes(d.type)||(n.allBuiltInEntityIds||[]).includes(d.id)))return{upstream:{},downstream:{}};const l=d,c=d,e=d,y=d,T=d,v=d,E=d,b=d,O=d,_=d,$=d,L=d,U=d,S=[...U.readsValue?[U.readsValue]:[],...U.declaration?[U.declaration]:[],...(L.calledByEntry||[]).flatMap(Q=>Q),...(L.calledBySuccess||[]).flatMap(Q=>Q),...(L.calledByError||[]).flatMap(Q=>Q),..._.parent?[_.parent]:[],...c.foreignKeyRef?[c.foreignKeyRef]:[]];Array.isArray(e.implements)?S.push(...e.implements.flatMap(Q=>Q)):y.implements&&S.push(y.implements),Array.isArray(e.extends)?S.push(...e.extends.flatMap(Q=>Q)):O.extends&&S.push(O.extends),T.valueAsTypeList&&Array.isArray(T.valueAsTypeList)&&S.push(...T.valueAsTypeList.flatMap(Q=>Q)),T.valueAsTypeSingle&&S.push(T.valueAsTypeSingle),(U.internalCalls||[]).forEach(Q=>{const fe=pe(Q);if(fe&&p[fe]){const oe=p[fe];[...oe.calledByEntry||[],...oe.calledBySuccess||[],...oe.calledByError||[]].forEach(ce=>{const me=pe(ce);me&&p[me]&&S.push(p[me])})}});const Z=[...(l.inputs||[]).flatMap(Q=>Q),...($.inputsDeclarations||[]).flatMap(Q=>Q),...($.outputs||[]).flatMap(Q=>Q),...(U.internalCalls||[]).flatMap(Q=>Q),...U.writesValues||[],...L.dataType?[L.dataType]:[],...v.body?[v.body]:[],...L.defaultValue?[L.defaultValue]:[],...(L.successCalls||[]).flatMap(Q=>Q),...(L.errorCalls||[]).flatMap(Q=>Q),...(e.properties||[]).flatMap(Q=>Q),...(e.methods||[]).flatMap(Q=>Q),...(e.abstractMethods||[]).flatMap(Q=>Q),...E.error?[E.error]:[],..._.throws?[_.throws]:[],...(c.andChildrenGroup||[]).flatMap(Q=>Q),...(c.orChildrenGroup||[]).flatMap(Q=>Q),...(b.entities||[]).flatMap(Q=>Q),...(b.functions||[]).flatMap(Q=>Q),...(b.functionCalls||[]).flatMap(Q=>Q),...(b.events||[]).flatMap(Q=>Q),...(b.conditions||[]).flatMap(Q=>Q),...(b.operations||[]).flatMap(Q=>Q),...(b.loops||[]).flatMap(Q=>Q),...(b.variableDeclarations||[]).flatMap(Q=>Q),...(b.variableInstances||[]).flatMap(Q=>Q),...(b.searches||[]).flatMap(Q=>Q),...(b.projects||[]).flatMap(Q=>Q),...(y.calls||[]).flatMap(Q=>Q)];d.type===o.DataType&&(c.entity&&p[pe(c.entity)]&&p[pe(c.entity)].parent&&pe(p[pe(c.entity)].parent)===d.id?Z.push(c.entity):c.entity&&S.push(c.entity)),(U.internalCalls||[]).forEach(Q=>{const fe=pe(Q);if(fe&&p[fe]){const oe=p[fe];[...oe.successCalls||[],...oe.errorCalls||[]].forEach(ce=>{const me=pe(ce);me&&p[me]&&Z.push(p[me])})}});const X={},ae={};return S.forEach(Q=>{var ce;const fe=pe(Q);if(fe&&n.ignoreBuiltInBaseEntities&&(ea.includes(Q.type)||(n.allBuiltInEntityIds||[]).includes(fe)))return;const oe=Q.version;if(fe){const me=((ce=n.entityMaps)==null?void 0:ce.get(fe))||fe;X[me]=oe}}),Z.forEach(Q=>{var ce;const fe=pe(Q);if(fe&&n.ignoreBuiltInBaseEntities&&(ea.includes(Q.type)||(n.allBuiltInEntityIds||[]).includes(fe)))return;const oe=Q.version;if(fe){const me=((ce=n.entityMaps)==null?void 0:ce.get(fe))||fe;ae[me]=oe}}),{upstream:X,downstream:ae}}function vUi(d,p){const i=[];if(zr.includes(d.type)){gs(d).forEach(c=>{const e=py(c,p);e&&i.push(e)});const l=[...d.inputs||[],...d.outputs||[]].map(c=>{const e=oy(c,p);return e?hje(e,p):null}).filter(c=>c!==null);i.push(...D(l))}if(Ft.includes(d.type)){const n=yA(d);n&&i.push(n)}return D(i)}function Mp(d){const p=[];if(zr.includes(d.type)){d.calledBy.forEach(l=>{const c=ki(l);c&&p.push(c)});const n=[...d.inputs||[],...d.outputs||[]].map(l=>yA(l)).filter(l=>l!==null);p.push(...D(n))}if(is.includes(d.type)){const i=yA(d);i&&p.push(i)}return D(p)}function gs(d){return[...d.calledByEntry||[],...d.calledByError||[],...d.calledBySuccess||[]].filter(p=>p.type!==o.GenericReference)}function cx(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(n=>Ne(n,p,i)),...d.dataType?Ne(d.dataType,p,i):[],...d.error?Ne(d.error,p,i):[],...d.parent?Ne(d.parent,p,i):[]]}function fx(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(n=>Ne(n,p,i)),...d.dataType?Ne(d.dataType,p,i):[],...d.parent?Ne(d.parent,p,i):[]]}function yx(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(n=>Ne(n,p,i)),...d.throws?Ne(d.throws,p,i):[],...d.dataType?Ne(d.dataType,p,i):[],...d.readsValue?Ne(d.readsValue,p,i):[],...(gs(d)||[]).flatMap(n=>Ne(n,p,i)),...d.parent?Ne(d.parent,p,i):[]]}function hx(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(n=>Ne(n,p,i)),...(d.methods||[]).flatMap(n=>Ne(n,p,i)),...(d.abstractMethods||[]).flatMap(n=>Ne(n,p,i)),...d.allPropertiesImplement?Ne(d.allPropertiesImplement,p,i):[],...d.additionalPropertiesDataType?Ne(d.additionalPropertiesDataType,p,i):[],...d.extends?Ne(d.extends,p,i):[]]}function mx(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(n=>Ne(n,p,i)),...(d.orChildrenGroup||[]).flatMap(n=>Ne(n,p,i)),...(d.inputs||[]).flatMap(n=>Ne(n,p,i)),...(d.successCalls||[]).flatMap(n=>Ne(n,p,i)),...(d.errorCalls||[]).flatMap(n=>Ne(n,p,i)),...(gs(d)||[]).flatMap(n=>Ne(n,p,i)),...d.parent?Ne(d.parent,p,i):[]]}function Tx(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(n=>Ne(n,p,i)),...d.readsValue?Ne(d.readsValue,p,i):[],...d.throws?Ne(d.throws,p,i):[],...d.dataType?Ne(d.dataType,p,i):[],...(gs(d)||[]).flatMap(n=>Ne(n,p,i)),...d.parent?Ne(d.parent,p,i):[]]}function vx(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(n=>Ne(n,p,i)),...(d.properties||[]).flatMap(n=>Ne(n,p,i)),...(d.methods||[]).flatMap(n=>Ne(n,p,i)),...(d.abstractMethods||[]).flatMap(n=>Ne(n,p,i)),...d.allPropertiesImplement?Ne(d.allPropertiesImplement,p,i):[],...d.additionalPropertiesDataType?Ne(d.additionalPropertiesDataType,p,i):[],...d.parent?Ne(d.parent,p,i):[]]}function Ex(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(n=>Ne(n,p,i)),...(d.orChildrenGroup||[]).flatMap(n=>Ne(n,p,i)),...d.entity?Ne(d.entity,p,i):[],...d.foreignKeyRef?Ne(d.foreignKeyRef,p,i):[],...d.parent?Ne(d.parent,p,i):[]]}function bx(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(n=>Ne(n,p,i)),...(d.outputs||[]).flatMap(n=>Ne(n,p,i)),...d.error?Ne(d.error,p,i):[],...(gs(d)||[]).flatMap(n=>Ne(n,p,i)),...(d.successCalls||[]).flatMap(n=>Ne(n,p,i)),...(d.errorCalls||[]).flatMap(n=>Ne(n,p,i)),...(d.writesValues||[]).flatMap(n=>Ne(n,p,i)),...d.parent?Ne(d.parent,p,i):[]]}function Ax(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(n=>Ne(n,p,i)),...(d.calls||[]).flatMap(n=>Ne(n,p,i)),...d.dataType?Ne(d.dataType,p,i):[],...d.implements?Ne(d.implements,p,i):[],...d.parent?Ne(d.parent,p,i):[]]}function gx(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(n=>Ne(n,p,i)),...(d.calls||[]).flatMap(n=>Ne(n,p,i)),...d.implements?Ne(d.implements,p,i):[],...d.parent?Ne(d.parent,p,i):[]]}function Ix(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 Rx(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(n=>Ne(n,p,i)),...(d.events||[]).flatMap(n=>Ne(n,p,i)),...d.parent?Ne(d.parent,p,i):[]]}function Dx(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(n=>Ne(n,p,i)),...(d.errorCalls||[]).flatMap(n=>Ne(n,p,i)),...(d.inputs||[]).flatMap(n=>Ne(n,p,i)),...(d.outputs||[]).flatMap(n=>Ne(n,p,i)),...(gs(d)||[]).flatMap(n=>Ne(n,p,i)),...d.error?Ne(d.error,p,i):[],...(d.writesValues||[]).flatMap(n=>Ne(n,p,i)),...d.parent?Ne(d.parent,p,i):[]]}function Ox(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(n=>Ne(n,p,i)):[],...d.parent?Ne(d.parent,p,i):[]]}function wx(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(n=>Ne(n,p,i)),...(d.outputs||[]).flatMap(n=>Ne(n,p,i)),...(d.successCalls||[]).flatMap(n=>Ne(n,p,i)),...(d.errorCalls||[]).flatMap(n=>Ne(n,p,i)),...d.error?Ne(d.error,p,i):[],...d.dataType?Ne(d.dataType,p,i):[],...d.body?Ne(d.body,p,i):[],...(gs(d)||[]).flatMap(n=>Ne(n,p,i)),...(d.writesValues||[]).flatMap(n=>Ne(n,p,i)),...d.parent?Ne(d.parent,p,i):[]]}function Cx(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(n=>Ne(n,p,i)),...(d.errorCalls||[]).flatMap(n=>Ne(n,p,i)),...(d.inputs||[]).flatMap(n=>Ne(n,p,i)),...(d.outputs||[]).flatMap(n=>Ne(n,p,i)),...(d.writesValues||[]).flatMap(n=>Ne(n,p,i)),...d.error?Ne(d.error,p,i):[],...(gs(d)||[]).flatMap(n=>Ne(n,p,i)),...d.parent?Ne(d.parent,p,i):[]]}function _x(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(n=>Ne(n,p,i)),...d.declaration?Ne(d.declaration,p,i):[],...d.parent?Ne(d.parent,p,i):[]]}function Px(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(n=>Ne(n,p,i)),...(d.methods||[]).flatMap(n=>Ne(n,p,i)),...(d.abstractMethods||[]).flatMap(n=>Ne(n,p,i))]}function Vx(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(n=>Ne(n,p,i)),...(d.functions||[]).flatMap(n=>Ne(n,p,i)),...(d.events||[]).flatMap(n=>Ne(n,p,i)),...(d.projects||[]).flatMap(n=>Ne(n,p,i)),...(d.variableDeclarations||[]).flatMap(n=>Ne(n,p,i)),...(d.variableInstances||[]).flatMap(n=>Ne(n,p,i)),...(d.operations||[]).flatMap(n=>Ne(n,p,i)),...(d.conditions||[]).flatMap(n=>Ne(n,p,i)),...(d.functionCalls||[]).flatMap(n=>Ne(n,p,i)),...(d.projects||[]).flatMap(n=>Ne(n,p,i)),...(d.loops||[]).flatMap(n=>Ne(n,p,i)),...(d.searches||[]).flatMap(n=>Ne(n,p,i))]}function Nx(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 xx(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(n=>Ne(n,p,i)),...d.throws?Ne(d.throws,p,i):[],...d.readsValue?Ne(d.readsValue,p,i):[],...d.dataType?Ne(d.dataType,p,i):[],...(gs(d)||[]).flatMap(n=>Ne(n,p,i)),...d.parent?Ne(d.parent,p,i):[]]}function $x(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(n=>Ne(n,p,i)),...(d.errorCalls||[]).flatMap(n=>Ne(n,p,i)),...(d.inputsDeclarations||[]).flatMap(n=>Ne(n,p,i)),...(d.inputs||[]).flatMap(n=>Ne(n,p,i)),...(d.writesValues||[]).flatMap(n=>Ne(n,p,i)),...(d.outputs||[]).flatMap(n=>Ne(n,p,i)),...d.error?Ne(d.error,p,i):[],...d.dataType?Ne(d.dataType,p,i):[],...(gs(d)||[]).flatMap(n=>Ne(n,p,i)),...d.parent?Ne(d.parent,p,i):[]]}function Lx(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 Mx(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(n=>Ne(n,p,i)),...(d.errorCalls||[]).flatMap(n=>Ne(n,p,i)),...(d.inputs||[]).flatMap(n=>Ne(n,p,i)),...(d.outputs||[]).flatMap(n=>Ne(n,p,i)),...(d.internalCalls||[]).flatMap(n=>Ne(n,p,i)),...(d.writesValues||[]).flatMap(n=>Ne(n,p,i)),...d.readsValue?Ne(d.readsValue,p,i):[],...d.defaultValue?Ne(d.defaultValue,p,i):[],...(gs(d)||[]).flatMap(n=>Ne(n,p,i)),...d.dataType?Ne(d.dataType,p,i):[],...d.parent?Ne(d.parent,p,i):[]]}function Bx(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(n=>Ne(n,p,i)),...(d.errorCalls||[]).flatMap(n=>Ne(n,p,i)),...(d.inputs||[]).flatMap(n=>Ne(n,p,i)),...(d.outputs||[]).flatMap(n=>Ne(n,p,i)),...(d.internalCalls||[]).flatMap(n=>Ne(n,p,i)),...(d.writesValues||[]).flatMap(n=>Ne(n,p,i)),...d.readsValue?Ne(d.readsValue,p,i):[],...d.defaultValue?Ne(d.defaultValue,p,i):[],...(gs(d)||[]).flatMap(n=>Ne(n,p,i)),...d.declaration?Ne(d.declaration,p,i):[],...d.parent?Ne(d.parent,p,i):[]]}function Yi(){const d=new Set;return pOe.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&&(ea.includes(d.type)||Yi().includes(d.id)))return[];if(p.has(d.id))return[];switch(d.type){case o.FunctionCall:return bx(d,p,i);case o.Operation:return Cx(d,p,i);case o.Condition:return mx(d,p,i);case o.Loop:return wx(d,p,i);case o.Search:return $x(d,p,i);case o.GlobalEvent:return gx(d,p,i);case o.ReturnStatement:return xx(d,p,i);case o.ContinueStatement:return Tx(d,p,i);case o.BreakStatement:return yx(d,p,i);case o.VariableDeclaration:return Mx(d,p,i);case o.DefinitionEntity:return vx(d,p,i);case o.FunctionDeclaration:return Ax(d,p,i);case o.Project:return Vx(d,p,i);case o.ActionDescriptor:return cx(d,p,i);case o.ArgumentDeclaration:return fx(d,p,i);case o.ValueDescriptor:return Lx(d,p,i);case o.InputMap:return Ix(d,p,i);case o.OutputMap:return _x(d,p,i);case o.DataType:return Ex(d,p,i);case o.InstalledProject:return Rx(d,p,i);case o.InternalCall:return Dx(d,p,i);case o.LiteralValue:return Ox(d,p,i);case o.Property:return Nx(d,p,i);case o.VariableInstance:return Bx(d,p,i);case o.BuiltInBaseEntity:return i.ignoreBuiltInBaseEntities?[]:hx(d,p,i);case o.PrimitiveEntity:return i.ignoreBuiltInBaseEntities?[]:Px(d,p,i)}return[]}async function fje(d,p=new Set,i={ignoreBuiltInBaseEntities:!1,yieldEvery:100}){const n={ignoreBuiltInBaseEntities:i.ignoreBuiltInBaseEntities??!1,yieldEvery:i.yieldEvery??100};if(!d)throw new Error("Entity must be defined to be flattened");if(d.type===o.GenericReference)return[];if(n.ignoreBuiltInBaseEntities&&(ea.includes(d.type)||Yi().includes(d.id)))return[];if(p.has(d.id))return[];switch(d.type){case o.FunctionCall:return bx(d,p,n);case o.Operation:return Cx(d,p,n);case o.Condition:return mx(d,p,n);case o.Loop:return wx(d,p,n);case o.Search:return $x(d,p,n);case o.GlobalEvent:return gx(d,p,n);case o.ReturnStatement:return xx(d,p,n);case o.ContinueStatement:return Tx(d,p,n);case o.BreakStatement:return yx(d,p,n);case o.VariableDeclaration:return Mx(d,p,n);case o.DefinitionEntity:return vx(d,p,n);case o.FunctionDeclaration:return Ax(d,p,n);case o.Project:return Vx(d,p,n);case o.ActionDescriptor:return cx(d,p,n);case o.ArgumentDeclaration:return fx(d,p,n);case o.ValueDescriptor:return Lx(d,p,n);case o.InputMap:return Ix(d,p,n);case o.OutputMap:return _x(d,p,n);case o.DataType:return Ex(d,p,n);case o.InstalledProject:return Rx(d,p,n);case o.InternalCall:return Dx(d,p,n);case o.LiteralValue:return Ox(d,p,n);case o.Property:return Nx(d,p,n);case o.VariableInstance:return Bx(d,p,n);case o.BuiltInBaseEntity:return n.ignoreBuiltInBaseEntities?[]:hx(d,p,n);case o.PrimitiveEntity:return n.ignoreBuiltInBaseEntities?[]:Px(d,p,n)}return[]}function Gx(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||Rc.includes(d.type)?d.inputs:d.type===o.Search?d.inputsDeclarations:[]}function EUi(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 yje(d){return Vi.includes(d.type)?d.inputs:[]}function bUi(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 jt.includes(d.type)?d.outputs.map(i=>i.declaration).filter(i=>!!i)||[]:[]}function AUi(d,p){return p.type===o.Condition?null:(p.type===o.FunctionCall||p.type===o.Operation)&&p.outputs.find(i=>{var n;return((n=i.declaration)==null?void 0:n.id)===d.id})||null}function gUi(d){return d.type===o.Condition?[]:Vi.includes(d.type)?d.outputs:[]}function yA(d){const p=d.readsValue;return p?ki(p):null}function hje(d,p){const i=d.readsValue;return i?py(i,p):null}function mje(d){const p=d.internalCalls||[];return D(Ao(D(p.flatMap(i=>[...i.successCalls,...i.errorCalls]))))}function Tje(d){const p=d.internalCalls||[];return D(D(p.flatMap(i=>[...i.successCalls,...i.errorCalls])))}function ry(d){const p=_1(d),i=[];return p.forEach(n=>{if(Hm.includes(n.type))i.push(n);else if(is.includes(n.type)){const l=ki(n.parent);i.push(l)}}),i}function ny(d){const p=_1(d),i=[];return p.forEach(n=>{if([...Ft,...jt].includes(n.type))i.push(n);else if(is.includes(n.type)){const l=n.parent;i.push(l)}}),i}function D(d){const p=new Set;return d.filter(i=>!i||p.has(i.id)?!1:(p.add(i.id),!0))}function vje(d){return d.type===o.Project?null:pC.includes(d.type)?d:ea.includes(d.type)?null:d.parent?vje(d.parent):null}function Tl(d,p=!1){ie.Logger.log("[getRelatedCanvasElementsOnTheRight]",d.type,se(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)||[]),yr.includes(d.type)&&i.push(...(d==null?void 0:d.detachedChildren)||[]),d.type===o.DefinitionEntity){const n=[...d.suggestedMethods,...d.methods].flatMap(l=>l.collapsed&&p?[]:(ie.Logger.log("[Recursive -- getRelatedCanvasElementsOnTheRight]",l.type,se(l,l.project),l.id),Tl(l,p)));i.push(...n)}if(d.type===o.Condition){const n=d.successCalls.map(c=>ki(c)),l=d.errorCalls.map(c=>ki(c));i.push(...n,...l)}if(Rc.includes(d.type)){if(d.collapsed&&p)return[];const n=d.inputs.map(c=>ry(c)).flat(),l=d.calls.map(c=>ki(c));i.push(...D(n),...l)}if(Vi.includes(d.type)&&d.type!==o.Condition&&d.type!==o.Loop){const n=d==null?void 0:d.outputs.map(e=>ry(e)).flat(),l=d.successCalls.map(e=>ki(e)),c=d.errorCalls.map(e=>ki(e));i.push(...D(n),...l,...c)}if(Ft.includes(d.type)){const n=ry(d),l=mje(d);i.push(...n,...l)}if(Ar.includes(d.type)){const n=ry(d);i.push(...n)}if(d.type===o.Loop){if(d.body){const c=Tl(d.body,p);i.push(...c)}const n=d.errorCalls.map(c=>ki(c)),l=d.successCalls.map(c=>ki(c));i.push(...l,...n)}if(d.type===o.FunctionDeclaration){if(d.collapsed&&p)return[];const n=d.inputs.map(c=>ry(c)).flat(),l=d.calls.map(c=>ki(c));i.push(...D(n),...l)}return D(i)}function hA(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)||[]),yr.includes(d.type)&&i.push(...(d==null?void 0:d.detachedChildren)||[]),d.type===o.DefinitionEntity){const n=[...d.suggestedMethods,...d.methods].flatMap(l=>l.collapsed&&p?[]:hA(l));i.push(...n)}if(d.type===o.Condition){const n=d.successCalls,l=d.errorCalls;i.push(...n,...l)}if(Rc.includes(d.type)){if(d.collapsed&&p)return[];const n=d.inputs.map(c=>ny(c)).flat(),l=d.calls;i.push(...D(n),...l)}if(Vi.includes(d.type)&&d.type!==o.Condition&&d.type!==o.Loop){const n=d==null?void 0:d.outputs.map(e=>ny(e)).flat(),l=d.successCalls,c=d.errorCalls;i.push(...D(n),...l,...c)}if(Ft.includes(d.type)){const n=ny(d),l=Tje(d);i.push(...n,...l)}if(d.type===o.Loop){const n=d.outputs.map(e=>ny(e)).flat();if(d.body){const e=hA(d.body,p);i.push(...e)}const l=d.errorCalls,c=d.successCalls;i.push(...D(n),...c,...l)}if(d.type===o.FunctionDeclaration){if(d.collapsed&&p)return[];const n=d.inputs.map(c=>ny(c)).flat(),l=d.calls;i.push(...D(n),...l)}return D(i)}function mA(d,p=!1){const i=Tl(d,p),n=[...i,...i.reduce((l,c)=>[...l,...mA(c,p)],[])];return D(n)}function Eje(d,p=!1){const i=hA(d,p),n=[...i,...i.reduce((l,c)=>[...l,...Eje(c,p)],[])];return D(n)}function Vv(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,...Vv(i),...Mu(i)]:(i==null?void 0:i.type)===o.BuiltInBaseEntity?[i==null?void 0:i.name,...Mu(i)]:[...p],[])}function Mu(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,...Mu(d.extends),...Vv(d.extends)];if(d.extends.type===o.BuiltInBaseEntity)return[d.extends.name,...Mu(d.extends)]}return[]}function qm(d){var p,i;return d.extends?((p=d.extends)==null?void 0:p.type)===o.DefinitionEntity?[d.extends,...qm(d.extends),...Ux(d.extends)]:((i=d.extends)==null?void 0:i.type)===o.BuiltInBaseEntity?[d.extends,...qm(d.extends)]:[]:[]}function Ux(d){return d.implements.reduce((p,i)=>i.type===o.DefinitionEntity?[...p,i,...Ux(i),...qm(i)]:(i==null?void 0:i.type)===o.BuiltInBaseEntity?[i,...qm(i)]:[...p,i],[])}function Dy(d){return[...Mu(d),...Vv(d)].filter((i,n,l)=>l.indexOf(i)===n)}function Ki(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||[...Mu(d)].includes(p)):!!Dy(d).includes(p)}function bje(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(Ki(d,p))return d;if(d.extends&&d.extends.type!==o.PrimitiveEntity){if(Ki(d.extends,p))return d.extends;if(d.extends.type===o.BuiltInBaseEntity)return sd(d.extends,p)}return null}if(d.extends)return Ki(d.extends,p)?d.extends:sd(d.extends,p);if(d.implements.length>0){for(const i of d.implements)if(i.type===o.BuiltInBaseEntity){if(Ki(i,p))return i;const n=sd(i,p);if(n)return n}else if(i.type===o.DefinitionEntity){const n=sd(i,p);if(n)return n}}return null}function sd(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 sd(d.extends,p)}return null}if(d.extends)return d.extends.name===p?d.extends:sd(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 n=sd(i,p);if(n)return n}else if(i.type===o.DefinitionEntity){const n=sd(i,p);if(n)return n}}return null}function Aje(d){const p=Mp(d),i=[...p,...p.reduce((n,l)=>[...n,...Aje(l)],[])];return D(i)}function jx(d){return d.implements.length===0&&!d.extends?null:d.implements.find(n=>n.type===o.BuiltInBaseEntity&&n.name===Re.PERSISTED_ENTITY)?d:[...d.implements,...d.extends?[d.extends]:[]].reduce((n,l)=>{if(l.type===o.DefinitionEntity){const c=jx(l);if(c)return c}return n},null)}function IUi(d){return d.extends&&d.extends.type===o.BuiltInBaseEntity?d.extends:null}function RUi(d){const p=d.implements.find(i=>i.type===o.BuiltInBaseEntity);return p&&p.type===o.BuiltInBaseEntity?p:null}function P1(d){return d.extends&&d.extends.type===o.DefinitionEntity?d.extends:null}function Fn(d){const p=[...d.implements||[],...d.extends?[d.extends]:[]].reduce((i,n)=>n.type===o.BuiltInBaseEntity?[...i,n,...Fn(n)]:n.type===o.DefinitionEntity?[...i,...Fn(n)]:i,[]);return D(p)}function sf(d){var p;if(d.type===o.PrimitiveEntity)return!0;if(d.type===o.BuiltInBaseEntity)return d.interactive;if(d.type===o.DefinitionEntity)return!Fn(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 sf(d.declaration);return!0}function DUi(d){return[o.DefinitionEntity,o.BuiltInBaseEntity,o.PrimitiveEntity,o.Property,o.InputMap,o.OutputMap].includes(d.type)?sf(d):!0}function OUi(d){return d.parent===d.project&&d.project.variableDeclarations.includes(d)}function kx(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 gje(d){if([...zt,o.DefinitionEntity,o.InstalledProject,o.Project].includes(d.type)||kx(d))return!1;const p=Mp(d);return p.length===0?!0:p.some(i=>gje(i))}function Kx(d){return[...zt,o.DefinitionEntity,o.InstalledProject,o.Project].includes(d.type)||kx(d)?!1:Mp(d).length===0}function Ije(d,p=0){if(Kx(d)){const i=Mp(d);return i.length===0?d:i.map(l=>Ije(l,p+1)).reduce((l,c)=>l?c&&c.x<l.x?c:l:c,null)}return null}function Rje(d){const p=[];if(Kx(d))p.push(d);else return[];return Mp(d).forEach(n=>{p.push(...Rje(n))}),p}function Sx(d){return d.type===o.FunctionDeclaration&&d.parent!==d.project&&!![o.DefinitionEntity,o.Loop,o.InstalledProject].includes(d.parent.type)}function wUi(d,p){const i=new Map;return d.forEach(n=>{i.set(n.id,n)}),p.forEach(n=>{i.set(n.id,n)}),Array.from(i.values())}function Sh(d){switch(d){case o.DefinitionEntity:return ls;case o.FunctionDeclaration:return Ro;case o.VariableDeclaration:return wu;case o.VariableInstance:return Ou;case o.FunctionCall:return Lu;case o.Operation:return Au;case o.Condition:return Ru;case o.ReturnStatement:return ud;case o.Loop:return Iu;case o.Search:return Cu;case o.InputMap:return ss;case o.OutputMap:return El;case o.ArgumentDeclaration:return ya;case o.Property:return Ma;case o.InstalledProject:return _u;case o.Project:return x;case o.DataType:return lr;case o.GlobalEvent:return gu;case o.InternalCall:return Pu;case o.ValueDescriptor:return pd;case o.BuiltInBaseEntity:return Do;case o.PrimitiveEntity:return pa;case o.ActionDescriptor:return Pi;case o.LiteralValue:return Jr;case o.ContinueStatement:return Nu;case o.BreakStatement:return Vu;default:return null}}function dn(d,p,i=null){const n=d!=null&&d.parent?pe(d==null?void 0:d.parent):null;let l=n?p.get(n):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 en(d,p,c);if(d.type===o.FunctionDeclaration&&(l==null?void 0:l.type)===o.Loop)return l;if(zt.includes(d.type))return d;if(d.type===o.Loop)return c.id===d.id?l:d;if(ea.includes(d.type))return null;const e=d.parent;if(!e)return null;if(e.type===o.GenericReference){const y=pe(e);if(!y)return null;const T=p.get(y);return T?dn(T,p,c):null}else return e===p?p:dn(e,p,c)}function en(d,p,i=null){const n=d!=null&&d.parent?pe(d==null?void 0:d.parent):null;let l=n?p.get(n):null,c=i||d;if(d.type===o.FunctionDeclaration&&(l==null?void 0:l.type)===o.Loop)return en(l.parent,p,c);if(zt.includes(d.type))return d;if(ea.includes(d.type))return null;const e=d.parent;if(!e)return null;if(e.type===o.GenericReference){const y=pe(e);if(!y)return null;const T=p.get(y);return T?en(T,p,c):null}else return e===p?p:en(e,p,c)}function cd(d,p){if(ea.includes(d.type))return ie.Logger.warn(`getRootEntryPointScopeOwner is \`null\` because it was called with a built-in entity type: ${d.type}`),null;if(p.getBuiltIn(d.id))return ie.Logger.warn(`getRootEntryPointScopeOwner is \`null\` because it was called with a built-in entity: ${d.id}`),null;const i=Sn(d.parent,p);return i?i===p?yr.includes(d.type)?d:(ie.Logger.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:cd(i,p):(ie.Logger.warn(`getRootEntryPointScopeOwner is \`null\` because it was called with an entity that has no parent: ${d.id}`),null)}function dy(d,p,i){if(d===p||p===i||d===i||!d||!p)return!1;const n=dn(p.parent,i);return n===i?!1:n===d?!0:dy(n,p,i)}var TA=(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))(TA||{});function es(d,p,i){if(!d)throw new Error("[checkScopeCompatibility] No entityA provided for scope compatibility check");if(!p)throw new Error("[checkScopeCompatibility] No entityB provided for scope compatibility check");if(yr.includes(d.type)&&yr.includes(p.type)){if(dy(d,p,i))return{compatible:!0,type:"b-in-a",commonAncestorScope:d};if(dy(p,d,i))return{compatible:!0,type:"a-in-b",commonAncestorScope:p}}const n=dn(d,i),l=dn(p,i);if((d==null?void 0:d.id)===(l==null?void 0:l.id))return{compatible:!0,type:"b-in-a",commonAncestorScope:d};if((p==null?void 0:p.id)===(n==null?void 0:n.id))return{compatible:!0,type:"a-in-b",commonAncestorScope:p};if(!n)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(n===l&&n.type!==o.Project)return{compatible:!0,type:"same-both-local",commonAncestorScope:n};if(n===l&&n.type===o.Project)return{compatible:!0,type:"same-both-global",commonAncestorScope:n};if(dy(n,l,i))return{compatible:!0,type:"b-in-a",commonAncestorScope:n};if(dy(l,n,i))return{compatible:!0,type:"a-in-b",commonAncestorScope:l};if(n.type===o.Project&&l.type!==o.Project)return{compatible:!1,type:"a-is-global-b-is-not",commonAncestorScope:n};if(n.type!==o.Project&&l.type===o.Project)return{compatible:!1,type:"b-is-global-a-is-not",commonAncestorScope:l};const y=ux(n,l);return y===i?{compatible:!1,type:"parallel-in-project",commonAncestorScope:y}:y?{compatible:!1,type:"parallel-in-common-parent",commonAncestorScope:dn(y,i)}:{compatible:!1,type:"parallel-in-project",commonAncestorScope:i}}function Dje(d,p,i){const n=es(d,p,i);if(!n.compatible||n.type!=="same-both-local")return null;if(d===p)return d;let l=dn(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=dn(l.parent,i)}let c=dn(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=dn(c.parent,i)}return null}function Oje(d){return d.length===0?null:d.length===1?d[0]:d.reduce((i,n)=>{const l=Dje(i,n,n.project);return!l||l===n?i:n},d[0])}function Sn(d,p){if(!d)return null;let i;return typeof d=="string"?i=d:d.type===o.GenericReference?i=pe(d):i=d.id,i===p.id?p:p.get(i)}function Bu(d){if(!d)return null;if(ea.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:Bu(p)}function Vm(d){const p=[];function i(c,e){return p.some(y=>y.blockedByCaller===c&&y.blockedByCalling===e)}function n(c,e){i(c,e)||p.push({blockedByCaller:c,blockedByCalling:e})}const l=cd(d,d.project);return l?(d.calledBySuccess.forEach(c=>{[...c.successCalls||[]].forEach(T=>{jt.includes(T.type)&&T.id!==d.id&&(Rt(d).find(b=>b===T)||n(c,T))});let y;if(Vi.includes(c.type)&&(y=c),y){const T=Vm(y);T.reachable||Rt(d).find(b=>b===c)||T.blocks.forEach(b=>{n(c,b.blockedByCalling)})}}),d.calledByError.forEach(c=>{[...c.errorCalls||[]].forEach(T=>{jt.includes(T.type)&&T!==d&&(Rt(d).find(b=>b===T)||n(c,T))});let y;if(Vi.includes(c.type)&&(y=c),y){const T=Vm(y);T.reachable||Rt(d).find(b=>b===c)||T.blocks.forEach(b=>{n(c,b.blockedByCalling)})}}),d.calledByEntry.forEach(c=>{if([...c.calls||[]].forEach(T=>{jt.includes(T.type)&&T!==d&&(Rt(d).find(b=>b===T)||n(c,T))}),c===l)return;let y;if(c.type===o.FunctionDeclaration){const T=ki(c);if(T.type===o.DefinitionEntity)return;T.type===o.Loop&&(y=T)}if(y){const T=Vm(y);T.reachable||T.blocks.forEach(v=>{n(c,v.blockedByCalling)})}}),{reachable:p.length===0,entryPoint:l,blocks:p}):{reachable:!0,entryPoint:null,blocks:[]}}function CUi(d){return Hm.includes(d.type)?d.type===o.FunctionDeclaration?!Sx(d):!0:!1}function _Ui(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 V1(d,p){return d.type===o.BuiltInBaseEntity?d.name===p:!!Mu(d).includes(p)}function PUi(d,p){return d.type===o.BuiltInBaseEntity?d.name===p:!!Vv(d).includes(p)}function VUi(d){const p=[];return d.entities.forEach(i=>{if(V1(i,Re.PERSISTED_ENTITY)){p.push(i);return}}),D(p)}function NUi(d){const p=[];return d.entities.forEach(i=>{if(V1(i,Re.RELATIONAL_DATABASE)){p.push(i);return}}),D(p)}function wje(d){return d.type!==o.DefinitionEntity||d.abstract||!V1(d,Re.PERSISTED_ENTITY)?null:(d==null?void 0:d.properties.find(i=>i.implements.find(n=>n.id===Y[o.BuiltInBaseEntity][Re.PERSISTED_ENTITY].properties.primaryKey.id)&&!i.abstract))||null}function Cje(d){var n;const p=jx(d);if(!p)return null;const i=p.properties.find(l=>l.implements.find(c=>c.id===Y[o.BuiltInBaseEntity][Re.PERSISTED_ENTITY].properties.database.id));return i?(n=i.getDefaultValue())==null?void 0:n.valueAsType:null}function hn(d){if(d.type!==o.DefinitionEntity)return[];if(d.abstract)return[];if(!Ki(d,Re.PERSISTED_ENTITY))return[];const p=[],i=d.properties.filter(n=>!n.implements.find(l=>l.id===Y[o.BuiltInBaseEntity][Re.PERSISTED_ENTITY].properties.database.id)&&!n.abstract);return p.push(...i),p}function xUi(d){var i;if(!d||d.type!==o.DefinitionEntity||!Ki(d,Re.PERSISTED_ENTITY))return null;const p=d.properties.find(n=>!!n.implements.find(l=>l.id===Y[o.BuiltInBaseEntity][Re.PERSISTED_ENTITY].properties.database.id));return(i=p==null?void 0:p.getDefaultValue())==null?void 0:i.valueAsTypeSingle}function Pr(d,p){var n;if(!XU.includes(p.type)||!d)return p.project||null;let i=p.project;return d.type===o.Project?i=d:(((n=p.project)==null?void 0:n.id)!==d.project.id||p.project!==d.project)&&(i=d.project),i}function $Ui(d){switch(d){case o.Project:return x;case o.InstalledProject:return _u;case o.DefinitionEntity:return ls;case o.FunctionDeclaration:return Ro;case o.GlobalEvent:return gu;case o.VariableInstance:return Ou;case o.VariableDeclaration:return wu;case o.InputMap:return ss;case o.OutputMap:return El;case o.Condition:return Ru;case o.Operation:return Au;case o.FunctionCall:return Lu;case o.ArgumentDeclaration:return ya;case o.PrimitiveEntity:return pa;case o.DataType:return lr;case o.Property:return Ma;case o.ActionDescriptor:return Pi;case o.ReturnStatement:return ud;case o.ContinueStatement:return Nu;case o.BreakStatement:return Vu;case o.Loop:return Iu;case o.Search:return Cu;case o.ValueDescriptor:return pd;case o.InternalCall:return Pu;case o.LiteralValue:return Jr}return null}function LUi(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 xr(d,p){const i=Sh(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,T)=>y===e[T]):!1}):!1}function $r(d,p,i){let n={...p};if(!d.checkCanEdit(d,i)){const l=Sh(d.type);if(!l)return n;l.MUTABLE_META_PROPERTIES.forEach(c=>{["x","y","collapsed"].includes(c)||delete n[c]})}return n}function Nv(d,p={}){if(d.type===o.Project)return[];if(!d.parent)return[];const i=pe(d.parent);if(!i)return[];const n=p[i];return n?[n.id,...Nv(n,p)]:[]}function MUi(d){const p=[],i=new Set;return[...d.listAdded,...d.listUpdated,...d.listAffected].forEach(l=>{var y;const c=ki(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} ${pe(c.parent)}`:""}`);i.add(c.id),i.add(l.id),p.push(e)}),D(p)}function BUi(d){if(d.type===o.Condition)return null;if(d.type===o.Search)return d.project.getBuiltIn(Y["value-descriptor"][OA.SearchErrorOutputDescriptor].id)||null;if(d.type===o.Operation)return d.declaration.error;if(d.type===o.FunctionCall){const i=d.declaration.returnStatements.find(n=>!!n.throws);return(i==null?void 0:i.throws)||null}return null}function _je(d){const p=d.entities.filter(l=>!!l.implements.find(c=>c.id===Y["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id)),i=p.find(l=>{const c=l.properties.find(T=>T.implements.find(v=>v.id===Y["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 nC(d,p){const i=Array.from(new Set([...p.getAllBuiltInIds(),...Yi()]));return!!(i.includes(d.id)||!Nv(d,{...p.instances,...p.builtInInstances}).every(c=>!i.includes(c)))}function Pje(d){if(!d)return null;if(d.type===o.Project)return d.id;const p=d.parent;return p?Pje(p):d.id}function xv(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=ki(d),i=cd(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 aC(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=ki(d),i=cd(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 GUi(d,p,i){const n=p,l=i,c=!!i,e=[];return n.forEach(y=>{var T;if(c){const v=es(l,y,d);if(!v.compatible&&v.type!=="b-is-global-a-is-not")return;e.push(y)}else{if(((T=y.parent)==null?void 0:T.type)!==o.Project)return;e.push(y)}}),D(e)}function sC(d,p){var i,n,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(((n=d.extends)==null?void 0:n.id)===p.id)return d;if(d.extends){const e=sC(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=sC(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 Hd(d){var p;return!!(d.required||(p=d.declaration)!=null&&p.required)}function fd(d){return d==null||d===""}function fl(d){return d?d.valueAsType?!1:fd(d.value):!0}function N1(d,p,i,n=new Set,l=Array.from(new Set([...d.project.getAllBuiltInIds(),...Yi()]))){if(n.has(d.id)||l.includes(d.id))return;n.add(d.id),d.editable=i,d.deletable=i,p.add(d,H.Updated);const{downstream:c}=ld(d,d.project.instances,{ignoreBuiltInBaseEntities:!0,allBuiltInEntityIds:l});Object.keys(c).forEach(e=>{const y=d.project.get(e);y&&N1(y,p,i,n,l)})}function UUi(d,p,i=new Set,n=Array.from(new Set([...d.project.getAllBuiltInIds(),...Yi()]))){N1(d,p,!0,i,n)}function jUi(d,p,i=new Set,n=Array.from(new Set([...d.project.getAllBuiltInIds(),...Yi()]))){N1(d,p,!1,i,n)}function Vje(d,p=[]){return D(Ao(d)).filter(n=>!p.includes(n.id))}function $v(d){return d.replace(/["'`]/g,"")}function Wi(d){const i=$v(d).split(/[\s-]+/).filter(e=>e.length>0);if(i.length===0)return"";const n=i[0],l=n[0].toLowerCase()+n.slice(1),c=i.slice(1).map(e=>e[0].toUpperCase()+e.slice(1));return[l,...c].join("")}function Ic(d){return $v(d).split(/[\s-]+/).filter(n=>n.length>0).map(n=>n[0].toUpperCase()+n.slice(1)).join("")}function Nje(d){const p=$v(d).trim();if(!p)return"";const i=p.replace(/[\s_-]+/g," ").split(" ").filter(Boolean),n=[];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&&n.push(e)}return n.join("-")}function kUi(d){const p=$v(d).trim();if(!p)return"";const i=p.replace(/[\s_-]+/g," ").split(" ").filter(Boolean),n=[];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&&n.push(e)}return n.join("_")}function vA(d){return Nje(d).toLowerCase()}function Fx(d){const p=$v(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 Oy(d){var i,n,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)&&!((n=d.orChildrenGroup)!=null&&n.length)&&(p=" as template"),d.foreignKeyRef){const e=d.isList,y=se(d.foreignKeyRef,d.project),T=se(d.foreignKeyRef.parent,d.project);return e?`List references to "${y}" from "${T}"${p}`:`Reference to "${y}" from "${T}"${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="",T=!1,v=!1;return(d.andChildrenGroup||[]).forEach(E=>{const b=Oy(E),O=yc(b);T&&(y+=" and "),E.isGroup?y+="("+O+")":T?y+=O:y+=b,T=!0,v=!0}),(d.orChildrenGroup||[]).forEach(E=>{const b=Oy(E),O=yc(b);T&&(v&&(y+=","),y+=" or "),E.isGroup?y+="("+O+")":T?y+=O:y+=b,T=!0}),e?`List of ${yc(y)}`:y}}if(d.entity.type===o.PrimitiveEntity){let e=d.entity.name;switch(d.entity.name){case le.String:e="Text";break;case le.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=se(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=$je(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===le.Null)return"Empty value";if(d.entity.name===le.Untyped)return"Untyped value";if(d.entity.name===le.File)return"File";if(d.entity.name===le.String)return`"${d.entity.value}" text`;if(d.entity.name===le.Number)return`Number '${d.entity.value}'`;if(d.entity.name===le.Boolean)return`${d.entity.value} value`;if(d.entity.name===le.UUID)return`"${d.entity.value}" unique identifier`;if(d.entity.name===le.Date)return`"${d.entity.value}" date`}return d.isList?`List of ${se(d.entity,d.project)} values${p}`:`${se(d.entity,d.project).slice(0,1).toUpperCase()+se(d.entity,d.project).slice(1)} value${p}`}function KUi(d){if(!d)return"Any data type";const p=d.getDataType(null);return Oy(p)}function Zb(d){switch(d.declaration.id){case Pt.PrimitiveEqual:return"is equal to";case Pt.PrimitiveNotEqual:return"is not equal to";case Pt.Empty:return"is empty";case Pt.NotEmpty:return"is present";case ee.MoreThan:return"is greater than";case ee.MoreThanOrEqual:return"is greater than or equal to";case ee.LessThan:return"is less than";case ee.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 Qr.BooleanIsFalse:return"is false";case Qr.BooleanIsTrue:return"is true";case sr.And:return"and";case sr.Or:return"or"}}function xje(d){if(d.includes(Re.HTTP_ENDPOINT))return"HTTP endpoint";if(d.includes(Re.PERSISTED_ENTITY))return"Persisted entity";if(d.includes(Re.CRON_JOB))return"Scheduled execution";if(d.includes(Re.RELATIONAL_DATABASE))return"Relational database";if(d.includes(Re.SQL_ROW_TRANSFORMER))return"Row transformer";if(d.includes(Re.GOOGLE_AUTH_CONNECTION))return"Google account connection";if(d.includes(Re.SLACK_AUTH_CONNECTION))return"Slack account connection";if(d.includes(Re.AIRTABLE_AUTH_CONNECTION))return"Airtable account connection";if(d.includes(Re.MICROSOFT_AUTH_CONNECTION))return"Microsoft account connection";if(d.includes(Re.OPENAI_AUTH_CONNECTION))return"OpenAI account connection";if(d.includes(Re.ATLASSIAN_AUTH_CONNECTION))return"Atlassian account connection";if(d.includes(Re.JIRA_AUTH_CONNECTION))return"Jira account connection";if(d.includes(Re.GOOGLE_DRIVE_AUTH_CONNECTION))return"Google Drive account connection";if(d.includes(Re.GOOGLE_MAIL_AUTH_CONNECTION))return"Gmail account connection";if(d.includes(Re.GOOGLE_SHEET_AUTH_CONNECTION))return"Google Sheet account connection";if(d.includes(Re.GOOGLE_SLIDES_AUTH_CONNECTION))return"Google Slides account connection";if(d.includes(Re.GOOGLE_GEMINI_AUTH_CONNECTION))return"Google Gemini account connection";if(d.includes(Re.EXTERNAL_INTEGRATION_CONNECTION))return"External integration connection";try{return Fx(d[0])}catch(p){return ie.Logger.error("Error resolving base entity name for base entities:",d,p),"Built-in base entity"}}function $je(d){switch(d.name){case Re.HTTP_ENDPOINT:return"HTTP endpoint";case Re.PERSISTED_ENTITY:return"Persisted entity";case Re.CRON_JOB:return"Scheduled execution";case Re.RELATIONAL_DATABASE:return"Relational database";case Re.SQL_ROW_TRANSFORMER:return"Row transformer";case Re.GOOGLE_AUTH_CONNECTION:return"Google account connection";case Re.SLACK_AUTH_CONNECTION:return"Slack account connection";case Re.AIRTABLE_AUTH_CONNECTION:return"Airtable account connection";case Re.MICROSOFT_AUTH_CONNECTION:return"Microsoft account connection";case Re.OPENAI_AUTH_CONNECTION:return"OpenAI account connection";case Re.ATLASSIAN_AUTH_CONNECTION:return"Atlassian account connection";case Re.JIRA_AUTH_CONNECTION:return"Jira account connection";case Re.GOOGLE_DRIVE_AUTH_CONNECTION:return"Google Drive account connection";case Re.GOOGLE_MAIL_AUTH_CONNECTION:return"Gmail account connection";case Re.GOOGLE_SHEET_AUTH_CONNECTION:return"Google Sheet account connection";case Re.GOOGLE_SLIDES_AUTH_CONNECTION:return"Google Slides account connection";case Re.GOOGLE_GEMINI_AUTH_CONNECTION:return"Google Gemini account connection";case Re.EXTERNAL_INTEGRATION_CONNECTION:return"External integration connection";case Re.EXTERNAL_INTEGRATION_CONNECTION:return"External integration connection"}try{return Fx(d.name)}catch(p){return ie.Logger.error("Error resolving built-in base entity data type label for entity:",d,p),"Built-in base entity"}}function SUi(d){const p=P1(d);if(!p){const i=Dy(d);return i.includes(Re.HTTP_ENDPOINT)?"HTTP endpoint":i.includes(Re.PERSISTED_ENTITY)?"Persisted entity":i.includes(Re.CRON_JOB)?"Scheduled execution":i.includes(Re.RELATIONAL_DATABASE)?"Relational database":i.includes(Re.SQL_ROW_TRANSFORMER)?"Row transformer":i.includes(Re.GOOGLE_AUTH_CONNECTION)?"Google account connection":i.includes(Re.SLACK_AUTH_CONNECTION)?"Slack account connection":i.includes(Re.AIRTABLE_AUTH_CONNECTION)?"Airtable account connection":i.includes(Re.MICROSOFT_AUTH_CONNECTION)?"Microsoft account connection":i.includes(Re.OPENAI_AUTH_CONNECTION)?"OpenAI account connection":i.includes(Re.ATLASSIAN_AUTH_CONNECTION)?"Atlassian account connection":i.includes(Re.JIRA_AUTH_CONNECTION)?"Jira account connection":i.includes(Re.EXTERNAL_INTEGRATION_CONNECTION)?"External integration connection":se(d,d.project)+" entity"}return se(p,d.project)+" entity"}function Lje(d){let p="Find ";return d.outputs.forEach((i,n)=>{const l=u1(i,null),c=yc(l&&l.entity?se(l.entity,d.project):"unstructured data");n===0?p+=`${c} `:n===d.outputs.length-1?p+=`and ${c} `:p+=`, ${c} `}),p}function Mje(d){switch(d.name){case le.String:return"Text";case le.Number:return"Number";case le.Boolean:return"Boolean";case le.KeyValue:return"Data structure";case le.UUID:return"Unique identifier";case le.Date:return"Date";case le.EntityTemplate:return"Entity as template";case le.Enum:return"Enumeration";case le.File:return"File";case le.Null:return"Empty";case le.ActionDescriptor:return"Action descriptor";case le.Untyped:return"Untyped";default:return d.name}}function Bje(d){switch(d.id){case st.List:return"Loop over list items";case st.ManualFlow:return"Manual flow control loop";case st.ObjectKeys:return"Loop over object keys";case st.ObjectValues:return"Loop over object values";case st.Counted:return"Loop given number of times";case st.String:return"Loop over text characters";case Pt.PrimitiveEqual:return"is equal to";case Pt.PrimitiveNotEqual:return"is not equal to";case Pt.Empty:return"is empty";case Pt.NotEmpty:return"is present";case Ce.DeleteKey:return"Delete property from object";case Ce.DeleteNestedKey:return"Delete nested property from object";case Ce.HasKey:return"Check if object has property";case Ce.HasNestedKey:return"Check if object has nested property";case Ce.IsInstanceOfType:return"Check if object is instance of type";case Ce.KeyValueEquals:return"Check if object property equals value";case Ce.NestedKeyValueEquals:return"Check if object nested property equals value";case Ce.ReadKey:return"Read property from object";case Ce.ReadNestedKey:return"Read nested property from object";case Ce.Validate:return"Validate object structure";case Ce.WriteKey:return"Write property to object";case Ce.WriteNestedKey:return"Write nested property to object";case Ce.WriteSafeNestedKeyRecursively:return"Write safe nested property to object recursively";case Ce.Merge:return"Merge objects";case Ce.Entries:return"Get a list with the object keys, and values";case Ce.Keys:return"Get a list with the object keys";case Ce.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 ee.Addition:return"Sum numbers";case ee.Subtraction:return"Subtract numbers";case ee.Multiplication:return"Multiply numbers";case ee.Division:return"Divide numbers";case ee.Remainder:return"Get remainder of numbers";case ee.Absolute:return"Get absolute value of numbers";case ee.Acos:return"Get arc cosine of numbers";case ee.Asin:return"Get arc sine of numbers";case ee.Atan:return"Get arc tangent of numbers";case ee.Ceil:return"Round numbers up";case ee.Cos:return"Get cosine of numbers";case ee.Floor:return"Round numbers down";case ee.LogNatural:return"Get natural logarithm of numbers";case ee.Log10:return"Get base-10 logarithm of numbers";case ee.MaxOf:return"Get maximum of numbers";case ee.MinOf:return"Get minimum of numbers";case ee.Round:return"Round numbers to nearest integer";case ee.Sin:return"Get sine of numbers";case ee.SquareRoot:return"Get square root of numbers";case ee.Tan:return"Get tangent of numbers";case ee.Negate:return"Negate numbers";case ee.Atan2:return"Get arc tangent of two numbers";case ee.Exp:return"Get exponential of numbers";case ee.Average:return"Get average of numbers";case ee.Clamp:return"Clamp numbers within range";case ee.CubeRoot:return"Get cube root of numbers";case ee.LessThan:return"Check if numbers are less than";case ee.LessThanOrEqual:return"Check if numbers are less than or equal to";case ee.MoreThan:return"Check if numbers are more than";case ee.MoreThanOrEqual:return"Check if numbers are more than or equal to";case ee.MapRange:return"Map numbers from one range to another";case ee.Median:return"Get median of numbers";case ee.NthRoot:return"Get nth root of numbers";case ee.PercentOf:return"Get percentage of numbers";case ee.PercentageChange:return"Get percentage change between numbers";case ee.RoundToDecimals:return"Round numbers to given decimal places";case ee.Sign:return"Get sign of numbers";case ee.SnapToStep:return"Snap numbers to nearest step";case ee.ToDegrees:return"Convert numbers to degrees";case ee.ToRadians:return"Convert numbers to radians";case ee.Trunc:return"Truncate numbers";case ee.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 Mi.Wait:return"Wait";case Mi.Parallel:return"Run in parallel";case Mi.Sequential:return"Run in sequence";case Zn.HttpRequest:return"HTTP request";case Yr.Parse:return"Parse JSON text";case Yr.Stringify:return"Convert to JSON text";case ii.ConstantTimeEqual:return"Compare values in constant time";case ii.Hash:return"Hash value";case ii.Hmac:return"Create HMAC";case ii.DeriveKeyPBKDF2:return"Derive key with PBKDF2";case Xr.HashPasswordPBKDF2:return"Hash password with PBKDF2";case Xr.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 te.AddAtIndex:return"Add item at index position";case te.DeleteFirstNItems:return"Delete first items";case te.DeleteLastNItems:return"Delete last items";case te.DeleteAtIndex:return"Delete items at index position";case te.Join:return"Join lists";case te.ReplaceFirstNItems:return"Replace first match";case te.ReplaceLastNItems:return"Replace last match";case te.Split:return"Split list";case te.ReplaceAtIndex:return"Replace at index position";case te.GetFirst:return"Get first item";case te.GetLast:return"Get last item";case te.GetIndexItem:return"Get item at index position";case te.Append:return"Add item at the end";case te.Prepend:return"Add item at the start";case te.Chunk:return"Chunk list into smaller lists";case te.Shuffle:return"Randomize order of list items";case te.Reverse:return"Reverse order of list items";case te.GetFirstNItems:return"Get the first given number of items";case te.GetLastNItems:return"Get the last given number of items";case te.Sort:return"Order list items";case te.Unique:return"Get a new list without duplicate values";case te.Concat:return"Combine lists";case te.Slice:return"Get a portion of the list";case te.Contains:return"Check if list contains value";case te.ContainsAll:return"Check if list contains all values";case te.ContainsAny:return"Check if list contains any value";case te.Flatten:return"Flatten nested lists into a single list";case te.GetIndexOf:return"Get the index position number of the item";case te.GetLastIndexOf:return"Get the last index position number of the item";case te.GetLength:return"Get number of items in list";case te.PadEnd:return"Pad list at the end";case te.PadStart:return"Pad list at the start";case te.Repeat:return"Create a list by repeating an item";case te.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 Xe.GenerateHexadecimalToken:return"Generate hexadecimal token";case Xe.GenerateIdentifier:return"Generate unique identifier";case Xe.GenerateRandomAlphanumeric:return"Generate random alphanumeric text";case Xe.GenerateRandomBase62:return"Generate random Base62 text";case Xe.GenerateRandomBase64:return"Generate random Base64 text";case Xe.GenerateRandomBytes:return"Generate random bytes";case Xe.GenerateRandomFloat:return"Generate random decimal number";case Xe.GenerateRandomInteger:return"Generate random whole number";case Xe.GenerateRandomHexadecimal:return"Generate random hexadecimal text";case Xe.GenerateRandomUUIDv4:return"Generate random UUID v4";case Xe.GenerateShortIdentifier:return"Generate short unique identifier";case vl.PROJECT_PUBLICATION_COMPLETED:return"Project publication completed";case Pt.PrimitiveEqual:return"Values are equal";case Pt.PrimitiveNotEqual:return"Values are not equal";case Pt.Empty:return"Value is empty";case Pt.NotEmpty:return"Value is not empty";default:return(d.name.slice(0,1).toUpperCase()+d.name.slice(1)).replaceAll("-"," ")}}function se(d,p){var i;if(o.FunctionDeclaration===d.type){const n=d.name;if(Object.values(Mr).includes(n))switch(n){case Mr.AbortExecution:return"Abort ongoing execution";case Mr.DeletePersistedEntity:return"Delete entry from database";case Mr.CreatePersistedEntity:return"Save new data entry in database";case Mr.UpdatePersistedEntity:return"Update entity data to database";case Mr.DownSQLRowTransformer:return"Reverse row";case Mr.UpSQLRowTransformer:return"Transform row";default:return Sr(d.type).replaceAll("-"," ")}return n}if(o.BuiltInBaseEntity===d.type)return xje([d.name]);if(YU.includes(d.type)&&d.type!==o.ActionDescriptor)return d.name;switch(d.type){case o.Search:return Lje(d);case o.GlobalEvent:return d.implements?se(d.implements,p):Sr(d.type).replaceAll("-"," ");case o.Operation:case o.InternalCall:case o.Loop:const n=Sn(d.declaration,p);return se(n,p);case o.ActionDescriptor:return Bje(d);case o.BreakStatement:const l=Sn(d.parent,p);return`Stop loop ${se(l,p)}`;case o.ContinueStatement:const c=Sn(d.parent,p);return`Execute next iteration of ${se(c,p)}`;case o.FunctionCall:return Sn(d.declaration,p).name;case o.Condition:{const y=d;if(y.declaration.id===sr.And)return"If all conditions are met";if(y.declaration.id===sr.Or)return"If any condition is met";if((i=d.inputs)!=null&&i.length){const T=se(y.inputs[0],y.project);if(y.inputs[1]){const v=y.inputs[1].declaration.name;return`If ${T} ${Zb(y)} ${v}`}return`If ${T} ${Zb(y)}`}else return`If ${Zb(y)}`}case o.ReturnStatement:{const y=Sn(d.parent,p);return y?`Output of ${se(y,p)}`:"Return statement"}case o.InputMap:if(d.declaration){const y=Sn(d.declaration,p);return se(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=Sn(d.declaration,p);return se(y,p)||""}case o.OutputMap:if(d.declaration){const y=Sn(d.declaration,p);return(y==null?void 0:y.name)||""}else return d.parentRelationType===fu.Error?"Undeclared error":"";case o.PrimitiveEntity:case o.LiteralValue:return Mje(d);default:return Sr(d.type).replaceAll("-"," ")}}function qx(d,p){const i=[];d.name||i.push(new De({id:`${d.id}--${Ie.EmptyName}`,message:`Entity with id "${d.id}" and type "${d.type}" has an empty name. Please provide a 'name' string.`,severity:ue.Error,code:Ie.EmptyName}));const n=p.entities.filter(l=>l.name===d.name);return n.length&&i.push(new De({id:`${d.id}--${Ie.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 "${n[0].id}" has the same name.
|
|
377
|
+
`,'AND "'+se(U[0].callee,n.project)+'" '),U=U.slice(1)}return{ancestor:_,callType:$}}function oUi(d){if(![...cy,o.OutputMap].includes(d.type))throw new Error(`[getEarliestSingleCallerAncestorOfValueWriterAndItsValueReaders] Entity: ${d.id} - ${se(d,d.project)} - Can only be used with a value writer entity`);let p;if(cy.includes(d.type)?p=d:d.type===o.OutputMap&&(p=d.parent),!p)throw new Error(`[getEarliestSingleCallerAncestorOfValueWriterAndItsValueReaders] Entity: ${d.id} - ${se(d,d.project)} - Can only be used with a value writer entity that has a caller`);const i=D([d,...uA(d),...Ft.includes(d.type)?d.outputs.flatMap(y=>uA(y)):[]]),n=D(i.map(y=>dx(y)).flatMap(y=>jt.includes(y==null?void 0:y.type)?y.calledBy:[y]));if(n.length===1){const y=n[0];if(zt.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] Entity: ${d.id} - ${se(d,d.project)} - Could not be resolved, single caller found, but it is not a valid caller: ${y.id} - ${se(y,p.project)}`)}const l=n.map(y=>{var v;if(zt.includes(y.type))return y.parent.type===o.Loop?{ancestor:y.parent,callType:"loop-body"}:{ancestor:y,callType:"entry"};if(y.parent===d.project&&!((v=p.calledBy)!=null&&v.length)){if(y===p)return{ancestor:y,callType:"success"};const E=gn(y.successCalls),b=gn(y.errorCalls);if(E.includes(p))return{ancestor:y,callType:"success"};if(b.includes(p))return{ancestor:y,callType:"error"}}const T=uc(y);if(!T.ancestor)throw new Error(`[getEarliestSingleCallerAncestorOfValueWriterAndItsValueReaders] Entity: ${d.id} - ${se(d,d.project)} - Could not be resolved, no ancestor found for entity ${y.id} -- ${se(y,p.project)}`);return T}).filter((y,T,v)=>T===v.findIndex(E=>{var b,O;return((b=E.ancestor)==null?void 0:b.id)===((O=y.ancestor)==null?void 0:O.id)})),c=Sm(p),e=l.filter(y=>y!=null&&y.ancestor?c===y.ancestor?!0:!l.filter(E=>E.ancestor!==y.ancestor).map(E=>E.ancestor).some(E=>{const b=vu(y.ancestor,E);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] Entity: ${d.id} - ${se(d,d.project)} - Could not be resolved, multiple candidates found: ${e.map(y=>se(y.ancestor,p.project)).join(", ")}`);return{ancestor:e[0].ancestor,callType:e[0].callType}}function YUe(d,p){if(d===p)return!0;if(Rt(d).includes(p)||!Rt(p).includes(d))return!1;const l=d.calledBy;return l.length===0?!1:l.length===1?l[0]===p:WUe(l).length>1&&l.includes(p)?!1:l.every(e=>d===p?!0:zt.includes(e.type)?!1:YUe(e,p))}function XUe(d){const p=[];let i=d.calledBySuccess;i=i.filter(l=>!i.filter(y=>y!==l).some(y=>cA(y,l)));let n=d.calledByError;n=n.filter(l=>!n.filter(y=>y!==l).some(y=>cA(y,l)));for(const l of i)p.push({ancestor:l,callType:"success"});for(const l of n)p.push({ancestor:l,callType:"error"});return p}function QUe(d){const p=[];return XUe(d).forEach(n=>{n.ancestor.type===o.Condition&&p.push({condition:n.ancestor,call:d,callType:n.callType});const c=QUe(n.ancestor).filter(e=>!p.some(y=>y.condition.id===e.condition.id));p.push(...c)}),p}function dx(d){if(!d)return null;if(d.type===o.Condition&&d.parent.type===o.Condition)return Fm(d.parent);if(pC.includes(d.type))return d;const p=d.parent;return p?dx(p):null}function uA(d,p=new Set){return d.writesValues.reduce((i,n)=>p.has(n.id)?i:(p.add(n.id),is.includes(n.type)?[...i,n]:Ar.includes(n.type)?[...i,n,...uA(n,p)]:i),[])}function Om(d){const p=d.calledBy;if(p.length===0)return d.project;const i=p.reduce((n,l)=>{const c=dn(l,d.project);return!c||c.type===o.Project?n:n.type===o.Project||Ry(c,n).last?c:(Ry(n,c).last,n)},d.project);return i.type===o.FunctionDeclaration&&i.parent.type===o.Loop?i.parent:i}function ht(d,p){let i=Om(d);if(d.type===o.InternalCall)if(d.parent.type===o.VariableInstance){const l=es(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&&!yr.includes(i.type)){d.remove({ignoreUpstream:!1},p);return}else if(Ft.includes(d.type)){const l=d.usedInternalCalls[0];if(l)if(i=Om(l),d.type===o.VariableInstance){const c=es(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=es(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(jt.includes(d.type))return;Rt(d).forEach(l=>{let c=Om(l);if(l.type===o.InternalCall)if(l.parent.type===o.VariableInstance){const e=es(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&&!yr.includes(c.type)){l.remove({ignoreUpstream:!1},p);return}else if(Ft.includes(l.type)){const e=l.usedInternalCalls[0];if(e)if(c=Om(e),l.type===o.VariableInstance){const y=es(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=es(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 pA(d,p,i=new Set){const n=Tl(d),l=Tl(p),c=n.filter(T=>!l.includes(T)),e=n.filter(T=>l.includes(T)),y=c.reduce((T,v)=>i.has(v.id)?T:(i.add(v.id),D([...T,...pA(v,p,i)])),[]);return D([...e,...y])}function Ac(d,p){const i=Ry(d,p);return i.last===p&&i.list.length>0&&i.list[0]!==p}function rC(d,p){return!!Ry(d,p).last}function cA(d,p){return!!vu(d,p).last}function ux(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 n=p.parent;if(n){if(n===d)return d;if(n.type===o.Project)return null}else return null;return ux(i,n)}function dUi(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(zr.includes(d.type)&&Fr.includes(p.type)){const y=vu(d,p),T=y.last;if(T){if(T===p)return{ancestor:p,callType:y.callType}}else return{ancestor:null,callType:null}}if(zr.includes(p.type)&&Fr.includes(d.type)){const y=vu(p,d),T=y.last;if(T){if(T===d)return{ancestor:d,callType:y.callType}}else return{ancestor:null,callType:null}}const n=Sm(d),l=Sm(p);if(!n||!l)return{ancestor:null,callType:null};if(n!==l)return{ancestor:null,callType:null};if(n.calls.includes(d)||n.calls.includes(p))return{ancestor:n,callType:"entry"};const c=n.calls.reduce((y,T)=>{if(!Fr.includes(T.type))return y;const v=$s(T),E=v.find(O=>O.callee===d),b=v.find(O=>O.callee===p);return E&&b&&(!i||E.callType===b.callType)?[...y,{ancestor:T,callType:E.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(T=>T.ancestor!==y.ancestor&&vu(y.ancestor,T.ancestor).last===T.ancestor));return e.length===1?{ancestor:e[0].ancestor,callType:e[0].callType}:{ancestor:n,callType:"entry"}}function ki(d){if(Hm.includes(d.type)){if(d.type===o.FunctionDeclaration){const p=d.parent;if(p.type===o.DefinitionEntity)return ki(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?ki(d.parent):d}else{const p=d.parent;return p?ki(p):null}}function py(d,p){const i=oy(d,p);if(!i)return null;if(Hm.includes(i.type)){if(i.type===o.FunctionDeclaration){const n=oy(i.parent,p);if(n){if(n.type===o.DefinitionEntity)return n;if(n.type===o.Loop)return n}}if(i.parent){const n=oy(i.parent,p);if(n&&(i.type===o.DefinitionEntity&&n.type===o.DataType||i.type===o.Condition&&n.type===o.Condition))return py(n,p)}return i}else{const n=i.parent?oy(i.parent,p):null;return n?py(n,p):null}}function $s(d){if(d.type===o.Loop){const p=[...gn(d.successCalls).map(l=>({callee:l,callType:"success"})),...gn(d.errorCalls).map(l=>({callee:l,callType:"error"})),...(d.body?Rt(d.body):[]).map(l=>({callee:l,callType:"loop-body"}))];return D(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(Vi.includes(d.type)){const p=[...gn(d.successCalls).map(l=>({callee:l,callType:"success"})),...gn(d.errorCalls).map(l=>({callee:l,callType:"error"}))];return D(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(zt.includes(d.type)){const p=[...gn(d.calls).map(l=>d.parent.type===o.Loop?{callee:l,callType:"loop-body"}:{callee:l,callType:"entry"})];return D(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 Fm(d){if(!d)return null;if(d.type===o.Condition&&d.parent.type===o.Condition)return Fm(d.parent);if(zr.includes(d.type))return d;const p=d.parent;return p?Fm(p):null}function eje(d){if(!d)return null;if(Vi.includes(d.type))return d;const p=d.parent;return p?eje(p):null}function tje(d){if(!d)return null;if(Fr.includes(d.type))return d;const p=d.parent;return p?tje(p):null}function uUi(d){return d.type===o.VariableDeclaration?[d]:Vi.includes(d.type)?[...d.inputs,...d.outputs||[]]:jt.includes(d.type)?d.outputs:Rc.includes(d.type)||d.type===o.FunctionDeclaration?d.inputs:[]}function pUi(d){const p=Tl(d),i=[],n=[];WU.includes(d.type)&&i.push(...C1(d));const l=p.filter(c=>{const e=i.includes(c);return e?!1:zr.includes(c.type)&&!e?(n.push(c),!1):!0});return i.sort((c,e)=>Ac(e,c)?-1:0),n.sort((c,e)=>Ac(e,c)?-1:0),[...i,...n,...l]}function ije(d){return[...d].sort((p,i)=>Ac(i,p)?-1:0)}function cUi(d){const p=ije(d),i=[];return p.forEach(n=>{const l=i[i.length-1];if(l){const c=l[l.length-1];Ac(n,c)?i.push([n]):l.push(n)}else i.push([n])}),i}function Ao(d){const p=d.map(i=>ki(i));return D(p)}function C1(d){return Vi.includes(d.type)?[...Ao(d.successCalls),...Ao(d.errorCalls)]:zt.includes(d.type)?Ao(d.calls):[]}function fUi(d,p){return C1(d).includes(p)}function _1(d){return d.writesValues||[]}function yUi(d,p){return _1(d).includes(p)}function rje(d){var p;return Ft.includes((p=d==null?void 0:d.readsValue)==null?void 0:p.type)?d.readsValue:null}function hUi(d){return d.writesValues}function nje(d=[]){return d.map(rje).filter(p=>!!p)}function fA(d=[]){return d.map(p=>p.writesValues).flat().filter(p=>Ft.includes(p.type))}function aje(d=[]){return d.map(p=>p.readsValue).filter(p=>!!p&&Ft.includes(p.type))}function sje(d){return Ft.includes(d.type)?d:null}function lje(d){return d.writesValues.map(sje).filter(p=>!!p)}function oje(d=[]){return d.reduce((p,i)=>i.type===o.OutputMap?[...p,...lje(i)]:p,[])}function Rt(d){return d.type===o.Loop?D([...gn(d.successCalls),...gn(d.errorCalls),...d.body?Rt(d.body):[]]):Vi.includes(d.type)?D([...gn(d.successCalls),...gn(d.errorCalls)]):zt.includes(d.type)?D(gn(d.calls)):[]}function mUi(d){return Vi.includes(d.type)?[...gn(d.successCalls),...gn(d.errorCalls)]:zt.includes(d.type)?gn(d.calls):[]}function dje(d,p=new Set){return d.writesValues.filter(n=>Ft.includes(n.type)&&!p.has(n.id)).reduce((n,l)=>p.has(l.id)?n:[...n,...Zi(l,p)],[])}function uje(d,p=new Set){var n;return(((n=d.readsValue)==null?void 0:n.writesValues)||[]).filter(l=>Ft.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 aje(d.outputs).reduce((n,l)=>[...n,...Zi(l,p)],[]);if(d.type===o.FunctionCall||d.type===o.Operation||d.type===o.Condition)return[...Rt(d).reduce((c,e)=>{const y=ki(e);return[...c,...Zi(y||e,p)]},[]),...nje(d.inputs),...oje(d.outputs)].reduce((c,e)=>[...c,...Zi(e,p)],[]);if(Rc.includes(d.type)){const i=fA(d.inputs),l=Rt(d).reduce((c,e)=>{const y=ki(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=[...fA(d.inputs)],l=Rt(d).reduce((c,e)=>{const y=ki(e);return[...c,...Zi(y||e,p)]},[]);return i.push(...l),i.reduce((c,e)=>[...c,...Zi(e)],[])}if(Ft.includes(d.type)){p.add(d.id);const n=Rt(d).reduce((l,c)=>{const e=ki(c);return[...l,...Zi(e||c,p)]},[]);return[d,...n,...uje(d,p),...dje(d,p)]}return[]}function Va(d,p=new Set){if(p.has(d.id))return[];p.add(d.id),ie.Logger.log("[flattenDerivedCanvasEntities]",d.type,se(d,d.project),d.id);const i=Tl(d);return i.forEach(l=>{p.add(l.id)}),[...i.reduce((l,c)=>(ie.Logger.log("[Recursive -- flattenDerivedCanvasEntities]",c.type,se(c,c.project),c.id),[...l,c,...Va(c,p)]),[])]}function gn(d){return d.reduce((p,i)=>i.type===o.ReturnStatement||i.type===o.ContinueStatement||i.type===o.BreakStatement?[...p,i]:[...p,i,...Rt(i)],[])}function pje(d){const p=d.entities||[],i=[...p,...d.functions||[],...d.events||[],...d.projects||[]],n=p.reduce((T,v)=>[...T,...v.properties],[]),l=p.reduce((T,v)=>[...T,...v.methods],[]),c=l.reduce((T,v)=>[...T,...fA(v.inputs),...gn(Ao(v.calls)),...v.returnStatements],[]),e=d.functions.reduce((T,v)=>[...T,...gn(Ao(v.calls)),...v.returnStatements],[]),y=d.events.reduce((T,v)=>[...T,...gn(Ao(v.calls)),...v.returnStatements],[]);return[...i,...n,...l,...c,...e,...y]}function cje(d,p){return p.filter(n=>{if(!n)return!1;switch(n.type){case o.FunctionCall:return n.inputs.find(l=>l.id===d.id)!==void 0||n.outputs.find(l=>l.id===d.id)!==void 0;case o.Condition:return n.successCalls.find(l=>l.id===d.id)!==void 0||n.errorCalls.find(l=>l.id===d.id)!==void 0||n.inputs.find(l=>l.id===d.id)!==void 0;case o.Operation:return n.outputs.find(l=>l.id===d.id)!==void 0;case o.VariableDeclaration:return Vi.includes(d.type)?yje(d).find(c=>{var e;return((e=c.readsValue)==null?void 0:e.id)===n.id})!==void 0:!1;case o.DefinitionEntity:return n.properties.find(l=>l.id===d.id)!==void 0||n.methods.find(l=>l.id===d.id)!==void 0;case o.FunctionDeclaration:return n.inputs.find(l=>l.id===d.id)!==void 0||(n.returnStatements.map(l=>l.outputs).flat()||[]).find(l=>l.id===d.id)!==void 0;default:return!1}})}function TUi(d){const p=pje(d.project);return cje(d,p)}function oy(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 px(d={},p){const i={};return Object.keys(d).forEach(n=>{const l=p.get(n)||n,c=d[n];i[l]=c}),i}function ld(d,p={},i={}){const n={ignoreBuiltInBaseEntities:!1,allBuiltInEntityIds:[],entityMaps:new Map,...i};if(n.ignoreBuiltInBaseEntities&&(ea.includes(d.type)||(n.allBuiltInEntityIds||[]).includes(d.id)))return{upstream:{},downstream:{}};const l=d,c=d,e=d,y=d,T=d,v=d,E=d,b=d,O=d,_=d,$=d,L=d,U=d,S=[...U.readsValue?[U.readsValue]:[],...U.declaration?[U.declaration]:[],...(L.calledByEntry||[]).flatMap(Q=>Q),...(L.calledBySuccess||[]).flatMap(Q=>Q),...(L.calledByError||[]).flatMap(Q=>Q),..._.parent?[_.parent]:[],...c.foreignKeyRef?[c.foreignKeyRef]:[]];Array.isArray(e.implements)?S.push(...e.implements.flatMap(Q=>Q)):y.implements&&S.push(y.implements),Array.isArray(e.extends)?S.push(...e.extends.flatMap(Q=>Q)):O.extends&&S.push(O.extends),T.valueAsTypeList&&Array.isArray(T.valueAsTypeList)&&S.push(...T.valueAsTypeList.flatMap(Q=>Q)),T.valueAsTypeSingle&&S.push(T.valueAsTypeSingle),(U.internalCalls||[]).forEach(Q=>{const fe=pe(Q);if(fe&&p[fe]){const oe=p[fe];[...oe.calledByEntry||[],...oe.calledBySuccess||[],...oe.calledByError||[]].forEach(ce=>{const me=pe(ce);me&&p[me]&&S.push(p[me])})}});const Z=[...(l.inputs||[]).flatMap(Q=>Q),...($.inputsDeclarations||[]).flatMap(Q=>Q),...($.outputs||[]).flatMap(Q=>Q),...(U.internalCalls||[]).flatMap(Q=>Q),...U.writesValues||[],...L.dataType?[L.dataType]:[],...v.body?[v.body]:[],...L.defaultValue?[L.defaultValue]:[],...(L.successCalls||[]).flatMap(Q=>Q),...(L.errorCalls||[]).flatMap(Q=>Q),...(e.properties||[]).flatMap(Q=>Q),...(e.methods||[]).flatMap(Q=>Q),...(e.abstractMethods||[]).flatMap(Q=>Q),...E.error?[E.error]:[],..._.throws?[_.throws]:[],...(c.andChildrenGroup||[]).flatMap(Q=>Q),...(c.orChildrenGroup||[]).flatMap(Q=>Q),...(b.entities||[]).flatMap(Q=>Q),...(b.functions||[]).flatMap(Q=>Q),...(b.functionCalls||[]).flatMap(Q=>Q),...(b.events||[]).flatMap(Q=>Q),...(b.conditions||[]).flatMap(Q=>Q),...(b.operations||[]).flatMap(Q=>Q),...(b.loops||[]).flatMap(Q=>Q),...(b.variableDeclarations||[]).flatMap(Q=>Q),...(b.variableInstances||[]).flatMap(Q=>Q),...(b.searches||[]).flatMap(Q=>Q),...(b.projects||[]).flatMap(Q=>Q),...(y.calls||[]).flatMap(Q=>Q)];d.type===o.DataType&&(c.entity&&p[pe(c.entity)]&&p[pe(c.entity)].parent&&pe(p[pe(c.entity)].parent)===d.id?Z.push(c.entity):c.entity&&S.push(c.entity)),(U.internalCalls||[]).forEach(Q=>{const fe=pe(Q);if(fe&&p[fe]){const oe=p[fe];[...oe.successCalls||[],...oe.errorCalls||[]].forEach(ce=>{const me=pe(ce);me&&p[me]&&Z.push(p[me])})}});const X={},ae={};return S.forEach(Q=>{var ce;const fe=pe(Q);if(fe&&n.ignoreBuiltInBaseEntities&&(ea.includes(Q.type)||(n.allBuiltInEntityIds||[]).includes(fe)))return;const oe=Q.version;if(fe){const me=((ce=n.entityMaps)==null?void 0:ce.get(fe))||fe;X[me]=oe}}),Z.forEach(Q=>{var ce;const fe=pe(Q);if(fe&&n.ignoreBuiltInBaseEntities&&(ea.includes(Q.type)||(n.allBuiltInEntityIds||[]).includes(fe)))return;const oe=Q.version;if(fe){const me=((ce=n.entityMaps)==null?void 0:ce.get(fe))||fe;ae[me]=oe}}),{upstream:X,downstream:ae}}function vUi(d,p){const i=[];if(zr.includes(d.type)){gs(d).forEach(c=>{const e=py(c,p);e&&i.push(e)});const l=[...d.inputs||[],...d.outputs||[]].map(c=>{const e=oy(c,p);return e?hje(e,p):null}).filter(c=>c!==null);i.push(...D(l))}if(Ft.includes(d.type)){const n=yA(d);n&&i.push(n)}return D(i)}function Mp(d){const p=[];if(zr.includes(d.type)){d.calledBy.forEach(l=>{const c=ki(l);c&&p.push(c)});const n=[...d.inputs||[],...d.outputs||[]].map(l=>yA(l)).filter(l=>l!==null);p.push(...D(n))}if(is.includes(d.type)){const i=yA(d);i&&p.push(i)}return D(p)}function gs(d){return[...d.calledByEntry||[],...d.calledByError||[],...d.calledBySuccess||[]].filter(p=>p.type!==o.GenericReference)}function cx(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(n=>Ne(n,p,i)),...d.dataType?Ne(d.dataType,p,i):[],...d.error?Ne(d.error,p,i):[],...d.parent?Ne(d.parent,p,i):[]]}function fx(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(n=>Ne(n,p,i)),...d.dataType?Ne(d.dataType,p,i):[],...d.parent?Ne(d.parent,p,i):[]]}function yx(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(n=>Ne(n,p,i)),...d.throws?Ne(d.throws,p,i):[],...d.dataType?Ne(d.dataType,p,i):[],...d.readsValue?Ne(d.readsValue,p,i):[],...(gs(d)||[]).flatMap(n=>Ne(n,p,i)),...d.parent?Ne(d.parent,p,i):[]]}function hx(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(n=>Ne(n,p,i)),...(d.methods||[]).flatMap(n=>Ne(n,p,i)),...(d.abstractMethods||[]).flatMap(n=>Ne(n,p,i)),...d.allPropertiesImplement?Ne(d.allPropertiesImplement,p,i):[],...d.additionalPropertiesDataType?Ne(d.additionalPropertiesDataType,p,i):[],...d.extends?Ne(d.extends,p,i):[]]}function mx(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(n=>Ne(n,p,i)),...(d.orChildrenGroup||[]).flatMap(n=>Ne(n,p,i)),...(d.inputs||[]).flatMap(n=>Ne(n,p,i)),...(d.successCalls||[]).flatMap(n=>Ne(n,p,i)),...(d.errorCalls||[]).flatMap(n=>Ne(n,p,i)),...(gs(d)||[]).flatMap(n=>Ne(n,p,i)),...d.parent?Ne(d.parent,p,i):[]]}function Tx(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(n=>Ne(n,p,i)),...d.readsValue?Ne(d.readsValue,p,i):[],...d.throws?Ne(d.throws,p,i):[],...d.dataType?Ne(d.dataType,p,i):[],...(gs(d)||[]).flatMap(n=>Ne(n,p,i)),...d.parent?Ne(d.parent,p,i):[]]}function vx(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(n=>Ne(n,p,i)),...(d.properties||[]).flatMap(n=>Ne(n,p,i)),...(d.methods||[]).flatMap(n=>Ne(n,p,i)),...(d.abstractMethods||[]).flatMap(n=>Ne(n,p,i)),...d.allPropertiesImplement?Ne(d.allPropertiesImplement,p,i):[],...d.additionalPropertiesDataType?Ne(d.additionalPropertiesDataType,p,i):[],...d.parent?Ne(d.parent,p,i):[]]}function Ex(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(n=>Ne(n,p,i)),...(d.orChildrenGroup||[]).flatMap(n=>Ne(n,p,i)),...d.entity?Ne(d.entity,p,i):[],...d.foreignKeyRef?Ne(d.foreignKeyRef,p,i):[],...d.parent?Ne(d.parent,p,i):[]]}function bx(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(n=>Ne(n,p,i)),...(d.outputs||[]).flatMap(n=>Ne(n,p,i)),...d.error?Ne(d.error,p,i):[],...(gs(d)||[]).flatMap(n=>Ne(n,p,i)),...(d.successCalls||[]).flatMap(n=>Ne(n,p,i)),...(d.errorCalls||[]).flatMap(n=>Ne(n,p,i)),...(d.writesValues||[]).flatMap(n=>Ne(n,p,i)),...d.parent?Ne(d.parent,p,i):[]]}function Ax(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(n=>Ne(n,p,i)),...(d.calls||[]).flatMap(n=>Ne(n,p,i)),...d.dataType?Ne(d.dataType,p,i):[],...d.implements?Ne(d.implements,p,i):[],...d.parent?Ne(d.parent,p,i):[]]}function gx(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(n=>Ne(n,p,i)),...(d.calls||[]).flatMap(n=>Ne(n,p,i)),...d.implements?Ne(d.implements,p,i):[],...d.parent?Ne(d.parent,p,i):[]]}function Ix(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 Rx(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(n=>Ne(n,p,i)),...(d.events||[]).flatMap(n=>Ne(n,p,i)),...d.parent?Ne(d.parent,p,i):[]]}function Dx(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(n=>Ne(n,p,i)),...(d.errorCalls||[]).flatMap(n=>Ne(n,p,i)),...(d.inputs||[]).flatMap(n=>Ne(n,p,i)),...(d.outputs||[]).flatMap(n=>Ne(n,p,i)),...(gs(d)||[]).flatMap(n=>Ne(n,p,i)),...d.error?Ne(d.error,p,i):[],...(d.writesValues||[]).flatMap(n=>Ne(n,p,i)),...d.parent?Ne(d.parent,p,i):[]]}function Ox(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(n=>Ne(n,p,i)):[],...d.parent?Ne(d.parent,p,i):[]]}function wx(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(n=>Ne(n,p,i)),...(d.outputs||[]).flatMap(n=>Ne(n,p,i)),...(d.successCalls||[]).flatMap(n=>Ne(n,p,i)),...(d.errorCalls||[]).flatMap(n=>Ne(n,p,i)),...d.error?Ne(d.error,p,i):[],...d.dataType?Ne(d.dataType,p,i):[],...d.body?Ne(d.body,p,i):[],...(gs(d)||[]).flatMap(n=>Ne(n,p,i)),...(d.writesValues||[]).flatMap(n=>Ne(n,p,i)),...d.parent?Ne(d.parent,p,i):[]]}function Cx(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(n=>Ne(n,p,i)),...(d.errorCalls||[]).flatMap(n=>Ne(n,p,i)),...(d.inputs||[]).flatMap(n=>Ne(n,p,i)),...(d.outputs||[]).flatMap(n=>Ne(n,p,i)),...(d.writesValues||[]).flatMap(n=>Ne(n,p,i)),...d.error?Ne(d.error,p,i):[],...(gs(d)||[]).flatMap(n=>Ne(n,p,i)),...d.parent?Ne(d.parent,p,i):[]]}function _x(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(n=>Ne(n,p,i)),...d.declaration?Ne(d.declaration,p,i):[],...d.parent?Ne(d.parent,p,i):[]]}function Px(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(n=>Ne(n,p,i)),...(d.methods||[]).flatMap(n=>Ne(n,p,i)),...(d.abstractMethods||[]).flatMap(n=>Ne(n,p,i))]}function Vx(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(n=>Ne(n,p,i)),...(d.functions||[]).flatMap(n=>Ne(n,p,i)),...(d.events||[]).flatMap(n=>Ne(n,p,i)),...(d.projects||[]).flatMap(n=>Ne(n,p,i)),...(d.variableDeclarations||[]).flatMap(n=>Ne(n,p,i)),...(d.variableInstances||[]).flatMap(n=>Ne(n,p,i)),...(d.operations||[]).flatMap(n=>Ne(n,p,i)),...(d.conditions||[]).flatMap(n=>Ne(n,p,i)),...(d.functionCalls||[]).flatMap(n=>Ne(n,p,i)),...(d.projects||[]).flatMap(n=>Ne(n,p,i)),...(d.loops||[]).flatMap(n=>Ne(n,p,i)),...(d.searches||[]).flatMap(n=>Ne(n,p,i))]}function Nx(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 xx(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(n=>Ne(n,p,i)),...d.throws?Ne(d.throws,p,i):[],...d.readsValue?Ne(d.readsValue,p,i):[],...d.dataType?Ne(d.dataType,p,i):[],...(gs(d)||[]).flatMap(n=>Ne(n,p,i)),...d.parent?Ne(d.parent,p,i):[]]}function $x(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(n=>Ne(n,p,i)),...(d.errorCalls||[]).flatMap(n=>Ne(n,p,i)),...(d.inputsDeclarations||[]).flatMap(n=>Ne(n,p,i)),...(d.inputs||[]).flatMap(n=>Ne(n,p,i)),...(d.writesValues||[]).flatMap(n=>Ne(n,p,i)),...(d.outputs||[]).flatMap(n=>Ne(n,p,i)),...d.error?Ne(d.error,p,i):[],...d.dataType?Ne(d.dataType,p,i):[],...(gs(d)||[]).flatMap(n=>Ne(n,p,i)),...d.parent?Ne(d.parent,p,i):[]]}function Lx(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 Mx(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(n=>Ne(n,p,i)),...(d.errorCalls||[]).flatMap(n=>Ne(n,p,i)),...(d.inputs||[]).flatMap(n=>Ne(n,p,i)),...(d.outputs||[]).flatMap(n=>Ne(n,p,i)),...(d.internalCalls||[]).flatMap(n=>Ne(n,p,i)),...(d.writesValues||[]).flatMap(n=>Ne(n,p,i)),...d.readsValue?Ne(d.readsValue,p,i):[],...d.defaultValue?Ne(d.defaultValue,p,i):[],...(gs(d)||[]).flatMap(n=>Ne(n,p,i)),...d.dataType?Ne(d.dataType,p,i):[],...d.parent?Ne(d.parent,p,i):[]]}function Bx(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(n=>Ne(n,p,i)),...(d.errorCalls||[]).flatMap(n=>Ne(n,p,i)),...(d.inputs||[]).flatMap(n=>Ne(n,p,i)),...(d.outputs||[]).flatMap(n=>Ne(n,p,i)),...(d.internalCalls||[]).flatMap(n=>Ne(n,p,i)),...(d.writesValues||[]).flatMap(n=>Ne(n,p,i)),...d.readsValue?Ne(d.readsValue,p,i):[],...d.defaultValue?Ne(d.defaultValue,p,i):[],...(gs(d)||[]).flatMap(n=>Ne(n,p,i)),...d.declaration?Ne(d.declaration,p,i):[],...d.parent?Ne(d.parent,p,i):[]]}function Yi(){const d=new Set;return pOe.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&&(ea.includes(d.type)||Yi().includes(d.id)))return[];if(p.has(d.id))return[];switch(d.type){case o.FunctionCall:return bx(d,p,i);case o.Operation:return Cx(d,p,i);case o.Condition:return mx(d,p,i);case o.Loop:return wx(d,p,i);case o.Search:return $x(d,p,i);case o.GlobalEvent:return gx(d,p,i);case o.ReturnStatement:return xx(d,p,i);case o.ContinueStatement:return Tx(d,p,i);case o.BreakStatement:return yx(d,p,i);case o.VariableDeclaration:return Mx(d,p,i);case o.DefinitionEntity:return vx(d,p,i);case o.FunctionDeclaration:return Ax(d,p,i);case o.Project:return Vx(d,p,i);case o.ActionDescriptor:return cx(d,p,i);case o.ArgumentDeclaration:return fx(d,p,i);case o.ValueDescriptor:return Lx(d,p,i);case o.InputMap:return Ix(d,p,i);case o.OutputMap:return _x(d,p,i);case o.DataType:return Ex(d,p,i);case o.InstalledProject:return Rx(d,p,i);case o.InternalCall:return Dx(d,p,i);case o.LiteralValue:return Ox(d,p,i);case o.Property:return Nx(d,p,i);case o.VariableInstance:return Bx(d,p,i);case o.BuiltInBaseEntity:return i.ignoreBuiltInBaseEntities?[]:hx(d,p,i);case o.PrimitiveEntity:return i.ignoreBuiltInBaseEntities?[]:Px(d,p,i)}return[]}async function fje(d,p=new Set,i={ignoreBuiltInBaseEntities:!1,yieldEvery:100}){const n={ignoreBuiltInBaseEntities:i.ignoreBuiltInBaseEntities??!1,yieldEvery:i.yieldEvery??100};if(!d)throw new Error("Entity must be defined to be flattened");if(d.type===o.GenericReference)return[];if(n.ignoreBuiltInBaseEntities&&(ea.includes(d.type)||Yi().includes(d.id)))return[];if(p.has(d.id))return[];switch(d.type){case o.FunctionCall:return bx(d,p,n);case o.Operation:return Cx(d,p,n);case o.Condition:return mx(d,p,n);case o.Loop:return wx(d,p,n);case o.Search:return $x(d,p,n);case o.GlobalEvent:return gx(d,p,n);case o.ReturnStatement:return xx(d,p,n);case o.ContinueStatement:return Tx(d,p,n);case o.BreakStatement:return yx(d,p,n);case o.VariableDeclaration:return Mx(d,p,n);case o.DefinitionEntity:return vx(d,p,n);case o.FunctionDeclaration:return Ax(d,p,n);case o.Project:return Vx(d,p,n);case o.ActionDescriptor:return cx(d,p,n);case o.ArgumentDeclaration:return fx(d,p,n);case o.ValueDescriptor:return Lx(d,p,n);case o.InputMap:return Ix(d,p,n);case o.OutputMap:return _x(d,p,n);case o.DataType:return Ex(d,p,n);case o.InstalledProject:return Rx(d,p,n);case o.InternalCall:return Dx(d,p,n);case o.LiteralValue:return Ox(d,p,n);case o.Property:return Nx(d,p,n);case o.VariableInstance:return Bx(d,p,n);case o.BuiltInBaseEntity:return n.ignoreBuiltInBaseEntities?[]:hx(d,p,n);case o.PrimitiveEntity:return n.ignoreBuiltInBaseEntities?[]:Px(d,p,n)}return[]}function Gx(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||Rc.includes(d.type)?d.inputs:d.type===o.Search?d.inputsDeclarations:[]}function EUi(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 yje(d){return Vi.includes(d.type)?d.inputs:[]}function bUi(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 jt.includes(d.type)?d.outputs.map(i=>i.declaration).filter(i=>!!i)||[]:[]}function AUi(d,p){return p.type===o.Condition?null:(p.type===o.FunctionCall||p.type===o.Operation)&&p.outputs.find(i=>{var n;return((n=i.declaration)==null?void 0:n.id)===d.id})||null}function gUi(d){return d.type===o.Condition?[]:Vi.includes(d.type)?d.outputs:[]}function yA(d){const p=d.readsValue;return p?ki(p):null}function hje(d,p){const i=d.readsValue;return i?py(i,p):null}function mje(d){const p=d.internalCalls||[];return D(Ao(D(p.flatMap(i=>[...i.successCalls,...i.errorCalls]))))}function Tje(d){const p=d.internalCalls||[];return D(D(p.flatMap(i=>[...i.successCalls,...i.errorCalls])))}function ry(d){const p=_1(d),i=[];return p.forEach(n=>{if(Hm.includes(n.type))i.push(n);else if(is.includes(n.type)){const l=ki(n.parent);i.push(l)}}),i}function ny(d){const p=_1(d),i=[];return p.forEach(n=>{if([...Ft,...jt].includes(n.type))i.push(n);else if(is.includes(n.type)){const l=n.parent;i.push(l)}}),i}function D(d){const p=new Set;return d.filter(i=>!i||p.has(i.id)?!1:(p.add(i.id),!0))}function vje(d){return d.type===o.Project?null:pC.includes(d.type)?d:ea.includes(d.type)?null:d.parent?vje(d.parent):null}function Tl(d,p=!1){ie.Logger.log("[getRelatedCanvasElementsOnTheRight]",d.type,se(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)||[]),yr.includes(d.type)&&i.push(...(d==null?void 0:d.detachedChildren)||[]),d.type===o.DefinitionEntity){const n=[...d.suggestedMethods,...d.methods].flatMap(l=>l.collapsed&&p?[]:(ie.Logger.log("[Recursive -- getRelatedCanvasElementsOnTheRight]",l.type,se(l,l.project),l.id),Tl(l,p)));i.push(...n)}if(d.type===o.Condition){const n=d.successCalls.map(c=>ki(c)),l=d.errorCalls.map(c=>ki(c));i.push(...n,...l)}if(Rc.includes(d.type)){if(d.collapsed&&p)return[];const n=d.inputs.map(c=>ry(c)).flat(),l=d.calls.map(c=>ki(c));i.push(...D(n),...l)}if(Vi.includes(d.type)&&d.type!==o.Condition&&d.type!==o.Loop){const n=d==null?void 0:d.outputs.map(e=>ry(e)).flat(),l=d.successCalls.map(e=>ki(e)),c=d.errorCalls.map(e=>ki(e));i.push(...D(n),...l,...c)}if(Ft.includes(d.type)){const n=ry(d),l=mje(d);i.push(...n,...l)}if(Ar.includes(d.type)){const n=ry(d);i.push(...n)}if(d.type===o.Loop){if(d.body){const c=Tl(d.body,p);i.push(...c)}const n=d.errorCalls.map(c=>ki(c)),l=d.successCalls.map(c=>ki(c));i.push(...l,...n)}if(d.type===o.FunctionDeclaration){if(d.collapsed&&p)return[];const n=d.inputs.map(c=>ry(c)).flat(),l=d.calls.map(c=>ki(c));i.push(...D(n),...l)}return D(i)}function hA(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)||[]),yr.includes(d.type)&&i.push(...(d==null?void 0:d.detachedChildren)||[]),d.type===o.DefinitionEntity){const n=[...d.suggestedMethods,...d.methods].flatMap(l=>l.collapsed&&p?[]:hA(l));i.push(...n)}if(d.type===o.Condition){const n=d.successCalls,l=d.errorCalls;i.push(...n,...l)}if(Rc.includes(d.type)){if(d.collapsed&&p)return[];const n=d.inputs.map(c=>ny(c)).flat(),l=d.calls;i.push(...D(n),...l)}if(Vi.includes(d.type)&&d.type!==o.Condition&&d.type!==o.Loop){const n=d==null?void 0:d.outputs.map(e=>ny(e)).flat(),l=d.successCalls,c=d.errorCalls;i.push(...D(n),...l,...c)}if(Ft.includes(d.type)){const n=ny(d),l=Tje(d);i.push(...n,...l)}if(d.type===o.Loop){const n=d.outputs.map(e=>ny(e)).flat();if(d.body){const e=hA(d.body,p);i.push(...e)}const l=d.errorCalls,c=d.successCalls;i.push(...D(n),...c,...l)}if(d.type===o.FunctionDeclaration){if(d.collapsed&&p)return[];const n=d.inputs.map(c=>ny(c)).flat(),l=d.calls;i.push(...D(n),...l)}return D(i)}function mA(d,p=!1){const i=Tl(d,p),n=[...i,...i.reduce((l,c)=>[...l,...mA(c,p)],[])];return D(n)}function Eje(d,p=!1){const i=hA(d,p),n=[...i,...i.reduce((l,c)=>[...l,...Eje(c,p)],[])];return D(n)}function Vv(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,...Vv(i),...Mu(i)]:(i==null?void 0:i.type)===o.BuiltInBaseEntity?[i==null?void 0:i.name,...Mu(i)]:[...p],[])}function Mu(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,...Mu(d.extends),...Vv(d.extends)];if(d.extends.type===o.BuiltInBaseEntity)return[d.extends.name,...Mu(d.extends)]}return[]}function qm(d){var p,i;return d.extends?((p=d.extends)==null?void 0:p.type)===o.DefinitionEntity?[d.extends,...qm(d.extends),...Ux(d.extends)]:((i=d.extends)==null?void 0:i.type)===o.BuiltInBaseEntity?[d.extends,...qm(d.extends)]:[]:[]}function Ux(d){return d.implements.reduce((p,i)=>i.type===o.DefinitionEntity?[...p,i,...Ux(i),...qm(i)]:(i==null?void 0:i.type)===o.BuiltInBaseEntity?[i,...qm(i)]:[...p,i],[])}function Dy(d){return[...Mu(d),...Vv(d)].filter((i,n,l)=>l.indexOf(i)===n)}function Ki(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||[...Mu(d)].includes(p)):!!Dy(d).includes(p)}function bje(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(Ki(d,p))return d;if(d.extends&&d.extends.type!==o.PrimitiveEntity){if(Ki(d.extends,p))return d.extends;if(d.extends.type===o.BuiltInBaseEntity)return sd(d.extends,p)}return null}if(d.extends)return Ki(d.extends,p)?d.extends:sd(d.extends,p);if(d.implements.length>0){for(const i of d.implements)if(i.type===o.BuiltInBaseEntity){if(Ki(i,p))return i;const n=sd(i,p);if(n)return n}else if(i.type===o.DefinitionEntity){const n=sd(i,p);if(n)return n}}return null}function sd(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 sd(d.extends,p)}return null}if(d.extends)return d.extends.name===p?d.extends:sd(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 n=sd(i,p);if(n)return n}else if(i.type===o.DefinitionEntity){const n=sd(i,p);if(n)return n}}return null}function Aje(d){const p=Mp(d),i=[...p,...p.reduce((n,l)=>[...n,...Aje(l)],[])];return D(i)}function jx(d){return d.implements.length===0&&!d.extends?null:d.implements.find(n=>n.type===o.BuiltInBaseEntity&&n.name===Re.PERSISTED_ENTITY)?d:[...d.implements,...d.extends?[d.extends]:[]].reduce((n,l)=>{if(l.type===o.DefinitionEntity){const c=jx(l);if(c)return c}return n},null)}function IUi(d){return d.extends&&d.extends.type===o.BuiltInBaseEntity?d.extends:null}function RUi(d){const p=d.implements.find(i=>i.type===o.BuiltInBaseEntity);return p&&p.type===o.BuiltInBaseEntity?p:null}function P1(d){return d.extends&&d.extends.type===o.DefinitionEntity?d.extends:null}function Fn(d){const p=[...d.implements||[],...d.extends?[d.extends]:[]].reduce((i,n)=>n.type===o.BuiltInBaseEntity?[...i,n,...Fn(n)]:n.type===o.DefinitionEntity?[...i,...Fn(n)]:i,[]);return D(p)}function sf(d){var p;if(d.type===o.PrimitiveEntity)return!0;if(d.type===o.BuiltInBaseEntity)return d.interactive;if(d.type===o.DefinitionEntity)return!Fn(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 sf(d.declaration);return!0}function DUi(d){return[o.DefinitionEntity,o.BuiltInBaseEntity,o.PrimitiveEntity,o.Property,o.InputMap,o.OutputMap].includes(d.type)?sf(d):!0}function OUi(d){return d.parent===d.project&&d.project.variableDeclarations.includes(d)}function kx(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 gje(d){if([...zt,o.DefinitionEntity,o.InstalledProject,o.Project].includes(d.type)||kx(d))return!1;const p=Mp(d);return p.length===0?!0:p.some(i=>gje(i))}function Kx(d){return[...zt,o.DefinitionEntity,o.InstalledProject,o.Project].includes(d.type)||kx(d)?!1:Mp(d).length===0}function Ije(d,p=0){if(Kx(d)){const i=Mp(d);return i.length===0?d:i.map(l=>Ije(l,p+1)).reduce((l,c)=>l?c&&c.x<l.x?c:l:c,null)}return null}function Rje(d){const p=[];if(Kx(d))p.push(d);else return[];return Mp(d).forEach(n=>{p.push(...Rje(n))}),p}function Sx(d){return d.type===o.FunctionDeclaration&&d.parent!==d.project&&!![o.DefinitionEntity,o.Loop,o.InstalledProject].includes(d.parent.type)}function wUi(d,p){const i=new Map;return d.forEach(n=>{i.set(n.id,n)}),p.forEach(n=>{i.set(n.id,n)}),Array.from(i.values())}function Sh(d){switch(d){case o.DefinitionEntity:return ls;case o.FunctionDeclaration:return Ro;case o.VariableDeclaration:return wu;case o.VariableInstance:return Ou;case o.FunctionCall:return Lu;case o.Operation:return Au;case o.Condition:return Ru;case o.ReturnStatement:return ud;case o.Loop:return Iu;case o.Search:return Cu;case o.InputMap:return ss;case o.OutputMap:return El;case o.ArgumentDeclaration:return ya;case o.Property:return Ma;case o.InstalledProject:return _u;case o.Project:return x;case o.DataType:return lr;case o.GlobalEvent:return gu;case o.InternalCall:return Pu;case o.ValueDescriptor:return pd;case o.BuiltInBaseEntity:return Do;case o.PrimitiveEntity:return pa;case o.ActionDescriptor:return Pi;case o.LiteralValue:return Jr;case o.ContinueStatement:return Nu;case o.BreakStatement:return Vu;default:return null}}function dn(d,p,i=null){const n=d!=null&&d.parent?pe(d==null?void 0:d.parent):null;let l=n?p.get(n):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 en(d,p,c);if(d.type===o.FunctionDeclaration&&(l==null?void 0:l.type)===o.Loop)return l;if(zt.includes(d.type))return d;if(d.type===o.Loop)return c.id===d.id?l:d;if(ea.includes(d.type))return null;const e=d.parent;if(!e)return null;if(e.type===o.GenericReference){const y=pe(e);if(!y)return null;const T=p.get(y);return T?dn(T,p,c):null}else return e===p?p:dn(e,p,c)}function en(d,p,i=null){const n=d!=null&&d.parent?pe(d==null?void 0:d.parent):null;let l=n?p.get(n):null,c=i||d;if(d.type===o.FunctionDeclaration&&(l==null?void 0:l.type)===o.Loop)return en(l.parent,p,c);if(zt.includes(d.type))return d;if(ea.includes(d.type))return null;const e=d.parent;if(!e)return null;if(e.type===o.GenericReference){const y=pe(e);if(!y)return null;const T=p.get(y);return T?en(T,p,c):null}else return e===p?p:en(e,p,c)}function cd(d,p){if(ea.includes(d.type))return ie.Logger.warn(`getRootEntryPointScopeOwner is \`null\` because it was called with a built-in entity type: ${d.type}`),null;if(p.getBuiltIn(d.id))return ie.Logger.warn(`getRootEntryPointScopeOwner is \`null\` because it was called with a built-in entity: ${d.id}`),null;const i=Sn(d.parent,p);return i?i===p?yr.includes(d.type)?d:(ie.Logger.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:cd(i,p):(ie.Logger.warn(`getRootEntryPointScopeOwner is \`null\` because it was called with an entity that has no parent: ${d.id}`),null)}function dy(d,p,i){if(d===p||p===i||d===i||!d||!p)return!1;const n=dn(p.parent,i);return n===i?!1:n===d?!0:dy(n,p,i)}var TA=(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))(TA||{});function es(d,p,i){if(!d)throw new Error("[checkScopeCompatibility] No entityA provided for scope compatibility check");if(!p)throw new Error("[checkScopeCompatibility] No entityB provided for scope compatibility check");if(yr.includes(d.type)&&yr.includes(p.type)){if(dy(d,p,i))return{compatible:!0,type:"b-in-a",commonAncestorScope:d};if(dy(p,d,i))return{compatible:!0,type:"a-in-b",commonAncestorScope:p}}const n=dn(d,i),l=dn(p,i);if((d==null?void 0:d.id)===(l==null?void 0:l.id))return{compatible:!0,type:"b-in-a",commonAncestorScope:d};if((p==null?void 0:p.id)===(n==null?void 0:n.id))return{compatible:!0,type:"a-in-b",commonAncestorScope:p};if(!n)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(n===l&&n.type!==o.Project)return{compatible:!0,type:"same-both-local",commonAncestorScope:n};if(n===l&&n.type===o.Project)return{compatible:!0,type:"same-both-global",commonAncestorScope:n};if(dy(n,l,i))return{compatible:!0,type:"b-in-a",commonAncestorScope:n};if(dy(l,n,i))return{compatible:!0,type:"a-in-b",commonAncestorScope:l};if(n.type===o.Project&&l.type!==o.Project)return{compatible:!1,type:"a-is-global-b-is-not",commonAncestorScope:n};if(n.type!==o.Project&&l.type===o.Project)return{compatible:!1,type:"b-is-global-a-is-not",commonAncestorScope:l};const y=ux(n,l);return y===i?{compatible:!1,type:"parallel-in-project",commonAncestorScope:y}:y?{compatible:!1,type:"parallel-in-common-parent",commonAncestorScope:dn(y,i)}:{compatible:!1,type:"parallel-in-project",commonAncestorScope:i}}function Dje(d,p,i){const n=es(d,p,i);if(!n.compatible||n.type!=="same-both-local")return null;if(d===p)return d;let l=dn(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=dn(l.parent,i)}let c=dn(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=dn(c.parent,i)}return null}function Oje(d){return d.length===0?null:d.length===1?d[0]:d.reduce((i,n)=>{const l=Dje(i,n,n.project);return!l||l===n?i:n},d[0])}function Sn(d,p){if(!d)return null;let i;return typeof d=="string"?i=d:d.type===o.GenericReference?i=pe(d):i=d.id,i===p.id?p:p.get(i)}function Bu(d){if(!d)return null;if(ea.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:Bu(p)}function Vm(d){const p=[];function i(c,e){return p.some(y=>y.blockedByCaller===c&&y.blockedByCalling===e)}function n(c,e){i(c,e)||p.push({blockedByCaller:c,blockedByCalling:e})}const l=cd(d,d.project);return l?(d.calledBySuccess.forEach(c=>{[...c.successCalls||[]].forEach(T=>{jt.includes(T.type)&&T.id!==d.id&&(Rt(d).find(b=>b===T)||n(c,T))});let y;if(Vi.includes(c.type)&&(y=c),y){const T=Vm(y);T.reachable||Rt(d).find(b=>b===c)||T.blocks.forEach(b=>{n(c,b.blockedByCalling)})}}),d.calledByError.forEach(c=>{[...c.errorCalls||[]].forEach(T=>{jt.includes(T.type)&&T!==d&&(Rt(d).find(b=>b===T)||n(c,T))});let y;if(Vi.includes(c.type)&&(y=c),y){const T=Vm(y);T.reachable||Rt(d).find(b=>b===c)||T.blocks.forEach(b=>{n(c,b.blockedByCalling)})}}),d.calledByEntry.forEach(c=>{if([...c.calls||[]].forEach(T=>{jt.includes(T.type)&&T!==d&&(Rt(d).find(b=>b===T)||n(c,T))}),c===l)return;let y;if(c.type===o.FunctionDeclaration){const T=ki(c);if(T.type===o.DefinitionEntity)return;T.type===o.Loop&&(y=T)}if(y){const T=Vm(y);T.reachable||T.blocks.forEach(v=>{n(c,v.blockedByCalling)})}}),{reachable:p.length===0,entryPoint:l,blocks:p}):{reachable:!0,entryPoint:null,blocks:[]}}function CUi(d){return Hm.includes(d.type)?d.type===o.FunctionDeclaration?!Sx(d):!0:!1}function _Ui(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 V1(d,p){return d.type===o.BuiltInBaseEntity?d.name===p:!!Mu(d).includes(p)}function PUi(d,p){return d.type===o.BuiltInBaseEntity?d.name===p:!!Vv(d).includes(p)}function VUi(d){const p=[];return d.entities.forEach(i=>{if(V1(i,Re.PERSISTED_ENTITY)){p.push(i);return}}),D(p)}function NUi(d){const p=[];return d.entities.forEach(i=>{if(V1(i,Re.RELATIONAL_DATABASE)){p.push(i);return}}),D(p)}function wje(d){return d.type!==o.DefinitionEntity||d.abstract||!V1(d,Re.PERSISTED_ENTITY)?null:(d==null?void 0:d.properties.find(i=>i.implements.find(n=>n.id===Y[o.BuiltInBaseEntity][Re.PERSISTED_ENTITY].properties.primaryKey.id)&&!i.abstract))||null}function Cje(d){var n;const p=jx(d);if(!p)return null;const i=p.properties.find(l=>l.implements.find(c=>c.id===Y[o.BuiltInBaseEntity][Re.PERSISTED_ENTITY].properties.database.id));return i?(n=i.getDefaultValue())==null?void 0:n.valueAsType:null}function hn(d){if(d.type!==o.DefinitionEntity)return[];if(d.abstract)return[];if(!Ki(d,Re.PERSISTED_ENTITY))return[];const p=[],i=d.properties.filter(n=>!n.implements.find(l=>l.id===Y[o.BuiltInBaseEntity][Re.PERSISTED_ENTITY].properties.database.id)&&!n.abstract);return p.push(...i),p}function xUi(d){var i;if(!d||d.type!==o.DefinitionEntity||!Ki(d,Re.PERSISTED_ENTITY))return null;const p=d.properties.find(n=>!!n.implements.find(l=>l.id===Y[o.BuiltInBaseEntity][Re.PERSISTED_ENTITY].properties.database.id));return(i=p==null?void 0:p.getDefaultValue())==null?void 0:i.valueAsTypeSingle}function Pr(d,p){var n;if(!XU.includes(p.type)||!d)return p.project||null;let i=p.project;return d.type===o.Project?i=d:(((n=p.project)==null?void 0:n.id)!==d.project.id||p.project!==d.project)&&(i=d.project),i}function $Ui(d){switch(d){case o.Project:return x;case o.InstalledProject:return _u;case o.DefinitionEntity:return ls;case o.FunctionDeclaration:return Ro;case o.GlobalEvent:return gu;case o.VariableInstance:return Ou;case o.VariableDeclaration:return wu;case o.InputMap:return ss;case o.OutputMap:return El;case o.Condition:return Ru;case o.Operation:return Au;case o.FunctionCall:return Lu;case o.ArgumentDeclaration:return ya;case o.PrimitiveEntity:return pa;case o.DataType:return lr;case o.Property:return Ma;case o.ActionDescriptor:return Pi;case o.ReturnStatement:return ud;case o.ContinueStatement:return Nu;case o.BreakStatement:return Vu;case o.Loop:return Iu;case o.Search:return Cu;case o.ValueDescriptor:return pd;case o.InternalCall:return Pu;case o.LiteralValue:return Jr}return null}function LUi(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 xr(d,p){const i=Sh(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,T)=>y===e[T]):!1}):!1}function $r(d,p,i){let n={...p};if(!d.checkCanEdit(d,i)){const l=Sh(d.type);if(!l)return n;l.MUTABLE_META_PROPERTIES.forEach(c=>{["x","y","collapsed"].includes(c)||delete n[c]})}return n}function Nv(d,p={}){if(d.type===o.Project)return[];if(!d.parent)return[];const i=pe(d.parent);if(!i)return[];const n=p[i];return n?[n.id,...Nv(n,p)]:[]}function MUi(d){const p=[],i=new Set;return[...d.listAdded,...d.listUpdated,...d.listAffected].forEach(l=>{var y;const c=ki(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} ${pe(c.parent)}`:""}`);i.add(c.id),i.add(l.id),p.push(e)}),D(p)}function BUi(d){if(d.type===o.Condition)return null;if(d.type===o.Search)return d.project.getBuiltIn(Y["value-descriptor"][OA.SearchErrorOutputDescriptor].id)||null;if(d.type===o.Operation)return d.declaration.error;if(d.type===o.FunctionCall){const i=d.declaration.returnStatements.find(n=>!!n.throws);return(i==null?void 0:i.throws)||null}return null}function _je(d){const p=d.entities.filter(l=>!!l.implements.find(c=>c.id===Y["built-in-base-entity"].BUILT_IN_RELATIONAL_DATABASE_ENTITY.id)),i=p.find(l=>{const c=l.properties.find(T=>T.implements.find(v=>v.id===Y["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 nC(d,p){const i=Array.from(new Set([...p.getAllBuiltInIds(),...Yi()]));return!!(i.includes(d.id)||!Nv(d,{...p.instances,...p.builtInInstances}).every(c=>!i.includes(c)))}function Pje(d){if(!d)return null;if(d.type===o.Project)return d.id;const p=d.parent;return p?Pje(p):d.id}function xv(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=ki(d),i=cd(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 aC(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=ki(d),i=cd(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 GUi(d,p,i){const n=p,l=i,c=!!i,e=[];return n.forEach(y=>{var T;if(c){const v=es(l,y,d);if(!v.compatible&&v.type!=="b-is-global-a-is-not")return;e.push(y)}else{if(((T=y.parent)==null?void 0:T.type)!==o.Project)return;e.push(y)}}),D(e)}function sC(d,p){var i,n,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(((n=d.extends)==null?void 0:n.id)===p.id)return d;if(d.extends){const e=sC(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=sC(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 Hd(d){var p;return!!(d.required||(p=d.declaration)!=null&&p.required)}function fd(d){return d==null||d===""}function fl(d){return d?d.valueAsType?!1:fd(d.value):!0}function N1(d,p,i,n=new Set,l=Array.from(new Set([...d.project.getAllBuiltInIds(),...Yi()]))){if(n.has(d.id)||l.includes(d.id))return;n.add(d.id),d.editable=i,d.deletable=i,p.add(d,H.Updated);const{downstream:c}=ld(d,d.project.instances,{ignoreBuiltInBaseEntities:!0,allBuiltInEntityIds:l});Object.keys(c).forEach(e=>{const y=d.project.get(e);y&&N1(y,p,i,n,l)})}function UUi(d,p,i=new Set,n=Array.from(new Set([...d.project.getAllBuiltInIds(),...Yi()]))){N1(d,p,!0,i,n)}function jUi(d,p,i=new Set,n=Array.from(new Set([...d.project.getAllBuiltInIds(),...Yi()]))){N1(d,p,!1,i,n)}function Vje(d,p=[]){return D(Ao(d)).filter(n=>!p.includes(n.id))}function $v(d){return d.replace(/["'`]/g,"")}function Wi(d){const i=$v(d).split(/[\s-]+/).filter(e=>e.length>0);if(i.length===0)return"";const n=i[0],l=n[0].toLowerCase()+n.slice(1),c=i.slice(1).map(e=>e[0].toUpperCase()+e.slice(1));return[l,...c].join("")}function Ic(d){return $v(d).split(/[\s-]+/).filter(n=>n.length>0).map(n=>n[0].toUpperCase()+n.slice(1)).join("")}function Nje(d){const p=$v(d).trim();if(!p)return"";const i=p.replace(/[\s_-]+/g," ").split(" ").filter(Boolean),n=[];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&&n.push(e)}return n.join("-")}function kUi(d){const p=$v(d).trim();if(!p)return"";const i=p.replace(/[\s_-]+/g," ").split(" ").filter(Boolean),n=[];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&&n.push(e)}return n.join("_")}function vA(d){return Nje(d).toLowerCase()}function Fx(d){const p=$v(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 Oy(d){var i,n,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)&&!((n=d.orChildrenGroup)!=null&&n.length)&&(p=" as template"),d.foreignKeyRef){const e=d.isList,y=se(d.foreignKeyRef,d.project),T=se(d.foreignKeyRef.parent,d.project);return e?`List references to "${y}" from "${T}"${p}`:`Reference to "${y}" from "${T}"${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="",T=!1,v=!1;return(d.andChildrenGroup||[]).forEach(E=>{const b=Oy(E),O=yc(b);T&&(y+=" and "),E.isGroup?y+="("+O+")":T?y+=O:y+=b,T=!0,v=!0}),(d.orChildrenGroup||[]).forEach(E=>{const b=Oy(E),O=yc(b);T&&(v&&(y+=","),y+=" or "),E.isGroup?y+="("+O+")":T?y+=O:y+=b,T=!0}),e?`List of ${yc(y)}`:y}}if(d.entity.type===o.PrimitiveEntity){let e=d.entity.name;switch(d.entity.name){case le.String:e="Text";break;case le.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=se(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=$je(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===le.Null)return"Empty value";if(d.entity.name===le.Untyped)return"Untyped value";if(d.entity.name===le.File)return"File";if(d.entity.name===le.String)return`"${d.entity.value}" text`;if(d.entity.name===le.Number)return`Number '${d.entity.value}'`;if(d.entity.name===le.Boolean)return`${d.entity.value} value`;if(d.entity.name===le.UUID)return`"${d.entity.value}" unique identifier`;if(d.entity.name===le.Date)return`"${d.entity.value}" date`}return d.isList?`List of ${se(d.entity,d.project)} values${p}`:`${se(d.entity,d.project).slice(0,1).toUpperCase()+se(d.entity,d.project).slice(1)} value${p}`}function KUi(d){if(!d)return"Any data type";const p=d.getDataType(null);return Oy(p)}function Zb(d){switch(d.declaration.id){case Pt.PrimitiveEqual:return"is equal to";case Pt.PrimitiveNotEqual:return"is not equal to";case Pt.Empty:return"is empty";case Pt.NotEmpty:return"is present";case ee.MoreThan:return"is greater than";case ee.MoreThanOrEqual:return"is greater than or equal to";case ee.LessThan:return"is less than";case ee.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 Qr.BooleanIsFalse:return"is false";case Qr.BooleanIsTrue:return"is true";case sr.And:return"and";case sr.Or:return"or"}}function xje(d){if(d.includes(Re.HTTP_ENDPOINT))return"HTTP endpoint";if(d.includes(Re.PERSISTED_ENTITY))return"Persisted entity";if(d.includes(Re.CRON_JOB))return"Scheduled execution";if(d.includes(Re.RELATIONAL_DATABASE))return"Relational database";if(d.includes(Re.SQL_ROW_TRANSFORMER))return"Row transformer";if(d.includes(Re.GOOGLE_AUTH_CONNECTION))return"Google account connection";if(d.includes(Re.SLACK_AUTH_CONNECTION))return"Slack account connection";if(d.includes(Re.AIRTABLE_AUTH_CONNECTION))return"Airtable account connection";if(d.includes(Re.MICROSOFT_AUTH_CONNECTION))return"Microsoft account connection";if(d.includes(Re.OPENAI_AUTH_CONNECTION))return"OpenAI account connection";if(d.includes(Re.ATLASSIAN_AUTH_CONNECTION))return"Atlassian account connection";if(d.includes(Re.JIRA_AUTH_CONNECTION))return"Jira account connection";if(d.includes(Re.GOOGLE_DRIVE_AUTH_CONNECTION))return"Google Drive account connection";if(d.includes(Re.GOOGLE_MAIL_AUTH_CONNECTION))return"Gmail account connection";if(d.includes(Re.GOOGLE_SHEET_AUTH_CONNECTION))return"Google Sheet account connection";if(d.includes(Re.GOOGLE_SLIDES_AUTH_CONNECTION))return"Google Slides account connection";if(d.includes(Re.GOOGLE_GEMINI_AUTH_CONNECTION))return"Google Gemini account connection";if(d.includes(Re.EXTERNAL_INTEGRATION_CONNECTION))return"External integration connection";try{return Fx(d[0])}catch(p){return ie.Logger.error("Error resolving base entity name for base entities:",d,p),"Built-in base entity"}}function $je(d){switch(d.name){case Re.HTTP_ENDPOINT:return"HTTP endpoint";case Re.PERSISTED_ENTITY:return"Persisted entity";case Re.CRON_JOB:return"Scheduled execution";case Re.RELATIONAL_DATABASE:return"Relational database";case Re.SQL_ROW_TRANSFORMER:return"Row transformer";case Re.GOOGLE_AUTH_CONNECTION:return"Google account connection";case Re.SLACK_AUTH_CONNECTION:return"Slack account connection";case Re.AIRTABLE_AUTH_CONNECTION:return"Airtable account connection";case Re.MICROSOFT_AUTH_CONNECTION:return"Microsoft account connection";case Re.OPENAI_AUTH_CONNECTION:return"OpenAI account connection";case Re.ATLASSIAN_AUTH_CONNECTION:return"Atlassian account connection";case Re.JIRA_AUTH_CONNECTION:return"Jira account connection";case Re.GOOGLE_DRIVE_AUTH_CONNECTION:return"Google Drive account connection";case Re.GOOGLE_MAIL_AUTH_CONNECTION:return"Gmail account connection";case Re.GOOGLE_SHEET_AUTH_CONNECTION:return"Google Sheet account connection";case Re.GOOGLE_SLIDES_AUTH_CONNECTION:return"Google Slides account connection";case Re.GOOGLE_GEMINI_AUTH_CONNECTION:return"Google Gemini account connection";case Re.EXTERNAL_INTEGRATION_CONNECTION:return"External integration connection";case Re.EXTERNAL_INTEGRATION_CONNECTION:return"External integration connection"}try{return Fx(d.name)}catch(p){return ie.Logger.error("Error resolving built-in base entity data type label for entity:",d,p),"Built-in base entity"}}function SUi(d){const p=P1(d);if(!p){const i=Dy(d);return i.includes(Re.HTTP_ENDPOINT)?"HTTP endpoint":i.includes(Re.PERSISTED_ENTITY)?"Persisted entity":i.includes(Re.CRON_JOB)?"Scheduled execution":i.includes(Re.RELATIONAL_DATABASE)?"Relational database":i.includes(Re.SQL_ROW_TRANSFORMER)?"Row transformer":i.includes(Re.GOOGLE_AUTH_CONNECTION)?"Google account connection":i.includes(Re.SLACK_AUTH_CONNECTION)?"Slack account connection":i.includes(Re.AIRTABLE_AUTH_CONNECTION)?"Airtable account connection":i.includes(Re.MICROSOFT_AUTH_CONNECTION)?"Microsoft account connection":i.includes(Re.OPENAI_AUTH_CONNECTION)?"OpenAI account connection":i.includes(Re.ATLASSIAN_AUTH_CONNECTION)?"Atlassian account connection":i.includes(Re.JIRA_AUTH_CONNECTION)?"Jira account connection":i.includes(Re.EXTERNAL_INTEGRATION_CONNECTION)?"External integration connection":se(d,d.project)+" entity"}return se(p,d.project)+" entity"}function Lje(d){let p="Find ";return d.outputs.forEach((i,n)=>{const l=u1(i,null),c=yc(l&&l.entity?se(l.entity,d.project):"unstructured data");n===0?p+=`${c} `:n===d.outputs.length-1?p+=`and ${c} `:p+=`, ${c} `}),p}function Mje(d){switch(d.name){case le.String:return"Text";case le.Number:return"Number";case le.Boolean:return"Boolean";case le.KeyValue:return"Data structure";case le.UUID:return"Unique identifier";case le.Date:return"Date";case le.EntityTemplate:return"Entity as template";case le.Enum:return"Enumeration";case le.File:return"File";case le.Null:return"Empty";case le.ActionDescriptor:return"Action descriptor";case le.Untyped:return"Untyped";default:return d.name}}function Bje(d){switch(d.id){case st.List:return"Loop over list items";case st.ManualFlow:return"Manual flow control loop";case st.ObjectKeys:return"Loop over object keys";case st.ObjectValues:return"Loop over object values";case st.Counted:return"Loop given number of times";case st.String:return"Loop over text characters";case Pt.PrimitiveEqual:return"is equal to";case Pt.PrimitiveNotEqual:return"is not equal to";case Pt.Empty:return"is empty";case Pt.NotEmpty:return"is present";case Ce.DeleteKey:return"Delete property from object";case Ce.DeleteNestedKey:return"Delete nested property from object";case Ce.HasKey:return"Check if object has property";case Ce.HasNestedKey:return"Check if object has nested property";case Ce.IsInstanceOfType:return"Check if object is instance of type";case Ce.KeyValueEquals:return"Check if object property equals value";case Ce.NestedKeyValueEquals:return"Check if object nested property equals value";case Ce.ReadKey:return"Read property from object";case Ce.ReadNestedKey:return"Read nested property from object";case Ce.Validate:return"Validate object structure";case Ce.WriteKey:return"Write property to object";case Ce.WriteNestedKey:return"Write nested property to object";case Ce.WriteSafeNestedKeyRecursively:return"Write safe nested property to object recursively";case Ce.Merge:return"Merge objects";case Ce.Entries:return"Get a list with the object keys, and values";case Ce.Keys:return"Get a list with the object keys";case Ce.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 ee.Addition:return"Sum numbers";case ee.Subtraction:return"Subtract numbers";case ee.Multiplication:return"Multiply numbers";case ee.Division:return"Divide numbers";case ee.Remainder:return"Get remainder of numbers";case ee.Absolute:return"Get absolute value of numbers";case ee.Acos:return"Get arc cosine of numbers";case ee.Asin:return"Get arc sine of numbers";case ee.Atan:return"Get arc tangent of numbers";case ee.Ceil:return"Round numbers up";case ee.Cos:return"Get cosine of numbers";case ee.Floor:return"Round numbers down";case ee.LogNatural:return"Get natural logarithm of numbers";case ee.Log10:return"Get base-10 logarithm of numbers";case ee.MaxOf:return"Get maximum of numbers";case ee.MinOf:return"Get minimum of numbers";case ee.Round:return"Round numbers to nearest integer";case ee.Sin:return"Get sine of numbers";case ee.SquareRoot:return"Get square root of numbers";case ee.Tan:return"Get tangent of numbers";case ee.Negate:return"Negate numbers";case ee.Atan2:return"Get arc tangent of two numbers";case ee.Exp:return"Get exponential of numbers";case ee.Average:return"Get average of numbers";case ee.Clamp:return"Clamp numbers within range";case ee.CubeRoot:return"Get cube root of numbers";case ee.LessThan:return"Check if numbers are less than";case ee.LessThanOrEqual:return"Check if numbers are less than or equal to";case ee.MoreThan:return"Check if numbers are more than";case ee.MoreThanOrEqual:return"Check if numbers are more than or equal to";case ee.MapRange:return"Map numbers from one range to another";case ee.Median:return"Get median of numbers";case ee.NthRoot:return"Get nth root of numbers";case ee.PercentOf:return"Get percentage of numbers";case ee.PercentageChange:return"Get percentage change between numbers";case ee.RoundToDecimals:return"Round numbers to given decimal places";case ee.Sign:return"Get sign of numbers";case ee.SnapToStep:return"Snap numbers to nearest step";case ee.ToDegrees:return"Convert numbers to degrees";case ee.ToRadians:return"Convert numbers to radians";case ee.Trunc:return"Truncate numbers";case ee.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 Mi.Wait:return"Wait";case Mi.Parallel:return"Run in parallel";case Mi.Sequential:return"Run in sequence";case Zn.HttpRequest:return"HTTP request";case Yr.Parse:return"Parse JSON text";case Yr.Stringify:return"Convert to JSON text";case ii.ConstantTimeEqual:return"Compare values in constant time";case ii.Hash:return"Hash value";case ii.Hmac:return"Create HMAC";case ii.DeriveKeyPBKDF2:return"Derive key with PBKDF2";case Xr.HashPasswordPBKDF2:return"Hash password with PBKDF2";case Xr.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 te.AddAtIndex:return"Add item at index position";case te.DeleteFirstNItems:return"Delete first items";case te.DeleteLastNItems:return"Delete last items";case te.DeleteAtIndex:return"Delete items at index position";case te.Join:return"Join lists";case te.ReplaceFirstNItems:return"Replace first match";case te.ReplaceLastNItems:return"Replace last match";case te.Split:return"Split list";case te.ReplaceAtIndex:return"Replace at index position";case te.GetFirst:return"Get first item";case te.GetLast:return"Get last item";case te.GetIndexItem:return"Get item at index position";case te.Append:return"Add item at the end";case te.Prepend:return"Add item at the start";case te.Chunk:return"Chunk list into smaller lists";case te.Shuffle:return"Randomize order of list items";case te.Reverse:return"Reverse order of list items";case te.GetFirstNItems:return"Get the first given number of items";case te.GetLastNItems:return"Get the last given number of items";case te.Sort:return"Order list items";case te.Unique:return"Get a new list without duplicate values";case te.Concat:return"Combine lists";case te.Slice:return"Get a portion of the list";case te.Contains:return"Check if list contains value";case te.ContainsAll:return"Check if list contains all values";case te.ContainsAny:return"Check if list contains any value";case te.Flatten:return"Flatten nested lists into a single list";case te.GetIndexOf:return"Get the index position number of the item";case te.GetLastIndexOf:return"Get the last index position number of the item";case te.GetLength:return"Get number of items in list";case te.PadEnd:return"Pad list at the end";case te.PadStart:return"Pad list at the start";case te.Repeat:return"Create a list by repeating an item";case te.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 Xe.GenerateHexadecimalToken:return"Generate hexadecimal token";case Xe.GenerateIdentifier:return"Generate unique identifier";case Xe.GenerateRandomAlphanumeric:return"Generate random alphanumeric text";case Xe.GenerateRandomBase62:return"Generate random Base62 text";case Xe.GenerateRandomBase64:return"Generate random Base64 text";case Xe.GenerateRandomBytes:return"Generate random bytes";case Xe.GenerateRandomFloat:return"Generate random decimal number";case Xe.GenerateRandomInteger:return"Generate random whole number";case Xe.GenerateRandomHexadecimal:return"Generate random hexadecimal text";case Xe.GenerateRandomUUIDv4:return"Generate random UUID v4";case Xe.GenerateShortIdentifier:return"Generate short unique identifier";case vl.PROJECT_PUBLICATION_COMPLETED:return"Project publication completed";case Pt.PrimitiveEqual:return"Values are equal";case Pt.PrimitiveNotEqual:return"Values are not equal";case Pt.Empty:return"Value is empty";case Pt.NotEmpty:return"Value is not empty";default:return(d.name.slice(0,1).toUpperCase()+d.name.slice(1)).replaceAll("-"," ")}}function se(d,p){var i;if(o.FunctionDeclaration===d.type){const n=d.name;if(Object.values(Mr).includes(n))switch(n){case Mr.AbortExecution:return"Abort ongoing execution";case Mr.DeletePersistedEntity:return"Delete entry from database";case Mr.CreatePersistedEntity:return"Save new data entry in database";case Mr.UpdatePersistedEntity:return"Update entity data to database";case Mr.DownSQLRowTransformer:return"Reverse row";case Mr.UpSQLRowTransformer:return"Transform row";default:return Sr(d.type).replaceAll("-"," ")}return n}if(o.BuiltInBaseEntity===d.type)return xje([d.name]);if(YU.includes(d.type)&&d.type!==o.ActionDescriptor)return d.name;switch(d.type){case o.Search:return Lje(d);case o.GlobalEvent:return d.implements?se(d.implements,p):Sr(d.type).replaceAll("-"," ");case o.Operation:case o.InternalCall:case o.Loop:const n=Sn(d.declaration,p);return se(n,p);case o.ActionDescriptor:return Bje(d);case o.BreakStatement:const l=Sn(d.parent,p);return`Stop loop ${se(l,p)}`;case o.ContinueStatement:const c=Sn(d.parent,p);return`Execute next iteration of ${se(c,p)}`;case o.FunctionCall:return Sn(d.declaration,p).name;case o.Condition:{const y=d;if(y.declaration.id===sr.And)return"If all conditions are met";if(y.declaration.id===sr.Or)return"If any condition is met";if((i=d.inputs)!=null&&i.length){const T=se(y.inputs[0],y.project);if(y.inputs[1]){const v=y.inputs[1].declaration.name;return`If ${T} ${Zb(y)} ${v}`}return`If ${T} ${Zb(y)}`}else return`If ${Zb(y)}`}case o.ReturnStatement:{const y=Sn(d.parent,p);return y?`Output of ${se(y,p)}`:"Return statement"}case o.InputMap:if(d.declaration){const y=Sn(d.declaration,p);return se(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=Sn(d.declaration,p);return se(y,p)||""}case o.OutputMap:if(d.declaration){const y=Sn(d.declaration,p);return(y==null?void 0:y.name)||""}else return d.parentRelationType===fu.Error?"Undeclared error":"";case o.PrimitiveEntity:case o.LiteralValue:return Mje(d);default:return Sr(d.type).replaceAll("-"," ")}}function qx(d,p){const i=[];d.name||i.push(new De({id:`${d.id}--${Ie.EmptyName}`,message:`Entity with id "${d.id}" and type "${d.type}" has an empty name. Please provide a 'name' string.`,severity:ue.Error,code:Ie.EmptyName}));const n=p.entities.filter(l=>l.name===d.name);return n.length&&i.push(new De({id:`${d.id}--${Ie.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 "${n[0].id}" has the same name.
|
|
378
378
|
Please provide a unique 'name' string.`,severity:ue.Error,code:Ie.NameNotUniqueInScope})),i}function Zx(d,p){const i=[];d.name||i.push(new De({id:`${d.id}--${Ie.EmptyName}`,message:`Entity with id "${d.id}" and type "${d.type}" has an empty name. Please provide a 'name' string.`,severity:ue.Error,code:Ie.EmptyName}));const n=d.parent?pe(d.parent):null;let l=p;n&&(l=p.get(n));const c=[];l.type===o.DefinitionEntity?c.push(...l.methods.map(y=>y)):l.type===o.Project?c.push(...l.functions.map(y=>y)):l.type===o.Loop?l.body&&c.push(l.body):l.type===o.InstalledProject&&c.push(...l.functions.map(y=>y));const e=c.filter(y=>y.name===d.name);return e.length&&i.push(new De({id:`${d.id}--${Ie.NameNotUniqueInScope}`,message:`Entity with id "${d.id}" and type "${d.type}" has a name "${d.name}" that is not unique in ${l.type===o.Project?"the globally declared project scope":"its parent entity"}. Entity with id "${e[0].id}" has the same name.
|
|
379
379
|
Please provide a unique 'name' string.`,severity:ue.Error,code:Ie.NameNotUniqueInScope})),i}function Hx(d,p){const i=[];d.name||i.push(new De({id:`${d.id}--${Ie.EmptyName}`,message:`Entity with id "${d.id}" and type "${d.type}" has an empty name. Please provide a 'name' string.`,severity:ue.Error,code:Ie.EmptyName}));const n=d.parent&&Sn(d.parent,p)||p;if(!n)i.push(new De({id:`${d.id}--parent-reference--${re.ReferencedEntityNotFound}`,message:`The entity with id '${d.parent}' that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,severity:ue.Error,code:re.ReferencedEntityNotFound}));else{const c=jN(n).filter(e=>e.name===d.name);c.length&&i.push(new De({id:`${d.id}--${Ie.NameNotUniqueInScope}`,message:`Entity with id "${d.id}" and type "${d.type}" has a name "${d.name}" that is not unique in its scope or higher scopes. Entity with id "${c[0].id}" has the same name.
|
|
380
380
|
Please provide a unique 'name' string.`,severity:ue.Error,code:Ie.NameNotUniqueInScope}))}return i}function Wx(d,p){const i=[];d.name||i.push(new De({id:`${d.id}--${Ie.EmptyName}`,message:`Entity with id "${d.id}" and type "${d.type}" has an empty name. Please provide a 'name' string.`,severity:ue.Error,code:Ie.EmptyName}));const n=pe(d.parent);if(!n)i.push(new De({id:`${d.id}--parent-reference--${re.InvalidReferenceObjectStructure}`,message:`Reference object at 'parent' property for entity with id "${d.id}" and type "${d.type}" is not a valid reference. A reference needs to be a 'id' string of an existing entity in the project.`,severity:ue.Error,code:re.InvalidReferenceObjectStructure}));else{const l=p.get(n);if(!l)i.push(new De({id:`${d.id}--parent-reference--${re.ReferencedEntityNotFound}`,message:`The entity with id '${n}' that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,severity:ue.Error,code:re.ReferencedEntityNotFound}));else{const e=l.properties.filter(y=>y.name===d.name);e.length&&i.push(new De({id:`${d.id}--${Ie.NameNotUniqueInScope}`,message:`Entity with id "${d.id}" and type "${d.type}" has a name "${d.name}" that is not unique among all properties in the parent entity. Entity with id "${e[0].id}" has the same name.
|
package/dist/index.js
CHANGED
|
@@ -182657,37 +182657,34 @@ function Vf(d, p, i = !1) {
|
|
|
182657
182657
|
};
|
|
182658
182658
|
if (T.length === 1) {
|
|
182659
182659
|
const Z = T[0];
|
|
182660
|
-
if (Z.type === o.Loop)
|
|
182661
|
-
|
|
182660
|
+
if (Z.type === o.Loop && Z.body.calls.includes(n))
|
|
182661
|
+
return {
|
|
182662
|
+
ancestor: Z,
|
|
182663
|
+
callType: "loop-body"
|
|
182664
|
+
};
|
|
182665
|
+
if (zt.includes(Z.type))
|
|
182666
|
+
return Z.type === o.FunctionDeclaration && Z.parent.type === o.Loop ? {
|
|
182667
|
+
ancestor: Z.parent,
|
|
182668
|
+
callType: "loop-body"
|
|
182669
|
+
} : {
|
|
182670
|
+
ancestor: Z,
|
|
182671
|
+
callType: "entry"
|
|
182672
|
+
};
|
|
182673
|
+
if (Pi.includes(Z.type)) {
|
|
182674
|
+
if (Z.successCalls.includes(
|
|
182675
|
+
n
|
|
182676
|
+
))
|
|
182662
182677
|
return {
|
|
182663
182678
|
ancestor: Z,
|
|
182664
|
-
callType: "
|
|
182679
|
+
callType: "success"
|
|
182665
182680
|
};
|
|
182666
|
-
|
|
182667
|
-
|
|
182668
|
-
|
|
182669
|
-
|
|
182670
|
-
callType: "loop-body"
|
|
182671
|
-
} : {
|
|
182681
|
+
if (Z.errorCalls.includes(
|
|
182682
|
+
n
|
|
182683
|
+
))
|
|
182684
|
+
return {
|
|
182672
182685
|
ancestor: Z,
|
|
182673
|
-
callType: "
|
|
182686
|
+
callType: "error"
|
|
182674
182687
|
};
|
|
182675
|
-
if (Pi.includes(Z.type)) {
|
|
182676
|
-
if (Z.successCalls.includes(
|
|
182677
|
-
n
|
|
182678
|
-
))
|
|
182679
|
-
return {
|
|
182680
|
-
ancestor: Z,
|
|
182681
|
-
callType: "success"
|
|
182682
|
-
};
|
|
182683
|
-
if (Z.errorCalls.includes(
|
|
182684
|
-
n
|
|
182685
|
-
))
|
|
182686
|
-
return {
|
|
182687
|
-
ancestor: Z,
|
|
182688
|
-
callType: "error"
|
|
182689
|
-
};
|
|
182690
|
-
}
|
|
182691
182688
|
}
|
|
182692
182689
|
}
|
|
182693
182690
|
const v = jt.includes(n.type) ? [] : Rt(n), b = e.filter((Z) => !(jt.includes(Z.callee.type) || Z.callee === n || !Rt(
|
|
@@ -182980,7 +182977,10 @@ function jUi(d) {
|
|
|
182980
182977
|
);
|
|
182981
182978
|
if (!T.ancestor)
|
|
182982
182979
|
throw new Error(
|
|
182983
|
-
`[getEarliestSingleCallerAncestorOfValueWriterAndItsValueReaders]
|
|
182980
|
+
`[getEarliestSingleCallerAncestorOfValueWriterAndItsValueReaders] Entity: ${d.id} - ${se(
|
|
182981
|
+
d,
|
|
182982
|
+
d.project
|
|
182983
|
+
)} - Could not be resolved, no ancestor found for entity ${y.id} -- ${se(y, p.project)}`
|
|
182984
182984
|
);
|
|
182985
182985
|
return T;
|
|
182986
182986
|
}).filter(
|
|
@@ -183005,7 +183005,10 @@ function jUi(d) {
|
|
|
183005
183005
|
};
|
|
183006
183006
|
if (e.length > 1)
|
|
183007
183007
|
throw new Error(
|
|
183008
|
-
`getEarliestSingleCallerAncestorOfValueWriterAndItsValueReaders:
|
|
183008
|
+
`[getEarliestSingleCallerAncestorOfValueWriterAndItsValueReaders] Entity: ${d.id} - ${se(
|
|
183009
|
+
d,
|
|
183010
|
+
d.project
|
|
183011
|
+
)} - Could not be resolved, multiple candidates found: ${e.map(
|
|
183009
183012
|
(y) => se(
|
|
183010
183013
|
y.ancestor,
|
|
183011
183014
|
p.project
|
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.6669",
|
|
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",
|