filecat 6.60.8 → 6.61.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/build/dist/{3105.8506dea62edb242a898c.js → 1128.b80776fbdbdda36034c3.js} +1 -1
- package/build/dist/1388.1dcf844b452e3aae3dc0.js +1 -0
- package/build/dist/1472.e8897d14d2cc609c9305.js +1 -0
- package/build/dist/{165.e102ca8665bd0983f320.js → 165.4eda7225a7bc15f10d54.js} +2 -2
- package/build/dist/1671.fb137d27b5763953487e.js +1 -0
- package/build/dist/2851.e103817a73bd5bc2ad56.js +1 -0
- package/build/dist/3230.7798ab546facfa058b34.js +1 -0
- package/build/dist/{3457.e003dede632769cfe55e.js → 3283.9386fc7f67aef46604fb.js} +1 -1
- package/build/dist/{9214.7750d99fcaff8de186f9.js → 3566.ba323afadcf41fad2fa7.js} +1 -1
- package/build/dist/{7277.aa3af95608a9d9d07634.js → 4220.b65b40382726a69ba0bc.js} +1 -1
- package/build/dist/4469.536491f90535e831ce3e.js +1 -0
- package/build/dist/4560.fd9f8cf2d6022b1d3a94.js +1 -0
- package/build/dist/{3721.c484f07613f940d94b90.js → 4772.9b95c402a4def0f576e3.js} +1 -1
- package/build/dist/{8840.525f17063dc60979415b.js → 5617.8efc3b1d218f80df9b39.js} +1 -1
- package/build/dist/6089.6d5d19a327284ff3b11c.js +1 -0
- package/build/dist/7038.166f915547d27e4dc5e4.js +1 -0
- package/build/dist/7310.bf944d03f24fcf109680.js +1 -0
- package/build/dist/7430.25bf8437ad8f7c1fd36f.js +1 -0
- package/build/dist/{9482.a952553a24ad781da8c4.js → 7567.09e1b34ad9bd3e463eb4.js} +1 -1
- package/build/dist/8090.4400dbf0a129ba8b152c.js +2 -0
- package/build/dist/{8090.90cb45de35e21b9cfcb0.js.LICENSE.txt → 8090.4400dbf0a129ba8b152c.js.LICENSE.txt} +2 -0
- package/build/dist/{9421.7eb137bdb14410e9f6f4.js → 8727.8658835acb7e0b6e5acc.js} +1 -1
- package/build/dist/8947.4a6c81c6c271e3ccd642.js +2 -0
- package/build/dist/{9546.69ad5ad33e3eb86164c6.js → 9546.c9b4ed852636fab1c104.js} +1 -1
- package/build/dist/index.html +1 -1
- package/build/dist/{main.c04bcbed6e5fc0b1f62f.js → main.ce650ef690ddefd87f88.js} +2 -2
- package/build/main.js +1 -1
- package/package.json +1 -1
- package/build/dist/1472.73bcbe12c597c2aa5715.js +0 -1
- package/build/dist/1695.8a7beb249e1ad17a47f3.js +0 -1
- package/build/dist/2851.a7ecf5bca38c79677f03.js +0 -1
- package/build/dist/378.a32383dade4a2e55152a.js +0 -1
- package/build/dist/4325.15c785b84773f0605fd4.js +0 -1
- package/build/dist/5622.01faef0a863f5cad9619.js +0 -1
- package/build/dist/647.42e7ab2f84bd57ba60e4.js +0 -1
- package/build/dist/6636.cc3f66845c61dbf76bd1.js +0 -1
- package/build/dist/7454.e647fbf309ca068e39e8.js +0 -1
- package/build/dist/8090.90cb45de35e21b9cfcb0.js +0 -2
- package/build/dist/8947.5c2814b7a2c2810f0ce2.js +0 -2
- package/build/dist/970.0a2e1e7d00bc1b8a2d6c.js +0 -1
- package/build/dist/9899.2a79d3f40f2bf1ae7829.js +0 -1
- /package/build/dist/{165.e102ca8665bd0983f320.js.LICENSE.txt → 165.4eda7225a7bc15f10d54.js.LICENSE.txt} +0 -0
- /package/build/dist/{8947.5c2814b7a2c2810f0ce2.js.LICENSE.txt → 8947.4a6c81c6c271e3ccd642.js.LICENSE.txt} +0 -0
- /package/build/dist/{main.c04bcbed6e5fc0b1f62f.js.LICENSE.txt → main.ce650ef690ddefd87f88.js.LICENSE.txt} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[7430],{77430(t,e,n){n.r(e),n.d(e,{render:()=>_n});var o=n(5691),r=(n(24980),n(27838)),s=(n(96865),n(48159),n(44505),n(69793),n(43287),n(12505),n(86535),n(31293)),i=n(86827),a=1e-5,c=1e-6;function f(t){const e=[];for(let n=0;n<t.length-1;n++)e.push({a:t[n],b:t[n+1]});return e}function d(t,e,n,o){const r=e.x-t.x,s=e.y-t.y,i=o.x-n.x,a=o.y-n.y,f=r*a-s*i;if(0===f)return null;const d=n.x-t.x,l=n.y-t.y,u=(d*a-l*i)/f,h=(d*s-l*r)/f;return u<=c||u>=.999999||h<=c||h>=.999999?null:{point:{x:t.x+u*r,y:t.y+u*s},tA:u,tB:h}}function l(t){return Math.abs(t.b.x-t.a.x)>=Math.abs(t.b.y-t.a.y)}function u(t){const e=[];for(let n=0;n<t.length;n++){const o=t[n],r=f(o.points);for(let s=n+1;s<t.length;s++){const n=t[s],i=f(n.points);for(const[t,s]of r.entries())for(const[r,a]of i.entries()){const i=d(s.a,s.b,a.a,a.b);if(!i)continue;const c=l(s);!!(c!==l(a))&&c?e.push({jumpEdgeId:o.id,otherEdgeId:n.id,segIndex:t,t:i.tA,point:i.point}):e.push({jumpEdgeId:n.id,otherEdgeId:o.id,segIndex:r,t:i.tB,point:i.point})}}}return e}function h(t){const e=Math.round(1e3*t)/1e3;return Number.isInteger(e),`${e}`}function g(t){return`${h(t.x)},${h(t.y)}`}function p(t){const e=t.b.x-t.a.x,n=t.b.y-t.a.y;return Math.abs(e)>=Math.abs(n)?e>=0?1:0:n>=0?1:0}(0,i.K)(f,"buildSegmentList"),(0,i.K)(d,"segmentIntersection"),(0,i.K)(l,"isHorizontalSeg"),(0,i.K)(u,"findEdgeIntersections"),(0,i.K)(h,"fmt"),(0,i.K)(g,"pointToString"),(0,i.K)(p,"getArcSweepFlag");function x(t,e){if(t.length<2)return t.map(t=>({...t}));const n=t.map(t=>({...t})),o=e.arrowTypeStart&&r.hq[e.arrowTypeStart];if(o){const e=t[0],r=t[1],s=Math.atan2(r.y-e.y,r.x-e.x);n[0].x=e.x+o*Math.cos(s),n[0].y=e.y+o*Math.sin(s)}const s=e.arrowTypeEnd&&r.hq[e.arrowTypeEnd];if(s){const e=t.length,o=t[e-2],r=t[e-1],i=Math.atan2(r.y-o.y,r.x-o.x);n[e-1].x=r.x-s*Math.cos(i),n[e-1].y=r.y-s*Math.sin(i)}return n}function m(t,e,n,o,r){const s=t.point.x,i=t.point.y,a={x:s-e*t.r,y:i-n*t.r},c={x:s+e*t.r,y:i+n*t.r},f=[`L${g(a)}`];return"arc"===r?f.push(`A${h(t.r)},${h(t.r)} 0 0 ${o} ${g(c)}`):f.push(`M${g(c)}`),f}function y(t,e,n,o){const r=e.x-t.x,s=e.y-t.y,i=n.x-e.x,c=n.y-e.y,f=Math.hypot(r,s),d=Math.hypot(i,c);if(f<a||d<a)return null;const l=r/f,u=s/f,h=i/d,g=c/d,p=l*h+u*g,x=Math.max(-1,Math.min(1,p)),m=Math.acos(x);if(m<a||Math.abs(Math.PI-m)<a)return null;const y=Math.min(o/Math.sin(m/2),f/2,d/2);return{startX:e.x-l*y,startY:e.y-u*y,endX:e.x+h*y,endY:e.y+g*y,ctrlX:e.x,ctrlY:e.y,cutLen:y}}function b(t,e,n){const o=t.points;if(o.length<2)return"";const r=x(o,t),s="rounded"===t.curve,i=f(r),a=new Map;for(const t of e){const e=i[t.segIndex];if(!e)continue;const o=Math.hypot(e.b.x-e.a.x,e.b.y-e.a.y),r=a.get(t.segIndex)??[];r.push({t:t.t,point:t.point,d:t.t*o,r:n.jumpRadius}),a.set(t.segIndex,r)}const c=[`M${g(r[0])}`];for(let t=0;t<i.length;t++){const e=i[t],o=Math.hypot(e.b.x-e.a.x,e.b.y-e.a.y),f=0===o?0:(e.b.x-e.a.x)/o,d=0===o?0:(e.b.y-e.a.y)/o,l=p(e);let u=0;if(s&&t>0){const e=y(r[t-1],r[t],r[t+1]??r[t],5);e&&(u=e.cutLen)}let x=o,b=null;s&&t<i.length-1&&(b=y(r[t],r[t+1],r[t+2]??r[t+1],5),b&&(x=o-b.cutLen));const M=[...a.get(t)??[]].sort((t,e)=>t.t-e.t);for(const t of M)t.r=Math.min(t.r,t.d-u,x-t.d);for(let t=0;t<M.length-1;t++){const e=M[t+1].d-M[t].d;if(M[t].r+M[t+1].r>e){const n=e/2;M[t].r=Math.min(M[t].r,n),M[t+1].r=Math.min(M[t+1].r,n)}}for(const t of M)t.r<.001||c.push(...m(t,f,d,l,n.jumpStyle));s&&b?(c.push(`L${h(b.startX)},${h(b.startY)}`),c.push(`Q${h(b.ctrlX)},${h(b.ctrlY)} ${h(b.endX)},${h(b.endY)}`)):c.push(`L${g(e.b)}`)}return c.join(" ")}function M(t){return/^[\d\s+,.LMelm-]*$/.test(t)}function K(t){return!t||("linear"===t||"rounded"===t||"step"===t||"stepBefore"===t||"stepAfter"===t)}function I(t){if(!t)return null;try{const e="function"==typeof atob?atob(t):Buffer.from(t,"base64").toString(),n=JSON.parse(e);if(!Array.isArray(n))return null;const o=[];for(const t of n)t&&"number"==typeof t.x&&"number"==typeof t.y&&o.push({x:t.x,y:t.y});return o.length>=2?o:null}catch{return null}}function S(t,e,n){if(!n.enabled)return;const o=t.node();if(!o)return;const r=new Map;for(const t of e)r.set(t.id,t);const s=[],i=new Map;for(const t of e){const e="undefined"!=typeof CSS&&CSS.escape?CSS.escape(t.id):t.id,n=o.querySelector(`path[data-id="${e}"]`);if(!n)continue;i.set(t.id,n);const r=I(n.getAttribute("data-points"))??t.points;s.push({...t,points:r})}const a=u(s);if(0===a.length)return;const c=new Map;for(const t of a){const e=c.get(t.jumpEdgeId)??[];e.push(t),c.set(t.jumpEdgeId,e)}for(const t of s){const e=c.get(t.id);if(!e||0===e.length)continue;const o=r.get(t.id),s=o?.curve;if(void 0!==s&&!K(s))continue;const a=i.get(t.id);if(!a)continue;if(void 0===s){if(!M(a.getAttribute("d")??""))continue}const f=a.getAttribute("style")??"",d=/stroke-dasharray\s*:\s*0\s+([\d.]+)\s+[\d.]+\s+([\d.]+)/.exec(f),l=d?Number.parseFloat(d[1]):null,u=d?Number.parseFloat(d[2]):null,h=b(t,e,n);if(a.setAttribute("d",h),null!==l&&null!==u&&"function"==typeof a.getTotalLength){const t=a.getTotalLength(),e=`0 ${l} ${Math.max(0,t-l-u)} ${u}`,n=f.replace(/stroke-dasharray\s*:[^;]*;?/g,`stroke-dasharray: ${e};`).replace(/;\s*;+/g,";");a.setAttribute("style",n)}}}function w(t,{measure:e}){const n=t.config?.swimlane?.lineHops;if(!1===n)return;const o="gap"===n?"gap":"arc",r=t.edges.filter(t=>Array.isArray(t.points)&&t.points.length>=2).map(t=>({id:t.id,points:t.points,curve:t.curve,arrowTypeStart:t.arrowTypeStart,arrowTypeEnd:t.arrowTypeEnd}));S(e.groups.edgePaths,r,{enabled:!0,jumpRadius:6,jumpStyle:o})}(0,i.K)(x,"applyMarkerOffsets"),(0,i.K)(m,"emitJump"),(0,i.K)(y,"computeRoundedCorner"),(0,i.K)(b,"rewriteEdgePath"),(0,i.K)(M,"isStraightPath"),(0,i.K)(K,"curveSupportsLineHops"),(0,i.K)(I,"decodeDataPoints"),(0,i.K)(S,"applyLineJumpsToSvg"),(0,i.K)(w,"applySwimlaneLineJumps");var v="__swimlane_default__";function C(t){return Math.max(t.padding??20,20)}function L(t){const{x:e,y:n,width:o,height:r}=t,s=t.swimlaneContentTop;if("number"!=typeof e||"number"!=typeof n||"number"!=typeof o||"number"!=typeof r||"number"!=typeof s||!Number.isFinite(e)||!Number.isFinite(n)||!Number.isFinite(o)||!Number.isFinite(r)||!Number.isFinite(s)||o<=0||r<=0)return void delete t.groupTitleRect;const i=n-r/2,a=Math.min(s,n+r/2),c=i+Math.min(21,Math.max(0,a-i));c<=i?delete t.groupTitleRect:t.groupTitleRect={left:e-o/2,right:e+o/2,top:i,bottom:c}}function k(t){const e=t.direction,n=t.nodes??=[];for(const n of t.nodes??[])n.isGroup&&!n.parentId&&(n.shape="swimlane",e&&(n.direction=e));const o=n.filter(t=>!t.isGroup&&!t.parentId);if(0===o.length)return;let r=n.find(t=>t.id===v);r?r.isGroup&&(r.shape="swimlane",e&&(r.direction=e)):(r={id:v,label:"",isGroup:!0,shape:"swimlane",padding:20,...e?{direction:e}:{}},n.push(r));for(const t of o)t.parentId=v}function O(t){const e=new Map;for(const n of t.nodes??[])e.set(n.id,n);const n=[];for(const e of t.edges??[]){const t="string"==typeof e.start?e.start:void 0,o="string"==typeof e.end?e.end:void 0;t&&o&&(e.labelNodeId||n.push({id:e.id,src:t,dst:o,ref:e}))}const o=t.nodes??[],r=o.filter(t=>t.isGroup),s=o.filter(t=>!t.isGroup);return{nodes:[...[...r].reverse(),...s].map(t=>t.id),edges:n,layout:t,nodeById:e}}function R(t,e,n,o){const{layout:r}=t,s=t.nodeById,i=o?.layerGap??100,a=o?.nodeGap??40;let c=0;for(const t of e.layers){let e=0;for(const o of t){const t=s.get(o);if(!t){e++;continue}t.layer=c,t.order=e;const r=n.x[o]??e*a,f=n.y[o]??c*i;t.x=r,t.y=f,e++}c++}const f=r.nodes??[],d=new Map,l=[];for(const t of f){if(!t?.isGroup)continue;t.parentId||l.push(t);const e=f.filter(e=>e.parentId===t.id);let o=1/0,r=-1/0,s=1/0,i=-1/0;for(const t of e){const e=t.x??n.x[t.id],a=t.y??n.y[t.id],c=t.width??0,f=t.height??0;null!=e&&null!=a&&(o=Math.min(o,e-c/2),r=Math.max(r,e+c/2),s=Math.min(s,a-f/2),i=Math.max(i,a+f/2))}if(o===1/0||s===1/0)t.x=t.x??0,t.y=t.y??0,t.width=t.width??0,t.height=t.height??0;else{const e=t.padding??20,n=t.parentId?e:2*C(t),a=e,c=Math.max(0,r-o)+n,f=Math.max(0,i-s)+a,l=(o+r)/2,u=(s+i)/2;t.x=l,t.y=u,t.width=c,t.height=f,d.set(t.id,{minX:o,maxX:r,minY:s,maxY:i})}}if(l.length>0&&d.size>0){let t=1/0,e=-1/0,n=0;for(const o of l){const r=o.padding??20;r>n&&(n=r);const s=d.get(o.id);s&&(t=Math.min(t,s.minY),e=Math.max(e,s.maxY))}if(t!==1/0&&e!==-1/0){const o=36,r=Math.max(0,e-t)+2*Math.max(n,o),s=(t+e)/2;for(const e of l)e.y=s,e.height=r,e.swimlaneContentTop=t;const i=[...l].sort((t,e)=>(t.x??0)-(e.x??0)),a=[],c=[],f=[];for(const t of i){const e=d.get(t.id);if(!e)continue;const n=Math.max(0,e.maxX-e.minX)+2*C(t),o=(e.minX+e.maxX)/2;a.push(t.id),c.push(o),f.push(n)}const u=a.length;if(u>0){const t=new Map;if(1===u)t.set(a[0],f[0]);else{const e=[];for(let t=0;t<u-1;t++)e.push(c[t+1]-c[t]);const n=new Array(u);n[0]=0;for(let t=0;t<u-1;t++)n[t+1]=2*e[t]-n[t];let o=0,r=Number.POSITIVE_INFINITY;for(let t=0;t<u;t++){const e=f[t];t%2==0?o=Math.max(o,e-n[t]):r=Math.min(r,n[t]-e)}let s=o;s=o<=r?(o+r)/2:o;for(let e=0;e<u;e++){const o=n[e]+(e%2==0?s:-s),r=Math.max(f[e],o);t.set(a[e],r)}}for(const e of l){const n=t.get(e.id);null!=n&&(e.width=n),L(e)}}}}}(0,i.K)(C,"topLaneHorizontalPadding"),(0,i.K)(L,"assignTopLaneTitleRect"),(0,i.K)(k,"prepareLayoutForSwimlanes"),(0,i.K)(O,"toGraphView"),(0,i.K)(R,"writeBackToLayoutData");function T(t){const e=[],n=[],o=new Map;for(const e of t.nodes)o.set(e.id,e);for(const r of t.edges){if(!r.label||0===r.label.length)continue;if(r.isLayoutOnly)continue;if(r.labelNodeId)continue;const t=r.start?o.get(r.start):void 0,i=r.end?o.get(r.end):void 0;if(!t||!i){s.R.warn("[EdgeLabelNodes]",`Edge ${r.id} has missing source or target node`);continue}const a=`edge-label-${r.start}-${r.end}-${r.id}`,c=t.parentId!==i.parentId?i.parentId:t.parentId,f={id:a,label:r.label,edgeStart:r.start??"",edgeEnd:r.end??"",shape:"labelRect",width:0,height:0,isEdgeLabel:!0,isDummy:!0,parentId:c,isGroup:!1,labelStyle:Array.isArray(r.labelStyle)?r.labelStyle[0]:r.labelStyle??"",...t.dir?{dir:t.dir}:{}};e.push(f),r.labelNodeId=a,r.label=void 0,r.text=void 0;const d={id:`${r.id}-to-label`,start:r.start,end:a,type:"normal",isLayoutOnly:!0},l={id:`${r.id}-from-label`,start:a,end:r.end,type:"normal",isLayoutOnly:!0};n.push(d,l)}const r=[...t.nodes,...e],i=[...t.edges,...n];return{...t,nodes:r,edges:i}}(0,i.K)(T,"createEdgeLabelNodes");var $=.001;function N(t){const e=t.x??0,n=t.y??0,o=t.width??0,r=t.height??0;return o>0&&r>0?{cx:e,cy:n,rect:Q(e,n,o,r)}:void 0}function B(t){if(t.isGroup)return;const e=N(t);if(!e)return;return{id:String(t.id??""),cx:e.cx,cy:e.cy,rect:e.rect}}function F(t,e,n=$){return Math.abs(t.x-e.x)<n&&Math.abs(t.y-e.y)<n}function E(t,e,n=$){return Math.abs(t.x-e.x)<n}function Y(t,e,n=$){return Math.abs(t.y-e.y)<n}function X(t,e,n=$){return Y(t,e,n)&&Math.abs(t.x-e.x)>n}function z(t,e,n=$){return E(t,e,n)&&Math.abs(t.y-e.y)>n}function A(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)))}function P(t,e,n=$){return t.horizontal&&e.horizontal&&Y(t.a,e.a,n)?A(t.a.x,t.b.x,e.a.x,e.b.x):t.vertical&&e.vertical&&E(t.a,e.a,n)?A(t.a.y,t.b.y,e.a.y,e.b.y):0}function D(t,e=$){const n=[];for(let o=0;o<t.length-1;o++){const r=t[o],s=t[o+1],i=X(r,s,e),a=z(r,s,e);(i||a)&&n.push({index:o,a:r,b:s,horizontal:i,vertical:a})}return n}function G(t,e=$){const n=D(t,e);let o=0;for(let t=1;t<n.length;t++)n[t-1].horizontal!==n[t].horizontal&&o++;return o}function H(t,e=$){const n=[];for(const o of t){const t=n.length>0?n[n.length-1]:void 0;t&&F(t,o,e)||n.push({x:o.x,y:o.y})}return n}function j(t,e=$){if(!t||4!==t.length)return;const[n,o,r,s]=t;if(X(n,o,e)&&z(o,r,e)&&X(r,s,e))return{kind:"HVH",p0:n,p1:o,p2:r,p3:s};return z(n,o,e)&&X(o,r,e)&&z(r,s,e)?{kind:"VHV",p0:n,p1:o,p2:r,p3:s}:void 0}function V(t,e,n,o=0){const r=Math.min(t.x,e.x),s=Math.max(t.x,e.x),i=Math.min(t.y,e.y),a=Math.max(t.y,e.y);return s>n.left-o&&r<n.right+o&&a>n.top-o&&i<n.bottom+o}function _(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}function W(t,e){return t.left<=e.left&&t.right>=e.right&&t.top<=e.top&&t.bottom>=e.bottom}function q(t,e){return t.left<e.right&&t.right>e.left&&t.top<e.bottom&&t.bottom>e.top}function J(t,e){return{left:t.left-e,right:t.right+e,top:t.top-e,bottom:t.bottom+e}}function Q(t,e,n,o){return{left:t-n/2,right:t+n/2,top:e-o/2,bottom:e+o/2}}function U(t){return N(t)?.rect}function Z(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}}}function tt(t,e,n,o,r,s=$){const i="left"===e||"right"===e,a="left"===o||"right"===o;if(i&&a){if("right"===e&&"left"===o&&t.x<n.x||"left"===e&&"right"===o&&t.x>n.x){if(Y(t,n,s))return[t,n];const e=(t.x+n.x)/2;return[t,{x:e,y:t.y},{x:e,y:n.y},n]}if(e===o){if(Y(t,n,s))return;const o="left"===e?Math.min(t.x,n.x)-r:Math.max(t.x,n.x)+r;return[t,{x:o,y:t.y},{x:o,y:n.y},n]}return}if(!i&&!a){if(e===o){if(E(t,n,s))return;const o="top"===e?Math.min(t.y,n.y)-r:Math.max(t.y,n.y)+r;return[t,{x:t.x,y:o},{x:n.x,y:o},n]}if(!("bottom"===e&&"top"===o&&t.y<n.y||"top"===e&&"bottom"===o&&t.y>n.y))return;if(E(t,n,s))return[t,n];const i=(t.y+n.y)/2;return[t,{x:t.x,y:i},{x:n.x,y:i},n]}if(i&&!a){const r="right"===e&&n.x>t.x||"left"===e&&n.x<t.x,s="top"===o&&t.y<n.y||"bottom"===o&&t.y>n.y;return r&&s?[t,{x:n.x,y:t.y},n]:void 0}const c="bottom"===e&&n.y>t.y||"top"===e&&n.y<t.y,f="left"===o&&t.x<n.x||"right"===o&&t.x>n.x;return c&&f?[t,{x:t.x,y:n.y},n]:void 0}function et(t,e,n,o){return"left"===e||"right"===e?[t,{x:o,y:t.y},{x:o,y:n.y},n]:[t,{x:t.x,y:o},{x:n.x,y:o},n]}function nt(t){const e=new Map,n=[];for(const o of t){if(o.isEdgeLabel)continue;const t=B(o);t&&(e.set(t.id,t),n.push({id:t.id,rect:t.rect}))}return{nodeInfoById:e,realNodeRects:n}}function ot(t){const e=[],n=[];for(const o of t){const t=B(o);if(!t)continue;const r={id:t.id,rect:t.rect};o.isEdgeLabel?n.push(r):e.push(r)}return{realNodeRects:e,labelNodeRects:n}}function rt(t,{includeEdgeLabels:e=!0}={}){const n=[];for(const o of t){if(o.isGroup||!e&&o.isEdgeLabel)continue;const t=o.x??0,r=o.y??0,s=o.width??0,i=o.height??0;n.push({nodeId:o.id,...Q(t,r,s,i)})}return n}function st(t,e,n=$){const o=t.start,r=t.end;if(!o||!r)return;const s=e.get(o),i=e.get(r);return s&&i?{srcId:o,dstId:r,srcInfo:s,dstInfo:i,collinearX:Math.abs(s.cx-i.cx)<n,collinearY:Math.abs(s.cy-i.cy)<n}:void 0}function it(t,e,n,o=[],r=0){for(const s of n)if(!o.includes(s.id)&&V(t,e,s.rect,-r))return!0;return!1}function at(t,e,n,o,r=$,s=1e-6){const i=Y(t,e,r),a=E(t,e,r),c=Y(n,o,r),f=E(n,o,r);if(i&&c||a&&f)return!1;if(!i&&!a||!c&&!f)return!1;const d=i?{a:t,b:e}:{a:n,b:o},l=a?{a:t,b:e}:{a:n,b:o},u=d.a.y,h=Math.min(d.a.x,d.b.x),g=Math.max(d.a.x,d.b.x),p=l.a.x,x=Math.min(l.a.y,l.b.y),m=Math.max(l.a.y,l.b.y);if(p<h||p>g||u<x||u>m)return!1;const y=Math.abs(p-d.a.x)<s&&Math.abs(u-d.a.y)<s||Math.abs(p-d.b.x)<s&&Math.abs(u-d.b.y)<s,b=Math.abs(p-l.a.x)<s&&Math.abs(u-l.a.y)<s||Math.abs(p-l.b.x)<s&&Math.abs(u-l.b.y)<s;return!(y&&b)}function ct(t,e,n,o,r=$){const s=Y(t,e,r),i=E(t,e,r),a=Y(n,o,r),c=E(n,o,r);return i&&c&&E(t,n,r)?A(t.y,e.y,n.y,o.y)>r:!!(s&&a&&Y(t,n,r))&&A(t.x,e.x,n.x,o.x)>r}function ft(t,e,n,o,{epsilon:r=$,skipDegenerateOther:s=!1}={}){for(const i of n){if(i===o||i.isLayoutOnly)continue;const n=i.points;if(n&&!(n.length<2))for(let o=0;o<n.length-1;o++){const i=n[o],a=n[o+1];if((!s||!F(i,a,r))&&(at(t,e,i,a,r)||ct(t,e,i,a,r)))return!0}}return!1}function dt(t,e,n,o,r=$){const s=Y(t,e,r),i=E(t,e,r),a=Y(n,o,r),c=E(n,o,r);if(!(s&&c||i&&a))return!1;const f=s?{a:t,b:e}:{a:n,b:o},d=s?{a:n,b:o}:{a:t,b:e},l=f.a.y,u=Math.min(f.a.x,f.b.x),h=Math.max(f.a.x,f.b.x),g=d.a.x,p=Math.min(d.a.y,d.b.y),x=Math.max(d.a.y,d.b.y);return g>u+r&&g<h-r&&l>p+r&&l<x-r}function lt(t,e,n){const o=Math.min(e,n),r=Math.max(e,n);return t>o+$&&t<r-$}function ut(t,e,n){return E(t,e)&&E(e,n)?lt(e.y,t.y,n.y):!(!Y(t,e)||!Y(e,n))&<(e.x,t.x,n.x)}function ht(t){let e=!1;const n=[];for(let o=0;o<t.length;o++){const r=n[n.length-1],s=t[o],i=o+1<t.length?t[o+1]:void 0;if(r&&i){if(F(r,i)){o++,e=!0;continue}if(ut(r,s,i)){e=!0;continue}}n.push(s)}return{points:n,changed:e}}function gt(t){const e=[t[0]];for(let n=1;n<t.length;n++){const o=e[e.length-1],r=t[n];if(!E(o,r)&&!Y(o,r)){const t=e.length>=2?e[e.length-2]:void 0,n=!!t&&E(t,o)?{x:o.x,y:r.y}:{x:r.x,y:o.y};e.push(n)}e.push(r)}const n=[];for(const t of e){const e=n[n.length-1];e&&F(e,t)||n.push(t)}return n}function pt(t){if(t.length<3)return t;let e=[...t];for(let t=0;t<32;t++){const t=ht(e);if(e=t.points,!t.changed)break}return e}(0,i.K)(N,"measuredNodeRect"),(0,i.K)(B,"nodeBoundsInfoFor"),(0,i.K)(F,"samePoint"),(0,i.K)(E,"sameX"),(0,i.K)(Y,"sameY"),(0,i.K)(X,"isHorizontalSegment"),(0,i.K)(z,"isVerticalSegment"),(0,i.K)(A,"overlapLength"),(0,i.K)(P,"sameAxisSegmentOverlapLength"),(0,i.K)(D,"orthogonalSegmentsForPoints"),(0,i.K)(G,"countOrthogonalBends"),(0,i.K)(H,"dedupeConsecutivePoints"),(0,i.K)(j,"classifyThreeSegmentRoute"),(0,i.K)(V,"segmentBoundsOverlapRect"),(0,i.K)(_,"pointInsideRect"),(0,i.K)(W,"rectContainsRect"),(0,i.K)(q,"rectsOverlap"),(0,i.K)(J,"inflateRect"),(0,i.K)(Q,"rectFromCenterSize"),(0,i.K)(U,"rectOfNodeBounds"),(0,i.K)(Z,"portForRectSide"),(0,i.K)(tt,"buildOrthogonalPortPath"),(0,i.K)(et,"buildSameSideTrackPath"),(0,i.K)(nt,"collectRealNodeBounds"),(0,i.K)(ot,"collectNodeRectEntries"),(0,i.K)(rt,"collectLayoutNodeRects"),(0,i.K)(st,"getNodePairGeometry"),(0,i.K)(it,"segmentHitsAnyRect"),(0,i.K)(at,"orthogonalSegmentsCross"),(0,i.K)(ct,"sameAxisSegmentsOverlap"),(0,i.K)(ft,"segmentConflictsWithAnyEdge"),(0,i.K)(dt,"orthogonalSegmentsStrictlyCross"),(0,i.K)(lt,"strictlyBetween"),(0,i.K)(ut,"isCollinearIntermediate"),(0,i.K)(ht,"simplifyPolylineOnce"),(0,i.K)(gt,"orthogonalizePolyline"),(0,i.K)(pt,"simplifyPolyline");var xt=.001;function mt(t,e,n){const o=t;if(o.isLayoutOnly||!o.points||o.points.length<n)return;const r=o.start?e.get(o.start):void 0,s=o.end?e.get(o.end):void 0;return{edge:o,points:o.points,srcRect:r?U(r):void 0,dstRect:s?U(s):void 0}}function yt(t,e,n){if(Y(t,e,xt)){return{x:t.x<n.left?n.left:n.right,y:t.y}}if(E(t,e,xt)){const e=t.y<n.top?n.top:n.bottom;return{x:t.x,y:e}}return{x:Math.min(n.right,Math.max(n.left,t.x)),y:Math.min(n.bottom,Math.max(n.top,t.y))}}function bt(t,e,n){const o=n?1:-1;let r=n?0:t.length-1;for(;r>=0&&r<t.length&&_(t[r],e,.5);)r+=o;if(r<0||r>=t.length)return t;const s=r-o;if(s<0||s>=t.length)return t;const i=yt(t[r],t[s],e);return n?[i,...t.slice(r)]:[...t.slice(0,r+1),i]}function Mt(t,e){for(const n of t){const t=mt(n,e,2);if(!t)continue;let o=[...t.points];t.srcRect&&(o=bt(o,t.srcRect,!0)),t.dstRect&&(o=bt(o,t.dstRect,!1)),o=pt(gt(o)),o=Tt(o,t.srcRect,t.dstRect),t.edge.points=pt(gt(o))}}function Kt(t,e,n,o=!1){if(Y(t,e,xt)){if(e.y<n.top-xt||e.y>n.bottom+xt)return e;if(o){if(t.x<n.left-xt)return{x:n.left,y:t.y};if(t.x>n.right+xt)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(E(t,e,xt)){if(e.x<n.left-xt||e.x>n.right+xt)return e;if(o){if(t.y<n.top-xt)return{x:t.x,y:n.top};if(t.y>n.bottom+xt)return{x:t.x,y:n.bottom}}const r=Math.abs(e.y-n.top)<=Math.abs(e.y-n.bottom);return{x:t.x,y:r?n.top:n.bottom}}return e}function It(t,e,n){const o=t[e];for(let r=e+n;r>=0&&r<t.length;r+=n){const e=t[r];if(!F(e,o,xt))return e}return t[e+n]}function St(t,e){const n=t+4,o=e-4;return n<=o?{lo:n,hi:o}:{lo:(t+e)/2,hi:(t+e)/2}}function wt(t,e,n){const{lo:o,hi:r}=St(e,n);return Math.min(r,Math.max(o,t))}function vt(t){const e=Math.max(...t.map(t=>t.lo)),n=Math.min(...t.map(t=>t.hi));if(!(e>n))return{lo:e,hi:n}}function Ct(t,e){return"left"===e||"right"===e?St(t.top,t.bottom):St(t.left,t.right)}function Lt(t,e,n){const o=t.y>=n.top-xt&&t.y<=n.bottom+xt,r=t.x>=n.left-xt&&t.x<=n.right+xt;if(Y(t,e,xt)&&o){if(Math.abs(t.x-n.left)<xt)return"left";if(Math.abs(t.x-n.right)<xt)return"right"}if(E(t,e,xt)&&r){if(Math.abs(t.y-n.top)<xt)return"top";if(Math.abs(t.y-n.bottom)<xt)return"bottom"}}function kt(t){return"left"===t||"right"===t}function Ot(t,e,n,o,r){const s=[],i=n?Lt(t,e,n):void 0,a=o?Lt(e,t,o):void 0;return n&&i&&kt(i)===r&&s.push(Ct(n,i)),o&&a&&kt(a)===r&&s.push(Ct(o,a)),s.length>0?vt(s):void 0}function Rt(t,e,n,o,r){const s=Ot(t,e,n,o,r);if(!s)return;const i=r?t.y:t.x,a=Math.min(s.hi,Math.max(s.lo,i));return Math.abs(a-i)<xt?void 0:r?[{x:t.x,y:a},{x:e.x,y:a}]:[{x:a,y:t.y},{x:a,y:e.y}]}function Tt(t,e,n){if(2!==t.length)return t;const[o,r]=t;return Y(o,r,xt)?Rt(o,r,e,n,!0)??t:E(o,r,xt)?Rt(o,r,e,n,!1)??t:t}function $t(t,e,n){return kt(n)?{x:t.x,y:wt(t.y,e.top,e.bottom)}:{x:wt(t.x,e.left,e.right),y:t.y}}function Nt(t,e,n,o,r,s){const i=t.map(t=>({...t}));for(let a=e;a>=0&&a<t.length;a+=n){const e=t[a];if(s&&!Y(e,o,xt))break;if(!s&&!E(e,o,xt))break;s?i[a].y=r.y:i[a].x=r.x}return i}function Bt(t,e,n){if(t.length<2)return t;const o=n?0:t.length-1,r=n?1:-1,s=t[o],i=It(t,o,r);if(!i)return t;const a=Lt(s,i,e);if(!a)return t;const c=kt(a),f=$t(s,e,a);return F(s,f,xt)?t:Nt(t,o,r,s,f,c)}function Ft(t,e,n){const o=Math.min(t.x,e.x)>=n.left-xt&&Math.max(t.x,e.x)<=n.right+xt,r=Math.min(t.y,e.y)>=n.top-xt&&Math.max(t.y,e.y)<=n.bottom+xt;return Math.abs(t.y-n.top)<xt&&Math.abs(e.y-n.top)<xt&&o?"top":Math.abs(t.y-n.bottom)<xt&&Math.abs(e.y-n.bottom)<xt&&o?"bottom":Math.abs(t.x-n.left)<xt&&Math.abs(e.x-n.left)<xt&&r?"left":Math.abs(t.x-n.right)<xt&&Math.abs(e.x-n.right)<xt&&r?"right":void 0}function Et(t,e,n,o){switch(t){case"top":return E(e,n,xt)&&n.y<o.top-xt;case"bottom":return E(e,n,xt)&&n.y>o.bottom+xt;case"left":return Y(e,n,xt)&&n.x<o.left-xt;case"right":return Y(e,n,xt)&&n.x>o.right+xt}}function Yt(t,e,n){if(t.length<3)return t;if(n){const n=Ft(t[0],t[1],e);return n&&Et(n,t[1],t[2],e)?t.slice(1):t}const o=t.length-1,r=Ft(t[o-1],t[o],e);return r&&Et(r,t[o-1],t[o-2],e)?t.slice(0,o):t}function Xt(t,e,n){let o=t;if(e){const t=It(o,0,1);if(t){const n=Kt(t,o[0],e);n!==o[0]&&(o=[n,...o.slice(1)])}o=Yt(o,e,!0)}if(n){const t=o.length-1,e=It(o,t,-1);if(e){const r=Kt(e,o[t],n,!0);r!==o[t]&&(o=[...o.slice(0,t),r])}o=Yt(o,n,!1)}const r=Tt(o,e,n);return r!==o||2===o.length?r:(e&&(o=Bt(o,e,!0)),n&&(o=Bt(o,n,!1)),o)}function zt(t,e){for(const n of t){const t=mt(n,e,2);if(!t)continue;const o=Xt(H(t.points,xt),t.srcRect,t.dstRect);if(o.length<3){t.edge.points=o;continue}const r=[o[0],{...o[0]},...o.slice(1,-1),o[o.length-1],{...o[o.length-1]}];t.edge.points=r}}function At(t){return new Map(t.map(t=>[t.id,t]))}function Pt(t,e){let n=t.parentId,o=null;for(;n;){const t=e.get(n);if(!t?.isGroup)break;o=t.id,n=t.parentId}return o}function Dt(t,e){let n=0,o=t.parentId;for(;o;){const t=e.get(o);if(!t?.isGroup)break;n++,o=t.parentId}return n}function Gt(t){let e=1/0,n=-1/0,o=1/0,r=-1/0;for(const s of t){const t=s.x,i=s.y;if("number"!=typeof t||"number"!=typeof i)continue;const a=s.width??0,c=s.height??0;e=Math.min(e,t-a/2),n=Math.max(n,t+a/2),o=Math.min(o,i-c/2),r=Math.max(r,i+c/2)}return e===1/0||o===1/0?null:{minX:e,maxX:n,minY:o,maxY:r}}function Ht(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}function jt(t){const e=At(t),n=t.filter(t=>t.isGroup&&t.parentId).sort((t,n)=>Dt(n,e)-Dt(t,e));for(const e of n){const n=Gt(t.filter(t=>t.parentId===e.id));n&&Ht(e,n)}}function Vt(t,e){const n=t.nodes??[],o=t.edges??[],r=n.filter(t=>!t.isGroup);let s=1/0,a=-1/0;for(const t of r){const n=t[e];"number"==typeof n&&(s=Math.min(s,n),a=Math.max(a,n))}if(!Number.isFinite(s)||!Number.isFinite(a))return!1;const c=(0,i.K)(t=>s+a-t,"mirror");for(const t of n){const n=t[e];"number"==typeof n&&(t[e]=c(n));const o=t.groupTitleRect;o&&(t.groupTitleRect="x"===e?{...o,left:c(o.right),right:c(o.left)}:{...o,top:c(o.bottom),bottom:c(o.top)})}for(const t of o)for(const n of t.points??[])n[e]=c(n[e]);return!0}function _t(t){return!(t.nodes??[]).some(t=>!t.isGroup)||Vt(t,"y")}function Wt(t,e="LR"){const n=t.nodes??[],o=t.edges??[],r=n.filter(t=>!t.isGroup);let s=1/0,i=1/0;for(const t of r){const e=t.x??0,n=t.y??0;e<s&&(s=e),n<i&&(i=n)}if(!Number.isFinite(s)||!Number.isFinite(i))return!1;const a=36;let c=0,f=0;for(const t of r)c+=t.width??0,f+=t.height??0;const d=c/r.length,l=f/r.length,u=l>0?Math.max(1,d/l):1;for(const t of r){const e=t.x??0,n=((t.y??0)-i)*u+a,o=e-s;t.x=n,t.y=o}for(const t of o)if(t.points)for(const e of t.points){const t=e.x,n=(e.y-i)*u+a,o=t-s;e.x=n,e.y=o}jt(n);const h=n.filter(t=>t.isGroup&&!t.parentId);if(0===h.length)return"RL"===e&&Vt(t,"x"),!0;const g=At(n),p=new Map;for(const t of n){if(t.isGroup)continue;const e=Pt(t,g);if(!e)continue;const n=p.get(e)??[];n.push(t),p.set(e,n)}let x=0;for(const t of h){const e=t.padding??0;e>x&&(x=e)}const m=[];let y=1/0,b=-1/0;for(const t of h){const e=Gt(p.get(t.id)??[]);e&&(y=Math.min(y,e.minX),b=Math.max(b,e.maxX),m.push({lane:t,contentTop:e.minY,contentBottom:e.maxY,centerY:(e.minY+e.maxY)/2}))}if(y===1/0||b===-1/0)return!0;const M=Math.max(0,b-y)+2*Math.max(x,10),K=a+M,I=(y+b)/2-M/2-a,S=I+K/2,w=Math.max(x,a);m.sort((t,e)=>t.centerY-e.centerY);for(let t=0;t<m.length;t++){const e=m[t];let n,o;if(0===t)n=e.contentTop-w;else{n=(m[t-1].contentBottom+e.contentTop)/2}if(t===m.length-1)o=e.contentBottom+w;else{const n=m[t+1];o=(e.contentBottom+n.contentTop)/2}const r=Math.max(0,o-n),s=(n+o)/2;e.lane.x=S,e.lane.y=s,e.lane.width=K,e.lane.height=r,e.lane.swimlaneContentTop=e.contentTop,e.lane.groupTitleRect={left:I,right:I+a,top:n,bottom:o}}return"RL"===e&&Vt(t,"x"),!0}(0,i.K)(mt,"endpointContextFor"),(0,i.K)(yt,"segmentEnterPoint"),(0,i.K)(bt,"clipEndpoint"),(0,i.K)(Mt,"clipEdgeEndpointsToNodeBoundaries"),(0,i.K)(Kt,"snapEndpointToBoundary"),(0,i.K)(It,"firstDistinctAdjacent"),(0,i.K)(St,"cornerClearanceRange"),(0,i.K)(wt,"clampToCornerClearance"),(0,i.K)(vt,"intersectRanges"),(0,i.K)(Ct,"clearanceRangeForSide"),(0,i.K)(Lt,"terminalSideForSegment"),(0,i.K)(kt,"isHorizontalSide"),(0,i.K)(Ot,"straightClearanceRange"),(0,i.K)(Rt,"clearStraightEndpointCornerAxis"),(0,i.K)(Tt,"clearStraightEndpointCornerConnections"),(0,i.K)($t,"cornerClearedEndpoint"),(0,i.K)(Nt,"moveCollinearEndpointRun"),(0,i.K)(Bt,"clearEndpointCornerConnection"),(0,i.K)(Ft,"borderSideForSegment"),(0,i.K)(Et,"leavesOutward"),(0,i.K)(Yt,"collapseOwnBorderStub"),(0,i.K)(Xt,"snapAndCollapseEndpoints"),(0,i.K)(zt,"prepareEdgeEndpointsForRenderer"),(0,i.K)(At,"buildNodeMap"),(0,i.K)(Pt,"resolveTopLevelGroupId"),(0,i.K)(Dt,"groupDepth"),(0,i.K)(Gt,"boundsForChildren"),(0,i.K)(Ht,"applyGroupBounds"),(0,i.K)(jt,"recomputeNestedGroupBounds"),(0,i.K)(Vt,"mirrorAxis"),(0,i.K)(_t,"applyBtDirectionTransform"),(0,i.K)(Wt,"applyLrDirectionTransform");var qt=1e-6,Jt=[0,8,-8,16,-16];function Qt(t,e){const{nodeInfoById:n,realNodeRects:o}=nt(e);for(const e of t){if(e.isLayoutOnly)continue;const r=e.points;if(!r||r.length<4)continue;const s=j(H(r,qt),qt);if(!s)continue;const{p3:i}=s,a="HVH"===s.kind,c=st(e,n,qt);if(!c)continue;const{srcId:f,dstId:d,srcInfo:l,dstInfo:u,collinearX:h,collinearY:g}=c;if(h||g)continue;let p;const x=l.rect;for(const n of Jt){let r,s,c;if(a){const t=u.cy>l.cy?x.bottom:x.top,e=l.cx+n;if(e<=x.left+qt||e>=x.right-qt)continue;r={x:e,y:t},s={x:e,y:i.y},c={x:i.x,y:i.y}}else{const t=u.cx>l.cx?x.right:x.left,e=l.cy+n;if(e<=x.top+qt||e>=x.bottom-qt)continue;r={x:t,y:e},s={x:i.x,y:e},c={x:i.x,y:i.y}}const h=F(r,s,qt),g=F(s,c,qt);if(h&&g)continue;if(!h&&it(r,s,o,[f],1))continue;if(!g&&it(s,c,o,[d],1))continue;const m=!h&&ft(r,s,t,e,{epsilon:qt,skipDegenerateOther:!0}),y=!g&&ft(s,c,t,e,{epsilon:qt,skipDegenerateOther:!0});if(!m&&!y){p=h?[s,c]:g?[r,s]:[r,s,c];break}}p&&(e.points=p)}}function Ut(t,e){const n=.001,{realNodeRects:o,labelNodeRects:r}=ot(e.values());for(const s of t){if(s.isLayoutOnly)continue;const a=s.points;if(!a||a.length<4)continue;const c=H(a,n);if(c.length<4)continue;const f=c.length-1,d=c[f],l=c[f-1],u=c[f-2],h=d.x-l.x,g=d.y-l.y,p=Math.hypot(h,g);if(p>=10||p<n)continue;const x=l.x-u.x,m=l.y-u.y;if(Math.hypot(x,m)<n)continue;const y=X(l,d,n),b=z(l,d,n),M=X(u,l,n),K=z(u,l,n);if(!(y&&K||b&&M))continue;const I=s.end,S=s.start,w=I?e.get(I):void 0;if(!w)continue;const v=w.x??0,C=w.y??0,L=U(w);if(!L)continue;let k,O;if(K){const t=m<0;k={x:v,y:u.y},O={x:v,y:t?L.bottom:L.top}}else{const t=x>0;k={x:u.x,y:C},O={x:t?L.right:L.left,y:C}}if(it(k,O,o,I?[I]:[],-2))continue;if(it(k,O,r,[],-2))continue;if(S){const t=e.get(S),n=t?U(t):void 0;if(n&&_(k,n,2))continue}const R=(0,i.K)((t,e)=>`${t.x.toFixed(3)},${t.y.toFixed(3)}|${e.x.toFixed(3)},${e.y.toFixed(3)}`,"ownSegmentKey"),T=new Set;for(let t=0;t<c.length-1;t++)T.add(R(c[t],c[t+1]));const $=(0,i.K)((e,o)=>{for(const r of t){if(r===s)continue;if(r.isLayoutOnly)continue;const t=r.points;if(t&&!(t.length<2))for(let r=0;r<t.length-1;r++){const s=t[r],i=t[r+1];if(!T.has(R(s,i))&&dt(e,o,s,i,n))return!0}}return!1},"segmentCrossesOtherEdge");if($(k,O))continue;if(f-3>=0){const t=c[f-3];if(it(t,k,o,[S,I].filter(t=>Boolean(t)),-2))continue;if($(t,k))continue}const N=[...c.slice(0,f-2),k,O];s.points=N;const B=s.labelNodeId;if(B){const t=e.get(B);if(t){const e=t.width??0,o=t.height??0;if(e>0&&o>0){let r,s,i=-1;for(let t=0;t<N.length-1;t++){const a=N[t],c=N[t+1],f=Math.hypot(c.x-a.x,c.y-a.y),d=Y(a,c,n),l=E(a,c,n);(d&&f>=e+2||l&&f>=o+2)&&(f>i&&(i=f,r=(a.x+c.x)/2,s=(a.y+c.y)/2))}void 0!==r&&void 0!==s&&(t.x=r,t.y=s)}}}}}(0,i.K)(Qt,"portSwapToLShape"),(0,i.K)(Ut,"collapseShortTerminalStub");var Zt=.001,te=D,ee=(0,i.K)((t,e)=>E(t,e,Zt)||Y(t,e,Zt),"orthogonallyAligned");function ne(t,e){const n=(0,i.K)((t,e)=>{const n=t.x??0,o=t.y??0,r=e.x-n,s=e.y-o;let i=(t.width??0)/2,a=(t.height??0)/2;return Math.abs(s)*i>Math.abs(r)*a?(s<0&&(a=-a),{x:n+(0===s?0:a*r/s),y:o+a}):(r<0&&(i=-i),{x:n+i,y:o+(0===r?0:i*s/r)})},"rectIntersect"),o=(0,i.K)((t,o)=>{const r=H(t.points??[]);if(r.length<2)return;const s=o?t.start:t.end,i=s?e.get(s):void 0,a=i?U(i):void 0;if(!i||!s||!a)return;const c=o?r[0]:r[r.length-1],f=o?r[1]:r[r.length-2],d=n(i,c);let l=c;return ee(f,d)&&(l=f),E(d,l,Zt)?{edge:t,edgeId:String(t.id??""),nodeId:s,atStart:o,orientation:"V",coord:d.x,min:Math.min(d.y,l.y),max:Math.max(d.y,l.y),boundary:d,railEnd:l,rect:a}:Y(d,l,Zt)?{edge:t,edgeId:String(t.id??""),nodeId:s,atStart:o,orientation:"H",coord:d.y,min:Math.min(d.x,l.x),max:Math.max(d.x,l.x),boundary:d,railEnd:l,rect:a}:void 0},"terminalLaneFor"),r=(0,i.K)((t,e)=>Math.max(0,Math.min(t.max,e.max)-Math.max(t.min,e.min)),"projectedOverlapLength"),s=(0,i.K)((t,e)=>{if(t.nodeId!==e.nodeId||t.orientation!==e.orientation)return!1;if("H"===t.orientation){return(Math.abs(t.boundary.x-t.rect.left)<1||Math.abs(t.boundary.x-t.rect.right)<1)&&E(t.boundary,e.boundary,1)}return(Math.abs(t.boundary.y-t.rect.top)<1||Math.abs(t.boundary.y-t.rect.bottom)<1)&&Y(t.boundary,e.boundary,1)},"sameTerminalFace"),a=(0,i.K)((t,e)=>{if(t.nodeId!==e.nodeId||t.orientation!==e.orientation)return!1;return r(t,e)>=8&&Math.abs(t.coord-e.coord)<.5},"exactTerminalLaneConflict"),c=(0,i.K)((t,e)=>{if(t.nodeId!==e.nodeId||t.orientation!==e.orientation||"H"!==t.orientation||t.atStart===e.atStart)return!1;const n=r(t,e);if(n<8)return!1;const o=t.rect.bottom-t.rect.top;return!(n<o||n>2*o)&&(s(t,e)&&Math.abs(t.coord-e.coord)<16)},"nearTerminalLaneConflict"),f=(0,i.K)((t,e)=>{const n=H(t.edge.points??[]);if(n.length<2)return;const o="V"===t.orientation?{x:t.boundary.x+e,y:t.boundary.y}:{x:t.boundary.x,y:t.boundary.y+e},r="V"===t.orientation?{x:t.railEnd.x+e,y:t.railEnd.y}:{x:t.railEnd.x,y:t.railEnd.y+e};if(!(0,i.K)(()=>Math.abs(t.boundary.y-t.rect.top)<1||Math.abs(t.boundary.y-t.rect.bottom)<1?Y(o,t.boundary,Zt)&&o.x>=t.rect.left+1&&o.x<=t.rect.right-1:(Math.abs(t.boundary.x-t.rect.left)<1||Math.abs(t.boundary.x-t.rect.right)<1)&&(E(o,t.boundary,Zt)&&o.y>=t.rect.top+1&&o.y<=t.rect.bottom-1),"boundaryStaysOnSameFace")())return;if(t.atStart){const e=n.length>1&&F(n[1],t.railEnd,Zt),s=n.slice(e?2:1),i=s[0];if(i&&!ee(i,r))return;return[o,r,...s]}const s=n.length>1&&F(n[n.length-2],t.railEnd,Zt),a=n.slice(0,s?-2:-1),c=a[a.length-1];return!c||ee(c,r)?[...a,r,o]:void 0},"shiftedCandidate"),d=(0,i.K)(t=>{const n=t.edge,o=H(n.points??[]);if(2!==o.length)return!1;const r=n.start,s=n.end,i=r?e.get(r):void 0,a=s?e.get(s):void 0;if(!i||!a)return!1;const c=i.x??0,f=i.y??0,d=a.x??0,l=a.y??0,[u,h]=o;return Y(u,h,Zt)&&Math.abs(f-l)<1&&Math.abs(c-d)>1||E(u,h,Zt)&&Math.abs(c-d)<1&&Math.abs(f-l)>1},"laneIsStraightCollinearConnector"),l=[-7,7,-14,14,-21,21];for(let e=0;e<8;e++){const e=t.filter(t=>!t.isLayoutOnly).flatMap(t=>[o(t,!0),o(t,!1)]).filter(t=>Boolean(t));let n=!1;for(let t=0;t<e.length&&!n;t++)for(let r=t+1;r<e.length&&!n;r++){const s=e[t],i=e[r];if(s.edge===i.edge||!a(s,i)&&!c(s,i))continue;const u=!a(s,i),h=[s,i].sort((t,e)=>{const n=d(t),o=d(e);return n!==o?Number(n)-Number(o):Number(!e.atStart)-Number(!t.atStart)});for(const t of h){for(const r of l){const s=f(t,r);if(!s)continue;const i=o({...t.edge,points:s},t.atStart);if(i&&!e.some(e=>e.edge!==t.edge&&(a(i,e)||u&&c(i,e)))){t.edge.points=s,n=!0;break}}if(n)break}}if(!n)return}}function oe(t,e){const{realNodeRects:n,labelNodeRects:o}=ot(e.values()),r=(0,i.K)((e,r)=>{const s=e.start,i=e.end,a=te(r);if(a.length!==r.length-1)return!1;const c=[s,i].filter(t=>Boolean(t));for(const t of a){if(it(t.a,t.b,n,c,-2))return!1;if(it(t.a,t.b,o,[],-2))return!1}for(const n of t){if(n===e||n.isLayoutOnly)continue;const t=n.points;if(t&&!(t.length<2))for(const e of a)for(const n of te(H(t))){if(P(e,n,.5)>=8)return!1;if(dt(e.a,e.b,n.a,n.b,Zt))return!1}}return!0},"candidateIsSafe"),s=(0,i.K)((t,e)=>{if(e+4>=t.length)return;const n=t[e],o=t[e+1],r=t[e+2],s=t[e+3],i=t[e+4],a=X(n,o)&&z(o,r)&&X(r,s)&&z(s,i)&&E(n,s,Zt)&&E(n,i,Zt)&&E(o,r,Zt)&&(o.x-n.x)*(s.x-r.x)<0,c=z(n,o)&&X(o,r)&&z(r,s)&&X(s,i)&&Y(n,s,Zt)&&Y(n,i,Zt)&&Y(o,r,Zt)&&(o.y-n.y)*(s.y-r.y)<0;if(a||c)return H([...t.slice(0,e+1),i,...t.slice(e+5)]);if(e+5>=t.length)return;const f=t[e+5],d=z(n,o)&&X(o,r)&&z(r,s)&&X(s,i)&&z(i,f)&&E(n,i,Zt)&&E(n,f,Zt)&&E(r,s,Zt)&&(r.x-o.x)*(i.x-s.x)<0,l=X(n,o)&&z(o,r)&&X(r,s)&&z(s,i)&&X(i,f)&&Y(n,i,Zt)&&Y(n,f,Zt)&&Y(r,s,Zt)&&(r.y-o.y)*(i.y-s.y)<0;return d||l?H([...t.slice(0,e+1),f,...t.slice(e+6)]):void 0},"withoutDogleg");for(let e=0;e<8;e++){let e=!1;for(const n of t){if(n.isLayoutOnly)continue;const t=H(n.points??[]);for(let o=0;o<=t.length-5;o++){const i=s(t,o);if(i&&r(n,i)){n.points=i,e=!0;break}}if(e)break}if(!e)return}}function re(t,e){const{realNodeRects:n,labelNodeRects:o}=ot(e.values()),r=t.filter(t=>!t.isLayoutOnly),s=(0,i.K)((t,e,n)=>H(t===e?n??[]:t.points??[]),"pointsFor"),a=(0,i.K)((t,e)=>{let n=0;for(let o=0;o<r.length;o++){const i=te(s(r[o],t,e));for(let a=o+1;a<r.length;a++){const o=te(s(r[a],t,e));for(const t of i)for(const e of o)dt(t.a,t.b,e.a,e.b,Zt)&&n++}}return n},"strictCrossingCount"),c=(0,i.K)(t=>{const e=te(t);if(3!==e.length)return;const n=e[1];return e[0].horizontal!==n.horizontal&&e[2].horizontal!==n.horizontal?{index:n.index,horizontal:n.horizontal,vertical:n.vertical,segment:n}:void 0},"middleRail"),f=(0,i.K)((t,e)=>{const o=[t.start,t.end].filter(t=>Boolean(t));return n.filter(t=>{if(o.includes(t.id))return!1;const n=t.rect;if(e.horizontal){return A(e.a.x,e.b.x,n.left,n.right)>=8&&e.a.y>=n.top-2&&e.a.y<=n.bottom+2}return A(e.a.y,e.b.y,n.top,n.bottom)>=8&&e.a.x>=n.left-2&&e.a.x<=n.right+2})},"blockingRectsFor"),d=(0,i.K)((t,e,n)=>{const o=t.map(t=>({...t}));if(e.horizontal)o[e.index].y=n,o[e.index+1].y=n;else{if(!e.vertical)return;o[e.index].x=n,o[e.index+1].x=n}const r=pt(H(o));return te(r).length===r.length-1?r:void 0},"candidateByMovingRail"),l=(0,i.K)((t,e,i)=>{const c=[t.start,t.end].filter(t=>Boolean(t)),f=te(e);if(f.length!==e.length-1)return!1;for(const t of f){if(it(t.a,t.b,n,c,-2))return!1;if(it(t.a,t.b,o,[],-2))return!1}for(const e of r)if(e!==t)for(const t of f)for(const n of te(s(e)))if(P(t,n,.5)>=8)return!1;return a(t,e)<=i},"candidateIsSafe");for(let t=0;t<8;t++){const t=a();let e=!1;for(const n of r){const o=s(n),r=c(o);if(!r)continue;const i=f(n,r.segment);if(0===i.length)continue;const a=r.horizontal?[Math.min(...i.map(t=>t.rect.top))-20,Math.max(...i.map(t=>t.rect.bottom))+20]:[Math.min(...i.map(t=>t.rect.left))-20,Math.max(...i.map(t=>t.rect.right))+20];for(const s of a){const i=d(o,r.segment,s);if(i&&l(n,i,t)){n.points=i,e=!0;break}}if(e)break}if(!e)return}}function se(t,e){const n=(0,i.K)(t=>{const e=t.groupTitleRect;if(e&&"number"==typeof e.left&&"number"==typeof e.right&&"number"==typeof e.top&&"number"==typeof e.bottom&&Number.isFinite(e.left)&&Number.isFinite(e.right)&&Number.isFinite(e.top)&&Number.isFinite(e.bottom)&&!(e.right<=e.left)&&!(e.bottom<=e.top))return{left:e.left,right:e.right,top:e.top,bottom:e.bottom}},"validTitleRect"),o=(0,i.K)(t=>{if(!t.isGroup||t.parentId)return;const e=t.direction,o="string"==typeof e?e.toUpperCase():"";if("LR"===o||"RL"===o||"BT"===o)return;const r=n(t),s=t.y,i=t.height;if(!r||"number"!=typeof s||"number"!=typeof i||!Number.isFinite(s)||!Number.isFinite(i)||i<=0)return;const a=r.right-r.left,c=r.bottom-r.top;return c<=0||a<c?void 0:{node:t,rect:r}},"topLaneTitleFor"),r=(0,i.K)((t,e)=>{if(!t.horizontal)return!1;const n=t.a.y;return!(n<=e.top+Zt||n>=e.bottom-Zt)&&A(t.a.x,t.b.x,e.left,e.right)>=8},"horizontalSegmentIntersectsTitle"),s=[...e.values()].map(o).filter(t=>Boolean(t));if(0===s.length)return;let a=0;for(const e of t){if(e.isLayoutOnly)continue;const t=H(e.points??[]);for(const e of te(t))for(const t of s)r(e,t.rect)&&(a=Math.max(a,t.rect.bottom-e.a.y+4))}if(!(a<=Zt))for(const t of s){const e=t.node.y,n=t.node.height;"number"!=typeof e||"number"!=typeof n||!Number.isFinite(e)||!Number.isFinite(n)||n<=0||(t.node.y=e-a/2,t.node.height=n+a,t.node.groupTitleRect={...t.rect,top:t.rect.top-a,bottom:t.rect.bottom-a})}}function ie(t,e){const n=(0,i.K)(t=>{const e=t.groupTitleRect;if(e&&"number"==typeof e.left&&"number"==typeof e.right&&"number"==typeof e.top&&"number"==typeof e.bottom&&Number.isFinite(e.left)&&Number.isFinite(e.right)&&Number.isFinite(e.top)&&Number.isFinite(e.bottom)&&!(e.right<=e.left)&&!(e.bottom<=e.top))return{left:e.left,right:e.right,top:e.top,bottom:e.bottom}},"validTitleRect"),o=(0,i.K)(t=>{if(!t.isGroup||t.parentId)return;if("LR"!==t.direction)return;const e=n(t),o=t.x,r=t.width;if(!e||"number"!=typeof o||"number"!=typeof r||!Number.isFinite(o)||!Number.isFinite(r)||r<=0)return;const s=e.right-e.left,i=e.bottom-e.top;return s<=0||i<s?void 0:{node:t,rect:e}},"leftLaneTitleFor"),r=(0,i.K)((t,e)=>{if(!t.vertical)return!1;const n=t.a.x;return!(n<=e.left+Zt||n>=e.right-Zt)&&A(t.a.y,t.b.y,e.top,e.bottom)>=8},"verticalSegmentIntersectsTitle"),s=(0,i.K)((t,e)=>{if(!t.horizontal)return!1;const n=t.a.y;return!(n<=e.top+Zt||n>=e.bottom-Zt)&&A(t.a.x,t.b.x,e.left,e.right)>=8},"horizontalSegmentIntersectsTitle"),a=[...e.values()].map(o).filter(t=>Boolean(t));if(0===a.length)return;let c=0;for(const e of t){if(e.isLayoutOnly)continue;const t=H(e.points??[]);for(const e of te(t))for(const t of a)if(r(e,t.rect))c=Math.max(c,t.rect.right-e.a.x+4);else if(s(e,t.rect)){const n=Math.min(e.a.x,e.b.x);c=Math.max(c,t.rect.right-n+4)}}if(!(c<=Zt))for(const t of a){const e=t.node.x,n=t.node.width;"number"!=typeof e||"number"!=typeof n||!Number.isFinite(e)||!Number.isFinite(n)||n<=0||(t.node.x=e-c/2,t.node.width=n+c,t.node.groupTitleRect={...t.rect,left:t.rect.left-c,right:t.rect.right-c})}}function ae(t,e){const{realNodeRects:n}=ot(e.values()),o=t.filter(t=>!t.isLayoutOnly),r=(0,i.K)((t,e=new Map)=>H(e.get(t)??t.points??[]),"replacementPointsFor"),s=(0,i.K)((t=new Map)=>{let e=0;for(let n=0;n<o.length;n++){const s=te(r(o[n],t));for(let i=n+1;i<o.length;i++){const n=te(r(o[i],t));for(const t of s)for(const o of n)dt(t.a,t.b,o.a,o.b,Zt)&&e++}}return e},"crossingCount"),a=(0,i.K)((t=new Map)=>o.reduce((e,n)=>e+G(r(n,t)),0),"totalBends"),c=(0,i.K)(t=>{const e=r(t);if(e.length<4)return;const n=e[e.length-2],o=e[e.length-1];return X(n,o,Zt)||z(n,o,Zt)?{tailStart:n,terminal:o}:void 0},"terminalTailFor"),f=(0,i.K)((t,e)=>{const n=r(t);if(n.length<3)return;const o=n[0],s=n[1];let i;if(X(o,s,Zt))i={x:s.x,y:e.tailStart.y};else{if(!z(o,s,Zt))return;i={x:e.tailStart.x,y:s.y}}const a=pt(H([o,s,i,e.tailStart,e.terminal]));return te(a).length===a.length-1?a:void 0},"candidateWithDestinationTail"),d=(0,i.K)((t,e)=>{const o=[t.start,t.end].filter(t=>Boolean(t));for(const t of te(e))if(it(t.a,t.b,n,o,-2))return!0;return!1},"pathHasNodeHit"),l=(0,i.K)((t,e,n)=>{for(const s of o)if(s!==t)for(const t of te(e))for(const e of te(r(s,n)))if(P(t,e,.5)>=8)return!0;return!1},"pathHasSharedTrack"),u=(0,i.K)((t,e,n)=>!d(t,e)&&!l(t,e,n),"candidateIsSafe"),h=(0,i.K)(()=>{const t=new Map;for(const n of o){const o=n.end;if(!o||!e.has(o))continue;if(r(n).length<4)continue;const s=t.get(o)??[];s.push(n),t.set(o,s)}return t},"edgesByDestination");for(let t=0;t<4;t++){const t=s();if(0===t)return;let e,n=t,o=a();for(const r of h().values())for(let i=0;i<r.length;i++)for(let d=i+1;d<r.length;d++){const l=r[i],h=r[d],g=c(l),p=c(h);if(!g||!p)continue;const x=f(l,p),m=f(h,g);if(!x||!m)continue;const y=new Map([[l,x],[h,m]]);if(!u(l,x,y)||!u(h,m,y))continue;const b=s(y),M=a(y);b>=t||(b>n||b===n&&M>=o||(e=y,n=b,o=M))}if(!e)return;for(const[t,n]of e)t.points=n}}function ce(t,e){const{realNodeRects:n,labelNodeRects:o}=ot(e.values()),r=t.filter(t=>!t.isLayoutOnly),s=(0,i.K)((t,e=new Map)=>H(e.get(t)??t.points??[]),"replacementPointsFor"),a=(0,i.K)((t=new Map)=>{let e=0;for(let n=0;n<r.length;n++){const o=te(s(r[n],t));for(let i=n+1;i<r.length;i++){const n=te(s(r[i],t));for(const t of o)for(const o of n)dt(t.a,t.b,o.a,o.b,Zt)&&e++}}return e},"strictCrossingCount"),c=(0,i.K)((t=new Map)=>r.reduce((e,n)=>e+G(s(n,t)),0),"totalBends"),f=(0,i.K)(t=>{const n=t.start,o=t.end,r=n?e.get(n):void 0,s=o?e.get(o):void 0,i=r?U(r):void 0,a=s?U(s):void 0;return i&&a?{src:i,dst:a}:void 0},"endpointRectsFor"),d=(0,i.K)((t,e,n)=>{if(n.index<=0||n.index+1>=e.length-1)return;const o=f(t);if(o){if(n.vertical){const r=n.a.x,s=Math.min(o.src.left,o.dst.left),i=Math.max(o.src.right,o.dst.right),a=r<s-Zt?"left":r>i+Zt?"right":void 0;if(!a)return;return{edge:t,points:e,segmentIndex:n.index,axis:"vertical",side:a,coord:r,min:Math.min(n.a.y,n.b.y),max:Math.max(n.a.y,n.b.y)}}if(n.horizontal){const r=n.a.y,s=Math.min(o.src.top,o.dst.top),i=Math.max(o.src.bottom,o.dst.bottom),a=r<s-Zt?"top":r>i+Zt?"bottom":void 0;if(!a)return;return{edge:t,points:e,segmentIndex:n.index,axis:"horizontal",side:a,coord:r,min:Math.min(n.a.x,n.b.x),max:Math.max(n.a.x,n.b.x)}}}},"externalRailForSegment"),l=(0,i.K)(()=>{const t=[];for(const e of r){const n=s(e);for(const o of te(n)){const r=d(e,n,o);r&&t.push(r)}}return t},"collectExternalRails"),u=(0,i.K)((t,e)=>t.edge!==e.edge&&t.axis===e.axis&&t.side===e.side&&A(t.min,t.max,e.min,e.max)>=8,"railsInteract"),h=(0,i.K)(t=>{const e=[],n=new Set;for(const o of t){if(n.has(o))continue;const r=[o],s=[];for(n.add(o);r.length>0;){const e=r.pop();s.push(e);for(const o of t)!n.has(o)&&u(e,o)&&(n.add(o),r.push(o))}s.length>1&&e.push(s)}return e},"connectedComponents"),g=(0,i.K)(t=>{const e=[];for(const n of t)e.some(t=>Math.abs(t-n.coord)<Zt)||e.push(n.coord);for(;e.length<t.length;){const n=Math.min(...e),o=Math.max(...e),r=t[0].side;e.push("left"===r||"top"===r?n-12*(t.length-e.length):o+12*(t.length-e.length))}return e},"uniqueCoordsFor"),p=(0,i.K)(t=>{const e=t.map(t=>t.coord),n=g(t),o=[];if(t.length<=6){const r=new Array(n.length).fill(!1),s=[],a=(0,i.K)(()=>{if(s.length!==t.length)for(const[t,e]of n.entries())r[t]||(r[t]=!0,s.push(e),a(),s.pop(),r[t]=!1);else s.some((t,n)=>Math.abs(t-e[n])>=Zt)&&o.push([...s])},"visit");return a(),o}for(let t=0;t<e.length;t++)for(let n=t+1;n<e.length;n++){const r=[...e];[r[t],r[n]]=[r[n],r[t]],o.push(r)}return o},"coordinateAssignmentsFor"),x=(0,i.K)((t,e)=>{const n=new Map;for(const[o,r]of t.entries()){const t=e[o],s=n.get(r.edge)??r.points.map(t=>({x:t.x,y:t.y}));"vertical"===r.axis?(s[r.segmentIndex].x=t,s[r.segmentIndex+1].x=t):(s[r.segmentIndex].y=t,s[r.segmentIndex+1].y=t),n.set(r.edge,s)}const o=new Map;for(const[t,e]of n){const n=pt(H(e));if(te(n).length!==n.length-1)return;o.set(t,n)}return o},"replacementsForAssignment"),m=(0,i.K)(t=>{for(const[e,r]of t){const t=[e.start,e.end].filter(t=>Boolean(t));for(const e of te(r)){if(it(e.a,e.b,n,t,-2))return!1;if(it(e.a,e.b,o,[],-2))return!1}}for(let e=0;e<r.length;e++){const n=r[e],o=t.has(n),i=te(s(n,t));for(let n=e+1;n<r.length;n++){const e=r[n];if(!o&&!t.has(e))continue;const a=te(s(e,t));for(const t of i)for(const e of a)if(P(t,e,.5)>=8)return!1}}return!0},"candidateIsSafe");for(let t=0;t<4;t++){const t=a();if(0===t)return;let e,n=t,o=c(),r=Number.POSITIVE_INFINITY;for(const s of h(l()))for(const i of p(s)){const f=x(s,i);if(!f||!m(f))continue;const d=a(f);if(d>=t)continue;const l=c(f),u=s.reduce((t,e,n)=>t+Math.abs(i[n]-e.coord),0);d>n||d===n&&(l>o||l===o&&u>=r)||(e=f,n=d,o=l,r=u)}if(!e)return;for(const[t,n]of e)t.points=n}}function fe(t,e){const{realNodeRects:n,labelNodeRects:o}=ot(e.values()),r=t.filter(t=>!t.isLayoutOnly),s=(0,i.K)((t,e,n)=>H(t===e?n??[]:t.points??[]),"pointsFor"),a=(0,i.K)(t=>te(t).reduce((t,e)=>{const n=e.a.x-e.b.x,o=e.a.y-e.b.y;return t+Math.hypot(n,o)},0),"pathLength"),c=(0,i.K)((t,e)=>{let n=0;for(let o=0;o<r.length;o++){const i=te(s(r[o],t,e));for(let a=o+1;a<r.length;a++){const o=te(s(r[a],t,e));for(const t of i)for(const e of o)dt(t.a,t.b,e.a,e.b,Zt)&&n++}}return n},"strictCrossingCount"),f=(0,i.K)((t,e)=>{if(t.horizontal){const n=t.a.y;return(Math.abs(n-e.top)<1||Math.abs(n-e.bottom)<1)&&A(t.a.x,t.b.x,e.left,e.right)>=8}if(t.vertical){const n=t.a.x;return(Math.abs(n-e.left)<1||Math.abs(n-e.right)<1)&&A(t.a.y,t.b.y,e.top,e.bottom)>=8}return!1},"segmentRunsAlongRectBorder"),d=(0,i.K)(t=>{const n=[t.start,t.end].filter(t=>Boolean(t)),o=[];for(const t of n){const n=e.get(t),r=n?U(n):void 0;r&&o.push(r)}return o},"endpointRectsFor"),l=(0,i.K)((t,e)=>{if(e+3>=t.length)return[];const n=t[e],o=t[e+1],r=t[e+2],s=t[e+3],i=X(n,o,Zt)&&z(o,r,Zt)&&X(r,s,Zt),a=z(n,o,Zt)&&X(o,r,Zt)&&z(r,s,Zt);if(!i&&!a)return[];if(!(i?Math.sign(o.x-n.x)!==Math.sign(s.x-r.x):Math.sign(o.y-n.y)!==Math.sign(s.y-r.y)))return[];const c=E(n,s,Zt)||Y(n,s,Zt)?[]:[{x:n.x,y:s.y},{x:s.x,y:n.y}],f=0===c.length?[[...t.slice(0,e+1),...t.slice(e+3)]]:c.map(n=>[...t.slice(0,e+1),n,...t.slice(e+3)]),d=new Set;return f.map(t=>pt(H(t))).filter(t=>{if(te(t).length!==t.length-1)return!1;if(!t.some(t=>F(t,s,Zt)))return!1;const e=t.map(t=>`${t.x.toFixed(3)},${t.y.toFixed(3)}`).join("|");return!d.has(e)&&(d.add(e),!0)})},"shortcutCandidatesAt"),u=(0,i.K)((t,e,i)=>{const a=[t.start,t.end].filter(t=>Boolean(t)),l=d(t);for(const t of te(e)){if(it(t.a,t.b,n,a,-2))return!1;if(it(t.a,t.b,o,[],-2))return!1;if(l.some(e=>f(t,e)))return!1}for(const n of r)if(n!==t)for(const t of te(e))for(const e of te(s(n)))if(P(t,e,.5)>=8)return!1;return c(t,e)<=i},"candidateIsSafe");for(let t=0;t<8;t++){const t=c();let e,n,o=t,i=Number.POSITIVE_INFINITY,f=Number.POSITIVE_INFINITY;for(const d of r){const r=s(d),h=G(r,Zt),g=a(r);for(let s=0;s<=r.length-4;s++)for(const p of l(r,s)){const r=G(p,Zt),s=a(p);if(!(r<h||r===h&&s<g-Zt)||!u(d,p,t))continue;const l=c(d,p);l>o||l===o&&(r>i||r===i&&s>=f)||(e=d,n=p,o=l,i=r,f=s)}}if(!e||!n)return;e.points=n}}function de(t,e){const n=20,o=[];for(const t of e.values()){if(t.isGroup||t.isEdgeLabel)continue;const e=t.x??0,n=t.y??0,r=U(t);r&&o.push({id:String(t.id??""),cx:e,cy:n,rect:r})}if(0===o.length)return;const r=new Map(o.map(t=>[t.id,t])),s=o.map(t=>({id:t.id,rect:t.rect})),a=["top","bottom","left","right"],c={top:Math.min(...o.map(t=>t.rect.top))-n,bottom:Math.max(...o.map(t=>t.rect.bottom))+n,left:Math.min(...o.map(t=>t.rect.left))-n,right:Math.max(...o.map(t=>t.rect.right))+n},f=t.filter(t=>!t.isLayoutOnly),d=new Map(f.map((t,e)=>[t,e])),l=(0,i.K)(t=>{const e="left"===t||"top"===t?-1:1,o=[];for(let r=0;r<=2;r++)o.push(c[t]+e*n*r);return o},"outwardTracksForSide"),u=(0,i.K)((t,e=new Map)=>H(e.get(t)??t.points??[]),"replacementPointsFor"),h=(0,i.K)((t,e)=>{let n=0;for(const o of t)for(const t of e)dt(o.a,o.b,t.a,t.b,Zt)&&n++;return n},"crossingCountBetweenSegments"),g=(0,i.K)((t,e)=>h(te(t),te(e)),"crossingCountBetweenPaths"),p=(0,i.K)((t=new Map)=>{let e=0;const n=[],o=new Set,r=[],s=(0,i.K)(t=>{o.has(t)||(o.add(t),r.push(t))},"addEdge");for(let o=0;o<f.length;o++){const r=f[o],i=u(r,t);for(let a=o+1;a<f.length;a++){const o=f[a],c=g(i,u(o,t));c>0&&(e+=c,n.push({first:r,second:o,count:c}),s(r),s(o))}}return r.sort((t,e)=>(d.get(t)??0)-(d.get(e)??0)),{count:e,pairs:n,edgeSet:o,edges:r}},"crossingSnapshot"),x=(0,i.K)((t,e)=>{const n=new Set(e.keys());if(0===n.size)return t.count;let o=0;for(const e of t.pairs)(n.has(e.first)||n.has(e.second))&&(o+=e.count);let r=0;for(let t=0;t<f.length;t++){const o=f[t],s=n.has(o),i=u(o,e);for(let o=t+1;o<f.length;o++){const t=f[o];(s||n.has(t))&&(r+=g(i,u(t,e)))}}return t.count-o+r},"crossingCountWithReplacements"),m=(0,i.K)(t=>{const e=new Map;for(const n of t.pairs){const t=e.get(n.first)??new Set;t.add(n.second),e.set(n.first,t);const o=e.get(n.second)??new Set;o.add(n.first),e.set(n.second,o)}const n=[],o=new Set;for(const r of t.edges){if(o.has(r))continue;const t=[r],s=[];for(o.add(r);t.length>0;){const n=t.pop();s.push(n);for(const r of e.get(n)??[])o.has(r)||(o.add(r),t.push(r))}s.sort((t,e)=>(d.get(t)??0)-(d.get(e)??0)),s.length>1&&n.push(s)}return n},"crossingComponents"),y=(0,i.K)(t=>[t.start,t.end].filter(t=>Boolean(t)),"endpointIdsFor"),b=(0,i.K)(t=>{const e=[];for(const n of m(t)){const t=new Set(n),o=new Set(n.flatMap(t=>y(t))),r=[...n];for(const e of f)t.has(e)||y(e).some(t=>o.has(t))&&r.push(e);r.sort((t,e)=>(d.get(t)??0)-(d.get(e)??0)),e.push(r)}return e},"pairSearchGroups"),M=(0,i.K)((t,e,n)=>x(t,new Map([[e,n]])),"crossingCountWithSingleReplacement"),K=(0,i.K)(t=>{const e=new Map;for(const n of t.pairs)e.set(n.first,(e.get(n.first)??0)+n.count),e.set(n.second,(e.get(n.second)??0)+n.count);return e},"currentCrossingsByEdge"),I=(0,i.K)(t=>t.slice(1).reduce((e,n,o)=>{const r=t[o];return e+Math.abs(n.x-r.x)+Math.abs(n.y-r.y)},0),"pathLength"),S=(0,i.K)((t=new Map)=>f.reduce((e,n)=>e+G(u(n,t)),0),"totalBends"),w=(0,i.K)((t=new Map)=>f.reduce((e,n)=>e+I(u(n,t)),0),"totalLength"),v=(0,i.K)((t,e,n=new Map)=>{const o=te(e);for(const e of f)if(e!==t)for(const t of o)for(const o of te(u(e,n)))if(P(t,o,.5)>=8)return!0;return!1},"pathHasSegmentConflict"),C=(0,i.K)((t,e)=>{const n=[t.start,t.end].filter(t=>Boolean(t));for(const t of te(e))if(it(t.a,t.b,s,n,-2))return!0;return!1},"pathHitsNode"),L=(0,i.K)((t,e)=>{const n=pt(H(e));te(n).length===n.length-1&&t.push(n)},"pushOrthogonalCandidate"),k=(0,i.K)(t=>"left"===t||"right"===t,"sideIsHorizontal"),O=(0,i.K)((t,e,o)=>{switch(e){case"left":return Math.min(t.x,o.x)-n;case"right":return Math.max(t.x,o.x)+n;case"top":return Math.min(t.y,o.y)-n;case"bottom":return Math.max(t.y,o.y)+n}},"localTrackForSameSide"),R=(0,i.K)((t,e,o,r)=>{const s="left"===o||"top"===o?-1:1,i=[O(e,o,r),c[o]];for(const a of i)for(let i=0;i<=2;i++)L(t,et(e,o,r,a+s*n*i))},"addSameSideCandidates"),T=(0,i.K)((t,e,n,o,r)=>{for(const s of l(n))for(const n of l(r))L(t,[e,{x:s,y:e.y},{x:s,y:n},{x:o.x,y:n},o])},"addHorizontalToVerticalCandidates"),$=(0,i.K)((t,e,n,o,r)=>{for(const s of l(n))for(const n of l(r))L(t,[e,{x:e.x,y:s},{x:n,y:s},{x:n,y:o.y},o])},"addVerticalToHorizontalCandidates"),N=(0,i.K)((t,e,n,o,r)=>{const s=[...l("top"),...l("bottom")];for(const i of l(n))for(const n of l(r))for(const r of s)L(t,[e,{x:i,y:e.y},{x:i,y:r},{x:n,y:r},{x:n,y:o.y},o])},"addHorizontalPairCandidates"),B=(0,i.K)((t,e,n,o,r)=>{const s=[...l("left"),...l("right")];for(const i of l(n))for(const n of l(r))for(const r of s)L(t,[e,{x:e.x,y:i},{x:r,y:i},{x:r,y:n},{x:o.x,y:n},o])},"addVerticalPairCandidates"),F=(0,i.K)(t=>{const e=new Set;return t.map(t=>H(t)).filter(t=>{const n=t.map(t=>`${t.x.toFixed(3)},${t.y.toFixed(3)}`).join("|");return!(e.has(n)||t.length<2)&&(e.add(n),!0)})},"dedupeCandidatePaths"),E=(0,i.K)((t,e,o,r)=>{const s=[],i=tt(t,e,o,r,n,Zt);i&&L(s,i),e===r&&R(s,t,e,o);const a=k(e),c=k(r);return a&&!c?T(s,t,e,o,r):!a&&c?$(s,t,e,o,r):a?N(s,t,e,o,r):B(s,t,e,o,r),F(s)},"buildCandidatesForSides"),Y=(0,i.K)((t,e,n,o)=>{const r=[...l("left"),...l("right")],s=[...l("top"),...l("bottom")];for(const i of a){const a=Z(o,i),c="top"===i||"bottom"===i?l(i):s;for(const o of r){L(t,[e,n,{x:o,y:n.y},{x:o,y:a.y},a]);for(const r of c)L(t,[e,n,{x:o,y:n.y},{x:o,y:r},{x:a.x,y:r},a])}}},"addVerticalDepartureOuterTrackCandidates"),A=(0,i.K)((t,e,n,o)=>{const r=[...l("left"),...l("right")],s=[...l("top"),...l("bottom")];for(const i of a){const a=Z(o,i),c="left"===i||"right"===i?l(i):r;for(const o of s){L(t,[e,n,{x:n.x,y:o},{x:a.x,y:o},a]);for(const r of c)L(t,[e,n,{x:n.x,y:o},{x:r,y:o},{x:r,y:a.y},a])}}},"addHorizontalDepartureOuterTrackCandidates"),D=(0,i.K)(t=>{const e=t.start,n=t.end,o=n?r.get(n):void 0;if(!e||!o)return[];const s=H(t.points??[]);if(s.length<4)return[];const i=s[0],a=s[1],c=[];return z(i,a,Zt)?Y(c,i,a,o):X(i,a,Zt)&&A(c,i,a,o),c},"terminalPreservingOuterTrackCandidates"),j=(0,i.K)(t=>{const e=t.start,n=t.end,o=e?r.get(e):void 0,s=n?r.get(n):void 0;if(!o||!s)return[];const i=[];for(const t of a){const e=Z(o,t);for(const n of a)i.push(...E(e,t,Z(s,n),n))}return i.push(...D(t)),i},"candidatePathsFor"),V=(0,i.K)(()=>new Map(f.map(t=>[t,te(u(t))])),"currentSegmentsByEdge"),_=(0,i.K)((t,e,n)=>{const o=new Set;for(const r of f){if(r===t)continue;const s=n.get(r)??te(u(r));e.some(t=>s.some(e=>P(t,e,.5)>=8))&&o.add(r)}return o},"sharedTrackConflictsFor"),W=(0,i.K)((t,e,n,o)=>{const r=new Set;return j(t).map(t=>pt(H(t))).filter(e=>{if(C(t,e))return!1;const n=e.map(t=>`${t.x.toFixed(3)},${t.y.toFixed(3)}`).join("|");return!(r.has(n)||e.length<2)&&(r.add(n),!0)}).map(r=>{const s=te(r);let i=0;for(const e of f)e!==t&&(i+=h(s,n.get(e)??te(u(e))));return{candidate:r,candidateSegments:s,crossings:e.count-(o.get(t)??0)+i,bends:G(r,Zt),totalBends:G(r),length:I(r)}}).filter(({crossings:t})=>t<=e.count).sort((t,e)=>t.crossings-e.crossings||t.bends-e.bends||t.length-e.length).slice(0,48).map(e=>({path:e.candidate,segments:e.candidateSegments,sharedTrackConflicts:_(t,e.candidateSegments,n),totalBends:e.totalBends,length:e.length}))},"pairCandidatesFor"),q=(0,i.K)((t,e,n,o,r,s)=>{let i=0;for(const n of t.pairs)n.first!==e&&n.second!==e&&n.first!==o&&n.second!==o||(i+=n.count);let a=h(n.segments,r.segments);for(const t of f){if(t===e||t===o)continue;const i=s.get(t)??te(u(t));a+=h(n.segments,i)+h(r.segments,i)}return t.count-i+a},"pairCrossingCount"),J=(0,i.K)((t,e)=>{for(const n of t.sharedTrackConflicts)if(n!==e)return!1;return!0},"conflictsOnlyWith"),Q=(0,i.K)((t,e)=>t.segments.some(t=>e.segments.some(e=>P(t,e,.5)>=8)),"candidatesShareTrack"),nt=(0,i.K)((t,e,n,o)=>J(e,n.edge)&&J(o,t.edge)&&!Q(e,o),"pairCandidatesAreCompatible"),ot=(0,i.K)((t,e,n,o,r)=>{const s=q(t.current,e.edge,n,o.edge,r,t.baseSegments);if(!(s>=t.current.count))return{replacements:new Map([[e.edge,n.path],[o.edge,r.path]]),crossings:s,bends:t.currentBends-(t.baseBendsByEdge.get(e.edge)??0)-(t.baseBendsByEdge.get(o.edge)??0)+n.totalBends+r.totalBends,length:t.currentLength-(t.baseLengthByEdge.get(e.edge)??0)-(t.baseLengthByEdge.get(o.edge)??0)+n.length+r.length}},"scorePairReplacement"),rt=(0,i.K)((t,e)=>t.crossings<e.crossings||t.crossings===e.crossings&&(t.bends<e.bends||t.bends===e.bends&&t.length<e.length),"pairScoreIsBetter"),st=(0,i.K)((t,e,n,o)=>{let r=o;for(const o of e.candidates)for(const s of n.candidates){if(!nt(e,o,n,s))continue;const i=ot(t,e,o,n,s);i&&rt(i,r)&&(r=i)}return r},"bestScoreForOptionPair"),at=(0,i.K)(t=>{const e=S(),n=w(),o=V(),r=K(t),s=new Map(f.map(t=>[t,G(u(t))])),i=new Map(f.map(t=>[t,I(u(t))])),a=new Map,c=b(t);for(const e of c)for(const n of e){if(a.has(n))continue;const e=W(n,t,o,r);e.length>0&&a.set(n,{edge:n,candidates:e})}let d={replacements:new Map,crossings:t.count,bends:e,length:n};const l={current:t,currentBends:e,currentLength:n,baseBendsByEdge:s,baseLengthByEdge:i,baseSegments:o};for(const e of c){const n=new Set(e.filter(e=>t.edgeSet.has(e))),o=e.map(t=>a.get(t)).filter(t=>Boolean(t));for(let t=0;t<o.length;t++){const e=o[t];for(let r=t+1;r<o.length;r++){const t=o[r];(n.has(e.edge)||n.has(t.edge))&&(d=st(l,e,t,d))}}}return d.replacements.size>0?d.replacements:void 0},"bestPairedReplacement");for(let t=0;t<4;t++){const t=p(),e=t.count;if(0===e)return;let n,o,r=e,s=Number.POSITIVE_INFINITY;for(const i of t.edges){const a=G(u(i),Zt);for(const c of j(i)){const f=C(i,c),d=!f&&v(i,c),l=M(t,i,c),u=G(c,Zt);if(f||d)continue;(l<e||l===e&&u<a)&&(l>r||l===r&&u>=s||(n=i,o=c,r=l,s=u))}}if(n&&o){n.points=o;continue}const i=at(t);if(!i)return;for(const[t,e]of i)t.points=e}}(0,i.K)(ne,"separateSharedRenderedTerminalLanes"),(0,i.K)(oe,"collapseRedundantRectangularDoglegs"),(0,i.K)(re,"liftObstacleHuggingSameSideRails"),(0,i.K)(se,"liftTopLaneTitleBandsAboveRails"),(0,i.K)(ie,"shiftLeftLaneTitleBandsLeftOfRails"),(0,i.K)(ae,"swapDestinationTerminalTailsToReduceCrossings"),(0,i.K)(ce,"reassignCrossingExternalRailChannels"),(0,i.K)(fe,"shortcutRedundantOrthogonalJogs"),(0,i.K)(de,"resolveRenderedOrthogonalCrossings");var le=.001;function ue(t,e){const{nodeInfoById:n,realNodeRects:o}=nt(e),r=["top","bottom","left","right"],s={top:Math.min(...o.map(t=>t.rect.top))-20,bottom:Math.max(...o.map(t=>t.rect.bottom))+20,left:Math.min(...o.map(t=>t.rect.left))-20,right:Math.max(...o.map(t=>t.rect.right))+20},a=(0,i.K)((t,e,n,o)=>{const r=[],i=tt(t,e,n,o,20,le);return i&&r.push(i),e===o&&r.push(et(t,e,n,s[e])),r},"buildOrthogonalPathCandidates"),c=(0,i.K)((t,e)=>{for(let n=0;n<t.length-1;n++){if(it(t[n],t[n+1],o,e,1))return!0}return!1},"pathHitsNode"),f=(0,i.K)((e,n,o=!1)=>{let r=0;const s=D(e,le),i=n.start,a=n.end;for(const e of t){if(e===n||e.isLayoutOnly)continue;const t=e.start,c=e.end;if(!o&&i&&a&&(t===i||t===a||c===i||c===a))continue;const f=e.points;if(f&&!(f.length<2))for(const t of s)for(const e of D(f,le))(at(t.a,t.b,e.a,e.b,le,le)||P(t,e,le)>=8)&&r++}return r},"pathConflictCount"),d=(0,i.K)((t,e)=>{const n=Math.abs(t.y-e.rect.top),o=Math.abs(t.y-e.rect.bottom),r=Math.abs(t.x-e.rect.left),s=Math.abs(t.x-e.rect.right);let i="top",a=n;return o<a&&(i="bottom",a=o),r<a&&(i="left",a=r),s<a&&(i="right",a=s),i},"nearestSideOfRect"),l=new Map,u=(0,i.K)((t,e,n)=>{const o=l.get(t)??[];o.push({side:e,edgeId:n}),l.set(t,o)},"addFaceClaim");for(const e of t){if(e.isLayoutOnly)continue;const t=e.points??[];if(t.length<1)continue;const o=e.id??"",r=e.start,s=e.end;if(r){const e=n.get(r);e&&u(r,d(t[0],e),o)}if(s){const e=n.get(s);e&&u(s,d(t[t.length-1],e),o)}}const h=(0,i.K)((t,e,n)=>l.get(t)?.some(t=>t.edgeId!==n&&t.side===e)??!1,"faceIsClaimed");for(const e of t){if(e.isLayoutOnly)continue;const t=e.points;if(!t||t.length<2)continue;const o=G(t,le);if(o<4)continue;const s=e.start,i=e.end;if(!s||!i)continue;const g=n.get(s),p=n.get(i);if(!g||!p)continue;const x=e.id??"",m=f(t,e,!0),y=f(t,e);let b,M=m,K=o;for(const t of r){if(h(s,t,x))continue;const n=Z(g,t);for(const o of r){if(h(i,o,x))continue;const r=Z(p,o);for(const d of a(n,t,r,o)){if(c(d,[s,i]))continue;const t=G(d,le);if(m>0){const n=f(d,e,!0);if(n>M||n===M&&t>=K)continue;M=n,K=t,b=d;continue}f(d,e)>y||t<K&&(K=t,b=d)}}}if(b){e.points=b;const t=l.get(s);t&&l.set(s,t.filter(t=>t.edgeId!==x));const n=l.get(i);n&&l.set(i,n.filter(t=>t.edgeId!==x)),u(s,d(b[0],g),x),u(i,d(b[b.length-1],p),x)}}}(0,i.K)(ue,"simplifyDetouredEdges");var he=.001;function ge(t,e){const n=e?0:t.length-1,o=e?1:-1,r=t[n],s=t[n+o];if(!r||!s)return;const i=s.x-r.x,a=s.y-r.y;if(!(Math.abs(i)+Math.abs(a)<he)){if(Math.abs(a)<=he){const t=r.x+10*Math.sign(i);return{left:Math.min(r.x,t),right:Math.max(r.x,t),top:r.y-7,bottom:r.y+7}}if(Math.abs(i)<=he){const t=r.y+10*Math.sign(a);return{left:r.x-7,right:r.x+7,top:Math.min(r.y,t),bottom:Math.max(r.y,t)}}return{left:Math.min(r.x,s.x),right:Math.max(r.x,s.x),top:Math.min(r.y,s.y),bottom:Math.max(r.y,s.y)}}}function pe(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)}}function xe(t,e){const n=H(e);return[ge(n,!0),ge(n,!1)].some(e=>e&&q(t,pe(e)))}function me(t,e){const n=[];for(const e of t){if(e.isLayoutOnly)continue;const t=e.points;if(t&&!(t.length<2))for(let o=0;o<t.length-1;o++)n.push({edgeId:e.id,p1:t[o],p2:t[o+1]})}const o=[],r=[];for(const t of e.values()){const e=t.isGroup,n=t.parentId;if(e&&!n){const e=U(t);e&&r.push({id:t.id,rect:e});continue}if(e)continue;if(t.isEdgeLabel)continue;const s=U(t);s&&o.push({nodeId:t.id,rect:s})}const s=(0,i.K)((t,e)=>{const n=J(e,3);for(const{nodeId:e,rect:r}of o)if(e!==t&&q(n,r))return!0;return!1},"labelOverlapsForeignNode"),a=(0,i.K)((t,e)=>{const o=J(e,3);for(const e of n)if(e.edgeId!==t&&V(e.p1,e.p2,o))return!0;return!1},"labelOverlapsForeignEdge"),c=(0,i.K)((t,e,n)=>s(t,n)||a(e,n),"labelOverlapsAnything"),f=[],d=(0,i.K)(t=>{for(const{id:e,rect:n}of r)if(W(n,t))return e},"findContainingLane"),l=(0,i.K)((t,e)=>f.some(n=>n.labelId!==t&&q(e,n.rect)),"overlapsPlacedLabel");for(const n of t){if(n.isLayoutOnly)continue;const t=n.labelNodeId;if(!t)continue;const o=e.get(t);if(!o)continue;const u=n.points;if(!u||u.length<2)continue;const h=o.width??0,g=o.height??0;if(h<=0||g<=0)continue;const p=[];for(let t=0;t<u.length-1;t++){const e=u[t],n=u[t+1],o=Math.abs(e.x-n.x),r=Math.abs(e.y-n.y);o<he&&r<he||(o>=he&&r>=he||p.push({idx:t,length:o+r,orientation:o>=he?"horizontal":"vertical",midX:(e.x+n.x)/2,midY:(e.y+n.y)/2}))}if(0===p.length)continue;const x=p.length>=3?p.filter(t=>t.idx>0&&t.idx<p.length-1):p,m=x.length>0?x:p,y=h>=g?"horizontal":"vertical",b=(0,i.K)(t=>[...t].sort((t,e)=>{const n=t.orientation===y;if(n!==(e.orientation===y))return n?-1:1;const o=t.length>=("horizontal"===t.orientation?h:g)+2;return o!==e.length>=("horizontal"===e.orientation?h:g)+2?o?-1:1:e.length-t.length}),"rankSegments"),M=p[0],K=p[p.length-1],I=[.5,.25,.75,.05,.95,.15,.85,.1,.9],S=(0,i.K)((t,e)=>{const n=u[t.idx],o=u[t.idx+1];return{midX:n.x+(o.x-n.x)*e,midY:n.y+(o.y-n.y)*e}},"anchorAtT"),w=(0,i.K)((t,e,n)=>Math.min(n,Math.max(e,t)),"clamp"),v=(0,i.K)((t,e)=>t.midX>=e.left-he&&t.midX<=e.right+he&&t.midY>=e.top-he&&t.midY<=e.bottom+he,"pointInsideRectInclusive"),C=(0,i.K)(t=>{const e=Q(t.midX,t.midY,h,g),n=d(e);if(n)return{laneId:n,anchor:t,rect:e};const o=r.find(({rect:e})=>v(t,e));if(!o)return;const s=o.rect.left+h/2+1,i=o.rect.right-h/2-1,a=o.rect.top+g/2+1,c=o.rect.bottom-g/2-1;if(s>i||a>c)return;const f={midX:w(t.midX,s,i),midY:w(t.midY,a,c)},l=Q(f.midX,f.midY,h,g);return v(t,l)?{laneId:o.id,anchor:f,rect:l}:void 0},"placementForAnchor"),L=(0,i.K)((t,e,n)=>"horizontal"===t.orientation?Math.abs(e.midX-n.x):Math.abs(e.midY-n.y),"distanceAlongSegment"),k=(0,i.K)((t,e)=>{const n=("horizontal"===t.orientation?h/2:g/2)+12;if(t===M){const o=u[t.idx];if(L(t,e,o)+he<n)return!1}if(t===K){const o=u[t.idx+1];if(L(t,e,o)+he<n)return!1}return!0},"labelClearsTerminalEndpoints"),O=(0,i.K)(e=>{const o=b(e);for(const e of o)for(const o of I){const r=S(e,o);if(!k(e,r))continue;const s=C(r);if(s&&(!xe(s.rect,u)&&!l(t,s.rect)&&!c(t,n.id,s.rect)))return{laneId:s.laneId,anchor:s.anchor}}},"tryPool"),R=(0,i.K)((e,o,r=!1)=>{const i=b(e);for(const e of i){const i={midX:e.midX,midY:e.midY};if(o&&!k(e,i))continue;const c=C(i);if(c&&!xe(c.rect,u)&&!l(t,c.rect)&&!s(t,c.rect)&&(r||!a(n.id,c.rect)))return{laneId:c.laneId,anchor:c.anchor}}},"findLaneContainingFallback"),T=O(m)??(m.length<p.length?O(p):void 0)??R(p,!0)??R(p,!1)??R(p,!1,!0);if(T){o.x=T.anchor.midX,o.y=T.anchor.midY,o.parentId=T.laneId;const e=Q(T.anchor.midX,T.anchor.midY,h,g),n=f.findIndex(e=>e.labelId===t);n>=0?f[n]={labelId:t,rect:e}:f.push({labelId:t,rect:e})}}}(0,i.K)(ge,"markerClearanceRectFor"),(0,i.K)(pe,"normalizeRect"),(0,i.K)(xe,"labelOverlapsOwnMarker"),(0,i.K)(me,"anchorLabelsToPolyline");var ye=1e-6;function be(t,e){return t<e?`${t}::${e}`:`${e}::${t}`}function Me(t,e){const{nodeInfoById:n,realNodeRects:o}=nt(e),r=new Map;for(const t of e){const e=t.id;t.isGroup||t.isEdgeLabel&&r.set(e,{w:t.width??0,h:t.height??0})}const s=(0,i.K)((e,n,o,s)=>{const a=be(n,o);let c=0;const f=(0,i.K)(t=>{if(!t)return;const e=r.get(t);if(!e)return;const n="x"===s?e.w/2:e.h/2;n>c&&(c=n)},"consider");f(e.labelNodeId);for(const n of t){if(n===e)continue;if(n.isLayoutOnly)continue;const t=n.start,o=n.end;t&&o&&(be(t,o)===a&&f(n.labelNodeId))}return c>0?c+3:0},"labelClearanceFor");for(const e of t){if(e.isLayoutOnly)continue;if(!j(e.points,ye))continue;const r=st(e,n,ye);if(!r)continue;const{srcId:i,dstId:a,srcInfo:c,dstInfo:f,collinearX:d,collinearY:l}=r;if(d===l)continue;let u,h;if(d){const t=f.cy>c.cy;u={x:c.cx,y:t?c.rect.bottom:c.rect.top},h={x:f.cx,y:t?f.rect.top:f.rect.bottom}}else{const t=f.cx>c.cx;u={x:t?c.rect.right:c.rect.left,y:c.cy},h={x:t?f.rect.left:f.rect.right,y:f.cy}}if(it(u,h,o,[i,a],1))continue;const g=s(e,i,a,d?"x":"y"),p=g>4?g:4,x=[0,p,-p];for(const n of x){const r={...u},s={...h};if(d){if(r.x+=n,s.x+=n,r.x<=c.rect.left||r.x>=c.rect.right)continue;if(s.x<=f.rect.left||s.x>=f.rect.right)continue}else{if(r.y+=n,s.y+=n,r.y<=c.rect.top||r.y>=c.rect.bottom)continue;if(s.y<=f.rect.top||s.y>=f.rect.bottom)continue}if(!it(r,s,o,[i,a],1)&&!ft(r,s,t,e,{epsilon:ye})){e.points=[r,s];break}}}}function Ke(t,e){const n=.001,{realNodeRects:o,labelNodeRects:r}=ot(e.values()),s=(0,i.K)((t,e)=>D(e,n).map(n=>({...n,edge:t,interior:n.index>=1&&n.index<=e.length-3})),"segmentsFor"),a=(0,i.K)(()=>{const e=[];for(const n of t){if(n.isLayoutOnly)continue;const t=n.points;!t||t.length<2||e.push(...s(n,H(t)))}return e},"allSegments"),c=(0,i.K)((t,e)=>t.horizontal&&e.horizontal?A(t.a.x,t.b.x,e.a.x,e.b.x)>=8&&Math.abs(t.a.y-e.a.y)<7:!(!t.vertical||!e.vertical)&&(A(t.a.y,t.b.y,e.a.y,e.b.y)>=8&&Math.abs(t.a.x-e.a.x)<7),"hasCrowdedParallelTrack"),f=(0,i.K)((e,i)=>{const a=e.start,f=e.end,d=s(e,i);if(d.length!==i.length-1)return!1;const l=[a,f].filter(t=>Boolean(t)),u=e.labelNodeId?[e.labelNodeId]:[];for(const t of d){if(it(t.a,t.b,o,l,-2))return!1;if(it(t.a,t.b,r,u,-2))return!1}for(const o of t){if(o===e||o.isLayoutOnly)continue;const t=o.points;if(t&&!(t.length<2))for(const e of d)for(const r of s(o,H(t))){if(c(e,r))return!1;if(dt(e.a,e.b,r.a,r.b,n))return!1}}return!0},"candidateIsSafe"),d=(0,i.K)((t,e)=>{const n=H(t.edge.points??[]);if(n.length<4||t.index>=n.length-1)return;const o=n.map(t=>({...t}));if(t.horizontal)o[t.index].y+=e,o[t.index+1].y+=e;else{if(!t.vertical)return;o[t.index].x+=e,o[t.index+1].x+=e}return s(t.edge,o).length===o.length-1?o:void 0},"shiftedCandidate"),l=(0,i.K)((t,e)=>({x:t.x??(e.left+e.right)/2,y:t.y??(e.top+e.bottom)/2}),"nodeCenter"),u=(0,i.K)(t=>{const n=t.edge,o=H(n.points??[]);if(4!==o.length||1!==t.index)return;const r=n.start?e.get(n.start):void 0,s=n.end?e.get(n.end):void 0,i=r?U(r):void 0,a=s?U(s):void 0,c=o.slice(t.index+2);return r&&s&&i&&a&&0!==c.length?{sourceCenter:l(r,i),targetCenter:l(s,a),sourceRect:i,tail:c}:void 0},"sourceDetourContextFor"),h=(0,i.K)((t,e,o,r,s,i)=>{const a=r.y>=o.y,c=a?s.bottom:s.top,f=c+(a?20:-20);if(a&&t.b.y<=f+n||!a&&t.b.y>=f-n)return;const d=t.a.x+e;return H([{x:o.x,y:c},{x:o.x,y:f},{x:d,y:f},{x:d,y:t.b.y},...i],n)},"verticalSourceDetour"),g=(0,i.K)((t,e,o,r,s,i)=>{const a=r.x>=o.x,c=a?s.right:s.left,f=c+(a?20:-20);if(a&&t.b.x<=f+n||!a&&t.b.x>=f-n)return;const d=t.a.y+e;return H([{x:c,y:o.y},{x:f,y:o.y},{x:f,y:d},{x:t.b.x,y:d},...i],n)},"horizontalSourceDetour"),p=(0,i.K)((t,e)=>{const n=u(t);if(n)return t.vertical?h(t,e,n.sourceCenter,n.targetCenter,n.sourceRect,n.tail):t.horizontal?g(t,e,n.sourceCenter,n.targetCenter,n.sourceRect,n.tail):void 0},"sourceDetourCandidate"),x=[-7,7,-14,14,-21,21];for(let t=0;t<12;t++){const t=a();let e=!1;for(let n=0;n<t.length&&!e;n++)for(let o=n+1;o<t.length&&!e;o++){const r=t[n],s=t[o];if(r.edge===s.edge||!c(r,s))continue;const i=[r,s].filter(t=>t.interior);for(const t of i){for(const n of x){const o=d(t,n);if(o&&f(t.edge,o)){t.edge.points=o,e=!0;break}const r=p(t,n);if(r&&f(t.edge,r)){t.edge.points=r,e=!0;break}}if(e)break}}if(!e)return}}function Ie(t,e,n,o){const r=e.x-t.x,s=e.y-t.y,i=o.x-n.x,a=o.y-n.y,c=r*a-s*i;if(Math.abs(c)<1e-10)return!1;const f=n.x-t.x,d=n.y-t.y,l=(f*a-d*i)/c,u=(f*s-d*r)/c,h=.01;return l>h&&l<.99&&u>h&&u<.99}function Se(t){const e=t.nodes??[],n=t.edges??[],o=[];if(!n.length||!e.length)return o;const r=rt(e),i=[];for(const t of n){if(t.isLayoutOnly)continue;const e=t.points;if(!e||e.length<2)continue;const n=t.start,s=t.end,a=t.labelNodeId,c=t.id??`${n}->${s}`;for(const t of r)if(t.nodeId!==n&&t.nodeId!==s&&(!a||t.nodeId!==a))for(let n=0;n<e.length-1;n++)if(V(e[n],e[n+1],t,-1)){o.push({type:"edge-node-overlap",edgeId:c,targetId:t.nodeId,detail:`segment ${n} passes through node "${t.nodeId}"`});break}for(let t=0;t<e.length-1;t++)i.push({edgeId:c,start:n,end:s,p1:e[t],p2:e[t+1]})}const a=new Set;for(let t=0;t<i.length;t++)for(let e=t+1;e<i.length;e++){const n=i[t],r=i[e];if(n.edgeId!==r.edgeId&&(n.start!==r.start&&n.start!==r.end&&n.end!==r.start&&n.end!==r.end&&Ie(n.p1,n.p2,r.p1,r.p2))){const t=n.edgeId<r.edgeId?`${n.edgeId}|${r.edgeId}`:`${r.edgeId}|${n.edgeId}`;a.has(t)||(a.add(t),o.push({type:"edge-edge-crossing",edgeId:n.edgeId,targetId:r.edgeId,detail:`edges "${n.edgeId}" and "${r.edgeId}" cross`}))}}if(o.length>0){const t=o.filter(t=>"edge-node-overlap"===t.type).length,e=o.filter(t=>"edge-edge-crossing"===t.type).length;s.R.warn(`[SWIMLANE_VALIDATE] ${o.length} issue(s) detected: ${t} edge-node overlap(s), ${e} edge crossing(s)`);for(const t of o)s.R.warn(`[SWIMLANE_VALIDATE] ${t.type}: ${t.detail}`)}return o}function we(t,e){const n=t.nodes??[],o=t.edges??[],r=n.filter(t=>!t.isGroup);if(("LR"===e||"RL"===e)&&r.length>0&&!Wt(t,e))return;if("BT"===e&&r.length>0&&!_t(t))return;for(const t of o){if(t.isLayoutOnly)continue;const e=t.points;!e||e.length<2||(t.points=pt(gt(e)))}ue(o,n),Me(o,n),Qt(o,n);const s=new Map;for(const t of n)s.set(String(t.id),t);me(o,s),Mt(o,s),Ut(o,s),Ke(o,s),ne(o,s),oe(o,s),re(o,s),ae(o,s);const a=(0,i.K)(()=>{de(o,s),ce(o,s),fe(o,s),me(o,s),zt(o,s),re(o,s),me(o,s),zt(o,s)},"finalizeRenderedEdges");a(),Ke(o,s),a(),se(o,s),ie(o,s),se(o,s),ie(o,s)}function ve(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 t=`${r.id}:${r.src}->${r.dst}`;n.has(t)||(n.add(t),o.push(r))}return{nodes:[...e.keys()],edges:o,layout:t.layout,nodeById:e}}function Ce(t,e){return t.edges.filter(t=>t.dst===e)}function Le(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}function ke(t){const e=Le(t);for(const t of e.values())t.sort((t,e)=>t.localeCompare(e));return e}function Oe(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}function Re(t){return[...t.entries()].filter(([,t])=>0===t).map(([t])=>t).sort((t,e)=>t.localeCompare(e))}function Te(t,e=()=>!0){const n=new Map,o=new Map;for(const e of t.nodes)n.set(e,[]),o.set(e,[]);for(const r of t.edges)e(r)&&(o.get(r.src).push(r.dst),n.get(r.dst).push(r.src));return{preds:n,succs:o}}function $e(t,e,n,o){let r=0;for(const e of t.nodes)o?.skipGroups&&t.nodeById.get(e)?.isGroup||(r=Math.max(r,n[e]??0));const s=Array.from({length:r+1},()=>[]);for(const r of e)o?.skipGroups&&t.nodeById.get(r)?.isGroup||s[Math.max(0,n[r]??0)].push(r);return s}function Ne(t){const e=Oe(t),n=Re(e),o=[],r=ke(t);for(;n.length;){const t=n.shift();o.push(t);for(const o of r.get(t)??[])if(e.set(o,(e.get(o)??0)-1),0===(e.get(o)??0)){let t=0;for(;t<n.length&&n[t]<o;)t++;n.splice(t,0,o)}}return o.length===t.nodes.length?o:null}function Be(t){const e=new Map;let n=0;for(const o of t)e.set(o,n),n++;return e}function Fe(t){const e=new Array(t.length),n=(0,i.K)((o,r)=>{if(r-o<=1)return 0;const s=o+r>>1;let i=n(o,s)+n(s,r),a=o,c=s,f=o;for(;a<s||c<r;)c>=r||a<s&&t[a]<=t[c]?e[f++]=t[a++]:(e[f++]=t[c++],i+=s-a);for(let n=o;n<r;n++)t[n]=e[n];return i},"count");return n(0,t.length)}function Ee(t){const e=ve(t),n=new Map;for(const t of e.nodes)n.set(t,[]);for(const t of e.edges)n.get(t.src).push(t);for(const t of n.values())t.sort((t,e)=>t.dst===e.dst?t.id.localeCompare(e.id):t.dst.localeCompare(e.dst));const o=Object.create(null);for(const t of e.nodes)o[t]=0;const r=[],s=(0,i.K)(t=>{o[t]=1;for(const e of n.get(t)??[]){const t=e.dst;0===o[t]?s(t):1===o[t]&&r.push(e)}o[t]=2},"dfs"),a=[...e.nodes].sort((t,e)=>t.localeCompare(e));for(const t of a)0===o[t]&&s(t);const c=new Set(r.map(t=>`${t.id}:${t.src}->${t.dst}`)),f=e.edges.map(t=>c.has(`${t.id}:${t.src}->${t.dst}`)?{id:t.id,src:t.dst,dst:t.src,weight:t.weight,ref:t.ref}:t);return{acyclic:{nodes:[...e.nodes],edges:f,layout:e.layout,nodeById:new Map(e.nodeById)},reversed:r}}function Ye(t){const e=new Map,n=(0,i.K)(o=>{if(e.has(o))return e.get(o);const r=t.nodeById.get(o);if(!r)return e.set(o,null),null;const s=r.parentId;if(!s)return e.set(o,null),null;const i=n(s)??s;return e.set(o,i),i},"resolve");for(const e of t.nodes)n(e);return e}function Xe(t){const e=Ye(t);return t=>e.get(t)??null}function ze(t){const e=[];for(const n of t.layout.nodes??[])n.isGroup&&!n.parentId&&e.push(n.id);return[...new Set(e)].reverse()}function Ae(t,e){const n=ze(t);if(!e||0===e.length)return n;const o=new Set(n),r=new Set,s=[];for(const t of e)o.has(t)&&!r.has(t)&&(r.add(t),s.push(t));for(const t of n)r.has(t)||s.push(t);return s}(0,i.K)(be,"pairKey"),(0,i.K)(Me,"straightenCollinearSiblingDetours"),(0,i.K)(Ke,"nudgeSharedInteriorSubpaths"),(0,i.K)(Ie,"segmentsIntersect"),(0,i.K)(Se,"validateSwimlanesLayout"),(0,i.K)(we,"postProcessSwimlaneLayout"),(0,i.K)(ve,"normalizeGraph"),(0,i.K)(Ce,"incoming"),(0,i.K)(Le,"buildSuccessorMap"),(0,i.K)(ke,"buildSortedSuccessorMap"),(0,i.K)(Oe,"buildInDegreeMap"),(0,i.K)(Re,"sortedZeroInDegreeNodes"),(0,i.K)(Te,"buildPredecessorSuccessorMaps"),(0,i.K)($e,"buildLayersFromRanks"),(0,i.K)(Ne,"topoSortIfAcyclic"),(0,i.K)(Be,"buildLayerIndex"),(0,i.K)(Fe,"countInversions"),(0,i.K)(Ee,"removeCycles_DFS"),(0,i.K)(Ye,"buildTopLaneMap"),(0,i.K)(Xe,"createTopLaneResolver"),(0,i.K)(ze,"buildTopLaneOrder"),(0,i.K)(Ae,"resolveTopLaneOrder");var Pe=8,De=4,Ge=!0,He=100,je=40;function Ve(t,e){const n=ve(t),o=e?.laneOf??(()=>null),r=e?.rankHint,{preds:s}=Te(n);for(const t of s.values())t.sort((t,e)=>t.localeCompare(e));const a=Ne(n)??[...n.nodes].sort((t,e)=>t.localeCompare(e)),c=new Map;for(const[t,e]of a.entries())c.set(e,t);const f=new Map,d=new Map;for(const t of n.nodes)d.set(t,[]);for(const t of a){const e=(s.get(t)??[]).filter(t=>f.has(t));if(e.length>0){const n=_e(t,e,{laneOf:o,rankHint:r,topoIndex:c});f.set(t,n),d.get(n).push(t)}else f.has(t)||f.set(t,null)}for(const t of n.nodes)f.has(t)||f.set(t,null);const l=new Set;for(const t of n.nodes)null===(f.get(t)??null)&&l.add(t);const u=[...l].sort((t,e)=>{const n=c.get(t)??0,o=c.get(e)??0;return n===o?t.localeCompare(e):n-o}),h=We(n),g=new Map;for(const[t,e]of h.entries())g.set(t,[...e].sort((t,e)=>t.localeCompare(e)));const p=qe(g),x=Je(g),m=new Map;for(const t of n.nodes)m.set(t,[]);for(const t of x)for(const e of t.nodes){const n=m.get(e);n?n.push(t.id):m.set(e,[t.id])}const y=[],b=[],M=new Set,K=(0,i.K)(t=>{if(!M.has(t)){M.add(t),y.push(t);for(const e of d.get(t)??[])K(e);b.push(t)}},"walk");for(const t of u)K(t);for(const t of a)K(t);return{parent:f,children:d,roots:u,componentOf:p,blocks:x,nodeBlocks:m,adjacency:g,preorder:y,postorder:b,topologicalOrder:a}}function _e(t,e,n){const o=n.laneOf(t);return[...e].sort((t,e)=>{const r=n.laneOf(t),s=n.laneOf(e),i=null!=r&&r===o;if(i!==(null!=s&&s===o))return i?-1:1;const a=n.rankHint?.[t],c=n.rankHint?.[e];if(null!=a&&null!=c&&a!==c)return c-a;const f=n.topoIndex.get(t)??0,d=n.topoIndex.get(e)??0;return f!==d?f-d:t.localeCompare(e)})[0]}function We(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}function qe(t){const e=new Map;let n=0;for(const o of t.keys()){if(e.has(o))continue;const r=[o];for(;r.length>0;){const o=r.pop();if(!e.has(o)){e.set(o,n);for(const n of t.get(o)??[])e.has(n)||r.push(n)}}n++}return e}function Je(t){const e=new Map,n=new Map,o=[],r=[];let s=0;const a=(0,i.K)((i,c)=>{e.set(i,++s),n.set(i,s);for(const f of t.get(i)??[])f!==c&&(e.has(f)?(e.get(f)??0)<(e.get(i)??0)&&(o.push([i,f]),n.set(i,Math.min(n.get(i)??s,e.get(f)??s))):(o.push([i,f]),a(f,i),n.set(i,Math.min(n.get(i)??s,n.get(f)??s)),(n.get(f)??0)>=(e.get(i)??0)&&r.push(Qe(i,f,o,r.length))))},"visit");for(const n of t.keys())e.has(n)||a(n,null);return r}function Qe(t,e,n,o){const r=[],s=new Set;for(;n.length>0;){const o=n.pop();if(r.push(o),s.add(o[0]),s.add(o[1]),o[0]===t&&o[1]===e||o[0]===e&&o[1]===t)break}return{id:o,edges:r,nodes:[...s]}}function Ue(t,e,n){const o=[...t.nodes],r=new Map;for(const[t,e]of o.entries())r.set(e,t);const s=o.length,a=new Array(s).fill(-1),c=new Array(s).fill(0),f=[],d=new Set;for(const t of o){const e=n.parent.get(t)??null,o=r.get(t);null!=o&&(null==e&&(a[o]=-1,c[o]=0,d.has(t)||(d.add(t),f.push(t))))}for(;f.length>0;){const t=f.shift(),e=r.get(t);if(null==e)continue;const o=n.children.get(t)??[];for(const t of o){if(d.has(t))continue;const n=r.get(t);null!=n&&(a[n]=e,c[n]=c[e]+1,d.add(t),f.push(t))}}for(const t of o){if(d.has(t))continue;const e=r.get(t);null!=e&&(a[e]=-1,c[e]=0,d.add(t))}const l=Math.max(1,Math.ceil(Math.log2(Math.max(1,s)))+1),u=Array.from({length:l},()=>new Array(s).fill(-1));for(let t=0;t<s;t++)u[0][t]=a[t];for(let t=1;t<l;t++)for(let e=0;e<s;e++){const n=u[t-1][e];u[t][e]=-1===n?-1:u[t-1][n]}const h=(0,i.K)((t,e)=>{if(-1===t||-1===e)return-1;c[t]<c[e]&&([t,e]=[e,t]);const n=c[t]-c[e];for(let e=0;e<l;e++)if(n>>e&1&&-1===(t=u[e][t]))return-1;if(t===e)return t;for(let n=l-1;n>=0;n--){const o=u[n][t],r=u[n][e];-1!==o&&-1!==r&&(o!==r&&(t=o,e=r))}return u[0][t]},"lcaIndex"),g=Array.from({length:s},()=>new Map);for(const n of t.edges){let t=n.src,o=n.dst,s=e[t],i=e[o];if(null==s||null==i)continue;if(s>i&&([t,o]=[o,t],[s,i]=[i,s]),null==s||null==i||s===i)continue;const a=r.get(t),c=r.get(o);if(null==a||null==c)continue;const f=h(a,c);if(-1===f)continue;const d=g[f];for(let t=s;t<i;t++)d.set(t,(d.get(t)??0)+1)}const p=new Map,x=(0,i.K)((t,e)=>{if(0!==e.size)for(const[n,o]of e)t.set(n,(t.get(n)??0)+o)},"mergeInto"),m=new Set,y=(0,i.K)(t=>{const o=r.get(t);m.add(t);const s=null==o?void 0:g[o],i=s?new Map(s):new Map,a=n.children.get(t)??[];for(const n of a){const o=y(n),r=e[t];if(null!=r){let s=p.get(t);s||(s=new Map,p.set(t,s));let i=o.get(r)??0;const a=e[n];null!=a&&a>r&&(i+=1),s.set(n,i)}x(i,o)}return i},"dfs");for(const t of n.roots)m.has(t)||y(t);for(const t of o)m.has(t)||y(t);return p}function Ze(t,e,n){const o=new Map,r=(0,i.K)(t=>{let s=n[t]??0;const i=[...e.get(t)??[]];i.sort(tn(n));for(const t of i){r(t);const e=o.get(t);null!=e&&(s=Math.min(s,e))}o.set(t,s)},"annotate");for(const e of t)r(e);return o}function tn(t){return(e,n)=>{const o=t[e]??0,r=t[n]??0;return o===r?e.localeCompare(n):o-r}}function en(t,e,n,o){let r=0;for(const t of e){const e=n[t]??0;e>r&&(r=e)}const s=Array.from({length:r+1},()=>[]),a=new Set,c=(0,i.K)(t=>{if(a.has(t))return;a.add(t);const e=n[t]??0;s[e]||(s[e]=[]),s[e].push(t);for(const e of o(t))c(e)},"emit");for(const e of t)c(e);for(const t of e)if(!a.has(t)){const e=n[t]??0;s[e]||(s[e]=[]),s[e].push(t),a.add(t)}return s}function nn(t){const e=[];for(const n of t){const t=new Set,o=[];for(const e of n)t.has(e)||(t.add(e),o.push(e));e.push(o)}return e}function on(t,e,n,o){return r=>{const s=t.get(r)??[];if(0===s.length)return[];const i=e[r]??0,a=[],c=[],f=n.get(r);for(const t of s){const e=o.get(t)??i;e>i?a.push({child:t,min:e}):c.push(t)}return a.sort((t,e)=>t.min===e.min?t.child.localeCompare(e.child):t.min-e.min),c.sort((t,e)=>{const n=f?.get(t)??0,r=f?.get(e)??0;if(n!==r)return n-r;const s=o.get(t)??i,a=o.get(e)??i;return s!==a?s-a:t.localeCompare(e)}),[...a.map(t=>t.child),...c]}}function rn(t,e,n){const o=Ve(t,{rankHint:e,laneOf:n}),{children:r,roots:s}=o;for(const e of t.nodes)r.has(e)||r.set(e,[]);const i=Ue(t,e,o),a=[...s].sort(tn(e)),c=on(r,e,i,Ze(a,r,e));let f=en(a,t.nodes,e,c);return f=nn(f),f}function sn(t,e,n){const o=new Set(t),r=new Set(e),s=Be(e),i=[];for(const t of n)o.has(t.src)&&r.has(t.dst)&&i.push(s.get(t.dst));return Fe(i)}function an(t,e,n){const o=[];for(const t of e){const e=n[t.src],r=n[t.dst];if(null==e||null==r||e===r)continue;let s=t.src,i=t.dst,a=e,c=r;e>r&&(s=t.dst,i=t.src,a=r,c=e);for(let e=a;e<c;e++)o.push({id:`${t.id}@${e}`,src:s,dst:i,ref:t.ref})}let r=0;for(let e=0;e+1<t.length;e++)r+=sn(t[e],t[e+1],o);return r}function cn(t,e){const n={...e},{preds:o}=Te(t),r=Xe(t);let s=an(rn(t,n,r),t.edges,n);const i=De;for(let e=0;e<i;e++){let e=!1;const i=[...t.nodes].sort((t,e)=>(n[e]??0)-(n[t]??0));for(const a of i){const i=n[a]??0;if(0===i)continue;let c=0;for(const t of o.get(a)??[])c=Math.max(c,(n[t]??0)+1);if(c>=i)continue;const f=i;n[a]=c;const d=an(rn(t,n,r),t.edges,n);d<s?(s=d,e=!0):n[a]=f}if(!e)break}return n}function fn(t,e){const n=Xe(t),o=[...t.nodes].sort((t,n)=>(e[t]??0)-(e[n]??0)||t.localeCompare(n));for(const r of o){const o=n(r);if(!o)continue;const s=t.edges.filter(t=>t.src===r);if(0===s.length)continue;let i=!1,a=0;for(const t of s){const e=n(t.dst);null==e||e===o?i=!0:a++}if(0===a||i)continue;let c=0,f=!1;for(const e of t.edges){if(e.dst!==r)continue;const t=n(e.src);t&&(t===o?f=!0:c++)}if(c>0||!f)continue;const d=e[r]??0,l=d+a;let u=0;for(const n of t.edges)n.dst===r&&(u=Math.max(u,(e[n.src]??0)+1));const h=Math.max(d,u,l);h!==d&&(e[r]=h)}}function dn(t,e){const n=ve(t),o=Ne(n)??[...n.nodes].sort(),r=e?.compactSingleInput??!1,s=Xe(n);let i=Object.create(null);for(const t of o){const o=Ce(n,t),a=e?.ignoreCrossLaneEdges?o.filter(e=>{const n=s(e.src),o=s(t);return!n||!o||n===o}):o;if(0===a.length)i[t]=0;else if(r&&1===a.length){const e=a[0].src,n=s(e),o=s(t);i[t]=n!==o?i[e]??0:(i[e]??0)+1}else{let e=-1/0;for(const t of a)e=Math.max(e,(i[t.src]??0)+1);i[t]=e===-1/0?0:e}}e?.optimizeRanksByCrossings&&(i=cn(n,i)),e?.ignoreCrossLaneEdges&&fn(n,i);return{layers:rn(n,i,s),rankOf:i,dummy:new Set}}function ln(t,e){const n=ve(t),o={...dn(n,{compactSingleInput:e?.compactSingleInput,ignoreCrossLaneEdges:e?.ignoreCrossLaneEdges,optimizeRanksByCrossings:e?.optimizeRanksByCrossings}).rankOf},r=Xe(n),{preds:s,succs:a}=Te(n,t=>{if(e?.ignoreCrossLaneEdges){const e=r(t.src),n=r(t.dst);if(e&&n&&e!==n)return!1}return!0}),c=Ne(n)??[...n.nodes],f=[...c].reverse(),d=(0,i.K)((t,e)=>{let n=0;for(const e of s.get(t)??[])n=Math.max(n,(o[e]??0)+1);let r=Number.POSITIVE_INFINITY;const i=a.get(t)??[];return i.length>0&&(r=Math.min(...i.map(t=>(o[t]??0)-1))),Number.isFinite(r)||(r=Math.max(n,e)),Math.min(Math.max(e,n),r)},"clampFeasible"),l=Pe,u=(0,i.K)(t=>{let e=!1;for(const n of t){const t=s.get(n)??[],r=a.get(n)??[];if(0===t.length&&0===r.length)continue;const i=t.length>0?t.reduce((t,e)=>t+(o[e]??0)+1,0)/t.length:o[n]??0,c=r.length>0?r.reduce((t,e)=>t+(o[e]??0)-1,0)/r.length:o[n]??0,f=Math.round((i+c)/2),l=d(n,f);l!==o[n]&&(o[n]=l,e=!0)}return e},"relaxOrder");for(let t=0;t<l;t++){const t=u(c),e=u(f);if(!t&&!e)break}for(const t of c){let e=0;for(const n of s.get(t)??[])e=Math.max(e,(o[n]??0)+1);(o[t]??0)<e&&(o[t]=e)}for(const t of f){const e=a.get(t)??[];if(e.length>0){const n=Math.min(...e.map(t=>(o[t]??0)-1));(o[t]??0)>n&&(o[t]=n)}}return{layers:$e(n,c,o),rankOf:o,dummy:new Set}}function un(t){const e=Oe(t),n=ke(t);let o=Re(e);const r=[];for(;o.length>0;){const t=[];for(const s of o){r.push(s);for(const o of n.get(s)??[])e.set(o,(e.get(o)??0)-1),0===(e.get(o)??0)&&t.push(o)}o=t.sort((t,e)=>t.localeCompare(e))}return r.length===t.nodes.length?r:null}function hn(t,e){const n=ve(t),o="LR"===e?.direction?un(n)??[...n.nodes].sort():Ne(n)??[...n.nodes].sort(),r=Xe(n),s=(0,i.K)(t=>r(t)??t,"laneOf"),a=Object.create(null),c=new Map,f=(0,i.K)((t,n)=>e?.ignoreCrossLaneEdges??!0?s(t)===s(n)?1:0:1,"edgeWeight");for(const t of o){const e=n.nodeById.get(t);if(e?.isGroup)continue;const o=Ce(n,t);let r=0;if(o.length>0)for(const e of o){const n=e.src,o=a[n]??0;r=Math.max(r,o+f(n,t))}const i=s(t),d=c.get(i)??0,l=Math.max(r,d);a[t]=l,c.set(i,l+1)}return{layers:$e(n,o,a,{skipGroups:!0}),rankOf:a,dummy:new Set}}function gn(t,e){const n=ve(e),{rankOf:o}=t,r=t.layers.map(t=>[...t]),s=new Set(t.dummy?[...t.dummy]:[]);let a=0;const c=new Map(n.nodeById),f=(0,i.K)(t=>{const e="placeholder-"+a++,n={id:e,isGroup:!1,isDummy:!0,width:0,height:0};for(c.set(e,n),s.add(e);r.length<=t;)r.push([]);return r[t].push(e),o[e]=t,e},"addDummyAt"),d=[...n.edges].sort((t,e)=>t.id===e.id?t.src===e.src?t.dst.localeCompare(e.dst):t.src.localeCompare(e.src):t.id.localeCompare(e.id)),l=[];for(const t of d){const e=o[t.src]??0,n=o[t.dst]??0;if(n-e<=1){l.push(t);continue}let r=t.src;for(let o=e+1,s=0;o<n;o++,s++){const e=f(o);l.push({id:`${t.id}#${s}`,src:r,dst:e,weight:t.weight,ref:t.ref}),r=e}const s=n-e-2;l.push({id:`${t.id}#${Math.max(s+1,0)}`,src:r,dst:t.dst,weight:t.weight,ref:t.ref})}const u={nodes:[...n.nodes,...[...s].filter(t=>!n.nodes.includes(t))],edges:l,layout:n.layout,nodeById:c};return{layering:{layers:r,rankOf:o,dummy:s},graphWithDummies:u}}function pn(t){const e=t.length;if(0===e)return Number.POSITIVE_INFINITY;const n=[...t].sort((t,e)=>t-e);return e%2==1?n[(e-1)/2]:.5*(n[e/2-1]+n[e/2])}function xn(t){if(0===t.length)return Number.POSITIVE_INFINITY;return t.reduce((t,e)=>t+e,0)/t.length}function mn(t,e,n,o){const r=new Map;for(const e of t)r.set(e,[]);for(const t of n)"down"===o?e.has(t.src)&&r.has(t.dst)&&r.get(t.dst).push(e.get(t.src)):e.has(t.dst)&&r.has(t.src)&&r.get(t.src).push(e.get(t.dst));return r}function yn(t,e,n){const o=n.get(t)??0,r=n.get(e)??0;return o!==r?o-r:t.localeCompare(e)}function bn(t,e,n){const o=new Set(t),r=new Set(e),s=Be(t),i=Be(e),a=[];for(const t of n)o.has(t.src)&&r.has(t.dst)&&a.push({u:s.get(t.src),v:i.get(t.dst)});a.sort((t,e)=>t.u===e.u?t.v-e.v:t.u-e.u);return Fe(a.map(t=>t.v))}function Mn(t,e,n){return[...t].sort((t,o)=>{const r=pn(e.get(t)??[]),s=pn(e.get(o)??[]);return r===s?yn(t,o,n):isFinite(r)?isFinite(s)?r-s:-1:1})}function Kn(t,e,n,o,r,s){const i=Be(t),a=Be(e),c=mn(e,i,n,o);if(!r||!s||0===s.length)return Mn(e,c,a);const f=new Map;for(const t of e){const e=r(t),n=f.get(e)??[];n.push(t),f.set(e,n)}const d=[];for(const t of s){const e=f.get(t);if(!e||0===e.length)continue;const n=Mn(e,c,a);d.push(...n)}const l=f.get(null);if(l&&l.length>0){const t=Mn(l,c,a);for(const e of t){const t=xn(c.get(e)??[]);let n=d.length;if(isFinite(t))for(const[e,o]of d.entries()){if(t<xn(c.get(o)??[])){n=e;break}}d.splice(n,0,e)}}return d}function In(t,e,n,o,r){const s=[...e],a=new Set(t),c=new Set(e),f=o?new Set(o):null,d=n.filter(t=>a.has(t.src)&&c.has(t.dst)),l=f?n.filter(t=>c.has(t.src)&&f.has(t.dst)):void 0,u=(0,i.K)(e=>{let n=bn(t,e,d);return l&&o&&(n+=bn(e,o,l)),n},"crossingScore"),h=r?new Map:null;if(r&&h)for(const t of e)h.set(t,r(t));let g=!0,p=u(s);for(;g;){g=!1;for(let t=0;t+1<s.length;t++){if(h){if(h.get(s[t])!==h.get(s[t+1]))continue}const e=p;[s[t],s[t+1]]=[s[t+1],s[t]];const n=u(s);n<e?(p=n,g=!0):[s[t],s[t+1]]=[s[t+1],s[t]]}}return s}function Sn(t,e,n){const o=t.layers.map(t=>[...t]),r=e.edges,s=Xe(e),i=Ae(e,n?.laneOrder);for(let t=0;t<3;t++){for(let t=1;t<o.length;t++)o[t]=Kn(o[t-1],o[t],r,"down",s,i),o[t]=In(o[t-1],o[t],r,o[t+1],s);for(let t=o.length-2;t>=0;t--)o[t]=Kn(o[t+1],o[t],r,"up",s,i),o[t]=In(o[t+1],o[t],r,o[t-1],s)}return{layers:o}}function wn(t,e,n){const o=n?.layerGap??He,r=n?.nodeGap??je,s=n?.laneGap??2*r,a=n?.direction??"TB",c="LR"===a||"RL"===a,f=t.layers,d=Object.create(null),l=Object.create(null),u=(0,i.K)(t=>e.nodeById.get(t),"getNode"),h=(0,i.K)(t=>u(t)?.width??0,"getWidth"),g=(0,i.K)(t=>u(t)?.height??0,"getHeight"),p=Xe(e),x=Ae(e,n?.laneOrder),m=f.map(t=>t.reduce((t,e)=>Math.max(t,g(e)),0)),y=[];if(c)for(let t=0;t+1<f.length;t++){const e=f[t].reduce((t,e)=>Math.max(t,h(e)),0),n=f[t+1].reduce((t,e)=>Math.max(t,h(e)),0),r=m[t]/2+m[t+1]/2,s=(e+n)/2,i=Math.max(0,s-r-o);y.push(i)}const b=new Set;for(const t of f)for(const e of t)b.add(p(e));const M=b.has(null),K=x.filter(t=>b.has(t)),I=[...M?[null]:[],...K],S=Object.create(null);for(const t of K)S[t]=0;M&&(S.null=0);for(const t of f){const e=Object.create(null),n=[];for(const o of t){const t=p(o);null===t?n.push(o):(e[t]||=[]).push(o)}for(const[t,n]of Object.entries(e)){const e=n.reduce((t,e)=>t+h(e),0)+r*Math.max(0,n.length-1);S[t]=Math.max(S[t]??0,e)}if(M&&n.length){const t=n.reduce((t,e)=>t+h(e),0)+r*Math.max(0,n.length-1);S.null=Math.max(S.null??0,t)}}const w=new Map;{const t=I.map(t=>(null===t?S.null:S[t])??0);let e=-(t.reduce((t,e)=>t+e,0)+s*Math.max(0,I.length-1))/2;for(let n=0;n<I.length;n++){const o=I[n],r=t[n]??0,i=e+r/2;w.set(o,i),e+=r,n<I.length-1&&(e+=s)}}let v=0;for(const[t,e]of f.entries()){const n=m[t]??0,s=new Map;for(const t of e){const e=p(t),n=s.get(e)??[];n.push(t),s.set(e,n)}for(const t of I){const e=s.get(t)??[];if(0===e.length)continue;const o=w.get(t);if(1===e.length){const t=e[0];d[t]=o,l[t]=v+n/2}else{const t=e.map(t=>h(t));let s=o-(t.reduce((t,e)=>t+e,0)+r*(e.length-1))/2;for(const[o,i]of e.entries()){const e=t[o];d[i]=s+e/2,l[i]=v+n/2,s+=e+r}}}v+=n+o+(y[t]??0)}const C=new Map;for(const t of e.edges){const e=t.ref.id;C.has(e)||C.set(e,[]),C.get(e).push(t)}for(const[,t]of C){if(0===t.length)continue;const n=t[0].ref,o=n.start,r=n.end;if(null==o||null==r)continue;const s=Math.round(((d[o]??0)+(d[r]??0))/2),i=new Set;for(const e of t)i.add(e.src),i.add(e.dst);for(const t of i){if(t===o||t===r)continue;const n=e.nodeById.get(t);n?.isDummy&&(d[t]=s)}}return{x:d,y:l}}(0,i.K)(Ve,"buildDrivingTree"),(0,i.K)(_e,"chooseParent"),(0,i.K)(We,"buildAdjacency"),(0,i.K)(qe,"assignComponents"),(0,i.K)(Je,"computeBlocks"),(0,i.K)(Qe,"popBlock"),(0,i.K)(Ue,"computeSubtreeCrossCounts"),(0,i.K)(Ze,"annotateMinimumLayers"),(0,i.K)(tn,"compareByRankThenId"),(0,i.K)(en,"emitNodesInTreeOrder"),(0,i.K)(nn,"deduplicateLayers"),(0,i.K)(on,"createChildOrderer"),(0,i.K)(rn,"buildMultitreeLayerOrder"),(0,i.K)(sn,"countCrossingsBetweenAdjacent"),(0,i.K)(an,"totalCrossings"),(0,i.K)(cn,"optimizeRanksByCrossings"),(0,i.K)(fn,"adjustCrossLaneSources"),(0,i.K)(dn,"assignLayers_LongestPath"),(0,i.K)(ln,"assignLayers_Gravity"),(0,i.K)(un,"topoSortByGenerationIfAcyclic"),(0,i.K)(hn,"assignLayers_LaneAwareCompact"),(0,i.K)(gn,"makeProperLayering"),(0,i.K)(pn,"median"),(0,i.K)(xn,"barycenter"),(0,i.K)(mn,"neighborPositionsFor"),(0,i.K)(yn,"currentOrderTieBreak"),(0,i.K)(bn,"countCrossingsBetweenAdjacent"),(0,i.K)(Mn,"sortByHeuristic"),(0,i.K)(Kn,"reorderLayer"),(0,i.K)(In,"transposeImprove"),(0,i.K)(Sn,"orderLayers"),(0,i.K)(wn,"assignCoordinates");function vn(t){let e=2166136261;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e>>>0}function Cn(t){let e=t>>>0;return()=>{e+=1831565813;let t=e;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296}}function Ln(t,e){const n=[...t],o=Cn(e);for(let t=n.length-1;t>0;t--){const e=Math.floor(o()*(t+1));[n[t],n[e]]=[n[e],n[t]]}return n}function kn(t,e){let n=0;for(const[o,r]of t.entries())n+=Math.abs(o-(e.get(r)??o));return n}function On(t,e){const n=new Map;for(const[e,o]of t.entries())n.set(o,e);let o=0;for(const{a:t,b:r,weight:s}of e){const e=n.get(t),i=n.get(r);null!=e&&null!=i&&(o+=s*Math.abs(e-i))}return o}function Rn(t){const e=ze(t);if(e.length<2)return[];const n=new Map(e.map((t,e)=>[t,e])),o=Xe(t),r=new Map;for(const e of t.layout.edges??[]){if(e.isLayoutOnly)continue;const s="string"==typeof e.start?e.start:void 0,i="string"==typeof e.end?e.end:void 0;if(!(s&&i&&t.nodeById.has(s)&&t.nodeById.has(i)))continue;const a=o(s),c=o(i);if(!a||!c||a===c)continue;const f=n.get(a),d=n.get(c);if(null==f||null==d)continue;const[l,u]=f<=d?[a,c]:[c,a],h=`${l}\0${u}`,g=r.get(h);g?g.weight++:r.set(h,{a:l,b:u,weight:1})}return[...r.values()]}function Tn(t,e,n){const o=[...t];let r=On(o,e),s=!0,i=0;const a=Math.max(1,o.length);for(;s&&i<a;){s=!1,i++;for(let t=0;t+1<o.length;t++){[o[t],o[t+1]]=[o[t+1],o[t]];const n=On(o,e);n<r?(r=n,s=!0):[o[t],o[t+1]]=[o[t+1],o[t]]}}return{order:o,cost:r,sourceDistance:kn(o,n)}}function $n(t,e){return t.cost!==e.cost?t.cost<e.cost:t.sourceDistance<e.sourceDistance}function Nn(t,e,n){const o=[...e].sort((t,e)=>t.a===e.a?t.b.localeCompare(e.b):t.a.localeCompare(e.a)).map(({a:t,b:e,weight:n})=>`${t}:${e}:${n}`).join("|");return vn(`${t.join("|")}#${o}#${n}`)}function Bn(t,e={}){const n=ze(t);if(n.length<2)return n;const o=Rn(t);if(0===o.length)return n;const r=new Map(n.map((t,e)=>[t,e]));let s=Tn(n,o,r);const i=Math.max(0,e.restarts??8);for(let t=0;t<i;t++){const e=Tn(Ln(n,Nn(n,o,t)),o,r);$n(e,s)&&(s=e)}return s.order}function Fn(t,e){const n=e?.ignoreCrossLaneEdges??!0,o=e?.optimizeRanksByCrossings??!0,r=ve(t),s=e?.automaticLaneOrdering?Bn(r,{restarts:8}):void 0,i=Ee(r),a=i.acyclic,c=n?hn(a,{compactSingleInput:e?.compactSingleInput??Ge,ignoreCrossLaneEdges:!0,direction:e?.direction}):ln(a,{compactSingleInput:e?.compactSingleInput??Ge,ignoreCrossLaneEdges:!1,optimizeRanksByCrossings:o}),{layering:f,graphWithDummies:d}=gn(c,a),l=Sn(f,d,{laneOrder:s}),u=wn(l,d,{layerGap:e?.layerGap,nodeGap:e?.nodeGap,direction:e?.direction,laneOrder:s});return{acyclic:a,reversed:i.reversed,layering:f,ordered:l,coordinates:u}}(0,i.K)(vn,"hashString"),(0,i.K)(Cn,"mulberry32"),(0,i.K)(Ln,"deterministicShuffle"),(0,i.K)(kn,"sourceDistance"),(0,i.K)(On,"laneArrangementCost"),(0,i.K)(Rn,"buildWeightedLaneEdges"),(0,i.K)(Tn,"greedySwitch"),(0,i.K)($n,"isBetterCandidate"),(0,i.K)(Nn,"seedForRestart"),(0,i.K)(Bn,"optimizeTopLaneOrder"),(0,i.K)(Fn,"sugiyamaLayout");var En=1e-6,Yn=15,Xn=15,zn=20;function An(t,e,n){const o=t.x??0,r=t.y??0,s=e.x-o,i=e.y-r,a=Math.abs(s),c=Math.abs(i);if(a<En&&c<En)return n;return c>En&&3*c>=a?i>0?"bottom":"top":a>En?s>0?"right":"left":n}function Pn(t,e){return Math.abs(t.to-e.from)<En||Math.abs(t.to-e.to)<En?t.to:t.from}function Dn(t,e){return"vertical"===t.orient?{x:t.coord,y:e}:{x:e,y:t.coord}}function Gn(t,e){const n=t.nodes??[],o=t.edges??[],r=[];for(const t of o)t.isLayoutOnly||r.push({...t,__originalEdge:t});const s=new Map,a=new Map,c=[],f="LR"===e;for(const t of n)s.set(t.id,t);const d=n.filter(t=>t.isGroup&&!t.parentId);for(const t of d){const e={id:t.id},o=(0,i.K)(t=>{a.set(t.id,e),n.filter(e=>e.parentId===t.id).forEach(o)},"assignLane");o(t)}const l=n.filter(t=>!t.isGroup&&!t.isEdgeLabel).map(t=>{const e=t.width??10,n=t.height??10,o=t.x??0,r=t.y??0;return{nodeId:t.id,minX:o-e/2-8,maxX:o+e/2+8,minY:r-n/2-8,maxY:r+n/2+8,visualXHalfExtent:f?n/2+8:e/2+8}}),u=(0,i.K)((t,e,n,o)=>{let r=c.find(n=>n.orientation===t&&Math.abs(n.coord-e)<1);return r||(r={id:`pipe-${t}-${e.toFixed(0)}`,orientation:t,coord:e,spanMin:n,spanMax:o,tracks:[]},c.push(r)),r.spanMin=Math.min(r.spanMin,n),r.spanMax=Math.max(r.spanMax,o),r},"getOrAddPipe"),h=(0,i.K)((t,e)=>{const n=t.width??10,o=t.height??10,r=t.x??0,s=t.y??0;switch(e){case"top":return{x:r,y:s-o/2};case"bottom":return{x:r,y:s+o/2};case"left":return{x:r-n/2,y:s};case"right":return{x:r+n/2,y:s}}},"portForSide"),g=(0,i.K)((t,e,n)=>h(t,An(t,e,n?"bottom":"top")),"getOrthogonalPort"),p=[],x=[],m=new Set,y=(0,i.K)((t,e,n)=>{if(0===p.length)return 0;const o=Math.abs(e.y-n.y)<En,r=Math.abs(e.x-n.x)<En;if(!o&&!r)return 0;let s=0;if(o){const o=e.y,r=Math.min(e.x,n.x)-En,i=Math.max(e.x,n.x)+En;if(i<=r)return 0;for(const e of p)e.edgeIndex!==t&&"vertical"===e.orientation&&(e.pipe.coord<r||e.pipe.coord>i||e.from-En<=o&&e.to+En>=o&&(s+=1e3))}else if(r){const o=e.x,r=Math.min(e.y,n.y)-En,i=Math.max(e.y,n.y)+En;if(i<=r)return 0;for(const e of p)e.edgeIndex!==t&&"horizontal"===e.orientation&&(e.pipe.coord<r||e.pipe.coord>i||e.from-En<=o&&e.to+En>=o&&(s+=1e3))}return s},"crossingPenalty"),b=r.map((t,e)=>{if(!t.start||!t.end)return{idx:e,crossLane:0,dx:0,dy:0};const n=s.get(t.start),o=s.get(t.end),r=a.get(t.start),i=a.get(t.end);return{idx:e,crossLane:r&&i&&r.id!==i.id?1:0,dx:n&&o?Math.abs((o.x??0)-(n.x??0)):0,dy:n&&o?Math.abs((o.y??0)-(n.y??0)):0}}).sort((t,e)=>{if(t.crossLane!==e.crossLane)return e.crossLane-t.crossLane;const n=t.dx+t.dy,o=e.dx+e.dy;return Math.abs(n-o)>1?n-o:t.idx-e.idx}).map(t=>t.idx),M=(0,i.K)((t,e,n,o)=>{const r=Math.min(t.x,e.x),s=Math.max(t.x,e.x),i=Math.min(t.y,e.y),a=Math.max(t.y,e.y);return!!l.find(c=>(!n||c.nodeId!==n)&&((!o||c.nodeId!==o)&&(Math.abs(t.x-e.x)>En?c.minY<t.y&&c.maxY>t.y&&c.maxX>r&&c.minX<s:c.minX<t.x&&c.maxX>t.x&&c.maxY>i&&c.minY<a)))},"isSegmentBlocked"),K=new Map,I=new Map;for(const t of r)t.start&&t.end&&t.start!==t.end&&(I.set(t.start,(I.get(t.start)??0)+1),I.set(t.end,(I.get(t.end)??0)+1));const S=(0,i.K)((t,e)=>An(t,e,"bottom"),"determineSide"),w=new Map;for(const[t,e]of r.entries()){if(!e.start||!e.end||e.start===e.end)continue;if(e.points&&e.points.length>0)continue;const n=s.get(e.start),o=s.get(e.end);if(!n||!o)continue;const r=(o.x??0)-(n.x??0),i=(o.y??0)-(n.y??0);w.set(t,{edgeIdx:t,srcId:e.start,dstId:e.end,srcSide:S(n,{x:o.x??0,y:o.y??0}),dstSide:S(o,{x:n.x??0,y:n.y??0}),absDx:Math.abs(r),absDy:Math.abs(i),dxSign:Math.sign(r),dySign:Math.sign(i)})}const v=(0,i.K)(t=>"top"===t.srcSide||"bottom"===t.srcSide?0===t.absDx?1/0:t.absDy/t.absDx:0===t.absDy?1/0:t.absDx/t.absDy,"preferenceStrength"),C=(0,i.K)(t=>"top"===t.srcSide||"bottom"===t.srcSide?t.dxSign>=0?"right":"left":t.dySign>=0?"bottom":"top","secondarySide"),L=new Map;for(const t of w.values()){const e=`${t.srcId}:${t.srcSide}`;L.has(e)||L.set(e,[]),L.get(e).push(t)}const k=new Map,O=(0,i.K)((t,e)=>`${t}:${e}`,"loadKey");for(const t of w.values())k.set(O(t.srcId,t.srcSide),(k.get(O(t.srcId,t.srcSide))??0)+1),k.set(O(t.dstId,t.dstSide),(k.get(O(t.dstId,t.dstSide))??0)+1);for(const t of L.values())if(!(t.length<2)){t.sort((t,e)=>{const n=v(t),o=v(e);return Math.abs(n-o)>1e-9?o-n:t.edgeIdx-e.edgeIdx});for(let e=1;e<t.length;e++){const n=t[e],o=C(n),r=k.get(O(n.srcId,n.srcSide))??0,s=k.get(O(n.srcId,o))??0;s>=r||(k.set(O(n.srcId,n.srcSide),r-1),k.set(O(n.srcId,o),s+1),n.srcSide=o)}}const R=(0,i.K)(t=>{const e=t?.shape;return"question"===e||"diamond"===e},"isDiamondNode"),T=new Map;for(const t of w.values())T.has(t.dstId)||T.set(t.dstId,new Set),T.get(t.dstId).add(t.dstSide);for(const t of w.values()){if(!R(s.get(t.srcId)))continue;const e=T.get(t.srcId);if(!e?.has(t.srcSide))continue;const n=C(t);if(e.has(n)||(k.get(O(t.srcId,n))??0)>0)continue;const o=k.get(O(t.srcId,t.srcSide))??0;k.set(O(t.srcId,t.srcSide),Math.max(0,o-1)),k.set(O(t.srcId,n),1),t.srcSide=n}for(const t of w.values()){const{edgeIdx:e,srcId:n,dstId:o,srcSide:r,dstSide:i}=t,a=s.get(n),c=s.get(o),f=`${n}:${r}:src`,d="top"===r||"bottom"===r?c.x??0:c.y??0;K.has(f)||K.set(f,[]),K.get(f).push({edgeIdx:e,oppositeCoord:d});const l=`${o}:${i}:dst`,u="top"===i||"bottom"===i?a.x??0:a.y??0;K.has(l)||K.set(l,[]),K.get(l).push({edgeIdx:e,oppositeCoord:u})}const $=new Map;for(const[t,e]of K){if(e.length<2)continue;e.sort((t,e)=>t.oppositeCoord-e.oppositeCoord);const n=t.split(":"),o=n.slice(0,-2).join(":"),r=n[n.length-2],i=n[n.length-1],a=s.get(o);if(!a)continue;const c="left"===r||"right"===r?a.height??10:a.width??10,f=a.shape,d="question"===f||"diamond"===f?.3*c:c,l=20,u=Math.min(l,Math.max(8,d/(e.length+1))),h=-(u*(e.length-1))/2;for(const[t,n]of e.entries()){const e=h+t*u,o=`${n.edgeIdx}:${i}`;$.set(o,e)}}const N=(0,i.K)(t=>Boolean(r[t]?.labelNodeId),"edgeHasLabelNode"),B=(0,i.K)((t,e)=>!!t&&((K.get(`${t}:${e}:src`)??[]).some(({edgeIdx:t})=>N(t))||(K.get(`${t}:${e}:dst`)??[]).some(({edgeIdx:t})=>N(t))),"faceHasLabelNode"),F=(0,i.K)((t,e,n)=>"top"===e||"bottom"===e?{x:t.x+n,y:t.y}:{x:t.x,y:t.y+n},"applyPortOffset"),E=(0,i.K)((t,e,n)=>{const o=w.get(t),r={x:n.x??0,y:n.y??0},s={x:e.x??0,y:e.y??0},i=o?.srcSide??S(e,r),a=o?.dstSide??S(n,s);let c=o?h(e,o.srcSide):g(e,r,!0),f=o?h(n,o.dstSide):g(n,s,!1);const d=$.get(`${t}:src`),l=$.get(`${t}:dst`);return void 0!==d&&(c=F(c,i,d)),void 0!==l&&(f=F(f,a,l)),{pSrcPort:c,pDstPort:f,srcSide:i,dstSide:a}},"portsForEdge");for(const t of b){const e=r[t];if(x[t]=[],!e.start||!e.end)continue;if(e.points&&e.points.length>0)continue;if(e.start===e.end)continue;const n=s.get(e.start),o=s.get(e.end);if(!n||!o)continue;const{pSrcPort:a,pDstPort:d,srcSide:h,dstSide:g}=E(t,n,o),b={...a},S={...d},w="top"===h||"bottom"===h,v="top"===g||"bottom"===g;if(w){const t=a.y>(n.y??0);b.y=t?a.y+zn:a.y-zn}else{const t=a.x>(n.x??0);b.x=t?a.x+zn:a.x-zn}if(v){const t=d.y>(o.y??0);S.y=t?d.y+zn:d.y-zn}else{const t=d.x>(o.x??0);S.x=t?d.x+zn:d.x-zn}const C=(0,i.K)((t,e)=>{for(const n of l)if(!e.includes(n.nodeId)&&t.x>n.minX&&t.x<n.maxX&&t.y>n.minY&&t.y<n.maxY)return{inside:!0,obstacle:n};return{inside:!1}},"isPointInObstacle"),L=(0,i.K)((t,e,n,o,r)=>{if(r){const r=t.y>(e.y??0);return{x:(n.x??0)>=t.x?o.maxX+Yn:o.minX-Yn,y:r?o.maxY+Xn:o.minY-Xn,leavesPositiveSide:r}}const s=t.x>(e.x??0),i=(n.y??0)>=t.y;return{x:s?o.maxX+Yn:o.minX-Yn,y:i?o.maxY+Xn:o.minY-Xn,leavesPositiveSide:s}},"obstacleDetour");let k=[];const O=[e.start,e.end],R=C(b,O);if(R.inside&&R.obstacle){const t=R.obstacle;if(w){const e=L(a,n,o,t,!0);b.x=e.x,b.y=e.y;const r=e.leavesPositiveSide?Math.min(t.minY-2,a.y+zn):Math.max(t.maxY+2,a.y-zn);k=[{x:a.x,y:r},{x:e.x,y:r},{x:e.x,y:e.y}]}else{const e=L(a,n,o,t,!1),r=e.leavesPositiveSide?Math.min(t.minX-2,a.x+zn):Math.max(t.maxX+2,a.x-zn);b.x=e.x,b.y=e.y,k=[{x:r,y:a.y},{x:r,y:e.y},{x:e.x,y:e.y}]}}let T=[];const N=C(S,O);if(N.inside&&N.obstacle){const t=N.obstacle;if(v){const e=L(d,o,n,t,!0);S.x=e.x,S.y=e.y,T=[{x:e.x,y:e.y},{x:d.x,y:e.y}]}else{const e=L(d,o,n,t,!1);S.x=e.x,S.y=e.y,T=[{x:e.x,y:e.y},{x:e.x,y:d.y}]}}if(0===k.length&&0===T.length){const n=Yn,o=Math.abs(b.x-S.x)<n,r=Math.abs(b.y-S.y)<n,s=void 0!==$.get(`${t}:src`)||void 0!==$.get(`${t}:dst`),i=(K.get(`${e.start??""}:${h}:src`)?.length??0)+(K.get(`${e.start??""}:${h}:dst`)?.length??0),c=(K.get(`${e.end??""}:${g}:src`)?.length??0)+(K.get(`${e.end??""}:${g}:dst`)?.length??0),f=i>1||c>1,l=I.get(e.start??"")??0,u=I.get(e.end??"")??0,x=i>1&&B(e.start,h)||c>1&&B(e.end,g);if((o||r)&&!s&&(!f||f&&!x&&(i<=1||l<=2)&&(c<=1||u<=2))){if(!M(a,d,e.start,e.end)){e.points=[{...a},{...b},{...S},{...d}],m.add(t);const n=r?"horizontal":"vertical",o=r?a.y:a.x,s=r?Math.min(a.x,d.x):Math.min(a.y,d.y),i=r?Math.max(a.x,d.x):Math.max(a.y,d.y),c={id:`fast-path-${n}-${o.toFixed(0)}-${t}`,orientation:n,coord:o,spanMin:s,spanMax:i,tracks:[]};p.push({edgeIndex:t,segmentIndex:0,orientation:n,pipe:c,trackIndex:0,from:s,to:i});continue}}}const F=u("vertical",b.x,b.y,b.y);b.x=F.coord;const Y=u("vertical",S.x,S.y,S.y);S.x=Y.coord;let X=Math.min(b.x,S.x)-50,z=Math.max(b.x,S.x)+50,A=Math.min(b.y,S.y)-50,P=Math.max(b.y,S.y)+50;for(const t of l){const e=Math.min(b.x,S.x),n=Math.max(b.x,S.x),o=Math.min(b.y,S.y),r=Math.max(b.y,S.y);t.minX<n&&t.maxX>e&&t.minY<r&&t.maxY>o&&(X=Math.min(X,t.minX-25),z=Math.max(z,t.maxX+25),A=Math.min(A,t.minY-25),P=Math.max(P,t.maxY+25))}for(const t of l){if(t.maxX<X||t.minX>z||t.maxY<A||t.minY>P)continue;const e=Yn;u("horizontal",t.minY-e,X,z),u("horizontal",t.maxY+e,X,z);const n=Xn;u("vertical",t.minX-n,A,P),u("vertical",t.maxX+n,A,P)}u("horizontal",b.y,X,z),u("horizontal",S.y,X,z);const D=c.filter(t=>"horizontal"===t.orientation&&t.coord>=A&&t.coord<=P),G=c.filter(t=>"vertical"===t.orientation&&t.coord>=X&&t.coord<=z),H=(0,i.K)((t,e)=>`${t.toFixed(1)},${e.toFixed(1)}`,"getKey"),j=H(b.x,b.y),V=H(S.x,S.y),_=new Map,W=new Map,q=new Map,J=new Set,Q=[];_.set(j,0),q.set(j,"n"),Q.push({key:j,f:Math.hypot(S.x-b.x,S.y-b.y),pt:b}),J.add(j);let U=[];const Z=(0,i.K)((t,n)=>M(t,n,e.start,e.end),"checkSegmentBlocked"),tt={x:S.x,y:b.y},et=Z(b,tt),nt=Z(tt,S),ot=et||nt,rt={x:b.x,y:S.y},st=Z(b,rt),it=Z(rt,S);if(ot?st||it||(U=Math.abs(b.x-S.x)<En?[b,S]:[b,rt,S]):U=Math.abs(b.y-S.y)<En||Math.abs(b.x-S.x)<En?[b,S]:[b,tt,S],0===U.length)for(;Q.length>0;){Q.sort((t,e)=>t.f-e.f);const n=Q.shift();if(J.delete(n.key),n.key===V){let t=V,e=S;for(U=[e];W.has(t);){const n=W.get(t);U.unshift(n),e=n,t=H(n.x,n.y)}break}const o=n.pt.x,r=n.pt.y,s=G.sort((t,e)=>t.coord-e.coord),i=s.findIndex(t=>Math.abs(t.coord-o)<1),a=D.sort((t,e)=>t.coord-e.coord),c=a.findIndex(t=>Math.abs(t.coord-r)<1),f=[];i>0&&f.push({x:s[i-1].coord,y:r}),i>=0&&i<s.length-1&&f.push({x:s[i+1].coord,y:r}),c>0&&f.push({x:o,y:a[c-1].coord}),c>=0&&c<a.length-1&&f.push({x:o,y:a[c+1].coord});for(const s of f){const i=Math.min(o,s.x),a=Math.max(o,s.x),c=Math.min(r,s.y),f=Math.max(r,s.y);if(l.some(t=>t.nodeId!==e.start&&t.nodeId!==e.end&&(i!==a?t.minY<r&&t.maxY>r&&t.maxX>i&&t.minX<a:t.minX<o&&t.maxX>o&&t.maxY>c&&t.minY<f)))continue;const d=H(s.x,s.y),u=Math.abs(s.x-o)+Math.abs(s.y-r),h=y(t,n.pt,s);let g=0;const p=S.x-b.x,x=S.y-b.y,m=s.x-o,M=s.y-r;(x>10&&M<-5||x<-10&&M>5)&&(g=100*Math.abs(M)),(p>10&&m<-5||p<-10&&m>5)&&(g+=50*Math.abs(m));let K=0;const I=q.get(n.key)??"n",w=Math.abs(m)>En?"h":"v";"n"!==I&&I!==w&&(K=50);const v=u+h+g+K,C=(_.get(n.key)??1/0)+v,L=Math.abs(S.x-s.x)+Math.abs(S.y-s.y);if(C<(_.get(d)??1/0))if(W.set(d,n.pt),_.set(d,C),q.set(d,w),J.has(d)){const t=Q.findIndex(t=>t.key===d);-1!==t&&(Q[t].f=C+L)}else Q.push({key:d,f:C+L,pt:s}),J.add(d)}}if(0===U.length&&(U=[b,{x:b.x,y:S.y},S]),U.length>4){const t=U[0],e=U[U.length-1];let n=Math.min(t.x,e.x),o=Math.max(t.x,e.x),r=Math.min(t.y,e.y),s=Math.max(t.y,e.y);for(const t of U)n=Math.min(n,t.x),o=Math.max(o,t.x),r=Math.min(r,t.y),s=Math.max(s,t.y);const a=o>Math.max(t.x,e.x),c=n<Math.min(t.x,e.x);if(f){const r=Xn;if(a){const n=Math.max(t.x,e.x),s=Math.min(t.y,e.y),i=Math.max(t.y,e.y),a=l.filter(t=>t.minX<n&&t.maxX>n&&t.minY<i&&t.maxY>s);if(a.length>0){let n=Math.max(t.x,e.x);for(const t of a){const e=(t.minX+t.maxX)/2;if(void 0===t.visualXHalfExtent||isNaN(t.visualXHalfExtent))continue;const o=e+t.visualXHalfExtent+r;n=Math.max(n,o)}isNaN(n)||(o=n)}}if(c){const o=l.filter(n=>n.minX<Math.min(t.x,e.x)+r&&n.minY<Math.max(t.y,e.y)&&n.maxY>Math.min(t.y,e.y));if(o.length>0){let s=Math.min(t.x,e.x);for(const t of o){const e=(t.minX+t.maxX)/2-t.visualXHalfExtent-r;s=Math.min(s,e)}n=s}}}const d=(0,i.K)(n=>{const o=e.y>t.y,r=l.filter(n=>{const o=Math.min(t.x,e.x)<n.maxX&&Math.max(t.x,e.x)>n.minX,r=Math.min(t.y,e.y)<n.maxY&&Math.max(t.y,e.y)>n.minY;return o&&r});let s=r;if(f&&r.length>0){const t=r.filter(t=>t.minX<n&&t.maxX>n);t.length>0&&(s=t)}if(0===s.length)return e.y;if(o){const t=Math.max(...s.map(t=>t.maxY))+15;if(t<e.y-En)return t}else{const t=Math.min(...s.map(t=>t.minY))-15;if(t>e.y+En)return t}return e.y},"findBestReturnY"),u=(0,i.K)(n=>{const o=d(n),r={x:n,y:t.y},s={x:n,y:o},i={x:e.x,y:o},a=Z(t,r),c=Z(r,s),f=Z(s,i),l=o!==e.y&&Z(i,e);return a||c||f||l?null:Math.abs(o-e.y)<En?[t,r,s,e]:[t,r,s,i,e]},"trySimplifyWithDetourX"),h=a&&!c?u(o):c&&!a?u(n):null;h&&(U=h)}const at=[a,...k,...U,...T.reverse(),d];if(at.length>=3){const t=at[at.length-1],e=at[at.length-2],n=at[at.length-3],o=Math.abs(n.y-e.y)<En&&Math.abs(e.y-t.y)<En,r=Math.abs(n.x-e.x)<En&&Math.abs(e.x-t.x)<En;if(o){const o=Math.sign(e.x-n.x),r=Math.sign(t.x-n.x);0!==o&&o===r&&Math.abs(e.x-n.x)>Math.abs(t.x-n.x)&&at.splice(-2,1)}else if(r){const o=Math.sign(e.y-n.y),r=Math.sign(t.y-n.y);0!==o&&o===r&&Math.abs(e.y-n.y)>Math.abs(t.y-n.y)&&at.splice(-2,1)}}const ct=[at[0]];for(let t=1;t<at.length-1;t++){if(1===t){ct.push(at[t]);continue}const e=ct[ct.length-1],n=at[t],o=at[t+1];if(Math.abs(e.y-n.y)<En&&Math.abs(n.y-o.y)<En){if(n.x>e.x!==o.x>n.x){ct.push(n);continue}continue}if(Math.abs(e.x-n.x)<En&&Math.abs(n.x-o.x)<En){if(n.y>e.y!==o.y>n.y){ct.push(n);continue}continue}ct.push(n)}ct.push(at[at.length-1]);for(let e=0;e<ct.length-1;e++){const n=ct[e],o=ct[e+1],r=Math.abs(n.x-o.x)<En?"vertical":"horizontal",s="vertical"===r?n.x:n.y,i="vertical"===r?Math.min(n.y,o.y):Math.min(n.x,o.x),a="vertical"===r?Math.max(n.y,o.y):Math.max(n.x,o.x),c=u(r,s,i,a),f={edgeIndex:t,segmentIndex:e,orientation:r,pipe:c,trackIndex:0,from:i,to:a};p.push(f),x[t].push(p.length-1),c.tracks[0]||(c.tracks[0]={index:0,coord:c.coord,segments:[]}),c.tracks[0].segments.push({edgeIndex:t,segmentIndex:e,from:i,to:a})}}const Y=(0,i.K)((t,e)=>t.from<e.to&&e.from<t.to,"segmentsOverlap"),X=(0,i.K)((t,e,n,o)=>{const r=!o.segments.some(n=>(n.edgeIndex!==e.edgeIndex||n.segmentIndex!==e.segmentIndex)&&Y(n,t)),s=!n.segments.some(n=>(n.edgeIndex!==t.edgeIndex||n.segmentIndex!==t.segmentIndex)&&Y(n,e));return!(!r||!s)&&(t.trackIndex=o.index,e.trackIndex=n.index,n.segments=[...n.segments.filter(e=>e.edgeIndex!==t.edgeIndex||e.segmentIndex!==t.segmentIndex),{edgeIndex:e.edgeIndex,segmentIndex:e.segmentIndex,from:e.from,to:e.to}],o.segments=[...o.segments.filter(t=>t.edgeIndex!==e.edgeIndex||t.segmentIndex!==e.segmentIndex),{edgeIndex:t.edgeIndex,segmentIndex:t.segmentIndex,from:t.from,to:t.to}],!0)},"trySwapSegmentsAcrossTracks"),z=(0,i.K)(t=>{const e=t.tracks.length;return t.tracks[e]={index:e,coord:t.coord,segments:[]},e},"createNewTrack"),A=(0,i.K)((t,e)=>{const n=t.pipe.tracks[t.trackIndex];n.segments=n.segments.filter(e=>e.edgeIndex!==t.edgeIndex||e.segmentIndex!==t.segmentIndex),t.trackIndex=e;t.pipe.tracks[e].segments.push({edgeIndex:t.edgeIndex,segmentIndex:t.segmentIndex,from:t.from,to:t.to})},"moveSegmentToTrack"),P=(0,i.K)((t,e)=>{const n=x[t.edgeIndex];for(const o of n){const n=p[o];n.pipe===t.pipe&&A(n,e)}},"moveSegmentChainToTrack"),D=(0,i.K)(t=>{const e=x[t.edgeIndex],n=e.indexOf(p.indexOf(t)),o=[];return n>0&&o.push(p[e[n-1]]),n<e.length-1&&o.push(p[e[n+1]]),o},"getAdjacentSegmentsAlongEdge"),G=(0,i.K)((t,e)=>{if(t.orientation===e.orientation)return!1;const n="horizontal"===t.orientation?t:e,o="horizontal"===t.orientation?e:t;return o.pipe.coord>n.from&&o.pipe.coord<n.to&&n.pipe.coord>o.from&&n.pipe.coord<o.to},"haveAnyCrossing"),H=(0,i.K)((t,e)=>{for(const n of t.tracks){if(!n.segments.some(t=>(t.edgeIndex!==e.edgeIndex||t.segmentIndex!==e.segmentIndex)&&Y(t,e)))return n.index}return-1},"findAvailableTrack"),j=(0,i.K)((t,e)=>{if(t.trackIndex===e.trackIndex)return Y(t,e);const n=D(t),o=D(e);return n.some(t=>o.some(e=>G(t,e)))},"segmentsConflict"),V=(0,i.K)((t,e,n)=>{if(X(t,e,t.pipe.tracks[t.trackIndex],e.pipe.tracks[e.trackIndex]))return;const o=H(t.pipe,e);n(e,-1!==o?o:z(t.pipe))},"resolveTrackConflict"),_=(0,i.K)(t=>{let e=0;for(let n=0;n<t.length;n++)for(let o=n+1;o<t.length;o++){const r=t[n],s=t[o];r.pipe===s.pipe&&(j(r,s)&&(e++,V(r,s,P)))}return e},"resolveHandleConflicts"),W=new Map,q=(0,i.K)(t=>{if(W.has(t))return W.get(t);const e=x[t];if(0===e.length){const e={dest:0,deviation:0,base:0,delta:0};return W.set(t,e),e}const n=p[e[0]].pipe.coord;let o=n;for(let t=1;t<e.length;t++){const r=p[e[t]];if("horizontal"===r.orientation){const t=r.from,e=r.to;o=Math.abs(t-n)>Math.abs(e-n)?t:e;break}}const r={dest:o,deviation:Math.abs(o-n),base:n,delta:o-n};return W.set(t,r),r},"getDestInfo"),J=(0,i.K)(()=>{let t=0;const e=new Map;for(const[t,n]of r.entries())0!==x[t].length&&n.start&&(e.has(n.start)||e.set(n.start,[]),e.get(n.start).push(t));const n=(0,i.K)(t=>{const e=r[t];if(!e.start||!e.end)return 0;const n=s.get(e.start),o=s.get(e.end);if(!n||!o)return 0;const i=(o.x??0)-(n.x??0),a=(o.y??0)-(n.y??0);return Math.abs(i)+Math.abs(a)},"getEdgeDistance");for(const o of e.values()){o.sort((t,e)=>{const o=q(t),r=q(e);if(Math.abs(o.deviation-r.deviation)>1)return o.deviation-r.deviation;if(Math.abs(o.dest-r.dest)>1)return o.dest-r.dest;const s=n(t),i=n(e);if(Math.abs(s-i)>1)return i-s;const a=x[t].length,c=x[e].length;if(a!==c)return a-c;if(1===a){const n=x[t][0],o=x[e][0];if(p[n]&&p[o]){const t=p[n],e=p[o],r=Math.abs(t.to-t.from),s=Math.abs(e.to-e.from);if(Math.abs(r-s)>1)return r-s}}return 0});const e=o.map(t=>p[x[t][0]]);t+=_(e)}return t},"fixSourceHandleCrossings"),Q=(0,i.K)(()=>{let t=0;const e=new Map;for(const[t,n]of r.entries()){0!==x[t].length&&(n.end&&(e.has(n.end)||e.set(n.end,[]),e.get(n.end).push(t)))}for(const n of e.values()){n.sort((t,e)=>{const n=(0,i.K)(t=>{const e=x[t];if(e.length<2)return 0;const n=p[e[e.length-2]];return Math.abs(n.to-n.from)},"getDist"),o=n(t),r=n(e);return Math.abs(o-r)>.1?o-r:t-e});const e=n.map(t=>p[x[t][x[t].length-1]]);t+=_(e)}return t},"fixTargetHandleCrossings"),U=(0,i.K)(()=>{let t=0;for(const e of c){const n=[];for(const t of e.tracks)for(const e of t.segments){const t=x[e.edgeIndex].find(t=>p[t].segmentIndex===e.segmentIndex);void 0!==t&&n.push(p[t])}n.sort((t,e)=>t.edgeIndex-e.edgeIndex||t.segmentIndex-e.segmentIndex);for(let e=0;e<n.length;e++)for(let o=e+1;o<n.length;o++){const r=n[e],s=n[o];j(r,s)&&(t++,V(r,s,A))}}return t},"fixPipeCrossings");let Z=0;for(;Z<10;){let t=0;if(t+=J(),t+=Q(),t+=U(),0===t)break;Z++}const tt=new Map;for(const t of c){const e=[];t.tracks.forEach(t=>{t.segments.forEach(n=>{e.push({edgeIndex:n.edgeIndex,segmentIndex:n.segmentIndex,trackIndex:t.index,from:n.from,to:n.to})})}),e.sort((t,e)=>t.from-e.from);const n=[];if(e.length>0){let t=[e[0]],o=e[0].to;for(let r=1;r<e.length;r++){const s=e[r];s.from<o?(t.push(s),o=Math.max(o,s.to)):(n.push(t),t=[s],o=s.to)}n.push(t)}for(const e of n){const n=new Set;e.forEach(t=>n.add(t.trackIndex));const o=new Map;e.forEach(t=>{const e=q(t.edgeIndex);o.set(t.trackIndex,(o.get(t.trackIndex)??0)+e.delta)});const r=[...n].filter(t=>(o.get(t)??0)<-1),s=[...n].filter(t=>(o.get(t)??0)>1),a=[...n].filter(t=>Math.abs(o.get(t)??0)<=1);r.sort((t,e)=>(o.get(e)??0)-(o.get(t)??0)),s.sort((t,e)=>(o.get(t)??0)-(o.get(e)??0));const c=(0,i.K)((n,o)=>{e.filter(t=>t.trackIndex===n).forEach(e=>{const n=m.has(e.edgeIndex)?t.coord:o;tt.set(`${e.edgeIndex}-${e.segmentIndex}`,n)})},"assignCoord");let f=0;for(const e of r)f++,c(e,t.coord-10*f);if(0===a.length&&n.size>0){const t=[...n].sort((t,e)=>Math.abs(o.get(t)??0)-Math.abs(o.get(e)??0))[0],e=r.indexOf(t);-1!==e&&r.splice(e,1);const i=s.indexOf(t);-1!==i&&s.splice(i,1),a.push(t)}let d=0;for(const e of a){if(0===d)c(e,t.coord);else{const n=d%2==1?1:-1,o=Math.ceil(d/2);c(e,t.coord+n*o*10*.5)}d++}let l=0;for(const e of s)l++,c(e,t.coord+10*l)}}for(const[t,e]of r.entries()){const n=x[t]??[];if(0===n.length)continue;const o=[],r=s.get(e.start),i=s.get(e.end),{pSrcPort:a,pDstPort:c}=E(t,r,i),f=n.map(t=>{const e=p[t],n=tt.get(`${e.edgeIndex}-${e.segmentIndex}`)??e.pipe.coord;return{orient:e.orientation,coord:n,from:e.from,to:e.to}});o.push(a);for(let t=0;t<f.length;t++){const e=f[t],n=o[o.length-1],r="vertical"===e.orient?n.y:n.x,s="vertical"===e.orient?n.x:n.y,i=f[t+1],a=t<f.length-1;if(Math.abs(s-e.coord)>En&&o.push(Dn(e,r)),a&&i.orient===e.orient)if(Math.abs(e.coord-i.coord)>En){const t="vertical"===e.orient?(r+i.from)/2:Pn(e,i);o.push(Dn(e,t),Dn(i,t))}else 0!==t&&t!==f.length-2||o.push(Dn(e,Pn(e,i)));else if(a)o.push(Dn(e,i.coord));else{const t=Math.abs(e.from-r)<Math.abs(e.to-r)?e.to:e.from;o.push(Dn(e,t))}}const d=o[o.length-1];(Math.abs(d.x-c.x)>En||Math.abs(d.y-c.y)>En)&&o.push(c);const l=[];o.length>0&&l.push(o[0]);for(let t=1;t<o.length;t++){const e=o[t],n=l[l.length-1];(Math.abs(e.x-n.x)>En||Math.abs(e.y-n.y)>En)&&l.push(e)}e.points=l}for(const t of r){const e=t.__originalEdge;e&&t.points&&(e.points=t.points)}t.edges=(t.edges??[]).filter(t=>!t.isLayoutOnly);const et=(0,i.K)((t,e)=>{const n=e.x??0,o=e.y??0,r=e.width??0,s=e.height??0;if(r<=0||s<=0)return t;const i=n-r/2,a=n+r/2,c=o-s/2,f=o+s/2;if(t.x<i||t.x>a||t.y<c||t.y>f)return t;const d=t.x-i,l=a-t.x,u=t.y-c,h=f-t.y,g=Math.min(d,l,u,h);return g===d?{x:i,y:t.y}:g===l?{x:a,y:t.y}:g===u?{x:t.x,y:c}:{x:t.x,y:f}},"nodeBoundaryClamp");for(const e of t.edges){const t=e.points;if(!t||t.length<2)continue;const n=e.start,o=e.end,r=n?s.get(n):void 0,i=o?s.get(o):void 0;r&&(t[0]=et(t[0],r)),i&&(t[t.length-1]=et(t[t.length-1],i))}return t}function Hn(t){return t.direction??"TB"}function jn(t){const e=O(t),n=t.config.flowchart?.nodeSpacing??40,o=t.config.flowchart?.rankSpacing??100,r=t.config.swimlane?.ignoreCrossLaneEdges??!0,s=t.config.swimlane?.optimizeRanksByCrossings??!0,i=t.config.swimlane?.automaticLaneOrdering??!1,a=Hn(t),{ordered:c,coordinates:f}=Fn(e,{nodeGap:n,layerGap:o,ignoreCrossLaneEdges:r,optimizeRanksByCrossings:s,automaticLaneOrdering:i,direction:a});R(e,c,f,{nodeGap:n,layerGap:o});for(const e of t.edges??[])delete e.points;Gn(t,a);for(const e of t.edges??[])e.curve&&"basis"!==e.curve||(e.curve="rounded");return we(t,a),Se(t),a}function Vn(t){k(t);const e=T(t);t.nodes=e.nodes,t.edges=e.edges}(0,i.K)(An,"chooseOrthogonalSide"),(0,i.K)(Pn,"sharedLineEndpointCoord"),(0,i.K)(Dn,"pointOnLine"),(0,i.K)(Gn,"routeEdgesOrthogonal"),(0,i.K)(Hn,"getSwimlaneDirection"),(0,i.K)(jn,"runSwimlaneLayoutCore"),(0,i.K)(Vn,"prepareSwimlaneLayout");var _n=(0,o.xY)({prepareLayout:Vn,runLayoutCore:jn,afterPaint:w})}}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[
|
|
1
|
+
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[7567],{67567(e,t,n){n.d(t,{diagram:()=>r});var a=n(27038),l=(n(64918),n(96755),n(1672),n(841),n(10561),n(338),n(24980),n(27838),n(96865),n(48159),n(44505),n(69793),n(43287),n(12505),n(86535),n(31293),(0,n(86827).K)(e=>`${(0,a.tM)(e)}\n .swimlane.cluster rect {\n stroke: ${e.clusterBorder} !important;\n }\n [data-look="neo"].cluster rect {\n filter: none;\n }\n`,"getStyles")),r=(0,a.ur)({defaultLayout:"swimlane",styles:l})}}]);
|