boardplot 0.57.0 → 0.58.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (494) hide show
  1. package/CHANGELOG.md +298 -0
  2. package/README.md +48 -14
  3. package/dist/{DiagnosticDetails-JFBBXOT2.js → DiagnosticDetails-VGSL4NJK.js} +1 -1
  4. package/dist/{ReaderBox-GCIITQCX.js → ReaderBox-MHMXIDAJ.js} +8 -7
  5. package/dist/{annotateEngine-JMZI6QEG.js → annotateEngine-753KQBNN.js} +2 -1
  6. package/dist/build-identity.json +3 -3
  7. package/dist/{chunk-5WSIH4SR.js → chunk-2CQBBN7M.js} +4 -4
  8. package/dist/{chunk-Q7VPTN5X.js → chunk-2ETK5TSA.js} +4 -4
  9. package/dist/{chunk-NO7GRVUU.js → chunk-2ETSI2EL.js} +8 -8
  10. package/dist/{chunk-4RN4OM6I.js → chunk-2GRXHWRH.js} +3 -3
  11. package/dist/{chunk-QFIRPOXR.js → chunk-2HII2B6S.js} +3 -3
  12. package/dist/{chunk-K6Y4HBK7.js → chunk-2LC2H3ZM.js} +1000 -904
  13. package/dist/{chunk-KF3ZHLHQ.js → chunk-2NX7EO7H.js} +5 -5
  14. package/dist/{chunk-D5G67OER.js → chunk-2QI2PK2O.js} +1 -1
  15. package/dist/{chunk-AFA32LHN.js → chunk-2VKQQLP7.js} +62 -36
  16. package/dist/chunk-3DOVXJ6K.js +602 -0
  17. package/dist/{chunk-XJUZC53Y.js → chunk-3E6NLODZ.js} +1 -1
  18. package/dist/{chunk-D5RAVZ5C.js → chunk-3HA4IJTO.js} +9 -8
  19. package/dist/{chunk-OTGNVAI4.js → chunk-3HPPTQEW.js} +4 -4
  20. package/dist/{chunk-TGR6PRKG.js → chunk-3KT2647F.js} +4 -2
  21. package/dist/{chunk-UBXIGE2P.js → chunk-3MFVJMP6.js} +2 -2
  22. package/dist/{chunk-JKXJWCJ5.js → chunk-3P3FKPFN.js} +116 -54
  23. package/dist/{chunk-JMOBA5ES.js → chunk-3XAJSMYD.js} +2 -2
  24. package/dist/{chunk-I65OLJ2X.js → chunk-42QKUSHJ.js} +13 -3
  25. package/dist/{chunk-Y5IKCXQR.js → chunk-44JU3VOT.js} +5 -5
  26. package/dist/{chunk-YBYV56FS.js → chunk-44K75CYE.js} +3 -3
  27. package/dist/{chunk-WKWCNS6K.js → chunk-4FNM4D57.js} +5 -5
  28. package/dist/{chunk-UD6U4EF5.js → chunk-4ROZ4TFL.js} +1 -1
  29. package/dist/{chunk-LO3AGGE3.js → chunk-4VV3KUFT.js} +5 -5
  30. package/dist/{chunk-6ZN2XJFI.js → chunk-54YO56IK.js} +1 -1
  31. package/dist/{chunk-JMGB444D.js → chunk-5ACFYNA4.js} +8 -4
  32. package/dist/{chunk-SHAAMKN7.js → chunk-5JEU6MWC.js} +18 -18
  33. package/dist/{chunk-I7KDPCC7.js → chunk-5JIB4VJA.js} +18 -10
  34. package/dist/{chunk-C5SQEYTQ.js → chunk-5OP3E2ZD.js} +153 -65
  35. package/dist/{chunk-BDCKHLUB.js → chunk-5SLBD4BT.js} +72 -304
  36. package/dist/{chunk-2BHLRHF2.js → chunk-5SVGTQTW.js} +4 -4
  37. package/dist/chunk-5U567TYU.js +23 -0
  38. package/dist/{chunk-BFDPY7JM.js → chunk-5ZLF4S7X.js} +11 -6
  39. package/dist/{chunk-73O6AOAA.js → chunk-5ZMTQATF.js} +241 -140
  40. package/dist/{chunk-5JTRCSBN.js → chunk-62BDQTO6.js} +2 -2
  41. package/dist/chunk-64K3V4VN.js +25 -0
  42. package/dist/{chunk-BM2A3IGQ.js → chunk-67YJJJIB.js} +1 -1
  43. package/dist/{chunk-TDDSWNGD.js → chunk-6DJNFT2K.js} +30 -28
  44. package/dist/{chunk-JYAZPMSA.js → chunk-6IUK6PAH.js} +7 -6
  45. package/dist/{chunk-W5SVS4B6.js → chunk-6JFQCVNN.js} +4 -4
  46. package/dist/{chunk-H2POQ4LB.js → chunk-6XPV6M3Q.js} +4 -4
  47. package/dist/{chunk-XFCBH3TI.js → chunk-6ZDSEITW.js} +3 -3
  48. package/dist/{chunk-LFX5BERN.js → chunk-72HVDLMT.js} +46 -32
  49. package/dist/chunk-75NU5RLX.js +24 -0
  50. package/dist/chunk-76GPN6AT.js +72 -0
  51. package/dist/{chunk-EFKFZNQC.js → chunk-7CAYRPJV.js} +34 -20
  52. package/dist/{chunk-EWR6WVOV.js → chunk-7GWWBHVQ.js} +6 -6
  53. package/dist/{chunk-H6EJ63QN.js → chunk-7NYUFMLJ.js} +143 -82
  54. package/dist/{chunk-D2B3KP35.js → chunk-7VWXXBTC.js} +4 -0
  55. package/dist/chunk-A65B23JK.js +113 -0
  56. package/dist/{chunk-XNV7VOIT.js → chunk-A7R6FUS6.js} +4 -4
  57. package/dist/{chunk-KIXNHDXS.js → chunk-AEVGUOPB.js} +5 -5
  58. package/dist/{chunk-IXM6BAM4.js → chunk-AHIK2N72.js} +1 -1
  59. package/dist/{chunk-I3DLERI7.js → chunk-AICO24HJ.js} +5 -2
  60. package/dist/{chunk-LSKCKGCF.js → chunk-AJGSCVVW.js} +2 -2
  61. package/dist/{chunk-RSCRIWAH.js → chunk-AL62JJTB.js} +10 -3
  62. package/dist/{chunk-CT4RFZO4.js → chunk-AN2V2LC4.js} +37 -22
  63. package/dist/{chunk-T5MBORBK.js → chunk-AOFUA5XP.js} +1 -1
  64. package/dist/{chunk-7FAO4ICF.js → chunk-BCMEGJRX.js} +2 -2
  65. package/dist/{chunk-H3EWFSWI.js → chunk-BDIKWR45.js} +43 -29
  66. package/dist/{chunk-DJBMA4FW.js → chunk-BG6AIWAK.js} +4 -6
  67. package/dist/{chunk-6XU5XGYV.js → chunk-BOT6W3VB.js} +5 -5
  68. package/dist/{chunk-DRHQG44U.js → chunk-BQBD6Q5J.js} +6 -2
  69. package/dist/{chunk-6LQKU6YN.js → chunk-BZ67BJBH.js} +11 -10
  70. package/dist/{chunk-2AJWRVZ2.js → chunk-C47POAC5.js} +1 -1
  71. package/dist/{chunk-FJKFYQ5I.js → chunk-C5OBPO4Z.js} +36 -28
  72. package/dist/{chunk-Y7Q3VEYC.js → chunk-CCAAI56H.js} +30 -10
  73. package/dist/{chunk-T3WCDDIL.js → chunk-CDUR3KWV.js} +2 -2
  74. package/dist/{chunk-WE5WVQE4.js → chunk-CMPHT2LS.js} +3 -3
  75. package/dist/{chunk-FHA3KMFC.js → chunk-CQBPNE7Z.js} +5 -1
  76. package/dist/{chunk-JSA3ESEJ.js → chunk-CR5FP5SF.js} +1 -1
  77. package/dist/{chunk-JHWDTV4K.js → chunk-D2TQX7UJ.js} +2 -2
  78. package/dist/{chunk-5TUDYKNL.js → chunk-DEANHDXU.js} +42 -29
  79. package/dist/{chunk-GHFTKVJN.js → chunk-DHGE46UK.js} +1 -1
  80. package/dist/{chunk-ZSYU6LIH.js → chunk-DIHX6NUB.js} +5 -5
  81. package/dist/{chunk-W7Q6PLT4.js → chunk-DILQ34NW.js} +37 -37
  82. package/dist/{chunk-IZRTNCJQ.js → chunk-DJKRYJP7.js} +5 -5
  83. package/dist/{chunk-43PCSBVQ.js → chunk-DKLC6QLF.js} +634 -8
  84. package/dist/{chunk-I6QGYRY4.js → chunk-DNHTMCUP.js} +2 -2
  85. package/dist/{chunk-26WNBTWB.js → chunk-DORE2RHL.js} +5 -5
  86. package/dist/{chunk-WZB6R2ZX.js → chunk-DZYTXZNS.js} +11 -3
  87. package/dist/chunk-E262NRFP.js +39 -0
  88. package/dist/{chunk-O4D27FKH.js → chunk-E5YF236N.js} +4 -1
  89. package/dist/{chunk-5H4HFRDO.js → chunk-EBUK7HJP.js} +5 -5
  90. package/dist/{chunk-YGPLUENN.js → chunk-ECBHC272.js} +132 -83
  91. package/dist/{chunk-KLQKHA3T.js → chunk-EFW43JQJ.js} +5 -5
  92. package/dist/{chunk-VM5CQ7CG.js → chunk-EHRRHSPV.js} +2 -2
  93. package/dist/{chunk-PYGEIPPH.js → chunk-EILNJQMN.js} +32 -12
  94. package/dist/{chunk-KGS5Z7SL.js → chunk-ERDKMZ7O.js} +2 -2
  95. package/dist/{chunk-AFGQXMKT.js → chunk-ETRAPN5G.js} +143 -62
  96. package/dist/{chunk-USFIDSTO.js → chunk-ETUKDEGL.js} +18 -11
  97. package/dist/chunk-F2ET5ZTT.js +49 -0
  98. package/dist/{chunk-HVX2E26J.js → chunk-F3XOBFS4.js} +9 -8
  99. package/dist/{chunk-I4NUYVP5.js → chunk-FB6X7QHA.js} +1 -1
  100. package/dist/{chunk-LW4ZQGVL.js → chunk-FGW54I23.js} +7 -8
  101. package/dist/{chunk-UCIAHSJK.js → chunk-FP5B5XIL.js} +7 -3
  102. package/dist/{chunk-QRZESG66.js → chunk-FRHQGA5Q.js} +64 -239
  103. package/dist/{chunk-YTEJYLU7.js → chunk-FRR7BJ3B.js} +2 -2
  104. package/dist/{chunk-DPUCT567.js → chunk-FVWHEM2N.js} +7 -5
  105. package/dist/{chunk-54HEIM2A.js → chunk-FWSMENKH.js} +2 -2
  106. package/dist/{chunk-F4JAGDPD.js → chunk-FWTUGNSF.js} +8 -8
  107. package/dist/{chunk-HB3TH7GY.js → chunk-FZKDZQ6U.js} +10 -6
  108. package/dist/{chunk-6EE6XEMA.js → chunk-G4FF6G3I.js} +25 -16
  109. package/dist/{chunk-72OJBDRB.js → chunk-GB6BZSTL.js} +52 -41
  110. package/dist/{chunk-QLWUFEKR.js → chunk-GCIHRRDJ.js} +8 -8
  111. package/dist/{chunk-MTCDGSYW.js → chunk-GHCU6OSE.js} +2 -2
  112. package/dist/chunk-GO66OCN7.js +24 -0
  113. package/dist/chunk-GOFS336W.js +24 -0
  114. package/dist/{chunk-JMXNXLAC.js → chunk-GQYT7G4F.js} +2 -2
  115. package/dist/{chunk-TWRFVW3J.js → chunk-GUTLXO7Q.js} +138 -89
  116. package/dist/{chunk-RRPTQGRU.js → chunk-H3VICNTN.js} +1 -1
  117. package/dist/{chunk-GC4WOLV3.js → chunk-HAG3K6PQ.js} +14 -2
  118. package/dist/{chunk-7P7D6WXR.js → chunk-HBQHSZ6S.js} +3 -3
  119. package/dist/{chunk-ZV3SNRJI.js → chunk-HTQGJQZN.js} +4 -2
  120. package/dist/{chunk-VY67Q6CJ.js → chunk-HUQRO6VF.js} +36 -33
  121. package/dist/{chunk-WSKZZ2ZB.js → chunk-I5VDW2XZ.js} +538 -503
  122. package/dist/{chunk-TMXRTYGT.js → chunk-I5VNHDPR.js} +3 -2
  123. package/dist/{chunk-M74H7QYD.js → chunk-IDXYHDQY.js} +1 -1
  124. package/dist/{chunk-IPWUBZ4P.js → chunk-IIWZJ5ZM.js} +1 -1
  125. package/dist/{chunk-HC6WHTBX.js → chunk-IPBOREIY.js} +1 -1
  126. package/dist/chunk-IU335UO7.js +27 -0
  127. package/dist/{chunk-WDAZ2MT4.js → chunk-IVDTP6SV.js} +4 -4
  128. package/dist/{chunk-BDGLMWPO.js → chunk-IXOBDDMW.js} +11 -2
  129. package/dist/{chunk-PSYPB22T.js → chunk-J4QRB6DQ.js} +5 -5
  130. package/dist/{chunk-CEMXGMQN.js → chunk-JCMGKQVS.js} +3 -3
  131. package/dist/{chunk-XR7VOF2V.js → chunk-JM7UTLF3.js} +25 -13
  132. package/dist/{chunk-VY2NPB2Q.js → chunk-JNDWRV34.js} +4 -4
  133. package/dist/{chunk-SHCW2TCA.js → chunk-JSRQTDZZ.js} +25 -23
  134. package/dist/{chunk-XYUXB5VK.js → chunk-JT3UTEWZ.js} +3 -3
  135. package/dist/{chunk-BO5EJBLH.js → chunk-JUYRDZSV.js} +63 -43
  136. package/dist/{chunk-I5ZADE2U.js → chunk-JVGL2SCN.js} +1 -1
  137. package/dist/{chunk-A6XCVOC5.js → chunk-JY4LTPOV.js} +1 -1
  138. package/dist/chunk-K7XPTQBJ.js +267 -0
  139. package/dist/{chunk-JIH52I36.js → chunk-KGBUXMFP.js} +119 -85
  140. package/dist/{chunk-2KCK63DD.js → chunk-KIE5V3DA.js} +2 -2
  141. package/dist/{chunk-A33MFWHW.js → chunk-KU4PCG4W.js} +2 -2
  142. package/dist/{chunk-MQ5EKWIG.js → chunk-KVBLTAO7.js} +5 -5
  143. package/dist/{chunk-XCROSJ2Z.js → chunk-KW4JXWHO.js} +1 -1
  144. package/dist/{chunk-BY5JGQFZ.js → chunk-KWIP5YRA.js} +4 -4
  145. package/dist/{chunk-JRRSKCGG.js → chunk-LG6M2JTH.js} +3 -3
  146. package/dist/{chunk-KUMJI5B6.js → chunk-LIE2WSB4.js} +17 -14
  147. package/dist/{chunk-KAAB2DIV.js → chunk-LJDATBPB.js} +6 -6
  148. package/dist/{chunk-EHNGPUTO.js → chunk-LMMS675D.js} +5 -5
  149. package/dist/{chunk-ANNQJWDX.js → chunk-LPKGZ664.js} +285 -34
  150. package/dist/{chunk-ZTSJ7NY6.js → chunk-LPMSGO7L.js} +3 -3
  151. package/dist/chunk-LQWINE7K.js +211 -0
  152. package/dist/{chunk-RHBQ2Q5H.js → chunk-MKMMQDIY.js} +60 -43
  153. package/dist/{chunk-RMVCKO6N.js → chunk-MQ4IEDM5.js} +458 -136
  154. package/dist/{chunk-J22ETKDJ.js → chunk-MRM4KJ2O.js} +2 -2
  155. package/dist/{chunk-Z2BDTZDT.js → chunk-MX2OZHIT.js} +97 -39
  156. package/dist/{chunk-IFURKTOL.js → chunk-MXUPMGRY.js} +2 -2
  157. package/dist/{chunk-IUVJVMKS.js → chunk-NHU26HQ7.js} +55 -32
  158. package/dist/{chunk-6KHRMK3I.js → chunk-NQVJ4FPY.js} +158 -75
  159. package/dist/chunk-NZ7FX3AE.js +65 -0
  160. package/dist/{chunk-L2XRUG4P.js → chunk-OALBVELJ.js} +5 -5
  161. package/dist/{chunk-3DUGZ7ML.js → chunk-OGZ4UPYK.js} +46 -31
  162. package/dist/{chunk-7MYJUJZV.js → chunk-OMNB27GM.js} +4 -4
  163. package/dist/{chunk-GS5UG6QD.js → chunk-OO63YP35.js} +1 -1
  164. package/dist/{chunk-RHVP62HI.js → chunk-OPYDTW5Q.js} +5 -5
  165. package/dist/{chunk-4U2WSW6F.js → chunk-OSJN7KDS.js} +65 -36
  166. package/dist/{chunk-EY4OA4OF.js → chunk-OSJXIW6I.js} +370 -785
  167. package/dist/{chunk-NRYERHEI.js → chunk-OVVE42P4.js} +5 -5
  168. package/dist/{chunk-Z257SH5U.js → chunk-OZA7HA6L.js} +1 -1
  169. package/dist/{chunk-WJQX7HBH.js → chunk-OZLKEBCD.js} +2 -2
  170. package/dist/{chunk-DYSEZVIJ.js → chunk-P6DEFCMQ.js} +2 -2
  171. package/dist/{chunk-CIDOL4FO.js → chunk-PDTIQL3B.js} +5 -5
  172. package/dist/{chunk-TQ5HHNM3.js → chunk-PJ5BYZPN.js} +2 -2
  173. package/dist/{chunk-EHQLLZCQ.js → chunk-PK7Z7WRJ.js} +59 -34
  174. package/dist/{chunk-KJLH5EHD.js → chunk-PL6NWB5U.js} +175 -110
  175. package/dist/chunk-PMT75APP.js +94 -0
  176. package/dist/{chunk-KQ2WZ6BY.js → chunk-PP6A4X55.js} +1 -1
  177. package/dist/{chunk-O7Y6RJ4D.js → chunk-PPCH3PLO.js} +11 -11
  178. package/dist/{chunk-IRXTNSZL.js → chunk-PPE6S7WU.js} +40 -22
  179. package/dist/{chunk-VT7PBGL2.js → chunk-PT7KSIEO.js} +23 -36
  180. package/dist/{chunk-GADI2DU7.js → chunk-QAUGRVRU.js} +121 -23
  181. package/dist/{chunk-2X6XY4K4.js → chunk-QMFWZG2P.js} +39 -19
  182. package/dist/{chunk-YB6QGOCO.js → chunk-QZGGCE45.js} +2 -2
  183. package/dist/{chunk-5P4MXWKP.js → chunk-R2RJQ3BM.js} +4 -4
  184. package/dist/{chunk-FAFUMSPR.js → chunk-R7HBIQ63.js} +83 -51
  185. package/dist/{chunk-76UL4CT4.js → chunk-RBNDZLYS.js} +27 -22
  186. package/dist/{chunk-XN7JDII2.js → chunk-RCSY4CT4.js} +230 -107
  187. package/dist/{chunk-OAT6FWKL.js → chunk-RHQRPJHS.js} +5 -5
  188. package/dist/chunk-RI6XQKWJ.js +26 -0
  189. package/dist/{chunk-FX5VZK5F.js → chunk-RJICOOB3.js} +14 -8
  190. package/dist/{chunk-NINK4G7U.js → chunk-RLAVNCQJ.js} +2 -2
  191. package/dist/{chunk-FERP4WS3.js → chunk-ROPPWJQB.js} +11 -10
  192. package/dist/{chunk-SSZB3VXG.js → chunk-SELOV32X.js} +102 -47
  193. package/dist/{chunk-EEBMK6T6.js → chunk-SQI4NWTQ.js} +8 -8
  194. package/dist/{chunk-2WTD3GCR.js → chunk-SRJ74CMG.js} +2 -2
  195. package/dist/{chunk-LSR3SBJ4.js → chunk-STWOURLG.js} +234 -136
  196. package/dist/{chunk-BQIADGJB.js → chunk-SWMFXSVW.js} +5 -5
  197. package/dist/{chunk-5HTGSB6Y.js → chunk-SZ5VGWDY.js} +3 -3
  198. package/dist/{chunk-EDBUVDRI.js → chunk-T26G23RS.js} +359 -86
  199. package/dist/chunk-T7GPIJ4L.js +89 -0
  200. package/dist/{chunk-LGMV7ZV4.js → chunk-TAEB3RU6.js} +5 -5
  201. package/dist/{chunk-YFI5PN5O.js → chunk-TBDIMTRD.js} +34 -11
  202. package/dist/{chunk-HDSHS2QZ.js → chunk-TFFPEWNP.js} +70 -47
  203. package/dist/{chunk-YO5UKKCQ.js → chunk-TMEUK2WS.js} +6 -2
  204. package/dist/{chunk-X5OVVMZX.js → chunk-TVOMGNFQ.js} +1 -1
  205. package/dist/{chunk-JARJP576.js → chunk-TX5FSNAU.js} +435 -29
  206. package/dist/{chunk-LUZ7HXBT.js → chunk-U52PNFPX.js} +1 -1
  207. package/dist/chunk-U74AWJ3X.js +24 -0
  208. package/dist/chunk-UC7LBW7N.js +26 -0
  209. package/dist/{chunk-V3UE3TB7.js → chunk-UCKUAKYQ.js} +2 -2
  210. package/dist/{chunk-62JZL6FW.js → chunk-UCYL3YA7.js} +56 -42
  211. package/dist/{chunk-AKJO6N4K.js → chunk-UD2GI3CS.js} +11 -4
  212. package/dist/{chunk-MOQFYJ3F.js → chunk-ULQIC76A.js} +5 -5
  213. package/dist/{chunk-HFFKN7PA.js → chunk-UY34DDUM.js} +3 -3
  214. package/dist/{chunk-2I76VFMZ.js → chunk-UYMFLWM6.js} +49 -37
  215. package/dist/{chunk-3LNVEE5Z.js → chunk-V7FV66KL.js} +1 -1
  216. package/dist/{chunk-UP4JSNDR.js → chunk-V7NUJEJE.js} +1 -1
  217. package/dist/{chunk-53OEKS4L.js → chunk-VESSIKBG.js} +6 -3
  218. package/dist/{chunk-HGPFEG2L.js → chunk-VRFJAF3R.js} +5 -5
  219. package/dist/chunk-VS2R3OGN.js +34 -0
  220. package/dist/{chunk-EEL2N4Y6.js → chunk-VS5B4J2D.js} +5 -5
  221. package/dist/{chunk-G5BUGYIL.js → chunk-W4R6SGU3.js} +192 -113
  222. package/dist/{chunk-JKOEHRGV.js → chunk-WDLWWEHZ.js} +1 -1
  223. package/dist/{chunk-IW3YUMPI.js → chunk-WFBN2HXR.js} +2 -2
  224. package/dist/{chunk-YCUNFAEE.js → chunk-WJS6SAWA.js} +238 -127
  225. package/dist/{chunk-VFLMBA2M.js → chunk-WQYNKF33.js} +19 -18
  226. package/dist/{chunk-QNLESRH6.js → chunk-WUP6C4ZD.js} +2 -2
  227. package/dist/{chunk-4JNHF6JW.js → chunk-X24WAHHV.js} +84 -40
  228. package/dist/{chunk-GKQLKUMF.js → chunk-X3UCQPVV.js} +41 -32
  229. package/dist/{chunk-TXMS7QUJ.js → chunk-X46PSAJ7.js} +6 -6
  230. package/dist/{chunk-M2OQK2FO.js → chunk-XD5XB22R.js} +2 -2
  231. package/dist/{chunk-AOIZJ7GR.js → chunk-XDIAQEYK.js} +6 -6
  232. package/dist/{chunk-7EQU2TUN.js → chunk-XFPNYHX3.js} +84 -53
  233. package/dist/{chunk-NCCDEUHD.js → chunk-XIBVAKCO.js} +1 -1
  234. package/dist/{chunk-SD6ENKTO.js → chunk-XMX4PCFL.js} +3 -3
  235. package/dist/{chunk-2HD5RY2U.js → chunk-XRRG4MBM.js} +3 -3
  236. package/dist/{chunk-Y5WHM2Q5.js → chunk-XTFO6D4L.js} +1 -1
  237. package/dist/chunk-XWRI3N5O.js +70 -0
  238. package/dist/{chunk-IVQT2E3Y.js → chunk-XXPLPSOE.js} +13 -13
  239. package/dist/{chunk-YNHPPZ7S.js → chunk-XZXZNI7A.js} +1 -1
  240. package/dist/{chunk-QZMLSK43.js → chunk-YEJZ2OYS.js} +294 -145
  241. package/dist/{chunk-GAFEN3H7.js → chunk-Z3WQXVFV.js} +2 -2
  242. package/dist/{chunk-D3PQAVFW.js → chunk-Z6DUNKFU.js} +152 -29
  243. package/dist/{chunk-FF7MV4D4.js → chunk-Z6H5ED2I.js} +1 -1
  244. package/dist/{chunk-CV3NC75L.js → chunk-ZBOOMLHD.js} +1 -1
  245. package/dist/{chunk-ZDD3MJ2H.js → chunk-ZDJ7C64T.js} +1 -1
  246. package/dist/{chunk-OKM5LYYP.js → chunk-ZGZLEUKM.js} +5 -5
  247. package/dist/{chunk-QHPJ5ZKS.js → chunk-ZHRGX225.js} +5 -5
  248. package/dist/{chunk-QYOZ46ZQ.js → chunk-ZIVCPXXL.js} +467 -650
  249. package/dist/{chunk-V62B23VC.js → chunk-ZNRSYS76.js} +8 -2
  250. package/dist/{chunk-UFZXZJJG.js → chunk-ZSLTSCTI.js} +5 -5
  251. package/dist/{chunk-NIDH22DI.js → chunk-ZSYFQSPF.js} +12 -2
  252. package/dist/cli/index.js +8 -3
  253. package/dist/{core-UNX4ZV4M.js → core-43GLGBOY.js} +5 -1
  254. package/dist/{core-T3OSZOVV.js → core-5GI3ERXO.js} +3 -1
  255. package/dist/{core-AMWCZTOT.js → core-5L7TMK7I.js} +5 -1
  256. package/dist/{core-5S5CJHBG.js → core-7TO4OVY5.js} +2 -1
  257. package/dist/{core-BJZEJ63L.js → core-BJVENHFQ.js} +3 -1
  258. package/dist/{core-A7HXVSKB.js → core-BX4MFWKC.js} +2 -1
  259. package/dist/{core-4PW4MXWR.js → core-C3KXTOIZ.js} +4 -1
  260. package/dist/{core-SKMHEA4Y.js → core-C5Y6BFLL.js} +3 -1
  261. package/dist/{core-FTQBESDS.js → core-CLUSJ2SK.js} +3 -1
  262. package/dist/{core-QM34237W.js → core-E3IN2VVH.js} +2 -1
  263. package/dist/{core-4M4RY7MX.js → core-FD67NQOV.js} +3 -1
  264. package/dist/{core-WXZJ7V7S.js → core-FDKMLRAK.js} +4 -1
  265. package/dist/{core-L3UR75IJ.js → core-FL6Z3VVX.js} +4 -1
  266. package/dist/{core-XKXDXALI.js → core-JC7JUFPY.js} +6 -1
  267. package/dist/{core-WP73P4CW.js → core-JF33TADA.js} +5 -1
  268. package/dist/{core-DMDAXVMY.js → core-JH32ZAKM.js} +2 -1
  269. package/dist/{core-GS4DXDDG.js → core-JYYZPPQV.js} +4 -1
  270. package/dist/{core-N2JEWJ7D.js → core-KJTKCV4U.js} +2 -1
  271. package/dist/{core-7XKNJM7Y.js → core-LCQPE5Y6.js} +5 -1
  272. package/dist/{core-ZACFV6XR.js → core-LHVGWE54.js} +5 -1
  273. package/dist/{core-VT35VDVS.js → core-OVSNBOCE.js} +6 -1
  274. package/dist/{core-AVA4XLQ2.js → core-PPEC236B.js} +2 -1
  275. package/dist/{core-QFAVWFI3.js → core-QTJZDK5H.js} +2 -1
  276. package/dist/{core-VWYXK2R3.js → core-R3YZCOUZ.js} +4 -1
  277. package/dist/{core-OFPPRHYY.js → core-RIBW5XU4.js} +3 -1
  278. package/dist/{core-MAW4S3KA.js → core-RJFILBWL.js} +5 -1
  279. package/dist/{core-FCSA74RT.js → core-RWSXEKTE.js} +3 -1
  280. package/dist/{core-WPEYRK6Y.js → core-SOPPZLEH.js} +4 -1
  281. package/dist/{core-EMSJRGSE.js → core-TBUZCXLX.js} +2 -1
  282. package/dist/{core-OBPTBKX6.js → core-TZ5QLTAX.js} +2 -1
  283. package/dist/{core-JDZDBTID.js → core-U7E5W4MY.js} +2 -1
  284. package/dist/{core-ZSERZGK6.js → core-UBNVSL44.js} +3 -1
  285. package/dist/{core-WNT6ZMRO.js → core-UDRD4WIU.js} +2 -1
  286. package/dist/{core-VRVL6LIM.js → core-UVJZ4HY2.js} +3 -1
  287. package/dist/{core-7TTM4KRP.js → core-X7WWYQH4.js} +3 -1
  288. package/dist/{core-D2OIGYC7.js → core-XP56X47I.js} +4 -1
  289. package/dist/{core-CCB3IXGD.js → core-XQG54CYG.js} +3 -1
  290. package/dist/{dataTable-7IO546LM.js → dataTable-U7W4I6IF.js} +7 -2
  291. package/dist/{engine-US3N6UCH.js → engine-O5V26MGR.js} +23 -18
  292. package/dist/fixtures.js +2 -1
  293. package/dist/flags-BVLSAXT3.js +10 -0
  294. package/dist/{fontTables-ZPZQ6IR3.js → fontTables-JUW7ZTQY.js} +3 -1
  295. package/dist/geo/dach.js +1 -1
  296. package/dist/geo/de-states.js +1 -1
  297. package/dist/geo/eu27.js +1 -1
  298. package/dist/geo/europe.js +1 -1
  299. package/dist/geo/index.js +2 -2
  300. package/dist/geo/us-states.js +1 -1
  301. package/dist/geo/world.js +1 -1
  302. package/dist/index.js +27 -20
  303. package/dist/{main-2UWKGUHR.js → main-35GS47XC.js} +50 -119
  304. package/dist/mcp/server.js +121 -118
  305. package/dist/react/bar.js +5 -1
  306. package/dist/react/bartable.js +3 -1
  307. package/dist/react/box.js +3 -1
  308. package/dist/react/bullet.js +4 -1
  309. package/dist/react/butterfly.js +5 -1
  310. package/dist/react/choropleth.js +3 -1
  311. package/dist/react/cohort.js +3 -1
  312. package/dist/react/column.js +5 -1
  313. package/dist/react/combo.js +5 -1
  314. package/dist/react/creative.js +4 -1
  315. package/dist/react/diagram.js +3 -1
  316. package/dist/react/dimswitch.js +6 -1
  317. package/dist/react/dot.js +4 -1
  318. package/dist/react/export.js +29 -18
  319. package/dist/react/funnel.js +4 -1
  320. package/dist/react/gantt.js +3 -1
  321. package/dist/react/grid.js +6 -1
  322. package/dist/react/heatmap.js +3 -1
  323. package/dist/react/histogram.js +6 -1
  324. package/dist/react/index.js +92 -85
  325. package/dist/react/kpi.js +4 -1
  326. package/dist/react/likert.js +6 -1
  327. package/dist/react/line.js +4 -1
  328. package/dist/react/mekko.js +5 -1
  329. package/dist/react/pareto.js +6 -1
  330. package/dist/react/pie.js +4 -1
  331. package/dist/react/prepare.js +35 -22
  332. package/dist/react/pvm.js +6 -1
  333. package/dist/react/pyramid.js +5 -1
  334. package/dist/react/sankey.js +3 -1
  335. package/dist/react/scatter.js +3 -1
  336. package/dist/react/slope.js +4 -1
  337. package/dist/react/sparkline.js +4 -1
  338. package/dist/react/spec.js +17 -13
  339. package/dist/react/status.js +3 -1
  340. package/dist/react/story.js +3 -2
  341. package/dist/react/table.js +4 -1
  342. package/dist/react/theme.js +5 -3
  343. package/dist/react/tilemap.js +3 -1
  344. package/dist/react/treemap.js +3 -1
  345. package/dist/react/variance.js +5 -1
  346. package/dist/react/waffle.js +3 -1
  347. package/dist/react/waterfall.js +5 -1
  348. package/dist/{resvg-VB7S5HRF.js → resvg-ZYEZTSUO.js} +3 -1
  349. package/dist/rows.js +2 -2
  350. package/dist/{rowsModule-DYDVHBAX.js → rowsModule-H2S6WW4D.js} +1 -1
  351. package/dist/{schema-YDZCGL56.js → schema-2R32F6AW.js} +1 -3
  352. package/dist/{schema-A2XUZUCV.js → schema-2TPGJGVR.js} +1 -3
  353. package/dist/{schema-MD22QYZU.js → schema-47BG2TZA.js} +1 -3
  354. package/dist/{schema-HEB6ZDI5.js → schema-56MOEOVR.js} +1 -3
  355. package/dist/{schema-K4V4PYBO.js → schema-5MSR4LNN.js} +1 -3
  356. package/dist/{schema-NOBNFD2F.js → schema-5RIYEWE6.js} +1 -3
  357. package/dist/{schema-PHIHMDVB.js → schema-A26ZNGTZ.js} +1 -3
  358. package/dist/{schema-OXO2XY4Y.js → schema-ALBF6V7Y.js} +1 -3
  359. package/dist/{schema-F2Q6MH7W.js → schema-BA6WP5YZ.js} +1 -3
  360. package/dist/{schema-G5KSSI5W.js → schema-CBL2SMVR.js} +1 -3
  361. package/dist/{schema-WFGDVBJK.js → schema-CWKGLDSR.js} +1 -3
  362. package/dist/{schema-DHMMGDTI.js → schema-DBIQFL56.js} +1 -3
  363. package/dist/{schema-626QXX4G.js → schema-DL7V6NN2.js} +1 -3
  364. package/dist/{schema-FC6J6KZC.js → schema-DUVJMFKQ.js} +1 -3
  365. package/dist/{schema-LGLQBRC4.js → schema-ECJERHKF.js} +1 -2
  366. package/dist/{schema-4JRNXEZF.js → schema-EDSEKZDJ.js} +1 -3
  367. package/dist/{schema-I44IDRGD.js → schema-ESR6ZIK4.js} +1 -3
  368. package/dist/{schema-FSYDLMGD.js → schema-F7TWGLRZ.js} +1 -3
  369. package/dist/{schema-JCU6LTYD.js → schema-FGB6IGZM.js} +1 -3
  370. package/dist/{schema-MGETMQYC.js → schema-FKGGTM4Z.js} +1 -2
  371. package/dist/{schema-6PL46VXZ.js → schema-FU2AFIEE.js} +1 -3
  372. package/dist/{schema-XIHAKX3B.js → schema-JNJFCYBM.js} +1 -1
  373. package/dist/{schema-6V5K3J2V.js → schema-JYZ4RF6S.js} +1 -3
  374. package/dist/{schema-GXOG4MXL.js → schema-K7F6TEDK.js} +1 -2
  375. package/dist/{schema-NMIYKGHE.js → schema-KAK6DZX4.js} +1 -3
  376. package/dist/{schema-XRSORYBI.js → schema-MOKWIGF7.js} +1 -3
  377. package/dist/{schema-3KMU5737.js → schema-MQT6BMNK.js} +1 -3
  378. package/dist/{schema-JJWORI7D.js → schema-MR3BPPQR.js} +1 -3
  379. package/dist/{schema-IFTIMTS3.js → schema-OPXZYIW7.js} +1 -3
  380. package/dist/{schema-UXWKA3PI.js → schema-PV7JGX5H.js} +1 -3
  381. package/dist/{schema-CNJ4Y6CT.js → schema-PWPQF5RC.js} +1 -3
  382. package/dist/{schema-WBOPCTPC.js → schema-PYQEUC5P.js} +1 -3
  383. package/dist/{schema-J4HCSD5C.js → schema-QPIC5MAG.js} +6 -2
  384. package/dist/{schema-IUY7VYHJ.js → schema-R42VXFIS.js} +1 -3
  385. package/dist/{schema-WX2RS4OU.js → schema-TVUJNEX7.js} +1 -3
  386. package/dist/{schema-FGE5YK3S.js → schema-Y4TI2T3T.js} +1 -3
  387. package/dist/{schema-MQB6CE5V.js → schema-ZU2EU2VP.js} +1 -3
  388. package/dist/{specValidation-XGELWQUU.js → specValidation-2NHJT7TQ.js} +3 -1
  389. package/dist/theme.js +4 -3
  390. package/dist/{themeShapeRules-PW4BQHKL.js → themeShapeRules-G7UZX6GJ.js} +1 -1
  391. package/dist/types/core/annotate.d.ts +27 -2
  392. package/dist/types/core/annotateArms.d.ts +3 -1
  393. package/dist/types/core/annotateTargets.d.ts +4 -0
  394. package/dist/types/core/annotationOrigin.d.ts +13 -0
  395. package/dist/types/core/axis.d.ts +2 -2
  396. package/dist/types/core/charts/band/stacks.d.ts +7 -1
  397. package/dist/types/core/charts/column/model.d.ts +13 -0
  398. package/dist/types/core/charts/combo/layout.d.ts +7 -0
  399. package/dist/types/core/charts/gantt/calendar.d.ts +4 -0
  400. package/dist/types/core/charts/grid/normalize.d.ts +5 -0
  401. package/dist/types/core/charts/grid/schema.d.ts +2 -2
  402. package/dist/types/core/charts/pareto/layout.d.ts +2 -0
  403. package/dist/types/core/charts/pvm/types.d.ts +1 -0
  404. package/dist/types/core/charts/scatter/clamp.d.ts +2 -1
  405. package/dist/types/core/charts/scatter/model.d.ts +5 -0
  406. package/dist/types/core/charts/scatter/valueLines.d.ts +3 -1
  407. package/dist/types/core/charts/table/resolve.d.ts +8 -3
  408. package/dist/types/core/charts/table/view.d.ts +24 -1
  409. package/dist/types/core/claims/browser.d.ts +2 -0
  410. package/dist/types/core/claims/ids.d.ts +38 -0
  411. package/dist/types/core/deferred.d.ts +1 -0
  412. package/dist/types/core/doc/diagnostics.d.ts +3 -2
  413. package/dist/types/core/formatSpec.d.ts +33 -14
  414. package/dist/types/core/frame.d.ts +25 -58
  415. package/dist/types/core/frameText.d.ts +203 -0
  416. package/dist/types/core/geometry.d.ts +2 -0
  417. package/dist/types/core/label/categoryRow.d.ts +19 -2
  418. package/dist/types/core/label/solver.d.ts +23 -2
  419. package/dist/types/core/normalize/shared.d.ts +12 -2
  420. package/dist/types/core/notes.d.ts +15 -2
  421. package/dist/types/core/reading.d.ts +12 -1
  422. package/dist/types/core/request.d.ts +1 -1
  423. package/dist/types/core/schema/capability.d.ts +12 -0
  424. package/dist/types/core/seriesIdentity.d.ts +4 -1
  425. package/dist/types/core/sizing.d.ts +32 -1
  426. package/dist/types/core/structureCounts.d.ts +3 -1
  427. package/dist/types/core/theme.d.ts +33 -4
  428. package/dist/types/core/themeRules.d.ts +2 -0
  429. package/dist/types/core/types/annotations.d.ts +74 -4
  430. package/dist/types/core/types/options.d.ts +35 -3
  431. package/dist/types/core/types/scene.d.ts +30 -2
  432. package/dist/types/core/types/table.d.ts +6 -0
  433. package/dist/types/core/types/theme.d.ts +23 -0
  434. package/dist/types/react/TableChart.d.ts +5 -0
  435. package/dist/validate.js +13 -6
  436. package/docs/TELEMETRY.md +2 -2
  437. package/docs/manual.md +252 -62
  438. package/docs/reference/bar.md +12 -4
  439. package/docs/reference/bartable.md +2 -2
  440. package/docs/reference/box.md +8 -4
  441. package/docs/reference/bullet.md +9 -5
  442. package/docs/reference/butterfly.md +10 -5
  443. package/docs/reference/choropleth.md +3 -5
  444. package/docs/reference/cohort.md +1 -1
  445. package/docs/reference/column.md +18 -4
  446. package/docs/reference/combo.md +10 -5
  447. package/docs/reference/creative.md +3 -7
  448. package/docs/reference/diagram.md +1 -1
  449. package/docs/reference/dimswitch.md +23 -88
  450. package/docs/reference/dot.md +9 -5
  451. package/docs/reference/fixtures.md +37 -1
  452. package/docs/reference/funnel.md +9 -5
  453. package/docs/reference/gantt.md +8 -15
  454. package/docs/reference/grid.md +5 -2
  455. package/docs/reference/heatmap.md +10 -6
  456. package/docs/reference/kpi.md +1 -1
  457. package/docs/reference/likert.md +9 -4
  458. package/docs/reference/line.md +18 -5
  459. package/docs/reference/mekko.md +10 -5
  460. package/docs/reference/options.md +17 -13
  461. package/docs/reference/pareto.md +8 -4
  462. package/docs/reference/pie.md +9 -5
  463. package/docs/reference/pvm.md +9 -5
  464. package/docs/reference/pyramid.md +8 -4
  465. package/docs/reference/react.md +5 -5
  466. package/docs/reference/sankey.md +2 -2
  467. package/docs/reference/scatter.md +8 -4
  468. package/docs/reference/slope.md +9 -5
  469. package/docs/reference/sparkline.md +1 -1
  470. package/docs/reference/status.md +1 -1
  471. package/docs/reference/table.md +33 -114
  472. package/docs/reference/theme.md +12 -4
  473. package/docs/reference/tilemap.md +2 -4
  474. package/docs/reference/treemap.md +1 -1
  475. package/docs/reference/variance.md +12 -6
  476. package/docs/reference/waffle.md +1 -1
  477. package/docs/reference/warnings.md +1077 -0
  478. package/docs/reference/waterfall.md +16 -4
  479. package/docs/use-cases.md +25 -13
  480. package/llms.txt +19 -6
  481. package/package.json +18 -3
  482. package/dist/chunk-5RHP7YTL.js +0 -24
  483. package/dist/chunk-6VU2XI3W.js +0 -89
  484. package/dist/chunk-6WJOHZPW.js +0 -26
  485. package/dist/chunk-FL3FQ2YA.js +0 -27
  486. package/dist/chunk-G5CELEUR.js +0 -26
  487. package/dist/chunk-M4SPKUZE.js +0 -7
  488. package/dist/chunk-OF7FMGH5.js +0 -24
  489. package/dist/chunk-S2TSXUYP.js +0 -24
  490. package/dist/chunk-TKERVBJ3.js +0 -23
  491. package/dist/chunk-VMGTNB6H.js +0 -25
  492. package/dist/chunk-WZL4EEBS.js +0 -11
  493. package/dist/chunk-YJGFT63R.js +0 -27
  494. package/dist/chunk-ZNX5J7D7.js +0 -47
