@memoarchitect/architect 0.4.6 → 0.6.2
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/README.md +44 -3
- package/dist/assets/AskPanel-Dqc6aaqg.js +1 -0
- package/dist/assets/ComplianceWizard-Bi9PLmJH.js +1 -0
- package/dist/assets/{DSMView-B4IEz19F.js → DSMView-DbC_fUKT.js} +1 -1
- package/dist/assets/{Dashboard-DNRzU1Hk.js → Dashboard-6Dgma4kY.js} +1 -1
- package/dist/assets/DhfDashboard-BPXIYJnw.js +1 -0
- package/dist/assets/{DhfSettingsPanel-C89T0dv7.js → DhfSettingsPanel-jQ5mh_50.js} +1 -1
- package/dist/assets/{DhfWorkbench-4gHayn-l.js → DhfWorkbench-CgFdQIts.js} +3 -3
- package/dist/assets/DiagramCanvas-CIfN1ybl.js +1 -0
- package/dist/assets/DiagramEditor-Y4sSx9nO.js +4 -0
- package/dist/assets/ElementDetailView-B946aM3p.js +2 -0
- package/dist/assets/{ImportView-t1dIoZF5.js → ImportView-HCDzL9Xx.js} +1 -1
- package/dist/assets/{LayerGrid-fSGvqSEj.js → LayerGrid-DSxAFwPk.js} +1 -1
- package/dist/assets/{LayerTable-D8QCFY1b.js → LayerTable-C5VBpm6T.js} +2 -2
- package/dist/assets/{MaxGraphCanvas-DYs6MPuP.js → MaxGraphCanvas-B7tAFvDf.js} +6 -6
- package/dist/assets/{ModelDiff-CLFqnELG.js → ModelDiff-MM5NKKXK.js} +1 -1
- package/dist/assets/OntologyDecompositionDiagram-CAzu3z_q.js +1 -0
- package/dist/assets/{OntologyViewer-72jTw72H.js → OntologyViewer-C5ik2Kmi.js} +2 -2
- package/dist/assets/{RelationshipOverlay-BDrBRSPP.js → RelationshipOverlay-DSzjs5U7.js} +1 -1
- package/dist/assets/{RelationshipsSection-D1-tuVYo.js → RelationshipsSection-2CEoiF6o.js} +1 -1
- package/dist/assets/{ReviewDashboard-BVOe2I5w.js → ReviewDashboard-DwlsAVBa.js} +1 -1
- package/dist/assets/ScenarioEditor-BRWvcD2f.js +3 -0
- package/dist/assets/{StatisticsDashboard-Dn6lsnKe.js → StatisticsDashboard-C67W4pb0.js} +1 -1
- package/dist/assets/{SysmlCodeEditor-BLcw6hdp.js → SysmlCodeEditor-CGOcUFE7.js} +1 -1
- package/dist/assets/SysmlGenerator-BwRhtec-.js +1 -0
- package/dist/assets/{TabularView-B99xy3H3.js → TabularView-CTQgMG25.js} +1 -1
- package/dist/assets/TraceabilityMatrix-Bw5ej-So.js +1 -0
- package/dist/assets/{WorkflowWizard-C38DZKOe.js → WorkflowWizard-BwGWzMkE.js} +1 -1
- package/dist/assets/index-D0i9ua6F.js +3277 -0
- package/dist/assets/index-DPzXL4uF.css +1 -0
- package/dist/assets/{layout-providers-BAUgp0nu.js → layout-providers-BFnfta4Z.js} +13 -13
- package/dist/assets/layout-selection-BTId1JyG.js +1 -0
- package/dist/assets/{reactflow-WKyu73tD.js → reactflow-CX-HDacK.js} +1 -1
- package/dist/index.html +3 -3
- package/lib/bin/memo-architect.js +39 -3
- package/lib/bin/memo-architect.js.map +1 -1
- package/lib/commands/dev.d.ts.map +1 -1
- package/lib/commands/dev.js +9 -0
- package/lib/commands/dev.js.map +1 -1
- package/lib/commands/example.d.ts +16 -0
- package/lib/commands/example.d.ts.map +1 -0
- package/lib/commands/example.js +143 -0
- package/lib/commands/example.js.map +1 -0
- package/package.json +5 -4
- package/dist/assets/AskPanel-D9_AKyYt.js +0 -1
- package/dist/assets/ComplianceWizard-BNvT_ic6.js +0 -1
- package/dist/assets/DhfDashboard-DguH-rDT.js +0 -1
- package/dist/assets/DiagramCanvas-BgfO0AtP.js +0 -1
- package/dist/assets/DiagramEditor-CEr6iqBf.js +0 -4
- package/dist/assets/DiagramSurface-B_lfUNzV.js +0 -2
- package/dist/assets/ElementDetailView-AclSjurg.js +0 -2
- package/dist/assets/OntologyDecompositionDiagram-cpmTTMRH.js +0 -1
- package/dist/assets/ScenarioEditor-CvOkiRC6.js +0 -3
- package/dist/assets/SysmlGenerator-CfBQWovl.js +0 -1
- package/dist/assets/TraceabilityMatrix-BAJb0X7G.js +0 -1
- package/dist/assets/index-CgRwea72.js +0 -3277
- package/dist/assets/index-CnFhl4_e.css +0 -1
- package/dist/assets/layout-selection-BQ2WuAEB.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{f as Be,E as ne,R as He,t as kt,F as ue,V as rn,u as nt,v as xn}from"./index-D0i9ua6F.js";import{r as wn,D as In}from"./layout-providers-BFnfta4Z.js";import{j as O}from"./reactflow-CX-HDacK.js";import{a as ye}from"./zustand-qbFpP9Up.js";const Ve=new Set(["composedOf","composes","decomposedBy","aggregation"]);function rt(t,e){const n=new Map;for(const l of t)n.set(l.id,l);const o=new Map,s=new Set;for(const l of e)Ve.has(l.type)&&(!n.has(l.sourceId)||!n.has(l.targetId)||l.sourceId!==l.targetId&&(s.has(l.targetId)||(o.has(l.sourceId)||o.set(l.sourceId,[]),o.get(l.sourceId).push(l.targetId),s.add(l.targetId))));return{roots:[...n.keys()].filter(l=>!s.has(l)),childrenMap:o,elements:n}}function Xs(t){if(t.elements.size===0)return null;const e=new Set,n=s=>{if(!e.has(s)){e.add(s);for(const c of t.childrenMap.get(s)??[])n(c)}};t.roots[0]&&n(t.roots[0]);const o=[...t.elements.keys()].filter(s=>!e.has(s));return t.roots.length===1&&o.length===0?null:{rootIds:t.roots,disconnectedIds:o}}const bn=new Set(["name","title","description","shortDescription","longDescription","sourceReference","rationaleText","semantics","protocolSemantics","queryDescription","dataSourceDescription","documentUsage","doc"]);function Sn(t,e=4){const n=[];t.shortId&&n.push({key:"id",value:t.shortId});for(const[o,s]of Object.entries(t.attributes)){if(n.length>=e)break;if(bn.has(o)||o.includes(".")||o==="id"&&n.some(l=>l.key==="id"))continue;const c=s.split("::").pop().trim();!c||c.length>28||n.push({key:o,value:c})}return n.slice(0,e)}const Ge={layout:(t,e)=>wn(t,e)},Mn=(t,e,n,o=10)=>{const s=n.x-o,c=n.x+n.width+o,l=n.y-o,i=n.y+n.height+o;return t.y===e.y?t.y>=l&&t.y<=i&&Math.max(t.x,e.x)>=s&&Math.min(t.x,e.x)<=c:t.x===e.x?t.x>=s&&t.x<=c&&Math.max(t.y,e.y)>=l&&Math.min(t.y,e.y)<=i:!1},an=(t,e,n,o)=>t.y===e.y&&n.y===o.y&&t.y===n.y?Math.max(Math.min(t.x,e.x),Math.min(n.x,o.x))<Math.min(Math.max(t.x,e.x),Math.max(n.x,o.x)):t.x===e.x&&n.x===o.x&&t.x===n.x?Math.max(Math.min(t.y,e.y),Math.min(n.y,o.y))<Math.min(Math.max(t.y,e.y),Math.max(n.y,o.y)):!1,cn=(t,e,n,o)=>{const s=t.y===e.y,c=n.y===o.y;if(s===c)return!1;const l=s?t:n,i=s?e:o,a=s?n:t,f=s?o:e;return a.x>Math.min(l.x,i.x)&&a.x<Math.max(l.x,i.x)&&l.y>Math.min(a.y,f.y)&&l.y<Math.max(a.y,f.y)},En=26,Ct=(t,e,n)=>e==="left"?{x:t.x-n,y:t.y}:e==="right"?{x:t.x+n,y:t.y}:e==="top"?{x:t.x,y:t.y-n}:{x:t.x,y:t.y+n};function qe(t,e,n=18){const o=new Map,s=[],c=Math.max(12,n*.75),l=[...t].sort((i,a)=>Math.abs(a.source.x-a.target.x)+Math.abs(a.source.y-a.target.y)-(Math.abs(i.source.x-i.target.x)+Math.abs(i.source.y-i.target.y)));for(const i of l){const{source:a,target:f}=i,p=Math.abs(a.x-f.x)+Math.abs(a.y-f.y),u=Math.min(En,p/3),x=!!i.sourceSide&&u>.5,m=!!i.targetSide&&u>.5,g=x?Ct(a,i.sourceSide,u):a,h=m?Ct(f,i.targetSide,u):f,d=(r,w)=>w.x>r.x-c&&w.x<r.x+r.width+c&&w.y>r.y-c&&w.y<r.y+r.height+c,M=e.filter(r=>r.id!==i.sourceNodeId&&r.id!==i.targetNodeId&&!d(r,a)&&!d(r,f)),b=new Set([g.x,h.x,(g.x+h.x)/2,g.x-n,g.x+n,h.x-n,h.x+n]),E=new Set([g.y,h.y,(g.y+h.y)/2,g.y-n,g.y+n,h.y-n,h.y+n]);for(const r of M)b.add(r.x-c),b.add(r.x+r.width+c),E.add(r.y-c),E.add(r.y+r.height+c);for(const[r,w]of s)b.add(r.x),b.add(w.x),E.add(r.y),E.add(w.y);const S=[...b].sort((r,w)=>r-w),N=[...E].sort((r,w)=>r-w),T=[],G=new Map,W=(r,w)=>`${r.toFixed(3)}:${w.toFixed(3)}`,H=r=>M.some(w=>r.x>w.x-c&&r.x<w.x+w.width+c&&r.y>w.y-c&&r.y<w.y+w.height+c);for(const r of N)for(const w of S){const k={x:w,y:r};H(k)&&W(w,r)!==W(g.x,g.y)&&W(w,r)!==W(h.x,h.y)||(G.set(W(w,r),T.length),T.push(k))}const X=new Map,re=(r,w)=>{X.has(r)||X.set(r,[]),X.has(w)||X.set(w,[]),X.get(r).push(w),X.get(w).push(r)},Ie=(r,w)=>!M.some(k=>Mn(r,w,k,c-1));for(const r of N){const w=S.map(k=>G.get(W(k,r))).filter(k=>k!==void 0);for(let k=1;k<w.length;k++)Ie(T[w[k-1]],T[w[k]])&&re(w[k-1],w[k])}for(const r of S){const w=N.map(k=>G.get(W(r,k))).filter(k=>k!==void 0);for(let k=1;k<w.length;k++)Ie(T[w[k-1]],T[w[k]])&&re(w[k-1],w[k])}const fe=G.get(W(g.x,g.y)),$=G.get(W(h.x,h.y)),Ee=(r,w)=>`${r}:${w}`,be=fe===void 0?[]:[{node:fe,dir:"N",g:0,f:Math.abs(g.x-h.x)+Math.abs(g.y-h.y)}],le=new Map(fe===void 0?[]:[[Ee(fe,"N"),0]]),ve=new Map;be[0]&&ve.set(Ee(be[0].node,be[0].dir),be[0]);let xe;const pe=(r,w,k)=>!k||k==="left"&&w.x<r.x||k==="right"&&w.x>r.x||k==="top"&&w.y<r.y||k==="bottom"&&w.y>r.y,Me=(r,w,k)=>!k||(k==="left"?w.x<=r.x:k==="right"?w.x>=r.x:k==="top"?w.y<=r.y:w.y>=r.y),v=x?Me:pe,R=m?Me:pe;for(;be.length>0;){be.sort((w,k)=>w.f-k.f);const r=be.shift();if(r.node===$){xe=r;break}for(const w of X.get(r.node)??[]){const k=T[r.node],L=T[w];if(r.node===fe&&!v(k,L,i.sourceSide)||w===$&&!R(L,k,i.targetSide))continue;const D=k.y===L.y?"H":"V",Q=Math.abs(k.x-L.x)+Math.abs(k.y-L.y);let B=r.dir!=="N"&&r.dir!==D?90:0;for(const[K,z]of s)an(k,L,K,z)?B+=4e3:cn(k,L,K,z)&&(B+=600);const Z=Math.abs(k.x-h.x)+Math.abs(k.y-h.y),J=Math.abs(L.x-h.x)+Math.abs(L.y-h.y);J>Z&&(B+=(J-Z)*1.5);const y=r.g+Q+B,A=Ee(w,D);if(y>=(le.get(A)??Number.POSITIVE_INFINITY))continue;const P={node:w,dir:D,g:y,f:y+J,parent:Ee(r.node,r.dir)};le.set(A,y),ve.set(A,P),be.push(P)}}let F=[];if(xe){let r=xe;for(;r;)F.push(T[r.node]),r=r.parent?ve.get(r.parent):void 0;F.reverse()}if(F.length<2){const r=(g.x+h.x)/2;F=[g,{x:r,y:g.y},{x:r,y:h.y},h]}x&&F.unshift(a),m&&F.push(f);const ie=F.filter((r,w)=>w===0||w===F.length-1||!(F[w-1].x===r.x&&r.x===F[w+1].x||F[w-1].y===r.y&&r.y===F[w+1].y));o.set(i.id,ie);for(let r=1;r<ie.length;r++)s.push([ie[r-1],ie[r]])}return o}const At=(t,e)=>{const n=Math.min(t.x+t.width,e.x+e.width)-Math.max(t.x,e.x),o=Math.min(t.y+t.height,e.y+e.height)-Math.max(t.y,e.y);return n>0&&o>0?n*o:0},vn=(t,e,n)=>{if(t.y===e.y){if(t.y<n.y||t.y>n.y+n.height)return 0;const o=Math.min(Math.max(t.x,e.x),n.x+n.width)-Math.max(Math.min(t.x,e.x),n.x);return Math.max(o,0)}if(t.x===e.x){if(t.x<n.x||t.x>n.x+n.width)return 0;const o=Math.min(Math.max(t.y,e.y),n.y+n.height)-Math.max(Math.min(t.y,e.y),n.y);return Math.max(o,0)}return 0};function it(t,e){var i;const n=new Map,o=[],s=a=>a.slice(1).reduce((f,p,u)=>f+Math.abs(p.x-a[u].x)+Math.abs(p.y-a[u].y),0),c=t.flatMap(a=>a.points.slice(1).map((f,p)=>({edgeId:a.id,a:a.points[p],b:f}))),l=[...t].sort((a,f)=>s(f.points)-s(a.points));for(const a of l){const{points:f,width:p,height:u}=a;if(f.length<2)continue;const x=[];for(let h=1;h<f.length;h++){const d=f[h-1],M=f[h],b=Math.abs(M.x-d.x)+Math.abs(M.y-d.y),E=Math.abs(M.x-d.x)>=Math.abs(M.y-d.y),S=u/2+4;for(const N of b>=p*1.5?[.5,.3,.7]:[.5,.25,.75]){const T={x:d.x+(M.x-d.x)*N,y:d.y+(M.y-d.y)*N};for(const G of[-1,1])x.push({center:E?{x:T.x,y:T.y+G*S}:{x:T.x+G*(p/2+4),y:T.y},segmentLength:b})}}let m=((i=x[0])==null?void 0:i.center)??f[0],g=Number.POSITIVE_INFINITY;for(const h of x){const d={x:h.center.x-p/2,y:h.center.y-u/2,width:p,height:u};let M=0;for(const b of o)M+=At(d,b)*3;for(const b of e)M+=At(d,b)*4;for(const b of c)b.edgeId!==a.id&&(M+=vn(b.a,b.b,d)*12*2.5);M+=Math.max(0,p*1.4-h.segmentLength)*2,M<g&&(g=M,m=h.center)}n.set(a.id,m),o.push({x:m.x-p/2,y:m.y-u/2,width:p,height:u})}return n}const at=20,ct=t=>t.length*6.4+12;function kn(t){const{connectors:e,rects:n}=t,o=t.obstacles??[...n.entries()].map(([m,g])=>({id:m,...g})),s=[],c=new Map;for(const m of e){const g=n.get(m.sourceId),h=n.get(m.targetId);if(!g||!h||m.sourceId===m.targetId)continue;const d=N=>({x:N.x+N.width/2,y:N.y+N.height/2}),M=Math.abs(d(h).x-d(g).x)>=Math.abs(d(h).y-d(g).y),b=M?d(h).x>=d(g).x:d(h).y>=d(g).y,E=M?b?"right":"left":b?"bottom":"top",S=M?b?"left":"right":b?"top":"bottom";c.set(m.id,{source:E,target:S}),s.push({connectorId:m.id,nodeId:m.sourceId,side:E,otherCentre:d(h)}),s.push({connectorId:m.id,nodeId:m.targetId,side:S,otherCentre:d(g)})}const l=new Map,i=(m,g)=>`${m}\0${g}`,a=new Map;for(const m of s){const g=`${m.nodeId}\0${m.side}`;a.set(g,[...a.get(g)??[],m])}for(const m of a.values()){const g=n.get(m[0].nodeId),h=m[0].side==="left"||m[0].side==="right",d=[...m].sort((E,S)=>h?E.otherCentre.y-S.otherCentre.y:E.otherCentre.x-S.otherCentre.x),M=(h?g.height:g.width)*.7,b=(h?g.y+g.height/2:g.x+g.width/2)-M/2;d.forEach((E,S)=>{const N=d.length===1?(h?g.height:g.width)/2:b+M*(S/(d.length-1))-(h?g.y:g.x);l.set(i(E.connectorId,E.nodeId),{x:E.side==="left"?g.x:E.side==="right"?g.x+g.width:g.x+(h?g.width/2:N),y:E.side==="top"?g.y:E.side==="bottom"?g.y+g.height:g.y+(h?N:g.height/2)})})}const f=[];for(const m of e){const g=c.get(m.id);g&&f.push({id:m.id,source:l.get(i(m.id,m.sourceId)),target:l.get(i(m.id,m.targetId)),sourceNodeId:m.sourceId,targetNodeId:m.targetId,sourceSide:g.source,targetSide:g.target})}const p=qe(f,o,t.channelGap),u=it(e.flatMap(m=>{const g=p.get(m.id);return m.label&&g&&g.length>=2?[{id:m.id,points:g,width:ct(m.label),height:at}]:[]}),o),x=new Map;for(const[m,g]of p)x.set(m,{points:g,labelPoint:u.get(m)});return x}function Cn(t,e,n=1.5){if(t<=0||e<=0)return Number.POSITIVE_INFINITY;const o=1+1.35*Math.abs(Math.log(t/e/n));return t*e*o}function An(t,e=1.25){return t<=1?Math.max(t,1):Math.min(t,Math.max(2,Math.round(Math.sqrt(t*e))))}function ln(t,e){const n=new Set(t.map(f=>f.id)),o=new Map,s=new Map(t.map(f=>[f.id,0]));for(const f of e)!n.has(f.source)||!n.has(f.target)||f.source===f.target||(o.has(f.source)||o.set(f.source,[]),o.get(f.source).push(f.target),s.set(f.target,(s.get(f.target)??0)+1));const c=t.map(f=>f.id),l=c.filter(f=>(s.get(f)??0)===0),i=[],a=new Set;for(;l.length;){const f=l.shift();if(!a.has(f)){a.add(f),i.push(f);for(const p of o.get(f)??[])s.set(p,(s.get(p)??1)-1),s.get(p)===0&&l.push(p)}}for(const f of c)a.has(f)||i.push(f);return i}function On(t,e,n,o,s){const c=new Map(t.map(h=>[h.id,h])),l=ln(t,e).map(h=>c.get(h)),i=An(t.length,s),a=Math.ceil(t.length/i),f=l.map((h,d)=>{const M=Math.floor(d/i),b=d%i,E=M%2===0?b:i-1-b;return{node:h,row:M,col:E}}),p=Array.from({length:i},()=>0),u=Array.from({length:a},()=>0);for(const{node:h,row:d,col:M}of f)p[M]=Math.max(p[M],h.width),u[d]=Math.max(u[d],h.height);const x=p.map((h,d)=>d===0?0:p.slice(0,d).reduce((M,b)=>M+b,0)+n*d),m=u.map((h,d)=>d===0?0:u.slice(0,d).reduce((M,b)=>M+b,0)+o*d),g=f.map(({node:h,row:d,col:M})=>({...h,x:x[M]+(p[M]-h.width)/2,y:m[d]+(u[d]-h.height)/2}));return{strategy:"balanced-board",width:p.reduce((h,d)=>h+d,0)+n*Math.max(i-1,0),height:u.reduce((h,d)=>h+d,0)+o*Math.max(a-1,0),children:g}}function Nn(t,e,n,o){const s={x:t.x+t.width/2,y:t.y+t.height/2},c={x:e.x+e.width/2,y:e.y+e.height/2},l={x:n.x+n.width/2,y:n.y+n.height/2},i={x:o.x+o.width/2,y:o.y+o.height/2},a=(f,p,u)=>(p.x-f.x)*(u.y-f.y)-(p.y-f.y)*(u.x-f.x);return a(s,c,l)*a(s,c,i)<0&&a(l,i,s)*a(l,i,c)<0}function Ot(t,e,n=1.5){const o=new Map(t.children.map(g=>[g.id,g]));let s=0,c=0,l=0,i=0;const a=e.filter(g=>o.has(g.source)&&o.has(g.target));for(const g of a){const h=o.get(g.source),d=o.get(g.target);s+=Math.abs(h.x+h.width/2-(d.x+d.width/2))+Math.abs(h.y+h.height/2-(d.y+d.height/2));const M=d.x+d.width/2-(h.x+h.width/2),b=Math.abs(d.y+d.height/2-(h.y+h.height/2));M<=0&&(l+=55e3),l+=Math.max(0,b-Math.max(M,0))*80,Math.abs(M)>8&&b>8&&(i+=18e3)}for(let g=0;g<a.length;g++)for(let h=g+1;h<a.length;h++){const d=a[g],M=a[h];d.source===M.source||d.source===M.target||d.target===M.source||d.target===M.target||Nn(o.get(d.source),o.get(d.target),o.get(M.source),o.get(M.target))&&c++}const f=qe(a.map(g=>{const h=o.get(g.source),d=o.get(g.target);return{id:g.id,source:{x:h.x+h.width,y:h.y+h.height/2},target:{x:d.x,y:d.y+d.height/2},sourceNodeId:g.source,targetNodeId:g.target,sourceSide:"right",targetSide:"left"}}),t.children);let p=0,u=0,x=0;const m=[];for(const[g,h]of f){u+=Math.max(0,h.length-2);for(let d=1;d<h.length;d++)p+=Math.abs(h[d].x-h[d-1].x)+Math.abs(h[d].y-h[d-1].y),m.push({edgeId:g,a:h[d-1],b:h[d]})}for(let g=0;g<m.length;g++)for(let h=g+1;h<m.length;h++){const d=m[g],M=m[h];d.edgeId!==M.edgeId&&(an(d.a,d.b,M.a,M.b)||cn(d.a,d.b,M.a,M.b))&&x++}return Cn(t.width,t.height,n)+s*18+l+i+c*Math.max(t.width*t.height*.35,5e4)+p*6+u*4e3+x*Math.max(t.width*t.height*.45,7e4)}async function Nt(t){const{nodes:e,edges:n}=t;if(e.length===0)return{strategy:"balanced-board",width:0,height:0,children:[]};const o=t.targetAspect??1.5,s=t.gapX??54,c=t.gapY??58,l=a=>{const f=new Map(e.map(d=>[d.id,d])),p=ln(e,n).map(d=>f.get(d));let u=0;const x=Math.max(...a==="RIGHT"?p.map(d=>d.height):p.map(d=>d.width));let m=p.map(d=>{const M={...d,x:a==="RIGHT"?u:(x-d.width)/2,y:a==="DOWN"?u:(x-d.height)/2};return u+=a==="RIGHT"?d.width+s:d.height+c,M});if(a==="RIGHT"&&n.some(d=>d.sourceAnchorY!==void 0&&d.targetAnchorY!==void 0)){new Map(m.map(S=>[S.id,S]));const d=new Map,M=[...m].sort((S,N)=>N.width*N.height-S.width*S.height)[0];d.set(M.id,0);let b=!0;for(;b;){b=!1;for(const S of n){if(S.sourceAnchorY===void 0||S.targetAnchorY===void 0)continue;const N=d.get(S.source),T=d.get(S.target);N!==void 0&&T===void 0?(d.set(S.target,N+S.sourceAnchorY-S.targetAnchorY),b=!0):T!==void 0&&N===void 0&&(d.set(S.source,T+S.targetAnchorY-S.sourceAnchorY),b=!0)}}m=m.map(S=>({...S,y:d.get(S.id)??S.y}));const E=Math.min(...m.map(S=>S.y));m=m.map(S=>({...S,y:S.y-E}))}const g=Math.max(...m.map(d=>d.x+d.width)),h=Math.max(...m.map(d=>d.y+d.height));return{strategy:a==="RIGHT"?"layered-right":"layered-down",width:g,height:h,children:m}};if(t.directedFlowAxis==="RIGHT")return l("RIGHT");if(t.directedFlowAxis==="DOWN")return l("DOWN");const i=[On(e,n,s,c,o),l("RIGHT"),l("DOWN")];if(e.length>=3&&n.length>0)try{const a=new Map(e.filter(h=>{var d;return(d=h.ports)==null?void 0:d.length}).map(h=>[h.id,h])),f={left:"WEST",right:"EAST",top:"NORTH",bottom:"SOUTH"},p=new Set((t.graphPorts??[]).map(h=>h.id)),u=(t.graphPorts??[]).map(h=>({id:h.id,width:1,height:1,layoutOptions:{"elk.layered.layering.layerConstraint":h.side==="right"?"LAST_SEPARATE":"FIRST_SEPARATE"}})),m=(await Ge.layout({id:`resolver-${t.id}`,layoutOptions:{"elk.algorithm":"layered","elk.direction":"RIGHT","elk.edgeRouting":"ORTHOGONAL","elk.aspectRatio":String(o),"elk.padding":"[top=0,left=0,bottom=0,right=0]","elk.spacing.nodeNode":String(c),"elk.layered.spacing.nodeNodeBetweenLayers":String(s),"elk.layered.nodePlacement.strategy":"BRANDES_KOEPF","elk.layered.nodePlacement.favorStraightEdges":"true","elk.layered.crossingMinimization.strategy":"LAYER_SWEEP","elk.layered.crossingMinimization.semiInteractive":"true","elk.layered.thoroughness":"18","elk.layered.wrapping.strategy":e.length>5?"MULTI_EDGE":"OFF","elk.layered.wrapping.additionalEdgeSpacing":"18","elk.separateConnectedComponents":"true","elk.layered.considerModelOrder.strategy":"NODES_AND_EDGES","elk.randomSeed":"1"},children:[...u,...e.map(h=>{var d;return(d=h.ports)!=null&&d.length?{id:h.id,width:h.width,height:h.height,layoutOptions:{"elk.portConstraints":"FIXED_SIDE"},ports:h.ports.map(M=>({id:M.id,width:8,height:8,layoutOptions:{"elk.port.side":f[M.side]}}))}:{id:h.id,width:h.width,height:h.height}})],edges:n.map(h=>({id:h.id,sources:[a.has(h.source)&&h.sourcePort?h.sourcePort:h.source],targets:[a.has(h.target)&&h.targetPort?h.targetPort:h.target]}))},{providerId:t.layoutProviderId})).children??[],g=m.filter(h=>!p.has(h.id));if(g.length===e.length){const h=new Map(e.map(S=>[S.id,S])),d=Math.min(...g.map(S=>S.x??0)),M=Math.min(...g.map(S=>S.y??0)),b=g.map(S=>{const N=S.ports;return{...h.get(S.id),x:(S.x??0)-d,y:(S.y??0)-M,...N!=null&&N.length?{portY:new Map(N.map(T=>[T.id,T.y??0]))}:{}}}),E=m.filter(S=>p.has(S.id));i.push({strategy:"elk-layered",width:Math.max(...b.map(S=>S.x+S.width)),height:Math.max(...b.map(S=>S.y+S.height)),...E.length?{graphPortY:new Map(E.map(S=>[S.id,(S.y??0)-M]))}:{},children:b})}}catch{}return i.reduce((a,f)=>Ot(f,n,o)<Ot(a,n,o)?f:a)}async function Tn(t,e){var b;const n=Object.values(t.elements),o=e!=null&&e.viewpointFilter?n.filter(e.viewpointFilter):n,s=new Set(o.map(E=>E.id)),c=(b=e==null?void 0:e.relationshipTypes)!=null&&b.length?new Set(e.relationshipTypes.map(E=>E.toLowerCase())):void 0,l=t.relationships.filter(E=>s.has(E.sourceId)&&s.has(E.targetId)&&(!c||c.has(E.type.toLowerCase()))),i=o.length,a=i>60?"RIGHT":"DOWN",f=i>40?"24":i>20?"32":"40",p=i>40?"60":i>20?"80":"100",u=e!=null&&e.compartments?new Map(o.map(E=>[E.id,Sn(E)])):void 0,x=E=>Math.max(E.name.length*7.5+48,E.kind.length*6.8+48,130),m=E=>{const S=u==null?void 0:u.get(E.id);return 52+(S!=null&&S.length?S.length*15+10:0)},g={id:"root",layoutOptions:{"elk.algorithm":"layered","elk.direction":a,"elk.spacing.nodeNode":f,"elk.layered.spacing.nodeNodeBetweenLayers":p,"elk.layered.spacing.edgeNodeBetweenLayers":"24","elk.layered.considerModelOrder.strategy":"NODES_AND_EDGES","elk.layered.nodePlacement.strategy":"NETWORK_SIMPLEX","elk.layered.crossingMinimization.strategy":"LAYER_SWEEP","elk.layered.compaction.postCompaction.strategy":"EDGE_LENGTH","elk.layered.wrapping.strategy":"MULTI_EDGE","elk.layered.wrapping.additionalEdgeSpacing":"16","elk.separateConnectedComponents":"true","elk.spacing.componentComponent":"56","elk.aspectRatio":"1.6","elk.padding":"[top=20, left=20, bottom=20, right=20]"},children:o.map(E=>({id:E.id,width:x(E),height:m(E)})),edges:l.map((E,S)=>({id:E.id||`e-${S}`,sources:[E.sourceId],targets:[E.targetId]}))};let h;try{h=await Ge.layout(g,{providerId:e==null?void 0:e.layoutProviderId})}catch(E){console.warn("ELK layout failed, retrying without edge wrapping:",E),delete g.layoutOptions["elk.layered.wrapping.strategy"],delete g.layoutOptions["elk.layered.wrapping.additionalEdgeSpacing"],h=await Ge.layout(g,{providerId:e==null?void 0:e.layoutProviderId})}const d=(h.children||[]).map(E=>{const S=t.elements[E.id],N=Be[S==null?void 0:S.layer]||"#666",T=u==null?void 0:u.get(E.id);return{id:E.id,type:"diagramNode",position:{x:E.x||0,y:E.y||0},data:{label:(S==null?void 0:S.name)||E.id,kind:(S==null?void 0:S.kind)??"",layer:(S==null?void 0:S.layer)??"",construct:S==null?void 0:S.construct,color:N,...T!=null&&T.length?{compartments:T}:{}}}}),M=l.map((E,S)=>{const N=He[E.type]||"#9CA3AF",T=E.type.toLowerCase(),G=E.type==="flow",W=E.type==="succession",H=T==="composedof"||T==="decomposedby"||T==="aggregation"||T==="composes";return{id:E.id||`e-${S}`,source:E.sourceId,target:E.targetId,label:H?void 0:E.type,type:W?"smoothstep":"default",animated:G,style:{stroke:N,strokeWidth:H?2.5:G?2:ne.defaultWidth,strokeDasharray:H||G?void 0:E.type==="traceTo"?"5 3":void 0},labelStyle:{fontSize:"10px",fill:"#6B7280",fontWeight:500},labelBgPadding:ne.labelBgPadding,labelBgBorderRadius:ne.labelBgRadius,labelBgStyle:ne.labelBgStyle,markerEnd:{type:H?"arrow":"arrowclosed",color:N,width:ne.arrowSize,height:ne.arrowSize}}});return{nodes:d,edges:M}}function dn(t){var l;const e=new Set((((l=t.registries)==null?void 0:l.kinds)??[]).filter(i=>{var a;return(a=i.namespace)==null?void 0:a.some(f=>f==="logical"||f==="implementation"||f==="realization")}).map(i=>i.name)),n=new Map;for(const i of Object.values(t.elements))e.has(i.kind)&&n.set(i.id,i);const o=new Map,s=new Set;for(const i of t.relationships)(i.type==="composedOf"||i.type==="aggregation")&&n.has(i.sourceId)&&n.has(i.targetId)&&(o.has(i.sourceId)||o.set(i.sourceId,[]),o.get(i.sourceId).push(i.targetId),s.add(i.targetId));return{roots:[...n.keys()].filter(i=>!s.has(i)),childrenMap:o,elements:n}}const De=64,Je=100,Tt=110,_t=300,Pt=44;function lt(t){return Math.max(t.name.length*8+80,220)}async function _n(t,e){const n=e.tree??dn(t);if(n.roots.length===0)return{nodes:[],edges:[]};const o=e.positionCache??new Map,s=x=>e.nodeDirections.get(x)||"vertical",c=x=>(n.childrenMap.get(x)||[]).filter(m=>n.elements.has(m)),l=x=>{const m=n.elements.get(x),g=lt(m),h=c(x);if(!e.expandedNodes.has(x)||h.length===0)return{width:g,height:De};const d=h.map(l);if(s(x)==="vertical"){const E=d.reduce((N,T)=>N+T.width,0)+(d.length-1)*Je,S=Math.max(...d.map(N=>N.height));return{width:Math.max(g,E),height:De+Tt+S}}const M=Math.max(...d.map(E=>E.width)),b=d.reduce((E,S)=>E+S.height,0)+(d.length-1)*Pt;return{width:g+_t+M,height:Math.max(De,b)}},i=[],a=[],f=He.composedOf,p=(x,m,g,h)=>{const d=n.elements.get(x),M=lt(d),b=c(x),E=e.expandedNodes.has(x);let S=o.get(x);S||(S={x:g-M/2,y:h-De/2},o.set(x,S));const N={element:d,layerColor:Be[d.layer]||"#666",isExpanded:E,hasChildren:b.length>0,childCount:b.length,direction:s(x),onToggleExpand:()=>e.callbacks.onToggleExpand(x),onToggleDirection:()=>e.callbacks.onToggleDirection(x),showDirectionButton:!0,label:d.name};if(i.push({id:x,type:"decompositionNode",position:{x:S.x,y:S.y},data:N,style:{width:M,height:De}}),m){const G=s(m);a.push({id:`decomp-${m}-${x}`,source:m,target:x,sourceHandle:G==="vertical"?"bottom":"right",targetHandle:G==="vertical"?"top":"left",type:"smoothstep",style:{stroke:f,strokeWidth:ne.defaultWidth},markerEnd:{type:"arrowclosed",color:f,width:ne.arrowSize,height:ne.arrowSize}})}if(!E||b.length===0)return;const T=b.map(l);if(s(x)==="vertical"){const G=T.reduce((X,re)=>X+re.width,0)+(T.length-1)*Je;let W=S.x+M/2-G/2;const H=S.y+De+Tt+De/2;b.forEach((X,re)=>{p(X,x,W+T[re].width/2,H),W+=T[re].width+Je})}else{const G=S.x+M+_t;let W=S.y+De+20;b.forEach((H,X)=>{const re=n.elements.get(H);p(H,x,G+lt(re)/2,W+De/2),W+=T[X].height+Pt})}};let u=0;for(const x of n.roots){if(!n.elements.has(x))continue;const m=l(x);p(x,null,u+m.width/2,100),u+=m.width+Je*2}return{nodes:i,edges:a}}const dt=240,ht=80,We=20;function Pn(t,e){const n=e.tree??dn(t);if(n.roots.length===0)return{nodes:[],edges:[]};const o=[];function s(u,x,m,g,h){const d=n.elements.get(u);if(!d)return{width:0,height:0};const M=Be[d.layer]||"#666",b=n.childrenMap.get(u)||[],E=b.length>0,S=e.expandedNodes.has(u);let N=dt,T=ht;if(S&&E){let H=We,X=ht+We,re=0,Ie=0;for(const fe of b){if(!n.elements.has(fe))continue;const $=s(fe,u,m+1,H,X);H+$.width>800&&H>We&&(H=We,X+=re+We,re=0,c(fe),s(fe,u,m+1,H,X)),H+=$.width+We,re=Math.max(re,$.height),Ie=Math.max(Ie,H)}N=Math.max(dt,Ie),T=X+re+We}const G=kt[m%kt.length],W={element:d,layerColor:M,isExpanded:S,hasChildren:E,childCount:b.length,direction:"vertical",onToggleExpand:()=>e.callbacks.onToggleExpand(u),onToggleDirection:()=>{},showDirectionButton:!1,depthBgColor:G,isContainer:E,label:d.name};return o.push({id:u,type:"decompositionNode",position:{x:g,y:h},...x?{parentId:x,extent:"parent"}:{},data:W,style:{width:S&&E?N:dt,height:S&&E?T:ht}}),{width:N,height:T}}function c(u){const x=new Set([u]),m=g=>{for(const h of n.childrenMap.get(g)||[])x.add(h),m(h)};m(u);for(let g=o.length-1;g>=0;g--)x.has(o[g].id)&&o.splice(g,1)}let l=0;for(const u of n.roots){if(!n.elements.has(u))continue;const x=s(u,null,0,l,0);l+=x.width+40}const i=new Map(o.map(u=>[u.id,u])),a=[],f=new Set,p=u=>{if(f.has(u.id))return;const x=u.parentId?i.get(u.parentId):void 0;x&&p(x),f.add(u.id),a.push(u)};for(const u of o)p(u);return{nodes:a,edges:[]}}function Fn(t){var l;const e=new Set((((l=t.registries)==null?void 0:l.kinds)??[]).filter(i=>{var a;return(a=i.namespace)==null?void 0:a.includes("functional")}).map(i=>i.name)),n=new Map;for(const i of Object.values(t.elements))e.has(i.kind)&&n.set(i.id,i);const o=new Map,s=new Set;for(const i of t.relationships)(i.type==="decomposedBy"||i.type==="composedOf")&&n.has(i.sourceId)&&n.has(i.targetId)&&(o.has(i.sourceId)||o.set(i.sourceId,[]),o.get(i.sourceId).push(i.targetId),s.add(i.targetId));return{roots:[...n.keys()].filter(i=>!s.has(i)),childrenMap:o,elements:n}}async function Ks(t,e){const n=Fn(t);if(n.roots.length===0)return{nodes:[],edges:[]};const o=new Set,s=[];function c(p){if(n.elements.has(p)&&(o.add(p),e.expandedNodes.has(p)))for(const u of n.childrenMap.get(p)||[])n.elements.has(u)&&(s.push({parentId:p,childId:u}),c(u))}for(const p of n.roots)c(p);const l={id:"root",layoutOptions:{"elk.algorithm":"mrtree","elk.direction":"DOWN","elk.spacing.nodeNode":"40","elk.mrtree.searchOrder":"DFS"},children:[...o].map(p=>{const u=n.elements.get(p);return{id:p,width:Math.max(u.name.length*8+80,220),height:56}}),edges:s.map((p,u)=>({id:`fbs-${u}`,sources:[p.parentId],targets:[p.childId]}))},a=((await Ge.layout(l,{providerId:e.layoutProviderId})).children||[]).map(p=>{const u=n.elements.get(p.id),x=Be[u.layer]||"#E67E22",m=(n.childrenMap.get(p.id)||[]).length,g=e.nodeDirections.get(p.id)||"vertical",h={element:u,layerColor:x,isExpanded:e.expandedNodes.has(p.id),hasChildren:m>0,childCount:m,direction:g,onToggleExpand:()=>e.callbacks.onToggleExpand(p.id),onToggleDirection:()=>e.callbacks.onToggleDirection(p.id),showDirectionButton:!0,label:u.name};return{id:p.id,type:"decompositionNode",position:{x:p.x||0,y:p.y||0},data:h}}),f=s.map((p,u)=>{const x=e.nodeDirections.get(p.parentId)||"vertical";return{id:`fbs-e-${u}`,source:p.parentId,target:p.childId,sourceHandle:x==="vertical"?"bottom":"right",targetHandle:x==="vertical"?"top":"left",type:"default",style:{stroke:He.decomposedBy,strokeWidth:ne.defaultWidth},markerEnd:{type:"arrowclosed",color:He.decomposedBy,width:ne.arrowSize,height:ne.arrowSize}}});return{nodes:a,edges:f}}const Us=["graph","tree","containment"];function Vs(t){const e=t==null?void 0:t.layoutHint;return e==="tree"||e==="containment"||e==="graph"?e:"graph"}function Dn(t,e){const n=Object.values(t.elements);return e?n.filter(e):n}function Rn(t,e){return rt(Dn(t,e),t.relationships)}async function qs(t,e){if(e.mode==="graph")return Tn(t,{viewpointFilter:e.viewpointFilter,relationshipTypes:e.relationshipTypes,compartments:!0,layoutProviderId:e.layoutProviderId});const n=Rn(t,e.viewpointFilter);return e.mode==="tree"?_n(t,{expandedNodes:e.expandedNodes,nodeDirections:e.nodeDirections,callbacks:e.callbacks,tree:n,positionCache:e.positionCache}):Pn(t,{expandedNodes:e.expandedNodes,callbacks:{onToggleExpand:e.callbacks.onToggleExpand},tree:n})}const Ft="__inner",Zs={in:"#16A34A",out:"#D97706",inout:"#2563EB"},Ln={data:"#3498DB",energy:"#D97706",material:"#16A34A",control:"#6B7280"};function Bn(t,e){const n=t??"";return/energy|power|voltage|current|thermal|heat/i.test(n)?"energy":/material|fluid|gas|liquid|drug|dose|batch|consumable/i.test(n)?"material":e&&/succession|control/i.test(e)?"control":"data"}function hn(t){return t.construct==="port"||t.kind.endsWith("Port")}function Dt(t){var o,s;const e=(o=t.portSpec)==null?void 0:o.direction;if(e==="in"||e==="out"||e==="inout")return e;const n=(s=(t.attributes.direction??"").split("::").pop())==null?void 0:s.trim();if(n==="bidirectional")return"inout";if(n==="in"||n==="out"||n==="inout")return n}const Oe=24,Js=Oe,ut=Oe,et=30,Re=70,gt=62,Qe=18,Rt=14,Lt=128,ze=38,Ye=18,ft=90,Bt=184,jn=168,Wn=(t,e=7.2)=>t.length*e+20,Hn=t=>Math.min(Math.max(Wn(t,7.1),132),216);function un(t){var o,s;const e=(o=t.portSpec)==null?void 0:o.direction,n=e==="in"||e==="out"||e==="inout"?e:(s=(t.attributes.direction??"").split("::").pop())==null?void 0:s.trim();if(n==="in")return"in";if(n==="out"||n==="inout"||n==="bidirectional"||/out(put)?$/i.test(t.name))return"out";if(/in(put)?$/i.test(t.name))return"in"}function zn(t,e,n){return un(t)??(e>n?"out":"in")}const Gn=t=>t==="in"?"left":"right";function $n(t,e){const n=t.filter(s=>!e.isConnected(s)&&!e.hasChildParts(s)&&e.portCount(s)===0),o=new Set(n);return{flowKids:t.filter(s=>!o.has(s)),orphanKids:n}}function Yn(t,e,n){const o=new Map,s=new Map;for(const[i,a]of t)a.owner&&(e(a.owner)?o.set(i,a.owner):t.has(a.owner)&&s.set(i,a.owner));for(const i of n)!Ve.has(i.type)||!t.has(i.targetId)||o.has(i.targetId)||s.has(i.targetId)||(e(i.sourceId)?o.set(i.targetId,i.sourceId):t.has(i.sourceId)&&s.set(i.targetId,i.sourceId));const c=new Map,l=(i,a)=>{const f=c.get(i)??o.get(i);if(f)return c.set(i,f),f;const p=s.get(i);if(!p||a.has(p))return;a.add(p);const u=l(p,a);return u&&c.set(i,u),u};for(const i of t.keys())l(i,new Set([i]));return{ownerPart:c,parentPort:s}}function jt(t,e,n){if(e==="none")return;if(e==="all")return t;let o=t;const s=new Set([o]);for(;n.has(o);){const c=n.get(o);if(s.has(c))break;s.add(c),o=c}return o}function Xn(t,e,n){const o=new Set,s=c=>{if(!(o.has(c)||!e(c))){o.add(c);for(const l of t.get(c)??[])s(l)}};return s(n),o}function Kn(t,e){const n=e.size??Oe,o=e.pitch??ze,s=e.nestedPitch??et,c=new Map;for(const l of["left","right"]){const i=t.filter(u=>e.sideOf(u)===l),a=i.length,f=Math.max(e.bodyBottom-e.bodyTop,0);let p=-1/0;i.forEach((u,x)=>{var g;let m=a===1&&e.singleCenterY!==void 0?e.singleCenterY:e.bodyTop+(a===1?f/2:(x+.5)/a*f);m=Math.max(m,e.bodyTop+o/2,p+o),p=m+((((g=e.weightOf)==null?void 0:g.call(e,u))??1)-1)*s,c.set(u,{x:l==="left"?-n/2:e.width-n/2,y:m-n/2,side:l})})}return c}function Wt(t,e){for(const n of["left","right"]){const o=[...t].filter(([c,l])=>l.side===n&&e.has(c)).map(([c])=>c);if(o.length<2)continue;const s=o.map(c=>t.get(c).y).sort((c,l)=>c-l);[...o].sort((c,l)=>e.get(c)-e.get(l)).forEach((c,l)=>{t.get(c).y=s[l]})}}async function Qs(t,e){var J;const n=Object.values(t.elements),o=e!=null&&e.viewpointFilter?n.filter(e.viewpointFilter):n,s=new Map,c=[];for(const y of o)hn(y)?s.set(y.id,y):c.push(y);if(c.length===0)return{nodes:[],edges:[]};const l=(e==null?void 0:e.portDisplay)??"all",i=l!=="none",a=rt(c,t.relationships),f=e!=null&&e.focusId&&a.elements.has(e.focusId)?e.focusId:void 0,p=f?Xn(a.childrenMap,y=>a.elements.has(y),f):null,u=y=>a.elements.has(y)&&(!p||p.has(y)),x=y=>{var A;return(A=e==null?void 0:e.collapsedNodes)!=null&&A.has(y)?[]:(a.childrenMap.get(y)??[]).filter(u)},{ownerPart:m,parentPort:g}=Yn(s,u,t.relationships);for(const y of[...s.keys()])m.has(y)||s.delete(y);const h=y=>jt(y,"ports",g),d=new Map;for(const[y,A]of m)!s.has(y)||g.has(y)||(d.has(A)||d.set(A,[]),d.get(A).push(y));const M=new Map;if(l==="all")for(const[y]of g){if(!s.has(y))continue;const A=h(y);!s.has(A)||A===y||(M.has(A)||M.set(A,[]),M.get(A).push(y))}const b=y=>{var A;return 1+(((A=M.get(y))==null?void 0:A.length)??0)},E=(J=e==null?void 0:e.relationshipTypes)!=null&&J.length?new Set(e.relationshipTypes.map(y=>y.toLowerCase())):void 0,S=y=>s.has(y)||u(y),N=t.relationships.filter(y=>!Ve.has(y.type)&&(!E||E.has(y.type.toLowerCase()))&&S(y.sourceId)&&S(y.targetId)&&y.sourceId!==y.targetId),T=new Set;for(const y of N)for(const A of[y.sourceId,y.targetId]){if(!s.has(A))continue;let P=A;for(;P&&!T.has(P);)T.add(P),P=g.get(P)}for(const[y,A]of d)d.set(y,A.filter(P=>T.has(P)));const G=new Set(N.filter(y=>u(y.sourceId)).map(y=>y.sourceId)),W=new Set(N.filter(y=>u(y.targetId)).map(y=>y.targetId)),H=y=>m.get(y)??y,X=new Map;for(const[y,A]of a.childrenMap)for(const P of A)u(P)&&X.set(P,y);const re=new Map,Ie=y=>{const A=re.get(y);if(A)return A;const P=s.get(y);let K=un(P);if(!K){const z=g.get(y);if(z&&s.has(z))K=Ie(z);else{let se=0,Y=0;for(const ee of N)ee.sourceId===y&&se++,ee.targetId===y&&Y++;K=zn(P,se,Y)}}return re.set(y,K),K},fe=y=>Gn(Ie(y)),$=y=>({left:y.some(A=>fe(A)==="left")?Lt:Rt,right:y.some(A=>fe(A)==="right")?Lt:Rt}),Ee=y=>Hn(y.name),be=(y,A)=>{const P={left:0,right:0};for(const ae of A)P[fe(ae)]+=ze+(b(ae)-1)*et;const K=Math.max(P.left,P.right,12),z=Math.max(gt+K+10,jn),se=$(A),Y=Math.max(Ee(y),118),ee=Math.max(se.left+Y+se.right,Bt),me=Kn(A,{width:ee,bodyTop:gt,bodyBottom:z-Qe/2,sideOf:fe,weightOf:b,singleCenterY:Math.max(z/2,gt+Oe/2)});return{width:ee,height:z,childPos:new Map,portPos:me}},le=new Map,ve=new Map,xe=async y=>{const A=x(y),P=i?d.get(y)??[]:[],K=a.elements.get(y);if(A.length===0){const q=be(K,P);return le.set(y,q),q}const z=new Map;for(const q of A)z.set(q,await xe(q));const se=new Set(A),Y=new Set(P),ee=q=>{if(s.has(q)){const j=h(q);if(Y.has(j))return j}let oe=H(q);for(;oe&&!se.has(oe);)oe=X.get(oe);return oe},me=(q,oe)=>{var te;if(!s.has(q)||m.get(q)!==oe)return;const j=h(q);return(te=d.get(oe))!=null&&te.includes(j)?j:void 0},ae=[],ke=new Set;N.forEach((q,oe)=>{const j=ee(q.sourceId),te=ee(q.targetId);j&&te&&j!==te&&(ae.push({id:`ic-${oe}`,source:j,target:te,sourcePort:me(q.sourceId,j),targetPort:me(q.targetId,te)}),se.has(j)&&ke.add(j),se.has(te)&&ke.add(te))});const{flowKids:I,orphanKids:C}=$n(A,{isConnected:q=>ke.has(q),hasChildParts:q=>(a.childrenMap.get(q)??[]).some(u),portCount:q=>{var oe;return((oe=d.get(q))==null?void 0:oe.length)??0}}),_=$(P),U=new Map;let V=0,de=0;if(I.length>0){const q=j=>(d.get(j)??[]).map(te=>({id:te,side:fe(te)})),oe=await Nt({id:`container-${y}`,nodes:I.map(j=>({id:j,width:z.get(j).width,height:z.get(j).height,ports:q(j)})),edges:ae,graphPorts:P.map(j=>({id:j,side:fe(j)})),gapX:54,gapY:58,targetAspect:2.4,layoutProviderId:e==null?void 0:e.layoutProviderId});for(const j of oe.children){const te=j.x+_.left,ce=j.y+Re;U.set(j.id,{x:te,y:ce}),V=Math.max(V,te-_.left+j.width),de=Math.max(de,ce+j.height),j.portY&&Wt(z.get(j.id).portPos,j.portY)}oe.graphPortY&&ve.set(y,new Map([...oe.graphPortY].map(([j,te])=>[j,te+Re])))}if(I.length>0&&ae.length>0){const q=(Re+Math.max(de,Re))/2,oe=new Map(ve.get(y)??[]),j=(ce,ge)=>{if(Y.has(ce))return oe.get(ce)??q;const Ae=U.get(ce),he=z.get(ce);if(!Ae||!he)return;const we=ge?he.portPos.get(ge):void 0;return we?Ae.y+we.y+Oe/2:Ae.y+he.height/2},te=ce=>ce.reduce((ge,Ae)=>ge+Ae,0)/ce.length;for(let ce=0;ce<2;ce++){const ge=new Map,Ae=(he,we)=>{he===void 0||we===void 0||(ge.has(he)||ge.set(he,[]),ge.get(he).push(we))};for(const he of ae){const we=j(he.source,he.sourcePort),Fe=j(he.target,he.targetPort);Ae(he.sourcePort??(Y.has(he.source)?he.source:void 0),Fe),Ae(he.targetPort??(Y.has(he.target)?he.target:void 0),we)}for(const he of I){const we=z.get(he),Fe=new Map;for(const $e of we.portPos.keys()){const Ze=ge.get($e);Ze!=null&&Ze.length&&Fe.set($e,te(Ze))}Fe.size>1&&Wt(we.portPos,Fe)}for(const he of P){const we=ge.get(he);we!=null&&we.length&&oe.set(he,te(we))}}oe.size>0&&ve.set(y,oe)}if(C.length>0){const q=Math.max(...C.map(we=>z.get(we).width)),oe=Math.max(V,q),j=Math.max(1,Math.min(C.length,Math.floor((oe+Ye)/(q+Ye))||1)),te=de>0?de+Ye:Re;let ce=0,ge=te,Ae=0,he=0;for(const we of C){const Fe=z.get(we),$e=_.left+ce*(q+Ye);U.set(we,{x:$e,y:ge}),V=Math.max(V,$e-_.left+Fe.width),Ae=Math.max(Ae,Fe.height),he=Math.max(he,ge+Fe.height),ce++,ce>=j&&(ce=0,ge+=Ae+Ye,Ae=0)}de=Math.max(de,he)}const Se=Math.min(Ee(K)+32,248);let Ne=Math.max(_.left+V+_.right,Se,Bt),Te=Math.max(de+Qe,Re+Qe+8);const Pe=new Map,je=ve.get(y)??new Map;for(const q of["left","right"]){const oe=P.filter(te=>fe(te)===q).sort((te,ce)=>(je.get(te)??0)-(je.get(ce)??0));let j=-1/0;for(const te of oe){const ce=Math.max(Te/2,Re+Oe/2);let ge=je.get(te)??(oe.length===1?ce:Re+ze/2);ge=Math.max(ge,Re+ze/2,j+ze);const Ae=ge+(b(te)-1)*et;j=Ae,Pe.set(te,{x:q==="left"?-Oe/2:Ne-Oe/2,y:ge-Oe/2,side:q}),Te=Math.max(Te,Ae+ze/2+Qe)}}for(const[q,oe]of Pe)oe.side==="right"&&(oe.x=Ne-Oe/2);const Ce={width:Ne,height:Te,childPos:U,portPos:Pe};return le.set(y,Ce),Ce},pe=f?[f]:a.roots.filter(y=>u(y));for(const y of pe)await xe(y);const Me=new Map;if(pe.length===1)Me.set(pe[0],{x:0,y:0});else{const y=Y=>{let ee=H(Y);const me=new Set;for(;ee&&X.has(ee)&&!me.has(ee);)me.add(ee),ee=X.get(ee);return ee&&pe.includes(ee)?ee:pe.includes(Y)?Y:ee},A=new Set(pe),P=[],K=(Y,ee)=>{var me;if(s.has(Y)&&m.get(Y)===ee){const ae=h(Y),ke=(me=le.get(ee))==null?void 0:me.portPos.get(ae);if(ke)return ke.y+Oe/2}return le.get(ee).height/2};N.forEach((Y,ee)=>{const me=y(Y.sourceId),ae=y(Y.targetId);me&&ae&&me!==ae&&A.has(me)&&A.has(ae)&&P.push({id:`root-${ee}`,source:me,target:ae,sourceAnchorY:K(Y.sourceId,me),targetAnchorY:K(Y.targetId,ae)})});const z=await Nt({id:"interconnection-roots",nodes:pe.map(Y=>({id:Y,width:le.get(Y).width,height:le.get(Y).height})),edges:P,gapX:ft,gapY:ft,directedFlowAxis:"RIGHT",layoutProviderId:e==null?void 0:e.layoutProviderId});for(const Y of z.children)Me.set(Y.id,{x:Y.x,y:Y.y});let se=0;for(const Y of pe)Me.has(Y)||(Me.set(Y,{x:se,y:0}),se+=le.get(Y).width+ft)}const v=new Map;for(const[y,A]of d){const P=le.get(y);if(!P)continue;const K=[];for(const z of A){const se=P.portPos.get(z);if(!se)continue;const Y=s.get(z);K.push({id:z,name:Y.name,x:se.x,y:se.y,side:se.side,direction:Dt(Y)??Ie(z)});const ee=se.y+Oe/2,me=se.x+(Oe-ut)/2;(M.get(z)??[]).forEach((ae,ke)=>{const I=s.get(ae);K.push({id:ae,name:I.name,x:me,y:ee+et*(ke+1)-ut/2,side:se.side,direction:Dt(I)??Ie(ae),size:ut,nested:!0})})}v.set(y,K)}const R=[],F=new Map,ie=(y,A,P,K={x:0,y:0})=>{var I;const z=a.elements.get(y),se=le.get(y),Y=Be[z.layer]||"#64748B",ee=P??Me.get(y),me=A?{x:K.x+ee.x,y:K.y+ee.y}:ee;F.set(y,me);const ae=(a.childrenMap.get(y)??[]).some(u),ke=ae;R.push({id:y,type:"interconnectionNode",position:ee,...A?{parentId:A,extent:"parent"}:{},data:{label:z.name,kind:z.kind,layer:z.layer,color:Y,isContainer:ke,isFrame:!A&&ke,hasChildren:ae,isCollapsed:((I=e==null?void 0:e.collapsedNodes)==null?void 0:I.has(y))??!1,onToggleCollapse:ae&&(e!=null&&e.onToggleCollapse)?()=>e.onToggleCollapse(y):void 0,ports:v.get(y)??[],implicitIn:i&&W.has(y),implicitOut:i&&G.has(y),onPortMove:e!=null&&e.onPortMove?(C,_)=>e.onPortMove(y,C,_):void 0},style:{width:se.width,height:se.height}});for(const[C,_]of se.childPos)ie(C,y,_,me)};for(const y of pe)ie(y);const r=(y,A)=>{let P=y;const K=new Set;for(;P&&!K.has(P);){if(P===A)return!0;K.add(P),P=X.get(P)}return!1},w=(y,A)=>{const P=m.get(y),K=H(A);return r(K,P)?`${y}${Ft}`:y},k=y=>s.has(y)?jt(y,l,g):void 0,L=N.flatMap((y,A)=>{const P=k(y.sourceId),K=k(y.targetId),z=s.has(y.sourceId)?m.get(y.sourceId):y.sourceId,se=s.has(y.targetId)?m.get(y.targetId):y.targetId;if(!le.has(z)||!le.has(se))return[];const Y=Bn(y.flowItem,y.type),ee=Ln[Y],me=y.flowItem||(y.type.toLowerCase()==="exchangeswith"?void 0:y.type),ae=P?w(P,y.targetId):"right",ke=K?w(K,y.sourceId):"left",I=Ce=>Ce==="left"?"right":Ce==="right"?"left":Ce==="top"?"bottom":"top",C=(Ce,q,oe,j)=>{var ce;if(!q)return j;const te=((ce=(v.get(Ce)??[]).find(ge=>ge.id===q))==null?void 0:ce.side)??j;return oe.endsWith(Ft)?I(te):te},_=C(z,P,ae,"right"),U=C(se,K,ke,"left"),V=y.id||`ic-e-${A}`,de=(Ce,q,oe)=>{const j=F.get(Ce),te=le.get(Ce);if(q){const ce=(v.get(Ce)??[]).find(ge=>ge.id===q);if(ce){const ge=ce.size??Oe;return{x:j.x+ce.x+ge/2,y:j.y+ce.y+ge/2}}}return{x:j.x+(oe?te.width:0),y:j.y+te.height/2}},Se=de(z,P,!0),Ne=de(se,K,!1),Te=F.get(z),Pe=F.get(se);return[{edge:{id:V,source:z,target:se,sourceHandle:ae,targetHandle:ke,type:"interconnectionEdge",className:"ibd-interconnection-edge",label:me,animated:y.type==="flow",style:{stroke:ee,strokeWidth:Math.max(2,ne.defaultWidth)},labelStyle:{fontSize:ue.badge,fill:"#4B5563",fontWeight:600},labelBgPadding:ne.labelBgPadding,labelBgBorderRadius:ne.labelBgRadius,labelBgStyle:{...ne.labelBgStyle,fillOpacity:.96,stroke:"#E2E8F0",strokeWidth:1},markerEnd:{type:"arrowclosed",color:ee,width:ne.arrowSize,height:ne.arrowSize},data:{flowCategory:Y,sourceOffset:{x:Se.x-Te.x,y:Se.y-Te.y},targetOffset:{x:Ne.x-Pe.x,y:Ne.y-Pe.y},sourcePortId:P,targetPortId:K,sourceSide:_,targetSide:U}},route:{id:V,source:Se,target:Ne,sourceNodeId:z,targetNodeId:se,sourceSide:_,targetSide:U}}]}),D=R.filter(y=>!y.data.isFrame).map(y=>{const A=F.get(y.id),P=le.get(y.id);return{id:y.id,x:A.x,y:A.y,width:P.width,height:P.height}}),Q=qe(L.map(y=>y.route),D),B=it(L.flatMap(({edge:y})=>{const A=Q.get(y.id);return y.label&&A&&A.length>=2?[{id:y.id,points:A,width:ct(String(y.label)),height:at}]:[]}),D),Z=L.map(({edge:y})=>({...y,data:{...y.data,points:Q.get(y.id)??[],labelPoint:B.get(y.id)}}));return{nodes:R,edges:Z}}function Le(t){return t.kind==="ForkNode"||t.kind==="JoinNode"}function eo(t,e){const n=new Set(t.filter(s=>!Le(s)).map(s=>s.id)),o=new Set;for(const s of e.relationships)s.type!=="flow"&&s.type!=="succession"||(n.has(s.sourceId)&&o.add(s.sourceId),n.has(s.targetId)&&o.add(s.targetId));return t.filter(s=>!Le(s)&&!o.has(s.id))}function Un(t,e,n=new Set,o){const s=Object.values(t.elements),l=(e?s.filter(e):s).filter(u=>u.construct==="action"||u.kind==="ActionUsage"||u.kind==="ActionDefinition"),i=l.filter(u=>u.parentAction);if(i.length===0)return l;const a=new Map(l.map(u=>[u.id,u])),f=[],p=u=>{const x=l.filter(m=>m.parentAction===u.id);if(n.has(u.id)&&x.length>0){for(const m of x)p(m);return}f.push(u)};if(o){for(const u of l.filter(x=>x.parentAction===o))p(u);return f}for(const u of i){const x=u.parentAction?a.get(u.parentAction):void 0;x!=null&&x.parentAction||p(u)}return f}function Vn(t,e,n=new Set,o){const s=Object.values(t.elements),l=(e?s.filter(e):s).filter(g=>g.construct==="action"||g.kind==="ActionUsage"||g.kind==="ActionDefinition"),i=[],a=new Map,f=new Map,p=g=>l.filter(h=>h.parentAction===g),u=(g,h)=>{i.push(g),h&&(a.set(g.id,h),f.has(h)||f.set(h,[]),f.get(h).push(g.id));const d=p(g.id);if(!(d.length===0||!n.has(g.id))){f.set(g.id,[]);for(const M of d)u(M,g.id)}};if(o){for(const g of p(o))u(g);return{actions:i,parentOf:a,childrenOf:f}}const x=new Map(l.map(g=>[g.id,g])),m=l.filter(g=>g.parentAction);if(m.length===0)return{actions:l,parentOf:a,childrenOf:f};for(const g of m){const h=g.parentAction?x.get(g.parentAction):void 0;h!=null&&h.parentAction||u(g)}return{actions:i,parentOf:a,childrenOf:f}}function qn(t,e){const n=t.attributes.actionType,o=n?e.elements[n]:void 0,s=((o==null?void 0:o.construct)==="action"?o.parameters:t.parameters)??[];return{inPorts:s.filter(c=>c.direction==="in"||c.direction==="inout").map(c=>c.name),outPorts:s.filter(c=>c.direction==="out"||c.direction==="inout").map(c=>c.name)}}const Ht=["#4A90D9","#E67E22","#2ECC71","#9B59B6","#E74C3C","#1ABC9C","#F39C12","#7B68EE"],mt="Unallocated",Zn="Unstaged";function Et(t,e,n="all"){const o=new Map;for(const a of e.relationships)Ve.has(a.type)&&!o.has(a.targetId)&&o.set(a.targetId,a.sourceId);const s=[t],c=new Set(s);let l=t;for(;o.has(l);){const a=o.get(l);if(c.has(a))break;s.unshift(a),c.add(a),l=a}if(n==="all")return{id:t,level:s.length};const i=Math.min(Math.max(n,1),s.length)-1;return{id:s[i],level:i+1}}function Jn(t,e,n="all"){var s;const o=Et(t,e,n).id;return((s=e.elements[o])==null?void 0:s.name)??o}function to(t,e){const n=[...new Set(t)].map(s=>Et(s,e).level);if(n.length===0)return[];const o=Math.min(...n);return o<=1?[]:Array.from({length:o},(s,c)=>c+1)}function Qn(t,e,n="allocation",o="all"){var i,a;const s=new Map,c=[],l=new Map;for(const f of t){if(Le(f))continue;const p=f.allocatedTo?Et(f.allocatedTo,e,o).id:mt,u=n==="stage"?f.attributes.stage||f.attributes.phase||Zn:p;if(s.set(f.id,u),!l.has(u)){const x={id:u,label:n==="allocation"&&u!==mt?((i=e.elements[u])==null?void 0:i.name)??u:u,color:Ht[l.size%Ht.length],inspectElementId:n==="allocation"&&u!==mt?u:((a=Object.values(e.elements).find(m=>m.id===u||m.name===u))==null?void 0:a.id)??f.id};l.set(u,x),c.push(x)}}return{laneOf:s,lanes:c}}const es=18,ts=36,ns=20,Xe=36,zt=16,Gt=120,pt=32,$t=64,Yt=10;function ss(t,e,n){if(Le(t))return n==="vertical"?{width:$t,height:Yt}:{width:Yt,height:$t};const s=Math.max(e.inPorts.length,e.outPorts.length,0)*es;return{width:Math.max(t.name.length*9+40,140),height:ts+s+(s>0?8:0)+(t.allocatedTo?ns:0)}}function Xt(t){const e=t??"";return/energy|power|voltage|current|thermal|heat/i.test(e)?"energy":/material|fluid|gas|liquid|batch|consumable/i.test(e)?"material":"data"}const yt={control:"#4B5563",data:"#3498DB",energy:"#D97706",material:"#16A34A"};async function no(t,e){var v,R,F,ie;const n=(e==null?void 0:e.nesting)??"flat",o=n==="nested"?Vn(t,e==null?void 0:e.viewpointFilter,e==null?void 0:e.expandedActionIds,e==null?void 0:e.focusActionId):{actions:Un(t,e==null?void 0:e.viewpointFilter,e==null?void 0:e.expandedActionIds,e==null?void 0:e.focusActionId),childrenOf:new Map},s=o.actions;if(s.length===0)return{nodes:[],edges:[]};const c=new Set(s.map(r=>r.id)),{laneOf:l,lanes:i}=Qn(s,t,e==null?void 0:e.laneGrouping,e==null?void 0:e.displayLevel),a=(e==null?void 0:e.direction)??"horizontal",f=n!=="nested"&&((e==null?void 0:e.swimlanes)??!0)&&i.length>=1,p=t.relationships.filter(r=>r.type==="succession"),u=t.relationships.filter(r=>r.type==="flow"),x=new Map;for(const r of n==="nested"?[]:(e==null?void 0:e.expandedActionIds)??[]){const w=Object.values(t.elements).filter(D=>D.parentAction===r);if(w.length===0)continue;const k=((v=p.find(D=>D.sourceId===`${r}__start`))==null?void 0:v.targetId)??w[0].id,L=((R=p.find(D=>D.targetId===`${r}__done`))==null?void 0:R.sourceId)??w[w.length-1].id;x.set(r,{first:k,last:L})}const m=r=>r.map(w=>{var k,L;return{...w,sourceId:((k=x.get(w.sourceId))==null?void 0:k.last)??w.sourceId,targetId:((L=x.get(w.targetId))==null?void 0:L.first)??w.targetId}}),g=m(p),h=m(u),d=new Set;for(const r of g){const w=r.sourceId.endsWith("__start")?r.sourceId.slice(0,-7):void 0,k=r.targetId.endsWith("__done")?r.targetId.slice(0,-6):void 0;w&&!x.has(w)&&c.has(r.targetId)&&d.add(r.sourceId),k&&!x.has(k)&&c.has(r.sourceId)&&d.add(r.targetId)}const M=new Set([...c,...d]),b=h.filter(r=>M.has(r.sourceId)&&M.has(r.targetId)&&(!(e!=null&&e.visibleFlowKinds)||e.visibleFlowKinds.has(Xt(r.flowItem)))),E=new Set(b.map(r=>`${r.sourceId}\0${r.targetId}`)),S=g.filter(r=>M.has(r.sourceId)&&M.has(r.targetId)&&(!(e!=null&&e.visibleFlowKinds)||e.visibleFlowKinds.has("control"))&&!E.has(`${r.sourceId}\0${r.targetId}`)),N=new Map(s.map(r=>[r.id,qn(r,t)])),T=new Map(s.map(r=>[r.id,r])),G=new Map,W=new Map;if(n==="nested"){for(const[r,w]of o.childrenOf)G.set(r,w.filter(k=>M.has(k)));for(const r of d){const w=r.endsWith("__start")?r.slice(0,-7):r.slice(0,-6);G.has(w)&&G.get(w).push(r)}for(const[r,w]of G)for(const k of w)W.set(k,r)}const H=r=>{const w=T.get(r);return w?ss(w,N.get(r),a):{width:28,height:28}},X=r=>{const w=G.get(r)??[];return w.length===0?{id:r,...H(r)}:{id:r,layoutOptions:{"elk.algorithm":"layered","elk.direction":a==="vertical"?"DOWN":"RIGHT","elk.padding":"[top=44,left=24,bottom=24,right=24]","elk.spacing.nodeNode":"36","elk.layered.spacing.nodeNodeBetweenLayers":"68","elk.layered.considerModelOrder.strategy":"NODES_AND_EDGES"},children:w.map(X)}},re=[...d,...s.map(r=>r.id)].filter(r=>!W.has(r)),Ie={id:"root",layoutOptions:{"elk.algorithm":"layered","elk.direction":a==="vertical"?"DOWN":"RIGHT","elk.spacing.nodeNode":"40","elk.layered.spacing.nodeNodeBetweenLayers":"80","elk.layered.considerModelOrder.strategy":"NODES_AND_EDGES","elk.layered.nodePlacement.strategy":"NETWORK_SIMPLEX","elk.layered.crossingMinimization.strategy":"LAYER_SWEEP","elk.separateConnectedComponents":"true","elk.spacing.componentComponent":"56",...n==="nested"?{"elk.hierarchyHandling":"INCLUDE_CHILDREN"}:{}},children:re.map(X),edges:[...b,...S].map((r,w)=>({id:`afe-${w}`,sources:[r.sourceId],targets:[r.targetId]}))},fe=await Ge.layout(Ie,{providerId:e==null?void 0:e.layoutProviderId}),$=new Map,Ee=r=>{$.set(r.id,{x:r.x??0,y:r.y??0,width:r.width??140,height:r.height??56});for(const w of r.children??[])Ee(w)};for(const r of fe.children??[])Ee(r);const be=new Map(i.map(r=>[r.id,r.color])),le=[];if(f&&a==="horizontal"){const r=new Map;for(const Q of s){if(Le(Q))continue;const B=$.get(Q.id),Z=l.get(Q.id);r.has(Z)||r.set(Z,[]),r.get(Z).push(B.y)}const w=[...i].sort((Q,B)=>{const Z=J=>J.reduce((y,A)=>y+A,0)/J.length;return Z(r.get(Q.id)??[0])-Z(r.get(B.id)??[0])});let k=1/0,L=-1/0;for(const Q of s){const B=$.get(Q.id);k=Math.min(k,B.x),L=Math.max(L,B.x+B.width)}let D=0;for(const Q of w){const B=s.filter(A=>l.get(A.id)===Q.id);B.sort((A,P)=>$.get(A.id).x-$.get(P.id).x||$.get(A.id).y-$.get(P.id).y);const Z=Math.min(...B.map(A=>$.get(A.id).y));let J=0;const y=[];for(const A of B){const P=$.get(A.id);let K=D+Xe+(P.y-Z);for(const z of y)P.x<z.x1&&P.x+P.width>z.x0&&(K=Math.max(K,z.bottom+16));$.set(A.id,{...P,y:K}),y.push({x0:P.x,x1:P.x+P.width,bottom:K+P.height}),J=Math.max(J,K+P.height-D)}J+=Xe,le.push({id:`__lane_${Q.id}`,type:"actionFlowLane",position:{x:k-Gt,y:D},data:{label:Q.label,color:Q.color,orientation:"row",inspectElementId:Q.inspectElementId,memberIds:B.map(A=>A.id),isFrame:!0},style:{width:L-k+Gt+Xe,height:J},draggable:!1,selectable:!1,zIndex:-1}),D+=J+zt}}else if(f){let r=1/0,w=-1/0;for(const L of s){const D=$.get(L.id);r=Math.min(r,D.y),w=Math.max(w,D.y+D.height)}let k=0;for(const L of i){const D=s.filter(Z=>l.get(Z.id)===L.id).sort((Z,J)=>$.get(Z.id).y-$.get(J.id).y||$.get(Z.id).x-$.get(J.id).x),B=Math.max(...D.map(Z=>$.get(Z.id).width))+Xe*2;for(const Z of D){const J=$.get(Z.id);$.set(Z.id,{...J,x:k+(B-J.width)/2})}le.push({id:`__lane_${L.id}`,type:"actionFlowLane",position:{x:k,y:r-pt},data:{label:L.label,color:L.color,orientation:"column",inspectElementId:L.inspectElementId,memberIds:D.map(Z=>Z.id),isFrame:!0},style:{width:B,height:w-r+pt+Xe},draggable:!1,selectable:!1,zIndex:-1}),k+=B+zt}}const ve=n==="nested"?[]:s.filter(Le);if(ve.length>0)for(const r of ve){const w=$.get(r.id),k=[];for(const D of[...S,...b]){const Q=D.sourceId===r.id?D.targetId:D.targetId===r.id?D.sourceId:void 0;if(Q===void 0)continue;const B=$.get(Q);B&&k.push(a==="vertical"?B.x+B.width/2:B.y+B.height/2)}if(k.length===0)continue;const L=k.reduce((D,Q)=>D+Q,0)/k.length;$.set(r.id,a==="vertical"?{...w,x:L-w.width/2}:{...w,y:L-w.height/2})}for(const r of n==="nested"?[]:d){const w=$.get(r);if(!w)continue;const k=[];for(const B of S){const Z=B.sourceId===r?B.targetId:B.targetId===r?B.sourceId:void 0;if(!Z)continue;const J=$.get(Z);J&&k.push(a==="vertical"?J.x+J.width/2:J.y+J.height/2)}if(k.length===0)continue;const L=k.reduce((B,Z)=>B+Z,0)/k.length,D=s.filter(B=>!Le(B)).map(B=>$.get(B.id)).filter(B=>!!B),Q=r.endsWith("__start");if(a==="vertical"){const B=Math.min(...D.map(J=>J.y)),Z=Math.max(...D.map(J=>J.y+J.height));$.set(r,{...w,x:L-w.width/2,y:Q?B-w.height-pt-16:Z+24})}else{const B=Math.min(...D.map(J=>J.x)),Z=Math.max(...D.map(J=>J.x+J.width));$.set(r,{...w,x:Q?B-w.width-24:Z+24,y:L-w.height/2})}}const xe=[...le],pe=r=>{const w=W.get(r);return w?{parentId:w,extent:"parent"}:{}};for(const r of d){const w=$.get(r),k=r.endsWith("__start"),L={label:k?"Start":"Done",nodeType:k?"start":"done",laneColor:"#374151",layerColor:"#374151",inPorts:[],outPorts:[],flowDirection:a};xe.push({id:r,type:"actionFlowNode",position:{x:w.x,y:w.y},...pe(r),data:L})}for(const r of s){const w=$.get(r.id);if(Le(r)){const Z={element:r,label:r.name,nodeType:r.kind==="ForkNode"?"fork":"join",laneColor:"#374151",layerColor:"#374151",inPorts:[],outPorts:[],flowDirection:a};xe.push({id:r.id,type:"actionFlowNode",position:{x:w.x,y:w.y},style:{width:w.width,height:w.height},...pe(r.id),data:Z});continue}const k=N.get(r.id),L=l.get(r.id),D=r.allocatedTo?Jn(r.allocatedTo,t,e==null?void 0:e.displayLevel):void 0,Q=(((F=G.get(r.id))==null?void 0:F.length)??0)>0,B={element:r,label:r.name,nodeType:"action",parameters:r.parameters,allocatedTo:D,laneColor:be.get(L)??"#9CA3AF",layerColor:Be[r.layer]||"#FF6B6B",inPorts:k.inPorts,outPorts:k.outPorts,hasChildren:Object.values(t.elements).some(Z=>Z.parentAction===r.id),isExpanded:((ie=e==null?void 0:e.expandedActionIds)==null?void 0:ie.has(r.id))??!1,isFrame:Q,onToggleExpand:e!=null&&e.onToggleAction?()=>e.onToggleAction(r.id):void 0,onDrillIn:e!=null&&e.onDrillInAction?()=>e.onDrillInAction(r.id):void 0,flowDirection:a};xe.push({id:r.id,type:"actionFlowNode",position:{x:w.x,y:w.y},...Q?{style:{width:w.width,height:w.height}}:{},...pe(r.id),data:B})}if(W.size>0){const r=new Map(xe.map(D=>[D.id,D])),w=[],k=new Set,L=D=>{if(k.has(D.id))return;k.add(D.id);const Q=D.parentId?r.get(D.parentId):void 0;Q&&L(Q),w.push(D)};for(const D of xe)L(D);xe.length=0,xe.push(...w)}const Me=[];for(const r of b){const w=Xt(r.flowItem),k=yt[w],L=r.flowItem?/signal|error|status|code|report|alarm|response|command|data|reading/i.test(r.flowItem):!1;Me.push({id:r.id,source:r.sourceId,target:r.targetId,label:void 0,type:"smoothstep",animated:!1,style:{stroke:k,strokeWidth:ne.flowWidth,strokeDasharray:L?"6 3":void 0},labelStyle:{fontSize:ue.badge,fill:k,fontWeight:600},labelBgStyle:ne.labelBgStyle,labelBgPadding:ne.labelBgPadding,labelBgBorderRadius:ne.labelBgRadius,markerEnd:{type:"arrowclosed",color:k,width:ne.arrowSize,height:ne.arrowSize},data:{flowCategory:w,flowItem:r.flowItem}})}for(const r of S)Me.push({id:r.id,source:r.sourceId,target:r.targetId,type:"smoothstep",animated:!1,style:{stroke:yt.control,strokeWidth:1.5},markerEnd:{type:"arrowclosed",color:yt.control,width:12,height:12},data:{flowCategory:"control"}});return{nodes:xe,edges:Me}}function os(t){return t.attributes.sourceState&&t.attributes.targetState?!0:t.kind==="Transition"||t.kind.endsWith("Transition")}function rs(t){return t.kind.endsWith("State")||t.kind.endsWith("Machine")||t.kind.endsWith("Mode")}function is(t,e){const n=Object.values(t.elements),o=e?n.filter(e):n,s=[],c=[],l=[];for(const i of o)os(i)?c.push(i):rs(i)?s.push(i):l.push(i);return{states:s,transitions:c,annotations:l}}const Kt=46;function as(t){return t.length>Kt?`${t.slice(0,Kt-1)}…`:t}function cs(t){const e=t.attributes.trigger??"",n=t.attributes.guardSummary??t.attributes.guard??"",o=n&&!/^none\b/i.test(n),s=e||t.name;return as(o?`${s} [${n}]`:s)}function ls(t,e){const n=new Map;for(const s of e)n.set(s.name,s.id),n.set(s.id,s.id);const o=[];for(const s of t){const c=n.get(s.attributes.sourceState??""),l=n.get(s.attributes.targetState??"");!c||!l||o.push({element:s,sourceId:c,targetId:l,label:cs(s)})}return o}function ds(t,e={}){const n=e.collapsedStateIds??new Set,o=e.focusStateId&&t.elements.has(e.focusStateId)?e.focusStateId:void 0,s=x=>(t.childrenMap.get(x)??[]).filter(m=>t.elements.has(m)),c=o?s(o):[],l=c.length>0?c:t.roots.filter(x=>t.elements.has(x)),i=new Set,a=new Map,f=new Map,p=(x,m)=>{a.set(x,m),f.set(m,(f.get(m)??0)+1);for(const g of s(x))p(g,m)},u=x=>{i.add(x);const m=s(x);if(n.has(x)){for(const g of m)p(g,x);return}for(const g of m)u(g)};for(const x of l)u(x);return{visible:i,liftTo:a,hiddenCount:f,roots:l}}function hs(t,e){const n=s=>e.visible.has(s)?s:e.liftTo.get(s),o=[];for(const s of t){const c=n(s.sourceId),l=n(s.targetId);if(!c||!l)continue;const i=s.sourceId===s.targetId;c===l&&!i||o.push({...s,sourceId:c,targetId:l})}return o}const us="#FF6B6B",gs="#95A5A6",Ut="#64748B";async function so(t,e){const{states:n,transitions:o,annotations:s}=is(t,e==null?void 0:e.viewpointFilter);if(n.length===0&&s.length===0)return{nodes:[],edges:[]};const c=rt(n,t.relationships),l=ds(c,{focusStateId:e==null?void 0:e.focusStateId,collapsedStateIds:e==null?void 0:e.collapsedStateIds}),i=hs(ls(o,n),l);if(l.visible.size===0&&s.length===0)return{nodes:[],edges:[]};const a=b=>({width:Math.max(b.name.length*7.5+56,150),height:(c.childrenMap.get(b.id)??[]).some(E=>c.elements.has(E))?74:54}),f=b=>{const E=c.elements.get(b),S=(c.childrenMap.get(b)??[]).filter(N=>l.visible.has(N));return S.length===0?{id:b,...a(E)}:{id:b,layoutOptions:{"elk.algorithm":"layered","elk.direction":"DOWN","elk.padding":"[top=48,left=28,bottom=28,right=28]","elk.spacing.nodeNode":"72","elk.layered.spacing.nodeNodeBetweenLayers":"120","elk.spacing.edgeNode":"32","elk.edgeRouting":"ORTHOGONAL","elk.layered.cycleBreaking.strategy":"MODEL_ORDER","elk.layered.considerModelOrder.strategy":"NODES_AND_EDGES"},children:S.map(f)}},p={id:"root",layoutOptions:{"elk.algorithm":"layered","elk.direction":"DOWN","elk.hierarchyHandling":"INCLUDE_CHILDREN","elk.edgeRouting":"ORTHOGONAL","elk.spacing.nodeNode":"72","elk.layered.spacing.nodeNodeBetweenLayers":"120","elk.spacing.edgeNode":"32","elk.spacing.edgeLabel":"8","elk.layered.cycleBreaking.strategy":"MODEL_ORDER","elk.layered.considerModelOrder.strategy":"NODES_AND_EDGES","elk.separateConnectedComponents":"true","elk.spacing.componentComponent":"64","elk.padding":"[top=20, left=20, bottom=20, right=20]"},children:l.roots.map(f),edges:i.map((b,E)=>({id:`st-${E}`,sources:[b.sourceId],targets:[b.targetId]}))},u=await Ge.layout(p,{providerId:e==null?void 0:e.layoutProviderId}),x=[],m=new Map,g=(b,E,S={x:0,y:0})=>{var T,G;const N=c.elements.get(b.id);if(N){const W=!!((T=b.children)!=null&&T.length),H=N.kind.endsWith("Machine"),X={x:S.x+(b.x??0),y:S.y+(b.y??0)};m.set(b.id,{...X,width:b.width??150,height:b.height??54,isContainer:W}),x.push({id:b.id,type:"stateNode",position:{x:b.x??0,y:b.y??0},...E?{parentId:E,extent:"parent"}:{},data:{label:N.name,kind:N.kind,color:us,isContainer:W,isMachine:H,subtitle:N.attributes.modeKind,hasChildren:(c.childrenMap.get(b.id)??[]).some(re=>c.elements.has(re)),isCollapsed:!!((G=e==null?void 0:e.collapsedStateIds)!=null&&G.has(b.id)),hiddenCount:l.hiddenCount.get(b.id)??0,onToggleCollapse:e!=null&&e.onToggleCollapse?()=>e.onToggleCollapse(b.id):void 0,onDrillIn:e!=null&&e.onDrillIn?()=>e.onDrillIn(b.id):void 0},style:{width:b.width??150,height:b.height??54}});for(const re of b.children??[])g(re,b.id,X);return}};for(const b of u.children??[])g(b);if(s.length>0){let b=0,E=800;for(const W of u.children??[])b=Math.max(b,(W.y??0)+(W.height??0)),E=Math.max(E,(W.x??0)+(W.width??0));const S=240,N=48,T=14,G=Math.max(2,Math.floor(E/(S+T)));s.forEach((W,H)=>{x.push({id:W.id,type:"stateNode",position:{x:H%G*(S+T),y:b+56+Math.floor(H/G)*(N+T)},data:{label:W.name,kind:W.kind,color:gs,isNote:!0},style:{width:S,height:N}})})}const h=[...m.entries()].filter(([,b])=>!b.isContainer).map(([b,E])=>({id:b,x:E.x,y:E.y,width:E.width,height:E.height})),d=kn({connectors:i.map((b,E)=>({id:b.element.id||`st-e-${E}`,sourceId:b.sourceId,targetId:b.targetId,label:b.label})),rects:m,obstacles:h,channelGap:26}),M=i.map((b,E)=>{const S=b.element.id||`st-e-${E}`,N=d.get(S),T={id:S,source:b.sourceId,target:b.targetId,label:b.label,style:{stroke:Ut,strokeWidth:ne.defaultWidth},markerEnd:{type:"arrowclosed",color:Ut,width:ne.arrowSize,height:ne.arrowSize}};return N?{...T,type:"interconnectionEdge",data:{points:N.points,labelPoint:N.labelPoint}}:{...T,type:"smoothstep",labelStyle:{fontSize:ue.badge,fill:"#6B7280",fontWeight:500},labelBgPadding:ne.labelBgPadding,labelBgBorderRadius:ne.labelBgRadius,labelBgStyle:ne.labelBgStyle}});return{nodes:x,edges:M}}const fs=/(?:Actor|User)$/,ms=new Set(["UseCase"]),gn=new Set(["initiates","participatesin","performs","interactswith","includes","extends"]),_e=t=>t.toLowerCase();function fn(t){return fs.test(t.kind)||t.construct==="actor"}function vt(t){return ms.has(t.kind)||t.construct==="use case"}function oo(t){const e=new Set(Object.values(t.elements).filter(vt).map(s=>s.id)),n=new Map;for(const s of t.relationships.filter(c=>_e(c.type)==="includes"&&e.has(c.sourceId)&&e.has(c.targetId)))n.set(s.targetId,[...n.get(s.targetId)??[],s.sourceId]);const o=(s,c=new Set)=>{if(c.has(s))return 0;const l=n.get(s)??[];return l.length===0?0:1+Math.min(...l.map(i=>o(i,new Set([...c,s]))))};return Math.max(0,...[...e].map(s=>o(s)))}function ro(t){const e=Object.values(t.elements),n=new Set(e.filter(vt).map(s=>s.id)),o=new Set(t.relationships.filter(s=>gn.has(_e(s.type))).flatMap(s=>n.has(s.sourceId)?[s.targetId]:n.has(s.targetId)?[s.sourceId]:[]));return e.filter(fn).filter(s=>o.has(s.id)).map(s=>({id:s.id,name:s.name})).sort((s,c)=>s.name.localeCompare(c.name))}function io(t){var s,c;const e=`${(t==null?void 0:t.layoutHint)??""};${(t==null?void 0:t.styleHint)??""}`,n=/(?:usecase:)?level\s*=\s*(all|\d+)/i.exec(e),o=/(?:edge|routing)\s*=\s*(straight|orthogonal|elbow|rounded|curved|arc)/i.exec(e);return{level:(n==null?void 0:n[1])==="all"?"all":n?Number(n[1]):"all",edgeStyle:{orthogonal:"elbow"}[((s=o==null?void 0:o[1])==null?void 0:s.toLowerCase())??""]??((c=o==null?void 0:o[1])==null?void 0:c.toLowerCase())??"rounded"}}function ao(t,e={}){const n=Object.values(t.elements).filter(I=>!e.viewpointFilter||e.viewpointFilter(I)),o=n.filter(vt),s=t.relationships.filter(I=>gn.has(_e(I.type))),c=new Map;for(const I of s.filter(C=>_e(C.type)==="includes")){const C=c.get(I.targetId)??[];C.push(I.sourceId),c.set(I.targetId,C)}const l=(I,C=new Set)=>{if(C.has(I))return 0;const _=c.get(I)??[];return _.length===0?0:1+Math.min(..._.map(U=>l(U,new Set([...C,I]))))},i=e.level??"all",a=new Set(o.filter(I=>i==="all"||l(I.id)<=i).map(I=>I.id));let f=!0;for(;f;){f=!1;for(const I of s.filter(C=>_e(C.type)==="extends"))if(a.has(I.sourceId)||a.has(I.targetId))for(const C of[I.sourceId,I.targetId])!a.has(C)&&o.some(_=>_.id===C)&&(a.add(C),f=!0)}const p=e.hiddenActorIds??new Set;for(const I of s){const C=a.has(I.sourceId)?I.targetId:a.has(I.targetId)?I.sourceId:void 0;C&&p.has(C)&&(a.delete(I.sourceId),a.delete(I.targetId))}const u=o.filter(I=>a.has(I.id)),x=n.filter(fn).filter(I=>!p.has(I.id)).filter(I=>s.some(C=>C.sourceId===I.id&&a.has(C.targetId)||C.targetId===I.id&&a.has(C.sourceId))),m=new Set([...x,...u].map(I=>I.id));if(u.length===0)return{nodes:[],edges:[]};const g=new Set(s.filter(I=>_e(I.type)==="extends").map(I=>I.sourceId)),h=new Map;for(const I of u){if(g.has(I.id))continue;const C=l(I.id);h.set(C,[...h.get(C)??[],I])}const M=[...h.keys()].sort((I,C)=>I-C).map(I=>[...h.get(I)??[]]),b=new Map;M.forEach((I,C)=>I.forEach(_=>b.set(_.id,C)));const E=new Map;for(const I of s.filter(C=>_e(C.type)==="extends")){const C=u.find(V=>V.id===I.sourceId),_=b.get(I.targetId);if(!C||_===void 0||b.has(C.id))continue;const U=M[_];U.splice(U.findIndex(V=>V.id===I.targetId)+1,0,C),b.set(C.id,_),E.set(I.targetId,[...E.get(I.targetId)??[],C])}const S=new Set([...E.values()].flat().map(I=>I.id)),N=I=>s.filter(C=>C.sourceId===I||C.targetId===I).map(C=>C.sourceId===I?C.targetId:C.sourceId),T=new Map,G=()=>M.forEach(I=>I.forEach((C,_)=>T.set(C.id,_)));G(),x.forEach((I,C)=>T.set(I.id,C));const W=I=>{const C=N(I).map(_=>T.get(_)).filter(_=>_!==void 0);return C.length===0?T.get(I)??0:C.reduce((_,U)=>_+U,0)/C.length};for(let I=0;I<3;I++){const C=I%2===0?M:[...M].reverse();for(const _ of C){const U=_.filter(V=>!S.has(V.id));U.sort((V,de)=>W(V.id)-W(de.id)),_.splice(0,_.length,...U.flatMap(V=>[V,...E.get(V.id)??[]])),G()}x.sort((_,U)=>W(_.id)-W(U.id)),x.forEach((_,U)=>T.set(_.id,U))}const H=176,X=88,re=104,Ie=40,fe=104,$=88,Ee=116,be=48,le=62,ve=44,xe=76,pe=20,Me=Math.max(1,...M.map(I=>I.length)),v=Math.max(520,M.length*H+Math.max(M.length-1,0)*re+be*2),R=Math.max(300,Me*X+(Me-1)*Ie+le+ve),F=I=>be+I*(H+re)+H/2,ie=new Map;for(const I of x){const C=N(I.id).map(U=>b.get(U)).filter(U=>U!==void 0).map(F),_=C.length?C.reduce((U,V)=>U+V,0)/C.length:0;ie.set(I.id,C.length===0||_<=v/2?"left":"right")}const r=x.filter(I=>ie.get(I.id)==="left"),w=x.filter(I=>ie.get(I.id)==="right"),k=pe+(r.length?fe+xe:0),L=pe,D=[{id:"__use_case_boundary__",type:"useCaseBoundary",position:{x:k,y:L},data:{label:e.systemName||"System Boundary",isFrame:!0,kind:"System Boundary"},style:{width:v,height:R},draggable:!1,selectable:!1,zIndex:-1}],Q=new Map,B=L+le,Z=R-le-ve;M.forEach((I,C)=>{const _=I.length*X+(I.length-1)*Ie;let U=B+(Z-_)/2;for(const V of I){const de={x:k+be+C*(H+re),y:U};Q.set(V.id,de),D.push({id:V.id,type:"useCase",position:de,data:{label:V.name,kind:V.kind,color:"#E67E22",level:l(V.id)},style:{width:H,height:X}}),U+=X+Ie}});for(const I of["left","right"]){const _=(I==="left"?r:w).map(V=>{const de=N(V.id).map(Se=>Q.get(Se)).filter(Se=>!!Se).map(Se=>Se.y);return{actor:V,y:de.length?de.reduce((Se,Ne)=>Se+Ne,0)/de.length:L+le}}).sort((V,de)=>V.y-de.y);let U=-1/0;for(const{actor:V,y:de}of _){const Se=Math.max(de,U+Ee-$,pe);U=Se+$,D.push({id:V.id,type:"useCaseActor",position:{x:I==="left"?pe:k+v+xe,y:Se},data:{label:V.name,kind:V.kind,color:"#334155",side:I},style:{width:fe,height:$}})}}const J=e.edgeStyle??"rounded",y=s.filter(I=>m.has(I.sourceId)&&m.has(I.targetId)).map(I=>{const C=w.some(V=>V.id===I.sourceId),_=C?I.targetId:I.sourceId,U=C?I.sourceId:I.targetId;return{edge:{id:I.id,source:_,target:U,label:/^(includes|extends)$/.test(_e(I.type))?`«${_e(I.type)}»`:void 0,type:"useCaseEdge",data:{routing:J},style:{stroke:"#64748B",strokeWidth:1.4,strokeDasharray:/^(includes|extends)$/.test(_e(I.type))?"5 4":void 0}},source:_,target:U}}),A=new Map(D.map(I=>[I.id,I])),P=I=>{var C,_;return{width:Number(((C=I.style)==null?void 0:C.width)??150),height:Number(((_=I.style)==null?void 0:_.height)??82)}},K=(I,C)=>{const _=P(A.get(I));return C==="left"?{x:0,y:_.height/2}:C==="right"?{x:_.width,y:_.height/2}:C==="top"?{x:_.width/2,y:0}:{x:_.width/2,y:_.height}},z=(I,C)=>{const _=A.get(I),U=K(I,C);return{x:_.position.x+U.x,y:_.position.y+U.y}},se=y.map(({edge:I,source:C,target:_})=>{var Pe,je;const U=x.find(Ce=>Ce.id===C),V=x.find(Ce=>Ce.id===_),de=!U&&!V&&b.get(C)!==void 0&&b.get(C)===b.get(_),Se=de&&(((Pe=Q.get(C))==null?void 0:Pe.y)??0)<(((je=Q.get(_))==null?void 0:je.y)??0),Ne=U?w.includes(U)?"left":"right":de?Se?"bottom":"top":"right",Te=V?w.includes(V)?"left":"right":de?Se?"top":"bottom":"left";return{id:I.id,source:z(C,Ne),target:z(_,Te),sourceNodeId:C,targetNodeId:_,sourceSide:Ne,targetSide:Te}}),Y=D.filter(I=>I.type==="useCase"||I.type==="useCaseActor").map(I=>({id:I.id,x:I.position.x,y:I.position.y,...P(I)})),ee=J==="straight"?new Map:qe(se,Y,28),me=it(y.flatMap(({edge:I})=>{const C=ee.get(I.id),_=I.label;return _&&C&&C.length>=2?[{id:I.id,points:C,width:ct(_),height:at}]:[]}),Y),ae=new Map(se.map(I=>[I.id,I])),ke=y.map(({edge:I})=>({...I,data:{...I.data,points:ee.get(I.id)??[],labelPoint:me.get(I.id),sourceOffset:K(I.source,ae.get(I.id).sourceSide),targetOffset:K(I.target,ae.get(I.id).targetSide),sourceSide:ae.get(I.id).sourceSide,targetSide:ae.get(I.id).targetSide}}));return{nodes:D,edges:ke}}const Vt=new Set(["includesStep",...Ve]);function qt(t){return t.kind.endsWith("Step")||!!t.attributes.stepOrder}function ps(t){if(!t)return;const e=t.split(":");return(e.length>1?e[e.length-1]:e[0]).trim()||void 0}function ys(t,e){const n=t.split(":")[0].trim(),o=e.elements[n];if(o)return o.name;for(const s of Object.values(e.elements))if(s.attributes.id===n)return s.name;return t}const Zt=t=>{const e=Number(t.attributes.stepOrder);return Number.isFinite(e)?e:0};function xs(t,e){const n=Object.values(t.elements),o=e?n.filter(e):n,s=o.filter(qt),c=new Set(s.map(h=>h.id)),l=o.filter(h=>!qt(h)&&t.relationships.some(d=>Vt.has(d.type)&&d.sourceId===h.id&&c.has(d.targetId))),i=[],a=new Map,f=h=>{const d=h.split(":")[0].trim()||h;return a.has(d)||(a.set(d,i.length),i.push({id:d,label:ys(h,t)})),a.get(d)},p=h=>[...h].sort((d,M)=>Zt(d)-Zt(M)).map(d=>({step:d,lane:f(d.attributes.allocatedFunction??d.allocatedTo??d.id),item:ps(d.attributes.exchangeItem)})),u=h=>{var M;const d=t.relationships.find(b=>b.type==="realizesScenario"&&b.sourceId===h.id);return d?(M=t.elements[d.targetId])==null?void 0:M.name:void 0},x=new Set,m=[];for(const h of l){const d=t.relationships.filter(M=>Vt.has(M.type)&&M.sourceId===h.id&&c.has(M.targetId)).map(M=>t.elements[M.targetId]);for(const M of d)x.add(M.id);m.push({chain:h,scenario:u(h),occurrences:p(d)})}const g=s.filter(h=>!x.has(h.id));return g.length>0&&m.push({occurrences:p(g)}),{lifelines:i,sections:m.filter(h=>h.occurrences.length>0)}}const Ke=240,ws=52,Is=68,bs=40,Ss=24,Jt=14;function co(t,e){const n=xs(t,e==null?void 0:e.viewpointFilter);if(n.lifelines.length===0)return{nodes:[],edges:[]};const o=[],s=[],c=p=>p*Ke+Ke/2;let l=ws+28;const i=[];for(const p of n.sections){const u=l;l+=bs;const x=p.occurrences.map(m=>{const g={...m,y:l};return l+=Is,g});i.push({section:p,top:u,bottom:l,placed:x}),l+=Ss}const a=l,f=n.lifelines.length*Ke;return n.lifelines.forEach((p,u)=>{o.push({id:`__lifeline_${p.id}`,type:"seqLifeline",position:{x:u*Ke,y:0},data:{label:p.label},style:{width:Ke,height:a},draggable:!1,selectable:!1,zIndex:-2})}),i.forEach(({section:p,top:u,bottom:x,placed:m},g)=>{var h;o.push({id:`__section_${g}`,type:"seqSection",position:{x:-24,y:u},data:{label:((h=p.chain)==null?void 0:h.name)??"Steps",scenario:p.scenario},style:{width:f+48,height:x-u},draggable:!1,selectable:!1,zIndex:-1}),m.forEach((d,M)=>{if(o.push({id:d.step.id,type:"seqOccurrence",position:{x:c(d.lane)-Jt/2,y:d.y-Jt/2},data:{label:d.step.name,kind:d.step.kind},draggable:!1,zIndex:2}),M<m.length-1){const b=m[M+1],E=b.lane>=d.lane,S=b.lane===d.lane;s.push({id:`seq-${g}-${M}`,source:d.step.id,target:b.step.id,sourceHandle:S||E?"right":"left",targetHandle:S?"right":E?"left":"right",type:S?"smoothstep":"straight",label:d.item,style:{stroke:"#3498DB",strokeWidth:ne.flowWidth},labelStyle:{fontSize:ue.badge,fill:"#4A90D9",fontWeight:600},labelBgPadding:ne.labelBgPadding,labelBgBorderRadius:ne.labelBgRadius,labelBgStyle:ne.labelBgStyle,markerEnd:{type:"arrowclosed",color:"#3498DB",width:ne.arrowSize,height:ne.arrowSize},zIndex:1})}})}),{nodes:o,edges:s}}const Ms=new Set(["interactswith","exchangeswith","appliesincontext","connectsphysically"]),Qt=/(?:Actor|User)$/,en=t=>t.toLowerCase(),tn=t=>t.kind==="UseContext"||/environment|context/i.test(t.name)||/environment/i.test(String(t.attributes.entityKind??"")),Es=t=>/systemofinterest|system-of-interest/i.test(String(t.attributes.contextRole??""))||String(t.attributes.isSystemOfInterest??"").toLowerCase()==="true",Ue=76,mn=170,vs=238,nn=30,sn=104,xt=240,wt=108,It=92,bt=74,St=40,on=t=>Math.min(Math.max(t.length*7.4+28,mn),vs);function ks(t,e,n){const o=new Map,s=[];for(const c of t){const l=e.some(a=>a.sourceId===c&&a.targetId===n),i=e.some(a=>a.sourceId===n&&a.targetId===c);l&&!i?o.set(c,"left"):i&&!l?o.set(c,"right"):s.push(c)}for(const c of s){const l=[...o.values()].filter(a=>a==="left").length,i=o.size-l;o.set(c,l<=i?"left":"right")}return o}function lo(t,e){var Me;const n=Object.values(t.elements),o=t.relationships.filter(v=>Ms.has(en(v.type))),s=new Set(o.flatMap(v=>[v.sourceId,v.targetId])),c=n.filter(v=>s.has(v.id)&&!hn(v));if(c.length===0)return{nodes:[],edges:[]};const l=v=>o.filter(R=>R.sourceId===v.id||R.targetId===v.id).length,i=c.find(Es)??c.find(v=>/system/i.test(v.name))??[...c].sort((v,R)=>l(R)-l(v))[0],a=c.filter(v=>v.id!==i.id),f=new Set([i.id,...a.map(v=>v.id)]),p=o.filter(v=>f.has(v.sourceId)&&f.has(v.targetId)),u=ks(a.map(v=>v.id),p,i.id),x=v=>Qt.test(v.kind)?0:tn(v)?1:2,m=v=>a.filter(R=>u.get(R.id)===v).sort((R,F)=>x(R)-x(F)||R.name.localeCompare(F.name)),g={left:m("left"),right:m("right")},h=v=>v.length===0?0:v.length*Ue+(v.length-1)*nn,d=v=>v.length===0?0:Math.max(...v.map(R=>on(R.name))),M=xt+It*2,b=wt+bt*2,E=St+Math.max(b,h(g.left),h(g.right))/2,S=d(g.left),N=St+(S>0?S+sn:0),T=E-b/2,G=N+M+sn,W=[{id:"__context_boundary__",type:"contextBoundary",position:{x:N,y:T},data:{label:`${e??i.name} — System Boundary`,isFrame:!0},style:{width:M,height:b},draggable:!1,selectable:!1,zIndex:-1},{id:i.id,type:"contextSystem",position:{x:N+It,y:T+bt},data:{label:i.name,kind:i.kind},style:{width:xt,height:wt}}],H=new Map;for(const v of["left","right"]){const R=g[v];let F=E-h(R)/2;for(const ie of R){const r=on(ie.name),w=v==="left"?St+S-r:G;H.set(ie.id,{x:w,y:F,width:r,height:Ue,side:v}),W.push({id:ie.id,type:"contextExternal",position:{x:w,y:F},data:{label:ie.name,kind:ie.kind,category:tn(ie)?"environment":Qt.test(ie.kind)?"person":"system"},style:{width:r,height:Ue}}),F+=Ue+nn}}const X={x:N+It,y:T+bt,width:xt,height:wt},re={left:[],right:[]};for(const v of p){const R=v.sourceId===i.id?v.targetId:v.sourceId;if(v.sourceId!==i.id&&v.targetId!==i.id)continue;const F=(Me=H.get(R))==null?void 0:Me.side;F&&!re[F].includes(v.id)&&re[F].push(v.id)}for(const v of["left","right"])re[v].sort((R,F)=>{const ie=r=>{var k;const w=p.find(L=>L.id===r);return((k=H.get(w.sourceId===i.id?w.targetId:w.sourceId))==null?void 0:k.y)??0};return ie(R)-ie(F)});const Ie=(v,R)=>{const F=re[R],ie=Math.max(F.indexOf(v),0);return{x:R==="left"?X.x:X.x+X.width,y:X.y+X.height*(ie+.5)/Math.max(F.length,1)}},fe=(v,R)=>{const F=H.get(v);return{x:R==="left"?F.x:F.x+F.width,y:F.y+F.height/2}},$=(v,R)=>{var r;if(v===i.id)return((r=H.get(R))==null?void 0:r.side)==="right"?"right":"left";const F=H.get(v);return(R===i.id?X:H.get(R)).x+(R===i.id?X.width:H.get(R).width)/2>=F.x+F.width/2?"right":"left"},Ee=p.map(v=>{const R=$(v.sourceId,v.targetId),F=$(v.targetId,v.sourceId),ie=(r,w)=>r===i.id?Ie(v.id,w):fe(r,w);return{rel:v,sourceSide:R,targetSide:F,source:ie(v.sourceId,R),target:ie(v.targetId,F)}}),be=W.filter(v=>!v.data.isFrame).map(v=>{var R,F;return{id:v.id,x:v.position.x,y:v.position.y,width:Number(((R=v.style)==null?void 0:R.width)??mn),height:Number(((F=v.style)==null?void 0:F.height)??Ue)}}),le=qe(Ee.map(v=>({id:v.rel.id,source:v.source,target:v.target,sourceNodeId:v.rel.sourceId,targetNodeId:v.rel.targetId,sourceSide:v.sourceSide,targetSide:v.targetSide})),be,24),ve=new Map(Ee.map(v=>[v.rel.id,`«${en(v.rel.type)}»`])),xe=it(Ee.flatMap(v=>{const R=le.get(v.rel.id),F=ve.get(v.rel.id);return R&&R.length>=2?[{id:v.rel.id,points:R,width:ct(F),height:at}]:[]}),be),pe=Ee.map(v=>{const R=(F,ie,r)=>{const w=F===i.id?X:H.get(F);return{x:r.x-w.x,y:r.y-w.y,side:ie}};return{id:v.rel.id,source:v.rel.sourceId,target:v.rel.targetId,type:"useCaseEdge",label:ve.get(v.rel.id),style:{stroke:"#0F766E",strokeWidth:1.5},data:{routing:"rounded",points:le.get(v.rel.id)??[v.source,v.target],labelPoint:xe.get(v.rel.id),sourceSide:v.sourceSide,targetSide:v.targetSide,sourceOffset:R(v.rel.sourceId,v.sourceSide,v.source),targetOffset:R(v.rel.targetId,v.targetSide,v.target)}}});return{nodes:W,edges:pe}}const Cs=new Set(["name","title","description","shortDescription","longDescription","sourceReference","rationaleText","semantics","queryDescription","dataSourceDescription","doc"]),As=7,Mt=80;function Os(t,e){const n=t.attributes[e];return n===void 0?void 0:(n.includes("::")?n.split("::").pop().trim():n)||void 0}function Ns(t){const e=new Map;for(const n of t)for(const o of Object.keys(n.attributes))Cs.has(o)||o.includes(".")||e.set(o,(e.get(o)??0)+1);return[...e.entries()].sort((n,o)=>o[1]-n[1]).slice(0,As).map(([n])=>n)}function Ts(t){const e=new Map;for(const o of t)e.has(o.kind)||e.set(o.kind,[]),e.get(o.kind).push(o);const n=[];for(const[o,s]of e){const c=Ns(s),l=s.map(a=>({element:a,values:c.map(f=>Os(a,f))})),i=c.map((a,f)=>{const p=l.map(u=>u.values[f]).filter(u=>u!==void 0);return p.length>0&&p.every(u=>Number.isFinite(Number(u)))});n.push({kind:o,columns:c,numeric:i,rows:l})}return n.sort((o,s)=>s.rows.length-o.rows.length)}function _s(t,e,n){const o=n==="asc"?1:-1;return[...t.rows].sort((c,l)=>{if(e<0)return c.element.name.localeCompare(l.element.name)*o;const i=c.values[e],a=l.values[e];return i===void 0&&a===void 0?0:i===void 0?1:a===void 0?-1:t.numeric[e]?(Number(i)-Number(a))*o:i.localeCompare(a)*o})}function Ps(t,e,n){const o=new Map(t.map(u=>[u.id,u])),s=n!=null&&n.length?new Set(n.map(u=>u.toLowerCase())):void 0,c=e.filter(u=>o.has(u.sourceId)&&o.has(u.targetId)&&u.sourceId!==u.targetId&&(!s||s.has(u.type.toLowerCase())));if(c.length===0)return;const l=new Set,i=new Set,a=new Map,f=new Set;for(const u of c){l.add(u.sourceId),i.add(u.targetId),f.add(u.type);const x=`${u.sourceId}|${u.targetId}`;a.has(x)||a.set(x,[]),a.get(x).includes(u.type)||a.get(x).push(u.type)}const p=(u,x)=>u.kind.localeCompare(x.kind)||u.name.localeCompare(x.name);return{rows:[...l].map(u=>o.get(u)).sort(p),cols:[...i].map(u=>o.get(u)).sort(p),cells:a,relTypes:[...f].sort()}}const st={padding:"6px 10px",fontSize:ue.xs,fontWeight:600,color:"#374151",textAlign:"left",borderBottom:"2px solid #E5E5E0",background:"#FAFAF8",position:"sticky",top:0,cursor:"pointer",whiteSpace:"nowrap",userSelect:"none"},ot={padding:"5px 10px",fontSize:ue.xs,color:"#374151",borderBottom:"1px solid #F0F0ED",verticalAlign:"top"};function Fs(t){return t.length>Mt?`${t.slice(0,Mt-1)}…`:t}function Ds({section:t,search:e}){var u;const n=nt(x=>x.selectElement),[o,s]=ye.useState(-1),[c,l]=ye.useState("asc"),i=ye.useMemo(()=>{const x=_s(t,o,c);if(!e)return x;const m=e.toLowerCase();return x.filter(g=>g.element.name.toLowerCase().includes(m)||g.values.some(h=>h==null?void 0:h.toLowerCase().includes(m)))},[t,o,c,e]);if(i.length===0)return null;const a=Be[(u=t.rows[0])==null?void 0:u.element.layer]||"#6B7280",f=x=>{o===x?l(m=>m==="asc"?"desc":"asc"):(s(x),l("asc"))},p=x=>o===x?c==="asc"?" ↑":" ↓":"";return O.jsxs("div",{style:{marginBottom:28},children:[O.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[O.jsx("span",{style:{width:8,height:8,borderRadius:2,background:a,display:"inline-block"}}),O.jsx("span",{style:{fontSize:ue.sm,fontWeight:700,color:"#1B3A4B"},children:t.kind}),O.jsx("span",{style:{fontSize:ue.xs,color:"#9CA3AF"},children:i.length})]}),O.jsxs("table",{style:{borderCollapse:"collapse",width:"100%",background:"#FFFFFF",borderRadius:8,overflow:"hidden",border:"1px solid #E5E5E0"},children:[O.jsx("thead",{children:O.jsxs("tr",{children:[O.jsxs("th",{style:st,onClick:()=>f(-1),children:["Element",p(-1)]}),t.columns.map((x,m)=>O.jsxs("th",{style:st,onClick:()=>f(m),children:[x,p(m)]},x))]})}),O.jsx("tbody",{children:i.map(x=>O.jsxs("tr",{onMouseEnter:m=>{m.currentTarget.style.background="#F7F7F5"},onMouseLeave:m=>{m.currentTarget.style.background="transparent"},children:[O.jsx("td",{style:{...ot,whiteSpace:"nowrap"},children:O.jsx("button",{onClick:()=>n(x.element.id),style:{background:"none",border:"none",padding:0,fontSize:ue.xs,fontWeight:600,color:"#1B6FD9",cursor:"pointer",textDecoration:"none"},title:"Open element detail",children:x.element.name})}),x.values.map((m,g)=>O.jsx("td",{style:ot,title:m&&m.length>Mt?m:void 0,children:m?Fs(m):O.jsx("span",{style:{color:"#D1D5DB"},children:"—"})},g))]},x.element.id))})]})]})}function Rs({elements:t,model:e,relationshipTypes:n}){const o=nt(l=>l.selectElement),s=ye.useMemo(()=>Ps(t,e.relationships,n),[t,e.relationships,n]);if(!s)return O.jsx("div",{style:{color:"#9CA3AF",fontSize:ue.sm,padding:24},children:"No relationships among this view's elements."});const c=(l,i=!1)=>O.jsx("button",{onClick:()=>o(l.id),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontSize:"10px",fontWeight:600,color:"#374151",...i?{writingMode:"vertical-rl",transform:"rotate(180deg)",maxHeight:120}:{},whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:180},title:`${l.kind} · open detail`,children:l.name});return O.jsxs("div",{children:[O.jsx("div",{className:"flex gap-3 mb-2",style:{fontSize:ue.xs,color:"#6B7280"},children:s.relTypes.map(l=>O.jsxs("span",{className:"flex items-center gap-1",children:[O.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:He[l]||"#6B7280",display:"inline-block"}}),l]},l))}),O.jsxs("table",{style:{borderCollapse:"collapse",background:"#FFFFFF",border:"1px solid #E5E5E0"},children:[O.jsx("thead",{children:O.jsxs("tr",{children:[O.jsx("th",{style:{...st,cursor:"default"}}),s.cols.map(l=>O.jsx("th",{style:{...st,cursor:"default",verticalAlign:"bottom",padding:"8px 4px"},children:c(l,!0)},l.id))]})}),O.jsx("tbody",{children:s.rows.map(l=>O.jsxs("tr",{children:[O.jsx("td",{style:{...ot,whiteSpace:"nowrap",background:"#FAFAF8"},children:c(l)}),s.cols.map(i=>{const a=s.cells.get(`${l.id}|${i.id}`);return O.jsx("td",{style:{...ot,textAlign:"center",padding:"4px 6px"},title:a==null?void 0:a.join(", "),children:a==null?void 0:a.map(f=>O.jsx("span",{style:{width:9,height:9,borderRadius:"50%",margin:1,background:He[f]||"#6B7280",display:"inline-block"}},f))},i.id)})]},l.id))})]})]})}function ho({diagram:t,model:e,viewpointFilter:n}){const[o,s]=ye.useState("table"),[c,l]=ye.useState(""),i=ye.useMemo(()=>{const p=Object.values(e.elements);return n?p.filter(n):p},[e,n]),a=ye.useMemo(()=>Ts(i),[i]),f=rn.grid;return O.jsx("div",{className:"flex-1 overflow-auto",style:{background:"#F7F7F5"},children:O.jsxs("div",{style:{padding:"16px 20px",maxWidth:1240},children:[O.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[O.jsx("span",{className:"px-1.5 py-0.5 rounded font-semibold",style:{background:f.color+"20",color:f.color,fontSize:ue.badge},title:f.fullName,children:f.label}),O.jsx("span",{style:{fontSize:ue.md,fontWeight:700,color:"#1a1a1a"},children:t.name}),O.jsxs("span",{style:{fontSize:ue.xs,color:"#9CA3AF"},children:[i.length," elements"]}),O.jsx("div",{className:"flex rounded overflow-hidden ml-2",style:{border:"1px solid #E5E5E0"},children:["table","matrix"].map(p=>O.jsx("button",{onClick:()=>s(p),className:"px-2 py-0.5 text-xs font-medium capitalize",style:{background:o===p?"#1B3A4B":"#FFFFFF",color:o===p?"#FFFFFF":"#6B7280",border:"none",cursor:"pointer"},children:p},p))}),o==="table"&&O.jsx("input",{value:c,onChange:p=>l(p.target.value),placeholder:"Filter rows…",className:"px-2 py-1 rounded focus:outline-none ml-auto",style:{fontSize:ue.xs,border:"1px solid #E5E5E0",background:"#FFFFFF",color:"#1a1a1a",width:200}})]}),o==="table"?a.map(p=>O.jsx(Ds,{section:p,search:c},p.kind)):O.jsx(Rs,{elements:i,model:e,relationshipTypes:t.relationshipTypes}),o==="table"&&a.length===0&&O.jsx("div",{style:{color:"#9CA3AF",fontSize:ue.sm,padding:24},children:"This view selects no elements."})]})})}const Ls=8;function pn(t,e,n){const o=(e.get(t.id)??[]).filter(s=>n.has(s)).map(s=>pn(n.get(s),e,n));return o.sort(tt),{id:t.id,label:t.name,element:t,kind:t.kind,layer:t.layer,children:o,count:1+o.reduce((s,c)=>s+c.count,0)}}const tt=(t,e)=>(t.kind??"").localeCompare(e.kind??"")||t.label.localeCompare(e.label);function Bs(t,e){const n=rt(t,e),o=new Map,s=[];for(const c of n.roots){const l=n.elements.get(c),i=pn(l,n.childrenMap,n.elements),a=l.package;if(!a){s.push(i);continue}if(!o.has(a)){const p=a.split("::").pop()??a,u={id:`pkg:${a}`,label:p,title:a,children:[],count:0};o.set(a,u),s.push(u)}const f=o.get(a);f.children.push(i),f.count+=i.count}for(const c of o.values()){const l=new Set(c.children.map(a=>a.kind));if(c.children.length<=Ls||l.size<=1){c.children.sort(tt);continue}const i=new Map;for(const a of c.children){const f=a.kind??"—";i.has(f)||i.set(f,[]),i.get(f).push(a)}c.children=[...i.entries()].sort((a,f)=>a[0].localeCompare(f[0])).map(([a,f])=>{var p;return{id:`kind:${c.id}:${a}`,label:a,kind:a,layer:(p=f[0])==null?void 0:p.layer,children:f.sort(tt),count:f.reduce((u,x)=>u+x.count,0)}})}return s.sort(tt),s}function js(t,e){const n=e.trim().toLowerCase();if(!n)return;const o=new Set,s=new Set,c=(l,i)=>{const a=l.label.toLowerCase().includes(n)||(l.kind??"").toLowerCase().includes(n);let f=!1;for(const p of l.children)c(p,[...i,l.id])&&(f=!0);if(a||f){o.add(l.id);for(const p of i)o.add(p),s.add(p);return f&&s.add(l.id),!0}return!1};for(const l of t)c(l,[]);return{visible:o,expanded:s}}function Ws(t){if(!t)return"·";const e=t.replace(/[^A-Za-z]/g,"").match(/[A-Z]/g);return e&&e.length>=2?e.slice(0,2).join(""):t.slice(0,2).toUpperCase()}const Hs=26;function yn({node:t,depth:e,expanded:n,visible:o,forceExpanded:s,onToggle:c}){const l=nt(m=>m.selectElement),i=nt(m=>m.selectedElementId);if(o&&!o.has(t.id))return null;const a=n.has(t.id)||!!(s!=null&&s.has(t.id)),f=t.children.length>0,p=!t.element,u=Be[t.layer??""]||"#95A5A6",x=t.element&&t.id===i;return O.jsxs(O.Fragment,{children:[O.jsxs("div",{className:"flex items-center gap-1.5",style:{height:Hs,paddingLeft:8+e*18,cursor:"pointer",background:x?"#2DD4A818":void 0,borderRadius:6},onMouseEnter:m=>{x||(m.currentTarget.style.background="#F0F0ED")},onMouseLeave:m=>{m.currentTarget.style.background=x?"#2DD4A818":"transparent"},onClick:()=>{f&&c(t.id),t.element&&l(t.id)},title:t.title??t.kind,children:[O.jsx("span",{style:{width:12,textAlign:"center",flexShrink:0,fontSize:"9px",color:"#9CA3AF",transform:a?"rotate(90deg)":"none",transition:"transform 120ms ease",visibility:f?"visible":"hidden"},children:"▶"}),p?O.jsx("span",{style:{fontSize:"10px",flexShrink:0},children:t.id.startsWith("pkg:")?"📦":"▣"}):O.jsx("span",{style:{flexShrink:0,width:20,height:16,borderRadius:4,background:u+"22",color:u,fontSize:"8px",fontWeight:800,display:"inline-flex",alignItems:"center",justifyContent:"center",letterSpacing:"0.02em"},title:t.kind,children:Ws(t.kind)}),O.jsx("span",{style:{fontSize:ue.xs,fontWeight:p?700:500,color:p?"#1B3A4B":"#374151",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t.label}),f&&O.jsx("span",{style:{fontSize:"9px",color:"#9CA3AF"},children:t.count})]}),a&&t.children.map(m=>O.jsx(yn,{node:m,depth:e+1,expanded:n,visible:o,forceExpanded:s,onToggle:c},m.id))]})}function uo({diagram:t,model:e,viewpointFilter:n}){const[o,s]=ye.useState(new Set),[c,l]=ye.useState(""),i=ye.useMemo(()=>{const g=Object.values(e.elements);return n?g.filter(n):g},[e,n]),a=ye.useMemo(()=>Bs(i,e.relationships),[i,e.relationships]),f=ye.useMemo(()=>js(a,c),[a,c]),p=ye.useCallback(g=>{s(h=>{const d=new Set(h);return d.has(g)?d.delete(g):d.add(g),d})},[]),u=ye.useCallback((g,h)=>{for(const d of g)d.children.length>0&&(h.add(d.id),u(d.children,h));return h},[]),x=rn.browser,m=i.length;return O.jsx("div",{className:"flex-1 overflow-auto",style:{background:"#F7F7F5"},children:O.jsxs("div",{style:{padding:"16px 20px",maxWidth:860},children:[O.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[O.jsx("span",{className:"px-1.5 py-0.5 rounded font-semibold",style:{background:x.color+"20",color:x.color,fontSize:ue.badge},title:x.fullName,children:x.label}),O.jsx("span",{style:{fontSize:ue.md,fontWeight:700,color:"#1a1a1a"},children:t.name}),O.jsxs("span",{style:{fontSize:ue.xs,color:"#9CA3AF"},children:[m," elements"]}),O.jsx("button",{onClick:()=>s(u(a,new Set)),className:"px-2 py-0.5 text-xs font-medium rounded ml-2",style:{background:"#FFFFFF",color:"#374151",border:"1px solid #E5E5E0",cursor:"pointer"},children:"Expand All"}),O.jsx("button",{onClick:()=>s(new Set),className:"px-2 py-0.5 text-xs font-medium rounded",style:{background:"#FFFFFF",color:"#374151",border:"1px solid #E5E5E0",cursor:"pointer"},children:"Collapse All"}),O.jsx("input",{value:c,onChange:g=>l(g.target.value),placeholder:"Filter by name or kind…",className:"px-2 py-1 rounded focus:outline-none ml-auto",style:{fontSize:ue.xs,border:"1px solid #E5E5E0",background:"#FFFFFF",color:"#1a1a1a",width:220}})]}),O.jsxs("div",{style:{background:"#FFFFFF",border:"1px solid #E5E5E0",borderRadius:10,padding:"10px 8px"},children:[a.length===0&&O.jsx("div",{style:{color:"#9CA3AF",fontSize:ue.sm,padding:16},children:"This view selects no elements."}),a.map(g=>O.jsx(yn,{node:g,depth:0,expanded:o,visible:f==null?void 0:f.visible,forceExpanded:f==null?void 0:f.expanded,onToggle:p},g.id)),f&&a.every(g=>!f.visible.has(g.id))&&O.jsxs("div",{style:{color:"#9CA3AF",fontSize:ue.sm,padding:16},children:["No matches for “",c,"”."]})]})]})})}function go({x:t,y:e,sourceElement:n,targetElement:o,registries:s,onSelect:c,onCancel:l}){const i=ye.useRef(null),[a,f]=ye.useState(""),p=ye.useRef(null);ye.useEffect(()=>{var M;(M=p.current)==null||M.focus()},[]),ye.useEffect(()=>{const M=b=>{i.current&&!i.current.contains(b.target)&&l()};return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[l]),ye.useEffect(()=>{const M=b=>{b.key==="Escape"&&l()};return document.addEventListener("keydown",M),()=>document.removeEventListener("keydown",M)},[l]);const u=ye.useMemo(()=>xn(n,o,s),[n,o,s]),x=ye.useMemo(()=>{const M=a.trim().toLowerCase();return M?u.filter(b=>b.definition.label.toLowerCase().includes(M)||b.definition.name.toLowerCase().includes(M)):u},[u,a]),m=260,g=320,h=Math.min(t,window.innerWidth-m-8),d=Math.min(e,window.innerHeight-g-8);return O.jsxs("div",{ref:i,className:"fixed z-50 flex flex-col shadow-xl rounded-xl overflow-hidden",style:{left:h,top:d,width:m,maxHeight:g,background:"#FFFFFF",border:"1px solid #E5E5E0",boxShadow:"0 8px 32px rgba(0,0,0,0.16)"},children:[O.jsxs("div",{className:"px-3 py-2",style:{borderBottom:"1px solid #E5E5E0",flexShrink:0},children:[O.jsx("div",{style:{fontSize:ue.xs,fontWeight:600,color:"#374151",marginBottom:4},children:"Relationship Type"}),O.jsxs("div",{style:{fontSize:"10px",color:"#9CA3AF",marginBottom:4},children:[n.kind," → ",o.kind]}),O.jsx("input",{ref:p,value:a,onChange:M=>f(M.target.value),placeholder:"Search…","aria-label":"Search relationship types",className:"w-full px-2 py-1 rounded focus:outline-none",style:{fontSize:ue.xs,background:"#F7F7F5",border:"1px solid #E5E5E0",color:"#374151"}})]}),O.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[x.map(M=>{const{definition:b,direction:E,sourceId:S,targetId:N}=M,T=E==="incoming";return O.jsxs("button",{onClick:()=>c({type:b.name,sourceId:S,targetId:N,direction:E}),className:"w-full flex items-center gap-2.5 px-3 py-1.5 text-left",style:{background:"none",border:"none",cursor:"pointer"},onMouseEnter:G=>{G.currentTarget.style.background="#F7F7F5"},onMouseLeave:G=>{G.currentTarget.style.background="none"},children:[O.jsx("div",{style:{width:10,height:10,borderRadius:"50%",flexShrink:0,background:He[b.name]??"#6B7280"}}),O.jsxs("div",{style:{minWidth:0},children:[O.jsxs("div",{style:{fontSize:ue.xs,fontWeight:500,color:"#1a1a1a"},children:[b.label,T&&O.jsx("span",{style:{color:"#9CA3AF",fontWeight:400},children:" (reversed)"})]}),O.jsxs("div",{className:"truncate",style:{fontSize:"10px",color:"#9CA3AF"},children:[b.sourceEnd.name," → ",b.targetEnd.name]})]})]},`${b.name}-${E}`)}),x.length===0&&O.jsx("div",{className:"p-3 text-center",style:{color:"#9CA3AF",fontSize:ue.xs},children:u.length===0?`The ontology defines no relationship between a ${n.kind} and a ${o.kind}.`:"No matching types"})]})]})}function fo(t){var e,n,o;return((o=(n=(e=t)==null?void 0:e.canvas)==null?void 0:n.layout)==null?void 0:o.provider)??In}export{qe as A,uo as B,Ve as C,Us as G,Js as I,Zs as P,go as R,_n as a,Pn as b,Ks as c,ao as d,lo as e,Qs as f,no as g,so as h,co as i,qs as j,Tn as k,Ft as l,ro as m,to as n,eo as o,rs as p,io as q,Vs as r,fo as s,Rn as t,oo as u,Xs as v,Fn as w,dn as x,ho as y,Ln as z};
|
|
@@ -51,4 +51,4 @@ Error generating stack: `+d.message+`
|
|
|
51
51
|
`,`
|
|
52
52
|
+`).split(`
|
|
53
53
|
`)),v=m.reduce((g,y)=>g.concat(...y),[]);return[m,v]}return[[],[]]},[n]);return q.useEffect(()=>{const p=(o==null?void 0:o.target)??Sh,m=(o==null?void 0:o.actInsideInputWithModifier)??!0;if(n!==null){const v=x=>{var N,E;if(u.current=x.ctrlKey||x.metaKey||x.shiftKey||x.altKey,(!u.current||u.current&&!m)&&Pp(x))return!1;const k=Eh(x.code,h);if(c.current.add(x[k]),_h(f,c.current,!1)){const L=((E=(N=x.composedPath)==null?void 0:N.call(x))==null?void 0:E[0])||x.target,_=(L==null?void 0:L.nodeName)==="BUTTON"||(L==null?void 0:L.nodeName)==="A";o.preventDefault!==!1&&(u.current||!_)&&x.preventDefault(),s(!0)}},g=x=>{const S=Eh(x.code,h);_h(f,c.current,!0)?(s(!1),c.current.clear()):c.current.delete(x[S]),x.key==="Meta"&&c.current.clear(),u.current=!1},y=()=>{c.current.clear(),s(!1)};return p==null||p.addEventListener("keydown",v),p==null||p.addEventListener("keyup",g),window.addEventListener("blur",y),window.addEventListener("contextmenu",y),()=>{p==null||p.removeEventListener("keydown",v),p==null||p.removeEventListener("keyup",g),window.removeEventListener("blur",y),window.removeEventListener("contextmenu",y)}}},[n,s]),i}function _h(n,o,i){return n.filter(s=>i||s.length===o.size).some(s=>s.every(u=>o.has(u)))}function Eh(n,o){return o.includes(n)?"code":"key"}const Ex=()=>{const n=$e();return q.useMemo(()=>({zoomIn:o=>{const{panZoom:i}=n.getState();return i?i.scaleBy(1.2,{duration:o==null?void 0:o.duration}):Promise.resolve(!1)},zoomOut:o=>{const{panZoom:i}=n.getState();return i?i.scaleBy(1/1.2,{duration:o==null?void 0:o.duration}):Promise.resolve(!1)},zoomTo:(o,i)=>{const{panZoom:s}=n.getState();return s?s.scaleTo(o,{duration:i==null?void 0:i.duration}):Promise.resolve(!1)},getZoom:()=>n.getState().transform[2],setViewport:async(o,i)=>{const{transform:[s,u,c],panZoom:f}=n.getState();return f?(await f.setViewport({x:o.x??s,y:o.y??u,zoom:o.zoom??c},i),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[o,i,s]=n.getState().transform;return{x:o,y:i,zoom:s}},setCenter:async(o,i,s)=>n.getState().setCenter(o,i,s),fitBounds:async(o,i)=>{const{width:s,height:u,minZoom:c,maxZoom:f,panZoom:h}=n.getState(),p=Ga(o,s,u,c,f,(i==null?void 0:i.padding)??.1);return h?(await h.setViewport(p,{duration:i==null?void 0:i.duration,ease:i==null?void 0:i.ease,interpolate:i==null?void 0:i.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(o,i={})=>{const{transform:s,snapGrid:u,snapToGrid:c,domNode:f}=n.getState();if(!f)return o;const{x:h,y:p}=f.getBoundingClientRect(),m={x:o.x-h,y:o.y-p},v=i.snapGrid??u,g=i.snapToGrid??c;return hi(m,s,g,v)},flowToScreenPosition:o=>{const{transform:i,domNode:s}=n.getState();if(!s)return o;const{x:u,y:c}=s.getBoundingClientRect(),f=ts(o,i);return{x:f.x+u,y:f.y+c}}}),[])};function Zp(n,o){const i=[],s=new Map,u=[];for(const c of n)if(c.type==="add"){u.push(c);continue}else if(c.type==="remove"||c.type==="replace")s.set(c.id,[c]);else{const f=s.get(c.id);f?f.push(c):s.set(c.id,[c])}for(const c of o){const f=s.get(c.id);if(!f){i.push(c);continue}if(f[0].type==="remove")continue;if(f[0].type==="replace"){i.push({...f[0].item});continue}const h={...c};for(const p of f)kx(p,h);i.push(h)}return u.length&&u.forEach(c=>{c.index!==void 0?i.splice(c.index,0,{...c.item}):i.push({...c.item})}),i}function kx(n,o){switch(n.type){case"select":{o.selected=n.selected;break}case"position":{typeof n.position<"u"&&(o.position=n.position),typeof n.dragging<"u"&&(o.dragging=n.dragging);break}case"dimensions":{typeof n.dimensions<"u"&&(o.measured={...n.dimensions},n.setAttributes&&((n.setAttributes===!0||n.setAttributes==="width")&&(o.width=n.dimensions.width),(n.setAttributes===!0||n.setAttributes==="height")&&(o.height=n.dimensions.height))),typeof n.resizing=="boolean"&&(o.resizing=n.resizing);break}}}function qp(n,o){return Zp(n,o)}function bp(n,o){return Zp(n,o)}function ir(n,o){return{id:n,type:"select",selected:o}}function Yr(n,o=new Set,i=!1){const s=[];for(const[u,c]of n){const f=o.has(u);!(c.selected===void 0&&!f)&&c.selected!==f&&(i&&(c.selected=f),s.push(ir(c.id,f)))}return s}function kh({items:n=[],lookup:o}){var u;const i=[],s=new Map(n.map(c=>[c.id,c]));for(const[c,f]of n.entries()){const h=o.get(f.id),p=((u=h==null?void 0:h.internals)==null?void 0:u.userNode)??h;p!==void 0&&p!==f&&i.push({id:f.id,item:f,type:"replace"}),p===void 0&&i.push({item:f,type:"add",index:c})}for(const[c]of o)s.get(c)===void 0&&i.push({id:c,type:"remove"});return i}function Nh(n){return{id:n.id,type:"remove"}}const Ch=n=>Yw(n),Nx=n=>xp(n);function Jp(n){return q.forwardRef(n)}const Cx=typeof window<"u"?q.useLayoutEffect:q.useEffect;function Mh(n){const[o,i]=q.useState(BigInt(0)),[s]=q.useState(()=>Mx(()=>i(u=>u+BigInt(1))));return Cx(()=>{const u=s.get();u.length&&(n(u),s.reset())},[o]),s}function Mx(n){let o=[];return{get:()=>o,reset:()=>{o=[]},push:i=>{o.push(i),n()}}}const eg=q.createContext(null);function Px({children:n}){const o=$e(),i=q.useCallback(h=>{const{nodes:p=[],setNodes:m,hasDefaultNodes:v,onNodesChange:g,nodeLookup:y,fitViewQueued:x,onNodesChangeMiddlewareMap:S}=o.getState();let k=p;for(const E of h)k=typeof E=="function"?E(k):E;let N=kh({items:k,lookup:y});for(const E of S.values())N=E(N);v&&m(k),N.length>0?g==null||g(N):x&&window.requestAnimationFrame(()=>{const{fitViewQueued:E,nodes:L,setNodes:_}=o.getState();E&&_(L)})},[]),s=Mh(i),u=q.useCallback(h=>{const{edges:p=[],setEdges:m,hasDefaultEdges:v,onEdgesChange:g,edgeLookup:y}=o.getState();let x=p;for(const S of h)x=typeof S=="function"?S(x):S;v?m(x):g&&g(kh({items:x,lookup:y}))},[]),c=Mh(u),f=q.useMemo(()=>({nodeQueue:s,edgeQueue:c}),[]);return K.jsx(eg.Provider,{value:f,children:n})}function zx(){const n=q.useContext(eg);if(!n)throw new Error("useBatchContext must be used within a BatchProvider");return n}const Ix=n=>!!n.panZoom;function nc(){const n=Ex(),o=$e(),i=zx(),s=Ce(Ix),u=q.useMemo(()=>{const c=g=>o.getState().nodeLookup.get(g),f=g=>{i.nodeQueue.push(g)},h=g=>{i.edgeQueue.push(g)},p=g=>{var E,L;const{nodeLookup:y,nodeOrigin:x}=o.getState(),S=Ch(g)?g:y.get(g.id),k=S.parentId?Cp(S.position,S.measured,S.parentId,y,x):S.position,N={...S,position:k,width:((E=S.measured)==null?void 0:E.width)??S.width,height:((L=S.measured)==null?void 0:L.height)??S.height};return Jr(N)},m=(g,y,x={replace:!1})=>{f(S=>S.map(k=>{if(k.id===g){const N=typeof y=="function"?y(k):y;return x.replace&&Ch(N)?N:{...k,...N}}return k}))},v=(g,y,x={replace:!1})=>{h(S=>S.map(k=>{if(k.id===g){const N=typeof y=="function"?y(k):y;return x.replace&&Nx(N)?N:{...k,...N}}return k}))};return{getNodes:()=>o.getState().nodes.map(g=>({...g})),getNode:g=>{var y;return(y=c(g))==null?void 0:y.internals.userNode},getInternalNode:c,getEdges:()=>{const{edges:g=[]}=o.getState();return g.map(y=>({...y}))},getEdge:g=>o.getState().edgeLookup.get(g),setNodes:f,setEdges:h,addNodes:g=>{const y=Array.isArray(g)?g:[g];i.nodeQueue.push(x=>[...x,...y])},addEdges:g=>{const y=Array.isArray(g)?g:[g];i.edgeQueue.push(x=>[...x,...y])},toObject:()=>{const{nodes:g=[],edges:y=[],transform:x}=o.getState(),[S,k,N]=x;return{nodes:g.map(E=>({...E})),edges:y.map(E=>({...E})),viewport:{x:S,y:k,zoom:N}}},deleteElements:async({nodes:g=[],edges:y=[]})=>{const{nodes:x,edges:S,onNodesDelete:k,onEdgesDelete:N,triggerNodeChanges:E,triggerEdgeChanges:L,onDelete:_,onBeforeDelete:C}=o.getState(),{nodes:F,edges:D}=await qw({nodesToRemove:g,edgesToRemove:y,nodes:x,edges:S,onBeforeDelete:C}),O=D.length>0,Y=F.length>0;if(O){const Q=D.map(Nh);N==null||N(D),L(Q)}if(Y){const Q=F.map(Nh);k==null||k(F),E(Q)}return(Y||O)&&(_==null||_({nodes:F,edges:D})),{deletedNodes:F,deletedEdges:D}},getIntersectingNodes:(g,y=!0,x)=>{const S=bd(g),k=S?g:p(g),N=x!==void 0;return k?(x||o.getState().nodes).filter(E=>{const L=o.getState().nodeLookup.get(E.id);if(L&&!S&&(E.id===g.id||!L.internals.positionAbsolute))return!1;const _=Jr(N?E:L),C=ii(_,k);return y&&C>0||C>=_.width*_.height||C>=k.width*k.height}):[]},isNodeIntersecting:(g,y,x=!0)=>{const k=bd(g)?g:p(g);if(!k)return!1;const N=ii(k,y);return x&&N>0||N>=y.width*y.height||N>=k.width*k.height},updateNode:m,updateNodeData:(g,y,x={replace:!1})=>{m(g,S=>{const k=typeof y=="function"?y(S):y;return x.replace?{...S,data:k}:{...S,data:{...S.data,...k}}},x)},updateEdge:v,updateEdgeData:(g,y,x={replace:!1})=>{v(g,S=>{const k=typeof y=="function"?y(S):y;return x.replace?{...S,data:k}:{...S,data:{...S.data,...k}}},x)},getNodesBounds:g=>{const{nodeLookup:y,nodeOrigin:x}=o.getState();return Qw(g,{nodeLookup:y,nodeOrigin:x})},getHandleConnections:({type:g,id:y,nodeId:x})=>{var S;return Array.from(((S=o.getState().connectionLookup.get(`${x}-${g}${y?`-${y}`:""}`))==null?void 0:S.values())??[])},getNodeConnections:({type:g,handleId:y,nodeId:x})=>{var S;return Array.from(((S=o.getState().connectionLookup.get(`${x}${g?y?`-${g}-${y}`:`-${g}`:""}`))==null?void 0:S.values())??[])},fitView:async g=>{const y=o.getState().fitViewResolver??t1();return o.setState({fitViewQueued:!0,fitViewOptions:g,fitViewResolver:y}),i.nodeQueue.push(x=>[...x]),y.promise}}},[]);return q.useMemo(()=>({...u,...n,viewportInitialized:s}),[s])}const Ph=n=>n.selected,Tx=typeof window<"u"?window:void 0;function Lx({deleteKeyCode:n,multiSelectionKeyCode:o}){const i=$e(),{deleteElements:s}=nc(),u=si(n,{actInsideInputWithModifier:!1}),c=si(o,{target:Tx});q.useEffect(()=>{if(u){const{edges:f,nodes:h}=i.getState();s({nodes:h.filter(Ph),edges:f.filter(Ph)}),i.setState({nodesSelectionActive:!1})}},[u]),q.useEffect(()=>{i.setState({multiSelectionActive:c})},[c])}function Ax(n){const o=$e();q.useEffect(()=>{const i=()=>{var u,c,f,h;if(!n.current||!(((c=(u=n.current).checkVisibility)==null?void 0:c.call(u))??!0))return!1;const s=Za(n.current);(s.height===0||s.width===0)&&((h=(f=o.getState()).onError)==null||h.call(f,"004",Kt.error004())),o.setState({width:s.width||500,height:s.height||500})};if(n.current){i(),window.addEventListener("resize",i);const s=new ResizeObserver(()=>i());return s.observe(n.current),()=>{window.removeEventListener("resize",i),s&&n.current&&s.unobserve(n.current)}}},[])}const gs={position:"absolute",width:"100%",height:"100%",top:0,left:0},Dx=n=>({userSelectionActive:n.userSelectionActive,lib:n.lib,connectionInProgress:n.connection.inProgress});function Rx({onPaneContextMenu:n,zoomOnScroll:o=!0,zoomOnPinch:i=!0,panOnScroll:s=!1,panOnScrollSpeed:u=.5,panOnScrollMode:c=ur.Free,zoomOnDoubleClick:f=!0,panOnDrag:h=!0,defaultViewport:p,translateExtent:m,minZoom:v,maxZoom:g,zoomActivationKeyCode:y,preventScrolling:x=!0,children:S,noWheelClassName:k,noPanClassName:N,onViewportChange:E,isControlledViewport:L,paneClickDistance:_,selectionOnDrag:C}){const F=$e(),D=q.useRef(null),{userSelectionActive:O,lib:Y,connectionInProgress:Q}=Ce(Dx,Re),ne=si(y),j=q.useRef();Ax(D);const U=q.useCallback(b=>{E==null||E({x:b[0],y:b[1],zoom:b[2]}),L||F.setState({transform:b})},[E,L]);return q.useEffect(()=>{if(D.current){j.current=O1({domNode:D.current,minZoom:v,maxZoom:g,translateExtent:m,viewport:p,onDraggingChange:R=>F.setState(W=>W.paneDragging===R?W:{paneDragging:R}),onPanZoomStart:(R,W)=>{const{onViewportChangeStart:P,onMoveStart:I}=F.getState();I==null||I(R,W),P==null||P(W)},onPanZoom:(R,W)=>{const{onViewportChange:P,onMove:I}=F.getState();I==null||I(R,W),P==null||P(W)},onPanZoomEnd:(R,W)=>{const{onViewportChangeEnd:P,onMoveEnd:I}=F.getState();I==null||I(R,W),P==null||P(W)}});const{x:b,y:z,zoom:B}=j.current.getViewport();return F.setState({panZoom:j.current,transform:[b,z,B],domNode:D.current.closest(".react-flow")}),()=>{var R;(R=j.current)==null||R.destroy()}}},[]),q.useEffect(()=>{var b;(b=j.current)==null||b.update({onPaneContextMenu:n,zoomOnScroll:o,zoomOnPinch:i,panOnScroll:s,panOnScrollSpeed:u,panOnScrollMode:c,zoomOnDoubleClick:f,panOnDrag:h,zoomActivationKeyPressed:ne,preventScrolling:x,noPanClassName:N,userSelectionActive:O,noWheelClassName:k,lib:Y,onTransformChange:U,connectionInProgress:Q,selectionOnDrag:C,paneClickDistance:_})},[n,o,i,s,u,c,f,h,ne,x,N,O,k,Y,U,Q,C,_]),K.jsx("div",{className:"react-flow__renderer",ref:D,style:gs,children:S})}const $x=n=>({userSelectionActive:n.userSelectionActive,userSelectionRect:n.userSelectionRect});function Fx(){const{userSelectionActive:n,userSelectionRect:o}=Ce($x,Re);return n&&o?K.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:o.width,height:o.height,transform:`translate(${o.x}px, ${o.y}px)`}}):null}const ka=(n,o)=>i=>{i.target===o.current&&(n==null||n(i))},Ox=n=>({userSelectionActive:n.userSelectionActive,elementsSelectable:n.elementsSelectable,connectionInProgress:n.connection.inProgress,dragging:n.paneDragging});function Hx({isSelecting:n,selectionKeyPressed:o,selectionMode:i=oi.Full,panOnDrag:s,paneClickDistance:u,selectionOnDrag:c,onSelectionStart:f,onSelectionEnd:h,onPaneClick:p,onPaneContextMenu:m,onPaneScroll:v,onPaneMouseEnter:g,onPaneMouseMove:y,onPaneMouseLeave:x,children:S}){const k=$e(),{userSelectionActive:N,elementsSelectable:E,dragging:L,connectionInProgress:_}=Ce(Ox,Re),C=E&&(n||N),F=q.useRef(null),D=q.useRef(),O=q.useRef(new Set),Y=q.useRef(new Set),Q=q.useRef(!1),ne=P=>{if(Q.current||_){Q.current=!1;return}p==null||p(P),k.getState().resetSelectedElements(),k.setState({nodesSelectionActive:!1})},j=P=>{if(Array.isArray(s)&&(s!=null&&s.includes(2))){P.preventDefault();return}m==null||m(P)},U=v?P=>v(P):void 0,b=P=>{Q.current&&(P.stopPropagation(),Q.current=!1)},z=P=>{var he,fe;const{domNode:I}=k.getState();if(D.current=I==null?void 0:I.getBoundingClientRect(),!D.current)return;const $=P.target===F.current;if(!$&&!!P.target.closest(".nokey")||!n||!(c&&$||o)||P.button!==0||!P.isPrimary)return;(fe=(he=P.target)==null?void 0:he.setPointerCapture)==null||fe.call(he,P.pointerId),Q.current=!1;const{x:le,y:ie}=Ot(P.nativeEvent,D.current);k.setState({userSelectionRect:{width:0,height:0,startX:le,startY:ie,x:le,y:ie}}),$||(P.stopPropagation(),P.preventDefault())},B=P=>{const{userSelectionRect:I,transform:$,nodeLookup:Z,edgeLookup:G,connectionLookup:le,triggerNodeChanges:ie,triggerEdgeChanges:he,defaultEdgeOptions:fe,resetSelectedElements:pe}=k.getState();if(!D.current||!I)return;const{x:oe,y:me}=Ot(P.nativeEvent,D.current),{startX:Ee,startY:Se}=I;if(!Q.current){const Ne=o?0:u;if(Math.hypot(oe-Ee,me-Se)<=Ne)return;pe(),f==null||f(P)}Q.current=!0;const xe={startX:Ee,startY:Se,x:oe<Ee?oe:Ee,y:me<Se?me:Se,width:Math.abs(oe-Ee),height:Math.abs(me-Se)},ge=O.current,ke=Y.current;O.current=new Set(Ka(Z,xe,$,i===oi.Partial,!0).map(Ne=>Ne.id)),Y.current=new Set;const Ie=(fe==null?void 0:fe.selectable)??!0;for(const Ne of O.current){const Be=le.get(Ne);if(Be)for(const{edgeId:Pt}of Be.values()){const ft=G.get(Pt);ft&&(ft.selectable??Ie)&&Y.current.add(Pt)}}if(!Jd(ge,O.current)){const Ne=Yr(Z,O.current,!0);ie(Ne)}if(!Jd(ke,Y.current)){const Ne=Yr(G,Y.current);he(Ne)}k.setState({userSelectionRect:xe,userSelectionActive:!0,nodesSelectionActive:!1})},R=P=>{var I,$;P.button===0&&(($=(I=P.target)==null?void 0:I.releasePointerCapture)==null||$.call(I,P.pointerId),!N&&P.target===F.current&&k.getState().userSelectionRect&&(ne==null||ne(P)),k.setState({userSelectionActive:!1,userSelectionRect:null}),Q.current&&(h==null||h(P),k.setState({nodesSelectionActive:O.current.size>0})))},W=s===!0||Array.isArray(s)&&s.includes(0);return K.jsxs("div",{className:We(["react-flow__pane",{draggable:W,dragging:L,selection:n}]),onClick:C?void 0:ka(ne,F),onContextMenu:ka(j,F),onWheel:ka(U,F),onPointerEnter:C?void 0:g,onPointerMove:C?B:y,onPointerUp:C?R:void 0,onPointerDownCapture:C?z:void 0,onClickCapture:C?b:void 0,onPointerLeave:x,ref:F,style:gs,children:[S,K.jsx(Fx,{})]})}function Ha({id:n,store:o,unselect:i=!1,nodeRef:s}){const{addSelectedNodes:u,unselectNodesAndEdges:c,multiSelectionActive:f,nodeLookup:h,onError:p}=o.getState(),m=h.get(n);if(!m){p==null||p("012",Kt.error012(n));return}o.setState({nodesSelectionActive:!1}),m.selected?(i||m.selected&&f)&&(c({nodes:[m],edges:[]}),requestAnimationFrame(()=>{var v;return(v=s==null?void 0:s.current)==null?void 0:v.blur()})):u([n])}function tg({nodeRef:n,disabled:o=!1,noDragClassName:i,handleSelector:s,nodeId:u,isSelectable:c,nodeClickDistance:f}){const h=$e(),[p,m]=q.useState(!1),v=q.useRef();return q.useEffect(()=>{v.current=k1({getStoreItems:()=>h.getState(),onNodeMouseDown:g=>{Ha({id:g,store:h,nodeRef:n})},onDragStart:()=>{m(!0)},onDragStop:()=>{m(!1)}})},[]),q.useEffect(()=>{if(!(o||!n.current||!v.current))return v.current.update({noDragClassName:i,handleSelector:s,domNode:n.current,isSelectable:c,nodeId:u,nodeClickDistance:f}),()=>{var g;(g=v.current)==null||g.destroy()}},[i,s,o,c,n,u,f]),p}const Vx=n=>o=>o.selected&&(o.draggable||n&&typeof o.draggable>"u");function ng(){const n=$e();return q.useCallback(i=>{const{nodeExtent:s,snapToGrid:u,snapGrid:c,nodesDraggable:f,onError:h,updateNodePositions:p,nodeLookup:m,nodeOrigin:v}=n.getState(),g=new Map,y=Vx(f),x=u?c[0]:5,S=u?c[1]:5,k=i.direction.x*x*i.factor,N=i.direction.y*S*i.factor;for(const[,E]of m){if(!y(E))continue;let L={x:E.internals.positionAbsolute.x+k,y:E.internals.positionAbsolute.y+N};u&&(L=di(L,c));const{position:_,positionAbsolute:C}=Sp({nodeId:E.id,nextPosition:L,nodeLookup:m,nodeExtent:s,nodeOrigin:v,onError:h});E.position=_,E.internals.positionAbsolute=C,g.set(E.id,E)}p(g)},[])}const rc=q.createContext(null),jx=rc.Provider;rc.Consumer;const rg=()=>q.useContext(rc),Bx=n=>({connectOnClick:n.connectOnClick,noPanClassName:n.noPanClassName,rfId:n.rfId}),Ux=(n,o,i)=>s=>{const{connectionClickStartHandle:u,connectionMode:c,connection:f}=s,{fromHandle:h,toHandle:p,isValid:m}=f,v=(p==null?void 0:p.nodeId)===n&&(p==null?void 0:p.id)===o&&(p==null?void 0:p.type)===i;return{connectingFrom:(h==null?void 0:h.nodeId)===n&&(h==null?void 0:h.id)===o&&(h==null?void 0:h.type)===i,connectingTo:v,clickConnecting:(u==null?void 0:u.nodeId)===n&&(u==null?void 0:u.id)===o&&(u==null?void 0:u.type)===i,isPossibleEndHandle:c===qr.Strict?(h==null?void 0:h.type)!==i:n!==(h==null?void 0:h.nodeId)||o!==(h==null?void 0:h.id),connectionInProcess:!!h,clickConnectionInProcess:!!u,valid:v&&m}};function Wx({type:n="source",position:o=ye.Top,isValidConnection:i,isConnectable:s=!0,isConnectableStart:u=!0,isConnectableEnd:c=!0,id:f,onConnect:h,children:p,className:m,onMouseDown:v,onTouchStart:g,...y},x){var B,R;const S=f||null,k=n==="target",N=$e(),E=rg(),{connectOnClick:L,noPanClassName:_,rfId:C}=Ce(Bx,Re),{connectingFrom:F,connectingTo:D,clickConnecting:O,isPossibleEndHandle:Y,connectionInProcess:Q,clickConnectionInProcess:ne,valid:j}=Ce(Ux(E,S,n),Re);E||(R=(B=N.getState()).onError)==null||R.call(B,"010",Kt.error010());const U=W=>{const{defaultEdgeOptions:P,onConnect:I,hasDefaultEdges:$}=N.getState(),Z={...P,...W};if($){const{edges:G,setEdges:le}=N.getState();le(u1(Z,G))}I==null||I(Z),h==null||h(Z)},b=W=>{if(!E)return;const P=zp(W.nativeEvent);if(u&&(P&&W.button===0||!P)){const I=N.getState();Oa.onPointerDown(W.nativeEvent,{handleDomNode:W.currentTarget,autoPanOnConnect:I.autoPanOnConnect,connectionMode:I.connectionMode,connectionRadius:I.connectionRadius,domNode:I.domNode,nodeLookup:I.nodeLookup,lib:I.lib,isTarget:k,handleId:S,nodeId:E,flowId:I.rfId,panBy:I.panBy,cancelConnection:I.cancelConnection,onConnectStart:I.onConnectStart,onConnectEnd:(...$)=>{var Z,G;return(G=(Z=N.getState()).onConnectEnd)==null?void 0:G.call(Z,...$)},updateConnection:I.updateConnection,onConnect:U,isValidConnection:i||((...$)=>{var Z,G;return((G=(Z=N.getState()).isValidConnection)==null?void 0:G.call(Z,...$))??!0}),getTransform:()=>N.getState().transform,getFromHandle:()=>N.getState().connection.fromHandle,autoPanSpeed:I.autoPanSpeed,dragThreshold:I.connectionDragThreshold})}P?v==null||v(W):g==null||g(W)},z=W=>{const{onClickConnectStart:P,onClickConnectEnd:I,connectionClickStartHandle:$,connectionMode:Z,isValidConnection:G,lib:le,rfId:ie,nodeLookup:he,connection:fe}=N.getState();if(!E||!$&&!u)return;if(!$){P==null||P(W.nativeEvent,{nodeId:E,handleId:S,handleType:n}),N.setState({connectionClickStartHandle:{nodeId:E,type:n,id:S}});return}const pe=Mp(W.target),oe=i||G,{connection:me,isValid:Ee}=Oa.isValid(W.nativeEvent,{handle:{nodeId:E,id:S,type:n},connectionMode:Z,fromNodeId:$.nodeId,fromHandleId:$.id||null,fromType:$.type,isValidConnection:oe,flowId:ie,doc:pe,lib:le,nodeLookup:he});Ee&&me&&U(me);const Se=structuredClone(fe);delete Se.inProgress,Se.toPosition=Se.toHandle?Se.toHandle.position:null,I==null||I(W,Se),N.setState({connectionClickStartHandle:null})};return K.jsx("div",{"data-handleid":S,"data-nodeid":E,"data-handlepos":o,"data-id":`${C}-${E}-${S}-${n}`,className:We(["react-flow__handle",`react-flow__handle-${o}`,"nodrag",_,m,{source:!k,target:k,connectable:s,connectablestart:u,connectableend:c,clickconnecting:O,connectingfrom:F,connectingto:D,valid:j,connectionindicator:s&&(!Q||Y)&&(Q||ne?c:u)}]),onMouseDown:b,onTouchStart:b,onClick:L?z:void 0,ref:x,...y,children:p})}const ns=q.memo(Jp(Wx));function Xx({data:n,isConnectable:o,sourcePosition:i=ye.Bottom}){return K.jsxs(K.Fragment,{children:[n==null?void 0:n.label,K.jsx(ns,{type:"source",position:i,isConnectable:o})]})}function Yx({data:n,isConnectable:o,targetPosition:i=ye.Top,sourcePosition:s=ye.Bottom}){return K.jsxs(K.Fragment,{children:[K.jsx(ns,{type:"target",position:i,isConnectable:o}),n==null?void 0:n.label,K.jsx(ns,{type:"source",position:s,isConnectable:o})]})}function Qx(){return null}function Kx({data:n,isConnectable:o,targetPosition:i=ye.Top}){return K.jsxs(K.Fragment,{children:[K.jsx(ns,{type:"target",position:i,isConnectable:o}),n==null?void 0:n.label]})}const rs={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},zh={input:Xx,default:Yx,output:Kx,group:Qx};function Gx(n){var o,i,s,u;return n.internals.handleBounds===void 0?{width:n.width??n.initialWidth??((o=n.style)==null?void 0:o.width),height:n.height??n.initialHeight??((i=n.style)==null?void 0:i.height)}:{width:n.width??((s=n.style)==null?void 0:s.width),height:n.height??((u=n.style)==null?void 0:u.height)}}const Zx=n=>{const{width:o,height:i,x:s,y:u}=fi(n.nodeLookup,{filter:c=>!!c.selected});return{width:Ft(o)?o:null,height:Ft(i)?i:null,userSelectionActive:n.userSelectionActive,transformString:`translate(${n.transform[0]}px,${n.transform[1]}px) scale(${n.transform[2]}) translate(${s}px,${u}px)`}};function qx({onSelectionContextMenu:n,noPanClassName:o,disableKeyboardA11y:i}){const s=$e(),{width:u,height:c,transformString:f,userSelectionActive:h}=Ce(Zx,Re),p=ng(),m=q.useRef(null);q.useEffect(()=>{var x;i||(x=m.current)==null||x.focus({preventScroll:!0})},[i]);const v=!h&&u!==null&&c!==null;if(tg({nodeRef:m,disabled:!v}),!v)return null;const g=n?x=>{const S=s.getState().nodes.filter(k=>k.selected);n(x,S)}:void 0,y=x=>{Object.prototype.hasOwnProperty.call(rs,x.key)&&(x.preventDefault(),p({direction:rs[x.key],factor:x.shiftKey?4:1}))};return K.jsx("div",{className:We(["react-flow__nodesselection","react-flow__container",o]),style:{transform:f},children:K.jsx("div",{ref:m,className:"react-flow__nodesselection-rect",onContextMenu:g,tabIndex:i?void 0:-1,onKeyDown:i?void 0:y,style:{width:u,height:c}})})}const Ih=typeof window<"u"?window:void 0,bx=n=>({nodesSelectionActive:n.nodesSelectionActive,userSelectionActive:n.userSelectionActive});function og({children:n,onPaneClick:o,onPaneMouseEnter:i,onPaneMouseMove:s,onPaneMouseLeave:u,onPaneContextMenu:c,onPaneScroll:f,paneClickDistance:h,deleteKeyCode:p,selectionKeyCode:m,selectionOnDrag:v,selectionMode:g,onSelectionStart:y,onSelectionEnd:x,multiSelectionKeyCode:S,panActivationKeyCode:k,zoomActivationKeyCode:N,elementsSelectable:E,zoomOnScroll:L,zoomOnPinch:_,panOnScroll:C,panOnScrollSpeed:F,panOnScrollMode:D,zoomOnDoubleClick:O,panOnDrag:Y,defaultViewport:Q,translateExtent:ne,minZoom:j,maxZoom:U,preventScrolling:b,onSelectionContextMenu:z,noWheelClassName:B,noPanClassName:R,disableKeyboardA11y:W,onViewportChange:P,isControlledViewport:I}){const{nodesSelectionActive:$,userSelectionActive:Z}=Ce(bx,Re),G=si(m,{target:Ih}),le=si(k,{target:Ih}),ie=le||Y,he=le||C,fe=v&&ie!==!0,pe=G||Z||fe;return Lx({deleteKeyCode:p,multiSelectionKeyCode:S}),K.jsx(Rx,{onPaneContextMenu:c,elementsSelectable:E,zoomOnScroll:L,zoomOnPinch:_,panOnScroll:he,panOnScrollSpeed:F,panOnScrollMode:D,zoomOnDoubleClick:O,panOnDrag:!G&&ie,defaultViewport:Q,translateExtent:ne,minZoom:j,maxZoom:U,zoomActivationKeyCode:N,preventScrolling:b,noWheelClassName:B,noPanClassName:R,onViewportChange:P,isControlledViewport:I,paneClickDistance:h,selectionOnDrag:fe,children:K.jsxs(Hx,{onSelectionStart:y,onSelectionEnd:x,onPaneClick:o,onPaneMouseEnter:i,onPaneMouseMove:s,onPaneMouseLeave:u,onPaneContextMenu:c,onPaneScroll:f,panOnDrag:ie,isSelecting:!!pe,selectionMode:g,selectionKeyPressed:G,paneClickDistance:h,selectionOnDrag:fe,children:[n,$&&K.jsx(qx,{onSelectionContextMenu:z,noPanClassName:R,disableKeyboardA11y:W})]})})}og.displayName="FlowRenderer";const Jx=q.memo(og),eS=n=>o=>n?Ka(o.nodeLookup,{x:0,y:0,width:o.width,height:o.height},o.transform,!0).map(i=>i.id):Array.from(o.nodeLookup.keys());function tS(n){return Ce(q.useCallback(eS(n),[n]),Re)}const nS=n=>n.updateNodeInternals;function rS(){const n=Ce(nS),[o]=q.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(i=>{const s=new Map;i.forEach(u=>{const c=u.target.getAttribute("data-id");s.set(c,{id:c,nodeElement:u.target,force:!0})}),n(s)}));return q.useEffect(()=>()=>{o==null||o.disconnect()},[o]),o}function oS({node:n,nodeType:o,hasDimensions:i,resizeObserver:s}){const u=$e(),c=q.useRef(null),f=q.useRef(null),h=q.useRef(n.sourcePosition),p=q.useRef(n.targetPosition),m=q.useRef(o),v=i&&!!n.internals.handleBounds;return q.useEffect(()=>{c.current&&!n.hidden&&(!v||f.current!==c.current)&&(f.current&&(s==null||s.unobserve(f.current)),s==null||s.observe(c.current),f.current=c.current)},[v,n.hidden]),q.useEffect(()=>()=>{f.current&&(s==null||s.unobserve(f.current),f.current=null)},[]),q.useEffect(()=>{if(c.current){const g=m.current!==o,y=h.current!==n.sourcePosition,x=p.current!==n.targetPosition;(g||y||x)&&(m.current=o,h.current=n.sourcePosition,p.current=n.targetPosition,u.getState().updateNodeInternals(new Map([[n.id,{id:n.id,nodeElement:c.current,force:!0}]])))}},[n.id,o,n.sourcePosition,n.targetPosition]),c}function iS({id:n,onClick:o,onMouseEnter:i,onMouseMove:s,onMouseLeave:u,onContextMenu:c,onDoubleClick:f,nodesDraggable:h,elementsSelectable:p,nodesConnectable:m,nodesFocusable:v,resizeObserver:g,noDragClassName:y,noPanClassName:x,disableKeyboardA11y:S,rfId:k,nodeTypes:N,nodeClickDistance:E,onError:L}){const{node:_,internals:C,isParent:F}=Ce(oe=>{const me=oe.nodeLookup.get(n),Ee=oe.parentLookup.has(n);return{node:me,internals:me.internals,isParent:Ee}},Re);let D=_.type||"default",O=(N==null?void 0:N[D])||zh[D];O===void 0&&(L==null||L("003",Kt.error003(D)),D="default",O=(N==null?void 0:N.default)||zh.default);const Y=!!(_.draggable||h&&typeof _.draggable>"u"),Q=!!(_.selectable||p&&typeof _.selectable>"u"),ne=!!(_.connectable||m&&typeof _.connectable>"u"),j=!!(_.focusable||v&&typeof _.focusable>"u"),U=$e(),b=Np(_),z=oS({node:_,nodeType:D,hasDimensions:b,resizeObserver:g}),B=tg({nodeRef:z,disabled:_.hidden||!Y,noDragClassName:y,handleSelector:_.dragHandle,nodeId:n,isSelectable:Q,nodeClickDistance:E}),R=ng();if(_.hidden)return null;const W=dn(_),P=Gx(_),I=Q||Y||o||i||s||u,$=i?oe=>i(oe,{...C.userNode}):void 0,Z=s?oe=>s(oe,{...C.userNode}):void 0,G=u?oe=>u(oe,{...C.userNode}):void 0,le=c?oe=>c(oe,{...C.userNode}):void 0,ie=f?oe=>f(oe,{...C.userNode}):void 0,he=oe=>{const{selectNodesOnDrag:me,nodeDragThreshold:Ee}=U.getState();Q&&(!me||!Y||Ee>0)&&Ha({id:n,store:U,nodeRef:z}),o&&o(oe,{...C.userNode})},fe=oe=>{if(!(Pp(oe.nativeEvent)||S)){if(mp.includes(oe.key)&&Q){const me=oe.key==="Escape";Ha({id:n,store:U,unselect:me,nodeRef:z})}else if(Y&&_.selected&&Object.prototype.hasOwnProperty.call(rs,oe.key)){oe.preventDefault();const{ariaLabelConfig:me}=U.getState();U.setState({ariaLiveMessage:me["node.a11yDescription.ariaLiveMessage"]({direction:oe.key.replace("Arrow","").toLowerCase(),x:~~C.positionAbsolute.x,y:~~C.positionAbsolute.y})}),R({direction:rs[oe.key],factor:oe.shiftKey?4:1})}}},pe=()=>{var ke;if(S||!((ke=z.current)!=null&&ke.matches(":focus-visible")))return;const{transform:oe,width:me,height:Ee,autoPanOnNodeFocus:Se,setCenter:xe}=U.getState();if(!Se)return;Ka(new Map([[n,_]]),{x:0,y:0,width:me,height:Ee},oe,!0).length>0||xe(_.position.x+W.width/2,_.position.y+W.height/2,{zoom:oe[2]})};return K.jsx("div",{className:We(["react-flow__node",`react-flow__node-${D}`,{[x]:Y},_.className,{selected:_.selected,selectable:Q,parent:F,draggable:Y,dragging:B}]),ref:z,style:{zIndex:C.z,transform:`translate(${C.positionAbsolute.x}px,${C.positionAbsolute.y}px)`,pointerEvents:I?"all":"none",visibility:b?"visible":"hidden",..._.style,...P},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:$,onMouseMove:Z,onMouseLeave:G,onContextMenu:le,onClick:he,onDoubleClick:ie,onKeyDown:j?fe:void 0,tabIndex:j?0:void 0,onFocus:j?pe:void 0,role:_.ariaRole??(j?"group":void 0),"aria-roledescription":"node","aria-describedby":S?void 0:`${Qp}-${k}`,"aria-label":_.ariaLabel,..._.domAttributes,children:K.jsx(jx,{value:n,children:K.jsx(O,{id:n,data:_.data,type:D,positionAbsoluteX:C.positionAbsolute.x,positionAbsoluteY:C.positionAbsolute.y,selected:_.selected??!1,selectable:Q,draggable:Y,deletable:_.deletable??!0,isConnectable:ne,sourcePosition:_.sourcePosition,targetPosition:_.targetPosition,dragging:B,dragHandle:_.dragHandle,zIndex:C.z,parentId:_.parentId,...W})})})}var lS=q.memo(iS);const sS=n=>({nodesDraggable:n.nodesDraggable,nodesConnectable:n.nodesConnectable,nodesFocusable:n.nodesFocusable,elementsSelectable:n.elementsSelectable,onError:n.onError});function ig(n){const{nodesDraggable:o,nodesConnectable:i,nodesFocusable:s,elementsSelectable:u,onError:c}=Ce(sS,Re),f=tS(n.onlyRenderVisibleElements),h=rS();return K.jsx("div",{className:"react-flow__nodes",style:gs,children:f.map(p=>K.jsx(lS,{id:p,nodeTypes:n.nodeTypes,nodeExtent:n.nodeExtent,onClick:n.onNodeClick,onMouseEnter:n.onNodeMouseEnter,onMouseMove:n.onNodeMouseMove,onMouseLeave:n.onNodeMouseLeave,onContextMenu:n.onNodeContextMenu,onDoubleClick:n.onNodeDoubleClick,noDragClassName:n.noDragClassName,noPanClassName:n.noPanClassName,rfId:n.rfId,disableKeyboardA11y:n.disableKeyboardA11y,resizeObserver:h,nodesDraggable:o,nodesConnectable:i,nodesFocusable:s,elementsSelectable:u,nodeClickDistance:n.nodeClickDistance,onError:c},p))})}ig.displayName="NodeRenderer";const uS=q.memo(ig);function aS(n){return Ce(q.useCallback(i=>{if(!n)return i.edges.map(u=>u.id);const s=[];if(i.width&&i.height)for(const u of i.edges){const c=i.nodeLookup.get(u.source),f=i.nodeLookup.get(u.target);c&&f&&i1({sourceNode:c,targetNode:f,width:i.width,height:i.height,transform:i.transform})&&s.push(u.id)}return s},[n]),Re)}const cS=({color:n="none",strokeWidth:o=1})=>{const i={strokeWidth:o,...n&&{stroke:n}};return K.jsx("polyline",{className:"arrow",style:i,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},fS=({color:n="none",strokeWidth:o=1})=>{const i={strokeWidth:o,...n&&{stroke:n,fill:n}};return K.jsx("polyline",{className:"arrowclosed",style:i,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},Th={[Jl.Arrow]:cS,[Jl.ArrowClosed]:fS};function dS(n){const o=$e();return q.useMemo(()=>{var u,c;return Object.prototype.hasOwnProperty.call(Th,n)?Th[n]:((c=(u=o.getState()).onError)==null||c.call(u,"009",Kt.error009(n)),null)},[n])}const hS=({id:n,type:o,color:i,width:s=12.5,height:u=12.5,markerUnits:c="strokeWidth",strokeWidth:f,orient:h="auto-start-reverse"})=>{const p=dS(o);return p?K.jsx("marker",{className:"react-flow__arrowhead",id:n,markerWidth:`${s}`,markerHeight:`${u}`,viewBox:"-10 -10 20 20",markerUnits:c,orient:h,refX:"0",refY:"0",children:K.jsx(p,{color:i,strokeWidth:f})}):null},lg=({defaultColor:n,rfId:o})=>{const i=Ce(c=>c.edges),s=Ce(c=>c.defaultEdgeOptions),u=q.useMemo(()=>h1(i,{id:o,defaultColor:n,defaultMarkerStart:s==null?void 0:s.markerStart,defaultMarkerEnd:s==null?void 0:s.markerEnd}),[i,s,o,n]);return u.length?K.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:K.jsx("defs",{children:u.map(c=>K.jsx(hS,{id:c.id,type:c.type,color:c.color,width:c.width,height:c.height,markerUnits:c.markerUnits,strokeWidth:c.strokeWidth,orient:c.orient},c.id))})}):null};lg.displayName="MarkerDefinitions";var pS=q.memo(lg);function sg({x:n,y:o,label:i,labelStyle:s,labelShowBg:u=!0,labelBgStyle:c,labelBgPadding:f=[2,4],labelBgBorderRadius:h=2,children:p,className:m,...v}){const[g,y]=q.useState({x:1,y:0,width:0,height:0}),x=We(["react-flow__edge-textwrapper",m]),S=q.useRef(null);return q.useEffect(()=>{if(S.current){const k=S.current.getBBox();y({x:k.x,y:k.y,width:k.width,height:k.height})}},[i]),i?K.jsxs("g",{transform:`translate(${n-g.width/2} ${o-g.height/2})`,className:x,visibility:g.width?"visible":"hidden",...v,children:[u&&K.jsx("rect",{width:g.width+2*f[0],x:-f[0],y:-f[1],height:g.height+2*f[1],className:"react-flow__edge-textbg",style:c,rx:h,ry:h}),K.jsx("text",{className:"react-flow__edge-text",y:g.height/2,dy:"0.3em",ref:S,style:s,children:i}),p]}):null}sg.displayName="EdgeText";const gS=q.memo(sg);function ms({path:n,labelX:o,labelY:i,label:s,labelStyle:u,labelShowBg:c,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:p,interactionWidth:m=20,...v}){return K.jsxs(K.Fragment,{children:[K.jsx("path",{...v,d:n,fill:"none",className:We(["react-flow__edge-path",v.className])}),m?K.jsx("path",{d:n,fill:"none",strokeOpacity:0,strokeWidth:m,className:"react-flow__edge-interaction"}):null,s&&Ft(o)&&Ft(i)?K.jsx(gS,{x:o,y:i,label:s,labelStyle:u,labelShowBg:c,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:p}):null]})}function Lh({pos:n,x1:o,y1:i,x2:s,y2:u}){return n===ye.Left||n===ye.Right?[.5*(o+s),i]:[o,.5*(i+u)]}function ug({sourceX:n,sourceY:o,sourcePosition:i=ye.Bottom,targetX:s,targetY:u,targetPosition:c=ye.Top}){const[f,h]=Lh({pos:i,x1:n,y1:o,x2:s,y2:u}),[p,m]=Lh({pos:c,x1:s,y1:u,x2:n,y2:o}),[v,g,y,x]=Ip({sourceX:n,sourceY:o,targetX:s,targetY:u,sourceControlX:f,sourceControlY:h,targetControlX:p,targetControlY:m});return[`M${n},${o} C${f},${h} ${p},${m} ${s},${u}`,v,g,y,x]}function ag(n){return q.memo(({id:o,sourceX:i,sourceY:s,targetX:u,targetY:c,sourcePosition:f,targetPosition:h,label:p,labelStyle:m,labelShowBg:v,labelBgStyle:g,labelBgPadding:y,labelBgBorderRadius:x,style:S,markerEnd:k,markerStart:N,interactionWidth:E})=>{const[L,_,C]=ug({sourceX:i,sourceY:s,sourcePosition:f,targetX:u,targetY:c,targetPosition:h}),F=n.isInternal?void 0:o;return K.jsx(ms,{id:F,path:L,labelX:_,labelY:C,label:p,labelStyle:m,labelShowBg:v,labelBgStyle:g,labelBgPadding:y,labelBgBorderRadius:x,style:S,markerEnd:k,markerStart:N,interactionWidth:E})})}const mS=ag({isInternal:!1}),cg=ag({isInternal:!0});mS.displayName="SimpleBezierEdge";cg.displayName="SimpleBezierEdgeInternal";function fg(n){return q.memo(({id:o,sourceX:i,sourceY:s,targetX:u,targetY:c,label:f,labelStyle:h,labelShowBg:p,labelBgStyle:m,labelBgPadding:v,labelBgBorderRadius:g,style:y,sourcePosition:x=ye.Bottom,targetPosition:S=ye.Top,markerEnd:k,markerStart:N,pathOptions:E,interactionWidth:L})=>{const[_,C,F]=Ra({sourceX:i,sourceY:s,sourcePosition:x,targetX:u,targetY:c,targetPosition:S,borderRadius:E==null?void 0:E.borderRadius,offset:E==null?void 0:E.offset,stepPosition:E==null?void 0:E.stepPosition}),D=n.isInternal?void 0:o;return K.jsx(ms,{id:D,path:_,labelX:C,labelY:F,label:f,labelStyle:h,labelShowBg:p,labelBgStyle:m,labelBgPadding:v,labelBgBorderRadius:g,style:y,markerEnd:k,markerStart:N,interactionWidth:L})})}const dg=fg({isInternal:!1}),hg=fg({isInternal:!0});dg.displayName="SmoothStepEdge";hg.displayName="SmoothStepEdgeInternal";function pg(n){return q.memo(({id:o,...i})=>{var u;const s=n.isInternal?void 0:o;return K.jsx(dg,{...i,id:s,pathOptions:q.useMemo(()=>{var c;return{borderRadius:0,offset:(c=i.pathOptions)==null?void 0:c.offset}},[(u=i.pathOptions)==null?void 0:u.offset])})})}const yS=pg({isInternal:!1}),gg=pg({isInternal:!0});yS.displayName="StepEdge";gg.displayName="StepEdgeInternal";function mg(n){return q.memo(({id:o,sourceX:i,sourceY:s,targetX:u,targetY:c,label:f,labelStyle:h,labelShowBg:p,labelBgStyle:m,labelBgPadding:v,labelBgBorderRadius:g,style:y,markerEnd:x,markerStart:S,interactionWidth:k})=>{const[N,E,L]=Ap({sourceX:i,sourceY:s,targetX:u,targetY:c}),_=n.isInternal?void 0:o;return K.jsx(ms,{id:_,path:N,labelX:E,labelY:L,label:f,labelStyle:h,labelShowBg:p,labelBgStyle:m,labelBgPadding:v,labelBgBorderRadius:g,style:y,markerEnd:x,markerStart:S,interactionWidth:k})})}const vS=mg({isInternal:!1}),yg=mg({isInternal:!0});vS.displayName="StraightEdge";yg.displayName="StraightEdgeInternal";function vg(n){return q.memo(({id:o,sourceX:i,sourceY:s,targetX:u,targetY:c,sourcePosition:f=ye.Bottom,targetPosition:h=ye.Top,label:p,labelStyle:m,labelShowBg:v,labelBgStyle:g,labelBgPadding:y,labelBgBorderRadius:x,style:S,markerEnd:k,markerStart:N,pathOptions:E,interactionWidth:L})=>{const[_,C,F]=Tp({sourceX:i,sourceY:s,sourcePosition:f,targetX:u,targetY:c,targetPosition:h,curvature:E==null?void 0:E.curvature}),D=n.isInternal?void 0:o;return K.jsx(ms,{id:D,path:_,labelX:C,labelY:F,label:p,labelStyle:m,labelShowBg:v,labelBgStyle:g,labelBgPadding:y,labelBgBorderRadius:x,style:S,markerEnd:k,markerStart:N,interactionWidth:L})})}const wS=vg({isInternal:!1}),wg=vg({isInternal:!0});wS.displayName="BezierEdge";wg.displayName="BezierEdgeInternal";const Ah={default:wg,straight:yg,step:gg,smoothstep:hg,simplebezier:cg},Dh={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},xS=(n,o,i)=>i===ye.Left?n-o:i===ye.Right?n+o:n,SS=(n,o,i)=>i===ye.Top?n-o:i===ye.Bottom?n+o:n,Rh="react-flow__edgeupdater";function $h({position:n,centerX:o,centerY:i,radius:s=10,onMouseDown:u,onMouseEnter:c,onMouseOut:f,type:h}){return K.jsx("circle",{onMouseDown:u,onMouseEnter:c,onMouseOut:f,className:We([Rh,`${Rh}-${h}`]),cx:xS(o,s,n),cy:SS(i,s,n),r:s,stroke:"transparent",fill:"transparent"})}function _S({isReconnectable:n,reconnectRadius:o,edge:i,sourceX:s,sourceY:u,targetX:c,targetY:f,sourcePosition:h,targetPosition:p,onReconnect:m,onReconnectStart:v,onReconnectEnd:g,setReconnecting:y,setUpdateHover:x}){const S=$e(),k=(C,F)=>{if(C.button!==0)return;const{autoPanOnConnect:D,domNode:O,connectionMode:Y,connectionRadius:Q,lib:ne,onConnectStart:j,cancelConnection:U,nodeLookup:b,rfId:z,panBy:B,updateConnection:R}=S.getState(),W=F.type==="target",P=(Z,G)=>{y(!1),g==null||g(Z,i,F.type,G)},I=Z=>m==null?void 0:m(i,Z),$=(Z,G)=>{y(!0),v==null||v(C,i,F.type),j==null||j(Z,G)};Oa.onPointerDown(C.nativeEvent,{autoPanOnConnect:D,connectionMode:Y,connectionRadius:Q,domNode:O,handleId:F.id,nodeId:F.nodeId,nodeLookup:b,isTarget:W,edgeUpdaterType:F.type,lib:ne,flowId:z,cancelConnection:U,panBy:B,isValidConnection:(...Z)=>{var G,le;return((le=(G=S.getState()).isValidConnection)==null?void 0:le.call(G,...Z))??!0},onConnect:I,onConnectStart:$,onConnectEnd:(...Z)=>{var G,le;return(le=(G=S.getState()).onConnectEnd)==null?void 0:le.call(G,...Z)},onReconnectEnd:P,updateConnection:R,getTransform:()=>S.getState().transform,getFromHandle:()=>S.getState().connection.fromHandle,dragThreshold:S.getState().connectionDragThreshold,handleDomNode:C.currentTarget})},N=C=>k(C,{nodeId:i.target,id:i.targetHandle??null,type:"target"}),E=C=>k(C,{nodeId:i.source,id:i.sourceHandle??null,type:"source"}),L=()=>x(!0),_=()=>x(!1);return K.jsxs(K.Fragment,{children:[(n===!0||n==="source")&&K.jsx($h,{position:h,centerX:s,centerY:u,radius:o,onMouseDown:N,onMouseEnter:L,onMouseOut:_,type:"source"}),(n===!0||n==="target")&&K.jsx($h,{position:p,centerX:c,centerY:f,radius:o,onMouseDown:E,onMouseEnter:L,onMouseOut:_,type:"target"})]})}function ES({id:n,edgesFocusable:o,edgesReconnectable:i,elementsSelectable:s,onClick:u,onDoubleClick:c,onContextMenu:f,onMouseEnter:h,onMouseMove:p,onMouseLeave:m,reconnectRadius:v,onReconnect:g,onReconnectStart:y,onReconnectEnd:x,rfId:S,edgeTypes:k,noPanClassName:N,onError:E,disableKeyboardA11y:L}){let _=Ce(xe=>xe.edgeLookup.get(n));const C=Ce(xe=>xe.defaultEdgeOptions);_=C?{...C,..._}:_;let F=_.type||"default",D=(k==null?void 0:k[F])||Ah[F];D===void 0&&(E==null||E("011",Kt.error011(F)),F="default",D=(k==null?void 0:k.default)||Ah.default);const O=!!(_.focusable||o&&typeof _.focusable>"u"),Y=typeof g<"u"&&(_.reconnectable||i&&typeof _.reconnectable>"u"),Q=!!(_.selectable||s&&typeof _.selectable>"u"),ne=q.useRef(null),[j,U]=q.useState(!1),[b,z]=q.useState(!1),B=$e(),{zIndex:R,sourceX:W,sourceY:P,targetX:I,targetY:$,sourcePosition:Z,targetPosition:G}=Ce(q.useCallback(xe=>{const ge=xe.nodeLookup.get(_.source),ke=xe.nodeLookup.get(_.target);if(!ge||!ke)return{zIndex:_.zIndex,...Dh};const Ie=d1({id:n,sourceNode:ge,targetNode:ke,sourceHandle:_.sourceHandle||null,targetHandle:_.targetHandle||null,connectionMode:xe.connectionMode,onError:E});return{zIndex:o1({selected:_.selected,zIndex:_.zIndex,sourceNode:ge,targetNode:ke,elevateOnSelect:xe.elevateEdgesOnSelect,zIndexMode:xe.zIndexMode}),...Ie||Dh}},[_.source,_.target,_.sourceHandle,_.targetHandle,_.selected,_.zIndex]),Re),le=q.useMemo(()=>_.markerStart?`url('#${$a(_.markerStart,S)}')`:void 0,[_.markerStart,S]),ie=q.useMemo(()=>_.markerEnd?`url('#${$a(_.markerEnd,S)}')`:void 0,[_.markerEnd,S]);if(_.hidden||W===null||P===null||I===null||$===null)return null;const he=xe=>{var Ne;const{addSelectedEdges:ge,unselectNodesAndEdges:ke,multiSelectionActive:Ie}=B.getState();Q&&(B.setState({nodesSelectionActive:!1}),_.selected&&Ie?(ke({nodes:[],edges:[_]}),(Ne=ne.current)==null||Ne.blur()):ge([n])),u&&u(xe,_)},fe=c?xe=>{c(xe,{..._})}:void 0,pe=f?xe=>{f(xe,{..._})}:void 0,oe=h?xe=>{h(xe,{..._})}:void 0,me=p?xe=>{p(xe,{..._})}:void 0,Ee=m?xe=>{m(xe,{..._})}:void 0,Se=xe=>{var ge;if(!L&&mp.includes(xe.key)&&Q){const{unselectNodesAndEdges:ke,addSelectedEdges:Ie}=B.getState();xe.key==="Escape"?((ge=ne.current)==null||ge.blur(),ke({edges:[_]})):Ie([n])}};return K.jsx("svg",{style:{zIndex:R},children:K.jsxs("g",{className:We(["react-flow__edge",`react-flow__edge-${F}`,_.className,N,{selected:_.selected,animated:_.animated,inactive:!Q&&!u,updating:j,selectable:Q}]),onClick:he,onDoubleClick:fe,onContextMenu:pe,onMouseEnter:oe,onMouseMove:me,onMouseLeave:Ee,onKeyDown:O?Se:void 0,tabIndex:O?0:void 0,role:_.ariaRole??(O?"group":"img"),"aria-roledescription":"edge","data-id":n,"data-testid":`rf__edge-${n}`,"aria-label":_.ariaLabel===null?void 0:_.ariaLabel||`Edge from ${_.source} to ${_.target}`,"aria-describedby":O?`${Kp}-${S}`:void 0,ref:ne,..._.domAttributes,children:[!b&&K.jsx(D,{id:n,source:_.source,target:_.target,type:_.type,selected:_.selected,animated:_.animated,selectable:Q,deletable:_.deletable??!0,label:_.label,labelStyle:_.labelStyle,labelShowBg:_.labelShowBg,labelBgStyle:_.labelBgStyle,labelBgPadding:_.labelBgPadding,labelBgBorderRadius:_.labelBgBorderRadius,sourceX:W,sourceY:P,targetX:I,targetY:$,sourcePosition:Z,targetPosition:G,data:_.data,style:_.style,sourceHandleId:_.sourceHandle,targetHandleId:_.targetHandle,markerStart:le,markerEnd:ie,pathOptions:"pathOptions"in _?_.pathOptions:void 0,interactionWidth:_.interactionWidth}),Y&&K.jsx(_S,{edge:_,isReconnectable:Y,reconnectRadius:v,onReconnect:g,onReconnectStart:y,onReconnectEnd:x,sourceX:W,sourceY:P,targetX:I,targetY:$,sourcePosition:Z,targetPosition:G,setUpdateHover:U,setReconnecting:z})]})})}var kS=q.memo(ES);const NS=n=>({edgesFocusable:n.edgesFocusable,edgesReconnectable:n.edgesReconnectable,elementsSelectable:n.elementsSelectable,connectionMode:n.connectionMode,onError:n.onError});function xg({defaultMarkerColor:n,onlyRenderVisibleElements:o,rfId:i,edgeTypes:s,noPanClassName:u,onReconnect:c,onEdgeContextMenu:f,onEdgeMouseEnter:h,onEdgeMouseMove:p,onEdgeMouseLeave:m,onEdgeClick:v,reconnectRadius:g,onEdgeDoubleClick:y,onReconnectStart:x,onReconnectEnd:S,disableKeyboardA11y:k}){const{edgesFocusable:N,edgesReconnectable:E,elementsSelectable:L,onError:_}=Ce(NS,Re),C=aS(o);return K.jsxs("div",{className:"react-flow__edges",children:[K.jsx(pS,{defaultColor:n,rfId:i}),C.map(F=>K.jsx(kS,{id:F,edgesFocusable:N,edgesReconnectable:E,elementsSelectable:L,noPanClassName:u,onReconnect:c,onContextMenu:f,onMouseEnter:h,onMouseMove:p,onMouseLeave:m,onClick:v,reconnectRadius:g,onDoubleClick:y,onReconnectStart:x,onReconnectEnd:S,rfId:i,onError:_,edgeTypes:s,disableKeyboardA11y:k},F))]})}xg.displayName="EdgeRenderer";const CS=q.memo(xg),MS=n=>`translate(${n.transform[0]}px,${n.transform[1]}px) scale(${n.transform[2]})`;function PS({children:n}){const o=Ce(MS);return K.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:o},children:n})}function zS(n){const o=nc(),i=q.useRef(!1);q.useEffect(()=>{!i.current&&o.viewportInitialized&&n&&(setTimeout(()=>n(o),1),i.current=!0)},[n,o.viewportInitialized])}const IS=n=>{var o;return(o=n.panZoom)==null?void 0:o.syncViewport};function TS(n){const o=Ce(IS),i=$e();return q.useEffect(()=>{n&&(o==null||o(n),i.setState({transform:[n.x,n.y,n.zoom]}))},[n,o]),null}function LS(n){return n.connection.inProgress?{...n.connection,to:hi(n.connection.to,n.transform)}:{...n.connection}}function AS(n){return LS}function DS(n){const o=AS();return Ce(o,Re)}const RS=n=>({nodesConnectable:n.nodesConnectable,isValid:n.connection.isValid,inProgress:n.connection.inProgress,width:n.width,height:n.height});function $S({containerStyle:n,style:o,type:i,component:s}){const{nodesConnectable:u,width:c,height:f,isValid:h,inProgress:p}=Ce(RS,Re);return!(c&&u&&p)?null:K.jsx("svg",{style:n,width:c,height:f,className:"react-flow__connectionline react-flow__container",children:K.jsx("g",{className:We(["react-flow__connection",wp(h)]),children:K.jsx(Sg,{style:o,type:i,CustomComponent:s,isValid:h})})})}const Sg=({style:n,type:o=Fn.Bezier,CustomComponent:i,isValid:s})=>{const{inProgress:u,from:c,fromNode:f,fromHandle:h,fromPosition:p,to:m,toNode:v,toHandle:g,toPosition:y,pointer:x}=DS();if(!u)return;if(i)return K.jsx(i,{connectionLineType:o,connectionLineStyle:n,fromNode:f,fromHandle:h,fromX:c.x,fromY:c.y,toX:m.x,toY:m.y,fromPosition:p,toPosition:y,connectionStatus:wp(s),toNode:v,toHandle:g,pointer:x});let S="";const k={sourceX:c.x,sourceY:c.y,sourcePosition:p,targetX:m.x,targetY:m.y,targetPosition:y};switch(o){case Fn.Bezier:[S]=Tp(k);break;case Fn.SimpleBezier:[S]=ug(k);break;case Fn.Step:[S]=Ra({...k,borderRadius:0});break;case Fn.SmoothStep:[S]=Ra(k);break;default:[S]=Ap(k)}return K.jsx("path",{d:S,fill:"none",className:"react-flow__connection-path",style:n})};Sg.displayName="ConnectionLine";const FS={};function Fh(n=FS){q.useRef(n),$e(),q.useEffect(()=>{},[n])}function OS(){$e(),q.useRef(!1),q.useEffect(()=>{},[])}function _g({nodeTypes:n,edgeTypes:o,onInit:i,onNodeClick:s,onEdgeClick:u,onNodeDoubleClick:c,onEdgeDoubleClick:f,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:m,onNodeContextMenu:v,onSelectionContextMenu:g,onSelectionStart:y,onSelectionEnd:x,connectionLineType:S,connectionLineStyle:k,connectionLineComponent:N,connectionLineContainerStyle:E,selectionKeyCode:L,selectionOnDrag:_,selectionMode:C,multiSelectionKeyCode:F,panActivationKeyCode:D,zoomActivationKeyCode:O,deleteKeyCode:Y,onlyRenderVisibleElements:Q,elementsSelectable:ne,defaultViewport:j,translateExtent:U,minZoom:b,maxZoom:z,preventScrolling:B,defaultMarkerColor:R,zoomOnScroll:W,zoomOnPinch:P,panOnScroll:I,panOnScrollSpeed:$,panOnScrollMode:Z,zoomOnDoubleClick:G,panOnDrag:le,onPaneClick:ie,onPaneMouseEnter:he,onPaneMouseMove:fe,onPaneMouseLeave:pe,onPaneScroll:oe,onPaneContextMenu:me,paneClickDistance:Ee,nodeClickDistance:Se,onEdgeContextMenu:xe,onEdgeMouseEnter:ge,onEdgeMouseMove:ke,onEdgeMouseLeave:Ie,reconnectRadius:Ne,onReconnect:Be,onReconnectStart:Pt,onReconnectEnd:ft,noDragClassName:dt,noWheelClassName:xt,noPanClassName:Zt,disableKeyboardA11y:hn,nodeExtent:pr,rfId:Hn,viewport:qt,onViewportChange:bt}){return Fh(n),Fh(o),OS(),zS(i),TS(qt),K.jsx(Jx,{onPaneClick:ie,onPaneMouseEnter:he,onPaneMouseMove:fe,onPaneMouseLeave:pe,onPaneContextMenu:me,onPaneScroll:oe,paneClickDistance:Ee,deleteKeyCode:Y,selectionKeyCode:L,selectionOnDrag:_,selectionMode:C,onSelectionStart:y,onSelectionEnd:x,multiSelectionKeyCode:F,panActivationKeyCode:D,zoomActivationKeyCode:O,elementsSelectable:ne,zoomOnScroll:W,zoomOnPinch:P,zoomOnDoubleClick:G,panOnScroll:I,panOnScrollSpeed:$,panOnScrollMode:Z,panOnDrag:le,defaultViewport:j,translateExtent:U,minZoom:b,maxZoom:z,onSelectionContextMenu:g,preventScrolling:B,noDragClassName:dt,noWheelClassName:xt,noPanClassName:Zt,disableKeyboardA11y:hn,onViewportChange:bt,isControlledViewport:!!qt,children:K.jsxs(PS,{children:[K.jsx(CS,{edgeTypes:o,onEdgeClick:u,onEdgeDoubleClick:f,onReconnect:Be,onReconnectStart:Pt,onReconnectEnd:ft,onlyRenderVisibleElements:Q,onEdgeContextMenu:xe,onEdgeMouseEnter:ge,onEdgeMouseMove:ke,onEdgeMouseLeave:Ie,reconnectRadius:Ne,defaultMarkerColor:R,noPanClassName:Zt,disableKeyboardA11y:hn,rfId:Hn}),K.jsx($S,{style:k,type:S,component:N,containerStyle:E}),K.jsx("div",{className:"react-flow__edgelabel-renderer"}),K.jsx(uS,{nodeTypes:n,onNodeClick:s,onNodeDoubleClick:c,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:m,onNodeContextMenu:v,nodeClickDistance:Se,onlyRenderVisibleElements:Q,noPanClassName:Zt,noDragClassName:dt,disableKeyboardA11y:hn,nodeExtent:pr,rfId:Hn}),K.jsx("div",{className:"react-flow__viewport-portal"})]})})}_g.displayName="GraphView";const HS=q.memo(_g),Oh=({nodes:n,edges:o,defaultNodes:i,defaultEdges:s,width:u,height:c,fitView:f,fitViewOptions:h,minZoom:p=.5,maxZoom:m=2,nodeOrigin:v,nodeExtent:g,zIndexMode:y="basic"}={})=>{const x=new Map,S=new Map,k=new Map,N=new Map,E=s??o??[],L=i??n??[],_=v??[0,0],C=g??ri;$p(k,N,E);const F=Fa(L,x,S,{nodeOrigin:_,nodeExtent:C,zIndexMode:y});let D=[0,0,1];if(f&&u&&c){const O=fi(x,{filter:j=>!!((j.width||j.initialWidth)&&(j.height||j.initialHeight))}),{x:Y,y:Q,zoom:ne}=Ga(O,u,c,p,m,(h==null?void 0:h.padding)??.1);D=[Y,Q,ne]}return{rfId:"1",width:u??0,height:c??0,transform:D,nodes:L,nodesInitialized:F,nodeLookup:x,parentLookup:S,edges:E,edgeLookup:N,connectionLookup:k,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:i!==void 0,hasDefaultEdges:s!==void 0,panZoom:null,minZoom:p,maxZoom:m,translateExtent:ri,nodeExtent:C,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:qr.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:_,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:f??!1,fitViewOptions:h,fitViewResolver:null,connection:{...vp},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:bw,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:yp,zIndexMode:y,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},VS=({nodes:n,edges:o,defaultNodes:i,defaultEdges:s,width:u,height:c,fitView:f,fitViewOptions:h,minZoom:p,maxZoom:m,nodeOrigin:v,nodeExtent:g,zIndexMode:y})=>ox((x,S)=>{async function k(){const{nodeLookup:N,panZoom:E,fitViewOptions:L,fitViewResolver:_,width:C,height:F,minZoom:D,maxZoom:O}=S();E&&(await Zw({nodes:N,width:C,height:F,panZoom:E,minZoom:D,maxZoom:O},L),_==null||_.resolve(!0),x({fitViewResolver:null}))}return{...Oh({nodes:n,edges:o,width:u,height:c,fitView:f,fitViewOptions:h,minZoom:p,maxZoom:m,nodeOrigin:v,nodeExtent:g,defaultNodes:i,defaultEdges:s,zIndexMode:y}),setNodes:N=>{const{nodeLookup:E,parentLookup:L,nodeOrigin:_,elevateNodesOnSelect:C,fitViewQueued:F,zIndexMode:D}=S(),O=Fa(N,E,L,{nodeOrigin:_,nodeExtent:g,elevateNodesOnSelect:C,checkEquality:!0,zIndexMode:D});F&&O?(k(),x({nodes:N,nodesInitialized:O,fitViewQueued:!1,fitViewOptions:void 0})):x({nodes:N,nodesInitialized:O})},setEdges:N=>{const{connectionLookup:E,edgeLookup:L}=S();$p(E,L,N),x({edges:N})},setDefaultNodesAndEdges:(N,E)=>{if(N){const{setNodes:L}=S();L(N),x({hasDefaultNodes:!0})}if(E){const{setEdges:L}=S();L(E),x({hasDefaultEdges:!0})}},updateNodeInternals:N=>{const{triggerNodeChanges:E,nodeLookup:L,parentLookup:_,domNode:C,nodeOrigin:F,nodeExtent:D,debug:O,fitViewQueued:Y,zIndexMode:Q}=S(),{changes:ne,updatedInternals:j}=x1(N,L,_,C,F,D,Q);j&&(m1(L,_,{nodeOrigin:F,nodeExtent:D,zIndexMode:Q}),Y?(k(),x({fitViewQueued:!1,fitViewOptions:void 0})):x({}),(ne==null?void 0:ne.length)>0&&(O&&console.log("React Flow: trigger node changes",ne),E==null||E(ne)))},updateNodePositions:(N,E=!1)=>{const L=[];let _=[];const{nodeLookup:C,triggerNodeChanges:F,connection:D,updateConnection:O,onNodesChangeMiddlewareMap:Y}=S();for(const[Q,ne]of N){const j=C.get(Q),U=!!(j!=null&&j.expandParent&&(j!=null&&j.parentId)&&(ne!=null&&ne.position)),b={id:Q,type:"position",position:U?{x:Math.max(0,ne.position.x),y:Math.max(0,ne.position.y)}:ne.position,dragging:E};if(j&&D.inProgress&&D.fromNode.id===j.id){const z=dr(j,D.fromHandle,ye.Left,!0);O({...D,from:z})}U&&j.parentId&&L.push({id:Q,parentId:j.parentId,rect:{...ne.internals.positionAbsolute,width:ne.measured.width??0,height:ne.measured.height??0}}),_.push(b)}if(L.length>0){const{parentLookup:Q,nodeOrigin:ne}=S(),j=tc(L,C,Q,ne);_.push(...j)}for(const Q of Y.values())_=Q(_);F(_)},triggerNodeChanges:N=>{const{onNodesChange:E,setNodes:L,nodes:_,hasDefaultNodes:C,debug:F}=S();if(N!=null&&N.length){if(C){const D=qp(N,_);L(D)}F&&console.log("React Flow: trigger node changes",N),E==null||E(N)}},triggerEdgeChanges:N=>{const{onEdgesChange:E,setEdges:L,edges:_,hasDefaultEdges:C,debug:F}=S();if(N!=null&&N.length){if(C){const D=bp(N,_);L(D)}F&&console.log("React Flow: trigger edge changes",N),E==null||E(N)}},addSelectedNodes:N=>{const{multiSelectionActive:E,edgeLookup:L,nodeLookup:_,triggerNodeChanges:C,triggerEdgeChanges:F}=S();if(E){const D=N.map(O=>ir(O,!0));C(D);return}C(Yr(_,new Set([...N]),!0)),F(Yr(L))},addSelectedEdges:N=>{const{multiSelectionActive:E,edgeLookup:L,nodeLookup:_,triggerNodeChanges:C,triggerEdgeChanges:F}=S();if(E){const D=N.map(O=>ir(O,!0));F(D);return}F(Yr(L,new Set([...N]))),C(Yr(_,new Set,!0))},unselectNodesAndEdges:({nodes:N,edges:E}={})=>{const{edges:L,nodes:_,nodeLookup:C,triggerNodeChanges:F,triggerEdgeChanges:D}=S(),O=N||_,Y=E||L,Q=[];for(const j of O){if(!j.selected)continue;const U=C.get(j.id);U&&(U.selected=!1),Q.push(ir(j.id,!1))}const ne=[];for(const j of Y)j.selected&&ne.push(ir(j.id,!1));F(Q),D(ne)},setMinZoom:N=>{const{panZoom:E,maxZoom:L}=S();E==null||E.setScaleExtent([N,L]),x({minZoom:N})},setMaxZoom:N=>{const{panZoom:E,minZoom:L}=S();E==null||E.setScaleExtent([L,N]),x({maxZoom:N})},setTranslateExtent:N=>{var E;(E=S().panZoom)==null||E.setTranslateExtent(N),x({translateExtent:N})},resetSelectedElements:()=>{const{edges:N,nodes:E,triggerNodeChanges:L,triggerEdgeChanges:_,elementsSelectable:C}=S();if(!C)return;const F=E.reduce((O,Y)=>Y.selected?[...O,ir(Y.id,!1)]:O,[]),D=N.reduce((O,Y)=>Y.selected?[...O,ir(Y.id,!1)]:O,[]);L(F),_(D)},setNodeExtent:N=>{const{nodes:E,nodeLookup:L,parentLookup:_,nodeOrigin:C,elevateNodesOnSelect:F,nodeExtent:D,zIndexMode:O}=S();N[0][0]===D[0][0]&&N[0][1]===D[0][1]&&N[1][0]===D[1][0]&&N[1][1]===D[1][1]||(Fa(E,L,_,{nodeOrigin:C,nodeExtent:N,elevateNodesOnSelect:F,checkEquality:!1,zIndexMode:O}),x({nodeExtent:N}))},panBy:N=>{const{transform:E,width:L,height:_,panZoom:C,translateExtent:F}=S();return S1({delta:N,panZoom:C,transform:E,translateExtent:F,width:L,height:_})},setCenter:async(N,E,L)=>{const{width:_,height:C,maxZoom:F,panZoom:D}=S();if(!D)return Promise.resolve(!1);const O=typeof(L==null?void 0:L.zoom)<"u"?L.zoom:F;return await D.setViewport({x:_/2-N*O,y:C/2-E*O,zoom:O},{duration:L==null?void 0:L.duration,ease:L==null?void 0:L.ease,interpolate:L==null?void 0:L.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{x({connection:{...vp}})},updateConnection:N=>{x({connection:N})},reset:()=>x({...Oh()})}},Object.is);function jS({initialNodes:n,initialEdges:o,defaultNodes:i,defaultEdges:s,initialWidth:u,initialHeight:c,initialMinZoom:f,initialMaxZoom:h,initialFitViewOptions:p,fitView:m,nodeOrigin:v,nodeExtent:g,zIndexMode:y,children:x}){const[S]=q.useState(()=>VS({nodes:n,edges:o,defaultNodes:i,defaultEdges:s,width:u,height:c,fitView:m,minZoom:f,maxZoom:h,fitViewOptions:p,nodeOrigin:v,nodeExtent:g,zIndexMode:y}));return K.jsx(ix,{value:S,children:K.jsx(Px,{children:x})})}function BS({children:n,nodes:o,edges:i,defaultNodes:s,defaultEdges:u,width:c,height:f,fitView:h,fitViewOptions:p,minZoom:m,maxZoom:v,nodeOrigin:g,nodeExtent:y,zIndexMode:x}){return q.useContext(hs)?K.jsx(K.Fragment,{children:n}):K.jsx(jS,{initialNodes:o,initialEdges:i,defaultNodes:s,defaultEdges:u,initialWidth:c,initialHeight:f,fitView:h,initialFitViewOptions:p,initialMinZoom:m,initialMaxZoom:v,nodeOrigin:g,nodeExtent:y,zIndexMode:x,children:n})}const US={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function WS({nodes:n,edges:o,defaultNodes:i,defaultEdges:s,className:u,nodeTypes:c,edgeTypes:f,onNodeClick:h,onEdgeClick:p,onInit:m,onMove:v,onMoveStart:g,onMoveEnd:y,onConnect:x,onConnectStart:S,onConnectEnd:k,onClickConnectStart:N,onClickConnectEnd:E,onNodeMouseEnter:L,onNodeMouseMove:_,onNodeMouseLeave:C,onNodeContextMenu:F,onNodeDoubleClick:D,onNodeDragStart:O,onNodeDrag:Y,onNodeDragStop:Q,onNodesDelete:ne,onEdgesDelete:j,onDelete:U,onSelectionChange:b,onSelectionDragStart:z,onSelectionDrag:B,onSelectionDragStop:R,onSelectionContextMenu:W,onSelectionStart:P,onSelectionEnd:I,onBeforeDelete:$,connectionMode:Z,connectionLineType:G=Fn.Bezier,connectionLineStyle:le,connectionLineComponent:ie,connectionLineContainerStyle:he,deleteKeyCode:fe="Backspace",selectionKeyCode:pe="Shift",selectionOnDrag:oe=!1,selectionMode:me=oi.Full,panActivationKeyCode:Ee="Space",multiSelectionKeyCode:Se=li()?"Meta":"Control",zoomActivationKeyCode:xe=li()?"Meta":"Control",snapToGrid:ge,snapGrid:ke,onlyRenderVisibleElements:Ie=!1,selectNodesOnDrag:Ne,nodesDraggable:Be,autoPanOnNodeFocus:Pt,nodesConnectable:ft,nodesFocusable:dt,nodeOrigin:xt=Gp,edgesFocusable:Zt,edgesReconnectable:hn,elementsSelectable:pr=!0,defaultViewport:Hn=vx,minZoom:qt=.5,maxZoom:bt=2,translateExtent:Vn=ri,preventScrolling:pi=!0,nodeExtent:Jt,defaultMarkerColor:jn="#b1b1b7",zoomOnScroll:ys=!0,zoomOnPinch:gi=!0,panOnScroll:mi=!1,panOnScrollSpeed:vs=.5,panOnScrollMode:to=ur.Free,zoomOnDoubleClick:no=!0,panOnDrag:ro=!0,onPaneClick:oo,onPaneMouseEnter:io,onPaneMouseMove:pn,onPaneMouseLeave:gn,onPaneScroll:yi,onPaneContextMenu:vi,paneClickDistance:wi=1,nodeClickDistance:xi=0,children:Si,onReconnect:lo,onReconnectStart:_i,onReconnectEnd:Bn,onEdgeContextMenu:so,onEdgeDoubleClick:Un,onEdgeMouseEnter:ws,onEdgeMouseMove:Wn,onEdgeMouseLeave:gr,reconnectRadius:mr=10,onNodesChange:uo,onEdgesChange:xs,noDragClassName:Ss="nodrag",noWheelClassName:_s="nowheel",noPanClassName:Vt="nopan",fitView:ao,fitViewOptions:co,connectOnClick:Es,attributionPosition:Ei,proOptions:ki,defaultEdgeOptions:Ni,elevateNodesOnSelect:Ci=!0,elevateEdgesOnSelect:ks=!1,disableKeyboardA11y:Mi=!1,autoPanOnConnect:Fe,autoPanOnNodeDrag:Ns,autoPanSpeed:fo,connectionRadius:Pi,isValidConnection:yr,onError:Cs,style:zi,id:Xn,nodeDragThreshold:St,connectionDragThreshold:Ms,viewport:ht,onViewportChange:Ps,width:zs,height:Is,colorMode:vr="light",debug:wr,onScroll:jt,ariaLabelConfig:xr,zIndexMode:Ii="basic",...Ts},ho){const Sr=Xn||"1",po=_x(vr),Yn=q.useCallback(Ti=>{Ti.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),jt==null||jt(Ti)},[jt]);return K.jsx("div",{"data-testid":"rf__wrapper",...Ts,onScroll:Yn,style:{...zi,...US},ref:ho,className:We(["react-flow",u,po]),id:Xn,role:"application",children:K.jsxs(BS,{nodes:n,edges:o,width:zs,height:Is,fitView:ao,fitViewOptions:co,minZoom:qt,maxZoom:bt,nodeOrigin:xt,nodeExtent:Jt,zIndexMode:Ii,children:[K.jsx(HS,{onInit:m,onNodeClick:h,onEdgeClick:p,onNodeMouseEnter:L,onNodeMouseMove:_,onNodeMouseLeave:C,onNodeContextMenu:F,onNodeDoubleClick:D,nodeTypes:c,edgeTypes:f,connectionLineType:G,connectionLineStyle:le,connectionLineComponent:ie,connectionLineContainerStyle:he,selectionKeyCode:pe,selectionOnDrag:oe,selectionMode:me,deleteKeyCode:fe,multiSelectionKeyCode:Se,panActivationKeyCode:Ee,zoomActivationKeyCode:xe,onlyRenderVisibleElements:Ie,defaultViewport:Hn,translateExtent:Vn,minZoom:qt,maxZoom:bt,preventScrolling:pi,zoomOnScroll:ys,zoomOnPinch:gi,zoomOnDoubleClick:no,panOnScroll:mi,panOnScrollSpeed:vs,panOnScrollMode:to,panOnDrag:ro,onPaneClick:oo,onPaneMouseEnter:io,onPaneMouseMove:pn,onPaneMouseLeave:gn,onPaneScroll:yi,onPaneContextMenu:vi,paneClickDistance:wi,nodeClickDistance:xi,onSelectionContextMenu:W,onSelectionStart:P,onSelectionEnd:I,onReconnect:lo,onReconnectStart:_i,onReconnectEnd:Bn,onEdgeContextMenu:so,onEdgeDoubleClick:Un,onEdgeMouseEnter:ws,onEdgeMouseMove:Wn,onEdgeMouseLeave:gr,reconnectRadius:mr,defaultMarkerColor:jn,noDragClassName:Ss,noWheelClassName:_s,noPanClassName:Vt,rfId:Sr,disableKeyboardA11y:Mi,nodeExtent:Jt,viewport:ht,onViewportChange:Ps}),K.jsx(Sx,{nodes:n,edges:o,defaultNodes:i,defaultEdges:s,onConnect:x,onConnectStart:S,onConnectEnd:k,onClickConnectStart:N,onClickConnectEnd:E,nodesDraggable:Be,autoPanOnNodeFocus:Pt,nodesConnectable:ft,nodesFocusable:dt,edgesFocusable:Zt,edgesReconnectable:hn,elementsSelectable:pr,elevateNodesOnSelect:Ci,elevateEdgesOnSelect:ks,minZoom:qt,maxZoom:bt,nodeExtent:Jt,onNodesChange:uo,onEdgesChange:xs,snapToGrid:ge,snapGrid:ke,connectionMode:Z,translateExtent:Vn,connectOnClick:Es,defaultEdgeOptions:Ni,fitView:ao,fitViewOptions:co,onNodesDelete:ne,onEdgesDelete:j,onDelete:U,onNodeDragStart:O,onNodeDrag:Y,onNodeDragStop:Q,onSelectionDrag:B,onSelectionDragStart:z,onSelectionDragStop:R,onMove:v,onMoveStart:g,onMoveEnd:y,noPanClassName:Vt,nodeOrigin:xt,rfId:Sr,autoPanOnConnect:Fe,autoPanOnNodeDrag:Ns,autoPanSpeed:fo,onError:Cs,connectionRadius:Pi,isValidConnection:yr,selectNodesOnDrag:Ne,nodeDragThreshold:St,connectionDragThreshold:Ms,onBeforeDelete:$,debug:wr,ariaLabelConfig:xr,zIndexMode:Ii}),K.jsx(yx,{onSelectionChange:b}),Si,K.jsx(dx,{proOptions:ki,position:Ei}),K.jsx(fx,{rfId:Sr,disableKeyboardA11y:Mi})]})})}var v_=Jp(WS);const XS=n=>{var o;return(o=n.domNode)==null?void 0:o.querySelector(".react-flow__edgelabel-renderer")};function w_({children:n}){const o=Ce(XS);return o?dm.createPortal(n,o):null}function x_(n){const[o,i]=q.useState(n),s=q.useCallback(u=>i(c=>qp(u,c)),[]);return[o,i,s]}function S_(n){const[o,i]=q.useState(n),s=q.useCallback(u=>i(c=>bp(u,c)),[]);return[o,i,s]}function YS({dimensions:n,lineWidth:o,variant:i,className:s}){return K.jsx("path",{strokeWidth:o,d:`M${n[0]/2} 0 V${n[1]} M0 ${n[1]/2} H${n[0]}`,className:We(["react-flow__background-pattern",i,s])})}function QS({radius:n,className:o}){return K.jsx("circle",{cx:n,cy:n,r:n,className:We(["react-flow__background-pattern","dots",o])})}var On;(function(n){n.Lines="lines",n.Dots="dots",n.Cross="cross"})(On||(On={}));const KS={[On.Dots]:1,[On.Lines]:1,[On.Cross]:6},GS=n=>({transform:n.transform,patternId:`pattern-${n.rfId}`});function Eg({id:n,variant:o=On.Dots,gap:i=20,size:s,lineWidth:u=1,offset:c=0,color:f,bgColor:h,style:p,className:m,patternClassName:v}){const g=q.useRef(null),{transform:y,patternId:x}=Ce(GS,Re),S=s||KS[o],k=o===On.Dots,N=o===On.Cross,E=Array.isArray(i)?i:[i,i],L=[E[0]*y[2]||1,E[1]*y[2]||1],_=S*y[2],C=Array.isArray(c)?c:[c,c],F=N?[_,_]:L,D=[C[0]*y[2]||1+F[0]/2,C[1]*y[2]||1+F[1]/2],O=`${x}${n||""}`;return K.jsxs("svg",{className:We(["react-flow__background",m]),style:{...p,...gs,"--xy-background-color-props":h,"--xy-background-pattern-color-props":f},ref:g,"data-testid":"rf__background",children:[K.jsx("pattern",{id:O,x:y[0]%L[0],y:y[1]%L[1],width:L[0],height:L[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${D[0]},-${D[1]})`,children:k?K.jsx(QS,{radius:_/2,className:v}):K.jsx(YS,{dimensions:F,lineWidth:u,variant:o,className:v})}),K.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${O})`})]})}Eg.displayName="Background";const __=q.memo(Eg);function ZS(){return K.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:K.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function qS(){return K.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:K.jsx("path",{d:"M0 0h32v4.2H0z"})})}function bS(){return K.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:K.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function JS(){return K.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:K.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function e_(){return K.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:K.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function Vl({children:n,className:o,...i}){return K.jsx("button",{type:"button",className:We(["react-flow__controls-button",o]),...i,children:n})}const t_=n=>({isInteractive:n.nodesDraggable||n.nodesConnectable||n.elementsSelectable,minZoomReached:n.transform[2]<=n.minZoom,maxZoomReached:n.transform[2]>=n.maxZoom,ariaLabelConfig:n.ariaLabelConfig});function kg({style:n,showZoom:o=!0,showFitView:i=!0,showInteractive:s=!0,fitViewOptions:u,onZoomIn:c,onZoomOut:f,onFitView:h,onInteractiveChange:p,className:m,children:v,position:g="bottom-left",orientation:y="vertical","aria-label":x}){const S=$e(),{isInteractive:k,minZoomReached:N,maxZoomReached:E,ariaLabelConfig:L}=Ce(t_,Re),{zoomIn:_,zoomOut:C,fitView:F}=nc(),D=()=>{_(),c==null||c()},O=()=>{C(),f==null||f()},Y=()=>{F(u),h==null||h()},Q=()=>{S.setState({nodesDraggable:!k,nodesConnectable:!k,elementsSelectable:!k}),p==null||p(!k)},ne=y==="horizontal"?"horizontal":"vertical";return K.jsxs(ps,{className:We(["react-flow__controls",ne,m]),position:g,style:n,"data-testid":"rf__controls","aria-label":x??L["controls.ariaLabel"],children:[o&&K.jsxs(K.Fragment,{children:[K.jsx(Vl,{onClick:D,className:"react-flow__controls-zoomin",title:L["controls.zoomIn.ariaLabel"],"aria-label":L["controls.zoomIn.ariaLabel"],disabled:E,children:K.jsx(ZS,{})}),K.jsx(Vl,{onClick:O,className:"react-flow__controls-zoomout",title:L["controls.zoomOut.ariaLabel"],"aria-label":L["controls.zoomOut.ariaLabel"],disabled:N,children:K.jsx(qS,{})})]}),i&&K.jsx(Vl,{className:"react-flow__controls-fitview",onClick:Y,title:L["controls.fitView.ariaLabel"],"aria-label":L["controls.fitView.ariaLabel"],children:K.jsx(bS,{})}),s&&K.jsx(Vl,{className:"react-flow__controls-interactive",onClick:Q,title:L["controls.interactive.ariaLabel"],"aria-label":L["controls.interactive.ariaLabel"],children:k?K.jsx(e_,{}):K.jsx(JS,{})}),v]})}kg.displayName="Controls";const E_=q.memo(kg);function n_({id:n,x:o,y:i,width:s,height:u,style:c,color:f,strokeColor:h,strokeWidth:p,className:m,borderRadius:v,shapeRendering:g,selected:y,onClick:x}){const{background:S,backgroundColor:k}=c||{},N=f||S||k;return K.jsx("rect",{className:We(["react-flow__minimap-node",{selected:y},m]),x:o,y:i,rx:v,ry:v,width:s,height:u,style:{fill:N,stroke:h,strokeWidth:p},shapeRendering:g,onClick:x?E=>x(E,n):void 0})}const r_=q.memo(n_),o_=n=>n.nodes.map(o=>o.id),Na=n=>n instanceof Function?n:()=>n;function i_({nodeStrokeColor:n,nodeColor:o,nodeClassName:i="",nodeBorderRadius:s=5,nodeStrokeWidth:u,nodeComponent:c=r_,onClick:f}){const h=Ce(o_,Re),p=Na(o),m=Na(n),v=Na(i),g=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return K.jsx(K.Fragment,{children:h.map(y=>K.jsx(s_,{id:y,nodeColorFunc:p,nodeStrokeColorFunc:m,nodeClassNameFunc:v,nodeBorderRadius:s,nodeStrokeWidth:u,NodeComponent:c,onClick:f,shapeRendering:g},y))})}function l_({id:n,nodeColorFunc:o,nodeStrokeColorFunc:i,nodeClassNameFunc:s,nodeBorderRadius:u,nodeStrokeWidth:c,shapeRendering:f,NodeComponent:h,onClick:p}){const{node:m,x:v,y:g,width:y,height:x}=Ce(S=>{const k=S.nodeLookup.get(n);if(!k)return{node:void 0,x:0,y:0,width:0,height:0};const N=k.internals.userNode,{x:E,y:L}=k.internals.positionAbsolute,{width:_,height:C}=dn(N);return{node:N,x:E,y:L,width:_,height:C}},Re);return!m||m.hidden||!Np(m)?null:K.jsx(h,{x:v,y:g,width:y,height:x,style:m.style,selected:!!m.selected,className:s(m),color:o(m),borderRadius:u,strokeColor:i(m),strokeWidth:c,shapeRendering:f,onClick:p,id:m.id})}const s_=q.memo(l_);var u_=q.memo(i_);const a_=200,c_=150,f_=n=>!n.hidden,d_=n=>{const o={x:-n.transform[0]/n.transform[2],y:-n.transform[1]/n.transform[2],width:n.width/n.transform[2],height:n.height/n.transform[2]};return{viewBB:o,boundingRect:n.nodeLookup.size>0?kp(fi(n.nodeLookup,{filter:f_}),o):o,rfId:n.rfId,panZoom:n.panZoom,translateExtent:n.translateExtent,flowWidth:n.width,flowHeight:n.height,ariaLabelConfig:n.ariaLabelConfig}},h_="react-flow__minimap-desc";function Ng({style:n,className:o,nodeStrokeColor:i,nodeColor:s,nodeClassName:u="",nodeBorderRadius:c=5,nodeStrokeWidth:f,nodeComponent:h,bgColor:p,maskColor:m,maskStrokeColor:v,maskStrokeWidth:g,position:y="bottom-right",onClick:x,onNodeClick:S,pannable:k=!1,zoomable:N=!1,ariaLabel:E,inversePan:L,zoomStep:_=1,offsetScale:C=5}){const F=$e(),D=q.useRef(null),{boundingRect:O,viewBB:Y,rfId:Q,panZoom:ne,translateExtent:j,flowWidth:U,flowHeight:b,ariaLabelConfig:z}=Ce(d_,Re),B=(n==null?void 0:n.width)??a_,R=(n==null?void 0:n.height)??c_,W=O.width/B,P=O.height/R,I=Math.max(W,P),$=I*B,Z=I*R,G=C*I,le=O.x-($-O.width)/2-G,ie=O.y-(Z-O.height)/2-G,he=$+G*2,fe=Z+G*2,pe=`${h_}-${Q}`,oe=q.useRef(0),me=q.useRef();oe.current=I,q.useEffect(()=>{if(D.current&&ne)return me.current=I1({domNode:D.current,panZoom:ne,getTransform:()=>F.getState().transform,getViewScale:()=>oe.current}),()=>{var ge;(ge=me.current)==null||ge.destroy()}},[ne]),q.useEffect(()=>{var ge;(ge=me.current)==null||ge.update({translateExtent:j,width:U,height:b,inversePan:L,pannable:k,zoomStep:_,zoomable:N})},[k,N,L,_,j,U,b]);const Ee=x?ge=>{var Ne;const[ke,Ie]=((Ne=me.current)==null?void 0:Ne.pointer(ge))||[0,0];x(ge,{x:ke,y:Ie})}:void 0,Se=S?q.useCallback((ge,ke)=>{const Ie=F.getState().nodeLookup.get(ke).internals.userNode;S(ge,Ie)},[]):void 0,xe=E??z["minimap.ariaLabel"];return K.jsx(ps,{position:y,style:{...n,"--xy-minimap-background-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-background-color-props":typeof m=="string"?m:void 0,"--xy-minimap-mask-stroke-color-props":typeof v=="string"?v:void 0,"--xy-minimap-mask-stroke-width-props":typeof g=="number"?g*I:void 0,"--xy-minimap-node-background-color-props":typeof s=="string"?s:void 0,"--xy-minimap-node-stroke-color-props":typeof i=="string"?i:void 0,"--xy-minimap-node-stroke-width-props":typeof f=="number"?f:void 0},className:We(["react-flow__minimap",o]),"data-testid":"rf__minimap",children:K.jsxs("svg",{width:B,height:R,viewBox:`${le} ${ie} ${he} ${fe}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":pe,ref:D,onClick:Ee,children:[xe&&K.jsx("title",{id:pe,children:xe}),K.jsx(u_,{onClick:Se,nodeColor:s,nodeStrokeColor:i,nodeBorderRadius:c,nodeClassName:u,nodeStrokeWidth:f,nodeComponent:h}),K.jsx("path",{className:"react-flow__minimap-mask",d:`M${le-G},${ie-G}h${he+G*2}v${fe+G*2}h${-he-G*2}z
|
|
54
|
-
M${Y.x},${Y.y}h${Y.width}v${Y.height}h${-Y.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}Ng.displayName="MiniMap";const k_=q.memo(Ng),p_=n=>o=>n?`${Math.max(1/o.transform[2],1)}`:void 0,g_={[hr.Line]:"right",[hr.Handle]:"bottom-right"};function m_({nodeId:n,position:o,variant:i=hr.Handle,className:s,style:u=void 0,children:c,color:f,minWidth:h=10,minHeight:p=10,maxWidth:m=Number.MAX_VALUE,maxHeight:v=Number.MAX_VALUE,keepAspectRatio:g=!1,resizeDirection:y,autoScale:x=!0,shouldResize:S,onResizeStart:k,onResize:N,onResizeEnd:E}){const L=rg(),_=typeof n=="string"?n:L,C=$e(),F=q.useRef(null),D=i===hr.Handle,O=Ce(q.useCallback(p_(D&&x),[D,x]),Re),Y=q.useRef(null),Q=o??g_[i];q.useEffect(()=>{if(!(!F.current||!_))return Y.current||(Y.current=Y1({domNode:F.current,nodeId:_,getStoreItems:()=>{const{nodeLookup:j,transform:U,snapGrid:b,snapToGrid:z,nodeOrigin:B,domNode:R}=C.getState();return{nodeLookup:j,transform:U,snapGrid:b,snapToGrid:z,nodeOrigin:B,paneDomNode:R}},onChange:(j,U)=>{const{triggerNodeChanges:b,nodeLookup:z,parentLookup:B,nodeOrigin:R}=C.getState(),W=[],P={x:j.x,y:j.y},I=z.get(_);if(I&&I.expandParent&&I.parentId){const $=I.origin??R,Z=j.width??I.measured.width??0,G=j.height??I.measured.height??0,le={id:I.id,parentId:I.parentId,rect:{width:Z,height:G,...Cp({x:j.x??I.position.x,y:j.y??I.position.y},{width:Z,height:G},I.parentId,z,$)}},ie=tc([le],z,B,R);W.push(...ie),P.x=j.x?Math.max($[0]*Z,j.x):void 0,P.y=j.y?Math.max($[1]*G,j.y):void 0}if(P.x!==void 0&&P.y!==void 0){const $={id:_,type:"position",position:{...P}};W.push($)}if(j.width!==void 0&&j.height!==void 0){const Z={id:_,type:"dimensions",resizing:!0,setAttributes:y?y==="horizontal"?"width":"height":!0,dimensions:{width:j.width,height:j.height}};W.push(Z)}for(const $ of U){const Z={...$,type:"position"};W.push(Z)}b(W)},onEnd:({width:j,height:U})=>{const b={id:_,type:"dimensions",resizing:!1,dimensions:{width:j,height:U}};C.getState().triggerNodeChanges([b])}})),Y.current.update({controlPosition:Q,boundaries:{minWidth:h,minHeight:p,maxWidth:m,maxHeight:v},keepAspectRatio:g,resizeDirection:y,onResizeStart:k,onResize:N,onResizeEnd:E,shouldResize:S}),()=>{var j;(j=Y.current)==null||j.destroy()}},[Q,h,p,m,v,g,k,N,E,S]);const ne=Q.split("-");return K.jsx("div",{className:We(["react-flow__resize-control","nodrag",...ne,i,s]),ref:F,style:{...u,scale:O,...f&&{[D?"backgroundColor":"borderColor"]:f}},children:c})}const Hh=q.memo(m_);function N_({nodeId:n,isVisible:o=!0,handleClassName:i,handleStyle:s,lineClassName:u,lineStyle:c,color:f,minWidth:h=10,minHeight:p=10,maxWidth:m=Number.MAX_VALUE,maxHeight:v=Number.MAX_VALUE,keepAspectRatio:g=!1,autoScale:y=!0,shouldResize:x,onResizeStart:S,onResize:k,onResizeEnd:N}){return o?K.jsxs(K.Fragment,{children:[V1.map(E=>K.jsx(Hh,{className:u,style:c,nodeId:n,position:E,variant:hr.Line,color:f,minWidth:h,minHeight:p,maxWidth:m,maxHeight:v,onResizeStart:S,keepAspectRatio:g,autoScale:y,shouldResize:x,onResize:k,onResizeEnd:N},E)),H1.map(E=>K.jsx(Hh,{className:i,style:s,nodeId:n,position:E,color:f,minWidth:h,minHeight:p,maxWidth:m,maxHeight:v,onResizeStart:S,keepAspectRatio:g,autoScale:y,shouldResize:x,onResize:k,onResizeEnd:N},E))]}):null}export{ms as B,qr as C,w_ as E,ns as H,k_ as M,N_ as N,ye as P,jS as R,
|
|
54
|
+
M${Y.x},${Y.y}h${Y.width}v${Y.height}h${-Y.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}Ng.displayName="MiniMap";const k_=q.memo(Ng),p_=n=>o=>n?`${Math.max(1/o.transform[2],1)}`:void 0,g_={[hr.Line]:"right",[hr.Handle]:"bottom-right"};function m_({nodeId:n,position:o,variant:i=hr.Handle,className:s,style:u=void 0,children:c,color:f,minWidth:h=10,minHeight:p=10,maxWidth:m=Number.MAX_VALUE,maxHeight:v=Number.MAX_VALUE,keepAspectRatio:g=!1,resizeDirection:y,autoScale:x=!0,shouldResize:S,onResizeStart:k,onResize:N,onResizeEnd:E}){const L=rg(),_=typeof n=="string"?n:L,C=$e(),F=q.useRef(null),D=i===hr.Handle,O=Ce(q.useCallback(p_(D&&x),[D,x]),Re),Y=q.useRef(null),Q=o??g_[i];q.useEffect(()=>{if(!(!F.current||!_))return Y.current||(Y.current=Y1({domNode:F.current,nodeId:_,getStoreItems:()=>{const{nodeLookup:j,transform:U,snapGrid:b,snapToGrid:z,nodeOrigin:B,domNode:R}=C.getState();return{nodeLookup:j,transform:U,snapGrid:b,snapToGrid:z,nodeOrigin:B,paneDomNode:R}},onChange:(j,U)=>{const{triggerNodeChanges:b,nodeLookup:z,parentLookup:B,nodeOrigin:R}=C.getState(),W=[],P={x:j.x,y:j.y},I=z.get(_);if(I&&I.expandParent&&I.parentId){const $=I.origin??R,Z=j.width??I.measured.width??0,G=j.height??I.measured.height??0,le={id:I.id,parentId:I.parentId,rect:{width:Z,height:G,...Cp({x:j.x??I.position.x,y:j.y??I.position.y},{width:Z,height:G},I.parentId,z,$)}},ie=tc([le],z,B,R);W.push(...ie),P.x=j.x?Math.max($[0]*Z,j.x):void 0,P.y=j.y?Math.max($[1]*G,j.y):void 0}if(P.x!==void 0&&P.y!==void 0){const $={id:_,type:"position",position:{...P}};W.push($)}if(j.width!==void 0&&j.height!==void 0){const Z={id:_,type:"dimensions",resizing:!0,setAttributes:y?y==="horizontal"?"width":"height":!0,dimensions:{width:j.width,height:j.height}};W.push(Z)}for(const $ of U){const Z={...$,type:"position"};W.push(Z)}b(W)},onEnd:({width:j,height:U})=>{const b={id:_,type:"dimensions",resizing:!1,dimensions:{width:j,height:U}};C.getState().triggerNodeChanges([b])}})),Y.current.update({controlPosition:Q,boundaries:{minWidth:h,minHeight:p,maxWidth:m,maxHeight:v},keepAspectRatio:g,resizeDirection:y,onResizeStart:k,onResize:N,onResizeEnd:E,shouldResize:S}),()=>{var j;(j=Y.current)==null||j.destroy()}},[Q,h,p,m,v,g,k,N,E,S]);const ne=Q.split("-");return K.jsx("div",{className:We(["react-flow__resize-control","nodrag",...ne,i,s]),ref:F,style:{...u,scale:O,...f&&{[D?"backgroundColor":"borderColor"]:f}},children:c})}const Hh=q.memo(m_);function N_({nodeId:n,isVisible:o=!0,handleClassName:i,handleStyle:s,lineClassName:u,lineStyle:c,color:f,minWidth:h=10,minHeight:p=10,maxWidth:m=Number.MAX_VALUE,maxHeight:v=Number.MAX_VALUE,keepAspectRatio:g=!1,autoScale:y=!0,shouldResize:x,onResizeStart:S,onResize:k,onResizeEnd:N}){return o?K.jsxs(K.Fragment,{children:[V1.map(E=>K.jsx(Hh,{className:u,style:c,nodeId:n,position:E,variant:hr.Line,color:f,minWidth:h,minHeight:p,maxWidth:m,maxHeight:v,onResizeStart:S,keepAspectRatio:g,autoScale:y,shouldResize:x,onResize:k,onResizeEnd:N},E)),H1.map(E=>K.jsx(Hh,{className:i,style:s,nodeId:n,position:E,color:f,minWidth:h,minHeight:p,maxWidth:m,maxHeight:v,onResizeStart:S,keepAspectRatio:g,autoScale:y,shouldResize:x,onResize:k,onResizeEnd:N},E))]}):null}export{ms as B,qr as C,w_ as E,ns as H,k_ as M,N_ as N,ye as P,jS as R,nc as a,x_ as b,S_ as c,u1 as d,qp as e,__ as f,E_ as g,v_ as i,K as j,fm as r,Ce as u};
|
package/dist/index.html
CHANGED
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
9
9
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
10
10
|
<link href="https://fonts.googleapis.com/css2?family=Nunito:wght@700;800;900&display=swap" rel="stylesheet">
|
|
11
|
-
<script type="module" crossorigin src="/assets/index-
|
|
11
|
+
<script type="module" crossorigin src="/assets/index-D0i9ua6F.js"></script>
|
|
12
12
|
<link rel="modulepreload" crossorigin href="/assets/zustand-qbFpP9Up.js">
|
|
13
|
-
<link rel="modulepreload" crossorigin href="/assets/reactflow-
|
|
14
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
13
|
+
<link rel="modulepreload" crossorigin href="/assets/reactflow-CX-HDacK.js">
|
|
14
|
+
<link rel="stylesheet" crossorigin href="/assets/index-DPzXL4uF.css">
|
|
15
15
|
</head>
|
|
16
16
|
<body>
|
|
17
17
|
<div id="root"></div>
|
|
@@ -2,18 +2,54 @@
|
|
|
2
2
|
import { Command } from 'commander';
|
|
3
3
|
import { architectBuildCommand } from '../commands/build.js';
|
|
4
4
|
import { architectDevCommand } from '../commands/dev.js';
|
|
5
|
+
import { architectExampleCommand } from '../commands/example.js';
|
|
5
6
|
const program = new Command();
|
|
6
7
|
program
|
|
7
8
|
.name('memo-architect')
|
|
8
9
|
.description('MEMO Architect — interactive and distributable model workbench')
|
|
9
|
-
.version('0.
|
|
10
|
+
.version('0.6.2')
|
|
11
|
+
.option('--example <name>', 'Open a bundled example project (e.g. gpca, standard-sysml-diagrams). A local checkout is opened in place; an installed package is opened read-only in a disposable copy')
|
|
12
|
+
.option('--read-only', 'Always open the example in a disposable copy, even from a local checkout')
|
|
13
|
+
.option('-p, --port <port>', 'Server port', '3000')
|
|
14
|
+
.option('--no-open', 'Do not open a browser')
|
|
15
|
+
.action(async (options) => {
|
|
16
|
+
if (options.example) {
|
|
17
|
+
await architectExampleCommand({
|
|
18
|
+
name: options.example,
|
|
19
|
+
port: Number.parseInt(options.port, 10),
|
|
20
|
+
open: options.open,
|
|
21
|
+
readOnly: options.readOnly,
|
|
22
|
+
});
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
program.help();
|
|
26
|
+
});
|
|
27
|
+
/**
|
|
28
|
+
* Read an option that is declared on both this command and its parent.
|
|
29
|
+
*
|
|
30
|
+
* `-p, --port` and `--no-open` exist on the program so `--example` can take
|
|
31
|
+
* them, and on `dev` so it can too. Commander binds the flag on the command
|
|
32
|
+
* line to the program-level declaration, leaving the subcommand holding its
|
|
33
|
+
* own default — which silently pinned `dev --port` to 3000. Prefer whichever
|
|
34
|
+
* declaration the user actually set, falling back to the local default.
|
|
35
|
+
*/
|
|
36
|
+
function resolveOption(command, name, local) {
|
|
37
|
+
if (command.getOptionValueSource(name) === 'cli')
|
|
38
|
+
return local;
|
|
39
|
+
const parent = command.parent;
|
|
40
|
+
if (parent?.getOptionValueSource(name) === 'cli')
|
|
41
|
+
return parent.opts()[name];
|
|
42
|
+
return local;
|
|
43
|
+
}
|
|
10
44
|
program
|
|
11
45
|
.command('dev')
|
|
12
46
|
.description('Start Architect with live model reload')
|
|
13
47
|
.option('-p, --port <port>', 'Server port', '3000')
|
|
14
48
|
.option('--no-open', 'Do not open a browser')
|
|
15
|
-
.action(async (options)
|
|
16
|
-
|
|
49
|
+
.action(async function (options) {
|
|
50
|
+
const port = resolveOption(this, 'port', options.port);
|
|
51
|
+
const open = resolveOption(this, 'open', options.open);
|
|
52
|
+
await architectDevCommand({ port: Number.parseInt(String(port), 10), open });
|
|
17
53
|
});
|
|
18
54
|
program
|
|
19
55
|
.command('build')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memo-architect.js","sourceRoot":"","sources":["../../src/bin/memo-architect.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"memo-architect.js","sourceRoot":"","sources":["../../src/bin/memo-architect.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACF,IAAI,CAAC,gBAAgB,CAAC;KACtB,WAAW,CAAC,gEAAgE,CAAC;KAC7E,OAAO,CAAC,OAAO,CAAC;KAChB,MAAM,CAAC,kBAAkB,EAAE,yKAAyK,CAAC;KACrM,MAAM,CAAC,aAAa,EAAE,0EAA0E,CAAC;KACjG,MAAM,CAAC,mBAAmB,EAAE,aAAa,EAAE,MAAM,CAAC;KAClD,MAAM,CAAC,WAAW,EAAE,uBAAuB,CAAC;KAC5C,MAAM,CAAC,KAAK,EAAE,OAA8E,EAAE,EAAE;IAC7F,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QAClB,MAAM,uBAAuB,CAAC;YAC1B,IAAI,EAAE,OAAO,CAAC,OAAO;YACrB,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;YACvC,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,QAAQ,EAAE,OAAO,CAAC,QAAQ;SAC7B,CAAC,CAAC;QACH,OAAO;IACX,CAAC;IACD,OAAO,CAAC,IAAI,EAAE,CAAC;AACnB,CAAC,CAAC,CAAC;AAEP;;;;;;;;GAQG;AACH,SAAS,aAAa,CAAI,OAAgB,EAAE,IAAY,EAAE,KAAQ;IAC9D,IAAI,OAAO,CAAC,oBAAoB,CAAC,IAAI,CAAC,KAAK,KAAK;QAAE,OAAO,KAAK,CAAC;IAC/D,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAC9B,IAAI,MAAM,EAAE,oBAAoB,CAAC,IAAI,CAAC,KAAK,KAAK;QAAE,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC,IAAI,CAAM,CAAC;IAClF,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,OAAO;KACF,OAAO,CAAC,KAAK,CAAC;KACd,WAAW,CAAC,wCAAwC,CAAC;KACrD,MAAM,CAAC,mBAAmB,EAAE,aAAa,EAAE,MAAM,CAAC;KAClD,MAAM,CAAC,WAAW,EAAE,uBAAuB,CAAC;KAC5C,MAAM,CAAC,KAAK,WAA0B,OAAwC;IAC3E,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,MAAM,mBAAmB,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;AACjF,CAAC,CAAC,CAAC;AAEP,OAAO;KACF,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,4DAA4D,CAAC;KACzE,MAAM,CAAC,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,CAAC;KACxD,MAAM,CAAC,cAAc,EAAE,qDAAqD,CAAC;KAC7E,MAAM,CAAC,KAAK,EAAE,OAAiD,EAAE,EAAE;IAChE,MAAM,qBAAqB,CAAC,OAAO,CAAC,CAAC;AACzC,CAAC,CAAC,CAAC;AAEP,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AAeA,wBAAsB,mBAAmB,CAAC,OAAO,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AAeA,wBAAsB,mBAAmB,CAAC,OAAO,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAgBnG"}
|
package/lib/commands/dev.js
CHANGED
|
@@ -11,6 +11,15 @@ function clientRoot() {
|
|
|
11
11
|
return existsSync(resolve(sourceRoot, 'index.html')) ? sourceRoot : root;
|
|
12
12
|
}
|
|
13
13
|
export async function architectDevCommand(options) {
|
|
14
|
+
// Ctrl+C has to stop the server. This command drives startProjectServer
|
|
15
|
+
// directly rather than going through the Tools dev command, so it does not
|
|
16
|
+
// inherit that command's signal handling and has to register its own —
|
|
17
|
+
// without this the process ignores SIGINT and only a kill will end it.
|
|
18
|
+
for (const signal of ['SIGINT', 'SIGTERM']) {
|
|
19
|
+
process.once(signal, () => {
|
|
20
|
+
process.exit(0);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
14
23
|
await startProjectServer({
|
|
15
24
|
port: options.port,
|
|
16
25
|
open: options.open,
|
package/lib/commands/dev.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,SAAS,oBAAoB;IACzB,OAAO,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;AACrE,CAAC;AAED,SAAS,UAAU;IACf,MAAM,IAAI,GAAG,oBAAoB,EAAE,CAAC;IACpC,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;IACpD,OAAO,UAAU,CAAC,OAAO,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC;AAC7E,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,OAA0C;IAChF,MAAM,kBAAkB,CAAC;QACrB,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,UAAU,EAAE,UAAU,EAAE;KAC3B,CAAC,CAAC;AACP,CAAC"}
|
|
1
|
+
{"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,SAAS,oBAAoB;IACzB,OAAO,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;AACrE,CAAC;AAED,SAAS,UAAU;IACf,MAAM,IAAI,GAAG,oBAAoB,EAAE,CAAC;IACpC,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;IACpD,OAAO,UAAU,CAAC,OAAO,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC;AAC7E,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,OAA0C;IAChF,wEAAwE;IACxE,2EAA2E;IAC3E,uEAAuE;IACvE,uEAAuE;IACvE,KAAK,MAAM,MAAM,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAU,EAAE,CAAC;QAClD,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE;YACtB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;IACP,CAAC;IAED,MAAM,kBAAkB,CAAC;QACrB,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,UAAU,EAAE,UAAU,EAAE;KAC3B,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Open a bundled example.
|
|
3
|
+
*
|
|
4
|
+
* A checkout you own is served in place, so edits are real and can be
|
|
5
|
+
* committed. An example inside an installed package is copied to a disposable
|
|
6
|
+
* directory first and the copy is discarded on exit, so a dependency is never
|
|
7
|
+
* modified.
|
|
8
|
+
*/
|
|
9
|
+
export declare function architectExampleCommand(options: {
|
|
10
|
+
name: string;
|
|
11
|
+
port?: number;
|
|
12
|
+
open?: boolean;
|
|
13
|
+
/** Force the disposable copy even for a local checkout. */
|
|
14
|
+
readOnly?: boolean;
|
|
15
|
+
}): Promise<void>;
|
|
16
|
+
//# sourceMappingURL=example.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example.d.ts","sourceRoot":"","sources":["../../src/commands/example.ts"],"names":[],"mappings":"AAiGA;;;;;;;GAOG;AACH,wBAAsB,uBAAuB,CAAC,OAAO,EAAE;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB,GAAG,OAAO,CAAC,IAAI,CAAC,CAyChB"}
|