lookatstudy-mobile 0.31.2 → 0.31.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/package.json +1 -1
  2. package/server.cjs +57 -3
  3. package/web/assets/{CanvasStage-BbqLSbD4.js → CanvasStage-Ccxan7wh.js} +1 -1
  4. package/web/assets/{CommandPalette-DQ5w84ic.js → CommandPalette-D8HzDvja.js} +1 -1
  5. package/web/assets/{CourseSearchPanel-ThxY4JL1.js → CourseSearchPanel-Dp11zUeA.js} +1 -1
  6. package/web/assets/{ExamView-DVLRcljJ.js → ExamView-BkOpDSyH.js} +1 -1
  7. package/web/assets/{ReviewPanel-D1jKVMQK.js → ReviewPanel-CyvrUQ9n.js} +1 -1
  8. package/web/assets/{SettingsView-BHoTkY38.js → SettingsView-DWTo5AIC.js} +2 -2
  9. package/web/assets/{VoicePanel-BP1Ur7sF.js → VoicePanel-CZfLESc_.js} +1 -1
  10. package/web/assets/{abnfDiagram-VCTEODGH-Ca-5zS8J.js → abnfDiagram-VCTEODGH-CPRwAUhv.js} +1 -1
  11. package/web/assets/{abnfDiagram-VCTEODGH-ODA7YWAP-ZI6_0Jfq.js → abnfDiagram-VCTEODGH-ODA7YWAP-Dp2Ugi00.js} +1 -1
  12. package/web/assets/{architectureDiagram-5GKGNRK7-C4PU3XN7-B2bOUqy0.js → architectureDiagram-5GKGNRK7-C4PU3XN7-BSi9GIa8.js} +1 -1
  13. package/web/assets/{architectureDiagram-5GKGNRK7-DCEYr1uX.js → architectureDiagram-5GKGNRK7-CratLAN7.js} +1 -1
  14. package/web/assets/{arrow-right---oCZhx2.js → arrow-right-BsX3ZJnE.js} +1 -1
  15. package/web/assets/{blockDiagram-I7D4REHJ-Dx9xiTwp.js → blockDiagram-I7D4REHJ-D53LWAaI.js} +1 -1
  16. package/web/assets/{blockDiagram-NRAW4CY4-UMJ6PMQQ-Do5yGQuh.js → blockDiagram-NRAW4CY4-UMJ6PMQQ-ydsf1o4S.js} +1 -1
  17. package/web/assets/{c4Diagram-7LVT6UL2-DXh9Ebug.js → c4Diagram-7LVT6UL2-zyk0vkS1.js} +1 -1
  18. package/web/assets/{c4Diagram-UCG6FXSJ-75X3U2P3-DH7ShBLp.js → c4Diagram-UCG6FXSJ-75X3U2P3-DoTJpJZT.js} +1 -1
  19. package/web/assets/channel-D1pzr5s8.js +1 -0
  20. package/web/assets/{chunk-2Q5K7J3B-Bbluh_im.js → chunk-2Q5K7J3B-Bb-Fbn7J.js} +1 -1
  21. package/web/assets/{chunk-5VM5RSS4-CwJZ1eAQ.js → chunk-5VM5RSS4-BUnm5mZw.js} +1 -1
  22. package/web/assets/{chunk-7XDTSPCN-3TtQfLC2.js → chunk-7XDTSPCN-BJpcbmYi.js} +1 -1
  23. package/web/assets/{chunk-CTNIYPP6--48noAMq.js → chunk-CTNIYPP6-_5LkeW58.js} +1 -1
  24. package/web/assets/{chunk-CXNFBKHE-BMfLUSYr.js → chunk-CXNFBKHE-Cl_w1xK3.js} +1 -1
  25. package/web/assets/{chunk-F27PBJKO-DQz5Eh8R.js → chunk-F27PBJKO-DOnNDX_T.js} +1 -1
  26. package/web/assets/{chunk-IMKFNOWR-mEHtzDJe.js → chunk-IMKFNOWR-DcOUgIY6.js} +1 -1
  27. package/web/assets/{chunk-ISA7TJRJ-Cua7d2fi.js → chunk-ISA7TJRJ-4ehz2eVS.js} +1 -1
  28. package/web/assets/{chunk-JWPE2WC7-DqWkk9f8.js → chunk-JWPE2WC7-gdjQngWd.js} +1 -1
  29. package/web/assets/{chunk-LV3HUYFY-BCzMQT8Q.js → chunk-LV3HUYFY-0dwD8rCC.js} +1 -1
  30. package/web/assets/{chunk-M3IUQBOH-B-r9ydC6.js → chunk-M3IUQBOH-kelT6RI-.js} +1 -1
  31. package/web/assets/{chunk-NDIOYS4C-DkAwrWHj.js → chunk-NDIOYS4C-DO0anlkR.js} +1 -1
  32. package/web/assets/{chunk-POPQ4Y6H-BjpioqkZ.js → chunk-POPQ4Y6H-v0VjJgg_.js} +1 -1
  33. package/web/assets/{chunk-RE4WF27V-CJEnGv6g.js → chunk-RE4WF27V-DxIwGJut.js} +1 -1
  34. package/web/assets/{chunk-SVP7TREG-DGaiaQgi.js → chunk-SVP7TREG-L0IIA3ui.js} +1 -1
  35. package/web/assets/{chunk-TICWLB2K-DqXyoflV.js → chunk-TICWLB2K-DGxX8kin.js} +1 -1
  36. package/web/assets/{chunk-VII2H2IX-CHqS8QXi.js → chunk-VII2H2IX-CPilSdxU.js} +1 -1
  37. package/web/assets/{chunk-X5GNSKZ3-CPiurspk.js → chunk-X5GNSKZ3-C6884RNs.js} +1 -1
  38. package/web/assets/{chunk-XCWWM2C3-CnpRc-BX.js → chunk-XCWWM2C3-CqqN87BO.js} +1 -1
  39. package/web/assets/{chunk-XXDRQBXY-xXPgDheN.js → chunk-XXDRQBXY-DWCWq3oG.js} +1 -1
  40. package/web/assets/classDiagram-DTDB5LWJ-LWRDKZ5K-bHJ5LzCU.js +1 -0
  41. package/web/assets/classDiagram-ZZMXUADV-B1mvkdHx.js +1 -0
  42. package/web/assets/classDiagram-v2-JRS7N3AN-2BZHGRP2-bHJ5LzCU.js +1 -0
  43. package/web/assets/classDiagram-v2-VYDZK3BY-B1mvkdHx.js +1 -0
  44. package/web/assets/{core-iYZpQJa6.js → core-4rNLJNcM.js} +1 -1
  45. package/web/assets/{cose-bilkent-JH36ORCC-Dr_WUhVB.js → cose-bilkent-JH36ORCC-BRAHxXkx.js} +1 -1
  46. package/web/assets/{cose-bilkent-JH36ORCC-OB24KH3T-CQsWVK5X.js → cose-bilkent-JH36ORCC-OB24KH3T-PEuVsnbK.js} +1 -1
  47. package/web/assets/{cynefin-OW5HDTMX-fybCqBi3.js → cynefin-OW5HDTMX-B96xQPn_.js} +1 -1
  48. package/web/assets/{cynefin-OW5HDTMX-GVF3BKWE-DwLRaQ37.js → cynefin-OW5HDTMX-GVF3BKWE-CmwiFdFp.js} +1 -1
  49. package/web/assets/{cynefinDiagram-5FMLGOSQ-H3WIRU3N-D7Mzcgjs.js → cynefinDiagram-5FMLGOSQ-H3WIRU3N-BS4Rn_lU.js} +1 -1
  50. package/web/assets/{cynefinDiagram-5FMLGOSQ-BLqywzF8.js → cynefinDiagram-5FMLGOSQ-WsNJrzND.js} +1 -1
  51. package/web/assets/{dagre-3AP2YEHR-DCERTXHT-C3dpohva.js → dagre-3AP2YEHR-DCERTXHT-DqLa7f22.js} +1 -1
  52. package/web/assets/{dagre-GXQ25YYZ-QPjECY_W.js → dagre-GXQ25YYZ-ChTZSRWH.js} +1 -1
  53. package/web/assets/{diagram-S7CK7UJ4-CwZRApeF.js → diagram-S7CK7UJ4-Cte8nBIL.js} +1 -1
  54. package/web/assets/{diagram-S7CK7UJ4-MULGZGEL-Czqn_Fna.js → diagram-S7CK7UJ4-MULGZGEL-DrYBAuoV.js} +1 -1
  55. package/web/assets/{diagram-UQ7AKVKN-Bo8gzrdx.js → diagram-UQ7AKVKN-BdhZy6LW.js} +1 -1
  56. package/web/assets/{diagram-UQ7AKVKN-YQBY353J-CgDXcRAT.js → diagram-UQ7AKVKN-YQBY353J-SIQXtTtG.js} +1 -1
  57. package/web/assets/{diagram-VSXAHHWV-0w4db5zY.js → diagram-VSXAHHWV-C9IXdf46.js} +1 -1
  58. package/web/assets/{diagram-VSXAHHWV-WLNH2ELY-DbTl04rE.js → diagram-VSXAHHWV-WLNH2ELY-eoBcSKFt.js} +1 -1
  59. package/web/assets/{diagram-VX7I27RA-DJvH_pmt.js → diagram-VX7I27RA-CFTomYjh.js} +1 -1
  60. package/web/assets/{diagram-VX7I27RA-XW6YQV5G-fzWHr6UJ.js → diagram-VX7I27RA-XW6YQV5G-Bd1uZFA4.js} +1 -1
  61. package/web/assets/{diagram-Z3DM3KII-DsT5qGVe.js → diagram-Z3DM3KII-Dqfg4VTQ.js} +1 -1
  62. package/web/assets/{diagram-Z3DM3KII-HG7RF65D-CDqb1-LL.js → diagram-Z3DM3KII-HG7RF65D-BwiG8Jl0.js} +1 -1
  63. package/web/assets/{ebnfDiagram-PWID7BFC-BoB0yBxV.js → ebnfDiagram-PWID7BFC-Cxj0Vv3C.js} +1 -1
  64. package/web/assets/{ebnfDiagram-PWID7BFC-OKY4VHYD-Dl7tZHv0.js → ebnfDiagram-PWID7BFC-OKY4VHYD-CBeGh1kf.js} +1 -1
  65. package/web/assets/{erDiagram-RLTQ6QDP-TcPkrxxF.js → erDiagram-RLTQ6QDP-g318DvBL.js} +1 -1
  66. package/web/assets/{erDiagram-SSCWMZ5O-PIPKOIK7-C13XODn3.js → erDiagram-SSCWMZ5O-PIPKOIK7-B-Gfdf5U.js} +1 -1
  67. package/web/assets/{flowDiagram-A5DVABFB-2Z4AVO5R-DNbmNTnm.js → flowDiagram-A5DVABFB-2Z4AVO5R-CCYPuJH_.js} +1 -1
  68. package/web/assets/{flowDiagram-HODETNUW-D2o5XxIm.js → flowDiagram-HODETNUW-B9oC9dAn.js} +1 -1
  69. package/web/assets/{ganttDiagram-EL5Y4UJY-JZNG7GOG-C5IgtJLL.js → ganttDiagram-EL5Y4UJY-JZNG7GOG-7FynKk0s.js} +1 -1
  70. package/web/assets/{ganttDiagram-EL5Y4UJY-D36iMZvH.js → ganttDiagram-EL5Y4UJY-hu6hQzSA.js} +1 -1
  71. package/web/assets/{gitGraphDiagram-WWUBYQGX-DMWMLL3G-BA7YVBKU.js → gitGraphDiagram-WWUBYQGX-DMWMLL3G-CLS0NrEQ.js} +1 -1
  72. package/web/assets/{gitGraphDiagram-WWUBYQGX-DoayvLMW.js → gitGraphDiagram-WWUBYQGX-yTtXkuKU.js} +1 -1
  73. package/web/assets/{index-DtMB_WdP.js → index-BTHtdpYN.js} +1 -1
  74. package/web/assets/{index-Zmq94tKz.js → index-Brv5KtDR.js} +3 -3
  75. package/web/assets/{index-5UvRMS_e.js → index-DJ_vjgYj.js} +1 -1
  76. package/web/assets/{infoDiagram-27XIBGKW-DbMBXMvx.js → infoDiagram-27XIBGKW-c42LSbRO.js} +1 -1
  77. package/web/assets/{infoDiagram-RXCK75RN-HANS5KVC-NdEBDyb0.js → infoDiagram-RXCK75RN-HANS5KVC-CVdQLogu.js} +1 -1
  78. package/web/assets/{ishikawaDiagram-5VMMS53U-7GCIT7WU-CzqV69s-.js → ishikawaDiagram-5VMMS53U-7GCIT7WU-BE12eSht.js} +1 -1
  79. package/web/assets/{ishikawaDiagram-5VMMS53U-j9THtiQE.js → ishikawaDiagram-5VMMS53U-DzJncJmv.js} +1 -1
  80. package/web/assets/{journeyDiagram-3NMN7TZE-C3h3msUP.js → journeyDiagram-3NMN7TZE-wTWsGARh.js} +1 -1
  81. package/web/assets/{journeyDiagram-EYS64GPL-OAPELBT7-ChETfPiS.js → journeyDiagram-EYS64GPL-OAPELBT7-DYBkNRJQ.js} +1 -1
  82. package/web/assets/{kanban-definition-3QL26DDD-I7RKWQQY-Wjr70XLu.js → kanban-definition-3QL26DDD-I7RKWQQY-DXa9FemT.js} +1 -1
  83. package/web/assets/{kanban-definition-UXKFOSKX-C1b6cL5N.js → kanban-definition-UXKFOSKX-M71sF3uC.js} +1 -1
  84. package/web/assets/{katex-N6JRN4PM-BIpBcqrZ.js → katex-N6JRN4PM-vlvahC1J.js} +1 -1
  85. package/web/assets/{layout-D2XzcM9d.js → layout-CDVV66Zl.js} +1 -1
  86. package/web/assets/{main-Dj875aWF.js → main-CmX_gEtO.js} +8 -8
  87. package/web/assets/{mermaid-layout-elk.core-CNNSrMhF.js → mermaid-layout-elk.core-VAQhTNif.js} +2 -2
  88. package/web/assets/{mermaid.core-CnNeOEec.js → mermaid.core-BBr71c1E.js} +5 -5
  89. package/web/assets/{mindmap-definition-FBJOCRG2-KIYZG64Y-CE91aZQc.js → mindmap-definition-FBJOCRG2-KIYZG64Y-BJs0jBiv.js} +1 -1
  90. package/web/assets/{mindmap-definition-YA3MSWOX-Dz0JwUgH.js → mindmap-definition-YA3MSWOX-5jMWortW.js} +1 -1
  91. package/web/assets/{pegDiagram-XKGWAZYB-BEOg8IHd.js → pegDiagram-XKGWAZYB-DWJAfH3i.js} +1 -1
  92. package/web/assets/{pegDiagram-XKGWAZYB-OIP57N6J-CB6_i_dk.js → pegDiagram-XKGWAZYB-OIP57N6J-SoiZ0uez.js} +1 -1
  93. package/web/assets/{pieDiagram-E7YTZNPT-2UOTW327-C_aP-GDD.js → pieDiagram-E7YTZNPT-2UOTW327-4wOQMxnh.js} +1 -1
  94. package/web/assets/{pieDiagram-E7YTZNPT-Btcl-uz0.js → pieDiagram-E7YTZNPT-CcLjyCkM.js} +1 -1
  95. package/web/assets/{quadrantDiagram-AXDQQJYC-CA7HBTBO.js → quadrantDiagram-AXDQQJYC-Df75lDtG.js} +1 -1
  96. package/web/assets/{quadrantDiagram-AXDQQJYC-SN3ASJJK-CAd5tIhG.js → quadrantDiagram-AXDQQJYC-SN3ASJJK-CTIClnUv.js} +1 -1
  97. package/web/assets/{railroadDiagram-O6MQD6OU-34742W6X-CLWiLZG6.js → railroadDiagram-O6MQD6OU-34742W6X-BUdIAX73.js} +1 -1
  98. package/web/assets/{railroadDiagram-O6MQD6OU-B7dkMwzi.js → railroadDiagram-O6MQD6OU-CGPAxOfe.js} +1 -1
  99. package/web/assets/{render-O7CIS3YK-DQb_czkx.js → render-O7CIS3YK-BysEI-dU.js} +7 -7
  100. package/web/assets/{requirementDiagram-BXWQKSXE-C70GJhMZ.js → requirementDiagram-BXWQKSXE-DmpSPAPs.js} +1 -1
  101. package/web/assets/{requirementDiagram-EFPCY7ZU-NGAFFSMB-Bc0CRxi2.js → requirementDiagram-EFPCY7ZU-NGAFFSMB-C658Njt8.js} +1 -1
  102. package/web/assets/{rotate-ccw-JEjtXKlH.js → rotate-ccw-D1E9nBsz.js} +1 -1
  103. package/web/assets/{sankeyDiagram-P5KCCOFB-3D3M4XPB-B9PL6--N.js → sankeyDiagram-P5KCCOFB-3D3M4XPB-0LGs5Ekr.js} +1 -1
  104. package/web/assets/{sankeyDiagram-P5KCCOFB-BJl2AqaQ.js → sankeyDiagram-P5KCCOFB-8tWaAOQW.js} +1 -1
  105. package/web/assets/{sequenceDiagram-WJ2MYXX4-DtmTM2Q1.js → sequenceDiagram-WJ2MYXX4-Cu8XQLW7.js} +1 -1
  106. package/web/assets/{sequenceDiagram-WJ2MYXX4-Q2IOPB4R-DH1L8a7Q.js → sequenceDiagram-WJ2MYXX4-Q2IOPB4R-Do020RsJ.js} +1 -1
  107. package/web/assets/{sizeCapture-INFHLROL-e9akerky.js → sizeCapture-INFHLROL-C4il96Zo.js} +1 -1
  108. package/web/assets/{sizeCapture-X5ZJPWSS-PSGVOMYM-CSyLq32l.js → sizeCapture-X5ZJPWSS-PSGVOMYM-Dl4mKOl5.js} +1 -1
  109. package/web/assets/{stateDiagram-D77RDMKH-Dc057ccO.js → stateDiagram-D77RDMKH-DZehEkpF.js} +1 -1
  110. package/web/assets/{stateDiagram-HBIQ2CUA-4M2S6MAN-D_uV5i1Q.js → stateDiagram-HBIQ2CUA-4M2S6MAN-CVgF7-_1.js} +1 -1
  111. package/web/assets/stateDiagram-v2-4QOOHH4V-LBBLA2WV-Bte2wVWv.js +1 -0
  112. package/web/assets/stateDiagram-v2-MP3YSRHH-v1GXQ5wD.js +1 -0
  113. package/web/assets/{swimlanes-42K2YHIH-ILKBiMPk.js → swimlanes-42K2YHIH-BQWg4acA.js} +1 -1
  114. package/web/assets/{swimlanes-XN3QIQJK-N6N2CCQ6-CJ7qUhPg.js → swimlanes-XN3QIQJK-N6N2CCQ6-DekhJu9e.js} +1 -1
  115. package/web/assets/swimlanesDiagram-VK2B7HYN-E6N4H5SY-zx5EFXza.js +8 -0
  116. package/web/assets/swimlanesDiagram-VR7AAH4N-BQyNIwz7.js +8 -0
  117. package/web/assets/{timeline-definition-24CTP7MA-BckRkRye.js → timeline-definition-24CTP7MA-BT6KUlBa.js} +1 -1
  118. package/web/assets/{timeline-definition-24CTP7MA-KN7RSRVM-DxSbNuQs.js → timeline-definition-24CTP7MA-KN7RSRVM-Du30VadP.js} +1 -1
  119. package/web/assets/{vennDiagram-4TSXK5OY-AKJ7LXAN-hG9roRh0.js → vennDiagram-4TSXK5OY-AKJ7LXAN-DQjUgbCT.js} +1 -1
  120. package/web/assets/{vennDiagram-4TSXK5OY-Bxkq0y0p.js → vennDiagram-4TSXK5OY-DTkmcJDL.js} +1 -1
  121. package/web/assets/{wardleyDiagram-VM6X3IG4-3B6A3BN5-CLmKLRJP.js → wardleyDiagram-VM6X3IG4-3B6A3BN5-BDk6JeO1.js} +1 -1
  122. package/web/assets/{wardleyDiagram-VM6X3IG4-CaTbamBI.js → wardleyDiagram-VM6X3IG4-C-NFt9uI.js} +1 -1
  123. package/web/assets/{xychartDiagram-S5SC5T6Z-CHtC3u6M.js → xychartDiagram-S5SC5T6Z-CxTqubEh.js} +1 -1
  124. package/web/assets/{xychartDiagram-S5SC5T6Z-OBDNV6WG-ZjDcqfTl.js → xychartDiagram-S5SC5T6Z-OBDNV6WG-CcfG2mA9.js} +1 -1
  125. package/web/index.html +1 -1
  126. package/web/assets/channel-CNRWz7VW.js +0 -1
  127. package/web/assets/classDiagram-DTDB5LWJ-LWRDKZ5K-C5s2iR9J.js +0 -1
  128. package/web/assets/classDiagram-ZZMXUADV-Cjli-tvb.js +0 -1
  129. package/web/assets/classDiagram-v2-JRS7N3AN-2BZHGRP2-C5s2iR9J.js +0 -1
  130. package/web/assets/classDiagram-v2-VYDZK3BY-Cjli-tvb.js +0 -1
  131. package/web/assets/stateDiagram-v2-4QOOHH4V-LBBLA2WV-DBkBTIqA.js +0 -1
  132. package/web/assets/stateDiagram-v2-MP3YSRHH-D6iIkIH3.js +0 -1
  133. package/web/assets/swimlanesDiagram-VK2B7HYN-E6N4H5SY-lkgr5sGZ.js +0 -8
  134. package/web/assets/swimlanesDiagram-VR7AAH4N-D-ke9u7H.js +0 -8
@@ -1 +1 @@
1
- import{aO as wr,l as To,_ as f,aW as dr}from"./render-O7CIS3YK-DQb_czkx.js";import"./transform-Bd_a5eGM.js";import{_ as w}from"./mermaid-layout-elk.core-CNNSrMhF.js";import"./main-Dj875aWF.js";import"./index-CJuEfFQr.js";import"./_commonjs-dynamic-modules-TDtrdbi3.js";var fr=5,cn=1e-5,an=1e-6;function Ye(t){const e=[];for(let n=0;n<t.length-1;n++)e.push({a:t[n],b:t[n+1]});return e}w(Ye,"buildSegmentList");f(Ye,"buildSegmentList");function Eo(t,e,n,o){const s=e.x-t.x,r=e.y-t.y,d=o.x-n.x,a=o.y-n.y,l=s*a-r*d;if(l===0)return null;const c=n.x-t.x,g=n.y-t.y,y=(c*a-g*d)/l,S=(c*r-g*s)/l;return y<=an||y>=1-an||S<=an||S>=1-an?null:{point:{x:t.x+y*s,y:t.y+y*r},tA:y,tB:S}}w(Eo,"segmentIntersection");f(Eo,"segmentIntersection");function un(t){return Math.abs(t.b.x-t.a.x)>=Math.abs(t.b.y-t.a.y)}w(un,"isHorizontalSeg");f(un,"isHorizontalSeg");function wo(t){const e=[];for(let n=0;n<t.length;n++){const o=t[n],s=Ye(o.points);for(let r=n+1;r<t.length;r++){const d=t[r],a=Ye(d.points);for(const[l,c]of s.entries())for(const[g,y]of a.entries()){const S=Eo(c.a,c.b,y.a,y.b);if(!S)continue;const u=un(c),h=un(y);(u!==h?u:!1)?e.push({jumpEdgeId:o.id,otherEdgeId:d.id,segIndex:l,t:S.tA,point:S.point}):e.push({jumpEdgeId:d.id,otherEdgeId:o.id,segIndex:g,t:S.tB,point:S.point})}}}return e}w(wo,"findEdgeIntersections");f(wo,"findEdgeIntersections");function le(t){const e=Math.round(t*1e3)/1e3;return Number.isInteger(e)?`${e}`:`${e}`}w(le,"fmt");f(le,"fmt");function Ee(t){return`${le(t.x)},${le(t.y)}`}w(Ee,"pointToString");f(Ee,"pointToString");function Ro(t){const e=t.b.x-t.a.x,n=t.b.y-t.a.y;return Math.abs(e)>=Math.abs(n)?e>=0?1:0:n>=0?1:0}w(Ro,"getArcSweepFlag");f(Ro,"getArcSweepFlag");var Rr=.001;function Ao(t,e){if(t.length<2)return t.map(r=>({...r}));const n=t.map(r=>({...r})),o=e.arrowTypeStart&&dr[e.arrowTypeStart];if(o){const r=t[0],d=t[1],a=Math.atan2(d.y-r.y,d.x-r.x);n[0].x=r.x+o*Math.cos(a),n[0].y=r.y+o*Math.sin(a)}const s=e.arrowTypeEnd&&dr[e.arrowTypeEnd];if(s){const r=t.length,d=t[r-2],a=t[r-1],l=Math.atan2(a.y-d.y,a.x-d.x);n[r-1].x=a.x-s*Math.cos(l),n[r-1].y=a.y-s*Math.sin(l)}return n}w(Ao,"applyMarkerOffsets");f(Ao,"applyMarkerOffsets");function Oo(t,e,n,o,s){const r=t.point.x,d=t.point.y,a={x:r-e*t.r,y:d-n*t.r},l={x:r+e*t.r,y:d+n*t.r},c=[`L${Ee(a)}`];return s==="arc"?c.push(`A${le(t.r)},${le(t.r)} 0 0 ${o} ${Ee(l)}`):c.push(`M${Ee(l)}`),c}w(Oo,"emitJump");f(Oo,"emitJump");function hn(t,e,n,o){const s=e.x-t.x,r=e.y-t.y,d=n.x-e.x,a=n.y-e.y,l=Math.hypot(s,r),c=Math.hypot(d,a);if(l<cn||c<cn)return null;const g=s/l,y=r/l,S=d/c,u=a/c,h=g*S+y*u,i=Math.max(-1,Math.min(1,h)),x=Math.acos(i);if(x<cn||Math.abs(Math.PI-x)<cn)return null;const C=Math.min(o/Math.sin(x/2),l/2,c/2);return{startX:e.x-g*C,startY:e.y-y*C,endX:e.x+S*C,endY:e.y+u*C,ctrlX:e.x,ctrlY:e.y,cutLen:C}}w(hn,"computeRoundedCorner");f(hn,"computeRoundedCorner");function No(t,e,n){const o=t.points;if(o.length<2)return"";const s=Ao(o,t),r=t.curve==="rounded",d=Ye(s),a=new Map;for(const c of e){const g=d[c.segIndex];if(!g)continue;const y=Math.hypot(g.b.x-g.a.x,g.b.y-g.a.y),S=a.get(c.segIndex)??[];S.push({t:c.t,point:c.point,d:c.t*y,r:n.jumpRadius}),a.set(c.segIndex,S)}const l=[`M${Ee(s[0])}`];for(let c=0;c<d.length;c++){const g=d[c],y=Math.hypot(g.b.x-g.a.x,g.b.y-g.a.y),S=y===0?0:(g.b.x-g.a.x)/y,u=y===0?0:(g.b.y-g.a.y)/y,h=Ro(g);let i=0;if(r&&c>0){const v=hn(s[c-1],s[c],s[c+1]??s[c],fr);v&&(i=v.cutLen)}let x=y,C=null;r&&c<d.length-1&&(C=hn(s[c],s[c+1],s[c+2]??s[c+1],fr),C&&(x=y-C.cutLen));const b=[...a.get(c)??[]].sort((v,L)=>v.t-L.t);for(const v of b)v.r=Math.min(v.r,v.d-i,x-v.d);for(let v=0;v<b.length-1;v++){const L=b[v+1].d-b[v].d;if(b[v].r+b[v+1].r>L){const p=L/2;b[v].r=Math.min(b[v].r,p),b[v+1].r=Math.min(b[v+1].r,p)}}for(const v of b)v.r<Rr||l.push(...Oo(v,S,u,h,n.jumpStyle));r&&C?(l.push(`L${le(C.startX)},${le(C.startY)}`),l.push(`Q${le(C.ctrlX)},${le(C.ctrlY)} ${le(C.endX)},${le(C.endY)}`)):l.push(`L${Ee(g.b)}`)}return l.join(" ")}w(No,"rewriteEdgePath");f(No,"rewriteEdgePath");function Bo(t){return/^[\d\s+,.LMelm-]*$/.test(t)}w(Bo,"isStraightPath");f(Bo,"isStraightPath");function Po(t){return t?t==="linear"||t==="rounded"||t==="step"||t==="stepBefore"||t==="stepAfter":!0}w(Po,"curveSupportsLineHops");f(Po,"curveSupportsLineHops");function ko(t){if(!t)return null;try{const e=typeof atob=="function"?atob(t):Buffer.from(t,"base64").toString(),n=JSON.parse(e);if(!Array.isArray(n))return null;const o=[];for(const s of n)s&&typeof s.x=="number"&&typeof s.y=="number"&&o.push({x:s.x,y:s.y});return o.length>=2?o:null}catch{return null}}w(ko,"decodeDataPoints");f(ko,"decodeDataPoints");function Fo(t,e,n){if(!n.enabled)return;const o=t.node();if(!o)return;const s=new Map;for(const c of e)s.set(c.id,c);const r=[],d=new Map;for(const c of e){const g=typeof CSS<"u"&&CSS.escape?CSS.escape(c.id):c.id,y=o.querySelector(`path[data-id="${g}"]`);if(!y)continue;d.set(c.id,y);const u=ko(y.getAttribute("data-points"))??c.points;r.push({...c,points:u})}const a=wo(r);if(a.length===0)return;const l=new Map;for(const c of a){const g=l.get(c.jumpEdgeId)??[];g.push(c),l.set(c.jumpEdgeId,g)}for(const c of r){const g=l.get(c.id);if(!g||g.length===0)continue;const y=s.get(c.id),S=y==null?void 0:y.curve;if(S!==void 0&&!Po(S))continue;const u=d.get(c.id);if(!u)continue;if(S===void 0){const v=u.getAttribute("d")??"";if(!Bo(v))continue}const h=u.getAttribute("style")??"",i=/stroke-dasharray\s*:\s*0\s+([\d.]+)\s+[\d.]+\s+([\d.]+)/.exec(h),x=i?Number.parseFloat(i[1]):null,C=i?Number.parseFloat(i[2]):null,b=No(c,g,n);if(u.setAttribute("d",b),x!==null&&C!==null&&typeof u.getTotalLength=="function"){const v=u.getTotalLength(),L=Math.max(0,v-x-C),p=`0 ${x} ${L} ${C}`,M=h.replace(/stroke-dasharray\s*:[^;]*;?/g,`stroke-dasharray: ${p};`).replace(/;\s*;+/g,";");u.setAttribute("style",M)}}}w(Fo,"applyLineJumpsToSvg");f(Fo,"applyLineJumpsToSvg");function _o(t,{measure:e}){var r,d;const n=(d=(r=t.config)==null?void 0:r.swimlane)==null?void 0:d.lineHops;if(n===!1)return;const o=n==="gap"?"gap":"arc",s=t.edges.filter(a=>Array.isArray(a.points)&&a.points.length>=2).map(a=>({id:a.id,points:a.points,curve:a.curve,arrowTypeStart:a.arrowTypeStart,arrowTypeEnd:a.arrowTypeEnd}));Fo(e.groups.edgePaths,s,{enabled:!0,jumpRadius:6,jumpStyle:o})}w(_o,"applySwimlaneLineJumps");f(_o,"applySwimlaneLineJumps");var Io="__swimlane_default__",Ar=21,ur=20;function gn(t){return Math.max(t.padding??ur,ur)}w(gn,"topLaneHorizontalPadding");f(gn,"topLaneHorizontalPadding");function Do(t){const{x:e,y:n,width:o,height:s}=t,r=t.swimlaneContentTop;if(typeof e!="number"||typeof n!="number"||typeof o!="number"||typeof s!="number"||typeof r!="number"||!Number.isFinite(e)||!Number.isFinite(n)||!Number.isFinite(o)||!Number.isFinite(s)||!Number.isFinite(r)||o<=0||s<=0){delete t.groupTitleRect;return}const d=n-s/2,a=Math.min(r,n+s/2),l=Math.min(Ar,Math.max(0,a-d)),c=d+l;if(c<=d){delete t.groupTitleRect;return}t.groupTitleRect={left:e-o/2,right:e+o/2,top:d,bottom:c}}w(Do,"assignTopLaneTitleRect");f(Do,"assignTopLaneTitleRect");function Ho(t){const e=t.direction,n=t.nodes??(t.nodes=[]);for(const r of t.nodes??[])r.isGroup&&!r.parentId&&(r.shape="swimlane",e&&(r.direction=e));const o=n.filter(r=>!r.isGroup&&!r.parentId);if(o.length===0)return;let s=n.find(r=>r.id===Io);s?s.isGroup&&(s.shape="swimlane",e&&(s.direction=e)):(s={id:Io,label:"",isGroup:!0,shape:"swimlane",padding:20,...e?{direction:e}:{}},n.push(s));for(const r of o)r.parentId=Io}w(Ho,"prepareLayoutForSwimlanes");f(Ho,"prepareLayoutForSwimlanes");function Xo(t){const e=new Map;for(const l of t.nodes??[])e.set(l.id,l);const n=[];for(const l of t.edges??[]){const c=typeof l.start=="string"?l.start:void 0,g=typeof l.end=="string"?l.end:void 0;!c||!g||l.labelNodeId||n.push({id:l.id,src:c,dst:g,ref:l})}const o=t.nodes??[],s=o.filter(l=>l.isGroup),r=o.filter(l=>!l.isGroup);return{nodes:[...[...s].reverse(),...r].map(l=>l.id),edges:n,layout:t,nodeById:e}}w(Xo,"toGraphView");f(Xo,"toGraphView");function Yo(t,e,n,o){const{layout:s}=t,r=t.nodeById,d=(o==null?void 0:o.layerGap)??100,a=(o==null?void 0:o.nodeGap)??40;let l=0;for(const S of e.layers){let u=0;for(const h of S){const i=r.get(h);if(!i){u++;continue}i.layer=l,i.order=u;const x=n.x[h]??u*a,C=n.y[h]??l*d;i.x=x,i.y=C,u++}l++}const c=s.nodes??[],g=new Map,y=[];for(const S of c){if(!(S!=null&&S.isGroup))continue;S.parentId||y.push(S);const u=c.filter(b=>b.parentId===S.id);let h=1/0,i=-1/0,x=1/0,C=-1/0;for(const b of u){const v=b.x??n.x[b.id],L=b.y??n.y[b.id],p=b.width??0,M=b.height??0;v!=null&&L!=null&&(h=Math.min(h,v-p/2),i=Math.max(i,v+p/2),x=Math.min(x,L-M/2),C=Math.max(C,L+M/2))}if(h===1/0||x===1/0)S.x=S.x??0,S.y=S.y??0,S.width=S.width??0,S.height=S.height??0;else{const b=S.padding??20,v=S.parentId?b:2*gn(S),L=b,p=Math.max(0,i-h)+v,M=Math.max(0,C-x)+L,T=(h+i)/2,A=(x+C)/2;S.x=T,S.y=A,S.width=p,S.height=M,g.set(S.id,{minX:h,maxX:i,minY:x,maxY:C})}}if(y.length>0&&g.size>0){let S=1/0,u=-1/0,h=0;for(const i of y){const x=i.padding??20;x>h&&(h=x);const C=g.get(i.id);C&&(S=Math.min(S,C.minY),u=Math.max(u,C.maxY))}if(S!==1/0&&u!==-1/0){const i=Math.max(0,u-S),C=Math.max(h,36),b=i+2*C,v=(S+u)/2;for(const k of y)k.y=v,k.height=b,k.swimlaneContentTop=S;const L=[...y].sort((k,B)=>{const F=k.x??0,X=B.x??0;return F-X}),p=[],M=[],T=[];for(const k of L){const B=g.get(k.id);if(!B)continue;const F=Math.max(0,B.maxX-B.minX)+2*gn(k),X=(B.minX+B.maxX)/2;p.push(k.id),M.push(X),T.push(F)}const A=p.length;if(A>0){const k=new Map;if(A===1)k.set(p[0],T[0]);else{const B=[];for(let U=0;U<A-1;U++)B.push(M[U+1]-M[U]);const F=new Array(A);F[0]=0;for(let U=0;U<A-1;U++)F[U+1]=2*B[U]-F[U];let X=0,P=Number.POSITIVE_INFINITY;for(let U=0;U<A;U++){const et=T[U];U%2===0?X=Math.max(X,et-F[U]):P=Math.min(P,F[U]-et)}let z=X;X<=P?z=(X+P)/2:z=X;for(let U=0;U<A;U++){const et=F[U]+(U%2===0?z:-z),ft=Math.max(T[U],et);k.set(p[U],ft)}}for(const B of y){const F=k.get(B.id);F!=null&&(B.width=F),Do(B)}}}}}w(Yo,"writeBackToLayoutData");f(Yo,"writeBackToLayoutData");var Or="[EdgeLabelNodes]";function Go(t){const e=[],n=[],o=new Map;for(const d of t.nodes)o.set(d.id,d);for(const d of t.edges){if(!d.label||d.label.length===0||d.isLayoutOnly||d.labelNodeId)continue;const a=d.start?o.get(d.start):void 0,l=d.end?o.get(d.end):void 0;if(!a||!l){To.warn(Or,`Edge ${d.id} has missing source or target node`);continue}const c=`edge-label-${d.start}-${d.end}-${d.id}`,y=a.parentId!==l.parentId?l.parentId:a.parentId,S={id:c,label:d.label,edgeStart:d.start??"",edgeEnd:d.end??"",shape:"labelRect",width:0,height:0,isEdgeLabel:!0,isDummy:!0,parentId:y,isGroup:!1,labelStyle:Array.isArray(d.labelStyle)?d.labelStyle[0]:d.labelStyle??"",...a.dir?{dir:a.dir}:{}};e.push(S),d.labelNodeId=c,d.label=void 0,d.text=void 0;const u={id:`${d.id}-to-label`,start:d.start,end:c,type:"normal",isLayoutOnly:!0},h={id:`${d.id}-from-label`,start:c,end:d.end,type:"normal",isLayoutOnly:!0};n.push(u,h)}const s=[...t.nodes,...e],r=[...t.edges,...n];return{...t,nodes:s,edges:r}}w(Go,"createEdgeLabelNodes");f(Go,"createEdgeLabelNodes");var Gt=.001;function jn(t){const e=t.x??0,n=t.y??0,o=t.width??0,s=t.height??0;return o>0&&s>0?{cx:e,cy:n,rect:we(e,n,o,s)}:void 0}w(jn,"measuredNodeRect");f(jn,"measuredNodeRect");function Un(t){if(t.isGroup)return;const e=jn(t);return e?{id:String(t.id??""),cx:e.cx,cy:e.cy,rect:e.rect}:void 0}w(Un,"nodeBoundsInfoFor");f(Un,"nodeBoundsInfoFor");function re(t,e,n=Gt){return Math.abs(t.x-e.x)<n&&Math.abs(t.y-e.y)<n}w(re,"samePoint");f(re,"samePoint");function gt(t,e,n=Gt){return Math.abs(t.x-e.x)<n}w(gt,"sameX");f(gt,"sameX");function pt(t,e,n=Gt){return Math.abs(t.y-e.y)<n}w(pt,"sameY");f(pt,"sameY");function At(t,e,n=Gt){return pt(t,e,n)&&Math.abs(t.x-e.x)>n}w(At,"isHorizontalSegment");f(At,"isHorizontalSegment");function Ot(t,e,n=Gt){return gt(t,e,n)&&Math.abs(t.y-e.y)>n}w(Ot,"isVerticalSegment");f(Ot,"isVerticalSegment");function Ut(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)))}w(Ut,"overlapLength");f(Ut,"overlapLength");function fe(t,e,n=Gt){return t.horizontal&&e.horizontal&&pt(t.a,e.a,n)?Ut(t.a.x,t.b.x,e.a.x,e.b.x):t.vertical&&e.vertical&&gt(t.a,e.a,n)?Ut(t.a.y,t.b.y,e.a.y,e.b.y):0}w(fe,"sameAxisSegmentOverlapLength");f(fe,"sameAxisSegmentOverlapLength");function Re(t,e=Gt){const n=[];for(let o=0;o<t.length-1;o++){const s=t[o],r=t[o+1],d=At(s,r,e),a=Ot(s,r,e);(d||a)&&n.push({index:o,a:s,b:r,horizontal:d,vertical:a})}return n}w(Re,"orthogonalSegmentsForPoints");f(Re,"orthogonalSegmentsForPoints");function ne(t,e=Gt){const n=Re(t,e);let o=0;for(let s=1;s<n.length;s++)n[s-1].horizontal!==n[s].horizontal&&o++;return o}w(ne,"countOrthogonalBends");f(ne,"countOrthogonalBends");function bt(t,e=Gt){const n=[];for(const o of t){const s=n.length>0?n[n.length-1]:void 0;(!s||!re(s,o,e))&&n.push({x:o.x,y:o.y})}return n}w(bt,"dedupeConsecutivePoints");f(bt,"dedupeConsecutivePoints");function Wn(t,e=Gt){if(!t||t.length!==4)return;const[n,o,s,r]=t;return At(n,o,e)&&Ot(o,s,e)&&At(s,r,e)?{kind:"HVH",p0:n,p1:o,p2:s,p3:r}:Ot(n,o,e)&&At(o,s,e)&&Ot(s,r,e)?{kind:"VHV",p0:n,p1:o,p2:s,p3:r}:void 0}w(Wn,"classifyThreeSegmentRoute");f(Wn,"classifyThreeSegmentRoute");function Je(t,e,n,o=0){const s=Math.min(t.x,e.x),r=Math.max(t.x,e.x),d=Math.min(t.y,e.y),a=Math.max(t.y,e.y);return r>n.left-o&&s<n.right+o&&a>n.top-o&&d<n.bottom+o}w(Je,"segmentBoundsOverlapRect");f(Je,"segmentBoundsOverlapRect");function Kn(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}w(Kn,"pointInsideRect");f(Kn,"pointInsideRect");function zo(t,e){return t.left<=e.left&&t.right>=e.right&&t.top<=e.top&&t.bottom>=e.bottom}w(zo,"rectContainsRect");f(zo,"rectContainsRect");function Ge(t,e){return t.left<e.right&&t.right>e.left&&t.top<e.bottom&&t.bottom>e.top}w(Ge,"rectsOverlap");f(Ge,"rectsOverlap");function mn(t,e){return{left:t.left-e,right:t.right+e,top:t.top-e,bottom:t.bottom+e}}w(mn,"inflateRect");f(mn,"inflateRect");function we(t,e,n,o){return{left:t-n/2,right:t+n/2,top:e-o/2,bottom:e+o/2}}w(we,"rectFromCenterSize");f(we,"rectFromCenterSize");function Jt(t){var e;return(e=jn(t))==null?void 0:e.rect}w(Jt,"rectOfNodeBounds");f(Jt,"rectOfNodeBounds");function ve(t,e){switch(e){case"top":return{x:t.cx,y:t.rect.top};case"bottom":return{x:t.cx,y:t.rect.bottom};case"left":return{x:t.rect.left,y:t.cy};case"right":return{x:t.rect.right,y:t.cy}}}w(ve,"portForRectSide");f(ve,"portForRectSide");function Jn(t,e,n,o,s,r=Gt){const d=e==="left"||e==="right",a=o==="left"||o==="right";if(d&&a){if(e==="right"&&o==="left"&&t.x<n.x||e==="left"&&o==="right"&&t.x>n.x){if(pt(t,n,r))return[t,n];const y=(t.x+n.x)/2;return[t,{x:y,y:t.y},{x:y,y:n.y},n]}if(e===o){if(pt(t,n,r))return;const y=e==="left"?Math.min(t.x,n.x)-s:Math.max(t.x,n.x)+s;return[t,{x:y,y:t.y},{x:y,y:n.y},n]}return}if(!d&&!a){if(e===o){if(gt(t,n,r))return;const S=e==="top"?Math.min(t.y,n.y)-s:Math.max(t.y,n.y)+s;return[t,{x:t.x,y:S},{x:n.x,y:S},n]}if(!(e==="bottom"&&o==="top"&&t.y<n.y||e==="top"&&o==="bottom"&&t.y>n.y))return;if(gt(t,n,r))return[t,n];const y=(t.y+n.y)/2;return[t,{x:t.x,y},{x:n.x,y},n]}if(d&&!a){const g=e==="right"&&n.x>t.x||e==="left"&&n.x<t.x,y=o==="top"&&t.y<n.y||o==="bottom"&&t.y>n.y;return g&&y?[t,{x:n.x,y:t.y},n]:void 0}const l=e==="bottom"&&n.y>t.y||e==="top"&&n.y<t.y,c=o==="left"&&t.x<n.x||o==="right"&&t.x>n.x;return l&&c?[t,{x:t.x,y:n.y},n]:void 0}w(Jn,"buildOrthogonalPortPath");f(Jn,"buildOrthogonalPortPath");function qn(t,e,n,o){return e==="left"||e==="right"?[t,{x:o,y:t.y},{x:o,y:n.y},n]:[t,{x:t.x,y:o},{x:n.x,y:o},n]}w(qn,"buildSameSideTrackPath");f(qn,"buildSameSideTrackPath");function qe(t){const e=new Map,n=[];for(const o of t){if(o.isEdgeLabel)continue;const s=Un(o);s&&(e.set(s.id,s),n.push({id:s.id,rect:s.rect}))}return{nodeInfoById:e,realNodeRects:n}}w(qe,"collectRealNodeBounds");f(qe,"collectRealNodeBounds");function pe(t){const e=[],n=[];for(const o of t){const s=Un(o);if(!s)continue;const r={id:s.id,rect:s.rect};o.isEdgeLabel?n.push(r):e.push(r)}return{realNodeRects:e,labelNodeRects:n}}w(pe,"collectNodeRectEntries");f(pe,"collectNodeRectEntries");function $o(t,{includeEdgeLabels:e=!0}={}){const n=[];for(const o of t){if(o.isGroup||!e&&o.isEdgeLabel)continue;const s=o.x??0,r=o.y??0,d=o.width??0,a=o.height??0;n.push({nodeId:o.id,...we(s,r,d,a)})}return n}w($o,"collectLayoutNodeRects");f($o,"collectLayoutNodeRects");function Zn(t,e,n=Gt){const o=t.start,s=t.end;if(!o||!s)return;const r=e.get(o),d=e.get(s);if(!(!r||!d))return{srcId:o,dstId:s,srcInfo:r,dstInfo:d,collinearX:Math.abs(r.cx-d.cx)<n,collinearY:Math.abs(r.cy-d.cy)<n}}w(Zn,"getNodePairGeometry");f(Zn,"getNodePairGeometry");function Pt(t,e,n,o=[],s=0){for(const r of n)if(!o.includes(r.id)&&Je(t,e,r.rect,-s))return!0;return!1}w(Pt,"segmentHitsAnyRect");f(Pt,"segmentHitsAnyRect");function Qn(t,e,n,o,s=Gt,r=1e-6){const d=pt(t,e,s),a=gt(t,e,s),l=pt(n,o,s),c=gt(n,o,s);if(d&&l||a&&c||!(d||a)||!(l||c))return!1;const g=d?{a:t,b:e}:{a:n,b:o},y=a?{a:t,b:e}:{a:n,b:o},S=g.a.y,u=Math.min(g.a.x,g.b.x),h=Math.max(g.a.x,g.b.x),i=y.a.x,x=Math.min(y.a.y,y.b.y),C=Math.max(y.a.y,y.b.y);if(i<u||i>h||S<x||S>C)return!1;const b=Math.abs(i-g.a.x)<r&&Math.abs(S-g.a.y)<r||Math.abs(i-g.b.x)<r&&Math.abs(S-g.b.y)<r,v=Math.abs(i-y.a.x)<r&&Math.abs(S-y.a.y)<r||Math.abs(i-y.b.x)<r&&Math.abs(S-y.b.y)<r;return!(b&&v)}w(Qn,"orthogonalSegmentsCross");f(Qn,"orthogonalSegmentsCross");function Vo(t,e,n,o,s=Gt){const r=pt(t,e,s),d=gt(t,e,s),a=pt(n,o,s),l=gt(n,o,s);return d&&l&&gt(t,n,s)?Ut(t.y,e.y,n.y,o.y)>s:r&&a&&pt(t,n,s)?Ut(t.x,e.x,n.x,o.x)>s:!1}w(Vo,"sameAxisSegmentsOverlap");f(Vo,"sameAxisSegmentsOverlap");function ze(t,e,n,o,{epsilon:s=Gt,skipDegenerateOther:r=!1}={}){for(const d of n){if(d===o||d.isLayoutOnly)continue;const a=d.points;if(!(!a||a.length<2))for(let l=0;l<a.length-1;l++){const c=a[l],g=a[l+1];if(!(r&&re(c,g,s))&&(Qn(t,e,c,g,s)||Vo(t,e,c,g,s)))return!0}}return!1}w(ze,"segmentConflictsWithAnyEdge");f(ze,"segmentConflictsWithAnyEdge");function ge(t,e,n,o,s=Gt){const r=pt(t,e,s),d=gt(t,e,s),a=pt(n,o,s),l=gt(n,o,s);if(!(r&&l||d&&a))return!1;const c=r?{a:t,b:e}:{a:n,b:o},g=r?{a:n,b:o}:{a:t,b:e},y=c.a.y,S=Math.min(c.a.x,c.b.x),u=Math.max(c.a.x,c.b.x),h=g.a.x,i=Math.min(g.a.y,g.b.y),x=Math.max(g.a.y,g.b.y);return h>S+s&&h<u-s&&y>i+s&&y<x-s}w(ge,"orthogonalSegmentsStrictlyCross");f(ge,"orthogonalSegmentsStrictlyCross");function pn(t,e,n){const o=Math.min(e,n),s=Math.max(e,n);return t>o+Gt&&t<s-Gt}w(pn,"strictlyBetween");f(pn,"strictlyBetween");function jo(t,e,n){return gt(t,e)&&gt(e,n)?pn(e.y,t.y,n.y):pt(t,e)&&pt(e,n)?pn(e.x,t.x,n.x):!1}w(jo,"isCollinearIntermediate");f(jo,"isCollinearIntermediate");function Uo(t){let e=!1;const n=[];for(let o=0;o<t.length;o++){const s=n[n.length-1],r=t[o],d=o+1<t.length?t[o+1]:void 0;if(s&&d){if(re(s,d)){o++,e=!0;continue}if(jo(s,r,d)){e=!0;continue}}n.push(r)}return{points:n,changed:e}}w(Uo,"simplifyPolylineOnce");f(Uo,"simplifyPolylineOnce");function $e(t){const e=[t[0]];for(let o=1;o<t.length;o++){const s=e[e.length-1],r=t[o];if(!gt(s,r)&&!pt(s,r)){const d=e.length>=2?e[e.length-2]:void 0,l=(d?gt(d,s):!1)?{x:s.x,y:r.y}:{x:r.x,y:s.y};e.push(l)}e.push(r)}const n=[];for(const o of e){const s=n[n.length-1];(!s||!re(s,o))&&n.push(o)}return n}w($e,"orthogonalizePolyline");f($e,"orthogonalizePolyline");function ue(t){if(t.length<3)return t;let e=[...t];for(let n=0;n<32;n++){const o=Uo(e);if(e=o.points,!o.changed)break}return e}w(ue,"simplifyPolyline");f(ue,"simplifyPolyline");var ct=.001,Nr=.5,hr=4;function to(t,e,n){const o=t;if(o.isLayoutOnly||!o.points||o.points.length<n)return;const s=o.start?e.get(o.start):void 0,r=o.end?e.get(o.end):void 0;return{edge:o,points:o.points,srcRect:s?Jt(s):void 0,dstRect:r?Jt(r):void 0}}w(to,"endpointContextFor");f(to,"endpointContextFor");function Wo(t,e,n){if(pt(t,e,ct))return{x:t.x<n.left?n.left:n.right,y:t.y};if(gt(t,e,ct)){const o=t.y<n.top?n.top:n.bottom;return{x:t.x,y:o}}return{x:Math.min(n.right,Math.max(n.left,t.x)),y:Math.min(n.bottom,Math.max(n.top,t.y))}}w(Wo,"segmentEnterPoint");f(Wo,"segmentEnterPoint");function yn(t,e,n){const o=n?1:-1;let s=n?0:t.length-1;for(;s>=0&&s<t.length&&Kn(t[s],e,Nr);)s+=o;if(s<0||s>=t.length)return t;const r=s-o;if(r<0||r>=t.length)return t;const d=Wo(t[s],t[r],e);return n?[d,...t.slice(s)]:[...t.slice(0,s+1),d]}w(yn,"clipEndpoint");f(yn,"clipEndpoint");function Ko(t,e){for(const n of t){const o=to(n,e,2);if(!o)continue;let s=[...o.points];o.srcRect&&(s=yn(s,o.srcRect,!0)),o.dstRect&&(s=yn(s,o.dstRect,!1)),s=ue($e(s)),s=eo(s,o.srcRect,o.dstRect),o.edge.points=ue($e(s))}}w(Ko,"clipEdgeEndpointsToNodeBoundaries");f(Ko,"clipEdgeEndpointsToNodeBoundaries");function xn(t,e,n,o=!1){if(pt(t,e,ct)){if(e.y<n.top-ct||e.y>n.bottom+ct)return e;if(o){if(t.x<n.left-ct)return{x:n.left,y:t.y};if(t.x>n.right+ct)return{x:n.right,y:t.y}}return{x:Math.abs(e.x-n.left)<=Math.abs(e.x-n.right)?n.left:n.right,y:t.y}}if(gt(t,e,ct)){if(e.x<n.left-ct||e.x>n.right+ct)return e;if(o){if(t.y<n.top-ct)return{x:t.x,y:n.top};if(t.y>n.bottom+ct)return{x:t.x,y:n.bottom}}const s=Math.abs(e.y-n.top)<=Math.abs(e.y-n.bottom);return{x:t.x,y:s?n.top:n.bottom}}return e}w(xn,"snapEndpointToBoundary");f(xn,"snapEndpointToBoundary");function Ve(t,e,n){const o=t[e];for(let s=e+n;s>=0&&s<t.length;s+=n){const r=t[s];if(!re(r,o,ct))return r}return t[e+n]}w(Ve,"firstDistinctAdjacent");f(Ve,"firstDistinctAdjacent");function je(t,e){const n=t+hr,o=e-hr;return n<=o?{lo:n,hi:o}:{lo:(t+e)/2,hi:(t+e)/2}}w(je,"cornerClearanceRange");f(je,"cornerClearanceRange");function bn(t,e,n){const{lo:o,hi:s}=je(e,n);return Math.min(s,Math.max(o,t))}w(bn,"clampToCornerClearance");f(bn,"clampToCornerClearance");function Jo(t){const e=Math.max(...t.map(o=>o.lo)),n=Math.min(...t.map(o=>o.hi));if(!(e>n))return{lo:e,hi:n}}w(Jo,"intersectRanges");f(Jo,"intersectRanges");function Mn(t,e){return e==="left"||e==="right"?je(t.top,t.bottom):je(t.left,t.right)}w(Mn,"clearanceRangeForSide");f(Mn,"clearanceRangeForSide");function Ue(t,e,n){const o=t.y>=n.top-ct&&t.y<=n.bottom+ct,s=t.x>=n.left-ct&&t.x<=n.right+ct;if(pt(t,e,ct)&&o){if(Math.abs(t.x-n.left)<ct)return"left";if(Math.abs(t.x-n.right)<ct)return"right"}if(gt(t,e,ct)&&s){if(Math.abs(t.y-n.top)<ct)return"top";if(Math.abs(t.y-n.bottom)<ct)return"bottom"}}w(Ue,"terminalSideForSegment");f(Ue,"terminalSideForSegment");function _e(t){return t==="left"||t==="right"}w(_e,"isHorizontalSide");f(_e,"isHorizontalSide");function qo(t,e,n,o,s){const r=[],d=n?Ue(t,e,n):void 0,a=o?Ue(e,t,o):void 0;return n&&d&&_e(d)===s&&r.push(Mn(n,d)),o&&a&&_e(a)===s&&r.push(Mn(o,a)),r.length>0?Jo(r):void 0}w(qo,"straightClearanceRange");f(qo,"straightClearanceRange");function Sn(t,e,n,o,s){const r=qo(t,e,n,o,s);if(!r)return;const d=s?t.y:t.x,a=Math.min(r.hi,Math.max(r.lo,d));if(!(Math.abs(a-d)<ct))return s?[{x:t.x,y:a},{x:e.x,y:a}]:[{x:a,y:t.y},{x:a,y:e.y}]}w(Sn,"clearStraightEndpointCornerAxis");f(Sn,"clearStraightEndpointCornerAxis");function eo(t,e,n){if(t.length!==2)return t;const[o,s]=t;return pt(o,s,ct)?Sn(o,s,e,n,!0)??t:gt(o,s,ct)?Sn(o,s,e,n,!1)??t:t}w(eo,"clearStraightEndpointCornerConnections");f(eo,"clearStraightEndpointCornerConnections");function Zo(t,e,n){return _e(n)?{x:t.x,y:bn(t.y,e.top,e.bottom)}:{x:bn(t.x,e.left,e.right),y:t.y}}w(Zo,"cornerClearedEndpoint");f(Zo,"cornerClearedEndpoint");function Qo(t,e,n,o,s,r){const d=t.map(a=>({...a}));for(let a=e;a>=0&&a<t.length;a+=n){const l=t[a];if(r&&!pt(l,o,ct)||!r&&!gt(l,o,ct))break;r?d[a].y=s.y:d[a].x=s.x}return d}w(Qo,"moveCollinearEndpointRun");f(Qo,"moveCollinearEndpointRun");function In(t,e,n){if(t.length<2)return t;const o=n?0:t.length-1,s=n?1:-1,r=t[o],d=Ve(t,o,s);if(!d)return t;const a=Ue(r,d,e);if(!a)return t;const l=_e(a),c=Zo(r,e,a);return re(r,c,ct)?t:Qo(t,o,s,r,c,l)}w(In,"clearEndpointCornerConnection");f(In,"clearEndpointCornerConnection");function Cn(t,e,n){const o=Math.min(t.x,e.x)>=n.left-ct&&Math.max(t.x,e.x)<=n.right+ct,s=Math.min(t.y,e.y)>=n.top-ct&&Math.max(t.y,e.y)<=n.bottom+ct;if(Math.abs(t.y-n.top)<ct&&Math.abs(e.y-n.top)<ct&&o)return"top";if(Math.abs(t.y-n.bottom)<ct&&Math.abs(e.y-n.bottom)<ct&&o)return"bottom";if(Math.abs(t.x-n.left)<ct&&Math.abs(e.x-n.left)<ct&&s)return"left";if(Math.abs(t.x-n.right)<ct&&Math.abs(e.x-n.right)<ct&&s)return"right"}w(Cn,"borderSideForSegment");f(Cn,"borderSideForSegment");function vn(t,e,n,o){switch(t){case"top":return gt(e,n,ct)&&n.y<o.top-ct;case"bottom":return gt(e,n,ct)&&n.y>o.bottom+ct;case"left":return pt(e,n,ct)&&n.x<o.left-ct;case"right":return pt(e,n,ct)&&n.x>o.right+ct}}w(vn,"leavesOutward");f(vn,"leavesOutward");function Ln(t,e,n){if(t.length<3)return t;if(n){const r=Cn(t[0],t[1],e);return r&&vn(r,t[1],t[2],e)?t.slice(1):t}const o=t.length-1,s=Cn(t[o-1],t[o],e);return s&&vn(s,t[o-1],t[o-2],e)?t.slice(0,o):t}w(Ln,"collapseOwnBorderStub");f(Ln,"collapseOwnBorderStub");function ts(t,e,n){let o=t;if(e){const r=Ve(o,0,1);if(r){const d=xn(r,o[0],e);d!==o[0]&&(o=[d,...o.slice(1)])}o=Ln(o,e,!0)}if(n){const r=o.length-1,d=Ve(o,r,-1);if(d){const a=xn(d,o[r],n,!0);a!==o[r]&&(o=[...o.slice(0,r),a])}o=Ln(o,n,!1)}const s=eo(o,e,n);return s!==o||o.length===2?s:(e&&(o=In(o,e,!0)),n&&(o=In(o,n,!1)),o)}w(ts,"snapAndCollapseEndpoints");f(ts,"snapAndCollapseEndpoints");function Tn(t,e){for(const n of t){const o=to(n,e,2);if(!o)continue;const s=bt(o.points,ct),r=ts(s,o.srcRect,o.dstRect);if(r.length<3){o.edge.points=r;continue}const d=[r[0],{...r[0]},...r.slice(1,-1),r[r.length-1],{...r[r.length-1]}];o.edge.points=d}}w(Tn,"prepareEdgeEndpointsForRenderer");f(Tn,"prepareEdgeEndpointsForRenderer");function no(t){return new Map(t.map(e=>[e.id,e]))}w(no,"buildNodeMap");f(no,"buildNodeMap");function es(t,e){let n=t.parentId,o=null;for(;n;){const s=e.get(n);if(!(s!=null&&s.isGroup))break;o=s.id,n=s.parentId}return o}w(es,"resolveTopLevelGroupId");f(es,"resolveTopLevelGroupId");function En(t,e){let n=0,o=t.parentId;for(;o;){const s=e.get(o);if(!(s!=null&&s.isGroup))break;n++,o=s.parentId}return n}w(En,"groupDepth");f(En,"groupDepth");function oo(t){let e=1/0,n=-1/0,o=1/0,s=-1/0;for(const r of t){const d=r.x,a=r.y;if(typeof d!="number"||typeof a!="number")continue;const l=r.width??0,c=r.height??0;e=Math.min(e,d-l/2),n=Math.max(n,d+l/2),o=Math.min(o,a-c/2),s=Math.max(s,a+c/2)}return e===1/0||o===1/0?null:{minX:e,maxX:n,minY:o,maxY:s}}w(oo,"boundsForChildren");f(oo,"boundsForChildren");function ns(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}w(ns,"applyGroupBounds");f(ns,"applyGroupBounds");function os(t){const e=no(t),n=t.filter(o=>o.isGroup&&o.parentId).sort((o,s)=>En(s,e)-En(o,e));for(const o of n){const s=t.filter(d=>d.parentId===o.id),r=oo(s);r&&ns(o,r)}}w(os,"recomputeNestedGroupBounds");f(os,"recomputeNestedGroupBounds");function We(t,e){const n=t.nodes??[],o=t.edges??[],s=n.filter(l=>!l.isGroup);let r=1/0,d=-1/0;for(const l of s){const c=l[e];typeof c=="number"&&(r=Math.min(r,c),d=Math.max(d,c))}if(!Number.isFinite(r)||!Number.isFinite(d))return!1;const a=f(l=>r+d-l,"mirror");for(const l of n){const c=l[e];typeof c=="number"&&(l[e]=a(c));const g=l.groupTitleRect;g&&(l.groupTitleRect=e==="x"?{...g,left:a(g.right),right:a(g.left)}:{...g,top:a(g.bottom),bottom:a(g.top)})}for(const l of o)for(const c of l.points??[])c[e]=a(c[e]);return!0}w(We,"mirrorAxis");f(We,"mirrorAxis");function ss(t){return(t.nodes??[]).some(n=>!n.isGroup)?We(t,"y"):!0}w(ss,"applyBtDirectionTransform");f(ss,"applyBtDirectionTransform");function rs(t,e="LR"){const n=t.nodes??[],o=t.edges??[],s=n.filter(P=>!P.isGroup);let r=1/0,d=1/0;for(const P of s){const z=P.x??0,U=P.y??0;z<r&&(r=z),U<d&&(d=U)}if(!Number.isFinite(r)||!Number.isFinite(d))return!1;const a=36;let l=0,c=0;for(const P of s)l+=P.width??0,c+=P.height??0;const g=l/s.length,y=c/s.length,S=y>0?Math.max(1,g/y):1;for(const P of s){const z=P.x??0,et=((P.y??0)-d)*S+a,ft=z-r;P.x=et,P.y=ft}for(const P of o)if(P.points)for(const z of P.points){const U=z.x,ft=(z.y-d)*S+a,St=U-r;z.x=ft,z.y=St}os(n);const u=n.filter(P=>P.isGroup&&!P.parentId);if(u.length===0)return e==="RL"&&We(t,"x"),!0;const h=no(n),i=new Map;for(const P of n){if(P.isGroup)continue;const z=es(P,h);if(!z)continue;const U=i.get(z)??[];U.push(P),i.set(z,U)}let x=0;for(const P of u){const z=P.padding??0;z>x&&(x=z)}const C=[];let b=1/0,v=-1/0;for(const P of u){const z=i.get(P.id)??[],U=oo(z);U&&(b=Math.min(b,U.minX),v=Math.max(v,U.maxX),C.push({lane:P,contentTop:U.minY,contentBottom:U.maxY,centerY:(U.minY+U.maxY)/2}))}if(b===1/0||v===-1/0)return!0;const L=Math.max(0,v-b),p=Math.max(x,10),M=L+2*p,T=a+M,B=(b+v)/2-M/2-a,F=B+T/2,X=Math.max(x,a);C.sort((P,z)=>P.centerY-z.centerY);for(let P=0;P<C.length;P++){const z=C[P];let U,et;if(P===0?U=z.contentTop-X:U=(C[P-1].contentBottom+z.contentTop)/2,P===C.length-1)et=z.contentBottom+X;else{const Xt=C[P+1];et=(z.contentBottom+Xt.contentTop)/2}const ft=Math.max(0,et-U),St=(U+et)/2;z.lane.x=F,z.lane.y=St,z.lane.width=T,z.lane.height=ft,z.lane.swimlaneContentTop=z.contentTop,z.lane.groupTitleRect={left:B,right:B+a,top:U,bottom:et}}return e==="RL"&&We(t,"x"),!0}w(rs,"applyLrDirectionTransform");f(rs,"applyLrDirectionTransform");var de=1e-6,Br=8,ln=Br,Pr=[0,ln,-ln,2*ln,-2*ln];function is(t,e){const{nodeInfoById:n,realNodeRects:o}=qe(e);for(const s of t){if(s.isLayoutOnly)continue;const r=s.points;if(!r||r.length<4)continue;const d=Wn(bt(r,de),de);if(!d)continue;const{p3:a}=d,l=d.kind==="HVH",c=Zn(s,n,de);if(!c)continue;const{srcId:g,dstId:y,srcInfo:S,dstInfo:u,collinearX:h,collinearY:i}=c;if(h||i)continue;let x;const C=S.rect;for(const b of Pr){let v,L,p;if(l){const F=u.cy>S.cy?C.bottom:C.top,X=S.cx+b;if(X<=C.left+de||X>=C.right-de)continue;v={x:X,y:F},L={x:X,y:a.y},p={x:a.x,y:a.y}}else{const F=u.cx>S.cx?C.right:C.left,X=S.cy+b;if(X<=C.top+de||X>=C.bottom-de)continue;v={x:F,y:X},L={x:a.x,y:X},p={x:a.x,y:a.y}}const M=re(v,L,de),T=re(L,p,de);if(M&&T||!M&&Pt(v,L,o,[g],1)||!T&&Pt(L,p,o,[y],1))continue;const A=!M&&ze(v,L,t,s,{epsilon:de,skipDegenerateOther:!0}),k=!T&&ze(L,p,t,s,{epsilon:de,skipDegenerateOther:!0});if(!(A||k)){M?x=[L,p]:T?x=[v,L]:x=[v,L,p];break}}x&&(s.points=x)}}w(is,"portSwapToLShape");f(is,"portSwapToLShape");function cs(t,e){const{realNodeRects:r,labelNodeRects:d}=pe(e.values());for(const a of t){if(a.isLayoutOnly)continue;const l=a.points;if(!l||l.length<4)continue;const c=bt(l,.001);if(c.length<4)continue;const g=c.length-1,y=c[g],S=c[g-1],u=c[g-2],h=y.x-S.x,i=y.y-S.y,x=Math.hypot(h,i);if(x>=10||x<.001)continue;const C=S.x-u.x,b=S.y-u.y;if(Math.hypot(C,b)<.001)continue;const L=At(S,y,.001),p=Ot(S,y,.001),M=At(u,S,.001),T=Ot(u,S,.001);if(!(L&&T||p&&M))continue;const A=a.end,k=a.start,B=A?e.get(A):void 0;if(!B)continue;const F=B.x??0,X=B.y??0,P=Jt(B);if(!P)continue;let z,U;if(T){const Z=b<0;z={x:F,y:u.y},U={x:F,y:Z?P.bottom:P.top}}else{const Z=C>0;z={x:u.x,y:X},U={x:Z?P.right:P.left,y:X}}if(Pt(z,U,r,A?[A]:[],-2)||Pt(z,U,d,[],-2))continue;if(k){const Z=e.get(k),it=Z?Jt(Z):void 0;if(it&&Kn(z,it,2))continue}const et=f((Z,it)=>`${Z.x.toFixed(3)},${Z.y.toFixed(3)}|${it.x.toFixed(3)},${it.y.toFixed(3)}`,"ownSegmentKey"),ft=new Set;for(let Z=0;Z<c.length-1;Z++)ft.add(et(c[Z],c[Z+1]));const St=f((Z,it)=>{for(const ht of t){if(ht===a||ht.isLayoutOnly)continue;const xt=ht.points;if(!(!xt||xt.length<2))for(let Ct=0;Ct<xt.length-1;Ct++){const Rt=xt[Ct],qt=xt[Ct+1];if(!ft.has(et(Rt,qt))&&ge(Z,it,Rt,qt,.001))return!0}}return!1},"segmentCrossesOtherEdge");if(St(z,U))continue;if(g-3>=0){const Z=c[g-3],it=[k,A].filter(ht=>!!ht);if(Pt(Z,z,r,it,-2)||St(Z,z))continue}const Dt=[...c.slice(0,g-2),z,U];a.points=Dt;const ot=a.labelNodeId;if(ot){const Z=e.get(ot);if(Z){const it=Z.width??0,ht=Z.height??0;if(it>0&&ht>0){let xt,Ct,Rt=-1;for(let qt=0;qt<Dt.length-1;qt++){const Zt=Dt[qt],Qt=Dt[qt+1],ie=Math.hypot(Qt.x-Zt.x,Qt.y-Zt.y),Oe=pt(Zt,Qt,.001),xe=gt(Zt,Qt,.001);(Oe&&ie>=it+2||xe&&ie>=ht+2)&&ie>Rt&&(Rt=ie,xt=(Zt.x+Qt.x)/2,Ct=(Zt.y+Qt.y)/2)}xt!==void 0&&Ct!==void 0&&(Z.x=xt,Z.y=Ct)}}}}}w(cs,"collapseShortTerminalStub");f(cs,"collapseShortTerminalStub");var nt=.001,Yt=8,lt=Re,Co=f((t,e)=>gt(t,e,nt)||pt(t,e,nt),"orthogonallyAligned");function as(t,e){const s=f((u,h)=>{const i=u.x??0,x=u.y??0,C=h.x-i,b=h.y-x;let v=(u.width??0)/2,L=(u.height??0)/2;return Math.abs(b)*v>Math.abs(C)*L?(b<0&&(L=-L),{x:i+(b===0?0:L*C/b),y:x+L}):(C<0&&(v=-v),{x:i+v,y:x+(C===0?0:v*b/C)})},"rectIntersect"),r=f((u,h)=>{const i=bt(u.points??[]);if(i.length<2)return;const x=h?u.start:u.end,C=x?e.get(x):void 0,b=C?Jt(C):void 0;if(!C||!x||!b)return;const v=h?i[0]:i[i.length-1],L=h?i[1]:i[i.length-2],p=s(C,v);let M=v;if(Co(L,p)&&(M=L),gt(p,M,nt))return{edge:u,edgeId:String(u.id??""),nodeId:x,atStart:h,orientation:"V",coord:p.x,min:Math.min(p.y,M.y),max:Math.max(p.y,M.y),boundary:p,railEnd:M,rect:b};if(pt(p,M,nt))return{edge:u,edgeId:String(u.id??""),nodeId:x,atStart:h,orientation:"H",coord:p.y,min:Math.min(p.x,M.x),max:Math.max(p.x,M.x),boundary:p,railEnd:M,rect:b}},"terminalLaneFor"),d=f((u,h)=>Math.max(0,Math.min(u.max,h.max)-Math.max(u.min,h.min)),"projectedOverlapLength"),a=f((u,h)=>u.nodeId!==h.nodeId||u.orientation!==h.orientation?!1:u.orientation==="H"?(Math.abs(u.boundary.x-u.rect.left)<1||Math.abs(u.boundary.x-u.rect.right)<1)&&gt(u.boundary,h.boundary,1):(Math.abs(u.boundary.y-u.rect.top)<1||Math.abs(u.boundary.y-u.rect.bottom)<1)&&pt(u.boundary,h.boundary,1),"sameTerminalFace"),l=f((u,h)=>u.nodeId!==h.nodeId||u.orientation!==h.orientation?!1:d(u,h)>=Yt&&Math.abs(u.coord-h.coord)<.5,"exactTerminalLaneConflict"),c=f((u,h)=>{if(u.nodeId!==h.nodeId||u.orientation!==h.orientation||u.orientation!=="H"||u.atStart===h.atStart)return!1;const i=d(u,h);if(i<Yt)return!1;const x=u.rect.bottom-u.rect.top;return i<x||i>2*x?!1:a(u,h)&&Math.abs(u.coord-h.coord)<16},"nearTerminalLaneConflict"),g=f((u,h)=>{const i=bt(u.edge.points??[]);if(i.length<2)return;const x=u.orientation==="V"?{x:u.boundary.x+h,y:u.boundary.y}:{x:u.boundary.x,y:u.boundary.y+h},C=u.orientation==="V"?{x:u.railEnd.x+h,y:u.railEnd.y}:{x:u.railEnd.x,y:u.railEnd.y+h};if(!f(()=>Math.abs(u.boundary.y-u.rect.top)<1||Math.abs(u.boundary.y-u.rect.bottom)<1?pt(x,u.boundary,nt)&&x.x>=u.rect.left+1&&x.x<=u.rect.right-1:Math.abs(u.boundary.x-u.rect.left)<1||Math.abs(u.boundary.x-u.rect.right)<1?gt(x,u.boundary,nt)&&x.y>=u.rect.top+1&&x.y<=u.rect.bottom-1:!1,"boundaryStaysOnSameFace")())return;if(u.atStart){const M=i.length>1&&re(i[1],u.railEnd,nt),T=i.slice(M?2:1),A=T[0];return A&&!Co(A,C)?void 0:[x,C,...T]}const v=i.length>1&&re(i[i.length-2],u.railEnd,nt),L=i.slice(0,v?-2:-1),p=L[L.length-1];if(!(p&&!Co(p,C)))return[...L,C,x]},"shiftedCandidate"),y=f(u=>{const h=u.edge,i=bt(h.points??[]);if(i.length!==2)return!1;const x=h.start,C=h.end,b=x?e.get(x):void 0,v=C?e.get(C):void 0;if(!b||!v)return!1;const L=b.x??0,p=b.y??0,M=v.x??0,T=v.y??0,[A,k]=i;return pt(A,k,nt)&&Math.abs(p-T)<1&&Math.abs(L-M)>1||gt(A,k,nt)&&Math.abs(L-M)<1&&Math.abs(p-T)>1},"laneIsStraightCollinearConnector"),S=[-7,7,-14,14,-21,21];for(let u=0;u<8;u++){const h=t.filter(x=>!x.isLayoutOnly).flatMap(x=>[r(x,!0),r(x,!1)]).filter(x=>!!x);let i=!1;for(let x=0;x<h.length&&!i;x++)for(let C=x+1;C<h.length&&!i;C++){const b=h[x],v=h[C];if(b.edge===v.edge||!(l(b,v)||c(b,v)))continue;const L=!l(b,v),p=[b,v].sort((M,T)=>{const A=y(M),k=y(T);return A!==k?Number(A)-Number(k):+!T.atStart-+!M.atStart});for(const M of p){for(const T of S){const A=g(M,T);if(!A)continue;const k=r({...M.edge,points:A},M.atStart);if(!(!k||h.some(B=>B.edge!==M.edge&&(l(k,B)||L&&c(k,B))))){M.edge.points=A,i=!0;break}}if(i)break}}if(!i)return}}w(as,"separateSharedRenderedTerminalLanes");f(as,"separateSharedRenderedTerminalLanes");function ls(t,e){const{realNodeRects:o,labelNodeRects:s}=pe(e.values()),r=f((a,l)=>{const c=a.start,g=a.end,y=lt(l);if(y.length!==l.length-1)return!1;const S=[c,g].filter(u=>!!u);for(const u of y)if(Pt(u.a,u.b,o,S,-2)||Pt(u.a,u.b,s,[],-2))return!1;for(const u of t){if(u===a||u.isLayoutOnly)continue;const h=u.points;if(!(!h||h.length<2)){for(const i of y)for(const x of lt(bt(h)))if(fe(i,x,.5)>=Yt||ge(i.a,i.b,x.a,x.b,nt))return!1}}return!0},"candidateIsSafe"),d=f((a,l)=>{if(l+4>=a.length)return;const c=a[l],g=a[l+1],y=a[l+2],S=a[l+3],u=a[l+4],h=At(c,g)&&Ot(g,y)&&At(y,S)&&Ot(S,u)&&gt(c,S,nt)&&gt(c,u,nt)&&gt(g,y,nt)&&(g.x-c.x)*(S.x-y.x)<0,i=Ot(c,g)&&At(g,y)&&Ot(y,S)&&At(S,u)&&pt(c,S,nt)&&pt(c,u,nt)&&pt(g,y,nt)&&(g.y-c.y)*(S.y-y.y)<0;if(h||i)return bt([...a.slice(0,l+1),u,...a.slice(l+5)]);if(l+5>=a.length)return;const x=a[l+5],C=Ot(c,g)&&At(g,y)&&Ot(y,S)&&At(S,u)&&Ot(u,x)&&gt(c,u,nt)&&gt(c,x,nt)&&gt(y,S,nt)&&(y.x-g.x)*(u.x-S.x)<0,b=At(c,g)&&Ot(g,y)&&At(y,S)&&Ot(S,u)&&At(u,x)&&pt(c,u,nt)&&pt(c,x,nt)&&pt(y,S,nt)&&(y.y-g.y)*(u.y-S.y)<0;if(!(!C&&!b))return bt([...a.slice(0,l+1),x,...a.slice(l+6)])},"withoutDogleg");for(let a=0;a<8;a++){let l=!1;for(const c of t){if(c.isLayoutOnly)continue;const g=bt(c.points??[]);for(let y=0;y<=g.length-5;y++){const S=d(g,y);if(!(!S||!r(c,S))){c.points=S,l=!0;break}}if(l)break}if(!l)return}}w(ls,"collapseRedundantRectangularDoglegs");f(ls,"collapseRedundantRectangularDoglegs");function wn(t,e){const{realNodeRects:r,labelNodeRects:d}=pe(e.values()),a=t.filter(h=>!h.isLayoutOnly),l=f((h,i,x)=>bt(h===i?x??[]:h.points??[]),"pointsFor"),c=f((h,i)=>{let x=0;for(let C=0;C<a.length;C++){const b=lt(l(a[C],h,i));for(let v=C+1;v<a.length;v++){const L=lt(l(a[v],h,i));for(const p of b)for(const M of L)ge(p.a,p.b,M.a,M.b,nt)&&x++}}return x},"strictCrossingCount"),g=f(h=>{const i=lt(h);if(i.length!==3)return;const x=i[1];if(!(i[0].horizontal===x.horizontal||i[2].horizontal===x.horizontal))return{index:x.index,horizontal:x.horizontal,vertical:x.vertical,segment:x}},"middleRail"),y=f((h,i)=>{const x=[h.start,h.end].filter(C=>!!C);return r.filter(C=>{if(x.includes(C.id))return!1;const b=C.rect;return i.horizontal?Ut(i.a.x,i.b.x,b.left,b.right)>=Yt&&i.a.y>=b.top-2&&i.a.y<=b.bottom+2:Ut(i.a.y,i.b.y,b.top,b.bottom)>=Yt&&i.a.x>=b.left-2&&i.a.x<=b.right+2})},"blockingRectsFor"),S=f((h,i,x)=>{const C=h.map(v=>({...v}));if(i.horizontal)C[i.index].y=x,C[i.index+1].y=x;else if(i.vertical)C[i.index].x=x,C[i.index+1].x=x;else return;const b=ue(bt(C));return lt(b).length===b.length-1?b:void 0},"candidateByMovingRail"),u=f((h,i,x)=>{const C=[h.start,h.end].filter(v=>!!v),b=lt(i);if(b.length!==i.length-1)return!1;for(const v of b)if(Pt(v.a,v.b,r,C,-2)||Pt(v.a,v.b,d,[],-2))return!1;for(const v of a)if(v!==h){for(const L of b)for(const p of lt(l(v)))if(fe(L,p,.5)>=Yt)return!1}return c(h,i)<=x},"candidateIsSafe");for(let h=0;h<8;h++){const i=c();let x=!1;for(const C of a){const b=l(C),v=g(b);if(!v)continue;const L=y(C,v.segment);if(L.length===0)continue;const p=v.horizontal?[Math.min(...L.map(M=>M.rect.top))-20,Math.max(...L.map(M=>M.rect.bottom))+20]:[Math.min(...L.map(M=>M.rect.left))-20,Math.max(...L.map(M=>M.rect.right))+20];for(const M of p){const T=S(b,v.segment,M);if(!(!T||!u(C,T,i))){C.points=T,x=!0;break}}if(x)break}if(!x)return}}w(wn,"liftObstacleHuggingSameSideRails");f(wn,"liftObstacleHuggingSameSideRails");function Rn(t,e){const o=f(l=>{const c=l.groupTitleRect;if(!(!c||typeof c.left!="number"||typeof c.right!="number"||typeof c.top!="number"||typeof c.bottom!="number"||!Number.isFinite(c.left)||!Number.isFinite(c.right)||!Number.isFinite(c.top)||!Number.isFinite(c.bottom)||c.right<=c.left||c.bottom<=c.top))return{left:c.left,right:c.right,top:c.top,bottom:c.bottom}},"validTitleRect"),s=f(l=>{if(!l.isGroup||l.parentId)return;const c=l.direction,g=typeof c=="string"?c.toUpperCase():"";if(g==="LR"||g==="RL"||g==="BT")return;const y=o(l),S=l.y,u=l.height;if(!y||typeof S!="number"||typeof u!="number"||!Number.isFinite(S)||!Number.isFinite(u)||u<=0)return;const h=y.right-y.left,i=y.bottom-y.top;if(!(i<=0||h<i))return{node:l,rect:y}},"topLaneTitleFor"),r=f((l,c)=>{if(!l.horizontal)return!1;const g=l.a.y;return g<=c.top+nt||g>=c.bottom-nt?!1:Ut(l.a.x,l.b.x,c.left,c.right)>=Yt},"horizontalSegmentIntersectsTitle"),d=[...e.values()].map(s).filter(l=>!!l);if(d.length===0)return;let a=0;for(const l of t){if(l.isLayoutOnly)continue;const c=bt(l.points??[]);for(const g of lt(c))for(const y of d)r(g,y.rect)&&(a=Math.max(a,y.rect.bottom-g.a.y+4))}if(!(a<=nt))for(const l of d){const c=l.node.y,g=l.node.height;typeof c!="number"||typeof g!="number"||!Number.isFinite(c)||!Number.isFinite(g)||g<=0||(l.node.y=c-a/2,l.node.height=g+a,l.node.groupTitleRect={...l.rect,top:l.rect.top-a,bottom:l.rect.bottom-a})}}w(Rn,"liftTopLaneTitleBandsAboveRails");f(Rn,"liftTopLaneTitleBandsAboveRails");function An(t,e){const o=f(c=>{const g=c.groupTitleRect;if(!(!g||typeof g.left!="number"||typeof g.right!="number"||typeof g.top!="number"||typeof g.bottom!="number"||!Number.isFinite(g.left)||!Number.isFinite(g.right)||!Number.isFinite(g.top)||!Number.isFinite(g.bottom)||g.right<=g.left||g.bottom<=g.top))return{left:g.left,right:g.right,top:g.top,bottom:g.bottom}},"validTitleRect"),s=f(c=>{if(!c.isGroup||c.parentId||c.direction!=="LR")return;const y=o(c),S=c.x,u=c.width;if(!y||typeof S!="number"||typeof u!="number"||!Number.isFinite(S)||!Number.isFinite(u)||u<=0)return;const h=y.right-y.left,i=y.bottom-y.top;if(!(h<=0||i<h))return{node:c,rect:y}},"leftLaneTitleFor"),r=f((c,g)=>{if(!c.vertical)return!1;const y=c.a.x;return y<=g.left+nt||y>=g.right-nt?!1:Ut(c.a.y,c.b.y,g.top,g.bottom)>=Yt},"verticalSegmentIntersectsTitle"),d=f((c,g)=>{if(!c.horizontal)return!1;const y=c.a.y;return y<=g.top+nt||y>=g.bottom-nt?!1:Ut(c.a.x,c.b.x,g.left,g.right)>=Yt},"horizontalSegmentIntersectsTitle"),a=[...e.values()].map(s).filter(c=>!!c);if(a.length===0)return;let l=0;for(const c of t){if(c.isLayoutOnly)continue;const g=bt(c.points??[]);for(const y of lt(g))for(const S of a)if(r(y,S.rect))l=Math.max(l,S.rect.right-y.a.x+4);else if(d(y,S.rect)){const u=Math.min(y.a.x,y.b.x);l=Math.max(l,S.rect.right-u+4)}}if(!(l<=nt))for(const c of a){const g=c.node.x,y=c.node.width;typeof g!="number"||typeof y!="number"||!Number.isFinite(g)||!Number.isFinite(y)||y<=0||(c.node.x=g-l/2,c.node.width=y+l,c.node.groupTitleRect={...c.rect,left:c.rect.left-l,right:c.rect.right-l})}}w(An,"shiftLeftLaneTitleBandsLeftOfRails");f(An,"shiftLeftLaneTitleBandsLeftOfRails");function ds(t,e){const{realNodeRects:o}=pe(e.values()),s=t.filter(h=>!h.isLayoutOnly),r=f((h,i=new Map)=>bt(i.get(h)??h.points??[]),"replacementPointsFor"),d=f((h=new Map)=>{let i=0;for(let x=0;x<s.length;x++){const C=lt(r(s[x],h));for(let b=x+1;b<s.length;b++){const v=lt(r(s[b],h));for(const L of C)for(const p of v)ge(L.a,L.b,p.a,p.b,nt)&&i++}}return i},"crossingCount"),a=f((h=new Map)=>s.reduce((i,x)=>i+ne(r(x,h)),0),"totalBends"),l=f(h=>{const i=r(h);if(i.length<4)return;const x=i[i.length-2],C=i[i.length-1];if(!(!At(x,C,nt)&&!Ot(x,C,nt)))return{tailStart:x,terminal:C}},"terminalTailFor"),c=f((h,i)=>{const x=r(h);if(x.length<3)return;const C=x[0],b=x[1];let v;if(At(C,b,nt))v={x:b.x,y:i.tailStart.y};else if(Ot(C,b,nt))v={x:i.tailStart.x,y:b.y};else return;const L=ue(bt([C,b,v,i.tailStart,i.terminal]));return lt(L).length===L.length-1?L:void 0},"candidateWithDestinationTail"),g=f((h,i)=>{const x=[h.start,h.end].filter(C=>!!C);for(const C of lt(i))if(Pt(C.a,C.b,o,x,-2))return!0;return!1},"pathHasNodeHit"),y=f((h,i,x)=>{for(const C of s)if(C!==h){for(const b of lt(i))for(const v of lt(r(C,x)))if(fe(b,v,.5)>=Yt)return!0}return!1},"pathHasSharedTrack"),S=f((h,i,x)=>!g(h,i)&&!y(h,i,x),"candidateIsSafe"),u=f(()=>{const h=new Map;for(const i of s){const x=i.end;if(!x||!e.has(x)||r(i).length<4)continue;const b=h.get(x)??[];b.push(i),h.set(x,b)}return h},"edgesByDestination");for(let h=0;h<4;h++){const i=d();if(i===0)return;const x=a();let C,b=i,v=x;for(const L of u().values())for(let p=0;p<L.length;p++)for(let M=p+1;M<L.length;M++){const T=L[p],A=L[M],k=l(T),B=l(A);if(!k||!B)continue;const F=c(T,B),X=c(A,k);if(!F||!X)continue;const P=new Map([[T,F],[A,X]]);if(!S(T,F,P)||!S(A,X,P))continue;const z=d(P),U=a(P);z>=i||z>b||z===b&&U>=v||(C=P,b=z,v=U)}if(!C)return;for(const[L,p]of C)L.points=p}}w(ds,"swapDestinationTerminalTailsToReduceCrossings");f(ds,"swapDestinationTerminalTailsToReduceCrossings");function fs(t,e){const{realNodeRects:r,labelNodeRects:d}=pe(e.values()),a=t.filter(L=>!L.isLayoutOnly),l=f((L,p=new Map)=>bt(p.get(L)??L.points??[]),"replacementPointsFor"),c=f((L=new Map)=>{let p=0;for(let M=0;M<a.length;M++){const T=lt(l(a[M],L));for(let A=M+1;A<a.length;A++){const k=lt(l(a[A],L));for(const B of T)for(const F of k)ge(B.a,B.b,F.a,F.b,nt)&&p++}}return p},"strictCrossingCount"),g=f((L=new Map)=>a.reduce((p,M)=>p+ne(l(M,L)),0),"totalBends"),y=f(L=>{const p=L.start,M=L.end,T=p?e.get(p):void 0,A=M?e.get(M):void 0,k=T?Jt(T):void 0,B=A?Jt(A):void 0;return k&&B?{src:k,dst:B}:void 0},"endpointRectsFor"),S=f((L,p,M)=>{if(M.index<=0||M.index+1>=p.length-1)return;const T=y(L);if(T){if(M.vertical){const A=M.a.x,k=Math.min(T.src.left,T.dst.left),B=Math.max(T.src.right,T.dst.right),F=A<k-nt?"left":A>B+nt?"right":void 0;return F?{edge:L,points:p,segmentIndex:M.index,axis:"vertical",side:F,coord:A,min:Math.min(M.a.y,M.b.y),max:Math.max(M.a.y,M.b.y)}:void 0}if(M.horizontal){const A=M.a.y,k=Math.min(T.src.top,T.dst.top),B=Math.max(T.src.bottom,T.dst.bottom),F=A<k-nt?"top":A>B+nt?"bottom":void 0;return F?{edge:L,points:p,segmentIndex:M.index,axis:"horizontal",side:F,coord:A,min:Math.min(M.a.x,M.b.x),max:Math.max(M.a.x,M.b.x)}:void 0}}},"externalRailForSegment"),u=f(()=>{const L=[];for(const p of a){const M=l(p);for(const T of lt(M)){const A=S(p,M,T);A&&L.push(A)}}return L},"collectExternalRails"),h=f((L,p)=>L.edge!==p.edge&&L.axis===p.axis&&L.side===p.side&&Ut(L.min,L.max,p.min,p.max)>=Yt,"railsInteract"),i=f(L=>{const p=[],M=new Set;for(const T of L){if(M.has(T))continue;const A=[T],k=[];for(M.add(T);A.length>0;){const B=A.pop();k.push(B);for(const F of L)!M.has(F)&&h(B,F)&&(M.add(F),A.push(F))}k.length>1&&p.push(k)}return p},"connectedComponents"),x=f(L=>{const p=[];for(const M of L)p.some(T=>Math.abs(T-M.coord)<nt)||p.push(M.coord);for(;p.length<L.length;){const M=Math.min(...p),T=Math.max(...p),A=L[0].side;p.push(A==="left"||A==="top"?M-12*(L.length-p.length):T+12*(L.length-p.length))}return p},"uniqueCoordsFor"),C=f(L=>{const p=L.map(A=>A.coord),M=x(L),T=[];if(L.length<=6){const A=new Array(M.length).fill(!1),k=[],B=f(()=>{if(k.length===L.length){k.some((F,X)=>Math.abs(F-p[X])>=nt)&&T.push([...k]);return}for(const[F,X]of M.entries())A[F]||(A[F]=!0,k.push(X),B(),k.pop(),A[F]=!1)},"visit");return B(),T}for(let A=0;A<p.length;A++)for(let k=A+1;k<p.length;k++){const B=[...p];[B[A],B[k]]=[B[k],B[A]],T.push(B)}return T},"coordinateAssignmentsFor"),b=f((L,p)=>{const M=new Map;for(const[A,k]of L.entries()){const B=p[A],F=M.get(k.edge)??k.points.map(X=>({x:X.x,y:X.y}));k.axis==="vertical"?(F[k.segmentIndex].x=B,F[k.segmentIndex+1].x=B):(F[k.segmentIndex].y=B,F[k.segmentIndex+1].y=B),M.set(k.edge,F)}const T=new Map;for(const[A,k]of M){const B=ue(bt(k));if(lt(B).length!==B.length-1)return;T.set(A,B)}return T},"replacementsForAssignment"),v=f(L=>{for(const[p,M]of L){const T=[p.start,p.end].filter(A=>!!A);for(const A of lt(M))if(Pt(A.a,A.b,r,T,-2)||Pt(A.a,A.b,d,[],-2))return!1}for(let p=0;p<a.length;p++){const M=a[p],T=L.has(M),A=lt(l(M,L));for(let k=p+1;k<a.length;k++){const B=a[k];if(!T&&!L.has(B))continue;const F=lt(l(B,L));for(const X of A)for(const P of F)if(fe(X,P,.5)>=Yt)return!1}}return!0},"candidateIsSafe");for(let L=0;L<4;L++){const p=c();if(p===0)return;let M,T=p,A=g(),k=Number.POSITIVE_INFINITY;for(const B of i(u()))for(const F of C(B)){const X=b(B,F);if(!X||!v(X))continue;const P=c(X);if(P>=p)continue;const z=g(X),U=B.reduce((et,ft,St)=>et+Math.abs(F[St]-ft.coord),0);P>T||P===T&&(z>A||z===A&&U>=k)||(M=X,T=P,A=z,k=U)}if(!M)return;for(const[B,F]of M)B.points=F}}w(fs,"reassignCrossingExternalRailChannels");f(fs,"reassignCrossingExternalRailChannels");function us(t,e){const{realNodeRects:o,labelNodeRects:s}=pe(e.values()),r=t.filter(u=>!u.isLayoutOnly),d=f((u,h,i)=>bt(u===h?i??[]:u.points??[]),"pointsFor"),a=f(u=>lt(u).reduce((h,i)=>{const x=i.a.x-i.b.x,C=i.a.y-i.b.y;return h+Math.hypot(x,C)},0),"pathLength"),l=f((u,h)=>{let i=0;for(let x=0;x<r.length;x++){const C=lt(d(r[x],u,h));for(let b=x+1;b<r.length;b++){const v=lt(d(r[b],u,h));for(const L of C)for(const p of v)ge(L.a,L.b,p.a,p.b,nt)&&i++}}return i},"strictCrossingCount"),c=f((u,h)=>{if(u.horizontal){const i=u.a.y;return(Math.abs(i-h.top)<1||Math.abs(i-h.bottom)<1)&&Ut(u.a.x,u.b.x,h.left,h.right)>=Yt}if(u.vertical){const i=u.a.x;return(Math.abs(i-h.left)<1||Math.abs(i-h.right)<1)&&Ut(u.a.y,u.b.y,h.top,h.bottom)>=Yt}return!1},"segmentRunsAlongRectBorder"),g=f(u=>{const h=[u.start,u.end].filter(x=>!!x),i=[];for(const x of h){const C=e.get(x),b=C?Jt(C):void 0;b&&i.push(b)}return i},"endpointRectsFor"),y=f((u,h)=>{if(h+3>=u.length)return[];const i=u[h],x=u[h+1],C=u[h+2],b=u[h+3],v=At(i,x,nt)&&Ot(x,C,nt)&&At(C,b,nt),L=Ot(i,x,nt)&&At(x,C,nt)&&Ot(C,b,nt);if(!v&&!L)return[];if(!(v?Math.sign(x.x-i.x)!==Math.sign(b.x-C.x):Math.sign(x.y-i.y)!==Math.sign(b.y-C.y)))return[];const M=gt(i,b,nt)||pt(i,b,nt)?[]:[{x:i.x,y:b.y},{x:b.x,y:i.y}],T=M.length===0?[[...u.slice(0,h+1),...u.slice(h+3)]]:M.map(k=>[...u.slice(0,h+1),k,...u.slice(h+3)]),A=new Set;return T.map(k=>ue(bt(k))).filter(k=>{if(lt(k).length!==k.length-1||!k.some(F=>re(F,b,nt)))return!1;const B=k.map(F=>`${F.x.toFixed(3)},${F.y.toFixed(3)}`).join("|");return A.has(B)?!1:(A.add(B),!0)})},"shortcutCandidatesAt"),S=f((u,h,i)=>{const x=[u.start,u.end].filter(b=>!!b),C=g(u);for(const b of lt(h))if(Pt(b.a,b.b,o,x,-2)||Pt(b.a,b.b,s,[],-2)||C.some(v=>c(b,v)))return!1;for(const b of r)if(b!==u){for(const v of lt(h))for(const L of lt(d(b)))if(fe(v,L,.5)>=Yt)return!1}return l(u,h)<=i},"candidateIsSafe");for(let u=0;u<8;u++){const h=l();let i,x,C=h,b=Number.POSITIVE_INFINITY,v=Number.POSITIVE_INFINITY;for(const L of r){const p=d(L),M=ne(p,nt),T=a(p);for(let A=0;A<=p.length-4;A++)for(const k of y(p,A)){const B=ne(k,nt),F=a(k);if(!(B<M||B===M&&F<T-nt)||!S(L,k,h))continue;const P=l(L,k);P>C||P===C&&(B>b||B===b&&F>=v)||(i=L,x=k,C=P,b=B,v=F)}}if(!i||!x)return;i.points=x}}w(us,"shortcutRedundantOrthogonalJogs");f(us,"shortcutRedundantOrthogonalJogs");function hs(t,e){const d=[];for(const O of e.values()){if(O.isGroup||O.isEdgeLabel)continue;const _=O.x??0,D=O.y??0,j=Jt(O);j&&d.push({id:String(O.id??""),cx:_,cy:D,rect:j})}if(d.length===0)return;const a=new Map(d.map(O=>[O.id,O])),l=d.map(O=>({id:O.id,rect:O.rect})),c=["top","bottom","left","right"],g={top:Math.min(...d.map(O=>O.rect.top))-20,bottom:Math.max(...d.map(O=>O.rect.bottom))+20,left:Math.min(...d.map(O=>O.rect.left))-20,right:Math.max(...d.map(O=>O.rect.right))+20},y=t.filter(O=>!O.isLayoutOnly),S=new Map(y.map((O,_)=>[O,_])),u=f(O=>{const _=O==="left"||O==="top"?-1:1,D=[];for(let j=0;j<=2;j++)D.push(g[O]+_*20*j);return D},"outwardTracksForSide"),h=f((O,_=new Map)=>bt(_.get(O)??O.points??[]),"replacementPointsFor"),i=f((O,_)=>{let D=0;for(const j of O)for(const J of _)ge(j.a,j.b,J.a,J.b,nt)&&D++;return D},"crossingCountBetweenSegments"),x=f((O,_)=>i(lt(O),lt(_)),"crossingCountBetweenPaths"),C=f((O=new Map)=>{let _=0;const D=[],j=new Set,J=[],Q=f(G=>{j.has(G)||(j.add(G),J.push(G))},"addEdge");for(let G=0;G<y.length;G++){const q=y[G],m=h(q,O);for(let I=G+1;I<y.length;I++){const R=y[I],E=x(m,h(R,O));E>0&&(_+=E,D.push({first:q,second:R,count:E}),Q(q),Q(R))}}return J.sort((G,q)=>(S.get(G)??0)-(S.get(q)??0)),{count:_,pairs:D,edgeSet:j,edges:J}},"crossingSnapshot"),b=f((O,_)=>{const D=new Set(_.keys());if(D.size===0)return O.count;let j=0;for(const Q of O.pairs)(D.has(Q.first)||D.has(Q.second))&&(j+=Q.count);let J=0;for(let Q=0;Q<y.length;Q++){const G=y[Q],q=D.has(G),m=h(G,_);for(let I=Q+1;I<y.length;I++){const R=y[I];!q&&!D.has(R)||(J+=x(m,h(R,_)))}}return O.count-j+J},"crossingCountWithReplacements"),v=f(O=>{const _=new Map;for(const J of O.pairs){const Q=_.get(J.first)??new Set;Q.add(J.second),_.set(J.first,Q);const G=_.get(J.second)??new Set;G.add(J.first),_.set(J.second,G)}const D=[],j=new Set;for(const J of O.edges){if(j.has(J))continue;const Q=[J],G=[];for(j.add(J);Q.length>0;){const q=Q.pop();G.push(q);for(const m of _.get(q)??[])j.has(m)||(j.add(m),Q.push(m))}G.sort((q,m)=>(S.get(q)??0)-(S.get(m)??0)),G.length>1&&D.push(G)}return D},"crossingComponents"),L=f(O=>[O.start,O.end].filter(_=>!!_),"endpointIdsFor"),p=f(O=>{const _=[];for(const D of v(O)){const j=new Set(D),J=new Set(D.flatMap(G=>L(G))),Q=[...D];for(const G of y)j.has(G)||L(G).some(q=>J.has(q))&&Q.push(G);Q.sort((G,q)=>(S.get(G)??0)-(S.get(q)??0)),_.push(Q)}return _},"pairSearchGroups"),M=f((O,_,D)=>b(O,new Map([[_,D]])),"crossingCountWithSingleReplacement"),T=f(O=>{const _=new Map;for(const D of O.pairs)_.set(D.first,(_.get(D.first)??0)+D.count),_.set(D.second,(_.get(D.second)??0)+D.count);return _},"currentCrossingsByEdge"),A=f(O=>O.slice(1).reduce((_,D,j)=>{const J=O[j];return _+Math.abs(D.x-J.x)+Math.abs(D.y-J.y)},0),"pathLength"),k=f((O=new Map)=>y.reduce((_,D)=>_+ne(h(D,O)),0),"totalBends"),B=f((O=new Map)=>y.reduce((_,D)=>_+A(h(D,O)),0),"totalLength"),F=f((O,_,D=new Map)=>{const j=lt(_);for(const J of y)if(J!==O){for(const Q of j)for(const G of lt(h(J,D)))if(fe(Q,G,.5)>=Yt)return!0}return!1},"pathHasSegmentConflict"),X=f((O,_)=>{const D=[O.start,O.end].filter(j=>!!j);for(const j of lt(_))if(Pt(j.a,j.b,l,D,-2))return!0;return!1},"pathHitsNode"),P=f((O,_)=>{const D=ue(bt(_));lt(D).length===D.length-1&&O.push(D)},"pushOrthogonalCandidate"),z=f(O=>O==="left"||O==="right","sideIsHorizontal"),U=f((O,_,D)=>{switch(_){case"left":return Math.min(O.x,D.x)-20;case"right":return Math.max(O.x,D.x)+20;case"top":return Math.min(O.y,D.y)-20;case"bottom":return Math.max(O.y,D.y)+20}},"localTrackForSameSide"),et=f((O,_,D,j)=>{const J=D==="left"||D==="top"?-1:1,Q=[U(_,D,j),g[D]];for(const G of Q)for(let q=0;q<=2;q++)P(O,qn(_,D,j,G+J*20*q))},"addSameSideCandidates"),ft=f((O,_,D,j,J)=>{for(const Q of u(D))for(const G of u(J))P(O,[_,{x:Q,y:_.y},{x:Q,y:G},{x:j.x,y:G},j])},"addHorizontalToVerticalCandidates"),St=f((O,_,D,j,J)=>{for(const Q of u(D))for(const G of u(J))P(O,[_,{x:_.x,y:Q},{x:G,y:Q},{x:G,y:j.y},j])},"addVerticalToHorizontalCandidates"),Xt=f((O,_,D,j,J)=>{const Q=[...u("top"),...u("bottom")];for(const G of u(D))for(const q of u(J))for(const m of Q)P(O,[_,{x:G,y:_.y},{x:G,y:m},{x:q,y:m},{x:q,y:j.y},j])},"addHorizontalPairCandidates"),Dt=f((O,_,D,j,J)=>{const Q=[...u("left"),...u("right")];for(const G of u(D))for(const q of u(J))for(const m of Q)P(O,[_,{x:_.x,y:G},{x:m,y:G},{x:m,y:q},{x:j.x,y:q},j])},"addVerticalPairCandidates"),ot=f(O=>{const _=new Set;return O.map(D=>bt(D)).filter(D=>{const j=D.map(J=>`${J.x.toFixed(3)},${J.y.toFixed(3)}`).join("|");return _.has(j)||D.length<2?!1:(_.add(j),!0)})},"dedupeCandidatePaths"),Z=f((O,_,D,j)=>{const J=[],Q=Jn(O,_,D,j,20,nt);Q&&P(J,Q),_===j&&et(J,O,_,D);const G=z(_),q=z(j);return G&&!q?ft(J,O,_,D,j):!G&&q?St(J,O,_,D,j):G?Xt(J,O,_,D,j):Dt(J,O,_,D,j),ot(J)},"buildCandidatesForSides"),it=f((O,_,D,j)=>{const J=[...u("left"),...u("right")],Q=[...u("top"),...u("bottom")];for(const G of c){const q=ve(j,G),m=G==="top"||G==="bottom"?u(G):Q;for(const I of J){P(O,[_,D,{x:I,y:D.y},{x:I,y:q.y},q]);for(const R of m)P(O,[_,D,{x:I,y:D.y},{x:I,y:R},{x:q.x,y:R},q])}}},"addVerticalDepartureOuterTrackCandidates"),ht=f((O,_,D,j)=>{const J=[...u("left"),...u("right")],Q=[...u("top"),...u("bottom")];for(const G of c){const q=ve(j,G),m=G==="left"||G==="right"?u(G):J;for(const I of Q){P(O,[_,D,{x:D.x,y:I},{x:q.x,y:I},q]);for(const R of m)P(O,[_,D,{x:D.x,y:I},{x:R,y:I},{x:R,y:q.y},q])}}},"addHorizontalDepartureOuterTrackCandidates"),xt=f(O=>{const _=O.start,D=O.end,j=D?a.get(D):void 0;if(!_||!j)return[];const J=bt(O.points??[]);if(J.length<4)return[];const Q=J[0],G=J[1],q=[];return Ot(Q,G,nt)?it(q,Q,G,j):At(Q,G,nt)&&ht(q,Q,G,j),q},"terminalPreservingOuterTrackCandidates"),Ct=f(O=>{const _=O.start,D=O.end,j=_?a.get(_):void 0,J=D?a.get(D):void 0;if(!j||!J)return[];const Q=[];for(const G of c){const q=ve(j,G);for(const m of c)Q.push(...Z(q,G,ve(J,m),m))}return Q.push(...xt(O)),Q},"candidatePathsFor"),Rt=f(()=>new Map(y.map(O=>[O,lt(h(O))])),"currentSegmentsByEdge"),qt=f((O,_,D)=>{const j=new Set;for(const J of y){if(J===O)continue;const Q=D.get(J)??lt(h(J));_.some(G=>Q.some(q=>fe(G,q,.5)>=Yt))&&j.add(J)}return j},"sharedTrackConflictsFor"),Zt=f((O,_,D,j)=>{const J=new Set;return Ct(O).map(G=>ue(bt(G))).filter(G=>{if(X(O,G))return!1;const q=G.map(m=>`${m.x.toFixed(3)},${m.y.toFixed(3)}`).join("|");return J.has(q)||G.length<2?!1:(J.add(q),!0)}).map(G=>{const q=lt(G);let m=0;for(const I of y)I!==O&&(m+=i(q,D.get(I)??lt(h(I))));return{candidate:G,candidateSegments:q,crossings:_.count-(j.get(O)??0)+m,bends:ne(G,nt),totalBends:ne(G),length:A(G)}}).filter(({crossings:G})=>G<=_.count).sort((G,q)=>G.crossings-q.crossings||G.bends-q.bends||G.length-q.length).slice(0,48).map(G=>({path:G.candidate,segments:G.candidateSegments,sharedTrackConflicts:qt(O,G.candidateSegments,D),totalBends:G.totalBends,length:G.length}))},"pairCandidatesFor"),Qt=f((O,_,D,j,J,Q)=>{let G=0;for(const m of O.pairs)(m.first===_||m.second===_||m.first===j||m.second===j)&&(G+=m.count);let q=i(D.segments,J.segments);for(const m of y){if(m===_||m===j)continue;const I=Q.get(m)??lt(h(m));q+=i(D.segments,I)+i(J.segments,I)}return O.count-G+q},"pairCrossingCount"),ie=f((O,_)=>{for(const D of O.sharedTrackConflicts)if(D!==_)return!1;return!0},"conflictsOnlyWith"),Oe=f((O,_)=>O.segments.some(D=>_.segments.some(j=>fe(D,j,.5)>=Yt)),"candidatesShareTrack"),xe=f((O,_,D,j)=>ie(_,D.edge)&&ie(j,O.edge)&&!Oe(_,j),"pairCandidatesAreCompatible"),Ne=f((O,_,D,j,J)=>{const Q=Qt(O.current,_.edge,D,j.edge,J,O.baseSegments);if(!(Q>=O.current.count))return{replacements:new Map([[_.edge,D.path],[j.edge,J.path]]),crossings:Q,bends:O.currentBends-(O.baseBendsByEdge.get(_.edge)??0)-(O.baseBendsByEdge.get(j.edge)??0)+D.totalBends+J.totalBends,length:O.currentLength-(O.baseLengthByEdge.get(_.edge)??0)-(O.baseLengthByEdge.get(j.edge)??0)+D.length+J.length}},"scorePairReplacement"),ho=f((O,_)=>O.crossings<_.crossings||O.crossings===_.crossings&&(O.bends<_.bends||O.bends===_.bends&&O.length<_.length),"pairScoreIsBetter"),go=f((O,_,D,j)=>{let J=j;for(const Q of _.candidates)for(const G of D.candidates){if(!xe(_,Q,D,G))continue;const q=Ne(O,_,Q,D,G);q&&ho(q,J)&&(J=q)}return J},"bestScoreForOptionPair"),mo=f(O=>{const _=k(),D=B(),j=Rt(),J=T(O),Q=new Map(y.map(E=>[E,ne(h(E))])),G=new Map(y.map(E=>[E,A(h(E))])),q=new Map,m=p(O);for(const E of m)for(const N of E){if(q.has(N))continue;const H=Zt(N,O,j,J);H.length>0&&q.set(N,{edge:N,candidates:H})}let I={replacements:new Map,crossings:O.count,bends:_,length:D};const R={current:O,currentBends:_,currentLength:D,baseBendsByEdge:Q,baseLengthByEdge:G,baseSegments:j};for(const E of m){const N=new Set(E.filter(K=>O.edgeSet.has(K))),H=E.map(K=>q.get(K)).filter(K=>!!K);for(let K=0;K<H.length;K++){const st=H[K];for(let W=K+1;W<H.length;W++){const V=H[W];!N.has(st.edge)&&!N.has(V.edge)||(I=go(R,st,V,I))}}}return I.replacements.size>0?I.replacements:void 0},"bestPairedReplacement");for(let O=0;O<4;O++){const _=C(),D=_.count;if(D===0)return;let j,J,Q=D,G=Number.POSITIVE_INFINITY;for(const m of _.edges){const I=ne(h(m),nt);for(const R of Ct(m)){const E=X(m,R),N=!E&&F(m,R),H=M(_,m,R),K=ne(R,nt);E||N||!(H<D||H===D&&K<I)||H>Q||H===Q&&K>=G||(j=m,J=R,Q=H,G=K)}}if(j&&J){j.points=J;continue}const q=mo(_);if(!q)return;for(const[m,I]of q)m.points=I}}w(hs,"resolveRenderedOrthogonalCrossings");f(hs,"resolveRenderedOrthogonalCrossings");var Ie=.001,kr=8;function gs(t,e){const{nodeInfoById:n,realNodeRects:o}=qe(e),s=["top","bottom","left","right"],r=20,d={top:Math.min(...o.map(i=>i.rect.top))-r,bottom:Math.max(...o.map(i=>i.rect.bottom))+r,left:Math.min(...o.map(i=>i.rect.left))-r,right:Math.max(...o.map(i=>i.rect.right))+r},a=f((i,x,C,b)=>{const v=[],L=Jn(i,x,C,b,r,Ie);return L&&v.push(L),x===b&&v.push(qn(i,x,C,d[x])),v},"buildOrthogonalPathCandidates"),l=f((i,x)=>{for(let C=0;C<i.length-1;C++){const b=i[C],v=i[C+1];if(Pt(b,v,o,x,1))return!0}return!1},"pathHitsNode"),c=f((i,x,C=!1)=>{let b=0;const v=Re(i,Ie),L=x.start,p=x.end;for(const M of t){if(M===x||M.isLayoutOnly)continue;const T=M.start,A=M.end;if(!C&&L&&p&&(T===L||T===p||A===L||A===p))continue;const k=M.points;if(!(!k||k.length<2))for(const B of v)for(const F of Re(k,Ie)){if(Qn(B.a,B.b,F.a,F.b,Ie,Ie)){b++;continue}fe(B,F,Ie)>=kr&&b++}}return b},"pathConflictCount"),g=4,y=f((i,x)=>{const C=Math.abs(i.y-x.rect.top),b=Math.abs(i.y-x.rect.bottom),v=Math.abs(i.x-x.rect.left),L=Math.abs(i.x-x.rect.right);let p="top",M=C;return b<M&&(p="bottom",M=b),v<M&&(p="left",M=v),L<M&&(p="right",M=L),p},"nearestSideOfRect"),S=new Map,u=f((i,x,C)=>{const b=S.get(i)??[];b.push({side:x,edgeId:C}),S.set(i,b)},"addFaceClaim");for(const i of t){if(i.isLayoutOnly)continue;const x=i.points??[];if(x.length<1)continue;const C=i.id??"",b=i.start,v=i.end;if(b){const L=n.get(b);L&&u(b,y(x[0],L),C)}if(v){const L=n.get(v);L&&u(v,y(x[x.length-1],L),C)}}const h=f((i,x,C)=>{var b;return((b=S.get(i))==null?void 0:b.some(v=>v.edgeId!==C&&v.side===x))??!1},"faceIsClaimed");for(const i of t){if(i.isLayoutOnly)continue;const x=i.points;if(!x||x.length<2)continue;const C=ne(x,Ie);if(C<g)continue;const b=i.start,v=i.end;if(!b||!v)continue;const L=n.get(b),p=n.get(v);if(!L||!p)continue;const M=i.id??"",T=c(x,i,!0),A=c(x,i);let k,B=T,F=C;for(const X of s){if(h(b,X,M))continue;const P=ve(L,X);for(const z of s){if(h(v,z,M))continue;const U=ve(p,z);for(const et of a(P,X,U,z)){if(l(et,[b,v]))continue;const ft=ne(et,Ie);if(T>0){const St=c(et,i,!0);if(St>B||St===B&&ft>=F)continue;B=St,F=ft,k=et;continue}c(et,i)>A||ft<F&&(F=ft,k=et)}}}if(k){i.points=k;const X=S.get(b);X&&S.set(b,X.filter(z=>z.edgeId!==M));const P=S.get(v);P&&S.set(v,P.filter(z=>z.edgeId!==M)),u(b,y(k[0],L),M),u(v,y(k[k.length-1],p),M)}}}w(gs,"simplifyDetouredEdges");f(gs,"simplifyDetouredEdges");var ee=.001,gr=10,dn=7;function On(t,e){const n=e?0:t.length-1,o=e?1:-1,s=t[n],r=t[n+o];if(!s||!r)return;const d=r.x-s.x,a=r.y-s.y;if(!(Math.abs(d)+Math.abs(a)<ee)){if(Math.abs(a)<=ee){const c=s.x+Math.sign(d)*gr;return{left:Math.min(s.x,c),right:Math.max(s.x,c),top:s.y-dn,bottom:s.y+dn}}if(Math.abs(d)<=ee){const c=s.y+Math.sign(a)*gr;return{left:s.x-dn,right:s.x+dn,top:Math.min(s.y,c),bottom:Math.max(s.y,c)}}return{left:Math.min(s.x,r.x),right:Math.max(s.x,r.x),top:Math.min(s.y,r.y),bottom:Math.max(s.y,r.y)}}}w(On,"markerClearanceRectFor");f(On,"markerClearanceRectFor");function ms(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)}}w(ms,"normalizeRect");f(ms,"normalizeRect");function Nn(t,e){const n=bt(e),o=On(n,!0),s=On(n,!1);return[o,s].some(r=>r&&Ge(t,ms(r)))}w(Nn,"labelOverlapsOwnMarker");f(Nn,"labelOverlapsOwnMarker");function He(t,e){const n=[];for(const h of t){if(h.isLayoutOnly)continue;const i=h.points;if(!(!i||i.length<2))for(let x=0;x<i.length-1;x++)n.push({edgeId:h.id,p1:i[x],p2:i[x+1]})}const o=[],s=[];for(const h of e.values()){const i=h.isGroup,x=h.parentId;if(i&&!x){const b=Jt(h);b&&s.push({id:h.id,rect:b});continue}if(i||h.isEdgeLabel)continue;const C=Jt(h);C&&o.push({nodeId:h.id,rect:C})}const r=3,d=1,a=12,l=f((h,i)=>{const x=mn(i,r);for(const{nodeId:C,rect:b}of o)if(C!==h&&Ge(x,b))return!0;return!1},"labelOverlapsForeignNode"),c=f((h,i)=>{const x=mn(i,r);for(const C of n)if(C.edgeId!==h&&Je(C.p1,C.p2,x))return!0;return!1},"labelOverlapsForeignEdge"),g=f((h,i,x)=>l(h,x)||c(i,x),"labelOverlapsAnything"),y=[],S=f(h=>{for(const{id:i,rect:x}of s)if(zo(x,h))return i},"findContainingLane"),u=f((h,i)=>y.some(x=>x.labelId!==h&&Ge(i,x.rect)),"overlapsPlacedLabel");for(const h of t){if(h.isLayoutOnly)continue;const i=h.labelNodeId;if(!i)continue;const x=e.get(i);if(!x)continue;const C=h.points;if(!C||C.length<2)continue;const b=x.width??0,v=x.height??0;if(b<=0||v<=0)continue;const L=[];for(let ot=0;ot<C.length-1;ot++){const Z=C[ot],it=C[ot+1],ht=Math.abs(Z.x-it.x),xt=Math.abs(Z.y-it.y);ht<ee&&xt<ee||ht>=ee&&xt>=ee||L.push({idx:ot,length:ht+xt,orientation:ht>=ee?"horizontal":"vertical",midX:(Z.x+it.x)/2,midY:(Z.y+it.y)/2})}if(L.length===0)continue;const p=L.length>=3?L.filter(ot=>ot.idx>0&&ot.idx<L.length-1):L,M=p.length>0?p:L,T=b>=v?"horizontal":"vertical",A=f(ot=>[...ot].sort((Z,it)=>{const ht=Z.orientation===T,xt=it.orientation===T;if(ht!==xt)return ht?-1:1;const Ct=Z.length>=(Z.orientation==="horizontal"?b:v)+2,Rt=it.length>=(it.orientation==="horizontal"?b:v)+2;return Ct!==Rt?Ct?-1:1:it.length-Z.length}),"rankSegments"),k=L[0],B=L[L.length-1],F=[.5,.25,.75,.05,.95,.15,.85,.1,.9],X=f((ot,Z)=>{const it=C[ot.idx],ht=C[ot.idx+1];return{midX:it.x+(ht.x-it.x)*Z,midY:it.y+(ht.y-it.y)*Z}},"anchorAtT"),P=f((ot,Z,it)=>Math.min(it,Math.max(Z,ot)),"clamp"),z=f((ot,Z)=>ot.midX>=Z.left-ee&&ot.midX<=Z.right+ee&&ot.midY>=Z.top-ee&&ot.midY<=Z.bottom+ee,"pointInsideRectInclusive"),U=f(ot=>{const Z=we(ot.midX,ot.midY,b,v),it=S(Z);if(it)return{laneId:it,anchor:ot,rect:Z};const ht=s.find(({rect:ie})=>z(ot,ie));if(!ht)return;const xt=ht.rect.left+b/2+d,Ct=ht.rect.right-b/2-d,Rt=ht.rect.top+v/2+d,qt=ht.rect.bottom-v/2-d;if(xt>Ct||Rt>qt)return;const Zt={midX:P(ot.midX,xt,Ct),midY:P(ot.midY,Rt,qt)},Qt=we(Zt.midX,Zt.midY,b,v);return z(ot,Qt)?{laneId:ht.id,anchor:Zt,rect:Qt}:void 0},"placementForAnchor"),et=f((ot,Z,it)=>ot.orientation==="horizontal"?Math.abs(Z.midX-it.x):Math.abs(Z.midY-it.y),"distanceAlongSegment"),ft=f((ot,Z)=>{const ht=(ot.orientation==="horizontal"?b/2:v/2)+a;if(ot===k){const xt=C[ot.idx];if(et(ot,Z,xt)+ee<ht)return!1}if(ot===B){const xt=C[ot.idx+1];if(et(ot,Z,xt)+ee<ht)return!1}return!0},"labelClearsTerminalEndpoints"),St=f(ot=>{const Z=A(ot);for(const it of Z)for(const ht of F){const xt=X(it,ht);if(!ft(it,xt))continue;const Ct=U(xt);if(Ct&&!Nn(Ct.rect,C)&&!u(i,Ct.rect)&&!g(i,h.id,Ct.rect))return{laneId:Ct.laneId,anchor:Ct.anchor}}},"tryPool"),Xt=f((ot,Z,it=!1)=>{const ht=A(ot);for(const xt of ht){const Ct={midX:xt.midX,midY:xt.midY};if(Z&&!ft(xt,Ct))continue;const Rt=U(Ct);if(Rt&&!Nn(Rt.rect,C)&&!u(i,Rt.rect)&&!l(i,Rt.rect)&&(it||!c(h.id,Rt.rect)))return{laneId:Rt.laneId,anchor:Rt.anchor}}},"findLaneContainingFallback"),Dt=St(M)??(M.length<L.length?St(L):void 0)??Xt(L,!0)??Xt(L,!1)??Xt(L,!1,!0);if(Dt){x.x=Dt.anchor.midX,x.y=Dt.anchor.midY,x.parentId=Dt.laneId;const ot=we(Dt.anchor.midX,Dt.anchor.midY,b,v),Z=y.findIndex(it=>it.labelId===i);Z>=0?y[Z]={labelId:i,rect:ot}:y.push({labelId:i,rect:ot})}}}w(He,"anchorLabelsToPolyline");f(He,"anchorLabelsToPolyline");var vo=1e-6,Fr=8,mr=Fr/2,_r=3;function Bn(t,e){return t<e?`${t}::${e}`:`${e}::${t}`}w(Bn,"pairKey");f(Bn,"pairKey");function ps(t,e){const{nodeInfoById:n,realNodeRects:o}=qe(e),s=new Map;for(const d of e){const a=d.id;if(!d.isGroup&&d.isEdgeLabel){s.set(a,{w:d.width??0,h:d.height??0});continue}}const r=f((d,a,l,c)=>{const g=Bn(a,l);let y=0;const S=f(u=>{if(!u)return;const h=s.get(u);if(!h)return;const i=c==="x"?h.w/2:h.h/2;i>y&&(y=i)},"consider");S(d.labelNodeId);for(const u of t){if(u===d||u.isLayoutOnly)continue;const h=u.start,i=u.end;!h||!i||Bn(h,i)===g&&S(u.labelNodeId)}return y>0?y+_r:0},"labelClearanceFor");for(const d of t){if(d.isLayoutOnly)continue;const a=d.points;if(!Wn(a,vo))continue;const l=Zn(d,n,vo);if(!l)continue;const{srcId:c,dstId:g,srcInfo:y,dstInfo:S,collinearX:u,collinearY:h}=l;if(u===h)continue;let i,x;if(u){const p=S.cy>y.cy;i={x:y.cx,y:p?y.rect.bottom:y.rect.top},x={x:S.cx,y:p?S.rect.top:S.rect.bottom}}else{const p=S.cx>y.cx;i={x:p?y.rect.right:y.rect.left,y:y.cy},x={x:p?S.rect.left:S.rect.right,y:S.cy}}if(Pt(i,x,o,[c,g],1))continue;const b=r(d,c,g,u?"x":"y"),v=b>mr?b:mr,L=[0,v,-v];for(const p of L){const M={...i},T={...x};if(u){if(M.x+=p,T.x+=p,M.x<=y.rect.left||M.x>=y.rect.right||T.x<=S.rect.left||T.x>=S.rect.right)continue}else if(M.y+=p,T.y+=p,M.y<=y.rect.top||M.y>=y.rect.bottom||T.y<=S.rect.top||T.y>=S.rect.bottom)continue;if(!Pt(M,T,o,[c,g],1)&&!ze(M,T,t,d,{epsilon:vo})){d.points=[M,T];break}}}}w(ps,"straightenCollinearSiblingDetours");f(ps,"straightenCollinearSiblingDetours");function Pn(t,e){const{realNodeRects:l,labelNodeRects:c}=pe(e.values()),g=f((p,M)=>Re(M,.001).map(T=>({...T,edge:p,interior:T.index>=1&&T.index<=M.length-3})),"segmentsFor"),y=f(()=>{const p=[];for(const M of t){if(M.isLayoutOnly)continue;const T=M.points;!T||T.length<2||p.push(...g(M,bt(T)))}return p},"allSegments"),S=f((p,M)=>p.horizontal&&M.horizontal?Ut(p.a.x,p.b.x,M.a.x,M.b.x)>=8&&Math.abs(p.a.y-M.a.y)<7:p.vertical&&M.vertical?Ut(p.a.y,p.b.y,M.a.y,M.b.y)>=8&&Math.abs(p.a.x-M.a.x)<7:!1,"hasCrowdedParallelTrack"),u=f((p,M)=>{const T=p.start,A=p.end,k=g(p,M);if(k.length!==M.length-1)return!1;const B=[T,A].filter(X=>!!X),F=p.labelNodeId?[p.labelNodeId]:[];for(const X of k)if(Pt(X.a,X.b,l,B,-2)||Pt(X.a,X.b,c,F,-2))return!1;for(const X of t){if(X===p||X.isLayoutOnly)continue;const P=X.points;if(!(!P||P.length<2)){for(const z of k)for(const U of g(X,bt(P)))if(S(z,U)||ge(z.a,z.b,U.a,U.b,.001))return!1}}return!0},"candidateIsSafe"),h=f((p,M)=>{const T=bt(p.edge.points??[]);if(T.length<4||p.index>=T.length-1)return;const A=T.map(k=>({...k}));if(p.horizontal)A[p.index].y+=M,A[p.index+1].y+=M;else if(p.vertical)A[p.index].x+=M,A[p.index+1].x+=M;else return;return g(p.edge,A).length===A.length-1?A:void 0},"shiftedCandidate"),i=f((p,M)=>({x:p.x??(M.left+M.right)/2,y:p.y??(M.top+M.bottom)/2}),"nodeCenter"),x=f(p=>{const M=p.edge,T=bt(M.points??[]);if(T.length!==4||p.index!==1)return;const A=M.start?e.get(M.start):void 0,k=M.end?e.get(M.end):void 0,B=A?Jt(A):void 0,F=k?Jt(k):void 0,X=T.slice(p.index+2);if(!(!A||!k||!B||!F||X.length===0))return{sourceCenter:i(A,B),targetCenter:i(k,F),sourceRect:B,tail:X}},"sourceDetourContextFor"),C=f((p,M,T,A,k,B)=>{const F=A.y>=T.y,X=F?k.bottom:k.top,P=X+(F?20:-20);if(F&&p.b.y<=P+.001||!F&&p.b.y>=P-.001)return;const z=p.a.x+M;return bt([{x:T.x,y:X},{x:T.x,y:P},{x:z,y:P},{x:z,y:p.b.y},...B],.001)},"verticalSourceDetour"),b=f((p,M,T,A,k,B)=>{const F=A.x>=T.x,X=F?k.right:k.left,P=X+(F?20:-20);if(F&&p.b.x<=P+.001||!F&&p.b.x>=P-.001)return;const z=p.a.y+M;return bt([{x:X,y:T.y},{x:P,y:T.y},{x:P,y:z},{x:p.b.x,y:z},...B],.001)},"horizontalSourceDetour"),v=f((p,M)=>{const T=x(p);if(T){if(p.vertical)return C(p,M,T.sourceCenter,T.targetCenter,T.sourceRect,T.tail);if(p.horizontal)return b(p,M,T.sourceCenter,T.targetCenter,T.sourceRect,T.tail)}},"sourceDetourCandidate"),L=[-7,7,-14,14,-21,21];for(let p=0;p<12;p++){const M=y();let T=!1;for(let A=0;A<M.length&&!T;A++)for(let k=A+1;k<M.length&&!T;k++){const B=M[A],F=M[k];if(B.edge===F.edge||!S(B,F))continue;const X=[B,F].filter(P=>P.interior);for(const P of X){for(const z of L){const U=h(P,z);if(U&&u(P.edge,U)){P.edge.points=U,T=!0;break}const et=v(P,z);if(et&&u(P.edge,et)){P.edge.points=et,T=!0;break}}if(T)break}}if(!T)return}}w(Pn,"nudgeSharedInteriorSubpaths");f(Pn,"nudgeSharedInteriorSubpaths");function ys(t,e,n,o){const s=e.x-t.x,r=e.y-t.y,d=o.x-n.x,a=o.y-n.y,l=s*a-r*d;if(Math.abs(l)<1e-10)return!1;const c=n.x-t.x,g=n.y-t.y,y=(c*a-g*d)/l,S=(c*r-g*s)/l,u=.01;return y>u&&y<1-u&&S>u&&S<1-u}w(ys,"segmentsIntersect");f(ys,"segmentsIntersect");function xs(t){const e=t.nodes??[],n=t.edges??[],o=[];if(!n.length||!e.length)return o;const s=$o(e),r=[];for(const a of n){if(a.isLayoutOnly)continue;const l=a.points;if(!l||l.length<2)continue;const c=a.start,g=a.end,y=a.labelNodeId,S=a.id??`${c}->${g}`;for(const u of s)if(!(u.nodeId===c||u.nodeId===g)&&!(y&&u.nodeId===y)){for(let h=0;h<l.length-1;h++)if(Je(l[h],l[h+1],u,-1)){o.push({type:"edge-node-overlap",edgeId:S,targetId:u.nodeId,detail:`segment ${h} passes through node "${u.nodeId}"`});break}}for(let u=0;u<l.length-1;u++)r.push({edgeId:S,start:c,end:g,p1:l[u],p2:l[u+1]})}const d=new Set;for(let a=0;a<r.length;a++)for(let l=a+1;l<r.length;l++){const c=r[a],g=r[l];if(c.edgeId!==g.edgeId&&!(c.start===g.start||c.start===g.end||c.end===g.start||c.end===g.end)&&ys(c.p1,c.p2,g.p1,g.p2)){const y=c.edgeId<g.edgeId?`${c.edgeId}|${g.edgeId}`:`${g.edgeId}|${c.edgeId}`;d.has(y)||(d.add(y),o.push({type:"edge-edge-crossing",edgeId:c.edgeId,targetId:g.edgeId,detail:`edges "${c.edgeId}" and "${g.edgeId}" cross`}))}}if(o.length>0){const a=o.filter(c=>c.type==="edge-node-overlap").length,l=o.filter(c=>c.type==="edge-edge-crossing").length;To.warn(`[SWIMLANE_VALIDATE] ${o.length} issue(s) detected: ${a} edge-node overlap(s), ${l} edge crossing(s)`);for(const c of o)To.warn(`[SWIMLANE_VALIDATE] ${c.type}: ${c.detail}`)}return o}w(xs,"validateSwimlanesLayout");f(xs,"validateSwimlanesLayout");function bs(t,e){const n=t.nodes??[],o=t.edges??[],s=n.filter(a=>!a.isGroup);if((e==="LR"||e==="RL")&&s.length>0&&!rs(t,e)||e==="BT"&&s.length>0&&!ss(t))return;for(const a of o){if(a.isLayoutOnly)continue;const l=a.points;!l||l.length<2||(a.points=ue($e(l)))}gs(o,n),ps(o,n),is(o,n);const r=new Map;for(const a of n)r.set(String(a.id),a);He(o,r),Ko(o,r),cs(o,r),Pn(o,r),as(o,r),ls(o,r),wn(o,r),ds(o,r);const d=f(()=>{hs(o,r),fs(o,r),us(o,r),He(o,r),Tn(o,r),wn(o,r),He(o,r),Tn(o,r)},"finalizeRenderedEdges");d(),Pn(o,r),d(),Rn(o,r),An(o,r),Rn(o,r),An(o,r)}w(bs,"postProcessSwimlaneLayout");f(bs,"postProcessSwimlaneLayout");function ye(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 d=`${r.id}:${r.src}->${r.dst}`;n.has(d)||(n.add(d),o.push(r))}return{nodes:[...e.keys()],edges:o,layout:t.layout,nodeById:e}}w(ye,"normalizeGraph");f(ye,"normalizeGraph");function so(t,e){return t.edges.filter(n=>n.dst===e)}w(so,"incoming");f(so,"incoming");function Ms(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}w(Ms,"buildSuccessorMap");f(Ms,"buildSuccessorMap");function ro(t){const e=Ms(t);for(const n of e.values())n.sort((o,s)=>o.localeCompare(s));return e}w(ro,"buildSortedSuccessorMap");f(ro,"buildSortedSuccessorMap");function io(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}w(io,"buildInDegreeMap");f(io,"buildInDegreeMap");function co(t){return[...t.entries()].filter(([,e])=>e===0).map(([e])=>e).sort((e,n)=>e.localeCompare(n))}w(co,"sortedZeroInDegreeNodes");f(co,"sortedZeroInDegreeNodes");function Ze(t,e=()=>!0){const n=new Map,o=new Map;for(const s of t.nodes)n.set(s,[]),o.set(s,[]);for(const s of t.edges)e(s)&&(o.get(s.src).push(s.dst),n.get(s.dst).push(s.src));return{preds:n,succs:o}}w(Ze,"buildPredecessorSuccessorMaps");f(Ze,"buildPredecessorSuccessorMaps");function ao(t,e,n,o){var d,a;let s=0;for(const l of t.nodes)o!=null&&o.skipGroups&&((d=t.nodeById.get(l))!=null&&d.isGroup)||(s=Math.max(s,n[l]??0));const r=Array.from({length:s+1},()=>[]);for(const l of e)o!=null&&o.skipGroups&&((a=t.nodeById.get(l))!=null&&a.isGroup)||r[Math.max(0,n[l]??0)].push(l);return r}w(ao,"buildLayersFromRanks");f(ao,"buildLayersFromRanks");function De(t){const e=io(t),n=co(e),o=[],s=ro(t);for(;n.length;){const r=n.shift();o.push(r);for(const d of s.get(r)??[])if(e.set(d,(e.get(d)??0)-1),(e.get(d)??0)===0){let a=0;for(;a<n.length&&n[a]<d;)a++;n.splice(a,0,d)}}return o.length===t.nodes.length?o:null}w(De,"topoSortIfAcyclic");f(De,"topoSortIfAcyclic");function Ae(t){const e=new Map;let n=0;for(const o of t)e.set(o,n),n++;return e}w(Ae,"buildLayerIndex");f(Ae,"buildLayerIndex");function lo(t){const e=new Array(t.length),n=f((o,s)=>{if(s-o<=1)return 0;const r=o+s>>1;let d=n(o,r)+n(r,s),a=o,l=r,c=o;for(;a<r||l<s;)l>=s||a<r&&t[a]<=t[l]?e[c++]=t[a++]:(e[c++]=t[l++],d+=r-a);for(let g=o;g<s;g++)t[g]=e[g];return d},"count");return n(0,t.length)}w(lo,"countInversions");f(lo,"countInversions");function Ss(t){const e=ye(t),n=new Map;for(const g of e.nodes)n.set(g,[]);for(const g of e.edges)n.get(g.src).push(g);for(const g of n.values())g.sort((y,S)=>y.dst===S.dst?y.id.localeCompare(S.id):y.dst.localeCompare(S.dst));const o=Object.create(null);for(const g of e.nodes)o[g]=0;const s=[],r=f(g=>{o[g]=1;for(const y of n.get(g)??[]){const S=y.dst;o[S]===0?r(S):o[S]===1&&s.push(y)}o[g]=2},"dfs"),d=[...e.nodes].sort((g,y)=>g.localeCompare(y));for(const g of d)o[g]===0&&r(g);const a=new Set(s.map(g=>`${g.id}:${g.src}->${g.dst}`)),l=e.edges.map(g=>a.has(`${g.id}:${g.src}->${g.dst}`)?{id:g.id,src:g.dst,dst:g.src,weight:g.weight,ref:g.ref}:g);return{acyclic:{nodes:[...e.nodes],edges:l,layout:e.layout,nodeById:new Map(e.nodeById)},reversed:s}}w(Ss,"removeCycles_DFS");f(Ss,"removeCycles_DFS");function Is(t){const e=new Map,n=f(o=>{if(e.has(o))return e.get(o);const s=t.nodeById.get(o);if(!s)return e.set(o,null),null;const r=s.parentId;if(!r)return e.set(o,null),null;const a=n(r)??r;return e.set(o,a),a},"resolve");for(const o of t.nodes)n(o);return e}w(Is,"buildTopLaneMap");f(Is,"buildTopLaneMap");function me(t){const e=Is(t);return n=>e.get(n)??null}w(me,"createTopLaneResolver");f(me,"createTopLaneResolver");function Qe(t){const e=[];for(const n of t.layout.nodes??[])n.isGroup&&!n.parentId&&e.push(n.id);return[...new Set(e)].reverse()}w(Qe,"buildTopLaneOrder");f(Qe,"buildTopLaneOrder");function fo(t,e){const n=Qe(t);if(!e||e.length===0)return n;const o=new Set(n),s=new Set,r=[];for(const d of e)!o.has(d)||s.has(d)||(s.add(d),r.push(d));for(const d of n)s.has(d)||r.push(d);return r}w(fo,"resolveTopLaneOrder");f(fo,"resolveTopLaneOrder");var Dr={EPSILON:1e-6},kn={GRAVITY_ITERATIONS:8,MAX_CROSSING_OPTIMIZATION_PASSES:4,DEFAULT_COMPACT_SINGLE_INPUT:!0},pr={DEFAULT_LAYER_GAP:100,DEFAULT_NODE_GAP:40};function Cs(t,e){const n=ye(t),o=(e==null?void 0:e.laneOf)??(()=>null),s=e==null?void 0:e.rankHint,{preds:r}=Ze(n);for(const p of r.values())p.sort((M,T)=>M.localeCompare(T));const d=De(n)??[...n.nodes].sort((p,M)=>p.localeCompare(M)),a=new Map;for(const[p,M]of d.entries())a.set(M,p);const l=new Map,c=new Map;for(const p of n.nodes)c.set(p,[]);for(const p of d){const M=(r.get(p)??[]).filter(T=>l.has(T));if(M.length>0){const T=vs(p,M,{laneOf:o,rankHint:s,topoIndex:a});l.set(p,T),c.get(T).push(p)}else l.has(p)||l.set(p,null)}for(const p of n.nodes)l.has(p)||l.set(p,null);const g=new Set;for(const p of n.nodes)(l.get(p)??null)===null&&g.add(p);const y=[...g].sort((p,M)=>{const T=a.get(p)??0,A=a.get(M)??0;return T===A?p.localeCompare(M):T-A}),S=Ls(n),u=new Map;for(const[p,M]of S.entries())u.set(p,[...M].sort((T,A)=>T.localeCompare(A)));const h=Ts(u),i=Es(u),x=new Map;for(const p of n.nodes)x.set(p,[]);for(const p of i)for(const M of p.nodes){const T=x.get(M);T?T.push(p.id):x.set(M,[p.id])}const C=[],b=[],v=new Set,L=f(p=>{if(!v.has(p)){v.add(p),C.push(p);for(const M of c.get(p)??[])L(M);b.push(p)}},"walk");for(const p of y)L(p);for(const p of d)L(p);return{parent:l,children:c,roots:y,componentOf:h,blocks:i,nodeBlocks:x,adjacency:u,preorder:C,postorder:b,topologicalOrder:d}}w(Cs,"buildDrivingTree");f(Cs,"buildDrivingTree");function vs(t,e,n){const o=n.laneOf(t);return[...e].sort((r,d)=>{var i,x;const a=n.laneOf(r),l=n.laneOf(d),c=a!=null&&a===o,g=l!=null&&l===o;if(c!==g)return c?-1:1;const y=(i=n.rankHint)==null?void 0:i[r],S=(x=n.rankHint)==null?void 0:x[d];if(y!=null&&S!=null&&y!==S)return S-y;const u=n.topoIndex.get(r)??0,h=n.topoIndex.get(d)??0;return u!==h?u-h:r.localeCompare(d)})[0]}w(vs,"chooseParent");f(vs,"chooseParent");function Ls(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}w(Ls,"buildAdjacency");f(Ls,"buildAdjacency");function Ts(t){const e=new Map;let n=0;for(const o of t.keys()){if(e.has(o))continue;const s=[o];for(;s.length>0;){const r=s.pop();if(!e.has(r)){e.set(r,n);for(const d of t.get(r)??[])e.has(d)||s.push(d)}}n++}return e}w(Ts,"assignComponents");f(Ts,"assignComponents");function Es(t){const e=new Map,n=new Map,o=[],s=[];let r=0;const d=f((a,l)=>{e.set(a,++r),n.set(a,r);for(const c of t.get(a)??[])c!==l&&(e.has(c)?(e.get(c)??0)<(e.get(a)??0)&&(o.push([a,c]),n.set(a,Math.min(n.get(a)??r,e.get(c)??r))):(o.push([a,c]),d(c,a),n.set(a,Math.min(n.get(a)??r,n.get(c)??r)),(n.get(c)??0)>=(e.get(a)??0)&&s.push(ws(a,c,o,s.length))))},"visit");for(const a of t.keys())e.has(a)||d(a,null);return s}w(Es,"computeBlocks");f(Es,"computeBlocks");function ws(t,e,n,o){const s=[],r=new Set;for(;n.length>0;){const d=n.pop();if(s.push(d),r.add(d[0]),r.add(d[1]),d[0]===t&&d[1]===e||d[0]===e&&d[1]===t)break}return{id:o,edges:s,nodes:[...r]}}w(ws,"popBlock");f(ws,"popBlock");function Rs(t,e,n){const o=[...t.nodes],s=new Map;for(const[b,v]of o.entries())s.set(v,b);const r=o.length,d=new Array(r).fill(-1),a=new Array(r).fill(0),l=[],c=new Set;for(const b of o){const v=n.parent.get(b)??null,L=s.get(b);L!=null&&v==null&&(d[L]=-1,a[L]=0,c.has(b)||(c.add(b),l.push(b)))}for(;l.length>0;){const b=l.shift(),v=s.get(b);if(v==null)continue;const L=n.children.get(b)??[];for(const p of L){if(c.has(p))continue;const M=s.get(p);M!=null&&(d[M]=v,a[M]=a[v]+1,c.add(p),l.push(p))}}for(const b of o){if(c.has(b))continue;const v=s.get(b);v!=null&&(d[v]=-1,a[v]=0,c.add(b))}const g=Math.max(1,Math.ceil(Math.log2(Math.max(1,r)))+1),y=Array.from({length:g},()=>new Array(r).fill(-1));for(let b=0;b<r;b++)y[0][b]=d[b];for(let b=1;b<g;b++)for(let v=0;v<r;v++){const L=y[b-1][v];y[b][v]=L===-1?-1:y[b-1][L]}const S=f((b,v)=>{if(b===-1||v===-1)return-1;a[b]<a[v]&&([b,v]=[v,b]);const L=a[b]-a[v];for(let p=0;p<g;p++)if(L>>p&1&&(b=y[p][b],b===-1))return-1;if(b===v)return b;for(let p=g-1;p>=0;p--){const M=y[p][b],T=y[p][v];M===-1||T===-1||M!==T&&(b=M,v=T)}return y[0][b]},"lcaIndex"),u=Array.from({length:r},()=>new Map);for(const b of t.edges){let v=b.src,L=b.dst,p=e[v],M=e[L];if(p==null||M==null||(p>M&&([v,L]=[L,v],[p,M]=[M,p]),p==null||M==null||p===M))continue;const T=s.get(v),A=s.get(L);if(T==null||A==null)continue;const k=S(T,A);if(k===-1)continue;const B=u[k];for(let F=p;F<M;F++)B.set(F,(B.get(F)??0)+1)}const h=new Map,i=f((b,v)=>{if(v.size!==0)for(const[L,p]of v)b.set(L,(b.get(L)??0)+p)},"mergeInto"),x=new Set,C=f(b=>{const v=s.get(b);x.add(b);const L=v==null?void 0:u[v],p=L?new Map(L):new Map,M=n.children.get(b)??[];for(const T of M){const A=C(T),k=e[b];if(k!=null){let B=h.get(b);B||(B=new Map,h.set(b,B));let F=A.get(k)??0;const X=e[T];X!=null&&X>k&&(F+=1),B.set(T,F)}i(p,A)}return p},"dfs");for(const b of n.roots)x.has(b)||C(b);for(const b of o)x.has(b)||C(b);return h}w(Rs,"computeSubtreeCrossCounts");f(Rs,"computeSubtreeCrossCounts");function As(t,e,n){const o=new Map,s=f(r=>{let d=n[r]??0;const a=[...e.get(r)??[]];a.sort(uo(n));for(const l of a){s(l);const c=o.get(l);c!=null&&(d=Math.min(d,c))}o.set(r,d)},"annotate");for(const r of t)s(r);return o}w(As,"annotateMinimumLayers");f(As,"annotateMinimumLayers");function uo(t){return(e,n)=>{const o=t[e]??0,s=t[n]??0;return o===s?e.localeCompare(n):o-s}}w(uo,"compareByRankThenId");f(uo,"compareByRankThenId");function Os(t,e,n,o){let s=0;for(const l of e){const c=n[l]??0;c>s&&(s=c)}const r=Array.from({length:s+1},()=>[]),d=new Set,a=f(l=>{if(d.has(l))return;d.add(l);const c=n[l]??0;r[c]||(r[c]=[]),r[c].push(l);for(const g of o(l))a(g)},"emit");for(const l of t)a(l);for(const l of e)if(!d.has(l)){const c=n[l]??0;r[c]||(r[c]=[]),r[c].push(l),d.add(l)}return r}w(Os,"emitNodesInTreeOrder");f(Os,"emitNodesInTreeOrder");function Ns(t){const e=[];for(const n of t){const o=new Set,s=[];for(const r of n)o.has(r)||(o.add(r),s.push(r));e.push(s)}return e}w(Ns,"deduplicateLayers");f(Ns,"deduplicateLayers");function Bs(t,e,n,o){return s=>{const r=t.get(s)??[];if(r.length===0)return[];const d=e[s]??0,a=[],l=[],c=n.get(s);for(const g of r){const y=o.get(g)??d;y>d?a.push({child:g,min:y}):l.push(g)}return a.sort((g,y)=>g.min===y.min?g.child.localeCompare(y.child):g.min-y.min),l.sort((g,y)=>{const S=(c==null?void 0:c.get(g))??0,u=(c==null?void 0:c.get(y))??0;if(S!==u)return S-u;const h=o.get(g)??d,i=o.get(y)??d;return h!==i?h-i:g.localeCompare(y)}),[...a.map(g=>g.child),...l]}}w(Bs,"createChildOrderer");f(Bs,"createChildOrderer");function Ke(t,e,n){const o=Cs(t,{rankHint:e,laneOf:n}),{children:s,roots:r}=o;for(const y of t.nodes)s.has(y)||s.set(y,[]);const d=Rs(t,e,o),a=[...r].sort(uo(e)),l=As(a,s,e),c=Bs(s,e,d,l);let g=Os(a,t.nodes,e,c);return g=Ns(g),g}w(Ke,"buildMultitreeLayerOrder");f(Ke,"buildMultitreeLayerOrder");function Ps(t,e,n){const o=new Set(t),s=new Set(e),r=Ae(e),d=[];for(const a of n)o.has(a.src)&&s.has(a.dst)&&d.push(r.get(a.dst));return lo(d)}w(Ps,"countCrossingsBetweenAdjacent");f(Ps,"countCrossingsBetweenAdjacent");function Fn(t,e,n){const o=[];for(const r of e){const d=n[r.src],a=n[r.dst];if(d==null||a==null||d===a)continue;let l=r.src,c=r.dst,g=d,y=a;d>a&&(l=r.dst,c=r.src,g=a,y=d);for(let S=g;S<y;S++)o.push({id:`${r.id}@${S}`,src:l,dst:c,ref:r.ref})}let s=0;for(let r=0;r+1<t.length;r++)s+=Ps(t[r],t[r+1],o);return s}w(Fn,"totalCrossings");f(Fn,"totalCrossings");function ks(t,e){const n={...e},{preds:o}=Ze(t),s=me(t),r=Ke(t,n,s);let d=Fn(r,t.edges,n);const a=kn.MAX_CROSSING_OPTIMIZATION_PASSES;for(let l=0;l<a;l++){let c=!1;const g=[...t.nodes].sort((y,S)=>(n[S]??0)-(n[y]??0));for(const y of g){const S=n[y]??0;if(S===0)continue;let u=0;for(const C of o.get(y)??[])u=Math.max(u,(n[C]??0)+1);if(u>=S)continue;const h=S;n[y]=u;const i=Ke(t,n,s),x=Fn(i,t.edges,n);x<d?(d=x,c=!0):n[y]=h}if(!c)break}return n}w(ks,"optimizeRanksByCrossings");f(ks,"optimizeRanksByCrossings");function Fs(t,e){const n=me(t),o=[...t.nodes].sort((s,r)=>(e[s]??0)-(e[r]??0)||s.localeCompare(r));for(const s of o){const r=n(s);if(!r)continue;const d=t.edges.filter(i=>i.src===s);if(d.length===0)continue;let a=!1,l=0;for(const i of d){const x=n(i.dst);x==null||x===r?a=!0:l++}if(l===0||a)continue;let c=0,g=!1;for(const i of t.edges){if(i.dst!==s)continue;const x=n(i.src);x&&(x===r?g=!0:c++)}if(c>0||!g)continue;const y=e[s]??0,S=y+l;let u=0;for(const i of t.edges)i.dst===s&&(u=Math.max(u,(e[i.src]??0)+1));const h=Math.max(y,u,S);h!==y&&(e[s]=h)}}w(Fs,"adjustCrossLaneSources");f(Fs,"adjustCrossLaneSources");function _s(t,e){const n=ye(t),o=De(n)??[...n.nodes].sort(),s=(e==null?void 0:e.compactSingleInput)??!1,r=me(n);let d=Object.create(null);for(const l of o){const c=so(n,l),g=e!=null&&e.ignoreCrossLaneEdges?c.filter(y=>{const S=r(y.src),u=r(l);return!S||!u?!0:S===u}):c;if(g.length===0)d[l]=0;else if(s&&g.length===1){const y=g[0].src,S=r(y),u=r(l);S!==u?d[l]=d[y]??0:d[l]=(d[y]??0)+1}else{let y=-1/0;for(const S of g)y=Math.max(y,(d[S.src]??0)+1);d[l]=y===-1/0?0:y}}return((e==null?void 0:e.optimizeRanksByCrossings)??!1)&&(d=ks(n,d)),e!=null&&e.ignoreCrossLaneEdges&&Fs(n,d),{layers:Ke(n,d,r),rankOf:d,dummy:new Set}}w(_s,"assignLayers_LongestPath");f(_s,"assignLayers_LongestPath");function Ds(t,e){const n=ye(t),s={..._s(n,{compactSingleInput:e==null?void 0:e.compactSingleInput,ignoreCrossLaneEdges:e==null?void 0:e.ignoreCrossLaneEdges,optimizeRanksByCrossings:e==null?void 0:e.optimizeRanksByCrossings}).rankOf},r=me(n),{preds:d,succs:a}=Ze(n,h=>{if(e!=null&&e.ignoreCrossLaneEdges){const i=r(h.src),x=r(h.dst);if(i&&x&&i!==x)return!1}return!0}),l=De(n)??[...n.nodes],c=[...l].reverse(),g=f((h,i)=>{let x=0;for(const v of d.get(h)??[])x=Math.max(x,(s[v]??0)+1);let C=Number.POSITIVE_INFINITY;const b=a.get(h)??[];return b.length>0&&(C=Math.min(...b.map(v=>(s[v]??0)-1))),Number.isFinite(C)||(C=Math.max(x,i)),Math.min(Math.max(i,x),C)},"clampFeasible"),y=kn.GRAVITY_ITERATIONS,S=f(h=>{let i=!1;for(const x of h){const C=d.get(x)??[],b=a.get(x)??[];if(C.length===0&&b.length===0)continue;const v=C.length>0?C.reduce((T,A)=>T+(s[A]??0)+1,0)/C.length:s[x]??0,L=b.length>0?b.reduce((T,A)=>T+(s[A]??0)-1,0)/b.length:s[x]??0,p=Math.round((v+L)/2),M=g(x,p);M!==s[x]&&(s[x]=M,i=!0)}return i},"relaxOrder");for(let h=0;h<y;h++){const i=S(l),x=S(c);if(!i&&!x)break}for(const h of l){let i=0;for(const x of d.get(h)??[])i=Math.max(i,(s[x]??0)+1);(s[h]??0)<i&&(s[h]=i)}for(const h of c){const i=a.get(h)??[];if(i.length>0){const x=Math.min(...i.map(C=>(s[C]??0)-1));(s[h]??0)>x&&(s[h]=x)}}return{layers:ao(n,l,s),rankOf:s,dummy:new Set}}w(Ds,"assignLayers_Gravity");f(Ds,"assignLayers_Gravity");function Hs(t){const e=io(t),n=ro(t);let o=co(e);const s=[];for(;o.length>0;){const r=[];for(const d of o){s.push(d);for(const a of n.get(d)??[])e.set(a,(e.get(a)??0)-1),(e.get(a)??0)===0&&r.push(a)}o=r.sort((d,a)=>d.localeCompare(a))}return s.length===t.nodes.length?s:null}w(Hs,"topoSortByGenerationIfAcyclic");f(Hs,"topoSortByGenerationIfAcyclic");function Xs(t,e){const n=ye(t),o=(e==null?void 0:e.direction)==="LR"?Hs(n)??[...n.nodes].sort():De(n)??[...n.nodes].sort(),s=me(n),r=f(g=>s(g)??g,"laneOf"),d=Object.create(null),a=new Map,l=f((g,y)=>(e==null?void 0:e.ignoreCrossLaneEdges)??!0?r(g)===r(y)?1:0:1,"edgeWeight");for(const g of o){const y=n.nodeById.get(g);if(y!=null&&y.isGroup)continue;const S=so(n,g);let u=0;if(S.length>0)for(const C of S){const b=C.src,v=d[b]??0;u=Math.max(u,v+l(b,g))}const h=r(g),i=a.get(h)??0,x=Math.max(u,i);d[g]=x,a.set(h,x+1)}return{layers:ao(n,o,d,{skipGroups:!0}),rankOf:d,dummy:new Set}}w(Xs,"assignLayers_LaneAwareCompact");f(Xs,"assignLayers_LaneAwareCompact");function Ys(t,e){const n=ye(e),{rankOf:o}=t,s=t.layers.map(u=>[...u]),r=new Set(t.dummy?[...t.dummy]:[]);let d=0;const a=new Map(n.nodeById),l=f(u=>{const h=`placeholder-${d++}`,i={id:h,isGroup:!1,isDummy:!0,width:0,height:0};for(a.set(h,i),r.add(h);s.length<=u;)s.push([]);return s[u].push(h),o[h]=u,h},"addDummyAt"),c=[...n.edges].sort((u,h)=>u.id===h.id?u.src===h.src?u.dst.localeCompare(h.dst):u.src.localeCompare(h.src):u.id.localeCompare(h.id)),g=[];for(const u of c){const h=o[u.src]??0,i=o[u.dst]??0;if(i-h<=1){g.push(u);continue}let x=u.src;for(let b=h+1,v=0;b<i;b++,v++){const L=l(b);g.push({id:`${u.id}#${v}`,src:x,dst:L,weight:u.weight,ref:u.ref}),x=L}const C=i-h-2;g.push({id:`${u.id}#${Math.max(C+1,0)}`,src:x,dst:u.dst,weight:u.weight,ref:u.ref})}const S={nodes:[...n.nodes,...[...r].filter(u=>!n.nodes.includes(u))],edges:g,layout:n.layout,nodeById:a};return{layering:{layers:s,rankOf:o,dummy:r},graphWithDummies:S}}w(Ys,"makeProperLayering");f(Ys,"makeProperLayering");function _n(t){const e=t.length;if(e===0)return Number.POSITIVE_INFINITY;const n=[...t].sort((o,s)=>o-s);return e%2===1?n[(e-1)/2]:.5*(n[e/2-1]+n[e/2])}w(_n,"median");f(_n,"median");function Dn(t){return t.length===0?Number.POSITIVE_INFINITY:t.reduce((n,o)=>n+o,0)/t.length}w(Dn,"barycenter");f(Dn,"barycenter");function Gs(t,e,n,o){const s=new Map;for(const r of t)s.set(r,[]);for(const r of n)o==="down"?e.has(r.src)&&s.has(r.dst)&&s.get(r.dst).push(e.get(r.src)):e.has(r.dst)&&s.has(r.src)&&s.get(r.src).push(e.get(r.dst));return s}w(Gs,"neighborPositionsFor");f(Gs,"neighborPositionsFor");function zs(t,e,n){const o=n.get(t)??0,s=n.get(e)??0;return o!==s?o-s:t.localeCompare(e)}w(zs,"currentOrderTieBreak");f(zs,"currentOrderTieBreak");function Hn(t,e,n){const o=new Set(t),s=new Set(e),r=Ae(t),d=Ae(e),a=[];for(const c of n)o.has(c.src)&&s.has(c.dst)&&a.push({u:r.get(c.src),v:d.get(c.dst)});a.sort((c,g)=>c.u===g.u?c.v-g.v:c.u-g.u);const l=a.map(c=>c.v);return lo(l)}w(Hn,"countCrossingsBetweenAdjacent2");f(Hn,"countCrossingsBetweenAdjacent");function Xe(t,e,n){return[...t].sort((o,s)=>{const r=_n(e.get(o)??[]),d=_n(e.get(s)??[]);return r===d?zs(o,s,n):isFinite(r)?isFinite(d)?r-d:-1:1})}w(Xe,"sortByHeuristic");f(Xe,"sortByHeuristic");function Xn(t,e,n,o,s,r){const d=Ae(t),a=Ae(e),l=Gs(e,d,n,o);if(!s||!r||r.length===0)return Xe(e,l,a);const c=new Map;for(const S of e){const u=s(S),h=c.get(u)??[];h.push(S),c.set(u,h)}const g=[];for(const S of r){const u=c.get(S);if(!u||u.length===0)continue;const h=Xe(u,l,a);g.push(...h)}const y=c.get(null);if(y&&y.length>0){const S=Xe(y,l,a);for(const u of S){const h=Dn(l.get(u)??[]);let i=g.length;if(isFinite(h))for(const[x,C]of g.entries()){const b=Dn(l.get(C)??[]);if(h<b){i=x;break}}g.splice(i,0,u)}}return g}w(Xn,"reorderLayer");f(Xn,"reorderLayer");function Yn(t,e,n,o,s){const r=[...e],d=new Set(t),a=new Set(e),l=o?new Set(o):null,c=n.filter(i=>d.has(i.src)&&a.has(i.dst)),g=l?n.filter(i=>a.has(i.src)&&l.has(i.dst)):void 0,y=f(i=>{let x=Hn(t,i,c);return g&&o&&(x+=Hn(i,o,g)),x},"crossingScore"),S=s?new Map:null;if(s&&S)for(const i of e)S.set(i,s(i));let u=!0,h=y(r);for(;u;){u=!1;for(let i=0;i+1<r.length;i++){if(S){const b=S.get(r[i]),v=S.get(r[i+1]);if(b!==v)continue}const x=h;[r[i],r[i+1]]=[r[i+1],r[i]];const C=y(r);C<x?(h=C,u=!0):[r[i],r[i+1]]=[r[i+1],r[i]]}}return r}w(Yn,"transposeImprove");f(Yn,"transposeImprove");function $s(t,e,n){const o=t.layers.map(a=>[...a]),s=e.edges,r=me(e),d=fo(e,n==null?void 0:n.laneOrder);for(let a=0;a<3;a++){for(let l=1;l<o.length;l++)o[l]=Xn(o[l-1],o[l],s,"down",r,d),o[l]=Yn(o[l-1],o[l],s,o[l+1],r);for(let l=o.length-2;l>=0;l--)o[l]=Xn(o[l+1],o[l],s,"up",r,d),o[l]=Yn(o[l+1],o[l],s,o[l-1],r)}return{layers:o}}w($s,"orderLayers");f($s,"orderLayers");function Vs(t,e,n){const o=(n==null?void 0:n.layerGap)??pr.DEFAULT_LAYER_GAP,s=(n==null?void 0:n.nodeGap)??pr.DEFAULT_NODE_GAP,r=(n==null?void 0:n.laneGap)??s*2,d=(n==null?void 0:n.direction)??"TB",a=d==="LR"||d==="RL",l=t.layers,c=Object.create(null),g=Object.create(null),y=f(B=>e.nodeById.get(B),"getNode"),S=f(B=>{var F;return((F=y(B))==null?void 0:F.width)??0},"getWidth"),u=f(B=>{var F;return((F=y(B))==null?void 0:F.height)??0},"getHeight"),h=me(e),i=fo(e,n==null?void 0:n.laneOrder),x=l.map(B=>B.reduce((F,X)=>Math.max(F,u(X)),0)),C=[];if(a)for(let B=0;B+1<l.length;B++){const F=l[B].reduce((St,Xt)=>Math.max(St,S(Xt)),0),X=l[B+1].reduce((St,Xt)=>Math.max(St,S(Xt)),0),P=x[B],z=x[B+1],U=P/2+z/2,et=(F+X)/2,ft=Math.max(0,et-U-o);C.push(ft)}const b=new Set;for(const B of l)for(const F of B)b.add(h(F));const v=b.has(null),L=i.filter(B=>b.has(B)),p=[...v?[null]:[],...L],M=Object.create(null);for(const B of L)M[B]=0;v&&(M.null=0);for(const B of l){const F=Object.create(null),X=[];for(const P of B){const z=h(P);z===null?X.push(P):(F[z]||(F[z]=[])).push(P)}for(const[P,z]of Object.entries(F)){const U=z.reduce((et,ft)=>et+S(ft),0)+s*Math.max(0,z.length-1);M[P]=Math.max(M[P]??0,U)}if(v&&X.length){const P=X.reduce((z,U)=>z+S(U),0)+s*Math.max(0,X.length-1);M.null=Math.max(M.null??0,P)}}const T=new Map;{const B=p.map(P=>(P===null?M.null:M[P])??0);let X=-(B.reduce((P,z)=>P+z,0)+r*Math.max(0,p.length-1))/2;for(let P=0;P<p.length;P++){const z=p[P],U=B[P]??0,et=X+U/2;T.set(z,et),X+=U,P<p.length-1&&(X+=r)}}let A=0;for(const[B,F]of l.entries()){const X=x[B]??0,P=new Map;for(const U of F){const et=h(U),ft=P.get(et)??[];ft.push(U),P.set(et,ft)}for(const U of p){const et=P.get(U)??[];if(et.length===0)continue;const ft=T.get(U);if(et.length===1){const St=et[0];c[St]=ft,g[St]=A+X/2}else{const St=et.map(ot=>S(ot)),Xt=St.reduce((ot,Z)=>ot+Z,0)+s*(et.length-1);let Dt=ft-Xt/2;for(const[ot,Z]of et.entries()){const it=St[ot];c[Z]=Dt+it/2,g[Z]=A+X/2,Dt+=it+s}}}const z=C[B]??0;A+=X+o+z}const k=new Map;for(const B of e.edges){const F=B.ref.id;k.has(F)||k.set(F,[]),k.get(F).push(B)}for(const[,B]of k){if(B.length===0)continue;const F=B[0].ref,X=F.start,P=F.end;if(X==null||P==null)continue;const z=Math.round(((c[X]??0)+(c[P]??0))/2),U=new Set;for(const et of B)U.add(et.src),U.add(et.dst);for(const et of U){if(et===X||et===P)continue;const ft=e.nodeById.get(et);ft!=null&&ft.isDummy&&(c[et]=z)}}return{x:c,y:g}}w(Vs,"assignCoordinates");f(Vs,"assignCoordinates");var yr=8;function js(t){let e=2166136261;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e>>>0}w(js,"hashString");f(js,"hashString");function Us(t){let e=t>>>0;return()=>{e+=1831565813;let n=e;return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}w(Us,"mulberry32");f(Us,"mulberry32");function Ws(t,e){const n=[...t],o=Us(e);for(let s=n.length-1;s>0;s--){const r=Math.floor(o()*(s+1));[n[s],n[r]]=[n[r],n[s]]}return n}w(Ws,"deterministicShuffle");f(Ws,"deterministicShuffle");function Ks(t,e){let n=0;for(const[o,s]of t.entries())n+=Math.abs(o-(e.get(s)??o));return n}w(Ks,"sourceDistance");f(Ks,"sourceDistance");function Gn(t,e){const n=new Map;for(const[s,r]of t.entries())n.set(r,s);let o=0;for(const{a:s,b:r,weight:d}of e){const a=n.get(s),l=n.get(r);a==null||l==null||(o+=d*Math.abs(a-l))}return o}w(Gn,"laneArrangementCost");f(Gn,"laneArrangementCost");function Js(t){const e=Qe(t);if(e.length<2)return[];const n=new Map(e.map((r,d)=>[r,d])),o=me(t),s=new Map;for(const r of t.layout.edges??[]){if(r.isLayoutOnly)continue;const d=typeof r.start=="string"?r.start:void 0,a=typeof r.end=="string"?r.end:void 0;if(!d||!a||!t.nodeById.has(d)||!t.nodeById.has(a))continue;const l=o(d),c=o(a);if(!l||!c||l===c)continue;const g=n.get(l),y=n.get(c);if(g==null||y==null)continue;const[S,u]=g<=y?[l,c]:[c,l],h=`${S}\0${u}`,i=s.get(h);i?i.weight++:s.set(h,{a:S,b:u,weight:1})}return[...s.values()]}w(Js,"buildWeightedLaneEdges");f(Js,"buildWeightedLaneEdges");function zn(t,e,n){const o=[...t];let s=Gn(o,e),r=!0,d=0;const a=Math.max(1,o.length);for(;r&&d<a;){r=!1,d++;for(let l=0;l+1<o.length;l++){[o[l],o[l+1]]=[o[l+1],o[l]];const c=Gn(o,e);c<s?(s=c,r=!0):[o[l],o[l+1]]=[o[l+1],o[l]]}}return{order:o,cost:s,sourceDistance:Ks(o,n)}}w(zn,"greedySwitch");f(zn,"greedySwitch");function qs(t,e){return t.cost!==e.cost?t.cost<e.cost:t.sourceDistance<e.sourceDistance}w(qs,"isBetterCandidate");f(qs,"isBetterCandidate");function Zs(t,e,n){const o=[...e].sort((s,r)=>s.a===r.a?s.b.localeCompare(r.b):s.a.localeCompare(r.a)).map(({a:s,b:r,weight:d})=>`${s}:${r}:${d}`).join("|");return js(`${t.join("|")}#${o}#${n}`)}w(Zs,"seedForRestart");f(Zs,"seedForRestart");function Qs(t,e={}){const n=Qe(t);if(n.length<2)return n;const o=Js(t);if(o.length===0)return n;const s=new Map(n.map((a,l)=>[a,l]));let r=zn(n,o,s);const d=Math.max(0,e.restarts??yr);for(let a=0;a<d;a++){const l=Zs(n,o,a),c=Ws(n,l),g=zn(c,o,s);qs(g,r)&&(r=g)}return r.order}w(Qs,"optimizeTopLaneOrder");f(Qs,"optimizeTopLaneOrder");function tr(t,e){const n=(e==null?void 0:e.ignoreCrossLaneEdges)??!0,o=(e==null?void 0:e.optimizeRanksByCrossings)??!0,s=ye(t),r=e!=null&&e.automaticLaneOrdering?Qs(s,{restarts:yr}):void 0,d=Ss(s),a=d.acyclic,l=n?Xs(a,{compactSingleInput:(e==null?void 0:e.compactSingleInput)??kn.DEFAULT_COMPACT_SINGLE_INPUT,ignoreCrossLaneEdges:!0,direction:e==null?void 0:e.direction}):Ds(a,{compactSingleInput:(e==null?void 0:e.compactSingleInput)??kn.DEFAULT_COMPACT_SINGLE_INPUT,ignoreCrossLaneEdges:!1,optimizeRanksByCrossings:o}),{layering:c,graphWithDummies:g}=Ys(l,a),y=$s(c,g,{laneOrder:r}),S=Vs(y,g,{layerGap:e==null?void 0:e.layerGap,nodeGap:e==null?void 0:e.nodeGap,direction:e==null?void 0:e.direction,laneOrder:r});return{acyclic:a,reversed:d.reversed,layering:c,ordered:y,coordinates:S}}w(tr,"sugiyamaLayout");f(tr,"sugiyamaLayout");var dt=Dr.EPSILON,Hr=8,Te=15,Fe=15,fn=25,ae=20,Lo=10;function $n(t,e,n){const o=t.x??0,s=t.y??0,r=e.x-o,d=e.y-s,a=Math.abs(r),l=Math.abs(d);return a<dt&&l<dt?n:l>dt&&l*3>=a?d>0?"bottom":"top":a>dt?r>0?"right":"left":n}w($n,"chooseOrthogonalSide");f($n,"chooseOrthogonalSide");function Vn(t,e){return Math.abs(t.to-e.from)<dt||Math.abs(t.to-e.to)<dt?t.to:t.from}w(Vn,"sharedLineEndpointCoord");f(Vn,"sharedLineEndpointCoord");function Ce(t,e){return t.orient==="vertical"?{x:t.coord,y:e}:{x:e,y:t.coord}}w(Ce,"pointOnLine");f(Ce,"pointOnLine");function er(t,e){var J,Q,G,q;const n=t.nodes??[],o=t.edges??[],s=[];for(const m of o)m.isLayoutOnly||s.push({...m,__originalEdge:m});const r=new Map,d=new Map,a=[],l=e==="LR";for(const m of n)r.set(m.id,m);const c=n.filter(m=>m.isGroup&&!m.parentId);for(const m of c){const I={id:m.id},R=f(E=>{d.set(E.id,I),n.filter(N=>N.parentId===E.id).forEach(R)},"assignLane");R(m)}const g=n.filter(m=>!m.isGroup&&!m.isEdgeLabel).map(m=>{const I=m.width??10,R=m.height??10,E=m.x??0,N=m.y??0,H=Hr;return{nodeId:m.id,minX:E-I/2-H,maxX:E+I/2+H,minY:N-R/2-H,maxY:N+R/2+H,visualXHalfExtent:l?R/2+H:I/2+H}}),y=f((m,I,R,E)=>{let N=a.find(H=>H.orientation===m&&Math.abs(H.coord-I)<1);return N||(N={id:`pipe-${m}-${I.toFixed(0)}`,orientation:m,coord:I,spanMin:R,spanMax:E,tracks:[]},a.push(N)),N.spanMin=Math.min(N.spanMin,R),N.spanMax=Math.max(N.spanMax,E),N},"getOrAddPipe"),S=f((m,I)=>{const R=m.width??10,E=m.height??10,N=m.x??0,H=m.y??0;switch(I){case"top":return{x:N,y:H-E/2};case"bottom":return{x:N,y:H+E/2};case"left":return{x:N-R/2,y:H};case"right":return{x:N+R/2,y:H}}},"portForSide"),u=f((m,I,R)=>S(m,$n(m,I,R?"bottom":"top")),"getOrthogonalPort"),h=[],i=[],x=new Set,C=1e3,b=f((m,I,R)=>{if(h.length===0)return 0;const E=Math.abs(I.y-R.y)<dt,N=Math.abs(I.x-R.x)<dt;if(!E&&!N)return 0;let H=0;if(E){const K=I.y,st=Math.min(I.x,R.x)-dt,W=Math.max(I.x,R.x)+dt;if(W<=st)return 0;for(const V of h)V.edgeIndex===m||V.orientation!=="vertical"||V.pipe.coord<st||V.pipe.coord>W||V.from-dt<=K&&V.to+dt>=K&&(H+=C)}else if(N){const K=I.x,st=Math.min(I.y,R.y)-dt,W=Math.max(I.y,R.y)+dt;if(W<=st)return 0;for(const V of h)V.edgeIndex===m||V.orientation!=="horizontal"||V.pipe.coord<st||V.pipe.coord>W||V.from-dt<=K&&V.to+dt>=K&&(H+=C)}return H},"crossingPenalty"),v=s.map((m,I)=>{if(!m.start||!m.end)return{idx:I,crossLane:0,dx:0,dy:0};const R=r.get(m.start),E=r.get(m.end),N=d.get(m.start),H=d.get(m.end),K=N&&H&&N.id!==H.id?1:0,st=R&&E?Math.abs((E.x??0)-(R.x??0)):0,W=R&&E?Math.abs((E.y??0)-(R.y??0)):0;return{idx:I,crossLane:K,dx:st,dy:W}}).sort((m,I)=>{if(m.crossLane!==I.crossLane)return I.crossLane-m.crossLane;const R=m.dx+m.dy,E=I.dx+I.dy;return Math.abs(R-E)>1?R-E:m.idx-I.idx}).map(m=>m.idx),L=f((m,I,R,E)=>{const N=Math.min(m.x,I.x),H=Math.max(m.x,I.x),K=Math.min(m.y,I.y),st=Math.max(m.y,I.y);return!!g.find(V=>R&&V.nodeId===R||E&&V.nodeId===E?!1:Math.abs(m.x-I.x)>dt?V.minY<m.y&&V.maxY>m.y&&V.maxX>N&&V.minX<H:V.minX<m.x&&V.maxX>m.x&&V.maxY>K&&V.minY<st)},"isSegmentBlocked"),p=new Map,M=new Map;for(const m of s)!m.start||!m.end||m.start===m.end||(M.set(m.start,(M.get(m.start)??0)+1),M.set(m.end,(M.get(m.end)??0)+1));const T=f((m,I)=>$n(m,I,"bottom"),"determineSide"),A=new Map;for(const[m,I]of s.entries()){if(!I.start||!I.end||I.start===I.end||I.points&&I.points.length>0)continue;const R=r.get(I.start),E=r.get(I.end);if(!R||!E)continue;const N=(E.x??0)-(R.x??0),H=(E.y??0)-(R.y??0);A.set(m,{edgeIdx:m,srcId:I.start,dstId:I.end,srcSide:T(R,{x:E.x??0,y:E.y??0}),dstSide:T(E,{x:R.x??0,y:R.y??0}),absDx:Math.abs(N),absDy:Math.abs(H),dxSign:Math.sign(N),dySign:Math.sign(H)})}const k=f(m=>m.srcSide==="top"||m.srcSide==="bottom"?m.absDx===0?1/0:m.absDy/m.absDx:m.absDy===0?1/0:m.absDx/m.absDy,"preferenceStrength"),B=f(m=>m.srcSide==="top"||m.srcSide==="bottom"?m.dxSign>=0?"right":"left":m.dySign>=0?"bottom":"top","secondarySide"),F=new Map;for(const m of A.values()){const I=`${m.srcId}:${m.srcSide}`;F.has(I)||F.set(I,[]),F.get(I).push(m)}const X=new Map,P=f((m,I)=>`${m}:${I}`,"loadKey");for(const m of A.values())X.set(P(m.srcId,m.srcSide),(X.get(P(m.srcId,m.srcSide))??0)+1),X.set(P(m.dstId,m.dstSide),(X.get(P(m.dstId,m.dstSide))??0)+1);for(const m of F.values())if(!(m.length<2)){m.sort((I,R)=>{const E=k(I),N=k(R);return Math.abs(E-N)>1e-9?N-E:I.edgeIdx-R.edgeIdx});for(let I=1;I<m.length;I++){const R=m[I],E=B(R),N=X.get(P(R.srcId,R.srcSide))??0,H=X.get(P(R.srcId,E))??0;H>=N||(X.set(P(R.srcId,R.srcSide),N-1),X.set(P(R.srcId,E),H+1),R.srcSide=E)}}const z=f(m=>{const I=m==null?void 0:m.shape;return I==="question"||I==="diamond"},"isDiamondNode"),U=new Map;for(const m of A.values())U.has(m.dstId)||U.set(m.dstId,new Set),U.get(m.dstId).add(m.dstSide);for(const m of A.values()){if(!z(r.get(m.srcId)))continue;const I=U.get(m.srcId);if(!(I!=null&&I.has(m.srcSide)))continue;const R=B(m);if(I.has(R)||(X.get(P(m.srcId,R))??0)>0)continue;const E=X.get(P(m.srcId,m.srcSide))??0;X.set(P(m.srcId,m.srcSide),Math.max(0,E-1)),X.set(P(m.srcId,R),1),m.srcSide=R}for(const m of A.values()){const{edgeIdx:I,srcId:R,dstId:E,srcSide:N,dstSide:H}=m,K=r.get(R),st=r.get(E),W=`${R}:${N}:src`,V=N==="top"||N==="bottom"?st.x??0:st.y??0;p.has(W)||p.set(W,[]),p.get(W).push({edgeIdx:I,oppositeCoord:V});const Mt=`${E}:${H}:dst`,ut=H==="top"||H==="bottom"?K.x??0:K.y??0;p.has(Mt)||p.set(Mt,[]),p.get(Mt).push({edgeIdx:I,oppositeCoord:ut})}const et=new Map,ft=8;for(const[m,I]of p){if(I.length<2)continue;I.sort((Nt,zt)=>Nt.oppositeCoord-zt.oppositeCoord);const R=m.split(":"),E=R.slice(0,-2).join(":"),N=R[R.length-2],H=R[R.length-1],K=r.get(E);if(!K)continue;const W=N==="left"||N==="right"?K.height??10:K.width??10,V=K.shape,ut=V==="question"||V==="diamond"?W*.3:W,rt=Math.min(20,Math.max(ft,ut/(I.length+1))),kt=-(rt*(I.length-1))/2;for(const[Nt,zt]of I.entries()){const oe=kt+Nt*rt,po=`${zt.edgeIdx}:${H}`;et.set(po,oe)}}const St=f(m=>{var I;return!!((I=s[m])!=null&&I.labelNodeId)},"edgeHasLabelNode"),Xt=f((m,I)=>m?(p.get(`${m}:${I}:src`)??[]).some(({edgeIdx:R})=>St(R))||(p.get(`${m}:${I}:dst`)??[]).some(({edgeIdx:R})=>St(R)):!1,"faceHasLabelNode"),Dt=f((m,I,R)=>I==="top"||I==="bottom"?{x:m.x+R,y:m.y}:{x:m.x,y:m.y+R},"applyPortOffset"),ot=f((m,I,R)=>{const E=A.get(m),N={x:R.x??0,y:R.y??0},H={x:I.x??0,y:I.y??0},K=(E==null?void 0:E.srcSide)??T(I,N),st=(E==null?void 0:E.dstSide)??T(R,H);let W=E?S(I,E.srcSide):u(I,N,!0),V=E?S(R,E.dstSide):u(R,H,!1);const Mt=et.get(`${m}:src`),ut=et.get(`${m}:dst`);return Mt!==void 0&&(W=Dt(W,K,Mt)),ut!==void 0&&(V=Dt(V,st,ut)),{pSrcPort:W,pDstPort:V,srcSide:K,dstSide:st}},"portsForEdge");for(const m of v){const I=s[m];if(i[m]=[],!I.start||!I.end||I.points&&I.points.length>0||I.start===I.end)continue;const R=r.get(I.start),E=r.get(I.end);if(!R||!E)continue;const{pSrcPort:N,pDstPort:H,srcSide:K,dstSide:st}=ot(m,R,E),W={...N},V={...H},Mt=K==="top"||K==="bottom",ut=st==="top"||st==="bottom";if(Mt){const Y=N.y>(R.y??0);W.y=Y?N.y+ae:N.y-ae}else{const Y=N.x>(R.x??0);W.x=Y?N.x+ae:N.x-ae}if(ut){const Y=H.y>(E.y??0);V.y=Y?H.y+ae:H.y-ae}else{const Y=H.x>(E.x??0);V.x=Y?H.x+ae:H.x-ae}const at=f((Y,$)=>{for(const tt of g)if(!$.includes(tt.nodeId)&&Y.x>tt.minX&&Y.x<tt.maxX&&Y.y>tt.minY&&Y.y<tt.maxY)return{inside:!0,obstacle:tt};return{inside:!1}},"isPointInObstacle"),rt=f((Y,$,tt,mt,wt)=>{if(wt){const Ft=Y.y>($.y??0);return{x:(tt.x??0)>=Y.x?mt.maxX+Te:mt.minX-Te,y:Ft?mt.maxY+Fe:mt.minY-Fe,leavesPositiveSide:Ft}}const vt=Y.x>($.x??0),Bt=(tt.y??0)>=Y.y;return{x:vt?mt.maxX+Te:mt.minX-Te,y:Bt?mt.maxY+Fe:mt.minY-Fe,leavesPositiveSide:vt}},"obstacleDetour");let It=[];const kt=[I.start,I.end],Nt=at(W,kt);if(Nt.inside&&Nt.obstacle){const Y=Nt.obstacle;if(Mt){const $=rt(N,R,E,Y,!0);W.x=$.x,W.y=$.y;const tt=$.leavesPositiveSide?Math.min(Y.minY-2,N.y+ae):Math.max(Y.maxY+2,N.y-ae);It=[{x:N.x,y:tt},{x:$.x,y:tt},{x:$.x,y:$.y}]}else{const $=rt(N,R,E,Y,!1),tt=$.leavesPositiveSide?Math.min(Y.minX-2,N.x+ae):Math.max(Y.maxX+2,N.x-ae);W.x=$.x,W.y=$.y,It=[{x:tt,y:N.y},{x:tt,y:$.y},{x:$.x,y:$.y}]}}let zt=[];const oe=at(V,kt);if(oe.inside&&oe.obstacle){const Y=oe.obstacle;if(ut){const $=rt(H,E,R,Y,!0);V.x=$.x,V.y=$.y,zt=[{x:$.x,y:$.y},{x:H.x,y:$.y}]}else{const $=rt(H,E,R,Y,!1);V.x=$.x,V.y=$.y,zt=[{x:$.x,y:$.y},{x:$.x,y:H.y}]}}if(It.length===0&&zt.length===0){const Y=Te,$=Math.abs(W.x-V.x)<Y,tt=Math.abs(W.y-V.y)<Y,mt=et.get(`${m}:src`)!==void 0||et.get(`${m}:dst`)!==void 0,wt=(((J=p.get(`${I.start??""}:${K}:src`))==null?void 0:J.length)??0)+(((Q=p.get(`${I.start??""}:${K}:dst`))==null?void 0:Q.length)??0),vt=(((G=p.get(`${I.end??""}:${st}:src`))==null?void 0:G.length)??0)+(((q=p.get(`${I.end??""}:${st}:dst`))==null?void 0:q.length)??0),Bt=wt>1||vt>1,Ft=M.get(I.start??"")??0,yt=M.get(I.end??"")??0,jt=wt>1&&Xt(I.start,K)||vt>1&&Xt(I.end,st),ce=wt<=1||Ft<=2,Ht=vt<=1||yt<=2;if(($||tt)&&!mt&&(!Bt||Bt&&!jt&&ce&&Ht)&&!L(N,H,I.start,I.end)){I.points=[{...N},{...W},{...V},{...H}],x.add(m);const Lt=tt?"horizontal":"vertical",Kt=tt?N.y:N.x,Tt=tt?Math.min(N.x,H.x):Math.min(N.y,H.y),Et=tt?Math.max(N.x,H.x):Math.max(N.y,H.y),te={id:`fast-path-${Lt}-${Kt.toFixed(0)}-${m}`,orientation:Lt,coord:Kt,spanMin:Tt,spanMax:Et,tracks:[]};h.push({edgeIndex:m,segmentIndex:0,orientation:Lt,pipe:te,trackIndex:0,from:Tt,to:Et});continue}}const po=y("vertical",W.x,W.y,W.y);W.x=po.coord;const xr=y("vertical",V.x,V.y,V.y);V.x=xr.coord;let be=Math.min(W.x,V.x)-50,Me=Math.max(W.x,V.x)+50,Be=Math.min(W.y,V.y)-50,Pe=Math.max(W.y,V.y)+50;for(const Y of g){const $=Math.min(W.x,V.x),tt=Math.max(W.x,V.x),mt=Math.min(W.y,V.y),wt=Math.max(W.y,V.y);Y.minX<tt&&Y.maxX>$&&Y.minY<wt&&Y.maxY>mt&&(be=Math.min(be,Y.minX-fn),Me=Math.max(Me,Y.maxX+fn),Be=Math.min(Be,Y.minY-fn),Pe=Math.max(Pe,Y.maxY+fn))}for(const Y of g){if(Y.maxX<be||Y.minX>Me||Y.maxY<Be||Y.minY>Pe)continue;const $=Te;y("horizontal",Y.minY-$,be,Me),y("horizontal",Y.maxY+$,be,Me);const tt=Fe;y("vertical",Y.minX-tt,Be,Pe),y("vertical",Y.maxX+tt,Be,Pe)}y("horizontal",W.y,be,Me),y("horizontal",V.y,be,Me);const br=a.filter(Y=>Y.orientation==="horizontal"&&Y.coord>=Be&&Y.coord<=Pe),Mr=a.filter(Y=>Y.orientation==="vertical"&&Y.coord>=be&&Y.coord<=Me),tn=f((Y,$)=>`${Y.toFixed(1)},${$.toFixed(1)}`,"getKey"),en=tn(W.x,W.y),rr=tn(V.x,V.y),nn=new Map,yo=new Map,xo=new Map,on=new Set,Le=[];nn.set(en,0),xo.set(en,"n"),Le.push({key:en,f:Math.hypot(V.x-W.x,V.y-W.y),pt:W}),on.add(en);let $t=[];const Se=f((Y,$)=>L(Y,$,I.start,I.end),"checkSegmentBlocked"),bo={x:V.x,y:W.y},Sr=Se(W,bo),Ir=Se(bo,V),Cr=Sr||Ir,Mo={x:W.x,y:V.y},vr=Se(W,Mo),Lr=Se(Mo,V);if(Cr?vr||Lr||(Math.abs(W.x-V.x)<dt?$t=[W,V]:$t=[W,Mo,V]):Math.abs(W.y-V.y)<dt||Math.abs(W.x-V.x)<dt?$t=[W,V]:$t=[W,bo,V],$t.length===0)for(;Le.length>0;){Le.sort((yt,jt)=>yt.f-jt.f);const Y=Le.shift();if(on.delete(Y.key),Y.key===rr){let yt=rr,jt=V;for($t=[jt];yo.has(yt);){const ce=yo.get(yt);$t.unshift(ce),jt=ce,yt=tn(ce.x,ce.y)}break}const $=Y.pt.x,tt=Y.pt.y,mt=Mr.sort((yt,jt)=>yt.coord-jt.coord),wt=mt.findIndex(yt=>Math.abs(yt.coord-$)<1),vt=br.sort((yt,jt)=>yt.coord-jt.coord),Bt=vt.findIndex(yt=>Math.abs(yt.coord-tt)<1),Ft=[];wt>0&&Ft.push({x:mt[wt-1].coord,y:tt}),wt>=0&&wt<mt.length-1&&Ft.push({x:mt[wt+1].coord,y:tt}),Bt>0&&Ft.push({x:$,y:vt[Bt-1].coord}),Bt>=0&&Bt<vt.length-1&&Ft.push({x:$,y:vt[Bt+1].coord});for(const yt of Ft){const jt=Math.min($,yt.x),ce=Math.max($,yt.x),Ht=Math.min(tt,yt.y),Wt=Math.max(tt,yt.y);if(g.some(se=>se.nodeId===I.start||se.nodeId===I.end?!1:jt!==ce?se.minY<tt&&se.maxY>tt&&se.maxX>jt&&se.minX<ce:se.minX<$&&se.maxX>$&&se.maxY>Ht&&se.minY<Wt))continue;const Lt=tn(yt.x,yt.y),Kt=Math.abs(yt.x-$)+Math.abs(yt.y-tt),Tt=b(m,Y.pt,yt);let Et=0;const te=V.x-W.x,ke=V.y-W.y,sn=yt.x-$,So=yt.y-tt;(ke>10&&So<-5||ke<-10&&So>5)&&(Et=Math.abs(So)*100),(te>10&&sn<-5||te<-10&&sn>5)&&(Et+=Math.abs(sn)*50);let ir=0;const cr=xo.get(Y.key)??"n",ar=Math.abs(sn)>dt?"h":"v";cr!=="n"&&cr!==ar&&(ir=50);const Tr=Kt+Tt+Et+ir,rn=(nn.get(Y.key)??1/0)+Tr,lr=Math.abs(V.x-yt.x)+Math.abs(V.y-yt.y);if(rn<(nn.get(Lt)??1/0))if(yo.set(Lt,Y.pt),nn.set(Lt,rn),xo.set(Lt,ar),!on.has(Lt))Le.push({key:Lt,f:rn+lr,pt:yt}),on.add(Lt);else{const se=Le.findIndex(Er=>Er.key===Lt);se!==-1&&(Le[se].f=rn+lr)}}}if($t.length===0&&($t=[W,{x:W.x,y:V.y},V]),$t.length>4){const Y=$t[0],$=$t[$t.length-1];let tt=Math.min(Y.x,$.x),mt=Math.max(Y.x,$.x),wt=Math.min(Y.y,$.y),vt=Math.max(Y.y,$.y);for(const Ht of $t)tt=Math.min(tt,Ht.x),mt=Math.max(mt,Ht.x),wt=Math.min(wt,Ht.y),vt=Math.max(vt,Ht.y);const Bt=mt>Math.max(Y.x,$.x),Ft=tt<Math.min(Y.x,$.x);if(l){const Ht=Fe;if(Bt){const Wt=Math.max(Y.x,$.x),_t=Math.min(Y.y,$.y),Lt=Math.max(Y.y,$.y),Kt=g.filter(Tt=>Tt.minX<Wt&&Tt.maxX>Wt&&Tt.minY<Lt&&Tt.maxY>_t);if(Kt.length>0){let Tt=Math.max(Y.x,$.x);for(const Et of Kt){const te=(Et.minX+Et.maxX)/2;if(Et.visualXHalfExtent===void 0||isNaN(Et.visualXHalfExtent))continue;const ke=te+Et.visualXHalfExtent+Ht;Tt=Math.max(Tt,ke)}isNaN(Tt)||(mt=Tt)}}if(Ft){const Wt=g.filter(_t=>_t.minX<Math.min(Y.x,$.x)+Ht&&_t.minY<Math.max(Y.y,$.y)&&_t.maxY>Math.min(Y.y,$.y));if(Wt.length>0){let _t=Math.min(Y.x,$.x);for(const Lt of Wt){const Tt=(Lt.minX+Lt.maxX)/2-Lt.visualXHalfExtent-Ht;_t=Math.min(_t,Tt)}tt=_t}}}const yt=f(Ht=>{const Wt=$.y>Y.y,_t=g.filter(Tt=>{const Et=Math.min(Y.x,$.x)<Tt.maxX&&Math.max(Y.x,$.x)>Tt.minX,te=Math.min(Y.y,$.y)<Tt.maxY&&Math.max(Y.y,$.y)>Tt.minY;return Et&&te});let Lt=_t;if(l&&_t.length>0){const Tt=_t.filter(Et=>Et.minX<Ht&&Et.maxX>Ht);Tt.length>0&&(Lt=Tt)}if(Lt.length===0)return $.y;const Kt=Te;if(Wt){const Et=Math.max(...Lt.map(te=>te.maxY))+Kt;if(Et<$.y-dt)return Et}else{const Et=Math.min(...Lt.map(te=>te.minY))-Kt;if(Et>$.y+dt)return Et}return $.y},"findBestReturnY"),jt=f(Ht=>{const Wt=yt(Ht),_t={x:Ht,y:Y.y},Lt={x:Ht,y:Wt},Kt={x:$.x,y:Wt},Tt=Se(Y,_t),Et=Se(_t,Lt),te=Se(Lt,Kt),ke=Wt!==$.y?Se(Kt,$):!1;return!Tt&&!Et&&!te&&!ke?Math.abs(Wt-$.y)<dt?[Y,_t,Lt,$]:[Y,_t,Lt,Kt,$]:null},"trySimplifyWithDetourX"),ce=Bt&&!Ft?jt(mt):Ft&&!Bt?jt(tt):null;ce&&($t=ce)}const Vt=[N,...It,...$t,...zt.reverse(),H];if(Vt.length>=3){const Y=Vt[Vt.length-1],$=Vt[Vt.length-2],tt=Vt[Vt.length-3],mt=Math.abs(tt.y-$.y)<dt&&Math.abs($.y-Y.y)<dt,wt=Math.abs(tt.x-$.x)<dt&&Math.abs($.x-Y.x)<dt;if(mt){const vt=Math.sign($.x-tt.x),Bt=Math.sign(Y.x-tt.x);vt!==0&&vt===Bt&&Math.abs($.x-tt.x)>Math.abs(Y.x-tt.x)&&Vt.splice(-2,1)}else if(wt){const vt=Math.sign($.y-tt.y),Bt=Math.sign(Y.y-tt.y);vt!==0&&vt===Bt&&Math.abs($.y-tt.y)>Math.abs(Y.y-tt.y)&&Vt.splice(-2,1)}}const he=[Vt[0]];for(let Y=1;Y<Vt.length-1;Y++){if(Y===1){he.push(Vt[Y]);continue}const $=he[he.length-1],tt=Vt[Y],mt=Vt[Y+1];if(Math.abs($.y-tt.y)<dt&&Math.abs(tt.y-mt.y)<dt){const wt=tt.x>$.x,vt=mt.x>tt.x;if(wt!==vt){he.push(tt);continue}continue}if(Math.abs($.x-tt.x)<dt&&Math.abs(tt.x-mt.x)<dt){const wt=tt.y>$.y,vt=mt.y>tt.y;if(wt!==vt){he.push(tt);continue}continue}he.push(tt)}he.push(Vt[Vt.length-1]);for(let Y=0;Y<he.length-1;Y++){const $=he[Y],tt=he[Y+1],mt=Math.abs($.x-tt.x)<dt?"vertical":"horizontal",wt=mt==="vertical"?$.x:$.y,vt=mt==="vertical"?Math.min($.y,tt.y):Math.min($.x,tt.x),Bt=mt==="vertical"?Math.max($.y,tt.y):Math.max($.x,tt.x),Ft=y(mt,wt,vt,Bt),yt={edgeIndex:m,segmentIndex:Y,orientation:mt,pipe:Ft,trackIndex:0,from:vt,to:Bt};h.push(yt),i[m].push(h.length-1),Ft.tracks[0]||(Ft.tracks[0]={index:0,coord:Ft.coord,segments:[]}),Ft.tracks[0].segments.push({edgeIndex:m,segmentIndex:Y,from:vt,to:Bt})}}const Z=f((m,I)=>m.from<I.to&&I.from<m.to,"segmentsOverlap"),it=f((m,I,R,E)=>{const N=!E.segments.some(K=>(K.edgeIndex!==I.edgeIndex||K.segmentIndex!==I.segmentIndex)&&Z(K,m)),H=!R.segments.some(K=>(K.edgeIndex!==m.edgeIndex||K.segmentIndex!==m.segmentIndex)&&Z(K,I));return N&&H?(m.trackIndex=E.index,I.trackIndex=R.index,R.segments=[...R.segments.filter(K=>K.edgeIndex!==m.edgeIndex||K.segmentIndex!==m.segmentIndex),{edgeIndex:I.edgeIndex,segmentIndex:I.segmentIndex,from:I.from,to:I.to}],E.segments=[...E.segments.filter(K=>K.edgeIndex!==I.edgeIndex||K.segmentIndex!==I.segmentIndex),{edgeIndex:m.edgeIndex,segmentIndex:m.segmentIndex,from:m.from,to:m.to}],!0):!1},"trySwapSegmentsAcrossTracks"),ht=f(m=>{const I=m.tracks.length;return m.tracks[I]={index:I,coord:m.coord,segments:[]},I},"createNewTrack"),xt=f((m,I)=>{const R=m.pipe.tracks[m.trackIndex];R.segments=R.segments.filter(N=>N.edgeIndex!==m.edgeIndex||N.segmentIndex!==m.segmentIndex),m.trackIndex=I,m.pipe.tracks[I].segments.push({edgeIndex:m.edgeIndex,segmentIndex:m.segmentIndex,from:m.from,to:m.to})},"moveSegmentToTrack"),Ct=f((m,I)=>{const R=i[m.edgeIndex];for(const E of R){const N=h[E];N.pipe===m.pipe&&xt(N,I)}},"moveSegmentChainToTrack"),Rt=f(m=>{const I=i[m.edgeIndex],R=I.indexOf(h.indexOf(m)),E=[];return R>0&&E.push(h[I[R-1]]),R<I.length-1&&E.push(h[I[R+1]]),E},"getAdjacentSegmentsAlongEdge"),qt=f((m,I)=>{if(m.orientation===I.orientation)return!1;const R=m.orientation==="horizontal"?m:I,E=m.orientation==="horizontal"?I:m;return E.pipe.coord>R.from&&E.pipe.coord<R.to&&R.pipe.coord>E.from&&R.pipe.coord<E.to},"haveAnyCrossing"),Zt=f((m,I)=>{for(const R of m.tracks)if(!R.segments.some(N=>(N.edgeIndex!==I.edgeIndex||N.segmentIndex!==I.segmentIndex)&&Z(N,I)))return R.index;return-1},"findAvailableTrack"),Qt=f((m,I)=>{if(m.trackIndex===I.trackIndex)return Z(m,I);const R=Rt(m),E=Rt(I);return R.some(N=>E.some(H=>qt(N,H)))},"segmentsConflict"),ie=f((m,I,R)=>{if(it(m,I,m.pipe.tracks[m.trackIndex],I.pipe.tracks[I.trackIndex]))return;const E=Zt(m.pipe,I);R(I,E!==-1?E:ht(m.pipe))},"resolveTrackConflict"),Oe=f(m=>{let I=0;for(let R=0;R<m.length;R++)for(let E=R+1;E<m.length;E++){const N=m[R],H=m[E];N.pipe===H.pipe&&Qt(N,H)&&(I++,ie(N,H,Ct))}return I},"resolveHandleConflicts"),xe=new Map,Ne=f(m=>{if(xe.has(m))return xe.get(m);const I=i[m];if(I.length===0){const st={dest:0,deviation:0,base:0,delta:0};return xe.set(m,st),st}const E=h[I[0]].pipe.coord;let N=E;for(let st=1;st<I.length;st++){const W=h[I[st]];if(W.orientation==="horizontal"){const V=W.from,Mt=W.to;N=Math.abs(V-E)>Math.abs(Mt-E)?V:Mt;break}}const H=Math.abs(N-E),K={dest:N,deviation:H,base:E,delta:N-E};return xe.set(m,K),K},"getDestInfo"),ho=f(()=>{let m=0;const I=new Map;for(const[E,N]of s.entries())i[E].length!==0&&N.start&&(I.has(N.start)||I.set(N.start,[]),I.get(N.start).push(E));const R=f(E=>{const N=s[E];if(!N.start||!N.end)return 0;const H=r.get(N.start),K=r.get(N.end);if(!H||!K)return 0;const st=(K.x??0)-(H.x??0),W=(K.y??0)-(H.y??0);return Math.abs(st)+Math.abs(W)},"getEdgeDistance");for(const E of I.values()){E.sort((H,K)=>{const st=Ne(H),W=Ne(K);if(Math.abs(st.deviation-W.deviation)>1)return st.deviation-W.deviation;if(Math.abs(st.dest-W.dest)>1)return st.dest-W.dest;const V=R(H),Mt=R(K);if(Math.abs(V-Mt)>1)return Mt-V;const ut=i[H].length,at=i[K].length;if(ut!==at)return ut-at;if(ut===1){const rt=i[H][0],It=i[K][0];if(h[rt]&&h[It]){const kt=h[rt],Nt=h[It],zt=Math.abs(kt.to-kt.from),oe=Math.abs(Nt.to-Nt.from);if(Math.abs(zt-oe)>1)return zt-oe}}return 0});const N=E.map(H=>h[i[H][0]]);m+=Oe(N)}return m},"fixSourceHandleCrossings"),go=f(()=>{let m=0;const I=new Map;for(const[R,E]of s.entries())i[R].length!==0&&E.end&&(I.has(E.end)||I.set(E.end,[]),I.get(E.end).push(R));for(const R of I.values()){R.sort((N,H)=>{const K=f(V=>{const Mt=i[V];if(Mt.length<2)return 0;const ut=h[Mt[Mt.length-2]];return Math.abs(ut.to-ut.from)},"getDist"),st=K(N),W=K(H);return Math.abs(st-W)>.1?st-W:N-H});const E=R.map(N=>h[i[N][i[N].length-1]]);m+=Oe(E)}return m},"fixTargetHandleCrossings"),mo=f(()=>{let m=0;for(const I of a){const R=[];for(const E of I.tracks)for(const N of E.segments){const H=i[N.edgeIndex].find(K=>h[K].segmentIndex===N.segmentIndex);H!==void 0&&R.push(h[H])}R.sort((E,N)=>E.edgeIndex-N.edgeIndex||E.segmentIndex-N.segmentIndex);for(let E=0;E<R.length;E++)for(let N=E+1;N<R.length;N++){const H=R[E],K=R[N];Qt(H,K)&&(m++,ie(H,K,xt))}}return m},"fixPipeCrossings");let O=0;const _=10;for(;O<_;){let m=0;if(m+=ho(),m+=go(),m+=mo(),m===0)break;O++}const D=new Map;for(const m of a){const I=[];m.tracks.forEach(E=>{E.segments.forEach(N=>{I.push({edgeIndex:N.edgeIndex,segmentIndex:N.segmentIndex,trackIndex:E.index,from:N.from,to:N.to})})}),I.sort((E,N)=>E.from-N.from);const R=[];if(I.length>0){let E=[I[0]],N=I[0].to;for(let H=1;H<I.length;H++){const K=I[H];K.from<N?(E.push(K),N=Math.max(N,K.to)):(R.push(E),E=[K],N=K.to)}R.push(E)}for(const E of R){const N=new Set;E.forEach(rt=>N.add(rt.trackIndex));const H=new Map;E.forEach(rt=>{const It=Ne(rt.edgeIndex);H.set(rt.trackIndex,(H.get(rt.trackIndex)??0)+It.delta)});const K=[...N].filter(rt=>(H.get(rt)??0)<-1),st=[...N].filter(rt=>(H.get(rt)??0)>1),W=[...N].filter(rt=>Math.abs(H.get(rt)??0)<=1);K.sort((rt,It)=>(H.get(It)??0)-(H.get(rt)??0)),st.sort((rt,It)=>(H.get(rt)??0)-(H.get(It)??0));const V=f((rt,It)=>{E.filter(kt=>kt.trackIndex===rt).forEach(kt=>{const Nt=x.has(kt.edgeIndex)?m.coord:It;D.set(`${kt.edgeIndex}-${kt.segmentIndex}`,Nt)})},"assignCoord");let Mt=0;for(const rt of K)Mt++,V(rt,m.coord-Mt*Lo);if(W.length===0&&N.size>0){const rt=[...N].sort((Nt,zt)=>Math.abs(H.get(Nt)??0)-Math.abs(H.get(zt)??0))[0],It=K.indexOf(rt);It!==-1&&K.splice(It,1);const kt=st.indexOf(rt);kt!==-1&&st.splice(kt,1),W.push(rt)}let ut=0;for(const rt of W){if(ut===0)V(rt,m.coord);else{const It=ut%2===1?1:-1,kt=Math.ceil(ut/2);V(rt,m.coord+It*kt*Lo*.5)}ut++}let at=0;for(const rt of st)at++,V(rt,m.coord+at*Lo)}}for(const[m,I]of s.entries()){const R=i[m]??[];if(R.length===0)continue;const E=[],N=r.get(I.start),H=r.get(I.end),{pSrcPort:K,pDstPort:st}=ot(m,N,H),W=R.map(ut=>{const at=h[ut],rt=D.get(`${at.edgeIndex}-${at.segmentIndex}`)??at.pipe.coord;return{orient:at.orientation,coord:rt,from:at.from,to:at.to}});E.push(K);for(let ut=0;ut<W.length;ut++){const at=W[ut],rt=E[E.length-1],It=at.orient==="vertical"?rt.y:rt.x,kt=at.orient==="vertical"?rt.x:rt.y,Nt=W[ut+1],zt=ut<W.length-1;if(Math.abs(kt-at.coord)>dt&&E.push(Ce(at,It)),zt&&Nt.orient===at.orient)if(Math.abs(at.coord-Nt.coord)>dt){const oe=at.orient==="vertical"?(It+Nt.from)/2:Vn(at,Nt);E.push(Ce(at,oe),Ce(Nt,oe))}else(ut===0||ut===W.length-2)&&E.push(Ce(at,Vn(at,Nt)));else if(zt)E.push(Ce(at,Nt.coord));else{const oe=Math.abs(at.from-It)<Math.abs(at.to-It)?at.to:at.from;E.push(Ce(at,oe))}}const V=E[E.length-1];(Math.abs(V.x-st.x)>dt||Math.abs(V.y-st.y)>dt)&&E.push(st);const Mt=[];E.length>0&&Mt.push(E[0]);for(let ut=1;ut<E.length;ut++){const at=E[ut],rt=Mt[Mt.length-1];(Math.abs(at.x-rt.x)>dt||Math.abs(at.y-rt.y)>dt)&&Mt.push(at)}I.points=Mt}for(const m of s){const I=m.__originalEdge;I&&m.points&&(I.points=m.points)}t.edges=(t.edges??[]).filter(m=>!m.isLayoutOnly);const j=f((m,I)=>{const R=I.x??0,E=I.y??0,N=I.width??0,H=I.height??0;if(N<=0||H<=0)return m;const K=R-N/2,st=R+N/2,W=E-H/2,V=E+H/2;if(m.x<K||m.x>st||m.y<W||m.y>V)return m;const Mt=m.x-K,ut=st-m.x,at=m.y-W,rt=V-m.y,It=Math.min(Mt,ut,at,rt);return It===Mt?{x:K,y:m.y}:It===ut?{x:st,y:m.y}:It===at?{x:m.x,y:W}:{x:m.x,y:V}},"nodeBoundaryClamp");for(const m of t.edges){const I=m.points;if(!I||I.length<2)continue;const R=m.start,E=m.end,N=R?r.get(R):void 0,H=E?r.get(E):void 0;N&&(I[0]=j(I[0],N)),H&&(I[I.length-1]=j(I[I.length-1],H))}return t}w(er,"routeEdgesOrthogonal");f(er,"routeEdgesOrthogonal");function nr(t){return t.direction??"TB"}w(nr,"getSwimlaneDirection");f(nr,"getSwimlaneDirection");function or(t){var g,y,S,u,h;const e=Xo(t),n=((g=t.config.flowchart)==null?void 0:g.nodeSpacing)??40,o=((y=t.config.flowchart)==null?void 0:y.rankSpacing)??100,s=((S=t.config.swimlane)==null?void 0:S.ignoreCrossLaneEdges)??!0,r=((u=t.config.swimlane)==null?void 0:u.optimizeRanksByCrossings)??!0,d=((h=t.config.swimlane)==null?void 0:h.automaticLaneOrdering)??!1,a=nr(t),{ordered:l,coordinates:c}=tr(e,{nodeGap:n,layerGap:o,ignoreCrossLaneEdges:s,optimizeRanksByCrossings:r,automaticLaneOrdering:d,direction:a});Yo(e,l,c,{nodeGap:n,layerGap:o});for(const i of t.edges??[])delete i.points;er(t,a);for(const i of t.edges??[])(!i.curve||i.curve==="basis")&&(i.curve="rounded");return bs(t,a),xs(t),a}w(or,"runSwimlaneLayoutCore");f(or,"runSwimlaneLayoutCore");function sr(t){Ho(t);const e=Go(t);t.nodes=e.nodes,t.edges=e.edges}w(sr,"prepareSwimlaneLayout");f(sr,"prepareSwimlaneLayout");var Ur=wr({prepareLayout:sr,runLayoutCore:or,afterPaint:_o});export{Ur as render};
1
+ import{aO as wr,l as To,_ as f,aW as dr}from"./render-O7CIS3YK-BysEI-dU.js";import"./transform-Bd_a5eGM.js";import{_ as w}from"./mermaid-layout-elk.core-VAQhTNif.js";import"./main-CmX_gEtO.js";import"./index-CJuEfFQr.js";import"./_commonjs-dynamic-modules-TDtrdbi3.js";var fr=5,cn=1e-5,an=1e-6;function Ye(t){const e=[];for(let n=0;n<t.length-1;n++)e.push({a:t[n],b:t[n+1]});return e}w(Ye,"buildSegmentList");f(Ye,"buildSegmentList");function Eo(t,e,n,o){const s=e.x-t.x,r=e.y-t.y,d=o.x-n.x,a=o.y-n.y,l=s*a-r*d;if(l===0)return null;const c=n.x-t.x,g=n.y-t.y,y=(c*a-g*d)/l,S=(c*r-g*s)/l;return y<=an||y>=1-an||S<=an||S>=1-an?null:{point:{x:t.x+y*s,y:t.y+y*r},tA:y,tB:S}}w(Eo,"segmentIntersection");f(Eo,"segmentIntersection");function un(t){return Math.abs(t.b.x-t.a.x)>=Math.abs(t.b.y-t.a.y)}w(un,"isHorizontalSeg");f(un,"isHorizontalSeg");function wo(t){const e=[];for(let n=0;n<t.length;n++){const o=t[n],s=Ye(o.points);for(let r=n+1;r<t.length;r++){const d=t[r],a=Ye(d.points);for(const[l,c]of s.entries())for(const[g,y]of a.entries()){const S=Eo(c.a,c.b,y.a,y.b);if(!S)continue;const u=un(c),h=un(y);(u!==h?u:!1)?e.push({jumpEdgeId:o.id,otherEdgeId:d.id,segIndex:l,t:S.tA,point:S.point}):e.push({jumpEdgeId:d.id,otherEdgeId:o.id,segIndex:g,t:S.tB,point:S.point})}}}return e}w(wo,"findEdgeIntersections");f(wo,"findEdgeIntersections");function le(t){const e=Math.round(t*1e3)/1e3;return Number.isInteger(e)?`${e}`:`${e}`}w(le,"fmt");f(le,"fmt");function Ee(t){return`${le(t.x)},${le(t.y)}`}w(Ee,"pointToString");f(Ee,"pointToString");function Ro(t){const e=t.b.x-t.a.x,n=t.b.y-t.a.y;return Math.abs(e)>=Math.abs(n)?e>=0?1:0:n>=0?1:0}w(Ro,"getArcSweepFlag");f(Ro,"getArcSweepFlag");var Rr=.001;function Ao(t,e){if(t.length<2)return t.map(r=>({...r}));const n=t.map(r=>({...r})),o=e.arrowTypeStart&&dr[e.arrowTypeStart];if(o){const r=t[0],d=t[1],a=Math.atan2(d.y-r.y,d.x-r.x);n[0].x=r.x+o*Math.cos(a),n[0].y=r.y+o*Math.sin(a)}const s=e.arrowTypeEnd&&dr[e.arrowTypeEnd];if(s){const r=t.length,d=t[r-2],a=t[r-1],l=Math.atan2(a.y-d.y,a.x-d.x);n[r-1].x=a.x-s*Math.cos(l),n[r-1].y=a.y-s*Math.sin(l)}return n}w(Ao,"applyMarkerOffsets");f(Ao,"applyMarkerOffsets");function Oo(t,e,n,o,s){const r=t.point.x,d=t.point.y,a={x:r-e*t.r,y:d-n*t.r},l={x:r+e*t.r,y:d+n*t.r},c=[`L${Ee(a)}`];return s==="arc"?c.push(`A${le(t.r)},${le(t.r)} 0 0 ${o} ${Ee(l)}`):c.push(`M${Ee(l)}`),c}w(Oo,"emitJump");f(Oo,"emitJump");function hn(t,e,n,o){const s=e.x-t.x,r=e.y-t.y,d=n.x-e.x,a=n.y-e.y,l=Math.hypot(s,r),c=Math.hypot(d,a);if(l<cn||c<cn)return null;const g=s/l,y=r/l,S=d/c,u=a/c,h=g*S+y*u,i=Math.max(-1,Math.min(1,h)),x=Math.acos(i);if(x<cn||Math.abs(Math.PI-x)<cn)return null;const C=Math.min(o/Math.sin(x/2),l/2,c/2);return{startX:e.x-g*C,startY:e.y-y*C,endX:e.x+S*C,endY:e.y+u*C,ctrlX:e.x,ctrlY:e.y,cutLen:C}}w(hn,"computeRoundedCorner");f(hn,"computeRoundedCorner");function No(t,e,n){const o=t.points;if(o.length<2)return"";const s=Ao(o,t),r=t.curve==="rounded",d=Ye(s),a=new Map;for(const c of e){const g=d[c.segIndex];if(!g)continue;const y=Math.hypot(g.b.x-g.a.x,g.b.y-g.a.y),S=a.get(c.segIndex)??[];S.push({t:c.t,point:c.point,d:c.t*y,r:n.jumpRadius}),a.set(c.segIndex,S)}const l=[`M${Ee(s[0])}`];for(let c=0;c<d.length;c++){const g=d[c],y=Math.hypot(g.b.x-g.a.x,g.b.y-g.a.y),S=y===0?0:(g.b.x-g.a.x)/y,u=y===0?0:(g.b.y-g.a.y)/y,h=Ro(g);let i=0;if(r&&c>0){const v=hn(s[c-1],s[c],s[c+1]??s[c],fr);v&&(i=v.cutLen)}let x=y,C=null;r&&c<d.length-1&&(C=hn(s[c],s[c+1],s[c+2]??s[c+1],fr),C&&(x=y-C.cutLen));const b=[...a.get(c)??[]].sort((v,L)=>v.t-L.t);for(const v of b)v.r=Math.min(v.r,v.d-i,x-v.d);for(let v=0;v<b.length-1;v++){const L=b[v+1].d-b[v].d;if(b[v].r+b[v+1].r>L){const p=L/2;b[v].r=Math.min(b[v].r,p),b[v+1].r=Math.min(b[v+1].r,p)}}for(const v of b)v.r<Rr||l.push(...Oo(v,S,u,h,n.jumpStyle));r&&C?(l.push(`L${le(C.startX)},${le(C.startY)}`),l.push(`Q${le(C.ctrlX)},${le(C.ctrlY)} ${le(C.endX)},${le(C.endY)}`)):l.push(`L${Ee(g.b)}`)}return l.join(" ")}w(No,"rewriteEdgePath");f(No,"rewriteEdgePath");function Bo(t){return/^[\d\s+,.LMelm-]*$/.test(t)}w(Bo,"isStraightPath");f(Bo,"isStraightPath");function Po(t){return t?t==="linear"||t==="rounded"||t==="step"||t==="stepBefore"||t==="stepAfter":!0}w(Po,"curveSupportsLineHops");f(Po,"curveSupportsLineHops");function ko(t){if(!t)return null;try{const e=typeof atob=="function"?atob(t):Buffer.from(t,"base64").toString(),n=JSON.parse(e);if(!Array.isArray(n))return null;const o=[];for(const s of n)s&&typeof s.x=="number"&&typeof s.y=="number"&&o.push({x:s.x,y:s.y});return o.length>=2?o:null}catch{return null}}w(ko,"decodeDataPoints");f(ko,"decodeDataPoints");function Fo(t,e,n){if(!n.enabled)return;const o=t.node();if(!o)return;const s=new Map;for(const c of e)s.set(c.id,c);const r=[],d=new Map;for(const c of e){const g=typeof CSS<"u"&&CSS.escape?CSS.escape(c.id):c.id,y=o.querySelector(`path[data-id="${g}"]`);if(!y)continue;d.set(c.id,y);const u=ko(y.getAttribute("data-points"))??c.points;r.push({...c,points:u})}const a=wo(r);if(a.length===0)return;const l=new Map;for(const c of a){const g=l.get(c.jumpEdgeId)??[];g.push(c),l.set(c.jumpEdgeId,g)}for(const c of r){const g=l.get(c.id);if(!g||g.length===0)continue;const y=s.get(c.id),S=y==null?void 0:y.curve;if(S!==void 0&&!Po(S))continue;const u=d.get(c.id);if(!u)continue;if(S===void 0){const v=u.getAttribute("d")??"";if(!Bo(v))continue}const h=u.getAttribute("style")??"",i=/stroke-dasharray\s*:\s*0\s+([\d.]+)\s+[\d.]+\s+([\d.]+)/.exec(h),x=i?Number.parseFloat(i[1]):null,C=i?Number.parseFloat(i[2]):null,b=No(c,g,n);if(u.setAttribute("d",b),x!==null&&C!==null&&typeof u.getTotalLength=="function"){const v=u.getTotalLength(),L=Math.max(0,v-x-C),p=`0 ${x} ${L} ${C}`,M=h.replace(/stroke-dasharray\s*:[^;]*;?/g,`stroke-dasharray: ${p};`).replace(/;\s*;+/g,";");u.setAttribute("style",M)}}}w(Fo,"applyLineJumpsToSvg");f(Fo,"applyLineJumpsToSvg");function _o(t,{measure:e}){var r,d;const n=(d=(r=t.config)==null?void 0:r.swimlane)==null?void 0:d.lineHops;if(n===!1)return;const o=n==="gap"?"gap":"arc",s=t.edges.filter(a=>Array.isArray(a.points)&&a.points.length>=2).map(a=>({id:a.id,points:a.points,curve:a.curve,arrowTypeStart:a.arrowTypeStart,arrowTypeEnd:a.arrowTypeEnd}));Fo(e.groups.edgePaths,s,{enabled:!0,jumpRadius:6,jumpStyle:o})}w(_o,"applySwimlaneLineJumps");f(_o,"applySwimlaneLineJumps");var Io="__swimlane_default__",Ar=21,ur=20;function gn(t){return Math.max(t.padding??ur,ur)}w(gn,"topLaneHorizontalPadding");f(gn,"topLaneHorizontalPadding");function Do(t){const{x:e,y:n,width:o,height:s}=t,r=t.swimlaneContentTop;if(typeof e!="number"||typeof n!="number"||typeof o!="number"||typeof s!="number"||typeof r!="number"||!Number.isFinite(e)||!Number.isFinite(n)||!Number.isFinite(o)||!Number.isFinite(s)||!Number.isFinite(r)||o<=0||s<=0){delete t.groupTitleRect;return}const d=n-s/2,a=Math.min(r,n+s/2),l=Math.min(Ar,Math.max(0,a-d)),c=d+l;if(c<=d){delete t.groupTitleRect;return}t.groupTitleRect={left:e-o/2,right:e+o/2,top:d,bottom:c}}w(Do,"assignTopLaneTitleRect");f(Do,"assignTopLaneTitleRect");function Ho(t){const e=t.direction,n=t.nodes??(t.nodes=[]);for(const r of t.nodes??[])r.isGroup&&!r.parentId&&(r.shape="swimlane",e&&(r.direction=e));const o=n.filter(r=>!r.isGroup&&!r.parentId);if(o.length===0)return;let s=n.find(r=>r.id===Io);s?s.isGroup&&(s.shape="swimlane",e&&(s.direction=e)):(s={id:Io,label:"",isGroup:!0,shape:"swimlane",padding:20,...e?{direction:e}:{}},n.push(s));for(const r of o)r.parentId=Io}w(Ho,"prepareLayoutForSwimlanes");f(Ho,"prepareLayoutForSwimlanes");function Xo(t){const e=new Map;for(const l of t.nodes??[])e.set(l.id,l);const n=[];for(const l of t.edges??[]){const c=typeof l.start=="string"?l.start:void 0,g=typeof l.end=="string"?l.end:void 0;!c||!g||l.labelNodeId||n.push({id:l.id,src:c,dst:g,ref:l})}const o=t.nodes??[],s=o.filter(l=>l.isGroup),r=o.filter(l=>!l.isGroup);return{nodes:[...[...s].reverse(),...r].map(l=>l.id),edges:n,layout:t,nodeById:e}}w(Xo,"toGraphView");f(Xo,"toGraphView");function Yo(t,e,n,o){const{layout:s}=t,r=t.nodeById,d=(o==null?void 0:o.layerGap)??100,a=(o==null?void 0:o.nodeGap)??40;let l=0;for(const S of e.layers){let u=0;for(const h of S){const i=r.get(h);if(!i){u++;continue}i.layer=l,i.order=u;const x=n.x[h]??u*a,C=n.y[h]??l*d;i.x=x,i.y=C,u++}l++}const c=s.nodes??[],g=new Map,y=[];for(const S of c){if(!(S!=null&&S.isGroup))continue;S.parentId||y.push(S);const u=c.filter(b=>b.parentId===S.id);let h=1/0,i=-1/0,x=1/0,C=-1/0;for(const b of u){const v=b.x??n.x[b.id],L=b.y??n.y[b.id],p=b.width??0,M=b.height??0;v!=null&&L!=null&&(h=Math.min(h,v-p/2),i=Math.max(i,v+p/2),x=Math.min(x,L-M/2),C=Math.max(C,L+M/2))}if(h===1/0||x===1/0)S.x=S.x??0,S.y=S.y??0,S.width=S.width??0,S.height=S.height??0;else{const b=S.padding??20,v=S.parentId?b:2*gn(S),L=b,p=Math.max(0,i-h)+v,M=Math.max(0,C-x)+L,T=(h+i)/2,A=(x+C)/2;S.x=T,S.y=A,S.width=p,S.height=M,g.set(S.id,{minX:h,maxX:i,minY:x,maxY:C})}}if(y.length>0&&g.size>0){let S=1/0,u=-1/0,h=0;for(const i of y){const x=i.padding??20;x>h&&(h=x);const C=g.get(i.id);C&&(S=Math.min(S,C.minY),u=Math.max(u,C.maxY))}if(S!==1/0&&u!==-1/0){const i=Math.max(0,u-S),C=Math.max(h,36),b=i+2*C,v=(S+u)/2;for(const k of y)k.y=v,k.height=b,k.swimlaneContentTop=S;const L=[...y].sort((k,B)=>{const F=k.x??0,X=B.x??0;return F-X}),p=[],M=[],T=[];for(const k of L){const B=g.get(k.id);if(!B)continue;const F=Math.max(0,B.maxX-B.minX)+2*gn(k),X=(B.minX+B.maxX)/2;p.push(k.id),M.push(X),T.push(F)}const A=p.length;if(A>0){const k=new Map;if(A===1)k.set(p[0],T[0]);else{const B=[];for(let U=0;U<A-1;U++)B.push(M[U+1]-M[U]);const F=new Array(A);F[0]=0;for(let U=0;U<A-1;U++)F[U+1]=2*B[U]-F[U];let X=0,P=Number.POSITIVE_INFINITY;for(let U=0;U<A;U++){const et=T[U];U%2===0?X=Math.max(X,et-F[U]):P=Math.min(P,F[U]-et)}let z=X;X<=P?z=(X+P)/2:z=X;for(let U=0;U<A;U++){const et=F[U]+(U%2===0?z:-z),ft=Math.max(T[U],et);k.set(p[U],ft)}}for(const B of y){const F=k.get(B.id);F!=null&&(B.width=F),Do(B)}}}}}w(Yo,"writeBackToLayoutData");f(Yo,"writeBackToLayoutData");var Or="[EdgeLabelNodes]";function Go(t){const e=[],n=[],o=new Map;for(const d of t.nodes)o.set(d.id,d);for(const d of t.edges){if(!d.label||d.label.length===0||d.isLayoutOnly||d.labelNodeId)continue;const a=d.start?o.get(d.start):void 0,l=d.end?o.get(d.end):void 0;if(!a||!l){To.warn(Or,`Edge ${d.id} has missing source or target node`);continue}const c=`edge-label-${d.start}-${d.end}-${d.id}`,y=a.parentId!==l.parentId?l.parentId:a.parentId,S={id:c,label:d.label,edgeStart:d.start??"",edgeEnd:d.end??"",shape:"labelRect",width:0,height:0,isEdgeLabel:!0,isDummy:!0,parentId:y,isGroup:!1,labelStyle:Array.isArray(d.labelStyle)?d.labelStyle[0]:d.labelStyle??"",...a.dir?{dir:a.dir}:{}};e.push(S),d.labelNodeId=c,d.label=void 0,d.text=void 0;const u={id:`${d.id}-to-label`,start:d.start,end:c,type:"normal",isLayoutOnly:!0},h={id:`${d.id}-from-label`,start:c,end:d.end,type:"normal",isLayoutOnly:!0};n.push(u,h)}const s=[...t.nodes,...e],r=[...t.edges,...n];return{...t,nodes:s,edges:r}}w(Go,"createEdgeLabelNodes");f(Go,"createEdgeLabelNodes");var Gt=.001;function jn(t){const e=t.x??0,n=t.y??0,o=t.width??0,s=t.height??0;return o>0&&s>0?{cx:e,cy:n,rect:we(e,n,o,s)}:void 0}w(jn,"measuredNodeRect");f(jn,"measuredNodeRect");function Un(t){if(t.isGroup)return;const e=jn(t);return e?{id:String(t.id??""),cx:e.cx,cy:e.cy,rect:e.rect}:void 0}w(Un,"nodeBoundsInfoFor");f(Un,"nodeBoundsInfoFor");function re(t,e,n=Gt){return Math.abs(t.x-e.x)<n&&Math.abs(t.y-e.y)<n}w(re,"samePoint");f(re,"samePoint");function gt(t,e,n=Gt){return Math.abs(t.x-e.x)<n}w(gt,"sameX");f(gt,"sameX");function pt(t,e,n=Gt){return Math.abs(t.y-e.y)<n}w(pt,"sameY");f(pt,"sameY");function At(t,e,n=Gt){return pt(t,e,n)&&Math.abs(t.x-e.x)>n}w(At,"isHorizontalSegment");f(At,"isHorizontalSegment");function Ot(t,e,n=Gt){return gt(t,e,n)&&Math.abs(t.y-e.y)>n}w(Ot,"isVerticalSegment");f(Ot,"isVerticalSegment");function Ut(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)))}w(Ut,"overlapLength");f(Ut,"overlapLength");function fe(t,e,n=Gt){return t.horizontal&&e.horizontal&&pt(t.a,e.a,n)?Ut(t.a.x,t.b.x,e.a.x,e.b.x):t.vertical&&e.vertical&&gt(t.a,e.a,n)?Ut(t.a.y,t.b.y,e.a.y,e.b.y):0}w(fe,"sameAxisSegmentOverlapLength");f(fe,"sameAxisSegmentOverlapLength");function Re(t,e=Gt){const n=[];for(let o=0;o<t.length-1;o++){const s=t[o],r=t[o+1],d=At(s,r,e),a=Ot(s,r,e);(d||a)&&n.push({index:o,a:s,b:r,horizontal:d,vertical:a})}return n}w(Re,"orthogonalSegmentsForPoints");f(Re,"orthogonalSegmentsForPoints");function ne(t,e=Gt){const n=Re(t,e);let o=0;for(let s=1;s<n.length;s++)n[s-1].horizontal!==n[s].horizontal&&o++;return o}w(ne,"countOrthogonalBends");f(ne,"countOrthogonalBends");function bt(t,e=Gt){const n=[];for(const o of t){const s=n.length>0?n[n.length-1]:void 0;(!s||!re(s,o,e))&&n.push({x:o.x,y:o.y})}return n}w(bt,"dedupeConsecutivePoints");f(bt,"dedupeConsecutivePoints");function Wn(t,e=Gt){if(!t||t.length!==4)return;const[n,o,s,r]=t;return At(n,o,e)&&Ot(o,s,e)&&At(s,r,e)?{kind:"HVH",p0:n,p1:o,p2:s,p3:r}:Ot(n,o,e)&&At(o,s,e)&&Ot(s,r,e)?{kind:"VHV",p0:n,p1:o,p2:s,p3:r}:void 0}w(Wn,"classifyThreeSegmentRoute");f(Wn,"classifyThreeSegmentRoute");function Je(t,e,n,o=0){const s=Math.min(t.x,e.x),r=Math.max(t.x,e.x),d=Math.min(t.y,e.y),a=Math.max(t.y,e.y);return r>n.left-o&&s<n.right+o&&a>n.top-o&&d<n.bottom+o}w(Je,"segmentBoundsOverlapRect");f(Je,"segmentBoundsOverlapRect");function Kn(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}w(Kn,"pointInsideRect");f(Kn,"pointInsideRect");function zo(t,e){return t.left<=e.left&&t.right>=e.right&&t.top<=e.top&&t.bottom>=e.bottom}w(zo,"rectContainsRect");f(zo,"rectContainsRect");function Ge(t,e){return t.left<e.right&&t.right>e.left&&t.top<e.bottom&&t.bottom>e.top}w(Ge,"rectsOverlap");f(Ge,"rectsOverlap");function mn(t,e){return{left:t.left-e,right:t.right+e,top:t.top-e,bottom:t.bottom+e}}w(mn,"inflateRect");f(mn,"inflateRect");function we(t,e,n,o){return{left:t-n/2,right:t+n/2,top:e-o/2,bottom:e+o/2}}w(we,"rectFromCenterSize");f(we,"rectFromCenterSize");function Jt(t){var e;return(e=jn(t))==null?void 0:e.rect}w(Jt,"rectOfNodeBounds");f(Jt,"rectOfNodeBounds");function ve(t,e){switch(e){case"top":return{x:t.cx,y:t.rect.top};case"bottom":return{x:t.cx,y:t.rect.bottom};case"left":return{x:t.rect.left,y:t.cy};case"right":return{x:t.rect.right,y:t.cy}}}w(ve,"portForRectSide");f(ve,"portForRectSide");function Jn(t,e,n,o,s,r=Gt){const d=e==="left"||e==="right",a=o==="left"||o==="right";if(d&&a){if(e==="right"&&o==="left"&&t.x<n.x||e==="left"&&o==="right"&&t.x>n.x){if(pt(t,n,r))return[t,n];const y=(t.x+n.x)/2;return[t,{x:y,y:t.y},{x:y,y:n.y},n]}if(e===o){if(pt(t,n,r))return;const y=e==="left"?Math.min(t.x,n.x)-s:Math.max(t.x,n.x)+s;return[t,{x:y,y:t.y},{x:y,y:n.y},n]}return}if(!d&&!a){if(e===o){if(gt(t,n,r))return;const S=e==="top"?Math.min(t.y,n.y)-s:Math.max(t.y,n.y)+s;return[t,{x:t.x,y:S},{x:n.x,y:S},n]}if(!(e==="bottom"&&o==="top"&&t.y<n.y||e==="top"&&o==="bottom"&&t.y>n.y))return;if(gt(t,n,r))return[t,n];const y=(t.y+n.y)/2;return[t,{x:t.x,y},{x:n.x,y},n]}if(d&&!a){const g=e==="right"&&n.x>t.x||e==="left"&&n.x<t.x,y=o==="top"&&t.y<n.y||o==="bottom"&&t.y>n.y;return g&&y?[t,{x:n.x,y:t.y},n]:void 0}const l=e==="bottom"&&n.y>t.y||e==="top"&&n.y<t.y,c=o==="left"&&t.x<n.x||o==="right"&&t.x>n.x;return l&&c?[t,{x:t.x,y:n.y},n]:void 0}w(Jn,"buildOrthogonalPortPath");f(Jn,"buildOrthogonalPortPath");function qn(t,e,n,o){return e==="left"||e==="right"?[t,{x:o,y:t.y},{x:o,y:n.y},n]:[t,{x:t.x,y:o},{x:n.x,y:o},n]}w(qn,"buildSameSideTrackPath");f(qn,"buildSameSideTrackPath");function qe(t){const e=new Map,n=[];for(const o of t){if(o.isEdgeLabel)continue;const s=Un(o);s&&(e.set(s.id,s),n.push({id:s.id,rect:s.rect}))}return{nodeInfoById:e,realNodeRects:n}}w(qe,"collectRealNodeBounds");f(qe,"collectRealNodeBounds");function pe(t){const e=[],n=[];for(const o of t){const s=Un(o);if(!s)continue;const r={id:s.id,rect:s.rect};o.isEdgeLabel?n.push(r):e.push(r)}return{realNodeRects:e,labelNodeRects:n}}w(pe,"collectNodeRectEntries");f(pe,"collectNodeRectEntries");function $o(t,{includeEdgeLabels:e=!0}={}){const n=[];for(const o of t){if(o.isGroup||!e&&o.isEdgeLabel)continue;const s=o.x??0,r=o.y??0,d=o.width??0,a=o.height??0;n.push({nodeId:o.id,...we(s,r,d,a)})}return n}w($o,"collectLayoutNodeRects");f($o,"collectLayoutNodeRects");function Zn(t,e,n=Gt){const o=t.start,s=t.end;if(!o||!s)return;const r=e.get(o),d=e.get(s);if(!(!r||!d))return{srcId:o,dstId:s,srcInfo:r,dstInfo:d,collinearX:Math.abs(r.cx-d.cx)<n,collinearY:Math.abs(r.cy-d.cy)<n}}w(Zn,"getNodePairGeometry");f(Zn,"getNodePairGeometry");function Pt(t,e,n,o=[],s=0){for(const r of n)if(!o.includes(r.id)&&Je(t,e,r.rect,-s))return!0;return!1}w(Pt,"segmentHitsAnyRect");f(Pt,"segmentHitsAnyRect");function Qn(t,e,n,o,s=Gt,r=1e-6){const d=pt(t,e,s),a=gt(t,e,s),l=pt(n,o,s),c=gt(n,o,s);if(d&&l||a&&c||!(d||a)||!(l||c))return!1;const g=d?{a:t,b:e}:{a:n,b:o},y=a?{a:t,b:e}:{a:n,b:o},S=g.a.y,u=Math.min(g.a.x,g.b.x),h=Math.max(g.a.x,g.b.x),i=y.a.x,x=Math.min(y.a.y,y.b.y),C=Math.max(y.a.y,y.b.y);if(i<u||i>h||S<x||S>C)return!1;const b=Math.abs(i-g.a.x)<r&&Math.abs(S-g.a.y)<r||Math.abs(i-g.b.x)<r&&Math.abs(S-g.b.y)<r,v=Math.abs(i-y.a.x)<r&&Math.abs(S-y.a.y)<r||Math.abs(i-y.b.x)<r&&Math.abs(S-y.b.y)<r;return!(b&&v)}w(Qn,"orthogonalSegmentsCross");f(Qn,"orthogonalSegmentsCross");function Vo(t,e,n,o,s=Gt){const r=pt(t,e,s),d=gt(t,e,s),a=pt(n,o,s),l=gt(n,o,s);return d&&l&&gt(t,n,s)?Ut(t.y,e.y,n.y,o.y)>s:r&&a&&pt(t,n,s)?Ut(t.x,e.x,n.x,o.x)>s:!1}w(Vo,"sameAxisSegmentsOverlap");f(Vo,"sameAxisSegmentsOverlap");function ze(t,e,n,o,{epsilon:s=Gt,skipDegenerateOther:r=!1}={}){for(const d of n){if(d===o||d.isLayoutOnly)continue;const a=d.points;if(!(!a||a.length<2))for(let l=0;l<a.length-1;l++){const c=a[l],g=a[l+1];if(!(r&&re(c,g,s))&&(Qn(t,e,c,g,s)||Vo(t,e,c,g,s)))return!0}}return!1}w(ze,"segmentConflictsWithAnyEdge");f(ze,"segmentConflictsWithAnyEdge");function ge(t,e,n,o,s=Gt){const r=pt(t,e,s),d=gt(t,e,s),a=pt(n,o,s),l=gt(n,o,s);if(!(r&&l||d&&a))return!1;const c=r?{a:t,b:e}:{a:n,b:o},g=r?{a:n,b:o}:{a:t,b:e},y=c.a.y,S=Math.min(c.a.x,c.b.x),u=Math.max(c.a.x,c.b.x),h=g.a.x,i=Math.min(g.a.y,g.b.y),x=Math.max(g.a.y,g.b.y);return h>S+s&&h<u-s&&y>i+s&&y<x-s}w(ge,"orthogonalSegmentsStrictlyCross");f(ge,"orthogonalSegmentsStrictlyCross");function pn(t,e,n){const o=Math.min(e,n),s=Math.max(e,n);return t>o+Gt&&t<s-Gt}w(pn,"strictlyBetween");f(pn,"strictlyBetween");function jo(t,e,n){return gt(t,e)&&gt(e,n)?pn(e.y,t.y,n.y):pt(t,e)&&pt(e,n)?pn(e.x,t.x,n.x):!1}w(jo,"isCollinearIntermediate");f(jo,"isCollinearIntermediate");function Uo(t){let e=!1;const n=[];for(let o=0;o<t.length;o++){const s=n[n.length-1],r=t[o],d=o+1<t.length?t[o+1]:void 0;if(s&&d){if(re(s,d)){o++,e=!0;continue}if(jo(s,r,d)){e=!0;continue}}n.push(r)}return{points:n,changed:e}}w(Uo,"simplifyPolylineOnce");f(Uo,"simplifyPolylineOnce");function $e(t){const e=[t[0]];for(let o=1;o<t.length;o++){const s=e[e.length-1],r=t[o];if(!gt(s,r)&&!pt(s,r)){const d=e.length>=2?e[e.length-2]:void 0,l=(d?gt(d,s):!1)?{x:s.x,y:r.y}:{x:r.x,y:s.y};e.push(l)}e.push(r)}const n=[];for(const o of e){const s=n[n.length-1];(!s||!re(s,o))&&n.push(o)}return n}w($e,"orthogonalizePolyline");f($e,"orthogonalizePolyline");function ue(t){if(t.length<3)return t;let e=[...t];for(let n=0;n<32;n++){const o=Uo(e);if(e=o.points,!o.changed)break}return e}w(ue,"simplifyPolyline");f(ue,"simplifyPolyline");var ct=.001,Nr=.5,hr=4;function to(t,e,n){const o=t;if(o.isLayoutOnly||!o.points||o.points.length<n)return;const s=o.start?e.get(o.start):void 0,r=o.end?e.get(o.end):void 0;return{edge:o,points:o.points,srcRect:s?Jt(s):void 0,dstRect:r?Jt(r):void 0}}w(to,"endpointContextFor");f(to,"endpointContextFor");function Wo(t,e,n){if(pt(t,e,ct))return{x:t.x<n.left?n.left:n.right,y:t.y};if(gt(t,e,ct)){const o=t.y<n.top?n.top:n.bottom;return{x:t.x,y:o}}return{x:Math.min(n.right,Math.max(n.left,t.x)),y:Math.min(n.bottom,Math.max(n.top,t.y))}}w(Wo,"segmentEnterPoint");f(Wo,"segmentEnterPoint");function yn(t,e,n){const o=n?1:-1;let s=n?0:t.length-1;for(;s>=0&&s<t.length&&Kn(t[s],e,Nr);)s+=o;if(s<0||s>=t.length)return t;const r=s-o;if(r<0||r>=t.length)return t;const d=Wo(t[s],t[r],e);return n?[d,...t.slice(s)]:[...t.slice(0,s+1),d]}w(yn,"clipEndpoint");f(yn,"clipEndpoint");function Ko(t,e){for(const n of t){const o=to(n,e,2);if(!o)continue;let s=[...o.points];o.srcRect&&(s=yn(s,o.srcRect,!0)),o.dstRect&&(s=yn(s,o.dstRect,!1)),s=ue($e(s)),s=eo(s,o.srcRect,o.dstRect),o.edge.points=ue($e(s))}}w(Ko,"clipEdgeEndpointsToNodeBoundaries");f(Ko,"clipEdgeEndpointsToNodeBoundaries");function xn(t,e,n,o=!1){if(pt(t,e,ct)){if(e.y<n.top-ct||e.y>n.bottom+ct)return e;if(o){if(t.x<n.left-ct)return{x:n.left,y:t.y};if(t.x>n.right+ct)return{x:n.right,y:t.y}}return{x:Math.abs(e.x-n.left)<=Math.abs(e.x-n.right)?n.left:n.right,y:t.y}}if(gt(t,e,ct)){if(e.x<n.left-ct||e.x>n.right+ct)return e;if(o){if(t.y<n.top-ct)return{x:t.x,y:n.top};if(t.y>n.bottom+ct)return{x:t.x,y:n.bottom}}const s=Math.abs(e.y-n.top)<=Math.abs(e.y-n.bottom);return{x:t.x,y:s?n.top:n.bottom}}return e}w(xn,"snapEndpointToBoundary");f(xn,"snapEndpointToBoundary");function Ve(t,e,n){const o=t[e];for(let s=e+n;s>=0&&s<t.length;s+=n){const r=t[s];if(!re(r,o,ct))return r}return t[e+n]}w(Ve,"firstDistinctAdjacent");f(Ve,"firstDistinctAdjacent");function je(t,e){const n=t+hr,o=e-hr;return n<=o?{lo:n,hi:o}:{lo:(t+e)/2,hi:(t+e)/2}}w(je,"cornerClearanceRange");f(je,"cornerClearanceRange");function bn(t,e,n){const{lo:o,hi:s}=je(e,n);return Math.min(s,Math.max(o,t))}w(bn,"clampToCornerClearance");f(bn,"clampToCornerClearance");function Jo(t){const e=Math.max(...t.map(o=>o.lo)),n=Math.min(...t.map(o=>o.hi));if(!(e>n))return{lo:e,hi:n}}w(Jo,"intersectRanges");f(Jo,"intersectRanges");function Mn(t,e){return e==="left"||e==="right"?je(t.top,t.bottom):je(t.left,t.right)}w(Mn,"clearanceRangeForSide");f(Mn,"clearanceRangeForSide");function Ue(t,e,n){const o=t.y>=n.top-ct&&t.y<=n.bottom+ct,s=t.x>=n.left-ct&&t.x<=n.right+ct;if(pt(t,e,ct)&&o){if(Math.abs(t.x-n.left)<ct)return"left";if(Math.abs(t.x-n.right)<ct)return"right"}if(gt(t,e,ct)&&s){if(Math.abs(t.y-n.top)<ct)return"top";if(Math.abs(t.y-n.bottom)<ct)return"bottom"}}w(Ue,"terminalSideForSegment");f(Ue,"terminalSideForSegment");function _e(t){return t==="left"||t==="right"}w(_e,"isHorizontalSide");f(_e,"isHorizontalSide");function qo(t,e,n,o,s){const r=[],d=n?Ue(t,e,n):void 0,a=o?Ue(e,t,o):void 0;return n&&d&&_e(d)===s&&r.push(Mn(n,d)),o&&a&&_e(a)===s&&r.push(Mn(o,a)),r.length>0?Jo(r):void 0}w(qo,"straightClearanceRange");f(qo,"straightClearanceRange");function Sn(t,e,n,o,s){const r=qo(t,e,n,o,s);if(!r)return;const d=s?t.y:t.x,a=Math.min(r.hi,Math.max(r.lo,d));if(!(Math.abs(a-d)<ct))return s?[{x:t.x,y:a},{x:e.x,y:a}]:[{x:a,y:t.y},{x:a,y:e.y}]}w(Sn,"clearStraightEndpointCornerAxis");f(Sn,"clearStraightEndpointCornerAxis");function eo(t,e,n){if(t.length!==2)return t;const[o,s]=t;return pt(o,s,ct)?Sn(o,s,e,n,!0)??t:gt(o,s,ct)?Sn(o,s,e,n,!1)??t:t}w(eo,"clearStraightEndpointCornerConnections");f(eo,"clearStraightEndpointCornerConnections");function Zo(t,e,n){return _e(n)?{x:t.x,y:bn(t.y,e.top,e.bottom)}:{x:bn(t.x,e.left,e.right),y:t.y}}w(Zo,"cornerClearedEndpoint");f(Zo,"cornerClearedEndpoint");function Qo(t,e,n,o,s,r){const d=t.map(a=>({...a}));for(let a=e;a>=0&&a<t.length;a+=n){const l=t[a];if(r&&!pt(l,o,ct)||!r&&!gt(l,o,ct))break;r?d[a].y=s.y:d[a].x=s.x}return d}w(Qo,"moveCollinearEndpointRun");f(Qo,"moveCollinearEndpointRun");function In(t,e,n){if(t.length<2)return t;const o=n?0:t.length-1,s=n?1:-1,r=t[o],d=Ve(t,o,s);if(!d)return t;const a=Ue(r,d,e);if(!a)return t;const l=_e(a),c=Zo(r,e,a);return re(r,c,ct)?t:Qo(t,o,s,r,c,l)}w(In,"clearEndpointCornerConnection");f(In,"clearEndpointCornerConnection");function Cn(t,e,n){const o=Math.min(t.x,e.x)>=n.left-ct&&Math.max(t.x,e.x)<=n.right+ct,s=Math.min(t.y,e.y)>=n.top-ct&&Math.max(t.y,e.y)<=n.bottom+ct;if(Math.abs(t.y-n.top)<ct&&Math.abs(e.y-n.top)<ct&&o)return"top";if(Math.abs(t.y-n.bottom)<ct&&Math.abs(e.y-n.bottom)<ct&&o)return"bottom";if(Math.abs(t.x-n.left)<ct&&Math.abs(e.x-n.left)<ct&&s)return"left";if(Math.abs(t.x-n.right)<ct&&Math.abs(e.x-n.right)<ct&&s)return"right"}w(Cn,"borderSideForSegment");f(Cn,"borderSideForSegment");function vn(t,e,n,o){switch(t){case"top":return gt(e,n,ct)&&n.y<o.top-ct;case"bottom":return gt(e,n,ct)&&n.y>o.bottom+ct;case"left":return pt(e,n,ct)&&n.x<o.left-ct;case"right":return pt(e,n,ct)&&n.x>o.right+ct}}w(vn,"leavesOutward");f(vn,"leavesOutward");function Ln(t,e,n){if(t.length<3)return t;if(n){const r=Cn(t[0],t[1],e);return r&&vn(r,t[1],t[2],e)?t.slice(1):t}const o=t.length-1,s=Cn(t[o-1],t[o],e);return s&&vn(s,t[o-1],t[o-2],e)?t.slice(0,o):t}w(Ln,"collapseOwnBorderStub");f(Ln,"collapseOwnBorderStub");function ts(t,e,n){let o=t;if(e){const r=Ve(o,0,1);if(r){const d=xn(r,o[0],e);d!==o[0]&&(o=[d,...o.slice(1)])}o=Ln(o,e,!0)}if(n){const r=o.length-1,d=Ve(o,r,-1);if(d){const a=xn(d,o[r],n,!0);a!==o[r]&&(o=[...o.slice(0,r),a])}o=Ln(o,n,!1)}const s=eo(o,e,n);return s!==o||o.length===2?s:(e&&(o=In(o,e,!0)),n&&(o=In(o,n,!1)),o)}w(ts,"snapAndCollapseEndpoints");f(ts,"snapAndCollapseEndpoints");function Tn(t,e){for(const n of t){const o=to(n,e,2);if(!o)continue;const s=bt(o.points,ct),r=ts(s,o.srcRect,o.dstRect);if(r.length<3){o.edge.points=r;continue}const d=[r[0],{...r[0]},...r.slice(1,-1),r[r.length-1],{...r[r.length-1]}];o.edge.points=d}}w(Tn,"prepareEdgeEndpointsForRenderer");f(Tn,"prepareEdgeEndpointsForRenderer");function no(t){return new Map(t.map(e=>[e.id,e]))}w(no,"buildNodeMap");f(no,"buildNodeMap");function es(t,e){let n=t.parentId,o=null;for(;n;){const s=e.get(n);if(!(s!=null&&s.isGroup))break;o=s.id,n=s.parentId}return o}w(es,"resolveTopLevelGroupId");f(es,"resolveTopLevelGroupId");function En(t,e){let n=0,o=t.parentId;for(;o;){const s=e.get(o);if(!(s!=null&&s.isGroup))break;n++,o=s.parentId}return n}w(En,"groupDepth");f(En,"groupDepth");function oo(t){let e=1/0,n=-1/0,o=1/0,s=-1/0;for(const r of t){const d=r.x,a=r.y;if(typeof d!="number"||typeof a!="number")continue;const l=r.width??0,c=r.height??0;e=Math.min(e,d-l/2),n=Math.max(n,d+l/2),o=Math.min(o,a-c/2),s=Math.max(s,a+c/2)}return e===1/0||o===1/0?null:{minX:e,maxX:n,minY:o,maxY:s}}w(oo,"boundsForChildren");f(oo,"boundsForChildren");function ns(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}w(ns,"applyGroupBounds");f(ns,"applyGroupBounds");function os(t){const e=no(t),n=t.filter(o=>o.isGroup&&o.parentId).sort((o,s)=>En(s,e)-En(o,e));for(const o of n){const s=t.filter(d=>d.parentId===o.id),r=oo(s);r&&ns(o,r)}}w(os,"recomputeNestedGroupBounds");f(os,"recomputeNestedGroupBounds");function We(t,e){const n=t.nodes??[],o=t.edges??[],s=n.filter(l=>!l.isGroup);let r=1/0,d=-1/0;for(const l of s){const c=l[e];typeof c=="number"&&(r=Math.min(r,c),d=Math.max(d,c))}if(!Number.isFinite(r)||!Number.isFinite(d))return!1;const a=f(l=>r+d-l,"mirror");for(const l of n){const c=l[e];typeof c=="number"&&(l[e]=a(c));const g=l.groupTitleRect;g&&(l.groupTitleRect=e==="x"?{...g,left:a(g.right),right:a(g.left)}:{...g,top:a(g.bottom),bottom:a(g.top)})}for(const l of o)for(const c of l.points??[])c[e]=a(c[e]);return!0}w(We,"mirrorAxis");f(We,"mirrorAxis");function ss(t){return(t.nodes??[]).some(n=>!n.isGroup)?We(t,"y"):!0}w(ss,"applyBtDirectionTransform");f(ss,"applyBtDirectionTransform");function rs(t,e="LR"){const n=t.nodes??[],o=t.edges??[],s=n.filter(P=>!P.isGroup);let r=1/0,d=1/0;for(const P of s){const z=P.x??0,U=P.y??0;z<r&&(r=z),U<d&&(d=U)}if(!Number.isFinite(r)||!Number.isFinite(d))return!1;const a=36;let l=0,c=0;for(const P of s)l+=P.width??0,c+=P.height??0;const g=l/s.length,y=c/s.length,S=y>0?Math.max(1,g/y):1;for(const P of s){const z=P.x??0,et=((P.y??0)-d)*S+a,ft=z-r;P.x=et,P.y=ft}for(const P of o)if(P.points)for(const z of P.points){const U=z.x,ft=(z.y-d)*S+a,St=U-r;z.x=ft,z.y=St}os(n);const u=n.filter(P=>P.isGroup&&!P.parentId);if(u.length===0)return e==="RL"&&We(t,"x"),!0;const h=no(n),i=new Map;for(const P of n){if(P.isGroup)continue;const z=es(P,h);if(!z)continue;const U=i.get(z)??[];U.push(P),i.set(z,U)}let x=0;for(const P of u){const z=P.padding??0;z>x&&(x=z)}const C=[];let b=1/0,v=-1/0;for(const P of u){const z=i.get(P.id)??[],U=oo(z);U&&(b=Math.min(b,U.minX),v=Math.max(v,U.maxX),C.push({lane:P,contentTop:U.minY,contentBottom:U.maxY,centerY:(U.minY+U.maxY)/2}))}if(b===1/0||v===-1/0)return!0;const L=Math.max(0,v-b),p=Math.max(x,10),M=L+2*p,T=a+M,B=(b+v)/2-M/2-a,F=B+T/2,X=Math.max(x,a);C.sort((P,z)=>P.centerY-z.centerY);for(let P=0;P<C.length;P++){const z=C[P];let U,et;if(P===0?U=z.contentTop-X:U=(C[P-1].contentBottom+z.contentTop)/2,P===C.length-1)et=z.contentBottom+X;else{const Xt=C[P+1];et=(z.contentBottom+Xt.contentTop)/2}const ft=Math.max(0,et-U),St=(U+et)/2;z.lane.x=F,z.lane.y=St,z.lane.width=T,z.lane.height=ft,z.lane.swimlaneContentTop=z.contentTop,z.lane.groupTitleRect={left:B,right:B+a,top:U,bottom:et}}return e==="RL"&&We(t,"x"),!0}w(rs,"applyLrDirectionTransform");f(rs,"applyLrDirectionTransform");var de=1e-6,Br=8,ln=Br,Pr=[0,ln,-ln,2*ln,-2*ln];function is(t,e){const{nodeInfoById:n,realNodeRects:o}=qe(e);for(const s of t){if(s.isLayoutOnly)continue;const r=s.points;if(!r||r.length<4)continue;const d=Wn(bt(r,de),de);if(!d)continue;const{p3:a}=d,l=d.kind==="HVH",c=Zn(s,n,de);if(!c)continue;const{srcId:g,dstId:y,srcInfo:S,dstInfo:u,collinearX:h,collinearY:i}=c;if(h||i)continue;let x;const C=S.rect;for(const b of Pr){let v,L,p;if(l){const F=u.cy>S.cy?C.bottom:C.top,X=S.cx+b;if(X<=C.left+de||X>=C.right-de)continue;v={x:X,y:F},L={x:X,y:a.y},p={x:a.x,y:a.y}}else{const F=u.cx>S.cx?C.right:C.left,X=S.cy+b;if(X<=C.top+de||X>=C.bottom-de)continue;v={x:F,y:X},L={x:a.x,y:X},p={x:a.x,y:a.y}}const M=re(v,L,de),T=re(L,p,de);if(M&&T||!M&&Pt(v,L,o,[g],1)||!T&&Pt(L,p,o,[y],1))continue;const A=!M&&ze(v,L,t,s,{epsilon:de,skipDegenerateOther:!0}),k=!T&&ze(L,p,t,s,{epsilon:de,skipDegenerateOther:!0});if(!(A||k)){M?x=[L,p]:T?x=[v,L]:x=[v,L,p];break}}x&&(s.points=x)}}w(is,"portSwapToLShape");f(is,"portSwapToLShape");function cs(t,e){const{realNodeRects:r,labelNodeRects:d}=pe(e.values());for(const a of t){if(a.isLayoutOnly)continue;const l=a.points;if(!l||l.length<4)continue;const c=bt(l,.001);if(c.length<4)continue;const g=c.length-1,y=c[g],S=c[g-1],u=c[g-2],h=y.x-S.x,i=y.y-S.y,x=Math.hypot(h,i);if(x>=10||x<.001)continue;const C=S.x-u.x,b=S.y-u.y;if(Math.hypot(C,b)<.001)continue;const L=At(S,y,.001),p=Ot(S,y,.001),M=At(u,S,.001),T=Ot(u,S,.001);if(!(L&&T||p&&M))continue;const A=a.end,k=a.start,B=A?e.get(A):void 0;if(!B)continue;const F=B.x??0,X=B.y??0,P=Jt(B);if(!P)continue;let z,U;if(T){const Z=b<0;z={x:F,y:u.y},U={x:F,y:Z?P.bottom:P.top}}else{const Z=C>0;z={x:u.x,y:X},U={x:Z?P.right:P.left,y:X}}if(Pt(z,U,r,A?[A]:[],-2)||Pt(z,U,d,[],-2))continue;if(k){const Z=e.get(k),it=Z?Jt(Z):void 0;if(it&&Kn(z,it,2))continue}const et=f((Z,it)=>`${Z.x.toFixed(3)},${Z.y.toFixed(3)}|${it.x.toFixed(3)},${it.y.toFixed(3)}`,"ownSegmentKey"),ft=new Set;for(let Z=0;Z<c.length-1;Z++)ft.add(et(c[Z],c[Z+1]));const St=f((Z,it)=>{for(const ht of t){if(ht===a||ht.isLayoutOnly)continue;const xt=ht.points;if(!(!xt||xt.length<2))for(let Ct=0;Ct<xt.length-1;Ct++){const Rt=xt[Ct],qt=xt[Ct+1];if(!ft.has(et(Rt,qt))&&ge(Z,it,Rt,qt,.001))return!0}}return!1},"segmentCrossesOtherEdge");if(St(z,U))continue;if(g-3>=0){const Z=c[g-3],it=[k,A].filter(ht=>!!ht);if(Pt(Z,z,r,it,-2)||St(Z,z))continue}const Dt=[...c.slice(0,g-2),z,U];a.points=Dt;const ot=a.labelNodeId;if(ot){const Z=e.get(ot);if(Z){const it=Z.width??0,ht=Z.height??0;if(it>0&&ht>0){let xt,Ct,Rt=-1;for(let qt=0;qt<Dt.length-1;qt++){const Zt=Dt[qt],Qt=Dt[qt+1],ie=Math.hypot(Qt.x-Zt.x,Qt.y-Zt.y),Oe=pt(Zt,Qt,.001),xe=gt(Zt,Qt,.001);(Oe&&ie>=it+2||xe&&ie>=ht+2)&&ie>Rt&&(Rt=ie,xt=(Zt.x+Qt.x)/2,Ct=(Zt.y+Qt.y)/2)}xt!==void 0&&Ct!==void 0&&(Z.x=xt,Z.y=Ct)}}}}}w(cs,"collapseShortTerminalStub");f(cs,"collapseShortTerminalStub");var nt=.001,Yt=8,lt=Re,Co=f((t,e)=>gt(t,e,nt)||pt(t,e,nt),"orthogonallyAligned");function as(t,e){const s=f((u,h)=>{const i=u.x??0,x=u.y??0,C=h.x-i,b=h.y-x;let v=(u.width??0)/2,L=(u.height??0)/2;return Math.abs(b)*v>Math.abs(C)*L?(b<0&&(L=-L),{x:i+(b===0?0:L*C/b),y:x+L}):(C<0&&(v=-v),{x:i+v,y:x+(C===0?0:v*b/C)})},"rectIntersect"),r=f((u,h)=>{const i=bt(u.points??[]);if(i.length<2)return;const x=h?u.start:u.end,C=x?e.get(x):void 0,b=C?Jt(C):void 0;if(!C||!x||!b)return;const v=h?i[0]:i[i.length-1],L=h?i[1]:i[i.length-2],p=s(C,v);let M=v;if(Co(L,p)&&(M=L),gt(p,M,nt))return{edge:u,edgeId:String(u.id??""),nodeId:x,atStart:h,orientation:"V",coord:p.x,min:Math.min(p.y,M.y),max:Math.max(p.y,M.y),boundary:p,railEnd:M,rect:b};if(pt(p,M,nt))return{edge:u,edgeId:String(u.id??""),nodeId:x,atStart:h,orientation:"H",coord:p.y,min:Math.min(p.x,M.x),max:Math.max(p.x,M.x),boundary:p,railEnd:M,rect:b}},"terminalLaneFor"),d=f((u,h)=>Math.max(0,Math.min(u.max,h.max)-Math.max(u.min,h.min)),"projectedOverlapLength"),a=f((u,h)=>u.nodeId!==h.nodeId||u.orientation!==h.orientation?!1:u.orientation==="H"?(Math.abs(u.boundary.x-u.rect.left)<1||Math.abs(u.boundary.x-u.rect.right)<1)&&gt(u.boundary,h.boundary,1):(Math.abs(u.boundary.y-u.rect.top)<1||Math.abs(u.boundary.y-u.rect.bottom)<1)&&pt(u.boundary,h.boundary,1),"sameTerminalFace"),l=f((u,h)=>u.nodeId!==h.nodeId||u.orientation!==h.orientation?!1:d(u,h)>=Yt&&Math.abs(u.coord-h.coord)<.5,"exactTerminalLaneConflict"),c=f((u,h)=>{if(u.nodeId!==h.nodeId||u.orientation!==h.orientation||u.orientation!=="H"||u.atStart===h.atStart)return!1;const i=d(u,h);if(i<Yt)return!1;const x=u.rect.bottom-u.rect.top;return i<x||i>2*x?!1:a(u,h)&&Math.abs(u.coord-h.coord)<16},"nearTerminalLaneConflict"),g=f((u,h)=>{const i=bt(u.edge.points??[]);if(i.length<2)return;const x=u.orientation==="V"?{x:u.boundary.x+h,y:u.boundary.y}:{x:u.boundary.x,y:u.boundary.y+h},C=u.orientation==="V"?{x:u.railEnd.x+h,y:u.railEnd.y}:{x:u.railEnd.x,y:u.railEnd.y+h};if(!f(()=>Math.abs(u.boundary.y-u.rect.top)<1||Math.abs(u.boundary.y-u.rect.bottom)<1?pt(x,u.boundary,nt)&&x.x>=u.rect.left+1&&x.x<=u.rect.right-1:Math.abs(u.boundary.x-u.rect.left)<1||Math.abs(u.boundary.x-u.rect.right)<1?gt(x,u.boundary,nt)&&x.y>=u.rect.top+1&&x.y<=u.rect.bottom-1:!1,"boundaryStaysOnSameFace")())return;if(u.atStart){const M=i.length>1&&re(i[1],u.railEnd,nt),T=i.slice(M?2:1),A=T[0];return A&&!Co(A,C)?void 0:[x,C,...T]}const v=i.length>1&&re(i[i.length-2],u.railEnd,nt),L=i.slice(0,v?-2:-1),p=L[L.length-1];if(!(p&&!Co(p,C)))return[...L,C,x]},"shiftedCandidate"),y=f(u=>{const h=u.edge,i=bt(h.points??[]);if(i.length!==2)return!1;const x=h.start,C=h.end,b=x?e.get(x):void 0,v=C?e.get(C):void 0;if(!b||!v)return!1;const L=b.x??0,p=b.y??0,M=v.x??0,T=v.y??0,[A,k]=i;return pt(A,k,nt)&&Math.abs(p-T)<1&&Math.abs(L-M)>1||gt(A,k,nt)&&Math.abs(L-M)<1&&Math.abs(p-T)>1},"laneIsStraightCollinearConnector"),S=[-7,7,-14,14,-21,21];for(let u=0;u<8;u++){const h=t.filter(x=>!x.isLayoutOnly).flatMap(x=>[r(x,!0),r(x,!1)]).filter(x=>!!x);let i=!1;for(let x=0;x<h.length&&!i;x++)for(let C=x+1;C<h.length&&!i;C++){const b=h[x],v=h[C];if(b.edge===v.edge||!(l(b,v)||c(b,v)))continue;const L=!l(b,v),p=[b,v].sort((M,T)=>{const A=y(M),k=y(T);return A!==k?Number(A)-Number(k):+!T.atStart-+!M.atStart});for(const M of p){for(const T of S){const A=g(M,T);if(!A)continue;const k=r({...M.edge,points:A},M.atStart);if(!(!k||h.some(B=>B.edge!==M.edge&&(l(k,B)||L&&c(k,B))))){M.edge.points=A,i=!0;break}}if(i)break}}if(!i)return}}w(as,"separateSharedRenderedTerminalLanes");f(as,"separateSharedRenderedTerminalLanes");function ls(t,e){const{realNodeRects:o,labelNodeRects:s}=pe(e.values()),r=f((a,l)=>{const c=a.start,g=a.end,y=lt(l);if(y.length!==l.length-1)return!1;const S=[c,g].filter(u=>!!u);for(const u of y)if(Pt(u.a,u.b,o,S,-2)||Pt(u.a,u.b,s,[],-2))return!1;for(const u of t){if(u===a||u.isLayoutOnly)continue;const h=u.points;if(!(!h||h.length<2)){for(const i of y)for(const x of lt(bt(h)))if(fe(i,x,.5)>=Yt||ge(i.a,i.b,x.a,x.b,nt))return!1}}return!0},"candidateIsSafe"),d=f((a,l)=>{if(l+4>=a.length)return;const c=a[l],g=a[l+1],y=a[l+2],S=a[l+3],u=a[l+4],h=At(c,g)&&Ot(g,y)&&At(y,S)&&Ot(S,u)&&gt(c,S,nt)&&gt(c,u,nt)&&gt(g,y,nt)&&(g.x-c.x)*(S.x-y.x)<0,i=Ot(c,g)&&At(g,y)&&Ot(y,S)&&At(S,u)&&pt(c,S,nt)&&pt(c,u,nt)&&pt(g,y,nt)&&(g.y-c.y)*(S.y-y.y)<0;if(h||i)return bt([...a.slice(0,l+1),u,...a.slice(l+5)]);if(l+5>=a.length)return;const x=a[l+5],C=Ot(c,g)&&At(g,y)&&Ot(y,S)&&At(S,u)&&Ot(u,x)&&gt(c,u,nt)&&gt(c,x,nt)&&gt(y,S,nt)&&(y.x-g.x)*(u.x-S.x)<0,b=At(c,g)&&Ot(g,y)&&At(y,S)&&Ot(S,u)&&At(u,x)&&pt(c,u,nt)&&pt(c,x,nt)&&pt(y,S,nt)&&(y.y-g.y)*(u.y-S.y)<0;if(!(!C&&!b))return bt([...a.slice(0,l+1),x,...a.slice(l+6)])},"withoutDogleg");for(let a=0;a<8;a++){let l=!1;for(const c of t){if(c.isLayoutOnly)continue;const g=bt(c.points??[]);for(let y=0;y<=g.length-5;y++){const S=d(g,y);if(!(!S||!r(c,S))){c.points=S,l=!0;break}}if(l)break}if(!l)return}}w(ls,"collapseRedundantRectangularDoglegs");f(ls,"collapseRedundantRectangularDoglegs");function wn(t,e){const{realNodeRects:r,labelNodeRects:d}=pe(e.values()),a=t.filter(h=>!h.isLayoutOnly),l=f((h,i,x)=>bt(h===i?x??[]:h.points??[]),"pointsFor"),c=f((h,i)=>{let x=0;for(let C=0;C<a.length;C++){const b=lt(l(a[C],h,i));for(let v=C+1;v<a.length;v++){const L=lt(l(a[v],h,i));for(const p of b)for(const M of L)ge(p.a,p.b,M.a,M.b,nt)&&x++}}return x},"strictCrossingCount"),g=f(h=>{const i=lt(h);if(i.length!==3)return;const x=i[1];if(!(i[0].horizontal===x.horizontal||i[2].horizontal===x.horizontal))return{index:x.index,horizontal:x.horizontal,vertical:x.vertical,segment:x}},"middleRail"),y=f((h,i)=>{const x=[h.start,h.end].filter(C=>!!C);return r.filter(C=>{if(x.includes(C.id))return!1;const b=C.rect;return i.horizontal?Ut(i.a.x,i.b.x,b.left,b.right)>=Yt&&i.a.y>=b.top-2&&i.a.y<=b.bottom+2:Ut(i.a.y,i.b.y,b.top,b.bottom)>=Yt&&i.a.x>=b.left-2&&i.a.x<=b.right+2})},"blockingRectsFor"),S=f((h,i,x)=>{const C=h.map(v=>({...v}));if(i.horizontal)C[i.index].y=x,C[i.index+1].y=x;else if(i.vertical)C[i.index].x=x,C[i.index+1].x=x;else return;const b=ue(bt(C));return lt(b).length===b.length-1?b:void 0},"candidateByMovingRail"),u=f((h,i,x)=>{const C=[h.start,h.end].filter(v=>!!v),b=lt(i);if(b.length!==i.length-1)return!1;for(const v of b)if(Pt(v.a,v.b,r,C,-2)||Pt(v.a,v.b,d,[],-2))return!1;for(const v of a)if(v!==h){for(const L of b)for(const p of lt(l(v)))if(fe(L,p,.5)>=Yt)return!1}return c(h,i)<=x},"candidateIsSafe");for(let h=0;h<8;h++){const i=c();let x=!1;for(const C of a){const b=l(C),v=g(b);if(!v)continue;const L=y(C,v.segment);if(L.length===0)continue;const p=v.horizontal?[Math.min(...L.map(M=>M.rect.top))-20,Math.max(...L.map(M=>M.rect.bottom))+20]:[Math.min(...L.map(M=>M.rect.left))-20,Math.max(...L.map(M=>M.rect.right))+20];for(const M of p){const T=S(b,v.segment,M);if(!(!T||!u(C,T,i))){C.points=T,x=!0;break}}if(x)break}if(!x)return}}w(wn,"liftObstacleHuggingSameSideRails");f(wn,"liftObstacleHuggingSameSideRails");function Rn(t,e){const o=f(l=>{const c=l.groupTitleRect;if(!(!c||typeof c.left!="number"||typeof c.right!="number"||typeof c.top!="number"||typeof c.bottom!="number"||!Number.isFinite(c.left)||!Number.isFinite(c.right)||!Number.isFinite(c.top)||!Number.isFinite(c.bottom)||c.right<=c.left||c.bottom<=c.top))return{left:c.left,right:c.right,top:c.top,bottom:c.bottom}},"validTitleRect"),s=f(l=>{if(!l.isGroup||l.parentId)return;const c=l.direction,g=typeof c=="string"?c.toUpperCase():"";if(g==="LR"||g==="RL"||g==="BT")return;const y=o(l),S=l.y,u=l.height;if(!y||typeof S!="number"||typeof u!="number"||!Number.isFinite(S)||!Number.isFinite(u)||u<=0)return;const h=y.right-y.left,i=y.bottom-y.top;if(!(i<=0||h<i))return{node:l,rect:y}},"topLaneTitleFor"),r=f((l,c)=>{if(!l.horizontal)return!1;const g=l.a.y;return g<=c.top+nt||g>=c.bottom-nt?!1:Ut(l.a.x,l.b.x,c.left,c.right)>=Yt},"horizontalSegmentIntersectsTitle"),d=[...e.values()].map(s).filter(l=>!!l);if(d.length===0)return;let a=0;for(const l of t){if(l.isLayoutOnly)continue;const c=bt(l.points??[]);for(const g of lt(c))for(const y of d)r(g,y.rect)&&(a=Math.max(a,y.rect.bottom-g.a.y+4))}if(!(a<=nt))for(const l of d){const c=l.node.y,g=l.node.height;typeof c!="number"||typeof g!="number"||!Number.isFinite(c)||!Number.isFinite(g)||g<=0||(l.node.y=c-a/2,l.node.height=g+a,l.node.groupTitleRect={...l.rect,top:l.rect.top-a,bottom:l.rect.bottom-a})}}w(Rn,"liftTopLaneTitleBandsAboveRails");f(Rn,"liftTopLaneTitleBandsAboveRails");function An(t,e){const o=f(c=>{const g=c.groupTitleRect;if(!(!g||typeof g.left!="number"||typeof g.right!="number"||typeof g.top!="number"||typeof g.bottom!="number"||!Number.isFinite(g.left)||!Number.isFinite(g.right)||!Number.isFinite(g.top)||!Number.isFinite(g.bottom)||g.right<=g.left||g.bottom<=g.top))return{left:g.left,right:g.right,top:g.top,bottom:g.bottom}},"validTitleRect"),s=f(c=>{if(!c.isGroup||c.parentId||c.direction!=="LR")return;const y=o(c),S=c.x,u=c.width;if(!y||typeof S!="number"||typeof u!="number"||!Number.isFinite(S)||!Number.isFinite(u)||u<=0)return;const h=y.right-y.left,i=y.bottom-y.top;if(!(h<=0||i<h))return{node:c,rect:y}},"leftLaneTitleFor"),r=f((c,g)=>{if(!c.vertical)return!1;const y=c.a.x;return y<=g.left+nt||y>=g.right-nt?!1:Ut(c.a.y,c.b.y,g.top,g.bottom)>=Yt},"verticalSegmentIntersectsTitle"),d=f((c,g)=>{if(!c.horizontal)return!1;const y=c.a.y;return y<=g.top+nt||y>=g.bottom-nt?!1:Ut(c.a.x,c.b.x,g.left,g.right)>=Yt},"horizontalSegmentIntersectsTitle"),a=[...e.values()].map(s).filter(c=>!!c);if(a.length===0)return;let l=0;for(const c of t){if(c.isLayoutOnly)continue;const g=bt(c.points??[]);for(const y of lt(g))for(const S of a)if(r(y,S.rect))l=Math.max(l,S.rect.right-y.a.x+4);else if(d(y,S.rect)){const u=Math.min(y.a.x,y.b.x);l=Math.max(l,S.rect.right-u+4)}}if(!(l<=nt))for(const c of a){const g=c.node.x,y=c.node.width;typeof g!="number"||typeof y!="number"||!Number.isFinite(g)||!Number.isFinite(y)||y<=0||(c.node.x=g-l/2,c.node.width=y+l,c.node.groupTitleRect={...c.rect,left:c.rect.left-l,right:c.rect.right-l})}}w(An,"shiftLeftLaneTitleBandsLeftOfRails");f(An,"shiftLeftLaneTitleBandsLeftOfRails");function ds(t,e){const{realNodeRects:o}=pe(e.values()),s=t.filter(h=>!h.isLayoutOnly),r=f((h,i=new Map)=>bt(i.get(h)??h.points??[]),"replacementPointsFor"),d=f((h=new Map)=>{let i=0;for(let x=0;x<s.length;x++){const C=lt(r(s[x],h));for(let b=x+1;b<s.length;b++){const v=lt(r(s[b],h));for(const L of C)for(const p of v)ge(L.a,L.b,p.a,p.b,nt)&&i++}}return i},"crossingCount"),a=f((h=new Map)=>s.reduce((i,x)=>i+ne(r(x,h)),0),"totalBends"),l=f(h=>{const i=r(h);if(i.length<4)return;const x=i[i.length-2],C=i[i.length-1];if(!(!At(x,C,nt)&&!Ot(x,C,nt)))return{tailStart:x,terminal:C}},"terminalTailFor"),c=f((h,i)=>{const x=r(h);if(x.length<3)return;const C=x[0],b=x[1];let v;if(At(C,b,nt))v={x:b.x,y:i.tailStart.y};else if(Ot(C,b,nt))v={x:i.tailStart.x,y:b.y};else return;const L=ue(bt([C,b,v,i.tailStart,i.terminal]));return lt(L).length===L.length-1?L:void 0},"candidateWithDestinationTail"),g=f((h,i)=>{const x=[h.start,h.end].filter(C=>!!C);for(const C of lt(i))if(Pt(C.a,C.b,o,x,-2))return!0;return!1},"pathHasNodeHit"),y=f((h,i,x)=>{for(const C of s)if(C!==h){for(const b of lt(i))for(const v of lt(r(C,x)))if(fe(b,v,.5)>=Yt)return!0}return!1},"pathHasSharedTrack"),S=f((h,i,x)=>!g(h,i)&&!y(h,i,x),"candidateIsSafe"),u=f(()=>{const h=new Map;for(const i of s){const x=i.end;if(!x||!e.has(x)||r(i).length<4)continue;const b=h.get(x)??[];b.push(i),h.set(x,b)}return h},"edgesByDestination");for(let h=0;h<4;h++){const i=d();if(i===0)return;const x=a();let C,b=i,v=x;for(const L of u().values())for(let p=0;p<L.length;p++)for(let M=p+1;M<L.length;M++){const T=L[p],A=L[M],k=l(T),B=l(A);if(!k||!B)continue;const F=c(T,B),X=c(A,k);if(!F||!X)continue;const P=new Map([[T,F],[A,X]]);if(!S(T,F,P)||!S(A,X,P))continue;const z=d(P),U=a(P);z>=i||z>b||z===b&&U>=v||(C=P,b=z,v=U)}if(!C)return;for(const[L,p]of C)L.points=p}}w(ds,"swapDestinationTerminalTailsToReduceCrossings");f(ds,"swapDestinationTerminalTailsToReduceCrossings");function fs(t,e){const{realNodeRects:r,labelNodeRects:d}=pe(e.values()),a=t.filter(L=>!L.isLayoutOnly),l=f((L,p=new Map)=>bt(p.get(L)??L.points??[]),"replacementPointsFor"),c=f((L=new Map)=>{let p=0;for(let M=0;M<a.length;M++){const T=lt(l(a[M],L));for(let A=M+1;A<a.length;A++){const k=lt(l(a[A],L));for(const B of T)for(const F of k)ge(B.a,B.b,F.a,F.b,nt)&&p++}}return p},"strictCrossingCount"),g=f((L=new Map)=>a.reduce((p,M)=>p+ne(l(M,L)),0),"totalBends"),y=f(L=>{const p=L.start,M=L.end,T=p?e.get(p):void 0,A=M?e.get(M):void 0,k=T?Jt(T):void 0,B=A?Jt(A):void 0;return k&&B?{src:k,dst:B}:void 0},"endpointRectsFor"),S=f((L,p,M)=>{if(M.index<=0||M.index+1>=p.length-1)return;const T=y(L);if(T){if(M.vertical){const A=M.a.x,k=Math.min(T.src.left,T.dst.left),B=Math.max(T.src.right,T.dst.right),F=A<k-nt?"left":A>B+nt?"right":void 0;return F?{edge:L,points:p,segmentIndex:M.index,axis:"vertical",side:F,coord:A,min:Math.min(M.a.y,M.b.y),max:Math.max(M.a.y,M.b.y)}:void 0}if(M.horizontal){const A=M.a.y,k=Math.min(T.src.top,T.dst.top),B=Math.max(T.src.bottom,T.dst.bottom),F=A<k-nt?"top":A>B+nt?"bottom":void 0;return F?{edge:L,points:p,segmentIndex:M.index,axis:"horizontal",side:F,coord:A,min:Math.min(M.a.x,M.b.x),max:Math.max(M.a.x,M.b.x)}:void 0}}},"externalRailForSegment"),u=f(()=>{const L=[];for(const p of a){const M=l(p);for(const T of lt(M)){const A=S(p,M,T);A&&L.push(A)}}return L},"collectExternalRails"),h=f((L,p)=>L.edge!==p.edge&&L.axis===p.axis&&L.side===p.side&&Ut(L.min,L.max,p.min,p.max)>=Yt,"railsInteract"),i=f(L=>{const p=[],M=new Set;for(const T of L){if(M.has(T))continue;const A=[T],k=[];for(M.add(T);A.length>0;){const B=A.pop();k.push(B);for(const F of L)!M.has(F)&&h(B,F)&&(M.add(F),A.push(F))}k.length>1&&p.push(k)}return p},"connectedComponents"),x=f(L=>{const p=[];for(const M of L)p.some(T=>Math.abs(T-M.coord)<nt)||p.push(M.coord);for(;p.length<L.length;){const M=Math.min(...p),T=Math.max(...p),A=L[0].side;p.push(A==="left"||A==="top"?M-12*(L.length-p.length):T+12*(L.length-p.length))}return p},"uniqueCoordsFor"),C=f(L=>{const p=L.map(A=>A.coord),M=x(L),T=[];if(L.length<=6){const A=new Array(M.length).fill(!1),k=[],B=f(()=>{if(k.length===L.length){k.some((F,X)=>Math.abs(F-p[X])>=nt)&&T.push([...k]);return}for(const[F,X]of M.entries())A[F]||(A[F]=!0,k.push(X),B(),k.pop(),A[F]=!1)},"visit");return B(),T}for(let A=0;A<p.length;A++)for(let k=A+1;k<p.length;k++){const B=[...p];[B[A],B[k]]=[B[k],B[A]],T.push(B)}return T},"coordinateAssignmentsFor"),b=f((L,p)=>{const M=new Map;for(const[A,k]of L.entries()){const B=p[A],F=M.get(k.edge)??k.points.map(X=>({x:X.x,y:X.y}));k.axis==="vertical"?(F[k.segmentIndex].x=B,F[k.segmentIndex+1].x=B):(F[k.segmentIndex].y=B,F[k.segmentIndex+1].y=B),M.set(k.edge,F)}const T=new Map;for(const[A,k]of M){const B=ue(bt(k));if(lt(B).length!==B.length-1)return;T.set(A,B)}return T},"replacementsForAssignment"),v=f(L=>{for(const[p,M]of L){const T=[p.start,p.end].filter(A=>!!A);for(const A of lt(M))if(Pt(A.a,A.b,r,T,-2)||Pt(A.a,A.b,d,[],-2))return!1}for(let p=0;p<a.length;p++){const M=a[p],T=L.has(M),A=lt(l(M,L));for(let k=p+1;k<a.length;k++){const B=a[k];if(!T&&!L.has(B))continue;const F=lt(l(B,L));for(const X of A)for(const P of F)if(fe(X,P,.5)>=Yt)return!1}}return!0},"candidateIsSafe");for(let L=0;L<4;L++){const p=c();if(p===0)return;let M,T=p,A=g(),k=Number.POSITIVE_INFINITY;for(const B of i(u()))for(const F of C(B)){const X=b(B,F);if(!X||!v(X))continue;const P=c(X);if(P>=p)continue;const z=g(X),U=B.reduce((et,ft,St)=>et+Math.abs(F[St]-ft.coord),0);P>T||P===T&&(z>A||z===A&&U>=k)||(M=X,T=P,A=z,k=U)}if(!M)return;for(const[B,F]of M)B.points=F}}w(fs,"reassignCrossingExternalRailChannels");f(fs,"reassignCrossingExternalRailChannels");function us(t,e){const{realNodeRects:o,labelNodeRects:s}=pe(e.values()),r=t.filter(u=>!u.isLayoutOnly),d=f((u,h,i)=>bt(u===h?i??[]:u.points??[]),"pointsFor"),a=f(u=>lt(u).reduce((h,i)=>{const x=i.a.x-i.b.x,C=i.a.y-i.b.y;return h+Math.hypot(x,C)},0),"pathLength"),l=f((u,h)=>{let i=0;for(let x=0;x<r.length;x++){const C=lt(d(r[x],u,h));for(let b=x+1;b<r.length;b++){const v=lt(d(r[b],u,h));for(const L of C)for(const p of v)ge(L.a,L.b,p.a,p.b,nt)&&i++}}return i},"strictCrossingCount"),c=f((u,h)=>{if(u.horizontal){const i=u.a.y;return(Math.abs(i-h.top)<1||Math.abs(i-h.bottom)<1)&&Ut(u.a.x,u.b.x,h.left,h.right)>=Yt}if(u.vertical){const i=u.a.x;return(Math.abs(i-h.left)<1||Math.abs(i-h.right)<1)&&Ut(u.a.y,u.b.y,h.top,h.bottom)>=Yt}return!1},"segmentRunsAlongRectBorder"),g=f(u=>{const h=[u.start,u.end].filter(x=>!!x),i=[];for(const x of h){const C=e.get(x),b=C?Jt(C):void 0;b&&i.push(b)}return i},"endpointRectsFor"),y=f((u,h)=>{if(h+3>=u.length)return[];const i=u[h],x=u[h+1],C=u[h+2],b=u[h+3],v=At(i,x,nt)&&Ot(x,C,nt)&&At(C,b,nt),L=Ot(i,x,nt)&&At(x,C,nt)&&Ot(C,b,nt);if(!v&&!L)return[];if(!(v?Math.sign(x.x-i.x)!==Math.sign(b.x-C.x):Math.sign(x.y-i.y)!==Math.sign(b.y-C.y)))return[];const M=gt(i,b,nt)||pt(i,b,nt)?[]:[{x:i.x,y:b.y},{x:b.x,y:i.y}],T=M.length===0?[[...u.slice(0,h+1),...u.slice(h+3)]]:M.map(k=>[...u.slice(0,h+1),k,...u.slice(h+3)]),A=new Set;return T.map(k=>ue(bt(k))).filter(k=>{if(lt(k).length!==k.length-1||!k.some(F=>re(F,b,nt)))return!1;const B=k.map(F=>`${F.x.toFixed(3)},${F.y.toFixed(3)}`).join("|");return A.has(B)?!1:(A.add(B),!0)})},"shortcutCandidatesAt"),S=f((u,h,i)=>{const x=[u.start,u.end].filter(b=>!!b),C=g(u);for(const b of lt(h))if(Pt(b.a,b.b,o,x,-2)||Pt(b.a,b.b,s,[],-2)||C.some(v=>c(b,v)))return!1;for(const b of r)if(b!==u){for(const v of lt(h))for(const L of lt(d(b)))if(fe(v,L,.5)>=Yt)return!1}return l(u,h)<=i},"candidateIsSafe");for(let u=0;u<8;u++){const h=l();let i,x,C=h,b=Number.POSITIVE_INFINITY,v=Number.POSITIVE_INFINITY;for(const L of r){const p=d(L),M=ne(p,nt),T=a(p);for(let A=0;A<=p.length-4;A++)for(const k of y(p,A)){const B=ne(k,nt),F=a(k);if(!(B<M||B===M&&F<T-nt)||!S(L,k,h))continue;const P=l(L,k);P>C||P===C&&(B>b||B===b&&F>=v)||(i=L,x=k,C=P,b=B,v=F)}}if(!i||!x)return;i.points=x}}w(us,"shortcutRedundantOrthogonalJogs");f(us,"shortcutRedundantOrthogonalJogs");function hs(t,e){const d=[];for(const O of e.values()){if(O.isGroup||O.isEdgeLabel)continue;const _=O.x??0,D=O.y??0,j=Jt(O);j&&d.push({id:String(O.id??""),cx:_,cy:D,rect:j})}if(d.length===0)return;const a=new Map(d.map(O=>[O.id,O])),l=d.map(O=>({id:O.id,rect:O.rect})),c=["top","bottom","left","right"],g={top:Math.min(...d.map(O=>O.rect.top))-20,bottom:Math.max(...d.map(O=>O.rect.bottom))+20,left:Math.min(...d.map(O=>O.rect.left))-20,right:Math.max(...d.map(O=>O.rect.right))+20},y=t.filter(O=>!O.isLayoutOnly),S=new Map(y.map((O,_)=>[O,_])),u=f(O=>{const _=O==="left"||O==="top"?-1:1,D=[];for(let j=0;j<=2;j++)D.push(g[O]+_*20*j);return D},"outwardTracksForSide"),h=f((O,_=new Map)=>bt(_.get(O)??O.points??[]),"replacementPointsFor"),i=f((O,_)=>{let D=0;for(const j of O)for(const J of _)ge(j.a,j.b,J.a,J.b,nt)&&D++;return D},"crossingCountBetweenSegments"),x=f((O,_)=>i(lt(O),lt(_)),"crossingCountBetweenPaths"),C=f((O=new Map)=>{let _=0;const D=[],j=new Set,J=[],Q=f(G=>{j.has(G)||(j.add(G),J.push(G))},"addEdge");for(let G=0;G<y.length;G++){const q=y[G],m=h(q,O);for(let I=G+1;I<y.length;I++){const R=y[I],E=x(m,h(R,O));E>0&&(_+=E,D.push({first:q,second:R,count:E}),Q(q),Q(R))}}return J.sort((G,q)=>(S.get(G)??0)-(S.get(q)??0)),{count:_,pairs:D,edgeSet:j,edges:J}},"crossingSnapshot"),b=f((O,_)=>{const D=new Set(_.keys());if(D.size===0)return O.count;let j=0;for(const Q of O.pairs)(D.has(Q.first)||D.has(Q.second))&&(j+=Q.count);let J=0;for(let Q=0;Q<y.length;Q++){const G=y[Q],q=D.has(G),m=h(G,_);for(let I=Q+1;I<y.length;I++){const R=y[I];!q&&!D.has(R)||(J+=x(m,h(R,_)))}}return O.count-j+J},"crossingCountWithReplacements"),v=f(O=>{const _=new Map;for(const J of O.pairs){const Q=_.get(J.first)??new Set;Q.add(J.second),_.set(J.first,Q);const G=_.get(J.second)??new Set;G.add(J.first),_.set(J.second,G)}const D=[],j=new Set;for(const J of O.edges){if(j.has(J))continue;const Q=[J],G=[];for(j.add(J);Q.length>0;){const q=Q.pop();G.push(q);for(const m of _.get(q)??[])j.has(m)||(j.add(m),Q.push(m))}G.sort((q,m)=>(S.get(q)??0)-(S.get(m)??0)),G.length>1&&D.push(G)}return D},"crossingComponents"),L=f(O=>[O.start,O.end].filter(_=>!!_),"endpointIdsFor"),p=f(O=>{const _=[];for(const D of v(O)){const j=new Set(D),J=new Set(D.flatMap(G=>L(G))),Q=[...D];for(const G of y)j.has(G)||L(G).some(q=>J.has(q))&&Q.push(G);Q.sort((G,q)=>(S.get(G)??0)-(S.get(q)??0)),_.push(Q)}return _},"pairSearchGroups"),M=f((O,_,D)=>b(O,new Map([[_,D]])),"crossingCountWithSingleReplacement"),T=f(O=>{const _=new Map;for(const D of O.pairs)_.set(D.first,(_.get(D.first)??0)+D.count),_.set(D.second,(_.get(D.second)??0)+D.count);return _},"currentCrossingsByEdge"),A=f(O=>O.slice(1).reduce((_,D,j)=>{const J=O[j];return _+Math.abs(D.x-J.x)+Math.abs(D.y-J.y)},0),"pathLength"),k=f((O=new Map)=>y.reduce((_,D)=>_+ne(h(D,O)),0),"totalBends"),B=f((O=new Map)=>y.reduce((_,D)=>_+A(h(D,O)),0),"totalLength"),F=f((O,_,D=new Map)=>{const j=lt(_);for(const J of y)if(J!==O){for(const Q of j)for(const G of lt(h(J,D)))if(fe(Q,G,.5)>=Yt)return!0}return!1},"pathHasSegmentConflict"),X=f((O,_)=>{const D=[O.start,O.end].filter(j=>!!j);for(const j of lt(_))if(Pt(j.a,j.b,l,D,-2))return!0;return!1},"pathHitsNode"),P=f((O,_)=>{const D=ue(bt(_));lt(D).length===D.length-1&&O.push(D)},"pushOrthogonalCandidate"),z=f(O=>O==="left"||O==="right","sideIsHorizontal"),U=f((O,_,D)=>{switch(_){case"left":return Math.min(O.x,D.x)-20;case"right":return Math.max(O.x,D.x)+20;case"top":return Math.min(O.y,D.y)-20;case"bottom":return Math.max(O.y,D.y)+20}},"localTrackForSameSide"),et=f((O,_,D,j)=>{const J=D==="left"||D==="top"?-1:1,Q=[U(_,D,j),g[D]];for(const G of Q)for(let q=0;q<=2;q++)P(O,qn(_,D,j,G+J*20*q))},"addSameSideCandidates"),ft=f((O,_,D,j,J)=>{for(const Q of u(D))for(const G of u(J))P(O,[_,{x:Q,y:_.y},{x:Q,y:G},{x:j.x,y:G},j])},"addHorizontalToVerticalCandidates"),St=f((O,_,D,j,J)=>{for(const Q of u(D))for(const G of u(J))P(O,[_,{x:_.x,y:Q},{x:G,y:Q},{x:G,y:j.y},j])},"addVerticalToHorizontalCandidates"),Xt=f((O,_,D,j,J)=>{const Q=[...u("top"),...u("bottom")];for(const G of u(D))for(const q of u(J))for(const m of Q)P(O,[_,{x:G,y:_.y},{x:G,y:m},{x:q,y:m},{x:q,y:j.y},j])},"addHorizontalPairCandidates"),Dt=f((O,_,D,j,J)=>{const Q=[...u("left"),...u("right")];for(const G of u(D))for(const q of u(J))for(const m of Q)P(O,[_,{x:_.x,y:G},{x:m,y:G},{x:m,y:q},{x:j.x,y:q},j])},"addVerticalPairCandidates"),ot=f(O=>{const _=new Set;return O.map(D=>bt(D)).filter(D=>{const j=D.map(J=>`${J.x.toFixed(3)},${J.y.toFixed(3)}`).join("|");return _.has(j)||D.length<2?!1:(_.add(j),!0)})},"dedupeCandidatePaths"),Z=f((O,_,D,j)=>{const J=[],Q=Jn(O,_,D,j,20,nt);Q&&P(J,Q),_===j&&et(J,O,_,D);const G=z(_),q=z(j);return G&&!q?ft(J,O,_,D,j):!G&&q?St(J,O,_,D,j):G?Xt(J,O,_,D,j):Dt(J,O,_,D,j),ot(J)},"buildCandidatesForSides"),it=f((O,_,D,j)=>{const J=[...u("left"),...u("right")],Q=[...u("top"),...u("bottom")];for(const G of c){const q=ve(j,G),m=G==="top"||G==="bottom"?u(G):Q;for(const I of J){P(O,[_,D,{x:I,y:D.y},{x:I,y:q.y},q]);for(const R of m)P(O,[_,D,{x:I,y:D.y},{x:I,y:R},{x:q.x,y:R},q])}}},"addVerticalDepartureOuterTrackCandidates"),ht=f((O,_,D,j)=>{const J=[...u("left"),...u("right")],Q=[...u("top"),...u("bottom")];for(const G of c){const q=ve(j,G),m=G==="left"||G==="right"?u(G):J;for(const I of Q){P(O,[_,D,{x:D.x,y:I},{x:q.x,y:I},q]);for(const R of m)P(O,[_,D,{x:D.x,y:I},{x:R,y:I},{x:R,y:q.y},q])}}},"addHorizontalDepartureOuterTrackCandidates"),xt=f(O=>{const _=O.start,D=O.end,j=D?a.get(D):void 0;if(!_||!j)return[];const J=bt(O.points??[]);if(J.length<4)return[];const Q=J[0],G=J[1],q=[];return Ot(Q,G,nt)?it(q,Q,G,j):At(Q,G,nt)&&ht(q,Q,G,j),q},"terminalPreservingOuterTrackCandidates"),Ct=f(O=>{const _=O.start,D=O.end,j=_?a.get(_):void 0,J=D?a.get(D):void 0;if(!j||!J)return[];const Q=[];for(const G of c){const q=ve(j,G);for(const m of c)Q.push(...Z(q,G,ve(J,m),m))}return Q.push(...xt(O)),Q},"candidatePathsFor"),Rt=f(()=>new Map(y.map(O=>[O,lt(h(O))])),"currentSegmentsByEdge"),qt=f((O,_,D)=>{const j=new Set;for(const J of y){if(J===O)continue;const Q=D.get(J)??lt(h(J));_.some(G=>Q.some(q=>fe(G,q,.5)>=Yt))&&j.add(J)}return j},"sharedTrackConflictsFor"),Zt=f((O,_,D,j)=>{const J=new Set;return Ct(O).map(G=>ue(bt(G))).filter(G=>{if(X(O,G))return!1;const q=G.map(m=>`${m.x.toFixed(3)},${m.y.toFixed(3)}`).join("|");return J.has(q)||G.length<2?!1:(J.add(q),!0)}).map(G=>{const q=lt(G);let m=0;for(const I of y)I!==O&&(m+=i(q,D.get(I)??lt(h(I))));return{candidate:G,candidateSegments:q,crossings:_.count-(j.get(O)??0)+m,bends:ne(G,nt),totalBends:ne(G),length:A(G)}}).filter(({crossings:G})=>G<=_.count).sort((G,q)=>G.crossings-q.crossings||G.bends-q.bends||G.length-q.length).slice(0,48).map(G=>({path:G.candidate,segments:G.candidateSegments,sharedTrackConflicts:qt(O,G.candidateSegments,D),totalBends:G.totalBends,length:G.length}))},"pairCandidatesFor"),Qt=f((O,_,D,j,J,Q)=>{let G=0;for(const m of O.pairs)(m.first===_||m.second===_||m.first===j||m.second===j)&&(G+=m.count);let q=i(D.segments,J.segments);for(const m of y){if(m===_||m===j)continue;const I=Q.get(m)??lt(h(m));q+=i(D.segments,I)+i(J.segments,I)}return O.count-G+q},"pairCrossingCount"),ie=f((O,_)=>{for(const D of O.sharedTrackConflicts)if(D!==_)return!1;return!0},"conflictsOnlyWith"),Oe=f((O,_)=>O.segments.some(D=>_.segments.some(j=>fe(D,j,.5)>=Yt)),"candidatesShareTrack"),xe=f((O,_,D,j)=>ie(_,D.edge)&&ie(j,O.edge)&&!Oe(_,j),"pairCandidatesAreCompatible"),Ne=f((O,_,D,j,J)=>{const Q=Qt(O.current,_.edge,D,j.edge,J,O.baseSegments);if(!(Q>=O.current.count))return{replacements:new Map([[_.edge,D.path],[j.edge,J.path]]),crossings:Q,bends:O.currentBends-(O.baseBendsByEdge.get(_.edge)??0)-(O.baseBendsByEdge.get(j.edge)??0)+D.totalBends+J.totalBends,length:O.currentLength-(O.baseLengthByEdge.get(_.edge)??0)-(O.baseLengthByEdge.get(j.edge)??0)+D.length+J.length}},"scorePairReplacement"),ho=f((O,_)=>O.crossings<_.crossings||O.crossings===_.crossings&&(O.bends<_.bends||O.bends===_.bends&&O.length<_.length),"pairScoreIsBetter"),go=f((O,_,D,j)=>{let J=j;for(const Q of _.candidates)for(const G of D.candidates){if(!xe(_,Q,D,G))continue;const q=Ne(O,_,Q,D,G);q&&ho(q,J)&&(J=q)}return J},"bestScoreForOptionPair"),mo=f(O=>{const _=k(),D=B(),j=Rt(),J=T(O),Q=new Map(y.map(E=>[E,ne(h(E))])),G=new Map(y.map(E=>[E,A(h(E))])),q=new Map,m=p(O);for(const E of m)for(const N of E){if(q.has(N))continue;const H=Zt(N,O,j,J);H.length>0&&q.set(N,{edge:N,candidates:H})}let I={replacements:new Map,crossings:O.count,bends:_,length:D};const R={current:O,currentBends:_,currentLength:D,baseBendsByEdge:Q,baseLengthByEdge:G,baseSegments:j};for(const E of m){const N=new Set(E.filter(K=>O.edgeSet.has(K))),H=E.map(K=>q.get(K)).filter(K=>!!K);for(let K=0;K<H.length;K++){const st=H[K];for(let W=K+1;W<H.length;W++){const V=H[W];!N.has(st.edge)&&!N.has(V.edge)||(I=go(R,st,V,I))}}}return I.replacements.size>0?I.replacements:void 0},"bestPairedReplacement");for(let O=0;O<4;O++){const _=C(),D=_.count;if(D===0)return;let j,J,Q=D,G=Number.POSITIVE_INFINITY;for(const m of _.edges){const I=ne(h(m),nt);for(const R of Ct(m)){const E=X(m,R),N=!E&&F(m,R),H=M(_,m,R),K=ne(R,nt);E||N||!(H<D||H===D&&K<I)||H>Q||H===Q&&K>=G||(j=m,J=R,Q=H,G=K)}}if(j&&J){j.points=J;continue}const q=mo(_);if(!q)return;for(const[m,I]of q)m.points=I}}w(hs,"resolveRenderedOrthogonalCrossings");f(hs,"resolveRenderedOrthogonalCrossings");var Ie=.001,kr=8;function gs(t,e){const{nodeInfoById:n,realNodeRects:o}=qe(e),s=["top","bottom","left","right"],r=20,d={top:Math.min(...o.map(i=>i.rect.top))-r,bottom:Math.max(...o.map(i=>i.rect.bottom))+r,left:Math.min(...o.map(i=>i.rect.left))-r,right:Math.max(...o.map(i=>i.rect.right))+r},a=f((i,x,C,b)=>{const v=[],L=Jn(i,x,C,b,r,Ie);return L&&v.push(L),x===b&&v.push(qn(i,x,C,d[x])),v},"buildOrthogonalPathCandidates"),l=f((i,x)=>{for(let C=0;C<i.length-1;C++){const b=i[C],v=i[C+1];if(Pt(b,v,o,x,1))return!0}return!1},"pathHitsNode"),c=f((i,x,C=!1)=>{let b=0;const v=Re(i,Ie),L=x.start,p=x.end;for(const M of t){if(M===x||M.isLayoutOnly)continue;const T=M.start,A=M.end;if(!C&&L&&p&&(T===L||T===p||A===L||A===p))continue;const k=M.points;if(!(!k||k.length<2))for(const B of v)for(const F of Re(k,Ie)){if(Qn(B.a,B.b,F.a,F.b,Ie,Ie)){b++;continue}fe(B,F,Ie)>=kr&&b++}}return b},"pathConflictCount"),g=4,y=f((i,x)=>{const C=Math.abs(i.y-x.rect.top),b=Math.abs(i.y-x.rect.bottom),v=Math.abs(i.x-x.rect.left),L=Math.abs(i.x-x.rect.right);let p="top",M=C;return b<M&&(p="bottom",M=b),v<M&&(p="left",M=v),L<M&&(p="right",M=L),p},"nearestSideOfRect"),S=new Map,u=f((i,x,C)=>{const b=S.get(i)??[];b.push({side:x,edgeId:C}),S.set(i,b)},"addFaceClaim");for(const i of t){if(i.isLayoutOnly)continue;const x=i.points??[];if(x.length<1)continue;const C=i.id??"",b=i.start,v=i.end;if(b){const L=n.get(b);L&&u(b,y(x[0],L),C)}if(v){const L=n.get(v);L&&u(v,y(x[x.length-1],L),C)}}const h=f((i,x,C)=>{var b;return((b=S.get(i))==null?void 0:b.some(v=>v.edgeId!==C&&v.side===x))??!1},"faceIsClaimed");for(const i of t){if(i.isLayoutOnly)continue;const x=i.points;if(!x||x.length<2)continue;const C=ne(x,Ie);if(C<g)continue;const b=i.start,v=i.end;if(!b||!v)continue;const L=n.get(b),p=n.get(v);if(!L||!p)continue;const M=i.id??"",T=c(x,i,!0),A=c(x,i);let k,B=T,F=C;for(const X of s){if(h(b,X,M))continue;const P=ve(L,X);for(const z of s){if(h(v,z,M))continue;const U=ve(p,z);for(const et of a(P,X,U,z)){if(l(et,[b,v]))continue;const ft=ne(et,Ie);if(T>0){const St=c(et,i,!0);if(St>B||St===B&&ft>=F)continue;B=St,F=ft,k=et;continue}c(et,i)>A||ft<F&&(F=ft,k=et)}}}if(k){i.points=k;const X=S.get(b);X&&S.set(b,X.filter(z=>z.edgeId!==M));const P=S.get(v);P&&S.set(v,P.filter(z=>z.edgeId!==M)),u(b,y(k[0],L),M),u(v,y(k[k.length-1],p),M)}}}w(gs,"simplifyDetouredEdges");f(gs,"simplifyDetouredEdges");var ee=.001,gr=10,dn=7;function On(t,e){const n=e?0:t.length-1,o=e?1:-1,s=t[n],r=t[n+o];if(!s||!r)return;const d=r.x-s.x,a=r.y-s.y;if(!(Math.abs(d)+Math.abs(a)<ee)){if(Math.abs(a)<=ee){const c=s.x+Math.sign(d)*gr;return{left:Math.min(s.x,c),right:Math.max(s.x,c),top:s.y-dn,bottom:s.y+dn}}if(Math.abs(d)<=ee){const c=s.y+Math.sign(a)*gr;return{left:s.x-dn,right:s.x+dn,top:Math.min(s.y,c),bottom:Math.max(s.y,c)}}return{left:Math.min(s.x,r.x),right:Math.max(s.x,r.x),top:Math.min(s.y,r.y),bottom:Math.max(s.y,r.y)}}}w(On,"markerClearanceRectFor");f(On,"markerClearanceRectFor");function ms(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)}}w(ms,"normalizeRect");f(ms,"normalizeRect");function Nn(t,e){const n=bt(e),o=On(n,!0),s=On(n,!1);return[o,s].some(r=>r&&Ge(t,ms(r)))}w(Nn,"labelOverlapsOwnMarker");f(Nn,"labelOverlapsOwnMarker");function He(t,e){const n=[];for(const h of t){if(h.isLayoutOnly)continue;const i=h.points;if(!(!i||i.length<2))for(let x=0;x<i.length-1;x++)n.push({edgeId:h.id,p1:i[x],p2:i[x+1]})}const o=[],s=[];for(const h of e.values()){const i=h.isGroup,x=h.parentId;if(i&&!x){const b=Jt(h);b&&s.push({id:h.id,rect:b});continue}if(i||h.isEdgeLabel)continue;const C=Jt(h);C&&o.push({nodeId:h.id,rect:C})}const r=3,d=1,a=12,l=f((h,i)=>{const x=mn(i,r);for(const{nodeId:C,rect:b}of o)if(C!==h&&Ge(x,b))return!0;return!1},"labelOverlapsForeignNode"),c=f((h,i)=>{const x=mn(i,r);for(const C of n)if(C.edgeId!==h&&Je(C.p1,C.p2,x))return!0;return!1},"labelOverlapsForeignEdge"),g=f((h,i,x)=>l(h,x)||c(i,x),"labelOverlapsAnything"),y=[],S=f(h=>{for(const{id:i,rect:x}of s)if(zo(x,h))return i},"findContainingLane"),u=f((h,i)=>y.some(x=>x.labelId!==h&&Ge(i,x.rect)),"overlapsPlacedLabel");for(const h of t){if(h.isLayoutOnly)continue;const i=h.labelNodeId;if(!i)continue;const x=e.get(i);if(!x)continue;const C=h.points;if(!C||C.length<2)continue;const b=x.width??0,v=x.height??0;if(b<=0||v<=0)continue;const L=[];for(let ot=0;ot<C.length-1;ot++){const Z=C[ot],it=C[ot+1],ht=Math.abs(Z.x-it.x),xt=Math.abs(Z.y-it.y);ht<ee&&xt<ee||ht>=ee&&xt>=ee||L.push({idx:ot,length:ht+xt,orientation:ht>=ee?"horizontal":"vertical",midX:(Z.x+it.x)/2,midY:(Z.y+it.y)/2})}if(L.length===0)continue;const p=L.length>=3?L.filter(ot=>ot.idx>0&&ot.idx<L.length-1):L,M=p.length>0?p:L,T=b>=v?"horizontal":"vertical",A=f(ot=>[...ot].sort((Z,it)=>{const ht=Z.orientation===T,xt=it.orientation===T;if(ht!==xt)return ht?-1:1;const Ct=Z.length>=(Z.orientation==="horizontal"?b:v)+2,Rt=it.length>=(it.orientation==="horizontal"?b:v)+2;return Ct!==Rt?Ct?-1:1:it.length-Z.length}),"rankSegments"),k=L[0],B=L[L.length-1],F=[.5,.25,.75,.05,.95,.15,.85,.1,.9],X=f((ot,Z)=>{const it=C[ot.idx],ht=C[ot.idx+1];return{midX:it.x+(ht.x-it.x)*Z,midY:it.y+(ht.y-it.y)*Z}},"anchorAtT"),P=f((ot,Z,it)=>Math.min(it,Math.max(Z,ot)),"clamp"),z=f((ot,Z)=>ot.midX>=Z.left-ee&&ot.midX<=Z.right+ee&&ot.midY>=Z.top-ee&&ot.midY<=Z.bottom+ee,"pointInsideRectInclusive"),U=f(ot=>{const Z=we(ot.midX,ot.midY,b,v),it=S(Z);if(it)return{laneId:it,anchor:ot,rect:Z};const ht=s.find(({rect:ie})=>z(ot,ie));if(!ht)return;const xt=ht.rect.left+b/2+d,Ct=ht.rect.right-b/2-d,Rt=ht.rect.top+v/2+d,qt=ht.rect.bottom-v/2-d;if(xt>Ct||Rt>qt)return;const Zt={midX:P(ot.midX,xt,Ct),midY:P(ot.midY,Rt,qt)},Qt=we(Zt.midX,Zt.midY,b,v);return z(ot,Qt)?{laneId:ht.id,anchor:Zt,rect:Qt}:void 0},"placementForAnchor"),et=f((ot,Z,it)=>ot.orientation==="horizontal"?Math.abs(Z.midX-it.x):Math.abs(Z.midY-it.y),"distanceAlongSegment"),ft=f((ot,Z)=>{const ht=(ot.orientation==="horizontal"?b/2:v/2)+a;if(ot===k){const xt=C[ot.idx];if(et(ot,Z,xt)+ee<ht)return!1}if(ot===B){const xt=C[ot.idx+1];if(et(ot,Z,xt)+ee<ht)return!1}return!0},"labelClearsTerminalEndpoints"),St=f(ot=>{const Z=A(ot);for(const it of Z)for(const ht of F){const xt=X(it,ht);if(!ft(it,xt))continue;const Ct=U(xt);if(Ct&&!Nn(Ct.rect,C)&&!u(i,Ct.rect)&&!g(i,h.id,Ct.rect))return{laneId:Ct.laneId,anchor:Ct.anchor}}},"tryPool"),Xt=f((ot,Z,it=!1)=>{const ht=A(ot);for(const xt of ht){const Ct={midX:xt.midX,midY:xt.midY};if(Z&&!ft(xt,Ct))continue;const Rt=U(Ct);if(Rt&&!Nn(Rt.rect,C)&&!u(i,Rt.rect)&&!l(i,Rt.rect)&&(it||!c(h.id,Rt.rect)))return{laneId:Rt.laneId,anchor:Rt.anchor}}},"findLaneContainingFallback"),Dt=St(M)??(M.length<L.length?St(L):void 0)??Xt(L,!0)??Xt(L,!1)??Xt(L,!1,!0);if(Dt){x.x=Dt.anchor.midX,x.y=Dt.anchor.midY,x.parentId=Dt.laneId;const ot=we(Dt.anchor.midX,Dt.anchor.midY,b,v),Z=y.findIndex(it=>it.labelId===i);Z>=0?y[Z]={labelId:i,rect:ot}:y.push({labelId:i,rect:ot})}}}w(He,"anchorLabelsToPolyline");f(He,"anchorLabelsToPolyline");var vo=1e-6,Fr=8,mr=Fr/2,_r=3;function Bn(t,e){return t<e?`${t}::${e}`:`${e}::${t}`}w(Bn,"pairKey");f(Bn,"pairKey");function ps(t,e){const{nodeInfoById:n,realNodeRects:o}=qe(e),s=new Map;for(const d of e){const a=d.id;if(!d.isGroup&&d.isEdgeLabel){s.set(a,{w:d.width??0,h:d.height??0});continue}}const r=f((d,a,l,c)=>{const g=Bn(a,l);let y=0;const S=f(u=>{if(!u)return;const h=s.get(u);if(!h)return;const i=c==="x"?h.w/2:h.h/2;i>y&&(y=i)},"consider");S(d.labelNodeId);for(const u of t){if(u===d||u.isLayoutOnly)continue;const h=u.start,i=u.end;!h||!i||Bn(h,i)===g&&S(u.labelNodeId)}return y>0?y+_r:0},"labelClearanceFor");for(const d of t){if(d.isLayoutOnly)continue;const a=d.points;if(!Wn(a,vo))continue;const l=Zn(d,n,vo);if(!l)continue;const{srcId:c,dstId:g,srcInfo:y,dstInfo:S,collinearX:u,collinearY:h}=l;if(u===h)continue;let i,x;if(u){const p=S.cy>y.cy;i={x:y.cx,y:p?y.rect.bottom:y.rect.top},x={x:S.cx,y:p?S.rect.top:S.rect.bottom}}else{const p=S.cx>y.cx;i={x:p?y.rect.right:y.rect.left,y:y.cy},x={x:p?S.rect.left:S.rect.right,y:S.cy}}if(Pt(i,x,o,[c,g],1))continue;const b=r(d,c,g,u?"x":"y"),v=b>mr?b:mr,L=[0,v,-v];for(const p of L){const M={...i},T={...x};if(u){if(M.x+=p,T.x+=p,M.x<=y.rect.left||M.x>=y.rect.right||T.x<=S.rect.left||T.x>=S.rect.right)continue}else if(M.y+=p,T.y+=p,M.y<=y.rect.top||M.y>=y.rect.bottom||T.y<=S.rect.top||T.y>=S.rect.bottom)continue;if(!Pt(M,T,o,[c,g],1)&&!ze(M,T,t,d,{epsilon:vo})){d.points=[M,T];break}}}}w(ps,"straightenCollinearSiblingDetours");f(ps,"straightenCollinearSiblingDetours");function Pn(t,e){const{realNodeRects:l,labelNodeRects:c}=pe(e.values()),g=f((p,M)=>Re(M,.001).map(T=>({...T,edge:p,interior:T.index>=1&&T.index<=M.length-3})),"segmentsFor"),y=f(()=>{const p=[];for(const M of t){if(M.isLayoutOnly)continue;const T=M.points;!T||T.length<2||p.push(...g(M,bt(T)))}return p},"allSegments"),S=f((p,M)=>p.horizontal&&M.horizontal?Ut(p.a.x,p.b.x,M.a.x,M.b.x)>=8&&Math.abs(p.a.y-M.a.y)<7:p.vertical&&M.vertical?Ut(p.a.y,p.b.y,M.a.y,M.b.y)>=8&&Math.abs(p.a.x-M.a.x)<7:!1,"hasCrowdedParallelTrack"),u=f((p,M)=>{const T=p.start,A=p.end,k=g(p,M);if(k.length!==M.length-1)return!1;const B=[T,A].filter(X=>!!X),F=p.labelNodeId?[p.labelNodeId]:[];for(const X of k)if(Pt(X.a,X.b,l,B,-2)||Pt(X.a,X.b,c,F,-2))return!1;for(const X of t){if(X===p||X.isLayoutOnly)continue;const P=X.points;if(!(!P||P.length<2)){for(const z of k)for(const U of g(X,bt(P)))if(S(z,U)||ge(z.a,z.b,U.a,U.b,.001))return!1}}return!0},"candidateIsSafe"),h=f((p,M)=>{const T=bt(p.edge.points??[]);if(T.length<4||p.index>=T.length-1)return;const A=T.map(k=>({...k}));if(p.horizontal)A[p.index].y+=M,A[p.index+1].y+=M;else if(p.vertical)A[p.index].x+=M,A[p.index+1].x+=M;else return;return g(p.edge,A).length===A.length-1?A:void 0},"shiftedCandidate"),i=f((p,M)=>({x:p.x??(M.left+M.right)/2,y:p.y??(M.top+M.bottom)/2}),"nodeCenter"),x=f(p=>{const M=p.edge,T=bt(M.points??[]);if(T.length!==4||p.index!==1)return;const A=M.start?e.get(M.start):void 0,k=M.end?e.get(M.end):void 0,B=A?Jt(A):void 0,F=k?Jt(k):void 0,X=T.slice(p.index+2);if(!(!A||!k||!B||!F||X.length===0))return{sourceCenter:i(A,B),targetCenter:i(k,F),sourceRect:B,tail:X}},"sourceDetourContextFor"),C=f((p,M,T,A,k,B)=>{const F=A.y>=T.y,X=F?k.bottom:k.top,P=X+(F?20:-20);if(F&&p.b.y<=P+.001||!F&&p.b.y>=P-.001)return;const z=p.a.x+M;return bt([{x:T.x,y:X},{x:T.x,y:P},{x:z,y:P},{x:z,y:p.b.y},...B],.001)},"verticalSourceDetour"),b=f((p,M,T,A,k,B)=>{const F=A.x>=T.x,X=F?k.right:k.left,P=X+(F?20:-20);if(F&&p.b.x<=P+.001||!F&&p.b.x>=P-.001)return;const z=p.a.y+M;return bt([{x:X,y:T.y},{x:P,y:T.y},{x:P,y:z},{x:p.b.x,y:z},...B],.001)},"horizontalSourceDetour"),v=f((p,M)=>{const T=x(p);if(T){if(p.vertical)return C(p,M,T.sourceCenter,T.targetCenter,T.sourceRect,T.tail);if(p.horizontal)return b(p,M,T.sourceCenter,T.targetCenter,T.sourceRect,T.tail)}},"sourceDetourCandidate"),L=[-7,7,-14,14,-21,21];for(let p=0;p<12;p++){const M=y();let T=!1;for(let A=0;A<M.length&&!T;A++)for(let k=A+1;k<M.length&&!T;k++){const B=M[A],F=M[k];if(B.edge===F.edge||!S(B,F))continue;const X=[B,F].filter(P=>P.interior);for(const P of X){for(const z of L){const U=h(P,z);if(U&&u(P.edge,U)){P.edge.points=U,T=!0;break}const et=v(P,z);if(et&&u(P.edge,et)){P.edge.points=et,T=!0;break}}if(T)break}}if(!T)return}}w(Pn,"nudgeSharedInteriorSubpaths");f(Pn,"nudgeSharedInteriorSubpaths");function ys(t,e,n,o){const s=e.x-t.x,r=e.y-t.y,d=o.x-n.x,a=o.y-n.y,l=s*a-r*d;if(Math.abs(l)<1e-10)return!1;const c=n.x-t.x,g=n.y-t.y,y=(c*a-g*d)/l,S=(c*r-g*s)/l,u=.01;return y>u&&y<1-u&&S>u&&S<1-u}w(ys,"segmentsIntersect");f(ys,"segmentsIntersect");function xs(t){const e=t.nodes??[],n=t.edges??[],o=[];if(!n.length||!e.length)return o;const s=$o(e),r=[];for(const a of n){if(a.isLayoutOnly)continue;const l=a.points;if(!l||l.length<2)continue;const c=a.start,g=a.end,y=a.labelNodeId,S=a.id??`${c}->${g}`;for(const u of s)if(!(u.nodeId===c||u.nodeId===g)&&!(y&&u.nodeId===y)){for(let h=0;h<l.length-1;h++)if(Je(l[h],l[h+1],u,-1)){o.push({type:"edge-node-overlap",edgeId:S,targetId:u.nodeId,detail:`segment ${h} passes through node "${u.nodeId}"`});break}}for(let u=0;u<l.length-1;u++)r.push({edgeId:S,start:c,end:g,p1:l[u],p2:l[u+1]})}const d=new Set;for(let a=0;a<r.length;a++)for(let l=a+1;l<r.length;l++){const c=r[a],g=r[l];if(c.edgeId!==g.edgeId&&!(c.start===g.start||c.start===g.end||c.end===g.start||c.end===g.end)&&ys(c.p1,c.p2,g.p1,g.p2)){const y=c.edgeId<g.edgeId?`${c.edgeId}|${g.edgeId}`:`${g.edgeId}|${c.edgeId}`;d.has(y)||(d.add(y),o.push({type:"edge-edge-crossing",edgeId:c.edgeId,targetId:g.edgeId,detail:`edges "${c.edgeId}" and "${g.edgeId}" cross`}))}}if(o.length>0){const a=o.filter(c=>c.type==="edge-node-overlap").length,l=o.filter(c=>c.type==="edge-edge-crossing").length;To.warn(`[SWIMLANE_VALIDATE] ${o.length} issue(s) detected: ${a} edge-node overlap(s), ${l} edge crossing(s)`);for(const c of o)To.warn(`[SWIMLANE_VALIDATE] ${c.type}: ${c.detail}`)}return o}w(xs,"validateSwimlanesLayout");f(xs,"validateSwimlanesLayout");function bs(t,e){const n=t.nodes??[],o=t.edges??[],s=n.filter(a=>!a.isGroup);if((e==="LR"||e==="RL")&&s.length>0&&!rs(t,e)||e==="BT"&&s.length>0&&!ss(t))return;for(const a of o){if(a.isLayoutOnly)continue;const l=a.points;!l||l.length<2||(a.points=ue($e(l)))}gs(o,n),ps(o,n),is(o,n);const r=new Map;for(const a of n)r.set(String(a.id),a);He(o,r),Ko(o,r),cs(o,r),Pn(o,r),as(o,r),ls(o,r),wn(o,r),ds(o,r);const d=f(()=>{hs(o,r),fs(o,r),us(o,r),He(o,r),Tn(o,r),wn(o,r),He(o,r),Tn(o,r)},"finalizeRenderedEdges");d(),Pn(o,r),d(),Rn(o,r),An(o,r),Rn(o,r),An(o,r)}w(bs,"postProcessSwimlaneLayout");f(bs,"postProcessSwimlaneLayout");function ye(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 d=`${r.id}:${r.src}->${r.dst}`;n.has(d)||(n.add(d),o.push(r))}return{nodes:[...e.keys()],edges:o,layout:t.layout,nodeById:e}}w(ye,"normalizeGraph");f(ye,"normalizeGraph");function so(t,e){return t.edges.filter(n=>n.dst===e)}w(so,"incoming");f(so,"incoming");function Ms(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}w(Ms,"buildSuccessorMap");f(Ms,"buildSuccessorMap");function ro(t){const e=Ms(t);for(const n of e.values())n.sort((o,s)=>o.localeCompare(s));return e}w(ro,"buildSortedSuccessorMap");f(ro,"buildSortedSuccessorMap");function io(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}w(io,"buildInDegreeMap");f(io,"buildInDegreeMap");function co(t){return[...t.entries()].filter(([,e])=>e===0).map(([e])=>e).sort((e,n)=>e.localeCompare(n))}w(co,"sortedZeroInDegreeNodes");f(co,"sortedZeroInDegreeNodes");function Ze(t,e=()=>!0){const n=new Map,o=new Map;for(const s of t.nodes)n.set(s,[]),o.set(s,[]);for(const s of t.edges)e(s)&&(o.get(s.src).push(s.dst),n.get(s.dst).push(s.src));return{preds:n,succs:o}}w(Ze,"buildPredecessorSuccessorMaps");f(Ze,"buildPredecessorSuccessorMaps");function ao(t,e,n,o){var d,a;let s=0;for(const l of t.nodes)o!=null&&o.skipGroups&&((d=t.nodeById.get(l))!=null&&d.isGroup)||(s=Math.max(s,n[l]??0));const r=Array.from({length:s+1},()=>[]);for(const l of e)o!=null&&o.skipGroups&&((a=t.nodeById.get(l))!=null&&a.isGroup)||r[Math.max(0,n[l]??0)].push(l);return r}w(ao,"buildLayersFromRanks");f(ao,"buildLayersFromRanks");function De(t){const e=io(t),n=co(e),o=[],s=ro(t);for(;n.length;){const r=n.shift();o.push(r);for(const d of s.get(r)??[])if(e.set(d,(e.get(d)??0)-1),(e.get(d)??0)===0){let a=0;for(;a<n.length&&n[a]<d;)a++;n.splice(a,0,d)}}return o.length===t.nodes.length?o:null}w(De,"topoSortIfAcyclic");f(De,"topoSortIfAcyclic");function Ae(t){const e=new Map;let n=0;for(const o of t)e.set(o,n),n++;return e}w(Ae,"buildLayerIndex");f(Ae,"buildLayerIndex");function lo(t){const e=new Array(t.length),n=f((o,s)=>{if(s-o<=1)return 0;const r=o+s>>1;let d=n(o,r)+n(r,s),a=o,l=r,c=o;for(;a<r||l<s;)l>=s||a<r&&t[a]<=t[l]?e[c++]=t[a++]:(e[c++]=t[l++],d+=r-a);for(let g=o;g<s;g++)t[g]=e[g];return d},"count");return n(0,t.length)}w(lo,"countInversions");f(lo,"countInversions");function Ss(t){const e=ye(t),n=new Map;for(const g of e.nodes)n.set(g,[]);for(const g of e.edges)n.get(g.src).push(g);for(const g of n.values())g.sort((y,S)=>y.dst===S.dst?y.id.localeCompare(S.id):y.dst.localeCompare(S.dst));const o=Object.create(null);for(const g of e.nodes)o[g]=0;const s=[],r=f(g=>{o[g]=1;for(const y of n.get(g)??[]){const S=y.dst;o[S]===0?r(S):o[S]===1&&s.push(y)}o[g]=2},"dfs"),d=[...e.nodes].sort((g,y)=>g.localeCompare(y));for(const g of d)o[g]===0&&r(g);const a=new Set(s.map(g=>`${g.id}:${g.src}->${g.dst}`)),l=e.edges.map(g=>a.has(`${g.id}:${g.src}->${g.dst}`)?{id:g.id,src:g.dst,dst:g.src,weight:g.weight,ref:g.ref}:g);return{acyclic:{nodes:[...e.nodes],edges:l,layout:e.layout,nodeById:new Map(e.nodeById)},reversed:s}}w(Ss,"removeCycles_DFS");f(Ss,"removeCycles_DFS");function Is(t){const e=new Map,n=f(o=>{if(e.has(o))return e.get(o);const s=t.nodeById.get(o);if(!s)return e.set(o,null),null;const r=s.parentId;if(!r)return e.set(o,null),null;const a=n(r)??r;return e.set(o,a),a},"resolve");for(const o of t.nodes)n(o);return e}w(Is,"buildTopLaneMap");f(Is,"buildTopLaneMap");function me(t){const e=Is(t);return n=>e.get(n)??null}w(me,"createTopLaneResolver");f(me,"createTopLaneResolver");function Qe(t){const e=[];for(const n of t.layout.nodes??[])n.isGroup&&!n.parentId&&e.push(n.id);return[...new Set(e)].reverse()}w(Qe,"buildTopLaneOrder");f(Qe,"buildTopLaneOrder");function fo(t,e){const n=Qe(t);if(!e||e.length===0)return n;const o=new Set(n),s=new Set,r=[];for(const d of e)!o.has(d)||s.has(d)||(s.add(d),r.push(d));for(const d of n)s.has(d)||r.push(d);return r}w(fo,"resolveTopLaneOrder");f(fo,"resolveTopLaneOrder");var Dr={EPSILON:1e-6},kn={GRAVITY_ITERATIONS:8,MAX_CROSSING_OPTIMIZATION_PASSES:4,DEFAULT_COMPACT_SINGLE_INPUT:!0},pr={DEFAULT_LAYER_GAP:100,DEFAULT_NODE_GAP:40};function Cs(t,e){const n=ye(t),o=(e==null?void 0:e.laneOf)??(()=>null),s=e==null?void 0:e.rankHint,{preds:r}=Ze(n);for(const p of r.values())p.sort((M,T)=>M.localeCompare(T));const d=De(n)??[...n.nodes].sort((p,M)=>p.localeCompare(M)),a=new Map;for(const[p,M]of d.entries())a.set(M,p);const l=new Map,c=new Map;for(const p of n.nodes)c.set(p,[]);for(const p of d){const M=(r.get(p)??[]).filter(T=>l.has(T));if(M.length>0){const T=vs(p,M,{laneOf:o,rankHint:s,topoIndex:a});l.set(p,T),c.get(T).push(p)}else l.has(p)||l.set(p,null)}for(const p of n.nodes)l.has(p)||l.set(p,null);const g=new Set;for(const p of n.nodes)(l.get(p)??null)===null&&g.add(p);const y=[...g].sort((p,M)=>{const T=a.get(p)??0,A=a.get(M)??0;return T===A?p.localeCompare(M):T-A}),S=Ls(n),u=new Map;for(const[p,M]of S.entries())u.set(p,[...M].sort((T,A)=>T.localeCompare(A)));const h=Ts(u),i=Es(u),x=new Map;for(const p of n.nodes)x.set(p,[]);for(const p of i)for(const M of p.nodes){const T=x.get(M);T?T.push(p.id):x.set(M,[p.id])}const C=[],b=[],v=new Set,L=f(p=>{if(!v.has(p)){v.add(p),C.push(p);for(const M of c.get(p)??[])L(M);b.push(p)}},"walk");for(const p of y)L(p);for(const p of d)L(p);return{parent:l,children:c,roots:y,componentOf:h,blocks:i,nodeBlocks:x,adjacency:u,preorder:C,postorder:b,topologicalOrder:d}}w(Cs,"buildDrivingTree");f(Cs,"buildDrivingTree");function vs(t,e,n){const o=n.laneOf(t);return[...e].sort((r,d)=>{var i,x;const a=n.laneOf(r),l=n.laneOf(d),c=a!=null&&a===o,g=l!=null&&l===o;if(c!==g)return c?-1:1;const y=(i=n.rankHint)==null?void 0:i[r],S=(x=n.rankHint)==null?void 0:x[d];if(y!=null&&S!=null&&y!==S)return S-y;const u=n.topoIndex.get(r)??0,h=n.topoIndex.get(d)??0;return u!==h?u-h:r.localeCompare(d)})[0]}w(vs,"chooseParent");f(vs,"chooseParent");function Ls(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}w(Ls,"buildAdjacency");f(Ls,"buildAdjacency");function Ts(t){const e=new Map;let n=0;for(const o of t.keys()){if(e.has(o))continue;const s=[o];for(;s.length>0;){const r=s.pop();if(!e.has(r)){e.set(r,n);for(const d of t.get(r)??[])e.has(d)||s.push(d)}}n++}return e}w(Ts,"assignComponents");f(Ts,"assignComponents");function Es(t){const e=new Map,n=new Map,o=[],s=[];let r=0;const d=f((a,l)=>{e.set(a,++r),n.set(a,r);for(const c of t.get(a)??[])c!==l&&(e.has(c)?(e.get(c)??0)<(e.get(a)??0)&&(o.push([a,c]),n.set(a,Math.min(n.get(a)??r,e.get(c)??r))):(o.push([a,c]),d(c,a),n.set(a,Math.min(n.get(a)??r,n.get(c)??r)),(n.get(c)??0)>=(e.get(a)??0)&&s.push(ws(a,c,o,s.length))))},"visit");for(const a of t.keys())e.has(a)||d(a,null);return s}w(Es,"computeBlocks");f(Es,"computeBlocks");function ws(t,e,n,o){const s=[],r=new Set;for(;n.length>0;){const d=n.pop();if(s.push(d),r.add(d[0]),r.add(d[1]),d[0]===t&&d[1]===e||d[0]===e&&d[1]===t)break}return{id:o,edges:s,nodes:[...r]}}w(ws,"popBlock");f(ws,"popBlock");function Rs(t,e,n){const o=[...t.nodes],s=new Map;for(const[b,v]of o.entries())s.set(v,b);const r=o.length,d=new Array(r).fill(-1),a=new Array(r).fill(0),l=[],c=new Set;for(const b of o){const v=n.parent.get(b)??null,L=s.get(b);L!=null&&v==null&&(d[L]=-1,a[L]=0,c.has(b)||(c.add(b),l.push(b)))}for(;l.length>0;){const b=l.shift(),v=s.get(b);if(v==null)continue;const L=n.children.get(b)??[];for(const p of L){if(c.has(p))continue;const M=s.get(p);M!=null&&(d[M]=v,a[M]=a[v]+1,c.add(p),l.push(p))}}for(const b of o){if(c.has(b))continue;const v=s.get(b);v!=null&&(d[v]=-1,a[v]=0,c.add(b))}const g=Math.max(1,Math.ceil(Math.log2(Math.max(1,r)))+1),y=Array.from({length:g},()=>new Array(r).fill(-1));for(let b=0;b<r;b++)y[0][b]=d[b];for(let b=1;b<g;b++)for(let v=0;v<r;v++){const L=y[b-1][v];y[b][v]=L===-1?-1:y[b-1][L]}const S=f((b,v)=>{if(b===-1||v===-1)return-1;a[b]<a[v]&&([b,v]=[v,b]);const L=a[b]-a[v];for(let p=0;p<g;p++)if(L>>p&1&&(b=y[p][b],b===-1))return-1;if(b===v)return b;for(let p=g-1;p>=0;p--){const M=y[p][b],T=y[p][v];M===-1||T===-1||M!==T&&(b=M,v=T)}return y[0][b]},"lcaIndex"),u=Array.from({length:r},()=>new Map);for(const b of t.edges){let v=b.src,L=b.dst,p=e[v],M=e[L];if(p==null||M==null||(p>M&&([v,L]=[L,v],[p,M]=[M,p]),p==null||M==null||p===M))continue;const T=s.get(v),A=s.get(L);if(T==null||A==null)continue;const k=S(T,A);if(k===-1)continue;const B=u[k];for(let F=p;F<M;F++)B.set(F,(B.get(F)??0)+1)}const h=new Map,i=f((b,v)=>{if(v.size!==0)for(const[L,p]of v)b.set(L,(b.get(L)??0)+p)},"mergeInto"),x=new Set,C=f(b=>{const v=s.get(b);x.add(b);const L=v==null?void 0:u[v],p=L?new Map(L):new Map,M=n.children.get(b)??[];for(const T of M){const A=C(T),k=e[b];if(k!=null){let B=h.get(b);B||(B=new Map,h.set(b,B));let F=A.get(k)??0;const X=e[T];X!=null&&X>k&&(F+=1),B.set(T,F)}i(p,A)}return p},"dfs");for(const b of n.roots)x.has(b)||C(b);for(const b of o)x.has(b)||C(b);return h}w(Rs,"computeSubtreeCrossCounts");f(Rs,"computeSubtreeCrossCounts");function As(t,e,n){const o=new Map,s=f(r=>{let d=n[r]??0;const a=[...e.get(r)??[]];a.sort(uo(n));for(const l of a){s(l);const c=o.get(l);c!=null&&(d=Math.min(d,c))}o.set(r,d)},"annotate");for(const r of t)s(r);return o}w(As,"annotateMinimumLayers");f(As,"annotateMinimumLayers");function uo(t){return(e,n)=>{const o=t[e]??0,s=t[n]??0;return o===s?e.localeCompare(n):o-s}}w(uo,"compareByRankThenId");f(uo,"compareByRankThenId");function Os(t,e,n,o){let s=0;for(const l of e){const c=n[l]??0;c>s&&(s=c)}const r=Array.from({length:s+1},()=>[]),d=new Set,a=f(l=>{if(d.has(l))return;d.add(l);const c=n[l]??0;r[c]||(r[c]=[]),r[c].push(l);for(const g of o(l))a(g)},"emit");for(const l of t)a(l);for(const l of e)if(!d.has(l)){const c=n[l]??0;r[c]||(r[c]=[]),r[c].push(l),d.add(l)}return r}w(Os,"emitNodesInTreeOrder");f(Os,"emitNodesInTreeOrder");function Ns(t){const e=[];for(const n of t){const o=new Set,s=[];for(const r of n)o.has(r)||(o.add(r),s.push(r));e.push(s)}return e}w(Ns,"deduplicateLayers");f(Ns,"deduplicateLayers");function Bs(t,e,n,o){return s=>{const r=t.get(s)??[];if(r.length===0)return[];const d=e[s]??0,a=[],l=[],c=n.get(s);for(const g of r){const y=o.get(g)??d;y>d?a.push({child:g,min:y}):l.push(g)}return a.sort((g,y)=>g.min===y.min?g.child.localeCompare(y.child):g.min-y.min),l.sort((g,y)=>{const S=(c==null?void 0:c.get(g))??0,u=(c==null?void 0:c.get(y))??0;if(S!==u)return S-u;const h=o.get(g)??d,i=o.get(y)??d;return h!==i?h-i:g.localeCompare(y)}),[...a.map(g=>g.child),...l]}}w(Bs,"createChildOrderer");f(Bs,"createChildOrderer");function Ke(t,e,n){const o=Cs(t,{rankHint:e,laneOf:n}),{children:s,roots:r}=o;for(const y of t.nodes)s.has(y)||s.set(y,[]);const d=Rs(t,e,o),a=[...r].sort(uo(e)),l=As(a,s,e),c=Bs(s,e,d,l);let g=Os(a,t.nodes,e,c);return g=Ns(g),g}w(Ke,"buildMultitreeLayerOrder");f(Ke,"buildMultitreeLayerOrder");function Ps(t,e,n){const o=new Set(t),s=new Set(e),r=Ae(e),d=[];for(const a of n)o.has(a.src)&&s.has(a.dst)&&d.push(r.get(a.dst));return lo(d)}w(Ps,"countCrossingsBetweenAdjacent");f(Ps,"countCrossingsBetweenAdjacent");function Fn(t,e,n){const o=[];for(const r of e){const d=n[r.src],a=n[r.dst];if(d==null||a==null||d===a)continue;let l=r.src,c=r.dst,g=d,y=a;d>a&&(l=r.dst,c=r.src,g=a,y=d);for(let S=g;S<y;S++)o.push({id:`${r.id}@${S}`,src:l,dst:c,ref:r.ref})}let s=0;for(let r=0;r+1<t.length;r++)s+=Ps(t[r],t[r+1],o);return s}w(Fn,"totalCrossings");f(Fn,"totalCrossings");function ks(t,e){const n={...e},{preds:o}=Ze(t),s=me(t),r=Ke(t,n,s);let d=Fn(r,t.edges,n);const a=kn.MAX_CROSSING_OPTIMIZATION_PASSES;for(let l=0;l<a;l++){let c=!1;const g=[...t.nodes].sort((y,S)=>(n[S]??0)-(n[y]??0));for(const y of g){const S=n[y]??0;if(S===0)continue;let u=0;for(const C of o.get(y)??[])u=Math.max(u,(n[C]??0)+1);if(u>=S)continue;const h=S;n[y]=u;const i=Ke(t,n,s),x=Fn(i,t.edges,n);x<d?(d=x,c=!0):n[y]=h}if(!c)break}return n}w(ks,"optimizeRanksByCrossings");f(ks,"optimizeRanksByCrossings");function Fs(t,e){const n=me(t),o=[...t.nodes].sort((s,r)=>(e[s]??0)-(e[r]??0)||s.localeCompare(r));for(const s of o){const r=n(s);if(!r)continue;const d=t.edges.filter(i=>i.src===s);if(d.length===0)continue;let a=!1,l=0;for(const i of d){const x=n(i.dst);x==null||x===r?a=!0:l++}if(l===0||a)continue;let c=0,g=!1;for(const i of t.edges){if(i.dst!==s)continue;const x=n(i.src);x&&(x===r?g=!0:c++)}if(c>0||!g)continue;const y=e[s]??0,S=y+l;let u=0;for(const i of t.edges)i.dst===s&&(u=Math.max(u,(e[i.src]??0)+1));const h=Math.max(y,u,S);h!==y&&(e[s]=h)}}w(Fs,"adjustCrossLaneSources");f(Fs,"adjustCrossLaneSources");function _s(t,e){const n=ye(t),o=De(n)??[...n.nodes].sort(),s=(e==null?void 0:e.compactSingleInput)??!1,r=me(n);let d=Object.create(null);for(const l of o){const c=so(n,l),g=e!=null&&e.ignoreCrossLaneEdges?c.filter(y=>{const S=r(y.src),u=r(l);return!S||!u?!0:S===u}):c;if(g.length===0)d[l]=0;else if(s&&g.length===1){const y=g[0].src,S=r(y),u=r(l);S!==u?d[l]=d[y]??0:d[l]=(d[y]??0)+1}else{let y=-1/0;for(const S of g)y=Math.max(y,(d[S.src]??0)+1);d[l]=y===-1/0?0:y}}return((e==null?void 0:e.optimizeRanksByCrossings)??!1)&&(d=ks(n,d)),e!=null&&e.ignoreCrossLaneEdges&&Fs(n,d),{layers:Ke(n,d,r),rankOf:d,dummy:new Set}}w(_s,"assignLayers_LongestPath");f(_s,"assignLayers_LongestPath");function Ds(t,e){const n=ye(t),s={..._s(n,{compactSingleInput:e==null?void 0:e.compactSingleInput,ignoreCrossLaneEdges:e==null?void 0:e.ignoreCrossLaneEdges,optimizeRanksByCrossings:e==null?void 0:e.optimizeRanksByCrossings}).rankOf},r=me(n),{preds:d,succs:a}=Ze(n,h=>{if(e!=null&&e.ignoreCrossLaneEdges){const i=r(h.src),x=r(h.dst);if(i&&x&&i!==x)return!1}return!0}),l=De(n)??[...n.nodes],c=[...l].reverse(),g=f((h,i)=>{let x=0;for(const v of d.get(h)??[])x=Math.max(x,(s[v]??0)+1);let C=Number.POSITIVE_INFINITY;const b=a.get(h)??[];return b.length>0&&(C=Math.min(...b.map(v=>(s[v]??0)-1))),Number.isFinite(C)||(C=Math.max(x,i)),Math.min(Math.max(i,x),C)},"clampFeasible"),y=kn.GRAVITY_ITERATIONS,S=f(h=>{let i=!1;for(const x of h){const C=d.get(x)??[],b=a.get(x)??[];if(C.length===0&&b.length===0)continue;const v=C.length>0?C.reduce((T,A)=>T+(s[A]??0)+1,0)/C.length:s[x]??0,L=b.length>0?b.reduce((T,A)=>T+(s[A]??0)-1,0)/b.length:s[x]??0,p=Math.round((v+L)/2),M=g(x,p);M!==s[x]&&(s[x]=M,i=!0)}return i},"relaxOrder");for(let h=0;h<y;h++){const i=S(l),x=S(c);if(!i&&!x)break}for(const h of l){let i=0;for(const x of d.get(h)??[])i=Math.max(i,(s[x]??0)+1);(s[h]??0)<i&&(s[h]=i)}for(const h of c){const i=a.get(h)??[];if(i.length>0){const x=Math.min(...i.map(C=>(s[C]??0)-1));(s[h]??0)>x&&(s[h]=x)}}return{layers:ao(n,l,s),rankOf:s,dummy:new Set}}w(Ds,"assignLayers_Gravity");f(Ds,"assignLayers_Gravity");function Hs(t){const e=io(t),n=ro(t);let o=co(e);const s=[];for(;o.length>0;){const r=[];for(const d of o){s.push(d);for(const a of n.get(d)??[])e.set(a,(e.get(a)??0)-1),(e.get(a)??0)===0&&r.push(a)}o=r.sort((d,a)=>d.localeCompare(a))}return s.length===t.nodes.length?s:null}w(Hs,"topoSortByGenerationIfAcyclic");f(Hs,"topoSortByGenerationIfAcyclic");function Xs(t,e){const n=ye(t),o=(e==null?void 0:e.direction)==="LR"?Hs(n)??[...n.nodes].sort():De(n)??[...n.nodes].sort(),s=me(n),r=f(g=>s(g)??g,"laneOf"),d=Object.create(null),a=new Map,l=f((g,y)=>(e==null?void 0:e.ignoreCrossLaneEdges)??!0?r(g)===r(y)?1:0:1,"edgeWeight");for(const g of o){const y=n.nodeById.get(g);if(y!=null&&y.isGroup)continue;const S=so(n,g);let u=0;if(S.length>0)for(const C of S){const b=C.src,v=d[b]??0;u=Math.max(u,v+l(b,g))}const h=r(g),i=a.get(h)??0,x=Math.max(u,i);d[g]=x,a.set(h,x+1)}return{layers:ao(n,o,d,{skipGroups:!0}),rankOf:d,dummy:new Set}}w(Xs,"assignLayers_LaneAwareCompact");f(Xs,"assignLayers_LaneAwareCompact");function Ys(t,e){const n=ye(e),{rankOf:o}=t,s=t.layers.map(u=>[...u]),r=new Set(t.dummy?[...t.dummy]:[]);let d=0;const a=new Map(n.nodeById),l=f(u=>{const h=`placeholder-${d++}`,i={id:h,isGroup:!1,isDummy:!0,width:0,height:0};for(a.set(h,i),r.add(h);s.length<=u;)s.push([]);return s[u].push(h),o[h]=u,h},"addDummyAt"),c=[...n.edges].sort((u,h)=>u.id===h.id?u.src===h.src?u.dst.localeCompare(h.dst):u.src.localeCompare(h.src):u.id.localeCompare(h.id)),g=[];for(const u of c){const h=o[u.src]??0,i=o[u.dst]??0;if(i-h<=1){g.push(u);continue}let x=u.src;for(let b=h+1,v=0;b<i;b++,v++){const L=l(b);g.push({id:`${u.id}#${v}`,src:x,dst:L,weight:u.weight,ref:u.ref}),x=L}const C=i-h-2;g.push({id:`${u.id}#${Math.max(C+1,0)}`,src:x,dst:u.dst,weight:u.weight,ref:u.ref})}const S={nodes:[...n.nodes,...[...r].filter(u=>!n.nodes.includes(u))],edges:g,layout:n.layout,nodeById:a};return{layering:{layers:s,rankOf:o,dummy:r},graphWithDummies:S}}w(Ys,"makeProperLayering");f(Ys,"makeProperLayering");function _n(t){const e=t.length;if(e===0)return Number.POSITIVE_INFINITY;const n=[...t].sort((o,s)=>o-s);return e%2===1?n[(e-1)/2]:.5*(n[e/2-1]+n[e/2])}w(_n,"median");f(_n,"median");function Dn(t){return t.length===0?Number.POSITIVE_INFINITY:t.reduce((n,o)=>n+o,0)/t.length}w(Dn,"barycenter");f(Dn,"barycenter");function Gs(t,e,n,o){const s=new Map;for(const r of t)s.set(r,[]);for(const r of n)o==="down"?e.has(r.src)&&s.has(r.dst)&&s.get(r.dst).push(e.get(r.src)):e.has(r.dst)&&s.has(r.src)&&s.get(r.src).push(e.get(r.dst));return s}w(Gs,"neighborPositionsFor");f(Gs,"neighborPositionsFor");function zs(t,e,n){const o=n.get(t)??0,s=n.get(e)??0;return o!==s?o-s:t.localeCompare(e)}w(zs,"currentOrderTieBreak");f(zs,"currentOrderTieBreak");function Hn(t,e,n){const o=new Set(t),s=new Set(e),r=Ae(t),d=Ae(e),a=[];for(const c of n)o.has(c.src)&&s.has(c.dst)&&a.push({u:r.get(c.src),v:d.get(c.dst)});a.sort((c,g)=>c.u===g.u?c.v-g.v:c.u-g.u);const l=a.map(c=>c.v);return lo(l)}w(Hn,"countCrossingsBetweenAdjacent2");f(Hn,"countCrossingsBetweenAdjacent");function Xe(t,e,n){return[...t].sort((o,s)=>{const r=_n(e.get(o)??[]),d=_n(e.get(s)??[]);return r===d?zs(o,s,n):isFinite(r)?isFinite(d)?r-d:-1:1})}w(Xe,"sortByHeuristic");f(Xe,"sortByHeuristic");function Xn(t,e,n,o,s,r){const d=Ae(t),a=Ae(e),l=Gs(e,d,n,o);if(!s||!r||r.length===0)return Xe(e,l,a);const c=new Map;for(const S of e){const u=s(S),h=c.get(u)??[];h.push(S),c.set(u,h)}const g=[];for(const S of r){const u=c.get(S);if(!u||u.length===0)continue;const h=Xe(u,l,a);g.push(...h)}const y=c.get(null);if(y&&y.length>0){const S=Xe(y,l,a);for(const u of S){const h=Dn(l.get(u)??[]);let i=g.length;if(isFinite(h))for(const[x,C]of g.entries()){const b=Dn(l.get(C)??[]);if(h<b){i=x;break}}g.splice(i,0,u)}}return g}w(Xn,"reorderLayer");f(Xn,"reorderLayer");function Yn(t,e,n,o,s){const r=[...e],d=new Set(t),a=new Set(e),l=o?new Set(o):null,c=n.filter(i=>d.has(i.src)&&a.has(i.dst)),g=l?n.filter(i=>a.has(i.src)&&l.has(i.dst)):void 0,y=f(i=>{let x=Hn(t,i,c);return g&&o&&(x+=Hn(i,o,g)),x},"crossingScore"),S=s?new Map:null;if(s&&S)for(const i of e)S.set(i,s(i));let u=!0,h=y(r);for(;u;){u=!1;for(let i=0;i+1<r.length;i++){if(S){const b=S.get(r[i]),v=S.get(r[i+1]);if(b!==v)continue}const x=h;[r[i],r[i+1]]=[r[i+1],r[i]];const C=y(r);C<x?(h=C,u=!0):[r[i],r[i+1]]=[r[i+1],r[i]]}}return r}w(Yn,"transposeImprove");f(Yn,"transposeImprove");function $s(t,e,n){const o=t.layers.map(a=>[...a]),s=e.edges,r=me(e),d=fo(e,n==null?void 0:n.laneOrder);for(let a=0;a<3;a++){for(let l=1;l<o.length;l++)o[l]=Xn(o[l-1],o[l],s,"down",r,d),o[l]=Yn(o[l-1],o[l],s,o[l+1],r);for(let l=o.length-2;l>=0;l--)o[l]=Xn(o[l+1],o[l],s,"up",r,d),o[l]=Yn(o[l+1],o[l],s,o[l-1],r)}return{layers:o}}w($s,"orderLayers");f($s,"orderLayers");function Vs(t,e,n){const o=(n==null?void 0:n.layerGap)??pr.DEFAULT_LAYER_GAP,s=(n==null?void 0:n.nodeGap)??pr.DEFAULT_NODE_GAP,r=(n==null?void 0:n.laneGap)??s*2,d=(n==null?void 0:n.direction)??"TB",a=d==="LR"||d==="RL",l=t.layers,c=Object.create(null),g=Object.create(null),y=f(B=>e.nodeById.get(B),"getNode"),S=f(B=>{var F;return((F=y(B))==null?void 0:F.width)??0},"getWidth"),u=f(B=>{var F;return((F=y(B))==null?void 0:F.height)??0},"getHeight"),h=me(e),i=fo(e,n==null?void 0:n.laneOrder),x=l.map(B=>B.reduce((F,X)=>Math.max(F,u(X)),0)),C=[];if(a)for(let B=0;B+1<l.length;B++){const F=l[B].reduce((St,Xt)=>Math.max(St,S(Xt)),0),X=l[B+1].reduce((St,Xt)=>Math.max(St,S(Xt)),0),P=x[B],z=x[B+1],U=P/2+z/2,et=(F+X)/2,ft=Math.max(0,et-U-o);C.push(ft)}const b=new Set;for(const B of l)for(const F of B)b.add(h(F));const v=b.has(null),L=i.filter(B=>b.has(B)),p=[...v?[null]:[],...L],M=Object.create(null);for(const B of L)M[B]=0;v&&(M.null=0);for(const B of l){const F=Object.create(null),X=[];for(const P of B){const z=h(P);z===null?X.push(P):(F[z]||(F[z]=[])).push(P)}for(const[P,z]of Object.entries(F)){const U=z.reduce((et,ft)=>et+S(ft),0)+s*Math.max(0,z.length-1);M[P]=Math.max(M[P]??0,U)}if(v&&X.length){const P=X.reduce((z,U)=>z+S(U),0)+s*Math.max(0,X.length-1);M.null=Math.max(M.null??0,P)}}const T=new Map;{const B=p.map(P=>(P===null?M.null:M[P])??0);let X=-(B.reduce((P,z)=>P+z,0)+r*Math.max(0,p.length-1))/2;for(let P=0;P<p.length;P++){const z=p[P],U=B[P]??0,et=X+U/2;T.set(z,et),X+=U,P<p.length-1&&(X+=r)}}let A=0;for(const[B,F]of l.entries()){const X=x[B]??0,P=new Map;for(const U of F){const et=h(U),ft=P.get(et)??[];ft.push(U),P.set(et,ft)}for(const U of p){const et=P.get(U)??[];if(et.length===0)continue;const ft=T.get(U);if(et.length===1){const St=et[0];c[St]=ft,g[St]=A+X/2}else{const St=et.map(ot=>S(ot)),Xt=St.reduce((ot,Z)=>ot+Z,0)+s*(et.length-1);let Dt=ft-Xt/2;for(const[ot,Z]of et.entries()){const it=St[ot];c[Z]=Dt+it/2,g[Z]=A+X/2,Dt+=it+s}}}const z=C[B]??0;A+=X+o+z}const k=new Map;for(const B of e.edges){const F=B.ref.id;k.has(F)||k.set(F,[]),k.get(F).push(B)}for(const[,B]of k){if(B.length===0)continue;const F=B[0].ref,X=F.start,P=F.end;if(X==null||P==null)continue;const z=Math.round(((c[X]??0)+(c[P]??0))/2),U=new Set;for(const et of B)U.add(et.src),U.add(et.dst);for(const et of U){if(et===X||et===P)continue;const ft=e.nodeById.get(et);ft!=null&&ft.isDummy&&(c[et]=z)}}return{x:c,y:g}}w(Vs,"assignCoordinates");f(Vs,"assignCoordinates");var yr=8;function js(t){let e=2166136261;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e>>>0}w(js,"hashString");f(js,"hashString");function Us(t){let e=t>>>0;return()=>{e+=1831565813;let n=e;return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}w(Us,"mulberry32");f(Us,"mulberry32");function Ws(t,e){const n=[...t],o=Us(e);for(let s=n.length-1;s>0;s--){const r=Math.floor(o()*(s+1));[n[s],n[r]]=[n[r],n[s]]}return n}w(Ws,"deterministicShuffle");f(Ws,"deterministicShuffle");function Ks(t,e){let n=0;for(const[o,s]of t.entries())n+=Math.abs(o-(e.get(s)??o));return n}w(Ks,"sourceDistance");f(Ks,"sourceDistance");function Gn(t,e){const n=new Map;for(const[s,r]of t.entries())n.set(r,s);let o=0;for(const{a:s,b:r,weight:d}of e){const a=n.get(s),l=n.get(r);a==null||l==null||(o+=d*Math.abs(a-l))}return o}w(Gn,"laneArrangementCost");f(Gn,"laneArrangementCost");function Js(t){const e=Qe(t);if(e.length<2)return[];const n=new Map(e.map((r,d)=>[r,d])),o=me(t),s=new Map;for(const r of t.layout.edges??[]){if(r.isLayoutOnly)continue;const d=typeof r.start=="string"?r.start:void 0,a=typeof r.end=="string"?r.end:void 0;if(!d||!a||!t.nodeById.has(d)||!t.nodeById.has(a))continue;const l=o(d),c=o(a);if(!l||!c||l===c)continue;const g=n.get(l),y=n.get(c);if(g==null||y==null)continue;const[S,u]=g<=y?[l,c]:[c,l],h=`${S}\0${u}`,i=s.get(h);i?i.weight++:s.set(h,{a:S,b:u,weight:1})}return[...s.values()]}w(Js,"buildWeightedLaneEdges");f(Js,"buildWeightedLaneEdges");function zn(t,e,n){const o=[...t];let s=Gn(o,e),r=!0,d=0;const a=Math.max(1,o.length);for(;r&&d<a;){r=!1,d++;for(let l=0;l+1<o.length;l++){[o[l],o[l+1]]=[o[l+1],o[l]];const c=Gn(o,e);c<s?(s=c,r=!0):[o[l],o[l+1]]=[o[l+1],o[l]]}}return{order:o,cost:s,sourceDistance:Ks(o,n)}}w(zn,"greedySwitch");f(zn,"greedySwitch");function qs(t,e){return t.cost!==e.cost?t.cost<e.cost:t.sourceDistance<e.sourceDistance}w(qs,"isBetterCandidate");f(qs,"isBetterCandidate");function Zs(t,e,n){const o=[...e].sort((s,r)=>s.a===r.a?s.b.localeCompare(r.b):s.a.localeCompare(r.a)).map(({a:s,b:r,weight:d})=>`${s}:${r}:${d}`).join("|");return js(`${t.join("|")}#${o}#${n}`)}w(Zs,"seedForRestart");f(Zs,"seedForRestart");function Qs(t,e={}){const n=Qe(t);if(n.length<2)return n;const o=Js(t);if(o.length===0)return n;const s=new Map(n.map((a,l)=>[a,l]));let r=zn(n,o,s);const d=Math.max(0,e.restarts??yr);for(let a=0;a<d;a++){const l=Zs(n,o,a),c=Ws(n,l),g=zn(c,o,s);qs(g,r)&&(r=g)}return r.order}w(Qs,"optimizeTopLaneOrder");f(Qs,"optimizeTopLaneOrder");function tr(t,e){const n=(e==null?void 0:e.ignoreCrossLaneEdges)??!0,o=(e==null?void 0:e.optimizeRanksByCrossings)??!0,s=ye(t),r=e!=null&&e.automaticLaneOrdering?Qs(s,{restarts:yr}):void 0,d=Ss(s),a=d.acyclic,l=n?Xs(a,{compactSingleInput:(e==null?void 0:e.compactSingleInput)??kn.DEFAULT_COMPACT_SINGLE_INPUT,ignoreCrossLaneEdges:!0,direction:e==null?void 0:e.direction}):Ds(a,{compactSingleInput:(e==null?void 0:e.compactSingleInput)??kn.DEFAULT_COMPACT_SINGLE_INPUT,ignoreCrossLaneEdges:!1,optimizeRanksByCrossings:o}),{layering:c,graphWithDummies:g}=Ys(l,a),y=$s(c,g,{laneOrder:r}),S=Vs(y,g,{layerGap:e==null?void 0:e.layerGap,nodeGap:e==null?void 0:e.nodeGap,direction:e==null?void 0:e.direction,laneOrder:r});return{acyclic:a,reversed:d.reversed,layering:c,ordered:y,coordinates:S}}w(tr,"sugiyamaLayout");f(tr,"sugiyamaLayout");var dt=Dr.EPSILON,Hr=8,Te=15,Fe=15,fn=25,ae=20,Lo=10;function $n(t,e,n){const o=t.x??0,s=t.y??0,r=e.x-o,d=e.y-s,a=Math.abs(r),l=Math.abs(d);return a<dt&&l<dt?n:l>dt&&l*3>=a?d>0?"bottom":"top":a>dt?r>0?"right":"left":n}w($n,"chooseOrthogonalSide");f($n,"chooseOrthogonalSide");function Vn(t,e){return Math.abs(t.to-e.from)<dt||Math.abs(t.to-e.to)<dt?t.to:t.from}w(Vn,"sharedLineEndpointCoord");f(Vn,"sharedLineEndpointCoord");function Ce(t,e){return t.orient==="vertical"?{x:t.coord,y:e}:{x:e,y:t.coord}}w(Ce,"pointOnLine");f(Ce,"pointOnLine");function er(t,e){var J,Q,G,q;const n=t.nodes??[],o=t.edges??[],s=[];for(const m of o)m.isLayoutOnly||s.push({...m,__originalEdge:m});const r=new Map,d=new Map,a=[],l=e==="LR";for(const m of n)r.set(m.id,m);const c=n.filter(m=>m.isGroup&&!m.parentId);for(const m of c){const I={id:m.id},R=f(E=>{d.set(E.id,I),n.filter(N=>N.parentId===E.id).forEach(R)},"assignLane");R(m)}const g=n.filter(m=>!m.isGroup&&!m.isEdgeLabel).map(m=>{const I=m.width??10,R=m.height??10,E=m.x??0,N=m.y??0,H=Hr;return{nodeId:m.id,minX:E-I/2-H,maxX:E+I/2+H,minY:N-R/2-H,maxY:N+R/2+H,visualXHalfExtent:l?R/2+H:I/2+H}}),y=f((m,I,R,E)=>{let N=a.find(H=>H.orientation===m&&Math.abs(H.coord-I)<1);return N||(N={id:`pipe-${m}-${I.toFixed(0)}`,orientation:m,coord:I,spanMin:R,spanMax:E,tracks:[]},a.push(N)),N.spanMin=Math.min(N.spanMin,R),N.spanMax=Math.max(N.spanMax,E),N},"getOrAddPipe"),S=f((m,I)=>{const R=m.width??10,E=m.height??10,N=m.x??0,H=m.y??0;switch(I){case"top":return{x:N,y:H-E/2};case"bottom":return{x:N,y:H+E/2};case"left":return{x:N-R/2,y:H};case"right":return{x:N+R/2,y:H}}},"portForSide"),u=f((m,I,R)=>S(m,$n(m,I,R?"bottom":"top")),"getOrthogonalPort"),h=[],i=[],x=new Set,C=1e3,b=f((m,I,R)=>{if(h.length===0)return 0;const E=Math.abs(I.y-R.y)<dt,N=Math.abs(I.x-R.x)<dt;if(!E&&!N)return 0;let H=0;if(E){const K=I.y,st=Math.min(I.x,R.x)-dt,W=Math.max(I.x,R.x)+dt;if(W<=st)return 0;for(const V of h)V.edgeIndex===m||V.orientation!=="vertical"||V.pipe.coord<st||V.pipe.coord>W||V.from-dt<=K&&V.to+dt>=K&&(H+=C)}else if(N){const K=I.x,st=Math.min(I.y,R.y)-dt,W=Math.max(I.y,R.y)+dt;if(W<=st)return 0;for(const V of h)V.edgeIndex===m||V.orientation!=="horizontal"||V.pipe.coord<st||V.pipe.coord>W||V.from-dt<=K&&V.to+dt>=K&&(H+=C)}return H},"crossingPenalty"),v=s.map((m,I)=>{if(!m.start||!m.end)return{idx:I,crossLane:0,dx:0,dy:0};const R=r.get(m.start),E=r.get(m.end),N=d.get(m.start),H=d.get(m.end),K=N&&H&&N.id!==H.id?1:0,st=R&&E?Math.abs((E.x??0)-(R.x??0)):0,W=R&&E?Math.abs((E.y??0)-(R.y??0)):0;return{idx:I,crossLane:K,dx:st,dy:W}}).sort((m,I)=>{if(m.crossLane!==I.crossLane)return I.crossLane-m.crossLane;const R=m.dx+m.dy,E=I.dx+I.dy;return Math.abs(R-E)>1?R-E:m.idx-I.idx}).map(m=>m.idx),L=f((m,I,R,E)=>{const N=Math.min(m.x,I.x),H=Math.max(m.x,I.x),K=Math.min(m.y,I.y),st=Math.max(m.y,I.y);return!!g.find(V=>R&&V.nodeId===R||E&&V.nodeId===E?!1:Math.abs(m.x-I.x)>dt?V.minY<m.y&&V.maxY>m.y&&V.maxX>N&&V.minX<H:V.minX<m.x&&V.maxX>m.x&&V.maxY>K&&V.minY<st)},"isSegmentBlocked"),p=new Map,M=new Map;for(const m of s)!m.start||!m.end||m.start===m.end||(M.set(m.start,(M.get(m.start)??0)+1),M.set(m.end,(M.get(m.end)??0)+1));const T=f((m,I)=>$n(m,I,"bottom"),"determineSide"),A=new Map;for(const[m,I]of s.entries()){if(!I.start||!I.end||I.start===I.end||I.points&&I.points.length>0)continue;const R=r.get(I.start),E=r.get(I.end);if(!R||!E)continue;const N=(E.x??0)-(R.x??0),H=(E.y??0)-(R.y??0);A.set(m,{edgeIdx:m,srcId:I.start,dstId:I.end,srcSide:T(R,{x:E.x??0,y:E.y??0}),dstSide:T(E,{x:R.x??0,y:R.y??0}),absDx:Math.abs(N),absDy:Math.abs(H),dxSign:Math.sign(N),dySign:Math.sign(H)})}const k=f(m=>m.srcSide==="top"||m.srcSide==="bottom"?m.absDx===0?1/0:m.absDy/m.absDx:m.absDy===0?1/0:m.absDx/m.absDy,"preferenceStrength"),B=f(m=>m.srcSide==="top"||m.srcSide==="bottom"?m.dxSign>=0?"right":"left":m.dySign>=0?"bottom":"top","secondarySide"),F=new Map;for(const m of A.values()){const I=`${m.srcId}:${m.srcSide}`;F.has(I)||F.set(I,[]),F.get(I).push(m)}const X=new Map,P=f((m,I)=>`${m}:${I}`,"loadKey");for(const m of A.values())X.set(P(m.srcId,m.srcSide),(X.get(P(m.srcId,m.srcSide))??0)+1),X.set(P(m.dstId,m.dstSide),(X.get(P(m.dstId,m.dstSide))??0)+1);for(const m of F.values())if(!(m.length<2)){m.sort((I,R)=>{const E=k(I),N=k(R);return Math.abs(E-N)>1e-9?N-E:I.edgeIdx-R.edgeIdx});for(let I=1;I<m.length;I++){const R=m[I],E=B(R),N=X.get(P(R.srcId,R.srcSide))??0,H=X.get(P(R.srcId,E))??0;H>=N||(X.set(P(R.srcId,R.srcSide),N-1),X.set(P(R.srcId,E),H+1),R.srcSide=E)}}const z=f(m=>{const I=m==null?void 0:m.shape;return I==="question"||I==="diamond"},"isDiamondNode"),U=new Map;for(const m of A.values())U.has(m.dstId)||U.set(m.dstId,new Set),U.get(m.dstId).add(m.dstSide);for(const m of A.values()){if(!z(r.get(m.srcId)))continue;const I=U.get(m.srcId);if(!(I!=null&&I.has(m.srcSide)))continue;const R=B(m);if(I.has(R)||(X.get(P(m.srcId,R))??0)>0)continue;const E=X.get(P(m.srcId,m.srcSide))??0;X.set(P(m.srcId,m.srcSide),Math.max(0,E-1)),X.set(P(m.srcId,R),1),m.srcSide=R}for(const m of A.values()){const{edgeIdx:I,srcId:R,dstId:E,srcSide:N,dstSide:H}=m,K=r.get(R),st=r.get(E),W=`${R}:${N}:src`,V=N==="top"||N==="bottom"?st.x??0:st.y??0;p.has(W)||p.set(W,[]),p.get(W).push({edgeIdx:I,oppositeCoord:V});const Mt=`${E}:${H}:dst`,ut=H==="top"||H==="bottom"?K.x??0:K.y??0;p.has(Mt)||p.set(Mt,[]),p.get(Mt).push({edgeIdx:I,oppositeCoord:ut})}const et=new Map,ft=8;for(const[m,I]of p){if(I.length<2)continue;I.sort((Nt,zt)=>Nt.oppositeCoord-zt.oppositeCoord);const R=m.split(":"),E=R.slice(0,-2).join(":"),N=R[R.length-2],H=R[R.length-1],K=r.get(E);if(!K)continue;const W=N==="left"||N==="right"?K.height??10:K.width??10,V=K.shape,ut=V==="question"||V==="diamond"?W*.3:W,rt=Math.min(20,Math.max(ft,ut/(I.length+1))),kt=-(rt*(I.length-1))/2;for(const[Nt,zt]of I.entries()){const oe=kt+Nt*rt,po=`${zt.edgeIdx}:${H}`;et.set(po,oe)}}const St=f(m=>{var I;return!!((I=s[m])!=null&&I.labelNodeId)},"edgeHasLabelNode"),Xt=f((m,I)=>m?(p.get(`${m}:${I}:src`)??[]).some(({edgeIdx:R})=>St(R))||(p.get(`${m}:${I}:dst`)??[]).some(({edgeIdx:R})=>St(R)):!1,"faceHasLabelNode"),Dt=f((m,I,R)=>I==="top"||I==="bottom"?{x:m.x+R,y:m.y}:{x:m.x,y:m.y+R},"applyPortOffset"),ot=f((m,I,R)=>{const E=A.get(m),N={x:R.x??0,y:R.y??0},H={x:I.x??0,y:I.y??0},K=(E==null?void 0:E.srcSide)??T(I,N),st=(E==null?void 0:E.dstSide)??T(R,H);let W=E?S(I,E.srcSide):u(I,N,!0),V=E?S(R,E.dstSide):u(R,H,!1);const Mt=et.get(`${m}:src`),ut=et.get(`${m}:dst`);return Mt!==void 0&&(W=Dt(W,K,Mt)),ut!==void 0&&(V=Dt(V,st,ut)),{pSrcPort:W,pDstPort:V,srcSide:K,dstSide:st}},"portsForEdge");for(const m of v){const I=s[m];if(i[m]=[],!I.start||!I.end||I.points&&I.points.length>0||I.start===I.end)continue;const R=r.get(I.start),E=r.get(I.end);if(!R||!E)continue;const{pSrcPort:N,pDstPort:H,srcSide:K,dstSide:st}=ot(m,R,E),W={...N},V={...H},Mt=K==="top"||K==="bottom",ut=st==="top"||st==="bottom";if(Mt){const Y=N.y>(R.y??0);W.y=Y?N.y+ae:N.y-ae}else{const Y=N.x>(R.x??0);W.x=Y?N.x+ae:N.x-ae}if(ut){const Y=H.y>(E.y??0);V.y=Y?H.y+ae:H.y-ae}else{const Y=H.x>(E.x??0);V.x=Y?H.x+ae:H.x-ae}const at=f((Y,$)=>{for(const tt of g)if(!$.includes(tt.nodeId)&&Y.x>tt.minX&&Y.x<tt.maxX&&Y.y>tt.minY&&Y.y<tt.maxY)return{inside:!0,obstacle:tt};return{inside:!1}},"isPointInObstacle"),rt=f((Y,$,tt,mt,wt)=>{if(wt){const Ft=Y.y>($.y??0);return{x:(tt.x??0)>=Y.x?mt.maxX+Te:mt.minX-Te,y:Ft?mt.maxY+Fe:mt.minY-Fe,leavesPositiveSide:Ft}}const vt=Y.x>($.x??0),Bt=(tt.y??0)>=Y.y;return{x:vt?mt.maxX+Te:mt.minX-Te,y:Bt?mt.maxY+Fe:mt.minY-Fe,leavesPositiveSide:vt}},"obstacleDetour");let It=[];const kt=[I.start,I.end],Nt=at(W,kt);if(Nt.inside&&Nt.obstacle){const Y=Nt.obstacle;if(Mt){const $=rt(N,R,E,Y,!0);W.x=$.x,W.y=$.y;const tt=$.leavesPositiveSide?Math.min(Y.minY-2,N.y+ae):Math.max(Y.maxY+2,N.y-ae);It=[{x:N.x,y:tt},{x:$.x,y:tt},{x:$.x,y:$.y}]}else{const $=rt(N,R,E,Y,!1),tt=$.leavesPositiveSide?Math.min(Y.minX-2,N.x+ae):Math.max(Y.maxX+2,N.x-ae);W.x=$.x,W.y=$.y,It=[{x:tt,y:N.y},{x:tt,y:$.y},{x:$.x,y:$.y}]}}let zt=[];const oe=at(V,kt);if(oe.inside&&oe.obstacle){const Y=oe.obstacle;if(ut){const $=rt(H,E,R,Y,!0);V.x=$.x,V.y=$.y,zt=[{x:$.x,y:$.y},{x:H.x,y:$.y}]}else{const $=rt(H,E,R,Y,!1);V.x=$.x,V.y=$.y,zt=[{x:$.x,y:$.y},{x:$.x,y:H.y}]}}if(It.length===0&&zt.length===0){const Y=Te,$=Math.abs(W.x-V.x)<Y,tt=Math.abs(W.y-V.y)<Y,mt=et.get(`${m}:src`)!==void 0||et.get(`${m}:dst`)!==void 0,wt=(((J=p.get(`${I.start??""}:${K}:src`))==null?void 0:J.length)??0)+(((Q=p.get(`${I.start??""}:${K}:dst`))==null?void 0:Q.length)??0),vt=(((G=p.get(`${I.end??""}:${st}:src`))==null?void 0:G.length)??0)+(((q=p.get(`${I.end??""}:${st}:dst`))==null?void 0:q.length)??0),Bt=wt>1||vt>1,Ft=M.get(I.start??"")??0,yt=M.get(I.end??"")??0,jt=wt>1&&Xt(I.start,K)||vt>1&&Xt(I.end,st),ce=wt<=1||Ft<=2,Ht=vt<=1||yt<=2;if(($||tt)&&!mt&&(!Bt||Bt&&!jt&&ce&&Ht)&&!L(N,H,I.start,I.end)){I.points=[{...N},{...W},{...V},{...H}],x.add(m);const Lt=tt?"horizontal":"vertical",Kt=tt?N.y:N.x,Tt=tt?Math.min(N.x,H.x):Math.min(N.y,H.y),Et=tt?Math.max(N.x,H.x):Math.max(N.y,H.y),te={id:`fast-path-${Lt}-${Kt.toFixed(0)}-${m}`,orientation:Lt,coord:Kt,spanMin:Tt,spanMax:Et,tracks:[]};h.push({edgeIndex:m,segmentIndex:0,orientation:Lt,pipe:te,trackIndex:0,from:Tt,to:Et});continue}}const po=y("vertical",W.x,W.y,W.y);W.x=po.coord;const xr=y("vertical",V.x,V.y,V.y);V.x=xr.coord;let be=Math.min(W.x,V.x)-50,Me=Math.max(W.x,V.x)+50,Be=Math.min(W.y,V.y)-50,Pe=Math.max(W.y,V.y)+50;for(const Y of g){const $=Math.min(W.x,V.x),tt=Math.max(W.x,V.x),mt=Math.min(W.y,V.y),wt=Math.max(W.y,V.y);Y.minX<tt&&Y.maxX>$&&Y.minY<wt&&Y.maxY>mt&&(be=Math.min(be,Y.minX-fn),Me=Math.max(Me,Y.maxX+fn),Be=Math.min(Be,Y.minY-fn),Pe=Math.max(Pe,Y.maxY+fn))}for(const Y of g){if(Y.maxX<be||Y.minX>Me||Y.maxY<Be||Y.minY>Pe)continue;const $=Te;y("horizontal",Y.minY-$,be,Me),y("horizontal",Y.maxY+$,be,Me);const tt=Fe;y("vertical",Y.minX-tt,Be,Pe),y("vertical",Y.maxX+tt,Be,Pe)}y("horizontal",W.y,be,Me),y("horizontal",V.y,be,Me);const br=a.filter(Y=>Y.orientation==="horizontal"&&Y.coord>=Be&&Y.coord<=Pe),Mr=a.filter(Y=>Y.orientation==="vertical"&&Y.coord>=be&&Y.coord<=Me),tn=f((Y,$)=>`${Y.toFixed(1)},${$.toFixed(1)}`,"getKey"),en=tn(W.x,W.y),rr=tn(V.x,V.y),nn=new Map,yo=new Map,xo=new Map,on=new Set,Le=[];nn.set(en,0),xo.set(en,"n"),Le.push({key:en,f:Math.hypot(V.x-W.x,V.y-W.y),pt:W}),on.add(en);let $t=[];const Se=f((Y,$)=>L(Y,$,I.start,I.end),"checkSegmentBlocked"),bo={x:V.x,y:W.y},Sr=Se(W,bo),Ir=Se(bo,V),Cr=Sr||Ir,Mo={x:W.x,y:V.y},vr=Se(W,Mo),Lr=Se(Mo,V);if(Cr?vr||Lr||(Math.abs(W.x-V.x)<dt?$t=[W,V]:$t=[W,Mo,V]):Math.abs(W.y-V.y)<dt||Math.abs(W.x-V.x)<dt?$t=[W,V]:$t=[W,bo,V],$t.length===0)for(;Le.length>0;){Le.sort((yt,jt)=>yt.f-jt.f);const Y=Le.shift();if(on.delete(Y.key),Y.key===rr){let yt=rr,jt=V;for($t=[jt];yo.has(yt);){const ce=yo.get(yt);$t.unshift(ce),jt=ce,yt=tn(ce.x,ce.y)}break}const $=Y.pt.x,tt=Y.pt.y,mt=Mr.sort((yt,jt)=>yt.coord-jt.coord),wt=mt.findIndex(yt=>Math.abs(yt.coord-$)<1),vt=br.sort((yt,jt)=>yt.coord-jt.coord),Bt=vt.findIndex(yt=>Math.abs(yt.coord-tt)<1),Ft=[];wt>0&&Ft.push({x:mt[wt-1].coord,y:tt}),wt>=0&&wt<mt.length-1&&Ft.push({x:mt[wt+1].coord,y:tt}),Bt>0&&Ft.push({x:$,y:vt[Bt-1].coord}),Bt>=0&&Bt<vt.length-1&&Ft.push({x:$,y:vt[Bt+1].coord});for(const yt of Ft){const jt=Math.min($,yt.x),ce=Math.max($,yt.x),Ht=Math.min(tt,yt.y),Wt=Math.max(tt,yt.y);if(g.some(se=>se.nodeId===I.start||se.nodeId===I.end?!1:jt!==ce?se.minY<tt&&se.maxY>tt&&se.maxX>jt&&se.minX<ce:se.minX<$&&se.maxX>$&&se.maxY>Ht&&se.minY<Wt))continue;const Lt=tn(yt.x,yt.y),Kt=Math.abs(yt.x-$)+Math.abs(yt.y-tt),Tt=b(m,Y.pt,yt);let Et=0;const te=V.x-W.x,ke=V.y-W.y,sn=yt.x-$,So=yt.y-tt;(ke>10&&So<-5||ke<-10&&So>5)&&(Et=Math.abs(So)*100),(te>10&&sn<-5||te<-10&&sn>5)&&(Et+=Math.abs(sn)*50);let ir=0;const cr=xo.get(Y.key)??"n",ar=Math.abs(sn)>dt?"h":"v";cr!=="n"&&cr!==ar&&(ir=50);const Tr=Kt+Tt+Et+ir,rn=(nn.get(Y.key)??1/0)+Tr,lr=Math.abs(V.x-yt.x)+Math.abs(V.y-yt.y);if(rn<(nn.get(Lt)??1/0))if(yo.set(Lt,Y.pt),nn.set(Lt,rn),xo.set(Lt,ar),!on.has(Lt))Le.push({key:Lt,f:rn+lr,pt:yt}),on.add(Lt);else{const se=Le.findIndex(Er=>Er.key===Lt);se!==-1&&(Le[se].f=rn+lr)}}}if($t.length===0&&($t=[W,{x:W.x,y:V.y},V]),$t.length>4){const Y=$t[0],$=$t[$t.length-1];let tt=Math.min(Y.x,$.x),mt=Math.max(Y.x,$.x),wt=Math.min(Y.y,$.y),vt=Math.max(Y.y,$.y);for(const Ht of $t)tt=Math.min(tt,Ht.x),mt=Math.max(mt,Ht.x),wt=Math.min(wt,Ht.y),vt=Math.max(vt,Ht.y);const Bt=mt>Math.max(Y.x,$.x),Ft=tt<Math.min(Y.x,$.x);if(l){const Ht=Fe;if(Bt){const Wt=Math.max(Y.x,$.x),_t=Math.min(Y.y,$.y),Lt=Math.max(Y.y,$.y),Kt=g.filter(Tt=>Tt.minX<Wt&&Tt.maxX>Wt&&Tt.minY<Lt&&Tt.maxY>_t);if(Kt.length>0){let Tt=Math.max(Y.x,$.x);for(const Et of Kt){const te=(Et.minX+Et.maxX)/2;if(Et.visualXHalfExtent===void 0||isNaN(Et.visualXHalfExtent))continue;const ke=te+Et.visualXHalfExtent+Ht;Tt=Math.max(Tt,ke)}isNaN(Tt)||(mt=Tt)}}if(Ft){const Wt=g.filter(_t=>_t.minX<Math.min(Y.x,$.x)+Ht&&_t.minY<Math.max(Y.y,$.y)&&_t.maxY>Math.min(Y.y,$.y));if(Wt.length>0){let _t=Math.min(Y.x,$.x);for(const Lt of Wt){const Tt=(Lt.minX+Lt.maxX)/2-Lt.visualXHalfExtent-Ht;_t=Math.min(_t,Tt)}tt=_t}}}const yt=f(Ht=>{const Wt=$.y>Y.y,_t=g.filter(Tt=>{const Et=Math.min(Y.x,$.x)<Tt.maxX&&Math.max(Y.x,$.x)>Tt.minX,te=Math.min(Y.y,$.y)<Tt.maxY&&Math.max(Y.y,$.y)>Tt.minY;return Et&&te});let Lt=_t;if(l&&_t.length>0){const Tt=_t.filter(Et=>Et.minX<Ht&&Et.maxX>Ht);Tt.length>0&&(Lt=Tt)}if(Lt.length===0)return $.y;const Kt=Te;if(Wt){const Et=Math.max(...Lt.map(te=>te.maxY))+Kt;if(Et<$.y-dt)return Et}else{const Et=Math.min(...Lt.map(te=>te.minY))-Kt;if(Et>$.y+dt)return Et}return $.y},"findBestReturnY"),jt=f(Ht=>{const Wt=yt(Ht),_t={x:Ht,y:Y.y},Lt={x:Ht,y:Wt},Kt={x:$.x,y:Wt},Tt=Se(Y,_t),Et=Se(_t,Lt),te=Se(Lt,Kt),ke=Wt!==$.y?Se(Kt,$):!1;return!Tt&&!Et&&!te&&!ke?Math.abs(Wt-$.y)<dt?[Y,_t,Lt,$]:[Y,_t,Lt,Kt,$]:null},"trySimplifyWithDetourX"),ce=Bt&&!Ft?jt(mt):Ft&&!Bt?jt(tt):null;ce&&($t=ce)}const Vt=[N,...It,...$t,...zt.reverse(),H];if(Vt.length>=3){const Y=Vt[Vt.length-1],$=Vt[Vt.length-2],tt=Vt[Vt.length-3],mt=Math.abs(tt.y-$.y)<dt&&Math.abs($.y-Y.y)<dt,wt=Math.abs(tt.x-$.x)<dt&&Math.abs($.x-Y.x)<dt;if(mt){const vt=Math.sign($.x-tt.x),Bt=Math.sign(Y.x-tt.x);vt!==0&&vt===Bt&&Math.abs($.x-tt.x)>Math.abs(Y.x-tt.x)&&Vt.splice(-2,1)}else if(wt){const vt=Math.sign($.y-tt.y),Bt=Math.sign(Y.y-tt.y);vt!==0&&vt===Bt&&Math.abs($.y-tt.y)>Math.abs(Y.y-tt.y)&&Vt.splice(-2,1)}}const he=[Vt[0]];for(let Y=1;Y<Vt.length-1;Y++){if(Y===1){he.push(Vt[Y]);continue}const $=he[he.length-1],tt=Vt[Y],mt=Vt[Y+1];if(Math.abs($.y-tt.y)<dt&&Math.abs(tt.y-mt.y)<dt){const wt=tt.x>$.x,vt=mt.x>tt.x;if(wt!==vt){he.push(tt);continue}continue}if(Math.abs($.x-tt.x)<dt&&Math.abs(tt.x-mt.x)<dt){const wt=tt.y>$.y,vt=mt.y>tt.y;if(wt!==vt){he.push(tt);continue}continue}he.push(tt)}he.push(Vt[Vt.length-1]);for(let Y=0;Y<he.length-1;Y++){const $=he[Y],tt=he[Y+1],mt=Math.abs($.x-tt.x)<dt?"vertical":"horizontal",wt=mt==="vertical"?$.x:$.y,vt=mt==="vertical"?Math.min($.y,tt.y):Math.min($.x,tt.x),Bt=mt==="vertical"?Math.max($.y,tt.y):Math.max($.x,tt.x),Ft=y(mt,wt,vt,Bt),yt={edgeIndex:m,segmentIndex:Y,orientation:mt,pipe:Ft,trackIndex:0,from:vt,to:Bt};h.push(yt),i[m].push(h.length-1),Ft.tracks[0]||(Ft.tracks[0]={index:0,coord:Ft.coord,segments:[]}),Ft.tracks[0].segments.push({edgeIndex:m,segmentIndex:Y,from:vt,to:Bt})}}const Z=f((m,I)=>m.from<I.to&&I.from<m.to,"segmentsOverlap"),it=f((m,I,R,E)=>{const N=!E.segments.some(K=>(K.edgeIndex!==I.edgeIndex||K.segmentIndex!==I.segmentIndex)&&Z(K,m)),H=!R.segments.some(K=>(K.edgeIndex!==m.edgeIndex||K.segmentIndex!==m.segmentIndex)&&Z(K,I));return N&&H?(m.trackIndex=E.index,I.trackIndex=R.index,R.segments=[...R.segments.filter(K=>K.edgeIndex!==m.edgeIndex||K.segmentIndex!==m.segmentIndex),{edgeIndex:I.edgeIndex,segmentIndex:I.segmentIndex,from:I.from,to:I.to}],E.segments=[...E.segments.filter(K=>K.edgeIndex!==I.edgeIndex||K.segmentIndex!==I.segmentIndex),{edgeIndex:m.edgeIndex,segmentIndex:m.segmentIndex,from:m.from,to:m.to}],!0):!1},"trySwapSegmentsAcrossTracks"),ht=f(m=>{const I=m.tracks.length;return m.tracks[I]={index:I,coord:m.coord,segments:[]},I},"createNewTrack"),xt=f((m,I)=>{const R=m.pipe.tracks[m.trackIndex];R.segments=R.segments.filter(N=>N.edgeIndex!==m.edgeIndex||N.segmentIndex!==m.segmentIndex),m.trackIndex=I,m.pipe.tracks[I].segments.push({edgeIndex:m.edgeIndex,segmentIndex:m.segmentIndex,from:m.from,to:m.to})},"moveSegmentToTrack"),Ct=f((m,I)=>{const R=i[m.edgeIndex];for(const E of R){const N=h[E];N.pipe===m.pipe&&xt(N,I)}},"moveSegmentChainToTrack"),Rt=f(m=>{const I=i[m.edgeIndex],R=I.indexOf(h.indexOf(m)),E=[];return R>0&&E.push(h[I[R-1]]),R<I.length-1&&E.push(h[I[R+1]]),E},"getAdjacentSegmentsAlongEdge"),qt=f((m,I)=>{if(m.orientation===I.orientation)return!1;const R=m.orientation==="horizontal"?m:I,E=m.orientation==="horizontal"?I:m;return E.pipe.coord>R.from&&E.pipe.coord<R.to&&R.pipe.coord>E.from&&R.pipe.coord<E.to},"haveAnyCrossing"),Zt=f((m,I)=>{for(const R of m.tracks)if(!R.segments.some(N=>(N.edgeIndex!==I.edgeIndex||N.segmentIndex!==I.segmentIndex)&&Z(N,I)))return R.index;return-1},"findAvailableTrack"),Qt=f((m,I)=>{if(m.trackIndex===I.trackIndex)return Z(m,I);const R=Rt(m),E=Rt(I);return R.some(N=>E.some(H=>qt(N,H)))},"segmentsConflict"),ie=f((m,I,R)=>{if(it(m,I,m.pipe.tracks[m.trackIndex],I.pipe.tracks[I.trackIndex]))return;const E=Zt(m.pipe,I);R(I,E!==-1?E:ht(m.pipe))},"resolveTrackConflict"),Oe=f(m=>{let I=0;for(let R=0;R<m.length;R++)for(let E=R+1;E<m.length;E++){const N=m[R],H=m[E];N.pipe===H.pipe&&Qt(N,H)&&(I++,ie(N,H,Ct))}return I},"resolveHandleConflicts"),xe=new Map,Ne=f(m=>{if(xe.has(m))return xe.get(m);const I=i[m];if(I.length===0){const st={dest:0,deviation:0,base:0,delta:0};return xe.set(m,st),st}const E=h[I[0]].pipe.coord;let N=E;for(let st=1;st<I.length;st++){const W=h[I[st]];if(W.orientation==="horizontal"){const V=W.from,Mt=W.to;N=Math.abs(V-E)>Math.abs(Mt-E)?V:Mt;break}}const H=Math.abs(N-E),K={dest:N,deviation:H,base:E,delta:N-E};return xe.set(m,K),K},"getDestInfo"),ho=f(()=>{let m=0;const I=new Map;for(const[E,N]of s.entries())i[E].length!==0&&N.start&&(I.has(N.start)||I.set(N.start,[]),I.get(N.start).push(E));const R=f(E=>{const N=s[E];if(!N.start||!N.end)return 0;const H=r.get(N.start),K=r.get(N.end);if(!H||!K)return 0;const st=(K.x??0)-(H.x??0),W=(K.y??0)-(H.y??0);return Math.abs(st)+Math.abs(W)},"getEdgeDistance");for(const E of I.values()){E.sort((H,K)=>{const st=Ne(H),W=Ne(K);if(Math.abs(st.deviation-W.deviation)>1)return st.deviation-W.deviation;if(Math.abs(st.dest-W.dest)>1)return st.dest-W.dest;const V=R(H),Mt=R(K);if(Math.abs(V-Mt)>1)return Mt-V;const ut=i[H].length,at=i[K].length;if(ut!==at)return ut-at;if(ut===1){const rt=i[H][0],It=i[K][0];if(h[rt]&&h[It]){const kt=h[rt],Nt=h[It],zt=Math.abs(kt.to-kt.from),oe=Math.abs(Nt.to-Nt.from);if(Math.abs(zt-oe)>1)return zt-oe}}return 0});const N=E.map(H=>h[i[H][0]]);m+=Oe(N)}return m},"fixSourceHandleCrossings"),go=f(()=>{let m=0;const I=new Map;for(const[R,E]of s.entries())i[R].length!==0&&E.end&&(I.has(E.end)||I.set(E.end,[]),I.get(E.end).push(R));for(const R of I.values()){R.sort((N,H)=>{const K=f(V=>{const Mt=i[V];if(Mt.length<2)return 0;const ut=h[Mt[Mt.length-2]];return Math.abs(ut.to-ut.from)},"getDist"),st=K(N),W=K(H);return Math.abs(st-W)>.1?st-W:N-H});const E=R.map(N=>h[i[N][i[N].length-1]]);m+=Oe(E)}return m},"fixTargetHandleCrossings"),mo=f(()=>{let m=0;for(const I of a){const R=[];for(const E of I.tracks)for(const N of E.segments){const H=i[N.edgeIndex].find(K=>h[K].segmentIndex===N.segmentIndex);H!==void 0&&R.push(h[H])}R.sort((E,N)=>E.edgeIndex-N.edgeIndex||E.segmentIndex-N.segmentIndex);for(let E=0;E<R.length;E++)for(let N=E+1;N<R.length;N++){const H=R[E],K=R[N];Qt(H,K)&&(m++,ie(H,K,xt))}}return m},"fixPipeCrossings");let O=0;const _=10;for(;O<_;){let m=0;if(m+=ho(),m+=go(),m+=mo(),m===0)break;O++}const D=new Map;for(const m of a){const I=[];m.tracks.forEach(E=>{E.segments.forEach(N=>{I.push({edgeIndex:N.edgeIndex,segmentIndex:N.segmentIndex,trackIndex:E.index,from:N.from,to:N.to})})}),I.sort((E,N)=>E.from-N.from);const R=[];if(I.length>0){let E=[I[0]],N=I[0].to;for(let H=1;H<I.length;H++){const K=I[H];K.from<N?(E.push(K),N=Math.max(N,K.to)):(R.push(E),E=[K],N=K.to)}R.push(E)}for(const E of R){const N=new Set;E.forEach(rt=>N.add(rt.trackIndex));const H=new Map;E.forEach(rt=>{const It=Ne(rt.edgeIndex);H.set(rt.trackIndex,(H.get(rt.trackIndex)??0)+It.delta)});const K=[...N].filter(rt=>(H.get(rt)??0)<-1),st=[...N].filter(rt=>(H.get(rt)??0)>1),W=[...N].filter(rt=>Math.abs(H.get(rt)??0)<=1);K.sort((rt,It)=>(H.get(It)??0)-(H.get(rt)??0)),st.sort((rt,It)=>(H.get(rt)??0)-(H.get(It)??0));const V=f((rt,It)=>{E.filter(kt=>kt.trackIndex===rt).forEach(kt=>{const Nt=x.has(kt.edgeIndex)?m.coord:It;D.set(`${kt.edgeIndex}-${kt.segmentIndex}`,Nt)})},"assignCoord");let Mt=0;for(const rt of K)Mt++,V(rt,m.coord-Mt*Lo);if(W.length===0&&N.size>0){const rt=[...N].sort((Nt,zt)=>Math.abs(H.get(Nt)??0)-Math.abs(H.get(zt)??0))[0],It=K.indexOf(rt);It!==-1&&K.splice(It,1);const kt=st.indexOf(rt);kt!==-1&&st.splice(kt,1),W.push(rt)}let ut=0;for(const rt of W){if(ut===0)V(rt,m.coord);else{const It=ut%2===1?1:-1,kt=Math.ceil(ut/2);V(rt,m.coord+It*kt*Lo*.5)}ut++}let at=0;for(const rt of st)at++,V(rt,m.coord+at*Lo)}}for(const[m,I]of s.entries()){const R=i[m]??[];if(R.length===0)continue;const E=[],N=r.get(I.start),H=r.get(I.end),{pSrcPort:K,pDstPort:st}=ot(m,N,H),W=R.map(ut=>{const at=h[ut],rt=D.get(`${at.edgeIndex}-${at.segmentIndex}`)??at.pipe.coord;return{orient:at.orientation,coord:rt,from:at.from,to:at.to}});E.push(K);for(let ut=0;ut<W.length;ut++){const at=W[ut],rt=E[E.length-1],It=at.orient==="vertical"?rt.y:rt.x,kt=at.orient==="vertical"?rt.x:rt.y,Nt=W[ut+1],zt=ut<W.length-1;if(Math.abs(kt-at.coord)>dt&&E.push(Ce(at,It)),zt&&Nt.orient===at.orient)if(Math.abs(at.coord-Nt.coord)>dt){const oe=at.orient==="vertical"?(It+Nt.from)/2:Vn(at,Nt);E.push(Ce(at,oe),Ce(Nt,oe))}else(ut===0||ut===W.length-2)&&E.push(Ce(at,Vn(at,Nt)));else if(zt)E.push(Ce(at,Nt.coord));else{const oe=Math.abs(at.from-It)<Math.abs(at.to-It)?at.to:at.from;E.push(Ce(at,oe))}}const V=E[E.length-1];(Math.abs(V.x-st.x)>dt||Math.abs(V.y-st.y)>dt)&&E.push(st);const Mt=[];E.length>0&&Mt.push(E[0]);for(let ut=1;ut<E.length;ut++){const at=E[ut],rt=Mt[Mt.length-1];(Math.abs(at.x-rt.x)>dt||Math.abs(at.y-rt.y)>dt)&&Mt.push(at)}I.points=Mt}for(const m of s){const I=m.__originalEdge;I&&m.points&&(I.points=m.points)}t.edges=(t.edges??[]).filter(m=>!m.isLayoutOnly);const j=f((m,I)=>{const R=I.x??0,E=I.y??0,N=I.width??0,H=I.height??0;if(N<=0||H<=0)return m;const K=R-N/2,st=R+N/2,W=E-H/2,V=E+H/2;if(m.x<K||m.x>st||m.y<W||m.y>V)return m;const Mt=m.x-K,ut=st-m.x,at=m.y-W,rt=V-m.y,It=Math.min(Mt,ut,at,rt);return It===Mt?{x:K,y:m.y}:It===ut?{x:st,y:m.y}:It===at?{x:m.x,y:W}:{x:m.x,y:V}},"nodeBoundaryClamp");for(const m of t.edges){const I=m.points;if(!I||I.length<2)continue;const R=m.start,E=m.end,N=R?r.get(R):void 0,H=E?r.get(E):void 0;N&&(I[0]=j(I[0],N)),H&&(I[I.length-1]=j(I[I.length-1],H))}return t}w(er,"routeEdgesOrthogonal");f(er,"routeEdgesOrthogonal");function nr(t){return t.direction??"TB"}w(nr,"getSwimlaneDirection");f(nr,"getSwimlaneDirection");function or(t){var g,y,S,u,h;const e=Xo(t),n=((g=t.config.flowchart)==null?void 0:g.nodeSpacing)??40,o=((y=t.config.flowchart)==null?void 0:y.rankSpacing)??100,s=((S=t.config.swimlane)==null?void 0:S.ignoreCrossLaneEdges)??!0,r=((u=t.config.swimlane)==null?void 0:u.optimizeRanksByCrossings)??!0,d=((h=t.config.swimlane)==null?void 0:h.automaticLaneOrdering)??!1,a=nr(t),{ordered:l,coordinates:c}=tr(e,{nodeGap:n,layerGap:o,ignoreCrossLaneEdges:s,optimizeRanksByCrossings:r,automaticLaneOrdering:d,direction:a});Yo(e,l,c,{nodeGap:n,layerGap:o});for(const i of t.edges??[])delete i.points;er(t,a);for(const i of t.edges??[])(!i.curve||i.curve==="basis")&&(i.curve="rounded");return bs(t,a),xs(t),a}w(or,"runSwimlaneLayoutCore");f(or,"runSwimlaneLayoutCore");function sr(t){Ho(t);const e=Go(t);t.nodes=e.nodes,t.edges=e.edges}w(sr,"prepareSwimlaneLayout");f(sr,"prepareSwimlaneLayout");var Ur=wr({prepareLayout:sr,runLayoutCore:or,afterPaint:_o});export{Ur as render};