@@ -6,35 +6,38 @@ import {
6
6
  } from "./chunk-OQQMDSCC.js";
7
7
  import {
8
8
  compileIcon
9
- } from "./chunk-M2OQK2FO.js";
9
+ } from "./chunk-XD5XB22R.js";
10
10
  import {
11
11
  yearSpan,
12
12
  yearSpanFromLabels
13
- } from "./chunk-3LNVEE5Z.js";
13
+ } from "./chunk-V7FV66KL.js";
14
14
  import {
15
15
  SHARES_OF_ONE_WHOLE_FIX,
16
16
  valuelessFix
17
- } from "./chunk-JMGB444D.js";
17
+ } from "./chunk-5ACFYNA4.js";
18
18
  import {
19
19
  isCategoryAlongY,
20
20
  valueLineHasTargetExtras
21
21
  } from "./chunk-CDZHNLO6.js";
22
22
  import {
23
+ BRACKET_TICK,
23
24
  indicator100LabelRect,
24
25
  lineLabelGutterLines,
25
26
  namedLineText,
26
27
  pruneOrphanAnnotationArms
27
- } from "./chunk-O4D27FKH.js";
28
+ } from "./chunk-E5YF236N.js";
28
29
  import {
29
30
  parseTimeText
30
31
  } from "./chunk-GDOW2KNP.js";
