@shaohui_jin/git-cockpit-mcp-server 0.1.27 → 0.1.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-HWO2V3M5.js → chunk-DK7VEJFY.js} +2 -2
- package/dist/{chunk-HWO2V3M5.js.map → chunk-DK7VEJFY.js.map} +1 -1
- package/dist/{chunk-3ALI2CBW.js → chunk-HXRA3DSL.js} +3 -3
- package/dist/{chunk-G6SEOLMU.js → chunk-OSTBV522.js} +144 -19
- package/dist/chunk-OSTBV522.js.map +1 -0
- package/dist/cli-entry.js +3 -3
- package/dist/cli.js +3 -3
- package/dist/index.js +3 -3
- package/dist/mcpServer.js +1 -1
- package/dist/web/assets/{abnfDiagram-O67JEVCF-Cpmc29Vo.js → abnfDiagram-O67JEVCF-BxKTIPvt.js} +1 -1
- package/dist/web/assets/{arc-C4CdJ3cz.js → arc-BFKkJjPp.js} +1 -1
- package/dist/web/assets/{architectureDiagram-NJMV4G6O-D-3EH44b.js → architectureDiagram-NJMV4G6O-DwuGbjcP.js} +1 -1
- package/dist/web/assets/{blockDiagram-BEXU5L5S-4o8DaZHq.js → blockDiagram-BEXU5L5S-DQtfpBon.js} +1 -1
- package/dist/web/assets/{c4Diagram-YGBWAQC7-DLufKbff.js → c4Diagram-YGBWAQC7-DQEx6b-X.js} +1 -1
- package/dist/web/assets/channel-SnOBxP58.js +1 -0
- package/dist/web/assets/{chunk-2Q5K7J3B-dEtvq-Sm.js → chunk-2Q5K7J3B-BZZAc8A2.js} +1 -1
- package/dist/web/assets/{chunk-3FUC2YCW-D8IY6i0n.js → chunk-3FUC2YCW-BKsUOX0P.js} +2 -2
- package/dist/web/assets/{chunk-5VM5RSS4-DTtnT10M.js → chunk-5VM5RSS4-DS8_TMNo.js} +1 -1
- package/dist/web/assets/{chunk-GTNCS2PH-CRKiRt85.js → chunk-GTNCS2PH-upTfZMjS.js} +1 -1
- package/dist/web/assets/{chunk-GWA4HPMP-CapkHNd2.js → chunk-GWA4HPMP-BKqnDCMe.js} +1 -1
- package/dist/web/assets/{chunk-JWPE2WC7-D1qG9232.js → chunk-JWPE2WC7-DRg2DW5G.js} +1 -1
- package/dist/web/assets/{chunk-NETBCI7D-Cf5bzyqy.js → chunk-NETBCI7D-D-NIf3Jh.js} +1 -1
- package/dist/web/assets/{chunk-WEXAMYUT-aMK135IE.js → chunk-WEXAMYUT-C-ODRuff.js} +1 -1
- package/dist/web/assets/{chunk-XXDRQBXY-DKObcU_j.js → chunk-XXDRQBXY-CyL5e2d_.js} +1 -1
- package/dist/web/assets/{classDiagram-v2-NBCMYWYE-BFKjdANY.js → classDiagram-v2-NBCMYWYE-CK5THZs3.js} +1 -1
- package/dist/web/assets/{cose-bilkent-JH36ORCC-Bbl702qf.js → cose-bilkent-JH36ORCC-02-3CpJi.js} +1 -1
- package/dist/web/assets/{cynefin-OW5HDTMX-BwkqOigD.js → cynefin-OW5HDTMX-CAexhoXe.js} +1 -1
- package/dist/web/assets/{cynefinDiagram-VND7K2PF-C032B141.js → cynefinDiagram-VND7K2PF-BJF_eeoU.js} +1 -1
- package/dist/web/assets/{dagre-6A5THRUB-mtU2etOs.js → dagre-6A5THRUB-C6GL7ERH.js} +1 -1
- package/dist/web/assets/{diagram-22UHCM2B-Bhef_gli.js → diagram-22UHCM2B-Ds8n2rH1.js} +1 -1
- package/dist/web/assets/{diagram-3UASUU5V-Bt5jGMJj.js → diagram-3UASUU5V-Dqf7ZoXN.js} +1 -1
- package/dist/web/assets/{diagram-ATOU4E4O-E9OEgrvO.js → diagram-ATOU4E4O-m7aUBWki.js} +1 -1
- package/dist/web/assets/{diagram-CDSNMT55-Ev4KURRW.js → diagram-CDSNMT55-DRH4aoMQ.js} +1 -1
- package/dist/web/assets/{diagram-MLGK6HIB-VyRxPiEM.js → diagram-MLGK6HIB-BcpYvpQA.js} +1 -1
- package/dist/web/assets/{diagram-MPIPVDR6-NZUHIzSK.js → diagram-MPIPVDR6-Bi0PAW2v.js} +1 -1
- package/dist/web/assets/{ebnfDiagram-ZINNZB2B-BWrpXmAB.js → ebnfDiagram-ZINNZB2B-qlPQrozl.js} +1 -1
- package/dist/web/assets/{elk-276RUBZZ-BGHyKt3X.js → elk-276RUBZZ-DMAkKBgQ.js} +1 -1
- package/dist/web/assets/{erDiagram-OPXOYQCR-GrSAUtcQ.js → erDiagram-OPXOYQCR-Twfp1387.js} +1 -1
- package/dist/web/assets/{flowDiagram-KWPJA3E3-B_WVUUVf.js → flowDiagram-KWPJA3E3-C2dUfvWx.js} +1 -1
- package/dist/web/assets/{ganttDiagram-FUAMR5RP-DajvFrX3.js → ganttDiagram-FUAMR5RP-BaPxeXq3.js} +1 -1
- package/dist/web/assets/{gitGraphDiagram-X574FWY7-CrHV5Rvk.js → gitGraphDiagram-X574FWY7-_hPb8CT4.js} +1 -1
- package/dist/web/assets/{index-DNSP9H_v.js → index-BFkHoNBz.js} +148 -147
- package/dist/web/assets/{index-COls5qGF.css → index-DYyaZxyF.css} +1 -1
- package/dist/web/assets/{infoDiagram-VRGFBTTK-BVr7SUMq.js → infoDiagram-VRGFBTTK-Du4dCYJ4.js} +1 -1
- package/dist/web/assets/{ishikawaDiagram-OU5B5YK6-Clo1T4Ou.js → ishikawaDiagram-OU5B5YK6-DDKBcmep.js} +1 -1
- package/dist/web/assets/{journeyDiagram-ZHPQQLJL-BJJiqW1W.js → journeyDiagram-ZHPQQLJL-CL0kUw14.js} +1 -1
- package/dist/web/assets/{kanban-definition-PNTS6WVX-FIP6aaWx.js → kanban-definition-PNTS6WVX-BEE1vcNj.js} +1 -1
- package/dist/web/assets/{linear-gNF2RYPF.js → linear-Dub9pXXw.js} +1 -1
- package/dist/web/assets/{mindmap-definition-NLK3R4M7-U9ZgUluP.js → mindmap-definition-NLK3R4M7-DoKDp1pJ.js} +1 -1
- package/dist/web/assets/{pegDiagram-GJSIUBJH-kqET45uW.js → pegDiagram-GJSIUBJH-ODJ_Yd0b.js} +1 -1
- package/dist/web/assets/{pieDiagram-5QR66LMP-0Vfqg8YJ.js → pieDiagram-5QR66LMP-Cmyperfp.js} +1 -1
- package/dist/web/assets/{quadrantDiagram-O4NWA36T-BwbgrFii.js → quadrantDiagram-O4NWA36T-aypd2R_C.js} +1 -1
- package/dist/web/assets/{railroadDiagram-XR7U4H2S-AQGvMbOL.js → railroadDiagram-XR7U4H2S-BI36mUxb.js} +1 -1
- package/dist/web/assets/{requirementDiagram-PLB6GJNP-WJNa_ucq.js → requirementDiagram-PLB6GJNP-DMp_AH1O.js} +1 -1
- package/dist/web/assets/{sankeyDiagram-IPEJSGJF-DTOl4R33.js → sankeyDiagram-IPEJSGJF-CYcGOg3G.js} +1 -1
- package/dist/web/assets/{sequenceDiagram-PO4LG4MO-4xQidS78.js → sequenceDiagram-PO4LG4MO-ChZB8RbV.js} +1 -1
- package/dist/web/assets/{sizeCapture-INFHLROL--JObXzuK.js → sizeCapture-INFHLROL-BqqVL3Rt.js} +1 -1
- package/dist/web/assets/{stateDiagram-v2-GCMORJYK-DO54xQHQ.js → stateDiagram-v2-GCMORJYK-DZvh8NA2.js} +1 -1
- package/dist/web/assets/{swimlanes-2SLR337P-D2RfEaDP.js → swimlanes-2SLR337P-B2UuTxFK.js} +1 -1
- package/dist/web/assets/swimlanesDiagram-TC7HE7FX-BoTo_Fcu.js +8 -0
- package/dist/web/assets/{timeline-definition-EJHVYXUP-CjEGHstB.js → timeline-definition-EJHVYXUP-C_eH7hMc.js} +1 -1
- package/dist/web/assets/{usecaseDiagram-POWQR4AR-B_QSF3HN.js → usecaseDiagram-POWQR4AR-yPvynT6u.js} +1 -1
- package/dist/web/assets/{vennDiagram-UO4OBE2U-DaXBK4lA.js → vennDiagram-UO4OBE2U-8NH9xysg.js} +1 -1
- package/dist/web/assets/{wardleyDiagram-VNRHLVJA-DAcGG1ul.js → wardleyDiagram-VNRHLVJA-8YoREFYM.js} +1 -1
- package/dist/web/assets/{xychartDiagram-PMCCYNJV-C9NMkFcl.js → xychartDiagram-PMCCYNJV-Bjj7znot.js} +1 -1
- package/dist/web/index.html +2 -2
- package/dist/webServer.js +2 -2
- package/package.json +2 -2
- package/dist/chunk-G6SEOLMU.js.map +0 -1
- package/dist/web/assets/channel-D3CmON_0.js +0 -1
- package/dist/web/assets/swimlanesDiagram-TC7HE7FX-BTVqf00K.js +0 -8
- /package/dist/{chunk-3ALI2CBW.js.map → chunk-HXRA3DSL.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as ar}from"./chunk-NETBCI7D-Cf5bzyqy.js";import{c as lr}from"./chunk-3FUC2YCW-D8IY6i0n.js";import{_ as l,l as Mn}from"./index-DNSP9H_v.js";import"./graph-DcfhsBxO.js";import"./element-plus-IBMLLhb-.js";import"./vue-BhwNxZ68.js";function Ao(t,{measure:e}){var r,c;const n=(c=(r=t.config)==null?void 0:r.swimlane)==null?void 0:c.lineHops;if(n===!1)return;const o=n==="gap"?"gap":"arc",s=t.edges.filter(a=>Array.isArray(a.points)&&a.points.length>=2).map(a=>({id:a.id,points:a.points,curve:a.curve,arrowTypeStart:a.arrowTypeStart,arrowTypeEnd:a.arrowTypeEnd}));ar(e.groups.edgePaths,s,{enabled:!0,jumpRadius:6,jumpStyle:o})}l(Ao,"applySwimlaneLineJumps");var yn="__swimlane_default__",fr=21,vo=20;function Sn(t){return Math.max(t.padding??vo,vo)}l(Sn,"topLaneHorizontalPadding");function Ro(t){const{x:e,y:n,width:o,height:s}=t,r=t.swimlaneContentTop;if(typeof e!="number"||typeof n!="number"||typeof o!="number"||typeof s!="number"||typeof r!="number"||!Number.isFinite(e)||!Number.isFinite(n)||!Number.isFinite(o)||!Number.isFinite(s)||!Number.isFinite(r)||o<=0||s<=0){delete t.groupTitleRect;return}const c=n-s/2,a=Math.min(r,n+s/2),f=Math.min(fr,Math.max(0,a-c)),h=c+f;if(h<=c){delete t.groupTitleRect;return}t.groupTitleRect={left:e-o/2,right:e+o/2,top:c,bottom:h}}l(Ro,"assignTopLaneTitleRect");function No(t){var r;const e=t.direction,n=t.nodes??(t.nodes=[]);for(const c of t.nodes??[])c.isGroup&&!c.parentId&&(c.shape="swimlane",e&&(c.direction=e));const o=n.filter(c=>!c.isGroup&&!c.parentId);if(o.length===0)return;let s=n.find(c=>c.id===yn);s?s.isGroup&&(s.shape="swimlane",e&&(s.direction=e)):(s={id:yn,label:"",isGroup:!0,shape:"swimlane",padding:20,look:(r=t.config)==null?void 0:r.look,colorIndex:n.reduce((c,a)=>Math.max(c,a.colorIndex??-1),-1)+1,...e?{direction:e}:{}},n.push(s));for(const c of o)c.parentId=yn}l(No,"prepareLayoutForSwimlanes");function Oo(t){const e=new Map;for(const f of t.nodes??[])e.set(f.id,f);const n=[];for(const f of t.edges??[]){const h=typeof f.start=="string"?f.start:void 0,p=typeof f.end=="string"?f.end:void 0;!h||!p||f.labelNodeId||n.push({id:f.id,src:h,dst:p,ref:f})}const o=t.nodes??[],s=o.filter(f=>f.isGroup),r=o.filter(f=>!f.isGroup);return{nodes:[...[...s].reverse(),...r].map(f=>f.id),edges:n,layout:t,nodeById:e}}l(Oo,"toGraphView");function Bo(t,e,n,o){const{layout:s}=t,r=t.nodeById,c=(o==null?void 0:o.layerGap)??100,a=(o==null?void 0:o.nodeGap)??40;let f=0;for(const S of e.layers){let d=0;for(const u of S){const i=r.get(u);if(!i){d++;continue}i.layer=f,i.order=d;const y=n.x[u]??d*a,C=n.y[u]??f*c;i.x=y,i.y=C,d++}f++}const h=s.nodes??[],p=new Map,x=[];for(const S of h){if(!(S!=null&&S.isGroup))continue;S.parentId||x.push(S);const d=h.filter(b=>b.parentId===S.id);let u=1/0,i=-1/0,y=1/0,C=-1/0;for(const b of d){const L=b.x??n.x[b.id],v=b.y??n.y[b.id],m=b.width??0,I=b.height??0;L!=null&&v!=null&&(u=Math.min(u,L-m/2),i=Math.max(i,L+m/2),y=Math.min(y,v-I/2),C=Math.max(C,v+I/2))}if(u===1/0||y===1/0)S.x=S.x??0,S.y=S.y??0,S.width=S.width??0,S.height=S.height??0;else{const b=S.padding??20,L=S.parentId?b:2*Sn(S),v=b,m=Math.max(0,i-u)+L,I=Math.max(0,C-y)+v,T=(u+i)/2,A=(y+C)/2;S.x=T,S.y=A,S.width=m,S.height=I,p.set(S.id,{minX:u,maxX:i,minY:y,maxY:C})}}if(x.length>0&&p.size>0){let S=1/0,d=-1/0,u=0;for(const i of x){const y=i.padding??20;y>u&&(u=y);const C=p.get(i.id);C&&(S=Math.min(S,C.minY),d=Math.max(d,C.maxY))}if(S!==1/0&&d!==-1/0){const i=Math.max(0,d-S),C=Math.max(u,36),b=i+2*C,L=(S+d)/2;for(const P of x)P.y=L,P.height=b,P.swimlaneContentTop=S;const v=[...x].sort((P,O)=>{const k=P.x??0,D=O.x??0;return k-D}),m=[],I=[],T=[];for(const P of v){const O=p.get(P.id);if(!O)continue;const k=Math.max(0,O.maxX-O.minX)+2*Sn(P),D=(O.minX+O.maxX)/2;m.push(P.id),I.push(D),T.push(k)}const A=m.length;if(A>0){const P=new Map;if(A===1)P.set(m[0],T[0]);else{const O=[];for(let j=0;j<A-1;j++)O.push(I[j+1]-I[j]);const k=new Array(A);k[0]=0;for(let j=0;j<A-1;j++)k[j+1]=2*O[j]-k[j];let D=0,B=Number.POSITIVE_INFINITY;for(let j=0;j<A;j++){const tt=T[j];j%2===0?D=Math.max(D,tt-k[j]):B=Math.min(B,k[j]-tt)}let G=D;D<=B?G=(D+B)/2:G=D;for(let j=0;j<A;j++){const tt=k[j]+(j%2===0?G:-G),ft=Math.max(T[j],tt);P.set(m[j],ft)}}for(const O of x){const k=P.get(O.id);k!=null&&(O.width=k),Ro(O)}}}}}l(Bo,"writeBackToLayoutData");var dr="[EdgeLabelNodes]";function Po(t){const e=[],n=[],o=new Map;for(const c of t.nodes)o.set(c.id,c);for(const c of t.edges){if(!c.label||c.label.length===0||c.isLayoutOnly||c.labelNodeId)continue;const a=c.start?o.get(c.start):void 0,f=c.end?o.get(c.end):void 0;if(!a||!f){Mn.warn(dr,`Edge ${c.id} has missing source or target node`);continue}const h=`edge-label-${c.start}-${c.end}-${c.id}`,x=a.parentId!==f.parentId?f.parentId:a.parentId,S={id:h,label:c.label,edgeStart:c.start??"",edgeEnd:c.end??"",shape:"labelRect",width:0,height:0,isEdgeLabel:!0,isDummy:!0,parentId:x,isGroup:!1,labelStyle:Array.isArray(c.labelStyle)?c.labelStyle[0]:c.labelStyle??"",...a.dir?{dir:a.dir}:{}};e.push(S),c.labelNodeId=h,c.label=void 0,c.text=void 0;const d={id:`${c.id}-to-label`,start:c.start,end:h,type:"normal",isLayoutOnly:!0},u={id:`${c.id}-from-label`,start:h,end:c.end,type:"normal",isLayoutOnly:!0};n.push(d,u)}const s=[...t.nodes,...e],r=[...t.edges,...n];return{...t,nodes:s,edges:r}}l(Po,"createEdgeLabelNodes");var Yt=.001;function Qn(t){const e=t.x??0,n=t.y??0,o=t.width??0,s=t.height??0;return o>0&&s>0?{cx:e,cy:n,rect:Ne(e,n,o,s)}:void 0}l(Qn,"measuredNodeRect");function to(t){if(t.isGroup)return;const e=Qn(t);return e?{id:String(t.id??""),cx:e.cx,cy:e.cy,rect:e.rect}:void 0}l(to,"nodeBoundsInfoFor");function ce(t,e,n=Yt){return Math.abs(t.x-e.x)<n&&Math.abs(t.y-e.y)<n}l(ce,"samePoint");function gt(t,e,n=Yt){return Math.abs(t.x-e.x)<n}l(gt,"sameX");function xt(t,e,n=Yt){return Math.abs(t.y-e.y)<n}l(xt,"sameY");function Nt(t,e,n=Yt){return xt(t,e,n)&&Math.abs(t.x-e.x)>n}l(Nt,"isHorizontalSegment");function Ot(t,e,n=Yt){return gt(t,e,n)&&Math.abs(t.y-e.y)>n}l(Ot,"isVerticalSegment");function Wt(t,e,n,o){return Math.max(0,Math.min(Math.max(t,e),Math.max(n,o))-Math.max(Math.min(t,e),Math.min(n,o)))}l(Wt,"overlapLength");function fe(t,e,n=Yt){return t.horizontal&&e.horizontal&&xt(t.a,e.a,n)?Wt(t.a.x,t.b.x,e.a.x,e.b.x):t.vertical&&e.vertical&>(t.a,e.a,n)?Wt(t.a.y,t.b.y,e.a.y,e.b.y):0}l(fe,"sameAxisSegmentOverlapLength");function Oe(t,e=Yt){const n=[];for(let o=0;o<t.length-1;o++){const s=t[o],r=t[o+1],c=Nt(s,r,e),a=Ot(s,r,e);(c||a)&&n.push({index:o,a:s,b:r,horizontal:c,vertical:a})}return n}l(Oe,"orthogonalSegmentsForPoints");function oe(t,e=Yt){const n=Oe(t,e);let o=0;for(let s=1;s<n.length;s++)n[s-1].horizontal!==n[s].horizontal&&o++;return o}l(oe,"countOrthogonalBends");function pt(t,e=Yt){const n=[];for(const o of t){const s=n.length>0?n[n.length-1]:void 0;(!s||!ce(s,o,e))&&n.push({x:o.x,y:o.y})}return n}l(pt,"dedupeConsecutivePoints");function eo(t,e=Yt){if(!t||t.length!==4)return;const[n,o,s,r]=t;return Nt(n,o,e)&&Ot(o,s,e)&&Nt(s,r,e)?{kind:"HVH",p0:n,p1:o,p2:s,p3:r}:Ot(n,o,e)&&Nt(o,s,e)&&Ot(s,r,e)?{kind:"VHV",p0:n,p1:o,p2:s,p3:r}:void 0}l(eo,"classifyThreeSegmentRoute");function nn(t,e,n,o=0){const s=Math.min(t.x,e.x),r=Math.max(t.x,e.x),c=Math.min(t.y,e.y),a=Math.max(t.y,e.y);return r>n.left-o&&s<n.right+o&&a>n.top-o&&c<n.bottom+o}l(nn,"segmentBoundsOverlapRect");function no(t,e,n=0){return t.x>e.left+n&&t.x<e.right-n&&t.y>e.top+n&&t.y<e.bottom-n}l(no,"pointInsideRect");function ko(t,e){return t.left<=e.left&&t.right>=e.right&&t.top<=e.top&&t.bottom>=e.bottom}l(ko,"rectContainsRect");function Ue(t,e){return t.left<e.right&&t.right>e.left&&t.top<e.bottom&&t.bottom>e.top}l(Ue,"rectsOverlap");function Cn(t,e){return{left:t.left-e,right:t.right+e,top:t.top-e,bottom:t.bottom+e}}l(Cn,"inflateRect");function Ne(t,e,n,o){return{left:t-n/2,right:t+n/2,top:e-o/2,bottom:e+o/2}}l(Ne,"rectFromCenterSize");function te(t){var e;return(e=Qn(t))==null?void 0:e.rect}l(te,"rectOfNodeBounds");function ve(t,e){switch(e){case"top":return{x:t.cx,y:t.rect.top};case"bottom":return{x:t.cx,y:t.rect.bottom};case"left":return{x:t.rect.left,y:t.cy};case"right":return{x:t.rect.right,y:t.cy}}}l(ve,"portForRectSide");function oo(t,e,n,o,s,r=Yt){const c=e==="left"||e==="right",a=o==="left"||o==="right";if(c&&a){if(e==="right"&&o==="left"&&t.x<n.x||e==="left"&&o==="right"&&t.x>n.x){if(xt(t,n,r))return[t,n];const x=(t.x+n.x)/2;return[t,{x,y:t.y},{x,y:n.y},n]}if(e===o){if(xt(t,n,r))return;const x=e==="left"?Math.min(t.x,n.x)-s:Math.max(t.x,n.x)+s;return[t,{x,y:t.y},{x,y:n.y},n]}return}if(!c&&!a){if(e===o){if(gt(t,n,r))return;const S=e==="top"?Math.min(t.y,n.y)-s:Math.max(t.y,n.y)+s;return[t,{x:t.x,y:S},{x:n.x,y:S},n]}if(!(e==="bottom"&&o==="top"&&t.y<n.y||e==="top"&&o==="bottom"&&t.y>n.y))return;if(gt(t,n,r))return[t,n];const x=(t.y+n.y)/2;return[t,{x:t.x,y:x},{x:n.x,y:x},n]}if(c&&!a){const p=e==="right"&&n.x>t.x||e==="left"&&n.x<t.x,x=o==="top"&&t.y<n.y||o==="bottom"&&t.y>n.y;return p&&x?[t,{x:n.x,y:t.y},n]:void 0}const f=e==="bottom"&&n.y>t.y||e==="top"&&n.y<t.y,h=o==="left"&&t.x<n.x||o==="right"&&t.x>n.x;return f&&h?[t,{x:t.x,y:n.y},n]:void 0}l(oo,"buildOrthogonalPortPath");function so(t,e,n,o){return e==="left"||e==="right"?[t,{x:o,y:t.y},{x:o,y:n.y},n]:[t,{x:t.x,y:o},{x:n.x,y:o},n]}l(so,"buildSameSideTrackPath");function on(t){const e=new Map,n=[];for(const o of t){if(o.isEdgeLabel)continue;const s=to(o);s&&(e.set(s.id,s),n.push({id:s.id,rect:s.rect}))}return{nodeInfoById:e,realNodeRects:n}}l(on,"collectRealNodeBounds");function be(t){const e=[],n=[];for(const o of t){const s=to(o);if(!s)continue;const r={id:s.id,rect:s.rect};o.isEdgeLabel?n.push(r):e.push(r)}return{realNodeRects:e,labelNodeRects:n}}l(be,"collectNodeRectEntries");function Fo(t,{includeEdgeLabels:e=!0}={}){const n=[];for(const o of t){if(o.isGroup||!e&&o.isEdgeLabel)continue;const s=o.x??0,r=o.y??0,c=o.width??0,a=o.height??0;n.push({nodeId:o.id,...Ne(s,r,c,a)})}return n}l(Fo,"collectLayoutNodeRects");function ro(t,e,n=Yt){const o=t.start,s=t.end;if(!o||!s)return;const r=e.get(o),c=e.get(s);if(!(!r||!c))return{srcId:o,dstId:s,srcInfo:r,dstInfo:c,collinearX:Math.abs(r.cx-c.cx)<n,collinearY:Math.abs(r.cy-c.cy)<n}}l(ro,"getNodePairGeometry");function Bt(t,e,n,o=[],s=0){for(const r of n)if(!o.includes(r.id)&&nn(t,e,r.rect,-s))return!0;return!1}l(Bt,"segmentHitsAnyRect");function io(t,e,n,o,s=Yt,r=1e-6){const c=xt(t,e,s),a=gt(t,e,s),f=xt(n,o,s),h=gt(n,o,s);if(c&&f||a&&h||!(c||a)||!(f||h))return!1;const p=c?{a:t,b:e}:{a:n,b:o},x=a?{a:t,b:e}:{a:n,b:o},S=p.a.y,d=Math.min(p.a.x,p.b.x),u=Math.max(p.a.x,p.b.x),i=x.a.x,y=Math.min(x.a.y,x.b.y),C=Math.max(x.a.y,x.b.y);if(i<d||i>u||S<y||S>C)return!1;const b=Math.abs(i-p.a.x)<r&&Math.abs(S-p.a.y)<r||Math.abs(i-p.b.x)<r&&Math.abs(S-p.b.y)<r,L=Math.abs(i-x.a.x)<r&&Math.abs(S-x.a.y)<r||Math.abs(i-x.b.x)<r&&Math.abs(S-x.b.y)<r;return!(b&&L)}l(io,"orthogonalSegmentsCross");function _o(t,e,n,o,s=Yt){const r=xt(t,e,s),c=gt(t,e,s),a=xt(n,o,s),f=gt(n,o,s);return c&&f&>(t,n,s)?Wt(t.y,e.y,n.y,o.y)>s:r&&a&&xt(t,n,s)?Wt(t.x,e.x,n.x,o.x)>s:!1}l(_o,"sameAxisSegmentsOverlap");function We(t,e,n,o,{epsilon:s=Yt,skipDegenerateOther:r=!1}={}){for(const c of n){if(c===o||c.isLayoutOnly)continue;const a=c.points;if(!(!a||a.length<2))for(let f=0;f<a.length-1;f++){const h=a[f],p=a[f+1];if(!(r&&ce(h,p,s))&&(io(t,e,h,p,s)||_o(t,e,h,p,s)))return!0}}return!1}l(We,"segmentConflictsWithAnyEdge");function ue(t,e,n,o,s=Yt){const r=xt(t,e,s),c=gt(t,e,s),a=xt(n,o,s),f=gt(n,o,s);if(!(r&&f||c&&a))return!1;const h=r?{a:t,b:e}:{a:n,b:o},p=r?{a:n,b:o}:{a:t,b:e},x=h.a.y,S=Math.min(h.a.x,h.b.x),d=Math.max(h.a.x,h.b.x),u=p.a.x,i=Math.min(p.a.y,p.b.y),y=Math.max(p.a.y,p.b.y);return u>S+s&&u<d-s&&x>i+s&&x<y-s}l(ue,"orthogonalSegmentsStrictlyCross");function vn(t,e,n){const o=Math.min(e,n),s=Math.max(e,n);return t>o+Yt&&t<s-Yt}l(vn,"strictlyBetween");function Ho(t,e,n){return gt(t,e)&>(e,n)?vn(e.y,t.y,n.y):xt(t,e)&&xt(e,n)?vn(e.x,t.x,n.x):!1}l(Ho,"isCollinearIntermediate");function Do(t){let e=!1;const n=[];for(let o=0;o<t.length;o++){const s=n[n.length-1],r=t[o],c=o+1<t.length?t[o+1]:void 0;if(s&&c){if(ce(s,c)){o++,e=!0;continue}if(Ho(s,r,c)){e=!0;continue}}n.push(r)}return{points:n,changed:e}}l(Do,"simplifyPolylineOnce");function Ke(t){const e=[t[0]];for(let o=1;o<t.length;o++){const s=e[e.length-1],r=t[o];if(!gt(s,r)&&!xt(s,r)){const c=e.length>=2?e[e.length-2]:void 0,f=(c?gt(c,s):!1)?{x:s.x,y:r.y}:{x:r.x,y:s.y};e.push(f)}e.push(r)}const n=[];for(const o of e){const s=n[n.length-1];(!s||!ce(s,o))&&n.push(o)}return n}l(Ke,"orthogonalizePolyline");function de(t){if(t.length<3)return t;let e=[...t];for(let n=0;n<32;n++){const o=Do(e);if(e=o.points,!o.changed)break}return e}l(de,"simplifyPolyline");var it=.001,ur=.5,Lo=4;function co(t,e,n){const o=t;if(o.isLayoutOnly||!o.points||o.points.length<n)return;const s=o.start?e.get(o.start):void 0,r=o.end?e.get(o.end):void 0;return{edge:o,points:o.points,srcRect:s?te(s):void 0,dstRect:r?te(r):void 0}}l(co,"endpointContextFor");function Xo(t,e,n){if(xt(t,e,it))return{x:t.x<n.left?n.left:n.right,y:t.y};if(gt(t,e,it)){const o=t.y<n.top?n.top:n.bottom;return{x:t.x,y:o}}return{x:Math.min(n.right,Math.max(n.left,t.x)),y:Math.min(n.bottom,Math.max(n.top,t.y))}}l(Xo,"segmentEnterPoint");function Ln(t,e,n){const o=n?1:-1;let s=n?0:t.length-1;for(;s>=0&&s<t.length&&no(t[s],e,ur);)s+=o;if(s<0||s>=t.length)return t;const r=s-o;if(r<0||r>=t.length)return t;const c=Xo(t[s],t[r],e);return n?[c,...t.slice(s)]:[...t.slice(0,s+1),c]}l(Ln,"clipEndpoint");function Yo(t,e){for(const n of t){const o=co(n,e,2);if(!o)continue;let s=[...o.points];o.srcRect&&(s=Ln(s,o.srcRect,!0)),o.dstRect&&(s=Ln(s,o.dstRect,!1)),s=de(Ke(s)),s=ao(s,o.srcRect,o.dstRect),o.edge.points=de(Ke(s))}}l(Yo,"clipEdgeEndpointsToNodeBoundaries");function Tn(t,e,n,o=!1){if(xt(t,e,it)){if(e.y<n.top-it||e.y>n.bottom+it)return e;if(o){if(t.x<n.left-it)return{x:n.left,y:t.y};if(t.x>n.right+it)return{x:n.right,y:t.y}}return{x:Math.abs(e.x-n.left)<=Math.abs(e.x-n.right)?n.left:n.right,y:t.y}}if(gt(t,e,it)){if(e.x<n.left-it||e.x>n.right+it)return e;if(o){if(t.y<n.top-it)return{x:t.x,y:n.top};if(t.y>n.bottom+it)return{x:t.x,y:n.bottom}}const s=Math.abs(e.y-n.top)<=Math.abs(e.y-n.bottom);return{x:t.x,y:s?n.top:n.bottom}}return e}l(Tn,"snapEndpointToBoundary");function qe(t,e,n){const o=t[e];for(let s=e+n;s>=0&&s<t.length;s+=n){const r=t[s];if(!ce(r,o,it))return r}return t[e+n]}l(qe,"firstDistinctAdjacent");function Ze(t,e){const n=t+Lo,o=e-Lo;return n<=o?{lo:n,hi:o}:{lo:(t+e)/2,hi:(t+e)/2}}l(Ze,"cornerClearanceRange");function wn(t,e,n){const{lo:o,hi:s}=Ze(e,n);return Math.min(s,Math.max(o,t))}l(wn,"clampToCornerClearance");function Go(t){const e=Math.max(...t.map(o=>o.lo)),n=Math.min(...t.map(o=>o.hi));if(!(e>n))return{lo:e,hi:n}}l(Go,"intersectRanges");function En(t,e){return e==="left"||e==="right"?Ze(t.top,t.bottom):Ze(t.left,t.right)}l(En,"clearanceRangeForSide");function Je(t,e,n){const o=t.y>=n.top-it&&t.y<=n.bottom+it,s=t.x>=n.left-it&&t.x<=n.right+it;if(xt(t,e,it)&&o){if(Math.abs(t.x-n.left)<it)return"left";if(Math.abs(t.x-n.right)<it)return"right"}if(gt(t,e,it)&&s){if(Math.abs(t.y-n.top)<it)return"top";if(Math.abs(t.y-n.bottom)<it)return"bottom"}}l(Je,"terminalSideForSegment");function Pe(t){return t==="left"||t==="right"}l(Pe,"isHorizontalSide");function zo(t,e,n,o,s){const r=[],c=n?Je(t,e,n):void 0,a=o?Je(e,t,o):void 0;return n&&c&&Pe(c)===s&&r.push(En(n,c)),o&&a&&Pe(a)===s&&r.push(En(o,a)),r.length>0?Go(r):void 0}l(zo,"straightClearanceRange");function An(t,e,n,o,s){const r=zo(t,e,n,o,s);if(!r)return;const c=s?t.y:t.x,a=Math.min(r.hi,Math.max(r.lo,c));if(!(Math.abs(a-c)<it))return s?[{x:t.x,y:a},{x:e.x,y:a}]:[{x:a,y:t.y},{x:a,y:e.y}]}l(An,"clearStraightEndpointCornerAxis");function ao(t,e,n){if(t.length!==2)return t;const[o,s]=t;return xt(o,s,it)?An(o,s,e,n,!0)??t:gt(o,s,it)?An(o,s,e,n,!1)??t:t}l(ao,"clearStraightEndpointCornerConnections");function $o(t,e,n){return Pe(n)?{x:t.x,y:wn(t.y,e.top,e.bottom)}:{x:wn(t.x,e.left,e.right),y:t.y}}l($o,"cornerClearedEndpoint");function Vo(t,e,n,o,s,r){const c=t.map(a=>({...a}));for(let a=e;a>=0&&a<t.length;a+=n){const f=t[a];if(r&&!xt(f,o,it)||!r&&!gt(f,o,it))break;r?c[a].y=s.y:c[a].x=s.x}return c}l(Vo,"moveCollinearEndpointRun");function Rn(t,e,n){if(t.length<2)return t;const o=n?0:t.length-1,s=n?1:-1,r=t[o],c=qe(t,o,s);if(!c)return t;const a=Je(r,c,e);if(!a)return t;const f=Pe(a),h=$o(r,e,a);return ce(r,h,it)?t:Vo(t,o,s,r,h,f)}l(Rn,"clearEndpointCornerConnection");function Nn(t,e,n){const o=Math.min(t.x,e.x)>=n.left-it&&Math.max(t.x,e.x)<=n.right+it,s=Math.min(t.y,e.y)>=n.top-it&&Math.max(t.y,e.y)<=n.bottom+it;if(Math.abs(t.y-n.top)<it&&Math.abs(e.y-n.top)<it&&o)return"top";if(Math.abs(t.y-n.bottom)<it&&Math.abs(e.y-n.bottom)<it&&o)return"bottom";if(Math.abs(t.x-n.left)<it&&Math.abs(e.x-n.left)<it&&s)return"left";if(Math.abs(t.x-n.right)<it&&Math.abs(e.x-n.right)<it&&s)return"right"}l(Nn,"borderSideForSegment");function On(t,e,n,o){switch(t){case"top":return gt(e,n,it)&&n.y<o.top-it;case"bottom":return gt(e,n,it)&&n.y>o.bottom+it;case"left":return xt(e,n,it)&&n.x<o.left-it;case"right":return xt(e,n,it)&&n.x>o.right+it}}l(On,"leavesOutward");function Bn(t,e,n){if(t.length<3)return t;if(n){const r=Nn(t[0],t[1],e);return r&&On(r,t[1],t[2],e)?t.slice(1):t}const o=t.length-1,s=Nn(t[o-1],t[o],e);return s&&On(s,t[o-1],t[o-2],e)?t.slice(0,o):t}l(Bn,"collapseOwnBorderStub");function jo(t,e,n){let o=t;if(e){const r=qe(o,0,1);if(r){const c=Tn(r,o[0],e);c!==o[0]&&(o=[c,...o.slice(1)])}o=Bn(o,e,!0)}if(n){const r=o.length-1,c=qe(o,r,-1);if(c){const a=Tn(c,o[r],n,!0);a!==o[r]&&(o=[...o.slice(0,r),a])}o=Bn(o,n,!1)}const s=ao(o,e,n);return s!==o||o.length===2?s:(e&&(o=Rn(o,e,!0)),n&&(o=Rn(o,n,!1)),o)}l(jo,"snapAndCollapseEndpoints");function Pn(t,e){for(const n of t){const o=co(n,e,2);if(!o)continue;const s=pt(o.points,it),r=jo(s,o.srcRect,o.dstRect);if(r.length<3){o.edge.points=r;continue}const c=[r[0],{...r[0]},...r.slice(1,-1),r[r.length-1],{...r[r.length-1]}];o.edge.points=c}}l(Pn,"prepareEdgeEndpointsForRenderer");function lo(t){return new Map(t.map(e=>[e.id,e]))}l(lo,"buildNodeMap");function Uo(t,e){let n=t.parentId,o=null;for(;n;){const s=e.get(n);if(!(s!=null&&s.isGroup))break;o=s.id,n=s.parentId}return o}l(Uo,"resolveTopLevelGroupId");function kn(t,e){let n=0,o=t.parentId;for(;o;){const s=e.get(o);if(!(s!=null&&s.isGroup))break;n++,o=s.parentId}return n}l(kn,"groupDepth");function fo(t){let e=1/0,n=-1/0,o=1/0,s=-1/0;for(const r of t){const c=r.x,a=r.y;if(typeof c!="number"||typeof a!="number")continue;const f=r.width??0,h=r.height??0;e=Math.min(e,c-f/2),n=Math.max(n,c+f/2),o=Math.min(o,a-h/2),s=Math.max(s,a+h/2)}return e===1/0||o===1/0?null:{minX:e,maxX:n,minY:o,maxY:s}}l(fo,"boundsForChildren");function Wo(t,e){const n=t.padding??20;t.x=(e.minX+e.maxX)/2,t.y=(e.minY+e.maxY)/2,t.width=Math.max(0,e.maxX-e.minX)+n,t.height=Math.max(0,e.maxY-e.minY)+n}l(Wo,"applyGroupBounds");function Ko(t){const e=lo(t),n=t.filter(o=>o.isGroup&&o.parentId).sort((o,s)=>kn(s,e)-kn(o,e));for(const o of n){const s=t.filter(c=>c.parentId===o.id),r=fo(s);r&&Wo(o,r)}}l(Ko,"recomputeNestedGroupBounds");function Qe(t,e){const n=t.nodes??[],o=t.edges??[],s=n.filter(f=>!f.isGroup);let r=1/0,c=-1/0;for(const f of s){const h=f[e];typeof h=="number"&&(r=Math.min(r,h),c=Math.max(c,h))}if(!Number.isFinite(r)||!Number.isFinite(c))return!1;const a=l(f=>r+c-f,"mirror");for(const f of n){const h=f[e];typeof h=="number"&&(f[e]=a(h));const p=f.groupTitleRect;p&&(f.groupTitleRect=e==="x"?{...p,left:a(p.right),right:a(p.left)}:{...p,top:a(p.bottom),bottom:a(p.top)})}for(const f of o)for(const h of f.points??[])h[e]=a(h[e]);return!0}l(Qe,"mirrorAxis");function qo(t){return(t.nodes??[]).some(n=>!n.isGroup)?Qe(t,"y"):!0}l(qo,"applyBtDirectionTransform");function Zo(t,e="LR"){const n=t.nodes??[],o=t.edges??[],s=n.filter(B=>!B.isGroup);let r=1/0,c=1/0;for(const B of s){const G=B.x??0,j=B.y??0;G<r&&(r=G),j<c&&(c=j)}if(!Number.isFinite(r)||!Number.isFinite(c))return!1;const a=36;let f=0,h=0;for(const B of s)f+=B.width??0,h+=B.height??0;const p=f/s.length,x=h/s.length,S=x>0?Math.max(1,p/x):1;for(const B of s){const G=B.x??0,tt=((B.y??0)-c)*S+a,ft=G-r;B.x=tt,B.y=ft}for(const B of o)if(B.points)for(const G of B.points){const j=G.x,ft=(G.y-c)*S+a,It=j-r;G.x=ft,G.y=It}Ko(n);const d=n.filter(B=>B.isGroup&&!B.parentId);if(d.length===0)return e==="RL"&&Qe(t,"x"),!0;const u=lo(n),i=new Map;for(const B of n){if(B.isGroup)continue;const G=Uo(B,u);if(!G)continue;const j=i.get(G)??[];j.push(B),i.set(G,j)}let y=0;for(const B of d){const G=B.padding??0;G>y&&(y=G)}const C=[];let b=1/0,L=-1/0;for(const B of d){const G=i.get(B.id)??[],j=fo(G);j&&(b=Math.min(b,j.minX),L=Math.max(L,j.maxX),C.push({lane:B,contentTop:j.minY,contentBottom:j.maxY,centerY:(j.minY+j.maxY)/2}))}if(b===1/0||L===-1/0)return!0;const v=Math.max(0,L-b),m=Math.max(y,10),I=v+2*m,T=a+I,O=(b+L)/2-I/2-a,k=O+T/2,D=Math.max(y,a);C.sort((B,G)=>B.centerY-G.centerY);for(let B=0;B<C.length;B++){const G=C[B];let j,tt;if(B===0?j=G.contentTop-D:j=(C[B-1].contentBottom+G.contentTop)/2,B===C.length-1)tt=G.contentBottom+D;else{const Dt=C[B+1];tt=(G.contentBottom+Dt.contentTop)/2}const ft=Math.max(0,tt-j),It=(j+tt)/2;G.lane.x=k,G.lane.y=It,G.lane.width=T,G.lane.height=ft,G.lane.swimlaneContentTop=G.contentTop,G.lane.groupTitleRect={left:O,right:O+a,top:j,bottom:tt}}return e==="RL"&&Qe(t,"x"),!0}l(Zo,"applyLrDirectionTransform");var ae=1e-6,hr=8,Ge=hr,gr=[0,Ge,-Ge,2*Ge,-2*Ge];function Jo(t,e){const{nodeInfoById:n,realNodeRects:o}=on(e);for(const s of t){if(s.isLayoutOnly)continue;const r=s.points;if(!r||r.length<4)continue;const c=eo(pt(r,ae),ae);if(!c)continue;const{p3:a}=c,f=c.kind==="HVH",h=ro(s,n,ae);if(!h)continue;const{srcId:p,dstId:x,srcInfo:S,dstInfo:d,collinearX:u,collinearY:i}=h;if(u||i)continue;let y;const C=S.rect;for(const b of gr){let L,v,m;if(f){const k=d.cy>S.cy?C.bottom:C.top,D=S.cx+b;if(D<=C.left+ae||D>=C.right-ae)continue;L={x:D,y:k},v={x:D,y:a.y},m={x:a.x,y:a.y}}else{const k=d.cx>S.cx?C.right:C.left,D=S.cy+b;if(D<=C.top+ae||D>=C.bottom-ae)continue;L={x:k,y:D},v={x:a.x,y:D},m={x:a.x,y:a.y}}const I=ce(L,v,ae),T=ce(v,m,ae);if(I&&T||!I&&Bt(L,v,o,[p],1)||!T&&Bt(v,m,o,[x],1))continue;const A=!I&&We(L,v,t,s,{epsilon:ae,skipDegenerateOther:!0}),P=!T&&We(v,m,t,s,{epsilon:ae,skipDegenerateOther:!0});if(!(A||P)){I?y=[v,m]:T?y=[L,v]:y=[L,v,m];break}}y&&(s.points=y)}}l(Jo,"portSwapToLShape");function Qo(t,e){const{realNodeRects:r,labelNodeRects:c}=be(e.values());for(const a of t){if(a.isLayoutOnly)continue;const f=a.points;if(!f||f.length<4)continue;const h=pt(f,.001);if(h.length<4)continue;const p=h.length-1,x=h[p],S=h[p-1],d=h[p-2],u=x.x-S.x,i=x.y-S.y,y=Math.hypot(u,i);if(y>=10||y<.001)continue;const C=S.x-d.x,b=S.y-d.y;if(Math.hypot(C,b)<.001)continue;const v=Nt(S,x,.001),m=Ot(S,x,.001),I=Nt(d,S,.001),T=Ot(d,S,.001);if(!(v&&T||m&&I))continue;const A=a.end,P=a.start,O=A?e.get(A):void 0;if(!O)continue;const k=O.x??0,D=O.y??0,B=te(O);if(!B)continue;let G,j;if(T){const Z=b<0;G={x:k,y:d.y},j={x:k,y:Z?B.bottom:B.top}}else{const Z=C>0;G={x:d.x,y:D},j={x:Z?B.right:B.left,y:D}}if(Bt(G,j,r,A?[A]:[],-2)||Bt(G,j,c,[],-2))continue;if(P){const Z=e.get(P),rt=Z?te(Z):void 0;if(rt&&no(G,rt,2))continue}const tt=l((Z,rt)=>`${Z.x.toFixed(3)},${Z.y.toFixed(3)}|${rt.x.toFixed(3)},${rt.y.toFixed(3)}`,"ownSegmentKey"),ft=new Set;for(let Z=0;Z<h.length-1;Z++)ft.add(tt(h[Z],h[Z+1]));const It=l((Z,rt)=>{for(const ut of t){if(ut===a||ut.isLayoutOnly)continue;const yt=ut.points;if(!(!yt||yt.length<2))for(let St=0;St<yt.length-1;St++){const Et=yt[St],Kt=yt[St+1];if(!ft.has(tt(Et,Kt))&&ue(Z,rt,Et,Kt,.001))return!0}}return!1},"segmentCrossesOtherEdge");if(It(G,j))continue;if(p-3>=0){const Z=h[p-3],rt=[P,A].filter(ut=>!!ut);if(Bt(Z,G,r,rt,-2)||It(Z,G))continue}const _t=[...h.slice(0,p-2),G,j];a.points=_t;const nt=a.labelNodeId;if(nt){const Z=e.get(nt);if(Z){const rt=Z.width??0,ut=Z.height??0;if(rt>0&&ut>0){let yt,St,Et=-1;for(let Kt=0;Kt<_t.length-1;Kt++){const qt=_t[Kt],Zt=_t[Kt+1],se=Math.hypot(Zt.x-qt.x,Zt.y-qt.y),Le=xt(qt,Zt,.001),ge=gt(qt,Zt,.001);(Le&&se>=rt+2||ge&&se>=ut+2)&&se>Et&&(Et=se,yt=(qt.x+Zt.x)/2,St=(qt.y+Zt.y)/2)}yt!==void 0&&St!==void 0&&(Z.x=yt,Z.y=St)}}}}}l(Qo,"collapseShortTerminalStub");var et=.001,Xt=8,at=Oe,pn=l((t,e)=>gt(t,e,et)||xt(t,e,et),"orthogonallyAligned");function ts(t,e){const s=l((d,u)=>{const i=d.x??0,y=d.y??0,C=u.x-i,b=u.y-y;let L=(d.width??0)/2,v=(d.height??0)/2;return Math.abs(b)*L>Math.abs(C)*v?(b<0&&(v=-v),{x:i+(b===0?0:v*C/b),y:y+v}):(C<0&&(L=-L),{x:i+L,y:y+(C===0?0:L*b/C)})},"rectIntersect"),r=l((d,u)=>{const i=pt(d.points??[]);if(i.length<2)return;const y=u?d.start:d.end,C=y?e.get(y):void 0,b=C?te(C):void 0;if(!C||!y||!b)return;const L=u?i[0]:i[i.length-1],v=u?i[1]:i[i.length-2],m=s(C,L);let I=L;if(pn(v,m)&&(I=v),gt(m,I,et))return{edge:d,edgeId:String(d.id??""),nodeId:y,atStart:u,orientation:"V",coord:m.x,min:Math.min(m.y,I.y),max:Math.max(m.y,I.y),boundary:m,railEnd:I,rect:b};if(xt(m,I,et))return{edge:d,edgeId:String(d.id??""),nodeId:y,atStart:u,orientation:"H",coord:m.y,min:Math.min(m.x,I.x),max:Math.max(m.x,I.x),boundary:m,railEnd:I,rect:b}},"terminalLaneFor"),c=l((d,u)=>Math.max(0,Math.min(d.max,u.max)-Math.max(d.min,u.min)),"projectedOverlapLength"),a=l((d,u)=>d.nodeId!==u.nodeId||d.orientation!==u.orientation?!1:d.orientation==="H"?(Math.abs(d.boundary.x-d.rect.left)<1||Math.abs(d.boundary.x-d.rect.right)<1)&>(d.boundary,u.boundary,1):(Math.abs(d.boundary.y-d.rect.top)<1||Math.abs(d.boundary.y-d.rect.bottom)<1)&&xt(d.boundary,u.boundary,1),"sameTerminalFace"),f=l((d,u)=>d.nodeId!==u.nodeId||d.orientation!==u.orientation?!1:c(d,u)>=Xt&&Math.abs(d.coord-u.coord)<.5,"exactTerminalLaneConflict"),h=l((d,u)=>{if(d.nodeId!==u.nodeId||d.orientation!==u.orientation||d.orientation!=="H"||d.atStart===u.atStart)return!1;const i=c(d,u);if(i<Xt)return!1;const y=d.rect.bottom-d.rect.top;return i<y||i>2*y?!1:a(d,u)&&Math.abs(d.coord-u.coord)<16},"nearTerminalLaneConflict"),p=l((d,u)=>{const i=pt(d.edge.points??[]);if(i.length<2)return;const y=d.orientation==="V"?{x:d.boundary.x+u,y:d.boundary.y}:{x:d.boundary.x,y:d.boundary.y+u},C=d.orientation==="V"?{x:d.railEnd.x+u,y:d.railEnd.y}:{x:d.railEnd.x,y:d.railEnd.y+u};if(!l(()=>Math.abs(d.boundary.y-d.rect.top)<1||Math.abs(d.boundary.y-d.rect.bottom)<1?xt(y,d.boundary,et)&&y.x>=d.rect.left+1&&y.x<=d.rect.right-1:Math.abs(d.boundary.x-d.rect.left)<1||Math.abs(d.boundary.x-d.rect.right)<1?gt(y,d.boundary,et)&&y.y>=d.rect.top+1&&y.y<=d.rect.bottom-1:!1,"boundaryStaysOnSameFace")())return;if(d.atStart){const I=i.length>1&&ce(i[1],d.railEnd,et),T=i.slice(I?2:1),A=T[0];return A&&!pn(A,C)?void 0:[y,C,...T]}const L=i.length>1&&ce(i[i.length-2],d.railEnd,et),v=i.slice(0,L?-2:-1),m=v[v.length-1];if(!(m&&!pn(m,C)))return[...v,C,y]},"shiftedCandidate"),x=l(d=>{const u=d.edge,i=pt(u.points??[]);if(i.length!==2)return!1;const y=u.start,C=u.end,b=y?e.get(y):void 0,L=C?e.get(C):void 0;if(!b||!L)return!1;const v=b.x??0,m=b.y??0,I=L.x??0,T=L.y??0,[A,P]=i;return xt(A,P,et)&&Math.abs(m-T)<1&&Math.abs(v-I)>1||gt(A,P,et)&&Math.abs(v-I)<1&&Math.abs(m-T)>1},"laneIsStraightCollinearConnector"),S=[-7,7,-14,14,-21,21];for(let d=0;d<8;d++){const u=t.filter(y=>!y.isLayoutOnly).flatMap(y=>[r(y,!0),r(y,!1)]).filter(y=>!!y);let i=!1;for(let y=0;y<u.length&&!i;y++)for(let C=y+1;C<u.length&&!i;C++){const b=u[y],L=u[C];if(b.edge===L.edge||!(f(b,L)||h(b,L)))continue;const v=!f(b,L),m=[b,L].sort((I,T)=>{const A=x(I),P=x(T);return A!==P?Number(A)-Number(P):+!T.atStart-+!I.atStart});for(const I of m){for(const T of S){const A=p(I,T);if(!A)continue;const P=r({...I.edge,points:A},I.atStart);if(!(!P||u.some(O=>O.edge!==I.edge&&(f(P,O)||v&&h(P,O))))){I.edge.points=A,i=!0;break}}if(i)break}}if(!i)return}}l(ts,"separateSharedRenderedTerminalLanes");function es(t,e){const{realNodeRects:o,labelNodeRects:s}=be(e.values()),r=l((a,f)=>{const h=a.start,p=a.end,x=at(f);if(x.length!==f.length-1)return!1;const S=[h,p].filter(d=>!!d);for(const d of x)if(Bt(d.a,d.b,o,S,-2)||Bt(d.a,d.b,s,[],-2))return!1;for(const d of t){if(d===a||d.isLayoutOnly)continue;const u=d.points;if(!(!u||u.length<2)){for(const i of x)for(const y of at(pt(u)))if(fe(i,y,.5)>=Xt||ue(i.a,i.b,y.a,y.b,et))return!1}}return!0},"candidateIsSafe"),c=l((a,f)=>{if(f+4>=a.length)return;const h=a[f],p=a[f+1],x=a[f+2],S=a[f+3],d=a[f+4],u=Nt(h,p)&&Ot(p,x)&&Nt(x,S)&&Ot(S,d)&>(h,S,et)&>(h,d,et)&>(p,x,et)&&(p.x-h.x)*(S.x-x.x)<0,i=Ot(h,p)&&Nt(p,x)&&Ot(x,S)&&Nt(S,d)&&xt(h,S,et)&&xt(h,d,et)&&xt(p,x,et)&&(p.y-h.y)*(S.y-x.y)<0;if(u||i)return pt([...a.slice(0,f+1),d,...a.slice(f+5)]);if(f+5>=a.length)return;const y=a[f+5],C=Ot(h,p)&&Nt(p,x)&&Ot(x,S)&&Nt(S,d)&&Ot(d,y)&>(h,d,et)&>(h,y,et)&>(x,S,et)&&(x.x-p.x)*(d.x-S.x)<0,b=Nt(h,p)&&Ot(p,x)&&Nt(x,S)&&Ot(S,d)&&Nt(d,y)&&xt(h,d,et)&&xt(h,y,et)&&xt(x,S,et)&&(x.y-p.y)*(d.y-S.y)<0;if(!(!C&&!b))return pt([...a.slice(0,f+1),y,...a.slice(f+6)])},"withoutDogleg");for(let a=0;a<8;a++){let f=!1;for(const h of t){if(h.isLayoutOnly)continue;const p=pt(h.points??[]);for(let x=0;x<=p.length-5;x++){const S=c(p,x);if(!(!S||!r(h,S))){h.points=S,f=!0;break}}if(f)break}if(!f)return}}l(es,"collapseRedundantRectangularDoglegs");function Fn(t,e){const{realNodeRects:r,labelNodeRects:c}=be(e.values()),a=t.filter(u=>!u.isLayoutOnly),f=l((u,i,y)=>pt(u===i?y??[]:u.points??[]),"pointsFor"),h=l((u,i)=>{let y=0;for(let C=0;C<a.length;C++){const b=at(f(a[C],u,i));for(let L=C+1;L<a.length;L++){const v=at(f(a[L],u,i));for(const m of b)for(const I of v)ue(m.a,m.b,I.a,I.b,et)&&y++}}return y},"strictCrossingCount"),p=l(u=>{const i=at(u);if(i.length!==3)return;const y=i[1];if(!(i[0].horizontal===y.horizontal||i[2].horizontal===y.horizontal))return{index:y.index,horizontal:y.horizontal,vertical:y.vertical,segment:y}},"middleRail"),x=l((u,i)=>{const y=[u.start,u.end].filter(C=>!!C);return r.filter(C=>{if(y.includes(C.id))return!1;const b=C.rect;return i.horizontal?Wt(i.a.x,i.b.x,b.left,b.right)>=Xt&&i.a.y>=b.top-2&&i.a.y<=b.bottom+2:Wt(i.a.y,i.b.y,b.top,b.bottom)>=Xt&&i.a.x>=b.left-2&&i.a.x<=b.right+2})},"blockingRectsFor"),S=l((u,i,y)=>{const C=u.map(L=>({...L}));if(i.horizontal)C[i.index].y=y,C[i.index+1].y=y;else if(i.vertical)C[i.index].x=y,C[i.index+1].x=y;else return;const b=de(pt(C));return at(b).length===b.length-1?b:void 0},"candidateByMovingRail"),d=l((u,i,y)=>{const C=[u.start,u.end].filter(L=>!!L),b=at(i);if(b.length!==i.length-1)return!1;for(const L of b)if(Bt(L.a,L.b,r,C,-2)||Bt(L.a,L.b,c,[],-2))return!1;for(const L of a)if(L!==u){for(const v of b)for(const m of at(f(L)))if(fe(v,m,.5)>=Xt)return!1}return h(u,i)<=y},"candidateIsSafe");for(let u=0;u<8;u++){const i=h();let y=!1;for(const C of a){const b=f(C),L=p(b);if(!L)continue;const v=x(C,L.segment);if(v.length===0)continue;const m=L.horizontal?[Math.min(...v.map(I=>I.rect.top))-20,Math.max(...v.map(I=>I.rect.bottom))+20]:[Math.min(...v.map(I=>I.rect.left))-20,Math.max(...v.map(I=>I.rect.right))+20];for(const I of m){const T=S(b,L.segment,I);if(!(!T||!d(C,T,i))){C.points=T,y=!0;break}}if(y)break}if(!y)return}}l(Fn,"liftObstacleHuggingSameSideRails");function _n(t,e){const o=l(f=>{const h=f.groupTitleRect;if(!(!h||typeof h.left!="number"||typeof h.right!="number"||typeof h.top!="number"||typeof h.bottom!="number"||!Number.isFinite(h.left)||!Number.isFinite(h.right)||!Number.isFinite(h.top)||!Number.isFinite(h.bottom)||h.right<=h.left||h.bottom<=h.top))return{left:h.left,right:h.right,top:h.top,bottom:h.bottom}},"validTitleRect"),s=l(f=>{if(!f.isGroup||f.parentId)return;const h=f.direction,p=typeof h=="string"?h.toUpperCase():"";if(p==="LR"||p==="RL"||p==="BT")return;const x=o(f),S=f.y,d=f.height;if(!x||typeof S!="number"||typeof d!="number"||!Number.isFinite(S)||!Number.isFinite(d)||d<=0)return;const u=x.right-x.left,i=x.bottom-x.top;if(!(i<=0||u<i))return{node:f,rect:x}},"topLaneTitleFor"),r=l((f,h)=>{if(!f.horizontal)return!1;const p=f.a.y;return p<=h.top+et||p>=h.bottom-et?!1:Wt(f.a.x,f.b.x,h.left,h.right)>=Xt},"horizontalSegmentIntersectsTitle"),c=[...e.values()].map(s).filter(f=>!!f);if(c.length===0)return;let a=0;for(const f of t){if(f.isLayoutOnly)continue;const h=pt(f.points??[]);for(const p of at(h))for(const x of c)r(p,x.rect)&&(a=Math.max(a,x.rect.bottom-p.a.y+4))}if(!(a<=et))for(const f of c){const h=f.node.y,p=f.node.height;typeof h!="number"||typeof p!="number"||!Number.isFinite(h)||!Number.isFinite(p)||p<=0||(f.node.y=h-a/2,f.node.height=p+a,f.node.groupTitleRect={...f.rect,top:f.rect.top-a,bottom:f.rect.bottom-a})}}l(_n,"liftTopLaneTitleBandsAboveRails");function Hn(t,e){const o=l(h=>{const p=h.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{left:p.left,right:p.right,top:p.top,bottom:p.bottom}},"validTitleRect"),s=l(h=>{if(!h.isGroup||h.parentId||h.direction!=="LR")return;const x=o(h),S=h.x,d=h.width;if(!x||typeof S!="number"||typeof d!="number"||!Number.isFinite(S)||!Number.isFinite(d)||d<=0)return;const u=x.right-x.left,i=x.bottom-x.top;if(!(u<=0||i<u))return{node:h,rect:x}},"leftLaneTitleFor"),r=l((h,p)=>{if(!h.vertical)return!1;const x=h.a.x;return x<=p.left+et||x>=p.right-et?!1:Wt(h.a.y,h.b.y,p.top,p.bottom)>=Xt},"verticalSegmentIntersectsTitle"),c=l((h,p)=>{if(!h.horizontal)return!1;const x=h.a.y;return x<=p.top+et||x>=p.bottom-et?!1:Wt(h.a.x,h.b.x,p.left,p.right)>=Xt},"horizontalSegmentIntersectsTitle"),a=[...e.values()].map(s).filter(h=>!!h);if(a.length===0)return;let f=0;for(const h of t){if(h.isLayoutOnly)continue;const p=pt(h.points??[]);for(const x of at(p))for(const S of a)if(r(x,S.rect))f=Math.max(f,S.rect.right-x.a.x+4);else if(c(x,S.rect)){const d=Math.min(x.a.x,x.b.x);f=Math.max(f,S.rect.right-d+4)}}if(!(f<=et))for(const h of a){const p=h.node.x,x=h.node.width;typeof p!="number"||typeof x!="number"||!Number.isFinite(p)||!Number.isFinite(x)||x<=0||(h.node.x=p-f/2,h.node.width=x+f,h.node.groupTitleRect={...h.rect,left:h.rect.left-f,right:h.rect.right-f})}}l(Hn,"shiftLeftLaneTitleBandsLeftOfRails");function ns(t,e){const{realNodeRects:o}=be(e.values()),s=t.filter(u=>!u.isLayoutOnly),r=l((u,i=new Map)=>pt(i.get(u)??u.points??[]),"replacementPointsFor"),c=l((u=new Map)=>{let i=0;for(let y=0;y<s.length;y++){const C=at(r(s[y],u));for(let b=y+1;b<s.length;b++){const L=at(r(s[b],u));for(const v of C)for(const m of L)ue(v.a,v.b,m.a,m.b,et)&&i++}}return i},"crossingCount"),a=l((u=new Map)=>s.reduce((i,y)=>i+oe(r(y,u)),0),"totalBends"),f=l(u=>{const i=r(u);if(i.length<4)return;const y=i[i.length-2],C=i[i.length-1];if(!(!Nt(y,C,et)&&!Ot(y,C,et)))return{tailStart:y,terminal:C}},"terminalTailFor"),h=l((u,i)=>{const y=r(u);if(y.length<3)return;const C=y[0],b=y[1];let L;if(Nt(C,b,et))L={x:b.x,y:i.tailStart.y};else if(Ot(C,b,et))L={x:i.tailStart.x,y:b.y};else return;const v=de(pt([C,b,L,i.tailStart,i.terminal]));return at(v).length===v.length-1?v:void 0},"candidateWithDestinationTail"),p=l((u,i)=>{const y=[u.start,u.end].filter(C=>!!C);for(const C of at(i))if(Bt(C.a,C.b,o,y,-2))return!0;return!1},"pathHasNodeHit"),x=l((u,i,y)=>{for(const C of s)if(C!==u){for(const b of at(i))for(const L of at(r(C,y)))if(fe(b,L,.5)>=Xt)return!0}return!1},"pathHasSharedTrack"),S=l((u,i,y)=>!p(u,i)&&!x(u,i,y),"candidateIsSafe"),d=l(()=>{const u=new Map;for(const i of s){const y=i.end;if(!y||!e.has(y)||r(i).length<4)continue;const b=u.get(y)??[];b.push(i),u.set(y,b)}return u},"edgesByDestination");for(let u=0;u<4;u++){const i=c();if(i===0)return;const y=a();let C,b=i,L=y;for(const v of d().values())for(let m=0;m<v.length;m++)for(let I=m+1;I<v.length;I++){const T=v[m],A=v[I],P=f(T),O=f(A);if(!P||!O)continue;const k=h(T,O),D=h(A,P);if(!k||!D)continue;const B=new Map([[T,k],[A,D]]);if(!S(T,k,B)||!S(A,D,B))continue;const G=c(B),j=a(B);G>=i||G>b||G===b&&j>=L||(C=B,b=G,L=j)}if(!C)return;for(const[v,m]of C)v.points=m}}l(ns,"swapDestinationTerminalTailsToReduceCrossings");function os(t,e){const{realNodeRects:r,labelNodeRects:c}=be(e.values()),a=t.filter(v=>!v.isLayoutOnly),f=l((v,m=new Map)=>pt(m.get(v)??v.points??[]),"replacementPointsFor"),h=l((v=new Map)=>{let m=0;for(let I=0;I<a.length;I++){const T=at(f(a[I],v));for(let A=I+1;A<a.length;A++){const P=at(f(a[A],v));for(const O of T)for(const k of P)ue(O.a,O.b,k.a,k.b,et)&&m++}}return m},"strictCrossingCount"),p=l((v=new Map)=>a.reduce((m,I)=>m+oe(f(I,v)),0),"totalBends"),x=l(v=>{const m=v.start,I=v.end,T=m?e.get(m):void 0,A=I?e.get(I):void 0,P=T?te(T):void 0,O=A?te(A):void 0;return P&&O?{src:P,dst:O}:void 0},"endpointRectsFor"),S=l((v,m,I)=>{if(I.index<=0||I.index+1>=m.length-1)return;const T=x(v);if(T){if(I.vertical){const A=I.a.x,P=Math.min(T.src.left,T.dst.left),O=Math.max(T.src.right,T.dst.right),k=A<P-et?"left":A>O+et?"right":void 0;return k?{edge:v,points:m,segmentIndex:I.index,axis:"vertical",side:k,coord:A,min:Math.min(I.a.y,I.b.y),max:Math.max(I.a.y,I.b.y)}:void 0}if(I.horizontal){const A=I.a.y,P=Math.min(T.src.top,T.dst.top),O=Math.max(T.src.bottom,T.dst.bottom),k=A<P-et?"top":A>O+et?"bottom":void 0;return k?{edge:v,points:m,segmentIndex:I.index,axis:"horizontal",side:k,coord:A,min:Math.min(I.a.x,I.b.x),max:Math.max(I.a.x,I.b.x)}:void 0}}},"externalRailForSegment"),d=l(()=>{const v=[];for(const m of a){const I=f(m);for(const T of at(I)){const A=S(m,I,T);A&&v.push(A)}}return v},"collectExternalRails"),u=l((v,m)=>v.edge!==m.edge&&v.axis===m.axis&&v.side===m.side&&Wt(v.min,v.max,m.min,m.max)>=Xt,"railsInteract"),i=l(v=>{const m=[],I=new Set;for(const T of v){if(I.has(T))continue;const A=[T],P=[];for(I.add(T);A.length>0;){const O=A.pop();P.push(O);for(const k of v)!I.has(k)&&u(O,k)&&(I.add(k),A.push(k))}P.length>1&&m.push(P)}return m},"connectedComponents"),y=l(v=>{const m=[];for(const I of v)m.some(T=>Math.abs(T-I.coord)<et)||m.push(I.coord);for(;m.length<v.length;){const I=Math.min(...m),T=Math.max(...m),A=v[0].side;m.push(A==="left"||A==="top"?I-12*(v.length-m.length):T+12*(v.length-m.length))}return m},"uniqueCoordsFor"),C=l(v=>{const m=v.map(A=>A.coord),I=y(v),T=[];if(v.length<=6){const A=new Array(I.length).fill(!1),P=[],O=l(()=>{if(P.length===v.length){P.some((k,D)=>Math.abs(k-m[D])>=et)&&T.push([...P]);return}for(const[k,D]of I.entries())A[k]||(A[k]=!0,P.push(D),O(),P.pop(),A[k]=!1)},"visit");return O(),T}for(let A=0;A<m.length;A++)for(let P=A+1;P<m.length;P++){const O=[...m];[O[A],O[P]]=[O[P],O[A]],T.push(O)}return T},"coordinateAssignmentsFor"),b=l((v,m)=>{const I=new Map;for(const[A,P]of v.entries()){const O=m[A],k=I.get(P.edge)??P.points.map(D=>({x:D.x,y:D.y}));P.axis==="vertical"?(k[P.segmentIndex].x=O,k[P.segmentIndex+1].x=O):(k[P.segmentIndex].y=O,k[P.segmentIndex+1].y=O),I.set(P.edge,k)}const T=new Map;for(const[A,P]of I){const O=de(pt(P));if(at(O).length!==O.length-1)return;T.set(A,O)}return T},"replacementsForAssignment"),L=l(v=>{for(const[m,I]of v){const T=[m.start,m.end].filter(A=>!!A);for(const A of at(I))if(Bt(A.a,A.b,r,T,-2)||Bt(A.a,A.b,c,[],-2))return!1}for(let m=0;m<a.length;m++){const I=a[m],T=v.has(I),A=at(f(I,v));for(let P=m+1;P<a.length;P++){const O=a[P];if(!T&&!v.has(O))continue;const k=at(f(O,v));for(const D of A)for(const B of k)if(fe(D,B,.5)>=Xt)return!1}}return!0},"candidateIsSafe");for(let v=0;v<4;v++){const m=h();if(m===0)return;let I,T=m,A=p(),P=Number.POSITIVE_INFINITY;for(const O of i(d()))for(const k of C(O)){const D=b(O,k);if(!D||!L(D))continue;const B=h(D);if(B>=m)continue;const G=p(D),j=O.reduce((tt,ft,It)=>tt+Math.abs(k[It]-ft.coord),0);B>T||B===T&&(G>A||G===A&&j>=P)||(I=D,T=B,A=G,P=j)}if(!I)return;for(const[O,k]of I)O.points=k}}l(os,"reassignCrossingExternalRailChannels");function ss(t,e){const{realNodeRects:o,labelNodeRects:s}=be(e.values()),r=t.filter(d=>!d.isLayoutOnly),c=l((d,u,i)=>pt(d===u?i??[]:d.points??[]),"pointsFor"),a=l(d=>at(d).reduce((u,i)=>{const y=i.a.x-i.b.x,C=i.a.y-i.b.y;return u+Math.hypot(y,C)},0),"pathLength"),f=l((d,u)=>{let i=0;for(let y=0;y<r.length;y++){const C=at(c(r[y],d,u));for(let b=y+1;b<r.length;b++){const L=at(c(r[b],d,u));for(const v of C)for(const m of L)ue(v.a,v.b,m.a,m.b,et)&&i++}}return i},"strictCrossingCount"),h=l((d,u)=>{if(d.horizontal){const i=d.a.y;return(Math.abs(i-u.top)<1||Math.abs(i-u.bottom)<1)&&Wt(d.a.x,d.b.x,u.left,u.right)>=Xt}if(d.vertical){const i=d.a.x;return(Math.abs(i-u.left)<1||Math.abs(i-u.right)<1)&&Wt(d.a.y,d.b.y,u.top,u.bottom)>=Xt}return!1},"segmentRunsAlongRectBorder"),p=l(d=>{const u=[d.start,d.end].filter(y=>!!y),i=[];for(const y of u){const C=e.get(y),b=C?te(C):void 0;b&&i.push(b)}return i},"endpointRectsFor"),x=l((d,u)=>{if(u+3>=d.length)return[];const i=d[u],y=d[u+1],C=d[u+2],b=d[u+3],L=Nt(i,y,et)&&Ot(y,C,et)&&Nt(C,b,et),v=Ot(i,y,et)&&Nt(y,C,et)&&Ot(C,b,et);if(!L&&!v)return[];if(!(L?Math.sign(y.x-i.x)!==Math.sign(b.x-C.x):Math.sign(y.y-i.y)!==Math.sign(b.y-C.y)))return[];const I=gt(i,b,et)||xt(i,b,et)?[]:[{x:i.x,y:b.y},{x:b.x,y:i.y}],T=I.length===0?[[...d.slice(0,u+1),...d.slice(u+3)]]:I.map(P=>[...d.slice(0,u+1),P,...d.slice(u+3)]),A=new Set;return T.map(P=>de(pt(P))).filter(P=>{if(at(P).length!==P.length-1||!P.some(k=>ce(k,b,et)))return!1;const O=P.map(k=>`${k.x.toFixed(3)},${k.y.toFixed(3)}`).join("|");return A.has(O)?!1:(A.add(O),!0)})},"shortcutCandidatesAt"),S=l((d,u,i)=>{const y=[d.start,d.end].filter(b=>!!b),C=p(d);for(const b of at(u))if(Bt(b.a,b.b,o,y,-2)||Bt(b.a,b.b,s,[],-2)||C.some(L=>h(b,L)))return!1;for(const b of r)if(b!==d){for(const L of at(u))for(const v of at(c(b)))if(fe(L,v,.5)>=Xt)return!1}return f(d,u)<=i},"candidateIsSafe");for(let d=0;d<8;d++){const u=f();let i,y,C=u,b=Number.POSITIVE_INFINITY,L=Number.POSITIVE_INFINITY;for(const v of r){const m=c(v),I=oe(m,et),T=a(m);for(let A=0;A<=m.length-4;A++)for(const P of x(m,A)){const O=oe(P,et),k=a(P);if(!(O<I||O===I&&k<T-et)||!S(v,P,u))continue;const B=f(v,P);B>C||B===C&&(O>b||O===b&&k>=L)||(i=v,y=P,C=B,b=O,L=k)}}if(!i||!y)return;i.points=y}}l(ss,"shortcutRedundantOrthogonalJogs");function rs(t,e){const c=[];for(const R of e.values()){if(R.isGroup||R.isEdgeLabel)continue;const F=R.x??0,_=R.y??0,V=te(R);V&&c.push({id:String(R.id??""),cx:F,cy:_,rect:V})}if(c.length===0)return;const a=new Map(c.map(R=>[R.id,R])),f=c.map(R=>({id:R.id,rect:R.rect})),h=["top","bottom","left","right"],p={top:Math.min(...c.map(R=>R.rect.top))-20,bottom:Math.max(...c.map(R=>R.rect.bottom))+20,left:Math.min(...c.map(R=>R.rect.left))-20,right:Math.max(...c.map(R=>R.rect.right))+20},x=t.filter(R=>!R.isLayoutOnly),S=new Map(x.map((R,F)=>[R,F])),d=l(R=>{const F=R==="left"||R==="top"?-1:1,_=[];for(let V=0;V<=2;V++)_.push(p[R]+F*20*V);return _},"outwardTracksForSide"),u=l((R,F=new Map)=>pt(F.get(R)??R.points??[]),"replacementPointsFor"),i=l((R,F)=>{let _=0;for(const V of R)for(const K of F)ue(V.a,V.b,K.a,K.b,et)&&_++;return _},"crossingCountBetweenSegments"),y=l((R,F)=>i(at(R),at(F)),"crossingCountBetweenPaths"),C=l((R=new Map)=>{let F=0;const _=[],V=new Set,K=[],J=l(Y=>{V.has(Y)||(V.add(Y),K.push(Y))},"addEdge");for(let Y=0;Y<x.length;Y++){const q=x[Y],g=u(q,R);for(let M=Y+1;M<x.length;M++){const E=x[M],w=y(g,u(E,R));w>0&&(F+=w,_.push({first:q,second:E,count:w}),J(q),J(E))}}return K.sort((Y,q)=>(S.get(Y)??0)-(S.get(q)??0)),{count:F,pairs:_,edgeSet:V,edges:K}},"crossingSnapshot"),b=l((R,F)=>{const _=new Set(F.keys());if(_.size===0)return R.count;let V=0;for(const J of R.pairs)(_.has(J.first)||_.has(J.second))&&(V+=J.count);let K=0;for(let J=0;J<x.length;J++){const Y=x[J],q=_.has(Y),g=u(Y,F);for(let M=J+1;M<x.length;M++){const E=x[M];!q&&!_.has(E)||(K+=y(g,u(E,F)))}}return R.count-V+K},"crossingCountWithReplacements"),L=l(R=>{const F=new Map;for(const K of R.pairs){const J=F.get(K.first)??new Set;J.add(K.second),F.set(K.first,J);const Y=F.get(K.second)??new Set;Y.add(K.first),F.set(K.second,Y)}const _=[],V=new Set;for(const K of R.edges){if(V.has(K))continue;const J=[K],Y=[];for(V.add(K);J.length>0;){const q=J.pop();Y.push(q);for(const g of F.get(q)??[])V.has(g)||(V.add(g),J.push(g))}Y.sort((q,g)=>(S.get(q)??0)-(S.get(g)??0)),Y.length>1&&_.push(Y)}return _},"crossingComponents"),v=l(R=>[R.start,R.end].filter(F=>!!F),"endpointIdsFor"),m=l(R=>{const F=[];for(const _ of L(R)){const V=new Set(_),K=new Set(_.flatMap(Y=>v(Y))),J=[..._];for(const Y of x)V.has(Y)||v(Y).some(q=>K.has(q))&&J.push(Y);J.sort((Y,q)=>(S.get(Y)??0)-(S.get(q)??0)),F.push(J)}return F},"pairSearchGroups"),I=l((R,F,_)=>b(R,new Map([[F,_]])),"crossingCountWithSingleReplacement"),T=l(R=>{const F=new Map;for(const _ of R.pairs)F.set(_.first,(F.get(_.first)??0)+_.count),F.set(_.second,(F.get(_.second)??0)+_.count);return F},"currentCrossingsByEdge"),A=l(R=>R.slice(1).reduce((F,_,V)=>{const K=R[V];return F+Math.abs(_.x-K.x)+Math.abs(_.y-K.y)},0),"pathLength"),P=l((R=new Map)=>x.reduce((F,_)=>F+oe(u(_,R)),0),"totalBends"),O=l((R=new Map)=>x.reduce((F,_)=>F+A(u(_,R)),0),"totalLength"),k=l((R,F,_=new Map)=>{const V=at(F);for(const K of x)if(K!==R){for(const J of V)for(const Y of at(u(K,_)))if(fe(J,Y,.5)>=Xt)return!0}return!1},"pathHasSegmentConflict"),D=l((R,F)=>{const _=[R.start,R.end].filter(V=>!!V);for(const V of at(F))if(Bt(V.a,V.b,f,_,-2))return!0;return!1},"pathHitsNode"),B=l((R,F)=>{const _=de(pt(F));at(_).length===_.length-1&&R.push(_)},"pushOrthogonalCandidate"),G=l(R=>R==="left"||R==="right","sideIsHorizontal"),j=l((R,F,_)=>{switch(F){case"left":return Math.min(R.x,_.x)-20;case"right":return Math.max(R.x,_.x)+20;case"top":return Math.min(R.y,_.y)-20;case"bottom":return Math.max(R.y,_.y)+20}},"localTrackForSameSide"),tt=l((R,F,_,V)=>{const K=_==="left"||_==="top"?-1:1,J=[j(F,_,V),p[_]];for(const Y of J)for(let q=0;q<=2;q++)B(R,so(F,_,V,Y+K*20*q))},"addSameSideCandidates"),ft=l((R,F,_,V,K)=>{for(const J of d(_))for(const Y of d(K))B(R,[F,{x:J,y:F.y},{x:J,y:Y},{x:V.x,y:Y},V])},"addHorizontalToVerticalCandidates"),It=l((R,F,_,V,K)=>{for(const J of d(_))for(const Y of d(K))B(R,[F,{x:F.x,y:J},{x:Y,y:J},{x:Y,y:V.y},V])},"addVerticalToHorizontalCandidates"),Dt=l((R,F,_,V,K)=>{const J=[...d("top"),...d("bottom")];for(const Y of d(_))for(const q of d(K))for(const g of J)B(R,[F,{x:Y,y:F.y},{x:Y,y:g},{x:q,y:g},{x:q,y:V.y},V])},"addHorizontalPairCandidates"),_t=l((R,F,_,V,K)=>{const J=[...d("left"),...d("right")];for(const Y of d(_))for(const q of d(K))for(const g of J)B(R,[F,{x:F.x,y:Y},{x:g,y:Y},{x:g,y:q},{x:V.x,y:q},V])},"addVerticalPairCandidates"),nt=l(R=>{const F=new Set;return R.map(_=>pt(_)).filter(_=>{const V=_.map(K=>`${K.x.toFixed(3)},${K.y.toFixed(3)}`).join("|");return F.has(V)||_.length<2?!1:(F.add(V),!0)})},"dedupeCandidatePaths"),Z=l((R,F,_,V)=>{const K=[],J=oo(R,F,_,V,20,et);J&&B(K,J),F===V&&tt(K,R,F,_);const Y=G(F),q=G(V);return Y&&!q?ft(K,R,F,_,V):!Y&&q?It(K,R,F,_,V):Y?Dt(K,R,F,_,V):_t(K,R,F,_,V),nt(K)},"buildCandidatesForSides"),rt=l((R,F,_,V)=>{const K=[...d("left"),...d("right")],J=[...d("top"),...d("bottom")];for(const Y of h){const q=ve(V,Y),g=Y==="top"||Y==="bottom"?d(Y):J;for(const M of K){B(R,[F,_,{x:M,y:_.y},{x:M,y:q.y},q]);for(const E of g)B(R,[F,_,{x:M,y:_.y},{x:M,y:E},{x:q.x,y:E},q])}}},"addVerticalDepartureOuterTrackCandidates"),ut=l((R,F,_,V)=>{const K=[...d("left"),...d("right")],J=[...d("top"),...d("bottom")];for(const Y of h){const q=ve(V,Y),g=Y==="left"||Y==="right"?d(Y):K;for(const M of J){B(R,[F,_,{x:_.x,y:M},{x:q.x,y:M},q]);for(const E of g)B(R,[F,_,{x:_.x,y:M},{x:E,y:M},{x:E,y:q.y},q])}}},"addHorizontalDepartureOuterTrackCandidates"),yt=l(R=>{const F=R.start,_=R.end,V=_?a.get(_):void 0;if(!F||!V)return[];const K=pt(R.points??[]);if(K.length<4)return[];const J=K[0],Y=K[1],q=[];return Ot(J,Y,et)?rt(q,J,Y,V):Nt(J,Y,et)&&ut(q,J,Y,V),q},"terminalPreservingOuterTrackCandidates"),St=l(R=>{const F=R.start,_=R.end,V=F?a.get(F):void 0,K=_?a.get(_):void 0;if(!V||!K)return[];const J=[];for(const Y of h){const q=ve(V,Y);for(const g of h)J.push(...Z(q,Y,ve(K,g),g))}return J.push(...yt(R)),J},"candidatePathsFor"),Et=l(()=>new Map(x.map(R=>[R,at(u(R))])),"currentSegmentsByEdge"),Kt=l((R,F,_)=>{const V=new Set;for(const K of x){if(K===R)continue;const J=_.get(K)??at(u(K));F.some(Y=>J.some(q=>fe(Y,q,.5)>=Xt))&&V.add(K)}return V},"sharedTrackConflictsFor"),qt=l((R,F,_,V)=>{const K=new Set;return St(R).map(Y=>de(pt(Y))).filter(Y=>{if(D(R,Y))return!1;const q=Y.map(g=>`${g.x.toFixed(3)},${g.y.toFixed(3)}`).join("|");return K.has(q)||Y.length<2?!1:(K.add(q),!0)}).map(Y=>{const q=at(Y);let g=0;for(const M of x)M!==R&&(g+=i(q,_.get(M)??at(u(M))));return{candidate:Y,candidateSegments:q,crossings:F.count-(V.get(R)??0)+g,bends:oe(Y,et),totalBends:oe(Y),length:A(Y)}}).filter(({crossings:Y})=>Y<=F.count).sort((Y,q)=>Y.crossings-q.crossings||Y.bends-q.bends||Y.length-q.length).slice(0,48).map(Y=>({path:Y.candidate,segments:Y.candidateSegments,sharedTrackConflicts:Kt(R,Y.candidateSegments,_),totalBends:Y.totalBends,length:Y.length}))},"pairCandidatesFor"),Zt=l((R,F,_,V,K,J)=>{let Y=0;for(const g of R.pairs)(g.first===F||g.second===F||g.first===V||g.second===V)&&(Y+=g.count);let q=i(_.segments,K.segments);for(const g of x){if(g===F||g===V)continue;const M=J.get(g)??at(u(g));q+=i(_.segments,M)+i(K.segments,M)}return R.count-Y+q},"pairCrossingCount"),se=l((R,F)=>{for(const _ of R.sharedTrackConflicts)if(_!==F)return!1;return!0},"conflictsOnlyWith"),Le=l((R,F)=>R.segments.some(_=>F.segments.some(V=>fe(_,V,.5)>=Xt)),"candidatesShareTrack"),ge=l((R,F,_,V)=>se(F,_.edge)&&se(V,R.edge)&&!Le(F,V),"pairCandidatesAreCompatible"),Te=l((R,F,_,V,K)=>{const J=Zt(R.current,F.edge,_,V.edge,K,R.baseSegments);if(!(J>=R.current.count))return{replacements:new Map([[F.edge,_.path],[V.edge,K.path]]),crossings:J,bends:R.currentBends-(R.baseBendsByEdge.get(F.edge)??0)-(R.baseBendsByEdge.get(V.edge)??0)+_.totalBends+K.totalBends,length:R.currentLength-(R.baseLengthByEdge.get(F.edge)??0)-(R.baseLengthByEdge.get(V.edge)??0)+_.length+K.length}},"scorePairReplacement"),an=l((R,F)=>R.crossings<F.crossings||R.crossings===F.crossings&&(R.bends<F.bends||R.bends===F.bends&&R.length<F.length),"pairScoreIsBetter"),ln=l((R,F,_,V)=>{let K=V;for(const J of F.candidates)for(const Y of _.candidates){if(!ge(F,J,_,Y))continue;const q=Te(R,F,J,_,Y);q&&an(q,K)&&(K=q)}return K},"bestScoreForOptionPair"),fn=l(R=>{const F=P(),_=O(),V=Et(),K=T(R),J=new Map(x.map(w=>[w,oe(u(w))])),Y=new Map(x.map(w=>[w,A(u(w))])),q=new Map,g=m(R);for(const w of g)for(const N of w){if(q.has(N))continue;const H=qt(N,R,V,K);H.length>0&&q.set(N,{edge:N,candidates:H})}let M={replacements:new Map,crossings:R.count,bends:F,length:_};const E={current:R,currentBends:F,currentLength:_,baseBendsByEdge:J,baseLengthByEdge:Y,baseSegments:V};for(const w of g){const N=new Set(w.filter(W=>R.edgeSet.has(W))),H=w.map(W=>q.get(W)).filter(W=>!!W);for(let W=0;W<H.length;W++){const ot=H[W];for(let U=W+1;U<H.length;U++){const $=H[U];!N.has(ot.edge)&&!N.has($.edge)||(M=ln(E,ot,$,M))}}}return M.replacements.size>0?M.replacements:void 0},"bestPairedReplacement");for(let R=0;R<4;R++){const F=C(),_=F.count;if(_===0)return;let V,K,J=_,Y=Number.POSITIVE_INFINITY;for(const g of F.edges){const M=oe(u(g),et);for(const E of St(g)){const w=D(g,E),N=!w&&k(g,E),H=I(F,g,E),W=oe(E,et);w||N||!(H<_||H===_&&W<M)||H>J||H===J&&W>=Y||(V=g,K=E,J=H,Y=W)}}if(V&&K){V.points=K;continue}const q=fn(F);if(!q)return;for(const[g,M]of q)g.points=M}}l(rs,"resolveRenderedOrthogonalCrossings");var pe=.001,mr=8;function is(t,e){const{nodeInfoById:n,realNodeRects:o}=on(e),s=["top","bottom","left","right"],r=20,c={top:Math.min(...o.map(i=>i.rect.top))-r,bottom:Math.max(...o.map(i=>i.rect.bottom))+r,left:Math.min(...o.map(i=>i.rect.left))-r,right:Math.max(...o.map(i=>i.rect.right))+r},a=l((i,y,C,b)=>{const L=[],v=oo(i,y,C,b,r,pe);return v&&L.push(v),y===b&&L.push(so(i,y,C,c[y])),L},"buildOrthogonalPathCandidates"),f=l((i,y)=>{for(let C=0;C<i.length-1;C++){const b=i[C],L=i[C+1];if(Bt(b,L,o,y,1))return!0}return!1},"pathHitsNode"),h=l((i,y,C=!1)=>{let b=0;const L=Oe(i,pe),v=y.start,m=y.end;for(const I of t){if(I===y||I.isLayoutOnly)continue;const T=I.start,A=I.end;if(!C&&v&&m&&(T===v||T===m||A===v||A===m))continue;const P=I.points;if(!(!P||P.length<2))for(const O of L)for(const k of Oe(P,pe)){if(io(O.a,O.b,k.a,k.b,pe,pe)){b++;continue}fe(O,k,pe)>=mr&&b++}}return b},"pathConflictCount"),p=4,x=l((i,y)=>{const C=Math.abs(i.y-y.rect.top),b=Math.abs(i.y-y.rect.bottom),L=Math.abs(i.x-y.rect.left),v=Math.abs(i.x-y.rect.right);let m="top",I=C;return b<I&&(m="bottom",I=b),L<I&&(m="left",I=L),v<I&&(m="right",I=v),m},"nearestSideOfRect"),S=new Map,d=l((i,y,C)=>{const b=S.get(i)??[];b.push({side:y,edgeId:C}),S.set(i,b)},"addFaceClaim");for(const i of t){if(i.isLayoutOnly)continue;const y=i.points??[];if(y.length<1)continue;const C=i.id??"",b=i.start,L=i.end;if(b){const v=n.get(b);v&&d(b,x(y[0],v),C)}if(L){const v=n.get(L);v&&d(L,x(y[y.length-1],v),C)}}const u=l((i,y,C)=>{var b;return((b=S.get(i))==null?void 0:b.some(L=>L.edgeId!==C&&L.side===y))??!1},"faceIsClaimed");for(const i of t){if(i.isLayoutOnly)continue;const y=i.points;if(!y||y.length<2)continue;const C=oe(y,pe);if(C<p)continue;const b=i.start,L=i.end;if(!b||!L)continue;const v=n.get(b),m=n.get(L);if(!v||!m)continue;const I=i.id??"",T=h(y,i,!0),A=h(y,i);let P,O=T,k=C;for(const D of s){if(u(b,D,I))continue;const B=ve(v,D);for(const G of s){if(u(L,G,I))continue;const j=ve(m,G);for(const tt of a(B,D,j,G)){if(f(tt,[b,L]))continue;const ft=oe(tt,pe);if(T>0){const It=h(tt,i,!0);if(It>O||It===O&&ft>=k)continue;O=It,k=ft,P=tt;continue}h(tt,i)>A||ft<k&&(k=ft,P=tt)}}}if(P){i.points=P;const D=S.get(b);D&&S.set(b,D.filter(G=>G.edgeId!==I));const B=S.get(L);B&&S.set(L,B.filter(G=>G.edgeId!==I)),d(b,x(P[0],v),I),d(L,x(P[P.length-1],m),I)}}}l(is,"simplifyDetouredEdges");var Qt=.001,To=10,ze=7;function Dn(t,e){const n=e?0:t.length-1,o=e?1:-1,s=t[n],r=t[n+o];if(!s||!r)return;const c=r.x-s.x,a=r.y-s.y;if(!(Math.abs(c)+Math.abs(a)<Qt)){if(Math.abs(a)<=Qt){const h=s.x+Math.sign(c)*To;return{left:Math.min(s.x,h),right:Math.max(s.x,h),top:s.y-ze,bottom:s.y+ze}}if(Math.abs(c)<=Qt){const h=s.y+Math.sign(a)*To;return{left:s.x-ze,right:s.x+ze,top:Math.min(s.y,h),bottom:Math.max(s.y,h)}}return{left:Math.min(s.x,r.x),right:Math.max(s.x,r.x),top:Math.min(s.y,r.y),bottom:Math.max(s.y,r.y)}}}l(Dn,"markerClearanceRectFor");function cs(t){return{left:Math.min(t.left,t.right),right:Math.max(t.left,t.right),top:Math.min(t.top,t.bottom),bottom:Math.max(t.top,t.bottom)}}l(cs,"normalizeRect");function Xn(t,e){const n=pt(e),o=Dn(n,!0),s=Dn(n,!1);return[o,s].some(r=>r&&Ue(t,cs(r)))}l(Xn,"labelOverlapsOwnMarker");function Ve(t,e){const n=[];for(const u of t){if(u.isLayoutOnly)continue;const i=u.points;if(!(!i||i.length<2))for(let y=0;y<i.length-1;y++)n.push({edgeId:u.id,p1:i[y],p2:i[y+1]})}const o=[],s=[];for(const u of e.values()){const i=u.isGroup,y=u.parentId;if(i&&!y){const b=te(u);b&&s.push({id:u.id,rect:b});continue}if(i||u.isEdgeLabel)continue;const C=te(u);C&&o.push({nodeId:u.id,rect:C})}const r=3,c=1,a=12,f=l((u,i)=>{const y=Cn(i,r);for(const{nodeId:C,rect:b}of o)if(C!==u&&Ue(y,b))return!0;return!1},"labelOverlapsForeignNode"),h=l((u,i)=>{const y=Cn(i,r);for(const C of n)if(C.edgeId!==u&&nn(C.p1,C.p2,y))return!0;return!1},"labelOverlapsForeignEdge"),p=l((u,i,y)=>f(u,y)||h(i,y),"labelOverlapsAnything"),x=[],S=l(u=>{for(const{id:i,rect:y}of s)if(ko(y,u))return i},"findContainingLane"),d=l((u,i)=>x.some(y=>y.labelId!==u&&Ue(i,y.rect)),"overlapsPlacedLabel");for(const u of t){if(u.isLayoutOnly)continue;const i=u.labelNodeId;if(!i)continue;const y=e.get(i);if(!y)continue;const C=u.points;if(!C||C.length<2)continue;const b=y.width??0,L=y.height??0;if(b<=0||L<=0)continue;const v=[];for(let nt=0;nt<C.length-1;nt++){const Z=C[nt],rt=C[nt+1],ut=Math.abs(Z.x-rt.x),yt=Math.abs(Z.y-rt.y);ut<Qt&&yt<Qt||ut>=Qt&&yt>=Qt||v.push({idx:nt,length:ut+yt,orientation:ut>=Qt?"horizontal":"vertical",midX:(Z.x+rt.x)/2,midY:(Z.y+rt.y)/2})}if(v.length===0)continue;const m=v.length>=3?v.filter(nt=>nt.idx>0&&nt.idx<v.length-1):v,I=m.length>0?m:v,T=b>=L?"horizontal":"vertical",A=l(nt=>[...nt].sort((Z,rt)=>{const ut=Z.orientation===T,yt=rt.orientation===T;if(ut!==yt)return ut?-1:1;const St=Z.length>=(Z.orientation==="horizontal"?b:L)+2,Et=rt.length>=(rt.orientation==="horizontal"?b:L)+2;return St!==Et?St?-1:1:rt.length-Z.length}),"rankSegments"),P=v[0],O=v[v.length-1],k=[.5,.25,.75,.05,.95,.15,.85,.1,.9],D=l((nt,Z)=>{const rt=C[nt.idx],ut=C[nt.idx+1];return{midX:rt.x+(ut.x-rt.x)*Z,midY:rt.y+(ut.y-rt.y)*Z}},"anchorAtT"),B=l((nt,Z,rt)=>Math.min(rt,Math.max(Z,nt)),"clamp"),G=l((nt,Z)=>nt.midX>=Z.left-Qt&&nt.midX<=Z.right+Qt&&nt.midY>=Z.top-Qt&&nt.midY<=Z.bottom+Qt,"pointInsideRectInclusive"),j=l(nt=>{const Z=Ne(nt.midX,nt.midY,b,L),rt=S(Z);if(rt)return{laneId:rt,anchor:nt,rect:Z};const ut=s.find(({rect:se})=>G(nt,se));if(!ut)return;const yt=ut.rect.left+b/2+c,St=ut.rect.right-b/2-c,Et=ut.rect.top+L/2+c,Kt=ut.rect.bottom-L/2-c;if(yt>St||Et>Kt)return;const qt={midX:B(nt.midX,yt,St),midY:B(nt.midY,Et,Kt)},Zt=Ne(qt.midX,qt.midY,b,L);return G(nt,Zt)?{laneId:ut.id,anchor:qt,rect:Zt}:void 0},"placementForAnchor"),tt=l((nt,Z,rt)=>nt.orientation==="horizontal"?Math.abs(Z.midX-rt.x):Math.abs(Z.midY-rt.y),"distanceAlongSegment"),ft=l((nt,Z)=>{const ut=(nt.orientation==="horizontal"?b/2:L/2)+a;if(nt===P){const yt=C[nt.idx];if(tt(nt,Z,yt)+Qt<ut)return!1}if(nt===O){const yt=C[nt.idx+1];if(tt(nt,Z,yt)+Qt<ut)return!1}return!0},"labelClearsTerminalEndpoints"),It=l(nt=>{const Z=A(nt);for(const rt of Z)for(const ut of k){const yt=D(rt,ut);if(!ft(rt,yt))continue;const St=j(yt);if(St&&!Xn(St.rect,C)&&!d(i,St.rect)&&!p(i,u.id,St.rect))return{laneId:St.laneId,anchor:St.anchor}}},"tryPool"),Dt=l((nt,Z,rt=!1)=>{const ut=A(nt);for(const yt of ut){const St={midX:yt.midX,midY:yt.midY};if(Z&&!ft(yt,St))continue;const Et=j(St);if(Et&&!Xn(Et.rect,C)&&!d(i,Et.rect)&&!f(i,Et.rect)&&(rt||!h(u.id,Et.rect)))return{laneId:Et.laneId,anchor:Et.anchor}}},"findLaneContainingFallback"),_t=It(I)??(I.length<v.length?It(v):void 0)??Dt(v,!0)??Dt(v,!1)??Dt(v,!1,!0);if(_t){y.x=_t.anchor.midX,y.y=_t.anchor.midY,y.parentId=_t.laneId;const nt=Ne(_t.anchor.midX,_t.anchor.midY,b,L),Z=x.findIndex(rt=>rt.labelId===i);Z>=0?x[Z]={labelId:i,rect:nt}:x.push({labelId:i,rect:nt})}}}l(Ve,"anchorLabelsToPolyline");var bn=1e-6,xr=8,wo=xr/2,yr=3;function Yn(t,e){return t<e?`${t}::${e}`:`${e}::${t}`}l(Yn,"pairKey");function as(t,e){const{nodeInfoById:n,realNodeRects:o}=on(e),s=new Map;for(const c of e){const a=c.id;if(!c.isGroup&&c.isEdgeLabel){s.set(a,{w:c.width??0,h:c.height??0});continue}}const r=l((c,a,f,h)=>{const p=Yn(a,f);let x=0;const S=l(d=>{if(!d)return;const u=s.get(d);if(!u)return;const i=h==="x"?u.w/2:u.h/2;i>x&&(x=i)},"consider");S(c.labelNodeId);for(const d of t){if(d===c||d.isLayoutOnly)continue;const u=d.start,i=d.end;!u||!i||Yn(u,i)===p&&S(d.labelNodeId)}return x>0?x+yr:0},"labelClearanceFor");for(const c of t){if(c.isLayoutOnly)continue;const a=c.points;if(!eo(a,bn))continue;const f=ro(c,n,bn);if(!f)continue;const{srcId:h,dstId:p,srcInfo:x,dstInfo:S,collinearX:d,collinearY:u}=f;if(d===u)continue;let i,y;if(d){const m=S.cy>x.cy;i={x:x.cx,y:m?x.rect.bottom:x.rect.top},y={x:S.cx,y:m?S.rect.top:S.rect.bottom}}else{const m=S.cx>x.cx;i={x:m?x.rect.right:x.rect.left,y:x.cy},y={x:m?S.rect.left:S.rect.right,y:S.cy}}if(Bt(i,y,o,[h,p],1))continue;const b=r(c,h,p,d?"x":"y"),L=b>wo?b:wo,v=[0,L,-L];for(const m of v){const I={...i},T={...y};if(d){if(I.x+=m,T.x+=m,I.x<=x.rect.left||I.x>=x.rect.right||T.x<=S.rect.left||T.x>=S.rect.right)continue}else if(I.y+=m,T.y+=m,I.y<=x.rect.top||I.y>=x.rect.bottom||T.y<=S.rect.top||T.y>=S.rect.bottom)continue;if(!Bt(I,T,o,[h,p],1)&&!We(I,T,t,c,{epsilon:bn})){c.points=[I,T];break}}}}l(as,"straightenCollinearSiblingDetours");function Gn(t,e){const{realNodeRects:f,labelNodeRects:h}=be(e.values()),p=l((m,I)=>Oe(I,.001).map(T=>({...T,edge:m,interior:T.index>=1&&T.index<=I.length-3})),"segmentsFor"),x=l(()=>{const m=[];for(const I of t){if(I.isLayoutOnly)continue;const T=I.points;!T||T.length<2||m.push(...p(I,pt(T)))}return m},"allSegments"),S=l((m,I)=>m.horizontal&&I.horizontal?Wt(m.a.x,m.b.x,I.a.x,I.b.x)>=8&&Math.abs(m.a.y-I.a.y)<7:m.vertical&&I.vertical?Wt(m.a.y,m.b.y,I.a.y,I.b.y)>=8&&Math.abs(m.a.x-I.a.x)<7:!1,"hasCrowdedParallelTrack"),d=l((m,I)=>{const T=m.start,A=m.end,P=p(m,I);if(P.length!==I.length-1)return!1;const O=[T,A].filter(D=>!!D),k=m.labelNodeId?[m.labelNodeId]:[];for(const D of P)if(Bt(D.a,D.b,f,O,-2)||Bt(D.a,D.b,h,k,-2))return!1;for(const D of t){if(D===m||D.isLayoutOnly)continue;const B=D.points;if(!(!B||B.length<2)){for(const G of P)for(const j of p(D,pt(B)))if(S(G,j)||ue(G.a,G.b,j.a,j.b,.001))return!1}}return!0},"candidateIsSafe"),u=l((m,I)=>{const T=pt(m.edge.points??[]);if(T.length<4||m.index>=T.length-1)return;const A=T.map(P=>({...P}));if(m.horizontal)A[m.index].y+=I,A[m.index+1].y+=I;else if(m.vertical)A[m.index].x+=I,A[m.index+1].x+=I;else return;return p(m.edge,A).length===A.length-1?A:void 0},"shiftedCandidate"),i=l((m,I)=>({x:m.x??(I.left+I.right)/2,y:m.y??(I.top+I.bottom)/2}),"nodeCenter"),y=l(m=>{const I=m.edge,T=pt(I.points??[]);if(T.length!==4||m.index!==1)return;const A=I.start?e.get(I.start):void 0,P=I.end?e.get(I.end):void 0,O=A?te(A):void 0,k=P?te(P):void 0,D=T.slice(m.index+2);if(!(!A||!P||!O||!k||D.length===0))return{sourceCenter:i(A,O),targetCenter:i(P,k),sourceRect:O,tail:D}},"sourceDetourContextFor"),C=l((m,I,T,A,P,O)=>{const k=A.y>=T.y,D=k?P.bottom:P.top,B=D+(k?20:-20);if(k&&m.b.y<=B+.001||!k&&m.b.y>=B-.001)return;const G=m.a.x+I;return pt([{x:T.x,y:D},{x:T.x,y:B},{x:G,y:B},{x:G,y:m.b.y},...O],.001)},"verticalSourceDetour"),b=l((m,I,T,A,P,O)=>{const k=A.x>=T.x,D=k?P.right:P.left,B=D+(k?20:-20);if(k&&m.b.x<=B+.001||!k&&m.b.x>=B-.001)return;const G=m.a.y+I;return pt([{x:D,y:T.y},{x:B,y:T.y},{x:B,y:G},{x:m.b.x,y:G},...O],.001)},"horizontalSourceDetour"),L=l((m,I)=>{const T=y(m);if(T){if(m.vertical)return C(m,I,T.sourceCenter,T.targetCenter,T.sourceRect,T.tail);if(m.horizontal)return b(m,I,T.sourceCenter,T.targetCenter,T.sourceRect,T.tail)}},"sourceDetourCandidate"),v=[-7,7,-14,14,-21,21];for(let m=0;m<12;m++){const I=x();let T=!1;for(let A=0;A<I.length&&!T;A++)for(let P=A+1;P<I.length&&!T;P++){const O=I[A],k=I[P];if(O.edge===k.edge||!S(O,k))continue;const D=[O,k].filter(B=>B.interior);for(const B of D){for(const G of v){const j=u(B,G);if(j&&d(B.edge,j)){B.edge.points=j,T=!0;break}const tt=L(B,G);if(tt&&d(B.edge,tt)){B.edge.points=tt,T=!0;break}}if(T)break}}if(!T)return}}l(Gn,"nudgeSharedInteriorSubpaths");function ls(t,e,n,o){const s=e.x-t.x,r=e.y-t.y,c=o.x-n.x,a=o.y-n.y,f=s*a-r*c;if(Math.abs(f)<1e-10)return!1;const h=n.x-t.x,p=n.y-t.y,x=(h*a-p*c)/f,S=(h*r-p*s)/f,d=.01;return x>d&&x<1-d&&S>d&&S<1-d}l(ls,"segmentsIntersect");function fs(t){const e=t.nodes??[],n=t.edges??[],o=[];if(!n.length||!e.length)return o;const s=Fo(e),r=[];for(const a of n){if(a.isLayoutOnly)continue;const f=a.points;if(!f||f.length<2)continue;const h=a.start,p=a.end,x=a.labelNodeId,S=a.id??`${h}->${p}`;for(const d of s)if(!(d.nodeId===h||d.nodeId===p)&&!(x&&d.nodeId===x)){for(let u=0;u<f.length-1;u++)if(nn(f[u],f[u+1],d,-1)){o.push({type:"edge-node-overlap",edgeId:S,targetId:d.nodeId,detail:`segment ${u} passes through node "${d.nodeId}"`});break}}for(let d=0;d<f.length-1;d++)r.push({edgeId:S,start:h,end:p,p1:f[d],p2:f[d+1]})}const c=new Set;for(let a=0;a<r.length;a++)for(let f=a+1;f<r.length;f++){const h=r[a],p=r[f];if(h.edgeId!==p.edgeId&&!(h.start===p.start||h.start===p.end||h.end===p.start||h.end===p.end)&&ls(h.p1,h.p2,p.p1,p.p2)){const x=h.edgeId<p.edgeId?`${h.edgeId}|${p.edgeId}`:`${p.edgeId}|${h.edgeId}`;c.has(x)||(c.add(x),o.push({type:"edge-edge-crossing",edgeId:h.edgeId,targetId:p.edgeId,detail:`edges "${h.edgeId}" and "${p.edgeId}" cross`}))}}if(o.length>0){const a=o.filter(h=>h.type==="edge-node-overlap").length,f=o.filter(h=>h.type==="edge-edge-crossing").length;Mn.warn(`[SWIMLANE_VALIDATE] ${o.length} issue(s) detected: ${a} edge-node overlap(s), ${f} edge crossing(s)`);for(const h of o)Mn.warn(`[SWIMLANE_VALIDATE] ${h.type}: ${h.detail}`)}return o}l(fs,"validateSwimlanesLayout");function ds(t,e){const n=t.nodes??[],o=t.edges??[],s=n.filter(a=>!a.isGroup);if((e==="LR"||e==="RL")&&s.length>0&&!Zo(t,e)||e==="BT"&&s.length>0&&!qo(t))return;for(const a of o){if(a.isLayoutOnly)continue;const f=a.points;!f||f.length<2||(a.points=de(Ke(f)))}is(o,n),as(o,n),Jo(o,n);const r=new Map;for(const a of n)r.set(String(a.id),a);Ve(o,r),Yo(o,r),Qo(o,r),Gn(o,r),ts(o,r),es(o,r),Fn(o,r),ns(o,r);const c=l(()=>{rs(o,r),os(o,r),ss(o,r),Ve(o,r),Pn(o,r),Fn(o,r),Ve(o,r),Pn(o,r)},"finalizeRenderedEdges");c(),Gn(o,r),c(),_n(o,r),Hn(o,r),_n(o,r),Hn(o,r)}l(ds,"postProcessSwimlaneLayout");function Ie(t){const e=new Map(t.nodeById),n=new Set,o=[];for(const r of t.edges){if(!e.has(r.src)||!e.has(r.dst))continue;const c=`${r.id}:${r.src}->${r.dst}`;n.has(c)||(n.add(c),o.push(r))}return{nodes:[...e.keys()],edges:o,layout:t.layout,nodeById:e}}l(Ie,"normalizeGraph");function uo(t,e){return t.edges.filter(n=>n.dst===e)}l(uo,"incoming");function us(t){const e=new Map;for(const n of t.nodes)e.set(n,[]);for(const n of t.edges)e.get(n.src).push(n.dst);return e}l(us,"buildSuccessorMap");function ho(t){const e=us(t);for(const n of e.values())n.sort((o,s)=>o.localeCompare(s));return e}l(ho,"buildSortedSuccessorMap");function sn(t){const e=new Map;for(const n of t.nodes)e.set(n,0);for(const n of t.edges)e.set(n.dst,(e.get(n.dst)??0)+1);return e}l(sn,"buildInDegreeMap");function go(t){return[...t.entries()].filter(([,e])=>e===0).map(([e])=>e).sort((e,n)=>e.localeCompare(n))}l(go,"sortedZeroInDegreeNodes");function rn(t,e=()=>!0){const n=new Map,o=new Map;for(const s of t.nodes)n.set(s,[]),o.set(s,[]);for(const s of t.edges)e(s)&&(o.get(s.src).push(s.dst),n.get(s.dst).push(s.src));return{preds:n,succs:o}}l(rn,"buildPredecessorSuccessorMaps");function mo(t,e,n,o){var c,a;let s=0;for(const f of t.nodes)o!=null&&o.skipGroups&&((c=t.nodeById.get(f))!=null&&c.isGroup)||(s=Math.max(s,n[f]??0));const r=Array.from({length:s+1},()=>[]);for(const f of e)o!=null&&o.skipGroups&&((a=t.nodeById.get(f))!=null&&a.isGroup)||r[Math.max(0,n[f]??0)].push(f);return r}l(mo,"buildLayersFromRanks");function ke(t){const e=sn(t),n=go(e),o=[],s=ho(t);for(;n.length;){const r=n.shift();o.push(r);for(const c of s.get(r)??[])if(e.set(c,(e.get(c)??0)-1),(e.get(c)??0)===0){let a=0;for(;a<n.length&&n[a]<c;)a++;n.splice(a,0,c)}}return o.length===t.nodes.length?o:null}l(ke,"topoSortIfAcyclic");function Be(t){const e=new Map;let n=0;for(const o of t)e.set(o,n),n++;return e}l(Be,"buildLayerIndex");function xo(t){const e=new Array(t.length),n=l((o,s)=>{if(s-o<=1)return 0;const r=o+s>>1;let c=n(o,r)+n(r,s),a=o,f=r,h=o;for(;a<r||f<s;)f>=s||a<r&&t[a]<=t[f]?e[h++]=t[a++]:(e[h++]=t[f++],c+=r-a);for(let p=o;p<s;p++)t[p]=e[p];return c},"count");return n(0,t.length)}l(xo,"countInversions");function hs(t){const e=Ie(t),n=new Map;for(const x of e.nodes)n.set(x,[]);for(const x of e.edges)n.get(x.src).push(x);for(const x of n.values())x.sort((S,d)=>S.dst===d.dst?S.id.localeCompare(d.id):S.dst.localeCompare(d.dst));const o=Object.create(null);for(const x of e.nodes)o[x]=0;const s=[],r=l(x=>{o[x]=1;for(const S of n.get(x)??[]){const d=S.dst;o[d]===0?r(d):o[d]===1&&s.push(S)}o[x]=2},"dfs"),c=sn(e),a=[...e.nodes.filter(x=>(c.get(x)??0)===0),...e.nodes.filter(x=>(c.get(x)??0)!==0)];for(const x of a)o[x]===0&&r(x);const f=new Set(s.map(x=>`${x.id}:${x.src}->${x.dst}`)),h=e.edges.map(x=>f.has(`${x.id}:${x.src}->${x.dst}`)?{id:x.id,src:x.dst,dst:x.src,weight:x.weight,ref:x.ref}:x);return{acyclic:{nodes:[...e.nodes],edges:h,layout:e.layout,nodeById:new Map(e.nodeById)},reversed:s}}l(hs,"removeCycles_DFS");function gs(t){const e=new Map,n=l(o=>{if(e.has(o))return e.get(o);const s=t.nodeById.get(o);if(!s)return e.set(o,null),null;const r=s.parentId;if(!r)return e.set(o,null),null;const a=n(r)??r;return e.set(o,a),a},"resolve");for(const o of t.nodes)n(o);return e}l(gs,"buildTopLaneMap");function he(t){const e=gs(t);return n=>e.get(n)??null}l(he,"createTopLaneResolver");function cn(t){const e=[];for(const n of t.layout.nodes??[])n.isGroup&&!n.parentId&&e.push(n.id);return[...new Set(e)].reverse()}l(cn,"buildTopLaneOrder");function yo(t,e){const n=cn(t);if(!e||e.length===0)return n;const o=new Set(n),s=new Set,r=[];for(const c of e)!o.has(c)||s.has(c)||(s.add(c),r.push(c));for(const c of n)s.has(c)||r.push(c);return r}l(yo,"resolveTopLaneOrder");var pr={EPSILON:1e-6},tn={GRAVITY_ITERATIONS:8,MAX_CROSSING_OPTIMIZATION_PASSES:4,DEFAULT_COMPACT_SINGLE_INPUT:!0},Eo={DEFAULT_LAYER_GAP:100,DEFAULT_NODE_GAP:40};function ms(t,e){const n=Ie(t),o=(e==null?void 0:e.laneOf)??(()=>null),s=e==null?void 0:e.rankHint,{preds:r}=rn(n);for(const m of r.values())m.sort((I,T)=>I.localeCompare(T));const c=ke(n)??[...n.nodes].sort((m,I)=>m.localeCompare(I)),a=new Map;for(const[m,I]of c.entries())a.set(I,m);const f=new Map,h=new Map;for(const m of n.nodes)h.set(m,[]);for(const m of c){const I=(r.get(m)??[]).filter(T=>f.has(T));if(I.length>0){const T=xs(m,I,{laneOf:o,rankHint:s,topoIndex:a});f.set(m,T),h.get(T).push(m)}else f.has(m)||f.set(m,null)}for(const m of n.nodes)f.has(m)||f.set(m,null);const p=new Set;for(const m of n.nodes)(f.get(m)??null)===null&&p.add(m);const x=[...p].sort((m,I)=>{const T=a.get(m)??0,A=a.get(I)??0;return T===A?m.localeCompare(I):T-A}),S=ys(n),d=new Map;for(const[m,I]of S.entries())d.set(m,[...I].sort((T,A)=>T.localeCompare(A)));const u=ps(d),i=bs(d),y=new Map;for(const m of n.nodes)y.set(m,[]);for(const m of i)for(const I of m.nodes){const T=y.get(I);T?T.push(m.id):y.set(I,[m.id])}const C=[],b=[],L=new Set,v=l(m=>{if(!L.has(m)){L.add(m),C.push(m);for(const I of h.get(m)??[])v(I);b.push(m)}},"walk");for(const m of x)v(m);for(const m of c)v(m);return{parent:f,children:h,roots:x,componentOf:u,blocks:i,nodeBlocks:y,adjacency:d,preorder:C,postorder:b,topologicalOrder:c}}l(ms,"buildDrivingTree");function xs(t,e,n){const o=n.laneOf(t);return[...e].sort((r,c)=>{var i,y;const a=n.laneOf(r),f=n.laneOf(c),h=a!=null&&a===o,p=f!=null&&f===o;if(h!==p)return h?-1:1;const x=(i=n.rankHint)==null?void 0:i[r],S=(y=n.rankHint)==null?void 0:y[c];if(x!=null&&S!=null&&x!==S)return S-x;const d=n.topoIndex.get(r)??0,u=n.topoIndex.get(c)??0;return d!==u?d-u:r.localeCompare(c)})[0]}l(xs,"chooseParent");function ys(t){const e=new Map;for(const n of t.nodes)e.set(n,new Set);for(const n of t.edges)e.get(n.src).add(n.dst),e.get(n.dst).add(n.src);return e}l(ys,"buildAdjacency");function ps(t){const e=new Map;let n=0;for(const o of t.keys()){if(e.has(o))continue;const s=[o];for(;s.length>0;){const r=s.pop();if(!e.has(r)){e.set(r,n);for(const c of t.get(r)??[])e.has(c)||s.push(c)}}n++}return e}l(ps,"assignComponents");function bs(t){const e=new Map,n=new Map,o=[],s=[];let r=0;const c=l((a,f)=>{e.set(a,++r),n.set(a,r);for(const h of t.get(a)??[])h!==f&&(e.has(h)?(e.get(h)??0)<(e.get(a)??0)&&(o.push([a,h]),n.set(a,Math.min(n.get(a)??r,e.get(h)??r))):(o.push([a,h]),c(h,a),n.set(a,Math.min(n.get(a)??r,n.get(h)??r)),(n.get(h)??0)>=(e.get(a)??0)&&s.push(Is(a,h,o,s.length))))},"visit");for(const a of t.keys())e.has(a)||c(a,null);return s}l(bs,"computeBlocks");function Is(t,e,n,o){const s=[],r=new Set;for(;n.length>0;){const c=n.pop();if(s.push(c),r.add(c[0]),r.add(c[1]),c[0]===t&&c[1]===e||c[0]===e&&c[1]===t)break}return{id:o,edges:s,nodes:[...r]}}l(Is,"popBlock");function Ms(t,e,n){const o=[...t.nodes],s=new Map;for(const[b,L]of o.entries())s.set(L,b);const r=o.length,c=new Array(r).fill(-1),a=new Array(r).fill(0),f=[],h=new Set;for(const b of o){const L=n.parent.get(b)??null,v=s.get(b);v!=null&&L==null&&(c[v]=-1,a[v]=0,h.has(b)||(h.add(b),f.push(b)))}for(;f.length>0;){const b=f.shift(),L=s.get(b);if(L==null)continue;const v=n.children.get(b)??[];for(const m of v){if(h.has(m))continue;const I=s.get(m);I!=null&&(c[I]=L,a[I]=a[L]+1,h.add(m),f.push(m))}}for(const b of o){if(h.has(b))continue;const L=s.get(b);L!=null&&(c[L]=-1,a[L]=0,h.add(b))}const p=Math.max(1,Math.ceil(Math.log2(Math.max(1,r)))+1),x=Array.from({length:p},()=>new Array(r).fill(-1));for(let b=0;b<r;b++)x[0][b]=c[b];for(let b=1;b<p;b++)for(let L=0;L<r;L++){const v=x[b-1][L];x[b][L]=v===-1?-1:x[b-1][v]}const S=l((b,L)=>{if(b===-1||L===-1)return-1;a[b]<a[L]&&([b,L]=[L,b]);const v=a[b]-a[L];for(let m=0;m<p;m++)if(v>>m&1&&(b=x[m][b],b===-1))return-1;if(b===L)return b;for(let m=p-1;m>=0;m--){const I=x[m][b],T=x[m][L];I===-1||T===-1||I!==T&&(b=I,L=T)}return x[0][b]},"lcaIndex"),d=Array.from({length:r},()=>new Map);for(const b of t.edges){let L=b.src,v=b.dst,m=e[L],I=e[v];if(m==null||I==null||(m>I&&([L,v]=[v,L],[m,I]=[I,m]),m==null||I==null||m===I))continue;const T=s.get(L),A=s.get(v);if(T==null||A==null)continue;const P=S(T,A);if(P===-1)continue;const O=d[P];for(let k=m;k<I;k++)O.set(k,(O.get(k)??0)+1)}const u=new Map,i=l((b,L)=>{if(L.size!==0)for(const[v,m]of L)b.set(v,(b.get(v)??0)+m)},"mergeInto"),y=new Set,C=l(b=>{const L=s.get(b);y.add(b);const v=L==null?void 0:d[L],m=v?new Map(v):new Map,I=n.children.get(b)??[];for(const T of I){const A=C(T),P=e[b];if(P!=null){let O=u.get(b);O||(O=new Map,u.set(b,O));let k=A.get(P)??0;const D=e[T];D!=null&&D>P&&(k+=1),O.set(T,k)}i(m,A)}return m},"dfs");for(const b of n.roots)y.has(b)||C(b);for(const b of o)y.has(b)||C(b);return u}l(Ms,"computeSubtreeCrossCounts");function Ss(t,e,n){const o=new Map,s=l(r=>{let c=n[r]??0;const a=[...e.get(r)??[]];a.sort(po(n));for(const f of a){s(f);const h=o.get(f);h!=null&&(c=Math.min(c,h))}o.set(r,c)},"annotate");for(const r of t)s(r);return o}l(Ss,"annotateMinimumLayers");function po(t){return(e,n)=>{const o=t[e]??0,s=t[n]??0;return o===s?e.localeCompare(n):o-s}}l(po,"compareByRankThenId");function Cs(t,e,n,o){let s=0;for(const f of e){const h=n[f]??0;h>s&&(s=h)}const r=Array.from({length:s+1},()=>[]),c=new Set,a=l(f=>{if(c.has(f))return;c.add(f);const h=n[f]??0;r[h]||(r[h]=[]),r[h].push(f);for(const p of o(f))a(p)},"emit");for(const f of t)a(f);for(const f of e)if(!c.has(f)){const h=n[f]??0;r[h]||(r[h]=[]),r[h].push(f),c.add(f)}return r}l(Cs,"emitNodesInTreeOrder");function vs(t){const e=[];for(const n of t){const o=new Set,s=[];for(const r of n)o.has(r)||(o.add(r),s.push(r));e.push(s)}return e}l(vs,"deduplicateLayers");function Ls(t,e,n,o){return s=>{const r=t.get(s)??[];if(r.length===0)return[];const c=e[s]??0,a=[],f=[],h=n.get(s);for(const p of r){const x=o.get(p)??c;x>c?a.push({child:p,min:x}):f.push(p)}return a.sort((p,x)=>p.min===x.min?p.child.localeCompare(x.child):p.min-x.min),f.sort((p,x)=>{const S=(h==null?void 0:h.get(p))??0,d=(h==null?void 0:h.get(x))??0;if(S!==d)return S-d;const u=o.get(p)??c,i=o.get(x)??c;return u!==i?u-i:p.localeCompare(x)}),[...a.map(p=>p.child),...f]}}l(Ls,"createChildOrderer");function en(t,e,n){const o=ms(t,{rankHint:e,laneOf:n}),{children:s,roots:r}=o;for(const x of t.nodes)s.has(x)||s.set(x,[]);const c=Ms(t,e,o),a=[...r].sort(po(e)),f=Ss(a,s,e),h=Ls(s,e,c,f);let p=Cs(a,t.nodes,e,h);return p=vs(p),p}l(en,"buildMultitreeLayerOrder");function Ts(t,e,n){const o=new Set(t),s=new Set(e),r=Be(e),c=[];for(const a of n)o.has(a.src)&&s.has(a.dst)&&c.push(r.get(a.dst));return xo(c)}l(Ts,"countCrossingsBetweenAdjacent");function zn(t,e,n){const o=[];for(const r of e){const c=n[r.src],a=n[r.dst];if(c==null||a==null||c===a)continue;let f=r.src,h=r.dst,p=c,x=a;c>a&&(f=r.dst,h=r.src,p=a,x=c);for(let S=p;S<x;S++)o.push({id:`${r.id}@${S}`,src:f,dst:h,ref:r.ref})}let s=0;for(let r=0;r+1<t.length;r++)s+=Ts(t[r],t[r+1],o);return s}l(zn,"totalCrossings");function ws(t,e){const n={...e},{preds:o}=rn(t),s=he(t),r=en(t,n,s);let c=zn(r,t.edges,n);const a=tn.MAX_CROSSING_OPTIMIZATION_PASSES;for(let f=0;f<a;f++){let h=!1;const p=[...t.nodes].sort((x,S)=>(n[S]??0)-(n[x]??0));for(const x of p){const S=n[x]??0;if(S===0)continue;let d=0;for(const C of o.get(x)??[])d=Math.max(d,(n[C]??0)+1);if(d>=S)continue;const u=S;n[x]=d;const i=en(t,n,s),y=zn(i,t.edges,n);y<c?(c=y,h=!0):n[x]=u}if(!h)break}return n}l(ws,"optimizeRanksByCrossings");function Es(t,e){const n=he(t),o=[...t.nodes].sort((s,r)=>(e[s]??0)-(e[r]??0)||s.localeCompare(r));for(const s of o){const r=n(s);if(!r)continue;const c=t.edges.filter(i=>i.src===s);if(c.length===0)continue;let a=!1,f=0;for(const i of c){const y=n(i.dst);y==null||y===r?a=!0:f++}if(f===0||a)continue;let h=0,p=!1;for(const i of t.edges){if(i.dst!==s)continue;const y=n(i.src);y&&(y===r?p=!0:h++)}if(h>0||!p)continue;const x=e[s]??0,S=x+f;let d=0;for(const i of t.edges)i.dst===s&&(d=Math.max(d,(e[i.src]??0)+1));const u=Math.max(x,d,S);u!==x&&(e[s]=u)}}l(Es,"adjustCrossLaneSources");function As(t,e){const n=Ie(t),o=ke(n)??[...n.nodes].sort(),s=(e==null?void 0:e.compactSingleInput)??!1,r=he(n);let c=Object.create(null);for(const f of o){const h=uo(n,f),p=e!=null&&e.ignoreCrossLaneEdges?h.filter(x=>{const S=r(x.src),d=r(f);return!S||!d?!0:S===d}):h;if(p.length===0)c[f]=0;else if(s&&p.length===1){const x=p[0].src,S=r(x),d=r(f);S!==d?c[f]=c[x]??0:c[f]=(c[x]??0)+1}else{let x=-1/0;for(const S of p)x=Math.max(x,(c[S.src]??0)+1);c[f]=x===-1/0?0:x}}return((e==null?void 0:e.optimizeRanksByCrossings)??!1)&&(c=ws(n,c)),e!=null&&e.ignoreCrossLaneEdges&&Es(n,c),{layers:en(n,c,r),rankOf:c,dummy:new Set}}l(As,"assignLayers_LongestPath");function Rs(t,e){const n=Ie(t),s={...As(n,{compactSingleInput:e==null?void 0:e.compactSingleInput,ignoreCrossLaneEdges:e==null?void 0:e.ignoreCrossLaneEdges,optimizeRanksByCrossings:e==null?void 0:e.optimizeRanksByCrossings}).rankOf},r=he(n),{preds:c,succs:a}=rn(n,u=>{if(e!=null&&e.ignoreCrossLaneEdges){const i=r(u.src),y=r(u.dst);if(i&&y&&i!==y)return!1}return!0}),f=ke(n)??[...n.nodes],h=[...f].reverse(),p=l((u,i)=>{let y=0;for(const L of c.get(u)??[])y=Math.max(y,(s[L]??0)+1);let C=Number.POSITIVE_INFINITY;const b=a.get(u)??[];return b.length>0&&(C=Math.min(...b.map(L=>(s[L]??0)-1))),Number.isFinite(C)||(C=Math.max(y,i)),Math.min(Math.max(i,y),C)},"clampFeasible"),x=tn.GRAVITY_ITERATIONS,S=l(u=>{let i=!1;for(const y of u){const C=c.get(y)??[],b=a.get(y)??[];if(C.length===0&&b.length===0)continue;const L=C.length>0?C.reduce((T,A)=>T+(s[A]??0)+1,0)/C.length:s[y]??0,v=b.length>0?b.reduce((T,A)=>T+(s[A]??0)-1,0)/b.length:s[y]??0,m=Math.round((L+v)/2),I=p(y,m);I!==s[y]&&(s[y]=I,i=!0)}return i},"relaxOrder");for(let u=0;u<x;u++){const i=S(f),y=S(h);if(!i&&!y)break}for(const u of f){let i=0;for(const y of c.get(u)??[])i=Math.max(i,(s[y]??0)+1);(s[u]??0)<i&&(s[u]=i)}for(const u of h){const i=a.get(u)??[];if(i.length>0){const y=Math.min(...i.map(C=>(s[C]??0)-1));(s[u]??0)>y&&(s[u]=y)}}return{layers:mo(n,f,s),rankOf:s,dummy:new Set}}l(Rs,"assignLayers_Gravity");function Ns(t){const e=sn(t),n=ho(t);let o=go(e);const s=[];for(;o.length>0;){const r=[];for(const c of o){s.push(c);for(const a of n.get(c)??[])e.set(a,(e.get(a)??0)-1),(e.get(a)??0)===0&&r.push(a)}o=r.sort((c,a)=>c.localeCompare(a))}return s.length===t.nodes.length?s:null}l(Ns,"topoSortByGenerationIfAcyclic");function Os(t,e){const n=Ie(t),o=(e==null?void 0:e.direction)==="LR"?Ns(n)??[...n.nodes].sort():ke(n)??[...n.nodes].sort(),s=he(n),r=l(p=>s(p)??p,"laneOf"),c=Object.create(null),a=new Map,f=l((p,x)=>(e==null?void 0:e.ignoreCrossLaneEdges)??!0?r(p)===r(x)?1:0:1,"edgeWeight");for(const p of o){const x=n.nodeById.get(p);if(x!=null&&x.isGroup)continue;const S=uo(n,p);let d=0;if(S.length>0)for(const C of S){const b=C.src,L=c[b]??0;d=Math.max(d,L+f(b,p))}const u=r(p),i=a.get(u)??0,y=Math.max(d,i);c[p]=y,a.set(u,y+1)}return{layers:mo(n,o,c,{skipGroups:!0}),rankOf:c,dummy:new Set}}l(Os,"assignLayers_LaneAwareCompact");function Bs(t,e){const n=Ie(e),{rankOf:o}=t,s=t.layers.map(d=>[...d]),r=new Set(t.dummy?[...t.dummy]:[]);let c=0;const a=new Map(n.nodeById),f=l(d=>{const u=`placeholder-${c++}`,i={id:u,isGroup:!1,isDummy:!0,width:0,height:0};for(a.set(u,i),r.add(u);s.length<=d;)s.push([]);return s[d].push(u),o[u]=d,u},"addDummyAt"),h=[...n.edges].sort((d,u)=>d.id===u.id?d.src===u.src?d.dst.localeCompare(u.dst):d.src.localeCompare(u.src):d.id.localeCompare(u.id)),p=[];for(const d of h){const u=o[d.src]??0,i=o[d.dst]??0;if(i-u<=1){p.push(d);continue}let y=d.src;for(let b=u+1,L=0;b<i;b++,L++){const v=f(b);p.push({id:`${d.id}#${L}`,src:y,dst:v,weight:d.weight,ref:d.ref}),y=v}const C=i-u-2;p.push({id:`${d.id}#${Math.max(C+1,0)}`,src:y,dst:d.dst,weight:d.weight,ref:d.ref})}const S={nodes:[...n.nodes,...[...r].filter(d=>!n.nodes.includes(d))],edges:p,layout:n.layout,nodeById:a};return{layering:{layers:s,rankOf:o,dummy:r},graphWithDummies:S}}l(Bs,"makeProperLayering");function $n(t){const e=t.length;if(e===0)return Number.POSITIVE_INFINITY;const n=[...t].sort((o,s)=>o-s);return e%2===1?n[(e-1)/2]:.5*(n[e/2-1]+n[e/2])}l($n,"median");function Vn(t){return t.length===0?Number.POSITIVE_INFINITY:t.reduce((n,o)=>n+o,0)/t.length}l(Vn,"barycenter");function Ps(t,e,n,o){const s=new Map;for(const r of t)s.set(r,[]);for(const r of n)o==="down"?e.has(r.src)&&s.has(r.dst)&&s.get(r.dst).push(e.get(r.src)):e.has(r.dst)&&s.has(r.src)&&s.get(r.src).push(e.get(r.dst));return s}l(Ps,"neighborPositionsFor");function ks(t,e,n){const o=n.get(t)??0,s=n.get(e)??0;return o!==s?o-s:t.localeCompare(e)}l(ks,"currentOrderTieBreak");function jn(t,e,n){const o=new Set(t),s=new Set(e),r=Be(t),c=Be(e),a=[];for(const h of n)o.has(h.src)&&s.has(h.dst)&&a.push({u:r.get(h.src),v:c.get(h.dst)});a.sort((h,p)=>h.u===p.u?h.v-p.v:h.u-p.u);const f=a.map(h=>h.v);return xo(f)}l(jn,"countCrossingsBetweenAdjacent");function je(t,e,n){return[...t].sort((o,s)=>{const r=$n(e.get(o)??[]),c=$n(e.get(s)??[]);return r===c?ks(o,s,n):isFinite(r)?isFinite(c)?r-c:-1:1})}l(je,"sortByHeuristic");function Un(t,e,n,o,s,r){const c=Be(t),a=Be(e),f=Ps(e,c,n,o);if(!s||!r||r.length===0)return je(e,f,a);const h=new Map;for(const S of e){const d=s(S),u=h.get(d)??[];u.push(S),h.set(d,u)}const p=[];for(const S of r){const d=h.get(S);if(!d||d.length===0)continue;const u=je(d,f,a);p.push(...u)}const x=h.get(null);if(x&&x.length>0){const S=je(x,f,a);for(const d of S){const u=Vn(f.get(d)??[]);let i=p.length;if(isFinite(u))for(const[y,C]of p.entries()){const b=Vn(f.get(C)??[]);if(u<b){i=y;break}}p.splice(i,0,d)}}return p}l(Un,"reorderLayer");function Wn(t,e,n,o,s){const r=[...e],c=new Set(t),a=new Set(e),f=o?new Set(o):null,h=n.filter(i=>c.has(i.src)&&a.has(i.dst)),p=f?n.filter(i=>a.has(i.src)&&f.has(i.dst)):void 0,x=l(i=>{let y=jn(t,i,h);return p&&o&&(y+=jn(i,o,p)),y},"crossingScore"),S=s?new Map:null;if(s&&S)for(const i of e)S.set(i,s(i));let d=!0,u=x(r);for(;d;){d=!1;for(let i=0;i+1<r.length;i++){if(S){const b=S.get(r[i]),L=S.get(r[i+1]);if(b!==L)continue}const y=u;[r[i],r[i+1]]=[r[i+1],r[i]];const C=x(r);C<y?(u=C,d=!0):[r[i],r[i+1]]=[r[i+1],r[i]]}}return r}l(Wn,"transposeImprove");function Fs(t,e,n){const o=t.layers.map(a=>[...a]),s=e.edges,r=he(e),c=yo(e,n==null?void 0:n.laneOrder);for(let a=0;a<3;a++){for(let f=1;f<o.length;f++)o[f]=Un(o[f-1],o[f],s,"down",r,c),o[f]=Wn(o[f-1],o[f],s,o[f+1],r);for(let f=o.length-2;f>=0;f--)o[f]=Un(o[f+1],o[f],s,"up",r,c),o[f]=Wn(o[f+1],o[f],s,o[f-1],r)}return{layers:o}}l(Fs,"orderLayers");function _s(t,e,n){const o=(n==null?void 0:n.layerGap)??Eo.DEFAULT_LAYER_GAP,s=(n==null?void 0:n.nodeGap)??Eo.DEFAULT_NODE_GAP,r=(n==null?void 0:n.laneGap)??s*2,c=(n==null?void 0:n.direction)??"TB",a=c==="LR"||c==="RL",f=t.layers,h=Object.create(null),p=Object.create(null),x=l(O=>e.nodeById.get(O),"getNode"),S=l(O=>{var k;return((k=x(O))==null?void 0:k.width)??0},"getWidth"),d=l(O=>{var k;return((k=x(O))==null?void 0:k.height)??0},"getHeight"),u=he(e),i=yo(e,n==null?void 0:n.laneOrder),y=f.map(O=>O.reduce((k,D)=>Math.max(k,d(D)),0)),C=[];if(a)for(let O=0;O+1<f.length;O++){const k=f[O].reduce((It,Dt)=>Math.max(It,S(Dt)),0),D=f[O+1].reduce((It,Dt)=>Math.max(It,S(Dt)),0),B=y[O],G=y[O+1],j=B/2+G/2,tt=(k+D)/2,ft=Math.max(0,tt-j-o);C.push(ft)}const b=new Set;for(const O of f)for(const k of O)b.add(u(k));const L=b.has(null),v=i.filter(O=>b.has(O)),m=[...L?[null]:[],...v],I=Object.create(null);for(const O of v)I[O]=0;L&&(I.null=0);for(const O of f){const k=Object.create(null),D=[];for(const B of O){const G=u(B);G===null?D.push(B):(k[G]||(k[G]=[])).push(B)}for(const[B,G]of Object.entries(k)){const j=G.reduce((tt,ft)=>tt+S(ft),0)+s*Math.max(0,G.length-1);I[B]=Math.max(I[B]??0,j)}if(L&&D.length){const B=D.reduce((G,j)=>G+S(j),0)+s*Math.max(0,D.length-1);I.null=Math.max(I.null??0,B)}}const T=new Map;{const O=m.map(B=>(B===null?I.null:I[B])??0);let D=-(O.reduce((B,G)=>B+G,0)+r*Math.max(0,m.length-1))/2;for(let B=0;B<m.length;B++){const G=m[B],j=O[B]??0,tt=D+j/2;T.set(G,tt),D+=j,B<m.length-1&&(D+=r)}}let A=0;for(const[O,k]of f.entries()){const D=y[O]??0,B=new Map;for(const j of k){const tt=u(j),ft=B.get(tt)??[];ft.push(j),B.set(tt,ft)}for(const j of m){const tt=B.get(j)??[];if(tt.length===0)continue;const ft=T.get(j);if(tt.length===1){const It=tt[0];h[It]=ft,p[It]=A+D/2}else{const It=tt.map(nt=>S(nt)),Dt=It.reduce((nt,Z)=>nt+Z,0)+s*(tt.length-1);let _t=ft-Dt/2;for(const[nt,Z]of tt.entries()){const rt=It[nt];h[Z]=_t+rt/2,p[Z]=A+D/2,_t+=rt+s}}}const G=C[O]??0;A+=D+o+G}const P=new Map;for(const O of e.edges){const k=O.ref.id;P.has(k)||P.set(k,[]),P.get(k).push(O)}for(const[,O]of P){if(O.length===0)continue;const k=O[0].ref,D=k.start,B=k.end;if(D==null||B==null)continue;const G=Math.round(((h[D]??0)+(h[B]??0))/2),j=new Set;for(const tt of O)j.add(tt.src),j.add(tt.dst);for(const tt of j){if(tt===D||tt===B)continue;const ft=e.nodeById.get(tt);ft!=null&&ft.isDummy&&(h[tt]=G)}}return{x:h,y:p}}l(_s,"assignCoordinates");var Hs=8;function Ds(t){let e=2166136261;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e>>>0}l(Ds,"hashString");function Xs(t){let e=t>>>0;return()=>{e+=1831565813;let n=e;return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}l(Xs,"mulberry32");function Ys(t,e){const n=[...t],o=Xs(e);for(let s=n.length-1;s>0;s--){const r=Math.floor(o()*(s+1));[n[s],n[r]]=[n[r],n[s]]}return n}l(Ys,"deterministicShuffle");function Gs(t,e){let n=0;for(const[o,s]of t.entries())n+=Math.abs(o-(e.get(s)??o));return n}l(Gs,"sourceDistance");function Kn(t,e){const n=new Map;for(const[s,r]of t.entries())n.set(r,s);let o=0;for(const{a:s,b:r,weight:c}of e){const a=n.get(s),f=n.get(r);a==null||f==null||(o+=c*Math.abs(a-f))}return o}l(Kn,"laneArrangementCost");function zs(t){const e=cn(t);if(e.length<2)return[];const n=new Map(e.map((r,c)=>[r,c])),o=he(t),s=new Map;for(const r of t.layout.edges??[]){if(r.isLayoutOnly)continue;const c=typeof r.start=="string"?r.start:void 0,a=typeof r.end=="string"?r.end:void 0;if(!c||!a||!t.nodeById.has(c)||!t.nodeById.has(a))continue;const f=o(c),h=o(a);if(!f||!h||f===h)continue;const p=n.get(f),x=n.get(h);if(p==null||x==null)continue;const[S,d]=p<=x?[f,h]:[h,f],u=`${S}\0${d}`,i=s.get(u);i?i.weight++:s.set(u,{a:S,b:d,weight:1})}return[...s.values()]}l(zs,"buildWeightedLaneEdges");function qn(t,e,n){const o=[...t];let s=Kn(o,e),r=!0,c=0;const a=Math.max(1,o.length);for(;r&&c<a;){r=!1,c++;for(let f=0;f+1<o.length;f++){[o[f],o[f+1]]=[o[f+1],o[f]];const h=Kn(o,e);h<s?(s=h,r=!0):[o[f],o[f+1]]=[o[f+1],o[f]]}}return{order:o,cost:s,sourceDistance:Gs(o,n)}}l(qn,"greedySwitch");function $s(t,e){return t.cost!==e.cost?t.cost<e.cost:t.sourceDistance<e.sourceDistance}l($s,"isBetterCandidate");function Vs(t,e,n){const o=[...e].sort((s,r)=>s.a===r.a?s.b.localeCompare(r.b):s.a.localeCompare(r.a)).map(({a:s,b:r,weight:c})=>`${s}:${r}:${c}`).join("|");return Ds(`${t.join("|")}#${o}#${n}`)}l(Vs,"seedForRestart");function js(t,e={}){const n=cn(t);if(n.length<2)return n;const o=zs(t);if(o.length===0)return n;const s=new Map(n.map((a,f)=>[a,f]));let r=qn(n,o,s);const c=Math.max(0,e.restarts??Hs);for(let a=0;a<c;a++){const f=Vs(n,o,a),h=Ys(n,f),p=qn(h,o,s);$s(p,r)&&(r=p)}return r.order}l(js,"optimizeTopLaneOrder");function Us(t,e){const n=(e==null?void 0:e.ignoreCrossLaneEdges)??!0,o=(e==null?void 0:e.optimizeRanksByCrossings)??!0,s=Ie(t),r=e!=null&&e.automaticLaneOrdering?js(s,{restarts:Hs}):void 0,c=hs(s),a=c.acyclic,f=n?Os(a,{compactSingleInput:(e==null?void 0:e.compactSingleInput)??tn.DEFAULT_COMPACT_SINGLE_INPUT,ignoreCrossLaneEdges:!0,direction:e==null?void 0:e.direction}):Rs(a,{compactSingleInput:(e==null?void 0:e.compactSingleInput)??tn.DEFAULT_COMPACT_SINGLE_INPUT,ignoreCrossLaneEdges:!1,optimizeRanksByCrossings:o}),{layering:h,graphWithDummies:p}=Bs(f,a),x=Fs(h,p,{laneOrder:r}),S=_s(x,p,{layerGap:e==null?void 0:e.layerGap,nodeGap:e==null?void 0:e.nodeGap,direction:e==null?void 0:e.direction,laneOrder:r});return{acyclic:a,reversed:c.reversed,layering:h,ordered:x,coordinates:S}}l(Us,"sugiyamaLayout");var lt=pr.EPSILON,br=8,Se=15,Re=15,$e=25,ie=20,In=10;function Zn(t,e,n){const o=t.x??0,s=t.y??0,r=e.x-o,c=e.y-s,a=Math.abs(r),f=Math.abs(c);return a<lt&&f<lt?n:f>lt&&f*3>=a?c>0?"bottom":"top":a>lt?r>0?"right":"left":n}l(Zn,"chooseOrthogonalSide");function Jn(t,e){return Math.abs(t.to-e.from)<lt||Math.abs(t.to-e.to)<lt?t.to:t.from}l(Jn,"sharedLineEndpointCoord");function Ce(t,e){return t.orient==="vertical"?{x:t.coord,y:e}:{x:e,y:t.coord}}l(Ce,"pointOnLine");function Ws(t,e){var K,J,Y,q;const n=t.nodes??[],o=t.edges??[],s=[];for(const g of o)g.isLayoutOnly||s.push({...g,__originalEdge:g});const r=new Map,c=new Map,a=[],f=e==="LR";for(const g of n)r.set(g.id,g);const h=n.filter(g=>g.isGroup&&!g.parentId);for(const g of h){const M={id:g.id},E=l(w=>{c.set(w.id,M),n.filter(N=>N.parentId===w.id).forEach(E)},"assignLane");E(g)}const p=n.filter(g=>!g.isGroup&&!g.isEdgeLabel).map(g=>{const M=g.width??10,E=g.height??10,w=g.x??0,N=g.y??0,H=br;return{nodeId:g.id,minX:w-M/2-H,maxX:w+M/2+H,minY:N-E/2-H,maxY:N+E/2+H,visualXHalfExtent:f?E/2+H:M/2+H}}),x=l((g,M,E,w)=>{let N=a.find(H=>H.orientation===g&&Math.abs(H.coord-M)<1);return N||(N={id:`pipe-${g}-${M.toFixed(0)}`,orientation:g,coord:M,spanMin:E,spanMax:w,tracks:[]},a.push(N)),N.spanMin=Math.min(N.spanMin,E),N.spanMax=Math.max(N.spanMax,w),N},"getOrAddPipe"),S=l((g,M)=>{const E=g.width??10,w=g.height??10,N=g.x??0,H=g.y??0;switch(M){case"top":return{x:N,y:H-w/2};case"bottom":return{x:N,y:H+w/2};case"left":return{x:N-E/2,y:H};case"right":return{x:N+E/2,y:H}}},"portForSide"),d=l((g,M,E)=>S(g,Zn(g,M,E?"bottom":"top")),"getOrthogonalPort"),u=[],i=[],y=new Set,C=1e3,b=l((g,M,E)=>{if(u.length===0)return 0;const w=Math.abs(M.y-E.y)<lt,N=Math.abs(M.x-E.x)<lt;if(!w&&!N)return 0;let H=0;if(w){const W=M.y,ot=Math.min(M.x,E.x)-lt,U=Math.max(M.x,E.x)+lt;if(U<=ot)return 0;for(const $ of u)$.edgeIndex===g||$.orientation!=="vertical"||$.pipe.coord<ot||$.pipe.coord>U||$.from-lt<=W&&$.to+lt>=W&&(H+=C)}else if(N){const W=M.x,ot=Math.min(M.y,E.y)-lt,U=Math.max(M.y,E.y)+lt;if(U<=ot)return 0;for(const $ of u)$.edgeIndex===g||$.orientation!=="horizontal"||$.pipe.coord<ot||$.pipe.coord>U||$.from-lt<=W&&$.to+lt>=W&&(H+=C)}return H},"crossingPenalty"),L=s.map((g,M)=>{if(!g.start||!g.end)return{idx:M,crossLane:0,dx:0,dy:0};const E=r.get(g.start),w=r.get(g.end),N=c.get(g.start),H=c.get(g.end),W=N&&H&&N.id!==H.id?1:0,ot=E&&w?Math.abs((w.x??0)-(E.x??0)):0,U=E&&w?Math.abs((w.y??0)-(E.y??0)):0;return{idx:M,crossLane:W,dx:ot,dy:U}}).sort((g,M)=>{if(g.crossLane!==M.crossLane)return M.crossLane-g.crossLane;const E=g.dx+g.dy,w=M.dx+M.dy;return Math.abs(E-w)>1?E-w:g.idx-M.idx}).map(g=>g.idx),v=l((g,M,E,w)=>{const N=Math.min(g.x,M.x),H=Math.max(g.x,M.x),W=Math.min(g.y,M.y),ot=Math.max(g.y,M.y);return!!p.find($=>E&&$.nodeId===E||w&&$.nodeId===w?!1:Math.abs(g.x-M.x)>lt?$.minY<g.y&&$.maxY>g.y&&$.maxX>N&&$.minX<H:$.minX<g.x&&$.maxX>g.x&&$.maxY>W&&$.minY<ot)},"isSegmentBlocked"),m=new Map,I=new Map;for(const g of s)!g.start||!g.end||g.start===g.end||(I.set(g.start,(I.get(g.start)??0)+1),I.set(g.end,(I.get(g.end)??0)+1));const T=l((g,M)=>Zn(g,M,"bottom"),"determineSide"),A=new Map;for(const[g,M]of s.entries()){if(!M.start||!M.end||M.start===M.end||M.points&&M.points.length>0)continue;const E=r.get(M.start),w=r.get(M.end);if(!E||!w)continue;const N=(w.x??0)-(E.x??0),H=(w.y??0)-(E.y??0);A.set(g,{edgeIdx:g,srcId:M.start,dstId:M.end,srcSide:T(E,{x:w.x??0,y:w.y??0}),dstSide:T(w,{x:E.x??0,y:E.y??0}),absDx:Math.abs(N),absDy:Math.abs(H),dxSign:Math.sign(N),dySign:Math.sign(H)})}const P=l(g=>g.srcSide==="top"||g.srcSide==="bottom"?g.absDx===0?1/0:g.absDy/g.absDx:g.absDy===0?1/0:g.absDx/g.absDy,"preferenceStrength"),O=l(g=>g.srcSide==="top"||g.srcSide==="bottom"?g.dxSign>=0?"right":"left":g.dySign>=0?"bottom":"top","secondarySide"),k=new Map;for(const g of A.values()){const M=`${g.srcId}:${g.srcSide}`;k.has(M)||k.set(M,[]),k.get(M).push(g)}const D=new Map,B=l((g,M)=>`${g}:${M}`,"loadKey");for(const g of A.values())D.set(B(g.srcId,g.srcSide),(D.get(B(g.srcId,g.srcSide))??0)+1),D.set(B(g.dstId,g.dstSide),(D.get(B(g.dstId,g.dstSide))??0)+1);for(const g of k.values())if(!(g.length<2)){g.sort((M,E)=>{const w=P(M),N=P(E);return Math.abs(w-N)>1e-9?N-w:M.edgeIdx-E.edgeIdx});for(let M=1;M<g.length;M++){const E=g[M],w=O(E),N=D.get(B(E.srcId,E.srcSide))??0,H=D.get(B(E.srcId,w))??0;H>=N||(D.set(B(E.srcId,E.srcSide),N-1),D.set(B(E.srcId,w),H+1),E.srcSide=w)}}const G=l(g=>{const M=g==null?void 0:g.shape;return M==="question"||M==="diamond"},"isDiamondNode"),j=new Map;for(const g of A.values())j.has(g.dstId)||j.set(g.dstId,new Set),j.get(g.dstId).add(g.dstSide);for(const g of A.values()){if(!G(r.get(g.srcId)))continue;const M=j.get(g.srcId);if(!(M!=null&&M.has(g.srcSide)))continue;const E=O(g);if(M.has(E)||(D.get(B(g.srcId,E))??0)>0)continue;const w=D.get(B(g.srcId,g.srcSide))??0;D.set(B(g.srcId,g.srcSide),Math.max(0,w-1)),D.set(B(g.srcId,E),1),g.srcSide=E}for(const g of A.values()){const{edgeIdx:M,srcId:E,dstId:w,srcSide:N,dstSide:H}=g,W=r.get(E),ot=r.get(w),U=`${E}:${N}:src`,$=N==="top"||N==="bottom"?ot.x??0:ot.y??0;m.has(U)||m.set(U,[]),m.get(U).push({edgeIdx:M,oppositeCoord:$});const bt=`${w}:${H}:dst`,dt=H==="top"||H==="bottom"?W.x??0:W.y??0;m.has(bt)||m.set(bt,[]),m.get(bt).push({edgeIdx:M,oppositeCoord:dt})}const tt=new Map,ft=8;for(const[g,M]of m){if(M.length<2)continue;M.sort((At,Gt)=>At.oppositeCoord-Gt.oppositeCoord);const E=g.split(":"),w=E.slice(0,-2).join(":"),N=E[E.length-2],H=E[E.length-1],W=r.get(w);if(!W)continue;const U=N==="left"||N==="right"?W.height??10:W.width??10,$=W.shape,dt=$==="question"||$==="diamond"?U*.3:U,st=Math.min(20,Math.max(ft,dt/(M.length+1))),Pt=-(st*(M.length-1))/2;for(const[At,Gt]of M.entries()){const ee=Pt+At*st,dn=`${Gt.edgeIdx}:${H}`;tt.set(dn,ee)}}const It=l(g=>{var M;return!!((M=s[g])!=null&&M.labelNodeId)},"edgeHasLabelNode"),Dt=l((g,M)=>g?(m.get(`${g}:${M}:src`)??[]).some(({edgeIdx:E})=>It(E))||(m.get(`${g}:${M}:dst`)??[]).some(({edgeIdx:E})=>It(E)):!1,"faceHasLabelNode"),_t=l((g,M,E)=>M==="top"||M==="bottom"?{x:g.x+E,y:g.y}:{x:g.x,y:g.y+E},"applyPortOffset"),nt=l((g,M,E)=>{const w=A.get(g),N={x:E.x??0,y:E.y??0},H={x:M.x??0,y:M.y??0},W=(w==null?void 0:w.srcSide)??T(M,N),ot=(w==null?void 0:w.dstSide)??T(E,H);let U=w?S(M,w.srcSide):d(M,N,!0),$=w?S(E,w.dstSide):d(E,H,!1);const bt=tt.get(`${g}:src`),dt=tt.get(`${g}:dst`);return bt!==void 0&&(U=_t(U,W,bt)),dt!==void 0&&($=_t($,ot,dt)),{pSrcPort:U,pDstPort:$,srcSide:W,dstSide:ot}},"portsForEdge");for(const g of L){const M=s[g];if(i[g]=[],!M.start||!M.end||M.points&&M.points.length>0||M.start===M.end)continue;const E=r.get(M.start),w=r.get(M.end);if(!E||!w)continue;const{pSrcPort:N,pDstPort:H,srcSide:W,dstSide:ot}=nt(g,E,w),U={...N},$={...H},bt=W==="top"||W==="bottom",dt=ot==="top"||ot==="bottom";if(bt){const X=N.y>(E.y??0);U.y=X?N.y+ie:N.y-ie}else{const X=N.x>(E.x??0);U.x=X?N.x+ie:N.x-ie}if(dt){const X=H.y>(w.y??0);$.y=X?H.y+ie:H.y-ie}else{const X=H.x>(w.x??0);$.x=X?H.x+ie:H.x-ie}const ct=l((X,z)=>{for(const Q of p)if(!z.includes(Q.nodeId)&&X.x>Q.minX&&X.x<Q.maxX&&X.y>Q.minY&&X.y<Q.maxY)return{inside:!0,obstacle:Q};return{inside:!1}},"isPointInObstacle"),st=l((X,z,Q,ht,wt)=>{if(wt){const kt=X.y>(z.y??0);return{x:(Q.x??0)>=X.x?ht.maxX+Se:ht.minX-Se,y:kt?ht.maxY+Re:ht.minY-Re,leavesPositiveSide:kt}}const Ct=X.x>(z.x??0),Rt=(Q.y??0)>=X.y;return{x:Ct?ht.maxX+Se:ht.minX-Se,y:Rt?ht.maxY+Re:ht.minY-Re,leavesPositiveSide:Ct}},"obstacleDetour");let Mt=[];const Pt=[M.start,M.end],At=ct(U,Pt);if(At.inside&&At.obstacle){const X=At.obstacle;if(bt){const z=st(N,E,w,X,!0);U.x=z.x,U.y=z.y;const Q=z.leavesPositiveSide?Math.min(X.minY-2,N.y+ie):Math.max(X.maxY+2,N.y-ie);Mt=[{x:N.x,y:Q},{x:z.x,y:Q},{x:z.x,y:z.y}]}else{const z=st(N,E,w,X,!1),Q=z.leavesPositiveSide?Math.min(X.minX-2,N.x+ie):Math.max(X.maxX+2,N.x-ie);U.x=z.x,U.y=z.y,Mt=[{x:Q,y:N.y},{x:Q,y:z.y},{x:z.x,y:z.y}]}}let Gt=[];const ee=ct($,Pt);if(ee.inside&&ee.obstacle){const X=ee.obstacle;if(dt){const z=st(H,w,E,X,!0);$.x=z.x,$.y=z.y,Gt=[{x:z.x,y:z.y},{x:H.x,y:z.y}]}else{const z=st(H,w,E,X,!1);$.x=z.x,$.y=z.y,Gt=[{x:z.x,y:z.y},{x:z.x,y:H.y}]}}if(Mt.length===0&&Gt.length===0){const X=Se,z=Math.abs(U.x-$.x)<X,Q=Math.abs(U.y-$.y)<X,ht=tt.get(`${g}:src`)!==void 0||tt.get(`${g}:dst`)!==void 0,wt=(((K=m.get(`${M.start??""}:${W}:src`))==null?void 0:K.length)??0)+(((J=m.get(`${M.start??""}:${W}:dst`))==null?void 0:J.length)??0),Ct=(((Y=m.get(`${M.end??""}:${ot}:src`))==null?void 0:Y.length)??0)+(((q=m.get(`${M.end??""}:${ot}:dst`))==null?void 0:q.length)??0),Rt=wt>1||Ct>1,kt=I.get(M.start??"")??0,mt=I.get(M.end??"")??0,Vt=wt>1&&Dt(M.start,W)||Ct>1&&Dt(M.end,ot),re=wt<=1||kt<=2,Ht=Ct<=1||mt<=2;if((z||Q)&&!ht&&(!Rt||Rt&&!Vt&&re&&Ht)&&!v(N,H,M.start,M.end)){M.points=[{...N},{...U},{...$},{...H}],y.add(g);const vt=Q?"horizontal":"vertical",Ut=Q?N.y:N.x,Lt=Q?Math.min(N.x,H.x):Math.min(N.y,H.y),Tt=Q?Math.max(N.x,H.x):Math.max(N.y,H.y),Jt={id:`fast-path-${vt}-${Ut.toFixed(0)}-${g}`,orientation:vt,coord:Ut,spanMin:Lt,spanMax:Tt,tracks:[]};u.push({edgeIndex:g,segmentIndex:0,orientation:vt,pipe:Jt,trackIndex:0,from:Lt,to:Tt});continue}}const dn=x("vertical",U.x,U.y,U.y);U.x=dn.coord;const Js=x("vertical",$.x,$.y,$.y);$.x=Js.coord;let me=Math.min(U.x,$.x)-50,xe=Math.max(U.x,$.x)+50,we=Math.min(U.y,$.y)-50,Ee=Math.max(U.y,$.y)+50;for(const X of p){const z=Math.min(U.x,$.x),Q=Math.max(U.x,$.x),ht=Math.min(U.y,$.y),wt=Math.max(U.y,$.y);X.minX<Q&&X.maxX>z&&X.minY<wt&&X.maxY>ht&&(me=Math.min(me,X.minX-$e),xe=Math.max(xe,X.maxX+$e),we=Math.min(we,X.minY-$e),Ee=Math.max(Ee,X.maxY+$e))}for(const X of p){if(X.maxX<me||X.minX>xe||X.maxY<we||X.minY>Ee)continue;const z=Se;x("horizontal",X.minY-z,me,xe),x("horizontal",X.maxY+z,me,xe);const Q=Re;x("vertical",X.minX-Q,we,Ee),x("vertical",X.maxX+Q,we,Ee)}x("horizontal",U.y,me,xe),x("horizontal",$.y,me,xe);const Qs=a.filter(X=>X.orientation==="horizontal"&&X.coord>=we&&X.coord<=Ee),tr=a.filter(X=>X.orientation==="vertical"&&X.coord>=me&&X.coord<=xe),Fe=l((X,z)=>`${X.toFixed(1)},${z.toFixed(1)}`,"getKey"),_e=Fe(U.x,U.y),bo=Fe($.x,$.y),He=new Map,un=new Map,hn=new Map,De=new Set,Me=[];He.set(_e,0),hn.set(_e,"n"),Me.push({key:_e,f:Math.hypot($.x-U.x,$.y-U.y),pt:U}),De.add(_e);let zt=[];const ye=l((X,z)=>v(X,z,M.start,M.end),"checkSegmentBlocked"),gn={x:$.x,y:U.y},er=ye(U,gn),nr=ye(gn,$),or=er||nr,mn={x:U.x,y:$.y},sr=ye(U,mn),rr=ye(mn,$);if(or?sr||rr||(Math.abs(U.x-$.x)<lt?zt=[U,$]:zt=[U,mn,$]):Math.abs(U.y-$.y)<lt||Math.abs(U.x-$.x)<lt?zt=[U,$]:zt=[U,gn,$],zt.length===0)for(;Me.length>0;){Me.sort((mt,Vt)=>mt.f-Vt.f);const X=Me.shift();if(De.delete(X.key),X.key===bo){let mt=bo,Vt=$;for(zt=[Vt];un.has(mt);){const re=un.get(mt);zt.unshift(re),Vt=re,mt=Fe(re.x,re.y)}break}const z=X.pt.x,Q=X.pt.y,ht=tr.sort((mt,Vt)=>mt.coord-Vt.coord),wt=ht.findIndex(mt=>Math.abs(mt.coord-z)<1),Ct=Qs.sort((mt,Vt)=>mt.coord-Vt.coord),Rt=Ct.findIndex(mt=>Math.abs(mt.coord-Q)<1),kt=[];wt>0&&kt.push({x:ht[wt-1].coord,y:Q}),wt>=0&&wt<ht.length-1&&kt.push({x:ht[wt+1].coord,y:Q}),Rt>0&&kt.push({x:z,y:Ct[Rt-1].coord}),Rt>=0&&Rt<Ct.length-1&&kt.push({x:z,y:Ct[Rt+1].coord});for(const mt of kt){const Vt=Math.min(z,mt.x),re=Math.max(z,mt.x),Ht=Math.min(Q,mt.y),jt=Math.max(Q,mt.y);if(p.some(ne=>ne.nodeId===M.start||ne.nodeId===M.end?!1:Vt!==re?ne.minY<Q&&ne.maxY>Q&&ne.maxX>Vt&&ne.minX<re:ne.minX<z&&ne.maxX>z&&ne.maxY>Ht&&ne.minY<jt))continue;const vt=Fe(mt.x,mt.y),Ut=Math.abs(mt.x-z)+Math.abs(mt.y-Q),Lt=b(g,X.pt,mt);let Tt=0;const Jt=$.x-U.x,Ae=$.y-U.y,Xe=mt.x-z,xn=mt.y-Q;(Ae>10&&xn<-5||Ae<-10&&xn>5)&&(Tt=Math.abs(xn)*100),(Jt>10&&Xe<-5||Jt<-10&&Xe>5)&&(Tt+=Math.abs(Xe)*50);let Io=0;const Mo=hn.get(X.key)??"n",So=Math.abs(Xe)>lt?"h":"v";Mo!=="n"&&Mo!==So&&(Io=50);const ir=Ut+Lt+Tt+Io,Ye=(He.get(X.key)??1/0)+ir,Co=Math.abs($.x-mt.x)+Math.abs($.y-mt.y);if(Ye<(He.get(vt)??1/0))if(un.set(vt,X.pt),He.set(vt,Ye),hn.set(vt,So),!De.has(vt))Me.push({key:vt,f:Ye+Co,pt:mt}),De.add(vt);else{const ne=Me.findIndex(cr=>cr.key===vt);ne!==-1&&(Me[ne].f=Ye+Co)}}}if(zt.length===0&&(zt=[U,{x:U.x,y:$.y},$]),zt.length>4){const X=zt[0],z=zt[zt.length-1];let Q=Math.min(X.x,z.x),ht=Math.max(X.x,z.x),wt=Math.min(X.y,z.y),Ct=Math.max(X.y,z.y);for(const Ht of zt)Q=Math.min(Q,Ht.x),ht=Math.max(ht,Ht.x),wt=Math.min(wt,Ht.y),Ct=Math.max(Ct,Ht.y);const Rt=ht>Math.max(X.x,z.x),kt=Q<Math.min(X.x,z.x);if(f){const Ht=Re;if(Rt){const jt=Math.max(X.x,z.x),Ft=Math.min(X.y,z.y),vt=Math.max(X.y,z.y),Ut=p.filter(Lt=>Lt.minX<jt&&Lt.maxX>jt&&Lt.minY<vt&&Lt.maxY>Ft);if(Ut.length>0){let Lt=Math.max(X.x,z.x);for(const Tt of Ut){const Jt=(Tt.minX+Tt.maxX)/2;if(Tt.visualXHalfExtent===void 0||isNaN(Tt.visualXHalfExtent))continue;const Ae=Jt+Tt.visualXHalfExtent+Ht;Lt=Math.max(Lt,Ae)}isNaN(Lt)||(ht=Lt)}}if(kt){const jt=p.filter(Ft=>Ft.minX<Math.min(X.x,z.x)+Ht&&Ft.minY<Math.max(X.y,z.y)&&Ft.maxY>Math.min(X.y,z.y));if(jt.length>0){let Ft=Math.min(X.x,z.x);for(const vt of jt){const Lt=(vt.minX+vt.maxX)/2-vt.visualXHalfExtent-Ht;Ft=Math.min(Ft,Lt)}Q=Ft}}}const mt=l(Ht=>{const jt=z.y>X.y,Ft=p.filter(Lt=>{const Tt=Math.min(X.x,z.x)<Lt.maxX&&Math.max(X.x,z.x)>Lt.minX,Jt=Math.min(X.y,z.y)<Lt.maxY&&Math.max(X.y,z.y)>Lt.minY;return Tt&&Jt});let vt=Ft;if(f&&Ft.length>0){const Lt=Ft.filter(Tt=>Tt.minX<Ht&&Tt.maxX>Ht);Lt.length>0&&(vt=Lt)}if(vt.length===0)return z.y;const Ut=Se;if(jt){const Tt=Math.max(...vt.map(Jt=>Jt.maxY))+Ut;if(Tt<z.y-lt)return Tt}else{const Tt=Math.min(...vt.map(Jt=>Jt.minY))-Ut;if(Tt>z.y+lt)return Tt}return z.y},"findBestReturnY"),Vt=l(Ht=>{const jt=mt(Ht),Ft={x:Ht,y:X.y},vt={x:Ht,y:jt},Ut={x:z.x,y:jt},Lt=ye(X,Ft),Tt=ye(Ft,vt),Jt=ye(vt,Ut),Ae=jt!==z.y?ye(Ut,z):!1;return!Lt&&!Tt&&!Jt&&!Ae?Math.abs(jt-z.y)<lt?[X,Ft,vt,z]:[X,Ft,vt,Ut,z]:null},"trySimplifyWithDetourX"),re=Rt&&!kt?Vt(ht):kt&&!Rt?Vt(Q):null;re&&(zt=re)}const $t=[N,...Mt,...zt,...Gt.reverse(),H];if($t.length>=3){const X=$t[$t.length-1],z=$t[$t.length-2],Q=$t[$t.length-3],ht=Math.abs(Q.y-z.y)<lt&&Math.abs(z.y-X.y)<lt,wt=Math.abs(Q.x-z.x)<lt&&Math.abs(z.x-X.x)<lt;if(ht){const Ct=Math.sign(z.x-Q.x),Rt=Math.sign(X.x-Q.x);Ct!==0&&Ct===Rt&&Math.abs(z.x-Q.x)>Math.abs(X.x-Q.x)&&$t.splice(-2,1)}else if(wt){const Ct=Math.sign(z.y-Q.y),Rt=Math.sign(X.y-Q.y);Ct!==0&&Ct===Rt&&Math.abs(z.y-Q.y)>Math.abs(X.y-Q.y)&&$t.splice(-2,1)}}const le=[$t[0]];for(let X=1;X<$t.length-1;X++){if(X===1){le.push($t[X]);continue}const z=le[le.length-1],Q=$t[X],ht=$t[X+1];if(Math.abs(z.y-Q.y)<lt&&Math.abs(Q.y-ht.y)<lt){const wt=Q.x>z.x,Ct=ht.x>Q.x;if(wt!==Ct){le.push(Q);continue}continue}if(Math.abs(z.x-Q.x)<lt&&Math.abs(Q.x-ht.x)<lt){const wt=Q.y>z.y,Ct=ht.y>Q.y;if(wt!==Ct){le.push(Q);continue}continue}le.push(Q)}le.push($t[$t.length-1]);for(let X=0;X<le.length-1;X++){const z=le[X],Q=le[X+1],ht=Math.abs(z.x-Q.x)<lt?"vertical":"horizontal",wt=ht==="vertical"?z.x:z.y,Ct=ht==="vertical"?Math.min(z.y,Q.y):Math.min(z.x,Q.x),Rt=ht==="vertical"?Math.max(z.y,Q.y):Math.max(z.x,Q.x),kt=x(ht,wt,Ct,Rt),mt={edgeIndex:g,segmentIndex:X,orientation:ht,pipe:kt,trackIndex:0,from:Ct,to:Rt};u.push(mt),i[g].push(u.length-1),kt.tracks[0]||(kt.tracks[0]={index:0,coord:kt.coord,segments:[]}),kt.tracks[0].segments.push({edgeIndex:g,segmentIndex:X,from:Ct,to:Rt})}}const Z=l((g,M)=>g.from<M.to&&M.from<g.to,"segmentsOverlap"),rt=l((g,M,E,w)=>{const N=!w.segments.some(W=>(W.edgeIndex!==M.edgeIndex||W.segmentIndex!==M.segmentIndex)&&Z(W,g)),H=!E.segments.some(W=>(W.edgeIndex!==g.edgeIndex||W.segmentIndex!==g.segmentIndex)&&Z(W,M));return N&&H?(g.trackIndex=w.index,M.trackIndex=E.index,E.segments=[...E.segments.filter(W=>W.edgeIndex!==g.edgeIndex||W.segmentIndex!==g.segmentIndex),{edgeIndex:M.edgeIndex,segmentIndex:M.segmentIndex,from:M.from,to:M.to}],w.segments=[...w.segments.filter(W=>W.edgeIndex!==M.edgeIndex||W.segmentIndex!==M.segmentIndex),{edgeIndex:g.edgeIndex,segmentIndex:g.segmentIndex,from:g.from,to:g.to}],!0):!1},"trySwapSegmentsAcrossTracks"),ut=l(g=>{const M=g.tracks.length;return g.tracks[M]={index:M,coord:g.coord,segments:[]},M},"createNewTrack"),yt=l((g,M)=>{const E=g.pipe.tracks[g.trackIndex];E.segments=E.segments.filter(N=>N.edgeIndex!==g.edgeIndex||N.segmentIndex!==g.segmentIndex),g.trackIndex=M,g.pipe.tracks[M].segments.push({edgeIndex:g.edgeIndex,segmentIndex:g.segmentIndex,from:g.from,to:g.to})},"moveSegmentToTrack"),St=l((g,M)=>{const E=i[g.edgeIndex];for(const w of E){const N=u[w];N.pipe===g.pipe&&yt(N,M)}},"moveSegmentChainToTrack"),Et=l(g=>{const M=i[g.edgeIndex],E=M.indexOf(u.indexOf(g)),w=[];return E>0&&w.push(u[M[E-1]]),E<M.length-1&&w.push(u[M[E+1]]),w},"getAdjacentSegmentsAlongEdge"),Kt=l((g,M)=>{if(g.orientation===M.orientation)return!1;const E=g.orientation==="horizontal"?g:M,w=g.orientation==="horizontal"?M:g;return w.pipe.coord>E.from&&w.pipe.coord<E.to&&E.pipe.coord>w.from&&E.pipe.coord<w.to},"haveAnyCrossing"),qt=l((g,M)=>{for(const E of g.tracks)if(!E.segments.some(N=>(N.edgeIndex!==M.edgeIndex||N.segmentIndex!==M.segmentIndex)&&Z(N,M)))return E.index;return-1},"findAvailableTrack"),Zt=l((g,M)=>{if(g.trackIndex===M.trackIndex)return Z(g,M);const E=Et(g),w=Et(M);return E.some(N=>w.some(H=>Kt(N,H)))},"segmentsConflict"),se=l((g,M,E)=>{if(rt(g,M,g.pipe.tracks[g.trackIndex],M.pipe.tracks[M.trackIndex]))return;const w=qt(g.pipe,M);E(M,w!==-1?w:ut(g.pipe))},"resolveTrackConflict"),Le=l(g=>{let M=0;for(let E=0;E<g.length;E++)for(let w=E+1;w<g.length;w++){const N=g[E],H=g[w];N.pipe===H.pipe&&Zt(N,H)&&(M++,se(N,H,St))}return M},"resolveHandleConflicts"),ge=new Map,Te=l(g=>{if(ge.has(g))return ge.get(g);const M=i[g];if(M.length===0){const ot={dest:0,deviation:0,base:0,delta:0};return ge.set(g,ot),ot}const w=u[M[0]].pipe.coord;let N=w;for(let ot=1;ot<M.length;ot++){const U=u[M[ot]];if(U.orientation==="horizontal"){const $=U.from,bt=U.to;N=Math.abs($-w)>Math.abs(bt-w)?$:bt;break}}const H=Math.abs(N-w),W={dest:N,deviation:H,base:w,delta:N-w};return ge.set(g,W),W},"getDestInfo"),an=l(()=>{let g=0;const M=new Map;for(const[w,N]of s.entries())i[w].length!==0&&N.start&&(M.has(N.start)||M.set(N.start,[]),M.get(N.start).push(w));const E=l(w=>{const N=s[w];if(!N.start||!N.end)return 0;const H=r.get(N.start),W=r.get(N.end);if(!H||!W)return 0;const ot=(W.x??0)-(H.x??0),U=(W.y??0)-(H.y??0);return Math.abs(ot)+Math.abs(U)},"getEdgeDistance");for(const w of M.values()){w.sort((H,W)=>{const ot=Te(H),U=Te(W);if(Math.abs(ot.deviation-U.deviation)>1)return ot.deviation-U.deviation;if(Math.abs(ot.dest-U.dest)>1)return ot.dest-U.dest;const $=E(H),bt=E(W);if(Math.abs($-bt)>1)return bt-$;const dt=i[H].length,ct=i[W].length;if(dt!==ct)return dt-ct;if(dt===1){const st=i[H][0],Mt=i[W][0];if(u[st]&&u[Mt]){const Pt=u[st],At=u[Mt],Gt=Math.abs(Pt.to-Pt.from),ee=Math.abs(At.to-At.from);if(Math.abs(Gt-ee)>1)return Gt-ee}}return 0});const N=w.map(H=>u[i[H][0]]);g+=Le(N)}return g},"fixSourceHandleCrossings"),ln=l(()=>{let g=0;const M=new Map;for(const[E,w]of s.entries())i[E].length!==0&&w.end&&(M.has(w.end)||M.set(w.end,[]),M.get(w.end).push(E));for(const E of M.values()){E.sort((N,H)=>{const W=l($=>{const bt=i[$];if(bt.length<2)return 0;const dt=u[bt[bt.length-2]];return Math.abs(dt.to-dt.from)},"getDist"),ot=W(N),U=W(H);return Math.abs(ot-U)>.1?ot-U:N-H});const w=E.map(N=>u[i[N][i[N].length-1]]);g+=Le(w)}return g},"fixTargetHandleCrossings"),fn=l(()=>{let g=0;for(const M of a){const E=[];for(const w of M.tracks)for(const N of w.segments){const H=i[N.edgeIndex].find(W=>u[W].segmentIndex===N.segmentIndex);H!==void 0&&E.push(u[H])}E.sort((w,N)=>w.edgeIndex-N.edgeIndex||w.segmentIndex-N.segmentIndex);for(let w=0;w<E.length;w++)for(let N=w+1;N<E.length;N++){const H=E[w],W=E[N];Zt(H,W)&&(g++,se(H,W,yt))}}return g},"fixPipeCrossings");let R=0;const F=10;for(;R<F;){let g=0;if(g+=an(),g+=ln(),g+=fn(),g===0)break;R++}const _=new Map;for(const g of a){const M=[];g.tracks.forEach(w=>{w.segments.forEach(N=>{M.push({edgeIndex:N.edgeIndex,segmentIndex:N.segmentIndex,trackIndex:w.index,from:N.from,to:N.to})})}),M.sort((w,N)=>w.from-N.from);const E=[];if(M.length>0){let w=[M[0]],N=M[0].to;for(let H=1;H<M.length;H++){const W=M[H];W.from<N?(w.push(W),N=Math.max(N,W.to)):(E.push(w),w=[W],N=W.to)}E.push(w)}for(const w of E){const N=new Set;w.forEach(st=>N.add(st.trackIndex));const H=new Map;w.forEach(st=>{const Mt=Te(st.edgeIndex);H.set(st.trackIndex,(H.get(st.trackIndex)??0)+Mt.delta)});const W=[...N].filter(st=>(H.get(st)??0)<-1),ot=[...N].filter(st=>(H.get(st)??0)>1),U=[...N].filter(st=>Math.abs(H.get(st)??0)<=1);W.sort((st,Mt)=>(H.get(Mt)??0)-(H.get(st)??0)),ot.sort((st,Mt)=>(H.get(st)??0)-(H.get(Mt)??0));const $=l((st,Mt)=>{w.filter(Pt=>Pt.trackIndex===st).forEach(Pt=>{const At=y.has(Pt.edgeIndex)?g.coord:Mt;_.set(`${Pt.edgeIndex}-${Pt.segmentIndex}`,At)})},"assignCoord");let bt=0;for(const st of W)bt++,$(st,g.coord-bt*In);if(U.length===0&&N.size>0){const st=[...N].sort((At,Gt)=>Math.abs(H.get(At)??0)-Math.abs(H.get(Gt)??0))[0],Mt=W.indexOf(st);Mt!==-1&&W.splice(Mt,1);const Pt=ot.indexOf(st);Pt!==-1&&ot.splice(Pt,1),U.push(st)}let dt=0;for(const st of U){if(dt===0)$(st,g.coord);else{const Mt=dt%2===1?1:-1,Pt=Math.ceil(dt/2);$(st,g.coord+Mt*Pt*In*.5)}dt++}let ct=0;for(const st of ot)ct++,$(st,g.coord+ct*In)}}for(const[g,M]of s.entries()){const E=i[g]??[];if(E.length===0)continue;const w=[],N=r.get(M.start),H=r.get(M.end),{pSrcPort:W,pDstPort:ot}=nt(g,N,H),U=E.map(dt=>{const ct=u[dt],st=_.get(`${ct.edgeIndex}-${ct.segmentIndex}`)??ct.pipe.coord;return{orient:ct.orientation,coord:st,from:ct.from,to:ct.to}});w.push(W);for(let dt=0;dt<U.length;dt++){const ct=U[dt],st=w[w.length-1],Mt=ct.orient==="vertical"?st.y:st.x,Pt=ct.orient==="vertical"?st.x:st.y,At=U[dt+1],Gt=dt<U.length-1;if(Math.abs(Pt-ct.coord)>lt&&w.push(Ce(ct,Mt)),Gt&&At.orient===ct.orient)if(Math.abs(ct.coord-At.coord)>lt){const ee=ct.orient==="vertical"?(Mt+At.from)/2:Jn(ct,At);w.push(Ce(ct,ee),Ce(At,ee))}else(dt===0||dt===U.length-2)&&w.push(Ce(ct,Jn(ct,At)));else if(Gt)w.push(Ce(ct,At.coord));else{const ee=Math.abs(ct.from-Mt)<Math.abs(ct.to-Mt)?ct.to:ct.from;w.push(Ce(ct,ee))}}const $=w[w.length-1];(Math.abs($.x-ot.x)>lt||Math.abs($.y-ot.y)>lt)&&w.push(ot);const bt=[];w.length>0&&bt.push(w[0]);for(let dt=1;dt<w.length;dt++){const ct=w[dt],st=bt[bt.length-1];(Math.abs(ct.x-st.x)>lt||Math.abs(ct.y-st.y)>lt)&&bt.push(ct)}M.points=bt}for(const g of s){const M=g.__originalEdge;M&&g.points&&(M.points=g.points)}t.edges=(t.edges??[]).filter(g=>!g.isLayoutOnly);const V=l((g,M)=>{const E=M.x??0,w=M.y??0,N=M.width??0,H=M.height??0;if(N<=0||H<=0)return g;const W=E-N/2,ot=E+N/2,U=w-H/2,$=w+H/2;if(g.x<W||g.x>ot||g.y<U||g.y>$)return g;const bt=g.x-W,dt=ot-g.x,ct=g.y-U,st=$-g.y,Mt=Math.min(bt,dt,ct,st);return Mt===bt?{x:W,y:g.y}:Mt===dt?{x:ot,y:g.y}:Mt===ct?{x:g.x,y:U}:{x:g.x,y:$}},"nodeBoundaryClamp");for(const g of t.edges){const M=g.points;if(!M||M.length<2)continue;const E=g.start,w=g.end,N=E?r.get(E):void 0,H=w?r.get(w):void 0;N&&(M[0]=V(M[0],N)),H&&(M[M.length-1]=V(M[M.length-1],H))}return t}l(Ws,"routeEdgesOrthogonal");function Ks(t){return t.direction??"TB"}l(Ks,"getSwimlaneDirection");function qs(t){var p,x,S,d,u;const e=Oo(t),n=((p=t.config.flowchart)==null?void 0:p.nodeSpacing)??40,o=((x=t.config.flowchart)==null?void 0:x.rankSpacing)??100,s=((S=t.config.swimlane)==null?void 0:S.ignoreCrossLaneEdges)??!0,r=((d=t.config.swimlane)==null?void 0:d.optimizeRanksByCrossings)??!0,c=((u=t.config.swimlane)==null?void 0:u.automaticLaneOrdering)??!1,a=Ks(t),{ordered:f,coordinates:h}=Us(e,{nodeGap:n,layerGap:o,ignoreCrossLaneEdges:s,optimizeRanksByCrossings:r,automaticLaneOrdering:c,direction:a});Bo(e,f,h,{nodeGap:n,layerGap:o});for(const i of t.edges??[])delete i.points;Ws(t,a);for(const i of t.edges??[])(!i.curve||i.curve==="basis")&&(i.curve="rounded");return ds(t,a),fs(t),a}l(qs,"runSwimlaneLayoutCore");function Zs(t){No(t);const e=Po(t);t.nodes=e.nodes,t.edges=e.edges}l(Zs,"prepareSwimlaneLayout");var wr=lr({prepareLayout:Zs,runLayoutCore:qs,afterPaint:Ao});export{wr as render};
|
|
1
|
+
import{a as ar}from"./chunk-NETBCI7D-D-NIf3Jh.js";import{c as lr}from"./chunk-3FUC2YCW-BKsUOX0P.js";import{_ as l,l as Mn}from"./index-BFkHoNBz.js";import"./graph-DcfhsBxO.js";import"./element-plus-IBMLLhb-.js";import"./vue-BhwNxZ68.js";function Ao(t,{measure:e}){var r,c;const n=(c=(r=t.config)==null?void 0:r.swimlane)==null?void 0:c.lineHops;if(n===!1)return;const o=n==="gap"?"gap":"arc",s=t.edges.filter(a=>Array.isArray(a.points)&&a.points.length>=2).map(a=>({id:a.id,points:a.points,curve:a.curve,arrowTypeStart:a.arrowTypeStart,arrowTypeEnd:a.arrowTypeEnd}));ar(e.groups.edgePaths,s,{enabled:!0,jumpRadius:6,jumpStyle:o})}l(Ao,"applySwimlaneLineJumps");var yn="__swimlane_default__",fr=21,vo=20;function Sn(t){return Math.max(t.padding??vo,vo)}l(Sn,"topLaneHorizontalPadding");function Ro(t){const{x:e,y:n,width:o,height:s}=t,r=t.swimlaneContentTop;if(typeof e!="number"||typeof n!="number"||typeof o!="number"||typeof s!="number"||typeof r!="number"||!Number.isFinite(e)||!Number.isFinite(n)||!Number.isFinite(o)||!Number.isFinite(s)||!Number.isFinite(r)||o<=0||s<=0){delete t.groupTitleRect;return}const c=n-s/2,a=Math.min(r,n+s/2),f=Math.min(fr,Math.max(0,a-c)),h=c+f;if(h<=c){delete t.groupTitleRect;return}t.groupTitleRect={left:e-o/2,right:e+o/2,top:c,bottom:h}}l(Ro,"assignTopLaneTitleRect");function No(t){var r;const e=t.direction,n=t.nodes??(t.nodes=[]);for(const c of t.nodes??[])c.isGroup&&!c.parentId&&(c.shape="swimlane",e&&(c.direction=e));const o=n.filter(c=>!c.isGroup&&!c.parentId);if(o.length===0)return;let s=n.find(c=>c.id===yn);s?s.isGroup&&(s.shape="swimlane",e&&(s.direction=e)):(s={id:yn,label:"",isGroup:!0,shape:"swimlane",padding:20,look:(r=t.config)==null?void 0:r.look,colorIndex:n.reduce((c,a)=>Math.max(c,a.colorIndex??-1),-1)+1,...e?{direction:e}:{}},n.push(s));for(const c of o)c.parentId=yn}l(No,"prepareLayoutForSwimlanes");function Oo(t){const e=new Map;for(const f of t.nodes??[])e.set(f.id,f);const n=[];for(const f of t.edges??[]){const h=typeof f.start=="string"?f.start:void 0,p=typeof f.end=="string"?f.end:void 0;!h||!p||f.labelNodeId||n.push({id:f.id,src:h,dst:p,ref:f})}const o=t.nodes??[],s=o.filter(f=>f.isGroup),r=o.filter(f=>!f.isGroup);return{nodes:[...[...s].reverse(),...r].map(f=>f.id),edges:n,layout:t,nodeById:e}}l(Oo,"toGraphView");function Bo(t,e,n,o){const{layout:s}=t,r=t.nodeById,c=(o==null?void 0:o.layerGap)??100,a=(o==null?void 0:o.nodeGap)??40;let f=0;for(const S of e.layers){let d=0;for(const u of S){const i=r.get(u);if(!i){d++;continue}i.layer=f,i.order=d;const y=n.x[u]??d*a,C=n.y[u]??f*c;i.x=y,i.y=C,d++}f++}const h=s.nodes??[],p=new Map,x=[];for(const S of h){if(!(S!=null&&S.isGroup))continue;S.parentId||x.push(S);const d=h.filter(b=>b.parentId===S.id);let u=1/0,i=-1/0,y=1/0,C=-1/0;for(const b of d){const L=b.x??n.x[b.id],v=b.y??n.y[b.id],m=b.width??0,I=b.height??0;L!=null&&v!=null&&(u=Math.min(u,L-m/2),i=Math.max(i,L+m/2),y=Math.min(y,v-I/2),C=Math.max(C,v+I/2))}if(u===1/0||y===1/0)S.x=S.x??0,S.y=S.y??0,S.width=S.width??0,S.height=S.height??0;else{const b=S.padding??20,L=S.parentId?b:2*Sn(S),v=b,m=Math.max(0,i-u)+L,I=Math.max(0,C-y)+v,T=(u+i)/2,A=(y+C)/2;S.x=T,S.y=A,S.width=m,S.height=I,p.set(S.id,{minX:u,maxX:i,minY:y,maxY:C})}}if(x.length>0&&p.size>0){let S=1/0,d=-1/0,u=0;for(const i of x){const y=i.padding??20;y>u&&(u=y);const C=p.get(i.id);C&&(S=Math.min(S,C.minY),d=Math.max(d,C.maxY))}if(S!==1/0&&d!==-1/0){const i=Math.max(0,d-S),C=Math.max(u,36),b=i+2*C,L=(S+d)/2;for(const P of x)P.y=L,P.height=b,P.swimlaneContentTop=S;const v=[...x].sort((P,O)=>{const k=P.x??0,D=O.x??0;return k-D}),m=[],I=[],T=[];for(const P of v){const O=p.get(P.id);if(!O)continue;const k=Math.max(0,O.maxX-O.minX)+2*Sn(P),D=(O.minX+O.maxX)/2;m.push(P.id),I.push(D),T.push(k)}const A=m.length;if(A>0){const P=new Map;if(A===1)P.set(m[0],T[0]);else{const O=[];for(let j=0;j<A-1;j++)O.push(I[j+1]-I[j]);const k=new Array(A);k[0]=0;for(let j=0;j<A-1;j++)k[j+1]=2*O[j]-k[j];let D=0,B=Number.POSITIVE_INFINITY;for(let j=0;j<A;j++){const tt=T[j];j%2===0?D=Math.max(D,tt-k[j]):B=Math.min(B,k[j]-tt)}let G=D;D<=B?G=(D+B)/2:G=D;for(let j=0;j<A;j++){const tt=k[j]+(j%2===0?G:-G),ft=Math.max(T[j],tt);P.set(m[j],ft)}}for(const O of x){const k=P.get(O.id);k!=null&&(O.width=k),Ro(O)}}}}}l(Bo,"writeBackToLayoutData");var dr="[EdgeLabelNodes]";function Po(t){const e=[],n=[],o=new Map;for(const c of t.nodes)o.set(c.id,c);for(const c of t.edges){if(!c.label||c.label.length===0||c.isLayoutOnly||c.labelNodeId)continue;const a=c.start?o.get(c.start):void 0,f=c.end?o.get(c.end):void 0;if(!a||!f){Mn.warn(dr,`Edge ${c.id} has missing source or target node`);continue}const h=`edge-label-${c.start}-${c.end}-${c.id}`,x=a.parentId!==f.parentId?f.parentId:a.parentId,S={id:h,label:c.label,edgeStart:c.start??"",edgeEnd:c.end??"",shape:"labelRect",width:0,height:0,isEdgeLabel:!0,isDummy:!0,parentId:x,isGroup:!1,labelStyle:Array.isArray(c.labelStyle)?c.labelStyle[0]:c.labelStyle??"",...a.dir?{dir:a.dir}:{}};e.push(S),c.labelNodeId=h,c.label=void 0,c.text=void 0;const d={id:`${c.id}-to-label`,start:c.start,end:h,type:"normal",isLayoutOnly:!0},u={id:`${c.id}-from-label`,start:h,end:c.end,type:"normal",isLayoutOnly:!0};n.push(d,u)}const s=[...t.nodes,...e],r=[...t.edges,...n];return{...t,nodes:s,edges:r}}l(Po,"createEdgeLabelNodes");var Yt=.001;function Qn(t){const e=t.x??0,n=t.y??0,o=t.width??0,s=t.height??0;return o>0&&s>0?{cx:e,cy:n,rect:Ne(e,n,o,s)}:void 0}l(Qn,"measuredNodeRect");function to(t){if(t.isGroup)return;const e=Qn(t);return e?{id:String(t.id??""),cx:e.cx,cy:e.cy,rect:e.rect}:void 0}l(to,"nodeBoundsInfoFor");function ce(t,e,n=Yt){return Math.abs(t.x-e.x)<n&&Math.abs(t.y-e.y)<n}l(ce,"samePoint");function gt(t,e,n=Yt){return Math.abs(t.x-e.x)<n}l(gt,"sameX");function xt(t,e,n=Yt){return Math.abs(t.y-e.y)<n}l(xt,"sameY");function Nt(t,e,n=Yt){return xt(t,e,n)&&Math.abs(t.x-e.x)>n}l(Nt,"isHorizontalSegment");function Ot(t,e,n=Yt){return gt(t,e,n)&&Math.abs(t.y-e.y)>n}l(Ot,"isVerticalSegment");function Wt(t,e,n,o){return Math.max(0,Math.min(Math.max(t,e),Math.max(n,o))-Math.max(Math.min(t,e),Math.min(n,o)))}l(Wt,"overlapLength");function fe(t,e,n=Yt){return t.horizontal&&e.horizontal&&xt(t.a,e.a,n)?Wt(t.a.x,t.b.x,e.a.x,e.b.x):t.vertical&&e.vertical&>(t.a,e.a,n)?Wt(t.a.y,t.b.y,e.a.y,e.b.y):0}l(fe,"sameAxisSegmentOverlapLength");function Oe(t,e=Yt){const n=[];for(let o=0;o<t.length-1;o++){const s=t[o],r=t[o+1],c=Nt(s,r,e),a=Ot(s,r,e);(c||a)&&n.push({index:o,a:s,b:r,horizontal:c,vertical:a})}return n}l(Oe,"orthogonalSegmentsForPoints");function oe(t,e=Yt){const n=Oe(t,e);let o=0;for(let s=1;s<n.length;s++)n[s-1].horizontal!==n[s].horizontal&&o++;return o}l(oe,"countOrthogonalBends");function pt(t,e=Yt){const n=[];for(const o of t){const s=n.length>0?n[n.length-1]:void 0;(!s||!ce(s,o,e))&&n.push({x:o.x,y:o.y})}return n}l(pt,"dedupeConsecutivePoints");function eo(t,e=Yt){if(!t||t.length!==4)return;const[n,o,s,r]=t;return Nt(n,o,e)&&Ot(o,s,e)&&Nt(s,r,e)?{kind:"HVH",p0:n,p1:o,p2:s,p3:r}:Ot(n,o,e)&&Nt(o,s,e)&&Ot(s,r,e)?{kind:"VHV",p0:n,p1:o,p2:s,p3:r}:void 0}l(eo,"classifyThreeSegmentRoute");function nn(t,e,n,o=0){const s=Math.min(t.x,e.x),r=Math.max(t.x,e.x),c=Math.min(t.y,e.y),a=Math.max(t.y,e.y);return r>n.left-o&&s<n.right+o&&a>n.top-o&&c<n.bottom+o}l(nn,"segmentBoundsOverlapRect");function no(t,e,n=0){return t.x>e.left+n&&t.x<e.right-n&&t.y>e.top+n&&t.y<e.bottom-n}l(no,"pointInsideRect");function ko(t,e){return t.left<=e.left&&t.right>=e.right&&t.top<=e.top&&t.bottom>=e.bottom}l(ko,"rectContainsRect");function Ue(t,e){return t.left<e.right&&t.right>e.left&&t.top<e.bottom&&t.bottom>e.top}l(Ue,"rectsOverlap");function Cn(t,e){return{left:t.left-e,right:t.right+e,top:t.top-e,bottom:t.bottom+e}}l(Cn,"inflateRect");function Ne(t,e,n,o){return{left:t-n/2,right:t+n/2,top:e-o/2,bottom:e+o/2}}l(Ne,"rectFromCenterSize");function te(t){var e;return(e=Qn(t))==null?void 0:e.rect}l(te,"rectOfNodeBounds");function ve(t,e){switch(e){case"top":return{x:t.cx,y:t.rect.top};case"bottom":return{x:t.cx,y:t.rect.bottom};case"left":return{x:t.rect.left,y:t.cy};case"right":return{x:t.rect.right,y:t.cy}}}l(ve,"portForRectSide");function oo(t,e,n,o,s,r=Yt){const c=e==="left"||e==="right",a=o==="left"||o==="right";if(c&&a){if(e==="right"&&o==="left"&&t.x<n.x||e==="left"&&o==="right"&&t.x>n.x){if(xt(t,n,r))return[t,n];const x=(t.x+n.x)/2;return[t,{x,y:t.y},{x,y:n.y},n]}if(e===o){if(xt(t,n,r))return;const x=e==="left"?Math.min(t.x,n.x)-s:Math.max(t.x,n.x)+s;return[t,{x,y:t.y},{x,y:n.y},n]}return}if(!c&&!a){if(e===o){if(gt(t,n,r))return;const S=e==="top"?Math.min(t.y,n.y)-s:Math.max(t.y,n.y)+s;return[t,{x:t.x,y:S},{x:n.x,y:S},n]}if(!(e==="bottom"&&o==="top"&&t.y<n.y||e==="top"&&o==="bottom"&&t.y>n.y))return;if(gt(t,n,r))return[t,n];const x=(t.y+n.y)/2;return[t,{x:t.x,y:x},{x:n.x,y:x},n]}if(c&&!a){const p=e==="right"&&n.x>t.x||e==="left"&&n.x<t.x,x=o==="top"&&t.y<n.y||o==="bottom"&&t.y>n.y;return p&&x?[t,{x:n.x,y:t.y},n]:void 0}const f=e==="bottom"&&n.y>t.y||e==="top"&&n.y<t.y,h=o==="left"&&t.x<n.x||o==="right"&&t.x>n.x;return f&&h?[t,{x:t.x,y:n.y},n]:void 0}l(oo,"buildOrthogonalPortPath");function so(t,e,n,o){return e==="left"||e==="right"?[t,{x:o,y:t.y},{x:o,y:n.y},n]:[t,{x:t.x,y:o},{x:n.x,y:o},n]}l(so,"buildSameSideTrackPath");function on(t){const e=new Map,n=[];for(const o of t){if(o.isEdgeLabel)continue;const s=to(o);s&&(e.set(s.id,s),n.push({id:s.id,rect:s.rect}))}return{nodeInfoById:e,realNodeRects:n}}l(on,"collectRealNodeBounds");function be(t){const e=[],n=[];for(const o of t){const s=to(o);if(!s)continue;const r={id:s.id,rect:s.rect};o.isEdgeLabel?n.push(r):e.push(r)}return{realNodeRects:e,labelNodeRects:n}}l(be,"collectNodeRectEntries");function Fo(t,{includeEdgeLabels:e=!0}={}){const n=[];for(const o of t){if(o.isGroup||!e&&o.isEdgeLabel)continue;const s=o.x??0,r=o.y??0,c=o.width??0,a=o.height??0;n.push({nodeId:o.id,...Ne(s,r,c,a)})}return n}l(Fo,"collectLayoutNodeRects");function ro(t,e,n=Yt){const o=t.start,s=t.end;if(!o||!s)return;const r=e.get(o),c=e.get(s);if(!(!r||!c))return{srcId:o,dstId:s,srcInfo:r,dstInfo:c,collinearX:Math.abs(r.cx-c.cx)<n,collinearY:Math.abs(r.cy-c.cy)<n}}l(ro,"getNodePairGeometry");function Bt(t,e,n,o=[],s=0){for(const r of n)if(!o.includes(r.id)&&nn(t,e,r.rect,-s))return!0;return!1}l(Bt,"segmentHitsAnyRect");function io(t,e,n,o,s=Yt,r=1e-6){const c=xt(t,e,s),a=gt(t,e,s),f=xt(n,o,s),h=gt(n,o,s);if(c&&f||a&&h||!(c||a)||!(f||h))return!1;const p=c?{a:t,b:e}:{a:n,b:o},x=a?{a:t,b:e}:{a:n,b:o},S=p.a.y,d=Math.min(p.a.x,p.b.x),u=Math.max(p.a.x,p.b.x),i=x.a.x,y=Math.min(x.a.y,x.b.y),C=Math.max(x.a.y,x.b.y);if(i<d||i>u||S<y||S>C)return!1;const b=Math.abs(i-p.a.x)<r&&Math.abs(S-p.a.y)<r||Math.abs(i-p.b.x)<r&&Math.abs(S-p.b.y)<r,L=Math.abs(i-x.a.x)<r&&Math.abs(S-x.a.y)<r||Math.abs(i-x.b.x)<r&&Math.abs(S-x.b.y)<r;return!(b&&L)}l(io,"orthogonalSegmentsCross");function _o(t,e,n,o,s=Yt){const r=xt(t,e,s),c=gt(t,e,s),a=xt(n,o,s),f=gt(n,o,s);return c&&f&>(t,n,s)?Wt(t.y,e.y,n.y,o.y)>s:r&&a&&xt(t,n,s)?Wt(t.x,e.x,n.x,o.x)>s:!1}l(_o,"sameAxisSegmentsOverlap");function We(t,e,n,o,{epsilon:s=Yt,skipDegenerateOther:r=!1}={}){for(const c of n){if(c===o||c.isLayoutOnly)continue;const a=c.points;if(!(!a||a.length<2))for(let f=0;f<a.length-1;f++){const h=a[f],p=a[f+1];if(!(r&&ce(h,p,s))&&(io(t,e,h,p,s)||_o(t,e,h,p,s)))return!0}}return!1}l(We,"segmentConflictsWithAnyEdge");function ue(t,e,n,o,s=Yt){const r=xt(t,e,s),c=gt(t,e,s),a=xt(n,o,s),f=gt(n,o,s);if(!(r&&f||c&&a))return!1;const h=r?{a:t,b:e}:{a:n,b:o},p=r?{a:n,b:o}:{a:t,b:e},x=h.a.y,S=Math.min(h.a.x,h.b.x),d=Math.max(h.a.x,h.b.x),u=p.a.x,i=Math.min(p.a.y,p.b.y),y=Math.max(p.a.y,p.b.y);return u>S+s&&u<d-s&&x>i+s&&x<y-s}l(ue,"orthogonalSegmentsStrictlyCross");function vn(t,e,n){const o=Math.min(e,n),s=Math.max(e,n);return t>o+Yt&&t<s-Yt}l(vn,"strictlyBetween");function Ho(t,e,n){return gt(t,e)&>(e,n)?vn(e.y,t.y,n.y):xt(t,e)&&xt(e,n)?vn(e.x,t.x,n.x):!1}l(Ho,"isCollinearIntermediate");function Do(t){let e=!1;const n=[];for(let o=0;o<t.length;o++){const s=n[n.length-1],r=t[o],c=o+1<t.length?t[o+1]:void 0;if(s&&c){if(ce(s,c)){o++,e=!0;continue}if(Ho(s,r,c)){e=!0;continue}}n.push(r)}return{points:n,changed:e}}l(Do,"simplifyPolylineOnce");function Ke(t){const e=[t[0]];for(let o=1;o<t.length;o++){const s=e[e.length-1],r=t[o];if(!gt(s,r)&&!xt(s,r)){const c=e.length>=2?e[e.length-2]:void 0,f=(c?gt(c,s):!1)?{x:s.x,y:r.y}:{x:r.x,y:s.y};e.push(f)}e.push(r)}const n=[];for(const o of e){const s=n[n.length-1];(!s||!ce(s,o))&&n.push(o)}return n}l(Ke,"orthogonalizePolyline");function de(t){if(t.length<3)return t;let e=[...t];for(let n=0;n<32;n++){const o=Do(e);if(e=o.points,!o.changed)break}return e}l(de,"simplifyPolyline");var it=.001,ur=.5,Lo=4;function co(t,e,n){const o=t;if(o.isLayoutOnly||!o.points||o.points.length<n)return;const s=o.start?e.get(o.start):void 0,r=o.end?e.get(o.end):void 0;return{edge:o,points:o.points,srcRect:s?te(s):void 0,dstRect:r?te(r):void 0}}l(co,"endpointContextFor");function Xo(t,e,n){if(xt(t,e,it))return{x:t.x<n.left?n.left:n.right,y:t.y};if(gt(t,e,it)){const o=t.y<n.top?n.top:n.bottom;return{x:t.x,y:o}}return{x:Math.min(n.right,Math.max(n.left,t.x)),y:Math.min(n.bottom,Math.max(n.top,t.y))}}l(Xo,"segmentEnterPoint");function Ln(t,e,n){const o=n?1:-1;let s=n?0:t.length-1;for(;s>=0&&s<t.length&&no(t[s],e,ur);)s+=o;if(s<0||s>=t.length)return t;const r=s-o;if(r<0||r>=t.length)return t;const c=Xo(t[s],t[r],e);return n?[c,...t.slice(s)]:[...t.slice(0,s+1),c]}l(Ln,"clipEndpoint");function Yo(t,e){for(const n of t){const o=co(n,e,2);if(!o)continue;let s=[...o.points];o.srcRect&&(s=Ln(s,o.srcRect,!0)),o.dstRect&&(s=Ln(s,o.dstRect,!1)),s=de(Ke(s)),s=ao(s,o.srcRect,o.dstRect),o.edge.points=de(Ke(s))}}l(Yo,"clipEdgeEndpointsToNodeBoundaries");function Tn(t,e,n,o=!1){if(xt(t,e,it)){if(e.y<n.top-it||e.y>n.bottom+it)return e;if(o){if(t.x<n.left-it)return{x:n.left,y:t.y};if(t.x>n.right+it)return{x:n.right,y:t.y}}return{x:Math.abs(e.x-n.left)<=Math.abs(e.x-n.right)?n.left:n.right,y:t.y}}if(gt(t,e,it)){if(e.x<n.left-it||e.x>n.right+it)return e;if(o){if(t.y<n.top-it)return{x:t.x,y:n.top};if(t.y>n.bottom+it)return{x:t.x,y:n.bottom}}const s=Math.abs(e.y-n.top)<=Math.abs(e.y-n.bottom);return{x:t.x,y:s?n.top:n.bottom}}return e}l(Tn,"snapEndpointToBoundary");function qe(t,e,n){const o=t[e];for(let s=e+n;s>=0&&s<t.length;s+=n){const r=t[s];if(!ce(r,o,it))return r}return t[e+n]}l(qe,"firstDistinctAdjacent");function Ze(t,e){const n=t+Lo,o=e-Lo;return n<=o?{lo:n,hi:o}:{lo:(t+e)/2,hi:(t+e)/2}}l(Ze,"cornerClearanceRange");function wn(t,e,n){const{lo:o,hi:s}=Ze(e,n);return Math.min(s,Math.max(o,t))}l(wn,"clampToCornerClearance");function Go(t){const e=Math.max(...t.map(o=>o.lo)),n=Math.min(...t.map(o=>o.hi));if(!(e>n))return{lo:e,hi:n}}l(Go,"intersectRanges");function En(t,e){return e==="left"||e==="right"?Ze(t.top,t.bottom):Ze(t.left,t.right)}l(En,"clearanceRangeForSide");function Je(t,e,n){const o=t.y>=n.top-it&&t.y<=n.bottom+it,s=t.x>=n.left-it&&t.x<=n.right+it;if(xt(t,e,it)&&o){if(Math.abs(t.x-n.left)<it)return"left";if(Math.abs(t.x-n.right)<it)return"right"}if(gt(t,e,it)&&s){if(Math.abs(t.y-n.top)<it)return"top";if(Math.abs(t.y-n.bottom)<it)return"bottom"}}l(Je,"terminalSideForSegment");function Pe(t){return t==="left"||t==="right"}l(Pe,"isHorizontalSide");function zo(t,e,n,o,s){const r=[],c=n?Je(t,e,n):void 0,a=o?Je(e,t,o):void 0;return n&&c&&Pe(c)===s&&r.push(En(n,c)),o&&a&&Pe(a)===s&&r.push(En(o,a)),r.length>0?Go(r):void 0}l(zo,"straightClearanceRange");function An(t,e,n,o,s){const r=zo(t,e,n,o,s);if(!r)return;const c=s?t.y:t.x,a=Math.min(r.hi,Math.max(r.lo,c));if(!(Math.abs(a-c)<it))return s?[{x:t.x,y:a},{x:e.x,y:a}]:[{x:a,y:t.y},{x:a,y:e.y}]}l(An,"clearStraightEndpointCornerAxis");function ao(t,e,n){if(t.length!==2)return t;const[o,s]=t;return xt(o,s,it)?An(o,s,e,n,!0)??t:gt(o,s,it)?An(o,s,e,n,!1)??t:t}l(ao,"clearStraightEndpointCornerConnections");function $o(t,e,n){return Pe(n)?{x:t.x,y:wn(t.y,e.top,e.bottom)}:{x:wn(t.x,e.left,e.right),y:t.y}}l($o,"cornerClearedEndpoint");function Vo(t,e,n,o,s,r){const c=t.map(a=>({...a}));for(let a=e;a>=0&&a<t.length;a+=n){const f=t[a];if(r&&!xt(f,o,it)||!r&&!gt(f,o,it))break;r?c[a].y=s.y:c[a].x=s.x}return c}l(Vo,"moveCollinearEndpointRun");function Rn(t,e,n){if(t.length<2)return t;const o=n?0:t.length-1,s=n?1:-1,r=t[o],c=qe(t,o,s);if(!c)return t;const a=Je(r,c,e);if(!a)return t;const f=Pe(a),h=$o(r,e,a);return ce(r,h,it)?t:Vo(t,o,s,r,h,f)}l(Rn,"clearEndpointCornerConnection");function Nn(t,e,n){const o=Math.min(t.x,e.x)>=n.left-it&&Math.max(t.x,e.x)<=n.right+it,s=Math.min(t.y,e.y)>=n.top-it&&Math.max(t.y,e.y)<=n.bottom+it;if(Math.abs(t.y-n.top)<it&&Math.abs(e.y-n.top)<it&&o)return"top";if(Math.abs(t.y-n.bottom)<it&&Math.abs(e.y-n.bottom)<it&&o)return"bottom";if(Math.abs(t.x-n.left)<it&&Math.abs(e.x-n.left)<it&&s)return"left";if(Math.abs(t.x-n.right)<it&&Math.abs(e.x-n.right)<it&&s)return"right"}l(Nn,"borderSideForSegment");function On(t,e,n,o){switch(t){case"top":return gt(e,n,it)&&n.y<o.top-it;case"bottom":return gt(e,n,it)&&n.y>o.bottom+it;case"left":return xt(e,n,it)&&n.x<o.left-it;case"right":return xt(e,n,it)&&n.x>o.right+it}}l(On,"leavesOutward");function Bn(t,e,n){if(t.length<3)return t;if(n){const r=Nn(t[0],t[1],e);return r&&On(r,t[1],t[2],e)?t.slice(1):t}const o=t.length-1,s=Nn(t[o-1],t[o],e);return s&&On(s,t[o-1],t[o-2],e)?t.slice(0,o):t}l(Bn,"collapseOwnBorderStub");function jo(t,e,n){let o=t;if(e){const r=qe(o,0,1);if(r){const c=Tn(r,o[0],e);c!==o[0]&&(o=[c,...o.slice(1)])}o=Bn(o,e,!0)}if(n){const r=o.length-1,c=qe(o,r,-1);if(c){const a=Tn(c,o[r],n,!0);a!==o[r]&&(o=[...o.slice(0,r),a])}o=Bn(o,n,!1)}const s=ao(o,e,n);return s!==o||o.length===2?s:(e&&(o=Rn(o,e,!0)),n&&(o=Rn(o,n,!1)),o)}l(jo,"snapAndCollapseEndpoints");function Pn(t,e){for(const n of t){const o=co(n,e,2);if(!o)continue;const s=pt(o.points,it),r=jo(s,o.srcRect,o.dstRect);if(r.length<3){o.edge.points=r;continue}const c=[r[0],{...r[0]},...r.slice(1,-1),r[r.length-1],{...r[r.length-1]}];o.edge.points=c}}l(Pn,"prepareEdgeEndpointsForRenderer");function lo(t){return new Map(t.map(e=>[e.id,e]))}l(lo,"buildNodeMap");function Uo(t,e){let n=t.parentId,o=null;for(;n;){const s=e.get(n);if(!(s!=null&&s.isGroup))break;o=s.id,n=s.parentId}return o}l(Uo,"resolveTopLevelGroupId");function kn(t,e){let n=0,o=t.parentId;for(;o;){const s=e.get(o);if(!(s!=null&&s.isGroup))break;n++,o=s.parentId}return n}l(kn,"groupDepth");function fo(t){let e=1/0,n=-1/0,o=1/0,s=-1/0;for(const r of t){const c=r.x,a=r.y;if(typeof c!="number"||typeof a!="number")continue;const f=r.width??0,h=r.height??0;e=Math.min(e,c-f/2),n=Math.max(n,c+f/2),o=Math.min(o,a-h/2),s=Math.max(s,a+h/2)}return e===1/0||o===1/0?null:{minX:e,maxX:n,minY:o,maxY:s}}l(fo,"boundsForChildren");function Wo(t,e){const n=t.padding??20;t.x=(e.minX+e.maxX)/2,t.y=(e.minY+e.maxY)/2,t.width=Math.max(0,e.maxX-e.minX)+n,t.height=Math.max(0,e.maxY-e.minY)+n}l(Wo,"applyGroupBounds");function Ko(t){const e=lo(t),n=t.filter(o=>o.isGroup&&o.parentId).sort((o,s)=>kn(s,e)-kn(o,e));for(const o of n){const s=t.filter(c=>c.parentId===o.id),r=fo(s);r&&Wo(o,r)}}l(Ko,"recomputeNestedGroupBounds");function Qe(t,e){const n=t.nodes??[],o=t.edges??[],s=n.filter(f=>!f.isGroup);let r=1/0,c=-1/0;for(const f of s){const h=f[e];typeof h=="number"&&(r=Math.min(r,h),c=Math.max(c,h))}if(!Number.isFinite(r)||!Number.isFinite(c))return!1;const a=l(f=>r+c-f,"mirror");for(const f of n){const h=f[e];typeof h=="number"&&(f[e]=a(h));const p=f.groupTitleRect;p&&(f.groupTitleRect=e==="x"?{...p,left:a(p.right),right:a(p.left)}:{...p,top:a(p.bottom),bottom:a(p.top)})}for(const f of o)for(const h of f.points??[])h[e]=a(h[e]);return!0}l(Qe,"mirrorAxis");function qo(t){return(t.nodes??[]).some(n=>!n.isGroup)?Qe(t,"y"):!0}l(qo,"applyBtDirectionTransform");function Zo(t,e="LR"){const n=t.nodes??[],o=t.edges??[],s=n.filter(B=>!B.isGroup);let r=1/0,c=1/0;for(const B of s){const G=B.x??0,j=B.y??0;G<r&&(r=G),j<c&&(c=j)}if(!Number.isFinite(r)||!Number.isFinite(c))return!1;const a=36;let f=0,h=0;for(const B of s)f+=B.width??0,h+=B.height??0;const p=f/s.length,x=h/s.length,S=x>0?Math.max(1,p/x):1;for(const B of s){const G=B.x??0,tt=((B.y??0)-c)*S+a,ft=G-r;B.x=tt,B.y=ft}for(const B of o)if(B.points)for(const G of B.points){const j=G.x,ft=(G.y-c)*S+a,It=j-r;G.x=ft,G.y=It}Ko(n);const d=n.filter(B=>B.isGroup&&!B.parentId);if(d.length===0)return e==="RL"&&Qe(t,"x"),!0;const u=lo(n),i=new Map;for(const B of n){if(B.isGroup)continue;const G=Uo(B,u);if(!G)continue;const j=i.get(G)??[];j.push(B),i.set(G,j)}let y=0;for(const B of d){const G=B.padding??0;G>y&&(y=G)}const C=[];let b=1/0,L=-1/0;for(const B of d){const G=i.get(B.id)??[],j=fo(G);j&&(b=Math.min(b,j.minX),L=Math.max(L,j.maxX),C.push({lane:B,contentTop:j.minY,contentBottom:j.maxY,centerY:(j.minY+j.maxY)/2}))}if(b===1/0||L===-1/0)return!0;const v=Math.max(0,L-b),m=Math.max(y,10),I=v+2*m,T=a+I,O=(b+L)/2-I/2-a,k=O+T/2,D=Math.max(y,a);C.sort((B,G)=>B.centerY-G.centerY);for(let B=0;B<C.length;B++){const G=C[B];let j,tt;if(B===0?j=G.contentTop-D:j=(C[B-1].contentBottom+G.contentTop)/2,B===C.length-1)tt=G.contentBottom+D;else{const Dt=C[B+1];tt=(G.contentBottom+Dt.contentTop)/2}const ft=Math.max(0,tt-j),It=(j+tt)/2;G.lane.x=k,G.lane.y=It,G.lane.width=T,G.lane.height=ft,G.lane.swimlaneContentTop=G.contentTop,G.lane.groupTitleRect={left:O,right:O+a,top:j,bottom:tt}}return e==="RL"&&Qe(t,"x"),!0}l(Zo,"applyLrDirectionTransform");var ae=1e-6,hr=8,Ge=hr,gr=[0,Ge,-Ge,2*Ge,-2*Ge];function Jo(t,e){const{nodeInfoById:n,realNodeRects:o}=on(e);for(const s of t){if(s.isLayoutOnly)continue;const r=s.points;if(!r||r.length<4)continue;const c=eo(pt(r,ae),ae);if(!c)continue;const{p3:a}=c,f=c.kind==="HVH",h=ro(s,n,ae);if(!h)continue;const{srcId:p,dstId:x,srcInfo:S,dstInfo:d,collinearX:u,collinearY:i}=h;if(u||i)continue;let y;const C=S.rect;for(const b of gr){let L,v,m;if(f){const k=d.cy>S.cy?C.bottom:C.top,D=S.cx+b;if(D<=C.left+ae||D>=C.right-ae)continue;L={x:D,y:k},v={x:D,y:a.y},m={x:a.x,y:a.y}}else{const k=d.cx>S.cx?C.right:C.left,D=S.cy+b;if(D<=C.top+ae||D>=C.bottom-ae)continue;L={x:k,y:D},v={x:a.x,y:D},m={x:a.x,y:a.y}}const I=ce(L,v,ae),T=ce(v,m,ae);if(I&&T||!I&&Bt(L,v,o,[p],1)||!T&&Bt(v,m,o,[x],1))continue;const A=!I&&We(L,v,t,s,{epsilon:ae,skipDegenerateOther:!0}),P=!T&&We(v,m,t,s,{epsilon:ae,skipDegenerateOther:!0});if(!(A||P)){I?y=[v,m]:T?y=[L,v]:y=[L,v,m];break}}y&&(s.points=y)}}l(Jo,"portSwapToLShape");function Qo(t,e){const{realNodeRects:r,labelNodeRects:c}=be(e.values());for(const a of t){if(a.isLayoutOnly)continue;const f=a.points;if(!f||f.length<4)continue;const h=pt(f,.001);if(h.length<4)continue;const p=h.length-1,x=h[p],S=h[p-1],d=h[p-2],u=x.x-S.x,i=x.y-S.y,y=Math.hypot(u,i);if(y>=10||y<.001)continue;const C=S.x-d.x,b=S.y-d.y;if(Math.hypot(C,b)<.001)continue;const v=Nt(S,x,.001),m=Ot(S,x,.001),I=Nt(d,S,.001),T=Ot(d,S,.001);if(!(v&&T||m&&I))continue;const A=a.end,P=a.start,O=A?e.get(A):void 0;if(!O)continue;const k=O.x??0,D=O.y??0,B=te(O);if(!B)continue;let G,j;if(T){const Z=b<0;G={x:k,y:d.y},j={x:k,y:Z?B.bottom:B.top}}else{const Z=C>0;G={x:d.x,y:D},j={x:Z?B.right:B.left,y:D}}if(Bt(G,j,r,A?[A]:[],-2)||Bt(G,j,c,[],-2))continue;if(P){const Z=e.get(P),rt=Z?te(Z):void 0;if(rt&&no(G,rt,2))continue}const tt=l((Z,rt)=>`${Z.x.toFixed(3)},${Z.y.toFixed(3)}|${rt.x.toFixed(3)},${rt.y.toFixed(3)}`,"ownSegmentKey"),ft=new Set;for(let Z=0;Z<h.length-1;Z++)ft.add(tt(h[Z],h[Z+1]));const It=l((Z,rt)=>{for(const ut of t){if(ut===a||ut.isLayoutOnly)continue;const yt=ut.points;if(!(!yt||yt.length<2))for(let St=0;St<yt.length-1;St++){const Et=yt[St],Kt=yt[St+1];if(!ft.has(tt(Et,Kt))&&ue(Z,rt,Et,Kt,.001))return!0}}return!1},"segmentCrossesOtherEdge");if(It(G,j))continue;if(p-3>=0){const Z=h[p-3],rt=[P,A].filter(ut=>!!ut);if(Bt(Z,G,r,rt,-2)||It(Z,G))continue}const _t=[...h.slice(0,p-2),G,j];a.points=_t;const nt=a.labelNodeId;if(nt){const Z=e.get(nt);if(Z){const rt=Z.width??0,ut=Z.height??0;if(rt>0&&ut>0){let yt,St,Et=-1;for(let Kt=0;Kt<_t.length-1;Kt++){const qt=_t[Kt],Zt=_t[Kt+1],se=Math.hypot(Zt.x-qt.x,Zt.y-qt.y),Le=xt(qt,Zt,.001),ge=gt(qt,Zt,.001);(Le&&se>=rt+2||ge&&se>=ut+2)&&se>Et&&(Et=se,yt=(qt.x+Zt.x)/2,St=(qt.y+Zt.y)/2)}yt!==void 0&&St!==void 0&&(Z.x=yt,Z.y=St)}}}}}l(Qo,"collapseShortTerminalStub");var et=.001,Xt=8,at=Oe,pn=l((t,e)=>gt(t,e,et)||xt(t,e,et),"orthogonallyAligned");function ts(t,e){const s=l((d,u)=>{const i=d.x??0,y=d.y??0,C=u.x-i,b=u.y-y;let L=(d.width??0)/2,v=(d.height??0)/2;return Math.abs(b)*L>Math.abs(C)*v?(b<0&&(v=-v),{x:i+(b===0?0:v*C/b),y:y+v}):(C<0&&(L=-L),{x:i+L,y:y+(C===0?0:L*b/C)})},"rectIntersect"),r=l((d,u)=>{const i=pt(d.points??[]);if(i.length<2)return;const y=u?d.start:d.end,C=y?e.get(y):void 0,b=C?te(C):void 0;if(!C||!y||!b)return;const L=u?i[0]:i[i.length-1],v=u?i[1]:i[i.length-2],m=s(C,L);let I=L;if(pn(v,m)&&(I=v),gt(m,I,et))return{edge:d,edgeId:String(d.id??""),nodeId:y,atStart:u,orientation:"V",coord:m.x,min:Math.min(m.y,I.y),max:Math.max(m.y,I.y),boundary:m,railEnd:I,rect:b};if(xt(m,I,et))return{edge:d,edgeId:String(d.id??""),nodeId:y,atStart:u,orientation:"H",coord:m.y,min:Math.min(m.x,I.x),max:Math.max(m.x,I.x),boundary:m,railEnd:I,rect:b}},"terminalLaneFor"),c=l((d,u)=>Math.max(0,Math.min(d.max,u.max)-Math.max(d.min,u.min)),"projectedOverlapLength"),a=l((d,u)=>d.nodeId!==u.nodeId||d.orientation!==u.orientation?!1:d.orientation==="H"?(Math.abs(d.boundary.x-d.rect.left)<1||Math.abs(d.boundary.x-d.rect.right)<1)&>(d.boundary,u.boundary,1):(Math.abs(d.boundary.y-d.rect.top)<1||Math.abs(d.boundary.y-d.rect.bottom)<1)&&xt(d.boundary,u.boundary,1),"sameTerminalFace"),f=l((d,u)=>d.nodeId!==u.nodeId||d.orientation!==u.orientation?!1:c(d,u)>=Xt&&Math.abs(d.coord-u.coord)<.5,"exactTerminalLaneConflict"),h=l((d,u)=>{if(d.nodeId!==u.nodeId||d.orientation!==u.orientation||d.orientation!=="H"||d.atStart===u.atStart)return!1;const i=c(d,u);if(i<Xt)return!1;const y=d.rect.bottom-d.rect.top;return i<y||i>2*y?!1:a(d,u)&&Math.abs(d.coord-u.coord)<16},"nearTerminalLaneConflict"),p=l((d,u)=>{const i=pt(d.edge.points??[]);if(i.length<2)return;const y=d.orientation==="V"?{x:d.boundary.x+u,y:d.boundary.y}:{x:d.boundary.x,y:d.boundary.y+u},C=d.orientation==="V"?{x:d.railEnd.x+u,y:d.railEnd.y}:{x:d.railEnd.x,y:d.railEnd.y+u};if(!l(()=>Math.abs(d.boundary.y-d.rect.top)<1||Math.abs(d.boundary.y-d.rect.bottom)<1?xt(y,d.boundary,et)&&y.x>=d.rect.left+1&&y.x<=d.rect.right-1:Math.abs(d.boundary.x-d.rect.left)<1||Math.abs(d.boundary.x-d.rect.right)<1?gt(y,d.boundary,et)&&y.y>=d.rect.top+1&&y.y<=d.rect.bottom-1:!1,"boundaryStaysOnSameFace")())return;if(d.atStart){const I=i.length>1&&ce(i[1],d.railEnd,et),T=i.slice(I?2:1),A=T[0];return A&&!pn(A,C)?void 0:[y,C,...T]}const L=i.length>1&&ce(i[i.length-2],d.railEnd,et),v=i.slice(0,L?-2:-1),m=v[v.length-1];if(!(m&&!pn(m,C)))return[...v,C,y]},"shiftedCandidate"),x=l(d=>{const u=d.edge,i=pt(u.points??[]);if(i.length!==2)return!1;const y=u.start,C=u.end,b=y?e.get(y):void 0,L=C?e.get(C):void 0;if(!b||!L)return!1;const v=b.x??0,m=b.y??0,I=L.x??0,T=L.y??0,[A,P]=i;return xt(A,P,et)&&Math.abs(m-T)<1&&Math.abs(v-I)>1||gt(A,P,et)&&Math.abs(v-I)<1&&Math.abs(m-T)>1},"laneIsStraightCollinearConnector"),S=[-7,7,-14,14,-21,21];for(let d=0;d<8;d++){const u=t.filter(y=>!y.isLayoutOnly).flatMap(y=>[r(y,!0),r(y,!1)]).filter(y=>!!y);let i=!1;for(let y=0;y<u.length&&!i;y++)for(let C=y+1;C<u.length&&!i;C++){const b=u[y],L=u[C];if(b.edge===L.edge||!(f(b,L)||h(b,L)))continue;const v=!f(b,L),m=[b,L].sort((I,T)=>{const A=x(I),P=x(T);return A!==P?Number(A)-Number(P):+!T.atStart-+!I.atStart});for(const I of m){for(const T of S){const A=p(I,T);if(!A)continue;const P=r({...I.edge,points:A},I.atStart);if(!(!P||u.some(O=>O.edge!==I.edge&&(f(P,O)||v&&h(P,O))))){I.edge.points=A,i=!0;break}}if(i)break}}if(!i)return}}l(ts,"separateSharedRenderedTerminalLanes");function es(t,e){const{realNodeRects:o,labelNodeRects:s}=be(e.values()),r=l((a,f)=>{const h=a.start,p=a.end,x=at(f);if(x.length!==f.length-1)return!1;const S=[h,p].filter(d=>!!d);for(const d of x)if(Bt(d.a,d.b,o,S,-2)||Bt(d.a,d.b,s,[],-2))return!1;for(const d of t){if(d===a||d.isLayoutOnly)continue;const u=d.points;if(!(!u||u.length<2)){for(const i of x)for(const y of at(pt(u)))if(fe(i,y,.5)>=Xt||ue(i.a,i.b,y.a,y.b,et))return!1}}return!0},"candidateIsSafe"),c=l((a,f)=>{if(f+4>=a.length)return;const h=a[f],p=a[f+1],x=a[f+2],S=a[f+3],d=a[f+4],u=Nt(h,p)&&Ot(p,x)&&Nt(x,S)&&Ot(S,d)&>(h,S,et)&>(h,d,et)&>(p,x,et)&&(p.x-h.x)*(S.x-x.x)<0,i=Ot(h,p)&&Nt(p,x)&&Ot(x,S)&&Nt(S,d)&&xt(h,S,et)&&xt(h,d,et)&&xt(p,x,et)&&(p.y-h.y)*(S.y-x.y)<0;if(u||i)return pt([...a.slice(0,f+1),d,...a.slice(f+5)]);if(f+5>=a.length)return;const y=a[f+5],C=Ot(h,p)&&Nt(p,x)&&Ot(x,S)&&Nt(S,d)&&Ot(d,y)&>(h,d,et)&>(h,y,et)&>(x,S,et)&&(x.x-p.x)*(d.x-S.x)<0,b=Nt(h,p)&&Ot(p,x)&&Nt(x,S)&&Ot(S,d)&&Nt(d,y)&&xt(h,d,et)&&xt(h,y,et)&&xt(x,S,et)&&(x.y-p.y)*(d.y-S.y)<0;if(!(!C&&!b))return pt([...a.slice(0,f+1),y,...a.slice(f+6)])},"withoutDogleg");for(let a=0;a<8;a++){let f=!1;for(const h of t){if(h.isLayoutOnly)continue;const p=pt(h.points??[]);for(let x=0;x<=p.length-5;x++){const S=c(p,x);if(!(!S||!r(h,S))){h.points=S,f=!0;break}}if(f)break}if(!f)return}}l(es,"collapseRedundantRectangularDoglegs");function Fn(t,e){const{realNodeRects:r,labelNodeRects:c}=be(e.values()),a=t.filter(u=>!u.isLayoutOnly),f=l((u,i,y)=>pt(u===i?y??[]:u.points??[]),"pointsFor"),h=l((u,i)=>{let y=0;for(let C=0;C<a.length;C++){const b=at(f(a[C],u,i));for(let L=C+1;L<a.length;L++){const v=at(f(a[L],u,i));for(const m of b)for(const I of v)ue(m.a,m.b,I.a,I.b,et)&&y++}}return y},"strictCrossingCount"),p=l(u=>{const i=at(u);if(i.length!==3)return;const y=i[1];if(!(i[0].horizontal===y.horizontal||i[2].horizontal===y.horizontal))return{index:y.index,horizontal:y.horizontal,vertical:y.vertical,segment:y}},"middleRail"),x=l((u,i)=>{const y=[u.start,u.end].filter(C=>!!C);return r.filter(C=>{if(y.includes(C.id))return!1;const b=C.rect;return i.horizontal?Wt(i.a.x,i.b.x,b.left,b.right)>=Xt&&i.a.y>=b.top-2&&i.a.y<=b.bottom+2:Wt(i.a.y,i.b.y,b.top,b.bottom)>=Xt&&i.a.x>=b.left-2&&i.a.x<=b.right+2})},"blockingRectsFor"),S=l((u,i,y)=>{const C=u.map(L=>({...L}));if(i.horizontal)C[i.index].y=y,C[i.index+1].y=y;else if(i.vertical)C[i.index].x=y,C[i.index+1].x=y;else return;const b=de(pt(C));return at(b).length===b.length-1?b:void 0},"candidateByMovingRail"),d=l((u,i,y)=>{const C=[u.start,u.end].filter(L=>!!L),b=at(i);if(b.length!==i.length-1)return!1;for(const L of b)if(Bt(L.a,L.b,r,C,-2)||Bt(L.a,L.b,c,[],-2))return!1;for(const L of a)if(L!==u){for(const v of b)for(const m of at(f(L)))if(fe(v,m,.5)>=Xt)return!1}return h(u,i)<=y},"candidateIsSafe");for(let u=0;u<8;u++){const i=h();let y=!1;for(const C of a){const b=f(C),L=p(b);if(!L)continue;const v=x(C,L.segment);if(v.length===0)continue;const m=L.horizontal?[Math.min(...v.map(I=>I.rect.top))-20,Math.max(...v.map(I=>I.rect.bottom))+20]:[Math.min(...v.map(I=>I.rect.left))-20,Math.max(...v.map(I=>I.rect.right))+20];for(const I of m){const T=S(b,L.segment,I);if(!(!T||!d(C,T,i))){C.points=T,y=!0;break}}if(y)break}if(!y)return}}l(Fn,"liftObstacleHuggingSameSideRails");function _n(t,e){const o=l(f=>{const h=f.groupTitleRect;if(!(!h||typeof h.left!="number"||typeof h.right!="number"||typeof h.top!="number"||typeof h.bottom!="number"||!Number.isFinite(h.left)||!Number.isFinite(h.right)||!Number.isFinite(h.top)||!Number.isFinite(h.bottom)||h.right<=h.left||h.bottom<=h.top))return{left:h.left,right:h.right,top:h.top,bottom:h.bottom}},"validTitleRect"),s=l(f=>{if(!f.isGroup||f.parentId)return;const h=f.direction,p=typeof h=="string"?h.toUpperCase():"";if(p==="LR"||p==="RL"||p==="BT")return;const x=o(f),S=f.y,d=f.height;if(!x||typeof S!="number"||typeof d!="number"||!Number.isFinite(S)||!Number.isFinite(d)||d<=0)return;const u=x.right-x.left,i=x.bottom-x.top;if(!(i<=0||u<i))return{node:f,rect:x}},"topLaneTitleFor"),r=l((f,h)=>{if(!f.horizontal)return!1;const p=f.a.y;return p<=h.top+et||p>=h.bottom-et?!1:Wt(f.a.x,f.b.x,h.left,h.right)>=Xt},"horizontalSegmentIntersectsTitle"),c=[...e.values()].map(s).filter(f=>!!f);if(c.length===0)return;let a=0;for(const f of t){if(f.isLayoutOnly)continue;const h=pt(f.points??[]);for(const p of at(h))for(const x of c)r(p,x.rect)&&(a=Math.max(a,x.rect.bottom-p.a.y+4))}if(!(a<=et))for(const f of c){const h=f.node.y,p=f.node.height;typeof h!="number"||typeof p!="number"||!Number.isFinite(h)||!Number.isFinite(p)||p<=0||(f.node.y=h-a/2,f.node.height=p+a,f.node.groupTitleRect={...f.rect,top:f.rect.top-a,bottom:f.rect.bottom-a})}}l(_n,"liftTopLaneTitleBandsAboveRails");function Hn(t,e){const o=l(h=>{const p=h.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{left:p.left,right:p.right,top:p.top,bottom:p.bottom}},"validTitleRect"),s=l(h=>{if(!h.isGroup||h.parentId||h.direction!=="LR")return;const x=o(h),S=h.x,d=h.width;if(!x||typeof S!="number"||typeof d!="number"||!Number.isFinite(S)||!Number.isFinite(d)||d<=0)return;const u=x.right-x.left,i=x.bottom-x.top;if(!(u<=0||i<u))return{node:h,rect:x}},"leftLaneTitleFor"),r=l((h,p)=>{if(!h.vertical)return!1;const x=h.a.x;return x<=p.left+et||x>=p.right-et?!1:Wt(h.a.y,h.b.y,p.top,p.bottom)>=Xt},"verticalSegmentIntersectsTitle"),c=l((h,p)=>{if(!h.horizontal)return!1;const x=h.a.y;return x<=p.top+et||x>=p.bottom-et?!1:Wt(h.a.x,h.b.x,p.left,p.right)>=Xt},"horizontalSegmentIntersectsTitle"),a=[...e.values()].map(s).filter(h=>!!h);if(a.length===0)return;let f=0;for(const h of t){if(h.isLayoutOnly)continue;const p=pt(h.points??[]);for(const x of at(p))for(const S of a)if(r(x,S.rect))f=Math.max(f,S.rect.right-x.a.x+4);else if(c(x,S.rect)){const d=Math.min(x.a.x,x.b.x);f=Math.max(f,S.rect.right-d+4)}}if(!(f<=et))for(const h of a){const p=h.node.x,x=h.node.width;typeof p!="number"||typeof x!="number"||!Number.isFinite(p)||!Number.isFinite(x)||x<=0||(h.node.x=p-f/2,h.node.width=x+f,h.node.groupTitleRect={...h.rect,left:h.rect.left-f,right:h.rect.right-f})}}l(Hn,"shiftLeftLaneTitleBandsLeftOfRails");function ns(t,e){const{realNodeRects:o}=be(e.values()),s=t.filter(u=>!u.isLayoutOnly),r=l((u,i=new Map)=>pt(i.get(u)??u.points??[]),"replacementPointsFor"),c=l((u=new Map)=>{let i=0;for(let y=0;y<s.length;y++){const C=at(r(s[y],u));for(let b=y+1;b<s.length;b++){const L=at(r(s[b],u));for(const v of C)for(const m of L)ue(v.a,v.b,m.a,m.b,et)&&i++}}return i},"crossingCount"),a=l((u=new Map)=>s.reduce((i,y)=>i+oe(r(y,u)),0),"totalBends"),f=l(u=>{const i=r(u);if(i.length<4)return;const y=i[i.length-2],C=i[i.length-1];if(!(!Nt(y,C,et)&&!Ot(y,C,et)))return{tailStart:y,terminal:C}},"terminalTailFor"),h=l((u,i)=>{const y=r(u);if(y.length<3)return;const C=y[0],b=y[1];let L;if(Nt(C,b,et))L={x:b.x,y:i.tailStart.y};else if(Ot(C,b,et))L={x:i.tailStart.x,y:b.y};else return;const v=de(pt([C,b,L,i.tailStart,i.terminal]));return at(v).length===v.length-1?v:void 0},"candidateWithDestinationTail"),p=l((u,i)=>{const y=[u.start,u.end].filter(C=>!!C);for(const C of at(i))if(Bt(C.a,C.b,o,y,-2))return!0;return!1},"pathHasNodeHit"),x=l((u,i,y)=>{for(const C of s)if(C!==u){for(const b of at(i))for(const L of at(r(C,y)))if(fe(b,L,.5)>=Xt)return!0}return!1},"pathHasSharedTrack"),S=l((u,i,y)=>!p(u,i)&&!x(u,i,y),"candidateIsSafe"),d=l(()=>{const u=new Map;for(const i of s){const y=i.end;if(!y||!e.has(y)||r(i).length<4)continue;const b=u.get(y)??[];b.push(i),u.set(y,b)}return u},"edgesByDestination");for(let u=0;u<4;u++){const i=c();if(i===0)return;const y=a();let C,b=i,L=y;for(const v of d().values())for(let m=0;m<v.length;m++)for(let I=m+1;I<v.length;I++){const T=v[m],A=v[I],P=f(T),O=f(A);if(!P||!O)continue;const k=h(T,O),D=h(A,P);if(!k||!D)continue;const B=new Map([[T,k],[A,D]]);if(!S(T,k,B)||!S(A,D,B))continue;const G=c(B),j=a(B);G>=i||G>b||G===b&&j>=L||(C=B,b=G,L=j)}if(!C)return;for(const[v,m]of C)v.points=m}}l(ns,"swapDestinationTerminalTailsToReduceCrossings");function os(t,e){const{realNodeRects:r,labelNodeRects:c}=be(e.values()),a=t.filter(v=>!v.isLayoutOnly),f=l((v,m=new Map)=>pt(m.get(v)??v.points??[]),"replacementPointsFor"),h=l((v=new Map)=>{let m=0;for(let I=0;I<a.length;I++){const T=at(f(a[I],v));for(let A=I+1;A<a.length;A++){const P=at(f(a[A],v));for(const O of T)for(const k of P)ue(O.a,O.b,k.a,k.b,et)&&m++}}return m},"strictCrossingCount"),p=l((v=new Map)=>a.reduce((m,I)=>m+oe(f(I,v)),0),"totalBends"),x=l(v=>{const m=v.start,I=v.end,T=m?e.get(m):void 0,A=I?e.get(I):void 0,P=T?te(T):void 0,O=A?te(A):void 0;return P&&O?{src:P,dst:O}:void 0},"endpointRectsFor"),S=l((v,m,I)=>{if(I.index<=0||I.index+1>=m.length-1)return;const T=x(v);if(T){if(I.vertical){const A=I.a.x,P=Math.min(T.src.left,T.dst.left),O=Math.max(T.src.right,T.dst.right),k=A<P-et?"left":A>O+et?"right":void 0;return k?{edge:v,points:m,segmentIndex:I.index,axis:"vertical",side:k,coord:A,min:Math.min(I.a.y,I.b.y),max:Math.max(I.a.y,I.b.y)}:void 0}if(I.horizontal){const A=I.a.y,P=Math.min(T.src.top,T.dst.top),O=Math.max(T.src.bottom,T.dst.bottom),k=A<P-et?"top":A>O+et?"bottom":void 0;return k?{edge:v,points:m,segmentIndex:I.index,axis:"horizontal",side:k,coord:A,min:Math.min(I.a.x,I.b.x),max:Math.max(I.a.x,I.b.x)}:void 0}}},"externalRailForSegment"),d=l(()=>{const v=[];for(const m of a){const I=f(m);for(const T of at(I)){const A=S(m,I,T);A&&v.push(A)}}return v},"collectExternalRails"),u=l((v,m)=>v.edge!==m.edge&&v.axis===m.axis&&v.side===m.side&&Wt(v.min,v.max,m.min,m.max)>=Xt,"railsInteract"),i=l(v=>{const m=[],I=new Set;for(const T of v){if(I.has(T))continue;const A=[T],P=[];for(I.add(T);A.length>0;){const O=A.pop();P.push(O);for(const k of v)!I.has(k)&&u(O,k)&&(I.add(k),A.push(k))}P.length>1&&m.push(P)}return m},"connectedComponents"),y=l(v=>{const m=[];for(const I of v)m.some(T=>Math.abs(T-I.coord)<et)||m.push(I.coord);for(;m.length<v.length;){const I=Math.min(...m),T=Math.max(...m),A=v[0].side;m.push(A==="left"||A==="top"?I-12*(v.length-m.length):T+12*(v.length-m.length))}return m},"uniqueCoordsFor"),C=l(v=>{const m=v.map(A=>A.coord),I=y(v),T=[];if(v.length<=6){const A=new Array(I.length).fill(!1),P=[],O=l(()=>{if(P.length===v.length){P.some((k,D)=>Math.abs(k-m[D])>=et)&&T.push([...P]);return}for(const[k,D]of I.entries())A[k]||(A[k]=!0,P.push(D),O(),P.pop(),A[k]=!1)},"visit");return O(),T}for(let A=0;A<m.length;A++)for(let P=A+1;P<m.length;P++){const O=[...m];[O[A],O[P]]=[O[P],O[A]],T.push(O)}return T},"coordinateAssignmentsFor"),b=l((v,m)=>{const I=new Map;for(const[A,P]of v.entries()){const O=m[A],k=I.get(P.edge)??P.points.map(D=>({x:D.x,y:D.y}));P.axis==="vertical"?(k[P.segmentIndex].x=O,k[P.segmentIndex+1].x=O):(k[P.segmentIndex].y=O,k[P.segmentIndex+1].y=O),I.set(P.edge,k)}const T=new Map;for(const[A,P]of I){const O=de(pt(P));if(at(O).length!==O.length-1)return;T.set(A,O)}return T},"replacementsForAssignment"),L=l(v=>{for(const[m,I]of v){const T=[m.start,m.end].filter(A=>!!A);for(const A of at(I))if(Bt(A.a,A.b,r,T,-2)||Bt(A.a,A.b,c,[],-2))return!1}for(let m=0;m<a.length;m++){const I=a[m],T=v.has(I),A=at(f(I,v));for(let P=m+1;P<a.length;P++){const O=a[P];if(!T&&!v.has(O))continue;const k=at(f(O,v));for(const D of A)for(const B of k)if(fe(D,B,.5)>=Xt)return!1}}return!0},"candidateIsSafe");for(let v=0;v<4;v++){const m=h();if(m===0)return;let I,T=m,A=p(),P=Number.POSITIVE_INFINITY;for(const O of i(d()))for(const k of C(O)){const D=b(O,k);if(!D||!L(D))continue;const B=h(D);if(B>=m)continue;const G=p(D),j=O.reduce((tt,ft,It)=>tt+Math.abs(k[It]-ft.coord),0);B>T||B===T&&(G>A||G===A&&j>=P)||(I=D,T=B,A=G,P=j)}if(!I)return;for(const[O,k]of I)O.points=k}}l(os,"reassignCrossingExternalRailChannels");function ss(t,e){const{realNodeRects:o,labelNodeRects:s}=be(e.values()),r=t.filter(d=>!d.isLayoutOnly),c=l((d,u,i)=>pt(d===u?i??[]:d.points??[]),"pointsFor"),a=l(d=>at(d).reduce((u,i)=>{const y=i.a.x-i.b.x,C=i.a.y-i.b.y;return u+Math.hypot(y,C)},0),"pathLength"),f=l((d,u)=>{let i=0;for(let y=0;y<r.length;y++){const C=at(c(r[y],d,u));for(let b=y+1;b<r.length;b++){const L=at(c(r[b],d,u));for(const v of C)for(const m of L)ue(v.a,v.b,m.a,m.b,et)&&i++}}return i},"strictCrossingCount"),h=l((d,u)=>{if(d.horizontal){const i=d.a.y;return(Math.abs(i-u.top)<1||Math.abs(i-u.bottom)<1)&&Wt(d.a.x,d.b.x,u.left,u.right)>=Xt}if(d.vertical){const i=d.a.x;return(Math.abs(i-u.left)<1||Math.abs(i-u.right)<1)&&Wt(d.a.y,d.b.y,u.top,u.bottom)>=Xt}return!1},"segmentRunsAlongRectBorder"),p=l(d=>{const u=[d.start,d.end].filter(y=>!!y),i=[];for(const y of u){const C=e.get(y),b=C?te(C):void 0;b&&i.push(b)}return i},"endpointRectsFor"),x=l((d,u)=>{if(u+3>=d.length)return[];const i=d[u],y=d[u+1],C=d[u+2],b=d[u+3],L=Nt(i,y,et)&&Ot(y,C,et)&&Nt(C,b,et),v=Ot(i,y,et)&&Nt(y,C,et)&&Ot(C,b,et);if(!L&&!v)return[];if(!(L?Math.sign(y.x-i.x)!==Math.sign(b.x-C.x):Math.sign(y.y-i.y)!==Math.sign(b.y-C.y)))return[];const I=gt(i,b,et)||xt(i,b,et)?[]:[{x:i.x,y:b.y},{x:b.x,y:i.y}],T=I.length===0?[[...d.slice(0,u+1),...d.slice(u+3)]]:I.map(P=>[...d.slice(0,u+1),P,...d.slice(u+3)]),A=new Set;return T.map(P=>de(pt(P))).filter(P=>{if(at(P).length!==P.length-1||!P.some(k=>ce(k,b,et)))return!1;const O=P.map(k=>`${k.x.toFixed(3)},${k.y.toFixed(3)}`).join("|");return A.has(O)?!1:(A.add(O),!0)})},"shortcutCandidatesAt"),S=l((d,u,i)=>{const y=[d.start,d.end].filter(b=>!!b),C=p(d);for(const b of at(u))if(Bt(b.a,b.b,o,y,-2)||Bt(b.a,b.b,s,[],-2)||C.some(L=>h(b,L)))return!1;for(const b of r)if(b!==d){for(const L of at(u))for(const v of at(c(b)))if(fe(L,v,.5)>=Xt)return!1}return f(d,u)<=i},"candidateIsSafe");for(let d=0;d<8;d++){const u=f();let i,y,C=u,b=Number.POSITIVE_INFINITY,L=Number.POSITIVE_INFINITY;for(const v of r){const m=c(v),I=oe(m,et),T=a(m);for(let A=0;A<=m.length-4;A++)for(const P of x(m,A)){const O=oe(P,et),k=a(P);if(!(O<I||O===I&&k<T-et)||!S(v,P,u))continue;const B=f(v,P);B>C||B===C&&(O>b||O===b&&k>=L)||(i=v,y=P,C=B,b=O,L=k)}}if(!i||!y)return;i.points=y}}l(ss,"shortcutRedundantOrthogonalJogs");function rs(t,e){const c=[];for(const R of e.values()){if(R.isGroup||R.isEdgeLabel)continue;const F=R.x??0,_=R.y??0,V=te(R);V&&c.push({id:String(R.id??""),cx:F,cy:_,rect:V})}if(c.length===0)return;const a=new Map(c.map(R=>[R.id,R])),f=c.map(R=>({id:R.id,rect:R.rect})),h=["top","bottom","left","right"],p={top:Math.min(...c.map(R=>R.rect.top))-20,bottom:Math.max(...c.map(R=>R.rect.bottom))+20,left:Math.min(...c.map(R=>R.rect.left))-20,right:Math.max(...c.map(R=>R.rect.right))+20},x=t.filter(R=>!R.isLayoutOnly),S=new Map(x.map((R,F)=>[R,F])),d=l(R=>{const F=R==="left"||R==="top"?-1:1,_=[];for(let V=0;V<=2;V++)_.push(p[R]+F*20*V);return _},"outwardTracksForSide"),u=l((R,F=new Map)=>pt(F.get(R)??R.points??[]),"replacementPointsFor"),i=l((R,F)=>{let _=0;for(const V of R)for(const K of F)ue(V.a,V.b,K.a,K.b,et)&&_++;return _},"crossingCountBetweenSegments"),y=l((R,F)=>i(at(R),at(F)),"crossingCountBetweenPaths"),C=l((R=new Map)=>{let F=0;const _=[],V=new Set,K=[],J=l(Y=>{V.has(Y)||(V.add(Y),K.push(Y))},"addEdge");for(let Y=0;Y<x.length;Y++){const q=x[Y],g=u(q,R);for(let M=Y+1;M<x.length;M++){const E=x[M],w=y(g,u(E,R));w>0&&(F+=w,_.push({first:q,second:E,count:w}),J(q),J(E))}}return K.sort((Y,q)=>(S.get(Y)??0)-(S.get(q)??0)),{count:F,pairs:_,edgeSet:V,edges:K}},"crossingSnapshot"),b=l((R,F)=>{const _=new Set(F.keys());if(_.size===0)return R.count;let V=0;for(const J of R.pairs)(_.has(J.first)||_.has(J.second))&&(V+=J.count);let K=0;for(let J=0;J<x.length;J++){const Y=x[J],q=_.has(Y),g=u(Y,F);for(let M=J+1;M<x.length;M++){const E=x[M];!q&&!_.has(E)||(K+=y(g,u(E,F)))}}return R.count-V+K},"crossingCountWithReplacements"),L=l(R=>{const F=new Map;for(const K of R.pairs){const J=F.get(K.first)??new Set;J.add(K.second),F.set(K.first,J);const Y=F.get(K.second)??new Set;Y.add(K.first),F.set(K.second,Y)}const _=[],V=new Set;for(const K of R.edges){if(V.has(K))continue;const J=[K],Y=[];for(V.add(K);J.length>0;){const q=J.pop();Y.push(q);for(const g of F.get(q)??[])V.has(g)||(V.add(g),J.push(g))}Y.sort((q,g)=>(S.get(q)??0)-(S.get(g)??0)),Y.length>1&&_.push(Y)}return _},"crossingComponents"),v=l(R=>[R.start,R.end].filter(F=>!!F),"endpointIdsFor"),m=l(R=>{const F=[];for(const _ of L(R)){const V=new Set(_),K=new Set(_.flatMap(Y=>v(Y))),J=[..._];for(const Y of x)V.has(Y)||v(Y).some(q=>K.has(q))&&J.push(Y);J.sort((Y,q)=>(S.get(Y)??0)-(S.get(q)??0)),F.push(J)}return F},"pairSearchGroups"),I=l((R,F,_)=>b(R,new Map([[F,_]])),"crossingCountWithSingleReplacement"),T=l(R=>{const F=new Map;for(const _ of R.pairs)F.set(_.first,(F.get(_.first)??0)+_.count),F.set(_.second,(F.get(_.second)??0)+_.count);return F},"currentCrossingsByEdge"),A=l(R=>R.slice(1).reduce((F,_,V)=>{const K=R[V];return F+Math.abs(_.x-K.x)+Math.abs(_.y-K.y)},0),"pathLength"),P=l((R=new Map)=>x.reduce((F,_)=>F+oe(u(_,R)),0),"totalBends"),O=l((R=new Map)=>x.reduce((F,_)=>F+A(u(_,R)),0),"totalLength"),k=l((R,F,_=new Map)=>{const V=at(F);for(const K of x)if(K!==R){for(const J of V)for(const Y of at(u(K,_)))if(fe(J,Y,.5)>=Xt)return!0}return!1},"pathHasSegmentConflict"),D=l((R,F)=>{const _=[R.start,R.end].filter(V=>!!V);for(const V of at(F))if(Bt(V.a,V.b,f,_,-2))return!0;return!1},"pathHitsNode"),B=l((R,F)=>{const _=de(pt(F));at(_).length===_.length-1&&R.push(_)},"pushOrthogonalCandidate"),G=l(R=>R==="left"||R==="right","sideIsHorizontal"),j=l((R,F,_)=>{switch(F){case"left":return Math.min(R.x,_.x)-20;case"right":return Math.max(R.x,_.x)+20;case"top":return Math.min(R.y,_.y)-20;case"bottom":return Math.max(R.y,_.y)+20}},"localTrackForSameSide"),tt=l((R,F,_,V)=>{const K=_==="left"||_==="top"?-1:1,J=[j(F,_,V),p[_]];for(const Y of J)for(let q=0;q<=2;q++)B(R,so(F,_,V,Y+K*20*q))},"addSameSideCandidates"),ft=l((R,F,_,V,K)=>{for(const J of d(_))for(const Y of d(K))B(R,[F,{x:J,y:F.y},{x:J,y:Y},{x:V.x,y:Y},V])},"addHorizontalToVerticalCandidates"),It=l((R,F,_,V,K)=>{for(const J of d(_))for(const Y of d(K))B(R,[F,{x:F.x,y:J},{x:Y,y:J},{x:Y,y:V.y},V])},"addVerticalToHorizontalCandidates"),Dt=l((R,F,_,V,K)=>{const J=[...d("top"),...d("bottom")];for(const Y of d(_))for(const q of d(K))for(const g of J)B(R,[F,{x:Y,y:F.y},{x:Y,y:g},{x:q,y:g},{x:q,y:V.y},V])},"addHorizontalPairCandidates"),_t=l((R,F,_,V,K)=>{const J=[...d("left"),...d("right")];for(const Y of d(_))for(const q of d(K))for(const g of J)B(R,[F,{x:F.x,y:Y},{x:g,y:Y},{x:g,y:q},{x:V.x,y:q},V])},"addVerticalPairCandidates"),nt=l(R=>{const F=new Set;return R.map(_=>pt(_)).filter(_=>{const V=_.map(K=>`${K.x.toFixed(3)},${K.y.toFixed(3)}`).join("|");return F.has(V)||_.length<2?!1:(F.add(V),!0)})},"dedupeCandidatePaths"),Z=l((R,F,_,V)=>{const K=[],J=oo(R,F,_,V,20,et);J&&B(K,J),F===V&&tt(K,R,F,_);const Y=G(F),q=G(V);return Y&&!q?ft(K,R,F,_,V):!Y&&q?It(K,R,F,_,V):Y?Dt(K,R,F,_,V):_t(K,R,F,_,V),nt(K)},"buildCandidatesForSides"),rt=l((R,F,_,V)=>{const K=[...d("left"),...d("right")],J=[...d("top"),...d("bottom")];for(const Y of h){const q=ve(V,Y),g=Y==="top"||Y==="bottom"?d(Y):J;for(const M of K){B(R,[F,_,{x:M,y:_.y},{x:M,y:q.y},q]);for(const E of g)B(R,[F,_,{x:M,y:_.y},{x:M,y:E},{x:q.x,y:E},q])}}},"addVerticalDepartureOuterTrackCandidates"),ut=l((R,F,_,V)=>{const K=[...d("left"),...d("right")],J=[...d("top"),...d("bottom")];for(const Y of h){const q=ve(V,Y),g=Y==="left"||Y==="right"?d(Y):K;for(const M of J){B(R,[F,_,{x:_.x,y:M},{x:q.x,y:M},q]);for(const E of g)B(R,[F,_,{x:_.x,y:M},{x:E,y:M},{x:E,y:q.y},q])}}},"addHorizontalDepartureOuterTrackCandidates"),yt=l(R=>{const F=R.start,_=R.end,V=_?a.get(_):void 0;if(!F||!V)return[];const K=pt(R.points??[]);if(K.length<4)return[];const J=K[0],Y=K[1],q=[];return Ot(J,Y,et)?rt(q,J,Y,V):Nt(J,Y,et)&&ut(q,J,Y,V),q},"terminalPreservingOuterTrackCandidates"),St=l(R=>{const F=R.start,_=R.end,V=F?a.get(F):void 0,K=_?a.get(_):void 0;if(!V||!K)return[];const J=[];for(const Y of h){const q=ve(V,Y);for(const g of h)J.push(...Z(q,Y,ve(K,g),g))}return J.push(...yt(R)),J},"candidatePathsFor"),Et=l(()=>new Map(x.map(R=>[R,at(u(R))])),"currentSegmentsByEdge"),Kt=l((R,F,_)=>{const V=new Set;for(const K of x){if(K===R)continue;const J=_.get(K)??at(u(K));F.some(Y=>J.some(q=>fe(Y,q,.5)>=Xt))&&V.add(K)}return V},"sharedTrackConflictsFor"),qt=l((R,F,_,V)=>{const K=new Set;return St(R).map(Y=>de(pt(Y))).filter(Y=>{if(D(R,Y))return!1;const q=Y.map(g=>`${g.x.toFixed(3)},${g.y.toFixed(3)}`).join("|");return K.has(q)||Y.length<2?!1:(K.add(q),!0)}).map(Y=>{const q=at(Y);let g=0;for(const M of x)M!==R&&(g+=i(q,_.get(M)??at(u(M))));return{candidate:Y,candidateSegments:q,crossings:F.count-(V.get(R)??0)+g,bends:oe(Y,et),totalBends:oe(Y),length:A(Y)}}).filter(({crossings:Y})=>Y<=F.count).sort((Y,q)=>Y.crossings-q.crossings||Y.bends-q.bends||Y.length-q.length).slice(0,48).map(Y=>({path:Y.candidate,segments:Y.candidateSegments,sharedTrackConflicts:Kt(R,Y.candidateSegments,_),totalBends:Y.totalBends,length:Y.length}))},"pairCandidatesFor"),Zt=l((R,F,_,V,K,J)=>{let Y=0;for(const g of R.pairs)(g.first===F||g.second===F||g.first===V||g.second===V)&&(Y+=g.count);let q=i(_.segments,K.segments);for(const g of x){if(g===F||g===V)continue;const M=J.get(g)??at(u(g));q+=i(_.segments,M)+i(K.segments,M)}return R.count-Y+q},"pairCrossingCount"),se=l((R,F)=>{for(const _ of R.sharedTrackConflicts)if(_!==F)return!1;return!0},"conflictsOnlyWith"),Le=l((R,F)=>R.segments.some(_=>F.segments.some(V=>fe(_,V,.5)>=Xt)),"candidatesShareTrack"),ge=l((R,F,_,V)=>se(F,_.edge)&&se(V,R.edge)&&!Le(F,V),"pairCandidatesAreCompatible"),Te=l((R,F,_,V,K)=>{const J=Zt(R.current,F.edge,_,V.edge,K,R.baseSegments);if(!(J>=R.current.count))return{replacements:new Map([[F.edge,_.path],[V.edge,K.path]]),crossings:J,bends:R.currentBends-(R.baseBendsByEdge.get(F.edge)??0)-(R.baseBendsByEdge.get(V.edge)??0)+_.totalBends+K.totalBends,length:R.currentLength-(R.baseLengthByEdge.get(F.edge)??0)-(R.baseLengthByEdge.get(V.edge)??0)+_.length+K.length}},"scorePairReplacement"),an=l((R,F)=>R.crossings<F.crossings||R.crossings===F.crossings&&(R.bends<F.bends||R.bends===F.bends&&R.length<F.length),"pairScoreIsBetter"),ln=l((R,F,_,V)=>{let K=V;for(const J of F.candidates)for(const Y of _.candidates){if(!ge(F,J,_,Y))continue;const q=Te(R,F,J,_,Y);q&&an(q,K)&&(K=q)}return K},"bestScoreForOptionPair"),fn=l(R=>{const F=P(),_=O(),V=Et(),K=T(R),J=new Map(x.map(w=>[w,oe(u(w))])),Y=new Map(x.map(w=>[w,A(u(w))])),q=new Map,g=m(R);for(const w of g)for(const N of w){if(q.has(N))continue;const H=qt(N,R,V,K);H.length>0&&q.set(N,{edge:N,candidates:H})}let M={replacements:new Map,crossings:R.count,bends:F,length:_};const E={current:R,currentBends:F,currentLength:_,baseBendsByEdge:J,baseLengthByEdge:Y,baseSegments:V};for(const w of g){const N=new Set(w.filter(W=>R.edgeSet.has(W))),H=w.map(W=>q.get(W)).filter(W=>!!W);for(let W=0;W<H.length;W++){const ot=H[W];for(let U=W+1;U<H.length;U++){const $=H[U];!N.has(ot.edge)&&!N.has($.edge)||(M=ln(E,ot,$,M))}}}return M.replacements.size>0?M.replacements:void 0},"bestPairedReplacement");for(let R=0;R<4;R++){const F=C(),_=F.count;if(_===0)return;let V,K,J=_,Y=Number.POSITIVE_INFINITY;for(const g of F.edges){const M=oe(u(g),et);for(const E of St(g)){const w=D(g,E),N=!w&&k(g,E),H=I(F,g,E),W=oe(E,et);w||N||!(H<_||H===_&&W<M)||H>J||H===J&&W>=Y||(V=g,K=E,J=H,Y=W)}}if(V&&K){V.points=K;continue}const q=fn(F);if(!q)return;for(const[g,M]of q)g.points=M}}l(rs,"resolveRenderedOrthogonalCrossings");var pe=.001,mr=8;function is(t,e){const{nodeInfoById:n,realNodeRects:o}=on(e),s=["top","bottom","left","right"],r=20,c={top:Math.min(...o.map(i=>i.rect.top))-r,bottom:Math.max(...o.map(i=>i.rect.bottom))+r,left:Math.min(...o.map(i=>i.rect.left))-r,right:Math.max(...o.map(i=>i.rect.right))+r},a=l((i,y,C,b)=>{const L=[],v=oo(i,y,C,b,r,pe);return v&&L.push(v),y===b&&L.push(so(i,y,C,c[y])),L},"buildOrthogonalPathCandidates"),f=l((i,y)=>{for(let C=0;C<i.length-1;C++){const b=i[C],L=i[C+1];if(Bt(b,L,o,y,1))return!0}return!1},"pathHitsNode"),h=l((i,y,C=!1)=>{let b=0;const L=Oe(i,pe),v=y.start,m=y.end;for(const I of t){if(I===y||I.isLayoutOnly)continue;const T=I.start,A=I.end;if(!C&&v&&m&&(T===v||T===m||A===v||A===m))continue;const P=I.points;if(!(!P||P.length<2))for(const O of L)for(const k of Oe(P,pe)){if(io(O.a,O.b,k.a,k.b,pe,pe)){b++;continue}fe(O,k,pe)>=mr&&b++}}return b},"pathConflictCount"),p=4,x=l((i,y)=>{const C=Math.abs(i.y-y.rect.top),b=Math.abs(i.y-y.rect.bottom),L=Math.abs(i.x-y.rect.left),v=Math.abs(i.x-y.rect.right);let m="top",I=C;return b<I&&(m="bottom",I=b),L<I&&(m="left",I=L),v<I&&(m="right",I=v),m},"nearestSideOfRect"),S=new Map,d=l((i,y,C)=>{const b=S.get(i)??[];b.push({side:y,edgeId:C}),S.set(i,b)},"addFaceClaim");for(const i of t){if(i.isLayoutOnly)continue;const y=i.points??[];if(y.length<1)continue;const C=i.id??"",b=i.start,L=i.end;if(b){const v=n.get(b);v&&d(b,x(y[0],v),C)}if(L){const v=n.get(L);v&&d(L,x(y[y.length-1],v),C)}}const u=l((i,y,C)=>{var b;return((b=S.get(i))==null?void 0:b.some(L=>L.edgeId!==C&&L.side===y))??!1},"faceIsClaimed");for(const i of t){if(i.isLayoutOnly)continue;const y=i.points;if(!y||y.length<2)continue;const C=oe(y,pe);if(C<p)continue;const b=i.start,L=i.end;if(!b||!L)continue;const v=n.get(b),m=n.get(L);if(!v||!m)continue;const I=i.id??"",T=h(y,i,!0),A=h(y,i);let P,O=T,k=C;for(const D of s){if(u(b,D,I))continue;const B=ve(v,D);for(const G of s){if(u(L,G,I))continue;const j=ve(m,G);for(const tt of a(B,D,j,G)){if(f(tt,[b,L]))continue;const ft=oe(tt,pe);if(T>0){const It=h(tt,i,!0);if(It>O||It===O&&ft>=k)continue;O=It,k=ft,P=tt;continue}h(tt,i)>A||ft<k&&(k=ft,P=tt)}}}if(P){i.points=P;const D=S.get(b);D&&S.set(b,D.filter(G=>G.edgeId!==I));const B=S.get(L);B&&S.set(L,B.filter(G=>G.edgeId!==I)),d(b,x(P[0],v),I),d(L,x(P[P.length-1],m),I)}}}l(is,"simplifyDetouredEdges");var Qt=.001,To=10,ze=7;function Dn(t,e){const n=e?0:t.length-1,o=e?1:-1,s=t[n],r=t[n+o];if(!s||!r)return;const c=r.x-s.x,a=r.y-s.y;if(!(Math.abs(c)+Math.abs(a)<Qt)){if(Math.abs(a)<=Qt){const h=s.x+Math.sign(c)*To;return{left:Math.min(s.x,h),right:Math.max(s.x,h),top:s.y-ze,bottom:s.y+ze}}if(Math.abs(c)<=Qt){const h=s.y+Math.sign(a)*To;return{left:s.x-ze,right:s.x+ze,top:Math.min(s.y,h),bottom:Math.max(s.y,h)}}return{left:Math.min(s.x,r.x),right:Math.max(s.x,r.x),top:Math.min(s.y,r.y),bottom:Math.max(s.y,r.y)}}}l(Dn,"markerClearanceRectFor");function cs(t){return{left:Math.min(t.left,t.right),right:Math.max(t.left,t.right),top:Math.min(t.top,t.bottom),bottom:Math.max(t.top,t.bottom)}}l(cs,"normalizeRect");function Xn(t,e){const n=pt(e),o=Dn(n,!0),s=Dn(n,!1);return[o,s].some(r=>r&&Ue(t,cs(r)))}l(Xn,"labelOverlapsOwnMarker");function Ve(t,e){const n=[];for(const u of t){if(u.isLayoutOnly)continue;const i=u.points;if(!(!i||i.length<2))for(let y=0;y<i.length-1;y++)n.push({edgeId:u.id,p1:i[y],p2:i[y+1]})}const o=[],s=[];for(const u of e.values()){const i=u.isGroup,y=u.parentId;if(i&&!y){const b=te(u);b&&s.push({id:u.id,rect:b});continue}if(i||u.isEdgeLabel)continue;const C=te(u);C&&o.push({nodeId:u.id,rect:C})}const r=3,c=1,a=12,f=l((u,i)=>{const y=Cn(i,r);for(const{nodeId:C,rect:b}of o)if(C!==u&&Ue(y,b))return!0;return!1},"labelOverlapsForeignNode"),h=l((u,i)=>{const y=Cn(i,r);for(const C of n)if(C.edgeId!==u&&nn(C.p1,C.p2,y))return!0;return!1},"labelOverlapsForeignEdge"),p=l((u,i,y)=>f(u,y)||h(i,y),"labelOverlapsAnything"),x=[],S=l(u=>{for(const{id:i,rect:y}of s)if(ko(y,u))return i},"findContainingLane"),d=l((u,i)=>x.some(y=>y.labelId!==u&&Ue(i,y.rect)),"overlapsPlacedLabel");for(const u of t){if(u.isLayoutOnly)continue;const i=u.labelNodeId;if(!i)continue;const y=e.get(i);if(!y)continue;const C=u.points;if(!C||C.length<2)continue;const b=y.width??0,L=y.height??0;if(b<=0||L<=0)continue;const v=[];for(let nt=0;nt<C.length-1;nt++){const Z=C[nt],rt=C[nt+1],ut=Math.abs(Z.x-rt.x),yt=Math.abs(Z.y-rt.y);ut<Qt&&yt<Qt||ut>=Qt&&yt>=Qt||v.push({idx:nt,length:ut+yt,orientation:ut>=Qt?"horizontal":"vertical",midX:(Z.x+rt.x)/2,midY:(Z.y+rt.y)/2})}if(v.length===0)continue;const m=v.length>=3?v.filter(nt=>nt.idx>0&&nt.idx<v.length-1):v,I=m.length>0?m:v,T=b>=L?"horizontal":"vertical",A=l(nt=>[...nt].sort((Z,rt)=>{const ut=Z.orientation===T,yt=rt.orientation===T;if(ut!==yt)return ut?-1:1;const St=Z.length>=(Z.orientation==="horizontal"?b:L)+2,Et=rt.length>=(rt.orientation==="horizontal"?b:L)+2;return St!==Et?St?-1:1:rt.length-Z.length}),"rankSegments"),P=v[0],O=v[v.length-1],k=[.5,.25,.75,.05,.95,.15,.85,.1,.9],D=l((nt,Z)=>{const rt=C[nt.idx],ut=C[nt.idx+1];return{midX:rt.x+(ut.x-rt.x)*Z,midY:rt.y+(ut.y-rt.y)*Z}},"anchorAtT"),B=l((nt,Z,rt)=>Math.min(rt,Math.max(Z,nt)),"clamp"),G=l((nt,Z)=>nt.midX>=Z.left-Qt&&nt.midX<=Z.right+Qt&&nt.midY>=Z.top-Qt&&nt.midY<=Z.bottom+Qt,"pointInsideRectInclusive"),j=l(nt=>{const Z=Ne(nt.midX,nt.midY,b,L),rt=S(Z);if(rt)return{laneId:rt,anchor:nt,rect:Z};const ut=s.find(({rect:se})=>G(nt,se));if(!ut)return;const yt=ut.rect.left+b/2+c,St=ut.rect.right-b/2-c,Et=ut.rect.top+L/2+c,Kt=ut.rect.bottom-L/2-c;if(yt>St||Et>Kt)return;const qt={midX:B(nt.midX,yt,St),midY:B(nt.midY,Et,Kt)},Zt=Ne(qt.midX,qt.midY,b,L);return G(nt,Zt)?{laneId:ut.id,anchor:qt,rect:Zt}:void 0},"placementForAnchor"),tt=l((nt,Z,rt)=>nt.orientation==="horizontal"?Math.abs(Z.midX-rt.x):Math.abs(Z.midY-rt.y),"distanceAlongSegment"),ft=l((nt,Z)=>{const ut=(nt.orientation==="horizontal"?b/2:L/2)+a;if(nt===P){const yt=C[nt.idx];if(tt(nt,Z,yt)+Qt<ut)return!1}if(nt===O){const yt=C[nt.idx+1];if(tt(nt,Z,yt)+Qt<ut)return!1}return!0},"labelClearsTerminalEndpoints"),It=l(nt=>{const Z=A(nt);for(const rt of Z)for(const ut of k){const yt=D(rt,ut);if(!ft(rt,yt))continue;const St=j(yt);if(St&&!Xn(St.rect,C)&&!d(i,St.rect)&&!p(i,u.id,St.rect))return{laneId:St.laneId,anchor:St.anchor}}},"tryPool"),Dt=l((nt,Z,rt=!1)=>{const ut=A(nt);for(const yt of ut){const St={midX:yt.midX,midY:yt.midY};if(Z&&!ft(yt,St))continue;const Et=j(St);if(Et&&!Xn(Et.rect,C)&&!d(i,Et.rect)&&!f(i,Et.rect)&&(rt||!h(u.id,Et.rect)))return{laneId:Et.laneId,anchor:Et.anchor}}},"findLaneContainingFallback"),_t=It(I)??(I.length<v.length?It(v):void 0)??Dt(v,!0)??Dt(v,!1)??Dt(v,!1,!0);if(_t){y.x=_t.anchor.midX,y.y=_t.anchor.midY,y.parentId=_t.laneId;const nt=Ne(_t.anchor.midX,_t.anchor.midY,b,L),Z=x.findIndex(rt=>rt.labelId===i);Z>=0?x[Z]={labelId:i,rect:nt}:x.push({labelId:i,rect:nt})}}}l(Ve,"anchorLabelsToPolyline");var bn=1e-6,xr=8,wo=xr/2,yr=3;function Yn(t,e){return t<e?`${t}::${e}`:`${e}::${t}`}l(Yn,"pairKey");function as(t,e){const{nodeInfoById:n,realNodeRects:o}=on(e),s=new Map;for(const c of e){const a=c.id;if(!c.isGroup&&c.isEdgeLabel){s.set(a,{w:c.width??0,h:c.height??0});continue}}const r=l((c,a,f,h)=>{const p=Yn(a,f);let x=0;const S=l(d=>{if(!d)return;const u=s.get(d);if(!u)return;const i=h==="x"?u.w/2:u.h/2;i>x&&(x=i)},"consider");S(c.labelNodeId);for(const d of t){if(d===c||d.isLayoutOnly)continue;const u=d.start,i=d.end;!u||!i||Yn(u,i)===p&&S(d.labelNodeId)}return x>0?x+yr:0},"labelClearanceFor");for(const c of t){if(c.isLayoutOnly)continue;const a=c.points;if(!eo(a,bn))continue;const f=ro(c,n,bn);if(!f)continue;const{srcId:h,dstId:p,srcInfo:x,dstInfo:S,collinearX:d,collinearY:u}=f;if(d===u)continue;let i,y;if(d){const m=S.cy>x.cy;i={x:x.cx,y:m?x.rect.bottom:x.rect.top},y={x:S.cx,y:m?S.rect.top:S.rect.bottom}}else{const m=S.cx>x.cx;i={x:m?x.rect.right:x.rect.left,y:x.cy},y={x:m?S.rect.left:S.rect.right,y:S.cy}}if(Bt(i,y,o,[h,p],1))continue;const b=r(c,h,p,d?"x":"y"),L=b>wo?b:wo,v=[0,L,-L];for(const m of v){const I={...i},T={...y};if(d){if(I.x+=m,T.x+=m,I.x<=x.rect.left||I.x>=x.rect.right||T.x<=S.rect.left||T.x>=S.rect.right)continue}else if(I.y+=m,T.y+=m,I.y<=x.rect.top||I.y>=x.rect.bottom||T.y<=S.rect.top||T.y>=S.rect.bottom)continue;if(!Bt(I,T,o,[h,p],1)&&!We(I,T,t,c,{epsilon:bn})){c.points=[I,T];break}}}}l(as,"straightenCollinearSiblingDetours");function Gn(t,e){const{realNodeRects:f,labelNodeRects:h}=be(e.values()),p=l((m,I)=>Oe(I,.001).map(T=>({...T,edge:m,interior:T.index>=1&&T.index<=I.length-3})),"segmentsFor"),x=l(()=>{const m=[];for(const I of t){if(I.isLayoutOnly)continue;const T=I.points;!T||T.length<2||m.push(...p(I,pt(T)))}return m},"allSegments"),S=l((m,I)=>m.horizontal&&I.horizontal?Wt(m.a.x,m.b.x,I.a.x,I.b.x)>=8&&Math.abs(m.a.y-I.a.y)<7:m.vertical&&I.vertical?Wt(m.a.y,m.b.y,I.a.y,I.b.y)>=8&&Math.abs(m.a.x-I.a.x)<7:!1,"hasCrowdedParallelTrack"),d=l((m,I)=>{const T=m.start,A=m.end,P=p(m,I);if(P.length!==I.length-1)return!1;const O=[T,A].filter(D=>!!D),k=m.labelNodeId?[m.labelNodeId]:[];for(const D of P)if(Bt(D.a,D.b,f,O,-2)||Bt(D.a,D.b,h,k,-2))return!1;for(const D of t){if(D===m||D.isLayoutOnly)continue;const B=D.points;if(!(!B||B.length<2)){for(const G of P)for(const j of p(D,pt(B)))if(S(G,j)||ue(G.a,G.b,j.a,j.b,.001))return!1}}return!0},"candidateIsSafe"),u=l((m,I)=>{const T=pt(m.edge.points??[]);if(T.length<4||m.index>=T.length-1)return;const A=T.map(P=>({...P}));if(m.horizontal)A[m.index].y+=I,A[m.index+1].y+=I;else if(m.vertical)A[m.index].x+=I,A[m.index+1].x+=I;else return;return p(m.edge,A).length===A.length-1?A:void 0},"shiftedCandidate"),i=l((m,I)=>({x:m.x??(I.left+I.right)/2,y:m.y??(I.top+I.bottom)/2}),"nodeCenter"),y=l(m=>{const I=m.edge,T=pt(I.points??[]);if(T.length!==4||m.index!==1)return;const A=I.start?e.get(I.start):void 0,P=I.end?e.get(I.end):void 0,O=A?te(A):void 0,k=P?te(P):void 0,D=T.slice(m.index+2);if(!(!A||!P||!O||!k||D.length===0))return{sourceCenter:i(A,O),targetCenter:i(P,k),sourceRect:O,tail:D}},"sourceDetourContextFor"),C=l((m,I,T,A,P,O)=>{const k=A.y>=T.y,D=k?P.bottom:P.top,B=D+(k?20:-20);if(k&&m.b.y<=B+.001||!k&&m.b.y>=B-.001)return;const G=m.a.x+I;return pt([{x:T.x,y:D},{x:T.x,y:B},{x:G,y:B},{x:G,y:m.b.y},...O],.001)},"verticalSourceDetour"),b=l((m,I,T,A,P,O)=>{const k=A.x>=T.x,D=k?P.right:P.left,B=D+(k?20:-20);if(k&&m.b.x<=B+.001||!k&&m.b.x>=B-.001)return;const G=m.a.y+I;return pt([{x:D,y:T.y},{x:B,y:T.y},{x:B,y:G},{x:m.b.x,y:G},...O],.001)},"horizontalSourceDetour"),L=l((m,I)=>{const T=y(m);if(T){if(m.vertical)return C(m,I,T.sourceCenter,T.targetCenter,T.sourceRect,T.tail);if(m.horizontal)return b(m,I,T.sourceCenter,T.targetCenter,T.sourceRect,T.tail)}},"sourceDetourCandidate"),v=[-7,7,-14,14,-21,21];for(let m=0;m<12;m++){const I=x();let T=!1;for(let A=0;A<I.length&&!T;A++)for(let P=A+1;P<I.length&&!T;P++){const O=I[A],k=I[P];if(O.edge===k.edge||!S(O,k))continue;const D=[O,k].filter(B=>B.interior);for(const B of D){for(const G of v){const j=u(B,G);if(j&&d(B.edge,j)){B.edge.points=j,T=!0;break}const tt=L(B,G);if(tt&&d(B.edge,tt)){B.edge.points=tt,T=!0;break}}if(T)break}}if(!T)return}}l(Gn,"nudgeSharedInteriorSubpaths");function ls(t,e,n,o){const s=e.x-t.x,r=e.y-t.y,c=o.x-n.x,a=o.y-n.y,f=s*a-r*c;if(Math.abs(f)<1e-10)return!1;const h=n.x-t.x,p=n.y-t.y,x=(h*a-p*c)/f,S=(h*r-p*s)/f,d=.01;return x>d&&x<1-d&&S>d&&S<1-d}l(ls,"segmentsIntersect");function fs(t){const e=t.nodes??[],n=t.edges??[],o=[];if(!n.length||!e.length)return o;const s=Fo(e),r=[];for(const a of n){if(a.isLayoutOnly)continue;const f=a.points;if(!f||f.length<2)continue;const h=a.start,p=a.end,x=a.labelNodeId,S=a.id??`${h}->${p}`;for(const d of s)if(!(d.nodeId===h||d.nodeId===p)&&!(x&&d.nodeId===x)){for(let u=0;u<f.length-1;u++)if(nn(f[u],f[u+1],d,-1)){o.push({type:"edge-node-overlap",edgeId:S,targetId:d.nodeId,detail:`segment ${u} passes through node "${d.nodeId}"`});break}}for(let d=0;d<f.length-1;d++)r.push({edgeId:S,start:h,end:p,p1:f[d],p2:f[d+1]})}const c=new Set;for(let a=0;a<r.length;a++)for(let f=a+1;f<r.length;f++){const h=r[a],p=r[f];if(h.edgeId!==p.edgeId&&!(h.start===p.start||h.start===p.end||h.end===p.start||h.end===p.end)&&ls(h.p1,h.p2,p.p1,p.p2)){const x=h.edgeId<p.edgeId?`${h.edgeId}|${p.edgeId}`:`${p.edgeId}|${h.edgeId}`;c.has(x)||(c.add(x),o.push({type:"edge-edge-crossing",edgeId:h.edgeId,targetId:p.edgeId,detail:`edges "${h.edgeId}" and "${p.edgeId}" cross`}))}}if(o.length>0){const a=o.filter(h=>h.type==="edge-node-overlap").length,f=o.filter(h=>h.type==="edge-edge-crossing").length;Mn.warn(`[SWIMLANE_VALIDATE] ${o.length} issue(s) detected: ${a} edge-node overlap(s), ${f} edge crossing(s)`);for(const h of o)Mn.warn(`[SWIMLANE_VALIDATE] ${h.type}: ${h.detail}`)}return o}l(fs,"validateSwimlanesLayout");function ds(t,e){const n=t.nodes??[],o=t.edges??[],s=n.filter(a=>!a.isGroup);if((e==="LR"||e==="RL")&&s.length>0&&!Zo(t,e)||e==="BT"&&s.length>0&&!qo(t))return;for(const a of o){if(a.isLayoutOnly)continue;const f=a.points;!f||f.length<2||(a.points=de(Ke(f)))}is(o,n),as(o,n),Jo(o,n);const r=new Map;for(const a of n)r.set(String(a.id),a);Ve(o,r),Yo(o,r),Qo(o,r),Gn(o,r),ts(o,r),es(o,r),Fn(o,r),ns(o,r);const c=l(()=>{rs(o,r),os(o,r),ss(o,r),Ve(o,r),Pn(o,r),Fn(o,r),Ve(o,r),Pn(o,r)},"finalizeRenderedEdges");c(),Gn(o,r),c(),_n(o,r),Hn(o,r),_n(o,r),Hn(o,r)}l(ds,"postProcessSwimlaneLayout");function Ie(t){const e=new Map(t.nodeById),n=new Set,o=[];for(const r of t.edges){if(!e.has(r.src)||!e.has(r.dst))continue;const c=`${r.id}:${r.src}->${r.dst}`;n.has(c)||(n.add(c),o.push(r))}return{nodes:[...e.keys()],edges:o,layout:t.layout,nodeById:e}}l(Ie,"normalizeGraph");function uo(t,e){return t.edges.filter(n=>n.dst===e)}l(uo,"incoming");function us(t){const e=new Map;for(const n of t.nodes)e.set(n,[]);for(const n of t.edges)e.get(n.src).push(n.dst);return e}l(us,"buildSuccessorMap");function ho(t){const e=us(t);for(const n of e.values())n.sort((o,s)=>o.localeCompare(s));return e}l(ho,"buildSortedSuccessorMap");function sn(t){const e=new Map;for(const n of t.nodes)e.set(n,0);for(const n of t.edges)e.set(n.dst,(e.get(n.dst)??0)+1);return e}l(sn,"buildInDegreeMap");function go(t){return[...t.entries()].filter(([,e])=>e===0).map(([e])=>e).sort((e,n)=>e.localeCompare(n))}l(go,"sortedZeroInDegreeNodes");function rn(t,e=()=>!0){const n=new Map,o=new Map;for(const s of t.nodes)n.set(s,[]),o.set(s,[]);for(const s of t.edges)e(s)&&(o.get(s.src).push(s.dst),n.get(s.dst).push(s.src));return{preds:n,succs:o}}l(rn,"buildPredecessorSuccessorMaps");function mo(t,e,n,o){var c,a;let s=0;for(const f of t.nodes)o!=null&&o.skipGroups&&((c=t.nodeById.get(f))!=null&&c.isGroup)||(s=Math.max(s,n[f]??0));const r=Array.from({length:s+1},()=>[]);for(const f of e)o!=null&&o.skipGroups&&((a=t.nodeById.get(f))!=null&&a.isGroup)||r[Math.max(0,n[f]??0)].push(f);return r}l(mo,"buildLayersFromRanks");function ke(t){const e=sn(t),n=go(e),o=[],s=ho(t);for(;n.length;){const r=n.shift();o.push(r);for(const c of s.get(r)??[])if(e.set(c,(e.get(c)??0)-1),(e.get(c)??0)===0){let a=0;for(;a<n.length&&n[a]<c;)a++;n.splice(a,0,c)}}return o.length===t.nodes.length?o:null}l(ke,"topoSortIfAcyclic");function Be(t){const e=new Map;let n=0;for(const o of t)e.set(o,n),n++;return e}l(Be,"buildLayerIndex");function xo(t){const e=new Array(t.length),n=l((o,s)=>{if(s-o<=1)return 0;const r=o+s>>1;let c=n(o,r)+n(r,s),a=o,f=r,h=o;for(;a<r||f<s;)f>=s||a<r&&t[a]<=t[f]?e[h++]=t[a++]:(e[h++]=t[f++],c+=r-a);for(let p=o;p<s;p++)t[p]=e[p];return c},"count");return n(0,t.length)}l(xo,"countInversions");function hs(t){const e=Ie(t),n=new Map;for(const x of e.nodes)n.set(x,[]);for(const x of e.edges)n.get(x.src).push(x);for(const x of n.values())x.sort((S,d)=>S.dst===d.dst?S.id.localeCompare(d.id):S.dst.localeCompare(d.dst));const o=Object.create(null);for(const x of e.nodes)o[x]=0;const s=[],r=l(x=>{o[x]=1;for(const S of n.get(x)??[]){const d=S.dst;o[d]===0?r(d):o[d]===1&&s.push(S)}o[x]=2},"dfs"),c=sn(e),a=[...e.nodes.filter(x=>(c.get(x)??0)===0),...e.nodes.filter(x=>(c.get(x)??0)!==0)];for(const x of a)o[x]===0&&r(x);const f=new Set(s.map(x=>`${x.id}:${x.src}->${x.dst}`)),h=e.edges.map(x=>f.has(`${x.id}:${x.src}->${x.dst}`)?{id:x.id,src:x.dst,dst:x.src,weight:x.weight,ref:x.ref}:x);return{acyclic:{nodes:[...e.nodes],edges:h,layout:e.layout,nodeById:new Map(e.nodeById)},reversed:s}}l(hs,"removeCycles_DFS");function gs(t){const e=new Map,n=l(o=>{if(e.has(o))return e.get(o);const s=t.nodeById.get(o);if(!s)return e.set(o,null),null;const r=s.parentId;if(!r)return e.set(o,null),null;const a=n(r)??r;return e.set(o,a),a},"resolve");for(const o of t.nodes)n(o);return e}l(gs,"buildTopLaneMap");function he(t){const e=gs(t);return n=>e.get(n)??null}l(he,"createTopLaneResolver");function cn(t){const e=[];for(const n of t.layout.nodes??[])n.isGroup&&!n.parentId&&e.push(n.id);return[...new Set(e)].reverse()}l(cn,"buildTopLaneOrder");function yo(t,e){const n=cn(t);if(!e||e.length===0)return n;const o=new Set(n),s=new Set,r=[];for(const c of e)!o.has(c)||s.has(c)||(s.add(c),r.push(c));for(const c of n)s.has(c)||r.push(c);return r}l(yo,"resolveTopLaneOrder");var pr={EPSILON:1e-6},tn={GRAVITY_ITERATIONS:8,MAX_CROSSING_OPTIMIZATION_PASSES:4,DEFAULT_COMPACT_SINGLE_INPUT:!0},Eo={DEFAULT_LAYER_GAP:100,DEFAULT_NODE_GAP:40};function ms(t,e){const n=Ie(t),o=(e==null?void 0:e.laneOf)??(()=>null),s=e==null?void 0:e.rankHint,{preds:r}=rn(n);for(const m of r.values())m.sort((I,T)=>I.localeCompare(T));const c=ke(n)??[...n.nodes].sort((m,I)=>m.localeCompare(I)),a=new Map;for(const[m,I]of c.entries())a.set(I,m);const f=new Map,h=new Map;for(const m of n.nodes)h.set(m,[]);for(const m of c){const I=(r.get(m)??[]).filter(T=>f.has(T));if(I.length>0){const T=xs(m,I,{laneOf:o,rankHint:s,topoIndex:a});f.set(m,T),h.get(T).push(m)}else f.has(m)||f.set(m,null)}for(const m of n.nodes)f.has(m)||f.set(m,null);const p=new Set;for(const m of n.nodes)(f.get(m)??null)===null&&p.add(m);const x=[...p].sort((m,I)=>{const T=a.get(m)??0,A=a.get(I)??0;return T===A?m.localeCompare(I):T-A}),S=ys(n),d=new Map;for(const[m,I]of S.entries())d.set(m,[...I].sort((T,A)=>T.localeCompare(A)));const u=ps(d),i=bs(d),y=new Map;for(const m of n.nodes)y.set(m,[]);for(const m of i)for(const I of m.nodes){const T=y.get(I);T?T.push(m.id):y.set(I,[m.id])}const C=[],b=[],L=new Set,v=l(m=>{if(!L.has(m)){L.add(m),C.push(m);for(const I of h.get(m)??[])v(I);b.push(m)}},"walk");for(const m of x)v(m);for(const m of c)v(m);return{parent:f,children:h,roots:x,componentOf:u,blocks:i,nodeBlocks:y,adjacency:d,preorder:C,postorder:b,topologicalOrder:c}}l(ms,"buildDrivingTree");function xs(t,e,n){const o=n.laneOf(t);return[...e].sort((r,c)=>{var i,y;const a=n.laneOf(r),f=n.laneOf(c),h=a!=null&&a===o,p=f!=null&&f===o;if(h!==p)return h?-1:1;const x=(i=n.rankHint)==null?void 0:i[r],S=(y=n.rankHint)==null?void 0:y[c];if(x!=null&&S!=null&&x!==S)return S-x;const d=n.topoIndex.get(r)??0,u=n.topoIndex.get(c)??0;return d!==u?d-u:r.localeCompare(c)})[0]}l(xs,"chooseParent");function ys(t){const e=new Map;for(const n of t.nodes)e.set(n,new Set);for(const n of t.edges)e.get(n.src).add(n.dst),e.get(n.dst).add(n.src);return e}l(ys,"buildAdjacency");function ps(t){const e=new Map;let n=0;for(const o of t.keys()){if(e.has(o))continue;const s=[o];for(;s.length>0;){const r=s.pop();if(!e.has(r)){e.set(r,n);for(const c of t.get(r)??[])e.has(c)||s.push(c)}}n++}return e}l(ps,"assignComponents");function bs(t){const e=new Map,n=new Map,o=[],s=[];let r=0;const c=l((a,f)=>{e.set(a,++r),n.set(a,r);for(const h of t.get(a)??[])h!==f&&(e.has(h)?(e.get(h)??0)<(e.get(a)??0)&&(o.push([a,h]),n.set(a,Math.min(n.get(a)??r,e.get(h)??r))):(o.push([a,h]),c(h,a),n.set(a,Math.min(n.get(a)??r,n.get(h)??r)),(n.get(h)??0)>=(e.get(a)??0)&&s.push(Is(a,h,o,s.length))))},"visit");for(const a of t.keys())e.has(a)||c(a,null);return s}l(bs,"computeBlocks");function Is(t,e,n,o){const s=[],r=new Set;for(;n.length>0;){const c=n.pop();if(s.push(c),r.add(c[0]),r.add(c[1]),c[0]===t&&c[1]===e||c[0]===e&&c[1]===t)break}return{id:o,edges:s,nodes:[...r]}}l(Is,"popBlock");function Ms(t,e,n){const o=[...t.nodes],s=new Map;for(const[b,L]of o.entries())s.set(L,b);const r=o.length,c=new Array(r).fill(-1),a=new Array(r).fill(0),f=[],h=new Set;for(const b of o){const L=n.parent.get(b)??null,v=s.get(b);v!=null&&L==null&&(c[v]=-1,a[v]=0,h.has(b)||(h.add(b),f.push(b)))}for(;f.length>0;){const b=f.shift(),L=s.get(b);if(L==null)continue;const v=n.children.get(b)??[];for(const m of v){if(h.has(m))continue;const I=s.get(m);I!=null&&(c[I]=L,a[I]=a[L]+1,h.add(m),f.push(m))}}for(const b of o){if(h.has(b))continue;const L=s.get(b);L!=null&&(c[L]=-1,a[L]=0,h.add(b))}const p=Math.max(1,Math.ceil(Math.log2(Math.max(1,r)))+1),x=Array.from({length:p},()=>new Array(r).fill(-1));for(let b=0;b<r;b++)x[0][b]=c[b];for(let b=1;b<p;b++)for(let L=0;L<r;L++){const v=x[b-1][L];x[b][L]=v===-1?-1:x[b-1][v]}const S=l((b,L)=>{if(b===-1||L===-1)return-1;a[b]<a[L]&&([b,L]=[L,b]);const v=a[b]-a[L];for(let m=0;m<p;m++)if(v>>m&1&&(b=x[m][b],b===-1))return-1;if(b===L)return b;for(let m=p-1;m>=0;m--){const I=x[m][b],T=x[m][L];I===-1||T===-1||I!==T&&(b=I,L=T)}return x[0][b]},"lcaIndex"),d=Array.from({length:r},()=>new Map);for(const b of t.edges){let L=b.src,v=b.dst,m=e[L],I=e[v];if(m==null||I==null||(m>I&&([L,v]=[v,L],[m,I]=[I,m]),m==null||I==null||m===I))continue;const T=s.get(L),A=s.get(v);if(T==null||A==null)continue;const P=S(T,A);if(P===-1)continue;const O=d[P];for(let k=m;k<I;k++)O.set(k,(O.get(k)??0)+1)}const u=new Map,i=l((b,L)=>{if(L.size!==0)for(const[v,m]of L)b.set(v,(b.get(v)??0)+m)},"mergeInto"),y=new Set,C=l(b=>{const L=s.get(b);y.add(b);const v=L==null?void 0:d[L],m=v?new Map(v):new Map,I=n.children.get(b)??[];for(const T of I){const A=C(T),P=e[b];if(P!=null){let O=u.get(b);O||(O=new Map,u.set(b,O));let k=A.get(P)??0;const D=e[T];D!=null&&D>P&&(k+=1),O.set(T,k)}i(m,A)}return m},"dfs");for(const b of n.roots)y.has(b)||C(b);for(const b of o)y.has(b)||C(b);return u}l(Ms,"computeSubtreeCrossCounts");function Ss(t,e,n){const o=new Map,s=l(r=>{let c=n[r]??0;const a=[...e.get(r)??[]];a.sort(po(n));for(const f of a){s(f);const h=o.get(f);h!=null&&(c=Math.min(c,h))}o.set(r,c)},"annotate");for(const r of t)s(r);return o}l(Ss,"annotateMinimumLayers");function po(t){return(e,n)=>{const o=t[e]??0,s=t[n]??0;return o===s?e.localeCompare(n):o-s}}l(po,"compareByRankThenId");function Cs(t,e,n,o){let s=0;for(const f of e){const h=n[f]??0;h>s&&(s=h)}const r=Array.from({length:s+1},()=>[]),c=new Set,a=l(f=>{if(c.has(f))return;c.add(f);const h=n[f]??0;r[h]||(r[h]=[]),r[h].push(f);for(const p of o(f))a(p)},"emit");for(const f of t)a(f);for(const f of e)if(!c.has(f)){const h=n[f]??0;r[h]||(r[h]=[]),r[h].push(f),c.add(f)}return r}l(Cs,"emitNodesInTreeOrder");function vs(t){const e=[];for(const n of t){const o=new Set,s=[];for(const r of n)o.has(r)||(o.add(r),s.push(r));e.push(s)}return e}l(vs,"deduplicateLayers");function Ls(t,e,n,o){return s=>{const r=t.get(s)??[];if(r.length===0)return[];const c=e[s]??0,a=[],f=[],h=n.get(s);for(const p of r){const x=o.get(p)??c;x>c?a.push({child:p,min:x}):f.push(p)}return a.sort((p,x)=>p.min===x.min?p.child.localeCompare(x.child):p.min-x.min),f.sort((p,x)=>{const S=(h==null?void 0:h.get(p))??0,d=(h==null?void 0:h.get(x))??0;if(S!==d)return S-d;const u=o.get(p)??c,i=o.get(x)??c;return u!==i?u-i:p.localeCompare(x)}),[...a.map(p=>p.child),...f]}}l(Ls,"createChildOrderer");function en(t,e,n){const o=ms(t,{rankHint:e,laneOf:n}),{children:s,roots:r}=o;for(const x of t.nodes)s.has(x)||s.set(x,[]);const c=Ms(t,e,o),a=[...r].sort(po(e)),f=Ss(a,s,e),h=Ls(s,e,c,f);let p=Cs(a,t.nodes,e,h);return p=vs(p),p}l(en,"buildMultitreeLayerOrder");function Ts(t,e,n){const o=new Set(t),s=new Set(e),r=Be(e),c=[];for(const a of n)o.has(a.src)&&s.has(a.dst)&&c.push(r.get(a.dst));return xo(c)}l(Ts,"countCrossingsBetweenAdjacent");function zn(t,e,n){const o=[];for(const r of e){const c=n[r.src],a=n[r.dst];if(c==null||a==null||c===a)continue;let f=r.src,h=r.dst,p=c,x=a;c>a&&(f=r.dst,h=r.src,p=a,x=c);for(let S=p;S<x;S++)o.push({id:`${r.id}@${S}`,src:f,dst:h,ref:r.ref})}let s=0;for(let r=0;r+1<t.length;r++)s+=Ts(t[r],t[r+1],o);return s}l(zn,"totalCrossings");function ws(t,e){const n={...e},{preds:o}=rn(t),s=he(t),r=en(t,n,s);let c=zn(r,t.edges,n);const a=tn.MAX_CROSSING_OPTIMIZATION_PASSES;for(let f=0;f<a;f++){let h=!1;const p=[...t.nodes].sort((x,S)=>(n[S]??0)-(n[x]??0));for(const x of p){const S=n[x]??0;if(S===0)continue;let d=0;for(const C of o.get(x)??[])d=Math.max(d,(n[C]??0)+1);if(d>=S)continue;const u=S;n[x]=d;const i=en(t,n,s),y=zn(i,t.edges,n);y<c?(c=y,h=!0):n[x]=u}if(!h)break}return n}l(ws,"optimizeRanksByCrossings");function Es(t,e){const n=he(t),o=[...t.nodes].sort((s,r)=>(e[s]??0)-(e[r]??0)||s.localeCompare(r));for(const s of o){const r=n(s);if(!r)continue;const c=t.edges.filter(i=>i.src===s);if(c.length===0)continue;let a=!1,f=0;for(const i of c){const y=n(i.dst);y==null||y===r?a=!0:f++}if(f===0||a)continue;let h=0,p=!1;for(const i of t.edges){if(i.dst!==s)continue;const y=n(i.src);y&&(y===r?p=!0:h++)}if(h>0||!p)continue;const x=e[s]??0,S=x+f;let d=0;for(const i of t.edges)i.dst===s&&(d=Math.max(d,(e[i.src]??0)+1));const u=Math.max(x,d,S);u!==x&&(e[s]=u)}}l(Es,"adjustCrossLaneSources");function As(t,e){const n=Ie(t),o=ke(n)??[...n.nodes].sort(),s=(e==null?void 0:e.compactSingleInput)??!1,r=he(n);let c=Object.create(null);for(const f of o){const h=uo(n,f),p=e!=null&&e.ignoreCrossLaneEdges?h.filter(x=>{const S=r(x.src),d=r(f);return!S||!d?!0:S===d}):h;if(p.length===0)c[f]=0;else if(s&&p.length===1){const x=p[0].src,S=r(x),d=r(f);S!==d?c[f]=c[x]??0:c[f]=(c[x]??0)+1}else{let x=-1/0;for(const S of p)x=Math.max(x,(c[S.src]??0)+1);c[f]=x===-1/0?0:x}}return((e==null?void 0:e.optimizeRanksByCrossings)??!1)&&(c=ws(n,c)),e!=null&&e.ignoreCrossLaneEdges&&Es(n,c),{layers:en(n,c,r),rankOf:c,dummy:new Set}}l(As,"assignLayers_LongestPath");function Rs(t,e){const n=Ie(t),s={...As(n,{compactSingleInput:e==null?void 0:e.compactSingleInput,ignoreCrossLaneEdges:e==null?void 0:e.ignoreCrossLaneEdges,optimizeRanksByCrossings:e==null?void 0:e.optimizeRanksByCrossings}).rankOf},r=he(n),{preds:c,succs:a}=rn(n,u=>{if(e!=null&&e.ignoreCrossLaneEdges){const i=r(u.src),y=r(u.dst);if(i&&y&&i!==y)return!1}return!0}),f=ke(n)??[...n.nodes],h=[...f].reverse(),p=l((u,i)=>{let y=0;for(const L of c.get(u)??[])y=Math.max(y,(s[L]??0)+1);let C=Number.POSITIVE_INFINITY;const b=a.get(u)??[];return b.length>0&&(C=Math.min(...b.map(L=>(s[L]??0)-1))),Number.isFinite(C)||(C=Math.max(y,i)),Math.min(Math.max(i,y),C)},"clampFeasible"),x=tn.GRAVITY_ITERATIONS,S=l(u=>{let i=!1;for(const y of u){const C=c.get(y)??[],b=a.get(y)??[];if(C.length===0&&b.length===0)continue;const L=C.length>0?C.reduce((T,A)=>T+(s[A]??0)+1,0)/C.length:s[y]??0,v=b.length>0?b.reduce((T,A)=>T+(s[A]??0)-1,0)/b.length:s[y]??0,m=Math.round((L+v)/2),I=p(y,m);I!==s[y]&&(s[y]=I,i=!0)}return i},"relaxOrder");for(let u=0;u<x;u++){const i=S(f),y=S(h);if(!i&&!y)break}for(const u of f){let i=0;for(const y of c.get(u)??[])i=Math.max(i,(s[y]??0)+1);(s[u]??0)<i&&(s[u]=i)}for(const u of h){const i=a.get(u)??[];if(i.length>0){const y=Math.min(...i.map(C=>(s[C]??0)-1));(s[u]??0)>y&&(s[u]=y)}}return{layers:mo(n,f,s),rankOf:s,dummy:new Set}}l(Rs,"assignLayers_Gravity");function Ns(t){const e=sn(t),n=ho(t);let o=go(e);const s=[];for(;o.length>0;){const r=[];for(const c of o){s.push(c);for(const a of n.get(c)??[])e.set(a,(e.get(a)??0)-1),(e.get(a)??0)===0&&r.push(a)}o=r.sort((c,a)=>c.localeCompare(a))}return s.length===t.nodes.length?s:null}l(Ns,"topoSortByGenerationIfAcyclic");function Os(t,e){const n=Ie(t),o=(e==null?void 0:e.direction)==="LR"?Ns(n)??[...n.nodes].sort():ke(n)??[...n.nodes].sort(),s=he(n),r=l(p=>s(p)??p,"laneOf"),c=Object.create(null),a=new Map,f=l((p,x)=>(e==null?void 0:e.ignoreCrossLaneEdges)??!0?r(p)===r(x)?1:0:1,"edgeWeight");for(const p of o){const x=n.nodeById.get(p);if(x!=null&&x.isGroup)continue;const S=uo(n,p);let d=0;if(S.length>0)for(const C of S){const b=C.src,L=c[b]??0;d=Math.max(d,L+f(b,p))}const u=r(p),i=a.get(u)??0,y=Math.max(d,i);c[p]=y,a.set(u,y+1)}return{layers:mo(n,o,c,{skipGroups:!0}),rankOf:c,dummy:new Set}}l(Os,"assignLayers_LaneAwareCompact");function Bs(t,e){const n=Ie(e),{rankOf:o}=t,s=t.layers.map(d=>[...d]),r=new Set(t.dummy?[...t.dummy]:[]);let c=0;const a=new Map(n.nodeById),f=l(d=>{const u=`placeholder-${c++}`,i={id:u,isGroup:!1,isDummy:!0,width:0,height:0};for(a.set(u,i),r.add(u);s.length<=d;)s.push([]);return s[d].push(u),o[u]=d,u},"addDummyAt"),h=[...n.edges].sort((d,u)=>d.id===u.id?d.src===u.src?d.dst.localeCompare(u.dst):d.src.localeCompare(u.src):d.id.localeCompare(u.id)),p=[];for(const d of h){const u=o[d.src]??0,i=o[d.dst]??0;if(i-u<=1){p.push(d);continue}let y=d.src;for(let b=u+1,L=0;b<i;b++,L++){const v=f(b);p.push({id:`${d.id}#${L}`,src:y,dst:v,weight:d.weight,ref:d.ref}),y=v}const C=i-u-2;p.push({id:`${d.id}#${Math.max(C+1,0)}`,src:y,dst:d.dst,weight:d.weight,ref:d.ref})}const S={nodes:[...n.nodes,...[...r].filter(d=>!n.nodes.includes(d))],edges:p,layout:n.layout,nodeById:a};return{layering:{layers:s,rankOf:o,dummy:r},graphWithDummies:S}}l(Bs,"makeProperLayering");function $n(t){const e=t.length;if(e===0)return Number.POSITIVE_INFINITY;const n=[...t].sort((o,s)=>o-s);return e%2===1?n[(e-1)/2]:.5*(n[e/2-1]+n[e/2])}l($n,"median");function Vn(t){return t.length===0?Number.POSITIVE_INFINITY:t.reduce((n,o)=>n+o,0)/t.length}l(Vn,"barycenter");function Ps(t,e,n,o){const s=new Map;for(const r of t)s.set(r,[]);for(const r of n)o==="down"?e.has(r.src)&&s.has(r.dst)&&s.get(r.dst).push(e.get(r.src)):e.has(r.dst)&&s.has(r.src)&&s.get(r.src).push(e.get(r.dst));return s}l(Ps,"neighborPositionsFor");function ks(t,e,n){const o=n.get(t)??0,s=n.get(e)??0;return o!==s?o-s:t.localeCompare(e)}l(ks,"currentOrderTieBreak");function jn(t,e,n){const o=new Set(t),s=new Set(e),r=Be(t),c=Be(e),a=[];for(const h of n)o.has(h.src)&&s.has(h.dst)&&a.push({u:r.get(h.src),v:c.get(h.dst)});a.sort((h,p)=>h.u===p.u?h.v-p.v:h.u-p.u);const f=a.map(h=>h.v);return xo(f)}l(jn,"countCrossingsBetweenAdjacent");function je(t,e,n){return[...t].sort((o,s)=>{const r=$n(e.get(o)??[]),c=$n(e.get(s)??[]);return r===c?ks(o,s,n):isFinite(r)?isFinite(c)?r-c:-1:1})}l(je,"sortByHeuristic");function Un(t,e,n,o,s,r){const c=Be(t),a=Be(e),f=Ps(e,c,n,o);if(!s||!r||r.length===0)return je(e,f,a);const h=new Map;for(const S of e){const d=s(S),u=h.get(d)??[];u.push(S),h.set(d,u)}const p=[];for(const S of r){const d=h.get(S);if(!d||d.length===0)continue;const u=je(d,f,a);p.push(...u)}const x=h.get(null);if(x&&x.length>0){const S=je(x,f,a);for(const d of S){const u=Vn(f.get(d)??[]);let i=p.length;if(isFinite(u))for(const[y,C]of p.entries()){const b=Vn(f.get(C)??[]);if(u<b){i=y;break}}p.splice(i,0,d)}}return p}l(Un,"reorderLayer");function Wn(t,e,n,o,s){const r=[...e],c=new Set(t),a=new Set(e),f=o?new Set(o):null,h=n.filter(i=>c.has(i.src)&&a.has(i.dst)),p=f?n.filter(i=>a.has(i.src)&&f.has(i.dst)):void 0,x=l(i=>{let y=jn(t,i,h);return p&&o&&(y+=jn(i,o,p)),y},"crossingScore"),S=s?new Map:null;if(s&&S)for(const i of e)S.set(i,s(i));let d=!0,u=x(r);for(;d;){d=!1;for(let i=0;i+1<r.length;i++){if(S){const b=S.get(r[i]),L=S.get(r[i+1]);if(b!==L)continue}const y=u;[r[i],r[i+1]]=[r[i+1],r[i]];const C=x(r);C<y?(u=C,d=!0):[r[i],r[i+1]]=[r[i+1],r[i]]}}return r}l(Wn,"transposeImprove");function Fs(t,e,n){const o=t.layers.map(a=>[...a]),s=e.edges,r=he(e),c=yo(e,n==null?void 0:n.laneOrder);for(let a=0;a<3;a++){for(let f=1;f<o.length;f++)o[f]=Un(o[f-1],o[f],s,"down",r,c),o[f]=Wn(o[f-1],o[f],s,o[f+1],r);for(let f=o.length-2;f>=0;f--)o[f]=Un(o[f+1],o[f],s,"up",r,c),o[f]=Wn(o[f+1],o[f],s,o[f-1],r)}return{layers:o}}l(Fs,"orderLayers");function _s(t,e,n){const o=(n==null?void 0:n.layerGap)??Eo.DEFAULT_LAYER_GAP,s=(n==null?void 0:n.nodeGap)??Eo.DEFAULT_NODE_GAP,r=(n==null?void 0:n.laneGap)??s*2,c=(n==null?void 0:n.direction)??"TB",a=c==="LR"||c==="RL",f=t.layers,h=Object.create(null),p=Object.create(null),x=l(O=>e.nodeById.get(O),"getNode"),S=l(O=>{var k;return((k=x(O))==null?void 0:k.width)??0},"getWidth"),d=l(O=>{var k;return((k=x(O))==null?void 0:k.height)??0},"getHeight"),u=he(e),i=yo(e,n==null?void 0:n.laneOrder),y=f.map(O=>O.reduce((k,D)=>Math.max(k,d(D)),0)),C=[];if(a)for(let O=0;O+1<f.length;O++){const k=f[O].reduce((It,Dt)=>Math.max(It,S(Dt)),0),D=f[O+1].reduce((It,Dt)=>Math.max(It,S(Dt)),0),B=y[O],G=y[O+1],j=B/2+G/2,tt=(k+D)/2,ft=Math.max(0,tt-j-o);C.push(ft)}const b=new Set;for(const O of f)for(const k of O)b.add(u(k));const L=b.has(null),v=i.filter(O=>b.has(O)),m=[...L?[null]:[],...v],I=Object.create(null);for(const O of v)I[O]=0;L&&(I.null=0);for(const O of f){const k=Object.create(null),D=[];for(const B of O){const G=u(B);G===null?D.push(B):(k[G]||(k[G]=[])).push(B)}for(const[B,G]of Object.entries(k)){const j=G.reduce((tt,ft)=>tt+S(ft),0)+s*Math.max(0,G.length-1);I[B]=Math.max(I[B]??0,j)}if(L&&D.length){const B=D.reduce((G,j)=>G+S(j),0)+s*Math.max(0,D.length-1);I.null=Math.max(I.null??0,B)}}const T=new Map;{const O=m.map(B=>(B===null?I.null:I[B])??0);let D=-(O.reduce((B,G)=>B+G,0)+r*Math.max(0,m.length-1))/2;for(let B=0;B<m.length;B++){const G=m[B],j=O[B]??0,tt=D+j/2;T.set(G,tt),D+=j,B<m.length-1&&(D+=r)}}let A=0;for(const[O,k]of f.entries()){const D=y[O]??0,B=new Map;for(const j of k){const tt=u(j),ft=B.get(tt)??[];ft.push(j),B.set(tt,ft)}for(const j of m){const tt=B.get(j)??[];if(tt.length===0)continue;const ft=T.get(j);if(tt.length===1){const It=tt[0];h[It]=ft,p[It]=A+D/2}else{const It=tt.map(nt=>S(nt)),Dt=It.reduce((nt,Z)=>nt+Z,0)+s*(tt.length-1);let _t=ft-Dt/2;for(const[nt,Z]of tt.entries()){const rt=It[nt];h[Z]=_t+rt/2,p[Z]=A+D/2,_t+=rt+s}}}const G=C[O]??0;A+=D+o+G}const P=new Map;for(const O of e.edges){const k=O.ref.id;P.has(k)||P.set(k,[]),P.get(k).push(O)}for(const[,O]of P){if(O.length===0)continue;const k=O[0].ref,D=k.start,B=k.end;if(D==null||B==null)continue;const G=Math.round(((h[D]??0)+(h[B]??0))/2),j=new Set;for(const tt of O)j.add(tt.src),j.add(tt.dst);for(const tt of j){if(tt===D||tt===B)continue;const ft=e.nodeById.get(tt);ft!=null&&ft.isDummy&&(h[tt]=G)}}return{x:h,y:p}}l(_s,"assignCoordinates");var Hs=8;function Ds(t){let e=2166136261;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e>>>0}l(Ds,"hashString");function Xs(t){let e=t>>>0;return()=>{e+=1831565813;let n=e;return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}l(Xs,"mulberry32");function Ys(t,e){const n=[...t],o=Xs(e);for(let s=n.length-1;s>0;s--){const r=Math.floor(o()*(s+1));[n[s],n[r]]=[n[r],n[s]]}return n}l(Ys,"deterministicShuffle");function Gs(t,e){let n=0;for(const[o,s]of t.entries())n+=Math.abs(o-(e.get(s)??o));return n}l(Gs,"sourceDistance");function Kn(t,e){const n=new Map;for(const[s,r]of t.entries())n.set(r,s);let o=0;for(const{a:s,b:r,weight:c}of e){const a=n.get(s),f=n.get(r);a==null||f==null||(o+=c*Math.abs(a-f))}return o}l(Kn,"laneArrangementCost");function zs(t){const e=cn(t);if(e.length<2)return[];const n=new Map(e.map((r,c)=>[r,c])),o=he(t),s=new Map;for(const r of t.layout.edges??[]){if(r.isLayoutOnly)continue;const c=typeof r.start=="string"?r.start:void 0,a=typeof r.end=="string"?r.end:void 0;if(!c||!a||!t.nodeById.has(c)||!t.nodeById.has(a))continue;const f=o(c),h=o(a);if(!f||!h||f===h)continue;const p=n.get(f),x=n.get(h);if(p==null||x==null)continue;const[S,d]=p<=x?[f,h]:[h,f],u=`${S}\0${d}`,i=s.get(u);i?i.weight++:s.set(u,{a:S,b:d,weight:1})}return[...s.values()]}l(zs,"buildWeightedLaneEdges");function qn(t,e,n){const o=[...t];let s=Kn(o,e),r=!0,c=0;const a=Math.max(1,o.length);for(;r&&c<a;){r=!1,c++;for(let f=0;f+1<o.length;f++){[o[f],o[f+1]]=[o[f+1],o[f]];const h=Kn(o,e);h<s?(s=h,r=!0):[o[f],o[f+1]]=[o[f+1],o[f]]}}return{order:o,cost:s,sourceDistance:Gs(o,n)}}l(qn,"greedySwitch");function $s(t,e){return t.cost!==e.cost?t.cost<e.cost:t.sourceDistance<e.sourceDistance}l($s,"isBetterCandidate");function Vs(t,e,n){const o=[...e].sort((s,r)=>s.a===r.a?s.b.localeCompare(r.b):s.a.localeCompare(r.a)).map(({a:s,b:r,weight:c})=>`${s}:${r}:${c}`).join("|");return Ds(`${t.join("|")}#${o}#${n}`)}l(Vs,"seedForRestart");function js(t,e={}){const n=cn(t);if(n.length<2)return n;const o=zs(t);if(o.length===0)return n;const s=new Map(n.map((a,f)=>[a,f]));let r=qn(n,o,s);const c=Math.max(0,e.restarts??Hs);for(let a=0;a<c;a++){const f=Vs(n,o,a),h=Ys(n,f),p=qn(h,o,s);$s(p,r)&&(r=p)}return r.order}l(js,"optimizeTopLaneOrder");function Us(t,e){const n=(e==null?void 0:e.ignoreCrossLaneEdges)??!0,o=(e==null?void 0:e.optimizeRanksByCrossings)??!0,s=Ie(t),r=e!=null&&e.automaticLaneOrdering?js(s,{restarts:Hs}):void 0,c=hs(s),a=c.acyclic,f=n?Os(a,{compactSingleInput:(e==null?void 0:e.compactSingleInput)??tn.DEFAULT_COMPACT_SINGLE_INPUT,ignoreCrossLaneEdges:!0,direction:e==null?void 0:e.direction}):Rs(a,{compactSingleInput:(e==null?void 0:e.compactSingleInput)??tn.DEFAULT_COMPACT_SINGLE_INPUT,ignoreCrossLaneEdges:!1,optimizeRanksByCrossings:o}),{layering:h,graphWithDummies:p}=Bs(f,a),x=Fs(h,p,{laneOrder:r}),S=_s(x,p,{layerGap:e==null?void 0:e.layerGap,nodeGap:e==null?void 0:e.nodeGap,direction:e==null?void 0:e.direction,laneOrder:r});return{acyclic:a,reversed:c.reversed,layering:h,ordered:x,coordinates:S}}l(Us,"sugiyamaLayout");var lt=pr.EPSILON,br=8,Se=15,Re=15,$e=25,ie=20,In=10;function Zn(t,e,n){const o=t.x??0,s=t.y??0,r=e.x-o,c=e.y-s,a=Math.abs(r),f=Math.abs(c);return a<lt&&f<lt?n:f>lt&&f*3>=a?c>0?"bottom":"top":a>lt?r>0?"right":"left":n}l(Zn,"chooseOrthogonalSide");function Jn(t,e){return Math.abs(t.to-e.from)<lt||Math.abs(t.to-e.to)<lt?t.to:t.from}l(Jn,"sharedLineEndpointCoord");function Ce(t,e){return t.orient==="vertical"?{x:t.coord,y:e}:{x:e,y:t.coord}}l(Ce,"pointOnLine");function Ws(t,e){var K,J,Y,q;const n=t.nodes??[],o=t.edges??[],s=[];for(const g of o)g.isLayoutOnly||s.push({...g,__originalEdge:g});const r=new Map,c=new Map,a=[],f=e==="LR";for(const g of n)r.set(g.id,g);const h=n.filter(g=>g.isGroup&&!g.parentId);for(const g of h){const M={id:g.id},E=l(w=>{c.set(w.id,M),n.filter(N=>N.parentId===w.id).forEach(E)},"assignLane");E(g)}const p=n.filter(g=>!g.isGroup&&!g.isEdgeLabel).map(g=>{const M=g.width??10,E=g.height??10,w=g.x??0,N=g.y??0,H=br;return{nodeId:g.id,minX:w-M/2-H,maxX:w+M/2+H,minY:N-E/2-H,maxY:N+E/2+H,visualXHalfExtent:f?E/2+H:M/2+H}}),x=l((g,M,E,w)=>{let N=a.find(H=>H.orientation===g&&Math.abs(H.coord-M)<1);return N||(N={id:`pipe-${g}-${M.toFixed(0)}`,orientation:g,coord:M,spanMin:E,spanMax:w,tracks:[]},a.push(N)),N.spanMin=Math.min(N.spanMin,E),N.spanMax=Math.max(N.spanMax,w),N},"getOrAddPipe"),S=l((g,M)=>{const E=g.width??10,w=g.height??10,N=g.x??0,H=g.y??0;switch(M){case"top":return{x:N,y:H-w/2};case"bottom":return{x:N,y:H+w/2};case"left":return{x:N-E/2,y:H};case"right":return{x:N+E/2,y:H}}},"portForSide"),d=l((g,M,E)=>S(g,Zn(g,M,E?"bottom":"top")),"getOrthogonalPort"),u=[],i=[],y=new Set,C=1e3,b=l((g,M,E)=>{if(u.length===0)return 0;const w=Math.abs(M.y-E.y)<lt,N=Math.abs(M.x-E.x)<lt;if(!w&&!N)return 0;let H=0;if(w){const W=M.y,ot=Math.min(M.x,E.x)-lt,U=Math.max(M.x,E.x)+lt;if(U<=ot)return 0;for(const $ of u)$.edgeIndex===g||$.orientation!=="vertical"||$.pipe.coord<ot||$.pipe.coord>U||$.from-lt<=W&&$.to+lt>=W&&(H+=C)}else if(N){const W=M.x,ot=Math.min(M.y,E.y)-lt,U=Math.max(M.y,E.y)+lt;if(U<=ot)return 0;for(const $ of u)$.edgeIndex===g||$.orientation!=="horizontal"||$.pipe.coord<ot||$.pipe.coord>U||$.from-lt<=W&&$.to+lt>=W&&(H+=C)}return H},"crossingPenalty"),L=s.map((g,M)=>{if(!g.start||!g.end)return{idx:M,crossLane:0,dx:0,dy:0};const E=r.get(g.start),w=r.get(g.end),N=c.get(g.start),H=c.get(g.end),W=N&&H&&N.id!==H.id?1:0,ot=E&&w?Math.abs((w.x??0)-(E.x??0)):0,U=E&&w?Math.abs((w.y??0)-(E.y??0)):0;return{idx:M,crossLane:W,dx:ot,dy:U}}).sort((g,M)=>{if(g.crossLane!==M.crossLane)return M.crossLane-g.crossLane;const E=g.dx+g.dy,w=M.dx+M.dy;return Math.abs(E-w)>1?E-w:g.idx-M.idx}).map(g=>g.idx),v=l((g,M,E,w)=>{const N=Math.min(g.x,M.x),H=Math.max(g.x,M.x),W=Math.min(g.y,M.y),ot=Math.max(g.y,M.y);return!!p.find($=>E&&$.nodeId===E||w&&$.nodeId===w?!1:Math.abs(g.x-M.x)>lt?$.minY<g.y&&$.maxY>g.y&&$.maxX>N&&$.minX<H:$.minX<g.x&&$.maxX>g.x&&$.maxY>W&&$.minY<ot)},"isSegmentBlocked"),m=new Map,I=new Map;for(const g of s)!g.start||!g.end||g.start===g.end||(I.set(g.start,(I.get(g.start)??0)+1),I.set(g.end,(I.get(g.end)??0)+1));const T=l((g,M)=>Zn(g,M,"bottom"),"determineSide"),A=new Map;for(const[g,M]of s.entries()){if(!M.start||!M.end||M.start===M.end||M.points&&M.points.length>0)continue;const E=r.get(M.start),w=r.get(M.end);if(!E||!w)continue;const N=(w.x??0)-(E.x??0),H=(w.y??0)-(E.y??0);A.set(g,{edgeIdx:g,srcId:M.start,dstId:M.end,srcSide:T(E,{x:w.x??0,y:w.y??0}),dstSide:T(w,{x:E.x??0,y:E.y??0}),absDx:Math.abs(N),absDy:Math.abs(H),dxSign:Math.sign(N),dySign:Math.sign(H)})}const P=l(g=>g.srcSide==="top"||g.srcSide==="bottom"?g.absDx===0?1/0:g.absDy/g.absDx:g.absDy===0?1/0:g.absDx/g.absDy,"preferenceStrength"),O=l(g=>g.srcSide==="top"||g.srcSide==="bottom"?g.dxSign>=0?"right":"left":g.dySign>=0?"bottom":"top","secondarySide"),k=new Map;for(const g of A.values()){const M=`${g.srcId}:${g.srcSide}`;k.has(M)||k.set(M,[]),k.get(M).push(g)}const D=new Map,B=l((g,M)=>`${g}:${M}`,"loadKey");for(const g of A.values())D.set(B(g.srcId,g.srcSide),(D.get(B(g.srcId,g.srcSide))??0)+1),D.set(B(g.dstId,g.dstSide),(D.get(B(g.dstId,g.dstSide))??0)+1);for(const g of k.values())if(!(g.length<2)){g.sort((M,E)=>{const w=P(M),N=P(E);return Math.abs(w-N)>1e-9?N-w:M.edgeIdx-E.edgeIdx});for(let M=1;M<g.length;M++){const E=g[M],w=O(E),N=D.get(B(E.srcId,E.srcSide))??0,H=D.get(B(E.srcId,w))??0;H>=N||(D.set(B(E.srcId,E.srcSide),N-1),D.set(B(E.srcId,w),H+1),E.srcSide=w)}}const G=l(g=>{const M=g==null?void 0:g.shape;return M==="question"||M==="diamond"},"isDiamondNode"),j=new Map;for(const g of A.values())j.has(g.dstId)||j.set(g.dstId,new Set),j.get(g.dstId).add(g.dstSide);for(const g of A.values()){if(!G(r.get(g.srcId)))continue;const M=j.get(g.srcId);if(!(M!=null&&M.has(g.srcSide)))continue;const E=O(g);if(M.has(E)||(D.get(B(g.srcId,E))??0)>0)continue;const w=D.get(B(g.srcId,g.srcSide))??0;D.set(B(g.srcId,g.srcSide),Math.max(0,w-1)),D.set(B(g.srcId,E),1),g.srcSide=E}for(const g of A.values()){const{edgeIdx:M,srcId:E,dstId:w,srcSide:N,dstSide:H}=g,W=r.get(E),ot=r.get(w),U=`${E}:${N}:src`,$=N==="top"||N==="bottom"?ot.x??0:ot.y??0;m.has(U)||m.set(U,[]),m.get(U).push({edgeIdx:M,oppositeCoord:$});const bt=`${w}:${H}:dst`,dt=H==="top"||H==="bottom"?W.x??0:W.y??0;m.has(bt)||m.set(bt,[]),m.get(bt).push({edgeIdx:M,oppositeCoord:dt})}const tt=new Map,ft=8;for(const[g,M]of m){if(M.length<2)continue;M.sort((At,Gt)=>At.oppositeCoord-Gt.oppositeCoord);const E=g.split(":"),w=E.slice(0,-2).join(":"),N=E[E.length-2],H=E[E.length-1],W=r.get(w);if(!W)continue;const U=N==="left"||N==="right"?W.height??10:W.width??10,$=W.shape,dt=$==="question"||$==="diamond"?U*.3:U,st=Math.min(20,Math.max(ft,dt/(M.length+1))),Pt=-(st*(M.length-1))/2;for(const[At,Gt]of M.entries()){const ee=Pt+At*st,dn=`${Gt.edgeIdx}:${H}`;tt.set(dn,ee)}}const It=l(g=>{var M;return!!((M=s[g])!=null&&M.labelNodeId)},"edgeHasLabelNode"),Dt=l((g,M)=>g?(m.get(`${g}:${M}:src`)??[]).some(({edgeIdx:E})=>It(E))||(m.get(`${g}:${M}:dst`)??[]).some(({edgeIdx:E})=>It(E)):!1,"faceHasLabelNode"),_t=l((g,M,E)=>M==="top"||M==="bottom"?{x:g.x+E,y:g.y}:{x:g.x,y:g.y+E},"applyPortOffset"),nt=l((g,M,E)=>{const w=A.get(g),N={x:E.x??0,y:E.y??0},H={x:M.x??0,y:M.y??0},W=(w==null?void 0:w.srcSide)??T(M,N),ot=(w==null?void 0:w.dstSide)??T(E,H);let U=w?S(M,w.srcSide):d(M,N,!0),$=w?S(E,w.dstSide):d(E,H,!1);const bt=tt.get(`${g}:src`),dt=tt.get(`${g}:dst`);return bt!==void 0&&(U=_t(U,W,bt)),dt!==void 0&&($=_t($,ot,dt)),{pSrcPort:U,pDstPort:$,srcSide:W,dstSide:ot}},"portsForEdge");for(const g of L){const M=s[g];if(i[g]=[],!M.start||!M.end||M.points&&M.points.length>0||M.start===M.end)continue;const E=r.get(M.start),w=r.get(M.end);if(!E||!w)continue;const{pSrcPort:N,pDstPort:H,srcSide:W,dstSide:ot}=nt(g,E,w),U={...N},$={...H},bt=W==="top"||W==="bottom",dt=ot==="top"||ot==="bottom";if(bt){const X=N.y>(E.y??0);U.y=X?N.y+ie:N.y-ie}else{const X=N.x>(E.x??0);U.x=X?N.x+ie:N.x-ie}if(dt){const X=H.y>(w.y??0);$.y=X?H.y+ie:H.y-ie}else{const X=H.x>(w.x??0);$.x=X?H.x+ie:H.x-ie}const ct=l((X,z)=>{for(const Q of p)if(!z.includes(Q.nodeId)&&X.x>Q.minX&&X.x<Q.maxX&&X.y>Q.minY&&X.y<Q.maxY)return{inside:!0,obstacle:Q};return{inside:!1}},"isPointInObstacle"),st=l((X,z,Q,ht,wt)=>{if(wt){const kt=X.y>(z.y??0);return{x:(Q.x??0)>=X.x?ht.maxX+Se:ht.minX-Se,y:kt?ht.maxY+Re:ht.minY-Re,leavesPositiveSide:kt}}const Ct=X.x>(z.x??0),Rt=(Q.y??0)>=X.y;return{x:Ct?ht.maxX+Se:ht.minX-Se,y:Rt?ht.maxY+Re:ht.minY-Re,leavesPositiveSide:Ct}},"obstacleDetour");let Mt=[];const Pt=[M.start,M.end],At=ct(U,Pt);if(At.inside&&At.obstacle){const X=At.obstacle;if(bt){const z=st(N,E,w,X,!0);U.x=z.x,U.y=z.y;const Q=z.leavesPositiveSide?Math.min(X.minY-2,N.y+ie):Math.max(X.maxY+2,N.y-ie);Mt=[{x:N.x,y:Q},{x:z.x,y:Q},{x:z.x,y:z.y}]}else{const z=st(N,E,w,X,!1),Q=z.leavesPositiveSide?Math.min(X.minX-2,N.x+ie):Math.max(X.maxX+2,N.x-ie);U.x=z.x,U.y=z.y,Mt=[{x:Q,y:N.y},{x:Q,y:z.y},{x:z.x,y:z.y}]}}let Gt=[];const ee=ct($,Pt);if(ee.inside&&ee.obstacle){const X=ee.obstacle;if(dt){const z=st(H,w,E,X,!0);$.x=z.x,$.y=z.y,Gt=[{x:z.x,y:z.y},{x:H.x,y:z.y}]}else{const z=st(H,w,E,X,!1);$.x=z.x,$.y=z.y,Gt=[{x:z.x,y:z.y},{x:z.x,y:H.y}]}}if(Mt.length===0&&Gt.length===0){const X=Se,z=Math.abs(U.x-$.x)<X,Q=Math.abs(U.y-$.y)<X,ht=tt.get(`${g}:src`)!==void 0||tt.get(`${g}:dst`)!==void 0,wt=(((K=m.get(`${M.start??""}:${W}:src`))==null?void 0:K.length)??0)+(((J=m.get(`${M.start??""}:${W}:dst`))==null?void 0:J.length)??0),Ct=(((Y=m.get(`${M.end??""}:${ot}:src`))==null?void 0:Y.length)??0)+(((q=m.get(`${M.end??""}:${ot}:dst`))==null?void 0:q.length)??0),Rt=wt>1||Ct>1,kt=I.get(M.start??"")??0,mt=I.get(M.end??"")??0,Vt=wt>1&&Dt(M.start,W)||Ct>1&&Dt(M.end,ot),re=wt<=1||kt<=2,Ht=Ct<=1||mt<=2;if((z||Q)&&!ht&&(!Rt||Rt&&!Vt&&re&&Ht)&&!v(N,H,M.start,M.end)){M.points=[{...N},{...U},{...$},{...H}],y.add(g);const vt=Q?"horizontal":"vertical",Ut=Q?N.y:N.x,Lt=Q?Math.min(N.x,H.x):Math.min(N.y,H.y),Tt=Q?Math.max(N.x,H.x):Math.max(N.y,H.y),Jt={id:`fast-path-${vt}-${Ut.toFixed(0)}-${g}`,orientation:vt,coord:Ut,spanMin:Lt,spanMax:Tt,tracks:[]};u.push({edgeIndex:g,segmentIndex:0,orientation:vt,pipe:Jt,trackIndex:0,from:Lt,to:Tt});continue}}const dn=x("vertical",U.x,U.y,U.y);U.x=dn.coord;const Js=x("vertical",$.x,$.y,$.y);$.x=Js.coord;let me=Math.min(U.x,$.x)-50,xe=Math.max(U.x,$.x)+50,we=Math.min(U.y,$.y)-50,Ee=Math.max(U.y,$.y)+50;for(const X of p){const z=Math.min(U.x,$.x),Q=Math.max(U.x,$.x),ht=Math.min(U.y,$.y),wt=Math.max(U.y,$.y);X.minX<Q&&X.maxX>z&&X.minY<wt&&X.maxY>ht&&(me=Math.min(me,X.minX-$e),xe=Math.max(xe,X.maxX+$e),we=Math.min(we,X.minY-$e),Ee=Math.max(Ee,X.maxY+$e))}for(const X of p){if(X.maxX<me||X.minX>xe||X.maxY<we||X.minY>Ee)continue;const z=Se;x("horizontal",X.minY-z,me,xe),x("horizontal",X.maxY+z,me,xe);const Q=Re;x("vertical",X.minX-Q,we,Ee),x("vertical",X.maxX+Q,we,Ee)}x("horizontal",U.y,me,xe),x("horizontal",$.y,me,xe);const Qs=a.filter(X=>X.orientation==="horizontal"&&X.coord>=we&&X.coord<=Ee),tr=a.filter(X=>X.orientation==="vertical"&&X.coord>=me&&X.coord<=xe),Fe=l((X,z)=>`${X.toFixed(1)},${z.toFixed(1)}`,"getKey"),_e=Fe(U.x,U.y),bo=Fe($.x,$.y),He=new Map,un=new Map,hn=new Map,De=new Set,Me=[];He.set(_e,0),hn.set(_e,"n"),Me.push({key:_e,f:Math.hypot($.x-U.x,$.y-U.y),pt:U}),De.add(_e);let zt=[];const ye=l((X,z)=>v(X,z,M.start,M.end),"checkSegmentBlocked"),gn={x:$.x,y:U.y},er=ye(U,gn),nr=ye(gn,$),or=er||nr,mn={x:U.x,y:$.y},sr=ye(U,mn),rr=ye(mn,$);if(or?sr||rr||(Math.abs(U.x-$.x)<lt?zt=[U,$]:zt=[U,mn,$]):Math.abs(U.y-$.y)<lt||Math.abs(U.x-$.x)<lt?zt=[U,$]:zt=[U,gn,$],zt.length===0)for(;Me.length>0;){Me.sort((mt,Vt)=>mt.f-Vt.f);const X=Me.shift();if(De.delete(X.key),X.key===bo){let mt=bo,Vt=$;for(zt=[Vt];un.has(mt);){const re=un.get(mt);zt.unshift(re),Vt=re,mt=Fe(re.x,re.y)}break}const z=X.pt.x,Q=X.pt.y,ht=tr.sort((mt,Vt)=>mt.coord-Vt.coord),wt=ht.findIndex(mt=>Math.abs(mt.coord-z)<1),Ct=Qs.sort((mt,Vt)=>mt.coord-Vt.coord),Rt=Ct.findIndex(mt=>Math.abs(mt.coord-Q)<1),kt=[];wt>0&&kt.push({x:ht[wt-1].coord,y:Q}),wt>=0&&wt<ht.length-1&&kt.push({x:ht[wt+1].coord,y:Q}),Rt>0&&kt.push({x:z,y:Ct[Rt-1].coord}),Rt>=0&&Rt<Ct.length-1&&kt.push({x:z,y:Ct[Rt+1].coord});for(const mt of kt){const Vt=Math.min(z,mt.x),re=Math.max(z,mt.x),Ht=Math.min(Q,mt.y),jt=Math.max(Q,mt.y);if(p.some(ne=>ne.nodeId===M.start||ne.nodeId===M.end?!1:Vt!==re?ne.minY<Q&&ne.maxY>Q&&ne.maxX>Vt&&ne.minX<re:ne.minX<z&&ne.maxX>z&&ne.maxY>Ht&&ne.minY<jt))continue;const vt=Fe(mt.x,mt.y),Ut=Math.abs(mt.x-z)+Math.abs(mt.y-Q),Lt=b(g,X.pt,mt);let Tt=0;const Jt=$.x-U.x,Ae=$.y-U.y,Xe=mt.x-z,xn=mt.y-Q;(Ae>10&&xn<-5||Ae<-10&&xn>5)&&(Tt=Math.abs(xn)*100),(Jt>10&&Xe<-5||Jt<-10&&Xe>5)&&(Tt+=Math.abs(Xe)*50);let Io=0;const Mo=hn.get(X.key)??"n",So=Math.abs(Xe)>lt?"h":"v";Mo!=="n"&&Mo!==So&&(Io=50);const ir=Ut+Lt+Tt+Io,Ye=(He.get(X.key)??1/0)+ir,Co=Math.abs($.x-mt.x)+Math.abs($.y-mt.y);if(Ye<(He.get(vt)??1/0))if(un.set(vt,X.pt),He.set(vt,Ye),hn.set(vt,So),!De.has(vt))Me.push({key:vt,f:Ye+Co,pt:mt}),De.add(vt);else{const ne=Me.findIndex(cr=>cr.key===vt);ne!==-1&&(Me[ne].f=Ye+Co)}}}if(zt.length===0&&(zt=[U,{x:U.x,y:$.y},$]),zt.length>4){const X=zt[0],z=zt[zt.length-1];let Q=Math.min(X.x,z.x),ht=Math.max(X.x,z.x),wt=Math.min(X.y,z.y),Ct=Math.max(X.y,z.y);for(const Ht of zt)Q=Math.min(Q,Ht.x),ht=Math.max(ht,Ht.x),wt=Math.min(wt,Ht.y),Ct=Math.max(Ct,Ht.y);const Rt=ht>Math.max(X.x,z.x),kt=Q<Math.min(X.x,z.x);if(f){const Ht=Re;if(Rt){const jt=Math.max(X.x,z.x),Ft=Math.min(X.y,z.y),vt=Math.max(X.y,z.y),Ut=p.filter(Lt=>Lt.minX<jt&&Lt.maxX>jt&&Lt.minY<vt&&Lt.maxY>Ft);if(Ut.length>0){let Lt=Math.max(X.x,z.x);for(const Tt of Ut){const Jt=(Tt.minX+Tt.maxX)/2;if(Tt.visualXHalfExtent===void 0||isNaN(Tt.visualXHalfExtent))continue;const Ae=Jt+Tt.visualXHalfExtent+Ht;Lt=Math.max(Lt,Ae)}isNaN(Lt)||(ht=Lt)}}if(kt){const jt=p.filter(Ft=>Ft.minX<Math.min(X.x,z.x)+Ht&&Ft.minY<Math.max(X.y,z.y)&&Ft.maxY>Math.min(X.y,z.y));if(jt.length>0){let Ft=Math.min(X.x,z.x);for(const vt of jt){const Lt=(vt.minX+vt.maxX)/2-vt.visualXHalfExtent-Ht;Ft=Math.min(Ft,Lt)}Q=Ft}}}const mt=l(Ht=>{const jt=z.y>X.y,Ft=p.filter(Lt=>{const Tt=Math.min(X.x,z.x)<Lt.maxX&&Math.max(X.x,z.x)>Lt.minX,Jt=Math.min(X.y,z.y)<Lt.maxY&&Math.max(X.y,z.y)>Lt.minY;return Tt&&Jt});let vt=Ft;if(f&&Ft.length>0){const Lt=Ft.filter(Tt=>Tt.minX<Ht&&Tt.maxX>Ht);Lt.length>0&&(vt=Lt)}if(vt.length===0)return z.y;const Ut=Se;if(jt){const Tt=Math.max(...vt.map(Jt=>Jt.maxY))+Ut;if(Tt<z.y-lt)return Tt}else{const Tt=Math.min(...vt.map(Jt=>Jt.minY))-Ut;if(Tt>z.y+lt)return Tt}return z.y},"findBestReturnY"),Vt=l(Ht=>{const jt=mt(Ht),Ft={x:Ht,y:X.y},vt={x:Ht,y:jt},Ut={x:z.x,y:jt},Lt=ye(X,Ft),Tt=ye(Ft,vt),Jt=ye(vt,Ut),Ae=jt!==z.y?ye(Ut,z):!1;return!Lt&&!Tt&&!Jt&&!Ae?Math.abs(jt-z.y)<lt?[X,Ft,vt,z]:[X,Ft,vt,Ut,z]:null},"trySimplifyWithDetourX"),re=Rt&&!kt?Vt(ht):kt&&!Rt?Vt(Q):null;re&&(zt=re)}const $t=[N,...Mt,...zt,...Gt.reverse(),H];if($t.length>=3){const X=$t[$t.length-1],z=$t[$t.length-2],Q=$t[$t.length-3],ht=Math.abs(Q.y-z.y)<lt&&Math.abs(z.y-X.y)<lt,wt=Math.abs(Q.x-z.x)<lt&&Math.abs(z.x-X.x)<lt;if(ht){const Ct=Math.sign(z.x-Q.x),Rt=Math.sign(X.x-Q.x);Ct!==0&&Ct===Rt&&Math.abs(z.x-Q.x)>Math.abs(X.x-Q.x)&&$t.splice(-2,1)}else if(wt){const Ct=Math.sign(z.y-Q.y),Rt=Math.sign(X.y-Q.y);Ct!==0&&Ct===Rt&&Math.abs(z.y-Q.y)>Math.abs(X.y-Q.y)&&$t.splice(-2,1)}}const le=[$t[0]];for(let X=1;X<$t.length-1;X++){if(X===1){le.push($t[X]);continue}const z=le[le.length-1],Q=$t[X],ht=$t[X+1];if(Math.abs(z.y-Q.y)<lt&&Math.abs(Q.y-ht.y)<lt){const wt=Q.x>z.x,Ct=ht.x>Q.x;if(wt!==Ct){le.push(Q);continue}continue}if(Math.abs(z.x-Q.x)<lt&&Math.abs(Q.x-ht.x)<lt){const wt=Q.y>z.y,Ct=ht.y>Q.y;if(wt!==Ct){le.push(Q);continue}continue}le.push(Q)}le.push($t[$t.length-1]);for(let X=0;X<le.length-1;X++){const z=le[X],Q=le[X+1],ht=Math.abs(z.x-Q.x)<lt?"vertical":"horizontal",wt=ht==="vertical"?z.x:z.y,Ct=ht==="vertical"?Math.min(z.y,Q.y):Math.min(z.x,Q.x),Rt=ht==="vertical"?Math.max(z.y,Q.y):Math.max(z.x,Q.x),kt=x(ht,wt,Ct,Rt),mt={edgeIndex:g,segmentIndex:X,orientation:ht,pipe:kt,trackIndex:0,from:Ct,to:Rt};u.push(mt),i[g].push(u.length-1),kt.tracks[0]||(kt.tracks[0]={index:0,coord:kt.coord,segments:[]}),kt.tracks[0].segments.push({edgeIndex:g,segmentIndex:X,from:Ct,to:Rt})}}const Z=l((g,M)=>g.from<M.to&&M.from<g.to,"segmentsOverlap"),rt=l((g,M,E,w)=>{const N=!w.segments.some(W=>(W.edgeIndex!==M.edgeIndex||W.segmentIndex!==M.segmentIndex)&&Z(W,g)),H=!E.segments.some(W=>(W.edgeIndex!==g.edgeIndex||W.segmentIndex!==g.segmentIndex)&&Z(W,M));return N&&H?(g.trackIndex=w.index,M.trackIndex=E.index,E.segments=[...E.segments.filter(W=>W.edgeIndex!==g.edgeIndex||W.segmentIndex!==g.segmentIndex),{edgeIndex:M.edgeIndex,segmentIndex:M.segmentIndex,from:M.from,to:M.to}],w.segments=[...w.segments.filter(W=>W.edgeIndex!==M.edgeIndex||W.segmentIndex!==M.segmentIndex),{edgeIndex:g.edgeIndex,segmentIndex:g.segmentIndex,from:g.from,to:g.to}],!0):!1},"trySwapSegmentsAcrossTracks"),ut=l(g=>{const M=g.tracks.length;return g.tracks[M]={index:M,coord:g.coord,segments:[]},M},"createNewTrack"),yt=l((g,M)=>{const E=g.pipe.tracks[g.trackIndex];E.segments=E.segments.filter(N=>N.edgeIndex!==g.edgeIndex||N.segmentIndex!==g.segmentIndex),g.trackIndex=M,g.pipe.tracks[M].segments.push({edgeIndex:g.edgeIndex,segmentIndex:g.segmentIndex,from:g.from,to:g.to})},"moveSegmentToTrack"),St=l((g,M)=>{const E=i[g.edgeIndex];for(const w of E){const N=u[w];N.pipe===g.pipe&&yt(N,M)}},"moveSegmentChainToTrack"),Et=l(g=>{const M=i[g.edgeIndex],E=M.indexOf(u.indexOf(g)),w=[];return E>0&&w.push(u[M[E-1]]),E<M.length-1&&w.push(u[M[E+1]]),w},"getAdjacentSegmentsAlongEdge"),Kt=l((g,M)=>{if(g.orientation===M.orientation)return!1;const E=g.orientation==="horizontal"?g:M,w=g.orientation==="horizontal"?M:g;return w.pipe.coord>E.from&&w.pipe.coord<E.to&&E.pipe.coord>w.from&&E.pipe.coord<w.to},"haveAnyCrossing"),qt=l((g,M)=>{for(const E of g.tracks)if(!E.segments.some(N=>(N.edgeIndex!==M.edgeIndex||N.segmentIndex!==M.segmentIndex)&&Z(N,M)))return E.index;return-1},"findAvailableTrack"),Zt=l((g,M)=>{if(g.trackIndex===M.trackIndex)return Z(g,M);const E=Et(g),w=Et(M);return E.some(N=>w.some(H=>Kt(N,H)))},"segmentsConflict"),se=l((g,M,E)=>{if(rt(g,M,g.pipe.tracks[g.trackIndex],M.pipe.tracks[M.trackIndex]))return;const w=qt(g.pipe,M);E(M,w!==-1?w:ut(g.pipe))},"resolveTrackConflict"),Le=l(g=>{let M=0;for(let E=0;E<g.length;E++)for(let w=E+1;w<g.length;w++){const N=g[E],H=g[w];N.pipe===H.pipe&&Zt(N,H)&&(M++,se(N,H,St))}return M},"resolveHandleConflicts"),ge=new Map,Te=l(g=>{if(ge.has(g))return ge.get(g);const M=i[g];if(M.length===0){const ot={dest:0,deviation:0,base:0,delta:0};return ge.set(g,ot),ot}const w=u[M[0]].pipe.coord;let N=w;for(let ot=1;ot<M.length;ot++){const U=u[M[ot]];if(U.orientation==="horizontal"){const $=U.from,bt=U.to;N=Math.abs($-w)>Math.abs(bt-w)?$:bt;break}}const H=Math.abs(N-w),W={dest:N,deviation:H,base:w,delta:N-w};return ge.set(g,W),W},"getDestInfo"),an=l(()=>{let g=0;const M=new Map;for(const[w,N]of s.entries())i[w].length!==0&&N.start&&(M.has(N.start)||M.set(N.start,[]),M.get(N.start).push(w));const E=l(w=>{const N=s[w];if(!N.start||!N.end)return 0;const H=r.get(N.start),W=r.get(N.end);if(!H||!W)return 0;const ot=(W.x??0)-(H.x??0),U=(W.y??0)-(H.y??0);return Math.abs(ot)+Math.abs(U)},"getEdgeDistance");for(const w of M.values()){w.sort((H,W)=>{const ot=Te(H),U=Te(W);if(Math.abs(ot.deviation-U.deviation)>1)return ot.deviation-U.deviation;if(Math.abs(ot.dest-U.dest)>1)return ot.dest-U.dest;const $=E(H),bt=E(W);if(Math.abs($-bt)>1)return bt-$;const dt=i[H].length,ct=i[W].length;if(dt!==ct)return dt-ct;if(dt===1){const st=i[H][0],Mt=i[W][0];if(u[st]&&u[Mt]){const Pt=u[st],At=u[Mt],Gt=Math.abs(Pt.to-Pt.from),ee=Math.abs(At.to-At.from);if(Math.abs(Gt-ee)>1)return Gt-ee}}return 0});const N=w.map(H=>u[i[H][0]]);g+=Le(N)}return g},"fixSourceHandleCrossings"),ln=l(()=>{let g=0;const M=new Map;for(const[E,w]of s.entries())i[E].length!==0&&w.end&&(M.has(w.end)||M.set(w.end,[]),M.get(w.end).push(E));for(const E of M.values()){E.sort((N,H)=>{const W=l($=>{const bt=i[$];if(bt.length<2)return 0;const dt=u[bt[bt.length-2]];return Math.abs(dt.to-dt.from)},"getDist"),ot=W(N),U=W(H);return Math.abs(ot-U)>.1?ot-U:N-H});const w=E.map(N=>u[i[N][i[N].length-1]]);g+=Le(w)}return g},"fixTargetHandleCrossings"),fn=l(()=>{let g=0;for(const M of a){const E=[];for(const w of M.tracks)for(const N of w.segments){const H=i[N.edgeIndex].find(W=>u[W].segmentIndex===N.segmentIndex);H!==void 0&&E.push(u[H])}E.sort((w,N)=>w.edgeIndex-N.edgeIndex||w.segmentIndex-N.segmentIndex);for(let w=0;w<E.length;w++)for(let N=w+1;N<E.length;N++){const H=E[w],W=E[N];Zt(H,W)&&(g++,se(H,W,yt))}}return g},"fixPipeCrossings");let R=0;const F=10;for(;R<F;){let g=0;if(g+=an(),g+=ln(),g+=fn(),g===0)break;R++}const _=new Map;for(const g of a){const M=[];g.tracks.forEach(w=>{w.segments.forEach(N=>{M.push({edgeIndex:N.edgeIndex,segmentIndex:N.segmentIndex,trackIndex:w.index,from:N.from,to:N.to})})}),M.sort((w,N)=>w.from-N.from);const E=[];if(M.length>0){let w=[M[0]],N=M[0].to;for(let H=1;H<M.length;H++){const W=M[H];W.from<N?(w.push(W),N=Math.max(N,W.to)):(E.push(w),w=[W],N=W.to)}E.push(w)}for(const w of E){const N=new Set;w.forEach(st=>N.add(st.trackIndex));const H=new Map;w.forEach(st=>{const Mt=Te(st.edgeIndex);H.set(st.trackIndex,(H.get(st.trackIndex)??0)+Mt.delta)});const W=[...N].filter(st=>(H.get(st)??0)<-1),ot=[...N].filter(st=>(H.get(st)??0)>1),U=[...N].filter(st=>Math.abs(H.get(st)??0)<=1);W.sort((st,Mt)=>(H.get(Mt)??0)-(H.get(st)??0)),ot.sort((st,Mt)=>(H.get(st)??0)-(H.get(Mt)??0));const $=l((st,Mt)=>{w.filter(Pt=>Pt.trackIndex===st).forEach(Pt=>{const At=y.has(Pt.edgeIndex)?g.coord:Mt;_.set(`${Pt.edgeIndex}-${Pt.segmentIndex}`,At)})},"assignCoord");let bt=0;for(const st of W)bt++,$(st,g.coord-bt*In);if(U.length===0&&N.size>0){const st=[...N].sort((At,Gt)=>Math.abs(H.get(At)??0)-Math.abs(H.get(Gt)??0))[0],Mt=W.indexOf(st);Mt!==-1&&W.splice(Mt,1);const Pt=ot.indexOf(st);Pt!==-1&&ot.splice(Pt,1),U.push(st)}let dt=0;for(const st of U){if(dt===0)$(st,g.coord);else{const Mt=dt%2===1?1:-1,Pt=Math.ceil(dt/2);$(st,g.coord+Mt*Pt*In*.5)}dt++}let ct=0;for(const st of ot)ct++,$(st,g.coord+ct*In)}}for(const[g,M]of s.entries()){const E=i[g]??[];if(E.length===0)continue;const w=[],N=r.get(M.start),H=r.get(M.end),{pSrcPort:W,pDstPort:ot}=nt(g,N,H),U=E.map(dt=>{const ct=u[dt],st=_.get(`${ct.edgeIndex}-${ct.segmentIndex}`)??ct.pipe.coord;return{orient:ct.orientation,coord:st,from:ct.from,to:ct.to}});w.push(W);for(let dt=0;dt<U.length;dt++){const ct=U[dt],st=w[w.length-1],Mt=ct.orient==="vertical"?st.y:st.x,Pt=ct.orient==="vertical"?st.x:st.y,At=U[dt+1],Gt=dt<U.length-1;if(Math.abs(Pt-ct.coord)>lt&&w.push(Ce(ct,Mt)),Gt&&At.orient===ct.orient)if(Math.abs(ct.coord-At.coord)>lt){const ee=ct.orient==="vertical"?(Mt+At.from)/2:Jn(ct,At);w.push(Ce(ct,ee),Ce(At,ee))}else(dt===0||dt===U.length-2)&&w.push(Ce(ct,Jn(ct,At)));else if(Gt)w.push(Ce(ct,At.coord));else{const ee=Math.abs(ct.from-Mt)<Math.abs(ct.to-Mt)?ct.to:ct.from;w.push(Ce(ct,ee))}}const $=w[w.length-1];(Math.abs($.x-ot.x)>lt||Math.abs($.y-ot.y)>lt)&&w.push(ot);const bt=[];w.length>0&&bt.push(w[0]);for(let dt=1;dt<w.length;dt++){const ct=w[dt],st=bt[bt.length-1];(Math.abs(ct.x-st.x)>lt||Math.abs(ct.y-st.y)>lt)&&bt.push(ct)}M.points=bt}for(const g of s){const M=g.__originalEdge;M&&g.points&&(M.points=g.points)}t.edges=(t.edges??[]).filter(g=>!g.isLayoutOnly);const V=l((g,M)=>{const E=M.x??0,w=M.y??0,N=M.width??0,H=M.height??0;if(N<=0||H<=0)return g;const W=E-N/2,ot=E+N/2,U=w-H/2,$=w+H/2;if(g.x<W||g.x>ot||g.y<U||g.y>$)return g;const bt=g.x-W,dt=ot-g.x,ct=g.y-U,st=$-g.y,Mt=Math.min(bt,dt,ct,st);return Mt===bt?{x:W,y:g.y}:Mt===dt?{x:ot,y:g.y}:Mt===ct?{x:g.x,y:U}:{x:g.x,y:$}},"nodeBoundaryClamp");for(const g of t.edges){const M=g.points;if(!M||M.length<2)continue;const E=g.start,w=g.end,N=E?r.get(E):void 0,H=w?r.get(w):void 0;N&&(M[0]=V(M[0],N)),H&&(M[M.length-1]=V(M[M.length-1],H))}return t}l(Ws,"routeEdgesOrthogonal");function Ks(t){return t.direction??"TB"}l(Ks,"getSwimlaneDirection");function qs(t){var p,x,S,d,u;const e=Oo(t),n=((p=t.config.flowchart)==null?void 0:p.nodeSpacing)??40,o=((x=t.config.flowchart)==null?void 0:x.rankSpacing)??100,s=((S=t.config.swimlane)==null?void 0:S.ignoreCrossLaneEdges)??!0,r=((d=t.config.swimlane)==null?void 0:d.optimizeRanksByCrossings)??!0,c=((u=t.config.swimlane)==null?void 0:u.automaticLaneOrdering)??!1,a=Ks(t),{ordered:f,coordinates:h}=Us(e,{nodeGap:n,layerGap:o,ignoreCrossLaneEdges:s,optimizeRanksByCrossings:r,automaticLaneOrdering:c,direction:a});Bo(e,f,h,{nodeGap:n,layerGap:o});for(const i of t.edges??[])delete i.points;Ws(t,a);for(const i of t.edges??[])(!i.curve||i.curve==="basis")&&(i.curve="rounded");return ds(t,a),fs(t),a}l(qs,"runSwimlaneLayoutCore");function Zs(t){No(t);const e=Po(t);t.nodes=e.nodes,t.edges=e.edges}l(Zs,"prepareSwimlaneLayout");var wr=lr({prepareLayout:Zs,runLayoutCore:qs,afterPaint:Ao});export{wr as render};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{c as r,s as e}from"./flowDiagram-KWPJA3E3-C2dUfvWx.js";import{_ as o}from"./index-BFkHoNBz.js";import"./element-plus-IBMLLhb-.js";import"./chunk-5VM5RSS4-DS8_TMNo.js";import"./chunk-XXDRQBXY-CyL5e2d_.js";import"./chunk-WEXAMYUT-C-ODRuff.js";import"./chunk-GWA4HPMP-BKqnDCMe.js";import"./channel-SnOBxP58.js";import"./vue-BhwNxZ68.js";var a=o(t=>`${e(t)}
|
|
2
|
+
.swimlane.cluster:not([data-color-id]) rect {
|
|
3
|
+
stroke: ${t.clusterBorder} !important;
|
|
4
|
+
}
|
|
5
|
+
[data-look="neo"].cluster rect {
|
|
6
|
+
filter: none;
|
|
7
|
+
}
|
|
8
|
+
`,"getStyles"),m=a,y=r({styles:m});export{y as diagram};
|