@celljs/ta 4.6.1 → 4.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (252) hide show
  1. package/README.en.md +108 -0
  2. package/README.md +11 -2
  3. package/dist/cli.mjs +149 -104
  4. package/dist/pi/CHANGELOG.md +12 -0
  5. package/dist/pi/package.json +1 -1
  6. package/dist/pi/packages/ta-channels/README.en.md +48 -0
  7. package/dist/pi/packages/ta-channels/README.md +1 -1
  8. package/dist/pi/packages/ta-channels/extension/index.mjs +8 -4
  9. package/dist/pi/packages/ta-channels/host/index.mjs +22 -3
  10. package/dist/pi/packages/ta-channels/lib/channels-model.d.ts +4 -1
  11. package/dist/pi/packages/ta-channels/lib/channels-model.d.ts.map +1 -1
  12. package/dist/pi/packages/ta-channels/lib/channels-model.js.map +1 -1
  13. package/dist/pi/packages/ta-channels/lib/channels-util.d.ts +2 -0
  14. package/dist/pi/packages/ta-channels/lib/channels-util.d.ts.map +1 -1
  15. package/dist/pi/packages/ta-channels/lib/channels-util.js +6 -1
  16. package/dist/pi/packages/ta-channels/lib/channels-util.js.map +1 -1
  17. package/dist/pi/packages/ta-channels/lib/channels.js +1 -1
  18. package/dist/pi/packages/ta-channels/lib/channels.js.map +1 -1
  19. package/dist/pi/packages/ta-channels/lib/extension.d.ts +2 -2
  20. package/dist/pi/packages/ta-channels/lib/extension.d.ts.map +1 -1
  21. package/dist/pi/packages/ta-channels/lib/extension.js +2 -2
  22. package/dist/pi/packages/ta-channels/lib/extension.js.map +1 -1
  23. package/dist/pi/packages/ta-channels/lib/sidebar.d.ts.map +1 -1
  24. package/dist/pi/packages/ta-channels/lib/sidebar.js +4 -2
  25. package/dist/pi/packages/ta-channels/lib/sidebar.js.map +1 -1
  26. package/dist/pi/packages/ta-channels/lib/style.d.ts +1 -1
  27. package/dist/pi/packages/ta-channels/lib/style.d.ts.map +1 -1
  28. package/dist/pi/packages/ta-channels/lib/style.js +1 -0
  29. package/dist/pi/packages/ta-channels/lib/style.js.map +1 -1
  30. package/dist/pi/packages/ta-channels/lib/team-tools.js +1 -1
  31. package/dist/pi/packages/ta-channels/lib/team-tools.js.map +1 -1
  32. package/dist/pi/packages/ta-channels/lib/team.d.ts +7 -1
  33. package/dist/pi/packages/ta-channels/lib/team.d.ts.map +1 -1
  34. package/dist/pi/packages/ta-channels/lib/team.js +25 -2
  35. package/dist/pi/packages/ta-channels/lib/team.js.map +1 -1
  36. package/dist/pi/packages/ta-channels/lib/views.d.ts +3 -1
  37. package/dist/pi/packages/ta-channels/lib/views.d.ts.map +1 -1
  38. package/dist/pi/packages/ta-channels/lib/views.js +6 -0
  39. package/dist/pi/packages/ta-channels/lib/views.js.map +1 -1
  40. package/dist/pi/packages/ta-channels/package.json +1 -1
  41. package/dist/pi/packages/ta-channels/web/index.js +18 -4
  42. package/dist/pi/packages/ta-computer-use/README.en.md +37 -0
  43. package/dist/pi/packages/ta-computer-use/README.md +37 -0
  44. package/dist/pi/packages/ta-computer-use/extension/index.mjs +549 -0
  45. package/dist/pi/packages/ta-computer-use/lib/cua-driver-access.d.ts +71 -0
  46. package/dist/pi/packages/ta-computer-use/lib/cua-driver-access.d.ts.map +1 -0
  47. package/dist/pi/packages/ta-computer-use/lib/cua-driver-access.js +143 -0
  48. package/dist/pi/packages/ta-computer-use/lib/cua-driver-access.js.map +1 -0
  49. package/dist/pi/packages/ta-computer-use/lib/cua-driver-daemon.d.ts +78 -0
  50. package/dist/pi/packages/ta-computer-use/lib/cua-driver-daemon.d.ts.map +1 -0
  51. package/dist/pi/packages/ta-computer-use/lib/cua-driver-daemon.js +250 -0
  52. package/dist/pi/packages/ta-computer-use/lib/cua-driver-daemon.js.map +1 -0
  53. package/dist/pi/packages/ta-computer-use/lib/cua-driver.d.ts +56 -0
  54. package/dist/pi/packages/ta-computer-use/lib/cua-driver.d.ts.map +1 -0
  55. package/dist/pi/packages/ta-computer-use/lib/cua-driver.js +112 -0
  56. package/dist/pi/packages/ta-computer-use/lib/cua-driver.js.map +1 -0
  57. package/dist/pi/packages/ta-computer-use/lib/extension.d.ts +39 -0
  58. package/dist/pi/packages/ta-computer-use/lib/extension.d.ts.map +1 -0
  59. package/dist/pi/packages/ta-computer-use/lib/extension.js +174 -0
  60. package/dist/pi/packages/ta-computer-use/lib/extension.js.map +1 -0
  61. package/dist/pi/packages/ta-computer-use/lib/pi-types.d.ts +3 -0
  62. package/dist/pi/packages/ta-computer-use/lib/pi-types.d.ts.map +1 -0
  63. package/dist/pi/packages/ta-computer-use/lib/pi-types.js +3 -0
  64. package/dist/pi/packages/ta-computer-use/lib/pi-types.js.map +1 -0
  65. package/dist/pi/packages/ta-computer-use/package.json +51 -0
  66. package/dist/pi/packages/ta-extensions/README.en.md +27 -0
  67. package/dist/pi/packages/ta-extensions/README.md +10 -3
  68. package/dist/pi/packages/ta-extensions/host/index.mjs +331 -1
  69. package/dist/pi/packages/ta-extensions/lib/actions.d.ts +5 -1
  70. package/dist/pi/packages/ta-extensions/lib/actions.d.ts.map +1 -1
  71. package/dist/pi/packages/ta-extensions/lib/actions.js +20 -1
  72. package/dist/pi/packages/ta-extensions/lib/actions.js.map +1 -1
  73. package/dist/pi/packages/ta-extensions/lib/context.d.ts +20 -0
  74. package/dist/pi/packages/ta-extensions/lib/context.d.ts.map +1 -0
  75. package/dist/pi/packages/ta-extensions/lib/context.js +8 -0
  76. package/dist/pi/packages/ta-extensions/lib/context.js.map +1 -0
  77. package/dist/pi/packages/ta-extensions/lib/host.d.ts +8 -2
  78. package/dist/pi/packages/ta-extensions/lib/host.d.ts.map +1 -1
  79. package/dist/pi/packages/ta-extensions/lib/host.js +11 -2
  80. package/dist/pi/packages/ta-extensions/lib/host.js.map +1 -1
  81. package/dist/pi/packages/ta-extensions/lib/i18n.d.ts +32 -0
  82. package/dist/pi/packages/ta-extensions/lib/i18n.d.ts.map +1 -1
  83. package/dist/pi/packages/ta-extensions/lib/i18n.js +78 -2
  84. package/dist/pi/packages/ta-extensions/lib/i18n.js.map +1 -1
  85. package/dist/pi/packages/ta-extensions/lib/index.d.ts +2 -1
  86. package/dist/pi/packages/ta-extensions/lib/index.d.ts.map +1 -1
  87. package/dist/pi/packages/ta-extensions/lib/index.js +25 -21
  88. package/dist/pi/packages/ta-extensions/lib/index.js.map +1 -1
  89. package/dist/pi/packages/ta-extensions/lib/market-detail.d.ts +12 -0
  90. package/dist/pi/packages/ta-extensions/lib/market-detail.d.ts.map +1 -0
  91. package/dist/pi/packages/ta-extensions/lib/market-detail.js +95 -0
  92. package/dist/pi/packages/ta-extensions/lib/market-detail.js.map +1 -0
  93. package/dist/pi/packages/ta-extensions/lib/market-parts.d.ts +33 -0
  94. package/dist/pi/packages/ta-extensions/lib/market-parts.d.ts.map +1 -0
  95. package/dist/pi/packages/ta-extensions/lib/market-parts.js +56 -0
  96. package/dist/pi/packages/ta-extensions/lib/market-parts.js.map +1 -0
  97. package/dist/pi/packages/ta-extensions/lib/market-store.d.ts +41 -0
  98. package/dist/pi/packages/ta-extensions/lib/market-store.d.ts.map +1 -0
  99. package/dist/pi/packages/ta-extensions/lib/market-store.js +99 -0
  100. package/dist/pi/packages/ta-extensions/lib/market-store.js.map +1 -0
  101. package/dist/pi/packages/ta-extensions/lib/market-style.d.ts +3 -0
  102. package/dist/pi/packages/ta-extensions/lib/market-style.d.ts.map +1 -0
  103. package/dist/pi/packages/ta-extensions/lib/market-style.js +98 -0
  104. package/dist/pi/packages/ta-extensions/lib/market-style.js.map +1 -0
  105. package/dist/pi/packages/ta-extensions/lib/market-util.d.ts +74 -0
  106. package/dist/pi/packages/ta-extensions/lib/market-util.d.ts.map +1 -0
  107. package/dist/pi/packages/ta-extensions/lib/market-util.js +193 -0
  108. package/dist/pi/packages/ta-extensions/lib/market-util.js.map +1 -0
  109. package/dist/pi/packages/ta-extensions/lib/market-view.d.ts +9 -0
  110. package/dist/pi/packages/ta-extensions/lib/market-view.d.ts.map +1 -0
  111. package/dist/pi/packages/ta-extensions/lib/market-view.js +144 -0
  112. package/dist/pi/packages/ta-extensions/lib/market-view.js.map +1 -0
  113. package/dist/pi/packages/ta-extensions/lib/market.d.ts +88 -0
  114. package/dist/pi/packages/ta-extensions/lib/market.d.ts.map +1 -0
  115. package/dist/pi/packages/ta-extensions/lib/market.js +198 -0
  116. package/dist/pi/packages/ta-extensions/lib/market.js.map +1 -0
  117. package/dist/pi/packages/ta-extensions/lib/page.d.ts +3 -16
  118. package/dist/pi/packages/ta-extensions/lib/page.d.ts.map +1 -1
  119. package/dist/pi/packages/ta-extensions/lib/page.js +87 -58
  120. package/dist/pi/packages/ta-extensions/lib/page.js.map +1 -1
  121. package/dist/pi/packages/ta-extensions/lib/signal.d.ts +12 -0
  122. package/dist/pi/packages/ta-extensions/lib/signal.d.ts.map +1 -0
  123. package/dist/pi/packages/ta-extensions/lib/signal.js +32 -0
  124. package/dist/pi/packages/ta-extensions/lib/signal.js.map +1 -0
  125. package/dist/pi/packages/ta-extensions/lib/style.d.ts +1 -1
  126. package/dist/pi/packages/ta-extensions/lib/style.d.ts.map +1 -1
  127. package/dist/pi/packages/ta-extensions/lib/style.js +3 -2
  128. package/dist/pi/packages/ta-extensions/lib/style.js.map +1 -1
  129. package/dist/pi/packages/ta-extensions/package.json +1 -1
  130. package/dist/pi/packages/ta-extensions/skills/ta-package/SKILL.md +1 -1
  131. package/dist/pi/packages/ta-extensions/web/index.js +937 -54
  132. package/dist/pi/packages/ta-workspace/README.md +1 -1
  133. package/dist/pi/packages/ta-workspace/README.zh-cn.md +29 -0
  134. package/dist/pi/packages/ta-workspace/lib/browser.d.ts.map +1 -1
  135. package/dist/pi/packages/ta-workspace/lib/browser.js +26 -2
  136. package/dist/pi/packages/ta-workspace/lib/browser.js.map +1 -1
  137. package/dist/pi/packages/ta-workspace/lib/util/workspace.d.ts +4 -0
  138. package/dist/pi/packages/ta-workspace/lib/util/workspace.d.ts.map +1 -1
  139. package/dist/pi/packages/ta-workspace/lib/util/workspace.js +24 -0
  140. package/dist/pi/packages/ta-workspace/lib/util/workspace.js.map +1 -1
  141. package/dist/pi/packages/ta-workspace/package.json +1 -1
  142. package/dist/pi/packages/ta-workspace/web/index.js +47 -6
  143. package/dist/public/assets/{abnfDiagram-S7VZAUFO-3_0FZVeo.js → abnfDiagram-S7VZAUFO-D1ZeYB9c.js} +1 -1
  144. package/dist/public/assets/{architecture-WOLXFQ4H-BX-N-_gd.js → architecture-WOLXFQ4H-RV_x_iFj.js} +1 -1
  145. package/dist/public/assets/{architectureDiagram-YGSQEFNW-Daeu1xjI.js → architectureDiagram-YGSQEFNW-BGOmzcpZ.js} +1 -1
  146. package/dist/public/assets/{blockDiagram-APKKGZFW-DjJS8902.js → blockDiagram-APKKGZFW-BkoflIym.js} +1 -1
  147. package/dist/public/assets/{browser-DZ1aJcgd.js → browser-Cl9_lr0X.js} +1 -1
  148. package/dist/public/assets/{c4Diagram-KJ2TOQU5-mKfHFqh9.js → c4Diagram-KJ2TOQU5-CfrQTIEs.js} +1 -1
  149. package/dist/public/assets/{chunk-6MUBBAK2-Cnx7dsB1.js → chunk-6MUBBAK2-C-VxnXsG.js} +1 -1
  150. package/dist/public/assets/{chunk-AXFCVDMN-g4Y7Pg2t.js → chunk-AXFCVDMN-aqbxPiaN.js} +1 -1
  151. package/dist/public/assets/{chunk-BG4553SI-QNE6A_Vg.js → chunk-BG4553SI-DDgvFLBP.js} +1 -1
  152. package/dist/public/assets/{chunk-DQASFODM-DPHr08r0.js → chunk-DQASFODM-CItpjfW5.js} +1 -1
  153. package/dist/public/assets/{chunk-HFQBQIA3-CenkxHlV.js → chunk-HFQBQIA3-BATYGV1I.js} +1 -1
  154. package/dist/public/assets/{chunk-KQLB2F66-C3Z8V8R_.js → chunk-KQLB2F66-BVAqVjgq.js} +1 -1
  155. package/dist/public/assets/{chunk-KS47KZWR-BbUyxMWY.js → chunk-KS47KZWR-Bk0_a-eE.js} +1 -1
  156. package/dist/public/assets/{chunk-LEVMRMFU-CKECy4cp.js → chunk-LEVMRMFU-DsFG_U8r.js} +1 -1
  157. package/dist/public/assets/{chunk-M57EVK23-DuZd8RGI.js → chunk-M57EVK23-BgeE81Y7.js} +1 -1
  158. package/dist/public/assets/{chunk-OY52VR5R-DatO2fu-.js → chunk-OY52VR5R-2Rp6C2LJ.js} +1 -1
  159. package/dist/public/assets/{chunk-QB3YPZ4I-11782Ox2.js → chunk-QB3YPZ4I-BhcIp-Bl.js} +1 -1
  160. package/dist/public/assets/{chunk-R3KSYZAL-CCTi2rHV.js → chunk-R3KSYZAL-i9n2AYPG.js} +1 -1
  161. package/dist/public/assets/{chunk-STOXU5M4-DU6EHCIH.js → chunk-STOXU5M4-DOSqSu65.js} +1 -1
  162. package/dist/public/assets/{chunk-TU62E6Q5-BtgGljqq.js → chunk-TU62E6Q5-BDA8bjy3.js} +1 -1
  163. package/dist/public/assets/{chunk-X4PVCEUW-Dd_Qy0Gx.js → chunk-X4PVCEUW-Cs-r9l_d.js} +1 -1
  164. package/dist/public/assets/{chunk-XXDRQBXY-DjOrWHxV.js → chunk-XXDRQBXY-DEcanQFC.js} +1 -1
  165. package/dist/public/assets/{classDiagram-v2-L25IHNXF-KfN1--CA.js → classDiagram-v2-L25IHNXF-BS8XxKRR.js} +1 -1
  166. package/dist/public/assets/{cose-bilkent-JH36ORCC-BuWVQ5UC.js → cose-bilkent-JH36ORCC--RPleOJ8.js} +1 -1
  167. package/dist/public/assets/cynefin-EF2NZ3EQ-CXQC7Jwi.js +1 -0
  168. package/dist/public/assets/{cynefinDiagram-L36ESFBY-BKljxAVP.js → cynefinDiagram-L36ESFBY-DZHM2oEU.js} +1 -1
  169. package/dist/public/assets/{d3-selection-CtCbiJ-r.js → d3-selection-D2iIEb1P.js} +1 -1
  170. package/dist/public/assets/{dagre-SPEB5RXH-nD3f86OL.js → dagre-SPEB5RXH-h_G5ukMB.js} +1 -1
  171. package/dist/public/assets/{diagram-3B7GL73J-wSVpHF4f.js → diagram-3B7GL73J-BnThWj9P.js} +1 -1
  172. package/dist/public/assets/{diagram-DNEMPZML-BOkeaSpr.js → diagram-DNEMPZML-DHCMo8sZ.js} +1 -1
  173. package/dist/public/assets/{diagram-L3MUGCDN-CRCErdiz.js → diagram-L3MUGCDN-DxJZnIKT.js} +1 -1
  174. package/dist/public/assets/{diagram-LA4NIPWU-y5kaOsii.js → diagram-LA4NIPWU-Cn0SGxqL.js} +1 -1
  175. package/dist/public/assets/{diagram-MHCOC4E2-D7l7ybij.js → diagram-MHCOC4E2-BafBOkBk.js} +1 -1
  176. package/dist/public/assets/{diagram-XPFHEONP-kHzV_Ibv.js → diagram-XPFHEONP-D7UnEMcU.js} +1 -1
  177. package/dist/public/assets/{dist-B-aKVhGg.js → dist-CN9JBoER.js} +1 -1
  178. package/dist/public/assets/{ebnfDiagram-UZSYDL2S-BX_-WdHG.js → ebnfDiagram-UZSYDL2S-Us1rkKwp.js} +1 -1
  179. package/dist/public/assets/{editor.api-Dwz0wCaW.js → editor.api-S_CuXudU.js} +1 -1
  180. package/dist/public/assets/{elk-XV6XMXQE-YaOVo5bZ.js → elk-XV6XMXQE-Czvqrn49.js} +1 -1
  181. package/dist/public/assets/{erDiagram-EYBAPDEH-BXQPjKDV.js → erDiagram-EYBAPDEH-C0g3K15f.js} +1 -1
  182. package/dist/public/assets/{eventmodeling-K75KTNOO-SiGVyftr.js → eventmodeling-K75KTNOO-DIcU7mQ5.js} +1 -1
  183. package/dist/public/assets/flowDiagram-MALGAFMO-D5Z_jzJ0.js +1 -0
  184. package/dist/public/assets/{freemarker2-DmbpSxx5.js → freemarker2-CkAEBjHO.js} +1 -1
  185. package/dist/public/assets/{ganttDiagram-23REXITY-B_i7AN7O.js → ganttDiagram-23REXITY-CIkKvihz.js} +1 -1
  186. package/dist/public/assets/gitGraph-VSP46ZUC-CvdLb7m6.js +1 -0
  187. package/dist/public/assets/{gitGraphDiagram-STJD7YCW-BMA1YavS.js → gitGraphDiagram-STJD7YCW-BxM3589j.js} +1 -1
  188. package/dist/public/assets/{handlebars-BVNKBeJT.js → handlebars-CPBNiVZ2.js} +1 -1
  189. package/dist/public/assets/{html-BHaxuuAl.js → html-CJBVALoy.js} +1 -1
  190. package/dist/public/assets/{index-DtU34jhH.js → index-CBMmE3BQ.js} +2 -2
  191. package/dist/public/assets/info-OHQRW6UA-BLs8wjUC.js +1 -0
  192. package/dist/public/assets/{infoDiagram-KBXO4MBG-BkNpfsDm.js → infoDiagram-KBXO4MBG-BIcStK_t.js} +1 -1
  193. package/dist/public/assets/{ishikawaDiagram-M35NCXHK-xTM6C-Kn.js → ishikawaDiagram-M35NCXHK-CpV2hKA6.js} +1 -1
  194. package/dist/public/assets/{javascript-C5dXKvxq.js → javascript-dv6GQsa3.js} +1 -1
  195. package/dist/public/assets/{journeyDiagram-OPLOXDXO-C6iaT7vL.js → journeyDiagram-OPLOXDXO-B_vnmdId.js} +1 -1
  196. package/dist/public/assets/{jsonMode-Ia_aRv-z.js → jsonMode-DG_orhvz.js} +1 -1
  197. package/dist/public/assets/{kanban-definition-BZKZHSQY-MobAdBhz.js → kanban-definition-BZKZHSQY-q5uWw99H.js} +1 -1
  198. package/dist/public/assets/{liquid-CIbIBxiN.js → liquid-CD-LM2Kh.js} +1 -1
  199. package/dist/public/assets/{mdx-BqruHcEe.js → mdx-C9mfI8up.js} +1 -1
  200. package/dist/public/assets/{mermaid-parser.core-kBQmxOUn.js → mermaid-parser.core-DNe1duhT.js} +3 -3
  201. package/dist/public/assets/{mermaid.core-BFkQwIYu.js → mermaid.core-B1AcqJgl.js} +4 -4
  202. package/dist/public/assets/{mindmap-definition-I2QAS2VK-DxpTmvUG.js → mindmap-definition-I2QAS2VK-CwYG3Fl3.js} +1 -1
  203. package/dist/public/assets/module-BLLqRvli.js +1099 -0
  204. package/dist/public/assets/module-BZPCnGxA.js +1 -0
  205. package/dist/public/assets/{monaco-BRwac88s.js → monaco-C0ktZo3r.js} +3 -3
  206. package/dist/public/assets/packet-JDAUHWVQ-jwWITUaQ.js +1 -0
  207. package/dist/public/assets/{pegDiagram-FD4XPPHP-B3bIVo4u.js → pegDiagram-FD4XPPHP-DxtA4QDS.js} +1 -1
  208. package/dist/public/assets/pie-XZMESJXO-CeTVZZgy.js +1 -0
  209. package/dist/public/assets/{pieDiagram-J4AKIIQI-CgnbwU0I.js → pieDiagram-J4AKIIQI-CfcIi0Vn.js} +1 -1
  210. package/dist/public/assets/{python-Cwjb3hEe.js → python-DCA1j2QE.js} +1 -1
  211. package/dist/public/assets/{quadrantDiagram-XTYBLID2-DWx4wRau.js → quadrantDiagram-XTYBLID2-BxkJdurF.js} +1 -1
  212. package/dist/public/assets/radar-ABXABTNO-BGI8J8LU.js +1 -0
  213. package/dist/public/assets/railroad-I3PHUGI6-CFkpx3Pr.js +1 -0
  214. package/dist/public/assets/{railroad-abnf-LNEFI6M7-CyjF4cc_.js → railroad-abnf-LNEFI6M7--H3g5ywg.js} +1 -1
  215. package/dist/public/assets/{railroad-ebnf-DWYD2UWJ-D2ypsr5c.js → railroad-ebnf-DWYD2UWJ-C2LAUFu6.js} +1 -1
  216. package/dist/public/assets/{railroad-peg-JR7BVNR7-Cy6Mde1c.js → railroad-peg-JR7BVNR7-Kq_ZXQMl.js} +1 -1
  217. package/dist/public/assets/{railroadDiagram-MRQ6NCDL-B6ya_k_l.js → railroadDiagram-MRQ6NCDL-i4xIvHJV.js} +1 -1
  218. package/dist/public/assets/{razor-D_ClW9Lh.js → razor-CEeNaFx5.js} +1 -1
  219. package/dist/public/assets/{requirementDiagram-Y7LWUY3S-Brg8B8VS.js → requirementDiagram-Y7LWUY3S-CYNXjuJm.js} +1 -1
  220. package/dist/public/assets/{sankeyDiagram-WGJFYUXA-DbzPDfky.js → sankeyDiagram-WGJFYUXA-CRQiHcW6.js} +1 -1
  221. package/dist/public/assets/{sequenceDiagram-5NDRBG5M-BuN84drT.js → sequenceDiagram-5NDRBG5M-BSDVFsi2.js} +1 -1
  222. package/dist/public/assets/{stateDiagram-v2-FJ4FJNEA-C_CTpHMj.js → stateDiagram-v2-FJ4FJNEA-uyUAaysl.js} +1 -1
  223. package/dist/public/assets/{swimlanes-UMQ2AFYF-BvD4v9jw.js → swimlanes-UMQ2AFYF-DdEjQumY.js} +1 -1
  224. package/dist/public/assets/swimlanesDiagram-OMPLPG4O-BJsun6CT.js +8 -0
  225. package/dist/public/assets/{timeline-definition-SEUHKTQE-VE2xWGk8.js → timeline-definition-SEUHKTQE-DZl-TXXh.js} +1 -1
  226. package/dist/public/assets/treeView-D4JQ5SDB-CL1mG6td.js +1 -0
  227. package/dist/public/assets/treemap-SAJKECNS-Bk3Z1uEC.js +1 -0
  228. package/dist/public/assets/{typescript-upeNz2VW.js → typescript-DrF8YGbQ.js} +1 -1
  229. package/dist/public/assets/{usecaseDiagram-AFA6YXN4-ZtyyvKye.js → usecaseDiagram-AFA6YXN4-DkG3gLrp.js} +1 -1
  230. package/dist/public/assets/{vennDiagram-NNMJR3RB-BTEvzrNd.js → vennDiagram-NNMJR3RB-B_lj8x7-.js} +1 -1
  231. package/dist/public/assets/wardley-7MLQ67FV-1E8i3qpD.js +1 -0
  232. package/dist/public/assets/{wardleyDiagram-S7YFUSEH-CF8wIUhx.js → wardleyDiagram-S7YFUSEH-B1VFrC5a.js} +1 -1
  233. package/dist/public/assets/{xml-Cki0HxGb.js → xml-DfL-Brke.js} +1 -1
  234. package/dist/public/assets/{xychartDiagram-GGNKY7IX-DcDpoJ4n.js → xychartDiagram-GGNKY7IX-CM2CpXu9.js} +1 -1
  235. package/dist/public/assets/{yaml-YIY66l1U.js → yaml-CpmxRjjF.js} +1 -1
  236. package/dist/public/index.html +21 -3
  237. package/dist/serve/index.mjs +2251 -656
  238. package/package.json +18 -17
  239. package/dist/public/assets/cynefin-EF2NZ3EQ-D_GZWaFs.js +0 -1
  240. package/dist/public/assets/flowDiagram-MALGAFMO-BHpEyQnS.js +0 -1
  241. package/dist/public/assets/gitGraph-VSP46ZUC-CSv9x0vY.js +0 -1
  242. package/dist/public/assets/info-OHQRW6UA-Bx2U6fFU.js +0 -1
  243. package/dist/public/assets/module-C1y_4M09.js +0 -1061
  244. package/dist/public/assets/module-DYWqfyIP.js +0 -1
  245. package/dist/public/assets/packet-JDAUHWVQ-Dy7GyfNz.js +0 -1
  246. package/dist/public/assets/pie-XZMESJXO-B4D2CjUH.js +0 -1
  247. package/dist/public/assets/radar-ABXABTNO-Dtf3tObc.js +0 -1
  248. package/dist/public/assets/railroad-I3PHUGI6-DKGa9xBx.js +0 -1
  249. package/dist/public/assets/swimlanesDiagram-OMPLPG4O-CMvLg13v.js +0 -8
  250. package/dist/public/assets/treeView-D4JQ5SDB-ETecwv1j.js +0 -1
  251. package/dist/public/assets/treemap-SAJKECNS-er6ceAYK.js +0 -1
  252. package/dist/public/assets/wardley-7MLQ67FV-CzrxsjBc.js +0 -1
@@ -1 +1 @@
1
- import{t as e}from"./chunk-KS47KZWR-BbUyxMWY.js";import{r as t}from"./chunk-KQLB2F66-C3Z8V8R_.js";import"./chunk-M57EVK23-DuZd8RGI.js";import"./chunk-DQASFODM-DPHr08r0.js";import"./chunk-LEVMRMFU-CKECy4cp.js";import"./chunk-AXFCVDMN-g4Y7Pg2t.js";import"./chunk-X4PVCEUW-Dd_Qy0Gx.js";import"./chunk-STOXU5M4-DU6EHCIH.js";import"./chunk-R3KSYZAL-CCTi2rHV.js";import"./chunk-6MUBBAK2-Cnx7dsB1.js";import"./chunk-BG4553SI-QNE6A_Vg.js";import{n}from"./d3-selection-CtCbiJ-r.js";import{n as r}from"./chunk-Y2CYZVJY-DsF7k-Jl.js";function i(t,{measure:n}){let r=t.config?.swimlane?.lineHops;if(r===!1)return;let i=r===`gap`?`gap`:`arc`,a=t.edges.filter(e=>Array.isArray(e.points)&&e.points.length>=2).map(e=>({id:e.id,points:e.points,curve:e.curve,arrowTypeStart:e.arrowTypeStart,arrowTypeEnd:e.arrowTypeEnd}));e(n.groups.edgePaths,a,{enabled:!0,jumpRadius:6,jumpStyle:i})}r(i,`applySwimlaneLineJumps`);function a(e){let t=e?.metadata?.laneRole;return t===`pool`||t===`lane`?t:void 0}r(a,`readLaneRole`);function o(e){let t=e?.metadata?.laneIndex;return typeof t==`number`&&Number.isFinite(t)?t:void 0}r(o,`readLaneIndex`);function s(e){let t=new Map,n=new Map;for(let r of e)t.set(r.id,r),r.isGroup&&r.parentId&&n.set(r.parentId,(n.get(r.parentId)??0)+1);let i=new Set;for(let t of e)t.isGroup&&a(t)===`pool`&&(n.get(t.id)??0)>0&&i.add(t.id);let o=new Set,s=new Map;for(let t of e)if(t.isGroup&&!i.has(t.id)){if(t.parentId&&i.has(t.parentId)){o.add(t.id);let e=s.get(t.parentId)??[];e.push(t.id),s.set(t.parentId,e)}else t.parentId||o.add(t.id)}let c=r((e,n)=>{let r=new Set([e]),i=t.get(e)?.parentId;for(;i&&!r.has(i);){if(n.has(i))return i;r.add(i),i=t.get(i)?.parentId}return null},`walk`),l=new Map;return{isPool:r(e=>i.has(e),`isPool`),isLane:r(e=>o.has(e),`isLane`),laneIdOf:r(e=>{let t=l.get(e);if(t!==void 0)return t;let n=c(e,o);return l.set(e,n),n},`laneIdOf`),poolIdOf:r(e=>i.has(e)?e:c(e,i),`poolIdOf`),lanesByPool:s,hasPools:i.size>0}}r(s,`buildLaneModel`);var c=new Set([`top`,`right`,`bottom`,`left`]),l=8,u=1e4;function d(e){let t=e?.metadata?.anchorTo;if(!t||typeof t!=`object`)return;let{hostId:n,side:r,slot:i,gap:a}=t;if(typeof n==`string`&&n.length!==0&&n!==e?.id)return{hostId:n,...typeof r==`string`&&c.has(r)?{side:r}:{},...typeof i==`number`&&Number.isFinite(i)?{slot:i}:{},...typeof a==`number`&&Number.isFinite(a)&&a>0?{gap:Math.min(a,u)}:{}}}r(d,`readAnchor`);function f(e,t){let n=new Set([e]),r=d(t.get(e))?.hostId;for(;r&&!n.has(r);){let e=t.get(r);if(!e)return;let i=d(e)?.hostId;if(!i)return r;n.add(r),r=i}}r(f,`resolveAnchorHostId`);function p(e){let t=new Map(e.map(e=>[e.id,e])),n=new Set;for(let r of e)d(r)&&f(r.id,t)&&n.add(r.id);return n}r(p,`collectAnchoredIds`);function m(e,t){return e===`canonical`?`right`:t===`LR`||t===`RL`?`bottom`:`right`}r(m,`defaultAnchorSide`);function h(e,t){let n=e.anchor.slot,r=t.anchor.slot;return n!==void 0&&r!==void 0&&n!==r?n-r:n!==void 0&&r===void 0?-1:n===void 0&&r!==void 0?1:e.index-t.index}r(h,`compareBucketEntries`);function g(e){let t=e.reduce((e,t)=>e+t,0)+l*Math.max(0,e.length-1),n=[],r=-t/2;for(let t of e)n.push(r+t/2),r+=t+l;return{offsets:n,total:t}}r(g,`packAlongBorder`);var _=r(e=>[e.width,e.height].every(e=>e===void 0||Number.isFinite(e)),`hasUsableSize`);function v(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Map;e.forEach((e,i)=>{let a=d(e);if(!a||!_(e))return;let o=f(e.id,n);if(!o)return;let s=t(a),c=`${s}:${o}`,l=r.get(c)??[];l.push({node:e,anchor:a,index:i,side:s,hostId:o}),r.set(c,l)});for(let e of r.values())e.sort(h);return r}r(v,`bucketByHostAndSide`);function y(e,t,n,r){return e+(!t&&n>0?-(r+l):0)}r(y,`centreAlongBorder`);function b(e,t){let n=t===`top`||t===`bottom`,i=r(e=>n?e.width??0:e.height??0,`alongBorder`),a=r(e=>n?e.height??0:e.width??0,`reach`),{offsets:o}=g(e.map(e=>i(e.node))),s=0,c=0,l=0;return e.forEach((e,t)=>{let r=e.anchor.gap??0,u=i(e.node)/2,d=y(o[t],n,r,u);s=Math.max(s,u-d),c=Math.max(c,d+u),l=Math.max(l,r>0?r+a(e.node):0)}),{before:s,after:c,beyond:l}}r(b,`footprintOf`);function x(e,t){let n=m(`final`,t??`TB`),r=new Map;for(let t of v(e,e=>e.side??n).values()){if(!t.some(e=>e.anchor.gap))continue;let{hostId:e,side:n}=t[0];r.set(e,{...r.get(e),[n]:b(t,n)})}return r}r(x,`anchorFootprints`);var S=`__swimlane_default__`,C=21,w=20;function T(e){return Math.max(e.padding??w,w)}r(T,`topLaneHorizontalPadding`);function E(e){let{x:t,y:n,width:r,height:i}=e,a=e.swimlaneContentTop;if(typeof t!=`number`||typeof n!=`number`||typeof r!=`number`||typeof i!=`number`||typeof a!=`number`||!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(i)||!Number.isFinite(a)||r<=0||i<=0){delete e.groupTitleRect;return}let o=n-i/2,s=Math.min(a,n+i/2),c=o+Math.min(C,Math.max(0,s-o));c<=o?delete e.groupTitleRect:e.groupTitleRect={left:t-r/2,right:t+r/2,top:o,bottom:c}}r(E,`assignTopLaneTitleRect`);function D(e){let t=e.other?.droppedSubGraphMembers;return Array.isArray(t)?t:[]}r(D,`sharedMembers`);var O=r((e,t,n)=>!t.some(e=>e.parentId===n)&&!(e.edges??[]).some(e=>e.start===n||e.end===n),`isEmptyLane`);function k(e,t){return e.isLane(t)?t:e.laneIdOf(t)??void 0}r(k,`laneIdOrSelf`);function ee(e,t,n){for(let r of n){let n=t.findIndex(e=>e.id===r);n>=0&&O(e,t,r)&&t.splice(n,1)}}r(ee,`removeEmptyLanes`);function A(e,t){let r=s(t),i=new Set(t.filter(e=>r.isLane(e.id)).map(e=>e.id)),a=new Set;for(let{node:t,keptBy:o,droppedFrom:s}of D(e)){let e=k(r,o);e&&e!==s&&i.has(s)&&(n.warn(`Swimlane node "${t}" is listed in lanes "${e}" and "${s}"; it is drawn in "${e}" only.`),a.add(s))}ee(e,t,a)}r(A,`dropLanesEmptiedBySharedNodes`);function j(e,t){for(let r of e)r.isGroup&&!t.isLane(r.id)&&!t.isPool(r.id)&&n.warn(`Swimlane subgraph "${r.id}" is nested in "${r.parentId}"; only top-level subgraphs are lanes, so it is drawn as a plain box.`)}r(j,`warnAboutNestedGroups`);function M(e){let t=e.direction,n=e.nodes??=[];A(e,n);let r=s(n);j(n,r);for(let e of n){let n=r.isLane(e.id);(n||r.isPool(e.id))&&(e.shape=n?`swimlane`:`pool`,t&&(e.direction=t))}let i=n.filter(e=>!e.isGroup&&!e.parentId);if(i.length===0)return;let a=n.find(e=>e.id===S);a?a.isGroup&&(a.shape=`swimlane`,t&&(a.direction=t)):(a={id:S,label:``,isGroup:!0,shape:`swimlane`,padding:20,look:e.config?.look,colorIndex:n.reduce((e,t)=>Math.max(e,t.colorIndex??-1),-1)+1,...t?{direction:t}:{}},n.push(a));for(let e of i)e.parentId=S}r(M,`prepareLayoutForSwimlanes`);function N(e){let t=(e.nodes??[]).filter(e=>!e.isEdgeLabel),n=new Map(t.map(e=>[e.id,e])),i=p(t),a=r(e=>i.has(e)?f(e,n)??e:e,`hostOf`),o=new Map;for(let e of t)i.has(e.id)||o.set(e.id,e);let s=[];for(let t of e.edges??[]){let e=typeof t.start==`string`?t.start:void 0,n=typeof t.end==`string`?t.end:void 0;if(!e||!n||t.isLayoutOnly)continue;let r=a(e),i=a(n);r!==i&&s.push({id:t.id,src:r,dst:i,ref:t})}let c=t.filter(e=>e.isGroup&&!i.has(e.id)),l=t.filter(e=>!e.isGroup&&!i.has(e.id));return{nodes:[...[...c].reverse(),...l].map(e=>e.id),edges:s,layout:e,nodeById:o}}r(N,`toGraphView`);function P(e){let t=new Map(e.map(e=>[e.id,e])),n=r(e=>{let n=0,r=e.parentId,i=new Set([e.id]);for(;r!=null&&!i.has(r);)i.add(r),n++,r=t.get(r)?.parentId;return n},`depthOf`);return e.filter(e=>e?.isGroup).map(e=>({node:e,depth:n(e)})).sort((e,t)=>t.depth-e.depth).map(e=>e.node)}r(P,`groupsDeepestFirst`);function te(e,t,n,r){let{layout:i}=e,a=e.nodeById,o=r?.layerGap??100,c=r?.nodeGap??40,l=0;for(let e of t.layers){let t=0;for(let r of e){let e=a.get(r);if(!e){t++;continue}e.layer=l,e.order=t;let i=n.x[r]??t*c,s=n.y[r]??l*o;e.x=i,e.y=s,t++}l++}let u=i.nodes??[],d=p(u);for(let e of u)e.isEdgeLabel&&n.x[e.id]!=null&&n.y[e.id]!=null&&(e.x=n.x[e.id],e.y=n.y[e.id]);let f=new Map,m=s(u),h=[];for(let e of P(u)){m.isLane(e.id)&&h.push(e);let t=u.filter(t=>t.parentId===e.id&&!d.has(t.id)),r=1/0,i=-1/0,a=1/0,o=-1/0;for(let e of t){let t=e.x??n.x[e.id],s=e.y??n.y[e.id],c=e.width??0,l=e.height??0;t!=null&&s!=null&&(e.isEdgeLabel||(r=Math.min(r,t-c/2),i=Math.max(i,t+c/2)),a=Math.min(a,s-l/2),o=Math.max(o,s+l/2))}if(r===1/0||a===1/0)e.x=e.x??0,e.y=e.y??0,e.width=e.width??0,e.height=e.height??0;else{let t=e.padding??20,n=e.parentId?t:2*T(e),s=t,c=Math.max(0,i-r)+n,l=Math.max(0,o-a)+s,u=(r+i)/2,d=(a+o)/2;e.x=u,e.y=d,e.width=c,e.height=l,f.set(e.id,{minX:r,maxX:i,minY:a,maxY:o})}}if(h.length>0&&f.size>0){let e=1/0,t=-1/0,n=0;for(let r of h){let i=r.padding??20;i>n&&(n=i);let a=f.get(r.id);a&&(e=Math.min(e,a.minY),t=Math.max(t,a.maxY))}if(e!==1/0&&t!==-1/0){let r=Math.max(0,t-e)+2*Math.max(n,36),i=(e+t)/2;for(let t of h)t.y=i,t.height=r,t.swimlaneContentTop=e;let a=[...h].sort((e,t)=>(e.x??0)-(t.x??0)),o=[],s=[],c=[];for(let e of a){let t=f.get(e.id);if(!t)continue;let n=Math.max(0,t.maxX-t.minX)+2*T(e),r=(t.minX+t.maxX)/2;o.push(e.id),s.push(r),c.push(n)}let l=o.length;if(l>0){let e=new Map;if(l===1)e.set(o[0],c[0]);else{let t=[];for(let e=0;e<l-1;e++)t.push(s[e+1]-s[e]);let n=Array(l);n[0]=0;for(let e=0;e<l-1;e++)n[e+1]=2*t[e]-n[e];let r=0,i=1/0;for(let e=0;e<l;e++){let t=c[e];e%2==0?r=Math.max(r,t-n[e]):i=Math.min(i,n[e]-t)}let a=r;a=r<=i?(r+i)/2:r;for(let t=0;t<l;t++){let r=n[t]+(t%2==0?a:-a),i=Math.max(c[t],r);e.set(o[t],i)}}for(let t of h){let n=e.get(t.id);n!=null&&(t.width=n),E(t)}}}}}r(te,`writeBackToLayoutData`);var ne=`[EdgeLabelNodes]`;function re(e){let t=[],r=[],i=new Map;for(let t of e.nodes)i.set(t.id,t);for(let a of e.edges){if(!a.label||a.label.length===0||a.isLayoutOnly||a.labelNodeId)continue;let e=a.start?i.get(a.start):void 0,o=a.end?i.get(a.end):void 0;if(!e||!o){n.warn(ne,`Edge ${a.id} has missing source or target node`);continue}let s=`edge-label-${a.start}-${a.end}-${a.id}`,c=e.parentId===o.parentId?e.parentId:o.parentId,l={id:s,label:a.label,edgeStart:a.start??``,edgeEnd:a.end??``,shape:`labelRect`,width:0,height:0,isEdgeLabel:!0,isDummy:!0,parentId:c,isGroup:!1,labelStyle:Array.isArray(a.labelStyle)?a.labelStyle[0]:a.labelStyle??``,...e.dir?{dir:e.dir}:{}};t.push(l),a.labelNodeId=s,a.label=void 0,a.text=void 0;let u={id:`${a.id}-to-label`,start:a.start,end:s,type:`normal`,isLayoutOnly:!0},d={id:`${a.id}-from-label`,start:s,end:a.end,type:`normal`,isLayoutOnly:!0};r.push(u,d)}let a=[...e.nodes,...t],o=[...e.edges,...r];return{...e,nodes:a,edges:o}}r(re,`createEdgeLabelNodes`);var F=.001;function ie(e){let t=e.x??0,n=e.y??0,r=e.width??0,i=e.height??0;return r>0&&i>0?{cx:t,cy:n,rect:me(t,n,r,i)}:void 0}r(ie,`measuredNodeRect`);function ae(e){if(e.isGroup)return;let t=ie(e);if(t)return{id:String(e.id??``),cx:t.cx,cy:t.cy,rect:t.rect}}r(ae,`nodeBoundsInfoFor`);function I(e,t,n=F){return Math.abs(e.x-t.x)<n&&Math.abs(e.y-t.y)<n}r(I,`samePoint`);function L(e,t,n=F){return Math.abs(e.x-t.x)<n}r(L,`sameX`);function R(e,t,n=F){return Math.abs(e.y-t.y)<n}r(R,`sameY`);function z(e,t,n=F){return R(e,t,n)&&Math.abs(e.x-t.x)>n}r(z,`isHorizontalSegment`);function B(e,t,n=F){return L(e,t,n)&&Math.abs(e.y-t.y)>n}r(B,`isVerticalSegment`);function V(e,t,n,r){return Math.max(0,Math.min(Math.max(e,t),Math.max(n,r))-Math.max(Math.min(e,t),Math.min(n,r)))}r(V,`overlapLength`);function H(e,t,n=F){return e.horizontal&&t.horizontal&&R(e.a,t.a,n)?V(e.a.x,e.b.x,t.a.x,t.b.x):e.vertical&&t.vertical&&L(e.a,t.a,n)?V(e.a.y,e.b.y,t.a.y,t.b.y):0}r(H,`sameAxisSegmentOverlapLength`);function U(e,t=F){let n=[];for(let r=0;r<e.length-1;r++){let i=e[r],a=e[r+1],o=z(i,a,t),s=B(i,a,t);(o||s)&&n.push({index:r,a:i,b:a,horizontal:o,vertical:s})}return n}r(U,`orthogonalSegmentsForPoints`);function W(e,t=F){let n=U(e,t),r=0;for(let e=1;e<n.length;e++)n[e-1].horizontal!==n[e].horizontal&&r++;return r}r(W,`countOrthogonalBends`);function oe(e){let t=U(G(e));return t.slice(1).flatMap((e,n)=>t[n].horizontal===e.horizontal?[]:[e.a])}r(oe,`bendPoints`);function se(e,t){let n=Math.max(Math.min(t.a.x,t.b.x)-e.x,0,e.x-Math.max(t.a.x,t.b.x)),r=Math.max(Math.min(t.a.y,t.b.y)-e.y,0,e.y-Math.max(t.a.y,t.b.y));return Math.hypot(n,r)}r(se,`distanceToSegment`);function ce(e,t,n){let i=r((e,t)=>{let r=U(G(t));return oe(e).some(e=>r.some(t=>se(e,t)<n))},`touches`);return i(e,t)||i(t,e)}r(ce,`routesTouchAtBend`);function G(e,t=F){let n=[];for(let r of e){let e=n.length>0?n[n.length-1]:void 0;e&&I(e,r,t)||n.push({x:r.x,y:r.y})}return n}r(G,`dedupeConsecutivePoints`);function le(e,t=F){if(!e||e.length!==4)return;let[n,r,i,a]=e;return z(n,r,t)&&B(r,i,t)&&z(i,a,t)?{kind:`HVH`,p0:n,p1:r,p2:i,p3:a}:B(n,r,t)&&z(r,i,t)&&B(i,a,t)?{kind:`VHV`,p0:n,p1:r,p2:i,p3:a}:void 0}r(le,`classifyThreeSegmentRoute`);function ue(e,t,n,r=0){let i=Math.min(e.x,t.x),a=Math.max(e.x,t.x),o=Math.min(e.y,t.y),s=Math.max(e.y,t.y);return a>n.left-r&&i<n.right+r&&s>n.top-r&&o<n.bottom+r}r(ue,`segmentBoundsOverlapRect`);function de(e,t,n=0){return e.x>t.left+n&&e.x<t.right-n&&e.y>t.top+n&&e.y<t.bottom-n}r(de,`pointInsideRect`);function fe(e,t){return e.left<=t.left&&e.right>=t.right&&e.top<=t.top&&e.bottom>=t.bottom}r(fe,`rectContainsRect`);function K(e,t){return e.left<t.right&&e.right>t.left&&e.top<t.bottom&&e.bottom>t.top}r(K,`rectsOverlap`);function pe(e,t){return{left:e.left-t,right:e.right+t,top:e.top-t,bottom:e.bottom+t}}r(pe,`inflateRect`);function me(e,t,n,r){return{left:e-n/2,right:e+n/2,top:t-r/2,bottom:t+r/2}}r(me,`rectFromCenterSize`);function q(e){return ie(e)?.rect}r(q,`rectOfNodeBounds`);function he(e,t){switch(t){case`top`:return{x:e.cx,y:e.rect.top};case`bottom`:return{x:e.cx,y:e.rect.bottom};case`left`:return{x:e.rect.left,y:e.cy};case`right`:return{x:e.rect.right,y:e.cy}}}r(he,`portForRectSide`);function ge(e,t,n,r,i,a=F){let o=t===`left`||t===`right`,s=r===`left`||r===`right`;if(o&&s){if(t===`right`&&r===`left`&&e.x<n.x||t===`left`&&r===`right`&&e.x>n.x){if(R(e,n,a))return[e,n];let t=(e.x+n.x)/2;return[e,{x:t,y:e.y},{x:t,y:n.y},n]}if(t===r){if(R(e,n,a))return;let r=t===`left`?Math.min(e.x,n.x)-i:Math.max(e.x,n.x)+i;return[e,{x:r,y:e.y},{x:r,y:n.y},n]}return}if(!o&&!s){if(t===r){if(L(e,n,a))return;let r=t===`top`?Math.min(e.y,n.y)-i:Math.max(e.y,n.y)+i;return[e,{x:e.x,y:r},{x:n.x,y:r},n]}if(!(t===`bottom`&&r===`top`&&e.y<n.y||t===`top`&&r===`bottom`&&e.y>n.y))return;if(L(e,n,a))return[e,n];let o=(e.y+n.y)/2;return[e,{x:e.x,y:o},{x:n.x,y:o},n]}if(o&&!s){let i=t===`right`&&n.x>e.x||t===`left`&&n.x<e.x,a=r===`top`&&e.y<n.y||r===`bottom`&&e.y>n.y;return i&&a?[e,{x:n.x,y:e.y},n]:void 0}let c=t===`bottom`&&n.y>e.y||t===`top`&&n.y<e.y,l=r===`left`&&e.x<n.x||r===`right`&&e.x>n.x;return c&&l?[e,{x:e.x,y:n.y},n]:void 0}r(ge,`buildOrthogonalPortPath`);function _e(e,t,n,r){return t===`left`||t===`right`?[e,{x:r,y:e.y},{x:r,y:n.y},n]:[e,{x:e.x,y:r},{x:n.x,y:r},n]}r(_e,`buildSameSideTrackPath`);function ve(e){let t=new Map,n=[];for(let r of e){if(r.isEdgeLabel)continue;let e=ae(r);e&&(t.set(e.id,e),n.push({id:e.id,rect:e.rect}))}return{nodeInfoById:t,realNodeRects:n}}r(ve,`collectRealNodeBounds`);function ye(e){let t=[],n=[];for(let r of e){let e=ae(r);if(!e)continue;let i={id:e.id,rect:e.rect};r.isEdgeLabel?n.push(i):t.push(i)}return{realNodeRects:t,labelNodeRects:n}}r(ye,`collectNodeRectEntries`);function be(e,{includeEdgeLabels:t=!0}={}){let n=[];for(let r of e){if(r.isGroup||!t&&r.isEdgeLabel)continue;let e=r.x??0,i=r.y??0,a=r.width??0,o=r.height??0;n.push({nodeId:r.id,...me(e,i,a,o)})}return n}r(be,`collectLayoutNodeRects`);function xe(e,t,n=F){let r=e.start,i=e.end;if(!r||!i)return;let a=t.get(r),o=t.get(i);if(a&&o)return{srcId:r,dstId:i,srcInfo:a,dstInfo:o,collinearX:Math.abs(a.cx-o.cx)<n,collinearY:Math.abs(a.cy-o.cy)<n}}r(xe,`getNodePairGeometry`);function J(e,t,n,r=[],i=0){for(let a of n)if(!r.includes(a.id)&&ue(e,t,a.rect,-i))return!0;return!1}r(J,`segmentHitsAnyRect`);function Se(e,t,n,r,i=F,a=1e-6){let o=R(e,t,i),s=L(e,t,i),c=R(n,r,i),l=L(n,r,i);if(o&&c||s&&l||!(o||s)||!(c||l))return!1;let u=o?{a:e,b:t}:{a:n,b:r},d=s?{a:e,b:t}:{a:n,b:r},f=u.a.y,p=Math.min(u.a.x,u.b.x),m=Math.max(u.a.x,u.b.x),h=d.a.x,g=Math.min(d.a.y,d.b.y),_=Math.max(d.a.y,d.b.y);if(h<p||h>m||f<g||f>_)return!1;let v=Math.abs(h-u.a.x)<a&&Math.abs(f-u.a.y)<a||Math.abs(h-u.b.x)<a&&Math.abs(f-u.b.y)<a,y=Math.abs(h-d.a.x)<a&&Math.abs(f-d.a.y)<a||Math.abs(h-d.b.x)<a&&Math.abs(f-d.b.y)<a;return!(v&&y)}r(Se,`orthogonalSegmentsCross`);function Ce(e,t,n,r,i=F){let a=R(e,t,i),o=L(e,t,i),s=R(n,r,i),c=L(n,r,i);return o&&c&&L(e,n,i)?V(e.y,t.y,n.y,r.y)>i:a&&s&&R(e,n,i)?V(e.x,t.x,n.x,r.x)>i:!1}r(Ce,`sameAxisSegmentsOverlap`);function we(e,t,n,r,{epsilon:i=F,skipDegenerateOther:a=!1}={}){for(let o of n){if(o===r||o.isLayoutOnly)continue;let n=o.points;if(!(!n||n.length<2))for(let r=0;r<n.length-1;r++){let o=n[r],s=n[r+1];if(!(a&&I(o,s,i))&&(Se(e,t,o,s,i)||Ce(e,t,o,s,i)))return!0}}return!1}r(we,`segmentConflictsWithAnyEdge`);function Te(e,t,n,r,i=F){let a=R(e,t,i),o=L(e,t,i),s=R(n,r,i),c=L(n,r,i);if(!(a&&c||o&&s))return!1;let l=a?{a:e,b:t}:{a:n,b:r},u=a?{a:n,b:r}:{a:e,b:t},d=l.a.y,f=Math.min(l.a.x,l.b.x),p=Math.max(l.a.x,l.b.x),m=u.a.x,h=Math.min(u.a.y,u.b.y),g=Math.max(u.a.y,u.b.y);return m>f+i&&m<p-i&&d>h+i&&d<g-i}r(Te,`orthogonalSegmentsStrictlyCross`);function Ee(e,t,n){let r=Math.min(t,n),i=Math.max(t,n);return e>r+F&&e<i-F}r(Ee,`strictlyBetween`);function De(e,t,n){return L(e,t)&&L(t,n)?Ee(t.y,e.y,n.y):R(e,t)&&R(t,n)?Ee(t.x,e.x,n.x):!1}r(De,`isCollinearIntermediate`);function Oe(e){let t=!1,n=[];for(let r=0;r<e.length;r++){let i=n[n.length-1],a=e[r],o=r+1<e.length?e[r+1]:void 0;if(i&&o){if(I(i,o)){r++,t=!0;continue}if(De(i,a,o)){t=!0;continue}}n.push(a)}return{points:n,changed:t}}r(Oe,`simplifyPolylineOnce`);function ke(e){let t=[e[0]];for(let n=1;n<e.length;n++){let r=t[t.length-1],i=e[n];if(!L(r,i)&&!R(r,i)){let e=t.length>=2?t[t.length-2]:void 0,n=e&&L(e,r)?{x:r.x,y:i.y}:{x:i.x,y:r.y};t.push(n)}t.push(i)}let n=[];for(let e of t){let t=n[n.length-1];t&&I(t,e)||n.push(e)}return n}r(ke,`orthogonalizePolyline`);function Ae(e){if(e.length<3)return e;let t=[...e];for(let e=0;e<32;e++){let e=Oe(t);if(t=e.points,!e.changed)break}return t}r(Ae,`simplifyPolyline`);var Y=.001,je=.5,Me=4;function Ne(e,t,n){let r=e;if(r.isLayoutOnly||!r.points||r.points.length<n)return;let i=r.start?t.get(r.start):void 0,a=r.end?t.get(r.end):void 0;return{edge:r,points:r.points,srcRect:i?q(i):void 0,dstRect:a?q(a):void 0}}r(Ne,`endpointContextFor`);function Pe(e,t,n){if(R(e,t,Y))return{x:e.x<n.left?n.left:n.right,y:e.y};if(L(e,t,Y)){let t=e.y<n.top?n.top:n.bottom;return{x:e.x,y:t}}return{x:Math.min(n.right,Math.max(n.left,e.x)),y:Math.min(n.bottom,Math.max(n.top,e.y))}}r(Pe,`segmentEnterPoint`);function Fe(e,t,n){let r=n?1:-1,i=n?0:e.length-1;for(;i>=0&&i<e.length&&de(e[i],t,je);)i+=r;if(i<0||i>=e.length)return e;let a=i-r;if(a<0||a>=e.length)return e;let o=Pe(e[i],e[a],t);return n?[o,...e.slice(i)]:[...e.slice(0,i+1),o]}r(Fe,`clipEndpoint`);function Ie(e,t){for(let n of e){let e=Ne(n,t,2);if(!e)continue;let r=[...e.points];e.srcRect&&(r=Fe(r,e.srcRect,!0)),e.dstRect&&(r=Fe(r,e.dstRect,!1)),r=Ae(ke(r)),r=qe(r,e.srcRect,e.dstRect),e.edge.points=Ae(ke(r))}}r(Ie,`clipEdgeEndpointsToNodeBoundaries`);function Le(e,t,n,r=!1){if(R(e,t,Y)){if(t.y<n.top-Y||t.y>n.bottom+Y)return t;if(r){if(e.x<n.left-Y)return{x:n.left,y:e.y};if(e.x>n.right+Y)return{x:n.right,y:e.y}}return{x:Math.abs(t.x-n.left)<=Math.abs(t.x-n.right)?n.left:n.right,y:e.y}}if(L(e,t,Y)){if(t.x<n.left-Y||t.x>n.right+Y)return t;if(r){if(e.y<n.top-Y)return{x:e.x,y:n.top};if(e.y>n.bottom+Y)return{x:e.x,y:n.bottom}}let i=Math.abs(t.y-n.top)<=Math.abs(t.y-n.bottom);return{x:e.x,y:i?n.top:n.bottom}}return t}r(Le,`snapEndpointToBoundary`);function Re(e,t,n){let r=e[t];for(let i=t+n;i>=0&&i<e.length;i+=n){let t=e[i];if(!I(t,r,Y))return t}return e[t+n]}r(Re,`firstDistinctAdjacent`);function ze(e,t){let n=e+Me,r=t-Me;return n<=r?{lo:n,hi:r}:{lo:(e+t)/2,hi:(e+t)/2}}r(ze,`cornerClearanceRange`);function Be(e,t,n){let{lo:r,hi:i}=ze(t,n);return Math.min(i,Math.max(r,e))}r(Be,`clampToCornerClearance`);function Ve(e){let t=Math.max(...e.map(e=>e.lo)),n=Math.min(...e.map(e=>e.hi));if(!(t>n))return{lo:t,hi:n}}r(Ve,`intersectRanges`);function He(e,t){return t===`left`||t===`right`?ze(e.top,e.bottom):ze(e.left,e.right)}r(He,`clearanceRangeForSide`);function Ue(e,t,n){let r=e.y>=n.top-Y&&e.y<=n.bottom+Y,i=e.x>=n.left-Y&&e.x<=n.right+Y;if(R(e,t,Y)&&r){if(Math.abs(e.x-n.left)<Y)return`left`;if(Math.abs(e.x-n.right)<Y)return`right`}if(L(e,t,Y)&&i){if(Math.abs(e.y-n.top)<Y)return`top`;if(Math.abs(e.y-n.bottom)<Y)return`bottom`}}r(Ue,`terminalSideForSegment`);function We(e){return e===`left`||e===`right`}r(We,`isHorizontalSide`);function Ge(e,t,n,r,i){let a=[],o=n?Ue(e,t,n):void 0,s=r?Ue(t,e,r):void 0;return n&&o&&We(o)===i&&a.push(He(n,o)),r&&s&&We(s)===i&&a.push(He(r,s)),a.length>0?Ve(a):void 0}r(Ge,`straightClearanceRange`);function Ke(e,t,n,r,i){let a=Ge(e,t,n,r,i);if(!a)return;let o=i?e.y:e.x,s=Math.min(a.hi,Math.max(a.lo,o));if(!(Math.abs(s-o)<Y))return i?[{x:e.x,y:s},{x:t.x,y:s}]:[{x:s,y:e.y},{x:s,y:t.y}]}r(Ke,`clearStraightEndpointCornerAxis`);function qe(e,t,n){if(e.length!==2)return e;let[r,i]=e;return R(r,i,Y)?Ke(r,i,t,n,!0)??e:L(r,i,Y)?Ke(r,i,t,n,!1)??e:e}r(qe,`clearStraightEndpointCornerConnections`);function Je(e,t,n){return We(n)?{x:e.x,y:Be(e.y,t.top,t.bottom)}:{x:Be(e.x,t.left,t.right),y:e.y}}r(Je,`cornerClearedEndpoint`);function Ye(e,t,n,r,i,a){let o=e.map(e=>({...e}));for(let s=t;s>=0&&s<e.length;s+=n){let t=e[s];if(a&&!R(t,r,Y)||!a&&!L(t,r,Y))break;a?o[s].y=i.y:o[s].x=i.x}return o}r(Ye,`moveCollinearEndpointRun`);function Xe(e,t,n){if(e.length<2)return e;let r=n?0:e.length-1,i=n?1:-1,a=e[r],o=Re(e,r,i);if(!o)return e;let s=Ue(a,o,t);if(!s)return e;let c=We(s),l=Je(a,t,s);return I(a,l,Y)?e:Ye(e,r,i,a,l,c)}r(Xe,`clearEndpointCornerConnection`);function Ze(e,t,n){let r=Math.min(e.x,t.x)>=n.left-Y&&Math.max(e.x,t.x)<=n.right+Y,i=Math.min(e.y,t.y)>=n.top-Y&&Math.max(e.y,t.y)<=n.bottom+Y;if(Math.abs(e.y-n.top)<Y&&Math.abs(t.y-n.top)<Y&&r)return`top`;if(Math.abs(e.y-n.bottom)<Y&&Math.abs(t.y-n.bottom)<Y&&r)return`bottom`;if(Math.abs(e.x-n.left)<Y&&Math.abs(t.x-n.left)<Y&&i)return`left`;if(Math.abs(e.x-n.right)<Y&&Math.abs(t.x-n.right)<Y&&i)return`right`}r(Ze,`borderSideForSegment`);function Qe(e,t,n,r){switch(e){case`top`:return L(t,n,Y)&&n.y<r.top-Y;case`bottom`:return L(t,n,Y)&&n.y>r.bottom+Y;case`left`:return R(t,n,Y)&&n.x<r.left-Y;case`right`:return R(t,n,Y)&&n.x>r.right+Y}}r(Qe,`leavesOutward`);function $e(e,t,n){if(e.length<3)return e;if(n){let n=Ze(e[0],e[1],t);return n&&Qe(n,e[1],e[2],t)?e.slice(1):e}let r=e.length-1,i=Ze(e[r-1],e[r],t);return i&&Qe(i,e[r-1],e[r-2],t)?e.slice(0,r):e}r($e,`collapseOwnBorderStub`);function et(e,t,n){let r=e;if(t){let e=Re(r,0,1);if(e){let n=Le(e,r[0],t);n!==r[0]&&(r=[n,...r.slice(1)])}r=$e(r,t,!0)}if(n){let e=r.length-1,t=Re(r,e,-1);if(t){let i=Le(t,r[e],n,!0);i!==r[e]&&(r=[...r.slice(0,e),i])}r=$e(r,n,!1)}let i=qe(r,t,n);return i!==r||r.length===2?i:(t&&(r=Xe(r,t,!0)),n&&(r=Xe(r,n,!1)),r)}r(et,`snapAndCollapseEndpoints`);function tt(e,t){for(let n of e){let e=Ne(n,t,2);if(!e)continue;let r=et(G(e.points,Y),e.srcRect,e.dstRect);if(r.length<3){e.edge.points=r;continue}let i=[r[0],{...r[0]},...r.slice(1,-1),r[r.length-1],{...r[r.length-1]}];e.edge.points=i}}r(tt,`prepareEdgeEndpointsForRenderer`);function nt(e){return new Map(e.map(e=>[e.id,e]))}r(nt,`buildNodeMap`);function rt(e,t){let n=new Set([e.id]),r=0,i=e.parentId;for(;i&&!n.has(i);){let e=t.get(i);if(!e?.isGroup)break;n.add(i),r++,i=e.parentId}return r}r(rt,`groupDepth`);function it(e){let t=1/0,n=-1/0,r=1/0,i=-1/0;for(let a of e){let e=a.x,o=a.y;if(typeof e!=`number`||typeof o!=`number`)continue;let s=a.width??0,c=a.height??0;t=Math.min(t,e-s/2),n=Math.max(n,e+s/2),r=Math.min(r,o-c/2),i=Math.max(i,o+c/2)}return t===1/0||r===1/0?null:{minX:t,maxX:n,minY:r,maxY:i}}r(it,`boundsForChildren`);function at(e,t){let n=e.padding??20;e.x=(t.minX+t.maxX)/2,e.y=(t.minY+t.maxY)/2,e.width=Math.max(0,t.maxX-t.minX)+n,e.height=Math.max(0,t.maxY-t.minY)+n}r(at,`applyGroupBounds`);function ot(e){let t=nt(e),n=e.filter(e=>e.isGroup&&e.parentId).sort((e,n)=>rt(n,t)-rt(e,t));for(let t of n){let n=it(e.filter(e=>e.parentId===t.id));n&&at(t,n)}}r(ot,`recomputeNestedGroupBounds`);function st(e,t){let n=e.nodes??[],i=e.edges??[],a=n.filter(e=>!e.isGroup),o=1/0,s=-1/0;for(let e of a){let n=e[t];typeof n==`number`&&(o=Math.min(o,n),s=Math.max(s,n))}if(!Number.isFinite(o)||!Number.isFinite(s))return!1;let c=r(e=>o+s-e,`mirror`);for(let e of n){let n=e[t];typeof n==`number`&&(e[t]=c(n));let r=e.groupTitleRect;r&&(e.groupTitleRect=t===`x`?{...r,left:c(r.right),right:c(r.left)}:{...r,top:c(r.bottom),bottom:c(r.top)})}for(let e of i)for(let n of e.points??[])n[t]=c(n[t]);return!0}r(st,`mirrorAxis`);function ct(e){return!(e.nodes??[]).some(e=>!e.isGroup)||st(e,`y`)}r(ct,`applyBtDirectionTransform`);function lt(e){let t=e.filter(e=>!e.isGroup&&!e.isEdgeLabel);if(t.length===0)return 1;let n=0,r=0;for(let e of t)n+=e.width??0,r+=e.height??0;let i=n/t.length,a=r/t.length;return a>0?Math.max(1,i/a):1}r(lt,`flowAxisStretch`);var ut=36,dt=[`top`,`right`,`bottom`,`left`];function ft(e){return e===`left`?`right`:e===`right`?`left`:e}r(ft,`mirroredSide`);function pt(e,t,n,r,i){if(n===`top`||n===`bottom`){let n=(t.left+t.right)/2,[a,o]=i?[r.after,r.before]:[r.before,r.after];e.left=Math.min(e.left,n-a),e.right=Math.max(e.right,n+o);return}let a=(t.top+t.bottom)/2;e.top=Math.min(e.top,a-r.before),e.bottom=Math.max(e.bottom,a+r.after)}r(pt,`growAlongBorder`);var mt={top:r((e,t,n)=>{e.top=Math.min(e.top,t.top-n)},`top`),bottom:r((e,t,n)=>{e.bottom=Math.max(e.bottom,t.bottom+n)},`bottom`),left:r((e,t,n)=>{e.left=Math.min(e.left,t.left-n)},`left`),right:r((e,t,n)=>{e.right=Math.max(e.right,t.right+n)},`right`)};function ht(e,t,n,r,i){pt(e,t,n,r,i),mt[n](e,t,r.beyond)}r(ht,`reserveOnSide`);function gt(e,t,n){let r=e.x??0,i=e.y??0,a=(e.width??0)/2,o=(e.height??0)/2,s={left:r-a,right:r+a,top:i-o,bottom:i+o},c={...s},l=n===`RL`;for(let e of dt){let n=t[e];n&&ht(c,s,l?ft(e):e,n,l)}return{...e,x:(c.left+c.right)/2,y:(c.top+c.bottom)/2,width:c.right-c.left,height:c.bottom-c.top}}r(gt,`withAnchorFootprints`);function _t(e,t=`LR`){let n=e.nodes??[],r=e.edges??[],i=p(n),a=n.filter(e=>!e.isGroup&&!i.has(e.id)),o=1/0,c=1/0;for(let e of a){let t=e.x??0,n=e.y??0;t<o&&(o=t),n<c&&(c=n)}if(!Number.isFinite(o)||!Number.isFinite(c))return!1;let l=ut,u=lt(a);for(let e of a){let t=e.x??0,n=((e.y??0)-c)*u+l,r=t-o;e.x=n,e.y=r}for(let e of r)if(e.points)for(let t of e.points){let e=t.x,n=(t.y-c)*u+l,r=e-o;t.x=n,t.y=r}ot(n);let d=s(n),f=n.filter(e=>d.isLane(e.id));if(f.length===0)return t===`RL`&&st(e,`x`),!0;let m=new Map,h=x(n,t);for(let e of n){if(d.isLane(e.id)||d.isPool(e.id)||i.has(e.id))continue;let n=d.laneIdOf(e.id);if(!n)continue;let r=m.get(n)??[],a=h.get(e.id);r.push(a?gt(e,a,t):e),m.set(n,r)}let g=0;for(let e of f){let t=e.padding??0;t>g&&(g=t)}let _=[],v=1/0,y=-1/0;for(let e of f){let t=it(m.get(e.id)??[]);t&&(v=Math.min(v,t.minX),y=Math.max(y,t.maxX),_.push({lane:e,contentTop:t.minY,contentBottom:t.maxY,centerY:(t.minY+t.maxY)/2}))}if(v===1/0||y===-1/0)return!0;let b=Math.max(0,y-v)+2*Math.max(g,10),S=l+b,C=(v+y)/2-b/2-l,w=C+S/2,T=Math.max(g,l);_.sort((e,t)=>e.centerY-t.centerY);for(let e=0;e<_.length;e++){let t=_[e],n,r;if(n=e===0?t.contentTop-T:(_[e-1].contentBottom+t.contentTop)/2,e===_.length-1)r=t.contentBottom+T;else{let n=_[e+1];r=(t.contentBottom+n.contentTop)/2}let i=Math.max(0,r-n),a=(n+r)/2;t.lane.x=w,t.lane.y=a,t.lane.width=S,t.lane.height=i,t.lane.swimlaneContentTop=t.contentTop,t.lane.groupTitleRect={left:C,right:C+l,top:n,bottom:r}}return t===`RL`&&st(e,`x`),!0}r(_t,`applyLrDirectionTransform`);var vt=1e-6,yt=8,bt=[0,yt,-yt,2*yt,-2*yt];function xt(e,t){let{nodeInfoById:n,realNodeRects:r}=ve(t);for(let t of e){if(t.isLayoutOnly)continue;let i=t.points;if(!i||i.length<4)continue;let a=le(G(i,vt),vt);if(!a)continue;let{p3:o}=a,s=a.kind===`HVH`,c=xe(t,n,vt);if(!c)continue;let{srcId:l,dstId:u,srcInfo:d,dstInfo:f,collinearX:p,collinearY:m}=c;if(p||m)continue;let h,g=d.rect;for(let n of bt){let i,a,c;if(s){let e=f.cy>d.cy?g.bottom:g.top,t=d.cx+n;if(t<=g.left+vt||t>=g.right-vt)continue;i={x:t,y:e},a={x:t,y:o.y},c={x:o.x,y:o.y}}else{let e=f.cx>d.cx?g.right:g.left,t=d.cy+n;if(t<=g.top+vt||t>=g.bottom-vt)continue;i={x:e,y:t},a={x:o.x,y:t},c={x:o.x,y:o.y}}let p=I(i,a,vt),m=I(a,c,vt);if(p&&m||!p&&J(i,a,r,[l],1)||!m&&J(a,c,r,[u],1))continue;let _=!p&&we(i,a,e,t,{epsilon:vt,skipDegenerateOther:!0}),v=!m&&we(a,c,e,t,{epsilon:vt,skipDegenerateOther:!0});if(!(_||v)){h=p?[a,c]:m?[i,a]:[i,a,c];break}}h&&(t.points=h)}}r(xt,`portSwapToLShape`);function St(e,t){let n=.001,{realNodeRects:i,labelNodeRects:a}=ye(t.values());for(let o of e){if(o.isLayoutOnly)continue;let s=o.points;if(!s||s.length<4)continue;let c=G(s,n);if(c.length<4)continue;let l=c.length-1,u=c[l],d=c[l-1],f=c[l-2],p=u.x-d.x,m=u.y-d.y,h=Math.hypot(p,m);if(h>=10||h<n)continue;let g=d.x-f.x,_=d.y-f.y;if(Math.hypot(g,_)<n)continue;let v=z(d,u,n),y=B(d,u,n),b=z(f,d,n),x=B(f,d,n);if(!(v&&x||y&&b))continue;let S=o.end,C=o.start,w=S?t.get(S):void 0;if(!w)continue;let T=w.x??0,E=w.y??0,D=q(w);if(!D)continue;let O,k;if(x){let e=_<0;O={x:T,y:f.y},k={x:T,y:e?D.bottom:D.top}}else{let e=g>0;O={x:f.x,y:E},k={x:e?D.right:D.left,y:E}}if(J(O,k,i,S?[S]:[],-2)||J(O,k,a,[],-2))continue;if(C){let e=t.get(C),n=e?q(e):void 0;if(n&&de(O,n,2))continue}let ee=r((e,t)=>`${e.x.toFixed(3)},${e.y.toFixed(3)}|${t.x.toFixed(3)},${t.y.toFixed(3)}`,`ownSegmentKey`),A=new Set;for(let e=0;e<c.length-1;e++)A.add(ee(c[e],c[e+1]));let j=r((t,r)=>{for(let i of e){if(i===o||i.isLayoutOnly)continue;let e=i.points;if(!(!e||e.length<2))for(let i=0;i<e.length-1;i++){let a=e[i],o=e[i+1];if(!A.has(ee(a,o))&&Te(t,r,a,o,n))return!0}}return!1},`segmentCrossesOtherEdge`);if(j(O,k))continue;if(l-3>=0){let e=c[l-3],t=[C,S].filter(e=>!!e);if(J(e,O,i,t,-2)||j(e,O))continue}let M=[...c.slice(0,l-2),O,k];o.points=M;let N=o.labelNodeId;if(N){let e=t.get(N);if(e){let t=e.width??0,r=e.height??0;if(t>0&&r>0){let i,a,o=-1;for(let e=0;e<M.length-1;e++){let s=M[e],c=M[e+1],l=Math.hypot(c.x-s.x,c.y-s.y),u=R(s,c,n),d=L(s,c,n);(u&&l>=t+2||d&&l>=r+2)&&l>o&&(o=l,i=(s.x+c.x)/2,a=(s.y+c.y)/2)}i!==void 0&&a!==void 0&&(e.x=i,e.y=a)}}}}}r(St,`collapseShortTerminalStub`);var Ct=4,wt=2,Tt={EDGE_GAP:12,LANE_MARGIN:20,ARROWHEAD_SIZE:8,ARROWHEAD_GAP:Ct,MIN_ARROWHEAD_SPACING:12,EDGE_STROKE_WIDTH:wt,ROUTE_TOUCH_TOLERANCE:Ct+wt},Et={EPSILON:1e-6},Dt={GRAVITY_ITERATIONS:8,MAX_CROSSING_OPTIMIZATION_PASSES:4,DEFAULT_COMPACT_SINGLE_INPUT:!0},Ot={DEFAULT_LAYER_GAP:100,DEFAULT_NODE_GAP:40,EDGE_LABEL_CLEARANCE:16},X=.001,Z=8,kt=r(e=>typeof e==`string`?e.toUpperCase():``,`upperCaseDirection`),Q=U,At=r((e,t)=>L(e,t,X)||R(e,t,X),`orthogonallyAligned`);function jt(e,t){let n=r((e,t)=>{let n=e.x??0,r=e.y??0,i=t.x-n,a=t.y-r,o=(e.width??0)/2,s=(e.height??0)/2;return Math.abs(a)*o>Math.abs(i)*s?(a<0&&(s=-s),{x:n+(a===0?0:s*i/a),y:r+s}):(i<0&&(o=-o),{x:n+o,y:r+(i===0?0:o*a/i)})},`rectIntersect`),i=r((e,r)=>{let i=G(e.points??[]);if(i.length<2)return;let a=r?e.start:e.end,o=a?t.get(a):void 0,s=o?q(o):void 0;if(!o||!a||!s)return;let c=r?i[0]:i[i.length-1],l=r?i[1]:i[i.length-2],u=n(o,c),d=c;if(At(l,u)&&(d=l),L(u,d,X))return{edge:e,edgeId:String(e.id??``),nodeId:a,atStart:r,orientation:`V`,coord:u.x,min:Math.min(u.y,d.y),max:Math.max(u.y,d.y),boundary:u,railEnd:d,rect:s};if(R(u,d,X))return{edge:e,edgeId:String(e.id??``),nodeId:a,atStart:r,orientation:`H`,coord:u.y,min:Math.min(u.x,d.x),max:Math.max(u.x,d.x),boundary:u,railEnd:d,rect:s}},`terminalLaneFor`),a=r((e,t)=>Math.max(0,Math.min(e.max,t.max)-Math.max(e.min,t.min)),`projectedOverlapLength`),o=r((e,t)=>e.nodeId!==t.nodeId||e.orientation!==t.orientation?!1:e.orientation===`H`?(Math.abs(e.boundary.x-e.rect.left)<1||Math.abs(e.boundary.x-e.rect.right)<1)&&L(e.boundary,t.boundary,1):(Math.abs(e.boundary.y-e.rect.top)<1||Math.abs(e.boundary.y-e.rect.bottom)<1)&&R(e.boundary,t.boundary,1),`sameTerminalFace`),s=r((e,t)=>e.nodeId!==t.nodeId||e.orientation!==t.orientation?!1:a(e,t)>=Z&&Math.abs(e.coord-t.coord)<.5,`exactTerminalLaneConflict`),c=r((e,t)=>{if(e.nodeId!==t.nodeId||e.orientation!==t.orientation||e.orientation!==`H`||e.atStart===t.atStart)return!1;let n=a(e,t);if(n<Z)return!1;let r=e.rect.bottom-e.rect.top;return n<r||n>2*r?!1:o(e,t)&&Math.abs(e.coord-t.coord)<16},`nearTerminalLaneConflict`),l=r((e,t)=>{let n=G(e.edge.points??[]);if(n.length<2)return;let i=e.orientation===`V`?{x:e.boundary.x+t,y:e.boundary.y}:{x:e.boundary.x,y:e.boundary.y+t},a=e.orientation===`V`?{x:e.railEnd.x+t,y:e.railEnd.y}:{x:e.railEnd.x,y:e.railEnd.y+t};if(!r(()=>Math.abs(e.boundary.y-e.rect.top)<1||Math.abs(e.boundary.y-e.rect.bottom)<1?R(i,e.boundary,X)&&i.x>=e.rect.left+1&&i.x<=e.rect.right-1:Math.abs(e.boundary.x-e.rect.left)<1||Math.abs(e.boundary.x-e.rect.right)<1?L(i,e.boundary,X)&&i.y>=e.rect.top+1&&i.y<=e.rect.bottom-1:!1,`boundaryStaysOnSameFace`)())return;if(e.atStart){let t=n.length>1&&I(n[1],e.railEnd,X),r=n.slice(t?2:1),o=r[0];return o&&!At(o,a)?void 0:[i,a,...r]}let o=n.length>1&&I(n[n.length-2],e.railEnd,X),s=n.slice(0,o?-2:-1),c=s[s.length-1];if(!c||At(c,a))return[...s,a,i]},`shiftedCandidate`),u=r(e=>{let n=e.edge,r=G(n.points??[]);if(r.length!==2)return!1;let i=n.start,a=n.end,o=i?t.get(i):void 0,s=a?t.get(a):void 0;if(!o||!s)return!1;let c=o.x??0,l=o.y??0,u=s.x??0,d=s.y??0,[f,p]=r;return R(f,p,X)&&Math.abs(l-d)<1&&Math.abs(c-u)>1||L(f,p,X)&&Math.abs(c-u)<1&&Math.abs(l-d)>1},`laneIsStraightCollinearConnector`),d=[-7,7,-14,14,-21,21];for(let t=0;t<8;t++){let t=e.filter(e=>!e.isLayoutOnly).flatMap(e=>[i(e,!0),i(e,!1)]).filter(e=>!!e),n=!1;for(let e=0;e<t.length&&!n;e++)for(let r=e+1;r<t.length&&!n;r++){let a=t[e],o=t[r];if(a.edge===o.edge||!(s(a,o)||c(a,o)))continue;let f=!s(a,o),p=[a,o].sort((e,t)=>{let n=u(e),r=u(t);return n===r?Number(!t.atStart)-Number(!e.atStart):Number(n)-Number(r)});for(let e of p){for(let r of d){let a=l(e,r);if(!a)continue;let o=i({...e.edge,points:a},e.atStart);if(o&&!t.some(t=>t.edge!==e.edge&&(s(o,t)||f&&c(o,t)))){e.edge.points=a,n=!0;break}}if(n)break}}if(!n)return}}r(jt,`separateSharedRenderedTerminalLanes`);function Mt(e,t){let{realNodeRects:n,labelNodeRects:i}=ye(t.values()),a=r((t,r)=>{let a=t.start,o=t.end,s=Q(r);if(s.length!==r.length-1)return!1;let c=[a,o].filter(e=>!!e);for(let e of s)if(J(e.a,e.b,n,c,-2)||J(e.a,e.b,i,[],-2))return!1;for(let n of e){if(n===t||n.isLayoutOnly)continue;let e=n.points;if(!(!e||e.length<2)){for(let t of s)for(let n of Q(G(e)))if(H(t,n,.5)>=Z||Te(t.a,t.b,n.a,n.b,X))return!1}}return!0},`candidateIsSafe`),o=r((e,t)=>{if(t+4>=e.length)return;let n=e[t],r=e[t+1],i=e[t+2],a=e[t+3],o=e[t+4],s=z(n,r)&&B(r,i)&&z(i,a)&&B(a,o)&&L(n,a,X)&&L(n,o,X)&&L(r,i,X)&&(r.x-n.x)*(a.x-i.x)<0,c=B(n,r)&&z(r,i)&&B(i,a)&&z(a,o)&&R(n,a,X)&&R(n,o,X)&&R(r,i,X)&&(r.y-n.y)*(a.y-i.y)<0;if(s||c)return G([...e.slice(0,t+1),o,...e.slice(t+5)]);if(t+5>=e.length)return;let l=e[t+5],u=B(n,r)&&z(r,i)&&B(i,a)&&z(a,o)&&B(o,l)&&L(n,o,X)&&L(n,l,X)&&L(i,a,X)&&(i.x-r.x)*(o.x-a.x)<0,d=z(n,r)&&B(r,i)&&z(i,a)&&B(a,o)&&z(o,l)&&R(n,o,X)&&R(n,l,X)&&R(i,a,X)&&(i.y-r.y)*(o.y-a.y)<0;if(u||d)return G([...e.slice(0,t+1),l,...e.slice(t+6)])},`withoutDogleg`);for(let t=0;t<8;t++){let t=!1;for(let n of e){if(n.isLayoutOnly)continue;let e=G(n.points??[]);for(let r=0;r<=e.length-5;r++){let i=o(e,r);if(i&&a(n,i)){n.points=i,t=!0;break}}if(t)break}if(!t)return}}r(Mt,`collapseRedundantRectangularDoglegs`);function Nt(e,t){let{realNodeRects:n,labelNodeRects:i}=ye(t.values()),a=e.filter(e=>!e.isLayoutOnly),o=r((e,t,n)=>G(e===t?n??[]:e.points??[]),`pointsFor`),s=r((e,t)=>{let n=0;for(let r=0;r<a.length;r++){let i=Q(o(a[r],e,t));for(let s=r+1;s<a.length;s++){let r=Q(o(a[s],e,t));for(let e of i)for(let t of r)Te(e.a,e.b,t.a,t.b,X)&&n++}}return n},`strictCrossingCount`),c=r(e=>{let t=Q(e);if(t.length!==3)return;let n=t[1];if(t[0].horizontal!==n.horizontal&&t[2].horizontal!==n.horizontal)return{index:n.index,horizontal:n.horizontal,vertical:n.vertical,segment:n}},`middleRail`),l=r((e,t)=>{let r=[e.start,e.end].filter(e=>!!e);return n.filter(e=>{if(r.includes(e.id))return!1;let n=e.rect;return t.horizontal?V(t.a.x,t.b.x,n.left,n.right)>=Z&&t.a.y>=n.top-2&&t.a.y<=n.bottom+2:V(t.a.y,t.b.y,n.top,n.bottom)>=Z&&t.a.x>=n.left-2&&t.a.x<=n.right+2})},`blockingRectsFor`),u=r((e,t,n)=>{let r=e.map(e=>({...e}));if(t.horizontal)r[t.index].y=n,r[t.index+1].y=n;else if(t.vertical)r[t.index].x=n,r[t.index+1].x=n;else return;let i=Ae(G(r));return Q(i).length===i.length-1?i:void 0},`candidateByMovingRail`),d=r((e,t,r)=>{let c=[e.start,e.end].filter(e=>!!e),l=Q(t);if(l.length!==t.length-1)return!1;for(let e of l)if(J(e.a,e.b,n,c,-2)||J(e.a,e.b,i,[],-2))return!1;for(let t of a)if(t!==e){for(let e of l)for(let n of Q(o(t)))if(H(e,n,.5)>=Z)return!1}return s(e,t)<=r},`candidateIsSafe`);for(let e=0;e<8;e++){let e=s(),t=!1;for(let n of a){let r=o(n),i=c(r);if(!i)continue;let a=l(n,i.segment);if(a.length===0)continue;let s=i.horizontal?[Math.min(...a.map(e=>e.rect.top))-20,Math.max(...a.map(e=>e.rect.bottom))+20]:[Math.min(...a.map(e=>e.rect.left))-20,Math.max(...a.map(e=>e.rect.right))+20];for(let a of s){let o=u(r,i.segment,a);if(o&&d(n,o,e)){n.points=o,t=!0;break}}if(t)break}if(!t)return}}r(Nt,`liftObstacleHuggingSameSideRails`);function Pt(e,t,n){let i=r(e=>{let t=e.groupTitleRect;if(!(!t||typeof t.left!=`number`||typeof t.right!=`number`||typeof t.top!=`number`||typeof t.bottom!=`number`||!Number.isFinite(t.left)||!Number.isFinite(t.right)||!Number.isFinite(t.top)||!Number.isFinite(t.bottom)||t.right<=t.left||t.bottom<=t.top))return{left:t.left,right:t.right,top:t.top,bottom:t.bottom}},`validTitleRect`),a=s([...t.values()]),o=r(e=>{if(!a.isLane(e.id))return;let t=kt(e.direction??n);if(t===`LR`||t===`RL`||t===`BT`)return;let r=i(e),o=e.y,s=e.height;if(!r||typeof o!=`number`||typeof s!=`number`||!Number.isFinite(o)||!Number.isFinite(s)||s<=0)return;let c=r.right-r.left,l=r.bottom-r.top;if(!(l<=0||c<l))return{node:e,rect:r}},`topLaneTitleFor`),c=r((e,t)=>{if(!e.horizontal)return!1;let n=e.a.y;return n<t.top-X||n>t.bottom+X?!1:V(e.a.x,e.b.x,t.left,t.right)>=Z},`horizontalSegmentIntersectsTitle`),l=[...t.values()].map(o).filter(e=>!!e);if(l.length===0)return;let u=0;for(let t of e){if(t.isLayoutOnly)continue;let e=G(t.points??[]);for(let t of Q(e))for(let e of l)c(t,e.rect)&&(u=Math.max(u,e.rect.bottom-t.a.y+4))}if(!(u<=X))for(let e of l){let t=e.node.y,n=e.node.height;typeof t!=`number`||typeof n!=`number`||!Number.isFinite(t)||!Number.isFinite(n)||n<=0||(e.node.y=t-u/2,e.node.height=n+u,e.node.groupTitleRect={...e.rect,top:e.rect.top-u,bottom:e.rect.bottom-u})}}r(Pt,`liftTopLaneTitleBandsAboveRails`);function Ft(e,t,n){let i=r(e=>{let t=e.groupTitleRect;if(!(!t||typeof t.left!=`number`||typeof t.right!=`number`||typeof t.top!=`number`||typeof t.bottom!=`number`||!Number.isFinite(t.left)||!Number.isFinite(t.right)||!Number.isFinite(t.top)||!Number.isFinite(t.bottom)||t.right<=t.left||t.bottom<=t.top))return{left:t.left,right:t.right,top:t.top,bottom:t.bottom}},`validTitleRect`),a=s([...t.values()]),o=r(e=>{if(!a.isLane(e.id)||kt(e.direction??n)!==`LR`)return;let t=i(e),r=e.x,o=e.width;if(!t||typeof r!=`number`||typeof o!=`number`||!Number.isFinite(r)||!Number.isFinite(o)||o<=0)return;let s=t.right-t.left,c=t.bottom-t.top;if(!(s<=0||c<s))return{node:e,rect:t}},`leftLaneTitleFor`),c=r((e,t)=>{if(!e.vertical)return!1;let n=e.a.x;return n<t.left-X||n>t.right+X?!1:V(e.a.y,e.b.y,t.top,t.bottom)>=Z},`verticalSegmentIntersectsTitle`),l=r((e,t)=>{if(!e.horizontal)return!1;let n=e.a.y;return n<t.top-X||n>t.bottom+X?!1:V(e.a.x,e.b.x,t.left,t.right)>=Z},`horizontalSegmentIntersectsTitle`),u=[...t.values()].map(o).filter(e=>!!e);if(u.length===0)return;let d=0;for(let t of e){if(t.isLayoutOnly)continue;let e=G(t.points??[]);for(let t of Q(e))for(let e of u)if(c(t,e.rect))d=Math.max(d,e.rect.right-t.a.x+4);else if(l(t,e.rect)){let n=Math.min(t.a.x,t.b.x);d=Math.max(d,e.rect.right-n+4)}}if(!(d<=X))for(let e of u){let t=e.node.x,n=e.node.width;typeof t!=`number`||typeof n!=`number`||!Number.isFinite(t)||!Number.isFinite(n)||n<=0||(e.node.x=t-d/2,e.node.width=n+d,e.node.groupTitleRect={...e.rect,left:e.rect.left-d,right:e.rect.right-d})}}r(Ft,`shiftLeftLaneTitleBandsLeftOfRails`);function It(e,t){let{realNodeRects:n}=ye(t.values()),i=e.filter(e=>!e.isLayoutOnly),a=r((e,t=new Map)=>G(t.get(e)??e.points??[]),`replacementPointsFor`),o=r((e=new Map)=>{let t=0;for(let n=0;n<i.length;n++){let r=Q(a(i[n],e));for(let o=n+1;o<i.length;o++){let n=Q(a(i[o],e));for(let e of r)for(let r of n)Te(e.a,e.b,r.a,r.b,X)&&t++}}return t},`crossingCount`),s=r((e=new Map)=>i.reduce((t,n)=>t+W(a(n,e)),0),`totalBends`),c=r(e=>{let t=a(e);if(t.length<4)return;let n=t[t.length-2],r=t[t.length-1];if(z(n,r,X)||B(n,r,X))return{tailStart:n,terminal:r}},`terminalTailFor`),l=r((e,t)=>{let n=a(e);if(n.length<3)return;let r=n[0],i=n[1],o;if(z(r,i,X))o={x:i.x,y:t.tailStart.y};else if(B(r,i,X))o={x:t.tailStart.x,y:i.y};else return;let s=Ae(G([r,i,o,t.tailStart,t.terminal]));return Q(s).length===s.length-1?s:void 0},`candidateWithDestinationTail`),u=r((e,t)=>{let r=[e.start,e.end].filter(e=>!!e);for(let e of Q(t))if(J(e.a,e.b,n,r,-2))return!0;return!1},`pathHasNodeHit`),d=r((e,t,n)=>{for(let r of i)if(r!==e){for(let e of Q(t))for(let t of Q(a(r,n)))if(H(e,t,.5)>=Z)return!0}return!1},`pathHasSharedTrack`),f=r((e,t,n)=>!u(e,t)&&!d(e,t,n),`candidateIsSafe`),p=r(()=>{let e=new Map;for(let n of i){let r=n.end;if(!r||!t.has(r)||a(n).length<4)continue;let i=e.get(r)??[];i.push(n),e.set(r,i)}return e},`edgesByDestination`);for(let e=0;e<4;e++){let e=o();if(e===0)return;let t=s(),n,r=e,i=t;for(let t of p().values())for(let a=0;a<t.length;a++)for(let u=a+1;u<t.length;u++){let d=t[a],p=t[u],m=c(d),h=c(p);if(!m||!h)continue;let g=l(d,h),_=l(p,m);if(!g||!_)continue;let v=new Map([[d,g],[p,_]]);if(!f(d,g,v)||!f(p,_,v))continue;let y=o(v),b=s(v);y>=e||y>r||y===r&&b>=i||(n=v,r=y,i=b)}if(!n)return;for(let[e,t]of n)e.points=t}}r(It,`swapDestinationTerminalTailsToReduceCrossings`);function Lt(e,t){let{realNodeRects:n,labelNodeRects:i}=ye(t.values()),a=e.filter(e=>!e.isLayoutOnly),o=r((e,t=new Map)=>G(t.get(e)??e.points??[]),`replacementPointsFor`),s=r((e=new Map)=>{let t=0;for(let n=0;n<a.length;n++){let r=Q(o(a[n],e));for(let i=n+1;i<a.length;i++){let n=Q(o(a[i],e));for(let e of r)for(let r of n)Te(e.a,e.b,r.a,r.b,X)&&t++}}return t},`strictCrossingCount`),c=r((e=new Map)=>a.reduce((t,n)=>t+W(o(n,e)),0),`totalBends`),l=r(e=>{let n=e.start,r=e.end,i=n?t.get(n):void 0,a=r?t.get(r):void 0,o=i?q(i):void 0,s=a?q(a):void 0;return o&&s?{src:o,dst:s}:void 0},`endpointRectsFor`),u=r((e,t,n)=>{if(n.index<=0||n.index+1>=t.length-1)return;let r=l(e);if(r){if(n.vertical){let i=n.a.x,a=Math.min(r.src.left,r.dst.left),o=Math.max(r.src.right,r.dst.right),s=i<a-X?`left`:i>o+X?`right`:void 0;return s?{edge:e,points:t,segmentIndex:n.index,axis:`vertical`,side:s,coord:i,min:Math.min(n.a.y,n.b.y),max:Math.max(n.a.y,n.b.y)}:void 0}if(n.horizontal){let i=n.a.y,a=Math.min(r.src.top,r.dst.top),o=Math.max(r.src.bottom,r.dst.bottom),s=i<a-X?`top`:i>o+X?`bottom`:void 0;return s?{edge:e,points:t,segmentIndex:n.index,axis:`horizontal`,side:s,coord:i,min:Math.min(n.a.x,n.b.x),max:Math.max(n.a.x,n.b.x)}:void 0}}},`externalRailForSegment`),d=r(()=>{let e=[];for(let t of a){let n=o(t);for(let r of Q(n)){let i=u(t,n,r);i&&e.push(i)}}return e},`collectExternalRails`),f=r((e,t)=>e.edge!==t.edge&&e.axis===t.axis&&e.side===t.side&&V(e.min,e.max,t.min,t.max)>=Z,`railsInteract`),p=r(e=>{let t=[],n=new Set;for(let r of e){if(n.has(r))continue;let i=[r],a=[];for(n.add(r);i.length>0;){let t=i.pop();a.push(t);for(let r of e)!n.has(r)&&f(t,r)&&(n.add(r),i.push(r))}a.length>1&&t.push(a)}return t},`connectedComponents`),m=r(e=>{let t=[];for(let n of e)t.some(e=>Math.abs(e-n.coord)<X)||t.push(n.coord);for(;t.length<e.length;){let n=Math.min(...t),r=Math.max(...t),i=e[0].side;t.push(i===`left`||i===`top`?n-12*(e.length-t.length):r+12*(e.length-t.length))}return t},`uniqueCoordsFor`),h=r(e=>{let t=e.map(e=>e.coord),n=m(e),i=[];if(e.length<=6){let a=Array(n.length).fill(!1),o=[],s=r(()=>{if(o.length===e.length)o.some((e,n)=>Math.abs(e-t[n])>=X)&&i.push([...o]);else for(let[e,t]of n.entries())a[e]||(a[e]=!0,o.push(t),s(),o.pop(),a[e]=!1)},`visit`);return s(),i}for(let e=0;e<t.length;e++)for(let n=e+1;n<t.length;n++){let r=[...t];[r[e],r[n]]=[r[n],r[e]],i.push(r)}return i},`coordinateAssignmentsFor`),g=r((e,t)=>{let n=new Map;for(let[r,i]of e.entries()){let e=t[r],a=n.get(i.edge)??i.points.map(e=>({x:e.x,y:e.y}));i.axis===`vertical`?(a[i.segmentIndex].x=e,a[i.segmentIndex+1].x=e):(a[i.segmentIndex].y=e,a[i.segmentIndex+1].y=e),n.set(i.edge,a)}let r=new Map;for(let[e,t]of n){let n=Ae(G(t));if(Q(n).length!==n.length-1)return;r.set(e,n)}return r},`replacementsForAssignment`),_=r(e=>{for(let[t,r]of e){let e=[t.start,t.end].filter(e=>!!e);for(let t of Q(r))if(J(t.a,t.b,n,e,-2)||J(t.a,t.b,i,[],-2))return!1}for(let t=0;t<a.length;t++){let n=a[t],r=e.has(n),i=Q(o(n,e));for(let n=t+1;n<a.length;n++){let t=a[n];if(!r&&!e.has(t))continue;let s=Q(o(t,e));for(let e of i)for(let t of s)if(H(e,t,.5)>=Z)return!1}}return!0},`candidateIsSafe`);for(let e=0;e<4;e++){let e=s();if(e===0)return;let t,n=e,r=c(),i=1/0;for(let a of p(d()))for(let o of h(a)){let l=g(a,o);if(!l||!_(l))continue;let u=s(l);if(u>=e)continue;let d=c(l),f=a.reduce((e,t,n)=>e+Math.abs(o[n]-t.coord),0);u>n||u===n&&(d>r||d===r&&f>=i)||(t=l,n=u,r=d,i=f)}if(!t)return;for(let[e,n]of t)e.points=n}}r(Lt,`reassignCrossingExternalRailChannels`);function Rt(e,t){let{realNodeRects:n,labelNodeRects:i}=ye(t.values()),a=e.filter(e=>!e.isLayoutOnly),o=r((e,t,n)=>G(e===t?n??[]:e.points??[]),`pointsFor`),s=r(e=>Q(e).reduce((e,t)=>{let n=t.a.x-t.b.x,r=t.a.y-t.b.y;return e+Math.hypot(n,r)},0),`pathLength`),c=r((e,t)=>{let n=0;for(let r=0;r<a.length;r++){let i=Q(o(a[r],e,t));for(let s=r+1;s<a.length;s++){let r=Q(o(a[s],e,t));for(let e of i)for(let t of r)Te(e.a,e.b,t.a,t.b,X)&&n++}}return n},`strictCrossingCount`),l=r((e,t)=>{if(e.horizontal){let n=e.a.y;return(Math.abs(n-t.top)<1||Math.abs(n-t.bottom)<1)&&V(e.a.x,e.b.x,t.left,t.right)>=Z}if(e.vertical){let n=e.a.x;return(Math.abs(n-t.left)<1||Math.abs(n-t.right)<1)&&V(e.a.y,e.b.y,t.top,t.bottom)>=Z}return!1},`segmentRunsAlongRectBorder`),u=r(e=>{let n=[e.start,e.end].filter(e=>!!e),r=[];for(let e of n){let n=t.get(e),i=n?q(n):void 0;i&&r.push(i)}return r},`endpointRectsFor`),d=r((e,t)=>{if(t+3>=e.length)return[];let n=e[t],r=e[t+1],i=e[t+2],a=e[t+3],o=z(n,r,X)&&B(r,i,X)&&z(i,a,X),s=B(n,r,X)&&z(r,i,X)&&B(i,a,X);if(!o&&!s||!(o?Math.sign(r.x-n.x)!==Math.sign(a.x-i.x):Math.sign(r.y-n.y)!==Math.sign(a.y-i.y)))return[];let c=L(n,a,X)||R(n,a,X)?[]:[{x:n.x,y:a.y},{x:a.x,y:n.y}],l=c.length===0?[[...e.slice(0,t+1),...e.slice(t+3)]]:c.map(n=>[...e.slice(0,t+1),n,...e.slice(t+3)]),u=new Set;return l.map(e=>Ae(G(e))).filter(e=>{if(Q(e).length!==e.length-1||!e.some(e=>I(e,a,X)))return!1;let t=e.map(e=>`${e.x.toFixed(3)},${e.y.toFixed(3)}`).join(`|`);return!u.has(t)&&(u.add(t),!0)})},`shortcutCandidatesAt`),f=r((e,t,r)=>{let s=[e.start,e.end].filter(e=>!!e),d=u(e);for(let e of Q(t))if(J(e.a,e.b,n,s,-2)||J(e.a,e.b,i,[],-2)||d.some(t=>l(e,t)))return!1;for(let n of a)if(n!==e){for(let e of Q(t))for(let t of Q(o(n)))if(H(e,t,.5)>=Z)return!1}return c(e,t)<=r},`candidateIsSafe`);for(let e=0;e<8;e++){let e=c(),t,n,r=e,i=1/0,l=1/0;for(let u of a){let a=o(u),p=W(a,X),m=s(a);for(let o=0;o<=a.length-4;o++)for(let h of d(a,o)){let a=W(h,X),o=s(h);if(!(a<p||a===p&&o<m-X)||!f(u,h,e))continue;let d=c(u,h);d>r||d===r&&(a>i||a===i&&o>=l)||(t=u,n=h,r=d,i=a,l=o)}}if(!t||!n)return;t.points=n}}r(Rt,`shortcutRedundantOrthogonalJogs`);function zt(e,t){let n=[];for(let e of t.values()){if(e.isGroup||e.isEdgeLabel)continue;let t=e.x??0,r=e.y??0,i=q(e);i&&n.push({id:String(e.id??``),cx:t,cy:r,rect:i})}if(n.length===0)return;let i=new Map(n.map(e=>[e.id,e])),a=n.map(e=>({id:e.id,rect:e.rect})),o=[`top`,`bottom`,`left`,`right`],s={top:Math.min(...n.map(e=>e.rect.top))-20,bottom:Math.max(...n.map(e=>e.rect.bottom))+20,left:Math.min(...n.map(e=>e.rect.left))-20,right:Math.max(...n.map(e=>e.rect.right))+20},c=e.filter(e=>!e.isLayoutOnly),l=new Map(c.map((e,t)=>[e,t])),u=r(e=>{let t=e===`left`||e===`top`?-1:1,n=[];for(let r=0;r<=2;r++)n.push(s[e]+t*20*r);return n},`outwardTracksForSide`),d=r((e,t=new Map)=>G(t.get(e)??e.points??[]),`replacementPointsFor`),f=r((e,t)=>{let n=0;for(let r of e)for(let e of t)Te(r.a,r.b,e.a,e.b,X)&&n++;return n},`crossingCountBetweenSegments`),p=r((e,t)=>f(Q(e),Q(t)),`crossingCountBetweenPaths`),m=r((e=new Map)=>{let t=0,n=[],i=new Set,a=[],o=r(e=>{i.has(e)||(i.add(e),a.push(e))},`addEdge`);for(let r=0;r<c.length;r++){let i=c[r],a=d(i,e);for(let s=r+1;s<c.length;s++){let r=c[s],l=p(a,d(r,e));l>0&&(t+=l,n.push({first:i,second:r,count:l}),o(i),o(r))}}return a.sort((e,t)=>(l.get(e)??0)-(l.get(t)??0)),{count:t,pairs:n,edgeSet:i,edges:a}},`crossingSnapshot`),h=r((e,t)=>{let n=new Set(t.keys());if(n.size===0)return e.count;let r=0;for(let t of e.pairs)(n.has(t.first)||n.has(t.second))&&(r+=t.count);let i=0;for(let e=0;e<c.length;e++){let r=c[e],a=n.has(r),o=d(r,t);for(let r=e+1;r<c.length;r++){let e=c[r];(a||n.has(e))&&(i+=p(o,d(e,t)))}}return e.count-r+i},`crossingCountWithReplacements`),g=r(e=>{let t=new Map;for(let n of e.pairs){let e=t.get(n.first)??new Set;e.add(n.second),t.set(n.first,e);let r=t.get(n.second)??new Set;r.add(n.first),t.set(n.second,r)}let n=[],r=new Set;for(let i of e.edges){if(r.has(i))continue;let e=[i],a=[];for(r.add(i);e.length>0;){let n=e.pop();a.push(n);for(let i of t.get(n)??[])r.has(i)||(r.add(i),e.push(i))}a.sort((e,t)=>(l.get(e)??0)-(l.get(t)??0)),a.length>1&&n.push(a)}return n},`crossingComponents`),_=r(e=>[e.start,e.end].filter(e=>!!e),`endpointIdsFor`),v=r(e=>{let t=[];for(let n of g(e)){let e=new Set(n),r=new Set(n.flatMap(e=>_(e))),i=[...n];for(let t of c)e.has(t)||_(t).some(e=>r.has(e))&&i.push(t);i.sort((e,t)=>(l.get(e)??0)-(l.get(t)??0)),t.push(i)}return t},`pairSearchGroups`),y=r((e,t,n)=>h(e,new Map([[t,n]])),`crossingCountWithSingleReplacement`),b=r(e=>{let t=new Map;for(let n of e.pairs)t.set(n.first,(t.get(n.first)??0)+n.count),t.set(n.second,(t.get(n.second)??0)+n.count);return t},`currentCrossingsByEdge`),x=r(e=>e.slice(1).reduce((t,n,r)=>{let i=e[r];return t+Math.abs(n.x-i.x)+Math.abs(n.y-i.y)},0),`pathLength`),S=r((e=new Map)=>c.reduce((t,n)=>t+W(d(n,e)),0),`totalBends`),C=r((e=new Map)=>c.reduce((t,n)=>t+x(d(n,e)),0),`totalLength`),w=r((e,t)=>ce(e,t,Tt.ROUTE_TOUCH_TOLERANCE),`touchesAtBend`),T=r((e,t,n=new Map)=>{let r=Q(t);for(let i of c)if(i!==e){for(let e of r)for(let t of Q(d(i,n)))if(H(e,t,.5)>=Z)return!0;if(w(t,d(i,n)))return!0}return!1},`pathHasSegmentConflict`),E=r((e,t)=>{let n=[e.start,e.end].filter(e=>!!e);for(let e of Q(t))if(J(e.a,e.b,a,n,-2))return!0;return!1},`pathHitsNode`),D=r((e,t)=>{let n=Ae(G(t));Q(n).length===n.length-1&&e.push(n)},`pushOrthogonalCandidate`),O=r(e=>e===`left`||e===`right`,`sideIsHorizontal`),k=r((e,t,n)=>{switch(t){case`left`:return Math.min(e.x,n.x)-20;case`right`:return Math.max(e.x,n.x)+20;case`top`:return Math.min(e.y,n.y)-20;case`bottom`:return Math.max(e.y,n.y)+20}},`localTrackForSameSide`),ee=r((e,t,n,r)=>{let i=n===`left`||n===`top`?-1:1,a=[k(t,n,r),s[n]];for(let o of a)for(let a=0;a<=2;a++)D(e,_e(t,n,r,o+i*20*a))},`addSameSideCandidates`),A=r((e,t,n,r,i)=>{for(let a of u(n))for(let n of u(i))D(e,[t,{x:a,y:t.y},{x:a,y:n},{x:r.x,y:n},r])},`addHorizontalToVerticalCandidates`),j=r((e,t,n,r,i)=>{for(let a of u(n))for(let n of u(i))D(e,[t,{x:t.x,y:a},{x:n,y:a},{x:n,y:r.y},r])},`addVerticalToHorizontalCandidates`),M=r((e,t,n,r,i)=>{let a=[...u(`top`),...u(`bottom`)];for(let o of u(n))for(let n of u(i))for(let i of a)D(e,[t,{x:o,y:t.y},{x:o,y:i},{x:n,y:i},{x:n,y:r.y},r])},`addHorizontalPairCandidates`),N=r((e,t,n,r,i)=>{let a=[...u(`left`),...u(`right`)];for(let o of u(n))for(let n of u(i))for(let i of a)D(e,[t,{x:t.x,y:o},{x:i,y:o},{x:i,y:n},{x:r.x,y:n},r])},`addVerticalPairCandidates`),P=r(e=>{let t=new Set;return e.map(e=>G(e)).filter(e=>{let n=e.map(e=>`${e.x.toFixed(3)},${e.y.toFixed(3)}`).join(`|`);return t.has(n)||e.length<2?!1:(t.add(n),!0)})},`dedupeCandidatePaths`),te=r((e,t,n,r)=>{let i=[],a=ge(e,t,n,r,20,X);a&&D(i,a),t===r&&ee(i,e,t,n);let o=O(t),s=O(r);return o&&!s?A(i,e,t,n,r):!o&&s?j(i,e,t,n,r):o?M(i,e,t,n,r):N(i,e,t,n,r),P(i)},`buildCandidatesForSides`),ne=r((e,t,n,r)=>{let i=[...u(`left`),...u(`right`)],a=[...u(`top`),...u(`bottom`)];for(let s of o){let o=he(r,s),c=s===`top`||s===`bottom`?u(s):a;for(let r of i){O(s)&&D(e,[t,n,{x:r,y:n.y},{x:r,y:o.y},o]);for(let i of c)D(e,[t,n,{x:r,y:n.y},{x:r,y:i},{x:o.x,y:i},o])}}},`addVerticalDepartureOuterTrackCandidates`),re=r((e,t,n,r)=>{let i=[...u(`left`),...u(`right`)],a=[...u(`top`),...u(`bottom`)];for(let s of o){let o=he(r,s),c=s===`left`||s===`right`?u(s):i;for(let r of a){O(s)||D(e,[t,n,{x:n.x,y:r},{x:o.x,y:r},o]);for(let i of c)D(e,[t,n,{x:n.x,y:r},{x:i,y:r},{x:i,y:o.y},o])}}},`addHorizontalDepartureOuterTrackCandidates`),F=r(e=>{let t=e.start,n=e.end,r=n?i.get(n):void 0;if(!t||!r)return[];let a=G(e.points??[]);if(a.length<4)return[];let o=a[0],s=a[1],c=[];return B(o,s,X)?ne(c,o,s,r):z(o,s,X)&&re(c,o,s,r),c},`terminalPreservingOuterTrackCandidates`),ie=r(e=>{let t=e.start,n=e.end,r=t?i.get(t):void 0,a=n?i.get(n):void 0;if(!r||!a)return[];let s=[];for(let e of o){let t=he(r,e);for(let n of o)s.push(...te(t,e,he(a,n),n))}return s.push(...F(e)),s},`candidatePathsFor`),ae=r(()=>new Map(c.map(e=>[e,Q(d(e))])),`currentSegmentsByEdge`),I=r((e,t,n,r)=>{let i=new Set;for(let a of c){if(a===e)continue;let o=r.get(a)??Q(d(a));(n.some(e=>o.some(t=>H(e,t,.5)>=Z))||w(t,d(a)))&&i.add(a)}return i},`sharedTrackConflictsFor`),L=r((e,t,n,r)=>{let i=new Set;return ie(e).map(e=>Ae(G(e))).filter(t=>{if(E(e,t))return!1;let n=t.map(e=>`${e.x.toFixed(3)},${e.y.toFixed(3)}`).join(`|`);return i.has(n)||t.length<2?!1:(i.add(n),!0)}).map(i=>{let a=Q(i),o=0;for(let t of c)t!==e&&(o+=f(a,n.get(t)??Q(d(t))));return{candidate:i,candidateSegments:a,crossings:t.count-(r.get(e)??0)+o,bends:W(i,X),totalBends:W(i),length:x(i)}}).filter(({crossings:e})=>e<=t.count).sort((e,t)=>e.crossings-t.crossings||e.bends-t.bends||e.length-t.length).slice(0,48).map(t=>({path:t.candidate,segments:t.candidateSegments,sharedTrackConflicts:I(e,t.candidate,t.candidateSegments,n),totalBends:t.totalBends,length:t.length}))},`pairCandidatesFor`),R=r((e,t,n,r,i,a)=>{let o=0;for(let n of e.pairs)(n.first===t||n.second===t||n.first===r||n.second===r)&&(o+=n.count);let s=f(n.segments,i.segments);for(let e of c){if(e===t||e===r)continue;let o=a.get(e)??Q(d(e));s+=f(n.segments,o)+f(i.segments,o)}return e.count-o+s},`pairCrossingCount`),V=r((e,t)=>{for(let n of e.sharedTrackConflicts)if(n!==t)return!1;return!0},`conflictsOnlyWith`),U=r((e,t)=>e.segments.some(e=>t.segments.some(t=>H(e,t,.5)>=Z))||w(e.path,t.path),`candidatesShareTrack`),oe=r((e,t,n,r)=>V(t,n.edge)&&V(r,e.edge)&&!U(t,r),`pairCandidatesAreCompatible`),se=r((e,t,n,r,i)=>{let a=R(e.current,t.edge,n,r.edge,i,e.baseSegments);if(!(a>=e.current.count))return{replacements:new Map([[t.edge,n.path],[r.edge,i.path]]),crossings:a,bends:e.currentBends-(e.baseBendsByEdge.get(t.edge)??0)-(e.baseBendsByEdge.get(r.edge)??0)+n.totalBends+i.totalBends,length:e.currentLength-(e.baseLengthByEdge.get(t.edge)??0)-(e.baseLengthByEdge.get(r.edge)??0)+n.length+i.length}},`scorePairReplacement`),le=r((e,t)=>e.crossings<t.crossings||e.crossings===t.crossings&&(e.bends<t.bends||e.bends===t.bends&&e.length<t.length),`pairScoreIsBetter`),ue=r((e,t,n,r)=>{let i=r;for(let r of t.candidates)for(let a of n.candidates){if(!oe(t,r,n,a))continue;let o=se(e,t,r,n,a);o&&le(o,i)&&(i=o)}return i},`bestScoreForOptionPair`),de=r(e=>{let t=S(),n=C(),r=ae(),i=b(e),a=new Map(c.map(e=>[e,W(d(e))])),o=new Map(c.map(e=>[e,x(d(e))])),s=new Map,l=v(e);for(let t of l)for(let n of t){if(s.has(n))continue;let t=L(n,e,r,i);t.length>0&&s.set(n,{edge:n,candidates:t})}let u={replacements:new Map,crossings:e.count,bends:t,length:n},f={current:e,currentBends:t,currentLength:n,baseBendsByEdge:a,baseLengthByEdge:o,baseSegments:r};for(let t of l){let n=new Set(t.filter(t=>e.edgeSet.has(t))),r=t.map(e=>s.get(e)).filter(e=>!!e);for(let e=0;e<r.length;e++){let t=r[e];for(let i=e+1;i<r.length;i++){let e=r[i];(n.has(t.edge)||n.has(e.edge))&&(u=ue(f,t,e,u))}}}return u.replacements.size>0?u.replacements:void 0},`bestPairedReplacement`);for(let e=0;e<4;e++){let e=m(),t=e.count;if(t===0)return;let n,r,i=t,a=1/0;for(let o of e.edges){let s=W(d(o),X);for(let c of ie(o)){let l=E(o,c),u=!l&&T(o,c),d=y(e,o,c),f=W(c,X);l||u||(d<t||d===t&&f<s)&&(d>i||d===i&&f>=a||(n=o,r=c,i=d,a=f))}}if(n&&r){n.points=r;continue}let o=de(e);if(!o)return;for(let[e,t]of o)e.points=t}}r(zt,`resolveRenderedOrthogonalCrossings`);var Bt=.001,Vt=8;function Ht(e,t){let{nodeInfoById:n,realNodeRects:i}=ve(t),a=[`top`,`bottom`,`left`,`right`],o={top:Math.min(...i.map(e=>e.rect.top))-20,bottom:Math.max(...i.map(e=>e.rect.bottom))+20,left:Math.min(...i.map(e=>e.rect.left))-20,right:Math.max(...i.map(e=>e.rect.right))+20},s=r((e,t,n,r)=>{let i=[],a=ge(e,t,n,r,20,Bt);return a&&i.push(a),t===r&&i.push(_e(e,t,n,o[t])),i},`buildOrthogonalPathCandidates`),c=r((e,t)=>{for(let n=0;n<e.length-1;n++){let r=e[n],a=e[n+1];if(J(r,a,i,t,1))return!0}return!1},`pathHitsNode`),l=r((t,n,r=!1)=>{let i=0,a=U(t,Bt),o=n.start,s=n.end;for(let t of e){if(t===n||t.isLayoutOnly)continue;let e=t.start,c=t.end;if(!r&&o&&s&&(e===o||e===s||c===o||c===s))continue;let l=t.points;if(!(!l||l.length<2))for(let e of a)for(let t of U(l,Bt))(Se(e.a,e.b,t.a,t.b,Bt,Bt)||H(e,t,Bt)>=Vt)&&i++}return i},`pathConflictCount`),u=r((e,t)=>{let n=Math.abs(e.y-t.rect.top),r=Math.abs(e.y-t.rect.bottom),i=Math.abs(e.x-t.rect.left),a=Math.abs(e.x-t.rect.right),o=`top`,s=n;return r<s&&(o=`bottom`,s=r),i<s&&(o=`left`,s=i),a<s&&(o=`right`,s=a),o},`nearestSideOfRect`),d=new Map,f=r((e,t,n)=>{let r=d.get(e)??[];r.push({side:t,edgeId:n}),d.set(e,r)},`addFaceClaim`);for(let t of e){if(t.isLayoutOnly)continue;let e=t.points??[];if(e.length<1)continue;let r=t.id??``,i=t.start,a=t.end;if(i){let t=n.get(i);t&&f(i,u(e[0],t),r)}if(a){let t=n.get(a);t&&f(a,u(e[e.length-1],t),r)}}let p=r((e,t,n)=>d.get(e)?.some(e=>e.edgeId!==n&&e.side===t)??!1,`faceIsClaimed`);for(let t of e){if(t.isLayoutOnly)continue;let e=t.points;if(!e||e.length<2)continue;let r=W(e,Bt);if(r<4)continue;let i=t.start,o=t.end;if(!i||!o)continue;let m=n.get(i),h=n.get(o);if(!m||!h)continue;let g=t.id??``,_=l(e,t,!0),v=l(e,t),y,b=_,x=r;for(let e of a){if(p(i,e,g))continue;let n=he(m,e);for(let r of a){if(p(o,r,g))continue;let a=he(h,r);for(let u of s(n,e,a,r)){if(c(u,[i,o]))continue;let e=W(u,Bt);if(_>0){let n=l(u,t,!0);if(n>b||n===b&&e>=x)continue;b=n,x=e,y=u}else l(u,t)>v||e<x&&(x=e,y=u)}}}if(y){t.points=y;let e=d.get(i);e&&d.set(i,e.filter(e=>e.edgeId!==g));let n=d.get(o);n&&d.set(o,n.filter(e=>e.edgeId!==g)),f(i,u(y[0],m),g),f(o,u(y[y.length-1],h),g)}}}r(Ht,`simplifyDetouredEdges`);var Ut=.001,Wt=10,Gt=7;function Kt(e,t){let n=t?0:e.length-1,r=t?1:-1,i=e[n],a=e[n+r];if(!i||!a)return;let o=a.x-i.x,s=a.y-i.y;if(!(Math.abs(o)+Math.abs(s)<Ut)){if(Math.abs(s)<=Ut){let e=i.x+Math.sign(o)*Wt;return{left:Math.min(i.x,e),right:Math.max(i.x,e),top:i.y-Gt,bottom:i.y+Gt}}if(Math.abs(o)<=Ut){let e=i.y+Math.sign(s)*Wt;return{left:i.x-Gt,right:i.x+Gt,top:Math.min(i.y,e),bottom:Math.max(i.y,e)}}return{left:Math.min(i.x,a.x),right:Math.max(i.x,a.x),top:Math.min(i.y,a.y),bottom:Math.max(i.y,a.y)}}}r(Kt,`markerClearanceRectFor`);function qt(e){return{left:Math.min(e.left,e.right),right:Math.max(e.left,e.right),top:Math.min(e.top,e.bottom),bottom:Math.max(e.top,e.bottom)}}r(qt,`normalizeRect`);function Jt(e,t){let n=G(t);return[Kt(n,!0),Kt(n,!1)].some(t=>t&&K(e,qt(t)))}r(Jt,`labelOverlapsOwnMarker`);function Yt(e,t){let n=[];for(let t of e){if(t.isLayoutOnly)continue;let e=t.points;if(!(!e||e.length<2))for(let r=0;r<e.length-1;r++)n.push({edgeId:t.id,p1:e[r],p2:e[r+1]})}let i=[],a=[],o=s([...t.values()]);for(let e of t.values()){let t=e.isGroup;if(o.isLane(e.id)){let t=q(e);t&&a.push({id:e.id,rect:t});continue}if(t||e.isEdgeLabel)continue;let n=q(e);n&&i.push({nodeId:e.id,rect:n})}let c=r((e,t)=>{let n=pe(t,3);for(let{nodeId:t,rect:r}of i)if(t!==e&&K(n,r))return!0;return!1},`labelOverlapsForeignNode`),l=r((e,t)=>{let r=pe(t,3);for(let t of n)if(t.edgeId!==e&&ue(t.p1,t.p2,r))return!0;return!1},`labelOverlapsForeignEdge`),u=r((e,t,n)=>c(e,n)||l(t,n),`labelOverlapsAnything`),d=[],f=r(e=>{for(let{id:t,rect:n}of a)if(fe(n,e))return t},`findContainingLane`),p=r((e,t)=>d.some(n=>n.labelId!==e&&K(t,n.rect)),`overlapsPlacedLabel`);for(let n of e){if(n.isLayoutOnly)continue;let e=n.labelNodeId;if(!e)continue;let i=t.get(e);if(!i)continue;let o=n.points;if(!o||o.length<2)continue;let s=i.width??0,m=i.height??0;if(s<=0||m<=0)continue;let h=[];for(let e=0;e<o.length-1;e++){let t=o[e],n=o[e+1],r=Math.abs(t.x-n.x),i=Math.abs(t.y-n.y);r<Ut&&i<Ut||r>=Ut&&i>=Ut||h.push({idx:e,length:r+i,orientation:r>=Ut?`horizontal`:`vertical`,midX:(t.x+n.x)/2,midY:(t.y+n.y)/2})}if(h.length===0)continue;let g=h.length>=3?h.filter(e=>e.idx>0&&e.idx<h.length-1):h,_=g.length>0?g:h,v=s>=m?`horizontal`:`vertical`,y=r(e=>[...e].sort((e,t)=>{let n=e.orientation===v;if(n!==(t.orientation===v))return n?-1:1;let r=e.length>=(e.orientation===`horizontal`?s:m)+2;return r===t.length>=(t.orientation===`horizontal`?s:m)+2?t.length-e.length:r?-1:1}),`rankSegments`),b=h[0],x=h[h.length-1],S=[.5,.25,.75,.05,.95,.15,.85,.1,.9],C=r((e,t)=>{let n=o[e.idx],r=o[e.idx+1];return{midX:n.x+(r.x-n.x)*t,midY:n.y+(r.y-n.y)*t}},`anchorAtT`),w=r((e,t,n)=>Math.min(n,Math.max(t,e)),`clamp`),T=r((e,t)=>e.midX>=t.left-Ut&&e.midX<=t.right+Ut&&e.midY>=t.top-Ut&&e.midY<=t.bottom+Ut,`pointInsideRectInclusive`),E=r(e=>{let t=me(e.midX,e.midY,s,m),n=f(t);if(n)return{laneId:n,anchor:e,rect:t};let r=a.find(({rect:t})=>T(e,t));if(!r)return;let i=r.rect.left+s/2+1,o=r.rect.right-s/2-1,c=r.rect.top+m/2+1,l=r.rect.bottom-m/2-1;if(i>o||c>l)return;let u={midX:w(e.midX,i,o),midY:w(e.midY,c,l)},d=me(u.midX,u.midY,s,m);return T(e,d)?{laneId:r.id,anchor:u,rect:d}:void 0},`placementForAnchor`),D=r((e,t,n)=>e.orientation===`horizontal`?Math.abs(t.midX-n.x):Math.abs(t.midY-n.y),`distanceAlongSegment`),O=r((e,t)=>{let n=(e.orientation===`horizontal`?s/2:m/2)+12;if(e===b){let r=o[e.idx];if(D(e,t,r)+Ut<n)return!1}if(e===x){let r=o[e.idx+1];if(D(e,t,r)+Ut<n)return!1}return!0},`labelClearsTerminalEndpoints`),k=r(t=>{let r=y(t);for(let t of r)for(let r of S){let i=C(t,r);if(!O(t,i))continue;let a=E(i);if(a&&!Jt(a.rect,o)&&!p(e,a.rect)&&!u(e,n.id,a.rect))return{laneId:a.laneId,anchor:a.anchor}}},`tryPool`),ee=r((t,r,i=!1)=>{let a=y(t);for(let t of a){let a={midX:t.midX,midY:t.midY};if(r&&!O(t,a))continue;let s=E(a);if(s&&!Jt(s.rect,o)&&!p(e,s.rect)&&!c(e,s.rect)&&(i||!l(n.id,s.rect)))return{laneId:s.laneId,anchor:s.anchor}}},`findLaneContainingFallback`),A=k(_)??(_.length<h.length?k(h):void 0)??ee(h,!0)??ee(h,!1)??ee(h,!1,!0);if(A){i.x=A.anchor.midX,i.y=A.anchor.midY,i.parentId=A.laneId;let t=me(A.anchor.midX,A.anchor.midY,s,m),n=d.findIndex(t=>t.labelId===e);n>=0?d[n]={labelId:e,rect:t}:d.push({labelId:e,rect:t})}}}r(Yt,`anchorLabelsToPolyline`);var Xt=1e-6,Zt=4,Qt=3;function $t(e,t,n,{cx:r,cy:i},a,o){let s={x:r,y:i},c=o===`x`?`y`:`x`,l=Math.sign(a[c]-s[c]);for(let r of e)if(r!==t&&!r.isLayoutOnly&&r.points?.length&&[...r.end===n?[r.points.at(-1)]:[],...r.start===n?[r.points[0]]:[]].some(e=>Math.sign(e[c]-s[c])===l&&Math.abs(e[o]-a[o])<Tt.MIN_ARROWHEAD_SPACING))return!0;return!1}r($t,`crowdsFaceNeighbour`);function en(e,t){return e<t?`${e}::${t}`:`${t}::${e}`}r(en,`pairKey`);function tn(e,t){let{nodeInfoById:n,realNodeRects:i}=ve(t),a=new Map;for(let e of t){let t=e.id;e.isGroup||e.isEdgeLabel&&a.set(t,{w:e.width??0,h:e.height??0})}let o=r((t,n,i,o)=>{let s=en(n,i),c=0,l=r(e=>{if(!e)return;let t=a.get(e);if(!t)return;let n=o===`x`?t.w/2:t.h/2;n>c&&(c=n)},`consider`);l(t.labelNodeId);for(let n of e){if(n===t||n.isLayoutOnly)continue;let e=n.start,r=n.end;e&&r&&en(e,r)===s&&l(n.labelNodeId)}return c>0?c+Qt:0},`labelClearanceFor`);for(let t of e){if(t.isLayoutOnly)continue;let r=t.points;if(!le(r,Xt))continue;let a=xe(t,n,Xt);if(!a)continue;let{srcId:s,dstId:c,srcInfo:l,dstInfo:u,collinearX:d,collinearY:f}=a;if(d===f)continue;let p,m;if(d){let e=u.cy>l.cy;p={x:l.cx,y:e?l.rect.bottom:l.rect.top},m={x:u.cx,y:e?u.rect.top:u.rect.bottom}}else{let e=u.cx>l.cx;p={x:e?l.rect.right:l.rect.left,y:l.cy},m={x:e?u.rect.left:u.rect.right,y:u.cy}}if(J(p,m,i,[s,c],1))continue;let h=d?`x`:`y`,g=o(t,s,c,h),_=g>Zt?g:Zt,v=[0,_,-_],y;for(let n of v){let r={...p},a={...m};if(d){if(r.x+=n,a.x+=n,r.x<=l.rect.left||r.x>=l.rect.right||a.x<=u.rect.left||a.x>=u.rect.right)continue}else if(r.y+=n,a.y+=n,r.y<=l.rect.top||r.y>=l.rect.bottom||a.y<=u.rect.top||a.y>=u.rect.bottom)continue;if(J(r,a,i,[s,c],1)||we(r,a,e,t,{epsilon:Xt}))continue;let o=[r,a];if($t(e,t,s,l,r,h)||$t(e,t,c,u,a,h))y??=o;else{t.points=o,y=void 0;break}}y&&(t.points=y)}}r(tn,`straightenCollinearSiblingDetours`);function nn(e,t){let n=.001,{realNodeRects:i,labelNodeRects:a}=ye(t.values()),o=r((e,t)=>U(t,n).map(n=>({...n,edge:e,interior:n.index>=1&&n.index<=t.length-3})),`segmentsFor`),s=r(()=>{let t=[];for(let n of e){if(n.isLayoutOnly)continue;let e=n.points;!e||e.length<2||t.push(...o(n,G(e)))}return t},`allSegments`),c=r((e,t)=>e.horizontal&&t.horizontal?V(e.a.x,e.b.x,t.a.x,t.b.x)>=8&&Math.abs(e.a.y-t.a.y)<7:e.vertical&&t.vertical?V(e.a.y,e.b.y,t.a.y,t.b.y)>=8&&Math.abs(e.a.x-t.a.x)<7:!1,`hasCrowdedParallelTrack`),l=r((t,r)=>{let s=t.start,l=t.end,u=o(t,r);if(u.length!==r.length-1)return!1;let d=[s,l].filter(e=>!!e),f=t.labelNodeId?[t.labelNodeId]:[];for(let e of u)if(J(e.a,e.b,i,d,-2)||J(e.a,e.b,a,f,-2))return!1;for(let r of e){if(r===t||r.isLayoutOnly)continue;let e=r.points;if(!(!e||e.length<2)){for(let t of u)for(let i of o(r,G(e)))if(c(t,i)||Te(t.a,t.b,i.a,i.b,n))return!1}}return!0},`candidateIsSafe`),u=r((e,t)=>{let n=G(e.edge.points??[]);if(n.length<4||e.index>=n.length-1)return;let r=n.map(e=>({...e}));if(e.horizontal)r[e.index].y+=t,r[e.index+1].y+=t;else if(e.vertical)r[e.index].x+=t,r[e.index+1].x+=t;else return;return o(e.edge,r).length===r.length-1?r:void 0},`shiftedCandidate`),d=r((e,t)=>({x:e.x??(t.left+t.right)/2,y:e.y??(t.top+t.bottom)/2}),`nodeCenter`),f=r(e=>{let n=e.edge,r=G(n.points??[]);if(r.length!==4||e.index!==1)return;let i=n.start?t.get(n.start):void 0,a=n.end?t.get(n.end):void 0,o=i?q(i):void 0,s=a?q(a):void 0,c=r.slice(e.index+2);if(i&&a&&o&&s&&c.length!==0)return{sourceCenter:d(i,o),targetCenter:d(a,s),sourceRect:o,tail:c}},`sourceDetourContextFor`),p=r((e,t,r,i,a,o)=>{let s=i.y>=r.y,c=s?a.bottom:a.top,l=c+(s?20:-20);if(s&&e.b.y<=l+n||!s&&e.b.y>=l-n)return;let u=e.a.x+t;return G([{x:r.x,y:c},{x:r.x,y:l},{x:u,y:l},{x:u,y:e.b.y},...o],n)},`verticalSourceDetour`),m=r((e,t,r,i,a,o)=>{let s=i.x>=r.x,c=s?a.right:a.left,l=c+(s?20:-20);if(s&&e.b.x<=l+n||!s&&e.b.x>=l-n)return;let u=e.a.y+t;return G([{x:c,y:r.y},{x:l,y:r.y},{x:l,y:u},{x:e.b.x,y:u},...o],n)},`horizontalSourceDetour`),h=r((e,t)=>{let n=f(e);if(n){if(e.vertical)return p(e,t,n.sourceCenter,n.targetCenter,n.sourceRect,n.tail);if(e.horizontal)return m(e,t,n.sourceCenter,n.targetCenter,n.sourceRect,n.tail)}},`sourceDetourCandidate`),g=[-7,7,-14,14,-21,21];for(let e=0;e<12;e++){let e=s(),t=!1;for(let n=0;n<e.length&&!t;n++)for(let r=n+1;r<e.length&&!t;r++){let i=e[n],a=e[r];if(i.edge===a.edge||!c(i,a))continue;let o=[i,a].filter(e=>e.interior);for(let e of o){for(let n of g){let r=u(e,n);if(r&&l(e.edge,r)){e.edge.points=r,t=!0;break}let i=h(e,n);if(i&&l(e.edge,i)){e.edge.points=i,t=!0;break}}if(t)break}}if(!t)return}}r(nn,`nudgeSharedInteriorSubpaths`);function rn(e,t,n,r){let i=t.x-e.x,a=t.y-e.y,o=r.x-n.x,s=r.y-n.y,c=i*s-a*o;if(Math.abs(c)<1e-10)return!1;let l=n.x-e.x,u=n.y-e.y,d=(l*s-u*o)/c,f=(l*a-u*i)/c,p=.01;return d>p&&d<.99&&f>p&&f<.99}r(rn,`segmentsIntersect`);function an(e){let t=e.nodes??[],r=e.edges??[],i=[];if(!r.length||!t.length)return i;let a=be(t),o=[];for(let e of r){if(e.isLayoutOnly)continue;let t=e.points;if(!t||t.length<2)continue;let n=e.start,r=e.end,s=e.labelNodeId,c=e.id??`${n}->${r}`;for(let e of a)if(e.nodeId!==n&&e.nodeId!==r&&!(s&&e.nodeId===s)){for(let n=0;n<t.length-1;n++)if(ue(t[n],t[n+1],e,-1)){i.push({type:`edge-node-overlap`,edgeId:c,targetId:e.nodeId,detail:`segment ${n} passes through node "${e.nodeId}"`});break}}for(let e=0;e<t.length-1;e++)o.push({edgeId:c,start:n,end:r,p1:t[e],p2:t[e+1]})}let s=new Set;for(let e=0;e<o.length;e++)for(let t=e+1;t<o.length;t++){let n=o[e],r=o[t];if(n.edgeId!==r.edgeId&&n.start!==r.start&&n.start!==r.end&&n.end!==r.start&&n.end!==r.end&&rn(n.p1,n.p2,r.p1,r.p2)){let e=n.edgeId<r.edgeId?`${n.edgeId}|${r.edgeId}`:`${r.edgeId}|${n.edgeId}`;s.has(e)||(s.add(e),i.push({type:`edge-edge-crossing`,edgeId:n.edgeId,targetId:r.edgeId,detail:`edges "${n.edgeId}" and "${r.edgeId}" cross`}))}}if(i.length>0){let e=i.filter(e=>e.type===`edge-node-overlap`).length,t=i.filter(e=>e.type===`edge-edge-crossing`).length;n.warn(`[SWIMLANE_VALIDATE] ${i.length} issue(s) detected: ${e} edge-node overlap(s), ${t} edge crossing(s)`);for(let e of i)n.warn(`[SWIMLANE_VALIDATE] ${e.type}: ${e.detail}`)}return i}r(an,`validateSwimlanesLayout`);function on(e,t){let n=e.nodes??[],i=e.edges??[],a=n.filter(e=>!e.isGroup);if((t===`LR`||t===`RL`)&&a.length>0&&!_t(e,t)||t===`BT`&&a.length>0&&!ct(e))return;for(let e of i){if(e.isLayoutOnly)continue;let t=e.points;!t||t.length<2||(e.points=Ae(ke(t)))}Ht(i,n),tn(i,n),xt(i,n);let o=new Map;for(let e of n)o.set(String(e.id),e);Yt(i,o),Ie(i,o),St(i,o),nn(i,o),jt(i,o),Mt(i,o),Nt(i,o),It(i,o);let s=r(()=>{zt(i,o),jt(i,o),Lt(i,o),Rt(i,o),Yt(i,o),tt(i,o),Nt(i,o),Yt(i,o),tt(i,o)},`finalizeRenderedEdges`);s(),nn(i,o),s(),Pt(i,o,t),Ft(i,o,t),Pt(i,o,t),Ft(i,o,t)}r(on,`postProcessSwimlaneLayout`);function sn(e){let t=new Map(e.nodeById),n=new Set,r=[];for(let i of e.edges){if(!t.has(i.src)||!t.has(i.dst))continue;let e=`${i.id}:${i.src}->${i.dst}`;n.has(e)||(n.add(e),r.push(i))}return{nodes:[...t.keys()],edges:r,layout:e.layout,nodeById:t}}r(sn,`normalizeGraph`);function cn(e,t){return e.edges.filter(e=>e.dst===t)}r(cn,`incoming`);function ln(e){let t=new Map;for(let n of e.nodes)t.set(n,[]);for(let n of e.edges)t.get(n.src).push(n.dst);return t}r(ln,`buildSuccessorMap`);function un(e){let t=ln(e);for(let e of t.values())e.sort((e,t)=>e.localeCompare(t));return t}r(un,`buildSortedSuccessorMap`);function dn(e){let t=new Map;for(let n of e.nodes)t.set(n,0);for(let n of e.edges)t.set(n.dst,(t.get(n.dst)??0)+1);return t}r(dn,`buildInDegreeMap`);function fn(e,t){let n=[...t.entries()].filter(([,e])=>e===0).map(([e])=>e).sort((e,t)=>e.localeCompare(t)),i=new Set(e.edges.flatMap(e=>[e.src,e.dst])),a=r(t=>!i.has(t)&&!e.nodeById.get(t)?.isGroup,`isUnconnected`),o=[...t.keys()].filter(e=>t.get(e)===0&&a(e)),s=0;return n.map(e=>a(e)?o[s++]:e)}r(fn,`sortedZeroInDegreeNodes`);function pn(e,t=()=>!0){let n=new Map,r=new Map;for(let t of e.nodes)n.set(t,[]),r.set(t,[]);for(let i of e.edges)t(i)&&(r.get(i.src).push(i.dst),n.get(i.dst).push(i.src));return{preds:n,succs:r}}r(pn,`buildPredecessorSuccessorMaps`);function mn(e,t,n,r){let i=0;for(let t of e.nodes)r?.skipGroups&&e.nodeById.get(t)?.isGroup||(i=Math.max(i,n[t]??0));let a=Array.from({length:i+1},()=>[]);for(let i of t)r?.skipGroups&&e.nodeById.get(i)?.isGroup||a[Math.max(0,n[i]??0)].push(i);return a}r(mn,`buildLayersFromRanks`);function hn(e){let t=dn(e),n=fn(e,t),r=[],i=un(e);for(;n.length;){let e=n.shift();r.push(e);for(let r of i.get(e)??[])if(t.set(r,(t.get(r)??0)-1),(t.get(r)??0)===0){let e=0;for(;e<n.length&&n[e]<r;)e++;n.splice(e,0,r)}}return r.length===e.nodes.length?r:null}r(hn,`topoSortIfAcyclic`);function gn(e){let t=new Map,n=0;for(let r of e)t.set(r,n),n++;return t}r(gn,`buildLayerIndex`);function _n(e){let t=Array(e.length),n=r((r,i)=>{if(i-r<=1)return 0;let a=r+i>>1,o=n(r,a)+n(a,i),s=r,c=a,l=r;for(;s<a||c<i;)c>=i||s<a&&e[s]<=e[c]?t[l++]=e[s++]:(t[l++]=e[c++],o+=a-s);for(let n=r;n<i;n++)e[n]=t[n];return o},`count`);return n(0,e.length)}r(_n,`countInversions`);function vn(e){let t=sn(e),n=new Map;for(let e of t.nodes)n.set(e,[]);for(let e of t.edges)n.get(e.src).push(e);for(let e of n.values())e.sort((e,t)=>e.dst===t.dst?e.id.localeCompare(t.id):e.dst.localeCompare(t.dst));let i=Object.create(null);for(let e of t.nodes)i[e]=0;let a=[],o=r(e=>{i[e]=1;for(let t of n.get(e)??[]){let e=t.dst;i[e]===0?o(e):i[e]===1&&a.push(t)}i[e]=2},`dfs`),s=dn(t),c=[...t.nodes.filter(e=>(s.get(e)??0)===0),...t.nodes.filter(e=>(s.get(e)??0)!==0)];for(let e of c)i[e]===0&&o(e);let l=new Set(a.map(e=>`${e.id}:${e.src}->${e.dst}`)),u=t.edges.map(e=>l.has(`${e.id}:${e.src}->${e.dst}`)?{id:e.id,src:e.dst,dst:e.src,weight:e.weight,ref:e.ref}:e);return{acyclic:{nodes:[...t.nodes],edges:u,layout:t.layout,nodeById:new Map(t.nodeById)},reversed:a}}r(vn,`removeCycles_DFS`);function yn(e){let t=s(e.layout.nodes??[]),n=new Map;for(let r of e.nodes)n.set(r,t.laneIdOf(r));return n}r(yn,`buildTopLaneMap`);function bn(e){let t=yn(e);return e=>t.get(e)??null}r(bn,`createTopLaneResolver`);function xn(e){let t=e.layout.nodes??[],n=s(t),r=t.filter(e=>n.isLane(e.id)),i=r.filter(e=>o(e)!==void 0);if(i.length>0&&i.length===r.length)return[...i].sort((e,t)=>(o(e)??0)-(o(t)??0)).map(e=>e.id);if(!n.hasPools)return[...new Set(r.map(e=>e.id))].reverse();let a=[];for(let e of t)e.parentId||(n.isPool(e.id)?a.push(...n.lanesByPool.get(e.id)??[]):n.isLane(e.id)&&a.push(e.id));return[...new Set(a)].reverse()}r(xn,`buildTopLaneOrder`);function Sn(e,t){let n=xn(e);if(!t||t.length===0)return n;let r=new Set(n),i=new Set,a=[];for(let e of t)r.has(e)&&!i.has(e)&&(i.add(e),a.push(e));for(let e of n)i.has(e)||a.push(e);return a}r(Sn,`resolveTopLaneOrder`);function Cn(e,t){let n=sn(e),i=t?.laneOf??(()=>null),a=t?.rankHint,{preds:o}=pn(n);for(let e of o.values())e.sort((e,t)=>e.localeCompare(t));let s=hn(n)??[...n.nodes].sort((e,t)=>e.localeCompare(t)),c=new Map;for(let[e,t]of s.entries())c.set(t,e);let l=new Map,u=new Map;for(let e of n.nodes)u.set(e,[]);for(let e of s){let t=(o.get(e)??[]).filter(e=>l.has(e));if(t.length>0){let n=wn(e,t,{laneOf:i,rankHint:a,topoIndex:c});l.set(e,n),u.get(n).push(e)}else l.has(e)||l.set(e,null)}for(let e of n.nodes)l.has(e)||l.set(e,null);let d=new Set;for(let e of n.nodes)(l.get(e)??null)===null&&d.add(e);let f=[...d].sort((e,t)=>{let n=c.get(e)??0,r=c.get(t)??0;return n===r?e.localeCompare(t):n-r}),p=Tn(n),m=new Map;for(let[e,t]of p.entries())m.set(e,[...t].sort((e,t)=>e.localeCompare(t)));let h=En(m),g=Dn(m),_=new Map;for(let e of n.nodes)_.set(e,[]);for(let e of g)for(let t of e.nodes){let n=_.get(t);n?n.push(e.id):_.set(t,[e.id])}let v=[],y=[],b=new Set,x=r(e=>{if(!b.has(e)){b.add(e),v.push(e);for(let t of u.get(e)??[])x(t);y.push(e)}},`walk`);for(let e of f)x(e);for(let e of s)x(e);return{parent:l,children:u,roots:f,componentOf:h,blocks:g,nodeBlocks:_,adjacency:m,preorder:v,postorder:y,topologicalOrder:s}}r(Cn,`buildDrivingTree`);function wn(e,t,n){let r=n.laneOf(e);return[...t].sort((e,t)=>{let i=n.laneOf(e),a=n.laneOf(t),o=i!=null&&i===r;if(o!==(a!=null&&a===r))return o?-1:1;let s=n.rankHint?.[e],c=n.rankHint?.[t];if(s!=null&&c!=null&&s!==c)return c-s;let l=n.topoIndex.get(e)??0,u=n.topoIndex.get(t)??0;return l===u?e.localeCompare(t):l-u})[0]}r(wn,`chooseParent`);function Tn(e){let t=new Map;for(let n of e.nodes)t.set(n,new Set);for(let n of e.edges)t.get(n.src).add(n.dst),t.get(n.dst).add(n.src);return t}r(Tn,`buildAdjacency`);function En(e){let t=new Map,n=0;for(let r of e.keys()){if(t.has(r))continue;let i=[r];for(;i.length>0;){let r=i.pop();if(!t.has(r)){t.set(r,n);for(let n of e.get(r)??[])t.has(n)||i.push(n)}}n++}return t}r(En,`assignComponents`);function Dn(e){let t=new Map,n=new Map,i=[],a=[],o=0,s=r((r,c)=>{t.set(r,++o),n.set(r,o);for(let l of e.get(r)??[])l!==c&&(t.has(l)?(t.get(l)??0)<(t.get(r)??0)&&(i.push([r,l]),n.set(r,Math.min(n.get(r)??o,t.get(l)??o))):(i.push([r,l]),s(l,r),n.set(r,Math.min(n.get(r)??o,n.get(l)??o)),(n.get(l)??0)>=(t.get(r)??0)&&a.push(On(r,l,i,a.length))))},`visit`);for(let n of e.keys())t.has(n)||s(n,null);return a}r(Dn,`computeBlocks`);function On(e,t,n,r){let i=[],a=new Set;for(;n.length>0;){let r=n.pop();if(i.push(r),a.add(r[0]),a.add(r[1]),r[0]===e&&r[1]===t||r[0]===t&&r[1]===e)break}return{id:r,edges:i,nodes:[...a]}}r(On,`popBlock`);function kn(e,t,n){let i=[...e.nodes],a=new Map;for(let[e,t]of i.entries())a.set(t,e);let o=i.length,s=Array(o).fill(-1),c=Array(o).fill(0),l=[],u=new Set;for(let e of i){let t=n.parent.get(e)??null,r=a.get(e);r!=null&&(t??(s[r]=-1,c[r]=0,u.has(e)||(u.add(e),l.push(e))))}for(;l.length>0;){let e=l.shift(),t=a.get(e);if(t==null)continue;let r=n.children.get(e)??[];for(let e of r){if(u.has(e))continue;let n=a.get(e);n!=null&&(s[n]=t,c[n]=c[t]+1,u.add(e),l.push(e))}}for(let e of i){if(u.has(e))continue;let t=a.get(e);t!=null&&(s[t]=-1,c[t]=0,u.add(e))}let d=Math.max(1,Math.ceil(Math.log2(Math.max(1,o)))+1),f=Array.from({length:d},()=>Array(o).fill(-1));for(let e=0;e<o;e++)f[0][e]=s[e];for(let e=1;e<d;e++)for(let t=0;t<o;t++){let n=f[e-1][t];f[e][t]=n===-1?-1:f[e-1][n]}let p=r((e,t)=>{if(e===-1||t===-1)return-1;c[e]<c[t]&&([e,t]=[t,e]);let n=c[e]-c[t];for(let t=0;t<d;t++)if(n>>t&1&&(e=f[t][e],e===-1))return-1;if(e===t)return e;for(let n=d-1;n>=0;n--){let r=f[n][e],i=f[n][t];r!==-1&&i!==-1&&r!==i&&(e=r,t=i)}return f[0][e]},`lcaIndex`),m=Array.from({length:o},()=>new Map);for(let n of e.edges){let e=n.src,r=n.dst,i=t[e],o=t[r];if(i==null||o==null||(i>o&&([e,r]=[r,e],[i,o]=[o,i]),i==null||o==null||i===o))continue;let s=a.get(e),c=a.get(r);if(s==null||c==null)continue;let l=p(s,c);if(l===-1)continue;let u=m[l];for(let e=i;e<o;e++)u.set(e,(u.get(e)??0)+1)}let h=new Map,g=r((e,t)=>{if(t.size!==0)for(let[n,r]of t)e.set(n,(e.get(n)??0)+r)},`mergeInto`),_=new Set,v=r(e=>{let r=a.get(e);_.add(e);let i=r==null?void 0:m[r],o=i?new Map(i):new Map,s=n.children.get(e)??[];for(let n of s){let r=v(n),i=t[e];if(i!=null){let a=h.get(e);a||(a=new Map,h.set(e,a));let o=r.get(i)??0,s=t[n];s!=null&&s>i&&(o+=1),a.set(n,o)}g(o,r)}return o},`dfs`);for(let e of n.roots)_.has(e)||v(e);for(let e of i)_.has(e)||v(e);return h}r(kn,`computeSubtreeCrossCounts`);function An(e,t,n){let i=new Map,a=r(e=>{let r=n[e]??0,o=[...t.get(e)??[]];o.sort(jn(n));for(let e of o){a(e);let t=i.get(e);t!=null&&(r=Math.min(r,t))}i.set(e,r)},`annotate`);for(let t of e)a(t);return i}r(An,`annotateMinimumLayers`);function jn(e){return(t,n)=>{let r=e[t]??0,i=e[n]??0;return r===i?t.localeCompare(n):r-i}}r(jn,`compareByRankThenId`);function Mn(e,t,n,i){let a=0;for(let e of t){let t=n[e]??0;t>a&&(a=t)}let o=Array.from({length:a+1},()=>[]),s=new Set,c=r(e=>{if(s.has(e))return;s.add(e);let t=n[e]??0;o[t]||(o[t]=[]),o[t].push(e);for(let t of i(e))c(t)},`emit`);for(let t of e)c(t);for(let e of t)if(!s.has(e)){let t=n[e]??0;o[t]||(o[t]=[]),o[t].push(e),s.add(e)}return o}r(Mn,`emitNodesInTreeOrder`);function Nn(e){let t=[];for(let n of e){let e=new Set,r=[];for(let t of n)e.has(t)||(e.add(t),r.push(t));t.push(r)}return t}r(Nn,`deduplicateLayers`);function Pn(e,t,n,r){return i=>{let a=e.get(i)??[];if(a.length===0)return[];let o=t[i]??0,s=[],c=[],l=n.get(i);for(let e of a){let t=r.get(e)??o;t>o?s.push({child:e,min:t}):c.push(e)}return s.sort((e,t)=>e.min===t.min?e.child.localeCompare(t.child):e.min-t.min),c.sort((e,t)=>{let n=l?.get(e)??0,i=l?.get(t)??0;if(n!==i)return n-i;let a=r.get(e)??o,s=r.get(t)??o;return a===s?e.localeCompare(t):a-s}),[...s.map(e=>e.child),...c]}}r(Pn,`createChildOrderer`);function Fn(e,t,n){let r=Cn(e,{rankHint:t,laneOf:n}),{children:i,roots:a}=r;for(let t of e.nodes)i.has(t)||i.set(t,[]);let o=kn(e,t,r),s=[...a].sort(jn(t)),c=Pn(i,t,o,An(s,i,t)),l=Mn(s,e.nodes,t,c);return l=Nn(l),l}r(Fn,`buildMultitreeLayerOrder`);function In(e,t,n){let r=new Set(e),i=new Set(t),a=gn(t),o=[];for(let e of n)r.has(e.src)&&i.has(e.dst)&&o.push(a.get(e.dst));return _n(o)}r(In,`countCrossingsBetweenAdjacent`);function Ln(e,t,n){let r=[];for(let e of t){let t=n[e.src],i=n[e.dst];if(t==null||i==null||t===i)continue;let a=e.src,o=e.dst,s=t,c=i;t>i&&(a=e.dst,o=e.src,s=i,c=t);for(let t=s;t<c;t++)r.push({id:`${e.id}@${t}`,src:a,dst:o,ref:e.ref})}let i=0;for(let t=0;t+1<e.length;t++)i+=In(e[t],e[t+1],r);return i}r(Ln,`totalCrossings`);function Rn(e,t){let n={...t},{preds:r}=pn(e),i=bn(e),a=Ln(Fn(e,n,i),e.edges,n),o=Dt.MAX_CROSSING_OPTIMIZATION_PASSES;for(let t=0;t<o;t++){let t=!1,o=[...e.nodes].sort((e,t)=>(n[t]??0)-(n[e]??0));for(let s of o){let o=n[s]??0;if(o===0)continue;let c=0;for(let e of r.get(s)??[])c=Math.max(c,(n[e]??0)+1);if(c>=o)continue;let l=o;n[s]=c;let u=Ln(Fn(e,n,i),e.edges,n);u<a?(a=u,t=!0):n[s]=l}if(!t)break}return n}r(Rn,`optimizeRanksByCrossings`);function zn(e,t){let n=bn(e),r=[...e.nodes].sort((e,n)=>(t[e]??0)-(t[n]??0)||e.localeCompare(n));for(let i of r){let r=n(i);if(!r)continue;let a=e.edges.filter(e=>e.src===i);if(a.length===0)continue;let o=!1,s=0;for(let e of a){let t=n(e.dst);t==null||t===r?o=!0:s++}if(s===0||o)continue;let c=0,l=!1;for(let t of e.edges){if(t.dst!==i)continue;let e=n(t.src);e&&(e===r?l=!0:c++)}if(c>0||!l)continue;let u=t[i]??0,d=u+s,f=0;for(let n of e.edges)n.dst===i&&(f=Math.max(f,(t[n.src]??0)+1));let p=Math.max(u,f,d);p!==u&&(t[i]=p)}}r(zn,`adjustCrossLaneSources`);function Bn(e,t){let n=sn(e),r=hn(n)??[...n.nodes].sort(),i=t?.compactSingleInput??!1,a=bn(n),o=Object.create(null);for(let e of r){let r=cn(n,e),s=t?.ignoreCrossLaneEdges?r.filter(t=>{let n=a(t.src),r=a(e);return!n||!r||n===r}):r;if(s.length===0)o[e]=0;else if(i&&s.length===1){let t=s[0].src;a(t)===a(e)?o[e]=(o[t]??0)+1:o[e]=o[t]??0}else{let t=-1/0;for(let e of s)t=Math.max(t,(o[e.src]??0)+1);o[e]=t===-1/0?0:t}}return(t?.optimizeRanksByCrossings??!1)&&(o=Rn(n,o)),t?.ignoreCrossLaneEdges&&zn(n,o),{layers:Fn(n,o,a),rankOf:o,dummy:new Set}}r(Bn,`assignLayers_LongestPath`);function Vn(e,t){let n=sn(e),i={...Bn(n,{compactSingleInput:t?.compactSingleInput,ignoreCrossLaneEdges:t?.ignoreCrossLaneEdges,optimizeRanksByCrossings:t?.optimizeRanksByCrossings}).rankOf},a=bn(n),{preds:o,succs:s}=pn(n,e=>{if(t?.ignoreCrossLaneEdges){let t=a(e.src),n=a(e.dst);if(t&&n&&t!==n)return!1}return!0}),c=hn(n)??[...n.nodes],l=[...c].reverse(),u=r((e,t)=>{let n=0;for(let t of o.get(e)??[])n=Math.max(n,(i[t]??0)+1);let r=1/0,a=s.get(e)??[];return a.length>0&&(r=Math.min(...a.map(e=>(i[e]??0)-1))),Number.isFinite(r)||(r=Math.max(n,t)),Math.min(Math.max(t,n),r)},`clampFeasible`),d=Dt.GRAVITY_ITERATIONS,f=r(e=>{let t=!1;for(let n of e){let e=o.get(n)??[],r=s.get(n)??[];if(e.length===0&&r.length===0)continue;let a=e.length>0?e.reduce((e,t)=>e+(i[t]??0)+1,0)/e.length:i[n]??0,c=r.length>0?r.reduce((e,t)=>e+(i[t]??0)-1,0)/r.length:i[n]??0,l=Math.round((a+c)/2),d=u(n,l);d!==i[n]&&(i[n]=d,t=!0)}return t},`relaxOrder`);for(let e=0;e<d;e++){let e=f(c),t=f(l);if(!e&&!t)break}for(let e of c){let t=0;for(let n of o.get(e)??[])t=Math.max(t,(i[n]??0)+1);(i[e]??0)<t&&(i[e]=t)}for(let e of l){let t=s.get(e)??[];if(t.length>0){let n=Math.min(...t.map(e=>(i[e]??0)-1));(i[e]??0)>n&&(i[e]=n)}}return{layers:mn(n,c,i),rankOf:i,dummy:new Set}}r(Vn,`assignLayers_Gravity`);function Hn(e){let t=dn(e),n=un(e),r=fn(e,t),i=[];for(;r.length>0;){let e=[];for(let a of r){i.push(a);for(let r of n.get(a)??[])t.set(r,(t.get(r)??0)-1),(t.get(r)??0)===0&&e.push(r)}r=e.sort((e,t)=>e.localeCompare(t))}return i.length===e.nodes.length?i:null}r(Hn,`topoSortByGenerationIfAcyclic`);function Un(e,t){let n=sn(e),i=t?.direction===`LR`?Hn(n)??[...n.nodes].sort():hn(n)??[...n.nodes].sort(),a=bn(n),o=r(e=>a(e)??e,`laneOf`),s=Object.create(null),c=new Map,l=r((e,n)=>t?.ignoreCrossLaneEdges??!0?+(o(e)===o(n)):1,`edgeWeight`);for(let e of i){if(n.nodeById.get(e)?.isGroup)continue;let t=cn(n,e),r=0;if(t.length>0)for(let n of t){let t=n.src,i=s[t]??0;r=Math.max(r,i+l(t,e))}let i=o(e),a=c.get(i)??0,u=Math.max(r,a);s[e]=u,c.set(i,u+1)}return{layers:mn(n,i,s,{skipGroups:!0}),rankOf:s,dummy:new Set}}r(Un,`assignLayers_LaneAwareCompact`);function Wn(e,t){let n=sn(t),{rankOf:i}=e,a=e.layers.map(e=>[...e]),o=new Set(e.dummy?[...e.dummy]:[]),s=0,c=new Map(n.nodeById),l=r(e=>{let t=`placeholder-${s++}`,n={id:t,isGroup:!1,isDummy:!0,width:0,height:0};for(c.set(t,n),o.add(t);a.length<=e;)a.push([]);return a[e].push(t),i[t]=e,t},`addDummyAt`),u=[...n.edges].sort((e,t)=>e.id===t.id?e.src===t.src?e.dst.localeCompare(t.dst):e.src.localeCompare(t.src):e.id.localeCompare(t.id)),d=[];for(let e of u){let t=i[e.src]??0,n=i[e.dst]??0;if(n-t<=1){d.push(e);continue}let r=e.src;for(let i=t+1,a=0;i<n;i++,a++){let t=l(i);d.push({id:`${e.id}#${a}`,src:r,dst:t,weight:e.weight,ref:e.ref}),r=t}let a=n-t-2;d.push({id:`${e.id}#${Math.max(a+1,0)}`,src:r,dst:e.dst,weight:e.weight,ref:e.ref})}let f={nodes:[...n.nodes,...[...o].filter(e=>!n.nodes.includes(e))],edges:d,layout:n.layout,nodeById:c};return{layering:{layers:a,rankOf:i,dummy:o},graphWithDummies:f}}r(Wn,`makeProperLayering`);function Gn(e){let t=e.length;if(t===0)return 1/0;let n=[...e].sort((e,t)=>e-t);return t%2==1?n[(t-1)/2]:.5*(n[t/2-1]+n[t/2])}r(Gn,`median`);function Kn(e){return e.length===0?1/0:e.reduce((e,t)=>e+t,0)/e.length}r(Kn,`barycenter`);function qn(e,t,n,r){let i=new Map;for(let t of e)i.set(t,[]);for(let e of n)r===`down`?t.has(e.src)&&i.has(e.dst)&&i.get(e.dst).push(t.get(e.src)):t.has(e.dst)&&i.has(e.src)&&i.get(e.src).push(t.get(e.dst));return i}r(qn,`neighborPositionsFor`);function Jn(e,t,n){let r=n.get(e)??0,i=n.get(t)??0;return r===i?e.localeCompare(t):r-i}r(Jn,`currentOrderTieBreak`);function Yn(e,t,n){let r=new Set(e),i=new Set(t),a=gn(e),o=gn(t),s=[];for(let e of n)r.has(e.src)&&i.has(e.dst)&&s.push({u:a.get(e.src),v:o.get(e.dst)});return s.sort((e,t)=>e.u===t.u?e.v-t.v:e.u-t.u),_n(s.map(e=>e.v))}r(Yn,`countCrossingsBetweenAdjacent`);function Xn(e,t,n){return[...e].sort((e,r)=>{let i=Gn(t.get(e)??[]),a=Gn(t.get(r)??[]);return i===a?Jn(e,r,n):isFinite(i)?isFinite(a)?i-a:-1:1})}r(Xn,`sortByHeuristic`);function Zn(e,t,n,r,i,a){let o=gn(e),s=gn(t),c=qn(t,o,n,r);if(!i||!a||a.length===0)return Xn(t,c,s);let l=new Map;for(let e of t){let t=i(e),n=l.get(t)??[];n.push(e),l.set(t,n)}let u=[];for(let e of a){let t=l.get(e);if(!t||t.length===0)continue;let n=Xn(t,c,s);u.push(...n)}let d=l.get(null);if(d&&d.length>0){let e=Xn(d,c,s);for(let t of e){let e=Kn(c.get(t)??[]),n=u.length;if(isFinite(e)){for(let[t,r]of u.entries())if(e<Kn(c.get(r)??[])){n=t;break}}u.splice(n,0,t)}}return u}r(Zn,`reorderLayer`);function Qn(e,t,n,i,a){let o=[...t],s=new Set(e),c=new Set(t),l=i?new Set(i):null,u=n.filter(e=>s.has(e.src)&&c.has(e.dst)),d=l?n.filter(e=>c.has(e.src)&&l.has(e.dst)):void 0,f=r(t=>{let n=Yn(e,t,u);return d&&i&&(n+=Yn(t,i,d)),n},`crossingScore`),p=a?new Map:null;if(a&&p)for(let e of t)p.set(e,a(e));let m=!0,h=f(o);for(;m;){m=!1;for(let e=0;e+1<o.length;e++){if(p&&p.get(o[e])!==p.get(o[e+1]))continue;let t=h;[o[e],o[e+1]]=[o[e+1],o[e]];let n=f(o);n<t?(h=n,m=!0):[o[e],o[e+1]]=[o[e+1],o[e]]}}return o}r(Qn,`transposeImprove`);function $n(e,t,n){let r=e.layers.map(e=>[...e]),i=t.edges,a=bn(t),o=Sn(t,n?.laneOrder);for(let e=0;e<3;e++){for(let e=1;e<r.length;e++)r[e]=Zn(r[e-1],r[e],i,`down`,a,o),r[e]=Qn(r[e-1],r[e],i,r[e+1],a);for(let e=r.length-2;e>=0;e--)r[e]=Zn(r[e+1],r[e],i,`up`,a,o),r[e]=Qn(r[e+1],r[e],i,r[e-1],a)}return{layers:r}}r($n,`orderLayers`);function er(e,t,n){let i=n?.layerGap??Ot.DEFAULT_LAYER_GAP,a=n?.nodeGap??Ot.DEFAULT_NODE_GAP,o=n?.laneGap??a*2,s=n?.direction??`TB`,c=s===`LR`||s===`RL`,l=Object.create(null),u=Object.create(null),d=new Map((t.layout?.nodes??[]).filter(e=>e.isEdgeLabel).map(e=>[e.id,e])),f=r(e=>d.get(e)??t.nodeById.get(e),`getNode`),p=r(e=>f(e)?.width??0,`getWidth`),m=r(e=>f(e)?.height??0,`getHeight`),h=bn(t),g=new Map,_=r(e=>g.has(e)?g.get(e)??null:h(e),`topLaneOf`),v=Sn(t,n?.laneOrder),y=new Set;for(let t of e.layers)for(let e of t)y.add(h(e));let b=y.has(null),x=v.filter(e=>y.has(e)),S=[...b?[null]:[],...x],C=e.layers,w=new Map;for(let[e,t]of C.entries())for(let n of t)w.set(n,e);let T=[],E=[],D=[];for(let e of t.layout?.edges??[]){let t=e.labelNodeId,n=e.start,i=e.end;if(!t||!d.has(t)||n==null||i==null)continue;let a=w.get(n),o=w.get(i);if(a==null||o==null){D.push({labelId:t,near:a==null?i:n});continue}if(g.set(t,h(i)),a===o){let e=r(e=>S.indexOf(h(e)),`column`);T.push({labelId:t,rank:o,lane:h(i),side:n!==i&&e(n)<e(i)?`before`:`after`});continue}let s=Math.min(a,o),c=Math.max(a,o);E.push({labelId:t,start:n,end:i,gap:s+Math.floor((c-s-1)/2),crossesLanes:h(n)!==h(i)})}let O=C.map(e=>e.reduce((e,t)=>Math.max(e,m(t)),0));for(let{labelId:e,rank:t}of T)O[t]=Math.max(O[t],m(e));let k=C.map(()=>0);if(c)for(let e=0;e+1<C.length;e++){let t=C[e].reduce((e,t)=>Math.max(e,p(t)),0),n=C[e+1].reduce((e,t)=>Math.max(e,p(t)),0),r=O[e],a=O[e+1],o=r/2+a/2,s=(t+n)/2;k[e]=Math.max(0,s-o-i)}let ee=c?lt(t.layout?.nodes??[]):1,A=C.map(()=>0);for(let{labelId:e,gap:t}of E){let n=((c?p(e):m(e))+2*Ot.EDGE_LABEL_CLEARANCE)/ee;A[t]=Math.max(A[t],n)}for(let[e,t]of A.entries())k[e]+=t;let j=Object.create(null);for(let e of x)j[e]=0;b&&(j.null=0);for(let e of C){let t=Object.create(null),n=[];for(let r of e){let e=_(r);e===null?n.push(r):(t[e]||=[]).push(r)}for(let[e,n]of Object.entries(t)){let t=n.reduce((e,t)=>e+p(t),0)+a*Math.max(0,n.length-1);j[e]=Math.max(j[e]??0,t)}if(b&&n.length){let e=n.reduce((e,t)=>e+p(t),0)+a*Math.max(0,n.length-1);j.null=Math.max(j.null??0,e)}}let M=new Map;for(let e of E){let t=`${e.gap}:${_(e.labelId)}`,n=M.get(t);n?n.push(e):M.set(t,[e])}for(let e of M.values()){let t=_(e[0].labelId);if(t!==null){let n=e.reduce((e,t,n)=>e+p(t.labelId)+(n>0?a:0),0);j[t]=Math.max(j[t]??0,n)}}let N=new Map;for(let{labelId:e,rank:t,lane:n,side:r}of T){let i=`${t}:${n}:${r}`;N.set(i,(N.get(i)??0)+a+p(e))}let P=r((e,t,n)=>N.get(`${e}:${t}:${n}`)??0,`rowLabelSpan`);for(let{rank:e,lane:t}of T){let n=C[e].filter(e=>_(e)===t).reduce((e,t,n)=>e+p(t)+(n>0?a:0),0),r=Math.max(P(e,t,`before`),P(e,t,`after`)),i=t??`null`;j[i]=Math.max(j[i]??0,n+2*r)}let te=new Map;{let e=S.map(e=>(e===null?j.null:j[e])??0),t=-(e.reduce((e,t)=>e+t,0)+o*Math.max(0,S.length-1))/2;for(let n=0;n<S.length;n++){let r=S[n],i=e[n]??0,a=t+i/2;te.set(r,a),t+=i,n<S.length-1&&(t+=o)}}let ne=[],re=0;for(let[e,t]of C.entries()){let n=O[e]??0,r=new Map;for(let e of t){let t=_(e),n=r.get(t)??[];n.push(e),r.set(t,n)}for(let e of S){let t=r.get(e)??[];if(t.length===0)continue;let i=te.get(e);if(t.length===1){let e=t[0];l[e]=i,u[e]=re+n/2}else{let e=t.map(e=>p(e)),r=i-(e.reduce((e,t)=>e+t,0)+a*(t.length-1))/2;for(let[i,o]of t.entries()){let t=e[i];l[o]=r+t/2,u[o]=re+n/2,r+=t+a}}}let o=i+(k[e]??0);ne[e]=re+n+o/2,re+=n+o}let F=new Map;for(let{labelId:e,rank:t,lane:n,side:r}of T){let i=`${t}:${n}:${r}`;if(!F.has(i)){let e=C[t].filter(e=>_(e)===n).map(e=>r===`before`?l[e]-p(e)/2:l[e]+p(e)/2);F.set(i,r===`before`?Math.min(...e):Math.max(...e))}let o=p(e),s=F.get(i)+(r===`before`?-1:1)*(a+o/2);l[e]=s,u[e]=u[C[t].find(e=>_(e)===n)],F.set(i,s+o/2*(r===`before`?-1:1))}for(let e of M.values()){let t=e.map(({start:e,end:t,crossesLanes:n})=>n?l[t]:((l[e]??0)+(l[t]??0))/2),n=e.map((e,t)=>t).sort((e,n)=>t[e]-t[n]||e-n),i=[],o=-1/0;for(let r of n){let n=p(e[r].labelId);i[r]=Math.max(t[r],o+a+n/2),o=i[r]+n/2}let s=r(e=>e.reduce((e,t)=>e+t,0)/e.length,`mean`),c=s(t)-s(i);for(let[t,{labelId:n,gap:r}]of e.entries())l[n]=i[t]+c,u[n]=ne[r]}for(let{labelId:e,near:t}of D)l[e]=l[t]??0,u[e]=u[t]??0;let ie=new Map;for(let e of t.edges){let t=e.ref.id;ie.has(t)||ie.set(t,[]),ie.get(t).push(e)}for(let[,e]of ie){if(e.length===0)continue;let n=e[0].ref,r=n.start,i=n.end;if(r==null||i==null)continue;let a=Math.round(((l[r]??0)+(l[i]??0))/2),o=new Set;for(let t of e)o.add(t.src),o.add(t.dst);for(let e of o)e!==r&&e!==i&&t.nodeById.get(e)?.isDummy&&(l[e]=a)}return{x:l,y:u}}r(er,`assignCoordinates`);var tr=8;function nr(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}r(nr,`hashString`);function rr(e){let t=e>>>0;return()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}r(rr,`mulberry32`);function ir(e,t){let n=[...e],r=rr(t);for(let e=n.length-1;e>0;e--){let t=Math.floor(r()*(e+1));[n[e],n[t]]=[n[t],n[e]]}return n}r(ir,`deterministicShuffle`);function ar(e,t){let n=0;for(let[r,i]of e.entries())n+=Math.abs(r-(t.get(i)??r));return n}r(ar,`sourceDistance`);function or(e,t){let n=new Map;for(let[t,r]of e.entries())n.set(r,t);let r=0;for(let{a:e,b:i,weight:a}of t){let t=n.get(e),o=n.get(i);t!=null&&o!=null&&(r+=a*Math.abs(t-o))}return r}r(or,`laneArrangementCost`);function sr(e){let t=xn(e);if(t.length<2)return[];let n=new Map(t.map((e,t)=>[e,t])),r=bn(e),i=new Map;for(let t of e.layout.edges??[]){if(t.isLayoutOnly)continue;let a=typeof t.start==`string`?t.start:void 0,o=typeof t.end==`string`?t.end:void 0;if(!a||!o||!e.nodeById.has(a)||!e.nodeById.has(o))continue;let s=r(a),c=r(o);if(!s||!c||s===c)continue;let l=n.get(s),u=n.get(c);if(l==null||u==null)continue;let[d,f]=l<=u?[s,c]:[c,s],p=`${d}\0${f}`,m=i.get(p);m?m.weight++:i.set(p,{a:d,b:f,weight:1})}return[...i.values()]}r(sr,`buildWeightedLaneEdges`);function cr(e,t,n){let r=[...e],i=or(r,t),a=!0,o=0,s=Math.max(1,r.length);for(;a&&o<s;){a=!1,o++;for(let e=0;e+1<r.length;e++){[r[e],r[e+1]]=[r[e+1],r[e]];let n=or(r,t);n<i?(i=n,a=!0):[r[e],r[e+1]]=[r[e+1],r[e]]}}return{order:r,cost:i,sourceDistance:ar(r,n)}}r(cr,`greedySwitch`);function lr(e,t){return e.cost===t.cost?e.sourceDistance<t.sourceDistance:e.cost<t.cost}r(lr,`isBetterCandidate`);function ur(e,t,n){let r=[...t].sort((e,t)=>e.a===t.a?e.b.localeCompare(t.b):e.a.localeCompare(t.a)).map(({a:e,b:t,weight:n})=>`${e}:${t}:${n}`).join(`|`);return nr(`${e.join(`|`)}#${r}#${n}`)}r(ur,`seedForRestart`);function dr(e,t={}){let n=xn(e);if(n.length<2)return n;let r=sr(e);if(r.length===0)return n;let i=new Map(n.map((e,t)=>[e,t])),a=cr(n,r,i),o=Math.max(0,t.restarts??tr);for(let e=0;e<o;e++){let t=cr(ir(n,ur(n,r,e)),r,i);lr(t,a)&&(a=t)}return a.order}r(dr,`optimizeTopLaneOrder`);function fr(e,t){let n=t?.ignoreCrossLaneEdges??!0,r=t?.optimizeRanksByCrossings??!0,i=sn(e),a=t?.automaticLaneOrdering?dr(i,{restarts:tr}):void 0,o=vn(i),s=o.acyclic,{layering:c,graphWithDummies:l}=Wn(n?Un(s,{compactSingleInput:t?.compactSingleInput??Dt.DEFAULT_COMPACT_SINGLE_INPUT,ignoreCrossLaneEdges:!0,direction:t?.direction}):Vn(s,{compactSingleInput:t?.compactSingleInput??Dt.DEFAULT_COMPACT_SINGLE_INPUT,ignoreCrossLaneEdges:!1,optimizeRanksByCrossings:r}),s),u=$n(c,l,{laneOrder:a}),d=er(u,l,{layerGap:t?.layerGap,nodeGap:t?.nodeGap,direction:t?.direction,laneOrder:a});return{acyclic:s,reversed:o.reversed,layering:c,ordered:u,coordinates:d}}r(fr,`sugiyamaLayout`);var $=Et.EPSILON,pr=8,mr=15,hr=15,gr=25,_r=20,vr=10;function yr(e,t,n){let r=e.x??0,i=e.y??0,a=t.x-r,o=t.y-i,s=Math.abs(a),c=Math.abs(o);return s<$&&c<$?n:c>$&&c*3>=s?o>0?`bottom`:`top`:s>$?a>0?`right`:`left`:n}r(yr,`chooseOrthogonalSide`);var br=r(e=>typeof e==`number`&&Number.isFinite(e)&&e>0,`isDrawableSize`);function xr(e,t){let n=e.metadata?.drawnExtent;return{w:br(n?.width)?n.width:e.width??t,h:br(n?.height)?n.height:e.height??t}}r(xr,`drawnSize`);function Sr(e,t){return Math.abs(e.to-t.from)<$||Math.abs(e.to-t.to)<$?e.to:e.from}r(Sr,`sharedLineEndpointCoord`);function Cr(e,t){return e.orient===`vertical`?{x:e.coord,y:t}:{x:t,y:e.coord}}r(Cr,`pointOnLine`);function wr(e,t){let n=e.nodes??[],i=e.edges??[],a=[];for(let e of i)e.isLayoutOnly||a.push({...e,__originalEdge:e});let o=new Map,c=new Map,l=[],u=t===`LR`;for(let e of n)o.set(e.id,e);let d=s(n),f=n.filter(e=>d.isLane(e.id));for(let e of f){let t={id:e.id},i=r(e=>{c.set(e.id,t),n.filter(t=>t.parentId===e.id).forEach(i)},`assignLane`);i(e)}let m=p(n),h=n.filter(e=>!e.isGroup&&!e.isEdgeLabel&&!m.has(e.id)).map(e=>{let t=e.width??10,n=e.height??10,r=e.x??0,i=e.y??0,a=pr;return{nodeId:e.id,minX:r-t/2-a,maxX:r+t/2+a,minY:i-n/2-a,maxY:i+n/2+a,visualXHalfExtent:u?n/2+a:t/2+a}}),g=r((e,t,n,r)=>{let i=l.find(n=>n.orientation===e&&Math.abs(n.coord-t)<1);return i||(i={id:`pipe-${e}-${t.toFixed(0)}`,orientation:e,coord:t,spanMin:n,spanMax:r,tracks:[]},l.push(i)),i.spanMin=Math.min(i.spanMin,n),i.spanMax=Math.max(i.spanMax,r),i},`getOrAddPipe`),_=r((e,t)=>{let{w:n,h:r}=xr(e,10),i=e.x??0,a=e.y??0;switch(t){case`top`:return{x:i,y:a-r/2};case`bottom`:return{x:i,y:a+r/2};case`left`:return{x:i-n/2,y:a};case`right`:return{x:i+n/2,y:a}}},`portForSide`),v=r((e,t,n)=>_(e,yr(e,t,n?`bottom`:`top`)),`getOrthogonalPort`),y=[],b=[],x=new Set,S=1e3,C=r((e,t,n)=>{if(y.length===0)return 0;let r=Math.abs(t.y-n.y)<$,i=Math.abs(t.x-n.x)<$;if(!r&&!i)return 0;let a=0;if(r){let r=t.y,i=Math.min(t.x,n.x)-$,o=Math.max(t.x,n.x)+$;if(o<=i)return 0;for(let t of y)t.edgeIndex!==e&&t.orientation===`vertical`&&(t.pipe.coord<i||t.pipe.coord>o||t.from-$<=r&&t.to+$>=r&&(a+=S))}else if(i){let r=t.x,i=Math.min(t.y,n.y)-$,o=Math.max(t.y,n.y)+$;if(o<=i)return 0;for(let t of y)t.edgeIndex!==e&&t.orientation===`horizontal`&&(t.pipe.coord<i||t.pipe.coord>o||t.from-$<=r&&t.to+$>=r&&(a+=S))}return a},`crossingPenalty`),w=a.map((e,t)=>{if(!e.start||!e.end)return{idx:t,crossLane:0,dx:0,dy:0};let n=o.get(e.start),r=o.get(e.end),i=c.get(e.start),a=c.get(e.end);return{idx:t,crossLane:i&&a&&i.id!==a.id?1:0,dx:n&&r?Math.abs((r.x??0)-(n.x??0)):0,dy:n&&r?Math.abs((r.y??0)-(n.y??0)):0}}).sort((e,t)=>{if(e.crossLane!==t.crossLane)return t.crossLane-e.crossLane;let n=e.dx+e.dy,r=t.dx+t.dy;return Math.abs(n-r)>1?n-r:e.idx-t.idx}).map(e=>e.idx),T=r((e,t,n,r)=>{let i=Math.min(e.x,t.x),a=Math.max(e.x,t.x),o=Math.min(e.y,t.y),s=Math.max(e.y,t.y);return!!h.find(c=>n&&c.nodeId===n||r&&c.nodeId===r?!1:Math.abs(e.x-t.x)>$?c.minY<e.y&&c.maxY>e.y&&c.maxX>i&&c.minX<a:c.minX<e.x&&c.maxX>e.x&&c.maxY>o&&c.minY<s)},`isSegmentBlocked`),E=new Map,D=new Map;for(let e of a)e.start&&e.end&&e.start!==e.end&&(D.set(e.start,(D.get(e.start)??0)+1),D.set(e.end,(D.get(e.end)??0)+1));let O=r((e,t)=>yr(e,t,`bottom`),`determineSide`),k=new Map;for(let[e,t]of a.entries()){if(!t.start||!t.end||t.start===t.end||t.points&&t.points.length>0)continue;let n=o.get(t.start),r=o.get(t.end);if(!n||!r)continue;let i=(r.x??0)-(n.x??0),a=(r.y??0)-(n.y??0);k.set(e,{edgeIdx:e,srcId:t.start,dstId:t.end,srcSide:O(n,{x:r.x??0,y:r.y??0}),dstSide:O(r,{x:n.x??0,y:n.y??0}),absDx:Math.abs(i),absDy:Math.abs(a),dxSign:Math.sign(i),dySign:Math.sign(a)})}let ee=r(e=>e.srcSide===`top`||e.srcSide===`bottom`?e.absDx===0?1/0:e.absDy/e.absDx:e.absDy===0?1/0:e.absDx/e.absDy,`preferenceStrength`),A=r(e=>e.srcSide===`top`||e.srcSide===`bottom`?e.dxSign===0?[`right`,`left`]:[e.dxSign>0?`right`:`left`]:e.dySign===0?[`bottom`,`top`]:[e.dySign>0?`bottom`:`top`],`secondarySides`),j=r(e=>A(e)[0],`secondarySide`),M=new Map;for(let e of k.values()){let t=`${e.srcId}:${e.srcSide}`;M.has(t)||M.set(t,[]),M.get(t).push(e)}let N=new Map,P=r((e,t)=>`${e}:${t}`,`loadKey`);for(let e of k.values())N.set(P(e.srcId,e.srcSide),(N.get(P(e.srcId,e.srcSide))??0)+1),N.set(P(e.dstId,e.dstSide),(N.get(P(e.dstId,e.dstSide))??0)+1);for(let e of M.values())if(!(e.length<2)){e.sort((e,t)=>{let n=ee(e),r=ee(t);return Math.abs(n-r)>1e-9?r-n:e.edgeIdx-t.edgeIdx});for(let t=1;t<e.length;t++){let n=e[t],r=N.get(P(n.srcId,n.srcSide))??0,i=A(n).reduce((e,t)=>(N.get(P(n.srcId,t))??0)<(N.get(P(n.srcId,e))??0)?t:e),a=N.get(P(n.srcId,i))??0;a>=r||(N.set(P(n.srcId,n.srcSide),r-1),N.set(P(n.srcId,i),a+1),n.srcSide=i)}}let te=r(e=>{let t=e?.shape;return t===`question`||t===`diamond`},`isDiamondNode`),ne=new Map;for(let e of k.values())ne.has(e.dstId)||ne.set(e.dstId,new Set),ne.get(e.dstId).add(e.dstSide);for(let e of k.values()){if(!te(o.get(e.srcId)))continue;let t=ne.get(e.srcId);if(!t?.has(e.srcSide))continue;let n=j(e);if(t.has(n)||(N.get(P(e.srcId,n))??0)>0)continue;let r=N.get(P(e.srcId,e.srcSide))??0;N.set(P(e.srcId,e.srcSide),Math.max(0,r-1)),N.set(P(e.srcId,n),1),e.srcSide=n}let re=r(e=>{let t=e?.shape;return t===`hexagon`||t===`notch-pent`},`hasVertexFaces`),F=new Map;for(let e of k.values())F.has(e.srcId)||F.set(e.srcId,new Set),F.get(e.srcId).add(e.srcSide);let ie=r(e=>e.dstSide===`top`||e.dstSide===`bottom`?e.dxSign>=0?`left`:`right`:e.dySign>=0?`top`:`bottom`,`secondaryDstSide`);for(let e of k.values()){if(!re(o.get(e.dstId)))continue;let t=F.get(e.dstId);if(!t?.has(e.dstSide))continue;let n=ie(e);if(t.has(n)||(N.get(P(e.dstId,n))??0)>0)continue;let r=N.get(P(e.dstId,e.dstSide))??0;N.set(P(e.dstId,e.dstSide),Math.max(0,r-1)),N.set(P(e.dstId,n),1),e.dstSide=n;let i=e.dySign>=0?`bottom`:`top`;if((n===`top`||n===`bottom`)&&ne.get(e.srcId)?.has(e.srcSide)&&!ne.get(e.srcId)?.has(i)&&(N.get(P(e.srcId,i))??0)===0){let t=N.get(P(e.srcId,e.srcSide))??0;N.set(P(e.srcId,e.srcSide),Math.max(0,t-1)),N.set(P(e.srcId,i),1),e.srcSide=i}}for(let e of k.values()){let{edgeIdx:t,srcId:n,dstId:r,srcSide:i,dstSide:a}=e,s=o.get(n),c=o.get(r),l=`${n}:${i}:src`,u=i===`top`||i===`bottom`?c.x??0:c.y??0;E.has(l)||E.set(l,[]),E.get(l).push({edgeIdx:t,oppositeCoord:u});let d=`${r}:${a}:dst`,f=a===`top`||a===`bottom`?s.x??0:s.y??0;E.has(d)||E.set(d,[]),E.get(d).push({edgeIdx:t,oppositeCoord:f})}let ae=new Map;for(let[e,t]of E){if(t.length<2)continue;t.sort((e,t)=>e.oppositeCoord-t.oppositeCoord);let n=e.split(`:`),r=n.slice(0,-2).join(`:`),i=n[n.length-2],a=n[n.length-1],s=o.get(r);if(!s)continue;let c=i===`left`||i===`right`,l=xr(s,10),u=c?l.h:l.w,d=s.shape,f=d===`question`||d===`diamond`?u*.3:u,p=Math.min(20,f/(t.length-1),Math.max(8,f/(t.length+1))),m=-(p*(t.length-1))/2;for(let[e,n]of t.entries()){let t=m+e*p,r=`${n.edgeIdx}:${a}`;ae.set(r,t)}}let I=r(e=>!!a[e]?.labelNodeId,`edgeHasLabelNode`),L=r((e,t)=>e?(E.get(`${e}:${t}:src`)??[]).some(({edgeIdx:e})=>I(e))||(E.get(`${e}:${t}:dst`)??[]).some(({edgeIdx:e})=>I(e)):!1,`faceHasLabelNode`),R=r((e,t,n)=>t===`top`||t===`bottom`?{x:e.x+n,y:e.y}:{x:e.x,y:e.y+n},`applyPortOffset`),z=r((e,t,n)=>{let r=k.get(e),i={x:n.x??0,y:n.y??0},a={x:t.x??0,y:t.y??0},o=r?.srcSide??O(t,i),s=r?.dstSide??O(n,a),c=r?_(t,r.srcSide):v(t,i,!0),l=r?_(n,r.dstSide):v(n,a,!1),u=ae.get(`${e}:src`),d=ae.get(`${e}:dst`);return u!==void 0&&(c=R(c,o,u)),d!==void 0&&(l=R(l,s,d)),{pSrcPort:c,pDstPort:l,srcSide:o,dstSide:s}},`portsForEdge`);for(let e of w){let t=a[e];if(b[e]=[],!t.start||!t.end||t.points&&t.points.length>0||t.start===t.end)continue;let n=o.get(t.start),i=o.get(t.end);if(!n||!i)continue;let{pSrcPort:s,pDstPort:c,srcSide:d,dstSide:f}=z(e,n,i),p={...s},m={...c},_=d===`top`||d===`bottom`,v=f===`top`||f===`bottom`;_?p.y=s.y>(n.y??0)?s.y+_r:s.y-_r:p.x=s.x>(n.x??0)?s.x+_r:s.x-_r,v?m.y=c.y>(i.y??0)?c.y+_r:c.y-_r:m.x=c.x>(i.x??0)?c.x+_r:c.x-_r;let S=r((e,t)=>{for(let n of h)if(!t.includes(n.nodeId)&&e.x>n.minX&&e.x<n.maxX&&e.y>n.minY&&e.y<n.maxY)return{inside:!0,obstacle:n};return{inside:!1}},`isPointInObstacle`),w=r((e,t,n,r,i)=>{if(i){let i=e.y>(t.y??0);return{x:(n.x??0)>=e.x?r.maxX+mr:r.minX-mr,y:i?r.maxY+hr:r.minY-hr,leavesPositiveSide:i}}let a=e.x>(t.x??0),o=(n.y??0)>=e.y;return{x:a?r.maxX+mr:r.minX-mr,y:o?r.maxY+hr:r.minY-hr,leavesPositiveSide:a}},`obstacleDetour`),O=[],k=[t.start,t.end],ee=S(p,k);if(ee.inside&&ee.obstacle){let e=ee.obstacle;if(_){let t=w(s,n,i,e,!0);p.x=t.x,p.y=t.y;let r=t.leavesPositiveSide?Math.min(e.minY-2,s.y+_r):Math.max(e.maxY+2,s.y-_r);O=[{x:s.x,y:r},{x:t.x,y:r},{x:t.x,y:t.y}]}else{let t=w(s,n,i,e,!1),r=t.leavesPositiveSide?Math.min(e.minX-2,s.x+_r):Math.max(e.maxX+2,s.x-_r);p.x=t.x,p.y=t.y,O=[{x:r,y:s.y},{x:r,y:t.y},{x:t.x,y:t.y}]}}let A=[],j=S(m,k);if(j.inside&&j.obstacle){let e=j.obstacle;if(v){let t=w(c,i,n,e,!0);m.x=t.x,m.y=t.y,A=[{x:t.x,y:t.y},{x:c.x,y:t.y}]}else{let t=w(c,i,n,e,!1);m.x=t.x,m.y=t.y,A=[{x:t.x,y:t.y},{x:t.x,y:c.y}]}}if(O.length===0&&A.length===0){let n=mr,r=Math.abs(p.x-m.x)<n,i=Math.abs(p.y-m.y)<n,a=ae.get(`${e}:src`)!==void 0||ae.get(`${e}:dst`)!==void 0,o=(E.get(`${t.start??``}:${d}:src`)?.length??0)+(E.get(`${t.start??``}:${d}:dst`)?.length??0),l=(E.get(`${t.end??``}:${f}:src`)?.length??0)+(E.get(`${t.end??``}:${f}:dst`)?.length??0),u=o>1||l>1,h=D.get(t.start??``)??0,g=D.get(t.end??``)??0,_=o>1&&L(t.start,d)||l>1&&L(t.end,f);if((r||i)&&!a&&(!u||u&&!_&&(o<=1||h<=2)&&(l<=1||g<=2))&&!T(s,c,t.start,t.end)){t.points=[{...s},{...p},{...m},{...c}],x.add(e);let n=i?`horizontal`:`vertical`,r=i?s.y:s.x,a=i?Math.min(s.x,c.x):Math.min(s.y,c.y),o=i?Math.max(s.x,c.x):Math.max(s.y,c.y),l={id:`fast-path-${n}-${r.toFixed(0)}-${e}`,orientation:n,coord:r,spanMin:a,spanMax:o,tracks:[]};y.push({edgeIndex:e,segmentIndex:0,orientation:n,pipe:l,trackIndex:0,from:a,to:o});continue}}p.x=g(`vertical`,p.x,p.y,p.y).coord,m.x=g(`vertical`,m.x,m.y,m.y).coord;let M=Math.min(p.x,m.x)-50,N=Math.max(p.x,m.x)+50,P=Math.min(p.y,m.y)-50,te=Math.max(p.y,m.y)+50;for(let e of h){let t=Math.min(p.x,m.x),n=Math.max(p.x,m.x),r=Math.min(p.y,m.y),i=Math.max(p.y,m.y);e.minX<n&&e.maxX>t&&e.minY<i&&e.maxY>r&&(M=Math.min(M,e.minX-gr),N=Math.max(N,e.maxX+gr),P=Math.min(P,e.minY-gr),te=Math.max(te,e.maxY+gr))}for(let e of h){if(e.maxX<M||e.minX>N||e.maxY<P||e.minY>te)continue;let t=mr;g(`horizontal`,e.minY-t,M,N),g(`horizontal`,e.maxY+t,M,N);let n=hr;g(`vertical`,e.minX-n,P,te),g(`vertical`,e.maxX+n,P,te)}g(`horizontal`,p.y,M,N),g(`horizontal`,m.y,M,N);let ne=l.filter(e=>e.orientation===`horizontal`&&e.coord>=P&&e.coord<=te),re=l.filter(e=>e.orientation===`vertical`&&e.coord>=M&&e.coord<=N),F=r((e,t)=>`${e.toFixed(1)},${t.toFixed(1)}`,`getKey`),ie=F(p.x,p.y),I=F(m.x,m.y),R=new Map,B=new Map,V=new Map,H=new Set,U=[];R.set(ie,0),V.set(ie,`n`),U.push({key:ie,f:Math.hypot(m.x-p.x,m.y-p.y),pt:p}),H.add(ie);let W=[],oe=r((e,n)=>T(e,n,t.start,t.end),`checkSegmentBlocked`),se={x:m.x,y:p.y},ce=oe(p,se),G=oe(se,m),le=ce||G,ue={x:p.x,y:m.y},de=oe(p,ue),fe=oe(ue,m);if(le?de||fe||(W=Math.abs(p.x-m.x)<$?[p,m]:[p,ue,m]):W=Math.abs(p.y-m.y)<$||Math.abs(p.x-m.x)<$?[p,m]:[p,se,m],W.length===0)for(;U.length>0;){U.sort((e,t)=>e.f-t.f);let n=U.shift();if(H.delete(n.key),n.key===I){let e=I,t=m;for(W=[t];B.has(e);){let n=B.get(e);W.unshift(n),t=n,e=F(n.x,n.y)}break}let r=n.pt.x,i=n.pt.y,a=re.sort((e,t)=>e.coord-t.coord),o=a.findIndex(e=>Math.abs(e.coord-r)<1),s=ne.sort((e,t)=>e.coord-t.coord),c=s.findIndex(e=>Math.abs(e.coord-i)<1),l=[];o>0&&l.push({x:a[o-1].coord,y:i}),o>=0&&o<a.length-1&&l.push({x:a[o+1].coord,y:i}),c>0&&l.push({x:r,y:s[c-1].coord}),c>=0&&c<s.length-1&&l.push({x:r,y:s[c+1].coord});for(let a of l){let o=Math.min(r,a.x),s=Math.max(r,a.x),c=Math.min(i,a.y),l=Math.max(i,a.y);if(h.some(e=>e.nodeId===t.start||e.nodeId===t.end?!1:o===s?e.minX<r&&e.maxX>r&&e.maxY>c&&e.minY<l:e.minY<i&&e.maxY>i&&e.maxX>o&&e.minX<s))continue;let u=F(a.x,a.y),d=Math.abs(a.x-r)+Math.abs(a.y-i),f=C(e,n.pt,a),g=0,_=m.x-p.x,v=m.y-p.y,y=a.x-r,b=a.y-i;(v>10&&b<-5||v<-10&&b>5)&&(g=Math.abs(b)*100),(_>10&&y<-5||_<-10&&y>5)&&(g+=Math.abs(y)*50);let x=0,S=V.get(n.key)??`n`,w=Math.abs(y)>$?`h`:`v`;S!==`n`&&S!==w&&(x=50);let T=d+f+g+x,E=(R.get(n.key)??1/0)+T,D=Math.abs(m.x-a.x)+Math.abs(m.y-a.y);if(E<(R.get(u)??1/0)){if(B.set(u,n.pt),R.set(u,E),V.set(u,w),!H.has(u))U.push({key:u,f:E+D,pt:a}),H.add(u);else{let e=U.findIndex(e=>e.key===u);e!==-1&&(U[e].f=E+D)}}}}if(W.length===0&&(W=[p,{x:p.x,y:m.y},m]),W.length>4){let e=W[0],t=W[W.length-1],n=Math.min(e.x,t.x),i=Math.max(e.x,t.x),a=Math.min(e.y,t.y),o=Math.max(e.y,t.y);for(let e of W)n=Math.min(n,e.x),i=Math.max(i,e.x),a=Math.min(a,e.y),o=Math.max(o,e.y);let s=i>Math.max(e.x,t.x),c=n<Math.min(e.x,t.x);if(u){let r=hr;if(s){let n=Math.max(e.x,t.x),a=Math.min(e.y,t.y),o=Math.max(e.y,t.y),s=h.filter(e=>e.minX<n&&e.maxX>n&&e.minY<o&&e.maxY>a);if(s.length>0){let n=Math.max(e.x,t.x);for(let e of s){let t=(e.minX+e.maxX)/2;if(e.visualXHalfExtent===void 0||isNaN(e.visualXHalfExtent))continue;let i=t+e.visualXHalfExtent+r;n=Math.max(n,i)}isNaN(n)||(i=n)}}if(c){let i=h.filter(n=>n.minX<Math.min(e.x,t.x)+r&&n.minY<Math.max(e.y,t.y)&&n.maxY>Math.min(e.y,t.y));if(i.length>0){let a=Math.min(e.x,t.x);for(let e of i){let t=(e.minX+e.maxX)/2-e.visualXHalfExtent-r;a=Math.min(a,t)}n=a}}}let l=r(n=>{let r=t.y>e.y,i=h.filter(n=>{let r=Math.min(e.x,t.x)<n.maxX&&Math.max(e.x,t.x)>n.minX,i=Math.min(e.y,t.y)<n.maxY&&Math.max(e.y,t.y)>n.minY;return r&&i}),a=i;if(u&&i.length>0){let e=i.filter(e=>e.minX<n&&e.maxX>n);e.length>0&&(a=e)}if(a.length===0)return t.y;let o=mr;if(r){let e=Math.max(...a.map(e=>e.maxY))+o;if(e<t.y-$)return e}else{let e=Math.min(...a.map(e=>e.minY))-o;if(e>t.y+$)return e}return t.y},`findBestReturnY`),d=r(n=>{let r=l(n),i={x:n,y:e.y},a={x:n,y:r},o={x:t.x,y:r},s=oe(e,i),c=oe(i,a),u=oe(a,o),d=r!==t.y&&oe(o,t);return!s&&!c&&!u&&!d?Math.abs(r-t.y)<$?[e,i,a,t]:[e,i,a,o,t]:null},`trySimplifyWithDetourX`),f=s&&!c?d(i):c&&!s?d(n):null;f&&(W=f)}let K=[s,...O,...W,...A.reverse(),c];if(K.length>=3){let e=K[K.length-1],t=K[K.length-2],n=K[K.length-3],r=Math.abs(n.y-t.y)<$&&Math.abs(t.y-e.y)<$,i=Math.abs(n.x-t.x)<$&&Math.abs(t.x-e.x)<$;if(r){let r=Math.sign(t.x-n.x),i=Math.sign(e.x-n.x);r!==0&&r===i&&Math.abs(t.x-n.x)>Math.abs(e.x-n.x)&&K.splice(-2,1)}else if(i){let r=Math.sign(t.y-n.y),i=Math.sign(e.y-n.y);r!==0&&r===i&&Math.abs(t.y-n.y)>Math.abs(e.y-n.y)&&K.splice(-2,1)}}let pe=[K[0]];for(let e=1;e<K.length-1;e++){if(e===1){pe.push(K[e]);continue}let t=pe[pe.length-1],n=K[e],r=K[e+1];if(Math.abs(t.y-n.y)<$&&Math.abs(n.y-r.y)<$){if(n.x>t.x!=r.x>n.x){pe.push(n);continue}}else if(Math.abs(t.x-n.x)<$&&Math.abs(n.x-r.x)<$){if(n.y>t.y!=r.y>n.y){pe.push(n);continue}}else pe.push(n)}pe.push(K[K.length-1]);for(let t=0;t<pe.length-1;t++){let n=pe[t],r=pe[t+1],i=Math.abs(n.x-r.x)<$?`vertical`:`horizontal`,a=i===`vertical`?n.x:n.y,o=i===`vertical`?Math.min(n.y,r.y):Math.min(n.x,r.x),s=i===`vertical`?Math.max(n.y,r.y):Math.max(n.x,r.x),c=g(i,a,o,s),l={edgeIndex:e,segmentIndex:t,orientation:i,pipe:c,trackIndex:0,from:o,to:s};y.push(l),b[e].push(y.length-1),c.tracks[0]||(c.tracks[0]={index:0,coord:c.coord,segments:[]}),c.tracks[0].segments.push({edgeIndex:e,segmentIndex:t,from:o,to:s})}}let B=r((e,t)=>e.from<t.to&&t.from<e.to,`segmentsOverlap`),V=r((e,t,n,r)=>{let i=!r.segments.some(n=>(n.edgeIndex!==t.edgeIndex||n.segmentIndex!==t.segmentIndex)&&B(n,e)),a=!n.segments.some(n=>(n.edgeIndex!==e.edgeIndex||n.segmentIndex!==e.segmentIndex)&&B(n,t));return i&&a?(e.trackIndex=r.index,t.trackIndex=n.index,n.segments=[...n.segments.filter(t=>t.edgeIndex!==e.edgeIndex||t.segmentIndex!==e.segmentIndex),{edgeIndex:t.edgeIndex,segmentIndex:t.segmentIndex,from:t.from,to:t.to}],r.segments=[...r.segments.filter(e=>e.edgeIndex!==t.edgeIndex||e.segmentIndex!==t.segmentIndex),{edgeIndex:e.edgeIndex,segmentIndex:e.segmentIndex,from:e.from,to:e.to}],!0):!1},`trySwapSegmentsAcrossTracks`),H=r(e=>{let t=e.tracks.length;return e.tracks[t]={index:t,coord:e.coord,segments:[]},t},`createNewTrack`),U=r((e,t)=>{let n=e.pipe.tracks[e.trackIndex];n.segments=n.segments.filter(t=>t.edgeIndex!==e.edgeIndex||t.segmentIndex!==e.segmentIndex),e.trackIndex=t,e.pipe.tracks[t].segments.push({edgeIndex:e.edgeIndex,segmentIndex:e.segmentIndex,from:e.from,to:e.to})},`moveSegmentToTrack`),W=r((e,t)=>{let n=b[e.edgeIndex];for(let r of n){let n=y[r];n.pipe===e.pipe&&U(n,t)}},`moveSegmentChainToTrack`),oe=r(e=>{let t=b[e.edgeIndex],n=t.indexOf(y.indexOf(e)),r=[];return n>0&&r.push(y[t[n-1]]),n<t.length-1&&r.push(y[t[n+1]]),r},`getAdjacentSegmentsAlongEdge`),se=r((e,t)=>{if(e.orientation===t.orientation)return!1;let n=e.orientation===`horizontal`?e:t,r=e.orientation===`horizontal`?t:e;return r.pipe.coord>n.from&&r.pipe.coord<n.to&&n.pipe.coord>r.from&&n.pipe.coord<r.to},`haveAnyCrossing`),ce=r((e,t)=>{for(let n of e.tracks)if(!n.segments.some(e=>(e.edgeIndex!==t.edgeIndex||e.segmentIndex!==t.segmentIndex)&&B(e,t)))return n.index;return-1},`findAvailableTrack`),G=r((e,t)=>{if(e.trackIndex===t.trackIndex)return B(e,t);let n=oe(e),r=oe(t);return n.some(e=>r.some(t=>se(e,t)))},`segmentsConflict`),le=r((e,t,n)=>{if(V(e,t,e.pipe.tracks[e.trackIndex],t.pipe.tracks[t.trackIndex]))return;let r=ce(e.pipe,t);n(t,r===-1?H(e.pipe):r)},`resolveTrackConflict`),ue=r(e=>{let t=0;for(let n=0;n<e.length;n++)for(let r=n+1;r<e.length;r++){let i=e[n],a=e[r];i.pipe===a.pipe&&G(i,a)&&(t++,le(i,a,W))}return t},`resolveHandleConflicts`),de=new Map,fe=r(e=>{if(de.has(e))return de.get(e);let t=b[e];if(t.length===0){let t={dest:0,deviation:0,base:0,delta:0};return de.set(e,t),t}let n=y[t[0]].pipe.coord,r=n;for(let e=1;e<t.length;e++){let i=y[t[e]];if(i.orientation===`horizontal`){let e=i.from,t=i.to;r=Math.abs(e-n)>Math.abs(t-n)?e:t;break}}let i=Math.abs(r-n),a={dest:r,deviation:i,base:n,delta:r-n};return de.set(e,a),a},`getDestInfo`),K=r(()=>{let e=0,t=new Map;for(let[e,n]of a.entries())b[e].length!==0&&n.start&&(t.has(n.start)||t.set(n.start,[]),t.get(n.start).push(e));let n=r(e=>{let t=a[e];if(!t.start||!t.end)return 0;let n=o.get(t.start),r=o.get(t.end);if(!n||!r)return 0;let i=(r.x??0)-(n.x??0),s=(r.y??0)-(n.y??0);return Math.abs(i)+Math.abs(s)},`getEdgeDistance`);for(let r of t.values()){r.sort((e,t)=>{let r=fe(e),i=fe(t);if(Math.abs(r.deviation-i.deviation)>1)return r.deviation-i.deviation;if(Math.abs(r.dest-i.dest)>1)return r.dest-i.dest;let a=n(e),o=n(t);if(Math.abs(a-o)>1)return o-a;let s=b[e].length,c=b[t].length;if(s!==c)return s-c;if(s===1){let n=b[e][0],r=b[t][0];if(y[n]&&y[r]){let e=y[n],t=y[r],i=Math.abs(e.to-e.from),a=Math.abs(t.to-t.from);if(Math.abs(i-a)>1)return i-a}}return 0});let t=r.map(e=>y[b[e][0]]);e+=ue(t)}return e},`fixSourceHandleCrossings`),pe=r(()=>{let e=0,t=new Map;for(let[e,n]of a.entries())b[e].length!==0&&n.end&&(t.has(n.end)||t.set(n.end,[]),t.get(n.end).push(e));for(let n of t.values()){n.sort((e,t)=>{let n=r(e=>{let t=b[e];if(t.length<2)return 0;let n=y[t[t.length-2]];return Math.abs(n.to-n.from)},`getDist`),i=n(e),a=n(t);return Math.abs(i-a)>.1?i-a:e-t});let t=n.map(e=>y[b[e][b[e].length-1]]);e+=ue(t)}return e},`fixTargetHandleCrossings`),me=r(()=>{let e=0;for(let t of l){let n=[];for(let e of t.tracks)for(let t of e.segments){let e=b[t.edgeIndex].find(e=>y[e].segmentIndex===t.segmentIndex);e!==void 0&&n.push(y[e])}n.sort((e,t)=>e.edgeIndex-t.edgeIndex||e.segmentIndex-t.segmentIndex);for(let t=0;t<n.length;t++)for(let r=t+1;r<n.length;r++){let i=n[t],a=n[r];G(i,a)&&(e++,le(i,a,U))}}return e},`fixPipeCrossings`),q=0;for(;q<10;){let e=0;if(e+=K(),e+=pe(),e+=me(),e===0)break;q++}let he=new Map;for(let e of l){let t=[];e.tracks.forEach(e=>{e.segments.forEach(n=>{t.push({edgeIndex:n.edgeIndex,segmentIndex:n.segmentIndex,trackIndex:e.index,from:n.from,to:n.to})})}),t.sort((e,t)=>e.from-t.from);let n=[];if(t.length>0){let e=[t[0]],r=t[0].to;for(let i=1;i<t.length;i++){let a=t[i];a.from<r?(e.push(a),r=Math.max(r,a.to)):(n.push(e),e=[a],r=a.to)}n.push(e)}for(let t of n){let n=new Set;t.forEach(e=>n.add(e.trackIndex));let i=new Map;t.forEach(e=>{let t=fe(e.edgeIndex);i.set(e.trackIndex,(i.get(e.trackIndex)??0)+t.delta)});let a=[...n].filter(e=>(i.get(e)??0)<-1),o=[...n].filter(e=>(i.get(e)??0)>1),s=[...n].filter(e=>Math.abs(i.get(e)??0)<=1);a.sort((e,t)=>(i.get(t)??0)-(i.get(e)??0)),o.sort((e,t)=>(i.get(e)??0)-(i.get(t)??0));let c=r((n,r)=>{t.filter(e=>e.trackIndex===n).forEach(t=>{let n=x.has(t.edgeIndex)?e.coord:r;he.set(`${t.edgeIndex}-${t.segmentIndex}`,n)})},`assignCoord`),l=0;for(let t of a)l++,c(t,e.coord-l*vr);if(s.length===0&&n.size>0){let e=[...n].sort((e,t)=>Math.abs(i.get(e)??0)-Math.abs(i.get(t)??0))[0],t=a.indexOf(e);t!==-1&&a.splice(t,1);let r=o.indexOf(e);r!==-1&&o.splice(r,1),s.push(e)}let u=0;for(let t of s){if(u===0)c(t,e.coord);else{let n=u%2==1?1:-1,r=Math.ceil(u/2);c(t,e.coord+n*r*vr*.5)}u++}let d=0;for(let t of o)d++,c(t,e.coord+d*vr)}}for(let[e,t]of a.entries()){let n=b[e]??[];if(n.length===0)continue;let r=[],{pSrcPort:i,pDstPort:a}=z(e,o.get(t.start),o.get(t.end)),s=n.map(e=>{let t=y[e],n=he.get(`${t.edgeIndex}-${t.segmentIndex}`)??t.pipe.coord;return{orient:t.orientation,coord:n,from:t.from,to:t.to}});r.push(i);for(let e=0;e<s.length;e++){let t=s[e],n=r[r.length-1],i=t.orient===`vertical`?n.y:n.x,a=t.orient===`vertical`?n.x:n.y,o=s[e+1],c=e<s.length-1;if(Math.abs(a-t.coord)>$&&r.push(Cr(t,i)),c&&o.orient===t.orient){if(Math.abs(t.coord-o.coord)>$){let e=t.orient===`vertical`?(i+o.from)/2:Sr(t,o);r.push(Cr(t,e),Cr(o,e))}else(e===0||e===s.length-2)&&r.push(Cr(t,Sr(t,o)))}else if(c)r.push(Cr(t,o.coord));else{let e=Math.abs(t.from-i)<Math.abs(t.to-i)?t.to:t.from;r.push(Cr(t,e))}}let c=r[r.length-1];(Math.abs(c.x-a.x)>$||Math.abs(c.y-a.y)>$)&&r.push(a);let l=r[0];l&&(Math.abs(l.x-i.x)>$||Math.abs(l.y-i.y)>$)&&r.unshift(i);let u=[];r.length>0&&u.push(r[0]);for(let e=1;e<r.length;e++){let t=r[e],n=u[u.length-1];(Math.abs(t.x-n.x)>$||Math.abs(t.y-n.y)>$)&&u.push(t)}t.points=u}for(let e of a){let t=e.__originalEdge;t&&e.points&&(t.points=e.points)}e.edges=(e.edges??[]).filter(e=>!e.isLayoutOnly);let ge=r((e,t)=>{let n=t.x??0,r=t.y??0,{w:i,h:a}=xr(t,0);if(i<=0||a<=0)return e;let o=n-i/2,s=n+i/2,c=r-a/2,l=r+a/2;if(e.x<o||e.x>s||e.y<c||e.y>l)return e;let u=e.x-o,d=s-e.x,f=e.y-c,p=l-e.y,m=Math.min(u,d,f,p);return m===u?{x:o,y:e.y}:m===d?{x:s,y:e.y}:m===f?{x:e.x,y:c}:{x:e.x,y:l}},`nodeBoundaryClamp`);for(let t of e.edges){let e=t.points;if(!e||e.length<2)continue;let n=t.start,r=t.end,i=n?o.get(n):void 0,a=r?o.get(r):void 0;i&&(e[0]=ge(e[0],i)),a&&(e[e.length-1]=ge(e[e.length-1],a))}return e}r(wr,`routeEdgesOrthogonal`);function Tr(e){return e.direction??`TB`}r(Tr,`getSwimlaneDirection`);function Er(e){let t=N(e),n=e.config.flowchart?.nodeSpacing??40,r=e.config.flowchart?.rankSpacing??100,i=e.config.swimlane?.ignoreCrossLaneEdges??!0,a=e.config.swimlane?.optimizeRanksByCrossings??!0,o=e.config.swimlane?.automaticLaneOrdering??!1,s=Tr(e),{ordered:c,coordinates:l}=fr(t,{nodeGap:n,layerGap:r,ignoreCrossLaneEdges:i,optimizeRanksByCrossings:a,automaticLaneOrdering:o,direction:s});te(t,c,l,{nodeGap:n,layerGap:r});for(let t of e.edges??[])delete t.points;wr(e,s);for(let t of e.edges??[])t.curve&&t.curve!==`basis`||(t.curve=`rounded`);return on(e,s),an(e),s}r(Er,`runSwimlaneLayoutCore`);function Dr(e){M(e);let t=re(e);e.nodes=t.nodes,e.edges=t.edges}r(Dr,`prepareSwimlaneLayout`);var Or=t({prepareLayout:Dr,runLayoutCore:Er,afterPaint:i});export{Or as render};
1
+ import{t as e}from"./chunk-KS47KZWR-Bk0_a-eE.js";import{r as t}from"./chunk-KQLB2F66-BVAqVjgq.js";import"./chunk-M57EVK23-BgeE81Y7.js";import"./chunk-DQASFODM-CItpjfW5.js";import"./chunk-LEVMRMFU-DsFG_U8r.js";import"./chunk-AXFCVDMN-aqbxPiaN.js";import"./chunk-X4PVCEUW-Cs-r9l_d.js";import"./chunk-STOXU5M4-DOSqSu65.js";import"./chunk-R3KSYZAL-i9n2AYPG.js";import"./chunk-6MUBBAK2-C-VxnXsG.js";import"./chunk-BG4553SI-DDgvFLBP.js";import{n}from"./d3-selection-D2iIEb1P.js";import{n as r}from"./chunk-Y2CYZVJY-DsF7k-Jl.js";function i(t,{measure:n}){let r=t.config?.swimlane?.lineHops;if(r===!1)return;let i=r===`gap`?`gap`:`arc`,a=t.edges.filter(e=>Array.isArray(e.points)&&e.points.length>=2).map(e=>({id:e.id,points:e.points,curve:e.curve,arrowTypeStart:e.arrowTypeStart,arrowTypeEnd:e.arrowTypeEnd}));e(n.groups.edgePaths,a,{enabled:!0,jumpRadius:6,jumpStyle:i})}r(i,`applySwimlaneLineJumps`);function a(e){let t=e?.metadata?.laneRole;return t===`pool`||t===`lane`?t:void 0}r(a,`readLaneRole`);function o(e){let t=e?.metadata?.laneIndex;return typeof t==`number`&&Number.isFinite(t)?t:void 0}r(o,`readLaneIndex`);function s(e){let t=new Map,n=new Map;for(let r of e)t.set(r.id,r),r.isGroup&&r.parentId&&n.set(r.parentId,(n.get(r.parentId)??0)+1);let i=new Set;for(let t of e)t.isGroup&&a(t)===`pool`&&(n.get(t.id)??0)>0&&i.add(t.id);let o=new Set,s=new Map;for(let t of e)if(t.isGroup&&!i.has(t.id)){if(t.parentId&&i.has(t.parentId)){o.add(t.id);let e=s.get(t.parentId)??[];e.push(t.id),s.set(t.parentId,e)}else t.parentId||o.add(t.id)}let c=r((e,n)=>{let r=new Set([e]),i=t.get(e)?.parentId;for(;i&&!r.has(i);){if(n.has(i))return i;r.add(i),i=t.get(i)?.parentId}return null},`walk`),l=new Map;return{isPool:r(e=>i.has(e),`isPool`),isLane:r(e=>o.has(e),`isLane`),laneIdOf:r(e=>{let t=l.get(e);if(t!==void 0)return t;let n=c(e,o);return l.set(e,n),n},`laneIdOf`),poolIdOf:r(e=>i.has(e)?e:c(e,i),`poolIdOf`),lanesByPool:s,hasPools:i.size>0}}r(s,`buildLaneModel`);var c=new Set([`top`,`right`,`bottom`,`left`]),l=8,u=1e4;function d(e){let t=e?.metadata?.anchorTo;if(!t||typeof t!=`object`)return;let{hostId:n,side:r,slot:i,gap:a}=t;if(typeof n==`string`&&n.length!==0&&n!==e?.id)return{hostId:n,...typeof r==`string`&&c.has(r)?{side:r}:{},...typeof i==`number`&&Number.isFinite(i)?{slot:i}:{},...typeof a==`number`&&Number.isFinite(a)&&a>0?{gap:Math.min(a,u)}:{}}}r(d,`readAnchor`);function f(e,t){let n=new Set([e]),r=d(t.get(e))?.hostId;for(;r&&!n.has(r);){let e=t.get(r);if(!e)return;let i=d(e)?.hostId;if(!i)return r;n.add(r),r=i}}r(f,`resolveAnchorHostId`);function p(e){let t=new Map(e.map(e=>[e.id,e])),n=new Set;for(let r of e)d(r)&&f(r.id,t)&&n.add(r.id);return n}r(p,`collectAnchoredIds`);function m(e,t){return e===`canonical`?`right`:t===`LR`||t===`RL`?`bottom`:`right`}r(m,`defaultAnchorSide`);function h(e,t){let n=e.anchor.slot,r=t.anchor.slot;return n!==void 0&&r!==void 0&&n!==r?n-r:n!==void 0&&r===void 0?-1:n===void 0&&r!==void 0?1:e.index-t.index}r(h,`compareBucketEntries`);function g(e){let t=e.reduce((e,t)=>e+t,0)+l*Math.max(0,e.length-1),n=[],r=-t/2;for(let t of e)n.push(r+t/2),r+=t+l;return{offsets:n,total:t}}r(g,`packAlongBorder`);var _=r(e=>[e.width,e.height].every(e=>e===void 0||Number.isFinite(e)),`hasUsableSize`);function v(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Map;e.forEach((e,i)=>{let a=d(e);if(!a||!_(e))return;let o=f(e.id,n);if(!o)return;let s=t(a),c=`${s}:${o}`,l=r.get(c)??[];l.push({node:e,anchor:a,index:i,side:s,hostId:o}),r.set(c,l)});for(let e of r.values())e.sort(h);return r}r(v,`bucketByHostAndSide`);function y(e,t,n,r){return e+(!t&&n>0?-(r+l):0)}r(y,`centreAlongBorder`);function b(e,t){let n=t===`top`||t===`bottom`,i=r(e=>n?e.width??0:e.height??0,`alongBorder`),a=r(e=>n?e.height??0:e.width??0,`reach`),{offsets:o}=g(e.map(e=>i(e.node))),s=0,c=0,l=0;return e.forEach((e,t)=>{let r=e.anchor.gap??0,u=i(e.node)/2,d=y(o[t],n,r,u);s=Math.max(s,u-d),c=Math.max(c,d+u),l=Math.max(l,r>0?r+a(e.node):0)}),{before:s,after:c,beyond:l}}r(b,`footprintOf`);function x(e,t){let n=m(`final`,t??`TB`),r=new Map;for(let t of v(e,e=>e.side??n).values()){if(!t.some(e=>e.anchor.gap))continue;let{hostId:e,side:n}=t[0];r.set(e,{...r.get(e),[n]:b(t,n)})}return r}r(x,`anchorFootprints`);var S=`__swimlane_default__`,C=21,w=20;function T(e){return Math.max(e.padding??w,w)}r(T,`topLaneHorizontalPadding`);function E(e){let{x:t,y:n,width:r,height:i}=e,a=e.swimlaneContentTop;if(typeof t!=`number`||typeof n!=`number`||typeof r!=`number`||typeof i!=`number`||typeof a!=`number`||!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(i)||!Number.isFinite(a)||r<=0||i<=0){delete e.groupTitleRect;return}let o=n-i/2,s=Math.min(a,n+i/2),c=o+Math.min(C,Math.max(0,s-o));c<=o?delete e.groupTitleRect:e.groupTitleRect={left:t-r/2,right:t+r/2,top:o,bottom:c}}r(E,`assignTopLaneTitleRect`);function D(e){let t=e.other?.droppedSubGraphMembers;return Array.isArray(t)?t:[]}r(D,`sharedMembers`);var O=r((e,t,n)=>!t.some(e=>e.parentId===n)&&!(e.edges??[]).some(e=>e.start===n||e.end===n),`isEmptyLane`);function k(e,t){return e.isLane(t)?t:e.laneIdOf(t)??void 0}r(k,`laneIdOrSelf`);function ee(e,t,n){for(let r of n){let n=t.findIndex(e=>e.id===r);n>=0&&O(e,t,r)&&t.splice(n,1)}}r(ee,`removeEmptyLanes`);function A(e,t){let r=s(t),i=new Set(t.filter(e=>r.isLane(e.id)).map(e=>e.id)),a=new Set;for(let{node:t,keptBy:o,droppedFrom:s}of D(e)){let e=k(r,o);e&&e!==s&&i.has(s)&&(n.warn(`Swimlane node "${t}" is listed in lanes "${e}" and "${s}"; it is drawn in "${e}" only.`),a.add(s))}ee(e,t,a)}r(A,`dropLanesEmptiedBySharedNodes`);function j(e,t){for(let r of e)r.isGroup&&!t.isLane(r.id)&&!t.isPool(r.id)&&n.warn(`Swimlane subgraph "${r.id}" is nested in "${r.parentId}"; only top-level subgraphs are lanes, so it is drawn as a plain box.`)}r(j,`warnAboutNestedGroups`);function M(e){let t=e.direction,n=e.nodes??=[];A(e,n);let r=s(n);j(n,r);for(let e of n){let n=r.isLane(e.id);(n||r.isPool(e.id))&&(e.shape=n?`swimlane`:`pool`,t&&(e.direction=t))}let i=n.filter(e=>!e.isGroup&&!e.parentId);if(i.length===0)return;let a=n.find(e=>e.id===S);a?a.isGroup&&(a.shape=`swimlane`,t&&(a.direction=t)):(a={id:S,label:``,isGroup:!0,shape:`swimlane`,padding:20,look:e.config?.look,colorIndex:n.reduce((e,t)=>Math.max(e,t.colorIndex??-1),-1)+1,...t?{direction:t}:{}},n.push(a));for(let e of i)e.parentId=S}r(M,`prepareLayoutForSwimlanes`);function N(e){let t=(e.nodes??[]).filter(e=>!e.isEdgeLabel),n=new Map(t.map(e=>[e.id,e])),i=p(t),a=r(e=>i.has(e)?f(e,n)??e:e,`hostOf`),o=new Map;for(let e of t)i.has(e.id)||o.set(e.id,e);let s=[];for(let t of e.edges??[]){let e=typeof t.start==`string`?t.start:void 0,n=typeof t.end==`string`?t.end:void 0;if(!e||!n||t.isLayoutOnly)continue;let r=a(e),i=a(n);r!==i&&s.push({id:t.id,src:r,dst:i,ref:t})}let c=t.filter(e=>e.isGroup&&!i.has(e.id)),l=t.filter(e=>!e.isGroup&&!i.has(e.id));return{nodes:[...[...c].reverse(),...l].map(e=>e.id),edges:s,layout:e,nodeById:o}}r(N,`toGraphView`);function P(e){let t=new Map(e.map(e=>[e.id,e])),n=r(e=>{let n=0,r=e.parentId,i=new Set([e.id]);for(;r!=null&&!i.has(r);)i.add(r),n++,r=t.get(r)?.parentId;return n},`depthOf`);return e.filter(e=>e?.isGroup).map(e=>({node:e,depth:n(e)})).sort((e,t)=>t.depth-e.depth).map(e=>e.node)}r(P,`groupsDeepestFirst`);function te(e,t,n,r){let{layout:i}=e,a=e.nodeById,o=r?.layerGap??100,c=r?.nodeGap??40,l=0;for(let e of t.layers){let t=0;for(let r of e){let e=a.get(r);if(!e){t++;continue}e.layer=l,e.order=t;let i=n.x[r]??t*c,s=n.y[r]??l*o;e.x=i,e.y=s,t++}l++}let u=i.nodes??[],d=p(u);for(let e of u)e.isEdgeLabel&&n.x[e.id]!=null&&n.y[e.id]!=null&&(e.x=n.x[e.id],e.y=n.y[e.id]);let f=new Map,m=s(u),h=[];for(let e of P(u)){m.isLane(e.id)&&h.push(e);let t=u.filter(t=>t.parentId===e.id&&!d.has(t.id)),r=1/0,i=-1/0,a=1/0,o=-1/0;for(let e of t){let t=e.x??n.x[e.id],s=e.y??n.y[e.id],c=e.width??0,l=e.height??0;t!=null&&s!=null&&(e.isEdgeLabel||(r=Math.min(r,t-c/2),i=Math.max(i,t+c/2)),a=Math.min(a,s-l/2),o=Math.max(o,s+l/2))}if(r===1/0||a===1/0)e.x=e.x??0,e.y=e.y??0,e.width=e.width??0,e.height=e.height??0;else{let t=e.padding??20,n=e.parentId?t:2*T(e),s=t,c=Math.max(0,i-r)+n,l=Math.max(0,o-a)+s,u=(r+i)/2,d=(a+o)/2;e.x=u,e.y=d,e.width=c,e.height=l,f.set(e.id,{minX:r,maxX:i,minY:a,maxY:o})}}if(h.length>0&&f.size>0){let e=1/0,t=-1/0,n=0;for(let r of h){let i=r.padding??20;i>n&&(n=i);let a=f.get(r.id);a&&(e=Math.min(e,a.minY),t=Math.max(t,a.maxY))}if(e!==1/0&&t!==-1/0){let r=Math.max(0,t-e)+2*Math.max(n,36),i=(e+t)/2;for(let t of h)t.y=i,t.height=r,t.swimlaneContentTop=e;let a=[...h].sort((e,t)=>(e.x??0)-(t.x??0)),o=[],s=[],c=[];for(let e of a){let t=f.get(e.id);if(!t)continue;let n=Math.max(0,t.maxX-t.minX)+2*T(e),r=(t.minX+t.maxX)/2;o.push(e.id),s.push(r),c.push(n)}let l=o.length;if(l>0){let e=new Map;if(l===1)e.set(o[0],c[0]);else{let t=[];for(let e=0;e<l-1;e++)t.push(s[e+1]-s[e]);let n=Array(l);n[0]=0;for(let e=0;e<l-1;e++)n[e+1]=2*t[e]-n[e];let r=0,i=1/0;for(let e=0;e<l;e++){let t=c[e];e%2==0?r=Math.max(r,t-n[e]):i=Math.min(i,n[e]-t)}let a=r;a=r<=i?(r+i)/2:r;for(let t=0;t<l;t++){let r=n[t]+(t%2==0?a:-a),i=Math.max(c[t],r);e.set(o[t],i)}}for(let t of h){let n=e.get(t.id);n!=null&&(t.width=n),E(t)}}}}}r(te,`writeBackToLayoutData`);var ne=`[EdgeLabelNodes]`;function re(e){let t=[],r=[],i=new Map;for(let t of e.nodes)i.set(t.id,t);for(let a of e.edges){if(!a.label||a.label.length===0||a.isLayoutOnly||a.labelNodeId)continue;let e=a.start?i.get(a.start):void 0,o=a.end?i.get(a.end):void 0;if(!e||!o){n.warn(ne,`Edge ${a.id} has missing source or target node`);continue}let s=`edge-label-${a.start}-${a.end}-${a.id}`,c=e.parentId===o.parentId?e.parentId:o.parentId,l={id:s,label:a.label,edgeStart:a.start??``,edgeEnd:a.end??``,shape:`labelRect`,width:0,height:0,isEdgeLabel:!0,isDummy:!0,parentId:c,isGroup:!1,labelStyle:Array.isArray(a.labelStyle)?a.labelStyle[0]:a.labelStyle??``,...e.dir?{dir:e.dir}:{}};t.push(l),a.labelNodeId=s,a.label=void 0,a.text=void 0;let u={id:`${a.id}-to-label`,start:a.start,end:s,type:`normal`,isLayoutOnly:!0},d={id:`${a.id}-from-label`,start:s,end:a.end,type:`normal`,isLayoutOnly:!0};r.push(u,d)}let a=[...e.nodes,...t],o=[...e.edges,...r];return{...e,nodes:a,edges:o}}r(re,`createEdgeLabelNodes`);var F=.001;function ie(e){let t=e.x??0,n=e.y??0,r=e.width??0,i=e.height??0;return r>0&&i>0?{cx:t,cy:n,rect:me(t,n,r,i)}:void 0}r(ie,`measuredNodeRect`);function ae(e){if(e.isGroup)return;let t=ie(e);if(t)return{id:String(e.id??``),cx:t.cx,cy:t.cy,rect:t.rect}}r(ae,`nodeBoundsInfoFor`);function I(e,t,n=F){return Math.abs(e.x-t.x)<n&&Math.abs(e.y-t.y)<n}r(I,`samePoint`);function L(e,t,n=F){return Math.abs(e.x-t.x)<n}r(L,`sameX`);function R(e,t,n=F){return Math.abs(e.y-t.y)<n}r(R,`sameY`);function z(e,t,n=F){return R(e,t,n)&&Math.abs(e.x-t.x)>n}r(z,`isHorizontalSegment`);function B(e,t,n=F){return L(e,t,n)&&Math.abs(e.y-t.y)>n}r(B,`isVerticalSegment`);function V(e,t,n,r){return Math.max(0,Math.min(Math.max(e,t),Math.max(n,r))-Math.max(Math.min(e,t),Math.min(n,r)))}r(V,`overlapLength`);function H(e,t,n=F){return e.horizontal&&t.horizontal&&R(e.a,t.a,n)?V(e.a.x,e.b.x,t.a.x,t.b.x):e.vertical&&t.vertical&&L(e.a,t.a,n)?V(e.a.y,e.b.y,t.a.y,t.b.y):0}r(H,`sameAxisSegmentOverlapLength`);function U(e,t=F){let n=[];for(let r=0;r<e.length-1;r++){let i=e[r],a=e[r+1],o=z(i,a,t),s=B(i,a,t);(o||s)&&n.push({index:r,a:i,b:a,horizontal:o,vertical:s})}return n}r(U,`orthogonalSegmentsForPoints`);function W(e,t=F){let n=U(e,t),r=0;for(let e=1;e<n.length;e++)n[e-1].horizontal!==n[e].horizontal&&r++;return r}r(W,`countOrthogonalBends`);function oe(e){let t=U(G(e));return t.slice(1).flatMap((e,n)=>t[n].horizontal===e.horizontal?[]:[e.a])}r(oe,`bendPoints`);function se(e,t){let n=Math.max(Math.min(t.a.x,t.b.x)-e.x,0,e.x-Math.max(t.a.x,t.b.x)),r=Math.max(Math.min(t.a.y,t.b.y)-e.y,0,e.y-Math.max(t.a.y,t.b.y));return Math.hypot(n,r)}r(se,`distanceToSegment`);function ce(e,t,n){let i=r((e,t)=>{let r=U(G(t));return oe(e).some(e=>r.some(t=>se(e,t)<n))},`touches`);return i(e,t)||i(t,e)}r(ce,`routesTouchAtBend`);function G(e,t=F){let n=[];for(let r of e){let e=n.length>0?n[n.length-1]:void 0;e&&I(e,r,t)||n.push({x:r.x,y:r.y})}return n}r(G,`dedupeConsecutivePoints`);function le(e,t=F){if(!e||e.length!==4)return;let[n,r,i,a]=e;return z(n,r,t)&&B(r,i,t)&&z(i,a,t)?{kind:`HVH`,p0:n,p1:r,p2:i,p3:a}:B(n,r,t)&&z(r,i,t)&&B(i,a,t)?{kind:`VHV`,p0:n,p1:r,p2:i,p3:a}:void 0}r(le,`classifyThreeSegmentRoute`);function ue(e,t,n,r=0){let i=Math.min(e.x,t.x),a=Math.max(e.x,t.x),o=Math.min(e.y,t.y),s=Math.max(e.y,t.y);return a>n.left-r&&i<n.right+r&&s>n.top-r&&o<n.bottom+r}r(ue,`segmentBoundsOverlapRect`);function de(e,t,n=0){return e.x>t.left+n&&e.x<t.right-n&&e.y>t.top+n&&e.y<t.bottom-n}r(de,`pointInsideRect`);function fe(e,t){return e.left<=t.left&&e.right>=t.right&&e.top<=t.top&&e.bottom>=t.bottom}r(fe,`rectContainsRect`);function K(e,t){return e.left<t.right&&e.right>t.left&&e.top<t.bottom&&e.bottom>t.top}r(K,`rectsOverlap`);function pe(e,t){return{left:e.left-t,right:e.right+t,top:e.top-t,bottom:e.bottom+t}}r(pe,`inflateRect`);function me(e,t,n,r){return{left:e-n/2,right:e+n/2,top:t-r/2,bottom:t+r/2}}r(me,`rectFromCenterSize`);function q(e){return ie(e)?.rect}r(q,`rectOfNodeBounds`);function he(e,t){switch(t){case`top`:return{x:e.cx,y:e.rect.top};case`bottom`:return{x:e.cx,y:e.rect.bottom};case`left`:return{x:e.rect.left,y:e.cy};case`right`:return{x:e.rect.right,y:e.cy}}}r(he,`portForRectSide`);function ge(e,t,n,r,i,a=F){let o=t===`left`||t===`right`,s=r===`left`||r===`right`;if(o&&s){if(t===`right`&&r===`left`&&e.x<n.x||t===`left`&&r===`right`&&e.x>n.x){if(R(e,n,a))return[e,n];let t=(e.x+n.x)/2;return[e,{x:t,y:e.y},{x:t,y:n.y},n]}if(t===r){if(R(e,n,a))return;let r=t===`left`?Math.min(e.x,n.x)-i:Math.max(e.x,n.x)+i;return[e,{x:r,y:e.y},{x:r,y:n.y},n]}return}if(!o&&!s){if(t===r){if(L(e,n,a))return;let r=t===`top`?Math.min(e.y,n.y)-i:Math.max(e.y,n.y)+i;return[e,{x:e.x,y:r},{x:n.x,y:r},n]}if(!(t===`bottom`&&r===`top`&&e.y<n.y||t===`top`&&r===`bottom`&&e.y>n.y))return;if(L(e,n,a))return[e,n];let o=(e.y+n.y)/2;return[e,{x:e.x,y:o},{x:n.x,y:o},n]}if(o&&!s){let i=t===`right`&&n.x>e.x||t===`left`&&n.x<e.x,a=r===`top`&&e.y<n.y||r===`bottom`&&e.y>n.y;return i&&a?[e,{x:n.x,y:e.y},n]:void 0}let c=t===`bottom`&&n.y>e.y||t===`top`&&n.y<e.y,l=r===`left`&&e.x<n.x||r===`right`&&e.x>n.x;return c&&l?[e,{x:e.x,y:n.y},n]:void 0}r(ge,`buildOrthogonalPortPath`);function _e(e,t,n,r){return t===`left`||t===`right`?[e,{x:r,y:e.y},{x:r,y:n.y},n]:[e,{x:e.x,y:r},{x:n.x,y:r},n]}r(_e,`buildSameSideTrackPath`);function ve(e){let t=new Map,n=[];for(let r of e){if(r.isEdgeLabel)continue;let e=ae(r);e&&(t.set(e.id,e),n.push({id:e.id,rect:e.rect}))}return{nodeInfoById:t,realNodeRects:n}}r(ve,`collectRealNodeBounds`);function ye(e){let t=[],n=[];for(let r of e){let e=ae(r);if(!e)continue;let i={id:e.id,rect:e.rect};r.isEdgeLabel?n.push(i):t.push(i)}return{realNodeRects:t,labelNodeRects:n}}r(ye,`collectNodeRectEntries`);function be(e,{includeEdgeLabels:t=!0}={}){let n=[];for(let r of e){if(r.isGroup||!t&&r.isEdgeLabel)continue;let e=r.x??0,i=r.y??0,a=r.width??0,o=r.height??0;n.push({nodeId:r.id,...me(e,i,a,o)})}return n}r(be,`collectLayoutNodeRects`);function xe(e,t,n=F){let r=e.start,i=e.end;if(!r||!i)return;let a=t.get(r),o=t.get(i);if(a&&o)return{srcId:r,dstId:i,srcInfo:a,dstInfo:o,collinearX:Math.abs(a.cx-o.cx)<n,collinearY:Math.abs(a.cy-o.cy)<n}}r(xe,`getNodePairGeometry`);function J(e,t,n,r=[],i=0){for(let a of n)if(!r.includes(a.id)&&ue(e,t,a.rect,-i))return!0;return!1}r(J,`segmentHitsAnyRect`);function Se(e,t,n,r,i=F,a=1e-6){let o=R(e,t,i),s=L(e,t,i),c=R(n,r,i),l=L(n,r,i);if(o&&c||s&&l||!(o||s)||!(c||l))return!1;let u=o?{a:e,b:t}:{a:n,b:r},d=s?{a:e,b:t}:{a:n,b:r},f=u.a.y,p=Math.min(u.a.x,u.b.x),m=Math.max(u.a.x,u.b.x),h=d.a.x,g=Math.min(d.a.y,d.b.y),_=Math.max(d.a.y,d.b.y);if(h<p||h>m||f<g||f>_)return!1;let v=Math.abs(h-u.a.x)<a&&Math.abs(f-u.a.y)<a||Math.abs(h-u.b.x)<a&&Math.abs(f-u.b.y)<a,y=Math.abs(h-d.a.x)<a&&Math.abs(f-d.a.y)<a||Math.abs(h-d.b.x)<a&&Math.abs(f-d.b.y)<a;return!(v&&y)}r(Se,`orthogonalSegmentsCross`);function Ce(e,t,n,r,i=F){let a=R(e,t,i),o=L(e,t,i),s=R(n,r,i),c=L(n,r,i);return o&&c&&L(e,n,i)?V(e.y,t.y,n.y,r.y)>i:a&&s&&R(e,n,i)?V(e.x,t.x,n.x,r.x)>i:!1}r(Ce,`sameAxisSegmentsOverlap`);function we(e,t,n,r,{epsilon:i=F,skipDegenerateOther:a=!1}={}){for(let o of n){if(o===r||o.isLayoutOnly)continue;let n=o.points;if(!(!n||n.length<2))for(let r=0;r<n.length-1;r++){let o=n[r],s=n[r+1];if(!(a&&I(o,s,i))&&(Se(e,t,o,s,i)||Ce(e,t,o,s,i)))return!0}}return!1}r(we,`segmentConflictsWithAnyEdge`);function Te(e,t,n,r,i=F){let a=R(e,t,i),o=L(e,t,i),s=R(n,r,i),c=L(n,r,i);if(!(a&&c||o&&s))return!1;let l=a?{a:e,b:t}:{a:n,b:r},u=a?{a:n,b:r}:{a:e,b:t},d=l.a.y,f=Math.min(l.a.x,l.b.x),p=Math.max(l.a.x,l.b.x),m=u.a.x,h=Math.min(u.a.y,u.b.y),g=Math.max(u.a.y,u.b.y);return m>f+i&&m<p-i&&d>h+i&&d<g-i}r(Te,`orthogonalSegmentsStrictlyCross`);function Ee(e,t,n){let r=Math.min(t,n),i=Math.max(t,n);return e>r+F&&e<i-F}r(Ee,`strictlyBetween`);function De(e,t,n){return L(e,t)&&L(t,n)?Ee(t.y,e.y,n.y):R(e,t)&&R(t,n)?Ee(t.x,e.x,n.x):!1}r(De,`isCollinearIntermediate`);function Oe(e){let t=!1,n=[];for(let r=0;r<e.length;r++){let i=n[n.length-1],a=e[r],o=r+1<e.length?e[r+1]:void 0;if(i&&o){if(I(i,o)){r++,t=!0;continue}if(De(i,a,o)){t=!0;continue}}n.push(a)}return{points:n,changed:t}}r(Oe,`simplifyPolylineOnce`);function ke(e){let t=[e[0]];for(let n=1;n<e.length;n++){let r=t[t.length-1],i=e[n];if(!L(r,i)&&!R(r,i)){let e=t.length>=2?t[t.length-2]:void 0,n=e&&L(e,r)?{x:r.x,y:i.y}:{x:i.x,y:r.y};t.push(n)}t.push(i)}let n=[];for(let e of t){let t=n[n.length-1];t&&I(t,e)||n.push(e)}return n}r(ke,`orthogonalizePolyline`);function Ae(e){if(e.length<3)return e;let t=[...e];for(let e=0;e<32;e++){let e=Oe(t);if(t=e.points,!e.changed)break}return t}r(Ae,`simplifyPolyline`);var Y=.001,je=.5,Me=4;function Ne(e,t,n){let r=e;if(r.isLayoutOnly||!r.points||r.points.length<n)return;let i=r.start?t.get(r.start):void 0,a=r.end?t.get(r.end):void 0;return{edge:r,points:r.points,srcRect:i?q(i):void 0,dstRect:a?q(a):void 0}}r(Ne,`endpointContextFor`);function Pe(e,t,n){if(R(e,t,Y))return{x:e.x<n.left?n.left:n.right,y:e.y};if(L(e,t,Y)){let t=e.y<n.top?n.top:n.bottom;return{x:e.x,y:t}}return{x:Math.min(n.right,Math.max(n.left,e.x)),y:Math.min(n.bottom,Math.max(n.top,e.y))}}r(Pe,`segmentEnterPoint`);function Fe(e,t,n){let r=n?1:-1,i=n?0:e.length-1;for(;i>=0&&i<e.length&&de(e[i],t,je);)i+=r;if(i<0||i>=e.length)return e;let a=i-r;if(a<0||a>=e.length)return e;let o=Pe(e[i],e[a],t);return n?[o,...e.slice(i)]:[...e.slice(0,i+1),o]}r(Fe,`clipEndpoint`);function Ie(e,t){for(let n of e){let e=Ne(n,t,2);if(!e)continue;let r=[...e.points];e.srcRect&&(r=Fe(r,e.srcRect,!0)),e.dstRect&&(r=Fe(r,e.dstRect,!1)),r=Ae(ke(r)),r=qe(r,e.srcRect,e.dstRect),e.edge.points=Ae(ke(r))}}r(Ie,`clipEdgeEndpointsToNodeBoundaries`);function Le(e,t,n,r=!1){if(R(e,t,Y)){if(t.y<n.top-Y||t.y>n.bottom+Y)return t;if(r){if(e.x<n.left-Y)return{x:n.left,y:e.y};if(e.x>n.right+Y)return{x:n.right,y:e.y}}return{x:Math.abs(t.x-n.left)<=Math.abs(t.x-n.right)?n.left:n.right,y:e.y}}if(L(e,t,Y)){if(t.x<n.left-Y||t.x>n.right+Y)return t;if(r){if(e.y<n.top-Y)return{x:e.x,y:n.top};if(e.y>n.bottom+Y)return{x:e.x,y:n.bottom}}let i=Math.abs(t.y-n.top)<=Math.abs(t.y-n.bottom);return{x:e.x,y:i?n.top:n.bottom}}return t}r(Le,`snapEndpointToBoundary`);function Re(e,t,n){let r=e[t];for(let i=t+n;i>=0&&i<e.length;i+=n){let t=e[i];if(!I(t,r,Y))return t}return e[t+n]}r(Re,`firstDistinctAdjacent`);function ze(e,t){let n=e+Me,r=t-Me;return n<=r?{lo:n,hi:r}:{lo:(e+t)/2,hi:(e+t)/2}}r(ze,`cornerClearanceRange`);function Be(e,t,n){let{lo:r,hi:i}=ze(t,n);return Math.min(i,Math.max(r,e))}r(Be,`clampToCornerClearance`);function Ve(e){let t=Math.max(...e.map(e=>e.lo)),n=Math.min(...e.map(e=>e.hi));if(!(t>n))return{lo:t,hi:n}}r(Ve,`intersectRanges`);function He(e,t){return t===`left`||t===`right`?ze(e.top,e.bottom):ze(e.left,e.right)}r(He,`clearanceRangeForSide`);function Ue(e,t,n){let r=e.y>=n.top-Y&&e.y<=n.bottom+Y,i=e.x>=n.left-Y&&e.x<=n.right+Y;if(R(e,t,Y)&&r){if(Math.abs(e.x-n.left)<Y)return`left`;if(Math.abs(e.x-n.right)<Y)return`right`}if(L(e,t,Y)&&i){if(Math.abs(e.y-n.top)<Y)return`top`;if(Math.abs(e.y-n.bottom)<Y)return`bottom`}}r(Ue,`terminalSideForSegment`);function We(e){return e===`left`||e===`right`}r(We,`isHorizontalSide`);function Ge(e,t,n,r,i){let a=[],o=n?Ue(e,t,n):void 0,s=r?Ue(t,e,r):void 0;return n&&o&&We(o)===i&&a.push(He(n,o)),r&&s&&We(s)===i&&a.push(He(r,s)),a.length>0?Ve(a):void 0}r(Ge,`straightClearanceRange`);function Ke(e,t,n,r,i){let a=Ge(e,t,n,r,i);if(!a)return;let o=i?e.y:e.x,s=Math.min(a.hi,Math.max(a.lo,o));if(!(Math.abs(s-o)<Y))return i?[{x:e.x,y:s},{x:t.x,y:s}]:[{x:s,y:e.y},{x:s,y:t.y}]}r(Ke,`clearStraightEndpointCornerAxis`);function qe(e,t,n){if(e.length!==2)return e;let[r,i]=e;return R(r,i,Y)?Ke(r,i,t,n,!0)??e:L(r,i,Y)?Ke(r,i,t,n,!1)??e:e}r(qe,`clearStraightEndpointCornerConnections`);function Je(e,t,n){return We(n)?{x:e.x,y:Be(e.y,t.top,t.bottom)}:{x:Be(e.x,t.left,t.right),y:e.y}}r(Je,`cornerClearedEndpoint`);function Ye(e,t,n,r,i,a){let o=e.map(e=>({...e}));for(let s=t;s>=0&&s<e.length;s+=n){let t=e[s];if(a&&!R(t,r,Y)||!a&&!L(t,r,Y))break;a?o[s].y=i.y:o[s].x=i.x}return o}r(Ye,`moveCollinearEndpointRun`);function Xe(e,t,n){if(e.length<2)return e;let r=n?0:e.length-1,i=n?1:-1,a=e[r],o=Re(e,r,i);if(!o)return e;let s=Ue(a,o,t);if(!s)return e;let c=We(s),l=Je(a,t,s);return I(a,l,Y)?e:Ye(e,r,i,a,l,c)}r(Xe,`clearEndpointCornerConnection`);function Ze(e,t,n){let r=Math.min(e.x,t.x)>=n.left-Y&&Math.max(e.x,t.x)<=n.right+Y,i=Math.min(e.y,t.y)>=n.top-Y&&Math.max(e.y,t.y)<=n.bottom+Y;if(Math.abs(e.y-n.top)<Y&&Math.abs(t.y-n.top)<Y&&r)return`top`;if(Math.abs(e.y-n.bottom)<Y&&Math.abs(t.y-n.bottom)<Y&&r)return`bottom`;if(Math.abs(e.x-n.left)<Y&&Math.abs(t.x-n.left)<Y&&i)return`left`;if(Math.abs(e.x-n.right)<Y&&Math.abs(t.x-n.right)<Y&&i)return`right`}r(Ze,`borderSideForSegment`);function Qe(e,t,n,r){switch(e){case`top`:return L(t,n,Y)&&n.y<r.top-Y;case`bottom`:return L(t,n,Y)&&n.y>r.bottom+Y;case`left`:return R(t,n,Y)&&n.x<r.left-Y;case`right`:return R(t,n,Y)&&n.x>r.right+Y}}r(Qe,`leavesOutward`);function $e(e,t,n){if(e.length<3)return e;if(n){let n=Ze(e[0],e[1],t);return n&&Qe(n,e[1],e[2],t)?e.slice(1):e}let r=e.length-1,i=Ze(e[r-1],e[r],t);return i&&Qe(i,e[r-1],e[r-2],t)?e.slice(0,r):e}r($e,`collapseOwnBorderStub`);function et(e,t,n){let r=e;if(t){let e=Re(r,0,1);if(e){let n=Le(e,r[0],t);n!==r[0]&&(r=[n,...r.slice(1)])}r=$e(r,t,!0)}if(n){let e=r.length-1,t=Re(r,e,-1);if(t){let i=Le(t,r[e],n,!0);i!==r[e]&&(r=[...r.slice(0,e),i])}r=$e(r,n,!1)}let i=qe(r,t,n);return i!==r||r.length===2?i:(t&&(r=Xe(r,t,!0)),n&&(r=Xe(r,n,!1)),r)}r(et,`snapAndCollapseEndpoints`);function tt(e,t){for(let n of e){let e=Ne(n,t,2);if(!e)continue;let r=et(G(e.points,Y),e.srcRect,e.dstRect);if(r.length<3){e.edge.points=r;continue}let i=[r[0],{...r[0]},...r.slice(1,-1),r[r.length-1],{...r[r.length-1]}];e.edge.points=i}}r(tt,`prepareEdgeEndpointsForRenderer`);function nt(e){return new Map(e.map(e=>[e.id,e]))}r(nt,`buildNodeMap`);function rt(e,t){let n=new Set([e.id]),r=0,i=e.parentId;for(;i&&!n.has(i);){let e=t.get(i);if(!e?.isGroup)break;n.add(i),r++,i=e.parentId}return r}r(rt,`groupDepth`);function it(e){let t=1/0,n=-1/0,r=1/0,i=-1/0;for(let a of e){let e=a.x,o=a.y;if(typeof e!=`number`||typeof o!=`number`)continue;let s=a.width??0,c=a.height??0;t=Math.min(t,e-s/2),n=Math.max(n,e+s/2),r=Math.min(r,o-c/2),i=Math.max(i,o+c/2)}return t===1/0||r===1/0?null:{minX:t,maxX:n,minY:r,maxY:i}}r(it,`boundsForChildren`);function at(e,t){let n=e.padding??20;e.x=(t.minX+t.maxX)/2,e.y=(t.minY+t.maxY)/2,e.width=Math.max(0,t.maxX-t.minX)+n,e.height=Math.max(0,t.maxY-t.minY)+n}r(at,`applyGroupBounds`);function ot(e){let t=nt(e),n=e.filter(e=>e.isGroup&&e.parentId).sort((e,n)=>rt(n,t)-rt(e,t));for(let t of n){let n=it(e.filter(e=>e.parentId===t.id));n&&at(t,n)}}r(ot,`recomputeNestedGroupBounds`);function st(e,t){let n=e.nodes??[],i=e.edges??[],a=n.filter(e=>!e.isGroup),o=1/0,s=-1/0;for(let e of a){let n=e[t];typeof n==`number`&&(o=Math.min(o,n),s=Math.max(s,n))}if(!Number.isFinite(o)||!Number.isFinite(s))return!1;let c=r(e=>o+s-e,`mirror`);for(let e of n){let n=e[t];typeof n==`number`&&(e[t]=c(n));let r=e.groupTitleRect;r&&(e.groupTitleRect=t===`x`?{...r,left:c(r.right),right:c(r.left)}:{...r,top:c(r.bottom),bottom:c(r.top)})}for(let e of i)for(let n of e.points??[])n[t]=c(n[t]);return!0}r(st,`mirrorAxis`);function ct(e){return!(e.nodes??[]).some(e=>!e.isGroup)||st(e,`y`)}r(ct,`applyBtDirectionTransform`);function lt(e){let t=e.filter(e=>!e.isGroup&&!e.isEdgeLabel);if(t.length===0)return 1;let n=0,r=0;for(let e of t)n+=e.width??0,r+=e.height??0;let i=n/t.length,a=r/t.length;return a>0?Math.max(1,i/a):1}r(lt,`flowAxisStretch`);var ut=36,dt=[`top`,`right`,`bottom`,`left`];function ft(e){return e===`left`?`right`:e===`right`?`left`:e}r(ft,`mirroredSide`);function pt(e,t,n,r,i){if(n===`top`||n===`bottom`){let n=(t.left+t.right)/2,[a,o]=i?[r.after,r.before]:[r.before,r.after];e.left=Math.min(e.left,n-a),e.right=Math.max(e.right,n+o);return}let a=(t.top+t.bottom)/2;e.top=Math.min(e.top,a-r.before),e.bottom=Math.max(e.bottom,a+r.after)}r(pt,`growAlongBorder`);var mt={top:r((e,t,n)=>{e.top=Math.min(e.top,t.top-n)},`top`),bottom:r((e,t,n)=>{e.bottom=Math.max(e.bottom,t.bottom+n)},`bottom`),left:r((e,t,n)=>{e.left=Math.min(e.left,t.left-n)},`left`),right:r((e,t,n)=>{e.right=Math.max(e.right,t.right+n)},`right`)};function ht(e,t,n,r,i){pt(e,t,n,r,i),mt[n](e,t,r.beyond)}r(ht,`reserveOnSide`);function gt(e,t,n){let r=e.x??0,i=e.y??0,a=(e.width??0)/2,o=(e.height??0)/2,s={left:r-a,right:r+a,top:i-o,bottom:i+o},c={...s},l=n===`RL`;for(let e of dt){let n=t[e];n&&ht(c,s,l?ft(e):e,n,l)}return{...e,x:(c.left+c.right)/2,y:(c.top+c.bottom)/2,width:c.right-c.left,height:c.bottom-c.top}}r(gt,`withAnchorFootprints`);function _t(e,t=`LR`){let n=e.nodes??[],r=e.edges??[],i=p(n),a=n.filter(e=>!e.isGroup&&!i.has(e.id)),o=1/0,c=1/0;for(let e of a){let t=e.x??0,n=e.y??0;t<o&&(o=t),n<c&&(c=n)}if(!Number.isFinite(o)||!Number.isFinite(c))return!1;let l=ut,u=lt(a);for(let e of a){let t=e.x??0,n=((e.y??0)-c)*u+l,r=t-o;e.x=n,e.y=r}for(let e of r)if(e.points)for(let t of e.points){let e=t.x,n=(t.y-c)*u+l,r=e-o;t.x=n,t.y=r}ot(n);let d=s(n),f=n.filter(e=>d.isLane(e.id));if(f.length===0)return t===`RL`&&st(e,`x`),!0;let m=new Map,h=x(n,t);for(let e of n){if(d.isLane(e.id)||d.isPool(e.id)||i.has(e.id))continue;let n=d.laneIdOf(e.id);if(!n)continue;let r=m.get(n)??[],a=h.get(e.id);r.push(a?gt(e,a,t):e),m.set(n,r)}let g=0;for(let e of f){let t=e.padding??0;t>g&&(g=t)}let _=[],v=1/0,y=-1/0;for(let e of f){let t=it(m.get(e.id)??[]);t&&(v=Math.min(v,t.minX),y=Math.max(y,t.maxX),_.push({lane:e,contentTop:t.minY,contentBottom:t.maxY,centerY:(t.minY+t.maxY)/2}))}if(v===1/0||y===-1/0)return!0;let b=Math.max(0,y-v)+2*Math.max(g,10),S=l+b,C=(v+y)/2-b/2-l,w=C+S/2,T=Math.max(g,l);_.sort((e,t)=>e.centerY-t.centerY);for(let e=0;e<_.length;e++){let t=_[e],n,r;if(n=e===0?t.contentTop-T:(_[e-1].contentBottom+t.contentTop)/2,e===_.length-1)r=t.contentBottom+T;else{let n=_[e+1];r=(t.contentBottom+n.contentTop)/2}let i=Math.max(0,r-n),a=(n+r)/2;t.lane.x=w,t.lane.y=a,t.lane.width=S,t.lane.height=i,t.lane.swimlaneContentTop=t.contentTop,t.lane.groupTitleRect={left:C,right:C+l,top:n,bottom:r}}return t===`RL`&&st(e,`x`),!0}r(_t,`applyLrDirectionTransform`);var vt=1e-6,yt=8,bt=[0,yt,-yt,2*yt,-2*yt];function xt(e,t){let{nodeInfoById:n,realNodeRects:r}=ve(t);for(let t of e){if(t.isLayoutOnly)continue;let i=t.points;if(!i||i.length<4)continue;let a=le(G(i,vt),vt);if(!a)continue;let{p3:o}=a,s=a.kind===`HVH`,c=xe(t,n,vt);if(!c)continue;let{srcId:l,dstId:u,srcInfo:d,dstInfo:f,collinearX:p,collinearY:m}=c;if(p||m)continue;let h,g=d.rect;for(let n of bt){let i,a,c;if(s){let e=f.cy>d.cy?g.bottom:g.top,t=d.cx+n;if(t<=g.left+vt||t>=g.right-vt)continue;i={x:t,y:e},a={x:t,y:o.y},c={x:o.x,y:o.y}}else{let e=f.cx>d.cx?g.right:g.left,t=d.cy+n;if(t<=g.top+vt||t>=g.bottom-vt)continue;i={x:e,y:t},a={x:o.x,y:t},c={x:o.x,y:o.y}}let p=I(i,a,vt),m=I(a,c,vt);if(p&&m||!p&&J(i,a,r,[l],1)||!m&&J(a,c,r,[u],1))continue;let _=!p&&we(i,a,e,t,{epsilon:vt,skipDegenerateOther:!0}),v=!m&&we(a,c,e,t,{epsilon:vt,skipDegenerateOther:!0});if(!(_||v)){h=p?[a,c]:m?[i,a]:[i,a,c];break}}h&&(t.points=h)}}r(xt,`portSwapToLShape`);function St(e,t){let n=.001,{realNodeRects:i,labelNodeRects:a}=ye(t.values());for(let o of e){if(o.isLayoutOnly)continue;let s=o.points;if(!s||s.length<4)continue;let c=G(s,n);if(c.length<4)continue;let l=c.length-1,u=c[l],d=c[l-1],f=c[l-2],p=u.x-d.x,m=u.y-d.y,h=Math.hypot(p,m);if(h>=10||h<n)continue;let g=d.x-f.x,_=d.y-f.y;if(Math.hypot(g,_)<n)continue;let v=z(d,u,n),y=B(d,u,n),b=z(f,d,n),x=B(f,d,n);if(!(v&&x||y&&b))continue;let S=o.end,C=o.start,w=S?t.get(S):void 0;if(!w)continue;let T=w.x??0,E=w.y??0,D=q(w);if(!D)continue;let O,k;if(x){let e=_<0;O={x:T,y:f.y},k={x:T,y:e?D.bottom:D.top}}else{let e=g>0;O={x:f.x,y:E},k={x:e?D.right:D.left,y:E}}if(J(O,k,i,S?[S]:[],-2)||J(O,k,a,[],-2))continue;if(C){let e=t.get(C),n=e?q(e):void 0;if(n&&de(O,n,2))continue}let ee=r((e,t)=>`${e.x.toFixed(3)},${e.y.toFixed(3)}|${t.x.toFixed(3)},${t.y.toFixed(3)}`,`ownSegmentKey`),A=new Set;for(let e=0;e<c.length-1;e++)A.add(ee(c[e],c[e+1]));let j=r((t,r)=>{for(let i of e){if(i===o||i.isLayoutOnly)continue;let e=i.points;if(!(!e||e.length<2))for(let i=0;i<e.length-1;i++){let a=e[i],o=e[i+1];if(!A.has(ee(a,o))&&Te(t,r,a,o,n))return!0}}return!1},`segmentCrossesOtherEdge`);if(j(O,k))continue;if(l-3>=0){let e=c[l-3],t=[C,S].filter(e=>!!e);if(J(e,O,i,t,-2)||j(e,O))continue}let M=[...c.slice(0,l-2),O,k];o.points=M;let N=o.labelNodeId;if(N){let e=t.get(N);if(e){let t=e.width??0,r=e.height??0;if(t>0&&r>0){let i,a,o=-1;for(let e=0;e<M.length-1;e++){let s=M[e],c=M[e+1],l=Math.hypot(c.x-s.x,c.y-s.y),u=R(s,c,n),d=L(s,c,n);(u&&l>=t+2||d&&l>=r+2)&&l>o&&(o=l,i=(s.x+c.x)/2,a=(s.y+c.y)/2)}i!==void 0&&a!==void 0&&(e.x=i,e.y=a)}}}}}r(St,`collapseShortTerminalStub`);var Ct=4,wt=2,Tt={EDGE_GAP:12,LANE_MARGIN:20,ARROWHEAD_SIZE:8,ARROWHEAD_GAP:Ct,MIN_ARROWHEAD_SPACING:12,EDGE_STROKE_WIDTH:wt,ROUTE_TOUCH_TOLERANCE:Ct+wt},Et={EPSILON:1e-6},Dt={GRAVITY_ITERATIONS:8,MAX_CROSSING_OPTIMIZATION_PASSES:4,DEFAULT_COMPACT_SINGLE_INPUT:!0},Ot={DEFAULT_LAYER_GAP:100,DEFAULT_NODE_GAP:40,EDGE_LABEL_CLEARANCE:16},X=.001,Z=8,kt=r(e=>typeof e==`string`?e.toUpperCase():``,`upperCaseDirection`),Q=U,At=r((e,t)=>L(e,t,X)||R(e,t,X),`orthogonallyAligned`);function jt(e,t){let n=r((e,t)=>{let n=e.x??0,r=e.y??0,i=t.x-n,a=t.y-r,o=(e.width??0)/2,s=(e.height??0)/2;return Math.abs(a)*o>Math.abs(i)*s?(a<0&&(s=-s),{x:n+(a===0?0:s*i/a),y:r+s}):(i<0&&(o=-o),{x:n+o,y:r+(i===0?0:o*a/i)})},`rectIntersect`),i=r((e,r)=>{let i=G(e.points??[]);if(i.length<2)return;let a=r?e.start:e.end,o=a?t.get(a):void 0,s=o?q(o):void 0;if(!o||!a||!s)return;let c=r?i[0]:i[i.length-1],l=r?i[1]:i[i.length-2],u=n(o,c),d=c;if(At(l,u)&&(d=l),L(u,d,X))return{edge:e,edgeId:String(e.id??``),nodeId:a,atStart:r,orientation:`V`,coord:u.x,min:Math.min(u.y,d.y),max:Math.max(u.y,d.y),boundary:u,railEnd:d,rect:s};if(R(u,d,X))return{edge:e,edgeId:String(e.id??``),nodeId:a,atStart:r,orientation:`H`,coord:u.y,min:Math.min(u.x,d.x),max:Math.max(u.x,d.x),boundary:u,railEnd:d,rect:s}},`terminalLaneFor`),a=r((e,t)=>Math.max(0,Math.min(e.max,t.max)-Math.max(e.min,t.min)),`projectedOverlapLength`),o=r((e,t)=>e.nodeId!==t.nodeId||e.orientation!==t.orientation?!1:e.orientation===`H`?(Math.abs(e.boundary.x-e.rect.left)<1||Math.abs(e.boundary.x-e.rect.right)<1)&&L(e.boundary,t.boundary,1):(Math.abs(e.boundary.y-e.rect.top)<1||Math.abs(e.boundary.y-e.rect.bottom)<1)&&R(e.boundary,t.boundary,1),`sameTerminalFace`),s=r((e,t)=>e.nodeId!==t.nodeId||e.orientation!==t.orientation?!1:a(e,t)>=Z&&Math.abs(e.coord-t.coord)<.5,`exactTerminalLaneConflict`),c=r((e,t)=>{if(e.nodeId!==t.nodeId||e.orientation!==t.orientation||e.orientation!==`H`||e.atStart===t.atStart)return!1;let n=a(e,t);if(n<Z)return!1;let r=e.rect.bottom-e.rect.top;return n<r||n>2*r?!1:o(e,t)&&Math.abs(e.coord-t.coord)<16},`nearTerminalLaneConflict`),l=r((e,t)=>{let n=G(e.edge.points??[]);if(n.length<2)return;let i=e.orientation===`V`?{x:e.boundary.x+t,y:e.boundary.y}:{x:e.boundary.x,y:e.boundary.y+t},a=e.orientation===`V`?{x:e.railEnd.x+t,y:e.railEnd.y}:{x:e.railEnd.x,y:e.railEnd.y+t};if(!r(()=>Math.abs(e.boundary.y-e.rect.top)<1||Math.abs(e.boundary.y-e.rect.bottom)<1?R(i,e.boundary,X)&&i.x>=e.rect.left+1&&i.x<=e.rect.right-1:Math.abs(e.boundary.x-e.rect.left)<1||Math.abs(e.boundary.x-e.rect.right)<1?L(i,e.boundary,X)&&i.y>=e.rect.top+1&&i.y<=e.rect.bottom-1:!1,`boundaryStaysOnSameFace`)())return;if(e.atStart){let t=n.length>1&&I(n[1],e.railEnd,X),r=n.slice(t?2:1),o=r[0];return o&&!At(o,a)?void 0:[i,a,...r]}let o=n.length>1&&I(n[n.length-2],e.railEnd,X),s=n.slice(0,o?-2:-1),c=s[s.length-1];if(!c||At(c,a))return[...s,a,i]},`shiftedCandidate`),u=r(e=>{let n=e.edge,r=G(n.points??[]);if(r.length!==2)return!1;let i=n.start,a=n.end,o=i?t.get(i):void 0,s=a?t.get(a):void 0;if(!o||!s)return!1;let c=o.x??0,l=o.y??0,u=s.x??0,d=s.y??0,[f,p]=r;return R(f,p,X)&&Math.abs(l-d)<1&&Math.abs(c-u)>1||L(f,p,X)&&Math.abs(c-u)<1&&Math.abs(l-d)>1},`laneIsStraightCollinearConnector`),d=[-7,7,-14,14,-21,21];for(let t=0;t<8;t++){let t=e.filter(e=>!e.isLayoutOnly).flatMap(e=>[i(e,!0),i(e,!1)]).filter(e=>!!e),n=!1;for(let e=0;e<t.length&&!n;e++)for(let r=e+1;r<t.length&&!n;r++){let a=t[e],o=t[r];if(a.edge===o.edge||!(s(a,o)||c(a,o)))continue;let f=!s(a,o),p=[a,o].sort((e,t)=>{let n=u(e),r=u(t);return n===r?Number(!t.atStart)-Number(!e.atStart):Number(n)-Number(r)});for(let e of p){for(let r of d){let a=l(e,r);if(!a)continue;let o=i({...e.edge,points:a},e.atStart);if(o&&!t.some(t=>t.edge!==e.edge&&(s(o,t)||f&&c(o,t)))){e.edge.points=a,n=!0;break}}if(n)break}}if(!n)return}}r(jt,`separateSharedRenderedTerminalLanes`);function Mt(e,t){let{realNodeRects:n,labelNodeRects:i}=ye(t.values()),a=r((t,r)=>{let a=t.start,o=t.end,s=Q(r);if(s.length!==r.length-1)return!1;let c=[a,o].filter(e=>!!e);for(let e of s)if(J(e.a,e.b,n,c,-2)||J(e.a,e.b,i,[],-2))return!1;for(let n of e){if(n===t||n.isLayoutOnly)continue;let e=n.points;if(!(!e||e.length<2)){for(let t of s)for(let n of Q(G(e)))if(H(t,n,.5)>=Z||Te(t.a,t.b,n.a,n.b,X))return!1}}return!0},`candidateIsSafe`),o=r((e,t)=>{if(t+4>=e.length)return;let n=e[t],r=e[t+1],i=e[t+2],a=e[t+3],o=e[t+4],s=z(n,r)&&B(r,i)&&z(i,a)&&B(a,o)&&L(n,a,X)&&L(n,o,X)&&L(r,i,X)&&(r.x-n.x)*(a.x-i.x)<0,c=B(n,r)&&z(r,i)&&B(i,a)&&z(a,o)&&R(n,a,X)&&R(n,o,X)&&R(r,i,X)&&(r.y-n.y)*(a.y-i.y)<0;if(s||c)return G([...e.slice(0,t+1),o,...e.slice(t+5)]);if(t+5>=e.length)return;let l=e[t+5],u=B(n,r)&&z(r,i)&&B(i,a)&&z(a,o)&&B(o,l)&&L(n,o,X)&&L(n,l,X)&&L(i,a,X)&&(i.x-r.x)*(o.x-a.x)<0,d=z(n,r)&&B(r,i)&&z(i,a)&&B(a,o)&&z(o,l)&&R(n,o,X)&&R(n,l,X)&&R(i,a,X)&&(i.y-r.y)*(o.y-a.y)<0;if(u||d)return G([...e.slice(0,t+1),l,...e.slice(t+6)])},`withoutDogleg`);for(let t=0;t<8;t++){let t=!1;for(let n of e){if(n.isLayoutOnly)continue;let e=G(n.points??[]);for(let r=0;r<=e.length-5;r++){let i=o(e,r);if(i&&a(n,i)){n.points=i,t=!0;break}}if(t)break}if(!t)return}}r(Mt,`collapseRedundantRectangularDoglegs`);function Nt(e,t){let{realNodeRects:n,labelNodeRects:i}=ye(t.values()),a=e.filter(e=>!e.isLayoutOnly),o=r((e,t,n)=>G(e===t?n??[]:e.points??[]),`pointsFor`),s=r((e,t)=>{let n=0;for(let r=0;r<a.length;r++){let i=Q(o(a[r],e,t));for(let s=r+1;s<a.length;s++){let r=Q(o(a[s],e,t));for(let e of i)for(let t of r)Te(e.a,e.b,t.a,t.b,X)&&n++}}return n},`strictCrossingCount`),c=r(e=>{let t=Q(e);if(t.length!==3)return;let n=t[1];if(t[0].horizontal!==n.horizontal&&t[2].horizontal!==n.horizontal)return{index:n.index,horizontal:n.horizontal,vertical:n.vertical,segment:n}},`middleRail`),l=r((e,t)=>{let r=[e.start,e.end].filter(e=>!!e);return n.filter(e=>{if(r.includes(e.id))return!1;let n=e.rect;return t.horizontal?V(t.a.x,t.b.x,n.left,n.right)>=Z&&t.a.y>=n.top-2&&t.a.y<=n.bottom+2:V(t.a.y,t.b.y,n.top,n.bottom)>=Z&&t.a.x>=n.left-2&&t.a.x<=n.right+2})},`blockingRectsFor`),u=r((e,t,n)=>{let r=e.map(e=>({...e}));if(t.horizontal)r[t.index].y=n,r[t.index+1].y=n;else if(t.vertical)r[t.index].x=n,r[t.index+1].x=n;else return;let i=Ae(G(r));return Q(i).length===i.length-1?i:void 0},`candidateByMovingRail`),d=r((e,t,r)=>{let c=[e.start,e.end].filter(e=>!!e),l=Q(t);if(l.length!==t.length-1)return!1;for(let e of l)if(J(e.a,e.b,n,c,-2)||J(e.a,e.b,i,[],-2))return!1;for(let t of a)if(t!==e){for(let e of l)for(let n of Q(o(t)))if(H(e,n,.5)>=Z)return!1}return s(e,t)<=r},`candidateIsSafe`);for(let e=0;e<8;e++){let e=s(),t=!1;for(let n of a){let r=o(n),i=c(r);if(!i)continue;let a=l(n,i.segment);if(a.length===0)continue;let s=i.horizontal?[Math.min(...a.map(e=>e.rect.top))-20,Math.max(...a.map(e=>e.rect.bottom))+20]:[Math.min(...a.map(e=>e.rect.left))-20,Math.max(...a.map(e=>e.rect.right))+20];for(let a of s){let o=u(r,i.segment,a);if(o&&d(n,o,e)){n.points=o,t=!0;break}}if(t)break}if(!t)return}}r(Nt,`liftObstacleHuggingSameSideRails`);function Pt(e,t,n){let i=r(e=>{let t=e.groupTitleRect;if(!(!t||typeof t.left!=`number`||typeof t.right!=`number`||typeof t.top!=`number`||typeof t.bottom!=`number`||!Number.isFinite(t.left)||!Number.isFinite(t.right)||!Number.isFinite(t.top)||!Number.isFinite(t.bottom)||t.right<=t.left||t.bottom<=t.top))return{left:t.left,right:t.right,top:t.top,bottom:t.bottom}},`validTitleRect`),a=s([...t.values()]),o=r(e=>{if(!a.isLane(e.id))return;let t=kt(e.direction??n);if(t===`LR`||t===`RL`||t===`BT`)return;let r=i(e),o=e.y,s=e.height;if(!r||typeof o!=`number`||typeof s!=`number`||!Number.isFinite(o)||!Number.isFinite(s)||s<=0)return;let c=r.right-r.left,l=r.bottom-r.top;if(!(l<=0||c<l))return{node:e,rect:r}},`topLaneTitleFor`),c=r((e,t)=>{if(!e.horizontal)return!1;let n=e.a.y;return n<t.top-X||n>t.bottom+X?!1:V(e.a.x,e.b.x,t.left,t.right)>=Z},`horizontalSegmentIntersectsTitle`),l=[...t.values()].map(o).filter(e=>!!e);if(l.length===0)return;let u=0;for(let t of e){if(t.isLayoutOnly)continue;let e=G(t.points??[]);for(let t of Q(e))for(let e of l)c(t,e.rect)&&(u=Math.max(u,e.rect.bottom-t.a.y+4))}if(!(u<=X))for(let e of l){let t=e.node.y,n=e.node.height;typeof t!=`number`||typeof n!=`number`||!Number.isFinite(t)||!Number.isFinite(n)||n<=0||(e.node.y=t-u/2,e.node.height=n+u,e.node.groupTitleRect={...e.rect,top:e.rect.top-u,bottom:e.rect.bottom-u})}}r(Pt,`liftTopLaneTitleBandsAboveRails`);function Ft(e,t,n){let i=r(e=>{let t=e.groupTitleRect;if(!(!t||typeof t.left!=`number`||typeof t.right!=`number`||typeof t.top!=`number`||typeof t.bottom!=`number`||!Number.isFinite(t.left)||!Number.isFinite(t.right)||!Number.isFinite(t.top)||!Number.isFinite(t.bottom)||t.right<=t.left||t.bottom<=t.top))return{left:t.left,right:t.right,top:t.top,bottom:t.bottom}},`validTitleRect`),a=s([...t.values()]),o=r(e=>{if(!a.isLane(e.id)||kt(e.direction??n)!==`LR`)return;let t=i(e),r=e.x,o=e.width;if(!t||typeof r!=`number`||typeof o!=`number`||!Number.isFinite(r)||!Number.isFinite(o)||o<=0)return;let s=t.right-t.left,c=t.bottom-t.top;if(!(s<=0||c<s))return{node:e,rect:t}},`leftLaneTitleFor`),c=r((e,t)=>{if(!e.vertical)return!1;let n=e.a.x;return n<t.left-X||n>t.right+X?!1:V(e.a.y,e.b.y,t.top,t.bottom)>=Z},`verticalSegmentIntersectsTitle`),l=r((e,t)=>{if(!e.horizontal)return!1;let n=e.a.y;return n<t.top-X||n>t.bottom+X?!1:V(e.a.x,e.b.x,t.left,t.right)>=Z},`horizontalSegmentIntersectsTitle`),u=[...t.values()].map(o).filter(e=>!!e);if(u.length===0)return;let d=0;for(let t of e){if(t.isLayoutOnly)continue;let e=G(t.points??[]);for(let t of Q(e))for(let e of u)if(c(t,e.rect))d=Math.max(d,e.rect.right-t.a.x+4);else if(l(t,e.rect)){let n=Math.min(t.a.x,t.b.x);d=Math.max(d,e.rect.right-n+4)}}if(!(d<=X))for(let e of u){let t=e.node.x,n=e.node.width;typeof t!=`number`||typeof n!=`number`||!Number.isFinite(t)||!Number.isFinite(n)||n<=0||(e.node.x=t-d/2,e.node.width=n+d,e.node.groupTitleRect={...e.rect,left:e.rect.left-d,right:e.rect.right-d})}}r(Ft,`shiftLeftLaneTitleBandsLeftOfRails`);function It(e,t){let{realNodeRects:n}=ye(t.values()),i=e.filter(e=>!e.isLayoutOnly),a=r((e,t=new Map)=>G(t.get(e)??e.points??[]),`replacementPointsFor`),o=r((e=new Map)=>{let t=0;for(let n=0;n<i.length;n++){let r=Q(a(i[n],e));for(let o=n+1;o<i.length;o++){let n=Q(a(i[o],e));for(let e of r)for(let r of n)Te(e.a,e.b,r.a,r.b,X)&&t++}}return t},`crossingCount`),s=r((e=new Map)=>i.reduce((t,n)=>t+W(a(n,e)),0),`totalBends`),c=r(e=>{let t=a(e);if(t.length<4)return;let n=t[t.length-2],r=t[t.length-1];if(z(n,r,X)||B(n,r,X))return{tailStart:n,terminal:r}},`terminalTailFor`),l=r((e,t)=>{let n=a(e);if(n.length<3)return;let r=n[0],i=n[1],o;if(z(r,i,X))o={x:i.x,y:t.tailStart.y};else if(B(r,i,X))o={x:t.tailStart.x,y:i.y};else return;let s=Ae(G([r,i,o,t.tailStart,t.terminal]));return Q(s).length===s.length-1?s:void 0},`candidateWithDestinationTail`),u=r((e,t)=>{let r=[e.start,e.end].filter(e=>!!e);for(let e of Q(t))if(J(e.a,e.b,n,r,-2))return!0;return!1},`pathHasNodeHit`),d=r((e,t,n)=>{for(let r of i)if(r!==e){for(let e of Q(t))for(let t of Q(a(r,n)))if(H(e,t,.5)>=Z)return!0}return!1},`pathHasSharedTrack`),f=r((e,t,n)=>!u(e,t)&&!d(e,t,n),`candidateIsSafe`),p=r(()=>{let e=new Map;for(let n of i){let r=n.end;if(!r||!t.has(r)||a(n).length<4)continue;let i=e.get(r)??[];i.push(n),e.set(r,i)}return e},`edgesByDestination`);for(let e=0;e<4;e++){let e=o();if(e===0)return;let t=s(),n,r=e,i=t;for(let t of p().values())for(let a=0;a<t.length;a++)for(let u=a+1;u<t.length;u++){let d=t[a],p=t[u],m=c(d),h=c(p);if(!m||!h)continue;let g=l(d,h),_=l(p,m);if(!g||!_)continue;let v=new Map([[d,g],[p,_]]);if(!f(d,g,v)||!f(p,_,v))continue;let y=o(v),b=s(v);y>=e||y>r||y===r&&b>=i||(n=v,r=y,i=b)}if(!n)return;for(let[e,t]of n)e.points=t}}r(It,`swapDestinationTerminalTailsToReduceCrossings`);function Lt(e,t){let{realNodeRects:n,labelNodeRects:i}=ye(t.values()),a=e.filter(e=>!e.isLayoutOnly),o=r((e,t=new Map)=>G(t.get(e)??e.points??[]),`replacementPointsFor`),s=r((e=new Map)=>{let t=0;for(let n=0;n<a.length;n++){let r=Q(o(a[n],e));for(let i=n+1;i<a.length;i++){let n=Q(o(a[i],e));for(let e of r)for(let r of n)Te(e.a,e.b,r.a,r.b,X)&&t++}}return t},`strictCrossingCount`),c=r((e=new Map)=>a.reduce((t,n)=>t+W(o(n,e)),0),`totalBends`),l=r(e=>{let n=e.start,r=e.end,i=n?t.get(n):void 0,a=r?t.get(r):void 0,o=i?q(i):void 0,s=a?q(a):void 0;return o&&s?{src:o,dst:s}:void 0},`endpointRectsFor`),u=r((e,t,n)=>{if(n.index<=0||n.index+1>=t.length-1)return;let r=l(e);if(r){if(n.vertical){let i=n.a.x,a=Math.min(r.src.left,r.dst.left),o=Math.max(r.src.right,r.dst.right),s=i<a-X?`left`:i>o+X?`right`:void 0;return s?{edge:e,points:t,segmentIndex:n.index,axis:`vertical`,side:s,coord:i,min:Math.min(n.a.y,n.b.y),max:Math.max(n.a.y,n.b.y)}:void 0}if(n.horizontal){let i=n.a.y,a=Math.min(r.src.top,r.dst.top),o=Math.max(r.src.bottom,r.dst.bottom),s=i<a-X?`top`:i>o+X?`bottom`:void 0;return s?{edge:e,points:t,segmentIndex:n.index,axis:`horizontal`,side:s,coord:i,min:Math.min(n.a.x,n.b.x),max:Math.max(n.a.x,n.b.x)}:void 0}}},`externalRailForSegment`),d=r(()=>{let e=[];for(let t of a){let n=o(t);for(let r of Q(n)){let i=u(t,n,r);i&&e.push(i)}}return e},`collectExternalRails`),f=r((e,t)=>e.edge!==t.edge&&e.axis===t.axis&&e.side===t.side&&V(e.min,e.max,t.min,t.max)>=Z,`railsInteract`),p=r(e=>{let t=[],n=new Set;for(let r of e){if(n.has(r))continue;let i=[r],a=[];for(n.add(r);i.length>0;){let t=i.pop();a.push(t);for(let r of e)!n.has(r)&&f(t,r)&&(n.add(r),i.push(r))}a.length>1&&t.push(a)}return t},`connectedComponents`),m=r(e=>{let t=[];for(let n of e)t.some(e=>Math.abs(e-n.coord)<X)||t.push(n.coord);for(;t.length<e.length;){let n=Math.min(...t),r=Math.max(...t),i=e[0].side;t.push(i===`left`||i===`top`?n-12*(e.length-t.length):r+12*(e.length-t.length))}return t},`uniqueCoordsFor`),h=r(e=>{let t=e.map(e=>e.coord),n=m(e),i=[];if(e.length<=6){let a=Array(n.length).fill(!1),o=[],s=r(()=>{if(o.length===e.length)o.some((e,n)=>Math.abs(e-t[n])>=X)&&i.push([...o]);else for(let[e,t]of n.entries())a[e]||(a[e]=!0,o.push(t),s(),o.pop(),a[e]=!1)},`visit`);return s(),i}for(let e=0;e<t.length;e++)for(let n=e+1;n<t.length;n++){let r=[...t];[r[e],r[n]]=[r[n],r[e]],i.push(r)}return i},`coordinateAssignmentsFor`),g=r((e,t)=>{let n=new Map;for(let[r,i]of e.entries()){let e=t[r],a=n.get(i.edge)??i.points.map(e=>({x:e.x,y:e.y}));i.axis===`vertical`?(a[i.segmentIndex].x=e,a[i.segmentIndex+1].x=e):(a[i.segmentIndex].y=e,a[i.segmentIndex+1].y=e),n.set(i.edge,a)}let r=new Map;for(let[e,t]of n){let n=Ae(G(t));if(Q(n).length!==n.length-1)return;r.set(e,n)}return r},`replacementsForAssignment`),_=r(e=>{for(let[t,r]of e){let e=[t.start,t.end].filter(e=>!!e);for(let t of Q(r))if(J(t.a,t.b,n,e,-2)||J(t.a,t.b,i,[],-2))return!1}for(let t=0;t<a.length;t++){let n=a[t],r=e.has(n),i=Q(o(n,e));for(let n=t+1;n<a.length;n++){let t=a[n];if(!r&&!e.has(t))continue;let s=Q(o(t,e));for(let e of i)for(let t of s)if(H(e,t,.5)>=Z)return!1}}return!0},`candidateIsSafe`);for(let e=0;e<4;e++){let e=s();if(e===0)return;let t,n=e,r=c(),i=1/0;for(let a of p(d()))for(let o of h(a)){let l=g(a,o);if(!l||!_(l))continue;let u=s(l);if(u>=e)continue;let d=c(l),f=a.reduce((e,t,n)=>e+Math.abs(o[n]-t.coord),0);u>n||u===n&&(d>r||d===r&&f>=i)||(t=l,n=u,r=d,i=f)}if(!t)return;for(let[e,n]of t)e.points=n}}r(Lt,`reassignCrossingExternalRailChannels`);function Rt(e,t){let{realNodeRects:n,labelNodeRects:i}=ye(t.values()),a=e.filter(e=>!e.isLayoutOnly),o=r((e,t,n)=>G(e===t?n??[]:e.points??[]),`pointsFor`),s=r(e=>Q(e).reduce((e,t)=>{let n=t.a.x-t.b.x,r=t.a.y-t.b.y;return e+Math.hypot(n,r)},0),`pathLength`),c=r((e,t)=>{let n=0;for(let r=0;r<a.length;r++){let i=Q(o(a[r],e,t));for(let s=r+1;s<a.length;s++){let r=Q(o(a[s],e,t));for(let e of i)for(let t of r)Te(e.a,e.b,t.a,t.b,X)&&n++}}return n},`strictCrossingCount`),l=r((e,t)=>{if(e.horizontal){let n=e.a.y;return(Math.abs(n-t.top)<1||Math.abs(n-t.bottom)<1)&&V(e.a.x,e.b.x,t.left,t.right)>=Z}if(e.vertical){let n=e.a.x;return(Math.abs(n-t.left)<1||Math.abs(n-t.right)<1)&&V(e.a.y,e.b.y,t.top,t.bottom)>=Z}return!1},`segmentRunsAlongRectBorder`),u=r(e=>{let n=[e.start,e.end].filter(e=>!!e),r=[];for(let e of n){let n=t.get(e),i=n?q(n):void 0;i&&r.push(i)}return r},`endpointRectsFor`),d=r((e,t)=>{if(t+3>=e.length)return[];let n=e[t],r=e[t+1],i=e[t+2],a=e[t+3],o=z(n,r,X)&&B(r,i,X)&&z(i,a,X),s=B(n,r,X)&&z(r,i,X)&&B(i,a,X);if(!o&&!s||!(o?Math.sign(r.x-n.x)!==Math.sign(a.x-i.x):Math.sign(r.y-n.y)!==Math.sign(a.y-i.y)))return[];let c=L(n,a,X)||R(n,a,X)?[]:[{x:n.x,y:a.y},{x:a.x,y:n.y}],l=c.length===0?[[...e.slice(0,t+1),...e.slice(t+3)]]:c.map(n=>[...e.slice(0,t+1),n,...e.slice(t+3)]),u=new Set;return l.map(e=>Ae(G(e))).filter(e=>{if(Q(e).length!==e.length-1||!e.some(e=>I(e,a,X)))return!1;let t=e.map(e=>`${e.x.toFixed(3)},${e.y.toFixed(3)}`).join(`|`);return!u.has(t)&&(u.add(t),!0)})},`shortcutCandidatesAt`),f=r((e,t,r)=>{let s=[e.start,e.end].filter(e=>!!e),d=u(e);for(let e of Q(t))if(J(e.a,e.b,n,s,-2)||J(e.a,e.b,i,[],-2)||d.some(t=>l(e,t)))return!1;for(let n of a)if(n!==e){for(let e of Q(t))for(let t of Q(o(n)))if(H(e,t,.5)>=Z)return!1}return c(e,t)<=r},`candidateIsSafe`);for(let e=0;e<8;e++){let e=c(),t,n,r=e,i=1/0,l=1/0;for(let u of a){let a=o(u),p=W(a,X),m=s(a);for(let o=0;o<=a.length-4;o++)for(let h of d(a,o)){let a=W(h,X),o=s(h);if(!(a<p||a===p&&o<m-X)||!f(u,h,e))continue;let d=c(u,h);d>r||d===r&&(a>i||a===i&&o>=l)||(t=u,n=h,r=d,i=a,l=o)}}if(!t||!n)return;t.points=n}}r(Rt,`shortcutRedundantOrthogonalJogs`);function zt(e,t){let n=[];for(let e of t.values()){if(e.isGroup||e.isEdgeLabel)continue;let t=e.x??0,r=e.y??0,i=q(e);i&&n.push({id:String(e.id??``),cx:t,cy:r,rect:i})}if(n.length===0)return;let i=new Map(n.map(e=>[e.id,e])),a=n.map(e=>({id:e.id,rect:e.rect})),o=[`top`,`bottom`,`left`,`right`],s={top:Math.min(...n.map(e=>e.rect.top))-20,bottom:Math.max(...n.map(e=>e.rect.bottom))+20,left:Math.min(...n.map(e=>e.rect.left))-20,right:Math.max(...n.map(e=>e.rect.right))+20},c=e.filter(e=>!e.isLayoutOnly),l=new Map(c.map((e,t)=>[e,t])),u=r(e=>{let t=e===`left`||e===`top`?-1:1,n=[];for(let r=0;r<=2;r++)n.push(s[e]+t*20*r);return n},`outwardTracksForSide`),d=r((e,t=new Map)=>G(t.get(e)??e.points??[]),`replacementPointsFor`),f=r((e,t)=>{let n=0;for(let r of e)for(let e of t)Te(r.a,r.b,e.a,e.b,X)&&n++;return n},`crossingCountBetweenSegments`),p=r((e,t)=>f(Q(e),Q(t)),`crossingCountBetweenPaths`),m=r((e=new Map)=>{let t=0,n=[],i=new Set,a=[],o=r(e=>{i.has(e)||(i.add(e),a.push(e))},`addEdge`);for(let r=0;r<c.length;r++){let i=c[r],a=d(i,e);for(let s=r+1;s<c.length;s++){let r=c[s],l=p(a,d(r,e));l>0&&(t+=l,n.push({first:i,second:r,count:l}),o(i),o(r))}}return a.sort((e,t)=>(l.get(e)??0)-(l.get(t)??0)),{count:t,pairs:n,edgeSet:i,edges:a}},`crossingSnapshot`),h=r((e,t)=>{let n=new Set(t.keys());if(n.size===0)return e.count;let r=0;for(let t of e.pairs)(n.has(t.first)||n.has(t.second))&&(r+=t.count);let i=0;for(let e=0;e<c.length;e++){let r=c[e],a=n.has(r),o=d(r,t);for(let r=e+1;r<c.length;r++){let e=c[r];(a||n.has(e))&&(i+=p(o,d(e,t)))}}return e.count-r+i},`crossingCountWithReplacements`),g=r(e=>{let t=new Map;for(let n of e.pairs){let e=t.get(n.first)??new Set;e.add(n.second),t.set(n.first,e);let r=t.get(n.second)??new Set;r.add(n.first),t.set(n.second,r)}let n=[],r=new Set;for(let i of e.edges){if(r.has(i))continue;let e=[i],a=[];for(r.add(i);e.length>0;){let n=e.pop();a.push(n);for(let i of t.get(n)??[])r.has(i)||(r.add(i),e.push(i))}a.sort((e,t)=>(l.get(e)??0)-(l.get(t)??0)),a.length>1&&n.push(a)}return n},`crossingComponents`),_=r(e=>[e.start,e.end].filter(e=>!!e),`endpointIdsFor`),v=r(e=>{let t=[];for(let n of g(e)){let e=new Set(n),r=new Set(n.flatMap(e=>_(e))),i=[...n];for(let t of c)e.has(t)||_(t).some(e=>r.has(e))&&i.push(t);i.sort((e,t)=>(l.get(e)??0)-(l.get(t)??0)),t.push(i)}return t},`pairSearchGroups`),y=r((e,t,n)=>h(e,new Map([[t,n]])),`crossingCountWithSingleReplacement`),b=r(e=>{let t=new Map;for(let n of e.pairs)t.set(n.first,(t.get(n.first)??0)+n.count),t.set(n.second,(t.get(n.second)??0)+n.count);return t},`currentCrossingsByEdge`),x=r(e=>e.slice(1).reduce((t,n,r)=>{let i=e[r];return t+Math.abs(n.x-i.x)+Math.abs(n.y-i.y)},0),`pathLength`),S=r((e=new Map)=>c.reduce((t,n)=>t+W(d(n,e)),0),`totalBends`),C=r((e=new Map)=>c.reduce((t,n)=>t+x(d(n,e)),0),`totalLength`),w=r((e,t)=>ce(e,t,Tt.ROUTE_TOUCH_TOLERANCE),`touchesAtBend`),T=r((e,t,n=new Map)=>{let r=Q(t);for(let i of c)if(i!==e){for(let e of r)for(let t of Q(d(i,n)))if(H(e,t,.5)>=Z)return!0;if(w(t,d(i,n)))return!0}return!1},`pathHasSegmentConflict`),E=r((e,t)=>{let n=[e.start,e.end].filter(e=>!!e);for(let e of Q(t))if(J(e.a,e.b,a,n,-2))return!0;return!1},`pathHitsNode`),D=r((e,t)=>{let n=Ae(G(t));Q(n).length===n.length-1&&e.push(n)},`pushOrthogonalCandidate`),O=r(e=>e===`left`||e===`right`,`sideIsHorizontal`),k=r((e,t,n)=>{switch(t){case`left`:return Math.min(e.x,n.x)-20;case`right`:return Math.max(e.x,n.x)+20;case`top`:return Math.min(e.y,n.y)-20;case`bottom`:return Math.max(e.y,n.y)+20}},`localTrackForSameSide`),ee=r((e,t,n,r)=>{let i=n===`left`||n===`top`?-1:1,a=[k(t,n,r),s[n]];for(let o of a)for(let a=0;a<=2;a++)D(e,_e(t,n,r,o+i*20*a))},`addSameSideCandidates`),A=r((e,t,n,r,i)=>{for(let a of u(n))for(let n of u(i))D(e,[t,{x:a,y:t.y},{x:a,y:n},{x:r.x,y:n},r])},`addHorizontalToVerticalCandidates`),j=r((e,t,n,r,i)=>{for(let a of u(n))for(let n of u(i))D(e,[t,{x:t.x,y:a},{x:n,y:a},{x:n,y:r.y},r])},`addVerticalToHorizontalCandidates`),M=r((e,t,n,r,i)=>{let a=[...u(`top`),...u(`bottom`)];for(let o of u(n))for(let n of u(i))for(let i of a)D(e,[t,{x:o,y:t.y},{x:o,y:i},{x:n,y:i},{x:n,y:r.y},r])},`addHorizontalPairCandidates`),N=r((e,t,n,r,i)=>{let a=[...u(`left`),...u(`right`)];for(let o of u(n))for(let n of u(i))for(let i of a)D(e,[t,{x:t.x,y:o},{x:i,y:o},{x:i,y:n},{x:r.x,y:n},r])},`addVerticalPairCandidates`),P=r(e=>{let t=new Set;return e.map(e=>G(e)).filter(e=>{let n=e.map(e=>`${e.x.toFixed(3)},${e.y.toFixed(3)}`).join(`|`);return t.has(n)||e.length<2?!1:(t.add(n),!0)})},`dedupeCandidatePaths`),te=r((e,t,n,r)=>{let i=[],a=ge(e,t,n,r,20,X);a&&D(i,a),t===r&&ee(i,e,t,n);let o=O(t),s=O(r);return o&&!s?A(i,e,t,n,r):!o&&s?j(i,e,t,n,r):o?M(i,e,t,n,r):N(i,e,t,n,r),P(i)},`buildCandidatesForSides`),ne=r((e,t,n,r)=>{let i=[...u(`left`),...u(`right`)],a=[...u(`top`),...u(`bottom`)];for(let s of o){let o=he(r,s),c=s===`top`||s===`bottom`?u(s):a;for(let r of i){O(s)&&D(e,[t,n,{x:r,y:n.y},{x:r,y:o.y},o]);for(let i of c)D(e,[t,n,{x:r,y:n.y},{x:r,y:i},{x:o.x,y:i},o])}}},`addVerticalDepartureOuterTrackCandidates`),re=r((e,t,n,r)=>{let i=[...u(`left`),...u(`right`)],a=[...u(`top`),...u(`bottom`)];for(let s of o){let o=he(r,s),c=s===`left`||s===`right`?u(s):i;for(let r of a){O(s)||D(e,[t,n,{x:n.x,y:r},{x:o.x,y:r},o]);for(let i of c)D(e,[t,n,{x:n.x,y:r},{x:i,y:r},{x:i,y:o.y},o])}}},`addHorizontalDepartureOuterTrackCandidates`),F=r(e=>{let t=e.start,n=e.end,r=n?i.get(n):void 0;if(!t||!r)return[];let a=G(e.points??[]);if(a.length<4)return[];let o=a[0],s=a[1],c=[];return B(o,s,X)?ne(c,o,s,r):z(o,s,X)&&re(c,o,s,r),c},`terminalPreservingOuterTrackCandidates`),ie=r(e=>{let t=e.start,n=e.end,r=t?i.get(t):void 0,a=n?i.get(n):void 0;if(!r||!a)return[];let s=[];for(let e of o){let t=he(r,e);for(let n of o)s.push(...te(t,e,he(a,n),n))}return s.push(...F(e)),s},`candidatePathsFor`),ae=r(()=>new Map(c.map(e=>[e,Q(d(e))])),`currentSegmentsByEdge`),I=r((e,t,n,r)=>{let i=new Set;for(let a of c){if(a===e)continue;let o=r.get(a)??Q(d(a));(n.some(e=>o.some(t=>H(e,t,.5)>=Z))||w(t,d(a)))&&i.add(a)}return i},`sharedTrackConflictsFor`),L=r((e,t,n,r)=>{let i=new Set;return ie(e).map(e=>Ae(G(e))).filter(t=>{if(E(e,t))return!1;let n=t.map(e=>`${e.x.toFixed(3)},${e.y.toFixed(3)}`).join(`|`);return i.has(n)||t.length<2?!1:(i.add(n),!0)}).map(i=>{let a=Q(i),o=0;for(let t of c)t!==e&&(o+=f(a,n.get(t)??Q(d(t))));return{candidate:i,candidateSegments:a,crossings:t.count-(r.get(e)??0)+o,bends:W(i,X),totalBends:W(i),length:x(i)}}).filter(({crossings:e})=>e<=t.count).sort((e,t)=>e.crossings-t.crossings||e.bends-t.bends||e.length-t.length).slice(0,48).map(t=>({path:t.candidate,segments:t.candidateSegments,sharedTrackConflicts:I(e,t.candidate,t.candidateSegments,n),totalBends:t.totalBends,length:t.length}))},`pairCandidatesFor`),R=r((e,t,n,r,i,a)=>{let o=0;for(let n of e.pairs)(n.first===t||n.second===t||n.first===r||n.second===r)&&(o+=n.count);let s=f(n.segments,i.segments);for(let e of c){if(e===t||e===r)continue;let o=a.get(e)??Q(d(e));s+=f(n.segments,o)+f(i.segments,o)}return e.count-o+s},`pairCrossingCount`),V=r((e,t)=>{for(let n of e.sharedTrackConflicts)if(n!==t)return!1;return!0},`conflictsOnlyWith`),U=r((e,t)=>e.segments.some(e=>t.segments.some(t=>H(e,t,.5)>=Z))||w(e.path,t.path),`candidatesShareTrack`),oe=r((e,t,n,r)=>V(t,n.edge)&&V(r,e.edge)&&!U(t,r),`pairCandidatesAreCompatible`),se=r((e,t,n,r,i)=>{let a=R(e.current,t.edge,n,r.edge,i,e.baseSegments);if(!(a>=e.current.count))return{replacements:new Map([[t.edge,n.path],[r.edge,i.path]]),crossings:a,bends:e.currentBends-(e.baseBendsByEdge.get(t.edge)??0)-(e.baseBendsByEdge.get(r.edge)??0)+n.totalBends+i.totalBends,length:e.currentLength-(e.baseLengthByEdge.get(t.edge)??0)-(e.baseLengthByEdge.get(r.edge)??0)+n.length+i.length}},`scorePairReplacement`),le=r((e,t)=>e.crossings<t.crossings||e.crossings===t.crossings&&(e.bends<t.bends||e.bends===t.bends&&e.length<t.length),`pairScoreIsBetter`),ue=r((e,t,n,r)=>{let i=r;for(let r of t.candidates)for(let a of n.candidates){if(!oe(t,r,n,a))continue;let o=se(e,t,r,n,a);o&&le(o,i)&&(i=o)}return i},`bestScoreForOptionPair`),de=r(e=>{let t=S(),n=C(),r=ae(),i=b(e),a=new Map(c.map(e=>[e,W(d(e))])),o=new Map(c.map(e=>[e,x(d(e))])),s=new Map,l=v(e);for(let t of l)for(let n of t){if(s.has(n))continue;let t=L(n,e,r,i);t.length>0&&s.set(n,{edge:n,candidates:t})}let u={replacements:new Map,crossings:e.count,bends:t,length:n},f={current:e,currentBends:t,currentLength:n,baseBendsByEdge:a,baseLengthByEdge:o,baseSegments:r};for(let t of l){let n=new Set(t.filter(t=>e.edgeSet.has(t))),r=t.map(e=>s.get(e)).filter(e=>!!e);for(let e=0;e<r.length;e++){let t=r[e];for(let i=e+1;i<r.length;i++){let e=r[i];(n.has(t.edge)||n.has(e.edge))&&(u=ue(f,t,e,u))}}}return u.replacements.size>0?u.replacements:void 0},`bestPairedReplacement`);for(let e=0;e<4;e++){let e=m(),t=e.count;if(t===0)return;let n,r,i=t,a=1/0;for(let o of e.edges){let s=W(d(o),X);for(let c of ie(o)){let l=E(o,c),u=!l&&T(o,c),d=y(e,o,c),f=W(c,X);l||u||(d<t||d===t&&f<s)&&(d>i||d===i&&f>=a||(n=o,r=c,i=d,a=f))}}if(n&&r){n.points=r;continue}let o=de(e);if(!o)return;for(let[e,t]of o)e.points=t}}r(zt,`resolveRenderedOrthogonalCrossings`);var Bt=.001,Vt=8;function Ht(e,t){let{nodeInfoById:n,realNodeRects:i}=ve(t),a=[`top`,`bottom`,`left`,`right`],o={top:Math.min(...i.map(e=>e.rect.top))-20,bottom:Math.max(...i.map(e=>e.rect.bottom))+20,left:Math.min(...i.map(e=>e.rect.left))-20,right:Math.max(...i.map(e=>e.rect.right))+20},s=r((e,t,n,r)=>{let i=[],a=ge(e,t,n,r,20,Bt);return a&&i.push(a),t===r&&i.push(_e(e,t,n,o[t])),i},`buildOrthogonalPathCandidates`),c=r((e,t)=>{for(let n=0;n<e.length-1;n++){let r=e[n],a=e[n+1];if(J(r,a,i,t,1))return!0}return!1},`pathHitsNode`),l=r((t,n,r=!1)=>{let i=0,a=U(t,Bt),o=n.start,s=n.end;for(let t of e){if(t===n||t.isLayoutOnly)continue;let e=t.start,c=t.end;if(!r&&o&&s&&(e===o||e===s||c===o||c===s))continue;let l=t.points;if(!(!l||l.length<2))for(let e of a)for(let t of U(l,Bt))(Se(e.a,e.b,t.a,t.b,Bt,Bt)||H(e,t,Bt)>=Vt)&&i++}return i},`pathConflictCount`),u=r((e,t)=>{let n=Math.abs(e.y-t.rect.top),r=Math.abs(e.y-t.rect.bottom),i=Math.abs(e.x-t.rect.left),a=Math.abs(e.x-t.rect.right),o=`top`,s=n;return r<s&&(o=`bottom`,s=r),i<s&&(o=`left`,s=i),a<s&&(o=`right`,s=a),o},`nearestSideOfRect`),d=new Map,f=r((e,t,n)=>{let r=d.get(e)??[];r.push({side:t,edgeId:n}),d.set(e,r)},`addFaceClaim`);for(let t of e){if(t.isLayoutOnly)continue;let e=t.points??[];if(e.length<1)continue;let r=t.id??``,i=t.start,a=t.end;if(i){let t=n.get(i);t&&f(i,u(e[0],t),r)}if(a){let t=n.get(a);t&&f(a,u(e[e.length-1],t),r)}}let p=r((e,t,n)=>d.get(e)?.some(e=>e.edgeId!==n&&e.side===t)??!1,`faceIsClaimed`);for(let t of e){if(t.isLayoutOnly)continue;let e=t.points;if(!e||e.length<2)continue;let r=W(e,Bt);if(r<4)continue;let i=t.start,o=t.end;if(!i||!o)continue;let m=n.get(i),h=n.get(o);if(!m||!h)continue;let g=t.id??``,_=l(e,t,!0),v=l(e,t),y,b=_,x=r;for(let e of a){if(p(i,e,g))continue;let n=he(m,e);for(let r of a){if(p(o,r,g))continue;let a=he(h,r);for(let u of s(n,e,a,r)){if(c(u,[i,o]))continue;let e=W(u,Bt);if(_>0){let n=l(u,t,!0);if(n>b||n===b&&e>=x)continue;b=n,x=e,y=u}else l(u,t)>v||e<x&&(x=e,y=u)}}}if(y){t.points=y;let e=d.get(i);e&&d.set(i,e.filter(e=>e.edgeId!==g));let n=d.get(o);n&&d.set(o,n.filter(e=>e.edgeId!==g)),f(i,u(y[0],m),g),f(o,u(y[y.length-1],h),g)}}}r(Ht,`simplifyDetouredEdges`);var Ut=.001,Wt=10,Gt=7;function Kt(e,t){let n=t?0:e.length-1,r=t?1:-1,i=e[n],a=e[n+r];if(!i||!a)return;let o=a.x-i.x,s=a.y-i.y;if(!(Math.abs(o)+Math.abs(s)<Ut)){if(Math.abs(s)<=Ut){let e=i.x+Math.sign(o)*Wt;return{left:Math.min(i.x,e),right:Math.max(i.x,e),top:i.y-Gt,bottom:i.y+Gt}}if(Math.abs(o)<=Ut){let e=i.y+Math.sign(s)*Wt;return{left:i.x-Gt,right:i.x+Gt,top:Math.min(i.y,e),bottom:Math.max(i.y,e)}}return{left:Math.min(i.x,a.x),right:Math.max(i.x,a.x),top:Math.min(i.y,a.y),bottom:Math.max(i.y,a.y)}}}r(Kt,`markerClearanceRectFor`);function qt(e){return{left:Math.min(e.left,e.right),right:Math.max(e.left,e.right),top:Math.min(e.top,e.bottom),bottom:Math.max(e.top,e.bottom)}}r(qt,`normalizeRect`);function Jt(e,t){let n=G(t);return[Kt(n,!0),Kt(n,!1)].some(t=>t&&K(e,qt(t)))}r(Jt,`labelOverlapsOwnMarker`);function Yt(e,t){let n=[];for(let t of e){if(t.isLayoutOnly)continue;let e=t.points;if(!(!e||e.length<2))for(let r=0;r<e.length-1;r++)n.push({edgeId:t.id,p1:e[r],p2:e[r+1]})}let i=[],a=[],o=s([...t.values()]);for(let e of t.values()){let t=e.isGroup;if(o.isLane(e.id)){let t=q(e);t&&a.push({id:e.id,rect:t});continue}if(t||e.isEdgeLabel)continue;let n=q(e);n&&i.push({nodeId:e.id,rect:n})}let c=r((e,t)=>{let n=pe(t,3);for(let{nodeId:t,rect:r}of i)if(t!==e&&K(n,r))return!0;return!1},`labelOverlapsForeignNode`),l=r((e,t)=>{let r=pe(t,3);for(let t of n)if(t.edgeId!==e&&ue(t.p1,t.p2,r))return!0;return!1},`labelOverlapsForeignEdge`),u=r((e,t,n)=>c(e,n)||l(t,n),`labelOverlapsAnything`),d=[],f=r(e=>{for(let{id:t,rect:n}of a)if(fe(n,e))return t},`findContainingLane`),p=r((e,t)=>d.some(n=>n.labelId!==e&&K(t,n.rect)),`overlapsPlacedLabel`);for(let n of e){if(n.isLayoutOnly)continue;let e=n.labelNodeId;if(!e)continue;let i=t.get(e);if(!i)continue;let o=n.points;if(!o||o.length<2)continue;let s=i.width??0,m=i.height??0;if(s<=0||m<=0)continue;let h=[];for(let e=0;e<o.length-1;e++){let t=o[e],n=o[e+1],r=Math.abs(t.x-n.x),i=Math.abs(t.y-n.y);r<Ut&&i<Ut||r>=Ut&&i>=Ut||h.push({idx:e,length:r+i,orientation:r>=Ut?`horizontal`:`vertical`,midX:(t.x+n.x)/2,midY:(t.y+n.y)/2})}if(h.length===0)continue;let g=h.length>=3?h.filter(e=>e.idx>0&&e.idx<h.length-1):h,_=g.length>0?g:h,v=s>=m?`horizontal`:`vertical`,y=r(e=>[...e].sort((e,t)=>{let n=e.orientation===v;if(n!==(t.orientation===v))return n?-1:1;let r=e.length>=(e.orientation===`horizontal`?s:m)+2;return r===t.length>=(t.orientation===`horizontal`?s:m)+2?t.length-e.length:r?-1:1}),`rankSegments`),b=h[0],x=h[h.length-1],S=[.5,.25,.75,.05,.95,.15,.85,.1,.9],C=r((e,t)=>{let n=o[e.idx],r=o[e.idx+1];return{midX:n.x+(r.x-n.x)*t,midY:n.y+(r.y-n.y)*t}},`anchorAtT`),w=r((e,t,n)=>Math.min(n,Math.max(t,e)),`clamp`),T=r((e,t)=>e.midX>=t.left-Ut&&e.midX<=t.right+Ut&&e.midY>=t.top-Ut&&e.midY<=t.bottom+Ut,`pointInsideRectInclusive`),E=r(e=>{let t=me(e.midX,e.midY,s,m),n=f(t);if(n)return{laneId:n,anchor:e,rect:t};let r=a.find(({rect:t})=>T(e,t));if(!r)return;let i=r.rect.left+s/2+1,o=r.rect.right-s/2-1,c=r.rect.top+m/2+1,l=r.rect.bottom-m/2-1;if(i>o||c>l)return;let u={midX:w(e.midX,i,o),midY:w(e.midY,c,l)},d=me(u.midX,u.midY,s,m);return T(e,d)?{laneId:r.id,anchor:u,rect:d}:void 0},`placementForAnchor`),D=r((e,t,n)=>e.orientation===`horizontal`?Math.abs(t.midX-n.x):Math.abs(t.midY-n.y),`distanceAlongSegment`),O=r((e,t)=>{let n=(e.orientation===`horizontal`?s/2:m/2)+12;if(e===b){let r=o[e.idx];if(D(e,t,r)+Ut<n)return!1}if(e===x){let r=o[e.idx+1];if(D(e,t,r)+Ut<n)return!1}return!0},`labelClearsTerminalEndpoints`),k=r(t=>{let r=y(t);for(let t of r)for(let r of S){let i=C(t,r);if(!O(t,i))continue;let a=E(i);if(a&&!Jt(a.rect,o)&&!p(e,a.rect)&&!u(e,n.id,a.rect))return{laneId:a.laneId,anchor:a.anchor}}},`tryPool`),ee=r((t,r,i=!1)=>{let a=y(t);for(let t of a){let a={midX:t.midX,midY:t.midY};if(r&&!O(t,a))continue;let s=E(a);if(s&&!Jt(s.rect,o)&&!p(e,s.rect)&&!c(e,s.rect)&&(i||!l(n.id,s.rect)))return{laneId:s.laneId,anchor:s.anchor}}},`findLaneContainingFallback`),A=k(_)??(_.length<h.length?k(h):void 0)??ee(h,!0)??ee(h,!1)??ee(h,!1,!0);if(A){i.x=A.anchor.midX,i.y=A.anchor.midY,i.parentId=A.laneId;let t=me(A.anchor.midX,A.anchor.midY,s,m),n=d.findIndex(t=>t.labelId===e);n>=0?d[n]={labelId:e,rect:t}:d.push({labelId:e,rect:t})}}}r(Yt,`anchorLabelsToPolyline`);var Xt=1e-6,Zt=4,Qt=3;function $t(e,t,n,{cx:r,cy:i},a,o){let s={x:r,y:i},c=o===`x`?`y`:`x`,l=Math.sign(a[c]-s[c]);for(let r of e)if(r!==t&&!r.isLayoutOnly&&r.points?.length&&[...r.end===n?[r.points.at(-1)]:[],...r.start===n?[r.points[0]]:[]].some(e=>Math.sign(e[c]-s[c])===l&&Math.abs(e[o]-a[o])<Tt.MIN_ARROWHEAD_SPACING))return!0;return!1}r($t,`crowdsFaceNeighbour`);function en(e,t){return e<t?`${e}::${t}`:`${t}::${e}`}r(en,`pairKey`);function tn(e,t){let{nodeInfoById:n,realNodeRects:i}=ve(t),a=new Map;for(let e of t){let t=e.id;e.isGroup||e.isEdgeLabel&&a.set(t,{w:e.width??0,h:e.height??0})}let o=r((t,n,i,o)=>{let s=en(n,i),c=0,l=r(e=>{if(!e)return;let t=a.get(e);if(!t)return;let n=o===`x`?t.w/2:t.h/2;n>c&&(c=n)},`consider`);l(t.labelNodeId);for(let n of e){if(n===t||n.isLayoutOnly)continue;let e=n.start,r=n.end;e&&r&&en(e,r)===s&&l(n.labelNodeId)}return c>0?c+Qt:0},`labelClearanceFor`);for(let t of e){if(t.isLayoutOnly)continue;let r=t.points;if(!le(r,Xt))continue;let a=xe(t,n,Xt);if(!a)continue;let{srcId:s,dstId:c,srcInfo:l,dstInfo:u,collinearX:d,collinearY:f}=a;if(d===f)continue;let p,m;if(d){let e=u.cy>l.cy;p={x:l.cx,y:e?l.rect.bottom:l.rect.top},m={x:u.cx,y:e?u.rect.top:u.rect.bottom}}else{let e=u.cx>l.cx;p={x:e?l.rect.right:l.rect.left,y:l.cy},m={x:e?u.rect.left:u.rect.right,y:u.cy}}if(J(p,m,i,[s,c],1))continue;let h=d?`x`:`y`,g=o(t,s,c,h),_=g>Zt?g:Zt,v=[0,_,-_],y;for(let n of v){let r={...p},a={...m};if(d){if(r.x+=n,a.x+=n,r.x<=l.rect.left||r.x>=l.rect.right||a.x<=u.rect.left||a.x>=u.rect.right)continue}else if(r.y+=n,a.y+=n,r.y<=l.rect.top||r.y>=l.rect.bottom||a.y<=u.rect.top||a.y>=u.rect.bottom)continue;if(J(r,a,i,[s,c],1)||we(r,a,e,t,{epsilon:Xt}))continue;let o=[r,a];if($t(e,t,s,l,r,h)||$t(e,t,c,u,a,h))y??=o;else{t.points=o,y=void 0;break}}y&&(t.points=y)}}r(tn,`straightenCollinearSiblingDetours`);function nn(e,t){let n=.001,{realNodeRects:i,labelNodeRects:a}=ye(t.values()),o=r((e,t)=>U(t,n).map(n=>({...n,edge:e,interior:n.index>=1&&n.index<=t.length-3})),`segmentsFor`),s=r(()=>{let t=[];for(let n of e){if(n.isLayoutOnly)continue;let e=n.points;!e||e.length<2||t.push(...o(n,G(e)))}return t},`allSegments`),c=r((e,t)=>e.horizontal&&t.horizontal?V(e.a.x,e.b.x,t.a.x,t.b.x)>=8&&Math.abs(e.a.y-t.a.y)<7:e.vertical&&t.vertical?V(e.a.y,e.b.y,t.a.y,t.b.y)>=8&&Math.abs(e.a.x-t.a.x)<7:!1,`hasCrowdedParallelTrack`),l=r((t,r)=>{let s=t.start,l=t.end,u=o(t,r);if(u.length!==r.length-1)return!1;let d=[s,l].filter(e=>!!e),f=t.labelNodeId?[t.labelNodeId]:[];for(let e of u)if(J(e.a,e.b,i,d,-2)||J(e.a,e.b,a,f,-2))return!1;for(let r of e){if(r===t||r.isLayoutOnly)continue;let e=r.points;if(!(!e||e.length<2)){for(let t of u)for(let i of o(r,G(e)))if(c(t,i)||Te(t.a,t.b,i.a,i.b,n))return!1}}return!0},`candidateIsSafe`),u=r((e,t)=>{let n=G(e.edge.points??[]);if(n.length<4||e.index>=n.length-1)return;let r=n.map(e=>({...e}));if(e.horizontal)r[e.index].y+=t,r[e.index+1].y+=t;else if(e.vertical)r[e.index].x+=t,r[e.index+1].x+=t;else return;return o(e.edge,r).length===r.length-1?r:void 0},`shiftedCandidate`),d=r((e,t)=>({x:e.x??(t.left+t.right)/2,y:e.y??(t.top+t.bottom)/2}),`nodeCenter`),f=r(e=>{let n=e.edge,r=G(n.points??[]);if(r.length!==4||e.index!==1)return;let i=n.start?t.get(n.start):void 0,a=n.end?t.get(n.end):void 0,o=i?q(i):void 0,s=a?q(a):void 0,c=r.slice(e.index+2);if(i&&a&&o&&s&&c.length!==0)return{sourceCenter:d(i,o),targetCenter:d(a,s),sourceRect:o,tail:c}},`sourceDetourContextFor`),p=r((e,t,r,i,a,o)=>{let s=i.y>=r.y,c=s?a.bottom:a.top,l=c+(s?20:-20);if(s&&e.b.y<=l+n||!s&&e.b.y>=l-n)return;let u=e.a.x+t;return G([{x:r.x,y:c},{x:r.x,y:l},{x:u,y:l},{x:u,y:e.b.y},...o],n)},`verticalSourceDetour`),m=r((e,t,r,i,a,o)=>{let s=i.x>=r.x,c=s?a.right:a.left,l=c+(s?20:-20);if(s&&e.b.x<=l+n||!s&&e.b.x>=l-n)return;let u=e.a.y+t;return G([{x:c,y:r.y},{x:l,y:r.y},{x:l,y:u},{x:e.b.x,y:u},...o],n)},`horizontalSourceDetour`),h=r((e,t)=>{let n=f(e);if(n){if(e.vertical)return p(e,t,n.sourceCenter,n.targetCenter,n.sourceRect,n.tail);if(e.horizontal)return m(e,t,n.sourceCenter,n.targetCenter,n.sourceRect,n.tail)}},`sourceDetourCandidate`),g=[-7,7,-14,14,-21,21];for(let e=0;e<12;e++){let e=s(),t=!1;for(let n=0;n<e.length&&!t;n++)for(let r=n+1;r<e.length&&!t;r++){let i=e[n],a=e[r];if(i.edge===a.edge||!c(i,a))continue;let o=[i,a].filter(e=>e.interior);for(let e of o){for(let n of g){let r=u(e,n);if(r&&l(e.edge,r)){e.edge.points=r,t=!0;break}let i=h(e,n);if(i&&l(e.edge,i)){e.edge.points=i,t=!0;break}}if(t)break}}if(!t)return}}r(nn,`nudgeSharedInteriorSubpaths`);function rn(e,t,n,r){let i=t.x-e.x,a=t.y-e.y,o=r.x-n.x,s=r.y-n.y,c=i*s-a*o;if(Math.abs(c)<1e-10)return!1;let l=n.x-e.x,u=n.y-e.y,d=(l*s-u*o)/c,f=(l*a-u*i)/c,p=.01;return d>p&&d<.99&&f>p&&f<.99}r(rn,`segmentsIntersect`);function an(e){let t=e.nodes??[],r=e.edges??[],i=[];if(!r.length||!t.length)return i;let a=be(t),o=[];for(let e of r){if(e.isLayoutOnly)continue;let t=e.points;if(!t||t.length<2)continue;let n=e.start,r=e.end,s=e.labelNodeId,c=e.id??`${n}->${r}`;for(let e of a)if(e.nodeId!==n&&e.nodeId!==r&&!(s&&e.nodeId===s)){for(let n=0;n<t.length-1;n++)if(ue(t[n],t[n+1],e,-1)){i.push({type:`edge-node-overlap`,edgeId:c,targetId:e.nodeId,detail:`segment ${n} passes through node "${e.nodeId}"`});break}}for(let e=0;e<t.length-1;e++)o.push({edgeId:c,start:n,end:r,p1:t[e],p2:t[e+1]})}let s=new Set;for(let e=0;e<o.length;e++)for(let t=e+1;t<o.length;t++){let n=o[e],r=o[t];if(n.edgeId!==r.edgeId&&n.start!==r.start&&n.start!==r.end&&n.end!==r.start&&n.end!==r.end&&rn(n.p1,n.p2,r.p1,r.p2)){let e=n.edgeId<r.edgeId?`${n.edgeId}|${r.edgeId}`:`${r.edgeId}|${n.edgeId}`;s.has(e)||(s.add(e),i.push({type:`edge-edge-crossing`,edgeId:n.edgeId,targetId:r.edgeId,detail:`edges "${n.edgeId}" and "${r.edgeId}" cross`}))}}if(i.length>0){let e=i.filter(e=>e.type===`edge-node-overlap`).length,t=i.filter(e=>e.type===`edge-edge-crossing`).length;n.warn(`[SWIMLANE_VALIDATE] ${i.length} issue(s) detected: ${e} edge-node overlap(s), ${t} edge crossing(s)`);for(let e of i)n.warn(`[SWIMLANE_VALIDATE] ${e.type}: ${e.detail}`)}return i}r(an,`validateSwimlanesLayout`);function on(e,t){let n=e.nodes??[],i=e.edges??[],a=n.filter(e=>!e.isGroup);if((t===`LR`||t===`RL`)&&a.length>0&&!_t(e,t)||t===`BT`&&a.length>0&&!ct(e))return;for(let e of i){if(e.isLayoutOnly)continue;let t=e.points;!t||t.length<2||(e.points=Ae(ke(t)))}Ht(i,n),tn(i,n),xt(i,n);let o=new Map;for(let e of n)o.set(String(e.id),e);Yt(i,o),Ie(i,o),St(i,o),nn(i,o),jt(i,o),Mt(i,o),Nt(i,o),It(i,o);let s=r(()=>{zt(i,o),jt(i,o),Lt(i,o),Rt(i,o),Yt(i,o),tt(i,o),Nt(i,o),Yt(i,o),tt(i,o)},`finalizeRenderedEdges`);s(),nn(i,o),s(),Pt(i,o,t),Ft(i,o,t),Pt(i,o,t),Ft(i,o,t)}r(on,`postProcessSwimlaneLayout`);function sn(e){let t=new Map(e.nodeById),n=new Set,r=[];for(let i of e.edges){if(!t.has(i.src)||!t.has(i.dst))continue;let e=`${i.id}:${i.src}->${i.dst}`;n.has(e)||(n.add(e),r.push(i))}return{nodes:[...t.keys()],edges:r,layout:e.layout,nodeById:t}}r(sn,`normalizeGraph`);function cn(e,t){return e.edges.filter(e=>e.dst===t)}r(cn,`incoming`);function ln(e){let t=new Map;for(let n of e.nodes)t.set(n,[]);for(let n of e.edges)t.get(n.src).push(n.dst);return t}r(ln,`buildSuccessorMap`);function un(e){let t=ln(e);for(let e of t.values())e.sort((e,t)=>e.localeCompare(t));return t}r(un,`buildSortedSuccessorMap`);function dn(e){let t=new Map;for(let n of e.nodes)t.set(n,0);for(let n of e.edges)t.set(n.dst,(t.get(n.dst)??0)+1);return t}r(dn,`buildInDegreeMap`);function fn(e,t){let n=[...t.entries()].filter(([,e])=>e===0).map(([e])=>e).sort((e,t)=>e.localeCompare(t)),i=new Set(e.edges.flatMap(e=>[e.src,e.dst])),a=r(t=>!i.has(t)&&!e.nodeById.get(t)?.isGroup,`isUnconnected`),o=[...t.keys()].filter(e=>t.get(e)===0&&a(e)),s=0;return n.map(e=>a(e)?o[s++]:e)}r(fn,`sortedZeroInDegreeNodes`);function pn(e,t=()=>!0){let n=new Map,r=new Map;for(let t of e.nodes)n.set(t,[]),r.set(t,[]);for(let i of e.edges)t(i)&&(r.get(i.src).push(i.dst),n.get(i.dst).push(i.src));return{preds:n,succs:r}}r(pn,`buildPredecessorSuccessorMaps`);function mn(e,t,n,r){let i=0;for(let t of e.nodes)r?.skipGroups&&e.nodeById.get(t)?.isGroup||(i=Math.max(i,n[t]??0));let a=Array.from({length:i+1},()=>[]);for(let i of t)r?.skipGroups&&e.nodeById.get(i)?.isGroup||a[Math.max(0,n[i]??0)].push(i);return a}r(mn,`buildLayersFromRanks`);function hn(e){let t=dn(e),n=fn(e,t),r=[],i=un(e);for(;n.length;){let e=n.shift();r.push(e);for(let r of i.get(e)??[])if(t.set(r,(t.get(r)??0)-1),(t.get(r)??0)===0){let e=0;for(;e<n.length&&n[e]<r;)e++;n.splice(e,0,r)}}return r.length===e.nodes.length?r:null}r(hn,`topoSortIfAcyclic`);function gn(e){let t=new Map,n=0;for(let r of e)t.set(r,n),n++;return t}r(gn,`buildLayerIndex`);function _n(e){let t=Array(e.length),n=r((r,i)=>{if(i-r<=1)return 0;let a=r+i>>1,o=n(r,a)+n(a,i),s=r,c=a,l=r;for(;s<a||c<i;)c>=i||s<a&&e[s]<=e[c]?t[l++]=e[s++]:(t[l++]=e[c++],o+=a-s);for(let n=r;n<i;n++)e[n]=t[n];return o},`count`);return n(0,e.length)}r(_n,`countInversions`);function vn(e){let t=sn(e),n=new Map;for(let e of t.nodes)n.set(e,[]);for(let e of t.edges)n.get(e.src).push(e);for(let e of n.values())e.sort((e,t)=>e.dst===t.dst?e.id.localeCompare(t.id):e.dst.localeCompare(t.dst));let i=Object.create(null);for(let e of t.nodes)i[e]=0;let a=[],o=r(e=>{i[e]=1;for(let t of n.get(e)??[]){let e=t.dst;i[e]===0?o(e):i[e]===1&&a.push(t)}i[e]=2},`dfs`),s=dn(t),c=[...t.nodes.filter(e=>(s.get(e)??0)===0),...t.nodes.filter(e=>(s.get(e)??0)!==0)];for(let e of c)i[e]===0&&o(e);let l=new Set(a.map(e=>`${e.id}:${e.src}->${e.dst}`)),u=t.edges.map(e=>l.has(`${e.id}:${e.src}->${e.dst}`)?{id:e.id,src:e.dst,dst:e.src,weight:e.weight,ref:e.ref}:e);return{acyclic:{nodes:[...t.nodes],edges:u,layout:t.layout,nodeById:new Map(t.nodeById)},reversed:a}}r(vn,`removeCycles_DFS`);function yn(e){let t=s(e.layout.nodes??[]),n=new Map;for(let r of e.nodes)n.set(r,t.laneIdOf(r));return n}r(yn,`buildTopLaneMap`);function bn(e){let t=yn(e);return e=>t.get(e)??null}r(bn,`createTopLaneResolver`);function xn(e){let t=e.layout.nodes??[],n=s(t),r=t.filter(e=>n.isLane(e.id)),i=r.filter(e=>o(e)!==void 0);if(i.length>0&&i.length===r.length)return[...i].sort((e,t)=>(o(e)??0)-(o(t)??0)).map(e=>e.id);if(!n.hasPools)return[...new Set(r.map(e=>e.id))].reverse();let a=[];for(let e of t)e.parentId||(n.isPool(e.id)?a.push(...n.lanesByPool.get(e.id)??[]):n.isLane(e.id)&&a.push(e.id));return[...new Set(a)].reverse()}r(xn,`buildTopLaneOrder`);function Sn(e,t){let n=xn(e);if(!t||t.length===0)return n;let r=new Set(n),i=new Set,a=[];for(let e of t)r.has(e)&&!i.has(e)&&(i.add(e),a.push(e));for(let e of n)i.has(e)||a.push(e);return a}r(Sn,`resolveTopLaneOrder`);function Cn(e,t){let n=sn(e),i=t?.laneOf??(()=>null),a=t?.rankHint,{preds:o}=pn(n);for(let e of o.values())e.sort((e,t)=>e.localeCompare(t));let s=hn(n)??[...n.nodes].sort((e,t)=>e.localeCompare(t)),c=new Map;for(let[e,t]of s.entries())c.set(t,e);let l=new Map,u=new Map;for(let e of n.nodes)u.set(e,[]);for(let e of s){let t=(o.get(e)??[]).filter(e=>l.has(e));if(t.length>0){let n=wn(e,t,{laneOf:i,rankHint:a,topoIndex:c});l.set(e,n),u.get(n).push(e)}else l.has(e)||l.set(e,null)}for(let e of n.nodes)l.has(e)||l.set(e,null);let d=new Set;for(let e of n.nodes)(l.get(e)??null)===null&&d.add(e);let f=[...d].sort((e,t)=>{let n=c.get(e)??0,r=c.get(t)??0;return n===r?e.localeCompare(t):n-r}),p=Tn(n),m=new Map;for(let[e,t]of p.entries())m.set(e,[...t].sort((e,t)=>e.localeCompare(t)));let h=En(m),g=Dn(m),_=new Map;for(let e of n.nodes)_.set(e,[]);for(let e of g)for(let t of e.nodes){let n=_.get(t);n?n.push(e.id):_.set(t,[e.id])}let v=[],y=[],b=new Set,x=r(e=>{if(!b.has(e)){b.add(e),v.push(e);for(let t of u.get(e)??[])x(t);y.push(e)}},`walk`);for(let e of f)x(e);for(let e of s)x(e);return{parent:l,children:u,roots:f,componentOf:h,blocks:g,nodeBlocks:_,adjacency:m,preorder:v,postorder:y,topologicalOrder:s}}r(Cn,`buildDrivingTree`);function wn(e,t,n){let r=n.laneOf(e);return[...t].sort((e,t)=>{let i=n.laneOf(e),a=n.laneOf(t),o=i!=null&&i===r;if(o!==(a!=null&&a===r))return o?-1:1;let s=n.rankHint?.[e],c=n.rankHint?.[t];if(s!=null&&c!=null&&s!==c)return c-s;let l=n.topoIndex.get(e)??0,u=n.topoIndex.get(t)??0;return l===u?e.localeCompare(t):l-u})[0]}r(wn,`chooseParent`);function Tn(e){let t=new Map;for(let n of e.nodes)t.set(n,new Set);for(let n of e.edges)t.get(n.src).add(n.dst),t.get(n.dst).add(n.src);return t}r(Tn,`buildAdjacency`);function En(e){let t=new Map,n=0;for(let r of e.keys()){if(t.has(r))continue;let i=[r];for(;i.length>0;){let r=i.pop();if(!t.has(r)){t.set(r,n);for(let n of e.get(r)??[])t.has(n)||i.push(n)}}n++}return t}r(En,`assignComponents`);function Dn(e){let t=new Map,n=new Map,i=[],a=[],o=0,s=r((r,c)=>{t.set(r,++o),n.set(r,o);for(let l of e.get(r)??[])l!==c&&(t.has(l)?(t.get(l)??0)<(t.get(r)??0)&&(i.push([r,l]),n.set(r,Math.min(n.get(r)??o,t.get(l)??o))):(i.push([r,l]),s(l,r),n.set(r,Math.min(n.get(r)??o,n.get(l)??o)),(n.get(l)??0)>=(t.get(r)??0)&&a.push(On(r,l,i,a.length))))},`visit`);for(let n of e.keys())t.has(n)||s(n,null);return a}r(Dn,`computeBlocks`);function On(e,t,n,r){let i=[],a=new Set;for(;n.length>0;){let r=n.pop();if(i.push(r),a.add(r[0]),a.add(r[1]),r[0]===e&&r[1]===t||r[0]===t&&r[1]===e)break}return{id:r,edges:i,nodes:[...a]}}r(On,`popBlock`);function kn(e,t,n){let i=[...e.nodes],a=new Map;for(let[e,t]of i.entries())a.set(t,e);let o=i.length,s=Array(o).fill(-1),c=Array(o).fill(0),l=[],u=new Set;for(let e of i){let t=n.parent.get(e)??null,r=a.get(e);r!=null&&(t??(s[r]=-1,c[r]=0,u.has(e)||(u.add(e),l.push(e))))}for(;l.length>0;){let e=l.shift(),t=a.get(e);if(t==null)continue;let r=n.children.get(e)??[];for(let e of r){if(u.has(e))continue;let n=a.get(e);n!=null&&(s[n]=t,c[n]=c[t]+1,u.add(e),l.push(e))}}for(let e of i){if(u.has(e))continue;let t=a.get(e);t!=null&&(s[t]=-1,c[t]=0,u.add(e))}let d=Math.max(1,Math.ceil(Math.log2(Math.max(1,o)))+1),f=Array.from({length:d},()=>Array(o).fill(-1));for(let e=0;e<o;e++)f[0][e]=s[e];for(let e=1;e<d;e++)for(let t=0;t<o;t++){let n=f[e-1][t];f[e][t]=n===-1?-1:f[e-1][n]}let p=r((e,t)=>{if(e===-1||t===-1)return-1;c[e]<c[t]&&([e,t]=[t,e]);let n=c[e]-c[t];for(let t=0;t<d;t++)if(n>>t&1&&(e=f[t][e],e===-1))return-1;if(e===t)return e;for(let n=d-1;n>=0;n--){let r=f[n][e],i=f[n][t];r!==-1&&i!==-1&&r!==i&&(e=r,t=i)}return f[0][e]},`lcaIndex`),m=Array.from({length:o},()=>new Map);for(let n of e.edges){let e=n.src,r=n.dst,i=t[e],o=t[r];if(i==null||o==null||(i>o&&([e,r]=[r,e],[i,o]=[o,i]),i==null||o==null||i===o))continue;let s=a.get(e),c=a.get(r);if(s==null||c==null)continue;let l=p(s,c);if(l===-1)continue;let u=m[l];for(let e=i;e<o;e++)u.set(e,(u.get(e)??0)+1)}let h=new Map,g=r((e,t)=>{if(t.size!==0)for(let[n,r]of t)e.set(n,(e.get(n)??0)+r)},`mergeInto`),_=new Set,v=r(e=>{let r=a.get(e);_.add(e);let i=r==null?void 0:m[r],o=i?new Map(i):new Map,s=n.children.get(e)??[];for(let n of s){let r=v(n),i=t[e];if(i!=null){let a=h.get(e);a||(a=new Map,h.set(e,a));let o=r.get(i)??0,s=t[n];s!=null&&s>i&&(o+=1),a.set(n,o)}g(o,r)}return o},`dfs`);for(let e of n.roots)_.has(e)||v(e);for(let e of i)_.has(e)||v(e);return h}r(kn,`computeSubtreeCrossCounts`);function An(e,t,n){let i=new Map,a=r(e=>{let r=n[e]??0,o=[...t.get(e)??[]];o.sort(jn(n));for(let e of o){a(e);let t=i.get(e);t!=null&&(r=Math.min(r,t))}i.set(e,r)},`annotate`);for(let t of e)a(t);return i}r(An,`annotateMinimumLayers`);function jn(e){return(t,n)=>{let r=e[t]??0,i=e[n]??0;return r===i?t.localeCompare(n):r-i}}r(jn,`compareByRankThenId`);function Mn(e,t,n,i){let a=0;for(let e of t){let t=n[e]??0;t>a&&(a=t)}let o=Array.from({length:a+1},()=>[]),s=new Set,c=r(e=>{if(s.has(e))return;s.add(e);let t=n[e]??0;o[t]||(o[t]=[]),o[t].push(e);for(let t of i(e))c(t)},`emit`);for(let t of e)c(t);for(let e of t)if(!s.has(e)){let t=n[e]??0;o[t]||(o[t]=[]),o[t].push(e),s.add(e)}return o}r(Mn,`emitNodesInTreeOrder`);function Nn(e){let t=[];for(let n of e){let e=new Set,r=[];for(let t of n)e.has(t)||(e.add(t),r.push(t));t.push(r)}return t}r(Nn,`deduplicateLayers`);function Pn(e,t,n,r){return i=>{let a=e.get(i)??[];if(a.length===0)return[];let o=t[i]??0,s=[],c=[],l=n.get(i);for(let e of a){let t=r.get(e)??o;t>o?s.push({child:e,min:t}):c.push(e)}return s.sort((e,t)=>e.min===t.min?e.child.localeCompare(t.child):e.min-t.min),c.sort((e,t)=>{let n=l?.get(e)??0,i=l?.get(t)??0;if(n!==i)return n-i;let a=r.get(e)??o,s=r.get(t)??o;return a===s?e.localeCompare(t):a-s}),[...s.map(e=>e.child),...c]}}r(Pn,`createChildOrderer`);function Fn(e,t,n){let r=Cn(e,{rankHint:t,laneOf:n}),{children:i,roots:a}=r;for(let t of e.nodes)i.has(t)||i.set(t,[]);let o=kn(e,t,r),s=[...a].sort(jn(t)),c=Pn(i,t,o,An(s,i,t)),l=Mn(s,e.nodes,t,c);return l=Nn(l),l}r(Fn,`buildMultitreeLayerOrder`);function In(e,t,n){let r=new Set(e),i=new Set(t),a=gn(t),o=[];for(let e of n)r.has(e.src)&&i.has(e.dst)&&o.push(a.get(e.dst));return _n(o)}r(In,`countCrossingsBetweenAdjacent`);function Ln(e,t,n){let r=[];for(let e of t){let t=n[e.src],i=n[e.dst];if(t==null||i==null||t===i)continue;let a=e.src,o=e.dst,s=t,c=i;t>i&&(a=e.dst,o=e.src,s=i,c=t);for(let t=s;t<c;t++)r.push({id:`${e.id}@${t}`,src:a,dst:o,ref:e.ref})}let i=0;for(let t=0;t+1<e.length;t++)i+=In(e[t],e[t+1],r);return i}r(Ln,`totalCrossings`);function Rn(e,t){let n={...t},{preds:r}=pn(e),i=bn(e),a=Ln(Fn(e,n,i),e.edges,n),o=Dt.MAX_CROSSING_OPTIMIZATION_PASSES;for(let t=0;t<o;t++){let t=!1,o=[...e.nodes].sort((e,t)=>(n[t]??0)-(n[e]??0));for(let s of o){let o=n[s]??0;if(o===0)continue;let c=0;for(let e of r.get(s)??[])c=Math.max(c,(n[e]??0)+1);if(c>=o)continue;let l=o;n[s]=c;let u=Ln(Fn(e,n,i),e.edges,n);u<a?(a=u,t=!0):n[s]=l}if(!t)break}return n}r(Rn,`optimizeRanksByCrossings`);function zn(e,t){let n=bn(e),r=[...e.nodes].sort((e,n)=>(t[e]??0)-(t[n]??0)||e.localeCompare(n));for(let i of r){let r=n(i);if(!r)continue;let a=e.edges.filter(e=>e.src===i);if(a.length===0)continue;let o=!1,s=0;for(let e of a){let t=n(e.dst);t==null||t===r?o=!0:s++}if(s===0||o)continue;let c=0,l=!1;for(let t of e.edges){if(t.dst!==i)continue;let e=n(t.src);e&&(e===r?l=!0:c++)}if(c>0||!l)continue;let u=t[i]??0,d=u+s,f=0;for(let n of e.edges)n.dst===i&&(f=Math.max(f,(t[n.src]??0)+1));let p=Math.max(u,f,d);p!==u&&(t[i]=p)}}r(zn,`adjustCrossLaneSources`);function Bn(e,t){let n=sn(e),r=hn(n)??[...n.nodes].sort(),i=t?.compactSingleInput??!1,a=bn(n),o=Object.create(null);for(let e of r){let r=cn(n,e),s=t?.ignoreCrossLaneEdges?r.filter(t=>{let n=a(t.src),r=a(e);return!n||!r||n===r}):r;if(s.length===0)o[e]=0;else if(i&&s.length===1){let t=s[0].src;a(t)===a(e)?o[e]=(o[t]??0)+1:o[e]=o[t]??0}else{let t=-1/0;for(let e of s)t=Math.max(t,(o[e.src]??0)+1);o[e]=t===-1/0?0:t}}return(t?.optimizeRanksByCrossings??!1)&&(o=Rn(n,o)),t?.ignoreCrossLaneEdges&&zn(n,o),{layers:Fn(n,o,a),rankOf:o,dummy:new Set}}r(Bn,`assignLayers_LongestPath`);function Vn(e,t){let n=sn(e),i={...Bn(n,{compactSingleInput:t?.compactSingleInput,ignoreCrossLaneEdges:t?.ignoreCrossLaneEdges,optimizeRanksByCrossings:t?.optimizeRanksByCrossings}).rankOf},a=bn(n),{preds:o,succs:s}=pn(n,e=>{if(t?.ignoreCrossLaneEdges){let t=a(e.src),n=a(e.dst);if(t&&n&&t!==n)return!1}return!0}),c=hn(n)??[...n.nodes],l=[...c].reverse(),u=r((e,t)=>{let n=0;for(let t of o.get(e)??[])n=Math.max(n,(i[t]??0)+1);let r=1/0,a=s.get(e)??[];return a.length>0&&(r=Math.min(...a.map(e=>(i[e]??0)-1))),Number.isFinite(r)||(r=Math.max(n,t)),Math.min(Math.max(t,n),r)},`clampFeasible`),d=Dt.GRAVITY_ITERATIONS,f=r(e=>{let t=!1;for(let n of e){let e=o.get(n)??[],r=s.get(n)??[];if(e.length===0&&r.length===0)continue;let a=e.length>0?e.reduce((e,t)=>e+(i[t]??0)+1,0)/e.length:i[n]??0,c=r.length>0?r.reduce((e,t)=>e+(i[t]??0)-1,0)/r.length:i[n]??0,l=Math.round((a+c)/2),d=u(n,l);d!==i[n]&&(i[n]=d,t=!0)}return t},`relaxOrder`);for(let e=0;e<d;e++){let e=f(c),t=f(l);if(!e&&!t)break}for(let e of c){let t=0;for(let n of o.get(e)??[])t=Math.max(t,(i[n]??0)+1);(i[e]??0)<t&&(i[e]=t)}for(let e of l){let t=s.get(e)??[];if(t.length>0){let n=Math.min(...t.map(e=>(i[e]??0)-1));(i[e]??0)>n&&(i[e]=n)}}return{layers:mn(n,c,i),rankOf:i,dummy:new Set}}r(Vn,`assignLayers_Gravity`);function Hn(e){let t=dn(e),n=un(e),r=fn(e,t),i=[];for(;r.length>0;){let e=[];for(let a of r){i.push(a);for(let r of n.get(a)??[])t.set(r,(t.get(r)??0)-1),(t.get(r)??0)===0&&e.push(r)}r=e.sort((e,t)=>e.localeCompare(t))}return i.length===e.nodes.length?i:null}r(Hn,`topoSortByGenerationIfAcyclic`);function Un(e,t){let n=sn(e),i=t?.direction===`LR`?Hn(n)??[...n.nodes].sort():hn(n)??[...n.nodes].sort(),a=bn(n),o=r(e=>a(e)??e,`laneOf`),s=Object.create(null),c=new Map,l=r((e,n)=>t?.ignoreCrossLaneEdges??!0?+(o(e)===o(n)):1,`edgeWeight`);for(let e of i){if(n.nodeById.get(e)?.isGroup)continue;let t=cn(n,e),r=0;if(t.length>0)for(let n of t){let t=n.src,i=s[t]??0;r=Math.max(r,i+l(t,e))}let i=o(e),a=c.get(i)??0,u=Math.max(r,a);s[e]=u,c.set(i,u+1)}return{layers:mn(n,i,s,{skipGroups:!0}),rankOf:s,dummy:new Set}}r(Un,`assignLayers_LaneAwareCompact`);function Wn(e,t){let n=sn(t),{rankOf:i}=e,a=e.layers.map(e=>[...e]),o=new Set(e.dummy?[...e.dummy]:[]),s=0,c=new Map(n.nodeById),l=r(e=>{let t=`placeholder-${s++}`,n={id:t,isGroup:!1,isDummy:!0,width:0,height:0};for(c.set(t,n),o.add(t);a.length<=e;)a.push([]);return a[e].push(t),i[t]=e,t},`addDummyAt`),u=[...n.edges].sort((e,t)=>e.id===t.id?e.src===t.src?e.dst.localeCompare(t.dst):e.src.localeCompare(t.src):e.id.localeCompare(t.id)),d=[];for(let e of u){let t=i[e.src]??0,n=i[e.dst]??0;if(n-t<=1){d.push(e);continue}let r=e.src;for(let i=t+1,a=0;i<n;i++,a++){let t=l(i);d.push({id:`${e.id}#${a}`,src:r,dst:t,weight:e.weight,ref:e.ref}),r=t}let a=n-t-2;d.push({id:`${e.id}#${Math.max(a+1,0)}`,src:r,dst:e.dst,weight:e.weight,ref:e.ref})}let f={nodes:[...n.nodes,...[...o].filter(e=>!n.nodes.includes(e))],edges:d,layout:n.layout,nodeById:c};return{layering:{layers:a,rankOf:i,dummy:o},graphWithDummies:f}}r(Wn,`makeProperLayering`);function Gn(e){let t=e.length;if(t===0)return 1/0;let n=[...e].sort((e,t)=>e-t);return t%2==1?n[(t-1)/2]:.5*(n[t/2-1]+n[t/2])}r(Gn,`median`);function Kn(e){return e.length===0?1/0:e.reduce((e,t)=>e+t,0)/e.length}r(Kn,`barycenter`);function qn(e,t,n,r){let i=new Map;for(let t of e)i.set(t,[]);for(let e of n)r===`down`?t.has(e.src)&&i.has(e.dst)&&i.get(e.dst).push(t.get(e.src)):t.has(e.dst)&&i.has(e.src)&&i.get(e.src).push(t.get(e.dst));return i}r(qn,`neighborPositionsFor`);function Jn(e,t,n){let r=n.get(e)??0,i=n.get(t)??0;return r===i?e.localeCompare(t):r-i}r(Jn,`currentOrderTieBreak`);function Yn(e,t,n){let r=new Set(e),i=new Set(t),a=gn(e),o=gn(t),s=[];for(let e of n)r.has(e.src)&&i.has(e.dst)&&s.push({u:a.get(e.src),v:o.get(e.dst)});return s.sort((e,t)=>e.u===t.u?e.v-t.v:e.u-t.u),_n(s.map(e=>e.v))}r(Yn,`countCrossingsBetweenAdjacent`);function Xn(e,t,n){return[...e].sort((e,r)=>{let i=Gn(t.get(e)??[]),a=Gn(t.get(r)??[]);return i===a?Jn(e,r,n):isFinite(i)?isFinite(a)?i-a:-1:1})}r(Xn,`sortByHeuristic`);function Zn(e,t,n,r,i,a){let o=gn(e),s=gn(t),c=qn(t,o,n,r);if(!i||!a||a.length===0)return Xn(t,c,s);let l=new Map;for(let e of t){let t=i(e),n=l.get(t)??[];n.push(e),l.set(t,n)}let u=[];for(let e of a){let t=l.get(e);if(!t||t.length===0)continue;let n=Xn(t,c,s);u.push(...n)}let d=l.get(null);if(d&&d.length>0){let e=Xn(d,c,s);for(let t of e){let e=Kn(c.get(t)??[]),n=u.length;if(isFinite(e)){for(let[t,r]of u.entries())if(e<Kn(c.get(r)??[])){n=t;break}}u.splice(n,0,t)}}return u}r(Zn,`reorderLayer`);function Qn(e,t,n,i,a){let o=[...t],s=new Set(e),c=new Set(t),l=i?new Set(i):null,u=n.filter(e=>s.has(e.src)&&c.has(e.dst)),d=l?n.filter(e=>c.has(e.src)&&l.has(e.dst)):void 0,f=r(t=>{let n=Yn(e,t,u);return d&&i&&(n+=Yn(t,i,d)),n},`crossingScore`),p=a?new Map:null;if(a&&p)for(let e of t)p.set(e,a(e));let m=!0,h=f(o);for(;m;){m=!1;for(let e=0;e+1<o.length;e++){if(p&&p.get(o[e])!==p.get(o[e+1]))continue;let t=h;[o[e],o[e+1]]=[o[e+1],o[e]];let n=f(o);n<t?(h=n,m=!0):[o[e],o[e+1]]=[o[e+1],o[e]]}}return o}r(Qn,`transposeImprove`);function $n(e,t,n){let r=e.layers.map(e=>[...e]),i=t.edges,a=bn(t),o=Sn(t,n?.laneOrder);for(let e=0;e<3;e++){for(let e=1;e<r.length;e++)r[e]=Zn(r[e-1],r[e],i,`down`,a,o),r[e]=Qn(r[e-1],r[e],i,r[e+1],a);for(let e=r.length-2;e>=0;e--)r[e]=Zn(r[e+1],r[e],i,`up`,a,o),r[e]=Qn(r[e+1],r[e],i,r[e-1],a)}return{layers:r}}r($n,`orderLayers`);function er(e,t,n){let i=n?.layerGap??Ot.DEFAULT_LAYER_GAP,a=n?.nodeGap??Ot.DEFAULT_NODE_GAP,o=n?.laneGap??a*2,s=n?.direction??`TB`,c=s===`LR`||s===`RL`,l=Object.create(null),u=Object.create(null),d=new Map((t.layout?.nodes??[]).filter(e=>e.isEdgeLabel).map(e=>[e.id,e])),f=r(e=>d.get(e)??t.nodeById.get(e),`getNode`),p=r(e=>f(e)?.width??0,`getWidth`),m=r(e=>f(e)?.height??0,`getHeight`),h=bn(t),g=new Map,_=r(e=>g.has(e)?g.get(e)??null:h(e),`topLaneOf`),v=Sn(t,n?.laneOrder),y=new Set;for(let t of e.layers)for(let e of t)y.add(h(e));let b=y.has(null),x=v.filter(e=>y.has(e)),S=[...b?[null]:[],...x],C=e.layers,w=new Map;for(let[e,t]of C.entries())for(let n of t)w.set(n,e);let T=[],E=[],D=[];for(let e of t.layout?.edges??[]){let t=e.labelNodeId,n=e.start,i=e.end;if(!t||!d.has(t)||n==null||i==null)continue;let a=w.get(n),o=w.get(i);if(a==null||o==null){D.push({labelId:t,near:a==null?i:n});continue}if(g.set(t,h(i)),a===o){let e=r(e=>S.indexOf(h(e)),`column`);T.push({labelId:t,rank:o,lane:h(i),side:n!==i&&e(n)<e(i)?`before`:`after`});continue}let s=Math.min(a,o),c=Math.max(a,o);E.push({labelId:t,start:n,end:i,gap:s+Math.floor((c-s-1)/2),crossesLanes:h(n)!==h(i)})}let O=C.map(e=>e.reduce((e,t)=>Math.max(e,m(t)),0));for(let{labelId:e,rank:t}of T)O[t]=Math.max(O[t],m(e));let k=C.map(()=>0);if(c)for(let e=0;e+1<C.length;e++){let t=C[e].reduce((e,t)=>Math.max(e,p(t)),0),n=C[e+1].reduce((e,t)=>Math.max(e,p(t)),0),r=O[e],a=O[e+1],o=r/2+a/2,s=(t+n)/2;k[e]=Math.max(0,s-o-i)}let ee=c?lt(t.layout?.nodes??[]):1,A=C.map(()=>0);for(let{labelId:e,gap:t}of E){let n=((c?p(e):m(e))+2*Ot.EDGE_LABEL_CLEARANCE)/ee;A[t]=Math.max(A[t],n)}for(let[e,t]of A.entries())k[e]+=t;let j=Object.create(null);for(let e of x)j[e]=0;b&&(j.null=0);for(let e of C){let t=Object.create(null),n=[];for(let r of e){let e=_(r);e===null?n.push(r):(t[e]||=[]).push(r)}for(let[e,n]of Object.entries(t)){let t=n.reduce((e,t)=>e+p(t),0)+a*Math.max(0,n.length-1);j[e]=Math.max(j[e]??0,t)}if(b&&n.length){let e=n.reduce((e,t)=>e+p(t),0)+a*Math.max(0,n.length-1);j.null=Math.max(j.null??0,e)}}let M=new Map;for(let e of E){let t=`${e.gap}:${_(e.labelId)}`,n=M.get(t);n?n.push(e):M.set(t,[e])}for(let e of M.values()){let t=_(e[0].labelId);if(t!==null){let n=e.reduce((e,t,n)=>e+p(t.labelId)+(n>0?a:0),0);j[t]=Math.max(j[t]??0,n)}}let N=new Map;for(let{labelId:e,rank:t,lane:n,side:r}of T){let i=`${t}:${n}:${r}`;N.set(i,(N.get(i)??0)+a+p(e))}let P=r((e,t,n)=>N.get(`${e}:${t}:${n}`)??0,`rowLabelSpan`);for(let{rank:e,lane:t}of T){let n=C[e].filter(e=>_(e)===t).reduce((e,t,n)=>e+p(t)+(n>0?a:0),0),r=Math.max(P(e,t,`before`),P(e,t,`after`)),i=t??`null`;j[i]=Math.max(j[i]??0,n+2*r)}let te=new Map;{let e=S.map(e=>(e===null?j.null:j[e])??0),t=-(e.reduce((e,t)=>e+t,0)+o*Math.max(0,S.length-1))/2;for(let n=0;n<S.length;n++){let r=S[n],i=e[n]??0,a=t+i/2;te.set(r,a),t+=i,n<S.length-1&&(t+=o)}}let ne=[],re=0;for(let[e,t]of C.entries()){let n=O[e]??0,r=new Map;for(let e of t){let t=_(e),n=r.get(t)??[];n.push(e),r.set(t,n)}for(let e of S){let t=r.get(e)??[];if(t.length===0)continue;let i=te.get(e);if(t.length===1){let e=t[0];l[e]=i,u[e]=re+n/2}else{let e=t.map(e=>p(e)),r=i-(e.reduce((e,t)=>e+t,0)+a*(t.length-1))/2;for(let[i,o]of t.entries()){let t=e[i];l[o]=r+t/2,u[o]=re+n/2,r+=t+a}}}let o=i+(k[e]??0);ne[e]=re+n+o/2,re+=n+o}let F=new Map;for(let{labelId:e,rank:t,lane:n,side:r}of T){let i=`${t}:${n}:${r}`;if(!F.has(i)){let e=C[t].filter(e=>_(e)===n).map(e=>r===`before`?l[e]-p(e)/2:l[e]+p(e)/2);F.set(i,r===`before`?Math.min(...e):Math.max(...e))}let o=p(e),s=F.get(i)+(r===`before`?-1:1)*(a+o/2);l[e]=s,u[e]=u[C[t].find(e=>_(e)===n)],F.set(i,s+o/2*(r===`before`?-1:1))}for(let e of M.values()){let t=e.map(({start:e,end:t,crossesLanes:n})=>n?l[t]:((l[e]??0)+(l[t]??0))/2),n=e.map((e,t)=>t).sort((e,n)=>t[e]-t[n]||e-n),i=[],o=-1/0;for(let r of n){let n=p(e[r].labelId);i[r]=Math.max(t[r],o+a+n/2),o=i[r]+n/2}let s=r(e=>e.reduce((e,t)=>e+t,0)/e.length,`mean`),c=s(t)-s(i);for(let[t,{labelId:n,gap:r}]of e.entries())l[n]=i[t]+c,u[n]=ne[r]}for(let{labelId:e,near:t}of D)l[e]=l[t]??0,u[e]=u[t]??0;let ie=new Map;for(let e of t.edges){let t=e.ref.id;ie.has(t)||ie.set(t,[]),ie.get(t).push(e)}for(let[,e]of ie){if(e.length===0)continue;let n=e[0].ref,r=n.start,i=n.end;if(r==null||i==null)continue;let a=Math.round(((l[r]??0)+(l[i]??0))/2),o=new Set;for(let t of e)o.add(t.src),o.add(t.dst);for(let e of o)e!==r&&e!==i&&t.nodeById.get(e)?.isDummy&&(l[e]=a)}return{x:l,y:u}}r(er,`assignCoordinates`);var tr=8;function nr(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}r(nr,`hashString`);function rr(e){let t=e>>>0;return()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}r(rr,`mulberry32`);function ir(e,t){let n=[...e],r=rr(t);for(let e=n.length-1;e>0;e--){let t=Math.floor(r()*(e+1));[n[e],n[t]]=[n[t],n[e]]}return n}r(ir,`deterministicShuffle`);function ar(e,t){let n=0;for(let[r,i]of e.entries())n+=Math.abs(r-(t.get(i)??r));return n}r(ar,`sourceDistance`);function or(e,t){let n=new Map;for(let[t,r]of e.entries())n.set(r,t);let r=0;for(let{a:e,b:i,weight:a}of t){let t=n.get(e),o=n.get(i);t!=null&&o!=null&&(r+=a*Math.abs(t-o))}return r}r(or,`laneArrangementCost`);function sr(e){let t=xn(e);if(t.length<2)return[];let n=new Map(t.map((e,t)=>[e,t])),r=bn(e),i=new Map;for(let t of e.layout.edges??[]){if(t.isLayoutOnly)continue;let a=typeof t.start==`string`?t.start:void 0,o=typeof t.end==`string`?t.end:void 0;if(!a||!o||!e.nodeById.has(a)||!e.nodeById.has(o))continue;let s=r(a),c=r(o);if(!s||!c||s===c)continue;let l=n.get(s),u=n.get(c);if(l==null||u==null)continue;let[d,f]=l<=u?[s,c]:[c,s],p=`${d}\0${f}`,m=i.get(p);m?m.weight++:i.set(p,{a:d,b:f,weight:1})}return[...i.values()]}r(sr,`buildWeightedLaneEdges`);function cr(e,t,n){let r=[...e],i=or(r,t),a=!0,o=0,s=Math.max(1,r.length);for(;a&&o<s;){a=!1,o++;for(let e=0;e+1<r.length;e++){[r[e],r[e+1]]=[r[e+1],r[e]];let n=or(r,t);n<i?(i=n,a=!0):[r[e],r[e+1]]=[r[e+1],r[e]]}}return{order:r,cost:i,sourceDistance:ar(r,n)}}r(cr,`greedySwitch`);function lr(e,t){return e.cost===t.cost?e.sourceDistance<t.sourceDistance:e.cost<t.cost}r(lr,`isBetterCandidate`);function ur(e,t,n){let r=[...t].sort((e,t)=>e.a===t.a?e.b.localeCompare(t.b):e.a.localeCompare(t.a)).map(({a:e,b:t,weight:n})=>`${e}:${t}:${n}`).join(`|`);return nr(`${e.join(`|`)}#${r}#${n}`)}r(ur,`seedForRestart`);function dr(e,t={}){let n=xn(e);if(n.length<2)return n;let r=sr(e);if(r.length===0)return n;let i=new Map(n.map((e,t)=>[e,t])),a=cr(n,r,i),o=Math.max(0,t.restarts??tr);for(let e=0;e<o;e++){let t=cr(ir(n,ur(n,r,e)),r,i);lr(t,a)&&(a=t)}return a.order}r(dr,`optimizeTopLaneOrder`);function fr(e,t){let n=t?.ignoreCrossLaneEdges??!0,r=t?.optimizeRanksByCrossings??!0,i=sn(e),a=t?.automaticLaneOrdering?dr(i,{restarts:tr}):void 0,o=vn(i),s=o.acyclic,{layering:c,graphWithDummies:l}=Wn(n?Un(s,{compactSingleInput:t?.compactSingleInput??Dt.DEFAULT_COMPACT_SINGLE_INPUT,ignoreCrossLaneEdges:!0,direction:t?.direction}):Vn(s,{compactSingleInput:t?.compactSingleInput??Dt.DEFAULT_COMPACT_SINGLE_INPUT,ignoreCrossLaneEdges:!1,optimizeRanksByCrossings:r}),s),u=$n(c,l,{laneOrder:a}),d=er(u,l,{layerGap:t?.layerGap,nodeGap:t?.nodeGap,direction:t?.direction,laneOrder:a});return{acyclic:s,reversed:o.reversed,layering:c,ordered:u,coordinates:d}}r(fr,`sugiyamaLayout`);var $=Et.EPSILON,pr=8,mr=15,hr=15,gr=25,_r=20,vr=10;function yr(e,t,n){let r=e.x??0,i=e.y??0,a=t.x-r,o=t.y-i,s=Math.abs(a),c=Math.abs(o);return s<$&&c<$?n:c>$&&c*3>=s?o>0?`bottom`:`top`:s>$?a>0?`right`:`left`:n}r(yr,`chooseOrthogonalSide`);var br=r(e=>typeof e==`number`&&Number.isFinite(e)&&e>0,`isDrawableSize`);function xr(e,t){let n=e.metadata?.drawnExtent;return{w:br(n?.width)?n.width:e.width??t,h:br(n?.height)?n.height:e.height??t}}r(xr,`drawnSize`);function Sr(e,t){return Math.abs(e.to-t.from)<$||Math.abs(e.to-t.to)<$?e.to:e.from}r(Sr,`sharedLineEndpointCoord`);function Cr(e,t){return e.orient===`vertical`?{x:e.coord,y:t}:{x:t,y:e.coord}}r(Cr,`pointOnLine`);function wr(e,t){let n=e.nodes??[],i=e.edges??[],a=[];for(let e of i)e.isLayoutOnly||a.push({...e,__originalEdge:e});let o=new Map,c=new Map,l=[],u=t===`LR`;for(let e of n)o.set(e.id,e);let d=s(n),f=n.filter(e=>d.isLane(e.id));for(let e of f){let t={id:e.id},i=r(e=>{c.set(e.id,t),n.filter(t=>t.parentId===e.id).forEach(i)},`assignLane`);i(e)}let m=p(n),h=n.filter(e=>!e.isGroup&&!e.isEdgeLabel&&!m.has(e.id)).map(e=>{let t=e.width??10,n=e.height??10,r=e.x??0,i=e.y??0,a=pr;return{nodeId:e.id,minX:r-t/2-a,maxX:r+t/2+a,minY:i-n/2-a,maxY:i+n/2+a,visualXHalfExtent:u?n/2+a:t/2+a}}),g=r((e,t,n,r)=>{let i=l.find(n=>n.orientation===e&&Math.abs(n.coord-t)<1);return i||(i={id:`pipe-${e}-${t.toFixed(0)}`,orientation:e,coord:t,spanMin:n,spanMax:r,tracks:[]},l.push(i)),i.spanMin=Math.min(i.spanMin,n),i.spanMax=Math.max(i.spanMax,r),i},`getOrAddPipe`),_=r((e,t)=>{let{w:n,h:r}=xr(e,10),i=e.x??0,a=e.y??0;switch(t){case`top`:return{x:i,y:a-r/2};case`bottom`:return{x:i,y:a+r/2};case`left`:return{x:i-n/2,y:a};case`right`:return{x:i+n/2,y:a}}},`portForSide`),v=r((e,t,n)=>_(e,yr(e,t,n?`bottom`:`top`)),`getOrthogonalPort`),y=[],b=[],x=new Set,S=1e3,C=r((e,t,n)=>{if(y.length===0)return 0;let r=Math.abs(t.y-n.y)<$,i=Math.abs(t.x-n.x)<$;if(!r&&!i)return 0;let a=0;if(r){let r=t.y,i=Math.min(t.x,n.x)-$,o=Math.max(t.x,n.x)+$;if(o<=i)return 0;for(let t of y)t.edgeIndex!==e&&t.orientation===`vertical`&&(t.pipe.coord<i||t.pipe.coord>o||t.from-$<=r&&t.to+$>=r&&(a+=S))}else if(i){let r=t.x,i=Math.min(t.y,n.y)-$,o=Math.max(t.y,n.y)+$;if(o<=i)return 0;for(let t of y)t.edgeIndex!==e&&t.orientation===`horizontal`&&(t.pipe.coord<i||t.pipe.coord>o||t.from-$<=r&&t.to+$>=r&&(a+=S))}return a},`crossingPenalty`),w=a.map((e,t)=>{if(!e.start||!e.end)return{idx:t,crossLane:0,dx:0,dy:0};let n=o.get(e.start),r=o.get(e.end),i=c.get(e.start),a=c.get(e.end);return{idx:t,crossLane:i&&a&&i.id!==a.id?1:0,dx:n&&r?Math.abs((r.x??0)-(n.x??0)):0,dy:n&&r?Math.abs((r.y??0)-(n.y??0)):0}}).sort((e,t)=>{if(e.crossLane!==t.crossLane)return t.crossLane-e.crossLane;let n=e.dx+e.dy,r=t.dx+t.dy;return Math.abs(n-r)>1?n-r:e.idx-t.idx}).map(e=>e.idx),T=r((e,t,n,r)=>{let i=Math.min(e.x,t.x),a=Math.max(e.x,t.x),o=Math.min(e.y,t.y),s=Math.max(e.y,t.y);return!!h.find(c=>n&&c.nodeId===n||r&&c.nodeId===r?!1:Math.abs(e.x-t.x)>$?c.minY<e.y&&c.maxY>e.y&&c.maxX>i&&c.minX<a:c.minX<e.x&&c.maxX>e.x&&c.maxY>o&&c.minY<s)},`isSegmentBlocked`),E=new Map,D=new Map;for(let e of a)e.start&&e.end&&e.start!==e.end&&(D.set(e.start,(D.get(e.start)??0)+1),D.set(e.end,(D.get(e.end)??0)+1));let O=r((e,t)=>yr(e,t,`bottom`),`determineSide`),k=new Map;for(let[e,t]of a.entries()){if(!t.start||!t.end||t.start===t.end||t.points&&t.points.length>0)continue;let n=o.get(t.start),r=o.get(t.end);if(!n||!r)continue;let i=(r.x??0)-(n.x??0),a=(r.y??0)-(n.y??0);k.set(e,{edgeIdx:e,srcId:t.start,dstId:t.end,srcSide:O(n,{x:r.x??0,y:r.y??0}),dstSide:O(r,{x:n.x??0,y:n.y??0}),absDx:Math.abs(i),absDy:Math.abs(a),dxSign:Math.sign(i),dySign:Math.sign(a)})}let ee=r(e=>e.srcSide===`top`||e.srcSide===`bottom`?e.absDx===0?1/0:e.absDy/e.absDx:e.absDy===0?1/0:e.absDx/e.absDy,`preferenceStrength`),A=r(e=>e.srcSide===`top`||e.srcSide===`bottom`?e.dxSign===0?[`right`,`left`]:[e.dxSign>0?`right`:`left`]:e.dySign===0?[`bottom`,`top`]:[e.dySign>0?`bottom`:`top`],`secondarySides`),j=r(e=>A(e)[0],`secondarySide`),M=new Map;for(let e of k.values()){let t=`${e.srcId}:${e.srcSide}`;M.has(t)||M.set(t,[]),M.get(t).push(e)}let N=new Map,P=r((e,t)=>`${e}:${t}`,`loadKey`);for(let e of k.values())N.set(P(e.srcId,e.srcSide),(N.get(P(e.srcId,e.srcSide))??0)+1),N.set(P(e.dstId,e.dstSide),(N.get(P(e.dstId,e.dstSide))??0)+1);for(let e of M.values())if(!(e.length<2)){e.sort((e,t)=>{let n=ee(e),r=ee(t);return Math.abs(n-r)>1e-9?r-n:e.edgeIdx-t.edgeIdx});for(let t=1;t<e.length;t++){let n=e[t],r=N.get(P(n.srcId,n.srcSide))??0,i=A(n).reduce((e,t)=>(N.get(P(n.srcId,t))??0)<(N.get(P(n.srcId,e))??0)?t:e),a=N.get(P(n.srcId,i))??0;a>=r||(N.set(P(n.srcId,n.srcSide),r-1),N.set(P(n.srcId,i),a+1),n.srcSide=i)}}let te=r(e=>{let t=e?.shape;return t===`question`||t===`diamond`},`isDiamondNode`),ne=new Map;for(let e of k.values())ne.has(e.dstId)||ne.set(e.dstId,new Set),ne.get(e.dstId).add(e.dstSide);for(let e of k.values()){if(!te(o.get(e.srcId)))continue;let t=ne.get(e.srcId);if(!t?.has(e.srcSide))continue;let n=j(e);if(t.has(n)||(N.get(P(e.srcId,n))??0)>0)continue;let r=N.get(P(e.srcId,e.srcSide))??0;N.set(P(e.srcId,e.srcSide),Math.max(0,r-1)),N.set(P(e.srcId,n),1),e.srcSide=n}let re=r(e=>{let t=e?.shape;return t===`hexagon`||t===`notch-pent`},`hasVertexFaces`),F=new Map;for(let e of k.values())F.has(e.srcId)||F.set(e.srcId,new Set),F.get(e.srcId).add(e.srcSide);let ie=r(e=>e.dstSide===`top`||e.dstSide===`bottom`?e.dxSign>=0?`left`:`right`:e.dySign>=0?`top`:`bottom`,`secondaryDstSide`);for(let e of k.values()){if(!re(o.get(e.dstId)))continue;let t=F.get(e.dstId);if(!t?.has(e.dstSide))continue;let n=ie(e);if(t.has(n)||(N.get(P(e.dstId,n))??0)>0)continue;let r=N.get(P(e.dstId,e.dstSide))??0;N.set(P(e.dstId,e.dstSide),Math.max(0,r-1)),N.set(P(e.dstId,n),1),e.dstSide=n;let i=e.dySign>=0?`bottom`:`top`;if((n===`top`||n===`bottom`)&&ne.get(e.srcId)?.has(e.srcSide)&&!ne.get(e.srcId)?.has(i)&&(N.get(P(e.srcId,i))??0)===0){let t=N.get(P(e.srcId,e.srcSide))??0;N.set(P(e.srcId,e.srcSide),Math.max(0,t-1)),N.set(P(e.srcId,i),1),e.srcSide=i}}for(let e of k.values()){let{edgeIdx:t,srcId:n,dstId:r,srcSide:i,dstSide:a}=e,s=o.get(n),c=o.get(r),l=`${n}:${i}:src`,u=i===`top`||i===`bottom`?c.x??0:c.y??0;E.has(l)||E.set(l,[]),E.get(l).push({edgeIdx:t,oppositeCoord:u});let d=`${r}:${a}:dst`,f=a===`top`||a===`bottom`?s.x??0:s.y??0;E.has(d)||E.set(d,[]),E.get(d).push({edgeIdx:t,oppositeCoord:f})}let ae=new Map;for(let[e,t]of E){if(t.length<2)continue;t.sort((e,t)=>e.oppositeCoord-t.oppositeCoord);let n=e.split(`:`),r=n.slice(0,-2).join(`:`),i=n[n.length-2],a=n[n.length-1],s=o.get(r);if(!s)continue;let c=i===`left`||i===`right`,l=xr(s,10),u=c?l.h:l.w,d=s.shape,f=d===`question`||d===`diamond`?u*.3:u,p=Math.min(20,f/(t.length-1),Math.max(8,f/(t.length+1))),m=-(p*(t.length-1))/2;for(let[e,n]of t.entries()){let t=m+e*p,r=`${n.edgeIdx}:${a}`;ae.set(r,t)}}let I=r(e=>!!a[e]?.labelNodeId,`edgeHasLabelNode`),L=r((e,t)=>e?(E.get(`${e}:${t}:src`)??[]).some(({edgeIdx:e})=>I(e))||(E.get(`${e}:${t}:dst`)??[]).some(({edgeIdx:e})=>I(e)):!1,`faceHasLabelNode`),R=r((e,t,n)=>t===`top`||t===`bottom`?{x:e.x+n,y:e.y}:{x:e.x,y:e.y+n},`applyPortOffset`),z=r((e,t,n)=>{let r=k.get(e),i={x:n.x??0,y:n.y??0},a={x:t.x??0,y:t.y??0},o=r?.srcSide??O(t,i),s=r?.dstSide??O(n,a),c=r?_(t,r.srcSide):v(t,i,!0),l=r?_(n,r.dstSide):v(n,a,!1),u=ae.get(`${e}:src`),d=ae.get(`${e}:dst`);return u!==void 0&&(c=R(c,o,u)),d!==void 0&&(l=R(l,s,d)),{pSrcPort:c,pDstPort:l,srcSide:o,dstSide:s}},`portsForEdge`);for(let e of w){let t=a[e];if(b[e]=[],!t.start||!t.end||t.points&&t.points.length>0||t.start===t.end)continue;let n=o.get(t.start),i=o.get(t.end);if(!n||!i)continue;let{pSrcPort:s,pDstPort:c,srcSide:d,dstSide:f}=z(e,n,i),p={...s},m={...c},_=d===`top`||d===`bottom`,v=f===`top`||f===`bottom`;_?p.y=s.y>(n.y??0)?s.y+_r:s.y-_r:p.x=s.x>(n.x??0)?s.x+_r:s.x-_r,v?m.y=c.y>(i.y??0)?c.y+_r:c.y-_r:m.x=c.x>(i.x??0)?c.x+_r:c.x-_r;let S=r((e,t)=>{for(let n of h)if(!t.includes(n.nodeId)&&e.x>n.minX&&e.x<n.maxX&&e.y>n.minY&&e.y<n.maxY)return{inside:!0,obstacle:n};return{inside:!1}},`isPointInObstacle`),w=r((e,t,n,r,i)=>{if(i){let i=e.y>(t.y??0);return{x:(n.x??0)>=e.x?r.maxX+mr:r.minX-mr,y:i?r.maxY+hr:r.minY-hr,leavesPositiveSide:i}}let a=e.x>(t.x??0),o=(n.y??0)>=e.y;return{x:a?r.maxX+mr:r.minX-mr,y:o?r.maxY+hr:r.minY-hr,leavesPositiveSide:a}},`obstacleDetour`),O=[],k=[t.start,t.end],ee=S(p,k);if(ee.inside&&ee.obstacle){let e=ee.obstacle;if(_){let t=w(s,n,i,e,!0);p.x=t.x,p.y=t.y;let r=t.leavesPositiveSide?Math.min(e.minY-2,s.y+_r):Math.max(e.maxY+2,s.y-_r);O=[{x:s.x,y:r},{x:t.x,y:r},{x:t.x,y:t.y}]}else{let t=w(s,n,i,e,!1),r=t.leavesPositiveSide?Math.min(e.minX-2,s.x+_r):Math.max(e.maxX+2,s.x-_r);p.x=t.x,p.y=t.y,O=[{x:r,y:s.y},{x:r,y:t.y},{x:t.x,y:t.y}]}}let A=[],j=S(m,k);if(j.inside&&j.obstacle){let e=j.obstacle;if(v){let t=w(c,i,n,e,!0);m.x=t.x,m.y=t.y,A=[{x:t.x,y:t.y},{x:c.x,y:t.y}]}else{let t=w(c,i,n,e,!1);m.x=t.x,m.y=t.y,A=[{x:t.x,y:t.y},{x:t.x,y:c.y}]}}if(O.length===0&&A.length===0){let n=mr,r=Math.abs(p.x-m.x)<n,i=Math.abs(p.y-m.y)<n,a=ae.get(`${e}:src`)!==void 0||ae.get(`${e}:dst`)!==void 0,o=(E.get(`${t.start??``}:${d}:src`)?.length??0)+(E.get(`${t.start??``}:${d}:dst`)?.length??0),l=(E.get(`${t.end??``}:${f}:src`)?.length??0)+(E.get(`${t.end??``}:${f}:dst`)?.length??0),u=o>1||l>1,h=D.get(t.start??``)??0,g=D.get(t.end??``)??0,_=o>1&&L(t.start,d)||l>1&&L(t.end,f);if((r||i)&&!a&&(!u||u&&!_&&(o<=1||h<=2)&&(l<=1||g<=2))&&!T(s,c,t.start,t.end)){t.points=[{...s},{...p},{...m},{...c}],x.add(e);let n=i?`horizontal`:`vertical`,r=i?s.y:s.x,a=i?Math.min(s.x,c.x):Math.min(s.y,c.y),o=i?Math.max(s.x,c.x):Math.max(s.y,c.y),l={id:`fast-path-${n}-${r.toFixed(0)}-${e}`,orientation:n,coord:r,spanMin:a,spanMax:o,tracks:[]};y.push({edgeIndex:e,segmentIndex:0,orientation:n,pipe:l,trackIndex:0,from:a,to:o});continue}}p.x=g(`vertical`,p.x,p.y,p.y).coord,m.x=g(`vertical`,m.x,m.y,m.y).coord;let M=Math.min(p.x,m.x)-50,N=Math.max(p.x,m.x)+50,P=Math.min(p.y,m.y)-50,te=Math.max(p.y,m.y)+50;for(let e of h){let t=Math.min(p.x,m.x),n=Math.max(p.x,m.x),r=Math.min(p.y,m.y),i=Math.max(p.y,m.y);e.minX<n&&e.maxX>t&&e.minY<i&&e.maxY>r&&(M=Math.min(M,e.minX-gr),N=Math.max(N,e.maxX+gr),P=Math.min(P,e.minY-gr),te=Math.max(te,e.maxY+gr))}for(let e of h){if(e.maxX<M||e.minX>N||e.maxY<P||e.minY>te)continue;let t=mr;g(`horizontal`,e.minY-t,M,N),g(`horizontal`,e.maxY+t,M,N);let n=hr;g(`vertical`,e.minX-n,P,te),g(`vertical`,e.maxX+n,P,te)}g(`horizontal`,p.y,M,N),g(`horizontal`,m.y,M,N);let ne=l.filter(e=>e.orientation===`horizontal`&&e.coord>=P&&e.coord<=te),re=l.filter(e=>e.orientation===`vertical`&&e.coord>=M&&e.coord<=N),F=r((e,t)=>`${e.toFixed(1)},${t.toFixed(1)}`,`getKey`),ie=F(p.x,p.y),I=F(m.x,m.y),R=new Map,B=new Map,V=new Map,H=new Set,U=[];R.set(ie,0),V.set(ie,`n`),U.push({key:ie,f:Math.hypot(m.x-p.x,m.y-p.y),pt:p}),H.add(ie);let W=[],oe=r((e,n)=>T(e,n,t.start,t.end),`checkSegmentBlocked`),se={x:m.x,y:p.y},ce=oe(p,se),G=oe(se,m),le=ce||G,ue={x:p.x,y:m.y},de=oe(p,ue),fe=oe(ue,m);if(le?de||fe||(W=Math.abs(p.x-m.x)<$?[p,m]:[p,ue,m]):W=Math.abs(p.y-m.y)<$||Math.abs(p.x-m.x)<$?[p,m]:[p,se,m],W.length===0)for(;U.length>0;){U.sort((e,t)=>e.f-t.f);let n=U.shift();if(H.delete(n.key),n.key===I){let e=I,t=m;for(W=[t];B.has(e);){let n=B.get(e);W.unshift(n),t=n,e=F(n.x,n.y)}break}let r=n.pt.x,i=n.pt.y,a=re.sort((e,t)=>e.coord-t.coord),o=a.findIndex(e=>Math.abs(e.coord-r)<1),s=ne.sort((e,t)=>e.coord-t.coord),c=s.findIndex(e=>Math.abs(e.coord-i)<1),l=[];o>0&&l.push({x:a[o-1].coord,y:i}),o>=0&&o<a.length-1&&l.push({x:a[o+1].coord,y:i}),c>0&&l.push({x:r,y:s[c-1].coord}),c>=0&&c<s.length-1&&l.push({x:r,y:s[c+1].coord});for(let a of l){let o=Math.min(r,a.x),s=Math.max(r,a.x),c=Math.min(i,a.y),l=Math.max(i,a.y);if(h.some(e=>e.nodeId===t.start||e.nodeId===t.end?!1:o===s?e.minX<r&&e.maxX>r&&e.maxY>c&&e.minY<l:e.minY<i&&e.maxY>i&&e.maxX>o&&e.minX<s))continue;let u=F(a.x,a.y),d=Math.abs(a.x-r)+Math.abs(a.y-i),f=C(e,n.pt,a),g=0,_=m.x-p.x,v=m.y-p.y,y=a.x-r,b=a.y-i;(v>10&&b<-5||v<-10&&b>5)&&(g=Math.abs(b)*100),(_>10&&y<-5||_<-10&&y>5)&&(g+=Math.abs(y)*50);let x=0,S=V.get(n.key)??`n`,w=Math.abs(y)>$?`h`:`v`;S!==`n`&&S!==w&&(x=50);let T=d+f+g+x,E=(R.get(n.key)??1/0)+T,D=Math.abs(m.x-a.x)+Math.abs(m.y-a.y);if(E<(R.get(u)??1/0)){if(B.set(u,n.pt),R.set(u,E),V.set(u,w),!H.has(u))U.push({key:u,f:E+D,pt:a}),H.add(u);else{let e=U.findIndex(e=>e.key===u);e!==-1&&(U[e].f=E+D)}}}}if(W.length===0&&(W=[p,{x:p.x,y:m.y},m]),W.length>4){let e=W[0],t=W[W.length-1],n=Math.min(e.x,t.x),i=Math.max(e.x,t.x),a=Math.min(e.y,t.y),o=Math.max(e.y,t.y);for(let e of W)n=Math.min(n,e.x),i=Math.max(i,e.x),a=Math.min(a,e.y),o=Math.max(o,e.y);let s=i>Math.max(e.x,t.x),c=n<Math.min(e.x,t.x);if(u){let r=hr;if(s){let n=Math.max(e.x,t.x),a=Math.min(e.y,t.y),o=Math.max(e.y,t.y),s=h.filter(e=>e.minX<n&&e.maxX>n&&e.minY<o&&e.maxY>a);if(s.length>0){let n=Math.max(e.x,t.x);for(let e of s){let t=(e.minX+e.maxX)/2;if(e.visualXHalfExtent===void 0||isNaN(e.visualXHalfExtent))continue;let i=t+e.visualXHalfExtent+r;n=Math.max(n,i)}isNaN(n)||(i=n)}}if(c){let i=h.filter(n=>n.minX<Math.min(e.x,t.x)+r&&n.minY<Math.max(e.y,t.y)&&n.maxY>Math.min(e.y,t.y));if(i.length>0){let a=Math.min(e.x,t.x);for(let e of i){let t=(e.minX+e.maxX)/2-e.visualXHalfExtent-r;a=Math.min(a,t)}n=a}}}let l=r(n=>{let r=t.y>e.y,i=h.filter(n=>{let r=Math.min(e.x,t.x)<n.maxX&&Math.max(e.x,t.x)>n.minX,i=Math.min(e.y,t.y)<n.maxY&&Math.max(e.y,t.y)>n.minY;return r&&i}),a=i;if(u&&i.length>0){let e=i.filter(e=>e.minX<n&&e.maxX>n);e.length>0&&(a=e)}if(a.length===0)return t.y;let o=mr;if(r){let e=Math.max(...a.map(e=>e.maxY))+o;if(e<t.y-$)return e}else{let e=Math.min(...a.map(e=>e.minY))-o;if(e>t.y+$)return e}return t.y},`findBestReturnY`),d=r(n=>{let r=l(n),i={x:n,y:e.y},a={x:n,y:r},o={x:t.x,y:r},s=oe(e,i),c=oe(i,a),u=oe(a,o),d=r!==t.y&&oe(o,t);return!s&&!c&&!u&&!d?Math.abs(r-t.y)<$?[e,i,a,t]:[e,i,a,o,t]:null},`trySimplifyWithDetourX`),f=s&&!c?d(i):c&&!s?d(n):null;f&&(W=f)}let K=[s,...O,...W,...A.reverse(),c];if(K.length>=3){let e=K[K.length-1],t=K[K.length-2],n=K[K.length-3],r=Math.abs(n.y-t.y)<$&&Math.abs(t.y-e.y)<$,i=Math.abs(n.x-t.x)<$&&Math.abs(t.x-e.x)<$;if(r){let r=Math.sign(t.x-n.x),i=Math.sign(e.x-n.x);r!==0&&r===i&&Math.abs(t.x-n.x)>Math.abs(e.x-n.x)&&K.splice(-2,1)}else if(i){let r=Math.sign(t.y-n.y),i=Math.sign(e.y-n.y);r!==0&&r===i&&Math.abs(t.y-n.y)>Math.abs(e.y-n.y)&&K.splice(-2,1)}}let pe=[K[0]];for(let e=1;e<K.length-1;e++){if(e===1){pe.push(K[e]);continue}let t=pe[pe.length-1],n=K[e],r=K[e+1];if(Math.abs(t.y-n.y)<$&&Math.abs(n.y-r.y)<$){if(n.x>t.x!=r.x>n.x){pe.push(n);continue}}else if(Math.abs(t.x-n.x)<$&&Math.abs(n.x-r.x)<$){if(n.y>t.y!=r.y>n.y){pe.push(n);continue}}else pe.push(n)}pe.push(K[K.length-1]);for(let t=0;t<pe.length-1;t++){let n=pe[t],r=pe[t+1],i=Math.abs(n.x-r.x)<$?`vertical`:`horizontal`,a=i===`vertical`?n.x:n.y,o=i===`vertical`?Math.min(n.y,r.y):Math.min(n.x,r.x),s=i===`vertical`?Math.max(n.y,r.y):Math.max(n.x,r.x),c=g(i,a,o,s),l={edgeIndex:e,segmentIndex:t,orientation:i,pipe:c,trackIndex:0,from:o,to:s};y.push(l),b[e].push(y.length-1),c.tracks[0]||(c.tracks[0]={index:0,coord:c.coord,segments:[]}),c.tracks[0].segments.push({edgeIndex:e,segmentIndex:t,from:o,to:s})}}let B=r((e,t)=>e.from<t.to&&t.from<e.to,`segmentsOverlap`),V=r((e,t,n,r)=>{let i=!r.segments.some(n=>(n.edgeIndex!==t.edgeIndex||n.segmentIndex!==t.segmentIndex)&&B(n,e)),a=!n.segments.some(n=>(n.edgeIndex!==e.edgeIndex||n.segmentIndex!==e.segmentIndex)&&B(n,t));return i&&a?(e.trackIndex=r.index,t.trackIndex=n.index,n.segments=[...n.segments.filter(t=>t.edgeIndex!==e.edgeIndex||t.segmentIndex!==e.segmentIndex),{edgeIndex:t.edgeIndex,segmentIndex:t.segmentIndex,from:t.from,to:t.to}],r.segments=[...r.segments.filter(e=>e.edgeIndex!==t.edgeIndex||e.segmentIndex!==t.segmentIndex),{edgeIndex:e.edgeIndex,segmentIndex:e.segmentIndex,from:e.from,to:e.to}],!0):!1},`trySwapSegmentsAcrossTracks`),H=r(e=>{let t=e.tracks.length;return e.tracks[t]={index:t,coord:e.coord,segments:[]},t},`createNewTrack`),U=r((e,t)=>{let n=e.pipe.tracks[e.trackIndex];n.segments=n.segments.filter(t=>t.edgeIndex!==e.edgeIndex||t.segmentIndex!==e.segmentIndex),e.trackIndex=t,e.pipe.tracks[t].segments.push({edgeIndex:e.edgeIndex,segmentIndex:e.segmentIndex,from:e.from,to:e.to})},`moveSegmentToTrack`),W=r((e,t)=>{let n=b[e.edgeIndex];for(let r of n){let n=y[r];n.pipe===e.pipe&&U(n,t)}},`moveSegmentChainToTrack`),oe=r(e=>{let t=b[e.edgeIndex],n=t.indexOf(y.indexOf(e)),r=[];return n>0&&r.push(y[t[n-1]]),n<t.length-1&&r.push(y[t[n+1]]),r},`getAdjacentSegmentsAlongEdge`),se=r((e,t)=>{if(e.orientation===t.orientation)return!1;let n=e.orientation===`horizontal`?e:t,r=e.orientation===`horizontal`?t:e;return r.pipe.coord>n.from&&r.pipe.coord<n.to&&n.pipe.coord>r.from&&n.pipe.coord<r.to},`haveAnyCrossing`),ce=r((e,t)=>{for(let n of e.tracks)if(!n.segments.some(e=>(e.edgeIndex!==t.edgeIndex||e.segmentIndex!==t.segmentIndex)&&B(e,t)))return n.index;return-1},`findAvailableTrack`),G=r((e,t)=>{if(e.trackIndex===t.trackIndex)return B(e,t);let n=oe(e),r=oe(t);return n.some(e=>r.some(t=>se(e,t)))},`segmentsConflict`),le=r((e,t,n)=>{if(V(e,t,e.pipe.tracks[e.trackIndex],t.pipe.tracks[t.trackIndex]))return;let r=ce(e.pipe,t);n(t,r===-1?H(e.pipe):r)},`resolveTrackConflict`),ue=r(e=>{let t=0;for(let n=0;n<e.length;n++)for(let r=n+1;r<e.length;r++){let i=e[n],a=e[r];i.pipe===a.pipe&&G(i,a)&&(t++,le(i,a,W))}return t},`resolveHandleConflicts`),de=new Map,fe=r(e=>{if(de.has(e))return de.get(e);let t=b[e];if(t.length===0){let t={dest:0,deviation:0,base:0,delta:0};return de.set(e,t),t}let n=y[t[0]].pipe.coord,r=n;for(let e=1;e<t.length;e++){let i=y[t[e]];if(i.orientation===`horizontal`){let e=i.from,t=i.to;r=Math.abs(e-n)>Math.abs(t-n)?e:t;break}}let i=Math.abs(r-n),a={dest:r,deviation:i,base:n,delta:r-n};return de.set(e,a),a},`getDestInfo`),K=r(()=>{let e=0,t=new Map;for(let[e,n]of a.entries())b[e].length!==0&&n.start&&(t.has(n.start)||t.set(n.start,[]),t.get(n.start).push(e));let n=r(e=>{let t=a[e];if(!t.start||!t.end)return 0;let n=o.get(t.start),r=o.get(t.end);if(!n||!r)return 0;let i=(r.x??0)-(n.x??0),s=(r.y??0)-(n.y??0);return Math.abs(i)+Math.abs(s)},`getEdgeDistance`);for(let r of t.values()){r.sort((e,t)=>{let r=fe(e),i=fe(t);if(Math.abs(r.deviation-i.deviation)>1)return r.deviation-i.deviation;if(Math.abs(r.dest-i.dest)>1)return r.dest-i.dest;let a=n(e),o=n(t);if(Math.abs(a-o)>1)return o-a;let s=b[e].length,c=b[t].length;if(s!==c)return s-c;if(s===1){let n=b[e][0],r=b[t][0];if(y[n]&&y[r]){let e=y[n],t=y[r],i=Math.abs(e.to-e.from),a=Math.abs(t.to-t.from);if(Math.abs(i-a)>1)return i-a}}return 0});let t=r.map(e=>y[b[e][0]]);e+=ue(t)}return e},`fixSourceHandleCrossings`),pe=r(()=>{let e=0,t=new Map;for(let[e,n]of a.entries())b[e].length!==0&&n.end&&(t.has(n.end)||t.set(n.end,[]),t.get(n.end).push(e));for(let n of t.values()){n.sort((e,t)=>{let n=r(e=>{let t=b[e];if(t.length<2)return 0;let n=y[t[t.length-2]];return Math.abs(n.to-n.from)},`getDist`),i=n(e),a=n(t);return Math.abs(i-a)>.1?i-a:e-t});let t=n.map(e=>y[b[e][b[e].length-1]]);e+=ue(t)}return e},`fixTargetHandleCrossings`),me=r(()=>{let e=0;for(let t of l){let n=[];for(let e of t.tracks)for(let t of e.segments){let e=b[t.edgeIndex].find(e=>y[e].segmentIndex===t.segmentIndex);e!==void 0&&n.push(y[e])}n.sort((e,t)=>e.edgeIndex-t.edgeIndex||e.segmentIndex-t.segmentIndex);for(let t=0;t<n.length;t++)for(let r=t+1;r<n.length;r++){let i=n[t],a=n[r];G(i,a)&&(e++,le(i,a,U))}}return e},`fixPipeCrossings`),q=0;for(;q<10;){let e=0;if(e+=K(),e+=pe(),e+=me(),e===0)break;q++}let he=new Map;for(let e of l){let t=[];e.tracks.forEach(e=>{e.segments.forEach(n=>{t.push({edgeIndex:n.edgeIndex,segmentIndex:n.segmentIndex,trackIndex:e.index,from:n.from,to:n.to})})}),t.sort((e,t)=>e.from-t.from);let n=[];if(t.length>0){let e=[t[0]],r=t[0].to;for(let i=1;i<t.length;i++){let a=t[i];a.from<r?(e.push(a),r=Math.max(r,a.to)):(n.push(e),e=[a],r=a.to)}n.push(e)}for(let t of n){let n=new Set;t.forEach(e=>n.add(e.trackIndex));let i=new Map;t.forEach(e=>{let t=fe(e.edgeIndex);i.set(e.trackIndex,(i.get(e.trackIndex)??0)+t.delta)});let a=[...n].filter(e=>(i.get(e)??0)<-1),o=[...n].filter(e=>(i.get(e)??0)>1),s=[...n].filter(e=>Math.abs(i.get(e)??0)<=1);a.sort((e,t)=>(i.get(t)??0)-(i.get(e)??0)),o.sort((e,t)=>(i.get(e)??0)-(i.get(t)??0));let c=r((n,r)=>{t.filter(e=>e.trackIndex===n).forEach(t=>{let n=x.has(t.edgeIndex)?e.coord:r;he.set(`${t.edgeIndex}-${t.segmentIndex}`,n)})},`assignCoord`),l=0;for(let t of a)l++,c(t,e.coord-l*vr);if(s.length===0&&n.size>0){let e=[...n].sort((e,t)=>Math.abs(i.get(e)??0)-Math.abs(i.get(t)??0))[0],t=a.indexOf(e);t!==-1&&a.splice(t,1);let r=o.indexOf(e);r!==-1&&o.splice(r,1),s.push(e)}let u=0;for(let t of s){if(u===0)c(t,e.coord);else{let n=u%2==1?1:-1,r=Math.ceil(u/2);c(t,e.coord+n*r*vr*.5)}u++}let d=0;for(let t of o)d++,c(t,e.coord+d*vr)}}for(let[e,t]of a.entries()){let n=b[e]??[];if(n.length===0)continue;let r=[],{pSrcPort:i,pDstPort:a}=z(e,o.get(t.start),o.get(t.end)),s=n.map(e=>{let t=y[e],n=he.get(`${t.edgeIndex}-${t.segmentIndex}`)??t.pipe.coord;return{orient:t.orientation,coord:n,from:t.from,to:t.to}});r.push(i);for(let e=0;e<s.length;e++){let t=s[e],n=r[r.length-1],i=t.orient===`vertical`?n.y:n.x,a=t.orient===`vertical`?n.x:n.y,o=s[e+1],c=e<s.length-1;if(Math.abs(a-t.coord)>$&&r.push(Cr(t,i)),c&&o.orient===t.orient){if(Math.abs(t.coord-o.coord)>$){let e=t.orient===`vertical`?(i+o.from)/2:Sr(t,o);r.push(Cr(t,e),Cr(o,e))}else(e===0||e===s.length-2)&&r.push(Cr(t,Sr(t,o)))}else if(c)r.push(Cr(t,o.coord));else{let e=Math.abs(t.from-i)<Math.abs(t.to-i)?t.to:t.from;r.push(Cr(t,e))}}let c=r[r.length-1];(Math.abs(c.x-a.x)>$||Math.abs(c.y-a.y)>$)&&r.push(a);let l=r[0];l&&(Math.abs(l.x-i.x)>$||Math.abs(l.y-i.y)>$)&&r.unshift(i);let u=[];r.length>0&&u.push(r[0]);for(let e=1;e<r.length;e++){let t=r[e],n=u[u.length-1];(Math.abs(t.x-n.x)>$||Math.abs(t.y-n.y)>$)&&u.push(t)}t.points=u}for(let e of a){let t=e.__originalEdge;t&&e.points&&(t.points=e.points)}e.edges=(e.edges??[]).filter(e=>!e.isLayoutOnly);let ge=r((e,t)=>{let n=t.x??0,r=t.y??0,{w:i,h:a}=xr(t,0);if(i<=0||a<=0)return e;let o=n-i/2,s=n+i/2,c=r-a/2,l=r+a/2;if(e.x<o||e.x>s||e.y<c||e.y>l)return e;let u=e.x-o,d=s-e.x,f=e.y-c,p=l-e.y,m=Math.min(u,d,f,p);return m===u?{x:o,y:e.y}:m===d?{x:s,y:e.y}:m===f?{x:e.x,y:c}:{x:e.x,y:l}},`nodeBoundaryClamp`);for(let t of e.edges){let e=t.points;if(!e||e.length<2)continue;let n=t.start,r=t.end,i=n?o.get(n):void 0,a=r?o.get(r):void 0;i&&(e[0]=ge(e[0],i)),a&&(e[e.length-1]=ge(e[e.length-1],a))}return e}r(wr,`routeEdgesOrthogonal`);function Tr(e){return e.direction??`TB`}r(Tr,`getSwimlaneDirection`);function Er(e){let t=N(e),n=e.config.flowchart?.nodeSpacing??40,r=e.config.flowchart?.rankSpacing??100,i=e.config.swimlane?.ignoreCrossLaneEdges??!0,a=e.config.swimlane?.optimizeRanksByCrossings??!0,o=e.config.swimlane?.automaticLaneOrdering??!1,s=Tr(e),{ordered:c,coordinates:l}=fr(t,{nodeGap:n,layerGap:r,ignoreCrossLaneEdges:i,optimizeRanksByCrossings:a,automaticLaneOrdering:o,direction:s});te(t,c,l,{nodeGap:n,layerGap:r});for(let t of e.edges??[])delete t.points;wr(e,s);for(let t of e.edges??[])t.curve&&t.curve!==`basis`||(t.curve=`rounded`);return on(e,s),an(e),s}r(Er,`runSwimlaneLayoutCore`);function Dr(e){M(e);let t=re(e);e.nodes=t.nodes,e.edges=t.edges}r(Dr,`prepareSwimlaneLayout`);var Or=t({prepareLayout:Dr,runLayoutCore:Er,afterPaint:i});export{Or as render};
@@ -0,0 +1,8 @@
1
+ import{r as e,t}from"./chunk-QB3YPZ4I-BhcIp-Bl.js";import"./chunk-TU62E6Q5-BDA8bjy3.js";import"./mermaid.core-B1AcqJgl.js";import"./chunk-HFQBQIA3-BATYGV1I.js";import"./chunk-M57EVK23-BgeE81Y7.js";import"./chunk-DQASFODM-CItpjfW5.js";import"./chunk-LEVMRMFU-DsFG_U8r.js";import"./chunk-AXFCVDMN-aqbxPiaN.js";import"./chunk-X4PVCEUW-Cs-r9l_d.js";import"./chunk-STOXU5M4-DOSqSu65.js";import"./chunk-R3KSYZAL-i9n2AYPG.js";import"./chunk-6MUBBAK2-C-VxnXsG.js";import"./chunk-BG4553SI-DDgvFLBP.js";import"./d3-selection-D2iIEb1P.js";import{n}from"./chunk-Y2CYZVJY-DsF7k-Jl.js";var r=t({styles:n(t=>`${e(t)}
2
+ .swimlane.cluster:not([data-color-id]) rect {
3
+ stroke: ${t.clusterBorder} !important;
4
+ }
5
+ [data-look="neo"].cluster rect {
6
+ filter: none;
7
+ }
8
+ `,`getStyles`)});export{r as diagram};