@bkm016/basalt 0.1.9 → 0.1.10

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.
Files changed (132) hide show
  1. package/{chunk-0xd9mnc2.js → chunk-0mjb3sm3.js} +2 -2
  2. package/{chunk-66h5qpc6.js → chunk-3mqf9ped.js} +89 -89
  3. package/compiled.js +1 -1
  4. package/package.json +1 -1
  5. package/ui-test-worker.js +1 -1
  6. package/web/chunk-045d3b5d.js +1 -0
  7. package/web/{chunk-ff1pmd3g.js → chunk-0770q5e1.js} +1 -1
  8. package/web/{chunk-2x4g9t37.js → chunk-18neka5g.js} +2 -2
  9. package/web/{chunk-w3w18stt.js → chunk-1ev0n3n4.js} +1 -1
  10. package/web/chunk-1ex3wgms.js +2 -0
  11. package/web/{chunk-7qkav30b.js → chunk-1qh7f5kr.js} +1 -1
  12. package/web/{chunk-rayf24gy.js → chunk-26ecc2xh.js} +8 -8
  13. package/web/{chunk-me7dza1c.js → chunk-2cz7tx8q.js} +1 -1
  14. package/web/{chunk-mdfksj61.js → chunk-32ty2xfn.js} +1 -1
  15. package/web/{chunk-ts6jsfdk.js → chunk-3eexx7y5.js} +1 -1
  16. package/web/{chunk-2dvbeqt0.js → chunk-46jnkghq.js} +1 -1
  17. package/web/chunk-4am8j3k3.js +1 -0
  18. package/web/{chunk-qz6r9v1z.js → chunk-5qvmefq2.js} +1 -1
  19. package/web/{chunk-9ctg0f30.js → chunk-5svqfj4g.js} +1 -1
  20. package/web/{chunk-qsqtwf34.js → chunk-5v5q13hz.js} +1 -1
  21. package/web/chunk-7np1jp3x.js +8 -0
  22. package/web/chunk-87e8d1hv.js +1 -0
  23. package/web/{chunk-kcjz03h5.js → chunk-88wd49xe.js} +2 -2
  24. package/web/{chunk-0pghpg4y.js → chunk-8h2x89tw.js} +1 -1
  25. package/web/chunk-8y2526ve.js +1 -0
  26. package/web/{chunk-8jcvdd5d.js → chunk-905vw286.js} +1 -1
  27. package/web/{chunk-2hrswh3d.js → chunk-918e5t4x.js} +1 -1
  28. package/web/chunk-96m2m3e8.js +1 -0
  29. package/web/{chunk-43g4wd7a.js → chunk-9f4zzqbx.js} +1 -1
  30. package/web/{chunk-dnv8dx72.js → chunk-a1n4468c.js} +1 -1
  31. package/web/{chunk-s37beysw.js → chunk-b46ws7rf.js} +1 -1
  32. package/web/{chunk-24jhbz82.js → chunk-bc3ajvfg.js} +1 -1
  33. package/web/{chunk-ket6g0yd.js → chunk-d5gshd1a.js} +1 -1
  34. package/web/{chunk-c6yacwbc.js → chunk-de40q05r.js} +1 -1
  35. package/web/chunk-dp0k5vhd.js +1 -0
  36. package/web/{chunk-5dr4tkem.js → chunk-dv1berk6.js} +3 -3
  37. package/web/{chunk-dwjmr0zj.js → chunk-eh7wp62z.js} +1 -1
  38. package/web/{chunk-ctzkqx2g.js → chunk-ehtmb6sn.js} +1 -1
  39. package/web/chunk-et1hytyv.js +1 -0
  40. package/web/chunk-f9m9seam.js +1 -0
  41. package/web/{chunk-3pd0qt83.js → chunk-fmmrthpa.js} +2 -2
  42. package/web/chunk-g2erm7k0.js +1 -0
  43. package/web/chunk-g3kbn0t2.js +1 -0
  44. package/web/{chunk-t893141g.js → chunk-g7dc4hrd.js} +1 -1
  45. package/web/{chunk-p9hfcamx.js → chunk-g7kz8f7q.js} +1 -1
  46. package/web/chunk-ght0t49g.js +1 -0
  47. package/web/{chunk-xa43ndfj.js → chunk-ghwm7bdj.js} +2 -2
  48. package/web/{chunk-8z0r0wtk.js → chunk-grm2208k.js} +1 -1
  49. package/web/{chunk-0zwc2rvh.js → chunk-gsw1tv96.js} +1 -1
  50. package/web/{chunk-tftc5v89.js → chunk-gw8x1g61.js} +1 -1
  51. package/web/chunk-gx340asc.js +1 -0
  52. package/web/{chunk-935mjq1c.js → chunk-h2txs73e.js} +1 -1
  53. package/web/chunk-h3tkacc7.js +1 -0
  54. package/web/{chunk-ewx42c11.js → chunk-h5ckjk48.js} +1 -1
  55. package/web/{chunk-nnyc889n.js → chunk-j37p0b13.js} +1 -1
  56. package/web/{chunk-fjb3ksfd.js → chunk-j89s11x8.js} +1 -1
  57. package/web/chunk-je78j3vr.js +1 -0
  58. package/web/{chunk-fpb2dd2d.js → chunk-jke2ev6m.js} +1 -1
  59. package/web/{chunk-98y92vmh.js → chunk-js6kb05s.js} +1 -1
  60. package/web/{chunk-30b33r2w.js → chunk-k0cg4n2k.js} +2 -2
  61. package/web/{chunk-b5h52neg.js → chunk-knm82fw9.js} +1 -1
  62. package/web/{chunk-vqmj6peg.js → chunk-kxdtg9dt.js} +1 -1
  63. package/web/{chunk-db3twjvk.js → chunk-m4fxd5d9.js} +5 -5
  64. package/web/chunk-m9xzt9p7.js +1 -0
  65. package/web/{chunk-xx11yv61.js → chunk-n4yzs2q0.js} +1 -1
  66. package/web/{chunk-zdyys4ar.js → chunk-nawxgz87.js} +2 -2
  67. package/web/chunk-ngt1j8py.js +1139 -0
  68. package/web/{chunk-3ak5dg10.js → chunk-p55vhns6.js} +1 -1
  69. package/web/{chunk-nvpp0ghj.js → chunk-pgwf37s2.js} +1 -1
  70. package/web/{chunk-af9evdza.js → chunk-q4bst4an.js} +1 -1
  71. package/web/{chunk-9fnr00kv.js → chunk-qdzy124b.js} +2 -2
  72. package/web/chunk-qe0bgeda.js +1 -0
  73. package/web/{chunk-60axh4sa.js → chunk-qy1zx2yw.js} +2 -2
  74. package/web/{chunk-sk1wkgjw.js → chunk-rag65pfs.js} +1 -1
  75. package/web/{chunk-5jdrev9p.js → chunk-rbqnre6q.js} +3 -3
  76. package/web/{chunk-ddyyc20r.js → chunk-rh3xb76f.js} +1 -1
  77. package/web/{chunk-wzd2a4k5.js → chunk-rwfmccmh.js} +1 -1
  78. package/web/{chunk-zb2bkr7f.js → chunk-rxvm70w5.js} +1 -1
  79. package/web/{chunk-z05x9cbm.js → chunk-sat7zyva.js} +1 -1
  80. package/web/{chunk-rrpn5r5w.js → chunk-sc63488q.js} +1 -1
  81. package/web/{chunk-v1exk5wd.js → chunk-sd3xat3r.js} +6 -6
  82. package/web/{chunk-4a6gdrbs.js → chunk-se4h6wx0.js} +1 -1
  83. package/web/{chunk-a0ryzdnp.js → chunk-sjkg40ay.js} +1 -1
  84. package/web/chunk-sk0hpa80.js +1 -0
  85. package/web/{chunk-spbs56wz.js → chunk-t5nvgz7z.js} +1 -1
  86. package/web/{chunk-veam6vk4.js → chunk-tfqarvdx.js} +30 -30
  87. package/web/{chunk-5a4mj3qz.js → chunk-tqze6d6b.js} +1 -1
  88. package/web/{chunk-8w7fyb3v.js → chunk-tt93zbn4.js} +7 -7
  89. package/web/chunk-tvcxrx6h.js +1 -0
  90. package/web/chunk-tzpnh70q.js +1 -0
  91. package/web/{chunk-79e08rk1.js → chunk-vasppf6b.js} +1 -1
  92. package/web/chunk-vb7g4xg6.js +1 -0
  93. package/web/{chunk-dz7g1gnv.js → chunk-w3zgfhjb.js} +1 -1
  94. package/web/{chunk-gn8kyz76.js → chunk-wrevb4ew.js} +1 -1
  95. package/web/{chunk-3ecrkvr3.js → chunk-wtvch4ad.js} +1 -1
  96. package/web/chunk-wzfe6jtq.js +1 -0
  97. package/web/{chunk-eadfxfkw.js → chunk-x5g1yy12.js} +1 -1
  98. package/web/{chunk-m9q5nr8f.js → chunk-x850q01z.js} +1 -1
  99. package/web/{chunk-a61zrp66.js → chunk-xk904wqv.js} +1 -1
  100. package/web/{chunk-3hr3ew9w.js → chunk-xtn305fd.js} +1 -1
  101. package/web/{chunk-3txxt0a7.js → chunk-yekaz74b.js} +1 -1
  102. package/web/{chunk-rasjtvsb.js → chunk-yppgejg7.js} +2 -2
  103. package/web/{chunk-66wb0p6e.js → chunk-z4bp6p32.js} +1 -1
  104. package/web/{chunk-5v2c0aqk.js → chunk-z5qn0xev.js} +1 -1
  105. package/web/{chunk-5baeh8q7.js → chunk-zms6mrqk.js} +4 -4
  106. package/web/{chunk-601k823s.js → chunk-zse05v6j.js} +2 -2
  107. package/web/{chunk-vsjpnwsr.js → chunk-zz1qkaar.js} +1 -1
  108. package/web/index.html +1 -1
  109. package/web/chunk-08sq3cwm.js +0 -1
  110. package/web/chunk-24fjnnee.js +0 -1
  111. package/web/chunk-2j2atyjw.js +0 -1
  112. package/web/chunk-3h3g3ca3.js +0 -1
  113. package/web/chunk-3pcrxg6m.js +0 -1
  114. package/web/chunk-814kkkmq.js +0 -8
  115. package/web/chunk-8w8atrdh.js +0 -1
  116. package/web/chunk-942g3eqn.js +0 -1
  117. package/web/chunk-avxk6jpc.js +0 -2
  118. package/web/chunk-fmthkpff.js +0 -1
  119. package/web/chunk-gv99c8zv.js +0 -1
  120. package/web/chunk-h0767tjv.js +0 -1
  121. package/web/chunk-hqynf99g.js +0 -1
  122. package/web/chunk-mbwwj216.js +0 -1
  123. package/web/chunk-n0wazxgz.js +0 -1
  124. package/web/chunk-nvt9tkt4.js +0 -1139
  125. package/web/chunk-ph1dgffm.js +0 -1
  126. package/web/chunk-rad2s9ha.js +0 -1
  127. package/web/chunk-s60s09mb.js +0 -1
  128. package/web/chunk-tfvcs2xx.js +0 -1
  129. package/web/chunk-wdq2tp9e.js +0 -1
  130. package/web/chunk-wkf5xfyr.js +0 -1
  131. package/web/chunk-y1qty77a.js +0 -1
  132. package/web/chunk-zgavhnt8.js +0 -1
