@az-zephyr/slate 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.en.md +107 -0
- package/README.md +106 -2
- package/bin/slate.mjs +226 -0
- package/dist/agent/chunk-BVWXAL54.js +3654 -0
- package/dist/agent/cli.js +6 -0
- package/dist/agent/multi.js +59 -0
- package/dist/api/001_initial.sql +127 -0
- package/dist/api/002_project_assistant.sql +24 -0
- package/dist/api/003_card_decisions.sql +20 -0
- package/dist/api/004_card_default_agent.sql +3 -0
- package/dist/api/005_card_attachments.sql +24 -0
- package/dist/api/006_comment_attachments.sql +7 -0
- package/dist/api/007_participant_last_outcome.sql +6 -0
- package/dist/api/008_output_attachments.sql +7 -0
- package/dist/api/009_card_agent_runs.sql +23 -0
- package/dist/api/server.js +4567 -0
- package/dist/api/server.js.map +1 -0
- package/dist/web/assets/abnfDiagram-XWFEHMT6-DmNFXSdi.js +1 -0
- package/dist/web/assets/architectureDiagram-CSQXQB3N-BTCN41JR.js +36 -0
- package/dist/web/assets/blockDiagram-BEDRHYPZ-BUJZDqr0.js +140 -0
- package/dist/web/assets/bpmnIcons-APHXDYXF-ByGoYv9M.js +1 -0
- package/dist/web/assets/c4Diagram-M2UUVUY5-CoTmMGy5.js +38 -0
- package/dist/web/assets/chunk-2Q5K7J3B-DN1oTl6j.js +1 -0
- package/dist/web/assets/chunk-3BJB4PZV-f0-m4Ag2.js +1 -0
- package/dist/web/assets/chunk-3GCGMST5-79GFiiwz.js +1 -0
- package/dist/web/assets/chunk-5VM5RSS4-D8XyNr_K.js +15 -0
- package/dist/web/assets/chunk-7U7NFRK5-CwjNfj8w.js +88 -0
- package/dist/web/assets/chunk-CNRTWJTD-CrX82YZ2.js +1 -0
- package/dist/web/assets/chunk-D5HYT7QG-DLlJaHjh.js +1 -0
- package/dist/web/assets/chunk-EBZ3SEQC-DYMBSe-a.js +2 -0
- package/dist/web/assets/chunk-JWPE2WC7-D7hN7LFG.js +1 -0
- package/dist/web/assets/chunk-KTR4FSNJ-DNqOwqFL.js +1 -0
- package/dist/web/assets/chunk-XXDRQBXY-ZgzK0pt4.js +1 -0
- package/dist/web/assets/classDiagram-v2-IZLYA2OM-CA7bnKxc.js +217 -0
- package/dist/web/assets/cose-bilkent-JH36ORCC-DOKkzmxA.js +1 -0
- package/dist/web/assets/cynefin-EF2NZ3EQ-C-bSVtsc.js +141 -0
- package/dist/web/assets/cynefinDiagram-NJNITYFG-C37MEEtf.js +62 -0
- package/dist/web/assets/cytoscape.esm-Bw5aGq32.js +332 -0
- package/dist/web/assets/d3-scale-4DPf7zan.js +1 -0
- package/dist/web/assets/dagre-KIHZ2IZ3-9ncwFAl9.js +4 -0
- package/dist/web/assets/diagram-7YQZDPLS-B5nOmdUq.js +41 -0
- package/dist/web/assets/diagram-QBROCOUO-C2R6lDiO.js +200 -0
- package/dist/web/assets/diagram-RJJCUUZO-C6CCweHA.js +30 -0
- package/dist/web/assets/diagram-WERXNKYE-BMvmqzmc.js +24 -0
- package/dist/web/assets/diagram-YHHI257C-mq9rFYCr.js +3 -0
- package/dist/web/assets/diagram-YR4HJLHV-GnLZxfuk.js +24 -0
- package/dist/web/assets/ebnfDiagram-N527522P-BD49AZHw.js +1 -0
- package/dist/web/assets/elk-O5DQBFGD-BPi3gK_q.js +27 -0
- package/dist/web/assets/erDiagram-GT5GOJPG-v00zB8rw.js +99 -0
- package/dist/web/assets/flowDiagram-JAYNFW54-DIf4aoDB.js +213 -0
- package/dist/web/assets/ganttDiagram-3PRQTZWP-DRl_shHP.js +292 -0
- package/dist/web/assets/gitGraphDiagram-VXDFKS5L-2RrHppJt.js +106 -0
- package/dist/web/assets/graph-Bn3Yngep.js +1 -0
- package/dist/web/assets/grid-E2QIVN74-BuI-3sqA.js +1 -0
- package/dist/web/assets/index-5BTf4y0R.css +1 -0
- package/dist/web/assets/index-CtfDl2Kw.js +358 -0
- package/dist/web/assets/infoDiagram-ATMJ4U3S-afgUHtXU.js +2 -0
- package/dist/web/assets/ishikawaDiagram-S3EKX5GW-BsIUfApm.js +70 -0
- package/dist/web/assets/journeyDiagram-POQNLL5X-BM1Liuxy.js +139 -0
- package/dist/web/assets/kanban-definition-BH5XI6FM-Bz439vDv.js +89 -0
- package/dist/web/assets/katex-Be3d8Y4U.js +257 -0
- package/dist/web/assets/mermaid.core-CDkqDmQh.js +314 -0
- package/dist/web/assets/mindmap-definition-WVAN44T4-DcgvDd37.js +98 -0
- package/dist/web/assets/pegDiagram-D4NLKWP3-Bs1FcfRL.js +1 -0
- package/dist/web/assets/pieDiagram-36ENHN4W-CX3-kIFy.js +39 -0
- package/dist/web/assets/quadrantDiagram-ZQUDMS73-CrSg-66H.js +7 -0
- package/dist/web/assets/railroadDiagram-JIZHGYPL-DBm7mKc_.js +1 -0
- package/dist/web/assets/render-VIF2ZAQL-CjnzRbOQ.js +2 -0
- package/dist/web/assets/requirementDiagram-AXW2TVFA--vkT5OaJ.js +84 -0
- package/dist/web/assets/sankeyDiagram-FBCJTAIF-CXyuNpgP.js +40 -0
- package/dist/web/assets/sequenceDiagram-3LA2ROMG-Cfn5c7T5.js +169 -0
- package/dist/web/assets/sizeCapture-2Q2CQKSF-CQJexuw3.js +1 -0
- package/dist/web/assets/stateDiagram-v2-XZFR63ZJ-W23Y_4Yd.js +291 -0
- package/dist/web/assets/swimlanes-YQL5WMAO-B8ymV9uv.js +1 -0
- package/dist/web/assets/swimlanesDiagram-BA3ZWDFA-ClHf-9J2.js +8 -0
- package/dist/web/assets/timeline-definition-7Z437IG3-BElgSf_v.js +120 -0
- package/dist/web/assets/usecaseDiagram-RDK6N6HP-BfopeYcl.js +370 -0
- package/dist/web/assets/vennDiagram-SHRQU5PJ-034PLwGh.js +34 -0
- package/dist/web/assets/wardleyDiagram-F3OXNVQS-Cmiyei3a.js +78 -0
- package/dist/web/assets/xychartDiagram-GDYJKCDI-DxF4glgl.js +7 -0
- package/dist/web/index.html +13 -0
- package/package.json +42 -4
- package/scripts/git-worktree.mjs +63 -0
- package/scripts/slate-cli.mjs +851 -0
- package/skills/slate-card/SKILL.md +109 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as Si,a as vi}from"./chunk-3GCGMST5-79GFiiwz.js";import{c as Ci}from"./chunk-EBZ3SEQC-DYMBSe-a.js";import{_ as c,l as qe}from"./mermaid.core-CDkqDmQh.js";import"./index-CtfDl2Kw.js";import"./graph-Bn3Yngep.js";function cs(t,{measure:e}){var s,r;const n=Si((r=(s=t.config)==null?void 0:s.swimlane)==null?void 0:r.lineHops);if(n===!1)return;const o=t.edges.filter(i=>Array.isArray(i.points)&&i.points.length>=2).map(i=>({id:i.id,points:i.points,curve:i.curve,cornerRadius:i.cornerRadius,arrowTypeStart:i.arrowTypeStart,arrowTypeEnd:i.arrowTypeEnd}));vi(e.groups.edgePaths,o,{enabled:!0,jumpRadius:6,jumpStyle:n})}c(cs,"applySwimlaneLineJumps");function as(t){var n;const e=(n=t==null?void 0:t.metadata)==null?void 0:n.laneRole;return e==="pool"||e==="lane"?e:void 0}c(as,"readLaneRole");function dn(t){var n;const e=(n=t==null?void 0:t.metadata)==null?void 0:n.laneIndex;return typeof e=="number"&&Number.isFinite(e)?e:void 0}c(dn,"readLaneIndex");function Ce(t){const e=new Map,n=new Map;for(const d of t)e.set(d.id,d),d.isGroup&&d.parentId&&n.set(d.parentId,(n.get(d.parentId)??0)+1);const o=new Set;for(const d of t)d.isGroup&&as(d)==="pool"&&(n.get(d.id)??0)>0&&o.add(d.id);const s=new Set,r=new Map;for(const d of t)if(!(!d.isGroup||o.has(d.id)))if(d.parentId&&o.has(d.parentId)){s.add(d.id);const b=r.get(d.parentId)??[];b.push(d.id),r.set(d.parentId,b)}else d.parentId||s.add(d.id);const i=c((d,b)=>{var p,y;const l=new Set([d]);let I=(p=e.get(d))==null?void 0:p.parentId;for(;I&&!l.has(I);){if(b.has(I))return I;l.add(I),I=(y=e.get(I))==null?void 0:y.parentId}return null},"walk"),a=new Map;return{isPool:c(d=>o.has(d),"isPool"),isLane:c(d=>s.has(d),"isLane"),laneIdOf:c(d=>{const b=a.get(d);if(b!==void 0)return b;const l=i(d,s);return a.set(d,l),l},"laneIdOf"),poolIdOf:c(d=>o.has(d)?d:i(d,o),"poolIdOf"),lanesByPool:r,hasPools:o.size>0}}c(Ce,"buildLaneModel");var Li=new Set(["top","right","bottom","left"]),$n=8,wi=1e4;function Ze(t){var i;const e=(i=t==null?void 0:t.metadata)==null?void 0:i.anchorTo;if(!e||typeof e!="object")return;const{hostId:n,side:o,slot:s,gap:r}=e;if(!(typeof n!="string"||n.length===0||n===(t==null?void 0:t.id)))return{hostId:n,...typeof o=="string"&&Li.has(o)?{side:o}:{},...typeof s=="number"&&Number.isFinite(s)?{slot:s}:{},...typeof r=="number"&&Number.isFinite(r)&&r>0?{gap:Math.min(r,wi)}:{}}}c(Ze,"readAnchor");function wn(t,e){var s,r;const n=new Set([t]);let o=(s=Ze(e.get(t)))==null?void 0:s.hostId;for(;o&&!n.has(o);){const i=e.get(o);if(!i)return;const a=(r=Ze(i))==null?void 0:r.hostId;if(!a)return o;n.add(o),o=a}}c(wn,"resolveAnchorHostId");function We(t){const e=new Map(t.map(o=>[o.id,o])),n=new Set;for(const o of t)Ze(o)&&wn(o.id,e)&&n.add(o.id);return n}c(We,"collectAnchoredIds");function ls(t,e){return t==="canonical"?"right":e==="LR"||e==="RL"?"bottom":"right"}c(ls,"defaultAnchorSide");function fs(t,e){const n=t.anchor.slot,o=e.anchor.slot;return n!==void 0&&o!==void 0&&n!==o?n-o:n!==void 0&&o===void 0?-1:n===void 0&&o!==void 0?1:t.index-e.index}c(fs,"compareBucketEntries");function ds(t){const e=t.reduce((s,r)=>s+r,0)+$n*Math.max(0,t.length-1),n=[];let o=-e/2;for(const s of t)n.push(o+s/2),o+=s+$n;return{offsets:n,total:e}}c(ds,"packAlongBorder");var Ai=c(t=>[t.width,t.height].every(e=>e===void 0||Number.isFinite(e)),"hasUsableSize");function us(t,e){const n=new Map(t.map(s=>[s.id,s])),o=new Map;t.forEach((s,r)=>{const i=Ze(s);if(!i||!Ai(s))return;const a=wn(s.id,n);if(!a)return;const f=e(i),d=`${f}:${a}`,b=o.get(d)??[];b.push({node:s,anchor:i,index:r,side:f,hostId:a}),o.set(d,b)});for(const s of o.values())s.sort(fs);return o}c(us,"bucketByHostAndSide");function hs(t,e,n,o){const s=!e&&n>0?-(o+$n):0;return t+s}c(hs,"centreAlongBorder");function gs(t,e){const n=e==="top"||e==="bottom",o=c(d=>n?d.width??0:d.height??0,"alongBorder"),s=c(d=>n?d.height??0:d.width??0,"reach"),{offsets:r}=ds(t.map(d=>o(d.node)));let i=0,a=0,f=0;return t.forEach((d,b)=>{const l=d.anchor.gap??0,I=o(d.node)/2,p=hs(r[b],n,l,I);i=Math.max(i,I-p),a=Math.max(a,p+I),f=Math.max(f,l>0?l+s(d.node):0)}),{before:i,after:a,beyond:f}}c(gs,"footprintOf");function ms(t,e){const n=ls("final",e??"TB"),o=new Map;for(const s of us(t,r=>r.side??n).values()){if(!s.some(a=>a.anchor.gap))continue;const{hostId:r,side:i}=s[0];o.set(r,{...o.get(r),[i]:gs(s,i)})}return o}c(ms,"anchorFootprints");var Dn="__swimlane_default__",Ei=21,es=20;function Vn(t){return Math.max(t.padding??es,es)}c(Vn,"topLaneHorizontalPadding");function ps(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 i=n-s/2,a=Math.min(r,n+s/2),f=Math.min(Ei,Math.max(0,a-i)),d=i+f;if(d<=i){delete t.groupTitleRect;return}t.groupTitleRect={left:e-o/2,right:e+o/2,top:i,bottom:d}}c(ps,"assignTopLaneTitleRect");function ys(t){var n;const e=(n=t.other)==null?void 0:n.droppedSubGraphMembers;return Array.isArray(e)?e:[]}c(ys,"sharedMembers");var Ti=c((t,e,n)=>!e.some(o=>o.parentId===n)&&!(t.edges??[]).some(o=>o.start===n||o.end===n),"isEmptyLane");function xs(t,e){return t.isLane(e)?e:t.laneIdOf(e)??void 0}c(xs,"laneIdOrSelf");function bs(t,e,n){for(const o of n){const s=e.findIndex(r=>r.id===o);s>=0&&Ti(t,e,o)&&e.splice(s,1)}}c(bs,"removeEmptyLanes");function Is(t,e){const n=Ce(e),o=new Set(e.filter(r=>n.isLane(r.id)).map(r=>r.id)),s=new Set;for(const{node:r,keptBy:i,droppedFrom:a}of ys(t)){const f=xs(n,i);f&&f!==a&&o.has(a)&&(qe.warn(`Swimlane node "${r}" is listed in lanes "${f}" and "${a}"; it is drawn in "${f}" only.`),s.add(a))}bs(t,e,s)}c(Is,"dropLanesEmptiedBySharedNodes");function Ms(t,e){for(const n of t)n.isGroup&&!e.isLane(n.id)&&!e.isPool(n.id)&&qe.warn(`Swimlane subgraph "${n.id}" is nested in "${n.parentId}"; only top-level subgraphs are lanes, so it is drawn as a plain box.`)}c(Ms,"warnAboutNestedGroups");function Ss(t){var i;const e=t.direction,n=t.nodes??(t.nodes=[]);Is(t,n);const o=Ce(n);Ms(n,o);for(const a of n){const f=o.isLane(a.id);!f&&!o.isPool(a.id)||(a.shape=f?"swimlane":"pool",e&&(a.direction=e))}const s=n.filter(a=>!a.isGroup&&!a.parentId);if(s.length===0)return;let r=n.find(a=>a.id===Dn);r?r.isGroup&&(r.shape="swimlane",e&&(r.direction=e)):(r={id:Dn,label:"",isGroup:!0,shape:"swimlane",padding:20,look:(i=t.config)==null?void 0:i.look,colorIndex:n.reduce((a,f)=>Math.max(a,f.colorIndex??-1),-1)+1,...e?{direction:e}:{}},n.push(r));for(const a of s)a.parentId=Dn}c(Ss,"prepareLayoutForSwimlanes");function vs(t){const e=(t.nodes??[]).filter(l=>!l.isEdgeLabel),n=new Map(e.map(l=>[l.id,l])),o=We(e),s=c(l=>o.has(l)?wn(l,n)??l:l,"hostOf"),r=new Map;for(const l of e)o.has(l.id)||r.set(l.id,l);const i=[];for(const l of t.edges??[]){const I=typeof l.start=="string"?l.start:void 0,p=typeof l.end=="string"?l.end:void 0;if(!I||!p||l.isLayoutOnly)continue;const y=s(I),h=s(p);y!==h&&i.push({id:l.id,src:y,dst:h,ref:l})}const a=e.filter(l=>l.isGroup&&!o.has(l.id)),f=e.filter(l=>!l.isGroup&&!o.has(l.id));return{nodes:[...[...a].reverse(),...f].map(l=>l.id),edges:i,layout:t,nodeById:r}}c(vs,"toGraphView");function Cs(t){const e=new Map(t.map(o=>[o.id,o])),n=c(o=>{var a;let s=0,r=o.parentId;const i=new Set([o.id]);for(;r!=null&&!i.has(r);)i.add(r),s++,r=(a=e.get(r))==null?void 0:a.parentId;return s},"depthOf");return t.filter(o=>o==null?void 0:o.isGroup).map(o=>({node:o,depth:n(o)})).sort((o,s)=>s.depth-o.depth).map(o=>o.node)}c(Cs,"groupsDeepestFirst");function Ls(t,e,n,o){const{layout:s}=t,r=t.nodeById,i=(o==null?void 0:o.layerGap)??100,a=(o==null?void 0:o.nodeGap)??40;let f=0;for(const y of e.layers){let h=0;for(const x of y){const L=r.get(x);if(!L){h++;continue}L.layer=f,L.order=h;const u=n.x[x]??h*a,v=n.y[x]??f*i;L.x=u,L.y=v,h++}f++}const d=s.nodes??[],b=We(d);for(const y of d)y.isEdgeLabel&&n.x[y.id]!=null&&n.y[y.id]!=null&&(y.x=n.x[y.id],y.y=n.y[y.id]);const l=new Map,I=Ce(d),p=[];for(const y of Cs(d)){I.isLane(y.id)&&p.push(y);const h=d.filter(S=>S.parentId===y.id&&!b.has(S.id));let x=1/0,L=-1/0,u=1/0,v=-1/0;for(const S of h){const m=S.x??n.x[S.id],M=S.y??n.y[S.id],w=S.width??0,A=S.height??0;m!=null&&M!=null&&(S.isEdgeLabel||(x=Math.min(x,m-w/2),L=Math.max(L,m+w/2)),u=Math.min(u,M-A/2),v=Math.max(v,M+A/2))}if(x===1/0||u===1/0)y.x=y.x??0,y.y=y.y??0,y.width=y.width??0,y.height=y.height??0;else{const S=y.padding??20,m=y.parentId?S:2*Vn(y),M=S,w=Math.max(0,L-x)+m,A=Math.max(0,v-u)+M,B=(x+L)/2,P=(u+v)/2;y.x=B,y.y=P,y.width=w,y.height=A,l.set(y.id,{minX:x,maxX:L,minY:u,maxY:v})}}if(p.length>0&&l.size>0){let y=1/0,h=-1/0,x=0;for(const L of p){const u=L.padding??20;u>x&&(x=u);const v=l.get(L.id);v&&(y=Math.min(y,v.minY),h=Math.max(h,v.maxY))}if(y!==1/0&&h!==-1/0){const L=Math.max(0,h-y),v=Math.max(x,36),S=L+2*v,m=(y+h)/2;for(const E of p)E.y=m,E.height=S,E.swimlaneContentTop=y;const M=[...p].sort((E,k)=>{const Y=E.x??0,W=k.x??0;return Y-W}),w=[],A=[],B=[];for(const E of M){const k=l.get(E.id);if(!k)continue;const Y=Math.max(0,k.maxX-k.minX)+2*Vn(E),W=(k.minX+k.maxX)/2;w.push(E.id),A.push(W),B.push(Y)}const P=w.length;if(P>0){const E=new Map;if(P===1)E.set(w[0],B[0]);else{const k=[];for(let it=0;it<P-1;it++)k.push(A[it+1]-A[it]);const Y=new Array(P);Y[0]=0;for(let it=0;it<P-1;it++)Y[it+1]=2*k[it]-Y[it];let W=0,z=Number.POSITIVE_INFINITY;for(let it=0;it<P;it++){const bt=B[it];it%2===0?W=Math.max(W,bt-Y[it]):z=Math.min(z,Y[it]-bt)}let Q=W;W<=z?Q=(W+z)/2:Q=W;for(let it=0;it<P;it++){const bt=Y[it]+(it%2===0?Q:-Q),ne=Math.max(B[it],bt);E.set(w[it],ne)}}for(const k of p){const Y=E.get(k.id);Y!=null&&(k.width=Y),ps(k)}}}}}c(Ls,"writeBackToLayoutData");var Ri="[EdgeLabelNodes]";function ws(t){const e=[],n=[],o=new Map;for(const i of t.nodes)o.set(i.id,i);for(const i of t.edges){if(!i.label||i.label.length===0||i.isLayoutOnly||i.labelNodeId)continue;const a=i.start?o.get(i.start):void 0,f=i.end?o.get(i.end):void 0;if(!a||!f){qe.warn(Ri,`Edge ${i.id} has missing source or target node`);continue}const d=`edge-label-${i.start}-${i.end}-${i.id}`,l=a.parentId!==f.parentId?f.parentId:a.parentId,I={id:d,label:i.label,edgeStart:i.start??"",edgeEnd:i.end??"",shape:"labelRect",width:0,height:0,isEdgeLabel:!0,isDummy:!0,parentId:l,isGroup:!1,labelStyle:Array.isArray(i.labelStyle)?i.labelStyle[0]:i.labelStyle??"",...a.dir?{dir:a.dir}:{}};e.push(I),i.labelNodeId=d,i.label=void 0,i.text=void 0;const p={id:`${i.id}-to-label`,start:i.start,end:d,type:"normal",isLayoutOnly:!0},y={id:`${i.id}-from-label`,start:d,end:i.end,type:"normal",isLayoutOnly:!0};n.push(p,y)}const s=[...t.nodes,...e],r=[...t.edges,...n];return{...t,nodes:s,edges:r}}c(ws,"createEdgeLabelNodes");var te=.001;function Ao(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:Ue(e,n,o,s)}:void 0}c(Ao,"measuredNodeRect");function Eo(t){if(t.isGroup)return;const e=Ao(t);return e?{id:String(t.id??""),cx:e.cx,cy:e.cy,rect:e.rect}:void 0}c(Eo,"nodeBoundsInfoFor");function Me(t,e,n=te){return Math.abs(t.x-e.x)<n&&Math.abs(t.y-e.y)<n}c(Me,"samePoint");function vt(t,e,n=te){return Math.abs(t.x-e.x)<n}c(vt,"sameX");function At(t,e,n=te){return Math.abs(t.y-e.y)<n}c(At,"sameY");function zt(t,e,n=te){return At(t,e,n)&&Math.abs(t.x-e.x)>n}c(zt,"isHorizontalSegment");function $t(t,e,n=te){return vt(t,e,n)&&Math.abs(t.y-e.y)>n}c($t,"isVerticalSegment");function fe(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)))}c(fe,"overlapLength");function Ae(t,e,n=te){return t.horizontal&&e.horizontal&&At(t.a,e.a,n)?fe(t.a.x,t.b.x,e.a.x,e.b.x):t.vertical&&e.vertical&&vt(t.a,e.a,n)?fe(t.a.y,t.b.y,e.a.y,e.b.y):0}c(Ae,"sameAxisSegmentOverlapLength");function ye(t,e=te){const n=[];for(let o=0;o<t.length-1;o++){const s=t[o],r=t[o+1],i=zt(s,r,e),a=$t(s,r,e);(i||a)&&n.push({index:o,a:s,b:r,horizontal:i,vertical:a})}return n}c(ye,"orthogonalSegmentsForPoints");function pe(t,e=te){const n=ye(t,e);let o=0;for(let s=1;s<n.length;s++)n[s-1].horizontal!==n[s].horizontal&&o++;return o}c(pe,"countOrthogonalBends");function As(t){const e=ye(Mt(t));return e.slice(1).flatMap((n,o)=>e[o].horizontal===n.horizontal?[]:[n.a])}c(As,"bendPoints");function Es(t,e){const n=Math.max(Math.min(e.a.x,e.b.x)-t.x,0,t.x-Math.max(e.a.x,e.b.x)),o=Math.max(Math.min(e.a.y,e.b.y)-t.y,0,t.y-Math.max(e.a.y,e.b.y));return Math.hypot(n,o)}c(Es,"distanceToSegment");function gn(t,e,n){const o=c((s,r)=>{const i=ye(Mt(r));return As(s).some(a=>i.some(f=>Es(a,f)<n))},"touches");return o(t,e)||o(e,t)}c(gn,"routesTouchAtBend");function Mt(t,e=te){const n=[];for(const o of t){const s=n.length>0?n[n.length-1]:void 0;(!s||!Me(s,o,e))&&n.push({x:o.x,y:o.y})}return n}c(Mt,"dedupeConsecutivePoints");function To(t,e=te){if(!t||t.length!==4)return;const[n,o,s,r]=t;return zt(n,o,e)&&$t(o,s,e)&&zt(s,r,e)?{kind:"HVH",p0:n,p1:o,p2:s,p3:r}:$t(n,o,e)&&zt(o,s,e)&&$t(s,r,e)?{kind:"VHV",p0:n,p1:o,p2:s,p3:r}:void 0}c(To,"classifyThreeSegmentRoute");function An(t,e,n,o=0){const s=Math.min(t.x,e.x),r=Math.max(t.x,e.x),i=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&&i<n.bottom+o}c(An,"segmentBoundsOverlapRect");function Ro(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}c(Ro,"pointInsideRect");function Ts(t,e){return t.left<=e.left&&t.right>=e.right&&t.top<=e.top&&t.bottom>=e.bottom}c(Ts,"rectContainsRect");function mn(t,e){return t.left<e.right&&t.right>e.left&&t.top<e.bottom&&t.bottom>e.top}c(mn,"rectsOverlap");function Un(t,e){return{left:t.left-e,right:t.right+e,top:t.top-e,bottom:t.bottom+e}}c(Un,"inflateRect");function Ue(t,e,n,o){return{left:t-n/2,right:t+n/2,top:e-o/2,bottom:e+o/2}}c(Ue,"rectFromCenterSize");function ce(t){var e;return(e=Ao(t))==null?void 0:e.rect}c(ce,"rectOfNodeBounds");function Ge(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}}}c(Ge,"portForRectSide");function Oo(t,e,n,o,s,r=te){const i=e==="left"||e==="right",a=o==="left"||o==="right";if(i&&a){if(e==="right"&&o==="left"&&t.x<n.x||e==="left"&&o==="right"&&t.x>n.x){if(At(t,n,r))return[t,n];const l=(t.x+n.x)/2;return[t,{x:l,y:t.y},{x:l,y:n.y},n]}if(e===o){if(At(t,n,r))return;const l=e==="left"?Math.min(t.x,n.x)-s:Math.max(t.x,n.x)+s;return[t,{x:l,y:t.y},{x:l,y:n.y},n]}return}if(!i&&!a){if(e===o){if(vt(t,n,r))return;const I=e==="top"?Math.min(t.y,n.y)-s:Math.max(t.y,n.y)+s;return[t,{x:t.x,y:I},{x:n.x,y:I},n]}if(!(e==="bottom"&&o==="top"&&t.y<n.y||e==="top"&&o==="bottom"&&t.y>n.y))return;if(vt(t,n,r))return[t,n];const l=(t.y+n.y)/2;return[t,{x:t.x,y:l},{x:n.x,y:l},n]}if(i&&!a){const b=e==="right"&&n.x>t.x||e==="left"&&n.x<t.x,l=o==="top"&&t.y<n.y||o==="bottom"&&t.y>n.y;return b&&l?[t,{x:n.x,y:t.y},n]:void 0}const f=e==="bottom"&&n.y>t.y||e==="top"&&n.y<t.y,d=o==="left"&&t.x<n.x||o==="right"&&t.x>n.x;return f&&d?[t,{x:t.x,y:n.y},n]:void 0}c(Oo,"buildOrthogonalPortPath");function No(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]}c(No,"buildSameSideTrackPath");function En(t){const e=new Map,n=[];for(const o of t){if(o.isEdgeLabel)continue;const s=Eo(o);s&&(e.set(s.id,s),n.push({id:s.id,rect:s.rect}))}return{nodeInfoById:e,realNodeRects:n}}c(En,"collectRealNodeBounds");function Ee(t){const e=[],n=[];for(const o of t){const s=Eo(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}}c(Ee,"collectNodeRectEntries");function Rs(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,i=o.width??0,a=o.height??0;n.push({nodeId:o.id,...Ue(s,r,i,a)})}return n}c(Rs,"collectLayoutNodeRects");function Bo(t,e,n=te){const o=t.start,s=t.end;if(!o||!s)return;const r=e.get(o),i=e.get(s);if(!(!r||!i))return{srcId:o,dstId:s,srcInfo:r,dstInfo:i,collinearX:Math.abs(r.cx-i.cx)<n,collinearY:Math.abs(r.cy-i.cy)<n}}c(Bo,"getNodePairGeometry");function Dt(t,e,n,o=[],s=0){for(const r of n)if(!o.includes(r.id)&&An(t,e,r.rect,-s))return!0;return!1}c(Dt,"segmentHitsAnyRect");function Po(t,e,n,o,s=te,r=1e-6){const i=At(t,e,s),a=vt(t,e,s),f=At(n,o,s),d=vt(n,o,s);if(i&&f||a&&d||!(i||a)||!(f||d))return!1;const b=i?{a:t,b:e}:{a:n,b:o},l=a?{a:t,b:e}:{a:n,b:o},I=b.a.y,p=Math.min(b.a.x,b.b.x),y=Math.max(b.a.x,b.b.x),h=l.a.x,x=Math.min(l.a.y,l.b.y),L=Math.max(l.a.y,l.b.y);if(h<p||h>y||I<x||I>L)return!1;const u=Math.abs(h-b.a.x)<r&&Math.abs(I-b.a.y)<r||Math.abs(h-b.b.x)<r&&Math.abs(I-b.b.y)<r,v=Math.abs(h-l.a.x)<r&&Math.abs(I-l.a.y)<r||Math.abs(h-l.b.x)<r&&Math.abs(I-l.b.y)<r;return!(u&&v)}c(Po,"orthogonalSegmentsCross");function Fo(t,e,n,o,s=te){const r=At(t,e,s),i=vt(t,e,s),a=At(n,o,s),f=vt(n,o,s);return i&&f&&vt(t,n,s)?fe(t.y,e.y,n.y,o.y)>s:r&&a&&At(t,n,s)?fe(t.x,e.x,n.x,o.x)>s:!1}c(Fo,"sameAxisSegmentsOverlap");function pn(t,e,n,o,{epsilon:s=te,skipDegenerateOther:r=!1}={}){for(const i of n){if(i===o||i.isLayoutOnly)continue;const a=i.points;if(!(!a||a.length<2))for(let f=0;f<a.length-1;f++){const d=a[f],b=a[f+1];if(!(r&&Me(d,b,s))&&(Po(t,e,d,b,s)||Fo(t,e,d,b,s)))return!0}}return!1}c(pn,"segmentConflictsWithAnyEdge");function Te(t,e,n,o,s=te){const r=At(t,e,s),i=vt(t,e,s),a=At(n,o,s),f=vt(n,o,s);if(!(r&&f||i&&a))return!1;const d=r?{a:t,b:e}:{a:n,b:o},b=r?{a:n,b:o}:{a:t,b:e},l=d.a.y,I=Math.min(d.a.x,d.b.x),p=Math.max(d.a.x,d.b.x),y=b.a.x,h=Math.min(b.a.y,b.b.y),x=Math.max(b.a.y,b.b.y);return y>I+s&&y<p-s&&l>h+s&&l<x-s}c(Te,"orthogonalSegmentsStrictlyCross");function jn(t,e,n){const o=Math.min(e,n),s=Math.max(e,n);return t>o+te&&t<s-te}c(jn,"strictlyBetween");function Os(t,e,n){return vt(t,e)&&vt(e,n)?jn(e.y,t.y,n.y):At(t,e)&&At(e,n)?jn(e.x,t.x,n.x):!1}c(Os,"isCollinearIntermediate");function Ns(t){let e=!1;const n=[];for(let o=0;o<t.length;o++){const s=n[n.length-1],r=t[o],i=o+1<t.length?t[o+1]:void 0;if(s&&i){if(Me(s,i)){o++,e=!0;continue}if(Os(s,r,i)){e=!0;continue}}n.push(r)}return{points:n,changed:e}}c(Ns,"simplifyPolylineOnce");function yn(t){const e=[t[0]];for(let o=1;o<t.length;o++){const s=e[e.length-1],r=t[o];if(!vt(s,r)&&!At(s,r)){const i=e.length>=2?e[e.length-2]:void 0,f=(i?vt(i,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||!Me(s,o))&&n.push(o)}return n}c(yn,"orthogonalizePolyline");function ve(t){if(t.length<3)return t;let e=[...t];for(let n=0;n<32;n++){const o=Ns(e);if(e=o.points,!o.changed)break}return e}c(ve,"simplifyPolyline");var ut=.001,Oi=.5,Wn=4;function ko(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?ce(s):void 0,dstRect:r?ce(r):void 0}}c(ko,"endpointContextFor");function Bs(t,e,n){if(At(t,e,ut))return{x:t.x<n.left?n.left:n.right,y:t.y};if(vt(t,e,ut)){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))}}c(Bs,"segmentEnterPoint");function Kn(t,e,n){const o=n?1:-1;let s=n?0:t.length-1;for(;s>=0&&s<t.length&&Ro(t[s],e,Oi);)s+=o;if(s<0||s>=t.length)return t;const r=s-o;if(r<0||r>=t.length)return t;const i=Bs(t[s],t[r],e);return n?[i,...t.slice(s)]:[...t.slice(0,s+1),i]}c(Kn,"clipEndpoint");function Ps(t,e){for(const n of t){const o=ko(n,e,2);if(!o)continue;let s=[...o.points];o.srcRect&&(s=Kn(s,o.srcRect,!0)),o.dstRect&&(s=Kn(s,o.dstRect,!1)),s=ve(yn(s)),s=_o(s,o.srcRect,o.dstRect),o.edge.points=ve(yn(s))}}c(Ps,"clipEdgeEndpointsToNodeBoundaries");function qn(t,e,n,o=!1){if(At(t,e,ut)){if(e.y<n.top-ut||e.y>n.bottom+ut)return e;if(o){if(t.x<n.left-ut)return{x:n.left,y:t.y};if(t.x>n.right+ut)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(vt(t,e,ut)){if(e.x<n.left-ut||e.x>n.right+ut)return e;if(o){if(t.y<n.top-ut)return{x:t.x,y:n.top};if(t.y>n.bottom+ut)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}c(qn,"snapEndpointToBoundary");function xn(t,e,n){const o=t[e];for(let s=e+n;s>=0&&s<t.length;s+=n){const r=t[s];if(!Me(r,o,ut))return r}return t[e+n]}c(xn,"firstDistinctAdjacent");function bn(t,e){const n=t+Wn,o=e-Wn;return n<=o?{lo:n,hi:o}:{lo:(t+e)/2,hi:(t+e)/2}}c(bn,"cornerClearanceRange");function Zn(t,e,n){const{lo:o,hi:s}=bn(e,n);return Math.min(s,Math.max(o,t))}c(Zn,"clampToCornerClearance");function Fs(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}}c(Fs,"intersectRanges");function Jn(t,e){return e==="left"||e==="right"?bn(t.top,t.bottom):bn(t.left,t.right)}c(Jn,"clearanceRangeForSide");function In(t,e,n){const o=t.y>=n.top-ut&&t.y<=n.bottom+ut,s=t.x>=n.left-ut&&t.x<=n.right+ut;if(At(t,e,ut)&&o){if(Math.abs(t.x-n.left)<ut)return"left";if(Math.abs(t.x-n.right)<ut)return"right"}if(vt(t,e,ut)&&s){if(Math.abs(t.y-n.top)<ut)return"top";if(Math.abs(t.y-n.bottom)<ut)return"bottom"}}c(In,"terminalSideForSegment");function Je(t){return t==="left"||t==="right"}c(Je,"isHorizontalSide");function ks(t,e,n,o,s){const r=[],i=n?In(t,e,n):void 0,a=o?In(e,t,o):void 0;return n&&i&&Je(i)===s&&r.push(Jn(n,i)),o&&a&&Je(a)===s&&r.push(Jn(o,a)),r.length>0?Fs(r):void 0}c(ks,"straightClearanceRange");function Qn(t,e,n,o,s){const r=ks(t,e,n,o,s);if(!r)return;const i=s?t.y:t.x,a=Math.min(r.hi,Math.max(r.lo,i));if(!(Math.abs(a-i)<ut))return s?[{x:t.x,y:a},{x:e.x,y:a}]:[{x:a,y:t.y},{x:a,y:e.y}]}c(Qn,"clearStraightEndpointCornerAxis");function _o(t,e,n){if(t.length!==2)return t;const[o,s]=t;return At(o,s,ut)?Qn(o,s,e,n,!0)??t:vt(o,s,ut)?Qn(o,s,e,n,!1)??t:t}c(_o,"clearStraightEndpointCornerConnections");function _s(t,e,n){return Je(n)?{x:t.x,y:Zn(t.y,e.top,e.bottom)}:{x:Zn(t.x,e.left,e.right),y:t.y}}c(_s,"cornerClearedEndpoint");function Hs(t,e,n,o,s,r){const i=t.map(a=>({...a}));for(let a=e;a>=0&&a<t.length;a+=n){const f=t[a];if(r&&!At(f,o,ut)||!r&&!vt(f,o,ut))break;r?i[a].y=s.y:i[a].x=s.x}return i}c(Hs,"moveCollinearEndpointRun");function to(t,e,n){if(t.length<2)return t;const o=n?0:t.length-1,s=n?1:-1,r=t[o],i=xn(t,o,s);if(!i)return t;const a=In(r,i,e);if(!a)return t;const f=Je(a),d=_s(r,e,a);return Me(r,d,ut)?t:Hs(t,o,s,r,d,f)}c(to,"clearEndpointCornerConnection");function eo(t,e,n){const o=Math.min(t.x,e.x)>=n.left-ut&&Math.max(t.x,e.x)<=n.right+ut,s=Math.min(t.y,e.y)>=n.top-ut&&Math.max(t.y,e.y)<=n.bottom+ut;if(Math.abs(t.y-n.top)<ut&&Math.abs(e.y-n.top)<ut&&o)return"top";if(Math.abs(t.y-n.bottom)<ut&&Math.abs(e.y-n.bottom)<ut&&o)return"bottom";if(Math.abs(t.x-n.left)<ut&&Math.abs(e.x-n.left)<ut&&s)return"left";if(Math.abs(t.x-n.right)<ut&&Math.abs(e.x-n.right)<ut&&s)return"right"}c(eo,"borderSideForSegment");function no(t,e,n,o){switch(t){case"top":return vt(e,n,ut)&&n.y<o.top-ut;case"bottom":return vt(e,n,ut)&&n.y>o.bottom+ut;case"left":return At(e,n,ut)&&n.x<o.left-ut;case"right":return At(e,n,ut)&&n.x>o.right+ut}}c(no,"leavesOutward");function oo(t,e,n){if(t.length<3)return t;if(n){const r=eo(t[0],t[1],e);return r&&no(r,t[1],t[2],e)?t.slice(1):t}const o=t.length-1,s=eo(t[o-1],t[o],e);return s&&no(s,t[o-1],t[o-2],e)?t.slice(0,o):t}c(oo,"collapseOwnBorderStub");function Ds(t,e,n){let o=t;if(e){const r=xn(o,0,1);if(r){const i=qn(r,o[0],e);i!==o[0]&&(o=[i,...o.slice(1)])}o=oo(o,e,!0)}if(n){const r=o.length-1,i=xn(o,r,-1);if(i){const a=qn(i,o[r],n,!0);a!==o[r]&&(o=[...o.slice(0,r),a])}o=oo(o,n,!1)}const s=_o(o,e,n);return s!==o||o.length===2?s:(e&&(o=to(o,e,!0)),n&&(o=to(o,n,!1)),o)}c(Ds,"snapAndCollapseEndpoints");function Mn(t,e){for(const n of t){const o=ko(n,e,2);if(!o)continue;const s=Mt(o.points,ut),r=Ds(s,o.srcRect,o.dstRect);if(r.length<3){o.edge.points=r;continue}const i=[r[0],{...r[0]},...r.slice(1,-1),r[r.length-1],{...r[r.length-1]}];o.edge.points=i}}c(Mn,"prepareEdgeEndpointsForRenderer");function Xs(t){return new Map(t.map(e=>[e.id,e]))}c(Xs,"buildNodeMap");function so(t,e){const n=new Set([t.id]);let o=0,s=t.parentId;for(;s&&!n.has(s);){const r=e.get(s);if(!(r!=null&&r.isGroup))break;n.add(s),o++,s=r.parentId}return o}c(so,"groupDepth");function Ho(t){let e=1/0,n=-1/0,o=1/0,s=-1/0;for(const r of t){const i=r.x,a=r.y;if(typeof i!="number"||typeof a!="number")continue;const f=r.width??0,d=r.height??0;e=Math.min(e,i-f/2),n=Math.max(n,i+f/2),o=Math.min(o,a-d/2),s=Math.max(s,a+d/2)}return e===1/0||o===1/0?null:{minX:e,maxX:n,minY:o,maxY:s}}c(Ho,"boundsForChildren");function Gs(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}c(Gs,"applyGroupBounds");function Ys(t){const e=Xs(t),n=t.filter(o=>o.isGroup&&o.parentId).sort((o,s)=>so(s,e)-so(o,e));for(const o of n){const s=t.filter(i=>i.parentId===o.id),r=Ho(s);r&&Gs(o,r)}}c(Ys,"recomputeNestedGroupBounds");function Sn(t,e){const n=t.nodes??[],o=t.edges??[],s=n.filter(f=>!f.isGroup);let r=1/0,i=-1/0;for(const f of s){const d=f[e];typeof d=="number"&&(r=Math.min(r,d),i=Math.max(i,d))}if(!Number.isFinite(r)||!Number.isFinite(i))return!1;const a=c(f=>r+i-f,"mirror");for(const f of n){const d=f[e];typeof d=="number"&&(f[e]=a(d));const b=f.groupTitleRect;b&&(f.groupTitleRect=e==="x"?{...b,left:a(b.right),right:a(b.left)}:{...b,top:a(b.bottom),bottom:a(b.top)})}for(const f of o)for(const d of f.points??[])d[e]=a(d[e]);return!0}c(Sn,"mirrorAxis");function zs(t){return(t.nodes??[]).some(n=>!n.isGroup)?Sn(t,"y"):!0}c(zs,"applyBtDirectionTransform");function Do(t){const e=We(t),n=t.filter(a=>!a.isGroup&&!a.isEdgeLabel&&!e.has(a.id));if(n.length===0)return 1;let o=0,s=0;for(const a of n)o+=a.width??0,s+=a.height??0;const r=o/n.length,i=s/n.length;return i>0?Math.max(1,r/i):1}c(Do,"flowAxisStretch");var Ni=36,Bi=["top","right","bottom","left"];function $s(t){return t==="left"?"right":t==="right"?"left":t}c($s,"mirroredSide");function Vs(t,e,n,o,s){if(n==="top"||n==="bottom"){const i=(e.left+e.right)/2,[a,f]=s?[o.after,o.before]:[o.before,o.after];t.left=Math.min(t.left,i-a),t.right=Math.max(t.right,i+f);return}const r=(e.top+e.bottom)/2;t.top=Math.min(t.top,r-o.before),t.bottom=Math.max(t.bottom,r+o.after)}c(Vs,"growAlongBorder");var Pi={top:c((t,e,n)=>{t.top=Math.min(t.top,e.top-n)},"top"),bottom:c((t,e,n)=>{t.bottom=Math.max(t.bottom,e.bottom+n)},"bottom"),left:c((t,e,n)=>{t.left=Math.min(t.left,e.left-n)},"left"),right:c((t,e,n)=>{t.right=Math.max(t.right,e.right+n)},"right")};function Us(t,e,n,o,s){Vs(t,e,n,o,s),Pi[n](t,e,o.beyond)}c(Us,"reserveOnSide");function js(t,e,n){const o=t.x??0,s=t.y??0,r=(t.width??0)/2,i=(t.height??0)/2,a={left:o-r,right:o+r,top:s-i,bottom:s+i},f={...a},d=n==="RL";for(const b of Bi){const l=e[b];l&&Us(f,a,d?$s(b):b,l,d)}return{...t,x:(f.left+f.right)/2,y:(f.top+f.bottom)/2,width:f.right-f.left,height:f.bottom-f.top}}c(js,"withAnchorFootprints");function Ws(t,e="LR"){const n=t.nodes??[],o=t.edges??[],s=We(n),r=n.filter(E=>!E.isGroup&&!s.has(E.id));let i=1/0,a=1/0;for(const E of r){const k=E.x??0,Y=E.y??0;k<i&&(i=k),Y<a&&(a=Y)}if(!Number.isFinite(i)||!Number.isFinite(a))return!1;const f=Ni,d=Do(n);for(const E of r){const k=E.x??0,W=((E.y??0)-a)*d+f,z=k-i;E.x=W,E.y=z}for(const E of o)if(E.points)for(const k of E.points){const Y=k.x,z=(k.y-a)*d+f,Q=Y-i;k.x=z,k.y=Q}Ys(n);const b=Ce(n),l=n.filter(E=>b.isLane(E.id));if(l.length===0)return e==="RL"&&Sn(t,"x"),!0;const I=new Map,p=ms(n,e);for(const E of n){if(b.isLane(E.id)||b.isPool(E.id)||s.has(E.id))continue;const k=b.laneIdOf(E.id);if(!k)continue;const Y=I.get(k)??[],W=p.get(E.id);Y.push(W?js(E,W,e):E),I.set(k,Y)}let y=0;for(const E of l){const k=E.padding??0;k>y&&(y=k)}const h=[];let x=1/0,L=-1/0;for(const E of l){const k=I.get(E.id)??[],Y=Ho(k);Y&&(x=Math.min(x,Y.minX),L=Math.max(L,Y.maxX),h.push({lane:E,contentTop:Y.minY,contentBottom:Y.maxY,centerY:(Y.minY+Y.maxY)/2}))}if(x===1/0||L===-1/0)return!0;const u=Math.max(0,L-x),v=Math.max(y,10),S=u+2*v,m=f+S,A=(x+L)/2-S/2-f,B=A+m/2,P=Math.max(y,f);h.sort((E,k)=>E.centerY-k.centerY);for(let E=0;E<h.length;E++){const k=h[E];let Y,W;if(E===0?Y=k.contentTop-P:Y=(h[E-1].contentBottom+k.contentTop)/2,E===h.length-1)W=k.contentBottom+P;else{const it=h[E+1];W=(k.contentBottom+it.contentTop)/2}const z=Math.max(0,W-Y),Q=(Y+W)/2;k.lane.x=B,k.lane.y=Q,k.lane.width=m,k.lane.height=z,k.lane.swimlaneContentTop=k.contentTop,k.lane.groupTitleRect={left:A,right:A+f,top:Y,bottom:W}}return e==="RL"&&Sn(t,"x"),!0}c(Ws,"applyLrDirectionTransform");var Se=1e-6,Fi=8,an=Fi,ki=[0,an,-an,2*an,-2*an];function Ks(t,e){const{nodeInfoById:n,realNodeRects:o}=En(e);for(const s of t){if(s.isLayoutOnly)continue;const r=s.points;if(!r||r.length<4)continue;const i=To(Mt(r,Se),Se);if(!i)continue;const{p3:a}=i,f=i.kind==="HVH",d=Bo(s,n,Se);if(!d)continue;const{srcId:b,dstId:l,srcInfo:I,dstInfo:p,collinearX:y,collinearY:h}=d;if(y||h)continue;let x;const L=I.rect;for(const u of ki){let v,S,m;if(f){const E=p.cy>I.cy?L.bottom:L.top,k=I.cx+u;if(k<=L.left+Se||k>=L.right-Se)continue;v={x:k,y:E},S={x:k,y:a.y},m={x:a.x,y:a.y}}else{const E=p.cx>I.cx?L.right:L.left,k=I.cy+u;if(k<=L.top+Se||k>=L.bottom-Se)continue;v={x:E,y:k},S={x:a.x,y:k},m={x:a.x,y:a.y}}const M=Me(v,S,Se),w=Me(S,m,Se);if(M&&w||!M&&Dt(v,S,o,[b],1)||!w&&Dt(S,m,o,[l],1))continue;const A=!M&&pn(v,S,t,s,{epsilon:Se,skipDegenerateOther:!0}),B=!w&&pn(S,m,t,s,{epsilon:Se,skipDegenerateOther:!0});if(!(A||B)){M?x=[S,m]:w?x=[v,S]:x=[v,S,m];break}}x&&(s.points=x)}}c(Ks,"portSwapToLShape");function qs(t,e){const{realNodeRects:r,labelNodeRects:i}=Ee(e.values());for(const a of t){if(a.isLayoutOnly)continue;const f=a.points;if(!f||f.length<4)continue;const d=Mt(f,.001);if(d.length<4)continue;const b=d.length-1,l=d[b],I=d[b-1],p=d[b-2],y=l.x-I.x,h=l.y-I.y,x=Math.hypot(y,h);if(x>=10||x<.001)continue;const L=I.x-p.x,u=I.y-p.y;if(Math.hypot(L,u)<.001)continue;const S=zt(I,l,.001),m=$t(I,l,.001),M=zt(p,I,.001),w=$t(p,I,.001);if(!(S&&w||m&&M))continue;const A=a.end,B=a.start,P=A?e.get(A):void 0;if(!P)continue;const E=P.x??0,k=P.y??0,Y=ce(P);if(!Y)continue;let W,z;if(w){const Z=u<0;W={x:E,y:p.y},z={x:E,y:Z?Y.bottom:Y.top}}else{const Z=L>0;W={x:p.x,y:k},z={x:Z?Y.right:Y.left,y:k}}if(Dt(W,z,r,A?[A]:[],-2)||Dt(W,z,i,[],-2))continue;if(B){const Z=e.get(B),at=Z?ce(Z):void 0;if(at&&Ro(W,at,2))continue}const Q=c((Z,at)=>`${Z.x.toFixed(3)},${Z.y.toFixed(3)}|${at.x.toFixed(3)},${at.y.toFixed(3)}`,"ownSegmentKey"),it=new Set;for(let Z=0;Z<d.length-1;Z++)it.add(Q(d[Z],d[Z+1]));const bt=c((Z,at)=>{for(const ht of t){if(ht===a||ht.isLayoutOnly)continue;const pt=ht.points;if(!(!pt||pt.length<2))for(let Ct=0;Ct<pt.length-1;Ct++){const H=pt[Ct],V=pt[Ct+1];if(!it.has(Q(H,V))&&Te(Z,at,H,V,.001))return!0}}return!1},"segmentCrossesOtherEdge");if(bt(W,z))continue;if(b-3>=0){const Z=d[b-3],at=[B,A].filter(ht=>!!ht);if(Dt(Z,W,r,at,-2)||bt(Z,W))continue}const Jt=[...d.slice(0,b-2),W,z];a.points=Jt;const Qt=a.labelNodeId;if(Qt){const Z=e.get(Qt);if(Z){const at=Z.width??0,ht=Z.height??0;if(at>0&&ht>0){let pt,Ct,H=-1;for(let V=0;V<Jt.length-1;V++){const ct=Jt[V],nt=Jt[V+1],dt=Math.hypot(nt.x-ct.x,nt.y-ct.y),gt=At(ct,nt,.001),It=vt(ct,nt,.001);(gt&&dt>=at+2||It&&dt>=ht+2)&&dt>H&&(H=dt,pt=(ct.x+nt.x)/2,Ct=(ct.y+nt.y)/2)}pt!==void 0&&Ct!==void 0&&(Z.x=pt,Z.y=Ct)}}}}}c(qs,"collapseShortTerminalStub");var _i=4,Hi=2,Xo={MIN_ARROWHEAD_SPACING:12,ROUTE_TOUCH_TOLERANCE:_i+Hi},Di={EPSILON:1e-6},vn={GRAVITY_ITERATIONS:8,MAX_CROSSING_OPTIMIZATION_PASSES:4,DEFAULT_COMPACT_SINGLE_INPUT:!0},Xn={DEFAULT_LAYER_GAP:100,DEFAULT_NODE_GAP:40,EDGE_LABEL_CLEARANCE:16},rt=.001,Zt=8,Zs=c(t=>typeof t=="string"?t.toUpperCase():"","upperCaseDirection"),xt=ye,Gn=c((t,e)=>vt(t,e,rt)||At(t,e,rt),"orthogonallyAligned");function ro(t,e){const r=c((u,v)=>{const S=Math.min(8,(v-u)/4);return{low:u+S,high:v-S}},"usableFace"),i=c((u,v)=>{const S=u.x??0,m=u.y??0,M=v.x-S,w=v.y-m;let A=(u.width??0)/2,B=(u.height??0)/2;return Math.abs(w)*A>Math.abs(M)*B?(w<0&&(B=-B),{x:S+(w===0?0:B*M/w),y:m+B}):(M<0&&(A=-A),{x:S+A,y:m+(M===0?0:A*w/M)})},"rectIntersect"),a=c((u,v)=>{const S=Mt(u.points??[]);if(S.length<2)return;const m=v?u.start:u.end,M=m?e.get(m):void 0,w=M?ce(M):void 0;if(!M||!m||!w)return;const A=v?S[0]:S[S.length-1],B=v?S[1]:S[S.length-2],P=i(M,A);let E=A;if(Gn(B,P)&&(E=B),vt(P,E,rt))return{edge:u,edgeId:String(u.id??""),nodeId:m,atStart:v,orientation:"V",coord:P.x,min:Math.min(P.y,E.y),max:Math.max(P.y,E.y),boundary:P,railEnd:E,rect:w};if(At(P,E,rt))return{edge:u,edgeId:String(u.id??""),nodeId:m,atStart:v,orientation:"H",coord:P.y,min:Math.min(P.x,E.x),max:Math.max(P.x,E.x),boundary:P,railEnd:E,rect:w}},"terminalLaneFor"),f=c((u,v)=>Math.max(0,Math.min(u.max,v.max)-Math.max(u.min,v.min)),"projectedOverlapLength"),d=c((u,v)=>u.nodeId!==v.nodeId||u.orientation!==v.orientation?!1:u.orientation==="H"?(Math.abs(u.boundary.x-u.rect.left)<1||Math.abs(u.boundary.x-u.rect.right)<1)&&vt(u.boundary,v.boundary,1):(Math.abs(u.boundary.y-u.rect.top)<1||Math.abs(u.boundary.y-u.rect.bottom)<1)&&At(u.boundary,v.boundary,1),"sameTerminalFace"),b=c((u,v)=>u.nodeId!==v.nodeId||u.orientation!==v.orientation?!1:f(u,v)>=Zt&&Math.abs(u.coord-v.coord)<.5,"exactTerminalLaneConflict"),l=c((u,v)=>{if(u.nodeId!==v.nodeId||u.orientation!==v.orientation||u.orientation!=="H"||u.atStart===v.atStart)return!1;const S=f(u,v);if(S<Zt)return!1;const m=u.rect.bottom-u.rect.top;return S<m||S>2*m?!1:d(u,v)&&Math.abs(u.coord-v.coord)<16},"nearTerminalLaneConflict"),I=c((u,v)=>{const S=Mt(u.edge.points??[]);if(S.length<2)return;const m=u.orientation==="V"?{x:u.boundary.x+v,y:u.boundary.y}:{x:u.boundary.x,y:u.boundary.y+v},M=u.orientation==="V"?{x:u.railEnd.x+v,y:u.railEnd.y}:{x:u.railEnd.x,y:u.railEnd.y+v};if(!c(()=>{if(Math.abs(u.boundary.y-u.rect.top)<1||Math.abs(u.boundary.y-u.rect.bottom)<1){const E=r(u.rect.left,u.rect.right);return At(m,u.boundary,rt)&&m.x>=E.low&&m.x<=E.high}if(Math.abs(u.boundary.x-u.rect.left)<1||Math.abs(u.boundary.x-u.rect.right)<1){const E=r(u.rect.top,u.rect.bottom);return vt(m,u.boundary,rt)&&m.y>=E.low&&m.y<=E.high}return!1},"boundaryStaysOnSameFace")())return;if(u.atStart){const E=S.length>1&&Me(S[1],u.railEnd,rt),k=S.slice(E?2:1),Y=k[0];return Y&&!Gn(Y,M)?void 0:[m,M,...k]}const A=S.length>1&&Me(S[S.length-2],u.railEnd,rt),B=S.slice(0,A?-2:-1),P=B[B.length-1];if(!(P&&!Gn(P,M)))return[...B,M,m]},"shiftedCandidate"),p=c(u=>{const v=u.edge,S=Mt(v.points??[]);if(S.length!==2)return!1;const m=v.start,M=v.end,w=m?e.get(m):void 0,A=M?e.get(M):void 0;if(!w||!A)return!1;const B=w.x??0,P=w.y??0,E=A.x??0,k=A.y??0,[Y,W]=S;return At(Y,W,rt)&&Math.abs(P-k)<1&&Math.abs(B-E)>1||vt(Y,W,rt)&&Math.abs(B-E)<1&&Math.abs(P-k)>1},"laneIsStraightCollinearConnector"),y=c(u=>u.orientation==="H"?r(u.rect.top,u.rect.bottom):r(u.rect.left,u.rect.right),"usableSpanOf"),h=c((u,v)=>{const S=y(u),m=u.coord<v.coord?S.low-u.coord:S.high-u.coord;return Math.sign(m)===Math.sign(u.coord-v.coord)?m:0},"shiftToFaceLimit"),x=c(u=>{const v=y(u);return[v.low-u.coord,v.high-u.coord]},"shiftsToFaceEnds"),L=[-7,7,-14,14,-21,21];for(let u=0;u<8;u++){const v=t.filter(m=>!m.isLayoutOnly).flatMap(m=>[a(m,!0),a(m,!1)]).filter(m=>!!m);let S=!1;for(let m=0;m<v.length&&!S;m++)for(let M=m+1;M<v.length&&!S;M++){const w=v[m],A=v[M];if(w.edge===A.edge||!(b(w,A)||l(w,A)))continue;const B=!b(w,A),P=[w,A].sort((z,Q)=>{const it=p(z),bt=p(Q);return it!==bt?Number(it)-Number(bt):+!Q.atStart-+!z.atStart}),E=c((z,Q,it)=>v.some(bt=>bt.edge!==z.edge&&(b(Q,bt)||it&&l(Q,bt))),"conflictsWith"),k=c((z,Q)=>Math.min(...v.filter(it=>it.edge!==z.edge&&it.nodeId===Q.nodeId&&it.orientation===Q.orientation&&f(Q,it)>=Zt).map(it=>Math.abs(Q.coord-it.coord))),"closestTrackGap"),Y=c((z,Q,it,bt=!1)=>{const ne=Q?a({...z.edge,points:Q},z.atStart):void 0;return!Q||!ne||E(z,ne,it)||bt&&k(z,ne)<k(z,z)?!1:(z.edge.points=Q,!0)},"accept"),W=B?P.filter(z=>!p(z)):P;for(const z of W)if(S=L.some(Q=>Y(z,I(z,Q),B)),S)break;if(!S){for(const z of W)if(S=(B?[h(z,z===w?A:w)]:x(z)).some(bt=>Math.abs(bt)>rt&&Y(z,I(z,bt),!1,!0)),S)break}}if(!S)return}}c(ro,"separateSharedRenderedTerminalLanes");function Js(t,e){const{realNodeRects:o,labelNodeRects:s}=Ee(e.values()),r=c((a,f)=>{const d=a.start,b=a.end,l=xt(f);if(l.length!==f.length-1)return!1;const I=[d,b].filter(p=>!!p);for(const p of l)if(Dt(p.a,p.b,o,I,-2)||Dt(p.a,p.b,s,[],-2))return!1;for(const p of t){if(p===a||p.isLayoutOnly)continue;const y=p.points;if(!(!y||y.length<2)){for(const h of l)for(const x of xt(Mt(y)))if(Ae(h,x,.5)>=Zt||Te(h.a,h.b,x.a,x.b,rt))return!1}}return!0},"candidateIsSafe"),i=c((a,f)=>{if(f+4>=a.length)return;const d=a[f],b=a[f+1],l=a[f+2],I=a[f+3],p=a[f+4],y=zt(d,b)&&$t(b,l)&&zt(l,I)&&$t(I,p)&&vt(d,I,rt)&&vt(d,p,rt)&&vt(b,l,rt)&&(b.x-d.x)*(I.x-l.x)<0,h=$t(d,b)&&zt(b,l)&&$t(l,I)&&zt(I,p)&&At(d,I,rt)&&At(d,p,rt)&&At(b,l,rt)&&(b.y-d.y)*(I.y-l.y)<0;if(y||h)return Mt([...a.slice(0,f+1),p,...a.slice(f+5)]);if(f+5>=a.length)return;const x=a[f+5],L=$t(d,b)&&zt(b,l)&&$t(l,I)&&zt(I,p)&&$t(p,x)&&vt(d,p,rt)&&vt(d,x,rt)&&vt(l,I,rt)&&(l.x-b.x)*(p.x-I.x)<0,u=zt(d,b)&&$t(b,l)&&zt(l,I)&&$t(I,p)&&zt(p,x)&&At(d,p,rt)&&At(d,x,rt)&&At(l,I,rt)&&(l.y-b.y)*(p.y-I.y)<0;if(!(!L&&!u))return Mt([...a.slice(0,f+1),x,...a.slice(f+6)])},"withoutDogleg");for(let a=0;a<8;a++){let f=!1;for(const d of t){if(d.isLayoutOnly)continue;const b=Mt(d.points??[]);for(let l=0;l<=b.length-5;l++){const I=i(b,l);if(!(!I||!r(d,I))){d.points=I,f=!0;break}}if(f)break}if(!f)return}}c(Js,"collapseRedundantRectangularDoglegs");function io(t,e){const{realNodeRects:r,labelNodeRects:i}=Ee(e.values()),a=t.filter(y=>!y.isLayoutOnly),f=c((y,h,x)=>Mt(y===h?x??[]:y.points??[]),"pointsFor"),d=c((y,h)=>{let x=0;for(let L=0;L<a.length;L++){const u=xt(f(a[L],y,h));for(let v=L+1;v<a.length;v++){const S=xt(f(a[v],y,h));for(const m of u)for(const M of S)Te(m.a,m.b,M.a,M.b,rt)&&x++}}return x},"strictCrossingCount"),b=c(y=>{const h=xt(y);if(h.length!==3)return;const x=h[1];if(!(h[0].horizontal===x.horizontal||h[2].horizontal===x.horizontal))return{index:x.index,horizontal:x.horizontal,vertical:x.vertical,segment:x}},"middleRail"),l=c((y,h)=>{const x=[y.start,y.end].filter(L=>!!L);return r.filter(L=>{if(x.includes(L.id))return!1;const u=L.rect;return h.horizontal?fe(h.a.x,h.b.x,u.left,u.right)>=Zt&&h.a.y>=u.top-2&&h.a.y<=u.bottom+2:fe(h.a.y,h.b.y,u.top,u.bottom)>=Zt&&h.a.x>=u.left-2&&h.a.x<=u.right+2})},"blockingRectsFor"),I=c((y,h,x)=>{const L=y.map(v=>({...v}));if(h.horizontal)L[h.index].y=x,L[h.index+1].y=x;else if(h.vertical)L[h.index].x=x,L[h.index+1].x=x;else return;const u=ve(Mt(L));return xt(u).length===u.length-1?u:void 0},"candidateByMovingRail"),p=c((y,h,x)=>{const L=[y.start,y.end].filter(v=>!!v),u=xt(h);if(u.length!==h.length-1)return!1;for(const v of u)if(Dt(v.a,v.b,r,L,-2)||Dt(v.a,v.b,i,[],-2))return!1;for(const v of a)if(v!==y){for(const S of u)for(const m of xt(f(v)))if(Ae(S,m,.5)>=Zt)return!1}return d(y,h)<=x},"candidateIsSafe");for(let y=0;y<8;y++){const h=d();let x=!1;for(const L of a){const u=f(L),v=b(u);if(!v)continue;const S=l(L,v.segment);if(S.length===0)continue;const m=v.horizontal?[Math.min(...S.map(M=>M.rect.top))-20,Math.max(...S.map(M=>M.rect.bottom))+20]:[Math.min(...S.map(M=>M.rect.left))-20,Math.max(...S.map(M=>M.rect.right))+20];for(const M of m){const w=I(u,v.segment,M);if(!(!w||!p(L,w,h))){L.points=w,x=!0;break}}if(x)break}if(!x)return}}c(io,"liftObstacleHuggingSameSideRails");function co(t,e,n){const s=c(b=>{const l=b.groupTitleRect;if(!(!l||typeof l.left!="number"||typeof l.right!="number"||typeof l.top!="number"||typeof l.bottom!="number"||!Number.isFinite(l.left)||!Number.isFinite(l.right)||!Number.isFinite(l.top)||!Number.isFinite(l.bottom)||l.right<=l.left||l.bottom<=l.top))return{left:l.left,right:l.right,top:l.top,bottom:l.bottom}},"validTitleRect"),r=Ce([...e.values()]),i=c(b=>{if(!r.isLane(b.id))return;const l=Zs(b.direction??n);if(l==="LR"||l==="RL"||l==="BT")return;const I=s(b),p=b.y,y=b.height;if(!I||typeof p!="number"||typeof y!="number"||!Number.isFinite(p)||!Number.isFinite(y)||y<=0)return;const h=I.right-I.left,x=I.bottom-I.top;if(!(x<=0||h<x))return{node:b,rect:I}},"topLaneTitleFor"),a=c((b,l)=>{if(!b.horizontal)return!1;const I=b.a.y;return I<l.top-rt||I>l.bottom+rt?!1:fe(b.a.x,b.b.x,l.left,l.right)>=Zt},"horizontalSegmentIntersectsTitle"),f=[...e.values()].map(i).filter(b=>!!b);if(f.length===0)return;let d=0;for(const b of t){if(b.isLayoutOnly)continue;const l=Mt(b.points??[]);for(const I of xt(l))for(const p of f)a(I,p.rect)&&(d=Math.max(d,p.rect.bottom-I.a.y+4))}if(!(d<=rt))for(const b of f){const l=b.node.y,I=b.node.height;typeof l!="number"||typeof I!="number"||!Number.isFinite(l)||!Number.isFinite(I)||I<=0||(b.node.y=l-d/2,b.node.height=I+d,b.node.groupTitleRect={...b.rect,top:b.rect.top-d,bottom:b.rect.bottom-d})}}c(co,"liftTopLaneTitleBandsAboveRails");function ao(t,e,n){const s=c(l=>{const I=l.groupTitleRect;if(!(!I||typeof I.left!="number"||typeof I.right!="number"||typeof I.top!="number"||typeof I.bottom!="number"||!Number.isFinite(I.left)||!Number.isFinite(I.right)||!Number.isFinite(I.top)||!Number.isFinite(I.bottom)||I.right<=I.left||I.bottom<=I.top))return{left:I.left,right:I.right,top:I.top,bottom:I.bottom}},"validTitleRect"),r=Ce([...e.values()]),i=c(l=>{if(!r.isLane(l.id)||Zs(l.direction??n)!=="LR")return;const p=s(l),y=l.x,h=l.width;if(!p||typeof y!="number"||typeof h!="number"||!Number.isFinite(y)||!Number.isFinite(h)||h<=0)return;const x=p.right-p.left,L=p.bottom-p.top;if(!(x<=0||L<x))return{node:l,rect:p}},"leftLaneTitleFor"),a=c((l,I)=>{if(!l.vertical)return!1;const p=l.a.x;return p<I.left-rt||p>I.right+rt?!1:fe(l.a.y,l.b.y,I.top,I.bottom)>=Zt},"verticalSegmentIntersectsTitle"),f=c((l,I)=>{if(!l.horizontal)return!1;const p=l.a.y;return p<I.top-rt||p>I.bottom+rt?!1:fe(l.a.x,l.b.x,I.left,I.right)>=Zt},"horizontalSegmentIntersectsTitle"),d=[...e.values()].map(i).filter(l=>!!l);if(d.length===0)return;let b=0;for(const l of t){if(l.isLayoutOnly)continue;const I=Mt(l.points??[]);for(const p of xt(I))for(const y of d)if(a(p,y.rect))b=Math.max(b,y.rect.right-p.a.x+4);else if(f(p,y.rect)){const h=Math.min(p.a.x,p.b.x);b=Math.max(b,y.rect.right-h+4)}}if(!(b<=rt))for(const l of d){const I=l.node.x,p=l.node.width;typeof I!="number"||typeof p!="number"||!Number.isFinite(I)||!Number.isFinite(p)||p<=0||(l.node.x=I-b/2,l.node.width=p+b,l.node.groupTitleRect={...l.rect,left:l.rect.left-b,right:l.rect.right-b})}}c(ao,"shiftLeftLaneTitleBandsLeftOfRails");function Qs(t,e){const{realNodeRects:o}=Ee(e.values()),s=t.filter(y=>!y.isLayoutOnly),r=c((y,h=new Map)=>Mt(h.get(y)??y.points??[]),"replacementPointsFor"),i=c((y=new Map)=>{let h=0;for(let x=0;x<s.length;x++){const L=xt(r(s[x],y));for(let u=x+1;u<s.length;u++){const v=xt(r(s[u],y));for(const S of L)for(const m of v)Te(S.a,S.b,m.a,m.b,rt)&&h++}}return h},"crossingCount"),a=c((y=new Map)=>s.reduce((h,x)=>h+pe(r(x,y)),0),"totalBends"),f=c(y=>{const h=r(y);if(h.length<4)return;const x=h[h.length-2],L=h[h.length-1];if(!(!zt(x,L,rt)&&!$t(x,L,rt)))return{tailStart:x,terminal:L}},"terminalTailFor"),d=c((y,h)=>{const x=r(y);if(x.length<3)return;const L=x[0],u=x[1];let v;if(zt(L,u,rt))v={x:u.x,y:h.tailStart.y};else if($t(L,u,rt))v={x:h.tailStart.x,y:u.y};else return;const S=ve(Mt([L,u,v,h.tailStart,h.terminal]));return xt(S).length===S.length-1?S:void 0},"candidateWithDestinationTail"),b=c((y,h)=>{const x=[y.start,y.end].filter(L=>!!L);for(const L of xt(h))if(Dt(L.a,L.b,o,x,-2))return!0;return!1},"pathHasNodeHit"),l=c((y,h,x)=>{for(const L of s)if(L!==y){for(const u of xt(h))for(const v of xt(r(L,x)))if(Ae(u,v,.5)>=Zt)return!0}return!1},"pathHasSharedTrack"),I=c((y,h,x)=>!b(y,h)&&!l(y,h,x),"candidateIsSafe"),p=c(()=>{const y=new Map;for(const h of s){const x=h.end;if(!x||!e.has(x)||r(h).length<4)continue;const u=y.get(x)??[];u.push(h),y.set(x,u)}return y},"edgesByDestination");for(let y=0;y<4;y++){const h=i();if(h===0)return;const x=a();let L,u=h,v=x;for(const S of p().values())for(let m=0;m<S.length;m++)for(let M=m+1;M<S.length;M++){const w=S[m],A=S[M],B=f(w),P=f(A);if(!B||!P)continue;const E=d(w,P),k=d(A,B);if(!E||!k)continue;const Y=new Map([[w,E],[A,k]]);if(!I(w,E,Y)||!I(A,k,Y))continue;const W=i(Y),z=a(Y);W>=h||W>u||W===u&&z>=v||(L=Y,u=W,v=z)}if(!L)return;for(const[S,m]of L)S.points=m}}c(Qs,"swapDestinationTerminalTailsToReduceCrossings");function tr(t,e){const{realNodeRects:r,labelNodeRects:i}=Ee(e.values()),a=t.filter(S=>!S.isLayoutOnly),f=c((S,m=new Map)=>Mt(m.get(S)??S.points??[]),"replacementPointsFor"),d=c((S=new Map)=>{let m=0;for(let M=0;M<a.length;M++){const w=xt(f(a[M],S));for(let A=M+1;A<a.length;A++){const B=xt(f(a[A],S));for(const P of w)for(const E of B)Te(P.a,P.b,E.a,E.b,rt)&&m++}}return m},"strictCrossingCount"),b=c((S=new Map)=>a.reduce((m,M)=>m+pe(f(M,S)),0),"totalBends"),l=c(S=>{const m=S.start,M=S.end,w=m?e.get(m):void 0,A=M?e.get(M):void 0,B=w?ce(w):void 0,P=A?ce(A):void 0;return B&&P?{src:B,dst:P}:void 0},"endpointRectsFor"),I=c((S,m,M)=>{if(M.index<=0||M.index+1>=m.length-1)return;const w=l(S);if(w){if(M.vertical){const A=M.a.x,B=Math.min(w.src.left,w.dst.left),P=Math.max(w.src.right,w.dst.right),E=A<B-rt?"left":A>P+rt?"right":void 0;return E?{edge:S,points:m,segmentIndex:M.index,axis:"vertical",side:E,coord:A,min:Math.min(M.a.y,M.b.y),max:Math.max(M.a.y,M.b.y)}:void 0}if(M.horizontal){const A=M.a.y,B=Math.min(w.src.top,w.dst.top),P=Math.max(w.src.bottom,w.dst.bottom),E=A<B-rt?"top":A>P+rt?"bottom":void 0;return E?{edge:S,points:m,segmentIndex:M.index,axis:"horizontal",side:E,coord:A,min:Math.min(M.a.x,M.b.x),max:Math.max(M.a.x,M.b.x)}:void 0}}},"externalRailForSegment"),p=c(()=>{const S=[];for(const m of a){const M=f(m);for(const w of xt(M)){const A=I(m,M,w);A&&S.push(A)}}return S},"collectExternalRails"),y=c((S,m)=>S.edge!==m.edge&&S.axis===m.axis&&S.side===m.side&&fe(S.min,S.max,m.min,m.max)>=Zt,"railsInteract"),h=c(S=>{const m=[],M=new Set;for(const w of S){if(M.has(w))continue;const A=[w],B=[];for(M.add(w);A.length>0;){const P=A.pop();B.push(P);for(const E of S)!M.has(E)&&y(P,E)&&(M.add(E),A.push(E))}B.length>1&&m.push(B)}return m},"connectedComponents"),x=c(S=>{const m=[];for(const M of S)m.some(w=>Math.abs(w-M.coord)<rt)||m.push(M.coord);for(;m.length<S.length;){const M=Math.min(...m),w=Math.max(...m),A=S[0].side;m.push(A==="left"||A==="top"?M-12*(S.length-m.length):w+12*(S.length-m.length))}return m},"uniqueCoordsFor"),L=c(S=>{const m=S.map(A=>A.coord),M=x(S),w=[];if(S.length<=6){const A=new Array(M.length).fill(!1),B=[],P=c(()=>{if(B.length===S.length){B.some((E,k)=>Math.abs(E-m[k])>=rt)&&w.push([...B]);return}for(const[E,k]of M.entries())A[E]||(A[E]=!0,B.push(k),P(),B.pop(),A[E]=!1)},"visit");return P(),w}for(let A=0;A<m.length;A++)for(let B=A+1;B<m.length;B++){const P=[...m];[P[A],P[B]]=[P[B],P[A]],w.push(P)}return w},"coordinateAssignmentsFor"),u=c((S,m)=>{const M=new Map;for(const[A,B]of S.entries()){const P=m[A],E=M.get(B.edge)??B.points.map(k=>({x:k.x,y:k.y}));B.axis==="vertical"?(E[B.segmentIndex].x=P,E[B.segmentIndex+1].x=P):(E[B.segmentIndex].y=P,E[B.segmentIndex+1].y=P),M.set(B.edge,E)}const w=new Map;for(const[A,B]of M){const P=ve(Mt(B));if(xt(P).length!==P.length-1)return;w.set(A,P)}return w},"replacementsForAssignment"),v=c(S=>{for(const[m,M]of S){const w=[m.start,m.end].filter(A=>!!A);for(const A of xt(M))if(Dt(A.a,A.b,r,w,-2)||Dt(A.a,A.b,i,[],-2))return!1}for(let m=0;m<a.length;m++){const M=a[m],w=S.has(M),A=xt(f(M,S));for(let B=m+1;B<a.length;B++){const P=a[B];if(!w&&!S.has(P))continue;const E=xt(f(P,S));for(const k of A)for(const Y of E)if(Ae(k,Y,.5)>=Zt)return!1}}return!0},"candidateIsSafe");for(let S=0;S<4;S++){const m=d();if(m===0)return;let M,w=m,A=b(),B=Number.POSITIVE_INFINITY;for(const P of h(p()))for(const E of L(P)){const k=u(P,E);if(!k||!v(k))continue;const Y=d(k);if(Y>=m)continue;const W=b(k),z=P.reduce((Q,it,bt)=>Q+Math.abs(E[bt]-it.coord),0);Y>w||Y===w&&(W>A||W===A&&z>=B)||(M=k,w=Y,A=W,B=z)}if(!M)return;for(const[P,E]of M)P.points=E}}c(tr,"reassignCrossingExternalRailChannels");function er(t,e){const{realNodeRects:o,labelNodeRects:s}=Ee(e.values()),r=t.filter(p=>!p.isLayoutOnly),i=c((p,y,h)=>Mt(p===y?h??[]:p.points??[]),"pointsFor"),a=c(p=>xt(p).reduce((y,h)=>{const x=h.a.x-h.b.x,L=h.a.y-h.b.y;return y+Math.hypot(x,L)},0),"pathLength"),f=c((p,y)=>{let h=0;for(let x=0;x<r.length;x++){const L=xt(i(r[x],p,y));for(let u=x+1;u<r.length;u++){const v=xt(i(r[u],p,y));for(const S of L)for(const m of v)Te(S.a,S.b,m.a,m.b,rt)&&h++}}return h},"strictCrossingCount"),d=c((p,y)=>{if(p.horizontal){const h=p.a.y;return(Math.abs(h-y.top)<1||Math.abs(h-y.bottom)<1)&&fe(p.a.x,p.b.x,y.left,y.right)>=Zt}if(p.vertical){const h=p.a.x;return(Math.abs(h-y.left)<1||Math.abs(h-y.right)<1)&&fe(p.a.y,p.b.y,y.top,y.bottom)>=Zt}return!1},"segmentRunsAlongRectBorder"),b=c(p=>{const y=[p.start,p.end].filter(x=>!!x),h=[];for(const x of y){const L=e.get(x),u=L?ce(L):void 0;u&&h.push(u)}return h},"endpointRectsFor"),l=c((p,y)=>{if(y+3>=p.length)return[];const h=p[y],x=p[y+1],L=p[y+2],u=p[y+3],v=zt(h,x,rt)&&$t(x,L,rt)&&zt(L,u,rt),S=$t(h,x,rt)&&zt(x,L,rt)&&$t(L,u,rt);if(!v&&!S)return[];if(!(v?Math.sign(x.x-h.x)!==Math.sign(u.x-L.x):Math.sign(x.y-h.y)!==Math.sign(u.y-L.y)))return[];const M=vt(h,u,rt)||At(h,u,rt)?[]:[{x:h.x,y:u.y},{x:u.x,y:h.y}],w=M.length===0?[[...p.slice(0,y+1),...p.slice(y+3)]]:M.map(B=>[...p.slice(0,y+1),B,...p.slice(y+3)]),A=new Set;return w.map(B=>ve(Mt(B))).filter(B=>{if(xt(B).length!==B.length-1||!B.some(E=>Me(E,u,rt)))return!1;const P=B.map(E=>`${E.x.toFixed(3)},${E.y.toFixed(3)}`).join("|");return A.has(P)?!1:(A.add(P),!0)})},"shortcutCandidatesAt"),I=c((p,y,h)=>{const x=[p.start,p.end].filter(u=>!!u),L=b(p);for(const u of xt(y))if(Dt(u.a,u.b,o,x,-2)||Dt(u.a,u.b,s,[],-2)||L.some(v=>d(u,v)))return!1;for(const u of r)if(u!==p){for(const v of xt(y))for(const S of xt(i(u)))if(Ae(v,S,.5)>=Zt)return!1}return f(p,y)<=h},"candidateIsSafe");for(let p=0;p<8;p++){const y=f();let h,x,L=y,u=Number.POSITIVE_INFINITY,v=Number.POSITIVE_INFINITY;for(const S of r){const m=i(S),M=pe(m,rt),w=a(m);for(let A=0;A<=m.length-4;A++)for(const B of l(m,A)){const P=pe(B,rt),E=a(B);if(!(P<M||P===M&&E<w-rt)||!I(S,B,y))continue;const Y=f(S,B);Y>L||Y===L&&(P>u||P===u&&E>=v)||(h=S,x=B,L=Y,u=P,v=E)}}if(!h||!x)return;h.points=x}}c(er,"shortcutRedundantOrthogonalJogs");function nr(t,e){const i=[];for(const T of e.values()){if(T.isGroup||T.isEdgeLabel)continue;const F=T.x??0,_=T.y??0,j=ce(T);j&&i.push({id:String(T.id??""),cx:F,cy:_,rect:j})}if(i.length===0)return;const a=new Map(i.map(T=>[T.id,T])),f=i.map(T=>({id:T.id,rect:T.rect})),d=["top","bottom","left","right"],b={top:Math.min(...i.map(T=>T.rect.top))-20,bottom:Math.max(...i.map(T=>T.rect.bottom))+20,left:Math.min(...i.map(T=>T.rect.left))-20,right:Math.max(...i.map(T=>T.rect.right))+20},l=t.filter(T=>!T.isLayoutOnly),I=new Map(l.map((T,F)=>[T,F])),p=c(T=>{const F=T==="left"||T==="top"?-1:1,_=[];for(let j=0;j<=2;j++)_.push(b[T]+F*20*j);return _},"outwardTracksForSide"),y=c((T,F=new Map)=>Mt(F.get(T)??T.points??[]),"replacementPointsFor"),h=c((T,F)=>{let _=0;for(const j of T)for(const q of F)Te(j.a,j.b,q.a,q.b,rt)&&_++;return _},"crossingCountBetweenSegments"),x=c((T,F)=>h(xt(T),xt(F)),"crossingCountBetweenPaths"),L=c((T=new Map)=>{let F=0;const _=[],j=new Set,q=[],tt=c(G=>{j.has(G)||(j.add(G),q.push(G))},"addEdge");for(let G=0;G<l.length;G++){const et=l[G],lt=y(et,T);for(let Lt=G+1;Lt<l.length;Lt++){const Ht=l[Lt],jt=x(lt,y(Ht,T));jt>0&&(F+=jt,_.push({first:et,second:Ht,count:jt}),tt(et),tt(Ht))}}return q.sort((G,et)=>(I.get(G)??0)-(I.get(et)??0)),{count:F,pairs:_,edgeSet:j,edges:q}},"crossingSnapshot"),u=c((T,F)=>{const _=new Set(F.keys());if(_.size===0)return T.count;let j=0;for(const tt of T.pairs)(_.has(tt.first)||_.has(tt.second))&&(j+=tt.count);let q=0;for(let tt=0;tt<l.length;tt++){const G=l[tt],et=_.has(G),lt=y(G,F);for(let Lt=tt+1;Lt<l.length;Lt++){const Ht=l[Lt];!et&&!_.has(Ht)||(q+=x(lt,y(Ht,F)))}}return T.count-j+q},"crossingCountWithReplacements"),v=c(T=>{const F=new Map;for(const q of T.pairs){const tt=F.get(q.first)??new Set;tt.add(q.second),F.set(q.first,tt);const G=F.get(q.second)??new Set;G.add(q.first),F.set(q.second,G)}const _=[],j=new Set;for(const q of T.edges){if(j.has(q))continue;const tt=[q],G=[];for(j.add(q);tt.length>0;){const et=tt.pop();G.push(et);for(const lt of F.get(et)??[])j.has(lt)||(j.add(lt),tt.push(lt))}G.sort((et,lt)=>(I.get(et)??0)-(I.get(lt)??0)),G.length>1&&_.push(G)}return _},"crossingComponents"),S=c(T=>[T.start,T.end].filter(F=>!!F),"endpointIdsFor"),m=c(T=>{const F=[];for(const _ of v(T)){const j=new Set(_),q=new Set(_.flatMap(G=>S(G))),tt=[..._];for(const G of l)j.has(G)||S(G).some(et=>q.has(et))&&tt.push(G);tt.sort((G,et)=>(I.get(G)??0)-(I.get(et)??0)),F.push(tt)}return F},"pairSearchGroups"),M=c((T,F,_)=>u(T,new Map([[F,_]])),"crossingCountWithSingleReplacement"),w=c(T=>{const F=new Map;for(const _ of T.pairs)F.set(_.first,(F.get(_.first)??0)+_.count),F.set(_.second,(F.get(_.second)??0)+_.count);return F},"currentCrossingsByEdge"),A=c(T=>T.slice(1).reduce((F,_,j)=>{const q=T[j];return F+Math.abs(_.x-q.x)+Math.abs(_.y-q.y)},0),"pathLength"),B=c((T=new Map)=>l.reduce((F,_)=>F+pe(y(_,T)),0),"totalBends"),P=c((T=new Map)=>l.reduce((F,_)=>F+A(y(_,T)),0),"totalLength"),E=c((T,F)=>gn(T,F,Xo.ROUTE_TOUCH_TOLERANCE),"touchesAtBend"),k=c((T,F,_=new Map)=>{const j=xt(F);for(const q of l)if(q!==T){for(const tt of j)for(const G of xt(y(q,_)))if(Ae(tt,G,.5)>=Zt)return!0;if(E(F,y(q,_)))return!0}return!1},"pathHasSegmentConflict"),Y=c((T,F)=>{const _=[T.start,T.end].filter(j=>!!j);for(const j of xt(F))if(Dt(j.a,j.b,f,_,-2))return!0;return!1},"pathHitsNode"),W=c((T,F)=>{const _=ve(Mt(F));xt(_).length===_.length-1&&T.push(_)},"pushOrthogonalCandidate"),z=c(T=>T==="left"||T==="right","sideIsHorizontal"),Q=c((T,F,_)=>{switch(F){case"left":return Math.min(T.x,_.x)-20;case"right":return Math.max(T.x,_.x)+20;case"top":return Math.min(T.y,_.y)-20;case"bottom":return Math.max(T.y,_.y)+20}},"localTrackForSameSide"),it=c((T,F,_,j)=>{const q=_==="left"||_==="top"?-1:1,tt=[Q(F,_,j),b[_]];for(const G of tt)for(let et=0;et<=2;et++)W(T,No(F,_,j,G+q*20*et))},"addSameSideCandidates"),bt=c((T,F,_,j,q)=>{for(const tt of p(_))for(const G of p(q))W(T,[F,{x:tt,y:F.y},{x:tt,y:G},{x:j.x,y:G},j])},"addHorizontalToVerticalCandidates"),ne=c((T,F,_,j,q)=>{for(const tt of p(_))for(const G of p(q))W(T,[F,{x:F.x,y:tt},{x:G,y:tt},{x:G,y:j.y},j])},"addVerticalToHorizontalCandidates"),Jt=c((T,F,_,j,q)=>{const tt=[...p("top"),...p("bottom")];for(const G of p(_))for(const et of p(q))for(const lt of tt)W(T,[F,{x:G,y:F.y},{x:G,y:lt},{x:et,y:lt},{x:et,y:j.y},j])},"addHorizontalPairCandidates"),Qt=c((T,F,_,j,q)=>{const tt=[...p("left"),...p("right")];for(const G of p(_))for(const et of p(q))for(const lt of tt)W(T,[F,{x:F.x,y:G},{x:lt,y:G},{x:lt,y:et},{x:j.x,y:et},j])},"addVerticalPairCandidates"),Z=c(T=>{const F=new Set;return T.map(_=>Mt(_)).filter(_=>{const j=_.map(q=>`${q.x.toFixed(3)},${q.y.toFixed(3)}`).join("|");return F.has(j)||_.length<2?!1:(F.add(j),!0)})},"dedupeCandidatePaths"),at=c((T,F,_,j)=>{const q=[],tt=Oo(T,F,_,j,20,rt);tt&&W(q,tt),F===j&&it(q,T,F,_);const G=z(F),et=z(j);return G&&!et?bt(q,T,F,_,j):!G&&et?ne(q,T,F,_,j):G?Jt(q,T,F,_,j):Qt(q,T,F,_,j),Z(q)},"buildCandidatesForSides"),ht=c((T,F,_,j)=>{const q=[...p("left"),...p("right")],tt=[...p("top"),...p("bottom")];for(const G of d){const et=Ge(j,G),lt=G==="top"||G==="bottom"?p(G):tt;for(const Lt of q){z(G)&&W(T,[F,_,{x:Lt,y:_.y},{x:Lt,y:et.y},et]);for(const Ht of lt)W(T,[F,_,{x:Lt,y:_.y},{x:Lt,y:Ht},{x:et.x,y:Ht},et])}}},"addVerticalDepartureOuterTrackCandidates"),pt=c((T,F,_,j)=>{const q=[...p("left"),...p("right")],tt=[...p("top"),...p("bottom")];for(const G of d){const et=Ge(j,G),lt=G==="left"||G==="right"?p(G):q;for(const Lt of tt){z(G)||W(T,[F,_,{x:_.x,y:Lt},{x:et.x,y:Lt},et]);for(const Ht of lt)W(T,[F,_,{x:_.x,y:Lt},{x:Ht,y:Lt},{x:Ht,y:et.y},et])}}},"addHorizontalDepartureOuterTrackCandidates"),Ct=c(T=>{const F=T.start,_=T.end,j=_?a.get(_):void 0;if(!F||!j)return[];const q=Mt(T.points??[]);if(q.length<4)return[];const tt=q[0],G=q[1],et=[];return $t(tt,G,rt)?ht(et,tt,G,j):zt(tt,G,rt)&&pt(et,tt,G,j),et},"terminalPreservingOuterTrackCandidates"),H=c(T=>{const F=T.start,_=T.end,j=F?a.get(F):void 0,q=_?a.get(_):void 0;if(!j||!q)return[];const tt=[];for(const G of d){const et=Ge(j,G);for(const lt of d)tt.push(...at(et,G,Ge(q,lt),lt))}return tt.push(...Ct(T)),tt},"candidatePathsFor"),V=c(()=>new Map(l.map(T=>[T,xt(y(T))])),"currentSegmentsByEdge"),ct=c((T,F,_,j)=>{const q=new Set;for(const tt of l){if(tt===T)continue;const G=j.get(tt)??xt(y(tt));(_.some(et=>G.some(lt=>Ae(et,lt,.5)>=Zt))||E(F,y(tt)))&&q.add(tt)}return q},"sharedTrackConflictsFor"),nt=c((T,F,_,j)=>{const q=new Set;return H(T).map(G=>ve(Mt(G))).filter(G=>{if(Y(T,G))return!1;const et=G.map(lt=>`${lt.x.toFixed(3)},${lt.y.toFixed(3)}`).join("|");return q.has(et)||G.length<2?!1:(q.add(et),!0)}).map(G=>{const et=xt(G);let lt=0;for(const Lt of l)Lt!==T&&(lt+=h(et,_.get(Lt)??xt(y(Lt))));return{candidate:G,candidateSegments:et,crossings:F.count-(j.get(T)??0)+lt,bends:pe(G,rt),totalBends:pe(G),length:A(G)}}).filter(({crossings:G})=>G<=F.count).sort((G,et)=>G.crossings-et.crossings||G.bends-et.bends||G.length-et.length).slice(0,48).map(G=>({path:G.candidate,segments:G.candidateSegments,sharedTrackConflicts:ct(T,G.candidate,G.candidateSegments,_),totalBends:G.totalBends,length:G.length}))},"pairCandidatesFor"),dt=c((T,F,_,j,q,tt)=>{let G=0;for(const lt of T.pairs)(lt.first===F||lt.second===F||lt.first===j||lt.second===j)&&(G+=lt.count);let et=h(_.segments,q.segments);for(const lt of l){if(lt===F||lt===j)continue;const Lt=tt.get(lt)??xt(y(lt));et+=h(_.segments,Lt)+h(q.segments,Lt)}return T.count-G+et},"pairCrossingCount"),gt=c((T,F)=>{for(const _ of T.sharedTrackConflicts)if(_!==F)return!1;return!0},"conflictsOnlyWith"),It=c((T,F)=>T.segments.some(_=>F.segments.some(j=>Ae(_,j,.5)>=Zt))||E(T.path,F.path),"candidatesShareTrack"),mt=c((T,F,_,j)=>gt(F,_.edge)&>(j,T.edge)&&!It(F,j),"pairCandidatesAreCompatible"),Et=c((T,F,_,j,q)=>{const tt=dt(T.current,F.edge,_,j.edge,q,T.baseSegments);if(!(tt>=T.current.count))return{replacements:new Map([[F.edge,_.path],[j.edge,q.path]]),crossings:tt,bends:T.currentBends-(T.baseBendsByEdge.get(F.edge)??0)-(T.baseBendsByEdge.get(j.edge)??0)+_.totalBends+q.totalBends,length:T.currentLength-(T.baseLengthByEdge.get(F.edge)??0)-(T.baseLengthByEdge.get(j.edge)??0)+_.length+q.length}},"scorePairReplacement"),Vt=c((T,F)=>T.crossings<F.crossings||T.crossings===F.crossings&&(T.bends<F.bends||T.bends===F.bends&&T.length<F.length),"pairScoreIsBetter"),_e=c((T,F,_,j)=>{let q=j;for(const tt of F.candidates)for(const G of _.candidates){if(!mt(F,tt,_,G))continue;const et=Et(T,F,tt,_,G);et&&Vt(et,q)&&(q=et)}return q},"bestScoreForOptionPair"),Le=c(T=>{const F=B(),_=P(),j=V(),q=w(T),tt=new Map(l.map(jt=>[jt,pe(y(jt))])),G=new Map(l.map(jt=>[jt,A(y(jt))])),et=new Map,lt=m(T);for(const jt of lt)for(const xe of jt){if(et.has(xe))continue;const oe=nt(xe,T,j,q);oe.length>0&&et.set(xe,{edge:xe,candidates:oe})}let Lt={replacements:new Map,crossings:T.count,bends:F,length:_};const Ht={current:T,currentBends:F,currentLength:_,baseBendsByEdge:tt,baseLengthByEdge:G,baseSegments:j};for(const jt of lt){const xe=new Set(jt.filter(ee=>T.edgeSet.has(ee))),oe=jt.map(ee=>et.get(ee)).filter(ee=>!!ee);for(let ee=0;ee<oe.length;ee++){const g=oe[ee];for(let C=ee+1;C<oe.length;C++){const O=oe[C];!xe.has(g.edge)&&!xe.has(O.edge)||(Lt=_e(Ht,g,O,Lt))}}}return Lt.replacements.size>0?Lt.replacements:void 0},"bestPairedReplacement");for(let T=0;T<4;T++){const F=L(),_=F.count;if(_===0)return;let j,q,tt=_,G=Number.POSITIVE_INFINITY;for(const lt of F.edges){const Lt=pe(y(lt),rt);for(const Ht of H(lt)){const jt=Y(lt,Ht),xe=!jt&&k(lt,Ht),oe=M(F,lt,Ht),ee=pe(Ht,rt);jt||xe||!(oe<_||oe===_&&ee<Lt)||oe>tt||oe===tt&&ee>=G||(j=lt,q=Ht,tt=oe,G=ee)}}if(j&&q){j.points=q;continue}const et=Le(F);if(!et)return;for(const[lt,Lt]of et)lt.points=Lt}}c(nr,"resolveRenderedOrthogonalCrossings");var Fe=.001,Xi=8;function or(t,e){const{nodeInfoById:n,realNodeRects:o}=En(e),s=["top","bottom","left","right"],r=20,i={top:Math.min(...o.map(h=>h.rect.top))-r,bottom:Math.max(...o.map(h=>h.rect.bottom))+r,left:Math.min(...o.map(h=>h.rect.left))-r,right:Math.max(...o.map(h=>h.rect.right))+r},a=c((h,x,L,u)=>{const v=[],S=Oo(h,x,L,u,r,Fe);return S&&v.push(S),x===u&&v.push(No(h,x,L,i[x])),v},"buildOrthogonalPathCandidates"),f=c((h,x)=>{for(let L=0;L<h.length-1;L++){const u=h[L],v=h[L+1];if(Dt(u,v,o,x,1))return!0}return!1},"pathHitsNode"),d=c((h,x,L=!1)=>{let u=0;const v=ye(h,Fe),S=x.start,m=x.end;for(const M of t){if(M===x||M.isLayoutOnly)continue;const w=M.start,A=M.end;if(!L&&S&&m&&(w===S||w===m||A===S||A===m))continue;const B=M.points;if(!(!B||B.length<2))for(const P of v)for(const E of ye(B,Fe)){if(Po(P.a,P.b,E.a,E.b,Fe,Fe)){u++;continue}Ae(P,E,Fe)>=Xi&&u++}}return u},"pathConflictCount"),b=4,l=c((h,x)=>{const L=Math.abs(h.y-x.rect.top),u=Math.abs(h.y-x.rect.bottom),v=Math.abs(h.x-x.rect.left),S=Math.abs(h.x-x.rect.right);let m="top",M=L;return u<M&&(m="bottom",M=u),v<M&&(m="left",M=v),S<M&&(m="right",M=S),m},"nearestSideOfRect"),I=new Map,p=c((h,x,L)=>{const u=I.get(h)??[];u.push({side:x,edgeId:L}),I.set(h,u)},"addFaceClaim");for(const h of t){if(h.isLayoutOnly)continue;const x=h.points??[];if(x.length<1)continue;const L=h.id??"",u=h.start,v=h.end;if(u){const S=n.get(u);S&&p(u,l(x[0],S),L)}if(v){const S=n.get(v);S&&p(v,l(x[x.length-1],S),L)}}const y=c((h,x,L)=>{var u;return((u=I.get(h))==null?void 0:u.some(v=>v.edgeId!==L&&v.side===x))??!1},"faceIsClaimed");for(const h of t){if(h.isLayoutOnly)continue;const x=h.points;if(!x||x.length<2)continue;const L=pe(x,Fe);if(L<b)continue;const u=h.start,v=h.end;if(!u||!v)continue;const S=n.get(u),m=n.get(v);if(!S||!m)continue;const M=h.id??"",w=d(x,h,!0),A=d(x,h);let B,P=w,E=L;for(const k of s){if(y(u,k,M))continue;const Y=Ge(S,k);for(const W of s){if(y(v,W,M))continue;const z=Ge(m,W);for(const Q of a(Y,k,z,W)){if(f(Q,[u,v]))continue;const it=pe(Q,Fe);if(w>0){const bt=d(Q,h,!0);if(bt>P||bt===P&&it>=E)continue;P=bt,E=it,B=Q;continue}d(Q,h)>A||it<E&&(E=it,B=Q)}}}if(B){h.points=B;const k=I.get(u);k&&I.set(u,k.filter(W=>W.edgeId!==M));const Y=I.get(v);Y&&I.set(v,Y.filter(W=>W.edgeId!==M)),p(u,l(B[0],S),M),p(v,l(B[B.length-1],m),M)}}}c(or,"simplifyDetouredEdges");var he=.001,ns=10,ln=7;function lo(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 i=r.x-s.x,a=r.y-s.y;if(!(Math.abs(i)+Math.abs(a)<he)){if(Math.abs(a)<=he){const d=s.x+Math.sign(i)*ns;return{left:Math.min(s.x,d),right:Math.max(s.x,d),top:s.y-ln,bottom:s.y+ln}}if(Math.abs(i)<=he){const d=s.y+Math.sign(a)*ns;return{left:s.x-ln,right:s.x+ln,top:Math.min(s.y,d),bottom:Math.max(s.y,d)}}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)}}}c(lo,"markerClearanceRectFor");function sr(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)}}c(sr,"normalizeRect");function fo(t,e){const n=Mt(e),o=lo(n,!0),s=lo(n,!1);return[o,s].some(r=>r&&mn(t,sr(r)))}c(fo,"labelOverlapsOwnMarker");function Ke(t,e){const n=[];for(const h of t){if(h.isLayoutOnly)continue;const x=h.points;if(!(!x||x.length<2))for(let L=0;L<x.length-1;L++)n.push({edgeId:h.id,p1:x[L],p2:x[L+1]})}const o=[],s=[],r=Ce([...e.values()]);for(const h of e.values()){const x=h.isGroup;if(r.isLane(h.id)){const u=ce(h);u&&s.push({id:h.id,rect:u});continue}if(x||h.isEdgeLabel)continue;const L=ce(h);L&&o.push({nodeId:h.id,rect:L})}const i=3,a=1,f=12,d=c((h,x)=>{const L=Un(x,i);for(const{nodeId:u,rect:v}of o)if(u!==h&&mn(L,v))return!0;return!1},"labelOverlapsForeignNode"),b=c((h,x)=>{const L=Un(x,i);for(const u of n)if(u.edgeId!==h&&An(u.p1,u.p2,L))return!0;return!1},"labelOverlapsForeignEdge"),l=c((h,x,L)=>d(h,L)||b(x,L),"labelOverlapsAnything"),I=[],p=c(h=>{for(const{id:x,rect:L}of s)if(Ts(L,h))return x},"findContainingLane"),y=c((h,x)=>I.some(L=>L.labelId!==h&&mn(x,L.rect)),"overlapsPlacedLabel");for(const h of t){if(h.isLayoutOnly)continue;const x=h.labelNodeId;if(!x)continue;const L=e.get(x);if(!L)continue;const u=h.points;if(!u||u.length<2)continue;const v=L.width??0,S=L.height??0;if(v<=0||S<=0)continue;const m=[];for(let Z=0;Z<u.length-1;Z++){const at=u[Z],ht=u[Z+1],pt=Math.abs(at.x-ht.x),Ct=Math.abs(at.y-ht.y);pt<he&&Ct<he||pt>=he&&Ct>=he||m.push({idx:Z,length:pt+Ct,orientation:pt>=he?"horizontal":"vertical",midX:(at.x+ht.x)/2,midY:(at.y+ht.y)/2})}if(m.length===0)continue;const M=m.length>=3?m.filter(Z=>Z.idx>0&&Z.idx<m.length-1):m,w=M.length>0?M:m,A=v>=S?"horizontal":"vertical",B=c(Z=>[...Z].sort((at,ht)=>{const pt=at.orientation===A,Ct=ht.orientation===A;if(pt!==Ct)return pt?-1:1;const H=at.length>=(at.orientation==="horizontal"?v:S)+2,V=ht.length>=(ht.orientation==="horizontal"?v:S)+2;return H!==V?H?-1:1:ht.length-at.length}),"rankSegments"),P=m[0],E=m[m.length-1],k=[.5,.25,.75,.05,.95,.15,.85,.1,.9],Y=c((Z,at)=>{const ht=u[Z.idx],pt=u[Z.idx+1];return{midX:ht.x+(pt.x-ht.x)*at,midY:ht.y+(pt.y-ht.y)*at}},"anchorAtT"),W=c((Z,at,ht)=>Math.min(ht,Math.max(at,Z)),"clamp"),z=c((Z,at)=>Z.midX>=at.left-he&&Z.midX<=at.right+he&&Z.midY>=at.top-he&&Z.midY<=at.bottom+he,"pointInsideRectInclusive"),Q=c(Z=>{const at=Ue(Z.midX,Z.midY,v,S),ht=p(at);if(ht)return{laneId:ht,anchor:Z,rect:at};const pt=s.find(({rect:gt})=>z(Z,gt));if(!pt)return;const Ct=pt.rect.left+v/2+a,H=pt.rect.right-v/2-a,V=pt.rect.top+S/2+a,ct=pt.rect.bottom-S/2-a;if(Ct>H||V>ct)return;const nt={midX:W(Z.midX,Ct,H),midY:W(Z.midY,V,ct)},dt=Ue(nt.midX,nt.midY,v,S);return z(Z,dt)?{laneId:pt.id,anchor:nt,rect:dt}:void 0},"placementForAnchor"),it=c((Z,at,ht)=>Z.orientation==="horizontal"?Math.abs(at.midX-ht.x):Math.abs(at.midY-ht.y),"distanceAlongSegment"),bt=c((Z,at)=>{const pt=(Z.orientation==="horizontal"?v/2:S/2)+f;if(Z===P){const Ct=u[Z.idx];if(it(Z,at,Ct)+he<pt)return!1}if(Z===E){const Ct=u[Z.idx+1];if(it(Z,at,Ct)+he<pt)return!1}return!0},"labelClearsTerminalEndpoints"),ne=c(Z=>{const at=B(Z);for(const ht of at)for(const pt of k){const Ct=Y(ht,pt);if(!bt(ht,Ct))continue;const H=Q(Ct);if(H&&!fo(H.rect,u)&&!y(x,H.rect)&&!l(x,h.id,H.rect))return{laneId:H.laneId,anchor:H.anchor}}},"tryPool"),Jt=c((Z,at,ht=!1)=>{const pt=B(Z);for(const Ct of pt){const H={midX:Ct.midX,midY:Ct.midY};if(at&&!bt(Ct,H))continue;const V=Q(H);if(V&&!fo(V.rect,u)&&!y(x,V.rect)&&!d(x,V.rect)&&(ht||!b(h.id,V.rect)))return{laneId:V.laneId,anchor:V.anchor}}},"findLaneContainingFallback"),Qt=ne(w)??(w.length<m.length?ne(m):void 0)??Jt(m,!0)??Jt(m,!1)??Jt(m,!1,!0);if(Qt){L.x=Qt.anchor.midX,L.y=Qt.anchor.midY,L.parentId=Qt.laneId;const Z=Ue(Qt.anchor.midX,Qt.anchor.midY,v,S),at=I.findIndex(ht=>ht.labelId===x);at>=0?I[at]={labelId:x,rect:Z}:I.push({labelId:x,rect:Z})}}}c(Ke,"anchorLabelsToPolyline");var Yn=1e-6,Gi=8,os=Gi/2,Yi=3;function uo(t,e,n,{cx:o,cy:s},r,i){var b;const a={x:o,y:s},f=i==="x"?"y":"x",d=Math.sign(r[f]-a[f]);for(const l of t){if(l===e||l.isLayoutOnly||!((b=l.points)!=null&&b.length))continue;if([...l.end===n?[l.points.at(-1)]:[],...l.start===n?[l.points[0]]:[]].some(p=>Math.sign(p[f]-a[f])===d&&Math.abs(p[i]-r[i])<Xo.MIN_ARROWHEAD_SPACING))return!0}return!1}c(uo,"crowdsFaceNeighbour");function ho(t,e){return t<e?`${t}::${e}`:`${e}::${t}`}c(ho,"pairKey");function rr(t,e){const{nodeInfoById:n,realNodeRects:o}=En(e),s=new Map;for(const i of e){const a=i.id;if(!i.isGroup&&i.isEdgeLabel){s.set(a,{w:i.width??0,h:i.height??0});continue}}const r=c((i,a,f,d)=>{const b=ho(a,f);let l=0;const I=c(p=>{if(!p)return;const y=s.get(p);if(!y)return;const h=d==="x"?y.w/2:y.h/2;h>l&&(l=h)},"consider");I(i.labelNodeId);for(const p of t){if(p===i||p.isLayoutOnly)continue;const y=p.start,h=p.end;!y||!h||ho(y,h)===b&&I(p.labelNodeId)}return l>0?l+Yi:0},"labelClearanceFor");for(const i of t){if(i.isLayoutOnly)continue;const a=i.points;if(!To(a,Yn))continue;const f=Bo(i,n,Yn);if(!f)continue;const{srcId:d,dstId:b,srcInfo:l,dstInfo:I,collinearX:p,collinearY:y}=f;if(p===y)continue;let h,x;if(p){const M=I.cy>l.cy;h={x:l.cx,y:M?l.rect.bottom:l.rect.top},x={x:I.cx,y:M?I.rect.top:I.rect.bottom}}else{const M=I.cx>l.cx;h={x:M?l.rect.right:l.rect.left,y:l.cy},x={x:M?I.rect.left:I.rect.right,y:I.cy}}if(Dt(h,x,o,[d,b],1))continue;const L=p?"x":"y",u=r(i,d,b,L),v=u>os?u:os,S=[0,v,-v];let m;for(const M of S){const w={...h},A={...x};if(p){if(w.x+=M,A.x+=M,w.x<=l.rect.left||w.x>=l.rect.right||A.x<=I.rect.left||A.x>=I.rect.right)continue}else if(w.y+=M,A.y+=M,w.y<=l.rect.top||w.y>=l.rect.bottom||A.y<=I.rect.top||A.y>=I.rect.bottom)continue;if(Dt(w,A,o,[d,b],1)||pn(w,A,t,i,{epsilon:Yn}))continue;const B=[w,A];if(uo(t,i,d,l,w,L)||uo(t,i,b,I,A,L)){m??(m=B);continue}i.points=B,m=void 0;break}m&&(i.points=m)}}c(rr,"straightenCollinearSiblingDetours");function go(t,e){const{realNodeRects:f,labelNodeRects:d}=Ee(e.values()),b=c((m,M)=>ye(M,.001).map(w=>({...w,edge:m,interior:w.index>=1&&w.index<=M.length-3})),"segmentsFor"),l=c(()=>{const m=[];for(const M of t){if(M.isLayoutOnly)continue;const w=M.points;!w||w.length<2||m.push(...b(M,Mt(w)))}return m},"allSegments"),I=c((m,M)=>m.horizontal&&M.horizontal?fe(m.a.x,m.b.x,M.a.x,M.b.x)>=8&&Math.abs(m.a.y-M.a.y)<7:m.vertical&&M.vertical?fe(m.a.y,m.b.y,M.a.y,M.b.y)>=8&&Math.abs(m.a.x-M.a.x)<7:!1,"hasCrowdedParallelTrack"),p=c((m,M)=>{const w=m.start,A=m.end,B=b(m,M);if(B.length!==M.length-1)return!1;const P=[w,A].filter(k=>!!k),E=m.labelNodeId?[m.labelNodeId]:[];for(const k of B)if(Dt(k.a,k.b,f,P,-2)||Dt(k.a,k.b,d,E,-2))return!1;for(const k of t){if(k===m||k.isLayoutOnly)continue;const Y=k.points;if(!(!Y||Y.length<2)){for(const W of B)for(const z of b(k,Mt(Y)))if(I(W,z)||Te(W.a,W.b,z.a,z.b,.001))return!1}}return!0},"candidateIsSafe"),y=c((m,M)=>{const w=Mt(m.edge.points??[]);if(w.length<4||m.index>=w.length-1)return;const A=w.map(B=>({...B}));if(m.horizontal)A[m.index].y+=M,A[m.index+1].y+=M;else if(m.vertical)A[m.index].x+=M,A[m.index+1].x+=M;else return;return b(m.edge,A).length===A.length-1?A:void 0},"shiftedCandidate"),h=c((m,M)=>({x:m.x??(M.left+M.right)/2,y:m.y??(M.top+M.bottom)/2}),"nodeCenter"),x=c(m=>{const M=m.edge,w=Mt(M.points??[]);if(w.length!==4||m.index!==1)return;const A=M.start?e.get(M.start):void 0,B=M.end?e.get(M.end):void 0,P=A?ce(A):void 0,E=B?ce(B):void 0,k=w.slice(m.index+2);if(!(!A||!B||!P||!E||k.length===0))return{sourceCenter:h(A,P),targetCenter:h(B,E),sourceRect:P,tail:k}},"sourceDetourContextFor"),L=c((m,M,w,A,B,P)=>{const E=A.y>=w.y,k=E?B.bottom:B.top,Y=k+(E?20:-20);if(E&&m.b.y<=Y+.001||!E&&m.b.y>=Y-.001)return;const W=m.a.x+M;return Mt([{x:w.x,y:k},{x:w.x,y:Y},{x:W,y:Y},{x:W,y:m.b.y},...P],.001)},"verticalSourceDetour"),u=c((m,M,w,A,B,P)=>{const E=A.x>=w.x,k=E?B.right:B.left,Y=k+(E?20:-20);if(E&&m.b.x<=Y+.001||!E&&m.b.x>=Y-.001)return;const W=m.a.y+M;return Mt([{x:k,y:w.y},{x:Y,y:w.y},{x:Y,y:W},{x:m.b.x,y:W},...P],.001)},"horizontalSourceDetour"),v=c((m,M)=>{const w=x(m);if(w){if(m.vertical)return L(m,M,w.sourceCenter,w.targetCenter,w.sourceRect,w.tail);if(m.horizontal)return u(m,M,w.sourceCenter,w.targetCenter,w.sourceRect,w.tail)}},"sourceDetourCandidate"),S=[-7,7,-14,14,-21,21];for(let m=0;m<12;m++){const M=l();let w=!1;for(let A=0;A<M.length&&!w;A++)for(let B=A+1;B<M.length&&!w;B++){const P=M[A],E=M[B];if(P.edge===E.edge||!I(P,E))continue;const k=[P,E].filter(Y=>Y.interior);for(const Y of k){for(const W of S){const z=y(Y,W);if(z&&p(Y.edge,z)){Y.edge.points=z,w=!0;break}const Q=v(Y,W);if(Q&&p(Y.edge,Q)){Y.edge.points=Q,w=!0;break}}if(w)break}}if(!w)return}}c(go,"nudgeSharedInteriorSubpaths");var Xt=.001,ss=2,Tn=c(t=>t==="top"||t==="bottom"?"x":"y","runsAlongFace");function ir(t,e,n){const o=Tn(n),[s,r]=o==="x"?[e.left,e.right]:[e.top,e.bottom];return{top:e.top-t.y,bottom:t.y-e.bottom,left:e.left-t.x,right:t.x-e.right}[n]>-Xt&&t[o]>=s-Xt&&t[o]<=r+Xt}c(ir,"endpointThroughFace");function Cn(t,e,n){const o=t.node.id;return n.every(s=>{if(s===e||s.isLayoutOnly)return!0;const r=s.points??[];return[[s.start,r.at(0)],[s.end,r.at(-1)]].every(([a,f])=>a!==o||!f||!ir(f,t.rect,t.side))})}c(Cn,"faceIsOwn");function mo(t,e){const n=ye(e,Xt);return ye(t,Xt).reduce((o,s)=>o+n.filter(r=>Te(s.a,s.b,r.a,r.b,Xt)).length,0)}c(mo,"strictCrossings");function cr(t,e){const n=ye(e,Xt);return ye(t,Xt).some(o=>n.some(s=>Fo(o.a,o.b,s.a,s.b,Xt)))}c(cr,"overlapsAny");function Go(t,e,n,o){const s=Xo.ROUTE_TOUCH_TOLERANCE;return o.every(r=>{const i=Mt(r.points??[],Xt);return r===t||r.isLayoutOnly||i.length<2?!0:!cr(n,i)&&mo(n,i)<=mo(e,i)&&(!gn(n,i,s)||gn(e,i,s))})}c(Go,"clearOfOtherEdges");function Yo(t,e,n){const o=t.labelNodeId,s=[t.start,t.end].filter(i=>!!i),r=ye(e,Xt);return r.every(i=>{const f=i.index===0||i.index===r.length-1?s:[];return!Dt(i.a,i.b,n.realNodeRects,f,ss)&&!Dt(i.a,i.b,n.labelNodeRects,o?[o]:[],ss)})}c(Yo,"clearOfNodes");var rs=1;function po(t){const e=t&&!t.isGroup?ce(t):void 0;return t&&e?{node:t,rect:e,cx:t.x??0,cy:t.y??0}:void 0}c(po,"placed");function ar(t,e){const n=e.rect.top>t.rect.bottom;if(!n&&e.rect.bottom>=t.rect.top)return;const[o,s]=n?["bottom","top"]:["top","bottom"];return{from:{node:t.node,rect:t.rect,side:o},to:{node:e.node,rect:e.rect,side:s},points:[{x:t.cx,y:n?t.rect.bottom:t.rect.top},{x:t.cx,y:n?e.rect.top:e.rect.bottom}]}}c(ar,"verticalLine");function lr(t,e){const n=e.rect.left>t.rect.right;if(!n&&e.rect.right>=t.rect.left)return;const[o,s]=n?["right","left"]:["left","right"];return{from:{node:t.node,rect:t.rect,side:o},to:{node:e.node,rect:e.rect,side:s},points:[{x:n?t.rect.right:t.rect.left,y:t.cy},{x:n?e.rect.left:e.rect.right,y:t.cy}]}}c(lr,"horizontalLine");function fr(t,e){const n=po(e.get(t.start??"")),o=po(e.get(t.end??""));if(!(!n||!o||n.node===o.node))return n.node.parentId===o.node.parentId?void 0:[n,o]}c(fr,"crossGroupPair");function dr(t,e){const n=fr(t,e);if(!n)return;const[o,s]=n;return Math.abs(o.cx-s.cx)<=rs?ar(o,s):Math.abs(o.cy-s.cy)<=rs?lr(o,s):void 0}c(dr,"straightLineFor");var zi=c((t,e)=>t.length===e.length&&t.every((n,o)=>Math.abs(n.x-e[o].x)<Xt&&Math.abs(n.y-e[o].y)<Xt),"isAlready");function ur(t,e,n,o,s){return Cn(e.from,t,o)&&Cn(e.to,t,o)&&Yo(t,e.points,s)&&Go(t,n,e.points,o)}c(ur,"lineIsClear");function hr(t,e,n,o){const s=dr(t,n),r=Mt(t.points??[],Xt);return!s||r.length<2||zi(r,s.points)||!ur(t,s,r,e,o)?!1:(t.points=s.points,!0)}c(hr,"straighten");function gr(t,e){const n=Ee(e.values());let o=!1;for(const s of t)!s.isLayoutOnly&&hr(s,t,e,n)&&(o=!0);return o}c(gr,"straightenAlignedCrossLaneEdges");var $i=new Set(["question","diamond","diam","decision"]),Vi=c(t=>$i.has(t.shape??""),"isDiamond"),Qe=c((t,e)=>Math.abs(t-e)<Xt,"near"),mr=c((t,e,n)=>t>=e-Xt&&t<=n+Xt,"within");function pr(t,e,n){if(!(!vt(t,e,Xt)||!mr(t.x,n.left,n.right)))return Qe(t.y,n.bottom)&&e.y>t.y?"bottom":Qe(t.y,n.top)&&e.y<t.y?"top":void 0}c(pr,"verticalLegFace");function yr(t,e,n){if(!(!At(t,e,Xt)||!mr(t.y,n.top,n.bottom)))return Qe(t.x,n.right)&&e.x>t.x?"right":Qe(t.x,n.left)&&e.x<t.x?"left":void 0}c(yr,"horizontalLegFace");var Ui=c((t,e,n)=>pr(t,e,n)??yr(t,e,n),"faceOfLeg");function xr(t,e,n,o){const s=Ui(o[0],o[1],n);if(!s)return;const r=Tn(s);return Qe(o[1][r],o[2][r])?void 0:{edge:t,node:e,rect:n,side:s,route:o}}c(xr,"terminalFrom");var ji=c((t,e)=>(e?t.start:t.end)??"","endpointId");function br(t,e,n){const o=Mt(t.points??[],Xt),s=n.get(ji(t,e)),r=s?ce(s):void 0;if(!(!s||!r||o.length<3))return xr(t,s,r,e?o:o.reverse())}c(br,"terminalAt");function Ir({node:t,rect:e,side:n,route:o}){const s=Tn(n),r=(s==="x"?t.x:t.y)??0,i=o[0][s];if(Math.abs(i-r)<Xt)return;if(Vi(t))return r;const[a,f]=s==="x"?[e.left,e.right]:[e.top,e.bottom];return Math.min(i-a,f-i)<=Wn+Xt?r:void 0}c(Ir,"alignedCoord");function Mr(t,e,n,o){const s=Ir(t);if(s===void 0||!Cn(t,t.edge,e))return!1;const r=Tn(t.side),[i,a,...f]=t.route,d=ve(Mt([{...i,[r]:s},{...a,[r]:s},...f],Xt)),b=o?t.route:[...t.route].reverse(),l=o?d:[...d].reverse();return!Yo(t.edge,l,n)||!Go(t.edge,b,l,e)?!1:(t.edge.points=l,!0)}c(Mr,"alignTerminal");function Sr(t,e){const n=Ee(e.values());let o=!1;for(const s of t)if(!s.isLayoutOnly)for(const r of[!0,!1]){const i=br(s,r,e);i&&Mr(i,t,n,r)&&(o=!0)}return o}c(Sr,"alignTerminalLegsToPorts");function vr(t,e,n,o){const s=e.x-t.x,r=e.y-t.y,i=o.x-n.x,a=o.y-n.y,f=s*a-r*i;if(Math.abs(f)<1e-10)return!1;const d=n.x-t.x,b=n.y-t.y,l=(d*a-b*i)/f,I=(d*r-b*s)/f,p=.01;return l>p&&l<1-p&&I>p&&I<1-p}c(vr,"segmentsIntersect");function Cr(t){const e=t.nodes??[],n=t.edges??[],o=[];if(!n.length||!e.length)return o;const s=Rs(e),r=[];for(const a of n){if(a.isLayoutOnly)continue;const f=a.points;if(!f||f.length<2)continue;const d=a.start,b=a.end,l=a.labelNodeId,I=a.id??`${d}->${b}`;for(const p of s)if(!(p.nodeId===d||p.nodeId===b)&&!(l&&p.nodeId===l)){for(let y=0;y<f.length-1;y++)if(An(f[y],f[y+1],p,-1)){o.push({type:"edge-node-overlap",edgeId:I,targetId:p.nodeId,detail:`segment ${y} passes through node "${p.nodeId}"`});break}}for(let p=0;p<f.length-1;p++)r.push({edgeId:I,start:d,end:b,p1:f[p],p2:f[p+1]})}const i=new Set;for(let a=0;a<r.length;a++)for(let f=a+1;f<r.length;f++){const d=r[a],b=r[f];if(d.edgeId!==b.edgeId&&!(d.start===b.start||d.start===b.end||d.end===b.start||d.end===b.end)&&vr(d.p1,d.p2,b.p1,b.p2)){const l=d.edgeId<b.edgeId?`${d.edgeId}|${b.edgeId}`:`${b.edgeId}|${d.edgeId}`;i.has(l)||(i.add(l),o.push({type:"edge-edge-crossing",edgeId:d.edgeId,targetId:b.edgeId,detail:`edges "${d.edgeId}" and "${b.edgeId}" cross`}))}}if(o.length>0){const a=o.filter(d=>d.type==="edge-node-overlap").length,f=o.filter(d=>d.type==="edge-edge-crossing").length;qe.warn(`[SWIMLANE_VALIDATE] ${o.length} issue(s) detected: ${a} edge-node overlap(s), ${f} edge crossing(s)`);for(const d of o)qe.warn(`[SWIMLANE_VALIDATE] ${d.type}: ${d.detail}`)}return o}c(Cr,"validateSwimlanesLayout");function Lr(t,e){const n=gr(t,e);(Sr(t,e)||n)&&(Ke(t,e),Mn(t,e))}c(Lr,"alignTerminalLegsAndRefresh");function wr(t,e){const n=t.nodes??[],o=t.edges??[],s=n.filter(a=>!a.isGroup);if((e==="LR"||e==="RL")&&s.length>0&&!Ws(t,e)||e==="BT"&&s.length>0&&!zs(t))return;for(const a of o){if(a.isLayoutOnly)continue;const f=a.points;!f||f.length<2||(a.points=ve(yn(f)))}or(o,n),rr(o,n),Ks(o,n);const r=new Map;for(const a of n)r.set(String(a.id),a);Ke(o,r),Ps(o,r),qs(o,r),go(o,r),ro(o,r),Js(o,r),io(o,r),Qs(o,r);const i=c(()=>{nr(o,r),ro(o,r),tr(o,r),er(o,r),Ke(o,r),Mn(o,r),io(o,r),Ke(o,r),Mn(o,r)},"finalizeRenderedEdges");i(),go(o,r),i(),Lr(o,r),co(o,r,e),ao(o,r,e),co(o,r,e),ao(o,r,e)}c(wr,"postProcessSwimlaneLayout");function ke(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 i=`${r.id}:${r.src}->${r.dst}`;n.has(i)||(n.add(i),o.push(r))}return{nodes:[...e.keys()],edges:o,layout:t.layout,nodeById:e}}c(ke,"normalizeGraph");function zo(t,e){return t.edges.filter(n=>n.dst===e)}c(zo,"incoming");function Ar(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}c(Ar,"buildSuccessorMap");function $o(t){const e=Ar(t);for(const n of e.values())n.sort((o,s)=>o.localeCompare(s));return e}c($o,"buildSortedSuccessorMap");function Rn(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}c(Rn,"buildInDegreeMap");function Vo(t,e){const n=[...e.entries()].filter(([,a])=>a===0).map(([a])=>a).sort((a,f)=>a.localeCompare(f)),o=new Set(t.edges.flatMap(a=>[a.src,a.dst])),s=c(a=>{var f;return!o.has(a)&&!((f=t.nodeById.get(a))!=null&&f.isGroup)},"isUnconnected"),r=[...e.keys()].filter(a=>e.get(a)===0&&s(a));let i=0;return n.map(a=>s(a)?r[i++]:a)}c(Vo,"sortedZeroInDegreeNodes");function On(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}}c(On,"buildPredecessorSuccessorMaps");function Uo(t,e,n,o){var i,a;let s=0;for(const f of t.nodes)o!=null&&o.skipGroups&&((i=t.nodeById.get(f))!=null&&i.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}c(Uo,"buildLayersFromRanks");function tn(t){const e=Rn(t),n=Vo(t,e),o=[],s=$o(t);for(;n.length;){const r=n.shift();o.push(r);for(const i of s.get(r)??[])if(e.set(i,(e.get(i)??0)-1),(e.get(i)??0)===0){let a=0;for(;a<n.length&&n[a]<i;)a++;n.splice(a,0,i)}}return o.length===t.nodes.length?o:null}c(tn,"topoSortIfAcyclic");function je(t){const e=new Map;let n=0;for(const o of t)e.set(o,n),n++;return e}c(je,"buildLayerIndex");function jo(t){const e=new Array(t.length),n=c((o,s)=>{if(s-o<=1)return 0;const r=o+s>>1;let i=n(o,r)+n(r,s),a=o,f=r,d=o;for(;a<r||f<s;)f>=s||a<r&&t[a]<=t[f]?e[d++]=t[a++]:(e[d++]=t[f++],i+=r-a);for(let b=o;b<s;b++)t[b]=e[b];return i},"count");return n(0,t.length)}c(jo,"countInversions");function Er(t){const e=ke(t),n=new Map;for(const l of e.nodes)n.set(l,[]);for(const l of e.edges)n.get(l.src).push(l);for(const l of n.values())l.sort((I,p)=>I.dst===p.dst?I.id.localeCompare(p.id):I.dst.localeCompare(p.dst));const o=Object.create(null);for(const l of e.nodes)o[l]=0;const s=[],r=c(l=>{o[l]=1;for(const I of n.get(l)??[]){const p=I.dst;o[p]===0?r(p):o[p]===1&&s.push(I)}o[l]=2},"dfs"),i=Rn(e),a=[...e.nodes.filter(l=>(i.get(l)??0)===0),...e.nodes.filter(l=>(i.get(l)??0)!==0)];for(const l of a)o[l]===0&&r(l);const f=new Set(s.map(l=>`${l.id}:${l.src}->${l.dst}`)),d=e.edges.map(l=>f.has(`${l.id}:${l.src}->${l.dst}`)?{id:l.id,src:l.dst,dst:l.src,weight:l.weight,ref:l.ref}:l);return{acyclic:{nodes:[...e.nodes],edges:d,layout:e.layout,nodeById:new Map(e.nodeById)},reversed:s}}c(Er,"removeCycles_DFS");function Tr(t){const e=Ce(t.layout.nodes??[]),n=new Map;for(const o of t.nodes)n.set(o,e.laneIdOf(o));return n}c(Tr,"buildTopLaneMap");function Re(t){const e=Tr(t);return n=>e.get(n)??null}c(Re,"createTopLaneResolver");function Nn(t){const e=t.layout.nodes??[],n=Ce(e),o=e.filter(i=>n.isLane(i.id)),s=o.filter(i=>dn(i)!==void 0);if(s.length>0&&s.length===o.length)return[...s].sort((i,a)=>(dn(i)??0)-(dn(a)??0)).map(i=>i.id);if(!n.hasPools)return[...new Set(o.map(i=>i.id))].reverse();const r=[];for(const i of e)i.parentId||(n.isPool(i.id)?r.push(...n.lanesByPool.get(i.id)??[]):n.isLane(i.id)&&r.push(i.id));return[...new Set(r)].reverse()}c(Nn,"buildTopLaneOrder");function Wo(t,e){const n=Nn(t);if(!e||e.length===0)return n;const o=new Set(n),s=new Set,r=[];for(const i of e)!o.has(i)||s.has(i)||(s.add(i),r.push(i));for(const i of n)s.has(i)||r.push(i);return r}c(Wo,"resolveTopLaneOrder");function Rr(t,e){const n=ke(t),o=(e==null?void 0:e.laneOf)??(()=>null),s=e==null?void 0:e.rankHint,{preds:r}=On(n);for(const m of r.values())m.sort((M,w)=>M.localeCompare(w));const i=tn(n)??[...n.nodes].sort((m,M)=>m.localeCompare(M)),a=new Map;for(const[m,M]of i.entries())a.set(M,m);const f=new Map,d=new Map;for(const m of n.nodes)d.set(m,[]);for(const m of i){const M=(r.get(m)??[]).filter(w=>f.has(w));if(M.length>0){const w=Or(m,M,{laneOf:o,rankHint:s,topoIndex:a});f.set(m,w),d.get(w).push(m)}else f.has(m)||f.set(m,null)}for(const m of n.nodes)f.has(m)||f.set(m,null);const b=new Set;for(const m of n.nodes)(f.get(m)??null)===null&&b.add(m);const l=[...b].sort((m,M)=>{const w=a.get(m)??0,A=a.get(M)??0;return w===A?m.localeCompare(M):w-A}),I=Nr(n),p=new Map;for(const[m,M]of I.entries())p.set(m,[...M].sort((w,A)=>w.localeCompare(A)));const y=Br(p),h=Pr(p),x=new Map;for(const m of n.nodes)x.set(m,[]);for(const m of h)for(const M of m.nodes){const w=x.get(M);w?w.push(m.id):x.set(M,[m.id])}const L=[],u=[],v=new Set,S=c(m=>{if(!v.has(m)){v.add(m),L.push(m);for(const M of d.get(m)??[])S(M);u.push(m)}},"walk");for(const m of l)S(m);for(const m of i)S(m);return{parent:f,children:d,roots:l,componentOf:y,blocks:h,nodeBlocks:x,adjacency:p,preorder:L,postorder:u,topologicalOrder:i}}c(Rr,"buildDrivingTree");function Or(t,e,n){const o=n.laneOf(t);return[...e].sort((r,i)=>{var h,x;const a=n.laneOf(r),f=n.laneOf(i),d=a!=null&&a===o,b=f!=null&&f===o;if(d!==b)return d?-1:1;const l=(h=n.rankHint)==null?void 0:h[r],I=(x=n.rankHint)==null?void 0:x[i];if(l!=null&&I!=null&&l!==I)return I-l;const p=n.topoIndex.get(r)??0,y=n.topoIndex.get(i)??0;return p!==y?p-y:r.localeCompare(i)})[0]}c(Or,"chooseParent");function Nr(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}c(Nr,"buildAdjacency");function Br(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 i of t.get(r)??[])e.has(i)||s.push(i)}}n++}return e}c(Br,"assignComponents");function Pr(t){const e=new Map,n=new Map,o=[],s=[];let r=0;const i=c((a,f)=>{e.set(a,++r),n.set(a,r);for(const d of t.get(a)??[])d!==f&&(e.has(d)?(e.get(d)??0)<(e.get(a)??0)&&(o.push([a,d]),n.set(a,Math.min(n.get(a)??r,e.get(d)??r))):(o.push([a,d]),i(d,a),n.set(a,Math.min(n.get(a)??r,n.get(d)??r)),(n.get(d)??0)>=(e.get(a)??0)&&s.push(Fr(a,d,o,s.length))))},"visit");for(const a of t.keys())e.has(a)||i(a,null);return s}c(Pr,"computeBlocks");function Fr(t,e,n,o){const s=[],r=new Set;for(;n.length>0;){const i=n.pop();if(s.push(i),r.add(i[0]),r.add(i[1]),i[0]===t&&i[1]===e||i[0]===e&&i[1]===t)break}return{id:o,edges:s,nodes:[...r]}}c(Fr,"popBlock");function kr(t,e,n){const o=[...t.nodes],s=new Map;for(const[u,v]of o.entries())s.set(v,u);const r=o.length,i=new Array(r).fill(-1),a=new Array(r).fill(0),f=[],d=new Set;for(const u of o){const v=n.parent.get(u)??null,S=s.get(u);S!=null&&v==null&&(i[S]=-1,a[S]=0,d.has(u)||(d.add(u),f.push(u)))}for(;f.length>0;){const u=f.shift(),v=s.get(u);if(v==null)continue;const S=n.children.get(u)??[];for(const m of S){if(d.has(m))continue;const M=s.get(m);M!=null&&(i[M]=v,a[M]=a[v]+1,d.add(m),f.push(m))}}for(const u of o){if(d.has(u))continue;const v=s.get(u);v!=null&&(i[v]=-1,a[v]=0,d.add(u))}const b=Math.max(1,Math.ceil(Math.log2(Math.max(1,r)))+1),l=Array.from({length:b},()=>new Array(r).fill(-1));for(let u=0;u<r;u++)l[0][u]=i[u];for(let u=1;u<b;u++)for(let v=0;v<r;v++){const S=l[u-1][v];l[u][v]=S===-1?-1:l[u-1][S]}const I=c((u,v)=>{if(u===-1||v===-1)return-1;a[u]<a[v]&&([u,v]=[v,u]);const S=a[u]-a[v];for(let m=0;m<b;m++)if(S>>m&1&&(u=l[m][u],u===-1))return-1;if(u===v)return u;for(let m=b-1;m>=0;m--){const M=l[m][u],w=l[m][v];M===-1||w===-1||M!==w&&(u=M,v=w)}return l[0][u]},"lcaIndex"),p=Array.from({length:r},()=>new Map);for(const u of t.edges){let v=u.src,S=u.dst,m=e[v],M=e[S];if(m==null||M==null||(m>M&&([v,S]=[S,v],[m,M]=[M,m]),m==null||M==null||m===M))continue;const w=s.get(v),A=s.get(S);if(w==null||A==null)continue;const B=I(w,A);if(B===-1)continue;const P=p[B];for(let E=m;E<M;E++)P.set(E,(P.get(E)??0)+1)}const y=new Map,h=c((u,v)=>{if(v.size!==0)for(const[S,m]of v)u.set(S,(u.get(S)??0)+m)},"mergeInto"),x=new Set,L=c(u=>{const v=s.get(u);x.add(u);const S=v==null?void 0:p[v],m=S?new Map(S):new Map,M=n.children.get(u)??[];for(const w of M){const A=L(w),B=e[u];if(B!=null){let P=y.get(u);P||(P=new Map,y.set(u,P));let E=A.get(B)??0;const k=e[w];k!=null&&k>B&&(E+=1),P.set(w,E)}h(m,A)}return m},"dfs");for(const u of n.roots)x.has(u)||L(u);for(const u of o)x.has(u)||L(u);return y}c(kr,"computeSubtreeCrossCounts");function _r(t,e,n){const o=new Map,s=c(r=>{let i=n[r]??0;const a=[...e.get(r)??[]];a.sort(Ko(n));for(const f of a){s(f);const d=o.get(f);d!=null&&(i=Math.min(i,d))}o.set(r,i)},"annotate");for(const r of t)s(r);return o}c(_r,"annotateMinimumLayers");function Ko(t){return(e,n)=>{const o=t[e]??0,s=t[n]??0;return o===s?e.localeCompare(n):o-s}}c(Ko,"compareByRankThenId");function Hr(t,e,n,o){let s=0;for(const f of e){const d=n[f]??0;d>s&&(s=d)}const r=Array.from({length:s+1},()=>[]),i=new Set,a=c(f=>{if(i.has(f))return;i.add(f);const d=n[f]??0;r[d]||(r[d]=[]),r[d].push(f);for(const b of o(f))a(b)},"emit");for(const f of t)a(f);for(const f of e)if(!i.has(f)){const d=n[f]??0;r[d]||(r[d]=[]),r[d].push(f),i.add(f)}return r}c(Hr,"emitNodesInTreeOrder");function Dr(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}c(Dr,"deduplicateLayers");function Xr(t,e,n,o){return s=>{const r=t.get(s)??[];if(r.length===0)return[];const i=e[s]??0,a=[],f=[],d=n.get(s);for(const b of r){const l=o.get(b)??i;l>i?a.push({child:b,min:l}):f.push(b)}return a.sort((b,l)=>b.min===l.min?b.child.localeCompare(l.child):b.min-l.min),f.sort((b,l)=>{const I=(d==null?void 0:d.get(b))??0,p=(d==null?void 0:d.get(l))??0;if(I!==p)return I-p;const y=o.get(b)??i,h=o.get(l)??i;return y!==h?y-h:b.localeCompare(l)}),[...a.map(b=>b.child),...f]}}c(Xr,"createChildOrderer");function Ln(t,e,n){const o=Rr(t,{rankHint:e,laneOf:n}),{children:s,roots:r}=o;for(const l of t.nodes)s.has(l)||s.set(l,[]);const i=kr(t,e,o),a=[...r].sort(Ko(e)),f=_r(a,s,e),d=Xr(s,e,i,f);let b=Hr(a,t.nodes,e,d);return b=Dr(b),b}c(Ln,"buildMultitreeLayerOrder");function Gr(t,e,n){const o=new Set(t),s=new Set(e),r=je(e),i=[];for(const a of n)o.has(a.src)&&s.has(a.dst)&&i.push(r.get(a.dst));return jo(i)}c(Gr,"countCrossingsBetweenAdjacent");function yo(t,e,n){const o=[];for(const r of e){const i=n[r.src],a=n[r.dst];if(i==null||a==null||i===a)continue;let f=r.src,d=r.dst,b=i,l=a;i>a&&(f=r.dst,d=r.src,b=a,l=i);for(let I=b;I<l;I++)o.push({id:`${r.id}@${I}`,src:f,dst:d,ref:r.ref})}let s=0;for(let r=0;r+1<t.length;r++)s+=Gr(t[r],t[r+1],o);return s}c(yo,"totalCrossings");function Yr(t,e){const n={...e},{preds:o}=On(t),s=Re(t),r=Ln(t,n,s);let i=yo(r,t.edges,n);const a=vn.MAX_CROSSING_OPTIMIZATION_PASSES;for(let f=0;f<a;f++){let d=!1;const b=[...t.nodes].sort((l,I)=>(n[I]??0)-(n[l]??0));for(const l of b){const I=n[l]??0;if(I===0)continue;let p=0;for(const L of o.get(l)??[])p=Math.max(p,(n[L]??0)+1);if(p>=I)continue;const y=I;n[l]=p;const h=Ln(t,n,s),x=yo(h,t.edges,n);x<i?(i=x,d=!0):n[l]=y}if(!d)break}return n}c(Yr,"optimizeRanksByCrossings");function zr(t,e){const n=Re(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 i=t.edges.filter(h=>h.src===s);if(i.length===0)continue;let a=!1,f=0;for(const h of i){const x=n(h.dst);x==null||x===r?a=!0:f++}if(f===0||a)continue;let d=0,b=!1;for(const h of t.edges){if(h.dst!==s)continue;const x=n(h.src);x&&(x===r?b=!0:d++)}if(d>0||!b)continue;const l=e[s]??0,I=l+f;let p=0;for(const h of t.edges)h.dst===s&&(p=Math.max(p,(e[h.src]??0)+1));const y=Math.max(l,p,I);y!==l&&(e[s]=y)}}c(zr,"adjustCrossLaneSources");function $r(t,e){const n=ke(t),o=tn(n)??[...n.nodes].sort(),s=(e==null?void 0:e.compactSingleInput)??!1,r=Re(n);let i=Object.create(null);for(const f of o){const d=zo(n,f),b=e!=null&&e.ignoreCrossLaneEdges?d.filter(l=>{const I=r(l.src),p=r(f);return!I||!p?!0:I===p}):d;if(b.length===0)i[f]=0;else if(s&&b.length===1){const l=b[0].src,I=r(l),p=r(f);I!==p?i[f]=i[l]??0:i[f]=(i[l]??0)+1}else{let l=-1/0;for(const I of b)l=Math.max(l,(i[I.src]??0)+1);i[f]=l===-1/0?0:l}}return((e==null?void 0:e.optimizeRanksByCrossings)??!1)&&(i=Yr(n,i)),e!=null&&e.ignoreCrossLaneEdges&&zr(n,i),{layers:Ln(n,i,r),rankOf:i,dummy:new Set}}c($r,"assignLayers_LongestPath");function Vr(t,e){const n=ke(t),s={...$r(n,{compactSingleInput:e==null?void 0:e.compactSingleInput,ignoreCrossLaneEdges:e==null?void 0:e.ignoreCrossLaneEdges,optimizeRanksByCrossings:e==null?void 0:e.optimizeRanksByCrossings}).rankOf},r=Re(n),{preds:i,succs:a}=On(n,y=>{if(e!=null&&e.ignoreCrossLaneEdges){const h=r(y.src),x=r(y.dst);if(h&&x&&h!==x)return!1}return!0}),f=tn(n)??[...n.nodes],d=[...f].reverse(),b=c((y,h)=>{let x=0;for(const v of i.get(y)??[])x=Math.max(x,(s[v]??0)+1);let L=Number.POSITIVE_INFINITY;const u=a.get(y)??[];return u.length>0&&(L=Math.min(...u.map(v=>(s[v]??0)-1))),Number.isFinite(L)||(L=Math.max(x,h)),Math.min(Math.max(h,x),L)},"clampFeasible"),l=vn.GRAVITY_ITERATIONS,I=c(y=>{let h=!1;for(const x of y){const L=i.get(x)??[],u=a.get(x)??[];if(L.length===0&&u.length===0)continue;const v=L.length>0?L.reduce((w,A)=>w+(s[A]??0)+1,0)/L.length:s[x]??0,S=u.length>0?u.reduce((w,A)=>w+(s[A]??0)-1,0)/u.length:s[x]??0,m=Math.round((v+S)/2),M=b(x,m);M!==s[x]&&(s[x]=M,h=!0)}return h},"relaxOrder");for(let y=0;y<l;y++){const h=I(f),x=I(d);if(!h&&!x)break}for(const y of f){let h=0;for(const x of i.get(y)??[])h=Math.max(h,(s[x]??0)+1);(s[y]??0)<h&&(s[y]=h)}for(const y of d){const h=a.get(y)??[];if(h.length>0){const x=Math.min(...h.map(L=>(s[L]??0)-1));(s[y]??0)>x&&(s[y]=x)}}return{layers:Uo(n,f,s),rankOf:s,dummy:new Set}}c(Vr,"assignLayers_Gravity");function Ur(t){const e=Rn(t),n=$o(t);let o=Vo(t,e);const s=[];for(;o.length>0;){const r=[];for(const i of o){s.push(i);for(const a of n.get(i)??[])e.set(a,(e.get(a)??0)-1),(e.get(a)??0)===0&&r.push(a)}o=r.sort((i,a)=>i.localeCompare(a))}return s.length===t.nodes.length?s:null}c(Ur,"topoSortByGenerationIfAcyclic");function jr(t,e){const n=ke(t),o=(e==null?void 0:e.direction)==="LR"?Ur(n)??[...n.nodes].sort():tn(n)??[...n.nodes].sort(),s=Re(n),r=c(b=>s(b)??b,"laneOf"),i=Object.create(null),a=new Map,f=c((b,l)=>(e==null?void 0:e.ignoreCrossLaneEdges)??!0?r(b)===r(l)?1:0:1,"edgeWeight");for(const b of o){const l=n.nodeById.get(b);if(l!=null&&l.isGroup)continue;const I=zo(n,b);let p=0;if(I.length>0)for(const L of I){const u=L.src,v=i[u]??0;p=Math.max(p,v+f(u,b))}const y=r(b),h=a.get(y)??0,x=Math.max(p,h);i[b]=x,a.set(y,x+1)}return{layers:Uo(n,o,i,{skipGroups:!0}),rankOf:i,dummy:new Set}}c(jr,"assignLayers_LaneAwareCompact");function Wr(t,e){const n=ke(e),{rankOf:o}=t,s=t.layers.map(p=>[...p]),r=new Set(t.dummy?[...t.dummy]:[]);let i=0;const a=new Map(n.nodeById),f=c(p=>{const y=`placeholder-${i++}`,h={id:y,isGroup:!1,isDummy:!0,width:0,height:0};for(a.set(y,h),r.add(y);s.length<=p;)s.push([]);return s[p].push(y),o[y]=p,y},"addDummyAt"),d=[...n.edges].sort((p,y)=>p.id===y.id?p.src===y.src?p.dst.localeCompare(y.dst):p.src.localeCompare(y.src):p.id.localeCompare(y.id)),b=[];for(const p of d){const y=o[p.src]??0,h=o[p.dst]??0;if(h-y<=1){b.push(p);continue}let x=p.src;for(let u=y+1,v=0;u<h;u++,v++){const S=f(u);b.push({id:`${p.id}#${v}`,src:x,dst:S,weight:p.weight,ref:p.ref}),x=S}const L=h-y-2;b.push({id:`${p.id}#${Math.max(L+1,0)}`,src:x,dst:p.dst,weight:p.weight,ref:p.ref})}const I={nodes:[...n.nodes,...[...r].filter(p=>!n.nodes.includes(p))],edges:b,layout:n.layout,nodeById:a};return{layering:{layers:s,rankOf:o,dummy:r},graphWithDummies:I}}c(Wr,"makeProperLayering");function xo(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])}c(xo,"median");function bo(t){return t.length===0?Number.POSITIVE_INFINITY:t.reduce((n,o)=>n+o,0)/t.length}c(bo,"barycenter");function Kr(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}c(Kr,"neighborPositionsFor");function qr(t,e,n){const o=n.get(t)??0,s=n.get(e)??0;return o!==s?o-s:t.localeCompare(e)}c(qr,"currentOrderTieBreak");function Io(t,e,n){const o=new Set(t),s=new Set(e),r=je(t),i=je(e),a=[];for(const d of n)o.has(d.src)&&s.has(d.dst)&&a.push({u:r.get(d.src),v:i.get(d.dst)});a.sort((d,b)=>d.u===b.u?d.v-b.v:d.u-b.u);const f=a.map(d=>d.v);return jo(f)}c(Io,"countCrossingsBetweenAdjacent");function un(t,e,n){return[...t].sort((o,s)=>{const r=xo(e.get(o)??[]),i=xo(e.get(s)??[]);return r===i?qr(o,s,n):isFinite(r)?isFinite(i)?r-i:-1:1})}c(un,"sortByHeuristic");function Mo(t,e,n,o,s,r){const i=je(t),a=je(e),f=Kr(e,i,n,o);if(!s||!r||r.length===0)return un(e,f,a);const d=new Map;for(const I of e){const p=s(I),y=d.get(p)??[];y.push(I),d.set(p,y)}const b=[];for(const I of r){const p=d.get(I);if(!p||p.length===0)continue;const y=un(p,f,a);b.push(...y)}const l=d.get(null);if(l&&l.length>0){const I=un(l,f,a);for(const p of I){const y=bo(f.get(p)??[]);let h=b.length;if(isFinite(y))for(const[x,L]of b.entries()){const u=bo(f.get(L)??[]);if(y<u){h=x;break}}b.splice(h,0,p)}}return b}c(Mo,"reorderLayer");function So(t,e,n,o,s){const r=[...e],i=new Set(t),a=new Set(e),f=o?new Set(o):null,d=n.filter(h=>i.has(h.src)&&a.has(h.dst)),b=f?n.filter(h=>a.has(h.src)&&f.has(h.dst)):void 0,l=c(h=>{let x=Io(t,h,d);return b&&o&&(x+=Io(h,o,b)),x},"crossingScore"),I=s?new Map:null;if(s&&I)for(const h of e)I.set(h,s(h));let p=!0,y=l(r);for(;p;){p=!1;for(let h=0;h+1<r.length;h++){if(I){const u=I.get(r[h]),v=I.get(r[h+1]);if(u!==v)continue}const x=y;[r[h],r[h+1]]=[r[h+1],r[h]];const L=l(r);L<x?(y=L,p=!0):[r[h],r[h+1]]=[r[h+1],r[h]]}}return r}c(So,"transposeImprove");function Zr(t,e,n){const o=t.layers.map(a=>[...a]),s=e.edges,r=Re(e),i=Wo(e,n==null?void 0:n.laneOrder);for(let a=0;a<3;a++){for(let f=1;f<o.length;f++)o[f]=Mo(o[f-1],o[f],s,"down",r,i),o[f]=So(o[f-1],o[f],s,o[f+1],r);for(let f=o.length-2;f>=0;f--)o[f]=Mo(o[f+1],o[f],s,"up",r,i),o[f]=So(o[f+1],o[f],s,o[f-1],r)}return{layers:o}}c(Zr,"orderLayers");function Jr(t,e,n){var ht,pt,Ct;const o=(n==null?void 0:n.layerGap)??Xn.DEFAULT_LAYER_GAP,s=(n==null?void 0:n.nodeGap)??Xn.DEFAULT_NODE_GAP,r=(n==null?void 0:n.laneGap)??s*2,i=(n==null?void 0:n.direction)??"TB",a=i==="LR"||i==="RL",f=Object.create(null),d=Object.create(null),b=new Map((((ht=e.layout)==null?void 0:ht.nodes)??[]).filter(H=>H.isEdgeLabel).map(H=>[H.id,H])),l=c(H=>b.get(H)??e.nodeById.get(H),"getNode"),I=c(H=>{var V;return((V=l(H))==null?void 0:V.width)??0},"getWidth"),p=c(H=>{var V;return((V=l(H))==null?void 0:V.height)??0},"getHeight"),y=Re(e),h=new Map,x=c(H=>h.has(H)?h.get(H)??null:y(H),"topLaneOf"),L=Wo(e,n==null?void 0:n.laneOrder),u=new Set;for(const H of t.layers)for(const V of H)u.add(y(V));const v=u.has(null),S=L.filter(H=>u.has(H)),m=[...v?[null]:[],...S],M=t.layers,w=new Map;for(const[H,V]of M.entries())for(const ct of V)w.set(ct,H);const A=[],B=[],P=[];for(const H of((pt=e.layout)==null?void 0:pt.edges)??[]){const V=H.labelNodeId,ct=H.start,nt=H.end;if(!V||!b.has(V)||ct==null||nt==null)continue;const dt=w.get(ct),gt=w.get(nt);if(dt==null||gt==null){P.push({labelId:V,near:dt==null?nt:ct});continue}if(h.set(V,y(nt)),dt===gt){const Et=c(Vt=>m.indexOf(y(Vt)),"column");A.push({labelId:V,rank:gt,lane:y(nt),side:ct!==nt&&Et(ct)<Et(nt)?"before":"after"});continue}const It=Math.min(dt,gt),mt=Math.max(dt,gt);B.push({labelId:V,start:ct,end:nt,gap:It+Math.floor((mt-It-1)/2),crossesLanes:y(ct)!==y(nt)})}const E=M.map(H=>H.reduce((V,ct)=>Math.max(V,p(ct)),0));for(const{labelId:H,rank:V}of A)E[V]=Math.max(E[V],p(H));const k=M.map(()=>0);if(a)for(let H=0;H+1<M.length;H++){const V=M[H].reduce((mt,Et)=>Math.max(mt,I(Et)),0),ct=M[H+1].reduce((mt,Et)=>Math.max(mt,I(Et)),0),nt=E[H],dt=E[H+1],gt=nt/2+dt/2,It=(V+ct)/2;k[H]=Math.max(0,It-gt-o)}const Y=a?Do(((Ct=e.layout)==null?void 0:Ct.nodes)??[]):1,W=M.map(()=>0);for(const{labelId:H,gap:V}of B){const nt=((a?I(H):p(H))+2*Xn.EDGE_LABEL_CLEARANCE)/Y;W[V]=Math.max(W[V],nt)}for(const[H,V]of W.entries())k[H]+=V;const z=Object.create(null);for(const H of S)z[H]=0;v&&(z.null=0);for(const H of M){const V=Object.create(null),ct=[];for(const nt of H){const dt=x(nt);dt===null?ct.push(nt):(V[dt]||(V[dt]=[])).push(nt)}for(const[nt,dt]of Object.entries(V)){const gt=dt.reduce((It,mt)=>It+I(mt),0)+s*Math.max(0,dt.length-1);z[nt]=Math.max(z[nt]??0,gt)}if(v&&ct.length){const nt=ct.reduce((dt,gt)=>dt+I(gt),0)+s*Math.max(0,ct.length-1);z.null=Math.max(z.null??0,nt)}}const Q=new Map;for(const H of B){const V=`${H.gap}:${x(H.labelId)}`,ct=Q.get(V);ct?ct.push(H):Q.set(V,[H])}for(const H of Q.values()){const V=x(H[0].labelId);if(V!==null){const ct=H.reduce((nt,dt,gt)=>nt+I(dt.labelId)+(gt>0?s:0),0);z[V]=Math.max(z[V]??0,ct)}}const it=new Map;for(const{labelId:H,rank:V,lane:ct,side:nt}of A){const dt=`${V}:${ct}:${nt}`;it.set(dt,(it.get(dt)??0)+s+I(H))}const bt=c((H,V,ct)=>it.get(`${H}:${V}:${ct}`)??0,"rowLabelSpan");for(const{rank:H,lane:V}of A){const ct=M[H].filter(gt=>x(gt)===V).reduce((gt,It,mt)=>gt+I(It)+(mt>0?s:0),0),nt=Math.max(bt(H,V,"before"),bt(H,V,"after")),dt=V??"null";z[dt]=Math.max(z[dt]??0,ct+2*nt)}const ne=new Map;{const H=m.map(nt=>(nt===null?z.null:z[nt])??0);let ct=-(H.reduce((nt,dt)=>nt+dt,0)+r*Math.max(0,m.length-1))/2;for(let nt=0;nt<m.length;nt++){const dt=m[nt],gt=H[nt]??0,It=ct+gt/2;ne.set(dt,It),ct+=gt,nt<m.length-1&&(ct+=r)}}const Jt=[];let Qt=0;for(const[H,V]of M.entries()){const ct=E[H]??0,nt=new Map;for(const gt of V){const It=x(gt),mt=nt.get(It)??[];mt.push(gt),nt.set(It,mt)}for(const gt of m){const It=nt.get(gt)??[];if(It.length===0)continue;const mt=ne.get(gt);if(It.length===1){const Et=It[0];f[Et]=mt,d[Et]=Qt+ct/2}else{const Et=It.map(Le=>I(Le)),Vt=Et.reduce((Le,T)=>Le+T,0)+s*(It.length-1);let _e=mt-Vt/2;for(const[Le,T]of It.entries()){const F=Et[Le];f[T]=_e+F/2,d[T]=Qt+ct/2,_e+=F+s}}}const dt=o+(k[H]??0);Jt[H]=Qt+ct+dt/2,Qt+=ct+dt}const Z=new Map;for(const{labelId:H,rank:V,lane:ct,side:nt}of A){const dt=`${V}:${ct}:${nt}`;if(!Z.has(dt)){const Et=M[V].filter(Vt=>x(Vt)===ct).map(Vt=>nt==="before"?f[Vt]-I(Vt)/2:f[Vt]+I(Vt)/2);Z.set(dt,nt==="before"?Math.min(...Et):Math.max(...Et))}const gt=I(H),It=Z.get(dt)+(nt==="before"?-1:1)*(s+gt/2);f[H]=It,d[H]=d[M[V].find(mt=>x(mt)===ct)],Z.set(dt,It+(nt==="before"?-1:1)*(gt/2))}for(const H of Q.values()){const V=H.map(({start:mt,end:Et,crossesLanes:Vt})=>Vt?f[Et]:((f[mt]??0)+(f[Et]??0))/2),ct=H.map((mt,Et)=>Et).sort((mt,Et)=>V[mt]-V[Et]||mt-Et),nt=[];let dt=-1/0;for(const mt of ct){const Et=I(H[mt].labelId);nt[mt]=Math.max(V[mt],dt+s+Et/2),dt=nt[mt]+Et/2}const gt=c(mt=>mt.reduce((Et,Vt)=>Et+Vt,0)/mt.length,"mean"),It=gt(V)-gt(nt);for(const[mt,{labelId:Et,gap:Vt}]of H.entries())f[Et]=nt[mt]+It,d[Et]=Jt[Vt]}for(const{labelId:H,near:V}of P)f[H]=f[V]??0,d[H]=d[V]??0;const at=new Map;for(const H of e.edges){const V=H.ref.id;at.has(V)||at.set(V,[]),at.get(V).push(H)}for(const[,H]of at){if(H.length===0)continue;const V=H[0].ref,ct=V.start,nt=V.end;if(ct==null||nt==null)continue;const dt=Math.round(((f[ct]??0)+(f[nt]??0))/2),gt=new Set;for(const It of H)gt.add(It.src),gt.add(It.dst);for(const It of gt){if(It===ct||It===nt)continue;const mt=e.nodeById.get(It);mt!=null&&mt.isDummy&&(f[It]=dt)}}return{x:f,y:d}}c(Jr,"assignCoordinates");var Qr=8;function ti(t){let e=2166136261;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e>>>0}c(ti,"hashString");function ei(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}}c(ei,"mulberry32");function ni(t,e){const n=[...t],o=ei(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}c(ni,"deterministicShuffle");function oi(t,e){let n=0;for(const[o,s]of t.entries())n+=Math.abs(o-(e.get(s)??o));return n}c(oi,"sourceDistance");function vo(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:i}of e){const a=n.get(s),f=n.get(r);a==null||f==null||(o+=i*Math.abs(a-f))}return o}c(vo,"laneArrangementCost");function si(t){const e=Nn(t);if(e.length<2)return[];const n=new Map(e.map((r,i)=>[r,i])),o=Re(t),s=new Map;for(const r of t.layout.edges??[]){if(r.isLayoutOnly)continue;const i=typeof r.start=="string"?r.start:void 0,a=typeof r.end=="string"?r.end:void 0;if(!i||!a||!t.nodeById.has(i)||!t.nodeById.has(a))continue;const f=o(i),d=o(a);if(!f||!d||f===d)continue;const b=n.get(f),l=n.get(d);if(b==null||l==null)continue;const[I,p]=b<=l?[f,d]:[d,f],y=`${I}\0${p}`,h=s.get(y);h?h.weight++:s.set(y,{a:I,b:p,weight:1})}return[...s.values()]}c(si,"buildWeightedLaneEdges");function Co(t,e,n){const o=[...t];let s=vo(o,e),r=!0,i=0;const a=Math.max(1,o.length);for(;r&&i<a;){r=!1,i++;for(let f=0;f+1<o.length;f++){[o[f],o[f+1]]=[o[f+1],o[f]];const d=vo(o,e);d<s?(s=d,r=!0):[o[f],o[f+1]]=[o[f+1],o[f]]}}return{order:o,cost:s,sourceDistance:oi(o,n)}}c(Co,"greedySwitch");function ri(t,e){return t.cost!==e.cost?t.cost<e.cost:t.sourceDistance<e.sourceDistance}c(ri,"isBetterCandidate");function ii(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:i})=>`${s}:${r}:${i}`).join("|");return ti(`${t.join("|")}#${o}#${n}`)}c(ii,"seedForRestart");function ci(t,e={}){const n=Nn(t);if(n.length<2)return n;const o=si(t);if(o.length===0)return n;const s=new Map(n.map((a,f)=>[a,f]));let r=Co(n,o,s);const i=Math.max(0,e.restarts??Qr);for(let a=0;a<i;a++){const f=ii(n,o,a),d=ni(n,f),b=Co(d,o,s);ri(b,r)&&(r=b)}return r.order}c(ci,"optimizeTopLaneOrder");function ai(t,e){const n=(e==null?void 0:e.ignoreCrossLaneEdges)??!0,o=(e==null?void 0:e.optimizeRanksByCrossings)??!0,s=ke(t),r=e!=null&&e.automaticLaneOrdering?ci(s,{restarts:Qr}):void 0,i=Er(s),a=i.acyclic,f=n?jr(a,{compactSingleInput:(e==null?void 0:e.compactSingleInput)??vn.DEFAULT_COMPACT_SINGLE_INPUT,ignoreCrossLaneEdges:!0,direction:e==null?void 0:e.direction}):Vr(a,{compactSingleInput:(e==null?void 0:e.compactSingleInput)??vn.DEFAULT_COMPACT_SINGLE_INPUT,ignoreCrossLaneEdges:!1,optimizeRanksByCrossings:o}),{layering:d,graphWithDummies:b}=Wr(f,a),l=Zr(d,b,{laneOrder:r}),I=Jr(l,b,{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:i.reversed,layering:d,ordered:l,coordinates:I}}c(ai,"sugiyamaLayout");var yt=Di.EPSILON,Wi=8,De=15,Ve=15,fn=25,Ie=20,zn=10;function Lo(t,e,n){const o=t.x??0,s=t.y??0,r=e.x-o,i=e.y-s,a=Math.abs(r),f=Math.abs(i);return a<yt&&f<yt?n:f>yt&&f*3>=a?i>0?"bottom":"top":a>yt?r>0?"right":"left":n}c(Lo,"chooseOrthogonalSide");var is=c(t=>typeof t=="number"&&Number.isFinite(t)&&t>0,"isDrawableSize");function hn(t,e){var o;const n=(o=t.metadata)==null?void 0:o.drawnExtent;return{w:is(n==null?void 0:n.width)?n.width:t.width??e,h:is(n==null?void 0:n.height)?n.height:t.height??e}}c(hn,"drawnSize");function wo(t,e){return Math.abs(t.to-e.from)<yt||Math.abs(t.to-e.to)<yt?t.to:t.from}c(wo,"sharedLineEndpointCoord");function Xe(t,e){return t.orient==="vertical"?{x:t.coord,y:e}:{x:e,y:t.coord}}c(Xe,"pointOnLine");function li(t,e){var Lt,Ht,jt,xe,oe,ee;const n=t.nodes??[],o=t.edges??[],s=[];for(const g of o)g.isLayoutOnly||s.push({...g,__originalEdge:g});const r=new Map,i=new Map,a=[],f=e==="LR";for(const g of n)r.set(g.id,g);const d=Ce(n),b=n.filter(g=>d.isLane(g.id));for(const g of b){const C={id:g.id},O=c(R=>{i.set(R.id,C),n.filter(N=>N.parentId===R.id).forEach(O)},"assignLane");O(g)}const l=We(n),I=n.filter(g=>!g.isGroup&&!g.isEdgeLabel&&!l.has(g.id)).map(g=>{const C=g.width??10,O=g.height??10,R=g.x??0,N=g.y??0,D=Wi;return{nodeId:g.id,minX:R-C/2-D,maxX:R+C/2+D,minY:N-O/2-D,maxY:N+O/2+D,visualXHalfExtent:f?O/2+D:C/2+D}}),p=c((g,C,O,R)=>{let N=a.find(D=>D.orientation===g&&Math.abs(D.coord-C)<1);return N||(N={id:`pipe-${g}-${C.toFixed(0)}`,orientation:g,coord:C,spanMin:O,spanMax:R,tracks:[]},a.push(N)),N.spanMin=Math.min(N.spanMin,O),N.spanMax=Math.max(N.spanMax,R),N},"getOrAddPipe"),y=c((g,C)=>{const{w:O,h:R}=hn(g,10),N=g.x??0,D=g.y??0;switch(C){case"top":return{x:N,y:D-R/2};case"bottom":return{x:N,y:D+R/2};case"left":return{x:N-O/2,y:D};case"right":return{x:N+O/2,y:D}}},"portForSide"),h=c((g,C,O)=>y(g,Lo(g,C,O?"bottom":"top")),"getOrthogonalPort"),x=[],L=[],u=new Set,v=1e3,S=c((g,C,O)=>{if(x.length===0)return 0;const R=Math.abs(C.y-O.y)<yt,N=Math.abs(C.x-O.x)<yt;if(!R&&!N)return 0;let D=0;if(R){const J=C.y,ft=Math.min(C.x,O.x)-yt,K=Math.max(C.x,O.x)+yt;if(K<=ft)return 0;for(const U of x)U.edgeIndex===g||U.orientation!=="vertical"||U.pipe.coord<ft||U.pipe.coord>K||U.from-yt<=J&&U.to+yt>=J&&(D+=v)}else if(N){const J=C.x,ft=Math.min(C.y,O.y)-yt,K=Math.max(C.y,O.y)+yt;if(K<=ft)return 0;for(const U of x)U.edgeIndex===g||U.orientation!=="horizontal"||U.pipe.coord<ft||U.pipe.coord>K||U.from-yt<=J&&U.to+yt>=J&&(D+=v)}return D},"crossingPenalty"),m=s.map((g,C)=>{if(!g.start||!g.end)return{idx:C,crossLane:0,dx:0,dy:0};const O=r.get(g.start),R=r.get(g.end),N=i.get(g.start),D=i.get(g.end),J=N&&D&&N.id!==D.id?1:0,ft=O&&R?Math.abs((R.x??0)-(O.x??0)):0,K=O&&R?Math.abs((R.y??0)-(O.y??0)):0;return{idx:C,crossLane:J,dx:ft,dy:K}}).sort((g,C)=>{if(g.crossLane!==C.crossLane)return C.crossLane-g.crossLane;const O=g.dx+g.dy,R=C.dx+C.dy;return Math.abs(O-R)>1?O-R:g.idx-C.idx}).map(g=>g.idx),M=c((g,C,O,R)=>{const N=Math.min(g.x,C.x),D=Math.max(g.x,C.x),J=Math.min(g.y,C.y),ft=Math.max(g.y,C.y);return!!I.find(U=>O&&U.nodeId===O||R&&U.nodeId===R?!1:Math.abs(g.x-C.x)>yt?U.minY<g.y&&U.maxY>g.y&&U.maxX>N&&U.minX<D:U.minX<g.x&&U.maxX>g.x&&U.maxY>J&&U.minY<ft)},"isSegmentBlocked"),w=new Map,A=new Map;for(const g of s)!g.start||!g.end||g.start===g.end||(A.set(g.start,(A.get(g.start)??0)+1),A.set(g.end,(A.get(g.end)??0)+1));const B=c((g,C)=>Lo(g,C,"bottom"),"determineSide"),P=new Map;for(const[g,C]of s.entries()){if(!C.start||!C.end||C.start===C.end||C.points&&C.points.length>0)continue;const O=r.get(C.start),R=r.get(C.end);if(!O||!R)continue;const N=(R.x??0)-(O.x??0),D=(R.y??0)-(O.y??0);P.set(g,{edgeIdx:g,srcId:C.start,dstId:C.end,srcSide:B(O,{x:R.x??0,y:R.y??0}),dstSide:B(R,{x:O.x??0,y:O.y??0}),absDx:Math.abs(N),absDy:Math.abs(D),dxSign:Math.sign(N),dySign:Math.sign(D)})}const E=c(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"),k=c(g=>g.srcSide==="top"||g.srcSide==="bottom"?g.dxSign===0?["right","left"]:[g.dxSign>0?"right":"left"]:g.dySign===0?["bottom","top"]:[g.dySign>0?"bottom":"top"],"secondarySides"),Y=c(g=>k(g)[0],"secondarySide"),W=new Map;for(const g of P.values()){const C=`${g.srcId}:${g.srcSide}`;W.has(C)||W.set(C,[]),W.get(C).push(g)}const z=new Map,Q=c((g,C)=>`${g}:${C}`,"loadKey");for(const g of P.values())z.set(Q(g.srcId,g.srcSide),(z.get(Q(g.srcId,g.srcSide))??0)+1),z.set(Q(g.dstId,g.dstSide),(z.get(Q(g.dstId,g.dstSide))??0)+1);for(const g of W.values())if(!(g.length<2)){g.sort((C,O)=>{const R=E(C),N=E(O);return Math.abs(R-N)>1e-9?N-R:C.edgeIdx-O.edgeIdx});for(let C=1;C<g.length;C++){const O=g[C],R=z.get(Q(O.srcId,O.srcSide))??0,N=k(O).reduce((J,ft)=>(z.get(Q(O.srcId,ft))??0)<(z.get(Q(O.srcId,J))??0)?ft:J),D=z.get(Q(O.srcId,N))??0;D>=R||(z.set(Q(O.srcId,O.srcSide),R-1),z.set(Q(O.srcId,N),D+1),O.srcSide=N)}}const it=c(g=>{const C=g==null?void 0:g.shape;return C==="question"||C==="diamond"},"isDiamondNode"),bt=new Map;for(const g of P.values())bt.has(g.dstId)||bt.set(g.dstId,new Set),bt.get(g.dstId).add(g.dstSide);for(const g of P.values()){if(!it(r.get(g.srcId)))continue;const C=bt.get(g.srcId);if(!(C!=null&&C.has(g.srcSide)))continue;const O=Y(g);if(C.has(O)||(z.get(Q(g.srcId,O))??0)>0)continue;const R=z.get(Q(g.srcId,g.srcSide))??0;z.set(Q(g.srcId,g.srcSide),Math.max(0,R-1)),z.set(Q(g.srcId,O),1),g.srcSide=O}const ne=c(g=>{const C=g==null?void 0:g.shape;return C==="hexagon"||C==="notch-pent"},"hasVertexFaces"),Jt=new Map;for(const g of P.values())Jt.has(g.srcId)||Jt.set(g.srcId,new Set),Jt.get(g.srcId).add(g.srcSide);const Qt=c(g=>g.dstSide==="top"||g.dstSide==="bottom"?g.dxSign>=0?"left":"right":g.dySign>=0?"top":"bottom","secondaryDstSide");for(const g of P.values()){if(!ne(r.get(g.dstId)))continue;const C=Jt.get(g.dstId);if(!(C!=null&&C.has(g.dstSide)))continue;const O=Qt(g);if(C.has(O)||(z.get(Q(g.dstId,O))??0)>0)continue;const R=z.get(Q(g.dstId,g.dstSide))??0;z.set(Q(g.dstId,g.dstSide),Math.max(0,R-1)),z.set(Q(g.dstId,O),1),g.dstSide=O;const N=g.dySign>=0?"bottom":"top";if((O==="top"||O==="bottom")&&((Lt=bt.get(g.srcId))!=null&&Lt.has(g.srcSide))&&!((Ht=bt.get(g.srcId))!=null&&Ht.has(N))&&(z.get(Q(g.srcId,N))??0)===0){const D=z.get(Q(g.srcId,g.srcSide))??0;z.set(Q(g.srcId,g.srcSide),Math.max(0,D-1)),z.set(Q(g.srcId,N),1),g.srcSide=N}}for(const g of P.values()){const{edgeIdx:C,srcId:O,dstId:R,srcSide:N,dstSide:D}=g,J=r.get(O),ft=r.get(R),K=`${O}:${N}:src`,U=N==="top"||N==="bottom"?ft.x??0:ft.y??0;w.has(K)||w.set(K,[]),w.get(K).push({edgeIdx:C,oppositeCoord:U});const Rt=`${R}:${D}:dst`,Ot=D==="top"||D==="bottom"?J.x??0:J.y??0;w.has(Rt)||w.set(Rt,[]),w.get(Rt).push({edgeIdx:C,oppositeCoord:Ot})}const Z=new Map,at=8;for(const[g,C]of w){if(C.length<2)continue;C.sort((Ut,ge)=>Ut.oppositeCoord-ge.oppositeCoord);const O=g.split(":"),R=O.slice(0,-2).join(":"),N=O[O.length-2],D=O[O.length-1],J=r.get(R);if(!J)continue;const ft=N==="left"||N==="right",K=hn(J,10),U=ft?K.h:K.w,Rt=J.shape,Bt=Rt==="question"||Rt==="diamond"?U*.3:U,St=Math.min(20,Bt/(C.length-1),Math.max(at,Bt/(C.length+1))),de=-(St*(C.length-1))/2;for(const[Ut,ge]of C.entries()){const Oe=de+Ut*St,Bn=`${ge.edgeIdx}:${D}`;Z.set(Bn,Oe)}}const ht=c(g=>{var C;return!!((C=s[g])!=null&&C.labelNodeId)},"edgeHasLabelNode"),pt=c((g,C)=>g?(w.get(`${g}:${C}:src`)??[]).some(({edgeIdx:O})=>ht(O))||(w.get(`${g}:${C}:dst`)??[]).some(({edgeIdx:O})=>ht(O)):!1,"faceHasLabelNode"),Ct=c((g,C,O)=>C==="top"||C==="bottom"?{x:g.x+O,y:g.y}:{x:g.x,y:g.y+O},"applyPortOffset"),H=c((g,C,O)=>{const R=P.get(g),N={x:O.x??0,y:O.y??0},D={x:C.x??0,y:C.y??0},J=(R==null?void 0:R.srcSide)??B(C,N),ft=(R==null?void 0:R.dstSide)??B(O,D);let K=R?y(C,R.srcSide):h(C,N,!0),U=R?y(O,R.dstSide):h(O,D,!1);const Rt=Z.get(`${g}:src`),Ot=Z.get(`${g}:dst`);return Rt!==void 0&&(K=Ct(K,J,Rt)),Ot!==void 0&&(U=Ct(U,ft,Ot)),{pSrcPort:K,pDstPort:U,srcSide:J,dstSide:ft}},"portsForEdge");for(const g of m){const C=s[g];if(L[g]=[],!C.start||!C.end||C.points&&C.points.length>0||C.start===C.end)continue;const O=r.get(C.start),R=r.get(C.end);if(!O||!R)continue;const{pSrcPort:N,pDstPort:D,srcSide:J,dstSide:ft}=H(g,O,R),K={...N},U={...D},Rt=J==="top"||J==="bottom",Ot=ft==="top"||ft==="bottom";if(Rt){const X=N.y>(O.y??0);K.y=X?N.y+Ie:N.y-Ie}else{const X=N.x>(O.x??0);K.x=X?N.x+Ie:N.x-Ie}if(Ot){const X=D.y>(R.y??0);U.y=X?D.y+Ie:D.y-Ie}else{const X=D.x>(R.x??0);U.x=X?D.x+Ie:D.x-Ie}const Bt=c((X,$)=>{for(const ot of I)if(!$.includes(ot.nodeId)&&X.x>ot.minX&&X.x<ot.maxX&&X.y>ot.minY&&X.y<ot.maxY)return{inside:!0,obstacle:ot};return{inside:!1}},"isPointInObstacle"),st=c((X,$,ot,wt,_t)=>{if(_t){const Wt=X.y>($.y??0);return{x:(ot.x??0)>=X.x?wt.maxX+De:wt.minX-De,y:Wt?wt.maxY+Ve:wt.minY-Ve,leavesPositiveSide:Wt}}const Nt=X.x>($.x??0),Yt=(ot.y??0)>=X.y;return{x:Nt?wt.maxX+De:wt.minX-De,y:Yt?wt.maxY+Ve:wt.minY-Ve,leavesPositiveSide:Nt}},"obstacleDetour");let St=[];const Gt=[C.start,C.end],de=Bt(K,Gt);if(de.inside&&de.obstacle){const X=de.obstacle;if(Rt){const $=st(N,O,R,X,!0);K.x=$.x,K.y=$.y;const ot=$.leavesPositiveSide?Math.min(X.minY-2,N.y+Ie):Math.max(X.maxY+2,N.y-Ie);St=[{x:N.x,y:ot},{x:$.x,y:ot},{x:$.x,y:$.y}]}else{const $=st(N,O,R,X,!1),ot=$.leavesPositiveSide?Math.min(X.minX-2,N.x+Ie):Math.max(X.maxX+2,N.x-Ie);K.x=$.x,K.y=$.y,St=[{x:ot,y:N.y},{x:ot,y:$.y},{x:$.x,y:$.y}]}}let Ut=[];const ge=Bt(U,Gt);if(ge.inside&&ge.obstacle){const X=ge.obstacle;if(Ot){const $=st(D,R,O,X,!0);U.x=$.x,U.y=$.y,Ut=[{x:$.x,y:$.y},{x:D.x,y:$.y}]}else{const $=st(D,R,O,X,!1);U.x=$.x,U.y=$.y,Ut=[{x:$.x,y:$.y},{x:$.x,y:D.y}]}}if(St.length===0&&Ut.length===0){const X=De,$=Math.abs(K.x-U.x)<X,ot=Math.abs(K.y-U.y)<X,wt=Z.get(`${g}:src`)!==void 0||Z.get(`${g}:dst`)!==void 0,_t=(((jt=w.get(`${C.start??""}:${J}:src`))==null?void 0:jt.length)??0)+(((xe=w.get(`${C.start??""}:${J}:dst`))==null?void 0:xe.length)??0),Nt=(((oe=w.get(`${C.end??""}:${ft}:src`))==null?void 0:oe.length)??0)+(((ee=w.get(`${C.end??""}:${ft}:dst`))==null?void 0:ee.length)??0),Yt=_t>1||Nt>1,Wt=A.get(C.start??"")??0,Tt=A.get(C.end??"")??0,ie=_t>1&&pt(C.start,J)||Nt>1&&pt(C.end,ft),be=_t<=1||Wt<=2,qt=Nt<=1||Tt<=2;if(($||ot)&&!wt&&(!Yt||Yt&&!ie&&be&&qt)&&!M(N,D,C.start,C.end)){C.points=[{...N},{...K},{...U},{...D}],u.add(g);const Pt=ot?"horizontal":"vertical",le=ot?N.y:N.x,Ft=ot?Math.min(N.x,D.x):Math.min(N.y,D.y),kt=ot?Math.max(N.x,D.x):Math.max(N.y,D.y),ue={id:`fast-path-${Pt}-${le.toFixed(0)}-${g}`,orientation:Pt,coord:le,spanMin:Ft,spanMax:kt,tracks:[]};x.push({edgeIndex:g,segmentIndex:0,orientation:Pt,pipe:ue,trackIndex:0,from:Ft,to:kt});continue}}const Oe=p("vertical",K.x,K.y,K.y);K.x=Oe.coord;const Bn=p("vertical",U.x,U.y,U.y);U.x=Bn.coord;let Ne=Math.min(K.x,U.x)-50,Be=Math.max(K.x,U.x)+50,Ye=Math.min(K.y,U.y)-50,ze=Math.max(K.y,U.y)+50;for(const X of I){const $=Math.min(K.x,U.x),ot=Math.max(K.x,U.x),wt=Math.min(K.y,U.y),_t=Math.max(K.y,U.y);X.minX<ot&&X.maxX>$&&X.minY<_t&&X.maxY>wt&&(Ne=Math.min(Ne,X.minX-fn),Be=Math.max(Be,X.maxX+fn),Ye=Math.min(Ye,X.minY-fn),ze=Math.max(ze,X.maxY+fn))}for(const X of I){if(X.maxX<Ne||X.minX>Be||X.maxY<Ye||X.minY>ze)continue;const $=De;p("horizontal",X.minY-$,Ne,Be),p("horizontal",X.maxY+$,Ne,Be);const ot=Ve;p("vertical",X.minX-ot,Ye,ze),p("vertical",X.maxX+ot,Ye,ze)}p("horizontal",K.y,Ne,Be),p("horizontal",U.y,Ne,Be);const hi=a.filter(X=>X.orientation==="horizontal"&&X.coord>=Ye&&X.coord<=ze),gi=a.filter(X=>X.orientation==="vertical"&&X.coord>=Ne&&X.coord<=Be),en=c((X,$)=>`${X.toFixed(1)},${$.toFixed(1)}`,"getKey"),nn=en(K.x,K.y),qo=en(U.x,U.y),on=new Map,Pn=new Map,Fn=new Map,sn=new Set,He=[];on.set(nn,0),Fn.set(nn,"n"),He.push({key:nn,f:Math.hypot(U.x-K.x,U.y-K.y),pt:K}),sn.add(nn);let se=[];const Pe=c((X,$)=>M(X,$,C.start,C.end),"checkSegmentBlocked"),kn={x:U.x,y:K.y},mi=Pe(K,kn),pi=Pe(kn,U),yi=mi||pi,_n={x:K.x,y:U.y},xi=Pe(K,_n),bi=Pe(_n,U);if(yi?xi||bi||(Math.abs(K.x-U.x)<yt?se=[K,U]:se=[K,_n,U]):Math.abs(K.y-U.y)<yt||Math.abs(K.x-U.x)<yt?se=[K,U]:se=[K,kn,U],se.length===0)for(;He.length>0;){He.sort((Tt,ie)=>Tt.f-ie.f);const X=He.shift();if(sn.delete(X.key),X.key===qo){let Tt=qo,ie=U;for(se=[ie];Pn.has(Tt);){const be=Pn.get(Tt);se.unshift(be),ie=be,Tt=en(be.x,be.y)}break}const $=X.pt.x,ot=X.pt.y,wt=gi.sort((Tt,ie)=>Tt.coord-ie.coord),_t=wt.findIndex(Tt=>Math.abs(Tt.coord-$)<1),Nt=hi.sort((Tt,ie)=>Tt.coord-ie.coord),Yt=Nt.findIndex(Tt=>Math.abs(Tt.coord-ot)<1),Wt=[];_t>0&&Wt.push({x:wt[_t-1].coord,y:ot}),_t>=0&&_t<wt.length-1&&Wt.push({x:wt[_t+1].coord,y:ot}),Yt>0&&Wt.push({x:$,y:Nt[Yt-1].coord}),Yt>=0&&Yt<Nt.length-1&&Wt.push({x:$,y:Nt[Yt+1].coord});for(const Tt of Wt){const ie=Math.min($,Tt.x),be=Math.max($,Tt.x),qt=Math.min(ot,Tt.y),ae=Math.max(ot,Tt.y);if(I.some(me=>me.nodeId===C.start||me.nodeId===C.end?!1:ie!==be?me.minY<ot&&me.maxY>ot&&me.maxX>ie&&me.minX<be:me.minX<$&&me.maxX>$&&me.maxY>qt&&me.minY<ae))continue;const Pt=en(Tt.x,Tt.y),le=Math.abs(Tt.x-$)+Math.abs(Tt.y-ot),Ft=S(g,X.pt,Tt);let kt=0;const ue=U.x-K.x,$e=U.y-K.y,rn=Tt.x-$,Hn=Tt.y-ot;($e>10&&Hn<-5||$e<-10&&Hn>5)&&(kt=Math.abs(Hn)*100),(ue>10&&rn<-5||ue<-10&&rn>5)&&(kt+=Math.abs(rn)*50);let Zo=0;const Jo=Fn.get(X.key)??"n",Qo=Math.abs(rn)>yt?"h":"v";Jo!=="n"&&Jo!==Qo&&(Zo=50);const Ii=le+Ft+kt+Zo,cn=(on.get(X.key)??1/0)+Ii,ts=Math.abs(U.x-Tt.x)+Math.abs(U.y-Tt.y);if(cn<(on.get(Pt)??1/0))if(Pn.set(Pt,X.pt),on.set(Pt,cn),Fn.set(Pt,Qo),!sn.has(Pt))He.push({key:Pt,f:cn+ts,pt:Tt}),sn.add(Pt);else{const me=He.findIndex(Mi=>Mi.key===Pt);me!==-1&&(He[me].f=cn+ts)}}}if(se.length===0&&(se=[K,{x:K.x,y:U.y},U]),se.length>4){const X=se[0],$=se[se.length-1];let ot=Math.min(X.x,$.x),wt=Math.max(X.x,$.x),_t=Math.min(X.y,$.y),Nt=Math.max(X.y,$.y);for(const qt of se)ot=Math.min(ot,qt.x),wt=Math.max(wt,qt.x),_t=Math.min(_t,qt.y),Nt=Math.max(Nt,qt.y);const Yt=wt>Math.max(X.x,$.x),Wt=ot<Math.min(X.x,$.x);if(f){const qt=Ve;if(Yt){const ae=Math.max(X.x,$.x),Kt=Math.min(X.y,$.y),Pt=Math.max(X.y,$.y),le=I.filter(Ft=>Ft.minX<ae&&Ft.maxX>ae&&Ft.minY<Pt&&Ft.maxY>Kt);if(le.length>0){let Ft=Math.max(X.x,$.x);for(const kt of le){const ue=(kt.minX+kt.maxX)/2;if(kt.visualXHalfExtent===void 0||isNaN(kt.visualXHalfExtent))continue;const $e=ue+kt.visualXHalfExtent+qt;Ft=Math.max(Ft,$e)}isNaN(Ft)||(wt=Ft)}}if(Wt){const ae=I.filter(Kt=>Kt.minX<Math.min(X.x,$.x)+qt&&Kt.minY<Math.max(X.y,$.y)&&Kt.maxY>Math.min(X.y,$.y));if(ae.length>0){let Kt=Math.min(X.x,$.x);for(const Pt of ae){const Ft=(Pt.minX+Pt.maxX)/2-Pt.visualXHalfExtent-qt;Kt=Math.min(Kt,Ft)}ot=Kt}}}const Tt=c(qt=>{const ae=$.y>X.y,Kt=I.filter(Ft=>{const kt=Math.min(X.x,$.x)<Ft.maxX&&Math.max(X.x,$.x)>Ft.minX,ue=Math.min(X.y,$.y)<Ft.maxY&&Math.max(X.y,$.y)>Ft.minY;return kt&&ue});let Pt=Kt;if(f&&Kt.length>0){const Ft=Kt.filter(kt=>kt.minX<qt&&kt.maxX>qt);Ft.length>0&&(Pt=Ft)}if(Pt.length===0)return $.y;const le=De;if(ae){const kt=Math.max(...Pt.map(ue=>ue.maxY))+le;if(kt<$.y-yt)return kt}else{const kt=Math.min(...Pt.map(ue=>ue.minY))-le;if(kt>$.y+yt)return kt}return $.y},"findBestReturnY"),ie=c(qt=>{const ae=Tt(qt),Kt={x:qt,y:X.y},Pt={x:qt,y:ae},le={x:$.x,y:ae},Ft=Pe(X,Kt),kt=Pe(Kt,Pt),ue=Pe(Pt,le),$e=ae!==$.y?Pe(le,$):!1;return!Ft&&!kt&&!ue&&!$e?Math.abs(ae-$.y)<yt?[X,Kt,Pt,$]:[X,Kt,Pt,le,$]:null},"trySimplifyWithDetourX"),be=Yt&&!Wt?ie(wt):Wt&&!Yt?ie(ot):null;be&&(se=be)}const re=[N,...St,...se,...Ut.reverse(),D];if(re.length>=3){const X=re[re.length-1],$=re[re.length-2],ot=re[re.length-3],wt=Math.abs(ot.y-$.y)<yt&&Math.abs($.y-X.y)<yt,_t=Math.abs(ot.x-$.x)<yt&&Math.abs($.x-X.x)<yt;if(wt){const Nt=Math.sign($.x-ot.x),Yt=Math.sign(X.x-ot.x);Nt!==0&&Nt===Yt&&Math.abs($.x-ot.x)>Math.abs(X.x-ot.x)&&re.splice(-2,1)}else if(_t){const Nt=Math.sign($.y-ot.y),Yt=Math.sign(X.y-ot.y);Nt!==0&&Nt===Yt&&Math.abs($.y-ot.y)>Math.abs(X.y-ot.y)&&re.splice(-2,1)}}const we=[re[0]];for(let X=1;X<re.length-1;X++){if(X===1){we.push(re[X]);continue}const $=we[we.length-1],ot=re[X],wt=re[X+1];if(Math.abs($.y-ot.y)<yt&&Math.abs(ot.y-wt.y)<yt){const _t=ot.x>$.x,Nt=wt.x>ot.x;if(_t!==Nt){we.push(ot);continue}continue}if(Math.abs($.x-ot.x)<yt&&Math.abs(ot.x-wt.x)<yt){const _t=ot.y>$.y,Nt=wt.y>ot.y;if(_t!==Nt){we.push(ot);continue}continue}we.push(ot)}we.push(re[re.length-1]);for(let X=0;X<we.length-1;X++){const $=we[X],ot=we[X+1],wt=Math.abs($.x-ot.x)<yt?"vertical":"horizontal",_t=wt==="vertical"?$.x:$.y,Nt=wt==="vertical"?Math.min($.y,ot.y):Math.min($.x,ot.x),Yt=wt==="vertical"?Math.max($.y,ot.y):Math.max($.x,ot.x),Wt=p(wt,_t,Nt,Yt),Tt={edgeIndex:g,segmentIndex:X,orientation:wt,pipe:Wt,trackIndex:0,from:Nt,to:Yt};x.push(Tt),L[g].push(x.length-1),Wt.tracks[0]||(Wt.tracks[0]={index:0,coord:Wt.coord,segments:[]}),Wt.tracks[0].segments.push({edgeIndex:g,segmentIndex:X,from:Nt,to:Yt})}}const V=c((g,C)=>g.from<C.to&&C.from<g.to,"segmentsOverlap"),ct=c((g,C,O,R)=>{const N=!R.segments.some(J=>(J.edgeIndex!==C.edgeIndex||J.segmentIndex!==C.segmentIndex)&&V(J,g)),D=!O.segments.some(J=>(J.edgeIndex!==g.edgeIndex||J.segmentIndex!==g.segmentIndex)&&V(J,C));return N&&D?(g.trackIndex=R.index,C.trackIndex=O.index,O.segments=[...O.segments.filter(J=>J.edgeIndex!==g.edgeIndex||J.segmentIndex!==g.segmentIndex),{edgeIndex:C.edgeIndex,segmentIndex:C.segmentIndex,from:C.from,to:C.to}],R.segments=[...R.segments.filter(J=>J.edgeIndex!==C.edgeIndex||J.segmentIndex!==C.segmentIndex),{edgeIndex:g.edgeIndex,segmentIndex:g.segmentIndex,from:g.from,to:g.to}],!0):!1},"trySwapSegmentsAcrossTracks"),nt=c(g=>{const C=g.tracks.length;return g.tracks[C]={index:C,coord:g.coord,segments:[]},C},"createNewTrack"),dt=c((g,C)=>{const O=g.pipe.tracks[g.trackIndex];O.segments=O.segments.filter(N=>N.edgeIndex!==g.edgeIndex||N.segmentIndex!==g.segmentIndex),g.trackIndex=C,g.pipe.tracks[C].segments.push({edgeIndex:g.edgeIndex,segmentIndex:g.segmentIndex,from:g.from,to:g.to})},"moveSegmentToTrack"),gt=c((g,C)=>{const O=L[g.edgeIndex];for(const R of O){const N=x[R];N.pipe===g.pipe&&dt(N,C)}},"moveSegmentChainToTrack"),It=c(g=>{const C=L[g.edgeIndex],O=C.indexOf(x.indexOf(g)),R=[];return O>0&&R.push(x[C[O-1]]),O<C.length-1&&R.push(x[C[O+1]]),R},"getAdjacentSegmentsAlongEdge"),mt=c((g,C)=>{if(g.orientation===C.orientation)return!1;const O=g.orientation==="horizontal"?g:C,R=g.orientation==="horizontal"?C:g;return R.pipe.coord>O.from&&R.pipe.coord<O.to&&O.pipe.coord>R.from&&O.pipe.coord<R.to},"haveAnyCrossing"),Et=c((g,C)=>{for(const O of g.tracks)if(!O.segments.some(N=>(N.edgeIndex!==C.edgeIndex||N.segmentIndex!==C.segmentIndex)&&V(N,C)))return O.index;return-1},"findAvailableTrack"),Vt=c((g,C)=>{if(g.trackIndex===C.trackIndex)return V(g,C);const O=It(g),R=It(C);return O.some(N=>R.some(D=>mt(N,D)))},"segmentsConflict"),_e=c((g,C,O)=>{if(ct(g,C,g.pipe.tracks[g.trackIndex],C.pipe.tracks[C.trackIndex]))return;const R=Et(g.pipe,C);O(C,R!==-1?R:nt(g.pipe))},"resolveTrackConflict"),Le=c(g=>{let C=0;for(let O=0;O<g.length;O++)for(let R=O+1;R<g.length;R++){const N=g[O],D=g[R];N.pipe===D.pipe&&Vt(N,D)&&(C++,_e(N,D,gt))}return C},"resolveHandleConflicts"),T=new Map,F=c(g=>{if(T.has(g))return T.get(g);const C=L[g];if(C.length===0){const ft={dest:0,deviation:0,base:0,delta:0};return T.set(g,ft),ft}const R=x[C[0]].pipe.coord;let N=R;for(let ft=1;ft<C.length;ft++){const K=x[C[ft]];if(K.orientation==="horizontal"){const U=K.from,Rt=K.to;N=Math.abs(U-R)>Math.abs(Rt-R)?U:Rt;break}}const D=Math.abs(N-R),J={dest:N,deviation:D,base:R,delta:N-R};return T.set(g,J),J},"getDestInfo"),_=c(()=>{let g=0;const C=new Map;for(const[R,N]of s.entries())L[R].length!==0&&N.start&&(C.has(N.start)||C.set(N.start,[]),C.get(N.start).push(R));const O=c(R=>{const N=s[R];if(!N.start||!N.end)return 0;const D=r.get(N.start),J=r.get(N.end);if(!D||!J)return 0;const ft=(J.x??0)-(D.x??0),K=(J.y??0)-(D.y??0);return Math.abs(ft)+Math.abs(K)},"getEdgeDistance");for(const R of C.values()){R.sort((D,J)=>{const ft=F(D),K=F(J);if(Math.abs(ft.deviation-K.deviation)>1)return ft.deviation-K.deviation;if(Math.abs(ft.dest-K.dest)>1)return ft.dest-K.dest;const U=O(D),Rt=O(J);if(Math.abs(U-Rt)>1)return Rt-U;const Ot=L[D].length,Bt=L[J].length;if(Ot!==Bt)return Ot-Bt;if(Ot===1){const st=L[D][0],St=L[J][0];if(x[st]&&x[St]){const Gt=x[st],de=x[St],Ut=Math.abs(Gt.to-Gt.from),ge=Math.abs(de.to-de.from);if(Math.abs(Ut-ge)>1)return Ut-ge}}return 0});const N=R.map(D=>x[L[D][0]]);g+=Le(N)}return g},"fixSourceHandleCrossings"),j=c(()=>{let g=0;const C=new Map;for(const[O,R]of s.entries())L[O].length!==0&&R.end&&(C.has(R.end)||C.set(R.end,[]),C.get(R.end).push(O));for(const O of C.values()){O.sort((N,D)=>{const J=c(U=>{const Rt=L[U];if(Rt.length<2)return 0;const Ot=x[Rt[Rt.length-2]];return Math.abs(Ot.to-Ot.from)},"getDist"),ft=J(N),K=J(D);return Math.abs(ft-K)>.1?ft-K:N-D});const R=O.map(N=>x[L[N][L[N].length-1]]);g+=Le(R)}return g},"fixTargetHandleCrossings"),q=c(()=>{let g=0;for(const C of a){const O=[];for(const R of C.tracks)for(const N of R.segments){const D=L[N.edgeIndex].find(J=>x[J].segmentIndex===N.segmentIndex);D!==void 0&&O.push(x[D])}O.sort((R,N)=>R.edgeIndex-N.edgeIndex||R.segmentIndex-N.segmentIndex);for(let R=0;R<O.length;R++)for(let N=R+1;N<O.length;N++){const D=O[R],J=O[N];Vt(D,J)&&(g++,_e(D,J,dt))}}return g},"fixPipeCrossings");let tt=0;const G=10;for(;tt<G;){let g=0;if(g+=_(),g+=j(),g+=q(),g===0)break;tt++}const et=new Map;for(const g of a){const C=[];g.tracks.forEach(R=>{R.segments.forEach(N=>{C.push({edgeIndex:N.edgeIndex,segmentIndex:N.segmentIndex,trackIndex:R.index,from:N.from,to:N.to})})}),C.sort((R,N)=>R.from-N.from);const O=[];if(C.length>0){let R=[C[0]],N=C[0].to;for(let D=1;D<C.length;D++){const J=C[D];J.from<N?(R.push(J),N=Math.max(N,J.to)):(O.push(R),R=[J],N=J.to)}O.push(R)}for(const R of O){const N=new Set;R.forEach(st=>N.add(st.trackIndex));const D=new Map;R.forEach(st=>{const St=F(st.edgeIndex);D.set(st.trackIndex,(D.get(st.trackIndex)??0)+St.delta)});const J=[...N].filter(st=>(D.get(st)??0)<-1),ft=[...N].filter(st=>(D.get(st)??0)>1),K=[...N].filter(st=>Math.abs(D.get(st)??0)<=1);J.sort((st,St)=>(D.get(St)??0)-(D.get(st)??0)),ft.sort((st,St)=>(D.get(st)??0)-(D.get(St)??0));const U=c((st,St)=>{R.filter(Gt=>Gt.trackIndex===st).forEach(Gt=>{const de=u.has(Gt.edgeIndex)?g.coord:St;et.set(`${Gt.edgeIndex}-${Gt.segmentIndex}`,de)})},"assignCoord");let Rt=0;for(const st of J)Rt++,U(st,g.coord-Rt*zn);if(K.length===0&&N.size>0){const st=[...N].sort((de,Ut)=>Math.abs(D.get(de)??0)-Math.abs(D.get(Ut)??0))[0],St=J.indexOf(st);St!==-1&&J.splice(St,1);const Gt=ft.indexOf(st);Gt!==-1&&ft.splice(Gt,1),K.push(st)}let Ot=0;for(const st of K){if(Ot===0)U(st,g.coord);else{const St=Ot%2===1?1:-1,Gt=Math.ceil(Ot/2);U(st,g.coord+St*Gt*zn*.5)}Ot++}let Bt=0;for(const st of ft)Bt++,U(st,g.coord+Bt*zn)}}for(const[g,C]of s.entries()){const O=L[g]??[];if(O.length===0)continue;const R=[],N=r.get(C.start),D=r.get(C.end),{pSrcPort:J,pDstPort:ft}=H(g,N,D),K=O.map(Bt=>{const st=x[Bt],St=et.get(`${st.edgeIndex}-${st.segmentIndex}`)??st.pipe.coord;return{orient:st.orientation,coord:St,from:st.from,to:st.to}});R.push(J);for(let Bt=0;Bt<K.length;Bt++){const st=K[Bt],St=R[R.length-1],Gt=st.orient==="vertical"?St.y:St.x,de=st.orient==="vertical"?St.x:St.y,Ut=K[Bt+1],ge=Bt<K.length-1;if(Math.abs(de-st.coord)>yt&&R.push(Xe(st,Gt)),ge&&Ut.orient===st.orient)if(Math.abs(st.coord-Ut.coord)>yt){const Oe=st.orient==="vertical"?(Gt+Ut.from)/2:wo(st,Ut);R.push(Xe(st,Oe),Xe(Ut,Oe))}else(Bt===0||Bt===K.length-2)&&R.push(Xe(st,wo(st,Ut)));else if(ge)R.push(Xe(st,Ut.coord));else{const Oe=Math.abs(st.from-Gt)<Math.abs(st.to-Gt)?st.to:st.from;R.push(Xe(st,Oe))}}const U=R[R.length-1];(Math.abs(U.x-ft.x)>yt||Math.abs(U.y-ft.y)>yt)&&R.push(ft);const Rt=R[0];Rt&&(Math.abs(Rt.x-J.x)>yt||Math.abs(Rt.y-J.y)>yt)&&R.unshift(J);const Ot=[];R.length>0&&Ot.push(R[0]);for(let Bt=1;Bt<R.length;Bt++){const st=R[Bt],St=Ot[Ot.length-1];(Math.abs(st.x-St.x)>yt||Math.abs(st.y-St.y)>yt)&&Ot.push(st)}C.points=Ot}for(const g of s){const C=g.__originalEdge;C&&g.points&&(C.points=g.points)}t.edges=(t.edges??[]).filter(g=>!g.isLayoutOnly);const lt=c((g,C)=>{const O=C.x??0,R=C.y??0,{w:N,h:D}=hn(C,0);if(N<=0||D<=0)return g;const J=O-N/2,ft=O+N/2,K=R-D/2,U=R+D/2;if(g.x<J||g.x>ft||g.y<K||g.y>U)return g;const Rt=g.x-J,Ot=ft-g.x,Bt=g.y-K,st=U-g.y,St=Math.min(Rt,Ot,Bt,st);return St===Rt?{x:J,y:g.y}:St===Ot?{x:ft,y:g.y}:St===Bt?{x:g.x,y:K}:{x:g.x,y:U}},"nodeBoundaryClamp");for(const g of t.edges){const C=g.points;if(!C||C.length<2)continue;const O=g.start,R=g.end,N=O?r.get(O):void 0,D=R?r.get(R):void 0;N&&(C[0]=lt(C[0],N)),D&&(C[C.length-1]=lt(C[C.length-1],D))}return t}c(li,"routeEdgesOrthogonal");function fi(t){return t.direction??"TB"}c(fi,"getSwimlaneDirection");function di(t){var b,l,I,p,y;const e=vs(t),n=((b=t.config.flowchart)==null?void 0:b.nodeSpacing)??40,o=((l=t.config.flowchart)==null?void 0:l.rankSpacing)??100,s=((I=t.config.swimlane)==null?void 0:I.ignoreCrossLaneEdges)??!0,r=((p=t.config.swimlane)==null?void 0:p.optimizeRanksByCrossings)??!0,i=((y=t.config.swimlane)==null?void 0:y.automaticLaneOrdering)??!1,a=fi(t),{ordered:f,coordinates:d}=ai(e,{nodeGap:n,layerGap:o,ignoreCrossLaneEdges:s,optimizeRanksByCrossings:r,automaticLaneOrdering:i,direction:a});Ls(e,f,d,{nodeGap:n,layerGap:o});for(const h of t.edges??[])delete h.points;li(t,a);for(const h of t.edges??[])(!h.curve||h.curve==="basis")&&(h.curve="rounded");return wr(t,a),Cr(t),a}c(di,"runSwimlaneLayoutCore");function ui(t){Ss(t);const e=ws(t);t.nodes=e.nodes,t.edges=e.edges}c(ui,"prepareSwimlaneLayout");var ec=Ci({prepareLayout:ui,runLayoutCore:di,afterPaint:cs});export{ec as render};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{c as r,s as e}from"./flowDiagram-JAYNFW54-DIf4aoDB.js";import"./chunk-KTR4FSNJ-DNqOwqFL.js";import{_ as o}from"./mermaid.core-CDkqDmQh.js";import"./chunk-5VM5RSS4-D8XyNr_K.js";import"./chunk-3BJB4PZV-f0-m4Ag2.js";import"./chunk-XXDRQBXY-ZgzK0pt4.js";import"./chunk-CNRTWJTD-CrX82YZ2.js";import"./chunk-D5HYT7QG-DLlJaHjh.js";import"./index-CtfDl2Kw.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};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import{_ as l,N as gt,G as nt,D as Pt,a7 as Bt,a8 as Vt,a9 as Ft,c as ft,l as S,S as zt,T as Gt,aa as yt,k as J,U as lt,M as Ot,ab as Dt,A as Ut}from"./mermaid.core-CDkqDmQh.js";import"./index-CtfDl2Kw.js";var tt=(function(){var e=l(function(k,i,d,h){for(d=d||{},h=k.length;h--;d[k[h]]=i);return d},"o"),t=[6,11,13,14,15,17,19,20,23,24],s=[1,12],r=[1,13],n=[1,14],a=[1,15],o=[1,16],c=[1,19],p=[1,20],y={trace:l(function(){},"trace"),yy:{},symbols_:{error:2,start:3,timeline_header:4,document:5,EOF:6,timeline:7,timeline_lr:8,timeline_td:9,line:10,SPACE:11,statement:12,NEWLINE:13,title:14,acc_title:15,acc_title_value:16,acc_descr:17,acc_descr_value:18,acc_descr_multiline_value:19,section:20,period_statement:21,event_statement:22,period:23,event:24,$accept:0,$end:1},terminals_:{2:"error",6:"EOF",7:"timeline",8:"timeline_lr",9:"timeline_td",11:"SPACE",13:"NEWLINE",14:"title",15:"acc_title",16:"acc_title_value",17:"acc_descr",18:"acc_descr_value",19:"acc_descr_multiline_value",20:"section",23:"period",24:"event"},productions_:[0,[3,3],[4,1],[4,1],[4,1],[5,0],[5,2],[10,2],[10,1],[10,1],[10,1],[12,1],[12,2],[12,2],[12,1],[12,1],[12,1],[12,1],[21,1],[22,1]],performAction:l(function(i,d,h,g,x,u,w){var v=u.length-1;switch(x){case 1:return u[v-1];case 3:g.setDirection("LR");break;case 4:g.setDirection("TD");break;case 5:this.$=[];break;case 6:u[v-1].push(u[v]),this.$=u[v-1];break;case 7:case 8:this.$=u[v];break;case 9:case 10:this.$=[];break;case 11:g.getCommonDb().setDiagramTitle(u[v].substr(6)),this.$=u[v].substr(6);break;case 12:this.$=u[v].trim(),g.getCommonDb().setAccTitle(this.$);break;case 13:case 14:this.$=u[v].trim(),g.getCommonDb().setAccDescription(this.$);break;case 15:g.addSection(u[v].substr(8)),this.$=u[v].substr(8);break;case 18:g.addTask(u[v],0,""),this.$=u[v];break;case 19:g.addEvent(u[v].substr(2)),this.$=u[v];break}},"anonymous"),table:[{3:1,4:2,7:[1,3],8:[1,4],9:[1,5]},{1:[3]},e(t,[2,5],{5:6}),e(t,[2,2]),e(t,[2,3]),e(t,[2,4]),{6:[1,7],10:8,11:[1,9],12:10,13:[1,11],14:s,15:r,17:n,19:a,20:o,21:17,22:18,23:c,24:p},e(t,[2,10],{1:[2,1]}),e(t,[2,6]),{12:21,14:s,15:r,17:n,19:a,20:o,21:17,22:18,23:c,24:p},e(t,[2,8]),e(t,[2,9]),e(t,[2,11]),{16:[1,22]},{18:[1,23]},e(t,[2,14]),e(t,[2,15]),e(t,[2,16]),e(t,[2,17]),e(t,[2,18]),e(t,[2,19]),e(t,[2,7]),e(t,[2,12]),e(t,[2,13])],defaultActions:{},parseError:l(function(i,d){if(d.recoverable)this.trace(i);else{var h=new Error(i);throw h.hash=d,h}},"parseError"),parse:l(function(i){var d=this,h=[0],g=[],x=[null],u=[],w=this.table,v="",M=0,R=0,P=2,V=1,L=u.slice.call(arguments,1),_=Object.create(this.lexer),C={yy:{}};for(var F in this.yy)Object.prototype.hasOwnProperty.call(this.yy,F)&&(C.yy[F]=this.yy[F]);_.setInput(i,C.yy),C.yy.lexer=_,C.yy.parser=this,typeof _.yylloc>"u"&&(_.yylloc={});var z=_.yylloc;u.push(z);var q=_.options&&_.options.ranges;typeof C.yy.parseError=="function"?this.parseError=C.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function U(A){h.length=h.length-2*A,x.length=x.length-A,u.length=u.length-A}l(U,"popStack");function O(){var A;return A=g.pop()||_.lex()||V,typeof A!="number"&&(A instanceof Array&&(g=A,A=g.pop()),A=d.symbols_[A]||A),A}l(O,"lex");for(var $,N,b,T,E={},H,I,B,D;;){if(N=h[h.length-1],this.defaultActions[N]?b=this.defaultActions[N]:(($===null||typeof $>"u")&&($=O()),b=w[N]&&w[N][$]),typeof b>"u"||!b.length||!b[0]){var K="";D=[];for(H in w[N])this.terminals_[H]&&H>P&&D.push("'"+this.terminals_[H]+"'");_.showPosition?K="Parse error on line "+(M+1)+`:
|
|
2
|
+
`+_.showPosition()+`
|
|
3
|
+
Expecting `+D.join(", ")+", got '"+(this.terminals_[$]||$)+"'":K="Parse error on line "+(M+1)+": Unexpected "+($==V?"end of input":"'"+(this.terminals_[$]||$)+"'"),this.parseError(K,{text:_.match,token:this.terminals_[$]||$,line:_.yylineno,loc:z,expected:D})}if(b[0]instanceof Array&&b.length>1)throw new Error("Parse Error: multiple actions possible at state: "+N+", token: "+$);switch(b[0]){case 1:h.push($),x.push(_.yytext),u.push(_.yylloc),h.push(b[1]),$=null,R=_.yyleng,v=_.yytext,M=_.yylineno,z=_.yylloc;break;case 2:if(I=this.productions_[b[1]][1],E.$=x[x.length-I],E._$={first_line:u[u.length-(I||1)].first_line,last_line:u[u.length-1].last_line,first_column:u[u.length-(I||1)].first_column,last_column:u[u.length-1].last_column},q&&(E._$.range=[u[u.length-(I||1)].range[0],u[u.length-1].range[1]]),T=this.performAction.apply(E,[v,R,M,C.yy,b[1],x,u].concat(L)),typeof T<"u")return T;I&&(h=h.slice(0,-1*I*2),x=x.slice(0,-1*I),u=u.slice(0,-1*I)),h.push(this.productions_[b[1]][0]),x.push(E.$),u.push(E._$),B=w[h[h.length-2]][h[h.length-1]],h.push(B);break;case 3:return!0}}return!0},"parse")},m=(function(){var k={EOF:1,parseError:l(function(d,h){if(this.yy.parser)this.yy.parser.parseError(d,h);else throw new Error(d)},"parseError"),setInput:l(function(i,d){return this.yy=d||this.yy||{},this._input=i,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:l(function(){var i=this._input[0];this.yytext+=i,this.yyleng++,this.offset++,this.match+=i,this.matched+=i;var d=i.match(/(?:\r\n?|\n).*/g);return d?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),i},"input"),unput:l(function(i){var d=i.length,h=i.split(/(?:\r\n?|\n)/g);this._input=i+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-d),this.offset-=d;var g=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),h.length-1&&(this.yylineno-=h.length-1);var x=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:h?(h.length===g.length?this.yylloc.first_column:0)+g[g.length-h.length].length-h[0].length:this.yylloc.first_column-d},this.options.ranges&&(this.yylloc.range=[x[0],x[0]+this.yyleng-d]),this.yyleng=this.yytext.length,this},"unput"),more:l(function(){return this._more=!0,this},"more"),reject:l(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
|
|
4
|
+
`+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},"reject"),less:l(function(i){this.unput(this.match.slice(i))},"less"),pastInput:l(function(){var i=this.matched.substr(0,this.matched.length-this.match.length);return(i.length>20?"...":"")+i.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:l(function(){var i=this.match;return i.length<20&&(i+=this._input.substr(0,20-i.length)),(i.substr(0,20)+(i.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:l(function(){var i=this.pastInput(),d=new Array(i.length+1).join("-");return i+this.upcomingInput()+`
|
|
5
|
+
`+d+"^"},"showPosition"),test_match:l(function(i,d){var h,g,x;if(this.options.backtrack_lexer&&(x={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(x.yylloc.range=this.yylloc.range.slice(0))),g=i[0].match(/(?:\r\n?|\n).*/g),g&&(this.yylineno+=g.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:g?g[g.length-1].length-g[g.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+i[0].length},this.yytext+=i[0],this.match+=i[0],this.matches=i,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(i[0].length),this.matched+=i[0],h=this.performAction.call(this,this.yy,this,d,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),h)return h;if(this._backtrack){for(var u in x)this[u]=x[u];return!1}return!1},"test_match"),next:l(function(){if(this.done)return this.EOF;this._input||(this.done=!0);var i,d,h,g;this._more||(this.yytext="",this.match="");for(var x=this._currentRules(),u=0;u<x.length;u++)if(h=this._input.match(this.rules[x[u]]),h&&(!d||h[0].length>d[0].length)){if(d=h,g=u,this.options.backtrack_lexer){if(i=this.test_match(h,x[u]),i!==!1)return i;if(this._backtrack){d=!1;continue}else return!1}else if(!this.options.flex)break}return d?(i=this.test_match(d,x[g]),i!==!1?i:!1):this._input===""?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+`. Unrecognized text.
|
|
6
|
+
`+this.showPosition(),{text:"",token:null,line:this.yylineno})},"next"),lex:l(function(){var d=this.next();return d||this.lex()},"lex"),begin:l(function(d){this.conditionStack.push(d)},"begin"),popState:l(function(){var d=this.conditionStack.length-1;return d>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:l(function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},"_currentRules"),topState:l(function(d){return d=this.conditionStack.length-1-Math.abs(d||0),d>=0?this.conditionStack[d]:"INITIAL"},"topState"),pushState:l(function(d){this.begin(d)},"pushState"),stateStackSize:l(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:l(function(d,h,g,x){switch(g){case 0:break;case 1:break;case 2:return 13;case 3:break;case 4:break;case 5:return 8;case 6:return 9;case 7:return 7;case 8:return 14;case 9:return this.begin("acc_title"),15;case 10:return this.popState(),"acc_title_value";case 11:return this.begin("acc_descr"),17;case 12:return this.popState(),"acc_descr_value";case 13:this.begin("acc_descr_multiline");break;case 14:this.popState();break;case 15:return"acc_descr_multiline_value";case 16:return 20;case 17:return 24;case 18:return 23;case 19:return 6;case 20:return"INVALID"}},"anonymous"),rules:[/^(?:%(?!\{)[^\n]*)/i,/^(?:[^\}]%%[^\n]*)/i,/^(?:[\n]+)/i,/^(?:\s+)/i,/^(?:#[^\n]*)/i,/^(?:timeline[ \t]+LR\b)/i,/^(?:timeline[ \t]+TD\b)/i,/^(?:timeline\b)/i,/^(?:title\s[^\n]+)/i,/^(?:accTitle\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*\{\s*)/i,/^(?:[\}])/i,/^(?:[^\}]*)/i,/^(?:section\s[^:\n]+)/i,/^(?::\s(?:[^:\n]|:(?!\s))+)/i,/^(?:[^#:\n]+)/i,/^(?:$)/i,/^(?:.)/i],conditions:{acc_descr_multiline:{rules:[14,15],inclusive:!1},acc_descr:{rules:[12],inclusive:!1},acc_title:{rules:[10],inclusive:!1},INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,11,13,16,17,18,19,20],inclusive:!0}}};return k})();y.lexer=m;function f(){this.yy={}}return l(f,"Parser"),f.prototype=y,y.Parser=f,new f})();tt.parser=tt;var Kt=tt,mt={};Ot(mt,{addEvent:()=>$t,addSection:()=>wt,addTask:()=>Tt,addTaskOrg:()=>Nt,clear:()=>vt,default:()=>Xt,getCommonDb:()=>kt,getDirection:()=>_t,getSections:()=>St,getTasks:()=>Et,setDirection:()=>bt});var X="",xt=0,rt="LR",st=[],Q=[],Z=[],kt=l(()=>Dt,"getCommonDb"),vt=l(function(){st.length=0,Q.length=0,X="",Z.length=0,rt="LR",Ut()},"clear"),bt=l(function(e){rt=e},"setDirection"),_t=l(function(){return rt},"getDirection"),wt=l(function(e){X=e,st.push(e)},"addSection"),St=l(function(){return st},"getSections"),Et=l(function(){let e=ct();const t=100;let s=0;for(;!e&&s<t;)e=ct(),s++;return Q.push(...Z),Q},"getTasks"),Tt=l(function(e,t,s){const r={id:xt++,section:X,type:X,task:e,score:t||0,events:s?[s]:[]};Z.push(r)},"addTask"),$t=l(function(e){Z.find(s=>s.id===xt-1).events.push(e)},"addEvent"),Nt=l(function(e){const t={section:X,type:X,description:e,task:e,classes:[]};Q.push(t)},"addTaskOrg"),ct=l(function(){const e=l(function(s){return Z[s].processed},"compileTask");let t=!0;for(const[s,r]of Z.entries())e(s),t=t&&r.processed;return t},"compileTasks"),Xt={clear:vt,getCommonDb:kt,getDirection:_t,setDirection:bt,addSection:wt,getSections:St,getTasks:Et,addTask:Tt,addTaskOrg:Nt,addEvent:$t},It=0,j=l(function(e,t){const s=e.append("rect");return s.attr("x",t.x),s.attr("y",t.y),s.attr("fill",t.fill),s.attr("stroke",t.stroke),s.attr("width",t.width),s.attr("height",t.height),s.attr("rx",t.rx),s.attr("ry",t.ry),t.class!==void 0&&s.attr("class",t.class),s},"drawRect"),Zt=l(function(e,t){const r=e.append("circle").attr("cx",t.cx).attr("cy",t.cy).attr("class","face").attr("r",15).attr("stroke-width",2).attr("overflow","visible"),n=e.append("g");n.append("circle").attr("cx",t.cx-15/3).attr("cy",t.cy-15/3).attr("r",1.5).attr("stroke-width",2).attr("fill","#666").attr("stroke","#666"),n.append("circle").attr("cx",t.cx+15/3).attr("cy",t.cy-15/3).attr("r",1.5).attr("stroke-width",2).attr("fill","#666").attr("stroke","#666");function a(p){const y=lt().startAngle(Math.PI/2).endAngle(3*(Math.PI/2)).innerRadius(7.5).outerRadius(6.8181818181818175);p.append("path").attr("class","mouth").attr("d",y).attr("transform","translate("+t.cx+","+(t.cy+2)+")")}l(a,"smile");function o(p){const y=lt().startAngle(3*Math.PI/2).endAngle(5*(Math.PI/2)).innerRadius(7.5).outerRadius(6.8181818181818175);p.append("path").attr("class","mouth").attr("d",y).attr("transform","translate("+t.cx+","+(t.cy+7)+")")}l(o,"sad");function c(p){p.append("line").attr("class","mouth").attr("stroke",2).attr("x1",t.cx-5).attr("y1",t.cy+7).attr("x2",t.cx+5).attr("y2",t.cy+7).attr("class","mouth").attr("stroke-width","1px").attr("stroke","#666")}return l(c,"ambivalent"),t.score>3?a(n):t.score<3?o(n):c(n),r},"drawFace"),qt=l(function(e,t){const s=e.append("circle");return s.attr("cx",t.cx),s.attr("cy",t.cy),s.attr("class","actor-"+t.pos),s.attr("fill",t.fill),s.attr("stroke",t.stroke),s.attr("r",t.r),s.class!==void 0&&s.attr("class",s.class),t.title!==void 0&&s.append("title").text(t.title),s},"drawCircle"),Ht=l(function(e,t){const s=t.text.replace(/<br\s*\/?>/gi," "),r=e.append("text");r.attr("x",t.x),r.attr("y",t.y),r.attr("class","legend"),r.style("text-anchor",t.anchor),t.class!==void 0&&r.attr("class",t.class);const n=r.append("tspan");return n.attr("x",t.x+t.textMargin*2),n.text(s),r},"drawText"),Jt=l(function(e,t){function s(n,a,o,c,p){return n+","+a+" "+(n+o)+","+a+" "+(n+o)+","+(a+c-p)+" "+(n+o-p*1.2)+","+(a+c)+" "+n+","+(a+c)}l(s,"genPoints");const r=e.append("polygon");r.attr("points",s(t.x,t.y,50,20,7)),r.attr("class","labelBox"),t.y=t.y+t.labelMargin,t.x=t.x+.5*t.labelMargin,Ht(e,t)},"drawLabel"),Qt=l(function(e,t,s){const r=e.append("g"),n=it();n.x=t.x,n.y=t.y,n.fill=t.fill,n.width=s.width,n.height=s.height,n.class="journey-section section-type-"+t.num,n.rx=3,n.ry=3,j(r,n),Lt(s)(t.text,r,n.x,n.y,n.width,n.height,{class:"journey-section section-type-"+t.num},s,t.colour)},"drawSection"),et=-1,jt=l(function(e,t,s,r){const n=t.x+s.width/2,a=e.append("g");et++,a.append("line").attr("id",r+"-task"+et).attr("x1",n).attr("y1",t.y).attr("x2",n).attr("y2",450).attr("class","task-line").attr("stroke-width","1px").attr("stroke-dasharray","4 2").attr("stroke","#666"),Zt(a,{cx:n,cy:300+(5-t.score)*30,score:t.score});const c=it();c.x=t.x,c.y=t.y,c.fill=t.fill,c.width=s.width,c.height=s.height,c.class="task task-type-"+t.num,c.rx=3,c.ry=3,j(a,c),Lt(s)(t.task,a,c.x,c.y,c.width,c.height,{class:"task"},s,t.colour)},"drawTask"),Yt=l(function(e,t){j(e,{x:t.startx,y:t.starty,width:t.stopx-t.startx,height:t.stopy-t.starty,fill:t.fill,class:"rect"}).lower()},"drawBackgroundRect"),te=l(function(){return{x:0,y:0,fill:void 0,"text-anchor":"start",width:100,height:100,textMargin:0,rx:0,ry:0}},"getTextObj"),it=l(function(){return{x:0,y:0,width:100,anchor:"start",height:100,rx:0,ry:0}},"getNoteRect"),Lt=(function(){function e(n,a,o,c,p,y,m,f){const k=a.append("text").attr("x",o+p/2).attr("y",c+y/2+5).style("font-color",f).style("text-anchor","middle").text(n);r(k,m)}l(e,"byText");function t(n,a,o,c,p,y,m,f,k){const{taskFontSize:i,taskFontFamily:d}=f,h=n.split(/<br\s*\/?>/gi);for(let g=0;g<h.length;g++){const x=g*i-i*(h.length-1)/2,u=a.append("text").attr("x",o+p/2).attr("y",c).attr("fill",k).style("text-anchor","middle").style("font-size",i).style("font-family",d);u.append("tspan").attr("x",o+p/2).attr("dy",x).text(h[g]),u.attr("y",c+y/2).attr("dominant-baseline","central").attr("alignment-baseline","central"),r(u,m)}}l(t,"byTspan");function s(n,a,o,c,p,y,m,f){const k=a.append("switch"),d=k.append("foreignObject").attr("x",o).attr("y",c).attr("width",p).attr("height",y).attr("position","fixed").append("xhtml:div").style("display","table").style("height","100%").style("width","100%");d.append("div").attr("class","label").style("display","table-cell").style("text-align","center").style("vertical-align","middle").text(n),t(n,k,o,c,p,y,m,f),r(d,m)}l(s,"byFo");function r(n,a){for(const o in a)o in a&&n.attr(o,a[o])}return l(r,"_setTextAttrs"),function(n){return n.textPlacement==="fo"?s:n.textPlacement==="old"?e:t}})(),ee=l(function(e,t){It=0,et=-1,e.append("defs").append("marker").attr("id",t+"-arrowhead").attr("refX",5).attr("refY",2).attr("markerWidth",6).attr("markerHeight",4).attr("orient","auto").append("path").attr("d","M 0,0 V 4 L6,2 Z")},"initGraphics");function at(e,t){e.each(function(){var s=J(this),r=s.text().split(/(\s+|<br>)/).reverse(),n,a=[],o=1.1,c=s.attr("y"),p=parseFloat(s.attr("dy")),y=s.text(null).append("tspan").attr("x",0).attr("y",c).attr("dy",p+"em");for(let m=0;m<r.length;m++)n=r[r.length-1-m],a.push(n),y.text(a.join(" ").trim()),(y.node().getComputedTextLength()>t||n==="<br>")&&(a.pop(),y.text(a.join(" ").trim()),n==="<br>"?a=[""]:a=[n],y=s.append("tspan").attr("x",0).attr("y",c).attr("dy",o+"em").text(n))})}l(at,"wrap");var ne=l(function(e,t,s,r,n,a=!1){var x,u,w;const{theme:o,look:c}=r,p=o==null?void 0:o.includes("redux"),y=((x=r==null?void 0:r.themeVariables)==null?void 0:x.THEME_COLOR_LIMIT)??12,m=s%y-1,f=e.append("g");t.section=m,f.attr("class",(t.class?t.class+" ":"")+"timeline-node "+("section-"+m));const k=f.append("g"),i=f.append("g"),h=i.append("text").text(t.descr).attr("dy","1em").attr("alignment-baseline","middle").attr("dominant-baseline","middle").attr("text-anchor","middle").call(at,t.width).node().getBBox(),g=(u=r.fontSize)!=null&&u.replace?r.fontSize.replace("px",""):r.fontSize;if(t.height=h.height+g*1.1*.5+t.padding,t.height=Math.max(t.height,t.maxHeight),t.width=t.width+2*t.padding,i.attr("transform","translate("+t.width/2+", "+t.padding/2+")"),p&&i.attr("transform",`translate(${t.width/2}, ${a?t.padding/2+3:t.padding})`),se(k,t,m,n,r),c==="neo"&&(f.attr("data-look","neo"),p)){const v=o.includes("dark"),M=((w=e.node())==null?void 0:w.ownerSVGElement)??e.node(),R=J(M),P=R.attr("id")??"",V=P?`${P}-drop-shadow`:"drop-shadow";if(R.select(`#${V}`).empty()){const L=R.select("defs");(L.empty()?R.append("defs"):L).append("filter").attr("id",V).attr("height","130%").attr("width","130%").append("feDropShadow").attr("dx","4").attr("dy","4").attr("stdDeviation",0).attr("flood-opacity",v?"0.2":"0.06").attr("flood-color",v?"#FFFFFF":"#000000")}}return t},"drawNode"),re=l(function(e,t,s){var c;const r=e.append("g"),a=r.append("text").text(t.descr).attr("dy","1em").attr("alignment-baseline","middle").attr("dominant-baseline","middle").attr("text-anchor","middle").call(at,t.width).node().getBBox(),o=(c=s.fontSize)!=null&&c.replace?s.fontSize.replace("px",""):s.fontSize;return r.remove(),a.height+o*1.1*.5+t.padding},"getVirtualNodeHeight"),se=l(function(e,t,s,r,n){const{theme:a}=n,o=a!=null&&a.includes("redux")?0:5,c=5,p=o>0?`M0 ${t.height-c} v${-t.height+2*c} q0,-${o},${o},-${o} h${t.width-2*c} q${o},0,${o},${o} v${t.height-c} H0 Z`:`M0 ${t.height-c} v${-(t.height-c)} h${t.width} v${t.height} H0 Z`;e.append("path").attr("id",r+"-node-"+It++).attr("class","node-bkg node-"+t.type).attr("d",p),a!=null&&a.includes("redux")||e.append("line").attr("class","node-line-"+s).attr("x1",0).attr("y1",t.height).attr("x2",t.width).attr("y2",t.height)},"defaultBkg"),W={drawRect:j,drawCircle:qt,drawSection:Qt,drawText:Ht,drawLabel:Jt,drawTask:jt,drawBackgroundRect:Yt,getTextObj:te,getNoteRect:it,initGraphics:ee,drawNode:ne,getVirtualNodeHeight:re},ie=l(function(e,t,s,r){var U,O,$;const n=ft(),{look:a,theme:o,themeVariables:c}=n,{useGradient:p,gradientStart:y,gradientStop:m}=c,f=((U=n.timeline)==null?void 0:U.leftMargin)??50;S.debug("timeline",r.db);const k=n.securityLevel;let i;k==="sandbox"&&(i=J("#i"+t));const h=(k==="sandbox"?J(i.nodes()[0].contentDocument.body):J("body")).select("#"+t);h.append("g");const g=r.db.getTasks(),x=r.db.getCommonDb().getDiagramTitle();S.debug("task",g),W.initGraphics(h,t);const u=r.db.getSections();S.debug("sections",u);let w=0,v=0,M=0,R=0,P=50+f,V=50;R=50;let L=0,_=!0;u.forEach(function(N){const b={number:L,descr:N,section:L,width:150,padding:20,maxHeight:w},T=W.getVirtualNodeHeight(h,b,n);S.debug("sectionHeight before draw",T),w=Math.max(w,T+20)});let C=0,F=0;S.debug("tasks.length",g.length);for(const[N,b]of g.entries()){const T={number:N,descr:b,section:b.section,width:150,padding:20,maxHeight:v},E=W.getVirtualNodeHeight(h,T,n);S.debug("taskHeight before draw",E),v=Math.max(v,E+20),C=Math.max(C,b.events.length);let H=0;for(const I of b.events){const B={descr:I,section:b.section,number:b.section,width:150,padding:20,maxHeight:50};H+=W.getVirtualNodeHeight(h,B,n)}b.events.length>0&&(H+=(b.events.length-1)*10),F=Math.max(F,H)}S.debug("maxSectionHeight before draw",w),S.debug("maxTaskHeight before draw",v),u&&u.length>0?u.forEach(N=>{const b=g.filter(I=>I.section===N),T={number:L,descr:N,section:L,width:200*Math.max(b.length,1)-50,padding:20,maxHeight:w};S.debug("sectionNode",T);const E=h.append("g"),H=W.drawNode(E,T,L,n,t);S.debug("sectionNode output",H),E.attr("transform",`translate(${P}, ${R})`),V+=w+50,b.length>0&&ht(h,b,L,P,V,v,n,C,F,w,!1,t),P+=200*Math.max(b.length,1),V=R,L++}):(_=!1,ht(h,g,L,P,V,v,n,C,F,w,!0,t));const z=h.node().getBBox();if(S.debug("bounds",z),x&&h.append("text").text(x).attr("x",a==="neo"?z.x*2+f:z.width/2-f).attr("font-size","4ex").attr("font-weight","bold").attr("y",20),M=_?w+v+150:v+100,h.append("g").attr("class","lineWrapper").append("line").attr("x1",f).attr("y1",M).attr("x2",z.width+3*f).attr("y2",M).attr("stroke-width",4).attr("stroke","black").attr("marker-end",`url(#${t}-arrowhead)`),a==="neo"&&p&&o!=="neutral"){const N=h.select("defs"),T=(N.empty()?h.append("defs"):N).append("linearGradient").attr("id",h.attr("id")+"-gradient").attr("gradientUnits","objectBoundingBox").attr("x1","0%").attr("y1","0%").attr("x2","100%").attr("y2","0%");T.append("stop").attr("offset","0%").attr("stop-color",y).attr("stop-opacity",1),T.append("stop").attr("offset","100%").attr("stop-color",m).attr("stop-opacity",1)}yt(void 0,h,((O=n.timeline)==null?void 0:O.padding)??50,(($=n.timeline)==null?void 0:$.useMaxWidth)??!1)},"draw"),ht=l(function(e,t,s,r,n,a,o,c,p,y,m,f){var k;for(const i of t){const d={descr:i.task,section:s,number:s,width:150,padding:20,maxHeight:a};S.debug("taskNode",d);const h=e.append("g").attr("class","taskWrapper"),x=W.drawNode(h,d,s,o,f).height;if(S.debug("taskHeight after draw",x),h.attr("transform",`translate(${r}, ${n})`),a=Math.max(a,x),i.events){const u=e.append("g").attr("class","lineWrapper");let w=a;n+=100,w=w+ae(e,i.events,s,r,n,o,f),n-=100,u.append("line").attr("x1",r+190/2).attr("y1",n+a).attr("x2",r+190/2).attr("y2",n+a+100+p+100).attr("stroke-width",2).attr("stroke","black").attr("marker-end",`url(#${f}-arrowhead)`).attr("stroke-dasharray","5,5")}r=r+200,m&&!((k=o.timeline)!=null&&k.disableMulticolor)&&s++}n=n-10},"drawTasks"),ae=l(function(e,t,s,r,n,a,o){let c=0;const p=n;n=n+100;for(const y of t){const m={descr:y,section:s,number:s,width:150,padding:20,maxHeight:50};S.debug("eventNode",m);const f=e.append("g").attr("class","eventWrapper"),i=W.drawNode(f,m,s,a,o,!0).height;c=c+i,f.attr("transform",`translate(${r}, ${n})`),n=n+10+i}return n=p,c},"drawEvents"),oe={setConf:l(()=>{},"setConf"),draw:ie},Y=200,G=5,le=Y+G*2,ot=Y+100,ce=ot+G*2,Mt=10,he=0,dt=20,At=20,ut=30,Ct=50,de=l(function(e,t,s,r){var U,O,$,N,b;const n=ft(),a=((U=n.timeline)==null?void 0:U.leftMargin)??50;S.debug("timeline",r.db);const o=zt(t);o.append("g");const c=r.db.getTasks(),p=r.db.getCommonDb().getDiagramTitle();S.debug("task",c),W.initGraphics(o);const y=r.db.getSections();S.debug("sections",y);let m=0,f=0;const k=50+a;let i=50;const d=i,h=k,g=le+At,x=ce+Ct,u=h+g;let w=0;const v=y&&y.length>0,M=v?u:k+g,R=Math.max(50,g+x-G*2);y.forEach(function(T){const E={number:w,descr:T,section:w,width:R,padding:G,maxHeight:m},H=W.getVirtualNodeHeight(o,E,n);S.debug("sectionHeight before draw",H),m=Math.max(m,H)});let P=0;S.debug("tasks.length",c.length);for(const[T,E]of c.entries()){const H={number:T,descr:E,section:E.section,width:Y,padding:G,maxHeight:f},I=W.getVirtualNodeHeight(o,H,n);S.debug("taskHeight before draw",I),f=Math.max(f,I);let B=0;for(const D of E.events){const K={descr:D,section:E.section,number:E.section,width:ot,padding:G,maxHeight:50};B+=W.getVirtualNodeHeight(o,K,n)}E.events.length>0&&(B+=(E.events.length-1)*Mt),P=Math.max(P,B)+he}S.debug("maxSectionHeight before draw",m),S.debug("maxTaskHeight before draw",f);const L=Math.max(f,P)+ut;v?y.forEach(T=>{const E=c.filter(Wt=>Wt.section===T),H={number:w,descr:T,section:w,width:R,padding:G,maxHeight:m};S.debug("sectionNode",H);const I=o.append("g"),B=W.drawNode(I,H,w,n);S.debug("sectionNode output",B);const D=M-g;I.attr("transform",`translate(${D}, ${i})`);const K=i+B.height+dt;E.length>0&&pt(o,E,w,M,K,f,n,L,!1);const A=E.length,Rt=B.height+dt+L*Math.max(A,1)-(A>0?ut*2:0);i+=Rt,w++}):pt(o,c,w,M,i,f,n,L,!0);let _=(O=o.node())==null?void 0:O.getBBox();if(!_)throw new Error("bbox not found");if(S.debug("bounds",_),p){if(o.append("text").text(p).attr("x",_.width/2-a).attr("font-size","4ex").attr("font-weight","bold").attr("y",20),_=($=o.node())==null?void 0:$.getBBox(),!_)throw new Error("bbox not found");S.debug("bounds after title",_)}const[C]=Gt(n.fontSize),F=(C??16)*2,z=(C??16)*.5+20,q=o.append("g").attr("class","lineWrapper");q.append("line").attr("x1",M).attr("y1",d-F).attr("x2",M).attr("y2",_.y+_.height+z).attr("stroke-width",4).attr("stroke","black").attr("marker-end","url(#arrowhead)"),q.lower(),yt(void 0,o,((N=n.timeline)==null?void 0:N.padding)??50,((b=n.timeline)==null?void 0:b.useMaxWidth)??!1)},"draw"),pt=l(function(e,t,s,r,n,a,o,c,p){var y;for(const m of t){const f={descr:m.task,section:s,number:s,width:Y,padding:G,maxHeight:a};S.debug("taskNode",f);const k=e.append("g").attr("class","taskWrapper"),i=W.drawNode(k,f,s,o),d=i.height;S.debug("taskHeight after draw",d);const h=r-At-i.width;if(k.attr("transform",`translate(${h}, ${n})`),a=Math.max(a,d),m.events&&m.events.length>0){const g=n,x=r+Ct;ue(e,m.events,s,r,x,g,o)}n=n+c,p&&!((y=o.timeline)!=null&&y.disableMulticolor)&&s++}},"drawTasks"),ue=l(function(e,t,s,r,n,a,o){let c=a;for(const p of t){const y={descr:p,section:s,number:s,width:ot,padding:G,maxHeight:0};S.debug("eventNode",y);const m=e.append("g").attr("class","eventWrapper"),k=W.drawNode(m,y,s,o).height;m.attr("transform",`translate(${n}, ${c})`);const i=e.append("g").attr("class","lineWrapper"),d=c+k/2;i.append("line").attr("x1",r).attr("y1",d).attr("x2",n).attr("y2",d).attr("stroke-width",2).attr("stroke","black").attr("marker-end","url(#arrowhead)").attr("stroke-dasharray","5,5"),c=c+k+Mt}return c-a},"drawEvents"),pe={setConf:l(()=>{},"setConf"),draw:de},ge=l(e=>{var c;const{theme:t}=gt(),s=t==null?void 0:t.includes("dark"),r=Pt(t,e.borderColorArray),n=((c=e.svgId)==null?void 0:c.replace(/^#/,""))??"",a=n?`url(#${n}-drop-shadow)`:e.dropShadow??"none";let o="";for(let p=0;p<nt(e.THEME_COLOR_LIMIT);p++){const y=`${17-3*p}`,m=r?e.borderColorArray[p%e.borderColorArray.length]:void 0,f=m??e.mainBkg,k=m??e.nodeBorder;o+=`
|
|
7
|
+
.section-${p-1} rect,
|
|
8
|
+
.section-${p-1} path,
|
|
9
|
+
.section-${p-1} circle {
|
|
10
|
+
fill: ${s&&r?e.mainBkg:f};
|
|
11
|
+
stroke: ${k};
|
|
12
|
+
stroke-width: ${e.strokeWidth};
|
|
13
|
+
filter: ${a};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.section-${p-1} text {
|
|
17
|
+
fill: ${e.nodeBorder};
|
|
18
|
+
font-weight: ${e.fontWeight}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.node-icon-${p-1} {
|
|
22
|
+
font-size: 40px;
|
|
23
|
+
color: ${e["cScaleLabel"+p]};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.section-edge-${p-1} {
|
|
27
|
+
stroke: ${e["cScale"+p]};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.edge-depth-${p-1} {
|
|
31
|
+
stroke-width: ${y};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.section-${p-1} line {
|
|
35
|
+
stroke: ${e["cScaleInv"+p]};
|
|
36
|
+
stroke-width: 3;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.lineWrapper line {
|
|
40
|
+
stroke: ${e.nodeBorder};
|
|
41
|
+
stroke-width:${e.strokeWidth}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.disabled,
|
|
45
|
+
.disabled circle,
|
|
46
|
+
.disabled text {
|
|
47
|
+
fill: ${e.tertiaryColor??"lightgray"};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.disabled text {
|
|
51
|
+
fill: ${e.clusterBorder??"#efefef"};
|
|
52
|
+
}
|
|
53
|
+
`}return o},"genReduxSections"),fe=l(e=>{let t="";const s=nt(e.THEME_COLOR_LIMIT);for(let r=0;r<s;r++)e["lineColor"+r]=e["lineColor"+r]??e["cScaleInv"+r],Bt(e["lineColor"+r])?e["lineColor"+r]=Vt(e["lineColor"+r],20):e["lineColor"+r]=Ft(e["lineColor"+r],20);for(let r=0;r<s;r++){const n=""+(17-3*r);t+=`
|
|
54
|
+
.section-${r-1} rect, .section-${r-1} path, .section-${r-1} circle, .section-${r-1} path {
|
|
55
|
+
fill: ${e["cScale"+r]};
|
|
56
|
+
}
|
|
57
|
+
.section-${r-1} text {
|
|
58
|
+
fill: ${e["cScaleLabel"+r]};
|
|
59
|
+
}
|
|
60
|
+
.node-icon-${r-1} {
|
|
61
|
+
font-size: 40px;
|
|
62
|
+
color: ${e["cScaleLabel"+r]};
|
|
63
|
+
}
|
|
64
|
+
.section-edge-${r-1}{
|
|
65
|
+
stroke: ${e["cScale"+r]};
|
|
66
|
+
}
|
|
67
|
+
.edge-depth-${r-1}{
|
|
68
|
+
stroke-width: ${n};
|
|
69
|
+
}
|
|
70
|
+
.section-${r-1} line {
|
|
71
|
+
stroke: ${e["cScaleInv"+r]} ;
|
|
72
|
+
stroke-width: 3;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.lineWrapper line{
|
|
76
|
+
stroke: ${e["cScaleLabel"+r]} ;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.disabled, .disabled circle, .disabled text {
|
|
80
|
+
fill: ${e.tertiaryColor??"lightgray"};
|
|
81
|
+
}
|
|
82
|
+
.disabled text {
|
|
83
|
+
fill: ${e.clusterBorder??"#efefef"};
|
|
84
|
+
}
|
|
85
|
+
`}return t},"genSections"),ye=l(e=>{var o;const{theme:t}=gt(),s=t==null?void 0:t.includes("redux"),r=t==="neutral",n=((o=e.svgId)==null?void 0:o.replace(/^#/,""))??"";let a="";if(e.useGradient&&n&&e.THEME_COLOR_LIMIT&&!r){const c=nt(e.THEME_COLOR_LIMIT);for(let p=0;p<c;p++)a+=`
|
|
86
|
+
.section-${p-1}[data-look="neo"] rect,
|
|
87
|
+
.section-${p-1}[data-look="neo"] path,
|
|
88
|
+
.section-${p-1}[data-look="neo"] circle {
|
|
89
|
+
fill: ${e.mainBkg};
|
|
90
|
+
stroke: url(#${n}-gradient);
|
|
91
|
+
stroke-width: 2;
|
|
92
|
+
}
|
|
93
|
+
.section-${p-1}[data-look="neo"] line {
|
|
94
|
+
stroke: url(#${n}-gradient);
|
|
95
|
+
stroke-width: 2;
|
|
96
|
+
}`}return`
|
|
97
|
+
.edge {
|
|
98
|
+
stroke-width: 3;
|
|
99
|
+
}
|
|
100
|
+
${s?ge(e):fe(e)}
|
|
101
|
+
${a}
|
|
102
|
+
.section-root rect, .section-root path, .section-root circle {
|
|
103
|
+
fill: ${e.git0};
|
|
104
|
+
}
|
|
105
|
+
.section-root text {
|
|
106
|
+
fill: ${e.gitBranchLabel0};
|
|
107
|
+
}
|
|
108
|
+
.icon-container {
|
|
109
|
+
height:100%;
|
|
110
|
+
display: flex;
|
|
111
|
+
justify-content: center;
|
|
112
|
+
align-items: center;
|
|
113
|
+
}
|
|
114
|
+
.edge {
|
|
115
|
+
fill: none;
|
|
116
|
+
}
|
|
117
|
+
.eventWrapper {
|
|
118
|
+
filter: brightness(120%);
|
|
119
|
+
}
|
|
120
|
+
`},"getStyles"),me=ye,xe={setConf:l(()=>{},"setConf"),draw:l((e,t,s,r)=>{var a,o;return(((o=(a=r==null?void 0:r.db)==null?void 0:a.getDirection)==null?void 0:o.call(a))??"LR")==="TD"?pe.draw(e,t,s,r):oe.draw(e,t,s,r)},"draw")},be={db:mt,renderer:xe,parser:Kt,styles:me};export{be as diagram};
|