31
32
  import {
32
33
  PRIORITY,
33
34
  anchorValueBox,
35
+ arrowLook,
34
36
  arrowSeats,
37
+ calloutArrowLook,
38
+ calloutArrowReach,
35
39
  composedTextRole,
36
40
  computedTextRole,
37
- defaultAnnotationId,
38
41
  finishCalloutHeads,
39
42
  formatDate,
40
43
  leaderCrossesLabel,
@@ -42,15 +45,17 @@ import {
42
45
  leaderHeightOf,
43
46
  leaderTerminus,
44
47
  leadersOffAnchorValues,
45
- rectsOverlap,
46
48
  solveLabels,
47
- unionRect,
48
49
  valueEdgeToward
49
- } from "./chunk-WSKZZ2ZB.js";
50
+ } from "./chunk-I5VDW2XZ.js";
50
51
  import {
51
52
  recordPartNeed,
52
53
  wrapFootnote
53
- } from "./chunk-WZB6R2ZX.js";
54
+ } from "./chunk-DZYTXZNS.js";
55
+ import {
56
+ annotationRef,
57
+ defaultAnnotationId
58
+ } from "./chunk-F2ET5ZTT.js";
54
59
  import {
55
60
  differenceExample,
56
61
  exampleSpec,
@@ -63,7 +68,7 @@ import {
63
68
  roundedNumber,
64
69
  specUnitKind,
65
70
  withChartMarks
66
- } from "./chunk-D3PQAVFW.js";
71
+ } from "./chunk-Z6DUNKFU.js";
67
72
  import {
68
73
  PERCENTAGE_POINTS,
69
74
  autoDecimals,
@@ -77,32 +82,35 @@ import {
77
82
  typicalDecimals
78
83
  } from "./chunk-MSYTF3DZ.js";
79
84
  import {
80
- arrowHeadPath,
81
- arrowShaftEnd,
82
85
  colorblindPaint,
83
86
  dashToken,
84
87
  emphasisWeight,
88
+ inflate,
85
89
  leaderPath,
86
90
  microType,
87
91
  ovalPath,
92
+ rectContains,
93
+ rectsOverlap,
94
+ segmentSpanInRect,
88
95
  signedFillPaint,
89
96
  strokeToken,
90
- typeWidthClass
91
- } from "./chunk-JARJP576.js";
97
+ typeWidthClass,
98
+ unionRect
99
+ } from "./chunk-TX5FSNAU.js";
92
100
  import {
93
101
  publishDeferred
94
- } from "./chunk-DRHQG44U.js";
102
+ } from "./chunk-BQBD6Q5J.js";
95
103
  import {
96
104
  NormalizeError
97
- } from "./chunk-FX5VZK5F.js";
105
+ } from "./chunk-RJICOOB3.js";
106
+ import {
107
+ wrapText
108
+ } from "./chunk-UIHGGWES.js";
98
109
  import {
99
110
  maxOf,
100
111
  minOf,
101
112
  pushAll
102
113
  } from "./chunk-WYJEOMNY.js";
103
- import {
104
- wrapText
105
- } from "./chunk-UIHGGWES.js";
106
114
 
107
115
  // src/core/strings/annotate.ts