@@ -1 +1 @@
1
- import{t,a,Ne}from"./chunk-veam6vk4.js";import"./chunk-kcjz03h5.js";import{lr}from"./chunk-zb2bkr7f.js";var Un=5,zn=0.00001,Rr=2,Tr=0.6,Vn=0.000001;function jn(n){let e=[];for(let o=0;o<n.length-1;o++)e.push({a:n[o],b:n[o+1]});return e}t(jn,"buildSegmentList");function Bo(n,e,o,s){let r=e.x-n.x,i=e.y-n.y,c=s.x-o.x,u=s.y-o.y,h=r*u-i*c;if(h===0)return null;let d=o.x-n.x,m=o.y-n.y,p=(d*u-m*c)/h,I=(d*i-m*r)/h;if(p<=Vn||p>=1-Vn||I<=Vn||I>=1-Vn)return null;return{point:{x:n.x+p*r,y:n.y+p*i},tA:p,tB:I}}t(Bo,"segmentIntersection");function Se(n){return Math.abs(n.b.x-n.a.x)>=Math.abs(n.b.y-n.a.y)}t(Se,"isHorizontalSeg");function Ce(n,e,o){if(n.curve!=="rounded")return!1;let s=n.points,r=s[e],i=s[e+1];if(!r||!i)return!1;let c=Math.hypot(i.x-r.x,i.y-r.y),u=o*c,h=e>0?Pn(s[e-1],r,i,Un):null;if(h&&u<h.cutLen)return!0;let d=e+2<s.length?Pn(r,i,s[e+2],Un):null;return d!==null&&c-u<d.cutLen}t(Ce,"crossingSitsInRoundedCorner");function Fo(n){let e=[];for(let o=0;o<n.length;o++){let s=n[o],r=jn(s.points);for(let i=o+1;i<n.length;i++){let c=n[i],u=jn(c.points);for(let[h,d]of r.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(c,m,I.tB))continue;let y=Se(d),g=Se(p);if(y!==g?y:!1)e.push({jumpEdgeId:s.id,otherEdgeId:c.id,segIndex:h,t:I.tA,point:I.point});else e.push({jumpEdgeId:c.id,otherEdgeId:s.id,segIndex:m,t:I.tB,point:I.point})}}}return e}t(Fo,"findEdgeIntersections");function cn(n){let e=Math.round(n*1000)/1000;return Number.isInteger(e)?`${e}`:`${e}`}t(cn,"fmt");function wn(n){return`${cn(n.x)},${cn(n.y)}`}t(wn,"pointToString");function Po(n){let e=n.b.x-n.a.x,o=n.b.y-n.a.y;if(Math.abs(e)>=Math.abs(o))return e>=0?1:0;return o>=0?1:0}t(Po,"getArcSweepFlag");function ko(n,e){if(n.length<2)return n.map((i)=>({...i}));let o=n.map((i)=>({...i})),s=e.arrowTypeStart&&Ne[e.arrowTypeStart];if(s){let i=n[0],c=n[1],u=Math.atan2(c.y-i.y,c.x-i.x);o[0].x=i.x+s*Math.cos(u),o[0].y=i.y+s*Math.sin(u)}let r=e.arrowTypeEnd&&Ne[e.arrowTypeEnd];if(r){let i=n.length,c=n[i-2],u=n[i-1],h=Math.atan2(u.y-c.y,u.x-c.x);o[i-1].x=u.x-r*Math.cos(h),o[i-1].y=u.y-r*Math.sin(h)}return o}t(ko,"applyMarkerOffsets");function _o(n,e,o,s,r){let i=n.point.x,c=n.point.y,u={x:i-e*n.r,y:c-o*n.r},h={x:i+e*n.r,y:c+o*n.r},d=[`L${wn(u)}`];if(r==="arc")d.push(`A${cn(n.r)},${cn(n.r)} 0 0 ${s} ${wn(h)}`);else d.push(`M${wn(h)}`);return d}t(_o,"emitJump");function Pn(n,e,o,s){let r=e.x-n.x,i=e.y-n.y,c=o.x-e.x,u=o.y-e.y,h=Math.hypot(r,i),d=Math.hypot(c,u);if(h<zn||d<zn)return null;let m=r/h,p=i/h,I=c/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:e.x-m*L,startY:e.y-p*L,endX:e.x+I*L,endY:e.y+y*L,ctrlX:e.x,ctrlY:e.y,cutLen:L}}t(Pn,"computeRoundedCorner");function Ho(n,e,o){let s=n.points;if(s.length<2)return"";let r=ko(s,n),i=n.curve==="rounded",c=jn(r),u=new Map;for(let d of e){let m=c[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(r[0])}`];for(let d=0;d<c.length;d++){let m=c[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(i&&d>0){let w=Pn(r[d-1],r[d],r[d+1]??r[d],Un);if(w)l=w.cutLen}let x=p,L=null;if(i&&d<c.length-1){if(L=Pn(r[d],r[d+1],r[d+2]??r[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(i&&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(" ")}t(Ho,"rewriteEdgePath");function Do(n){return/^[\d\s+,.LMelm-]*$/.test(n)}t(Do,"isStraightPath");function Xo(n){if(!n)return!0;return n==="linear"||n==="rounded"||n==="step"||n==="stepBefore"||n==="stepAfter"}t(Xo,"curveSupportsLineHops");function Yo(n){if(!n)return null;try{let e=typeof atob==="function"?atob(n):Buffer.from(n,"base64").toString(),o=JSON.parse(e);if(!Array.isArray(o))return null;let s=[];for(let r of o)if(r&&typeof r.x==="number"&&typeof r.y==="number")s.push({x:r.x,y:r.y});return s.length>=2?s:null}catch{return null}}t(Yo,"decodeDataPoints");function ve(n,e,o){if(!o.enabled)return;let s=n.node();if(!s)return;let r=new Map;for(let d of e)r.set(d.id,d);let i=new Map;for(let d of s.querySelectorAll("path[data-id]")){let m=d.getAttribute("data-id");if(m!==null&&!i.has(m))i.set(m,d)}let c=[];for(let d of e){let m=i.get(d.id);if(!m)continue;let I=Yo(m.getAttribute("data-points"))??d.points;c.push({...d,points:I})}let u=Fo(c);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 c){let m=h.get(d.id);if(!m||m.length===0)continue;let I=r.get(d.id)?.curve;if(I!==void 0&&!Xo(I))continue;let y=i.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)}}}t(ve,"applyLineJumpsToSvg");function jo(n,{measure:e}){let o=n.config?.swimlane?.lineHops;if(o===!1)return;let s=o==="gap"?"gap":"arc",r=n.edges.filter((i)=>Array.isArray(i.points)&&i.points.length>=2).map((i)=>({id:i.id,points:i.points,curve:i.curve,arrowTypeStart:i.arrowTypeStart,arrowTypeEnd:i.arrowTypeEnd}));ve(e.groups.edgePaths,r,{enabled:!0,jumpRadius:6,jumpStyle:s})}t(jo,"applySwimlaneLineJumps");var Le="__swimlane_default__",wr=21,Go=20;function Te(n){return Math.max(n.padding??Go,Go)}t(Te,"topLaneHorizontalPadding");function Wo(n){let{x:e,y:o,width:s,height:r}=n,i=n.swimlaneContentTop;if(typeof e!=="number"||typeof o!=="number"||typeof s!=="number"||typeof r!=="number"||typeof i!=="number"||!Number.isFinite(e)||!Number.isFinite(o)||!Number.isFinite(s)||!Number.isFinite(r)||!Number.isFinite(i)||s<=0||r<=0){delete n.groupTitleRect;return}let c=o-r/2,u=Math.min(i,o+r/2),h=Math.min(wr,Math.max(0,u-c)),d=c+h;if(d<=c){delete n.groupTitleRect;return}n.groupTitleRect={left:e-s/2,right:e+s/2,top:c,bottom:d}}t(Wo,"assignTopLaneTitleRect");function Ko(n){let e=n.direction,o=n.nodes??=[];for(let i of n.nodes??[])if(i.isGroup&&!i.parentId){if(i.shape="swimlane",e)i.direction=e}let s=o.filter((i)=>!i.isGroup&&!i.parentId);if(s.length===0)return;let r=o.find((i)=>i.id===Le);if(!r)r={id:Le,label:"",isGroup:!0,shape:"swimlane",padding:20,look:n.config?.look,colorIndex:o.reduce((i,c)=>Math.max(i,c.colorIndex??-1),-1)+1,...e?{direction:e}:{}},o.push(r);else if(r.isGroup){if(r.shape="swimlane",e)r.direction=e}for(let i of s)i.parentId=Le}t(Ko,"prepareLayoutForSwimlanes");function qo(n){let e=new Map;for(let h of n.nodes??[])e.set(h.id,h);let o=[];for(let h of n.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=n.nodes??[],r=s.filter((h)=>h.isGroup),i=s.filter((h)=>!h.isGroup);return{nodes:[...[...r].reverse(),...i].map((h)=>h.id),edges:o,layout:n,nodeById:e}}t(qo,"toGraphView");function Jo(n,e,o,s){let{layout:r}=n,i=n.nodeById,c=s?.layerGap??100,u=s?.nodeGap??40,h=0;for(let I of e.layers){let y=0;for(let g of I){let l=i.get(g);if(!l){y++;continue}l.layer=h,l.order=y;let x=o.x[g]??y*u,L=o.y[g]??h*c;l.x=x,l.y=L,y++}h++}let d=r.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)}}}}}t(Jo,"writeBackToLayoutData");var Nr="[EdgeLabelNodes]";function Zo(n){let e=[],o=[],s=new Map;for(let c of n.nodes)s.set(c.id,c);for(let c of n.edges){if(!c.label||c.label.length===0)continue;if(c.isLayoutOnly)continue;if(c.labelNodeId)continue;let u=c.start?s.get(c.start):void 0,h=c.end?s.get(c.end):void 0;if(!u||!h){a.warn(Nr,`Edge ${c.id} has missing source or target node`);continue}let d=`edge-label-${c.start}-${c.end}-${c.id}`,p=u.parentId!==h.parentId?h.parentId:u.parentId,I={id:d,label:c.label,edgeStart:c.start??"",edgeEnd:c.end??"",shape:"labelRect",width:0,height:0,isEdgeLabel:!0,isDummy:!0,parentId:p,isGroup:!1,labelStyle:Array.isArray(c.labelStyle)?c.labelStyle[0]:c.labelStyle??"",...u.dir?{dir:u.dir}:{}};e.push(I),c.labelNodeId=d,c.label=void 0,c.text=void 0;let y={id:`${c.id}-to-label`,start:c.start,end:d,type:"normal",isLayoutOnly:!0},g={id:`${c.id}-from-label`,start:d,end:c.end,type:"normal",isLayoutOnly:!0};o.push(y,g)}let r=[...n.nodes,...e],i=[...n.edges,...o];return{...n,nodes:r,edges:i}}t(Zo,"createEdgeLabelNodes");var Dt=0.001;function ao(n){let e=n.x??0,o=n.y??0,s=n.width??0,r=n.height??0;return s>0&&r>0?{cx:e,cy:o,rect:On(e,o,s,r)}:void 0}t(ao,"measuredNodeRect");function lo(n){if(n.isGroup)return;let e=ao(n);if(!e)return;return{id:String(n.id??""),cx:e.cx,cy:e.cy,rect:e.rect}}t(lo,"nodeBoundsInfoFor");function rn(n,e,o=Dt){return Math.abs(n.x-e.x)<o&&Math.abs(n.y-e.y)<o}t(rn,"samePoint");function ht(n,e,o=Dt){return Math.abs(n.x-e.x)<o}t(ht,"sameX");function pt(n,e,o=Dt){return Math.abs(n.y-e.y)<o}t(pt,"sameY");function Tt(n,e,o=Dt){return pt(n,e,o)&&Math.abs(n.x-e.x)>o}t(Tt,"isHorizontalSegment");function wt(n,e,o=Dt){return ht(n,e,o)&&Math.abs(n.y-e.y)>o}t(wt,"isVerticalSegment");function Ut(n,e,o,s){return Math.max(0,Math.min(Math.max(n,e),Math.max(o,s))-Math.max(Math.min(n,e),Math.min(o,s)))}t(Ut,"overlapLength");function fn(n,e,o=Dt){if(n.horizontal&&e.horizontal&&pt(n.a,e.a,o))return Ut(n.a.x,n.b.x,e.a.x,e.b.x);if(n.vertical&&e.vertical&&ht(n.a,e.a,o))return Ut(n.a.y,n.b.y,e.a.y,e.b.y);return 0}t(fn,"sameAxisSegmentOverlapLength");function Bn(n,e=Dt){let o=[];for(let s=0;s<n.length-1;s++){let r=n[s],i=n[s+1],c=Tt(r,i,e),u=wt(r,i,e);if(c||u)o.push({index:s,a:r,b:i,horizontal:c,vertical:u})}return o}t(Bn,"orthogonalSegmentsForPoints");function nn(n,e=Dt){let o=Bn(n,e),s=0;for(let r=1;r<o.length;r++)if(o[r-1].horizontal!==o[r].horizontal)s++;return s}t(nn,"countOrthogonalBends");function yt(n,e=Dt){let o=[];for(let s of n){let r=o.length>0?o[o.length-1]:void 0;if(!r||!rn(r,s,e))o.push({x:s.x,y:s.y})}return o}t(yt,"dedupeConsecutivePoints");function fo(n,e=Dt){if(!n||n.length!==4)return;let[o,s,r,i]=n;if(Tt(o,s,e)&&wt(s,r,e)&&Tt(r,i,e))return{kind:"HVH",p0:o,p1:s,p2:r,p3:i};return wt(o,s,e)&&Tt(s,r,e)&&wt(r,i,e)?{kind:"VHV",p0:o,p1:s,p2:r,p3:i}:void 0}t(fo,"classifyThreeSegmentRoute");function ae(n,e,o,s=0){let r=Math.min(n.x,e.x),i=Math.max(n.x,e.x),c=Math.min(n.y,e.y),u=Math.max(n.y,e.y);return i>o.left-s&&r<o.right+s&&u>o.top-s&&c<o.bottom+s}t(ae,"segmentBoundsOverlapRect");function uo(n,e,o=0){return n.x>e.left+o&&n.x<e.right-o&&n.y>e.top+o&&n.y<e.bottom-o}t(uo,"pointInsideRect");function Qo(n,e){return n.left<=e.left&&n.right>=e.right&&n.top<=e.top&&n.bottom>=e.bottom}t(Qo,"rectContainsRect");function Qn(n,e){return n.left<e.right&&n.right>e.left&&n.top<e.bottom&&n.bottom>e.top}t(Qn,"rectsOverlap");function we(n,e){return{left:n.left-e,right:n.right+e,top:n.top-e,bottom:n.bottom+e}}t(we,"inflateRect");function On(n,e,o,s){return{left:n-o/2,right:n+o/2,top:e-s/2,bottom:e+s/2}}t(On,"rectFromCenterSize");function Zt(n){return ao(n)?.rect}t(Zt,"rectOfNodeBounds");function vn(n,e){switch(e){case"top":return{x:n.cx,y:n.rect.top};case"bottom":return{x:n.cx,y:n.rect.bottom};case"left":return{x:n.rect.left,y:n.cy};case"right":return{x:n.rect.right,y:n.cy}}}t(vn,"portForRectSide");function ho(n,e,o,s,r,i=Dt){let c=e==="left"||e==="right",u=s==="left"||s==="right";if(c&&u){if(e==="right"&&s==="left"&&n.x<o.x||e==="left"&&s==="right"&&n.x>o.x){if(pt(n,o,i))return[n,o];let p=(n.x+o.x)/2;return[n,{x:p,y:n.y},{x:p,y:o.y},o]}if(e===s){if(pt(n,o,i))return;let p=e==="left"?Math.min(n.x,o.x)-r:Math.max(n.x,o.x)+r;return[n,{x:p,y:n.y},{x:p,y:o.y},o]}return}if(!c&&!u){if(e===s){if(ht(n,o,i))return;let I=e==="top"?Math.min(n.y,o.y)-r:Math.max(n.y,o.y)+r;return[n,{x:n.x,y:I},{x:o.x,y:I},o]}if(!(e==="bottom"&&s==="top"&&n.y<o.y||e==="top"&&s==="bottom"&&n.y>o.y))return;if(ht(n,o,i))return[n,o];let p=(n.y+o.y)/2;return[n,{x:n.x,y:p},{x:o.x,y:p},o]}if(c&&!u){let m=e==="right"&&o.x>n.x||e==="left"&&o.x<n.x,p=s==="top"&&n.y<o.y||s==="bottom"&&n.y>o.y;return m&&p?[n,{x:o.x,y:n.y},o]:void 0}let h=e==="bottom"&&o.y>n.y||e==="top"&&o.y<n.y,d=s==="left"&&n.x<o.x||s==="right"&&n.x>o.x;return h&&d?[n,{x:n.x,y:o.y},o]:void 0}t(ho,"buildOrthogonalPortPath");function go(n,e,o,s){return e==="left"||e==="right"?[n,{x:s,y:n.y},{x:s,y:o.y},o]:[n,{x:n.x,y:s},{x:o.x,y:s},o]}t(go,"buildSameSideTrackPath");function le(n){let e=new Map,o=[];for(let s of n){if(s.isEdgeLabel)continue;let r=lo(s);if(!r)continue;e.set(r.id,r),o.push({id:r.id,rect:r.rect})}return{nodeInfoById:e,realNodeRects:o}}t(le,"collectRealNodeBounds");function bn(n){let e=[],o=[];for(let s of n){let r=lo(s);if(!r)continue;let i={id:r.id,rect:r.rect};if(s.isEdgeLabel)o.push(i);else e.push(i)}return{realNodeRects:e,labelNodeRects:o}}t(bn,"collectNodeRectEntries");function ts(n,{includeEdgeLabels:e=!0}={}){let o=[];for(let s of n){if(s.isGroup||!e&&s.isEdgeLabel)continue;let r=s.x??0,i=s.y??0,c=s.width??0,u=s.height??0;o.push({nodeId:s.id,...On(r,i,c,u)})}return o}t(ts,"collectLayoutNodeRects");function po(n,e,o=Dt){let{start:s,end:r}=n;if(!s||!r)return;let i=e.get(s),c=e.get(r);if(!i||!c)return;return{srcId:s,dstId:r,srcInfo:i,dstInfo:c,collinearX:Math.abs(i.cx-c.cx)<o,collinearY:Math.abs(i.cy-c.cy)<o}}t(po,"getNodePairGeometry");function Nt(n,e,o,s=[],r=0){for(let i of o){if(s.includes(i.id))continue;if(ae(n,e,i.rect,-r))return!0}return!1}t(Nt,"segmentHitsAnyRect");function mo(n,e,o,s,r=Dt,i=0.000001){let c=pt(n,e,r),u=ht(n,e,r),h=pt(o,s,r),d=ht(o,s,r);if(c&&h||u&&d)return!1;if(!(c||u)||!(h||d))return!1;let m=c?{a:n,b:e}:{a:o,b:s},p=u?{a:n,b:e}:{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)<i&&Math.abs(I-m.a.y)<i||Math.abs(l-m.b.x)<i&&Math.abs(I-m.b.y)<i,E=Math.abs(l-p.a.x)<i&&Math.abs(I-p.a.y)<i||Math.abs(l-p.b.x)<i&&Math.abs(I-p.b.y)<i;return!(S&&E)}t(mo,"orthogonalSegmentsCross");function ns(n,e,o,s,r=Dt){let i=pt(n,e,r),c=ht(n,e,r),u=pt(o,s,r),h=ht(o,s,r);if(c&&h&&ht(n,o,r))return Ut(n.y,e.y,o.y,s.y)>r;if(i&&u&&pt(n,o,r))return Ut(n.x,e.x,o.x,s.x)>r;return!1}t(ns,"sameAxisSegmentsOverlap");function te(n,e,o,s,{epsilon:r=Dt,skipDegenerateOther:i=!1}={}){for(let c of o){if(c===s||c.isLayoutOnly)continue;let u=c.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(i&&rn(d,m,r))continue;if(mo(n,e,d,m,r)||ns(n,e,d,m,r))return!0}}return!1}t(te,"segmentConflictsWithAnyEdge");function un(n,e,o,s,r=Dt){let i=pt(n,e,r),c=ht(n,e,r),u=pt(o,s,r),h=ht(o,s,r);if(!(i&&h||c&&u))return!1;let d=i?{a:n,b:e}:{a:o,b:s},m=i?{a:o,b:s}:{a:n,b:e},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+r&&g<y-r&&p>l+r&&p<x-r}t(un,"orthogonalSegmentsStrictlyCross");function Oe(n,e,o){let s=Math.min(e,o),r=Math.max(e,o);return n>s+Dt&&n<r-Dt}t(Oe,"strictlyBetween");function es(n,e,o){if(ht(n,e)&&ht(e,o))return Oe(e.y,n.y,o.y);if(pt(n,e)&&pt(e,o))return Oe(e.x,n.x,o.x);return!1}t(es,"isCollinearIntermediate");function os(n){let e=!1,o=[];for(let s=0;s<n.length;s++){let r=o[o.length-1],i=n[s],c=s+1<n.length?n[s+1]:void 0;if(r&&c){if(rn(r,c)){s++,e=!0;continue}if(es(r,i,c)){e=!0;continue}}o.push(i)}return{points:o,changed:e}}t(os,"simplifyPolylineOnce");function ne(n){let e=[n[0]];for(let s=1;s<n.length;s++){let r=e[e.length-1],i=n[s];if(!ht(r,i)&&!pt(r,i)){let c=e.length>=2?e[e.length-2]:void 0,h=(c?ht(c,r):!1)?{x:r.x,y:i.y}:{x:i.x,y:r.y};e.push(h)}e.push(i)}let o=[];for(let s of e){let r=o[o.length-1];if(!r||!rn(r,s))o.push(s)}return o}t(ne,"orthogonalizePolyline");function dn(n){if(n.length<3)return n;let e=[...n];for(let o=0;o<32;o++){let s=os(e);if(e=s.points,!s.changed)break}return e}t(dn,"simplifyPolyline");var st=0.001,Or=0.5,$o=4;function yo(n,e,o){let s=n;if(s.isLayoutOnly||!s.points||s.points.length<o)return;let r=s.start?e.get(s.start):void 0,i=s.end?e.get(s.end):void 0;return{edge:s,points:s.points,srcRect:r?Zt(r):void 0,dstRect:i?Zt(i):void 0}}t(yo,"endpointContextFor");function ss(n,e,o){if(pt(n,e,st))return{x:n.x<o.left?o.left:o.right,y:n.y};if(ht(n,e,st)){let s=n.y<o.top?o.top:o.bottom;return{x:n.x,y:s}}return{x:Math.min(o.right,Math.max(o.left,n.x)),y:Math.min(o.bottom,Math.max(o.top,n.y))}}t(ss,"segmentEnterPoint");function Be(n,e,o){let s=o?1:-1,r=o?0:n.length-1;while(r>=0&&r<n.length&&uo(n[r],e,Or))r+=s;if(r<0||r>=n.length)return n;let i=r-s;if(i<0||i>=n.length)return n;let c=ss(n[r],n[i],e);return o?[c,...n.slice(r)]:[...n.slice(0,r+1),c]}t(Be,"clipEndpoint");function rs(n,e){for(let o of n){let s=yo(o,e,2);if(!s)continue;let r=[...s.points];if(s.srcRect)r=Be(r,s.srcRect,!0);if(s.dstRect)r=Be(r,s.dstRect,!1);r=dn(ne(r)),r=xo(r,s.srcRect,s.dstRect),s.edge.points=dn(ne(r))}}t(rs,"clipEdgeEndpointsToNodeBoundaries");function Fe(n,e,o,s=!1){if(pt(n,e,st)){if(e.y<o.top-st||e.y>o.bottom+st)return e;if(s){if(n.x<o.left-st)return{x:o.left,y:n.y};if(n.x>o.right+st)return{x:o.right,y:n.y}}return{x:Math.abs(e.x-o.left)<=Math.abs(e.x-o.right)?o.left:o.right,y:n.y}}if(ht(n,e,st)){if(e.x<o.left-st||e.x>o.right+st)return e;if(s){if(n.y<o.top-st)return{x:n.x,y:o.top};if(n.y>o.bottom+st)return{x:n.x,y:o.bottom}}let r=Math.abs(e.y-o.top)<=Math.abs(e.y-o.bottom);return{x:n.x,y:r?o.top:o.bottom}}return e}t(Fe,"snapEndpointToBoundary");function ee(n,e,o){let s=n[e];for(let r=e+o;r>=0&&r<n.length;r+=o){let i=n[r];if(!rn(i,s,st))return i}return n[e+o]}t(ee,"firstDistinctAdjacent");function oe(n,e){let o=n+$o,s=e-$o;return o<=s?{lo:o,hi:s}:{lo:(n+e)/2,hi:(n+e)/2}}t(oe,"cornerClearanceRange");function Pe(n,e,o){let{lo:s,hi:r}=oe(e,o);return Math.min(r,Math.max(s,n))}t(Pe,"clampToCornerClearance");function is(n){let e=Math.max(...n.map((s)=>s.lo)),o=Math.min(...n.map((s)=>s.hi));if(e>o)return;return{lo:e,hi:o}}t(is,"intersectRanges");function ke(n,e){return e==="left"||e==="right"?oe(n.top,n.bottom):oe(n.left,n.right)}t(ke,"clearanceRangeForSide");function se(n,e,o){let s=n.y>=o.top-st&&n.y<=o.bottom+st,r=n.x>=o.left-st&&n.x<=o.right+st;if(pt(n,e,st)&&s){if(Math.abs(n.x-o.left)<st)return"left";if(Math.abs(n.x-o.right)<st)return"right"}if(ht(n,e,st)&&r){if(Math.abs(n.y-o.top)<st)return"top";if(Math.abs(n.y-o.bottom)<st)return"bottom"}return}t(se,"terminalSideForSegment");function kn(n){return n==="left"||n==="right"}t(kn,"isHorizontalSide");function cs(n,e,o,s,r){let i=[],c=o?se(n,e,o):void 0,u=s?se(e,n,s):void 0;if(o&&c&&kn(c)===r)i.push(ke(o,c));if(s&&u&&kn(u)===r)i.push(ke(s,u));return i.length>0?is(i):void 0}t(cs,"straightClearanceRange");function _e(n,e,o,s,r){let i=cs(n,e,o,s,r);if(!i)return;let c=r?n.y:n.x,u=Math.min(i.hi,Math.max(i.lo,c));if(Math.abs(u-c)<st)return;return r?[{x:n.x,y:u},{x:e.x,y:u}]:[{x:u,y:n.y},{x:u,y:e.y}]}t(_e,"clearStraightEndpointCornerAxis");function xo(n,e,o){if(n.length!==2)return n;let[s,r]=n;if(pt(s,r,st))return _e(s,r,e,o,!0)??n;if(ht(s,r,st))return _e(s,r,e,o,!1)??n;return n}t(xo,"clearStraightEndpointCornerConnections");function as(n,e,o){return kn(o)?{x:n.x,y:Pe(n.y,e.top,e.bottom)}:{x:Pe(n.x,e.left,e.right),y:n.y}}t(as,"cornerClearedEndpoint");function ls(n,e,o,s,r,i){let c=n.map((u)=>({...u}));for(let u=e;u>=0&&u<n.length;u+=o){let h=n[u];if(i&&!pt(h,s,st))break;if(!i&&!ht(h,s,st))break;if(i)c[u].y=r.y;else c[u].x=r.x}return c}t(ls,"moveCollinearEndpointRun");function He(n,e,o){if(n.length<2)return n;let s=o?0:n.length-1,r=o?1:-1,i=n[s],c=ee(n,s,r);if(!c)return n;let u=se(i,c,e);if(!u)return n;let h=kn(u),d=as(i,e,u);if(rn(i,d,st))return n;return ls(n,s,r,i,d,h)}t(He,"clearEndpointCornerConnection");function De(n,e,o){let s=Math.min(n.x,e.x)>=o.left-st&&Math.max(n.x,e.x)<=o.right+st,r=Math.min(n.y,e.y)>=o.top-st&&Math.max(n.y,e.y)<=o.bottom+st;if(Math.abs(n.y-o.top)<st&&Math.abs(e.y-o.top)<st&&s)return"top";if(Math.abs(n.y-o.bottom)<st&&Math.abs(e.y-o.bottom)<st&&s)return"bottom";if(Math.abs(n.x-o.left)<st&&Math.abs(e.x-o.left)<st&&r)return"left";if(Math.abs(n.x-o.right)<st&&Math.abs(e.x-o.right)<st&&r)return"right";return}t(De,"borderSideForSegment");function Xe(n,e,o,s){switch(n){case"top":return ht(e,o,st)&&o.y<s.top-st;case"bottom":return ht(e,o,st)&&o.y>s.bottom+st;case"left":return pt(e,o,st)&&o.x<s.left-st;case"right":return pt(e,o,st)&&o.x>s.right+st}}t(Xe,"leavesOutward");function Ye(n,e,o){if(n.length<3)return n;if(o){let i=De(n[0],n[1],e);if(i&&Xe(i,n[1],n[2],e))return n.slice(1);return n}let s=n.length-1,r=De(n[s-1],n[s],e);if(r&&Xe(r,n[s-1],n[s-2],e))return n.slice(0,s);return n}t(Ye,"collapseOwnBorderStub");function fs(n,e,o){let s=n;if(e){let i=ee(s,0,1);if(i){let c=Fe(i,s[0],e);if(c!==s[0])s=[c,...s.slice(1)]}s=Ye(s,e,!0)}if(o){let i=s.length-1,c=ee(s,i,-1);if(c){let u=Fe(c,s[i],o,!0);if(u!==s[i])s=[...s.slice(0,i),u]}s=Ye(s,o,!1)}let r=xo(s,e,o);if(r!==s||s.length===2)return r;if(e)s=He(s,e,!0);if(o)s=He(s,o,!1);return s}t(fs,"snapAndCollapseEndpoints");function Ge(n,e){for(let o of n){let s=yo(o,e,2);if(!s)continue;let r=yt(s.points,st),i=fs(r,s.srcRect,s.dstRect);if(i.length<3){s.edge.points=i;continue}let c=[i[0],{...i[0]},...i.slice(1,-1),i[i.length-1],{...i[i.length-1]}];s.edge.points=c}}t(Ge,"prepareEdgeEndpointsForRenderer");function bo(n){return new Map(n.map((e)=>[e.id,e]))}t(bo,"buildNodeMap");function ds(n,e){let o=n.parentId,s=null;while(o){let r=e.get(o);if(!r?.isGroup)break;s=r.id,o=r.parentId}return s}t(ds,"resolveTopLevelGroupId");function $e(n,e){let o=0,s=n.parentId;while(s){let r=e.get(s);if(!r?.isGroup)break;o++,s=r.parentId}return o}t($e,"groupDepth");function Mo(n){let e=1/0,o=-1/0,s=1/0,r=-1/0;for(let i of n){let{x:c,y:u}=i;if(typeof c!=="number"||typeof u!=="number")continue;let h=i.width??0,d=i.height??0;e=Math.min(e,c-h/2),o=Math.max(o,c+h/2),s=Math.min(s,u-d/2),r=Math.max(r,u+d/2)}if(e===1/0||s===1/0)return null;return{minX:e,maxX:o,minY:s,maxY:r}}t(Mo,"boundsForChildren");function us(n,e){let o=n.padding??20;n.x=(e.minX+e.maxX)/2,n.y=(e.minY+e.maxY)/2,n.width=Math.max(0,e.maxX-e.minX)+o,n.height=Math.max(0,e.maxY-e.minY)+o}t(us,"applyGroupBounds");function hs(n){let e=bo(n),o=n.filter((s)=>s.isGroup&&s.parentId).sort((s,r)=>$e(r,e)-$e(s,e));for(let s of o){let r=n.filter((c)=>c.parentId===s.id),i=Mo(r);if(i)us(s,i)}}t(hs,"recomputeNestedGroupBounds");function re(n,e){let o=n.nodes??[],s=n.edges??[],r=o.filter((h)=>!h.isGroup),i=1/0,c=-1/0;for(let h of r){let d=h[e];if(typeof d!=="number")continue;i=Math.min(i,d),c=Math.max(c,d)}if(!Number.isFinite(i)||!Number.isFinite(c))return!1;let u=t((h)=>i+c-h,"mirror");for(let h of o){let d=h[e];if(typeof d==="number")h[e]=u(d);let m=h.groupTitleRect;if(m)h.groupTitleRect=e==="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[e]=u(d[e]);return!0}t(re,"mirrorAxis");function gs(n){if(!(n.nodes??[]).some((o)=>!o.isGroup))return!0;return re(n,"y")}t(gs,"applyBtDirectionTransform");function ps(n,e="LR"){let o=n.nodes??[],s=n.edges??[],r=o.filter((F)=>!F.isGroup),i=1/0,c=1/0;for(let F of r){let Y=F.x??0,V=F.y??0;if(Y<i)i=Y;if(V<c)c=V}if(!Number.isFinite(i)||!Number.isFinite(c))return!1;let u=36,h=0,d=0;for(let F of r)h+=F.width??0,d+=F.height??0;let m=h/r.length,p=d/r.length,I=p>0?Math.max(1,m/p):1;for(let F of r){let Y=F.x??0,J=((F.y??0)-c)*I+u,lt=Y-i;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-c)*I+u,xt=V-i;Y.x=lt,Y.y=xt}}hs(o);let y=o.filter((F)=>F.isGroup&&!F.parentId);if(y.length===0){if(e==="RL")re(n,"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(e==="RL")re(n,"x");return!0}t(ps,"applyLrDirectionTransform");var an=0.000001,Br=8,Wn=Br,Fr=[0,Wn,-Wn,2*Wn,-2*Wn];function ms(n,e){let{nodeInfoById:o,realNodeRects:s}=le(e);for(let r of n){if(r.isLayoutOnly)continue;let i=r.points;if(!i||i.length<4)continue;let c=fo(yt(i,an),an);if(!c)continue;let{p3:u}=c,h=c.kind==="HVH",d=po(r,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,n,r,{epsilon:an,skipDegenerateOther:!0}),P=!R&&te(w,C,n,r,{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)r.points=x}}t(ms,"portSwapToLShape");function ys(n,e){let{realNodeRects:i,labelNodeRects:c}=bn(e.values());for(let u of n){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?e.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,i,O?[O]:[],-2))continue;if(Nt(Y,V,c,[],-2))continue;if(P){let q=e.get(P),ot=q?Zt(q):void 0;if(ot&&uo(Y,ot,2))continue}let J=t((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=t((q,ot)=>{for(let dt of n){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,i,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=e.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}}}}}t(ys,"collapseShortTerminalStub");var tt=0.001,Ht=8,xs=t((n)=>typeof n==="string"?n.toUpperCase():"","upperCaseDirection"),at=Bn,Ee=t((n,e)=>ht(n,e,tt)||pt(n,e,tt),"orthogonallyAligned");function ze(n,e){let r=t((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"),i=t((y,g)=>{let l=yt(y.points??[]);if(l.length<2)return;let x=g?y.start:y.end,L=x?e.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=r(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"),c=t((y,g)=>Math.max(0,Math.min(y.max,g.max)-Math.max(y.min,g.min)),"projectedOverlapLength"),u=t((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=t((y,g)=>{if(y.nodeId!==g.nodeId||y.orientation!==g.orientation)return!1;return c(y,g)>=Ht&&Math.abs(y.coord-g.coord)<0.5},"exactTerminalLaneConflict"),d=t((y,g)=>{if(y.nodeId!==g.nodeId||y.orientation!==g.orientation||y.orientation!=="H"||y.atStart===g.atStart)return!1;let l=c(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=t((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(!t(()=>{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=t((y)=>{let g=y.edge,l=yt(g.points??[]);if(l.length!==2)return!1;let{start:x,end:L}=g,S=x?e.get(x):void 0,E=L?e.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=n.filter((x)=>!x.isLayoutOnly).flatMap((x)=>[i(x,!0),i(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=i({...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}}t(ze,"separateSharedRenderedTerminalLanes");function bs(n,e){let{realNodeRects:r,labelNodeRects:i}=bn(e.values()),c=t((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,r,y,-2))return!1;if(Nt(g.a,g.b,i,[],-2))return!1}for(let g of n){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=t((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 n){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||!c(m,y))continue;m.points=y,d=!0;break}if(d)break}if(!d)return}}t(bs,"collapseRedundantRectangularDoglegs");function Ve(n,e){let{realNodeRects:i,labelNodeRects:c}=bn(e.values()),u=n.filter((g)=>!g.isLayoutOnly),h=t((g,l,x)=>yt(g===l?x??[]:g.points??[]),"pointsFor"),d=t((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=t((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=t((g,l)=>{let x=[g.start,g.end].filter((L)=>Boolean(L));return i.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=t((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=t((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,i,L,-2))return!1;if(Nt(E.a,E.b,c,[],-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}}t(Ve,"liftObstacleHuggingSameSideRails");function Ue(n,e,o){let r=t((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"),i=t((d)=>{if(!d.isGroup||d.parentId)return;let m=xs(d.direction??o);if(m==="LR"||m==="RL"||m==="BT")return;let p=r(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"),c=t((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=[...e.values()].map(i).filter((d)=>Boolean(d));if(u.length===0)return;let h=0;for(let d of n){if(d.isLayoutOnly)continue;let m=yt(d.points??[]);for(let p of at(m))for(let I of u){if(!c(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}}}t(Ue,"liftTopLaneTitleBandsAboveRails");function je(n,e,o){let r=t((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"),i=t((m)=>{if(!m.isGroup||m.parentId)return;if(xs(m.direction??o)!=="LR")return;let I=r(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"),c=t((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=t((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=[...e.values()].map(i).filter((m)=>Boolean(m));if(h.length===0)return;let d=0;for(let m of n){if(m.isLayoutOnly)continue;let p=yt(m.points??[]);for(let I of at(p))for(let y of h)if(c(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}}}t(je,"shiftLeftLaneTitleBandsLeftOfRails");function Ms(n,e){let{realNodeRects:r}=bn(e.values()),i=n.filter((l)=>!l.isLayoutOnly),c=t((l,x=new Map)=>yt(x.get(l)??l.points??[]),"replacementPointsFor"),u=t((l=new Map)=>{let x=0;for(let L=0;L<i.length;L++){let S=at(c(i[L],l));for(let E=L+1;E<i.length;E++){let w=at(c(i[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=t((l=new Map)=>i.reduce((x,L)=>x+nn(c(L,l)),0),"totalBends"),d=t((l)=>{let x=c(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=t((l,x)=>{let L=c(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=t((l,x)=>{let L=[l.start,l.end].filter((S)=>Boolean(S));for(let S of at(x))if(Nt(S.a,S.b,r,L,-2))return!0;return!1},"pathHasNodeHit"),I=t((l,x,L)=>{for(let S of i){if(S===l)continue;for(let E of at(x))for(let w of at(c(S,L)))if(fn(E,w,0.5)>=Ht)return!0}return!1},"pathHasSharedTrack"),y=t((l,x,L)=>!p(l,x)&&!I(l,x,L),"candidateIsSafe"),g=t(()=>{let l=new Map;for(let x of i){let L=x.end;if(!L||!e.has(L))continue;if(c(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}}t(Ms,"swapDestinationTerminalTailsToReduceCrossings");function Is(n,e){let{realNodeRects:c,labelNodeRects:u}=bn(e.values()),h=n.filter((C)=>!C.isLayoutOnly),d=t((C,b=new Map)=>yt(b.get(C)??C.points??[]),"replacementPointsFor"),m=t((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=t((C=new Map)=>h.reduce((b,R)=>b+nn(d(R,C)),0),"totalBends"),I=t((C)=>{let{start:b,end:R}=C,O=b?e.get(b):void 0,P=R?e.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=t((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=t(()=>{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=t((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=t((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=t((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=t((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=t(()=>{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=t((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=t((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,c,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=_}}t(Is,"reassignCrossingExternalRailChannels");function Ss(n,e){let{realNodeRects:r,labelNodeRects:i}=bn(e.values()),c=n.filter((g)=>!g.isLayoutOnly),u=t((g,l,x)=>yt(g===l?x??[]:g.points??[]),"pointsFor"),h=t((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=t((g,l)=>{let x=0;for(let L=0;L<c.length;L++){let S=at(u(c[L],g,l));for(let E=L+1;E<c.length;E++){let w=at(u(c[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=t((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=t((g)=>{let l=[g.start,g.end].filter((L)=>Boolean(L)),x=[];for(let L of l){let S=e.get(L),E=S?Zt(S):void 0;if(E)x.push(E)}return x},"endpointRectsFor"),I=t((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=t((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,r,L,-2))return!1;if(Nt(E.a,E.b,i,[],-2))return!1;if(S.some((w)=>m(E,w)))return!1}for(let E of c){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 c){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}}t(Ss,"shortcutRedundantOrthogonalJogs");function Cs(n,e){let c=[];for(let B of e.values()){if(B.isGroup||B.isEdgeLabel)continue;let D=B.x??0,X=B.y??0,W=Zt(B);if(!W)continue;c.push({id:String(B.id??""),cx:D,cy:X,rect:W})}if(c.length===0)return;let u=new Map(c.map((B)=>[B.id,B])),h=c.map((B)=>({id:B.id,rect:B.rect})),d=["top","bottom","left","right"],m={top:Math.min(...c.map((B)=>B.rect.top))-20,bottom:Math.max(...c.map((B)=>B.rect.bottom))+20,left:Math.min(...c.map((B)=>B.rect.left))-20,right:Math.max(...c.map((B)=>B.rect.right))+20},p=n.filter((B)=>!B.isLayoutOnly),I=new Map(p.map((B,D)=>[B,D])),y=t((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=t((B,D=new Map)=>yt(D.get(B)??B.points??[]),"replacementPointsFor"),l=t((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=t((B,D)=>l(at(B),at(D)),"crossingCountBetweenPaths"),L=t((B=new Map)=>{let D=0,X=[],W=new Set,f=[],M=t((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=t((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=t((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=t((B)=>[B.start,B.end].filter((D)=>Boolean(D)),"endpointIdsFor"),C=t((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=t((B,D,X)=>S(B,new Map([[D,X]])),"crossingCountWithSingleReplacement"),R=t((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=t((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=t((B=new Map)=>p.reduce((D,X)=>D+nn(g(X,B)),0),"totalBends"),N=t((B=new Map)=>p.reduce((D,X)=>D+O(g(X,B)),0),"totalLength"),H=t((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"),_=t((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=t((B,D)=>{let X=dn(yt(D));if(at(X).length===X.length-1)B.push(X)},"pushOrthogonalCandidate"),Y=t((B)=>B==="left"||B==="right","sideIsHorizontal"),V=t((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=t((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=t((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=t((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=t((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=t((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=t((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=t((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=t((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=t((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=t((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=t((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=t(()=>new Map(p.map((B)=>[B,at(g(B))])),"currentSegmentsByEdge"),jt=t((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=t((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=t((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=t((B,D)=>{for(let X of B.sharedTrackConflicts)if(X!==D)return!1;return!0},"conflictsOnlyWith"),Ln=t((B,D)=>B.segments.some((X)=>D.segments.some((W)=>fn(X,W,0.5)>=Ht)),"candidatesShareTrack"),gn=t((B,D,X,W)=>en(D,X.edge)&&en(W,B.edge)&&!Ln(D,W),"pairCandidatesAreCompatible"),En=t((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=t((B,D)=>B.crossings<D.crossings||B.crossings===D.crossings&&(B.bends<D.bends||B.bends===D.bends&&B.length<D.length),"pairScoreIsBetter"),ge=t((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=t((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}}t(Cs,"resolveRenderedOrthogonalCrossings");var xn=0.001,Pr=8;function vs(n,e){let{nodeInfoById:o,realNodeRects:s}=le(e),r=["top","bottom","left","right"],i=20,c={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=t((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,c[x]));return E},"buildOrthogonalPathCandidates"),h=t((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=t((l,x,L=!1)=>{let S=0,E=Bn(l,xn),{start:w,end:C}=x;for(let b of n){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=t((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=t((l,x,L)=>{let S=I.get(l)??[];S.push({side:x,edgeId:L}),I.set(l,S)},"addFaceClaim");for(let l of n){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=t((l,x,L)=>I.get(l)?.some((S)=>S.edgeId!==L&&S.side===x)??!1,"faceIsClaimed");for(let l of n){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 r){if(g(S,_,b))continue;let F=vn(w,_);for(let Y of r){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&&lt>=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)}}}t(vs,"simplifyDetouredEdges");var Jt=0.001,zo=10,Kn=7;function We(n,e){let o=e?0:n.length-1,s=e?1:-1,r=n[o],i=n[o+s];if(!r||!i)return;let c=i.x-r.x,u=i.y-r.y;if(Math.abs(c)+Math.abs(u)<Jt)return;if(Math.abs(u)<=Jt){let d=r.x+Math.sign(c)*zo;return{left:Math.min(r.x,d),right:Math.max(r.x,d),top:r.y-Kn,bottom:r.y+Kn}}if(Math.abs(c)<=Jt){let d=r.y+Math.sign(u)*zo;return{left:r.x-Kn,right:r.x+Kn,top:Math.min(r.y,d),bottom:Math.max(r.y,d)}}return{left:Math.min(r.x,i.x),right:Math.max(r.x,i.x),top:Math.min(r.y,i.y),bottom:Math.max(r.y,i.y)}}t(We,"markerClearanceRectFor");function Ls(n){return{left:Math.min(n.left,n.right),right:Math.max(n.left,n.right),top:Math.min(n.top,n.bottom),bottom:Math.max(n.top,n.bottom)}}t(Ls,"normalizeRect");function Ke(n,e){let o=yt(e),s=We(o,!0),r=We(o,!1);return[s,r].some((i)=>i&&Qn(n,Ls(i)))}t(Ke,"labelOverlapsOwnMarker");function Jn(n,e){let o=[];for(let g of n){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=[],r=[];for(let g of e.values()){let{isGroup:l,parentId:x}=g;if(l&&!x){let S=Zt(g);if(S)r.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 i=3,c=1,u=12,h=t((g,l)=>{let x=we(l,i);for(let{nodeId:L,rect:S}of s){if(L===g)continue;if(Qn(x,S))return!0}return!1},"labelOverlapsForeignNode"),d=t((g,l)=>{let x=we(l,i);for(let L of o){if(L.edgeId===g)continue;if(ae(L.p1,L.p2,x))return!0}return!1},"labelOverlapsForeignEdge"),m=t((g,l,x)=>h(g,x)||d(l,x),"labelOverlapsAnything"),p=[],I=t((g)=>{for(let{id:l,rect:x}of r)if(Qo(x,g))return l;return},"findContainingLane"),y=t((g,l)=>p.some((x)=>x.labelId!==g&&Qn(l,x.rect)),"overlapsPlacedLabel");for(let g of n){if(g.isLayoutOnly)continue;let l=g.labelNodeId;if(!l)continue;let x=e.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=t((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],_=t((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=t((nt,q,ot)=>Math.min(ot,Math.max(q,nt)),"clamp"),Y=t((nt,q)=>nt.midX>=q.left-Jt&&nt.midX<=q.right+Jt&&nt.midY>=q.top-Jt&&nt.midY<=q.bottom+Jt,"pointInsideRectInclusive"),V=t((nt)=>{let q=On(nt.midX,nt.midY,S,E),ot=I(q);if(ot)return{laneId:ot,anchor:nt,rect:q};let dt=r.find(({rect:en})=>Y(nt,en));if(!dt)return;let mt=dt.rect.left+S/2+c,Mt=dt.rect.right-S/2-c,Et=dt.rect.top+E/2+c,jt=dt.rect.bottom-E/2-c;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=t((nt,q,ot)=>nt.orientation==="horizontal"?Math.abs(q.midX-ot.x):Math.abs(q.midY-ot.y),"distanceAlongSegment"),lt=t((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=t((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=t((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})}}}t(Jn,"anchorLabelsToPolyline");var Ae=0.000001,kr=8,Vo=kr/2,_r=3;function qe(n,e){return n<e?`${n}::${e}`:`${e}::${n}`}t(qe,"pairKey");function Es(n,e){let{nodeInfoById:o,realNodeRects:s}=le(e),r=new Map;for(let c of e){let u=c.id;if(c.isGroup)continue;if(c.isEdgeLabel){r.set(u,{w:c.width??0,h:c.height??0});continue}}let i=t((c,u,h,d)=>{let m=qe(u,h),p=0,I=t((y)=>{if(!y)return;let g=r.get(y);if(!g)return;let l=d==="x"?g.w/2:g.h/2;if(l>p)p=l},"consider");I(c.labelNodeId);for(let y of n){if(y===c)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 c of n){if(c.isLayoutOnly)continue;let u=c.points;if(!fo(u,Ae))continue;let h=po(c,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=i(c,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,n,c,{epsilon:Ae}))continue;c.points=[b,R];break}}}t(Es,"straightenCollinearSiblingDetours");function Je(n,e){let{realNodeRects:d,labelNodeRects:m}=bn(e.values()),p=t((b,R)=>Bn(R,0.001).map((O)=>({...O,edge:b,interior:O.index>=1&&O.index<=R.length-3})),"segmentsFor"),I=t(()=>{let b=[];for(let R of n){if(R.isLayoutOnly)continue;let O=R.points;if(!O||O.length<2)continue;b.push(...p(R,yt(O)))}return b},"allSegments"),y=t((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=t((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 n){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=t((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=t((b,R)=>({x:b.x??(R.left+R.right)/2,y:b.y??(R.top+R.bottom)/2}),"nodeCenter"),L=t((b)=>{let R=b.edge,O=yt(R.points??[]);if(O.length!==4||b.index!==1)return;let P=R.start?e.get(R.start):void 0,N=R.end?e.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=t((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=t((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=t((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}}t(Je,"nudgeSharedInteriorSubpaths");function As(n,e,o,s){let r=e.x-n.x,i=e.y-n.y,c=s.x-o.x,u=s.y-o.y,h=r*u-i*c;if(Math.abs(h)<0.0000000001)return!1;let d=o.x-n.x,m=o.y-n.y,p=(d*u-m*c)/h,I=(d*i-m*r)/h,y=0.01;return p>y&&p<1-y&&I>y&&I<1-y}t(As,"segmentsIntersect");function Rs(n){let e=n.nodes??[],o=n.edges??[],s=[];if(!o.length||!e.length)return s;let r=ts(e),i=1,c=[];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 r){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,-i)){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++)c.push({edgeId:y,start:m,end:p,p1:d[g],p2:d[g+1]})}let u=new Set;for(let h=0;h<c.length;h++)for(let d=h+1;d<c.length;d++){let m=c[h],p=c[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;a.warn(`[SWIMLANE_VALIDATE] ${s.length} issue(s) detected: ${h} edge-node overlap(s), ${d} edge crossing(s)`);for(let m of s)a.warn(`[SWIMLANE_VALIDATE] ${m.type}: ${m.detail}`)}return s}t(Rs,"validateSwimlanesLayout");function Ts(n,e){let o=n.nodes??[],s=n.edges??[],r=o.filter((u)=>!u.isGroup);if((e==="LR"||e==="RL")&&r.length>0&&!ps(n,e))return;if(e==="BT"&&r.length>0&&!gs(n))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 i=new Map;for(let u of o)i.set(String(u.id),u);Jn(s,i),rs(s,i),ys(s,i),Je(s,i),ze(s,i),bs(s,i),Ve(s,i),Ms(s,i);let c=t(()=>{Cs(s,i),ze(s,i),Is(s,i),Ss(s,i),Jn(s,i),Ge(s,i),Ve(s,i),Jn(s,i),Ge(s,i)},"finalizeRenderedEdges");c(),Je(s,i),c(),Ue(s,i,e),je(s,i,e),Ue(s,i,e),je(s,i,e)}t(Ts,"postProcessSwimlaneLayout");function Mn(n){let e=new Map(n.nodeById),o=new Set,s=[];for(let i of n.edges){if(!e.has(i.src)||!e.has(i.dst))continue;let c=`${i.id}:${i.src}->${i.dst}`;if(o.has(c))continue;o.add(c),s.push(i)}return{nodes:[...e.keys()],edges:s,layout:n.layout,nodeById:e}}t(Mn,"normalizeGraph");function Io(n,e){return n.edges.filter((o)=>o.dst===e)}t(Io,"incoming");function ws(n){let e=new Map;for(let o of n.nodes)e.set(o,[]);for(let o of n.edges)e.get(o.src).push(o.dst);return e}t(ws,"buildSuccessorMap");function So(n){let e=ws(n);for(let o of e.values())o.sort((s,r)=>s.localeCompare(r));return e}t(So,"buildSortedSuccessorMap");function fe(n){let e=new Map;for(let o of n.nodes)e.set(o,0);for(let o of n.edges)e.set(o.dst,(e.get(o.dst)??0)+1);return e}t(fe,"buildInDegreeMap");function Co(n,e){let o=[...e.entries()].filter(([,u])=>u===0).map(([u])=>u).sort((u,h)=>u.localeCompare(h)),s=new Set(n.edges.flatMap((u)=>[u.src,u.dst])),r=t((u)=>!s.has(u)&&!n.nodeById.get(u)?.isGroup,"isUnconnected"),i=[...e.keys()].filter((u)=>e.get(u)===0&&r(u)),c=0;return o.map((u)=>r(u)?i[c++]:u)}t(Co,"sortedZeroInDegreeNodes");function de(n,e=()=>!0){let o=new Map,s=new Map;for(let r of n.nodes)o.set(r,[]),s.set(r,[]);for(let r of n.edges){if(!e(r))continue;s.get(r.src).push(r.dst),o.get(r.dst).push(r.src)}return{preds:o,succs:s}}t(de,"buildPredecessorSuccessorMaps");function vo(n,e,o,s){let r=0;for(let c of n.nodes){if(s?.skipGroups&&n.nodeById.get(c)?.isGroup)continue;r=Math.max(r,o[c]??0)}let i=Array.from({length:r+1},()=>[]);for(let c of e){if(s?.skipGroups&&n.nodeById.get(c)?.isGroup)continue;i[Math.max(0,o[c]??0)].push(c)}return i}t(vo,"buildLayersFromRanks");function _n(n){let e=fe(n),o=Co(n,e),s=[],r=So(n);while(o.length){let i=o.shift();s.push(i);for(let c of r.get(i)??[])if(e.set(c,(e.get(c)??0)-1),(e.get(c)??0)===0){let u=0;while(u<o.length&&o[u]<c)u++;o.splice(u,0,c)}}return s.length===n.nodes.length?s:null}t(_n,"topoSortIfAcyclic");function Fn(n){let e=new Map,o=0;for(let s of n)e.set(s,o),o++;return e}t(Fn,"buildLayerIndex");function Lo(n){let e=Array(n.length),o=t((s,r)=>{if(r-s<=1)return 0;let i=s+r>>1,c=o(s,i)+o(i,r),u=s,h=i,d=s;while(u<i||h<r)if(h>=r||u<i&&n[u]<=n[h])e[d++]=n[u++];else e[d++]=n[h++],c+=i-u;for(let m=s;m<r;m++)n[m]=e[m];return c},"count");return o(0,n.length)}t(Lo,"countInversions");function Ns(n){let e=Mn(n),o=new Map;for(let p of e.nodes)o.set(p,[]);for(let p of e.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 e.nodes)s[p]=0;let r=[],i=t((p)=>{s[p]=1;for(let I of o.get(p)??[]){let y=I.dst;if(s[y]===0)i(y);else if(s[y]===1)r.push(I)}s[p]=2},"dfs"),c=fe(e),u=[...e.nodes.filter((p)=>(c.get(p)??0)===0),...e.nodes.filter((p)=>(c.get(p)??0)!==0)];for(let p of u)if(s[p]===0)i(p);let h=new Set(r.map((p)=>`${p.id}:${p.src}->${p.dst}`)),d=e.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:[...e.nodes],edges:d,layout:e.layout,nodeById:new Map(e.nodeById)},reversed:r}}t(Ns,"removeCycles_DFS");function Os(n){let e=new Map,o=t((s)=>{if(e.has(s))return e.get(s);let r=n.nodeById.get(s);if(!r)return e.set(s,null),null;let i=r.parentId;if(!i)return e.set(s,null),null;let u=o(i)??i;return e.set(s,u),u},"resolve");for(let s of n.nodes)o(s);return e}t(Os,"buildTopLaneMap");function hn(n){let e=Os(n);return(o)=>e.get(o)??null}t(hn,"createTopLaneResolver");function ue(n){let e=[];for(let o of n.layout.nodes??[])if(o.isGroup&&!o.parentId)e.push(o.id);return[...new Set(e)].reverse()}t(ue,"buildTopLaneOrder");function Eo(n,e){let o=ue(n);if(!e||e.length===0)return o;let s=new Set(o),r=new Set,i=[];for(let c of e){if(!s.has(c)||r.has(c))continue;r.add(c),i.push(c)}for(let c of o){if(r.has(c))continue;i.push(c)}return i}t(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(n,e){let o=Mn(n),s=e?.laneOf??(()=>null),r=e?.rankHint,{preds:i}=de(o);for(let C of i.values())C.sort((b,R)=>b.localeCompare(R));let c=_n(o)??[...o.nodes].sort((C,b)=>C.localeCompare(b)),u=new Map;for(let[C,b]of c.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 c){let b=(i.get(C)??[]).filter((R)=>h.has(R));if(b.length>0){let R=Fs(C,b,{laneOf:s,rankHint:r,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=t((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 c)w(C);return{parent:h,children:d,roots:p,componentOf:g,blocks:l,nodeBlocks:x,adjacency:y,preorder:L,postorder:S,topologicalOrder:c}}t(Bs,"buildDrivingTree");function Fs(n,e,o){let s=o.laneOf(n);return[...e].sort((i,c)=>{let u=o.laneOf(i),h=o.laneOf(c),d=u!=null&&u===s,m=h!=null&&h===s;if(d!==m)return d?-1:1;let p=o.rankHint?.[i],I=o.rankHint?.[c];if(p!=null&&I!=null&&p!==I)return I-p;let y=o.topoIndex.get(i)??0,g=o.topoIndex.get(c)??0;if(y!==g)return y-g;return i.localeCompare(c)})[0]}t(Fs,"chooseParent");function Ps(n){let e=new Map;for(let o of n.nodes)e.set(o,new Set);for(let o of n.edges)e.get(o.src).add(o.dst),e.get(o.dst).add(o.src);return e}t(Ps,"buildAdjacency");function ks(n){let e=new Map,o=0;for(let s of n.keys()){if(e.has(s))continue;let r=[s];while(r.length>0){let i=r.pop();if(e.has(i))continue;e.set(i,o);for(let c of n.get(i)??[])if(!e.has(c))r.push(c)}o++}return e}t(ks,"assignComponents");function _s(n){let e=new Map,o=new Map,s=[],r=[],i=0,c=t((u,h)=>{e.set(u,++i),o.set(u,i);for(let d of n.get(u)??[]){if(d===h)continue;if(!e.has(d)){if(s.push([u,d]),c(d,u),o.set(u,Math.min(o.get(u)??i,o.get(d)??i)),(o.get(d)??0)>=(e.get(u)??0))r.push(Hs(u,d,s,r.length))}else if((e.get(d)??0)<(e.get(u)??0))s.push([u,d]),o.set(u,Math.min(o.get(u)??i,e.get(d)??i))}},"visit");for(let u of n.keys())if(!e.has(u))c(u,null);return r}t(_s,"computeBlocks");function Hs(n,e,o,s){let r=[],i=new Set;while(o.length>0){let c=o.pop();if(r.push(c),i.add(c[0]),i.add(c[1]),c[0]===n&&c[1]===e||c[0]===e&&c[1]===n)break}return{id:s,edges:r,nodes:[...i]}}t(Hs,"popBlock");function Ds(n,e,o){let s=[...n.nodes],r=new Map;for(let[S,E]of s.entries())r.set(E,S);let i=s.length,c=Array(i).fill(-1),u=Array(i).fill(0),h=[],d=new Set;for(let S of s){let E=o.parent.get(S)??null,w=r.get(S);if(w==null)continue;if(E==null){if(c[w]=-1,u[w]=0,!d.has(S))d.add(S),h.push(S)}}while(h.length>0){let S=h.shift(),E=r.get(S);if(E==null)continue;let w=o.children.get(S)??[];for(let C of w){if(d.has(C))continue;let b=r.get(C);if(b==null)continue;c[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=r.get(S);if(E==null)continue;c[E]=-1,u[E]=0,d.add(S)}let m=Math.max(1,Math.ceil(Math.log2(Math.max(1,i)))+1),p=Array.from({length:m},()=>Array(i).fill(-1));for(let S=0;S<i;S++)p[0][S]=c[S];for(let S=1;S<m;S++)for(let E=0;E<i;E++){let w=p[S-1][E];p[S][E]=w===-1?-1:p[S-1][w]}let I=t((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:i},()=>new Map);for(let S of n.edges){let{src:E,dst:w}=S,C=e[E],b=e[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=r.get(E),O=r.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=t((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=t((S)=>{let E=r.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=e[S];if(P!=null){let N=g.get(S);if(!N)N=new Map,g.set(S,N);let H=O.get(P)??0,_=e[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}t(Ds,"computeSubtreeCrossCounts");function Xs(n,e,o){let s=new Map,r=t((i)=>{let c=o[i]??0,u=[...e.get(i)??[]];u.sort(Ao(o));for(let h of u){r(h);let d=s.get(h);if(d!=null)c=Math.min(c,d)}s.set(i,c)},"annotate");for(let i of n)r(i);return s}t(Xs,"annotateMinimumLayers");function Ao(n){return(e,o)=>{let s=n[e]??0,r=n[o]??0;return s===r?e.localeCompare(o):s-r}}t(Ao,"compareByRankThenId");function Ys(n,e,o,s){let r=0;for(let h of e){let d=o[h]??0;if(d>r)r=d}let i=Array.from({length:r+1},()=>[]),c=new Set,u=t((h)=>{if(c.has(h))return;c.add(h);let d=o[h]??0;if(!i[d])i[d]=[];i[d].push(h);for(let m of s(h))u(m)},"emit");for(let h of n)u(h);for(let h of e)if(!c.has(h)){let d=o[h]??0;if(!i[d])i[d]=[];i[d].push(h),c.add(h)}return i}t(Ys,"emitNodesInTreeOrder");function Gs(n){let e=[];for(let o of n){let s=new Set,r=[];for(let i of o){if(s.has(i))continue;s.add(i),r.push(i)}e.push(r)}return e}t(Gs,"deduplicateLayers");function $s(n,e,o,s){return(r)=>{let i=n.get(r)??[];if(i.length===0)return[];let c=e[r]??0,u=[],h=[],d=o.get(r);for(let m of i){let p=s.get(m)??c;if(p>c)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)??c,l=s.get(p)??c;if(g!==l)return g-l;return m.localeCompare(p)}),[...u.map((m)=>m.child),...h]}}t($s,"createChildOrderer");function ce(n,e,o){let s=Bs(n,{rankHint:e,laneOf:o}),{children:r,roots:i}=s;for(let p of n.nodes)if(!r.has(p))r.set(p,[]);let c=Ds(n,e,s),u=[...i].sort(Ao(e)),h=Xs(u,r,e),d=$s(r,e,c,h),m=Ys(u,n.nodes,e,d);return m=Gs(m),m}t(ce,"buildMultitreeLayerOrder");function zs(n,e,o){let s=new Set(n),r=new Set(e),i=Fn(e),c=[];for(let u of o)if(s.has(u.src)&&r.has(u.dst))c.push(i.get(u.dst));return Lo(c)}t(zs,"countCrossingsBetweenAdjacent");function Ze(n,e,o){let s=[];for(let i of e){let c=o[i.src],u=o[i.dst];if(c==null||u==null||c===u)continue;let{src:h,dst:d}=i,m=c,p=u;if(c>u)h=i.dst,d=i.src,m=u,p=c;for(let I=m;I<p;I++)s.push({id:`${i.id}@${I}`,src:h,dst:d,ref:i.ref})}let r=0;for(let i=0;i+1<n.length;i++)r+=zs(n[i],n[i+1],s);return r}t(Ze,"totalCrossings");function Vs(n,e){let o={...e},{preds:s}=de(n),r=hn(n),i=ce(n,o,r),c=Ze(i,n.edges,o),u=ie.MAX_CROSSING_OPTIMIZATION_PASSES;for(let h=0;h<u;h++){let d=!1,m=[...n.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(n,o,r),x=Ze(l,n.edges,o);if(x<c)c=x,d=!0;else o[p]=g}if(!d)break}return o}t(Vs,"optimizeRanksByCrossings");function Us(n,e){let o=hn(n),s=[...n.nodes].sort((r,i)=>(e[r]??0)-(e[i]??0)||r.localeCompare(i));for(let r of s){let i=o(r);if(!i)continue;let c=n.edges.filter((l)=>l.src===r);if(c.length===0)continue;let u=!1,h=0;for(let l of c){let x=o(l.dst);if(x==null||x===i)u=!0;else h++}if(h===0||u)continue;let d=0,m=!1;for(let l of n.edges){if(l.dst!==r)continue;let x=o(l.src);if(!x)continue;if(x===i)m=!0;else d++}if(d>0||!m)continue;let p=e[r]??0,I=p+h,y=0;for(let l of n.edges)if(l.dst===r)y=Math.max(y,(e[l.src]??0)+1);let g=Math.max(p,y,I);if(g!==p)e[r]=g}}t(Us,"adjustCrossLaneSources");function js(n,e){let o=Mn(n),s=_n(o)??[...o.nodes].sort(),r=e?.compactSingleInput??!1,i=hn(o),c=Object.create(null);for(let h of s){let d=Io(o,h),m=e?.ignoreCrossLaneEdges?d.filter((p)=>{let I=i(p.src),y=i(h);if(!I||!y)return!0;return I===y}):d;if(m.length===0)c[h]=0;else if(r&&m.length===1){let p=m[0].src,I=i(p),y=i(h);if(I!==y)c[h]=c[p]??0;else c[h]=(c[p]??0)+1}else{let p=-1/0;for(let I of m)p=Math.max(p,(c[I.src]??0)+1);c[h]=p===-1/0?0:p}}if(e?.optimizeRanksByCrossings??!1)c=Vs(o,c);if(e?.ignoreCrossLaneEdges)Us(o,c);return{layers:ce(o,c,i),rankOf:c,dummy:new Set}}t(js,"assignLayers_LongestPath");function Ws(n,e){let o=Mn(n),r={...js(o,{compactSingleInput:e?.compactSingleInput,ignoreCrossLaneEdges:e?.ignoreCrossLaneEdges,optimizeRanksByCrossings:e?.optimizeRanksByCrossings}).rankOf},i=hn(o),{preds:c,succs:u}=de(o,(g)=>{if(e?.ignoreCrossLaneEdges){let l=i(g.src),x=i(g.dst);if(l&&x&&l!==x)return!1}return!0}),h=_n(o)??[...o.nodes],d=[...h].reverse(),m=t((g,l)=>{let x=0;for(let E of c.get(g)??[])x=Math.max(x,(r[E]??0)+1);let L=Number.POSITIVE_INFINITY,S=u.get(g)??[];if(S.length>0)L=Math.min(...S.map((E)=>(r[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=t((g)=>{let l=!1;for(let x of g){let L=c.get(x)??[],S=u.get(x)??[];if(L.length===0&&S.length===0)continue;let E=L.length>0?L.reduce((R,O)=>R+(r[O]??0)+1,0)/L.length:r[x]??0,w=S.length>0?S.reduce((R,O)=>R+(r[O]??0)-1,0)/S.length:r[x]??0,C=Math.round((E+w)/2),b=m(x,C);if(b!==r[x])r[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 c.get(g)??[])l=Math.max(l,(r[x]??0)+1);if((r[g]??0)<l)r[g]=l}for(let g of d){let l=u.get(g)??[];if(l.length>0){let x=Math.min(...l.map((L)=>(r[L]??0)-1));if((r[g]??0)>x)r[g]=x}}return{layers:vo(o,h,r),rankOf:r,dummy:new Set}}t(Ws,"assignLayers_Gravity");function Ks(n){let e=fe(n),o=So(n),s=Co(n,e),r=[];while(s.length>0){let i=[];for(let c of s){r.push(c);for(let u of o.get(c)??[])if(e.set(u,(e.get(u)??0)-1),(e.get(u)??0)===0)i.push(u)}s=i.sort((c,u)=>c.localeCompare(u))}return r.length===n.nodes.length?r:null}t(Ks,"topoSortByGenerationIfAcyclic");function qs(n,e){let o=Mn(n),s=e?.direction==="LR"?Ks(o)??[...o.nodes].sort():_n(o)??[...o.nodes].sort(),r=hn(o),i=t((m)=>r(m)??m,"laneOf"),c=Object.create(null),u=new Map,h=t((m,p)=>{if(e?.ignoreCrossLaneEdges??!0)return i(m)===i(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=c[S]??0;y=Math.max(y,E+h(S,m))}let g=i(m),l=u.get(g)??0,x=Math.max(y,l);c[m]=x,u.set(g,x+1)}return{layers:vo(o,s,c,{skipGroups:!0}),rankOf:c,dummy:new Set}}t(qs,"assignLayers_LaneAwareCompact");function Js(n,e){let o=Mn(e),{rankOf:s}=n,r=n.layers.map((y)=>[...y]),i=new Set(n.dummy?[...n.dummy]:[]),c=0,u=new Map(o.nodeById),h=t((y)=>{let g=`placeholder-${c++}`,l={id:g,isGroup:!1,isDummy:!0,width:0,height:0};u.set(g,l),i.add(g);while(r.length<=y)r.push([]);return r[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,...[...i].filter((y)=>!o.nodes.includes(y))],edges:m,layout:o.layout,nodeById:u};return{layering:{layers:r,rankOf:s,dummy:i},graphWithDummies:I}}t(Js,"makeProperLayering");function Qe(n){let e=n.length;if(e===0)return Number.POSITIVE_INFINITY;let o=[...n].sort((s,r)=>s-r);if(e%2===1)return o[(e-1)/2];return 0.5*(o[e/2-1]+o[e/2])}t(Qe,"median");function to(n){if(n.length===0)return Number.POSITIVE_INFINITY;return n.reduce((o,s)=>o+s,0)/n.length}t(to,"barycenter");function Zs(n,e,o,s){let r=new Map;for(let i of n)r.set(i,[]);for(let i of o)if(s==="down"){if(e.has(i.src)&&r.has(i.dst))r.get(i.dst).push(e.get(i.src))}else if(e.has(i.dst)&&r.has(i.src))r.get(i.src).push(e.get(i.dst));return r}t(Zs,"neighborPositionsFor");function Qs(n,e,o){let s=o.get(n)??0,r=o.get(e)??0;return s!==r?s-r:n.localeCompare(e)}t(Qs,"currentOrderTieBreak");function no(n,e,o){let s=new Set(n),r=new Set(e),i=Fn(n),c=Fn(e),u=[];for(let d of o)if(s.has(d.src)&&r.has(d.dst))u.push({u:i.get(d.src),v:c.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)}t(no,"countCrossingsBetweenAdjacent");function Zn(n,e,o){return[...n].sort((s,r)=>{let i=Qe(e.get(s)??[]),c=Qe(e.get(r)??[]);if(i===c)return Qs(s,r,o);if(!isFinite(i))return 1;if(!isFinite(c))return-1;return i-c})}t(Zn,"sortByHeuristic");function eo(n,e,o,s,r,i){let c=Fn(n),u=Fn(e),h=Zs(e,c,o,s);if(!r||!i||i.length===0)return Zn(e,h,u);let d=new Map;for(let I of e){let y=r(I),g=d.get(y)??[];g.push(I),d.set(y,g)}let m=[];for(let I of i){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}t(eo,"reorderLayer");function oo(n,e,o,s,r){let i=[...e],c=new Set(n),u=new Set(e),h=s?new Set(s):null,d=o.filter((l)=>c.has(l.src)&&u.has(l.dst)),m=h?o.filter((l)=>u.has(l.src)&&h.has(l.dst)):void 0,p=t((l)=>{let x=no(n,l,d);if(m&&s)x+=no(l,s,m);return x},"crossingScore"),I=r?new Map:null;if(r&&I)for(let l of e)I.set(l,r(l));let y=!0,g=p(i);while(y){y=!1;for(let l=0;l+1<i.length;l++){if(I){let S=I.get(i[l]),E=I.get(i[l+1]);if(S!==E)continue}let x=g;[i[l],i[l+1]]=[i[l+1],i[l]];let L=p(i);if(L<x)g=L,y=!0;else[i[l],i[l+1]]=[i[l+1],i[l]]}}return i}t(oo,"transposeImprove");function tr(n,e,o){let s=n.layers.map((u)=>[...u]),r=e.edges,i=hn(e),c=Eo(e,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],r,"down",i,c),s[h]=oo(s[h-1],s[h],r,s[h+1],i);for(let h=s.length-2;h>=0;h--)s[h]=eo(s[h+1],s[h],r,"up",i,c),s[h]=oo(s[h+1],s[h],r,s[h-1],i)}return{layers:s}}t(tr,"orderLayers");function nr(n,e,o){let s=o?.layerGap??Uo.DEFAULT_LAYER_GAP,r=o?.nodeGap??Uo.DEFAULT_NODE_GAP,i=o?.laneGap??r*2,c=o?.direction??"TB",u=c==="LR"||c==="RL",h=n.layers,d=Object.create(null),m=Object.create(null),p=t((N)=>e.nodeById.get(N),"getNode"),I=t((N)=>p(N)?.width??0,"getWidth"),y=t((N)=>p(N)?.height??0,"getHeight"),g=hn(e),l=Eo(e,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)+r*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)+r*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)+i*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)_+=i}}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)+r*(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+r}}}let Y=L[N]??0;O+=_+s+Y}let P=new Map;for(let N of e.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(e.nodeById.get(J)?.isDummy)d[J]=Y}}return{x:d,y:m}}t(nr,"assignCoordinates");var er=8;function or(n){let e=2166136261;for(let o=0;o<n.length;o++)e^=n.charCodeAt(o),e=Math.imul(e,16777619);return e>>>0}t(or,"hashString");function sr(n){let e=n>>>0;return()=>{e+=1831565813;let o=e;return o=Math.imul(o^o>>>15,o|1),o^=o+Math.imul(o^o>>>7,o|61),((o^o>>>14)>>>0)/4294967296}}t(sr,"mulberry32");function rr(n,e){let o=[...n],s=sr(e);for(let r=o.length-1;r>0;r--){let i=Math.floor(s()*(r+1));[o[r],o[i]]=[o[i],o[r]]}return o}t(rr,"deterministicShuffle");function ir(n,e){let o=0;for(let[s,r]of n.entries())o+=Math.abs(s-(e.get(r)??s));return o}t(ir,"sourceDistance");function so(n,e){let o=new Map;for(let[r,i]of n.entries())o.set(i,r);let s=0;for(let{a:r,b:i,weight:c}of e){let u=o.get(r),h=o.get(i);if(u==null||h==null)continue;s+=c*Math.abs(u-h)}return s}t(so,"laneArrangementCost");function cr(n){let e=ue(n);if(e.length<2)return[];let o=new Map(e.map((i,c)=>[i,c])),s=hn(n),r=new Map;for(let i of n.layout.edges??[]){if(i.isLayoutOnly)continue;let c=typeof i.start==="string"?i.start:void 0,u=typeof i.end==="string"?i.end:void 0;if(!c||!u||!n.nodeById.has(c)||!n.nodeById.has(u))continue;let h=s(c),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=r.get(g);if(l)l.weight++;else r.set(g,{a:I,b:y,weight:1})}return[...r.values()]}t(cr,"buildWeightedLaneEdges");function ro(n,e,o){let s=[...n],r=so(s,e),i=!0,c=0,u=Math.max(1,s.length);while(i&&c<u){i=!1,c++;for(let h=0;h+1<s.length;h++){[s[h],s[h+1]]=[s[h+1],s[h]];let d=so(s,e);if(d<r)r=d,i=!0;else[s[h],s[h+1]]=[s[h+1],s[h]]}}return{order:s,cost:r,sourceDistance:ir(s,o)}}t(ro,"greedySwitch");function ar(n,e){if(n.cost!==e.cost)return n.cost<e.cost;return n.sourceDistance<e.sourceDistance}t(ar,"isBetterCandidate");function fr(n,e,o){let s=[...e].sort((r,i)=>r.a===i.a?r.b.localeCompare(i.b):r.a.localeCompare(i.a)).map(({a:r,b:i,weight:c})=>`${r}:${i}:${c}`).join("|");return or(`${n.join("|")}#${s}#${o}`)}t(fr,"seedForRestart");function dr(n,e={}){let o=ue(n);if(o.length<2)return o;let s=cr(n);if(s.length===0)return o;let r=new Map(o.map((u,h)=>[u,h])),i=ro(o,s,r),c=Math.max(0,e.restarts??er);for(let u=0;u<c;u++){let h=fr(o,s,u),d=rr(o,h),m=ro(d,s,r);if(ar(m,i))i=m}return i.order}t(dr,"optimizeTopLaneOrder");function ur(n,e){let o=e?.ignoreCrossLaneEdges??!0,s=e?.optimizeRanksByCrossings??!0,r=Mn(n),i=e?.automaticLaneOrdering?dr(r,{restarts:er}):void 0,c=Ns(r),u=c.acyclic,h=o?qs(u,{compactSingleInput:e?.compactSingleInput??ie.DEFAULT_COMPACT_SINGLE_INPUT,ignoreCrossLaneEdges:!0,direction:e?.direction}):Ws(u,{compactSingleInput:e?.compactSingleInput??ie.DEFAULT_COMPACT_SINGLE_INPUT,ignoreCrossLaneEdges:!1,optimizeRanksByCrossings:s}),{layering:d,graphWithDummies:m}=Js(h,u),p=tr(d,m,{laneOrder:i}),I=nr(p,m,{layerGap:e?.layerGap,nodeGap:e?.nodeGap,direction:e?.direction,laneOrder:i});return{acyclic:u,reversed:c.reversed,layering:d,ordered:p,coordinates:I}}t(ur,"sugiyamaLayout");var ft=Hr.EPSILON,Dr=8,Sn=15,Nn=15,qn=25,sn=20,Re=10;function io(n,e,o){let s=n.x??0,r=n.y??0,i=e.x-s,c=e.y-r,u=Math.abs(i),h=Math.abs(c);if(u<ft&&h<ft)return o;let d=3;if(h>ft&&h*d>=u)return c>0?"bottom":"top";if(u>ft)return i>0?"right":"left";return o}t(io,"chooseOrthogonalSide");function co(n,e){return Math.abs(n.to-e.from)<ft||Math.abs(n.to-e.to)<ft?n.to:n.from}t(co,"sharedLineEndpointCoord");function Cn(n,e){return n.orient==="vertical"?{x:n.coord,y:e}:{x:e,y:n.coord}}t(Cn,"pointOnLine");function hr(n,e){let o=n.nodes??[],s=n.edges??[],r=[];for(let f of s){if(f.isLayoutOnly)continue;r.push({...f,__originalEdge:f})}let i=new Map,c=new Map,u=[],h=e==="LR";for(let f of o)i.set(f.id,f);let d=o.filter((f)=>f.isGroup&&!f.parentId);for(let f of d){let M={id:f.id},v=t((A)=>{c.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=t((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=t((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=t((f,M,v)=>I(f,io(f,M,v?"bottom":"top")),"getOrthogonalPort"),g=[],l=[],x=new Set,L=1000,S=t((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=r.map((f,M)=>{if(!f.start||!f.end)return{idx:M,crossLane:0,dx:0,dy:0};let v=i.get(f.start),A=i.get(f.end),T=c.get(f.start),k=c.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=t((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 r){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=t((f,M)=>io(f,M,"bottom"),"determineSide"),O=new Map;for(let[f,M]of r.entries()){if(!M.start||!M.end||M.start===M.end)continue;if(M.points&&M.points.length>0)continue;let v=i.get(M.start),A=i.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=t((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=t((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=t((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=t((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(i.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=i.get(v),Q=i.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=i.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=t((f)=>Boolean(r[f]?.labelNodeId),"edgeHasLabelNode"),Ot=t((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=t((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=t((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=r[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=i.get(M.start),A=i.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=t((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=t((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=t((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=t((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=t((_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=t((_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=t((f,M)=>f.from<M.to&&M.from<f.to,"segmentsOverlap"),ot=t((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=t((f)=>{let M=f.tracks.length;return f.tracks[M]={index:M,coord:f.coord,segments:[]},M},"createNewTrack"),mt=t((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=t((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=t((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=t((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=t((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=t((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=t((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=t((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=t((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=t(()=>{let f=0,M=new Map;for(let[A,T]of r.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=t((A)=>{let T=r[A];if(!T.start||!T.end)return 0;let k=i.get(T.start),K=i.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=t(()=>{let f=0,M=new Map;for(let[v,A]of r.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=t((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=t(()=>{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=t((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 r.entries()){let v=l[f]??[];if(v.length===0)continue;let A=[],T=i.get(M.start),k=i.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 r){let M=f.__originalEdge;if(M&&f.points)M.points=f.points}n.edges=(n.edges??[]).filter((f)=>!f.isLayoutOnly);let W=t((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 n.edges){let M=f.points;if(!M||M.length<2)continue;let{start:v,end:A}=f,T=v?i.get(v):void 0,k=A?i.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 n}t(hr,"routeEdgesOrthogonal");function gr(n){return n.direction??"TB"}t(gr,"getSwimlaneDirection");function pr(n){let e=qo(n),o=n.config.flowchart?.nodeSpacing??40,s=n.config.flowchart?.rankSpacing??100,r=n.config.swimlane?.ignoreCrossLaneEdges??!0,i=n.config.swimlane?.optimizeRanksByCrossings??!0,c=n.config.swimlane?.automaticLaneOrdering??!1,u=gr(n),{ordered:h,coordinates:d}=ur(e,{nodeGap:o,layerGap:s,ignoreCrossLaneEdges:r,optimizeRanksByCrossings:i,automaticLaneOrdering:c,direction:u});Jo(e,h,d,{nodeGap:o,layerGap:s});for(let m of n.edges??[])delete m.points;hr(n,u);for(let m of n.edges??[])if(!m.curve||m.curve==="basis")m.curve="rounded";return Ts(n,u),Rs(n),u}t(pr,"runSwimlaneLayoutCore");function mr(n){Ko(n);let e=Zo(n);n.nodes=e.nodes,n.edges=e.edges}t(mr,"prepareSwimlaneLayout");var oi=lr({prepareLayout:mr,runLayoutCore:pr,afterPaint:jo});export{oi as render};
1
+ import{t,a,Ne}from"./chunk-tfqarvdx.js";import"./chunk-88wd49xe.js";import{lr}from"./chunk-rxvm70w5.js";var Un=5,zn=0.00001,Rr=2,Tr=0.6,Vn=0.000001;function jn(n){let e=[];for(let o=0;o<n.length-1;o++)e.push({a:n[o],b:n[o+1]});return e}t(jn,"buildSegmentList");function Bo(n,e,o,s){let r=e.x-n.x,i=e.y-n.y,c=s.x-o.x,u=s.y-o.y,h=r*u-i*c;if(h===0)return null;let d=o.x-n.x,m=o.y-n.y,p=(d*u-m*c)/h,I=(d*i-m*r)/h;if(p<=Vn||p>=1-Vn||I<=Vn||I>=1-Vn)return null;return{point:{x:n.x+p*r,y:n.y+p*i},tA:p,tB:I}}t(Bo,"segmentIntersection");function Se(n){return Math.abs(n.b.x-n.a.x)>=Math.abs(n.b.y-n.a.y)}t(Se,"isHorizontalSeg");function Ce(n,e,o){if(n.curve!=="rounded")return!1;let s=n.points,r=s[e],i=s[e+1];if(!r||!i)return!1;let c=Math.hypot(i.x-r.x,i.y-r.y),u=o*c,h=e>0?Pn(s[e-1],r,i,Un):null;if(h&&u<h.cutLen)return!0;let d=e+2<s.length?Pn(r,i,s[e+2],Un):null;return d!==null&&c-u<d.cutLen}t(Ce,"crossingSitsInRoundedCorner");function Fo(n){let e=[];for(let o=0;o<n.length;o++){let s=n[o],r=jn(s.points);for(let i=o+1;i<n.length;i++){let c=n[i],u=jn(c.points);for(let[h,d]of r.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(c,m,I.tB))continue;let y=Se(d),g=Se(p);if(y!==g?y:!1)e.push({jumpEdgeId:s.id,otherEdgeId:c.id,segIndex:h,t:I.tA,point:I.point});else e.push({jumpEdgeId:c.id,otherEdgeId:s.id,segIndex:m,t:I.tB,point:I.point})}}}return e}t(Fo,"findEdgeIntersections");function cn(n){let e=Math.round(n*1000)/1000;return Number.isInteger(e)?`${e}`:`${e}`}t(cn,"fmt");function wn(n){return`${cn(n.x)},${cn(n.y)}`}t(wn,"pointToString");function Po(n){let e=n.b.x-n.a.x,o=n.b.y-n.a.y;if(Math.abs(e)>=Math.abs(o))return e>=0?1:0;return o>=0?1:0}t(Po,"getArcSweepFlag");function ko(n,e){if(n.length<2)return n.map((i)=>({...i}));let o=n.map((i)=>({...i})),s=e.arrowTypeStart&&Ne[e.arrowTypeStart];if(s){let i=n[0],c=n[1],u=Math.atan2(c.y-i.y,c.x-i.x);o[0].x=i.x+s*Math.cos(u),o[0].y=i.y+s*Math.sin(u)}let r=e.arrowTypeEnd&&Ne[e.arrowTypeEnd];if(r){let i=n.length,c=n[i-2],u=n[i-1],h=Math.atan2(u.y-c.y,u.x-c.x);o[i-1].x=u.x-r*Math.cos(h),o[i-1].y=u.y-r*Math.sin(h)}return o}t(ko,"applyMarkerOffsets");function _o(n,e,o,s,r){let i=n.point.x,c=n.point.y,u={x:i-e*n.r,y:c-o*n.r},h={x:i+e*n.r,y:c+o*n.r},d=[`L${wn(u)}`];if(r==="arc")d.push(`A${cn(n.r)},${cn(n.r)} 0 0 ${s} ${wn(h)}`);else d.push(`M${wn(h)}`);return d}t(_o,"emitJump");function Pn(n,e,o,s){let r=e.x-n.x,i=e.y-n.y,c=o.x-e.x,u=o.y-e.y,h=Math.hypot(r,i),d=Math.hypot(c,u);if(h<zn||d<zn)return null;let m=r/h,p=i/h,I=c/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:e.x-m*L,startY:e.y-p*L,endX:e.x+I*L,endY:e.y+y*L,ctrlX:e.x,ctrlY:e.y,cutLen:L}}t(Pn,"computeRoundedCorner");function Ho(n,e,o){let s=n.points;if(s.length<2)return"";let r=ko(s,n),i=n.curve==="rounded",c=jn(r),u=new Map;for(let d of e){let m=c[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(r[0])}`];for(let d=0;d<c.length;d++){let m=c[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(i&&d>0){let w=Pn(r[d-1],r[d],r[d+1]??r[d],Un);if(w)l=w.cutLen}let x=p,L=null;if(i&&d<c.length-1){if(L=Pn(r[d],r[d+1],r[d+2]??r[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(i&&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(" ")}t(Ho,"rewriteEdgePath");function Do(n){return/^[\d\s+,.LMelm-]*$/.test(n)}t(Do,"isStraightPath");function Xo(n){if(!n)return!0;return n==="linear"||n==="rounded"||n==="step"||n==="stepBefore"||n==="stepAfter"}t(Xo,"curveSupportsLineHops");function Yo(n){if(!n)return null;try{let e=typeof atob==="function"?atob(n):Buffer.from(n,"base64").toString(),o=JSON.parse(e);if(!Array.isArray(o))return null;let s=[];for(let r of o)if(r&&typeof r.x==="number"&&typeof r.y==="number")s.push({x:r.x,y:r.y});return s.length>=2?s:null}catch{return null}}t(Yo,"decodeDataPoints");function ve(n,e,o){if(!o.enabled)return;let s=n.node();if(!s)return;let r=new Map;for(let d of e)r.set(d.id,d);let i=new Map;for(let d of s.querySelectorAll("path[data-id]")){let m=d.getAttribute("data-id");if(m!==null&&!i.has(m))i.set(m,d)}let c=[];for(let d of e){let m=i.get(d.id);if(!m)continue;let I=Yo(m.getAttribute("data-points"))??d.points;c.push({...d,points:I})}let u=Fo(c);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 c){let m=h.get(d.id);if(!m||m.length===0)continue;let I=r.get(d.id)?.curve;if(I!==void 0&&!Xo(I))continue;let y=i.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)}}}t(ve,"applyLineJumpsToSvg");function jo(n,{measure:e}){let o=n.config?.swimlane?.lineHops;if(o===!1)return;let s=o==="gap"?"gap":"arc",r=n.edges.filter((i)=>Array.isArray(i.points)&&i.points.length>=2).map((i)=>({id:i.id,points:i.points,curve:i.curve,arrowTypeStart:i.arrowTypeStart,arrowTypeEnd:i.arrowTypeEnd}));ve(e.groups.edgePaths,r,{enabled:!0,jumpRadius:6,jumpStyle:s})}t(jo,"applySwimlaneLineJumps");var Le="__swimlane_default__",wr=21,Go=20;function Te(n){return Math.max(n.padding??Go,Go)}t(Te,"topLaneHorizontalPadding");function Wo(n){let{x:e,y:o,width:s,height:r}=n,i=n.swimlaneContentTop;if(typeof e!=="number"||typeof o!=="number"||typeof s!=="number"||typeof r!=="number"||typeof i!=="number"||!Number.isFinite(e)||!Number.isFinite(o)||!Number.isFinite(s)||!Number.isFinite(r)||!Number.isFinite(i)||s<=0||r<=0){delete n.groupTitleRect;return}let c=o-r/2,u=Math.min(i,o+r/2),h=Math.min(wr,Math.max(0,u-c)),d=c+h;if(d<=c){delete n.groupTitleRect;return}n.groupTitleRect={left:e-s/2,right:e+s/2,top:c,bottom:d}}t(Wo,"assignTopLaneTitleRect");function Ko(n){let e=n.direction,o=n.nodes??=[];for(let i of n.nodes??[])if(i.isGroup&&!i.parentId){if(i.shape="swimlane",e)i.direction=e}let s=o.filter((i)=>!i.isGroup&&!i.parentId);if(s.length===0)return;let r=o.find((i)=>i.id===Le);if(!r)r={id:Le,label:"",isGroup:!0,shape:"swimlane",padding:20,look:n.config?.look,colorIndex:o.reduce((i,c)=>Math.max(i,c.colorIndex??-1),-1)+1,...e?{direction:e}:{}},o.push(r);else if(r.isGroup){if(r.shape="swimlane",e)r.direction=e}for(let i of s)i.parentId=Le}t(Ko,"prepareLayoutForSwimlanes");function qo(n){let e=new Map;for(let h of n.nodes??[])e.set(h.id,h);let o=[];for(let h of n.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=n.nodes??[],r=s.filter((h)=>h.isGroup),i=s.filter((h)=>!h.isGroup);return{nodes:[...[...r].reverse(),...i].map((h)=>h.id),edges:o,layout:n,nodeById:e}}t(qo,"toGraphView");function Jo(n,e,o,s){let{layout:r}=n,i=n.nodeById,c=s?.layerGap??100,u=s?.nodeGap??40,h=0;for(let I of e.layers){let y=0;for(let g of I){let l=i.get(g);if(!l){y++;continue}l.layer=h,l.order=y;let x=o.x[g]??y*u,L=o.y[g]??h*c;l.x=x,l.y=L,y++}h++}let d=r.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)}}}}}t(Jo,"writeBackToLayoutData");var Nr="[EdgeLabelNodes]";function Zo(n){let e=[],o=[],s=new Map;for(let c of n.nodes)s.set(c.id,c);for(let c of n.edges){if(!c.label||c.label.length===0)continue;if(c.isLayoutOnly)continue;if(c.labelNodeId)continue;let u=c.start?s.get(c.start):void 0,h=c.end?s.get(c.end):void 0;if(!u||!h){a.warn(Nr,`Edge ${c.id} has missing source or target node`);continue}let d=`edge-label-${c.start}-${c.end}-${c.id}`,p=u.parentId!==h.parentId?h.parentId:u.parentId,I={id:d,label:c.label,edgeStart:c.start??"",edgeEnd:c.end??"",shape:"labelRect",width:0,height:0,isEdgeLabel:!0,isDummy:!0,parentId:p,isGroup:!1,labelStyle:Array.isArray(c.labelStyle)?c.labelStyle[0]:c.labelStyle??"",...u.dir?{dir:u.dir}:{}};e.push(I),c.labelNodeId=d,c.label=void 0,c.text=void 0;let y={id:`${c.id}-to-label`,start:c.start,end:d,type:"normal",isLayoutOnly:!0},g={id:`${c.id}-from-label`,start:d,end:c.end,type:"normal",isLayoutOnly:!0};o.push(y,g)}let r=[...n.nodes,...e],i=[...n.edges,...o];return{...n,nodes:r,edges:i}}t(Zo,"createEdgeLabelNodes");var Dt=0.001;function ao(n){let e=n.x??0,o=n.y??0,s=n.width??0,r=n.height??0;return s>0&&r>0?{cx:e,cy:o,rect:On(e,o,s,r)}:void 0}t(ao,"measuredNodeRect");function lo(n){if(n.isGroup)return;let e=ao(n);if(!e)return;return{id:String(n.id??""),cx:e.cx,cy:e.cy,rect:e.rect}}t(lo,"nodeBoundsInfoFor");function rn(n,e,o=Dt){return Math.abs(n.x-e.x)<o&&Math.abs(n.y-e.y)<o}t(rn,"samePoint");function ht(n,e,o=Dt){return Math.abs(n.x-e.x)<o}t(ht,"sameX");function pt(n,e,o=Dt){return Math.abs(n.y-e.y)<o}t(pt,"sameY");function Tt(n,e,o=Dt){return pt(n,e,o)&&Math.abs(n.x-e.x)>o}t(Tt,"isHorizontalSegment");function wt(n,e,o=Dt){return ht(n,e,o)&&Math.abs(n.y-e.y)>o}t(wt,"isVerticalSegment");function Ut(n,e,o,s){return Math.max(0,Math.min(Math.max(n,e),Math.max(o,s))-Math.max(Math.min(n,e),Math.min(o,s)))}t(Ut,"overlapLength");function fn(n,e,o=Dt){if(n.horizontal&&e.horizontal&&pt(n.a,e.a,o))return Ut(n.a.x,n.b.x,e.a.x,e.b.x);if(n.vertical&&e.vertical&&ht(n.a,e.a,o))return Ut(n.a.y,n.b.y,e.a.y,e.b.y);return 0}t(fn,"sameAxisSegmentOverlapLength");function Bn(n,e=Dt){let o=[];for(let s=0;s<n.length-1;s++){let r=n[s],i=n[s+1],c=Tt(r,i,e),u=wt(r,i,e);if(c||u)o.push({index:s,a:r,b:i,horizontal:c,vertical:u})}return o}t(Bn,"orthogonalSegmentsForPoints");function nn(n,e=Dt){let o=Bn(n,e),s=0;for(let r=1;r<o.length;r++)if(o[r-1].horizontal!==o[r].horizontal)s++;return s}t(nn,"countOrthogonalBends");function yt(n,e=Dt){let o=[];for(let s of n){let r=o.length>0?o[o.length-1]:void 0;if(!r||!rn(r,s,e))o.push({x:s.x,y:s.y})}return o}t(yt,"dedupeConsecutivePoints");function fo(n,e=Dt){if(!n||n.length!==4)return;let[o,s,r,i]=n;if(Tt(o,s,e)&&wt(s,r,e)&&Tt(r,i,e))return{kind:"HVH",p0:o,p1:s,p2:r,p3:i};return wt(o,s,e)&&Tt(s,r,e)&&wt(r,i,e)?{kind:"VHV",p0:o,p1:s,p2:r,p3:i}:void 0}t(fo,"classifyThreeSegmentRoute");function ae(n,e,o,s=0){let r=Math.min(n.x,e.x),i=Math.max(n.x,e.x),c=Math.min(n.y,e.y),u=Math.max(n.y,e.y);return i>o.left-s&&r<o.right+s&&u>o.top-s&&c<o.bottom+s}t(ae,"segmentBoundsOverlapRect");function uo(n,e,o=0){return n.x>e.left+o&&n.x<e.right-o&&n.y>e.top+o&&n.y<e.bottom-o}t(uo,"pointInsideRect");function Qo(n,e){return n.left<=e.left&&n.right>=e.right&&n.top<=e.top&&n.bottom>=e.bottom}t(Qo,"rectContainsRect");function Qn(n,e){return n.left<e.right&&n.right>e.left&&n.top<e.bottom&&n.bottom>e.top}t(Qn,"rectsOverlap");function we(n,e){return{left:n.left-e,right:n.right+e,top:n.top-e,bottom:n.bottom+e}}t(we,"inflateRect");function On(n,e,o,s){return{left:n-o/2,right:n+o/2,top:e-s/2,bottom:e+s/2}}t(On,"rectFromCenterSize");function Zt(n){return ao(n)?.rect}t(Zt,"rectOfNodeBounds");function vn(n,e){switch(e){case"top":return{x:n.cx,y:n.rect.top};case"bottom":return{x:n.cx,y:n.rect.bottom};case"left":return{x:n.rect.left,y:n.cy};case"right":return{x:n.rect.right,y:n.cy}}}t(vn,"portForRectSide");function ho(n,e,o,s,r,i=Dt){let c=e==="left"||e==="right",u=s==="left"||s==="right";if(c&&u){if(e==="right"&&s==="left"&&n.x<o.x||e==="left"&&s==="right"&&n.x>o.x){if(pt(n,o,i))return[n,o];let p=(n.x+o.x)/2;return[n,{x:p,y:n.y},{x:p,y:o.y},o]}if(e===s){if(pt(n,o,i))return;let p=e==="left"?Math.min(n.x,o.x)-r:Math.max(n.x,o.x)+r;return[n,{x:p,y:n.y},{x:p,y:o.y},o]}return}if(!c&&!u){if(e===s){if(ht(n,o,i))return;let I=e==="top"?Math.min(n.y,o.y)-r:Math.max(n.y,o.y)+r;return[n,{x:n.x,y:I},{x:o.x,y:I},o]}if(!(e==="bottom"&&s==="top"&&n.y<o.y||e==="top"&&s==="bottom"&&n.y>o.y))return;if(ht(n,o,i))return[n,o];let p=(n.y+o.y)/2;return[n,{x:n.x,y:p},{x:o.x,y:p},o]}if(c&&!u){let m=e==="right"&&o.x>n.x||e==="left"&&o.x<n.x,p=s==="top"&&n.y<o.y||s==="bottom"&&n.y>o.y;return m&&p?[n,{x:o.x,y:n.y},o]:void 0}let h=e==="bottom"&&o.y>n.y||e==="top"&&o.y<n.y,d=s==="left"&&n.x<o.x||s==="right"&&n.x>o.x;return h&&d?[n,{x:n.x,y:o.y},o]:void 0}t(ho,"buildOrthogonalPortPath");function go(n,e,o,s){return e==="left"||e==="right"?[n,{x:s,y:n.y},{x:s,y:o.y},o]:[n,{x:n.x,y:s},{x:o.x,y:s},o]}t(go,"buildSameSideTrackPath");function le(n){let e=new Map,o=[];for(let s of n){if(s.isEdgeLabel)continue;let r=lo(s);if(!r)continue;e.set(r.id,r),o.push({id:r.id,rect:r.rect})}return{nodeInfoById:e,realNodeRects:o}}t(le,"collectRealNodeBounds");function bn(n){let e=[],o=[];for(let s of n){let r=lo(s);if(!r)continue;let i={id:r.id,rect:r.rect};if(s.isEdgeLabel)o.push(i);else e.push(i)}return{realNodeRects:e,labelNodeRects:o}}t(bn,"collectNodeRectEntries");function ts(n,{includeEdgeLabels:e=!0}={}){let o=[];for(let s of n){if(s.isGroup||!e&&s.isEdgeLabel)continue;let r=s.x??0,i=s.y??0,c=s.width??0,u=s.height??0;o.push({nodeId:s.id,...On(r,i,c,u)})}return o}t(ts,"collectLayoutNodeRects");function po(n,e,o=Dt){let{start:s,end:r}=n;if(!s||!r)return;let i=e.get(s),c=e.get(r);if(!i||!c)return;return{srcId:s,dstId:r,srcInfo:i,dstInfo:c,collinearX:Math.abs(i.cx-c.cx)<o,collinearY:Math.abs(i.cy-c.cy)<o}}t(po,"getNodePairGeometry");function Nt(n,e,o,s=[],r=0){for(let i of o){if(s.includes(i.id))continue;if(ae(n,e,i.rect,-r))return!0}return!1}t(Nt,"segmentHitsAnyRect");function mo(n,e,o,s,r=Dt,i=0.000001){let c=pt(n,e,r),u=ht(n,e,r),h=pt(o,s,r),d=ht(o,s,r);if(c&&h||u&&d)return!1;if(!(c||u)||!(h||d))return!1;let m=c?{a:n,b:e}:{a:o,b:s},p=u?{a:n,b:e}:{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)<i&&Math.abs(I-m.a.y)<i||Math.abs(l-m.b.x)<i&&Math.abs(I-m.b.y)<i,E=Math.abs(l-p.a.x)<i&&Math.abs(I-p.a.y)<i||Math.abs(l-p.b.x)<i&&Math.abs(I-p.b.y)<i;return!(S&&E)}t(mo,"orthogonalSegmentsCross");function ns(n,e,o,s,r=Dt){let i=pt(n,e,r),c=ht(n,e,r),u=pt(o,s,r),h=ht(o,s,r);if(c&&h&&ht(n,o,r))return Ut(n.y,e.y,o.y,s.y)>r;if(i&&u&&pt(n,o,r))return Ut(n.x,e.x,o.x,s.x)>r;return!1}t(ns,"sameAxisSegmentsOverlap");function te(n,e,o,s,{epsilon:r=Dt,skipDegenerateOther:i=!1}={}){for(let c of o){if(c===s||c.isLayoutOnly)continue;let u=c.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(i&&rn(d,m,r))continue;if(mo(n,e,d,m,r)||ns(n,e,d,m,r))return!0}}return!1}t(te,"segmentConflictsWithAnyEdge");function un(n,e,o,s,r=Dt){let i=pt(n,e,r),c=ht(n,e,r),u=pt(o,s,r),h=ht(o,s,r);if(!(i&&h||c&&u))return!1;let d=i?{a:n,b:e}:{a:o,b:s},m=i?{a:o,b:s}:{a:n,b:e},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+r&&g<y-r&&p>l+r&&p<x-r}t(un,"orthogonalSegmentsStrictlyCross");function Oe(n,e,o){let s=Math.min(e,o),r=Math.max(e,o);return n>s+Dt&&n<r-Dt}t(Oe,"strictlyBetween");function es(n,e,o){if(ht(n,e)&&ht(e,o))return Oe(e.y,n.y,o.y);if(pt(n,e)&&pt(e,o))return Oe(e.x,n.x,o.x);return!1}t(es,"isCollinearIntermediate");function os(n){let e=!1,o=[];for(let s=0;s<n.length;s++){let r=o[o.length-1],i=n[s],c=s+1<n.length?n[s+1]:void 0;if(r&&c){if(rn(r,c)){s++,e=!0;continue}if(es(r,i,c)){e=!0;continue}}o.push(i)}return{points:o,changed:e}}t(os,"simplifyPolylineOnce");function ne(n){let e=[n[0]];for(let s=1;s<n.length;s++){let r=e[e.length-1],i=n[s];if(!ht(r,i)&&!pt(r,i)){let c=e.length>=2?e[e.length-2]:void 0,h=(c?ht(c,r):!1)?{x:r.x,y:i.y}:{x:i.x,y:r.y};e.push(h)}e.push(i)}let o=[];for(let s of e){let r=o[o.length-1];if(!r||!rn(r,s))o.push(s)}return o}t(ne,"orthogonalizePolyline");function dn(n){if(n.length<3)return n;let e=[...n];for(let o=0;o<32;o++){let s=os(e);if(e=s.points,!s.changed)break}return e}t(dn,"simplifyPolyline");var st=0.001,Or=0.5,$o=4;function yo(n,e,o){let s=n;if(s.isLayoutOnly||!s.points||s.points.length<o)return;let r=s.start?e.get(s.start):void 0,i=s.end?e.get(s.end):void 0;return{edge:s,points:s.points,srcRect:r?Zt(r):void 0,dstRect:i?Zt(i):void 0}}t(yo,"endpointContextFor");function ss(n,e,o){if(pt(n,e,st))return{x:n.x<o.left?o.left:o.right,y:n.y};if(ht(n,e,st)){let s=n.y<o.top?o.top:o.bottom;return{x:n.x,y:s}}return{x:Math.min(o.right,Math.max(o.left,n.x)),y:Math.min(o.bottom,Math.max(o.top,n.y))}}t(ss,"segmentEnterPoint");function Be(n,e,o){let s=o?1:-1,r=o?0:n.length-1;while(r>=0&&r<n.length&&uo(n[r],e,Or))r+=s;if(r<0||r>=n.length)return n;let i=r-s;if(i<0||i>=n.length)return n;let c=ss(n[r],n[i],e);return o?[c,...n.slice(r)]:[...n.slice(0,r+1),c]}t(Be,"clipEndpoint");function rs(n,e){for(let o of n){let s=yo(o,e,2);if(!s)continue;let r=[...s.points];if(s.srcRect)r=Be(r,s.srcRect,!0);if(s.dstRect)r=Be(r,s.dstRect,!1);r=dn(ne(r)),r=xo(r,s.srcRect,s.dstRect),s.edge.points=dn(ne(r))}}t(rs,"clipEdgeEndpointsToNodeBoundaries");function Fe(n,e,o,s=!1){if(pt(n,e,st)){if(e.y<o.top-st||e.y>o.bottom+st)return e;if(s){if(n.x<o.left-st)return{x:o.left,y:n.y};if(n.x>o.right+st)return{x:o.right,y:n.y}}return{x:Math.abs(e.x-o.left)<=Math.abs(e.x-o.right)?o.left:o.right,y:n.y}}if(ht(n,e,st)){if(e.x<o.left-st||e.x>o.right+st)return e;if(s){if(n.y<o.top-st)return{x:n.x,y:o.top};if(n.y>o.bottom+st)return{x:n.x,y:o.bottom}}let r=Math.abs(e.y-o.top)<=Math.abs(e.y-o.bottom);return{x:n.x,y:r?o.top:o.bottom}}return e}t(Fe,"snapEndpointToBoundary");function ee(n,e,o){let s=n[e];for(let r=e+o;r>=0&&r<n.length;r+=o){let i=n[r];if(!rn(i,s,st))return i}return n[e+o]}t(ee,"firstDistinctAdjacent");function oe(n,e){let o=n+$o,s=e-$o;return o<=s?{lo:o,hi:s}:{lo:(n+e)/2,hi:(n+e)/2}}t(oe,"cornerClearanceRange");function Pe(n,e,o){let{lo:s,hi:r}=oe(e,o);return Math.min(r,Math.max(s,n))}t(Pe,"clampToCornerClearance");function is(n){let e=Math.max(...n.map((s)=>s.lo)),o=Math.min(...n.map((s)=>s.hi));if(e>o)return;return{lo:e,hi:o}}t(is,"intersectRanges");function ke(n,e){return e==="left"||e==="right"?oe(n.top,n.bottom):oe(n.left,n.right)}t(ke,"clearanceRangeForSide");function se(n,e,o){let s=n.y>=o.top-st&&n.y<=o.bottom+st,r=n.x>=o.left-st&&n.x<=o.right+st;if(pt(n,e,st)&&s){if(Math.abs(n.x-o.left)<st)return"left";if(Math.abs(n.x-o.right)<st)return"right"}if(ht(n,e,st)&&r){if(Math.abs(n.y-o.top)<st)return"top";if(Math.abs(n.y-o.bottom)<st)return"bottom"}return}t(se,"terminalSideForSegment");function kn(n){return n==="left"||n==="right"}t(kn,"isHorizontalSide");function cs(n,e,o,s,r){let i=[],c=o?se(n,e,o):void 0,u=s?se(e,n,s):void 0;if(o&&c&&kn(c)===r)i.push(ke(o,c));if(s&&u&&kn(u)===r)i.push(ke(s,u));return i.length>0?is(i):void 0}t(cs,"straightClearanceRange");function _e(n,e,o,s,r){let i=cs(n,e,o,s,r);if(!i)return;let c=r?n.y:n.x,u=Math.min(i.hi,Math.max(i.lo,c));if(Math.abs(u-c)<st)return;return r?[{x:n.x,y:u},{x:e.x,y:u}]:[{x:u,y:n.y},{x:u,y:e.y}]}t(_e,"clearStraightEndpointCornerAxis");function xo(n,e,o){if(n.length!==2)return n;let[s,r]=n;if(pt(s,r,st))return _e(s,r,e,o,!0)??n;if(ht(s,r,st))return _e(s,r,e,o,!1)??n;return n}t(xo,"clearStraightEndpointCornerConnections");function as(n,e,o){return kn(o)?{x:n.x,y:Pe(n.y,e.top,e.bottom)}:{x:Pe(n.x,e.left,e.right),y:n.y}}t(as,"cornerClearedEndpoint");function ls(n,e,o,s,r,i){let c=n.map((u)=>({...u}));for(let u=e;u>=0&&u<n.length;u+=o){let h=n[u];if(i&&!pt(h,s,st))break;if(!i&&!ht(h,s,st))break;if(i)c[u].y=r.y;else c[u].x=r.x}return c}t(ls,"moveCollinearEndpointRun");function He(n,e,o){if(n.length<2)return n;let s=o?0:n.length-1,r=o?1:-1,i=n[s],c=ee(n,s,r);if(!c)return n;let u=se(i,c,e);if(!u)return n;let h=kn(u),d=as(i,e,u);if(rn(i,d,st))return n;return ls(n,s,r,i,d,h)}t(He,"clearEndpointCornerConnection");function De(n,e,o){let s=Math.min(n.x,e.x)>=o.left-st&&Math.max(n.x,e.x)<=o.right+st,r=Math.min(n.y,e.y)>=o.top-st&&Math.max(n.y,e.y)<=o.bottom+st;if(Math.abs(n.y-o.top)<st&&Math.abs(e.y-o.top)<st&&s)return"top";if(Math.abs(n.y-o.bottom)<st&&Math.abs(e.y-o.bottom)<st&&s)return"bottom";if(Math.abs(n.x-o.left)<st&&Math.abs(e.x-o.left)<st&&r)return"left";if(Math.abs(n.x-o.right)<st&&Math.abs(e.x-o.right)<st&&r)return"right";return}t(De,"borderSideForSegment");function Xe(n,e,o,s){switch(n){case"top":return ht(e,o,st)&&o.y<s.top-st;case"bottom":return ht(e,o,st)&&o.y>s.bottom+st;case"left":return pt(e,o,st)&&o.x<s.left-st;case"right":return pt(e,o,st)&&o.x>s.right+st}}t(Xe,"leavesOutward");function Ye(n,e,o){if(n.length<3)return n;if(o){let i=De(n[0],n[1],e);if(i&&Xe(i,n[1],n[2],e))return n.slice(1);return n}let s=n.length-1,r=De(n[s-1],n[s],e);if(r&&Xe(r,n[s-1],n[s-2],e))return n.slice(0,s);return n}t(Ye,"collapseOwnBorderStub");function fs(n,e,o){let s=n;if(e){let i=ee(s,0,1);if(i){let c=Fe(i,s[0],e);if(c!==s[0])s=[c,...s.slice(1)]}s=Ye(s,e,!0)}if(o){let i=s.length-1,c=ee(s,i,-1);if(c){let u=Fe(c,s[i],o,!0);if(u!==s[i])s=[...s.slice(0,i),u]}s=Ye(s,o,!1)}let r=xo(s,e,o);if(r!==s||s.length===2)return r;if(e)s=He(s,e,!0);if(o)s=He(s,o,!1);return s}t(fs,"snapAndCollapseEndpoints");function Ge(n,e){for(let o of n){let s=yo(o,e,2);if(!s)continue;let r=yt(s.points,st),i=fs(r,s.srcRect,s.dstRect);if(i.length<3){s.edge.points=i;continue}let c=[i[0],{...i[0]},...i.slice(1,-1),i[i.length-1],{...i[i.length-1]}];s.edge.points=c}}t(Ge,"prepareEdgeEndpointsForRenderer");function bo(n){return new Map(n.map((e)=>[e.id,e]))}t(bo,"buildNodeMap");function ds(n,e){let o=n.parentId,s=null;while(o){let r=e.get(o);if(!r?.isGroup)break;s=r.id,o=r.parentId}return s}t(ds,"resolveTopLevelGroupId");function $e(n,e){let o=0,s=n.parentId;while(s){let r=e.get(s);if(!r?.isGroup)break;o++,s=r.parentId}return o}t($e,"groupDepth");function Mo(n){let e=1/0,o=-1/0,s=1/0,r=-1/0;for(let i of n){let{x:c,y:u}=i;if(typeof c!=="number"||typeof u!=="number")continue;let h=i.width??0,d=i.height??0;e=Math.min(e,c-h/2),o=Math.max(o,c+h/2),s=Math.min(s,u-d/2),r=Math.max(r,u+d/2)}if(e===1/0||s===1/0)return null;return{minX:e,maxX:o,minY:s,maxY:r}}t(Mo,"boundsForChildren");function us(n,e){let o=n.padding??20;n.x=(e.minX+e.maxX)/2,n.y=(e.minY+e.maxY)/2,n.width=Math.max(0,e.maxX-e.minX)+o,n.height=Math.max(0,e.maxY-e.minY)+o}t(us,"applyGroupBounds");function hs(n){let e=bo(n),o=n.filter((s)=>s.isGroup&&s.parentId).sort((s,r)=>$e(r,e)-$e(s,e));for(let s of o){let r=n.filter((c)=>c.parentId===s.id),i=Mo(r);if(i)us(s,i)}}t(hs,"recomputeNestedGroupBounds");function re(n,e){let o=n.nodes??[],s=n.edges??[],r=o.filter((h)=>!h.isGroup),i=1/0,c=-1/0;for(let h of r){let d=h[e];if(typeof d!=="number")continue;i=Math.min(i,d),c=Math.max(c,d)}if(!Number.isFinite(i)||!Number.isFinite(c))return!1;let u=t((h)=>i+c-h,"mirror");for(let h of o){let d=h[e];if(typeof d==="number")h[e]=u(d);let m=h.groupTitleRect;if(m)h.groupTitleRect=e==="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[e]=u(d[e]);return!0}t(re,"mirrorAxis");function gs(n){if(!(n.nodes??[]).some((o)=>!o.isGroup))return!0;return re(n,"y")}t(gs,"applyBtDirectionTransform");function ps(n,e="LR"){let o=n.nodes??[],s=n.edges??[],r=o.filter((F)=>!F.isGroup),i=1/0,c=1/0;for(let F of r){let Y=F.x??0,V=F.y??0;if(Y<i)i=Y;if(V<c)c=V}if(!Number.isFinite(i)||!Number.isFinite(c))return!1;let u=36,h=0,d=0;for(let F of r)h+=F.width??0,d+=F.height??0;let m=h/r.length,p=d/r.length,I=p>0?Math.max(1,m/p):1;for(let F of r){let Y=F.x??0,J=((F.y??0)-c)*I+u,lt=Y-i;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-c)*I+u,xt=V-i;Y.x=lt,Y.y=xt}}hs(o);let y=o.filter((F)=>F.isGroup&&!F.parentId);if(y.length===0){if(e==="RL")re(n,"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(e==="RL")re(n,"x");return!0}t(ps,"applyLrDirectionTransform");var an=0.000001,Br=8,Wn=Br,Fr=[0,Wn,-Wn,2*Wn,-2*Wn];function ms(n,e){let{nodeInfoById:o,realNodeRects:s}=le(e);for(let r of n){if(r.isLayoutOnly)continue;let i=r.points;if(!i||i.length<4)continue;let c=fo(yt(i,an),an);if(!c)continue;let{p3:u}=c,h=c.kind==="HVH",d=po(r,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,n,r,{epsilon:an,skipDegenerateOther:!0}),P=!R&&te(w,C,n,r,{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)r.points=x}}t(ms,"portSwapToLShape");function ys(n,e){let{realNodeRects:i,labelNodeRects:c}=bn(e.values());for(let u of n){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?e.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,i,O?[O]:[],-2))continue;if(Nt(Y,V,c,[],-2))continue;if(P){let q=e.get(P),ot=q?Zt(q):void 0;if(ot&&uo(Y,ot,2))continue}let J=t((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=t((q,ot)=>{for(let dt of n){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,i,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=e.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}}}}}t(ys,"collapseShortTerminalStub");var tt=0.001,Ht=8,xs=t((n)=>typeof n==="string"?n.toUpperCase():"","upperCaseDirection"),at=Bn,Ee=t((n,e)=>ht(n,e,tt)||pt(n,e,tt),"orthogonallyAligned");function ze(n,e){let r=t((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"),i=t((y,g)=>{let l=yt(y.points??[]);if(l.length<2)return;let x=g?y.start:y.end,L=x?e.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=r(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"),c=t((y,g)=>Math.max(0,Math.min(y.max,g.max)-Math.max(y.min,g.min)),"projectedOverlapLength"),u=t((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=t((y,g)=>{if(y.nodeId!==g.nodeId||y.orientation!==g.orientation)return!1;return c(y,g)>=Ht&&Math.abs(y.coord-g.coord)<0.5},"exactTerminalLaneConflict"),d=t((y,g)=>{if(y.nodeId!==g.nodeId||y.orientation!==g.orientation||y.orientation!=="H"||y.atStart===g.atStart)return!1;let l=c(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=t((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(!t(()=>{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=t((y)=>{let g=y.edge,l=yt(g.points??[]);if(l.length!==2)return!1;let{start:x,end:L}=g,S=x?e.get(x):void 0,E=L?e.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=n.filter((x)=>!x.isLayoutOnly).flatMap((x)=>[i(x,!0),i(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=i({...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}}t(ze,"separateSharedRenderedTerminalLanes");function bs(n,e){let{realNodeRects:r,labelNodeRects:i}=bn(e.values()),c=t((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,r,y,-2))return!1;if(Nt(g.a,g.b,i,[],-2))return!1}for(let g of n){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=t((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 n){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||!c(m,y))continue;m.points=y,d=!0;break}if(d)break}if(!d)return}}t(bs,"collapseRedundantRectangularDoglegs");function Ve(n,e){let{realNodeRects:i,labelNodeRects:c}=bn(e.values()),u=n.filter((g)=>!g.isLayoutOnly),h=t((g,l,x)=>yt(g===l?x??[]:g.points??[]),"pointsFor"),d=t((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=t((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=t((g,l)=>{let x=[g.start,g.end].filter((L)=>Boolean(L));return i.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=t((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=t((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,i,L,-2))return!1;if(Nt(E.a,E.b,c,[],-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}}t(Ve,"liftObstacleHuggingSameSideRails");function Ue(n,e,o){let r=t((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"),i=t((d)=>{if(!d.isGroup||d.parentId)return;let m=xs(d.direction??o);if(m==="LR"||m==="RL"||m==="BT")return;let p=r(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"),c=t((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=[...e.values()].map(i).filter((d)=>Boolean(d));if(u.length===0)return;let h=0;for(let d of n){if(d.isLayoutOnly)continue;let m=yt(d.points??[]);for(let p of at(m))for(let I of u){if(!c(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}}}t(Ue,"liftTopLaneTitleBandsAboveRails");function je(n,e,o){let r=t((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"),i=t((m)=>{if(!m.isGroup||m.parentId)return;if(xs(m.direction??o)!=="LR")return;let I=r(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"),c=t((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=t((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=[...e.values()].map(i).filter((m)=>Boolean(m));if(h.length===0)return;let d=0;for(let m of n){if(m.isLayoutOnly)continue;let p=yt(m.points??[]);for(let I of at(p))for(let y of h)if(c(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}}}t(je,"shiftLeftLaneTitleBandsLeftOfRails");function Ms(n,e){let{realNodeRects:r}=bn(e.values()),i=n.filter((l)=>!l.isLayoutOnly),c=t((l,x=new Map)=>yt(x.get(l)??l.points??[]),"replacementPointsFor"),u=t((l=new Map)=>{let x=0;for(let L=0;L<i.length;L++){let S=at(c(i[L],l));for(let E=L+1;E<i.length;E++){let w=at(c(i[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=t((l=new Map)=>i.reduce((x,L)=>x+nn(c(L,l)),0),"totalBends"),d=t((l)=>{let x=c(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=t((l,x)=>{let L=c(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=t((l,x)=>{let L=[l.start,l.end].filter((S)=>Boolean(S));for(let S of at(x))if(Nt(S.a,S.b,r,L,-2))return!0;return!1},"pathHasNodeHit"),I=t((l,x,L)=>{for(let S of i){if(S===l)continue;for(let E of at(x))for(let w of at(c(S,L)))if(fn(E,w,0.5)>=Ht)return!0}return!1},"pathHasSharedTrack"),y=t((l,x,L)=>!p(l,x)&&!I(l,x,L),"candidateIsSafe"),g=t(()=>{let l=new Map;for(let x of i){let L=x.end;if(!L||!e.has(L))continue;if(c(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}}t(Ms,"swapDestinationTerminalTailsToReduceCrossings");function Is(n,e){let{realNodeRects:c,labelNodeRects:u}=bn(e.values()),h=n.filter((C)=>!C.isLayoutOnly),d=t((C,b=new Map)=>yt(b.get(C)??C.points??[]),"replacementPointsFor"),m=t((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=t((C=new Map)=>h.reduce((b,R)=>b+nn(d(R,C)),0),"totalBends"),I=t((C)=>{let{start:b,end:R}=C,O=b?e.get(b):void 0,P=R?e.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=t((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=t(()=>{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=t((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=t((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=t((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=t((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=t(()=>{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=t((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=t((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,c,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=_}}t(Is,"reassignCrossingExternalRailChannels");function Ss(n,e){let{realNodeRects:r,labelNodeRects:i}=bn(e.values()),c=n.filter((g)=>!g.isLayoutOnly),u=t((g,l,x)=>yt(g===l?x??[]:g.points??[]),"pointsFor"),h=t((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=t((g,l)=>{let x=0;for(let L=0;L<c.length;L++){let S=at(u(c[L],g,l));for(let E=L+1;E<c.length;E++){let w=at(u(c[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=t((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=t((g)=>{let l=[g.start,g.end].filter((L)=>Boolean(L)),x=[];for(let L of l){let S=e.get(L),E=S?Zt(S):void 0;if(E)x.push(E)}return x},"endpointRectsFor"),I=t((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=t((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,r,L,-2))return!1;if(Nt(E.a,E.b,i,[],-2))return!1;if(S.some((w)=>m(E,w)))return!1}for(let E of c){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 c){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}}t(Ss,"shortcutRedundantOrthogonalJogs");function Cs(n,e){let c=[];for(let B of e.values()){if(B.isGroup||B.isEdgeLabel)continue;let D=B.x??0,X=B.y??0,W=Zt(B);if(!W)continue;c.push({id:String(B.id??""),cx:D,cy:X,rect:W})}if(c.length===0)return;let u=new Map(c.map((B)=>[B.id,B])),h=c.map((B)=>({id:B.id,rect:B.rect})),d=["top","bottom","left","right"],m={top:Math.min(...c.map((B)=>B.rect.top))-20,bottom:Math.max(...c.map((B)=>B.rect.bottom))+20,left:Math.min(...c.map((B)=>B.rect.left))-20,right:Math.max(...c.map((B)=>B.rect.right))+20},p=n.filter((B)=>!B.isLayoutOnly),I=new Map(p.map((B,D)=>[B,D])),y=t((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=t((B,D=new Map)=>yt(D.get(B)??B.points??[]),"replacementPointsFor"),l=t((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=t((B,D)=>l(at(B),at(D)),"crossingCountBetweenPaths"),L=t((B=new Map)=>{let D=0,X=[],W=new Set,f=[],M=t((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=t((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=t((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=t((B)=>[B.start,B.end].filter((D)=>Boolean(D)),"endpointIdsFor"),C=t((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=t((B,D,X)=>S(B,new Map([[D,X]])),"crossingCountWithSingleReplacement"),R=t((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=t((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=t((B=new Map)=>p.reduce((D,X)=>D+nn(g(X,B)),0),"totalBends"),N=t((B=new Map)=>p.reduce((D,X)=>D+O(g(X,B)),0),"totalLength"),H=t((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"),_=t((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=t((B,D)=>{let X=dn(yt(D));if(at(X).length===X.length-1)B.push(X)},"pushOrthogonalCandidate"),Y=t((B)=>B==="left"||B==="right","sideIsHorizontal"),V=t((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=t((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=t((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=t((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=t((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=t((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=t((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=t((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=t((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=t((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=t((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=t((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=t(()=>new Map(p.map((B)=>[B,at(g(B))])),"currentSegmentsByEdge"),jt=t((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=t((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=t((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=t((B,D)=>{for(let X of B.sharedTrackConflicts)if(X!==D)return!1;return!0},"conflictsOnlyWith"),Ln=t((B,D)=>B.segments.some((X)=>D.segments.some((W)=>fn(X,W,0.5)>=Ht)),"candidatesShareTrack"),gn=t((B,D,X,W)=>en(D,X.edge)&&en(W,B.edge)&&!Ln(D,W),"pairCandidatesAreCompatible"),En=t((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=t((B,D)=>B.crossings<D.crossings||B.crossings===D.crossings&&(B.bends<D.bends||B.bends===D.bends&&B.length<D.length),"pairScoreIsBetter"),ge=t((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=t((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}}t(Cs,"resolveRenderedOrthogonalCrossings");var xn=0.001,Pr=8;function vs(n,e){let{nodeInfoById:o,realNodeRects:s}=le(e),r=["top","bottom","left","right"],i=20,c={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=t((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,c[x]));return E},"buildOrthogonalPathCandidates"),h=t((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=t((l,x,L=!1)=>{let S=0,E=Bn(l,xn),{start:w,end:C}=x;for(let b of n){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=t((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=t((l,x,L)=>{let S=I.get(l)??[];S.push({side:x,edgeId:L}),I.set(l,S)},"addFaceClaim");for(let l of n){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=t((l,x,L)=>I.get(l)?.some((S)=>S.edgeId!==L&&S.side===x)??!1,"faceIsClaimed");for(let l of n){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 r){if(g(S,_,b))continue;let F=vn(w,_);for(let Y of r){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&&lt>=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)}}}t(vs,"simplifyDetouredEdges");var Jt=0.001,zo=10,Kn=7;function We(n,e){let o=e?0:n.length-1,s=e?1:-1,r=n[o],i=n[o+s];if(!r||!i)return;let c=i.x-r.x,u=i.y-r.y;if(Math.abs(c)+Math.abs(u)<Jt)return;if(Math.abs(u)<=Jt){let d=r.x+Math.sign(c)*zo;return{left:Math.min(r.x,d),right:Math.max(r.x,d),top:r.y-Kn,bottom:r.y+Kn}}if(Math.abs(c)<=Jt){let d=r.y+Math.sign(u)*zo;return{left:r.x-Kn,right:r.x+Kn,top:Math.min(r.y,d),bottom:Math.max(r.y,d)}}return{left:Math.min(r.x,i.x),right:Math.max(r.x,i.x),top:Math.min(r.y,i.y),bottom:Math.max(r.y,i.y)}}t(We,"markerClearanceRectFor");function Ls(n){return{left:Math.min(n.left,n.right),right:Math.max(n.left,n.right),top:Math.min(n.top,n.bottom),bottom:Math.max(n.top,n.bottom)}}t(Ls,"normalizeRect");function Ke(n,e){let o=yt(e),s=We(o,!0),r=We(o,!1);return[s,r].some((i)=>i&&Qn(n,Ls(i)))}t(Ke,"labelOverlapsOwnMarker");function Jn(n,e){let o=[];for(let g of n){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=[],r=[];for(let g of e.values()){let{isGroup:l,parentId:x}=g;if(l&&!x){let S=Zt(g);if(S)r.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 i=3,c=1,u=12,h=t((g,l)=>{let x=we(l,i);for(let{nodeId:L,rect:S}of s){if(L===g)continue;if(Qn(x,S))return!0}return!1},"labelOverlapsForeignNode"),d=t((g,l)=>{let x=we(l,i);for(let L of o){if(L.edgeId===g)continue;if(ae(L.p1,L.p2,x))return!0}return!1},"labelOverlapsForeignEdge"),m=t((g,l,x)=>h(g,x)||d(l,x),"labelOverlapsAnything"),p=[],I=t((g)=>{for(let{id:l,rect:x}of r)if(Qo(x,g))return l;return},"findContainingLane"),y=t((g,l)=>p.some((x)=>x.labelId!==g&&Qn(l,x.rect)),"overlapsPlacedLabel");for(let g of n){if(g.isLayoutOnly)continue;let l=g.labelNodeId;if(!l)continue;let x=e.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=t((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],_=t((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=t((nt,q,ot)=>Math.min(ot,Math.max(q,nt)),"clamp"),Y=t((nt,q)=>nt.midX>=q.left-Jt&&nt.midX<=q.right+Jt&&nt.midY>=q.top-Jt&&nt.midY<=q.bottom+Jt,"pointInsideRectInclusive"),V=t((nt)=>{let q=On(nt.midX,nt.midY,S,E),ot=I(q);if(ot)return{laneId:ot,anchor:nt,rect:q};let dt=r.find(({rect:en})=>Y(nt,en));if(!dt)return;let mt=dt.rect.left+S/2+c,Mt=dt.rect.right-S/2-c,Et=dt.rect.top+E/2+c,jt=dt.rect.bottom-E/2-c;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=t((nt,q,ot)=>nt.orientation==="horizontal"?Math.abs(q.midX-ot.x):Math.abs(q.midY-ot.y),"distanceAlongSegment"),lt=t((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=t((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=t((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})}}}t(Jn,"anchorLabelsToPolyline");var Ae=0.000001,kr=8,Vo=kr/2,_r=3;function qe(n,e){return n<e?`${n}::${e}`:`${e}::${n}`}t(qe,"pairKey");function Es(n,e){let{nodeInfoById:o,realNodeRects:s}=le(e),r=new Map;for(let c of e){let u=c.id;if(c.isGroup)continue;if(c.isEdgeLabel){r.set(u,{w:c.width??0,h:c.height??0});continue}}let i=t((c,u,h,d)=>{let m=qe(u,h),p=0,I=t((y)=>{if(!y)return;let g=r.get(y);if(!g)return;let l=d==="x"?g.w/2:g.h/2;if(l>p)p=l},"consider");I(c.labelNodeId);for(let y of n){if(y===c)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 c of n){if(c.isLayoutOnly)continue;let u=c.points;if(!fo(u,Ae))continue;let h=po(c,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=i(c,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,n,c,{epsilon:Ae}))continue;c.points=[b,R];break}}}t(Es,"straightenCollinearSiblingDetours");function Je(n,e){let{realNodeRects:d,labelNodeRects:m}=bn(e.values()),p=t((b,R)=>Bn(R,0.001).map((O)=>({...O,edge:b,interior:O.index>=1&&O.index<=R.length-3})),"segmentsFor"),I=t(()=>{let b=[];for(let R of n){if(R.isLayoutOnly)continue;let O=R.points;if(!O||O.length<2)continue;b.push(...p(R,yt(O)))}return b},"allSegments"),y=t((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=t((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 n){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=t((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=t((b,R)=>({x:b.x??(R.left+R.right)/2,y:b.y??(R.top+R.bottom)/2}),"nodeCenter"),L=t((b)=>{let R=b.edge,O=yt(R.points??[]);if(O.length!==4||b.index!==1)return;let P=R.start?e.get(R.start):void 0,N=R.end?e.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=t((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=t((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=t((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}}t(Je,"nudgeSharedInteriorSubpaths");function As(n,e,o,s){let r=e.x-n.x,i=e.y-n.y,c=s.x-o.x,u=s.y-o.y,h=r*u-i*c;if(Math.abs(h)<0.0000000001)return!1;let d=o.x-n.x,m=o.y-n.y,p=(d*u-m*c)/h,I=(d*i-m*r)/h,y=0.01;return p>y&&p<1-y&&I>y&&I<1-y}t(As,"segmentsIntersect");function Rs(n){let e=n.nodes??[],o=n.edges??[],s=[];if(!o.length||!e.length)return s;let r=ts(e),i=1,c=[];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 r){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,-i)){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++)c.push({edgeId:y,start:m,end:p,p1:d[g],p2:d[g+1]})}let u=new Set;for(let h=0;h<c.length;h++)for(let d=h+1;d<c.length;d++){let m=c[h],p=c[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;a.warn(`[SWIMLANE_VALIDATE] ${s.length} issue(s) detected: ${h} edge-node overlap(s), ${d} edge crossing(s)`);for(let m of s)a.warn(`[SWIMLANE_VALIDATE] ${m.type}: ${m.detail}`)}return s}t(Rs,"validateSwimlanesLayout");function Ts(n,e){let o=n.nodes??[],s=n.edges??[],r=o.filter((u)=>!u.isGroup);if((e==="LR"||e==="RL")&&r.length>0&&!ps(n,e))return;if(e==="BT"&&r.length>0&&!gs(n))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 i=new Map;for(let u of o)i.set(String(u.id),u);Jn(s,i),rs(s,i),ys(s,i),Je(s,i),ze(s,i),bs(s,i),Ve(s,i),Ms(s,i);let c=t(()=>{Cs(s,i),ze(s,i),Is(s,i),Ss(s,i),Jn(s,i),Ge(s,i),Ve(s,i),Jn(s,i),Ge(s,i)},"finalizeRenderedEdges");c(),Je(s,i),c(),Ue(s,i,e),je(s,i,e),Ue(s,i,e),je(s,i,e)}t(Ts,"postProcessSwimlaneLayout");function Mn(n){let e=new Map(n.nodeById),o=new Set,s=[];for(let i of n.edges){if(!e.has(i.src)||!e.has(i.dst))continue;let c=`${i.id}:${i.src}->${i.dst}`;if(o.has(c))continue;o.add(c),s.push(i)}return{nodes:[...e.keys()],edges:s,layout:n.layout,nodeById:e}}t(Mn,"normalizeGraph");function Io(n,e){return n.edges.filter((o)=>o.dst===e)}t(Io,"incoming");function ws(n){let e=new Map;for(let o of n.nodes)e.set(o,[]);for(let o of n.edges)e.get(o.src).push(o.dst);return e}t(ws,"buildSuccessorMap");function So(n){let e=ws(n);for(let o of e.values())o.sort((s,r)=>s.localeCompare(r));return e}t(So,"buildSortedSuccessorMap");function fe(n){let e=new Map;for(let o of n.nodes)e.set(o,0);for(let o of n.edges)e.set(o.dst,(e.get(o.dst)??0)+1);return e}t(fe,"buildInDegreeMap");function Co(n,e){let o=[...e.entries()].filter(([,u])=>u===0).map(([u])=>u).sort((u,h)=>u.localeCompare(h)),s=new Set(n.edges.flatMap((u)=>[u.src,u.dst])),r=t((u)=>!s.has(u)&&!n.nodeById.get(u)?.isGroup,"isUnconnected"),i=[...e.keys()].filter((u)=>e.get(u)===0&&r(u)),c=0;return o.map((u)=>r(u)?i[c++]:u)}t(Co,"sortedZeroInDegreeNodes");function de(n,e=()=>!0){let o=new Map,s=new Map;for(let r of n.nodes)o.set(r,[]),s.set(r,[]);for(let r of n.edges){if(!e(r))continue;s.get(r.src).push(r.dst),o.get(r.dst).push(r.src)}return{preds:o,succs:s}}t(de,"buildPredecessorSuccessorMaps");function vo(n,e,o,s){let r=0;for(let c of n.nodes){if(s?.skipGroups&&n.nodeById.get(c)?.isGroup)continue;r=Math.max(r,o[c]??0)}let i=Array.from({length:r+1},()=>[]);for(let c of e){if(s?.skipGroups&&n.nodeById.get(c)?.isGroup)continue;i[Math.max(0,o[c]??0)].push(c)}return i}t(vo,"buildLayersFromRanks");function _n(n){let e=fe(n),o=Co(n,e),s=[],r=So(n);while(o.length){let i=o.shift();s.push(i);for(let c of r.get(i)??[])if(e.set(c,(e.get(c)??0)-1),(e.get(c)??0)===0){let u=0;while(u<o.length&&o[u]<c)u++;o.splice(u,0,c)}}return s.length===n.nodes.length?s:null}t(_n,"topoSortIfAcyclic");function Fn(n){let e=new Map,o=0;for(let s of n)e.set(s,o),o++;return e}t(Fn,"buildLayerIndex");function Lo(n){let e=Array(n.length),o=t((s,r)=>{if(r-s<=1)return 0;let i=s+r>>1,c=o(s,i)+o(i,r),u=s,h=i,d=s;while(u<i||h<r)if(h>=r||u<i&&n[u]<=n[h])e[d++]=n[u++];else e[d++]=n[h++],c+=i-u;for(let m=s;m<r;m++)n[m]=e[m];return c},"count");return o(0,n.length)}t(Lo,"countInversions");function Ns(n){let e=Mn(n),o=new Map;for(let p of e.nodes)o.set(p,[]);for(let p of e.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 e.nodes)s[p]=0;let r=[],i=t((p)=>{s[p]=1;for(let I of o.get(p)??[]){let y=I.dst;if(s[y]===0)i(y);else if(s[y]===1)r.push(I)}s[p]=2},"dfs"),c=fe(e),u=[...e.nodes.filter((p)=>(c.get(p)??0)===0),...e.nodes.filter((p)=>(c.get(p)??0)!==0)];for(let p of u)if(s[p]===0)i(p);let h=new Set(r.map((p)=>`${p.id}:${p.src}->${p.dst}`)),d=e.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:[...e.nodes],edges:d,layout:e.layout,nodeById:new Map(e.nodeById)},reversed:r}}t(Ns,"removeCycles_DFS");function Os(n){let e=new Map,o=t((s)=>{if(e.has(s))return e.get(s);let r=n.nodeById.get(s);if(!r)return e.set(s,null),null;let i=r.parentId;if(!i)return e.set(s,null),null;let u=o(i)??i;return e.set(s,u),u},"resolve");for(let s of n.nodes)o(s);return e}t(Os,"buildTopLaneMap");function hn(n){let e=Os(n);return(o)=>e.get(o)??null}t(hn,"createTopLaneResolver");function ue(n){let e=[];for(let o of n.layout.nodes??[])if(o.isGroup&&!o.parentId)e.push(o.id);return[...new Set(e)].reverse()}t(ue,"buildTopLaneOrder");function Eo(n,e){let o=ue(n);if(!e||e.length===0)return o;let s=new Set(o),r=new Set,i=[];for(let c of e){if(!s.has(c)||r.has(c))continue;r.add(c),i.push(c)}for(let c of o){if(r.has(c))continue;i.push(c)}return i}t(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(n,e){let o=Mn(n),s=e?.laneOf??(()=>null),r=e?.rankHint,{preds:i}=de(o);for(let C of i.values())C.sort((b,R)=>b.localeCompare(R));let c=_n(o)??[...o.nodes].sort((C,b)=>C.localeCompare(b)),u=new Map;for(let[C,b]of c.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 c){let b=(i.get(C)??[]).filter((R)=>h.has(R));if(b.length>0){let R=Fs(C,b,{laneOf:s,rankHint:r,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=t((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 c)w(C);return{parent:h,children:d,roots:p,componentOf:g,blocks:l,nodeBlocks:x,adjacency:y,preorder:L,postorder:S,topologicalOrder:c}}t(Bs,"buildDrivingTree");function Fs(n,e,o){let s=o.laneOf(n);return[...e].sort((i,c)=>{let u=o.laneOf(i),h=o.laneOf(c),d=u!=null&&u===s,m=h!=null&&h===s;if(d!==m)return d?-1:1;let p=o.rankHint?.[i],I=o.rankHint?.[c];if(p!=null&&I!=null&&p!==I)return I-p;let y=o.topoIndex.get(i)??0,g=o.topoIndex.get(c)??0;if(y!==g)return y-g;return i.localeCompare(c)})[0]}t(Fs,"chooseParent");function Ps(n){let e=new Map;for(let o of n.nodes)e.set(o,new Set);for(let o of n.edges)e.get(o.src).add(o.dst),e.get(o.dst).add(o.src);return e}t(Ps,"buildAdjacency");function ks(n){let e=new Map,o=0;for(let s of n.keys()){if(e.has(s))continue;let r=[s];while(r.length>0){let i=r.pop();if(e.has(i))continue;e.set(i,o);for(let c of n.get(i)??[])if(!e.has(c))r.push(c)}o++}return e}t(ks,"assignComponents");function _s(n){let e=new Map,o=new Map,s=[],r=[],i=0,c=t((u,h)=>{e.set(u,++i),o.set(u,i);for(let d of n.get(u)??[]){if(d===h)continue;if(!e.has(d)){if(s.push([u,d]),c(d,u),o.set(u,Math.min(o.get(u)??i,o.get(d)??i)),(o.get(d)??0)>=(e.get(u)??0))r.push(Hs(u,d,s,r.length))}else if((e.get(d)??0)<(e.get(u)??0))s.push([u,d]),o.set(u,Math.min(o.get(u)??i,e.get(d)??i))}},"visit");for(let u of n.keys())if(!e.has(u))c(u,null);return r}t(_s,"computeBlocks");function Hs(n,e,o,s){let r=[],i=new Set;while(o.length>0){let c=o.pop();if(r.push(c),i.add(c[0]),i.add(c[1]),c[0]===n&&c[1]===e||c[0]===e&&c[1]===n)break}return{id:s,edges:r,nodes:[...i]}}t(Hs,"popBlock");function Ds(n,e,o){let s=[...n.nodes],r=new Map;for(let[S,E]of s.entries())r.set(E,S);let i=s.length,c=Array(i).fill(-1),u=Array(i).fill(0),h=[],d=new Set;for(let S of s){let E=o.parent.get(S)??null,w=r.get(S);if(w==null)continue;if(E==null){if(c[w]=-1,u[w]=0,!d.has(S))d.add(S),h.push(S)}}while(h.length>0){let S=h.shift(),E=r.get(S);if(E==null)continue;let w=o.children.get(S)??[];for(let C of w){if(d.has(C))continue;let b=r.get(C);if(b==null)continue;c[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=r.get(S);if(E==null)continue;c[E]=-1,u[E]=0,d.add(S)}let m=Math.max(1,Math.ceil(Math.log2(Math.max(1,i)))+1),p=Array.from({length:m},()=>Array(i).fill(-1));for(let S=0;S<i;S++)p[0][S]=c[S];for(let S=1;S<m;S++)for(let E=0;E<i;E++){let w=p[S-1][E];p[S][E]=w===-1?-1:p[S-1][w]}let I=t((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:i},()=>new Map);for(let S of n.edges){let{src:E,dst:w}=S,C=e[E],b=e[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=r.get(E),O=r.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=t((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=t((S)=>{let E=r.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=e[S];if(P!=null){let N=g.get(S);if(!N)N=new Map,g.set(S,N);let H=O.get(P)??0,_=e[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}t(Ds,"computeSubtreeCrossCounts");function Xs(n,e,o){let s=new Map,r=t((i)=>{let c=o[i]??0,u=[...e.get(i)??[]];u.sort(Ao(o));for(let h of u){r(h);let d=s.get(h);if(d!=null)c=Math.min(c,d)}s.set(i,c)},"annotate");for(let i of n)r(i);return s}t(Xs,"annotateMinimumLayers");function Ao(n){return(e,o)=>{let s=n[e]??0,r=n[o]??0;return s===r?e.localeCompare(o):s-r}}t(Ao,"compareByRankThenId");function Ys(n,e,o,s){let r=0;for(let h of e){let d=o[h]??0;if(d>r)r=d}let i=Array.from({length:r+1},()=>[]),c=new Set,u=t((h)=>{if(c.has(h))return;c.add(h);let d=o[h]??0;if(!i[d])i[d]=[];i[d].push(h);for(let m of s(h))u(m)},"emit");for(let h of n)u(h);for(let h of e)if(!c.has(h)){let d=o[h]??0;if(!i[d])i[d]=[];i[d].push(h),c.add(h)}return i}t(Ys,"emitNodesInTreeOrder");function Gs(n){let e=[];for(let o of n){let s=new Set,r=[];for(let i of o){if(s.has(i))continue;s.add(i),r.push(i)}e.push(r)}return e}t(Gs,"deduplicateLayers");function $s(n,e,o,s){return(r)=>{let i=n.get(r)??[];if(i.length===0)return[];let c=e[r]??0,u=[],h=[],d=o.get(r);for(let m of i){let p=s.get(m)??c;if(p>c)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)??c,l=s.get(p)??c;if(g!==l)return g-l;return m.localeCompare(p)}),[...u.map((m)=>m.child),...h]}}t($s,"createChildOrderer");function ce(n,e,o){let s=Bs(n,{rankHint:e,laneOf:o}),{children:r,roots:i}=s;for(let p of n.nodes)if(!r.has(p))r.set(p,[]);let c=Ds(n,e,s),u=[...i].sort(Ao(e)),h=Xs(u,r,e),d=$s(r,e,c,h),m=Ys(u,n.nodes,e,d);return m=Gs(m),m}t(ce,"buildMultitreeLayerOrder");function zs(n,e,o){let s=new Set(n),r=new Set(e),i=Fn(e),c=[];for(let u of o)if(s.has(u.src)&&r.has(u.dst))c.push(i.get(u.dst));return Lo(c)}t(zs,"countCrossingsBetweenAdjacent");function Ze(n,e,o){let s=[];for(let i of e){let c=o[i.src],u=o[i.dst];if(c==null||u==null||c===u)continue;let{src:h,dst:d}=i,m=c,p=u;if(c>u)h=i.dst,d=i.src,m=u,p=c;for(let I=m;I<p;I++)s.push({id:`${i.id}@${I}`,src:h,dst:d,ref:i.ref})}let r=0;for(let i=0;i+1<n.length;i++)r+=zs(n[i],n[i+1],s);return r}t(Ze,"totalCrossings");function Vs(n,e){let o={...e},{preds:s}=de(n),r=hn(n),i=ce(n,o,r),c=Ze(i,n.edges,o),u=ie.MAX_CROSSING_OPTIMIZATION_PASSES;for(let h=0;h<u;h++){let d=!1,m=[...n.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(n,o,r),x=Ze(l,n.edges,o);if(x<c)c=x,d=!0;else o[p]=g}if(!d)break}return o}t(Vs,"optimizeRanksByCrossings");function Us(n,e){let o=hn(n),s=[...n.nodes].sort((r,i)=>(e[r]??0)-(e[i]??0)||r.localeCompare(i));for(let r of s){let i=o(r);if(!i)continue;let c=n.edges.filter((l)=>l.src===r);if(c.length===0)continue;let u=!1,h=0;for(let l of c){let x=o(l.dst);if(x==null||x===i)u=!0;else h++}if(h===0||u)continue;let d=0,m=!1;for(let l of n.edges){if(l.dst!==r)continue;let x=o(l.src);if(!x)continue;if(x===i)m=!0;else d++}if(d>0||!m)continue;let p=e[r]??0,I=p+h,y=0;for(let l of n.edges)if(l.dst===r)y=Math.max(y,(e[l.src]??0)+1);let g=Math.max(p,y,I);if(g!==p)e[r]=g}}t(Us,"adjustCrossLaneSources");function js(n,e){let o=Mn(n),s=_n(o)??[...o.nodes].sort(),r=e?.compactSingleInput??!1,i=hn(o),c=Object.create(null);for(let h of s){let d=Io(o,h),m=e?.ignoreCrossLaneEdges?d.filter((p)=>{let I=i(p.src),y=i(h);if(!I||!y)return!0;return I===y}):d;if(m.length===0)c[h]=0;else if(r&&m.length===1){let p=m[0].src,I=i(p),y=i(h);if(I!==y)c[h]=c[p]??0;else c[h]=(c[p]??0)+1}else{let p=-1/0;for(let I of m)p=Math.max(p,(c[I.src]??0)+1);c[h]=p===-1/0?0:p}}if(e?.optimizeRanksByCrossings??!1)c=Vs(o,c);if(e?.ignoreCrossLaneEdges)Us(o,c);return{layers:ce(o,c,i),rankOf:c,dummy:new Set}}t(js,"assignLayers_LongestPath");function Ws(n,e){let o=Mn(n),r={...js(o,{compactSingleInput:e?.compactSingleInput,ignoreCrossLaneEdges:e?.ignoreCrossLaneEdges,optimizeRanksByCrossings:e?.optimizeRanksByCrossings}).rankOf},i=hn(o),{preds:c,succs:u}=de(o,(g)=>{if(e?.ignoreCrossLaneEdges){let l=i(g.src),x=i(g.dst);if(l&&x&&l!==x)return!1}return!0}),h=_n(o)??[...o.nodes],d=[...h].reverse(),m=t((g,l)=>{let x=0;for(let E of c.get(g)??[])x=Math.max(x,(r[E]??0)+1);let L=Number.POSITIVE_INFINITY,S=u.get(g)??[];if(S.length>0)L=Math.min(...S.map((E)=>(r[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=t((g)=>{let l=!1;for(let x of g){let L=c.get(x)??[],S=u.get(x)??[];if(L.length===0&&S.length===0)continue;let E=L.length>0?L.reduce((R,O)=>R+(r[O]??0)+1,0)/L.length:r[x]??0,w=S.length>0?S.reduce((R,O)=>R+(r[O]??0)-1,0)/S.length:r[x]??0,C=Math.round((E+w)/2),b=m(x,C);if(b!==r[x])r[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 c.get(g)??[])l=Math.max(l,(r[x]??0)+1);if((r[g]??0)<l)r[g]=l}for(let g of d){let l=u.get(g)??[];if(l.length>0){let x=Math.min(...l.map((L)=>(r[L]??0)-1));if((r[g]??0)>x)r[g]=x}}return{layers:vo(o,h,r),rankOf:r,dummy:new Set}}t(Ws,"assignLayers_Gravity");function Ks(n){let e=fe(n),o=So(n),s=Co(n,e),r=[];while(s.length>0){let i=[];for(let c of s){r.push(c);for(let u of o.get(c)??[])if(e.set(u,(e.get(u)??0)-1),(e.get(u)??0)===0)i.push(u)}s=i.sort((c,u)=>c.localeCompare(u))}return r.length===n.nodes.length?r:null}t(Ks,"topoSortByGenerationIfAcyclic");function qs(n,e){let o=Mn(n),s=e?.direction==="LR"?Ks(o)??[...o.nodes].sort():_n(o)??[...o.nodes].sort(),r=hn(o),i=t((m)=>r(m)??m,"laneOf"),c=Object.create(null),u=new Map,h=t((m,p)=>{if(e?.ignoreCrossLaneEdges??!0)return i(m)===i(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=c[S]??0;y=Math.max(y,E+h(S,m))}let g=i(m),l=u.get(g)??0,x=Math.max(y,l);c[m]=x,u.set(g,x+1)}return{layers:vo(o,s,c,{skipGroups:!0}),rankOf:c,dummy:new Set}}t(qs,"assignLayers_LaneAwareCompact");function Js(n,e){let o=Mn(e),{rankOf:s}=n,r=n.layers.map((y)=>[...y]),i=new Set(n.dummy?[...n.dummy]:[]),c=0,u=new Map(o.nodeById),h=t((y)=>{let g=`placeholder-${c++}`,l={id:g,isGroup:!1,isDummy:!0,width:0,height:0};u.set(g,l),i.add(g);while(r.length<=y)r.push([]);return r[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,...[...i].filter((y)=>!o.nodes.includes(y))],edges:m,layout:o.layout,nodeById:u};return{layering:{layers:r,rankOf:s,dummy:i},graphWithDummies:I}}t(Js,"makeProperLayering");function Qe(n){let e=n.length;if(e===0)return Number.POSITIVE_INFINITY;let o=[...n].sort((s,r)=>s-r);if(e%2===1)return o[(e-1)/2];return 0.5*(o[e/2-1]+o[e/2])}t(Qe,"median");function to(n){if(n.length===0)return Number.POSITIVE_INFINITY;return n.reduce((o,s)=>o+s,0)/n.length}t(to,"barycenter");function Zs(n,e,o,s){let r=new Map;for(let i of n)r.set(i,[]);for(let i of o)if(s==="down"){if(e.has(i.src)&&r.has(i.dst))r.get(i.dst).push(e.get(i.src))}else if(e.has(i.dst)&&r.has(i.src))r.get(i.src).push(e.get(i.dst));return r}t(Zs,"neighborPositionsFor");function Qs(n,e,o){let s=o.get(n)??0,r=o.get(e)??0;return s!==r?s-r:n.localeCompare(e)}t(Qs,"currentOrderTieBreak");function no(n,e,o){let s=new Set(n),r=new Set(e),i=Fn(n),c=Fn(e),u=[];for(let d of o)if(s.has(d.src)&&r.has(d.dst))u.push({u:i.get(d.src),v:c.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)}t(no,"countCrossingsBetweenAdjacent");function Zn(n,e,o){return[...n].sort((s,r)=>{let i=Qe(e.get(s)??[]),c=Qe(e.get(r)??[]);if(i===c)return Qs(s,r,o);if(!isFinite(i))return 1;if(!isFinite(c))return-1;return i-c})}t(Zn,"sortByHeuristic");function eo(n,e,o,s,r,i){let c=Fn(n),u=Fn(e),h=Zs(e,c,o,s);if(!r||!i||i.length===0)return Zn(e,h,u);let d=new Map;for(let I of e){let y=r(I),g=d.get(y)??[];g.push(I),d.set(y,g)}let m=[];for(let I of i){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}t(eo,"reorderLayer");function oo(n,e,o,s,r){let i=[...e],c=new Set(n),u=new Set(e),h=s?new Set(s):null,d=o.filter((l)=>c.has(l.src)&&u.has(l.dst)),m=h?o.filter((l)=>u.has(l.src)&&h.has(l.dst)):void 0,p=t((l)=>{let x=no(n,l,d);if(m&&s)x+=no(l,s,m);return x},"crossingScore"),I=r?new Map:null;if(r&&I)for(let l of e)I.set(l,r(l));let y=!0,g=p(i);while(y){y=!1;for(let l=0;l+1<i.length;l++){if(I){let S=I.get(i[l]),E=I.get(i[l+1]);if(S!==E)continue}let x=g;[i[l],i[l+1]]=[i[l+1],i[l]];let L=p(i);if(L<x)g=L,y=!0;else[i[l],i[l+1]]=[i[l+1],i[l]]}}return i}t(oo,"transposeImprove");function tr(n,e,o){let s=n.layers.map((u)=>[...u]),r=e.edges,i=hn(e),c=Eo(e,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],r,"down",i,c),s[h]=oo(s[h-1],s[h],r,s[h+1],i);for(let h=s.length-2;h>=0;h--)s[h]=eo(s[h+1],s[h],r,"up",i,c),s[h]=oo(s[h+1],s[h],r,s[h-1],i)}return{layers:s}}t(tr,"orderLayers");function nr(n,e,o){let s=o?.layerGap??Uo.DEFAULT_LAYER_GAP,r=o?.nodeGap??Uo.DEFAULT_NODE_GAP,i=o?.laneGap??r*2,c=o?.direction??"TB",u=c==="LR"||c==="RL",h=n.layers,d=Object.create(null),m=Object.create(null),p=t((N)=>e.nodeById.get(N),"getNode"),I=t((N)=>p(N)?.width??0,"getWidth"),y=t((N)=>p(N)?.height??0,"getHeight"),g=hn(e),l=Eo(e,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)+r*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)+r*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)+i*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)_+=i}}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)+r*(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+r}}}let Y=L[N]??0;O+=_+s+Y}let P=new Map;for(let N of e.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(e.nodeById.get(J)?.isDummy)d[J]=Y}}return{x:d,y:m}}t(nr,"assignCoordinates");var er=8;function or(n){let e=2166136261;for(let o=0;o<n.length;o++)e^=n.charCodeAt(o),e=Math.imul(e,16777619);return e>>>0}t(or,"hashString");function sr(n){let e=n>>>0;return()=>{e+=1831565813;let o=e;return o=Math.imul(o^o>>>15,o|1),o^=o+Math.imul(o^o>>>7,o|61),((o^o>>>14)>>>0)/4294967296}}t(sr,"mulberry32");function rr(n,e){let o=[...n],s=sr(e);for(let r=o.length-1;r>0;r--){let i=Math.floor(s()*(r+1));[o[r],o[i]]=[o[i],o[r]]}return o}t(rr,"deterministicShuffle");function ir(n,e){let o=0;for(let[s,r]of n.entries())o+=Math.abs(s-(e.get(r)??s));return o}t(ir,"sourceDistance");function so(n,e){let o=new Map;for(let[r,i]of n.entries())o.set(i,r);let s=0;for(let{a:r,b:i,weight:c}of e){let u=o.get(r),h=o.get(i);if(u==null||h==null)continue;s+=c*Math.abs(u-h)}return s}t(so,"laneArrangementCost");function cr(n){let e=ue(n);if(e.length<2)return[];let o=new Map(e.map((i,c)=>[i,c])),s=hn(n),r=new Map;for(let i of n.layout.edges??[]){if(i.isLayoutOnly)continue;let c=typeof i.start==="string"?i.start:void 0,u=typeof i.end==="string"?i.end:void 0;if(!c||!u||!n.nodeById.has(c)||!n.nodeById.has(u))continue;let h=s(c),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=r.get(g);if(l)l.weight++;else r.set(g,{a:I,b:y,weight:1})}return[...r.values()]}t(cr,"buildWeightedLaneEdges");function ro(n,e,o){let s=[...n],r=so(s,e),i=!0,c=0,u=Math.max(1,s.length);while(i&&c<u){i=!1,c++;for(let h=0;h+1<s.length;h++){[s[h],s[h+1]]=[s[h+1],s[h]];let d=so(s,e);if(d<r)r=d,i=!0;else[s[h],s[h+1]]=[s[h+1],s[h]]}}return{order:s,cost:r,sourceDistance:ir(s,o)}}t(ro,"greedySwitch");function ar(n,e){if(n.cost!==e.cost)return n.cost<e.cost;return n.sourceDistance<e.sourceDistance}t(ar,"isBetterCandidate");function fr(n,e,o){let s=[...e].sort((r,i)=>r.a===i.a?r.b.localeCompare(i.b):r.a.localeCompare(i.a)).map(({a:r,b:i,weight:c})=>`${r}:${i}:${c}`).join("|");return or(`${n.join("|")}#${s}#${o}`)}t(fr,"seedForRestart");function dr(n,e={}){let o=ue(n);if(o.length<2)return o;let s=cr(n);if(s.length===0)return o;let r=new Map(o.map((u,h)=>[u,h])),i=ro(o,s,r),c=Math.max(0,e.restarts??er);for(let u=0;u<c;u++){let h=fr(o,s,u),d=rr(o,h),m=ro(d,s,r);if(ar(m,i))i=m}return i.order}t(dr,"optimizeTopLaneOrder");function ur(n,e){let o=e?.ignoreCrossLaneEdges??!0,s=e?.optimizeRanksByCrossings??!0,r=Mn(n),i=e?.automaticLaneOrdering?dr(r,{restarts:er}):void 0,c=Ns(r),u=c.acyclic,h=o?qs(u,{compactSingleInput:e?.compactSingleInput??ie.DEFAULT_COMPACT_SINGLE_INPUT,ignoreCrossLaneEdges:!0,direction:e?.direction}):Ws(u,{compactSingleInput:e?.compactSingleInput??ie.DEFAULT_COMPACT_SINGLE_INPUT,ignoreCrossLaneEdges:!1,optimizeRanksByCrossings:s}),{layering:d,graphWithDummies:m}=Js(h,u),p=tr(d,m,{laneOrder:i}),I=nr(p,m,{layerGap:e?.layerGap,nodeGap:e?.nodeGap,direction:e?.direction,laneOrder:i});return{acyclic:u,reversed:c.reversed,layering:d,ordered:p,coordinates:I}}t(ur,"sugiyamaLayout");var ft=Hr.EPSILON,Dr=8,Sn=15,Nn=15,qn=25,sn=20,Re=10;function io(n,e,o){let s=n.x??0,r=n.y??0,i=e.x-s,c=e.y-r,u=Math.abs(i),h=Math.abs(c);if(u<ft&&h<ft)return o;let d=3;if(h>ft&&h*d>=u)return c>0?"bottom":"top";if(u>ft)return i>0?"right":"left";return o}t(io,"chooseOrthogonalSide");function co(n,e){return Math.abs(n.to-e.from)<ft||Math.abs(n.to-e.to)<ft?n.to:n.from}t(co,"sharedLineEndpointCoord");function Cn(n,e){return n.orient==="vertical"?{x:n.coord,y:e}:{x:e,y:n.coord}}t(Cn,"pointOnLine");function hr(n,e){let o=n.nodes??[],s=n.edges??[],r=[];for(let f of s){if(f.isLayoutOnly)continue;r.push({...f,__originalEdge:f})}let i=new Map,c=new Map,u=[],h=e==="LR";for(let f of o)i.set(f.id,f);let d=o.filter((f)=>f.isGroup&&!f.parentId);for(let f of d){let M={id:f.id},v=t((A)=>{c.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=t((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=t((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=t((f,M,v)=>I(f,io(f,M,v?"bottom":"top")),"getOrthogonalPort"),g=[],l=[],x=new Set,L=1000,S=t((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=r.map((f,M)=>{if(!f.start||!f.end)return{idx:M,crossLane:0,dx:0,dy:0};let v=i.get(f.start),A=i.get(f.end),T=c.get(f.start),k=c.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=t((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 r){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=t((f,M)=>io(f,M,"bottom"),"determineSide"),O=new Map;for(let[f,M]of r.entries()){if(!M.start||!M.end||M.start===M.end)continue;if(M.points&&M.points.length>0)continue;let v=i.get(M.start),A=i.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=t((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=t((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=t((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=t((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(i.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=i.get(v),Q=i.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=i.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=t((f)=>Boolean(r[f]?.labelNodeId),"edgeHasLabelNode"),Ot=t((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=t((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=t((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=r[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=i.get(M.start),A=i.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=t((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=t((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=t((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=t((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=t((_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=t((_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=t((f,M)=>f.from<M.to&&M.from<f.to,"segmentsOverlap"),ot=t((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=t((f)=>{let M=f.tracks.length;return f.tracks[M]={index:M,coord:f.coord,segments:[]},M},"createNewTrack"),mt=t((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=t((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=t((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=t((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=t((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=t((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=t((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=t((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=t((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=t(()=>{let f=0,M=new Map;for(let[A,T]of r.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=t((A)=>{let T=r[A];if(!T.start||!T.end)return 0;let k=i.get(T.start),K=i.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=t(()=>{let f=0,M=new Map;for(let[v,A]of r.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=t((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=t(()=>{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=t((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 r.entries()){let v=l[f]??[];if(v.length===0)continue;let A=[],T=i.get(M.start),k=i.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 r){let M=f.__originalEdge;if(M&&f.points)M.points=f.points}n.edges=(n.edges??[]).filter((f)=>!f.isLayoutOnly);let W=t((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 n.edges){let M=f.points;if(!M||M.length<2)continue;let{start:v,end:A}=f,T=v?i.get(v):void 0,k=A?i.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 n}t(hr,"routeEdgesOrthogonal");function gr(n){return n.direction??"TB"}t(gr,"getSwimlaneDirection");function pr(n){let e=qo(n),o=n.config.flowchart?.nodeSpacing??40,s=n.config.flowchart?.rankSpacing??100,r=n.config.swimlane?.ignoreCrossLaneEdges??!0,i=n.config.swimlane?.optimizeRanksByCrossings??!0,c=n.config.swimlane?.automaticLaneOrdering??!1,u=gr(n),{ordered:h,coordinates:d}=ur(e,{nodeGap:o,layerGap:s,ignoreCrossLaneEdges:r,optimizeRanksByCrossings:i,automaticLaneOrdering:c,direction:u});Jo(e,h,d,{nodeGap:o,layerGap:s});for(let m of n.edges??[])delete m.points;hr(n,u);for(let m of n.edges??[])if(!m.curve||m.curve==="basis")m.curve="rounded";return Ts(n,u),Rs(n),u}t(pr,"runSwimlaneLayoutCore");function mr(n){Ko(n);let e=Zo(n);n.nodes=e.nodes,n.edges=e.edges}t(mr,"prepareSwimlaneLayout");var oi=lr({prepareLayout:mr,runLayoutCore:pr,afterPaint:jo});export{oi as render};