boardplot 0.54.0 → 0.55.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +448 -0
- package/README.md +4 -4
- package/dist/{ReaderBox-YXC5XK7D.js → ReaderBox-3FFPHWSI.js} +14 -10
- package/dist/{annotateEngine-5O3IRSQL.js → annotateEngine-ET4DM2OK.js} +3 -1
- package/dist/build-identity.json +3 -3
- package/dist/{chunk-GVKFFJ23.js → chunk-2ALFFOKB.js} +460 -148
- package/dist/chunk-2BP6X5GX.js +125 -0
- package/dist/chunk-2C4SYWZ3.js +25 -0
- package/dist/{chunk-23RWLBZF.js → chunk-2TAK2ELB.js} +3 -3
- package/dist/{chunk-J33RA3YO.js → chunk-2YNF6AHH.js} +5 -5
- package/dist/{chunk-DDI2W4TR.js → chunk-32IKJMUF.js} +3 -3
- package/dist/{chunk-7X3UZM7F.js → chunk-33FCWTGT.js} +1 -1
- package/dist/{chunk-KL2XJQAA.js → chunk-37A6CLR5.js} +1729 -196
- package/dist/{chunk-EHDWWFNV.js → chunk-3AJY353W.js} +3 -3
- package/dist/chunk-3B3CFJ2H.js +48 -0
- package/dist/{chunk-6TJDWMZV.js → chunk-3B3K7TD5.js} +83 -9
- package/dist/{chunk-WDONXBQE.js → chunk-3C24WWUQ.js} +1 -1
- package/dist/{chunk-BWTX7LUG.js → chunk-3L2VXXM4.js} +9 -4
- package/dist/{chunk-OD3IH6FG.js → chunk-3OZRODC4.js} +39 -21
- package/dist/{chunk-JB4YPOMT.js → chunk-3XOWXLLQ.js} +6 -7
- package/dist/{chunk-JAKRPSWP.js → chunk-3ZAH24P6.js} +164 -51
- package/dist/{chunk-2THWIKRB.js → chunk-4CJ6UCX4.js} +33 -16
- package/dist/{chunk-VDAZPGR2.js → chunk-4DZFR52I.js} +2 -2
- package/dist/{chunk-AZIRTSVP.js → chunk-4WT3T5SH.js} +122 -52
- package/dist/{chunk-FPPN5NAR.js → chunk-4X3HNETE.js} +3 -3
- package/dist/{chunk-WZBMTZBM.js → chunk-4Y7BA2NW.js} +4 -4
- package/dist/{chunk-TSPWXAAI.js → chunk-4YHZSPAJ.js} +6 -7
- package/dist/{chunk-GSMWHKOW.js → chunk-5DMHMQFP.js} +7 -7
- package/dist/{chunk-E64MTTBC.js → chunk-5SHI57XD.js} +45 -14
- package/dist/{chunk-A5TY7H5T.js → chunk-5SLJGRUO.js} +139 -47
- package/dist/{chunk-47BO6MYI.js → chunk-5UVJKB7L.js} +137 -70
- package/dist/{chunk-D3D7XHBI.js → chunk-63L35UCI.js} +6 -6
- package/dist/{chunk-S6CRZKPO.js → chunk-6C64IBOG.js} +5 -5
- package/dist/{chunk-ENOCOA3F.js → chunk-6D4EO3S7.js} +5 -5
- package/dist/chunk-6H3OSHEY.js +25 -0
- package/dist/chunk-6WZZADRL.js +25 -0
- package/dist/{chunk-HGGLJYPZ.js → chunk-75TWO5B2.js} +89 -57
- package/dist/chunk-7ADUVRG5.js +14 -0
- package/dist/{chunk-U4P6TQRW.js → chunk-7DAH2E4T.js} +2 -2
- package/dist/{chunk-43OQ26TL.js → chunk-7FKY6YWU.js} +8 -8
- package/dist/{chunk-RKITD2UJ.js → chunk-7GVYMGLK.js} +6 -3
- package/dist/{chunk-DSZUV3TM.js → chunk-7Q2WV6D2.js} +3 -3
- package/dist/{chunk-JFBEAUJ6.js → chunk-7Q37C6GZ.js} +1 -1
- package/dist/{chunk-GEBGBJBD.js → chunk-7UPZPFHQ.js} +41 -34
- package/dist/{chunk-T7ZCYYQZ.js → chunk-7Z73MM35.js} +14 -6
- package/dist/{chunk-VWYUUBBP.js → chunk-AB35GVPG.js} +80 -31
- package/dist/{chunk-HZG5NB7Q.js → chunk-AF7EB6N6.js} +151 -84
- package/dist/chunk-AIU4GZV5.js +24 -0
- package/dist/{chunk-TNHD4UTC.js → chunk-AM2CG7VX.js} +13 -3
- package/dist/{chunk-BXEM2CVW.js → chunk-APQPYM2Z.js} +3 -3
- package/dist/{chunk-AHQ4L3BE.js → chunk-AZM4YNRE.js} +2 -2
- package/dist/{chunk-U2HQELXL.js → chunk-B3AXM3MT.js} +2 -2
- package/dist/{chunk-6I7YZTY7.js → chunk-BDGLMWPO.js} +12 -4
- package/dist/{chunk-MKVV7GVJ.js → chunk-BFFPYT3Y.js} +13 -7
- package/dist/{chunk-EYLWVI26.js → chunk-BGJRCG7N.js} +135 -114
- package/dist/{chunk-RNOJSEES.js → chunk-BK6P6KMW.js} +1 -1
- package/dist/{chunk-XB4KZ6WO.js → chunk-BSATR6ZO.js} +40 -13
- package/dist/{chunk-PDG4IM3L.js → chunk-BVYIKLQ5.js} +1 -1
- package/dist/chunk-BWVNCLUS.js +19 -0
- package/dist/{chunk-MT4MP3UZ.js → chunk-CKNOLGRR.js} +1 -1
- package/dist/chunk-CLGUFVHM.js +24 -0
- package/dist/{chunk-VAEC53B3.js → chunk-COQEHO7B.js} +3 -3
- package/dist/{chunk-3EZRM4YM.js → chunk-CPGASWNN.js} +25 -1
- package/dist/{chunk-SFQ5ADIG.js → chunk-CVIW2MV4.js} +284 -150
- package/dist/chunk-CYKIX3IQ.js +24 -0
- package/dist/{chunk-4MREJWRM.js → chunk-CZ3WCG55.js} +5 -4
- package/dist/{chunk-DRTA6JG5.js → chunk-D2B3KP35.js} +26 -15
- package/dist/{chunk-E42JZ2DA.js → chunk-D2QMNHCC.js} +4 -5
- package/dist/{chunk-AA4U62G6.js → chunk-D7G27EYZ.js} +4 -4
- package/dist/{chunk-3RMTPAEJ.js → chunk-DB2JKPOX.js} +806 -69
- package/dist/{chunk-G6XCUX3I.js → chunk-DEYAI662.js} +60 -13
- package/dist/{chunk-4WK3CNW5.js → chunk-DRHQG44U.js} +11 -0
- package/dist/{chunk-WZGJSQKN.js → chunk-DZ3S4RPI.js} +15 -1
- package/dist/{chunk-JTJNQKPM.js → chunk-E44W4EEG.js} +2 -2
- package/dist/{chunk-QJ4WGAC6.js → chunk-E5OEWMNX.js} +66 -12
- package/dist/chunk-E6HDUEGK.js +26 -0
- package/dist/{chunk-A7IEVBYI.js → chunk-E76U5H52.js} +1 -5
- package/dist/{chunk-2IXDYW6O.js → chunk-EAR43REB.js} +195 -57
- package/dist/{chunk-MYCLO35J.js → chunk-EBC5TMI2.js} +29 -8
- package/dist/chunk-EBVJCVXL.js +25 -0
- package/dist/chunk-EC2PGJ64.js +24 -0
- package/dist/chunk-EGPXEY2K.js +24 -0
- package/dist/{chunk-LYVOL4TQ.js → chunk-EQRFSVDD.js} +2 -1
- package/dist/{chunk-WKWMOZNE.js → chunk-EW47LNWH.js} +226 -61
- package/dist/{chunk-7EVIIADO.js → chunk-EXDMYV5W.js} +3 -1
- package/dist/{chunk-WMZCOGD6.js → chunk-EZZ533MH.js} +1 -1
- package/dist/{chunk-K4RCWNLC.js → chunk-F5V7YFKS.js} +11 -8
- package/dist/{chunk-JEYJRJ7M.js → chunk-F6CVYNDY.js} +5 -4
- package/dist/{chunk-NRHTC2SQ.js → chunk-F6OLHND5.js} +2 -2
- package/dist/chunk-FI5EXISD.js +27 -0
- package/dist/{chunk-F35DA442.js → chunk-FQF7GSJK.js} +46 -27
- package/dist/{chunk-GYNZ72GO.js → chunk-FS6ZE5TG.js} +2 -2
- package/dist/{chunk-6BJQULXR.js → chunk-G63WXSQP.js} +75 -34
- package/dist/{chunk-DHWCFQNO.js → chunk-GCSCHK5Y.js} +4 -18
- package/dist/{chunk-WUKSZNHL.js → chunk-GD5TYS5R.js} +32 -21
- package/dist/{chunk-RGZGLKFB.js → chunk-GDVR3XHT.js} +418 -62
- package/dist/{chunk-UTQGZF37.js → chunk-GDZI5ZJ7.js} +1 -1
- package/dist/{chunk-FMFCGYCE.js → chunk-GFIT3FRE.js} +277 -291
- package/dist/chunk-GM2HIU6C.js +24 -0
- package/dist/{chunk-MZJBPDIL.js → chunk-GMJFCBR6.js} +1 -1
- package/dist/{chunk-PBYUJSEY.js → chunk-H3AEYPRP.js} +66 -43
- package/dist/{chunk-BUPLB3EX.js → chunk-H3IBJQ5A.js} +6 -2
- package/dist/chunk-H4VDQ7OE.js +24 -0
- package/dist/{chunk-FV32N6AF.js → chunk-H5L2P2GO.js} +6 -4
- package/dist/{chunk-F7X53SZM.js → chunk-HFRQLMKK.js} +12 -7
- package/dist/{chunk-KJEZFOO6.js → chunk-HGT3UKDW.js} +91 -48
- package/dist/{chunk-B3F4TS3V.js → chunk-HJRNBKIT.js} +768 -69
- package/dist/{chunk-G63ROSY5.js → chunk-HLOXWM2O.js} +118 -62
- package/dist/{chunk-NGRIT3CY.js → chunk-HR2BKLS3.js} +113 -128
- package/dist/{chunk-S4QSJAGY.js → chunk-HZUAEMN5.js} +1 -1
- package/dist/{chunk-OZUTYDV4.js → chunk-IF2ZABAM.js} +2 -2
- package/dist/chunk-IF76JRXT.js +24 -0
- package/dist/{chunk-4ZGN4ZUN.js → chunk-IGNBQT23.js} +87 -3
- package/dist/{chunk-B6LHZLLK.js → chunk-IGVAWAOK.js} +31 -101
- package/dist/{chunk-KFWEO4UA.js → chunk-ILFQ75N4.js} +253 -141
- package/dist/chunk-INHDHZNP.js +8 -0
- package/dist/chunk-IOKWBUQP.js +25 -0
- package/dist/{chunk-JJJ2KAHR.js → chunk-IQDMZ33D.js} +20 -9
- package/dist/{chunk-IDDA5INB.js → chunk-IVRYF7QA.js} +7 -4
- package/dist/{chunk-L7RHB734.js → chunk-J5PL6JLL.js} +1 -1
- package/dist/chunk-JBMWRXDS.js +24 -0
- package/dist/{chunk-IDT7DJ7F.js → chunk-JKOEHRGV.js} +1 -1
- package/dist/chunk-JMGB444D.js +26 -0
- package/dist/chunk-JU7S52HI.js +26 -0
- package/dist/{chunk-BBL3R5YZ.js → chunk-JXBZIJCG.js} +1 -1
- package/dist/{chunk-WLZ54FWG.js → chunk-JYAZPMSA.js} +70 -1
- package/dist/chunk-K5S3K6QK.js +24 -0
- package/dist/{chunk-V7RAPZHX.js → chunk-KAYBRD4F.js} +3 -3
- package/dist/{chunk-OMNQXHFF.js → chunk-KC52E5G4.js} +31 -20
- package/dist/{chunk-LNKY5Z2X.js → chunk-KDSYZLF6.js} +2 -3
- package/dist/{chunk-C3O45JWU.js → chunk-KEDNHCGB.js} +4 -4
- package/dist/chunk-KFGZMHIB.js +28 -0
- package/dist/{chunk-QQNPU27R.js → chunk-KHRAJDBM.js} +1 -1
- package/dist/{chunk-ZTH6YSVA.js → chunk-KND4OM4B.js} +117 -102
- package/dist/{chunk-IM4WUIR7.js → chunk-KZH2QI6S.js} +2 -2
- package/dist/{chunk-IYEFEBRN.js → chunk-KZJ5VM6E.js} +14 -3
- package/dist/{chunk-CICWSCLC.js → chunk-LA5OYJ5P.js} +146 -69
- package/dist/{chunk-I2E3YDNZ.js → chunk-LAVVML3X.js} +33 -9
- package/dist/{chunk-TKQKXBGC.js → chunk-LD4LML5P.js} +10 -8
- package/dist/{chunk-OURX73UJ.js → chunk-LF6RTFNK.js} +13 -11
- package/dist/{chunk-HDZGZJKR.js → chunk-LFUJTEJO.js} +100 -36
- package/dist/{chunk-53OYF4ZT.js → chunk-LHKDZAWN.js} +16 -8
- package/dist/{chunk-5PCCSSII.js → chunk-LLDKKEUD.js} +1 -1
- package/dist/{chunk-VNLSTZES.js → chunk-LRCO4G7C.js} +314 -92
- package/dist/{chunk-HZZH3MQI.js → chunk-LSF76AS3.js} +7 -3
- package/dist/chunk-M427S3G7.js +25 -0
- package/dist/{chunk-WGIO6AHP.js → chunk-MEMPP7VZ.js} +3 -3
- package/dist/{chunk-K4K6KGEF.js → chunk-MJMOKPTF.js} +186 -167
- package/dist/chunk-MLGEBFEX.js +47 -0
- package/dist/chunk-MLW72KWN.js +24 -0
- package/dist/chunk-MQYIBGZE.js +19 -0
- package/dist/{chunk-6NLH6TEP.js → chunk-MTRV3BJL.js} +301 -130
- package/dist/{chunk-H4H4O62O.js → chunk-N5HN5QGH.js} +1 -1
- package/dist/chunk-N5TZL74Y.js +53 -0
- package/dist/chunk-N7N5NIAU.js +211 -0
- package/dist/{chunk-G57ZO7DB.js → chunk-NA6WLZ66.js} +66 -26
- package/dist/{chunk-XNA6DATU.js → chunk-NB7M4KX4.js} +99 -56
- package/dist/{chunk-WEPAE4KG.js → chunk-NCZWLV7T.js} +4 -4
- package/dist/{chunk-C54QLNE4.js → chunk-NGA7ICG4.js} +1 -1
- package/dist/{chunk-RZB4RPPD.js → chunk-NHYKSPL4.js} +154 -99
- package/dist/chunk-NMTWUYUF.js +30 -0
- package/dist/{chunk-XTGWCYAR.js → chunk-NOCIN2EM.js} +430 -256
- package/dist/{chunk-RK4S3VPS.js → chunk-NUCYUKVH.js} +3 -3
- package/dist/{chunk-S32YYDIB.js → chunk-NVGAEQ6M.js} +4 -3
- package/dist/{chunk-4FFCIQDG.js → chunk-O2KKQNGW.js} +4 -1
- package/dist/chunk-O36WX56O.js +13 -0
- package/dist/{chunk-P52JHUUM.js → chunk-O4WJWHCH.js} +187 -85
- package/dist/{chunk-MEG4NMSI.js → chunk-O6NJDRXE.js} +2 -2
- package/dist/{chunk-UYNAL3Y3.js → chunk-O7DVW3IE.js} +141 -68
- package/dist/{chunk-TNNK4IIY.js → chunk-O7W35PT3.js} +13 -12
- package/dist/{chunk-26P4WRQC.js → chunk-ODZJ4LW7.js} +6 -3
- package/dist/{chunk-7JQAUJOL.js → chunk-OHGEDG46.js} +1 -1
- package/dist/{chunk-ISWU5YB3.js → chunk-OJ2BPQGQ.js} +11 -5
- package/dist/chunk-ONKSGT2M.js +28 -0
- package/dist/{chunk-EP54VZI5.js → chunk-OOFSQ5AS.js} +1 -1
- package/dist/{chunk-SHH2AHIU.js → chunk-OY2UJ4XK.js} +64 -42
- package/dist/{chunk-OU5K2JPF.js → chunk-P6TA7M3G.js} +102 -32
- package/dist/{chunk-PJWLKCFX.js → chunk-PQYJZMCR.js} +98 -90
- package/dist/{chunk-ELPQZIGR.js → chunk-PYV6ZIR6.js} +37 -13
- package/dist/chunk-PZ46S2SY.js +69 -0
- package/dist/{chunk-5SJQOPL7.js → chunk-Q3E74U2W.js} +4 -4
- package/dist/{chunk-4TPHMIE5.js → chunk-QBJDHFJJ.js} +4 -2
- package/dist/chunk-QBRRJ5OR.js +24 -0
- package/dist/{chunk-3FNY7ZCG.js → chunk-QEP3X3OV.js} +141 -79
- package/dist/{chunk-OMVYFSOM.js → chunk-QKWBDH2L.js} +2 -2
- package/dist/{chunk-QY5ZKUWY.js → chunk-QOWE55RR.js} +9 -3
- package/dist/{chunk-LVXOY5WL.js → chunk-QRVIS2QB.js} +6 -5
- package/dist/chunk-R27IDIJI.js +24 -0
- package/dist/{chunk-FILDYFT4.js → chunk-RNIYG6PI.js} +2 -2
- package/dist/{chunk-AVMKRVNP.js → chunk-RO2PSSAI.js} +13 -23
- package/dist/{chunk-2DR5MMDY.js → chunk-ROLR7HRB.js} +12 -6
- package/dist/{chunk-YF2PYLC4.js → chunk-RSCRIWAH.js} +1 -1
- package/dist/{chunk-T3PNYRDM.js → chunk-RTXRIZYU.js} +370 -134
- package/dist/{chunk-GGO43PHB.js → chunk-RUWNG2JC.js} +6 -5
- package/dist/chunk-RYPJB3RO.js +132 -0
- package/dist/{chunk-DAVHGK27.js → chunk-S7NRL66K.js} +46 -23
- package/dist/{chunk-VABRPZVC.js → chunk-SA46CNMS.js} +5 -1
- package/dist/{chunk-ZXOD37BE.js → chunk-SBR2RLEQ.js} +72 -38
- package/dist/chunk-SC42DPNV.js +24 -0
- package/dist/{chunk-MBVXROCI.js → chunk-SFG7NG23.js} +20 -3
- package/dist/{chunk-AG2CJ4JY.js → chunk-SNQ7D5R7.js} +18 -1
- package/dist/{chunk-3V7AA3IZ.js → chunk-SPSGUFTI.js} +11 -3
- package/dist/chunk-SRUV7AT6.js +51 -0
- package/dist/{chunk-NRF223FR.js → chunk-SZXKV3BX.js} +1 -1
- package/dist/{chunk-5A6MO4AR.js → chunk-T5Y4HXYO.js} +7 -4
- package/dist/{chunk-QR35TD2B.js → chunk-U7W7GYXP.js} +37 -37
- package/dist/{chunk-LFX7W4B7.js → chunk-UDKYY27B.js} +1 -1
- package/dist/{chunk-24BHMKDD.js → chunk-UF3HSFAE.js} +25 -2
- package/dist/chunk-UIYXMPDW.js +24 -0
- package/dist/{chunk-CPKHL7FK.js → chunk-UNMIUILK.js} +1 -1
- package/dist/chunk-V3MSLNSD.js +24 -0
- package/dist/chunk-V634AXDM.js +31 -0
- package/dist/{chunk-57ZGVAU3.js → chunk-V7F4F6JA.js} +39 -6
- package/dist/{chunk-JEL6665C.js → chunk-VBVG6NEL.js} +6 -6
- package/dist/chunk-VL7WLE4H.js +24 -0
- package/dist/chunk-W45AR6EW.js +94 -0
- package/dist/{chunk-U7LLQ7XM.js → chunk-WALYNKBN.js} +446 -103
- package/dist/{chunk-J2ROMB7J.js → chunk-WAPCCJUB.js} +64 -26
- package/dist/{chunk-WQ55QPEB.js → chunk-WDIVAU5U.js} +241 -118
- package/dist/{chunk-EHVESNLV.js → chunk-WEMUCDPK.js} +1 -1
- package/dist/{chunk-HHS6333D.js → chunk-WFSOKGGA.js} +2 -2
- package/dist/{chunk-AJHYXD5U.js → chunk-WG5CJGLU.js} +2 -2
- package/dist/{chunk-WJKVNRCR.js → chunk-WQT6HIIY.js} +18 -17
- package/dist/{chunk-KAQH75T6.js → chunk-WSJDLZSZ.js} +78 -47
- package/dist/{chunk-3UBTO342.js → chunk-WWIY6BBY.js} +77 -38
- package/dist/{chunk-33PLBIMA.js → chunk-WXJ5MHLH.js} +3 -2
- package/dist/chunk-X3YP4DUV.js +76 -0
- package/dist/{chunk-ZNHF2XCP.js → chunk-X7XTIM6U.js} +50 -36
- package/dist/chunk-XJQXFVXY.js +24 -0
- package/dist/{chunk-NQSDIDRO.js → chunk-XMN3Z43K.js} +5 -5
- package/dist/{chunk-32X7JGH3.js → chunk-XPOMQWXY.js} +89 -69
- package/dist/chunk-XVUQMZWV.js +24 -0
- package/dist/chunk-XYYRHGQI.js +24 -0
- package/dist/{chunk-EYZ6SLF3.js → chunk-XZLU3G23.js} +7 -7
- package/dist/chunk-Y2CAIAUI.js +24 -0
- package/dist/{chunk-3P4PJJND.js → chunk-Y3L655X6.js} +6 -6
- package/dist/{chunk-QKL7IY42.js → chunk-Y54LU4CU.js} +1 -1
- package/dist/chunk-YGTNVZJE.js +89 -0
- package/dist/{chunk-4WQ2MBE7.js → chunk-YLC42C3M.js} +1 -1
- package/dist/{chunk-SGD3ZHID.js → chunk-YOOHNQ3L.js} +15 -4
- package/dist/{chunk-7NWFKHSG.js → chunk-YTCIGJUU.js} +116 -42
- package/dist/{chunk-ULTSSIOU.js → chunk-YV5KYGE5.js} +1 -1
- package/dist/{chunk-BRPOSOK5.js → chunk-YXM4W3TN.js} +144 -71
- package/dist/{chunk-7EOLHBI6.js → chunk-Z2X4JQNY.js} +81 -21
- package/dist/{chunk-SZCPKGYG.js → chunk-Z5V6ZM76.js} +3 -3
- package/dist/{chunk-KBFPMESI.js → chunk-Z7NHFNH3.js} +165 -79
- package/dist/{chunk-LTMF75MR.js → chunk-ZBSNF5F7.js} +208 -62
- package/dist/chunk-ZGHBDMYF.js +24 -0
- package/dist/{chunk-KORHKDJW.js → chunk-ZHFUMVW7.js} +2 -1
- package/dist/{chunk-YS56RSTZ.js → chunk-ZLYQWUNR.js} +84 -50
- package/dist/chunk-ZTMZOKVC.js +61 -0
- package/dist/cli/index.js +3 -3
- package/dist/{core-WJSKT5XM.js → core-2SICIP63.js} +5 -1
- package/dist/{core-CJ7FFPDU.js → core-2YTKFBNZ.js} +5 -1
- package/dist/{core-JLXFDYHX.js → core-3647Z25D.js} +4 -1
- package/dist/{core-ASBJZZTP.js → core-3IJPBNGC.js} +2 -1
- package/dist/{core-DJPGSTXB.js → core-6HMJHFRR.js} +8 -1
- package/dist/{core-ONNGSKWQ.js → core-7JKE7H32.js} +5 -1
- package/dist/{core-MNUVP5IJ.js → core-BMY7OL76.js} +5 -1
- package/dist/{core-GEUPUZUY.js → core-CAL7YNFC.js} +3 -1
- package/dist/{core-JLJTP7P6.js → core-CBEGB2NO.js} +3 -1
- package/dist/{core-XKV7GMPG.js → core-CLLIG7ZU.js} +2 -1
- package/dist/{core-L7Y7YXWR.js → core-CTZLHGXE.js} +1 -1
- package/dist/{core-KZK3WCUG.js → core-EYJ3WJK4.js} +3 -1
- package/dist/{core-KF6GJOGW.js → core-FX7HRKTF.js} +2 -1
- package/dist/{core-EAIFSTDE.js → core-GQC6VDW5.js} +3 -1
- package/dist/{core-R27R6J5M.js → core-GRWI22NS.js} +3 -1
- package/dist/{core-7YKLT7KY.js → core-H7KMWYP5.js} +4 -1
- package/dist/{core-CJZXX2V3.js → core-HJUGHAX7.js} +2 -1
- package/dist/{core-YPH723Z7.js → core-JMYMIH6Z.js} +8 -1
- package/dist/{core-7R3ARYNI.js → core-KEB5PBCO.js} +5 -1
- package/dist/{core-AEYGGH7X.js → core-MEC6A5DD.js} +4 -1
- package/dist/{core-L5KTPXHC.js → core-MV6KGAUV.js} +3 -1
- package/dist/{core-34KIMTK6.js → core-NTWHFDM4.js} +2 -1
- package/dist/{core-RGLOYY73.js → core-OIC5KJSD.js} +6 -1
- package/dist/{core-V7I4F6JW.js → core-OWCTIPHD.js} +5 -1
- package/dist/{core-RCFFJANI.js → core-PMYCLXT7.js} +5 -1
- package/dist/{core-MN45UFF4.js → core-PTRQPQTO.js} +3 -1
- package/dist/{core-DKJUX7Q4.js → core-QABTVASG.js} +2 -1
- package/dist/{core-PFXIBWLD.js → core-RPQBIOU4.js} +4 -1
- package/dist/{core-W7AZNHOX.js → core-SKRADU7T.js} +3 -1
- package/dist/{core-KII4CH3W.js → core-T2KHX5LG.js} +3 -1
- package/dist/{core-DAFZ7YJW.js → core-T4ZH3FAU.js} +2 -1
- package/dist/{core-WHI4ABF2.js → core-UAY2G7LN.js} +1 -1
- package/dist/{core-O2K4BDYH.js → core-ULZ7XUQP.js} +4 -1
- package/dist/{core-3CWPIFAL.js → core-VBR253SM.js} +3 -1
- package/dist/{core-YVNOHIQ4.js → core-VMIBBHXI.js} +3 -1
- package/dist/{core-KCORN7F7.js → core-XMTKUXLO.js} +3 -1
- package/dist/{core-QXIAQFHM.js → core-YEFGEW3Z.js} +3 -1
- package/dist/{dataTable-VKEHFLJM.js → dataTable-2ZXK54TP.js} +3 -2
- package/dist/{engine-PPXKJJFI.js → engine-HGXSWGOI.js} +26 -27
- package/dist/fixtures.js +6 -1
- package/dist/{fontTables-WYCZNRE7.js → fontTables-ZPZQ6IR3.js} +1 -1
- package/dist/fonts.js +2 -1
- package/dist/geo/dach.js +3 -1
- package/dist/geo/de-states.js +3 -1
- package/dist/geo/eu27.js +3 -1
- package/dist/geo/europe.js +3 -1
- package/dist/geo/index.js +4 -2
- package/dist/geo/us-states.js +3 -1
- package/dist/geo/world.js +3 -1
- package/dist/index.js +31 -27
- package/dist/{main-53MXACOU.js → main-PVT6FMGC.js} +54 -24
- package/dist/mcp/server.js +50 -23
- package/dist/{module-SVEW5ZUE.js → module-ZSR7KTAS.js} +1 -1
- package/dist/react/bar.js +6 -1
- package/dist/react/bartable.js +6 -1
- package/dist/react/box.js +6 -1
- package/dist/react/bullet.js +4 -1
- package/dist/react/butterfly.js +5 -1
- package/dist/react/choropleth.js +4 -1
- package/dist/react/cohort.js +4 -1
- package/dist/react/column.js +9 -1
- package/dist/react/combo.js +3 -1
- package/dist/react/creative.js +2 -1
- package/dist/react/diagram.js +3 -1
- package/dist/react/dimswitch.js +4 -1
- package/dist/react/dot.js +9 -1
- package/dist/react/export.js +33 -31
- package/dist/react/funnel.js +4 -1
- package/dist/react/gantt.js +3 -1
- package/dist/react/grid.js +4 -1
- package/dist/react/heatmap.js +4 -1
- package/dist/react/histogram.js +6 -1
- package/dist/react/index.js +94 -90
- package/dist/react/kpi.js +2 -1
- package/dist/react/likert.js +7 -1
- package/dist/react/line.js +4 -1
- package/dist/react/mekko.js +5 -1
- package/dist/react/pareto.js +3 -1
- package/dist/react/pie.js +5 -1
- package/dist/react/prepare.js +33 -28
- package/dist/react/pvm.js +4 -1
- package/dist/react/pyramid.js +5 -1
- package/dist/react/sankey.js +4 -1
- package/dist/react/scatter.js +4 -1
- package/dist/react/slope.js +6 -1
- package/dist/react/sparkline.js +4 -1
- package/dist/react/spec.js +25 -32
- package/dist/react/status.js +3 -1
- package/dist/react/story.js +6 -4
- package/dist/react/table.js +4 -1
- package/dist/react/theme.js +6 -3
- package/dist/react/tilemap.js +4 -1
- package/dist/react/treemap.js +3 -1
- package/dist/react/variance.js +5 -1
- package/dist/react/waffle.js +3 -1
- package/dist/react/waterfall.js +4 -1
- package/dist/{resvg-ZOVDIZTV.js → resvg-VB7S5HRF.js} +1 -1
- package/dist/rows.js +2 -3
- package/dist/{rowsModule-L3MBGPBH.js → rowsModule-JTDPTWXG.js} +2 -1
- package/dist/{schema-6ZV532RM.js → schema-2M3LXR35.js} +1 -1
- package/dist/{schema-WAKLKLBB.js → schema-2Q7IJ22V.js} +1 -1
- package/dist/{schema-IOKAZVL7.js → schema-3OLBUVMZ.js} +1 -1
- package/dist/{schema-ZSYX76MO.js → schema-3XLO43SX.js} +1 -1
- package/dist/{schema-KHCLVE2V.js → schema-5753NOAL.js} +1 -1
- package/dist/{schema-QNI6MNQ2.js → schema-5KHDHTIX.js} +1 -1
- package/dist/{schema-HWU55RJL.js → schema-76XRTBCJ.js} +1 -1
- package/dist/{schema-KFXLS67Q.js → schema-7CPGNCOL.js} +1 -1
- package/dist/{schema-26YUL3MG.js → schema-BKHQ3ZUH.js} +1 -1
- package/dist/{schema-CMXL5F5L.js → schema-BMD5JR3Y.js} +1 -1
- package/dist/{schema-HGUBNXUY.js → schema-BOGTPL7F.js} +1 -1
- package/dist/{schema-733PO52K.js → schema-BUTNGYTT.js} +1 -1
- package/dist/{schema-GSE3QXUK.js → schema-C7NVOQNV.js} +5 -3
- package/dist/{schema-LYBOPAGQ.js → schema-FNTAAXQ3.js} +1 -1
- package/dist/{schema-MNG24WU2.js → schema-FYULDJFB.js} +1 -1
- package/dist/{schema-4ZXJCRZR.js → schema-FZKNIAIH.js} +1 -1
- package/dist/{schema-IOWE3RQO.js → schema-G2PLJCYL.js} +1 -1
- package/dist/{schema-HRHNGOFC.js → schema-GGG2VOY7.js} +2 -2
- package/dist/{schema-WCDYWS4K.js → schema-GLN7IHSH.js} +1 -1
- package/dist/{schema-H7RKVTVO.js → schema-HIDW4BA4.js} +1 -1
- package/dist/{schema-KH62LDYK.js → schema-J53LCIY3.js} +1 -1
- package/dist/{schema-5E5J43CF.js → schema-KIJA53MB.js} +2 -1
- package/dist/{schema-3W7IFXVN.js → schema-LEQNLBNG.js} +1 -1
- package/dist/{schema-GK6MD4EG.js → schema-LHMEXFLY.js} +1 -1
- package/dist/{schema-FT37ZEYY.js → schema-MT6NA5AL.js} +1 -3
- package/dist/{schema-NOPOI5G2.js → schema-MUTAVQMI.js} +1 -1
- package/dist/{schema-PNUC54GC.js → schema-NVMEOHAW.js} +1 -1
- package/dist/{schema-QLH2DZFI.js → schema-TA3MSAPQ.js} +1 -1
- package/dist/{schema-B4GFRYIP.js → schema-U26KG42U.js} +1 -1
- package/dist/{schema-KORNUIC6.js → schema-UHHFTVGS.js} +1 -1
- package/dist/{schema-GVHM2HEF.js → schema-V3BPW4LA.js} +1 -1
- package/dist/{schema-SY3MKF5S.js → schema-WIZ2TZAT.js} +1 -1
- package/dist/{schema-ZCZCY34J.js → schema-WZLWHOMY.js} +1 -1
- package/dist/{schema-Q4IPIR6W.js → schema-XATDKZPW.js} +1 -1
- package/dist/{schema-SLQPM32G.js → schema-XHKSGMUH.js} +1 -1
- package/dist/{schema-33ZF6WKL.js → schema-XKY2EQFH.js} +1 -1
- package/dist/{schema-AQD3H5VV.js → schema-ZE7WUNFS.js} +1 -1
- package/dist/{specValidation-H5B4MQST.js → specValidation-X5XJBPTP.js} +3 -1
- package/dist/theme.js +4 -2
- package/dist/{themeShapeRules-54U5EIZR.js → themeShapeRules-PW4BQHKL.js} +1 -1
- package/dist/types/core/a11y/recordsShared.d.ts +4 -0
- package/dist/types/core/annotate.d.ts +39 -0
- package/dist/types/core/annotateArms.d.ts +1 -1
- package/dist/types/core/axis.d.ts +2 -0
- package/dist/types/core/calendarLabels.d.ts +15 -0
- package/dist/types/core/charts/band/stacks.d.ts +71 -2
- package/dist/types/core/charts/bartable/types.d.ts +10 -0
- package/dist/types/core/charts/choropleth/index.d.ts +7 -0
- package/dist/types/core/charts/choropleth/layout.d.ts +7 -0
- package/dist/types/core/charts/choropleth/schema.d.ts +36 -0
- package/dist/types/core/charts/cohort/types.d.ts +8 -1
- package/dist/types/core/charts/column/layout.d.ts +1 -1
- package/dist/types/core/charts/column/model.d.ts +4 -0
- package/dist/types/core/charts/combo/endpoints.d.ts +1 -1
- package/dist/types/core/charts/creative/types.d.ts +1 -1
- package/dist/types/core/charts/dimswitch/compile.d.ts +2 -0
- package/dist/types/core/charts/dimswitch/types.d.ts +8 -0
- package/dist/types/core/charts/grid/normalize.d.ts +18 -1
- package/dist/types/core/charts/heatmap/fixtures.d.ts +2 -2
- package/dist/types/core/charts/histogram/types.d.ts +14 -2
- package/dist/types/core/charts/likert/layout.d.ts +14 -9
- package/dist/types/core/charts/logAxis.d.ts +55 -0
- package/dist/types/core/charts/pvm/types.d.ts +6 -0
- package/dist/types/core/charts/pyramid/types.d.ts +7 -4
- package/dist/types/core/charts/sankey/types.d.ts +3 -1
- package/dist/types/core/charts/scatter/clamp.d.ts +155 -0
- package/dist/types/core/charts/scatter/frontier.d.ts +21 -0
- package/dist/types/core/charts/scatter/index.d.ts +9 -0
- package/dist/types/core/charts/scatter/layout.d.ts +26 -0
- package/dist/types/core/charts/scatter/logAxis.d.ts +14 -0
- package/dist/types/core/charts/scatter/model.d.ts +258 -0
- package/dist/types/core/charts/scatter/schema.d.ts +57 -0
- package/dist/types/core/charts/scatter/trend.d.ts +54 -0
- package/dist/types/core/charts/scatter/valueLines.d.ts +47 -0
- package/dist/types/core/charts/sparkline/fixtures.d.ts +1 -1
- package/dist/types/core/charts/status/layout.d.ts +5 -3
- package/dist/types/core/charts/table/resolve.d.ts +0 -7
- package/dist/types/core/charts/tilemap/index.d.ts +6 -0
- package/dist/types/core/charts/tilemap/layout.d.ts +5 -0
- package/dist/types/core/charts/tilemap/schema.d.ts +4 -0
- package/dist/types/core/charts/treemap/types.d.ts +2 -2
- package/dist/types/core/charts/variance/fixtures.d.ts +2 -1
- package/dist/types/core/charts/waffle/types.d.ts +2 -0
- package/dist/types/core/dateFormat.d.ts +1 -1
- package/dist/types/core/doc/diagnostics.d.ts +8 -0
- package/dist/types/core/doc/document.d.ts +9 -1
- package/dist/types/core/doc/ownedDocumentCopy.d.ts +2 -1
- package/dist/types/core/fontMetrics/index.d.ts +1 -1
- package/dist/types/core/footer.d.ts +9 -1
- package/dist/types/core/format.d.ts +4 -1
- package/dist/types/core/formatSpec.d.ts +84 -6
- package/dist/types/core/frame.d.ts +41 -8
- package/dist/types/core/geo/packs/registry.d.ts +3 -2
- package/dist/types/core/geometry.d.ts +19 -0
- package/dist/types/core/icons.d.ts +11 -0
- package/dist/types/core/inputError.d.ts +3 -0
- package/dist/types/core/isoDate.d.ts +2 -0
- package/dist/types/core/label/categoryRow.d.ts +8 -0
- package/dist/types/core/label/occupied.d.ts +5 -0
- package/dist/types/core/label/solver.d.ts +31 -2
- package/dist/types/core/notes.d.ts +13 -1
- package/dist/types/core/ols.d.ts +38 -0
- package/dist/types/core/periodYears.d.ts +5 -1
- package/dist/types/core/registry.d.ts +12 -0
- package/dist/types/core/request.d.ts +3 -2
- package/dist/types/core/scale.d.ts +7 -0
- package/dist/types/core/schema/capability.d.ts +17 -20
- package/dist/types/core/schema/namedColumns.d.ts +6 -0
- package/dist/types/core/schema/refusals.d.ts +1 -4
- package/dist/types/core/shareRounding.d.ts +8 -0
- package/dist/types/core/sizing.d.ts +17 -12
- package/dist/types/core/story.d.ts +3 -0
- package/dist/types/core/target.d.ts +6 -0
- package/dist/types/core/text.d.ts +8 -0
- package/dist/types/core/theme.d.ts +52 -1
- package/dist/types/core/types/annotations.d.ts +15 -3
- package/dist/types/core/types/data.d.ts +4 -1
- package/dist/types/core/types/diagram.d.ts +81 -2
- package/dist/types/core/types/optionInput.d.ts +13 -0
- package/dist/types/core/types/options.d.ts +65 -24
- package/dist/types/core/types/scene.d.ts +79 -2
- package/dist/types/core/types/table.d.ts +9 -0
- package/dist/types/core/types/theme.d.ts +48 -3
- package/dist/types/index.d.ts +28 -27
- package/dist/types/optionTypes.d.ts +44 -0
- package/dist/types/react/DimSwitchChart.d.ts +2 -1
- package/dist/types/react/RefusalBoundary.d.ts +25 -0
- package/dist/types/react/SceneRenderer.d.ts +3 -1
- package/dist/types/react/SizePlaceholder.d.ts +2 -1
- package/dist/types/react/TableChart.d.ts +8 -4
- package/dist/types/react/barrelCharts.d.ts +1521 -1012
- package/dist/types/react/charts/bar.d.ts +36 -25
- package/dist/types/react/charts/bartable.d.ts +36 -25
- package/dist/types/react/charts/box.d.ts +36 -25
- package/dist/types/react/charts/bullet.d.ts +36 -25
- package/dist/types/react/charts/butterfly.d.ts +36 -25
- package/dist/types/react/charts/choropleth.d.ts +36 -25
- package/dist/types/react/charts/cohort.d.ts +76 -50
- package/dist/types/react/charts/column.d.ts +36 -25
- package/dist/types/react/charts/combo.d.ts +2 -1
- package/dist/types/react/charts/creative.d.ts +31 -25
- package/dist/types/react/charts/diagram.d.ts +302 -160
- package/dist/types/react/charts/dot.d.ts +36 -25
- package/dist/types/react/charts/funnel.d.ts +36 -25
- package/dist/types/react/charts/gantt.d.ts +36 -25
- package/dist/types/react/charts/grid.d.ts +38 -27
- package/dist/types/react/charts/heatmap.d.ts +36 -25
- package/dist/types/react/charts/histogram.d.ts +36 -25
- package/dist/types/react/charts/kpi.d.ts +36 -25
- package/dist/types/react/charts/likert.d.ts +36 -25
- package/dist/types/react/charts/line.d.ts +36 -25
- package/dist/types/react/charts/mekko.d.ts +36 -25
- package/dist/types/react/charts/pareto.d.ts +33 -25
- package/dist/types/react/charts/pie.d.ts +36 -25
- package/dist/types/react/charts/pvm.d.ts +36 -25
- package/dist/types/react/charts/pyramid.d.ts +33 -25
- package/dist/types/react/charts/sankey.d.ts +36 -25
- package/dist/types/react/charts/scatter.d.ts +36 -25
- package/dist/types/react/charts/slope.d.ts +36 -25
- package/dist/types/react/charts/sparkline.d.ts +36 -25
- package/dist/types/react/charts/status.d.ts +36 -25
- package/dist/types/react/charts/tilemap.d.ts +36 -25
- package/dist/types/react/charts/treemap.d.ts +36 -25
- package/dist/types/react/charts/variance.d.ts +36 -25
- package/dist/types/react/charts/waffle.d.ts +36 -25
- package/dist/types/react/charts/waterfall.d.ts +36 -25
- package/dist/types/react/createChartComponent.d.ts +11 -9
- package/dist/types/react/footerFrame.d.ts +1 -1
- package/dist/types/react/hover/engine.d.ts +2 -1
- package/dist/types/react/hover/labelCard.d.ts +14 -2
- package/dist/types/react/prepare.d.ts +2 -2
- package/dist/types/react/prepared.d.ts +5 -1
- package/dist/types/react/useContainerSize.d.ts +2 -0
- package/dist/types/rows.d.ts +1 -1
- package/dist/validate.js +12 -8
- package/docs/manual.md +139 -35
- package/docs/reference/bar.md +10 -7
- package/docs/reference/bartable.md +7 -3
- package/docs/reference/box.md +5 -2
- package/docs/reference/bullet.md +7 -5
- package/docs/reference/butterfly.md +12 -5
- package/docs/reference/choropleth.md +9 -7
- package/docs/reference/cohort.md +3 -2
- package/docs/reference/column.md +14 -7
- package/docs/reference/combo.md +8 -6
- package/docs/reference/creative.md +1 -1
- package/docs/reference/diagram.md +94 -18
- package/docs/reference/dimswitch.md +16 -13
- package/docs/reference/dot.md +7 -4
- package/docs/reference/fixtures.md +49 -5
- package/docs/reference/funnel.md +4 -3
- package/docs/reference/gantt.md +1 -1
- package/docs/reference/grid.md +1 -1
- package/docs/reference/heatmap.md +6 -4
- package/docs/reference/histogram.md +7 -4
- package/docs/reference/kpi.md +11 -8
- package/docs/reference/likert.md +7 -3
- package/docs/reference/line.md +9 -8
- package/docs/reference/mekko.md +4 -4
- package/docs/reference/options.md +34 -32
- package/docs/reference/pareto.md +4 -4
- package/docs/reference/pie.md +8 -7
- package/docs/reference/pvm.md +4 -2
- package/docs/reference/pyramid.md +4 -4
- package/docs/reference/react.md +20 -11
- package/docs/reference/sankey.md +5 -3
- package/docs/reference/scatter.md +3 -3
- package/docs/reference/slope.md +7 -6
- package/docs/reference/sparkline.md +6 -5
- package/docs/reference/status.md +6 -4
- package/docs/reference/table.md +28 -26
- package/docs/reference/theme.md +93 -85
- package/docs/reference/tilemap.md +7 -6
- package/docs/reference/treemap.md +6 -5
- package/docs/reference/variance.md +8 -5
- package/docs/reference/waffle.md +2 -1
- package/docs/reference/waterfall.md +12 -9
- package/docs/use-cases.md +25 -2
- package/llms.txt +1 -1
- package/package.json +1 -1
- package/dist/chunk-2HXKW6U6.js +0 -24
- package/dist/chunk-35ZTANEK.js +0 -24
- package/dist/chunk-3CLLHMFF.js +0 -24
- package/dist/chunk-46ZPFJAM.js +0 -24
- package/dist/chunk-6BWSF5PS.js +0 -24
- package/dist/chunk-6K2TMVPF.js +0 -42
- package/dist/chunk-6KWIQ5KF.js +0 -18
- package/dist/chunk-6ZXMA4TY.js +0 -24
- package/dist/chunk-7HFUG25L.js +0 -24
- package/dist/chunk-7R5EV5MS.js +0 -24
- package/dist/chunk-7X65ZQN4.js +0 -38
- package/dist/chunk-ATUZTGZI.js +0 -25
- package/dist/chunk-BW5VLBSZ.js +0 -15
- package/dist/chunk-BYD7VLAI.js +0 -24
- package/dist/chunk-CEY646NZ.js +0 -28
- package/dist/chunk-D7GZPMHW.js +0 -24
- package/dist/chunk-FIANWJXX.js +0 -19
- package/dist/chunk-H4SYN3QA.js +0 -24
- package/dist/chunk-HC4NDND6.js +0 -24
- package/dist/chunk-HNVW3YDS.js +0 -25
- package/dist/chunk-HW7BPJNQ.js +0 -24
- package/dist/chunk-I5L3QTKQ.js +0 -24
- package/dist/chunk-IK4BHOPZ.js +0 -33
- package/dist/chunk-IMJXJHFW.js +0 -88
- package/dist/chunk-JDEVGTSX.js +0 -24
- package/dist/chunk-K2KU4HHT.js +0 -25
- package/dist/chunk-KDMKHR5A.js +0 -32
- package/dist/chunk-KNZD53L4.js +0 -24
- package/dist/chunk-KOJ5QETJ.js +0 -8
- package/dist/chunk-KSQEG6DX.js +0 -24
- package/dist/chunk-KVSJ2O4Q.js +0 -24
- package/dist/chunk-L3JWM7FR.js +0 -50
- package/dist/chunk-L7FSCT4M.js +0 -28
- package/dist/chunk-LMPZKCDM.js +0 -24
- package/dist/chunk-MONVTUHR.js +0 -24
- package/dist/chunk-NWQTSZYC.js +0 -24
- package/dist/chunk-OM67S6S4.js +0 -19
- package/dist/chunk-OTW5SEFS.js +0 -21
- package/dist/chunk-PGV25HTX.js +0 -25
- package/dist/chunk-QGCEHR6S.js +0 -13
- package/dist/chunk-T3IGJARD.js +0 -22
- package/dist/chunk-U2ES66IN.js +0 -26
- package/dist/chunk-U6CJPTOB.js +0 -19
- package/dist/chunk-VDVXGAIP.js +0 -24
- package/dist/chunk-VGWWUCAB.js +0 -24
- package/dist/chunk-X4U6PT3Z.js +0 -33
- package/dist/chunk-XXNLNZ7E.js +0 -24
- package/dist/chunk-ZBJNEJSL.js +0 -24
- package/dist/chunk-ZWJTHFWB.js +0 -27
- /package/dist/{DiagnosticDetails-UNYNYCAH.js → DiagnosticDetails-JFBBXOT2.js} +0 -0
|
@@ -1,26 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
2
|
chartPalette,
|
|
3
3
|
chartTheme
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-7DAH2E4T.js";
|
|
5
5
|
import {
|
|
6
6
|
diagramKindError
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-7Q37C6GZ.js";
|
|
8
8
|
import {
|
|
9
9
|
compileIcon
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import {
|
|
12
|
-
rowDrivenHeight
|
|
13
|
-
} from "./chunk-OTW5SEFS.js";
|
|
10
|
+
} from "./chunk-H3IBJQ5A.js";
|
|
14
11
|
import {
|
|
15
12
|
structureCount
|
|
16
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-UDKYY27B.js";
|
|
17
14
|
import {
|
|
18
15
|
CARD_MIN_WIDTH,
|
|
19
16
|
chartSizing,
|
|
20
17
|
contentSizing,
|
|
21
18
|
resolveSizing,
|
|
19
|
+
rowDrivenHeight,
|
|
22
20
|
sizeRefusal
|
|
23
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-WALYNKBN.js";
|
|
24
22
|
import {
|
|
25
23
|
PRIORITY,
|
|
26
24
|
boundsOf,
|
|
@@ -33,38 +31,42 @@ import {
|
|
|
33
31
|
labelsToNodes,
|
|
34
32
|
rectCenter,
|
|
35
33
|
rectContains,
|
|
34
|
+
rectLineDistance,
|
|
36
35
|
rectsOverlap,
|
|
36
|
+
seatLeader,
|
|
37
37
|
solveFrame,
|
|
38
38
|
solveLabels
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-2ALFFOKB.js";
|
|
40
40
|
import {
|
|
41
41
|
chartStrings
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-LHKDZAWN.js";
|
|
43
43
|
import {
|
|
44
44
|
canvasMargin,
|
|
45
45
|
contrastInkPaint,
|
|
46
46
|
dashToken,
|
|
47
47
|
emphasisWeight,
|
|
48
|
+
groundTextPaint,
|
|
48
49
|
headingWeight,
|
|
49
50
|
markRolePaint,
|
|
50
51
|
paintColor,
|
|
51
52
|
panelTypeClass,
|
|
52
53
|
resolveSurface,
|
|
53
54
|
resolveTheme,
|
|
55
|
+
secondaryFont,
|
|
54
56
|
seriesPaint,
|
|
55
57
|
strokeToken,
|
|
56
58
|
themeForWidth
|
|
57
|
-
} from "./chunk-
|
|
59
|
+
} from "./chunk-HJRNBKIT.js";
|
|
58
60
|
import {
|
|
59
61
|
monotonePath,
|
|
60
62
|
monotoneSegments
|
|
61
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-JYAZPMSA.js";
|
|
62
64
|
import {
|
|
63
65
|
NormalizeError,
|
|
64
66
|
TARGET_SIZE,
|
|
65
67
|
accessibleTitle,
|
|
66
68
|
resolveSize
|
|
67
|
-
} from "./chunk-
|
|
69
|
+
} from "./chunk-YOOHNQ3L.js";
|
|
68
70
|
import {
|
|
69
71
|
maxOf,
|
|
70
72
|
minOf,
|
|
@@ -73,8 +75,9 @@ import {
|
|
|
73
75
|
import {
|
|
74
76
|
compareText,
|
|
75
77
|
defaultMeasurer,
|
|
78
|
+
wrapNameText,
|
|
76
79
|
wrapText
|
|
77
|
-
} from "./chunk-
|
|
80
|
+
} from "./chunk-SNQ7D5R7.js";
|
|
78
81
|
|
|
79
82
|
// src/core/strings/diagram.ts
|
|
80
83
|
var EN = {
|
|
@@ -98,6 +101,9 @@ var EN = {
|
|
|
98
101
|
diagramIssueTree: "issue-tree",
|
|
99
102
|
diagramLinearProcess: "linear-process",
|
|
100
103
|
diagramCustomerJourney: "customer-journey",
|
|
104
|
+
diagramArchitecture: "architecture",
|
|
105
|
+
diagramCopies: "{v1} ({v2} copies)",
|
|
106
|
+
diagramProtected: "{v1} (marked protected)",
|
|
101
107
|
diagramCircularProcess: "circular-process",
|
|
102
108
|
diagramStrategyHouse: "strategy-house",
|
|
103
109
|
diagramRoadmap: "roadmap"
|
|
@@ -122,6 +128,9 @@ var EN = {
|
|
|
122
128
|
diagramIssueTree: "Problembaum",
|
|
123
129
|
diagramLinearProcess: "Linearer Ablauf",
|
|
124
130
|
diagramCustomerJourney: "Kundenablauf",
|
|
131
|
+
diagramArchitecture: "Architektur",
|
|
132
|
+
diagramCopies: "{v1} ({v2} Kopien)",
|
|
133
|
+
diagramProtected: "{v1} (als gesch\xFCtzt markiert)",
|
|
125
134
|
diagramCircularProcess: "Kreisprozess",
|
|
126
135
|
diagramStrategyHouse: "Strategiehaus",
|
|
127
136
|
diagramRoadmap: "Zeitplan"
|
|
@@ -145,17 +154,148 @@ var stableOrder = (items) => items.map((item, sourceIndex) => ({ item, sourceInd
|
|
|
145
154
|
).map(({ item }) => item);
|
|
146
155
|
function normalizeDiagramModel(rawData, rawOptions) {
|
|
147
156
|
if (!Array.isArray(rawData.nodes) || rawData.nodes.length === 0) throw new NormalizeError("empty-data", "nodes", "diagram requires at least one node");
|
|
148
|
-
let
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
157
|
+
let nodes = stableOrder(rawData.nodes).map((node) => ({ ...node })), groups = stableOrder(rawData.groups ?? []), groupEnds = /* @__PURE__ */ new Map(), resolveEnd = (edge, end) => {
|
|
158
|
+
let endpoint2 = edge[end];
|
|
159
|
+
if (!("groupId" in endpoint2)) return endpoint2;
|
|
160
|
+
if (rawOptions.variant !== "architecture") throw new NormalizeError("invalid-membership", `edges[${edge.id}].${end}`, `only variant 'architecture' ends an edge on a group, not '${rawOptions.variant}'`, "name a node, or set options.variant to architecture");
|
|
161
|
+
let member = nodes.find((node) => node.groupId !== void 0 && groupWithin(groups, node.groupId, endpoint2.groupId));
|
|
162
|
+
if (!member) throw new NormalizeError("invalid-membership", `edges[${edge.id}].${end}`, `group '${endpoint2.groupId}' has no nodes to end edge '${edge.id}' on`, `add a node to group '${endpoint2.groupId}'`);
|
|
163
|
+
return groupEnds.set(edge.id, { ...groupEnds.get(edge.id), [end]: endpoint2.groupId }), { nodeId: member.id };
|
|
164
|
+
}, data = {
|
|
165
|
+
nodes,
|
|
166
|
+
edges: (rawData.edges ?? []).map((edge) => ({ ...edge, source: resolveEnd(edge, "source"), target: resolveEnd(edge, "target") })).sort((a, b) => compareText(a.id, b.id)),
|
|
167
|
+
groups,
|
|
153
168
|
lanes: stableOrder(rawData.lanes ?? []),
|
|
154
|
-
key: rawData.key ?? []
|
|
169
|
+
key: rawData.key ?? [],
|
|
170
|
+
channels: rawData.channels ?? [],
|
|
171
|
+
callouts: rawData.callouts ?? [],
|
|
172
|
+
...rawData.inset ? { inset: rawData.inset } : {},
|
|
173
|
+
groupEnds
|
|
155
174
|
};
|
|
156
|
-
|
|
175
|
+
if (validatePreset(data, rawOptions, rawData.nodes), rawOptions.variant === "architecture") {
|
|
176
|
+
let policy = new Set(groups.filter((group) => group.kind === "policy").map((group) => group.id));
|
|
177
|
+
data.nodes = data.nodes.map((node) => node.groupId !== void 0 && policy.has(node.groupId) ? { ...node, shape: { kind: "text" } } : node), applyHighlight(data, rawOptions.highlight);
|
|
178
|
+
}
|
|
179
|
+
return { data, options: rawOptions };
|
|
180
|
+
}
|
|
181
|
+
function groupWithin(groups, id, within) {
|
|
182
|
+
let seen = /* @__PURE__ */ new Set();
|
|
183
|
+
for (let at = id; at !== void 0 && !seen.has(at); at = groups.find((group) => group.id === at)?.parentId) {
|
|
184
|
+
if (at === within) return !0;
|
|
185
|
+
seen.add(at);
|
|
186
|
+
}
|
|
187
|
+
return !1;
|
|
188
|
+
}
|
|
189
|
+
var DEVIATIONS = /* @__PURE__ */ new Set(["good", "bad", "warn", "category"]);
|
|
190
|
+
function applyHighlight(data, highlight) {
|
|
191
|
+
if (highlight === void 0) return;
|
|
192
|
+
let focus = typeof highlight == "string" ? [highlight] : highlight, named = new Set(focus), nodeIds = new Set(data.nodes.map((node) => node.id)), edgeIds = new Set(data.edges.map((edge) => edge.id)), unknown = focus.find((id) => !nodeIds.has(id) && !edgeIds.has(id));
|
|
193
|
+
if (unknown !== void 0) throw new NormalizeError("invalid-membership", "options.highlight", `highlight names '${unknown}', which is no node or edge`, "name ids of data.nodes or data.edges");
|
|
194
|
+
let focalNodes = new Set(focus.filter((id) => nodeIds.has(id))), pathNamed = focus.some((id) => edgeIds.has(id));
|
|
195
|
+
for (let edge of data.edges)
|
|
196
|
+
named.has(edge.id) && (focalNodes.add(edge.source.nodeId), focalNodes.add(edge.target.nodeId));
|
|
197
|
+
data.nodes = data.nodes.map((node) => DEVIATIONS.has(node.role) && focalNodes.has(node.id) ? node : { ...node, role: focalNodes.has(node.id) ? "accent" : "muted", paletteKey: void 0 }), data.edges = data.edges.map((edge) => (pathNamed ? named.has(edge.id) : focalNodes.has(edge.source.nodeId) && focalNodes.has(edge.target.nodeId)) ? { ...edge, role: "accent", paletteKey: void 0, weight: "strong" } : { ...edge, role: "muted", paletteKey: void 0 });
|
|
198
|
+
}
|
|
199
|
+
var ARCHITECTURE_NODE_REFUSALS = [
|
|
200
|
+
["position", "the engine owns geometry: use track and order"],
|
|
201
|
+
["size", "the engine sizes nodes from their text: shorten the text"],
|
|
202
|
+
["minSize", "the engine sizes nodes from their text: shorten the text"],
|
|
203
|
+
["caption", "use secondaryLabel"],
|
|
204
|
+
["ports", "the engine picks the ports: remove them"]
|
|
205
|
+
];
|
|
206
|
+
function validateGroups(data, options) {
|
|
207
|
+
let byId = new Map(data.groups.map((group) => [group.id, group]));
|
|
208
|
+
for (let group of data.groups) {
|
|
209
|
+
let path = [group.id];
|
|
210
|
+
for (let at = group.parentId; at !== void 0; at = byId.get(at)?.parentId) {
|
|
211
|
+
if (path.includes(at)) throw new NormalizeError("diagram-group-cycle", `groups[${group.id}].parentId`, `the groups ${[...path, at].map((id) => `'${id}'`).join(" \u2192 ")} form a cycle`, `remove parentId from group '${at}'`);
|
|
212
|
+
path.push(at);
|
|
213
|
+
}
|
|
214
|
+
if (path.length > 3) throw new NormalizeError("invalid-membership", `groups[${group.id}].parentId`, `group '${group.id}' sits ${path.length} levels deep, and zones nest up to three`, "flatten one level");
|
|
215
|
+
if (group.parentId !== void 0 && options.flow === "lanes") throw new NormalizeError("invalid-membership", `groups[${group.id}].parentId`, "flow 'lanes' draws flat zones", "remove parentId, or use flow 'columns'");
|
|
216
|
+
}
|
|
217
|
+
let policies = data.groups.filter((group) => group.kind === "policy");
|
|
218
|
+
if (policies.length > 1) throw new NormalizeError("invalid-membership", "groups", "an exhibit has one policy strip", `merge group '${policies[1].id}' into '${policies[0].id}'`);
|
|
219
|
+
let policy = policies[0];
|
|
220
|
+
if (!policy) return;
|
|
221
|
+
if (policy.parentId !== void 0 || policy.protected || data.groups.some((group) => group.parentId === policy.id))
|
|
222
|
+
throw new NormalizeError("invalid-membership", `groups[${policy.id}]`, "a policy strip spans the exhibit, so it takes no parent, no child and no protection", "use a zone for that");
|
|
223
|
+
let wired = data.edges.find((edge) => [edge.source.nodeId, edge.target.nodeId].some((id) => data.nodes.find((node) => node.id === id)?.groupId === policy.id));
|
|
224
|
+
if (wired) throw new NormalizeError("invalid-membership", `edges[${wired.id}]`, `edge '${wired.id}' touches the policy strip, whose items take no edges`, "move the node to a zone, or remove the edge");
|
|
225
|
+
}
|
|
226
|
+
function validateArchitecture(data, options) {
|
|
227
|
+
validateGroups(data, options);
|
|
228
|
+
let policy = data.groups.find((group) => group.kind === "policy")?.id;
|
|
229
|
+
if (options.flow === "lanes") {
|
|
230
|
+
if (data.lanes.length === 0) throw new NormalizeError("invalid-membership", "lanes", "flow 'lanes' requires data.lanes", "add data.lanes, or remove options.flow");
|
|
231
|
+
let vertical = data.lanes.find((lane) => lane.orientation !== "horizontal");
|
|
232
|
+
if (vertical) throw new NormalizeError("invalid-membership", `lanes[${vertical.id}].orientation`, "flow 'lanes' stacks horizontal lanes", `set lane '${vertical.id}' to orientation 'horizontal'`);
|
|
233
|
+
let outside = data.nodes.find((node) => !node.laneId && (policy === void 0 || node.groupId !== policy));
|
|
234
|
+
if (outside) throw new NormalizeError("invalid-membership", `nodes[${outside.id}].laneId`, `flow 'lanes' requires every node to name its lane, and '${outside.id}' names none`, `set nodes[${outside.id}].laneId`);
|
|
235
|
+
let policyNode = data.nodes.find((node) => policy !== void 0 && node.groupId === policy && node.laneId !== void 0);
|
|
236
|
+
if (policyNode) throw new NormalizeError("invalid-membership", `nodes[${policyNode.id}].laneId`, `policy node '${policyNode.id}' cannot also belong to a lane`, "remove laneId from the policy node, or move it out of the policy strip");
|
|
237
|
+
} else if (data.lanes.length > 0 || data.nodes.some((node) => node.laneId))
|
|
238
|
+
throw new NormalizeError("invalid-membership", "lanes", "flow 'columns' reads groups, not lanes", "set options.flow to 'lanes', or remove the lanes");
|
|
239
|
+
for (let node of data.nodes) {
|
|
240
|
+
for (let [field, fix] of ARCHITECTURE_NODE_REFUSALS)
|
|
241
|
+
if (node[field] !== void 0) throw new NormalizeError("invalid-membership", `nodes[${node.id}].${field}`, `variant 'architecture' does not read ${field}`, fix);
|
|
242
|
+
if (!["rectangle", "roundedRect", "store"].includes(node.shape.kind))
|
|
243
|
+
throw new NormalizeError("invalid-membership", `nodes[${node.id}].shape`, `variant 'architecture' does not draw shape '${node.shape.kind}'`, "use shape 'rectangle', 'roundedRect' or 'store'");
|
|
244
|
+
if (node.shape.kind === "store" && node.repeat !== void 0) throw new NormalizeError("invalid-membership", `nodes[${node.id}].repeat`, "a store draws no stacked copies", "remove repeat, or use a rectangle");
|
|
245
|
+
}
|
|
246
|
+
for (let edge of data.edges) {
|
|
247
|
+
if (edge.waypoints) throw new NormalizeError("invalid-membership", `edges[${edge.id}].waypoints`, "variant 'architecture' does not read waypoints", "the engine routes every edge: use track to line up its nodes");
|
|
248
|
+
if (edge.routing) throw new NormalizeError("invalid-membership", `edges[${edge.id}].routing`, "variant 'architecture' does not read routing", "the engine routes every edge: remove routing");
|
|
249
|
+
if (edge.source.portId || edge.target.portId) throw new NormalizeError("invalid-membership", `edges[${edge.id}]`, "variant 'architecture' does not read portId", "the engine picks the ports: remove portId");
|
|
250
|
+
}
|
|
251
|
+
let forward = data.edges.filter((edge) => edge.flow !== "return" && edge.source.nodeId !== edge.target.nodeId), waiting = new Map(data.nodes.map((node) => [node.id, 0]));
|
|
252
|
+
for (let edge of forward) waiting.set(edge.target.nodeId, waiting.get(edge.target.nodeId) + 1);
|
|
253
|
+
let ready = data.nodes.filter((node) => waiting.get(node.id) === 0).map((node) => node.id);
|
|
254
|
+
for (let id of ready)
|
|
255
|
+
for (let edge of forward)
|
|
256
|
+
edge.source.nodeId === id && (waiting.set(edge.target.nodeId, waiting.get(edge.target.nodeId) - 1), waiting.get(edge.target.nodeId) === 0 && ready.push(edge.target.nodeId));
|
|
257
|
+
let looped = forward.filter((edge) => waiting.get(edge.source.nodeId) > 0 && waiting.get(edge.target.nodeId) > 0);
|
|
258
|
+
if (looped.length > 0)
|
|
259
|
+
throw new NormalizeError(
|
|
260
|
+
"diagram-cycle",
|
|
261
|
+
"edges",
|
|
262
|
+
`the forward edges ${looped.map((edge) => `'${edge.id}'`).join(", ")} form a cycle`,
|
|
263
|
+
`set flow: 'return' on the edge that closes the loop, for example '${looped[looped.length - 1].id}'`
|
|
264
|
+
);
|
|
265
|
+
let edgeIds = new Set(data.edges.map((edge) => edge.id)), channelled = /* @__PURE__ */ new Set();
|
|
266
|
+
for (let channel of data.channels)
|
|
267
|
+
for (let id of channel.edgeIds) {
|
|
268
|
+
if (!edgeIds.has(id)) throw new NormalizeError("diagram-channel-mismatch", `channels[${channel.id}].edgeIds`, `channel '${channel.id}' names the unknown edge '${id}'`, "name an edge of data.edges");
|
|
269
|
+
if (channelled.has(id)) throw new NormalizeError("diagram-channel-mismatch", `channels[${channel.id}].edgeIds`, `edge '${id}' is in two channels`, "keep each edge in one channel");
|
|
270
|
+
channelled.add(id);
|
|
271
|
+
}
|
|
272
|
+
for (let [id, ends] of data.groupEnds) {
|
|
273
|
+
let edge = data.edges.find((item) => item.id === id), other = (end) => data.nodes.find((node) => node.id === edge[end].nodeId)?.groupId, inner = (group, end) => group !== void 0 && (ends[end] !== void 0 ? groupWithin(data.groups, ends[end], group) : groupWithin(data.groups, other(end) ?? "", group));
|
|
274
|
+
if (inner(ends.source, "target") || inner(ends.target, "source")) throw new NormalizeError("invalid-membership", `edges[${id}]`, `edge '${id}' ends on a zone that holds its other end`, "end it on a node");
|
|
275
|
+
if (ends.source !== void 0 && data.groups.find((group) => group.id === ends.source)?.kind === "policy") throw new NormalizeError("invalid-membership", `edges[${id}]`, "a policy strip takes no edges", "end the edge on a zone");
|
|
276
|
+
if (ends.target !== void 0 && data.groups.find((group) => group.id === ends.target)?.kind === "policy") throw new NormalizeError("invalid-membership", `edges[${id}]`, "a policy strip takes no edges", "end the edge on a zone");
|
|
277
|
+
}
|
|
278
|
+
let groupIds = new Set(data.groups.map((group) => group.id)), calloutTargets = /* @__PURE__ */ new Set();
|
|
279
|
+
for (let callout of data.callouts) {
|
|
280
|
+
let target = callout.target;
|
|
281
|
+
if (!("nodeId" in target ? data.nodes.some((node) => node.id === target.nodeId) : "edgeId" in target ? edgeIds.has(target.edgeId) : groupIds.has(target.groupId))) throw new NormalizeError("invalid-membership", `callouts[${callout.id}].target`, `callout '${callout.id}' names an unknown target`, "name a node, edge or group of this diagram");
|
|
282
|
+
if ("groupId" in target && options.flow === "lanes" && data.groups.find((group) => group.id === target.groupId)?.kind !== "policy" && !data.nodes.some((node) => node.groupId === target.groupId))
|
|
283
|
+
throw new NormalizeError("invalid-membership", `callouts[${callout.id}].target`, `callout '${callout.id}' targets empty zone '${target.groupId}', which has no frame in flow 'lanes'`, `add a node to zone '${target.groupId}', or choose another target`);
|
|
284
|
+
let targetKey = "nodeId" in target ? `node:${target.nodeId}` : "edgeId" in target ? `edge:${target.edgeId}` : `group:${target.groupId}`;
|
|
285
|
+
if (calloutTargets.has(targetKey)) throw new NormalizeError("invalid-membership", `callouts[${callout.id}].target`, `callout '${callout.id}' targets a node, edge or zone that already has a callout`, "merge the callout text into one callout");
|
|
286
|
+
calloutTargets.add(targetKey);
|
|
287
|
+
}
|
|
157
288
|
}
|
|
158
289
|
function validatePreset(data, options, authoredNodes) {
|
|
290
|
+
if (options.variant === "architecture") {
|
|
291
|
+
validateArchitecture(data, options);
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
let architectureOnly = data.nodes.find((node) => node.track !== void 0 || node.span !== void 0 || node.repeat !== void 0 || node.protected !== void 0 || node.shape.kind === "store")?.id ?? data.edges.find((edge) => edge.flow !== void 0)?.id ?? data.groups.find((group) => group.kind !== void 0 || group.parentId !== void 0 || group.protected !== void 0)?.id ?? (data.channels.length > 0 ? "channels" : data.callouts.length > 0 ? "callouts" : data.inset ? "inset" : void 0);
|
|
295
|
+
if (architectureOnly !== void 0)
|
|
296
|
+
throw new NormalizeError("invalid-membership", architectureOnly, `track, span, repeat, protected, shape store, edge flow, group kind, parentId, channels, callouts and inset are read only by variant 'architecture', not '${options.variant}'`, "remove them, or set options.variant to 'architecture'");
|
|
297
|
+
let looped = data.edges.find((edge) => edge.source.nodeId === edge.target.nodeId);
|
|
298
|
+
if (looped) throw new NormalizeError("invalid-membership", `edges[${looped.id}]`, `self-loops are read only by variant 'architecture', not '${options.variant}'`, "remove the edge");
|
|
159
299
|
let membership = data.nodes.filter((node) => node.groupId || node.laneId), requireKinds = () => {
|
|
160
300
|
let error = diagramKindError(authoredNodes, options);
|
|
161
301
|
if (error) throw error;
|
|
@@ -268,7 +408,7 @@ function validateMonotonePins(data, options) {
|
|
|
268
408
|
}
|
|
269
409
|
|
|
270
410
|
// src/core/charts/diagram/primitives.ts
|
|
271
|
-
var q = (value) => Math.round(value * 2) / 2, qPoint = (point) => ({ x: q(point.x), y: q(point.y) }), qRect = (rect) => ({
|
|
411
|
+
var q = (value) => Math.round(value * 2) / 2, BOX_LABEL_INSET = 8, gapSpread = (fixedHeight, plotH, naturalH, gapSum) => fixedHeight && gapSum > 0 ? Math.min(2.6, 1 + 0.8 * Math.max(0, plotH - naturalH) / gapSum) : 1, qPoint = (point) => ({ x: q(point.x), y: q(point.y) }), qRect = (rect) => ({
|
|
272
412
|
x: q(rect.x),
|
|
273
413
|
y: q(rect.y),
|
|
274
414
|
w: q(rect.w),
|
|
@@ -385,6 +525,9 @@ function nodeShapeScene(node, resolved, palette, theme, org) {
|
|
|
385
525
|
radius: q(node.shape.radius ?? nodeRadius(theme))
|
|
386
526
|
});
|
|
387
527
|
break;
|
|
528
|
+
case "store":
|
|
529
|
+
out.push({ t: "path", ...common, d: org?.d ?? storePath(rect, q(Math.min(rect.h / 4, 2 * theme.space.labelPad))), fill, stroke, width: ringWidth });
|
|
530
|
+
break;
|
|
388
531
|
case "chevron": {
|
|
389
532
|
let tip = q(Math.min(rect.w * (node.shape.tip ?? 0.16), rect.h));
|
|
390
533
|
out.push({
|
|
@@ -465,6 +608,10 @@ function nodeShapeScene(node, resolved, palette, theme, org) {
|
|
|
465
608
|
}
|
|
466
609
|
return out;
|
|
467
610
|
}
|
|
611
|
+
function storePath(rect, cap) {
|
|
612
|
+
let [x0, x1, y0, y1] = [q(rect.x), q(rect.x + rect.w), q(rect.y + cap), q(rect.y + rect.h - cap)], curve = (from, to, y, bulge) => `C${from} ${q(y + bulge)} ${to} ${q(y + bulge)} ${to} ${q(y)}`;
|
|
613
|
+
return `M${x0} ${y0}${curve(x0, x1, y0, -(4 * cap) / 3)}L${x1} ${y1}${curve(x1, x0, y1, 4 * cap / 3)}ZM${x1} ${y0}${curve(x1, x0, y0, 4 * cap / 3)}`;
|
|
614
|
+
}
|
|
468
615
|
function roundedRectPath(rect, radius) {
|
|
469
616
|
let r = q(Math.min(radius, rect.w / 2, rect.h / 2));
|
|
470
617
|
return `M${q(rect.x + r)} ${q(rect.y)}L${q(rect.x + rect.w - r)} ${q(rect.y)}Q${q(rect.x + rect.w)} ${q(rect.y)} ${q(rect.x + rect.w)} ${q(rect.y + r)}L${q(rect.x + rect.w)} ${q(rect.y + rect.h - r)}Q${q(rect.x + rect.w)} ${q(rect.y + rect.h)} ${q(rect.x + rect.w - r)} ${q(rect.y + rect.h)}L${q(rect.x + r)} ${q(rect.y + rect.h)}Q${q(rect.x)} ${q(rect.y + rect.h)} ${q(rect.x)} ${q(rect.y + rect.h - r)}L${q(rect.x)} ${q(rect.y + r)}Q${q(rect.x)} ${q(rect.y)} ${q(rect.x + r)} ${q(rect.y)}Z`;
|
|
@@ -530,6 +677,8 @@ function dispatchPreset(theme, context) {
|
|
|
530
677
|
return layoutStrategyHouse(context);
|
|
531
678
|
case "roadmap":
|
|
532
679
|
return layoutRoadmap(theme, context);
|
|
680
|
+
case "architecture":
|
|
681
|
+
return emptyResult(context.data);
|
|
533
682
|
}
|
|
534
683
|
}
|
|
535
684
|
var emptyResult = (data) => ({
|
|
@@ -763,7 +912,7 @@ function layoutIssueTree(context) {
|
|
|
763
912
|
);
|
|
764
913
|
for (let node of context.data.nodes) {
|
|
765
914
|
if (!node.secondaryLabel) continue;
|
|
766
|
-
let width = Math.max(1, widths.get(ranks.get(node.id) ?? 0) - 4 * context.u), primary =
|
|
915
|
+
let width = Math.max(1, widths.get(ranks.get(node.id) ?? 0) - 4 * context.u), primary = wrapNameText(node.label, context.font, width, 3, context.measure).lines.length, secondary = wrapText(node.secondaryLabel, context.font, width, 2, context.measure).lines.length, size = context.sizes.get(node.id), icon = node.icon || node.shape.kind === "icon" ? 4.5 * context.u : 0;
|
|
767
916
|
context.sizes.set(node.id, { ...size, height: Math.max(size.height, (primary + secondary) * context.lineHeight + icon + 3.5 * context.u) });
|
|
768
917
|
}
|
|
769
918
|
let nodeGap = 2 * context.u, subtreeHeights = /* @__PURE__ */ new Map(), subtreeHeight = (id) => {
|
|
@@ -774,7 +923,7 @@ function layoutIssueTree(context) {
|
|
|
774
923
|
}, root = [...columns.get(0) ?? []].sort(nodeOrder)[0], totalHeight = subtreeHeight(root.id);
|
|
775
924
|
if (totalHeight > context.plot.h) {
|
|
776
925
|
let heights = context.data.nodes.map((node) => {
|
|
777
|
-
let size = context.sizes.get(node.id), width = Math.max(1, widths.get(ranks.get(node.id) ?? 0) - 4 * context.u), primary =
|
|
926
|
+
let size = context.sizes.get(node.id), width = Math.max(1, widths.get(ranks.get(node.id) ?? 0) - 4 * context.u), primary = wrapNameText(node.label, context.font, width, 3, context.measure).lines.length, icon = node.icon || node.shape.kind === "icon" ? 4.5 * context.u : 0, minimum = Math.max(
|
|
778
927
|
7 * context.u,
|
|
779
928
|
primary * context.lineHeight + icon + 3 * context.u,
|
|
780
929
|
node.minSize?.height ?? 0,
|
|
@@ -1013,18 +1162,18 @@ function layoutJourney(theme, context) {
|
|
|
1013
1162
|
});
|
|
1014
1163
|
}), result.readingOrder = lanes.flatMap((lane) => membersByLane.get(lane.id).map((node) => node.id)), result;
|
|
1015
1164
|
}
|
|
1016
|
-
function circularRing(steps, plot, u, text) {
|
|
1165
|
+
function circularRing(steps, plot, u, text, edges = []) {
|
|
1017
1166
|
let cap = Math.min(plot.w, plot.h) / 3.5, lineHeight = text.font.size * (text.font.lineHeight ?? 1.2), own = (step) => {
|
|
1018
1167
|
let icon = step.icon || step.shape.kind === "icon" ? 2.5 * lineHeight : 0, secondary = step.secondaryLabel ? Math.min(cap, text.measure(step.secondaryLabel, text.font).width + 4 * u) : 0;
|
|
1019
1168
|
return Math.max(icon, secondary, step.size?.width ?? 0, step.size?.height ?? 0, step.minSize?.width ?? 0, step.minSize?.height ?? 0);
|
|
1020
|
-
}, diameter = Math.max(8 * u, Math.min(16 + 0.08 * plot.w, 0.6 * plot.h), maxOf(steps.map(own))), captionHeight = Math.max(0, maxOf(steps.map((step) => step.caption ? wrapText(step.caption, text.font, Math.max(diameter, 16 * u), 2, text.measure).lines.length * lineHeight + 2 * u : 0))), minRadius = steps.length > 2 ? (diameter + captionHeight + 2 * u) / (2 * Math.sin(Math.PI / steps.length)) : diameter + captionHeight, labelWidth = Math.min(18 * u, plot.w / 5), maxRadius = Math.min((plot.h - 2 * circularLabelBand(text.font, u) - diameter) / 2, (plot.w - diameter) / 2 - labelWidth - 2 * u);
|
|
1021
|
-
return { diameter, radius: Math.max(minRadius, Math.min(20 + 0.128 * plot.w, maxRadius)) };
|
|
1169
|
+
}, s = Math.sin(Math.PI / Math.max(2, steps.length)), spaced = (plot.h - 2 * circularLabelBand(text.font, u)) * s / (1.6 + s), diameter = Math.max(8 * u, Math.min(16 + 0.08 * plot.w, 0.6 * plot.h, spaced), maxOf(steps.map(own))), captionHeight = Math.max(0, maxOf(steps.map((step) => step.caption ? wrapText(step.caption, text.font, Math.max(diameter, 16 * u), 2, text.measure).lines.length * lineHeight + 2 * u : 0))), minRadius = steps.length > 2 ? (diameter + captionHeight + 2 * u) / (2 * Math.sin(Math.PI / steps.length)) : diameter + captionHeight, labelWidth = Math.min(18 * u, plot.w / 5), maxRadius = Math.min((plot.h - 2 * circularLabelBand(text.font, u) - diameter) / 2, (plot.w - diameter) / 2 - labelWidth - 2 * u), edgeWidth = maxOf(edges.map((edge) => edge.label ? text.measure(edge.label, text.font).width : 0)), edgeGap = edgeWidth > 0 ? Math.max(2 * lineHeight, Math.min(24 * u, edgeWidth)) + 4 * u : 0, labelledRadius = edgeGap > 0 ? (diameter + captionHeight + edgeGap) / (2 * s) : 0;
|
|
1170
|
+
return { diameter, radius: Math.max(minRadius, Math.min(Math.max(20 + 0.128 * plot.w, labelledRadius), maxRadius)) };
|
|
1022
1171
|
}
|
|
1023
1172
|
function circularLabelBand(font, u) {
|
|
1024
1173
|
return 2 * font.size * (font.lineHeight ?? 1.2) + 2 * u;
|
|
1025
1174
|
}
|
|
1026
1175
|
function layoutCircular(context) {
|
|
1027
|
-
let result = emptyResult(context.data), steps = [...context.data.nodes].sort(nodeOrder), { diameter: ringDiameter, radius } = circularRing(steps, context.plot, context.u, context), centre = { x: context.plot.x + context.plot.w / 2, y: context.plot.y + context.plot.h / 2 };
|
|
1176
|
+
let result = emptyResult(context.data), steps = [...context.data.nodes].sort(nodeOrder), { diameter: ringDiameter, radius } = circularRing(steps, context.plot, context.u, context, context.data.edges), centre = { x: context.plot.x + context.plot.w / 2, y: context.plot.y + context.plot.h / 2 };
|
|
1028
1177
|
return steps.forEach((node, index) => {
|
|
1029
1178
|
let angle = -Math.PI / 2 + index * Math.PI * 2 / steps.length, diameter = ringDiameter;
|
|
1030
1179
|
result.nodeRects.set(
|
|
@@ -1049,13 +1198,13 @@ function layoutCircular(context) {
|
|
|
1049
1198
|
}), result.syntheticEdgeIds = result.edges.map((edge) => edge.id)), placeAuthored(result, context), result;
|
|
1050
1199
|
}
|
|
1051
1200
|
function strategyHouseBands(data, width, u, font, measure, headFont = font) {
|
|
1052
|
-
let lineH = font.size * (font.lineHeight ?? 1.2), groups = data.groups, columnW = width / Math.max(1, groups.length), lines = (node, w) => node ?
|
|
1201
|
+
let lineH = font.size * (font.lineHeight ?? 1.2), groups = data.groups, columnW = width / Math.max(1, groups.length), lines = (node, w) => node ? wrapNameText(node.label, node.kind === "initiative" || node.kind === "enabler" ? font : headFont, Math.max(1, w - 4 * u), 3, measure).lines.length : 1, objectives = data.nodes.filter((node) => node.kind === "objective").sort(nodeOrder), enablers = data.nodes.filter((node) => node.kind === "enabler").sort(nodeOrder), foundation = data.nodes.find((node) => node.kind === "foundation"), columns = groups.map((group) => data.nodes.filter((node) => node.kind === "initiative" && node.groupId === group.id).sort(nodeOrder)), rows = Math.max(1, maxOf(columns.map((cells2) => cells2.length))), pad = 2.6 * u, wide = width >= 120 * u, header = Math.max(1, maxOf(objectives.map((node) => lines(node, columnW - u)))) * lineH + (wide ? 3.3 * u : pad), cells = Array.from({ length: rows }, (_, row) => Math.max(2, maxOf(columns.map((cells2) => cells2[row] ? lines(cells2[row], columnW - u) : 1))) * lineH + (wide ? 4.2 * u : pad)), bands = enablers.map((node) => lines(node, width - u) * lineH + pad), base = lines(foundation, width) * lineH + pad, roof = Math.max(3.6 * lineH, 0.09 * width), gap = { roof: 1.2 * u, header: wide ? 1.2 * u : 0.8 * u, cell: wide ? 1.2 * u : 0.8 * u, body: wide ? 2.8 * u : 2 * u, band: 0.6 * u, base: u }, height = roof + gap.roof + header + gap.header + cells.reduce((sum, value) => sum + value, 0) + Math.max(0, rows - 1) * gap.cell + (bands.length > 0 ? gap.body + bands.reduce((sum, value) => sum + value, 0) + (bands.length - 1) * gap.band + gap.base : gap.body) + base;
|
|
1053
1202
|
return { roof, header, cells, bands, base, gap, height, inset: wide ? 0.8 * u : 0.6 * u };
|
|
1054
1203
|
}
|
|
1055
1204
|
function layoutStrategyHouse(context) {
|
|
1056
|
-
let result = emptyResult(context.data), vision = context.data.nodes.find((node) => node.kind === "vision"), foundation = context.data.nodes.find((node) => node.kind === "foundation"), enablers = context.data.nodes.filter((node) => node.kind === "enabler").sort(nodeOrder), objectives = context.data.nodes.filter((node) => node.kind === "objective").sort(nodeOrder), groups = context.data.groups, px = Math.ceil(context.plot.x * 2) / 2, py = Math.ceil(context.plot.y * 2) / 2, pw = Math.floor((context.plot.x + context.plot.w) * 2) / 2 - px, ph = Math.floor((context.plot.y + context.plot.h) * 2) / 2 - py,
|
|
1205
|
+
let result = emptyResult(context.data), vision = context.data.nodes.find((node) => node.kind === "vision"), foundation = context.data.nodes.find((node) => node.kind === "foundation"), enablers = context.data.nodes.filter((node) => node.kind === "enabler").sort(nodeOrder), objectives = context.data.nodes.filter((node) => node.kind === "objective").sort(nodeOrder), groups = context.data.groups, px = Math.ceil(context.plot.x * 2) / 2, py = Math.ceil(context.plot.y * 2) / 2, pw = Math.floor((context.plot.x + context.plot.w) * 2) / 2 - px, ph = Math.floor((context.plot.y + context.plot.h) * 2) / 2 - py, raw = strategyHouseBands(context.data, pw, context.u, context.font, context.measure, context.headFont), visionWrap = wrapText(vision.label, context.headFont ?? context.font, Math.max(1, pw - 4 * context.u), 3, context.measure).lines, visionLines = visionWrap.length, visionNeeds = visionLines * context.lineHeight + 2.6 * context.u, keepsVision = ph > visionNeeds ? (raw.roof * ph - visionNeeds * raw.height) / (ph - visionNeeds) : 0, roofCut = Math.max(0, Math.min(raw.height - ph, raw.roof - 2.4 * context.lineHeight, keepsVision)), bands = { ...raw, roof: raw.roof - roofCut, height: raw.height - roofCut }, k = ph / bands.height, columnW = pw / groups.length, inset = bands.inset, bodyTop = py + (bands.roof + bands.gap.roof) * k, cellTop = bodyTop + (bands.header + bands.gap.header) * k, foundationTop = q(py + ph - bands.base * k);
|
|
1057
1206
|
result.nodeRects.set(vision.id, qRect({ x: px, y: py, w: pw, h: bands.roof * k }));
|
|
1058
|
-
let
|
|
1207
|
+
let roofH = bands.roof * k, widest = Math.max(...visionWrap.map((line) => context.measure(line, context.headFont ?? context.font).width)), clearOfSlopes = 2 * (roofH * (widest / 2 + context.u)) / (pw / 2) - roofH + visionLines * context.lineHeight, roofReserve = Math.min(Math.max(roofH / 3, clearOfSlopes), roofH - 2.5 * context.u - visionLines * context.lineHeight);
|
|
1059
1208
|
roofReserve > 0 && result.contentTopReserves.set(vision.id, roofReserve);
|
|
1060
1209
|
let bottom = cellTop;
|
|
1061
1210
|
groups.forEach((group, groupIndex) => {
|
|
@@ -1191,20 +1340,20 @@ function groupsFromMembers(context, result) {
|
|
|
1191
1340
|
return groups.map(({ group, members, rects, memberBounds, pad }, index) => {
|
|
1192
1341
|
let header = Math.max(group.padding ?? pad, line + context.u / 2), left = memberBounds.x - pad, right = memberBounds.x + memberBounds.w + pad, title = { x: memberBounds.x, w: memberBounds.w }, entered = rects.filter((rect, at) => parents.has(members[at].id) && rect.y === memberBounds.y);
|
|
1193
1342
|
if (entered.length > 0) {
|
|
1194
|
-
let
|
|
1343
|
+
let crossings2 = entered.map(centre).sort((a, b) => a - b), edges = [left, ...crossings2.flatMap((x) => [x - context.u, x + context.u]), right], stretches = edges.flatMap((x, at) => at % 2 === 0 ? [{ x, w: edges[at + 1] - x }] : []), top = memberBounds.y - pad, bottom = memberBounds.y + memberBounds.h + pad, beside = [...frames.filter((_, at) => at !== index), ...[...result.nodeRects].flatMap(([id, rect]) => members.some((node) => node.id === id) ? [] : [rect])].filter((rect) => rect.y < bottom && rect.y + rect.h > top), roomLeft = Math.max(0, left - Math.max(context.plot.x, maxOf(beside.filter((rect) => rect.x + rect.w <= left).map((rect) => rect.x + rect.w + context.u)))), roomRight = Math.max(0, Math.min(context.plot.x + context.plot.w, minOf(beside.filter((rect) => rect.x >= right).map((rect) => rect.x - context.u))) - right), runs = entered.map((rect) => {
|
|
1195
1344
|
let [a, b] = [centre(rect), parents.get(members[rects.indexOf(rect)].id)].sort((p, q2) => p - q2);
|
|
1196
1345
|
return { a, b };
|
|
1197
|
-
}),
|
|
1346
|
+
}), place2 = (need, clearOfRuns) => {
|
|
1198
1347
|
let fits = stretches.map((stretch2, at2) => ({ stretch: stretch2, at: at2, room: at2 === 0 ? roomLeft : at2 === stretches.length - 1 ? roomRight : 0 })).filter(({ stretch: stretch2, room }) => stretch2.w + room >= need && (!clearOfRuns || runs.every(({ a, b }) => stretch2.x >= b || stretch2.x + stretch2.w <= a)));
|
|
1199
1348
|
if (fits.length === 0) return !1;
|
|
1200
1349
|
let { stretch, at } = fits.reduce((best, fit) => fit.stretch.w > best.stretch.w ? fit : best), grow = Math.max(0, need - stretch.w);
|
|
1201
1350
|
return at === 0 ? left -= grow : right += grow, title = { x: at === 0 ? stretch.x - grow : stretch.x, w: stretch.w + grow }, !0;
|
|
1202
1351
|
};
|
|
1203
|
-
if (!
|
|
1352
|
+
if (!place2(width(group.title) + 2 * context.u, !0) && !place2(width(group.title) + 2 * context.u, !1)) {
|
|
1204
1353
|
let words = group.title.split(" "), split = words.slice(1).map((_, at) => Math.max(width(words.slice(0, at + 1).join(" ")), width(words.slice(at + 1).join(" "))));
|
|
1205
|
-
split.length > 0 &&
|
|
1354
|
+
split.length > 0 && place2(Math.min(...split) + 2 * context.u, !0) ? header = Math.max(header, 2 * line + context.u / 2) : title = stretches.reduce((best, stretch) => stretch.w > best.w ? stretch : best);
|
|
1206
1355
|
}
|
|
1207
|
-
}
|
|
1356
|
+
} else width(group.title) + BOX_LABEL_INSET > title.w && (title = { x: left, w: right - left }, width(group.title) + BOX_LABEL_INSET > title.w && (header = Math.max(header, 2 * line + context.u / 2)));
|
|
1208
1357
|
return frames[index] = { x: left, y: memberBounds.y - header, w: right - left, h: memberBounds.h + header + pad }, {
|
|
1209
1358
|
id: group.id,
|
|
1210
1359
|
bounds: qRect(frames[index]),
|
|
@@ -1253,7 +1402,7 @@ function levelsOf(data) {
|
|
|
1253
1402
|
return levels;
|
|
1254
1403
|
}
|
|
1255
1404
|
var byOrder = (a, b) => a.order === void 0 || b.order === void 0 ? 0 : a.order - b.order || compareText(a.id, b.id);
|
|
1256
|
-
function layoutOrgChart(data, plot, labelFont, measure, u) {
|
|
1405
|
+
function layoutOrgChart(data, plot, labelFont, measure, u, fixedHeight = !1) {
|
|
1257
1406
|
let levels = levelsOf(data), root = data.nodes.find((node) => levels.get(node.id) === 0), kidsOf = (id) => data.edges.filter((edge) => edge.source.nodeId === id).map((edge) => data.nodes.find((node) => node.id === edge.target.nodeId)).sort(byOrder), branches = kidsOf(root.id), leaves = new Map(branches.map((branch) => [branch.id, kidsOf(branch.id)])), leafFont = { ...labelFont, size: labelFont.size > 13 ? labelFont.size - 1 : labelFont.size }, fonts = new Map(data.nodes.map((node) => [node.id, levels.get(node.id) === 2 ? leafFont : labelFont])), text = (node) => measure(node.label, fonts.get(node.id)).width, icon = 4 * u, iconLead = 6.8 * u, padRight = u, leafPad = (mode2) => mode2 === "tree" ? 2 * u : 1.8 * u, need = (node, mode2) => node.icon ? iconLead + text(node) + padRight : (levels.get(node.id) === 2 ? leafPad(mode2) : 2 * u) + text(node) + padRight, rootNeed = text(root) + 4 * u + (root.icon ? icon + u : 0), maxNeed = (nodes, mode2) => Math.max(0, maxOf(nodes.map((node) => need(node, mode2)))), allLeaves = [...leaves.values()].flat(), wide = plot.w >= 160 * u, lineFloor = (font) => font.size * (font.lineHeight ?? 1.2) + 2 * u, heightsFor = (mode2) => {
|
|
1258
1407
|
let base = mode2 === "tree" ? wide ? [8.8, 8, 6.8] : [8, 7.6, 6.4] : mode2 === "stacked" ? [7.2, 6.8, 5.8] : [6.8, 6.8, 5.6];
|
|
1259
1408
|
return [Math.max(base[0] * u, lineFloor(labelFont)), Math.max(base[1] * u, lineFloor(labelFont)), Math.max(base[2] * u, lineFloor(leafFont))];
|
|
@@ -1266,8 +1415,8 @@ function layoutOrgChart(data, plot, labelFont, measure, u) {
|
|
|
1266
1415
|
let gap = (wide ? 2.4 : 1.6) * u, columnGap = (wide ? 10.8 : 6) * u, slots = branches.map((branch) => Math.max(1, leaves.get(branch.id).length)), total = slots.reduce((sum, value) => sum + value, 0), leafW = Math.min(28 * u, (plot.w - (branches.length - 1) * columnGap - slots.reduce((sum, value) => sum + (value - 1) * gap, 0)) / total), columns = slots.map((count) => count * leafW + (count - 1) * gap), narrowest = minOf(columns), branchW = Math.min(narrowest, Math.max(maxNeed(branches, "tree"), 0.65 * narrowest));
|
|
1267
1416
|
if (leafW >= maxNeed(allLeaves, "tree") && branchW >= maxNeed(branches, "tree")) {
|
|
1268
1417
|
mode = "tree";
|
|
1269
|
-
let [h0, h1, h2] = heightsFor(mode),
|
|
1270
|
-
height =
|
|
1418
|
+
let [h0, h1, h2] = heightsFor(mode), natural = (wide ? [7.2, 5.2] : [7.2, 4.8]).map((value) => value * u), bodies = h0 + h1 + (allLeaves.length > 0 ? h2 : 0), spread = gapSpread(fixedHeight, plot.h, bodies + natural[0] + (allLeaves.length > 0 ? natural[1] : 0), natural[0] + (allLeaves.length > 0 ? natural[1] : 0)), [gap0, gap1] = natural.map((value) => value * spread);
|
|
1419
|
+
height = bodies + gap0 + (allLeaves.length > 0 ? gap1 : 0);
|
|
1271
1420
|
let top = plot.y + Math.max(0, (plot.h - height) / 2), rootW = Math.min(plot.w, Math.max(rootNeed, Math.min(1.29 * branchW, 0.36 * plot.w))), span = columns.reduce((sum, value) => sum + value, 0) + (branches.length - 1) * columnGap;
|
|
1272
1421
|
put(root.id, { x: plot.x + (plot.w - rootW) / 2, y: top, w: rootW, h: h0 });
|
|
1273
1422
|
let left = plot.x + (plot.w - span) / 2;
|
|
@@ -1298,10 +1447,10 @@ function layoutOrgChart(data, plot, labelFont, measure, u) {
|
|
|
1298
1447
|
let column = (plot.w - (branches.length - 1) * columnGap) / branches.length;
|
|
1299
1448
|
if (column < maxNeed(branches, "stacked") || column - 3.6 * u < maxNeed(allLeaves, "stacked")) continue;
|
|
1300
1449
|
mode = "stacked";
|
|
1301
|
-
let [h0, h1, h2] = heightsFor(mode),
|
|
1450
|
+
let [h0, h1, h2] = heightsFor(mode), first = 2.4 * u, pitch = h2 + 1.4 * u, deepest = Math.max(0, maxOf(branches.map((branch) => {
|
|
1302
1451
|
let count = leaves.get(branch.id).length;
|
|
1303
1452
|
return count === 0 ? 0 : first + count * pitch - 1.4 * u;
|
|
1304
|
-
})));
|
|
1453
|
+
}))), gap0 = 4.8 * u * gapSpread(fixedHeight, plot.h, h0 + 4.8 * u + h1 + deepest, 4.8 * u);
|
|
1305
1454
|
height = h0 + gap0 + h1 + deepest;
|
|
1306
1455
|
let top = plot.y + Math.max(0, (plot.h - height) / 2), rootW = Math.min(plot.w, Math.max(rootNeed, Math.min(1.29 * column, 0.36 * plot.w)));
|
|
1307
1456
|
put(root.id, { x: plot.x + (plot.w - rootW) / 2, y: top, w: rootW, h: h0 }), branches.forEach((branch, index) => {
|
|
@@ -1427,10 +1576,10 @@ function layoutIssueTreeCompact(data, plot, labelFont, measure, u, headWeight) {
|
|
|
1427
1576
|
let indented = Math.max(...Array.from({ length: depth - 1 }, (_, index) => widest(index + 1))) + 2 * pad * u, leafNeed = widest(depth) + 2 * pad * u, spare = plot.w - (depth - 1) * indent * u - bracket * u - indented - leafNeed;
|
|
1428
1577
|
if (widest(0) + 2 * pad * u > plot.w || spare < 0) continue;
|
|
1429
1578
|
mode = "outline";
|
|
1430
|
-
let nodeW = indented + spare / 2, leafW = leafNeed + spare / 2, leafX = plot.x + plot.w - leafW, rootH = Math.max(lineFloor, 6.8 * u), branchH = Math.max(lineFloor, 6 * u), rowH = Math.max(lineFloor, 5.6 * u), placed = [[root.id, { x: plot.x, y: 0, w: plot.w, h: rootH }]], y = rootH + 3.2 * u,
|
|
1579
|
+
let nodeW = indented + spare / 2, leafW = leafNeed + spare / 2, leafX = plot.x + plot.w - leafW, rootH = Math.max(lineFloor, 6.8 * u), branchH = Math.max(lineFloor, 6 * u), rowH = Math.max(lineFloor, 5.6 * u), placed = [[root.id, { x: plot.x, y: 0, w: plot.w, h: rootH }]], y = rootH + 3.2 * u, place2 = (node, isFirst) => {
|
|
1431
1580
|
let level = levels.get(node.id), x = plot.x + level * indent * u, kids = kidsOf(node.id);
|
|
1432
1581
|
if (level < depth - 1) {
|
|
1433
|
-
placed.push([node.id, { x, y, w: nodeW, h: branchH }]), y += branchH + 2 * u, kids.forEach((kid, index) =>
|
|
1582
|
+
placed.push([node.id, { x, y, w: nodeW, h: branchH }]), y += branchH + 2 * u, kids.forEach((kid, index) => place2(kid, index === 0));
|
|
1434
1583
|
return;
|
|
1435
1584
|
}
|
|
1436
1585
|
isFirst || (y += 1.6 * u);
|
|
@@ -1438,7 +1587,7 @@ function layoutIssueTreeCompact(data, plot, labelFont, measure, u, headWeight) {
|
|
|
1438
1587
|
placed.push([node.id, { x, y: y + (groupH - rowH) / 2, w: nodeW, h: rowH }]), kids.forEach((kid, index) => placed.push([kid.id, { x: leafX, y: y + (groupH - stack) / 2 + index * (rowH + 1.2 * u), w: leafW, h: rowH }])), y += groupH;
|
|
1439
1588
|
};
|
|
1440
1589
|
kidsOf(root.id).forEach((branch, index) => {
|
|
1441
|
-
index > 0 && (y += 3.2 * u),
|
|
1590
|
+
index > 0 && (y += 3.2 * u), place2(branch, !0);
|
|
1442
1591
|
});
|
|
1443
1592
|
let top = plot.y + Math.max(0, (plot.h - y) / 2);
|
|
1444
1593
|
for (let [id, rect] of placed) put(id, { ...rect, y: rect.y + top });
|
|
@@ -1487,13 +1636,1225 @@ function layoutIssueTreeCompact(data, plot, labelFont, measure, u, headWeight) {
|
|
|
1487
1636
|
};
|
|
1488
1637
|
}
|
|
1489
1638
|
|
|
1639
|
+
// src/core/charts/diagram/architecture.ts
|
|
1640
|
+
var PITCH = 8, GAP_HALF = 16, NODE_CLEARANCE = 7, TEXT_CLEARANCE = 4, BEND_COST = 40, CROSSING_COST = 64, SIDE_COST = 48, LANE_RAMP = [0.9, 0.78, 0.6, 0.22, 0], ZONE_TINT = 0.93, PROTECTED_TINT = 0.89, PROTECTED_INSET = 3, REPEAT_STEP = 3, LOOP_REACH = 2.25, DISC_UNITS = 3.5, ZONE_COST = 160, INSET_BESIDE_WIDTH = 800, INSET_MAX_SHARE = 0.3, ROUTE_PASSES = 4;
|
|
1641
|
+
function architectureEligible(options) {
|
|
1642
|
+
return options.variant === "architecture";
|
|
1643
|
+
}
|
|
1644
|
+
var ARCHITECTURE_PLANS = /* @__PURE__ */ Symbol("architecturePlans");
|
|
1645
|
+
function layoutArchitecture(data, options, plot, fonts, measure, u, palette, theme, badges, plans) {
|
|
1646
|
+
let planFonts = { ...fonts, text: { ...secondaryFont(theme), weight: 400 } };
|
|
1647
|
+
if (!data.inset) return planArchitecture(data, options, plot, planFonts, measure, u, palette, theme, badges, plans);
|
|
1648
|
+
let beside = plot.w >= INSET_BESIDE_WIDTH, gap = 6 * u, width = beside ? insetWidth(data.inset, plot.w, fonts, measure, u) : plot.w, layout = planArchitecture(data, options, beside ? { ...plot, w: plot.w - width - gap } : plot, planFonts, measure, u, palette, theme, badges, plans), bottom = Math.max(...[...layout.preset.nodeRects.values(), ...layout.preset.groups.map((group) => group.bounds), ...layout.preset.lanes.map((lane) => lane.bounds), ...layout.extent].map((rect) => rect.y + rect.h)), box = { x: plot.x + plot.w - width, y: beside ? plot.y : bottom + gap, w: width }, panel = insetPanel(data.inset, box, !beside, fonts, measure, u), end = box.y + panel.height, stroke = { token: "axis" }, hair = strokeToken(theme, "hair"), rule = beside ? { x1: box.x - gap / 2, y1: plot.y, x2: box.x - gap / 2, y2: Math.max(bottom, end) } : { x1: plot.x, y1: bottom + gap / 2, x2: plot.x + plot.w, y2: bottom + gap / 2 };
|
|
1649
|
+
return layout.preset.decorationScene.push({ t: "line", id: diagramSceneId("inset", "rule"), ...rule, stroke, width: hair, owner: {}, part: "diagramLane" }), layout.channelLabels = [...layout.channelLabels ?? [], ...panel.labels], layout.extent.push(...panel.labels.map((label) => label.rect)), end > plot.y + plot.h + 1 && !layout.warnings.some((warning) => warning.code === "diagram-size-too-small") && layout.warnings.push({ code: "diagram-size-too-small", severity: "error", message: `architecture needs ${Math.ceil(end - plot.y - plot.h)} px more height` }), layout;
|
|
1650
|
+
}
|
|
1651
|
+
function insetWidth(inset, plotW, fonts, measure, u) {
|
|
1652
|
+
let need = Math.max(
|
|
1653
|
+
measure(inset.title, fonts.title).width,
|
|
1654
|
+
...(inset.rows ?? []).map((row) => measure(row.label, fonts.text).width + measure(row.value, fonts.name).width + 3 * u),
|
|
1655
|
+
...(inset.kpis ?? []).flatMap((kpi) => [measure(kpi.value, kpiFont(fonts)).width, measure(kpi.label, fonts.text).width])
|
|
1656
|
+
);
|
|
1657
|
+
return q(Math.max(36 * u, Math.min(Math.ceil(need), INSET_MAX_SHARE * plotW)));
|
|
1658
|
+
}
|
|
1659
|
+
var kpiFont = (fonts) => ({ ...fonts.title, size: Math.round(fonts.title.size * 1.75) });
|
|
1660
|
+
function insetPanel(inset, box, wide, fonts, measure, u) {
|
|
1661
|
+
let labels = [], seat = (id, text, font, x, y2, width, right = !1) => {
|
|
1662
|
+
let wrapped = wrapText(text, font, width, 4, measure), w = Math.ceil(Math.max(...wrapped.lines.map((line) => measure(line, font).width))) + 1, h = wrapped.lines.length * font.size * (font.lineHeight ?? 1.2);
|
|
1663
|
+
return labels.push({ id: `inset-label:${id}`, text, rect: qRect({ x: right ? x + width - w : x, y: y2, w, h }), owner: {}, font }), h;
|
|
1664
|
+
}, y = box.y + seat("title", inset.title, fonts.title, box.x, box.y, box.w) + 2 * u, kpis = inset.kpis ?? [], across = wide ? kpis.length : 1, cell = (box.w - (across - 1) * 3 * u) / Math.max(1, across);
|
|
1665
|
+
for (let at = 0; at < kpis.length; at += across) {
|
|
1666
|
+
let tallest = 0;
|
|
1667
|
+
kpis.slice(at, at + across).forEach((kpi, index) => {
|
|
1668
|
+
let x = box.x + index * (cell + 3 * u), top = seat(`kpi:${at + index}:value`, kpi.value, kpiFont(fonts), x, y, cell);
|
|
1669
|
+
tallest = Math.max(tallest, top + u + seat(`kpi:${at + index}:label`, kpi.label, fonts.text, x, y + top + u, cell));
|
|
1670
|
+
}), y += tallest + 2 * u;
|
|
1671
|
+
}
|
|
1672
|
+
return (inset.rows ?? []).forEach((row, index) => {
|
|
1673
|
+
let value = Math.min(Math.ceil(measure(row.value, fonts.name).width) + 1, Math.floor(box.w / 2)), name = seat(`row:${index}:label`, row.label, fonts.text, box.x, y, box.w - value - 2 * u), worth = seat(`row:${index}:value`, row.value, fonts.name, box.x + box.w - value, y, value, !0);
|
|
1674
|
+
y += Math.max(name, worth) + u;
|
|
1675
|
+
}), { labels, height: y - box.y - u };
|
|
1676
|
+
}
|
|
1677
|
+
function planArchitecture(data, options, plot, fonts, measure, u, palette, theme, badges, plans) {
|
|
1678
|
+
let key = [plot.x, plot.y, plot.w, u, fonts.name.size, fonts.text.size, fonts.title.size, fonts.badge.size].join(), planned = plans?.get(key), env = {
|
|
1679
|
+
data,
|
|
1680
|
+
options,
|
|
1681
|
+
plot: { ...plot, h: 1 / 0 },
|
|
1682
|
+
...fonts,
|
|
1683
|
+
measure,
|
|
1684
|
+
u,
|
|
1685
|
+
badges,
|
|
1686
|
+
order: planned?.order ?? rankNodes(data),
|
|
1687
|
+
neighbours: planned?.neighbours ?? neighboursOf(data)
|
|
1688
|
+
};
|
|
1689
|
+
if (planned) return emit(planned.arrangement, planned.geometry, planned.routed, { ...env, plot }, palette, theme);
|
|
1690
|
+
let finish = (plan) => (plans?.set(key, { ...plan, order: env.order, neighbours: env.neighbours }), emit(plan.arrangement, plan.geometry, plan.routed, { ...env, plot }, palette, theme)), last, routedLines = /* @__PURE__ */ new Map();
|
|
1691
|
+
for (let ownReturnLabels of env.data.edges.some((edge) => edge.flow === "return" && edge.label) ? [!0, !1] : [!1]) {
|
|
1692
|
+
let arrangementIndex = 0;
|
|
1693
|
+
for (let arrangement of arrangements(env)) {
|
|
1694
|
+
let index = arrangementIndex++;
|
|
1695
|
+
env.ownReturnLabels = ownReturnLabels;
|
|
1696
|
+
let gaps = /* @__PURE__ */ new Map(), wants = /* @__PURE__ */ new Map(), outward = /* @__PURE__ */ new Set(), clean;
|
|
1697
|
+
for (let pass = 0; pass < ROUTE_PASSES; pass++) {
|
|
1698
|
+
let requested = new Map([...gaps, ...[...wants].filter(([key2, need]) => need > (gaps.get(key2) ?? 0))]), wanted = place(arrangement, requested, env), geometry = wanted ?? place(arrangement, gaps, env);
|
|
1699
|
+
if (!geometry) break;
|
|
1700
|
+
let routeKey = JSON.stringify([index, [...wanted ? requested : gaps], [...outward]]), routed = routeEdges(geometry, env, outward, routedLines, routeKey);
|
|
1701
|
+
last = { geometry, routed, arrangement }, routed.problems.length === 0 && (clean = last);
|
|
1702
|
+
let grew = !1;
|
|
1703
|
+
for (let id of routed.unseated)
|
|
1704
|
+
!outward.has(id) && !heldInZone(env.data.edges.find((edge) => edge.id === id), geometry, env.data) && (outward.add(id), grew = !0);
|
|
1705
|
+
for (let [name, need] of routed.needs) {
|
|
1706
|
+
let key2 = name.replace("want:", ""), store = key2 === name ? gaps : wants;
|
|
1707
|
+
(store.get(key2) ?? 0) < need && (store.set(key2, need), grew = !0);
|
|
1708
|
+
}
|
|
1709
|
+
if (!grew) break;
|
|
1710
|
+
}
|
|
1711
|
+
if (clean) return finish(clean);
|
|
1712
|
+
}
|
|
1713
|
+
}
|
|
1714
|
+
if (!last) {
|
|
1715
|
+
let fallback = fallbackArrangement(env), geometry = place(fallback, /* @__PURE__ */ new Map(), { ...env, plot: { ...plot, w: Math.max(plot.w, 40 * u) } }, !0);
|
|
1716
|
+
last = { geometry, routed: routeEdges(geometry, env, /* @__PURE__ */ new Set()), arrangement: fallback };
|
|
1717
|
+
}
|
|
1718
|
+
return finish(last);
|
|
1719
|
+
}
|
|
1720
|
+
function rankNodes(data) {
|
|
1721
|
+
let rank = new Map(data.nodes.map((node) => [node.id, 0])), steps = data.edges.filter((edge) => !selfLoop(edge)).map((edge) => edge.flow === "return" ? [edge.target.nodeId, edge.source.nodeId] : [edge.source.nodeId, edge.target.nodeId]);
|
|
1722
|
+
for (let pass = 0; pass < data.nodes.length; pass++) {
|
|
1723
|
+
let changed = !1;
|
|
1724
|
+
for (let [from, to] of steps)
|
|
1725
|
+
rank.get(to) < rank.get(from) + 1 && rank.get(from) + 1 < data.nodes.length && (rank.set(to, rank.get(from) + 1), changed = !0);
|
|
1726
|
+
if (!changed) break;
|
|
1727
|
+
}
|
|
1728
|
+
return rank;
|
|
1729
|
+
}
|
|
1730
|
+
var selfLoop = (edge) => edge.source.nodeId === edge.target.nodeId;
|
|
1731
|
+
function neighboursOf(data) {
|
|
1732
|
+
let byId = new Map(data.nodes.map((node) => [node.id, node])), out = new Map(data.nodes.map((node) => [node.id, []]));
|
|
1733
|
+
for (let edge of data.edges)
|
|
1734
|
+
edge.flow === "return" || selfLoop(edge) || (out.get(edge.source.nodeId).push(byId.get(edge.target.nodeId)), out.get(edge.target.nodeId).push(byId.get(edge.source.nodeId)));
|
|
1735
|
+
return out;
|
|
1736
|
+
}
|
|
1737
|
+
function unitsOf(env) {
|
|
1738
|
+
let { data } = env, tree = (parent, chain) => data.groups.filter((group) => group.kind !== "policy" && group.parentId === parent).flatMap((group) => {
|
|
1739
|
+
let inner = [...chain, group], nodes = data.nodes.filter((node) => node.groupId === group.id), children = tree(group.id, inner);
|
|
1740
|
+
return nodes.length > 0 || children.length === 0 ? [{ chain: inner, nodes, c0: 0, c1: 0 }, ...children] : children;
|
|
1741
|
+
}), units = tree(void 0, []), free = data.nodes.filter((node) => !node.groupId).sort((a, b) => env.order.get(a.id) - env.order.get(b.id));
|
|
1742
|
+
for (let node of free) {
|
|
1743
|
+
let to = data.edges.filter((edge) => edge.flow !== "return" && !selfLoop(edge) && edge.source.nodeId === node.id).map((edge) => unitIndex(units, edge.target.nodeId)).filter((index) => index >= 0), from = data.edges.filter((edge) => edge.flow !== "return" && !selfLoop(edge) && edge.target.nodeId === node.id).map((edge) => unitIndex(units, edge.source.nodeId)).filter((index) => index >= 0), seat = to.length > 0 ? Math.min(...to) : from.length > 0 ? Math.max(...from) + 1 : units.length;
|
|
1744
|
+
for (; seat > 0 && seat < units.length && units[seat].chain[0] !== void 0 && units[seat - 1].chain[0] === units[seat].chain[0]; ) seat++;
|
|
1745
|
+
let beside = units[seat - 1]?.chain.length === 0 ? units[seat - 1] : units[seat]?.chain.length === 0 ? units[seat] : void 0;
|
|
1746
|
+
beside ? beside.nodes.push(node) : units.splice(seat, 0, { chain: [], nodes: [node], c0: 0, c1: 0 });
|
|
1747
|
+
}
|
|
1748
|
+
return units.filter((unit) => unit.nodes.length > 0 || unit.chain.length > 0);
|
|
1749
|
+
}
|
|
1750
|
+
function rootsOf(units) {
|
|
1751
|
+
let roots = [];
|
|
1752
|
+
for (let unit of units) {
|
|
1753
|
+
let last = roots.at(-1);
|
|
1754
|
+
last && unit.chain[0] !== void 0 && last[0].chain[0] === unit.chain[0] ? last.push(unit) : roots.push([unit]);
|
|
1755
|
+
}
|
|
1756
|
+
return roots;
|
|
1757
|
+
}
|
|
1758
|
+
function bandFrames(band) {
|
|
1759
|
+
let frames = /* @__PURE__ */ new Map();
|
|
1760
|
+
for (let unit of band.units)
|
|
1761
|
+
unit.chain.forEach((group, depth) => {
|
|
1762
|
+
let frame = frames.get(group.id);
|
|
1763
|
+
frame ? frame.c1 = unit.c1 : frames.set(group.id, { group, depth, c0: unit.c0, c1: unit.c1 });
|
|
1764
|
+
});
|
|
1765
|
+
return [...frames.values()];
|
|
1766
|
+
}
|
|
1767
|
+
var unitIndex = (units, id) => units.findIndex((unit) => unit.nodes.some((node) => node.id === id));
|
|
1768
|
+
function columnsFor(env) {
|
|
1769
|
+
let { plot, u } = env;
|
|
1770
|
+
return plot.w < 380 ? 1 : Math.max(1, Math.floor((plot.w + 6 * u) / (40 * u)));
|
|
1771
|
+
}
|
|
1772
|
+
function* arrangements(env) {
|
|
1773
|
+
if (env.options.flow === "lanes") {
|
|
1774
|
+
let wide = columnsFor(env);
|
|
1775
|
+
for (let cap2 = wide; cap2 >= 1; cap2--) {
|
|
1776
|
+
let arrangement = arrangeLanes(env, cap2);
|
|
1777
|
+
arrangement && (yield arrangement);
|
|
1778
|
+
}
|
|
1779
|
+
return;
|
|
1780
|
+
}
|
|
1781
|
+
let units = unitsOf(env), cap = columnsFor(env);
|
|
1782
|
+
for (let perBand = Math.min(5, rootsOf(units).length); perBand >= 1; perBand--)
|
|
1783
|
+
for (let inner = cap; inner >= 1; inner--) {
|
|
1784
|
+
let arrangement = arrangeColumns(env, units, perBand, inner, cap);
|
|
1785
|
+
arrangement && (yield arrangement);
|
|
1786
|
+
}
|
|
1787
|
+
}
|
|
1788
|
+
function fallbackArrangement(env) {
|
|
1789
|
+
return env.options.flow === "lanes" ? arrangeLanes(env, 1) : arrangeColumns(env, unitsOf(env), 1, 1, 1);
|
|
1790
|
+
}
|
|
1791
|
+
function refuseTrack(a, b) {
|
|
1792
|
+
throw new NormalizeError("diagram-track-conflict", "nodes", `nodes '${a}' and '${b}' claim one cell`, `give '${b}' another track`);
|
|
1793
|
+
}
|
|
1794
|
+
function arrangeColumns(env, units, perBand, inner, cap) {
|
|
1795
|
+
let tracks = [...new Set(env.data.nodes.flatMap((node) => node.track === void 0 ? [] : [node.track]))], cells = /* @__PURE__ */ new Map(), bands = [], width = (unit) => Math.min(inner, Math.max(1, new Set(localColumns(unit, env).values()).size)), slices = [], roots = rootsOf(units);
|
|
1796
|
+
for (let start = 0; start < roots.length; start += perBand) {
|
|
1797
|
+
let slice = roots.slice(start, start + perBand);
|
|
1798
|
+
if (slice.length > 1 || slice.flat().reduce((sum, unit) => sum + width(unit), 0) <= cap) {
|
|
1799
|
+
slices.push(slice.flat());
|
|
1800
|
+
continue;
|
|
1801
|
+
}
|
|
1802
|
+
let line = [], used = 0;
|
|
1803
|
+
for (let unit of slice.flat())
|
|
1804
|
+
line.length > 0 && used + width(unit) > cap && (slices.push(line), line = [], used = 0), line.push(unit), used += width(unit);
|
|
1805
|
+
slices.push(line);
|
|
1806
|
+
}
|
|
1807
|
+
for (let slice of slices) {
|
|
1808
|
+
let members = slice.map((unit) => ({ ...unit })), band = bands.length, taken = /* @__PURE__ */ new Map(), claim = (id, c, r) => {
|
|
1809
|
+
let other = taken.get(`${c}:${r}`);
|
|
1810
|
+
other && refuseTrack(other, id), taken.set(`${c}:${r}`, id);
|
|
1811
|
+
}, free = (c, r) => !taken.has(`${c}:${r}`), cols = 0, pending = [], full = [];
|
|
1812
|
+
for (let unit of members) {
|
|
1813
|
+
unit.c0 = cols;
|
|
1814
|
+
let local = localColumns(unit, env), ranks = [...new Set(local.values())].sort((a, b) => a - b), own = Math.max(1, ranks.length);
|
|
1815
|
+
if (own <= inner) {
|
|
1816
|
+
unit.c1 = cols + own - 1;
|
|
1817
|
+
for (let node of unit.nodes) {
|
|
1818
|
+
let col = cols + ranks.indexOf(local.get(node.id));
|
|
1819
|
+
if (node.span === "full") full.push({ node, col });
|
|
1820
|
+
else if (node.track !== void 0) {
|
|
1821
|
+
let row = tracks.indexOf(node.track);
|
|
1822
|
+
claim(node.id, col, row), cells.set(node.id, { node, band, c0: col, c1: col, r0: row, r1: row });
|
|
1823
|
+
} else pending.push({ node, col });
|
|
1824
|
+
}
|
|
1825
|
+
} else {
|
|
1826
|
+
let read = [...unit.nodes].sort((a, b) => env.order.get(a.id) - env.order.get(b.id));
|
|
1827
|
+
unit.c1 = cols + inner - 1, read.forEach((node, index) => {
|
|
1828
|
+
let col = cols + index % inner, row = Math.floor(index / inner);
|
|
1829
|
+
claim(node.id, col, row), cells.set(node.id, { node, band, c0: col, c1: col, r0: row, r1: row });
|
|
1830
|
+
});
|
|
1831
|
+
}
|
|
1832
|
+
cols = unit.c1 + 1;
|
|
1833
|
+
}
|
|
1834
|
+
if (cols > cap) return;
|
|
1835
|
+
settleUntracked(pending, cells, free, claim, band, env);
|
|
1836
|
+
let rows = Math.max(1, ...[...cells.values()].filter((cell) => cell.band === band).map((cell) => cell.r1 + 1));
|
|
1837
|
+
for (let { node, col } of full) {
|
|
1838
|
+
for (let r = 0; r < rows; r++) claim(node.id, col, r);
|
|
1839
|
+
cells.set(node.id, { node, band, c0: col, c1: col, r0: 0, r1: rows - 1 });
|
|
1840
|
+
}
|
|
1841
|
+
bands.push({ cols, rows, units: members });
|
|
1842
|
+
}
|
|
1843
|
+
return compressRows(cells, bands), { cells, bands };
|
|
1844
|
+
}
|
|
1845
|
+
function localColumns(unit, env) {
|
|
1846
|
+
let ids = new Map(unit.nodes.map((node) => [node.id, node])), col = new Map(unit.nodes.map((node) => [node.id, 0])), steps = env.data.edges.filter((edge) => ids.has(edge.source.nodeId) && ids.has(edge.target.nodeId) && !selfLoop(edge)).map((edge) => edge.flow === "return" ? [edge.target.nodeId, edge.source.nodeId] : [edge.source.nodeId, edge.target.nodeId]);
|
|
1847
|
+
for (let pass = 0; pass < unit.nodes.length; pass++) {
|
|
1848
|
+
let changed = !1;
|
|
1849
|
+
for (let [from, to] of steps) {
|
|
1850
|
+
let [a, b] = [ids.get(from).track, ids.get(to).track], need = col.get(from) + (a !== void 0 && b !== void 0 && a !== b ? 0 : 1);
|
|
1851
|
+
need > col.get(to) && need < unit.nodes.length && (col.set(to, need), changed = !0);
|
|
1852
|
+
}
|
|
1853
|
+
if (!changed) break;
|
|
1854
|
+
}
|
|
1855
|
+
return col;
|
|
1856
|
+
}
|
|
1857
|
+
function settleUntracked(pending, cells, free, claim, band, env) {
|
|
1858
|
+
let rest = [...pending], inBand = (id) => cells.get(id)?.band === band ? cells.get(id) : void 0, known = (node) => (env.neighbours.get(node.id) ?? []).filter((other) => inBand(other.id)), total = (node) => (env.neighbours.get(node.id) ?? []).filter((other) => rest.some((item) => item.node.id === other.id) || inBand(other.id)).length;
|
|
1859
|
+
for (; rest.length > 0; ) {
|
|
1860
|
+
let pick = rest.findIndex(({ node: node2 }) => total(node2) > 0 && known(node2).length === total(node2)), some = rest.findIndex(({ node: node2 }) => known(node2).length > 0), chosen = pick >= 0 ? pick : Math.max(0, some), { node, col } = rest.splice(chosen, 1)[0], near = known(node).map((other) => inBand(other.id)), lo = Math.min(...near.map((cell) => cell.r0)), hi = Math.max(...near.map((cell) => cell.r1));
|
|
1861
|
+
if (near.length > 1 && hi > lo && Array.from({ length: hi - lo + 1 }, (_, i) => lo + i).every((r) => free(col, r))) {
|
|
1862
|
+
for (let r = lo; r <= hi; r++) claim(node.id, col, r);
|
|
1863
|
+
cells.set(node.id, { node, band, c0: col, c1: col, r0: lo, r1: hi });
|
|
1864
|
+
continue;
|
|
1865
|
+
}
|
|
1866
|
+
let row = near.length > 0 ? lo : 0;
|
|
1867
|
+
for (; !free(col, row); ) row++;
|
|
1868
|
+
claim(node.id, col, row), cells.set(node.id, { node, band, c0: col, c1: col, r0: row, r1: row });
|
|
1869
|
+
}
|
|
1870
|
+
}
|
|
1871
|
+
function compressRows(cells, bands) {
|
|
1872
|
+
bands.forEach((band, index) => {
|
|
1873
|
+
let own = [...cells.values()].filter((cell) => cell.band === index), used = [...new Set(own.flatMap((cell) => [cell.r0, cell.r1]))].sort((a, b) => a - b), next = new Map(used.map((row, rank) => [row, rank]));
|
|
1874
|
+
for (let cell of own)
|
|
1875
|
+
cell.r0 = next.get(cell.r0), cell.r1 = next.get(cell.r1);
|
|
1876
|
+
band.rows = Math.max(1, used.length);
|
|
1877
|
+
});
|
|
1878
|
+
}
|
|
1879
|
+
function arrangeLanes(env, cap) {
|
|
1880
|
+
let { data } = env, tracks = [...new Set(data.nodes.flatMap((node) => node.track === void 0 ? [] : [node.track]))], members = data.lanes.map((lane) => data.nodes.filter((node) => node.laneId === lane.id)), seats = Math.max(tracks.length, ...members.map((nodes) => nodes.filter((node) => node.span !== "full").length), 1), placed = data.nodes.filter((node) => node.laneId !== void 0), cols = Math.min(seats, cap), reflow = seats > cap, cells = /* @__PURE__ */ new Map(), lanes = [], row = 0;
|
|
1881
|
+
data.lanes.forEach((lane, laneIndex) => {
|
|
1882
|
+
let nodes = members[laneIndex], r0 = row, wide = nodes.filter((node) => node.span === "full"), seated = nodes.filter((node) => node.span !== "full");
|
|
1883
|
+
seated.length > 0 && (reflow ? (seated.forEach((node, index) => cells.set(node.id, { node, band: 0, c0: index % cols, c1: index % cols, r0: row + Math.floor(index / cols), r1: row + Math.floor(index / cols) })), row += Math.ceil(seated.length / cols)) : (seatLane(seated, tracks, cols, row, cells, env), row++));
|
|
1884
|
+
for (let node of wide) cells.set(node.id, { node, band: 0, c0: 0, c1: cols - 1, r0: row, r1: row++ });
|
|
1885
|
+
row === r0 && row++, lanes.push({ lane, r0, r1: row - 1 });
|
|
1886
|
+
}), reflow || widenToNeighbours(cells, env);
|
|
1887
|
+
let units = [{ chain: [], nodes: placed, c0: 0, c1: cols - 1 }];
|
|
1888
|
+
return { cells, lanes, bands: [{ cols, rows: row, units }], labelAbove: env.plot.w < 520 };
|
|
1889
|
+
}
|
|
1890
|
+
function seatLane(nodes, tracks, cols, row, cells, env) {
|
|
1891
|
+
let taken = /* @__PURE__ */ new Map(), seat = (node, col) => {
|
|
1892
|
+
taken.set(col, node.id), cells.set(node.id, { node, band: 0, c0: col, c1: col, r0: row, r1: row });
|
|
1893
|
+
};
|
|
1894
|
+
for (let node of nodes) {
|
|
1895
|
+
if (node.track === void 0) continue;
|
|
1896
|
+
let col = tracks.indexOf(node.track);
|
|
1897
|
+
taken.has(col) && refuseTrack(taken.get(col), node.id), seat(node, col);
|
|
1898
|
+
}
|
|
1899
|
+
let open = nodes.filter((node) => node.track === void 0);
|
|
1900
|
+
open.forEach((node, index) => {
|
|
1901
|
+
let known = (env.neighbours.get(node.id) ?? []).flatMap((other) => cells.has(other.id) ? [(cells.get(other.id).c0 + cells.get(other.id).c1) / 2] : []), wanted = known.length > 0 ? known.reduce((sum, value) => sum + value, 0) / known.length : open.length === 1 && nodes.length === 1 ? 0 : (index + 0.5) * cols / open.length - 0.5, best = -1;
|
|
1902
|
+
for (let col = 0; col < cols; col++)
|
|
1903
|
+
!taken.has(col) && (best < 0 || Math.abs(col - wanted) < Math.abs(best - wanted)) && (best = col);
|
|
1904
|
+
seat(node, best);
|
|
1905
|
+
});
|
|
1906
|
+
}
|
|
1907
|
+
function widenToNeighbours(cells, env) {
|
|
1908
|
+
let cellsIn = [...cells.values()];
|
|
1909
|
+
for (let cell of cellsIn) {
|
|
1910
|
+
if (cell.node.track !== void 0 || cell.node.span === "full") continue;
|
|
1911
|
+
let near = (env.neighbours.get(cell.node.id) ?? []).map((other) => cells.get(other.id));
|
|
1912
|
+
if (near.length < 2) continue;
|
|
1913
|
+
let lo = Math.min(...near.map((other) => other.c0)), hi = Math.max(...near.map((other) => other.c1)), clear = (c) => !cellsIn.some((other) => other !== cell && other.r0 <= cell.r0 && other.r1 >= cell.r0 && other.c0 <= c && other.c1 >= c);
|
|
1914
|
+
for (; cell.c0 > lo && clear(cell.c0 - 1); ) cell.c0--;
|
|
1915
|
+
for (; cell.c1 < hi && clear(cell.c1 + 1); ) cell.c1++;
|
|
1916
|
+
}
|
|
1917
|
+
}
|
|
1918
|
+
var lockWidth = (node, u) => node.protected ? 3.5 * u : 0, stackOf = (node) => node.repeat ? (node.repeat - 1) * REPEAT_STEP : 0;
|
|
1919
|
+
function frontRect(node, rect) {
|
|
1920
|
+
let stack = stackOf(node);
|
|
1921
|
+
return stack === 0 ? rect : { ...rect, w: rect.w - stack, h: rect.h - stack };
|
|
1922
|
+
}
|
|
1923
|
+
var storeCap = (node, u) => node.shape.kind === "store" ? 2 * u : 0;
|
|
1924
|
+
function nodeText(node, width, env) {
|
|
1925
|
+
let cache = env.nodeText ??= /* @__PURE__ */ new Map(), key = `${node.id}:${width}`;
|
|
1926
|
+
if (cache.has(key)) return cache.get(key);
|
|
1927
|
+
let result = measureNodeText(node, width, env);
|
|
1928
|
+
return cache.set(key, result), result;
|
|
1929
|
+
}
|
|
1930
|
+
function measureNodeText(node, width, env) {
|
|
1931
|
+
let { name, text, measure, options, u } = env, inner = width - 4 * u - (node.icon ? 3.5 * u : 0) - lockWidth(node, u);
|
|
1932
|
+
if (inner < 1) return;
|
|
1933
|
+
let lineH = (font) => font.size * (font.lineHeight ?? 1.2), lead = fitText(node.label, name, inner, 3, measure, { target: options.target, typeRole: "label" });
|
|
1934
|
+
if (lead.title !== void 0) return;
|
|
1935
|
+
let second = node.secondaryLabel ? fitText(node.secondaryLabel, text, inner, 2, measure, { target: options.target, typeRole: "label" }) : void 0;
|
|
1936
|
+
if (second?.title === void 0)
|
|
1937
|
+
return { height: lead.lines.length * lineH(name) + (second ? 0.5 * u + second.lines.length * lineH(text) : 0) };
|
|
1938
|
+
}
|
|
1939
|
+
function place(arrangement, gaps, env, force = !1) {
|
|
1940
|
+
let { plot, u, title, measure } = env, lanesFlow = arrangement.lanes !== void 0, pad = 2.5 * u, titleH = title.size * (title.lineHeight ?? 1.2), laneZoneGap = Math.max(0, titleH / 2 + 2 - 2 * u), innerGap = 2 * GAP_HALF, unitGap = 2 * GAP_HALF, gap = (key, base) => Math.max(base, gaps.get(key) ?? 0), laneLabel = lanesFlow && !arrangement.labelAbove ? laneLabelWidth(env) : 0, geometry = { rects: /* @__PURE__ */ new Map(), textBoxes: /* @__PURE__ */ new Map(), icons: /* @__PURE__ */ new Map(), badges: /* @__PURE__ */ new Map(), zones: [], loops: [], locks: /* @__PURE__ */ new Map(), lanes: [], labelClaims: [], xs: [], ys: [], gaps: [], width: plot.w, labelLeft: plot.x + laneLabel }, outerL = gap("oL", 0), outerR = gap("oR", 0), frameInset = lanesFlow && env.data.groups.some((group) => group.kind !== "policy") ? 1.5 * u + 1 : 0, left = plot.x + laneLabel + outerL + frameInset, right = plot.x + plot.w - outerR - frameInset, axisX = [[left - Math.max(outerL, 2 * PITCH) / 2, "oL"], [right + Math.max(outerR, 2 * PITCH) / 2, "oR"]], axisY = [], strip = placePolicy(geometry, env);
|
|
1941
|
+
if (strip === void 0 && !force)
|
|
1942
|
+
return;
|
|
1943
|
+
let flowTop = plot.y + (strip ?? 0), y = flowTop, spans = /* @__PURE__ */ new Map();
|
|
1944
|
+
for (let [b, band] of arrangement.bands.entries()) {
|
|
1945
|
+
let key = (axis, index) => `${axis}:${b}:${index}`, frames = lanesFlow ? [] : bandFrames(band), opening = frames.filter((frame) => !spans.has(frame.group.id)), unitAfter = new Set(band.units.map((unit) => unit.c1)), fixed = 0;
|
|
1946
|
+
for (let c = 0; c + 1 < band.cols; c++) fixed += gap(key("v", c), unitAfter.has(c) ? unitGap : innerGap);
|
|
1947
|
+
lanesFlow || (fixed += frames.length * 2 * pad);
|
|
1948
|
+
let avail = right - left - fixed;
|
|
1949
|
+
if (avail / band.cols < 1 && !force) return;
|
|
1950
|
+
let fair = Math.max(1, avail / band.cols), columnW = band.units.length > 1 || band.cols > 1 ? Math.min(fair, 60 * u) : fair, spare = band.cols > 1 ? (avail - columnW * band.cols) / (band.cols - 1) : 0, colX = [], x = left;
|
|
1951
|
+
for (let c = 0; c < band.cols; c++) {
|
|
1952
|
+
if (x += frames.filter((frame) => frame.c0 === c).length * pad, colX[c] = q(x), x += columnW, x += frames.filter((frame) => frame.c1 === c).length * pad, c + 1 < band.cols) {
|
|
1953
|
+
let width = gap(key("v", c), unitAfter.has(c) ? unitGap : innerGap) + spare;
|
|
1954
|
+
geometry.gaps.push({ key: key("v", c), axis: "v", rect: { x, y: 0, w: width, h: 0 } }), axisX.push([x + width / 2, key("v", c)]), x += width;
|
|
1955
|
+
}
|
|
1956
|
+
axisX.push([colX[c] + columnW / 2]);
|
|
1957
|
+
}
|
|
1958
|
+
let own = [...arrangement.cells.values()].filter((cell) => cell.band === b), heights = /* @__PURE__ */ new Map(), textH = /* @__PURE__ */ new Map(), rowH = new Array(band.rows).fill(11 * u);
|
|
1959
|
+
for (let cell of own) {
|
|
1960
|
+
let width = columnW * (cell.c1 - cell.c0 + 1) + colX[cell.c1] - colX[cell.c0] - columnW * (cell.c1 - cell.c0), stack = stackOf(cell.node), text = nodeText(cell.node, width - stack, env);
|
|
1961
|
+
if (!text && !force)
|
|
1962
|
+
return;
|
|
1963
|
+
let badge = env.badges.get(cell.node.id), height = Math.max(11 * u, (text?.height ?? 0) + 3 * u + (badge ? badge.height + 0.5 * u : 0) + 2 * storeCap(cell.node, u)) + stack;
|
|
1964
|
+
textH.set(cell.node.id, text?.height ?? 0), heights.set(cell.node.id, height), cell.r0 === cell.r1 && (rowH[cell.r0] = Math.max(rowH[cell.r0], height));
|
|
1965
|
+
}
|
|
1966
|
+
let lines = /* @__PURE__ */ new Map(), rowsAt = [];
|
|
1967
|
+
for (let frame of opening) {
|
|
1968
|
+
let width = colX[frame.c1] + columnW - colX[frame.c0] + 2 * pad - 2 * u - (frame.group.protected ? 3.5 * u : 0), wrapped = wrapText(frame.group.title, title, width, 2, measure);
|
|
1969
|
+
if (wrapped.truncated && !force) return;
|
|
1970
|
+
lines.set(frame.group.id, wrapped.lines), rowsAt[frame.depth] = Math.max(rowsAt[frame.depth] ?? 0, wrapped.lines.length * titleH + 2 * u);
|
|
1971
|
+
}
|
|
1972
|
+
let topAt = (depth) => {
|
|
1973
|
+
let at = 0;
|
|
1974
|
+
for (let d = 0; d < depth; d++) at += (rowsAt[d] ?? 0) + u;
|
|
1975
|
+
return at;
|
|
1976
|
+
}, deepest = Math.max(-1, ...frames.map((frame) => frame.depth)), head = opening.length > 0 ? topAt(rowsAt.length - 1) + rowsAt.at(-1) + 1.5 * u : 0, laneOfRow = (r) => arrangement.lanes?.find((lane) => r >= lane.r0 && r <= lane.r1), rowY = [], cursor = y + head, top = y;
|
|
1977
|
+
for (let r = 0; r < band.rows; r++) {
|
|
1978
|
+
let lane = laneOfRow(r);
|
|
1979
|
+
if (lane && r === lane.r0) {
|
|
1980
|
+
let headerH = arrangement.labelAbove && lane.lane.label ? titleH + u : 0, box = lane.lane.label ? laneHeader(lane.lane.label, plot.x, cursor + u, laneLabel, env, arrangement.labelAbove) : void 0;
|
|
1981
|
+
box && geometry.labelClaims.push(box), geometry.lanes.push({
|
|
1982
|
+
id: lane.lane.id,
|
|
1983
|
+
bounds: { x: plot.x, y: cursor, w: plot.w, h: 0 },
|
|
1984
|
+
...box ? { headerBox: box } : {},
|
|
1985
|
+
memberNodeIds: env.data.nodes.filter((node) => node.laneId === lane.lane.id).map((node) => node.id),
|
|
1986
|
+
...r > 0 ? { rule: cursor } : {}
|
|
1987
|
+
});
|
|
1988
|
+
let framedLane = env.data.nodes.some((node) => node.laneId === lane.lane.id && node.groupId !== void 0);
|
|
1989
|
+
cursor += headerH + 2 * u + (framedLane ? titleH / 2 + u + laneZoneGap : 0);
|
|
1990
|
+
}
|
|
1991
|
+
rowY[r] = q(cursor), cursor += rowH[r], axisY.push([rowY[r] + rowH[r] / 2]);
|
|
1992
|
+
let loop = env.data.edges.filter((edge) => selfLoop(edge) && own.some((cell) => cell.r1 === r && cell.node.id === edge.source.nodeId));
|
|
1993
|
+
if (loop.length > 0 && (cursor += LOOP_REACH * u + PITCH + (loop.some((edge) => edge.label) ? env.text.size * (env.text.lineHeight ?? 1.2) + TEXT_CLEARANCE + 1 : 0)), lane && r === lane.r1) {
|
|
1994
|
+
let laneBox = geometry.lanes.at(-1);
|
|
1995
|
+
cursor += 2 * u, laneBox.bounds.h = cursor - laneBox.bounds.y;
|
|
1996
|
+
}
|
|
1997
|
+
if (r + 1 < band.rows) {
|
|
1998
|
+
let width = gap(key("h", r), lane && r === lane.r1 ? 2 * GAP_HALF - 4 * u : innerGap);
|
|
1999
|
+
geometry.gaps.push({ key: key("h", r), axis: "h", rect: { x: plot.x, y: cursor, w: plot.w, h: width } }), axisY.push([cursor + width / 2, key("h", r)]), cursor += width;
|
|
2000
|
+
}
|
|
2001
|
+
}
|
|
2002
|
+
let bandBottom = cursor + (deepest + 1) * pad;
|
|
2003
|
+
for (let item of geometry.gaps)
|
|
2004
|
+
item.axis === "v" && item.rect.h === 0 && (item.rect.y = top, item.rect.h = bandBottom - top);
|
|
2005
|
+
for (let cell of own) {
|
|
2006
|
+
let x0 = colX[cell.c0], x1 = colX[cell.c1] + columnW, y0 = rowY[cell.r0], y1 = rowY[cell.r1] + rowH[cell.r1], id = cell.node.id;
|
|
2007
|
+
geometry.rects.set(id, qRect({ x: x0, y: y0, w: x1 - x0, h: y1 - y0 }));
|
|
2008
|
+
let rect = frontRect(cell.node, geometry.rects.get(id)), badge = env.badges.get(id), cap = storeCap(cell.node, u), reserve = (badge ? badge.height + 0.5 * u : 0) + 2 * cap;
|
|
2009
|
+
badge && geometry.badges.set(id, qRect({ x: rect.x + rect.w - badge.width - u - lockWidth(cell.node, u), y: rect.y + u, w: badge.width, h: badge.height }));
|
|
2010
|
+
let icon = cell.node.icon ? 3.5 * u : 0, box = textH.get(id), bodyTop = rect.y + reserve + (rect.h - reserve - box) / 2;
|
|
2011
|
+
geometry.textBoxes.set(id, qRect({ x: rect.x + 2 * u + icon, y: bodyTop - 0.5, w: rect.w - 4 * u - icon - lockWidth(cell.node, u), h: box + 1 })), icon && geometry.icons.set(id, qRect({ x: rect.x + 2 * u, y: bodyTop + (env.name.size * 1.2 - 2.5 * u) / 2, w: 2.5 * u, h: 2.5 * u }));
|
|
2012
|
+
}
|
|
2013
|
+
for (let frame of frames) {
|
|
2014
|
+
let within = (edge) => frames.filter((other) => other[edge] === frame[edge] && other.depth > frame.depth).length + 1, x0 = colX[frame.c0] - within("c0") * pad, x1 = colX[frame.c1] + columnW + within("c1") * pad, y1 = bandBottom - frame.depth * pad;
|
|
2015
|
+
frame.depth > 0 && axisX.push([x0 - pad / 2], [x1 + pad / 2]);
|
|
2016
|
+
let span = spans.get(frame.group.id);
|
|
2017
|
+
span ? (span.x0 = Math.min(span.x0, x0), span.x1 = Math.max(span.x1, x1), span.y1 = y1) : spans.set(frame.group.id, { frame, x0, x1, y0: top + topAt(frame.depth), y1, lines: lines.get(frame.group.id), opened: b });
|
|
2018
|
+
}
|
|
2019
|
+
if (y = bandBottom, b + 1 < arrangement.bands.length) {
|
|
2020
|
+
let width = gap(`b:${b}`, 2 * GAP_HALF);
|
|
2021
|
+
geometry.gaps.push({ key: `b:${b}`, axis: "h", rect: { x: plot.x, y, w: plot.w, h: width } }), axisY.push([y + width / 2, `b:${b}`]), y += width;
|
|
2022
|
+
}
|
|
2023
|
+
}
|
|
2024
|
+
for (let { frame, x0, x1, y0, y1, lines } of spans.values()) {
|
|
2025
|
+
let width = Math.max(...lines.map((line) => measure(line, title).width)), titleBox = qRect({ x: x0 + 2 * u - 4, y: y0 + 2 * u, w: width + 8, h: lines.length * titleH });
|
|
2026
|
+
geometry.labelClaims.push(titleBox), frame.group.protected && addZoneLock(geometry, frame.group.id, titleBox, u), geometry.zones.push({
|
|
2027
|
+
id: frame.group.id,
|
|
2028
|
+
bounds: qRect({ x: x0, y: y0, w: x1 - x0, h: y1 - y0 }),
|
|
2029
|
+
titleBox,
|
|
2030
|
+
memberNodeIds: zoneMembers(frame.group.id, env),
|
|
2031
|
+
dashed: !1,
|
|
2032
|
+
depth: frame.depth
|
|
2033
|
+
});
|
|
2034
|
+
}
|
|
2035
|
+
geometry.gaps.push({ key: "oL", axis: "v", rect: { x: left - Math.max(outerL, 2 * PITCH), y: flowTop, w: Math.max(outerL, 2 * PITCH), h: y - flowTop } }), geometry.gaps.push({ key: "oR", axis: "v", rect: { x: right, y: flowTop, w: Math.max(outerR, 2 * PITCH), h: y - flowTop } });
|
|
2036
|
+
let bottom = gap("oB", 0);
|
|
2037
|
+
return axisY.push([y + Math.max(bottom, 2 * PITCH) / 2, "oB"]), geometry.gaps.push({ key: "oB", axis: "h", rect: { x: plot.x, y, w: plot.w, h: Math.max(bottom, 2 * PITCH) } }), lanesFlow && laneZones(geometry, env, laneZoneGap), geometry.xs = corridorLines(axisX), geometry.ys = corridorLines(axisY), geometry;
|
|
2038
|
+
}
|
|
2039
|
+
var zoneMembers = (id, env) => env.data.nodes.filter((node) => node.groupId !== void 0 && groupWithin(env.data.groups, node.groupId, id)).map((node) => node.id);
|
|
2040
|
+
function addZoneLock(geometry, id, titleBox, u) {
|
|
2041
|
+
let size = 2.5 * u, lock = qRect({ x: titleBox.x + titleBox.w, y: titleBox.y + (Math.min(titleBox.h, 3 * u) - size) / 2, w: size, h: size });
|
|
2042
|
+
geometry.locks.set(id, lock), geometry.labelClaims.push(lock);
|
|
2043
|
+
}
|
|
2044
|
+
function placePolicy(geometry, env) {
|
|
2045
|
+
let { data, plot, name, title, measure, u } = env, group = data.groups.find((item) => item.kind === "policy");
|
|
2046
|
+
if (!group) return 0;
|
|
2047
|
+
let items = data.nodes.filter((node) => node.groupId === group.id), titleH = title.size * (title.lineHeight ?? 1.2), pad = 2 * u, inner = plot.w - 2 * pad, wide = (node) => measure(node.label, name).width + (node.icon ? 3.5 * u : 0), longest = Math.max(1, ...items.map(wide)), columnsWide = Math.max(1, Math.min(items.length, Math.floor((inner + pad) / (longest + pad)))), columnW = (inner - (columnsWide - 1) * pad) / columnsWide, y0 = plot.y + titleH / 2, y = y0 + titleH / 2 + u;
|
|
2048
|
+
for (let start = 0; start < items.length; start += columnsWide) {
|
|
2049
|
+
let row = items.slice(start, start + columnsWide), texts = row.map((node) => nodeText(node, columnW + 4 * u, env));
|
|
2050
|
+
if (texts.some((text) => !text)) return;
|
|
2051
|
+
let height = Math.ceil(Math.max(...texts.map((text) => text.height)) * 2) / 2;
|
|
2052
|
+
row.forEach((node, index) => {
|
|
2053
|
+
let rect = qRect({ x: plot.x + pad + index * (columnW + pad), y, w: columnW, h: height }), icon = node.icon ? 3.5 * u : 0;
|
|
2054
|
+
geometry.rects.set(node.id, rect), geometry.textBoxes.set(node.id, { ...rect, x: q(rect.x + icon), w: q(rect.w - icon) }), icon && geometry.icons.set(node.id, qRect({ x: rect.x, y: rect.y + (name.size * 1.2 - 2.5 * u) / 2, w: 2.5 * u, h: 2.5 * u }));
|
|
2055
|
+
}), y += height + u;
|
|
2056
|
+
}
|
|
2057
|
+
let y1 = y - u + 1.5 * u, titleBox = qRect({ x: plot.x + 2 * u - 4, y: y0 - titleH / 2, w: measure(group.title, title).width + 8, h: titleH });
|
|
2058
|
+
return geometry.labelClaims.push(titleBox), geometry.zones.push({ id: group.id, bounds: qRect({ x: plot.x, y: y0, w: plot.w, h: y1 - y0 }), titleBox, memberNodeIds: items.map((node) => node.id), dashed: !0, depth: 0, policy: !0 }), y1 + 3 * u - plot.y;
|
|
2059
|
+
}
|
|
2060
|
+
function discSize(env) {
|
|
2061
|
+
let widest = env.measure(String(env.data.callouts.length), env.badge).width;
|
|
2062
|
+
return q(Math.max(DISC_UNITS * env.u, Math.ceil(widest) + BOX_LABEL_INSET));
|
|
2063
|
+
}
|
|
2064
|
+
function laneLabelWidth(env) {
|
|
2065
|
+
let { data, title, measure, plot, u } = env, widest = Math.max(0, ...data.lanes.map((lane) => {
|
|
2066
|
+
let words = (lane.label ?? "").split(/\s+/).map((word) => measure(word, title).width);
|
|
2067
|
+
return Math.min(measure(lane.label ?? "", title).width, Math.max(...words, plot.w * 0.13));
|
|
2068
|
+
}));
|
|
2069
|
+
return Math.ceil(Math.min(widest, plot.w * 0.25)) + 3 * u;
|
|
2070
|
+
}
|
|
2071
|
+
function laneHeader(label, x, y, width, env, above) {
|
|
2072
|
+
let { title, measure, plot, u } = env, room = above ? plot.w : Math.max(1, width - 3 * u), lines = wrapText(label, title, room, 2, measure).lines, w = Math.max(...lines.map((line) => measure(line, title).width));
|
|
2073
|
+
return qRect({ x: x - 4, y, w: w + 8, h: lines.length * title.size * (title.lineHeight ?? 1.2) });
|
|
2074
|
+
}
|
|
2075
|
+
function laneZones(geometry, env, clearance) {
|
|
2076
|
+
let { data, title, measure, u } = env;
|
|
2077
|
+
for (let group of data.groups) {
|
|
2078
|
+
let members = data.nodes.filter((node) => node.groupId === group.id);
|
|
2079
|
+
if (members.length === 0 || group.kind === "policy") continue;
|
|
2080
|
+
let rects = members.map((node) => geometry.rects.get(node.id)), x0 = Math.min(...rects.map((rect) => rect.x)) - 1.5 * u, y0 = Math.min(...rects.map((rect) => rect.y)) - 2 * u - clearance, x1 = Math.max(...rects.map((rect) => rect.x + rect.w)) + 1.5 * u, y1 = Math.max(...rects.map((rect) => rect.y + rect.h)) + 1.5 * u, bounds = qRect({ x: x0, y: y0, w: x1 - x0, h: y1 - y0 }), height = title.size * (title.lineHeight ?? 1.2), width = measure(group.title, title).width, titleBox = qRect({ x: x0 + 2 * u - 4, y: y0 - height / 2, w: width + 8, h: height });
|
|
2081
|
+
geometry.labelClaims.push(titleBox), group.protected && addZoneLock(geometry, group.id, titleBox, u), geometry.zones.push({ id: group.id, bounds, titleBox, memberNodeIds: members.map((node) => node.id), dashed: !0, depth: 0 });
|
|
2082
|
+
}
|
|
2083
|
+
}
|
|
2084
|
+
function corridorLines(raw) {
|
|
2085
|
+
let sorted = raw.map(([pos, key]) => ({ pos: snap(pos), keys: key ? [key] : [] })).sort((a, b) => a.pos - b.pos || a.keys.length - b.keys.length), lines = [];
|
|
2086
|
+
for (let line of sorted) {
|
|
2087
|
+
let last = lines.at(-1);
|
|
2088
|
+
if (last && line.pos === last.pos) last.keys.push(...line.keys);
|
|
2089
|
+
else {
|
|
2090
|
+
if (last && line.pos - last.pos < PITCH && line.keys.length === 0) continue;
|
|
2091
|
+
last && line.pos - last.pos < PITCH && last.keys.length === 0 ? lines[lines.length - 1] = line : lines.push(line);
|
|
2092
|
+
}
|
|
2093
|
+
}
|
|
2094
|
+
return lines;
|
|
2095
|
+
}
|
|
2096
|
+
var styleKeys = /* @__PURE__ */ new WeakMap();
|
|
2097
|
+
function styleOf(edge) {
|
|
2098
|
+
let key = styleKeys.get(edge);
|
|
2099
|
+
return key === void 0 && styleKeys.set(edge, key = [edge.dash ?? "solid", edge.weight ?? "normal", edge.role ?? "", edge.paletteKey ?? "", edge.flow ?? "forward", edge.arrowStart ? 1 : 0].join("|")), key;
|
|
2100
|
+
}
|
|
2101
|
+
function compatible(a, b) {
|
|
2102
|
+
return styleOf(a) !== styleOf(b) ? !1 : a.source.nodeId === b.source.nodeId ? !0 : a.target.nodeId === b.target.nodeId && (a.dash ?? "solid") === "solid";
|
|
2103
|
+
}
|
|
2104
|
+
function sideLines(lines, from, to) {
|
|
2105
|
+
let out = [];
|
|
2106
|
+
return lines.forEach((line, index) => {
|
|
2107
|
+
line.pos >= from + 4 && line.pos <= to - 4 && out.push(index);
|
|
2108
|
+
}), out;
|
|
2109
|
+
}
|
|
2110
|
+
function routeEdges(geometry, env, outward, cache, key) {
|
|
2111
|
+
let lines = key === void 0 ? void 0 : cache.get(key);
|
|
2112
|
+
lines || (lines = routeLines(geometry, env, outward), key !== void 0 && cache.set(key, lines)), geometry.loops = lines.loops;
|
|
2113
|
+
let { order, polylines, segmentBoxes, routes, dots } = lines, needs = new Map(lines.needs), problems = [...lines.problems], unseated = [], labels = placeLabels(order, polylines, segmentBoxes, geometry, env, needs, unseated, outward, lines);
|
|
2114
|
+
problems.push(...unseated);
|
|
2115
|
+
let channels = placeChannels(order, polylines, segmentBoxes, geometry, labels, env, needs, problems);
|
|
2116
|
+
return { routes, dots, labels, channels, problems, needs, unseated };
|
|
2117
|
+
}
|
|
2118
|
+
function routeLines(geometry, env, outward) {
|
|
2119
|
+
let { data } = env, { xs, ys, rects } = geometry, W = xs.length, H = ys.length, loops = new Map(data.edges.filter(selfLoop).map((edge) => [edge.id, selfLoopRoute(rects.get(edge.source.nodeId), env)]));
|
|
2120
|
+
geometry.loops = [...loops.values()].map(([a, b, c]) => ({ x: a.x, y: a.y, w: c.x - a.x, h: b.y - a.y }));
|
|
2121
|
+
let stubClaims = [...geometry.labelClaims, ...geometry.loops].map((claim) => grown(claim, TEXT_CLEARANCE)), blocked = obstacleGrid(geometry, W, H), zones = geometry.zones.filter((zone) => !zone.policy), frameUse = frameCrossings(geometry, zones, W, H), walledH = new Uint8Array(W * H), walledV = new Uint8Array(W * H), order = [...data.edges].sort((a, b) => +(a.flow === "return") - +(b.flow === "return") || env.order.get(a.source.nodeId) - env.order.get(b.source.nodeId) || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0)), useH = /* @__PURE__ */ new Map(), useV = /* @__PURE__ */ new Map(), states = 4 * W * H, cost = new Float64Array(states), prev = new Int32Array(states), goal = new Float64Array(states), runs = [], problems = [], sides = [], down = env.options.flow === "lanes";
|
|
2122
|
+
order.forEach((edge, edgeIndex) => {
|
|
2123
|
+
if (loops.has(edge.id)) {
|
|
2124
|
+
runs.push([]), sides.push({ source: "bottom", target: "bottom" });
|
|
2125
|
+
return;
|
|
2126
|
+
}
|
|
2127
|
+
let sourceRect = endRect(edge, "source", geometry, data), targetRect = endRect(edge, "target", geometry, data);
|
|
2128
|
+
walledH.fill(0), walledV.fill(0), zones.forEach((zone, index) => {
|
|
2129
|
+
if (!mustCross(edge, zone, data)) {
|
|
2130
|
+
for (let seg of frameUse[index].h) walledH[seg] = 1;
|
|
2131
|
+
for (let seg of frameUse[index].v) walledV[seg] = 1;
|
|
2132
|
+
}
|
|
2133
|
+
}), cost.fill(1 / 0), prev.fill(-1), goal.fill(1 / 0);
|
|
2134
|
+
let heap = new StateHeap(cost), startSide = /* @__PURE__ */ new Map(), endSide = /* @__PURE__ */ new Map(), across = sourceRect.x < targetRect.x + targetRect.w && targetRect.x < sourceRect.x + sourceRect.w, level = sourceRect.y < targetRect.y + targetRect.h && targetRect.y < sourceRect.y + sourceRect.h, towards = (down ? level : !across) ? targetRect.x >= sourceRect.x ? "right" : "left" : targetRect.y >= sourceRect.y ? "bottom" : "top", open = (side, rect, source) => {
|
|
2135
|
+
let penalty = edge.flow === "return" || side === (source ? towards : { top: "bottom", bottom: "top", left: "right", right: "left" }[towards]) ? 0 : SIDE_COST, dir = source ? { right: 0, bottom: 1, left: 2, top: 3 }[side] : { left: 0, top: 1, right: 2, bottom: 3 }[side], horizontal = side === "left" || side === "right", crossLines = horizontal ? sideLines(ys, rect.y, rect.y + rect.h) : sideLines(xs, rect.x, rect.x + rect.w);
|
|
2136
|
+
for (let cross of crossLines) {
|
|
2137
|
+
let lines = horizontal ? xs : ys, edgePos = side === "left" ? rect.x : side === "right" ? rect.x + rect.w : side === "top" ? rect.y : rect.y + rect.h, index = side === "right" || side === "bottom" ? lines.findIndex((line) => line.pos > edgePos + NODE_CLEARANCE) : findLast(lines, (line) => line.pos < edgePos - NODE_CLEARANCE);
|
|
2138
|
+
if (index < 0) continue;
|
|
2139
|
+
let i = horizontal ? index : cross, j = horizontal ? cross : index;
|
|
2140
|
+
if (blocked.vertex[i + j * W]) continue;
|
|
2141
|
+
let crossPos = (horizontal ? ys : xs)[cross].pos, [stubA, stubB] = horizontal ? [{ x: edgePos, y: crossPos }, { x: lines[index].pos, y: crossPos }] : [{ x: crossPos, y: edgePos }, { x: crossPos, y: lines[index].pos }];
|
|
2142
|
+
if (stubClaims.some((claim) => segmentHits(stubA, stubB, claim))) continue;
|
|
2143
|
+
let state = (i + j * W) * 4 + dir, stub = Math.abs(lines[index].pos - edgePos) + penalty;
|
|
2144
|
+
source ? stub < cost[state] && (cost[state] = stub, startSide.set(state, side), heap.push(state)) : stub < goal[state] && (goal[state] = stub, endSide.set(state, side));
|
|
2145
|
+
}
|
|
2146
|
+
};
|
|
2147
|
+
for (let side of ["right", "bottom", "left", "top"])
|
|
2148
|
+
open(side, sourceRect, !0), open(side, targetRect, !1);
|
|
2149
|
+
let self = edgeIndex, friendlyUsers = order.slice(0, edgeIndex).map((other) => compatible(other, edge)), incompatible = (users) => {
|
|
2150
|
+
let count = 0;
|
|
2151
|
+
if (users) for (let user of users) friendlyUsers[user] || count++;
|
|
2152
|
+
return count;
|
|
2153
|
+
}, best = 1 / 0, bestState = -1, bestEnd = -1;
|
|
2154
|
+
for (; heap.size > 0; ) {
|
|
2155
|
+
let state = heap.pop(), here = cost[state];
|
|
2156
|
+
if (here >= best) break;
|
|
2157
|
+
let dir = state & 3, vertex = state >> 2;
|
|
2158
|
+
for (let turn = 0; turn < 3; turn++) {
|
|
2159
|
+
let arrive = turn === 0 ? dir : dir + (turn === 1 ? 1 : 3) & 3, total = here + goal[vertex * 4 + arrive] + (arrive === dir ? 0 : BEND_COST);
|
|
2160
|
+
total < best && (best = total, bestState = state, bestEnd = vertex * 4 + arrive);
|
|
2161
|
+
}
|
|
2162
|
+
let i = vertex % W, j = (vertex - i) / W;
|
|
2163
|
+
for (let turn = 0; turn < 3; turn++) {
|
|
2164
|
+
let next = turn === 0 ? dir : dir + (turn === 1 ? 1 : 3) & 3, horizontal = next === 0 || next === 2, ni = next === 0 ? i + 1 : next === 2 ? i - 1 : i, nj = next === 1 ? j + 1 : next === 3 ? j - 1 : j;
|
|
2165
|
+
if (ni < 0 || nj < 0 || ni >= W || nj >= H) continue;
|
|
2166
|
+
let seg = horizontal ? Math.min(i, ni) + j * W : i + Math.min(j, nj) * W;
|
|
2167
|
+
if ((horizontal ? blocked.h : blocked.v)[seg]) continue;
|
|
2168
|
+
let length = Math.abs(horizontal ? xs[ni].pos - xs[i].pos : ys[nj].pos - ys[j].pos), users = (horizontal ? useH : useV).get(seg), step = length, against = incompatible(users);
|
|
2169
|
+
if (against > 0 ? step += 24 * against : users?.length && (step *= 0.15), (edge.flow === "return" || outward.has(edge.id)) && !(horizontal ? ys[j] : xs[i]).keys.some((key) => key.startsWith("o")) && (step *= outward.has(edge.id) ? 40 : 2.5), (horizontal ? walledH : walledV)[seg] && (step += ZONE_COST), next !== dir) step += BEND_COST;
|
|
2170
|
+
else {
|
|
2171
|
+
let crossUse = horizontal ? useV : useH;
|
|
2172
|
+
(incompatible(crossUse.get(i + j * W)) > 0 || incompatible(crossUse.get(horizontal ? i + (j - 1) * W : i - 1 + j * W)) > 0) && (step += CROSSING_COST);
|
|
2173
|
+
}
|
|
2174
|
+
let target = (ni + nj * W) * 4 + next;
|
|
2175
|
+
here + step < cost[target] && (cost[target] = here + step, prev[target] = state, heap.push(target));
|
|
2176
|
+
}
|
|
2177
|
+
}
|
|
2178
|
+
if (bestState < 0) {
|
|
2179
|
+
problems.push(edge.id), runs.push([]), sides.push({ source: "right", target: "left" });
|
|
2180
|
+
return;
|
|
2181
|
+
}
|
|
2182
|
+
let trail = [];
|
|
2183
|
+
for (let state = bestState; state >= 0; state = prev[state]) trail.unshift(state);
|
|
2184
|
+
bestEnd !== bestState && trail.push(bestEnd);
|
|
2185
|
+
for (let index = 1; index < trail.length; index++) {
|
|
2186
|
+
let a = trail[index - 1] >> 2, b = trail[index] >> 2;
|
|
2187
|
+
if (a === b) continue;
|
|
2188
|
+
let horizontal = (trail[index] & 3) % 2 === 0, ai = a % W, bi = b % W, aj = (a - ai) / W, bj = (b - bi) / W, seg = horizontal ? Math.min(ai, bi) + aj * W : ai + Math.min(aj, bj) * W, map = horizontal ? useH : useV, users = map.get(seg);
|
|
2189
|
+
users ? users.push(self) : map.set(seg, [self]);
|
|
2190
|
+
}
|
|
2191
|
+
let first = startSide.get(trail[0]), lastSide = endSide.get(bestEnd);
|
|
2192
|
+
sides.push({ source: first, target: lastSide }), runs.push(runsOf(trail, W, geometry, sourceRect, targetRect, first, lastSide, edgeIndex));
|
|
2193
|
+
});
|
|
2194
|
+
let all = runs.flat(), counts = assignTracks(all, order), offsets = (run) => trackOffset(run, counts), polylines = runs.map((path) => polyline(path, geometry, offsets));
|
|
2195
|
+
polylines = settleCrossings(all, runs, counts, order, geometry, polylines), order.forEach((edge, index) => {
|
|
2196
|
+
let loop = loops.get(edge.id);
|
|
2197
|
+
loop && (polylines[index] = loop);
|
|
2198
|
+
});
|
|
2199
|
+
let routes = /* @__PURE__ */ new Map();
|
|
2200
|
+
order.forEach((edge, index) => {
|
|
2201
|
+
polylines[index].length !== 0 && routes.set(edge.id, { points: polylines[index], sourceSide: sides[index].source, targetSide: sides[index].target });
|
|
2202
|
+
});
|
|
2203
|
+
let needs = /* @__PURE__ */ new Map(), need = (keys, value) => keys.forEach((key) => needs.set(key, Math.max(needs.get(key) ?? 0, value)));
|
|
2204
|
+
for (let [key, tracks] of counts) {
|
|
2205
|
+
let [axis, index] = key.split(":"), line = (axis === "h" ? ys : xs)[Number(index)];
|
|
2206
|
+
line.keys.some((name) => name.startsWith("o")) ? need(line.keys, tracks * PITCH + 2 * PITCH) : tracks > 1 && need(line.keys, (tracks - 1) * PITCH + 2 * GAP_HALF);
|
|
2207
|
+
}
|
|
2208
|
+
problems.push(...lineProblems(order, polylines, rects, geometry, data, zones));
|
|
2209
|
+
let segmentBoxes = polylines.map((points) => {
|
|
2210
|
+
let boxes = [];
|
|
2211
|
+
return forSegments(points, (a, b) => boxes.push({ x: Math.min(a.x, b.x), y: Math.min(a.y, b.y), w: Math.abs(a.x - b.x), h: Math.abs(a.y - b.y) })), boxes;
|
|
2212
|
+
}), rules = geometry.lanes.flatMap((lane) => lane.rule === void 0 ? [] : [{ x: env.plot.x, y: lane.rule, w: env.plot.w, h: 1 }]), frames = geometry.zones.flatMap(({ bounds: { x, y, w, h } }) => [{ x, y, w, h: 1 }, { x, y: y + h, w, h: 1 }, { x, y, w: 1, h }, { x: x + w, y, w: 1, h }]), labelBlockers = labelClaims(segmentBoxes, [...geometry.rects.values(), ...geometry.labelClaims, ...rules, ...frames]);
|
|
2213
|
+
return { order, polylines, segmentBoxes, loops: geometry.loops, seats: /* @__PURE__ */ new Map(), labelBlockers, routes, dots: junctions(order, polylines), needs, problems };
|
|
2214
|
+
}
|
|
2215
|
+
function endRect(edge, end, geometry, data) {
|
|
2216
|
+
let group = data.groupEnds.get(edge.id)?.[end];
|
|
2217
|
+
return group === void 0 ? geometry.rects.get(edge[end].nodeId) : geometry.zones.find((zone) => zone.id === group).bounds;
|
|
2218
|
+
}
|
|
2219
|
+
function endInside(edge, end, zone, data) {
|
|
2220
|
+
let group = data.groupEnds.get(edge.id)?.[end];
|
|
2221
|
+
return group === void 0 ? zone.memberNodeIds.includes(edge[end].nodeId) : group !== zone.id && groupWithin(data.groups, group, zone.id);
|
|
2222
|
+
}
|
|
2223
|
+
var heldInZone = (edge, geometry, data) => geometry.zones.some((zone) => !zone.policy && endInside(edge, "source", zone, data) && endInside(edge, "target", zone, data)), mustCross = (edge, zone, data) => endInside(edge, "source", zone, data) !== endInside(edge, "target", zone, data);
|
|
2224
|
+
function frameCrossings(geometry, zones, W, H) {
|
|
2225
|
+
let { xs, ys } = geometry, stepOver = (lines, frame) => lines.findIndex((line, index) => index + 1 < lines.length && line.pos < frame && frame < lines[index + 1].pos);
|
|
2226
|
+
return zones.map(({ bounds: { x, y, w, h: tall } }) => {
|
|
2227
|
+
let h = [], v = [];
|
|
2228
|
+
for (let frame of [x, x + w]) {
|
|
2229
|
+
let i = stepOver(xs, frame);
|
|
2230
|
+
if (i >= 0) for (let j = 0; j < H; j++) ys[j].pos > y && ys[j].pos < y + tall && h.push(i + j * W);
|
|
2231
|
+
}
|
|
2232
|
+
for (let frame of [y, y + tall]) {
|
|
2233
|
+
let j = stepOver(ys, frame);
|
|
2234
|
+
if (j >= 0) for (let i = 0; i < W; i++) xs[i].pos > x && xs[i].pos < x + w && v.push(i + j * W);
|
|
2235
|
+
}
|
|
2236
|
+
return { h, v };
|
|
2237
|
+
});
|
|
2238
|
+
}
|
|
2239
|
+
function frameHits(points, { x, y, w, h }) {
|
|
2240
|
+
let hits = [];
|
|
2241
|
+
return forSegments(points, (a, b) => {
|
|
2242
|
+
let [lo, hi] = [{ x: Math.min(a.x, b.x), y: Math.min(a.y, b.y) }, { x: Math.max(a.x, b.x), y: Math.max(a.y, b.y) }];
|
|
2243
|
+
if (a.y === b.y && a.y > y && a.y < y + h) for (let frame of [x, x + w]) lo.x < frame && frame < hi.x && hits.push({ x: frame, y: a.y });
|
|
2244
|
+
if (a.x === b.x && a.x > x && a.x < x + w) for (let frame of [y, y + h]) lo.y < frame && frame < hi.y && hits.push({ x: a.x, y: frame });
|
|
2245
|
+
}), hits;
|
|
2246
|
+
}
|
|
2247
|
+
function selfLoopRoute(rect, env) {
|
|
2248
|
+
let bottom = rect.y + rect.h, reach = snap(bottom + LOOP_REACH * env.u), right = snap(rect.x + rect.w - 2 * env.u), left = snap(right - 4 * env.u);
|
|
2249
|
+
return [{ x: left, y: bottom }, { x: left, y: reach }, { x: right, y: reach }, { x: right, y: bottom }];
|
|
2250
|
+
}
|
|
2251
|
+
function findLast(items, test) {
|
|
2252
|
+
for (let index = items.length - 1; index >= 0; index--) if (test(items[index])) return index;
|
|
2253
|
+
return -1;
|
|
2254
|
+
}
|
|
2255
|
+
function obstacleGrid(geometry, W, H) {
|
|
2256
|
+
let { xs, ys } = geometry, grid = { h: new Uint8Array(W * H), v: new Uint8Array(W * H), vertex: new Uint8Array(W * H) }, boxes = [
|
|
2257
|
+
...[...geometry.rects.values()].map((rect) => ({ x: rect.x - NODE_CLEARANCE, y: rect.y - NODE_CLEARANCE, w: rect.w + 2 * NODE_CLEARANCE, h: rect.h + 2 * NODE_CLEARANCE })),
|
|
2258
|
+
...geometry.labelClaims.map((rect) => ({ x: rect.x - TEXT_CLEARANCE, y: rect.y - TEXT_CLEARANCE, w: rect.w + 2 * TEXT_CLEARANCE, h: rect.h + 2 * TEXT_CLEARANCE })),
|
|
2259
|
+
...geometry.loops
|
|
2260
|
+
];
|
|
2261
|
+
for (let box of boxes) {
|
|
2262
|
+
let x1 = box.x + box.w, y1 = box.y + box.h;
|
|
2263
|
+
for (let j = 0; j < H; j++) {
|
|
2264
|
+
let y = ys[j].pos;
|
|
2265
|
+
for (let i = 0; i < W; i++) {
|
|
2266
|
+
let x = xs[i].pos;
|
|
2267
|
+
y > box.y && y < y1 && (x > box.x && x < x1 && (grid.vertex[i + j * W] = 1), i + 1 < W && xs[i + 1].pos > box.x && x < x1 && (grid.h[i + j * W] = 1)), x > box.x && x < x1 && j + 1 < H && ys[j + 1].pos > box.y && y < y1 && (grid.v[i + j * W] = 1);
|
|
2268
|
+
}
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2271
|
+
return grid;
|
|
2272
|
+
}
|
|
2273
|
+
var StateHeap = class {
|
|
2274
|
+
constructor(cost) {
|
|
2275
|
+
this.cost = cost;
|
|
2276
|
+
}
|
|
2277
|
+
cost;
|
|
2278
|
+
items = [];
|
|
2279
|
+
get size() {
|
|
2280
|
+
return this.items.length;
|
|
2281
|
+
}
|
|
2282
|
+
less(a, b) {
|
|
2283
|
+
return this.cost[a] < this.cost[b] || this.cost[a] === this.cost[b] && a < b;
|
|
2284
|
+
}
|
|
2285
|
+
push(state) {
|
|
2286
|
+
let items = this.items;
|
|
2287
|
+
items.push(state);
|
|
2288
|
+
let index = items.length - 1;
|
|
2289
|
+
for (; index > 0; ) {
|
|
2290
|
+
let parent = index - 1 >> 1;
|
|
2291
|
+
if (!this.less(items[index], items[parent])) break;
|
|
2292
|
+
[items[index], items[parent]] = [items[parent], items[index]], index = parent;
|
|
2293
|
+
}
|
|
2294
|
+
}
|
|
2295
|
+
pop() {
|
|
2296
|
+
let items = this.items, top = items[0], tail = items.pop();
|
|
2297
|
+
if (items.length > 0) {
|
|
2298
|
+
items[0] = tail;
|
|
2299
|
+
let index = 0;
|
|
2300
|
+
for (; ; ) {
|
|
2301
|
+
let left = 2 * index + 1, right = left + 1, least = index;
|
|
2302
|
+
if (left < items.length && this.less(items[left], items[least]) && (least = left), right < items.length && this.less(items[right], items[least]) && (least = right), least === index) break;
|
|
2303
|
+
[items[index], items[least]] = [items[least], items[index]], index = least;
|
|
2304
|
+
}
|
|
2305
|
+
}
|
|
2306
|
+
return top;
|
|
2307
|
+
}
|
|
2308
|
+
};
|
|
2309
|
+
function runsOf(trail, W, geometry, source, target, sourceSide, targetSide, edge) {
|
|
2310
|
+
let { xs, ys } = geometry, at = (state) => {
|
|
2311
|
+
let vertex = state >> 2, i = vertex % W;
|
|
2312
|
+
return { i, j: (vertex - i) / W, horizontal: (state & 3) % 2 === 0 };
|
|
2313
|
+
}, coordinate = (side, rect) => side === "left" ? rect.x : side === "right" ? rect.x + rect.w : side === "top" ? rect.y : rect.y + rect.h, runs = [], head = at(trail[0]), run = { edge, horizontal: head.horizontal, line: head.horizontal ? head.j : head.i, from: coordinate(sourceSide, source), to: 0, fromLine: -1, toLine: -1, track: 0 };
|
|
2314
|
+
for (let index = 1; index < trail.length; index++) {
|
|
2315
|
+
let point = at(trail[index]);
|
|
2316
|
+
if (point.horizontal === run.horizontal) continue;
|
|
2317
|
+
let corner = at(trail[index - 1]);
|
|
2318
|
+
run.to = run.horizontal ? xs[corner.i].pos : ys[corner.j].pos, run.toLine = run.horizontal ? corner.i : corner.j, runs.push(run), run = { edge, horizontal: point.horizontal, line: point.horizontal ? corner.j : corner.i, from: run.horizontal ? ys[corner.j].pos : xs[corner.i].pos, to: 0, fromLine: run.horizontal ? corner.j : corner.i, toLine: -1, track: 0 };
|
|
2319
|
+
}
|
|
2320
|
+
return run.to = coordinate(targetSide, target), runs.push(run), runs;
|
|
2321
|
+
}
|
|
2322
|
+
var lineKey = (run) => `${run.horizontal ? "h" : "v"}:${run.line}`;
|
|
2323
|
+
function assignTracks(runs, order) {
|
|
2324
|
+
let lines = /* @__PURE__ */ new Map();
|
|
2325
|
+
for (let run of runs) lines.set(lineKey(run), [...lines.get(lineKey(run)) ?? [], run]);
|
|
2326
|
+
let counts = /* @__PURE__ */ new Map();
|
|
2327
|
+
for (let [key, members] of lines) {
|
|
2328
|
+
members.sort((a, b) => Math.min(a.from, a.to) - Math.min(b.from, b.to) || a.edge - b.edge);
|
|
2329
|
+
let tracks = [], meets = (a, b) => Math.min(a.from, a.to) - PITCH < Math.max(b.from, b.to) && Math.min(b.from, b.to) - PITCH < Math.max(a.from, a.to);
|
|
2330
|
+
for (let run of members) {
|
|
2331
|
+
let allowed = (track) => track.every((other) => other.edge === run.edge || !meets(other, run) || compatible(order[other.edge], order[run.edge])), joined = tracks.findIndex((track) => allowed(track) && track.some((other) => other.edge !== run.edge && meets(other, run) && compatible(order[other.edge], order[run.edge]))), index = joined >= 0 ? joined : tracks.findIndex(allowed);
|
|
2332
|
+
index >= 0 ? (tracks[index].push(run), run.track = index) : (run.track = tracks.length, tracks.push([run]));
|
|
2333
|
+
}
|
|
2334
|
+
counts.set(key, tracks.length);
|
|
2335
|
+
}
|
|
2336
|
+
return counts;
|
|
2337
|
+
}
|
|
2338
|
+
function trackOffset(run, counts) {
|
|
2339
|
+
let tracks = counts.get(lineKey(run)) ?? 1;
|
|
2340
|
+
return (run.track - (tracks - 1) / 2) * PITCH;
|
|
2341
|
+
}
|
|
2342
|
+
function polyline(path, geometry, offset) {
|
|
2343
|
+
if (path.length === 0) return [];
|
|
2344
|
+
let position = (run) => (run.horizontal ? geometry.ys : geometry.xs)[run.line].pos + offset(run), first = path[0], last = path.at(-1), points = [first.horizontal ? { x: first.from, y: position(first) } : { x: position(first), y: first.from }];
|
|
2345
|
+
for (let index = 1; index < path.length; index++) {
|
|
2346
|
+
let a = path[index - 1], b = path[index];
|
|
2347
|
+
points.push(a.horizontal ? { x: position(b), y: position(a) } : { x: position(a), y: position(b) });
|
|
2348
|
+
}
|
|
2349
|
+
return points.push(last.horizontal ? { x: last.to, y: position(last) } : { x: position(last), y: last.to }), points.map((point) => ({ x: q(point.x), y: q(point.y) }));
|
|
2350
|
+
}
|
|
2351
|
+
function crossings(polylines, order) {
|
|
2352
|
+
let total = 0;
|
|
2353
|
+
for (let a = 0; a < polylines.length; a++)
|
|
2354
|
+
for (let b = a + 1; b < polylines.length; b++)
|
|
2355
|
+
compatible(order[a], order[b]) || forSegments(polylines[a], (p, q1) => forSegments(polylines[b], (r, s) => {
|
|
2356
|
+
let pH = p.y === q1.y, rH = r.y === s.y;
|
|
2357
|
+
if (pH === rH) return;
|
|
2358
|
+
let [h0, h1, v0, v1] = pH ? [p, q1, r, s] : [r, s, p, q1];
|
|
2359
|
+
Math.min(h0.x, h1.x) < v0.x && v0.x < Math.max(h0.x, h1.x) && Math.min(v0.y, v1.y) < h0.y && h0.y < Math.max(v0.y, v1.y) && total++;
|
|
2360
|
+
}));
|
|
2361
|
+
return total;
|
|
2362
|
+
}
|
|
2363
|
+
function forSegments(points, visit) {
|
|
2364
|
+
for (let index = 1; index < points.length; index++) visit(points[index - 1], points[index]);
|
|
2365
|
+
}
|
|
2366
|
+
function settleCrossings(all, runs, counts, order, geometry, start) {
|
|
2367
|
+
let polylines = start, score = crossings(polylines, order), keys = [...counts].filter(([, tracks]) => tracks > 1).map(([key]) => key).sort();
|
|
2368
|
+
for (let key of keys) {
|
|
2369
|
+
if (score === 0) break;
|
|
2370
|
+
let members = all.filter((run) => lineKey(run) === key), tracks = counts.get(key);
|
|
2371
|
+
members.forEach((run) => {
|
|
2372
|
+
run.track = tracks - 1 - run.track;
|
|
2373
|
+
});
|
|
2374
|
+
let trial = runs.map((path) => polyline(path, geometry, (run) => trackOffset(run, counts))), next = crossings(trial, order);
|
|
2375
|
+
next < score ? (score = next, polylines = trial) : members.forEach((run) => {
|
|
2376
|
+
run.track = tracks - 1 - run.track;
|
|
2377
|
+
});
|
|
2378
|
+
}
|
|
2379
|
+
return polylines;
|
|
2380
|
+
}
|
|
2381
|
+
function lineProblems(order, polylines, rects, geometry, data, zones) {
|
|
2382
|
+
let problems = [];
|
|
2383
|
+
return order.forEach((edge, index) => {
|
|
2384
|
+
let points = polylines[index];
|
|
2385
|
+
if (points.length !== 0) {
|
|
2386
|
+
(!touches(points[0], endRect(edge, "source", geometry, data)) || !touches(points.at(-1), endRect(edge, "target", geometry, data))) && problems.push(edge.id);
|
|
2387
|
+
for (let zone of zones) {
|
|
2388
|
+
let loops = edge.flow === "return" && endInside(edge, "source", zone, data) && endInside(edge, "target", zone, data) && !data.groups.find((group) => group.id === zone.id)?.protected;
|
|
2389
|
+
frameHits(points, zone.bounds).length > (mustCross(edge, zone, data) ? 1 : loops ? 2 : 0) && problems.push(edge.id);
|
|
2390
|
+
}
|
|
2391
|
+
forSegments(points, (a, b) => {
|
|
2392
|
+
for (let [id, rect] of rects) {
|
|
2393
|
+
let own = id === edge.source.nodeId || id === edge.target.nodeId;
|
|
2394
|
+
segmentHits(a, b, own ? { x: rect.x + 1, y: rect.y + 1, w: rect.w - 2, h: rect.h - 2 } : { x: rect.x - 1, y: rect.y - 1, w: rect.w + 2, h: rect.h + 2 }) && problems.push(edge.id);
|
|
2395
|
+
}
|
|
2396
|
+
});
|
|
2397
|
+
for (let other = index + 1; other < order.length; other++)
|
|
2398
|
+
compatible(edge, order[other]) || forSegments(points, (a, b) => forSegments(polylines[other], (c, d) => {
|
|
2399
|
+
let horizontal = a.y === b.y;
|
|
2400
|
+
if (horizontal !== (c.y === d.y)) return;
|
|
2401
|
+
let apart = Math.abs(horizontal ? a.y - c.y : a.x - c.x), [a0, a1, c0, c1] = horizontal ? [a.x, b.x, c.x, d.x] : [a.y, b.y, c.y, d.y];
|
|
2402
|
+
apart < PITCH - 1 && Math.min(a0, a1) < Math.max(c0, c1) && Math.min(c0, c1) < Math.max(a0, a1) && problems.push(edge.id);
|
|
2403
|
+
}));
|
|
2404
|
+
}
|
|
2405
|
+
}), problems;
|
|
2406
|
+
}
|
|
2407
|
+
var touches = (point, rect) => point.x >= rect.x && point.x <= rect.x + rect.w && point.y >= rect.y && point.y <= rect.y + rect.h;
|
|
2408
|
+
function segmentHits(a, b, rect) {
|
|
2409
|
+
let x0 = Math.min(a.x, b.x), x1 = Math.max(a.x, b.x), y0 = Math.min(a.y, b.y), y1 = Math.max(a.y, b.y);
|
|
2410
|
+
return x0 < rect.x + rect.w && x1 > rect.x && y0 < rect.y + rect.h && y1 > rect.y;
|
|
2411
|
+
}
|
|
2412
|
+
function grown(rect, by) {
|
|
2413
|
+
return { x: rect.x - by, y: rect.y - by, w: rect.w + 2 * by, h: rect.h + 2 * by };
|
|
2414
|
+
}
|
|
2415
|
+
function labelClear(box, blockers, plot) {
|
|
2416
|
+
if (box.x < plot.x || box.x + box.w > plot.x + plot.w) return !1;
|
|
2417
|
+
let left = box.x - TEXT_CLEARANCE, top = box.y - TEXT_CLEARANCE, right = left + (box.w + 2 * TEXT_CLEARANCE), bottom = top + (box.h + 2 * TEXT_CLEARANCE);
|
|
2418
|
+
for (let rect of blockers) if (left < rect.x + rect.w && rect.x < right && top < rect.y + rect.h && rect.y < bottom) return !1;
|
|
2419
|
+
return !0;
|
|
2420
|
+
}
|
|
2421
|
+
function labelsApart(box, labels, u) {
|
|
2422
|
+
for (let other of labels)
|
|
2423
|
+
if (box.y < other.y + other.h && other.y < box.y + box.h && box.x < other.x + other.w + 2 * u && other.x < box.x + box.w + 2 * u) return !1;
|
|
2424
|
+
return !0;
|
|
2425
|
+
}
|
|
2426
|
+
function slidePositions(box, axis, claims, positions = /* @__PURE__ */ new Set()) {
|
|
2427
|
+
if (axis === "x") {
|
|
2428
|
+
let top = box.y - TEXT_CLEARANCE, bottom = top + (box.h + 2 * TEXT_CLEARANCE);
|
|
2429
|
+
for (let claim of claims)
|
|
2430
|
+
top >= claim.y + claim.h || claim.y >= bottom || (positions.add(Math.floor(2 * (claim.x - box.w - TEXT_CLEARANCE)) / 2), positions.add(Math.ceil(2 * (claim.x + claim.w + TEXT_CLEARANCE)) / 2));
|
|
2431
|
+
} else {
|
|
2432
|
+
let left = box.x - TEXT_CLEARANCE, right = left + (box.w + 2 * TEXT_CLEARANCE);
|
|
2433
|
+
for (let claim of claims)
|
|
2434
|
+
left >= claim.x + claim.w || claim.x >= right || (positions.add(Math.floor(2 * (claim.y - box.h - TEXT_CLEARANCE)) / 2), positions.add(Math.ceil(2 * (claim.y + claim.h + TEXT_CLEARANCE)) / 2));
|
|
2435
|
+
}
|
|
2436
|
+
return Array.from(positions);
|
|
2437
|
+
}
|
|
2438
|
+
function slideLabel(box, axis, from, to, claims, clear) {
|
|
2439
|
+
if (clear(box)) return box;
|
|
2440
|
+
let size = axis === "x" ? box.w : box.h, best, offset = 1 / 0;
|
|
2441
|
+
for (let position of slidePositions(box, axis, claims)) {
|
|
2442
|
+
if (position + size / 2 < from || position + size / 2 > to) continue;
|
|
2443
|
+
let distance = Math.abs(position - box[axis]);
|
|
2444
|
+
if (distance > offset || distance === offset && position >= best[axis]) continue;
|
|
2445
|
+
let candidate = { ...box, [axis]: position };
|
|
2446
|
+
clear(candidate) && (best = candidate, offset = distance);
|
|
2447
|
+
}
|
|
2448
|
+
return best;
|
|
2449
|
+
}
|
|
2450
|
+
function labelClaims(segmentBoxes, blockers) {
|
|
2451
|
+
let claims = [...blockers];
|
|
2452
|
+
for (let boxes of segmentBoxes) for (let box of boxes) claims.push(box);
|
|
2453
|
+
return claims;
|
|
2454
|
+
}
|
|
2455
|
+
function canImprove(box, segments, distance) {
|
|
2456
|
+
if (distance === 1 / 0 || segments.length === 0) return !0;
|
|
2457
|
+
if (!(distance > 0)) return !1;
|
|
2458
|
+
for (let segment of segments)
|
|
2459
|
+
if (segment.x - box.x - box.w < distance && box.x - segment.x - segment.w < distance && segment.y - box.y - box.h < distance && box.y - segment.y - segment.h < distance) return !0;
|
|
2460
|
+
return !1;
|
|
2461
|
+
}
|
|
2462
|
+
function spacedLabel(box, u) {
|
|
2463
|
+
let extra = Math.max(0, 2 * u - TEXT_CLEARANCE);
|
|
2464
|
+
return { ...box, x: box.x - extra, w: box.w + 2 * extra };
|
|
2465
|
+
}
|
|
2466
|
+
var gapContains = (item, point) => point.x >= item.rect.x && point.x <= item.rect.x + item.rect.w && point.y >= item.rect.y && point.y <= item.rect.y + item.rect.h, segmentMiddle = ([a, b]) => ({ x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 }), labelGutterWidth = (width, seg) => (seg[0].x === seg[1].x ? 2 : 1) * (width + 2 * (TEXT_CLEARANCE + 1)), segmentLength = ([a, b]) => Math.abs(a.x - b.x) + Math.abs(a.y - b.y), longestFirst = (a, b) => segmentLength(b) - segmentLength(a);
|
|
2467
|
+
function edgeLabelBlocks(edge, env) {
|
|
2468
|
+
let cache = env.labelBlocks ??= /* @__PURE__ */ new Map(), cached = cache.get(edge.id);
|
|
2469
|
+
if (cached) return cached;
|
|
2470
|
+
let { text, measure } = env, lineH = text.size * (text.lineHeight ?? 1.2), one = Math.ceil(measure(edge.label, text).width) + 1, two = wrapText(edge.label, text, Math.ceil(one * 0.6), 2, measure), disc = env.data.callouts.some((callout) => "edgeId" in callout.target && callout.target.edgeId === edge.id) ? discSize(env) + 2 : 0, blocks = [{ width: one + disc, height: Math.max(lineH, disc) }], three = wrapText(edge.label, text, Math.ceil(one * 0.42), 3, measure);
|
|
2471
|
+
for (let wrapped of [two, three])
|
|
2472
|
+
!wrapped.truncated && wrapped.lines.length > 1 && blocks.push({ width: Math.ceil(Math.max(...wrapped.lines.map((line) => measure(line, text).width))) + 1 + disc, height: wrapped.lines.length * lineH });
|
|
2473
|
+
return cache.set(edge.id, blocks), blocks;
|
|
2474
|
+
}
|
|
2475
|
+
function prepareLabelSeats(edge, points, geometry, env, plot) {
|
|
2476
|
+
let segments = [];
|
|
2477
|
+
forSegments(points, (a, b) => segments.push([a, b]));
|
|
2478
|
+
let flat = segments.filter((s) => s[0].y === s[1].y).sort(longestFirst), upright = segments.filter((s) => s[0].x === s[1].x).sort(longestFirst), blocks = edgeLabelBlocks(edge, env);
|
|
2479
|
+
return { segments, flat, blocks, seats: [], rest: edgeLabelSeats(blocks, flat, upright, geometry, env, plot), bands: /* @__PURE__ */ new Map(), pass: 0 };
|
|
2480
|
+
}
|
|
2481
|
+
function* edgeLabelSeats(blocks, flat, upright, geometry, env, plot) {
|
|
2482
|
+
let off = TEXT_CLEARANCE + 1, rows = geometry.gaps.filter((item) => item.axis === "h"), horizontal = flat.map(([a, b]) => {
|
|
2483
|
+
let from = Math.min(a.x, b.x), to = Math.max(a.x, b.x), spots = [(a.x + b.x) / 2];
|
|
2484
|
+
for (let gap of geometry.gaps) gap.axis === "v" && from <= gap.rect.x && to >= gap.rect.x + gap.rect.w && spots.push(gap.rect.x + gap.rect.w / 4, gap.rect.x + 3 * gap.rect.w / 4);
|
|
2485
|
+
for (let { bounds } of geometry.zones) for (let wall of [bounds.x, bounds.x + bounds.w])
|
|
2486
|
+
wall > from && wall < to && spots.push((a.x + wall) / 2, (b.x + wall) / 2);
|
|
2487
|
+
return { y: a.y, from, to, spots };
|
|
2488
|
+
}), vertical = upright.map(([a, b]) => {
|
|
2489
|
+
let from = Math.min(a.y, b.y), to = Math.max(a.y, b.y), middles = [(a.y + b.y) / 2];
|
|
2490
|
+
for (let { bounds } of geometry.zones) for (let wall of [bounds.y, bounds.y + bounds.h])
|
|
2491
|
+
wall > from && wall < to && middles.push((a.y + wall) / 2, (b.y + wall) / 2);
|
|
2492
|
+
return { x: a.x, from, to, middles, crossed: rows.filter((row) => row.rect.y > from && row.rect.y + row.rect.h < to) };
|
|
2493
|
+
});
|
|
2494
|
+
for (let { width, height } of blocks) {
|
|
2495
|
+
let w = q(width), h = q(height);
|
|
2496
|
+
if (!(w > plot.w)) {
|
|
2497
|
+
for (let { y, from, to, spots } of horizontal) for (let spot of spots) {
|
|
2498
|
+
let x = q(Math.max(env.plot.x, Math.min(spot - width / 2, env.plot.x + env.plot.w - width)));
|
|
2499
|
+
yield { box: { x, y: q(y - off - height), w, h }, axis: "x", from, to }, yield { box: { x, y: q(y + off), w, h }, axis: "x", from, to };
|
|
2500
|
+
}
|
|
2501
|
+
for (let { x, from, to, middles, crossed } of vertical) {
|
|
2502
|
+
let right = q(x + off + 2), left = q(x - off - 2 - width);
|
|
2503
|
+
for (let middle of middles) {
|
|
2504
|
+
let y = q(middle - height / 2);
|
|
2505
|
+
yield { box: { x: right, y, w, h }, axis: "y", from, to }, yield { box: { x: left, y, w, h }, axis: "y", from, to };
|
|
2506
|
+
}
|
|
2507
|
+
for (let row of crossed) {
|
|
2508
|
+
let y = q(row.rect.y + (row.rect.h - height) / 2);
|
|
2509
|
+
yield { box: { x: right, y, w, h }, axis: "y", from, to }, yield { box: { x: left, y, w, h }, axis: "y", from, to };
|
|
2510
|
+
for (let { bounds } of geometry.zones)
|
|
2511
|
+
x > bounds.x + bounds.w && x - bounds.x - bounds.w < width + 2 * off ? yield { box: { x: q(bounds.x + bounds.w - off - width), y, w, h }, axis: "y", from, to } : x < bounds.x && bounds.x - x < width + 2 * off && (yield { box: { x: q(bounds.x + off), y, w, h }, axis: "y", from, to });
|
|
2512
|
+
}
|
|
2513
|
+
}
|
|
2514
|
+
}
|
|
2515
|
+
}
|
|
2516
|
+
}
|
|
2517
|
+
function considerLabel(box, axis, band, pos, search) {
|
|
2518
|
+
if (band.seen.has(pos)) return;
|
|
2519
|
+
band.seen.add(pos);
|
|
2520
|
+
let candidate = pos === (axis === "x" ? box.x : box.y) ? box : {
|
|
2521
|
+
x: axis === "x" ? pos : box.x,
|
|
2522
|
+
y: axis === "y" ? pos : box.y,
|
|
2523
|
+
w: box.w,
|
|
2524
|
+
h: box.h
|
|
2525
|
+
};
|
|
2526
|
+
if (!canImprove(candidate, search.segmentBoxes, search.nearest) || !labelClear(candidate, band.blockers, search.plot) || search.otherLabels.length > 0 && (!labelClear(candidate, search.otherLabels, search.plot) || !labelsApart(candidate, search.otherLabels, search.u))) return;
|
|
2527
|
+
let distances = band.distances ??= /* @__PURE__ */ new Map(), cached = distances.get(pos), distance = cached ?? rectLineDistance(candidate, search.points);
|
|
2528
|
+
if (cached === void 0 && distances.set(pos, distance), !(search.seat && distance >= search.nearest)) {
|
|
2529
|
+
if (search.ownReturn) {
|
|
2530
|
+
for (let other = 0; other < search.polylines.length; other++)
|
|
2531
|
+
if (other !== search.index && canImprove(candidate, search.lineBoxes[other], distance) && !(distance <= rectLineDistance(candidate, search.polylines[other]))) return;
|
|
2532
|
+
}
|
|
2533
|
+
search.seat = candidate, search.nearest = distance;
|
|
2534
|
+
}
|
|
2535
|
+
}
|
|
2536
|
+
function placeLabels(order, polylines, segmentBoxes, geometry, env, needs, unseated, outward, lines) {
|
|
2537
|
+
let out = /* @__PURE__ */ new Map();
|
|
2538
|
+
if (!order.some((edge) => edge.label)) return out;
|
|
2539
|
+
let blockers = lines.labelBlockers, spacing = [], otherLabels = [], plot = { ...env.plot, x: geometry.labelLeft, w: env.plot.x + env.plot.w - geometry.labelLeft }, rows = geometry.gaps.filter((item) => item.axis === "h");
|
|
2540
|
+
for (let index = 0; index < order.length; index++) {
|
|
2541
|
+
let edge = order[index];
|
|
2542
|
+
if (!edge.label) continue;
|
|
2543
|
+
let points = polylines[index], prepared = lines.seats.get(edge.id);
|
|
2544
|
+
prepared || (prepared = prepareLabelSeats(edge, points, geometry, env, plot), lines.seats.set(edge.id, prepared));
|
|
2545
|
+
let { segments, flat, blocks } = prepared, off = TEXT_CLEARANCE + 1, pass = ++prepared.pass, search = {
|
|
2546
|
+
seat: void 0,
|
|
2547
|
+
nearest: 1 / 0,
|
|
2548
|
+
points,
|
|
2549
|
+
segmentBoxes: segmentBoxes[index],
|
|
2550
|
+
lineBoxes: segmentBoxes,
|
|
2551
|
+
polylines,
|
|
2552
|
+
index,
|
|
2553
|
+
plot,
|
|
2554
|
+
otherLabels,
|
|
2555
|
+
u: env.u,
|
|
2556
|
+
ownReturn: !!env.ownReturnLabels && edge.flow === "return"
|
|
2557
|
+
};
|
|
2558
|
+
for (let at = 0; ; at++) {
|
|
2559
|
+
let candidate = prepared.seats[at];
|
|
2560
|
+
if (!candidate) {
|
|
2561
|
+
let next = prepared.rest.next();
|
|
2562
|
+
if (next.done) break;
|
|
2563
|
+
candidate = next.value, prepared.seats.push(candidate);
|
|
2564
|
+
}
|
|
2565
|
+
let { box, axis, from, to } = candidate;
|
|
2566
|
+
if (axis === "y" && (box.x < plot.x || box.x + box.w > plot.x + plot.w)) continue;
|
|
2567
|
+
let size = axis === "x" ? box.w : box.h, start = axis === "x" ? Math.max(from - size / 2, plot.x) : from - size / 2, end = axis === "x" ? Math.min(to - size / 2, plot.x + plot.w - box.w) : to - size / 2, sweep = axis === "x" ? { x: start, y: box.y, w: end - start + box.w, h: box.h } : { x: box.x, y: start, w: box.w, h: end - start + box.h };
|
|
2568
|
+
if (!canImprove(box, segmentBoxes[index], search.nearest) && (start > end || !canImprove(sweep, segmentBoxes[index], search.nearest))) continue;
|
|
2569
|
+
let key = `${axis}:${axis === "x" ? box.y : box.x}:${box.w}:${box.h}`, band = prepared.bands.get(key);
|
|
2570
|
+
if (band)
|
|
2571
|
+
band.pass !== pass && (band.seen.clear(), band.remaining = void 0, band.pass = pass);
|
|
2572
|
+
else {
|
|
2573
|
+
let halo = grown(box, TEXT_CLEARANCE);
|
|
2574
|
+
band = {
|
|
2575
|
+
blockers: axis === "x" ? blockers.filter((rect) => halo.y < rect.y + rect.h && rect.y < halo.y + halo.h) : blockers.filter((rect) => halo.x < rect.x + rect.w && rect.x < halo.x + halo.w),
|
|
2576
|
+
seen: /* @__PURE__ */ new Set(),
|
|
2577
|
+
pass
|
|
2578
|
+
}, prepared.bands.set(key, band);
|
|
2579
|
+
}
|
|
2580
|
+
let position = axis === "x" ? box.x : box.y;
|
|
2581
|
+
if (considerLabel(box, axis, band, position, search), search.nearest === TEXT_CLEARANCE) break;
|
|
2582
|
+
if (band.remaining?.length === 0 || start > end || !canImprove(sweep, segmentBoxes[index], search.nearest) || search.nearest <= rectLineDistance(sweep, points)) continue;
|
|
2583
|
+
let bandBlockers = band.blockers, fixedPositions = band.positions ??= slidePositions(box, axis, bandBlockers).filter((pos) => {
|
|
2584
|
+
let candidate2 = { x: axis === "x" ? pos : box.x, y: axis === "y" ? pos : box.y, w: box.w, h: box.h };
|
|
2585
|
+
return labelClear(candidate2, bandBlockers, plot);
|
|
2586
|
+
}).sort((a, b) => a - b), positions = band.remaining ??= spacing.length === 0 ? fixedPositions : slidePositions(box, axis, spacing, new Set(fixedPositions)).sort((a, b) => a - b), lo = 0, hi = positions.length;
|
|
2587
|
+
for (; lo < hi; ) {
|
|
2588
|
+
let mid = lo + hi >>> 1;
|
|
2589
|
+
positions[mid] < position ? lo = mid + 1 : hi = mid;
|
|
2590
|
+
}
|
|
2591
|
+
let left = lo - 1, right = lo;
|
|
2592
|
+
for (; (left >= 0 || right < positions.length) && search.nearest !== TEXT_CLEARANCE; ) {
|
|
2593
|
+
let before = left >= 0 ? positions[left] : -1 / 0, after = right < positions.length ? positions[right] : 1 / 0, pos = position - before <= after - position ? positions[left--] : positions[right++];
|
|
2594
|
+
pos >= start && pos <= end && considerLabel(box, axis, band, pos, search);
|
|
2595
|
+
}
|
|
2596
|
+
if (band.remaining = positions.filter((pos) => !band.seen.has(pos)), search.nearest === TEXT_CLEARANCE) break;
|
|
2597
|
+
}
|
|
2598
|
+
if (search.seat) {
|
|
2599
|
+
out.set(edge.id, search.seat), otherLabels.push(search.seat), spacing.push(search.seat, spacedLabel(search.seat, env.u));
|
|
2600
|
+
continue;
|
|
2601
|
+
}
|
|
2602
|
+
if (unseated.push(edge.id), edge.flow === "return" && !outward.has(edge.id)) continue;
|
|
2603
|
+
let block = blocks.at(-1), tall = 2 * (block.height + off + TEXT_CLEARANCE), along = flat.find((seg) => segmentLength(seg) >= block.width + 2 * off && rows.some((row2) => gapContains(row2, segmentMiddle(seg))));
|
|
2604
|
+
if (along) {
|
|
2605
|
+
let row2 = rows.find((item) => gapContains(item, segmentMiddle(along)));
|
|
2606
|
+
needs.set(row2.key, Math.max(needs.get(row2.key) ?? 0, tall));
|
|
2607
|
+
continue;
|
|
2608
|
+
}
|
|
2609
|
+
let longest = [...segments].sort((a, b) => segmentLength(b) - segmentLength(a))[0];
|
|
2610
|
+
if (!longest) continue;
|
|
2611
|
+
let inside = geometry.gaps.find((item) => gapContains(item, segmentMiddle(longest))), wide = labelGutterWidth(block.width, longest), gap = (inside?.axis === "v" && wide > env.plot.w / 3 ? rows.filter((item) => item.rect.y > Math.min(longest[0].y, longest[1].y) && item.rect.y + item.rect.h < Math.max(longest[0].y, longest[1].y)).sort((a, b) => Math.abs(a.rect.y - segmentMiddle(longest).y) - Math.abs(b.rect.y - segmentMiddle(longest).y))[0] : void 0) ?? inside;
|
|
2612
|
+
if (gap) {
|
|
2613
|
+
if (gap.axis === "v" && longest[0].y === longest[1].y) {
|
|
2614
|
+
let tracks = [];
|
|
2615
|
+
for (let line of polylines) forSegments(line, (a, b) => {
|
|
2616
|
+
a.x === b.x && a.x > gap.rect.x && a.x < gap.rect.x + gap.rect.w && Math.min(a.y, b.y) < longest[0].y - off && Math.max(a.y, b.y) > longest[0].y + off && tracks.push(a.x);
|
|
2617
|
+
});
|
|
2618
|
+
tracks.length > 0 && (wide = Math.max(wide, 2 * (block.width + 2 * off) + Math.max(...tracks) - Math.min(...tracks)));
|
|
2619
|
+
}
|
|
2620
|
+
needs.set(gap.key, Math.max(needs.get(gap.key) ?? 0, gap.axis === "v" ? wide : tall)), gap.axis === "v" && block !== blocks[0] && needs.set(`want:${gap.key}`, labelGutterWidth(blocks[0].width, longest));
|
|
2621
|
+
}
|
|
2622
|
+
}
|
|
2623
|
+
return out;
|
|
2624
|
+
}
|
|
2625
|
+
function placeChannels(order, polylines, segmentBoxes, geometry, labels, env, needs, problems) {
|
|
2626
|
+
let { text, measure, data } = env, out = [];
|
|
2627
|
+
if (data.channels.length === 0) return out;
|
|
2628
|
+
let blockers = labelClaims(segmentBoxes, [...geometry.rects.values(), ...geometry.labelClaims, ...labels.values()]), otherLabels = [...labels.values()], claims = [...blockers, ...otherLabels.map((box) => spacedLabel(box, env.u))], plot = { ...env.plot, x: geometry.labelLeft, w: env.plot.x + env.plot.w - geometry.labelLeft }, lineH = text.size * (text.lineHeight ?? 1.2);
|
|
2629
|
+
for (let channel of data.channels) {
|
|
2630
|
+
let crossing = (gap2, points) => {
|
|
2631
|
+
let hits2 = [];
|
|
2632
|
+
return forSegments(points, (a, b) => {
|
|
2633
|
+
gap2.axis === "v" && a.y === b.y && Math.min(a.x, b.x) <= gap2.rect.x && Math.max(a.x, b.x) >= gap2.rect.x + gap2.rect.w && a.y >= gap2.rect.y && a.y <= gap2.rect.y + gap2.rect.h && hits2.push(a.y), gap2.axis === "h" && a.x === b.x && Math.min(a.y, b.y) <= gap2.rect.y && Math.max(a.y, b.y) >= gap2.rect.y + gap2.rect.h && hits2.push(a.x);
|
|
2634
|
+
}), hits2;
|
|
2635
|
+
}, members = channel.edgeIds.map((id) => polylines[order.findIndex((edge) => edge.id === id)]), gap = geometry.gaps.find((item) => members.every((points) => crossing(item, points).length > 0));
|
|
2636
|
+
if (!gap) {
|
|
2637
|
+
problems.push(`channel:${channel.id}`);
|
|
2638
|
+
continue;
|
|
2639
|
+
}
|
|
2640
|
+
let hits = members.flatMap((points) => crossing(gap, points)).sort((a, b) => a - b), room = gap.axis === "v" ? gap.rect.w - 2 * TEXT_CLEARANCE - 2 : Math.abs(hits.at(-1) - hits[0]) - 2 * TEXT_CLEARANCE - 2, oneLine = Math.ceil(measure(channel.label, text).width) + 1;
|
|
2641
|
+
gap.axis === "v" && needs.set(`want:${gap.key}`, oneLine + 2 * GAP_HALF);
|
|
2642
|
+
let wrapped = wrapText(channel.label, text, Math.max(1, Math.min(oneLine, room > 0 ? room : oneLine)), 2, measure), width = Math.ceil(Math.max(...wrapped.lines.map((line) => measure(line, text).width))) + 1, height = wrapped.lines.length * lineH, box = gap.axis === "v" ? { x: gap.rect.x + (gap.rect.w - width) / 2, y: hits.length > 1 ? (hits[0] + hits.at(-1)) / 2 - height / 2 : hits[0] + 2 * TEXT_CLEARANCE, w: width, h: height } : { x: hits.length > 1 ? (hits[0] + hits.at(-1)) / 2 - width / 2 : hits[0] + 2 * TEXT_CLEARANCE, y: gap.rect.y + (gap.rect.h - height) / 2, w: width, h: height }, rect = wrapped.truncated ? void 0 : slideLabel(
|
|
2643
|
+
qRect(box),
|
|
2644
|
+
gap.axis === "v" ? "y" : "x",
|
|
2645
|
+
hits[0],
|
|
2646
|
+
hits.at(-1),
|
|
2647
|
+
claims,
|
|
2648
|
+
(seat) => labelClear(seat, blockers, plot) && (otherLabels.length === 0 || labelsApart(seat, otherLabels, env.u))
|
|
2649
|
+
);
|
|
2650
|
+
if (wrapped.truncated || !rect) {
|
|
2651
|
+
problems.push(`channel:${channel.id}`), needs.set(gap.key, Math.max(needs.get(gap.key) ?? 0, gap.axis === "v" ? width + 2 * GAP_HALF : height + 2 * GAP_HALF));
|
|
2652
|
+
continue;
|
|
2653
|
+
}
|
|
2654
|
+
out.push({ id: channel.id, label: channel.label, rect, edgeId: channel.edgeIds[0] }), blockers.push(rect), otherLabels.push(rect), claims.push(rect, spacedLabel(rect, env.u));
|
|
2655
|
+
}
|
|
2656
|
+
return out;
|
|
2657
|
+
}
|
|
2658
|
+
function junctions(order, polylines) {
|
|
2659
|
+
let dots = /* @__PURE__ */ new Map(), add = (point) => dots.set(`${point.x}:${point.y}`, point);
|
|
2660
|
+
for (let a = 0; a < order.length; a++)
|
|
2661
|
+
for (let b = a + 1; b < order.length; b++) {
|
|
2662
|
+
if (!compatible(order[a], order[b])) continue;
|
|
2663
|
+
let [pa, pb] = [polylines[a], polylines[b]], ends = new Set([pa[0], pa.at(-1), pb[0], pb.at(-1)].map((point) => `${point?.x}:${point?.y}`));
|
|
2664
|
+
forSegments(pa, (p, r) => forSegments(pb, (s, t) => {
|
|
2665
|
+
let horizontal = p.y === r.y;
|
|
2666
|
+
if (horizontal !== (s.y === t.y) || (horizontal ? p.y !== s.y : p.x !== s.x)) return;
|
|
2667
|
+
let [p0, p1, s0, s1] = horizontal ? [p.x, r.x, s.x, t.x] : [p.y, r.y, s.y, t.y], lo = Math.max(Math.min(p0, p1), Math.min(s0, s1)), hi = Math.min(Math.max(p0, p1), Math.max(s0, s1));
|
|
2668
|
+
if (!(lo >= hi))
|
|
2669
|
+
for (let value of [lo, hi]) {
|
|
2670
|
+
let point = horizontal ? { x: value, y: p.y } : { x: p.x, y: value };
|
|
2671
|
+
ends.has(`${point.x}:${point.y}`) || add(point);
|
|
2672
|
+
}
|
|
2673
|
+
}));
|
|
2674
|
+
}
|
|
2675
|
+
return [...dots.keys()].sort().map((key) => dots.get(key));
|
|
2676
|
+
}
|
|
2677
|
+
function laneRamp(index, count) {
|
|
2678
|
+
let step = count === 1 ? 0 : Math.round(index * (LANE_RAMP.length - 1) / (count - 1)), tint = LANE_RAMP[step];
|
|
2679
|
+
return tint === 0 ? { token: "total" } : { token: "total", tint };
|
|
2680
|
+
}
|
|
2681
|
+
function architectureFill(node, lanes, palette) {
|
|
2682
|
+
if (node.shape.kind === "text") return { fill: { token: "background" } };
|
|
2683
|
+
let plain = node.role === void 0 || node.role === "primary", lane = lanes.findIndex((item) => item.id === node.laneId);
|
|
2684
|
+
return node.protected && (plain || node.role === "secondary" || node.role === "muted") ? { fill: { token: "total", tint: PROTECTED_TINT }, ring: "axis" } : plain && lane >= 0 ? { fill: laneRamp(lane, lanes.length) } : plain || node.role === "secondary" || node.role === "muted" ? { fill: { token: "background" }, ring: node.role === "muted" ? "grid" : "axis" } : node.role === "accent" && lane >= 0 ? { fill: { token: "focus", theme: { kind: "focus-apart", apartFrom: [{ token: "total" }] } } } : { fill: palette.fill(node.role, node.paletteKey) };
|
|
2685
|
+
}
|
|
2686
|
+
function emit(arrangement, geometry, routed, env, palette, theme) {
|
|
2687
|
+
let { data, name } = env, fills = /* @__PURE__ */ new Map(), rings = /* @__PURE__ */ new Map(), hair = strokeToken(theme, "hair");
|
|
2688
|
+
for (let node of data.nodes) {
|
|
2689
|
+
let { fill, ring } = architectureFill(node, data.lanes, palette);
|
|
2690
|
+
fills.set(node.id, fill), ring && rings.set(node.id, { stroke: { token: ring }, width: hair });
|
|
2691
|
+
}
|
|
2692
|
+
let groupById = new Map(data.groups.map((group) => [group.id, group])), zoneFills = /* @__PURE__ */ new Map();
|
|
2693
|
+
for (let zone of geometry.zones)
|
|
2694
|
+
groupById.get(zone.id).protected ? zoneFills.set(zone.id, { token: "total", tint: PROTECTED_TINT }) : zone.depth % 2 === 1 && zoneFills.set(zone.id, { token: "background" });
|
|
2695
|
+
let calloutEdges = new Set(data.callouts.flatMap((callout) => "edgeId" in callout.target ? [callout.target.edgeId] : []));
|
|
2696
|
+
for (let [id, label] of routed.labels) {
|
|
2697
|
+
let route = routed.routes.get(id);
|
|
2698
|
+
route && (route.labelBox = calloutEdges.has(id) ? { ...label, w: label.w - discSize(env) - 2 } : label);
|
|
2699
|
+
}
|
|
2700
|
+
let scene = [], claims = [], overlay = [], ink = { token: "inkMuted" }, lock = (id, box, owner) => compileIcon("lock", box).forEach((primitive, index) => {
|
|
2701
|
+
let common = { id: diagramSceneId("lock", id, String(index)), owner, part: "diagramIcon" };
|
|
2702
|
+
overlay.push(primitive.kind === "circle" ? { t: "circle", ...common, cx: primitive.cx, cy: primitive.cy, r: primitive.r, stroke: ink, strokeWidth: strokeToken(theme, "rule") } : { t: "path", ...common, d: primitive.d, stroke: ink, width: strokeToken(theme, "rule"), lineCap: "round" });
|
|
2703
|
+
}), innerFrame = (id, rect, owner) => {
|
|
2704
|
+
let [x, y, w, h] = [q(rect.x + PROTECTED_INSET), q(rect.y + PROTECTED_INSET), q(rect.w - 2 * PROTECTED_INSET), q(rect.h - 2 * PROTECTED_INSET)];
|
|
2705
|
+
return { t: "path", id: diagramSceneId("protected", id), d: `M${x} ${y}H${q(x + w)}V${q(y + h)}H${x}Z`, stroke: { token: "axis" }, width: hair, owner, part: "diagramGroup" };
|
|
2706
|
+
}, fronts = /* @__PURE__ */ new Map();
|
|
2707
|
+
for (let node of data.nodes) {
|
|
2708
|
+
let rect = geometry.rects.get(node.id), front = frontRect(node, rect);
|
|
2709
|
+
fronts.set(node.id, front);
|
|
2710
|
+
for (let copy = (node.repeat ?? 1) - 1; copy >= 1; copy--)
|
|
2711
|
+
scene.push({
|
|
2712
|
+
t: "rect",
|
|
2713
|
+
id: diagramSceneId("node", node.id, `copy-${copy}`),
|
|
2714
|
+
rect: qRect({ ...front, x: front.x + copy * REPEAT_STEP, y: front.y + copy * REPEAT_STEP }),
|
|
2715
|
+
fill: fills.get(node.id),
|
|
2716
|
+
stroke: { token: "axis" },
|
|
2717
|
+
strokeWidth: hair,
|
|
2718
|
+
owner: nodeOwner(node.id),
|
|
2719
|
+
part: "diagramNode"
|
|
2720
|
+
});
|
|
2721
|
+
if (node.protected) {
|
|
2722
|
+
overlay.push(innerFrame(node.id, front, nodeOwner(node.id)));
|
|
2723
|
+
let size = 2.5 * env.u;
|
|
2724
|
+
lock(node.id, qRect({ x: front.x + front.w - size - 1.5 * env.u, y: front.y + 1.5 * env.u, w: size, h: size }), nodeOwner(node.id));
|
|
2725
|
+
}
|
|
2726
|
+
}
|
|
2727
|
+
for (let zone of geometry.zones)
|
|
2728
|
+
groupById.get(zone.id).protected && ((zone.dashed ? overlay : scene).push(innerFrame(zone.id, zone.bounds, { seriesId: zone.id })), lock(zone.id, geometry.locks.get(zone.id), { seriesId: zone.id }));
|
|
2729
|
+
let channelled = new Set(data.channels.flatMap((channel) => channel.edgeIds)), marked = /* @__PURE__ */ new Map();
|
|
2730
|
+
for (let edge of data.edges) {
|
|
2731
|
+
let route = routed.routes.get(edge.id);
|
|
2732
|
+
if (route) {
|
|
2733
|
+
for (let zone of geometry.zones)
|
|
2734
|
+
if (!(zone.policy || !channelled.has(edge.id) && !groupById.get(zone.id).protected))
|
|
2735
|
+
for (let hit of frameHits(route.points, zone.bounds)) marked.set(`${hit.x}:${hit.y}`, hit);
|
|
2736
|
+
}
|
|
2737
|
+
}
|
|
2738
|
+
[...marked.keys()].sort().forEach((key, index) => {
|
|
2739
|
+
let hit = marked.get(key);
|
|
2740
|
+
overlay.push({ t: "circle", id: diagramSceneId("boundary", String(index)), cx: hit.x, cy: hit.y, r: 2.5, fill: { token: "background" }, stroke: { token: "axis" }, strokeWidth: hair, owner: {}, part: "diagramJunction" });
|
|
2741
|
+
});
|
|
2742
|
+
let disc = discSize(env), discs = data.callouts.map((callout, index) => {
|
|
2743
|
+
let target = callout.target, seat = (point) => qRect({ x: point.x - disc / 2, y: point.y - disc / 2, w: disc, h: disc }), text = String(index + 1);
|
|
2744
|
+
if ("nodeId" in target) {
|
|
2745
|
+
let front = fronts.get(target.nodeId), node = data.nodes.find((item) => item.id === target.nodeId), inset = (node.protected || node.badge ? 6 : 2) * env.u;
|
|
2746
|
+
return { id: callout.id, text, rect: seat({ x: front.x + front.w - inset - disc / 2, y: front.y }), owner: nodeOwner(target.nodeId) };
|
|
2747
|
+
}
|
|
2748
|
+
if ("groupId" in target) {
|
|
2749
|
+
let zone = geometry.zones.find((item) => item.id === target.groupId);
|
|
2750
|
+
return { id: callout.id, text, rect: seat({ x: zone.bounds.x + zone.bounds.w - 3 * env.u, y: zone.bounds.y }), owner: { seriesId: zone.id } };
|
|
2751
|
+
}
|
|
2752
|
+
let label = routed.labels.get(target.edgeId);
|
|
2753
|
+
if (label) return { id: callout.id, text, rect: qRect({ x: label.x + label.w - disc, y: label.y + (label.h - disc) / 2, w: disc, h: disc }), owner: edgeOwner(target.edgeId) };
|
|
2754
|
+
let points = routed.routes.get(target.edgeId).points, longest = [points[0], points[1]], length = ([a, b]) => Math.abs(a.x - b.x) + Math.abs(a.y - b.y);
|
|
2755
|
+
return forSegments(points, (a, b) => {
|
|
2756
|
+
length([a, b]) > length(longest) && (longest = [a, b]);
|
|
2757
|
+
}), { id: callout.id, text, rect: seat({ x: (longest[0].x + longest[1].x) / 2, y: (longest[0].y + longest[1].y) / 2 }), owner: edgeOwner(target.edgeId) };
|
|
2758
|
+
}), lanes = geometry.lanes.map(({ rule, ...lane }) => {
|
|
2759
|
+
if (rule !== void 0) {
|
|
2760
|
+
let y = snap(rule);
|
|
2761
|
+
scene.push({
|
|
2762
|
+
t: "line",
|
|
2763
|
+
id: diagramSceneId("lane", lane.id, "partition"),
|
|
2764
|
+
x1: env.plot.x,
|
|
2765
|
+
y1: y,
|
|
2766
|
+
x2: env.plot.x + env.plot.w,
|
|
2767
|
+
y2: y,
|
|
2768
|
+
stroke: { token: "grid" },
|
|
2769
|
+
width: hair,
|
|
2770
|
+
owner: laneOwner(lane.id),
|
|
2771
|
+
part: "diagramLanePartition"
|
|
2772
|
+
});
|
|
2773
|
+
}
|
|
2774
|
+
return lane;
|
|
2775
|
+
});
|
|
2776
|
+
for (let zone of geometry.zones.filter((item) => item.dashed)) {
|
|
2777
|
+
let { x, y, w, h } = zone.bounds;
|
|
2778
|
+
scene.push({
|
|
2779
|
+
t: "path",
|
|
2780
|
+
id: diagramSceneId("group", zone.id),
|
|
2781
|
+
d: `M${x} ${y}H${x + w}V${y + h}H${x}Z`,
|
|
2782
|
+
fill: zoneFills.get(zone.id) ?? { token: "background" },
|
|
2783
|
+
stroke: { token: "axis" },
|
|
2784
|
+
width: hair,
|
|
2785
|
+
dash: dashToken(theme, "reference"),
|
|
2786
|
+
owner: { seriesId: zone.id },
|
|
2787
|
+
part: "diagramGroup"
|
|
2788
|
+
}), scene.push({ t: "rect", id: diagramSceneId("group", zone.id, "title"), rect: zone.titleBox, fill: { token: "background" }, owner: { seriesId: zone.id }, part: "diagramGroupTitle" });
|
|
2789
|
+
}
|
|
2790
|
+
routed.dots.forEach((dot, index) => {
|
|
2791
|
+
scene.push({ t: "circle", id: diagramSceneId("junction", String(index)), cx: dot.x, cy: dot.y, r: 3, fill: { token: "inkMuted" }, owner: {}, part: "diagramJunction" });
|
|
2792
|
+
});
|
|
2793
|
+
let edges = data.edges.map((edge) => ({ ...edge, arrowEnd: edge.arrowEnd ?? !0 })), unresolved = [...new Set(routed.problems)], warnings = [];
|
|
2794
|
+
if (unresolved.length > 0) {
|
|
2795
|
+
let channel = unresolved.find((id) => id.startsWith("channel:") && !routed.channels.some((item) => `channel:${item.id}` === id));
|
|
2796
|
+
warnings.push(channel && unresolved.length === 1 ? {
|
|
2797
|
+
code: "diagram-channel-mismatch",
|
|
2798
|
+
severity: "error",
|
|
2799
|
+
message: `channel '${channel.slice(8)}' has no gutter that all its edges cross, or no room for its label there`,
|
|
2800
|
+
suggest: "keep its edges between the same two zones, or shorten the label"
|
|
2801
|
+
} : {
|
|
2802
|
+
code: "diagram-route-unresolved",
|
|
2803
|
+
severity: "error",
|
|
2804
|
+
message: `no clean route or label seat for ${unresolved.map((id) => `'${id}'`).join(", ")}`,
|
|
2805
|
+
suggest: "widen the canvas, shorten the edge labels, or split the exhibit"
|
|
2806
|
+
});
|
|
2807
|
+
}
|
|
2808
|
+
let paths = new Map(data.nodes.filter((node) => node.shape.kind === "store").map((node) => [node.id, storePath(fronts.get(node.id), storeCap(node, env.u))])), extent = [...routed.routes.values()].flatMap((route) => [...route.points.map((point) => ({ x: point.x, y: point.y, w: 1, h: 1 })), ...route.labelBox ? [route.labelBox] : []]), bottom = Math.max(...extent.map((rect) => rect.y + rect.h), ...[...geometry.rects.values()].map((rect) => rect.y + rect.h));
|
|
2809
|
+
bottom > env.plot.y + env.plot.h + 1 && warnings.push({ code: "diagram-size-too-small", severity: "error", message: `architecture needs ${Math.ceil(bottom - env.plot.y - env.plot.h)} px more height` });
|
|
2810
|
+
let readingOrder = [...data.nodes.filter((node) => geometry.zones.some((zone) => zone.policy && zone.memberNodeIds.includes(node.id))).map((node) => node.id), ...[...arrangement.cells.values()].sort((a, b) => a.band - b.band || a.c0 - b.c0 || a.r0 - b.r0 || (a.node.id < b.node.id ? -1 : 1)).map((cell) => cell.node.id)], fonts = new Map(data.nodes.map((node) => [node.id, name]));
|
|
2811
|
+
return {
|
|
2812
|
+
mode: "columns",
|
|
2813
|
+
preset: {
|
|
2814
|
+
nodeRects: fronts,
|
|
2815
|
+
readingOrder,
|
|
2816
|
+
edges,
|
|
2817
|
+
syntheticEdgeIds: [],
|
|
2818
|
+
groups: geometry.zones.map(({ id, bounds, titleBox, memberNodeIds }) => ({ id, bounds, titleBox, memberNodeIds })),
|
|
2819
|
+
lanes,
|
|
2820
|
+
decorationScene: scene,
|
|
2821
|
+
decorationClaims: claims,
|
|
2822
|
+
contentTopReserves: /* @__PURE__ */ new Map()
|
|
2823
|
+
},
|
|
2824
|
+
routes: routed.routes,
|
|
2825
|
+
fonts,
|
|
2826
|
+
labelBoxes: geometry.textBoxes,
|
|
2827
|
+
icons: geometry.icons,
|
|
2828
|
+
rings,
|
|
2829
|
+
fills,
|
|
2830
|
+
plainShape: !0,
|
|
2831
|
+
paths,
|
|
2832
|
+
overlay,
|
|
2833
|
+
discs,
|
|
2834
|
+
badges: geometry.badges,
|
|
2835
|
+
labelInks: new Map(data.nodes.filter((node) => node.secondaryLabel).map((node) => [`secondary-label:${node.id}`, groundTextPaint({ token: "inkMuted" }, fills.get(node.id))])),
|
|
2836
|
+
laneFills: new Map(data.lanes.map((lane) => [lane.id, { token: "background" }])),
|
|
2837
|
+
extent,
|
|
2838
|
+
edgePaint: { token: "inkMuted" },
|
|
2839
|
+
secondaryFont: env.text,
|
|
2840
|
+
groupPaint: {
|
|
2841
|
+
fill: { token: "total", tint: ZONE_TINT },
|
|
2842
|
+
stroke: { token: "axis" },
|
|
2843
|
+
fills: zoneFills,
|
|
2844
|
+
dashed: new Set(geometry.zones.filter((zone) => zone.dashed).map((zone) => zone.id))
|
|
2845
|
+
},
|
|
2846
|
+
warnings,
|
|
2847
|
+
channelLabels: routed.channels.map((channel) => ({ id: `channel-label:${channel.id}`, text: channel.label, rect: channel.rect, owner: edgeOwner(channel.edgeId), font: env.text }))
|
|
2848
|
+
};
|
|
2849
|
+
}
|
|
2850
|
+
|
|
1490
2851
|
// src/core/charts/diagram/journeyCompact.ts
|
|
1491
2852
|
function journeyEligible(data, options) {
|
|
1492
|
-
return options.variant !== "customer-journey" ||
|
|
2853
|
+
return options.variant !== "customer-journey" || data.edges.length > 0 || data.groups.length > 0 || data.lanes.length === 0 || data.lanes.length > 8 ? !1 : data.nodes.every((node) => node.kind === "painPoint" && node.laneId && !node.position && !node.ports?.length && !node.size && !node.minSize && !node.caption && !node.badge && !node.secondaryLabel && !node.label.includes(`
|
|
1493
2854
|
`) && (node.shape.kind === "roundedRect" || node.shape.kind === "rectangle"));
|
|
1494
2855
|
}
|
|
1495
2856
|
var judged = (node) => node.role === "bad" || node.role === "warn" || node.role === "good";
|
|
1496
|
-
function layoutJourneyCompact(data, options, plot, labelFont, headerFont, measure, u, palette, headWeight) {
|
|
2857
|
+
function layoutJourneyCompact(data, options, plot, labelFont, headerFont, measure, u, palette, headWeight, fixedHeight = !1) {
|
|
1497
2858
|
let lanes = data.lanes, members = new Map(lanes.map((lane) => [lane.id, data.nodes.filter((node) => node.laneId === lane.id).sort(byOrder)])), card = { ...labelFont, size: labelFont.size > 13 ? labelFont.size - 1 : labelFont.size }, bold = { ...card, weight: headWeight }, fonts = new Map(data.nodes.map((node) => [node.id, judged(node) ? bold : card])), lineH = card.size * (card.lineHeight ?? 1.2), pad = 2 * u, padRight = 1.2 * u, icon = 2.6 * u, lead = (node) => node.icon ? 5.2 * u : pad, linesIn = (node, width) => wrapText(node.label, fonts.get(node.id), Math.max(1, width - lead(node) - padRight), 3, measure), fits = (node, width, maxLines) => {
|
|
1498
2859
|
let wrapped = linesIn(node, width);
|
|
1499
2860
|
return !wrapped.truncated && wrapped.lines.length <= maxLines;
|
|
@@ -1511,22 +2872,27 @@ function layoutJourneyCompact(data, options, plot, labelFont, headerFont, measur
|
|
|
1511
2872
|
contentTopReserves: /* @__PURE__ */ new Map()
|
|
1512
2873
|
}, header = (laneId, d, box, fill) => {
|
|
1513
2874
|
result.decorationScene.push({ t: "path", id: diagramSceneId("lane", laneId, "header"), d, fill, owner: laneOwner(laneId), part: "diagramLaneHeader" }), result.decorationClaims.push({ rect: box, owner: laneOwner(laneId), part: "diagramLaneHeader" });
|
|
1514
|
-
}, mode, gap = 1.6 * u, pitch = (plot.w + gap) /
|
|
1515
|
-
if (lanes.every((lane) => headerText(lane
|
|
2875
|
+
}, mode, serpentine = options.variant === "customer-journey" && options.flow === "serpentine" && lanes.length > 1, rowCount = serpentine ? 2 : 1, perRow = Math.ceil(lanes.length / rowCount), phaseLabel = (lane, index) => serpentine && lane.label ? `${index + 1} ${lane.label}` : lane.label, gap = 1.6 * u, pitch = (plot.w + gap) / perRow, boxW = pitch - gap, tip = Math.min(1.6 * u, boxW / 6);
|
|
2876
|
+
if (lanes.every((lane, index) => headerText(phaseLabel(lane, index)) <= boxW - 2 * tip - u) && data.nodes.every((node) => fits(node, boxW, 2))) {
|
|
1516
2877
|
mode = "columns";
|
|
1517
|
-
let headerH = 6 * u,
|
|
1518
|
-
let
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
2878
|
+
let headerH = 6 * u, bands = Array.from({ length: rowCount }, (_, row) => {
|
|
2879
|
+
let rowLanes = lanes.slice(row * perRow, (row + 1) * perRow), rows = Math.max(0, maxOf(rowLanes.map((lane) => members.get(lane.id).length))), rowHeights = Array.from({ length: rows }, (_2, cardRow) => Math.max(0, maxOf(rowLanes.map((lane) => {
|
|
2880
|
+
let node = members.get(lane.id)[cardRow];
|
|
2881
|
+
return node ? cardH(linesIn(node, boxW).lines.length) : 0;
|
|
2882
|
+
})))), gapSum2 = (rows > 0 ? 2 * u : 0) + Math.max(0, rows - 1) * 1.2 * u;
|
|
2883
|
+
return { rows, rowHeights, gapSum: gapSum2, bodies: headerH + rowHeights.reduce((sum, value) => sum + value, 0) };
|
|
2884
|
+
}), breakGap = 3 * u * (rowCount - 1), gapSum = bands.reduce((sum, band) => sum + band.gapSum, 0) + breakGap, bodies = bands.reduce((sum, band) => sum + band.bodies, 0), spread = gapSpread(fixedHeight, plot.h, bodies + gapSum, gapSum), headGap = 2 * u * spread, rowGap = 1.2 * u * spread, height = bodies + gapSum * spread, top = plot.y + Math.max(0, (plot.h - height) / 2);
|
|
2885
|
+
bands.forEach((band, row) => {
|
|
2886
|
+
lanes.slice(row * perRow, (row + 1) * perRow).forEach((lane, local) => {
|
|
2887
|
+
let index = row * perRow + local, x = plot.x + (row % 2 === 1 ? perRow - local - 1 : local) * pitch, box = qRect({ x, y: top, w: boxW, h: headerH }), y = top + headerH + headGap;
|
|
2888
|
+
members.get(lane.id).forEach((node, cardRow) => {
|
|
2889
|
+
put(node.id, { x, y, w: boxW, h: band.rowHeights[cardRow] }), y += band.rowHeights[cardRow] + rowGap;
|
|
2890
|
+
});
|
|
2891
|
+
let bottom = Math.max(box.y + box.h, maxOf(members.get(lane.id).map((node) => rects.get(node.id).y + rects.get(node.id).h)));
|
|
2892
|
+
result.lanes.push({ id: lane.id, bounds: qRect({ x, y: top, w: boxW, h: bottom - top }), headerBox: box, memberNodeIds: members.get(lane.id).map((node) => node.id) });
|
|
2893
|
+
let d = index === 0 ? `M${q(box.x)} ${q(box.y)}L${q(box.x + box.w - tip)} ${q(box.y)}L${q(box.x + box.w)} ${q(box.y + box.h / 2)}L${q(box.x + box.w - tip)} ${q(box.y + box.h)}L${q(box.x)} ${q(box.y + box.h)}Z` : chevronPath(box, tip, row % 2 === 1);
|
|
2894
|
+
header(lane.id, d, box, palette.lane(lane.role, lane.paletteKey));
|
|
2895
|
+
}), top += band.bodies + (band.rows > 0 ? headGap : 0) + Math.max(0, band.rows - 1) * rowGap + breakGap * spread;
|
|
1530
2896
|
});
|
|
1531
2897
|
}
|
|
1532
2898
|
if (!mode && options.variant === "customer-journey" && options.flow === void 0) {
|
|
@@ -1543,10 +2909,10 @@ function layoutJourneyCompact(data, options, plot, labelFont, headerFont, measur
|
|
|
1543
2909
|
cards.slice(row * 2, row * 2 + 2).forEach((node, column) => out.push([node.id, { x: left + column * (cardW + cardGap), y: cardY, w: cardW, h: rowH }])), cardY += rowH + cardGap;
|
|
1544
2910
|
}), placed.push({ lane: lane.id, box: { x: plot.x, y, w: chevronW, h: bodyH }, cards: out }), y += bodyH + u;
|
|
1545
2911
|
});
|
|
1546
|
-
let
|
|
2912
|
+
let natural = y - u + tipH, extra = (gapSpread(fixedHeight, plot.h, natural, (placed.length - 1) * u) - 1) * u, height = natural + (placed.length - 1) * extra, top = plot.y + Math.max(0, (plot.h - height) / 2);
|
|
1547
2913
|
placed.forEach(({ lane: laneId, box: raw, cards }, index) => {
|
|
1548
|
-
let box = qRect({ ...raw, y: raw.y +
|
|
1549
|
-
for (let [id, rect] of cards) put(id, { ...rect, y: rect.y +
|
|
2914
|
+
let shift = top + index * extra, box = qRect({ ...raw, y: raw.y + shift });
|
|
2915
|
+
for (let [id, rect] of cards) put(id, { ...rect, y: rect.y + shift });
|
|
1550
2916
|
let lane = lanes.find((candidate) => candidate.id === laneId), mid = box.x + box.w / 2, d = `M${q(box.x)} ${q(box.y)}` + (index > 0 ? `L${q(mid)} ${q(box.y + tipH)}` : "") + `L${q(box.x + box.w)} ${q(box.y)}L${q(box.x + box.w)} ${q(box.y + box.h)}L${q(mid)} ${q(box.y + box.h + tipH)}L${q(box.x)} ${q(box.y + box.h)}Z`, label = qRect({ x: box.x, y: box.y + (index > 0 ? tipH : 0), w: box.w, h: box.h - (index > 0 ? tipH : 0) }), memberIds = members.get(laneId).map((node) => node.id), bottom = Math.max(box.y + box.h + tipH, maxOf(memberIds.map((id) => rects.get(id).y + rects.get(id).h)));
|
|
1551
2917
|
result.lanes.push({ id: laneId, bounds: qRect({ x: plot.x, y: box.y, w: plot.w, h: bottom - box.y }), headerBox: label, memberNodeIds: memberIds }), header(laneId, d, { ...box, h: box.h + tipH }, palette.lane(lane.role, lane.paletteKey));
|
|
1552
2918
|
});
|
|
@@ -1566,7 +2932,7 @@ function linearEligible(data, options) {
|
|
|
1566
2932
|
return options.variant !== "linear-process" || data.edges.length > 0 || data.groups.length > 0 || data.lanes.length > 0 || data.nodes.length === 0 ? !1 : data.nodes.every((node) => node.kind === "step" && node.shape.kind === "chevron" && !node.position && !node.ports?.length && !node.size && !node.minSize && !node.badge && !node.secondaryLabel && !node.label.includes(`
|
|
1567
2933
|
`));
|
|
1568
2934
|
}
|
|
1569
|
-
function layoutLinearCompact(data, plot, nameFont, badgeFont, captionFont, measure, u, badgeText, headerGap = 0) {
|
|
2935
|
+
function layoutLinearCompact(data, plot, nameFont, badgeFont, captionFont, measure, u, badgeText, headerGap = 0, fixedHeight = !1) {
|
|
1570
2936
|
let steps = [...data.nodes].sort(byOrder), n = steps.length, size = nameFont.size, lineH = size * (nameFont.lineHeight ?? 1.2), captionLineH = captionFont.size * (captionFont.lineHeight ?? 1.2), nameW = (node) => measure(node.label, nameFont).width, disc = q(Math.max(20, badgeFont.size * 1.5, maxOf(steps.map((node) => measure(badgeText(node), badgeFont).width + 2 * u)))), discGap = 1.5 * u, icons = steps.some((node) => node.icon), rects = /* @__PURE__ */ new Map(), labelBoxes = /* @__PURE__ */ new Map(), iconBoxes = /* @__PURE__ */ new Map(), badges = /* @__PURE__ */ new Map(), paths = /* @__PURE__ */ new Map(), captionBoxes = /* @__PURE__ */ new Map(), extent = [], fonts = new Map(steps.map((node) => [node.id, nameFont])), result = {
|
|
1571
2937
|
nodeRects: rects,
|
|
1572
2938
|
readingOrder: steps.map((node) => node.id),
|
|
@@ -1602,7 +2968,7 @@ function layoutLinearCompact(data, plot, nameFont, badgeFont, captionFont, measu
|
|
|
1602
2968
|
});
|
|
1603
2969
|
}
|
|
1604
2970
|
if (!mode) {
|
|
1605
|
-
let
|
|
2971
|
+
let point = q(2 * u), stackGap = 1.5 * u, airy = Math.max(2.6 * size, lineH + 2 * u, disc + 2 * u), bandH = q(Math.max(lineH + 1.2 * u, disc + 1.2 * u, fixedHeight ? Math.min(airy, (plot.h - point - (n - 1) * stackGap) / n) : airy)), icon = q(Math.min(22, bandH - 2 * u)), lead = 2 * u + disc + discGap, tail = icons ? 2 * u + icon + 2 * u : 2 * u, need = Math.ceil(lead + maxOf(steps.map(nameW)) + tail), captionGap = 3 * u, widestCaption = Math.max(0, maxOf(steps.map((node) => node.caption ? measure(node.caption, captionFont).width : 0))), room = plot.w - (widestCaption > 0 ? captionGap + widestCaption : 0), bandW = Math.floor(Math.max(need, Math.min(75 * u, Math.round(0.65 * plot.w), room))), captionW = plot.w - bandW - captionGap;
|
|
1606
2972
|
if (bandW > plot.w || steps.some((node) => captionLines(node, captionW)?.truncated)) return;
|
|
1607
2973
|
let rowPitch = Math.max(bandH + stackGap, maxOf(steps.map((node) => (captionLines(node, captionW)?.lines.length ?? 0) * captionLineH + stackGap))), height = (n - 1) * rowPitch + bandH + point, top = plot.y + Math.max(0, (plot.h - height) / 2);
|
|
1608
2974
|
steps.forEach((node, index) => {
|
|
@@ -1776,12 +3142,10 @@ function routeDiagramEdges(theme, input) {
|
|
|
1776
3142
|
for (let edge of [...input.edges].sort((a, b) => compareText(a.id, b.id))) {
|
|
1777
3143
|
let sourceNode = nodeById.get(edge.source.nodeId), targetNode = nodeById.get(edge.target.nodeId), sourceRect = input.nodeRects.get(sourceNode.id), targetRect = input.nodeRects.get(targetNode.id), sourceCandidates = endpointCandidates(sourceNode, sourceRect, edge.source.portId, "source", used), targetCandidates = endpointCandidates(targetNode, targetRect, edge.target.portId, "target", used), requested = edge.routing ?? "orthogonal", fixed = input.fixedRoutes?.get(edge.id);
|
|
1778
3144
|
if (fixed) {
|
|
1779
|
-
let points2 = fixed.points, start = points2[0], end = points2.at(-1),
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
!0
|
|
1784
|
-
), targetPort = resolvePort(targetNode.id, targetRect, fixed.targetSide === "top" ? { id: "auto:org-in", at: { side: "top", offset: (end.x - targetRect.x) / targetRect.w }, intent: "in" } : { id: "auto:org-in", at: { side: "left", offset: (end.y - targetRect.y) / targetRect.h }, intent: "in" }, !0), edgeResult2 = {
|
|
3145
|
+
let points2 = fixed.points, start = points2[0], end = points2.at(-1), at = (side, point, rect) => ({
|
|
3146
|
+
side,
|
|
3147
|
+
offset: side === "left" || side === "right" ? (point.y - rect.y) / rect.h : (point.x - rect.x) / rect.w
|
|
3148
|
+
}), sourcePort = resolvePort(sourceNode.id, sourceRect, { id: "auto:org-out", at: at(fixed.sourceSide ?? "bottom", start, sourceRect), intent: "out" }, !0), targetPort = resolvePort(targetNode.id, targetRect, { id: "auto:org-in", at: at(fixed.targetSide, end, targetRect), intent: "in" }, !0), edgeResult2 = {
|
|
1785
3149
|
id: edge.id,
|
|
1786
3150
|
source: endpoint({ ...sourcePort, point: start }, points2[1] ?? end, input.clearance),
|
|
1787
3151
|
target: endpoint({ ...targetPort, point: end }, points2.at(-2) ?? start, input.clearance),
|
|
@@ -1795,9 +3159,10 @@ function routeDiagramEdges(theme, input) {
|
|
|
1795
3159
|
},
|
|
1796
3160
|
bends: countBends(points2),
|
|
1797
3161
|
crossings: 0,
|
|
1798
|
-
sceneNodeIds: []
|
|
3162
|
+
sceneNodeIds: [],
|
|
3163
|
+
...fixed.labelBox ? { labelBox: fixed.labelBox } : {}
|
|
1799
3164
|
};
|
|
1800
|
-
edgeResult2.sceneNodeIds = emitRouteScene(theme, edge, edgeResult2, scene, claims, input.clearance, warnings, input.palette, input.edgePaint), resolved.push(edgeResult2), recordPorts({ ...sourcePort, point: start }, { ...targetPort, point: end }, portsByNode, used);
|
|
3165
|
+
fixed.labelBox && labelBoxes.set(edge.id, fixed.labelBox), edgeResult2.sceneNodeIds = emitRouteScene(theme, edge, edgeResult2, scene, claims, input.clearance, warnings, input.palette, input.edgePaint, input.preset === "circular-process"), resolved.push(edgeResult2), recordPorts({ ...sourcePort, point: start }, { ...targetPort, point: end }, portsByNode, used);
|
|
1801
3166
|
continue;
|
|
1802
3167
|
}
|
|
1803
3168
|
if (input.preset === "circular-process" && requested === "curved") {
|
|
@@ -1819,7 +3184,8 @@ function routeDiagramEdges(theme, input) {
|
|
|
1819
3184
|
input.clearance,
|
|
1820
3185
|
warnings,
|
|
1821
3186
|
input.palette,
|
|
1822
|
-
input.edgePaint
|
|
3187
|
+
input.edgePaint,
|
|
3188
|
+
!0
|
|
1823
3189
|
);
|
|
1824
3190
|
resolved.push({ ...circular, sceneNodeIds: arrowIds }), recordPorts(sourceCandidates[0].port, targetCandidates[0].port, portsByNode, used);
|
|
1825
3191
|
continue;
|
|
@@ -1930,7 +3296,7 @@ function routeDiagramEdges(theme, input) {
|
|
|
1930
3296
|
crossings: countCrossings(points, acceptedSegments),
|
|
1931
3297
|
sceneNodeIds: []
|
|
1932
3298
|
}, labelSize = edge.label ? input.labelSizes.get(edge.id) : void 0;
|
|
1933
|
-
if (edge.label && labelSize) {
|
|
3299
|
+
if (edge.label && labelSize && input.preset !== "circular-process") {
|
|
1934
3300
|
let labelBox = chooseEdgeLabelBox(points, labelSize, hard, reserved, input.plot, input.clearance);
|
|
1935
3301
|
labelBox ? (edgeResult.labelBox = labelBox, labelBoxes.set(edge.id, labelBox), reserved.push(labelBox)) : warnings.push({
|
|
1936
3302
|
code: "diagram-edge-label-unplaced",
|
|
@@ -1947,11 +3313,34 @@ function routeDiagramEdges(theme, input) {
|
|
|
1947
3313
|
claims,
|
|
1948
3314
|
input.clearance,
|
|
1949
3315
|
warnings,
|
|
1950
|
-
input.palette
|
|
3316
|
+
input.palette,
|
|
3317
|
+
void 0,
|
|
3318
|
+
input.preset === "circular-process"
|
|
1951
3319
|
), resolved.push(edgeResult), edgeResult.route.kind === "polyline" && edgeResult.route.segments.forEach(
|
|
1952
3320
|
(segment) => acceptedSegments.push({ edgeId: edge.id, from: segment.from, to: segment.to })
|
|
1953
3321
|
), recordPorts(best.source.port, best.target.port, portsByNode, used);
|
|
1954
3322
|
}
|
|
3323
|
+
if (input.preset === "circular-process") {
|
|
3324
|
+
let hard = [...input.nodeRects.values(), ...input.reserved, ...claims.map((claim) => claim.rect)].map((rect) => inflate(rect, input.clearance));
|
|
3325
|
+
for (let edge of resolved) {
|
|
3326
|
+
let size = input.labelSizes.get(edge.id);
|
|
3327
|
+
if (!size) continue;
|
|
3328
|
+
let points = edge.route.kind === "polyline" ? edge.route.points : sampleQuadratic(edge.route.controlPoints);
|
|
3329
|
+
for (let candidate of [size, ...size.wrapped ?? []]) {
|
|
3330
|
+
let box = chooseEdgeLabelBox(points, candidate, hard, reserved, input.plot, 2 * input.clearance, !0);
|
|
3331
|
+
if (box) {
|
|
3332
|
+
edge.labelBox = box, labelBoxes.set(edge.id, box), reserved.push(inflate(box, input.clearance));
|
|
3333
|
+
break;
|
|
3334
|
+
}
|
|
3335
|
+
}
|
|
3336
|
+
edge.labelBox || warnings.push({
|
|
3337
|
+
code: "diagram-edge-label-unplaced",
|
|
3338
|
+
severity: "warn",
|
|
3339
|
+
message: `edge label '${input.edges.find((candidate) => candidate.id === edge.id).label}' on '${edge.id}' has no collision-free candidate`,
|
|
3340
|
+
owner: edgeOwner(edge.id)
|
|
3341
|
+
});
|
|
3342
|
+
}
|
|
3343
|
+
}
|
|
1955
3344
|
for (let ports of portsByNode.values())
|
|
1956
3345
|
ports.forEach((port) => {
|
|
1957
3346
|
port.used = used.get(portKey(port)) ?? 0;
|
|
@@ -2200,7 +3589,7 @@ function circularRoute(edge, source, target, sourceRect, targetRect, plot, clear
|
|
|
2200
3589
|
sceneNodeIds: []
|
|
2201
3590
|
};
|
|
2202
3591
|
}
|
|
2203
|
-
function emitRouteScene(theme, edge, resolved, scene, claims, clearance, warnings, palette, plainPaint = { token: "leader" }) {
|
|
3592
|
+
function emitRouteScene(theme, edge, resolved, scene, claims, clearance, warnings, palette, plainPaint = { token: "leader" }, claimArrowheads = !1) {
|
|
2204
3593
|
let ids = [], shaftId = diagramSceneId("edge", edge.id), width = strokeWidth(theme, edge), dash = edgeDash(theme, edge.dash), paint = edge.role === void 0 || edge.role === "secondary" || edge.role === "muted" ? plainPaint : palette.paint(edge.role, edge.paletteKey);
|
|
2205
3594
|
if (resolved.route.kind === "path" ? (scene.push({
|
|
2206
3595
|
t: "path",
|
|
@@ -2232,7 +3621,7 @@ function emitRouteScene(theme, edge, resolved, scene, claims, clearance, warning
|
|
|
2232
3621
|
}), resolved.route.segments.forEach(
|
|
2233
3622
|
(segment) => claims.push({ rect: segmentBounds(segment.from, segment.to, width), edgeId: edge.id, part: "diagramEdge" })
|
|
2234
3623
|
)), ids.push(shaftId), edge.arrowEnd) {
|
|
2235
|
-
let arrow = arrowScene(edge, resolved, !1, clearance, paint);
|
|
3624
|
+
let arrow = arrowScene(edge, resolved, !1, clearance, paint, claimArrowheads ? claims : void 0);
|
|
2236
3625
|
arrow ? (scene.push(arrow), ids.push(arrow.id)) : warnings.push({
|
|
2237
3626
|
code: "diagram-arrowhead-unplaced",
|
|
2238
3627
|
severity: "warn",
|
|
@@ -2241,7 +3630,7 @@ function emitRouteScene(theme, edge, resolved, scene, claims, clearance, warning
|
|
|
2241
3630
|
});
|
|
2242
3631
|
}
|
|
2243
3632
|
if (edge.arrowStart) {
|
|
2244
|
-
let arrow = arrowScene(edge, resolved, !0, clearance, paint);
|
|
3633
|
+
let arrow = arrowScene(edge, resolved, !0, clearance, paint, claimArrowheads ? claims : void 0);
|
|
2245
3634
|
arrow ? (scene.push(arrow), ids.push(arrow.id)) : warnings.push({
|
|
2246
3635
|
code: "diagram-arrowhead-unplaced",
|
|
2247
3636
|
severity: "warn",
|
|
@@ -2262,13 +3651,17 @@ function sampleQuadratic(controlPoints) {
|
|
|
2262
3651
|
});
|
|
2263
3652
|
});
|
|
2264
3653
|
}
|
|
2265
|
-
function arrowScene(edge, resolved, atStart, clearance, fill) {
|
|
3654
|
+
function arrowScene(edge, resolved, atStart, clearance, fill, claims) {
|
|
2266
3655
|
let points = resolved.route.kind === "polyline" ? resolved.route.points : resolved.route.controlPoints;
|
|
2267
3656
|
if (points.length < 2) return;
|
|
2268
3657
|
let tip = atStart ? points[0] : points[points.length - 1], previous = atStart ? points[1] : points[points.length - 2], dx = tip.x - previous.x, dy = tip.y - previous.y, length = Math.hypot(dx, dy);
|
|
2269
3658
|
if (length < 3 * clearance) return;
|
|
2270
3659
|
let arrowLength = 3 * clearance, arrowWidth = 2 * clearance, ux = dx / length, uy = dy / length, bx = tip.x - ux * arrowLength, by = tip.y - uy * arrowLength, px = -uy * arrowWidth / 2, py = ux * arrowWidth / 2;
|
|
2271
|
-
return {
|
|
3660
|
+
return claims?.push({
|
|
3661
|
+
rect: boundsOf([tip, { x: bx + px, y: by + py }, { x: bx - px, y: by - py }].map((point) => ({ ...qPoint(point), w: 0, h: 0 }))),
|
|
3662
|
+
edgeId: edge.id,
|
|
3663
|
+
part: "diagramArrow"
|
|
3664
|
+
}), {
|
|
2272
3665
|
t: "path",
|
|
2273
3666
|
id: diagramSceneId("arrow", edge.id, atStart ? "start" : "end"),
|
|
2274
3667
|
d: `M${q(tip.x)} ${q(tip.y)}L${q(bx + px)} ${q(by + py)}L${q(bx - px)} ${q(by - py)}Z`,
|
|
@@ -2277,7 +3670,8 @@ function arrowScene(edge, resolved, atStart, clearance, fill) {
|
|
|
2277
3670
|
part: "diagramArrow"
|
|
2278
3671
|
};
|
|
2279
3672
|
}
|
|
2280
|
-
function chooseEdgeLabelBox(points, size, hard, reserved, plot, clearance) {
|
|
3673
|
+
function chooseEdgeLabelBox(points, size, hard, reserved, plot, clearance, extraSeats = !1) {
|
|
3674
|
+
extraSeats && (size = { width: Math.ceil(size.width * 2) / 2, height: Math.ceil(size.height * 2) / 2 });
|
|
2281
3675
|
let segments = points.slice(0, -1).map((from, index) => ({ from, to: points[index + 1] })).sort(
|
|
2282
3676
|
(a, b) => Math.hypot(b.to.x - b.from.x, b.to.y - b.from.y) - Math.hypot(a.to.x - a.from.x, a.to.y - a.from.y)
|
|
2283
3677
|
);
|
|
@@ -2285,10 +3679,23 @@ function chooseEdgeLabelBox(points, size, hard, reserved, plot, clearance) {
|
|
|
2285
3679
|
let centre = {
|
|
2286
3680
|
x: (segment.from.x + segment.to.x) / 2,
|
|
2287
3681
|
y: (segment.from.y + segment.to.y) / 2
|
|
2288
|
-
},
|
|
3682
|
+
}, candidates = [
|
|
2289
3683
|
{ x: centre.x - size.width / 2, y: centre.y - size.height - clearance, w: size.width, h: size.height },
|
|
2290
3684
|
{ x: centre.x - size.width / 2, y: centre.y + clearance, w: size.width, h: size.height }
|
|
2291
|
-
]
|
|
3685
|
+
];
|
|
3686
|
+
if (extraSeats) {
|
|
3687
|
+
let dx = segment.to.x - segment.from.x, dy = segment.to.y - segment.from.y, length = Math.hypot(dx, dy);
|
|
3688
|
+
if (length === 0) continue;
|
|
3689
|
+
let nx = -dy / length, ny = dx / length, offset = Math.abs(nx) * size.width / 2 + Math.abs(ny) * size.height / 2 + clearance;
|
|
3690
|
+
for (let t of [0.5, 0.25, 0.75]) for (let side of [-1, 1])
|
|
3691
|
+
candidates.push({
|
|
3692
|
+
x: segment.from.x + t * dx + side * nx * offset - size.width / 2,
|
|
3693
|
+
y: segment.from.y + t * dy + side * ny * offset - size.height / 2,
|
|
3694
|
+
w: size.width,
|
|
3695
|
+
h: size.height
|
|
3696
|
+
});
|
|
3697
|
+
}
|
|
3698
|
+
let accepted = candidates.map((rect) => ({ x: q(rect.x), y: q(rect.y), w: q(rect.w), h: q(rect.h) })).find(
|
|
2292
3699
|
(rect) => rect.x >= plot.x && rect.y >= plot.y && rect.x + rect.w <= plot.x + plot.w && rect.y + rect.h <= plot.y + plot.h && ![...hard, ...reserved].some((obstacle) => rectsOverlapOpen(rect, obstacle))
|
|
2293
3700
|
);
|
|
2294
3701
|
if (accepted) return accepted;
|
|
@@ -2416,7 +3823,8 @@ var pointKey = (point) => `${q(point.x)},${q(point.y)}`, uniqueSorted = (values)
|
|
|
2416
3823
|
// src/core/charts/diagram/layout.ts
|
|
2417
3824
|
var DIAGRAM_MIN_WIDTH = 480, NARROW_PRESETS = /* @__PURE__ */ new Set(["circular-process", "strategy-house"]);
|
|
2418
3825
|
function layoutDiagram(rawData, rawOptions, measureMinimum = !0) {
|
|
2419
|
-
|
|
3826
|
+
let planned = rawOptions?.variant === "architecture" && !(ARCHITECTURE_PLANS in rawOptions);
|
|
3827
|
+
return layoutDiagramPass(rawData, planned ? { ...rawOptions, [ARCHITECTURE_PLANS]: /* @__PURE__ */ new Map() } : rawOptions, measureMinimum);
|
|
2420
3828
|
}
|
|
2421
3829
|
function layoutDiagramPass(rawData, rawOptions, measureMinimum, fitOnly = !1) {
|
|
2422
3830
|
if (!rawOptions?.variant)
|
|
@@ -2440,16 +3848,18 @@ function layoutDiagramPass(rawData, rawOptions, measureMinimum, fitOnly = !1) {
|
|
|
2440
3848
|
message: `nodes filled in the ${unkeyed.join(", ")} tone read by convention; name it in data.key when the tone means something else`,
|
|
2441
3849
|
suggest: `name it in data.key, for example { role: '${unkeyed[0]}', label: '\u2026' }`
|
|
2442
3850
|
});
|
|
2443
|
-
let
|
|
2444
|
-
|
|
2445
|
-
label:
|
|
2446
|
-
|
|
2447
|
-
paint:
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
3851
|
+
let calloutItems = data.callouts.flatMap((callout, index) => {
|
|
3852
|
+
let label = [callout.title, callout.text].filter(Boolean).join(": ");
|
|
3853
|
+
return label ? [{ id: `callout:${index}`, label, paint: { token: "ink" }, key: "glyph", glyph: String(index + 1) }] : [];
|
|
3854
|
+
}), keyItems = [...data.key.map((entry, index) => {
|
|
3855
|
+
if (entry.line !== void 0) return { id: `key:${index}`, label: entry.label, paint: { token: "leader" }, key: "line", width: strokeToken(theme, "rule"), ...entry.line === "solid" ? {} : { dash: edgeDash(theme, entry.line), lineCap: entry.line === "dotted" ? "round" : "butt" } };
|
|
3856
|
+
let node = data.nodes.find((item) => item.role === entry.role && item.paletteKey === entry.paletteKey) ?? { id: `key:${index}`, kind: "step", label: entry.label, shape: { kind: "rectangle" }, role: entry.role, paletteKey: entry.paletteKey };
|
|
3857
|
+
if (options.variant === "architecture") {
|
|
3858
|
+
let { fill, ring } = architectureFill(node, data.lanes, diagramPalette);
|
|
3859
|
+
return { id: `key:${index}`, label: entry.label, ...ring && "token" in fill && fill.token === "background" ? { paint: { token: ring }, hollow: !0 } : { paint: fill } };
|
|
3860
|
+
}
|
|
3861
|
+
return { id: `key:${index}`, label: entry.label, paint: nodeFillPaint(node, diagramPalette, theme) };
|
|
3862
|
+
}), ...calloutItems], occupied = createOccupiedIndex({ x: 0, y: 0, w: size.width, h: size.height }), frame = solveFrame(
|
|
2453
3863
|
{
|
|
2454
3864
|
size,
|
|
2455
3865
|
margin: { ...canvasMargin(theme, size.width), ...options.margin },
|
|
@@ -2460,7 +3870,7 @@ function layoutDiagramPass(rawData, rawOptions, measureMinimum, fitOnly = !1) {
|
|
|
2460
3870
|
measure
|
|
2461
3871
|
},
|
|
2462
3872
|
occupied
|
|
2463
|
-
), plot = frame.plot, labelFont = { family: theme.type.family, ...theme.type.label }, axisFont = { family: theme.type.family, ...theme.type.axis }, stepFont = { ...labelFont, weight: emphasisWeight(theme) }, headFont = { ...labelFont, weight: headingWeight(theme) }, badgeFont = options.variant === "linear-process" ? { ...labelFont, weight: emphasisWeight(theme) } : labelFont, laneFont = options.variant === "roadmap" ? { ...axisFont, weight: headingWeight(theme) } : axisFont, nodeFontById = (id) => {
|
|
3873
|
+
), plot = frame.plot, labelFont = { family: theme.type.family, ...theme.type.label }, axisFont = { family: theme.type.family, ...theme.type.axis }, stepFont = { ...labelFont, weight: emphasisWeight(theme) }, headFont = { ...labelFont, weight: headingWeight(theme) }, badgeFont = options.variant === "linear-process" ? { ...labelFont, weight: emphasisWeight(theme) } : labelFont, laneFont = options.variant === "roadmap" || options.variant === "architecture" ? { ...axisFont, weight: headingWeight(theme) } : axisFont, nodeFontById = (id) => {
|
|
2464
3874
|
let node = data.nodes.find((candidate) => candidate.id === id);
|
|
2465
3875
|
return node ? presetFont(node) : void 0;
|
|
2466
3876
|
}, presetFont = (node) => options.variant === "linear-process" && node.kind === "step" ? stepFont : options.variant === "strategy-house" && (node.kind === "vision" || node.kind === "objective" || node.kind === "foundation") ? headFont : void 0, captionFont = options.variant === "linear-process" ? axisFont : labelFont, lineHeight = labelFont.size * (labelFont.lineHeight ?? 1.2), externalLabels = options.variant === "circular-process" || options.variant === "roadmap", pills = new Map(data.nodes.filter((node) => node.badge && node.badge.text.length > 3).map((node) => {
|
|
@@ -2491,7 +3901,18 @@ function layoutDiagramPass(rawData, rawOptions, measureMinimum, fitOnly = !1) {
|
|
|
2491
3901
|
font: labelFont,
|
|
2492
3902
|
titleFont: axisFont,
|
|
2493
3903
|
headFont
|
|
2494
|
-
},
|
|
3904
|
+
}, fixedHeight = rawOptions[TARGET_SIZE]?.fixed.height ?? (typeof rawOptions.size == "object" && rawOptions.size.height !== void 0), spreadGaps = options.heightFill !== "none", org = architectureEligible(options) ? layoutArchitecture(
|
|
3905
|
+
data,
|
|
3906
|
+
options,
|
|
3907
|
+
plot,
|
|
3908
|
+
{ name: stepFont, text: labelFont, title: laneFont, badge: badgeFont },
|
|
3909
|
+
measure,
|
|
3910
|
+
u,
|
|
3911
|
+
diagramPalette,
|
|
3912
|
+
theme,
|
|
3913
|
+
badgeSizes,
|
|
3914
|
+
rawOptions[ARCHITECTURE_PLANS]
|
|
3915
|
+
) : orgChartEligible(data, options) ? layoutOrgChart(data, plot, labelFont, measure, u, fixedHeight && spreadGaps) : issueTreeEligible(data, options) ? layoutIssueTreeCompact(data, plot, labelFont, measure, u, headingWeight(theme)) : journeyEligible(data, options) ? layoutJourneyCompact(data, options, plot, labelFont, axisFont, measure, u, diagramPalette, headingWeight(theme), fixedHeight && spreadGaps) : linearEligible(data, options) ? layoutLinearCompact(
|
|
2495
3916
|
data,
|
|
2496
3917
|
plot,
|
|
2497
3918
|
stepFont,
|
|
@@ -2500,15 +3921,16 @@ function layoutDiagramPass(rawData, rawOptions, measureMinimum, fitOnly = !1) {
|
|
|
2500
3921
|
measure,
|
|
2501
3922
|
u,
|
|
2502
3923
|
badgeText,
|
|
2503
|
-
size.width >= 720 ? 2 * stepFont.size : 0
|
|
2504
|
-
|
|
2505
|
-
|
|
3924
|
+
size.width >= 720 ? 2 * stepFont.size : 0,
|
|
3925
|
+
fixedHeight
|
|
3926
|
+
) : roadmapEligible(data, options) ? layoutRoadmapCompact(data, options, plot, labelFont, laneFont, measure, u, diagramPalette, theme) : void 0, edgeLabelFont = options.variant === "architecture" ? org?.secondaryFont ?? labelFont : labelFont, narrow = org !== void 0 || NARROW_PRESETS.has(options.variant), narrowCard = !narrow && panelTypeClass(options) === void 0 && size.width < DIAGRAM_MIN_WIDTH, probe = fitOnly && !narrowCard, preset = org?.preset ?? layoutPreset(theme, presetContext);
|
|
3927
|
+
if (org?.warnings && pushAll(warnings, org.warnings), !externalLabels && !org)
|
|
2506
3928
|
for (let pass = 0; pass < 2; pass++) {
|
|
2507
3929
|
let changed = !1;
|
|
2508
3930
|
for (let node of data.nodes) {
|
|
2509
3931
|
let rect = preset.nodeRects.get(node.id);
|
|
2510
3932
|
if (!rect) continue;
|
|
2511
|
-
let width = Math.max(1, rect.w - 4 * u), lines =
|
|
3933
|
+
let width = Math.max(1, rect.w - 4 * u), lines = wrapNameText(node.label, presetFont(node) ?? labelFont, width, 3, measure).lines.length, secondary = node.secondaryLabel ? wrapText(node.secondaryLabel, labelFont, width, 2, measure).lines.length * lineHeight + u : 0, icon = Math.max(preset.contentTopReserves.get(node.id) ?? 0, node.icon || node.shape.kind === "icon" ? Math.max(4.5 * u, 28) : 0), height = lines * lineHeight + secondary + icon + 3 * u + (badgeSizes.get(node.id)?.height ?? 0), current = nodeSizes.get(node.id);
|
|
2512
3934
|
height > current.height && (nodeSizes.set(node.id, { ...current, height }), changed = !0);
|
|
2513
3935
|
}
|
|
2514
3936
|
if (!changed) break;
|
|
@@ -2534,20 +3956,20 @@ function layoutDiagramPass(rawData, rawOptions, measureMinimum, fitOnly = !1) {
|
|
|
2534
3956
|
message: `phase '${lane.label ?? lane.id}' has no members`,
|
|
2535
3957
|
owner: laneOwner(lane.id)
|
|
2536
3958
|
});
|
|
2537
|
-
let refusedIds = ensurePositionContract(rawData.nodes, data.nodes, preset.nodeRects, plot, warnings), labelRequests = [], labelKinds = /* @__PURE__ */ new Map(), boldLeads = /* @__PURE__ */ new Map(), nodeMarks = [], nodeScene = [], badgeScene = [], groupScene = [], framedGroups = options.variant !== "strategy-house" || theme.marks?.nodeStroke !== void 0, groups = preset.groups.map((group) => {
|
|
3959
|
+
let refusedIds = ensurePositionContract(rawData.nodes, data.nodes, preset.nodeRects, plot, warnings), labelRequests = [], joinedLabels = /* @__PURE__ */ new Map(), labelKinds = /* @__PURE__ */ new Map(), boldLeads = /* @__PURE__ */ new Map(), nodeMarks = [], nodeScene = [], badgeScene = [], groupScene = [], framedGroups = options.variant !== "strategy-house" || theme.marks?.nodeStroke !== void 0, groups = preset.groups.map((group) => {
|
|
2538
3960
|
let authored = data.groups.find((candidate) => candidate.id === group.id), nodeId = diagramSceneId("group", group.id);
|
|
2539
|
-
return framedGroups && groupScene.push({
|
|
3961
|
+
return framedGroups && !org?.groupPaint?.dashed.has(group.id) && groupScene.push({
|
|
2540
3962
|
t: "rect",
|
|
2541
3963
|
id: nodeId,
|
|
2542
3964
|
rect: group.bounds,
|
|
2543
|
-
fill: { token: "others", tint: 0.82 },
|
|
2544
|
-
stroke: diagramPalette.paint(authored.role, authored.paletteKey),
|
|
3965
|
+
fill: org?.groupPaint?.fills?.get(group.id) ?? org?.groupPaint?.fill ?? { token: "others", tint: 0.82 },
|
|
3966
|
+
stroke: org?.groupPaint && authored.role === void 0 ? org.groupPaint.stroke : diagramPalette.paint(authored.role, authored.paletteKey),
|
|
2545
3967
|
// A group frame follows the node ring's width and corner.
|
|
2546
3968
|
strokeWidth: theme.marks?.nodeStrokeWidth ?? strokeToken(theme, "hair"),
|
|
2547
3969
|
radius: theme.marks?.nodeRadius ?? resolveSurface(theme).chipRadius,
|
|
2548
3970
|
owner: groupOwner(group.id),
|
|
2549
3971
|
part: "diagramGroup"
|
|
2550
|
-
}), options.variant === "hierarchy" && addBoxLabelRequest(
|
|
3972
|
+
}), (options.variant === "hierarchy" || options.variant === "architecture") && addBoxLabelRequest(
|
|
2551
3973
|
labelRequests,
|
|
2552
3974
|
labelKinds,
|
|
2553
3975
|
`group-label:${group.id}`,
|
|
@@ -2555,7 +3977,7 @@ function layoutDiagramPass(rawData, rawOptions, measureMinimum, fitOnly = !1) {
|
|
|
2555
3977
|
groupOwner(group.id),
|
|
2556
3978
|
authored.title,
|
|
2557
3979
|
group.titleBox,
|
|
2558
|
-
|
|
3980
|
+
laneFont,
|
|
2559
3981
|
measure,
|
|
2560
3982
|
PRIORITY.endpoint,
|
|
2561
3983
|
options.target
|
|
@@ -2587,9 +4009,12 @@ function layoutDiagramPass(rawData, rawOptions, measureMinimum, fitOnly = !1) {
|
|
|
2587
4009
|
preset.decorationClaims.forEach(
|
|
2588
4010
|
(claim) => occupied.claim(claim.rect, "mark", claim.owner, claim.part)
|
|
2589
4011
|
);
|
|
4012
|
+
let badgeFlush = /* @__PURE__ */ new Set();
|
|
2590
4013
|
for (let [id, pill] of badgeSizes) {
|
|
2591
|
-
let rect = preset.nodeRects.get(id);
|
|
2592
|
-
|
|
4014
|
+
let rect = preset.nodeRects.get(id), node = rect && !externalLabels && !org?.badges ? data.nodes.find((candidate) => candidate.id === id) : void 0;
|
|
4015
|
+
if (!rect || !node) continue;
|
|
4016
|
+
let icon = node.icon ?? (node.shape.kind === "icon" ? node.shape.name : void 0), room = rect.h - pill.height / 2 - 2.5 * u - Math.max(0, pill.height / 2 + u - 1.25 * u) - (preset.contentTopReserves.get(id) ?? (icon ? Math.min(rect.h * 0.42, 28) : 0)), lines = fitText(node.label, presetFont(node) ?? labelFont, Math.max(1, rect.w - 4 * u), 3, measure, { target: options.target, typeRole: "label", hyphenRetry: !0 }).lines.length;
|
|
4017
|
+
room + 0.5 < lines * lineHeight ? badgeFlush.add(id) : preset.nodeRects.set(id, qRect({ ...rect, y: rect.y + pill.height / 2, h: rect.h - pill.height / 2 }));
|
|
2593
4018
|
}
|
|
2594
4019
|
for (let node of data.nodes) {
|
|
2595
4020
|
let rect = preset.nodeRects.get(node.id);
|
|
@@ -2605,7 +4030,9 @@ function layoutDiagramPass(rawData, rawOptions, measureMinimum, fitOnly = !1) {
|
|
|
2605
4030
|
w: Math.max(1, rect.w - 4 * u),
|
|
2606
4031
|
h: Math.max(1, rect.h - 2.5 * u)
|
|
2607
4032
|
}), pill = pills.get(node.id), badgeSize = badgeSizes.get(node.id);
|
|
2608
|
-
if (badgeSize &&
|
|
4033
|
+
if (badgeSize && badgeFlush.has(node.id))
|
|
4034
|
+
contentRect.x += badgeSize.width, contentRect.w = Math.max(1, contentRect.w - badgeSize.width);
|
|
4035
|
+
else if (badgeSize && !externalLabels && !org?.badges) {
|
|
2609
4036
|
let reserve = Math.max(0, badgeSize.height / 2 + u - 1.25 * u);
|
|
2610
4037
|
contentRect.y += reserve, contentRect.h = Math.max(1, contentRect.h - reserve);
|
|
2611
4038
|
}
|
|
@@ -2650,15 +4077,20 @@ function layoutDiagramPass(rawData, rawOptions, measureMinimum, fitOnly = !1) {
|
|
|
2650
4077
|
options.variant === "roadmap" ? preset.lanes.find((lane) => lane.id === node.laneId)?.bounds : void 0,
|
|
2651
4078
|
org !== void 0 && !org.centred,
|
|
2652
4079
|
emphasisWeight(theme),
|
|
2653
|
-
org?.captionBoxes ? { font: captionFont, box: org.captionBoxes.get(node.id) } : org?.seats ? { font: labelFont, seat: org.seats.get(node.id) } : void 0
|
|
4080
|
+
org?.captionBoxes ? { font: captionFont, box: org.captionBoxes.get(node.id) } : org?.seats ? { font: labelFont, seat: org.seats.get(node.id) } : org?.secondaryFont ? { font: captionFont, secondaryFont: org.secondaryFont } : void 0,
|
|
4081
|
+
joinedLabels
|
|
2654
4082
|
), node.badge || options.variant === "linear-process") {
|
|
2655
|
-
let badgePaint = org?.badgePaint ?? (node.badge ? diagramPalette.fill(node.badge.role, node.badge.paletteKey) : { token: "neutralMark" }), text = badgeText(node), diameter = q(Math.max(4 * u, measure(text, badgeFont).width + 2 * u)),
|
|
4083
|
+
let badgePaint = org?.badgePaint ?? (node.badge ? diagramPalette.fill(node.badge.role, node.badge.paletteKey) : { token: "neutralMark" }), text = badgeText(node), diameter = q(Math.max(4 * u, measure(text, badgeFont).width + 2 * u)), placed = org?.badges?.get(node.id) ?? qRect({
|
|
2656
4084
|
x: rect.x + u,
|
|
2657
|
-
y: rect.y - (badgeSize?.height ?? diameter) / 2,
|
|
4085
|
+
y: badgeFlush.has(node.id) ? rect.y + (rect.h - badgeSize.height) / 2 : rect.y - (badgeSize?.height ?? diameter) / 2,
|
|
2658
4086
|
w: badgeSize?.width ?? diameter,
|
|
2659
4087
|
h: badgeSize?.height ?? diameter
|
|
4088
|
+
}), canvas = { x: 0, y: 0, w: size.width, h: size.height }, nodeOnCanvas = rectContains(canvas, rect, -0.5), badgeBox = qRect({
|
|
4089
|
+
...placed,
|
|
4090
|
+
x: Math.max(0, Math.min(placed.x, size.width - placed.w)),
|
|
4091
|
+
y: Math.max(0, Math.min(placed.y, size.height - placed.h))
|
|
2660
4092
|
});
|
|
2661
|
-
if (rectContains(
|
|
4093
|
+
if (nodeOnCanvas && rectContains(canvas, badgeBox)) {
|
|
2662
4094
|
let badgeId = diagramSceneId("badge", node.id);
|
|
2663
4095
|
badgeScene.push({
|
|
2664
4096
|
...pill ? { t: "rect", rect: badgeBox, radius: resolveSurface(theme).chipRadius } : {
|
|
@@ -2688,7 +4120,7 @@ function layoutDiagramPass(rawData, rawOptions, measureMinimum, fitOnly = !1) {
|
|
|
2688
4120
|
// Authored badge text is a name; the linear-process sequence number is a value.
|
|
2689
4121
|
node.badge ? "category" : "value"
|
|
2690
4122
|
);
|
|
2691
|
-
} else node.badge && warnings.push({
|
|
4123
|
+
} else node.badge && nodeOnCanvas && warnings.push({
|
|
2692
4124
|
code: "diagram-size-too-small",
|
|
2693
4125
|
severity: "error",
|
|
2694
4126
|
message: `badge '${text}' on node '${node.id}' cannot fit the canvas`,
|
|
@@ -2698,15 +4130,19 @@ function layoutDiagramPass(rawData, rawOptions, measureMinimum, fitOnly = !1) {
|
|
|
2698
4130
|
}
|
|
2699
4131
|
nodeMarks.push(resolved);
|
|
2700
4132
|
}
|
|
2701
|
-
|
|
4133
|
+
org?.discs?.forEach((disc) => {
|
|
4134
|
+
let paint = { token: "neutralMark" };
|
|
4135
|
+
badgeScene.push({ t: "circle", id: diagramSceneId("callout", disc.id), cx: q(disc.rect.x + disc.rect.w / 2), cy: q(disc.rect.y + disc.rect.h / 2), r: q(disc.rect.w / 2), fill: paint, owner: disc.owner, part: "diagramBadge" }), addBoxLabelRequest(labelRequests, labelKinds, `callout-label:${disc.id}`, "diagramBadge", disc.owner, disc.text, disc.rect, badgeFont, measure, PRIORITY.endpoint, options.target, paintColor(theme, paint), paint, "value");
|
|
4136
|
+
});
|
|
4137
|
+
let structuralCtx = labelCtx(theme, size, {}, {
|
|
2702
4138
|
density: "full",
|
|
2703
4139
|
measure,
|
|
2704
4140
|
plot,
|
|
2705
4141
|
labelPad: 1
|
|
2706
|
-
}));
|
|
4142
|
+
}), solvedStructural = solveLabels(labelRequests, occupied, structuralCtx);
|
|
2707
4143
|
remapLabelKinds(solvedStructural.placed, labelKinds);
|
|
2708
4144
|
for (let label of solvedStructural.placed) {
|
|
2709
|
-
let node = org?.
|
|
4145
|
+
let node = org?.badgePaint && label.id.startsWith("badge-label:") ? data.nodes.find((candidate) => candidate.id === label.owner.pointId) : void 0, ink = org?.labelInks?.get(label.id) ?? (node ? nodeFillPaint(node, diagramPalette, theme) : void 0);
|
|
2710
4146
|
ink && !label.hidden && (label.ink = ink);
|
|
2711
4147
|
}
|
|
2712
4148
|
if (pushAll(warnings, solvedStructural.warnings), translateLabelLosses(solvedStructural.placed, labelKinds, warnings), probe && (warnings.some((warning) => warning.severity === "error") || sizeWarning(
|
|
@@ -2717,6 +4153,8 @@ function layoutDiagramPass(rawData, rawOptions, measureMinimum, fitOnly = !1) {
|
|
|
2717
4153
|
0
|
|
2718
4154
|
))) return { warnings };
|
|
2719
4155
|
if (probe && fitOnly === "structural") return { warnings };
|
|
4156
|
+
let unplaced = settleJoinedLabels(solvedStructural.placed, joinedLabels, nodeMarks, occupied, { x: 0, y: 0, w: size.width, h: size.height }, structuralCtx);
|
|
4157
|
+
unplaced && (remapLabelKinds(unplaced.placed, labelKinds), solvedStructural.placed.push(...unplaced.placed), solvedStructural.decisions.push(...unplaced.decisions), pushAll(warnings, unplaced.warnings), translateLabelLosses(unplaced.placed, labelKinds, warnings));
|
|
2720
4158
|
for (let label of solvedStructural.placed) {
|
|
2721
4159
|
let nodeId = label.owner.pointId;
|
|
2722
4160
|
if (!nodeId) continue;
|
|
@@ -2726,10 +4164,22 @@ function layoutDiagramPass(rawData, rawOptions, measureMinimum, fitOnly = !1) {
|
|
|
2726
4164
|
let structuralLabelNodes = probe ? [] : labelsToNodes(
|
|
2727
4165
|
theme,
|
|
2728
4166
|
solvedStructural.placed,
|
|
2729
|
-
(label) => ["diagramLane", "diagramGroup", "diagramBadge"].includes(label.kind) ? labelKinds.get(label.id) === "diagramBadge" ? badgeFont : labelKinds.get(label.id) === "diagramLane" ? laneFont : axisFont : labelKinds.get(label.id) === "diagramCaption" && org?.captionBoxes ? captionFont : (label.owner.pointId ? org?.fonts.get(label.owner.pointId) ?? (label.id.startsWith("node-label:") ? nodeFontById(label.owner.pointId) : void 0) : void 0) ?? labelFont
|
|
4167
|
+
(label) => ["diagramLane", "diagramGroup", "diagramBadge"].includes(label.kind) ? labelKinds.get(label.id) === "diagramBadge" ? badgeFont : labelKinds.get(label.id) === "diagramLane" || options.variant === "architecture" ? laneFont : axisFont : labelKinds.get(label.id) === "diagramCaption" && org?.captionBoxes ? captionFont : org?.secondaryFont && label.id.startsWith("secondary-label:") ? org.secondaryFont : (label.owner.pointId ? org?.fonts.get(label.owner.pointId) ?? (label.id.startsWith("node-label:") ? nodeFontById(label.owner.pointId) : void 0) : void 0) ?? labelFont
|
|
2730
4168
|
).flatMap((node) => splitBoldLead(node, boldLeads, emphasisWeight(theme))), reservedForRouting = solvedStructural.placed.filter((label) => !label.hidden).map((label) => label.rect), edgeLabelSizes = new Map(
|
|
2731
4169
|
preset.edges.flatMap(
|
|
2732
|
-
(edge) => edge.label ? [[edge.id, {
|
|
4170
|
+
(edge) => edge.label ? [[edge.id, {
|
|
4171
|
+
width: measure(edge.label, edgeLabelFont).width,
|
|
4172
|
+
height: measure(edge.label, edgeLabelFont).height,
|
|
4173
|
+
...options.variant === "circular-process" ? {
|
|
4174
|
+
wrapped: [0.5, 0.65, 0.8].flatMap((share) => {
|
|
4175
|
+
let wrapped = wrapText(edge.label, edgeLabelFont, measure(edge.label, edgeLabelFont).width * share, 2, measure);
|
|
4176
|
+
return !wrapped.truncated && wrapped.lines.length === 2 ? [{
|
|
4177
|
+
width: Math.max(...wrapped.lines.map((line) => measure(line, edgeLabelFont).width)),
|
|
4178
|
+
height: 2 * edgeLabelFont.size * (edgeLabelFont.lineHeight ?? 1.2)
|
|
4179
|
+
}] : [];
|
|
4180
|
+
})
|
|
4181
|
+
} : {}
|
|
4182
|
+
}]] : []
|
|
2733
4183
|
)
|
|
2734
4184
|
), routed = routeDiagramEdges(theme, {
|
|
2735
4185
|
preset: options.variant,
|
|
@@ -2737,11 +4187,12 @@ function layoutDiagramPass(rawData, rawOptions, measureMinimum, fitOnly = !1) {
|
|
|
2737
4187
|
nodeRects: preset.nodeRects,
|
|
2738
4188
|
edges: preset.edges,
|
|
2739
4189
|
plot,
|
|
2740
|
-
|
|
4190
|
+
// The smaller arrowhead of a dense flow exhibit.
|
|
4191
|
+
clearance: options.variant === "architecture" ? 0.7 * u : u,
|
|
2741
4192
|
labelSizes: edgeLabelSizes,
|
|
2742
4193
|
reserved: reservedForRouting,
|
|
2743
4194
|
palette: diagramPalette,
|
|
2744
|
-
...org ? { fixedRoutes: org.routes, ...org.centred ? {} : { edgePaint: { token: "neutral", tint: 0.2 } } } : options.variant === "circular-process" ? { edgePaint: { token: "neutral" } } : {}
|
|
4195
|
+
...org ? { fixedRoutes: org.routes, ...org.edgePaint ? { edgePaint: org.edgePaint } : org.centred ? {} : { edgePaint: { token: "neutral", tint: 0.2 } } } : options.variant === "circular-process" ? { edgePaint: { token: "neutral" } } : {}
|
|
2745
4196
|
});
|
|
2746
4197
|
if (pushAll(warnings, routed.warnings), probe) return { warnings };
|
|
2747
4198
|
routed.claims.forEach(
|
|
@@ -2752,33 +4203,64 @@ function layoutDiagramPass(rawData, rawOptions, measureMinimum, fitOnly = !1) {
|
|
|
2752
4203
|
let edgeLabelRequests = [], edgeLabelKinds = /* @__PURE__ */ new Map();
|
|
2753
4204
|
preset.edges.forEach((edge) => {
|
|
2754
4205
|
let rect = routed.labelBoxes.get(edge.id);
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
4206
|
+
if (edge.label) {
|
|
4207
|
+
if (!rect) {
|
|
4208
|
+
options.variant === "circular-process" && (edgeLabelKinds.set(`edge-label:${edge.id}`, "diagramEdge"), edgeLabelRequests.push({
|
|
4209
|
+
id: `edge-label:${edge.id}`,
|
|
4210
|
+
kind: "annotation",
|
|
4211
|
+
typeRole: "label",
|
|
4212
|
+
owner: { segmentId: edge.id },
|
|
4213
|
+
text: edge.label,
|
|
4214
|
+
lines: [edge.label],
|
|
4215
|
+
font: edgeLabelFont,
|
|
4216
|
+
priority: PRIORITY.interior,
|
|
4217
|
+
candidates: []
|
|
4218
|
+
}));
|
|
4219
|
+
return;
|
|
4220
|
+
}
|
|
4221
|
+
addBoxLabelRequest(
|
|
4222
|
+
edgeLabelRequests,
|
|
4223
|
+
edgeLabelKinds,
|
|
4224
|
+
`edge-label:${edge.id}`,
|
|
4225
|
+
"diagramEdge",
|
|
4226
|
+
{ segmentId: edge.id },
|
|
4227
|
+
edge.label,
|
|
4228
|
+
rect,
|
|
4229
|
+
edgeLabelFont,
|
|
4230
|
+
measure,
|
|
4231
|
+
PRIORITY.interior,
|
|
4232
|
+
options.target
|
|
4233
|
+
);
|
|
4234
|
+
}
|
|
4235
|
+
}), org?.channelLabels?.forEach((label) => addBoxLabelRequest(
|
|
4236
|
+
edgeLabelRequests,
|
|
4237
|
+
edgeLabelKinds,
|
|
4238
|
+
label.id,
|
|
4239
|
+
"diagramEdge",
|
|
4240
|
+
label.owner,
|
|
4241
|
+
label.text,
|
|
4242
|
+
label.rect,
|
|
4243
|
+
label.font ?? edgeLabelFont,
|
|
4244
|
+
measure,
|
|
4245
|
+
PRIORITY.interior,
|
|
4246
|
+
options.target
|
|
4247
|
+
));
|
|
2769
4248
|
let solvedEdges = solveLabels(edgeLabelRequests, occupied, labelCtx(theme, size, {}, {
|
|
2770
4249
|
density: "full",
|
|
2771
4250
|
measure,
|
|
2772
4251
|
plot,
|
|
2773
4252
|
labelPad: 1
|
|
2774
4253
|
}));
|
|
2775
|
-
remapLabelKinds(solvedEdges.placed, edgeLabelKinds),
|
|
2776
|
-
|
|
4254
|
+
if (remapLabelKinds(solvedEdges.placed, edgeLabelKinds), options.variant === "architecture")
|
|
4255
|
+
for (let label of solvedEdges.placed) label.owner.segmentId !== void 0 && (label.ink = { token: "inkMuted" });
|
|
4256
|
+
pushAll(warnings, solvedEdges.warnings);
|
|
4257
|
+
let edgeLabelFonts = new Map(org?.channelLabels?.map((label) => [label.id, label.font ?? edgeLabelFont])), edgeLabelNodes = labelsToNodes(theme, solvedEdges.placed, (label) => edgeLabelFonts.get(label.id) ?? edgeLabelFont), { laneGroupLabels, nodeLabels, accessoryLabels } = groupStructuralLabels(structuralLabelNodes), scene = [
|
|
2777
4258
|
...frame.nodes,
|
|
2778
4259
|
...groupScene,
|
|
2779
4260
|
...preset.decorationScene,
|
|
2780
4261
|
...routed.scene,
|
|
2781
4262
|
...nodeScene,
|
|
4263
|
+
...org?.overlay ?? [],
|
|
2782
4264
|
...laneGroupLabels,
|
|
2783
4265
|
...nodeLabels,
|
|
2784
4266
|
...badgeScene,
|
|
@@ -2797,7 +4279,7 @@ function layoutDiagramPass(rawData, rawOptions, measureMinimum, fitOnly = !1) {
|
|
|
2797
4279
|
...nodeMarks.flatMap((node) => badgeSizes.has(node.id) && node.badgeBox ? [node.badgeBox] : []),
|
|
2798
4280
|
...labels.filter((label) => !label.hidden).map((label) => label.rect),
|
|
2799
4281
|
...org?.extent ?? []
|
|
2800
|
-
], sizing = org ? contentSizing("diagram", size, plot, contentRects) : naturalDiagramSizing(options, data, nodeSizes, labelFont, measure, u, contentSizing("diagram", size, plot, contentRects), size, plot, headFont), unreadable = narrowCard && (solvedStructural.placed.some((label) => !label.hidden && label.title !== void 0 && CARD_TEXT_KINDS.has(label.kind)) || labels.some((label) => !!label.hidden && label.hidden !== "redundant") || solvedEdges.placed.some((label) => !label.hidden && label.title !== void 0) || refusedIds.size > 0 || groups.some((group, i) => groups.slice(i + 1).some((other) => rectsOverlap(group.bounds, other.bounds)))), refusedNarrow = unreadable && rawOptions[TARGET_SIZE]?.fixed.height !== !1, requiredAccessoryLoss = warnings.some((warning) => warning.code === "diagram-size-too-small" && warning.severity === "error"), minimumRequiredSize = (tooSmall || requiredAccessoryLoss || refusedIds.size > 0) && measureMinimum && !refusedNarrow ? measuredDiagramMinimum(
|
|
4282
|
+
], sizing = org ? contentSizing("diagram", size, plot, contentRects) : naturalDiagramSizing(options, data, nodeSizes, labelFont, measure, u, contentSizing("diagram", size, plot, contentRects), size, plot, headFont), unreadable = narrowCard && (solvedStructural.placed.some((label) => !label.hidden && label.title !== void 0 && CARD_TEXT_KINDS.has(label.kind)) || labels.some((label) => !!label.hidden && label.hidden !== "redundant") || solvedEdges.placed.some((label) => !label.hidden && label.title !== void 0) || refusedIds.size > 0 || groups.some((group, i) => groups.slice(i + 1).some((other) => rectsOverlap(group.bounds, other.bounds)))), refusedNarrow = unreadable && rawOptions[TARGET_SIZE]?.fixed.height !== !1, requiredAccessoryLoss = warnings.some((warning) => (warning.code === "diagram-size-too-small" || warning.code === "diagram-route-unresolved") && warning.severity === "error"), minimumRequiredSize = (tooSmall || requiredAccessoryLoss || refusedIds.size > 0) && measureMinimum && !refusedNarrow ? measuredDiagramMinimum(
|
|
2801
4283
|
size,
|
|
2802
4284
|
sizing.naturalHeight,
|
|
2803
4285
|
panelTypeClass(options) !== void 0,
|
|
@@ -2856,78 +4338,93 @@ function layoutDiagramPass(rawData, rawOptions, measureMinimum, fitOnly = !1) {
|
|
|
2856
4338
|
}
|
|
2857
4339
|
};
|
|
2858
4340
|
}
|
|
2859
|
-
function addNodeLabels(node, resolved, options, font, measure, u, requests, kinds, warnings, fillCss, plot, insidePaint, boldLeads, laneBox, start = !1, leadWeight = font.weight, caption) {
|
|
4341
|
+
function addNodeLabels(node, resolved, options, font, measure, u, requests, kinds, warnings, fillCss, plot, insidePaint, boldLeads, laneBox, start = !1, leadWeight = font.weight, caption, joinedLabels) {
|
|
2860
4342
|
let external = options.variant === "roadmap" || options.variant === "circular-process", ring = options.variant === "circular-process" ? circularSide(resolved.rect, plot) : void 0, ringWidth = ring === "left" ? resolved.rect.x - plot.x - 2 * u : ring === "right" ? plot.x + plot.w - resolved.rect.x - resolved.rect.w - 2 * u : plot.w / 2, maxWidth = ring ? Math.max(Math.min(18 * u, plot.w / 4), ringWidth) : external ? Math.min(18 * u, plot.w / Math.max(2, options.variant === "roadmap" ? 5 : 4)) : resolved.contentRect.w, externalFit = {
|
|
2861
4343
|
target: options.target,
|
|
2862
4344
|
typeRole: "label",
|
|
4345
|
+
hyphenRetry: !0,
|
|
2863
4346
|
...external && !ring ? { wider: plot.w / (options.variant === "roadmap" ? 5 : 4) } : {}
|
|
2864
4347
|
}, id = `node-label:${node.id}`, cut = options.variant === "circular-process" ? node.label.indexOf(`
|
|
2865
|
-
`) : -1, bold = { ...font, weight: leadWeight }, lead = cut > 0 ? fitText(node.label.slice(0, cut), bold, maxWidth, 1, measure, externalFit) : void 0, seat = caption?.seat,
|
|
4348
|
+
`) : -1, bold = { ...font, weight: leadWeight }, lead = cut > 0 ? fitText(node.label.slice(0, cut), bold, maxWidth, 1, measure, externalFit) : void 0, seat = caption?.seat, primary = seat ? { lines: seat.lines, title: void 0 } : lead ? (() => {
|
|
2866
4349
|
let rest = fitText(node.label.slice(cut + 1), font, maxWidth, 2, measure, externalFit);
|
|
2867
4350
|
return { lines: [...lead.lines, ...rest.lines], title: lead.title ?? rest.title };
|
|
2868
4351
|
})() : fitText(node.label, font, maxWidth, 3, measure, externalFit);
|
|
2869
4352
|
lead && boldLeads.set(id, lead.lines.length);
|
|
2870
|
-
let lineH = font.size * (font.lineHeight ?? 1.2),
|
|
4353
|
+
let lineH = font.size * (font.lineHeight ?? 1.2), secondaryFont2 = caption?.secondaryFont ?? font, secondary = node.secondaryLabel ? fitText(node.secondaryLabel, secondaryFont2, resolved.contentRect.w, 2, measure, { target: options.target, typeRole: "label" }) : void 0, architecture = options.variant === "architecture", secondaryHeight = (secondary?.lines.length ?? 0) * (architecture ? secondaryFont2.size * (secondaryFont2.lineHeight ?? 1.2) : lineH), secondaryGap = architecture ? 0.5 * u : u, height = primary.lines.length * lineH, secondaryFits = secondary && !secondary.title && height + secondaryHeight + secondaryGap <= resolved.contentRect.h, primaryHeight = resolved.contentRect.h - (!external && secondaryFits ? secondaryHeight + secondaryGap : 0), blockTop = resolved.contentRect.y + (resolved.contentRect.h - height - secondaryHeight - secondaryGap) / 2;
|
|
2871
4354
|
kinds.set(id, "diagramNode");
|
|
2872
|
-
let
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
4355
|
+
let labelRequest = (block, text) => {
|
|
4356
|
+
let width = Math.max(1, ...block.lines.map((line, index) => measure(line, index < (lead?.lines.length ?? 0) ? bold : font).width)), blockHeight = block.lines.length * lineH, candidates = seat ? [{ slot: "right", rect: qRect(seat.rect), penalty: 0 }] : !external && blockHeight > primaryHeight + 0.5 ? [] : external ? externalCandidates(
|
|
4357
|
+
resolved.rect,
|
|
4358
|
+
width,
|
|
4359
|
+
blockHeight,
|
|
4360
|
+
u,
|
|
4361
|
+
options.variant === "roadmap",
|
|
4362
|
+
plot,
|
|
4363
|
+
laneBox
|
|
4364
|
+
) : [
|
|
4365
|
+
{
|
|
4366
|
+
slot: "inside",
|
|
4367
|
+
rect: qRect({
|
|
4368
|
+
x: start ? resolved.contentRect.x : resolved.contentRect.x + (resolved.contentRect.w - width) / 2,
|
|
4369
|
+
y: architecture && secondaryFits ? blockTop : resolved.contentRect.y + (primaryHeight - blockHeight) / 2,
|
|
4370
|
+
w: width,
|
|
4371
|
+
h: blockHeight
|
|
4372
|
+
}),
|
|
4373
|
+
penalty: 0,
|
|
4374
|
+
insideFill: fillCss,
|
|
4375
|
+
insidePaint
|
|
4376
|
+
}
|
|
4377
|
+
];
|
|
4378
|
+
return {
|
|
4379
|
+
id,
|
|
4380
|
+
kind: "point",
|
|
4381
|
+
markAnchored: !1,
|
|
4382
|
+
typeRole: "label",
|
|
4383
|
+
owner: nodeOwner(node.id),
|
|
4384
|
+
text,
|
|
4385
|
+
lines: block.lines,
|
|
4386
|
+
...block.title !== void 0 ? { title: block.title } : {},
|
|
4387
|
+
font,
|
|
4388
|
+
priority: PRIORITY.valueLine,
|
|
4389
|
+
...ring === "left" ? { align: "end" } : ring === "above" || ring === "below" || !external && !start && !seat && block.lines.length > 1 ? { align: "middle" } : { align: "start" },
|
|
4390
|
+
candidates
|
|
4391
|
+
};
|
|
4392
|
+
};
|
|
4393
|
+
requests.push(labelRequest(primary, node.label));
|
|
4394
|
+
let joined = joinedLabels !== void 0 && external && !seat && !!node.secondaryLabel && !secondaryFits;
|
|
4395
|
+
joined && joinedLabels.set(id, {
|
|
4396
|
+
block: () => {
|
|
4397
|
+
let outside = fitText(node.secondaryLabel, font, maxWidth, 2, measure, externalFit), text = `${node.label}
|
|
4398
|
+
${node.secondaryLabel}`, block = { lines: [...primary.lines, ...outside.lines], title: primary.title !== void 0 || outside.title !== void 0 ? text : void 0 };
|
|
4399
|
+
return { text, lines: block.lines, title: block.title, seats: labelRequest(block, text).candidates };
|
|
4400
|
+
},
|
|
4401
|
+
from: { x: resolved.rect.x + resolved.rect.w / 2, y: resolved.rect.y + resolved.rect.h / 2 },
|
|
4402
|
+
secondary: () => secondaryRequest(secondary)
|
|
4403
|
+
}), primary.title !== void 0 && warnings.push({
|
|
2908
4404
|
code: "diagram-node-label-unplaced",
|
|
2909
4405
|
severity: "error",
|
|
2910
4406
|
message: `primary label on node '${node.id}' cannot fit without truncation`,
|
|
2911
4407
|
owner: nodeOwner(node.id)
|
|
2912
|
-
})
|
|
2913
|
-
|
|
2914
|
-
|
|
4408
|
+
});
|
|
4409
|
+
function secondaryRequest(lines) {
|
|
4410
|
+
let secondaryWidth = Math.max(1, ...lines.lines.map((line) => measure(line, secondaryFont2).width)), secondaryId = `secondary-label:${node.id}`;
|
|
4411
|
+
return kinds.set(secondaryId, "diagramSecondary"), {
|
|
2915
4412
|
id: secondaryId,
|
|
2916
4413
|
kind: "point",
|
|
2917
4414
|
markAnchored: !1,
|
|
2918
4415
|
typeRole: "label",
|
|
2919
4416
|
owner: nodeOwner(node.id),
|
|
2920
4417
|
text: node.secondaryLabel,
|
|
2921
|
-
lines:
|
|
2922
|
-
...
|
|
2923
|
-
font,
|
|
4418
|
+
lines: lines.lines,
|
|
4419
|
+
...lines.title !== void 0 ? { title: lines.title } : {},
|
|
4420
|
+
font: secondaryFont2,
|
|
2924
4421
|
priority: PRIORITY.interior,
|
|
2925
4422
|
candidates: secondaryFits ? [
|
|
2926
4423
|
{
|
|
2927
4424
|
slot: "inside-secondary",
|
|
2928
4425
|
rect: qRect({
|
|
2929
|
-
x: resolved.contentRect.x + (resolved.contentRect.w - secondaryWidth) / 2,
|
|
2930
|
-
y: resolved.contentRect.y + resolved.contentRect.h - secondaryHeight,
|
|
4426
|
+
x: caption?.secondaryFont ? resolved.contentRect.x : resolved.contentRect.x + (resolved.contentRect.w - secondaryWidth) / 2,
|
|
4427
|
+
y: architecture ? blockTop + height + secondaryGap : resolved.contentRect.y + resolved.contentRect.h - secondaryHeight,
|
|
2931
4428
|
w: secondaryWidth,
|
|
2932
4429
|
h: secondaryHeight
|
|
2933
4430
|
}),
|
|
@@ -2936,9 +4433,35 @@ function addNodeLabels(node, resolved, options, font, measure, u, requests, kind
|
|
|
2936
4433
|
insidePaint
|
|
2937
4434
|
}
|
|
2938
4435
|
] : []
|
|
2939
|
-
}
|
|
4436
|
+
};
|
|
4437
|
+
}
|
|
4438
|
+
secondary && !joined && requests.push(secondaryRequest(secondary)), addNodeCaption(node, resolved, options, caption?.font ?? font, measure, u, requests, kinds, caption?.box);
|
|
4439
|
+
}
|
|
4440
|
+
function settleJoinedLabels(placed, joined, nodes, occupied, canvas, ctx) {
|
|
4441
|
+
if (joined.size === 0) return;
|
|
4442
|
+
let pad = ctx.labelPad ?? 2, byId = new Map(placed.map((label) => [label.id, label])), unplaced = [];
|
|
4443
|
+
for (let [id, entry] of joined) {
|
|
4444
|
+
let label = byId.get(id), name = label && !label.hidden ? occupied.hitsWhich(label.rect, 0).find((claim) => claim.kind === "label" && claim.owner.pointId === label.owner.pointId && sameRect(claim.rect, label.rect)) : void 0;
|
|
4445
|
+
if (!label || !name) {
|
|
4446
|
+
unplaced.push(entry.secondary());
|
|
4447
|
+
continue;
|
|
4448
|
+
}
|
|
4449
|
+
occupied.release?.(name);
|
|
4450
|
+
let block = entry.block(), seat = block.seats.find((candidate) => rectContains(canvas, candidate.rect, 0) && !occupied.hits(candidate.rect, pad));
|
|
4451
|
+
if (!seat) {
|
|
4452
|
+
occupied.claim(label.rect, "label", label.owner), unplaced.push(entry.secondary());
|
|
4453
|
+
continue;
|
|
4454
|
+
}
|
|
4455
|
+
occupied.claim(seat.rect, "label", label.owner), label.rect = seat.rect, label.slot = seat.slot, label.lines = block.lines, label.text = block.text, block.title === void 0 ? delete label.title : label.title = block.title;
|
|
4456
|
+
let leader = seatLeader(seat.rect, entry.from);
|
|
4457
|
+
leader ? label.leader = leader : delete label.leader;
|
|
4458
|
+
let node = nodes.find((candidate) => candidate.id === label.owner.pointId);
|
|
4459
|
+
node && (node.secondaryPrinted = !0);
|
|
2940
4460
|
}
|
|
2941
|
-
|
|
4461
|
+
return unplaced.length === 0 ? void 0 : solveLabels(unplaced, occupied, ctx);
|
|
4462
|
+
}
|
|
4463
|
+
function sameRect(a, b) {
|
|
4464
|
+
return a.x === b.x && a.y === b.y && a.w === b.w && a.h === b.h;
|
|
2942
4465
|
}
|
|
2943
4466
|
function circularSide(rect, plot) {
|
|
2944
4467
|
let dx = rect.x + rect.w / 2 - (plot.x + plot.w / 2), dy = rect.y + rect.h / 2 - (plot.y + plot.h / 2);
|
|
@@ -3002,7 +4525,7 @@ function externalCandidates(rect, width, height, u, roadmap, plot, laneBox) {
|
|
|
3002
4525
|
];
|
|
3003
4526
|
}
|
|
3004
4527
|
function addBoxLabelRequest(requests, kinds, id, kind, owner, text, box, font, measure, priority, target, insideFill, insidePaint, role) {
|
|
3005
|
-
let wrapped = fitText(text, font, Math.max(1, box.w -
|
|
4528
|
+
let maxLines = kind === "diagramEdge" ? Math.max(2, Math.round(box.h / (font.size * (font.lineHeight ?? 1.2)))) : 2, wrapped = fitText(text, font, Math.max(1, box.w - (kind === "diagramEdge" ? 0 : BOX_LABEL_INSET)), maxLines, measure, { target, typeRole: kind === "diagramBadge" || kind === "diagramEdge" ? "label" : "axis" }), lineH = font.size * (font.lineHeight ?? 1.2), width = Math.max(1, ...wrapped.lines.map((line) => measure(line, font).width)), height = wrapped.lines.length * lineH;
|
|
3006
4529
|
kinds.set(id, kind), requests.push({
|
|
3007
4530
|
id,
|
|
3008
4531
|
kind: "annotation",
|
|
@@ -3140,7 +4663,13 @@ function measuredDiagramMinimum(received, naturalHeight, nested, layoutAt) {
|
|
|
3140
4663
|
return size;
|
|
3141
4664
|
}
|
|
3142
4665
|
function diagramA11y(data, options, readingOrder, edges) {
|
|
3143
|
-
let labels = new Map(data.nodes.map((node) =>
|
|
4666
|
+
let labels = new Map(data.nodes.map((node) => {
|
|
4667
|
+
let copies = node.repeat ? chartString(options, "diagramCopies", { v1: node.label, v2: node.repeat }) : node.label;
|
|
4668
|
+
return [node.id, node.protected ? chartString(options, "diagramProtected", { v1: copies }) : copies];
|
|
4669
|
+
})), end = (edge, side) => {
|
|
4670
|
+
let group = data.groupEnds?.get(edge.id ?? "")?.[side];
|
|
4671
|
+
return group !== void 0 ? data.groups.find((item) => item.id === group)?.title ?? group : labels.get(edge[side].nodeId) ?? edge[side].nodeId;
|
|
4672
|
+
}, order = readingOrder.map((id) => labels.get(id) ?? id).join("; "), relationships = edges.map((edge) => `${end(edge, "source")} \u2192 ${end(edge, "target")}`).join("; "), groups = data.groups.map((group) => {
|
|
3144
4673
|
let members = data.nodes.filter((node) => node.groupId === group.id).map((node) => node.label).join(", ");
|
|
3145
4674
|
return chartString(options, "containsMembers", { v1: group.title, v2: members || chartString(options, "noNodes") });
|
|
3146
4675
|
}).join("; "), lanes = data.lanes.map((lane) => {
|
|
@@ -3148,12 +4677,13 @@ function diagramA11y(data, options, readingOrder, edges) {
|
|
|
3148
4677
|
return chartString(options, "containsMembers", { v1: lane.label ?? lane.id, v2: members || chartString(options, "noNodes") });
|
|
3149
4678
|
}).join("; ");
|
|
3150
4679
|
return {
|
|
3151
|
-
title: accessibleTitle(options.title, chartString(options, "diagramTitle", { v1: chartString(options, { hierarchy: "diagramHierarchy", "issue-tree": "diagramIssueTree", "linear-process": "diagramLinearProcess", "customer-journey": "diagramCustomerJourney", "circular-process": "diagramCircularProcess", "strategy-house": "diagramStrategyHouse", roadmap: "diagramRoadmap" }[options.variant]) })),
|
|
4680
|
+
title: accessibleTitle(options.title, chartString(options, "diagramTitle", { v1: chartString(options, { hierarchy: "diagramHierarchy", "issue-tree": "diagramIssueTree", "linear-process": "diagramLinearProcess", "customer-journey": "diagramCustomerJourney", "circular-process": "diagramCircularProcess", "strategy-house": "diagramStrategyHouse", roadmap: "diagramRoadmap", architecture: "diagramArchitecture" }[options.variant]) })),
|
|
3152
4681
|
counts: [structureCount("nodes", data.nodes.length, void 0, options), structureCount("relationships", edges.length, void 0, options)],
|
|
3153
4682
|
desc: [
|
|
3154
|
-
chartString(options, "diagramDesc", { v1: chartString(options, { hierarchy: "diagramHierarchy", "issue-tree": "diagramIssueTree", "linear-process": "diagramLinearProcess", "customer-journey": "diagramCustomerJourney", "circular-process": "diagramCircularProcess", "strategy-house": "diagramStrategyHouse", roadmap: "diagramRoadmap" }[options.variant]), v2: data.nodes.length, v3: edges.length }),
|
|
4683
|
+
chartString(options, "diagramDesc", { v1: chartString(options, { hierarchy: "diagramHierarchy", "issue-tree": "diagramIssueTree", "linear-process": "diagramLinearProcess", "customer-journey": "diagramCustomerJourney", "circular-process": "diagramCircularProcess", "strategy-house": "diagramStrategyHouse", roadmap: "diagramRoadmap", architecture: "diagramArchitecture" }[options.variant]), v2: data.nodes.length, v3: edges.length }),
|
|
3155
4684
|
chartString(options, "readingOrder", { v1: order }),
|
|
3156
4685
|
relationships ? chartString(options, "relationshipsSentence", { v1: relationships }) : "",
|
|
4686
|
+
data.inset ? `${data.inset.title}: ${[...(data.inset.kpis ?? []).map((kpi) => `${kpi.value} ${kpi.label}`), ...(data.inset.rows ?? []).map((row) => `${row.label} ${row.value}`)].join("; ")}.` : "",
|
|
3157
4687
|
groups ? chartString(options, "groupsSentence", { v1: groups }) : "",
|
|
3158
4688
|
lanes ? chartString(options, "lanesSentence", { v1: lanes }) : ""
|
|
3159
4689
|
].filter(Boolean).join(" ")
|
|
@@ -3247,7 +4777,7 @@ function naturalDiagramSizing(options, data, sizes, font, measure, u, measured,
|
|
|
3247
4777
|
plotHeight = 2 * u + Math.max(12 * u, maxOf([...sizes.values()].map((size2) => size2.height))) + (captions.length ? u + maxOf(captions) : 0);
|
|
3248
4778
|
} else if (authored) plotHeight = authoredPlotHeight(nodes, sizes, plot.w, u);
|
|
3249
4779
|
else if (options.variant === "circular-process") {
|
|
3250
|
-
let { diameter, radius } = circularRing(nodes, { w: plot.w, h: 1 / 0 }, u, { font, measure });
|
|
4780
|
+
let { diameter, radius } = circularRing(nodes, { w: plot.w, h: 1 / 0 }, u, { font, measure }, data.edges);
|
|
3251
4781
|
plotHeight = 2 * radius + diameter + 2 * circularLabelBand(font, u);
|
|
3252
4782
|
} else if (options.variant === "roadmap") {
|
|
3253
4783
|
let milestones = nodes.filter((node) => node.kind === "milestone"), lineH = font.size * (font.lineHeight ?? 1.2), rows = milestones.map((node) => {
|
|
@@ -3281,7 +4811,10 @@ function normalizeDiagramData(data) {
|
|
|
3281
4811
|
edges: data.edges ? [...data.edges] : [],
|
|
3282
4812
|
groups: data.groups ? [...data.groups] : [],
|
|
3283
4813
|
lanes: data.lanes ? [...data.lanes] : [],
|
|
3284
|
-
...data.key ? { key: [...data.key] } : {}
|
|
4814
|
+
...data.key ? { key: [...data.key] } : {},
|
|
4815
|
+
...data.channels ? { channels: [...data.channels] } : {},
|
|
4816
|
+
...data.callouts ? { callouts: [...data.callouts] } : {},
|
|
4817
|
+
...data.inset ? { inset: structuredClone(data.inset) } : {}
|
|
3285
4818
|
};
|
|
3286
4819
|
}
|
|
3287
4820
|
var diagramCore = {
|
|
@@ -3290,7 +4823,7 @@ var diagramCore = {
|
|
|
3290
4823
|
// other layout still reports the 480 px floor itself (layout.ts).
|
|
3291
4824
|
sizing: { ...chartSizing("diagram"), minWidth: CARD_MIN_WIDTH },
|
|
3292
4825
|
title: "Diagram",
|
|
3293
|
-
summary: "Deterministic node-edge diagrams with
|
|
4826
|
+
summary: "Deterministic node-edge diagrams with eight consulting presets, obstacle-aware routing, and structural descriptions",
|
|
3294
4827
|
layout: layoutDiagram,
|
|
3295
4828
|
defaults: {},
|
|
3296
4829
|
annotationKinds: [],
|