@diagrammo/dgmo 0.55.0 → 0.56.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 (271) hide show
  1. package/dist/advanced.d.ts +62 -2
  2. package/dist/advanced.js +115 -113
  3. package/dist/{analyzer-TDN5KJFP.js → analyzer-HQUXKZ5J.js} +3 -3
  4. package/dist/auto.js +131 -129
  5. package/dist/auto.mjs +1178 -626
  6. package/dist/block.js +56 -55
  7. package/dist/{calculator-VBIT6GQF.js → calculator-BBKAAQGD.js} +3 -3
  8. package/dist/chart-meta.js +47 -47
  9. package/dist/charts-d3-D67V6KHE.js +29 -0
  10. package/dist/{chunk-INTAQV2Y.js → chunk-23THM67F.js} +2 -2
  11. package/dist/{chunk-QZYGRDMM.js → chunk-2JMNOEAU.js} +97 -97
  12. package/dist/{chunk-WVGNXDEE.js → chunk-2UZVMWSQ.js} +4 -4
  13. package/dist/{chunk-A2ARDILY.js → chunk-3KOPPSUQ.js} +3 -3
  14. package/dist/{chunk-ETTDF3S2.js → chunk-3R67RRPC.js} +86 -55
  15. package/dist/{chunk-JYDMBWRP.js → chunk-42IT4BG2.js} +2 -2
  16. package/dist/{chunk-JQLSFZZP.js → chunk-4MB4UOT5.js} +3 -3
  17. package/dist/{chunk-ITXL2KU5.js → chunk-4MJOBVY7.js} +3 -3
  18. package/dist/{chunk-WITOJZGL.js → chunk-5J2RQGFG.js} +4 -4
  19. package/dist/{chunk-FBP33UM6.js → chunk-5VLUAAAE.js} +4 -4
  20. package/dist/{chunk-P5XXIVEU.js → chunk-5XMDSXZT.js} +3 -3
  21. package/dist/{chunk-32HUNA33.js → chunk-5ZDHXS5N.js} +13 -10
  22. package/dist/{chunk-MEQYZZFR.js → chunk-6IVXRTXH.js} +96 -23
  23. package/dist/{chunk-US3P2DQO.js → chunk-6VJCURWU.js} +2 -2
  24. package/dist/{chunk-QZAW5SFH.js → chunk-7NK42OIB.js} +2 -2
  25. package/dist/{chunk-NN5TF4OV.js → chunk-7SXTD7L6.js} +3 -3
  26. package/dist/{chunk-VVIRAGID.js → chunk-A4DAZO3U.js} +12 -9
  27. package/dist/{chunk-UXXLE6AH.js → chunk-AIH6M5J6.js} +6 -6
  28. package/dist/{chunk-A4UJP4IS.js → chunk-AMC2OGXF.js} +10 -10
  29. package/dist/{chunk-SSHS42QG.js → chunk-AN465MXC.js} +2 -2
  30. package/dist/{chunk-NPPUZ4SK.js → chunk-AOJJSGXE.js} +5 -5
  31. package/dist/{chunk-MEH4TJEX.js → chunk-APD52YJV.js} +8 -8
  32. package/dist/{chunk-QQXFYTLC.js → chunk-BR2VSKHI.js} +36 -19
  33. package/dist/{chunk-Q5CMQVWF.js → chunk-C3BWDEYN.js} +5 -5
  34. package/dist/{chunk-HO3RCNF6.js → chunk-CGLBK5Q4.js} +2 -2
  35. package/dist/{chunk-ADYKAKE3.js → chunk-CQ7Y3O67.js} +7 -4
  36. package/dist/{chunk-SCOHNGPG.js → chunk-CQOC2MD6.js} +21 -9
  37. package/dist/{chunk-A2PTRSAO.js → chunk-CXI6X54X.js} +3 -3
  38. package/dist/{chunk-PCVXXPYU.js → chunk-CY5KE2P5.js} +57 -7
  39. package/dist/{chunk-COVYNAKJ.js → chunk-D3WTEBGT.js} +2 -2
  40. package/dist/{chunk-JR7Q6GHE.js → chunk-D5FANMSG.js} +3 -3
  41. package/dist/{chunk-MSWIBF6J.js → chunk-D64FRGKU.js} +3 -3
  42. package/dist/{chunk-5K5XBEXT.js → chunk-DIKIHU52.js} +4 -4
  43. package/dist/{chunk-EMSOFHEN.js → chunk-DNSEG6P2.js} +2 -2
  44. package/dist/{chunk-UJRTPOHH.js → chunk-DUI5SMFX.js} +2 -2
  45. package/dist/{chunk-O4CZDTQA.js → chunk-EEKGMS63.js} +4 -4
  46. package/dist/{chunk-2HX6ZGY7.js → chunk-ES3MUYRX.js} +5 -5
  47. package/dist/{chunk-GRXPFBYC.js → chunk-ES66QH6J.js} +2 -2
  48. package/dist/{chunk-ZKPPI6BF.js → chunk-EXNKNJ65.js} +2 -2
  49. package/dist/{chunk-YXKNXIWA.js → chunk-FCA2UGJT.js} +5 -5
  50. package/dist/{chunk-VMWSZCAK.js → chunk-FERE46TP.js} +5 -5
  51. package/dist/{chunk-B4XS2AF2.js → chunk-FWVKPEG3.js} +3 -3
  52. package/dist/{chunk-RZWIPDZ2.js → chunk-FXVPSTDT.js} +6 -6
  53. package/dist/{chunk-KK3L5NVK.js → chunk-FZECLCCU.js} +4 -4
  54. package/dist/{chunk-XKKH2DPG.js → chunk-GDGOVO2I.js} +60 -41
  55. package/dist/{chunk-ZXNHHO6D.js → chunk-GG7TK3IA.js} +5 -5
  56. package/dist/{chunk-GTO5VCYG.js → chunk-GUVVQW3Y.js} +5 -5
  57. package/dist/{chunk-DS4MDEQ7.js → chunk-HE57UQHL.js} +3 -3
  58. package/dist/{chunk-ZP265ICS.js → chunk-HIMDUQT7.js} +7 -7
  59. package/dist/{chunk-JGCEFKZP.js → chunk-HKKPUUNK.js} +10 -10
  60. package/dist/{chunk-FGAMFJNJ.js → chunk-HODUM6LY.js} +7 -7
  61. package/dist/{chunk-5D5VHDJM.js → chunk-HOPTF3ZP.js} +9 -9
  62. package/dist/{chunk-LCRPGGGS.js → chunk-HPJITTF7.js} +11 -8
  63. package/dist/{chunk-BEOAKGNA.js → chunk-I55PVEIX.js} +2 -2
  64. package/dist/{chunk-EFUQENO5.js → chunk-IMXG673Y.js} +3 -3
  65. package/dist/{chunk-KC3WBBI7.js → chunk-JE3SMHRZ.js} +6 -6
  66. package/dist/{chunk-5H5GWWA4.js → chunk-JXFB3APA.js} +11 -11
  67. package/dist/{chunk-HX7QNHC6.js → chunk-KF575IXC.js} +4 -4
  68. package/dist/{chunk-LW7STMYZ.js → chunk-KIGV66SP.js} +3 -3
  69. package/dist/{chunk-2R6HG6D5.js → chunk-KSPCR75O.js} +7 -7
  70. package/dist/{chunk-JTSMEYIZ.js → chunk-L43KTQTW.js} +5 -2
  71. package/dist/{chunk-ZWVKTWK6.js → chunk-LV5BFA24.js} +6 -6
  72. package/dist/{chunk-HES4K6DV.js → chunk-MD2KWAXJ.js} +4 -4
  73. package/dist/{chunk-ETYF5QZR.js → chunk-MGLJA5TK.js} +3 -3
  74. package/dist/{chunk-L2DIXZUT.js → chunk-N2KO445N.js} +15 -12
  75. package/dist/{chunk-3BZJ5KD5.js → chunk-NFAHDPCG.js} +4 -4
  76. package/dist/{chunk-S52F62GW.js → chunk-NHZAYL2X.js} +7 -7
  77. package/dist/{chunk-PIXZTCKH.js → chunk-NVQXIDLE.js} +3 -3
  78. package/dist/chunk-NZ5QVASG.js +20 -0
  79. package/dist/{chunk-PC4YLEKA.js → chunk-OHBIN74X.js} +4 -4
  80. package/dist/{chunk-4W2PE66Q.js → chunk-OLMWTJVU.js} +11 -1
  81. package/dist/{chunk-6NJWBMJV.js → chunk-OWLGERJL.js} +7 -7
  82. package/dist/{chunk-2ZJXKJSI.js → chunk-P6XFQVYY.js} +8 -8
  83. package/dist/{chunk-LKGQ46P4.js → chunk-PECYPUJJ.js} +5 -5
  84. package/dist/{chunk-MNS2ENXF.js → chunk-PFG3EVRD.js} +4 -4
  85. package/dist/{chunk-ASPS5O6F.js → chunk-QDOYT6UW.js} +5 -5
  86. package/dist/{chunk-HLGOG44K.js → chunk-QWUYFUNO.js} +3 -3
  87. package/dist/{chunk-IWG2ECAO.js → chunk-R7ECJQTB.js} +10 -8
  88. package/dist/{chunk-UBQU2BY6.js → chunk-RBIX3HQQ.js} +4 -4
  89. package/dist/{chunk-F5ZNUMSY.js → chunk-RK3Y4WMV.js} +14 -11
  90. package/dist/{chunk-HUTP35XT.js → chunk-RQGNELB3.js} +5 -5
  91. package/dist/{chunk-WF64MW5G.js → chunk-RRX4Z4TH.js} +2 -2
  92. package/dist/{chunk-PSIDVCBA.js → chunk-RV2N7COG.js} +4 -4
  93. package/dist/{chunk-X3X4LZDC.js → chunk-S6QDCFEU.js} +2 -2
  94. package/dist/{chunk-Q5IHQ4NW.js → chunk-SCJ7CAJF.js} +2 -2
  95. package/dist/{chunk-3B2GXZCX.js → chunk-SK7PCW4F.js} +2 -2
  96. package/dist/{chunk-IALX52TR.js → chunk-SOBGK35Z.js} +4 -4
  97. package/dist/{chunk-4R5KIPNX.js → chunk-ST3ZNEUQ.js} +3 -3
  98. package/dist/{chunk-3IUHKMJI.js → chunk-U2BKSEKU.js} +2 -2
  99. package/dist/{chunk-ZGIBV36U.js → chunk-U7ZQTUZT.js} +6 -6
  100. package/dist/{chunk-VXTUWXFB.js → chunk-ULONXAOD.js} +8 -8
  101. package/dist/{chunk-NL7FUIVD.js → chunk-ULR3BVNH.js} +8 -8
  102. package/dist/{chunk-YP2T5YUP.js → chunk-USFZQPJ2.js} +5 -5
  103. package/dist/{chunk-M53MDBIW.js → chunk-UZ6L5VQJ.js} +4 -4
  104. package/dist/{chunk-HGKOVKAX.js → chunk-VKN7YW4Q.js} +10 -7
  105. package/dist/{chunk-NYOOPQFD.js → chunk-VSFAJUEF.js} +4 -4
  106. package/dist/{chunk-W4TSD3IP.js → chunk-VU3DOZ6C.js} +3 -3
  107. package/dist/{chunk-IIUYKQ5J.js → chunk-VYEQPPS6.js} +7 -7
  108. package/dist/{chunk-IG6J7JWH.js → chunk-W2I2EXSC.js} +15 -12
  109. package/dist/{chunk-WB3NA3JJ.js → chunk-W4EKQ2P6.js} +2 -2
  110. package/dist/{chunk-3BFXELBL.js → chunk-WFX6AUQO.js} +5 -5
  111. package/dist/{chunk-PV7ND5WL.js → chunk-WK3UFCZC.js} +9 -9
  112. package/dist/{chunk-IF4KYSJZ.js → chunk-WOMXS5R7.js} +20 -5
  113. package/dist/chunk-WTTIODDV.js +10 -0
  114. package/dist/{chunk-RSBH2C7O.js → chunk-X32RDWT5.js} +5 -5
  115. package/dist/{chunk-AKE6C2D7.js → chunk-XN4ZSACM.js} +4 -4
  116. package/dist/{chunk-RYNCWA5X.js → chunk-Y2L2LET6.js} +5 -5
  117. package/dist/{chunk-PKUWYPI5.js → chunk-YG5KQ55U.js} +9 -9
  118. package/dist/{chunk-4MZCJV4M.js → chunk-YH62K5D4.js} +15 -12
  119. package/dist/{chunk-3FUTFYSP.js → chunk-YJUF2N3C.js} +11 -11
  120. package/dist/{chunk-UES4P7FN.js → chunk-YM2ZQIVG.js} +4 -4
  121. package/dist/{chunk-AU75JHSR.js → chunk-YNAHUNMA.js} +3 -3
  122. package/dist/{chunk-Y4BBGFKY.js → chunk-YWPWRR7W.js} +2 -2
  123. package/dist/{chunk-RKBCKCSF.js → chunk-ZMMYCERO.js} +2 -2
  124. package/dist/cli.cjs +153 -150
  125. package/dist/completion-registry.js +6 -6
  126. package/dist/dgmo-router-GSWUPLP2.js +88 -0
  127. package/dist/dimensions-PLECMFTR.js +22 -0
  128. package/dist/element.js +132 -130
  129. package/dist/element.mjs +1178 -626
  130. package/dist/flowchart-parser-DA3V2SLH.js +21 -0
  131. package/dist/{flowchart-renderer-FFEQFQEU.js → flowchart-renderer-UQVXOUW4.js} +13 -12
  132. package/dist/index.js +61 -56
  133. package/dist/{layout-UR7CYAHL.js → layout-2BJDECLZ.js} +5 -8
  134. package/dist/{layout-NF4EWFLT.js → layout-3XFPPFXI.js} +4 -4
  135. package/dist/layout-A5UVXINF.js +15 -0
  136. package/dist/layout-HIK4ZJFQ.js +15 -0
  137. package/dist/{layout-CB3XWCOI.js → layout-NX37NSRY.js} +3 -3
  138. package/dist/layout-OHAIIXBC.js +10 -0
  139. package/dist/{layout-CRLTSFYQ.js → layout-QRVYYYZ3.js} +6 -6
  140. package/dist/{layout-LGXOKUCD.js → layout-SNIEAZ2I.js} +8 -8
  141. package/dist/{layout-SP7HJWKA.js → layout-UFZQI6SX.js} +4 -4
  142. package/dist/{layout-3ZZBKUQC.js → layout-UXMNKETK.js} +7 -7
  143. package/dist/layout-WDXNSQQF.js +15 -0
  144. package/dist/{layout-search-U2H4ORFJ.js → layout-search-I4VNIRGT.js} +315 -33
  145. package/dist/{legend-constants-B77VKB3R.js → legend-constants-QQU3QYBF.js} +5 -5
  146. package/dist/{palettes-FGTNFARW.js → palettes-WO3VA6NU.js} +4 -4
  147. package/dist/parser-4TX6U4ZU.js +11 -0
  148. package/dist/{parser-DYYTPLBL.js → parser-4ZIJDGPG.js} +6 -6
  149. package/dist/parser-5UZWYSIV.js +16 -0
  150. package/dist/parser-6CM27UPA.js +14 -0
  151. package/dist/parser-73YUU35J.js +11 -0
  152. package/dist/parser-A6M25MLK.js +11 -0
  153. package/dist/parser-AYZTKZC3.js +11 -0
  154. package/dist/parser-CCAUZLYI.js +15 -0
  155. package/dist/parser-D7YZX3CH.js +12 -0
  156. package/dist/parser-DQ2DGDYO.js +11 -0
  157. package/dist/parser-GGCDY65M.js +14 -0
  158. package/dist/parser-HMQZPPOK.js +19 -0
  159. package/dist/parser-IPBEW2DG.js +13 -0
  160. package/dist/{parser-TO7IENWL.js → parser-JWAGGYLL.js} +7 -7
  161. package/dist/parser-KTVDCWHG.js +13 -0
  162. package/dist/{parser-PVBUAVRR.js → parser-LNEAHGXF.js} +7 -7
  163. package/dist/parser-LQDEU22S.js +15 -0
  164. package/dist/{parser-2LF33IS2.js → parser-MH62NYKM.js} +6 -6
  165. package/dist/parser-O5XCVGZG.js +11 -0
  166. package/dist/parser-OPOGIKFR.js +17 -0
  167. package/dist/parser-PEBXIOPX.js +12 -0
  168. package/dist/parser-PQXN6SBB.js +18 -0
  169. package/dist/parser-Q3KNFXQR.js +12 -0
  170. package/dist/parser-Q62VR2UJ.js +20 -0
  171. package/dist/parser-QEWSTNEJ.js +15 -0
  172. package/dist/{parser-SUV52NQW.js → parser-QL2LBPFE.js} +7 -7
  173. package/dist/{parser-BMOTF72G.js → parser-QN3GJJ3J.js} +5 -5
  174. package/dist/parser-RBNOWHGM.js +15 -0
  175. package/dist/parser-SJ7ECFAP.js +13 -0
  176. package/dist/parser-VVTCMQWY.js +16 -0
  177. package/dist/parser-WT3DSNPQ.js +13 -0
  178. package/dist/parser-XWNSCDY6.js +13 -0
  179. package/dist/{renderer-TXTTV4HA.js → renderer-2NU7M5PN.js} +14 -13
  180. package/dist/renderer-3IETIUZB.js +30 -0
  181. package/dist/renderer-4VLQKKTV.js +39 -0
  182. package/dist/{renderer-UZIU4AHK.js → renderer-52S6JM5R.js} +12 -12
  183. package/dist/renderer-53FU55KK.js +19 -0
  184. package/dist/renderer-5CU6GYF2.js +27 -0
  185. package/dist/{renderer-DW6TEBLA.js → renderer-5G3PORFD.js} +13 -13
  186. package/dist/renderer-CB2DOQ2O.js +25 -0
  187. package/dist/{renderer-RDBUXW7P.js → renderer-CL4SAUA5.js} +8 -8
  188. package/dist/{renderer-IRAFJNTK.js → renderer-CRAIC4ER.js} +12 -11
  189. package/dist/renderer-DZ5N6BHW.js +26 -0
  190. package/dist/renderer-FRBPMKPP.js +25 -0
  191. package/dist/renderer-HGWKAXS6.js +16 -0
  192. package/dist/renderer-I5MAFUKX.js +26 -0
  193. package/dist/{renderer-K7XLVPH5.js → renderer-IWNHBIZ6.js} +5 -5
  194. package/dist/renderer-J5MMVCGN.js +29 -0
  195. package/dist/renderer-J5TL5ZX4.js +39 -0
  196. package/dist/renderer-JNC6VJMN.js +24 -0
  197. package/dist/{renderer-CENXCMWG.js → renderer-KUIZNLAQ.js} +6 -6
  198. package/dist/renderer-M6AFKVLS.js +21 -0
  199. package/dist/renderer-MLDGFZDW.js +23 -0
  200. package/dist/{renderer-3PWLOJPD.js → renderer-O4ECS2BI.js} +13 -12
  201. package/dist/{renderer-IO4KCFVL.js → renderer-OZIPP7VF.js} +14 -13
  202. package/dist/{renderer-TKTM2SL4.js → renderer-P7O6OUYC.js} +13 -13
  203. package/dist/renderer-Q3A7572V.js +25 -0
  204. package/dist/renderer-QRX7Q2YN.js +22 -0
  205. package/dist/{renderer-QZESC66H.js → renderer-RJT3MOUU.js} +5 -5
  206. package/dist/{renderer-5EMHIQL5.js → renderer-SYT4L7GE.js} +6 -6
  207. package/dist/{renderer-FXK6ZL3P.js → renderer-TOKGYFTG.js} +6 -6
  208. package/dist/renderer-WWC5VGHH.js +27 -0
  209. package/dist/{renderer-HTDS4FED.js → renderer-YVCD55ZX.js} +15 -14
  210. package/dist/renderer-YWYX6WAI.js +16 -0
  211. package/dist/renderer-radial-QG644QYY.js +21 -0
  212. package/dist/{resolver-ZSFQQRTH.js → resolver-W3WKLWDP.js} +3 -3
  213. package/dist/state-parser-NQGVYSM3.js +19 -0
  214. package/dist/state-renderer-NKV5B3KH.js +40 -0
  215. package/docs/language-reference.md +9 -1
  216. package/package.json +2 -2
  217. package/dist/charts-d3-KZ6V4OP2.js +0 -28
  218. package/dist/dgmo-router-T4HGLIGA.js +0 -88
  219. package/dist/dimensions-3JINHSYK.js +0 -22
  220. package/dist/flowchart-parser-M7KKTLX7.js +0 -21
  221. package/dist/layout-AUKTWGYL.js +0 -15
  222. package/dist/layout-FNZDJGKF.js +0 -19
  223. package/dist/layout-GHWRJKZQ.js +0 -15
  224. package/dist/layout-UTMEVFHN.js +0 -15
  225. package/dist/parser-2AXPSKWB.js +0 -14
  226. package/dist/parser-2AZ2KQTO.js +0 -12
  227. package/dist/parser-3QJ2Z4H4.js +0 -11
  228. package/dist/parser-5GCQFSTQ.js +0 -13
  229. package/dist/parser-62OHBRU5.js +0 -11
  230. package/dist/parser-7LYJFZCP.js +0 -14
  231. package/dist/parser-CIFLYZYP.js +0 -15
  232. package/dist/parser-D2UL2G5U.js +0 -11
  233. package/dist/parser-DM2APTKB.js +0 -11
  234. package/dist/parser-GOUGUTPU.js +0 -12
  235. package/dist/parser-HGVUVD6J.js +0 -11
  236. package/dist/parser-IEJD3CZB.js +0 -11
  237. package/dist/parser-JBEWNLAV.js +0 -20
  238. package/dist/parser-JMXPHNZD.js +0 -12
  239. package/dist/parser-JMXSQY3K.js +0 -13
  240. package/dist/parser-LUXS7J32.js +0 -16
  241. package/dist/parser-M5BUHULF.js +0 -15
  242. package/dist/parser-MESRHUS4.js +0 -17
  243. package/dist/parser-OOYNI2UT.js +0 -15
  244. package/dist/parser-QKRBSQLJ.js +0 -18
  245. package/dist/parser-S6NWSIJO.js +0 -16
  246. package/dist/parser-SFEK6Q7Z.js +0 -19
  247. package/dist/parser-SZHGLOOZ.js +0 -13
  248. package/dist/parser-TVAMC7CQ.js +0 -13
  249. package/dist/parser-VAW46R57.js +0 -13
  250. package/dist/parser-XDSPOXSE.js +0 -15
  251. package/dist/renderer-5PODNLYP.js +0 -16
  252. package/dist/renderer-AQJIQ2XU.js +0 -25
  253. package/dist/renderer-BEW3AYFT.js +0 -28
  254. package/dist/renderer-C3UYAXA6.js +0 -26
  255. package/dist/renderer-CXM3ARYN.js +0 -23
  256. package/dist/renderer-FE5M6SEZ.js +0 -25
  257. package/dist/renderer-G5ESLCJB.js +0 -29
  258. package/dist/renderer-MFTTFW32.js +0 -38
  259. package/dist/renderer-MPXI4FVL.js +0 -24
  260. package/dist/renderer-NVBEMQ6L.js +0 -19
  261. package/dist/renderer-OOGDCR6K.js +0 -16
  262. package/dist/renderer-Q5P72O4A.js +0 -26
  263. package/dist/renderer-S4XB3JR2.js +0 -27
  264. package/dist/renderer-SIWEEWJ5.js +0 -26
  265. package/dist/renderer-V72VJIGG.js +0 -38
  266. package/dist/renderer-VEGOEZOI.js +0 -25
  267. package/dist/renderer-W6I6T2TA.js +0 -21
  268. package/dist/renderer-WSHJRR2T.js +0 -22
  269. package/dist/renderer-radial-AG75PBYD.js +0 -21
  270. package/dist/state-parser-KIPZGIB4.js +0 -19
  271. package/dist/state-renderer-U6OSJG52.js +0 -39