108
116
  var EN = {
@@ -118,7 +126,7 @@ var EN = {
118
126
  }, { chartString: chartString2 } = chartStrings(EN, DE);
119
127
 
120
128
  // src/core/annotateArms.ts
121
- var ARM_CLEARANCE = 10, ARM_STEP = 8, MAX_LIFTS = 40, ARM_ARROW = 5, ARM_START_GAP = 12, ARM_END_GAP = 12, ARM_END_GAP_ON_ARM = 4, ON_ARM_CLEARANCE = 3, ON_ARM_TOP = 41, MIN_LEG = 16, INSET_ARM = 22, INSET_GAP = 6, INSET_MIN_LEG = 4, INSET_TIP_GAP = 4, STRAIGHT_ARROW_HEAD = 10, STRAIGHT_ARROW_PROBE = 4, OVAL_RX = 0.72, OVAL_RY = 1;
129
+ var ARM_CLEARANCE = 10, ARM_STEP = 8, MAX_LIFTS = 40, ARM_ARROW = 5, armLook = (theme) => arrowLook(theme, { size: ARM_ARROW }), ARM_START_GAP = 12, LEVEL_POINT_R = 3, ARM_END_GAP = 12, ARM_END_GAP_ON_ARM = 4, ON_ARM_CLEARANCE = 3, ON_ARM_TOP = 41, MIN_LEG = 16, INSET_ARM = 22, INSET_GAP = 6, INSET_MIN_LEG = 4, INSET_TIP_GAP = 4, STRAIGHT_ARROW_HEAD = 10, STRAIGHT_ARROW_PROBE = 4, OVAL_RX = 0.72, OVAL_RY = 1;
122
130
  function ownAnchorMark(occupiedOwner, occupiedKind, occupiedPart, anchorOwner) {
123
131
  let sameCategory = anchorOwner.categoryId !== void 0 && occupiedOwner.categoryId === anchorOwner.categoryId;
124
132
  return occupiedKind === "mark" && sameCategory && (anchorOwner.seriesId === void 0 && occupiedOwner.seriesId === void 0 || (occupiedPart === "segment" || occupiedPart === "bar") && (anchorOwner.seriesId === void 0 || occupiedOwner.seriesId === anchorOwner.seriesId));
@@ -136,8 +144,13 @@ function claimSegment(occupied, annId, x0, y0, x1, y1, part) {
136
144
  part
137
145
  );
138
146
  }
139
- function claimArrowHead(occupied, annId, x, y) {
140
- occupied.claim({ x: x - 5, y: y - 5, w: 10, h: 10 }, "annotation", { annotationId: annId }, "arrowHead");
147
+ function claimArrowHead(occupied, annId, x, y, look, angle) {
148
+ if (!look.standard) {
149
+ occupied.claim({ x: x - 5, y: y - 5, w: 10, h: 10 }, "annotation", { annotationId: annId }, "arrowHead");
150
+ return;
151
+ }
152
+ let ux = Math.cos(angle), uy = Math.sin(angle), bx = x - ux * look.depth, by = y - uy * look.depth, xs = [x, bx - uy * look.half, bx + uy * look.half], ys = [y, by + ux * look.half, by - ux * look.half], x0 = Math.min(...xs), y0 = Math.min(...ys);
153
+ occupied.claim({ x: x0 - 1, y: y0 - 1, w: Math.max(...xs) - x0 + 2, h: Math.max(...ys) - y0 + 2 }, "annotation", { annotationId: annId }, "arrowHead");
141
154
  }
142
155
  function claimSlantedLine(occupied, annId, p, q) {
143
156
  let length = Math.hypot(q.x - p.x, q.y - p.y) || 1, nx = (q.y - p.y) / length * 3, ny = (p.x - q.x) / length * 3;
@@ -186,7 +199,7 @@ function legRuns(occupied, x, top, bottom, anchor) {
186
199
  from > y && runs.push([y, Math.min(from, bottom)]), y = Math.max(y, to);
187
200
  return y < bottom && runs.push([y, bottom]), runs;
188
201
  }
189
- function pushCagrPlacement(pass, annId, text, computed, font, candidates, nodeIds, derivation) {
202
+ function pushCagrPlacement(pass, annId, text, computed, font, candidates, nodeIds, derivation, kind = "cagr") {
190
203
  pass.labelRequests.push({
191
204
  id: `annotation:${annId}`,
192
205
  kind: "annotation",
@@ -200,64 +213,64 @@ function pushCagrPlacement(pass, annId, text, computed, font, candidates, nodeId
200
213
  candidates
201
214
  }), pass.placed.push({
202
215
  id: annId,
203
- kind: "cagr",
216
+ kind,
204
217
  computedText: computed,
205
218
  nodeIds,
206
219
  labelId: `annotation:${annId}`,
207
220
  ...derivation ? { derivation } : {}
208
221
  });
209
222
  }
210
- function drawLiftedCagrArm(pass, a, b, text, annId, computed, derivation) {
223
+ function drawLiftedCagrArm(pass, a, b, text, annId, computed, derivation, kind = "cagr") {
211
224
  let { input, nodes, nid } = pass, { font, tsize } = measureArmLabel(input, text), buriedA = buried(input.occupied, a), buriedB = buried(input.occupied, b), outward = a.x <= b.x ? 1 : -1;
212
225
  buriedA && (a = { ...a, x: besideLabels(input, a, -outward) }), buriedB && (b = { ...b, x: besideLabels(input, b, outward) });
213
- let leftAnchor = a.x <= b.x ? a : b, rightAnchor = a.x <= b.x ? b : a, spanX0 = leftAnchor.x, spanX1 = rightAnchor.x, startY = laneTop(input.occupied, input.plot.y, spanX0, leftAnchor.y, leftAnchor.owner, input.laneCeiling), endY = laneTop(input.occupied, input.plot.y, spanX1, rightAnchor.y, rightAnchor.owner, input.laneCeiling), direction = a.x <= b.x ? 1 : -1, fromY = direction === 1 ? startY : endY, toY = direction === 1 ? endY : startY, onArm = input.cagrLabelOnArm === !0, endGap = onArm ? ARM_END_GAP_ON_ARM : ARM_END_GAP, endpointCeiling = Math.min(startY, endY) - ARM_CLEARANCE - 8, labelX = (spanX0 + spanX1) / 2 - tsize.width / 2, labelAt = (y) => onArm ? { x: labelX, y: y - tsize.height / 2, w: tsize.width, h: tsize.height } : { x: labelX, y: y - 4 - tsize.height, w: tsize.width, h: tsize.height }, armFloor = onArm ? Math.max(input.plot.y + tsize.height / 2 + 2, (input.bandCeiling ?? input.plot.y) + ON_ARM_TOP) : input.plot.y + tsize.height + 6, armY = Math.max(endpointCeiling, armFloor), bandOvershoot = 0;
226
+ let leftAnchor = a.x <= b.x ? a : b, rightAnchor = a.x <= b.x ? b : a, spanX0 = leftAnchor.x, spanX1 = rightAnchor.x, startY = laneTop(input.occupied, input.plot.y, spanX0, leftAnchor.y, leftAnchor.owner, input.laneCeiling), endY = laneTop(input.occupied, input.plot.y, spanX1, rightAnchor.y, rightAnchor.owner, input.laneCeiling), direction = a.x <= b.x ? 1 : -1, fromY = direction === 1 ? startY : endY, toY = direction === 1 ? endY : startY, onArm = input.cagrLabelOnArm === !0 || kind !== "cagr", endGap = onArm ? ARM_END_GAP_ON_ARM : ARM_END_GAP, endpointCeiling = Math.min(startY, endY) - ARM_CLEARANCE - 8, labelX = (spanX0 + spanX1) / 2 - tsize.width / 2, labelAt = (y) => onArm ? { x: labelX, y: y - tsize.height / 2, w: tsize.width, h: tsize.height } : { x: labelX, y: y - 4 - tsize.height, w: tsize.width, h: tsize.height }, armFloor = onArm ? Math.max(input.plot.y + tsize.height / 2 + 2, (input.bandCeiling ?? input.plot.y) + ON_ARM_TOP) : input.plot.y + tsize.height + 6, armY = Math.max(endpointCeiling, armFloor), bandOvershoot = 0;
214
227
  for (let i = 0; i < MAX_LIFTS; i++) {
215
228
  let armRect = { x: spanX0, y: armY - 3, w: spanX1 - spanX0, h: 6 }, labelRect = labelAt(armY), blocked = input.occupied.hits(armRect, 2) || input.occupied.hits(labelRect, 2);
216
229
  if (armY <= endpointCeiling && !blocked) break;
217
230
  blocked && bandOvershoot === 0 && labelRect.y < input.plot.y && (bandOvershoot = input.plot.y - labelRect.y), armY -= ARM_STEP;
218
231
  }
219
232
  bandOvershoot > 0 && labelAt(armY).y < input.plot.y && pass.addLegDeficit(bandOvershoot);
220
- let stubs = a.lineAnchored && b.lineAnchored && (!a.series && !b.series || buriedA || buriedB);
233
+ let stubs = a.lineAnchored && b.lineAnchored && (!a.series && !b.series || buriedA || buriedB), look = armLook(input.theme);
221
234
  if (!stubs) {
222
- let legFloor = Math.min(fromY - ARM_START_GAP, toY - endGap - arrowShaftEnd(ARM_ARROW, strokeToken(input.theme, "rule"))) - MIN_LEG;
235
+ let legFloor = Math.min(fromY - ARM_START_GAP, toY - endGap - look.shaftEnd) - MIN_LEG;
223
236
  if (armY > legFloor) {
224
237
  let candidate = Math.max(legFloor, armFloor), candidateArm = { x: spanX0, y: candidate - 3, w: spanX1 - spanX0, h: 6 }, candidateLabel = labelAt(candidate);
225
- candidate < armY && candidate <= endpointCeiling && !input.occupied.hits(candidateArm, 2) && !input.occupied.hits(candidateLabel, 2) && (armY = candidate), armY > legFloor && pass.addLegDeficit(armY - legFloor);
238
+ candidate < armY && candidate <= endpointCeiling && !input.occupied.hits(candidateArm, 2) && !input.occupied.hits(candidateLabel, 2) && (armY = candidate), armY > legFloor && pass.addLegDeficit((kind === "cagr" ? armY : Math.max(armY, armFloor)) - legFloor);
226
239
  }
227
240
  }
228
241
  let pathId = nid("arm"), headId = nid("arrowHead");
229
242
  if (stubs) {
230
- let armEnd = b.x - direction * arrowShaftEnd(ARM_ARROW, strokeToken(input.theme, "rule"));
243
+ let armEnd = b.x - direction * look.shaftEnd;
231
244
  nodes.push({
232
245
  t: "path",
233
246
  id: pathId,
234
247
  d: `M${a.x} ${armY + 10}L${a.x} ${armY}L${armEnd} ${armY}`,
235
248
  stroke: { token: "ink" },
236
- width: strokeToken(input.theme, "rule"),
249
+ width: look.stroke,
237
250
  owner: { annotationId: annId },
238
251
  part: "arm"
239
252
  }), nodes.push({
240
253
  t: "path",
241
254
  id: headId,
242
- d: arrowHeadPath({ x: b.x, y: armY }, direction === 1 ? 0 : Math.PI, ARM_ARROW),
255
+ d: look.head({ x: b.x, y: armY }, direction === 1 ? 0 : Math.PI),
243
256
  fill: { token: "ink" },
244
257
  owner: { annotationId: annId },
245
258
  part: "arrowHead"
246
- }), claimSegment(input.occupied, annId, a.x, armY + 10, a.x, armY, "leg"), claimSegment(input.occupied, annId, a.x, armY, armEnd, armY, "arm"), claimArrowHead(input.occupied, annId, b.x, armY);
259
+ }), claimSegment(input.occupied, annId, a.x, armY + 10, a.x, armY, "leg"), claimSegment(input.occupied, annId, a.x, armY, armEnd, armY, "arm"), claimArrowHead(input.occupied, annId, b.x, armY, look, direction === 1 ? 0 : Math.PI);
247
260
  } else {
248
- let reach = (anchor) => anchor.y - (anchor.lineAnchored ? 6 : 4), legStartY = buriedA ? reach(a) : fromY - ARM_START_GAP, tipY = buriedB ? reach(b) : toY - endGap, legEndY = tipY - arrowShaftEnd(ARM_ARROW, strokeToken(input.theme, "rule")), up = legRuns(input.occupied, a.x, armY, legStartY, a).reverse().map(([top, bottom]) => `M${a.x} ${bottom}L${a.x} ${top}`).join(""), down = legRuns(input.occupied, b.x, armY, legEndY, b).map(([top, bottom], index) => `${index === 0 ? "" : `M${b.x} ${top}`}L${b.x} ${bottom}`).join("");
261
+ let reach = (anchor) => anchor.y - (anchor.lineAnchored ? 6 : 4), legStartY = buriedA ? reach(a) : fromY - ARM_START_GAP, tipY = buriedB ? reach(b) : toY - endGap, legEndY = tipY - look.shaftEnd, up = legRuns(input.occupied, a.x, armY, legStartY, a).reverse().map(([top, bottom]) => `M${a.x} ${bottom}L${a.x} ${top}`).join(""), down = legRuns(input.occupied, b.x, armY, legEndY, b).map(([top, bottom], index) => `${index === 0 ? "" : `M${b.x} ${top}`}L${b.x} ${bottom}`).join("");
249
262
  if (nodes.push({
250
263
  t: "path",
251
264
  id: pathId,
252
265
  d: `${up}L${b.x} ${armY}${down}`,
253
266
  stroke: { token: "ink" },
254
- width: strokeToken(input.theme, "rule"),
267
+ width: look.stroke,
255
268
  owner: { annotationId: annId },
256
269
  part: "arm"
257
270
  }), nodes.push({
258
271
  t: "path",
259
272
  id: headId,
260
- d: arrowHeadPath({ x: b.x, y: tipY }, Math.PI / 2, ARM_ARROW),
273
+ d: look.head({ x: b.x, y: tipY }, Math.PI / 2),
261
274
  fill: { token: "ink" },
262
275
  owner: { annotationId: annId },
263
276
  part: "arrowHead"
@@ -265,13 +278,18 @@ function drawLiftedCagrArm(pass, a, b, text, annId, computed, derivation) {
265
278
  let seat0 = labelX - ON_ARM_CLEARANCE, seat1 = labelX + tsize.width + ON_ARM_CLEARANCE;
266
279
  seat0 > Math.min(a.x, b.x) && claimSegment(input.occupied, annId, Math.min(a.x, b.x), armY, seat0, armY, "arm"), seat1 < Math.max(a.x, b.x) && claimSegment(input.occupied, annId, seat1, armY, Math.max(a.x, b.x), armY, "arm");
267
280
  } else claimSegment(input.occupied, annId, a.x, armY, b.x, armY, "arm");
268
- claimSegment(input.occupied, annId, b.x, armY, b.x, legEndY, "leg"), onArm ? input.occupied.claim({ x: b.x - 3, y: tipY - 5, w: 6, h: 5 }, "annotation", { annotationId: annId }, "arrowHead") : claimArrowHead(input.occupied, annId, b.x, tipY);
281
+ claimSegment(input.occupied, annId, b.x, armY, b.x, legEndY, "leg"), onArm ? input.occupied.claim(
282
+ look.standard ? { x: b.x - look.half, y: tipY - look.depth, w: look.half * 2, h: look.depth } : { x: b.x - 3, y: tipY - 5, w: 6, h: 5 },
283
+ "annotation",
284
+ { annotationId: annId },
285
+ "arrowHead"
286
+ ) : claimArrowHead(input.occupied, annId, b.x, tipY, look, Math.PI / 2);
269
287
  }
270
288
  pushCagrPlacement(pass, annId, text, computed, font, [
271
289
  ...onArm && !stubs ? [{ slot: "onArm", rect: labelAt(armY), penalty: 0 }] : [],
272
290
  { slot: "aboveArm", rect: { x: labelX, y: armY - 4 - tsize.height, w: tsize.width, h: tsize.height }, penalty: onArm ? 1 : 0 },
273
291
  { slot: "belowArm", rect: { x: labelX, y: armY + 4, w: tsize.width, h: tsize.height }, penalty: onArm ? 2 : 1 }
274
- ], [pathId, headId], derivation);
292
+ ], [pathId, headId], derivation, kind);
275
293
  }
276
294
  function drawStraightCagrArrow(pass, a, b, text, annId, computed, derivation) {
277
295
  let { input, nodes, nid } = pass, horizontal = input.valueAxis === "horizontal", giveWay = (reason) => (pass.warn?.("cagr-arrow-no-room", `cagr '${annId}': ${reason}, so it draws as a bracket`, "keep shape 'arrow' for a span with room over its marks, or leave it out for the bracket"), !1);
@@ -291,9 +309,9 @@ function drawStraightCagrArrow(pass, a, b, text, annId, computed, derivation) {
291
309
  }
292
310
  if (!route)
293
311
  return pass.addLegDeficit(ry * 2), giveWay("no straight line clears the marks");
294
- let [p, q] = route;
295
- if (Math.hypot(q.x - p.x, q.y - p.y) / 2 < rx + STRAIGHT_ARROW_HEAD) return giveWay("the span is too short for the oval");
296
- let width2 = strokeToken(input.theme, "rule"), angle = Math.atan2(q.y - p.y, q.x - p.x), shaftEnd = arrowShaftEnd(STRAIGHT_ARROW_HEAD, width2), centre = middle(p, q), owner = { annotationId: annId }, lineId = nid("arm"), headId = nid("arrowHead"), ovalId = nid("oval");
312
+ let [p, q] = route, look = arrowLook(input.theme, { size: STRAIGHT_ARROW_HEAD });
313
+ if (Math.hypot(q.x - p.x, q.y - p.y) / 2 < rx + (look.standard ? look.depth + look.minShaft / 2 : STRAIGHT_ARROW_HEAD)) return giveWay("the span is too short for the oval");
314
+ let width2 = look.stroke, angle = Math.atan2(q.y - p.y, q.x - p.x), shaftEnd = look.shaftEnd, centre = middle(p, q), owner = { annotationId: annId }, lineId = nid("arm"), headId = nid("arrowHead"), ovalId = nid("oval");
297
315
  return nodes.push({
298
316
  t: "line",
299
317
  id: lineId,
@@ -305,7 +323,7 @@ function drawStraightCagrArrow(pass, a, b, text, annId, computed, derivation) {
305
323
  width: width2,
306
324
  owner,
307
325
  part: "arm"
308
- }), nodes.push({ t: "path", id: headId, d: arrowHeadPath(q, angle, STRAIGHT_ARROW_HEAD), fill: { token: "ink" }, owner, part: "arrowHead" }), nodes.push({ t: "path", id: ovalId, d: ovalPath(centre, rx, ry), fill: { token: "background" }, stroke: { token: "ink" }, width: width2, owner, part: "oval" }), claimSlantedLine(input.occupied, annId, p, q), claimArrowHead(input.occupied, annId, q.x, q.y), input.occupied.claim(ovalRect(centre), "annotation", owner, "oval"), pushCagrPlacement(pass, annId, text, computed, font, [
326
+ }), nodes.push({ t: "path", id: headId, d: look.head(q, angle), fill: { token: "ink" }, owner, part: "arrowHead" }), nodes.push({ t: "path", id: ovalId, d: ovalPath(centre, rx, ry), fill: { token: "background" }, stroke: { token: "ink" }, width: width2, owner, part: "oval" }), claimSlantedLine(input.occupied, annId, p, q), claimArrowHead(input.occupied, annId, q.x, q.y, look, angle), input.occupied.claim(ovalRect(centre), "annotation", owner, "oval"), pushCagrPlacement(pass, annId, text, computed, font, [
309
327
  { slot: "onArm", rect: { x: centre.x - tsize.width / 2, y: centre.y - tsize.height / 2, w: tsize.width, h: tsize.height }, penalty: 0, overRules: !0 }
310
328
  ], [lineId, headId, ovalId], derivation), !0;
311
329
  }
@@ -355,28 +373,28 @@ function drawShiftedCagrArm(pass, a, b, text, annId, computed, derivation, parts
355
373
  if (armX >= endpointFloor && !input.occupied.hits(armRect, 2) && (inset || !input.occupied.hits(labelRect, 2))) break;
356
374
  armX += ARM_STEP;
357
375
  }
358
- let legFloor = Math.max(fromX + startGap, toX + endGap + arrowShaftEnd(ARM_ARROW, strokeToken(input.theme, "rule"))) + (inset ? INSET_MIN_LEG : MIN_LEG);
376
+ let look = armLook(input.theme), legFloor = Math.max(fromX + startGap, toX + endGap + look.shaftEnd) + (inset ? INSET_MIN_LEG : MIN_LEG);
359
377
  if (armX < legFloor) {
360
378
  let candidate = Math.min(legFloor, plotRight - 3), candidateArm = { x: candidate - 3, y: spanY0, w: 6, h: Math.max(spanY1 - spanY0, 1) }, labelAt = (x) => ({ x, y: (spanY0 + spanY1) / 2 - tsize.height / 2, w: tsize.width, h: tsize.height }), labelFree = (rect) => rect.x >= input.plot.x && rect.x + rect.w <= plotRight && !input.occupied.hits(rect, 2);
361
379
  candidate > armX && candidate >= endpointFloor && !input.occupied.hits(candidateArm, 2) && (labelFree(labelAt(candidate + 4)) || labelFree(labelAt(candidate - 4 - tsize.width))) && (armX = candidate), armX < legFloor && pass.addLegDeficit(legFloor - armX);
362
380
  }
363
- let pathId = nid("arm"), headId = nid("arrowHead"), legEndX = toX + endGap + arrowShaftEnd(ARM_ARROW, strokeToken(input.theme, "rule")), d = `M${fromX + startGap} ${a.y}L${armX} ${a.y}L${armX} ${b.y}L${legEndX} ${b.y}`;
381
+ let pathId = nid("arm"), headId = nid("arrowHead"), legEndX = toX + endGap + look.shaftEnd, d = `M${fromX + startGap} ${a.y}L${armX} ${a.y}L${armX} ${b.y}L${legEndX} ${b.y}`;
364
382
  nodes.push({
365
383
  t: "path",
366
384
  id: pathId,
367
385
  d,
368
386
  stroke: { token: "ink" },
369
- width: strokeToken(input.theme, "rule"),
387
+ width: look.stroke,
370
388
  owner: { annotationId: annId },
371
389
  part: "arm"
372
390
  }), nodes.push({
373
391
  t: "path",
374
392
  id: headId,
375
- d: arrowHeadPath({ x: toX + endGap, y: b.y }, Math.PI, ARM_ARROW),
393
+ d: look.head({ x: toX + endGap, y: b.y }, Math.PI),
376
394
  fill: { token: "ink" },
377
395
  owner: { annotationId: annId },
378
396
  part: "arrowHead"
379
- }), claimSegment(input.occupied, annId, fromX + startGap, a.y, armX, a.y, "leg"), claimSegment(input.occupied, annId, armX, a.y, armX, b.y, "arm"), claimSegment(input.occupied, annId, armX, b.y, legEndX, b.y, "leg"), claimArrowHead(input.occupied, annId, toX + endGap, b.y);
397
+ }), claimSegment(input.occupied, annId, fromX + startGap, a.y, armX, a.y, "leg"), claimSegment(input.occupied, annId, armX, a.y, armX, b.y, "arm"), claimSegment(input.occupied, annId, armX, b.y, legEndX, b.y, "leg"), claimArrowHead(input.occupied, annId, toX + endGap, b.y, look, Math.PI);
380
398
  let midY = (spanY0 + spanY1) / 2;
381
399
  if (inset) {
382
400
  pushInsetCagrPlacement(pass, annId, text, computed, font, armX, midY, parts, [pathId, headId], derivation, [spanY0, spanY1]);
@@ -400,16 +418,16 @@ function drawVerticalLevelDiff(pass, a, b, text, annId, computed, derivation) {
400
418
  (anchor) => anchor.lineAnchored && Math.abs(sx - anchor.x) < 0.5 && claim.kind === "mark" && !claim.polygon && claim.owner.seriesId === anchor.owner.seriesId && anchor.x >= claim.rect.x - 2 && anchor.x <= claim.rect.x + claim.rect.w + 2 && anchor.y >= claim.rect.y - 2 && anchor.y <= claim.rect.y + claim.rect.h + 2
401
419
  )), x = candidatesX.find(stripFree) ?? (a.x + b.x) / 2, lineId = nid("diffLine");
402
420
  pushGuide(pass, "leader0", annId, { x: a.x, y: y0 }, { x, y: y0 }), pushGuide(pass, "leader1", annId, { x: b.x, y: y1 }, { x, y: y1 });
403
- let headTipY = y1 + (y1 > y0 ? -1 : 1), shaftEndY = headTipY + (y1 > y0 ? -1 : 1) * -arrowShaftEnd(ARM_ARROW, strokeToken(input.theme, "rule"));
421
+ let look = armLook(input.theme), onPoint = look.standard && b.lineAnchored && Math.abs(x - b.x) < 0.5, headTipY = y1 + (y1 > y0 ? -1 : 1) * (onPoint ? (b.markerRadius ?? LEVEL_POINT_R) + look.tipGap : 1), shaftEndY = headTipY - (y1 > y0 ? 1 : -1) * look.shaftEnd;
404
422
  nodes.push({
405
423
  t: "line",
406
424
  id: lineId,
407
425
  x1: x,
408
- y1: y0,
426
+ y1: y0 + (look.standard && a.lineAnchored && Math.abs(x - a.x) < 0.5 ? (y1 > y0 ? 1 : -1) * ((a.markerRadius ?? LEVEL_POINT_R) + look.tipGap) : 0),
409
427
  x2: x,
410
428
  y2: shaftEndY,
411
429
  stroke: { token: "ink" },
412
- width: strokeToken(input.theme, "rule"),
430
+ width: look.stroke,
413
431
  owner: { annotationId: annId },
414
432
  part: "diffArrow"
415
433
  });
@@ -417,7 +435,7 @@ function drawVerticalLevelDiff(pass, a, b, text, annId, computed, derivation) {
417
435
  nodes.push({
418
436
  t: "path",
419
437
  id: headId,
420
- d: arrowHeadPath({ x, y: headTipY }, angle, ARM_ARROW),
438
+ d: look.head({ x, y: headTipY }, angle),
421
439
  fill: { token: "ink" },
422
440
  owner: { annotationId: annId },
423
441
  part: "arrowHead"
@@ -498,16 +516,16 @@ function drawHorizontalLevelDiff(pass, a, b, text, annId, computed, derivation)
498
516
  2
499
517
  ).every((claim) => claim.part === "referenceLine"), y = candidatesY.find(stripFree) ?? (a.y + b.y) / 2, lineId = nid("diffLine");
500
518
  pushGuide(pass, "leader0", annId, { x: x0, y: a.y }, { x: x0, y }), pushGuide(pass, "leader1", annId, { x: x1, y: b.y }, { x: x1, y });
501
- let headTipX = x1 + (x1 > x0 ? -1 : 1), shaftEndX = headTipX + (x1 > x0 ? -1 : 1) * -arrowShaftEnd(ARM_ARROW, strokeToken(input.theme, "rule"));
519
+ let look = armLook(input.theme), onPoint = look.standard && b.lineAnchored && Math.abs(y - b.y) < 0.5, headTipX = x1 + (x1 > x0 ? -1 : 1) * (onPoint ? (b.markerRadius ?? LEVEL_POINT_R) + look.tipGap : 1), shaftEndX = headTipX - (x1 > x0 ? 1 : -1) * look.shaftEnd;
502
520
  nodes.push({
503
521
  t: "line",
504
522
  id: lineId,
505
- x1: x0,
523
+ x1: x0 + (look.standard && a.lineAnchored && Math.abs(y - a.y) < 0.5 ? (x1 > x0 ? 1 : -1) * ((a.markerRadius ?? LEVEL_POINT_R) + look.tipGap) : 0),
506
524
  y1: y,
507
525
  x2: shaftEndX,
508
526
  y2: y,
509
527
  stroke: { token: "ink" },
510
- width: strokeToken(input.theme, "rule"),
528
+ width: look.stroke,
511
529
  owner: { annotationId: annId },
512
530
  part: "diffArrow"
513
531
  });
@@ -515,7 +533,7 @@ function drawHorizontalLevelDiff(pass, a, b, text, annId, computed, derivation)
515
533
  nodes.push({
516
534
  t: "path",
517
535
  id: headId,
518
- d: arrowHeadPath({ x: headTipX, y }, angle, ARM_ARROW),
536
+ d: look.head({ x: headTipX, y }, angle),
519
537
  fill: { token: "ink" },
520
538
  owner: { annotationId: annId },
521
539
  part: "arrowHead"
@@ -558,35 +576,37 @@ function drawInsetBarGap(pass, a, b, text, annId, computed, parts, derivation) {
558
576
  if (a.value < 0 || b.value < 0 || Math.abs(a.x - b.x) < 1) return !1;
559
577
  let [short, long] = a.x < b.x ? [a, b] : [b, a], longBar = anchorBar(input.occupied, long), shortBar = anchorBar(input.occupied, short);
560
578
  if (!longBar || !shortBar) return !1;
561
- let y = short.y, dropFrom = long.y < y ? longBar.y + longBar.h : longBar.y, dropStrip = { x: long.x - 1, y: Math.min(dropFrom, y) + 1, w: 2, h: Math.max(Math.abs(y - dropFrom) - 2, 0) };
562
- if (dropStrip.h > 0 && input.occupied.hitsWhich(dropStrip, 0).some((claim) => claim.kind === "mark" && claim.owner.seriesId !== short.owner.seriesId)) return !1;
563
- let rule = strokeToken(input.theme, "rule"), tipX = short.x + INSET_TIP_GAP, regular = { family: input.theme.type.family, ...input.theme.type.label }, font = { ...regular, weight: emphasisWeight(input.theme) }, runs = [{ text: `${parts.lead}\xA0` }, { text: parts.value, weight: font.weight }], w = input.measure(`${parts.lead}\xA0`, regular).width + input.measure(parts.value, font).width, h = input.measure(text, font).height;
564
- if (long.x - tipX < w + 4 * ARM_ARROW) return !1;
579
+ let y = short.y, dropFrom = long.y < y ? longBar.y + longBar.h : longBar.y, dropStrip = { x: long.x - 1, y: Math.min(dropFrom, y) + 1, w: 2, h: Math.max(Math.abs(y - dropFrom) - 2, 0) }, own = (owner) => [short, long].some((end) => owner.categoryId === end.owner.categoryId && owner.seriesId === end.owner.seriesId);
580
+ if (dropStrip.h > 0 && input.occupied.hitsWhich(dropStrip, 0).some((claim) => claim.kind === "mark" && (parts ? claim.owner.seriesId !== short.owner.seriesId : !own(claim.owner)))) return !1;
581
+ let look = armLook(input.theme), atEnd = (end, bar) => Math.abs(end.x - (bar.x + bar.w)) < 1;
582
+ if (!parts && (!atEnd(short, shortBar) || !atEnd(long, longBar))) return !1;
583
+ let shortValue = parts ? void 0 : anchorValueBox(input.occupied, { x: short.x, y: short.y - 1, w: 0, h: 2 }, short.owner, 24), shortEdge = shortValue && shortValue.x >= short.x - 2 ? shortValue.x + shortValue.w : short.x, towardLong = !parts && b === long, shortX = shortEdge + (look.standard && !parts ? look.tipGap : INSET_TIP_GAP), tipX = towardLong ? long.x - 1 : shortX, tailX = towardLong ? shortX : long.x, regular = { family: input.theme.type.family, ...input.theme.type.label }, font = { ...regular, weight: emphasisWeight(input.theme) }, runs = parts ? [{ text: `${parts.lead}\xA0` }, { text: parts.value, weight: font.weight }] : [{ text, weight: font.weight }], w = parts ? input.measure(`${parts.lead}\xA0`, regular).width + input.measure(parts.value, font).width : input.measure(text, font).width, h = input.measure(text, font).height;
584
+ if (long.x - shortX < w + (look.standard ? 2 * look.depth + 8 : 4 * ARM_ARROW) || !parts && input.occupied.hitsWhich({ x: shortX, y: y - 4, w: long.x - shortX, h: 8 }, 0).some((claim) => claim.kind === "mark" || claim.kind === "annotation" && claim.owner.annotationId !== annId)) return !1;
565
585
  pushGuide(pass, "leader0", annId, { x: long.x, y: dropFrom }, { x: long.x, y });
566
- let lineId = nid("diffLine");
586
+ let lineId = nid("diffLine"), direction = Math.sign(tipX - tailX);
567
587
  nodes.push({
568
588
  t: "line",
569
589
  id: lineId,
570
- x1: long.x,
590
+ x1: tailX,
571
591
  y1: y,
572
- x2: tipX + arrowShaftEnd(ARM_ARROW, rule),
592
+ x2: tipX - direction * look.shaftEnd,
573
593
  y2: y,
574
594
  stroke: { token: "ink" },
575
- width: rule,
595
+ width: look.stroke,
576
596
  owner: { annotationId: annId },
577
597
  part: "diffArrow"
578
598
  });
579
- let headId = nid("arrowHead");
599
+ let headId = nid("arrowHead"), angle = direction > 0 ? 0 : Math.PI;
580
600
  nodes.push({
581
601
  t: "path",
582
602
  id: headId,
583
- d: arrowHeadPath({ x: tipX, y }, Math.PI, ARM_ARROW),
603
+ d: look.head({ x: tipX, y }, angle),
584
604
  fill: { token: "ink" },
585
605
  owner: { annotationId: annId },
586
606
  part: "arrowHead"
587
607
  });
588
- let seat = { x: (tipX + long.x) / 2 - w / 2, y: y - h / 2, w, h };
589
- return input.occupied.claim({ x: tipX, y: y - 2, w: Math.max(seat.x - 2 - tipX, 0), h: 4 }, "annotation", { annotationId: annId }), input.occupied.claim({ x: seat.x + seat.w + 2, y: y - 2, w: Math.max(long.x - seat.x - seat.w - 2, 0), h: 4 }, "annotation", { annotationId: annId }), claimArrowHead(input.occupied, annId, tipX, y), labelRequests.push({
608
+ let [left, right] = [Math.min(tipX, tailX), Math.max(tipX, tailX)], seat = { x: (left + right) / 2 - w / 2, y: y - h / 2, w, h };
609
+ return input.occupied.claim({ x: left, y: y - 2, w: Math.max(seat.x - 2 - left, 0), h: 4 }, "annotation", { annotationId: annId }), input.occupied.claim({ x: seat.x + seat.w + 2, y: y - 2, w: Math.max(right - seat.x - seat.w - 2, 0), h: 4 }, "annotation", { annotationId: annId }), claimArrowHead(input.occupied, annId, tipX, y, look, angle), labelRequests.push({
590
610
  id: `annotation:${annId}`,
591
611
  kind: "annotation",
592
612
  role: computedTextRole(text, computed),
@@ -606,12 +626,15 @@ function drawInsetBarGap(pass, a, b, text, annId, computed, parts, derivation) {
606
626
  id: annId,
607
627
  kind: "diff",
608
628
  computedText: computed,
609
- tone: parts.value.startsWith("\u2212") || parts.value.startsWith("-") ? "bad" : "neutral",
629
+ tone: (parts?.value ?? computed).startsWith("\u2212") || (parts?.value ?? computed).startsWith("-") ? "bad" : "neutral",
610
630
  nodeIds: [lineId, headId],
611
631
  labelId: `annotation:${annId}`,
612
632
  ...derivation ? { derivation } : {}
613
633
  }), !0;
614
634
  }
635
+ function drawSpanBracket(pass, a, b, text, annId, kind, computed, derivation) {
636
+ drawLiftedCagrArm(pass, a, b, text, annId, computed, derivation, kind);
637
+ }
615
638
  function drawCagrArm(pass, a, b, text, annId, computed, derivation, parts, shape) {
616
639
  if (pass.input.comparisonLayout) {
617
640
  shape === "arrow" && pass.warn?.("cagr-arrow-no-room", `cagr '${annId}': this chart lays out its comparisons itself, so it keeps its own form`), pass.input.comparisonLayout.draw(pass, a, b, text, annId, "cagr", computed, derivation);
@@ -625,13 +648,13 @@ function drawCagrArm(pass, a, b, text, annId, computed, derivation, parts, shape
625
648
  drawLiftedCagrArm(pass, a, b, text, annId, computed, derivation);
626
649
  }
627
650
  }
628
- function drawDiffArm(pass, a, b, text, annId, computed, derivation, parts) {
651
+ function drawDiffArm(pass, a, b, text, annId, computed, derivation, parts, placement) {
629
652
  if (pass.input.comparisonLayout) {
630
653
  pass.input.comparisonLayout.draw(pass, a, b, text, annId, "diff", computed, derivation);
631
654
  return;
632
655
  }
633
656
  if (pass.input.valueAxis === "horizontal") {
634
- if (parts && drawInsetBarGap(pass, a, b, text, annId, computed, parts, derivation)) return;
657
+ if ((parts || placement !== "label") && drawInsetBarGap(pass, a, b, text, annId, computed, parts, derivation)) return;
635
658
  drawHorizontalLevelDiff(pass, a, b, text, annId, computed, derivation);
636
659
  return;
637
660
  }
@@ -817,6 +840,22 @@ function resolveSpan(ctx, from, to) {
817
840
  let start = ctx.input.resolveCategoryBand(from), end = ctx.input.resolveCategoryBand(to);
818
841
  return !start || !end ? (pushWarn(ctx.warnings, ctx.id, "bad-anchor", `band '${ctx.id}': unresolvable category span`), null) : categorySpanRect(start, end, plot);
819
842
  }
843
+ function corridorEdgeRects(ann, input) {
844
+ if (ann.style !== "corridor" || scenarioPaint(ann.scenario).pattern !== "outline") return [];
845
+ let mapper = valueMapper(input), bounds = finitePair(ann.low, ann.high);
846
+ if (!mapper || !bounds) return [];
847
+ let plot = input.bandPlot ?? input.plot, span = plot;
848
+ if (ann.from !== void 0 || ann.to !== void 0) {
849
+ if (ann.from === void 0 || ann.to === void 0) return [];
850
+ let from = input.resolveCategoryBand?.(ann.from), to = input.resolveCategoryBand?.(ann.to);
851
+ if (!from || !to) return [];
852
+ span = categorySpanRect(from, to, plot);
853
+ }
854
+ let rect = valueBandRect(span, bounds.low, bounds.high, mapper, plot);
855
+ if (!rect) return [];
856
+ let width2 = strokeToken(input.theme, "hair");
857
+ return mapper.axis === "y" ? [rect.y, rect.y + rect.h].map((y) => ({ x: rect.x, y: y - width2 / 2, w: rect.w, h: width2 })) : [rect.x, rect.x + rect.w].map((x) => ({ x: x - width2 / 2, y: rect.y, w: width2, h: rect.h }));
858
+ }
820
859
  function placeCorridorOrTolerance(ctx, ann, role) {
821
860
  let mapper = valueMapper(ctx.input);
822
861
  if (!mapper) {
@@ -1192,7 +1231,7 @@ function placeEraShade(ctx, ann, rect) {
1192
1231
  ctx.placed.push({ id: ctx.id, kind: "band", computedText: text, nodeIds: [bandId], labelId });
1193
1232
  }
1194
1233
  function placeEraBracket(ctx, ann, rect, bandPlot) {
1195
- let text = ann.label ?? "", labelId = ann.label ? `annotation:${ctx.id}` : void 0, font = { family: ctx.input.theme.type.family, ...ctx.input.theme.type.axis }, size = ctx.input.measure(text || "X", font), bracketY = bandPlot.y - ctx.input.plot.y >= size.height + 12 ? bandPlot.y - 7 : bandPlot.y + size.height + 6, left = rect.x, right = rect.x + rect.w, arrowInset = Math.min(5, rect.w / 2), bracketIds = [], lineId = ctx.nid("bracket");
1234
+ let text = ann.label ?? "", labelId = ann.label ? `annotation:${ctx.id}` : void 0, font = { family: ctx.input.theme.type.family, ...ctx.input.theme.type.axis }, size = ctx.input.measure(text || "X", font), bracketY = bandPlot.y - ctx.input.plot.y >= size.height + 12 ? bandPlot.y - 7 : bandPlot.y + size.height + 6, left = rect.x, right = rect.x + rect.w, look = arrowLook(ctx.input.theme, { size: 5 }), arrowInset = Math.min(look.standard ? look.shaftEnd : 5, rect.w / 2), bracketIds = [], lineId = ctx.nid("bracket");
1196
1235
  bracketIds.push(lineId), ctx.nodes.push({
1197
1236
  t: "line",
1198
1237
  id: lineId,
@@ -1201,7 +1240,7 @@ function placeEraBracket(ctx, ann, rect, bandPlot) {
1201
1240
  x2: right - arrowInset,
1202
1241
  y2: bracketY,
1203
1242
  stroke: { token: "ink" },
1204
- width: strokeToken(ctx.input.theme, "rule"),
1243
+ width: look.stroke,
1205
1244
  owner: { annotationId: ctx.id },
1206
1245
  part: "bandBracket"
1207
1246
  });
@@ -1213,7 +1252,7 @@ function placeEraBracket(ctx, ann, rect, bandPlot) {
1213
1252
  bracketIds.push(headId), ctx.nodes.push({
1214
1253
  t: "path",
1215
1254
  id: headId,
1216
- d: arrowHeadPath({ x, y: bracketY }, angle, 5),
1255
+ d: look.head({ x, y: bracketY }, angle),
1217
1256
  fill: { token: "ink" },
1218
1257
  owner: { annotationId: ctx.id },
1219
1258
  part: "bandArrowHead"
@@ -1352,6 +1391,132 @@ function buildExtendedEraBandCandidates(plan, input, forHeadroomEstimate = !1) {
1352
1391
  return out;
1353
1392
  }
1354
1393
 
1394
+ // src/core/annotateDrawing.ts
1395
+ var DRAWING_ARROW_HEAD = 6, POINT_MARKER_R = 3, CUT_CLEARANCE = 2, CLAIM_HALF = 1, MIN_STRETCH = 4, TEXT_GAP = 8, BOX_BAND_PAD = 2;
1396
+ function resolveDrawingPoint(input, point) {
1397
+ if (typeof point != "object" || point === null || !("value" in point)) {
1398
+ let found = input.resolve(point);
1399
+ return found ? { x: found.x, y: found.y, mark: found.lineAnchored ? found.markerRadius ?? POINT_MARKER_R : 0 } : { error: "unresolvable anchor" };
1400
+ }
1401
+ let mapper = valueMapper(input);
1402
+ if (!mapper) return { error: `this chart has no value scale, so it has no place for value ${point.value}` };
1403
+ let mapped = mapper.scale(point.value), plot = input.bandPlot ?? input.plot, [low, high] = mapper.axis === "y" ? [plot.y, plot.y + plot.h] : [plot.x, plot.x + plot.w];
1404
+ if (!Number.isFinite(mapped) || mapped < low - 0.5 || mapped > high + 0.5) return { error: `value ${point.value} lies outside the plot; a drawing does not extend the axis` };
1405
+ let category = categoryPosition(input, point.categoryId);
1406
+ if (category === void 0) return { error: "unresolvable category" };
1407
+ let band = categorySpan(input, point.categoryId);
1408
+ return { ...mapper.axis === "y" ? { x: category, y: mapped } : { x: mapped, y: category }, ...band ? { band } : {} };
1409
+ }
1410
+ function categorySpan(input, categoryId) {
1411
+ let band = (input.resolveCategoryBand ?? input.drawingCategoryBand)?.(categoryId);
1412
+ if (band)
1413
+ return isCategoryAlongY(band) ? [band.y, band.y + band.h] : [band.x, band.x + band.w];
1414
+ }
1415
+ function boxCorners(input, from, to) {
1416
+ if ("error" in from || "error" in to || !from.band && !to.band) return [from, to];
1417
+ let alongX = valueMapper(input)?.axis === "y", reach = (point) => {
1418
+ let at = alongX ? point.x : point.y;
1419
+ return point.band ? [point.band[0] - BOX_BAND_PAD, point.band[1] + BOX_BAND_PAD] : [at, at];
1420
+ }, [a, b] = [reach(from), reach(to)], low = Math.min(a[0], b[0]), high = Math.max(a[1], b[1]);
1421
+ return alongX ? [{ x: low, y: from.y }, { x: high, y: to.y }] : [{ x: from.x, y: low }, { x: to.x, y: high }];
1422
+ }
1423
+ function categoryPosition(input, categoryId) {
1424
+ let axis = valueMapper(input).axis;
1425
+ if (input.resolveCategoryBand) {
1426
+ let band = input.resolveCategoryBand(categoryId);
1427
+ return band ? isCategoryAlongY(band) ? band.y + band.h / 2 : band.x + band.w / 2 : void 0;
1428
+ }
1429
+ let found = input.resolve(categoryId);
1430
+ return found ? axis === "y" ? found.x : found.y : void 0;
1431
+ }
1432
+ function drawingFailure(kind, from, to) {
1433
+ if ("error" in from) return `from: ${from.error}`;
1434
+ if ("error" in to) return `to: ${to.error}`;
1435
+ let dx = Math.abs(to.x - from.x), dy = Math.abs(to.y - from.y);
1436
+ if (kind === "box" ? dx < 1 || dy < 1 : Math.hypot(dx, dy) < 1) return kind === "box" ? "from and to must differ in both directions to make a box" : "from and to are one point";
1437
+ }
1438
+ function textSeats(at, size) {
1439
+ let seat = (slot, x, y, penalty) => ({ slot, rect: { x, y, w: size.w, h: size.h }, penalty, overColumns: !0, needsBacking: !0 }), { w, h } = size;
1440
+ return [
1441
+ seat("at", at.x - w / 2, at.y - h / 2, 0),
1442
+ seat("above", at.x - w / 2, at.y - h - TEXT_GAP, 1),
1443
+ seat("below", at.x - w / 2, at.y + TEXT_GAP, 2),
1444
+ seat("right", at.x + TEXT_GAP, at.y - h / 2, 3),
1445
+ seat("left", at.x - w - TEXT_GAP, at.y - h / 2, 4)
1446
+ ];
1447
+ }
1448
+ function claimStroke(occupied, a, b, id) {
1449
+ let dx = b.x - a.x, dy = b.y - a.y, box = { x: Math.min(a.x, b.x) - CLAIM_HALF, y: Math.min(a.y, b.y) - CLAIM_HALF, w: Math.abs(dx) + 2 * CLAIM_HALF, h: Math.abs(dy) + 2 * CLAIM_HALF };
1450
+ if (Math.abs(dx) < 0.5 || Math.abs(dy) < 0.5) {
1451
+ occupied.claim(box, "annotation", { annotationId: id }, "drawing");
1452
+ return;
1453
+ }
1454
+ let length = Math.hypot(dx, dy), nx = -dy / length * CLAIM_HALF, ny = dx / length * CLAIM_HALF;
1455
+ occupied.claim(box, "annotation", { annotationId: id }, "drawing", [
1456
+ { x: a.x + nx, y: a.y + ny },
1457
+ { x: b.x + nx, y: b.y + ny },
1458
+ { x: b.x - nx, y: b.y - ny },
1459
+ { x: a.x - nx, y: a.y - ny }
1460
+ ]);
1461
+ }
1462
+ function drawDrawing(ann, id, from, to, theme, occupied, nodes, nid, cuts, toMark, short) {
1463
+ let look = ann.kind === "arrow" ? arrowLook(theme, { size: DRAWING_ARROW_HEAD }) : void 0, width2 = look?.stroke ?? strokeToken(theme, "rule"), owner = { annotationId: id }, paint = { stroke: { token: "ink" }, width: width2, owner, part: "drawing", ...ann.dashed ? { dash: dashToken(theme, "reference") } : {} }, run = (a, b) => {
1464
+ let nodeId = nid("drawing");
1465
+ return nodes.push({ t: "line", id: nodeId, x1: a.x, y1: a.y, x2: b.x, y2: b.y, ...paint }), nodeId;
1466
+ };
1467
+ if (ann.kind === "box") {
1468
+ let [left, right] = [Math.min(from.x, to.x), Math.max(from.x, to.x)], [top, bottom] = [Math.min(from.y, to.y), Math.max(from.y, to.y)], cap = width2 / 2;
1469
+ return [
1470
+ [{ x: left - cap, y: top }, { x: right + cap, y: top }],
1471
+ [{ x: right, y: top }, { x: right, y: bottom }],
1472
+ [{ x: right + cap, y: bottom }, { x: left - cap, y: bottom }],
1473
+ [{ x: left, y: bottom }, { x: left, y: top }]
1474
+ ].map(([a, b]) => (claimStroke(occupied, a, b, id), run(a, b)));
1475
+ }
1476
+ if (!look)
1477
+ return claimStroke(occupied, from, to, id), [run(from, to)];
1478
+ let full = Math.hypot(to.x - from.x, to.y - from.y), ux = (to.x - from.x) / full, uy = (to.y - from.y) / full, pull = look.standard && toMark !== void 0 ? Math.min(toMark + look.tipGap, full / 2) : 0, tip = { x: to.x - ux * pull, y: to.y - uy * pull }, length = full - pull;
1479
+ if (look.standard && length - look.depth < look.minShaft && (short?.(Math.max(0, length - look.depth), look.minShaft, length - look.depth < 1), length - look.depth < 1))
1480
+ return [];
1481
+ claimStroke(occupied, from, tip, id);
1482
+ let shaft = Math.min(look.shaftEnd, length), shaftId = run(from, { x: tip.x - ux * shaft, y: tip.y - uy * shaft }), headId = nid("drawingHead");
1483
+ return nodes.push({ t: "path", id: headId, d: look.head(tip, Math.atan2(uy, ux)), fill: { token: "ink" }, owner, part: "drawing" }), cuts.set(shaftId, { headId, tip }), [shaftId, headId];
1484
+ }
1485
+ function stretchesClearOfText(occupied, a, b) {
1486
+ let box = { 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) }, spans = occupied.hitsWhich(box, CUT_CLEARANCE).filter((claim) => claim.kind === "label").flatMap((claim) => {
1487
+ let span = segmentSpanInRect(a, b, claim.rect, CUT_CLEARANCE);
1488
+ return span ? [span] : [];
1489
+ }).sort((u, v) => u[0] - v[0]);
1490
+ if (spans.length === 0) return;
1491
+ let length = Math.hypot(b.x - a.x, b.y - a.y), at = (t) => ({ x: a.x + (b.x - a.x) * t, y: a.y + (b.y - a.y) * t }), stretches = [], from = 0;
1492
+ for (let [t0, t1] of spans)
1493
+ t0 > from && (t0 - from) * length >= MIN_STRETCH && stretches.push([at(from), at(t0)]), from = Math.max(from, t1);
1494
+ return from < 1 && (1 - from) * length >= MIN_STRETCH && stretches.push([at(from), b]), stretches;
1495
+ }
1496
+ function cutDrawingsAroundText(nodes, placed, occupied, warnings, cuts) {
1497
+ let warned = /* @__PURE__ */ new Set();
1498
+ for (let i = nodes.length - 1; i >= 0; i--) {
1499
+ let node = nodes[i];
1500
+ if (node.t !== "line" || node.part !== "drawing") continue;
1501
+ let a = { x: node.x1, y: node.y1 }, b = { x: node.x2, y: node.y2 }, stretches = stretchesClearOfText(occupied, a, b), arrow = cuts.get(node.id), headOnText = arrow !== void 0 && stretchesClearOfText(occupied, b, arrow.tip) !== void 0;
1502
+ if (!stretches && !headOnText) continue;
1503
+ let id = node.owner.annotationId, record = placed.find((entry) => entry.id === id), pieces = (stretches ?? [[a, b]]).map(([p, q], n) => ({ ...node, id: n === 0 ? node.id : `${node.id}:${n}`, x1: p.x, y1: p.y, x2: q.x, y2: q.y })), after = nodes.splice(i + 1);
1504
+ nodes.length = i, nodes.push(...pieces, ...after), record && (record.nodeIds = record.nodeIds.filter((nodeId) => nodeId !== node.id).concat(pieces.map((piece) => piece.id)));
1505
+ let lastReachesEnd = stretches === void 0 || stretches.at(-1)?.[1] === b;
1506
+ if (arrow && (headOnText || !lastReachesEnd)) {
1507
+ let headAt = nodes.findIndex((entry) => entry.id === arrow.headId);
1508
+ headAt >= 0 && nodes.splice(headAt, 1), record && (record.nodeIds = record.nodeIds.filter((nodeId) => nodeId !== arrow.headId));
1509
+ }
1510
+ warned.has(id) || (warned.add(id), warnings.push({
1511
+ code: "draw-crosses-text",
1512
+ severity: "warn",
1513
+ message: `${record?.kind ?? "drawing"} '${id}' would cross text, so it breaks around the label there`,
1514
+ owner: { annotationId: id },
1515
+ suggest: "Move the drawing to other points, or move the label with labelOffsets."
1516
+ }));
1517
+ }
1518
+ }
1519
+
1355
1520
  // src/core/annotate.ts
1356
1521
  function anchorRefLabel(ref) {
1357
1522
  if (typeof ref == "string") return ref;
@@ -1402,7 +1567,7 @@ function runAnnotatePass(input) {
1402
1567
  return input.annotations.forEach((ann, n) => {
1403
1568
  let id = defaultAnnotationId(ann, n);
1404
1569
  anchorErrors.length = 0;
1405
- let warningStart = warnings.length, secondaryLine = ann.kind === "valueLine" && ann.axis === "secondary", valuesNotShares = sharesOnly && ann.kind !== "valueLine", referenceFormat = secondaryLine ? input.secondaryFormat : valuesNotShares ? void 0 : input.format, anchorFormat = "at" in ann && ann.at !== void 0 ? input.resolve(ann.at)?.format : ann.kind === "diff" ? input.resolve(ann.to)?.format ?? input.resolve(ann.from)?.format : ann.kind === "valueLine" ? secondaryLine ? input.secondaryFormat : seriesMeanFormat(input, ann) : void 0, example = ann.format ?? anchorFormat, own = example === void 0 ? void 0 : exampleSpec(example, locale), signed = own ? { ...exampleSpec(ann.format ?? differenceExample(example), locale), signed: !0 } : void 0, referencePercent = ann.kind === "valueLine" ? (secondaryLine ? input.secondaryPercentLevels : input.valueLinePercentLevels) ?? percent : percent, referenceUnit = ann.kind === "valueLine" ? input.valueLineUnit : void 0, baseRun = referenceUnit ? { ...run, fmt: referenceFormat ? (v) => formatWithSpec(v, { ...exampleSpec(referenceFormat, locale), prefix: "", suffix: referenceUnit }) : plain(referenceUnit, !1) } : ann.kind === "valueLine" && !referenceFormat && (secondaryLine || referencePercent !== percent) ? { ...run, fmt: plain(referencePercent ? "%" : "", !1) } : valuesNotShares ? { ...run, fmt: valueFmt, statFmt: valueFmt, fmtSigned: plain(input.percentLevels === !0 ? PERCENTAGE_POINTS : "", !0), printsZero: (v) => roundsToZero(v, autoDecimals(v)) } : run, fmtRun = own ? {
1570
+ let warningStart = warnings.length, secondaryLine = ann.kind === "valueLine" && ann.axis === "secondary", valuesNotShares = sharesOnly && ann.kind !== "valueLine", referenceFormat = secondaryLine ? input.secondaryFormat : valuesNotShares ? void 0 : input.format, anchorFormat = ann.kind === "text" || ann.kind === "line" || ann.kind === "arrow" || ann.kind === "box" ? void 0 : "at" in ann && ann.at !== void 0 ? input.resolve(ann.at)?.format : ann.kind === "diff" ? input.resolve(ann.to)?.format ?? input.resolve(ann.from)?.format : ann.kind === "valueLine" ? secondaryLine ? input.secondaryFormat : seriesMeanFormat(input, ann) : void 0, example = ann.format ?? anchorFormat, own = example === void 0 ? void 0 : exampleSpec(example, locale), signed = own ? { ...exampleSpec(ann.format ?? differenceExample(example), locale), signed: !0 } : void 0, referencePercent = ann.kind === "valueLine" ? (secondaryLine ? input.secondaryPercentLevels : input.valueLinePercentLevels) ?? percent : percent, referenceUnit = ann.kind === "valueLine" ? input.valueLineUnit : void 0, baseRun = referenceUnit ? { ...run, fmt: referenceFormat ? (v) => formatWithSpec(v, { ...exampleSpec(referenceFormat, locale), prefix: "", suffix: referenceUnit }) : plain(referenceUnit, !1) } : ann.kind === "valueLine" && !referenceFormat && (secondaryLine || referencePercent !== percent) ? { ...run, fmt: plain(referencePercent ? "%" : "", !1) } : valuesNotShares ? { ...run, fmt: valueFmt, statFmt: valueFmt, fmtSigned: plain(input.percentLevels === !0 ? PERCENTAGE_POINTS : "", !0), printsZero: (v) => roundsToZero(v, autoDecimals(v)) } : run, fmtRun = own ? {
1406
1571
  ...baseRun,
1407
1572
  fmt: referenceUnit ? (v) => formatWithSpec(v, { ...own, prefix: "", suffix: referenceUnit }) : formatterFromExample(example, input.locale),
1408
1573
  fmtSigned: (v) => formatWithSpec(v, signed),
@@ -1423,7 +1588,7 @@ function runAnnotatePass(input) {
1423
1588
  run.legDeficit = Math.max(run.legDeficit, pixels);
1424
1589
  }
1425
1590
  };
1426
- if (scope.warn = (code, message, suggest) => warn(scope, code, message, suggest), placeAnnotation(scope, ann), anchorErrors.length) for (let warning of warnings.slice(warningStart))
1591
+ if (scope.warn = (code, message, suggest) => warn(scope, code, message, suggest), placeAnnotation(scope, ann, run), anchorErrors.length) for (let warning of warnings.slice(warningStart))
1427
1592
  warning.code === "bad-anchor" && (warning.message += `: ${[...new Set(anchorErrors)].join("; ")}`);
1428
1593
  }), finishAnnotatePass(input, run, nodes, placed, labelRequests, warnings);
1429
1594
  }
@@ -1432,7 +1597,7 @@ function seriesMeanFormat(input, ann) {
1432
1597
  let mean = input.meanValueFor?.({ seriesId: ann.seriesId, from: ann.from, to: ann.to });
1433
1598
  return mean && !("error" in mean) ? mean.format : void 0;
1434
1599
  }
1435
- function placeAnnotation(s, ann) {
1600
+ function placeAnnotation(s, ann, run) {
1436
1601
  switch (ann.kind) {
1437
1602
  case "cagr":
1438
1603
  return placeCagr(s, ann);
@@ -1456,6 +1621,12 @@ function placeAnnotation(s, ann) {
1456
1621
  return;
1457
1622
  case "event":
1458
1623
  return;
1624
+ case "text":
1625
+ return placeDrawingText(s, ann);
1626
+ case "line":
1627
+ case "arrow":
1628
+ case "box":
1629
+ return placeDrawing(s, ann, run);
1459
1630
  }
1460
1631
  }
1461
1632
  function partialAnchors(s, ...anchors) {
@@ -1567,14 +1738,13 @@ function spanLead(s, a, b, periodOn, colon = !1) {
1567
1738
  let names = [...new Set([a.series?.label, b.series?.label].filter((name) => name !== void 0))], named = names.length === 2 ? chartString2({ locale: s.input.locale, strings: s.input.strings }, "seriesSpan", { v1: names[0], v2: names[1] }) : names[0] ?? "", period = periodOn && a.label && b.label && a.label !== b.label ? `${a.label}\u2013${b.label}` : "", lead = [named, period].filter(Boolean).join(" ");
1568
1739
  return lead && (period || colon) ? `${lead}:` : lead;
1569
1740
  }
1570
- var BRACKET_TICK = 5;
1571
1741
  function placeBracket(s, ann) {
1572
1742
  let { input, id } = s;
1573
1743
  if (!input.resolveSpan) return warn(s, "unsupported", `bracket '${id}': this chart has no steps to add up`);
1574
1744
  if (typeof ann.from != "string" || typeof ann.to != "string" || !ann.from || !ann.to) return warn(s, "bad-anchor", `bracket '${id}': from and to are step ids (non-empty strings)`);
1575
1745
  let span = input.resolveSpan(ann.from, ann.to);
1576
1746
  if ("error" in span) return warn(s, span.code, `bracket '${id}': ${span.error}`);
1577
- let sumText = s.run.fmtSigned(span.sum), composed = ann.label ? `${ann.label} ${sumText}` : sumText, label = authored(s, "bracket", composed, ann.text, sumText), lineId = s.nid("bracket"), { left, right, y } = span;
1747
+ let sumText = s.run.fmtSigned(span.sum), composed = ann.label ? `${ann.label} ${sumText}` : sumText, label = authored(s, "bracket", composed, ann.text, sumText), lineId = s.nid("bracket"), { left, right } = span, font = { family: input.theme.type.family, ...input.theme.type.label }, size = input.measure(label.text, font), labelRectAt = (top) => ({ x: (left + right - size.width) / 2, y: top - 3 - size.height, w: size.width, h: size.height }), runRectAt = (top) => ({ x: left - 1, y: top - 1, w: right - left + 2, h: BRACKET_TICK + 2 }), seat = unionRect(labelRectAt(span.spanY), runRectAt(span.spanY)), canvas = input.solveCtx.canvas, y = input.occupied.hits(seat, 2) || canvas && !rectContains(canvas, seat, 0) ? span.y : span.spanY;
1578
1748
  s.nodes.push({
1579
1749
  t: "path",
1580
1750
  id: lineId,
@@ -1583,9 +1753,9 @@ function placeBracket(s, ann) {
1583
1753
  width: strokeToken(input.theme, "rule"),
1584
1754
  owner: { annotationId: id },
1585
1755
  part: "bracket"
1586
- }), input.occupied.claim({ x: left - 1, y: y - 1, w: right - left + 2, h: BRACKET_TICK + 2 }, "annotation", { annotationId: id }, "bracket");
1587
- let font = { family: input.theme.type.family, ...input.theme.type.label }, size = input.measure(label.text, font);
1588
- s.labelRequests.push({
1756
+ }), input.occupied.claim(runRectAt(y), "annotation", { annotationId: id }, "bracket");
1757
+ let labelRect = labelRectAt(y);
1758
+ input.occupied.hits(labelRect, 2, (claim) => claim.owner.annotationId === id) || input.occupied.claim(labelRect, "annotation", { annotationId: id }, "bracketLabel"), s.labelRequests.push({
1589
1759
  id: `annotation:${id}`,
1590
1760
  kind: "annotation",
1591
1761
  role: computedTextRole(label.text, label.computed),
@@ -1595,7 +1765,7 @@ function placeBracket(s, ann) {
1595
1765
  typeRole: "label",
1596
1766
  font,
1597
1767
  priority: ann.priority ?? PRIORITY.valueLine,
1598
- candidates: [{ slot: "aboveBracket", rect: { x: (left + right - size.width) / 2, y: y - 3 - size.height, w: size.width, h: size.height }, penalty: 0 }]
1768
+ candidates: [{ slot: "aboveBracket", rect: labelRect, penalty: 0 }]
1599
1769
  }), s.placed.push({
1600
1770
  id,
1601
1771
  kind: "bracket",
@@ -1616,14 +1786,14 @@ function placeDiff(s, ann) {
1616
1786
  if (valueless(s, "diff", [a, b])) return;
1617
1787
  warnPartialComparison(s, "diff", partialAnchors(s, a, b));
1618
1788
  let mode = ann.mode ?? "relative";
1619
- if (mode !== "relative" && mode !== "reversed" && mode !== "absolute")
1789
+ if (mode !== "relative" && mode !== "reversed" && mode !== "absolute" && mode !== "both")
1620
1790
  return warn(
1621
1791
  s,
1622
1792
  "diff-mode-unimplemented",
1623
1793
  `diff '${id}': mode '${String(mode)}' is not implemented \u2014 nothing is drawn`,
1624
- mode === "pctOf100" ? "use mode:'absolute' for the raw difference, or author the shares as data if the reader needs points of 100%" : "use 'relative', 'absolute' or 'reversed'"
1794
+ mode === "pctOf100" ? "use mode:'absolute' for the raw difference, or author the shares as data if the reader needs points of 100%" : "use 'relative', 'absolute', 'reversed' or 'both'"
1625
1795
  );
1626
- let computed, derivation;
1796
+ let computed, pctText = "", derivation;
1627
1797
  if (mode === "relative" || mode === "reversed") {
1628
1798
  let [base, tip] = mode === "reversed" ? [b, a] : [a, b];
1629
1799
  if (base.value === 0) return warn(s, "ref-zero", `diff '${id}': zero base`);
@@ -1642,8 +1812,10 @@ function placeDiff(s, ann) {
1642
1812
  `diff '${id}': percent change off a negative base (${base.value}) is measured against its magnitude, so the sign follows the direction of the change`,
1643
1813
  "use mode:'absolute' if the reader needs the raw difference instead of a ratio to a negative reference"
1644
1814
  );
1645
- } else
1646
- computed = s.run.fmtSigned(b.value - a.value), derivation = {
1815
+ } else {
1816
+ if (mode === "both" && a.value === 0) return warn(s, "ref-zero", `diff '${id}': mode 'both' needs a nonzero 'from'`);
1817
+ let pct = mode === "both" ? (b.value - a.value) / Math.abs(a.value) * 100 : 0;
1818
+ pctText = mode === "both" ? formatAutomaticPercent(pct, typicalDecimals([pct]), !0, input.locale) : "", computed = s.run.fmtSigned(b.value - a.value) + (mode === "both" ? ` (${pctText})` : ""), derivation = {
1647
1819
  basis: "derived",
1648
1820
  op: "annotation-diff-absolute@1",
1649
1821
  inputs: [
@@ -1652,12 +1824,14 @@ function placeDiff(s, ann) {
1652
1824
  ],
1653
1825
  raw: b.value - a.value
1654
1826
  };
1827
+ }
1655
1828
  if (gapPlacement(s, ann, a, b)) {
1656
- let text = mode !== "absolute" ? computed : gapNumber(s, ann, a, b, b.value - a.value, computed), [tail, head] = mode === "reversed" ? [b, a] : [a, b];
1829
+ let value = mode === "relative" || mode === "reversed" ? computed : gapNumber(s, ann, a, b, b.value - a.value, s.run.fmtSigned(b.value - a.value)), text = mode === "both" ? `${value} (${pctText})` : value, [tail, head] = mode === "reversed" ? [b, a] : [a, b];
1657
1830
  return drawGapBracket(s, ann, tail, head, authored(s, "diff", text, ann.text, text), derivation);
1658
1831
  }
1659
1832
  let lead = input.comparisonLayout?.namesSpan ? spanLead(s, a, b, !0, !0) : "", gapWord = input.barInset && !lead && ann.text === void 0 && a.owner.categoryId !== void 0 && a.owner.categoryId === b.owner.categoryId && a.owner.seriesId !== b.owner.seriesId ? input.barInset.gapWord : "", label = gapWord ? { text: `${gapWord}\xA0${computed}`, computed } : authored(s, "diff", lead ? `${lead} ${computed}` : computed, ann.text, computed);
1660
- drawDiffArm(s, a, b, label.text, id, label.computed, derivation, gapWord ? { lead: gapWord, value: computed } : void 0);
1833
+ if (input.spanBracket?.(ann)) return drawSpanBracket(s, a, b, label.text, id, "diff", label.computed, derivation);
1834
+ drawDiffArm(s, a, b, label.text, id, label.computed, derivation, gapWord ? { lead: gapWord, value: computed } : void 0, ann.placement);
1661
1835
  }
1662
1836
  function placeNote(s, ann) {
1663
1837
  let found = s.input.resolve(ann.at);
@@ -1674,13 +1848,13 @@ function placeNote(s, ann) {
1674
1848
  let headline = ann.kind === "callout" && ann.headline !== void 0 ? ann.headline.replace(/\$\{value\}/g, value) : void 0;
1675
1849
  !text.trim() && headline === void 0 && !glyph && warn(s, "annotation-empty", `${ann.kind} '${s.id}': its text is empty, so it prints no words; any arrow or leader stays`);
1676
1850
  let placedGlyph = glyph ? planCalloutGlyph(s, at, glyph, text) : void 0, lines = headline === void 0 ? text : `${headline}
1677
- ${text}`;
1851
+ ${text}`, printsValue = !repeats && [ann.text, ann.kind === "callout" ? ann.headline : void 0].some((part) => part?.includes("${value}"));
1678
1852
  calloutLabel(s, ann, at, lines, ann.kind, void 0, lines, {
1679
1853
  basis: "authored",
1680
1854
  op: `annotation-${ann.kind}@1`,
1681
1855
  inputs: [{ ref: `at:${anchorRefLabel(ann.at)}`, value: at.noValue === void 0 ? at.value : null, state: "anchor" }],
1682
1856
  raw: null
1683
- }, placedGlyph);
1857
+ }, placedGlyph, printsValue ? found.owner : void 0);
1684
1858
  }
1685
1859
  function placeDelta(s, ann) {
1686
1860
  let { input, id } = s, at = input.resolve(ann.at);
@@ -1689,19 +1863,27 @@ function placeDelta(s, ann) {
1689
1863
  if (vsValue === null) return warn(s, "bad-anchor", `delta '${id}': unresolvable vs`);
1690
1864
  if (valueless(s, "delta", [at, vsAnchor])) return;
1691
1865
  warnPartialComparison(s, "delta", partialAnchors(s, at, vsAnchor));
1692
- let atValue = vsAnchor ? at.comparisonValue ?? at.value : at.value, d = atValue - vsValue, computed = s.run.fmtSigned(d), tone = s.run.printsZero(d) ? void 0 : d > 0 ? "good" : "bad", acrossRows = input.deltaAcrossRows === !0 && vsAnchor !== null && vsAnchor.owner.categoryId !== void 0 && vsAnchor.owner.categoryId !== at.owner.categoryId, derivation = {
1866
+ let atValue = vsAnchor ? at.comparisonValue ?? at.value : at.value, d = atValue - vsValue, mode = ann.mode ?? "absolute";
1867
+ if (mode !== "absolute" && vsValue === 0) return warn(s, "ref-zero", `delta '${id}': mode '${mode}' needs a nonzero vs`);
1868
+ let pct = d / Math.abs(vsValue) * 100, pctText = ann.format && mode === "relative" ? s.run.fmtSigned(pct) : formatAutomaticPercent(pct, typicalDecimals([pct]), !0, input.locale), computed = mode === "relative" ? pctText : mode === "both" ? `${s.run.fmtSigned(d)} (${pctText})` : s.run.fmtSigned(d), tone = s.run.printsZero(d) ? void 0 : d > 0 ? "good" : "bad", acrossRows = input.deltaAcrossRows === !0 && vsAnchor !== null && vsAnchor.owner.categoryId !== void 0 && vsAnchor.owner.categoryId !== at.owner.categoryId, vsRef = typeof ann.vs == "number" ? "vs:literal" : `vs:${anchorRefLabel(ann.vs)}`, derivation = mode === "relative" ? {
1869
+ basis: "derived",
1870
+ op: "annotation-diff-relative@1",
1871
+ inputs: [{ ref: `base:${vsRef.slice(3)}`, value: vsValue }, { ref: `tip:${anchorRefLabel(ann.at)}`, value: atValue }],
1872
+ raw: pct
1873
+ } : {
1693
1874
  basis: "derived",
1694
1875
  op: "annotation-delta@1",
1695
- inputs: [
1696
- { ref: `at:${anchorRefLabel(ann.at)}`, value: atValue },
1697
- { ref: typeof ann.vs == "number" ? "vs:literal" : `vs:${anchorRefLabel(ann.vs)}`, value: vsValue }
1698
- ],
1876
+ inputs: [{ ref: `at:${anchorRefLabel(ann.at)}`, value: atValue }, { ref: vsRef, value: vsValue }],
1699
1877
  raw: d
1700
1878
  };
1701
1879
  if (gapPlacement(s, ann, at, vsAnchor)) {
1702
- let text = gapNumber(s, ann, vsAnchor, at, d, computed);
1880
+ let value = mode === "relative" ? computed : gapNumber(s, ann, vsAnchor, at, d, s.run.fmtSigned(d)), text = mode === "both" ? `${value} (${pctText})` : value;
1703
1881
  return drawGapBracket(s, ann, vsAnchor, at, authored(s, "delta", text, ann.text, text), derivation);
1704
1882
  }
1883
+ if (vsAnchor && input.spanBracket?.(ann)) {
1884
+ let label2 = authored(s, "delta", computed, ann.text, computed);
1885
+ return drawSpanBracket(s, comparisonAnchor(vsAnchor) ?? vsAnchor, comparisonAnchor(at) ?? at, label2.text, id, "delta", label2.computed, derivation);
1886
+ }
1705
1887
  let label = authored(s, "delta", acrossRows && vsAnchor.label ? `${computed} vs ${vsAnchor.label}` : computed, ann.text, computed), seat = acrossRows ? { ...at, x: (at.x + vsAnchor.x) / 2 } : at;
1706
1888
  calloutLabel(s, ann, seat, label.text, "delta", tone, label.computed, derivation);
1707
1889
  }
@@ -1743,13 +1925,13 @@ function placeAbs(s, ann) {
1743
1925
  let at = s.input.resolve(ann.at);
1744
1926
  if (!at) return warn(s, "bad-anchor", `abs '${s.id}': unresolvable anchor`);
1745
1927
  if (valueless(s, "abs", [at])) return;
1746
- let computed = s.run.fmt(at.value), label = authored(s, "abs", computed, ann.text);
1928
+ let computed = ann.format === void 0 && at.markValueText !== void 0 ? at.markValueText : s.run.fmt(at.value), label = authored(s, "abs", computed, ann.text);
1747
1929
  calloutLabel(s, ann, at, label.text, "abs", void 0, label.computed, {
1748
1930
  basis: "observed",
1749
1931
  op: "annotation-abs@1",
1750
1932
  inputs: [{ ref: `at:${anchorRefLabel(ann.at)}`, value: at.value, state: "anchor" }],
1751
1933
  raw: at.value
1752
- });
1934
+ }, void 0, label.text === label.computed ? at.owner : void 0);
1753
1935
  }
1754
1936
  function valueLineMean(s, ann) {
1755
1937
  let { input, id } = s, onSecondary = ann.axis === "secondary";
@@ -1828,8 +2010,12 @@ function valueAxisTickColumn(occupied, plotX) {
1828
2010
  return right > left ? [left, right] : void 0;
1829
2011
  }
1830
2012
  var LINE_LABEL_GAP = 3, LINE_SEAT_STEP = 16, LINE_SEAT_MAX = 96, LINE_LABEL_AIR = 12;
2013
+ function alongLine(start, end, fromStart = !1) {
2014
+ let steps = Math.min(LINE_SEAT_MAX, Math.ceil((end - start) / LINE_SEAT_STEP));
2015
+ return steps > 1 ? Array.from({ length: steps - 1 }, (_, i) => fromStart ? start + (i + 1) * (end - start) / steps : end - (i + 1) * (end - start) / steps) : [];
2016
+ }
1831
2017
  function rightLineSeats(input, text, font, size, y, rightSeat) {
1832
- let { plot } = input, above = y - size.height - LINE_LABEL_GAP, below = y + LINE_LABEL_GAP, seat = (slot, x, top, penalty) => ({ slot, rect: { x, y: top, w: size.width, h: size.height }, penalty }), end = plot.x + plot.w - size.width, start = plot.x + 4, steps = Math.min(LINE_SEAT_MAX, Math.ceil((end - start) / LINE_SEAT_STEP)), along = steps > 1 ? Array.from({ length: steps - 1 }, (_, i) => end - (i + 1) * (end - start) / steps) : [], lines = lineLabelGutterLines(text, (t) => input.measure(t, font).width), wrappedW = Math.max(...lines.map((line) => input.measure(line, font).width)), wrappedH = size.height * lines.length;
2018
+ let { plot } = input, above = y - size.height - LINE_LABEL_GAP, below = y + LINE_LABEL_GAP, seat = (slot, x, top, penalty) => ({ slot, rect: { x, y: top, w: size.width, h: size.height }, penalty }), end = plot.x + plot.w - size.width, start = plot.x + 4, along = alongLine(start, end), lines = lineLabelGutterLines(text, (t) => input.measure(t, font).width), wrappedW = Math.max(...lines.map((line) => input.measure(line, font).width)), wrappedH = size.height * lines.length;
1833
2019
  return [
1834
2020
  // One penalty for every seat on the line: the order below is the
1835
2021
  // preference, and a seat that crowds another owner's label
@@ -1845,10 +2031,14 @@ function rightLineSeats(input, text, font, size, y, rightSeat) {
1845
2031
  ...lines.length > 1 ? [{ slot: "lineEndWrapped", rect: { x: rightSeat, y: y - wrappedH / 2, w: wrappedW, h: wrappedH }, penalty: 103, lines }] : []
1846
2032
  ];
1847
2033
  }
2034
+ function repeatsEndValue(input, v, valueText, y, size) {
2035
+ let right = input.plot.x + input.plot.w, near = (rect) => rect.x + rect.w >= right - 2 * size.width && rect.x <= right + size.width && Math.abs(rect.y + rect.h / 2 - y) <= 2 * size.height, sameValue = (owner) => owner.categoryId !== void 0 && input.resolve({ categoryId: owner.categoryId, ...owner.seriesId === void 0 ? {} : { seriesId: owner.seriesId } })?.value === v;
2036
+ return (input.printedLabels ?? []).find((label) => label.kind === "point" && label.hidden === void 0 && label.text === valueText && near(label.rect) && sameValue(label.owner))?.rect;
2037
+ }
1848
2038
  function valueLineLabel(s, ann, v, y, axis) {
1849
- let { input, id } = s, span = input.meanSpan?.({ from: ann.from, to: ann.to }), isMean = ann.value === "mean" || ann.value === void 0, valueText = (isMean ? s.run.statFmt : s.run.fmt)(v), labelText = ann.label === !1 ? "" : ann.label !== void 0 ? namedLineText(ann.label, valueText, v, id) : isMean ? `${input.strings?.average ?? localeStrings(input.locale).average} ${valueText}${span ? ` (${span})` : ""}` : valueText;
2039
+ let { input, id } = s, span = input.meanSpan?.({ from: ann.from, to: ann.to }), isMean = ann.value === "mean" || ann.value === void 0, valueText = (isMean ? s.run.statFmt : s.run.fmt)(v), font = { family: input.theme.type.family, ...input.theme.type.label }, endValue = typeof ann.label == "string" && !ann.label.includes("${value}") && axis === "y" && (ann.side ?? "right") === "right" ? repeatsEndValue(input, v, valueText, y, input.measure(`${ann.label} ${valueText}`, font)) : void 0, nameOnly = endValue !== void 0, labelText = ann.label === !1 || input.valueLineLabels === !1 ? "" : typeof ann.label == "string" && nameOnly ? ann.label : ann.label !== void 0 ? namedLineText(ann.label, valueText, v, id) : isMean ? `${input.strings?.average ?? localeStrings(input.locale).average} ${valueText}${span ? ` (${span})` : ""}` : valueText;
1850
2040
  if (!labelText) return labelText;
1851
- let font = { family: input.theme.type.family, ...input.theme.type.label }, row = input.valueLineRows?.get(id);
2041
+ let row = input.valueLineRows?.get(id);
1852
2042
  if (row) {
1853
2043
  let rowFont = { ...font, weight: emphasisWeight(input.theme) }, lines = wrapText(labelText, rowFont, row.w, Math.max(1, labelText.length), input.measure).lines;
1854
2044
  return s.labelRequests.push({
@@ -1886,7 +2076,10 @@ function valueLineLabel(s, ann, v, y, axis) {
1886
2076
  },
1887
2077
  penalty: 1
1888
2078
  }
1889
- ] : side === "right" ? rightLineSeats(input, labelText, font, size, y, rightSeat) : [
2079
+ ] : side === "right" ? [
2080
+ ...endValue ? [{ slot: "beforeEndValue", rect: { x: endValue.x - 4 - size.width, y: y - size.height - LINE_LABEL_GAP, w: size.width, h: size.height }, penalty: -1 }] : [],
2081
+ ...rightLineSeats(input, labelText, font, size, y, rightSeat)
2082
+ ] : [
1890
2083
  // Inside the plot the centred slot would sit on the label's own
1891
2084
  // dashed line (the solver ignores the annotation's own claims), so
1892
2085
  // a relocated left label takes the slots above and below the line.
@@ -1896,7 +2089,12 @@ function valueLineLabel(s, ann, v, y, axis) {
1896
2089
  ...x !== marginX ? [{ slot: "lineEndMargin", rect: { x: marginX, y: y - size.height / 2, w: size.width, h: size.height }, penalty: 3 }] : [],
1897
2090
  // A left label whose start is taken by the data steps to the line's right end, above or below it.
1898
2091
  { slot: "insideEnd", rect: { x: input.plot.x + input.plot.w - size.width, y: y - size.height - LINE_LABEL_GAP, w: size.width, h: size.height }, penalty: 4 },
1899
- { slot: "insideEndLow", rect: { x: input.plot.x + input.plot.w - size.width, y: y + LINE_LABEL_GAP, w: size.width, h: size.height }, penalty: 5 }
2092
+ { slot: "insideEndLow", rect: { x: input.plot.x + input.plot.w - size.width, y: y + LINE_LABEL_GAP, w: size.width, h: size.height }, penalty: 5 },
2093
+ // Both ends taken: even steps along the line from left to right, as a right label has them.
2094
+ ...alongLine(input.plot.x + 4, input.plot.x + input.plot.w - size.width, !0).flatMap((at, i) => [
2095
+ { slot: `insideAlong${i + 1}`, rect: { x: at, y: y - size.height - LINE_LABEL_GAP, w: size.width, h: size.height }, penalty: 6 },
2096
+ { slot: `insideAlong${i + 1}Low`, rect: { x: at, y: y + LINE_LABEL_GAP, w: size.width, h: size.height }, penalty: 6 }
2097
+ ])
1900
2098
  ], tight = axis === "x" ? [] : candidates.flatMap((c) => Math.abs(c.rect.y + c.rect.h - (y - LINE_LABEL_GAP)) < 1e-6 || Math.abs(c.rect.y - (y + LINE_LABEL_GAP)) < 1e-6 ? [{ ...c, slot: `${c.slot}Tight`, rect: { ...c.rect, y: c.rect.y + (c.rect.y > y ? -1 : 1) }, penalty: c.penalty + 10 }] : []);
1901
2099
  return s.labelRequests.push({
1902
2100
  id: `valueLine:${id}`,
@@ -1938,7 +2136,7 @@ function placeValueLine(s, ann) {
1938
2136
  id,
1939
2137
  kind: "valueLine",
1940
2138
  computedText: labelText || "",
1941
- valueText: (meanLine ? s.run.statFmt : s.run.fmt)(v),
2139
+ valueText: (id === input.averageMarker?.id ? input.averageMarker.fmt : meanLine ? s.run.statFmt : s.run.fmt)(v),
1942
2140
  nodeIds: [lineId],
1943
2141
  labelId: labelText ? `valueLine:${id}` : void 0,
1944
2142
  // A mean is MEASURED over the plotted series (the observations are the
@@ -2007,7 +2205,99 @@ function placeIndicator100(s, ann) {
2007
2205
  derivation: { basis: "authored", op: "annotation-indicator100@1", inputs: [{ ref: "reference", value: 100, state: "constant" }], raw: 100 }
2008
2206
  });
2009
2207
  }
2010
- function calloutLabel(s, ann, anchor, text, kind, tone, computed = text, derivation, glyph) {
2208
+ function placeDrawingText(s, ann) {
2209
+ let { input, id } = s, at = resolveDrawingPoint(input, ann.at);
2210
+ if ("error" in at) return warn(s, "bad-anchor", `text '${id}': ${at.error}`);
2211
+ let font = { family: input.theme.type.family, ...input.theme.type.label }, lines = ann.text.split(`
2212
+ `), lineH = input.measure("X", font).height, size = { w: Math.max(0, ...lines.map((line) => input.measure(line, font).width)), h: lineH * lines.length };
2213
+ s.labelRequests.push({
2214
+ id: `annotation:${id}`,
2215
+ kind: "annotation",
2216
+ role: "note",
2217
+ owner: { annotationId: id },
2218
+ text: ann.text,
2219
+ lines,
2220
+ typeRole: "label",
2221
+ font,
2222
+ priority: ann.priority ?? PRIORITY.extreme,
2223
+ noLeader: !0,
2224
+ candidates: textSeats(at, size)
2225
+ }), s.placed.push({ id, kind: "text", computedText: ann.text, tone: "neutral", nodeIds: [], labelId: `annotation:${id}` });
2226
+ }
2227
+ function placeDrawing(s, ann, run) {
2228
+ let { input, id } = s;
2229
+ if (ann.kind !== "box" && (isTextEnd(ann.from) || isTextEnd(ann.to))) {
2230
+ let end = (point, field) => {
2231
+ if (!isTextEnd(point)) {
2232
+ let at = resolveDrawingPoint(input, point);
2233
+ return "error" in at ? `${field}: ${at.error}` : at;
2234
+ }
2235
+ let texts = input.annotations.flatMap((annotation, index) => annotation.kind === "text" ? [defaultAnnotationId(annotation, index)] : []);
2236
+ return texts.includes(point.annotationId) ? { textId: point.annotationId } : `${field}: annotationId '${point.annotationId}' names no text annotation${texts.length ? `; text ids: ${texts.join(", ")}` : ""}`;
2237
+ }, from2 = end(ann.from, "from"), to2 = end(ann.to, "to");
2238
+ if (typeof from2 == "string" || typeof to2 == "string") return warn(s, "bad-anchor", `${ann.kind} '${id}': ${typeof from2 == "string" ? from2 : to2}`);
2239
+ let record = { id, kind: ann.kind, computedText: "", tone: "neutral", nodeIds: [] };
2240
+ s.placed.push(record), (run.textDrawings ??= []).push({ ann, id, from: from2, to: to2, nid: s.nid, record });
2241
+ return;
2242
+ }
2243
+ let ends = [resolveDrawingPoint(input, ann.from), resolveDrawingPoint(input, ann.to)], [from, to] = ann.kind === "box" ? boxCorners(input, ...ends) : ends, failure = drawingFailure(ann.kind, from, to);
2244
+ if (failure !== void 0) return warn(s, "bad-anchor", `${ann.kind} '${id}': ${failure}`);
2245
+ run.drawings ??= /* @__PURE__ */ new Map();
2246
+ let nodeIds = drawDrawing(
2247
+ ann,
2248
+ id,
2249
+ from,
2250
+ to,
2251
+ input.theme,
2252
+ input.occupied,
2253
+ s.nodes,
2254
+ s.nid,
2255
+ run.drawings,
2256
+ ann.kind === "box" ? void 0 : to.mark,
2257
+ shortArrow(s.warnings, id)
2258
+ );
2259
+ s.placed.push({ id, kind: ann.kind, computedText: "", tone: "neutral", nodeIds });
2260
+ }
2261
+ function isTextEnd(point) {
2262
+ return typeof point == "object" && point !== null && "annotationId" in point;
2263
+ }
2264
+ var TEXT_END_GAP = 3;
2265
+ function shortArrow(warnings, id) {
2266
+ return (shaft, minimum, dropped) => warnings.push({
2267
+ code: "arrow-short",
2268
+ severity: "warn",
2269
+ owner: { annotationId: id },
2270
+ message: dropped ? `arrow '${id}': its ends lie too close together for a head and a shaft, so it is not drawn` : `arrow '${id}': its shaft is ${Math.round(shaft)} px, under the ${minimum} px an arrow needs to read as one`,
2271
+ suggest: "Move the arrow's start farther from its end, or draw a line."
2272
+ });
2273
+ }
2274
+ function drawFromText(input, run, drawing, labels, nodes, warnings) {
2275
+ let fail = (why) => {
2276
+ warnings.push({ code: "bad-anchor", severity: "warn", message: `${drawing.ann.kind} '${drawing.id}': ${why}, so it is not drawn`, owner: { annotationId: drawing.id } });
2277
+ }, look = drawing.ann.kind === "arrow" ? arrowLook(input.theme, { size: 0 }) : void 0, gap = look?.standard ? look.tailGap : TEXT_END_GAP, seatOf = (end) => {
2278
+ if (!("textId" in end)) return;
2279
+ let label = labels.find((entry) => entry.id === `annotation:${end.textId}`);
2280
+ return label && !label.hidden ? inflate(label.rect, gap) : null;
2281
+ }, fromSeat = seatOf(drawing.from), toSeat = seatOf(drawing.to);
2282
+ if (fromSeat === null || toSeat === null) return fail(`text '${"textId" in drawing.from && fromSeat === null ? drawing.from.textId : drawing.to.textId}' has no place on the chart`);
2283
+ let centre = (end, seat) => seat ? { x: seat.x + seat.w / 2, y: seat.y + seat.h / 2 } : end, nearest = (seat, toward) => ({ x: Math.min(Math.max(toward.x, seat.x), seat.x + seat.w), y: Math.min(Math.max(toward.y, seat.y), seat.y + seat.h) }), aimFrom = centre(drawing.from, fromSeat), aimTo = centre(drawing.to, toSeat), from = fromSeat ? nearest(fromSeat, aimTo) : aimFrom, to = toSeat ? nearest(toSeat, aimFrom) : aimTo;
2284
+ if (fromSeat && rectContains(fromSeat, { ...to, w: 0, h: 0 }) || toSeat && rectContains(toSeat, { ...from, w: 0, h: 0 }) || Math.hypot(to.x - from.x, to.y - from.y) < 1) return fail("its other end lies on the text");
2285
+ run.drawings ??= /* @__PURE__ */ new Map(), drawing.record.nodeIds = drawDrawing(
2286
+ drawing.ann,
2287
+ drawing.id,
2288
+ from,
2289
+ to,
2290
+ input.theme,
2291
+ input.occupied,
2292
+ nodes,
2293
+ drawing.nid,
2294
+ run.drawings,
2295
+ toSeat ? void 0 : drawing.to.mark,
2296
+ shortArrow(warnings, drawing.id)
2297
+ );
2298
+ }
2299
+ var CALLOUT_MARKER_R = 3, VALUE_BOX_REACH = 24;
2300
+ function calloutLabel(s, ann, anchor, text, kind, tone, computed = text, derivation, glyph, valueOwner) {
2011
2301
  let { input, id: annId } = s, at = calloutAttachment(anchor, kind, glyph), head = kind === "callout" ? ann : {}, base = { family: input.theme.type.family, ...input.theme.type.label }, font = head.arrow === !0 && !glyph || head.headline !== void 0 ? { ...base, weight: input.plainLabelWeight ?? base.weight } : base, rowWidth = input.gridCallouts?.rows.get(annId)?.w ?? input.gridCallouts?.widths?.get(annId), headSourceLines = head.headline?.split(`
2012
2302
  `).length ?? 0, headlineLines = 0, lines = text.split(`
2013
2303
  `).flatMap((line, i) => {
@@ -2040,7 +2330,18 @@ function calloutLabel(s, ann, anchor, text, kind, tone, computed = text, derivat
2040
2330
  return glyph.placements.set(slot, { groupRect, labelRect, chipCenter, anchor: anchor2 }), { slot, rect: groupRect, penalty, leaderLengthBound: Math.abs(chipCenter.x - anchor2.x) + Math.abs(chipCenter.y - anchor2.y) };
2041
2331
  }
2042
2332
  return { slot, rect: labelRect, penalty, ...leader ? { leaderFrom: edgeToward(labelRect) } : {} };
2043
- }, all = [
2333
+ }, stackMembers = kind === "callout" || kind === "note" || kind === "delta" ? input.annotations.filter((other) => ["callout", "note", "delta"].includes(other.kind) && "at" in other && other.at !== void 0 && samePoint(other.at)) : [], sharing = stackMembers.length, columnTop = input.calloutColumnStack === !0 && !glyph && head.arrow !== !0 && w > 0 && !anchor.lineAnchored && box.w === 0 && sharing > 0, stackSeats = [], stackBase, otherNotes = [];
2334
+ if (columnTop) {
2335
+ let stackW = Math.max(w, ...stackMembers.map((other) => "text" in other && typeof other.text == "string" ? input.measure(other.text, font).width : 0)), aboveRect = { x: at.x - stackW / 2, y: top - h - gap, w: stackW, h }, ticks = input.occupied.hitsWhich(aboveRect, 0).filter((claim) => claim.kind === "mark"), value = input.printedLabels?.find((label) => label.kind === "point" && label.hidden === void 0 && label.owner.categoryId === anchor.owner.categoryId && label.owner.seriesId === anchor.owner.seriesId && label.rect.y < top), base2 = Math.min(top - gap, ...ticks.map((claim) => claim.rect.y - 4), ...value ? [value.rect.y - 4] : []);
2336
+ sharing === 1 && (stackBase = base2), otherNotes = input.annotations.flatMap((other) => {
2337
+ if (other === ann || other.kind !== "callout" && other.kind !== "note" || typeof other.text != "string") return [];
2338
+ let x = input.resolve(other.at)?.x;
2339
+ return x === void 0 ? [] : [{ x, w: input.measure(other.text, font).width }];
2340
+ });
2341
+ let place = Math.max(0, stackMembers.indexOf(ann));
2342
+ for (let k = 0; k < sharing; k++) stackSeats.push(mk(`aboveStack${k}`, at.x - w / 2, base2 - h - k * (h + 4), 0.1 * (1 + Math.abs(k - place))));
2343
+ }
2344
+ let all = [
2044
2345
  mk(
2045
2346
  "above",
2046
2347
  glyph ? at.x + gap : at.x - w / 2,
@@ -2059,6 +2360,9 @@ function calloutLabel(s, ann, anchor, text, kind, tone, computed = text, derivat
2059
2360
  prefer === "below" ? -1 : 3,
2060
2361
  glyph !== void 0
2061
2362
  ),
2363
+ // A column's seat above, stacked: over a plan tick across the column's end, and over the other notes
2364
+ // on the same column (a delta, then its callout), straight above it with no leader.
2365
+ ...stackSeats,
2062
2366
  // over or under the first point of a late-starting line, the
2063
2367
  // note may also end at the point, where its own line has not started. The centred seat
2064
2368
  // lost to the line's first climb, and the note moved to the side its author did not ask for.
@@ -2124,7 +2428,7 @@ function calloutLabel(s, ann, anchor, text, kind, tone, computed = text, derivat
2124
2428
  let rect = { x, y, w: ww, h: hh }, from = value ? valueEdgeToward(value, rect) : edgeToward(rect), candidate = { slot, rect, penalty: extra + penalty, lines: wrapped, ...leader ? { leaderFrom: from, leaderLineHeight: lineH } : {} }, drawn = leader ? leaderFor(candidate) : void 0;
2125
2429
  drawn && leaderCrossesLabel(drawn.d, input.occupied) || (leader && /^(above|below)/.test(slot) && !drawn && (candidate.penalty += 1e3), wrappedSeats.push(candidate));
2126
2430
  };
2127
- seat("aboveWrap", cx, wTop - hh - gap, prefer === "above" ? -1 : 0), seat("rightWrapAt", wRight + gap * 2, sideY - hh / 2, prefer === "right" ? -1 : 1, !0), seat("leftWrapAt", wLeft - ww - gap * 2, sideY - hh / 2, prefer === "left" ? -1 : 2, !0), seat("belowWrap", cx, wBottom + gap, prefer === "below" ? -1 : 3), seat("aboveLeftWrap", Math.max(input.plot.x, wLeft - ww - gap * 2), wTop - hh - gap, 3.1, !0), seat("aboveRightWrap", Math.min(wRight + gap * 2, input.plot.x + input.plot.w - ww), wTop - hh - gap, 3.2, !0), seat("belowLeftWrap", Math.max(input.plot.x, wLeft - ww - gap * 2), wBottom + gap, 3.3, !0), seat("belowRightWrap", Math.min(wRight + gap * 2, input.plot.x + input.plot.w - ww), wBottom + gap, 3.4, !0);
2431
+ seat("aboveWrap", cx, wTop - hh - gap, prefer === "above" ? -1 : 0), stackBase !== void 0 && !otherNotes.some((other) => Math.abs(other.x - at.x) < (ww + other.w) / 2 + gap) && seat("aboveStackWrap", at.x - ww / 2, stackBase - hh, -50 - (wrapped.length - 2) * 20), seat("rightWrapAt", wRight + gap * 2, sideY - hh / 2, prefer === "right" ? -1 : 1, !0), seat("leftWrapAt", wLeft - ww - gap * 2, sideY - hh / 2, prefer === "left" ? -1 : 2, !0), seat("belowWrap", cx, wBottom + gap, prefer === "below" ? -1 : 3), seat("aboveLeftWrap", Math.max(input.plot.x, wLeft - ww - gap * 2), wTop - hh - gap, 3.1, !0), seat("aboveRightWrap", Math.min(wRight + gap * 2, input.plot.x + input.plot.w - ww), wTop - hh - gap, 3.2, !0), seat("belowLeftWrap", Math.max(input.plot.x, wLeft - ww - gap * 2), wBottom + gap, 3.3, !0), seat("belowRightWrap", Math.min(wRight + gap * 2, input.plot.x + input.plot.w - ww), wBottom + gap, 3.4, !0);
2128
2432
  }
2129
2433
  all.push(...wrappedSeats.sort((a, b) => a.penalty - b.penalty));
2130
2434
  }
@@ -2142,8 +2446,12 @@ function calloutLabel(s, ann, anchor, text, kind, tone, computed = text, derivat
2142
2446
  let [a, b] = ends, run = { 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) };
2143
2447
  return !input.occupied.hitsWhich(run).some((claim) => claim.kind === "label");
2144
2448
  }));
2145
- let arrow = head.arrow === !0 && !glyph ? { anchor: { x: at.x, y: at.y }, nodeIds: [s.nid("arrow"), s.nid("arrowHead")], owner: { annotationId: annId } } : void 0;
2146
- if (arrow && (all = [...arrowSeats(arrow.anchor, w, h, lineH, prefer), ...all]), (arrow || head.headline !== void 0) && s.run.calloutHeads.set(`annotation:${annId}`, { font, headline: head.headline !== void 0, headlineLines, headlineWeight: emphasisWeight(input.theme), ...arrow ? { arrow } : {} }), input.gridCallouts && (kind === "callout" || kind === "note")) {
2449
+ let arrow = head.arrow === !0 && !glyph ? { anchor: { x: at.x, y: at.y }, edge: at.lineAnchored ? at.markerRadius ?? CALLOUT_MARKER_R : 0, nodeIds: [s.nid("arrow"), s.nid("arrowHead")], owner: { annotationId: annId } } : void 0;
2450
+ if (arrow) {
2451
+ let look = calloutArrowLook(input.theme), valueBox = look.standard ? anchorValueBox(input.occupied, { x: at.x, y: at.y, w: 0, h: 0 }, at.owner, VALUE_BOX_REACH) : void 0;
2452
+ valueBox && (arrow.valueBox = valueBox), all = [...arrowSeats(arrow.anchor, w, h, lineH, prefer, calloutArrowReach(look, arrow.edge), look.standard, valueBox), ...all];
2453
+ }
2454
+ if ((arrow || head.headline !== void 0) && s.run.calloutHeads.set(`annotation:${annId}`, { font, headline: head.headline !== void 0, headlineLines, headlineWeight: emphasisWeight(input.theme), ...arrow ? { arrow } : {} }), input.gridCallouts && (kind === "callout" || kind === "note")) {
2147
2455
  let { rows, bounds, grid, sideLimit } = input.gridCallouts, row = rows.get(annId);
2148
2456
  row ? all = [{ ...mk(
2149
2457
  row.y >= grid.y + grid.h ? "belowRow" : "aboveRow",
@@ -2172,7 +2480,9 @@ function calloutLabel(s, ann, anchor, text, kind, tone, computed = text, derivat
2172
2480
  ...(kind === "callout" || kind === "note") && input.calloutLeaderClear ? { leaderClear: !0 } : {},
2173
2481
  // On a grid, a seat nearer another row's cell than its own is
2174
2482
  // ambiguous, and takes a leader from its cell if nothing else is free.
2175
- ...gridRow?.end !== void 0 ? { anchor: box } : {}
2483
+ ...gridRow?.end !== void 0 ? { anchor: box } : {},
2484
+ // A labelOffsets move leads back to the mark itself, not to the edge of the seat it left.
2485
+ movedLeaderFrom: { x: at.x, y: at.y }
2176
2486
  }), glyph && s.run.calloutGlyphPlans.set(`annotation:${annId}`, glyph), s.placed.push({
2177
2487
  id: annId,
2178
2488
  kind,
@@ -2180,7 +2490,8 @@ function calloutLabel(s, ann, anchor, text, kind, tone, computed = text, derivat
2180
2490
  tone: tone ?? "neutral",
2181
2491
  nodeIds: glyph?.nodeIds ?? arrow?.nodeIds ?? [],
2182
2492
  labelId: `annotation:${annId}`,
2183
- ...derivation ? { derivation } : {}
2493
+ ...derivation ? { derivation } : {},
2494
+ ...valueOwner ? { valueOwner } : {}
2184
2495
  });
2185
2496
  }
2186
2497
  function calloutGlyphOf(s, annotation) {
@@ -2238,32 +2549,35 @@ function finishAnnotatePass(input, run, nodes, placed, labelRequests, warnings)
2238
2549
  if (!glyph) continue;
2239
2550
  let placement = glyph.placements.get(String(label.slot));
2240
2551
  if (!placement) continue;
2241
- if (label.rect = placement.labelRect, label.hidden) {
2552
+ let dx = label.rect.x - placement.groupRect.x, dy = label.rect.y - placement.groupRect.y, labelRect = dx === 0 && dy === 0 ? placement.labelRect : { ...placement.labelRect, x: placement.labelRect.x + dx, y: placement.labelRect.y + dy }, chipCenter = dx === 0 && dy === 0 ? placement.chipCenter : { x: placement.chipCenter.x + dx, y: placement.chipCenter.y + dy };
2553
+ if (label.rect = labelRect, label.hidden) {
2242
2554
  glyph.nodeIds.splice(0);
2243
2555
  continue;
2244
2556
  }
2245
2557
  label.leader = calloutGlyphLeader(
2246
- placement.chipCenter,
2558
+ chipCenter,
2247
2559
  placement.anchor,
2248
2560
  glyph.radius
2249
2561
  );
2250
- let glyphNodes = calloutGlyphNodes(glyph, placement.chipCenter, input.theme);
2562
+ let glyphNodes = calloutGlyphNodes(glyph, chipCenter, input.theme);
2251
2563
  nodes.push(...glyphNodes);
2252
2564
  let chipRect = {
2253
- x: placement.chipCenter.x - glyph.radius,
2254
- y: placement.chipCenter.y - glyph.radius,
2565
+ x: chipCenter.x - glyph.radius,
2566
+ y: chipCenter.y - glyph.radius,
2255
2567
  w: glyph.radius * 2,
2256
2568
  h: glyph.radius * 2
2257
2569
  };
2258
2570
  input.occupied.claim(chipRect, "annotation", glyph.owner, "calloutGlyph");
2259
2571
  }
2260
- finishCalloutHeads(input.theme, solved.placed, run.calloutHeads, nodes, input.occupied);
2572
+ finishCalloutHeads(input.theme, solved.placed, run.calloutHeads, nodes, input.occupied, warnings);
2261
2573
  let leaderAnchors = /* @__PURE__ */ new Map();
2262
2574
  input.annotations.forEach((annotation, index) => {
2263
2575
  if (annotation.kind !== "callout" && annotation.kind !== "note" && annotation.kind !== "abs" && annotation.kind !== "delta") return;
2264
2576
  let id = `annotation:${defaultAnnotationId(annotation, index)}`, owner = run.calloutGlyphPlans.has(id) ? void 0 : input.resolve(annotation.at)?.owner;
2265
2577
  owner && leaderAnchors.set(id, owner);
2266
- }), leaderAnchors.size > 0 && leadersOffAnchorValues(solved.placed, leaderAnchors, input.occupied), trimAnnotationGuides(nodes, input.occupied), pruneOrphanAnnotationArms(nodes, placed, solved.placed);
2578
+ }), leaderAnchors.size > 0 && leadersOffAnchorValues(solved.placed, leaderAnchors, input.occupied), trimAnnotationGuides(nodes, input.occupied);
2579
+ for (let drawing of run.textDrawings ?? []) drawFromText(input, run, drawing, solved.placed, nodes, warnings);
2580
+ run.drawings && cutDrawingsAroundText(nodes, placed, input.occupied, warnings, run.drawings), pruneOrphanAnnotationArms(nodes, placed, solved.placed);
2267
2581
  for (let annotation of placed)
2268
2582
  annotation.derivation || (annotation.derivation = {
2269
2583
  basis: "authored",
@@ -2302,7 +2616,7 @@ function settleEraBands(input, run, requests) {
2302
2616
  return { solved: solveLabels(requests, input.occupied, input.solveCtx), bandNeed: 0 };
2303
2617
  for (let plan of run.eraBands) {
2304
2618
  let req = requests.find((r) => r.id === plan.labelId);
2305
- req && (req.candidates = buildExtendedEraBandCandidates(plan, input, !1));
2619
+ req && (req.candidates = buildExtendedEraBandCandidates(plan, input, !1), plan.style === "shade" && (req.pinnedSlot ?? input.solveCtx.pins[plan.labelId]) === void 0 && req.candidates.sort((a, b) => +!rectContains(input.plot, a.rect) - +!rectContains(input.plot, b.rect)));
2306
2620
  }
2307
2621
  let solved = solveLabels(requests, input.occupied, input.solveCtx), stillHidden = run.eraBands.filter((plan) => solved.placed.find((l) => l.id === plan.labelId)?.hidden);
2308
2622
  if (stillHidden.length === 0)
@@ -2445,7 +2759,7 @@ function resolveEvents(input) {
2445
2759
  }, groups = new Map((input.events?.groups ?? []).map((g, i) => [g.id, { ...g, glyph: g.glyph ?? GLYPHS[i % GLYPHS.length] }])), paintOf = (tone) => tone === "neutral" ? { token: "inkMuted" } : input.colorblindSafe ? colorblindPaint(tone) : { token: tone }, out = [];
2446
2760
  return input.annotations.forEach((annotation, index) => {
2447
2761
  if (annotation.kind !== "event") return;
2448
- let ann = annotation, id = defaultAnnotationId(ann, index), warn2 = (code, message, suggest) => warnings.push({ code, severity: "warn", message, owner: { annotationId: id }, ...suggest ? { suggest } : {} }), pos, date, when, period;
2762
+ let ann = annotation, id = defaultAnnotationId(ann, index), ref = annotationRef(annotation, index, `options.annotations[${index}]`), warn2 = (code, message, suggest) => warnings.push({ code, severity: "warn", message, owner: { annotationId: id }, ...suggest ? { suggest } : {} }), pos, date, when, period;
2449
2763
  if (ann.date !== void 0 && input.scale) {
2450
2764
  let scale = input.scale, x = scale.read(ann.date, `options.annotations[${index}].date`, !1);
2451
2765
  if (x < scale.lo || x > scale.hi) {
@@ -2460,17 +2774,21 @@ function resolveEvents(input) {
2460
2774
  if (!dated)
2461
2775
  throw new NormalizeError(
2462
2776
  "event-date-unresolvable",
2463
- `options.annotations[${index}].date`,
2777
+ `${ref.name}.date`,
2464
2778
  `event '${id}' has a date, but not every category carries an ISO date to place it by`,
2465
- "give each category an ISO 'date', or anchor the event to a category with 'at'"
2779
+ "give each category an ISO 'date', or anchor the event to a category with 'at'",
2780
+ void 0,
2781
+ ref.segments.length ? [...ref.segments, "date"] : []
2466
2782
  );
2467
2783
  let parsed = parseISODate(ann.date);
2468
2784
  if (!parsed && parseTimeText(ann.date))
2469
2785
  throw new NormalizeError(
2470
2786
  "event-time-needs-x-axis",
2471
- `options.annotations[${index}].date`,
2787
+ `${ref.name}.date`,
2472
2788
  `event '${id}' gives a time of day, and the categories are days, so the time has no place`,
2473
- "give the day only (yyyy-mm-dd), or draw the readings on a continuous axis: data.x with options.xAxis: { type: 'time' }"
2789
+ "give the day only (yyyy-mm-dd), or draw the readings on a continuous axis: data.x with options.xAxis: { type: 'time' }",
2790
+ void 0,
2791
+ ref.segments.length ? [...ref.segments, "date"] : []
2474
2792
  );
2475
2793
  let at = parsed ? posOfDay(dayOf(parsed)) : null;
2476
2794
  if (at === null) {
@@ -2642,9 +2960,9 @@ function xAt(axis, pos, count) {
2642
2960
  let ci = Math.min(count - 1, Math.max(0, Math.floor(pos))), x = axis.continuous ? axis.x(pos) : axis.x(ci) + (pos - ci - 0.5) * axis.step;
2643
2961
  return Math.min(axis.plot.x + axis.plot.w, Math.max(axis.plot.x, x));
2644
2962
  }
2645
- var TEXT_GAP = 4, GUTTER = 14, ROW_GAP = 6, TRACK = 6;
2963
+ var TEXT_GAP2 = 4, GUTTER = 14, ROW_GAP = 6, TRACK = 6;
2646
2964
  function extent(p, x) {
2647
- return p.side === "right" ? [x - 1, x + TEXT_GAP + p.block.w] : [x - TEXT_GAP - p.block.w, x + 1];
2965
+ return p.side === "right" ? [x - 1, x + TEXT_GAP2 + p.block.w] : [x - TEXT_GAP2 - p.block.w, x + 1];
2648
2966
  }
2649
2967
  function planLane(events, axis, count, rows, bounds, f, measure, noKey = !1) {
2650
2968
  let maxW = Math.min(230, axis.plot.w / 3.6), placed = [], keyed = [], inline = [], poleAt = /* @__PURE__ */ new Set(), order = [...events].sort((a, b) => b.priority - a.priority || byTime(a, b)), clashes = (others, { block, row, side }) => {
@@ -2748,10 +3066,12 @@ function settleEventLane(input) {
2748
3066
  return fullBand !== void 0 && recordPartNeed(framed.frame.frame, Math.ceil((s.size.height - fullBand) / (1 - KEY_BAND_FLOOR) - 1e-6)), { framed: shifted, area: s.area(shifted, s.warnings), lane: { plan, top } };
2749
3067
  }
2750
3068
  function emitEventLane(theme, input) {
2751
- let { plan, top, axis, occupied } = input, f = plan.fonts, laneBottom = top + plan.height, rowTop = (row) => top + (plan.rows - 1 - row) * (plan.rowH + ROW_GAP), tracksTop = top + plan.rows * (plan.rowH + ROW_GAP), stripY = tracksTop + (plan.tracks ? plan.tracks * TRACK + 2 : 0) + f.ringR + 1, stopAt = (x) => {
2752
- if (input.mode === "through") return laneBottom;
2753
- let hits = occupied.hitsWhich({ x: x - 1, y: laneBottom, w: 2, h: Math.max(0, input.baseline - laneBottom) }).filter((o) => o.kind === "mark" || o.kind === "label");
2754
- return Math.min(input.baseline, minOf(hits.map((o) => o.rect.y))) - 3;
3069
+ let { plan, top, axis, occupied } = input, f = plan.fonts, laneBottom = top + plan.height, rowTop = (row) => top + (plan.rows - 1 - row) * (plan.rowH + ROW_GAP), tracksTop = top + plan.rows * (plan.rowH + ROW_GAP), stripY = tracksTop + (plan.tracks ? plan.tracks * TRACK + 2 : 0) + f.ringR + 1, poleRuns = (x, y1) => {
3070
+ if (input.mode === "through") return laneBottom > y1 ? [[y1, laneBottom]] : [];
3071
+ let hits = occupied.hitsWhich({ x: x - 1, y: laneBottom, w: 2, h: Math.max(0, input.baseline - laneBottom) }).filter((o) => o.kind === "mark" || o.kind === "label"), seriesName = (o) => o.kind === "label" && o.owner.seriesId !== void 0 && o.owner.categoryId === void 0 && o.owner.annotationId === void 0, end = Math.min(input.baseline, minOf(hits.filter((o) => !seriesName(o)).map((o) => o.rect.y))) - 3, runs = [], from = y1;
3072
+ for (let name of hits.filter((o) => seriesName(o) && o.rect.y < end).sort((a, b) => a.rect.y - b.rect.y))
3073
+ name.rect.y - 3 > from && runs.push([from, name.rect.y - 3]), from = Math.max(from, name.rect.y + name.rect.h + 3);
3074
+ return end > from && runs.push([from, end]), runs;
2755
3075
  }, requests = [], fixed = (id, evId, text2, lines, font, rect, slot, role = "note") => requests.push({ id, kind: "annotation", owner: { annotationId: evId }, text: text2, lines, typeRole: font === f.num ? "micro" : font === f.title ? "axis" : "footnote", font, priority: PRIORITY.valueLine, pad: 0, candidates: [{ slot, rect, penalty: 0 }], role });
2756
3076
  for (let p of plan.placed) {
2757
3077
  let slot = `lane-${p.row}-${p.side}`;
@@ -2782,7 +3102,7 @@ function emitEventLane(theme, input) {
2782
3102
  [0.28, 0.5, 0.72].forEach((fraction, row) => {
2783
3103
  let y = axis.plot.y + axis.plot.h * fraction - block.h / 2;
2784
3104
  for (let side of ["right", "left"]) {
2785
- let rect = { x: side === "right" ? x + TEXT_GAP : x - TEXT_GAP - block.w, y, w: block.w, h: block.h };
3105
+ let rect = { x: side === "right" ? x + TEXT_GAP2 : x - TEXT_GAP2 - block.w, y, w: block.w, h: block.h };
2786
3106
  rect.x >= axis.plot.x && rect.x + rect.w <= axis.plot.x + axis.plot.w && candidates.push({ slot: `inline-${side}-${row}`, rect, penalty: row + (side === "left" ? 0.5 : 0), needsBacking: !0 });
2787
3107
  }
2788
3108
  }), requests.push({
@@ -2807,8 +3127,10 @@ function emitEventLane(theme, input) {
2807
3127
  }, own = (evId, node, back = !1) => {
2808
3128
  (back ? behind : nodes).push(node), nodeIds.set(evId, [...nodeIds.get(evId) ?? [], node.id]);
2809
3129
  }, pole = (ev, x, y1) => {
2810
- let owner = { annotationId: ev.id }, y2 = stopAt(x);
2811
- y2 > y1 && (own(ev.id, { t: "line", id: `ann:${ev.id}:pole`, x1: x, y1, x2: x, y2, stroke: { token: "leader" }, width: strokeToken(theme, "rule"), owner, part: "eventPole" }), occupied.claim({ x: x - 1, y: y1, w: 2, h: y2 - y1 }, "annotation", owner, "eventPole")), input.mode === "through" && input.baseline > laneBottom && own(ev.id, { t: "line", id: `ann:${ev.id}:rule`, x1: x, y1: laneBottom, x2: x, y2: input.baseline, stroke: { token: "leader" }, width: strokeToken(theme, "rule"), dash: dashToken(theme, "dotted"), lineCap: "round", owner, part: "eventRule" }, !0);
3130
+ let owner = { annotationId: ev.id };
3131
+ poleRuns(x, y1).forEach(([from, to], k) => {
3132
+ own(ev.id, { t: "line", id: `ann:${ev.id}:pole${k === 0 ? "" : `:${k + 1}`}`, x1: x, y1: from, x2: x, y2: to, stroke: { token: "leader" }, width: strokeToken(theme, "rule"), owner, part: "eventPole" }), occupied.claim({ x: x - 1, y: from, w: 2, h: to - from }, "annotation", owner, "eventPole");
3133
+ }), input.mode === "through" && input.baseline > laneBottom && own(ev.id, { t: "line", id: `ann:${ev.id}:rule`, x1: x, y1: laneBottom, x2: x, y2: input.baseline, stroke: { token: "leader" }, width: strokeToken(theme, "rule"), dash: dashToken(theme, "dotted"), lineCap: "round", owner, part: "eventRule" }, !0);
2812
3134
  }, text = (evId, id, line, halo) => {
2813
3135
  let owner = { annotationId: evId }, gs = line.glyph ? 11 * f.glyphS : 0;
2814
3136
  line.glyph && own(evId, eventGlyphNode(line.glyph.glyph, line.rect.x + 3.6 * f.glyphS, line.rect.y + line.font.size * (EVENT_TEXT_ASCENT - 0.35), f.glyphS, line.glyph.paint, `ann:${evId}:glyph`, owner, "eventGlyph"));
@@ -2894,7 +3216,7 @@ function emitEventLane(theme, input) {
2894
3216
  return { nodes, behind, labels: solved.placed, placed, warnings: solved.warnings };
2895
3217
  }
2896
3218
  function blockLines(block, pole, top, side, f) {
2897
- let x = side === "right" ? pole + TEXT_GAP : pole - TEXT_GAP, align = side === "right" ? "start" : "end", rect = (y2, w, h) => ({ x: side === "right" ? x : x - w, y: y2, w, h }), ev = block.ev, out = [], y = top;
3219
+ let x = side === "right" ? pole + TEXT_GAP2 : pole - TEXT_GAP2, align = side === "right" ? "start" : "end", rect = (y2, w, h) => ({ x: side === "right" ? x : x - w, y: y2, w, h }), ev = block.ev, out = [], y = top;
2898
3220
  if (block.headerW > 0) {
2899
3221
  let header = headerRuns(ev).map((r) => r.text).join("");
2900
3222
  out.push({ id: `event:${ev.id}:header`, text: header, lines: [header], font: f.note, ink: { token: "inkMuted" }, x, align, rect: rect(y, block.headerW, f.noteLH), header: ev, ...ev.glyph ? { glyph: ev } : {} }), y += f.noteLH;
@@ -2907,7 +3229,7 @@ function valueAnnotationLabels(labels, annotations) {
2907
3229
  return (Array.isArray(annotations) ? annotations : []).flatMap((item, i) => (item?.kind === "callout" || item?.kind === "note") && `${item.text}${item.headline}`.includes("${value}") ? labels.filter((label) => label.kind === "annotation" && !label.hidden && label.owner.annotationId === defaultAnnotationId(item, i)).map((label) => [label, typeof item.at == "string" ? { categoryId: item.at } : item.at ?? {}]) : []);
2908
3230
  }
2909
3231
  function linkAnnotateEngine() {
2910
- publishDeferred("annotate", { runAnnotatePass, settleEventLane, emitEventLane, drawCagrArm, drawHorizontalLevelDiff, valueAnnotationLabels });
3232
+ publishDeferred("annotate", { runAnnotatePass, settleEventLane, emitEventLane, drawCagrArm, drawHorizontalLevelDiff, valueAnnotationLabels, corridorEdgeRects });
2911
3233
  }
2912
3234
  linkAnnotateEngine();
2913
3235