@lancc/cmark 1.2.0 → 1.2.1
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/CHANGELOG.md +8 -0
- package/LICENSE +21 -21
- package/README.md +47 -107
- package/assets/abnfDiagram-WEYOIA3C-CKV_7Upb.js +1 -0
- package/assets/architectureDiagram-ZHVYKT53-BvLudDvk.js +1 -0
- package/assets/blockDiagram-RJAE7QA3--gzkMGi2.js +1 -0
- package/assets/c4Diagram-XDPPPE54-ByfRiJGR.js +1 -0
- package/assets/chunk-2E7WHVMD-TfbC_dmh.js +1 -0
- package/assets/chunk-2Q5K7J3B-0YJgChVo.js +1 -0
- package/assets/chunk-4EMNKR2T-DHoYW7g5.js +1 -0
- package/assets/chunk-55XCU76K-Cq25Yw_G.js +1 -0
- package/assets/chunk-5VM5RSS4-CJaRXFHK.js +1 -0
- package/assets/chunk-JWPE2WC7-BP2iXBhe.js +1 -0
- package/assets/chunk-VQ5W62QI-B95zur4F.js +1 -0
- package/assets/chunk-XXDRQBXY-Ct0MhvQo.js +1 -0
- package/assets/chunk-ZCHMQSOR-C5VhW-wL.js +2 -0
- package/assets/classDiagram-v2-4MYWR3UA-C1G-Vkj0.js +1 -0
- package/assets/cose-bilkent-JH36ORCC-qIQoIBv0.js +1 -0
- package/assets/cynefin-EF2NZ3EQ-CR1E3YiZ.js +1 -0
- package/assets/cynefinDiagram-WF24UDRP-DaJFvZ3b.js +1 -0
- package/assets/cytoscape.esm-SjxgSg6I.js +9 -0
- package/assets/dagre-NK4GIZVX-BFRQhpii.js +1 -0
- package/assets/diagram-CBK3MWTC-DlueL6XZ.js +1 -0
- package/assets/diagram-I5XIIV2D-bITyafYX.js +1 -0
- package/assets/diagram-ODIL2UCW-Dlb4hg_-.js +1 -0
- package/assets/diagram-PFBEJUXE-CRfen0O7.js +1 -0
- package/assets/diagram-RJA3I4VV-CK-FlhGV.js +1 -0
- package/assets/diagram-TYUNFSNR-DmgVsxqa.js +1 -0
- package/assets/ebnfDiagram-V4P3TTPT-B9KGI9eQ.js +1 -0
- package/assets/echarts-CytsvCdp.js +25 -0
- package/assets/elk-QONTBCTQ-VgDftvsU.js +1 -0
- package/assets/erDiagram-KYQIGQAA-DkpP7sS4.js +1 -0
- package/assets/flowDiagram-IUGLLWBU-CRXa9Kxy.js +1 -0
- package/assets/ganttDiagram-R7GPNTJY-Cu2I55Wb.js +1 -0
- package/assets/gitGraphDiagram-PDYL7XHY-CwSo663I.js +1 -0
- package/assets/graph-Dz7AM1Q5.js +1 -0
- package/assets/index-BJ-NdQc4.js +100 -0
- package/assets/infoDiagram-MVDRKAX5-D3Qknzuo.js +1 -0
- package/assets/ishikawaDiagram-HPEHV2GE-9qYT75tk.js +1 -0
- package/assets/journeyDiagram-BOSHW7O7-DeSrJg9o.js +1 -0
- package/assets/kanban-definition-FNSA4HC5-DINkB6G7.js +1 -0
- package/assets/katex-DN8cTsI3.js +1 -0
- package/assets/markdown-S2mWvoE-.js +5 -0
- package/assets/mermaid-T_6Ze_cT.js +7 -0
- package/assets/mindmap-definition-6OY57UG3-DW5hqiAe.js +1 -0
- package/assets/pegDiagram-ECIUJNBX-BWy_tkzy.js +1 -0
- package/assets/pieDiagram-GNMPY74T-CniJbr6l.js +1 -0
- package/assets/quadrantDiagram-D57K4MC3-BVnDJkCv.js +1 -0
- package/assets/railroadDiagram-Y72NRBL7-BNKZpJJb.js +1 -0
- package/assets/requirementDiagram-EQYSW5RA-BETipHj0.js +1 -0
- package/assets/sankeyDiagram-SY24JHO5-ByEYqT7T.js +1 -0
- package/assets/sequenceDiagram-BLEHNHQU-BqCJ2tKG.js +1 -0
- package/assets/sizeCapture-INFHLROL-DlhrWFj-.js +1 -0
- package/assets/stateDiagram-v2-A6IESKWZ-DJUBWLTP.js +1 -0
- package/assets/swimlanes-B3ENRKFQ-D7k7tF5U.js +1 -0
- package/assets/swimlanesDiagram-AYQRV4AK-DoQBgB9o.js +1 -0
- package/assets/timeline-definition-JXYKGLGB-BCNhwnn6.js +1 -0
- package/assets/usecaseDiagram-WPOLBNNX-DRa_Rgl3.js +1 -0
- package/assets/vennDiagram-Q3Y3IDCW-Ba2eaO68.js +1 -0
- package/assets/wardleyDiagram-IVAIDKWA-W_i9vzY-.js +1 -0
- package/assets/xychartDiagram-4URNHDU4-ByfaGjvc.js +1 -0
- package/index.html +3 -3
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/preload/git-panel.js +29 -5
- package/preload/git-service.js +48 -15
- package/preload/remote-setup.js +66 -33
- package/preload/remote-wizard.js +2 -0
- package/preload.js +30 -0
- package/assets/abnfDiagram-WEYOIA3C-BgXsTF7a.js +0 -1
- package/assets/architectureDiagram-ZHVYKT53-BsCWa_qC.js +0 -36
- package/assets/blockDiagram-RJAE7QA3-wbIxEiYN.js +0 -140
- package/assets/c4Diagram-XDPPPE54-5zdyxFvA.js +0 -38
- package/assets/chunk-2E7WHVMD-F85Lca-i.js +0 -88
- package/assets/chunk-2Q5K7J3B-CjpAZ0OI.js +0 -1
- package/assets/chunk-4EMNKR2T-C8Kbh83c.js +0 -1
- package/assets/chunk-55XCU76K-BINcFiLN.js +0 -1
- package/assets/chunk-5VM5RSS4-Diy5h2LS.js +0 -15
- package/assets/chunk-JWPE2WC7-BXnjDdh1.js +0 -1
- package/assets/chunk-VQ5W62QI-BM7ZZo1I.js +0 -1
- package/assets/chunk-XXDRQBXY-CW8CjB1w.js +0 -1
- package/assets/chunk-ZCHMQSOR-C7ATz1L1.js +0 -2
- package/assets/classDiagram-v2-4MYWR3UA-CMoqNk-b.js +0 -217
- package/assets/cose-bilkent-JH36ORCC-6rqR5iJk.js +0 -1
- package/assets/cynefin-EF2NZ3EQ-DypLIJxl.js +0 -141
- package/assets/cynefinDiagram-WF24UDRP-8b2CEBlR.js +0 -62
- package/assets/cytoscape.esm-CjX6Hyah.js +0 -331
- package/assets/dagre-NK4GIZVX-Dv6vuUbR.js +0 -4
- package/assets/diagram-CBK3MWTC-DJgMDeYd.js +0 -24
- package/assets/diagram-I5XIIV2D-BB9cMoRW.js +0 -24
- package/assets/diagram-ODIL2UCW-BVcRtsdy.js +0 -30
- package/assets/diagram-PFBEJUXE-BbGSOtJx.js +0 -3
- package/assets/diagram-RJA3I4VV-CzkY_8Fo.js +0 -41
- package/assets/diagram-TYUNFSNR-YTl5QdfL.js +0 -200
- package/assets/ebnfDiagram-V4P3TTPT-COVjPAjE.js +0 -1
- package/assets/echarts-BAPDkhe3.js +0 -61
- package/assets/elk-QONTBCTQ-DHsjY8Z_.js +0 -27
- package/assets/erDiagram-KYQIGQAA-CUAbTUl1.js +0 -99
- package/assets/flowDiagram-IUGLLWBU-CWsiqTQC.js +0 -213
- package/assets/ganttDiagram-R7GPNTJY-DetBW0Wm.js +0 -292
- package/assets/gitGraphDiagram-PDYL7XHY-ByrdgJmw.js +0 -106
- package/assets/graph-D8UmR1vK.js +0 -1
- package/assets/index-B17NCAw4.js +0 -758
- package/assets/infoDiagram-MVDRKAX5-BM48fjhU.js +0 -2
- package/assets/ishikawaDiagram-HPEHV2GE-DtHYywHZ.js +0 -70
- package/assets/journeyDiagram-BOSHW7O7-DJ1LiRh3.js +0 -139
- package/assets/kanban-definition-FNSA4HC5-DPPt8pwJ.js +0 -89
- package/assets/katex-CQL9J12G.js +0 -257
- package/assets/markdown-DVehI1Sg.js +0 -314
- package/assets/mermaid-C_q9pug0.js +0 -312
- package/assets/mindmap-definition-6OY57UG3-zbqYOEY6.js +0 -98
- package/assets/pegDiagram-ECIUJNBX-e7QG7TMq.js +0 -1
- package/assets/pieDiagram-GNMPY74T-Duf6YP0N.js +0 -39
- package/assets/quadrantDiagram-D57K4MC3-B2eYoUUy.js +0 -7
- package/assets/railroadDiagram-Y72NRBL7-BWCzPcI_.js +0 -1
- package/assets/requirementDiagram-EQYSW5RA-HhPMEqB1.js +0 -84
- package/assets/sankeyDiagram-SY24JHO5-CMUTwFBB.js +0 -40
- package/assets/sequenceDiagram-BLEHNHQU-C9wR2ll7.js +0 -169
- package/assets/sizeCapture-INFHLROL-DXfz37S6.js +0 -1
- package/assets/stateDiagram-v2-A6IESKWZ-D_gtonhE.js +0 -291
- package/assets/swimlanes-B3ENRKFQ-DdJOuuMV.js +0 -1
- package/assets/swimlanesDiagram-AYQRV4AK-BWt3HxHV.js +0 -8
- package/assets/timeline-definition-JXYKGLGB-DQsdwJe-.js +0 -120
- package/assets/usecaseDiagram-WPOLBNNX-DTRyFq7d.js +0 -370
- package/assets/vennDiagram-Q3Y3IDCW-dihYszm0.js +0 -34
- package/assets/wardleyDiagram-IVAIDKWA-BoPpgYfK.js +0 -78
- package/assets/xychartDiagram-4URNHDU4-DoLjYxeB.js +0 -7
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as t}from"./chunk-4EMNKR2T-DHoYW7g5.js";import{c as e}from"./chunk-ZCHMQSOR-C5VhW-wL.js";import{_ as n,l as o}from"./mermaid-T_6Ze_cT.js";import"./graph-Dz7AM1Q5.js";import"./markdown-S2mWvoE-.js";function r(e,{measure:n}){const o=e.config?.swimlane?.lineHops;if(!1===o)return;const r="gap"===o?"gap":"arc",s=e.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}));t(n.groups.edgePaths,s,{enabled:!0,jumpRadius:6,jumpStyle:r})}n(r,"applySwimlaneLineJumps");var s="__swimlane_default__";function i(t){return Math.max(t.padding??20,20)}function a(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 c(t){const e=t.direction,n=t.nodes??=[];for(const s of t.nodes??[])s.isGroup&&!s.parentId&&(s.shape="swimlane",e&&(s.direction=e));const o=n.filter(t=>!t.isGroup&&!t.parentId);if(0===o.length)return;let r=n.find(t=>t.id===s);r?r.isGroup&&(r.shape="swimlane",e&&(r.direction=e)):(r={id:s,label:"",isGroup:!0,shape:"swimlane",padding:20,look:t.config?.look,colorIndex:n.reduce((t,e)=>Math.max(t,e.colorIndex??-1),-1)+1,...e?{direction:e}:{}},n.push(r));for(const i of o)i.parentId=s}function f(t){const e=new Map;for(const i of t.nodes??[])e.set(i.id,i);const n=[];for(const i of t.edges??[]){const t="string"==typeof i.start?i.start:void 0,e="string"==typeof i.end?i.end:void 0;t&&e&&(i.labelNodeId||n.push({id:i.id,src:t,dst:e,ref:i}))}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 d(t,e,n,o){const{layout:r}=t,s=t.nodeById,c=o?.layerGap??100,f=o?.nodeGap??40;let d=0;for(const i of e.layers){let t=0;for(const e of i){const o=s.get(e);if(!o){t++;continue}o.layer=d,o.order=t;const r=n.x[e]??t*f,i=n.y[e]??d*c;o.x=r,o.y=i,t++}d++}const l=r.nodes??[],u=new Map,h=[];for(const a of l){if(!a?.isGroup)continue;a.parentId||h.push(a);const t=l.filter(t=>t.parentId===a.id);let e=1/0,o=-1/0,r=1/0,s=-1/0;for(const i of t){const t=i.x??n.x[i.id],a=i.y??n.y[i.id],c=i.width??0,f=i.height??0;null!=t&&null!=a&&(e=Math.min(e,t-c/2),o=Math.max(o,t+c/2),r=Math.min(r,a-f/2),s=Math.max(s,a+f/2))}if(e===1/0||r===1/0)a.x=a.x??0,a.y=a.y??0,a.width=a.width??0,a.height=a.height??0;else{const t=a.padding??20,n=a.parentId?t:2*i(a),c=t,f=Math.max(0,o-e)+n,d=Math.max(0,s-r)+c,l=(e+o)/2,h=(r+s)/2;a.x=l,a.y=h,a.width=f,a.height=d,u.set(a.id,{minX:e,maxX:o,minY:r,maxY:s})}}if(h.length>0&&u.size>0){let t=1/0,e=-1/0,n=0;for(const o of h){const r=o.padding??20;r>n&&(n=r);const s=u.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 h)e.y=s,e.height=r,e.swimlaneContentTop=t;const c=[...h].sort((t,e)=>(t.x??0)-(e.x??0)),f=[],d=[],l=[];for(const t of c){const e=u.get(t.id);if(!e)continue;const n=Math.max(0,e.maxX-e.minX)+2*i(t),o=(e.minX+e.maxX)/2;f.push(t.id),d.push(o),l.push(n)}const g=f.length;if(g>0){const t=new Map;if(1===g)t.set(f[0],l[0]);else{const e=[];for(let t=0;t<g-1;t++)e.push(d[t+1]-d[t]);const n=new Array(g);n[0]=0;for(let t=0;t<g-1;t++)n[t+1]=2*e[t]-n[t];let o=0,r=Number.POSITIVE_INFINITY;for(let t=0;t<g;t++){const e=l[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 i=0;i<g;i++){const e=n[i]+(i%2==0?s:-s),o=Math.max(l[i],e);t.set(f[i],o)}}for(const e of h){const n=t.get(e.id);null!=n&&(e.width=n),a(e)}}}}}n(i,"topLaneHorizontalPadding"),n(a,"assignTopLaneTitleRect"),n(c,"prepareLayoutForSwimlanes"),n(f,"toGraphView"),n(d,"writeBackToLayoutData");function l(t){const e=[],n=[],r=new Map;for(const o of t.nodes)r.set(o.id,o);for(const a of t.edges){if(!a.label||0===a.label.length)continue;if(a.isLayoutOnly)continue;if(a.labelNodeId)continue;const t=a.start?r.get(a.start):void 0,s=a.end?r.get(a.end):void 0;if(!t||!s){o.warn("[EdgeLabelNodes]",`Edge ${a.id} has missing source or target node`);continue}const i=`edge-label-${a.start}-${a.end}-${a.id}`,c=t.parentId!==s.parentId?s.parentId:t.parentId,f={id:i,label:a.label,edgeStart:a.start??"",edgeEnd:a.end??"",shape:"labelRect",width:0,height:0,isEdgeLabel:!0,isDummy:!0,parentId:c,isGroup:!1,labelStyle:Array.isArray(a.labelStyle)?a.labelStyle[0]:a.labelStyle??"",...t.dir?{dir:t.dir}:{}};e.push(f),a.labelNodeId=i,a.label=void 0,a.text=void 0;const d={id:`${a.id}-to-label`,start:a.start,end:i,type:"normal",isLayoutOnly:!0},l={id:`${a.id}-from-label`,start:i,end:a.end,type:"normal",isLayoutOnly:!0};n.push(d,l)}const s=[...t.nodes,...e],i=[...t.edges,...n];return{...t,nodes:s,edges:i}}n(l,"createEdgeLabelNodes");var u=.001;function h(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:T(e,n,o,r)}:void 0}function g(t){if(t.isGroup)return;const e=h(t);if(!e)return;return{id:String(t.id??""),cx:e.cx,cy:e.cy,rect:e.rect}}function p(t,e,n=u){return Math.abs(t.x-e.x)<n&&Math.abs(t.y-e.y)<n}function x(t,e,n=u){return Math.abs(t.x-e.x)<n}function m(t,e,n=u){return Math.abs(t.y-e.y)<n}function y(t,e,n=u){return m(t,e,n)&&Math.abs(t.x-e.x)>n}function b(t,e,n=u){return x(t,e,n)&&Math.abs(t.y-e.y)>n}function M(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 I(t,e,n=u){return t.horizontal&&e.horizontal&&m(t.a,e.a,n)?M(t.a.x,t.b.x,e.a.x,e.b.x):t.vertical&&e.vertical&&x(t.a,e.a,n)?M(t.a.y,t.b.y,e.a.y,e.b.y):0}function S(t,e=u){const n=[];for(let o=0;o<t.length-1;o++){const r=t[o],s=t[o+1],i=y(r,s,e),a=b(r,s,e);(i||a)&&n.push({index:o,a:r,b:s,horizontal:i,vertical:a})}return n}function w(t,e=u){const n=S(t,e);let o=0;for(let r=1;r<n.length;r++)n[r-1].horizontal!==n[r].horizontal&&o++;return o}function v(t,e=u){const n=[];for(const o of t){const t=n.length>0?n[n.length-1]:void 0;t&&p(t,o,e)||n.push({x:o.x,y:o.y})}return n}function C(t,e=u){if(!t||4!==t.length)return;const[n,o,r,s]=t;if(y(n,o,e)&&b(o,r,e)&&y(r,s,e))return{kind:"HVH",p0:n,p1:o,p2:r,p3:s};return b(n,o,e)&&y(o,r,e)&&b(r,s,e)?{kind:"VHV",p0:n,p1:o,p2:r,p3:s}:void 0}function L(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 k(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 O(t,e){return t.left<=e.left&&t.right>=e.right&&t.top<=e.top&&t.bottom>=e.bottom}function R(t,e){return t.left<e.right&&t.right>e.left&&t.top<e.bottom&&t.bottom>e.top}function N(t,e){return{left:t.left-e,right:t.right+e,top:t.top-e,bottom:t.bottom+e}}function T(t,e,n,o){return{left:t-n/2,right:t+n/2,top:e-o/2,bottom:e+o/2}}function B(t){return h(t)?.rect}function F(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 E(t,e,n,o,r,s=u){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(m(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(m(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(x(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(x(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 $(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 Y(t){const e=new Map,n=[];for(const o of t){if(o.isEdgeLabel)continue;const t=g(o);t&&(e.set(t.id,t),n.push({id:t.id,rect:t.rect}))}return{nodeInfoById:e,realNodeRects:n}}function X(t){const e=[],n=[];for(const o of t){const t=g(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 z(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,...T(t,r,s,i)})}return n}function P(t,e,n=u){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 G(t,e,n,o=[],r=0){for(const s of n)if(!o.includes(s.id)&&L(t,e,s.rect,-r))return!0;return!1}function D(t,e,n,o,r=u,s=1e-6){const i=m(t,e,r),a=x(t,e,r),c=m(n,o,r),f=x(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},h=d.a.y,g=Math.min(d.a.x,d.b.x),p=Math.max(d.a.x,d.b.x),y=l.a.x,b=Math.min(l.a.y,l.b.y),M=Math.max(l.a.y,l.b.y);if(y<g||y>p||h<b||h>M)return!1;const I=Math.abs(y-d.a.x)<s&&Math.abs(h-d.a.y)<s||Math.abs(y-d.b.x)<s&&Math.abs(h-d.b.y)<s,S=Math.abs(y-l.a.x)<s&&Math.abs(h-l.a.y)<s||Math.abs(y-l.b.x)<s&&Math.abs(h-l.b.y)<s;return!(I&&S)}function A(t,e,n,o,r=u){const s=m(t,e,r),i=x(t,e,r),a=m(n,o,r),c=x(n,o,r);return i&&c&&x(t,n,r)?M(t.y,e.y,n.y,o.y)>r:!!(s&&a&&m(t,n,r))&&M(t.x,e.x,n.x,o.x)>r}function H(t,e,n,o,{epsilon:r=u,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||!p(i,a,r))&&(D(t,e,i,a,r)||A(t,e,i,a,r)))return!0}}return!1}function j(t,e,n,o,r=u){const s=m(t,e,r),i=x(t,e,r),a=m(n,o,r),c=x(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,h=Math.min(f.a.x,f.b.x),g=Math.max(f.a.x,f.b.x),p=d.a.x,y=Math.min(d.a.y,d.b.y),b=Math.max(d.a.y,d.b.y);return p>h+r&&p<g-r&&l>y+r&&l<b-r}function V(t,e,n){const o=Math.min(e,n),r=Math.max(e,n);return t>o+u&&t<r-u}function _(t,e,n){return x(t,e)&&x(e,n)?V(e.y,t.y,n.y):!(!m(t,e)||!m(e,n))&&V(e.x,t.x,n.x)}function W(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(p(r,i)){o++,e=!0;continue}if(_(r,s,i)){e=!0;continue}}n.push(s)}return{points:n,changed:e}}function K(t){const e=[t[0]];for(let o=1;o<t.length;o++){const n=e[e.length-1],r=t[o];if(!x(n,r)&&!m(n,r)){const t=e.length>=2?e[e.length-2]:void 0,o=!!t&&x(t,n)?{x:n.x,y:r.y}:{x:r.x,y:n.y};e.push(o)}e.push(r)}const n=[];for(const o of e){const t=n[n.length-1];t&&p(t,o)||n.push(o)}return n}function q(t){if(t.length<3)return t;let e=[...t];for(let n=0;n<32;n++){const t=W(e);if(e=t.points,!t.changed)break}return e}n(h,"measuredNodeRect"),n(g,"nodeBoundsInfoFor"),n(p,"samePoint"),n(x,"sameX"),n(m,"sameY"),n(y,"isHorizontalSegment"),n(b,"isVerticalSegment"),n(M,"overlapLength"),n(I,"sameAxisSegmentOverlapLength"),n(S,"orthogonalSegmentsForPoints"),n(w,"countOrthogonalBends"),n(v,"dedupeConsecutivePoints"),n(C,"classifyThreeSegmentRoute"),n(L,"segmentBoundsOverlapRect"),n(k,"pointInsideRect"),n(O,"rectContainsRect"),n(R,"rectsOverlap"),n(N,"inflateRect"),n(T,"rectFromCenterSize"),n(B,"rectOfNodeBounds"),n(F,"portForRectSide"),n(E,"buildOrthogonalPortPath"),n($,"buildSameSideTrackPath"),n(Y,"collectRealNodeBounds"),n(X,"collectNodeRectEntries"),n(z,"collectLayoutNodeRects"),n(P,"getNodePairGeometry"),n(G,"segmentHitsAnyRect"),n(D,"orthogonalSegmentsCross"),n(A,"sameAxisSegmentsOverlap"),n(H,"segmentConflictsWithAnyEdge"),n(j,"orthogonalSegmentsStrictlyCross"),n(V,"strictlyBetween"),n(_,"isCollinearIntermediate"),n(W,"simplifyPolylineOnce"),n(K,"orthogonalizePolyline"),n(q,"simplifyPolyline");var U=.001;function J(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?B(r):void 0,dstRect:s?B(s):void 0}}function Z(t,e,n){if(m(t,e,U)){return{x:t.x<n.left?n.left:n.right,y:t.y}}if(x(t,e,U)){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 Q(t,e,n){const o=n?1:-1;let r=n?0:t.length-1;for(;r>=0&&r<t.length&&k(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=Z(t[r],t[s],e);return n?[i,...t.slice(r)]:[...t.slice(0,r+1),i]}function tt(t,e){for(const n of t){const t=J(n,e,2);if(!t)continue;let o=[...t.points];t.srcRect&&(o=Q(o,t.srcRect,!0)),t.dstRect&&(o=Q(o,t.dstRect,!1)),o=q(K(o)),o=lt(o,t.srcRect,t.dstRect),t.edge.points=q(K(o))}}function et(t,e,n,o=!1){if(m(t,e,U)){if(e.y<n.top-U||e.y>n.bottom+U)return e;if(o){if(t.x<n.left-U)return{x:n.left,y:t.y};if(t.x>n.right+U)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(x(t,e,U)){if(e.x<n.left-U||e.x>n.right+U)return e;if(o){if(t.y<n.top-U)return{x:t.x,y:n.top};if(t.y>n.bottom+U)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 nt(t,e,n){const o=t[e];for(let r=e+n;r>=0&&r<t.length;r+=n){const e=t[r];if(!p(e,o,U))return e}return t[e+n]}function ot(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 rt(t,e,n){const{lo:o,hi:r}=ot(e,n);return Math.min(r,Math.max(o,t))}function st(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 it(t,e){return"left"===e||"right"===e?ot(t.top,t.bottom):ot(t.left,t.right)}function at(t,e,n){const o=t.y>=n.top-U&&t.y<=n.bottom+U,r=t.x>=n.left-U&&t.x<=n.right+U;if(m(t,e,U)&&o){if(Math.abs(t.x-n.left)<U)return"left";if(Math.abs(t.x-n.right)<U)return"right"}if(x(t,e,U)&&r){if(Math.abs(t.y-n.top)<U)return"top";if(Math.abs(t.y-n.bottom)<U)return"bottom"}}function ct(t){return"left"===t||"right"===t}function ft(t,e,n,o,r){const s=[],i=n?at(t,e,n):void 0,a=o?at(e,t,o):void 0;return n&&i&&ct(i)===r&&s.push(it(n,i)),o&&a&&ct(a)===r&&s.push(it(o,a)),s.length>0?st(s):void 0}function dt(t,e,n,o,r){const s=ft(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)<U?void 0:r?[{x:t.x,y:a},{x:e.x,y:a}]:[{x:a,y:t.y},{x:a,y:e.y}]}function lt(t,e,n){if(2!==t.length)return t;const[o,r]=t;return m(o,r,U)?dt(o,r,e,n,!0)??t:x(o,r,U)?dt(o,r,e,n,!1)??t:t}function ut(t,e,n){return ct(n)?{x:t.x,y:rt(t.y,e.top,e.bottom)}:{x:rt(t.x,e.left,e.right),y:t.y}}function ht(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&&!m(e,o,U))break;if(!s&&!x(e,o,U))break;s?i[a].y=r.y:i[a].x=r.x}return i}function gt(t,e,n){if(t.length<2)return t;const o=n?0:t.length-1,r=n?1:-1,s=t[o],i=nt(t,o,r);if(!i)return t;const a=at(s,i,e);if(!a)return t;const c=ct(a),f=ut(s,e,a);return p(s,f,U)?t:ht(t,o,r,s,f,c)}function pt(t,e,n){const o=Math.min(t.x,e.x)>=n.left-U&&Math.max(t.x,e.x)<=n.right+U,r=Math.min(t.y,e.y)>=n.top-U&&Math.max(t.y,e.y)<=n.bottom+U;return Math.abs(t.y-n.top)<U&&Math.abs(e.y-n.top)<U&&o?"top":Math.abs(t.y-n.bottom)<U&&Math.abs(e.y-n.bottom)<U&&o?"bottom":Math.abs(t.x-n.left)<U&&Math.abs(e.x-n.left)<U&&r?"left":Math.abs(t.x-n.right)<U&&Math.abs(e.x-n.right)<U&&r?"right":void 0}function xt(t,e,n,o){switch(t){case"top":return x(e,n,U)&&n.y<o.top-U;case"bottom":return x(e,n,U)&&n.y>o.bottom+U;case"left":return m(e,n,U)&&n.x<o.left-U;case"right":return m(e,n,U)&&n.x>o.right+U}}function mt(t,e,n){if(t.length<3)return t;if(n){const n=pt(t[0],t[1],e);return n&&xt(n,t[1],t[2],e)?t.slice(1):t}const o=t.length-1,r=pt(t[o-1],t[o],e);return r&&xt(r,t[o-1],t[o-2],e)?t.slice(0,o):t}function yt(t,e,n){let o=t;if(e){const t=nt(o,0,1);if(t){const n=et(t,o[0],e);n!==o[0]&&(o=[n,...o.slice(1)])}o=mt(o,e,!0)}if(n){const t=o.length-1,e=nt(o,t,-1);if(e){const r=et(e,o[t],n,!0);r!==o[t]&&(o=[...o.slice(0,t),r])}o=mt(o,n,!1)}const r=lt(o,e,n);return r!==o||2===o.length?r:(e&&(o=gt(o,e,!0)),n&&(o=gt(o,n,!1)),o)}function bt(t,e){for(const n of t){const t=J(n,e,2);if(!t)continue;const o=yt(v(t.points,U),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 Mt(t){return new Map(t.map(t=>[t.id,t]))}function It(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 St(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 wt(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 vt(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 Ct(t){const e=Mt(t),n=t.filter(t=>t.isGroup&&t.parentId).sort((t,n)=>St(n,e)-St(t,e));for(const o of n){const e=wt(t.filter(t=>t.parentId===o.id));e&&vt(o,e)}}function Lt(t,e){const o=t.nodes??[],r=t.edges??[],s=o.filter(t=>!t.isGroup);let i=1/0,a=-1/0;for(const n of s){const t=n[e];"number"==typeof t&&(i=Math.min(i,t),a=Math.max(a,t))}if(!Number.isFinite(i)||!Number.isFinite(a))return!1;const c=n(t=>i+a-t,"mirror");for(const n of o){const t=n[e];"number"==typeof t&&(n[e]=c(t));const o=n.groupTitleRect;o&&(n.groupTitleRect="x"===e?{...o,left:c(o.right),right:c(o.left)}:{...o,top:c(o.bottom),bottom:c(o.top)})}for(const n of r)for(const t of n.points??[])t[e]=c(t[e]);return!0}function kt(t){return!(t.nodes??[]).some(t=>!t.isGroup)||Lt(t,"y")}function Ot(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 C of r){const t=C.x??0,e=C.y??0;t<s&&(s=t),e<i&&(i=e)}if(!Number.isFinite(s)||!Number.isFinite(i))return!1;const a=36;let c=0,f=0;for(const C of r)c+=C.width??0,f+=C.height??0;const d=c/r.length,l=f/r.length,u=l>0?Math.max(1,d/l):1;for(const C of r){const t=C.x??0,e=((C.y??0)-i)*u+a,n=t-s;C.x=e,C.y=n}for(const C of o)if(C.points)for(const t of C.points){const e=t.x,n=(t.y-i)*u+a,o=e-s;t.x=n,t.y=o}Ct(n);const h=n.filter(t=>t.isGroup&&!t.parentId);if(0===h.length)return"RL"===e&&Lt(t,"x"),!0;const g=Mt(n),p=new Map;for(const C of n){if(C.isGroup)continue;const t=It(C,g);if(!t)continue;const e=p.get(t)??[];e.push(C),p.set(t,e)}let x=0;for(const C of h){const t=C.padding??0;t>x&&(x=t)}const m=[];let y=1/0,b=-1/0;for(const C of h){const t=wt(p.get(C.id)??[]);t&&(y=Math.min(y,t.minX),b=Math.max(b,t.maxX),m.push({lane:C,contentTop:t.minY,contentBottom:t.maxY,centerY:(t.minY+t.maxY)/2}))}if(y===1/0||b===-1/0)return!0;const M=Math.max(0,b-y)+2*Math.max(x,10),I=a+M,S=(y+b)/2-M/2-a,w=S+I/2,v=Math.max(x,a);m.sort((t,e)=>t.centerY-e.centerY);for(let C=0;C<m.length;C++){const t=m[C];let e,n;if(0===C)e=t.contentTop-v;else{e=(m[C-1].contentBottom+t.contentTop)/2}if(C===m.length-1)n=t.contentBottom+v;else{const e=m[C+1];n=(t.contentBottom+e.contentTop)/2}const o=Math.max(0,n-e),r=(e+n)/2;t.lane.x=w,t.lane.y=r,t.lane.width=I,t.lane.height=o,t.lane.swimlaneContentTop=t.contentTop,t.lane.groupTitleRect={left:S,right:S+a,top:e,bottom:n}}return"RL"===e&&Lt(t,"x"),!0}n(J,"endpointContextFor"),n(Z,"segmentEnterPoint"),n(Q,"clipEndpoint"),n(tt,"clipEdgeEndpointsToNodeBoundaries"),n(et,"snapEndpointToBoundary"),n(nt,"firstDistinctAdjacent"),n(ot,"cornerClearanceRange"),n(rt,"clampToCornerClearance"),n(st,"intersectRanges"),n(it,"clearanceRangeForSide"),n(at,"terminalSideForSegment"),n(ct,"isHorizontalSide"),n(ft,"straightClearanceRange"),n(dt,"clearStraightEndpointCornerAxis"),n(lt,"clearStraightEndpointCornerConnections"),n(ut,"cornerClearedEndpoint"),n(ht,"moveCollinearEndpointRun"),n(gt,"clearEndpointCornerConnection"),n(pt,"borderSideForSegment"),n(xt,"leavesOutward"),n(mt,"collapseOwnBorderStub"),n(yt,"snapAndCollapseEndpoints"),n(bt,"prepareEdgeEndpointsForRenderer"),n(Mt,"buildNodeMap"),n(It,"resolveTopLevelGroupId"),n(St,"groupDepth"),n(wt,"boundsForChildren"),n(vt,"applyGroupBounds"),n(Ct,"recomputeNestedGroupBounds"),n(Lt,"mirrorAxis"),n(kt,"applyBtDirectionTransform"),n(Ot,"applyLrDirectionTransform");var Rt=1e-6,Nt=[0,8,-8,16,-16];function Tt(t,e){const{nodeInfoById:n,realNodeRects:o}=Y(e);for(const r of t){if(r.isLayoutOnly)continue;const e=r.points;if(!e||e.length<4)continue;const s=C(v(e,Rt),Rt);if(!s)continue;const{p3:i}=s,a="HVH"===s.kind,c=P(r,n,Rt);if(!c)continue;const{srcId:f,dstId:d,srcInfo:l,dstInfo:u,collinearX:h,collinearY:g}=c;if(h||g)continue;let x;const m=l.rect;for(const n of Nt){let e,s,c;if(a){const t=u.cy>l.cy?m.bottom:m.top,o=l.cx+n;if(o<=m.left+Rt||o>=m.right-Rt)continue;e={x:o,y:t},s={x:o,y:i.y},c={x:i.x,y:i.y}}else{const t=u.cx>l.cx?m.right:m.left,o=l.cy+n;if(o<=m.top+Rt||o>=m.bottom-Rt)continue;e={x:t,y:o},s={x:i.x,y:o},c={x:i.x,y:i.y}}const h=p(e,s,Rt),g=p(s,c,Rt);if(h&&g)continue;if(!h&&G(e,s,o,[f],1))continue;if(!g&&G(s,c,o,[d],1))continue;const y=!h&&H(e,s,t,r,{epsilon:Rt,skipDegenerateOther:!0}),b=!g&&H(s,c,t,r,{epsilon:Rt,skipDegenerateOther:!0});if(!y&&!b){x=h?[s,c]:g?[e,s]:[e,s,c];break}}x&&(r.points=x)}}function Bt(t,e){const o=.001,{realNodeRects:r,labelNodeRects:s}=X(e.values());for(const i of t){if(i.isLayoutOnly)continue;const a=i.points;if(!a||a.length<4)continue;const c=v(a,o);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<o)continue;const M=l.x-u.x,I=l.y-u.y;if(Math.hypot(M,I)<o)continue;const S=y(l,d,o),w=b(l,d,o),C=y(u,l,o),L=b(u,l,o);if(!(S&&L||w&&C))continue;const O=i.end,R=i.start,N=O?e.get(O):void 0;if(!N)continue;const T=N.x??0,F=N.y??0,E=B(N);if(!E)continue;let $,Y;if(L){const t=I<0;$={x:T,y:u.y},Y={x:T,y:t?E.bottom:E.top}}else{const t=M>0;$={x:u.x,y:F},Y={x:t?E.right:E.left,y:F}}if(G($,Y,r,O?[O]:[],-2))continue;if(G($,Y,s,[],-2))continue;if(R){const t=e.get(R),n=t?B(t):void 0;if(n&&k($,n,2))continue}const X=n((t,e)=>`${t.x.toFixed(3)},${t.y.toFixed(3)}|${e.x.toFixed(3)},${e.y.toFixed(3)}`,"ownSegmentKey"),z=new Set;for(let t=0;t<c.length-1;t++)z.add(X(c[t],c[t+1]));const P=n((e,n)=>{for(const r of t){if(r===i)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(!z.has(X(s,i))&&j(e,n,s,i,o))return!0}}return!1},"segmentCrossesOtherEdge");if(P($,Y))continue;if(f-3>=0){const t=c[f-3];if(G(t,$,r,[R,O].filter(t=>Boolean(t)),-2))continue;if(P(t,$))continue}const D=[...c.slice(0,f-2),$,Y];i.points=D;const A=i.labelNodeId;if(A){const t=e.get(A);if(t){const e=t.width??0,n=t.height??0;if(e>0&&n>0){let r,s,i=-1;for(let t=0;t<D.length-1;t++){const a=D[t],c=D[t+1],f=Math.hypot(c.x-a.x,c.y-a.y),d=m(a,c,o),l=x(a,c,o);(d&&f>=e+2||l&&f>=n+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)}}}}}n(Tt,"portSwapToLShape"),n(Bt,"collapseShortTerminalStub");var Ft=.001,Et=n(t=>"string"==typeof t?t.toUpperCase():"","upperCaseDirection"),$t=S,Yt=n((t,e)=>x(t,e,Ft)||m(t,e,Ft),"orthogonallyAligned");function Xt(t,e){const o=n((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"),r=n((t,n)=>{const r=v(t.points??[]);if(r.length<2)return;const s=n?t.start:t.end,i=s?e.get(s):void 0,a=i?B(i):void 0;if(!i||!s||!a)return;const c=n?r[0]:r[r.length-1],f=n?r[1]:r[r.length-2],d=o(i,c);let l=c;return Yt(f,d)&&(l=f),x(d,l,Ft)?{edge:t,edgeId:String(t.id??""),nodeId:s,atStart:n,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}:m(d,l,Ft)?{edge:t,edgeId:String(t.id??""),nodeId:s,atStart:n,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"),s=n((t,e)=>Math.max(0,Math.min(t.max,e.max)-Math.max(t.min,e.min)),"projectedOverlapLength"),i=n((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)&&x(t.boundary,e.boundary,1)}return(Math.abs(t.boundary.y-t.rect.top)<1||Math.abs(t.boundary.y-t.rect.bottom)<1)&&m(t.boundary,e.boundary,1)},"sameTerminalFace"),a=n((t,e)=>{if(t.nodeId!==e.nodeId||t.orientation!==e.orientation)return!1;return s(t,e)>=8&&Math.abs(t.coord-e.coord)<.5},"exactTerminalLaneConflict"),c=n((t,e)=>{if(t.nodeId!==e.nodeId||t.orientation!==e.orientation||"H"!==t.orientation||t.atStart===e.atStart)return!1;const n=s(t,e);if(n<8)return!1;const o=t.rect.bottom-t.rect.top;return!(n<o||n>2*o)&&(i(t,e)&&Math.abs(t.coord-e.coord)<16)},"nearTerminalLaneConflict"),f=n((t,e)=>{const o=v(t.edge.points??[]);if(o.length<2)return;const r="V"===t.orientation?{x:t.boundary.x+e,y:t.boundary.y}:{x:t.boundary.x,y:t.boundary.y+e},s="V"===t.orientation?{x:t.railEnd.x+e,y:t.railEnd.y}:{x:t.railEnd.x,y:t.railEnd.y+e};if(!n(()=>Math.abs(t.boundary.y-t.rect.top)<1||Math.abs(t.boundary.y-t.rect.bottom)<1?m(r,t.boundary,Ft)&&r.x>=t.rect.left+1&&r.x<=t.rect.right-1:(Math.abs(t.boundary.x-t.rect.left)<1||Math.abs(t.boundary.x-t.rect.right)<1)&&(x(r,t.boundary,Ft)&&r.y>=t.rect.top+1&&r.y<=t.rect.bottom-1),"boundaryStaysOnSameFace")())return;if(t.atStart){const e=o.length>1&&p(o[1],t.railEnd,Ft),n=o.slice(e?2:1),i=n[0];if(i&&!Yt(i,s))return;return[r,s,...n]}const i=o.length>1&&p(o[o.length-2],t.railEnd,Ft),a=o.slice(0,i?-2:-1),c=a[a.length-1];return!c||Yt(c,s)?[...a,s,r]:void 0},"shiftedCandidate"),d=n(t=>{const n=t.edge,o=v(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 m(u,h,Ft)&&Math.abs(f-l)<1&&Math.abs(c-d)>1||x(u,h,Ft)&&Math.abs(c-d)<1&&Math.abs(f-l)>1},"laneIsStraightCollinearConnector"),l=[-7,7,-14,14,-21,21];for(let n=0;n<8;n++){const e=t.filter(t=>!t.isLayoutOnly).flatMap(t=>[r(t,!0),r(t,!1)]).filter(t=>Boolean(t));let n=!1;for(let t=0;t<e.length&&!n;t++)for(let o=t+1;o<e.length&&!n;o++){const s=e[t],i=e[o];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 o of l){const s=f(t,o);if(!s)continue;const i=r({...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 zt(t,e){const{realNodeRects:o,labelNodeRects:r}=X(e.values()),s=n((e,n)=>{const s=e.start,i=e.end,a=$t(n);if(a.length!==n.length-1)return!1;const c=[s,i].filter(t=>Boolean(t));for(const t of a){if(G(t.a,t.b,o,c,-2))return!1;if(G(t.a,t.b,r,[],-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 a)for(const n of $t(v(t))){if(I(e,n,.5)>=8)return!1;if(j(e.a,e.b,n.a,n.b,Ft))return!1}}return!0},"candidateIsSafe"),i=n((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=y(n,o)&&b(o,r)&&y(r,s)&&b(s,i)&&x(n,s,Ft)&&x(n,i,Ft)&&x(o,r,Ft)&&(o.x-n.x)*(s.x-r.x)<0,c=b(n,o)&&y(o,r)&&b(r,s)&&y(s,i)&&m(n,s,Ft)&&m(n,i,Ft)&&m(o,r,Ft)&&(o.y-n.y)*(s.y-r.y)<0;if(a||c)return v([...t.slice(0,e+1),i,...t.slice(e+5)]);if(e+5>=t.length)return;const f=t[e+5],d=b(n,o)&&y(o,r)&&b(r,s)&&y(s,i)&&b(i,f)&&x(n,i,Ft)&&x(n,f,Ft)&&x(r,s,Ft)&&(r.x-o.x)*(i.x-s.x)<0,l=y(n,o)&&b(o,r)&&y(r,s)&&b(s,i)&&y(i,f)&&m(n,i,Ft)&&m(n,f,Ft)&&m(r,s,Ft)&&(r.y-o.y)*(i.y-s.y)<0;return d||l?v([...t.slice(0,e+1),f,...t.slice(e+6)]):void 0},"withoutDogleg");for(let n=0;n<8;n++){let e=!1;for(const n of t){if(n.isLayoutOnly)continue;const t=v(n.points??[]);for(let o=0;o<=t.length-5;o++){const r=i(t,o);if(r&&s(n,r)){n.points=r,e=!0;break}}if(e)break}if(!e)return}}function Pt(t,e){const{realNodeRects:o,labelNodeRects:r}=X(e.values()),s=t.filter(t=>!t.isLayoutOnly),i=n((t,e,n)=>v(t===e?n??[]:t.points??[]),"pointsFor"),a=n((t,e)=>{let n=0;for(let o=0;o<s.length;o++){const r=$t(i(s[o],t,e));for(let a=o+1;a<s.length;a++){const o=$t(i(s[a],t,e));for(const t of r)for(const e of o)j(t.a,t.b,e.a,e.b,Ft)&&n++}}return n},"strictCrossingCount"),c=n(t=>{const e=$t(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=n((t,e)=>{const n=[t.start,t.end].filter(t=>Boolean(t));return o.filter(t=>{if(n.includes(t.id))return!1;const o=t.rect;if(e.horizontal){return M(e.a.x,e.b.x,o.left,o.right)>=8&&e.a.y>=o.top-2&&e.a.y<=o.bottom+2}return M(e.a.y,e.b.y,o.top,o.bottom)>=8&&e.a.x>=o.left-2&&e.a.x<=o.right+2})},"blockingRectsFor"),d=n((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=q(v(o));return $t(r).length===r.length-1?r:void 0},"candidateByMovingRail"),l=n((t,e,n)=>{const c=[t.start,t.end].filter(t=>Boolean(t)),f=$t(e);if(f.length!==e.length-1)return!1;for(const s of f){if(G(s.a,s.b,o,c,-2))return!1;if(G(s.a,s.b,r,[],-2))return!1}for(const o of s)if(o!==t)for(const t of f)for(const e of $t(i(o)))if(I(t,e,.5)>=8)return!1;return a(t,e)<=n},"candidateIsSafe");for(let n=0;n<8;n++){const t=a();let e=!1;for(const n of s){const o=i(n),r=c(o);if(!r)continue;const s=f(n,r.segment);if(0===s.length)continue;const a=r.horizontal?[Math.min(...s.map(t=>t.rect.top))-20,Math.max(...s.map(t=>t.rect.bottom))+20]:[Math.min(...s.map(t=>t.rect.left))-20,Math.max(...s.map(t=>t.rect.right))+20];for(const i of a){const s=d(o,r.segment,i);if(s&&l(n,s,t)){n.points=s,e=!0;break}}if(e)break}if(!e)return}}function Gt(t,e,o){const r=n(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"),s=n(t=>{if(!t.isGroup||t.parentId)return;const e=Et(t.direction??o);if("LR"===e||"RL"===e||"BT"===e)return;const n=r(t),s=t.y,i=t.height;if(!n||"number"!=typeof s||"number"!=typeof i||!Number.isFinite(s)||!Number.isFinite(i)||i<=0)return;const a=n.right-n.left,c=n.bottom-n.top;return c<=0||a<c?void 0:{node:t,rect:n}},"topLaneTitleFor"),i=n((t,e)=>{if(!t.horizontal)return!1;const n=t.a.y;return!(n<e.top-Ft||n>e.bottom+Ft)&&M(t.a.x,t.b.x,e.left,e.right)>=8},"horizontalSegmentIntersectsTitle"),a=[...e.values()].map(s).filter(t=>Boolean(t));if(0===a.length)return;let c=0;for(const n of t){if(n.isLayoutOnly)continue;const t=v(n.points??[]);for(const e of $t(t))for(const t of a)i(e,t.rect)&&(c=Math.max(c,t.rect.bottom-e.a.y+4))}if(!(c<=Ft))for(const n of a){const t=n.node.y,e=n.node.height;"number"!=typeof t||"number"!=typeof e||!Number.isFinite(t)||!Number.isFinite(e)||e<=0||(n.node.y=t-c/2,n.node.height=e+c,n.node.groupTitleRect={...n.rect,top:n.rect.top-c,bottom:n.rect.bottom-c})}}function Dt(t,e,o){const r=n(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"),s=n(t=>{if(!t.isGroup||t.parentId)return;if("LR"!==Et(t.direction??o))return;const e=r(t),n=t.x,s=t.width;if(!e||"number"!=typeof n||"number"!=typeof s||!Number.isFinite(n)||!Number.isFinite(s)||s<=0)return;const i=e.right-e.left,a=e.bottom-e.top;return i<=0||a<i?void 0:{node:t,rect:e}},"leftLaneTitleFor"),i=n((t,e)=>{if(!t.vertical)return!1;const n=t.a.x;return!(n<e.left-Ft||n>e.right+Ft)&&M(t.a.y,t.b.y,e.top,e.bottom)>=8},"verticalSegmentIntersectsTitle"),a=n((t,e)=>{if(!t.horizontal)return!1;const n=t.a.y;return!(n<e.top-Ft||n>e.bottom+Ft)&&M(t.a.x,t.b.x,e.left,e.right)>=8},"horizontalSegmentIntersectsTitle"),c=[...e.values()].map(s).filter(t=>Boolean(t));if(0===c.length)return;let f=0;for(const n of t){if(n.isLayoutOnly)continue;const t=v(n.points??[]);for(const e of $t(t))for(const t of c)if(i(e,t.rect))f=Math.max(f,t.rect.right-e.a.x+4);else if(a(e,t.rect)){const n=Math.min(e.a.x,e.b.x);f=Math.max(f,t.rect.right-n+4)}}if(!(f<=Ft))for(const n of c){const t=n.node.x,e=n.node.width;"number"!=typeof t||"number"!=typeof e||!Number.isFinite(t)||!Number.isFinite(e)||e<=0||(n.node.x=t-f/2,n.node.width=e+f,n.node.groupTitleRect={...n.rect,left:n.rect.left-f,right:n.rect.right-f})}}function At(t,e){const{realNodeRects:o}=X(e.values()),r=t.filter(t=>!t.isLayoutOnly),s=n((t,e=new Map)=>v(e.get(t)??t.points??[]),"replacementPointsFor"),i=n((t=new Map)=>{let e=0;for(let n=0;n<r.length;n++){const o=$t(s(r[n],t));for(let i=n+1;i<r.length;i++){const n=$t(s(r[i],t));for(const t of o)for(const o of n)j(t.a,t.b,o.a,o.b,Ft)&&e++}}return e},"crossingCount"),a=n((t=new Map)=>r.reduce((e,n)=>e+w(s(n,t)),0),"totalBends"),c=n(t=>{const e=s(t);if(e.length<4)return;const n=e[e.length-2],o=e[e.length-1];return y(n,o,Ft)||b(n,o,Ft)?{tailStart:n,terminal:o}:void 0},"terminalTailFor"),f=n((t,e)=>{const n=s(t);if(n.length<3)return;const o=n[0],r=n[1];let i;if(y(o,r,Ft))i={x:r.x,y:e.tailStart.y};else{if(!b(o,r,Ft))return;i={x:e.tailStart.x,y:r.y}}const a=q(v([o,r,i,e.tailStart,e.terminal]));return $t(a).length===a.length-1?a:void 0},"candidateWithDestinationTail"),d=n((t,e)=>{const n=[t.start,t.end].filter(t=>Boolean(t));for(const r of $t(e))if(G(r.a,r.b,o,n,-2))return!0;return!1},"pathHasNodeHit"),l=n((t,e,n)=>{for(const o of r)if(o!==t)for(const t of $t(e))for(const e of $t(s(o,n)))if(I(t,e,.5)>=8)return!0;return!1},"pathHasSharedTrack"),u=n((t,e,n)=>!d(t,e)&&!l(t,e,n),"candidateIsSafe"),h=n(()=>{const t=new Map;for(const n of r){const o=n.end;if(!o||!e.has(o))continue;if(s(n).length<4)continue;const r=t.get(o)??[];r.push(n),t.set(o,r)}return t},"edgesByDestination");for(let n=0;n<4;n++){const t=i();if(0===t)return;let e,n=t,o=a();for(const r of h().values())for(let s=0;s<r.length;s++)for(let d=s+1;d<r.length;d++){const l=r[s],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=i(y),M=a(y);b>=t||(b>n||b===n&&M>=o||(e=y,n=b,o=M))}if(!e)return;for(const[r,s]of e)r.points=s}}function Ht(t,e){const{realNodeRects:o,labelNodeRects:r}=X(e.values()),s=t.filter(t=>!t.isLayoutOnly),i=n((t,e=new Map)=>v(e.get(t)??t.points??[]),"replacementPointsFor"),a=n((t=new Map)=>{let e=0;for(let n=0;n<s.length;n++){const o=$t(i(s[n],t));for(let r=n+1;r<s.length;r++){const n=$t(i(s[r],t));for(const t of o)for(const o of n)j(t.a,t.b,o.a,o.b,Ft)&&e++}}return e},"strictCrossingCount"),c=n((t=new Map)=>s.reduce((e,n)=>e+w(i(n,t)),0),"totalBends"),f=n(t=>{const n=t.start,o=t.end,r=n?e.get(n):void 0,s=o?e.get(o):void 0,i=r?B(r):void 0,a=s?B(s):void 0;return i&&a?{src:i,dst:a}:void 0},"endpointRectsFor"),d=n((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-Ft?"left":r>i+Ft?"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-Ft?"top":r>i+Ft?"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=n(()=>{const t=[];for(const e of s){const n=i(e);for(const o of $t(n)){const r=d(e,n,o);r&&t.push(r)}}return t},"collectExternalRails"),u=n((t,e)=>t.edge!==e.edge&&t.axis===e.axis&&t.side===e.side&&M(t.min,t.max,e.min,e.max)>=8,"railsInteract"),h=n(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=n(t=>{const e=[];for(const n of t)e.some(t=>Math.abs(t-n.coord)<Ft)||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=n(t=>{const e=t.map(t=>t.coord),o=g(t),r=[];if(t.length<=6){const s=new Array(o.length).fill(!1),i=[],a=n(()=>{if(i.length!==t.length)for(const[t,e]of o.entries())s[t]||(s[t]=!0,i.push(e),a(),i.pop(),s[t]=!1);else i.some((t,n)=>Math.abs(t-e[n])>=Ft)&&r.push([...i])},"visit");return a(),r}for(let n=0;n<e.length;n++)for(let t=n+1;t<e.length;t++){const o=[...e];[o[n],o[t]]=[o[t],o[n]],r.push(o)}return r},"coordinateAssignmentsFor"),x=n((t,e)=>{const n=new Map;for(const[r,s]of t.entries()){const t=e[r],o=n.get(s.edge)??s.points.map(t=>({x:t.x,y:t.y}));"vertical"===s.axis?(o[s.segmentIndex].x=t,o[s.segmentIndex+1].x=t):(o[s.segmentIndex].y=t,o[s.segmentIndex+1].y=t),n.set(s.edge,o)}const o=new Map;for(const[r,s]of n){const t=q(v(s));if($t(t).length!==t.length-1)return;o.set(r,t)}return o},"replacementsForAssignment"),m=n(t=>{for(const[e,n]of t){const t=[e.start,e.end].filter(t=>Boolean(t));for(const e of $t(n)){if(G(e.a,e.b,o,t,-2))return!1;if(G(e.a,e.b,r,[],-2))return!1}}for(let e=0;e<s.length;e++){const n=s[e],o=t.has(n),r=$t(i(n,t));for(let a=e+1;a<s.length;a++){const e=s[a];if(!o&&!t.has(e))continue;const n=$t(i(e,t));for(const t of r)for(const e of n)if(I(t,e,.5)>=8)return!1}}return!0},"candidateIsSafe");for(let n=0;n<4;n++){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[s,i]of e)s.points=i}}function jt(t,e){const{realNodeRects:o,labelNodeRects:r}=X(e.values()),s=t.filter(t=>!t.isLayoutOnly),i=n((t,e,n)=>v(t===e?n??[]:t.points??[]),"pointsFor"),a=n(t=>$t(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=n((t,e)=>{let n=0;for(let o=0;o<s.length;o++){const r=$t(i(s[o],t,e));for(let a=o+1;a<s.length;a++){const o=$t(i(s[a],t,e));for(const t of r)for(const e of o)j(t.a,t.b,e.a,e.b,Ft)&&n++}}return n},"strictCrossingCount"),f=n((t,e)=>{if(t.horizontal){const n=t.a.y;return(Math.abs(n-e.top)<1||Math.abs(n-e.bottom)<1)&&M(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)&&M(t.a.y,t.b.y,e.top,e.bottom)>=8}return!1},"segmentRunsAlongRectBorder"),d=n(t=>{const n=[t.start,t.end].filter(t=>Boolean(t)),o=[];for(const r of n){const t=e.get(r),n=t?B(t):void 0;n&&o.push(n)}return o},"endpointRectsFor"),l=n((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=y(n,o,Ft)&&b(o,r,Ft)&&y(r,s,Ft),a=b(n,o,Ft)&&y(o,r,Ft)&&b(r,s,Ft);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=x(n,s,Ft)||m(n,s,Ft)?[]:[{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=>q(v(t))).filter(t=>{if($t(t).length!==t.length-1)return!1;if(!t.some(t=>p(t,s,Ft)))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=n((t,e,n)=>{const a=[t.start,t.end].filter(t=>Boolean(t)),l=d(t);for(const s of $t(e)){if(G(s.a,s.b,o,a,-2))return!1;if(G(s.a,s.b,r,[],-2))return!1;if(l.some(t=>f(s,t)))return!1}for(const o of s)if(o!==t)for(const t of $t(e))for(const e of $t(i(o)))if(I(t,e,.5)>=8)return!1;return c(t,e)<=n},"candidateIsSafe");for(let n=0;n<8;n++){const t=c();let e,n,o=t,r=Number.POSITIVE_INFINITY,f=Number.POSITIVE_INFINITY;for(const d of s){const s=i(d),h=w(s,Ft),g=a(s);for(let i=0;i<=s.length-4;i++)for(const p of l(s,i)){const s=w(p,Ft),i=a(p);if(!(s<h||s===h&&i<g-Ft)||!u(d,p,t))continue;const l=c(d,p);l>o||l===o&&(s>r||s===r&&i>=f)||(e=d,n=p,o=l,r=s,f=i)}}if(!e||!n)return;e.points=n}}function Vt(t,e){const o=20,r=[];for(const n of e.values()){if(n.isGroup||n.isEdgeLabel)continue;const t=n.x??0,e=n.y??0,o=B(n);o&&r.push({id:String(n.id??""),cx:t,cy:e,rect:o})}if(0===r.length)return;const s=new Map(r.map(t=>[t.id,t])),i=r.map(t=>({id:t.id,rect:t.rect})),a=["top","bottom","left","right"],c={top:Math.min(...r.map(t=>t.rect.top))-o,bottom:Math.max(...r.map(t=>t.rect.bottom))+o,left:Math.min(...r.map(t=>t.rect.left))-o,right:Math.max(...r.map(t=>t.rect.right))+o},f=t.filter(t=>!t.isLayoutOnly),d=new Map(f.map((t,e)=>[t,e])),l=n(t=>{const e="left"===t||"top"===t?-1:1,n=[];for(let r=0;r<=2;r++)n.push(c[t]+e*o*r);return n},"outwardTracksForSide"),u=n((t,e=new Map)=>v(e.get(t)??t.points??[]),"replacementPointsFor"),h=n((t,e)=>{let n=0;for(const o of t)for(const t of e)j(o.a,o.b,t.a,t.b,Ft)&&n++;return n},"crossingCountBetweenSegments"),g=n((t,e)=>h($t(t),$t(e)),"crossingCountBetweenPaths"),p=n((t=new Map)=>{let e=0;const o=[],r=new Set,s=[],i=n(t=>{r.has(t)||(r.add(t),s.push(t))},"addEdge");for(let n=0;n<f.length;n++){const r=f[n],s=u(r,t);for(let a=n+1;a<f.length;a++){const n=f[a],c=g(s,u(n,t));c>0&&(e+=c,o.push({first:r,second:n,count:c}),i(r),i(n))}}return s.sort((t,e)=>(d.get(t)??0)-(d.get(e)??0)),{count:e,pairs:o,edgeSet:r,edges:s}},"crossingSnapshot"),x=n((t,e)=>{const n=new Set(e.keys());if(0===n.size)return t.count;let o=0;for(const s of t.pairs)(n.has(s.first)||n.has(s.second))&&(o+=s.count);let r=0;for(let s=0;s<f.length;s++){const t=f[s],o=n.has(t),i=u(t,e);for(let a=s+1;a<f.length;a++){const t=f[a];(o||n.has(t))&&(r+=g(i,u(t,e)))}}return t.count-o+r},"crossingCountWithReplacements"),m=n(t=>{const e=new Map;for(const r of t.pairs){const t=e.get(r.first)??new Set;t.add(r.second),e.set(r.first,t);const n=e.get(r.second)??new Set;n.add(r.first),e.set(r.second,n)}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"),M=n(t=>[t.start,t.end].filter(t=>Boolean(t)),"endpointIdsFor"),S=n(t=>{const e=[];for(const n of m(t)){const t=new Set(n),o=new Set(n.flatMap(t=>M(t))),r=[...n];for(const e of f)t.has(e)||M(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"),C=n((t,e,n)=>x(t,new Map([[e,n]])),"crossingCountWithSingleReplacement"),L=n(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"),k=n(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"),O=n((t=new Map)=>f.reduce((e,n)=>e+w(u(n,t)),0),"totalBends"),R=n((t=new Map)=>f.reduce((e,n)=>e+k(u(n,t)),0),"totalLength"),N=n((t,e,n=new Map)=>{const o=$t(e);for(const r of f)if(r!==t)for(const t of o)for(const e of $t(u(r,n)))if(I(t,e,.5)>=8)return!0;return!1},"pathHasSegmentConflict"),T=n((t,e)=>{const n=[t.start,t.end].filter(t=>Boolean(t));for(const o of $t(e))if(G(o.a,o.b,i,n,-2))return!0;return!1},"pathHitsNode"),Y=n((t,e)=>{const n=q(v(e));$t(n).length===n.length-1&&t.push(n)},"pushOrthogonalCandidate"),X=n(t=>"left"===t||"right"===t,"sideIsHorizontal"),z=n((t,e,n)=>{switch(e){case"left":return Math.min(t.x,n.x)-o;case"right":return Math.max(t.x,n.x)+o;case"top":return Math.min(t.y,n.y)-o;case"bottom":return Math.max(t.y,n.y)+o}},"localTrackForSameSide"),P=n((t,e,n,r)=>{const s="left"===n||"top"===n?-1:1,i=[z(e,n,r),c[n]];for(const a of i)for(let i=0;i<=2;i++)Y(t,$(e,n,r,a+s*o*i))},"addSameSideCandidates"),D=n((t,e,n,o,r)=>{for(const s of l(n))for(const n of l(r))Y(t,[e,{x:s,y:e.y},{x:s,y:n},{x:o.x,y:n},o])},"addHorizontalToVerticalCandidates"),A=n((t,e,n,o,r)=>{for(const s of l(n))for(const n of l(r))Y(t,[e,{x:e.x,y:s},{x:n,y:s},{x:n,y:o.y},o])},"addVerticalToHorizontalCandidates"),H=n((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)Y(t,[e,{x:i,y:e.y},{x:i,y:r},{x:n,y:r},{x:n,y:o.y},o])},"addHorizontalPairCandidates"),V=n((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)Y(t,[e,{x:e.x,y:i},{x:r,y:i},{x:r,y:n},{x:o.x,y:n},o])},"addVerticalPairCandidates"),_=n(t=>{const e=new Set;return t.map(t=>v(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"),W=n((t,e,n,r)=>{const s=[],i=E(t,e,n,r,o,Ft);i&&Y(s,i),e===r&&P(s,t,e,n);const a=X(e),c=X(r);return a&&!c?D(s,t,e,n,r):!a&&c?A(s,t,e,n,r):a?H(s,t,e,n,r):V(s,t,e,n,r),_(s)},"buildCandidatesForSides"),K=n((t,e,n,o)=>{const r=[...l("left"),...l("right")],s=[...l("top"),...l("bottom")];for(const i of a){const a=F(o,i),c="top"===i||"bottom"===i?l(i):s;for(const o of r){Y(t,[e,n,{x:o,y:n.y},{x:o,y:a.y},a]);for(const r of c)Y(t,[e,n,{x:o,y:n.y},{x:o,y:r},{x:a.x,y:r},a])}}},"addVerticalDepartureOuterTrackCandidates"),U=n((t,e,n,o)=>{const r=[...l("left"),...l("right")],s=[...l("top"),...l("bottom")];for(const i of a){const a=F(o,i),c="left"===i||"right"===i?l(i):r;for(const o of s){Y(t,[e,n,{x:n.x,y:o},{x:a.x,y:o},a]);for(const r of c)Y(t,[e,n,{x:n.x,y:o},{x:r,y:o},{x:r,y:a.y},a])}}},"addHorizontalDepartureOuterTrackCandidates"),J=n(t=>{const e=t.start,n=t.end,o=n?s.get(n):void 0;if(!e||!o)return[];const r=v(t.points??[]);if(r.length<4)return[];const i=r[0],a=r[1],c=[];return b(i,a,Ft)?K(c,i,a,o):y(i,a,Ft)&&U(c,i,a,o),c},"terminalPreservingOuterTrackCandidates"),Z=n(t=>{const e=t.start,n=t.end,o=e?s.get(e):void 0,r=n?s.get(n):void 0;if(!o||!r)return[];const i=[];for(const s of a){const t=F(o,s);for(const e of a)i.push(...W(t,s,F(r,e),e))}return i.push(...J(t)),i},"candidatePathsFor"),Q=n(()=>new Map(f.map(t=>[t,$t(u(t))])),"currentSegmentsByEdge"),tt=n((t,e,n)=>{const o=new Set;for(const r of f){if(r===t)continue;const s=n.get(r)??$t(u(r));e.some(t=>s.some(e=>I(t,e,.5)>=8))&&o.add(r)}return o},"sharedTrackConflictsFor"),et=n((t,e,n,o)=>{const r=new Set;return Z(t).map(t=>q(v(t))).filter(e=>{if(T(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=$t(r);let i=0;for(const e of f)e!==t&&(i+=h(s,n.get(e)??$t(u(e))));return{candidate:r,candidateSegments:s,crossings:e.count-(o.get(t)??0)+i,bends:w(r,Ft),totalBends:w(r),length:k(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:tt(t,e.candidateSegments,n),totalBends:e.totalBends,length:e.length}))},"pairCandidatesFor"),nt=n((t,e,n,o,r,s)=>{let i=0;for(const c of t.pairs)c.first!==e&&c.second!==e&&c.first!==o&&c.second!==o||(i+=c.count);let a=h(n.segments,r.segments);for(const c of f){if(c===e||c===o)continue;const t=s.get(c)??$t(u(c));a+=h(n.segments,t)+h(r.segments,t)}return t.count-i+a},"pairCrossingCount"),ot=n((t,e)=>{for(const n of t.sharedTrackConflicts)if(n!==e)return!1;return!0},"conflictsOnlyWith"),rt=n((t,e)=>t.segments.some(t=>e.segments.some(e=>I(t,e,.5)>=8)),"candidatesShareTrack"),st=n((t,e,n,o)=>ot(e,n.edge)&&ot(o,t.edge)&&!rt(e,o),"pairCandidatesAreCompatible"),it=n((t,e,n,o,r)=>{const s=nt(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"),at=n((t,e)=>t.crossings<e.crossings||t.crossings===e.crossings&&(t.bends<e.bends||t.bends===e.bends&&t.length<e.length),"pairScoreIsBetter"),ct=n((t,e,n,o)=>{let r=o;for(const s of e.candidates)for(const o of n.candidates){if(!st(e,s,n,o))continue;const i=it(t,e,s,n,o);i&&at(i,r)&&(r=i)}return r},"bestScoreForOptionPair"),ft=n(t=>{const e=O(),n=R(),o=Q(),r=L(t),s=new Map(f.map(t=>[t,w(u(t))])),i=new Map(f.map(t=>[t,k(u(t))])),a=new Map,c=S(t);for(const f of c)for(const e of f){if(a.has(e))continue;const n=et(e,t,o,r);n.length>0&&a.set(e,{edge:e,candidates:n})}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 f of c){const e=new Set(f.filter(e=>t.edgeSet.has(e))),n=f.map(t=>a.get(t)).filter(t=>Boolean(t));for(let t=0;t<n.length;t++){const o=n[t];for(let r=t+1;r<n.length;r++){const t=n[r];(e.has(o.edge)||e.has(t.edge))&&(d=ct(l,o,t,d))}}}return d.replacements.size>0?d.replacements:void 0},"bestPairedReplacement");for(let n=0;n<4;n++){const t=p(),e=t.count;if(0===e)return;let n,o,r=e,s=Number.POSITIVE_INFINITY;for(const a of t.edges){const i=w(u(a),Ft);for(const c of Z(a)){const f=T(a,c),d=!f&&N(a,c),l=C(t,a,c),u=w(c,Ft);if(f||d)continue;(l<e||l===e&&u<i)&&(l>r||l===r&&u>=s||(n=a,o=c,r=l,s=u))}}if(n&&o){n.points=o;continue}const i=ft(t);if(!i)return;for(const[a,c]of i)a.points=c}}n(Xt,"separateSharedRenderedTerminalLanes"),n(zt,"collapseRedundantRectangularDoglegs"),n(Pt,"liftObstacleHuggingSameSideRails"),n(Gt,"liftTopLaneTitleBandsAboveRails"),n(Dt,"shiftLeftLaneTitleBandsLeftOfRails"),n(At,"swapDestinationTerminalTailsToReduceCrossings"),n(Ht,"reassignCrossingExternalRailChannels"),n(jt,"shortcutRedundantOrthogonalJogs"),n(Vt,"resolveRenderedOrthogonalCrossings");var _t=.001;function Wt(t,e){const{nodeInfoById:o,realNodeRects:r}=Y(e),s=["top","bottom","left","right"],i={top:Math.min(...r.map(t=>t.rect.top))-20,bottom:Math.max(...r.map(t=>t.rect.bottom))+20,left:Math.min(...r.map(t=>t.rect.left))-20,right:Math.max(...r.map(t=>t.rect.right))+20},a=n((t,e,n,o)=>{const r=[],s=E(t,e,n,o,20,_t);return s&&r.push(s),e===o&&r.push($(t,e,n,i[e])),r},"buildOrthogonalPathCandidates"),c=n((t,e)=>{for(let n=0;n<t.length-1;n++){if(G(t[n],t[n+1],r,e,1))return!0}return!1},"pathHitsNode"),f=n((e,n,o=!1)=>{let r=0;const s=S(e,_t),i=n.start,a=n.end;for(const c of t){if(c===n||c.isLayoutOnly)continue;const t=c.start,e=c.end;if(!o&&i&&a&&(t===i||t===a||e===i||e===a))continue;const f=c.points;if(f&&!(f.length<2))for(const n of s)for(const t of S(f,_t))(D(n.a,n.b,t.a,t.b,_t,_t)||I(n,t,_t)>=8)&&r++}return r},"pathConflictCount"),d=n((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=n((t,e,n)=>{const o=l.get(t)??[];o.push({side:e,edgeId:n}),l.set(t,o)},"addFaceClaim");for(const n of t){if(n.isLayoutOnly)continue;const t=n.points??[];if(t.length<1)continue;const e=n.id??"",r=n.start,s=n.end;if(r){const n=o.get(r);n&&u(r,d(t[0],n),e)}if(s){const n=o.get(s);n&&u(s,d(t[t.length-1],n),e)}}const h=n((t,e,n)=>l.get(t)?.some(t=>t.edgeId!==n&&t.side===e)??!1,"faceIsClaimed");for(const n of t){if(n.isLayoutOnly)continue;const t=n.points;if(!t||t.length<2)continue;const e=w(t,_t);if(e<4)continue;const r=n.start,i=n.end;if(!r||!i)continue;const g=o.get(r),p=o.get(i);if(!g||!p)continue;const x=n.id??"",m=f(t,n,!0),y=f(t,n);let b,M=m,I=e;for(const o of s){if(h(r,o,x))continue;const t=F(g,o);for(const e of s){if(h(i,e,x))continue;const s=F(p,e);for(const d of a(t,o,s,e)){if(c(d,[r,i]))continue;const t=w(d,_t);if(m>0){const e=f(d,n,!0);if(e>M||e===M&&t>=I)continue;M=e,I=t,b=d;continue}f(d,n)>y||t<I&&(I=t,b=d)}}}if(b){n.points=b;const t=l.get(r);t&&l.set(r,t.filter(t=>t.edgeId!==x));const e=l.get(i);e&&l.set(i,e.filter(t=>t.edgeId!==x)),u(r,d(b[0],g),x),u(i,d(b[b.length-1],p),x)}}}n(Wt,"simplifyDetouredEdges");var Kt=.001;function qt(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)<Kt)){if(Math.abs(a)<=Kt){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)<=Kt){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 Ut(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 Jt(t,e){const n=v(e);return[qt(n,!0),qt(n,!1)].some(e=>e&&R(t,Ut(e)))}function Zt(t,e){const o=[];for(const n of t){if(n.isLayoutOnly)continue;const t=n.points;if(t&&!(t.length<2))for(let e=0;e<t.length-1;e++)o.push({edgeId:n.id,p1:t[e],p2:t[e+1]})}const r=[],s=[];for(const n of e.values()){const t=n.isGroup,e=n.parentId;if(t&&!e){const t=B(n);t&&s.push({id:n.id,rect:t});continue}if(t)continue;if(n.isEdgeLabel)continue;const o=B(n);o&&r.push({nodeId:n.id,rect:o})}const i=n((t,e)=>{const n=N(e,3);for(const{nodeId:o,rect:s}of r)if(o!==t&&R(n,s))return!0;return!1},"labelOverlapsForeignNode"),a=n((t,e)=>{const n=N(e,3);for(const r of o)if(r.edgeId!==t&&L(r.p1,r.p2,n))return!0;return!1},"labelOverlapsForeignEdge"),c=n((t,e,n)=>i(t,n)||a(e,n),"labelOverlapsAnything"),f=[],d=n(t=>{for(const{id:e,rect:n}of s)if(O(n,t))return e},"findContainingLane"),l=n((t,e)=>f.some(n=>n.labelId!==t&&R(e,n.rect)),"overlapsPlacedLabel");for(const u of t){if(u.isLayoutOnly)continue;const t=u.labelNodeId;if(!t)continue;const o=e.get(t);if(!o)continue;const r=u.points;if(!r||r.length<2)continue;const h=o.width??0,g=o.height??0;if(h<=0||g<=0)continue;const p=[];for(let e=0;e<r.length-1;e++){const t=r[e],n=r[e+1],o=Math.abs(t.x-n.x),s=Math.abs(t.y-n.y);o<Kt&&s<Kt||(o>=Kt&&s>=Kt||p.push({idx:e,length:o+s,orientation:o>=Kt?"horizontal":"vertical",midX:(t.x+n.x)/2,midY:(t.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=n(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],I=p[p.length-1],S=[.5,.25,.75,.05,.95,.15,.85,.1,.9],w=n((t,e)=>{const n=r[t.idx],o=r[t.idx+1];return{midX:n.x+(o.x-n.x)*e,midY:n.y+(o.y-n.y)*e}},"anchorAtT"),v=n((t,e,n)=>Math.min(n,Math.max(e,t)),"clamp"),C=n((t,e)=>t.midX>=e.left-Kt&&t.midX<=e.right+Kt&&t.midY>=e.top-Kt&&t.midY<=e.bottom+Kt,"pointInsideRectInclusive"),L=n(t=>{const e=T(t.midX,t.midY,h,g),n=d(e);if(n)return{laneId:n,anchor:t,rect:e};const o=s.find(({rect:e})=>C(t,e));if(!o)return;const r=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(r>i||a>c)return;const f={midX:v(t.midX,r,i),midY:v(t.midY,a,c)},l=T(f.midX,f.midY,h,g);return C(t,l)?{laneId:o.id,anchor:f,rect:l}:void 0},"placementForAnchor"),k=n((t,e,n)=>"horizontal"===t.orientation?Math.abs(e.midX-n.x):Math.abs(e.midY-n.y),"distanceAlongSegment"),O=n((t,e)=>{const n=("horizontal"===t.orientation?h/2:g/2)+12;if(t===M){const o=r[t.idx];if(k(t,e,o)+Kt<n)return!1}if(t===I){const o=r[t.idx+1];if(k(t,e,o)+Kt<n)return!1}return!0},"labelClearsTerminalEndpoints"),R=n(e=>{const n=b(e);for(const o of n)for(const e of S){const n=w(o,e);if(!O(o,n))continue;const s=L(n);if(s&&(!Jt(s.rect,r)&&!l(t,s.rect)&&!c(t,u.id,s.rect)))return{laneId:s.laneId,anchor:s.anchor}}},"tryPool"),N=n((e,n,o=!1)=>{const s=b(e);for(const c of s){const e={midX:c.midX,midY:c.midY};if(n&&!O(c,e))continue;const s=L(e);if(s&&!Jt(s.rect,r)&&!l(t,s.rect)&&!i(t,s.rect)&&(o||!a(u.id,s.rect)))return{laneId:s.laneId,anchor:s.anchor}}},"findLaneContainingFallback"),B=R(m)??(m.length<p.length?R(p):void 0)??N(p,!0)??N(p,!1)??N(p,!1,!0);if(B){o.x=B.anchor.midX,o.y=B.anchor.midY,o.parentId=B.laneId;const e=T(B.anchor.midX,B.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})}}}n(qt,"markerClearanceRectFor"),n(Ut,"normalizeRect"),n(Jt,"labelOverlapsOwnMarker"),n(Zt,"anchorLabelsToPolyline");var Qt=1e-6;function te(t,e){return t<e?`${t}::${e}`:`${e}::${t}`}function ee(t,e){const{nodeInfoById:o,realNodeRects:r}=Y(e),s=new Map;for(const n of e){const t=n.id;n.isGroup||n.isEdgeLabel&&s.set(t,{w:n.width??0,h:n.height??0})}const i=n((e,o,r,i)=>{const a=te(o,r);let c=0;const f=n(t=>{if(!t)return;const e=s.get(t);if(!e)return;const n="x"===i?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&&(te(t,o)===a&&f(n.labelNodeId))}return c>0?c+3:0},"labelClearanceFor");for(const n of t){if(n.isLayoutOnly)continue;if(!C(n.points,Qt))continue;const e=P(n,o,Qt);if(!e)continue;const{srcId:s,dstId:a,srcInfo:c,dstInfo:f,collinearX:d,collinearY:l}=e;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(G(u,h,r,[s,a],1))continue;const g=i(n,s,a,d?"x":"y"),p=g>4?g:4,x=[0,p,-p];for(const o of x){const e={...u},i={...h};if(d){if(e.x+=o,i.x+=o,e.x<=c.rect.left||e.x>=c.rect.right)continue;if(i.x<=f.rect.left||i.x>=f.rect.right)continue}else{if(e.y+=o,i.y+=o,e.y<=c.rect.top||e.y>=c.rect.bottom)continue;if(i.y<=f.rect.top||i.y>=f.rect.bottom)continue}if(!G(e,i,r,[s,a],1)&&!H(e,i,t,n,{epsilon:Qt})){n.points=[e,i];break}}}}function ne(t,e){const o=.001,{realNodeRects:r,labelNodeRects:s}=X(e.values()),i=n((t,e)=>S(e,o).map(n=>({...n,edge:t,interior:n.index>=1&&n.index<=e.length-3})),"segmentsFor"),a=n(()=>{const e=[];for(const n of t){if(n.isLayoutOnly)continue;const t=n.points;!t||t.length<2||e.push(...i(n,v(t)))}return e},"allSegments"),c=n((t,e)=>t.horizontal&&e.horizontal?M(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)&&(M(t.a.y,t.b.y,e.a.y,e.b.y)>=8&&Math.abs(t.a.x-e.a.x)<7),"hasCrowdedParallelTrack"),f=n((e,n)=>{const a=e.start,f=e.end,d=i(e,n);if(d.length!==n.length-1)return!1;const l=[a,f].filter(t=>Boolean(t)),u=e.labelNodeId?[e.labelNodeId]:[];for(const t of d){if(G(t.a,t.b,r,l,-2))return!1;if(G(t.a,t.b,s,u,-2))return!1}for(const r of t){if(r===e||r.isLayoutOnly)continue;const t=r.points;if(t&&!(t.length<2))for(const e of d)for(const n of i(r,v(t))){if(c(e,n))return!1;if(j(e.a,e.b,n.a,n.b,o))return!1}}return!0},"candidateIsSafe"),d=n((t,e)=>{const n=v(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 i(t.edge,o).length===o.length-1?o:void 0},"shiftedCandidate"),l=n((t,e)=>({x:t.x??(e.left+e.right)/2,y:t.y??(e.top+e.bottom)/2}),"nodeCenter"),u=n(t=>{const n=t.edge,o=v(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?B(r):void 0,a=s?B(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=n((t,e,n,r,s,i)=>{const a=r.y>=n.y,c=a?s.bottom:s.top,f=c+(a?20:-20);if(a&&t.b.y<=f+o||!a&&t.b.y>=f-o)return;const d=t.a.x+e;return v([{x:n.x,y:c},{x:n.x,y:f},{x:d,y:f},{x:d,y:t.b.y},...i],o)},"verticalSourceDetour"),g=n((t,e,n,r,s,i)=>{const a=r.x>=n.x,c=a?s.right:s.left,f=c+(a?20:-20);if(a&&t.b.x<=f+o||!a&&t.b.x>=f-o)return;const d=t.a.y+e;return v([{x:c,y:n.y},{x:f,y:n.y},{x:f,y:d},{x:t.b.x,y:d},...i],o)},"horizontalSourceDetour"),p=n((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 n=0;n<12;n++){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 oe(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 re(t){const e=t.nodes??[],n=t.edges??[],r=[];if(!n.length||!e.length)return r;const s=z(e),i=[];for(const o of n){if(o.isLayoutOnly)continue;const t=o.points;if(!t||t.length<2)continue;const e=o.start,n=o.end,a=o.labelNodeId,c=o.id??`${e}->${n}`;for(const o of s)if(o.nodeId!==e&&o.nodeId!==n&&(!a||o.nodeId!==a))for(let e=0;e<t.length-1;e++)if(L(t[e],t[e+1],o,-1)){r.push({type:"edge-node-overlap",edgeId:c,targetId:o.nodeId,detail:`segment ${e} passes through node "${o.nodeId}"`});break}for(let o=0;o<t.length-1;o++)i.push({edgeId:c,start:e,end:n,p1:t[o],p2:t[o+1]})}const a=new Set;for(let o=0;o<i.length;o++)for(let t=o+1;t<i.length;t++){const e=i[o],n=i[t];if(e.edgeId!==n.edgeId&&(e.start!==n.start&&e.start!==n.end&&e.end!==n.start&&e.end!==n.end&&oe(e.p1,e.p2,n.p1,n.p2))){const t=e.edgeId<n.edgeId?`${e.edgeId}|${n.edgeId}`:`${n.edgeId}|${e.edgeId}`;a.has(t)||(a.add(t),r.push({type:"edge-edge-crossing",edgeId:e.edgeId,targetId:n.edgeId,detail:`edges "${e.edgeId}" and "${n.edgeId}" cross`}))}}if(r.length>0){const t=r.filter(t=>"edge-node-overlap"===t.type).length,e=r.filter(t=>"edge-edge-crossing"===t.type).length;o.warn(`[SWIMLANE_VALIDATE] ${r.length} issue(s) detected: ${t} edge-node overlap(s), ${e} edge crossing(s)`);for(const n of r)o.warn(`[SWIMLANE_VALIDATE] ${n.type}: ${n.detail}`)}return r}function se(t,e){const o=t.nodes??[],r=t.edges??[],s=o.filter(t=>!t.isGroup);if(("LR"===e||"RL"===e)&&s.length>0&&!Ot(t,e))return;if("BT"===e&&s.length>0&&!kt(t))return;for(const n of r){if(n.isLayoutOnly)continue;const t=n.points;!t||t.length<2||(n.points=q(K(t)))}Wt(r,o),ee(r,o),Tt(r,o);const i=new Map;for(const n of o)i.set(String(n.id),n);Zt(r,i),tt(r,i),Bt(r,i),ne(r,i),Xt(r,i),zt(r,i),Pt(r,i),At(r,i);const a=n(()=>{Vt(r,i),Xt(r,i),Ht(r,i),jt(r,i),Zt(r,i),bt(r,i),Pt(r,i),Zt(r,i),bt(r,i)},"finalizeRenderedEdges");a(),ne(r,i),a(),Gt(r,i,e),Dt(r,i,e),Gt(r,i,e),Dt(r,i,e)}function ie(t){const e=new Map(t.nodeById),n=new Set,o=[];for(const r of t.edges){if(!e.has(r.src)||!e.has(r.dst))continue;const 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 ae(t,e){return t.edges.filter(t=>t.dst===e)}function ce(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 fe(t){const e=ce(t);for(const n of e.values())n.sort((t,e)=>t.localeCompare(e));return e}function de(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 le(t,e){const o=[...e.entries()].filter(([,t])=>0===t).map(([t])=>t).sort((t,e)=>t.localeCompare(e)),r=new Set(t.edges.flatMap(t=>[t.src,t.dst])),s=n(e=>!r.has(e)&&!t.nodeById.get(e)?.isGroup,"isUnconnected"),i=[...e.keys()].filter(t=>0===e.get(t)&&s(t));let a=0;return o.map(t=>s(t)?i[a++]:t)}function ue(t,e=()=>!0){const n=new Map,o=new Map;for(const r of t.nodes)n.set(r,[]),o.set(r,[]);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 he(t,e,n,o){let r=0;for(const i of t.nodes)o?.skipGroups&&t.nodeById.get(i)?.isGroup||(r=Math.max(r,n[i]??0));const s=Array.from({length:r+1},()=>[]);for(const i of e)o?.skipGroups&&t.nodeById.get(i)?.isGroup||s[Math.max(0,n[i]??0)].push(i);return s}function ge(t){const e=de(t),n=le(t,e),o=[],r=fe(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 pe(t){const e=new Map;let n=0;for(const o of t)e.set(o,n),n++;return e}function xe(t){const e=new Array(t.length),o=n((n,r)=>{if(r-n<=1)return 0;const s=n+r>>1;let i=o(n,s)+o(s,r),a=n,c=s,f=n;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 o=n;o<r;o++)t[o]=e[o];return i},"count");return o(0,t.length)}function me(t){const e=ie(t),o=new Map;for(const n of e.nodes)o.set(n,[]);for(const n of e.edges)o.get(n.src).push(n);for(const n of o.values())n.sort((t,e)=>t.dst===e.dst?t.id.localeCompare(e.id):t.dst.localeCompare(e.dst));const r=Object.create(null);for(const n of e.nodes)r[n]=0;const s=[],i=n(t=>{r[t]=1;for(const e of o.get(t)??[]){const t=e.dst;0===r[t]?i(t):1===r[t]&&s.push(e)}r[t]=2},"dfs"),a=de(e),c=[...e.nodes.filter(t=>0===(a.get(t)??0)),...e.nodes.filter(t=>0!==(a.get(t)??0))];for(const n of c)0===r[n]&&i(n);const f=new Set(s.map(t=>`${t.id}:${t.src}->${t.dst}`)),d=e.edges.map(t=>f.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:d,layout:e.layout,nodeById:new Map(e.nodeById)},reversed:s}}function ye(t){const e=new Map,o=n(n=>{if(e.has(n))return e.get(n);const r=t.nodeById.get(n);if(!r)return e.set(n,null),null;const s=r.parentId;if(!s)return e.set(n,null),null;const i=o(s)??s;return e.set(n,i),i},"resolve");for(const n of t.nodes)o(n);return e}function be(t){const e=ye(t);return t=>e.get(t)??null}function Me(t){const e=[];for(const n of t.layout.nodes??[])n.isGroup&&!n.parentId&&e.push(n.id);return[...new Set(e)].reverse()}function Ie(t,e){const n=Me(t);if(!e||0===e.length)return n;const o=new Set(n),r=new Set,s=[];for(const i of e)o.has(i)&&!r.has(i)&&(r.add(i),s.push(i));for(const i of n)r.has(i)||s.push(i);return s}n(te,"pairKey"),n(ee,"straightenCollinearSiblingDetours"),n(ne,"nudgeSharedInteriorSubpaths"),n(oe,"segmentsIntersect"),n(re,"validateSwimlanesLayout"),n(se,"postProcessSwimlaneLayout"),n(ie,"normalizeGraph"),n(ae,"incoming"),n(ce,"buildSuccessorMap"),n(fe,"buildSortedSuccessorMap"),n(de,"buildInDegreeMap"),n(le,"sortedZeroInDegreeNodes"),n(ue,"buildPredecessorSuccessorMaps"),n(he,"buildLayersFromRanks"),n(ge,"topoSortIfAcyclic"),n(pe,"buildLayerIndex"),n(xe,"countInversions"),n(me,"removeCycles_DFS"),n(ye,"buildTopLaneMap"),n(be,"createTopLaneResolver"),n(Me,"buildTopLaneOrder"),n(Ie,"resolveTopLaneOrder");var Se=8,we=4,ve=!0,Ce=100,Le=40;function ke(t,e){const o=ie(t),r=e?.laneOf??(()=>null),s=e?.rankHint,{preds:i}=ue(o);for(const n of i.values())n.sort((t,e)=>t.localeCompare(e));const a=ge(o)??[...o.nodes].sort((t,e)=>t.localeCompare(e)),c=new Map;for(const[n,S]of a.entries())c.set(S,n);const f=new Map,d=new Map;for(const n of o.nodes)d.set(n,[]);for(const n of a){const t=(i.get(n)??[]).filter(t=>f.has(t));if(t.length>0){const e=Oe(n,t,{laneOf:r,rankHint:s,topoIndex:c});f.set(n,e),d.get(e).push(n)}else f.has(n)||f.set(n,null)}for(const n of o.nodes)f.has(n)||f.set(n,null);const l=new Set;for(const n of o.nodes)null===(f.get(n)??null)&&l.add(n);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=Re(o),g=new Map;for(const[n,S]of h.entries())g.set(n,[...S].sort((t,e)=>t.localeCompare(e)));const p=Ne(g),x=Te(g),m=new Map;for(const n of o.nodes)m.set(n,[]);for(const n of x)for(const t of n.nodes){const e=m.get(t);e?e.push(n.id):m.set(t,[n.id])}const y=[],b=[],M=new Set,I=n(t=>{if(!M.has(t)){M.add(t),y.push(t);for(const e of d.get(t)??[])I(e);b.push(t)}},"walk");for(const n of u)I(n);for(const n of a)I(n);return{parent:f,children:d,roots:u,componentOf:p,blocks:x,nodeBlocks:m,adjacency:g,preorder:y,postorder:b,topologicalOrder:a}}function Oe(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 Re(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 Ne(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 Te(t){const e=new Map,o=new Map,r=[],s=[];let i=0;const a=n((n,c)=>{e.set(n,++i),o.set(n,i);for(const f of t.get(n)??[])f!==c&&(e.has(f)?(e.get(f)??0)<(e.get(n)??0)&&(r.push([n,f]),o.set(n,Math.min(o.get(n)??i,e.get(f)??i))):(r.push([n,f]),a(f,n),o.set(n,Math.min(o.get(n)??i,o.get(f)??i)),(o.get(f)??0)>=(e.get(n)??0)&&s.push(Be(n,f,r,s.length))))},"visit");for(const n of t.keys())e.has(n)||a(n,null);return s}function Be(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 Fe(t,e,o){const r=[...t.nodes],s=new Map;for(const[n,b]of r.entries())s.set(b,n);const i=r.length,a=new Array(i).fill(-1),c=new Array(i).fill(0),f=[],d=new Set;for(const n of r){const t=o.parent.get(n)??null,e=s.get(n);null!=e&&(null==t&&(a[e]=-1,c[e]=0,d.has(n)||(d.add(n),f.push(n))))}for(;f.length>0;){const t=f.shift(),e=s.get(t);if(null==e)continue;const n=o.children.get(t)??[];for(const o of n){if(d.has(o))continue;const t=s.get(o);null!=t&&(a[t]=e,c[t]=c[e]+1,d.add(o),f.push(o))}}for(const n of r){if(d.has(n))continue;const t=s.get(n);null!=t&&(a[t]=-1,c[t]=0,d.add(n))}const l=Math.max(1,Math.ceil(Math.log2(Math.max(1,i)))+1),u=Array.from({length:l},()=>new Array(i).fill(-1));for(let n=0;n<i;n++)u[0][n]=a[n];for(let n=1;n<l;n++)for(let t=0;t<i;t++){const e=u[n-1][t];u[n][t]=-1===e?-1:u[n-1][e]}const h=n((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 o=0;o<l;o++)if(n>>o&1&&-1===(t=u[o][t]))return-1;if(t===e)return t;for(let o=l-1;o>=0;o--){const n=u[o][t],r=u[o][e];-1!==n&&-1!==r&&(n!==r&&(t=n,e=r))}return u[0][t]},"lcaIndex"),g=Array.from({length:i},()=>new Map);for(const n of t.edges){let t=n.src,o=n.dst,r=e[t],i=e[o];if(null==r||null==i)continue;if(r>i&&([t,o]=[o,t],[r,i]=[i,r]),null==r||null==i||r===i)continue;const a=s.get(t),c=s.get(o);if(null==a||null==c)continue;const f=h(a,c);if(-1===f)continue;const d=g[f];for(let e=r;e<i;e++)d.set(e,(d.get(e)??0)+1)}const p=new Map,x=n((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=n(t=>{const n=s.get(t);m.add(t);const r=null==n?void 0:g[n],i=r?new Map(r):new Map,a=o.children.get(t)??[];for(const o of a){const n=y(o),r=e[t];if(null!=r){let s=p.get(t);s||(s=new Map,p.set(t,s));let i=n.get(r)??0;const a=e[o];null!=a&&a>r&&(i+=1),s.set(o,i)}x(i,n)}return i},"dfs");for(const n of o.roots)m.has(n)||y(n);for(const n of r)m.has(n)||y(n);return p}function Ee(t,e,o){const r=new Map,s=n(t=>{let n=o[t]??0;const i=[...e.get(t)??[]];i.sort($e(o));for(const e of i){s(e);const t=r.get(e);null!=t&&(n=Math.min(n,t))}r.set(t,n)},"annotate");for(const n of t)s(n);return r}function $e(t){return(e,n)=>{const o=t[e]??0,r=t[n]??0;return o===r?e.localeCompare(n):o-r}}function Ye(t,e,o,r){let s=0;for(const n of e){const t=o[n]??0;t>s&&(s=t)}const i=Array.from({length:s+1},()=>[]),a=new Set,c=n(t=>{if(a.has(t))return;a.add(t);const e=o[t]??0;i[e]||(i[e]=[]),i[e].push(t);for(const n of r(t))c(n)},"emit");for(const n of t)c(n);for(const n of e)if(!a.has(n)){const t=o[n]??0;i[t]||(i[t]=[]),i[t].push(n),a.add(n)}return i}function Xe(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 ze(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 Pe(t,e,n){const o=ke(t,{rankHint:e,laneOf:n}),{children:r,roots:s}=o;for(const d of t.nodes)r.has(d)||r.set(d,[]);const i=Fe(t,e,o),a=[...s].sort($e(e)),c=ze(r,e,i,Ee(a,r,e));let f=Ye(a,t.nodes,e,c);return f=Xe(f),f}function Ge(t,e,n){const o=new Set(t),r=new Set(e),s=pe(e),i=[];for(const a of n)o.has(a.src)&&r.has(a.dst)&&i.push(s.get(a.dst));return xe(i)}function De(t,e,n){const o=[];for(const s of e){const t=n[s.src],e=n[s.dst];if(null==t||null==e||t===e)continue;let r=s.src,i=s.dst,a=t,c=e;t>e&&(r=s.dst,i=s.src,a=e,c=t);for(let n=a;n<c;n++)o.push({id:`${s.id}@${n}`,src:r,dst:i,ref:s.ref})}let r=0;for(let s=0;s+1<t.length;s++)r+=Ge(t[s],t[s+1],o);return r}function Ae(t,e){const n={...e},{preds:o}=ue(t),r=be(t);let s=De(Pe(t,n,r),t.edges,n);const i=we;for(let a=0;a<i;a++){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=De(Pe(t,n,r),t.edges,n);d<s?(s=d,e=!0):n[a]=f}if(!e)break}return n}function He(t,e){const n=be(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 je(t,e){const n=ie(t),o=ge(n)??[...n.nodes].sort(),r=e?.compactSingleInput??!1,s=be(n);let i=Object.create(null);for(const a of o){const t=ae(n,a),o=e?.ignoreCrossLaneEdges?t.filter(t=>{const e=s(t.src),n=s(a);return!e||!n||e===n}):t;if(0===o.length)i[a]=0;else if(r&&1===o.length){const t=o[0].src,e=s(t),n=s(a);i[a]=e!==n?i[t]??0:(i[t]??0)+1}else{let t=-1/0;for(const e of o)t=Math.max(t,(i[e.src]??0)+1);i[a]=t===-1/0?0:t}}e?.optimizeRanksByCrossings&&(i=Ae(n,i)),e?.ignoreCrossLaneEdges&&He(n,i);return{layers:Pe(n,i,s),rankOf:i,dummy:new Set}}function Ve(t,e){const o=ie(t),r={...je(o,{compactSingleInput:e?.compactSingleInput,ignoreCrossLaneEdges:e?.ignoreCrossLaneEdges,optimizeRanksByCrossings:e?.optimizeRanksByCrossings}).rankOf},s=be(o),{preds:i,succs:a}=ue(o,t=>{if(e?.ignoreCrossLaneEdges){const e=s(t.src),n=s(t.dst);if(e&&n&&e!==n)return!1}return!0}),c=ge(o)??[...o.nodes],f=[...c].reverse(),d=n((t,e)=>{let n=0;for(const a of i.get(t)??[])n=Math.max(n,(r[a]??0)+1);let o=Number.POSITIVE_INFINITY;const s=a.get(t)??[];return s.length>0&&(o=Math.min(...s.map(t=>(r[t]??0)-1))),Number.isFinite(o)||(o=Math.max(n,e)),Math.min(Math.max(e,n),o)},"clampFeasible"),l=Se,u=n(t=>{let e=!1;for(const n of t){const t=i.get(n)??[],o=a.get(n)??[];if(0===t.length&&0===o.length)continue;const s=t.length>0?t.reduce((t,e)=>t+(r[e]??0)+1,0)/t.length:r[n]??0,c=o.length>0?o.reduce((t,e)=>t+(r[e]??0)-1,0)/o.length:r[n]??0,f=Math.round((s+c)/2),l=d(n,f);l!==r[n]&&(r[n]=l,e=!0)}return e},"relaxOrder");for(let n=0;n<l;n++){const t=u(c),e=u(f);if(!t&&!e)break}for(const n of c){let t=0;for(const e of i.get(n)??[])t=Math.max(t,(r[e]??0)+1);(r[n]??0)<t&&(r[n]=t)}for(const n of f){const t=a.get(n)??[];if(t.length>0){const e=Math.min(...t.map(t=>(r[t]??0)-1));(r[n]??0)>e&&(r[n]=e)}}return{layers:he(o,c,r),rankOf:r,dummy:new Set}}function _e(t){const e=de(t),n=fe(t);let o=le(t,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 We(t,e){const o=ie(t),r="LR"===e?.direction?_e(o)??[...o.nodes].sort():ge(o)??[...o.nodes].sort(),s=be(o),i=n(t=>s(t)??t,"laneOf"),a=Object.create(null),c=new Map,f=n((t,n)=>e?.ignoreCrossLaneEdges??!0?i(t)===i(n)?1:0:1,"edgeWeight");for(const n of r){const t=o.nodeById.get(n);if(t?.isGroup)continue;const e=ae(o,n);let r=0;if(e.length>0)for(const o of e){const t=o.src,e=a[t]??0;r=Math.max(r,e+f(t,n))}const s=i(n),d=c.get(s)??0,l=Math.max(r,d);a[n]=l,c.set(s,l+1)}return{layers:he(o,r,a,{skipGroups:!0}),rankOf:a,dummy:new Set}}function Ke(t,e){const o=ie(e),{rankOf:r}=t,s=t.layers.map(t=>[...t]),i=new Set(t.dummy?[...t.dummy]:[]);let a=0;const c=new Map(o.nodeById),f=n(t=>{const e="placeholder-"+a++,n={id:e,isGroup:!1,isDummy:!0,width:0,height:0};for(c.set(e,n),i.add(e);s.length<=t;)s.push([]);return s[t].push(e),r[e]=t,e},"addDummyAt"),d=[...o.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 n of d){const t=r[n.src]??0,e=r[n.dst]??0;if(e-t<=1){l.push(n);continue}let o=n.src;for(let r=t+1,i=0;r<e;r++,i++){const t=f(r);l.push({id:`${n.id}#${i}`,src:o,dst:t,weight:n.weight,ref:n.ref}),o=t}const s=e-t-2;l.push({id:`${n.id}#${Math.max(s+1,0)}`,src:o,dst:n.dst,weight:n.weight,ref:n.ref})}const u={nodes:[...o.nodes,...[...i].filter(t=>!o.nodes.includes(t))],edges:l,layout:o.layout,nodeById:c};return{layering:{layers:s,rankOf:r,dummy:i},graphWithDummies:u}}function qe(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 Ue(t){if(0===t.length)return Number.POSITIVE_INFINITY;return t.reduce((t,e)=>t+e,0)/t.length}function Je(t,e,n,o){const r=new Map;for(const s of t)r.set(s,[]);for(const s of n)"down"===o?e.has(s.src)&&r.has(s.dst)&&r.get(s.dst).push(e.get(s.src)):e.has(s.dst)&&r.has(s.src)&&r.get(s.src).push(e.get(s.dst));return r}function Ze(t,e,n){const o=n.get(t)??0,r=n.get(e)??0;return o!==r?o-r:t.localeCompare(e)}function Qe(t,e,n){const o=new Set(t),r=new Set(e),s=pe(t),i=pe(e),a=[];for(const c of n)o.has(c.src)&&r.has(c.dst)&&a.push({u:s.get(c.src),v:i.get(c.dst)});a.sort((t,e)=>t.u===e.u?t.v-e.v:t.u-e.u);return xe(a.map(t=>t.v))}function tn(t,e,n){return[...t].sort((t,o)=>{const r=qe(e.get(t)??[]),s=qe(e.get(o)??[]);return r===s?Ze(t,o,n):isFinite(r)?isFinite(s)?r-s:-1:1})}function en(t,e,n,o,r,s){const i=pe(t),a=pe(e),c=Je(e,i,n,o);if(!r||!s||0===s.length)return tn(e,c,a);const f=new Map;for(const u of e){const t=r(u),e=f.get(t)??[];e.push(u),f.set(t,e)}const d=[];for(const u of s){const t=f.get(u);if(!t||0===t.length)continue;const e=tn(t,c,a);d.push(...e)}const l=f.get(null);if(l&&l.length>0){const t=tn(l,c,a);for(const e of t){const t=Ue(c.get(e)??[]);let n=d.length;if(isFinite(t))for(const[e,o]of d.entries()){if(t<Ue(c.get(o)??[])){n=e;break}}d.splice(n,0,e)}}return d}function nn(t,e,o,r,s){const i=[...e],a=new Set(t),c=new Set(e),f=r?new Set(r):null,d=o.filter(t=>a.has(t.src)&&c.has(t.dst)),l=f?o.filter(t=>c.has(t.src)&&f.has(t.dst)):void 0,u=n(e=>{let n=Qe(t,e,d);return l&&r&&(n+=Qe(e,r,l)),n},"crossingScore"),h=s?new Map:null;if(s&&h)for(const n of e)h.set(n,s(n));let g=!0,p=u(i);for(;g;){g=!1;for(let t=0;t+1<i.length;t++){if(h){if(h.get(i[t])!==h.get(i[t+1]))continue}const e=p;[i[t],i[t+1]]=[i[t+1],i[t]];const n=u(i);n<e?(p=n,g=!0):[i[t],i[t+1]]=[i[t+1],i[t]]}}return i}function on(t,e,n){const o=t.layers.map(t=>[...t]),r=e.edges,s=be(e),i=Ie(e,n?.laneOrder);for(let a=0;a<3;a++){for(let t=1;t<o.length;t++)o[t]=en(o[t-1],o[t],r,"down",s,i),o[t]=nn(o[t-1],o[t],r,o[t+1],s);for(let t=o.length-2;t>=0;t--)o[t]=en(o[t+1],o[t],r,"up",s,i),o[t]=nn(o[t+1],o[t],r,o[t-1],s)}return{layers:o}}function rn(t,e,o){const r=o?.layerGap??Ce,s=o?.nodeGap??Le,i=o?.laneGap??2*s,a=o?.direction??"TB",c="LR"===a||"RL"===a,f=t.layers,d=Object.create(null),l=Object.create(null),u=n(t=>e.nodeById.get(t),"getNode"),h=n(t=>u(t)?.width??0,"getWidth"),g=n(t=>u(t)?.height??0,"getHeight"),p=be(e),x=Ie(e,o?.laneOrder),m=f.map(t=>t.reduce((t,e)=>Math.max(t,g(e)),0)),y=[];if(c)for(let n=0;n+1<f.length;n++){const t=f[n].reduce((t,e)=>Math.max(t,h(e)),0),e=f[n+1].reduce((t,e)=>Math.max(t,h(e)),0),o=m[n]/2+m[n+1]/2,s=(t+e)/2,i=Math.max(0,s-o-r);y.push(i)}const b=new Set;for(const n of f)for(const t of n)b.add(p(t));const M=b.has(null),I=x.filter(t=>b.has(t)),S=[...M?[null]:[],...I],w=Object.create(null);for(const n of I)w[n]=0;M&&(w.null=0);for(const n of f){const t=Object.create(null),e=[];for(const o of n){const n=p(o);null===n?e.push(o):(t[n]||=[]).push(o)}for(const[n,o]of Object.entries(t)){const t=o.reduce((t,e)=>t+h(e),0)+s*Math.max(0,o.length-1);w[n]=Math.max(w[n]??0,t)}if(M&&e.length){const t=e.reduce((t,e)=>t+h(e),0)+s*Math.max(0,e.length-1);w.null=Math.max(w.null??0,t)}}const v=new Map;{const t=S.map(t=>(null===t?w.null:w[t])??0);let e=-(t.reduce((t,e)=>t+e,0)+i*Math.max(0,S.length-1))/2;for(let n=0;n<S.length;n++){const o=S[n],r=t[n]??0,s=e+r/2;v.set(o,s),e+=r,n<S.length-1&&(e+=i)}}let C=0;for(const[n,k]of f.entries()){const t=m[n]??0,e=new Map;for(const n of k){const t=p(n),o=e.get(t)??[];o.push(n),e.set(t,o)}for(const n of S){const o=e.get(n)??[];if(0===o.length)continue;const r=v.get(n);if(1===o.length){const e=o[0];d[e]=r,l[e]=C+t/2}else{const e=o.map(t=>h(t));let n=r-(e.reduce((t,e)=>t+e,0)+s*(o.length-1))/2;for(const[r,i]of o.entries()){const o=e[r];d[i]=n+o/2,l[i]=C+t/2,n+=o+s}}}C+=t+r+(y[n]??0)}const L=new Map;for(const n of e.edges){const t=n.ref.id;L.has(t)||L.set(t,[]),L.get(t).push(n)}for(const[,n]of L){if(0===n.length)continue;const t=n[0].ref,o=t.start,r=t.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 n)i.add(e.src),i.add(e.dst);for(const n of i){if(n===o||n===r)continue;const t=e.nodeById.get(n);t?.isDummy&&(d[n]=s)}}return{x:d,y:l}}n(ke,"buildDrivingTree"),n(Oe,"chooseParent"),n(Re,"buildAdjacency"),n(Ne,"assignComponents"),n(Te,"computeBlocks"),n(Be,"popBlock"),n(Fe,"computeSubtreeCrossCounts"),n(Ee,"annotateMinimumLayers"),n($e,"compareByRankThenId"),n(Ye,"emitNodesInTreeOrder"),n(Xe,"deduplicateLayers"),n(ze,"createChildOrderer"),n(Pe,"buildMultitreeLayerOrder"),n(Ge,"countCrossingsBetweenAdjacent"),n(De,"totalCrossings"),n(Ae,"optimizeRanksByCrossings"),n(He,"adjustCrossLaneSources"),n(je,"assignLayers_LongestPath"),n(Ve,"assignLayers_Gravity"),n(_e,"topoSortByGenerationIfAcyclic"),n(We,"assignLayers_LaneAwareCompact"),n(Ke,"makeProperLayering"),n(qe,"median"),n(Ue,"barycenter"),n(Je,"neighborPositionsFor"),n(Ze,"currentOrderTieBreak"),n(Qe,"countCrossingsBetweenAdjacent"),n(tn,"sortByHeuristic"),n(en,"reorderLayer"),n(nn,"transposeImprove"),n(on,"orderLayers"),n(rn,"assignCoordinates");function sn(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 an(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 cn(t,e){const n=[...t],o=an(e);for(let r=n.length-1;r>0;r--){const t=Math.floor(o()*(r+1));[n[r],n[t]]=[n[t],n[r]]}return n}function fn(t,e){let n=0;for(const[o,r]of t.entries())n+=Math.abs(o-(e.get(r)??o));return n}function dn(t,e){const n=new Map;for(const[r,s]of t.entries())n.set(s,r);let o=0;for(const{a:r,b:s,weight:i}of e){const t=n.get(r),e=n.get(s);null!=t&&null!=e&&(o+=i*Math.abs(t-e))}return o}function ln(t){const e=Me(t);if(e.length<2)return[];const n=new Map(e.map((t,e)=>[t,e])),o=be(t),r=new Map;for(const s of t.layout.edges??[]){if(s.isLayoutOnly)continue;const e="string"==typeof s.start?s.start:void 0,i="string"==typeof s.end?s.end:void 0;if(!(e&&i&&t.nodeById.has(e)&&t.nodeById.has(i)))continue;const a=o(e),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 un(t,e,n){const o=[...t];let r=dn(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=dn(o,e);n<r?(r=n,s=!0):[o[t],o[t+1]]=[o[t+1],o[t]]}}return{order:o,cost:r,sourceDistance:fn(o,n)}}function hn(t,e){return t.cost!==e.cost?t.cost<e.cost:t.sourceDistance<e.sourceDistance}function gn(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 sn(`${t.join("|")}#${o}#${n}`)}function pn(t,e={}){const n=Me(t);if(n.length<2)return n;const o=ln(t);if(0===o.length)return n;const r=new Map(n.map((t,e)=>[t,e]));let s=un(n,o,r);const i=Math.max(0,e.restarts??8);for(let a=0;a<i;a++){const t=un(cn(n,gn(n,o,a)),o,r);hn(t,s)&&(s=t)}return s.order}function xn(t,e){const n=e?.ignoreCrossLaneEdges??!0,o=e?.optimizeRanksByCrossings??!0,r=ie(t),s=e?.automaticLaneOrdering?pn(r,{restarts:8}):void 0,i=me(r),a=i.acyclic,c=n?We(a,{compactSingleInput:e?.compactSingleInput??ve,ignoreCrossLaneEdges:!0,direction:e?.direction}):Ve(a,{compactSingleInput:e?.compactSingleInput??ve,ignoreCrossLaneEdges:!1,optimizeRanksByCrossings:o}),{layering:f,graphWithDummies:d}=Ke(c,a),l=on(f,d,{laneOrder:s}),u=rn(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}}n(sn,"hashString"),n(an,"mulberry32"),n(cn,"deterministicShuffle"),n(fn,"sourceDistance"),n(dn,"laneArrangementCost"),n(ln,"buildWeightedLaneEdges"),n(un,"greedySwitch"),n(hn,"isBetterCandidate"),n(gn,"seedForRestart"),n(pn,"optimizeTopLaneOrder"),n(xn,"sugiyamaLayout");var mn=1e-6,yn=15,bn=15,Mn=20;function In(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<mn&&c<mn)return n;return c>mn&&3*c>=a?i>0?"bottom":"top":a>mn?s>0?"right":"left":n}function Sn(t,e){return Math.abs(t.to-e.from)<mn||Math.abs(t.to-e.to)<mn?t.to:t.from}function wn(t,e){return"vertical"===t.orient?{x:t.coord,y:e}:{x:e,y:t.coord}}function vn(t,e){const o=t.nodes??[],r=t.edges??[],s=[];for(const n of r)n.isLayoutOnly||s.push({...n,__originalEdge:n});const i=new Map,a=new Map,c=[],f="LR"===e;for(const n of o)i.set(n.id,n);const d=o.filter(t=>t.isGroup&&!t.parentId);for(const nt of d){const t={id:nt.id},e=n(n=>{a.set(n.id,t),o.filter(t=>t.parentId===n.id).forEach(e)},"assignLane");e(nt)}const l=o.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=n((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=n((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=n((t,e,n)=>h(t,In(t,e,n?"bottom":"top")),"getOrthogonalPort"),p=[],x=[],m=new Set,y=n((t,e,n)=>{if(0===p.length)return 0;const o=Math.abs(e.y-n.y)<mn,r=Math.abs(e.x-n.x)<mn;if(!o&&!r)return 0;let s=0;if(o){const o=e.y,r=Math.min(e.x,n.x)-mn,i=Math.max(e.x,n.x)+mn;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-mn<=o&&e.to+mn>=o&&(s+=1e3))}else if(r){const o=e.x,r=Math.min(e.y,n.y)-mn,i=Math.max(e.y,n.y)+mn;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-mn<=o&&e.to+mn>=o&&(s+=1e3))}return s},"crossingPenalty"),b=s.map((t,e)=>{if(!t.start||!t.end)return{idx:e,crossLane:0,dx:0,dy:0};const n=i.get(t.start),o=i.get(t.end),r=a.get(t.start),s=a.get(t.end);return{idx:e,crossLane:r&&s&&r.id!==s.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=n((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)>mn?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"),I=new Map,S=new Map;for(const n of s)n.start&&n.end&&n.start!==n.end&&(S.set(n.start,(S.get(n.start)??0)+1),S.set(n.end,(S.get(n.end)??0)+1));const w=n((t,e)=>In(t,e,"bottom"),"determineSide"),v=new Map;for(const[n,nt]of s.entries()){if(!nt.start||!nt.end||nt.start===nt.end)continue;if(nt.points&&nt.points.length>0)continue;const t=i.get(nt.start),e=i.get(nt.end);if(!t||!e)continue;const o=(e.x??0)-(t.x??0),r=(e.y??0)-(t.y??0);v.set(n,{edgeIdx:n,srcId:nt.start,dstId:nt.end,srcSide:w(t,{x:e.x??0,y:e.y??0}),dstSide:w(e,{x:t.x??0,y:t.y??0}),absDx:Math.abs(o),absDy:Math.abs(r),dxSign:Math.sign(o),dySign:Math.sign(r)})}const C=n(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"),L=n(t=>"top"===t.srcSide||"bottom"===t.srcSide?t.dxSign>=0?"right":"left":t.dySign>=0?"bottom":"top","secondarySide"),k=new Map;for(const n of v.values()){const t=`${n.srcId}:${n.srcSide}`;k.has(t)||k.set(t,[]),k.get(t).push(n)}const O=new Map,R=n((t,e)=>`${t}:${e}`,"loadKey");for(const n of v.values())O.set(R(n.srcId,n.srcSide),(O.get(R(n.srcId,n.srcSide))??0)+1),O.set(R(n.dstId,n.dstSide),(O.get(R(n.dstId,n.dstSide))??0)+1);for(const n of k.values())if(!(n.length<2)){n.sort((t,e)=>{const n=C(t),o=C(e);return Math.abs(n-o)>1e-9?o-n:t.edgeIdx-e.edgeIdx});for(let t=1;t<n.length;t++){const e=n[t],o=L(e),r=O.get(R(e.srcId,e.srcSide))??0,s=O.get(R(e.srcId,o))??0;s>=r||(O.set(R(e.srcId,e.srcSide),r-1),O.set(R(e.srcId,o),s+1),e.srcSide=o)}}const N=n(t=>{const e=t?.shape;return"question"===e||"diamond"===e},"isDiamondNode"),T=new Map;for(const n of v.values())T.has(n.dstId)||T.set(n.dstId,new Set),T.get(n.dstId).add(n.dstSide);for(const n of v.values()){if(!N(i.get(n.srcId)))continue;const t=T.get(n.srcId);if(!t?.has(n.srcSide))continue;const e=L(n);if(t.has(e)||(O.get(R(n.srcId,e))??0)>0)continue;const o=O.get(R(n.srcId,n.srcSide))??0;O.set(R(n.srcId,n.srcSide),Math.max(0,o-1)),O.set(R(n.srcId,e),1),n.srcSide=e}for(const n of v.values()){const{edgeIdx:t,srcId:e,dstId:o,srcSide:r,dstSide:s}=n,a=i.get(e),c=i.get(o),f=`${e}:${r}:src`,d="top"===r||"bottom"===r?c.x??0:c.y??0;I.has(f)||I.set(f,[]),I.get(f).push({edgeIdx:t,oppositeCoord:d});const l=`${o}:${s}:dst`,u="top"===s||"bottom"===s?a.x??0:a.y??0;I.has(l)||I.set(l,[]),I.get(l).push({edgeIdx:t,oppositeCoord:u})}const B=new Map;for(const[n,nt]of I){if(nt.length<2)continue;nt.sort((t,e)=>t.oppositeCoord-e.oppositeCoord);const t=n.split(":"),e=t.slice(0,-2).join(":"),o=t[t.length-2],r=t[t.length-1],s=i.get(e);if(!s)continue;const a="left"===o||"right"===o?s.height??10:s.width??10,c=s.shape,f="question"===c||"diamond"===c?.3*a:a,d=20,l=Math.min(d,Math.max(8,f/(nt.length+1))),u=-(l*(nt.length-1))/2;for(const[n,i]of nt.entries()){const t=u+n*l,e=`${i.edgeIdx}:${r}`;B.set(e,t)}}const F=n(t=>Boolean(s[t]?.labelNodeId),"edgeHasLabelNode"),E=n((t,e)=>!!t&&((I.get(`${t}:${e}:src`)??[]).some(({edgeIdx:t})=>F(t))||(I.get(`${t}:${e}:dst`)??[]).some(({edgeIdx:t})=>F(t))),"faceHasLabelNode"),$=n((t,e,n)=>"top"===e||"bottom"===e?{x:t.x+n,y:t.y}:{x:t.x,y:t.y+n},"applyPortOffset"),Y=n((t,e,n)=>{const o=v.get(t),r={x:n.x??0,y:n.y??0},s={x:e.x??0,y:e.y??0},i=o?.srcSide??w(e,r),a=o?.dstSide??w(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=B.get(`${t}:src`),l=B.get(`${t}:dst`);return void 0!==d&&(c=$(c,i,d)),void 0!==l&&(f=$(f,a,l)),{pSrcPort:c,pDstPort:f,srcSide:i,dstSide:a}},"portsForEdge");for(const nt of b){const t=s[nt];if(x[nt]=[],!t.start||!t.end)continue;if(t.points&&t.points.length>0)continue;if(t.start===t.end)continue;const e=i.get(t.start),o=i.get(t.end);if(!e||!o)continue;const{pSrcPort:r,pDstPort:a,srcSide:d,dstSide:h}=Y(nt,e,o),g={...r},b={...a},w="top"===d||"bottom"===d,v="top"===h||"bottom"===h;if(w){const t=r.y>(e.y??0);g.y=t?r.y+Mn:r.y-Mn}else{const t=r.x>(e.x??0);g.x=t?r.x+Mn:r.x-Mn}if(v){const t=a.y>(o.y??0);b.y=t?a.y+Mn:a.y-Mn}else{const t=a.x>(o.x??0);b.x=t?a.x+Mn:a.x-Mn}const C=n((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=n((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+bn:o.minY-bn,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+bn:o.minY-bn,leavesPositiveSide:s}},"obstacleDetour");let k=[];const O=[t.start,t.end],R=C(g,O);if(R.inside&&R.obstacle){const t=R.obstacle;if(w){const n=L(r,e,o,t,!0);g.x=n.x,g.y=n.y;const s=n.leavesPositiveSide?Math.min(t.minY-2,r.y+Mn):Math.max(t.maxY+2,r.y-Mn);k=[{x:r.x,y:s},{x:n.x,y:s},{x:n.x,y:n.y}]}else{const n=L(r,e,o,t,!1),s=n.leavesPositiveSide?Math.min(t.minX-2,r.x+Mn):Math.max(t.maxX+2,r.x-Mn);g.x=n.x,g.y=n.y,k=[{x:s,y:r.y},{x:s,y:n.y},{x:n.x,y:n.y}]}}let N=[];const T=C(b,O);if(T.inside&&T.obstacle){const t=T.obstacle;if(v){const n=L(a,o,e,t,!0);b.x=n.x,b.y=n.y,N=[{x:n.x,y:n.y},{x:a.x,y:n.y}]}else{const n=L(a,o,e,t,!1);b.x=n.x,b.y=n.y,N=[{x:n.x,y:n.y},{x:n.x,y:a.y}]}}if(0===k.length&&0===N.length){const e=yn,n=Math.abs(g.x-b.x)<e,o=Math.abs(g.y-b.y)<e,s=void 0!==B.get(`${nt}:src`)||void 0!==B.get(`${nt}:dst`),i=(I.get(`${t.start??""}:${d}:src`)?.length??0)+(I.get(`${t.start??""}:${d}:dst`)?.length??0),c=(I.get(`${t.end??""}:${h}:src`)?.length??0)+(I.get(`${t.end??""}:${h}:dst`)?.length??0),f=i>1||c>1,l=S.get(t.start??"")??0,u=S.get(t.end??"")??0,x=i>1&&E(t.start,d)||c>1&&E(t.end,h);if((n||o)&&!s&&(!f||f&&!x&&(i<=1||l<=2)&&(c<=1||u<=2))){if(!M(r,a,t.start,t.end)){t.points=[{...r},{...g},{...b},{...a}],m.add(nt);const e=o?"horizontal":"vertical",n=o?r.y:r.x,s=o?Math.min(r.x,a.x):Math.min(r.y,a.y),i=o?Math.max(r.x,a.x):Math.max(r.y,a.y),c={id:`fast-path-${e}-${n.toFixed(0)}-${nt}`,orientation:e,coord:n,spanMin:s,spanMax:i,tracks:[]};p.push({edgeIndex:nt,segmentIndex:0,orientation:e,pipe:c,trackIndex:0,from:s,to:i});continue}}}const F=u("vertical",g.x,g.y,g.y);g.x=F.coord;const $=u("vertical",b.x,b.y,b.y);b.x=$.coord;let X=Math.min(g.x,b.x)-50,z=Math.max(g.x,b.x)+50,P=Math.min(g.y,b.y)-50,G=Math.max(g.y,b.y)+50;for(const n of l){const t=Math.min(g.x,b.x),e=Math.max(g.x,b.x),o=Math.min(g.y,b.y),r=Math.max(g.y,b.y);n.minX<e&&n.maxX>t&&n.minY<r&&n.maxY>o&&(X=Math.min(X,n.minX-25),z=Math.max(z,n.maxX+25),P=Math.min(P,n.minY-25),G=Math.max(G,n.maxY+25))}for(const n of l){if(n.maxX<X||n.minX>z||n.maxY<P||n.minY>G)continue;const t=yn;u("horizontal",n.minY-t,X,z),u("horizontal",n.maxY+t,X,z);const e=bn;u("vertical",n.minX-e,P,G),u("vertical",n.maxX+e,P,G)}u("horizontal",g.y,X,z),u("horizontal",b.y,X,z);const D=c.filter(t=>"horizontal"===t.orientation&&t.coord>=P&&t.coord<=G),A=c.filter(t=>"vertical"===t.orientation&&t.coord>=X&&t.coord<=z),H=n((t,e)=>`${t.toFixed(1)},${e.toFixed(1)}`,"getKey"),j=H(g.x,g.y),V=H(b.x,b.y),_=new Map,W=new Map,K=new Map,q=new Set,U=[];_.set(j,0),K.set(j,"n"),U.push({key:j,f:Math.hypot(b.x-g.x,b.y-g.y),pt:g}),q.add(j);let J=[];const Z=n((e,n)=>M(e,n,t.start,t.end),"checkSegmentBlocked"),Q={x:b.x,y:g.y},tt=Z(g,Q),et=Z(Q,b),ot=tt||et,rt={x:g.x,y:b.y},st=Z(g,rt),it=Z(rt,b);if(ot?st||it||(J=Math.abs(g.x-b.x)<mn?[g,b]:[g,rt,b]):J=Math.abs(g.y-b.y)<mn||Math.abs(g.x-b.x)<mn?[g,b]:[g,Q,b],0===J.length)for(;U.length>0;){U.sort((t,e)=>t.f-e.f);const e=U.shift();if(q.delete(e.key),e.key===V){let t=V,e=b;for(J=[e];W.has(t);){const n=W.get(t);J.unshift(n),e=n,t=H(n.x,n.y)}break}const n=e.pt.x,o=e.pt.y,r=A.sort((t,e)=>t.coord-e.coord),s=r.findIndex(t=>Math.abs(t.coord-n)<1),i=D.sort((t,e)=>t.coord-e.coord),a=i.findIndex(t=>Math.abs(t.coord-o)<1),c=[];s>0&&c.push({x:r[s-1].coord,y:o}),s>=0&&s<r.length-1&&c.push({x:r[s+1].coord,y:o}),a>0&&c.push({x:n,y:i[a-1].coord}),a>=0&&a<i.length-1&&c.push({x:n,y:i[a+1].coord});for(const f of c){const r=Math.min(n,f.x),s=Math.max(n,f.x),i=Math.min(o,f.y),a=Math.max(o,f.y);if(l.some(e=>e.nodeId!==t.start&&e.nodeId!==t.end&&(r!==s?e.minY<o&&e.maxY>o&&e.maxX>r&&e.minX<s:e.minX<n&&e.maxX>n&&e.maxY>i&&e.minY<a)))continue;const c=H(f.x,f.y),d=Math.abs(f.x-n)+Math.abs(f.y-o),u=y(nt,e.pt,f);let h=0;const p=b.x-g.x,x=b.y-g.y,m=f.x-n,M=f.y-o;(x>10&&M<-5||x<-10&&M>5)&&(h=100*Math.abs(M)),(p>10&&m<-5||p<-10&&m>5)&&(h+=50*Math.abs(m));let I=0;const S=K.get(e.key)??"n",w=Math.abs(m)>mn?"h":"v";"n"!==S&&S!==w&&(I=50);const v=d+u+h+I,C=(_.get(e.key)??1/0)+v,L=Math.abs(b.x-f.x)+Math.abs(b.y-f.y);if(C<(_.get(c)??1/0))if(W.set(c,e.pt),_.set(c,C),K.set(c,w),q.has(c)){const t=U.findIndex(t=>t.key===c);-1!==t&&(U[t].f=C+L)}else U.push({key:c,f:C+L,pt:f}),q.add(c)}}if(0===J.length&&(J=[g,{x:g.x,y:b.y},b]),J.length>4){const t=J[0],e=J[J.length-1];let o=Math.min(t.x,e.x),r=Math.max(t.x,e.x),s=Math.min(t.y,e.y),i=Math.max(t.y,e.y);for(const n of J)o=Math.min(o,n.x),r=Math.max(r,n.x),s=Math.min(s,n.y),i=Math.max(i,n.y);const a=r>Math.max(t.x,e.x),c=o<Math.min(t.x,e.x);if(f){const n=bn;if(a){const o=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<o&&t.maxX>o&&t.minY<i&&t.maxY>s);if(a.length>0){let o=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 r=e+t.visualXHalfExtent+n;o=Math.max(o,r)}isNaN(o)||(r=o)}}if(c){const r=l.filter(o=>o.minX<Math.min(t.x,e.x)+n&&o.minY<Math.max(t.y,e.y)&&o.maxY>Math.min(t.y,e.y));if(r.length>0){let s=Math.min(t.x,e.x);for(const t of r){const e=(t.minX+t.maxX)/2-t.visualXHalfExtent-n;s=Math.min(s,e)}o=s}}}const d=n(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-mn)return t}else{const t=Math.min(...s.map(t=>t.minY))-15;if(t>e.y+mn)return t}return e.y},"findBestReturnY"),u=n(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)<mn?[t,r,s,e]:[t,r,s,i,e]},"trySimplifyWithDetourX"),h=a&&!c?u(r):c&&!a?u(o):null;h&&(J=h)}const at=[r,...k,...J,...N.reverse(),a];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)<mn&&Math.abs(e.y-t.y)<mn,r=Math.abs(n.x-e.x)<mn&&Math.abs(e.x-t.x)<mn;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 n=1;n<at.length-1;n++){if(1===n){ct.push(at[n]);continue}const t=ct[ct.length-1],e=at[n],o=at[n+1];if(Math.abs(t.y-e.y)<mn&&Math.abs(e.y-o.y)<mn){if(e.x>t.x!==o.x>e.x){ct.push(e);continue}continue}if(Math.abs(t.x-e.x)<mn&&Math.abs(e.x-o.x)<mn){if(e.y>t.y!==o.y>e.y){ct.push(e);continue}continue}ct.push(e)}ct.push(at[at.length-1]);for(let n=0;n<ct.length-1;n++){const t=ct[n],e=ct[n+1],o=Math.abs(t.x-e.x)<mn?"vertical":"horizontal",r="vertical"===o?t.x:t.y,s="vertical"===o?Math.min(t.y,e.y):Math.min(t.x,e.x),i="vertical"===o?Math.max(t.y,e.y):Math.max(t.x,e.x),a=u(o,r,s,i),c={edgeIndex:nt,segmentIndex:n,orientation:o,pipe:a,trackIndex:0,from:s,to:i};p.push(c),x[nt].push(p.length-1),a.tracks[0]||(a.tracks[0]={index:0,coord:a.coord,segments:[]}),a.tracks[0].segments.push({edgeIndex:nt,segmentIndex:n,from:s,to:i})}}const X=n((t,e)=>t.from<e.to&&e.from<t.to,"segmentsOverlap"),z=n((t,e,n,o)=>{const r=!o.segments.some(n=>(n.edgeIndex!==e.edgeIndex||n.segmentIndex!==e.segmentIndex)&&X(n,t)),s=!n.segments.some(n=>(n.edgeIndex!==t.edgeIndex||n.segmentIndex!==t.segmentIndex)&&X(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"),P=n(t=>{const e=t.tracks.length;return t.tracks[e]={index:e,coord:t.coord,segments:[]},e},"createNewTrack"),G=n((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"),D=n((t,e)=>{const n=x[t.edgeIndex];for(const o of n){const n=p[o];n.pipe===t.pipe&&G(n,e)}},"moveSegmentChainToTrack"),A=n(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"),H=n((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"),j=n((t,e)=>{for(const n of t.tracks){if(!n.segments.some(t=>(t.edgeIndex!==e.edgeIndex||t.segmentIndex!==e.segmentIndex)&&X(t,e)))return n.index}return-1},"findAvailableTrack"),V=n((t,e)=>{if(t.trackIndex===e.trackIndex)return X(t,e);const n=A(t),o=A(e);return n.some(t=>o.some(e=>H(t,e)))},"segmentsConflict"),_=n((t,e,n)=>{if(z(t,e,t.pipe.tracks[t.trackIndex],e.pipe.tracks[e.trackIndex]))return;const o=j(t.pipe,e);n(e,-1!==o?o:P(t.pipe))},"resolveTrackConflict"),W=n(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&&(V(r,s)&&(e++,_(r,s,D)))}return e},"resolveHandleConflicts"),K=new Map,q=n(t=>{if(K.has(t))return K.get(t);const e=x[t];if(0===e.length){const e={dest:0,deviation:0,base:0,delta:0};return K.set(t,e),e}const n=p[e[0]].pipe.coord;let o=n;for(let s=1;s<e.length;s++){const t=p[e[s]];if("horizontal"===t.orientation){const e=t.from,r=t.to;o=Math.abs(e-n)>Math.abs(r-n)?e:r;break}}const r={dest:o,deviation:Math.abs(o-n),base:n,delta:o-n};return K.set(t,r),r},"getDestInfo"),U=n(()=>{let t=0;const e=new Map;for(const[n,r]of s.entries())0!==x[n].length&&r.start&&(e.has(r.start)||e.set(r.start,[]),e.get(r.start).push(n));const o=n(t=>{const e=s[t];if(!e.start||!e.end)return 0;const n=i.get(e.start),o=i.get(e.end);if(!n||!o)return 0;const r=(o.x??0)-(n.x??0),a=(o.y??0)-(n.y??0);return Math.abs(r)+Math.abs(a)},"getEdgeDistance");for(const n of e.values()){n.sort((t,e)=>{const n=q(t),r=q(e);if(Math.abs(n.deviation-r.deviation)>1)return n.deviation-r.deviation;if(Math.abs(n.dest-r.dest)>1)return n.dest-r.dest;const s=o(t),i=o(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=n.map(t=>p[x[t][0]]);t+=W(e)}return t},"fixSourceHandleCrossings"),J=n(()=>{let t=0;const e=new Map;for(const[n,o]of s.entries()){0!==x[n].length&&(o.end&&(e.has(o.end)||e.set(o.end,[]),e.get(o.end).push(n)))}for(const o of e.values()){o.sort((t,e)=>{const o=n(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"),r=o(t),s=o(e);return Math.abs(r-s)>.1?r-s:t-e});const e=o.map(t=>p[x[t][x[t].length-1]]);t+=W(e)}return t},"fixTargetHandleCrossings"),Z=n(()=>{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];V(r,s)&&(t++,_(r,s,G))}}return t},"fixPipeCrossings");let Q=0;for(;Q<10;){let t=0;if(t+=U(),t+=J(),t+=Z(),0===t)break;Q++}const tt=new Map;for(const nt of c){const t=[];nt.tracks.forEach(e=>{e.segments.forEach(n=>{t.push({edgeIndex:n.edgeIndex,segmentIndex:n.segmentIndex,trackIndex:e.index,from:n.from,to:n.to})})}),t.sort((t,e)=>t.from-e.from);const e=[];if(t.length>0){let n=[t[0]],o=t[0].to;for(let r=1;r<t.length;r++){const s=t[r];s.from<o?(n.push(s),o=Math.max(o,s.to)):(e.push(n),n=[s],o=s.to)}e.push(n)}for(const o of e){const t=new Set;o.forEach(e=>t.add(e.trackIndex));const e=new Map;o.forEach(t=>{const n=q(t.edgeIndex);e.set(t.trackIndex,(e.get(t.trackIndex)??0)+n.delta)});const r=[...t].filter(t=>(e.get(t)??0)<-1),s=[...t].filter(t=>(e.get(t)??0)>1),i=[...t].filter(t=>Math.abs(e.get(t)??0)<=1);r.sort((t,n)=>(e.get(n)??0)-(e.get(t)??0)),s.sort((t,n)=>(e.get(t)??0)-(e.get(n)??0));const a=n((t,e)=>{o.filter(e=>e.trackIndex===t).forEach(t=>{const n=m.has(t.edgeIndex)?nt.coord:e;tt.set(`${t.edgeIndex}-${t.segmentIndex}`,n)})},"assignCoord");let c=0;for(const n of r)c++,a(n,nt.coord-10*c);if(0===i.length&&t.size>0){const n=[...t].sort((t,n)=>Math.abs(e.get(t)??0)-Math.abs(e.get(n)??0))[0],o=r.indexOf(n);-1!==o&&r.splice(o,1);const a=s.indexOf(n);-1!==a&&s.splice(a,1),i.push(n)}let f=0;for(const n of i){if(0===f)a(n,nt.coord);else{const t=f%2==1?1:-1,e=Math.ceil(f/2);a(n,nt.coord+t*e*10*.5)}f++}let d=0;for(const n of s)d++,a(n,nt.coord+10*d)}}for(const[n,nt]of s.entries()){const t=x[n]??[];if(0===t.length)continue;const e=[],o=i.get(nt.start),r=i.get(nt.end),{pSrcPort:s,pDstPort:a}=Y(n,o,r),c=t.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}});e.push(s);for(let n=0;n<c.length;n++){const t=c[n],o=e[e.length-1],r="vertical"===t.orient?o.y:o.x,s="vertical"===t.orient?o.x:o.y,i=c[n+1],a=n<c.length-1;if(Math.abs(s-t.coord)>mn&&e.push(wn(t,r)),a&&i.orient===t.orient)if(Math.abs(t.coord-i.coord)>mn){const n="vertical"===t.orient?(r+i.from)/2:Sn(t,i);e.push(wn(t,n),wn(i,n))}else 0!==n&&n!==c.length-2||e.push(wn(t,Sn(t,i)));else if(a)e.push(wn(t,i.coord));else{const n=Math.abs(t.from-r)<Math.abs(t.to-r)?t.to:t.from;e.push(wn(t,n))}}const f=e[e.length-1];(Math.abs(f.x-a.x)>mn||Math.abs(f.y-a.y)>mn)&&e.push(a);const d=[];e.length>0&&d.push(e[0]);for(let n=1;n<e.length;n++){const t=e[n],o=d[d.length-1];(Math.abs(t.x-o.x)>mn||Math.abs(t.y-o.y)>mn)&&d.push(t)}nt.points=d}for(const n of s){const t=n.__originalEdge;t&&n.points&&(t.points=n.points)}t.edges=(t.edges??[]).filter(t=>!t.isLayoutOnly);const et=n((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 n of t.edges){const t=n.points;if(!t||t.length<2)continue;const e=n.start,o=n.end,r=e?i.get(e):void 0,s=o?i.get(o):void 0;r&&(t[0]=et(t[0],r)),s&&(t[t.length-1]=et(t[t.length-1],s))}return t}function Cn(t){return t.direction??"TB"}function Ln(t){const e=f(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=Cn(t),{ordered:c,coordinates:l}=xn(e,{nodeGap:n,layerGap:o,ignoreCrossLaneEdges:r,optimizeRanksByCrossings:s,automaticLaneOrdering:i,direction:a});d(e,c,l,{nodeGap:n,layerGap:o});for(const f of t.edges??[])delete f.points;vn(t,a);for(const f of t.edges??[])f.curve&&"basis"!==f.curve||(f.curve="rounded");return se(t,a),re(t),a}function kn(t){c(t);const e=l(t);t.nodes=e.nodes,t.edges=e.edges}n(In,"chooseOrthogonalSide"),n(Sn,"sharedLineEndpointCoord"),n(wn,"pointOnLine"),n(vn,"routeEdgesOrthogonal"),n(Cn,"getSwimlaneDirection"),n(Ln,"runSwimlaneLayoutCore"),n(kn,"prepareSwimlaneLayout");var On=e({prepareLayout:kn,runLayoutCore:Ln,afterPaint:r});export{On as render};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as r,s as t}from"./flowDiagram-IUGLLWBU-CRXa9Kxy.js";import{_ as o}from"./mermaid-T_6Ze_cT.js";import"./chunk-5VM5RSS4-CJaRXFHK.js";import"./chunk-XXDRQBXY-Ct0MhvQo.js";import"./chunk-VQ5W62QI-B95zur4F.js";import"./chunk-55XCU76K-Cq25Yw_G.js";import"./markdown-S2mWvoE-.js";var s=r({styles:o(r=>`${t(r)}\n .swimlane.cluster:not([data-color-id]) rect {\n stroke: ${r.clusterBorder} !important;\n }\n [data-look="neo"].cluster rect {\n filter: none;\n }\n`,"getStyles")});export{s as diagram};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_ as t,L as e,E as n,B as i,a8 as r,a9 as a,aa as s,c as o,l as c,Q as l,R as h,ab as d,k as u,S as p,K as g,ac as y,z as f}from"./mermaid-T_6Ze_cT.js";import"./markdown-S2mWvoE-.js";var m=function(){var e=t(function(t,e,n,i){for(n=n||{},i=t.length;i--;n[t[i]]=e);return n},"o"),n=[6,11,13,14,15,17,19,20,23,24],i=[1,12],r=[1,13],a=[1,14],s=[1,15],o=[1,16],c=[1,19],l=[1,20],h={trace:t(function(){},"trace"),yy:{},symbols_:{error:2,start:3,timeline_header:4,document:5,EOF:6,timeline:7,timeline_lr:8,timeline_td:9,line:10,SPACE:11,statement:12,NEWLINE:13,title:14,acc_title:15,acc_title_value:16,acc_descr:17,acc_descr_value:18,acc_descr_multiline_value:19,section:20,period_statement:21,event_statement:22,period:23,event:24,$accept:0,$end:1},terminals_:{2:"error",6:"EOF",7:"timeline",8:"timeline_lr",9:"timeline_td",11:"SPACE",13:"NEWLINE",14:"title",15:"acc_title",16:"acc_title_value",17:"acc_descr",18:"acc_descr_value",19:"acc_descr_multiline_value",20:"section",23:"period",24:"event"},productions_:[0,[3,3],[4,1],[4,1],[4,1],[5,0],[5,2],[10,2],[10,1],[10,1],[10,1],[12,1],[12,2],[12,2],[12,1],[12,1],[12,1],[12,1],[21,1],[22,1]],performAction:t(function(t,e,n,i,r,a,s){var o=a.length-1;switch(r){case 1:return a[o-1];case 3:i.setDirection("LR");break;case 4:i.setDirection("TD");break;case 5:case 9:case 10:this.$=[];break;case 6:a[o-1].push(a[o]),this.$=a[o-1];break;case 7:case 8:this.$=a[o];break;case 11:i.getCommonDb().setDiagramTitle(a[o].substr(6)),this.$=a[o].substr(6);break;case 12:this.$=a[o].trim(),i.getCommonDb().setAccTitle(this.$);break;case 13:case 14:this.$=a[o].trim(),i.getCommonDb().setAccDescription(this.$);break;case 15:i.addSection(a[o].substr(8)),this.$=a[o].substr(8);break;case 18:i.addTask(a[o],0,""),this.$=a[o];break;case 19:i.addEvent(a[o].substr(2)),this.$=a[o]}},"anonymous"),table:[{3:1,4:2,7:[1,3],8:[1,4],9:[1,5]},{1:[3]},e(n,[2,5],{5:6}),e(n,[2,2]),e(n,[2,3]),e(n,[2,4]),{6:[1,7],10:8,11:[1,9],12:10,13:[1,11],14:i,15:r,17:a,19:s,20:o,21:17,22:18,23:c,24:l},e(n,[2,10],{1:[2,1]}),e(n,[2,6]),{12:21,14:i,15:r,17:a,19:s,20:o,21:17,22:18,23:c,24:l},e(n,[2,8]),e(n,[2,9]),e(n,[2,11]),{16:[1,22]},{18:[1,23]},e(n,[2,14]),e(n,[2,15]),e(n,[2,16]),e(n,[2,17]),e(n,[2,18]),e(n,[2,19]),e(n,[2,7]),e(n,[2,12]),e(n,[2,13])],defaultActions:{},parseError:t(function(t,e){if(!e.recoverable){var n=new Error(t);throw n.hash=e,n}this.trace(t)},"parseError"),parse:t(function(e){var n=this,i=[0],r=[],a=[null],s=[],o=this.table,c="",l=0,h=0,d=s.slice.call(arguments,1),u=Object.create(this.lexer),p={yy:{}};for(var g in this.yy)Object.prototype.hasOwnProperty.call(this.yy,g)&&(p.yy[g]=this.yy[g]);u.setInput(e,p.yy),p.yy.lexer=u,p.yy.parser=this,void 0===u.yylloc&&(u.yylloc={});var y=u.yylloc;s.push(y);var f=u.options&&u.options.ranges;function m(){var t;return"number"!=typeof(t=r.pop()||u.lex()||1)&&(t instanceof Array&&(t=(r=t).pop()),t=n.symbols_[t]||t),t}"function"==typeof p.yy.parseError?this.parseError=p.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError,t(function(t){i.length=i.length-2*t,a.length=a.length-t,s.length=s.length-t},"popStack"),t(m,"lex");for(var x,b,k,w,_,$,v,S,E={};;){if(b=i[i.length-1],this.defaultActions[b]?k=this.defaultActions[b]:(null==x&&(x=m()),k=o[b]&&o[b][x]),void 0===k||!k.length||!k[0]){var T="";for(_ in S=[],o[b])this.terminals_[_]&&_>2&&S.push("'"+this.terminals_[_]+"'");T=u.showPosition?"Parse error on line "+(l+1)+":\n"+u.showPosition()+"\nExpecting "+S.join(", ")+", got '"+(this.terminals_[x]||x)+"'":"Parse error on line "+(l+1)+": Unexpected "+(1==x?"end of input":"'"+(this.terminals_[x]||x)+"'"),this.parseError(T,{text:u.match,token:this.terminals_[x]||x,line:u.yylineno,loc:y,expected:S})}if(k[0]instanceof Array&&k.length>1)throw new Error("Parse Error: multiple actions possible at state: "+b+", token: "+x);switch(k[0]){case 1:i.push(x),a.push(u.yytext),s.push(u.yylloc),i.push(k[1]),x=null,h=u.yyleng,c=u.yytext,l=u.yylineno,y=u.yylloc;break;case 2:if($=this.productions_[k[1]][1],E.$=a[a.length-$],E._$={first_line:s[s.length-($||1)].first_line,last_line:s[s.length-1].last_line,first_column:s[s.length-($||1)].first_column,last_column:s[s.length-1].last_column},f&&(E._$.range=[s[s.length-($||1)].range[0],s[s.length-1].range[1]]),void 0!==(w=this.performAction.apply(E,[c,h,l,p.yy,k[1],a,s].concat(d))))return w;$&&(i=i.slice(0,-1*$*2),a=a.slice(0,-1*$),s=s.slice(0,-1*$)),i.push(this.productions_[k[1]][0]),a.push(E.$),s.push(E._$),v=o[i[i.length-2]][i[i.length-1]],i.push(v);break;case 3:return!0}}return!0},"parse")},d=function(){return{EOF:1,parseError:t(function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e)},"parseError"),setInput:t(function(t,e){return this.yy=e||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:t(function(){var t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},"input"),unput:t(function(t){var e=t.length,n=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var i=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),n.length-1&&(this.yylineno-=n.length-1);var r=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:n?(n.length===i.length?this.yylloc.first_column:0)+i[i.length-n.length].length-n[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[r[0],r[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},"unput"),more:t(function(){return this._more=!0,this},"more"),reject:t(function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},"reject"),less:t(function(t){this.unput(this.match.slice(t))},"less"),pastInput:t(function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:t(function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:t(function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},"showPosition"),test_match:t(function(t,e){var n,i,r;if(this.options.backtrack_lexer&&(r={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(r.yylloc.range=this.yylloc.range.slice(0))),(i=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=i.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:i?i[i.length-1].length-i[i.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],n=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),n)return n;if(this._backtrack){for(var a in r)this[a]=r[a];return!1}return!1},"test_match"),next:t(function(){if(this.done)return this.EOF;var t,e,n,i;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var r=this._currentRules(),a=0;a<r.length;a++)if((n=this._input.match(this.rules[r[a]]))&&(!e||n[0].length>e[0].length)){if(e=n,i=a,this.options.backtrack_lexer){if(!1!==(t=this.test_match(n,r[a])))return t;if(this._backtrack){e=!1;continue}return!1}if(!this.options.flex)break}return e?!1!==(t=this.test_match(e,r[i]))&&t:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},"next"),lex:t(function(){var t=this.next();return t||this.lex()},"lex"),begin:t(function(t){this.conditionStack.push(t)},"begin"),popState:t(function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:t(function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},"_currentRules"),topState:t(function(t){return(t=this.conditionStack.length-1-Math.abs(t||0))>=0?this.conditionStack[t]:"INITIAL"},"topState"),pushState:t(function(t){this.begin(t)},"pushState"),stateStackSize:t(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:t(function(t,e,n,i){switch(n){case 0:case 1:case 3:case 4:break;case 2:return 13;case 5:return 8;case 6:return 9;case 7:return 7;case 8:return 14;case 9:return this.begin("acc_title"),15;case 10:return this.popState(),"acc_title_value";case 11:return this.begin("acc_descr"),17;case 12:return this.popState(),"acc_descr_value";case 13:this.begin("acc_descr_multiline");break;case 14:this.popState();break;case 15:return"acc_descr_multiline_value";case 16:return 20;case 17:return 24;case 18:return 23;case 19:return 6;case 20:return"INVALID"}},"anonymous"),rules:[/^(?:%(?!\{)[^\n]*)/i,/^(?:[^\}]%%[^\n]*)/i,/^(?:[\n]+)/i,/^(?:\s+)/i,/^(?:#[^\n]*)/i,/^(?:timeline[ \t]+LR\b)/i,/^(?:timeline[ \t]+TD\b)/i,/^(?:timeline\b)/i,/^(?:title\s[^\n]+)/i,/^(?:accTitle\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*\{\s*)/i,/^(?:[\}])/i,/^(?:[^\}]*)/i,/^(?:section\s[^:\n]+)/i,/^(?::\s(?:[^:\n]|:(?!\s))+)/i,/^(?:[^#:\n]+)/i,/^(?:$)/i,/^(?:.)/i],conditions:{acc_descr_multiline:{rules:[14,15],inclusive:!1},acc_descr:{rules:[12],inclusive:!1},acc_title:{rules:[10],inclusive:!1},INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,11,13,16,17,18,19,20],inclusive:!0}}}}();function u(){this.yy={}}return h.lexer=d,t(u,"Parser"),u.prototype=h,h.Parser=u,new u}();m.parser=m;var x=m,b={};g(b,{addEvent:()=>D,addSection:()=>H,addTask:()=>N,addTaskOrg:()=>A,clear:()=>T,default:()=>O,getCommonDb:()=>E,getDirection:()=>M,getSections:()=>C,getTasks:()=>L,setDirection:()=>I});var k="",w=0,_="LR",$=[],v=[],S=[],E=t(()=>y,"getCommonDb"),T=t(function(){$.length=0,v.length=0,k="",S.length=0,_="LR",f()},"clear"),I=t(function(t){_=t},"setDirection"),M=t(function(){return _},"getDirection"),H=t(function(t){k=t,$.push(t)},"addSection"),C=t(function(){return $},"getSections"),L=t(function(){let t=B();let e=0;for(;!t&&e<100;)t=B(),e++;return v.push(...S),v},"getTasks"),N=t(function(t,e,n){const i={id:w++,section:k,type:k,task:t,score:e||0,events:n?[n]:[]};S.push(i)},"addTask"),D=t(function(t){S.find(t=>t.id===w-1).events.push(t)},"addEvent"),A=t(function(t){const e={section:k,type:k,description:t,task:t,classes:[]};v.push(e)},"addTaskOrg"),B=t(function(){const e=t(function(t){return S[t].processed},"compileTask");let n=!0;for(const[t,i]of S.entries())e(t),n=n&&i.processed;return n},"compileTasks"),O={clear:T,getCommonDb:E,getDirection:M,setDirection:I,addSection:H,getSections:C,getTasks:L,addTask:N,addTaskOrg:A,addEvent:D},R=0,P=t(function(t,e){const n=t.append("rect");return n.attr("x",e.x),n.attr("y",e.y),n.attr("fill",e.fill),n.attr("stroke",e.stroke),n.attr("width",e.width),n.attr("height",e.height),n.attr("rx",e.rx),n.attr("ry",e.ry),void 0!==e.class&&n.attr("class",e.class),n},"drawRect"),j=t(function(e,n){const i=15,r=e.append("circle").attr("cx",n.cx).attr("cy",n.cy).attr("class","face").attr("r",i).attr("stroke-width",2).attr("overflow","visible"),a=e.append("g");function s(t){const e=p().startAngle(Math.PI/2).endAngle(Math.PI/2*3).innerRadius(7.5).outerRadius(i/2.2);t.append("path").attr("class","mouth").attr("d",e).attr("transform","translate("+n.cx+","+(n.cy+2)+")")}function o(t){const e=p().startAngle(3*Math.PI/2).endAngle(Math.PI/2*5).innerRadius(7.5).outerRadius(i/2.2);t.append("path").attr("class","mouth").attr("d",e).attr("transform","translate("+n.cx+","+(n.cy+7)+")")}function c(t){t.append("line").attr("class","mouth").attr("stroke",2).attr("x1",n.cx-5).attr("y1",n.cy+7).attr("x2",n.cx+5).attr("y2",n.cy+7).attr("class","mouth").attr("stroke-width","1px").attr("stroke","#666")}return a.append("circle").attr("cx",n.cx-5).attr("cy",n.cy-5).attr("r",1.5).attr("stroke-width",2).attr("fill","#666").attr("stroke","#666"),a.append("circle").attr("cx",n.cx+5).attr("cy",n.cy-5).attr("r",1.5).attr("stroke-width",2).attr("fill","#666").attr("stroke","#666"),t(s,"smile"),t(o,"sad"),t(c,"ambivalent"),n.score>3?s(a):n.score<3?o(a):c(a),r},"drawFace"),W=t(function(t,e){const n=t.append("circle");return n.attr("cx",e.cx),n.attr("cy",e.cy),n.attr("class","actor-"+e.pos),n.attr("fill",e.fill),n.attr("stroke",e.stroke),n.attr("r",e.r),void 0!==n.class&&n.attr("class",n.class),void 0!==e.title&&n.append("title").text(e.title),n},"drawCircle"),z=t(function(t,e){const n=e.text.replace(/<br\s*\/?>/gi," "),i=t.append("text");i.attr("x",e.x),i.attr("y",e.y),i.attr("class","legend"),i.style("text-anchor",e.anchor),void 0!==e.class&&i.attr("class",e.class);const r=i.append("tspan");return r.attr("x",e.x+2*e.textMargin),r.text(n),i},"drawText"),F=t(function(e,n){function i(t,e,n,i,r){return t+","+e+" "+(t+n)+","+e+" "+(t+n)+","+(e+i-r)+" "+(t+n-1.2*r)+","+(e+i)+" "+t+","+(e+i)}t(i,"genPoints");const r=e.append("polygon");r.attr("points",i(n.x,n.y,50,20,7)),r.attr("class","labelBox"),n.y=n.y+n.labelMargin,n.x=n.x+.5*n.labelMargin,z(e,n)},"drawLabel"),V=t(function(t,e,n){const i=t.append("g"),r=Y();r.x=e.x,r.y=e.y,r.fill=e.fill,r.width=n.width,r.height=n.height,r.class="journey-section section-type-"+e.num,r.rx=3,r.ry=3,P(i,r),K(n)(e.text,i,r.x,r.y,r.width,r.height,{class:"journey-section section-type-"+e.num},n,e.colour)},"drawSection"),G=-1,U=t(function(t,e,n,i){const r=e.x+n.width/2,a=t.append("g");G++;a.append("line").attr("id",i+"-task"+G).attr("x1",r).attr("y1",e.y).attr("x2",r).attr("y2",450).attr("class","task-line").attr("stroke-width","1px").attr("stroke-dasharray","4 2").attr("stroke","#666"),j(a,{cx:r,cy:300+30*(5-e.score),score:e.score});const s=Y();s.x=e.x,s.y=e.y,s.fill=e.fill,s.width=n.width,s.height=n.height,s.class="task task-type-"+e.num,s.rx=3,s.ry=3,P(a,s),K(n)(e.task,a,s.x,s.y,s.width,s.height,{class:"task"},n,e.colour)},"drawTask"),Z=t(function(t,e){P(t,{x:e.startx,y:e.starty,width:e.stopx-e.startx,height:e.stopy-e.starty,fill:e.fill,class:"rect"}).lower()},"drawBackgroundRect"),q=t(function(){return{x:0,y:0,fill:void 0,"text-anchor":"start",width:100,height:100,textMargin:0,rx:0,ry:0}},"getTextObj"),Y=t(function(){return{x:0,y:0,width:100,anchor:"start",height:100,rx:0,ry:0}},"getNoteRect"),K=function(){function e(t,e,n,i,a,s,o,c){r(e.append("text").attr("x",n+a/2).attr("y",i+s/2+5).style("font-color",c).style("text-anchor","middle").text(t),o)}function n(t,e,n,i,a,s,o,c,l){const{taskFontSize:h,taskFontFamily:d}=c,u=t.split(/<br\s*\/?>/gi);for(let p=0;p<u.length;p++){const t=p*h-h*(u.length-1)/2,c=e.append("text").attr("x",n+a/2).attr("y",i).attr("fill",l).style("text-anchor","middle").style("font-size",h).style("font-family",d);c.append("tspan").attr("x",n+a/2).attr("dy",t).text(u[p]),c.attr("y",i+s/2).attr("dominant-baseline","central").attr("alignment-baseline","central"),r(c,o)}}function i(t,e,i,a,s,o,c,l){const h=e.append("switch"),d=h.append("foreignObject").attr("x",i).attr("y",a).attr("width",s).attr("height",o).attr("position","fixed").append("xhtml:div").style("display","table").style("height","100%").style("width","100%");d.append("div").attr("class","label").style("display","table-cell").style("text-align","center").style("vertical-align","middle").text(t),n(t,h,i,a,s,o,c,l),r(d,c)}function r(t,e){for(const n in e)n in e&&t.attr(n,e[n])}return t(e,"byText"),t(n,"byTspan"),t(i,"byFo"),t(r,"_setTextAttrs"),function(t){return"fo"===t.textPlacement?i:"old"===t.textPlacement?e:n}}(),Q=t(function(t,e){R=0,G=-1,t.append("defs").append("marker").attr("id",e+"-arrowhead").attr("refX",5).attr("refY",2).attr("markerWidth",6).attr("markerHeight",4).attr("orient","auto").append("path").attr("d","M 0,0 V 4 L6,2 Z")},"initGraphics");function X(t,e){t.each(function(){var t,n=u(this),i=n.text().split(/(\s+|<br>)/).reverse(),r=[],a=n.attr("y"),s=parseFloat(n.attr("dy")),o=n.text(null).append("tspan").attr("x",0).attr("y",a).attr("dy",s+"em");for(let c=0;c<i.length;c++)t=i[i.length-1-c],r.push(t),o.text(r.join(" ").trim()),(o.node().getComputedTextLength()>e||"<br>"===t)&&(r.pop(),o.text(r.join(" ").trim()),r="<br>"===t?[""]:[t],o=n.append("tspan").attr("x",0).attr("y",a).attr("dy","1.1em").text(t))})}t(X,"wrap");var J=t(function(t,e,n,i,r,a=!1){const{theme:s,look:o}=i,c=s?.includes("redux"),l=n%(i?.themeVariables?.THEME_COLOR_LIMIT??12)-1,h=t.append("g");e.section=l,h.attr("class",(e.class?e.class+" ":"")+"timeline-node section-"+l);const d=h.append("g"),p=h.append("g"),g=p.append("text").text(e.descr).attr("dy","1em").attr("alignment-baseline","middle").attr("dominant-baseline","middle").attr("text-anchor","middle").call(X,e.width).node().getBBox(),y=i.fontSize?.replace?i.fontSize.replace("px",""):i.fontSize;if(e.height=g.height+1.1*y*.5+e.padding,e.height=Math.max(e.height,e.maxHeight),e.width=e.width+2*e.padding,p.attr("transform","translate("+e.width/2+", "+e.padding/2+")"),c&&p.attr("transform",`translate(${e.width/2}, ${a?e.padding/2+3:e.padding})`),et(d,e,l,r,i),"neo"===o&&(h.attr("data-look","neo"),c)){const e=s.includes("dark"),n=t.node()?.ownerSVGElement??t.node(),i=u(n),r=i.attr("id")??"",a=r?`${r}-drop-shadow`:"drop-shadow";if(i.select(`#${a}`).empty()){const t=i.select("defs");(t.empty()?i.append("defs"):t).append("filter").attr("id",a).attr("height","130%").attr("width","130%").append("feDropShadow").attr("dx","4").attr("dy","4").attr("stdDeviation",0).attr("flood-opacity",e?"0.2":"0.06").attr("flood-color",e?"#FFFFFF":"#000000")}}return e},"drawNode"),tt=t(function(t,e,n){const i=t.append("g"),r=i.append("text").text(e.descr).attr("dy","1em").attr("alignment-baseline","middle").attr("dominant-baseline","middle").attr("text-anchor","middle").call(X,e.width).node().getBBox(),a=n.fontSize?.replace?n.fontSize.replace("px",""):n.fontSize;return i.remove(),r.height+1.1*a*.5+e.padding},"getVirtualNodeHeight"),et=t(function(t,e,n,i,r){const{theme:a}=r,s=a?.includes("redux")?0:5,o=s>0?`M0 ${e.height-5} v${10-e.height} q0,-${s},${s},-${s} h${e.width-10} q${s},0,${s},${s} v${e.height-5} H0 Z`:`M0 ${e.height-5} v${-(e.height-5)} h${e.width} v${e.height} H0 Z`;t.append("path").attr("id",i+"-node-"+R++).attr("class","node-bkg node-"+e.type).attr("d",o),a?.includes("redux")||t.append("line").attr("class","node-line-"+n).attr("x1",0).attr("y1",e.height).attr("x2",e.width).attr("y2",e.height)},"defaultBkg"),nt={drawRect:P,drawCircle:W,drawSection:V,drawText:z,drawLabel:F,drawTask:U,drawBackgroundRect:Z,getTextObj:q,getNoteRect:Y,initGraphics:Q,drawNode:J,getVirtualNodeHeight:tt},it=t(function(t,e,n,i){const r=o(),{look:a,theme:s,themeVariables:l}=r,{useGradient:h,gradientStart:p,gradientStop:g}=l,y=r.timeline?.leftMargin??50;c.debug("timeline",i.db);const f=r.securityLevel;let m;"sandbox"===f&&(m=u("#i"+e));const x=u("sandbox"===f?m.nodes()[0].contentDocument.body:"body").select("#"+e);x.append("g");const b=i.db.getTasks(),k=i.db.getCommonDb().getDiagramTitle();c.debug("task",b),nt.initGraphics(x,e);const w=i.db.getSections();c.debug("sections",w);let _=0,$=0,v=0,S=0,E=50+y,T=50;S=50;let I=0,M=!0;w.forEach(function(t){const e={number:I,descr:t,section:I,width:150,padding:20,maxHeight:_},n=nt.getVirtualNodeHeight(x,e,r);c.debug("sectionHeight before draw",n),_=Math.max(_,n+20)});let H=0,C=0;c.debug("tasks.length",b.length);for(const[o,d]of b.entries()){const t={number:o,descr:d,section:d.section,width:150,padding:20,maxHeight:$},e=nt.getVirtualNodeHeight(x,t,r);c.debug("taskHeight before draw",e),$=Math.max($,e+20),H=Math.max(H,d.events.length);let n=0;for(const i of d.events){const t={descr:i,section:d.section,number:d.section,width:150,padding:20,maxHeight:50};n+=nt.getVirtualNodeHeight(x,t,r)}d.events.length>0&&(n+=10*(d.events.length-1)),C=Math.max(C,n)}c.debug("maxSectionHeight before draw",_),c.debug("maxTaskHeight before draw",$),w&&w.length>0?w.forEach(t=>{const n=b.filter(e=>e.section===t),i={number:I,descr:t,section:I,width:200*Math.max(n.length,1)-50,padding:20,maxHeight:_};c.debug("sectionNode",i);const a=x.append("g"),s=nt.drawNode(a,i,I,r,e);c.debug("sectionNode output",s),a.attr("transform",`translate(${E}, 50)`),T+=_+50,n.length>0&&rt(x,n,I,E,T,$,r,H,C,_,!1,e),E+=200*Math.max(n.length,1),T=50,I++}):(M=!1,rt(x,b,I,E,T,$,r,H,C,_,!0,e));const L=x.node().getBBox();c.debug("bounds",L),k&&x.append("text").text(k).attr("x","neo"===a?2*L.x+y:L.width/2-y).attr("font-size","4ex").attr("font-weight","bold").attr("y",20),v=M?_+$+150:$+100;if(x.append("g").attr("class","lineWrapper").append("line").attr("x1",y).attr("y1",v).attr("x2",L.width+3*y).attr("y2",v).attr("stroke-width",4).attr("stroke","black").attr("marker-end",`url(#${e}-arrowhead)`),"neo"===a&&h&&"neutral"!==s){const t=x.select("defs"),e=(t.empty()?x.append("defs"):t).append("linearGradient").attr("id",x.attr("id")+"-gradient").attr("gradientUnits","objectBoundingBox").attr("x1","0%").attr("y1","0%").attr("x2","100%").attr("y2","0%");e.append("stop").attr("offset","0%").attr("stop-color",p).attr("stop-opacity",1),e.append("stop").attr("offset","100%").attr("stop-color",g).attr("stop-opacity",1)}d(void 0,x,r.timeline?.padding??50,r.timeline?.useMaxWidth??!1)},"draw"),rt=t(function(t,e,n,i,r,a,s,o,l,h,d,u){for(const p of e){const e={descr:p.task,section:n,number:n,width:150,padding:20,maxHeight:a};c.debug("taskNode",e);const o=t.append("g").attr("class","taskWrapper"),h=nt.drawNode(o,e,n,s,u).height;if(c.debug("taskHeight after draw",h),o.attr("transform",`translate(${i}, ${r})`),a=Math.max(a,h),p.events){const e=t.append("g").attr("class","lineWrapper");let o=a;r+=100,o+=at(t,p.events,n,i,r,s,u),r-=100,e.append("line").attr("x1",i+95).attr("y1",r+a).attr("x2",i+95).attr("y2",r+a+100+l+100).attr("stroke-width",2).attr("stroke","black").attr("marker-end",`url(#${u}-arrowhead)`).attr("stroke-dasharray","5,5")}i+=200,d&&!s.timeline?.disableMulticolor&&n++}r-=10},"drawTasks"),at=t(function(t,e,n,i,r,a,s){let o=0;const l=r;r+=100;for(const h of e){const e={descr:h,section:n,number:n,width:150,padding:20,maxHeight:50};c.debug("eventNode",e);const l=t.append("g").attr("class","eventWrapper"),d=nt.drawNode(l,e,n,a,s,!0).height;o+=d,l.attr("transform",`translate(${i}, ${r})`),r=r+10+d}return r=l,o},"drawEvents"),st={setConf:t(()=>{},"setConf"),draw:it},ot=200,ct=t(function(t,e,n,i){const r=o(),a=r.timeline?.leftMargin??50;c.debug("timeline",i.db);const s=l(e);s.append("g");const u=i.db.getTasks(),p=i.db.getCommonDb().getDiagramTitle();c.debug("task",u),nt.initGraphics(s);const g=i.db.getSections();c.debug("sections",g);let y=0,f=0;const m=50+a;let x=50;const b=x,k=230,w=m+k;let _=0;const $=g&&g.length>0,v=$?w:m+k,S=Math.max(50,580);g.forEach(function(t){const e={number:_,descr:t,section:_,width:S,padding:5,maxHeight:y},n=nt.getVirtualNodeHeight(s,e,r);c.debug("sectionHeight before draw",n),y=Math.max(y,n)});let E=0;c.debug("tasks.length",u.length);for(const[o,l]of u.entries()){const t={number:o,descr:l,section:l.section,width:ot,padding:5,maxHeight:f},e=nt.getVirtualNodeHeight(s,t,r);c.debug("taskHeight before draw",e),f=Math.max(f,e);let n=0;for(const i of l.events){const t={descr:i,section:l.section,number:l.section,width:300,padding:5,maxHeight:50};n+=nt.getVirtualNodeHeight(s,t,r)}l.events.length>0&&(n+=10*(l.events.length-1)),E=Math.max(E,n)+0}c.debug("maxSectionHeight before draw",y),c.debug("maxTaskHeight before draw",f);const T=Math.max(f,E)+30;$?g.forEach(t=>{const e=u.filter(e=>e.section===t),n={number:_,descr:t,section:_,width:S,padding:5,maxHeight:y};c.debug("sectionNode",n);const i=s.append("g"),a=nt.drawNode(i,n,_,r);c.debug("sectionNode output",a);const o=v-k;i.attr("transform",`translate(${o}, ${x})`);const l=x+a.height+20;e.length>0&<(s,e,_,v,l,f,r,T,!1);const h=e.length,d=a.height+20+T*Math.max(h,1)-(h>0?60:0);x+=d,_++}):lt(s,u,_,v,x,f,r,T,!0);let I=s.node()?.getBBox();if(!I)throw new Error("bbox not found");if(c.debug("bounds",I),p){if(s.append("text").text(p).attr("x",I.width/2-a).attr("font-size","4ex").attr("font-weight","bold").attr("y",20),I=s.node()?.getBBox(),!I)throw new Error("bbox not found");c.debug("bounds after title",I)}const[M]=h(r.fontSize),H=2*(M??16),C=.5*(M??16)+20,L=s.append("g").attr("class","lineWrapper");L.append("line").attr("x1",v).attr("y1",b-H).attr("x2",v).attr("y2",I.y+I.height+C).attr("stroke-width",4).attr("stroke","black").attr("marker-end","url(#arrowhead)"),L.lower(),d(void 0,s,r.timeline?.padding??50,r.timeline?.useMaxWidth??!1)},"draw"),lt=t(function(t,e,n,i,r,a,s,o,l){for(const h of e){const e={descr:h.task,section:n,number:n,width:ot,padding:5,maxHeight:a};c.debug("taskNode",e);const d=t.append("g").attr("class","taskWrapper"),u=nt.drawNode(d,e,n,s),p=u.height;c.debug("taskHeight after draw",p);const g=i-20-u.width;if(d.attr("transform",`translate(${g}, ${r})`),a=Math.max(a,p),h.events&&h.events.length>0){const e=r,a=i+50;ht(t,h.events,n,i,a,e,s)}r+=o,l&&!s.timeline?.disableMulticolor&&n++}},"drawTasks"),ht=t(function(t,e,n,i,r,a,s){let o=a;for(const l of e){const e={descr:l,section:n,number:n,width:300,padding:5,maxHeight:0};c.debug("eventNode",e);const a=t.append("g").attr("class","eventWrapper"),h=nt.drawNode(a,e,n,s).height;a.attr("transform",`translate(${r}, ${o})`);const d=o+h/2;t.append("g").attr("class","lineWrapper").append("line").attr("x1",i).attr("y1",d).attr("x2",r).attr("y2",d).attr("stroke-width",2).attr("stroke","black").attr("marker-end","url(#arrowhead)").attr("stroke-dasharray","5,5"),o=o+h+10}return o-a},"drawEvents"),dt={setConf:t(()=>{},"setConf"),draw:ct},ut=t(t=>{const{theme:r}=e(),a=r?.includes("dark"),s=i(r,t.borderColorArray),o=t.svgId?.replace(/^#/,"")??"",c=o?`url(#${o}-drop-shadow)`:t.dropShadow??"none";let l="";for(let e=0;e<n(t.THEME_COLOR_LIMIT);e++){const n=""+(17-3*e),i=s?t.borderColorArray[e%t.borderColorArray.length]:void 0,r=i??t.mainBkg,o=i??t.nodeBorder;l+=`\n .section-${e-1} rect,\n .section-${e-1} path,\n .section-${e-1} circle {\n fill: ${a&&s?t.mainBkg:r};\n stroke: ${o};\n stroke-width: ${t.strokeWidth};\n filter: ${c};\n }\n\n .section-${e-1} text {\n fill: ${t.nodeBorder};\n font-weight: ${t.fontWeight}\n }\n\n .node-icon-${e-1} {\n font-size: 40px;\n color: ${t["cScaleLabel"+e]};\n }\n\n .section-edge-${e-1} {\n stroke: ${t["cScale"+e]};\n }\n\n .edge-depth-${e-1} {\n stroke-width: ${n};\n }\n\n .section-${e-1} line {\n stroke: ${t["cScaleInv"+e]};\n stroke-width: 3;\n }\n\n .lineWrapper line {\n stroke: ${t.nodeBorder};\n stroke-width:${t.strokeWidth}\n }\n\n .disabled,\n .disabled circle,\n .disabled text {\n fill: ${t.tertiaryColor??"lightgray"};\n }\n\n .disabled text {\n fill: ${t.clusterBorder??"#efefef"};\n }\n `}return l},"genReduxSections"),pt=t(t=>{let e="";const i=n(t.THEME_COLOR_LIMIT);for(let n=0;n<i;n++)t["lineColor"+n]=t["lineColor"+n]??t["cScaleInv"+n],r(t["lineColor"+n])?t["lineColor"+n]=a(t["lineColor"+n],20):t["lineColor"+n]=s(t["lineColor"+n],20);for(let n=0;n<i;n++){const i=""+(17-3*n);e+=`\n .section-${n-1} rect, .section-${n-1} path, .section-${n-1} circle, .section-${n-1} path {\n fill: ${t["cScale"+n]};\n }\n .section-${n-1} text {\n fill: ${t["cScaleLabel"+n]};\n }\n .node-icon-${n-1} {\n font-size: 40px;\n color: ${t["cScaleLabel"+n]};\n }\n .section-edge-${n-1}{\n stroke: ${t["cScale"+n]};\n }\n .edge-depth-${n-1}{\n stroke-width: ${i};\n }\n .section-${n-1} line {\n stroke: ${t["cScaleInv"+n]} ;\n stroke-width: 3;\n }\n\n .lineWrapper line{\n stroke: ${t["cScaleLabel"+n]} ;\n }\n\n .disabled, .disabled circle, .disabled text {\n fill: ${t.tertiaryColor??"lightgray"};\n }\n .disabled text {\n fill: ${t.clusterBorder??"#efefef"};\n }\n `}return e},"genSections"),gt=t(t=>{const{theme:i}=e(),r=i?.includes("redux"),a="neutral"===i,s=t.svgId?.replace(/^#/,"")??"";let o="";if(t.useGradient&&s&&t.THEME_COLOR_LIMIT&&!a){const e=n(t.THEME_COLOR_LIMIT);for(let n=0;n<e;n++)o+=`\n .section-${n-1}[data-look="neo"] rect,\n .section-${n-1}[data-look="neo"] path,\n .section-${n-1}[data-look="neo"] circle {\n fill: ${t.mainBkg};\n stroke: url(#${s}-gradient);\n stroke-width: 2;\n }\n .section-${n-1}[data-look="neo"] line {\n stroke: url(#${s}-gradient);\n stroke-width: 2;\n }`}return`\n .edge {\n stroke-width: 3;\n }\n ${r?ut(t):pt(t)}\n ${o}\n .section-root rect, .section-root path, .section-root circle {\n fill: ${t.git0};\n }\n .section-root text {\n fill: ${t.gitBranchLabel0};\n }\n .icon-container {\n height:100%;\n display: flex;\n justify-content: center;\n align-items: center;\n }\n .edge {\n fill: none;\n }\n .eventWrapper {\n filter: brightness(120%);\n }\n`},"getStyles"),yt={db:b,renderer:{setConf:t(()=>{},"setConf"),draw:t((t,e,n,i)=>"TD"===(i?.db?.getDirection?.()??"LR")?dt.draw(t,e,n,i):st.draw(t,e,n,i),"draw")},parser:x,styles:gt};export{yt as diagram};
|