package/dist/element.mjs CHANGED
@@ -104,7 +104,7 @@ function nameMergedMessage(args) {
104
104
  function emptyMetadataValueMessage(key) {
105
105
  return `Metadata key '${key}:' has no value \u2014 the pair is dropped. Provide a value or remove the key.`;
106
106
  }
107
- var NAME_DIAGNOSTIC_CODES, METADATA_DIAGNOSTIC_CODES, TITLE_DIRECTIVE_DX;
107
+ var NAME_DIAGNOSTIC_CODES, METADATA_DIAGNOSTIC_CODES, NEGATIVE_VALUE_DX, TITLE_DIRECTIVE_DX;
108
108
  var init_diagnostics = __esm({
109
109
  "src/diagnostics.ts"() {
110
110
  "use strict";
@@ -135,6 +135,15 @@ var init_diagnostics = __esm({
135
135
  */
136
136
  EMPTY_METADATA_VALUE: "W_EMPTY_METADATA_VALUE"
137
137
  };
138
+ NEGATIVE_VALUE_DX = {
139
+ code: "E_VALUE_NEGATIVE",
140
+ severity: "error",
141
+ chartType: null,
142
+ title: "Negative value on a magnitude channel",
143
+ message: (p) => `Negative value ${p.value ?? -300} on "${p.label ?? "Refunds"}" \u2014 ${p.channel ?? "this chart's values"} encode magnitude and can't be negative.`,
144
+ hint: 'Restate the data as positive magnitudes (e.g. "decline %"). If direction matters, use a bar chart \u2014 bars support negative values.',
145
+ example: "pie Budget\nRent 1200\nRefunds -300"
146
+ };
138
147
  TITLE_DIRECTIVE_DX = {
139
148
  code: "E_TITLE_DIRECTIVE",
140
149
  severity: "error",
@@ -2708,6 +2717,16 @@ function parseVisualizationFull(content, palette) {
2708
2717
  palette
2709
2718
  ) ?? null : null;
2710
2719
  const arcValue = linkMatch[4] ? parseFloat(normalizeNumericToken(linkMatch[4]) ?? linkMatch[4]) : 1;
2720
+ if (arcValue < 0) {
2721
+ result.diagnostics.push(
2722
+ emit(NEGATIVE_VALUE_DX, lineNumber, {
2723
+ value: arcValue,
2724
+ label: `${source} -> ${target}`,
2725
+ channel: "arc link weights"
2726
+ })
2727
+ );
2728
+ continue;
2729
+ }
2711
2730
  result.links.push({
2712
2731
  source,
2713
2732
  target,
@@ -3327,6 +3346,14 @@ function parseVisualizationFull(content, palette) {
3327
3346
  weight: maybeWeight,
3328
3347
  lineNumber
3329
3348
  });
3349
+ } else if (lastSpace >= 0 && !isNaN(maybeWeight) && maybeWeight < 0) {
3350
+ result.diagnostics.push(
3351
+ emit(NEGATIVE_VALUE_DX, lineNumber, {
3352
+ value: maybeWeight,
3353
+ label: line11.substring(0, lastSpace).trim(),
3354
+ channel: "wordcloud weights"
3355
+ })
3356
+ );
3330
3357
  } else {
3331
3358
  freeformLines.push(line11);
3332
3359
  }
@@ -3639,6 +3666,27 @@ var init_parse = __esm({
3639
3666
  }
3640
3667
  });
3641
3668
 
3669
+ // src/utils/svg-serialize.ts
3670
+ function escapeAttributeAngleBrackets(svg) {
3671
+ return svg.replace(
3672
+ // ` name="value"` / ` xlink:href="value"` — attribute names in SVG may carry
3673
+ // a namespace prefix, a dot, or a dash.
3674
+ /(\s[\w:.-]+=")([^"]*)"/g,
3675
+ (match, prefix, value) => {
3676
+ if (!value.includes("<") && !value.includes(">")) return match;
3677
+ return `${prefix}${value.replace(/</g, "&lt;").replace(/>/g, "&gt;")}"`;
3678
+ }
3679
+ );
3680
+ }
3681
+ function serializeSvg(svgEl) {
3682
+ return escapeAttributeAngleBrackets(svgEl.outerHTML);
3683
+ }
3684
+ var init_svg_serialize = __esm({
3685
+ "src/utils/svg-serialize.ts"() {
3686
+ "use strict";
3687
+ }
3688
+ });
3689
+
3642
3690
  // src/fonts.ts
3643
3691
  var FONT_FAMILY;
3644
3692
  var init_fonts = __esm({
@@ -4842,15 +4890,15 @@ function showTooltip(tooltip, html, event) {
4842
4890
  tooltip.style.display = "block";
4843
4891
  const container = tooltip.parentElement;
4844
4892
  const rect2 = container.getBoundingClientRect();
4845
- let left = event.clientX - rect2.left + 12;
4846
- let top = event.clientY - rect2.top - 28;
4893
+ let left2 = event.clientX - rect2.left + 12;
4894
+ let top2 = event.clientY - rect2.top - 28;
4847
4895
  const tipW = tooltip.offsetWidth;
4848
4896
  const tipH = tooltip.offsetHeight;
4849
- if (left + tipW > rect2.width) left = rect2.width - tipW - 4;
4850
- if (top < 0) top = event.clientY - rect2.top + 16;
4851
- if (top + tipH > rect2.height) top = rect2.height - tipH - 4;
4852
- tooltip.style.left = `${left}px`;
4853
- tooltip.style.top = `${top}px`;
4897
+ if (left2 + tipW > rect2.width) left2 = rect2.width - tipW - 4;
4898
+ if (top2 < 0) top2 = event.clientY - rect2.top + 16;
4899
+ if (top2 + tipH > rect2.height) top2 = rect2.height - tipH - 4;
4900
+ tooltip.style.left = `${left2}px`;
4901
+ tooltip.style.top = `${top2}px`;
4854
4902
  }
4855
4903
  function hideTooltip(tooltip) {
4856
4904
  tooltip.style.display = "none";
@@ -4880,7 +4928,7 @@ function finalizeSvgExport(container, theme, palette) {
4880
4928
  svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
4881
4929
  svgEl.style.fontFamily = FONT_FAMILY;
4882
4930
  svgEl.querySelectorAll("[data-export-ignore]").forEach((el) => el.remove());
4883
- const svgHtml = svgEl.outerHTML;
4931
+ const svgHtml = serializeSvg(svgEl);
4884
4932
  document.body.removeChild(container);
4885
4933
  return svgHtml;
4886
4934
  }
@@ -4888,6 +4936,7 @@ var EXPORT_WIDTH, EXPORT_HEIGHT;
4888
4936
  var init_d3_helpers = __esm({
4889
4937
  "src/utils/d3-helpers.ts"() {
4890
4938
  "use strict";
4939
+ init_svg_serialize();
4891
4940
  init_fonts();
4892
4941
  init_palettes();
4893
4942
  init_title_constants();
@@ -5932,13 +5981,13 @@ function getMaxLegendReservedHeight(config, containerWidth) {
5932
5981
  }
5933
5982
  function getLegendExtent(config, state, containerWidth) {
5934
5983
  const layout = computeLegendLayout(config, state, containerWidth);
5935
- let left = Infinity;
5936
- let right = 0;
5937
- let bottom = 0;
5984
+ let left2 = Infinity;
5985
+ let right2 = 0;
5986
+ let bottom2 = 0;
5938
5987
  const track = (x, y, w, h) => {
5939
- left = Math.min(left, x);
5940
- right = Math.max(right, x + w);
5941
- bottom = Math.max(bottom, y + h);
5988
+ left2 = Math.min(left2, x);
5989
+ right2 = Math.max(right2, x + w);
5990
+ bottom2 = Math.max(bottom2, y + h);
5942
5991
  };
5943
5992
  if (layout.activeCapsule) {
5944
5993
  const c = layout.activeCapsule;
@@ -5946,8 +5995,8 @@ function getLegendExtent(config, state, containerWidth) {
5946
5995
  }
5947
5996
  for (const pill of layout.pills) track(pill.x, pill.y, pill.width, pill.height);
5948
5997
  return {
5949
- width: right - (left === Infinity ? 0 : left),
5950
- height: bottom || LEGEND_HEIGHT
5998
+ width: right2 - (left2 === Infinity ? 0 : left2),
5999
+ height: bottom2 || LEGEND_HEIGHT
5951
6000
  };
5952
6001
  }
5953
6002
  var CONTROL_PILL_PAD, CONTROL_FONT_SIZE, CONTROL_ICON_GAP, CONTROL_GAP, RAMP_LEGEND_W, RAMP_LEGEND_H, RAMP_LABEL_GAP;
@@ -8658,9 +8707,9 @@ function parseSequenceDgmo(content, palette) {
8658
8707
  const blockStack = [];
8659
8708
  const currentContainer = () => {
8660
8709
  if (blockStack.length === 0) return result.elements;
8661
- const top = blockStack[blockStack.length - 1];
8662
- if (top.activeElseIfBranch) return top.activeElseIfBranch.children;
8663
- return top.inElse ? top.block.elseChildren : top.block.children;
8710
+ const top2 = blockStack[blockStack.length - 1];
8711
+ if (top2.activeElseIfBranch) return top2.activeElseIfBranch.children;
8712
+ return top2.inElse ? top2.block.elseChildren : top2.block.children;
8664
8713
  };
8665
8714
  let lastMsgFrom = null;
8666
8715
  for (let i = 0; i < lines.length; i++) {
@@ -8798,8 +8847,8 @@ function parseSequenceDgmo(content, palette) {
8798
8847
  if (sectionMatch) {
8799
8848
  const sectionIndent = measureIndent(raw);
8800
8849
  while (blockStack.length > 0) {
8801
- const top = blockStack[blockStack.length - 1];
8802
- if (sectionIndent > top.indent) break;
8850
+ const top2 = blockStack[blockStack.length - 1];
8851
+ if (sectionIndent > top2.indent) break;
8803
8852
  blockStack.pop();
8804
8853
  }
8805
8854
  const labelRaw = sectionMatch[1].trim();
@@ -8999,9 +9048,9 @@ function parseSequenceDgmo(content, palette) {
8999
9048
  }
9000
9049
  const indent = measureIndent(raw);
9001
9050
  while (blockStack.length > 0) {
9002
- const top = blockStack[blockStack.length - 1];
9003
- if (indent > top.indent) break;
9004
- if (indent === top.indent && (top.block.type === "if" || top.block.type === "parallel")) {
9051
+ const top2 = blockStack[blockStack.length - 1];
9052
+ if (indent > top2.indent) break;
9053
+ if (indent === top2.indent && (top2.block.type === "if" || top2.block.type === "parallel")) {
9005
9054
  const lower = trimmed.toLowerCase();
9006
9055
  if (lower === "else" || lower.startsWith("else if ")) break;
9007
9056
  }
@@ -9158,26 +9207,26 @@ function parseSequenceDgmo(content, palette) {
9158
9207
  if (elseIfMatch) {
9159
9208
  if (blockStack.length > 0 && // In-bounds by the length check above.
9160
9209
  blockStack[blockStack.length - 1].indent === indent) {
9161
- const top = blockStack[blockStack.length - 1];
9162
- if (top.block.type === "parallel") {
9210
+ const top2 = blockStack[blockStack.length - 1];
9211
+ if (top2.block.type === "parallel") {
9163
9212
  pushError(
9164
9213
  lineNumber,
9165
9214
  "parallel blocks don't support else if \u2014 list all concurrent messages directly inside the block"
9166
9215
  );
9167
9216
  continue;
9168
9217
  }
9169
- if (top.block.type === "if") {
9218
+ if (top2.block.type === "if") {
9170
9219
  const branch = {
9171
9220
  // Capture group 1 guaranteed present after successful match.
9172
9221
  label: elseIfMatch[1].trim(),
9173
9222
  children: [],
9174
9223
  lineNumber
9175
9224
  };
9176
- if (!top.block.elseIfBranches) top.block.elseIfBranches = [];
9177
- const branches = top.block.elseIfBranches;
9225
+ if (!top2.block.elseIfBranches) top2.block.elseIfBranches = [];
9226
+ const branches = top2.block.elseIfBranches;
9178
9227
  branches.push(branch);
9179
- top.activeElseIfBranch = branch;
9180
- top.inElse = false;
9228
+ top2.activeElseIfBranch = branch;
9229
+ top2.inElse = false;
9181
9230
  }
9182
9231
  }
9183
9232
  continue;
@@ -9185,18 +9234,18 @@ function parseSequenceDgmo(content, palette) {
9185
9234
  if (trimmed.toLowerCase() === "else") {
9186
9235
  if (blockStack.length > 0 && // In-bounds by the length check above.
9187
9236
  blockStack[blockStack.length - 1].indent === indent) {
9188
- const top = blockStack[blockStack.length - 1];
9189
- if (top.block.type === "parallel") {
9237
+ const top2 = blockStack[blockStack.length - 1];
9238
+ if (top2.block.type === "parallel") {
9190
9239
  pushError(
9191
9240
  lineNumber,
9192
9241
  "parallel blocks don't support else \u2014 list all concurrent messages directly inside the block"
9193
9242
  );
9194
9243
  continue;
9195
9244
  }
9196
- if (top.block.type === "if") {
9197
- top.inElse = true;
9198
- delete top.activeElseIfBranch;
9199
- top.block.elseLineNumber = lineNumber;
9245
+ if (top2.block.type === "if") {
9246
+ top2.inElse = true;
9247
+ delete top2.activeElseIfBranch;
9248
+ top2.block.elseLineNumber = lineNumber;
9200
9249
  }
9201
9250
  }
9202
9251
  continue;
@@ -9964,25 +10013,25 @@ function placeNotes(obstacles, requests, direction) {
9964
10013
  const rectFor = (side) => {
9965
10014
  switch (side) {
9966
10015
  case "right": {
9967
- const left = nodeRight + NOTE_GAP;
9968
- const top = cy - noteH / 2;
9969
- return { left, top, right: left + noteW, bottom: top + noteH };
10016
+ const left2 = nodeRight + NOTE_GAP;
10017
+ const top2 = cy - noteH / 2;
10018
+ return { left: left2, top: top2, right: left2 + noteW, bottom: top2 + noteH };
9970
10019
  }
9971
10020
  case "left": {
9972
- const right = nodeLeft - NOTE_GAP;
9973
- const top = cy - noteH / 2;
9974
- return { left: right - noteW, top, right, bottom: top + noteH };
10021
+ const right2 = nodeLeft - NOTE_GAP;
10022
+ const top2 = cy - noteH / 2;
10023
+ return { left: right2 - noteW, top: top2, right: right2, bottom: top2 + noteH };
9975
10024
  }
9976
10025
  case "below": {
9977
- const left = cx - noteW / 2;
9978
- const top = nodeBottom + NOTE_GAP;
9979
- return { left, top, right: left + noteW, bottom: top + noteH };
10026
+ const left2 = cx - noteW / 2;
10027
+ const top2 = nodeBottom + NOTE_GAP;
10028
+ return { left: left2, top: top2, right: left2 + noteW, bottom: top2 + noteH };
9980
10029
  }
9981
10030
  case "above":
9982
10031
  default: {
9983
- const left = cx - noteW / 2;
9984
- const bottom = nodeTop - NOTE_GAP;
9985
- return { left, top: bottom - noteH, right: left + noteW, bottom };
10032
+ const left2 = cx - noteW / 2;
10033
+ const bottom2 = nodeTop - NOTE_GAP;
10034
+ return { left: left2, top: bottom2 - noteH, right: left2 + noteW, bottom: bottom2 };
9986
10035
  }
9987
10036
  }
9988
10037
  };
@@ -10006,17 +10055,17 @@ function placeNotes(obstacles, requests, direction) {
10006
10055
  );
10007
10056
  if (blockers.length === 0) break;
10008
10057
  if (axisIsY && outward > 0) {
10009
- const top = Math.max(...blockers.map((b) => b.bottom)) + NOTE_CLEAR;
10010
- rect2 = { ...rect2, top, bottom: top + noteH };
10058
+ const top2 = Math.max(...blockers.map((b) => b.bottom)) + NOTE_CLEAR;
10059
+ rect2 = { ...rect2, top: top2, bottom: top2 + noteH };
10011
10060
  } else if (axisIsY) {
10012
- const bottom = Math.min(...blockers.map((b) => b.top)) - NOTE_CLEAR;
10013
- rect2 = { ...rect2, bottom, top: bottom - noteH };
10061
+ const bottom2 = Math.min(...blockers.map((b) => b.top)) - NOTE_CLEAR;
10062
+ rect2 = { ...rect2, bottom: bottom2, top: bottom2 - noteH };
10014
10063
  } else if (outward > 0) {
10015
- const left = Math.max(...blockers.map((b) => b.right)) + NOTE_CLEAR;
10016
- rect2 = { ...rect2, left, right: left + noteW };
10064
+ const left2 = Math.max(...blockers.map((b) => b.right)) + NOTE_CLEAR;
10065
+ rect2 = { ...rect2, left: left2, right: left2 + noteW };
10017
10066
  } else {
10018
- const right = Math.min(...blockers.map((b) => b.left)) - NOTE_CLEAR;
10019
- rect2 = { ...rect2, right, left: right - noteW };
10067
+ const right2 = Math.min(...blockers.map((b) => b.left)) - NOTE_CLEAR;
10068
+ rect2 = { ...rect2, right: right2, left: right2 - noteW };
10020
10069
  }
10021
10070
  }
10022
10071
  chosen = { rect: rect2, side };
@@ -10356,8 +10405,8 @@ function parseFlowchart(content, palette) {
10356
10405
  function processContentLine(trimmed, lineNumber, indent) {
10357
10406
  contentStarted = true;
10358
10407
  while (indentStack.length > 0) {
10359
- const top = indentStack[indentStack.length - 1];
10360
- if (top.indent >= indent) {
10408
+ const top2 = indentStack[indentStack.length - 1];
10409
+ if (top2.indent >= indent) {
10361
10410
  indentStack.pop();
10362
10411
  } else {
10363
10412
  break;
@@ -10943,8 +10992,8 @@ function parseState(content, palette) {
10943
10992
  groupIndent = -1;
10944
10993
  }
10945
10994
  while (indentStack.length > 0) {
10946
- const top = indentStack[indentStack.length - 1];
10947
- if (top.indent >= indent) {
10995
+ const top2 = indentStack[indentStack.length - 1];
10996
+ if (top2.indent >= indent) {
10948
10997
  indentStack.pop();
10949
10998
  } else {
10950
10999
  break;
@@ -12325,8 +12374,8 @@ function parseNodeLabel(trimmed, _indent, lineNumber, _palette, counter, metaAli
12325
12374
  }
12326
12375
  function attachNode(node, indent, indentStack, result) {
12327
12376
  while (indentStack.length > 0) {
12328
- const top = indentStack[indentStack.length - 1];
12329
- if (top.indent < indent) break;
12377
+ const top2 = indentStack[indentStack.length - 1];
12378
+ if (top2.indent < indent) break;
12330
12379
  indentStack.pop();
12331
12380
  }
12332
12381
  if (indentStack.length > 0) {
@@ -12849,8 +12898,8 @@ function parseSitemapMetaTail(tail, metaAliasMap) {
12849
12898
  }
12850
12899
  function attachNode2(node, indent, indentStack, result) {
12851
12900
  while (indentStack.length > 0) {
12852
- const top = indentStack[indentStack.length - 1];
12853
- if (top.indent < indent) break;
12901
+ const top2 = indentStack[indentStack.length - 1];
12902
+ if (top2.indent < indent) break;
12854
12903
  indentStack.pop();
12855
12904
  }
12856
12905
  if (indentStack.length > 0) {
@@ -13530,8 +13579,8 @@ function parsePert(content, parseOpts = {}) {
13530
13579
  if (trimmed.startsWith("#") || trimmed.startsWith("//")) continue;
13531
13580
  const indent = measureIndent(rawLine);
13532
13581
  while (groupStack.length > 0) {
13533
- const top = groupStack[groupStack.length - 1];
13534
- if (indent <= top.indent) groupStack.pop();
13582
+ const top2 = groupStack[groupStack.length - 1];
13583
+ if (indent <= top2.indent) groupStack.pop();
13535
13584
  else break;
13536
13585
  }
13537
13586
  if (currentSourceIndent >= 0 && indent <= currentSourceIndent && !trimmed.startsWith("-")) {
@@ -14944,6 +14993,19 @@ function parseChart(content, palette) {
14944
14993
  lineNumber
14945
14994
  );
14946
14995
  const [first, ...rest] = dataValues.values;
14996
+ if (result.type === "pie" || result.type === "polar-area" || result.type === "radar") {
14997
+ const neg = dataValues.values.find((v) => v < 0);
14998
+ if (neg !== void 0) {
14999
+ result.diagnostics.push(
15000
+ emit(NEGATIVE_VALUE_DX, lineNumber, {
15001
+ value: neg,
15002
+ label: rawLabel,
15003
+ channel: CHANNEL_NAME[result.type]
15004
+ })
15005
+ );
15006
+ continue;
15007
+ }
15008
+ }
14947
15009
  result.data.push({
14948
15010
  label: rawLabel,
14949
15011
  // parseDataRowValues guarantees values.length >= 1.
@@ -15095,13 +15157,18 @@ function trailingNumerics(tokens, minIndex) {
15095
15157
  }
15096
15158
  return values;
15097
15159
  }
15098
- var VALID_TYPES, KNOWN_OPTIONS3, DEFAULT_HOLE, KNOWN_BOOLEANS2, KNOWN_FIRST_TOKENS;
15160
+ var CHANNEL_NAME, VALID_TYPES, KNOWN_OPTIONS3, DEFAULT_HOLE, KNOWN_BOOLEANS2, KNOWN_FIRST_TOKENS;
15099
15161
  var init_chart = __esm({
15100
15162
  "src/chart.ts"() {
15101
15163
  "use strict";
15102
15164
  init_colors();
15103
15165
  init_diagnostics();
15104
15166
  init_parsing();
15167
+ CHANNEL_NAME = {
15168
+ pie: "pie slices",
15169
+ "polar-area": "polar-area wedges",
15170
+ radar: "radar axis values"
15171
+ };
15105
15172
  VALID_TYPES = /* @__PURE__ */ new Set([
15106
15173
  "bar",
15107
15174
  "line",
@@ -15382,11 +15449,22 @@ function parseExtendedChartFull(content, palette) {
15382
15449
  result.diagnostics,
15383
15450
  palette
15384
15451
  ) : void 0;
15452
+ const linkValue = parseFloat(val);
15453
+ if (linkValue < 0) {
15454
+ result.diagnostics.push(
15455
+ emit(NEGATIVE_VALUE_DX, lineNumber, {
15456
+ value: linkValue,
15457
+ label: `${source} -> ${target}`,
15458
+ channel: "flow widths"
15459
+ })
15460
+ );
15461
+ continue;
15462
+ }
15385
15463
  if (!result.links) result.links = [];
15386
15464
  result.links.push({
15387
15465
  source,
15388
15466
  target,
15389
- value: parseFloat(val),
15467
+ value: linkValue,
15390
15468
  ...linkColor && { color: linkColor },
15391
15469
  directed: arrow === "->",
15392
15470
  lineNumber
@@ -15424,12 +15502,22 @@ function parseExtendedChartFull(content, palette) {
15424
15502
  if (!result.nodeColors) result.nodeColors = {};
15425
15503
  result.nodeColors[target] = targetColor;
15426
15504
  }
15505
+ const childValue = dataRow2.values[0];
15506
+ if (childValue < 0) {
15507
+ result.diagnostics.push(
15508
+ emit(NEGATIVE_VALUE_DX, lineNumber, {
15509
+ value: childValue,
15510
+ label: `${source} -> ${target}`,
15511
+ channel: "flow widths"
15512
+ })
15513
+ );
15514
+ continue;
15515
+ }
15427
15516
  if (!result.links) result.links = [];
15428
15517
  result.links.push({
15429
15518
  source,
15430
15519
  target,
15431
- // In-bounds by values.length === 1 guard above.
15432
- value: dataRow2.values[0],
15520
+ value: childValue,
15433
15521
  ...linkColor && { color: linkColor },
15434
15522
  lineNumber
15435
15523
  });
@@ -15677,6 +15765,16 @@ function parseExtendedChartFull(content, palette) {
15677
15765
  result.diagnostics,
15678
15766
  lineNumber
15679
15767
  );
15768
+ if (result.type === "funnel" && dataRow.values[0] < 0) {
15769
+ result.diagnostics.push(
15770
+ emit(NEGATIVE_VALUE_DX, lineNumber, {
15771
+ value: dataRow.values[0],
15772
+ label: rawLabel,
15773
+ channel: "funnel stage sizes"
15774
+ })
15775
+ );
15776
+ continue;
15777
+ }
15680
15778
  result.data.push({
15681
15779
  label: rawLabel,
15682
15780
  // In-bounds by values.length === 1 guard above.
@@ -16312,10 +16410,10 @@ function resolveFutureEvents(events) {
16312
16410
  e.futureSpan = [lo, hi];
16313
16411
  });
16314
16412
  } else if (lo === null && hi !== null) {
16315
- const left = hi - pad3;
16413
+ const left2 = hi - pad3;
16316
16414
  group.forEach((e, k) => {
16317
- e.dateValue = left + (hi - left) * (k + 1) / (g + 1);
16318
- e.futureSpan = [left, hi];
16415
+ e.dateValue = left2 + (hi - left2) * (k + 1) / (g + 1);
16416
+ e.futureSpan = [left2, hi];
16319
16417
  });
16320
16418
  } else {
16321
16419
  group.forEach((e, k) => {
@@ -17579,8 +17677,8 @@ function parseC4(content, palette) {
17579
17677
  const indent = measureIndent(line11);
17580
17678
  if (inDeployment) {
17581
17679
  while (deployStack.length > 0) {
17582
- const top = deployStack[deployStack.length - 1];
17583
- if (top.indent < indent) break;
17680
+ const top2 = deployStack[deployStack.length - 1];
17681
+ if (top2.indent < indent) break;
17584
17682
  deployStack.pop();
17585
17683
  }
17586
17684
  if (indent === 0 && (C4_IS_A_RE.test(trimmed) || ELEMENT_RE.test(trimmed))) {
@@ -17658,8 +17756,8 @@ function parseC4(content, palette) {
17658
17756
  continue;
17659
17757
  }
17660
17758
  while (stack.length > 0) {
17661
- const top = stack[stack.length - 1];
17662
- if (top.indent < indent) break;
17759
+ const top2 = stack[stack.length - 1];
17760
+ if (top2.indent < indent) break;
17663
17761
  stack.pop();
17664
17762
  }
17665
17763
  const containerMatch = trimmed.match(CONTAINER_RE3);
@@ -19435,11 +19533,11 @@ function parseGantt(content, palette) {
19435
19533
  let hadDeeperPop = false;
19436
19534
  let lastPoppedTaskRef = null;
19437
19535
  while (blockStack.length > 0) {
19438
- const top = blockStack[blockStack.length - 1];
19439
- if (indent <= top.indent) {
19440
- if (top.indent > indent) hadDeeperPop = true;
19441
- if (top.containerType === "task" && top.taskRef) {
19442
- lastPoppedTaskRef = top.taskRef;
19536
+ const top2 = blockStack[blockStack.length - 1];
19537
+ if (indent <= top2.indent) {
19538
+ if (top2.indent > indent) hadDeeperPop = true;
19539
+ if (top2.containerType === "task" && top2.taskRef) {
19540
+ lastPoppedTaskRef = top2.taskRef;
19443
19541
  }
19444
19542
  blockStack.pop();
19445
19543
  } else {
@@ -20612,6 +20710,19 @@ function parseMap(content, palette) {
20612
20710
  delete meta[k];
20613
20711
  }
20614
20712
  }
20713
+ if (own !== "heat" && meta[own] !== void 0) {
20714
+ const n = Number(meta[own]);
20715
+ if (Number.isFinite(n) && n < 0) {
20716
+ diagnostics.push(
20717
+ emit(NEGATIVE_VALUE_DX, line11, {
20718
+ value: n,
20719
+ label: `${own}: ${meta[own]}`,
20720
+ channel: own === "size" ? "marker sizes" : "edge widths"
20721
+ })
20722
+ );
20723
+ delete meta[own];
20724
+ }
20725
+ }
20615
20726
  }
20616
20727
  function handleDirective2(key, value, line11) {
20617
20728
  const d = result.directives;
@@ -23389,17 +23500,17 @@ function hasCycle(n, edges) {
23389
23500
  stack.push({ v: s, i: 0 });
23390
23501
  color[s] = 1;
23391
23502
  while (stack.length) {
23392
- const top = stack[stack.length - 1];
23393
- const nbrs = adj.get(top.v) ?? [];
23394
- if (top.i < nbrs.length) {
23395
- const w = nbrs[top.i++];
23503
+ const top2 = stack[stack.length - 1];
23504
+ const nbrs = adj.get(top2.v) ?? [];
23505
+ if (top2.i < nbrs.length) {
23506
+ const w = nbrs[top2.i++];
23396
23507
  if (color[w] === 1) return true;
23397
23508
  if (color[w] === 0) {
23398
23509
  color[w] = 1;
23399
23510
  stack.push({ v: w, i: 0 });
23400
23511
  }
23401
23512
  } else {
23402
- color[top.v] = 2;
23513
+ color[top2.v] = 2;
23403
23514
  stack.pop();
23404
23515
  }
23405
23516
  }
@@ -24191,8 +24302,8 @@ function parseNodeLine2(trimmed, lineNumber, _palette, counter, aliasMap, diagno
24191
24302
  }
24192
24303
  function attachNode3(node, indent, indentStack, result, nodesWithChildren) {
24193
24304
  while (indentStack.length > 0) {
24194
- const top = indentStack[indentStack.length - 1];
24195
- if (top.indent < indent) break;
24305
+ const top2 = indentStack[indentStack.length - 1];
24306
+ if (top2.indent < indent) break;
24196
24307
  indentStack.pop();
24197
24308
  }
24198
24309
  if (indentStack.length > 0) {
@@ -26638,8 +26749,8 @@ function parseNodeLine3(trimmed, lineNumber, counter, aliasMap, diagnostics, bad
26638
26749
  }
26639
26750
  function attachNode4(node, indent, indentStack, result) {
26640
26751
  while (indentStack.length > 0) {
26641
- const top = indentStack[indentStack.length - 1];
26642
- if (top.indent < indent) break;
26752
+ const top2 = indentStack[indentStack.length - 1];
26753
+ if (top2.indent < indent) break;
26643
26754
  indentStack.pop();
26644
26755
  }
26645
26756
  if (indentStack.length > 0) {
@@ -33639,13 +33750,13 @@ function renderLegendSvg(groups, options) {
33639
33750
  }
33640
33751
  const { groupBg, pillBorder } = legendChromeColors(palette, isDark);
33641
33752
  const parts = [];
33642
- let bottom = 0;
33643
- let left = Infinity;
33644
- let right = 0;
33753
+ let bottom2 = 0;
33754
+ let left2 = Infinity;
33755
+ let right2 = 0;
33645
33756
  const track = (x, y, w, h) => {
33646
- left = Math.min(left, x);
33647
- right = Math.max(right, x + w);
33648
- bottom = Math.max(bottom, y + h);
33757
+ left2 = Math.min(left2, x);
33758
+ right2 = Math.max(right2, x + w);
33759
+ bottom2 = Math.max(bottom2, y + h);
33649
33760
  };
33650
33761
  if (layout.activeCapsule) {
33651
33762
  const c = layout.activeCapsule;
@@ -33661,8 +33772,8 @@ function renderLegendSvg(groups, options) {
33661
33772
  const svg = `<g${classAttr}${activeAttr}>${parts.join("")}</g>`;
33662
33773
  return {
33663
33774
  svg,
33664
- height: bottom,
33665
- width: right - (left === Infinity ? 0 : left)
33775
+ height: bottom2,
33776
+ width: right2 - (left2 === Infinity ? 0 : left2)
33666
33777
  };
33667
33778
  }
33668
33779
  var init_legend_svg = __esm({
@@ -33901,7 +34012,7 @@ var init_shared = __esm({
33901
34012
 
33902
34013
  // src/charts-d3/bar.ts
33903
34014
  import { scaleBand, scaleLinear as scaleLinear5 } from "d3-scale";
33904
- import { max as d3max } from "d3-array";
34015
+ import { max as d3max, min as d3min } from "d3-array";
33905
34016
  function seriesValues(pt, seriesCount) {
33906
34017
  const out = [pt.value];
33907
34018
  for (let s = 1; s < seriesCount; s++) out.push(pt.extraValues?.[s - 1] ?? 0);
@@ -33925,7 +34036,7 @@ function renderBar(svg, chart, width, height, colors, palette, isDark, textColor
33925
34036
  return multiSeries ? chart.seriesNameColors?.[seriesIdx] ?? colors[seriesIdx % colors.length] : colors[catIdx % colors.length];
33926
34037
  };
33927
34038
  const fillOf = (c) => shapeFill(palette, c, isDark, { mode: fillMode });
33928
- const top = reserveHeader(
34039
+ const top2 = reserveHeader(
33929
34040
  svg,
33930
34041
  chart,
33931
34042
  colors,
@@ -33936,11 +34047,20 @@ function renderBar(svg, chart, width, height, colors, palette, isDark, textColor
33936
34047
  inlineTitle
33937
34048
  );
33938
34049
  const perCat = data.map((d) => seriesValues(d, seriesCount));
33939
- const maxVal = stacked ? d3max(perCat, (vals) => vals.reduce((a, b) => a + b, 0)) ?? 0 : d3max(perCat, (vals) => d3max(vals) ?? 0) ?? 0;
33940
- const niceMax = maxVal === 0 ? 1 : maxVal;
33941
- const leftLabels = horizontal ? data.map((d) => d.label) : [fmtNum(niceMax), fmtNum(niceMax / 2)];
34050
+ const maxVal = stacked ? d3max(
34051
+ perCat,
34052
+ (vals) => vals.filter((v) => v > 0).reduce((a, b) => a + b, 0)
34053
+ ) ?? 0 : d3max(perCat, (vals) => d3max(vals) ?? 0) ?? 0;
34054
+ const minVal = stacked ? d3min(
34055
+ perCat,
34056
+ (vals) => vals.filter((v) => v < 0).reduce((a, b) => a + b, 0)
34057
+ ) ?? 0 : d3min(perCat, (vals) => d3min(vals) ?? 0) ?? 0;
34058
+ const hiVal = Math.max(0, maxVal);
34059
+ const loVal = Math.min(0, minVal);
34060
+ const niceMax = hiVal === 0 && loVal === 0 ? 1 : hiVal;
34061
+ const leftLabels = horizontal ? data.map((d) => d.label) : [fmtNum(niceMax), fmtNum(niceMax / 2), fmtNum(loVal), fmtNum(loVal / 2)];
33942
34062
  const m = {
33943
- top: top + 8,
34063
+ top: top2 + 8,
33944
34064
  right: 32,
33945
34065
  bottom: 64,
33946
34066
  left: computeLeftMargin(chart.ylabel, leftLabels)
@@ -33951,7 +34071,7 @@ function renderBar(svg, chart, width, height, colors, palette, isDark, textColor
33951
34071
  const catRange = horiz ? [m.top, m.top + plotH] : [m.left, m.left + plotW];
33952
34072
  const cat = scaleBand().domain(data.map((d) => d.label)).range(catRange).padding(0.3);
33953
34073
  const valRange = horiz ? [m.left, m.left + plotW] : [m.top + plotH, m.top];
33954
- const val = scaleLinear5().domain([0, niceMax]).nice().range(valRange);
34074
+ const val = scaleLinear5().domain([loVal, niceMax]).nice().range(valRange);
33955
34075
  for (const t of val.ticks(6)) {
33956
34076
  if (horiz) {
33957
34077
  const x = val(t);
@@ -33976,7 +34096,8 @@ function renderBar(svg, chart, width, height, colors, palette, isDark, textColor
33976
34096
  data.forEach((d, ci) => {
33977
34097
  const base = cat(d.label) ?? 0;
33978
34098
  const vals = seriesValues(d, seriesCount);
33979
- let acc = 0;
34099
+ let accPos = 0;
34100
+ let accNeg = 0;
33980
34101
  vals.forEach((v, s) => {
33981
34102
  const stroke2 = colorFor(s, ci, seriesCount === 1 ? d.color : void 0);
33982
34103
  const fill2 = fillOf(stroke2);
@@ -33990,6 +34111,7 @@ function renderBar(svg, chart, width, height, colors, palette, isDark, textColor
33990
34111
  seriesName: multiSeries ? sName : void 0
33991
34112
  };
33992
34113
  if (stacked) {
34114
+ const acc = v < 0 ? accNeg : accPos;
33993
34115
  if (horiz) {
33994
34116
  const x0 = val(acc);
33995
34117
  const x1 = val(acc + v);
@@ -34033,7 +34155,8 @@ function renderBar(svg, chart, width, height, colors, palette, isDark, textColor
34033
34155
  textColor
34034
34156
  );
34035
34157
  }
34036
- acc += v;
34158
+ if (v < 0) accNeg += v;
34159
+ else accPos += v;
34037
34160
  } else {
34038
34161
  const off = inner(s) ?? 0;
34039
34162
  const bw = inner.bandwidth();
@@ -34049,13 +34172,16 @@ function renderBar(svg, chart, width, height, colors, palette, isDark, textColor
34049
34172
  stroke2,
34050
34173
  tag
34051
34174
  );
34175
+ const txt = fmtNum(v);
34176
+ const approxW = txt.length * 7 + 6;
34177
+ const inside = v < 0 ? x1 - approxW < m.left : x1 + approxW > m.left + plotW;
34052
34178
  drawValueLabel(
34053
34179
  svg,
34054
- fmtNum(v),
34055
- x1 + 6,
34180
+ txt,
34181
+ v < 0 ? inside ? x1 + 6 : x1 - 6 : inside ? x1 - 6 : x1 + 6,
34056
34182
  base + off + bw / 2 + 4,
34057
34183
  textColor,
34058
- "start"
34184
+ v < 0 !== inside ? "end" : "start"
34059
34185
  );
34060
34186
  } else {
34061
34187
  const y1 = val(v);
@@ -34069,11 +34195,13 @@ function renderBar(svg, chart, width, height, colors, palette, isDark, textColor
34069
34195
  stroke2,
34070
34196
  tag
34071
34197
  );
34198
+ const yOut = v < 0 ? y1 + 14 : y1 - 6;
34199
+ const yInside = v < 0 ? yOut > m.top + plotH - 2 : yOut < m.top + 2;
34072
34200
  drawValueLabel(
34073
34201
  svg,
34074
34202
  fmtNum(v),
34075
34203
  base + off + bw / 2,
34076
- y1 - 6,
34204
+ yInside ? v < 0 ? y1 - 6 : y1 + 14 : yOut,
34077
34205
  textColor
34078
34206
  );
34079
34207
  }
@@ -34127,7 +34255,7 @@ function renderLine(svg, chart, width, height, colors, palette, isDark, textColo
34127
34255
  if (axisOf(s) === side) owners.push(s);
34128
34256
  return owners.length === 1 ? seriesColor(owners[0]) : void 0;
34129
34257
  };
34130
- const top = reserveHeader(
34258
+ const top2 = reserveHeader(
34131
34259
  svg,
34132
34260
  chart,
34133
34261
  colors,
@@ -34162,7 +34290,7 @@ function renderLine(svg, chart, width, height, colors, palette, isDark, textColo
34162
34290
  const [loL, hiL] = extentFor("left");
34163
34291
  const [loR, hiR] = dual ? extentFor("right") : [0, 1];
34164
34292
  const m = {
34165
- top: top + 8,
34293
+ top: top2 + 8,
34166
34294
  right: dual ? computeLeftMargin(chart.yrlabel, [fmtNum(hiR), fmtNum(loR)]) : 32,
34167
34295
  bottom: 64,
34168
34296
  left: computeLeftMargin(chart.ylabel, [fmtNum(hiL), fmtNum(loL)])
@@ -34278,9 +34406,9 @@ function renderPie(svg, chart, width, height, palette, isDark, textColor, topIns
34278
34406
  const fillMode = chart.fillMode;
34279
34407
  const total = data.reduce((a, d) => a + d.value, 0);
34280
34408
  const cx = width / 2;
34281
- const top = topInset + 12;
34282
- const availH = height - top;
34283
- const cy = top + availH / 2;
34409
+ const top2 = topInset + 12;
34410
+ const availH = height - top2;
34411
+ const cy = top2 + availH / 2;
34284
34412
  const labels = data.map((d) => {
34285
34413
  const pct = Math.round(d.value / total * 100);
34286
34414
  const nm = chart.noName ? "" : d.label;
@@ -34291,8 +34419,8 @@ function renderPie(svg, chart, width, height, palette, isDark, textColor, topIns
34291
34419
  return [nm, tail].filter(Boolean).join(" \u2014 ");
34292
34420
  });
34293
34421
  const maxLabelLen = labels.reduce((m, s) => Math.max(m, s.length), 0);
34294
- const MARGIN11 = 6;
34295
- const halfW = width / 2 - MARGIN11;
34422
+ const MARGIN12 = 6;
34423
+ const halfW = width / 2 - MARGIN12;
34296
34424
  const rH = availH / 2 - availH * 0.06;
34297
34425
  const labelExtent = 1.27 + 0.06 * maxLabelLen;
34298
34426
  const rLabeled = Math.min(rH, halfW / labelExtent);
@@ -34419,9 +34547,9 @@ function renderRadar(svg, chart, width, height, colors, palette, isDark, textCol
34419
34547
  for (let s = 0; s < seriesCount; s++) allValues.push(seriesValue2(d, s));
34420
34548
  const maxValue = Math.max(...allValues) * 1.15 || 1;
34421
34549
  const cx = width / 2;
34422
- const top = topInset + 8;
34423
- const cy = top + (height - top) / 2;
34424
- const radius = Math.min(width / 2 - 130, (height - top) / 2 - 50);
34550
+ const top2 = topInset + 8;
34551
+ const cy = top2 + (height - top2) / 2;
34552
+ const radius = Math.min(width / 2 - 130, (height - top2) / 2 - 50);
34425
34553
  const angle = (i) => -Math.PI / 2 + i * 2 * Math.PI / n;
34426
34554
  const pt = (i, r) => [
34427
34555
  cx + Math.cos(angle(i)) * r,
@@ -34497,9 +34625,9 @@ function renderPolarArea(svg, chart, width, height, palette, isDark, textColor,
34497
34625
  const total = data.reduce((a, d) => a + d.value, 0);
34498
34626
  const maxValue = Math.max(...data.map((d) => d.value)) || 1;
34499
34627
  const cx = width / 2;
34500
- const top = topInset + 8;
34501
- const cy = top + (height - top) / 2;
34502
- const outerR = Math.min(width / 2 - 200, (height - top) / 2 - 40);
34628
+ const top2 = topInset + 8;
34629
+ const cy = top2 + (height - top2) / 2;
34630
+ const outerR = Math.min(width / 2 - 200, (height - top2) / 2 - 40);
34503
34631
  const innerR = outerR * 0.14;
34504
34632
  const segColors = getSegmentColors(palette, n);
34505
34633
  const g = svg.append("g").attr("transform", `translate(${cx},${cy})`);
@@ -34549,9 +34677,9 @@ function renderFunnel(svg, chart, width, height, colors, palette, isDark, topIns
34549
34677
  const n = sorted.length;
34550
34678
  if (n === 0) return;
34551
34679
  const fillMode = chart.fillMode;
34552
- const top = topInset + 8;
34553
- const bottom = height - 30;
34554
- const H2 = bottom - top;
34680
+ const top2 = topInset + 8;
34681
+ const bottom2 = height - 30;
34682
+ const H2 = bottom2 - top2;
34555
34683
  const bandH = H2 / n;
34556
34684
  const maxValue = sorted[0].value || 1;
34557
34685
  const sideFont = Math.max(11, Math.min(21, width / 52));
@@ -34608,7 +34736,7 @@ function renderFunnel(svg, chart, width, height, colors, palette, isDark, topIns
34608
34736
  const stroke2 = d.color ?? colors[chart.data.indexOf(d) % colors.length];
34609
34737
  const fill2 = shapeFill(palette, stroke2, isDark, { mode: fillMode });
34610
34738
  const { topW, botW } = bandWidthsAt(plotW, i);
34611
- const y0 = top + i * bandH;
34739
+ const y0 = top2 + i * bandH;
34612
34740
  const y1 = y0 + bandH;
34613
34741
  const seg = svg.append("polygon").attr(
34614
34742
  "points",
@@ -34697,12 +34825,12 @@ function renderHeatmap(svg, chart, width, height, palette, isDark, textColor, bg
34697
34825
  return hslToHex(h, targetS, targetL);
34698
34826
  };
34699
34827
  const rowLabelW = Math.max(0, ...rows.map((r) => measureText(r.label, 13))) + 16;
34700
- const left = 20 + rowLabelW;
34701
- const top = topInset + 28;
34702
- const right = 24;
34703
- const bottom = 24;
34704
- const plotW = width - left - right;
34705
- const plotH = height - top - bottom;
34828
+ const left2 = 20 + rowLabelW;
34829
+ const top2 = topInset + 28;
34830
+ const right2 = 24;
34831
+ const bottom2 = 24;
34832
+ const plotW = width - left2 - right2;
34833
+ const plotH = height - top2 - bottom2;
34706
34834
  const cw = plotW / ncols;
34707
34835
  const ch = plotH / nrows;
34708
34836
  const REF2 = 100;
@@ -34716,26 +34844,26 @@ function renderHeatmap(svg, chart, width, height, palette, isDark, textColor, bg
34716
34844
  );
34717
34845
  const rotate = cols.some((c) => measureText(c, 12) > cw * 0.85);
34718
34846
  cols.forEach((c, ci) => {
34719
- const x = left + ci * cw + cw / 2;
34847
+ const x = left2 + ci * cw + cw / 2;
34720
34848
  const t = svg.append("text").attr("class", "dgmo-axis-label").attr("data-filter-attr", "data-col-key").attr("data-filter-value", c).attr("fill", textColor).attr("font-size", 12).attr("font-family", FONT_FAMILY).text(c);
34721
34849
  if (rotate) {
34722
- t.attr("transform", `translate(${x},${top - 8}) rotate(-40)`).attr(
34850
+ t.attr("transform", `translate(${x},${top2 - 8}) rotate(-40)`).attr(
34723
34851
  "text-anchor",
34724
34852
  "start"
34725
34853
  );
34726
34854
  } else {
34727
- t.attr("x", x).attr("y", top - 8).attr("text-anchor", "middle");
34855
+ t.attr("x", x).attr("y", top2 - 8).attr("text-anchor", "middle");
34728
34856
  }
34729
34857
  });
34730
34858
  rows.forEach((row, ri) => {
34731
- svg.append("text").attr("class", "dgmo-axis-label").attr("data-filter-attr", "data-row-key").attr("data-filter-value", row.label).attr("x", left - 10).attr("y", top + ri * ch + ch / 2 + 4).attr("text-anchor", "end").attr("fill", textColor).attr("font-size", 13).attr("font-family", FONT_FAMILY).text(row.label);
34859
+ svg.append("text").attr("class", "dgmo-axis-label").attr("data-filter-attr", "data-row-key").attr("data-filter-value", row.label).attr("x", left2 - 10).attr("y", top2 + ri * ch + ch / 2 + 4).attr("text-anchor", "end").attr("fill", textColor).attr("font-size", 13).attr("font-family", FONT_FAMILY).text(row.label);
34732
34860
  row.values.forEach((v, ci) => {
34733
34861
  const t = maxValue === minValue ? 0.5 : (v - minValue) / (maxValue - minValue);
34734
34862
  const ramp = gradientAt(t);
34735
34863
  const cell = outline ? baseBg : ramp;
34736
34864
  const colLabel = cols[ci] ?? `Col ${ci + 1}`;
34737
34865
  const cellKey = `${row.label} \xB7 ${colLabel}`;
34738
- const r = svg.append("rect").attr("x", left + ci * cw).attr("y", top + ri * ch).attr("width", cw).attr("height", ch).attr("fill", cell).attr("stroke", outline ? ramp : bgColor).attr("stroke-width", outline ? 1.5 : 2).attr("data-row-key", row.label).attr("data-col-key", colLabel);
34866
+ const r = svg.append("rect").attr("x", left2 + ci * cw).attr("y", top2 + ri * ch).attr("width", cw).attr("height", ch).attr("fill", cell).attr("stroke", outline ? ramp : bgColor).attr("stroke-width", outline ? 1.5 : 2).attr("data-row-key", row.label).attr("data-col-key", colLabel);
34739
34867
  tagDatum(r, {
34740
34868
  line: row.lineNumber,
34741
34869
  key: cellKey,
@@ -34744,7 +34872,7 @@ function renderHeatmap(svg, chart, width, height, palette, isDark, textColor, bg
34744
34872
  color: ramp
34745
34873
  });
34746
34874
  if (!chart.noValue) {
34747
- const label = svg.append("text").attr("x", left + ci * cw + cw / 2).attr("y", top + ri * ch + ch / 2 + cellFont / 3).attr("text-anchor", "middle").attr("fill", labelTint(ramp)).attr("font-size", cellFont).attr("font-weight", 600).attr("font-family", FONT_FAMILY).text(fmtNum(v));
34875
+ const label = svg.append("text").attr("x", left2 + ci * cw + cw / 2).attr("y", top2 + ri * ch + ch / 2 + cellFont / 3).attr("text-anchor", "middle").attr("fill", labelTint(ramp)).attr("font-size", cellFont).attr("font-weight", 600).attr("font-family", FONT_FAMILY).text(fmtNum(v));
34748
34876
  tagDatum(label, {
34749
34877
  line: row.lineNumber,
34750
34878
  key: cellKey,
@@ -35029,9 +35157,9 @@ function renderSankey(svg, chart, width, height, colors, bgColor, textColor, top
35029
35157
  const layers = Array.from({ length: maxRank + 1 }, () => []);
35030
35158
  for (const n of node.values()) layers[n.rank].push(n);
35031
35159
  const plotLeft = 16;
35032
- const top = topInset + 8;
35160
+ const top2 = topInset + 8;
35033
35161
  const plotW = width - plotLeft - 16 - measureText("M", 14);
35034
- const plotH = height - top - 24;
35162
+ const plotH = height - top2 - 24;
35035
35163
  let valueScale = Infinity;
35036
35164
  for (const layer of layers) {
35037
35165
  const tot = layer.reduce((a, n) => a + n.value, 0);
@@ -35043,7 +35171,7 @@ function renderSankey(svg, chart, width, height, colors, bgColor, textColor, top
35043
35171
  const placeLayer = (layer) => {
35044
35172
  layer.sort((a, b) => a.order - b.order);
35045
35173
  const totH = layer.reduce((a, n) => a + n.value * valueScale, 0) + (layer.length - 1) * NODE_GAP;
35046
- let y = top + (plotH - totH) / 2;
35174
+ let y = top2 + (plotH - totH) / 2;
35047
35175
  for (const n of layer) {
35048
35176
  n.h = n.value * valueScale;
35049
35177
  n.x = layerX(n.rank);
@@ -35149,11 +35277,11 @@ function renderChord(svg, chart, width, height, colors, palette, isDark, textCol
35149
35277
  const n = names.length;
35150
35278
  const idx = new Map(names.map((nm, i) => [nm, i]));
35151
35279
  const colorOf2 = (i) => colors[i % colors.length];
35152
- const top = topInset + 8;
35280
+ const top2 = topInset + 8;
35153
35281
  const cx = width / 2;
35154
- const cy = top + (height - top) / 2;
35282
+ const cy = top2 + (height - top2) / 2;
35155
35283
  const maxLabel = Math.max(0, ...names.map((nm) => measureText(nm, 14)));
35156
- const radius = Math.min(width / 2 - maxLabel - 60, (height - top) / 2 - 50);
35284
+ const radius = Math.min(width / 2 - maxLabel - 60, (height - top2) / 2 - 50);
35157
35285
  const angle = (i) => -Math.PI / 2 + i * 2 * Math.PI / n;
35158
35286
  const pos = (i) => [
35159
35287
  cx + Math.cos(angle(i)) * radius,
@@ -35598,7 +35726,7 @@ function renderInto(s, content, palette, isDark, width, height, textColor, muted
35598
35726
  return true;
35599
35727
  case "radar": {
35600
35728
  const groups = std.noLegend ? [] : getSimpleChartLegendGroups(std, colors);
35601
- const top = injectLegendGroups(
35729
+ const top2 = injectLegendGroups(
35602
35730
  s,
35603
35731
  groups,
35604
35732
  palette,
@@ -35617,7 +35745,7 @@ function renderInto(s, content, palette, isDark, width, height, textColor, muted
35617
35745
  isDark,
35618
35746
  textColor,
35619
35747
  mutedColor,
35620
- top
35748
+ top2
35621
35749
  );
35622
35750
  return true;
35623
35751
  }
@@ -35670,7 +35798,7 @@ function renderInto(s, content, palette, isDark, width, height, textColor, muted
35670
35798
  return true;
35671
35799
  case "scatter": {
35672
35800
  const groups = ext.noLegend ? [] : getExtendedChartLegendGroups(ext, seriesColors2);
35673
- const top = injectLegendGroups(
35801
+ const top2 = injectLegendGroups(
35674
35802
  s,
35675
35803
  groups,
35676
35804
  palette,
@@ -35689,7 +35817,7 @@ function renderInto(s, content, palette, isDark, width, height, textColor, muted
35689
35817
  isDark,
35690
35818
  textColor,
35691
35819
  mutedColor,
35692
- top
35820
+ top2
35693
35821
  );
35694
35822
  return true;
35695
35823
  }
@@ -35720,7 +35848,7 @@ function renderInto(s, content, palette, isDark, width, height, textColor, muted
35720
35848
  return true;
35721
35849
  case "function": {
35722
35850
  const groups = ext.noLegend ? [] : getExtendedChartLegendGroups(ext, seriesColors2);
35723
- const top = injectLegendGroups(
35851
+ const top2 = injectLegendGroups(
35724
35852
  s,
35725
35853
  groups,
35726
35854
  palette,
@@ -35737,7 +35865,7 @@ function renderInto(s, content, palette, isDark, width, height, textColor, muted
35737
35865
  seriesColors2,
35738
35866
  textColor,
35739
35867
  mutedColor,
35740
- top,
35868
+ top2,
35741
35869
  palette,
35742
35870
  isDark
35743
35871
  );
@@ -36160,17 +36288,17 @@ function renderEventLine(container, parsed, palette, isDark, onClickItem, export
36160
36288
  const maxLeft = p.x - CARD_INSET;
36161
36289
  const minLeft = p.x - CARD_W + CARD_INSET;
36162
36290
  let lane = laneRight.length;
36163
- let left = Math.max(preferred, minLeft);
36291
+ let left2 = Math.max(preferred, minLeft);
36164
36292
  for (let l = 0; l < laneRight.length; l++) {
36165
36293
  const want = Math.max(preferred, laneRight[l] + FAN_GAP, minLeft);
36166
36294
  if (want <= maxLeft) {
36167
36295
  lane = l;
36168
- left = want;
36296
+ left2 = want;
36169
36297
  break;
36170
36298
  }
36171
36299
  }
36172
36300
  p.lane = lane;
36173
- p.left = Math.max(6, left);
36301
+ p.left = Math.max(6, left2);
36174
36302
  laneRight[lane] = p.left + CARD_W;
36175
36303
  }
36176
36304
  }
@@ -36302,8 +36430,8 @@ function renderEventLine(container, parsed, palette, isDark, onClickItem, export
36302
36430
  }
36303
36431
  const geo = placed.map((p) => {
36304
36432
  const near = p.side === "above" ? spineY - laneNear(p) : spineY + laneNear(p);
36305
- const top = p.side === "above" ? near - p.cardH : near;
36306
- return { p, near, top };
36433
+ const top2 = p.side === "above" ? near - p.cardH : near;
36434
+ return { p, near, top: top2 };
36307
36435
  });
36308
36436
  const leaderCrossesBox = (owner, near) => {
36309
36437
  const lo = Math.min(spineY, near);
@@ -36322,9 +36450,9 @@ function renderEventLine(container, parsed, palette, isDark, onClickItem, export
36322
36450
  applyHoverHooks(leader, p);
36323
36451
  }
36324
36452
  let shelfClipSeq = 0;
36325
- for (const { p, top } of geo) {
36326
- const left = p.left;
36327
- const cardG = svg.append("g").attr("class", "dgmo-event-card").attr("transform", `translate(${left}, ${top})`).attr("data-line-number", p.lineNumber);
36453
+ for (const { p, top: top2 } of geo) {
36454
+ const left2 = p.left;
36455
+ const cardG = svg.append("g").attr("class", "dgmo-event-card").attr("transform", `translate(${left2}, ${top2})`).attr("data-line-number", p.lineNumber);
36328
36456
  applyHoverHooks(cardG, p);
36329
36457
  if (p.kind === "era") {
36330
36458
  cardG.attr("data-era", p.era.name).attr("data-era-collapsed", "true");
@@ -37014,27 +37142,27 @@ function renderFigureBody(fig, view, parts, partColor, emphKey, form, palette, i
37014
37142
  const muscleFill = mix(palette.bg, palette.border, 0.7);
37015
37143
  const seam = palette.bg;
37016
37144
  const outlineStroke = palette.textMuted;
37017
- const gid = `body-skin-${vx}-${vy}`;
37145
+ const gid2 = `body-skin-${vx}-${vy}`;
37018
37146
  defs.push(
37019
- `<linearGradient id="${gid}" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="${mix(palette.surface, palette.bg, 0.4)}"/><stop offset="1" stop-color="${mix(palette.border, palette.bg, 0.3)}"/></linearGradient>`
37147
+ `<linearGradient id="${gid2}" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="${mix(palette.surface, palette.bg, 0.4)}"/><stop offset="1" stop-color="${mix(palette.border, palette.bg, 0.3)}"/></linearGradient>`
37020
37148
  );
37021
37149
  let out = "";
37022
37150
  if (form === "skin") {
37023
- out += `<path d="${fig.outline}" fill="url(#${gid})"/>`;
37151
+ out += `<path d="${fig.outline}" fill="url(#${gid2})"/>`;
37024
37152
  for (const d of fig.headPaths) {
37025
- out += `<path d="${d}" fill="url(#${gid})" stroke="${outlineStroke}" stroke-width="2.5"/>`;
37153
+ out += `<path d="${d}" fill="url(#${gid2})" stroke="${outlineStroke}" stroke-width="2.5"/>`;
37026
37154
  }
37027
37155
  const hairFill = mix(palette.text, palette.bg, 0.6);
37028
37156
  for (const d of fig.hairPaths) {
37029
37157
  out += `<path d="${d}" fill="${hairFill}" stroke="${outlineStroke}" stroke-width="1.5"/>`;
37030
37158
  }
37031
37159
  } else {
37032
- out += `<path d="${fig.outline}" fill="url(#${gid})"/>`;
37160
+ out += `<path d="${fig.outline}" fill="url(#${gid2})"/>`;
37033
37161
  for (const d of fig.base) {
37034
37162
  out += `<path d="${d}" fill="${muscleFill}" fill-opacity="0.55" stroke="${seam}" stroke-width="1"/>`;
37035
37163
  }
37036
37164
  for (const d of fig.headPaths) {
37037
- out += `<path d="${d}" fill="url(#${gid})" stroke="${outlineStroke}" stroke-width="2.5"/>`;
37165
+ out += `<path d="${d}" fill="url(#${gid2})" stroke="${outlineStroke}" stroke-width="2.5"/>`;
37038
37166
  }
37039
37167
  for (const d of fig.hairPaths) {
37040
37168
  out += `<path d="${d}" fill="none" stroke="${outlineStroke}" stroke-width="2.5"/>`;
@@ -37107,10 +37235,10 @@ function gutterLabels(r, palette) {
37107
37235
  const cx = vx + vw / 2;
37108
37236
  const list = [...r.anchors.values()];
37109
37237
  const band = vw * 0.1;
37110
- const left = list.filter((a) => a.x < cx - band);
37111
- const right = list.filter((a) => a.x > cx + band);
37238
+ const left2 = list.filter((a) => a.x < cx - band);
37239
+ const right2 = list.filter((a) => a.x > cx + band);
37112
37240
  const mid = list.filter((a) => a.x >= cx - band && a.x <= cx + band).sort((a, b) => a.y - b.y);
37113
- for (const a of mid) (left.length <= right.length ? left : right).push(a);
37241
+ for (const a of mid) (left2.length <= right2.length ? left2 : right2).push(a);
37114
37242
  let labels = "";
37115
37243
  const place = (arr, side) => {
37116
37244
  const gx = side === "L" ? vx - 14 : vx + vw + 14;
@@ -37130,8 +37258,8 @@ function gutterLabels(r, palette) {
37130
37258
  }
37131
37259
  }
37132
37260
  };
37133
- place(left, "L");
37134
- place(right, "R");
37261
+ place(left2, "L");
37262
+ place(right2, "R");
37135
37263
  return labels;
37136
37264
  }
37137
37265
  function renderBody2(container, parsed, palette, _isDark, _onClickItem, exportDims, tagOverride) {
@@ -37202,17 +37330,17 @@ function renderBody2(container, parsed, palette, _isDark, _onClickItem, exportDi
37202
37330
  const aR = fR.anchors.get(nm);
37203
37331
  if (!aL && !aR) continue;
37204
37332
  seen.add(nm);
37205
- const left = aL ? mapL(nearestCenter(aL, fL.vx + fL.vw)) : void 0;
37206
- const right = aR ? mapR(nearestCenter(aR, fR.vx)) : void 0;
37207
- const ys = [left?.y, right?.y].filter((v) => v != null);
37333
+ const left2 = aL ? mapL(nearestCenter(aL, fL.vx + fL.vw)) : void 0;
37334
+ const right2 = aR ? mapR(nearestCenter(aR, fR.vx)) : void 0;
37335
+ const ys = [left2?.y, right2?.y].filter((v) => v != null);
37208
37336
  items.push({
37209
37337
  name: partLabel(part),
37210
37338
  note: part.notes.length ? part.notes[0] : "",
37211
37339
  color: (aL ?? aR).color,
37212
37340
  emph: (aL ?? aR).emph,
37213
37341
  line: part.lineNumber,
37214
- ...left && { left },
37215
- ...right && { right },
37342
+ ...left2 && { left: left2 },
37343
+ ...right2 && { right: right2 },
37216
37344
  y: ys.reduce((s, v) => s + v, 0) / ys.length
37217
37345
  });
37218
37346
  }
@@ -37408,25 +37536,25 @@ function renderVersionControl(container, parsed, palette, isDark, onClickItem, e
37408
37536
  for (const n of sorted) {
37409
37537
  const p = pos.get(n.key);
37410
37538
  const w = label.get(n.key).lw + SHELF_PAD * 2;
37411
- const left = p.x - w / 2;
37539
+ const left2 = p.x - w / 2;
37412
37540
  let row = rowRight.length;
37413
37541
  for (let l = 0; l < rowRight.length; l++)
37414
- if (rowRight[l] + shelfGap <= left) {
37542
+ if (rowRight[l] + shelfGap <= left2) {
37415
37543
  row = l;
37416
37544
  break;
37417
37545
  }
37418
- const top = bandTop + row * (SHELF_H + ROW_GAP);
37419
- rowRight[row] = left + w;
37546
+ const top2 = bandTop + row * (SHELF_H + ROW_GAP);
37547
+ rowRight[row] = left2 + w;
37420
37548
  placements.push({
37421
37549
  node: n,
37422
37550
  kind: "msg",
37423
37551
  x: p.x,
37424
- y: top,
37552
+ y: top2,
37425
37553
  anchor: "start",
37426
- shelfLeft: Math.max(4, left),
37427
- shelfTop: top,
37554
+ shelfLeft: Math.max(4, left2),
37555
+ shelfTop: top2,
37428
37556
  shelfW: w,
37429
- leader: { x1: p.x, y1: p.y + DOT, x2: p.x, y2: top }
37557
+ leader: { x1: p.x, y1: p.y + DOT, x2: p.x, y2: top2 }
37430
37558
  });
37431
37559
  const stack = above.get(n.key) ?? [];
37432
37560
  stack.forEach(
@@ -37689,15 +37817,15 @@ function drawGraph(g, parsed, palette, TB, pos, placements, label, colorOf2, byK
37689
37817
  let ty = pl.y + 4;
37690
37818
  let anchor = pl.anchor;
37691
37819
  if (pl.shelfW != null) {
37692
- const left = pl.shelfLeft;
37693
- const top = pl.shelfTop;
37820
+ const left2 = pl.shelfLeft;
37821
+ const top2 = pl.shelfTop;
37694
37822
  const w = pl.shelfW;
37695
37823
  const clipId = `dgmo-vc-shelf-${shelfSeq++}`;
37696
- g.append("clipPath").attr("id", clipId).append("rect").attr("x", left).attr("y", top).attr("width", w).attr("height", SHELF_H).attr("rx", SHELF_EDGE2);
37697
- g.append("rect").attr("x", left).attr("y", top).attr("width", w).attr("height", SHELF_H).attr("rx", SHELF_EDGE2).attr("fill", gh ? palette.bg : mix(c, palette.bg, SHELF_TINT2)).attr("data-branch", n.branch).attr("opacity", gh ? 0.5 : 1);
37698
- g.append("rect").attr("x", left).attr("y", top).attr("width", w).attr("height", SHELF_LIP2).attr("clip-path", `url(#${clipId})`).attr("fill", c).attr("data-branch", n.branch).attr("opacity", gh ? 0.4 : 1);
37699
- tx = left + SHELF_PAD;
37700
- ty = top + SHELF_H / 2 + 4;
37824
+ g.append("clipPath").attr("id", clipId).append("rect").attr("x", left2).attr("y", top2).attr("width", w).attr("height", SHELF_H).attr("rx", SHELF_EDGE2);
37825
+ g.append("rect").attr("x", left2).attr("y", top2).attr("width", w).attr("height", SHELF_H).attr("rx", SHELF_EDGE2).attr("fill", gh ? palette.bg : mix(c, palette.bg, SHELF_TINT2)).attr("data-branch", n.branch).attr("opacity", gh ? 0.5 : 1);
37826
+ g.append("rect").attr("x", left2).attr("y", top2).attr("width", w).attr("height", SHELF_LIP2).attr("clip-path", `url(#${clipId})`).attr("fill", c).attr("data-branch", n.branch).attr("opacity", gh ? 0.4 : 1);
37827
+ tx = left2 + SHELF_PAD;
37828
+ ty = top2 + SHELF_H / 2 + 4;
37701
37829
  anchor = "start";
37702
37830
  }
37703
37831
  const t = g.append("text").attr("x", tx).attr("y", ty).attr("text-anchor", anchor).attr("font-size", 12).attr("data-branch", n.branch).attr("opacity", gh ? 0.6 : 1);
@@ -37836,18 +37964,18 @@ function centerHeavyChildren(node) {
37836
37964
  const weighted = node.children.map((child) => ({ child, weight: countDescendants(child) })).sort((a, b) => b.weight - a.weight);
37837
37965
  const result = new Array(weighted.length);
37838
37966
  const mid = Math.floor((weighted.length - 1) / 2);
37839
- let left = mid;
37840
- let right = mid;
37967
+ let left2 = mid;
37968
+ let right2 = mid;
37841
37969
  for (let i = 0; i < weighted.length; i++) {
37842
37970
  const w = weighted[i];
37843
37971
  if (i === 0) {
37844
37972
  result[mid] = w.child;
37845
37973
  } else if (i % 2 === 1) {
37846
- right++;
37847
- result[right] = w.child;
37974
+ right2++;
37975
+ result[right2] = w.child;
37848
37976
  } else {
37849
- left--;
37850
- result[left] = w.child;
37977
+ left2--;
37978
+ result[left2] = w.child;
37851
37979
  }
37852
37980
  }
37853
37981
  node.children = result;
@@ -38182,8 +38310,8 @@ function layoutOrg(parsed, hiddenCounts, activeTagGroup, hiddenAttributes, expan
38182
38310
  }
38183
38311
  }
38184
38312
  const screenRect = (ax, ay, w, h2) => {
38185
- const { left, top } = screenTopLeft(ax, ay, w, h2);
38186
- return { left, top, right: left + w, bottom: top + h2 };
38313
+ const { left: left2, top: top2 } = screenTopLeft(ax, ay, w, h2);
38314
+ return { left: left2, top: top2, right: left2 + w, bottom: top2 + h2 };
38187
38315
  };
38188
38316
  const growBBox = (r) => {
38189
38317
  if (r.left < minX) minX = r.left;
@@ -38397,11 +38525,11 @@ function layoutOrg(parsed, hiddenCounts, activeTagGroup, hiddenAttributes, expan
38397
38525
  let descMaxX = -Infinity;
38398
38526
  let descMinY = Infinity;
38399
38527
  let descMaxY = -Infinity;
38400
- const growDesc = (left, top, right, bottom) => {
38401
- if (left < descMinX) descMinX = left;
38402
- if (right > descMaxX) descMaxX = right;
38403
- if (top < descMinY) descMinY = top;
38404
- if (bottom > descMaxY) descMaxY = bottom;
38528
+ const growDesc = (left2, top2, right2, bottom2) => {
38529
+ if (left2 < descMinX) descMinX = left2;
38530
+ if (right2 > descMaxX) descMaxX = right2;
38531
+ if (top2 < descMinY) descMinY = top2;
38532
+ if (bottom2 > descMaxY) descMaxY = bottom2;
38405
38533
  };
38406
38534
  for (const desc of allDesc) {
38407
38535
  const innerBounds = containerBoundsMap.get(desc.data.orgNode.id);
@@ -38773,11 +38901,12 @@ function extractExportSvg(container, theme, palette) {
38773
38901
  svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
38774
38902
  svgEl.style.fontFamily = FONT_FAMILY;
38775
38903
  svgEl.querySelectorAll("[data-export-ignore]").forEach((el) => el.remove());
38776
- return svgEl.outerHTML;
38904
+ return serializeSvg(svgEl);
38777
38905
  }
38778
38906
  var init_export_container = __esm({
38779
38907
  "src/utils/export-container.ts"() {
38780
38908
  "use strict";
38909
+ init_svg_serialize();
38781
38910
  init_fonts();
38782
38911
  }
38783
38912
  });
@@ -39739,16 +39868,16 @@ function layoutSitemap(parsed, hiddenCounts, activeTagGroup, hiddenAttributes, e
39739
39868
  let totalWidth = 0;
39740
39869
  let totalHeight = 0;
39741
39870
  for (const node of layoutNodes) {
39742
- const right = node.x + node.width / 2;
39743
- const bottom = node.y + node.height;
39744
- if (right > totalWidth) totalWidth = right;
39745
- if (bottom > totalHeight) totalHeight = bottom;
39871
+ const right2 = node.x + node.width / 2;
39872
+ const bottom2 = node.y + node.height;
39873
+ if (right2 > totalWidth) totalWidth = right2;
39874
+ if (bottom2 > totalHeight) totalHeight = bottom2;
39746
39875
  }
39747
39876
  for (const c of layoutContainers) {
39748
- const right = c.x + c.width;
39749
- const bottom = c.y + c.height;
39750
- if (right > totalWidth) totalWidth = right;
39751
- if (bottom > totalHeight) totalHeight = bottom;
39877
+ const right2 = c.x + c.width;
39878
+ const bottom2 = c.y + c.height;
39879
+ if (right2 > totalWidth) totalWidth = right2;
39880
+ if (bottom2 > totalHeight) totalHeight = bottom2;
39752
39881
  }
39753
39882
  for (const edge of layoutEdges) {
39754
39883
  for (const p of edge.points) {
@@ -40378,7 +40507,7 @@ async function renderSitemapForExport(content, theme, palette) {
40378
40507
  }
40379
40508
  svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
40380
40509
  svgEl.style.fontFamily = FONT_FAMILY;
40381
- const svgHtml = svgEl.outerHTML;
40510
+ const svgHtml = serializeSvg(svgEl);
40382
40511
  document.body.removeChild(container);
40383
40512
  return svgHtml;
40384
40513
  }
@@ -40386,6 +40515,7 @@ var DIAGRAM_PADDING2, MAX_SCALE2, TITLE_HEIGHT2, ARROWHEAD_W, ARROWHEAD_H, EDGE_
40386
40515
  var init_renderer6 = __esm({
40387
40516
  "src/sitemap/renderer.ts"() {
40388
40517
  "use strict";
40518
+ init_svg_serialize();
40389
40519
  init_tag_groups();
40390
40520
  init_parsing();
40391
40521
  init_inline_header();
@@ -40819,7 +40949,7 @@ function renderKanbanForExport(content, theme, palette) {
40819
40949
  exportMode: true
40820
40950
  });
40821
40951
  const svgEl = container.querySelector("svg");
40822
- return svgEl?.outerHTML ?? "";
40952
+ return svgEl ? serializeSvg(svgEl) : "";
40823
40953
  }
40824
40954
  function drawSwimlaneIcon(parent, x, y, isActive, palette) {
40825
40955
  const iconG = parent.append("g").attr("class", "kanban-swimlane-icon").attr("transform", `translate(${x}, ${y})`);
@@ -41154,6 +41284,7 @@ var DIAGRAM_PADDING3, COLUMN_GAP, COLUMN_HEADER_HEIGHT, COLUMN_PADDING, COLUMN_M
41154
41284
  var init_renderer7 = __esm({
41155
41285
  "src/kanban/renderer.ts"() {
41156
41286
  "use strict";
41287
+ init_svg_serialize();
41157
41288
  init_tag_groups();
41158
41289
  init_parsing();
41159
41290
  init_fonts();
@@ -42667,7 +42798,7 @@ function renderERDiagramForExport(content, theme, palette) {
42667
42798
  }
42668
42799
  svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
42669
42800
  svgEl.style.fontFamily = FONT_FAMILY;
42670
- return svgEl.outerHTML;
42801
+ return serializeSvg(svgEl);
42671
42802
  } finally {
42672
42803
  document.body.removeChild(container);
42673
42804
  }
@@ -42676,6 +42807,7 @@ var DIAGRAM_PADDING5, MAX_SCALE4, TABLE_FONT_SIZE2, COLUMN_FONT_SIZE2, EDGE_LABE
42676
42807
  var init_renderer9 = __esm({
42677
42808
  "src/er/renderer.ts"() {
42678
42809
  "use strict";
42810
+ init_svg_serialize();
42679
42811
  init_tag_groups();
42680
42812
  init_parsing();
42681
42813
  init_fonts();
@@ -42785,6 +42917,16 @@ var layout_exports5 = {};
42785
42917
  __export(layout_exports5, {
42786
42918
  layoutSketch: () => layoutSketch
42787
42919
  });
42920
+ function resolveAutoFlags(f = {}) {
42921
+ return {
42922
+ normalizeOrigin: f.normalizeOrigin ?? true,
42923
+ sortRootsBySource: f.sortRootsBySource ?? true,
42924
+ resolveOverlap: f.resolveOverlap ?? true,
42925
+ groupCollisionAsRect: f.groupCollisionAsRect ?? true,
42926
+ flowPlaceUnpositioned: f.flowPlaceUnpositioned ?? true,
42927
+ avoidEdges: f.avoidEdges ?? true
42928
+ };
42929
+ }
42788
42930
  function unitRect(c, r) {
42789
42931
  return { c, r, w: SKETCH_SEP, h: SKETCH_SEP };
42790
42932
  }
@@ -42817,7 +42959,7 @@ function nearestFree(base, occupied) {
42817
42959
  }
42818
42960
  return { c: base.c, r: base.r };
42819
42961
  }
42820
- function layoutChildren(box, nodesById, warn) {
42962
+ function layoutChildren(box, nodesById, warn, flags) {
42821
42963
  const occupied = [];
42822
42964
  const children = [];
42823
42965
  const pending = [];
@@ -42829,13 +42971,17 @@ function layoutChildren(box, nodesById, warn) {
42829
42971
  continue;
42830
42972
  }
42831
42973
  const target = unitRect(node.at.c, node.at.r);
42832
- const spot = nearestFree(target, occupied);
42974
+ const spot = flags.resolveOverlap ? nearestFree(target, occupied) : { c: node.at.c, r: node.at.r };
42833
42975
  if (spot.c !== node.at.c || spot.r !== node.at.r) {
42834
42976
  warn(node.lineNumber, node.label);
42835
42977
  }
42836
42978
  occupied.push(unitRect(spot.c, spot.r));
42837
42979
  children.push({ node, c: spot.c, r: spot.r });
42838
42980
  }
42981
+ if (!flags.flowPlaceUnpositioned) {
42982
+ for (const node of pending) children.push({ node, c: 0, r: 0 });
42983
+ pending.length = 0;
42984
+ }
42839
42985
  let flowRow = occupied.length > 0 ? Math.max(...occupied.map((o) => o.r)) + SKETCH_SEP : 0;
42840
42986
  let flowCol = 0;
42841
42987
  const wrapAt = Math.max(
@@ -42882,6 +43028,7 @@ function layoutSketch(parsed, options = {}) {
42882
43028
  )
42883
43029
  );
42884
43030
  };
43031
+ const flags = resolveAutoFlags(options.autoLayout);
42885
43032
  const collapsed = collapseSketch(parsed, options.collapsedBoxes);
42886
43033
  const nodesById = new Map(collapsed.nodes.map((n) => [n.id, n]));
42887
43034
  const padHsX = SKETCH_GEOMETRY.boxPadPx / SKETCH_HALF_SLOT_X;
@@ -42890,10 +43037,39 @@ function layoutSketch(parsed, options = {}) {
42890
43037
  const boxLocal = /* @__PURE__ */ new Map();
42891
43038
  const inExpandedBox = /* @__PURE__ */ new Set();
42892
43039
  for (const box of collapsed.boxes) {
42893
- const local = layoutChildren(box, nodesById, overlapWarn);
43040
+ const local = layoutChildren(box, nodesById, overlapWarn, flags);
42894
43041
  boxLocal.set(box.id, local);
42895
43042
  for (const child of local.children) inExpandedBox.add(child.node.id);
42896
43043
  }
43044
+ const allNodesById = new Map(parsed.nodes.map((n) => [n.id, n]));
43045
+ const noWarn = () => {
43046
+ };
43047
+ const virtualLocal = /* @__PURE__ */ new Map();
43048
+ for (const box of collapsed.virtualBoxes) {
43049
+ virtualLocal.set(box.id, layoutChildren(box, allNodesById, noWarn, flags));
43050
+ }
43051
+ const footWs = SKETCH_FOOT_W / SKETCH_HALF_SLOT_X;
43052
+ const footHs = SKETCH_FOOT_H / SKETCH_HALF_SLOT_Y;
43053
+ const virtualCardSpot = (boxId, spot) => {
43054
+ const local = virtualLocal.get(boxId);
43055
+ if (local.children.length === 0) return { c: spot.c, r: spot.r };
43056
+ let minC = Infinity;
43057
+ let minR = Infinity;
43058
+ let maxC = -Infinity;
43059
+ let maxR = -Infinity;
43060
+ for (const ch of local.children) {
43061
+ minC = Math.min(minC, ch.c);
43062
+ minR = Math.min(minR, ch.r);
43063
+ maxC = Math.max(maxC, ch.c + footWs);
43064
+ maxR = Math.max(maxR, ch.r + footHs);
43065
+ }
43066
+ const cx = spot.c + (minC + maxC) / 2;
43067
+ const cy = spot.r + (minR + maxR) / 2 + (padHsY - bandHs) / 2;
43068
+ return {
43069
+ c: Math.round(cx - footWs / 2),
43070
+ r: Math.round(cy - footHs / 2)
43071
+ };
43072
+ };
42897
43073
  const rootUnits = [];
42898
43074
  for (const node of collapsed.nodes) {
42899
43075
  if (!inExpandedBox.has(node.id)) rootUnits.push({ kind: "shape", node });
@@ -42904,14 +43080,27 @@ function layoutSketch(parsed, options = {}) {
42904
43080
  for (const box of collapsed.boxes) {
42905
43081
  rootUnits.push({ kind: "box", box });
42906
43082
  }
42907
- rootUnits.sort((a, b) => {
42908
- const la = a.kind === "shape" ? a.node.lineNumber : a.box.lineNumber;
42909
- const lb = b.kind === "shape" ? b.node.lineNumber : b.box.lineNumber;
42910
- return la - lb;
42911
- });
43083
+ const lineOf = (u) => u.kind === "shape" ? u.node.lineNumber : u.box.lineNumber;
43084
+ const atOf = (u) => u.kind === "shape" ? u.node.at : u.box.at;
43085
+ if (flags.sortRootsBySource) {
43086
+ rootUnits.sort((a, b) => lineOf(a) - lineOf(b));
43087
+ } else {
43088
+ rootUnits.sort((a, b) => {
43089
+ const aa = atOf(a);
43090
+ const ba = atOf(b);
43091
+ if (aa && ba) {
43092
+ return aa.r - ba.r || aa.c - ba.c || lineOf(a) - lineOf(b);
43093
+ }
43094
+ if (aa) return -1;
43095
+ if (ba) return 1;
43096
+ return lineOf(a) - lineOf(b);
43097
+ });
43098
+ }
42912
43099
  const rectFor = (unit, c, r) => {
42913
- if (unit.kind === "box") {
42914
- const local = boxLocal.get(unit.box.id);
43100
+ if (unit.kind !== "shape" && flags.groupCollisionAsRect) {
43101
+ const local = (unit.kind === "box" ? boxLocal : virtualLocal).get(
43102
+ unit.box.id
43103
+ );
42915
43104
  return {
42916
43105
  c: c + local.extent.c - padHsX,
42917
43106
  r: r + local.extent.r - bandHs,
@@ -42925,26 +43114,31 @@ function layoutSketch(parsed, options = {}) {
42925
43114
  const placedAt = /* @__PURE__ */ new Map();
42926
43115
  const pending = [];
42927
43116
  for (const unit of rootUnits) {
42928
- const at = unit.kind === "shape" ? unit.node.at : unit.box.at;
43117
+ const at = atOf(unit);
42929
43118
  if (at === null) {
42930
43119
  pending.push(unit);
42931
43120
  continue;
42932
43121
  }
42933
43122
  const base = rectFor(unit, at.c, at.r);
42934
43123
  let spot = { c: at.c, r: at.r };
42935
- if (collidesAny(base, occupied)) {
43124
+ if (flags.resolveOverlap && unit.kind === "shape" && collidesAny(base, occupied)) {
42936
43125
  const freed = nearestFree(base, occupied);
42937
43126
  spot = {
42938
43127
  c: at.c + (freed.c - base.c),
42939
43128
  r: at.r + (freed.r - base.r)
42940
43129
  };
42941
- const line11 = unit.kind === "shape" ? unit.node.lineNumber : unit.box.lineNumber;
42942
- const label = unit.kind === "shape" ? unit.node.label : unit.box.label;
42943
- overlapWarn(line11, label);
43130
+ overlapWarn(unit.node.lineNumber, unit.node.label);
42944
43131
  }
42945
43132
  occupied.push(rectFor(unit, spot.c, spot.r));
42946
43133
  placedAt.set(unit, spot);
42947
43134
  }
43135
+ if (!flags.flowPlaceUnpositioned) {
43136
+ for (const unit of pending) {
43137
+ occupied.push(rectFor(unit, 0, 0));
43138
+ placedAt.set(unit, { c: 0, r: 0 });
43139
+ }
43140
+ pending.length = 0;
43141
+ }
42948
43142
  let flowRow = occupied.length > 0 ? Math.ceil(Math.max(...occupied.map((o) => o.r + o.h))) : 0;
42949
43143
  let flowCol = 0;
42950
43144
  const wrapAt = Math.max(
@@ -42971,8 +43165,10 @@ function layoutSketch(parsed, options = {}) {
42971
43165
  const spot = placedAt.get(u);
42972
43166
  return rectFor(u, spot.c, spot.r);
42973
43167
  });
42974
- const cMin = allRects.length > 0 ? Math.min(...allRects.map((r) => r.c)) : 0;
42975
- const rMin = allRects.length > 0 ? Math.min(...allRects.map((r) => r.r)) : 0;
43168
+ const liveCMin = allRects.length > 0 ? Math.min(...allRects.map((r) => r.c)) : 0;
43169
+ const liveRMin = allRects.length > 0 ? Math.min(...allRects.map((r) => r.r)) : 0;
43170
+ const cMin = flags.normalizeOrigin ? liveCMin : Math.min(options.frozenOrigin?.c ?? liveCMin, liveCMin);
43171
+ const rMin = flags.normalizeOrigin ? liveRMin : Math.min(options.frozenOrigin?.r ?? liveRMin, liveRMin);
42976
43172
  const toPx = (c, r) => ({
42977
43173
  x: (c - cMin) * SKETCH_HALF_SLOT_X,
42978
43174
  y: (r - rMin) * SKETCH_HALF_SLOT_Y
@@ -42997,14 +43193,15 @@ function layoutSketch(parsed, options = {}) {
42997
43193
  h: SKETCH_FOOT_H
42998
43194
  });
42999
43195
  } else if (unit.kind === "virtual") {
43000
- const { x, y } = toPx(spot.c, spot.r);
43196
+ const cardSpot = virtualCardSpot(unit.box.id, spot);
43197
+ const { x, y } = toPx(cardSpot.c, cardSpot.r);
43001
43198
  nodes.push({
43002
43199
  id: unit.box.id,
43003
43200
  label: unit.box.label,
43004
43201
  shape: "rectangle",
43005
43202
  metadata: unit.box.metadata,
43006
43203
  lineNumber: unit.box.lineNumber,
43007
- slot: spot,
43204
+ slot: cardSpot,
43008
43205
  x,
43009
43206
  y,
43010
43207
  w: SKETCH_FOOT_W,
@@ -43061,7 +43258,13 @@ function layoutSketch(parsed, options = {}) {
43061
43258
  });
43062
43259
  }
43063
43260
  }
43064
- {
43261
+ if (flags.avoidEdges) {
43262
+ const authored = /* @__PURE__ */ new Set();
43263
+ for (const unit of rootUnits) {
43264
+ if (atOf(unit) !== null) {
43265
+ authored.add(unit.kind === "shape" ? unit.node.id : unit.box.id);
43266
+ }
43267
+ }
43065
43268
  const centerOf = (id) => {
43066
43269
  const n = nodes.find((nd) => nd.id === id);
43067
43270
  if (n) return { x: n.x + n.w / 2, y: n.y + n.h / 2 };
@@ -43095,6 +43298,7 @@ function layoutSketch(parsed, options = {}) {
43095
43298
  let moved = false;
43096
43299
  for (const n of nodes) {
43097
43300
  if (n.boxLabel) continue;
43301
+ if (authored.has(n.id)) continue;
43098
43302
  for (const e of collapsed.edges) {
43099
43303
  if (e.sourceId === n.id || e.targetId === n.id) continue;
43100
43304
  const a = centerOf(e.sourceId);
@@ -43145,7 +43349,8 @@ function layoutSketch(parsed, options = {}) {
43145
43349
  edges: collapsed.edges,
43146
43350
  width,
43147
43351
  height,
43148
- diagnostics
43352
+ diagnostics,
43353
+ origin: { c: cMin, r: rMin }
43149
43354
  };
43150
43355
  }
43151
43356
  var init_layout5 = __esm({
@@ -43328,7 +43533,7 @@ function drawMarkdownBlock(container, text, opts) {
43328
43533
  const textEl = container.append("text").attr("x", line11.x).attr("y", y).attr("font-size", fontSize);
43329
43534
  let cursorX = line11.x;
43330
43535
  const segs = line11.segments.slice();
43331
- if (clamped && isLast) {
43536
+ if (clamped && isLast && !opts.noEllipsis) {
43332
43537
  segs.push({ text: ELLIPSIS, bold: false });
43333
43538
  }
43334
43539
  for (const seg of segs) {
@@ -43342,7 +43547,11 @@ function drawMarkdownBlock(container, text, opts) {
43342
43547
  cursorX += w;
43343
43548
  }
43344
43549
  }
43345
- return shown.length * lineHeight;
43550
+ return {
43551
+ height: shown.length * lineHeight,
43552
+ shown: shown.length,
43553
+ total: visualLines.length
43554
+ };
43346
43555
  }
43347
43556
  var BOLD_WIDTH_FACTOR2, INDENT_PX, BULLET_HANG_PX, ELLIPSIS, BULLET;
43348
43557
  var init_markdown_card = __esm({
@@ -43395,14 +43604,6 @@ function drawTypeBadge(g, kind, color, bx, by) {
43395
43604
  return;
43396
43605
  }
43397
43606
  }
43398
- function metaRows(metadata, tagGroups) {
43399
- const rows = [];
43400
- for (const grp of tagGroups) {
43401
- const v = metadata[tagAttrKey(grp.name)];
43402
- if (v !== void 0) rows.push([grp.name, v]);
43403
- }
43404
- return rows;
43405
- }
43406
43607
  function fitWrapped(label, maxWidth, maxFont = CARD_LABEL_MAX, minFont = CARD_LABEL_MIN, maxLines = 2) {
43407
43608
  for (let fs = maxFont; fs >= minFont; fs--) {
43408
43609
  const lines2 = wrapTextToWidth(label, fs, maxWidth, { hardBreak: true });
@@ -43421,7 +43622,8 @@ function renderSketch(container, parsed, layout, palette, isDark, options = {})
43421
43622
  const {
43422
43623
  activeTagGroup,
43423
43624
  exportMode = false,
43424
- hideDescriptions = false
43625
+ hideDescriptions = false,
43626
+ splitCardIds
43425
43627
  } = options;
43426
43628
  const hideDesc = hideDescriptions || parsed.options.noDescriptions;
43427
43629
  const neutralFill = parsed.options.fillMode === "outline" ? themeBaseBg(palette, isDark) : mix(palette.textMuted, palette.bg, 12);
@@ -43686,7 +43888,7 @@ function renderSketch(container, parsed, layout, palette, isDark, options = {})
43686
43888
  colorsFor(node.metadata),
43687
43889
  palette,
43688
43890
  isDark,
43689
- hideDesc ? [] : tagGroups
43891
+ !hideDesc && (splitCardIds?.includes(node.id) ?? false)
43690
43892
  );
43691
43893
  }
43692
43894
  const labelLayer = root.append("g").attr("class", "sk-edge-labels");
@@ -43713,7 +43915,7 @@ function drawBoxFrame(layer, box, colors, palette) {
43713
43915
  g.append("text").attr("x", box.x + box.w / 2).attr("y", startY + li * lineH).attr("text-anchor", "middle").attr("dominant-baseline", "central").attr("font-size", fit.fontSize).attr("font-weight", 800).attr("fill", palette.text).attr("opacity", BAND_LABEL_OPACITY).text(fit.lines[li]);
43714
43916
  }
43715
43917
  }
43716
- function drawNode(layer, node, colors, palette, isDark, tagGroups) {
43918
+ function drawNode(layer, node, colors, palette, isDark, splitCard) {
43717
43919
  void isDark;
43718
43920
  const g = layer.append("g").attr("class", node.isCollapsedBox ? "sk-node sk-box-collapsed" : "sk-node").attr("transform", `translate(${node.x},${node.y})`).attr("data-node-id", node.id).attr("data-line-number", node.lineNumber);
43719
43921
  for (const [k, v] of Object.entries(node.metadata)) {
@@ -43730,12 +43932,11 @@ function drawNode(layer, node, colors, palette, isDark, tagGroups) {
43730
43932
  g.append("text").attr("x", 10).attr("y", 20 + i * lineHeight).attr("font-size", NOTE_FONT_SIZE2).attr("fill", colors.text).text(line11);
43731
43933
  });
43732
43934
  } else {
43733
- const rows = node.isCollapsedBox ? [] : metaRows(node.metadata, tagGroups);
43734
43935
  const badge = node.shape !== "rectangle";
43735
43936
  const labelInset = badge ? 22 : 0;
43736
43937
  const solidLike = colors.stroke === colors.fill;
43737
43938
  const ruleColor = solidLike ? colors.text : colors.stroke;
43738
- if (node.description && !node.isCollapsedBox) {
43939
+ if (!node.isCollapsedBox && (node.description || splitCard)) {
43739
43940
  const fitH = fitWrapped(
43740
43941
  node.label,
43741
43942
  node.w - 24 - labelInset,
@@ -43756,33 +43957,37 @@ function drawNode(layer, node, colors, palette, isDark, tagGroups) {
43756
43957
  headerHeight: CARD_HEADER_H
43757
43958
  });
43758
43959
  g.append("line").attr("x1", 0).attr("y1", CARD_HEADER_H).attr("x2", node.w).attr("y2", CARD_HEADER_H).attr("stroke", ruleColor).attr("stroke-opacity", 0.3).attr("stroke-width", 1);
43759
- const inset = 12;
43760
- const bodyGap = 8;
43761
- const lh = CARD_META_FONT + 4;
43762
- const avail = node.h - CARD_HEADER_H - bodyGap - 8;
43763
- const body = g.append("g").attr("class", "sk-desc").attr("transform", `translate(${inset} ${CARD_HEADER_H + bodyGap})`);
43764
- drawMarkdownBlock(body, node.description, {
43765
- width: node.w - inset * 2,
43766
- fontSize: CARD_META_FONT,
43767
- lineHeight: lh,
43768
- color: colors.text,
43769
- // match the header label (contrast-aware in solid)
43770
- linkColor: colors.text,
43771
- maxLines: Math.max(1, Math.floor(avail / lh))
43772
- });
43960
+ if (node.description) {
43961
+ const inset = 12;
43962
+ const bodyGap = 8;
43963
+ const lh = CARD_META_FONT + 4;
43964
+ const avail = node.h - CARD_HEADER_H - bodyGap - 8;
43965
+ const body = g.append("g").attr("class", "sk-desc").attr("transform", `translate(${inset} ${CARD_HEADER_H + bodyGap})`);
43966
+ const block = drawMarkdownBlock(body, node.description, {
43967
+ width: node.w - inset * 2,
43968
+ fontSize: CARD_META_FONT,
43969
+ lineHeight: lh,
43970
+ color: colors.text,
43971
+ // match the header label (contrast-aware in solid)
43972
+ linkColor: colors.text,
43973
+ maxLines: Math.max(1, Math.floor(avail / lh)),
43974
+ noEllipsis: true
43975
+ });
43976
+ if (block.total > block.shown) {
43977
+ g.append("text").attr("class", "sk-desc-more").attr("x", node.w - 8).attr("y", node.h - 5).attr("text-anchor", "end").attr("font-size", 9).attr("fill", palette.textMuted).attr("data-line-number", node.lineNumber).style("cursor", "pointer").text(`+${block.total - block.shown} more in source`);
43978
+ }
43979
+ }
43773
43980
  if (badge) {
43774
43981
  drawTypeBadge(g, node.shape, colors.text, 10, (CARD_HEADER_H - 16) / 2);
43775
43982
  }
43776
43983
  return;
43777
43984
  }
43778
- const headerH = rows.length ? CARD_HEADER_H : node.h;
43779
- const fillTitle = rows.length === 0;
43780
43985
  const fit = fitWrapped(
43781
43986
  node.label,
43782
43987
  node.w - 24 - labelInset,
43783
- fillTitle ? CARD_TITLE_MAX : CARD_LABEL_MAX,
43988
+ CARD_TITLE_MAX,
43784
43989
  CARD_LABEL_MIN,
43785
- fillTitle ? 3 : 2
43990
+ 3
43786
43991
  );
43787
43992
  renderNodeCard(g, {
43788
43993
  width: node.w,
@@ -43795,18 +44000,7 @@ function drawNode(layer, node, colors, palette, isDark, tagGroups) {
43795
44000
  labelLines: fit.lines,
43796
44001
  labelColor: colors.text,
43797
44002
  labelFontSize: fit.fontSize,
43798
- headerHeight: headerH,
43799
- ...rows.length ? {
43800
- meta: {
43801
- rows,
43802
- fontSize: CARD_META_FONT,
43803
- lineHeight: CARD_META_FONT + 5,
43804
- separatorGap: 8,
43805
- separatorColor: ruleColor,
43806
- textColor: solidLike ? colors.text : palette.text,
43807
- keyX: 12
43808
- }
43809
- } : {}
44003
+ headerHeight: node.h
43810
44004
  });
43811
44005
  if (badge) {
43812
44006
  drawTypeBadge(g, node.shape, colors.text, 10, (CARD_HEADER_H - 16) / 2);
@@ -43842,8 +44036,8 @@ function assignEdgeSides(edges, rectById) {
43842
44036
  return { s: below ? "B" : "T", t: below ? "T" : "B" };
43843
44037
  }
43844
44038
  if (yOverlap >= 0 && yOverlap >= xOverlap) {
43845
- const right = dx >= 0;
43846
- return { s: right ? "R" : "L", t: right ? "L" : "R" };
44039
+ const right2 = dx >= 0;
44040
+ return { s: right2 ? "R" : "L", t: right2 ? "L" : "R" };
43847
44041
  }
43848
44042
  return { s: facing(dx, dy), t: facing(-dx, -dy) };
43849
44043
  });
@@ -44059,6 +44253,8 @@ function sketchEdgeGeometry(layout, offsets) {
44059
44253
  const n = normalOf(side);
44060
44254
  return 1 - (n.x * dx + n.y * dy) / len;
44061
44255
  };
44256
+ const W_BACK = 2.6;
44257
+ const backFacingCost = (from, to, side) => W_BACK * Math.max(0, facingCost(from, to, side) - 1);
44062
44258
  const ctx = layout.edges.map((edge) => {
44063
44259
  const source = rectById.get(edge.sourceId);
44064
44260
  const target = rectById.get(edge.targetId);
@@ -44093,6 +44289,7 @@ function sketchEdgeGeometry(layout, offsets) {
44093
44289
  const W_NODE = 100;
44094
44290
  const W_EDGE = 8;
44095
44291
  const W_PORT = 1.5;
44292
+ const W_PORT_SAME = 0.6;
44096
44293
  const isBox = (id) => portsById.has(id);
44097
44294
  const portClashCount = (self, s, t) => {
44098
44295
  const e = layout.edges[self];
@@ -44110,6 +44307,44 @@ function sketchEdgeGeometry(layout, offsets) {
44110
44307
  }
44111
44308
  return n;
44112
44309
  };
44310
+ const portStackCount = (self, _s, t) => {
44311
+ const e = layout.edges[self];
44312
+ if (isBox(e.targetId)) return 0;
44313
+ let n = 0;
44314
+ for (let j = 0; j < layout.edges.length; j++) {
44315
+ if (j === self) continue;
44316
+ const ej = layout.edges[j];
44317
+ if (ej.targetId === e.targetId && ej.sourceId !== e.sourceId && // not reciprocal
44318
+ chosen[j].t === t)
44319
+ n++;
44320
+ }
44321
+ return n;
44322
+ };
44323
+ const W_TURN = 0.55;
44324
+ const W_SCURVE = 1.8;
44325
+ const CURVE_STRAIGHT = 0.35;
44326
+ const curveCostPoly = (pts) => {
44327
+ let totalTurn = 0;
44328
+ let inflections = 0;
44329
+ let prevSign = 0;
44330
+ for (let i = 1; i < pts.length - 1; i++) {
44331
+ const ax = pts[i].x - pts[i - 1].x;
44332
+ const ay = pts[i].y - pts[i - 1].y;
44333
+ const bx = pts[i + 1].x - pts[i].x;
44334
+ const by = pts[i + 1].y - pts[i].y;
44335
+ const cross = ax * by - ay * bx;
44336
+ const dot = ax * bx + ay * by;
44337
+ if (ax === 0 && ay === 0) continue;
44338
+ if (bx === 0 && by === 0) continue;
44339
+ totalTurn += Math.abs(Math.atan2(cross, dot));
44340
+ const sign = cross > 1e-6 ? 1 : cross < -1e-6 ? -1 : 0;
44341
+ if (sign !== 0) {
44342
+ if (prevSign !== 0 && sign !== prevSign) inflections++;
44343
+ prevSign = sign;
44344
+ }
44345
+ }
44346
+ return totalTurn * W_TURN + inflections * W_SCURVE;
44347
+ };
44113
44348
  const scoreOf = (c, g, poly, self, polys2, s, t) => {
44114
44349
  let edgeCross = 0;
44115
44350
  for (let j = 0; j < polys2.length; j++) {
@@ -44117,7 +44352,7 @@ function sketchEdgeGeometry(layout, offsets) {
44117
44352
  const pj = polys2[j];
44118
44353
  if (pj) edgeCross += polyCrossings(poly, pj);
44119
44354
  }
44120
- return pathCrossings(g, c.obstacleRects) * W_NODE + edgeCross * W_EDGE + portClashCount(self, s, t) * W_PORT + facingCost(c.source, c.target, s) + facingCost(c.target, c.source, t);
44355
+ return pathCrossings(g, c.obstacleRects) * W_NODE + edgeCross * W_EDGE + portClashCount(self, s, t) * W_PORT + portStackCount(self, s, t) * W_PORT_SAME + curveCostPoly(poly) + facingCost(c.source, c.target, s) + facingCost(c.target, c.source, t) + backFacingCost(c.source, c.target, s) + backFacingCost(c.target, c.source, t);
44121
44356
  };
44122
44357
  const chosen = layout.edges.map(
44123
44358
  (_, i) => sides[i] ?? { s: "R", t: "L" }
@@ -44142,7 +44377,8 @@ function sketchEdgeGeometry(layout, offsets) {
44142
44377
  if (!c || !g || !p) continue;
44143
44378
  const cur = chosen[i];
44144
44379
  const curScore = scoreOf(c, g, p, i, polys, cur.s, cur.t);
44145
- if (curScore < W_EDGE && portClashCount(i, cur.s, cur.t) === 0) continue;
44380
+ if (curScore < W_EDGE && portClashCount(i, cur.s, cur.t) === 0 && portStackCount(i, cur.s, cur.t) === 0 && curveCostPoly(p) < CURVE_STRAIGHT && backFacingCost(c.source, c.target, cur.s) === 0 && backFacingCost(c.target, c.source, cur.t) === 0)
44381
+ continue;
44146
44382
  let bestScore = curScore;
44147
44383
  let bestG = g;
44148
44384
  let bestP = p;
@@ -44219,8 +44455,8 @@ var init_renderer10 = __esm({
44219
44455
  NODE_STROKE_WIDTH2 = 2;
44220
44456
  EDGE_STROKE_WIDTH2 = 2;
44221
44457
  EDGE_HIT_WIDTH = 18;
44222
- ARROWHEAD_W2 = 12;
44223
- ARROWHEAD_H2 = 8;
44458
+ ARROWHEAD_W2 = 18;
44459
+ ARROWHEAD_H2 = 12;
44224
44460
  DASH = "6 3";
44225
44461
  BAND_LABEL_FONT_SIZE = 19;
44226
44462
  BAND_LABEL_OPACITY = 0.55;
@@ -44587,6 +44823,18 @@ function renderBoxesAndLines(container, parsed, layout, palette, isDark, options
44587
44823
  for (let li = 0; li < fitted.lines.length; li++) {
44588
44824
  groupG.append("text").attr("class", "bl-group-label").attr("x", group.x).attr("y", group.y - totalH / 2 + lineH / 2 + li * lineH).attr("text-anchor", "middle").attr("dominant-baseline", "central").attr("font-family", FONT_FAMILY).attr("font-size", fitted.fontSize).attr("font-weight", "600").attr("fill", palette.text).text(fitted.lines[li]);
44589
44825
  }
44826
+ if (group.childCount !== void 0 && group.childCount > 0) {
44827
+ const chipFont = Math.max(9, sMinNodeFontSize - 2);
44828
+ const chipH = chipFont + 7;
44829
+ const chipW = Math.max(
44830
+ chipH,
44831
+ String(group.childCount).length * chipFont * 0.62 + 10
44832
+ );
44833
+ const chipCx = gx + group.width - chipW / 2 - 6;
44834
+ const chipCy = gy + chipH / 2 + 6;
44835
+ groupG.append("rect").attr("class", "bl-collapse-count").attr("x", chipCx - chipW / 2).attr("y", chipCy - chipH / 2).attr("width", chipW).attr("height", chipH).attr("rx", chipH / 2).attr("ry", chipH / 2).attr("fill", palette.textMuted).attr("fill-opacity", 0.18);
44836
+ groupG.append("text").attr("class", "bl-collapse-count").attr("x", chipCx).attr("y", chipCy).attr("text-anchor", "middle").attr("dominant-baseline", "central").attr("font-family", FONT_FAMILY).attr("font-size", chipFont).attr("font-weight", "600").attr("fill", palette.text).text(String(group.childCount));
44837
+ }
44590
44838
  } else {
44591
44839
  groupG.append("rect").attr("x", gx).attr("y", gy).attr("width", group.width).attr("height", groupHeight).attr("rx", GROUP_RX).attr("ry", GROUP_RX).attr("fill", mix(palette.surface, palette.bg, 40)).attr("stroke", palette.textMuted).attr("stroke-width", 1).attr("stroke-opacity", 0.35);
44592
44840
  groupG.append("text").attr("class", "bl-group-label").attr("x", gx + group.width / 2).attr("y", gy + 18).attr("text-anchor", "middle").attr("font-family", FONT_FAMILY).attr("font-size", sGroupLabelFontSize).attr("font-weight", "600").attr("fill", palette.text).text(group.label);
@@ -45003,6 +45251,17 @@ var init_renderer11 = __esm({
45003
45251
  }
45004
45252
  });
45005
45253
 
45254
+ // src/boxes-and-lines/node-metrics.ts
45255
+ var PHI, NODE_HEIGHT, NODE_WIDTH;
45256
+ var init_node_metrics = __esm({
45257
+ "src/boxes-and-lines/node-metrics.ts"() {
45258
+ "use strict";
45259
+ PHI = 1.618;
45260
+ NODE_HEIGHT = 60;
45261
+ NODE_WIDTH = Math.round(NODE_HEIGHT * PHI);
45262
+ }
45263
+ });
45264
+
45006
45265
  // src/boxes-and-lines/label-placement.ts
45007
45266
  function measureEdgeLabel(label, fontSize = EDGE_LABEL_FONT_SIZE7, maxWidth = LABEL_MAX_WIDTH) {
45008
45267
  let lines = wrapTextToWidth(label, fontSize, maxWidth, { hardBreak: true });
@@ -45384,9 +45643,9 @@ function layeredCandidates(parsed, sizes, opts) {
45384
45643
  const m = Math.floor(vals.length / 2);
45385
45644
  if (vals.length % 2 === 1) return vals[m];
45386
45645
  if (vals.length === 2) return (vals[0] + vals[1]) / 2;
45387
- const left = vals[m - 1] - vals[0];
45388
- const right = vals[vals.length - 1] - vals[m];
45389
- return left + right === 0 ? (vals[m - 1] + vals[m]) / 2 : (vals[m - 1] * right + vals[m] * left) / (left + right);
45646
+ const left2 = vals[m - 1] - vals[0];
45647
+ const right2 = vals[vals.length - 1] - vals[m];
45648
+ return left2 + right2 === 0 ? (vals[m - 1] + vals[m]) / 2 : (vals[m - 1] * right2 + vals[m] * left2) / (left2 + right2);
45390
45649
  };
45391
45650
  const wmedianRank = (r, useUp) => {
45392
45651
  const ids = ranks[r];
@@ -45712,7 +45971,7 @@ var NODESEP, RANKSEP, DUMMY_THICK, MARGIN4, W_REAL_REAL, W_REAL_DUMMY, W_DUMMY_D
45712
45971
  var init_layout_layered = __esm({
45713
45972
  "src/boxes-and-lines/layout-layered.ts"() {
45714
45973
  "use strict";
45715
- init_layout6();
45974
+ init_node_metrics();
45716
45975
  NODESEP = 50;
45717
45976
  RANKSEP = 60;
45718
45977
  DUMMY_THICK = 10;
@@ -45739,9 +45998,9 @@ function median(vals) {
45739
45998
  const m = Math.floor(vals.length / 2);
45740
45999
  if (vals.length % 2 === 1) return vals[m];
45741
46000
  if (vals.length === 2) return (vals[0] + vals[1]) / 2;
45742
- const left = vals[m - 1] - vals[0];
45743
- const right = vals[vals.length - 1] - vals[m];
45744
- return left + right === 0 ? (vals[m - 1] + vals[m]) / 2 : (vals[m - 1] * right + vals[m] * left) / (left + right);
46001
+ const left2 = vals[m - 1] - vals[0];
46002
+ const right2 = vals[vals.length - 1] - vals[m];
46003
+ return left2 + right2 === 0 ? (vals[m - 1] + vals[m]) / 2 : (vals[m - 1] * right2 + vals[m] * left2) / (left2 + right2);
45745
46004
  }
45746
46005
  function acyclicOrient(ids, edges) {
45747
46006
  const adj = /* @__PURE__ */ new Map();
@@ -46397,7 +46656,7 @@ var NODESEP2, RANKSEP2, DUMMY_THICK2, MARGIN5, GROUP_PAD, GROUP_LABEL_ZONE2, GRO
46397
46656
  var init_layout_grouped = __esm({
46398
46657
  "src/boxes-and-lines/layout-grouped.ts"() {
46399
46658
  "use strict";
46400
- init_layout6();
46659
+ init_node_metrics();
46401
46660
  NODESEP2 = 50;
46402
46661
  RANKSEP2 = 60;
46403
46662
  DUMMY_THICK2 = 10;
@@ -46412,6 +46671,282 @@ var init_layout_grouped = __esm({
46412
46671
  }
46413
46672
  });
46414
46673
 
46674
+ // src/boxes-and-lines/layout-stable-collapse.ts
46675
+ function bboxOf(rects) {
46676
+ let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;
46677
+ for (const r of rects) {
46678
+ x0 = Math.min(x0, left(r));
46679
+ y0 = Math.min(y0, top(r));
46680
+ x1 = Math.max(x1, right(r));
46681
+ y1 = Math.max(y1, bottom(r));
46682
+ }
46683
+ return {
46684
+ x: (x0 + x1) / 2,
46685
+ y: (y0 + y1) / 2,
46686
+ width: x1 - x0,
46687
+ height: y1 - y0
46688
+ };
46689
+ }
46690
+ function borderPoint(rect2, toward) {
46691
+ const dx = toward.x - rect2.x;
46692
+ const dy = toward.y - rect2.y;
46693
+ const sx = dx === 0 ? Infinity : rect2.width / 2 / Math.abs(dx);
46694
+ const sy = dy === 0 ? Infinity : rect2.height / 2 / Math.abs(dy);
46695
+ const s = Math.min(sx, sy);
46696
+ if (!Number.isFinite(s)) return { x: rect2.x, y: rect2.y };
46697
+ return { x: rect2.x + dx * s, y: rect2.y + dy * s };
46698
+ }
46699
+ function tryStableCollapseLayout(input) {
46700
+ const {
46701
+ parsed,
46702
+ collapseInfo,
46703
+ collapsedGroupLabels,
46704
+ previousPositions,
46705
+ sizes
46706
+ } = input;
46707
+ const prev = previousPositions;
46708
+ const rects = /* @__PURE__ */ new Map();
46709
+ for (const n of parsed.nodes) {
46710
+ const p = prev.get(n.label);
46711
+ const s = sizes.get(n.label);
46712
+ if (!p || !s) return null;
46713
+ rects.set(n.label, { x: p.x, y: p.y, width: s.width, height: s.height });
46714
+ }
46715
+ const ogByLabel = /* @__PURE__ */ new Map();
46716
+ for (const g of collapseInfo.originalGroups) ogByLabel.set(g.label, g);
46717
+ const descendantNodes = (label, seen = /* @__PURE__ */ new Set()) => {
46718
+ if (seen.has(label)) return [];
46719
+ seen.add(label);
46720
+ const g = ogByLabel.get(label);
46721
+ if (!g) return [];
46722
+ const out = [];
46723
+ for (const c of g.children) {
46724
+ if (ogByLabel.has(c)) out.push(...descendantNodes(c, seen));
46725
+ else out.push(c);
46726
+ }
46727
+ return out;
46728
+ };
46729
+ const newlyCollapsed = [];
46730
+ for (const label of collapsedGroupLabels) {
46731
+ const own = prev.get(gid(label));
46732
+ if (own) {
46733
+ rects.set(gid(label), {
46734
+ x: own.x,
46735
+ y: own.y,
46736
+ width: NODE_WIDTH,
46737
+ height: NODE_HEIGHT
46738
+ });
46739
+ continue;
46740
+ }
46741
+ const members = descendantNodes(label);
46742
+ if (members.length === 0) return null;
46743
+ const memberRects = [];
46744
+ for (const m of members) {
46745
+ const p = prev.get(m);
46746
+ if (!p) return null;
46747
+ memberRects.push({
46748
+ x: p.x,
46749
+ y: p.y,
46750
+ width: NODE_WIDTH,
46751
+ height: NODE_HEIGHT
46752
+ });
46753
+ }
46754
+ const bbox = bboxOf(memberRects);
46755
+ rects.set(gid(label), {
46756
+ x: bbox.x,
46757
+ y: bbox.y,
46758
+ width: NODE_WIDTH,
46759
+ height: NODE_HEIGHT
46760
+ });
46761
+ newlyCollapsed.push({ label, memberBbox: bbox });
46762
+ }
46763
+ const groupByLabel = new Map(parsed.groups.map((g) => [g.label, g]));
46764
+ const inUnit = /* @__PURE__ */ new Set();
46765
+ const unitKeys = (label, seen = /* @__PURE__ */ new Set()) => {
46766
+ if (seen.has(label)) return [];
46767
+ seen.add(label);
46768
+ const g = groupByLabel.get(label);
46769
+ if (!g) return [];
46770
+ const out = [];
46771
+ for (const c of g.children) {
46772
+ if (groupByLabel.has(c)) out.push(...unitKeys(c, seen));
46773
+ else if (rects.has(c)) out.push(c);
46774
+ else if (rects.has(gid(c))) out.push(gid(c));
46775
+ }
46776
+ return out;
46777
+ };
46778
+ const units = [];
46779
+ for (const g of parsed.groups) {
46780
+ if (g.parentGroup) continue;
46781
+ const keys = unitKeys(g.label);
46782
+ if (keys.length === 0) continue;
46783
+ for (const k of keys) inUnit.add(k);
46784
+ units.push(keys);
46785
+ }
46786
+ for (const key of rects.keys()) if (!inUnit.has(key)) units.push([key]);
46787
+ const axes = ["x", "y"];
46788
+ for (const { label, memberBbox } of newlyCollapsed) {
46789
+ const pill = rects.get(gid(label));
46790
+ for (const axis of axes) {
46791
+ const size = axis === "x" ? "width" : "height";
46792
+ const perpMin = axis === "x" ? top : left;
46793
+ const perpMax = axis === "x" ? bottom : right;
46794
+ const axMin = axis === "x" ? left : top;
46795
+ const axMax = axis === "x" ? right : bottom;
46796
+ const reclaim = memberBbox[size] - pill[size];
46797
+ if (reclaim <= 0) continue;
46798
+ const unitBbox = (keys) => bboxOf(keys.map((k) => rects.get(k)));
46799
+ const sliding = [];
46800
+ const staticRects = [];
46801
+ for (const u of units) {
46802
+ const b = unitBbox(u);
46803
+ if (axMin(b) >= pill[axis] && !u.includes(gid(label))) sliding.push(u);
46804
+ else staticRects.push(...u.map((k) => rects.get(k)));
46805
+ }
46806
+ if (sliding.length === 0) continue;
46807
+ let delta = reclaim;
46808
+ for (const u of sliding) {
46809
+ const b = unitBbox(u);
46810
+ for (const s of staticRects) {
46811
+ const overlaps = perpMin(b) < perpMax(s) - 4 && perpMax(b) > perpMin(s) + 4;
46812
+ if (!overlaps || axMax(s) > axMin(b)) continue;
46813
+ delta = Math.min(delta, axMin(b) - axMax(s) - MIN_GAP);
46814
+ }
46815
+ }
46816
+ if (delta <= 0) continue;
46817
+ for (const u of sliding)
46818
+ for (const k of u) {
46819
+ const r = rects.get(k);
46820
+ rects.set(k, { ...r, [axis]: r[axis] - delta });
46821
+ }
46822
+ }
46823
+ }
46824
+ const groupRect = /* @__PURE__ */ new Map();
46825
+ const buildGroupRect = (label, seen = /* @__PURE__ */ new Set()) => {
46826
+ if (groupRect.has(label)) return groupRect.get(label);
46827
+ if (seen.has(label)) return null;
46828
+ seen.add(label);
46829
+ const g = groupByLabel.get(label);
46830
+ if (!g) return null;
46831
+ const memberRects = [];
46832
+ for (const c of g.children) {
46833
+ if (groupByLabel.has(c)) {
46834
+ const sub = buildGroupRect(c, seen);
46835
+ if (sub) memberRects.push(sub);
46836
+ } else if (rects.has(c)) memberRects.push(rects.get(c));
46837
+ else if (rects.has(gid(c))) memberRects.push(rects.get(gid(c)));
46838
+ }
46839
+ if (memberRects.length === 0) return null;
46840
+ const b = bboxOf(memberRects);
46841
+ const rect2 = {
46842
+ x: b.x,
46843
+ y: b.y - GROUP_LABEL_ZONE3 / 2,
46844
+ width: b.width + 2 * GROUP_PAD2,
46845
+ height: b.height + 2 * GROUP_PAD2 + GROUP_LABEL_ZONE3
46846
+ };
46847
+ groupRect.set(label, rect2);
46848
+ return rect2;
46849
+ };
46850
+ for (const g of parsed.groups) if (!buildGroupRect(g.label)) return null;
46851
+ const boxes = [...rects.values()];
46852
+ for (let i = 0; i < boxes.length; i++)
46853
+ for (let j = i + 1; j < boxes.length; j++) {
46854
+ const a = boxes[i];
46855
+ const b = boxes[j];
46856
+ if (Math.abs(a.x - b.x) < (a.width + b.width) / 2 - 4 && Math.abs(a.y - b.y) < (a.height + b.height) / 2 - 4)
46857
+ return null;
46858
+ }
46859
+ const endpointRect = (key) => {
46860
+ const direct = rects.get(key);
46861
+ if (direct) return direct;
46862
+ if (key.startsWith("__group_")) {
46863
+ const label = key.slice("__group_".length);
46864
+ return groupRect.get(label) ?? null;
46865
+ }
46866
+ return groupRect.get(key) ?? null;
46867
+ };
46868
+ const edges = [];
46869
+ for (const e of parsed.edges) {
46870
+ const sr = endpointRect(e.source);
46871
+ const tr = endpointRect(e.target);
46872
+ if (!sr || !tr) return null;
46873
+ edges.push({
46874
+ source: e.source,
46875
+ target: e.target,
46876
+ ...e.label !== void 0 && { label: e.label },
46877
+ bidirectional: e.bidirectional,
46878
+ lineNumber: e.lineNumber,
46879
+ points: [borderPoint(sr, tr), borderPoint(tr, sr)],
46880
+ yOffset: 0,
46881
+ parallelCount: 1,
46882
+ metadata: e.metadata
46883
+ });
46884
+ }
46885
+ const allRects = [...rects.values(), ...groupRect.values()];
46886
+ const total = bboxOf(allRects);
46887
+ const dx = MARGIN6 - left(total);
46888
+ const dy = MARGIN6 - top(total);
46889
+ const shift = (r) => ({ ...r, x: r.x + dx, y: r.y + dy });
46890
+ const nodes = parsed.nodes.map((n) => {
46891
+ const r = shift(rects.get(n.label));
46892
+ return { label: n.label, x: r.x, y: r.y, width: r.width, height: r.height };
46893
+ });
46894
+ const groups = parsed.groups.map((g) => {
46895
+ const r = shift(groupRect.get(g.label));
46896
+ return {
46897
+ label: g.label,
46898
+ lineNumber: g.lineNumber,
46899
+ x: r.x,
46900
+ y: r.y,
46901
+ width: r.width,
46902
+ height: r.height,
46903
+ collapsed: false,
46904
+ childCount: g.children.length
46905
+ };
46906
+ });
46907
+ for (const label of collapsedGroupLabels) {
46908
+ const r = shift(rects.get(gid(label)));
46909
+ groups.push({
46910
+ label,
46911
+ lineNumber: 0,
46912
+ x: r.x,
46913
+ y: r.y,
46914
+ width: r.width,
46915
+ height: r.height,
46916
+ collapsed: true,
46917
+ childCount: collapseInfo.collapsedChildCounts.get(label) ?? 0
46918
+ });
46919
+ }
46920
+ const shiftedEdges = edges.map((e) => ({
46921
+ ...e,
46922
+ points: e.points.map((p) => ({ x: p.x + dx, y: p.y + dy }))
46923
+ }));
46924
+ const shiftedTotal = shift(total);
46925
+ return {
46926
+ nodes,
46927
+ edges: shiftedEdges,
46928
+ groups,
46929
+ width: right(shiftedTotal) + MARGIN6,
46930
+ height: bottom(shiftedTotal) + MARGIN6
46931
+ };
46932
+ }
46933
+ var GROUP_PAD2, GROUP_LABEL_ZONE3, MARGIN6, MIN_GAP, gid, left, right, top, bottom;
46934
+ var init_layout_stable_collapse = __esm({
46935
+ "src/boxes-and-lines/layout-stable-collapse.ts"() {
46936
+ "use strict";
46937
+ init_node_metrics();
46938
+ GROUP_PAD2 = 16;
46939
+ GROUP_LABEL_ZONE3 = 32;
46940
+ MARGIN6 = 40;
46941
+ MIN_GAP = 36;
46942
+ gid = (label) => `__group_${label}`;
46943
+ left = (r) => r.x - r.width / 2;
46944
+ right = (r) => r.x + r.width / 2;
46945
+ top = (r) => r.y - r.height / 2;
46946
+ bottom = (r) => r.y + r.height / 2;
46947
+ }
46948
+ });
46949
+
46415
46950
  // src/boxes-and-lines/layout-search.ts
46416
46951
  var layout_search_exports = {};
46417
46952
  __export(layout_search_exports, {
@@ -46784,7 +47319,7 @@ function detectGroupOverlaps(layout, opts) {
46784
47319
  const contains = (outer, inner) => outer.l <= inner.l + margin && outer.r >= inner.r - margin && outer.t <= inner.t + margin && outer.b >= inner.b - margin;
46785
47320
  const rend = raw.map((a, i) => {
46786
47321
  const parent = raw.some((b, j) => j !== i && contains(a, b));
46787
- return parent ? { ...a, t: a.t - GROUP_LABEL_ZONE3 } : a;
47322
+ return parent ? { ...a, t: a.t - GROUP_LABEL_ZONE4 } : a;
46788
47323
  });
46789
47324
  const hit = /* @__PURE__ */ new Set();
46790
47325
  for (let i = 0; i < raw.length; i++)
@@ -46811,7 +47346,7 @@ function countGroupOverlaps(layout, opts) {
46811
47346
  const contains = (outer, inner) => outer.l <= inner.l + margin && outer.r >= inner.r - margin && outer.t <= inner.t + margin && outer.b >= inner.b - margin;
46812
47347
  const rend = raw.map((a, i) => {
46813
47348
  const parent = raw.some((b, j) => j !== i && contains(a, b));
46814
- return parent ? { ...a, t: a.t - GROUP_LABEL_ZONE3 } : a;
47349
+ return parent ? { ...a, t: a.t - GROUP_LABEL_ZONE4 } : a;
46815
47350
  });
46816
47351
  let count = 0;
46817
47352
  for (let i = 0; i < raw.length; i++)
@@ -46854,7 +47389,7 @@ function separateGroupBands(layout, parsed) {
46854
47389
  let lo = (axis === "y" ? g.y : g.x) - half2;
46855
47390
  const hi = (axis === "y" ? g.y : g.x) + half2;
46856
47391
  const isParent = parsed.groups.some((c) => c.parentGroup === label);
46857
- if (axis === "y" && isParent) lo -= GROUP_LABEL_ZONE3;
47392
+ if (axis === "y" && isParent) lo -= GROUP_LABEL_ZONE4;
46858
47393
  return { label, lo, hi, c: (lo + hi) / 2 };
46859
47394
  });
46860
47395
  bands.sort((a, b) => a.c - b.c);
@@ -46890,8 +47425,8 @@ function separateGroupBands(layout, parsed) {
46890
47425
  const nodeDelta = (label) => {
46891
47426
  if (label.startsWith("__group_"))
46892
47427
  return delta.get(topOf(label.slice("__group_".length))) ?? 0;
46893
- const top = nodeTop.get(label);
46894
- return top ? delta.get(top) ?? 0 : 0;
47428
+ const top2 = nodeTop.get(label);
47429
+ return top2 ? delta.get(top2) ?? 0 : 0;
46895
47430
  };
46896
47431
  const shift = (p, d) => axis === "y" ? { x: p.x, y: p.y + d } : { x: p.x + d, y: p.y };
46897
47432
  const nodes = layout.nodes.map((n) => {
@@ -46925,7 +47460,7 @@ function separateGroupBands(layout, parsed) {
46925
47460
  acc(n.x + n.width / 2, n.y + n.height / 2);
46926
47461
  }
46927
47462
  for (const g of groups) {
46928
- acc(g.x - g.width / 2, g.y - g.height / 2 - GROUP_LABEL_ZONE3);
47463
+ acc(g.x - g.width / 2, g.y - g.height / 2 - GROUP_LABEL_ZONE4);
46929
47464
  acc(g.x + g.width / 2, g.y + g.height / 2);
46930
47465
  }
46931
47466
  for (const e of edges) for (const p of e.points) acc(p.x, p.y);
@@ -47044,8 +47579,19 @@ async function layoutBoxesAndLinesSearch(parsed, collapseInfo, opts) {
47044
47579
  sizes.set(node.label, { width: s.width, height: maxDescH });
47045
47580
  }
47046
47581
  }
47047
- const gid = (label) => `__group_${label}`;
47582
+ const gid2 = (label) => `__group_${label}`;
47048
47583
  const rankdir = parsed.direction === "TB" ? "TB" : "LR";
47584
+ if (opts?.stableCollapse && collapseInfo && collapsedGroupLabels.size > 0 && opts.previousPositions) {
47585
+ const stable = tryStableCollapseLayout({
47586
+ parsed,
47587
+ collapseInfo,
47588
+ collapsedGroupLabels,
47589
+ previousPositions: opts.previousPositions,
47590
+ sizes,
47591
+ rankdir
47592
+ });
47593
+ if (stable) return stable;
47594
+ }
47049
47595
  const nodeLabelSet = new Set(parsed.nodes.map((n2) => n2.label));
47050
47596
  const directNodeChildren = /* @__PURE__ */ new Map();
47051
47597
  const childGroupsOf = /* @__PURE__ */ new Map();
@@ -47103,8 +47649,8 @@ async function layoutBoxesAndLinesSearch(parsed, collapseInfo, opts) {
47103
47649
  if (rankOf(mem) > rankOf(exit)) exit = mem;
47104
47650
  if (rankOf(mem) < rankOf(entry)) entry = mem;
47105
47651
  }
47106
- gidSourceRep.set(gid(grp.label), exit);
47107
- gidTargetRep.set(gid(grp.label), entry);
47652
+ gidSourceRep.set(gid2(grp.label), exit);
47653
+ gidTargetRep.set(gid2(grp.label), entry);
47108
47654
  }
47109
47655
  const srcRep = (label) => gidSourceRep.get(label) ?? label;
47110
47656
  const tgtRep = (label) => gidTargetRep.get(label) ?? label;
@@ -47134,25 +47680,25 @@ async function layoutBoxesAndLinesSearch(parsed, collapseInfo, opts) {
47134
47680
  });
47135
47681
  g.setDefaultEdgeLabel(() => ({}));
47136
47682
  for (const grp of ord(parsed.groups))
47137
- g.setNode(gid(grp.label), { label: grp.label });
47683
+ g.setNode(gid2(grp.label), { label: grp.label });
47138
47684
  for (const node of ord(parsed.nodes)) {
47139
47685
  const s = sizes.get(node.label);
47140
47686
  g.setNode(node.label, { width: s.width, height: s.height });
47141
47687
  }
47142
47688
  for (const label of collapsedGroupLabels)
47143
- g.setNode(gid(label), { width: NODE_WIDTH, height: NODE_HEIGHT });
47689
+ g.setNode(gid2(label), { width: NODE_WIDTH, height: NODE_HEIGHT });
47144
47690
  for (const grp of parsed.groups) {
47145
- if (grp.parentGroup && g.hasNode(gid(grp.parentGroup)))
47146
- g.setParent(gid(grp.label), gid(grp.parentGroup));
47691
+ if (grp.parentGroup && g.hasNode(gid2(grp.parentGroup)))
47692
+ g.setParent(gid2(grp.label), gid2(grp.parentGroup));
47147
47693
  for (const c of ord(grp.children)) {
47148
- if (g.hasNode(c)) g.setParent(c, gid(grp.label));
47694
+ if (g.hasNode(c)) g.setParent(c, gid2(grp.label));
47149
47695
  }
47150
47696
  }
47151
47697
  if (collapseInfo)
47152
47698
  for (const label of collapsedGroupLabels) {
47153
47699
  const og = collapseInfo.originalGroups.find((x) => x.label === label);
47154
- if (og?.parentGroup && !collapsedGroupLabels.has(og.parentGroup) && g.hasNode(gid(og.parentGroup)))
47155
- g.setParent(gid(label), gid(og.parentGroup));
47700
+ if (og?.parentGroup && !collapsedGroupLabels.has(og.parentGroup) && g.hasNode(gid2(og.parentGroup)))
47701
+ g.setParent(gid2(label), gid2(og.parentGroup));
47156
47702
  }
47157
47703
  for (const e of ord(parsed.edges)) {
47158
47704
  const s = srcRep(e.source);
@@ -47179,7 +47725,7 @@ async function layoutBoxesAndLinesSearch(parsed, collapseInfo, opts) {
47179
47725
  });
47180
47726
  const groups = parsed.groups.map(
47181
47727
  (grp) => {
47182
- const p = g.node(gid(grp.label));
47728
+ const p = g.node(gid2(grp.label));
47183
47729
  return {
47184
47730
  label: grp.label,
47185
47731
  lineNumber: grp.lineNumber,
@@ -47193,7 +47739,7 @@ async function layoutBoxesAndLinesSearch(parsed, collapseInfo, opts) {
47193
47739
  }
47194
47740
  );
47195
47741
  for (const label of collapsedGroupLabels) {
47196
- const p = g.node(gid(label));
47742
+ const p = g.node(gid2(label));
47197
47743
  groups.push({
47198
47744
  label,
47199
47745
  lineNumber: 0,
@@ -47207,9 +47753,9 @@ async function layoutBoxesAndLinesSearch(parsed, collapseInfo, opts) {
47207
47753
  }
47208
47754
  const groupRectByGid = /* @__PURE__ */ new Map();
47209
47755
  for (const grp of parsed.groups) {
47210
- const p = g.node(gid(grp.label));
47756
+ const p = g.node(gid2(grp.label));
47211
47757
  if (p)
47212
- groupRectByGid.set(gid(grp.label), {
47758
+ groupRectByGid.set(gid2(grp.label), {
47213
47759
  x: p.x,
47214
47760
  y: p.y,
47215
47761
  w: p.width,
@@ -47409,14 +47955,16 @@ async function layoutBoxesAndLinesSearch(parsed, collapseInfo, opts) {
47409
47955
  opts?.onTopConfigs?.(topConfigs);
47410
47956
  return best;
47411
47957
  }
47412
- var DEFAULT_LAMBDA, ESCALATE_THRESHOLD, ESCALATE_MAX_N, ESCALATE_SEEDS, ESCALATE_REFINE, DEFAULT_SEARCH_BUDGET_MS, splineGen, PATH_TOKEN_RE, FLAT_CACHE, GROUP_LABEL_ZONE3;
47958
+ var DEFAULT_LAMBDA, ESCALATE_THRESHOLD, ESCALATE_MAX_N, ESCALATE_SEEDS, ESCALATE_REFINE, DEFAULT_SEARCH_BUDGET_MS, splineGen, PATH_TOKEN_RE, FLAT_CACHE, GROUP_LABEL_ZONE4;
47413
47959
  var init_layout_search = __esm({
47414
47960
  "src/boxes-and-lines/layout-search.ts"() {
47415
47961
  "use strict";
47962
+ init_node_metrics();
47416
47963
  init_layout6();
47417
47964
  init_layout_layered();
47418
47965
  init_layout_grouped();
47419
47966
  init_label_placement();
47967
+ init_layout_stable_collapse();
47420
47968
  DEFAULT_LAMBDA = 4;
47421
47969
  ESCALATE_THRESHOLD = 4;
47422
47970
  ESCALATE_MAX_N = 45;
@@ -47426,15 +47974,13 @@ var init_layout_search = __esm({
47426
47974
  splineGen = d3line3().x((d) => d.x).y((d) => d.y).curve(curveBasis5);
47427
47975
  PATH_TOKEN_RE = /[MLQC]|-?\d*\.?\d+(?:e-?\d+)?/gi;
47428
47976
  FLAT_CACHE = /* @__PURE__ */ new WeakMap();
47429
- GROUP_LABEL_ZONE3 = 32;
47977
+ GROUP_LABEL_ZONE4 = 32;
47430
47978
  }
47431
47979
  });
47432
47980
 
47433
47981
  // src/boxes-and-lines/layout.ts
47434
47982
  var layout_exports6 = {};
47435
47983
  __export(layout_exports6, {
47436
- NODE_HEIGHT: () => NODE_HEIGHT,
47437
- NODE_WIDTH: () => NODE_WIDTH,
47438
47984
  computeNodeSize: () => computeNodeSize,
47439
47985
  layoutBoxesAndLines: () => layoutBoxesAndLines
47440
47986
  });
@@ -47517,6 +48063,9 @@ async function layoutBoxesAndLines(parsed, collapseInfo, layoutOptions) {
47517
48063
  ...layoutOptions?.previousPositions !== void 0 && {
47518
48064
  previousPositions: layoutOptions.previousPositions
47519
48065
  },
48066
+ ...layoutOptions?.stableCollapse !== void 0 && {
48067
+ stableCollapse: layoutOptions.stableCollapse
48068
+ },
47520
48069
  ...layoutOptions?.onProgress !== void 0 && {
47521
48070
  onProgress: layoutOptions.onProgress
47522
48071
  }
@@ -47621,8 +48170,8 @@ function attachNotes(layout, parsed, collapsedNotes) {
47621
48170
  nodes: finalNodes,
47622
48171
  edges: finalEdges,
47623
48172
  groups: finalGroups,
47624
- width: bbMaxX + shiftX + MARGIN6,
47625
- height: bbMaxY + shiftY + MARGIN6
48173
+ width: bbMaxX + shiftX + MARGIN7,
48174
+ height: bbMaxY + shiftY + MARGIN7
47626
48175
  };
47627
48176
  }
47628
48177
  function applyParallelEdgeOffsets(layout) {
@@ -47655,19 +48204,17 @@ function applyParallelEdgeOffsets(layout) {
47655
48204
  }))
47656
48205
  };
47657
48206
  }
47658
- var MARGIN6, MAX_PARALLEL_EDGES, PARALLEL_SPACING, PHI, NODE_HEIGHT, NODE_WIDTH, DESC_NODE_WIDTH, DESC_FONT_SIZE2, DESC_LINE_HEIGHT2, DESC_PADDING, SEPARATOR_GAP4, MAX_DESC_LINES2, MAX_LABEL_LINES2, LABEL_LINE_HEIGHT2, LABEL_PAD, VALUE_ROW_FONT, VALUE_ROW_H;
48207
+ var MARGIN7, MAX_PARALLEL_EDGES, PARALLEL_SPACING, DESC_NODE_WIDTH, DESC_FONT_SIZE2, DESC_LINE_HEIGHT2, DESC_PADDING, SEPARATOR_GAP4, MAX_DESC_LINES2, MAX_LABEL_LINES2, LABEL_LINE_HEIGHT2, LABEL_PAD, VALUE_ROW_FONT, VALUE_ROW_H;
47659
48208
  var init_layout6 = __esm({
47660
48209
  "src/boxes-and-lines/layout.ts"() {
47661
48210
  "use strict";
48211
+ init_node_metrics();
47662
48212
  init_text_measure();
47663
48213
  init_label_placement();
47664
48214
  init_notes();
47665
- MARGIN6 = 40;
48215
+ MARGIN7 = 40;
47666
48216
  MAX_PARALLEL_EDGES = 5;
47667
48217
  PARALLEL_SPACING = 22;
47668
- PHI = 1.618;
47669
- NODE_HEIGHT = 60;
47670
- NODE_WIDTH = Math.round(NODE_HEIGHT * PHI);
47671
48218
  DESC_NODE_WIDTH = 140;
47672
48219
  DESC_FONT_SIZE2 = 10;
47673
48220
  DESC_LINE_HEIGHT2 = 1.4;
@@ -47793,7 +48340,7 @@ function layoutSwimlane(parsed) {
47793
48340
  const rankIndex = new Map(usedRanks.map((r, i) => [r, i]));
47794
48341
  const R = usedRanks.length;
47795
48342
  const riOf = (id) => rankIndex.get(finalRank.get(id)) ?? 0;
47796
- const contentFlowStart = LANE_HEADER + MARGIN7;
48343
+ const contentFlowStart = LANE_HEADER + MARGIN8;
47797
48344
  const colFlowLen = Array.from({ length: R }, () => 0);
47798
48345
  for (const id of ids) {
47799
48346
  const ri = riOf(id);
@@ -47811,8 +48358,8 @@ function layoutSwimlane(parsed) {
47811
48358
  }
47812
48359
  }
47813
48360
  const gapMid = (gi) => flowCenter[gi] + colLen[gi] / 2 + COL_GAP / 2;
47814
- const totalFlow = (R > 0 ? flowCenter[R - 1] + Math.max(colFlowLen[R - 1], NODE_W2) / 2 : contentFlowStart) + MARGIN7;
47815
- const contentCrossStart = (parsed.phases.length ? PHASE_HEADER : 0) + MARGIN7;
48361
+ const totalFlow = (R > 0 ? flowCenter[R - 1] + Math.max(colFlowLen[R - 1], NODE_W2) / 2 : contentFlowStart) + MARGIN8;
48362
+ const contentCrossStart = (parsed.phases.length ? PHASE_HEADER : 0) + MARGIN8;
47816
48363
  const cellNodes = /* @__PURE__ */ new Map();
47817
48364
  for (const n of parsed.nodes) {
47818
48365
  const key = `${n.lane}\0${riOf(n.id)}`;
@@ -47864,7 +48411,7 @@ function layoutSwimlane(parsed) {
47864
48411
  if ((finalRank.get(e.to) ?? 0) < (finalRank.get(e.from) ?? 0)) backCount++;
47865
48412
  const needsBack = backCount > 0;
47866
48413
  const backReserve = needsBack ? BACK_CHANNEL + BACK_STEP * (backCount - 1) : 0;
47867
- const totalCross = laneCrossEnd + backReserve + MARGIN7;
48414
+ const totalCross = laneCrossEnd + backReserve + MARGIN8;
47868
48415
  const project = (flow, cross) => isLR ? { x: flow, y: cross } : { x: cross, y: flow };
47869
48416
  const layoutNodes = parsed.nodes.map((n) => {
47870
48417
  const s = size.get(n.id);
@@ -48086,12 +48633,12 @@ function layoutSwimlane(parsed) {
48086
48633
  height: isLR ? totalCross : totalFlow
48087
48634
  };
48088
48635
  }
48089
- var MARGIN7, COL_GAP, NODE_W2, NODE_H, DIAMOND, TERM_D, INTRA_GAP, LANE_PAD, MIN_LANE, LANE_HEADER, PHASE_HEADER, BACK_CHANNEL, BACK_STEP;
48636
+ var MARGIN8, COL_GAP, NODE_W2, NODE_H, DIAMOND, TERM_D, INTRA_GAP, LANE_PAD, MIN_LANE, LANE_HEADER, PHASE_HEADER, BACK_CHANNEL, BACK_STEP;
48090
48637
  var init_layout7 = __esm({
48091
48638
  "src/swimlane/layout.ts"() {
48092
48639
  "use strict";
48093
48640
  init_layout_grouped();
48094
- MARGIN7 = 30;
48641
+ MARGIN8 = 30;
48095
48642
  COL_GAP = 64;
48096
48643
  NODE_W2 = 124;
48097
48644
  NODE_H = 44;
@@ -48386,9 +48933,9 @@ function renderSwimlaneForExport(container, parsed, layout, palette, isDark, opt
48386
48933
  anchor = "middle";
48387
48934
  baseline = below ? "hanging" : "auto";
48388
48935
  } else {
48389
- const right = clearance(mid.x + LABEL_GAP2, mid.y, 1);
48390
- const left = clearance(mid.x - LABEL_GAP2, mid.y, -1);
48391
- const toLeft = right < CROWD && left > right;
48936
+ const right2 = clearance(mid.x + LABEL_GAP2, mid.y, 1);
48937
+ const left2 = clearance(mid.x - LABEL_GAP2, mid.y, -1);
48938
+ const toLeft = right2 < CROWD && left2 > right2;
48392
48939
  tx = mid.x + (toLeft ? -LABEL_GAP2 : LABEL_GAP2);
48393
48940
  ty = mid.y;
48394
48941
  anchor = toLeft ? "end" : "start";
@@ -48609,8 +49156,8 @@ function cardSize(p) {
48609
49156
  const valueX = KEY_X + maxKeyW + KEY_VALUE_GAP;
48610
49157
  let contentRight = 0;
48611
49158
  for (const r of rows) {
48612
- const right = r.year ? KEY_X + measureText(r.value, META_FONT_SIZE) : valueX + measureText(r.value, META_FONT_SIZE);
48613
- contentRight = Math.max(contentRight, right);
49159
+ const right2 = r.year ? KEY_X + measureText(r.value, META_FONT_SIZE) : valueX + measureText(r.value, META_FONT_SIZE);
49160
+ contentRight = Math.max(contentRight, right2);
48614
49161
  }
48615
49162
  const labelW = measureText(p.label, LABEL_FONT_SIZE);
48616
49163
  const width = Math.max(
@@ -48784,7 +49331,7 @@ function layoutFamily(parsed, focusId) {
48784
49331
  }
48785
49332
  const rowY = /* @__PURE__ */ new Map();
48786
49333
  {
48787
- let acc = MARGIN8 + ANCESTOR_BAND;
49334
+ let acc = MARGIN9 + ANCESTOR_BAND;
48788
49335
  for (let r = 0; r <= maxRow; r++) {
48789
49336
  rowY.set(r, acc);
48790
49337
  acc += (rowHeight.get(r) ?? 0) + ROW_GAP2;
@@ -48859,11 +49406,11 @@ function layoutFamily(parsed, focusId) {
48859
49406
  if (kids.length === 0 || u.parents.every((p) => !centerX.has(p)))
48860
49407
  continue;
48861
49408
  const blockW = kids.reduce((s, id) => s + sizes.get(id).width, 0) + H_GAP2 * (kids.length - 1);
48862
- let left = unionMid(u) - blockW / 2;
49409
+ let left2 = unionMid(u) - blockW / 2;
48863
49410
  for (const id of kids) {
48864
49411
  const w = sizes.get(id).width;
48865
- desired.set(id, left + w / 2);
48866
- left += w + H_GAP2;
49412
+ desired.set(id, left2 + w / 2);
49413
+ left2 += w + H_GAP2;
48867
49414
  }
48868
49415
  }
48869
49416
  resolveRow(rowPersons.get(r) ?? [], desired);
@@ -48873,7 +49420,7 @@ function layoutFamily(parsed, focusId) {
48873
49420
  for (const id of persons.keys())
48874
49421
  minLeft = Math.min(minLeft, centerX.get(id) - sizes.get(id).width / 2);
48875
49422
  const gutter = showGen ? GUTTER_WIDTH : 0;
48876
- const dx = (Number.isFinite(minLeft) ? MARGIN8 - minLeft : MARGIN8) + gutter;
49423
+ const dx = (Number.isFinite(minLeft) ? MARGIN9 - minLeft : MARGIN9) + gutter;
48877
49424
  const nodes = [];
48878
49425
  const topY = /* @__PURE__ */ new Map();
48879
49426
  const bottomY = /* @__PURE__ */ new Map();
@@ -48987,13 +49534,13 @@ function layoutFamily(parsed, focusId) {
48987
49534
  sex: p.sex,
48988
49535
  ...p.color !== void 0 && { color: p.color },
48989
49536
  x: fx,
48990
- y: MARGIN8 + 10 + i * ANCESTOR_STAGGER
49537
+ y: MARGIN9 + 10 + i * ANCESTOR_STAGGER
48991
49538
  });
48992
49539
  });
48993
49540
  }
48994
- const width = contentRightEdge + MARGIN8;
49541
+ const width = contentRightEdge + MARGIN9;
48995
49542
  const lastR = maxRow;
48996
- const height = (rowY.get(lastR) ?? MARGIN8) + (rowHeight.get(lastR) ?? 0) + MARGIN8;
49543
+ const height = (rowY.get(lastR) ?? MARGIN9) + (rowHeight.get(lastR) ?? 0) + MARGIN9;
48997
49544
  const rows = [];
48998
49545
  for (let r = 0; r <= maxRow; r++) {
48999
49546
  if (!rowPersons.get(r)?.length) continue;
@@ -49010,7 +49557,7 @@ function layoutFamily(parsed, focusId) {
49010
49557
  height
49011
49558
  };
49012
49559
  }
49013
- var MARGIN8, MIN_CARD_W, CARD_H_PAD3, CARD_TEXT_PAD, H_GAP2, ROW_GAP2, KEY_VALUE_GAP, KEY_X, GUTTER_WIDTH;
49560
+ var MARGIN9, MIN_CARD_W, CARD_H_PAD3, CARD_TEXT_PAD, H_GAP2, ROW_GAP2, KEY_VALUE_GAP, KEY_X, GUTTER_WIDTH;
49014
49561
  var init_layout8 = __esm({
49015
49562
  "src/family/layout.ts"() {
49016
49563
  "use strict";
@@ -49018,7 +49565,7 @@ var init_layout8 = __esm({
49018
49565
  init_visual_conventions();
49019
49566
  init_couple_rank();
49020
49567
  init_card_model();
49021
- MARGIN8 = 30;
49568
+ MARGIN9 = 30;
49022
49569
  MIN_CARD_W = 132;
49023
49570
  CARD_H_PAD3 = 12;
49024
49571
  CARD_TEXT_PAD = 12;
@@ -49461,7 +50008,7 @@ function layoutMindmap(parsed, _palette, options) {
49461
50008
  leafWidth: ctx.structural(LEAF_WIDTH),
49462
50009
  hGap: ctx.aesthetic(H_GAP3),
49463
50010
  vGap: ctx.aesthetic(V_GAP2),
49464
- margin: ctx.aesthetic(MARGIN9),
50011
+ margin: ctx.aesthetic(MARGIN10),
49465
50012
  multiRootGap: ctx.aesthetic(MULTI_ROOT_GAP)
49466
50013
  };
49467
50014
  populateDepthCache(roots);
@@ -49781,20 +50328,20 @@ function balancedSplitS(children, hideDescriptions, sc) {
49781
50328
  node: c,
49782
50329
  height: computeSubtreeHeightS(c, 1, hideDescriptions, sc)
49783
50330
  }));
49784
- const right = [];
49785
- const left = [];
50331
+ const right2 = [];
50332
+ const left2 = [];
49786
50333
  let rightWeight = 0;
49787
50334
  let leftWeight = 0;
49788
50335
  for (const w of weights) {
49789
50336
  if (rightWeight <= leftWeight) {
49790
- right.push(w.node);
50337
+ right2.push(w.node);
49791
50338
  rightWeight += w.height;
49792
50339
  } else {
49793
- left.push(w.node);
50340
+ left2.push(w.node);
49794
50341
  leftWeight += w.height;
49795
50342
  }
49796
50343
  }
49797
- return { right, left };
50344
+ return { right: right2, left: left2 };
49798
50345
  }
49799
50346
  function offsetPath(path, dx, dy) {
49800
50347
  if (dx === 0 && dy === 0) return path;
@@ -49839,7 +50386,7 @@ function populateDepthCache(roots) {
49839
50386
  };
49840
50387
  walk(roots, 0);
49841
50388
  }
49842
- var ROOT_WIDTH, DEPTH1_WIDTH, LEAF_WIDTH, SINGLE_LABEL_HEIGHT, LABEL_LINE_HEIGHT3, DESC_LINE_HEIGHT3, NODE_V_PAD, H_GAP3, V_GAP2, MARGIN9, MULTI_ROOT_GAP, nodeDepthCache;
50389
+ var ROOT_WIDTH, DEPTH1_WIDTH, LEAF_WIDTH, SINGLE_LABEL_HEIGHT, LABEL_LINE_HEIGHT3, DESC_LINE_HEIGHT3, NODE_V_PAD, H_GAP3, V_GAP2, MARGIN10, MULTI_ROOT_GAP, nodeDepthCache;
49843
50390
  var init_layout9 = __esm({
49844
50391
  "src/mindmap/layout.ts"() {
49845
50392
  "use strict";
@@ -49855,7 +50402,7 @@ var init_layout9 = __esm({
49855
50402
  NODE_V_PAD = 10;
49856
50403
  H_GAP3 = 40;
49857
50404
  V_GAP2 = 12;
49858
- MARGIN9 = 40;
50405
+ MARGIN10 = 40;
49859
50406
  MULTI_ROOT_GAP = 60;
49860
50407
  nodeDepthCache = /* @__PURE__ */ new Map();
49861
50408
  }
@@ -51678,14 +52225,14 @@ function layoutC4Context(parsed, activeTagGroup) {
51678
52225
  );
51679
52226
  let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
51680
52227
  for (const node of nodes) {
51681
- const left = node.x - node.width / 2;
51682
- const top = node.y - node.height / 2;
51683
- const right = node.x + node.width / 2;
51684
- const bottom = node.y + node.height / 2;
51685
- if (left < minX) minX = left;
51686
- if (top < minY) minY = top;
51687
- if (right > maxX) maxX = right;
51688
- if (bottom > maxY) maxY = bottom;
52228
+ const left2 = node.x - node.width / 2;
52229
+ const top2 = node.y - node.height / 2;
52230
+ const right2 = node.x + node.width / 2;
52231
+ const bottom2 = node.y + node.height / 2;
52232
+ if (left2 < minX) minX = left2;
52233
+ if (top2 < minY) minY = top2;
52234
+ if (right2 > maxX) maxX = right2;
52235
+ if (bottom2 > maxY) maxY = bottom2;
51689
52236
  }
51690
52237
  for (const edge of edges) {
51691
52238
  for (const pt of edge.points) {
@@ -51696,8 +52243,8 @@ function layoutC4Context(parsed, activeTagGroup) {
51696
52243
  }
51697
52244
  }
51698
52245
  if (nodes.length > 0) {
51699
- const shiftX = MARGIN10 - minX;
51700
- const shiftY = MARGIN10 - minY;
52246
+ const shiftX = MARGIN11 - minX;
52247
+ const shiftY = MARGIN11 - minY;
51701
52248
  for (const node of nodes) {
51702
52249
  node.x += shiftX;
51703
52250
  node.y += shiftY;
@@ -51709,14 +52256,14 @@ function layoutC4Context(parsed, activeTagGroup) {
51709
52256
  }
51710
52257
  }
51711
52258
  }
51712
- let totalWidth = nodes.length > 0 ? maxX - minX + MARGIN10 * 2 : 0;
51713
- let totalHeight = nodes.length > 0 ? maxY - minY + MARGIN10 * 2 : 0;
52259
+ let totalWidth = nodes.length > 0 ? maxX - minX + MARGIN11 * 2 : 0;
52260
+ let totalHeight = nodes.length > 0 ? maxY - minY + MARGIN11 * 2 : 0;
51714
52261
  const legendGroups = computeLegendGroups3(
51715
52262
  legendSuppressed(parsed.options) ? [] : parsed.tagGroups
51716
52263
  );
51717
52264
  if (legendGroups.length > 0) {
51718
- const legendY = totalHeight + MARGIN10;
51719
- let legendX = MARGIN10;
52265
+ const legendY = totalHeight + MARGIN11;
52266
+ let legendX = MARGIN11;
51720
52267
  for (const lg of legendGroups) {
51721
52268
  lg.x = legendX;
51722
52269
  lg.y = legendY;
@@ -51967,14 +52514,14 @@ function layoutC4Containers(parsed, systemName, activeTagGroup) {
51967
52514
  const containerNodes = nodes.filter((n) => n.type === "container");
51968
52515
  let bMinX = Infinity, bMinY = Infinity, bMaxX = -Infinity, bMaxY = -Infinity;
51969
52516
  for (const n of containerNodes) {
51970
- const left = n.x - n.width / 2;
51971
- const top = n.y - n.height / 2;
51972
- const right = n.x + n.width / 2;
51973
- const bottom = n.y + n.height / 2;
51974
- if (left < bMinX) bMinX = left;
51975
- if (top < bMinY) bMinY = top;
51976
- if (right > bMaxX) bMaxX = right;
51977
- if (bottom > bMaxY) bMaxY = bottom;
52517
+ const left2 = n.x - n.width / 2;
52518
+ const top2 = n.y - n.height / 2;
52519
+ const right2 = n.x + n.width / 2;
52520
+ const bottom2 = n.y + n.height / 2;
52521
+ if (left2 < bMinX) bMinX = left2;
52522
+ if (top2 < bMinY) bMinY = top2;
52523
+ if (right2 > bMaxX) bMaxX = right2;
52524
+ if (bottom2 > bMaxY) bMaxY = bottom2;
51978
52525
  }
51979
52526
  const boundary = {
51980
52527
  label: system.name,
@@ -52001,14 +52548,14 @@ function layoutC4Containers(parsed, systemName, activeTagGroup) {
52001
52548
  if (members.length === 0) continue;
52002
52549
  let gMinX = Infinity, gMinY = Infinity, gMaxX = -Infinity, gMaxY = -Infinity;
52003
52550
  for (const m of members) {
52004
- const left = m.x - m.width / 2;
52005
- const top = m.y - m.height / 2;
52006
- const right = m.x + m.width / 2;
52007
- const bottom = m.y + m.height / 2;
52008
- if (left < gMinX) gMinX = left;
52009
- if (top < gMinY) gMinY = top;
52010
- if (right > gMaxX) gMaxX = right;
52011
- if (bottom > gMaxY) gMaxY = bottom;
52551
+ const left2 = m.x - m.width / 2;
52552
+ const top2 = m.y - m.height / 2;
52553
+ const right2 = m.x + m.width / 2;
52554
+ const bottom2 = m.y + m.height / 2;
52555
+ if (left2 < gMinX) gMinX = left2;
52556
+ if (top2 < gMinY) gMinY = top2;
52557
+ if (right2 > gMaxX) gMaxX = right2;
52558
+ if (bottom2 > gMaxY) gMaxY = bottom2;
52012
52559
  }
52013
52560
  groupBoundaries.push({
52014
52561
  label: groupName,
@@ -52023,14 +52570,14 @@ function layoutC4Containers(parsed, systemName, activeTagGroup) {
52023
52570
  }
52024
52571
  let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
52025
52572
  for (const node of nodes) {
52026
- const left = node.x - node.width / 2;
52027
- const top = node.y - node.height / 2;
52028
- const right = node.x + node.width / 2;
52029
- const bottom = node.y + node.height / 2;
52030
- if (left < minX) minX = left;
52031
- if (top < minY) minY = top;
52032
- if (right > maxX) maxX = right;
52033
- if (bottom > maxY) maxY = bottom;
52573
+ const left2 = node.x - node.width / 2;
52574
+ const top2 = node.y - node.height / 2;
52575
+ const right2 = node.x + node.width / 2;
52576
+ const bottom2 = node.y + node.height / 2;
52577
+ if (left2 < minX) minX = left2;
52578
+ if (top2 < minY) minY = top2;
52579
+ if (right2 > maxX) maxX = right2;
52580
+ if (bottom2 > maxY) maxY = bottom2;
52034
52581
  }
52035
52582
  if (boundary.x < minX) minX = boundary.x;
52036
52583
  if (boundary.y < minY) minY = boundary.y;
@@ -52050,8 +52597,8 @@ function layoutC4Containers(parsed, systemName, activeTagGroup) {
52050
52597
  if (pt.y > maxY) maxY = pt.y;
52051
52598
  }
52052
52599
  }
52053
- const shiftX = MARGIN10 - minX;
52054
- const shiftY = MARGIN10 - minY;
52600
+ const shiftX = MARGIN11 - minX;
52601
+ const shiftY = MARGIN11 - minY;
52055
52602
  for (const node of nodes) {
52056
52603
  node.x += shiftX;
52057
52604
  node.y += shiftY;
@@ -52068,14 +52615,14 @@ function layoutC4Containers(parsed, systemName, activeTagGroup) {
52068
52615
  pt.y += shiftY;
52069
52616
  }
52070
52617
  }
52071
- let totalWidth = maxX - minX + MARGIN10 * 2;
52072
- let totalHeight = maxY - minY + MARGIN10 * 2;
52618
+ let totalWidth = maxX - minX + MARGIN11 * 2;
52619
+ let totalHeight = maxY - minY + MARGIN11 * 2;
52073
52620
  const legendGroups = computeLegendGroups3(
52074
52621
  legendSuppressed(parsed.options) ? [] : parsed.tagGroups
52075
52622
  );
52076
52623
  if (legendGroups.length > 0) {
52077
- const legendY = totalHeight + MARGIN10;
52078
- let legendX = MARGIN10;
52624
+ const legendY = totalHeight + MARGIN11;
52625
+ let legendX = MARGIN11;
52079
52626
  for (const lg of legendGroups) {
52080
52627
  lg.x = legendX;
52081
52628
  lg.y = legendY;
@@ -52386,14 +52933,14 @@ function layoutC4Components(parsed, systemName, containerName, activeTagGroup) {
52386
52933
  const componentNodes = nodes.filter((n) => n.type === "component");
52387
52934
  let bMinX = Infinity, bMinY = Infinity, bMaxX = -Infinity, bMaxY = -Infinity;
52388
52935
  for (const n of componentNodes) {
52389
- const left = n.x - n.width / 2;
52390
- const top = n.y - n.height / 2;
52391
- const right = n.x + n.width / 2;
52392
- const bottom = n.y + n.height / 2;
52393
- if (left < bMinX) bMinX = left;
52394
- if (top < bMinY) bMinY = top;
52395
- if (right > bMaxX) bMaxX = right;
52396
- if (bottom > bMaxY) bMaxY = bottom;
52936
+ const left2 = n.x - n.width / 2;
52937
+ const top2 = n.y - n.height / 2;
52938
+ const right2 = n.x + n.width / 2;
52939
+ const bottom2 = n.y + n.height / 2;
52940
+ if (left2 < bMinX) bMinX = left2;
52941
+ if (top2 < bMinY) bMinY = top2;
52942
+ if (right2 > bMaxX) bMaxX = right2;
52943
+ if (bottom2 > bMaxY) bMaxY = bottom2;
52397
52944
  }
52398
52945
  const boundary = {
52399
52946
  label: targetContainer.name,
@@ -52420,14 +52967,14 @@ function layoutC4Components(parsed, systemName, containerName, activeTagGroup) {
52420
52967
  if (members.length === 0) continue;
52421
52968
  let gMinX = Infinity, gMinY = Infinity, gMaxX = -Infinity, gMaxY = -Infinity;
52422
52969
  for (const m of members) {
52423
- const left = m.x - m.width / 2;
52424
- const top = m.y - m.height / 2;
52425
- const right = m.x + m.width / 2;
52426
- const bottom = m.y + m.height / 2;
52427
- if (left < gMinX) gMinX = left;
52428
- if (top < gMinY) gMinY = top;
52429
- if (right > gMaxX) gMaxX = right;
52430
- if (bottom > gMaxY) gMaxY = bottom;
52970
+ const left2 = m.x - m.width / 2;
52971
+ const top2 = m.y - m.height / 2;
52972
+ const right2 = m.x + m.width / 2;
52973
+ const bottom2 = m.y + m.height / 2;
52974
+ if (left2 < gMinX) gMinX = left2;
52975
+ if (top2 < gMinY) gMinY = top2;
52976
+ if (right2 > gMaxX) gMaxX = right2;
52977
+ if (bottom2 > gMaxY) gMaxY = bottom2;
52431
52978
  }
52432
52979
  groupBoundaries.push({
52433
52980
  label: groupName,
@@ -52442,14 +52989,14 @@ function layoutC4Components(parsed, systemName, containerName, activeTagGroup) {
52442
52989
  }
52443
52990
  let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
52444
52991
  for (const node of nodes) {
52445
- const left = node.x - node.width / 2;
52446
- const top = node.y - node.height / 2;
52447
- const right = node.x + node.width / 2;
52448
- const bottom = node.y + node.height / 2;
52449
- if (left < minX) minX = left;
52450
- if (top < minY) minY = top;
52451
- if (right > maxX) maxX = right;
52452
- if (bottom > maxY) maxY = bottom;
52992
+ const left2 = node.x - node.width / 2;
52993
+ const top2 = node.y - node.height / 2;
52994
+ const right2 = node.x + node.width / 2;
52995
+ const bottom2 = node.y + node.height / 2;
52996
+ if (left2 < minX) minX = left2;
52997
+ if (top2 < minY) minY = top2;
52998
+ if (right2 > maxX) maxX = right2;
52999
+ if (bottom2 > maxY) maxY = bottom2;
52453
53000
  }
52454
53001
  if (boundary.x < minX) minX = boundary.x;
52455
53002
  if (boundary.y < minY) minY = boundary.y;
@@ -52469,8 +53016,8 @@ function layoutC4Components(parsed, systemName, containerName, activeTagGroup) {
52469
53016
  if (pt.y > maxY) maxY = pt.y;
52470
53017
  }
52471
53018
  }
52472
- const shiftX = MARGIN10 - minX;
52473
- const shiftY = MARGIN10 - minY;
53019
+ const shiftX = MARGIN11 - minX;
53020
+ const shiftY = MARGIN11 - minY;
52474
53021
  for (const node of nodes) {
52475
53022
  node.x += shiftX;
52476
53023
  node.y += shiftY;
@@ -52487,14 +53034,14 @@ function layoutC4Components(parsed, systemName, containerName, activeTagGroup) {
52487
53034
  pt.y += shiftY;
52488
53035
  }
52489
53036
  }
52490
- let totalWidth = maxX - minX + MARGIN10 * 2;
52491
- let totalHeight = maxY - minY + MARGIN10 * 2;
53037
+ let totalWidth = maxX - minX + MARGIN11 * 2;
53038
+ let totalHeight = maxY - minY + MARGIN11 * 2;
52492
53039
  const legendGroups = computeLegendGroups3(
52493
53040
  legendSuppressed(parsed.options) ? [] : parsed.tagGroups
52494
53041
  );
52495
53042
  if (legendGroups.length > 0) {
52496
- const legendY = totalHeight + MARGIN10;
52497
- let legendX = MARGIN10;
53043
+ const legendY = totalHeight + MARGIN11;
53044
+ let legendX = MARGIN11;
52498
53045
  for (const lg of legendGroups) {
52499
53046
  lg.x = legendX;
52500
53047
  lg.y = legendY;
@@ -52713,14 +53260,14 @@ function layoutC4Deployment(parsed, activeTagGroup) {
52713
53260
  const members = infraMembers.get(infraId) ?? [];
52714
53261
  for (const m of members) {
52715
53262
  hasContent = true;
52716
- const left = m.x - m.width / 2;
52717
- const top = m.y - m.height / 2;
52718
- const right = m.x + m.width / 2;
52719
- const bottom = m.y + m.height / 2;
52720
- if (left < bMinX) bMinX = left;
52721
- if (top < bMinY) bMinY = top;
52722
- if (right > bMaxX) bMaxX = right;
52723
- if (bottom > bMaxY) bMaxY = bottom;
53263
+ const left2 = m.x - m.width / 2;
53264
+ const top2 = m.y - m.height / 2;
53265
+ const right2 = m.x + m.width / 2;
53266
+ const bottom2 = m.y + m.height / 2;
53267
+ if (left2 < bMinX) bMinX = left2;
53268
+ if (top2 < bMinY) bMinY = top2;
53269
+ if (right2 > bMaxX) bMaxX = right2;
53270
+ if (bottom2 > bMaxY) bMaxY = bottom2;
52724
53271
  }
52725
53272
  for (const [childId, parentId] of infraParents) {
52726
53273
  if (parentId === infraId) {
@@ -52761,14 +53308,14 @@ function layoutC4Deployment(parsed, activeTagGroup) {
52761
53308
  groupBoundaries.sort((a, b) => b.width * b.height - a.width * a.height);
52762
53309
  let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
52763
53310
  for (const node of nodes) {
52764
- const left = node.x - node.width / 2;
52765
- const top = node.y - node.height / 2;
52766
- const right = node.x + node.width / 2;
52767
- const bottom = node.y + node.height / 2;
52768
- if (left < minX) minX = left;
52769
- if (top < minY) minY = top;
52770
- if (right > maxX) maxX = right;
52771
- if (bottom > maxY) maxY = bottom;
53311
+ const left2 = node.x - node.width / 2;
53312
+ const top2 = node.y - node.height / 2;
53313
+ const right2 = node.x + node.width / 2;
53314
+ const bottom2 = node.y + node.height / 2;
53315
+ if (left2 < minX) minX = left2;
53316
+ if (top2 < minY) minY = top2;
53317
+ if (right2 > maxX) maxX = right2;
53318
+ if (bottom2 > maxY) maxY = bottom2;
52772
53319
  }
52773
53320
  for (const gb of groupBoundaries) {
52774
53321
  if (gb.x < minX) minX = gb.x;
@@ -52784,8 +53331,8 @@ function layoutC4Deployment(parsed, activeTagGroup) {
52784
53331
  if (pt.y > maxY) maxY = pt.y;
52785
53332
  }
52786
53333
  }
52787
- const shiftX = MARGIN10 - minX;
52788
- const shiftY = MARGIN10 - minY;
53334
+ const shiftX = MARGIN11 - minX;
53335
+ const shiftY = MARGIN11 - minY;
52789
53336
  for (const node of nodes) {
52790
53337
  node.x += shiftX;
52791
53338
  node.y += shiftY;
@@ -52800,14 +53347,14 @@ function layoutC4Deployment(parsed, activeTagGroup) {
52800
53347
  pt.y += shiftY;
52801
53348
  }
52802
53349
  }
52803
- let totalWidth = maxX - minX + MARGIN10 * 2;
52804
- let totalHeight = maxY - minY + MARGIN10 * 2;
53350
+ let totalWidth = maxX - minX + MARGIN11 * 2;
53351
+ let totalHeight = maxY - minY + MARGIN11 * 2;
52805
53352
  const legendGroups = computeLegendGroups3(
52806
53353
  legendSuppressed(parsed.options) ? [] : parsed.tagGroups
52807
53354
  );
52808
53355
  if (legendGroups.length > 0) {
52809
- const legendY = totalHeight + MARGIN10;
52810
- let legendX = MARGIN10;
53356
+ const legendY = totalHeight + MARGIN11;
53357
+ let legendX = MARGIN11;
52811
53358
  for (const lg of legendGroups) {
52812
53359
  lg.x = legendX;
52813
53360
  lg.y = legendY;
@@ -52827,7 +53374,7 @@ function layoutC4Deployment(parsed, activeTagGroup) {
52827
53374
  height: totalHeight
52828
53375
  };
52829
53376
  }
52830
- var gNode, gEdge, MIN_NODE_WIDTH, MAX_NODE_WIDTH, TYPE_LABEL_HEIGHT, DIVIDER_GAP, NAME_HEIGHT, NAME_FONT_SIZE, DESC_LINE_HEIGHT5, DESC_FONT_SIZE4, CARD_V_PAD3, CARD_H_PAD4, META_LINE_HEIGHT4, META_FONT_SIZE4, MARGIN10, BOUNDARY_PAD, GROUP_BOUNDARY_PAD, EDGE_NODE_COLLISION_WEIGHT, META_EXCLUDE_KEYS;
53377
+ var gNode, gEdge, MIN_NODE_WIDTH, MAX_NODE_WIDTH, TYPE_LABEL_HEIGHT, DIVIDER_GAP, NAME_HEIGHT, NAME_FONT_SIZE, DESC_LINE_HEIGHT5, DESC_FONT_SIZE4, CARD_V_PAD3, CARD_H_PAD4, META_LINE_HEIGHT4, META_FONT_SIZE4, MARGIN11, BOUNDARY_PAD, GROUP_BOUNDARY_PAD, EDGE_NODE_COLLISION_WEIGHT, META_EXCLUDE_KEYS;
52831
53378
  var init_layout11 = __esm({
52832
53379
  "src/c4/layout.ts"() {
52833
53380
  "use strict";
@@ -52849,7 +53396,7 @@ var init_layout11 = __esm({
52849
53396
  CARD_H_PAD4 = 20;
52850
53397
  META_LINE_HEIGHT4 = 16;
52851
53398
  META_FONT_SIZE4 = 11;
52852
- MARGIN10 = 40;
53399
+ MARGIN11 = 40;
52853
53400
  BOUNDARY_PAD = 40;
52854
53401
  GROUP_BOUNDARY_PAD = 24;
52855
53402
  EDGE_NODE_COLLISION_WEIGHT = 5e3;
@@ -53125,7 +53672,7 @@ function renderC4ContextForExport(content, theme, palette) {
53125
53672
  }
53126
53673
  svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
53127
53674
  svgEl.style.fontFamily = FONT_FAMILY;
53128
- return svgEl.outerHTML;
53675
+ return serializeSvg(svgEl);
53129
53676
  } finally {
53130
53677
  document.body.removeChild(container);
53131
53678
  }
@@ -53741,7 +54288,7 @@ function renderC4ContainersForExport(content, systemName, theme, palette) {
53741
54288
  }
53742
54289
  svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
53743
54290
  svgEl.style.fontFamily = FONT_FAMILY;
53744
- return svgEl.outerHTML;
54291
+ return serializeSvg(svgEl);
53745
54292
  } finally {
53746
54293
  document.body.removeChild(el);
53747
54294
  }
@@ -53773,7 +54320,7 @@ function renderC4ComponentsForExport(content, systemName, containerName, theme,
53773
54320
  }
53774
54321
  svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
53775
54322
  svgEl.style.fontFamily = FONT_FAMILY;
53776
- return svgEl.outerHTML;
54323
+ return serializeSvg(svgEl);
53777
54324
  } finally {
53778
54325
  document.body.removeChild(el);
53779
54326
  }
@@ -53818,7 +54365,7 @@ function renderC4DeploymentForExport(content, theme, palette) {
53818
54365
  }
53819
54366
  svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
53820
54367
  svgEl.style.fontFamily = FONT_FAMILY;
53821
- return svgEl.outerHTML;
54368
+ return serializeSvg(svgEl);
53822
54369
  } finally {
53823
54370
  document.body.removeChild(el);
53824
54371
  }
@@ -53827,6 +54374,7 @@ var DIAGRAM_PADDING9, MAX_SCALE5, TITLE_HEIGHT6, TYPE_FONT_SIZE, NAME_FONT_SIZE2
53827
54374
  var init_renderer16 = __esm({
53828
54375
  "src/c4/renderer.ts"() {
53829
54376
  "use strict";
54377
+ init_svg_serialize();
53830
54378
  init_tag_groups();
53831
54379
  init_parsing();
53832
54380
  init_fonts();
@@ -54095,14 +54643,14 @@ function layoutGraph(graph, options) {
54095
54643
  let maxX = -Infinity;
54096
54644
  let maxY = -Infinity;
54097
54645
  for (const member of members) {
54098
- const left = member.x - member.width / 2;
54099
- const right = member.x + member.width / 2;
54100
- const top = member.y - member.height / 2;
54101
- const bottom = member.y + member.height / 2;
54102
- if (left < minX) minX = left;
54103
- if (right > maxX) maxX = right;
54104
- if (top < minY) minY = top;
54105
- if (bottom > maxY) maxY = bottom;
54646
+ const left2 = member.x - member.width / 2;
54647
+ const right2 = member.x + member.width / 2;
54648
+ const top2 = member.y - member.height / 2;
54649
+ const bottom2 = member.y + member.height / 2;
54650
+ if (left2 < minX) minX = left2;
54651
+ if (right2 > maxX) maxX = right2;
54652
+ if (top2 < minY) minY = top2;
54653
+ if (bottom2 > maxY) maxY = bottom2;
54106
54654
  }
54107
54655
  layoutGroups.push({
54108
54656
  id: group.id,
@@ -54371,15 +54919,15 @@ function renderDocument(g, node, palette, isDark, colorOff, fillMode, sNodeStrok
54371
54919
  const w = node.width;
54372
54920
  const h = node.height;
54373
54921
  const waveH = sDocWaveHeight;
54374
- const left = -w / 2;
54375
- const right = w / 2;
54376
- const top = -h / 2;
54377
- const bottom = h / 2 - waveH;
54922
+ const left2 = -w / 2;
54923
+ const right2 = w / 2;
54924
+ const top2 = -h / 2;
54925
+ const bottom2 = h / 2 - waveH;
54378
54926
  const d = [
54379
- `M ${left} ${top}`,
54380
- `L ${right} ${top}`,
54381
- `L ${right} ${bottom}`,
54382
- `C ${right - w * 0.25} ${bottom + waveH * 2}, ${left + w * 0.25} ${bottom - waveH}, ${left} ${bottom}`,
54927
+ `M ${left2} ${top2}`,
54928
+ `L ${right2} ${top2}`,
54929
+ `L ${right2} ${bottom2}`,
54930
+ `C ${right2 - w * 0.25} ${bottom2 + waveH * 2}, ${left2 + w * 0.25} ${bottom2 - waveH}, ${left2} ${bottom2}`,
54383
54931
  "Z"
54384
54932
  ].join(" ");
54385
54933
  g.append("path").attr("d", d).attr(
@@ -54745,7 +55293,7 @@ function renderFlowchartForExport(content, theme, palette) {
54745
55293
  }
54746
55294
  svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
54747
55295
  svgEl.style.fontFamily = FONT_FAMILY;
54748
- return svgEl.outerHTML;
55296
+ return serializeSvg(svgEl);
54749
55297
  } finally {
54750
55298
  document.body.removeChild(container);
54751
55299
  }
@@ -54754,6 +55302,7 @@ var DIAGRAM_PADDING10, MAX_SCALE6, NODE_FONT_SIZE3, EDGE_LABEL_FONT_SIZE9, ARROW
54754
55302
  var init_flowchart_renderer = __esm({
54755
55303
  "src/graph/flowchart-renderer.ts"() {
54756
55304
  "use strict";
55305
+ init_svg_serialize();
54757
55306
  init_parsing();
54758
55307
  init_arrow_markers();
54759
55308
  init_fit_canvas();
@@ -56160,14 +56709,14 @@ function layoutInfra(computed, expandedNodeIds, collapsedNodes) {
56160
56709
  }
56161
56710
  let minX2 = Infinity, minY2 = Infinity, maxX2 = -Infinity, maxY2 = -Infinity;
56162
56711
  for (const child of childNodes) {
56163
- const left = child.x - child.width / 2;
56164
- const right = child.x + child.width / 2;
56165
- const top = child.y - child.height / 2;
56166
- const bottom = child.y + child.height / 2;
56167
- if (left < minX2) minX2 = left;
56168
- if (right > maxX2) maxX2 = right;
56169
- if (top < minY2) minY2 = top;
56170
- if (bottom > maxY2) maxY2 = bottom;
56712
+ const left2 = child.x - child.width / 2;
56713
+ const right2 = child.x + child.width / 2;
56714
+ const top2 = child.y - child.height / 2;
56715
+ const bottom2 = child.y + child.height / 2;
56716
+ if (left2 < minX2) minX2 = left2;
56717
+ if (right2 > maxX2) maxX2 = right2;
56718
+ if (top2 < minY2) minY2 = top2;
56719
+ if (bottom2 > maxY2) maxY2 = bottom2;
56171
56720
  }
56172
56721
  return {
56173
56722
  id: group.id,
@@ -56185,14 +56734,14 @@ function layoutInfra(computed, expandedNodeIds, collapsedNodes) {
56185
56734
  fixEdgeWaypoints(layoutEdges, layoutNodes, groupDeltas);
56186
56735
  let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
56187
56736
  for (const node of layoutNodes) {
56188
- const left = node.x - node.width / 2;
56189
- const right = node.x + node.width / 2;
56190
- const top = node.y - node.height / 2;
56191
- const bottom = node.y + node.height / 2;
56192
- if (left < minX) minX = left;
56193
- if (right > maxX) maxX = right;
56194
- if (top < minY) minY = top;
56195
- if (bottom > maxY) maxY = bottom;
56737
+ const left2 = node.x - node.width / 2;
56738
+ const right2 = node.x + node.width / 2;
56739
+ const top2 = node.y - node.height / 2;
56740
+ const bottom2 = node.y + node.height / 2;
56741
+ if (left2 < minX) minX = left2;
56742
+ if (right2 > maxX) maxX = right2;
56743
+ if (top2 < minY) minY = top2;
56744
+ if (bottom2 > maxY) maxY = bottom2;
56196
56745
  }
56197
56746
  for (const group of layoutGroups) {
56198
56747
  if (group.x < minX) minX = group.x;
@@ -56512,7 +57061,7 @@ function findRoutingLane(blocking, targetY, margin) {
56512
57061
  }
56513
57062
  }
56514
57063
  if (merged.length === 0) return targetY;
56515
- const MIN_GAP = 10;
57064
+ const MIN_GAP2 = 10;
56516
57065
  const candidates = [
56517
57066
  // In-bounds: merged.length > 0 guarded above.
56518
57067
  merged[0][0] - margin,
@@ -56523,7 +57072,7 @@ function findRoutingLane(blocking, targetY, margin) {
56523
57072
  for (let i = 0; i < merged.length - 1; i++) {
56524
57073
  const gapLo = merged[i][1];
56525
57074
  const gapHi = merged[i + 1][0];
56526
- if (gapHi - gapLo >= MIN_GAP) {
57075
+ if (gapHi - gapLo >= MIN_GAP2) {
56527
57076
  candidates.push((gapLo + gapHi) / 2);
56528
57077
  }
56529
57078
  }
@@ -59172,14 +59721,14 @@ function relayoutPert(resolved, overrides, collapsedGroupIds = /* @__PURE__ */ n
59172
59721
  let maxX = -Infinity;
59173
59722
  let maxY = -Infinity;
59174
59723
  for (const m of members) {
59175
- const left = m.x - m.width / 2;
59176
- const right = m.x + m.width / 2;
59177
- const top = m.y - m.height / 2;
59178
- const bottom = m.y + m.height / 2;
59179
- if (left < minX) minX = left;
59180
- if (right > maxX) maxX = right;
59181
- if (top < minY) minY = top;
59182
- if (bottom > maxY) maxY = bottom;
59724
+ const left2 = m.x - m.width / 2;
59725
+ const right2 = m.x + m.width / 2;
59726
+ const top2 = m.y - m.height / 2;
59727
+ const bottom2 = m.y + m.height / 2;
59728
+ if (left2 < minX) minX = left2;
59729
+ if (right2 > maxX) maxX = right2;
59730
+ if (top2 < minY) minY = top2;
59731
+ if (bottom2 > maxY) maxY = bottom2;
59183
59732
  }
59184
59733
  return {
59185
59734
  id: rg.group.id,
@@ -59193,10 +59742,10 @@ function relayoutPert(resolved, overrides, collapsedGroupIds = /* @__PURE__ */ n
59193
59742
  let totalW = 0;
59194
59743
  let totalH = 0;
59195
59744
  for (const n of nodes) {
59196
- const right = n.x + n.width / 2;
59197
- const bottom = n.y + n.height / 2;
59198
- if (right > totalW) totalW = right;
59199
- if (bottom > totalH) totalH = bottom;
59745
+ const right2 = n.x + n.width / 2;
59746
+ const bottom2 = n.y + n.height / 2;
59747
+ if (right2 > totalW) totalW = right2;
59748
+ if (bottom2 > totalH) totalH = bottom2;
59200
59749
  }
59201
59750
  for (const grp of groups) {
59202
59751
  if (grp.x + grp.width > totalW) totalW = grp.x + grp.width;
@@ -59369,15 +59918,15 @@ function centerByCriticality(g, resolved, memberToGroup, collapsedGroupIds) {
59369
59918
  if (cb !== ca) return cb - ca;
59370
59919
  return (currentSlot.get(a) ?? 0) - (currentSlot.get(b) ?? 0);
59371
59920
  });
59372
- const top = [];
59373
- const bottom = [];
59921
+ const top2 = [];
59922
+ const bottom2 = [];
59374
59923
  let middle = null;
59375
59924
  sortedDesc.forEach((id, i) => {
59376
59925
  if (i === 0) middle = id;
59377
- else if (i % 2 === 1) top.unshift(id);
59378
- else bottom.push(id);
59926
+ else if (i % 2 === 1) top2.unshift(id);
59927
+ else bottom2.push(id);
59379
59928
  });
59380
- const newOrder = middle ? [...top, middle, ...bottom] : [...top, ...bottom];
59929
+ const newOrder = middle ? [...top2, middle, ...bottom2] : [...top2, ...bottom2];
59381
59930
  newOrder.forEach((id, i) => {
59382
59931
  const node = g.node(id);
59383
59932
  const oldVal = node[slotAxis];
@@ -59805,7 +60354,7 @@ function renderPertForExport(content, theme, palette, now) {
59805
60354
  else svgEl.style.background = palette.bg;
59806
60355
  svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
59807
60356
  svgEl.style.fontFamily = FONT_FAMILY;
59808
- return svgEl.outerHTML;
60357
+ return serializeSvg(svgEl);
59809
60358
  } finally {
59810
60359
  document.body.removeChild(container);
59811
60360
  }
@@ -60690,10 +61239,10 @@ function drawMilestonePill(g, a) {
60690
61239
  drawCenteredText(x + w / 2, y + h - botRowH / 2, a.slack, "normal", sNCFS);
60691
61240
  }
60692
61241
  }
60693
- function drawAnchorPin(g, left, centerY, color, pinW = PIN_ICON_W, pinH = PIN_ICON_H) {
61242
+ function drawAnchorPin(g, left2, centerY, color, pinW = PIN_ICON_W, pinH = PIN_ICON_H) {
60694
61243
  const scale = pinW / 24;
60695
- const top = centerY - pinH / 2;
60696
- const pin = g.append("g").attr("class", "pert-pin").attr("data-pert-pin", "").attr("transform", `translate(${left}, ${top}) scale(${scale})`);
61244
+ const top2 = centerY - pinH / 2;
61245
+ const pin = g.append("g").attr("class", "pert-pin").attr("data-pert-pin", "").attr("transform", `translate(${left2}, ${top2}) scale(${scale})`);
60697
61246
  pin.append("path").attr("d", "M12 22V8 M5 12H2a10 10 0 0 0 20 0h-3").attr("fill", "none").attr("stroke", color).attr("stroke-width", 2).attr("stroke-linecap", "round").attr("stroke-linejoin", "round");
60698
61247
  pin.append("circle").attr("cx", 12).attr("cy", 5).attr("r", 3).attr("fill", "none").attr("stroke", color).attr("stroke-width", 2);
60699
61248
  }
@@ -61227,6 +61776,7 @@ var DIAGRAM_PADDING12, NODE_FONT_SIZE6, NODE_CELL_FONT_SIZE2, NODE_RADIUS2, NODE
61227
61776
  var init_renderer18 = __esm({
61228
61777
  "src/pert/renderer.ts"() {
61229
61778
  "use strict";
61779
+ init_svg_serialize();
61230
61780
  init_fonts();
61231
61781
  init_color_utils();
61232
61782
  init_scaling();
@@ -64640,7 +65190,7 @@ function renderStateForExport(content, theme, palette) {
64640
65190
  }
64641
65191
  svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
64642
65192
  svgEl.style.fontFamily = FONT_FAMILY;
64643
- return svgEl.outerHTML;
65193
+ return serializeSvg(svgEl);
64644
65194
  } finally {
64645
65195
  document.body.removeChild(container);
64646
65196
  }
@@ -64649,6 +65199,7 @@ var DIAGRAM_PADDING13, MAX_SCALE7, NODE_FONT_SIZE7, EDGE_LABEL_FONT_SIZE12, GROU
64649
65199
  var init_state_renderer = __esm({
64650
65200
  "src/graph/state-renderer.ts"() {
64651
65201
  "use strict";
65202
+ init_svg_serialize();
64652
65203
  init_parsing();
64653
65204
  init_inline_header();
64654
65205
  init_arrow_markers();
@@ -65975,14 +66526,14 @@ function positionPopover(popover, event) {
65975
66526
  const cursorY = event.clientY - rect2.top;
65976
66527
  const centerX = rect2.width / 2;
65977
66528
  const centerY = rect2.height / 2;
65978
- let left = cursorX < centerX ? cursorX + 16 : cursorX - tipW - 16;
65979
- let top = cursorY < centerY ? cursorY + 16 : cursorY - tipH - 16;
65980
- if (left + tipW > rect2.width - 4) left = rect2.width - tipW - 4;
65981
- if (left < 4) left = 4;
65982
- if (top + tipH > rect2.height - 4) top = rect2.height - tipH - 4;
65983
- if (top < 4) top = 4;
65984
- popover.style.left = `${left}px`;
65985
- popover.style.top = `${top}px`;
66529
+ let left2 = cursorX < centerX ? cursorX + 16 : cursorX - tipW - 16;
66530
+ let top2 = cursorY < centerY ? cursorY + 16 : cursorY - tipH - 16;
66531
+ if (left2 + tipW > rect2.width - 4) left2 = rect2.width - tipW - 4;
66532
+ if (left2 < 4) left2 = 4;
66533
+ if (top2 + tipH > rect2.height - 4) top2 = rect2.height - tipH - 4;
66534
+ if (top2 < 4) top2 = 4;
66535
+ popover.style.left = `${left2}px`;
66536
+ popover.style.top = `${top2}px`;
65986
66537
  }
65987
66538
  function hideBlipPopover(popover) {
65988
66539
  popover.style.display = "none";
@@ -67193,12 +67744,13 @@ function renderJourneyMapForExport(content, theme, palette) {
67193
67744
  const bgRect = svgEl.querySelector("rect:first-child");
67194
67745
  if (bgRect) bgRect.remove();
67195
67746
  }
67196
- return svgEl.outerHTML;
67747
+ return serializeSvg(svgEl);
67197
67748
  }
67198
67749
  var DIAGRAM_PADDING14, PADDING2, CARD_PADDING_X3, CARD_PADDING_Y3, CARD_HEADER_HEIGHT3, CARD_STROKE_WIDTH2, CARD_META_LINE_HEIGHT3, CARD_GAP_INTERNAL, COLUMN_RADIUS2, COLUMN_HEADER_HEIGHT2, COLUMN_PADDING3, FONT_SIZE_TITLE, FONT_SIZE_PHASE, FONT_SIZE_STEP, FONT_SIZE_META, GRID_LINE_OPACITY, CURVE_STROKE_WIDTH, FACE_RADIUS, CURVE_AREA_BOTTOM_GAP, FACE_HOVER_SCALE, FACE_HOVER_R, DIM_HOVER, TITLE_LINE_HEIGHT, EMOTION_LABEL_MAX_WIDTH, EMOTION_LABEL_FONT_SIZE, ICON_THUMBS_DOWN, ICON_THUMBS_UP, ICON_THOUGHT;
67199
67750
  var init_renderer21 = __esm({
67200
67751
  "src/journey-map/renderer.ts"() {
67201
67752
  "use strict";
67753
+ init_svg_serialize();
67202
67754
  init_tag_groups();
67203
67755
  init_parsing();
67204
67756
  init_color_utils();
@@ -69893,13 +70445,13 @@ function placeContextLabels(args) {
69893
70445
  if (!rectFits(rect2, width, height)) return null;
69894
70446
  if (cand.italic && overLand) {
69895
70447
  const inset = 2;
69896
- const top = cy - (cand.lines.length - 1) / 2 * LINE_HEIGHT;
70448
+ const top2 = cy - (cand.lines.length - 1) / 2 * LINE_HEIGHT;
69897
70449
  const touchesLand = cand.lines.some((line11, li) => {
69898
70450
  const lw = labelWidth(line11, cand.letterSpacing);
69899
70451
  const x0 = cx - lw / 2 + inset;
69900
70452
  const x1 = cx + lw / 2 - inset;
69901
70453
  const xs = [x0, (x0 + cx) / 2, cx, (cx + x1) / 2, x1];
69902
- const base = top + li * LINE_HEIGHT;
70454
+ const base = top2 + li * LINE_HEIGHT;
69903
70455
  return [base, base - FONT * 0.4, base - FONT * 0.8].some(
69904
70456
  (y) => xs.some((x) => overLand(x, y))
69905
70457
  );
@@ -70724,12 +71276,12 @@ function layoutMap(resolvedIn, data, size, opts) {
70724
71276
  const sh = Number.isFinite(bb[0][0]) ? bb[1][1] - bb[0][1] : iw;
70725
71277
  const needH = sh + 2 * PAD3;
70726
71278
  let topFit = topGuess;
70727
- const bottom = Math.min(topFit + needH, yB);
70728
- if (bottom - topFit < needH) topFit = bottom - needH;
71279
+ const bottom2 = Math.min(topFit + needH, yB);
71280
+ if (bottom2 - topFit < needH) topFit = bottom2 - needH;
70729
71281
  proj.fitExtent(
70730
71282
  [
70731
71283
  [x0 + PAD3, topFit + PAD3],
70732
- [xr - PAD3, bottom - PAD3]
71284
+ [xr - PAD3, bottom2 - PAD3]
70733
71285
  ],
70734
71286
  f
70735
71287
  );
@@ -70757,12 +71309,12 @@ function layoutMap(resolvedIn, data, size, opts) {
70757
71309
  x: x0,
70758
71310
  y: topFit,
70759
71311
  w: xr - x0,
70760
- h: bottom - topFit,
71312
+ h: bottom2 - topFit,
70761
71313
  points: [
70762
71314
  [x0, topFit],
70763
71315
  [xr, topFit],
70764
- [xr, bottom],
70765
- [x0, bottom]
71316
+ [xr, bottom2],
71317
+ [x0, bottom2]
70766
71318
  ],
70767
71319
  // The FITTED inset projection (just fit to this box) — captured so the
70768
71320
  // geo-query can invert pixels inside the frame back to AK/HI coords.
@@ -72083,11 +72635,11 @@ function layoutMap(resolvedIn, data, size, opts) {
72083
72635
  const COL_GAP2 = 16;
72084
72636
  const makeItems = (group) => group.map((p) => ({ p, ...labelInfo(p) })).sort((a, b) => a.p.cy - b.p.cy || (a.text < b.text ? -1 : 1));
72085
72637
  const columnRows = (items, side) => {
72086
- const left = Math.min(...items.map((o) => o.p.cx - o.p.r));
72087
- const right = Math.max(...items.map((o) => o.p.cx + o.p.r));
72638
+ const left2 = Math.min(...items.map((o) => o.p.cx - o.p.r));
72639
+ const right2 = Math.max(...items.map((o) => o.p.cx + o.p.r));
72088
72640
  const maxW = Math.max(...items.map((o) => o.w));
72089
72641
  const cyMid = (Math.min(...items.map((o) => o.p.cy)) + Math.max(...items.map((o) => o.p.cy))) / 2;
72090
- const colX = side === "right" ? Math.min(right + COL_GAP2, width - POI_EDGE_CLEAR - maxW) : Math.max(left - COL_GAP2, POI_EDGE_CLEAR + maxW);
72642
+ const colX = side === "right" ? Math.min(right2 + COL_GAP2, width - POI_EDGE_CLEAR - maxW) : Math.max(left2 - COL_GAP2, POI_EDGE_CLEAR + maxW);
72091
72643
  const totalH = items.length * step;
72092
72644
  let startY = cyMid - totalH / 2;
72093
72645
  startY = Math.max(
@@ -72285,11 +72837,11 @@ function layoutMap(resolvedIn, data, size, opts) {
72285
72837
  pushInline(p, text, w, side);
72286
72838
  continue;
72287
72839
  }
72288
- const left = Math.min(...items.map((o) => o.p.cx - o.p.r));
72289
- const right = Math.max(...items.map((o) => o.p.cx + o.p.r));
72840
+ const left2 = Math.min(...items.map((o) => o.p.cx - o.p.r));
72841
+ const right2 = Math.max(...items.map((o) => o.p.cx + o.p.r));
72290
72842
  const minCy = Math.min(...items.map((o) => o.p.cy));
72291
72843
  const maxCy = Math.max(...items.map((o) => o.p.cy));
72292
- const diag = Math.hypot(right - left, maxCy - minCy);
72844
+ const diag = Math.hypot(right2 - left2, maxCy - minCy);
72293
72845
  if (diag > maxExtent || items.length > MAX_COLUMN_ROWS) {
72294
72846
  items.forEach((o) => pushHidden(o.p));
72295
72847
  } else {
@@ -72349,18 +72901,18 @@ function layoutMap(resolvedIn, data, size, opts) {
72349
72901
  needBottom = Math.min(Math.max(0, Math.ceil(needBottom)), capV);
72350
72902
  if (needLeft >= 1 || needRight >= 1 || needTop >= 1 || needBottom >= 1) {
72351
72903
  const prev = opts._calloutReserve;
72352
- const left = Math.min((prev?.left ?? 0) + needLeft, capH);
72353
- const right = Math.min((prev?.right ?? 0) + needRight, capH);
72354
- const top = Math.min((prev?.top ?? 0) + needTop, capV);
72355
- const bottom = Math.min((prev?.bottom ?? 0) + needBottom, capV);
72904
+ const left2 = Math.min((prev?.left ?? 0) + needLeft, capH);
72905
+ const right2 = Math.min((prev?.right ?? 0) + needRight, capH);
72906
+ const top2 = Math.min((prev?.top ?? 0) + needTop, capV);
72907
+ const bottom2 = Math.min((prev?.bottom ?? 0) + needBottom, capV);
72356
72908
  return layoutMap(resolved, data, size, {
72357
72909
  ...opts,
72358
72910
  _poiClearancePass: clearancePass + 1,
72359
72911
  _calloutReserve: {
72360
- ...left > 0 && { left },
72361
- ...right > 0 && { right },
72362
- ...top > 0 && { top },
72363
- ...bottom > 0 && { bottom }
72912
+ ...left2 > 0 && { left: left2 },
72913
+ ...right2 > 0 && { right: right2 },
72914
+ ...top2 > 0 && { top: top2 },
72915
+ ...bottom2 > 0 && { bottom: bottom2 }
72364
72916
  }
72365
72917
  });
72366
72918
  }
@@ -74350,8 +74902,8 @@ function layoutTreemapRadial(roots, opts) {
74350
74902
  );
74351
74903
  const ringSpan = Math.max(1, radius - discRadius);
74352
74904
  const ringWidth = ringSpan / Math.max(1, treeDepth);
74353
- (hroot.children ?? []).forEach((top, i) => {
74354
- top.each((d) => {
74905
+ (hroot.children ?? []).forEach((top2, i) => {
74906
+ top2.each((d) => {
74355
74907
  d._topIndex = i;
74356
74908
  });
74357
74909
  });
@@ -74785,14 +75337,14 @@ function fitFs(text, maxFs, availLen) {
74785
75337
  return Math.max(MIN_LABEL_FS, Math.floor(maxFs * availLen / w));
74786
75338
  }
74787
75339
  function drawCurvedLine(g, defs, pathId, cell, centerR, fs, weight, text, ink) {
74788
- const bottom = isBottomHalf(cell);
74789
- const rPath = bottom ? centerR + fs * 0.32 : centerR - fs * 0.32;
74790
- const [a0, a1] = bottom ? [cell.endAngle, cell.startAngle] : [cell.startAngle, cell.endAngle];
75340
+ const bottom2 = isBottomHalf(cell);
75341
+ const rPath = bottom2 ? centerR + fs * 0.32 : centerR - fs * 0.32;
75342
+ const [a0, a1] = bottom2 ? [cell.endAngle, cell.startAngle] : [cell.startAngle, cell.endAngle];
74791
75343
  const p0x = Math.sin(a0) * rPath;
74792
75344
  const p0y = -Math.cos(a0) * rPath;
74793
75345
  const p1x = Math.sin(a1) * rPath;
74794
75346
  const p1y = -Math.cos(a1) * rPath;
74795
- const sweepFlag = bottom ? 0 : 1;
75347
+ const sweepFlag = bottom2 ? 0 : 1;
74796
75348
  const largeArc = cell.endAngle - cell.startAngle > Math.PI ? 1 : 0;
74797
75349
  const d = `M ${p0x.toFixed(2)} ${p0y.toFixed(2)} A ${rPath.toFixed(2)} ${rPath.toFixed(2)} 0 ${largeArc} ${sweepFlag} ${p1x.toFixed(2)} ${p1y.toFixed(2)}`;
74798
75350
  defs.append("path").attr("id", pathId).attr("d", d);
@@ -74917,8 +75469,8 @@ function layoutTreemap(roots, opts) {
74917
75469
  const h = hierarchy3(rootDatum).sum((d) => d.children?.length ? 0 : d.value ?? 0).sort((a, b) => (b.value ?? 0) - (a.value ?? 0));
74918
75470
  const hroot = treemap().tile(treemapSquarify).size([opts.width, opts.height]).paddingOuter(opts.paddingOuter ?? 3).paddingTop(opts.headerH > 0 ? opts.headerH : opts.paddingInner ?? 2).paddingInner(opts.paddingInner ?? 2).round(true)(h);
74919
75471
  const total = hroot.value ?? 0;
74920
- (hroot.children ?? []).forEach((top, i) => {
74921
- top.each((d) => {
75472
+ (hroot.children ?? []).forEach((top2, i) => {
75473
+ top2.each((d) => {
74922
75474
  d._topIndex = i;
74923
75475
  });
74924
75476
  });
@@ -75790,13 +76342,13 @@ function renderWrappedMarkdown(textEl, lines, lineH) {
75790
76342
  }
75791
76343
  });
75792
76344
  }
75793
- function drawNote(svg, description, paint, left, top, width) {
76345
+ function drawNote(svg, description, paint, left2, top2, width) {
75794
76346
  const descSize = 15;
75795
76347
  const lineH = descSize * 1.4;
75796
76348
  const maxChars = Math.max(8, Math.floor(width / (descSize * 0.46)));
75797
- const firstY = top + descSize;
75798
- const lines = layoutDescription(description, left, maxChars);
75799
- const desc = svg.append("text").attr("x", left).attr("y", firstY).attr("text-anchor", "start").attr("fill", paint.muted).attr("font-family", FONT_FAMILY).attr("font-size", descSize).attr("font-weight", 500);
76349
+ const firstY = top2 + descSize;
76350
+ const lines = layoutDescription(description, left2, maxChars);
76351
+ const desc = svg.append("text").attr("x", left2).attr("y", firstY).attr("text-anchor", "start").attr("fill", paint.muted).attr("font-family", FONT_FAMILY).attr("font-size", descSize).attr("font-weight", 500);
75800
76352
  renderWrappedMarkdown(desc, lines, lineH);
75801
76353
  return firstY + lines.length * lineH;
75802
76354
  }
@@ -75834,15 +76386,15 @@ function renderBar2(svg, parsed, metrics, paint) {
75834
76386
  if (parsed.hasTarget) {
75835
76387
  g.append("text").attr("x", barRight + gap).attr("y", barCy + 26 * 0.35).attr("text-anchor", "start").attr("fill", paint.text).attr("font-family", FONT_FAMILY).attr("font-size", 26).attr("font-weight", 700).text(compactNumber2(parsed.target));
75836
76388
  }
75837
- let bottom = y + trackH;
76389
+ let bottom2 = y + trackH;
75838
76390
  if (parsed.description && !parsed.options.noNote) {
75839
- bottom = drawNote(svg, parsed.description, paint, x, bottom + 40, trackW);
76391
+ bottom2 = drawNote(svg, parsed.description, paint, x, bottom2 + 40, trackW);
75840
76392
  }
75841
76393
  return {
75842
76394
  minX: 0,
75843
76395
  minY: 0,
75844
76396
  maxX: barRight + gap + targetLabelW,
75845
- maxY: bottom
76397
+ maxY: bottom2
75846
76398
  };
75847
76399
  }
75848
76400
  function renderThermometer(svg, parsed, metrics, paint) {
@@ -75943,12 +76495,12 @@ function renderGauge(svg, parsed, metrics, paint) {
75943
76495
  let colBottom = crestTop;
75944
76496
  if (hasNote) {
75945
76497
  const titleSize = GOAL_TITLE_SIZE;
75946
- let top = crestTop;
76498
+ let top2 = crestTop;
75947
76499
  if (parsed.title && !parsed.options.noTitle) {
75948
- svg.append("text").attr("class", "chart-title").attr("x", colLeft).attr("y", top + titleSize * 0.78).attr("text-anchor", "start").attr("fill", paint.text).attr("font-family", FONT_FAMILY).attr("font-size", titleSize).attr("font-weight", TITLE_FONT_WEIGHT).attr("data-line-number", parsed.titleLineNumber).text(parsed.title);
75949
- top += titleSize * 0.78 + 16;
76500
+ svg.append("text").attr("class", "chart-title").attr("x", colLeft).attr("y", top2 + titleSize * 0.78).attr("text-anchor", "start").attr("fill", paint.text).attr("font-family", FONT_FAMILY).attr("font-size", titleSize).attr("font-weight", TITLE_FONT_WEIGHT).attr("data-line-number", parsed.titleLineNumber).text(parsed.title);
76501
+ top2 += titleSize * 0.78 + 16;
75950
76502
  }
75951
- colBottom = drawNote(svg, parsed.description, paint, colLeft, top, colW);
76503
+ colBottom = drawNote(svg, parsed.description, paint, colLeft, top2, colW);
75952
76504
  } else if (hasTopTitle) {
75953
76505
  faceTitle(svg, parsed, paint, cx, GOAL_TITLE_SIZE);
75954
76506
  }
@@ -76474,7 +77026,7 @@ function vizMonthGrid(svg, g, nowMs, resolvedMs, C) {
76474
77026
  const gridW = mw - 2 * padX;
76475
77027
  const cols = 7;
76476
77028
  const cellW = gridW / cols;
76477
- const top = g.top;
77029
+ const top2 = g.top;
76478
77030
  const headH = 26;
76479
77031
  const cellH = (g.height - headH - 8) / 6;
76480
77032
  const gridH = 6 * cellH;
@@ -76484,8 +77036,8 @@ function vizMonthGrid(svg, g, nowMs, resolvedMs, C) {
76484
77036
  months.forEach((m, mi) => {
76485
77037
  const mt = isContext[mi] ? svg.append("g").attr("opacity", 0.42) : svg;
76486
77038
  const mx = g.left + mi * (mw + gap);
76487
- aRect(mt, mx, top, mw, g.height, 14, C.inert, C.inertBorder, 1.25);
76488
- const gy = top + headH;
77039
+ aRect(mt, mx, top2, mw, g.height, 14, C.inert, C.inertBorder, 1.25);
77040
+ const gy = top2 + headH;
76489
77041
  for (const wcol of [0, 6])
76490
77042
  aRect(
76491
77043
  mt,
@@ -76499,14 +77051,14 @@ function vizMonthGrid(svg, g, nowMs, resolvedMs, C) {
76499
77051
  aText(
76500
77052
  mt,
76501
77053
  mx + mw / 2,
76502
- top + 16,
77054
+ top2 + 16,
76503
77055
  14,
76504
77056
  C.text,
76505
77057
  700,
76506
77058
  "middle",
76507
77059
  `${MON_ABBR[m.getMonth()]} ${m.getFullYear()}`
76508
77060
  );
76509
- aLine(mt, mx, top + headH - 6, mx + mw, top + headH - 6, C.rule, 1.25);
77061
+ aLine(mt, mx, top2 + headH - 6, mx + mw, top2 + headH - 6, C.rule, 1.25);
76510
77062
  const first = new Date(m.getFullYear(), m.getMonth(), 1).getDay();
76511
77063
  const dim = new Date(m.getFullYear(), m.getMonth() + 1, 0).getDate();
76512
77064
  for (let day = 1; day <= dim; day++) {
@@ -77348,9 +77900,9 @@ function drawRow(svg, entry, index, parsed, now, rowTop, rowH, geom, col) {
77348
77900
  if (status) lines.push({ kind: "avail" });
77349
77901
  if (sun) lines.push({ kind: "sun" });
77350
77902
  const lh = 23;
77351
- const top = center + 10 - (lines.length - 1) * lh / 2;
77903
+ const top2 = center + 10 - (lines.length - 1) * lh / 2;
77352
77904
  lines.forEach((ln, i) => {
77353
- const yy = top + i * lh;
77905
+ const yy = top2 + i * lh;
77354
77906
  if (ln.kind === "place") {
77355
77907
  g.append("path").attr("transform", `translate(${iconX},${yy - 5}) scale(1.25)`).attr("d", "M0,4 L-2.3,-0.6 A2.6,2.6 0 1 1 2.3,-0.6 Z").attr("fill", muted);
77356
77908
  g.append("text").attr("x", textX).attr("y", yy).attr("fill", muted).attr("font-family", FONT_FAMILY).attr("font-size", 14).attr("font-weight", 500).text(ellipsize(entry.place, 14, textMax));
@@ -77390,15 +77942,15 @@ function bakeAnchors(g, entry, parsed, sun, sw) {
77390
77942
  );
77391
77943
  }
77392
77944
  }
77393
- function drawColumns(body, parsed, now, top, geom, col) {
77945
+ function drawColumns(body, parsed, now, top2, geom, col) {
77394
77946
  const { width, cardM } = geom;
77395
77947
  const { text, muted, line2: line22, tick, cardFill, sw } = col;
77396
77948
  const n = Math.max(1, parsed.entries.length);
77397
77949
  const colW = (width - 2 * cardM) / n;
77398
77950
  const tints = [];
77399
- let maxBottom = top;
77951
+ let maxBottom = top2;
77400
77952
  const deferred = [];
77401
- let detailTop = top;
77953
+ let detailTop = top2;
77402
77954
  parsed.entries.forEach((entry, i) => {
77403
77955
  const x0 = cardM + i * colW;
77404
77956
  const cx = x0 + colW / 2;
@@ -77437,13 +77989,13 @@ function drawColumns(body, parsed, now, top, geom, col) {
77437
77989
  bakeAnchors(g, entry, parsed, sun, sw);
77438
77990
  if (auto)
77439
77991
  tints.push(
77440
- g.append("rect").attr("data-dgmo-clock-lane", "").attr("x", x0).attr("y", top).attr("width", colW).attr("fill", fm === "outline" ? col.baseBg : auto.laneTint)
77992
+ g.append("rect").attr("data-dgmo-clock-lane", "").attr("x", x0).attr("y", top2).attr("width", colW).attr("fill", fm === "outline" ? col.baseBg : auto.laneTint)
77441
77993
  );
77442
77994
  if (auto) {
77443
77995
  g.attr("data-dgmo-clock-auto-solid", auto.solid).attr("data-dgmo-clock-auto-face", faceFill).attr("data-dgmo-clock-auto-mode", parsed.colorBy).attr("data-dgmo-clock-cardfill", cardFill);
77444
77996
  }
77445
77997
  if (fm) g.attr("data-dgmo-clock-fill-mode", fm);
77446
- let cy = top + (parsed.face === "analog" ? 22 : 36);
77998
+ let cy = top2 + (parsed.face === "analog" ? 22 : 36);
77447
77999
  const innerW = colW - 16;
77448
78000
  if (parsed.face === "analog") {
77449
78001
  const size = Math.min(innerW, 96);
@@ -77534,17 +78086,17 @@ function drawColumns(body, parsed, now, top, geom, col) {
77534
78086
  });
77535
78087
  deferred.forEach((d) => {
77536
78088
  d.draw(detailTop);
77537
- const bottom = d.kinds ? detailTop + (d.kinds - 1) * 20 + 8 : detailTop;
77538
- if (bottom > maxBottom) maxBottom = bottom;
78089
+ const bottom2 = d.kinds ? detailTop + (d.kinds - 1) * 20 + 8 : detailTop;
78090
+ if (bottom2 > maxBottom) maxBottom = bottom2;
77539
78091
  });
77540
- const colBodyH = maxBottom - top + 14;
78092
+ const colBodyH = maxBottom - top2 + 14;
77541
78093
  tints.forEach((r) => r.attr("height", colBodyH));
77542
78094
  const dividerColor = mix(col.palette.text, col.palette.bg, 40);
77543
78095
  for (let i = 1; i < n; i++) {
77544
78096
  const x = cardM + i * colW;
77545
- body.append("line").attr("data-dgmo-clock-col-divider", "").attr("x1", x).attr("x2", x).attr("y1", top).attr("y2", top + colBodyH).attr("stroke", dividerColor).attr("stroke-width", 1);
78097
+ body.append("line").attr("data-dgmo-clock-col-divider", "").attr("x1", x).attr("x2", x).attr("y1", top2).attr("y2", top2 + colBodyH).attr("stroke", dividerColor).attr("stroke-width", 1);
77546
78098
  }
77547
- return top + colBodyH + cardM;
78099
+ return top2 + colBodyH + cardM;
77548
78100
  }
77549
78101
  function renderClockForExport(container, parsed, palette, isDark, exportDims) {
77550
78102
  renderClock(container, parsed, palette, isDark, exportDims);
@@ -77960,36 +78512,36 @@ function layoutBracket(parsed) {
77960
78512
  champion = winnerNameOf(finalNode);
77961
78513
  }
77962
78514
  } else {
77963
- const left = groups[0];
77964
- const right = groups[1];
77965
- const L = left.built.rounds;
77966
- const R = right.built.rounds;
78515
+ const left2 = groups[0];
78516
+ const right2 = groups[1];
78517
+ const L = left2.built.rounds;
78518
+ const R = right2.built.rounds;
77967
78519
  const centerX = L * COL_W + BOX_W / 2;
77968
- for (const n of left.built.nodes) {
78520
+ for (const n of left2.built.nodes) {
77969
78521
  n.x = (n.round - 1) * COL_W + BOX_W / 2;
77970
78522
  n.y = n.y * rowScale;
77971
78523
  allNodes.push(n);
77972
78524
  nodeById.set(n.id, n);
77973
78525
  addColLabel(n.x, roundLabel(n.round, L, parsed.roundNames, true));
77974
78526
  }
77975
- for (const n of right.built.nodes) {
78527
+ for (const n of right2.built.nodes) {
77976
78528
  n.x = centerX + (R - n.round + 1) * COL_W;
77977
78529
  n.y = n.y * rowScale;
77978
78530
  allNodes.push(n);
77979
78531
  nodeById.set(n.id, n);
77980
78532
  addColLabel(n.x, roundLabel(n.round, R, parsed.roundNames, true));
77981
78533
  }
77982
- if (left.label)
77983
- pushSide(0, (L - 1) * COL_W + BOX_W, left.label, left.color);
77984
- if (right.label)
78534
+ if (left2.label)
78535
+ pushSide(0, (L - 1) * COL_W + BOX_W, left2.label, left2.color);
78536
+ if (right2.label)
77985
78537
  pushSide(
77986
78538
  centerX + COL_W - BOX_W / 2,
77987
78539
  centerX + R * COL_W + BOX_W / 2,
77988
- right.label,
77989
- right.color
78540
+ right2.label,
78541
+ right2.color
77990
78542
  );
77991
- const leftRoot = left.built.rootId !== null ? nodeById.get(left.built.rootId) : null;
77992
- const rightRoot = right.built.rootId !== null ? nodeById.get(right.built.rootId) : null;
78543
+ const leftRoot = left2.built.rootId !== null ? nodeById.get(left2.built.rootId) : null;
78544
+ const rightRoot = right2.built.rootId !== null ? nodeById.get(right2.built.rootId) : null;
77993
78545
  const cid = nextId();
77994
78546
  const champNode = {
77995
78547
  id: cid,
@@ -78323,9 +78875,9 @@ function renderBracket(container, parsed, palette, isDark, exportDims) {
78323
78875
  const covered = layout.sideLabels.some(
78324
78876
  (s) => col.x >= s.x0 && col.x <= s.x1
78325
78877
  );
78326
- const top = covered ? bandTop : 2;
78878
+ const top2 = covered ? bandTop : 2;
78327
78879
  const c = resolveColor(col.color, palette) ?? col.color;
78328
- root.append("rect").attr("x", col.x - BOX_W / 2 - 10).attr("y", top).attr("width", BOX_W + 20).attr("height", Math.max(0, layout.height - top)).attr("rx", 10).attr(
78880
+ root.append("rect").attr("x", col.x - BOX_W / 2 - 10).attr("y", top2).attr("width", BOX_W + 20).attr("height", Math.max(0, layout.height - top2)).attr("rx", 10).attr(
78329
78881
  "fill",
78330
78882
  fillMode === "outline" ? themeBaseBg(palette, isDark) : mix(c, palette.bg, isDark ? 12 : 8)
78331
78883
  ).call((sel) => {
@@ -79671,20 +80223,20 @@ function buildRenderSequence(messages) {
79671
80223
  for (let mi = 0; mi < messages.length; mi++) {
79672
80224
  const msg = messages[mi];
79673
80225
  while (stack.length > 0) {
79674
- const top = stack[stack.length - 1];
79675
- if (top.to === msg.from) break;
80226
+ const top2 = stack[stack.length - 1];
80227
+ if (top2.to === msg.from) break;
79676
80228
  stack.pop();
79677
80229
  steps.push({
79678
80230
  type: "return",
79679
- from: top.to,
79680
- to: top.from,
80231
+ from: top2.to,
80232
+ to: top2.from,
79681
80233
  label: "",
79682
- messageIndex: top.messageIndex
80234
+ messageIndex: top2.messageIndex
79683
80235
  });
79684
80236
  }
79685
80237
  if (stack.length > 0 && !msg.async && msg.from !== msg.to) {
79686
- const top = stack[stack.length - 1];
79687
- if (top.from === msg.to && top.to === msg.from) {
80238
+ const top2 = stack[stack.length - 1];
80239
+ if (top2.from === msg.to && top2.to === msg.from) {
79688
80240
  stack.pop();
79689
80241
  steps.push({
79690
80242
  type: "return",
@@ -79724,13 +80276,13 @@ function buildRenderSequence(messages) {
79724
80276
  }
79725
80277
  }
79726
80278
  while (stack.length > 0) {
79727
- const top = stack.pop();
80279
+ const top2 = stack.pop();
79728
80280
  steps.push({
79729
80281
  type: "return",
79730
- from: top.to,
79731
- to: top.from,
80282
+ from: top2.to,
80283
+ to: top2.from,
79732
80284
  label: "",
79733
- messageIndex: top.messageIndex
80285
+ messageIndex: top2.messageIndex
79734
80286
  });
79735
80287
  }
79736
80288
  return steps;
@@ -79836,11 +80388,11 @@ function applyGroupOrdering(participants, groups, messages = []) {
79836
80388
  const group = idToGroup.get(id);
79837
80389
  if (group && !placedGroups.has(group)) {
79838
80390
  placedGroups.add(group);
79839
- for (const gid of group.participantIds) {
79840
- const p = participants.find((pp) => pp.id === gid);
79841
- if (p && !placed.has(gid)) {
80391
+ for (const gid2 of group.participantIds) {
80392
+ const p = participants.find((pp) => pp.id === gid2);
80393
+ if (p && !placed.has(gid2)) {
79842
80394
  result.push(p);
79843
- placed.add(gid);
80395
+ placed.add(gid2);
79844
80396
  }
79845
80397
  }
79846
80398
  } else if (!group) {
@@ -81687,12 +82239,12 @@ function resolveVerticalCollisions(items, minGap, maxY) {
81687
82239
  let prevBottom = -Infinity;
81688
82240
  for (const item of sorted) {
81689
82241
  const halfH = item.height / 2;
81690
- let top = Math.max(item.naturalY - halfH, prevBottom + minGap);
82242
+ let top2 = Math.max(item.naturalY - halfH, prevBottom + minGap);
81691
82243
  if (maxY !== void 0) {
81692
- top = Math.min(top, maxY - item.height);
82244
+ top2 = Math.min(top2, maxY - item.height);
81693
82245
  }
81694
- adjustedY[item.idx] = top + halfH;
81695
- prevBottom = top + item.height;
82246
+ adjustedY[item.idx] = top2 + halfH;
82247
+ prevBottom = top2 + item.height;
81696
82248
  }
81697
82249
  return adjustedY;
81698
82250
  }
@@ -82753,8 +83305,8 @@ function renderVenn(container, parsed, palette, _isDark, onClickItem, exportDims
82753
83305
  const cci = circles[ci];
82754
83306
  const dy = py - cci.y;
82755
83307
  const halfChord = Math.sqrt(Math.max(0, cci.r * cci.r - dy * dy));
82756
- let left = cci.x - halfChord;
82757
- let right = cci.x + halfChord;
83308
+ let left2 = cci.x - halfChord;
83309
+ let right2 = cci.x + halfChord;
82758
83310
  for (let j = 0; j < n; j++) {
82759
83311
  if (j === ci) continue;
82760
83312
  const cj = circles[j];
@@ -82763,11 +83315,11 @@ function renderVenn(container, parsed, palette, _isDark, onClickItem, exportDims
82763
83315
  const hc = Math.sqrt(cj.r * cj.r - djy * djy);
82764
83316
  const jLeft = cj.x - hc;
82765
83317
  const jRight = cj.x + hc;
82766
- if (jLeft <= left && jRight >= right) return 0;
82767
- if (jLeft <= left && jRight > left) left = jRight;
82768
- if (jRight >= right && jLeft < right) right = jLeft;
83318
+ if (jLeft <= left2 && jRight >= right2) return 0;
83319
+ if (jLeft <= left2 && jRight > left2) left2 = jRight;
83320
+ if (jRight >= right2 && jLeft < right2) right2 = jLeft;
82769
83321
  }
82770
- return Math.max(0, right - left);
83322
+ return Math.max(0, right2 - left2);
82771
83323
  }
82772
83324
  const MIN_FONT = ctx.text(10);
82773
83325
  const MAX_FONT = ctx.text(22);
@@ -86702,7 +87254,7 @@ var CSS = AUTO_BASE_CSS + "\n" + BLOCK_CSS + "\n" + darkScopedBlockCss(BLOCK_CSS
86702
87254
 
86703
87255
  // src/auto/shared.ts
86704
87256
  init_safe_href();
86705
- var VERSION = "0.55.0";
87257
+ var VERSION = "0.56.0";
86706
87258
  var ARIA_LABEL_MAX = 200;
86707
87259
  var COPIED_INTERACTION_MS = 1500;
86708
87260
  var LOG_PREFIX = "[dgmo]";