@bkm016/basalt 0.1.2 → 0.1.3
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/{chunk-shhrr741.js → chunk-bxn5kmpz.js} +1 -1
- package/compiled.js +1 -1
- package/package.json +1 -1
- package/web/{chunk-agmkx996.js → chunk-0xc2c540.js} +1 -1
- package/web/{chunk-kgerjbn4.js → chunk-0z0jycs8.js} +1 -1
- package/web/chunk-166qe5j6.js +2 -0
- package/web/chunk-1c95wfvq.js +1 -0
- package/web/{chunk-8wye0wbb.js → chunk-23c1df7e.js} +1 -1
- package/web/{chunk-mjpjkyd1.js → chunk-24h1rfje.js} +1 -1
- package/web/{chunk-dt8ss97f.js → chunk-2hd1pe9w.js} +1 -1
- package/web/chunk-329rtxa9.js +1 -0
- package/web/{chunk-9re6yttj.js → chunk-33qwz9bc.js} +1 -1
- package/web/{chunk-vkc149rb.js → chunk-3qjnwsph.js} +1 -1
- package/web/{chunk-jvj66qhs.js → chunk-47q4hmfp.js} +1 -1
- package/web/{chunk-xa88zgkr.js → chunk-4fzj0azw.js} +1 -1
- package/web/{chunk-zrzq29e6.js → chunk-5b2nw6j1.js} +1 -1
- package/web/{chunk-q1pkntc6.js → chunk-5hmfk69r.js} +1 -1
- package/web/{chunk-znvnb9dh.js → chunk-5qqw2e0t.js} +1 -1
- package/web/{chunk-rc2vq9wz.js → chunk-61jahh35.js} +1 -1
- package/web/chunk-6gxf3vsg.js +1 -0
- package/web/{chunk-5jbf7n5q.js → chunk-6parf7sy.js} +1 -1
- package/web/{chunk-shbw6wg8.js → chunk-7520nrbb.js} +1 -1
- package/web/{chunk-ezkqa7we.js → chunk-7ba8vrfc.js} +1 -1
- package/web/{chunk-pk3ap3wh.js → chunk-7qxhk1kz.js} +1 -1
- package/web/{chunk-h31p43qa.js → chunk-7v5rxabp.js} +1 -1
- package/web/{chunk-8ah6ce1b.js → chunk-7xk0ntav.js} +1 -1
- package/web/{chunk-xdcs8qz3.js → chunk-7yc083xj.js} +1 -1
- package/web/{chunk-vjqmnkh2.js → chunk-89fkdgbp.js} +1 -1
- package/web/{chunk-vny496ba.js → chunk-8qgpfxkz.js} +1 -1
- package/web/{chunk-rkj743fg.js → chunk-90xqeczk.js} +1 -1
- package/web/{chunk-jmnaq7c1.js → chunk-97b62pvb.js} +1 -1
- package/web/{chunk-693m9kt7.js → chunk-9a3q0jsh.js} +1 -1
- package/web/{chunk-jzmzhj8z.js → chunk-9bgey148.js} +1 -1
- package/web/{chunk-6qejm5s2.js → chunk-9xh96b33.js} +1 -1
- package/web/{chunk-3z93efr4.js → chunk-a5sg33w2.js} +1 -1
- package/web/chunk-a91vxtx4.js +1 -0
- package/web/{chunk-ctd8bfg2.js → chunk-acybsx44.js} +1 -1
- package/web/chunk-agec7jj4.js +1 -0
- package/web/{chunk-rrws61wf.js → chunk-axkyft9f.js} +1 -1
- package/web/{chunk-kww4azv5.js → chunk-b0a8nbj0.js} +1 -1
- package/web/chunk-c516cghj.js +1 -0
- package/web/{chunk-43jqvsrg.js → chunk-cwtdnacf.js} +1 -1
- package/web/chunk-dg1vas6z.js +8 -0
- package/web/{chunk-tn1xzmgx.js → chunk-ep37qp12.js} +1 -1
- package/web/{chunk-z760wagr.js → chunk-eqsd8zta.js} +1 -1
- package/web/{chunk-ctcrk3qn.js → chunk-es28k2t7.js} +1 -1
- package/web/chunk-fc0nx23g.js +1 -0
- package/web/{chunk-aqm3spxt.js → chunk-fhnypcrm.js} +84 -84
- package/web/{chunk-abbvjt4e.js → chunk-fv60p68p.js} +1 -1
- package/web/{chunk-vz5ck6x9.js → chunk-g46f421r.js} +1 -1
- package/web/{chunk-24k0r5aq.js → chunk-h18tnrf2.js} +1 -1
- package/web/{chunk-284a17k8.js → chunk-h288yd5w.js} +1 -1
- package/web/{chunk-z24vs8q9.js → chunk-hszjc2ny.js} +1 -1
- package/web/{chunk-5e7ygjdn.js → chunk-j0bwwc1g.js} +1 -1
- package/web/{chunk-bt1m87ck.js → chunk-jqa39f8t.js} +1 -1
- package/web/chunk-jvbbrnpa.js +1 -0
- package/web/{chunk-g8ee1csm.js → chunk-jzfd7cyh.js} +1 -1
- package/web/chunk-ka9ak8wr.js +1 -0
- package/web/{chunk-s3hwejnr.js → chunk-mb4qx9hy.js} +1 -1
- package/web/chunk-mnjd59jk.js +1 -0
- package/web/{chunk-1z5p7a1h.js → chunk-mwj9tpkz.js} +1 -1
- package/web/{chunk-qryrg2pq.js → chunk-n8gfjj9a.js} +2 -2
- package/web/chunk-ng0nbfhh.js +1 -0
- package/web/chunk-nz9nxk48.js +1 -0
- package/web/{chunk-raqqscwa.js → chunk-p9hsd3rn.js} +1 -1
- package/web/chunk-phw908hn.js +1 -0
- package/web/chunk-pjmmma1k.js +1 -0
- package/web/chunk-q7yn4m3t.js +1 -0
- package/web/chunk-qh15dxav.css +1 -0
- package/web/chunk-qnhqexe0.js +1 -0
- package/web/{chunk-yjv2c45j.js → chunk-rcx1aee5.js} +1 -1
- package/web/chunk-rjqj6ffe.js +1 -0
- package/web/{chunk-fy8ey195.js → chunk-rks7ksv3.js} +1 -1
- package/web/{chunk-cwvtraca.js → chunk-sb1cjpq8.js} +1 -1
- package/web/{chunk-5rx8rtsa.js → chunk-sgvp8vge.js} +1 -1
- package/web/chunk-sjjwte12.js +1 -0
- package/web/{chunk-yen2kkn2.js → chunk-sn9ecfvy.js} +1 -1
- package/web/{chunk-3mvr2gwh.js → chunk-t7bwsdbr.js} +1 -1
- package/web/{chunk-avwpjsxw.js → chunk-tse9gvyq.js} +1 -1
- package/web/{chunk-fqj9kry9.js → chunk-tx8240k4.js} +1 -1
- package/web/{chunk-s3rdx28k.js → chunk-vd6y2pcm.js} +1 -1
- package/web/{chunk-8e43yaq3.js → chunk-vpa55vje.js} +1 -1
- package/web/{chunk-9dd1c37b.js → chunk-vymqrpm3.js} +2 -2
- package/web/{chunk-t1xk6hca.js → chunk-w7snhcyg.js} +2 -2
- package/web/{chunk-jf2ehmvp.js → chunk-wdtnhpd6.js} +1 -1
- package/web/{chunk-vj6kstpp.js → chunk-wmvd6j0b.js} +1 -1
- package/web/{chunk-dk90px7g.js → chunk-xnq41dgs.js} +1 -1
- package/web/{chunk-986z0p48.js → chunk-xvsmtetz.js} +1 -1
- package/web/{chunk-2pjdtesn.js → chunk-y3ajqthy.js} +1 -1
- package/web/{chunk-f078k1ej.js → chunk-yd1ez3wd.js} +1 -1
- package/web/chunk-yfbxtg5p.js +1 -0
- package/web/{chunk-tnv7z83q.js → chunk-ywp4s71k.js} +1 -1
- package/web/{chunk-r92sbgwv.js → chunk-z4x331rx.js} +1 -1
- package/web/{chunk-4bry4xds.js → chunk-z6bpamwq.js} +1 -1
- package/web/{chunk-anbn2ttv.js → chunk-zmdnxn6m.js} +1 -1
- package/web/index.html +1 -1
- package/web/chunk-0sewdyz1.js +0 -1
- package/web/chunk-21ke27j6.js +0 -1
- package/web/chunk-3t3zwx9j.js +0 -1
- package/web/chunk-5xc9d5ft.js +0 -1
- package/web/chunk-b470hvpk.js +0 -1
- package/web/chunk-fekjj24p.css +0 -1
- package/web/chunk-frjfamx7.js +0 -8
- package/web/chunk-h5p5jsrw.js +0 -1
- package/web/chunk-h9fmr6ch.js +0 -1
- package/web/chunk-jq0pw0k2.js +0 -1
- package/web/chunk-k4cfnvyq.js +0 -1
- package/web/chunk-m29dhjkh.js +0 -1
- package/web/chunk-mj6tee5h.js +0 -1
- package/web/chunk-szcy5z56.js +0 -1
- package/web/chunk-t2hhdg9r.js +0 -1
- package/web/chunk-tj4cmkwe.js +0 -1
- package/web/chunk-v2b5q0n5.js +0 -1
- package/web/chunk-y5x74t89.js +0 -1
- package/web/chunk-yx3dh5hg.js +0 -1
- package/web/chunk-yz4fmtk2.js +0 -1
- package/web/chunk-z5j6x6j8.js +0 -2
- package/web/chunk-z5stjrhc.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e,r,Ne}from"./chunk-9dd1c37b.js";import"./chunk-8ah6ce1b.js";import{lr}from"./chunk-g8ee1csm.js";var Un=5,zn=0.00001,Rr=2,Tr=0.6,Vn=0.000001;function jn(t){let n=[];for(let o=0;o<t.length-1;o++)n.push({a:t[o],b:t[o+1]});return n}e(jn,"buildSegmentList");function Bo(t,n,o,s){let i=n.x-t.x,c=n.y-t.y,a=s.x-o.x,u=s.y-o.y,h=i*u-c*a;if(h===0)return null;let d=o.x-t.x,m=o.y-t.y,p=(d*u-m*a)/h,I=(d*c-m*i)/h;if(p<=Vn||p>=1-Vn||I<=Vn||I>=1-Vn)return null;return{point:{x:t.x+p*i,y:t.y+p*c},tA:p,tB:I}}e(Bo,"segmentIntersection");function Se(t){return Math.abs(t.b.x-t.a.x)>=Math.abs(t.b.y-t.a.y)}e(Se,"isHorizontalSeg");function Ce(t,n,o){if(t.curve!=="rounded")return!1;let s=t.points,i=s[n],c=s[n+1];if(!i||!c)return!1;let a=Math.hypot(c.x-i.x,c.y-i.y),u=o*a,h=n>0?Pn(s[n-1],i,c,Un):null;if(h&&u<h.cutLen)return!0;let d=n+2<s.length?Pn(i,c,s[n+2],Un):null;return d!==null&&a-u<d.cutLen}e(Ce,"crossingSitsInRoundedCorner");function Fo(t){let n=[];for(let o=0;o<t.length;o++){let s=t[o],i=jn(s.points);for(let c=o+1;c<t.length;c++){let a=t[c],u=jn(a.points);for(let[h,d]of i.entries())for(let[m,p]of u.entries()){let I=Bo(d.a,d.b,p.a,p.b);if(!I)continue;if(Ce(s,h,I.tA)||Ce(a,m,I.tB))continue;let y=Se(d),g=Se(p);if(y!==g?y:!1)n.push({jumpEdgeId:s.id,otherEdgeId:a.id,segIndex:h,t:I.tA,point:I.point});else n.push({jumpEdgeId:a.id,otherEdgeId:s.id,segIndex:m,t:I.tB,point:I.point})}}}return n}e(Fo,"findEdgeIntersections");function cn(t){let n=Math.round(t*1000)/1000;return Number.isInteger(n)?`${n}`:`${n}`}e(cn,"fmt");function wn(t){return`${cn(t.x)},${cn(t.y)}`}e(wn,"pointToString");function Po(t){let n=t.b.x-t.a.x,o=t.b.y-t.a.y;if(Math.abs(n)>=Math.abs(o))return n>=0?1:0;return o>=0?1:0}e(Po,"getArcSweepFlag");function ko(t,n){if(t.length<2)return t.map((c)=>({...c}));let o=t.map((c)=>({...c})),s=n.arrowTypeStart&&Ne[n.arrowTypeStart];if(s){let c=t[0],a=t[1],u=Math.atan2(a.y-c.y,a.x-c.x);o[0].x=c.x+s*Math.cos(u),o[0].y=c.y+s*Math.sin(u)}let i=n.arrowTypeEnd&&Ne[n.arrowTypeEnd];if(i){let c=t.length,a=t[c-2],u=t[c-1],h=Math.atan2(u.y-a.y,u.x-a.x);o[c-1].x=u.x-i*Math.cos(h),o[c-1].y=u.y-i*Math.sin(h)}return o}e(ko,"applyMarkerOffsets");function _o(t,n,o,s,i){let c=t.point.x,a=t.point.y,u={x:c-n*t.r,y:a-o*t.r},h={x:c+n*t.r,y:a+o*t.r},d=[`L${wn(u)}`];if(i==="arc")d.push(`A${cn(t.r)},${cn(t.r)} 0 0 ${s} ${wn(h)}`);else d.push(`M${wn(h)}`);return d}e(_o,"emitJump");function Pn(t,n,o,s){let i=n.x-t.x,c=n.y-t.y,a=o.x-n.x,u=o.y-n.y,h=Math.hypot(i,c),d=Math.hypot(a,u);if(h<zn||d<zn)return null;let m=i/h,p=c/h,I=a/d,y=u/d,g=m*I+p*y,l=Math.max(-1,Math.min(1,g)),x=Math.acos(l);if(x<zn||Math.abs(Math.PI-x)<zn)return null;let L=Math.min(s/Math.sin(x/2),h/2,d/2);return{startX:n.x-m*L,startY:n.y-p*L,endX:n.x+I*L,endY:n.y+y*L,ctrlX:n.x,ctrlY:n.y,cutLen:L}}e(Pn,"computeRoundedCorner");function Ho(t,n,o){let s=t.points;if(s.length<2)return"";let i=ko(s,t),c=t.curve==="rounded",a=jn(i),u=new Map;for(let d of n){let m=a[d.segIndex];if(!m)continue;let p=Math.hypot(m.b.x-m.a.x,m.b.y-m.a.y),I=u.get(d.segIndex)??[];I.push({t:d.t,point:d.point,d:d.t*p,r:o.jumpRadius}),u.set(d.segIndex,I)}let h=[`M${wn(i[0])}`];for(let d=0;d<a.length;d++){let m=a[d],p=Math.hypot(m.b.x-m.a.x,m.b.y-m.a.y),I=p===0?0:(m.b.x-m.a.x)/p,y=p===0?0:(m.b.y-m.a.y)/p,g=Po(m),l=0;if(c&&d>0){let w=Pn(i[d-1],i[d],i[d+1]??i[d],Un);if(w)l=w.cutLen}let x=p,L=null;if(c&&d<a.length-1){if(L=Pn(i[d],i[d+1],i[d+2]??i[d+1],Un),L)x=p-L.cutLen}let S=o.jumpRadius*Tr,E=[...u.get(d)??[]].sort((w,C)=>w.t-C.t).filter((w)=>{let C=Math.min(w.d-l,x-w.d)-Rr;return w.r=Math.min(w.r,C),w.r>=S});for(let w=0;w<E.length-1;w++){let C=E[w+1].d-E[w].d;if(E[w].r+E[w+1].r>C){let b=C/2;E[w].r=Math.min(E[w].r,b),E[w+1].r=Math.min(E[w+1].r,b)}}for(let w of E){if(w.r<S)continue;h.push(..._o(w,I,y,g,o.jumpStyle))}if(c&&L)h.push(`L${cn(L.startX)},${cn(L.startY)}`),h.push(`Q${cn(L.ctrlX)},${cn(L.ctrlY)} ${cn(L.endX)},${cn(L.endY)}`);else h.push(`L${wn(m.b)}`)}return h.join(" ")}e(Ho,"rewriteEdgePath");function Do(t){return/^[\d\s+,.LMelm-]*$/.test(t)}e(Do,"isStraightPath");function Xo(t){if(!t)return!0;return t==="linear"||t==="rounded"||t==="step"||t==="stepBefore"||t==="stepAfter"}e(Xo,"curveSupportsLineHops");function Yo(t){if(!t)return null;try{let n=typeof atob==="function"?atob(t):Buffer.from(t,"base64").toString(),o=JSON.parse(n);if(!Array.isArray(o))return null;let s=[];for(let i of o)if(i&&typeof i.x==="number"&&typeof i.y==="number")s.push({x:i.x,y:i.y});return s.length>=2?s:null}catch{return null}}e(Yo,"decodeDataPoints");function ve(t,n,o){if(!o.enabled)return;let s=t.node();if(!s)return;let i=new Map;for(let d of n)i.set(d.id,d);let c=new Map;for(let d of s.querySelectorAll("path[data-id]")){let m=d.getAttribute("data-id");if(m!==null&&!c.has(m))c.set(m,d)}let a=[];for(let d of n){let m=c.get(d.id);if(!m)continue;let I=Yo(m.getAttribute("data-points"))??d.points;a.push({...d,points:I})}let u=Fo(a);if(u.length===0)return;let h=new Map;for(let d of u){let m=h.get(d.jumpEdgeId)??[];m.push(d),h.set(d.jumpEdgeId,m)}for(let d of a){let m=h.get(d.id);if(!m||m.length===0)continue;let I=i.get(d.id)?.curve;if(I!==void 0&&!Xo(I))continue;let y=c.get(d.id);if(!y)continue;if(I===void 0){let E=y.getAttribute("d")??"";if(!Do(E))continue}let g=y.getAttribute("style")??"",l=/stroke-dasharray\s*:\s*0\s+([\d.]+)\s+[\d.]+\s+([\d.]+)/.exec(g),x=l?Number.parseFloat(l[1]):null,L=l?Number.parseFloat(l[2]):null,S=Ho(d,m,o);if(y.setAttribute("d",S),x!==null&&L!==null&&typeof y.getTotalLength==="function"){let E=y.getTotalLength(),w=Math.max(0,E-x-L),C=`0 ${x} ${w} ${L}`,b=g.replace(/stroke-dasharray\s*:[^;]*;?/g,`stroke-dasharray: ${C};`).replace(/;\s*;+/g,";");y.setAttribute("style",b)}}}e(ve,"applyLineJumpsToSvg");function jo(t,{measure:n}){let o=t.config?.swimlane?.lineHops;if(o===!1)return;let s=o==="gap"?"gap":"arc",i=t.edges.filter((c)=>Array.isArray(c.points)&&c.points.length>=2).map((c)=>({id:c.id,points:c.points,curve:c.curve,arrowTypeStart:c.arrowTypeStart,arrowTypeEnd:c.arrowTypeEnd}));ve(n.groups.edgePaths,i,{enabled:!0,jumpRadius:6,jumpStyle:s})}e(jo,"applySwimlaneLineJumps");var Le="__swimlane_default__",wr=21,Go=20;function Te(t){return Math.max(t.padding??Go,Go)}e(Te,"topLaneHorizontalPadding");function Wo(t){let{x:n,y:o,width:s,height:i}=t,c=t.swimlaneContentTop;if(typeof n!=="number"||typeof o!=="number"||typeof s!=="number"||typeof i!=="number"||typeof c!=="number"||!Number.isFinite(n)||!Number.isFinite(o)||!Number.isFinite(s)||!Number.isFinite(i)||!Number.isFinite(c)||s<=0||i<=0){delete t.groupTitleRect;return}let a=o-i/2,u=Math.min(c,o+i/2),h=Math.min(wr,Math.max(0,u-a)),d=a+h;if(d<=a){delete t.groupTitleRect;return}t.groupTitleRect={left:n-s/2,right:n+s/2,top:a,bottom:d}}e(Wo,"assignTopLaneTitleRect");function Ko(t){let n=t.direction,o=t.nodes??=[];for(let c of t.nodes??[])if(c.isGroup&&!c.parentId){if(c.shape="swimlane",n)c.direction=n}let s=o.filter((c)=>!c.isGroup&&!c.parentId);if(s.length===0)return;let i=o.find((c)=>c.id===Le);if(!i)i={id:Le,label:"",isGroup:!0,shape:"swimlane",padding:20,look:t.config?.look,colorIndex:o.reduce((c,a)=>Math.max(c,a.colorIndex??-1),-1)+1,...n?{direction:n}:{}},o.push(i);else if(i.isGroup){if(i.shape="swimlane",n)i.direction=n}for(let c of s)c.parentId=Le}e(Ko,"prepareLayoutForSwimlanes");function qo(t){let n=new Map;for(let h of t.nodes??[])n.set(h.id,h);let o=[];for(let h of t.edges??[]){let d=typeof h.start==="string"?h.start:void 0,m=typeof h.end==="string"?h.end:void 0;if(!d||!m)continue;if(h.labelNodeId)continue;o.push({id:h.id,src:d,dst:m,ref:h})}let s=t.nodes??[],i=s.filter((h)=>h.isGroup),c=s.filter((h)=>!h.isGroup);return{nodes:[...[...i].reverse(),...c].map((h)=>h.id),edges:o,layout:t,nodeById:n}}e(qo,"toGraphView");function Jo(t,n,o,s){let{layout:i}=t,c=t.nodeById,a=s?.layerGap??100,u=s?.nodeGap??40,h=0;for(let I of n.layers){let y=0;for(let g of I){let l=c.get(g);if(!l){y++;continue}l.layer=h,l.order=y;let x=o.x[g]??y*u,L=o.y[g]??h*a;l.x=x,l.y=L,y++}h++}let d=i.nodes??[],m=new Map,p=[];for(let I of d){if(!I?.isGroup)continue;if(!I.parentId)p.push(I);let y=d.filter((S)=>S.parentId===I.id),g=1/0,l=-1/0,x=1/0,L=-1/0;for(let S of y){let E=S.x??o.x[S.id],w=S.y??o.y[S.id],C=S.width??0,b=S.height??0;if(E!=null&&w!=null)g=Math.min(g,E-C/2),l=Math.max(l,E+C/2),x=Math.min(x,w-b/2),L=Math.max(L,w+b/2)}if(g===1/0||x===1/0)I.x=I.x??0,I.y=I.y??0,I.width=I.width??0,I.height=I.height??0;else{let S=I.padding??20,E=I.parentId?S:2*Te(I),w=S,C=Math.max(0,l-g)+E,b=Math.max(0,L-x)+w,R=(g+l)/2,O=(x+L)/2;I.x=R,I.y=O,I.width=C,I.height=b,m.set(I.id,{minX:g,maxX:l,minY:x,maxY:L})}}if(p.length>0&&m.size>0){let I=1/0,y=-1/0,g=0;for(let l of p){let x=l.padding??20;if(x>g)g=x;let L=m.get(l.id);if(!L)continue;I=Math.min(I,L.minY),y=Math.max(y,L.maxY)}if(I!==1/0&&y!==-1/0){let l=Math.max(0,y-I),x=36,L=Math.max(g,36),S=l+2*L,E=(I+y)/2;for(let P of p)P.y=E,P.height=S,P.swimlaneContentTop=I;let w=[...p].sort((P,N)=>{let H=P.x??0,_=N.x??0;return H-_}),C=[],b=[],R=[];for(let P of w){let N=m.get(P.id);if(!N)continue;let H=Math.max(0,N.maxX-N.minX)+2*Te(P),_=(N.minX+N.maxX)/2;C.push(P.id),b.push(_),R.push(H)}let O=C.length;if(O>0){let P=new Map;if(O===1)P.set(C[0],R[0]);else{let N=[];for(let V=0;V<O-1;V++)N.push(b[V+1]-b[V]);let H=Array(O);H[0]=0;for(let V=0;V<O-1;V++)H[V+1]=2*N[V]-H[V];let _=0,F=Number.POSITIVE_INFINITY;for(let V=0;V<O;V++){let J=R[V];if(V%2===0)_=Math.max(_,J-H[V]);else F=Math.min(F,H[V]-J)}let Y=_;if(_<=F)Y=(_+F)/2;else Y=_;for(let V=0;V<O;V++){let J=H[V]+(V%2===0?Y:-Y),lt=Math.max(R[V],J);P.set(C[V],lt)}}for(let N of p){let H=P.get(N.id);if(H!=null)N.width=H;Wo(N)}}}}}e(Jo,"writeBackToLayoutData");var Nr="[EdgeLabelNodes]";function Zo(t){let n=[],o=[],s=new Map;for(let a of t.nodes)s.set(a.id,a);for(let a of t.edges){if(!a.label||a.label.length===0)continue;if(a.isLayoutOnly)continue;if(a.labelNodeId)continue;let u=a.start?s.get(a.start):void 0,h=a.end?s.get(a.end):void 0;if(!u||!h){r.warn(Nr,`Edge ${a.id} has missing source or target node`);continue}let d=`edge-label-${a.start}-${a.end}-${a.id}`,p=u.parentId!==h.parentId?h.parentId:u.parentId,I={id:d,label:a.label,edgeStart:a.start??"",edgeEnd:a.end??"",shape:"labelRect",width:0,height:0,isEdgeLabel:!0,isDummy:!0,parentId:p,isGroup:!1,labelStyle:Array.isArray(a.labelStyle)?a.labelStyle[0]:a.labelStyle??"",...u.dir?{dir:u.dir}:{}};n.push(I),a.labelNodeId=d,a.label=void 0,a.text=void 0;let y={id:`${a.id}-to-label`,start:a.start,end:d,type:"normal",isLayoutOnly:!0},g={id:`${a.id}-from-label`,start:d,end:a.end,type:"normal",isLayoutOnly:!0};o.push(y,g)}let i=[...t.nodes,...n],c=[...t.edges,...o];return{...t,nodes:i,edges:c}}e(Zo,"createEdgeLabelNodes");var Dt=0.001;function ao(t){let n=t.x??0,o=t.y??0,s=t.width??0,i=t.height??0;return s>0&&i>0?{cx:n,cy:o,rect:On(n,o,s,i)}:void 0}e(ao,"measuredNodeRect");function lo(t){if(t.isGroup)return;let n=ao(t);if(!n)return;return{id:String(t.id??""),cx:n.cx,cy:n.cy,rect:n.rect}}e(lo,"nodeBoundsInfoFor");function rn(t,n,o=Dt){return Math.abs(t.x-n.x)<o&&Math.abs(t.y-n.y)<o}e(rn,"samePoint");function ht(t,n,o=Dt){return Math.abs(t.x-n.x)<o}e(ht,"sameX");function pt(t,n,o=Dt){return Math.abs(t.y-n.y)<o}e(pt,"sameY");function Tt(t,n,o=Dt){return pt(t,n,o)&&Math.abs(t.x-n.x)>o}e(Tt,"isHorizontalSegment");function wt(t,n,o=Dt){return ht(t,n,o)&&Math.abs(t.y-n.y)>o}e(wt,"isVerticalSegment");function Ut(t,n,o,s){return Math.max(0,Math.min(Math.max(t,n),Math.max(o,s))-Math.max(Math.min(t,n),Math.min(o,s)))}e(Ut,"overlapLength");function fn(t,n,o=Dt){if(t.horizontal&&n.horizontal&&pt(t.a,n.a,o))return Ut(t.a.x,t.b.x,n.a.x,n.b.x);if(t.vertical&&n.vertical&&ht(t.a,n.a,o))return Ut(t.a.y,t.b.y,n.a.y,n.b.y);return 0}e(fn,"sameAxisSegmentOverlapLength");function Bn(t,n=Dt){let o=[];for(let s=0;s<t.length-1;s++){let i=t[s],c=t[s+1],a=Tt(i,c,n),u=wt(i,c,n);if(a||u)o.push({index:s,a:i,b:c,horizontal:a,vertical:u})}return o}e(Bn,"orthogonalSegmentsForPoints");function nn(t,n=Dt){let o=Bn(t,n),s=0;for(let i=1;i<o.length;i++)if(o[i-1].horizontal!==o[i].horizontal)s++;return s}e(nn,"countOrthogonalBends");function yt(t,n=Dt){let o=[];for(let s of t){let i=o.length>0?o[o.length-1]:void 0;if(!i||!rn(i,s,n))o.push({x:s.x,y:s.y})}return o}e(yt,"dedupeConsecutivePoints");function fo(t,n=Dt){if(!t||t.length!==4)return;let[o,s,i,c]=t;if(Tt(o,s,n)&&wt(s,i,n)&&Tt(i,c,n))return{kind:"HVH",p0:o,p1:s,p2:i,p3:c};return wt(o,s,n)&&Tt(s,i,n)&&wt(i,c,n)?{kind:"VHV",p0:o,p1:s,p2:i,p3:c}:void 0}e(fo,"classifyThreeSegmentRoute");function ae(t,n,o,s=0){let i=Math.min(t.x,n.x),c=Math.max(t.x,n.x),a=Math.min(t.y,n.y),u=Math.max(t.y,n.y);return c>o.left-s&&i<o.right+s&&u>o.top-s&&a<o.bottom+s}e(ae,"segmentBoundsOverlapRect");function uo(t,n,o=0){return t.x>n.left+o&&t.x<n.right-o&&t.y>n.top+o&&t.y<n.bottom-o}e(uo,"pointInsideRect");function Qo(t,n){return t.left<=n.left&&t.right>=n.right&&t.top<=n.top&&t.bottom>=n.bottom}e(Qo,"rectContainsRect");function Qn(t,n){return t.left<n.right&&t.right>n.left&&t.top<n.bottom&&t.bottom>n.top}e(Qn,"rectsOverlap");function we(t,n){return{left:t.left-n,right:t.right+n,top:t.top-n,bottom:t.bottom+n}}e(we,"inflateRect");function On(t,n,o,s){return{left:t-o/2,right:t+o/2,top:n-s/2,bottom:n+s/2}}e(On,"rectFromCenterSize");function Zt(t){return ao(t)?.rect}e(Zt,"rectOfNodeBounds");function vn(t,n){switch(n){case"top":return{x:t.cx,y:t.rect.top};case"bottom":return{x:t.cx,y:t.rect.bottom};case"left":return{x:t.rect.left,y:t.cy};case"right":return{x:t.rect.right,y:t.cy}}}e(vn,"portForRectSide");function ho(t,n,o,s,i,c=Dt){let a=n==="left"||n==="right",u=s==="left"||s==="right";if(a&&u){if(n==="right"&&s==="left"&&t.x<o.x||n==="left"&&s==="right"&&t.x>o.x){if(pt(t,o,c))return[t,o];let p=(t.x+o.x)/2;return[t,{x:p,y:t.y},{x:p,y:o.y},o]}if(n===s){if(pt(t,o,c))return;let p=n==="left"?Math.min(t.x,o.x)-i:Math.max(t.x,o.x)+i;return[t,{x:p,y:t.y},{x:p,y:o.y},o]}return}if(!a&&!u){if(n===s){if(ht(t,o,c))return;let I=n==="top"?Math.min(t.y,o.y)-i:Math.max(t.y,o.y)+i;return[t,{x:t.x,y:I},{x:o.x,y:I},o]}if(!(n==="bottom"&&s==="top"&&t.y<o.y||n==="top"&&s==="bottom"&&t.y>o.y))return;if(ht(t,o,c))return[t,o];let p=(t.y+o.y)/2;return[t,{x:t.x,y:p},{x:o.x,y:p},o]}if(a&&!u){let m=n==="right"&&o.x>t.x||n==="left"&&o.x<t.x,p=s==="top"&&t.y<o.y||s==="bottom"&&t.y>o.y;return m&&p?[t,{x:o.x,y:t.y},o]:void 0}let h=n==="bottom"&&o.y>t.y||n==="top"&&o.y<t.y,d=s==="left"&&t.x<o.x||s==="right"&&t.x>o.x;return h&&d?[t,{x:t.x,y:o.y},o]:void 0}e(ho,"buildOrthogonalPortPath");function go(t,n,o,s){return n==="left"||n==="right"?[t,{x:s,y:t.y},{x:s,y:o.y},o]:[t,{x:t.x,y:s},{x:o.x,y:s},o]}e(go,"buildSameSideTrackPath");function le(t){let n=new Map,o=[];for(let s of t){if(s.isEdgeLabel)continue;let i=lo(s);if(!i)continue;n.set(i.id,i),o.push({id:i.id,rect:i.rect})}return{nodeInfoById:n,realNodeRects:o}}e(le,"collectRealNodeBounds");function bn(t){let n=[],o=[];for(let s of t){let i=lo(s);if(!i)continue;let c={id:i.id,rect:i.rect};if(s.isEdgeLabel)o.push(c);else n.push(c)}return{realNodeRects:n,labelNodeRects:o}}e(bn,"collectNodeRectEntries");function ts(t,{includeEdgeLabels:n=!0}={}){let o=[];for(let s of t){if(s.isGroup||!n&&s.isEdgeLabel)continue;let i=s.x??0,c=s.y??0,a=s.width??0,u=s.height??0;o.push({nodeId:s.id,...On(i,c,a,u)})}return o}e(ts,"collectLayoutNodeRects");function po(t,n,o=Dt){let{start:s,end:i}=t;if(!s||!i)return;let c=n.get(s),a=n.get(i);if(!c||!a)return;return{srcId:s,dstId:i,srcInfo:c,dstInfo:a,collinearX:Math.abs(c.cx-a.cx)<o,collinearY:Math.abs(c.cy-a.cy)<o}}e(po,"getNodePairGeometry");function Nt(t,n,o,s=[],i=0){for(let c of o){if(s.includes(c.id))continue;if(ae(t,n,c.rect,-i))return!0}return!1}e(Nt,"segmentHitsAnyRect");function mo(t,n,o,s,i=Dt,c=0.000001){let a=pt(t,n,i),u=ht(t,n,i),h=pt(o,s,i),d=ht(o,s,i);if(a&&h||u&&d)return!1;if(!(a||u)||!(h||d))return!1;let m=a?{a:t,b:n}:{a:o,b:s},p=u?{a:t,b:n}:{a:o,b:s},I=m.a.y,y=Math.min(m.a.x,m.b.x),g=Math.max(m.a.x,m.b.x),l=p.a.x,x=Math.min(p.a.y,p.b.y),L=Math.max(p.a.y,p.b.y);if(l<y||l>g||I<x||I>L)return!1;let S=Math.abs(l-m.a.x)<c&&Math.abs(I-m.a.y)<c||Math.abs(l-m.b.x)<c&&Math.abs(I-m.b.y)<c,E=Math.abs(l-p.a.x)<c&&Math.abs(I-p.a.y)<c||Math.abs(l-p.b.x)<c&&Math.abs(I-p.b.y)<c;return!(S&&E)}e(mo,"orthogonalSegmentsCross");function ns(t,n,o,s,i=Dt){let c=pt(t,n,i),a=ht(t,n,i),u=pt(o,s,i),h=ht(o,s,i);if(a&&h&&ht(t,o,i))return Ut(t.y,n.y,o.y,s.y)>i;if(c&&u&&pt(t,o,i))return Ut(t.x,n.x,o.x,s.x)>i;return!1}e(ns,"sameAxisSegmentsOverlap");function te(t,n,o,s,{epsilon:i=Dt,skipDegenerateOther:c=!1}={}){for(let a of o){if(a===s||a.isLayoutOnly)continue;let u=a.points;if(!u||u.length<2)continue;for(let h=0;h<u.length-1;h++){let d=u[h],m=u[h+1];if(c&&rn(d,m,i))continue;if(mo(t,n,d,m,i)||ns(t,n,d,m,i))return!0}}return!1}e(te,"segmentConflictsWithAnyEdge");function un(t,n,o,s,i=Dt){let c=pt(t,n,i),a=ht(t,n,i),u=pt(o,s,i),h=ht(o,s,i);if(!(c&&h||a&&u))return!1;let d=c?{a:t,b:n}:{a:o,b:s},m=c?{a:o,b:s}:{a:t,b:n},p=d.a.y,I=Math.min(d.a.x,d.b.x),y=Math.max(d.a.x,d.b.x),g=m.a.x,l=Math.min(m.a.y,m.b.y),x=Math.max(m.a.y,m.b.y);return g>I+i&&g<y-i&&p>l+i&&p<x-i}e(un,"orthogonalSegmentsStrictlyCross");function Oe(t,n,o){let s=Math.min(n,o),i=Math.max(n,o);return t>s+Dt&&t<i-Dt}e(Oe,"strictlyBetween");function es(t,n,o){if(ht(t,n)&&ht(n,o))return Oe(n.y,t.y,o.y);if(pt(t,n)&&pt(n,o))return Oe(n.x,t.x,o.x);return!1}e(es,"isCollinearIntermediate");function os(t){let n=!1,o=[];for(let s=0;s<t.length;s++){let i=o[o.length-1],c=t[s],a=s+1<t.length?t[s+1]:void 0;if(i&&a){if(rn(i,a)){s++,n=!0;continue}if(es(i,c,a)){n=!0;continue}}o.push(c)}return{points:o,changed:n}}e(os,"simplifyPolylineOnce");function ne(t){let n=[t[0]];for(let s=1;s<t.length;s++){let i=n[n.length-1],c=t[s];if(!ht(i,c)&&!pt(i,c)){let a=n.length>=2?n[n.length-2]:void 0,h=(a?ht(a,i):!1)?{x:i.x,y:c.y}:{x:c.x,y:i.y};n.push(h)}n.push(c)}let o=[];for(let s of n){let i=o[o.length-1];if(!i||!rn(i,s))o.push(s)}return o}e(ne,"orthogonalizePolyline");function dn(t){if(t.length<3)return t;let n=[...t];for(let o=0;o<32;o++){let s=os(n);if(n=s.points,!s.changed)break}return n}e(dn,"simplifyPolyline");var st=0.001,Or=0.5,$o=4;function yo(t,n,o){let s=t;if(s.isLayoutOnly||!s.points||s.points.length<o)return;let i=s.start?n.get(s.start):void 0,c=s.end?n.get(s.end):void 0;return{edge:s,points:s.points,srcRect:i?Zt(i):void 0,dstRect:c?Zt(c):void 0}}e(yo,"endpointContextFor");function ss(t,n,o){if(pt(t,n,st))return{x:t.x<o.left?o.left:o.right,y:t.y};if(ht(t,n,st)){let s=t.y<o.top?o.top:o.bottom;return{x:t.x,y:s}}return{x:Math.min(o.right,Math.max(o.left,t.x)),y:Math.min(o.bottom,Math.max(o.top,t.y))}}e(ss,"segmentEnterPoint");function Be(t,n,o){let s=o?1:-1,i=o?0:t.length-1;while(i>=0&&i<t.length&&uo(t[i],n,Or))i+=s;if(i<0||i>=t.length)return t;let c=i-s;if(c<0||c>=t.length)return t;let a=ss(t[i],t[c],n);return o?[a,...t.slice(i)]:[...t.slice(0,i+1),a]}e(Be,"clipEndpoint");function rs(t,n){for(let o of t){let s=yo(o,n,2);if(!s)continue;let i=[...s.points];if(s.srcRect)i=Be(i,s.srcRect,!0);if(s.dstRect)i=Be(i,s.dstRect,!1);i=dn(ne(i)),i=xo(i,s.srcRect,s.dstRect),s.edge.points=dn(ne(i))}}e(rs,"clipEdgeEndpointsToNodeBoundaries");function Fe(t,n,o,s=!1){if(pt(t,n,st)){if(n.y<o.top-st||n.y>o.bottom+st)return n;if(s){if(t.x<o.left-st)return{x:o.left,y:t.y};if(t.x>o.right+st)return{x:o.right,y:t.y}}return{x:Math.abs(n.x-o.left)<=Math.abs(n.x-o.right)?o.left:o.right,y:t.y}}if(ht(t,n,st)){if(n.x<o.left-st||n.x>o.right+st)return n;if(s){if(t.y<o.top-st)return{x:t.x,y:o.top};if(t.y>o.bottom+st)return{x:t.x,y:o.bottom}}let i=Math.abs(n.y-o.top)<=Math.abs(n.y-o.bottom);return{x:t.x,y:i?o.top:o.bottom}}return n}e(Fe,"snapEndpointToBoundary");function ee(t,n,o){let s=t[n];for(let i=n+o;i>=0&&i<t.length;i+=o){let c=t[i];if(!rn(c,s,st))return c}return t[n+o]}e(ee,"firstDistinctAdjacent");function oe(t,n){let o=t+$o,s=n-$o;return o<=s?{lo:o,hi:s}:{lo:(t+n)/2,hi:(t+n)/2}}e(oe,"cornerClearanceRange");function Pe(t,n,o){let{lo:s,hi:i}=oe(n,o);return Math.min(i,Math.max(s,t))}e(Pe,"clampToCornerClearance");function is(t){let n=Math.max(...t.map((s)=>s.lo)),o=Math.min(...t.map((s)=>s.hi));if(n>o)return;return{lo:n,hi:o}}e(is,"intersectRanges");function ke(t,n){return n==="left"||n==="right"?oe(t.top,t.bottom):oe(t.left,t.right)}e(ke,"clearanceRangeForSide");function se(t,n,o){let s=t.y>=o.top-st&&t.y<=o.bottom+st,i=t.x>=o.left-st&&t.x<=o.right+st;if(pt(t,n,st)&&s){if(Math.abs(t.x-o.left)<st)return"left";if(Math.abs(t.x-o.right)<st)return"right"}if(ht(t,n,st)&&i){if(Math.abs(t.y-o.top)<st)return"top";if(Math.abs(t.y-o.bottom)<st)return"bottom"}return}e(se,"terminalSideForSegment");function kn(t){return t==="left"||t==="right"}e(kn,"isHorizontalSide");function cs(t,n,o,s,i){let c=[],a=o?se(t,n,o):void 0,u=s?se(n,t,s):void 0;if(o&&a&&kn(a)===i)c.push(ke(o,a));if(s&&u&&kn(u)===i)c.push(ke(s,u));return c.length>0?is(c):void 0}e(cs,"straightClearanceRange");function _e(t,n,o,s,i){let c=cs(t,n,o,s,i);if(!c)return;let a=i?t.y:t.x,u=Math.min(c.hi,Math.max(c.lo,a));if(Math.abs(u-a)<st)return;return i?[{x:t.x,y:u},{x:n.x,y:u}]:[{x:u,y:t.y},{x:u,y:n.y}]}e(_e,"clearStraightEndpointCornerAxis");function xo(t,n,o){if(t.length!==2)return t;let[s,i]=t;if(pt(s,i,st))return _e(s,i,n,o,!0)??t;if(ht(s,i,st))return _e(s,i,n,o,!1)??t;return t}e(xo,"clearStraightEndpointCornerConnections");function as(t,n,o){return kn(o)?{x:t.x,y:Pe(t.y,n.top,n.bottom)}:{x:Pe(t.x,n.left,n.right),y:t.y}}e(as,"cornerClearedEndpoint");function ls(t,n,o,s,i,c){let a=t.map((u)=>({...u}));for(let u=n;u>=0&&u<t.length;u+=o){let h=t[u];if(c&&!pt(h,s,st))break;if(!c&&!ht(h,s,st))break;if(c)a[u].y=i.y;else a[u].x=i.x}return a}e(ls,"moveCollinearEndpointRun");function He(t,n,o){if(t.length<2)return t;let s=o?0:t.length-1,i=o?1:-1,c=t[s],a=ee(t,s,i);if(!a)return t;let u=se(c,a,n);if(!u)return t;let h=kn(u),d=as(c,n,u);if(rn(c,d,st))return t;return ls(t,s,i,c,d,h)}e(He,"clearEndpointCornerConnection");function De(t,n,o){let s=Math.min(t.x,n.x)>=o.left-st&&Math.max(t.x,n.x)<=o.right+st,i=Math.min(t.y,n.y)>=o.top-st&&Math.max(t.y,n.y)<=o.bottom+st;if(Math.abs(t.y-o.top)<st&&Math.abs(n.y-o.top)<st&&s)return"top";if(Math.abs(t.y-o.bottom)<st&&Math.abs(n.y-o.bottom)<st&&s)return"bottom";if(Math.abs(t.x-o.left)<st&&Math.abs(n.x-o.left)<st&&i)return"left";if(Math.abs(t.x-o.right)<st&&Math.abs(n.x-o.right)<st&&i)return"right";return}e(De,"borderSideForSegment");function Xe(t,n,o,s){switch(t){case"top":return ht(n,o,st)&&o.y<s.top-st;case"bottom":return ht(n,o,st)&&o.y>s.bottom+st;case"left":return pt(n,o,st)&&o.x<s.left-st;case"right":return pt(n,o,st)&&o.x>s.right+st}}e(Xe,"leavesOutward");function Ye(t,n,o){if(t.length<3)return t;if(o){let c=De(t[0],t[1],n);if(c&&Xe(c,t[1],t[2],n))return t.slice(1);return t}let s=t.length-1,i=De(t[s-1],t[s],n);if(i&&Xe(i,t[s-1],t[s-2],n))return t.slice(0,s);return t}e(Ye,"collapseOwnBorderStub");function fs(t,n,o){let s=t;if(n){let c=ee(s,0,1);if(c){let a=Fe(c,s[0],n);if(a!==s[0])s=[a,...s.slice(1)]}s=Ye(s,n,!0)}if(o){let c=s.length-1,a=ee(s,c,-1);if(a){let u=Fe(a,s[c],o,!0);if(u!==s[c])s=[...s.slice(0,c),u]}s=Ye(s,o,!1)}let i=xo(s,n,o);if(i!==s||s.length===2)return i;if(n)s=He(s,n,!0);if(o)s=He(s,o,!1);return s}e(fs,"snapAndCollapseEndpoints");function Ge(t,n){for(let o of t){let s=yo(o,n,2);if(!s)continue;let i=yt(s.points,st),c=fs(i,s.srcRect,s.dstRect);if(c.length<3){s.edge.points=c;continue}let a=[c[0],{...c[0]},...c.slice(1,-1),c[c.length-1],{...c[c.length-1]}];s.edge.points=a}}e(Ge,"prepareEdgeEndpointsForRenderer");function bo(t){return new Map(t.map((n)=>[n.id,n]))}e(bo,"buildNodeMap");function ds(t,n){let o=t.parentId,s=null;while(o){let i=n.get(o);if(!i?.isGroup)break;s=i.id,o=i.parentId}return s}e(ds,"resolveTopLevelGroupId");function $e(t,n){let o=0,s=t.parentId;while(s){let i=n.get(s);if(!i?.isGroup)break;o++,s=i.parentId}return o}e($e,"groupDepth");function Mo(t){let n=1/0,o=-1/0,s=1/0,i=-1/0;for(let c of t){let{x:a,y:u}=c;if(typeof a!=="number"||typeof u!=="number")continue;let h=c.width??0,d=c.height??0;n=Math.min(n,a-h/2),o=Math.max(o,a+h/2),s=Math.min(s,u-d/2),i=Math.max(i,u+d/2)}if(n===1/0||s===1/0)return null;return{minX:n,maxX:o,minY:s,maxY:i}}e(Mo,"boundsForChildren");function us(t,n){let o=t.padding??20;t.x=(n.minX+n.maxX)/2,t.y=(n.minY+n.maxY)/2,t.width=Math.max(0,n.maxX-n.minX)+o,t.height=Math.max(0,n.maxY-n.minY)+o}e(us,"applyGroupBounds");function hs(t){let n=bo(t),o=t.filter((s)=>s.isGroup&&s.parentId).sort((s,i)=>$e(i,n)-$e(s,n));for(let s of o){let i=t.filter((a)=>a.parentId===s.id),c=Mo(i);if(c)us(s,c)}}e(hs,"recomputeNestedGroupBounds");function re(t,n){let o=t.nodes??[],s=t.edges??[],i=o.filter((h)=>!h.isGroup),c=1/0,a=-1/0;for(let h of i){let d=h[n];if(typeof d!=="number")continue;c=Math.min(c,d),a=Math.max(a,d)}if(!Number.isFinite(c)||!Number.isFinite(a))return!1;let u=e((h)=>c+a-h,"mirror");for(let h of o){let d=h[n];if(typeof d==="number")h[n]=u(d);let m=h.groupTitleRect;if(m)h.groupTitleRect=n==="x"?{...m,left:u(m.right),right:u(m.left)}:{...m,top:u(m.bottom),bottom:u(m.top)}}for(let h of s)for(let d of h.points??[])d[n]=u(d[n]);return!0}e(re,"mirrorAxis");function gs(t){if(!(t.nodes??[]).some((o)=>!o.isGroup))return!0;return re(t,"y")}e(gs,"applyBtDirectionTransform");function ps(t,n="LR"){let o=t.nodes??[],s=t.edges??[],i=o.filter((F)=>!F.isGroup),c=1/0,a=1/0;for(let F of i){let Y=F.x??0,V=F.y??0;if(Y<c)c=Y;if(V<a)a=V}if(!Number.isFinite(c)||!Number.isFinite(a))return!1;let u=36,h=0,d=0;for(let F of i)h+=F.width??0,d+=F.height??0;let m=h/i.length,p=d/i.length,I=p>0?Math.max(1,m/p):1;for(let F of i){let Y=F.x??0,J=((F.y??0)-a)*I+u,lt=Y-c;F.x=J,F.y=lt}for(let F of s){if(!F.points)continue;for(let Y of F.points){let V=Y.x,lt=(Y.y-a)*I+u,xt=V-c;Y.x=lt,Y.y=xt}}hs(o);let y=o.filter((F)=>F.isGroup&&!F.parentId);if(y.length===0){if(n==="RL")re(t,"x");return!0}let g=bo(o),l=new Map;for(let F of o){if(F.isGroup)continue;let Y=ds(F,g);if(!Y)continue;let V=l.get(Y)??[];V.push(F),l.set(Y,V)}let x=0;for(let F of y){let Y=F.padding??0;if(Y>x)x=Y}let L=[],S=1/0,E=-1/0;for(let F of y){let Y=l.get(F.id)??[],V=Mo(Y);if(!V)continue;S=Math.min(S,V.minX),E=Math.max(E,V.maxX),L.push({lane:F,contentTop:V.minY,contentBottom:V.maxY,centerY:(V.minY+V.maxY)/2})}if(S===1/0||E===-1/0)return!0;let w=Math.max(0,E-S),C=Math.max(x,10),b=w+2*C,R=u+b,N=(S+E)/2-b/2-u,H=N+R/2,_=Math.max(x,u);L.sort((F,Y)=>F.centerY-Y.centerY);for(let F=0;F<L.length;F++){let Y=L[F],V,J;if(F===0)V=Y.contentTop-_;else V=(L[F-1].contentBottom+Y.contentTop)/2;if(F===L.length-1)J=Y.contentBottom+_;else{let Ot=L[F+1];J=(Y.contentBottom+Ot.contentTop)/2}let lt=Math.max(0,J-V),xt=(V+J)/2;Y.lane.x=H,Y.lane.y=xt,Y.lane.width=R,Y.lane.height=lt,Y.lane.swimlaneContentTop=Y.contentTop,Y.lane.groupTitleRect={left:N,right:N+u,top:V,bottom:J}}if(n==="RL")re(t,"x");return!0}e(ps,"applyLrDirectionTransform");var an=0.000001,Br=8,Wn=Br,Fr=[0,Wn,-Wn,2*Wn,-2*Wn];function ms(t,n){let{nodeInfoById:o,realNodeRects:s}=le(n);for(let i of t){if(i.isLayoutOnly)continue;let c=i.points;if(!c||c.length<4)continue;let a=fo(yt(c,an),an);if(!a)continue;let{p3:u}=a,h=a.kind==="HVH",d=po(i,o,an);if(!d)continue;let{srcId:m,dstId:p,srcInfo:I,dstInfo:y,collinearX:g,collinearY:l}=d;if(g||l)continue;let x,L=I.rect;for(let S of Fr){let E,w,C;if(h){let H=y.cy>I.cy?L.bottom:L.top,_=I.cx+S;if(_<=L.left+an||_>=L.right-an)continue;E={x:_,y:H},w={x:_,y:u.y},C={x:u.x,y:u.y}}else{let H=y.cx>I.cx?L.right:L.left,_=I.cy+S;if(_<=L.top+an||_>=L.bottom-an)continue;E={x:H,y:_},w={x:u.x,y:_},C={x:u.x,y:u.y}}let b=rn(E,w,an),R=rn(w,C,an);if(b&&R)continue;if(!b&&Nt(E,w,s,[m],1))continue;if(!R&&Nt(w,C,s,[p],1))continue;let O=!b&&te(E,w,t,i,{epsilon:an,skipDegenerateOther:!0}),P=!R&&te(w,C,t,i,{epsilon:an,skipDegenerateOther:!0});if(O||P)continue;if(b)x=[w,C];else if(R)x=[E,w];else x=[E,w,C];break}if(x)i.points=x}}e(ms,"portSwapToLShape");function ys(t,n){let{realNodeRects:c,labelNodeRects:a}=bn(n.values());for(let u of t){if(u.isLayoutOnly)continue;let h=u.points;if(!h||h.length<4)continue;let d=yt(h,0.001);if(d.length<4)continue;let m=d.length-1,p=d[m],I=d[m-1],y=d[m-2],g=p.x-I.x,l=p.y-I.y,x=Math.hypot(g,l);if(x>=10||x<0.001)continue;let L=I.x-y.x,S=I.y-y.y;if(Math.hypot(L,S)<0.001)continue;let w=Tt(I,p,0.001),C=wt(I,p,0.001),b=Tt(y,I,0.001),R=wt(y,I,0.001);if(!(w&&R||C&&b))continue;let{end:O,start:P}=u,N=O?n.get(O):void 0;if(!N)continue;let H=N.x??0,_=N.y??0,F=Zt(N);if(!F)continue;let Y,V;if(R){let q=S<0;Y={x:H,y:y.y},V={x:H,y:q?F.bottom:F.top}}else{let q=L>0;Y={x:y.x,y:_},V={x:q?F.right:F.left,y:_}}if(Nt(Y,V,c,O?[O]:[],-2))continue;if(Nt(Y,V,a,[],-2))continue;if(P){let q=n.get(P),ot=q?Zt(q):void 0;if(ot&&uo(Y,ot,2))continue}let J=e((q,ot)=>`${q.x.toFixed(3)},${q.y.toFixed(3)}|${ot.x.toFixed(3)},${ot.y.toFixed(3)}`,"ownSegmentKey"),lt=new Set;for(let q=0;q<d.length-1;q++)lt.add(J(d[q],d[q+1]));let xt=e((q,ot)=>{for(let dt of t){if(dt===u)continue;if(dt.isLayoutOnly)continue;let mt=dt.points;if(!mt||mt.length<2)continue;for(let Mt=0;Mt<mt.length-1;Mt++){let Et=mt[Mt],jt=mt[Mt+1];if(lt.has(J(Et,jt)))continue;if(un(q,ot,Et,jt,0.001))return!0}}return!1},"segmentCrossesOtherEdge");if(xt(Y,V))continue;if(m-3>=0){let q=d[m-3],ot=[P,O].filter((dt)=>Boolean(dt));if(Nt(q,Y,c,ot,-2))continue;if(xt(q,Y))continue}let kt=[...d.slice(0,m-2),Y,V];u.points=kt;let nt=u.labelNodeId;if(nt){let q=n.get(nt);if(q){let ot=q.width??0,dt=q.height??0;if(ot>0&&dt>0){let mt,Mt,Et=-1;for(let jt=0;jt<kt.length-1;jt++){let Wt=kt[jt],Kt=kt[jt+1],en=Math.hypot(Kt.x-Wt.x,Kt.y-Wt.y),Ln=pt(Wt,Kt,0.001),gn=ht(Wt,Kt,0.001);if(!(Ln&&en>=ot+2||gn&&en>=dt+2))continue;if(en>Et)Et=en,mt=(Wt.x+Kt.x)/2,Mt=(Wt.y+Kt.y)/2}if(mt!==void 0&&Mt!==void 0)q.x=mt,q.y=Mt}}}}}e(ys,"collapseShortTerminalStub");var tt=0.001,Ht=8,xs=e((t)=>typeof t==="string"?t.toUpperCase():"","upperCaseDirection"),at=Bn,Ee=e((t,n)=>ht(t,n,tt)||pt(t,n,tt),"orthogonallyAligned");function ze(t,n){let i=e((y,g)=>{let l=y.x??0,x=y.y??0,L=g.x-l,S=g.y-x,E=(y.width??0)/2,w=(y.height??0)/2;if(Math.abs(S)*E>Math.abs(L)*w){if(S<0)w=-w;return{x:l+(S===0?0:w*L/S),y:x+w}}if(L<0)E=-E;return{x:l+E,y:x+(L===0?0:E*S/L)}},"rectIntersect"),c=e((y,g)=>{let l=yt(y.points??[]);if(l.length<2)return;let x=g?y.start:y.end,L=x?n.get(x):void 0,S=L?Zt(L):void 0;if(!L||!x||!S)return;let E=g?l[0]:l[l.length-1],w=g?l[1]:l[l.length-2],C=i(L,E),b=E;if(Ee(w,C))b=w;if(ht(C,b,tt))return{edge:y,edgeId:String(y.id??""),nodeId:x,atStart:g,orientation:"V",coord:C.x,min:Math.min(C.y,b.y),max:Math.max(C.y,b.y),boundary:C,railEnd:b,rect:S};if(pt(C,b,tt))return{edge:y,edgeId:String(y.id??""),nodeId:x,atStart:g,orientation:"H",coord:C.y,min:Math.min(C.x,b.x),max:Math.max(C.x,b.x),boundary:C,railEnd:b,rect:S};return},"terminalLaneFor"),a=e((y,g)=>Math.max(0,Math.min(y.max,g.max)-Math.max(y.min,g.min)),"projectedOverlapLength"),u=e((y,g)=>{if(y.nodeId!==g.nodeId||y.orientation!==g.orientation)return!1;if(y.orientation==="H")return(Math.abs(y.boundary.x-y.rect.left)<1||Math.abs(y.boundary.x-y.rect.right)<1)&&ht(y.boundary,g.boundary,1);return(Math.abs(y.boundary.y-y.rect.top)<1||Math.abs(y.boundary.y-y.rect.bottom)<1)&&pt(y.boundary,g.boundary,1)},"sameTerminalFace"),h=e((y,g)=>{if(y.nodeId!==g.nodeId||y.orientation!==g.orientation)return!1;return a(y,g)>=Ht&&Math.abs(y.coord-g.coord)<0.5},"exactTerminalLaneConflict"),d=e((y,g)=>{if(y.nodeId!==g.nodeId||y.orientation!==g.orientation||y.orientation!=="H"||y.atStart===g.atStart)return!1;let l=a(y,g);if(l<Ht)return!1;let x=y.rect.bottom-y.rect.top;if(l<x||l>2*x)return!1;return u(y,g)&&Math.abs(y.coord-g.coord)<16},"nearTerminalLaneConflict"),m=e((y,g)=>{let l=yt(y.edge.points??[]);if(l.length<2)return;let x=y.orientation==="V"?{x:y.boundary.x+g,y:y.boundary.y}:{x:y.boundary.x,y:y.boundary.y+g},L=y.orientation==="V"?{x:y.railEnd.x+g,y:y.railEnd.y}:{x:y.railEnd.x,y:y.railEnd.y+g};if(!e(()=>{if(Math.abs(y.boundary.y-y.rect.top)<1||Math.abs(y.boundary.y-y.rect.bottom)<1)return pt(x,y.boundary,tt)&&x.x>=y.rect.left+1&&x.x<=y.rect.right-1;if(Math.abs(y.boundary.x-y.rect.left)<1||Math.abs(y.boundary.x-y.rect.right)<1)return ht(x,y.boundary,tt)&&x.y>=y.rect.top+1&&x.y<=y.rect.bottom-1;return!1},"boundaryStaysOnSameFace")())return;if(y.atStart){let b=l.length>1&&rn(l[1],y.railEnd,tt),R=l.slice(b?2:1),O=R[0];if(O&&!Ee(O,L))return;return[x,L,...R]}let E=l.length>1&&rn(l[l.length-2],y.railEnd,tt),w=l.slice(0,E?-2:-1),C=w[w.length-1];if(C&&!Ee(C,L))return;return[...w,L,x]},"shiftedCandidate"),p=e((y)=>{let g=y.edge,l=yt(g.points??[]);if(l.length!==2)return!1;let{start:x,end:L}=g,S=x?n.get(x):void 0,E=L?n.get(L):void 0;if(!S||!E)return!1;let w=S.x??0,C=S.y??0,b=E.x??0,R=E.y??0,[O,P]=l;return pt(O,P,tt)&&Math.abs(C-R)<1&&Math.abs(w-b)>1||ht(O,P,tt)&&Math.abs(w-b)<1&&Math.abs(C-R)>1},"laneIsStraightCollinearConnector"),I=[-7,7,-14,14,-21,21];for(let y=0;y<8;y++){let g=t.filter((x)=>!x.isLayoutOnly).flatMap((x)=>[c(x,!0),c(x,!1)]).filter((x)=>Boolean(x)),l=!1;for(let x=0;x<g.length&&!l;x++)for(let L=x+1;L<g.length&&!l;L++){let S=g[x],E=g[L];if(S.edge===E.edge||!(h(S,E)||d(S,E)))continue;let w=!h(S,E),C=[S,E].sort((b,R)=>{let O=p(b),P=p(R);if(O!==P)return Number(O)-Number(P);return Number(!R.atStart)-Number(!b.atStart)});for(let b of C){for(let R of I){let O=m(b,R);if(!O)continue;let P=c({...b.edge,points:O},b.atStart);if(!P||g.some((N)=>N.edge!==b.edge&&(h(P,N)||w&&d(P,N))))continue;b.edge.points=O,l=!0;break}if(l)break}}if(!l)return}}e(ze,"separateSharedRenderedTerminalLanes");function bs(t,n){let{realNodeRects:i,labelNodeRects:c}=bn(n.values()),a=e((h,d)=>{let{start:m,end:p}=h,I=at(d);if(I.length!==d.length-1)return!1;let y=[m,p].filter((g)=>Boolean(g));for(let g of I){if(Nt(g.a,g.b,i,y,-2))return!1;if(Nt(g.a,g.b,c,[],-2))return!1}for(let g of t){if(g===h||g.isLayoutOnly)continue;let l=g.points;if(!l||l.length<2)continue;for(let x of I)for(let L of at(yt(l))){if(fn(x,L,0.5)>=Ht)return!1;if(un(x.a,x.b,L.a,L.b,tt))return!1}}return!0},"candidateIsSafe"),u=e((h,d)=>{if(d+4>=h.length)return;let m=h[d],p=h[d+1],I=h[d+2],y=h[d+3],g=h[d+4],l=Tt(m,p)&&wt(p,I)&&Tt(I,y)&&wt(y,g)&&ht(m,y,tt)&&ht(m,g,tt)&&ht(p,I,tt)&&(p.x-m.x)*(y.x-I.x)<0,x=wt(m,p)&&Tt(p,I)&&wt(I,y)&&Tt(y,g)&&pt(m,y,tt)&&pt(m,g,tt)&&pt(p,I,tt)&&(p.y-m.y)*(y.y-I.y)<0;if(l||x)return yt([...h.slice(0,d+1),g,...h.slice(d+5)]);if(d+5>=h.length)return;let L=h[d+5],S=wt(m,p)&&Tt(p,I)&&wt(I,y)&&Tt(y,g)&&wt(g,L)&&ht(m,g,tt)&&ht(m,L,tt)&&ht(I,y,tt)&&(I.x-p.x)*(g.x-y.x)<0,E=Tt(m,p)&&wt(p,I)&&Tt(I,y)&&wt(y,g)&&Tt(g,L)&&pt(m,g,tt)&&pt(m,L,tt)&&pt(I,y,tt)&&(I.y-p.y)*(g.y-y.y)<0;if(!S&&!E)return;return yt([...h.slice(0,d+1),L,...h.slice(d+6)])},"withoutDogleg");for(let h=0;h<8;h++){let d=!1;for(let m of t){if(m.isLayoutOnly)continue;let p=yt(m.points??[]);for(let I=0;I<=p.length-5;I++){let y=u(p,I);if(!y||!a(m,y))continue;m.points=y,d=!0;break}if(d)break}if(!d)return}}e(bs,"collapseRedundantRectangularDoglegs");function Ve(t,n){let{realNodeRects:c,labelNodeRects:a}=bn(n.values()),u=t.filter((g)=>!g.isLayoutOnly),h=e((g,l,x)=>yt(g===l?x??[]:g.points??[]),"pointsFor"),d=e((g,l)=>{let x=0;for(let L=0;L<u.length;L++){let S=at(h(u[L],g,l));for(let E=L+1;E<u.length;E++){let w=at(h(u[E],g,l));for(let C of S)for(let b of w)if(un(C.a,C.b,b.a,b.b,tt))x++}}return x},"strictCrossingCount"),m=e((g)=>{let l=at(g);if(l.length!==3)return;let x=l[1];if(l[0].horizontal===x.horizontal||l[2].horizontal===x.horizontal)return;return{index:x.index,horizontal:x.horizontal,vertical:x.vertical,segment:x}},"middleRail"),p=e((g,l)=>{let x=[g.start,g.end].filter((L)=>Boolean(L));return c.filter((L)=>{if(x.includes(L.id))return!1;let S=L.rect;if(l.horizontal)return Ut(l.a.x,l.b.x,S.left,S.right)>=Ht&&l.a.y>=S.top-2&&l.a.y<=S.bottom+2;return Ut(l.a.y,l.b.y,S.top,S.bottom)>=Ht&&l.a.x>=S.left-2&&l.a.x<=S.right+2})},"blockingRectsFor"),I=e((g,l,x)=>{let L=g.map((E)=>({...E}));if(l.horizontal)L[l.index].y=x,L[l.index+1].y=x;else if(l.vertical)L[l.index].x=x,L[l.index+1].x=x;else return;let S=dn(yt(L));return at(S).length===S.length-1?S:void 0},"candidateByMovingRail"),y=e((g,l,x)=>{let L=[g.start,g.end].filter((E)=>Boolean(E)),S=at(l);if(S.length!==l.length-1)return!1;for(let E of S){if(Nt(E.a,E.b,c,L,-2))return!1;if(Nt(E.a,E.b,a,[],-2))return!1}for(let E of u){if(E===g)continue;for(let w of S)for(let C of at(h(E)))if(fn(w,C,0.5)>=Ht)return!1}return d(g,l)<=x},"candidateIsSafe");for(let g=0;g<8;g++){let l=d(),x=!1;for(let L of u){let S=h(L),E=m(S);if(!E)continue;let w=p(L,E.segment);if(w.length===0)continue;let C=E.horizontal?[Math.min(...w.map((b)=>b.rect.top))-20,Math.max(...w.map((b)=>b.rect.bottom))+20]:[Math.min(...w.map((b)=>b.rect.left))-20,Math.max(...w.map((b)=>b.rect.right))+20];for(let b of C){let R=I(S,E.segment,b);if(!R||!y(L,R,l))continue;L.points=R,x=!0;break}if(x)break}if(!x)return}}e(Ve,"liftObstacleHuggingSameSideRails");function Ue(t,n,o){let i=e((d)=>{let m=d.groupTitleRect;if(!m||typeof m.left!=="number"||typeof m.right!=="number"||typeof m.top!=="number"||typeof m.bottom!=="number"||!Number.isFinite(m.left)||!Number.isFinite(m.right)||!Number.isFinite(m.top)||!Number.isFinite(m.bottom)||m.right<=m.left||m.bottom<=m.top)return;return{left:m.left,right:m.right,top:m.top,bottom:m.bottom}},"validTitleRect"),c=e((d)=>{if(!d.isGroup||d.parentId)return;let m=xs(d.direction??o);if(m==="LR"||m==="RL"||m==="BT")return;let p=i(d),{y:I,height:y}=d;if(!p||typeof I!=="number"||typeof y!=="number"||!Number.isFinite(I)||!Number.isFinite(y)||y<=0)return;let g=p.right-p.left,l=p.bottom-p.top;if(l<=0||g<l)return;return{node:d,rect:p}},"topLaneTitleFor"),a=e((d,m)=>{if(!d.horizontal)return!1;let p=d.a.y;if(p<m.top-tt||p>m.bottom+tt)return!1;return Ut(d.a.x,d.b.x,m.left,m.right)>=Ht},"horizontalSegmentIntersectsTitle"),u=[...n.values()].map(c).filter((d)=>Boolean(d));if(u.length===0)return;let h=0;for(let d of t){if(d.isLayoutOnly)continue;let m=yt(d.points??[]);for(let p of at(m))for(let I of u){if(!a(p,I.rect))continue;h=Math.max(h,I.rect.bottom-p.a.y+4)}}if(h<=tt)return;for(let d of u){let m=d.node.y,p=d.node.height;if(typeof m!=="number"||typeof p!=="number"||!Number.isFinite(m)||!Number.isFinite(p)||p<=0)continue;d.node.y=m-h/2,d.node.height=p+h,d.node.groupTitleRect={...d.rect,top:d.rect.top-h,bottom:d.rect.bottom-h}}}e(Ue,"liftTopLaneTitleBandsAboveRails");function je(t,n,o){let i=e((m)=>{let p=m.groupTitleRect;if(!p||typeof p.left!=="number"||typeof p.right!=="number"||typeof p.top!=="number"||typeof p.bottom!=="number"||!Number.isFinite(p.left)||!Number.isFinite(p.right)||!Number.isFinite(p.top)||!Number.isFinite(p.bottom)||p.right<=p.left||p.bottom<=p.top)return;return{left:p.left,right:p.right,top:p.top,bottom:p.bottom}},"validTitleRect"),c=e((m)=>{if(!m.isGroup||m.parentId)return;if(xs(m.direction??o)!=="LR")return;let I=i(m),{x:y,width:g}=m;if(!I||typeof y!=="number"||typeof g!=="number"||!Number.isFinite(y)||!Number.isFinite(g)||g<=0)return;let l=I.right-I.left,x=I.bottom-I.top;if(l<=0||x<l)return;return{node:m,rect:I}},"leftLaneTitleFor"),a=e((m,p)=>{if(!m.vertical)return!1;let I=m.a.x;if(I<p.left-tt||I>p.right+tt)return!1;return Ut(m.a.y,m.b.y,p.top,p.bottom)>=Ht},"verticalSegmentIntersectsTitle"),u=e((m,p)=>{if(!m.horizontal)return!1;let I=m.a.y;if(I<p.top-tt||I>p.bottom+tt)return!1;return Ut(m.a.x,m.b.x,p.left,p.right)>=Ht},"horizontalSegmentIntersectsTitle"),h=[...n.values()].map(c).filter((m)=>Boolean(m));if(h.length===0)return;let d=0;for(let m of t){if(m.isLayoutOnly)continue;let p=yt(m.points??[]);for(let I of at(p))for(let y of h)if(a(I,y.rect))d=Math.max(d,y.rect.right-I.a.x+4);else if(u(I,y.rect)){let g=Math.min(I.a.x,I.b.x);d=Math.max(d,y.rect.right-g+4)}}if(d<=tt)return;for(let m of h){let p=m.node.x,I=m.node.width;if(typeof p!=="number"||typeof I!=="number"||!Number.isFinite(p)||!Number.isFinite(I)||I<=0)continue;m.node.x=p-d/2,m.node.width=I+d,m.node.groupTitleRect={...m.rect,left:m.rect.left-d,right:m.rect.right-d}}}e(je,"shiftLeftLaneTitleBandsLeftOfRails");function Ms(t,n){let{realNodeRects:i}=bn(n.values()),c=t.filter((l)=>!l.isLayoutOnly),a=e((l,x=new Map)=>yt(x.get(l)??l.points??[]),"replacementPointsFor"),u=e((l=new Map)=>{let x=0;for(let L=0;L<c.length;L++){let S=at(a(c[L],l));for(let E=L+1;E<c.length;E++){let w=at(a(c[E],l));for(let C of S)for(let b of w)if(un(C.a,C.b,b.a,b.b,tt))x++}}return x},"crossingCount"),h=e((l=new Map)=>c.reduce((x,L)=>x+nn(a(L,l)),0),"totalBends"),d=e((l)=>{let x=a(l);if(x.length<4)return;let L=x[x.length-2],S=x[x.length-1];if(!Tt(L,S,tt)&&!wt(L,S,tt))return;return{tailStart:L,terminal:S}},"terminalTailFor"),m=e((l,x)=>{let L=a(l);if(L.length<3)return;let S=L[0],E=L[1],w;if(Tt(S,E,tt))w={x:E.x,y:x.tailStart.y};else if(wt(S,E,tt))w={x:x.tailStart.x,y:E.y};else return;let C=dn(yt([S,E,w,x.tailStart,x.terminal]));return at(C).length===C.length-1?C:void 0},"candidateWithDestinationTail"),p=e((l,x)=>{let L=[l.start,l.end].filter((S)=>Boolean(S));for(let S of at(x))if(Nt(S.a,S.b,i,L,-2))return!0;return!1},"pathHasNodeHit"),I=e((l,x,L)=>{for(let S of c){if(S===l)continue;for(let E of at(x))for(let w of at(a(S,L)))if(fn(E,w,0.5)>=Ht)return!0}return!1},"pathHasSharedTrack"),y=e((l,x,L)=>!p(l,x)&&!I(l,x,L),"candidateIsSafe"),g=e(()=>{let l=new Map;for(let x of c){let L=x.end;if(!L||!n.has(L))continue;if(a(x).length<4)continue;let E=l.get(L)??[];E.push(x),l.set(L,E)}return l},"edgesByDestination");for(let l=0;l<4;l++){let x=u();if(x===0)return;let L=h(),S,E=x,w=L;for(let C of g().values())for(let b=0;b<C.length;b++)for(let R=b+1;R<C.length;R++){let O=C[b],P=C[R],N=d(O),H=d(P);if(!N||!H)continue;let _=m(O,H),F=m(P,N);if(!_||!F)continue;let Y=new Map([[O,_],[P,F]]);if(!y(O,_,Y)||!y(P,F,Y))continue;let V=u(Y),J=h(Y);if(V>=x)continue;if(V>E||V===E&&J>=w)continue;S=Y,E=V,w=J}if(!S)return;for(let[C,b]of S)C.points=b}}e(Ms,"swapDestinationTerminalTailsToReduceCrossings");function Is(t,n){let{realNodeRects:a,labelNodeRects:u}=bn(n.values()),h=t.filter((C)=>!C.isLayoutOnly),d=e((C,b=new Map)=>yt(b.get(C)??C.points??[]),"replacementPointsFor"),m=e((C=new Map)=>{let b=0;for(let R=0;R<h.length;R++){let O=at(d(h[R],C));for(let P=R+1;P<h.length;P++){let N=at(d(h[P],C));for(let H of O)for(let _ of N)if(un(H.a,H.b,_.a,_.b,tt))b++}}return b},"strictCrossingCount"),p=e((C=new Map)=>h.reduce((b,R)=>b+nn(d(R,C)),0),"totalBends"),I=e((C)=>{let{start:b,end:R}=C,O=b?n.get(b):void 0,P=R?n.get(R):void 0,N=O?Zt(O):void 0,H=P?Zt(P):void 0;return N&&H?{src:N,dst:H}:void 0},"endpointRectsFor"),y=e((C,b,R)=>{if(R.index<=0||R.index+1>=b.length-1)return;let O=I(C);if(!O)return;if(R.vertical){let P=R.a.x,N=Math.min(O.src.left,O.dst.left),H=Math.max(O.src.right,O.dst.right),_=P<N-tt?"left":P>H+tt?"right":void 0;if(!_)return;return{edge:C,points:b,segmentIndex:R.index,axis:"vertical",side:_,coord:P,min:Math.min(R.a.y,R.b.y),max:Math.max(R.a.y,R.b.y)}}if(R.horizontal){let P=R.a.y,N=Math.min(O.src.top,O.dst.top),H=Math.max(O.src.bottom,O.dst.bottom),_=P<N-tt?"top":P>H+tt?"bottom":void 0;if(!_)return;return{edge:C,points:b,segmentIndex:R.index,axis:"horizontal",side:_,coord:P,min:Math.min(R.a.x,R.b.x),max:Math.max(R.a.x,R.b.x)}}return},"externalRailForSegment"),g=e(()=>{let C=[];for(let b of h){let R=d(b);for(let O of at(R)){let P=y(b,R,O);if(P)C.push(P)}}return C},"collectExternalRails"),l=e((C,b)=>C.edge!==b.edge&&C.axis===b.axis&&C.side===b.side&&Ut(C.min,C.max,b.min,b.max)>=Ht,"railsInteract"),x=e((C)=>{let b=[],R=new Set;for(let O of C){if(R.has(O))continue;let P=[O],N=[];R.add(O);while(P.length>0){let H=P.pop();N.push(H);for(let _ of C)if(!R.has(_)&&l(H,_))R.add(_),P.push(_)}if(N.length>1)b.push(N)}return b},"connectedComponents"),L=e((C)=>{let b=[];for(let R of C)if(!b.some((O)=>Math.abs(O-R.coord)<tt))b.push(R.coord);while(b.length<C.length){let R=Math.min(...b),O=Math.max(...b),P=C[0].side;b.push(P==="left"||P==="top"?R-12*(C.length-b.length):O+12*(C.length-b.length))}return b},"uniqueCoordsFor"),S=e((C)=>{let b=C.map((P)=>P.coord),R=L(C),O=[];if(C.length<=6){let P=Array(R.length).fill(!1),N=[],H=e(()=>{if(N.length===C.length){if(N.some((_,F)=>Math.abs(_-b[F])>=tt))O.push([...N]);return}for(let[_,F]of R.entries()){if(P[_])continue;P[_]=!0,N.push(F),H(),N.pop(),P[_]=!1}},"visit");return H(),O}for(let P=0;P<b.length;P++)for(let N=P+1;N<b.length;N++){let H=[...b];[H[P],H[N]]=[H[N],H[P]],O.push(H)}return O},"coordinateAssignmentsFor"),E=e((C,b)=>{let R=new Map;for(let[P,N]of C.entries()){let H=b[P],_=R.get(N.edge)??N.points.map((F)=>({x:F.x,y:F.y}));if(N.axis==="vertical")_[N.segmentIndex].x=H,_[N.segmentIndex+1].x=H;else _[N.segmentIndex].y=H,_[N.segmentIndex+1].y=H;R.set(N.edge,_)}let O=new Map;for(let[P,N]of R){let H=dn(yt(N));if(at(H).length!==H.length-1)return;O.set(P,H)}return O},"replacementsForAssignment"),w=e((C)=>{for(let[b,R]of C){let O=[b.start,b.end].filter((P)=>Boolean(P));for(let P of at(R)){if(Nt(P.a,P.b,a,O,-2))return!1;if(Nt(P.a,P.b,u,[],-2))return!1}}for(let b=0;b<h.length;b++){let R=h[b],O=C.has(R),P=at(d(R,C));for(let N=b+1;N<h.length;N++){let H=h[N];if(!O&&!C.has(H))continue;let _=at(d(H,C));for(let F of P)for(let Y of _)if(fn(F,Y,0.5)>=Ht)return!1}}return!0},"candidateIsSafe");for(let C=0;C<4;C++){let b=m();if(b===0)return;let R,O=b,P=p(),N=Number.POSITIVE_INFINITY;for(let H of x(g()))for(let _ of S(H)){let F=E(H,_);if(!F||!w(F))continue;let Y=m(F);if(Y>=b)continue;let V=p(F),J=H.reduce((lt,xt,Ot)=>lt+Math.abs(_[Ot]-xt.coord),0);if(Y>O||Y===O&&(V>P||V===P&&J>=N))continue;R=F,O=Y,P=V,N=J}if(!R)return;for(let[H,_]of R)H.points=_}}e(Is,"reassignCrossingExternalRailChannels");function Ss(t,n){let{realNodeRects:i,labelNodeRects:c}=bn(n.values()),a=t.filter((g)=>!g.isLayoutOnly),u=e((g,l,x)=>yt(g===l?x??[]:g.points??[]),"pointsFor"),h=e((g)=>at(g).reduce((l,x)=>{let L=x.a.x-x.b.x,S=x.a.y-x.b.y;return l+Math.hypot(L,S)},0),"pathLength"),d=e((g,l)=>{let x=0;for(let L=0;L<a.length;L++){let S=at(u(a[L],g,l));for(let E=L+1;E<a.length;E++){let w=at(u(a[E],g,l));for(let C of S)for(let b of w)if(un(C.a,C.b,b.a,b.b,tt))x++}}return x},"strictCrossingCount"),m=e((g,l)=>{if(g.horizontal){let x=g.a.y;return(Math.abs(x-l.top)<1||Math.abs(x-l.bottom)<1)&&Ut(g.a.x,g.b.x,l.left,l.right)>=Ht}if(g.vertical){let x=g.a.x;return(Math.abs(x-l.left)<1||Math.abs(x-l.right)<1)&&Ut(g.a.y,g.b.y,l.top,l.bottom)>=Ht}return!1},"segmentRunsAlongRectBorder"),p=e((g)=>{let l=[g.start,g.end].filter((L)=>Boolean(L)),x=[];for(let L of l){let S=n.get(L),E=S?Zt(S):void 0;if(E)x.push(E)}return x},"endpointRectsFor"),I=e((g,l)=>{if(l+3>=g.length)return[];let x=g[l],L=g[l+1],S=g[l+2],E=g[l+3],w=Tt(x,L,tt)&&wt(L,S,tt)&&Tt(S,E,tt),C=wt(x,L,tt)&&Tt(L,S,tt)&&wt(S,E,tt);if(!w&&!C)return[];if(!(w?Math.sign(L.x-x.x)!==Math.sign(E.x-S.x):Math.sign(L.y-x.y)!==Math.sign(E.y-S.y)))return[];let R=ht(x,E,tt)||pt(x,E,tt)?[]:[{x:x.x,y:E.y},{x:E.x,y:x.y}],O=R.length===0?[[...g.slice(0,l+1),...g.slice(l+3)]]:R.map((N)=>[...g.slice(0,l+1),N,...g.slice(l+3)]),P=new Set;return O.map((N)=>dn(yt(N))).filter((N)=>{if(at(N).length!==N.length-1)return!1;if(!N.some((_)=>rn(_,E,tt)))return!1;let H=N.map((_)=>`${_.x.toFixed(3)},${_.y.toFixed(3)}`).join("|");if(P.has(H))return!1;return P.add(H),!0})},"shortcutCandidatesAt"),y=e((g,l,x)=>{let L=[g.start,g.end].filter((E)=>Boolean(E)),S=p(g);for(let E of at(l)){if(Nt(E.a,E.b,i,L,-2))return!1;if(Nt(E.a,E.b,c,[],-2))return!1;if(S.some((w)=>m(E,w)))return!1}for(let E of a){if(E===g)continue;for(let w of at(l))for(let C of at(u(E)))if(fn(w,C,0.5)>=Ht)return!1}return d(g,l)<=x},"candidateIsSafe");for(let g=0;g<8;g++){let l=d(),x,L,S=l,{POSITIVE_INFINITY:E,POSITIVE_INFINITY:w}=Number;for(let C of a){let b=u(C),R=nn(b,tt),O=h(b);for(let P=0;P<=b.length-4;P++)for(let N of I(b,P)){let H=nn(N,tt),_=h(N);if(!(H<R||H===R&&_<O-tt)||!y(C,N,l))continue;let Y=d(C,N);if(Y>S||Y===S&&(H>E||H===E&&_>=w))continue;x=C,L=N,S=Y,E=H,w=_}}if(!x||!L)return;x.points=L}}e(Ss,"shortcutRedundantOrthogonalJogs");function Cs(t,n){let a=[];for(let B of n.values()){if(B.isGroup||B.isEdgeLabel)continue;let D=B.x??0,X=B.y??0,W=Zt(B);if(!W)continue;a.push({id:String(B.id??""),cx:D,cy:X,rect:W})}if(a.length===0)return;let u=new Map(a.map((B)=>[B.id,B])),h=a.map((B)=>({id:B.id,rect:B.rect})),d=["top","bottom","left","right"],m={top:Math.min(...a.map((B)=>B.rect.top))-20,bottom:Math.max(...a.map((B)=>B.rect.bottom))+20,left:Math.min(...a.map((B)=>B.rect.left))-20,right:Math.max(...a.map((B)=>B.rect.right))+20},p=t.filter((B)=>!B.isLayoutOnly),I=new Map(p.map((B,D)=>[B,D])),y=e((B)=>{let D=B==="left"||B==="top"?-1:1,X=[];for(let W=0;W<=2;W++)X.push(m[B]+D*20*W);return X},"outwardTracksForSide"),g=e((B,D=new Map)=>yt(D.get(B)??B.points??[]),"replacementPointsFor"),l=e((B,D)=>{let X=0;for(let W of B)for(let f of D)if(un(W.a,W.b,f.a,f.b,tt))X++;return X},"crossingCountBetweenSegments"),x=e((B,D)=>l(at(B),at(D)),"crossingCountBetweenPaths"),L=e((B=new Map)=>{let D=0,X=[],W=new Set,f=[],M=e((v)=>{if(!W.has(v))W.add(v),f.push(v)},"addEdge");for(let v=0;v<p.length;v++){let A=p[v],T=g(A,B);for(let k=v+1;k<p.length;k++){let K=p[k],Q=x(T,g(K,B));if(Q>0)D+=Q,X.push({first:A,second:K,count:Q}),M(A),M(K)}}return f.sort((v,A)=>(I.get(v)??0)-(I.get(A)??0)),{count:D,pairs:X,edgeSet:W,edges:f}},"crossingSnapshot"),S=e((B,D)=>{let X=new Set(D.keys());if(X.size===0)return B.count;let W=0;for(let M of B.pairs)if(X.has(M.first)||X.has(M.second))W+=M.count;let f=0;for(let M=0;M<p.length;M++){let v=p[M],A=X.has(v),T=g(v,D);for(let k=M+1;k<p.length;k++){let K=p[k];if(!A&&!X.has(K))continue;f+=x(T,g(K,D))}}return B.count-W+f},"crossingCountWithReplacements"),E=e((B)=>{let D=new Map;for(let f of B.pairs){let M=D.get(f.first)??new Set;M.add(f.second),D.set(f.first,M);let v=D.get(f.second)??new Set;v.add(f.first),D.set(f.second,v)}let X=[],W=new Set;for(let f of B.edges){if(W.has(f))continue;let M=[f],v=[];W.add(f);while(M.length>0){let A=M.pop();v.push(A);for(let T of D.get(A)??[])if(!W.has(T))W.add(T),M.push(T)}if(v.sort((A,T)=>(I.get(A)??0)-(I.get(T)??0)),v.length>1)X.push(v)}return X},"crossingComponents"),w=e((B)=>[B.start,B.end].filter((D)=>Boolean(D)),"endpointIdsFor"),C=e((B)=>{let D=[];for(let X of E(B)){let W=new Set(X),f=new Set(X.flatMap((v)=>w(v))),M=[...X];for(let v of p){if(W.has(v))continue;if(w(v).some((A)=>f.has(A)))M.push(v)}M.sort((v,A)=>(I.get(v)??0)-(I.get(A)??0)),D.push(M)}return D},"pairSearchGroups"),b=e((B,D,X)=>S(B,new Map([[D,X]])),"crossingCountWithSingleReplacement"),R=e((B)=>{let D=new Map;for(let X of B.pairs)D.set(X.first,(D.get(X.first)??0)+X.count),D.set(X.second,(D.get(X.second)??0)+X.count);return D},"currentCrossingsByEdge"),O=e((B)=>B.slice(1).reduce((D,X,W)=>{let f=B[W];return D+Math.abs(X.x-f.x)+Math.abs(X.y-f.y)},0),"pathLength"),P=e((B=new Map)=>p.reduce((D,X)=>D+nn(g(X,B)),0),"totalBends"),N=e((B=new Map)=>p.reduce((D,X)=>D+O(g(X,B)),0),"totalLength"),H=e((B,D,X=new Map)=>{let W=at(D);for(let f of p){if(f===B)continue;for(let M of W)for(let v of at(g(f,X)))if(fn(M,v,0.5)>=Ht)return!0}return!1},"pathHasSegmentConflict"),_=e((B,D)=>{let X=[B.start,B.end].filter((W)=>Boolean(W));for(let W of at(D))if(Nt(W.a,W.b,h,X,-2))return!0;return!1},"pathHitsNode"),F=e((B,D)=>{let X=dn(yt(D));if(at(X).length===X.length-1)B.push(X)},"pushOrthogonalCandidate"),Y=e((B)=>B==="left"||B==="right","sideIsHorizontal"),V=e((B,D,X)=>{switch(D){case"left":return Math.min(B.x,X.x)-20;case"right":return Math.max(B.x,X.x)+20;case"top":return Math.min(B.y,X.y)-20;case"bottom":return Math.max(B.y,X.y)+20}},"localTrackForSameSide"),J=e((B,D,X,W)=>{let f=X==="left"||X==="top"?-1:1,M=[V(D,X,W),m[X]];for(let v of M)for(let A=0;A<=2;A++)F(B,go(D,X,W,v+f*20*A))},"addSameSideCandidates"),lt=e((B,D,X,W,f)=>{for(let M of y(X))for(let v of y(f))F(B,[D,{x:M,y:D.y},{x:M,y:v},{x:W.x,y:v},W])},"addHorizontalToVerticalCandidates"),xt=e((B,D,X,W,f)=>{for(let M of y(X))for(let v of y(f))F(B,[D,{x:D.x,y:M},{x:v,y:M},{x:v,y:W.y},W])},"addVerticalToHorizontalCandidates"),Ot=e((B,D,X,W,f)=>{let M=[...y("top"),...y("bottom")];for(let v of y(X))for(let A of y(f))for(let T of M)F(B,[D,{x:v,y:D.y},{x:v,y:T},{x:A,y:T},{x:A,y:W.y},W])},"addHorizontalPairCandidates"),kt=e((B,D,X,W,f)=>{let M=[...y("left"),...y("right")];for(let v of y(X))for(let A of y(f))for(let T of M)F(B,[D,{x:D.x,y:v},{x:T,y:v},{x:T,y:A},{x:W.x,y:A},W])},"addVerticalPairCandidates"),nt=e((B)=>{let D=new Set;return B.map((X)=>yt(X)).filter((X)=>{let W=X.map((f)=>`${f.x.toFixed(3)},${f.y.toFixed(3)}`).join("|");if(D.has(W)||X.length<2)return!1;return D.add(W),!0})},"dedupeCandidatePaths"),q=e((B,D,X,W)=>{let f=[],M=ho(B,D,X,W,20,tt);if(M)F(f,M);if(D===W)J(f,B,D,X);let v=Y(D),A=Y(W);if(v&&!A)lt(f,B,D,X,W);else if(!v&&A)xt(f,B,D,X,W);else if(v)Ot(f,B,D,X,W);else kt(f,B,D,X,W);return nt(f)},"buildCandidatesForSides"),ot=e((B,D,X,W)=>{let f=[...y("left"),...y("right")],M=[...y("top"),...y("bottom")];for(let v of d){let A=vn(W,v),T=v==="top"||v==="bottom"?y(v):M;for(let k of f){F(B,[D,X,{x:k,y:X.y},{x:k,y:A.y},A]);for(let K of T)F(B,[D,X,{x:k,y:X.y},{x:k,y:K},{x:A.x,y:K},A])}}},"addVerticalDepartureOuterTrackCandidates"),dt=e((B,D,X,W)=>{let f=[...y("left"),...y("right")],M=[...y("top"),...y("bottom")];for(let v of d){let A=vn(W,v),T=v==="left"||v==="right"?y(v):f;for(let k of M){F(B,[D,X,{x:X.x,y:k},{x:A.x,y:k},A]);for(let K of T)F(B,[D,X,{x:X.x,y:k},{x:K,y:k},{x:K,y:A.y},A])}}},"addHorizontalDepartureOuterTrackCandidates"),mt=e((B)=>{let{start:D,end:X}=B,W=X?u.get(X):void 0;if(!D||!W)return[];let f=yt(B.points??[]);if(f.length<4)return[];let M=f[0],v=f[1],A=[];if(wt(M,v,tt))ot(A,M,v,W);else if(Tt(M,v,tt))dt(A,M,v,W);return A},"terminalPreservingOuterTrackCandidates"),Mt=e((B)=>{let{start:D,end:X}=B,W=D?u.get(D):void 0,f=X?u.get(X):void 0;if(!W||!f)return[];let M=[];for(let v of d){let A=vn(W,v);for(let T of d)M.push(...q(A,v,vn(f,T),T))}return M.push(...mt(B)),M},"candidatePathsFor"),Et=e(()=>new Map(p.map((B)=>[B,at(g(B))])),"currentSegmentsByEdge"),jt=e((B,D,X)=>{let W=new Set;for(let f of p){if(f===B)continue;let M=X.get(f)??at(g(f));if(D.some((v)=>M.some((A)=>fn(v,A,0.5)>=Ht)))W.add(f)}return W},"sharedTrackConflictsFor"),Wt=e((B,D,X,W)=>{let f=new Set;return Mt(B).map((v)=>dn(yt(v))).filter((v)=>{if(_(B,v))return!1;let A=v.map((T)=>`${T.x.toFixed(3)},${T.y.toFixed(3)}`).join("|");if(f.has(A)||v.length<2)return!1;return f.add(A),!0}).map((v)=>{let A=at(v),T=0;for(let k of p){if(k===B)continue;T+=l(A,X.get(k)??at(g(k)))}return{candidate:v,candidateSegments:A,crossings:D.count-(W.get(B)??0)+T,bends:nn(v,tt),totalBends:nn(v),length:O(v)}}).filter(({crossings:v})=>v<=D.count).sort((v,A)=>v.crossings-A.crossings||v.bends-A.bends||v.length-A.length).slice(0,48).map((v)=>({path:v.candidate,segments:v.candidateSegments,sharedTrackConflicts:jt(B,v.candidateSegments,X),totalBends:v.totalBends,length:v.length}))},"pairCandidatesFor"),Kt=e((B,D,X,W,f,M)=>{let v=0;for(let T of B.pairs)if(T.first===D||T.second===D||T.first===W||T.second===W)v+=T.count;let A=l(X.segments,f.segments);for(let T of p){if(T===D||T===W)continue;let k=M.get(T)??at(g(T));A+=l(X.segments,k)+l(f.segments,k)}return B.count-v+A},"pairCrossingCount"),en=e((B,D)=>{for(let X of B.sharedTrackConflicts)if(X!==D)return!1;return!0},"conflictsOnlyWith"),Ln=e((B,D)=>B.segments.some((X)=>D.segments.some((W)=>fn(X,W,0.5)>=Ht)),"candidatesShareTrack"),gn=e((B,D,X,W)=>en(D,X.edge)&&en(W,B.edge)&&!Ln(D,W),"pairCandidatesAreCompatible"),En=e((B,D,X,W,f)=>{let M=Kt(B.current,D.edge,X,W.edge,f,B.baseSegments);if(M>=B.current.count)return;return{replacements:new Map([[D.edge,X.path],[W.edge,f.path]]),crossings:M,bends:B.currentBends-(B.baseBendsByEdge.get(D.edge)??0)-(B.baseBendsByEdge.get(W.edge)??0)+X.totalBends+f.totalBends,length:B.currentLength-(B.baseLengthByEdge.get(D.edge)??0)-(B.baseLengthByEdge.get(W.edge)??0)+X.length+f.length}},"scorePairReplacement"),he=e((B,D)=>B.crossings<D.crossings||B.crossings===D.crossings&&(B.bends<D.bends||B.bends===D.bends&&B.length<D.length),"pairScoreIsBetter"),ge=e((B,D,X,W)=>{let f=W;for(let M of D.candidates)for(let v of X.candidates){if(!gn(D,M,X,v))continue;let A=En(B,D,M,X,v);if(A&&he(A,f))f=A}return f},"bestScoreForOptionPair"),pe=e((B)=>{let D=P(),X=N(),W=Et(),f=R(B),M=new Map(p.map((Q)=>[Q,nn(g(Q))])),v=new Map(p.map((Q)=>[Q,O(g(Q))])),A=new Map,T=C(B);for(let Q of T)for(let j of Q){if(A.has(j))continue;let z=Wt(j,B,W,f);if(z.length>0)A.set(j,{edge:j,candidates:z})}let k={replacements:new Map,crossings:B.count,bends:D,length:X},K={current:B,currentBends:D,currentLength:X,baseBendsByEdge:M,baseLengthByEdge:v,baseSegments:W};for(let Q of T){let j=new Set(Q.filter((rt)=>B.edgeSet.has(rt))),z=Q.map((rt)=>A.get(rt)).filter((rt)=>Boolean(rt));for(let rt=0;rt<z.length;rt++){let ct=z[rt];for(let it=rt+1;it<z.length;it++){let et=z[it];if(!j.has(ct.edge)&&!j.has(et.edge))continue;k=ge(K,ct,et,k)}}}return k.replacements.size>0?k.replacements:void 0},"bestPairedReplacement");for(let B=0;B<4;B++){let D=L(),X=D.count;if(X===0)return;let W,f,M=X,v=Number.POSITIVE_INFINITY;for(let T of D.edges){let k=nn(g(T),tt);for(let K of Mt(T)){let Q=_(T,K),j=!Q&&H(T,K),z=b(D,T,K),rt=nn(K,tt);if(Q||j)continue;if(!(z<X||z===X&&rt<k))continue;if(z>M||z===M&&rt>=v)continue;W=T,f=K,M=z,v=rt}}if(W&&f){W.points=f;continue}let A=pe(D);if(!A)return;for(let[T,k]of A)T.points=k}}e(Cs,"resolveRenderedOrthogonalCrossings");var xn=0.001,Pr=8;function vs(t,n){let{nodeInfoById:o,realNodeRects:s}=le(n),i=["top","bottom","left","right"],c=20,a={top:Math.min(...s.map((l)=>l.rect.top))-20,bottom:Math.max(...s.map((l)=>l.rect.bottom))+20,left:Math.min(...s.map((l)=>l.rect.left))-20,right:Math.max(...s.map((l)=>l.rect.right))+20},u=e((l,x,L,S)=>{let E=[],w=ho(l,x,L,S,20,xn);if(w)E.push(w);if(x===S)E.push(go(l,x,L,a[x]));return E},"buildOrthogonalPathCandidates"),h=e((l,x)=>{for(let L=0;L<l.length-1;L++){let S=l[L],E=l[L+1];if(Nt(S,E,s,x,1))return!0}return!1},"pathHitsNode"),d=e((l,x,L=!1)=>{let S=0,E=Bn(l,xn),{start:w,end:C}=x;for(let b of t){if(b===x||b.isLayoutOnly)continue;let{start:R,end:O}=b;if(!L&&w&&C&&(R===w||R===C||O===w||O===C))continue;let P=b.points;if(!P||P.length<2)continue;for(let N of E)for(let H of Bn(P,xn)){if(mo(N.a,N.b,H.a,H.b,xn,xn)){S++;continue}if(fn(N,H,xn)>=Pr)S++}}return S},"pathConflictCount"),m=4,p=e((l,x)=>{let L=Math.abs(l.y-x.rect.top),S=Math.abs(l.y-x.rect.bottom),E=Math.abs(l.x-x.rect.left),w=Math.abs(l.x-x.rect.right),C="top",b=L;if(S<b)C="bottom",b=S;if(E<b)C="left",b=E;if(w<b)C="right",b=w;return C},"nearestSideOfRect"),I=new Map,y=e((l,x,L)=>{let S=I.get(l)??[];S.push({side:x,edgeId:L}),I.set(l,S)},"addFaceClaim");for(let l of t){if(l.isLayoutOnly)continue;let x=l.points??[];if(x.length<1)continue;let L=l.id??"",{start:S,end:E}=l;if(S){let w=o.get(S);if(w)y(S,p(x[0],w),L)}if(E){let w=o.get(E);if(w)y(E,p(x[x.length-1],w),L)}}let g=e((l,x,L)=>I.get(l)?.some((S)=>S.edgeId!==L&&S.side===x)??!1,"faceIsClaimed");for(let l of t){if(l.isLayoutOnly)continue;let x=l.points;if(!x||x.length<2)continue;let L=nn(x,xn);if(L<4)continue;let{start:S,end:E}=l;if(!S||!E)continue;let w=o.get(S),C=o.get(E);if(!w||!C)continue;let b=l.id??"",R=d(x,l,!0),O=d(x,l),P,N=R,H=L;for(let _ of i){if(g(S,_,b))continue;let F=vn(w,_);for(let Y of i){if(g(E,Y,b))continue;let V=vn(C,Y);for(let J of u(F,_,V,Y)){if(h(J,[S,E]))continue;let lt=nn(J,xn);if(R>0){let xt=d(J,l,!0);if(xt>N||xt===N&<>=H)continue;N=xt,H=lt,P=J;continue}if(d(J,l)>O)continue;if(lt<H)H=lt,P=J}}}if(P){l.points=P;let _=I.get(S);if(_)I.set(S,_.filter((Y)=>Y.edgeId!==b));let F=I.get(E);if(F)I.set(E,F.filter((Y)=>Y.edgeId!==b));y(S,p(P[0],w),b),y(E,p(P[P.length-1],C),b)}}}e(vs,"simplifyDetouredEdges");var Jt=0.001,zo=10,Kn=7;function We(t,n){let o=n?0:t.length-1,s=n?1:-1,i=t[o],c=t[o+s];if(!i||!c)return;let a=c.x-i.x,u=c.y-i.y;if(Math.abs(a)+Math.abs(u)<Jt)return;if(Math.abs(u)<=Jt){let d=i.x+Math.sign(a)*zo;return{left:Math.min(i.x,d),right:Math.max(i.x,d),top:i.y-Kn,bottom:i.y+Kn}}if(Math.abs(a)<=Jt){let d=i.y+Math.sign(u)*zo;return{left:i.x-Kn,right:i.x+Kn,top:Math.min(i.y,d),bottom:Math.max(i.y,d)}}return{left:Math.min(i.x,c.x),right:Math.max(i.x,c.x),top:Math.min(i.y,c.y),bottom:Math.max(i.y,c.y)}}e(We,"markerClearanceRectFor");function Ls(t){return{left:Math.min(t.left,t.right),right:Math.max(t.left,t.right),top:Math.min(t.top,t.bottom),bottom:Math.max(t.top,t.bottom)}}e(Ls,"normalizeRect");function Ke(t,n){let o=yt(n),s=We(o,!0),i=We(o,!1);return[s,i].some((c)=>c&&Qn(t,Ls(c)))}e(Ke,"labelOverlapsOwnMarker");function Jn(t,n){let o=[];for(let g of t){if(g.isLayoutOnly)continue;let l=g.points;if(!l||l.length<2)continue;for(let x=0;x<l.length-1;x++)o.push({edgeId:g.id,p1:l[x],p2:l[x+1]})}let s=[],i=[];for(let g of n.values()){let{isGroup:l,parentId:x}=g;if(l&&!x){let S=Zt(g);if(S)i.push({id:g.id,rect:S});continue}if(l)continue;if(g.isEdgeLabel)continue;let L=Zt(g);if(!L)continue;s.push({nodeId:g.id,rect:L})}let c=3,a=1,u=12,h=e((g,l)=>{let x=we(l,c);for(let{nodeId:L,rect:S}of s){if(L===g)continue;if(Qn(x,S))return!0}return!1},"labelOverlapsForeignNode"),d=e((g,l)=>{let x=we(l,c);for(let L of o){if(L.edgeId===g)continue;if(ae(L.p1,L.p2,x))return!0}return!1},"labelOverlapsForeignEdge"),m=e((g,l,x)=>h(g,x)||d(l,x),"labelOverlapsAnything"),p=[],I=e((g)=>{for(let{id:l,rect:x}of i)if(Qo(x,g))return l;return},"findContainingLane"),y=e((g,l)=>p.some((x)=>x.labelId!==g&&Qn(l,x.rect)),"overlapsPlacedLabel");for(let g of t){if(g.isLayoutOnly)continue;let l=g.labelNodeId;if(!l)continue;let x=n.get(l);if(!x)continue;let L=g.points;if(!L||L.length<2)continue;let S=x.width??0,E=x.height??0;if(S<=0||E<=0)continue;let w=[];for(let nt=0;nt<L.length-1;nt++){let q=L[nt],ot=L[nt+1],dt=Math.abs(q.x-ot.x),mt=Math.abs(q.y-ot.y);if(dt<Jt&&mt<Jt)continue;if(dt>=Jt&&mt>=Jt)continue;w.push({idx:nt,length:dt+mt,orientation:dt>=Jt?"horizontal":"vertical",midX:(q.x+ot.x)/2,midY:(q.y+ot.y)/2})}if(w.length===0)continue;let C=w.length>=3?w.filter((nt)=>nt.idx>0&&nt.idx<w.length-1):w,b=C.length>0?C:w,R=S>=E?"horizontal":"vertical",O=e((nt)=>[...nt].sort((q,ot)=>{let dt=q.orientation===R,mt=ot.orientation===R;if(dt!==mt)return dt?-1:1;let Mt=q.length>=(q.orientation==="horizontal"?S:E)+2,Et=ot.length>=(ot.orientation==="horizontal"?S:E)+2;if(Mt!==Et)return Mt?-1:1;return ot.length-q.length}),"rankSegments"),P=w[0],N=w[w.length-1],H=[0.5,0.25,0.75,0.05,0.95,0.15,0.85,0.1,0.9],_=e((nt,q)=>{let ot=L[nt.idx],dt=L[nt.idx+1];return{midX:ot.x+(dt.x-ot.x)*q,midY:ot.y+(dt.y-ot.y)*q}},"anchorAtT"),F=e((nt,q,ot)=>Math.min(ot,Math.max(q,nt)),"clamp"),Y=e((nt,q)=>nt.midX>=q.left-Jt&&nt.midX<=q.right+Jt&&nt.midY>=q.top-Jt&&nt.midY<=q.bottom+Jt,"pointInsideRectInclusive"),V=e((nt)=>{let q=On(nt.midX,nt.midY,S,E),ot=I(q);if(ot)return{laneId:ot,anchor:nt,rect:q};let dt=i.find(({rect:en})=>Y(nt,en));if(!dt)return;let mt=dt.rect.left+S/2+a,Mt=dt.rect.right-S/2-a,Et=dt.rect.top+E/2+a,jt=dt.rect.bottom-E/2-a;if(mt>Mt||Et>jt)return;let Wt={midX:F(nt.midX,mt,Mt),midY:F(nt.midY,Et,jt)},Kt=On(Wt.midX,Wt.midY,S,E);return Y(nt,Kt)?{laneId:dt.id,anchor:Wt,rect:Kt}:void 0},"placementForAnchor"),J=e((nt,q,ot)=>nt.orientation==="horizontal"?Math.abs(q.midX-ot.x):Math.abs(q.midY-ot.y),"distanceAlongSegment"),lt=e((nt,q)=>{let dt=(nt.orientation==="horizontal"?S/2:E/2)+u;if(nt===P){let mt=L[nt.idx];if(J(nt,q,mt)+Jt<dt)return!1}if(nt===N){let mt=L[nt.idx+1];if(J(nt,q,mt)+Jt<dt)return!1}return!0},"labelClearsTerminalEndpoints"),xt=e((nt)=>{let q=O(nt);for(let ot of q)for(let dt of H){let mt=_(ot,dt);if(!lt(ot,mt))continue;let Mt=V(mt);if(!Mt)continue;if(Ke(Mt.rect,L))continue;if(y(l,Mt.rect))continue;if(!m(l,g.id,Mt.rect))return{laneId:Mt.laneId,anchor:Mt.anchor}}return},"tryPool"),Ot=e((nt,q,ot=!1)=>{let dt=O(nt);for(let mt of dt){let Mt={midX:mt.midX,midY:mt.midY};if(q&&!lt(mt,Mt))continue;let Et=V(Mt);if(Et&&!Ke(Et.rect,L)&&!y(l,Et.rect)&&!h(l,Et.rect)&&(ot||!d(g.id,Et.rect)))return{laneId:Et.laneId,anchor:Et.anchor}}return},"findLaneContainingFallback"),kt=xt(b)??(b.length<w.length?xt(w):void 0)??Ot(w,!0)??Ot(w,!1)??Ot(w,!1,!0);if(kt){x.x=kt.anchor.midX,x.y=kt.anchor.midY,x.parentId=kt.laneId;let nt=On(kt.anchor.midX,kt.anchor.midY,S,E),q=p.findIndex((ot)=>ot.labelId===l);if(q>=0)p[q]={labelId:l,rect:nt};else p.push({labelId:l,rect:nt})}}}e(Jn,"anchorLabelsToPolyline");var Ae=0.000001,kr=8,Vo=kr/2,_r=3;function qe(t,n){return t<n?`${t}::${n}`:`${n}::${t}`}e(qe,"pairKey");function Es(t,n){let{nodeInfoById:o,realNodeRects:s}=le(n),i=new Map;for(let a of n){let u=a.id;if(a.isGroup)continue;if(a.isEdgeLabel){i.set(u,{w:a.width??0,h:a.height??0});continue}}let c=e((a,u,h,d)=>{let m=qe(u,h),p=0,I=e((y)=>{if(!y)return;let g=i.get(y);if(!g)return;let l=d==="x"?g.w/2:g.h/2;if(l>p)p=l},"consider");I(a.labelNodeId);for(let y of t){if(y===a)continue;if(y.isLayoutOnly)continue;let{start:g,end:l}=y;if(!g||!l)continue;if(qe(g,l)!==m)continue;I(y.labelNodeId)}return p>0?p+_r:0},"labelClearanceFor");for(let a of t){if(a.isLayoutOnly)continue;let u=a.points;if(!fo(u,Ae))continue;let h=po(a,o,Ae);if(!h)continue;let{srcId:d,dstId:m,srcInfo:p,dstInfo:I,collinearX:y,collinearY:g}=h;if(y===g)continue;let l,x;if(y){let C=I.cy>p.cy;l={x:p.cx,y:C?p.rect.bottom:p.rect.top},x={x:I.cx,y:C?I.rect.top:I.rect.bottom}}else{let C=I.cx>p.cx;l={x:C?p.rect.right:p.rect.left,y:p.cy},x={x:C?I.rect.left:I.rect.right,y:I.cy}}if(Nt(l,x,s,[d,m],1))continue;let S=c(a,d,m,y?"x":"y"),E=S>Vo?S:Vo,w=[0,E,-E];for(let C of w){let b={...l},R={...x};if(y){if(b.x+=C,R.x+=C,b.x<=p.rect.left||b.x>=p.rect.right)continue;if(R.x<=I.rect.left||R.x>=I.rect.right)continue}else{if(b.y+=C,R.y+=C,b.y<=p.rect.top||b.y>=p.rect.bottom)continue;if(R.y<=I.rect.top||R.y>=I.rect.bottom)continue}if(Nt(b,R,s,[d,m],1))continue;if(te(b,R,t,a,{epsilon:Ae}))continue;a.points=[b,R];break}}}e(Es,"straightenCollinearSiblingDetours");function Je(t,n){let{realNodeRects:d,labelNodeRects:m}=bn(n.values()),p=e((b,R)=>Bn(R,0.001).map((O)=>({...O,edge:b,interior:O.index>=1&&O.index<=R.length-3})),"segmentsFor"),I=e(()=>{let b=[];for(let R of t){if(R.isLayoutOnly)continue;let O=R.points;if(!O||O.length<2)continue;b.push(...p(R,yt(O)))}return b},"allSegments"),y=e((b,R)=>{if(b.horizontal&&R.horizontal)return Ut(b.a.x,b.b.x,R.a.x,R.b.x)>=8&&Math.abs(b.a.y-R.a.y)<7;if(b.vertical&&R.vertical)return Ut(b.a.y,b.b.y,R.a.y,R.b.y)>=8&&Math.abs(b.a.x-R.a.x)<7;return!1},"hasCrowdedParallelTrack"),g=e((b,R)=>{let{start:O,end:P}=b,N=p(b,R);if(N.length!==R.length-1)return!1;let H=[O,P].filter((F)=>Boolean(F)),_=b.labelNodeId?[b.labelNodeId]:[];for(let F of N){if(Nt(F.a,F.b,d,H,-2))return!1;if(Nt(F.a,F.b,m,_,-2))return!1}for(let F of t){if(F===b||F.isLayoutOnly)continue;let Y=F.points;if(!Y||Y.length<2)continue;for(let V of N)for(let J of p(F,yt(Y))){if(y(V,J))return!1;if(un(V.a,V.b,J.a,J.b,0.001))return!1}}return!0},"candidateIsSafe"),l=e((b,R)=>{let O=yt(b.edge.points??[]);if(O.length<4||b.index>=O.length-1)return;let P=O.map((N)=>({...N}));if(b.horizontal)P[b.index].y+=R,P[b.index+1].y+=R;else if(b.vertical)P[b.index].x+=R,P[b.index+1].x+=R;else return;return p(b.edge,P).length===P.length-1?P:void 0},"shiftedCandidate"),x=e((b,R)=>({x:b.x??(R.left+R.right)/2,y:b.y??(R.top+R.bottom)/2}),"nodeCenter"),L=e((b)=>{let R=b.edge,O=yt(R.points??[]);if(O.length!==4||b.index!==1)return;let P=R.start?n.get(R.start):void 0,N=R.end?n.get(R.end):void 0,H=P?Zt(P):void 0,_=N?Zt(N):void 0,F=O.slice(b.index+2);if(!P||!N||!H||!_||F.length===0)return;return{sourceCenter:x(P,H),targetCenter:x(N,_),sourceRect:H,tail:F}},"sourceDetourContextFor"),S=e((b,R,O,P,N,H)=>{let _=P.y>=O.y,F=_?N.bottom:N.top,Y=F+(_?20:-20);if(_&&b.b.y<=Y+0.001||!_&&b.b.y>=Y-0.001)return;let V=b.a.x+R;return yt([{x:O.x,y:F},{x:O.x,y:Y},{x:V,y:Y},{x:V,y:b.b.y},...H],0.001)},"verticalSourceDetour"),E=e((b,R,O,P,N,H)=>{let _=P.x>=O.x,F=_?N.right:N.left,Y=F+(_?20:-20);if(_&&b.b.x<=Y+0.001||!_&&b.b.x>=Y-0.001)return;let V=b.a.y+R;return yt([{x:F,y:O.y},{x:Y,y:O.y},{x:Y,y:V},{x:b.b.x,y:V},...H],0.001)},"horizontalSourceDetour"),w=e((b,R)=>{let O=L(b);if(!O)return;if(b.vertical)return S(b,R,O.sourceCenter,O.targetCenter,O.sourceRect,O.tail);if(b.horizontal)return E(b,R,O.sourceCenter,O.targetCenter,O.sourceRect,O.tail);return},"sourceDetourCandidate"),C=[-7,7,-14,14,-21,21];for(let b=0;b<12;b++){let R=I(),O=!1;for(let P=0;P<R.length&&!O;P++)for(let N=P+1;N<R.length&&!O;N++){let H=R[P],_=R[N];if(H.edge===_.edge||!y(H,_))continue;let F=[H,_].filter((Y)=>Y.interior);for(let Y of F){for(let V of C){let J=l(Y,V);if(J&&g(Y.edge,J)){Y.edge.points=J,O=!0;break}let lt=w(Y,V);if(lt&&g(Y.edge,lt)){Y.edge.points=lt,O=!0;break}}if(O)break}}if(!O)return}}e(Je,"nudgeSharedInteriorSubpaths");function As(t,n,o,s){let i=n.x-t.x,c=n.y-t.y,a=s.x-o.x,u=s.y-o.y,h=i*u-c*a;if(Math.abs(h)<0.0000000001)return!1;let d=o.x-t.x,m=o.y-t.y,p=(d*u-m*a)/h,I=(d*c-m*i)/h,y=0.01;return p>y&&p<1-y&&I>y&&I<1-y}e(As,"segmentsIntersect");function Rs(t){let n=t.nodes??[],o=t.edges??[],s=[];if(!o.length||!n.length)return s;let i=ts(n),c=1,a=[];for(let h of o){if(h.isLayoutOnly)continue;let d=h.points;if(!d||d.length<2)continue;let{start:m,end:p,labelNodeId:I}=h,y=h.id??`${m}->${p}`;for(let g of i){if(g.nodeId===m||g.nodeId===p)continue;if(I&&g.nodeId===I)continue;for(let l=0;l<d.length-1;l++)if(ae(d[l],d[l+1],g,-c)){s.push({type:"edge-node-overlap",edgeId:y,targetId:g.nodeId,detail:`segment ${l} passes through node "${g.nodeId}"`});break}}for(let g=0;g<d.length-1;g++)a.push({edgeId:y,start:m,end:p,p1:d[g],p2:d[g+1]})}let u=new Set;for(let h=0;h<a.length;h++)for(let d=h+1;d<a.length;d++){let m=a[h],p=a[d];if(m.edgeId===p.edgeId)continue;if(m.start===p.start||m.start===p.end||m.end===p.start||m.end===p.end)continue;if(As(m.p1,m.p2,p.p1,p.p2)){let I=m.edgeId<p.edgeId?`${m.edgeId}|${p.edgeId}`:`${p.edgeId}|${m.edgeId}`;if(!u.has(I))u.add(I),s.push({type:"edge-edge-crossing",edgeId:m.edgeId,targetId:p.edgeId,detail:`edges "${m.edgeId}" and "${p.edgeId}" cross`})}}if(s.length>0){let h=s.filter((m)=>m.type==="edge-node-overlap").length,d=s.filter((m)=>m.type==="edge-edge-crossing").length;r.warn(`[SWIMLANE_VALIDATE] ${s.length} issue(s) detected: ${h} edge-node overlap(s), ${d} edge crossing(s)`);for(let m of s)r.warn(`[SWIMLANE_VALIDATE] ${m.type}: ${m.detail}`)}return s}e(Rs,"validateSwimlanesLayout");function Ts(t,n){let o=t.nodes??[],s=t.edges??[],i=o.filter((u)=>!u.isGroup);if((n==="LR"||n==="RL")&&i.length>0&&!ps(t,n))return;if(n==="BT"&&i.length>0&&!gs(t))return;for(let u of s){if(u.isLayoutOnly)continue;let h=u.points;if(!h||h.length<2)continue;u.points=dn(ne(h))}vs(s,o),Es(s,o),ms(s,o);let c=new Map;for(let u of o)c.set(String(u.id),u);Jn(s,c),rs(s,c),ys(s,c),Je(s,c),ze(s,c),bs(s,c),Ve(s,c),Ms(s,c);let a=e(()=>{Cs(s,c),ze(s,c),Is(s,c),Ss(s,c),Jn(s,c),Ge(s,c),Ve(s,c),Jn(s,c),Ge(s,c)},"finalizeRenderedEdges");a(),Je(s,c),a(),Ue(s,c,n),je(s,c,n),Ue(s,c,n),je(s,c,n)}e(Ts,"postProcessSwimlaneLayout");function Mn(t){let n=new Map(t.nodeById),o=new Set,s=[];for(let c of t.edges){if(!n.has(c.src)||!n.has(c.dst))continue;let a=`${c.id}:${c.src}->${c.dst}`;if(o.has(a))continue;o.add(a),s.push(c)}return{nodes:[...n.keys()],edges:s,layout:t.layout,nodeById:n}}e(Mn,"normalizeGraph");function Io(t,n){return t.edges.filter((o)=>o.dst===n)}e(Io,"incoming");function ws(t){let n=new Map;for(let o of t.nodes)n.set(o,[]);for(let o of t.edges)n.get(o.src).push(o.dst);return n}e(ws,"buildSuccessorMap");function So(t){let n=ws(t);for(let o of n.values())o.sort((s,i)=>s.localeCompare(i));return n}e(So,"buildSortedSuccessorMap");function fe(t){let n=new Map;for(let o of t.nodes)n.set(o,0);for(let o of t.edges)n.set(o.dst,(n.get(o.dst)??0)+1);return n}e(fe,"buildInDegreeMap");function Co(t,n){let o=[...n.entries()].filter(([,u])=>u===0).map(([u])=>u).sort((u,h)=>u.localeCompare(h)),s=new Set(t.edges.flatMap((u)=>[u.src,u.dst])),i=e((u)=>!s.has(u)&&!t.nodeById.get(u)?.isGroup,"isUnconnected"),c=[...n.keys()].filter((u)=>n.get(u)===0&&i(u)),a=0;return o.map((u)=>i(u)?c[a++]:u)}e(Co,"sortedZeroInDegreeNodes");function de(t,n=()=>!0){let o=new Map,s=new Map;for(let i of t.nodes)o.set(i,[]),s.set(i,[]);for(let i of t.edges){if(!n(i))continue;s.get(i.src).push(i.dst),o.get(i.dst).push(i.src)}return{preds:o,succs:s}}e(de,"buildPredecessorSuccessorMaps");function vo(t,n,o,s){let i=0;for(let a of t.nodes){if(s?.skipGroups&&t.nodeById.get(a)?.isGroup)continue;i=Math.max(i,o[a]??0)}let c=Array.from({length:i+1},()=>[]);for(let a of n){if(s?.skipGroups&&t.nodeById.get(a)?.isGroup)continue;c[Math.max(0,o[a]??0)].push(a)}return c}e(vo,"buildLayersFromRanks");function _n(t){let n=fe(t),o=Co(t,n),s=[],i=So(t);while(o.length){let c=o.shift();s.push(c);for(let a of i.get(c)??[])if(n.set(a,(n.get(a)??0)-1),(n.get(a)??0)===0){let u=0;while(u<o.length&&o[u]<a)u++;o.splice(u,0,a)}}return s.length===t.nodes.length?s:null}e(_n,"topoSortIfAcyclic");function Fn(t){let n=new Map,o=0;for(let s of t)n.set(s,o),o++;return n}e(Fn,"buildLayerIndex");function Lo(t){let n=Array(t.length),o=e((s,i)=>{if(i-s<=1)return 0;let c=s+i>>1,a=o(s,c)+o(c,i),u=s,h=c,d=s;while(u<c||h<i)if(h>=i||u<c&&t[u]<=t[h])n[d++]=t[u++];else n[d++]=t[h++],a+=c-u;for(let m=s;m<i;m++)t[m]=n[m];return a},"count");return o(0,t.length)}e(Lo,"countInversions");function Ns(t){let n=Mn(t),o=new Map;for(let p of n.nodes)o.set(p,[]);for(let p of n.edges)o.get(p.src).push(p);for(let p of o.values())p.sort((I,y)=>I.dst===y.dst?I.id.localeCompare(y.id):I.dst.localeCompare(y.dst));let s=Object.create(null);for(let p of n.nodes)s[p]=0;let i=[],c=e((p)=>{s[p]=1;for(let I of o.get(p)??[]){let y=I.dst;if(s[y]===0)c(y);else if(s[y]===1)i.push(I)}s[p]=2},"dfs"),a=fe(n),u=[...n.nodes.filter((p)=>(a.get(p)??0)===0),...n.nodes.filter((p)=>(a.get(p)??0)!==0)];for(let p of u)if(s[p]===0)c(p);let h=new Set(i.map((p)=>`${p.id}:${p.src}->${p.dst}`)),d=n.edges.map((p)=>h.has(`${p.id}:${p.src}->${p.dst}`)?{id:p.id,src:p.dst,dst:p.src,weight:p.weight,ref:p.ref}:p);return{acyclic:{nodes:[...n.nodes],edges:d,layout:n.layout,nodeById:new Map(n.nodeById)},reversed:i}}e(Ns,"removeCycles_DFS");function Os(t){let n=new Map,o=e((s)=>{if(n.has(s))return n.get(s);let i=t.nodeById.get(s);if(!i)return n.set(s,null),null;let c=i.parentId;if(!c)return n.set(s,null),null;let u=o(c)??c;return n.set(s,u),u},"resolve");for(let s of t.nodes)o(s);return n}e(Os,"buildTopLaneMap");function hn(t){let n=Os(t);return(o)=>n.get(o)??null}e(hn,"createTopLaneResolver");function ue(t){let n=[];for(let o of t.layout.nodes??[])if(o.isGroup&&!o.parentId)n.push(o.id);return[...new Set(n)].reverse()}e(ue,"buildTopLaneOrder");function Eo(t,n){let o=ue(t);if(!n||n.length===0)return o;let s=new Set(o),i=new Set,c=[];for(let a of n){if(!s.has(a)||i.has(a))continue;i.add(a),c.push(a)}for(let a of o){if(i.has(a))continue;c.push(a)}return c}e(Eo,"resolveTopLaneOrder");var Hr={EPSILON:0.000001},ie={GRAVITY_ITERATIONS:8,MAX_CROSSING_OPTIMIZATION_PASSES:4,DEFAULT_COMPACT_SINGLE_INPUT:!0},Uo={DEFAULT_LAYER_GAP:100,DEFAULT_NODE_GAP:40};function Bs(t,n){let o=Mn(t),s=n?.laneOf??(()=>null),i=n?.rankHint,{preds:c}=de(o);for(let C of c.values())C.sort((b,R)=>b.localeCompare(R));let a=_n(o)??[...o.nodes].sort((C,b)=>C.localeCompare(b)),u=new Map;for(let[C,b]of a.entries())u.set(b,C);let h=new Map,d=new Map;for(let C of o.nodes)d.set(C,[]);for(let C of a){let b=(c.get(C)??[]).filter((R)=>h.has(R));if(b.length>0){let R=Fs(C,b,{laneOf:s,rankHint:i,topoIndex:u});h.set(C,R),d.get(R).push(C)}else if(!h.has(C))h.set(C,null)}for(let C of o.nodes)if(!h.has(C))h.set(C,null);let m=new Set;for(let C of o.nodes)if((h.get(C)??null)===null)m.add(C);let p=[...m].sort((C,b)=>{let R=u.get(C)??0,O=u.get(b)??0;if(R===O)return C.localeCompare(b);return R-O}),I=Ps(o),y=new Map;for(let[C,b]of I.entries())y.set(C,[...b].sort((R,O)=>R.localeCompare(O)));let g=ks(y),l=_s(y),x=new Map;for(let C of o.nodes)x.set(C,[]);for(let C of l)for(let b of C.nodes){let R=x.get(b);if(R)R.push(C.id);else x.set(b,[C.id])}let L=[],S=[],E=new Set,w=e((C)=>{if(E.has(C))return;E.add(C),L.push(C);for(let b of d.get(C)??[])w(b);S.push(C)},"walk");for(let C of p)w(C);for(let C of a)w(C);return{parent:h,children:d,roots:p,componentOf:g,blocks:l,nodeBlocks:x,adjacency:y,preorder:L,postorder:S,topologicalOrder:a}}e(Bs,"buildDrivingTree");function Fs(t,n,o){let s=o.laneOf(t);return[...n].sort((c,a)=>{let u=o.laneOf(c),h=o.laneOf(a),d=u!=null&&u===s,m=h!=null&&h===s;if(d!==m)return d?-1:1;let p=o.rankHint?.[c],I=o.rankHint?.[a];if(p!=null&&I!=null&&p!==I)return I-p;let y=o.topoIndex.get(c)??0,g=o.topoIndex.get(a)??0;if(y!==g)return y-g;return c.localeCompare(a)})[0]}e(Fs,"chooseParent");function Ps(t){let n=new Map;for(let o of t.nodes)n.set(o,new Set);for(let o of t.edges)n.get(o.src).add(o.dst),n.get(o.dst).add(o.src);return n}e(Ps,"buildAdjacency");function ks(t){let n=new Map,o=0;for(let s of t.keys()){if(n.has(s))continue;let i=[s];while(i.length>0){let c=i.pop();if(n.has(c))continue;n.set(c,o);for(let a of t.get(c)??[])if(!n.has(a))i.push(a)}o++}return n}e(ks,"assignComponents");function _s(t){let n=new Map,o=new Map,s=[],i=[],c=0,a=e((u,h)=>{n.set(u,++c),o.set(u,c);for(let d of t.get(u)??[]){if(d===h)continue;if(!n.has(d)){if(s.push([u,d]),a(d,u),o.set(u,Math.min(o.get(u)??c,o.get(d)??c)),(o.get(d)??0)>=(n.get(u)??0))i.push(Hs(u,d,s,i.length))}else if((n.get(d)??0)<(n.get(u)??0))s.push([u,d]),o.set(u,Math.min(o.get(u)??c,n.get(d)??c))}},"visit");for(let u of t.keys())if(!n.has(u))a(u,null);return i}e(_s,"computeBlocks");function Hs(t,n,o,s){let i=[],c=new Set;while(o.length>0){let a=o.pop();if(i.push(a),c.add(a[0]),c.add(a[1]),a[0]===t&&a[1]===n||a[0]===n&&a[1]===t)break}return{id:s,edges:i,nodes:[...c]}}e(Hs,"popBlock");function Ds(t,n,o){let s=[...t.nodes],i=new Map;for(let[S,E]of s.entries())i.set(E,S);let c=s.length,a=Array(c).fill(-1),u=Array(c).fill(0),h=[],d=new Set;for(let S of s){let E=o.parent.get(S)??null,w=i.get(S);if(w==null)continue;if(E==null){if(a[w]=-1,u[w]=0,!d.has(S))d.add(S),h.push(S)}}while(h.length>0){let S=h.shift(),E=i.get(S);if(E==null)continue;let w=o.children.get(S)??[];for(let C of w){if(d.has(C))continue;let b=i.get(C);if(b==null)continue;a[b]=E,u[b]=u[E]+1,d.add(C),h.push(C)}}for(let S of s){if(d.has(S))continue;let E=i.get(S);if(E==null)continue;a[E]=-1,u[E]=0,d.add(S)}let m=Math.max(1,Math.ceil(Math.log2(Math.max(1,c)))+1),p=Array.from({length:m},()=>Array(c).fill(-1));for(let S=0;S<c;S++)p[0][S]=a[S];for(let S=1;S<m;S++)for(let E=0;E<c;E++){let w=p[S-1][E];p[S][E]=w===-1?-1:p[S-1][w]}let I=e((S,E)=>{if(S===-1||E===-1)return-1;if(u[S]<u[E])[S,E]=[E,S];let w=u[S]-u[E];for(let C=0;C<m;C++)if(w>>C&1){if(S=p[C][S],S===-1)return-1}if(S===E)return S;for(let C=m-1;C>=0;C--){let b=p[C][S],R=p[C][E];if(b===-1||R===-1)continue;if(b!==R)S=b,E=R}return p[0][S]},"lcaIndex"),y=Array.from({length:c},()=>new Map);for(let S of t.edges){let{src:E,dst:w}=S,C=n[E],b=n[w];if(C==null||b==null)continue;if(C>b)[E,w]=[w,E],[C,b]=[b,C];if(C==null||b==null||C===b)continue;let R=i.get(E),O=i.get(w);if(R==null||O==null)continue;let P=I(R,O);if(P===-1)continue;let N=y[P];for(let H=C;H<b;H++)N.set(H,(N.get(H)??0)+1)}let g=new Map,l=e((S,E)=>{if(E.size===0)return;for(let[w,C]of E)S.set(w,(S.get(w)??0)+C)},"mergeInto"),x=new Set,L=e((S)=>{let E=i.get(S);x.add(S);let w=E==null?void 0:y[E],C=w?new Map(w):new Map,b=o.children.get(S)??[];for(let R of b){let O=L(R),P=n[S];if(P!=null){let N=g.get(S);if(!N)N=new Map,g.set(S,N);let H=O.get(P)??0,_=n[R];if(_!=null&&_>P)H+=1;N.set(R,H)}l(C,O)}return C},"dfs");for(let S of o.roots)if(!x.has(S))L(S);for(let S of s)if(!x.has(S))L(S);return g}e(Ds,"computeSubtreeCrossCounts");function Xs(t,n,o){let s=new Map,i=e((c)=>{let a=o[c]??0,u=[...n.get(c)??[]];u.sort(Ao(o));for(let h of u){i(h);let d=s.get(h);if(d!=null)a=Math.min(a,d)}s.set(c,a)},"annotate");for(let c of t)i(c);return s}e(Xs,"annotateMinimumLayers");function Ao(t){return(n,o)=>{let s=t[n]??0,i=t[o]??0;return s===i?n.localeCompare(o):s-i}}e(Ao,"compareByRankThenId");function Ys(t,n,o,s){let i=0;for(let h of n){let d=o[h]??0;if(d>i)i=d}let c=Array.from({length:i+1},()=>[]),a=new Set,u=e((h)=>{if(a.has(h))return;a.add(h);let d=o[h]??0;if(!c[d])c[d]=[];c[d].push(h);for(let m of s(h))u(m)},"emit");for(let h of t)u(h);for(let h of n)if(!a.has(h)){let d=o[h]??0;if(!c[d])c[d]=[];c[d].push(h),a.add(h)}return c}e(Ys,"emitNodesInTreeOrder");function Gs(t){let n=[];for(let o of t){let s=new Set,i=[];for(let c of o){if(s.has(c))continue;s.add(c),i.push(c)}n.push(i)}return n}e(Gs,"deduplicateLayers");function $s(t,n,o,s){return(i)=>{let c=t.get(i)??[];if(c.length===0)return[];let a=n[i]??0,u=[],h=[],d=o.get(i);for(let m of c){let p=s.get(m)??a;if(p>a)u.push({child:m,min:p});else h.push(m)}return u.sort((m,p)=>{if(m.min===p.min)return m.child.localeCompare(p.child);return m.min-p.min}),h.sort((m,p)=>{let I=d?.get(m)??0,y=d?.get(p)??0;if(I!==y)return I-y;let g=s.get(m)??a,l=s.get(p)??a;if(g!==l)return g-l;return m.localeCompare(p)}),[...u.map((m)=>m.child),...h]}}e($s,"createChildOrderer");function ce(t,n,o){let s=Bs(t,{rankHint:n,laneOf:o}),{children:i,roots:c}=s;for(let p of t.nodes)if(!i.has(p))i.set(p,[]);let a=Ds(t,n,s),u=[...c].sort(Ao(n)),h=Xs(u,i,n),d=$s(i,n,a,h),m=Ys(u,t.nodes,n,d);return m=Gs(m),m}e(ce,"buildMultitreeLayerOrder");function zs(t,n,o){let s=new Set(t),i=new Set(n),c=Fn(n),a=[];for(let u of o)if(s.has(u.src)&&i.has(u.dst))a.push(c.get(u.dst));return Lo(a)}e(zs,"countCrossingsBetweenAdjacent");function Ze(t,n,o){let s=[];for(let c of n){let a=o[c.src],u=o[c.dst];if(a==null||u==null||a===u)continue;let{src:h,dst:d}=c,m=a,p=u;if(a>u)h=c.dst,d=c.src,m=u,p=a;for(let I=m;I<p;I++)s.push({id:`${c.id}@${I}`,src:h,dst:d,ref:c.ref})}let i=0;for(let c=0;c+1<t.length;c++)i+=zs(t[c],t[c+1],s);return i}e(Ze,"totalCrossings");function Vs(t,n){let o={...n},{preds:s}=de(t),i=hn(t),c=ce(t,o,i),a=Ze(c,t.edges,o),u=ie.MAX_CROSSING_OPTIMIZATION_PASSES;for(let h=0;h<u;h++){let d=!1,m=[...t.nodes].sort((p,I)=>(o[I]??0)-(o[p]??0));for(let p of m){let I=o[p]??0;if(I===0)continue;let y=0;for(let L of s.get(p)??[])y=Math.max(y,(o[L]??0)+1);if(y>=I)continue;let g=I;o[p]=y;let l=ce(t,o,i),x=Ze(l,t.edges,o);if(x<a)a=x,d=!0;else o[p]=g}if(!d)break}return o}e(Vs,"optimizeRanksByCrossings");function Us(t,n){let o=hn(t),s=[...t.nodes].sort((i,c)=>(n[i]??0)-(n[c]??0)||i.localeCompare(c));for(let i of s){let c=o(i);if(!c)continue;let a=t.edges.filter((l)=>l.src===i);if(a.length===0)continue;let u=!1,h=0;for(let l of a){let x=o(l.dst);if(x==null||x===c)u=!0;else h++}if(h===0||u)continue;let d=0,m=!1;for(let l of t.edges){if(l.dst!==i)continue;let x=o(l.src);if(!x)continue;if(x===c)m=!0;else d++}if(d>0||!m)continue;let p=n[i]??0,I=p+h,y=0;for(let l of t.edges)if(l.dst===i)y=Math.max(y,(n[l.src]??0)+1);let g=Math.max(p,y,I);if(g!==p)n[i]=g}}e(Us,"adjustCrossLaneSources");function js(t,n){let o=Mn(t),s=_n(o)??[...o.nodes].sort(),i=n?.compactSingleInput??!1,c=hn(o),a=Object.create(null);for(let h of s){let d=Io(o,h),m=n?.ignoreCrossLaneEdges?d.filter((p)=>{let I=c(p.src),y=c(h);if(!I||!y)return!0;return I===y}):d;if(m.length===0)a[h]=0;else if(i&&m.length===1){let p=m[0].src,I=c(p),y=c(h);if(I!==y)a[h]=a[p]??0;else a[h]=(a[p]??0)+1}else{let p=-1/0;for(let I of m)p=Math.max(p,(a[I.src]??0)+1);a[h]=p===-1/0?0:p}}if(n?.optimizeRanksByCrossings??!1)a=Vs(o,a);if(n?.ignoreCrossLaneEdges)Us(o,a);return{layers:ce(o,a,c),rankOf:a,dummy:new Set}}e(js,"assignLayers_LongestPath");function Ws(t,n){let o=Mn(t),i={...js(o,{compactSingleInput:n?.compactSingleInput,ignoreCrossLaneEdges:n?.ignoreCrossLaneEdges,optimizeRanksByCrossings:n?.optimizeRanksByCrossings}).rankOf},c=hn(o),{preds:a,succs:u}=de(o,(g)=>{if(n?.ignoreCrossLaneEdges){let l=c(g.src),x=c(g.dst);if(l&&x&&l!==x)return!1}return!0}),h=_n(o)??[...o.nodes],d=[...h].reverse(),m=e((g,l)=>{let x=0;for(let E of a.get(g)??[])x=Math.max(x,(i[E]??0)+1);let L=Number.POSITIVE_INFINITY,S=u.get(g)??[];if(S.length>0)L=Math.min(...S.map((E)=>(i[E]??0)-1));if(!Number.isFinite(L))L=Math.max(x,l);return Math.min(Math.max(l,x),L)},"clampFeasible"),p=ie.GRAVITY_ITERATIONS,I=e((g)=>{let l=!1;for(let x of g){let L=a.get(x)??[],S=u.get(x)??[];if(L.length===0&&S.length===0)continue;let E=L.length>0?L.reduce((R,O)=>R+(i[O]??0)+1,0)/L.length:i[x]??0,w=S.length>0?S.reduce((R,O)=>R+(i[O]??0)-1,0)/S.length:i[x]??0,C=Math.round((E+w)/2),b=m(x,C);if(b!==i[x])i[x]=b,l=!0}return l},"relaxOrder");for(let g=0;g<p;g++){let l=I(h),x=I(d);if(!l&&!x)break}for(let g of h){let l=0;for(let x of a.get(g)??[])l=Math.max(l,(i[x]??0)+1);if((i[g]??0)<l)i[g]=l}for(let g of d){let l=u.get(g)??[];if(l.length>0){let x=Math.min(...l.map((L)=>(i[L]??0)-1));if((i[g]??0)>x)i[g]=x}}return{layers:vo(o,h,i),rankOf:i,dummy:new Set}}e(Ws,"assignLayers_Gravity");function Ks(t){let n=fe(t),o=So(t),s=Co(t,n),i=[];while(s.length>0){let c=[];for(let a of s){i.push(a);for(let u of o.get(a)??[])if(n.set(u,(n.get(u)??0)-1),(n.get(u)??0)===0)c.push(u)}s=c.sort((a,u)=>a.localeCompare(u))}return i.length===t.nodes.length?i:null}e(Ks,"topoSortByGenerationIfAcyclic");function qs(t,n){let o=Mn(t),s=n?.direction==="LR"?Ks(o)??[...o.nodes].sort():_n(o)??[...o.nodes].sort(),i=hn(o),c=e((m)=>i(m)??m,"laneOf"),a=Object.create(null),u=new Map,h=e((m,p)=>{if(n?.ignoreCrossLaneEdges??!0)return c(m)===c(p)?1:0;return 1},"edgeWeight");for(let m of s){if(o.nodeById.get(m)?.isGroup)continue;let I=Io(o,m),y=0;if(I.length>0)for(let L of I){let S=L.src,E=a[S]??0;y=Math.max(y,E+h(S,m))}let g=c(m),l=u.get(g)??0,x=Math.max(y,l);a[m]=x,u.set(g,x+1)}return{layers:vo(o,s,a,{skipGroups:!0}),rankOf:a,dummy:new Set}}e(qs,"assignLayers_LaneAwareCompact");function Js(t,n){let o=Mn(n),{rankOf:s}=t,i=t.layers.map((y)=>[...y]),c=new Set(t.dummy?[...t.dummy]:[]),a=0,u=new Map(o.nodeById),h=e((y)=>{let g=`placeholder-${a++}`,l={id:g,isGroup:!1,isDummy:!0,width:0,height:0};u.set(g,l),c.add(g);while(i.length<=y)i.push([]);return i[y].push(g),s[g]=y,g},"addDummyAt"),d=[...o.edges].sort((y,g)=>y.id===g.id?y.src===g.src?y.dst.localeCompare(g.dst):y.src.localeCompare(g.src):y.id.localeCompare(g.id)),m=[];for(let y of d){let g=s[y.src]??0,l=s[y.dst]??0;if(l-g<=1){m.push(y);continue}let x=y.src;for(let S=g+1,E=0;S<l;S++,E++){let w=h(S);m.push({id:`${y.id}#${E}`,src:x,dst:w,weight:y.weight,ref:y.ref}),x=w}let L=l-g-2;m.push({id:`${y.id}#${Math.max(L+1,0)}`,src:x,dst:y.dst,weight:y.weight,ref:y.ref})}let I={nodes:[...o.nodes,...[...c].filter((y)=>!o.nodes.includes(y))],edges:m,layout:o.layout,nodeById:u};return{layering:{layers:i,rankOf:s,dummy:c},graphWithDummies:I}}e(Js,"makeProperLayering");function Qe(t){let n=t.length;if(n===0)return Number.POSITIVE_INFINITY;let o=[...t].sort((s,i)=>s-i);if(n%2===1)return o[(n-1)/2];return 0.5*(o[n/2-1]+o[n/2])}e(Qe,"median");function to(t){if(t.length===0)return Number.POSITIVE_INFINITY;return t.reduce((o,s)=>o+s,0)/t.length}e(to,"barycenter");function Zs(t,n,o,s){let i=new Map;for(let c of t)i.set(c,[]);for(let c of o)if(s==="down"){if(n.has(c.src)&&i.has(c.dst))i.get(c.dst).push(n.get(c.src))}else if(n.has(c.dst)&&i.has(c.src))i.get(c.src).push(n.get(c.dst));return i}e(Zs,"neighborPositionsFor");function Qs(t,n,o){let s=o.get(t)??0,i=o.get(n)??0;return s!==i?s-i:t.localeCompare(n)}e(Qs,"currentOrderTieBreak");function no(t,n,o){let s=new Set(t),i=new Set(n),c=Fn(t),a=Fn(n),u=[];for(let d of o)if(s.has(d.src)&&i.has(d.dst))u.push({u:c.get(d.src),v:a.get(d.dst)});u.sort((d,m)=>d.u===m.u?d.v-m.v:d.u-m.u);let h=u.map((d)=>d.v);return Lo(h)}e(no,"countCrossingsBetweenAdjacent");function Zn(t,n,o){return[...t].sort((s,i)=>{let c=Qe(n.get(s)??[]),a=Qe(n.get(i)??[]);if(c===a)return Qs(s,i,o);if(!isFinite(c))return 1;if(!isFinite(a))return-1;return c-a})}e(Zn,"sortByHeuristic");function eo(t,n,o,s,i,c){let a=Fn(t),u=Fn(n),h=Zs(n,a,o,s);if(!i||!c||c.length===0)return Zn(n,h,u);let d=new Map;for(let I of n){let y=i(I),g=d.get(y)??[];g.push(I),d.set(y,g)}let m=[];for(let I of c){let y=d.get(I);if(!y||y.length===0)continue;let g=Zn(y,h,u);m.push(...g)}let p=d.get(null);if(p&&p.length>0){let I=Zn(p,h,u);for(let y of I){let g=to(h.get(y)??[]),l=m.length;if(isFinite(g))for(let[x,L]of m.entries()){let S=to(h.get(L)??[]);if(g<S){l=x;break}}m.splice(l,0,y)}}return m}e(eo,"reorderLayer");function oo(t,n,o,s,i){let c=[...n],a=new Set(t),u=new Set(n),h=s?new Set(s):null,d=o.filter((l)=>a.has(l.src)&&u.has(l.dst)),m=h?o.filter((l)=>u.has(l.src)&&h.has(l.dst)):void 0,p=e((l)=>{let x=no(t,l,d);if(m&&s)x+=no(l,s,m);return x},"crossingScore"),I=i?new Map:null;if(i&&I)for(let l of n)I.set(l,i(l));let y=!0,g=p(c);while(y){y=!1;for(let l=0;l+1<c.length;l++){if(I){let S=I.get(c[l]),E=I.get(c[l+1]);if(S!==E)continue}let x=g;[c[l],c[l+1]]=[c[l+1],c[l]];let L=p(c);if(L<x)g=L,y=!0;else[c[l],c[l+1]]=[c[l+1],c[l]]}}return c}e(oo,"transposeImprove");function tr(t,n,o){let s=t.layers.map((u)=>[...u]),i=n.edges,c=hn(n),a=Eo(n,o?.laneOrder);for(let u=0;u<3;u++){for(let h=1;h<s.length;h++)s[h]=eo(s[h-1],s[h],i,"down",c,a),s[h]=oo(s[h-1],s[h],i,s[h+1],c);for(let h=s.length-2;h>=0;h--)s[h]=eo(s[h+1],s[h],i,"up",c,a),s[h]=oo(s[h+1],s[h],i,s[h-1],c)}return{layers:s}}e(tr,"orderLayers");function nr(t,n,o){let s=o?.layerGap??Uo.DEFAULT_LAYER_GAP,i=o?.nodeGap??Uo.DEFAULT_NODE_GAP,c=o?.laneGap??i*2,a=o?.direction??"TB",u=a==="LR"||a==="RL",h=t.layers,d=Object.create(null),m=Object.create(null),p=e((N)=>n.nodeById.get(N),"getNode"),I=e((N)=>p(N)?.width??0,"getWidth"),y=e((N)=>p(N)?.height??0,"getHeight"),g=hn(n),l=Eo(n,o?.laneOrder),x=h.map((N)=>N.reduce((H,_)=>Math.max(H,y(_)),0)),L=[];if(u)for(let N=0;N+1<h.length;N++){let H=h[N].reduce((xt,Ot)=>Math.max(xt,I(Ot)),0),_=h[N+1].reduce((xt,Ot)=>Math.max(xt,I(Ot)),0),F=x[N],Y=x[N+1],V=F/2+Y/2,J=(H+_)/2,lt=Math.max(0,J-V-s);L.push(lt)}let S=new Set;for(let N of h)for(let H of N)S.add(g(H));let E=S.has(null),w=l.filter((N)=>S.has(N)),C=[...E?[null]:[],...w],b=Object.create(null);for(let N of w)b[N]=0;if(E)b.null=0;for(let N of h){let H=Object.create(null),_=[];for(let F of N){let Y=g(F);if(Y===null)_.push(F);else(H[Y]||=[]).push(F)}for(let[F,Y]of Object.entries(H)){let V=Y.reduce((J,lt)=>J+I(lt),0)+i*Math.max(0,Y.length-1);b[F]=Math.max(b[F]??0,V)}if(E&&_.length){let F=_.reduce((Y,V)=>Y+I(V),0)+i*Math.max(0,_.length-1);b.null=Math.max(b.null??0,F)}}let R=new Map;{let N=C.map((F)=>(F===null?b.null:b[F])??0),_=-(N.reduce((F,Y)=>F+Y,0)+c*Math.max(0,C.length-1))/2;for(let F=0;F<C.length;F++){let Y=C[F],V=N[F]??0,J=_+V/2;if(R.set(Y,J),_+=V,F<C.length-1)_+=c}}let O=0;for(let[N,H]of h.entries()){let _=x[N]??0,F=new Map;for(let V of H){let J=g(V),lt=F.get(J)??[];lt.push(V),F.set(J,lt)}for(let V of C){let J=F.get(V)??[];if(J.length===0)continue;let lt=R.get(V);if(J.length===1){let xt=J[0];d[xt]=lt,m[xt]=O+_/2}else{let xt=J.map((nt)=>I(nt)),Ot=xt.reduce((nt,q)=>nt+q,0)+i*(J.length-1),kt=lt-Ot/2;for(let[nt,q]of J.entries()){let ot=xt[nt];d[q]=kt+ot/2,m[q]=O+_/2,kt+=ot+i}}}let Y=L[N]??0;O+=_+s+Y}let P=new Map;for(let N of n.edges){let H=N.ref.id;if(!P.has(H))P.set(H,[]);P.get(H).push(N)}for(let[,N]of P){if(N.length===0)continue;let H=N[0].ref,{start:_,end:F}=H;if(_==null||F==null)continue;let Y=Math.round(((d[_]??0)+(d[F]??0))/2),V=new Set;for(let J of N)V.add(J.src),V.add(J.dst);for(let J of V){if(J===_||J===F)continue;if(n.nodeById.get(J)?.isDummy)d[J]=Y}}return{x:d,y:m}}e(nr,"assignCoordinates");var er=8;function or(t){let n=2166136261;for(let o=0;o<t.length;o++)n^=t.charCodeAt(o),n=Math.imul(n,16777619);return n>>>0}e(or,"hashString");function sr(t){let n=t>>>0;return()=>{n+=1831565813;let o=n;return o=Math.imul(o^o>>>15,o|1),o^=o+Math.imul(o^o>>>7,o|61),((o^o>>>14)>>>0)/4294967296}}e(sr,"mulberry32");function rr(t,n){let o=[...t],s=sr(n);for(let i=o.length-1;i>0;i--){let c=Math.floor(s()*(i+1));[o[i],o[c]]=[o[c],o[i]]}return o}e(rr,"deterministicShuffle");function ir(t,n){let o=0;for(let[s,i]of t.entries())o+=Math.abs(s-(n.get(i)??s));return o}e(ir,"sourceDistance");function so(t,n){let o=new Map;for(let[i,c]of t.entries())o.set(c,i);let s=0;for(let{a:i,b:c,weight:a}of n){let u=o.get(i),h=o.get(c);if(u==null||h==null)continue;s+=a*Math.abs(u-h)}return s}e(so,"laneArrangementCost");function cr(t){let n=ue(t);if(n.length<2)return[];let o=new Map(n.map((c,a)=>[c,a])),s=hn(t),i=new Map;for(let c of t.layout.edges??[]){if(c.isLayoutOnly)continue;let a=typeof c.start==="string"?c.start:void 0,u=typeof c.end==="string"?c.end:void 0;if(!a||!u||!t.nodeById.has(a)||!t.nodeById.has(u))continue;let h=s(a),d=s(u);if(!h||!d||h===d)continue;let m=o.get(h),p=o.get(d);if(m==null||p==null)continue;let[I,y]=m<=p?[h,d]:[d,h],g=`${I}\x00${y}`,l=i.get(g);if(l)l.weight++;else i.set(g,{a:I,b:y,weight:1})}return[...i.values()]}e(cr,"buildWeightedLaneEdges");function ro(t,n,o){let s=[...t],i=so(s,n),c=!0,a=0,u=Math.max(1,s.length);while(c&&a<u){c=!1,a++;for(let h=0;h+1<s.length;h++){[s[h],s[h+1]]=[s[h+1],s[h]];let d=so(s,n);if(d<i)i=d,c=!0;else[s[h],s[h+1]]=[s[h+1],s[h]]}}return{order:s,cost:i,sourceDistance:ir(s,o)}}e(ro,"greedySwitch");function ar(t,n){if(t.cost!==n.cost)return t.cost<n.cost;return t.sourceDistance<n.sourceDistance}e(ar,"isBetterCandidate");function fr(t,n,o){let s=[...n].sort((i,c)=>i.a===c.a?i.b.localeCompare(c.b):i.a.localeCompare(c.a)).map(({a:i,b:c,weight:a})=>`${i}:${c}:${a}`).join("|");return or(`${t.join("|")}#${s}#${o}`)}e(fr,"seedForRestart");function dr(t,n={}){let o=ue(t);if(o.length<2)return o;let s=cr(t);if(s.length===0)return o;let i=new Map(o.map((u,h)=>[u,h])),c=ro(o,s,i),a=Math.max(0,n.restarts??er);for(let u=0;u<a;u++){let h=fr(o,s,u),d=rr(o,h),m=ro(d,s,i);if(ar(m,c))c=m}return c.order}e(dr,"optimizeTopLaneOrder");function ur(t,n){let o=n?.ignoreCrossLaneEdges??!0,s=n?.optimizeRanksByCrossings??!0,i=Mn(t),c=n?.automaticLaneOrdering?dr(i,{restarts:er}):void 0,a=Ns(i),u=a.acyclic,h=o?qs(u,{compactSingleInput:n?.compactSingleInput??ie.DEFAULT_COMPACT_SINGLE_INPUT,ignoreCrossLaneEdges:!0,direction:n?.direction}):Ws(u,{compactSingleInput:n?.compactSingleInput??ie.DEFAULT_COMPACT_SINGLE_INPUT,ignoreCrossLaneEdges:!1,optimizeRanksByCrossings:s}),{layering:d,graphWithDummies:m}=Js(h,u),p=tr(d,m,{laneOrder:c}),I=nr(p,m,{layerGap:n?.layerGap,nodeGap:n?.nodeGap,direction:n?.direction,laneOrder:c});return{acyclic:u,reversed:a.reversed,layering:d,ordered:p,coordinates:I}}e(ur,"sugiyamaLayout");var ft=Hr.EPSILON,Dr=8,Sn=15,Nn=15,qn=25,sn=20,Re=10;function io(t,n,o){let s=t.x??0,i=t.y??0,c=n.x-s,a=n.y-i,u=Math.abs(c),h=Math.abs(a);if(u<ft&&h<ft)return o;let d=3;if(h>ft&&h*d>=u)return a>0?"bottom":"top";if(u>ft)return c>0?"right":"left";return o}e(io,"chooseOrthogonalSide");function co(t,n){return Math.abs(t.to-n.from)<ft||Math.abs(t.to-n.to)<ft?t.to:t.from}e(co,"sharedLineEndpointCoord");function Cn(t,n){return t.orient==="vertical"?{x:t.coord,y:n}:{x:n,y:t.coord}}e(Cn,"pointOnLine");function hr(t,n){let o=t.nodes??[],s=t.edges??[],i=[];for(let f of s){if(f.isLayoutOnly)continue;i.push({...f,__originalEdge:f})}let c=new Map,a=new Map,u=[],h=n==="LR";for(let f of o)c.set(f.id,f);let d=o.filter((f)=>f.isGroup&&!f.parentId);for(let f of d){let M={id:f.id},v=e((A)=>{a.set(A.id,M),o.filter((T)=>T.parentId===A.id).forEach(v)},"assignLane");v(f)}let m=o.filter((f)=>!f.isGroup&&!f.isEdgeLabel).map((f)=>{let M=f.width??10,v=f.height??10,A=f.x??0,T=f.y??0,k=Dr;return{nodeId:f.id,minX:A-M/2-k,maxX:A+M/2+k,minY:T-v/2-k,maxY:T+v/2+k,visualXHalfExtent:h?v/2+k:M/2+k}}),p=e((f,M,v,A)=>{let T=u.find((k)=>k.orientation===f&&Math.abs(k.coord-M)<1);if(!T)T={id:`pipe-${f}-${M.toFixed(0)}`,orientation:f,coord:M,spanMin:v,spanMax:A,tracks:[]},u.push(T);return T.spanMin=Math.min(T.spanMin,v),T.spanMax=Math.max(T.spanMax,A),T},"getOrAddPipe"),I=e((f,M)=>{let v=f.width??10,A=f.height??10,T=f.x??0,k=f.y??0;switch(M){case"top":return{x:T,y:k-A/2};case"bottom":return{x:T,y:k+A/2};case"left":return{x:T-v/2,y:k};case"right":return{x:T+v/2,y:k}}},"portForSide"),y=e((f,M,v)=>I(f,io(f,M,v?"bottom":"top")),"getOrthogonalPort"),g=[],l=[],x=new Set,L=1000,S=e((f,M,v)=>{if(g.length===0)return 0;let A=Math.abs(M.y-v.y)<ft,T=Math.abs(M.x-v.x)<ft;if(!A&&!T)return 0;let k=0;if(A){let K=M.y,Q=Math.min(M.x,v.x)-ft,j=Math.max(M.x,v.x)+ft;if(j<=Q)return 0;for(let z of g){if(z.edgeIndex===f||z.orientation!=="vertical")continue;if(z.pipe.coord<Q||z.pipe.coord>j)continue;if(z.from-ft<=K&&z.to+ft>=K)k+=L}}else if(T){let K=M.x,Q=Math.min(M.y,v.y)-ft,j=Math.max(M.y,v.y)+ft;if(j<=Q)return 0;for(let z of g){if(z.edgeIndex===f||z.orientation!=="horizontal")continue;if(z.pipe.coord<Q||z.pipe.coord>j)continue;if(z.from-ft<=K&&z.to+ft>=K)k+=L}}return k},"crossingPenalty"),E=i.map((f,M)=>{if(!f.start||!f.end)return{idx:M,crossLane:0,dx:0,dy:0};let v=c.get(f.start),A=c.get(f.end),T=a.get(f.start),k=a.get(f.end),K=T&&k&&T.id!==k.id?1:0,Q=v&&A?Math.abs((A.x??0)-(v.x??0)):0,j=v&&A?Math.abs((A.y??0)-(v.y??0)):0;return{idx:M,crossLane:K,dx:Q,dy:j}}).sort((f,M)=>{if(f.crossLane!==M.crossLane)return M.crossLane-f.crossLane;let v=f.dx+f.dy,A=M.dx+M.dy;if(Math.abs(v-A)>1)return v-A;return f.idx-M.idx}).map((f)=>f.idx),w=e((f,M,v,A)=>{let T=Math.min(f.x,M.x),k=Math.max(f.x,M.x),K=Math.min(f.y,M.y),Q=Math.max(f.y,M.y);return!!m.find((z)=>{if(v&&z.nodeId===v)return!1;if(A&&z.nodeId===A)return!1;if(Math.abs(f.x-M.x)>ft)return z.minY<f.y&&z.maxY>f.y&&z.maxX>T&&z.minX<k;else return z.minX<f.x&&z.maxX>f.x&&z.maxY>K&&z.minY<Q})},"isSegmentBlocked"),C=new Map,b=new Map;for(let f of i){if(!f.start||!f.end||f.start===f.end)continue;b.set(f.start,(b.get(f.start)??0)+1),b.set(f.end,(b.get(f.end)??0)+1)}let R=e((f,M)=>io(f,M,"bottom"),"determineSide"),O=new Map;for(let[f,M]of i.entries()){if(!M.start||!M.end||M.start===M.end)continue;if(M.points&&M.points.length>0)continue;let v=c.get(M.start),A=c.get(M.end);if(!v||!A)continue;let T=(A.x??0)-(v.x??0),k=(A.y??0)-(v.y??0);O.set(f,{edgeIdx:f,srcId:M.start,dstId:M.end,srcSide:R(v,{x:A.x??0,y:A.y??0}),dstSide:R(A,{x:v.x??0,y:v.y??0}),absDx:Math.abs(T),absDy:Math.abs(k),dxSign:Math.sign(T),dySign:Math.sign(k)})}let P=e((f)=>{if(f.srcSide==="top"||f.srcSide==="bottom")return f.absDx===0?1/0:f.absDy/f.absDx;return f.absDy===0?1/0:f.absDx/f.absDy},"preferenceStrength"),N=e((f)=>{if(f.srcSide==="top"||f.srcSide==="bottom")return f.dxSign>=0?"right":"left";return f.dySign>=0?"bottom":"top"},"secondarySide"),H=new Map;for(let f of O.values()){let M=`${f.srcId}:${f.srcSide}`;if(!H.has(M))H.set(M,[]);H.get(M).push(f)}let _=new Map,F=e((f,M)=>`${f}:${M}`,"loadKey");for(let f of O.values())_.set(F(f.srcId,f.srcSide),(_.get(F(f.srcId,f.srcSide))??0)+1),_.set(F(f.dstId,f.dstSide),(_.get(F(f.dstId,f.dstSide))??0)+1);for(let f of H.values()){if(f.length<2)continue;f.sort((M,v)=>{let A=P(M),T=P(v);if(Math.abs(A-T)>0.000000001)return T-A;return M.edgeIdx-v.edgeIdx});for(let M=1;M<f.length;M++){let v=f[M],A=N(v),T=_.get(F(v.srcId,v.srcSide))??0,k=_.get(F(v.srcId,A))??0;if(k>=T)continue;_.set(F(v.srcId,v.srcSide),T-1),_.set(F(v.srcId,A),k+1),v.srcSide=A}}let Y=e((f)=>{let M=f?.shape;return M==="question"||M==="diamond"},"isDiamondNode"),V=new Map;for(let f of O.values()){if(!V.has(f.dstId))V.set(f.dstId,new Set);V.get(f.dstId).add(f.dstSide)}for(let f of O.values()){if(!Y(c.get(f.srcId)))continue;let M=V.get(f.srcId);if(!M?.has(f.srcSide))continue;let v=N(f);if(M.has(v)||(_.get(F(f.srcId,v))??0)>0)continue;let A=_.get(F(f.srcId,f.srcSide))??0;_.set(F(f.srcId,f.srcSide),Math.max(0,A-1)),_.set(F(f.srcId,v),1),f.srcSide=v}for(let f of O.values()){let{edgeIdx:M,srcId:v,dstId:A,srcSide:T,dstSide:k}=f,K=c.get(v),Q=c.get(A),j=`${v}:${T}:src`,z=T==="top"||T==="bottom"?Q.x??0:Q.y??0;if(!C.has(j))C.set(j,[]);C.get(j).push({edgeIdx:M,oppositeCoord:z});let rt=`${A}:${k}:dst`,ct=k==="top"||k==="bottom"?K.x??0:K.y??0;if(!C.has(rt))C.set(rt,[]);C.get(rt).push({edgeIdx:M,oppositeCoord:ct})}let J=new Map,lt=8;for(let[f,M]of C){if(M.length<2)continue;M.sort((At,Xt)=>At.oppositeCoord-Xt.oppositeCoord);let v=f.split(":"),A=v.slice(0,-2).join(":"),T=v[v.length-2],k=v[v.length-1],K=c.get(A);if(!K)continue;let j=T==="left"||T==="right"?K.height??10:K.width??10,z=K.shape,ct=z==="question"||z==="diamond"?j*0.3:j,et=Math.min(20,Math.max(lt,ct/(M.length+1))),Bt=-(et*(M.length-1))/2;for(let[At,Xt]of M.entries()){let Qt=Bt+At*et,me=`${Xt.edgeIdx}:${k}`;J.set(me,Qt)}}let xt=e((f)=>Boolean(i[f]?.labelNodeId),"edgeHasLabelNode"),Ot=e((f,M)=>{if(!f)return!1;return(C.get(`${f}:${M}:src`)??[]).some(({edgeIdx:v})=>xt(v))||(C.get(`${f}:${M}:dst`)??[]).some(({edgeIdx:v})=>xt(v))},"faceHasLabelNode"),kt=e((f,M,v)=>{if(M==="top"||M==="bottom")return{x:f.x+v,y:f.y};else return{x:f.x,y:f.y+v}},"applyPortOffset"),nt=e((f,M,v)=>{let A=O.get(f),T={x:v.x??0,y:v.y??0},k={x:M.x??0,y:M.y??0},K=A?.srcSide??R(M,T),Q=A?.dstSide??R(v,k),j=A?I(M,A.srcSide):y(M,T,!0),z=A?I(v,A.dstSide):y(v,k,!1),rt=J.get(`${f}:src`),ct=J.get(`${f}:dst`);if(rt!==void 0)j=kt(j,K,rt);if(ct!==void 0)z=kt(z,Q,ct);return{pSrcPort:j,pDstPort:z,srcSide:K,dstSide:Q}},"portsForEdge");for(let f of E){let M=i[f];if(l[f]=[],!M.start||!M.end)continue;if(M.points&&M.points.length>0)continue;if(M.start===M.end)continue;let v=c.get(M.start),A=c.get(M.end);if(!v||!A)continue;let{pSrcPort:T,pDstPort:k,srcSide:K,dstSide:Q}=nt(f,v,A),j={...T},z={...k},rt=K==="top"||K==="bottom",ct=Q==="top"||Q==="bottom";if(rt){let G=T.y>(v.y??0);j.y=G?T.y+sn:T.y-sn}else{let G=T.x>(v.x??0);j.x=G?T.x+sn:T.x-sn}if(ct){let G=k.y>(A.y??0);z.y=G?k.y+sn:k.y-sn}else{let G=k.x>(A.x??0);z.x=G?k.x+sn:k.x-sn}let it=e((G,U)=>{for(let Z of m){if(U.includes(Z.nodeId))continue;if(G.x>Z.minX&&G.x<Z.maxX&&G.y>Z.minY&&G.y<Z.maxY)return{inside:!0,obstacle:Z}}return{inside:!1}},"isPointInObstacle"),et=e((G,U,Z,ut,Lt)=>{if(Lt){let Ft=G.y>(U.y??0);return{x:(Z.x??0)>=G.x?ut.maxX+Sn:ut.minX-Sn,y:Ft?ut.maxY+Nn:ut.minY-Nn,leavesPositiveSide:Ft}}let It=G.x>(U.x??0),Rt=(Z.y??0)>=G.y;return{x:It?ut.maxX+Sn:ut.minX-Sn,y:Rt?ut.maxY+Nn:ut.minY-Nn,leavesPositiveSide:It}},"obstacleDetour"),bt=[],Bt=[M.start,M.end],At=it(j,Bt);if(At.inside&&At.obstacle){let G=At.obstacle;if(rt){let U=et(T,v,A,G,!0);j.x=U.x,j.y=U.y;let Z=U.leavesPositiveSide?Math.min(G.minY-2,T.y+sn):Math.max(G.maxY+2,T.y-sn);bt=[{x:T.x,y:Z},{x:U.x,y:Z},{x:U.x,y:U.y}]}else{let U=et(T,v,A,G,!1),Z=U.leavesPositiveSide?Math.min(G.minX-2,T.x+sn):Math.max(G.maxX+2,T.x-sn);j.x=U.x,j.y=U.y,bt=[{x:Z,y:T.y},{x:Z,y:U.y},{x:U.x,y:U.y}]}}let Xt=[],Qt=it(z,Bt);if(Qt.inside&&Qt.obstacle){let G=Qt.obstacle;if(ct){let U=et(k,A,v,G,!0);z.x=U.x,z.y=U.y,Xt=[{x:U.x,y:U.y},{x:k.x,y:U.y}]}else{let U=et(k,A,v,G,!1);z.x=U.x,z.y=U.y,Xt=[{x:U.x,y:U.y},{x:U.x,y:k.y}]}}if(bt.length===0&&Xt.length===0){let G=Sn,U=Math.abs(j.x-z.x)<G,Z=Math.abs(j.y-z.y)<G,ut=J.get(`${f}:src`)!==void 0||J.get(`${f}:dst`)!==void 0,Lt=(C.get(`${M.start??""}:${K}:src`)?.length??0)+(C.get(`${M.start??""}:${K}:dst`)?.length??0),It=(C.get(`${M.end??""}:${Q}:src`)?.length??0)+(C.get(`${M.end??""}:${Q}:dst`)?.length??0),Rt=Lt>1||It>1,Ft=b.get(M.start??"")??0,gt=b.get(M.end??"")??0,$t=Lt>1&&Ot(M.start,K)||It>1&&Ot(M.end,Q),on=Lt<=1||Ft<=2,_t=It<=1||gt<=2;if((U||Z)&&!ut&&(!Rt||Rt&&!$t&&on&&_t)){if(!w(T,k,M.start,M.end)){M.points=[{...T},{...j},{...z},{...k}],x.add(f);let St=Z?"horizontal":"vertical",Vt=Z?T.y:T.x,Ct=Z?Math.min(T.x,k.x):Math.min(T.y,k.y),vt=Z?Math.max(T.x,k.x):Math.max(T.y,k.y),qt={id:`fast-path-${St}-${Vt.toFixed(0)}-${f}`,orientation:St,coord:Vt,spanMin:Ct,spanMax:vt,tracks:[]};g.push({edgeIndex:f,segmentIndex:0,orientation:St,pipe:qt,trackIndex:0,from:Ct,to:vt});continue}}}let me=p("vertical",j.x,j.y,j.y);j.x=me.coord;let yr=p("vertical",z.x,z.y,z.y);z.x=yr.coord;let pn=Math.min(j.x,z.x)-50,mn=Math.max(j.x,z.x)+50,An=Math.min(j.y,z.y)-50,Rn=Math.max(j.y,z.y)+50;for(let G of m){let U=Math.min(j.x,z.x),Z=Math.max(j.x,z.x),ut=Math.min(j.y,z.y),Lt=Math.max(j.y,z.y);if(G.minX<Z&&G.maxX>U&&G.minY<Lt&&G.maxY>ut)pn=Math.min(pn,G.minX-qn),mn=Math.max(mn,G.maxX+qn),An=Math.min(An,G.minY-qn),Rn=Math.max(Rn,G.maxY+qn)}for(let G of m){if(G.maxX<pn||G.minX>mn||G.maxY<An||G.minY>Rn)continue;let U=Sn;p("horizontal",G.minY-U,pn,mn),p("horizontal",G.maxY+U,pn,mn);let Z=Nn;p("vertical",G.minX-Z,An,Rn),p("vertical",G.maxX+Z,An,Rn)}p("horizontal",j.y,pn,mn),p("horizontal",z.y,pn,mn);let xr=u.filter((G)=>G.orientation==="horizontal"&&G.coord>=An&&G.coord<=Rn),br=u.filter((G)=>G.orientation==="vertical"&&G.coord>=pn&&G.coord<=mn),Hn=e((G,U)=>`${G.toFixed(1)},${U.toFixed(1)}`,"getKey"),Dn=Hn(j.x,j.y),Ro=Hn(z.x,z.y),Xn=new Map,ye=new Map,xe=new Map,Yn=new Set,In=[];Xn.set(Dn,0),xe.set(Dn,"n"),In.push({key:Dn,f:Math.hypot(z.x-j.x,z.y-j.y),pt:j}),Yn.add(Dn);let Yt=[],yn=e((G,U)=>w(G,U,M.start,M.end),"checkSegmentBlocked"),be={x:z.x,y:j.y},Mr=yn(j,be),Ir=yn(be,z),Sr=Mr||Ir,Me={x:j.x,y:z.y},Cr=yn(j,Me),vr=yn(Me,z),Lr=Cr||vr;if(!Sr)if(Math.abs(j.y-z.y)<ft||Math.abs(j.x-z.x)<ft)Yt=[j,z];else Yt=[j,be,z];else if(!Lr)if(Math.abs(j.x-z.x)<ft)Yt=[j,z];else Yt=[j,Me,z];if(Yt.length===0)while(In.length>0){In.sort((gt,$t)=>gt.f-$t.f);let G=In.shift();if(Yn.delete(G.key),G.key===Ro){let gt=Ro,$t=z;Yt=[$t];while(ye.has(gt)){let on=ye.get(gt);Yt.unshift(on),$t=on,gt=Hn(on.x,on.y)}break}let U=G.pt.x,Z=G.pt.y,ut=br.sort((gt,$t)=>gt.coord-$t.coord),Lt=ut.findIndex((gt)=>Math.abs(gt.coord-U)<1),It=xr.sort((gt,$t)=>gt.coord-$t.coord),Rt=It.findIndex((gt)=>Math.abs(gt.coord-Z)<1),Ft=[];if(Lt>0)Ft.push({x:ut[Lt-1].coord,y:Z});if(Lt>=0&&Lt<ut.length-1)Ft.push({x:ut[Lt+1].coord,y:Z});if(Rt>0)Ft.push({x:U,y:It[Rt-1].coord});if(Rt>=0&&Rt<It.length-1)Ft.push({x:U,y:It[Rt+1].coord});for(let gt of Ft){let $t=Math.min(U,gt.x),on=Math.max(U,gt.x),_t=Math.min(Z,gt.y),zt=Math.max(Z,gt.y);if(m.some((tn)=>{if(tn.nodeId===M.start||tn.nodeId===M.end)return!1;if($t!==on)return tn.minY<Z&&tn.maxY>Z&&tn.maxX>$t&&tn.minX<on;else return tn.minX<U&&tn.maxX>U&&tn.maxY>_t&&tn.minY<zt}))continue;let St=Hn(gt.x,gt.y),Vt=Math.abs(gt.x-U)+Math.abs(gt.y-Z),Ct=S(f,G.pt,gt),vt=0,qt=z.x-j.x,Tn=z.y-j.y,Gn=gt.x-U,Ie=gt.y-Z;if(Tn>10&&Ie<-5||Tn<-10&&Ie>5)vt=Math.abs(Ie)*100;if(qt>10&&Gn<-5||qt<-10&&Gn>5)vt+=Math.abs(Gn)*50;let To=0,wo=xe.get(G.key)??"n",No=Math.abs(Gn)>ft?"h":"v";if(wo!=="n"&&wo!==No)To=50;let Er=Vt+Ct+vt+To,$n=(Xn.get(G.key)??1/0)+Er,Oo=Math.abs(z.x-gt.x)+Math.abs(z.y-gt.y);if($n<(Xn.get(St)??1/0))if(ye.set(St,G.pt),Xn.set(St,$n),xe.set(St,No),!Yn.has(St))In.push({key:St,f:$n+Oo,pt:gt}),Yn.add(St);else{let tn=In.findIndex((Ar)=>Ar.key===St);if(tn!==-1)In[tn].f=$n+Oo}}}if(Yt.length===0)Yt=[j,{x:j.x,y:z.y},z];if(Yt.length>4){let G=Yt[0],U=Yt[Yt.length-1],Z=Math.min(G.x,U.x),ut=Math.max(G.x,U.x),Lt=Math.min(G.y,U.y),It=Math.max(G.y,U.y);for(let _t of Yt)Z=Math.min(Z,_t.x),ut=Math.max(ut,_t.x),Lt=Math.min(Lt,_t.y),It=Math.max(It,_t.y);let Rt=ut>Math.max(G.x,U.x),Ft=Z<Math.min(G.x,U.x);if(h){let _t=Nn;if(Rt){let zt=Math.max(G.x,U.x),Pt=Math.min(G.y,U.y),St=Math.max(G.y,U.y),Vt=m.filter((Ct)=>Ct.minX<zt&&Ct.maxX>zt&&Ct.minY<St&&Ct.maxY>Pt);if(Vt.length>0){let Ct=Math.max(G.x,U.x);for(let vt of Vt){let qt=(vt.minX+vt.maxX)/2;if(vt.visualXHalfExtent===void 0||isNaN(vt.visualXHalfExtent))continue;let Tn=qt+vt.visualXHalfExtent+_t;Ct=Math.max(Ct,Tn)}if(!isNaN(Ct))ut=Ct}}if(Ft){let zt=m.filter((Pt)=>Pt.minX<Math.min(G.x,U.x)+_t&&Pt.minY<Math.max(G.y,U.y)&&Pt.maxY>Math.min(G.y,U.y));if(zt.length>0){let Pt=Math.min(G.x,U.x);for(let St of zt){let Ct=(St.minX+St.maxX)/2-St.visualXHalfExtent-_t;Pt=Math.min(Pt,Ct)}Z=Pt}}}let gt=e((_t)=>{let zt=U.y>G.y,Pt=m.filter((Ct)=>{let vt=Math.min(G.x,U.x)<Ct.maxX&&Math.max(G.x,U.x)>Ct.minX,qt=Math.min(G.y,U.y)<Ct.maxY&&Math.max(G.y,U.y)>Ct.minY;return vt&&qt}),St=Pt;if(h&&Pt.length>0){let Ct=Pt.filter((vt)=>vt.minX<_t&&vt.maxX>_t);if(Ct.length>0)St=Ct}if(St.length===0)return U.y;let Vt=Sn;if(zt){let vt=Math.max(...St.map((qt)=>qt.maxY))+Vt;if(vt<U.y-ft)return vt}else{let vt=Math.min(...St.map((qt)=>qt.minY))-Vt;if(vt>U.y+ft)return vt}return U.y},"findBestReturnY"),$t=e((_t)=>{let zt=gt(_t),Pt={x:_t,y:G.y},St={x:_t,y:zt},Vt={x:U.x,y:zt},Ct=yn(G,Pt),vt=yn(Pt,St),qt=yn(St,Vt),Tn=zt!==U.y?yn(Vt,U):!1;if(!Ct&&!vt&&!qt&&!Tn){if(Math.abs(zt-U.y)<ft)return[G,Pt,St,U];return[G,Pt,St,Vt,U]}return null},"trySimplifyWithDetourX"),on=Rt&&!Ft?$t(ut):Ft&&!Rt?$t(Z):null;if(on)Yt=on}let Gt=[T,...bt,...Yt,...Xt.reverse(),k];if(Gt.length>=3){let G=Gt[Gt.length-1],U=Gt[Gt.length-2],Z=Gt[Gt.length-3],ut=Math.abs(Z.y-U.y)<ft&&Math.abs(U.y-G.y)<ft,Lt=Math.abs(Z.x-U.x)<ft&&Math.abs(U.x-G.x)<ft;if(ut){let It=Math.sign(U.x-Z.x),Rt=Math.sign(G.x-Z.x);if(It!==0&&It===Rt&&Math.abs(U.x-Z.x)>Math.abs(G.x-Z.x))Gt.splice(-2,1)}else if(Lt){let It=Math.sign(U.y-Z.y),Rt=Math.sign(G.y-Z.y);if(It!==0&&It===Rt&&Math.abs(U.y-Z.y)>Math.abs(G.y-Z.y))Gt.splice(-2,1)}}let ln=[Gt[0]];for(let G=1;G<Gt.length-1;G++){if(G===1){ln.push(Gt[G]);continue}let U=ln[ln.length-1],Z=Gt[G],ut=Gt[G+1];if(Math.abs(U.y-Z.y)<ft&&Math.abs(Z.y-ut.y)<ft){let Lt=Z.x>U.x,It=ut.x>Z.x;if(Lt!==It){ln.push(Z);continue}continue}if(Math.abs(U.x-Z.x)<ft&&Math.abs(Z.x-ut.x)<ft){let Lt=Z.y>U.y,It=ut.y>Z.y;if(Lt!==It){ln.push(Z);continue}continue}ln.push(Z)}ln.push(Gt[Gt.length-1]);for(let G=0;G<ln.length-1;G++){let U=ln[G],Z=ln[G+1],ut=Math.abs(U.x-Z.x)<ft?"vertical":"horizontal",Lt=ut==="vertical"?U.x:U.y,It=ut==="vertical"?Math.min(U.y,Z.y):Math.min(U.x,Z.x),Rt=ut==="vertical"?Math.max(U.y,Z.y):Math.max(U.x,Z.x),Ft=p(ut,Lt,It,Rt),gt={edgeIndex:f,segmentIndex:G,orientation:ut,pipe:Ft,trackIndex:0,from:It,to:Rt};if(g.push(gt),l[f].push(g.length-1),!Ft.tracks[0])Ft.tracks[0]={index:0,coord:Ft.coord,segments:[]};Ft.tracks[0].segments.push({edgeIndex:f,segmentIndex:G,from:It,to:Rt})}}let q=e((f,M)=>f.from<M.to&&M.from<f.to,"segmentsOverlap"),ot=e((f,M,v,A)=>{let T=!A.segments.some((K)=>(K.edgeIndex!==M.edgeIndex||K.segmentIndex!==M.segmentIndex)&&q(K,f)),k=!v.segments.some((K)=>(K.edgeIndex!==f.edgeIndex||K.segmentIndex!==f.segmentIndex)&&q(K,M));if(T&&k)return f.trackIndex=A.index,M.trackIndex=v.index,v.segments=[...v.segments.filter((K)=>K.edgeIndex!==f.edgeIndex||K.segmentIndex!==f.segmentIndex),{edgeIndex:M.edgeIndex,segmentIndex:M.segmentIndex,from:M.from,to:M.to}],A.segments=[...A.segments.filter((K)=>K.edgeIndex!==M.edgeIndex||K.segmentIndex!==M.segmentIndex),{edgeIndex:f.edgeIndex,segmentIndex:f.segmentIndex,from:f.from,to:f.to}],!0;return!1},"trySwapSegmentsAcrossTracks"),dt=e((f)=>{let M=f.tracks.length;return f.tracks[M]={index:M,coord:f.coord,segments:[]},M},"createNewTrack"),mt=e((f,M)=>{let v=f.pipe.tracks[f.trackIndex];v.segments=v.segments.filter((T)=>T.edgeIndex!==f.edgeIndex||T.segmentIndex!==f.segmentIndex),f.trackIndex=M,f.pipe.tracks[M].segments.push({edgeIndex:f.edgeIndex,segmentIndex:f.segmentIndex,from:f.from,to:f.to})},"moveSegmentToTrack"),Mt=e((f,M)=>{let v=l[f.edgeIndex];for(let A of v){let T=g[A];if(T.pipe===f.pipe)mt(T,M)}},"moveSegmentChainToTrack"),Et=e((f)=>{let M=l[f.edgeIndex],v=M.indexOf(g.indexOf(f)),A=[];if(v>0)A.push(g[M[v-1]]);if(v<M.length-1)A.push(g[M[v+1]]);return A},"getAdjacentSegmentsAlongEdge"),jt=e((f,M)=>{if(f.orientation===M.orientation)return!1;let v=f.orientation==="horizontal"?f:M,A=f.orientation==="horizontal"?M:f;return A.pipe.coord>v.from&&A.pipe.coord<v.to&&v.pipe.coord>A.from&&v.pipe.coord<A.to},"haveAnyCrossing"),Wt=e((f,M)=>{for(let v of f.tracks)if(!v.segments.some((T)=>(T.edgeIndex!==M.edgeIndex||T.segmentIndex!==M.segmentIndex)&&q(T,M)))return v.index;return-1},"findAvailableTrack"),Kt=e((f,M)=>{if(f.trackIndex===M.trackIndex)return q(f,M);let v=Et(f),A=Et(M);return v.some((T)=>A.some((k)=>jt(T,k)))},"segmentsConflict"),en=e((f,M,v)=>{if(ot(f,M,f.pipe.tracks[f.trackIndex],M.pipe.tracks[M.trackIndex]))return;let A=Wt(f.pipe,M);v(M,A!==-1?A:dt(f.pipe))},"resolveTrackConflict"),Ln=e((f)=>{let M=0;for(let v=0;v<f.length;v++)for(let A=v+1;A<f.length;A++){let T=f[v],k=f[A];if(T.pipe!==k.pipe)continue;if(Kt(T,k))M++,en(T,k,Mt)}return M},"resolveHandleConflicts"),gn=new Map,En=e((f)=>{if(gn.has(f))return gn.get(f);let M=l[f];if(M.length===0){let Q={dest:0,deviation:0,base:0,delta:0};return gn.set(f,Q),Q}let A=g[M[0]].pipe.coord,T=A;for(let Q=1;Q<M.length;Q++){let j=g[M[Q]];if(j.orientation==="horizontal"){let{from:z,to:rt}=j;T=Math.abs(z-A)>Math.abs(rt-A)?z:rt;break}}let k=Math.abs(T-A),K={dest:T,deviation:k,base:A,delta:T-A};return gn.set(f,K),K},"getDestInfo"),he=e(()=>{let f=0,M=new Map;for(let[A,T]of i.entries()){if(l[A].length===0)continue;if(!T.start)continue;if(!M.has(T.start))M.set(T.start,[]);M.get(T.start).push(A)}let v=e((A)=>{let T=i[A];if(!T.start||!T.end)return 0;let k=c.get(T.start),K=c.get(T.end);if(!k||!K)return 0;let Q=(K.x??0)-(k.x??0),j=(K.y??0)-(k.y??0);return Math.abs(Q)+Math.abs(j)},"getEdgeDistance");for(let A of M.values()){A.sort((k,K)=>{let Q=En(k),j=En(K);if(Math.abs(Q.deviation-j.deviation)>1)return Q.deviation-j.deviation;if(Math.abs(Q.dest-j.dest)>1)return Q.dest-j.dest;let z=v(k),rt=v(K);if(Math.abs(z-rt)>1)return rt-z;let ct=l[k].length,it=l[K].length;if(ct!==it)return ct-it;if(ct===1){let et=l[k][0],bt=l[K][0];if(g[et]&&g[bt]){let Bt=g[et],At=g[bt],Xt=Math.abs(Bt.to-Bt.from),Qt=Math.abs(At.to-At.from);if(Math.abs(Xt-Qt)>1)return Xt-Qt}}return 0});let T=A.map((k)=>g[l[k][0]]);f+=Ln(T)}return f},"fixSourceHandleCrossings"),ge=e(()=>{let f=0,M=new Map;for(let[v,A]of i.entries()){if(l[v].length===0)continue;if(!A.end)continue;if(!M.has(A.end))M.set(A.end,[]);M.get(A.end).push(v)}for(let v of M.values()){v.sort((T,k)=>{let K=e((z)=>{let rt=l[z];if(rt.length<2)return 0;let ct=g[rt[rt.length-2]];return Math.abs(ct.to-ct.from)},"getDist"),Q=K(T),j=K(k);if(Math.abs(Q-j)>0.1)return Q-j;return T-k});let A=v.map((T)=>g[l[T][l[T].length-1]]);f+=Ln(A)}return f},"fixTargetHandleCrossings"),pe=e(()=>{let f=0;for(let M of u){let v=[];for(let A of M.tracks)for(let T of A.segments){let k=l[T.edgeIndex].find((K)=>g[K].segmentIndex===T.segmentIndex);if(k!==void 0)v.push(g[k])}v.sort((A,T)=>A.edgeIndex-T.edgeIndex||A.segmentIndex-T.segmentIndex);for(let A=0;A<v.length;A++)for(let T=A+1;T<v.length;T++){let k=v[A],K=v[T];if(Kt(k,K))f++,en(k,K,mt)}}return f},"fixPipeCrossings"),B=0,D=10;while(B<D){let f=0;if(f+=he(),f+=ge(),f+=pe(),f===0)break;B++}let X=new Map;for(let f of u){let M=[];f.tracks.forEach((A)=>{A.segments.forEach((T)=>{M.push({edgeIndex:T.edgeIndex,segmentIndex:T.segmentIndex,trackIndex:A.index,from:T.from,to:T.to})})}),M.sort((A,T)=>A.from-T.from);let v=[];if(M.length>0){let A=[M[0]],T=M[0].to;for(let k=1;k<M.length;k++){let K=M[k];if(K.from<T)A.push(K),T=Math.max(T,K.to);else v.push(A),A=[K],T=K.to}v.push(A)}for(let A of v){let T=new Set;A.forEach((et)=>T.add(et.trackIndex));let k=new Map;A.forEach((et)=>{let bt=En(et.edgeIndex);k.set(et.trackIndex,(k.get(et.trackIndex)??0)+bt.delta)});let K=[...T].filter((et)=>(k.get(et)??0)<-1),Q=[...T].filter((et)=>(k.get(et)??0)>1),j=[...T].filter((et)=>Math.abs(k.get(et)??0)<=1);K.sort((et,bt)=>(k.get(bt)??0)-(k.get(et)??0)),Q.sort((et,bt)=>(k.get(et)??0)-(k.get(bt)??0));let z=e((et,bt)=>{A.filter((Bt)=>Bt.trackIndex===et).forEach((Bt)=>{let At=x.has(Bt.edgeIndex)?f.coord:bt;X.set(`${Bt.edgeIndex}-${Bt.segmentIndex}`,At)})},"assignCoord"),rt=0;for(let et of K)rt++,z(et,f.coord-rt*Re);if(j.length===0&&T.size>0){let et=[...T].sort((At,Xt)=>Math.abs(k.get(At)??0)-Math.abs(k.get(Xt)??0))[0],bt=K.indexOf(et);if(bt!==-1)K.splice(bt,1);let Bt=Q.indexOf(et);if(Bt!==-1)Q.splice(Bt,1);j.push(et)}let ct=0;for(let et of j){if(ct===0)z(et,f.coord);else{let bt=ct%2===1?1:-1,Bt=Math.ceil(ct/2);z(et,f.coord+bt*Bt*Re*0.5)}ct++}let it=0;for(let et of Q)it++,z(et,f.coord+it*Re)}}for(let[f,M]of i.entries()){let v=l[f]??[];if(v.length===0)continue;let A=[],T=c.get(M.start),k=c.get(M.end),{pSrcPort:K,pDstPort:Q}=nt(f,T,k),j=v.map((ct)=>{let it=g[ct],et=X.get(`${it.edgeIndex}-${it.segmentIndex}`)??it.pipe.coord;return{orient:it.orientation,coord:et,from:it.from,to:it.to}});A.push(K);for(let ct=0;ct<j.length;ct++){let it=j[ct],et=A[A.length-1],bt=it.orient==="vertical"?et.y:et.x,Bt=it.orient==="vertical"?et.x:et.y,At=j[ct+1],Xt=ct<j.length-1;if(Math.abs(Bt-it.coord)>ft)A.push(Cn(it,bt));if(Xt&&At.orient===it.orient){if(Math.abs(it.coord-At.coord)>ft){let Qt=it.orient==="vertical"?(bt+At.from)/2:co(it,At);A.push(Cn(it,Qt),Cn(At,Qt))}else if(ct===0||ct===j.length-2)A.push(Cn(it,co(it,At)))}else if(Xt)A.push(Cn(it,At.coord));else{let Qt=Math.abs(it.from-bt)<Math.abs(it.to-bt)?it.to:it.from;A.push(Cn(it,Qt))}}let z=A[A.length-1];if(Math.abs(z.x-Q.x)>ft||Math.abs(z.y-Q.y)>ft)A.push(Q);let rt=[];if(A.length>0)rt.push(A[0]);for(let ct=1;ct<A.length;ct++){let it=A[ct],et=rt[rt.length-1];if(Math.abs(it.x-et.x)>ft||Math.abs(it.y-et.y)>ft)rt.push(it)}M.points=rt}for(let f of i){let M=f.__originalEdge;if(M&&f.points)M.points=f.points}t.edges=(t.edges??[]).filter((f)=>!f.isLayoutOnly);let W=e((f,M)=>{let v=M.x??0,A=M.y??0,T=M.width??0,k=M.height??0;if(T<=0||k<=0)return f;let K=v-T/2,Q=v+T/2,j=A-k/2,z=A+k/2;if(f.x<K||f.x>Q||f.y<j||f.y>z)return f;let rt=f.x-K,ct=Q-f.x,it=f.y-j,et=z-f.y,bt=Math.min(rt,ct,it,et);if(bt===rt)return{x:K,y:f.y};if(bt===ct)return{x:Q,y:f.y};if(bt===it)return{x:f.x,y:j};return{x:f.x,y:z}},"nodeBoundaryClamp");for(let f of t.edges){let M=f.points;if(!M||M.length<2)continue;let{start:v,end:A}=f,T=v?c.get(v):void 0,k=A?c.get(A):void 0;if(T)M[0]=W(M[0],T);if(k)M[M.length-1]=W(M[M.length-1],k)}return t}e(hr,"routeEdgesOrthogonal");function gr(t){return t.direction??"TB"}e(gr,"getSwimlaneDirection");function pr(t){let n=qo(t),o=t.config.flowchart?.nodeSpacing??40,s=t.config.flowchart?.rankSpacing??100,i=t.config.swimlane?.ignoreCrossLaneEdges??!0,c=t.config.swimlane?.optimizeRanksByCrossings??!0,a=t.config.swimlane?.automaticLaneOrdering??!1,u=gr(t),{ordered:h,coordinates:d}=ur(n,{nodeGap:o,layerGap:s,ignoreCrossLaneEdges:i,optimizeRanksByCrossings:c,automaticLaneOrdering:a,direction:u});Jo(n,h,d,{nodeGap:o,layerGap:s});for(let m of t.edges??[])delete m.points;hr(t,u);for(let m of t.edges??[])if(!m.curve||m.curve==="basis")m.curve="rounded";return Ts(t,u),Rs(t),u}e(pr,"runSwimlaneLayoutCore");function mr(t){Ko(t);let n=Zo(t);t.nodes=n.nodes,t.edges=n.edges}e(mr,"prepareSwimlaneLayout");var oi=lr({prepareLayout:mr,runLayoutCore:pr,afterPaint:jo});export{oi as render};
|
|
1
|
+
import{e,r,Ne}from"./chunk-vymqrpm3.js";import"./chunk-7xk0ntav.js";import{lr}from"./chunk-jzfd7cyh.js";var Un=5,zn=0.00001,Rr=2,Tr=0.6,Vn=0.000001;function jn(t){let n=[];for(let o=0;o<t.length-1;o++)n.push({a:t[o],b:t[o+1]});return n}e(jn,"buildSegmentList");function Bo(t,n,o,s){let i=n.x-t.x,c=n.y-t.y,a=s.x-o.x,u=s.y-o.y,h=i*u-c*a;if(h===0)return null;let d=o.x-t.x,m=o.y-t.y,p=(d*u-m*a)/h,I=(d*c-m*i)/h;if(p<=Vn||p>=1-Vn||I<=Vn||I>=1-Vn)return null;return{point:{x:t.x+p*i,y:t.y+p*c},tA:p,tB:I}}e(Bo,"segmentIntersection");function Se(t){return Math.abs(t.b.x-t.a.x)>=Math.abs(t.b.y-t.a.y)}e(Se,"isHorizontalSeg");function Ce(t,n,o){if(t.curve!=="rounded")return!1;let s=t.points,i=s[n],c=s[n+1];if(!i||!c)return!1;let a=Math.hypot(c.x-i.x,c.y-i.y),u=o*a,h=n>0?Pn(s[n-1],i,c,Un):null;if(h&&u<h.cutLen)return!0;let d=n+2<s.length?Pn(i,c,s[n+2],Un):null;return d!==null&&a-u<d.cutLen}e(Ce,"crossingSitsInRoundedCorner");function Fo(t){let n=[];for(let o=0;o<t.length;o++){let s=t[o],i=jn(s.points);for(let c=o+1;c<t.length;c++){let a=t[c],u=jn(a.points);for(let[h,d]of i.entries())for(let[m,p]of u.entries()){let I=Bo(d.a,d.b,p.a,p.b);if(!I)continue;if(Ce(s,h,I.tA)||Ce(a,m,I.tB))continue;let y=Se(d),g=Se(p);if(y!==g?y:!1)n.push({jumpEdgeId:s.id,otherEdgeId:a.id,segIndex:h,t:I.tA,point:I.point});else n.push({jumpEdgeId:a.id,otherEdgeId:s.id,segIndex:m,t:I.tB,point:I.point})}}}return n}e(Fo,"findEdgeIntersections");function cn(t){let n=Math.round(t*1000)/1000;return Number.isInteger(n)?`${n}`:`${n}`}e(cn,"fmt");function wn(t){return`${cn(t.x)},${cn(t.y)}`}e(wn,"pointToString");function Po(t){let n=t.b.x-t.a.x,o=t.b.y-t.a.y;if(Math.abs(n)>=Math.abs(o))return n>=0?1:0;return o>=0?1:0}e(Po,"getArcSweepFlag");function ko(t,n){if(t.length<2)return t.map((c)=>({...c}));let o=t.map((c)=>({...c})),s=n.arrowTypeStart&&Ne[n.arrowTypeStart];if(s){let c=t[0],a=t[1],u=Math.atan2(a.y-c.y,a.x-c.x);o[0].x=c.x+s*Math.cos(u),o[0].y=c.y+s*Math.sin(u)}let i=n.arrowTypeEnd&&Ne[n.arrowTypeEnd];if(i){let c=t.length,a=t[c-2],u=t[c-1],h=Math.atan2(u.y-a.y,u.x-a.x);o[c-1].x=u.x-i*Math.cos(h),o[c-1].y=u.y-i*Math.sin(h)}return o}e(ko,"applyMarkerOffsets");function _o(t,n,o,s,i){let c=t.point.x,a=t.point.y,u={x:c-n*t.r,y:a-o*t.r},h={x:c+n*t.r,y:a+o*t.r},d=[`L${wn(u)}`];if(i==="arc")d.push(`A${cn(t.r)},${cn(t.r)} 0 0 ${s} ${wn(h)}`);else d.push(`M${wn(h)}`);return d}e(_o,"emitJump");function Pn(t,n,o,s){let i=n.x-t.x,c=n.y-t.y,a=o.x-n.x,u=o.y-n.y,h=Math.hypot(i,c),d=Math.hypot(a,u);if(h<zn||d<zn)return null;let m=i/h,p=c/h,I=a/d,y=u/d,g=m*I+p*y,l=Math.max(-1,Math.min(1,g)),x=Math.acos(l);if(x<zn||Math.abs(Math.PI-x)<zn)return null;let L=Math.min(s/Math.sin(x/2),h/2,d/2);return{startX:n.x-m*L,startY:n.y-p*L,endX:n.x+I*L,endY:n.y+y*L,ctrlX:n.x,ctrlY:n.y,cutLen:L}}e(Pn,"computeRoundedCorner");function Ho(t,n,o){let s=t.points;if(s.length<2)return"";let i=ko(s,t),c=t.curve==="rounded",a=jn(i),u=new Map;for(let d of n){let m=a[d.segIndex];if(!m)continue;let p=Math.hypot(m.b.x-m.a.x,m.b.y-m.a.y),I=u.get(d.segIndex)??[];I.push({t:d.t,point:d.point,d:d.t*p,r:o.jumpRadius}),u.set(d.segIndex,I)}let h=[`M${wn(i[0])}`];for(let d=0;d<a.length;d++){let m=a[d],p=Math.hypot(m.b.x-m.a.x,m.b.y-m.a.y),I=p===0?0:(m.b.x-m.a.x)/p,y=p===0?0:(m.b.y-m.a.y)/p,g=Po(m),l=0;if(c&&d>0){let w=Pn(i[d-1],i[d],i[d+1]??i[d],Un);if(w)l=w.cutLen}let x=p,L=null;if(c&&d<a.length-1){if(L=Pn(i[d],i[d+1],i[d+2]??i[d+1],Un),L)x=p-L.cutLen}let S=o.jumpRadius*Tr,E=[...u.get(d)??[]].sort((w,C)=>w.t-C.t).filter((w)=>{let C=Math.min(w.d-l,x-w.d)-Rr;return w.r=Math.min(w.r,C),w.r>=S});for(let w=0;w<E.length-1;w++){let C=E[w+1].d-E[w].d;if(E[w].r+E[w+1].r>C){let b=C/2;E[w].r=Math.min(E[w].r,b),E[w+1].r=Math.min(E[w+1].r,b)}}for(let w of E){if(w.r<S)continue;h.push(..._o(w,I,y,g,o.jumpStyle))}if(c&&L)h.push(`L${cn(L.startX)},${cn(L.startY)}`),h.push(`Q${cn(L.ctrlX)},${cn(L.ctrlY)} ${cn(L.endX)},${cn(L.endY)}`);else h.push(`L${wn(m.b)}`)}return h.join(" ")}e(Ho,"rewriteEdgePath");function Do(t){return/^[\d\s+,.LMelm-]*$/.test(t)}e(Do,"isStraightPath");function Xo(t){if(!t)return!0;return t==="linear"||t==="rounded"||t==="step"||t==="stepBefore"||t==="stepAfter"}e(Xo,"curveSupportsLineHops");function Yo(t){if(!t)return null;try{let n=typeof atob==="function"?atob(t):Buffer.from(t,"base64").toString(),o=JSON.parse(n);if(!Array.isArray(o))return null;let s=[];for(let i of o)if(i&&typeof i.x==="number"&&typeof i.y==="number")s.push({x:i.x,y:i.y});return s.length>=2?s:null}catch{return null}}e(Yo,"decodeDataPoints");function ve(t,n,o){if(!o.enabled)return;let s=t.node();if(!s)return;let i=new Map;for(let d of n)i.set(d.id,d);let c=new Map;for(let d of s.querySelectorAll("path[data-id]")){let m=d.getAttribute("data-id");if(m!==null&&!c.has(m))c.set(m,d)}let a=[];for(let d of n){let m=c.get(d.id);if(!m)continue;let I=Yo(m.getAttribute("data-points"))??d.points;a.push({...d,points:I})}let u=Fo(a);if(u.length===0)return;let h=new Map;for(let d of u){let m=h.get(d.jumpEdgeId)??[];m.push(d),h.set(d.jumpEdgeId,m)}for(let d of a){let m=h.get(d.id);if(!m||m.length===0)continue;let I=i.get(d.id)?.curve;if(I!==void 0&&!Xo(I))continue;let y=c.get(d.id);if(!y)continue;if(I===void 0){let E=y.getAttribute("d")??"";if(!Do(E))continue}let g=y.getAttribute("style")??"",l=/stroke-dasharray\s*:\s*0\s+([\d.]+)\s+[\d.]+\s+([\d.]+)/.exec(g),x=l?Number.parseFloat(l[1]):null,L=l?Number.parseFloat(l[2]):null,S=Ho(d,m,o);if(y.setAttribute("d",S),x!==null&&L!==null&&typeof y.getTotalLength==="function"){let E=y.getTotalLength(),w=Math.max(0,E-x-L),C=`0 ${x} ${w} ${L}`,b=g.replace(/stroke-dasharray\s*:[^;]*;?/g,`stroke-dasharray: ${C};`).replace(/;\s*;+/g,";");y.setAttribute("style",b)}}}e(ve,"applyLineJumpsToSvg");function jo(t,{measure:n}){let o=t.config?.swimlane?.lineHops;if(o===!1)return;let s=o==="gap"?"gap":"arc",i=t.edges.filter((c)=>Array.isArray(c.points)&&c.points.length>=2).map((c)=>({id:c.id,points:c.points,curve:c.curve,arrowTypeStart:c.arrowTypeStart,arrowTypeEnd:c.arrowTypeEnd}));ve(n.groups.edgePaths,i,{enabled:!0,jumpRadius:6,jumpStyle:s})}e(jo,"applySwimlaneLineJumps");var Le="__swimlane_default__",wr=21,Go=20;function Te(t){return Math.max(t.padding??Go,Go)}e(Te,"topLaneHorizontalPadding");function Wo(t){let{x:n,y:o,width:s,height:i}=t,c=t.swimlaneContentTop;if(typeof n!=="number"||typeof o!=="number"||typeof s!=="number"||typeof i!=="number"||typeof c!=="number"||!Number.isFinite(n)||!Number.isFinite(o)||!Number.isFinite(s)||!Number.isFinite(i)||!Number.isFinite(c)||s<=0||i<=0){delete t.groupTitleRect;return}let a=o-i/2,u=Math.min(c,o+i/2),h=Math.min(wr,Math.max(0,u-a)),d=a+h;if(d<=a){delete t.groupTitleRect;return}t.groupTitleRect={left:n-s/2,right:n+s/2,top:a,bottom:d}}e(Wo,"assignTopLaneTitleRect");function Ko(t){let n=t.direction,o=t.nodes??=[];for(let c of t.nodes??[])if(c.isGroup&&!c.parentId){if(c.shape="swimlane",n)c.direction=n}let s=o.filter((c)=>!c.isGroup&&!c.parentId);if(s.length===0)return;let i=o.find((c)=>c.id===Le);if(!i)i={id:Le,label:"",isGroup:!0,shape:"swimlane",padding:20,look:t.config?.look,colorIndex:o.reduce((c,a)=>Math.max(c,a.colorIndex??-1),-1)+1,...n?{direction:n}:{}},o.push(i);else if(i.isGroup){if(i.shape="swimlane",n)i.direction=n}for(let c of s)c.parentId=Le}e(Ko,"prepareLayoutForSwimlanes");function qo(t){let n=new Map;for(let h of t.nodes??[])n.set(h.id,h);let o=[];for(let h of t.edges??[]){let d=typeof h.start==="string"?h.start:void 0,m=typeof h.end==="string"?h.end:void 0;if(!d||!m)continue;if(h.labelNodeId)continue;o.push({id:h.id,src:d,dst:m,ref:h})}let s=t.nodes??[],i=s.filter((h)=>h.isGroup),c=s.filter((h)=>!h.isGroup);return{nodes:[...[...i].reverse(),...c].map((h)=>h.id),edges:o,layout:t,nodeById:n}}e(qo,"toGraphView");function Jo(t,n,o,s){let{layout:i}=t,c=t.nodeById,a=s?.layerGap??100,u=s?.nodeGap??40,h=0;for(let I of n.layers){let y=0;for(let g of I){let l=c.get(g);if(!l){y++;continue}l.layer=h,l.order=y;let x=o.x[g]??y*u,L=o.y[g]??h*a;l.x=x,l.y=L,y++}h++}let d=i.nodes??[],m=new Map,p=[];for(let I of d){if(!I?.isGroup)continue;if(!I.parentId)p.push(I);let y=d.filter((S)=>S.parentId===I.id),g=1/0,l=-1/0,x=1/0,L=-1/0;for(let S of y){let E=S.x??o.x[S.id],w=S.y??o.y[S.id],C=S.width??0,b=S.height??0;if(E!=null&&w!=null)g=Math.min(g,E-C/2),l=Math.max(l,E+C/2),x=Math.min(x,w-b/2),L=Math.max(L,w+b/2)}if(g===1/0||x===1/0)I.x=I.x??0,I.y=I.y??0,I.width=I.width??0,I.height=I.height??0;else{let S=I.padding??20,E=I.parentId?S:2*Te(I),w=S,C=Math.max(0,l-g)+E,b=Math.max(0,L-x)+w,R=(g+l)/2,O=(x+L)/2;I.x=R,I.y=O,I.width=C,I.height=b,m.set(I.id,{minX:g,maxX:l,minY:x,maxY:L})}}if(p.length>0&&m.size>0){let I=1/0,y=-1/0,g=0;for(let l of p){let x=l.padding??20;if(x>g)g=x;let L=m.get(l.id);if(!L)continue;I=Math.min(I,L.minY),y=Math.max(y,L.maxY)}if(I!==1/0&&y!==-1/0){let l=Math.max(0,y-I),x=36,L=Math.max(g,36),S=l+2*L,E=(I+y)/2;for(let P of p)P.y=E,P.height=S,P.swimlaneContentTop=I;let w=[...p].sort((P,N)=>{let H=P.x??0,_=N.x??0;return H-_}),C=[],b=[],R=[];for(let P of w){let N=m.get(P.id);if(!N)continue;let H=Math.max(0,N.maxX-N.minX)+2*Te(P),_=(N.minX+N.maxX)/2;C.push(P.id),b.push(_),R.push(H)}let O=C.length;if(O>0){let P=new Map;if(O===1)P.set(C[0],R[0]);else{let N=[];for(let V=0;V<O-1;V++)N.push(b[V+1]-b[V]);let H=Array(O);H[0]=0;for(let V=0;V<O-1;V++)H[V+1]=2*N[V]-H[V];let _=0,F=Number.POSITIVE_INFINITY;for(let V=0;V<O;V++){let J=R[V];if(V%2===0)_=Math.max(_,J-H[V]);else F=Math.min(F,H[V]-J)}let Y=_;if(_<=F)Y=(_+F)/2;else Y=_;for(let V=0;V<O;V++){let J=H[V]+(V%2===0?Y:-Y),lt=Math.max(R[V],J);P.set(C[V],lt)}}for(let N of p){let H=P.get(N.id);if(H!=null)N.width=H;Wo(N)}}}}}e(Jo,"writeBackToLayoutData");var Nr="[EdgeLabelNodes]";function Zo(t){let n=[],o=[],s=new Map;for(let a of t.nodes)s.set(a.id,a);for(let a of t.edges){if(!a.label||a.label.length===0)continue;if(a.isLayoutOnly)continue;if(a.labelNodeId)continue;let u=a.start?s.get(a.start):void 0,h=a.end?s.get(a.end):void 0;if(!u||!h){r.warn(Nr,`Edge ${a.id} has missing source or target node`);continue}let d=`edge-label-${a.start}-${a.end}-${a.id}`,p=u.parentId!==h.parentId?h.parentId:u.parentId,I={id:d,label:a.label,edgeStart:a.start??"",edgeEnd:a.end??"",shape:"labelRect",width:0,height:0,isEdgeLabel:!0,isDummy:!0,parentId:p,isGroup:!1,labelStyle:Array.isArray(a.labelStyle)?a.labelStyle[0]:a.labelStyle??"",...u.dir?{dir:u.dir}:{}};n.push(I),a.labelNodeId=d,a.label=void 0,a.text=void 0;let y={id:`${a.id}-to-label`,start:a.start,end:d,type:"normal",isLayoutOnly:!0},g={id:`${a.id}-from-label`,start:d,end:a.end,type:"normal",isLayoutOnly:!0};o.push(y,g)}let i=[...t.nodes,...n],c=[...t.edges,...o];return{...t,nodes:i,edges:c}}e(Zo,"createEdgeLabelNodes");var Dt=0.001;function ao(t){let n=t.x??0,o=t.y??0,s=t.width??0,i=t.height??0;return s>0&&i>0?{cx:n,cy:o,rect:On(n,o,s,i)}:void 0}e(ao,"measuredNodeRect");function lo(t){if(t.isGroup)return;let n=ao(t);if(!n)return;return{id:String(t.id??""),cx:n.cx,cy:n.cy,rect:n.rect}}e(lo,"nodeBoundsInfoFor");function rn(t,n,o=Dt){return Math.abs(t.x-n.x)<o&&Math.abs(t.y-n.y)<o}e(rn,"samePoint");function ht(t,n,o=Dt){return Math.abs(t.x-n.x)<o}e(ht,"sameX");function pt(t,n,o=Dt){return Math.abs(t.y-n.y)<o}e(pt,"sameY");function Tt(t,n,o=Dt){return pt(t,n,o)&&Math.abs(t.x-n.x)>o}e(Tt,"isHorizontalSegment");function wt(t,n,o=Dt){return ht(t,n,o)&&Math.abs(t.y-n.y)>o}e(wt,"isVerticalSegment");function Ut(t,n,o,s){return Math.max(0,Math.min(Math.max(t,n),Math.max(o,s))-Math.max(Math.min(t,n),Math.min(o,s)))}e(Ut,"overlapLength");function fn(t,n,o=Dt){if(t.horizontal&&n.horizontal&&pt(t.a,n.a,o))return Ut(t.a.x,t.b.x,n.a.x,n.b.x);if(t.vertical&&n.vertical&&ht(t.a,n.a,o))return Ut(t.a.y,t.b.y,n.a.y,n.b.y);return 0}e(fn,"sameAxisSegmentOverlapLength");function Bn(t,n=Dt){let o=[];for(let s=0;s<t.length-1;s++){let i=t[s],c=t[s+1],a=Tt(i,c,n),u=wt(i,c,n);if(a||u)o.push({index:s,a:i,b:c,horizontal:a,vertical:u})}return o}e(Bn,"orthogonalSegmentsForPoints");function nn(t,n=Dt){let o=Bn(t,n),s=0;for(let i=1;i<o.length;i++)if(o[i-1].horizontal!==o[i].horizontal)s++;return s}e(nn,"countOrthogonalBends");function yt(t,n=Dt){let o=[];for(let s of t){let i=o.length>0?o[o.length-1]:void 0;if(!i||!rn(i,s,n))o.push({x:s.x,y:s.y})}return o}e(yt,"dedupeConsecutivePoints");function fo(t,n=Dt){if(!t||t.length!==4)return;let[o,s,i,c]=t;if(Tt(o,s,n)&&wt(s,i,n)&&Tt(i,c,n))return{kind:"HVH",p0:o,p1:s,p2:i,p3:c};return wt(o,s,n)&&Tt(s,i,n)&&wt(i,c,n)?{kind:"VHV",p0:o,p1:s,p2:i,p3:c}:void 0}e(fo,"classifyThreeSegmentRoute");function ae(t,n,o,s=0){let i=Math.min(t.x,n.x),c=Math.max(t.x,n.x),a=Math.min(t.y,n.y),u=Math.max(t.y,n.y);return c>o.left-s&&i<o.right+s&&u>o.top-s&&a<o.bottom+s}e(ae,"segmentBoundsOverlapRect");function uo(t,n,o=0){return t.x>n.left+o&&t.x<n.right-o&&t.y>n.top+o&&t.y<n.bottom-o}e(uo,"pointInsideRect");function Qo(t,n){return t.left<=n.left&&t.right>=n.right&&t.top<=n.top&&t.bottom>=n.bottom}e(Qo,"rectContainsRect");function Qn(t,n){return t.left<n.right&&t.right>n.left&&t.top<n.bottom&&t.bottom>n.top}e(Qn,"rectsOverlap");function we(t,n){return{left:t.left-n,right:t.right+n,top:t.top-n,bottom:t.bottom+n}}e(we,"inflateRect");function On(t,n,o,s){return{left:t-o/2,right:t+o/2,top:n-s/2,bottom:n+s/2}}e(On,"rectFromCenterSize");function Zt(t){return ao(t)?.rect}e(Zt,"rectOfNodeBounds");function vn(t,n){switch(n){case"top":return{x:t.cx,y:t.rect.top};case"bottom":return{x:t.cx,y:t.rect.bottom};case"left":return{x:t.rect.left,y:t.cy};case"right":return{x:t.rect.right,y:t.cy}}}e(vn,"portForRectSide");function ho(t,n,o,s,i,c=Dt){let a=n==="left"||n==="right",u=s==="left"||s==="right";if(a&&u){if(n==="right"&&s==="left"&&t.x<o.x||n==="left"&&s==="right"&&t.x>o.x){if(pt(t,o,c))return[t,o];let p=(t.x+o.x)/2;return[t,{x:p,y:t.y},{x:p,y:o.y},o]}if(n===s){if(pt(t,o,c))return;let p=n==="left"?Math.min(t.x,o.x)-i:Math.max(t.x,o.x)+i;return[t,{x:p,y:t.y},{x:p,y:o.y},o]}return}if(!a&&!u){if(n===s){if(ht(t,o,c))return;let I=n==="top"?Math.min(t.y,o.y)-i:Math.max(t.y,o.y)+i;return[t,{x:t.x,y:I},{x:o.x,y:I},o]}if(!(n==="bottom"&&s==="top"&&t.y<o.y||n==="top"&&s==="bottom"&&t.y>o.y))return;if(ht(t,o,c))return[t,o];let p=(t.y+o.y)/2;return[t,{x:t.x,y:p},{x:o.x,y:p},o]}if(a&&!u){let m=n==="right"&&o.x>t.x||n==="left"&&o.x<t.x,p=s==="top"&&t.y<o.y||s==="bottom"&&t.y>o.y;return m&&p?[t,{x:o.x,y:t.y},o]:void 0}let h=n==="bottom"&&o.y>t.y||n==="top"&&o.y<t.y,d=s==="left"&&t.x<o.x||s==="right"&&t.x>o.x;return h&&d?[t,{x:t.x,y:o.y},o]:void 0}e(ho,"buildOrthogonalPortPath");function go(t,n,o,s){return n==="left"||n==="right"?[t,{x:s,y:t.y},{x:s,y:o.y},o]:[t,{x:t.x,y:s},{x:o.x,y:s},o]}e(go,"buildSameSideTrackPath");function le(t){let n=new Map,o=[];for(let s of t){if(s.isEdgeLabel)continue;let i=lo(s);if(!i)continue;n.set(i.id,i),o.push({id:i.id,rect:i.rect})}return{nodeInfoById:n,realNodeRects:o}}e(le,"collectRealNodeBounds");function bn(t){let n=[],o=[];for(let s of t){let i=lo(s);if(!i)continue;let c={id:i.id,rect:i.rect};if(s.isEdgeLabel)o.push(c);else n.push(c)}return{realNodeRects:n,labelNodeRects:o}}e(bn,"collectNodeRectEntries");function ts(t,{includeEdgeLabels:n=!0}={}){let o=[];for(let s of t){if(s.isGroup||!n&&s.isEdgeLabel)continue;let i=s.x??0,c=s.y??0,a=s.width??0,u=s.height??0;o.push({nodeId:s.id,...On(i,c,a,u)})}return o}e(ts,"collectLayoutNodeRects");function po(t,n,o=Dt){let{start:s,end:i}=t;if(!s||!i)return;let c=n.get(s),a=n.get(i);if(!c||!a)return;return{srcId:s,dstId:i,srcInfo:c,dstInfo:a,collinearX:Math.abs(c.cx-a.cx)<o,collinearY:Math.abs(c.cy-a.cy)<o}}e(po,"getNodePairGeometry");function Nt(t,n,o,s=[],i=0){for(let c of o){if(s.includes(c.id))continue;if(ae(t,n,c.rect,-i))return!0}return!1}e(Nt,"segmentHitsAnyRect");function mo(t,n,o,s,i=Dt,c=0.000001){let a=pt(t,n,i),u=ht(t,n,i),h=pt(o,s,i),d=ht(o,s,i);if(a&&h||u&&d)return!1;if(!(a||u)||!(h||d))return!1;let m=a?{a:t,b:n}:{a:o,b:s},p=u?{a:t,b:n}:{a:o,b:s},I=m.a.y,y=Math.min(m.a.x,m.b.x),g=Math.max(m.a.x,m.b.x),l=p.a.x,x=Math.min(p.a.y,p.b.y),L=Math.max(p.a.y,p.b.y);if(l<y||l>g||I<x||I>L)return!1;let S=Math.abs(l-m.a.x)<c&&Math.abs(I-m.a.y)<c||Math.abs(l-m.b.x)<c&&Math.abs(I-m.b.y)<c,E=Math.abs(l-p.a.x)<c&&Math.abs(I-p.a.y)<c||Math.abs(l-p.b.x)<c&&Math.abs(I-p.b.y)<c;return!(S&&E)}e(mo,"orthogonalSegmentsCross");function ns(t,n,o,s,i=Dt){let c=pt(t,n,i),a=ht(t,n,i),u=pt(o,s,i),h=ht(o,s,i);if(a&&h&&ht(t,o,i))return Ut(t.y,n.y,o.y,s.y)>i;if(c&&u&&pt(t,o,i))return Ut(t.x,n.x,o.x,s.x)>i;return!1}e(ns,"sameAxisSegmentsOverlap");function te(t,n,o,s,{epsilon:i=Dt,skipDegenerateOther:c=!1}={}){for(let a of o){if(a===s||a.isLayoutOnly)continue;let u=a.points;if(!u||u.length<2)continue;for(let h=0;h<u.length-1;h++){let d=u[h],m=u[h+1];if(c&&rn(d,m,i))continue;if(mo(t,n,d,m,i)||ns(t,n,d,m,i))return!0}}return!1}e(te,"segmentConflictsWithAnyEdge");function un(t,n,o,s,i=Dt){let c=pt(t,n,i),a=ht(t,n,i),u=pt(o,s,i),h=ht(o,s,i);if(!(c&&h||a&&u))return!1;let d=c?{a:t,b:n}:{a:o,b:s},m=c?{a:o,b:s}:{a:t,b:n},p=d.a.y,I=Math.min(d.a.x,d.b.x),y=Math.max(d.a.x,d.b.x),g=m.a.x,l=Math.min(m.a.y,m.b.y),x=Math.max(m.a.y,m.b.y);return g>I+i&&g<y-i&&p>l+i&&p<x-i}e(un,"orthogonalSegmentsStrictlyCross");function Oe(t,n,o){let s=Math.min(n,o),i=Math.max(n,o);return t>s+Dt&&t<i-Dt}e(Oe,"strictlyBetween");function es(t,n,o){if(ht(t,n)&&ht(n,o))return Oe(n.y,t.y,o.y);if(pt(t,n)&&pt(n,o))return Oe(n.x,t.x,o.x);return!1}e(es,"isCollinearIntermediate");function os(t){let n=!1,o=[];for(let s=0;s<t.length;s++){let i=o[o.length-1],c=t[s],a=s+1<t.length?t[s+1]:void 0;if(i&&a){if(rn(i,a)){s++,n=!0;continue}if(es(i,c,a)){n=!0;continue}}o.push(c)}return{points:o,changed:n}}e(os,"simplifyPolylineOnce");function ne(t){let n=[t[0]];for(let s=1;s<t.length;s++){let i=n[n.length-1],c=t[s];if(!ht(i,c)&&!pt(i,c)){let a=n.length>=2?n[n.length-2]:void 0,h=(a?ht(a,i):!1)?{x:i.x,y:c.y}:{x:c.x,y:i.y};n.push(h)}n.push(c)}let o=[];for(let s of n){let i=o[o.length-1];if(!i||!rn(i,s))o.push(s)}return o}e(ne,"orthogonalizePolyline");function dn(t){if(t.length<3)return t;let n=[...t];for(let o=0;o<32;o++){let s=os(n);if(n=s.points,!s.changed)break}return n}e(dn,"simplifyPolyline");var st=0.001,Or=0.5,$o=4;function yo(t,n,o){let s=t;if(s.isLayoutOnly||!s.points||s.points.length<o)return;let i=s.start?n.get(s.start):void 0,c=s.end?n.get(s.end):void 0;return{edge:s,points:s.points,srcRect:i?Zt(i):void 0,dstRect:c?Zt(c):void 0}}e(yo,"endpointContextFor");function ss(t,n,o){if(pt(t,n,st))return{x:t.x<o.left?o.left:o.right,y:t.y};if(ht(t,n,st)){let s=t.y<o.top?o.top:o.bottom;return{x:t.x,y:s}}return{x:Math.min(o.right,Math.max(o.left,t.x)),y:Math.min(o.bottom,Math.max(o.top,t.y))}}e(ss,"segmentEnterPoint");function Be(t,n,o){let s=o?1:-1,i=o?0:t.length-1;while(i>=0&&i<t.length&&uo(t[i],n,Or))i+=s;if(i<0||i>=t.length)return t;let c=i-s;if(c<0||c>=t.length)return t;let a=ss(t[i],t[c],n);return o?[a,...t.slice(i)]:[...t.slice(0,i+1),a]}e(Be,"clipEndpoint");function rs(t,n){for(let o of t){let s=yo(o,n,2);if(!s)continue;let i=[...s.points];if(s.srcRect)i=Be(i,s.srcRect,!0);if(s.dstRect)i=Be(i,s.dstRect,!1);i=dn(ne(i)),i=xo(i,s.srcRect,s.dstRect),s.edge.points=dn(ne(i))}}e(rs,"clipEdgeEndpointsToNodeBoundaries");function Fe(t,n,o,s=!1){if(pt(t,n,st)){if(n.y<o.top-st||n.y>o.bottom+st)return n;if(s){if(t.x<o.left-st)return{x:o.left,y:t.y};if(t.x>o.right+st)return{x:o.right,y:t.y}}return{x:Math.abs(n.x-o.left)<=Math.abs(n.x-o.right)?o.left:o.right,y:t.y}}if(ht(t,n,st)){if(n.x<o.left-st||n.x>o.right+st)return n;if(s){if(t.y<o.top-st)return{x:t.x,y:o.top};if(t.y>o.bottom+st)return{x:t.x,y:o.bottom}}let i=Math.abs(n.y-o.top)<=Math.abs(n.y-o.bottom);return{x:t.x,y:i?o.top:o.bottom}}return n}e(Fe,"snapEndpointToBoundary");function ee(t,n,o){let s=t[n];for(let i=n+o;i>=0&&i<t.length;i+=o){let c=t[i];if(!rn(c,s,st))return c}return t[n+o]}e(ee,"firstDistinctAdjacent");function oe(t,n){let o=t+$o,s=n-$o;return o<=s?{lo:o,hi:s}:{lo:(t+n)/2,hi:(t+n)/2}}e(oe,"cornerClearanceRange");function Pe(t,n,o){let{lo:s,hi:i}=oe(n,o);return Math.min(i,Math.max(s,t))}e(Pe,"clampToCornerClearance");function is(t){let n=Math.max(...t.map((s)=>s.lo)),o=Math.min(...t.map((s)=>s.hi));if(n>o)return;return{lo:n,hi:o}}e(is,"intersectRanges");function ke(t,n){return n==="left"||n==="right"?oe(t.top,t.bottom):oe(t.left,t.right)}e(ke,"clearanceRangeForSide");function se(t,n,o){let s=t.y>=o.top-st&&t.y<=o.bottom+st,i=t.x>=o.left-st&&t.x<=o.right+st;if(pt(t,n,st)&&s){if(Math.abs(t.x-o.left)<st)return"left";if(Math.abs(t.x-o.right)<st)return"right"}if(ht(t,n,st)&&i){if(Math.abs(t.y-o.top)<st)return"top";if(Math.abs(t.y-o.bottom)<st)return"bottom"}return}e(se,"terminalSideForSegment");function kn(t){return t==="left"||t==="right"}e(kn,"isHorizontalSide");function cs(t,n,o,s,i){let c=[],a=o?se(t,n,o):void 0,u=s?se(n,t,s):void 0;if(o&&a&&kn(a)===i)c.push(ke(o,a));if(s&&u&&kn(u)===i)c.push(ke(s,u));return c.length>0?is(c):void 0}e(cs,"straightClearanceRange");function _e(t,n,o,s,i){let c=cs(t,n,o,s,i);if(!c)return;let a=i?t.y:t.x,u=Math.min(c.hi,Math.max(c.lo,a));if(Math.abs(u-a)<st)return;return i?[{x:t.x,y:u},{x:n.x,y:u}]:[{x:u,y:t.y},{x:u,y:n.y}]}e(_e,"clearStraightEndpointCornerAxis");function xo(t,n,o){if(t.length!==2)return t;let[s,i]=t;if(pt(s,i,st))return _e(s,i,n,o,!0)??t;if(ht(s,i,st))return _e(s,i,n,o,!1)??t;return t}e(xo,"clearStraightEndpointCornerConnections");function as(t,n,o){return kn(o)?{x:t.x,y:Pe(t.y,n.top,n.bottom)}:{x:Pe(t.x,n.left,n.right),y:t.y}}e(as,"cornerClearedEndpoint");function ls(t,n,o,s,i,c){let a=t.map((u)=>({...u}));for(let u=n;u>=0&&u<t.length;u+=o){let h=t[u];if(c&&!pt(h,s,st))break;if(!c&&!ht(h,s,st))break;if(c)a[u].y=i.y;else a[u].x=i.x}return a}e(ls,"moveCollinearEndpointRun");function He(t,n,o){if(t.length<2)return t;let s=o?0:t.length-1,i=o?1:-1,c=t[s],a=ee(t,s,i);if(!a)return t;let u=se(c,a,n);if(!u)return t;let h=kn(u),d=as(c,n,u);if(rn(c,d,st))return t;return ls(t,s,i,c,d,h)}e(He,"clearEndpointCornerConnection");function De(t,n,o){let s=Math.min(t.x,n.x)>=o.left-st&&Math.max(t.x,n.x)<=o.right+st,i=Math.min(t.y,n.y)>=o.top-st&&Math.max(t.y,n.y)<=o.bottom+st;if(Math.abs(t.y-o.top)<st&&Math.abs(n.y-o.top)<st&&s)return"top";if(Math.abs(t.y-o.bottom)<st&&Math.abs(n.y-o.bottom)<st&&s)return"bottom";if(Math.abs(t.x-o.left)<st&&Math.abs(n.x-o.left)<st&&i)return"left";if(Math.abs(t.x-o.right)<st&&Math.abs(n.x-o.right)<st&&i)return"right";return}e(De,"borderSideForSegment");function Xe(t,n,o,s){switch(t){case"top":return ht(n,o,st)&&o.y<s.top-st;case"bottom":return ht(n,o,st)&&o.y>s.bottom+st;case"left":return pt(n,o,st)&&o.x<s.left-st;case"right":return pt(n,o,st)&&o.x>s.right+st}}e(Xe,"leavesOutward");function Ye(t,n,o){if(t.length<3)return t;if(o){let c=De(t[0],t[1],n);if(c&&Xe(c,t[1],t[2],n))return t.slice(1);return t}let s=t.length-1,i=De(t[s-1],t[s],n);if(i&&Xe(i,t[s-1],t[s-2],n))return t.slice(0,s);return t}e(Ye,"collapseOwnBorderStub");function fs(t,n,o){let s=t;if(n){let c=ee(s,0,1);if(c){let a=Fe(c,s[0],n);if(a!==s[0])s=[a,...s.slice(1)]}s=Ye(s,n,!0)}if(o){let c=s.length-1,a=ee(s,c,-1);if(a){let u=Fe(a,s[c],o,!0);if(u!==s[c])s=[...s.slice(0,c),u]}s=Ye(s,o,!1)}let i=xo(s,n,o);if(i!==s||s.length===2)return i;if(n)s=He(s,n,!0);if(o)s=He(s,o,!1);return s}e(fs,"snapAndCollapseEndpoints");function Ge(t,n){for(let o of t){let s=yo(o,n,2);if(!s)continue;let i=yt(s.points,st),c=fs(i,s.srcRect,s.dstRect);if(c.length<3){s.edge.points=c;continue}let a=[c[0],{...c[0]},...c.slice(1,-1),c[c.length-1],{...c[c.length-1]}];s.edge.points=a}}e(Ge,"prepareEdgeEndpointsForRenderer");function bo(t){return new Map(t.map((n)=>[n.id,n]))}e(bo,"buildNodeMap");function ds(t,n){let o=t.parentId,s=null;while(o){let i=n.get(o);if(!i?.isGroup)break;s=i.id,o=i.parentId}return s}e(ds,"resolveTopLevelGroupId");function $e(t,n){let o=0,s=t.parentId;while(s){let i=n.get(s);if(!i?.isGroup)break;o++,s=i.parentId}return o}e($e,"groupDepth");function Mo(t){let n=1/0,o=-1/0,s=1/0,i=-1/0;for(let c of t){let{x:a,y:u}=c;if(typeof a!=="number"||typeof u!=="number")continue;let h=c.width??0,d=c.height??0;n=Math.min(n,a-h/2),o=Math.max(o,a+h/2),s=Math.min(s,u-d/2),i=Math.max(i,u+d/2)}if(n===1/0||s===1/0)return null;return{minX:n,maxX:o,minY:s,maxY:i}}e(Mo,"boundsForChildren");function us(t,n){let o=t.padding??20;t.x=(n.minX+n.maxX)/2,t.y=(n.minY+n.maxY)/2,t.width=Math.max(0,n.maxX-n.minX)+o,t.height=Math.max(0,n.maxY-n.minY)+o}e(us,"applyGroupBounds");function hs(t){let n=bo(t),o=t.filter((s)=>s.isGroup&&s.parentId).sort((s,i)=>$e(i,n)-$e(s,n));for(let s of o){let i=t.filter((a)=>a.parentId===s.id),c=Mo(i);if(c)us(s,c)}}e(hs,"recomputeNestedGroupBounds");function re(t,n){let o=t.nodes??[],s=t.edges??[],i=o.filter((h)=>!h.isGroup),c=1/0,a=-1/0;for(let h of i){let d=h[n];if(typeof d!=="number")continue;c=Math.min(c,d),a=Math.max(a,d)}if(!Number.isFinite(c)||!Number.isFinite(a))return!1;let u=e((h)=>c+a-h,"mirror");for(let h of o){let d=h[n];if(typeof d==="number")h[n]=u(d);let m=h.groupTitleRect;if(m)h.groupTitleRect=n==="x"?{...m,left:u(m.right),right:u(m.left)}:{...m,top:u(m.bottom),bottom:u(m.top)}}for(let h of s)for(let d of h.points??[])d[n]=u(d[n]);return!0}e(re,"mirrorAxis");function gs(t){if(!(t.nodes??[]).some((o)=>!o.isGroup))return!0;return re(t,"y")}e(gs,"applyBtDirectionTransform");function ps(t,n="LR"){let o=t.nodes??[],s=t.edges??[],i=o.filter((F)=>!F.isGroup),c=1/0,a=1/0;for(let F of i){let Y=F.x??0,V=F.y??0;if(Y<c)c=Y;if(V<a)a=V}if(!Number.isFinite(c)||!Number.isFinite(a))return!1;let u=36,h=0,d=0;for(let F of i)h+=F.width??0,d+=F.height??0;let m=h/i.length,p=d/i.length,I=p>0?Math.max(1,m/p):1;for(let F of i){let Y=F.x??0,J=((F.y??0)-a)*I+u,lt=Y-c;F.x=J,F.y=lt}for(let F of s){if(!F.points)continue;for(let Y of F.points){let V=Y.x,lt=(Y.y-a)*I+u,xt=V-c;Y.x=lt,Y.y=xt}}hs(o);let y=o.filter((F)=>F.isGroup&&!F.parentId);if(y.length===0){if(n==="RL")re(t,"x");return!0}let g=bo(o),l=new Map;for(let F of o){if(F.isGroup)continue;let Y=ds(F,g);if(!Y)continue;let V=l.get(Y)??[];V.push(F),l.set(Y,V)}let x=0;for(let F of y){let Y=F.padding??0;if(Y>x)x=Y}let L=[],S=1/0,E=-1/0;for(let F of y){let Y=l.get(F.id)??[],V=Mo(Y);if(!V)continue;S=Math.min(S,V.minX),E=Math.max(E,V.maxX),L.push({lane:F,contentTop:V.minY,contentBottom:V.maxY,centerY:(V.minY+V.maxY)/2})}if(S===1/0||E===-1/0)return!0;let w=Math.max(0,E-S),C=Math.max(x,10),b=w+2*C,R=u+b,N=(S+E)/2-b/2-u,H=N+R/2,_=Math.max(x,u);L.sort((F,Y)=>F.centerY-Y.centerY);for(let F=0;F<L.length;F++){let Y=L[F],V,J;if(F===0)V=Y.contentTop-_;else V=(L[F-1].contentBottom+Y.contentTop)/2;if(F===L.length-1)J=Y.contentBottom+_;else{let Ot=L[F+1];J=(Y.contentBottom+Ot.contentTop)/2}let lt=Math.max(0,J-V),xt=(V+J)/2;Y.lane.x=H,Y.lane.y=xt,Y.lane.width=R,Y.lane.height=lt,Y.lane.swimlaneContentTop=Y.contentTop,Y.lane.groupTitleRect={left:N,right:N+u,top:V,bottom:J}}if(n==="RL")re(t,"x");return!0}e(ps,"applyLrDirectionTransform");var an=0.000001,Br=8,Wn=Br,Fr=[0,Wn,-Wn,2*Wn,-2*Wn];function ms(t,n){let{nodeInfoById:o,realNodeRects:s}=le(n);for(let i of t){if(i.isLayoutOnly)continue;let c=i.points;if(!c||c.length<4)continue;let a=fo(yt(c,an),an);if(!a)continue;let{p3:u}=a,h=a.kind==="HVH",d=po(i,o,an);if(!d)continue;let{srcId:m,dstId:p,srcInfo:I,dstInfo:y,collinearX:g,collinearY:l}=d;if(g||l)continue;let x,L=I.rect;for(let S of Fr){let E,w,C;if(h){let H=y.cy>I.cy?L.bottom:L.top,_=I.cx+S;if(_<=L.left+an||_>=L.right-an)continue;E={x:_,y:H},w={x:_,y:u.y},C={x:u.x,y:u.y}}else{let H=y.cx>I.cx?L.right:L.left,_=I.cy+S;if(_<=L.top+an||_>=L.bottom-an)continue;E={x:H,y:_},w={x:u.x,y:_},C={x:u.x,y:u.y}}let b=rn(E,w,an),R=rn(w,C,an);if(b&&R)continue;if(!b&&Nt(E,w,s,[m],1))continue;if(!R&&Nt(w,C,s,[p],1))continue;let O=!b&&te(E,w,t,i,{epsilon:an,skipDegenerateOther:!0}),P=!R&&te(w,C,t,i,{epsilon:an,skipDegenerateOther:!0});if(O||P)continue;if(b)x=[w,C];else if(R)x=[E,w];else x=[E,w,C];break}if(x)i.points=x}}e(ms,"portSwapToLShape");function ys(t,n){let{realNodeRects:c,labelNodeRects:a}=bn(n.values());for(let u of t){if(u.isLayoutOnly)continue;let h=u.points;if(!h||h.length<4)continue;let d=yt(h,0.001);if(d.length<4)continue;let m=d.length-1,p=d[m],I=d[m-1],y=d[m-2],g=p.x-I.x,l=p.y-I.y,x=Math.hypot(g,l);if(x>=10||x<0.001)continue;let L=I.x-y.x,S=I.y-y.y;if(Math.hypot(L,S)<0.001)continue;let w=Tt(I,p,0.001),C=wt(I,p,0.001),b=Tt(y,I,0.001),R=wt(y,I,0.001);if(!(w&&R||C&&b))continue;let{end:O,start:P}=u,N=O?n.get(O):void 0;if(!N)continue;let H=N.x??0,_=N.y??0,F=Zt(N);if(!F)continue;let Y,V;if(R){let q=S<0;Y={x:H,y:y.y},V={x:H,y:q?F.bottom:F.top}}else{let q=L>0;Y={x:y.x,y:_},V={x:q?F.right:F.left,y:_}}if(Nt(Y,V,c,O?[O]:[],-2))continue;if(Nt(Y,V,a,[],-2))continue;if(P){let q=n.get(P),ot=q?Zt(q):void 0;if(ot&&uo(Y,ot,2))continue}let J=e((q,ot)=>`${q.x.toFixed(3)},${q.y.toFixed(3)}|${ot.x.toFixed(3)},${ot.y.toFixed(3)}`,"ownSegmentKey"),lt=new Set;for(let q=0;q<d.length-1;q++)lt.add(J(d[q],d[q+1]));let xt=e((q,ot)=>{for(let dt of t){if(dt===u)continue;if(dt.isLayoutOnly)continue;let mt=dt.points;if(!mt||mt.length<2)continue;for(let Mt=0;Mt<mt.length-1;Mt++){let Et=mt[Mt],jt=mt[Mt+1];if(lt.has(J(Et,jt)))continue;if(un(q,ot,Et,jt,0.001))return!0}}return!1},"segmentCrossesOtherEdge");if(xt(Y,V))continue;if(m-3>=0){let q=d[m-3],ot=[P,O].filter((dt)=>Boolean(dt));if(Nt(q,Y,c,ot,-2))continue;if(xt(q,Y))continue}let kt=[...d.slice(0,m-2),Y,V];u.points=kt;let nt=u.labelNodeId;if(nt){let q=n.get(nt);if(q){let ot=q.width??0,dt=q.height??0;if(ot>0&&dt>0){let mt,Mt,Et=-1;for(let jt=0;jt<kt.length-1;jt++){let Wt=kt[jt],Kt=kt[jt+1],en=Math.hypot(Kt.x-Wt.x,Kt.y-Wt.y),Ln=pt(Wt,Kt,0.001),gn=ht(Wt,Kt,0.001);if(!(Ln&&en>=ot+2||gn&&en>=dt+2))continue;if(en>Et)Et=en,mt=(Wt.x+Kt.x)/2,Mt=(Wt.y+Kt.y)/2}if(mt!==void 0&&Mt!==void 0)q.x=mt,q.y=Mt}}}}}e(ys,"collapseShortTerminalStub");var tt=0.001,Ht=8,xs=e((t)=>typeof t==="string"?t.toUpperCase():"","upperCaseDirection"),at=Bn,Ee=e((t,n)=>ht(t,n,tt)||pt(t,n,tt),"orthogonallyAligned");function ze(t,n){let i=e((y,g)=>{let l=y.x??0,x=y.y??0,L=g.x-l,S=g.y-x,E=(y.width??0)/2,w=(y.height??0)/2;if(Math.abs(S)*E>Math.abs(L)*w){if(S<0)w=-w;return{x:l+(S===0?0:w*L/S),y:x+w}}if(L<0)E=-E;return{x:l+E,y:x+(L===0?0:E*S/L)}},"rectIntersect"),c=e((y,g)=>{let l=yt(y.points??[]);if(l.length<2)return;let x=g?y.start:y.end,L=x?n.get(x):void 0,S=L?Zt(L):void 0;if(!L||!x||!S)return;let E=g?l[0]:l[l.length-1],w=g?l[1]:l[l.length-2],C=i(L,E),b=E;if(Ee(w,C))b=w;if(ht(C,b,tt))return{edge:y,edgeId:String(y.id??""),nodeId:x,atStart:g,orientation:"V",coord:C.x,min:Math.min(C.y,b.y),max:Math.max(C.y,b.y),boundary:C,railEnd:b,rect:S};if(pt(C,b,tt))return{edge:y,edgeId:String(y.id??""),nodeId:x,atStart:g,orientation:"H",coord:C.y,min:Math.min(C.x,b.x),max:Math.max(C.x,b.x),boundary:C,railEnd:b,rect:S};return},"terminalLaneFor"),a=e((y,g)=>Math.max(0,Math.min(y.max,g.max)-Math.max(y.min,g.min)),"projectedOverlapLength"),u=e((y,g)=>{if(y.nodeId!==g.nodeId||y.orientation!==g.orientation)return!1;if(y.orientation==="H")return(Math.abs(y.boundary.x-y.rect.left)<1||Math.abs(y.boundary.x-y.rect.right)<1)&&ht(y.boundary,g.boundary,1);return(Math.abs(y.boundary.y-y.rect.top)<1||Math.abs(y.boundary.y-y.rect.bottom)<1)&&pt(y.boundary,g.boundary,1)},"sameTerminalFace"),h=e((y,g)=>{if(y.nodeId!==g.nodeId||y.orientation!==g.orientation)return!1;return a(y,g)>=Ht&&Math.abs(y.coord-g.coord)<0.5},"exactTerminalLaneConflict"),d=e((y,g)=>{if(y.nodeId!==g.nodeId||y.orientation!==g.orientation||y.orientation!=="H"||y.atStart===g.atStart)return!1;let l=a(y,g);if(l<Ht)return!1;let x=y.rect.bottom-y.rect.top;if(l<x||l>2*x)return!1;return u(y,g)&&Math.abs(y.coord-g.coord)<16},"nearTerminalLaneConflict"),m=e((y,g)=>{let l=yt(y.edge.points??[]);if(l.length<2)return;let x=y.orientation==="V"?{x:y.boundary.x+g,y:y.boundary.y}:{x:y.boundary.x,y:y.boundary.y+g},L=y.orientation==="V"?{x:y.railEnd.x+g,y:y.railEnd.y}:{x:y.railEnd.x,y:y.railEnd.y+g};if(!e(()=>{if(Math.abs(y.boundary.y-y.rect.top)<1||Math.abs(y.boundary.y-y.rect.bottom)<1)return pt(x,y.boundary,tt)&&x.x>=y.rect.left+1&&x.x<=y.rect.right-1;if(Math.abs(y.boundary.x-y.rect.left)<1||Math.abs(y.boundary.x-y.rect.right)<1)return ht(x,y.boundary,tt)&&x.y>=y.rect.top+1&&x.y<=y.rect.bottom-1;return!1},"boundaryStaysOnSameFace")())return;if(y.atStart){let b=l.length>1&&rn(l[1],y.railEnd,tt),R=l.slice(b?2:1),O=R[0];if(O&&!Ee(O,L))return;return[x,L,...R]}let E=l.length>1&&rn(l[l.length-2],y.railEnd,tt),w=l.slice(0,E?-2:-1),C=w[w.length-1];if(C&&!Ee(C,L))return;return[...w,L,x]},"shiftedCandidate"),p=e((y)=>{let g=y.edge,l=yt(g.points??[]);if(l.length!==2)return!1;let{start:x,end:L}=g,S=x?n.get(x):void 0,E=L?n.get(L):void 0;if(!S||!E)return!1;let w=S.x??0,C=S.y??0,b=E.x??0,R=E.y??0,[O,P]=l;return pt(O,P,tt)&&Math.abs(C-R)<1&&Math.abs(w-b)>1||ht(O,P,tt)&&Math.abs(w-b)<1&&Math.abs(C-R)>1},"laneIsStraightCollinearConnector"),I=[-7,7,-14,14,-21,21];for(let y=0;y<8;y++){let g=t.filter((x)=>!x.isLayoutOnly).flatMap((x)=>[c(x,!0),c(x,!1)]).filter((x)=>Boolean(x)),l=!1;for(let x=0;x<g.length&&!l;x++)for(let L=x+1;L<g.length&&!l;L++){let S=g[x],E=g[L];if(S.edge===E.edge||!(h(S,E)||d(S,E)))continue;let w=!h(S,E),C=[S,E].sort((b,R)=>{let O=p(b),P=p(R);if(O!==P)return Number(O)-Number(P);return Number(!R.atStart)-Number(!b.atStart)});for(let b of C){for(let R of I){let O=m(b,R);if(!O)continue;let P=c({...b.edge,points:O},b.atStart);if(!P||g.some((N)=>N.edge!==b.edge&&(h(P,N)||w&&d(P,N))))continue;b.edge.points=O,l=!0;break}if(l)break}}if(!l)return}}e(ze,"separateSharedRenderedTerminalLanes");function bs(t,n){let{realNodeRects:i,labelNodeRects:c}=bn(n.values()),a=e((h,d)=>{let{start:m,end:p}=h,I=at(d);if(I.length!==d.length-1)return!1;let y=[m,p].filter((g)=>Boolean(g));for(let g of I){if(Nt(g.a,g.b,i,y,-2))return!1;if(Nt(g.a,g.b,c,[],-2))return!1}for(let g of t){if(g===h||g.isLayoutOnly)continue;let l=g.points;if(!l||l.length<2)continue;for(let x of I)for(let L of at(yt(l))){if(fn(x,L,0.5)>=Ht)return!1;if(un(x.a,x.b,L.a,L.b,tt))return!1}}return!0},"candidateIsSafe"),u=e((h,d)=>{if(d+4>=h.length)return;let m=h[d],p=h[d+1],I=h[d+2],y=h[d+3],g=h[d+4],l=Tt(m,p)&&wt(p,I)&&Tt(I,y)&&wt(y,g)&&ht(m,y,tt)&&ht(m,g,tt)&&ht(p,I,tt)&&(p.x-m.x)*(y.x-I.x)<0,x=wt(m,p)&&Tt(p,I)&&wt(I,y)&&Tt(y,g)&&pt(m,y,tt)&&pt(m,g,tt)&&pt(p,I,tt)&&(p.y-m.y)*(y.y-I.y)<0;if(l||x)return yt([...h.slice(0,d+1),g,...h.slice(d+5)]);if(d+5>=h.length)return;let L=h[d+5],S=wt(m,p)&&Tt(p,I)&&wt(I,y)&&Tt(y,g)&&wt(g,L)&&ht(m,g,tt)&&ht(m,L,tt)&&ht(I,y,tt)&&(I.x-p.x)*(g.x-y.x)<0,E=Tt(m,p)&&wt(p,I)&&Tt(I,y)&&wt(y,g)&&Tt(g,L)&&pt(m,g,tt)&&pt(m,L,tt)&&pt(I,y,tt)&&(I.y-p.y)*(g.y-y.y)<0;if(!S&&!E)return;return yt([...h.slice(0,d+1),L,...h.slice(d+6)])},"withoutDogleg");for(let h=0;h<8;h++){let d=!1;for(let m of t){if(m.isLayoutOnly)continue;let p=yt(m.points??[]);for(let I=0;I<=p.length-5;I++){let y=u(p,I);if(!y||!a(m,y))continue;m.points=y,d=!0;break}if(d)break}if(!d)return}}e(bs,"collapseRedundantRectangularDoglegs");function Ve(t,n){let{realNodeRects:c,labelNodeRects:a}=bn(n.values()),u=t.filter((g)=>!g.isLayoutOnly),h=e((g,l,x)=>yt(g===l?x??[]:g.points??[]),"pointsFor"),d=e((g,l)=>{let x=0;for(let L=0;L<u.length;L++){let S=at(h(u[L],g,l));for(let E=L+1;E<u.length;E++){let w=at(h(u[E],g,l));for(let C of S)for(let b of w)if(un(C.a,C.b,b.a,b.b,tt))x++}}return x},"strictCrossingCount"),m=e((g)=>{let l=at(g);if(l.length!==3)return;let x=l[1];if(l[0].horizontal===x.horizontal||l[2].horizontal===x.horizontal)return;return{index:x.index,horizontal:x.horizontal,vertical:x.vertical,segment:x}},"middleRail"),p=e((g,l)=>{let x=[g.start,g.end].filter((L)=>Boolean(L));return c.filter((L)=>{if(x.includes(L.id))return!1;let S=L.rect;if(l.horizontal)return Ut(l.a.x,l.b.x,S.left,S.right)>=Ht&&l.a.y>=S.top-2&&l.a.y<=S.bottom+2;return Ut(l.a.y,l.b.y,S.top,S.bottom)>=Ht&&l.a.x>=S.left-2&&l.a.x<=S.right+2})},"blockingRectsFor"),I=e((g,l,x)=>{let L=g.map((E)=>({...E}));if(l.horizontal)L[l.index].y=x,L[l.index+1].y=x;else if(l.vertical)L[l.index].x=x,L[l.index+1].x=x;else return;let S=dn(yt(L));return at(S).length===S.length-1?S:void 0},"candidateByMovingRail"),y=e((g,l,x)=>{let L=[g.start,g.end].filter((E)=>Boolean(E)),S=at(l);if(S.length!==l.length-1)return!1;for(let E of S){if(Nt(E.a,E.b,c,L,-2))return!1;if(Nt(E.a,E.b,a,[],-2))return!1}for(let E of u){if(E===g)continue;for(let w of S)for(let C of at(h(E)))if(fn(w,C,0.5)>=Ht)return!1}return d(g,l)<=x},"candidateIsSafe");for(let g=0;g<8;g++){let l=d(),x=!1;for(let L of u){let S=h(L),E=m(S);if(!E)continue;let w=p(L,E.segment);if(w.length===0)continue;let C=E.horizontal?[Math.min(...w.map((b)=>b.rect.top))-20,Math.max(...w.map((b)=>b.rect.bottom))+20]:[Math.min(...w.map((b)=>b.rect.left))-20,Math.max(...w.map((b)=>b.rect.right))+20];for(let b of C){let R=I(S,E.segment,b);if(!R||!y(L,R,l))continue;L.points=R,x=!0;break}if(x)break}if(!x)return}}e(Ve,"liftObstacleHuggingSameSideRails");function Ue(t,n,o){let i=e((d)=>{let m=d.groupTitleRect;if(!m||typeof m.left!=="number"||typeof m.right!=="number"||typeof m.top!=="number"||typeof m.bottom!=="number"||!Number.isFinite(m.left)||!Number.isFinite(m.right)||!Number.isFinite(m.top)||!Number.isFinite(m.bottom)||m.right<=m.left||m.bottom<=m.top)return;return{left:m.left,right:m.right,top:m.top,bottom:m.bottom}},"validTitleRect"),c=e((d)=>{if(!d.isGroup||d.parentId)return;let m=xs(d.direction??o);if(m==="LR"||m==="RL"||m==="BT")return;let p=i(d),{y:I,height:y}=d;if(!p||typeof I!=="number"||typeof y!=="number"||!Number.isFinite(I)||!Number.isFinite(y)||y<=0)return;let g=p.right-p.left,l=p.bottom-p.top;if(l<=0||g<l)return;return{node:d,rect:p}},"topLaneTitleFor"),a=e((d,m)=>{if(!d.horizontal)return!1;let p=d.a.y;if(p<m.top-tt||p>m.bottom+tt)return!1;return Ut(d.a.x,d.b.x,m.left,m.right)>=Ht},"horizontalSegmentIntersectsTitle"),u=[...n.values()].map(c).filter((d)=>Boolean(d));if(u.length===0)return;let h=0;for(let d of t){if(d.isLayoutOnly)continue;let m=yt(d.points??[]);for(let p of at(m))for(let I of u){if(!a(p,I.rect))continue;h=Math.max(h,I.rect.bottom-p.a.y+4)}}if(h<=tt)return;for(let d of u){let m=d.node.y,p=d.node.height;if(typeof m!=="number"||typeof p!=="number"||!Number.isFinite(m)||!Number.isFinite(p)||p<=0)continue;d.node.y=m-h/2,d.node.height=p+h,d.node.groupTitleRect={...d.rect,top:d.rect.top-h,bottom:d.rect.bottom-h}}}e(Ue,"liftTopLaneTitleBandsAboveRails");function je(t,n,o){let i=e((m)=>{let p=m.groupTitleRect;if(!p||typeof p.left!=="number"||typeof p.right!=="number"||typeof p.top!=="number"||typeof p.bottom!=="number"||!Number.isFinite(p.left)||!Number.isFinite(p.right)||!Number.isFinite(p.top)||!Number.isFinite(p.bottom)||p.right<=p.left||p.bottom<=p.top)return;return{left:p.left,right:p.right,top:p.top,bottom:p.bottom}},"validTitleRect"),c=e((m)=>{if(!m.isGroup||m.parentId)return;if(xs(m.direction??o)!=="LR")return;let I=i(m),{x:y,width:g}=m;if(!I||typeof y!=="number"||typeof g!=="number"||!Number.isFinite(y)||!Number.isFinite(g)||g<=0)return;let l=I.right-I.left,x=I.bottom-I.top;if(l<=0||x<l)return;return{node:m,rect:I}},"leftLaneTitleFor"),a=e((m,p)=>{if(!m.vertical)return!1;let I=m.a.x;if(I<p.left-tt||I>p.right+tt)return!1;return Ut(m.a.y,m.b.y,p.top,p.bottom)>=Ht},"verticalSegmentIntersectsTitle"),u=e((m,p)=>{if(!m.horizontal)return!1;let I=m.a.y;if(I<p.top-tt||I>p.bottom+tt)return!1;return Ut(m.a.x,m.b.x,p.left,p.right)>=Ht},"horizontalSegmentIntersectsTitle"),h=[...n.values()].map(c).filter((m)=>Boolean(m));if(h.length===0)return;let d=0;for(let m of t){if(m.isLayoutOnly)continue;let p=yt(m.points??[]);for(let I of at(p))for(let y of h)if(a(I,y.rect))d=Math.max(d,y.rect.right-I.a.x+4);else if(u(I,y.rect)){let g=Math.min(I.a.x,I.b.x);d=Math.max(d,y.rect.right-g+4)}}if(d<=tt)return;for(let m of h){let p=m.node.x,I=m.node.width;if(typeof p!=="number"||typeof I!=="number"||!Number.isFinite(p)||!Number.isFinite(I)||I<=0)continue;m.node.x=p-d/2,m.node.width=I+d,m.node.groupTitleRect={...m.rect,left:m.rect.left-d,right:m.rect.right-d}}}e(je,"shiftLeftLaneTitleBandsLeftOfRails");function Ms(t,n){let{realNodeRects:i}=bn(n.values()),c=t.filter((l)=>!l.isLayoutOnly),a=e((l,x=new Map)=>yt(x.get(l)??l.points??[]),"replacementPointsFor"),u=e((l=new Map)=>{let x=0;for(let L=0;L<c.length;L++){let S=at(a(c[L],l));for(let E=L+1;E<c.length;E++){let w=at(a(c[E],l));for(let C of S)for(let b of w)if(un(C.a,C.b,b.a,b.b,tt))x++}}return x},"crossingCount"),h=e((l=new Map)=>c.reduce((x,L)=>x+nn(a(L,l)),0),"totalBends"),d=e((l)=>{let x=a(l);if(x.length<4)return;let L=x[x.length-2],S=x[x.length-1];if(!Tt(L,S,tt)&&!wt(L,S,tt))return;return{tailStart:L,terminal:S}},"terminalTailFor"),m=e((l,x)=>{let L=a(l);if(L.length<3)return;let S=L[0],E=L[1],w;if(Tt(S,E,tt))w={x:E.x,y:x.tailStart.y};else if(wt(S,E,tt))w={x:x.tailStart.x,y:E.y};else return;let C=dn(yt([S,E,w,x.tailStart,x.terminal]));return at(C).length===C.length-1?C:void 0},"candidateWithDestinationTail"),p=e((l,x)=>{let L=[l.start,l.end].filter((S)=>Boolean(S));for(let S of at(x))if(Nt(S.a,S.b,i,L,-2))return!0;return!1},"pathHasNodeHit"),I=e((l,x,L)=>{for(let S of c){if(S===l)continue;for(let E of at(x))for(let w of at(a(S,L)))if(fn(E,w,0.5)>=Ht)return!0}return!1},"pathHasSharedTrack"),y=e((l,x,L)=>!p(l,x)&&!I(l,x,L),"candidateIsSafe"),g=e(()=>{let l=new Map;for(let x of c){let L=x.end;if(!L||!n.has(L))continue;if(a(x).length<4)continue;let E=l.get(L)??[];E.push(x),l.set(L,E)}return l},"edgesByDestination");for(let l=0;l<4;l++){let x=u();if(x===0)return;let L=h(),S,E=x,w=L;for(let C of g().values())for(let b=0;b<C.length;b++)for(let R=b+1;R<C.length;R++){let O=C[b],P=C[R],N=d(O),H=d(P);if(!N||!H)continue;let _=m(O,H),F=m(P,N);if(!_||!F)continue;let Y=new Map([[O,_],[P,F]]);if(!y(O,_,Y)||!y(P,F,Y))continue;let V=u(Y),J=h(Y);if(V>=x)continue;if(V>E||V===E&&J>=w)continue;S=Y,E=V,w=J}if(!S)return;for(let[C,b]of S)C.points=b}}e(Ms,"swapDestinationTerminalTailsToReduceCrossings");function Is(t,n){let{realNodeRects:a,labelNodeRects:u}=bn(n.values()),h=t.filter((C)=>!C.isLayoutOnly),d=e((C,b=new Map)=>yt(b.get(C)??C.points??[]),"replacementPointsFor"),m=e((C=new Map)=>{let b=0;for(let R=0;R<h.length;R++){let O=at(d(h[R],C));for(let P=R+1;P<h.length;P++){let N=at(d(h[P],C));for(let H of O)for(let _ of N)if(un(H.a,H.b,_.a,_.b,tt))b++}}return b},"strictCrossingCount"),p=e((C=new Map)=>h.reduce((b,R)=>b+nn(d(R,C)),0),"totalBends"),I=e((C)=>{let{start:b,end:R}=C,O=b?n.get(b):void 0,P=R?n.get(R):void 0,N=O?Zt(O):void 0,H=P?Zt(P):void 0;return N&&H?{src:N,dst:H}:void 0},"endpointRectsFor"),y=e((C,b,R)=>{if(R.index<=0||R.index+1>=b.length-1)return;let O=I(C);if(!O)return;if(R.vertical){let P=R.a.x,N=Math.min(O.src.left,O.dst.left),H=Math.max(O.src.right,O.dst.right),_=P<N-tt?"left":P>H+tt?"right":void 0;if(!_)return;return{edge:C,points:b,segmentIndex:R.index,axis:"vertical",side:_,coord:P,min:Math.min(R.a.y,R.b.y),max:Math.max(R.a.y,R.b.y)}}if(R.horizontal){let P=R.a.y,N=Math.min(O.src.top,O.dst.top),H=Math.max(O.src.bottom,O.dst.bottom),_=P<N-tt?"top":P>H+tt?"bottom":void 0;if(!_)return;return{edge:C,points:b,segmentIndex:R.index,axis:"horizontal",side:_,coord:P,min:Math.min(R.a.x,R.b.x),max:Math.max(R.a.x,R.b.x)}}return},"externalRailForSegment"),g=e(()=>{let C=[];for(let b of h){let R=d(b);for(let O of at(R)){let P=y(b,R,O);if(P)C.push(P)}}return C},"collectExternalRails"),l=e((C,b)=>C.edge!==b.edge&&C.axis===b.axis&&C.side===b.side&&Ut(C.min,C.max,b.min,b.max)>=Ht,"railsInteract"),x=e((C)=>{let b=[],R=new Set;for(let O of C){if(R.has(O))continue;let P=[O],N=[];R.add(O);while(P.length>0){let H=P.pop();N.push(H);for(let _ of C)if(!R.has(_)&&l(H,_))R.add(_),P.push(_)}if(N.length>1)b.push(N)}return b},"connectedComponents"),L=e((C)=>{let b=[];for(let R of C)if(!b.some((O)=>Math.abs(O-R.coord)<tt))b.push(R.coord);while(b.length<C.length){let R=Math.min(...b),O=Math.max(...b),P=C[0].side;b.push(P==="left"||P==="top"?R-12*(C.length-b.length):O+12*(C.length-b.length))}return b},"uniqueCoordsFor"),S=e((C)=>{let b=C.map((P)=>P.coord),R=L(C),O=[];if(C.length<=6){let P=Array(R.length).fill(!1),N=[],H=e(()=>{if(N.length===C.length){if(N.some((_,F)=>Math.abs(_-b[F])>=tt))O.push([...N]);return}for(let[_,F]of R.entries()){if(P[_])continue;P[_]=!0,N.push(F),H(),N.pop(),P[_]=!1}},"visit");return H(),O}for(let P=0;P<b.length;P++)for(let N=P+1;N<b.length;N++){let H=[...b];[H[P],H[N]]=[H[N],H[P]],O.push(H)}return O},"coordinateAssignmentsFor"),E=e((C,b)=>{let R=new Map;for(let[P,N]of C.entries()){let H=b[P],_=R.get(N.edge)??N.points.map((F)=>({x:F.x,y:F.y}));if(N.axis==="vertical")_[N.segmentIndex].x=H,_[N.segmentIndex+1].x=H;else _[N.segmentIndex].y=H,_[N.segmentIndex+1].y=H;R.set(N.edge,_)}let O=new Map;for(let[P,N]of R){let H=dn(yt(N));if(at(H).length!==H.length-1)return;O.set(P,H)}return O},"replacementsForAssignment"),w=e((C)=>{for(let[b,R]of C){let O=[b.start,b.end].filter((P)=>Boolean(P));for(let P of at(R)){if(Nt(P.a,P.b,a,O,-2))return!1;if(Nt(P.a,P.b,u,[],-2))return!1}}for(let b=0;b<h.length;b++){let R=h[b],O=C.has(R),P=at(d(R,C));for(let N=b+1;N<h.length;N++){let H=h[N];if(!O&&!C.has(H))continue;let _=at(d(H,C));for(let F of P)for(let Y of _)if(fn(F,Y,0.5)>=Ht)return!1}}return!0},"candidateIsSafe");for(let C=0;C<4;C++){let b=m();if(b===0)return;let R,O=b,P=p(),N=Number.POSITIVE_INFINITY;for(let H of x(g()))for(let _ of S(H)){let F=E(H,_);if(!F||!w(F))continue;let Y=m(F);if(Y>=b)continue;let V=p(F),J=H.reduce((lt,xt,Ot)=>lt+Math.abs(_[Ot]-xt.coord),0);if(Y>O||Y===O&&(V>P||V===P&&J>=N))continue;R=F,O=Y,P=V,N=J}if(!R)return;for(let[H,_]of R)H.points=_}}e(Is,"reassignCrossingExternalRailChannels");function Ss(t,n){let{realNodeRects:i,labelNodeRects:c}=bn(n.values()),a=t.filter((g)=>!g.isLayoutOnly),u=e((g,l,x)=>yt(g===l?x??[]:g.points??[]),"pointsFor"),h=e((g)=>at(g).reduce((l,x)=>{let L=x.a.x-x.b.x,S=x.a.y-x.b.y;return l+Math.hypot(L,S)},0),"pathLength"),d=e((g,l)=>{let x=0;for(let L=0;L<a.length;L++){let S=at(u(a[L],g,l));for(let E=L+1;E<a.length;E++){let w=at(u(a[E],g,l));for(let C of S)for(let b of w)if(un(C.a,C.b,b.a,b.b,tt))x++}}return x},"strictCrossingCount"),m=e((g,l)=>{if(g.horizontal){let x=g.a.y;return(Math.abs(x-l.top)<1||Math.abs(x-l.bottom)<1)&&Ut(g.a.x,g.b.x,l.left,l.right)>=Ht}if(g.vertical){let x=g.a.x;return(Math.abs(x-l.left)<1||Math.abs(x-l.right)<1)&&Ut(g.a.y,g.b.y,l.top,l.bottom)>=Ht}return!1},"segmentRunsAlongRectBorder"),p=e((g)=>{let l=[g.start,g.end].filter((L)=>Boolean(L)),x=[];for(let L of l){let S=n.get(L),E=S?Zt(S):void 0;if(E)x.push(E)}return x},"endpointRectsFor"),I=e((g,l)=>{if(l+3>=g.length)return[];let x=g[l],L=g[l+1],S=g[l+2],E=g[l+3],w=Tt(x,L,tt)&&wt(L,S,tt)&&Tt(S,E,tt),C=wt(x,L,tt)&&Tt(L,S,tt)&&wt(S,E,tt);if(!w&&!C)return[];if(!(w?Math.sign(L.x-x.x)!==Math.sign(E.x-S.x):Math.sign(L.y-x.y)!==Math.sign(E.y-S.y)))return[];let R=ht(x,E,tt)||pt(x,E,tt)?[]:[{x:x.x,y:E.y},{x:E.x,y:x.y}],O=R.length===0?[[...g.slice(0,l+1),...g.slice(l+3)]]:R.map((N)=>[...g.slice(0,l+1),N,...g.slice(l+3)]),P=new Set;return O.map((N)=>dn(yt(N))).filter((N)=>{if(at(N).length!==N.length-1)return!1;if(!N.some((_)=>rn(_,E,tt)))return!1;let H=N.map((_)=>`${_.x.toFixed(3)},${_.y.toFixed(3)}`).join("|");if(P.has(H))return!1;return P.add(H),!0})},"shortcutCandidatesAt"),y=e((g,l,x)=>{let L=[g.start,g.end].filter((E)=>Boolean(E)),S=p(g);for(let E of at(l)){if(Nt(E.a,E.b,i,L,-2))return!1;if(Nt(E.a,E.b,c,[],-2))return!1;if(S.some((w)=>m(E,w)))return!1}for(let E of a){if(E===g)continue;for(let w of at(l))for(let C of at(u(E)))if(fn(w,C,0.5)>=Ht)return!1}return d(g,l)<=x},"candidateIsSafe");for(let g=0;g<8;g++){let l=d(),x,L,S=l,{POSITIVE_INFINITY:E,POSITIVE_INFINITY:w}=Number;for(let C of a){let b=u(C),R=nn(b,tt),O=h(b);for(let P=0;P<=b.length-4;P++)for(let N of I(b,P)){let H=nn(N,tt),_=h(N);if(!(H<R||H===R&&_<O-tt)||!y(C,N,l))continue;let Y=d(C,N);if(Y>S||Y===S&&(H>E||H===E&&_>=w))continue;x=C,L=N,S=Y,E=H,w=_}}if(!x||!L)return;x.points=L}}e(Ss,"shortcutRedundantOrthogonalJogs");function Cs(t,n){let a=[];for(let B of n.values()){if(B.isGroup||B.isEdgeLabel)continue;let D=B.x??0,X=B.y??0,W=Zt(B);if(!W)continue;a.push({id:String(B.id??""),cx:D,cy:X,rect:W})}if(a.length===0)return;let u=new Map(a.map((B)=>[B.id,B])),h=a.map((B)=>({id:B.id,rect:B.rect})),d=["top","bottom","left","right"],m={top:Math.min(...a.map((B)=>B.rect.top))-20,bottom:Math.max(...a.map((B)=>B.rect.bottom))+20,left:Math.min(...a.map((B)=>B.rect.left))-20,right:Math.max(...a.map((B)=>B.rect.right))+20},p=t.filter((B)=>!B.isLayoutOnly),I=new Map(p.map((B,D)=>[B,D])),y=e((B)=>{let D=B==="left"||B==="top"?-1:1,X=[];for(let W=0;W<=2;W++)X.push(m[B]+D*20*W);return X},"outwardTracksForSide"),g=e((B,D=new Map)=>yt(D.get(B)??B.points??[]),"replacementPointsFor"),l=e((B,D)=>{let X=0;for(let W of B)for(let f of D)if(un(W.a,W.b,f.a,f.b,tt))X++;return X},"crossingCountBetweenSegments"),x=e((B,D)=>l(at(B),at(D)),"crossingCountBetweenPaths"),L=e((B=new Map)=>{let D=0,X=[],W=new Set,f=[],M=e((v)=>{if(!W.has(v))W.add(v),f.push(v)},"addEdge");for(let v=0;v<p.length;v++){let A=p[v],T=g(A,B);for(let k=v+1;k<p.length;k++){let K=p[k],Q=x(T,g(K,B));if(Q>0)D+=Q,X.push({first:A,second:K,count:Q}),M(A),M(K)}}return f.sort((v,A)=>(I.get(v)??0)-(I.get(A)??0)),{count:D,pairs:X,edgeSet:W,edges:f}},"crossingSnapshot"),S=e((B,D)=>{let X=new Set(D.keys());if(X.size===0)return B.count;let W=0;for(let M of B.pairs)if(X.has(M.first)||X.has(M.second))W+=M.count;let f=0;for(let M=0;M<p.length;M++){let v=p[M],A=X.has(v),T=g(v,D);for(let k=M+1;k<p.length;k++){let K=p[k];if(!A&&!X.has(K))continue;f+=x(T,g(K,D))}}return B.count-W+f},"crossingCountWithReplacements"),E=e((B)=>{let D=new Map;for(let f of B.pairs){let M=D.get(f.first)??new Set;M.add(f.second),D.set(f.first,M);let v=D.get(f.second)??new Set;v.add(f.first),D.set(f.second,v)}let X=[],W=new Set;for(let f of B.edges){if(W.has(f))continue;let M=[f],v=[];W.add(f);while(M.length>0){let A=M.pop();v.push(A);for(let T of D.get(A)??[])if(!W.has(T))W.add(T),M.push(T)}if(v.sort((A,T)=>(I.get(A)??0)-(I.get(T)??0)),v.length>1)X.push(v)}return X},"crossingComponents"),w=e((B)=>[B.start,B.end].filter((D)=>Boolean(D)),"endpointIdsFor"),C=e((B)=>{let D=[];for(let X of E(B)){let W=new Set(X),f=new Set(X.flatMap((v)=>w(v))),M=[...X];for(let v of p){if(W.has(v))continue;if(w(v).some((A)=>f.has(A)))M.push(v)}M.sort((v,A)=>(I.get(v)??0)-(I.get(A)??0)),D.push(M)}return D},"pairSearchGroups"),b=e((B,D,X)=>S(B,new Map([[D,X]])),"crossingCountWithSingleReplacement"),R=e((B)=>{let D=new Map;for(let X of B.pairs)D.set(X.first,(D.get(X.first)??0)+X.count),D.set(X.second,(D.get(X.second)??0)+X.count);return D},"currentCrossingsByEdge"),O=e((B)=>B.slice(1).reduce((D,X,W)=>{let f=B[W];return D+Math.abs(X.x-f.x)+Math.abs(X.y-f.y)},0),"pathLength"),P=e((B=new Map)=>p.reduce((D,X)=>D+nn(g(X,B)),0),"totalBends"),N=e((B=new Map)=>p.reduce((D,X)=>D+O(g(X,B)),0),"totalLength"),H=e((B,D,X=new Map)=>{let W=at(D);for(let f of p){if(f===B)continue;for(let M of W)for(let v of at(g(f,X)))if(fn(M,v,0.5)>=Ht)return!0}return!1},"pathHasSegmentConflict"),_=e((B,D)=>{let X=[B.start,B.end].filter((W)=>Boolean(W));for(let W of at(D))if(Nt(W.a,W.b,h,X,-2))return!0;return!1},"pathHitsNode"),F=e((B,D)=>{let X=dn(yt(D));if(at(X).length===X.length-1)B.push(X)},"pushOrthogonalCandidate"),Y=e((B)=>B==="left"||B==="right","sideIsHorizontal"),V=e((B,D,X)=>{switch(D){case"left":return Math.min(B.x,X.x)-20;case"right":return Math.max(B.x,X.x)+20;case"top":return Math.min(B.y,X.y)-20;case"bottom":return Math.max(B.y,X.y)+20}},"localTrackForSameSide"),J=e((B,D,X,W)=>{let f=X==="left"||X==="top"?-1:1,M=[V(D,X,W),m[X]];for(let v of M)for(let A=0;A<=2;A++)F(B,go(D,X,W,v+f*20*A))},"addSameSideCandidates"),lt=e((B,D,X,W,f)=>{for(let M of y(X))for(let v of y(f))F(B,[D,{x:M,y:D.y},{x:M,y:v},{x:W.x,y:v},W])},"addHorizontalToVerticalCandidates"),xt=e((B,D,X,W,f)=>{for(let M of y(X))for(let v of y(f))F(B,[D,{x:D.x,y:M},{x:v,y:M},{x:v,y:W.y},W])},"addVerticalToHorizontalCandidates"),Ot=e((B,D,X,W,f)=>{let M=[...y("top"),...y("bottom")];for(let v of y(X))for(let A of y(f))for(let T of M)F(B,[D,{x:v,y:D.y},{x:v,y:T},{x:A,y:T},{x:A,y:W.y},W])},"addHorizontalPairCandidates"),kt=e((B,D,X,W,f)=>{let M=[...y("left"),...y("right")];for(let v of y(X))for(let A of y(f))for(let T of M)F(B,[D,{x:D.x,y:v},{x:T,y:v},{x:T,y:A},{x:W.x,y:A},W])},"addVerticalPairCandidates"),nt=e((B)=>{let D=new Set;return B.map((X)=>yt(X)).filter((X)=>{let W=X.map((f)=>`${f.x.toFixed(3)},${f.y.toFixed(3)}`).join("|");if(D.has(W)||X.length<2)return!1;return D.add(W),!0})},"dedupeCandidatePaths"),q=e((B,D,X,W)=>{let f=[],M=ho(B,D,X,W,20,tt);if(M)F(f,M);if(D===W)J(f,B,D,X);let v=Y(D),A=Y(W);if(v&&!A)lt(f,B,D,X,W);else if(!v&&A)xt(f,B,D,X,W);else if(v)Ot(f,B,D,X,W);else kt(f,B,D,X,W);return nt(f)},"buildCandidatesForSides"),ot=e((B,D,X,W)=>{let f=[...y("left"),...y("right")],M=[...y("top"),...y("bottom")];for(let v of d){let A=vn(W,v),T=v==="top"||v==="bottom"?y(v):M;for(let k of f){F(B,[D,X,{x:k,y:X.y},{x:k,y:A.y},A]);for(let K of T)F(B,[D,X,{x:k,y:X.y},{x:k,y:K},{x:A.x,y:K},A])}}},"addVerticalDepartureOuterTrackCandidates"),dt=e((B,D,X,W)=>{let f=[...y("left"),...y("right")],M=[...y("top"),...y("bottom")];for(let v of d){let A=vn(W,v),T=v==="left"||v==="right"?y(v):f;for(let k of M){F(B,[D,X,{x:X.x,y:k},{x:A.x,y:k},A]);for(let K of T)F(B,[D,X,{x:X.x,y:k},{x:K,y:k},{x:K,y:A.y},A])}}},"addHorizontalDepartureOuterTrackCandidates"),mt=e((B)=>{let{start:D,end:X}=B,W=X?u.get(X):void 0;if(!D||!W)return[];let f=yt(B.points??[]);if(f.length<4)return[];let M=f[0],v=f[1],A=[];if(wt(M,v,tt))ot(A,M,v,W);else if(Tt(M,v,tt))dt(A,M,v,W);return A},"terminalPreservingOuterTrackCandidates"),Mt=e((B)=>{let{start:D,end:X}=B,W=D?u.get(D):void 0,f=X?u.get(X):void 0;if(!W||!f)return[];let M=[];for(let v of d){let A=vn(W,v);for(let T of d)M.push(...q(A,v,vn(f,T),T))}return M.push(...mt(B)),M},"candidatePathsFor"),Et=e(()=>new Map(p.map((B)=>[B,at(g(B))])),"currentSegmentsByEdge"),jt=e((B,D,X)=>{let W=new Set;for(let f of p){if(f===B)continue;let M=X.get(f)??at(g(f));if(D.some((v)=>M.some((A)=>fn(v,A,0.5)>=Ht)))W.add(f)}return W},"sharedTrackConflictsFor"),Wt=e((B,D,X,W)=>{let f=new Set;return Mt(B).map((v)=>dn(yt(v))).filter((v)=>{if(_(B,v))return!1;let A=v.map((T)=>`${T.x.toFixed(3)},${T.y.toFixed(3)}`).join("|");if(f.has(A)||v.length<2)return!1;return f.add(A),!0}).map((v)=>{let A=at(v),T=0;for(let k of p){if(k===B)continue;T+=l(A,X.get(k)??at(g(k)))}return{candidate:v,candidateSegments:A,crossings:D.count-(W.get(B)??0)+T,bends:nn(v,tt),totalBends:nn(v),length:O(v)}}).filter(({crossings:v})=>v<=D.count).sort((v,A)=>v.crossings-A.crossings||v.bends-A.bends||v.length-A.length).slice(0,48).map((v)=>({path:v.candidate,segments:v.candidateSegments,sharedTrackConflicts:jt(B,v.candidateSegments,X),totalBends:v.totalBends,length:v.length}))},"pairCandidatesFor"),Kt=e((B,D,X,W,f,M)=>{let v=0;for(let T of B.pairs)if(T.first===D||T.second===D||T.first===W||T.second===W)v+=T.count;let A=l(X.segments,f.segments);for(let T of p){if(T===D||T===W)continue;let k=M.get(T)??at(g(T));A+=l(X.segments,k)+l(f.segments,k)}return B.count-v+A},"pairCrossingCount"),en=e((B,D)=>{for(let X of B.sharedTrackConflicts)if(X!==D)return!1;return!0},"conflictsOnlyWith"),Ln=e((B,D)=>B.segments.some((X)=>D.segments.some((W)=>fn(X,W,0.5)>=Ht)),"candidatesShareTrack"),gn=e((B,D,X,W)=>en(D,X.edge)&&en(W,B.edge)&&!Ln(D,W),"pairCandidatesAreCompatible"),En=e((B,D,X,W,f)=>{let M=Kt(B.current,D.edge,X,W.edge,f,B.baseSegments);if(M>=B.current.count)return;return{replacements:new Map([[D.edge,X.path],[W.edge,f.path]]),crossings:M,bends:B.currentBends-(B.baseBendsByEdge.get(D.edge)??0)-(B.baseBendsByEdge.get(W.edge)??0)+X.totalBends+f.totalBends,length:B.currentLength-(B.baseLengthByEdge.get(D.edge)??0)-(B.baseLengthByEdge.get(W.edge)??0)+X.length+f.length}},"scorePairReplacement"),he=e((B,D)=>B.crossings<D.crossings||B.crossings===D.crossings&&(B.bends<D.bends||B.bends===D.bends&&B.length<D.length),"pairScoreIsBetter"),ge=e((B,D,X,W)=>{let f=W;for(let M of D.candidates)for(let v of X.candidates){if(!gn(D,M,X,v))continue;let A=En(B,D,M,X,v);if(A&&he(A,f))f=A}return f},"bestScoreForOptionPair"),pe=e((B)=>{let D=P(),X=N(),W=Et(),f=R(B),M=new Map(p.map((Q)=>[Q,nn(g(Q))])),v=new Map(p.map((Q)=>[Q,O(g(Q))])),A=new Map,T=C(B);for(let Q of T)for(let j of Q){if(A.has(j))continue;let z=Wt(j,B,W,f);if(z.length>0)A.set(j,{edge:j,candidates:z})}let k={replacements:new Map,crossings:B.count,bends:D,length:X},K={current:B,currentBends:D,currentLength:X,baseBendsByEdge:M,baseLengthByEdge:v,baseSegments:W};for(let Q of T){let j=new Set(Q.filter((rt)=>B.edgeSet.has(rt))),z=Q.map((rt)=>A.get(rt)).filter((rt)=>Boolean(rt));for(let rt=0;rt<z.length;rt++){let ct=z[rt];for(let it=rt+1;it<z.length;it++){let et=z[it];if(!j.has(ct.edge)&&!j.has(et.edge))continue;k=ge(K,ct,et,k)}}}return k.replacements.size>0?k.replacements:void 0},"bestPairedReplacement");for(let B=0;B<4;B++){let D=L(),X=D.count;if(X===0)return;let W,f,M=X,v=Number.POSITIVE_INFINITY;for(let T of D.edges){let k=nn(g(T),tt);for(let K of Mt(T)){let Q=_(T,K),j=!Q&&H(T,K),z=b(D,T,K),rt=nn(K,tt);if(Q||j)continue;if(!(z<X||z===X&&rt<k))continue;if(z>M||z===M&&rt>=v)continue;W=T,f=K,M=z,v=rt}}if(W&&f){W.points=f;continue}let A=pe(D);if(!A)return;for(let[T,k]of A)T.points=k}}e(Cs,"resolveRenderedOrthogonalCrossings");var xn=0.001,Pr=8;function vs(t,n){let{nodeInfoById:o,realNodeRects:s}=le(n),i=["top","bottom","left","right"],c=20,a={top:Math.min(...s.map((l)=>l.rect.top))-20,bottom:Math.max(...s.map((l)=>l.rect.bottom))+20,left:Math.min(...s.map((l)=>l.rect.left))-20,right:Math.max(...s.map((l)=>l.rect.right))+20},u=e((l,x,L,S)=>{let E=[],w=ho(l,x,L,S,20,xn);if(w)E.push(w);if(x===S)E.push(go(l,x,L,a[x]));return E},"buildOrthogonalPathCandidates"),h=e((l,x)=>{for(let L=0;L<l.length-1;L++){let S=l[L],E=l[L+1];if(Nt(S,E,s,x,1))return!0}return!1},"pathHitsNode"),d=e((l,x,L=!1)=>{let S=0,E=Bn(l,xn),{start:w,end:C}=x;for(let b of t){if(b===x||b.isLayoutOnly)continue;let{start:R,end:O}=b;if(!L&&w&&C&&(R===w||R===C||O===w||O===C))continue;let P=b.points;if(!P||P.length<2)continue;for(let N of E)for(let H of Bn(P,xn)){if(mo(N.a,N.b,H.a,H.b,xn,xn)){S++;continue}if(fn(N,H,xn)>=Pr)S++}}return S},"pathConflictCount"),m=4,p=e((l,x)=>{let L=Math.abs(l.y-x.rect.top),S=Math.abs(l.y-x.rect.bottom),E=Math.abs(l.x-x.rect.left),w=Math.abs(l.x-x.rect.right),C="top",b=L;if(S<b)C="bottom",b=S;if(E<b)C="left",b=E;if(w<b)C="right",b=w;return C},"nearestSideOfRect"),I=new Map,y=e((l,x,L)=>{let S=I.get(l)??[];S.push({side:x,edgeId:L}),I.set(l,S)},"addFaceClaim");for(let l of t){if(l.isLayoutOnly)continue;let x=l.points??[];if(x.length<1)continue;let L=l.id??"",{start:S,end:E}=l;if(S){let w=o.get(S);if(w)y(S,p(x[0],w),L)}if(E){let w=o.get(E);if(w)y(E,p(x[x.length-1],w),L)}}let g=e((l,x,L)=>I.get(l)?.some((S)=>S.edgeId!==L&&S.side===x)??!1,"faceIsClaimed");for(let l of t){if(l.isLayoutOnly)continue;let x=l.points;if(!x||x.length<2)continue;let L=nn(x,xn);if(L<4)continue;let{start:S,end:E}=l;if(!S||!E)continue;let w=o.get(S),C=o.get(E);if(!w||!C)continue;let b=l.id??"",R=d(x,l,!0),O=d(x,l),P,N=R,H=L;for(let _ of i){if(g(S,_,b))continue;let F=vn(w,_);for(let Y of i){if(g(E,Y,b))continue;let V=vn(C,Y);for(let J of u(F,_,V,Y)){if(h(J,[S,E]))continue;let lt=nn(J,xn);if(R>0){let xt=d(J,l,!0);if(xt>N||xt===N&<>=H)continue;N=xt,H=lt,P=J;continue}if(d(J,l)>O)continue;if(lt<H)H=lt,P=J}}}if(P){l.points=P;let _=I.get(S);if(_)I.set(S,_.filter((Y)=>Y.edgeId!==b));let F=I.get(E);if(F)I.set(E,F.filter((Y)=>Y.edgeId!==b));y(S,p(P[0],w),b),y(E,p(P[P.length-1],C),b)}}}e(vs,"simplifyDetouredEdges");var Jt=0.001,zo=10,Kn=7;function We(t,n){let o=n?0:t.length-1,s=n?1:-1,i=t[o],c=t[o+s];if(!i||!c)return;let a=c.x-i.x,u=c.y-i.y;if(Math.abs(a)+Math.abs(u)<Jt)return;if(Math.abs(u)<=Jt){let d=i.x+Math.sign(a)*zo;return{left:Math.min(i.x,d),right:Math.max(i.x,d),top:i.y-Kn,bottom:i.y+Kn}}if(Math.abs(a)<=Jt){let d=i.y+Math.sign(u)*zo;return{left:i.x-Kn,right:i.x+Kn,top:Math.min(i.y,d),bottom:Math.max(i.y,d)}}return{left:Math.min(i.x,c.x),right:Math.max(i.x,c.x),top:Math.min(i.y,c.y),bottom:Math.max(i.y,c.y)}}e(We,"markerClearanceRectFor");function Ls(t){return{left:Math.min(t.left,t.right),right:Math.max(t.left,t.right),top:Math.min(t.top,t.bottom),bottom:Math.max(t.top,t.bottom)}}e(Ls,"normalizeRect");function Ke(t,n){let o=yt(n),s=We(o,!0),i=We(o,!1);return[s,i].some((c)=>c&&Qn(t,Ls(c)))}e(Ke,"labelOverlapsOwnMarker");function Jn(t,n){let o=[];for(let g of t){if(g.isLayoutOnly)continue;let l=g.points;if(!l||l.length<2)continue;for(let x=0;x<l.length-1;x++)o.push({edgeId:g.id,p1:l[x],p2:l[x+1]})}let s=[],i=[];for(let g of n.values()){let{isGroup:l,parentId:x}=g;if(l&&!x){let S=Zt(g);if(S)i.push({id:g.id,rect:S});continue}if(l)continue;if(g.isEdgeLabel)continue;let L=Zt(g);if(!L)continue;s.push({nodeId:g.id,rect:L})}let c=3,a=1,u=12,h=e((g,l)=>{let x=we(l,c);for(let{nodeId:L,rect:S}of s){if(L===g)continue;if(Qn(x,S))return!0}return!1},"labelOverlapsForeignNode"),d=e((g,l)=>{let x=we(l,c);for(let L of o){if(L.edgeId===g)continue;if(ae(L.p1,L.p2,x))return!0}return!1},"labelOverlapsForeignEdge"),m=e((g,l,x)=>h(g,x)||d(l,x),"labelOverlapsAnything"),p=[],I=e((g)=>{for(let{id:l,rect:x}of i)if(Qo(x,g))return l;return},"findContainingLane"),y=e((g,l)=>p.some((x)=>x.labelId!==g&&Qn(l,x.rect)),"overlapsPlacedLabel");for(let g of t){if(g.isLayoutOnly)continue;let l=g.labelNodeId;if(!l)continue;let x=n.get(l);if(!x)continue;let L=g.points;if(!L||L.length<2)continue;let S=x.width??0,E=x.height??0;if(S<=0||E<=0)continue;let w=[];for(let nt=0;nt<L.length-1;nt++){let q=L[nt],ot=L[nt+1],dt=Math.abs(q.x-ot.x),mt=Math.abs(q.y-ot.y);if(dt<Jt&&mt<Jt)continue;if(dt>=Jt&&mt>=Jt)continue;w.push({idx:nt,length:dt+mt,orientation:dt>=Jt?"horizontal":"vertical",midX:(q.x+ot.x)/2,midY:(q.y+ot.y)/2})}if(w.length===0)continue;let C=w.length>=3?w.filter((nt)=>nt.idx>0&&nt.idx<w.length-1):w,b=C.length>0?C:w,R=S>=E?"horizontal":"vertical",O=e((nt)=>[...nt].sort((q,ot)=>{let dt=q.orientation===R,mt=ot.orientation===R;if(dt!==mt)return dt?-1:1;let Mt=q.length>=(q.orientation==="horizontal"?S:E)+2,Et=ot.length>=(ot.orientation==="horizontal"?S:E)+2;if(Mt!==Et)return Mt?-1:1;return ot.length-q.length}),"rankSegments"),P=w[0],N=w[w.length-1],H=[0.5,0.25,0.75,0.05,0.95,0.15,0.85,0.1,0.9],_=e((nt,q)=>{let ot=L[nt.idx],dt=L[nt.idx+1];return{midX:ot.x+(dt.x-ot.x)*q,midY:ot.y+(dt.y-ot.y)*q}},"anchorAtT"),F=e((nt,q,ot)=>Math.min(ot,Math.max(q,nt)),"clamp"),Y=e((nt,q)=>nt.midX>=q.left-Jt&&nt.midX<=q.right+Jt&&nt.midY>=q.top-Jt&&nt.midY<=q.bottom+Jt,"pointInsideRectInclusive"),V=e((nt)=>{let q=On(nt.midX,nt.midY,S,E),ot=I(q);if(ot)return{laneId:ot,anchor:nt,rect:q};let dt=i.find(({rect:en})=>Y(nt,en));if(!dt)return;let mt=dt.rect.left+S/2+a,Mt=dt.rect.right-S/2-a,Et=dt.rect.top+E/2+a,jt=dt.rect.bottom-E/2-a;if(mt>Mt||Et>jt)return;let Wt={midX:F(nt.midX,mt,Mt),midY:F(nt.midY,Et,jt)},Kt=On(Wt.midX,Wt.midY,S,E);return Y(nt,Kt)?{laneId:dt.id,anchor:Wt,rect:Kt}:void 0},"placementForAnchor"),J=e((nt,q,ot)=>nt.orientation==="horizontal"?Math.abs(q.midX-ot.x):Math.abs(q.midY-ot.y),"distanceAlongSegment"),lt=e((nt,q)=>{let dt=(nt.orientation==="horizontal"?S/2:E/2)+u;if(nt===P){let mt=L[nt.idx];if(J(nt,q,mt)+Jt<dt)return!1}if(nt===N){let mt=L[nt.idx+1];if(J(nt,q,mt)+Jt<dt)return!1}return!0},"labelClearsTerminalEndpoints"),xt=e((nt)=>{let q=O(nt);for(let ot of q)for(let dt of H){let mt=_(ot,dt);if(!lt(ot,mt))continue;let Mt=V(mt);if(!Mt)continue;if(Ke(Mt.rect,L))continue;if(y(l,Mt.rect))continue;if(!m(l,g.id,Mt.rect))return{laneId:Mt.laneId,anchor:Mt.anchor}}return},"tryPool"),Ot=e((nt,q,ot=!1)=>{let dt=O(nt);for(let mt of dt){let Mt={midX:mt.midX,midY:mt.midY};if(q&&!lt(mt,Mt))continue;let Et=V(Mt);if(Et&&!Ke(Et.rect,L)&&!y(l,Et.rect)&&!h(l,Et.rect)&&(ot||!d(g.id,Et.rect)))return{laneId:Et.laneId,anchor:Et.anchor}}return},"findLaneContainingFallback"),kt=xt(b)??(b.length<w.length?xt(w):void 0)??Ot(w,!0)??Ot(w,!1)??Ot(w,!1,!0);if(kt){x.x=kt.anchor.midX,x.y=kt.anchor.midY,x.parentId=kt.laneId;let nt=On(kt.anchor.midX,kt.anchor.midY,S,E),q=p.findIndex((ot)=>ot.labelId===l);if(q>=0)p[q]={labelId:l,rect:nt};else p.push({labelId:l,rect:nt})}}}e(Jn,"anchorLabelsToPolyline");var Ae=0.000001,kr=8,Vo=kr/2,_r=3;function qe(t,n){return t<n?`${t}::${n}`:`${n}::${t}`}e(qe,"pairKey");function Es(t,n){let{nodeInfoById:o,realNodeRects:s}=le(n),i=new Map;for(let a of n){let u=a.id;if(a.isGroup)continue;if(a.isEdgeLabel){i.set(u,{w:a.width??0,h:a.height??0});continue}}let c=e((a,u,h,d)=>{let m=qe(u,h),p=0,I=e((y)=>{if(!y)return;let g=i.get(y);if(!g)return;let l=d==="x"?g.w/2:g.h/2;if(l>p)p=l},"consider");I(a.labelNodeId);for(let y of t){if(y===a)continue;if(y.isLayoutOnly)continue;let{start:g,end:l}=y;if(!g||!l)continue;if(qe(g,l)!==m)continue;I(y.labelNodeId)}return p>0?p+_r:0},"labelClearanceFor");for(let a of t){if(a.isLayoutOnly)continue;let u=a.points;if(!fo(u,Ae))continue;let h=po(a,o,Ae);if(!h)continue;let{srcId:d,dstId:m,srcInfo:p,dstInfo:I,collinearX:y,collinearY:g}=h;if(y===g)continue;let l,x;if(y){let C=I.cy>p.cy;l={x:p.cx,y:C?p.rect.bottom:p.rect.top},x={x:I.cx,y:C?I.rect.top:I.rect.bottom}}else{let C=I.cx>p.cx;l={x:C?p.rect.right:p.rect.left,y:p.cy},x={x:C?I.rect.left:I.rect.right,y:I.cy}}if(Nt(l,x,s,[d,m],1))continue;let S=c(a,d,m,y?"x":"y"),E=S>Vo?S:Vo,w=[0,E,-E];for(let C of w){let b={...l},R={...x};if(y){if(b.x+=C,R.x+=C,b.x<=p.rect.left||b.x>=p.rect.right)continue;if(R.x<=I.rect.left||R.x>=I.rect.right)continue}else{if(b.y+=C,R.y+=C,b.y<=p.rect.top||b.y>=p.rect.bottom)continue;if(R.y<=I.rect.top||R.y>=I.rect.bottom)continue}if(Nt(b,R,s,[d,m],1))continue;if(te(b,R,t,a,{epsilon:Ae}))continue;a.points=[b,R];break}}}e(Es,"straightenCollinearSiblingDetours");function Je(t,n){let{realNodeRects:d,labelNodeRects:m}=bn(n.values()),p=e((b,R)=>Bn(R,0.001).map((O)=>({...O,edge:b,interior:O.index>=1&&O.index<=R.length-3})),"segmentsFor"),I=e(()=>{let b=[];for(let R of t){if(R.isLayoutOnly)continue;let O=R.points;if(!O||O.length<2)continue;b.push(...p(R,yt(O)))}return b},"allSegments"),y=e((b,R)=>{if(b.horizontal&&R.horizontal)return Ut(b.a.x,b.b.x,R.a.x,R.b.x)>=8&&Math.abs(b.a.y-R.a.y)<7;if(b.vertical&&R.vertical)return Ut(b.a.y,b.b.y,R.a.y,R.b.y)>=8&&Math.abs(b.a.x-R.a.x)<7;return!1},"hasCrowdedParallelTrack"),g=e((b,R)=>{let{start:O,end:P}=b,N=p(b,R);if(N.length!==R.length-1)return!1;let H=[O,P].filter((F)=>Boolean(F)),_=b.labelNodeId?[b.labelNodeId]:[];for(let F of N){if(Nt(F.a,F.b,d,H,-2))return!1;if(Nt(F.a,F.b,m,_,-2))return!1}for(let F of t){if(F===b||F.isLayoutOnly)continue;let Y=F.points;if(!Y||Y.length<2)continue;for(let V of N)for(let J of p(F,yt(Y))){if(y(V,J))return!1;if(un(V.a,V.b,J.a,J.b,0.001))return!1}}return!0},"candidateIsSafe"),l=e((b,R)=>{let O=yt(b.edge.points??[]);if(O.length<4||b.index>=O.length-1)return;let P=O.map((N)=>({...N}));if(b.horizontal)P[b.index].y+=R,P[b.index+1].y+=R;else if(b.vertical)P[b.index].x+=R,P[b.index+1].x+=R;else return;return p(b.edge,P).length===P.length-1?P:void 0},"shiftedCandidate"),x=e((b,R)=>({x:b.x??(R.left+R.right)/2,y:b.y??(R.top+R.bottom)/2}),"nodeCenter"),L=e((b)=>{let R=b.edge,O=yt(R.points??[]);if(O.length!==4||b.index!==1)return;let P=R.start?n.get(R.start):void 0,N=R.end?n.get(R.end):void 0,H=P?Zt(P):void 0,_=N?Zt(N):void 0,F=O.slice(b.index+2);if(!P||!N||!H||!_||F.length===0)return;return{sourceCenter:x(P,H),targetCenter:x(N,_),sourceRect:H,tail:F}},"sourceDetourContextFor"),S=e((b,R,O,P,N,H)=>{let _=P.y>=O.y,F=_?N.bottom:N.top,Y=F+(_?20:-20);if(_&&b.b.y<=Y+0.001||!_&&b.b.y>=Y-0.001)return;let V=b.a.x+R;return yt([{x:O.x,y:F},{x:O.x,y:Y},{x:V,y:Y},{x:V,y:b.b.y},...H],0.001)},"verticalSourceDetour"),E=e((b,R,O,P,N,H)=>{let _=P.x>=O.x,F=_?N.right:N.left,Y=F+(_?20:-20);if(_&&b.b.x<=Y+0.001||!_&&b.b.x>=Y-0.001)return;let V=b.a.y+R;return yt([{x:F,y:O.y},{x:Y,y:O.y},{x:Y,y:V},{x:b.b.x,y:V},...H],0.001)},"horizontalSourceDetour"),w=e((b,R)=>{let O=L(b);if(!O)return;if(b.vertical)return S(b,R,O.sourceCenter,O.targetCenter,O.sourceRect,O.tail);if(b.horizontal)return E(b,R,O.sourceCenter,O.targetCenter,O.sourceRect,O.tail);return},"sourceDetourCandidate"),C=[-7,7,-14,14,-21,21];for(let b=0;b<12;b++){let R=I(),O=!1;for(let P=0;P<R.length&&!O;P++)for(let N=P+1;N<R.length&&!O;N++){let H=R[P],_=R[N];if(H.edge===_.edge||!y(H,_))continue;let F=[H,_].filter((Y)=>Y.interior);for(let Y of F){for(let V of C){let J=l(Y,V);if(J&&g(Y.edge,J)){Y.edge.points=J,O=!0;break}let lt=w(Y,V);if(lt&&g(Y.edge,lt)){Y.edge.points=lt,O=!0;break}}if(O)break}}if(!O)return}}e(Je,"nudgeSharedInteriorSubpaths");function As(t,n,o,s){let i=n.x-t.x,c=n.y-t.y,a=s.x-o.x,u=s.y-o.y,h=i*u-c*a;if(Math.abs(h)<0.0000000001)return!1;let d=o.x-t.x,m=o.y-t.y,p=(d*u-m*a)/h,I=(d*c-m*i)/h,y=0.01;return p>y&&p<1-y&&I>y&&I<1-y}e(As,"segmentsIntersect");function Rs(t){let n=t.nodes??[],o=t.edges??[],s=[];if(!o.length||!n.length)return s;let i=ts(n),c=1,a=[];for(let h of o){if(h.isLayoutOnly)continue;let d=h.points;if(!d||d.length<2)continue;let{start:m,end:p,labelNodeId:I}=h,y=h.id??`${m}->${p}`;for(let g of i){if(g.nodeId===m||g.nodeId===p)continue;if(I&&g.nodeId===I)continue;for(let l=0;l<d.length-1;l++)if(ae(d[l],d[l+1],g,-c)){s.push({type:"edge-node-overlap",edgeId:y,targetId:g.nodeId,detail:`segment ${l} passes through node "${g.nodeId}"`});break}}for(let g=0;g<d.length-1;g++)a.push({edgeId:y,start:m,end:p,p1:d[g],p2:d[g+1]})}let u=new Set;for(let h=0;h<a.length;h++)for(let d=h+1;d<a.length;d++){let m=a[h],p=a[d];if(m.edgeId===p.edgeId)continue;if(m.start===p.start||m.start===p.end||m.end===p.start||m.end===p.end)continue;if(As(m.p1,m.p2,p.p1,p.p2)){let I=m.edgeId<p.edgeId?`${m.edgeId}|${p.edgeId}`:`${p.edgeId}|${m.edgeId}`;if(!u.has(I))u.add(I),s.push({type:"edge-edge-crossing",edgeId:m.edgeId,targetId:p.edgeId,detail:`edges "${m.edgeId}" and "${p.edgeId}" cross`})}}if(s.length>0){let h=s.filter((m)=>m.type==="edge-node-overlap").length,d=s.filter((m)=>m.type==="edge-edge-crossing").length;r.warn(`[SWIMLANE_VALIDATE] ${s.length} issue(s) detected: ${h} edge-node overlap(s), ${d} edge crossing(s)`);for(let m of s)r.warn(`[SWIMLANE_VALIDATE] ${m.type}: ${m.detail}`)}return s}e(Rs,"validateSwimlanesLayout");function Ts(t,n){let o=t.nodes??[],s=t.edges??[],i=o.filter((u)=>!u.isGroup);if((n==="LR"||n==="RL")&&i.length>0&&!ps(t,n))return;if(n==="BT"&&i.length>0&&!gs(t))return;for(let u of s){if(u.isLayoutOnly)continue;let h=u.points;if(!h||h.length<2)continue;u.points=dn(ne(h))}vs(s,o),Es(s,o),ms(s,o);let c=new Map;for(let u of o)c.set(String(u.id),u);Jn(s,c),rs(s,c),ys(s,c),Je(s,c),ze(s,c),bs(s,c),Ve(s,c),Ms(s,c);let a=e(()=>{Cs(s,c),ze(s,c),Is(s,c),Ss(s,c),Jn(s,c),Ge(s,c),Ve(s,c),Jn(s,c),Ge(s,c)},"finalizeRenderedEdges");a(),Je(s,c),a(),Ue(s,c,n),je(s,c,n),Ue(s,c,n),je(s,c,n)}e(Ts,"postProcessSwimlaneLayout");function Mn(t){let n=new Map(t.nodeById),o=new Set,s=[];for(let c of t.edges){if(!n.has(c.src)||!n.has(c.dst))continue;let a=`${c.id}:${c.src}->${c.dst}`;if(o.has(a))continue;o.add(a),s.push(c)}return{nodes:[...n.keys()],edges:s,layout:t.layout,nodeById:n}}e(Mn,"normalizeGraph");function Io(t,n){return t.edges.filter((o)=>o.dst===n)}e(Io,"incoming");function ws(t){let n=new Map;for(let o of t.nodes)n.set(o,[]);for(let o of t.edges)n.get(o.src).push(o.dst);return n}e(ws,"buildSuccessorMap");function So(t){let n=ws(t);for(let o of n.values())o.sort((s,i)=>s.localeCompare(i));return n}e(So,"buildSortedSuccessorMap");function fe(t){let n=new Map;for(let o of t.nodes)n.set(o,0);for(let o of t.edges)n.set(o.dst,(n.get(o.dst)??0)+1);return n}e(fe,"buildInDegreeMap");function Co(t,n){let o=[...n.entries()].filter(([,u])=>u===0).map(([u])=>u).sort((u,h)=>u.localeCompare(h)),s=new Set(t.edges.flatMap((u)=>[u.src,u.dst])),i=e((u)=>!s.has(u)&&!t.nodeById.get(u)?.isGroup,"isUnconnected"),c=[...n.keys()].filter((u)=>n.get(u)===0&&i(u)),a=0;return o.map((u)=>i(u)?c[a++]:u)}e(Co,"sortedZeroInDegreeNodes");function de(t,n=()=>!0){let o=new Map,s=new Map;for(let i of t.nodes)o.set(i,[]),s.set(i,[]);for(let i of t.edges){if(!n(i))continue;s.get(i.src).push(i.dst),o.get(i.dst).push(i.src)}return{preds:o,succs:s}}e(de,"buildPredecessorSuccessorMaps");function vo(t,n,o,s){let i=0;for(let a of t.nodes){if(s?.skipGroups&&t.nodeById.get(a)?.isGroup)continue;i=Math.max(i,o[a]??0)}let c=Array.from({length:i+1},()=>[]);for(let a of n){if(s?.skipGroups&&t.nodeById.get(a)?.isGroup)continue;c[Math.max(0,o[a]??0)].push(a)}return c}e(vo,"buildLayersFromRanks");function _n(t){let n=fe(t),o=Co(t,n),s=[],i=So(t);while(o.length){let c=o.shift();s.push(c);for(let a of i.get(c)??[])if(n.set(a,(n.get(a)??0)-1),(n.get(a)??0)===0){let u=0;while(u<o.length&&o[u]<a)u++;o.splice(u,0,a)}}return s.length===t.nodes.length?s:null}e(_n,"topoSortIfAcyclic");function Fn(t){let n=new Map,o=0;for(let s of t)n.set(s,o),o++;return n}e(Fn,"buildLayerIndex");function Lo(t){let n=Array(t.length),o=e((s,i)=>{if(i-s<=1)return 0;let c=s+i>>1,a=o(s,c)+o(c,i),u=s,h=c,d=s;while(u<c||h<i)if(h>=i||u<c&&t[u]<=t[h])n[d++]=t[u++];else n[d++]=t[h++],a+=c-u;for(let m=s;m<i;m++)t[m]=n[m];return a},"count");return o(0,t.length)}e(Lo,"countInversions");function Ns(t){let n=Mn(t),o=new Map;for(let p of n.nodes)o.set(p,[]);for(let p of n.edges)o.get(p.src).push(p);for(let p of o.values())p.sort((I,y)=>I.dst===y.dst?I.id.localeCompare(y.id):I.dst.localeCompare(y.dst));let s=Object.create(null);for(let p of n.nodes)s[p]=0;let i=[],c=e((p)=>{s[p]=1;for(let I of o.get(p)??[]){let y=I.dst;if(s[y]===0)c(y);else if(s[y]===1)i.push(I)}s[p]=2},"dfs"),a=fe(n),u=[...n.nodes.filter((p)=>(a.get(p)??0)===0),...n.nodes.filter((p)=>(a.get(p)??0)!==0)];for(let p of u)if(s[p]===0)c(p);let h=new Set(i.map((p)=>`${p.id}:${p.src}->${p.dst}`)),d=n.edges.map((p)=>h.has(`${p.id}:${p.src}->${p.dst}`)?{id:p.id,src:p.dst,dst:p.src,weight:p.weight,ref:p.ref}:p);return{acyclic:{nodes:[...n.nodes],edges:d,layout:n.layout,nodeById:new Map(n.nodeById)},reversed:i}}e(Ns,"removeCycles_DFS");function Os(t){let n=new Map,o=e((s)=>{if(n.has(s))return n.get(s);let i=t.nodeById.get(s);if(!i)return n.set(s,null),null;let c=i.parentId;if(!c)return n.set(s,null),null;let u=o(c)??c;return n.set(s,u),u},"resolve");for(let s of t.nodes)o(s);return n}e(Os,"buildTopLaneMap");function hn(t){let n=Os(t);return(o)=>n.get(o)??null}e(hn,"createTopLaneResolver");function ue(t){let n=[];for(let o of t.layout.nodes??[])if(o.isGroup&&!o.parentId)n.push(o.id);return[...new Set(n)].reverse()}e(ue,"buildTopLaneOrder");function Eo(t,n){let o=ue(t);if(!n||n.length===0)return o;let s=new Set(o),i=new Set,c=[];for(let a of n){if(!s.has(a)||i.has(a))continue;i.add(a),c.push(a)}for(let a of o){if(i.has(a))continue;c.push(a)}return c}e(Eo,"resolveTopLaneOrder");var Hr={EPSILON:0.000001},ie={GRAVITY_ITERATIONS:8,MAX_CROSSING_OPTIMIZATION_PASSES:4,DEFAULT_COMPACT_SINGLE_INPUT:!0},Uo={DEFAULT_LAYER_GAP:100,DEFAULT_NODE_GAP:40};function Bs(t,n){let o=Mn(t),s=n?.laneOf??(()=>null),i=n?.rankHint,{preds:c}=de(o);for(let C of c.values())C.sort((b,R)=>b.localeCompare(R));let a=_n(o)??[...o.nodes].sort((C,b)=>C.localeCompare(b)),u=new Map;for(let[C,b]of a.entries())u.set(b,C);let h=new Map,d=new Map;for(let C of o.nodes)d.set(C,[]);for(let C of a){let b=(c.get(C)??[]).filter((R)=>h.has(R));if(b.length>0){let R=Fs(C,b,{laneOf:s,rankHint:i,topoIndex:u});h.set(C,R),d.get(R).push(C)}else if(!h.has(C))h.set(C,null)}for(let C of o.nodes)if(!h.has(C))h.set(C,null);let m=new Set;for(let C of o.nodes)if((h.get(C)??null)===null)m.add(C);let p=[...m].sort((C,b)=>{let R=u.get(C)??0,O=u.get(b)??0;if(R===O)return C.localeCompare(b);return R-O}),I=Ps(o),y=new Map;for(let[C,b]of I.entries())y.set(C,[...b].sort((R,O)=>R.localeCompare(O)));let g=ks(y),l=_s(y),x=new Map;for(let C of o.nodes)x.set(C,[]);for(let C of l)for(let b of C.nodes){let R=x.get(b);if(R)R.push(C.id);else x.set(b,[C.id])}let L=[],S=[],E=new Set,w=e((C)=>{if(E.has(C))return;E.add(C),L.push(C);for(let b of d.get(C)??[])w(b);S.push(C)},"walk");for(let C of p)w(C);for(let C of a)w(C);return{parent:h,children:d,roots:p,componentOf:g,blocks:l,nodeBlocks:x,adjacency:y,preorder:L,postorder:S,topologicalOrder:a}}e(Bs,"buildDrivingTree");function Fs(t,n,o){let s=o.laneOf(t);return[...n].sort((c,a)=>{let u=o.laneOf(c),h=o.laneOf(a),d=u!=null&&u===s,m=h!=null&&h===s;if(d!==m)return d?-1:1;let p=o.rankHint?.[c],I=o.rankHint?.[a];if(p!=null&&I!=null&&p!==I)return I-p;let y=o.topoIndex.get(c)??0,g=o.topoIndex.get(a)??0;if(y!==g)return y-g;return c.localeCompare(a)})[0]}e(Fs,"chooseParent");function Ps(t){let n=new Map;for(let o of t.nodes)n.set(o,new Set);for(let o of t.edges)n.get(o.src).add(o.dst),n.get(o.dst).add(o.src);return n}e(Ps,"buildAdjacency");function ks(t){let n=new Map,o=0;for(let s of t.keys()){if(n.has(s))continue;let i=[s];while(i.length>0){let c=i.pop();if(n.has(c))continue;n.set(c,o);for(let a of t.get(c)??[])if(!n.has(a))i.push(a)}o++}return n}e(ks,"assignComponents");function _s(t){let n=new Map,o=new Map,s=[],i=[],c=0,a=e((u,h)=>{n.set(u,++c),o.set(u,c);for(let d of t.get(u)??[]){if(d===h)continue;if(!n.has(d)){if(s.push([u,d]),a(d,u),o.set(u,Math.min(o.get(u)??c,o.get(d)??c)),(o.get(d)??0)>=(n.get(u)??0))i.push(Hs(u,d,s,i.length))}else if((n.get(d)??0)<(n.get(u)??0))s.push([u,d]),o.set(u,Math.min(o.get(u)??c,n.get(d)??c))}},"visit");for(let u of t.keys())if(!n.has(u))a(u,null);return i}e(_s,"computeBlocks");function Hs(t,n,o,s){let i=[],c=new Set;while(o.length>0){let a=o.pop();if(i.push(a),c.add(a[0]),c.add(a[1]),a[0]===t&&a[1]===n||a[0]===n&&a[1]===t)break}return{id:s,edges:i,nodes:[...c]}}e(Hs,"popBlock");function Ds(t,n,o){let s=[...t.nodes],i=new Map;for(let[S,E]of s.entries())i.set(E,S);let c=s.length,a=Array(c).fill(-1),u=Array(c).fill(0),h=[],d=new Set;for(let S of s){let E=o.parent.get(S)??null,w=i.get(S);if(w==null)continue;if(E==null){if(a[w]=-1,u[w]=0,!d.has(S))d.add(S),h.push(S)}}while(h.length>0){let S=h.shift(),E=i.get(S);if(E==null)continue;let w=o.children.get(S)??[];for(let C of w){if(d.has(C))continue;let b=i.get(C);if(b==null)continue;a[b]=E,u[b]=u[E]+1,d.add(C),h.push(C)}}for(let S of s){if(d.has(S))continue;let E=i.get(S);if(E==null)continue;a[E]=-1,u[E]=0,d.add(S)}let m=Math.max(1,Math.ceil(Math.log2(Math.max(1,c)))+1),p=Array.from({length:m},()=>Array(c).fill(-1));for(let S=0;S<c;S++)p[0][S]=a[S];for(let S=1;S<m;S++)for(let E=0;E<c;E++){let w=p[S-1][E];p[S][E]=w===-1?-1:p[S-1][w]}let I=e((S,E)=>{if(S===-1||E===-1)return-1;if(u[S]<u[E])[S,E]=[E,S];let w=u[S]-u[E];for(let C=0;C<m;C++)if(w>>C&1){if(S=p[C][S],S===-1)return-1}if(S===E)return S;for(let C=m-1;C>=0;C--){let b=p[C][S],R=p[C][E];if(b===-1||R===-1)continue;if(b!==R)S=b,E=R}return p[0][S]},"lcaIndex"),y=Array.from({length:c},()=>new Map);for(let S of t.edges){let{src:E,dst:w}=S,C=n[E],b=n[w];if(C==null||b==null)continue;if(C>b)[E,w]=[w,E],[C,b]=[b,C];if(C==null||b==null||C===b)continue;let R=i.get(E),O=i.get(w);if(R==null||O==null)continue;let P=I(R,O);if(P===-1)continue;let N=y[P];for(let H=C;H<b;H++)N.set(H,(N.get(H)??0)+1)}let g=new Map,l=e((S,E)=>{if(E.size===0)return;for(let[w,C]of E)S.set(w,(S.get(w)??0)+C)},"mergeInto"),x=new Set,L=e((S)=>{let E=i.get(S);x.add(S);let w=E==null?void 0:y[E],C=w?new Map(w):new Map,b=o.children.get(S)??[];for(let R of b){let O=L(R),P=n[S];if(P!=null){let N=g.get(S);if(!N)N=new Map,g.set(S,N);let H=O.get(P)??0,_=n[R];if(_!=null&&_>P)H+=1;N.set(R,H)}l(C,O)}return C},"dfs");for(let S of o.roots)if(!x.has(S))L(S);for(let S of s)if(!x.has(S))L(S);return g}e(Ds,"computeSubtreeCrossCounts");function Xs(t,n,o){let s=new Map,i=e((c)=>{let a=o[c]??0,u=[...n.get(c)??[]];u.sort(Ao(o));for(let h of u){i(h);let d=s.get(h);if(d!=null)a=Math.min(a,d)}s.set(c,a)},"annotate");for(let c of t)i(c);return s}e(Xs,"annotateMinimumLayers");function Ao(t){return(n,o)=>{let s=t[n]??0,i=t[o]??0;return s===i?n.localeCompare(o):s-i}}e(Ao,"compareByRankThenId");function Ys(t,n,o,s){let i=0;for(let h of n){let d=o[h]??0;if(d>i)i=d}let c=Array.from({length:i+1},()=>[]),a=new Set,u=e((h)=>{if(a.has(h))return;a.add(h);let d=o[h]??0;if(!c[d])c[d]=[];c[d].push(h);for(let m of s(h))u(m)},"emit");for(let h of t)u(h);for(let h of n)if(!a.has(h)){let d=o[h]??0;if(!c[d])c[d]=[];c[d].push(h),a.add(h)}return c}e(Ys,"emitNodesInTreeOrder");function Gs(t){let n=[];for(let o of t){let s=new Set,i=[];for(let c of o){if(s.has(c))continue;s.add(c),i.push(c)}n.push(i)}return n}e(Gs,"deduplicateLayers");function $s(t,n,o,s){return(i)=>{let c=t.get(i)??[];if(c.length===0)return[];let a=n[i]??0,u=[],h=[],d=o.get(i);for(let m of c){let p=s.get(m)??a;if(p>a)u.push({child:m,min:p});else h.push(m)}return u.sort((m,p)=>{if(m.min===p.min)return m.child.localeCompare(p.child);return m.min-p.min}),h.sort((m,p)=>{let I=d?.get(m)??0,y=d?.get(p)??0;if(I!==y)return I-y;let g=s.get(m)??a,l=s.get(p)??a;if(g!==l)return g-l;return m.localeCompare(p)}),[...u.map((m)=>m.child),...h]}}e($s,"createChildOrderer");function ce(t,n,o){let s=Bs(t,{rankHint:n,laneOf:o}),{children:i,roots:c}=s;for(let p of t.nodes)if(!i.has(p))i.set(p,[]);let a=Ds(t,n,s),u=[...c].sort(Ao(n)),h=Xs(u,i,n),d=$s(i,n,a,h),m=Ys(u,t.nodes,n,d);return m=Gs(m),m}e(ce,"buildMultitreeLayerOrder");function zs(t,n,o){let s=new Set(t),i=new Set(n),c=Fn(n),a=[];for(let u of o)if(s.has(u.src)&&i.has(u.dst))a.push(c.get(u.dst));return Lo(a)}e(zs,"countCrossingsBetweenAdjacent");function Ze(t,n,o){let s=[];for(let c of n){let a=o[c.src],u=o[c.dst];if(a==null||u==null||a===u)continue;let{src:h,dst:d}=c,m=a,p=u;if(a>u)h=c.dst,d=c.src,m=u,p=a;for(let I=m;I<p;I++)s.push({id:`${c.id}@${I}`,src:h,dst:d,ref:c.ref})}let i=0;for(let c=0;c+1<t.length;c++)i+=zs(t[c],t[c+1],s);return i}e(Ze,"totalCrossings");function Vs(t,n){let o={...n},{preds:s}=de(t),i=hn(t),c=ce(t,o,i),a=Ze(c,t.edges,o),u=ie.MAX_CROSSING_OPTIMIZATION_PASSES;for(let h=0;h<u;h++){let d=!1,m=[...t.nodes].sort((p,I)=>(o[I]??0)-(o[p]??0));for(let p of m){let I=o[p]??0;if(I===0)continue;let y=0;for(let L of s.get(p)??[])y=Math.max(y,(o[L]??0)+1);if(y>=I)continue;let g=I;o[p]=y;let l=ce(t,o,i),x=Ze(l,t.edges,o);if(x<a)a=x,d=!0;else o[p]=g}if(!d)break}return o}e(Vs,"optimizeRanksByCrossings");function Us(t,n){let o=hn(t),s=[...t.nodes].sort((i,c)=>(n[i]??0)-(n[c]??0)||i.localeCompare(c));for(let i of s){let c=o(i);if(!c)continue;let a=t.edges.filter((l)=>l.src===i);if(a.length===0)continue;let u=!1,h=0;for(let l of a){let x=o(l.dst);if(x==null||x===c)u=!0;else h++}if(h===0||u)continue;let d=0,m=!1;for(let l of t.edges){if(l.dst!==i)continue;let x=o(l.src);if(!x)continue;if(x===c)m=!0;else d++}if(d>0||!m)continue;let p=n[i]??0,I=p+h,y=0;for(let l of t.edges)if(l.dst===i)y=Math.max(y,(n[l.src]??0)+1);let g=Math.max(p,y,I);if(g!==p)n[i]=g}}e(Us,"adjustCrossLaneSources");function js(t,n){let o=Mn(t),s=_n(o)??[...o.nodes].sort(),i=n?.compactSingleInput??!1,c=hn(o),a=Object.create(null);for(let h of s){let d=Io(o,h),m=n?.ignoreCrossLaneEdges?d.filter((p)=>{let I=c(p.src),y=c(h);if(!I||!y)return!0;return I===y}):d;if(m.length===0)a[h]=0;else if(i&&m.length===1){let p=m[0].src,I=c(p),y=c(h);if(I!==y)a[h]=a[p]??0;else a[h]=(a[p]??0)+1}else{let p=-1/0;for(let I of m)p=Math.max(p,(a[I.src]??0)+1);a[h]=p===-1/0?0:p}}if(n?.optimizeRanksByCrossings??!1)a=Vs(o,a);if(n?.ignoreCrossLaneEdges)Us(o,a);return{layers:ce(o,a,c),rankOf:a,dummy:new Set}}e(js,"assignLayers_LongestPath");function Ws(t,n){let o=Mn(t),i={...js(o,{compactSingleInput:n?.compactSingleInput,ignoreCrossLaneEdges:n?.ignoreCrossLaneEdges,optimizeRanksByCrossings:n?.optimizeRanksByCrossings}).rankOf},c=hn(o),{preds:a,succs:u}=de(o,(g)=>{if(n?.ignoreCrossLaneEdges){let l=c(g.src),x=c(g.dst);if(l&&x&&l!==x)return!1}return!0}),h=_n(o)??[...o.nodes],d=[...h].reverse(),m=e((g,l)=>{let x=0;for(let E of a.get(g)??[])x=Math.max(x,(i[E]??0)+1);let L=Number.POSITIVE_INFINITY,S=u.get(g)??[];if(S.length>0)L=Math.min(...S.map((E)=>(i[E]??0)-1));if(!Number.isFinite(L))L=Math.max(x,l);return Math.min(Math.max(l,x),L)},"clampFeasible"),p=ie.GRAVITY_ITERATIONS,I=e((g)=>{let l=!1;for(let x of g){let L=a.get(x)??[],S=u.get(x)??[];if(L.length===0&&S.length===0)continue;let E=L.length>0?L.reduce((R,O)=>R+(i[O]??0)+1,0)/L.length:i[x]??0,w=S.length>0?S.reduce((R,O)=>R+(i[O]??0)-1,0)/S.length:i[x]??0,C=Math.round((E+w)/2),b=m(x,C);if(b!==i[x])i[x]=b,l=!0}return l},"relaxOrder");for(let g=0;g<p;g++){let l=I(h),x=I(d);if(!l&&!x)break}for(let g of h){let l=0;for(let x of a.get(g)??[])l=Math.max(l,(i[x]??0)+1);if((i[g]??0)<l)i[g]=l}for(let g of d){let l=u.get(g)??[];if(l.length>0){let x=Math.min(...l.map((L)=>(i[L]??0)-1));if((i[g]??0)>x)i[g]=x}}return{layers:vo(o,h,i),rankOf:i,dummy:new Set}}e(Ws,"assignLayers_Gravity");function Ks(t){let n=fe(t),o=So(t),s=Co(t,n),i=[];while(s.length>0){let c=[];for(let a of s){i.push(a);for(let u of o.get(a)??[])if(n.set(u,(n.get(u)??0)-1),(n.get(u)??0)===0)c.push(u)}s=c.sort((a,u)=>a.localeCompare(u))}return i.length===t.nodes.length?i:null}e(Ks,"topoSortByGenerationIfAcyclic");function qs(t,n){let o=Mn(t),s=n?.direction==="LR"?Ks(o)??[...o.nodes].sort():_n(o)??[...o.nodes].sort(),i=hn(o),c=e((m)=>i(m)??m,"laneOf"),a=Object.create(null),u=new Map,h=e((m,p)=>{if(n?.ignoreCrossLaneEdges??!0)return c(m)===c(p)?1:0;return 1},"edgeWeight");for(let m of s){if(o.nodeById.get(m)?.isGroup)continue;let I=Io(o,m),y=0;if(I.length>0)for(let L of I){let S=L.src,E=a[S]??0;y=Math.max(y,E+h(S,m))}let g=c(m),l=u.get(g)??0,x=Math.max(y,l);a[m]=x,u.set(g,x+1)}return{layers:vo(o,s,a,{skipGroups:!0}),rankOf:a,dummy:new Set}}e(qs,"assignLayers_LaneAwareCompact");function Js(t,n){let o=Mn(n),{rankOf:s}=t,i=t.layers.map((y)=>[...y]),c=new Set(t.dummy?[...t.dummy]:[]),a=0,u=new Map(o.nodeById),h=e((y)=>{let g=`placeholder-${a++}`,l={id:g,isGroup:!1,isDummy:!0,width:0,height:0};u.set(g,l),c.add(g);while(i.length<=y)i.push([]);return i[y].push(g),s[g]=y,g},"addDummyAt"),d=[...o.edges].sort((y,g)=>y.id===g.id?y.src===g.src?y.dst.localeCompare(g.dst):y.src.localeCompare(g.src):y.id.localeCompare(g.id)),m=[];for(let y of d){let g=s[y.src]??0,l=s[y.dst]??0;if(l-g<=1){m.push(y);continue}let x=y.src;for(let S=g+1,E=0;S<l;S++,E++){let w=h(S);m.push({id:`${y.id}#${E}`,src:x,dst:w,weight:y.weight,ref:y.ref}),x=w}let L=l-g-2;m.push({id:`${y.id}#${Math.max(L+1,0)}`,src:x,dst:y.dst,weight:y.weight,ref:y.ref})}let I={nodes:[...o.nodes,...[...c].filter((y)=>!o.nodes.includes(y))],edges:m,layout:o.layout,nodeById:u};return{layering:{layers:i,rankOf:s,dummy:c},graphWithDummies:I}}e(Js,"makeProperLayering");function Qe(t){let n=t.length;if(n===0)return Number.POSITIVE_INFINITY;let o=[...t].sort((s,i)=>s-i);if(n%2===1)return o[(n-1)/2];return 0.5*(o[n/2-1]+o[n/2])}e(Qe,"median");function to(t){if(t.length===0)return Number.POSITIVE_INFINITY;return t.reduce((o,s)=>o+s,0)/t.length}e(to,"barycenter");function Zs(t,n,o,s){let i=new Map;for(let c of t)i.set(c,[]);for(let c of o)if(s==="down"){if(n.has(c.src)&&i.has(c.dst))i.get(c.dst).push(n.get(c.src))}else if(n.has(c.dst)&&i.has(c.src))i.get(c.src).push(n.get(c.dst));return i}e(Zs,"neighborPositionsFor");function Qs(t,n,o){let s=o.get(t)??0,i=o.get(n)??0;return s!==i?s-i:t.localeCompare(n)}e(Qs,"currentOrderTieBreak");function no(t,n,o){let s=new Set(t),i=new Set(n),c=Fn(t),a=Fn(n),u=[];for(let d of o)if(s.has(d.src)&&i.has(d.dst))u.push({u:c.get(d.src),v:a.get(d.dst)});u.sort((d,m)=>d.u===m.u?d.v-m.v:d.u-m.u);let h=u.map((d)=>d.v);return Lo(h)}e(no,"countCrossingsBetweenAdjacent");function Zn(t,n,o){return[...t].sort((s,i)=>{let c=Qe(n.get(s)??[]),a=Qe(n.get(i)??[]);if(c===a)return Qs(s,i,o);if(!isFinite(c))return 1;if(!isFinite(a))return-1;return c-a})}e(Zn,"sortByHeuristic");function eo(t,n,o,s,i,c){let a=Fn(t),u=Fn(n),h=Zs(n,a,o,s);if(!i||!c||c.length===0)return Zn(n,h,u);let d=new Map;for(let I of n){let y=i(I),g=d.get(y)??[];g.push(I),d.set(y,g)}let m=[];for(let I of c){let y=d.get(I);if(!y||y.length===0)continue;let g=Zn(y,h,u);m.push(...g)}let p=d.get(null);if(p&&p.length>0){let I=Zn(p,h,u);for(let y of I){let g=to(h.get(y)??[]),l=m.length;if(isFinite(g))for(let[x,L]of m.entries()){let S=to(h.get(L)??[]);if(g<S){l=x;break}}m.splice(l,0,y)}}return m}e(eo,"reorderLayer");function oo(t,n,o,s,i){let c=[...n],a=new Set(t),u=new Set(n),h=s?new Set(s):null,d=o.filter((l)=>a.has(l.src)&&u.has(l.dst)),m=h?o.filter((l)=>u.has(l.src)&&h.has(l.dst)):void 0,p=e((l)=>{let x=no(t,l,d);if(m&&s)x+=no(l,s,m);return x},"crossingScore"),I=i?new Map:null;if(i&&I)for(let l of n)I.set(l,i(l));let y=!0,g=p(c);while(y){y=!1;for(let l=0;l+1<c.length;l++){if(I){let S=I.get(c[l]),E=I.get(c[l+1]);if(S!==E)continue}let x=g;[c[l],c[l+1]]=[c[l+1],c[l]];let L=p(c);if(L<x)g=L,y=!0;else[c[l],c[l+1]]=[c[l+1],c[l]]}}return c}e(oo,"transposeImprove");function tr(t,n,o){let s=t.layers.map((u)=>[...u]),i=n.edges,c=hn(n),a=Eo(n,o?.laneOrder);for(let u=0;u<3;u++){for(let h=1;h<s.length;h++)s[h]=eo(s[h-1],s[h],i,"down",c,a),s[h]=oo(s[h-1],s[h],i,s[h+1],c);for(let h=s.length-2;h>=0;h--)s[h]=eo(s[h+1],s[h],i,"up",c,a),s[h]=oo(s[h+1],s[h],i,s[h-1],c)}return{layers:s}}e(tr,"orderLayers");function nr(t,n,o){let s=o?.layerGap??Uo.DEFAULT_LAYER_GAP,i=o?.nodeGap??Uo.DEFAULT_NODE_GAP,c=o?.laneGap??i*2,a=o?.direction??"TB",u=a==="LR"||a==="RL",h=t.layers,d=Object.create(null),m=Object.create(null),p=e((N)=>n.nodeById.get(N),"getNode"),I=e((N)=>p(N)?.width??0,"getWidth"),y=e((N)=>p(N)?.height??0,"getHeight"),g=hn(n),l=Eo(n,o?.laneOrder),x=h.map((N)=>N.reduce((H,_)=>Math.max(H,y(_)),0)),L=[];if(u)for(let N=0;N+1<h.length;N++){let H=h[N].reduce((xt,Ot)=>Math.max(xt,I(Ot)),0),_=h[N+1].reduce((xt,Ot)=>Math.max(xt,I(Ot)),0),F=x[N],Y=x[N+1],V=F/2+Y/2,J=(H+_)/2,lt=Math.max(0,J-V-s);L.push(lt)}let S=new Set;for(let N of h)for(let H of N)S.add(g(H));let E=S.has(null),w=l.filter((N)=>S.has(N)),C=[...E?[null]:[],...w],b=Object.create(null);for(let N of w)b[N]=0;if(E)b.null=0;for(let N of h){let H=Object.create(null),_=[];for(let F of N){let Y=g(F);if(Y===null)_.push(F);else(H[Y]||=[]).push(F)}for(let[F,Y]of Object.entries(H)){let V=Y.reduce((J,lt)=>J+I(lt),0)+i*Math.max(0,Y.length-1);b[F]=Math.max(b[F]??0,V)}if(E&&_.length){let F=_.reduce((Y,V)=>Y+I(V),0)+i*Math.max(0,_.length-1);b.null=Math.max(b.null??0,F)}}let R=new Map;{let N=C.map((F)=>(F===null?b.null:b[F])??0),_=-(N.reduce((F,Y)=>F+Y,0)+c*Math.max(0,C.length-1))/2;for(let F=0;F<C.length;F++){let Y=C[F],V=N[F]??0,J=_+V/2;if(R.set(Y,J),_+=V,F<C.length-1)_+=c}}let O=0;for(let[N,H]of h.entries()){let _=x[N]??0,F=new Map;for(let V of H){let J=g(V),lt=F.get(J)??[];lt.push(V),F.set(J,lt)}for(let V of C){let J=F.get(V)??[];if(J.length===0)continue;let lt=R.get(V);if(J.length===1){let xt=J[0];d[xt]=lt,m[xt]=O+_/2}else{let xt=J.map((nt)=>I(nt)),Ot=xt.reduce((nt,q)=>nt+q,0)+i*(J.length-1),kt=lt-Ot/2;for(let[nt,q]of J.entries()){let ot=xt[nt];d[q]=kt+ot/2,m[q]=O+_/2,kt+=ot+i}}}let Y=L[N]??0;O+=_+s+Y}let P=new Map;for(let N of n.edges){let H=N.ref.id;if(!P.has(H))P.set(H,[]);P.get(H).push(N)}for(let[,N]of P){if(N.length===0)continue;let H=N[0].ref,{start:_,end:F}=H;if(_==null||F==null)continue;let Y=Math.round(((d[_]??0)+(d[F]??0))/2),V=new Set;for(let J of N)V.add(J.src),V.add(J.dst);for(let J of V){if(J===_||J===F)continue;if(n.nodeById.get(J)?.isDummy)d[J]=Y}}return{x:d,y:m}}e(nr,"assignCoordinates");var er=8;function or(t){let n=2166136261;for(let o=0;o<t.length;o++)n^=t.charCodeAt(o),n=Math.imul(n,16777619);return n>>>0}e(or,"hashString");function sr(t){let n=t>>>0;return()=>{n+=1831565813;let o=n;return o=Math.imul(o^o>>>15,o|1),o^=o+Math.imul(o^o>>>7,o|61),((o^o>>>14)>>>0)/4294967296}}e(sr,"mulberry32");function rr(t,n){let o=[...t],s=sr(n);for(let i=o.length-1;i>0;i--){let c=Math.floor(s()*(i+1));[o[i],o[c]]=[o[c],o[i]]}return o}e(rr,"deterministicShuffle");function ir(t,n){let o=0;for(let[s,i]of t.entries())o+=Math.abs(s-(n.get(i)??s));return o}e(ir,"sourceDistance");function so(t,n){let o=new Map;for(let[i,c]of t.entries())o.set(c,i);let s=0;for(let{a:i,b:c,weight:a}of n){let u=o.get(i),h=o.get(c);if(u==null||h==null)continue;s+=a*Math.abs(u-h)}return s}e(so,"laneArrangementCost");function cr(t){let n=ue(t);if(n.length<2)return[];let o=new Map(n.map((c,a)=>[c,a])),s=hn(t),i=new Map;for(let c of t.layout.edges??[]){if(c.isLayoutOnly)continue;let a=typeof c.start==="string"?c.start:void 0,u=typeof c.end==="string"?c.end:void 0;if(!a||!u||!t.nodeById.has(a)||!t.nodeById.has(u))continue;let h=s(a),d=s(u);if(!h||!d||h===d)continue;let m=o.get(h),p=o.get(d);if(m==null||p==null)continue;let[I,y]=m<=p?[h,d]:[d,h],g=`${I}\x00${y}`,l=i.get(g);if(l)l.weight++;else i.set(g,{a:I,b:y,weight:1})}return[...i.values()]}e(cr,"buildWeightedLaneEdges");function ro(t,n,o){let s=[...t],i=so(s,n),c=!0,a=0,u=Math.max(1,s.length);while(c&&a<u){c=!1,a++;for(let h=0;h+1<s.length;h++){[s[h],s[h+1]]=[s[h+1],s[h]];let d=so(s,n);if(d<i)i=d,c=!0;else[s[h],s[h+1]]=[s[h+1],s[h]]}}return{order:s,cost:i,sourceDistance:ir(s,o)}}e(ro,"greedySwitch");function ar(t,n){if(t.cost!==n.cost)return t.cost<n.cost;return t.sourceDistance<n.sourceDistance}e(ar,"isBetterCandidate");function fr(t,n,o){let s=[...n].sort((i,c)=>i.a===c.a?i.b.localeCompare(c.b):i.a.localeCompare(c.a)).map(({a:i,b:c,weight:a})=>`${i}:${c}:${a}`).join("|");return or(`${t.join("|")}#${s}#${o}`)}e(fr,"seedForRestart");function dr(t,n={}){let o=ue(t);if(o.length<2)return o;let s=cr(t);if(s.length===0)return o;let i=new Map(o.map((u,h)=>[u,h])),c=ro(o,s,i),a=Math.max(0,n.restarts??er);for(let u=0;u<a;u++){let h=fr(o,s,u),d=rr(o,h),m=ro(d,s,i);if(ar(m,c))c=m}return c.order}e(dr,"optimizeTopLaneOrder");function ur(t,n){let o=n?.ignoreCrossLaneEdges??!0,s=n?.optimizeRanksByCrossings??!0,i=Mn(t),c=n?.automaticLaneOrdering?dr(i,{restarts:er}):void 0,a=Ns(i),u=a.acyclic,h=o?qs(u,{compactSingleInput:n?.compactSingleInput??ie.DEFAULT_COMPACT_SINGLE_INPUT,ignoreCrossLaneEdges:!0,direction:n?.direction}):Ws(u,{compactSingleInput:n?.compactSingleInput??ie.DEFAULT_COMPACT_SINGLE_INPUT,ignoreCrossLaneEdges:!1,optimizeRanksByCrossings:s}),{layering:d,graphWithDummies:m}=Js(h,u),p=tr(d,m,{laneOrder:c}),I=nr(p,m,{layerGap:n?.layerGap,nodeGap:n?.nodeGap,direction:n?.direction,laneOrder:c});return{acyclic:u,reversed:a.reversed,layering:d,ordered:p,coordinates:I}}e(ur,"sugiyamaLayout");var ft=Hr.EPSILON,Dr=8,Sn=15,Nn=15,qn=25,sn=20,Re=10;function io(t,n,o){let s=t.x??0,i=t.y??0,c=n.x-s,a=n.y-i,u=Math.abs(c),h=Math.abs(a);if(u<ft&&h<ft)return o;let d=3;if(h>ft&&h*d>=u)return a>0?"bottom":"top";if(u>ft)return c>0?"right":"left";return o}e(io,"chooseOrthogonalSide");function co(t,n){return Math.abs(t.to-n.from)<ft||Math.abs(t.to-n.to)<ft?t.to:t.from}e(co,"sharedLineEndpointCoord");function Cn(t,n){return t.orient==="vertical"?{x:t.coord,y:n}:{x:n,y:t.coord}}e(Cn,"pointOnLine");function hr(t,n){let o=t.nodes??[],s=t.edges??[],i=[];for(let f of s){if(f.isLayoutOnly)continue;i.push({...f,__originalEdge:f})}let c=new Map,a=new Map,u=[],h=n==="LR";for(let f of o)c.set(f.id,f);let d=o.filter((f)=>f.isGroup&&!f.parentId);for(let f of d){let M={id:f.id},v=e((A)=>{a.set(A.id,M),o.filter((T)=>T.parentId===A.id).forEach(v)},"assignLane");v(f)}let m=o.filter((f)=>!f.isGroup&&!f.isEdgeLabel).map((f)=>{let M=f.width??10,v=f.height??10,A=f.x??0,T=f.y??0,k=Dr;return{nodeId:f.id,minX:A-M/2-k,maxX:A+M/2+k,minY:T-v/2-k,maxY:T+v/2+k,visualXHalfExtent:h?v/2+k:M/2+k}}),p=e((f,M,v,A)=>{let T=u.find((k)=>k.orientation===f&&Math.abs(k.coord-M)<1);if(!T)T={id:`pipe-${f}-${M.toFixed(0)}`,orientation:f,coord:M,spanMin:v,spanMax:A,tracks:[]},u.push(T);return T.spanMin=Math.min(T.spanMin,v),T.spanMax=Math.max(T.spanMax,A),T},"getOrAddPipe"),I=e((f,M)=>{let v=f.width??10,A=f.height??10,T=f.x??0,k=f.y??0;switch(M){case"top":return{x:T,y:k-A/2};case"bottom":return{x:T,y:k+A/2};case"left":return{x:T-v/2,y:k};case"right":return{x:T+v/2,y:k}}},"portForSide"),y=e((f,M,v)=>I(f,io(f,M,v?"bottom":"top")),"getOrthogonalPort"),g=[],l=[],x=new Set,L=1000,S=e((f,M,v)=>{if(g.length===0)return 0;let A=Math.abs(M.y-v.y)<ft,T=Math.abs(M.x-v.x)<ft;if(!A&&!T)return 0;let k=0;if(A){let K=M.y,Q=Math.min(M.x,v.x)-ft,j=Math.max(M.x,v.x)+ft;if(j<=Q)return 0;for(let z of g){if(z.edgeIndex===f||z.orientation!=="vertical")continue;if(z.pipe.coord<Q||z.pipe.coord>j)continue;if(z.from-ft<=K&&z.to+ft>=K)k+=L}}else if(T){let K=M.x,Q=Math.min(M.y,v.y)-ft,j=Math.max(M.y,v.y)+ft;if(j<=Q)return 0;for(let z of g){if(z.edgeIndex===f||z.orientation!=="horizontal")continue;if(z.pipe.coord<Q||z.pipe.coord>j)continue;if(z.from-ft<=K&&z.to+ft>=K)k+=L}}return k},"crossingPenalty"),E=i.map((f,M)=>{if(!f.start||!f.end)return{idx:M,crossLane:0,dx:0,dy:0};let v=c.get(f.start),A=c.get(f.end),T=a.get(f.start),k=a.get(f.end),K=T&&k&&T.id!==k.id?1:0,Q=v&&A?Math.abs((A.x??0)-(v.x??0)):0,j=v&&A?Math.abs((A.y??0)-(v.y??0)):0;return{idx:M,crossLane:K,dx:Q,dy:j}}).sort((f,M)=>{if(f.crossLane!==M.crossLane)return M.crossLane-f.crossLane;let v=f.dx+f.dy,A=M.dx+M.dy;if(Math.abs(v-A)>1)return v-A;return f.idx-M.idx}).map((f)=>f.idx),w=e((f,M,v,A)=>{let T=Math.min(f.x,M.x),k=Math.max(f.x,M.x),K=Math.min(f.y,M.y),Q=Math.max(f.y,M.y);return!!m.find((z)=>{if(v&&z.nodeId===v)return!1;if(A&&z.nodeId===A)return!1;if(Math.abs(f.x-M.x)>ft)return z.minY<f.y&&z.maxY>f.y&&z.maxX>T&&z.minX<k;else return z.minX<f.x&&z.maxX>f.x&&z.maxY>K&&z.minY<Q})},"isSegmentBlocked"),C=new Map,b=new Map;for(let f of i){if(!f.start||!f.end||f.start===f.end)continue;b.set(f.start,(b.get(f.start)??0)+1),b.set(f.end,(b.get(f.end)??0)+1)}let R=e((f,M)=>io(f,M,"bottom"),"determineSide"),O=new Map;for(let[f,M]of i.entries()){if(!M.start||!M.end||M.start===M.end)continue;if(M.points&&M.points.length>0)continue;let v=c.get(M.start),A=c.get(M.end);if(!v||!A)continue;let T=(A.x??0)-(v.x??0),k=(A.y??0)-(v.y??0);O.set(f,{edgeIdx:f,srcId:M.start,dstId:M.end,srcSide:R(v,{x:A.x??0,y:A.y??0}),dstSide:R(A,{x:v.x??0,y:v.y??0}),absDx:Math.abs(T),absDy:Math.abs(k),dxSign:Math.sign(T),dySign:Math.sign(k)})}let P=e((f)=>{if(f.srcSide==="top"||f.srcSide==="bottom")return f.absDx===0?1/0:f.absDy/f.absDx;return f.absDy===0?1/0:f.absDx/f.absDy},"preferenceStrength"),N=e((f)=>{if(f.srcSide==="top"||f.srcSide==="bottom")return f.dxSign>=0?"right":"left";return f.dySign>=0?"bottom":"top"},"secondarySide"),H=new Map;for(let f of O.values()){let M=`${f.srcId}:${f.srcSide}`;if(!H.has(M))H.set(M,[]);H.get(M).push(f)}let _=new Map,F=e((f,M)=>`${f}:${M}`,"loadKey");for(let f of O.values())_.set(F(f.srcId,f.srcSide),(_.get(F(f.srcId,f.srcSide))??0)+1),_.set(F(f.dstId,f.dstSide),(_.get(F(f.dstId,f.dstSide))??0)+1);for(let f of H.values()){if(f.length<2)continue;f.sort((M,v)=>{let A=P(M),T=P(v);if(Math.abs(A-T)>0.000000001)return T-A;return M.edgeIdx-v.edgeIdx});for(let M=1;M<f.length;M++){let v=f[M],A=N(v),T=_.get(F(v.srcId,v.srcSide))??0,k=_.get(F(v.srcId,A))??0;if(k>=T)continue;_.set(F(v.srcId,v.srcSide),T-1),_.set(F(v.srcId,A),k+1),v.srcSide=A}}let Y=e((f)=>{let M=f?.shape;return M==="question"||M==="diamond"},"isDiamondNode"),V=new Map;for(let f of O.values()){if(!V.has(f.dstId))V.set(f.dstId,new Set);V.get(f.dstId).add(f.dstSide)}for(let f of O.values()){if(!Y(c.get(f.srcId)))continue;let M=V.get(f.srcId);if(!M?.has(f.srcSide))continue;let v=N(f);if(M.has(v)||(_.get(F(f.srcId,v))??0)>0)continue;let A=_.get(F(f.srcId,f.srcSide))??0;_.set(F(f.srcId,f.srcSide),Math.max(0,A-1)),_.set(F(f.srcId,v),1),f.srcSide=v}for(let f of O.values()){let{edgeIdx:M,srcId:v,dstId:A,srcSide:T,dstSide:k}=f,K=c.get(v),Q=c.get(A),j=`${v}:${T}:src`,z=T==="top"||T==="bottom"?Q.x??0:Q.y??0;if(!C.has(j))C.set(j,[]);C.get(j).push({edgeIdx:M,oppositeCoord:z});let rt=`${A}:${k}:dst`,ct=k==="top"||k==="bottom"?K.x??0:K.y??0;if(!C.has(rt))C.set(rt,[]);C.get(rt).push({edgeIdx:M,oppositeCoord:ct})}let J=new Map,lt=8;for(let[f,M]of C){if(M.length<2)continue;M.sort((At,Xt)=>At.oppositeCoord-Xt.oppositeCoord);let v=f.split(":"),A=v.slice(0,-2).join(":"),T=v[v.length-2],k=v[v.length-1],K=c.get(A);if(!K)continue;let j=T==="left"||T==="right"?K.height??10:K.width??10,z=K.shape,ct=z==="question"||z==="diamond"?j*0.3:j,et=Math.min(20,Math.max(lt,ct/(M.length+1))),Bt=-(et*(M.length-1))/2;for(let[At,Xt]of M.entries()){let Qt=Bt+At*et,me=`${Xt.edgeIdx}:${k}`;J.set(me,Qt)}}let xt=e((f)=>Boolean(i[f]?.labelNodeId),"edgeHasLabelNode"),Ot=e((f,M)=>{if(!f)return!1;return(C.get(`${f}:${M}:src`)??[]).some(({edgeIdx:v})=>xt(v))||(C.get(`${f}:${M}:dst`)??[]).some(({edgeIdx:v})=>xt(v))},"faceHasLabelNode"),kt=e((f,M,v)=>{if(M==="top"||M==="bottom")return{x:f.x+v,y:f.y};else return{x:f.x,y:f.y+v}},"applyPortOffset"),nt=e((f,M,v)=>{let A=O.get(f),T={x:v.x??0,y:v.y??0},k={x:M.x??0,y:M.y??0},K=A?.srcSide??R(M,T),Q=A?.dstSide??R(v,k),j=A?I(M,A.srcSide):y(M,T,!0),z=A?I(v,A.dstSide):y(v,k,!1),rt=J.get(`${f}:src`),ct=J.get(`${f}:dst`);if(rt!==void 0)j=kt(j,K,rt);if(ct!==void 0)z=kt(z,Q,ct);return{pSrcPort:j,pDstPort:z,srcSide:K,dstSide:Q}},"portsForEdge");for(let f of E){let M=i[f];if(l[f]=[],!M.start||!M.end)continue;if(M.points&&M.points.length>0)continue;if(M.start===M.end)continue;let v=c.get(M.start),A=c.get(M.end);if(!v||!A)continue;let{pSrcPort:T,pDstPort:k,srcSide:K,dstSide:Q}=nt(f,v,A),j={...T},z={...k},rt=K==="top"||K==="bottom",ct=Q==="top"||Q==="bottom";if(rt){let G=T.y>(v.y??0);j.y=G?T.y+sn:T.y-sn}else{let G=T.x>(v.x??0);j.x=G?T.x+sn:T.x-sn}if(ct){let G=k.y>(A.y??0);z.y=G?k.y+sn:k.y-sn}else{let G=k.x>(A.x??0);z.x=G?k.x+sn:k.x-sn}let it=e((G,U)=>{for(let Z of m){if(U.includes(Z.nodeId))continue;if(G.x>Z.minX&&G.x<Z.maxX&&G.y>Z.minY&&G.y<Z.maxY)return{inside:!0,obstacle:Z}}return{inside:!1}},"isPointInObstacle"),et=e((G,U,Z,ut,Lt)=>{if(Lt){let Ft=G.y>(U.y??0);return{x:(Z.x??0)>=G.x?ut.maxX+Sn:ut.minX-Sn,y:Ft?ut.maxY+Nn:ut.minY-Nn,leavesPositiveSide:Ft}}let It=G.x>(U.x??0),Rt=(Z.y??0)>=G.y;return{x:It?ut.maxX+Sn:ut.minX-Sn,y:Rt?ut.maxY+Nn:ut.minY-Nn,leavesPositiveSide:It}},"obstacleDetour"),bt=[],Bt=[M.start,M.end],At=it(j,Bt);if(At.inside&&At.obstacle){let G=At.obstacle;if(rt){let U=et(T,v,A,G,!0);j.x=U.x,j.y=U.y;let Z=U.leavesPositiveSide?Math.min(G.minY-2,T.y+sn):Math.max(G.maxY+2,T.y-sn);bt=[{x:T.x,y:Z},{x:U.x,y:Z},{x:U.x,y:U.y}]}else{let U=et(T,v,A,G,!1),Z=U.leavesPositiveSide?Math.min(G.minX-2,T.x+sn):Math.max(G.maxX+2,T.x-sn);j.x=U.x,j.y=U.y,bt=[{x:Z,y:T.y},{x:Z,y:U.y},{x:U.x,y:U.y}]}}let Xt=[],Qt=it(z,Bt);if(Qt.inside&&Qt.obstacle){let G=Qt.obstacle;if(ct){let U=et(k,A,v,G,!0);z.x=U.x,z.y=U.y,Xt=[{x:U.x,y:U.y},{x:k.x,y:U.y}]}else{let U=et(k,A,v,G,!1);z.x=U.x,z.y=U.y,Xt=[{x:U.x,y:U.y},{x:U.x,y:k.y}]}}if(bt.length===0&&Xt.length===0){let G=Sn,U=Math.abs(j.x-z.x)<G,Z=Math.abs(j.y-z.y)<G,ut=J.get(`${f}:src`)!==void 0||J.get(`${f}:dst`)!==void 0,Lt=(C.get(`${M.start??""}:${K}:src`)?.length??0)+(C.get(`${M.start??""}:${K}:dst`)?.length??0),It=(C.get(`${M.end??""}:${Q}:src`)?.length??0)+(C.get(`${M.end??""}:${Q}:dst`)?.length??0),Rt=Lt>1||It>1,Ft=b.get(M.start??"")??0,gt=b.get(M.end??"")??0,$t=Lt>1&&Ot(M.start,K)||It>1&&Ot(M.end,Q),on=Lt<=1||Ft<=2,_t=It<=1||gt<=2;if((U||Z)&&!ut&&(!Rt||Rt&&!$t&&on&&_t)){if(!w(T,k,M.start,M.end)){M.points=[{...T},{...j},{...z},{...k}],x.add(f);let St=Z?"horizontal":"vertical",Vt=Z?T.y:T.x,Ct=Z?Math.min(T.x,k.x):Math.min(T.y,k.y),vt=Z?Math.max(T.x,k.x):Math.max(T.y,k.y),qt={id:`fast-path-${St}-${Vt.toFixed(0)}-${f}`,orientation:St,coord:Vt,spanMin:Ct,spanMax:vt,tracks:[]};g.push({edgeIndex:f,segmentIndex:0,orientation:St,pipe:qt,trackIndex:0,from:Ct,to:vt});continue}}}let me=p("vertical",j.x,j.y,j.y);j.x=me.coord;let yr=p("vertical",z.x,z.y,z.y);z.x=yr.coord;let pn=Math.min(j.x,z.x)-50,mn=Math.max(j.x,z.x)+50,An=Math.min(j.y,z.y)-50,Rn=Math.max(j.y,z.y)+50;for(let G of m){let U=Math.min(j.x,z.x),Z=Math.max(j.x,z.x),ut=Math.min(j.y,z.y),Lt=Math.max(j.y,z.y);if(G.minX<Z&&G.maxX>U&&G.minY<Lt&&G.maxY>ut)pn=Math.min(pn,G.minX-qn),mn=Math.max(mn,G.maxX+qn),An=Math.min(An,G.minY-qn),Rn=Math.max(Rn,G.maxY+qn)}for(let G of m){if(G.maxX<pn||G.minX>mn||G.maxY<An||G.minY>Rn)continue;let U=Sn;p("horizontal",G.minY-U,pn,mn),p("horizontal",G.maxY+U,pn,mn);let Z=Nn;p("vertical",G.minX-Z,An,Rn),p("vertical",G.maxX+Z,An,Rn)}p("horizontal",j.y,pn,mn),p("horizontal",z.y,pn,mn);let xr=u.filter((G)=>G.orientation==="horizontal"&&G.coord>=An&&G.coord<=Rn),br=u.filter((G)=>G.orientation==="vertical"&&G.coord>=pn&&G.coord<=mn),Hn=e((G,U)=>`${G.toFixed(1)},${U.toFixed(1)}`,"getKey"),Dn=Hn(j.x,j.y),Ro=Hn(z.x,z.y),Xn=new Map,ye=new Map,xe=new Map,Yn=new Set,In=[];Xn.set(Dn,0),xe.set(Dn,"n"),In.push({key:Dn,f:Math.hypot(z.x-j.x,z.y-j.y),pt:j}),Yn.add(Dn);let Yt=[],yn=e((G,U)=>w(G,U,M.start,M.end),"checkSegmentBlocked"),be={x:z.x,y:j.y},Mr=yn(j,be),Ir=yn(be,z),Sr=Mr||Ir,Me={x:j.x,y:z.y},Cr=yn(j,Me),vr=yn(Me,z),Lr=Cr||vr;if(!Sr)if(Math.abs(j.y-z.y)<ft||Math.abs(j.x-z.x)<ft)Yt=[j,z];else Yt=[j,be,z];else if(!Lr)if(Math.abs(j.x-z.x)<ft)Yt=[j,z];else Yt=[j,Me,z];if(Yt.length===0)while(In.length>0){In.sort((gt,$t)=>gt.f-$t.f);let G=In.shift();if(Yn.delete(G.key),G.key===Ro){let gt=Ro,$t=z;Yt=[$t];while(ye.has(gt)){let on=ye.get(gt);Yt.unshift(on),$t=on,gt=Hn(on.x,on.y)}break}let U=G.pt.x,Z=G.pt.y,ut=br.sort((gt,$t)=>gt.coord-$t.coord),Lt=ut.findIndex((gt)=>Math.abs(gt.coord-U)<1),It=xr.sort((gt,$t)=>gt.coord-$t.coord),Rt=It.findIndex((gt)=>Math.abs(gt.coord-Z)<1),Ft=[];if(Lt>0)Ft.push({x:ut[Lt-1].coord,y:Z});if(Lt>=0&&Lt<ut.length-1)Ft.push({x:ut[Lt+1].coord,y:Z});if(Rt>0)Ft.push({x:U,y:It[Rt-1].coord});if(Rt>=0&&Rt<It.length-1)Ft.push({x:U,y:It[Rt+1].coord});for(let gt of Ft){let $t=Math.min(U,gt.x),on=Math.max(U,gt.x),_t=Math.min(Z,gt.y),zt=Math.max(Z,gt.y);if(m.some((tn)=>{if(tn.nodeId===M.start||tn.nodeId===M.end)return!1;if($t!==on)return tn.minY<Z&&tn.maxY>Z&&tn.maxX>$t&&tn.minX<on;else return tn.minX<U&&tn.maxX>U&&tn.maxY>_t&&tn.minY<zt}))continue;let St=Hn(gt.x,gt.y),Vt=Math.abs(gt.x-U)+Math.abs(gt.y-Z),Ct=S(f,G.pt,gt),vt=0,qt=z.x-j.x,Tn=z.y-j.y,Gn=gt.x-U,Ie=gt.y-Z;if(Tn>10&&Ie<-5||Tn<-10&&Ie>5)vt=Math.abs(Ie)*100;if(qt>10&&Gn<-5||qt<-10&&Gn>5)vt+=Math.abs(Gn)*50;let To=0,wo=xe.get(G.key)??"n",No=Math.abs(Gn)>ft?"h":"v";if(wo!=="n"&&wo!==No)To=50;let Er=Vt+Ct+vt+To,$n=(Xn.get(G.key)??1/0)+Er,Oo=Math.abs(z.x-gt.x)+Math.abs(z.y-gt.y);if($n<(Xn.get(St)??1/0))if(ye.set(St,G.pt),Xn.set(St,$n),xe.set(St,No),!Yn.has(St))In.push({key:St,f:$n+Oo,pt:gt}),Yn.add(St);else{let tn=In.findIndex((Ar)=>Ar.key===St);if(tn!==-1)In[tn].f=$n+Oo}}}if(Yt.length===0)Yt=[j,{x:j.x,y:z.y},z];if(Yt.length>4){let G=Yt[0],U=Yt[Yt.length-1],Z=Math.min(G.x,U.x),ut=Math.max(G.x,U.x),Lt=Math.min(G.y,U.y),It=Math.max(G.y,U.y);for(let _t of Yt)Z=Math.min(Z,_t.x),ut=Math.max(ut,_t.x),Lt=Math.min(Lt,_t.y),It=Math.max(It,_t.y);let Rt=ut>Math.max(G.x,U.x),Ft=Z<Math.min(G.x,U.x);if(h){let _t=Nn;if(Rt){let zt=Math.max(G.x,U.x),Pt=Math.min(G.y,U.y),St=Math.max(G.y,U.y),Vt=m.filter((Ct)=>Ct.minX<zt&&Ct.maxX>zt&&Ct.minY<St&&Ct.maxY>Pt);if(Vt.length>0){let Ct=Math.max(G.x,U.x);for(let vt of Vt){let qt=(vt.minX+vt.maxX)/2;if(vt.visualXHalfExtent===void 0||isNaN(vt.visualXHalfExtent))continue;let Tn=qt+vt.visualXHalfExtent+_t;Ct=Math.max(Ct,Tn)}if(!isNaN(Ct))ut=Ct}}if(Ft){let zt=m.filter((Pt)=>Pt.minX<Math.min(G.x,U.x)+_t&&Pt.minY<Math.max(G.y,U.y)&&Pt.maxY>Math.min(G.y,U.y));if(zt.length>0){let Pt=Math.min(G.x,U.x);for(let St of zt){let Ct=(St.minX+St.maxX)/2-St.visualXHalfExtent-_t;Pt=Math.min(Pt,Ct)}Z=Pt}}}let gt=e((_t)=>{let zt=U.y>G.y,Pt=m.filter((Ct)=>{let vt=Math.min(G.x,U.x)<Ct.maxX&&Math.max(G.x,U.x)>Ct.minX,qt=Math.min(G.y,U.y)<Ct.maxY&&Math.max(G.y,U.y)>Ct.minY;return vt&&qt}),St=Pt;if(h&&Pt.length>0){let Ct=Pt.filter((vt)=>vt.minX<_t&&vt.maxX>_t);if(Ct.length>0)St=Ct}if(St.length===0)return U.y;let Vt=Sn;if(zt){let vt=Math.max(...St.map((qt)=>qt.maxY))+Vt;if(vt<U.y-ft)return vt}else{let vt=Math.min(...St.map((qt)=>qt.minY))-Vt;if(vt>U.y+ft)return vt}return U.y},"findBestReturnY"),$t=e((_t)=>{let zt=gt(_t),Pt={x:_t,y:G.y},St={x:_t,y:zt},Vt={x:U.x,y:zt},Ct=yn(G,Pt),vt=yn(Pt,St),qt=yn(St,Vt),Tn=zt!==U.y?yn(Vt,U):!1;if(!Ct&&!vt&&!qt&&!Tn){if(Math.abs(zt-U.y)<ft)return[G,Pt,St,U];return[G,Pt,St,Vt,U]}return null},"trySimplifyWithDetourX"),on=Rt&&!Ft?$t(ut):Ft&&!Rt?$t(Z):null;if(on)Yt=on}let Gt=[T,...bt,...Yt,...Xt.reverse(),k];if(Gt.length>=3){let G=Gt[Gt.length-1],U=Gt[Gt.length-2],Z=Gt[Gt.length-3],ut=Math.abs(Z.y-U.y)<ft&&Math.abs(U.y-G.y)<ft,Lt=Math.abs(Z.x-U.x)<ft&&Math.abs(U.x-G.x)<ft;if(ut){let It=Math.sign(U.x-Z.x),Rt=Math.sign(G.x-Z.x);if(It!==0&&It===Rt&&Math.abs(U.x-Z.x)>Math.abs(G.x-Z.x))Gt.splice(-2,1)}else if(Lt){let It=Math.sign(U.y-Z.y),Rt=Math.sign(G.y-Z.y);if(It!==0&&It===Rt&&Math.abs(U.y-Z.y)>Math.abs(G.y-Z.y))Gt.splice(-2,1)}}let ln=[Gt[0]];for(let G=1;G<Gt.length-1;G++){if(G===1){ln.push(Gt[G]);continue}let U=ln[ln.length-1],Z=Gt[G],ut=Gt[G+1];if(Math.abs(U.y-Z.y)<ft&&Math.abs(Z.y-ut.y)<ft){let Lt=Z.x>U.x,It=ut.x>Z.x;if(Lt!==It){ln.push(Z);continue}continue}if(Math.abs(U.x-Z.x)<ft&&Math.abs(Z.x-ut.x)<ft){let Lt=Z.y>U.y,It=ut.y>Z.y;if(Lt!==It){ln.push(Z);continue}continue}ln.push(Z)}ln.push(Gt[Gt.length-1]);for(let G=0;G<ln.length-1;G++){let U=ln[G],Z=ln[G+1],ut=Math.abs(U.x-Z.x)<ft?"vertical":"horizontal",Lt=ut==="vertical"?U.x:U.y,It=ut==="vertical"?Math.min(U.y,Z.y):Math.min(U.x,Z.x),Rt=ut==="vertical"?Math.max(U.y,Z.y):Math.max(U.x,Z.x),Ft=p(ut,Lt,It,Rt),gt={edgeIndex:f,segmentIndex:G,orientation:ut,pipe:Ft,trackIndex:0,from:It,to:Rt};if(g.push(gt),l[f].push(g.length-1),!Ft.tracks[0])Ft.tracks[0]={index:0,coord:Ft.coord,segments:[]};Ft.tracks[0].segments.push({edgeIndex:f,segmentIndex:G,from:It,to:Rt})}}let q=e((f,M)=>f.from<M.to&&M.from<f.to,"segmentsOverlap"),ot=e((f,M,v,A)=>{let T=!A.segments.some((K)=>(K.edgeIndex!==M.edgeIndex||K.segmentIndex!==M.segmentIndex)&&q(K,f)),k=!v.segments.some((K)=>(K.edgeIndex!==f.edgeIndex||K.segmentIndex!==f.segmentIndex)&&q(K,M));if(T&&k)return f.trackIndex=A.index,M.trackIndex=v.index,v.segments=[...v.segments.filter((K)=>K.edgeIndex!==f.edgeIndex||K.segmentIndex!==f.segmentIndex),{edgeIndex:M.edgeIndex,segmentIndex:M.segmentIndex,from:M.from,to:M.to}],A.segments=[...A.segments.filter((K)=>K.edgeIndex!==M.edgeIndex||K.segmentIndex!==M.segmentIndex),{edgeIndex:f.edgeIndex,segmentIndex:f.segmentIndex,from:f.from,to:f.to}],!0;return!1},"trySwapSegmentsAcrossTracks"),dt=e((f)=>{let M=f.tracks.length;return f.tracks[M]={index:M,coord:f.coord,segments:[]},M},"createNewTrack"),mt=e((f,M)=>{let v=f.pipe.tracks[f.trackIndex];v.segments=v.segments.filter((T)=>T.edgeIndex!==f.edgeIndex||T.segmentIndex!==f.segmentIndex),f.trackIndex=M,f.pipe.tracks[M].segments.push({edgeIndex:f.edgeIndex,segmentIndex:f.segmentIndex,from:f.from,to:f.to})},"moveSegmentToTrack"),Mt=e((f,M)=>{let v=l[f.edgeIndex];for(let A of v){let T=g[A];if(T.pipe===f.pipe)mt(T,M)}},"moveSegmentChainToTrack"),Et=e((f)=>{let M=l[f.edgeIndex],v=M.indexOf(g.indexOf(f)),A=[];if(v>0)A.push(g[M[v-1]]);if(v<M.length-1)A.push(g[M[v+1]]);return A},"getAdjacentSegmentsAlongEdge"),jt=e((f,M)=>{if(f.orientation===M.orientation)return!1;let v=f.orientation==="horizontal"?f:M,A=f.orientation==="horizontal"?M:f;return A.pipe.coord>v.from&&A.pipe.coord<v.to&&v.pipe.coord>A.from&&v.pipe.coord<A.to},"haveAnyCrossing"),Wt=e((f,M)=>{for(let v of f.tracks)if(!v.segments.some((T)=>(T.edgeIndex!==M.edgeIndex||T.segmentIndex!==M.segmentIndex)&&q(T,M)))return v.index;return-1},"findAvailableTrack"),Kt=e((f,M)=>{if(f.trackIndex===M.trackIndex)return q(f,M);let v=Et(f),A=Et(M);return v.some((T)=>A.some((k)=>jt(T,k)))},"segmentsConflict"),en=e((f,M,v)=>{if(ot(f,M,f.pipe.tracks[f.trackIndex],M.pipe.tracks[M.trackIndex]))return;let A=Wt(f.pipe,M);v(M,A!==-1?A:dt(f.pipe))},"resolveTrackConflict"),Ln=e((f)=>{let M=0;for(let v=0;v<f.length;v++)for(let A=v+1;A<f.length;A++){let T=f[v],k=f[A];if(T.pipe!==k.pipe)continue;if(Kt(T,k))M++,en(T,k,Mt)}return M},"resolveHandleConflicts"),gn=new Map,En=e((f)=>{if(gn.has(f))return gn.get(f);let M=l[f];if(M.length===0){let Q={dest:0,deviation:0,base:0,delta:0};return gn.set(f,Q),Q}let A=g[M[0]].pipe.coord,T=A;for(let Q=1;Q<M.length;Q++){let j=g[M[Q]];if(j.orientation==="horizontal"){let{from:z,to:rt}=j;T=Math.abs(z-A)>Math.abs(rt-A)?z:rt;break}}let k=Math.abs(T-A),K={dest:T,deviation:k,base:A,delta:T-A};return gn.set(f,K),K},"getDestInfo"),he=e(()=>{let f=0,M=new Map;for(let[A,T]of i.entries()){if(l[A].length===0)continue;if(!T.start)continue;if(!M.has(T.start))M.set(T.start,[]);M.get(T.start).push(A)}let v=e((A)=>{let T=i[A];if(!T.start||!T.end)return 0;let k=c.get(T.start),K=c.get(T.end);if(!k||!K)return 0;let Q=(K.x??0)-(k.x??0),j=(K.y??0)-(k.y??0);return Math.abs(Q)+Math.abs(j)},"getEdgeDistance");for(let A of M.values()){A.sort((k,K)=>{let Q=En(k),j=En(K);if(Math.abs(Q.deviation-j.deviation)>1)return Q.deviation-j.deviation;if(Math.abs(Q.dest-j.dest)>1)return Q.dest-j.dest;let z=v(k),rt=v(K);if(Math.abs(z-rt)>1)return rt-z;let ct=l[k].length,it=l[K].length;if(ct!==it)return ct-it;if(ct===1){let et=l[k][0],bt=l[K][0];if(g[et]&&g[bt]){let Bt=g[et],At=g[bt],Xt=Math.abs(Bt.to-Bt.from),Qt=Math.abs(At.to-At.from);if(Math.abs(Xt-Qt)>1)return Xt-Qt}}return 0});let T=A.map((k)=>g[l[k][0]]);f+=Ln(T)}return f},"fixSourceHandleCrossings"),ge=e(()=>{let f=0,M=new Map;for(let[v,A]of i.entries()){if(l[v].length===0)continue;if(!A.end)continue;if(!M.has(A.end))M.set(A.end,[]);M.get(A.end).push(v)}for(let v of M.values()){v.sort((T,k)=>{let K=e((z)=>{let rt=l[z];if(rt.length<2)return 0;let ct=g[rt[rt.length-2]];return Math.abs(ct.to-ct.from)},"getDist"),Q=K(T),j=K(k);if(Math.abs(Q-j)>0.1)return Q-j;return T-k});let A=v.map((T)=>g[l[T][l[T].length-1]]);f+=Ln(A)}return f},"fixTargetHandleCrossings"),pe=e(()=>{let f=0;for(let M of u){let v=[];for(let A of M.tracks)for(let T of A.segments){let k=l[T.edgeIndex].find((K)=>g[K].segmentIndex===T.segmentIndex);if(k!==void 0)v.push(g[k])}v.sort((A,T)=>A.edgeIndex-T.edgeIndex||A.segmentIndex-T.segmentIndex);for(let A=0;A<v.length;A++)for(let T=A+1;T<v.length;T++){let k=v[A],K=v[T];if(Kt(k,K))f++,en(k,K,mt)}}return f},"fixPipeCrossings"),B=0,D=10;while(B<D){let f=0;if(f+=he(),f+=ge(),f+=pe(),f===0)break;B++}let X=new Map;for(let f of u){let M=[];f.tracks.forEach((A)=>{A.segments.forEach((T)=>{M.push({edgeIndex:T.edgeIndex,segmentIndex:T.segmentIndex,trackIndex:A.index,from:T.from,to:T.to})})}),M.sort((A,T)=>A.from-T.from);let v=[];if(M.length>0){let A=[M[0]],T=M[0].to;for(let k=1;k<M.length;k++){let K=M[k];if(K.from<T)A.push(K),T=Math.max(T,K.to);else v.push(A),A=[K],T=K.to}v.push(A)}for(let A of v){let T=new Set;A.forEach((et)=>T.add(et.trackIndex));let k=new Map;A.forEach((et)=>{let bt=En(et.edgeIndex);k.set(et.trackIndex,(k.get(et.trackIndex)??0)+bt.delta)});let K=[...T].filter((et)=>(k.get(et)??0)<-1),Q=[...T].filter((et)=>(k.get(et)??0)>1),j=[...T].filter((et)=>Math.abs(k.get(et)??0)<=1);K.sort((et,bt)=>(k.get(bt)??0)-(k.get(et)??0)),Q.sort((et,bt)=>(k.get(et)??0)-(k.get(bt)??0));let z=e((et,bt)=>{A.filter((Bt)=>Bt.trackIndex===et).forEach((Bt)=>{let At=x.has(Bt.edgeIndex)?f.coord:bt;X.set(`${Bt.edgeIndex}-${Bt.segmentIndex}`,At)})},"assignCoord"),rt=0;for(let et of K)rt++,z(et,f.coord-rt*Re);if(j.length===0&&T.size>0){let et=[...T].sort((At,Xt)=>Math.abs(k.get(At)??0)-Math.abs(k.get(Xt)??0))[0],bt=K.indexOf(et);if(bt!==-1)K.splice(bt,1);let Bt=Q.indexOf(et);if(Bt!==-1)Q.splice(Bt,1);j.push(et)}let ct=0;for(let et of j){if(ct===0)z(et,f.coord);else{let bt=ct%2===1?1:-1,Bt=Math.ceil(ct/2);z(et,f.coord+bt*Bt*Re*0.5)}ct++}let it=0;for(let et of Q)it++,z(et,f.coord+it*Re)}}for(let[f,M]of i.entries()){let v=l[f]??[];if(v.length===0)continue;let A=[],T=c.get(M.start),k=c.get(M.end),{pSrcPort:K,pDstPort:Q}=nt(f,T,k),j=v.map((ct)=>{let it=g[ct],et=X.get(`${it.edgeIndex}-${it.segmentIndex}`)??it.pipe.coord;return{orient:it.orientation,coord:et,from:it.from,to:it.to}});A.push(K);for(let ct=0;ct<j.length;ct++){let it=j[ct],et=A[A.length-1],bt=it.orient==="vertical"?et.y:et.x,Bt=it.orient==="vertical"?et.x:et.y,At=j[ct+1],Xt=ct<j.length-1;if(Math.abs(Bt-it.coord)>ft)A.push(Cn(it,bt));if(Xt&&At.orient===it.orient){if(Math.abs(it.coord-At.coord)>ft){let Qt=it.orient==="vertical"?(bt+At.from)/2:co(it,At);A.push(Cn(it,Qt),Cn(At,Qt))}else if(ct===0||ct===j.length-2)A.push(Cn(it,co(it,At)))}else if(Xt)A.push(Cn(it,At.coord));else{let Qt=Math.abs(it.from-bt)<Math.abs(it.to-bt)?it.to:it.from;A.push(Cn(it,Qt))}}let z=A[A.length-1];if(Math.abs(z.x-Q.x)>ft||Math.abs(z.y-Q.y)>ft)A.push(Q);let rt=[];if(A.length>0)rt.push(A[0]);for(let ct=1;ct<A.length;ct++){let it=A[ct],et=rt[rt.length-1];if(Math.abs(it.x-et.x)>ft||Math.abs(it.y-et.y)>ft)rt.push(it)}M.points=rt}for(let f of i){let M=f.__originalEdge;if(M&&f.points)M.points=f.points}t.edges=(t.edges??[]).filter((f)=>!f.isLayoutOnly);let W=e((f,M)=>{let v=M.x??0,A=M.y??0,T=M.width??0,k=M.height??0;if(T<=0||k<=0)return f;let K=v-T/2,Q=v+T/2,j=A-k/2,z=A+k/2;if(f.x<K||f.x>Q||f.y<j||f.y>z)return f;let rt=f.x-K,ct=Q-f.x,it=f.y-j,et=z-f.y,bt=Math.min(rt,ct,it,et);if(bt===rt)return{x:K,y:f.y};if(bt===ct)return{x:Q,y:f.y};if(bt===it)return{x:f.x,y:j};return{x:f.x,y:z}},"nodeBoundaryClamp");for(let f of t.edges){let M=f.points;if(!M||M.length<2)continue;let{start:v,end:A}=f,T=v?c.get(v):void 0,k=A?c.get(A):void 0;if(T)M[0]=W(M[0],T);if(k)M[M.length-1]=W(M[M.length-1],k)}return t}e(hr,"routeEdgesOrthogonal");function gr(t){return t.direction??"TB"}e(gr,"getSwimlaneDirection");function pr(t){let n=qo(t),o=t.config.flowchart?.nodeSpacing??40,s=t.config.flowchart?.rankSpacing??100,i=t.config.swimlane?.ignoreCrossLaneEdges??!0,c=t.config.swimlane?.optimizeRanksByCrossings??!0,a=t.config.swimlane?.automaticLaneOrdering??!1,u=gr(t),{ordered:h,coordinates:d}=ur(n,{nodeGap:o,layerGap:s,ignoreCrossLaneEdges:i,optimizeRanksByCrossings:c,automaticLaneOrdering:a,direction:u});Jo(n,h,d,{nodeGap:o,layerGap:s});for(let m of t.edges??[])delete m.points;hr(t,u);for(let m of t.edges??[])if(!m.curve||m.curve==="basis")m.curve="rounded";return Ts(t,u),Rs(t),u}e(pr,"runSwimlaneLayoutCore");function mr(t){Ko(t);let n=Zo(t);t.nodes=n.nodes,t.edges=n.edges}e(mr,"prepareSwimlaneLayout");var oi=lr({prepareLayout:mr,runLayoutCore:pr,afterPaint:jo});export{oi as render};
|