boardplot 0.0.0-stage → 0.52.5

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 (817) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/LICENSE +201 -0
  3. package/NOTICE.md +180 -0
  4. package/README.md +208 -2
  5. package/THIRD_PARTY_NOTICES.md +1110 -0
  6. package/dist/DiagnosticDetails-UNYNYCAH.js +69 -0
  7. package/dist/ReaderBox-VUNSFKZY.js +137 -0
  8. package/dist/annotateEngine-H7OW4H3W.js +30 -0
  9. package/dist/build-identity.json +6 -0
  10. package/dist/chunk-24WB3HMB.js +621 -0
  11. package/dist/chunk-263SZKIL.js +8 -0
  12. package/dist/chunk-27QQEWNV.js +18 -0
  13. package/dist/chunk-2AKWCMS4.js +24 -0
  14. package/dist/chunk-2DHJJ2EN.js +24 -0
  15. package/dist/chunk-2EQE4E3I.js +22 -0
  16. package/dist/chunk-2GELJH37.js +88 -0
  17. package/dist/chunk-2JAWQ7VV.js +3874 -0
  18. package/dist/chunk-2LMCD3ZR.js +6 -0
  19. package/dist/chunk-2MTWKMEG.js +841 -0
  20. package/dist/chunk-2SGIHKKU.js +33 -0
  21. package/dist/chunk-2UVTHU7A.js +1146 -0
  22. package/dist/chunk-33CBPK5Q.js +2800 -0
  23. package/dist/chunk-33PLBIMA.js +176 -0
  24. package/dist/chunk-35DZP2R2.js +22 -0
  25. package/dist/chunk-3D3D3D23.js +25 -0
  26. package/dist/chunk-3EZRM4YM.js +92 -0
  27. package/dist/chunk-3GZECHOK.js +802 -0
  28. package/dist/chunk-3HHNQPAH.js +68 -0
  29. package/dist/chunk-3I6RANBJ.js +1058 -0
  30. package/dist/chunk-3SIRPKMP.js +12 -0
  31. package/dist/chunk-3W23F7EY.js +185 -0
  32. package/dist/chunk-3XQ635KD.js +24 -0
  33. package/dist/chunk-3ZCKEANJ.js +24 -0
  34. package/dist/chunk-4DNOEV3Q.js +25857 -0
  35. package/dist/chunk-4GB7TBY7.js +373 -0
  36. package/dist/chunk-4SM2ONUC.js +18 -0
  37. package/dist/chunk-5C7TWNYZ.js +79 -0
  38. package/dist/chunk-5DJXJXDE.js +58 -0
  39. package/dist/chunk-5ENRZX6I.js +687 -0
  40. package/dist/chunk-5KWXRYAT.js +294 -0
  41. package/dist/chunk-5T5YW52S.js +47 -0
  42. package/dist/chunk-627P6T25.js +936 -0
  43. package/dist/chunk-62FR4FYJ.js +23 -0
  44. package/dist/chunk-6JUJ2DU3.js +67 -0
  45. package/dist/chunk-6KWIQ5KF.js +18 -0
  46. package/dist/chunk-6UBEGKIQ.js +25 -0
  47. package/dist/chunk-6XE3GVGU.js +116 -0
  48. package/dist/chunk-76ANFJOI.js +227 -0
  49. package/dist/chunk-7IFLQMJL.js +160 -0
  50. package/dist/chunk-7JVAQX6C.js +28 -0
  51. package/dist/chunk-7QDAHY5M.js +63 -0
  52. package/dist/chunk-7VXZDB45.js +149 -0
  53. package/dist/chunk-7X65ZQN4.js +38 -0
  54. package/dist/chunk-A2FHZH7E.js +1410 -0
  55. package/dist/chunk-A372DLQX.js +54 -0
  56. package/dist/chunk-A3ULWR5N.js +76 -0
  57. package/dist/chunk-A4QZXLXF.js +7 -0
  58. package/dist/chunk-A5JWFZVU.js +1467 -0
  59. package/dist/chunk-A5LZUYK4.js +59 -0
  60. package/dist/chunk-A6XCAQ52.js +89 -0
  61. package/dist/chunk-A7A4PDG5.js +24 -0
  62. package/dist/chunk-A7IEVBYI.js +35 -0
  63. package/dist/chunk-ACXX2JNL.js +6 -0
  64. package/dist/chunk-AFK47A6O.js +25 -0
  65. package/dist/chunk-ALKTNXMR.js +3650 -0
  66. package/dist/chunk-AOQ6VF5H.js +6 -0
  67. package/dist/chunk-ASAON7G4.js +648 -0
  68. package/dist/chunk-ATTE3FYC.js +24 -0
  69. package/dist/chunk-AZOUSKZD.js +728 -0
  70. package/dist/chunk-B2EBEXIS.js +113 -0
  71. package/dist/chunk-B67K5X4M.js +58 -0
  72. package/dist/chunk-BBL3R5YZ.js +186 -0
  73. package/dist/chunk-BIDIGDGH.js +6 -0
  74. package/dist/chunk-BKYMLFUG.js +69 -0
  75. package/dist/chunk-BLFWUMTD.js +12 -0
  76. package/dist/chunk-BM6SFFWF.js +6 -0
  77. package/dist/chunk-BUPLB3EX.js +129 -0
  78. package/dist/chunk-BVWU6GOB.js +47 -0
  79. package/dist/chunk-BW5VLBSZ.js +15 -0
  80. package/dist/chunk-C64FBRJO.js +290 -0
  81. package/dist/chunk-CAE2HK2G.js +295 -0
  82. package/dist/chunk-CCQNL33L.js +446 -0
  83. package/dist/chunk-CDZHNLO6.js +42 -0
  84. package/dist/chunk-COKHNEJP.js +24 -0
  85. package/dist/chunk-COYPDRJK.js +21 -0
  86. package/dist/chunk-CRZKGHZ6.js +1810 -0
  87. package/dist/chunk-CS4DHFNG.js +128 -0
  88. package/dist/chunk-CYDZP5W6.js +1589 -0
  89. package/dist/chunk-D4BIV6WG.js +1072 -0
  90. package/dist/chunk-D4SOADBD.js +19 -0
  91. package/dist/chunk-DCCJRLAJ.js +422 -0
  92. package/dist/chunk-DFKTS6XJ.js +75 -0
  93. package/dist/chunk-DGDOGOTQ.js +25 -0
  94. package/dist/chunk-DLC23CKC.js +53 -0
  95. package/dist/chunk-DRTA6JG5.js +160 -0
  96. package/dist/chunk-DVKBU23L.js +97 -0
  97. package/dist/chunk-E2HEVF23.js +692 -0
  98. package/dist/chunk-EC2NAYPQ.js +24 -0
  99. package/dist/chunk-EKQK5D6G.js +14 -0
  100. package/dist/chunk-EKQMYG2B.js +2353 -0
  101. package/dist/chunk-ELYU6TRQ.js +98 -0
  102. package/dist/chunk-EQT3EPTB.js +203 -0
  103. package/dist/chunk-ERAIVAK5.js +1359 -0
  104. package/dist/chunk-ETHWK2RZ.js +16 -0
  105. package/dist/chunk-EWVKBRLV.js +72 -0
  106. package/dist/chunk-F77BNDAT.js +43 -0
  107. package/dist/chunk-FGAGGPFF.js +566 -0
  108. package/dist/chunk-FIANWJXX.js +19 -0
  109. package/dist/chunk-FIWNDOMO.js +6 -0
  110. package/dist/chunk-FOKEGVPB.js +24 -0
  111. package/dist/chunk-FT3F72C3.js +30 -0
  112. package/dist/chunk-FT47HQ5U.js +47 -0
  113. package/dist/chunk-GDOW2KNP.js +19 -0
  114. package/dist/chunk-GDQ3NGDZ.js +17 -0
  115. package/dist/chunk-GH3ZMBFX.js +563 -0
  116. package/dist/chunk-GQPESFAF.js +3378 -0
  117. package/dist/chunk-GQS46LC3.js +50 -0
  118. package/dist/chunk-GULJ6KVT.js +587 -0
  119. package/dist/chunk-GWQIXU37.js +2774 -0
  120. package/dist/chunk-GZ2VNM4L.js +24 -0
  121. package/dist/chunk-GZ4RHGIW.js +836 -0
  122. package/dist/chunk-H4H4O62O.js +46 -0
  123. package/dist/chunk-H57TJD3B.js +72 -0
  124. package/dist/chunk-H7UZZ7KP.js +24 -0
  125. package/dist/chunk-HAAUJDGB.js +83 -0
  126. package/dist/chunk-HFG76JTS.js +296 -0
  127. package/dist/chunk-HJXXFPOL.js +211 -0
  128. package/dist/chunk-HTYFQHRC.js +24 -0
  129. package/dist/chunk-HUF6TQ2J.js +24 -0
  130. package/dist/chunk-HUFCSX2Y.js +89 -0
  131. package/dist/chunk-HX3MQ3H4.js +26 -0
  132. package/dist/chunk-HZQEQ34U.js +296 -0
  133. package/dist/chunk-I322G5UG.js +888 -0
  134. package/dist/chunk-IDDA5INB.js +60 -0
  135. package/dist/chunk-IDTLHPTK.js +60 -0
  136. package/dist/chunk-II7652VA.js +2918 -0
  137. package/dist/chunk-IN4QT33I.js +38 -0
  138. package/dist/chunk-IV2UXZXX.js +16 -0
  139. package/dist/chunk-IXSZ7OKR.js +133 -0
  140. package/dist/chunk-IYEFEBRN.js +41 -0
  141. package/dist/chunk-IZ35GMGB.js +2543 -0
  142. package/dist/chunk-IZCOG3FS.js +28 -0
  143. package/dist/chunk-JA755JHN.js +379 -0
  144. package/dist/chunk-JETXFF3M.js +33 -0
  145. package/dist/chunk-JFBEAUJ6.js +24 -0
  146. package/dist/chunk-JFG4DHKQ.js +48 -0
  147. package/dist/chunk-JL5BRMDT.js +179 -0
  148. package/dist/chunk-JLCAWQ3H.js +195 -0
  149. package/dist/chunk-JLZM7XMZ.js +525 -0
  150. package/dist/chunk-JMH5MD5A.js +19 -0
  151. package/dist/chunk-JRPI64AQ.js +3066 -0
  152. package/dist/chunk-JSX3C6LL.js +344 -0
  153. package/dist/chunk-JY4R3GML.js +83 -0
  154. package/dist/chunk-JYBT2JNY.js +61 -0
  155. package/dist/chunk-K2HNV4LE.js +2008 -0
  156. package/dist/chunk-KAXJFL7N.js +43 -0
  157. package/dist/chunk-KDMKHR5A.js +32 -0
  158. package/dist/chunk-KFFNCDX6.js +19 -0
  159. package/dist/chunk-KKWZWP67.js +24 -0
  160. package/dist/chunk-KOJ5QETJ.js +8 -0
  161. package/dist/chunk-KPMGGE4W.js +51 -0
  162. package/dist/chunk-KS7DXCXH.js +27 -0
  163. package/dist/chunk-KSYVTEKR.js +24 -0
  164. package/dist/chunk-KU4YS6HN.js +61 -0
  165. package/dist/chunk-KYELSLDJ.js +40 -0
  166. package/dist/chunk-LC3PSQJJ.js +383 -0
  167. package/dist/chunk-LC6DYCTG.js +85 -0
  168. package/dist/chunk-LNKY5Z2X.js +23 -0
  169. package/dist/chunk-LO2DANS6.js +302 -0
  170. package/dist/chunk-M4SPKUZE.js +7 -0
  171. package/dist/chunk-M4YLED7M.js +17 -0
  172. package/dist/chunk-M6KTNAND.js +746 -0
  173. package/dist/chunk-MCOIEWW6.js +54 -0
  174. package/dist/chunk-MDYLOIS2.js +48 -0
  175. package/dist/chunk-MEISCROL.js +24 -0
  176. package/dist/chunk-MFLH5ZDQ.js +69 -0
  177. package/dist/chunk-MIXKQJ64.js +935 -0
  178. package/dist/chunk-MJMJEURO.js +359 -0
  179. package/dist/chunk-MNJ2DHU6.js +526 -0
  180. package/dist/chunk-NEVSQGOI.js +63 -0
  181. package/dist/chunk-NG5IGZXC.js +1179 -0
  182. package/dist/chunk-NLOMCLKI.js +3303 -0
  183. package/dist/chunk-NMCOUVN5.js +24 -0
  184. package/dist/chunk-NT3HAZYT.js +51 -0
  185. package/dist/chunk-NXNQQ3DS.js +382 -0
  186. package/dist/chunk-NYEY6W5R.js +569 -0
  187. package/dist/chunk-OAPCJO6W.js +23 -0
  188. package/dist/chunk-OH7FA4TF.js +251 -0
  189. package/dist/chunk-OLNORNCT.js +331 -0
  190. package/dist/chunk-OQEBOVUO.js +30 -0
  191. package/dist/chunk-ORUJI3VB.js +83 -0
  192. package/dist/chunk-PEN2DK7T.js +49 -0
  193. package/dist/chunk-PGIQMQRU.js +1650 -0
  194. package/dist/chunk-PTVOXB5T.js +39 -0
  195. package/dist/chunk-PUVGWJQ5.js +24 -0
  196. package/dist/chunk-PWROWDZS.js +137 -0
  197. package/dist/chunk-Q6XJOJTY.js +29 -0
  198. package/dist/chunk-QBR6IKIX.js +50 -0
  199. package/dist/chunk-QETGGFH2.js +30 -0
  200. package/dist/chunk-QG6MOQLI.js +2934 -0
  201. package/dist/chunk-QGCEHR6S.js +13 -0
  202. package/dist/chunk-QHFQHQDC.js +43 -0
  203. package/dist/chunk-QHRE2M6V.js +26 -0
  204. package/dist/chunk-QKL7IY42.js +38 -0
  205. package/dist/chunk-QN6JHMGU.js +44 -0
  206. package/dist/chunk-QNHZXFRA.js +347 -0
  207. package/dist/chunk-QPWRHDLZ.js +17 -0
  208. package/dist/chunk-QVABTUDS.js +80 -0
  209. package/dist/chunk-QXILAMAU.js +28 -0
  210. package/dist/chunk-QZAT46PP.js +95 -0
  211. package/dist/chunk-R3WI7ZLE.js +545 -0
  212. package/dist/chunk-R5SWC3EW.js +30 -0
  213. package/dist/chunk-RJQ5YS3Q.js +40 -0
  214. package/dist/chunk-RNOD2UWF.js +613 -0
  215. package/dist/chunk-RNXITK5M.js +24 -0
  216. package/dist/chunk-ROXO4R3J.js +16 -0
  217. package/dist/chunk-RQ5DNYLG.js +10 -0
  218. package/dist/chunk-RSWVH7DB.js +24 -0
  219. package/dist/chunk-RTJXOIIQ.js +12 -0
  220. package/dist/chunk-RZNYW7UP.js +133 -0
  221. package/dist/chunk-S4F27M7N.js +37 -0
  222. package/dist/chunk-S4ONWRJE.js +28 -0
  223. package/dist/chunk-S53OGZL6.js +168 -0
  224. package/dist/chunk-S5ADHIZK.js +2508 -0
  225. package/dist/chunk-S62M63LU.js +19 -0
  226. package/dist/chunk-S7VDRUED.js +62 -0
  227. package/dist/chunk-SGD3ZHID.js +250 -0
  228. package/dist/chunk-SGSPYHFE.js +40 -0
  229. package/dist/chunk-SLTMRTXV.js +597 -0
  230. package/dist/chunk-SXGTRZFN.js +26 -0
  231. package/dist/chunk-SZPTTNW7.js +16 -0
  232. package/dist/chunk-T3IGJARD.js +22 -0
  233. package/dist/chunk-TA3TFKYZ.js +86 -0
  234. package/dist/chunk-TNEHPP3H.js +18 -0
  235. package/dist/chunk-TPYV2FTV.js +25 -0
  236. package/dist/chunk-TPZB2YWR.js +25 -0
  237. package/dist/chunk-TSR5YDPS.js +1266 -0
  238. package/dist/chunk-TTR7EWNH.js +170 -0
  239. package/dist/chunk-TVHLKVUO.js +24 -0
  240. package/dist/chunk-TXINIAFL.js +198 -0
  241. package/dist/chunk-TXZBBZOG.js +58 -0
  242. package/dist/chunk-UEU46Q3D.js +300 -0
  243. package/dist/chunk-UMDEWWXT.js +33 -0
  244. package/dist/chunk-UQSVWO7Z.js +334 -0
  245. package/dist/chunk-UZF3G2FN.js +942 -0
  246. package/dist/chunk-V422EKLW.js +24 -0
  247. package/dist/chunk-V4DYVLOO.js +433 -0
  248. package/dist/chunk-V4VC25UL.js +128 -0
  249. package/dist/chunk-V667FCIJ.js +12 -0
  250. package/dist/chunk-VABRPZVC.js +43 -0
  251. package/dist/chunk-VB2MJLET.js +19 -0
  252. package/dist/chunk-VDAKTZQP.js +18 -0
  253. package/dist/chunk-VDAZPGR2.js +79 -0
  254. package/dist/chunk-VXZFQKBJ.js +21 -0
  255. package/dist/chunk-VYMGZ27S.js +133 -0
  256. package/dist/chunk-W2RGSGRR.js +131 -0
  257. package/dist/chunk-W7UZXD5D.js +1109 -0
  258. package/dist/chunk-WDUNR2VI.js +2718 -0
  259. package/dist/chunk-WHSTEAVP.js +229 -0
  260. package/dist/chunk-WJMUMN3I.js +127 -0
  261. package/dist/chunk-WLZ54FWG.js +120 -0
  262. package/dist/chunk-WMJPFLF3.js +2980 -0
  263. package/dist/chunk-WRHFBCVY.js +24 -0
  264. package/dist/chunk-WVSNSWBJ.js +47 -0
  265. package/dist/chunk-WYJEOMNY.js +31 -0
  266. package/dist/chunk-WYJMV62X.js +24 -0
  267. package/dist/chunk-WZGJSQKN.js +29 -0
  268. package/dist/chunk-WZL4EEBS.js +11 -0
  269. package/dist/chunk-X7TXGKRX.js +272 -0
  270. package/dist/chunk-XB4KZ6WO.js +81 -0
  271. package/dist/chunk-XDLQRSSH.js +266 -0
  272. package/dist/chunk-XDS4UZGR.js +113 -0
  273. package/dist/chunk-XEGRWWNO.js +30 -0
  274. package/dist/chunk-XO5ONLVM.js +420 -0
  275. package/dist/chunk-XPWRD424.js +24 -0
  276. package/dist/chunk-XTNV2YMB.js +50 -0
  277. package/dist/chunk-XW5J5JAX.js +42 -0
  278. package/dist/chunk-XY5O74BH.js +33 -0
  279. package/dist/chunk-XYONCO5Q.js +984 -0
  280. package/dist/chunk-Y4PXIJMD.js +829 -0
  281. package/dist/chunk-YAYRRKC7.js +24 -0
  282. package/dist/chunk-YEDYBMCW.js +210 -0
  283. package/dist/chunk-YFG4E3N2.js +1161 -0
  284. package/dist/chunk-YHTO46W2.js +2670 -0
  285. package/dist/chunk-YI2ZVTCB.js +38 -0
  286. package/dist/chunk-YKO3VCTF.js +24 -0
  287. package/dist/chunk-YP3I6W7T.js +24 -0
  288. package/dist/chunk-YQ2B3YVF.js +687 -0
  289. package/dist/chunk-YS6KMYM4.js +91 -0
  290. package/dist/chunk-YTSSXSZR.js +197 -0
  291. package/dist/chunk-Z256ACGC.js +27 -0
  292. package/dist/chunk-Z2MGTKDR.js +20 -0
  293. package/dist/chunk-Z5VSLLNY.js +23 -0
  294. package/dist/chunk-Z7X3RGGA.js +22 -0
  295. package/dist/chunk-ZF43WRG3.js +29 -0
  296. package/dist/chunk-ZJKOLOVF.js +1754 -0
  297. package/dist/chunk-ZQ4VFQID.js +76 -0
  298. package/dist/chunk-ZSLGN6CO.js +89 -0
  299. package/dist/chunk-ZVTFZF4V.js +542 -0
  300. package/dist/cli/index.js +9 -0
  301. package/dist/core-5Z6UW5DS.js +31 -0
  302. package/dist/core-6ANZ2OWO.js +40 -0
  303. package/dist/core-6LLJNZ4O.js +37 -0
  304. package/dist/core-CPN2HF75.js +33 -0
  305. package/dist/core-CS7AKNME.js +37 -0
  306. package/dist/core-DBRILYNB.js +38 -0
  307. package/dist/core-DU77ZYPR.js +34 -0
  308. package/dist/core-E6YD7VU4.js +32 -0
  309. package/dist/core-EE55P6XK.js +56 -0
  310. package/dist/core-FFLPH5XK.js +41 -0
  311. package/dist/core-IV26EL5C.js +32 -0
  312. package/dist/core-IZVZ2B7Y.js +34 -0
  313. package/dist/core-JQV7STNF.js +34 -0
  314. package/dist/core-KBH3EJZV.js +32 -0
  315. package/dist/core-KFBW5PRT.js +36 -0
  316. package/dist/core-KWGXHBJE.js +37 -0
  317. package/dist/core-MZMR2DF4.js +32 -0
  318. package/dist/core-OK2ZY5OJ.js +29 -0
  319. package/dist/core-OV5MPTZP.js +43 -0
  320. package/dist/core-OW5V74Q4.js +40 -0
  321. package/dist/core-PL64QPOH.js +57 -0
  322. package/dist/core-PVINU5JJ.js +33 -0
  323. package/dist/core-QUYSNTC7.js +34 -0
  324. package/dist/core-RE3L6YCM.js +29 -0
  325. package/dist/core-RUA3EWW3.js +39 -0
  326. package/dist/core-RY6IFRKM.js +35 -0
  327. package/dist/core-SCWEVNUY.js +34 -0
  328. package/dist/core-SE67HHFG.js +55 -0
  329. package/dist/core-T5Q4DSH2.js +32 -0
  330. package/dist/core-TJX3I7KH.js +37 -0
  331. package/dist/core-ULUA5ZB2.js +55 -0
  332. package/dist/core-WLVU2HWX.js +46 -0
  333. package/dist/core-WQPHNVNY.js +51 -0
  334. package/dist/core-XXIOJY2X.js +52 -0
  335. package/dist/core-ZH7XTJTD.js +39 -0
  336. package/dist/core-ZHE7N4NS.js +50 -0
  337. package/dist/core-ZJYLJWZQ.js +38 -0
  338. package/dist/dataTable-IL7HVDHL.js +58 -0
  339. package/dist/engine-MYLZI5VH.js +961 -0
  340. package/dist/fixtures.d.ts +1 -0
  341. package/dist/fixtures.js +40 -0
  342. package/dist/fontTables-ZYBUCJ5N.js +18 -0
  343. package/dist/fonts.d.ts +1 -0
  344. package/dist/fonts.js +19 -0
  345. package/dist/geo/dach.d.ts +1 -0
  346. package/dist/geo/dach.js +14 -0
  347. package/dist/geo/de-states.d.ts +1 -0
  348. package/dist/geo/de-states.js +14 -0
  349. package/dist/geo/eu27.d.ts +1 -0
  350. package/dist/geo/eu27.js +14 -0
  351. package/dist/geo/europe.d.ts +1 -0
  352. package/dist/geo/europe.js +14 -0
  353. package/dist/geo/index.d.ts +1 -0
  354. package/dist/geo/index.js +41 -0
  355. package/dist/geo/us-states.d.ts +1 -0
  356. package/dist/geo/us-states.js +14 -0
  357. package/dist/geo/world.d.ts +1 -0
  358. package/dist/geo/world.js +14 -0
  359. package/dist/index.d.ts +1 -0
  360. package/dist/index.js +363 -0
  361. package/dist/main-ISJ53IS5.js +568 -0
  362. package/dist/mcp/server.js +1023 -0
  363. package/dist/module-SVEW5ZUE.js +137233 -0
  364. package/dist/react/bar.d.ts +1 -0
  365. package/dist/react/bar.js +80 -0
  366. package/dist/react/bartable.d.ts +1 -0
  367. package/dist/react/bartable.js +70 -0
  368. package/dist/react/box.d.ts +1 -0
  369. package/dist/react/box.js +64 -0
  370. package/dist/react/bullet.d.ts +1 -0
  371. package/dist/react/bullet.js +71 -0
  372. package/dist/react/butterfly.d.ts +1 -0
  373. package/dist/react/butterfly.js +65 -0
  374. package/dist/react/choropleth.d.ts +1 -0
  375. package/dist/react/choropleth.js +67 -0
  376. package/dist/react/cohort.d.ts +1 -0
  377. package/dist/react/cohort.js +69 -0
  378. package/dist/react/column.d.ts +1 -0
  379. package/dist/react/column.js +85 -0
  380. package/dist/react/combo.d.ts +1 -0
  381. package/dist/react/combo.js +85 -0
  382. package/dist/react/creative.d.ts +1 -0
  383. package/dist/react/creative.js +61 -0
  384. package/dist/react/diagram.d.ts +1 -0
  385. package/dist/react/diagram.js +60 -0
  386. package/dist/react/dimswitch.d.ts +1 -0
  387. package/dist/react/dimswitch.js +71 -0
  388. package/dist/react/dot.d.ts +1 -0
  389. package/dist/react/dot.js +69 -0
  390. package/dist/react/export.d.ts +1 -0
  391. package/dist/react/export.js +657 -0
  392. package/dist/react/funnel.d.ts +1 -0
  393. package/dist/react/funnel.js +62 -0
  394. package/dist/react/gantt.d.ts +1 -0
  395. package/dist/react/gantt.js +62 -0
  396. package/dist/react/grid.d.ts +1 -0
  397. package/dist/react/grid.js +66 -0
  398. package/dist/react/heatmap.d.ts +1 -0
  399. package/dist/react/heatmap.js +67 -0
  400. package/dist/react/histogram.d.ts +1 -0
  401. package/dist/react/histogram.js +85 -0
  402. package/dist/react/index.d.ts +1 -0
  403. package/dist/react/index.js +503 -0
  404. package/dist/react/kpi.d.ts +1 -0
  405. package/dist/react/kpi.js +67 -0
  406. package/dist/react/likert.d.ts +1 -0
  407. package/dist/react/likert.js +82 -0
  408. package/dist/react/line.d.ts +1 -0
  409. package/dist/react/line.js +80 -0
  410. package/dist/react/mekko.d.ts +1 -0
  411. package/dist/react/mekko.js +70 -0
  412. package/dist/react/pareto.d.ts +1 -0
  413. package/dist/react/pareto.js +89 -0
  414. package/dist/react/pie.d.ts +1 -0
  415. package/dist/react/pie.js +63 -0
  416. package/dist/react/prepare.d.ts +1 -0
  417. package/dist/react/prepare.js +277 -0
  418. package/dist/react/pvm.d.ts +1 -0
  419. package/dist/react/pvm.js +67 -0
  420. package/dist/react/pyramid.d.ts +1 -0
  421. package/dist/react/pyramid.js +66 -0
  422. package/dist/react/sankey.d.ts +1 -0
  423. package/dist/react/sankey.js +59 -0
  424. package/dist/react/scatter.d.ts +1 -0
  425. package/dist/react/scatter.js +62 -0
  426. package/dist/react/slope.d.ts +1 -0
  427. package/dist/react/slope.js +63 -0
  428. package/dist/react/sparkline.d.ts +1 -0
  429. package/dist/react/sparkline.js +59 -0
  430. package/dist/react/spec.d.ts +1 -0
  431. package/dist/react/spec.js +370 -0
  432. package/dist/react/status.d.ts +1 -0
  433. package/dist/react/status.js +64 -0
  434. package/dist/react/story.d.ts +1 -0
  435. package/dist/react/story.js +140 -0
  436. package/dist/react/table.d.ts +1 -0
  437. package/dist/react/table.js +68 -0
  438. package/dist/react/theme.d.ts +1 -0
  439. package/dist/react/theme.js +53 -0
  440. package/dist/react/tilemap.d.ts +1 -0
  441. package/dist/react/tilemap.js +66 -0
  442. package/dist/react/treemap.d.ts +1 -0
  443. package/dist/react/treemap.js +61 -0
  444. package/dist/react/variance.d.ts +1 -0
  445. package/dist/react/variance.js +64 -0
  446. package/dist/react/waffle.d.ts +1 -0
  447. package/dist/react/waffle.js +62 -0
  448. package/dist/react/waterfall.d.ts +1 -0
  449. package/dist/react/waterfall.js +67 -0
  450. package/dist/resvg-ZOVDIZTV.js +23 -0
  451. package/dist/rows.d.ts +1 -0
  452. package/dist/rows.js +23 -0
  453. package/dist/rowsModule-3Y4I3M3E.js +27 -0
  454. package/dist/schema-2BMZOHXI.js +22 -0
  455. package/dist/schema-2GUBWOBC.js +26 -0
  456. package/dist/schema-34ZELWRQ.js +25 -0
  457. package/dist/schema-3BHL2B76.js +22 -0
  458. package/dist/schema-4735XAZX.js +29 -0
  459. package/dist/schema-5YTNQ6JY.js +22 -0
  460. package/dist/schema-7J3NAIN2.js +27 -0
  461. package/dist/schema-AOJJ7JZB.js +22 -0
  462. package/dist/schema-CVMV4LRA.js +22 -0
  463. package/dist/schema-D3RCMN3T.js +22 -0
  464. package/dist/schema-E2ISJ65D.js +23 -0
  465. package/dist/schema-E6YOSOWB.js +28 -0
  466. package/dist/schema-EQQB43AY.js +22 -0
  467. package/dist/schema-EVLLL5UF.js +22 -0
  468. package/dist/schema-EYQ5IBLF.js +23 -0
  469. package/dist/schema-EYZVD73N.js +22 -0
  470. package/dist/schema-G4KFMQBL.js +22 -0
  471. package/dist/schema-GH7IKSOU.js +23 -0
  472. package/dist/schema-IF5N3J56.js +42 -0
  473. package/dist/schema-IG7JIR4H.js +23 -0
  474. package/dist/schema-JJYJOQTT.js +23 -0
  475. package/dist/schema-KFC4WYH4.js +32 -0
  476. package/dist/schema-L7263JMT.js +25 -0
  477. package/dist/schema-MEAFRXVH.js +53 -0
  478. package/dist/schema-P63S63GE.js +23 -0
  479. package/dist/schema-P7LJFJAJ.js +22 -0
  480. package/dist/schema-PA2MXYY4.js +23 -0
  481. package/dist/schema-PDZ6256H.js +23 -0
  482. package/dist/schema-PNC3Z7AH.js +25 -0
  483. package/dist/schema-QEVSIMGO.js +22 -0
  484. package/dist/schema-QJJPRRE7.js +22 -0
  485. package/dist/schema-S3EQKVOT.js +23 -0
  486. package/dist/schema-STGL44TL.js +22 -0
  487. package/dist/schema-T4NE2EAO.js +22 -0
  488. package/dist/schema-TQYTESG3.js +22 -0
  489. package/dist/schema-W376PAJG.js +22 -0
  490. package/dist/schema-XYYDUUHS.js +26 -0
  491. package/dist/specValidation-NVBIZMEE.js +48 -0
  492. package/dist/theme.d.ts +1 -0
  493. package/dist/theme.js +24 -0
  494. package/dist/themeShapeRules-5C2463YH.js +11 -0
  495. package/dist/types/core/a11y/accessibility.d.ts +43 -0
  496. package/dist/types/core/a11y/recordsShared.d.ts +44 -0
  497. package/dist/types/core/a11y/structuralRecords.d.ts +6 -0
  498. package/dist/types/core/a11y/types.d.ts +116 -0
  499. package/dist/types/core/annotate.d.ts +300 -0
  500. package/dist/types/core/annotateArms.d.ts +37 -0
  501. package/dist/types/core/annotateFields.d.ts +30 -0
  502. package/dist/types/core/annotateGapBracket.d.ts +66 -0
  503. package/dist/types/core/annotateLinks.d.ts +47 -0
  504. package/dist/types/core/annotateTargets.d.ts +90 -0
  505. package/dist/types/core/axis.d.ts +179 -0
  506. package/dist/types/core/bandSelect.d.ts +10 -0
  507. package/dist/types/core/bands.d.ts +14 -0
  508. package/dist/types/core/calendarLabels.d.ts +101 -0
  509. package/dist/types/core/charts/band/stacks.d.ts +155 -0
  510. package/dist/types/core/charts/bar/fixtures.d.ts +9 -0
  511. package/dist/types/core/charts/bar/layout.d.ts +95 -0
  512. package/dist/types/core/charts/bartable/fixtures.d.ts +4 -0
  513. package/dist/types/core/charts/bartable/types.d.ts +192 -0
  514. package/dist/types/core/charts/box/fixtures.d.ts +12 -0
  515. package/dist/types/core/charts/box/types.d.ts +110 -0
  516. package/dist/types/core/charts/bullet/fixtures.d.ts +11 -0
  517. package/dist/types/core/charts/butterfly/fixtures.d.ts +9 -0
  518. package/dist/types/core/charts/choropleth/fixtures.d.ts +3 -0
  519. package/dist/types/core/charts/choropleth/overlayTypes.d.ts +68 -0
  520. package/dist/types/core/charts/choropleth/types.d.ts +117 -0
  521. package/dist/types/core/charts/cohort/fixtures.d.ts +12 -0
  522. package/dist/types/core/charts/cohort/types.d.ts +165 -0
  523. package/dist/types/core/charts/column/anomaly.d.ts +204 -0
  524. package/dist/types/core/charts/column/fixtures.d.ts +12 -0
  525. package/dist/types/core/charts/column/layout.d.ts +116 -0
  526. package/dist/types/core/charts/column/model.d.ts +295 -0
  527. package/dist/types/core/charts/column/types.d.ts +56 -0
  528. package/dist/types/core/charts/combo/endpoints.d.ts +165 -0
  529. package/dist/types/core/charts/combo/fixtures.d.ts +12 -0
  530. package/dist/types/core/charts/combo/layout.d.ts +48 -0
  531. package/dist/types/core/charts/creative/fixtures.d.ts +4 -0
  532. package/dist/types/core/charts/creative/types.d.ts +73 -0
  533. package/dist/types/core/charts/diagram/fixtures.d.ts +3 -0
  534. package/dist/types/core/charts/dimswitch/compile.d.ts +20 -0
  535. package/dist/types/core/charts/dimswitch/fixtures.d.ts +3 -0
  536. package/dist/types/core/charts/dimswitch/types.d.ts +152 -0
  537. package/dist/types/core/charts/dot/fixtures.d.ts +11 -0
  538. package/dist/types/core/charts/funnel/fixtures.d.ts +11 -0
  539. package/dist/types/core/charts/gantt/fixtures.d.ts +9 -0
  540. package/dist/types/core/charts/gantt/layout.d.ts +56 -0
  541. package/dist/types/core/charts/grid/fixtures.d.ts +3 -0
  542. package/dist/types/core/charts/grid/metricStack.d.ts +108 -0
  543. package/dist/types/core/charts/grid/metricStackSchema.d.ts +74 -0
  544. package/dist/types/core/charts/grid/normalize.d.ts +99 -0
  545. package/dist/types/core/charts/grid/schema.d.ts +168 -0
  546. package/dist/types/core/charts/heatmap/fixtures.d.ts +11 -0
  547. package/dist/types/core/charts/histogram/fixtures.d.ts +15 -0
  548. package/dist/types/core/charts/histogram/types.d.ts +98 -0
  549. package/dist/types/core/charts/kpi/fixtures.d.ts +9 -0
  550. package/dist/types/core/charts/likert/fixtures.d.ts +11 -0
  551. package/dist/types/core/charts/likert/layout.d.ts +111 -0
  552. package/dist/types/core/charts/line/fixtures.d.ts +16 -0
  553. package/dist/types/core/charts/line/types.d.ts +6 -0
  554. package/dist/types/core/charts/mekko/fixtures.d.ts +13 -0
  555. package/dist/types/core/charts/pareto/fixtures.d.ts +5 -0
  556. package/dist/types/core/charts/pareto/layout.d.ts +68 -0
  557. package/dist/types/core/charts/pie/fixtures.d.ts +14 -0
  558. package/dist/types/core/charts/pvm/fixtures.d.ts +13 -0
  559. package/dist/types/core/charts/pvm/types.d.ts +118 -0
  560. package/dist/types/core/charts/pyramid/fixtures.d.ts +4 -0
  561. package/dist/types/core/charts/pyramid/types.d.ts +92 -0
  562. package/dist/types/core/charts/sankey/fixtures.d.ts +4 -0
  563. package/dist/types/core/charts/sankey/types.d.ts +116 -0
  564. package/dist/types/core/charts/scatter/fixtures.d.ts +12 -0
  565. package/dist/types/core/charts/scatter/types.d.ts +58 -0
  566. package/dist/types/core/charts/slope/fixtures.d.ts +13 -0
  567. package/dist/types/core/charts/sparkline/fixtures.d.ts +9 -0
  568. package/dist/types/core/charts/status/fixtures.d.ts +8 -0
  569. package/dist/types/core/charts/status/layout.d.ts +71 -0
  570. package/dist/types/core/charts/table/fitFormats.d.ts +67 -0
  571. package/dist/types/core/charts/table/fixtures.d.ts +7 -0
  572. package/dist/types/core/charts/table/resolve.d.ts +72 -0
  573. package/dist/types/core/charts/table/view.d.ts +156 -0
  574. package/dist/types/core/charts/tilemap/fixtures.d.ts +3 -0
  575. package/dist/types/core/charts/tilemap/types.d.ts +94 -0
  576. package/dist/types/core/charts/treemap/fixtures.d.ts +4 -0
  577. package/dist/types/core/charts/treemap/types.d.ts +78 -0
  578. package/dist/types/core/charts/variance/fixtures.d.ts +12 -0
  579. package/dist/types/core/charts/waffle/fixtures.d.ts +5 -0
  580. package/dist/types/core/charts/waffle/types.d.ts +117 -0
  581. package/dist/types/core/charts/waterfall/fixtures.d.ts +9 -0
  582. package/dist/types/core/claims/browser.d.ts +49 -0
  583. package/dist/types/core/claims/manifest.d.ts +22 -0
  584. package/dist/types/core/dateFormat.d.ts +39 -0
  585. package/dist/types/core/deferred.d.ts +121 -0
  586. package/dist/types/core/diagnostics/describe.d.ts +149 -0
  587. package/dist/types/core/diagnostics/jsonPatch.d.ts +36 -0
  588. package/dist/types/core/doc/bareChart.d.ts +2 -0
  589. package/dist/types/core/doc/diagnostics.d.ts +124 -0
  590. package/dist/types/core/doc/docExpand.d.ts +39 -0
  591. package/dist/types/core/doc/document.d.ts +43 -0
  592. package/dist/types/core/doc/ownedDocumentCopy.d.ts +5 -0
  593. package/dist/types/core/doc/specError.d.ts +6 -0
  594. package/dist/types/core/emptyData.d.ts +27 -0
  595. package/dist/types/core/eventLane.d.ts +208 -0
  596. package/dist/types/core/fontMetrics/index.d.ts +47 -0
  597. package/dist/types/core/fontMetrics/injected.d.ts +40 -0
  598. package/dist/types/core/fontMetrics/tableDocument.d.ts +73 -0
  599. package/dist/types/core/fontMetrics/tables.generated.d.ts +17 -0
  600. package/dist/types/core/footer.d.ts +59 -0
  601. package/dist/types/core/format.d.ts +149 -0
  602. package/dist/types/core/formatPrecision.d.ts +136 -0
  603. package/dist/types/core/formatSpec.d.ts +302 -0
  604. package/dist/types/core/frame.d.ts +583 -0
  605. package/dist/types/core/geo/packs/all.d.ts +7 -0
  606. package/dist/types/core/geo/packs/dach.d.ts +16 -0
  607. package/dist/types/core/geo/packs/de-states.d.ts +16 -0
  608. package/dist/types/core/geo/packs/eu27.d.ts +16 -0
  609. package/dist/types/core/geo/packs/europe.d.ts +16 -0
  610. package/dist/types/core/geo/packs/index.d.ts +22 -0
  611. package/dist/types/core/geo/packs/registry.d.ts +37 -0
  612. package/dist/types/core/geo/packs/us-states.d.ts +16 -0
  613. package/dist/types/core/geo/packs/world.d.ts +16 -0
  614. package/dist/types/core/geo/tiles/eu27.generated.d.ts +412 -0
  615. package/dist/types/core/geo/tiles/europe.generated.d.ts +842 -0
  616. package/dist/types/core/geo/tiles/index.d.ts +8 -0
  617. package/dist/types/core/geo/tiles/types.d.ts +36 -0
  618. package/dist/types/core/geo/tiles/us-states.generated.d.ts +952 -0
  619. package/dist/types/core/geo/tiles/world.generated.d.ts +968 -0
  620. package/dist/types/core/geo/types.d.ts +146 -0
  621. package/dist/types/core/geometry.d.ts +102 -0
  622. package/dist/types/core/grid/sharedScale.d.ts +82 -0
  623. package/dist/types/core/icons.d.ts +227 -0
  624. package/dist/types/core/inputError.d.ts +14 -0
  625. package/dist/types/core/isoDate.d.ts +2 -0
  626. package/dist/types/core/isoTime.d.ts +7 -0
  627. package/dist/types/core/label/categoryRow.d.ts +332 -0
  628. package/dist/types/core/label/occupied.d.ts +41 -0
  629. package/dist/types/core/label/ownership.d.ts +83 -0
  630. package/dist/types/core/label/solver.d.ts +380 -0
  631. package/dist/types/core/label/tickRow.d.ts +78 -0
  632. package/dist/types/core/live/types.d.ts +50 -0
  633. package/dist/types/core/normalize/shared.d.ts +56 -0
  634. package/dist/types/core/notes.d.ts +174 -0
  635. package/dist/types/core/othersShade.d.ts +9 -0
  636. package/dist/types/core/periodYears.d.ts +9 -0
  637. package/dist/types/core/polyline.d.ts +11 -0
  638. package/dist/types/core/rangeRules.d.ts +19 -0
  639. package/dist/types/core/ratioTier.d.ts +120 -0
  640. package/dist/types/core/readerStrings.d.ts +13 -0
  641. package/dist/types/core/reading.d.ts +120 -0
  642. package/dist/types/core/registry.d.ts +178 -0
  643. package/dist/types/core/repaintGeometry.d.ts +19 -0
  644. package/dist/types/core/request.d.ts +124 -0
  645. package/dist/types/core/rows.d.ts +45 -0
  646. package/dist/types/core/scale.d.ts +106 -0
  647. package/dist/types/core/schema/capability.d.ts +229 -0
  648. package/dist/types/core/schema/namedColumns.d.ts +45 -0
  649. package/dist/types/core/schema/reference.d.ts +31 -0
  650. package/dist/types/core/schema/refusals.d.ts +45 -0
  651. package/dist/types/core/schema/unknownKeys.d.ts +45 -0
  652. package/dist/types/core/seriesIdentity.d.ts +120 -0
  653. package/dist/types/core/shareRounding.d.ts +49 -0
  654. package/dist/types/core/sizing.d.ts +330 -0
  655. package/dist/types/core/staticFooter.d.ts +6 -0
  656. package/dist/types/core/story.d.ts +41 -0
  657. package/dist/types/core/structureCounts.d.ts +10 -0
  658. package/dist/types/core/svg/renderSvg.d.ts +51 -0
  659. package/dist/types/core/target.d.ts +89 -0
  660. package/dist/types/core/text.d.ts +113 -0
  661. package/dist/types/core/theme.d.ts +478 -0
  662. package/dist/types/core/themeFields.d.ts +11 -0
  663. package/dist/types/core/themeRules.d.ts +111 -0
  664. package/dist/types/core/themeShape.d.ts +87 -0
  665. package/dist/types/core/themeValidate.d.ts +15 -0
  666. package/dist/types/core/timeAxis.d.ts +106 -0
  667. package/dist/types/core/types/annotations.d.ts +223 -0
  668. package/dist/types/core/types/cell.d.ts +82 -0
  669. package/dist/types/core/types/data.d.ts +309 -0
  670. package/dist/types/core/types/diagram.d.ts +234 -0
  671. package/dist/types/core/types/index.d.ts +8 -0
  672. package/dist/types/core/types/options.d.ts +1583 -0
  673. package/dist/types/core/types/scene.d.ts +990 -0
  674. package/dist/types/core/types/sizing.d.ts +51 -0
  675. package/dist/types/core/types/table.d.ts +873 -0
  676. package/dist/types/core/types/theme.d.ts +806 -0
  677. package/dist/types/core/zoom.d.ts +106 -0
  678. package/dist/types/fixtures/index.d.ts +40 -0
  679. package/dist/types/fixtures/registry.d.ts +15 -0
  680. package/dist/types/fonts.d.ts +10 -0
  681. package/dist/types/index.d.ts +70 -0
  682. package/dist/types/react/BoardplotTheme.d.ts +9 -0
  683. package/dist/types/react/DimSwitchChart.d.ts +36 -0
  684. package/dist/types/react/ScaleGroup.d.ts +31 -0
  685. package/dist/types/react/SceneRenderer.d.ts +23 -0
  686. package/dist/types/react/SizePlaceholder.d.ts +51 -0
  687. package/dist/types/react/StoryFrame.d.ts +42 -0
  688. package/dist/types/react/TableChart.d.ts +220 -0
  689. package/dist/types/react/a11ySurface.d.ts +20 -0
  690. package/dist/types/react/barrelCharts.d.ts +1023 -0
  691. package/dist/types/react/charts/bar.d.ts +28 -0
  692. package/dist/types/react/charts/bartable.d.ts +27 -0
  693. package/dist/types/react/charts/box.d.ts +27 -0
  694. package/dist/types/react/charts/bullet.d.ts +28 -0
  695. package/dist/types/react/charts/butterfly.d.ts +28 -0
  696. package/dist/types/react/charts/choropleth.d.ts +27 -0
  697. package/dist/types/react/charts/cohort.d.ts +52 -0
  698. package/dist/types/react/charts/column.d.ts +27 -0
  699. package/dist/types/react/charts/combo.d.ts +7 -0
  700. package/dist/types/react/charts/creative.d.ts +27 -0
  701. package/dist/types/react/charts/diagram.d.ts +162 -0
  702. package/dist/types/react/charts/dimswitch.d.ts +6 -0
  703. package/dist/types/react/charts/dot.d.ts +28 -0
  704. package/dist/types/react/charts/funnel.d.ts +28 -0
  705. package/dist/types/react/charts/gantt.d.ts +28 -0
  706. package/dist/types/react/charts/grid.d.ts +29 -0
  707. package/dist/types/react/charts/heatmap.d.ts +28 -0
  708. package/dist/types/react/charts/histogram.d.ts +27 -0
  709. package/dist/types/react/charts/kpi.d.ts +28 -0
  710. package/dist/types/react/charts/likert.d.ts +27 -0
  711. package/dist/types/react/charts/line.d.ts +28 -0
  712. package/dist/types/react/charts/mekko.d.ts +28 -0
  713. package/dist/types/react/charts/pareto.d.ts +28 -0
  714. package/dist/types/react/charts/pie.d.ts +28 -0
  715. package/dist/types/react/charts/pvm.d.ts +27 -0
  716. package/dist/types/react/charts/pyramid.d.ts +27 -0
  717. package/dist/types/react/charts/sankey.d.ts +27 -0
  718. package/dist/types/react/charts/scatter.d.ts +28 -0
  719. package/dist/types/react/charts/slope.d.ts +28 -0
  720. package/dist/types/react/charts/sparkline.d.ts +28 -0
  721. package/dist/types/react/charts/status.d.ts +27 -0
  722. package/dist/types/react/charts/table.d.ts +6 -0
  723. package/dist/types/react/charts/tilemap.d.ts +27 -0
  724. package/dist/types/react/charts/treemap.d.ts +27 -0
  725. package/dist/types/react/charts/variance.d.ts +28 -0
  726. package/dist/types/react/charts/waffle.d.ts +28 -0
  727. package/dist/types/react/charts/waterfall.d.ts +28 -0
  728. package/dist/types/react/createChartComponent.d.ts +135 -0
  729. package/dist/types/react/export/clipboard.d.ts +8 -0
  730. package/dist/types/react/export/csv.d.ts +2 -0
  731. package/dist/types/react/export/frame.d.ts +35 -0
  732. package/dist/types/react/export/index.d.ts +7 -0
  733. package/dist/types/react/export/png.d.ts +14 -0
  734. package/dist/types/react/export/svg.d.ts +5 -0
  735. package/dist/types/react/export/types.d.ts +69 -0
  736. package/dist/types/react/export/useExport.d.ts +17 -0
  737. package/dist/types/react/exportLink.d.ts +49 -0
  738. package/dist/types/react/footerFrame.d.ts +25 -0
  739. package/dist/types/react/hover/dataTable.d.ts +13 -0
  740. package/dist/types/react/hover/engine.d.ts +210 -0
  741. package/dist/types/react/hover/keyboard.d.ts +44 -0
  742. package/dist/types/react/hover/labelCard.d.ts +170 -0
  743. package/dist/types/react/hover/placement.d.ts +49 -0
  744. package/dist/types/react/index.d.ts +16 -0
  745. package/dist/types/react/parseChartSpec.d.ts +16 -0
  746. package/dist/types/react/prepare.d.ts +32 -0
  747. package/dist/types/react/prepared.d.ts +53 -0
  748. package/dist/types/react/preparedTable.d.ts +15 -0
  749. package/dist/types/react/rowsInput.d.ts +55 -0
  750. package/dist/types/react/rowsModule.d.ts +18 -0
  751. package/dist/types/react/rowsStore.d.ts +50 -0
  752. package/dist/types/react/scale-group.d.ts +2 -0
  753. package/dist/types/react/scaleGroupContext.d.ts +22 -0
  754. package/dist/types/react/scenePaint.d.ts +10 -0
  755. package/dist/types/react/scrollState.d.ts +26 -0
  756. package/dist/types/react/spec.d.ts +65 -0
  757. package/dist/types/react/specValidation.d.ts +45 -0
  758. package/dist/types/react/story.d.ts +15 -0
  759. package/dist/types/react/theme.d.ts +9 -0
  760. package/dist/types/react/themeContext.d.ts +44 -0
  761. package/dist/types/react/useChartLayout.d.ts +22 -0
  762. package/dist/types/react/useContainerSize.d.ts +57 -0
  763. package/dist/types/react/useHover.d.ts +100 -0
  764. package/dist/types/react/useZoom.d.ts +50 -0
  765. package/dist/types/rows.d.ts +58 -0
  766. package/dist/types/tableLooks.d.ts +6 -0
  767. package/dist/types/theme.d.ts +3 -0
  768. package/dist/types/validate.d.ts +3 -0
  769. package/dist/validate.d.ts +1 -0
  770. package/dist/validate.js +222 -0
  771. package/docs/FONTS.md +68 -0
  772. package/docs/TELEMETRY.md +94 -0
  773. package/docs/manual.md +838 -0
  774. package/docs/reference/bar.md +222 -0
  775. package/docs/reference/bartable.md +143 -0
  776. package/docs/reference/box.md +93 -0
  777. package/docs/reference/bullet.md +118 -0
  778. package/docs/reference/butterfly.md +117 -0
  779. package/docs/reference/choropleth.md +148 -0
  780. package/docs/reference/cohort.md +149 -0
  781. package/docs/reference/column.md +275 -0
  782. package/docs/reference/combo.md +219 -0
  783. package/docs/reference/creative.md +147 -0
  784. package/docs/reference/diagram.md +191 -0
  785. package/docs/reference/dimswitch.md +1395 -0
  786. package/docs/reference/dot.md +117 -0
  787. package/docs/reference/fixtures.md +1088 -0
  788. package/docs/reference/funnel.md +121 -0
  789. package/docs/reference/gantt.md +132 -0
  790. package/docs/reference/grid.md +302 -0
  791. package/docs/reference/heatmap.md +127 -0
  792. package/docs/reference/histogram.md +77 -0
  793. package/docs/reference/kpi.md +115 -0
  794. package/docs/reference/likert.md +113 -0
  795. package/docs/reference/line.md +436 -0
  796. package/docs/reference/mekko.md +114 -0
  797. package/docs/reference/options.md +313 -0
  798. package/docs/reference/pareto.md +102 -0
  799. package/docs/reference/pie.md +114 -0
  800. package/docs/reference/pvm.md +114 -0
  801. package/docs/reference/pyramid.md +99 -0
  802. package/docs/reference/react.md +703 -0
  803. package/docs/reference/reading.md +28 -0
  804. package/docs/reference/sankey.md +110 -0
  805. package/docs/reference/scatter.md +211 -0
  806. package/docs/reference/slope.md +126 -0
  807. package/docs/reference/sparkline.md +74 -0
  808. package/docs/reference/status.md +107 -0
  809. package/docs/reference/table.md +673 -0
  810. package/docs/reference/theme.md +361 -0
  811. package/docs/reference/tilemap.md +121 -0
  812. package/docs/reference/treemap.md +86 -0
  813. package/docs/reference/variance.md +126 -0
  814. package/docs/reference/waffle.md +106 -0
  815. package/docs/reference/waterfall.md +164 -0
  816. package/llms.txt +57 -0
  817. package/package.json +437 -4
@@ -0,0 +1,3066 @@
1
+ import {
2
+ clipTrendToDomain,
3
+ olsFit,
4
+ olsMoments
5
+ } from "./chunk-7X65ZQN4.js";
6
+ import {
7
+ preparePolyline
8
+ } from "./chunk-ELYU6TRQ.js";
9
+ import {
10
+ DEFAULT_OTHERS_SHADE
11
+ } from "./chunk-RQ5DNYLG.js";
12
+ import {
13
+ restValueHiding
14
+ } from "./chunk-EKQK5D6G.js";
15
+ import {
16
+ warnSliverLabels
17
+ } from "./chunk-HJXXFPOL.js";
18
+ import {
19
+ gapMarkerNode
20
+ } from "./chunk-7QDAHY5M.js";
21
+ import {
22
+ chartString as chartString2,
23
+ localeStrings,
24
+ planNearZeroTails
25
+ } from "./chunk-3W23F7EY.js";
26
+ import {
27
+ withUnit
28
+ } from "./chunk-JETXFF3M.js";
29
+ import {
30
+ categoryBandFromCenters
31
+ } from "./chunk-CDZHNLO6.js";
32
+ import {
33
+ trendTimeUnit
34
+ } from "./chunk-LC3PSQJJ.js";
35
+ import {
36
+ categoryLineAlign,
37
+ dayUnit,
38
+ layoutValueAxis,
39
+ noteName,
40
+ rotatedClaimRect,
41
+ spread1D,
42
+ spread1DResult,
43
+ straightBreakGlyph,
44
+ sweepHide,
45
+ valueAxisTitleRequest,
46
+ warnSpreadOverflow,
47
+ yearRowRequests
48
+ } from "./chunk-GQPESFAF.js";
49
+ import {
50
+ AREA_FILL_PART,
51
+ LAST_RESORT_PENALTY,
52
+ PRIORITY,
53
+ SWATCH_RESERVE,
54
+ adjacentSeriesWarnings,
55
+ composedTextRole,
56
+ createOccupiedIndex,
57
+ defaultAnnotationId,
58
+ fitText,
59
+ inflate,
60
+ othersShadeUnavailableWarnings,
61
+ partialKeyForced,
62
+ polylineYAt,
63
+ resolvePaintWarnings,
64
+ retainAdjacentWarningRule,
65
+ round2,
66
+ saysToDate,
67
+ segmentHitsRect,
68
+ sideAwayFrom,
69
+ toDateFits,
70
+ toDateLabel,
71
+ unitPrinted
72
+ } from "./chunk-2JAWQ7VV.js";
73
+ import {
74
+ disclosureNote
75
+ } from "./chunk-YTSSXSZR.js";
76
+ import {
77
+ defaultFormatSpec,
78
+ formatWithSpec,
79
+ parseISODate,
80
+ seriesRasterFormatter,
81
+ trendRateFormatter
82
+ } from "./chunk-ASAON7G4.js";
83
+ import {
84
+ NOT_AVAILABLE,
85
+ NOT_MEANINGFUL,
86
+ chartString,
87
+ distinctDecimalLift,
88
+ formatAutomaticNumber,
89
+ formatAutomaticPercent,
90
+ formatExactNumber,
91
+ notApplicableGlyph,
92
+ numberRange,
93
+ shareDecimals,
94
+ stringFields
95
+ } from "./chunk-YQ2B3YVF.js";
96
+ import {
97
+ HATCH_STRENGTH_DEFAULT,
98
+ LABEL_PLATE_RADIUS,
99
+ bumpStoryPaints,
100
+ dashToken,
101
+ effectiveFill,
102
+ emphasisWeight,
103
+ fanPaintSteps,
104
+ hatchGapFactor,
105
+ isOthersFill,
106
+ labelPlate,
107
+ labelsOffKeepsNames,
108
+ linePath,
109
+ markRolePaint,
110
+ markRoleToken,
111
+ mixedPaint,
112
+ orderedRampPaint,
113
+ othersSeparation,
114
+ paintColor,
115
+ rampSlots,
116
+ readerFloorPx,
117
+ secondaryFont,
118
+ separatedWashPaint,
119
+ seriesPaint,
120
+ strokeToken,
121
+ textScaleOf
122
+ } from "./chunk-II7652VA.js";
123
+ import {
124
+ PALETTE_NORMAL_FLOOR,
125
+ palettePerceptualDistance
126
+ } from "./chunk-2MTWKMEG.js";
127
+ import {
128
+ cubicPoint,
129
+ curvePathFromSegments,
130
+ drawnStroke,
131
+ fmtPathNumber,
132
+ monotonePath,
133
+ monotoneSegments,
134
+ monotoneYAt,
135
+ splitCurve,
136
+ splitCurveSegmentsAtX
137
+ } from "./chunk-WLZ54FWG.js";
138
+ import {
139
+ DEFAULT_TARGET,
140
+ NormalizeError,
141
+ resolveSubtitle
142
+ } from "./chunk-SGD3ZHID.js";
143
+ import {
144
+ maxOf,
145
+ minOf,
146
+ pushAll
147
+ } from "./chunk-WYJEOMNY.js";
148
+
149
+ // src/core/charts/line/trend.ts
150
+ var DAY = 864e5;
151
+ function datesOf(cats) {
152
+ let dates = cats.map((c) => c.date ? parseISODate(c.date) : void 0);
153
+ if (!(dates.length < 2 || dates.some((d, i) => !d || i > 0 && d.getTime() <= dates[i - 1].getTime())))
154
+ return dates;
155
+ }
156
+ function trendUnit(cats) {
157
+ let dates = datesOf(cats);
158
+ if (!dates) return "period";
159
+ let months = dates.map((d) => d.getUTCFullYear() * 12 + d.getUTCMonth()), steps = months.slice(1).map((m, i) => m - months[i]), calendar = dates.every((d) => d.getUTCDate() === dates[0].getUTCDate()) || dayUnit(dates) !== "day";
160
+ return calendar && steps.every((step) => step > 0 && step % 12 === 0) ? "year" : calendar && steps.every((step) => step > 0 && step % 3 === 0) ? "quarter" : calendar && steps.every((step) => step > 0) ? "month" : dates.slice(1).every((d, i) => d.getTime() - dates[i].getTime() === 7 * DAY) ? "week" : "day";
161
+ }
162
+ function trendXs(cats, unit) {
163
+ let dates = cats.map((c) => parseISODate(c.date)), months = (d) => d.getUTCFullYear() * 12 + d.getUTCMonth(), per = { month: 1, quarter: 3, year: 12 };
164
+ return dates.map((d) => unit === "day" || unit === "week" ? (d.getTime() - dates[0].getTime()) / DAY / (unit === "week" ? 7 : 1) : (months(d) - months(dates[0])) / per[unit]);
165
+ }
166
+ function trendTimeline(cats, source = cats) {
167
+ let unit = trendUnit(source);
168
+ if (unit === "period") return;
169
+ let all = trendXs(source, unit), steps = all.slice(1).map((x, i) => x - all[i]), step = minOf(steps);
170
+ if (cats === source && steps.every((gap) => gap === step)) return;
171
+ let xs = trendXs(cats, unit);
172
+ return { positions: xs.map((x) => x / step), span: xs[xs.length - 1] / step + 1 };
173
+ }
174
+ function fitLineTrends(domain, warnings) {
175
+ if (!domain.options.trend) return [];
176
+ if (domain.isStacked || domain.bumpDerived)
177
+ throw new NormalizeError("trend-unsupported", "options.trend", "trend needs variant 'line' or 'area'; a stack or rank is not a series value");
178
+ let population = domain.population, lo = population ? population.indexes[0] : 0, hi = population ? population.indexes[population.indexes.length - 1] : domain.cats.length - 1, cats = population ? population.categories.slice(lo, hi + 1) : domain.cats, rows = population ? population.plotted : domain.pv, continuous = domain.x ? continuousTrend(domain.x, lo, hi) : void 0, unit = continuous?.unit ?? trendUnit(cats), xs = continuous?.xs ?? (unit === "period" ? cats.map((_, i) => population ? i : domain.timeline?.positions[i] ?? i) : trendXs(cats, unit));
179
+ return domain.drawnSeries.flatMap((s) => {
180
+ let row = rows[domain.rowOf.get(s)], points = xs.flatMap((x, i) => row[lo + i] === null ? [] : [{ x, y: row[lo + i] }]), moments = olsMoments(points), fit = moments.n >= 3 ? olsFit(moments) : null;
181
+ return fit ? [{ id: s.id, ...moments, ...fit, x0: points[0].x, x1: points[points.length - 1].x, unit }] : (warnings.push({
182
+ code: "trend-undefined",
183
+ severity: "warn",
184
+ field: ["options", "trend"],
185
+ owner: { seriesId: s.id },
186
+ message: `no trend line for series '${s.id}': a fit needs at least 3 non-null points at distinct x positions; it has ${moments.n}`
187
+ }), []);
188
+ });
189
+ }
190
+ function continuousTrend(x, lo, hi) {
191
+ let source = x.model.xs.slice(lo, hi + 1);
192
+ if (!x.model.clock) return { unit: "x", xs: source };
193
+ let { unit, ms } = trendTimeUnit(source[source.length - 1] - source[0]);
194
+ return { unit, xs: source.map((v) => (v - source[0]) / ms) };
195
+ }
196
+ function drawnXs(domain, unit) {
197
+ if (domain.x) {
198
+ let first = domain.x.model.xs[domain.population?.indexes[0] ?? 0], ms = domain.x.model.clock ? { second: 1e3, minute: 6e4, hour: 36e5, day: 864e5, week: 6048e5 }[unit] : 1;
199
+ return domain.x.shown.map((v) => domain.x.model.clock ? (v - first) / ms : v);
200
+ }
201
+ return unit === "period" ? domain.cats.map((_, ci) => domain.population?.positions[ci] ?? domain.timeline?.positions[ci] ?? ci) : trendXs(domain.cats, unit);
202
+ }
203
+ var TREND_UNIT_KEY = { day: "trendPerDay", week: "trendPerWeek", month: "trendPerMonth", quarter: "trendPerQuarter", year: "trendPerYear", period: "trendPerPeriod", second: "trendPerSecond", minute: "trendPerMinute", hour: "trendPerHour" };
204
+ function lineTrendLabel(domain, fit) {
205
+ let { options } = domain, label = typeof options.trend == "object" ? options.trend.label : void 0, series = domain.drawnSeries.find((s) => s.id === fit.id), example = domain.rebased ? void 0 : series.format ?? options.format, unit = domain.rebased ? void 0 : series.unit ?? options.unit, percent = !domain.rebased && series.vals.some((v) => v.isPct), slope = trendRateFormatter(example, options.locale?.language, percent ? "%" : unit, !0)(fit.slope), r2 = fit.r2 === null ? chartString2(options, "trendUndefined") : formatAutomaticNumber(fit.r2, { decimals: 2, locale: options.locale?.language });
206
+ return chartString2(options, "lineTrendKey", {
207
+ v1: label ?? chartString2(options, "linearTrend"),
208
+ v2: series.label,
209
+ v3: slope,
210
+ v4: fit.unit === "x" ? options.xAxis?.unit ? chartString2(options, "trendPerXUnit", { v1: options.xAxis.unit }) : chartString2(options, "trendPerUnitOfX") : chartString2(options, TREND_UNIT_KEY[fit.unit]),
211
+ v5: r2
212
+ });
213
+ }
214
+ function lineTrendKeys(theme, domain, paints) {
215
+ return domain.trends.map((fit) => {
216
+ let i = domain.drawnSeries.findIndex((s) => s.id === fit.id);
217
+ return {
218
+ id: `trend:${fit.id}`,
219
+ label: lineTrendLabel(domain, fit),
220
+ paint: paints.series(domain.drawnSeries[i], i),
221
+ key: "line",
222
+ width: strokeToken(theme, "rule"),
223
+ dash: dashToken(theme, "reference")
224
+ };
225
+ });
226
+ }
227
+ function drawLineTrends(theme, domain, area, paints, nodes, claims) {
228
+ for (let fit of domain.trends) {
229
+ let span = clipTrendToDomain(fit, [fit.x0, fit.x1], [domain.dLo, domain.dHi]);
230
+ if (!span) continue;
231
+ let xs = drawnXs(domain, fit.unit), n = xs.length - 1;
232
+ if (n < 1 || xs[n] === xs[0]) continue;
233
+ let x = (value) => area.xOf(0) + (value - xs[0]) / (xs[n] - xs[0]) * (area.xOf(n) - area.xOf(0)), x1 = x(span[0]), x2 = x(span[1]), y1 = area.y(fit.intercept + fit.slope * span[0]), y2 = area.y(fit.intercept + fit.slope * span[1]), i = domain.drawnSeries.findIndex((s) => s.id === fit.id), owner = { seriesId: fit.id };
234
+ nodes.push({
235
+ t: "line",
236
+ id: `trend:${fit.id}`,
237
+ x1,
238
+ y1,
239
+ x2,
240
+ y2,
241
+ owner,
242
+ part: "trendLine",
243
+ stroke: paints.series(domain.drawnSeries[i], i),
244
+ width: strokeToken(theme, "rule"),
245
+ dash: dashToken(theme, "reference")
246
+ });
247
+ for (let k = 0; k < 12; k++) {
248
+ let a = y1 + (y2 - y1) * k / 12, b = y1 + (y2 - y1) * (k + 1) / 12;
249
+ claims.claim(
250
+ { x: x1 + (x2 - x1) * k / 12, y: Math.min(a, b) - 1.5, w: Math.max((x2 - x1) / 12, 1), h: Math.abs(b - a) + 3 },
251
+ "annotation",
252
+ { annotationId: `trend:${fit.id}` },
253
+ "trendLine"
254
+ );
255
+ }
256
+ }
257
+ }
258
+
259
+ // src/core/label/areaGround.ts
260
+ function polylineYAt2(line, x) {
261
+ if (x <= line[0].x) return line[0].y;
262
+ for (let i = 1; i < line.length; i++) {
263
+ let a = line[i - 1], b = line[i];
264
+ if (x <= b.x) return b.x === a.x ? b.y : a.y + (b.y - a.y) * (x - a.x) / (b.x - a.x);
265
+ }
266
+ return line[line.length - 1].y;
267
+ }
268
+ function screenEdges(a, b) {
269
+ let lo = Math.max(a[0].x, b[0].x), hi = Math.min(a[a.length - 1].x, b[b.length - 1].x), points = [...a.map((p) => ({ x: p.x, ya: p.y, yb: polylineYAt2(b, p.x) })), ...b.map((p) => ({ x: p.x, ya: polylineYAt2(a, p.x), yb: p.y }))].filter((p) => p.x >= lo && p.x <= hi).sort((p, q) => p.x - q.x), top = [], bottom = [];
270
+ return points.forEach((q, i) => {
271
+ let p = points[i - 1], dp = p ? p.ya - p.yb : 0, dq = q.ya - q.yb;
272
+ if (p && dp * dq < 0) {
273
+ let t = dp / (dp - dq), cross = { x: p.x + t * (q.x - p.x), y: p.ya + t * (q.ya - p.ya) };
274
+ top.push(cross), bottom.push(cross);
275
+ }
276
+ top.push({ x: q.x, y: Math.min(q.ya, q.yb) }), bottom.push({ x: q.x, y: Math.max(q.ya, q.yb) });
277
+ }), { top, bottom };
278
+ }
279
+ var edgeYs = (edge, x0, x1) => [polylineYAt2(edge, x0), polylineYAt2(edge, x1), ...edge.filter((point) => point.x > x0 && point.x < x1).map((point) => point.y)], spanOf = (ground, x0, x1) => {
280
+ let a = Math.max(x0, ground.top[0].x, ground.bottom[0].x), b = Math.min(x1, ground.top[ground.top.length - 1].x, ground.bottom[ground.bottom.length - 1].x);
281
+ return a < b ? [a, b] : void 0;
282
+ };
283
+ function groundUnder(rect, pad, grounds) {
284
+ let x0 = rect.x, x1 = rect.x + rect.w, y0 = rect.y - pad, y1 = rect.y + rect.h + pad;
285
+ for (let i = grounds.length - 1; i >= 0; i--) {
286
+ let ground = grounds[i];
287
+ if (ground.top.length < 2 || ground.bottom.length < 2) continue;
288
+ let span = spanOf(ground, x0, x1);
289
+ if (span) {
290
+ if (span[0] <= x0 && x1 <= span[1] && edgeYs(ground.top, x0, x1).every((y) => y <= y0) && edgeYs(ground.bottom, x0, x1).every((y) => y >= y1)) return ground;
291
+ if (reachesInto(ground, span, y0, y1)) return;
292
+ }
293
+ }
294
+ }
295
+ var reachesInto = (ground, span, y0, y1) => Math.min(...edgeYs(ground.top, ...span)) < y1 && Math.max(...edgeYs(ground.bottom, ...span)) > y0;
296
+ function straddlesOwn(rect, grounds, own) {
297
+ return grounds.some((ground) => {
298
+ if (ground.seriesId !== own || ground.top.length < 2 || ground.bottom.length < 2) return !1;
299
+ let span = spanOf(ground, rect.x, rect.x + rect.w);
300
+ return span !== void 0 && reachesInto(ground, span, rect.y, rect.y + rect.h);
301
+ });
302
+ }
303
+ function seatValuesOnGround(requests, grounds, pad, cssOf, others = !0, kinds = ["point"]) {
304
+ if (grounds.length !== 0)
305
+ for (let request of requests) {
306
+ let own = request.owner.seriesId ?? "";
307
+ if (!kinds.includes(request.kind) || own === "" && request.kind === "point") continue;
308
+ let rank = /* @__PURE__ */ new Map();
309
+ if (request.candidates = request.candidates.map((candidate) => {
310
+ if (candidate.leaderFrom || candidate.insideFill !== void 0 || candidate.needsBacking) return candidate;
311
+ let under = groundUnder(candidate.rect, pad, grounds), ownUnder = groundUnder(candidate.rect, 0, grounds), ground = under && (others || under.seriesId === own) ? under : ownUnder?.seriesId === own ? ownUnder : void 0;
312
+ if (ground) {
313
+ let seated = { ...candidate, onFill: { seriesId: ground.seriesId, fill: cssOf(ground), paint: ground.paint, ...ground.pattern ? { pattern: ground.pattern } : {} } };
314
+ return ground.seriesId === own && rank.set(seated, 1), seated;
315
+ }
316
+ return straddlesOwn(candidate.rect, grounds, own) && rank.set(candidate, 2), candidate;
317
+ }), rank.size === 0) continue;
318
+ let tier = (candidate) => (candidate.leaderFrom || candidate.penalty >= LAST_RESORT_PENALTY ? 3 : 0) + (rank.get(candidate) ?? 0);
319
+ request.candidates = request.candidates.map((candidate, index) => ({ candidate, index })).sort((a, b) => tier(a.candidate) - tier(b.candidate) || a.index - b.index).map(({ candidate }) => candidate);
320
+ }
321
+ }
322
+
323
+ // src/core/charts/line/labels.ts
324
+ var BUMP_NAME_MAX_FRACTION = 0.18, BUMP_NAME_MAX_LINES = 2, ENDPOINT_LEADER_CLEARANCE = 4, ENDPOINT_LEADER_MIN_DY = 3, END_LABEL_MAX_DISPLACEMENT_LINES = 3, SLIVER_MIN_H = 10, END_NAME_GAP = 16, NAME_PRIORITY = PRIORITY.endpoint + 1, END_LABEL_KEY = /* @__PURE__ */ Symbol("lineEndLabelKey"), END_LABEL_WIDE = /* @__PURE__ */ Symbol("lineEndLabelWide"), INLINE_FALLBACK = /* @__PURE__ */ Symbol("lineInlineFallback"), usesInlineFallback = (options) => options[INLINE_FALLBACK] === !0, usesEndLabelKey = (options) => options[END_LABEL_KEY] !== void 0, fanEdgeInKey = (domain) => domain.fan !== null && domain.x?.range?.cut.hi === !0 && usesEndLabelKey(domain.options), usesWideEndLabels = (options) => options[END_LABEL_WIDE] === !0;
325
+ function lineFocusFont(env, domain, font, weight) {
326
+ return !env.isBump && env.anyHighlight && domain.variant === "line" && !domain.isArea && domain.options.highlightMode !== "fade" ? { ...font, weight } : void 0;
327
+ }
328
+ function areaLeaderGap(labelHeight) {
329
+ return Math.max(12, ENDPOINT_LEADER_CLEARANCE + Math.ceil(labelHeight) + 1);
330
+ }
331
+ var ENDPOINT_LABEL_GUTTER_MAX_FRACTION = 0.18, STACKED_AREA_GUTTER_MAX_FRACTION = 0.21, ENDPOINT_LABEL_MAX_LINES = 2;
332
+ function wrapEndpointLabel(text, font, maxWidth, measure) {
333
+ let words = text.trim().split(/\s+/).filter(Boolean);
334
+ if (words.length === 0) return { lines: [], w: 0 };
335
+ let lines = [], current = "";
336
+ for (let word of words) {
337
+ let next = current ? `${current} ${word}` : word;
338
+ if (current && measure(next, font).width > maxWidth) {
339
+ if (lines.push(current), current = word, lines.length >= ENDPOINT_LABEL_MAX_LINES) return null;
340
+ } else current = next;
341
+ }
342
+ return current && lines.push(current), lines.length > ENDPOINT_LABEL_MAX_LINES ? null : { lines, w: Math.max(...lines.map((line) => measure(line, font).width)) };
343
+ }
344
+ function endUnitSuffix(options, unitless) {
345
+ return !unitless && options.unit && !unitPrinted({ subtitle: resolveSubtitle(options.subtitle), unit: options.unit, unitShown: options.unitShown }) ? options.unit : "";
346
+ }
347
+ function valueUnit(options, isBump, rebased) {
348
+ return isBump ? { endUnitSuffix: options.unit ?? "", unitOnEvery: !0 } : { endUnitSuffix: endUnitSuffix(options, rebased), unitOnEvery: !1 };
349
+ }
350
+ function authoredCellText(override, value) {
351
+ let number = value.composeText(
352
+ value.variant === "stacked100-area" ? ["percent"] : ["absolute"],
353
+ value.abs,
354
+ value.pct,
355
+ "",
356
+ "",
357
+ value.unitSuffix,
358
+ value.isPct,
359
+ value.source,
360
+ value.categoryId
361
+ );
362
+ return override.replace(/\$\{value\}/g, number);
363
+ }
364
+ function buildEndpointSeeds(input) {
365
+ let { endUnitSuffix: endUnitSuffix2, drawnSeries, cats, lastIdxOf, pv, rowOf, rebased, variant, absOf, composeText, printsZero, labelOnly } = input, valueParts = input.valueContent.filter((part) => part === "absolute" || part === "percent"), seeds = [];
366
+ return drawnSeries.forEach((series, dataIdx) => {
367
+ if (labelOnly !== void 0 && !labelOnly.has(series.id)) return;
368
+ let ci = lastIdxOf.get(series.id);
369
+ if (ci === void 0) return;
370
+ let plotted = pv[rowOf.get(series)][ci], abs = rebased ? plotted : absOf(series, ci), pct = variant === "stacked100-area" && !input.sharesWithheld.has(cats[ci].id) ? plotted : null, source = rebased ? void 0 : series.vals[ci]?.format ? { ...series, format: series.vals[ci].format } : series, compose = (content, seriesLabel) => composeText(content, abs, pct, cats[ci].label ?? cats[ci].id, seriesLabel, endUnitSuffix2, series.vals[ci].isPct, source, cats[ci].id);
371
+ seeds.push({
372
+ id: `series:${series.id}`,
373
+ kind: "series",
374
+ compose,
375
+ s: series,
376
+ dataIdx,
377
+ ci,
378
+ fullText: series.label,
379
+ ...series.shortLabel ? { shortText: series.shortLabel } : {},
380
+ valueText: typeof series.vals[ci].labelOverride == "string" ? authoredCellText(series.vals[ci].labelOverride, { composeText, variant, abs, pct, isPct: series.vals[ci].isPct, unitSuffix: endUnitSuffix2, source, categoryId: cats[ci].id }) : series.vals[ci].labelOverride === !1 ? "" : compose(valueParts, ""),
381
+ zeroText: composeText(valueParts, 0, 0, "", "", endUnitSuffix2, !1, source),
382
+ // Every printed part is zero at its precision: the absolute value by
383
+ // its raw number, a share by its printed text.
384
+ printsZero: valueParts.length > 0 && valueParts.every((part) => part === "absolute" ? abs !== null && printsZero(abs, series.vals[ci].isPct, source) : pct !== null && (pct === 0 || composeText(["percent"], abs, pct, "", "", "", series.vals[ci].isPct, source, cats[ci].id) === composeText(["percent"], 0, 0, "", "", "", !1, source))),
385
+ exactZero: abs === 0
386
+ });
387
+ }), seeds;
388
+ }
389
+ function toEndLabel(seed, text, lines, width, labelH) {
390
+ return { id: seed.id, kind: seed.kind, ...seed.shared ? { shared: !0 } : {}, s: seed.s, dataIdx: seed.dataIdx, ci: seed.ci, text, w: width, lines, h: Math.max(1, lines.length) * labelH, ...seed.valueText ? { valueText: seed.valueText } : {} };
391
+ }
392
+ function oneLineLabels(seeds, textOf, labelFont, labelH, measure) {
393
+ return seeds.flatMap((seed) => {
394
+ let text = textOf(seed);
395
+ return text ? [toEndLabel(seed, text, [text], measure(text, labelFont).width, labelH)] : [];
396
+ });
397
+ }
398
+ function wrappedLabels(seeds, textOf, labelFont, labelH, maxWidth, measure) {
399
+ let labels = [];
400
+ for (let seed of seeds) {
401
+ let text = textOf(seed);
402
+ if (!text) continue;
403
+ let block = wrapEndpointLabel(text, labelFont, maxWidth, measure);
404
+ if (!block) return null;
405
+ labels.push(toEndLabel(seed, text, block.lines, block.w, labelH));
406
+ }
407
+ return labels.some((label) => label.lines.length > 1) ? labels : null;
408
+ }
409
+ function prepareEndpointLabels(input) {
410
+ let { options, isBump, isArea, size, labelFont, labelH, measure } = input, endContent = input.names === "end" ? ["series"] : null, built = endContent ? buildEndpointSeeds({ ...input, endUnitSuffix: endUnitSuffix(options, isBump || input.rebased) }) : [], nearZero = planNearZeroTails({
411
+ strings: options.strings,
412
+ seeds: built,
413
+ endContent,
414
+ pinned: (id) => options.labelPlacements?.[id] !== void 0
415
+ }), seeds = nearZero.seeds, nameFloor = readerFloorPx(options.target ?? DEFAULT_TARGET, "label", textScaleOf(options)), fitName = (text, cap, nameFont = labelFont) => {
416
+ let wrapped = fitText(text, nameFont, cap, BUMP_NAME_MAX_LINES, measure, { target: options.target, textScale: textScaleOf(options), typeRole: "label", ...nameFloor < nameFont.size ? { shrink: { ...nameFont, size: nameFloor } } : {} }), lines = wrapped.lines.length > 0 ? wrapped.lines : [text], font = wrapped.lines.length > 0 && wrapped.font.size < nameFont.size ? wrapped.font : void 0, widest = Math.max(...lines.map((line) => measure(line, font ?? nameFont).width));
417
+ return { lines, w: Math.min(widest, cap), h: lines.length * (font ? labelH * font.size / labelFont.size : labelH), ...wrapped.title !== void 0 ? { title: wrapped.title } : {}, ...font ? { font } : {} };
418
+ }, nameBlock = (text, seriesId) => {
419
+ if (!isBump) return { lines: [text], w: measure(text, labelFont).width, h: labelH };
420
+ let nameFont = seriesId !== void 0 && input.bumpStory?.ids.has(seriesId) ? input.bumpStory.font : labelFont, cap = Math.max(size.width * BUMP_NAME_MAX_FRACTION, (input.bumpNameRoom ?? 0) / 2), block = fitName(text, cap, nameFont);
421
+ if (!input.bumpOneColumn || block.title === void 0) return block;
422
+ let wide = fitName(text, Math.max(size.width * BUMP_NAME_MAX_FRACTION * 2, input.bumpNameRoom ?? 0), nameFont);
423
+ return wide.title === void 0 ? wide : block;
424
+ }, endpointSwatches = !isBump && !isArea && (input.heroMode || input.anyHighlight && !(input.variant === "line" && options.highlightMode !== "fade")), endSwatchReserve = isArea || endpointSwatches ? SWATCH_RESERVE : 0, effectiveWidth = typeof options.embed?.width == "number" && options.embed.width > 0 ? options.embed.width : size.width, effectiveScale = effectiveWidth / size.width, effectiveBudget = effectiveWidth * (input.variant === "stacked-area" ? STACKED_AREA_GUTTER_MAX_FRACTION : ENDPOINT_LABEL_GUTTER_MAX_FRACTION), svgBudget = effectiveBudget / effectiveScale, endpointPadding = isArea ? areaLeaderGap(labelH * ENDPOINT_LABEL_MAX_LINES) + 8 : 14, textBudget = Math.max(0, svgBudget - endSwatchReserve - endpointPadding), full = oneLineLabels(seeds, (seed) => seed.fullText, labelFont, labelH, measure), fullWrapped = wrappedLabels(seeds, (seed) => seed.fullText, labelFont, labelH, textBudget, measure), hasShort = seeds.some((seed) => seed.shortText !== void 0), short = hasShort ? oneLineLabels(seeds, (seed) => seed.shortText ?? seed.fullText, labelFont, labelH, measure) : null, shortWrapped = hasShort ? wrappedLabels(seeds, (seed) => seed.shortText ?? seed.fullText, labelFont, labelH, textBudget, measure) : null, legendPosition = typeof options.legend == "object" ? options.legend.position : options.legend, gridLegend = options.gridEndpointIdentity === "legend", legend = !isBump && endContent !== null && legendPosition !== "none" && legendPosition !== "right" && !seeds.some((seed) => options.labelPlacements?.[seed.id] !== void 0) || gridLegend ? [] : null, candidates = [
425
+ { strategy: "full", labels: full },
426
+ ...fullWrapped ? [{ strategy: "wrapped", labels: fullWrapped }] : [],
427
+ ...legendPosition !== "none" && short ? [{ strategy: "short", labels: short }] : [],
428
+ ...legendPosition !== "none" && shortWrapped ? [{ strategy: "short", labels: shortWrapped }] : [],
429
+ ...legend ? [{ strategy: "legend", labels: legend }] : []
430
+ ], gutter = (labels) => labels.length > 0 ? maxOf(labels.map((label) => label.w)) + endSwatchReserve + (isArea ? areaLeaderGap(maxOf(labels.map((label) => label.h))) + 8 : endpointPadding) : 0, chosen = usesEndLabelKey(options) ? { strategy: "legend", labels: [] } : gridLegend && legend ? { strategy: "legend", labels: legend } : candidates.find((candidate) => gutter(candidate.labels) <= svgBudget + 1e-9) ?? candidates.reduce((best, candidate) => gutter(candidate.labels) < gutter(best.labels) ? candidate : best), endLabels = isBump ? full.map((label) => ({ ...label, ...foldBumpValue(label.text, input.bumpFolded?.get(`point:${label.s.id}:${input.cats[label.ci].id}`), (text) => nameBlock(text, label.s.id)) })) : chosen.labels, nameGutter = gutter(endLabels), columnGap = isBump ? 6 : Math.max(isArea ? areaLeaderGap(Math.max(0, maxOf(endLabels.map((label) => label.h)))) : END_NAME_GAP, input.endRoom), endReserve = isBump || endLabels.length === 0 ? nameGutter : maxOf(endLabels.map((label) => usesWideEndLabels(options) && input.mergeEndValues && label.valueText && !label.shared ? Math.max(label.w, measure(`${label.text} `, labelFont).width + measure(label.valueText, labelFont).width) : label.w)) + endSwatchReserve + columnGap + 8, economy = !isBump && seeds.length > 0 ? { strategy: chosen.strategy, maxGutterFraction: ENDPOINT_LABEL_GUTTER_MAX_FRACTION, requiredGutter: nameGutter, appliedGutter: nameGutter, effectiveRequiredGutter: nameGutter * effectiveScale, effectiveBudget, overflow: nameGutter > svgBudget + 1e-9 } : void 0;
431
+ return { inlineNamesEnabled: input.names === "inline", endContent, nameBlock, endLabels, endSwatchReserve, endpointSwatches, endReserve, columnGap, ...economy ? { endpointLabelEconomy: economy } : {}, ...nearZero.tail ? { nearZeroTail: nearZero.tail } : {}, endpointLegendFallback: economy?.strategy === "legend" || economy?.strategy === "short" || nearZero.tail?.mode === "dropped" && legendPosition === void 0 };
432
+ }
433
+ function foldBumpValue(name, value, nameBlock) {
434
+ let folded = value === void 0 ? void 0 : `${name} \xB7 ${value}`, block = folded === void 0 ? void 0 : nameBlock(folded);
435
+ return block && block.lines.join(" ").includes(`\xB7 ${value}`) ? { text: folded, ...block } : { text: name, ...nameBlock(name) };
436
+ }
437
+ var BESIDE_PENALTY = 5;
438
+ function containedRect(plot, centerX, y, width, height) {
439
+ return width > plot.w || height > plot.h || y < plot.y || y + height > plot.y + plot.h ? null : { x: Math.max(plot.x + width / 2, Math.min(centerX, plot.x + plot.w - width / 2)) - width / 2, y, w: width, h: height };
440
+ }
441
+ function inlineAnchors(series, mark, interpolation, categoryOrder) {
442
+ let vertices = mark.points.map((point) => ({ ...point, order: categoryOrder.get(point.categoryId) ?? -1, tier: 2 })), stroke = drawnStroke(vertices, interpolation), along = (share, tier, suffix) => vertices.flatMap((point, index) => {
443
+ let next = vertices[index + 1];
444
+ if (!next || !series.interpolateGaps && next.order !== point.order + 1) return [];
445
+ let x = point.x + (next.x - point.x) * share;
446
+ return [{ categoryId: `${point.categoryId}->${next.categoryId}${suffix}`, x, y: polylineYAt(stroke, x), order: point.order, tier }];
447
+ });
448
+ return [...along(0.5, 0, ""), ...along(0.25, 1, ":q1"), ...along(0.75, 1, ":q3"), ...vertices];
449
+ }
450
+ function placeInlineSeriesLabels(input) {
451
+ if (!input.enabled) return;
452
+ let plotCenter = input.plot.x + input.plot.w / 2;
453
+ input.drawnSeries.forEach((series) => {
454
+ let mark = input.marks.series.find((entry) => entry.seriesId === series.id);
455
+ if (!mark || mark.points.length === 0) return;
456
+ let ordered = [...inlineAnchors(series, mark, input.interpolationFor(series), input.categoryOrder)].sort((a, b) => a.tier - b.tier || Math.abs(a.x - plotCenter) - Math.abs(b.x - plotCenter) || a.order - b.order), text = series.label, nameFont = input.focusFont && input.highlights.has(series.id) ? input.focusFont : input.labelFont, width = input.measure(text, nameFont).width, onLine = [], beside = [], clear = (rect) => !input.marks.series.some((entry) => entry.points.some((point, i) => {
457
+ let next = entry.points[i + 1];
458
+ return next !== void 0 && segmentHitsRect(point, next, rect, 1);
459
+ }));
460
+ input.beside || ordered.forEach((point, index) => {
461
+ let rect = containedRect(input.plot, point.x, point.y - input.labelH / 2, width, input.labelH);
462
+ rect && !input.dividerXs.some((x) => x > rect.x - 3.5 && x < rect.x + rect.w + 3.5) && onLine.push({ slot: `inline:${point.categoryId}`, rect, penalty: input.beside ? 2 * ordered.length + index : index, needsBacking: !0 });
463
+ });
464
+ let others = input.marks.series.filter((entry) => entry.seriesId !== series.id && entry.points.length > 0), yAt = (points, x) => {
465
+ for (let i = 1; i < points.length; i++) {
466
+ let a = points[i - 1], b = points[i];
467
+ if (x >= Math.min(a.x, b.x) && x <= Math.max(a.x, b.x)) return b.x === a.x ? a.y : a.y + (b.y - a.y) * (x - a.x) / (b.x - a.x);
468
+ }
469
+ }, roomOf = (rect, above, lineY) => {
470
+ let xs = [rect.x, rect.x + rect.w / 2, rect.x + rect.w], ys = others.flatMap((entry) => xs.flatMap((x) => yAt(entry.points, x) ?? []));
471
+ if (xs.flatMap((x) => yAt(mark.points, x) ?? []).some((y) => above ? y < rect.y + rect.h + 2 : y > rect.y - 2)) return -1;
472
+ let edge = above ? rect.y - input.plot.y : input.plot.y + input.plot.h - rect.y - rect.h;
473
+ return Math.min(edge, minOf(ys.filter((y) => above ? y < lineY : y > lineY).map((y) => above ? rect.y - y : y - rect.y - rect.h)));
474
+ }, roomy = [];
475
+ ordered.forEach((point, index) => {
476
+ for (let [side, y] of [["over", point.y - input.labelH - 3], ["under", point.y + 3]]) {
477
+ let rect = containedRect(input.plot, point.x, y, width, input.labelH);
478
+ if (rect && !input.dividerXs.some((x) => x > rect.x - 3.5 && x < rect.x + rect.w + 3.5) && (!input.beside || clear(rect))) {
479
+ let cand = { slot: `inline:${side}:${point.categoryId}`, rect, penalty: input.beside ? index : ordered.length + index };
480
+ input.beside ? roomy.push({ cand, room: roomOf(rect, side === "over", point.y), index: roomy.length }) : beside.push(cand);
481
+ }
482
+ }
483
+ }), pushAll(beside, roomy.sort((a, b) => b.room - a.room || a.index - b.index).map(({ cand }, i) => ({ ...cand, penalty: i })));
484
+ let overSeats = beside.length;
485
+ if (input.beside && ordered.forEach((point) => {
486
+ for (let [side, x, y] of [["left", point.x - 4 - width, point.y - input.labelH], ["right", point.x + 4, point.y], ["left", point.x - 4 - width, point.y], ["right", point.x + 4, point.y - input.labelH], ["left", point.x - 6 - width, point.y - input.labelH / 2], ["right", point.x + 6, point.y - input.labelH / 2]]) {
487
+ let rect = { x, y, w: width, h: input.labelH };
488
+ rect.x < input.plot.x || rect.x + rect.w > input.plot.x + input.plot.w || rect.y < input.plot.y || rect.y + rect.h > input.plot.y + input.plot.h || input.dividerXs.some((d) => d > rect.x - 3.5 && d < rect.x + rect.w + 3.5) || !clear(rect) || beside.some((cand) => cand.rect.x === rect.x && cand.rect.y === rect.y) || beside.push({ slot: `inline:${side}:${point.categoryId}:${beside.length}`, rect, penalty: beside.length });
489
+ }
490
+ }), input.beside) {
491
+ let airOf = (rect) => Math.min(1 / 0, minOf(others.flatMap((entry) => [rect.x, rect.x + rect.w / 2, rect.x + rect.w].flatMap((x) => {
492
+ let y = yAt(entry.points, x);
493
+ return y === void 0 ? [] : [y < rect.y ? rect.y - y : y > rect.y + rect.h ? y - rect.y - rect.h : 0];
494
+ })))), side = beside.splice(overSeats), airy = side.filter((cand) => airOf(cand.rect) >= input.labelH);
495
+ pushAll(beside, [...airy, ...side.filter((cand) => !airy.includes(cand))].map((cand, i) => ({ ...cand, penalty: overSeats + i })));
496
+ }
497
+ let candidates = input.beside ? [...beside, ...onLine] : [...onLine, ...beside];
498
+ input.labelRequests.push({
499
+ id: `series:${series.id}`,
500
+ kind: "series",
501
+ owner: { seriesId: series.id },
502
+ text,
503
+ lines: [text],
504
+ typeRole: "label",
505
+ font: nameFont,
506
+ priority: NAME_PRIORITY + (input.highlights.has(series.id) || input.heroId === series.id ? PRIORITY.highlightBonus : 0),
507
+ candidates
508
+ });
509
+ });
510
+ }
511
+ function endpointAnchor(label, marks, cats, isStacked, y, cumTop, cumBot) {
512
+ let point = marks.series.find((item) => item.seriesId === label.s.id)?.points.find((item) => item.categoryId === cats[label.ci].id);
513
+ return point ? isStacked ? { x: point.x, y: (y(cumTop[label.dataIdx][label.ci]) + y(cumBot[label.dataIdx][label.ci])) / 2 } : point : null;
514
+ }
515
+ function endpointCandidate(input) {
516
+ let { rect, size, leaderFrom } = input;
517
+ return rect.x < 0 || rect.y < 0 || rect.x + rect.w > size.width || rect.y + rect.h > size.height || input.outsideRankBand(rect) ? null : {
518
+ slot: input.slot,
519
+ rect,
520
+ penalty: input.penalty,
521
+ ...leaderFrom && input.leaderClearsAreaFill && (input.isArea || input.isStacked || input.keepLeader || Math.abs(rect.y + rect.h / 2 - input.desiredY) > ENDPOINT_LEADER_MIN_DY) ? { leaderFrom } : {}
522
+ };
523
+ }
524
+ function nameSpreadSizes(heights, rankYs) {
525
+ let loose = heights.map((h) => h + 2);
526
+ if (!rankYs) return loose;
527
+ let ys = rankYs.filter((y) => y !== void 0), rows = [...new Set(ys)].sort((a, b) => a - b);
528
+ if (rows.length < ys.length || rows.length < 2) return loose;
529
+ let pitch = minOf(rows.slice(1).map((y, i) => y - rows[i]));
530
+ return heights.every((h) => h + 2 <= pitch) ? heights.map((h) => Math.min(h + 2, pitch - 2)) : loose;
531
+ }
532
+ function placeEndpointLabels(input) {
533
+ let leaders = /* @__PURE__ */ new Map();
534
+ if (input.endLabels.length === 0) return leaders;
535
+ let anchors = input.endLabels.map((label) => endpointAnchor(label, input.marks, input.cats, input.isStacked, input.y, input.cumTop, input.cumBot)), swatched = /* @__PURE__ */ new Set(), pairs = /* @__PURE__ */ new Set();
536
+ if (input.crowdedEnds && !input.isStacked && !input.isArea) {
537
+ let atLast = input.endLabels.flatMap((label, index) => label.ci === input.cats.length - 1 && !label.shared && anchors[index] ? [index] : []).sort((a, b) => anchors[a].y - anchors[b].y), clusters = [];
538
+ for (let index of atLast) {
539
+ let cluster = clusters[clusters.length - 1];
540
+ cluster && anchors[index].y - anchors[cluster[cluster.length - 1]].y < input.endLabels[index].h + 5 ? cluster.push(index) : clusters.push([index]);
541
+ }
542
+ let joinEvery = input.joinEvery === !0 && input.bounded !== void 0;
543
+ for (let cluster of clusters.filter((members) => joinEvery || members.length >= (input.bounded ? 2 : 3))) {
544
+ let fits = [];
545
+ for (let index of cluster) {
546
+ let label = input.endLabels[index], w = label.w;
547
+ if (input.valuesAtEnd && label.valueText) {
548
+ let valueText = label.valueText, lineH = label.h / Math.max(1, label.lines.length);
549
+ w = Math.max(label.w, input.valuesAtEnd.measure(valueText, input.labelFont).width), input.endLabels[index] = { ...label, text: `${label.text} ${valueText}`, lines: [...label.lines, valueText], h: label.h + lineH, w }, input.valuesAtEnd.merged.add(label.s.id), (cluster.length === 2 || joinEvery) && pairs.add(label.s.id);
550
+ }
551
+ !input.bounded && !input.endpointSwatches && input.endSwatchReserve === 0 && input.columnX + w + SWATCH_RESERVE <= input.size.width && fits.push(label.id);
552
+ }
553
+ if (fits.length === cluster.length) for (let id of fits) swatched.add(id);
554
+ }
555
+ }
556
+ let endsEarly = input.endLabels.map((label, index) => !input.isArea && anchors[index] !== null && label.ci < input.cats.length - 1), early = endsEarly.map((ends) => ends && input.atLineEnd === !0), sizes = nameSpreadSizes(input.endLabels.map((label) => label.h), input.rankLadder ? anchors.map((anchor) => anchor?.y) : void 0), items = anchors.map((anchor, index) => ({ desired: anchor?.y ?? input.plot.y + input.plot.h / 2, size: sizes[index] })), edgeIndices = items.flatMap((_, index) => early[index] ? [] : [index]), edgeItems = edgeIndices.map((index) => items[index]), range = [input.plot.y, input.plot.y + input.plot.h - (input.columnX < input.plot.x + input.plot.w ? 3 : 0)], spread = spread1DResult(edgeItems, range, 2);
557
+ if (input.bounded) {
558
+ let bound = input.bounded.lineHeight * END_LABEL_MAX_DISPLACEMENT_LINES, fits = () => spread.fits && edgeIndices.every((index, k) => Math.abs(spread.positions[k] - items[index].desired) <= bound), joinAll = !fits();
559
+ if (input.valuesAtEnd && (joinAll || pairs.size > 0)) {
560
+ for (let index of edgeIndices) {
561
+ let label = input.endLabels[index];
562
+ if (!input.valuesAtEnd.merged.has(label.s.id) || !label.valueText || !joinAll && !pairs.has(label.s.id)) continue;
563
+ let name = label.lines.slice(0, -1).join(" "), text = `${name} ${label.valueText}`;
564
+ input.endLabels[index] = {
565
+ ...label,
566
+ text,
567
+ lines: [text],
568
+ h: input.bounded.lineHeight,
569
+ w: input.valuesAtEnd.measure(`${name} `, input.labelFont).width + input.valuesAtEnd.measure(label.valueText, input.labelFont).width
570
+ };
571
+ }
572
+ items = anchors.map((anchor, index) => ({ desired: anchor?.y ?? input.plot.y + input.plot.h / 2, size: input.endLabels[index].h + 2 })), edgeItems = edgeIndices.map((index) => items[index]), spread = spread1DResult(edgeItems, range, 2);
573
+ }
574
+ let tooWide = edgeIndices.some((index) => input.columnX + input.endLabels[index].w + input.endSwatchReserve > input.size.width - 8);
575
+ if (fits() && tooWide && !input.bounded.wide && input.valuesAtEnd?.merged.size)
576
+ return input.bounded.widen = !0, leaders;
577
+ if (!fits() || tooWide)
578
+ return input.bounded.fallback = !0, leaders;
579
+ }
580
+ warnSpreadOverflow(input.warnings, spread.fits, "endpoint labels exceed the plot height even after spreading \u2014 labels stay bounded but overlap; fewer series or a larger canvas fixes it");
581
+ let edgePositions = spread.fits ? spread.positions : spread1D(edgeItems, range, 2), positions = items.map((item) => item.desired);
582
+ return edgeIndices.forEach((index, k) => {
583
+ positions[index] = edgePositions[k];
584
+ }), input.endLabels.forEach((label, index) => {
585
+ let anchor = anchors[index], desiredY = anchor?.y ?? input.plot.y + input.plot.h / 2, rect = { x: input.columnX, y: positions[index] - label.h / 2, w: label.w + (swatched.has(label.id) ? SWATCH_RESERVE : input.endSwatchReserve), h: label.h }, leaderFrom = anchor ? { x: Math.min(anchor.x + ENDPOINT_LEADER_CLEARANCE, rect.x - 2), y: anchor.y } : void 0;
586
+ leaderFrom && leaders.set(label.id, leaderFrom);
587
+ let common = { size: input.size, outsideRankBand: input.outsideRankBand, leaderFrom, leaderClearsAreaFill: !input.isArea || !input.paintedAreaCats.has(label.s.id) || label.ci === input.cats.length - 1 && input.paintedAreaCats.get(label.s.id)?.has(label.ci) === !0, isArea: input.isArea, isStacked: input.isStacked, keepLeader: endsEarly[index], desiredY }, atPoint = early[index] && anchor ? [
588
+ { slot: "besideEnd", rect: { ...rect, x: anchor.x + 8, y: anchor.y - label.h / 2 }, penalty: 0 },
589
+ { slot: "aboveEnd", rect: { ...rect, x: anchor.x + 4, y: anchor.y - label.h - 6 }, penalty: 1 },
590
+ { slot: "belowEnd", rect: { ...rect, x: anchor.x + 4, y: anchor.y + 6 }, penalty: 1 },
591
+ { slot: "overValueEnd", rect: { ...rect, x: anchor.x + 4, y: anchor.y - 2 * label.h - 8 }, penalty: 2 },
592
+ // Left of the point, where the lines that run on leave the right side
593
+ // no room: a line that ends at its first category.
594
+ { slot: "beforeEnd", rect: { ...rect, x: anchor.x - 8 - rect.w, y: anchor.y - label.h / 2 }, penalty: 2.5 },
595
+ { slot: "belowBeforeEnd", rect: { ...rect, x: anchor.x - 4 - rect.w, y: anchor.y + 6 }, penalty: 2.5 },
596
+ // A row further from the point, where other lines crowd the near rows
597
+ // and the value took the row above: over the value, as "Jun 26" reads
598
+ // over "60%", or under the rows below. Only then the right-hand rail,
599
+ // whose leader would cross the plot ("Mar 26" beside "Sep 25").
600
+ ...[1, 2].flatMap((k) => [
601
+ { slot: `overValueEnd${k}`, rect: { ...rect, x: anchor.x - rect.w / 2, y: anchor.y - (2 + k) * (label.h + 2) - 8 }, penalty: 2.6 + k / 10 },
602
+ { slot: `belowEnd${k}`, rect: { ...rect, x: anchor.x + 4, y: anchor.y + 6 + k * (label.h + 2) }, penalty: 2.6 + k / 10 }
603
+ ])
604
+ ].map((candidate) => endpointCandidate({ ...candidate, ...common, leaderFrom: void 0 })) : [], candidates = [
605
+ ...atPoint,
606
+ endpointCandidate({ slot: "lineEnd", rect, penalty: atPoint.length > 0 ? 3 : 0, ...common }),
607
+ ...!input.bounded || early[index] ? [endpointCandidate({ slot: "lineEndShifted", rect: { ...rect, y: rect.y + label.h + 2 }, penalty: atPoint.length > 0 ? 4 : 1, ...common })] : []
608
+ ].filter((item) => item !== null && (!input.bounded || Math.abs(item.rect.y + item.rect.h / 2 - desiredY) <= input.bounded.lineHeight * END_LABEL_MAX_DISPLACEMENT_LINES));
609
+ input.labelRequests.push({
610
+ id: label.id,
611
+ kind: label.kind,
612
+ owner: { seriesId: label.s.id, categoryId: input.cats[label.ci].id },
613
+ text: label.text,
614
+ lines: label.lines,
615
+ ...label.valueText && label.text.endsWith(` ${label.valueText}`) ? { printsFor: [{ seriesId: label.s.id, categoryId: input.cats[label.ci].id }] } : {},
616
+ ...label.title !== void 0 ? { title: label.title } : {},
617
+ typeRole: "label",
618
+ font: label.font ?? input.labelFont,
619
+ ...label.font ? { fontStep: label.font } : {},
620
+ // A name at an early end shares its point with the last value, and the
621
+ // value places first so it sits at the point (cohort curves).
622
+ priority: (early[index] ? PRIORITY.endpoint - 1 : NAME_PRIORITY) + (input.highlights.has(label.s.id) ? PRIORITY.highlightBonus : 0),
623
+ candidates,
624
+ ...input.bounded ? { leaderClear: "includingPins" } : {},
625
+ // A name at an early end takes a seat only where it lies nearer its
626
+ // own end than another series' marks; the rows further out (over the
627
+ // value, under the rows below) can reach a crossing line.
628
+ ...early[index] && anchor ? { anchor: { x: anchor.x, y: anchor.y } } : {},
629
+ // A shared label names several series; one colour swatch would claim it belongs to one of them.
630
+ ...label.shared ? {} : input.isArea ? { swatch: input.keyPaint(label.s, label.dataIdx) } : input.endpointSwatches || swatched.has(label.id) ? { swatch: input.seriesPaint(label.s, label.dataIdx) } : {}
631
+ });
632
+ }), leaders;
633
+ }
634
+ function pointLabelSeeds(input) {
635
+ let { series, row, cats } = input, drawn = row.flatMap((value, ci) => value === null ? [] : [ci]), values = drawn.map((ci) => row[ci]), min = minOf(values), max = maxOf(values), last = drawn[drawn.length - 1], seeds = [];
636
+ for (let ci of input.categoryIndices ?? drawn) {
637
+ let category = cats[ci], value = row[ci];
638
+ if (value === null) continue;
639
+ let cell = series.vals[ci], source = input.rebased ? void 0 : cell.format ? { ...series, format: cell.format } : series, pct = input.variant === "stacked100-area" && !input.sharesWithheld.has(category.id) ? value : null, abs = input.rebased ? value : input.absOf(series, ci), unitSuffix = input.unitOnEvery || ci === last ? input.endUnitSuffix : "", composeText = ci === last ? input.composeEndText ?? input.composeText : input.composeText, text = composeText(input.content, abs, pct, category.label ?? category.id, series.label, unitSuffix, cell.isPct, source, category.id);
640
+ if (typeof cell.labelOverride == "string" && (text = authoredCellText(cell.labelOverride, {
641
+ composeText,
642
+ variant: input.variant,
643
+ abs,
644
+ pct,
645
+ isPct: cell.isPct,
646
+ unitSuffix,
647
+ source,
648
+ categoryId: category.id
649
+ })), !text && cell.labelOverride !== !1) continue;
650
+ let endpoint = ci === drawn[0] || ci === last, extreme = value === min || value === max, highlighted = input.highlights.has(series.id) || input.highlights.has(category.id), priority = cell.priority ?? (endpoint ? PRIORITY.endpoint : extreme ? PRIORITY.extreme : PRIORITY.interior + Math.min(99, Math.abs(value))) + (highlighted ? PRIORITY.highlightBonus : 0);
651
+ seeds.push({ ci, text, w: input.measure(text || "0", input.labelFont).width, priority, suppressed: cell.labelOverride === !1 });
652
+ }
653
+ return seeds;
654
+ }
655
+ function buildPointCandidates(input) {
656
+ let { series, dataIdx, row } = input;
657
+ return pointLabelSeeds(input).map((seed) => {
658
+ let { ci, w: width } = seed, value = row[ci], py = input.isStacked ? input.y(input.cumTop[dataIdx][ci]) : input.y(value), center = width <= input.plot.w ? Math.max(input.plot.x + width / 2, Math.min(input.xOf(ci), input.plot.x + input.plot.w - width / 2)) : input.xOf(ci), candidate = { ...seed, x: center, py };
659
+ return input.isStacked && (candidate.bandTop = input.y(input.cumTop[dataIdx][ci]), candidate.bandBot = input.y(input.cumBot[dataIdx][ci]), input.paintedAreaCats.get(series.id)?.has(ci) && (candidate.insidePaint = input.areaFillPaint(series, dataIdx), candidate.insideFill = input.paintCss(candidate.insidePaint))), candidate;
660
+ });
661
+ }
662
+ function insideBandEdges(rect, edges, labelH) {
663
+ let hits = (edge) => edge.some((point, i) => i > 0 && segmentHitsRect(edge[i - 1], point, rect, 2));
664
+ if (!hits(edges.top) && !hits(edges.bottom)) return rect;
665
+ let x0 = rect.x, x1 = rect.x + rect.w, within = (edge) => [polylineYAt(edge, x0), polylineYAt(edge, x1), ...edge.filter((p) => p.x > x0 && p.x < x1).map((p) => p.y)], top = maxOf(within(edges.top)), bottom = minOf(within(edges.bottom));
666
+ if (!(bottom - top < labelH + 4))
667
+ return { ...rect, y: (top + bottom) / 2 - labelH / 2 };
668
+ }
669
+ function drawnRuns(row, interpolateGaps) {
670
+ let runs = [], run = [];
671
+ return row.forEach((value, ci) => {
672
+ value !== null ? run.push(ci) : !interpolateGaps && run.length > 0 && (runs.push(run), run = []);
673
+ }), run.length > 0 && runs.push(run), runs;
674
+ }
675
+ function lineToDateIds(env, domain, text) {
676
+ let ids = /* @__PURE__ */ new Set(), { options, cats } = domain;
677
+ if (partialKeyForced(options) || !cats.some((c) => c.partial === !0) || domain.drawnSeries.length !== 1 || env.isBump || domain.isStacked || domain.fan || domain.labelModes.values === "none" || text.contentOf("point", ["absolute"]) === null) return ids;
678
+ let words = options.strings?.toDate ?? chartString(options, "toDate");
679
+ return !domain.x && !toDateFits(words, env.theme, env.measure, env.size.width / Math.max(1, cats.length)) || cats.forEach((c, ci) => {
680
+ c.partial === !0 && !saysToDate(c.label ?? c.id, words) && domain.drawnSeries.some((s) => (s.vals[ci]?.v ?? null) !== null) && ids.add(c.id);
681
+ }), ids;
682
+ }
683
+ function pushPointRequests(input) {
684
+ let keep = input.regularRow ? input.candidates.map((candidate) => !candidate.suppressed) : sweepHide(input.candidates.map((candidate) => ({ start: candidate.x - candidate.w / 2, size: candidate.w, priority: candidate.suppressed ? -1 / 0 : candidate.priority })), 4), lastDrawn = input.series.vals.reduce((last, cell, ci) => cell.v === null ? last : ci, -1), firstDrawn = input.series.vals.findIndex((cell) => cell.v !== null), { ownQueries, otherQueries } = input;
685
+ input.candidates.forEach((candidate, index) => {
686
+ let category = input.cats[candidate.ci], name = `${input.series.label} in ${category.label ?? category.id}`, words = !input.isStacked && input.toDate?.ids.has(category.id) ? toDateLabel(candidate.text, input.labelFont, input.toDate.words, input.toDate.theme, input.toDate.measure) : void 0, labelH = words?.size.height ?? input.labelH, w = words?.size.width ?? candidate.w, redundant = candidate.suppressed || !keep[index], authored = typeof input.series.vals[candidate.ci]?.labelOverride == "string", computed = !(input.namedEnd && candidate.ci === lastDrawn) && !authored, continuedEnd = input.continued && (candidate.ci === firstDrawn || candidate.ci === lastDrawn), beside = computed && input.step > w + 8, lost = candidate.suppressed ? {} : { suppressedAs: "density" }, rest = input.restHidden === !0 && !candidate.suppressed, restFields = rest ? restValueHiding(`${input.series.label} ${candidate.text} (${noteName(category)})`) : {}, slots;
687
+ if (input.isStacked) {
688
+ let bandH = candidate.bandBot - candidate.bandTop, fits = input.labelH + 2 <= bandH && candidate.w + 4 <= input.step, ends = input.bandEdges ? [input.bandEdges.top[0].x + 5, input.bandEdges.top[input.bandEdges.top.length - 1].x - 5] : [input.plot.x, input.plot.x + input.plot.w], painted = input.painted;
689
+ painted?.has(candidate.ci) && (candidate.ci > 0 && !painted.has(candidate.ci - 1) && (ends[0] = Math.max(ends[0], input.xOf(candidate.ci) + 5)), candidate.ci < input.cats.length - 1 && !painted.has(candidate.ci + 1) && (ends[1] = Math.min(ends[1], input.xOf(candidate.ci) - 5)));
690
+ let x = input.row !== void 0 && (input.row[candidate.ci - 1] ?? null) === null && (input.row[candidate.ci + 1] ?? null) === null ? candidate.x : Math.max(ends[0] + candidate.w / 2, Math.min(candidate.x, ends[1] - candidate.w / 2)), centred = containedRect(input.plot, x, (candidate.bandTop + candidate.bandBot) / 2 - input.labelH / 2, candidate.w, input.labelH), rect = centred && input.bandEdges ? insideBandEdges(centred, input.bandEdges, input.labelH) : centred;
691
+ slots = rect ? [{ slot: rect === centred ? "insideBand" : "insideBandFitted", rect, penalty: 0, insideFill: candidate.insideFill, insidePaint: candidate.insidePaint }] : [];
692
+ let aboveTop = input.topBand && authored ? containedRect(
693
+ { ...input.plot, y: input.plot.y - input.labelH - 8, h: input.plot.h + input.labelH + 8 },
694
+ candidate.x !== input.xOf(candidate.ci) ? candidate.x : input.xOf(candidate.ci) + 8 + candidate.w / 2,
695
+ candidate.bandTop - input.labelH - 6,
696
+ candidate.w,
697
+ input.labelH
698
+ ) : null;
699
+ if (aboveTop) {
700
+ let leaderFrom = { x: input.xOf(candidate.ci), y: (candidate.bandTop + candidate.bandBot) / 2 };
701
+ !fits || centred && !rect || input.density !== "full" && bandH < SLIVER_MIN_H ? slots = [{ slot: "aboveBand", rect: aboveTop, penalty: 0, leaderFrom }] : rect && slots.push({ slot: "aboveBand", rect: aboveTop, penalty: 1, leaderFrom });
702
+ }
703
+ if (!aboveTop && (!fits || centred && !rect || input.density !== "full" && bandH < SLIVER_MIN_H)) {
704
+ !candidate.suppressed && !rest && input.lost.sliver.push(name), input.labelRequests.push({
705
+ id: `point:${input.series.id}:${category.id}`,
706
+ kind: "point",
707
+ role: composedTextRole(candidate.text),
708
+ owner: { seriesId: input.series.id, categoryId: category.id },
709
+ text: candidate.text,
710
+ lines: [candidate.text],
711
+ typeRole: "label",
712
+ font: input.labelFont,
713
+ priority: candidate.priority,
714
+ redundant: !0,
715
+ ...lost,
716
+ ...restFields,
717
+ candidates: slots,
718
+ // sliver-labels-hidden reports it; the requested-row warn leaves it out.
719
+ quietWhenCrowded: !0
720
+ });
721
+ return;
722
+ }
723
+ } else {
724
+ let away = input.bump ? "above" : sideAwayFrom({ x: input.xOf(candidate.ci), y: candidate.py }, input.others), order = away === "below" ? ["below", "above", "belowShifted", "aboveShifted"] : away === "above" ? ["above", "below", "aboveShifted", "belowShifted"] : ["above", "aboveShifted", "below", "belowShifted"], px = input.xOf(candidate.ci), at = { x: px, y: candidate.py, w: 0, h: 0 }, rivals = otherQueries.filter((stroke) => stroke.distance(at) > 1e-6), last = candidate.ci === lastDrawn, lateFirst = candidate.ci === firstDrawn && firstDrawn > 0 && !input.bump, rescue = [
725
+ // The first focus value has the same level seat as the last value,
726
+ // mirrored left. A steep rise can block every seat over the point.
727
+ ...candidate.ci === firstDrawn && input.highlighted ? [
728
+ { slot: "left", rect: { x: px - w - 7, y: candidate.py - labelH / 2, w, h: labelH }, penalty: 4 }
729
+ ] : [],
730
+ // Use the plot's 8 px axis gutter, with 2 px left clear, when clamping
731
+ // a first endpoint inward would put it on the rising stroke.
732
+ ...candidate.ci === firstDrawn && !input.bump ? [
733
+ { slot: "aboveEdge", rect: { x: Math.max(px - w / 2, input.plot.x - 6), y: candidate.py - labelH - 5, w, h: labelH }, penalty: 3 }
734
+ ] : [],
735
+ // Where an area's edge climbs into that seat, the value lifts 4 px, as its raised seat does.
736
+ ...candidate.ci === firstDrawn && input.variant === "area" ? [
737
+ { slot: "aboveEdgeHigh", rect: { x: Math.max(px - w / 2, input.plot.x - 6), y: candidate.py - labelH - 9, w, h: labelH }, penalty: 3.05 }
738
+ ] : [],
739
+ // A gap divider can cross the inward-clamped last forecast value.
740
+ // The reserved canvas margin can hold that value over its own point.
741
+ ...last && input.variant === "area" && candidate.ci > 0 && input.series.vals.findIndex((cell) => cell.scenario === "FC") === candidate.ci ? [
742
+ { slot: "forecastAboveEdge", rect: { x: px - w / 2, y: candidate.py - labelH - 5, w, h: labelH }, penalty: 4.2 },
743
+ { slot: "forecastBelowEdge", rect: { x: px - w / 2, y: candidate.py + 5, w, h: labelH }, penalty: 4.3 }
744
+ ] : [],
745
+ ...last && input.besideLast ? [{ slot: "right", rect: { x: px + 7, y: candidate.py - labelH / 2, w, h: labelH }, penalty: 4 }] : [],
746
+ // Two lines that end a line apart share the seat right of their
747
+ // points; the second value steps half a line off it on a short leader.
748
+ ...last && input.besideLast ? [1, -1, 2, -2].map((step) => ({
749
+ slot: `rightStep${step}`,
750
+ rect: { x: px + 9, y: candidate.py - labelH / 2 + step * (labelH + 2), w, h: labelH },
751
+ penalty: 4.5 + Math.abs(step) / 10,
752
+ leaderFrom: { x: px, y: candidate.py }
753
+ })) : [],
754
+ ...last && candidate.py - labelH - 5 < input.plot.y ? [{ slot: "aboveOut", rect: { x: candidate.x - w / 2, y: candidate.py - labelH - 5, w, h: labelH }, penalty: order.indexOf("above") }] : []
755
+ ], early = last && candidate.ci < input.cats.length - 1, x = candidate.x, bounds = input.bump ? { ...input.plot, y: input.plot.y - input.bump.headroom, h: input.plot.h + input.bump.headroom } : input.plot, seats = [
756
+ { slot: "above", x, y: candidate.py - labelH - 5 },
757
+ { slot: "below", x, y: candidate.py + 5 },
758
+ { slot: "aboveShifted", x, y: candidate.py - 2 * labelH - 9 },
759
+ { slot: "belowShifted", x, y: candidate.py + labelH + 9 },
760
+ // An area's value reads over its edge, never on the fill
761
+ // under it; where the edge climbs into the seat over the point, the value lifts 4 px.
762
+ ...input.variant === "area" ? [{ slot: "aboveRaised", x, y: candidate.py - labelH - 9, penalty: 0.5 }] : [],
763
+ // A rank line that climbs or drops at the point crosses the seat over
764
+ // it: the value keeps over its point, beside the diagonal, before it
765
+ // gives the side up.
766
+ ...input.bump ? [
767
+ { slot: "aboveLeft", x: px - 1 - w / 2, y: candidate.py - labelH - 5, penalty: 0.4 },
768
+ { slot: "aboveRight", x: px + 1 + w / 2, y: candidate.py - labelH - 5, penalty: 0.5 }
769
+ ] : [
770
+ // The seats an early end name takes (placeEndpointLabels), which the
771
+ // value takes first; the name then reads over it. A last value at the
772
+ // last category keeps the seats right of its point above.
773
+ ...early || beside && !last ? [
774
+ { slot: "aboveRight", x: px + 4 + w / 2, y: candidate.py - labelH - 6, penalty: early ? 1.5 : BESIDE_PENALTY },
775
+ { slot: "belowRight", x: px + 4 + w / 2, y: candidate.py + 6, penalty: early ? 1.5 : BESIDE_PENALTY }
776
+ ] : [],
777
+ // a late first value mirrors the early last one. It may also end at its
778
+ // point, over or under it to the left, where its own line has not started yet.
779
+ ...lateFirst || beside ? [
780
+ { slot: "aboveLeft", x: px - 4 - w / 2, y: candidate.py - labelH - 6, penalty: lateFirst ? 1.5 : BESIDE_PENALTY },
781
+ { slot: "belowLeft", x: px - 4 - w / 2, y: candidate.py + 6, penalty: lateFirst ? 1.5 : BESIDE_PENALTY }
782
+ ] : []
783
+ ]
784
+ ], named = input.bump?.named?.has(`${input.series.id}:${candidate.ci}`) === !0;
785
+ slots = seats.filter((seat) => !last || continuedEnd || Math.max(seat.y - candidate.py, candidate.py - seat.y - labelH, 0) <= labelH).filter((seat) => !((named || input.bump) && seat.slot.startsWith("below"))).filter((seat) => input.fillTo === void 0 || (seat.y + labelH / 2 - candidate.py) * (input.fillTo - candidate.py) <= 0).map((seat) => ({ slot: seat.slot, rect: containedRect(bounds, seat.x, seat.y, w, labelH), penalty: seat.penalty ?? (seat.slot.endsWith("Right") ? 1.5 : order.indexOf(seat.slot)) })).concat(rescue).sort((a, b) => a.penalty - b.penalty).flatMap((seat) => {
786
+ let { slot, rect, penalty } = seat, leaderFrom = "leaderFrom" in seat ? seat.leaderFrom : void 0;
787
+ if (rect === null) return [];
788
+ if (ownQueries.some((stroke) => stroke.hits(rect, 2))) return [];
789
+ if (leaderFrom) return [{ slot, rect, penalty, leaderFrom }];
790
+ if (lateFirst || rivals.length === 0) return [{ slot, rect, penalty }];
791
+ let own = 1 / 0;
792
+ for (let stroke of ownQueries) own = Math.min(own, stroke.distance(rect));
793
+ return rivals.some((stroke) => stroke.distance(rect) < own) ? [] : [{ slot, rect, penalty }];
794
+ });
795
+ }
796
+ computed && !continuedEnd && (slots = slots.filter((slot) => !slot.leaderFrom && !/Shifted|Raised|Step/.test(slot.slot))), !candidate.suppressed && !rest && !keep[index] && input.lost.thinned.push(name), input.labelRequests.push({
797
+ id: `point:${input.series.id}:${category.id}`,
798
+ kind: "point",
799
+ role: composedTextRole(candidate.text),
800
+ owner: { seriesId: input.series.id, categoryId: category.id },
801
+ text: candidate.text,
802
+ lines: words?.lines ?? [candidate.text],
803
+ ...words?.request,
804
+ typeRole: "label",
805
+ font: input.labelFont,
806
+ priority: candidate.priority,
807
+ redundant,
808
+ ...lost,
809
+ ...restFields,
810
+ candidates: slots,
811
+ ...computed && !input.highlighted && !continuedEnd ? { noLeader: !0 } : {},
812
+ // A value over a neighbour's point reads as that point's value.
813
+ ...input.isStacked || input.bump ? {} : { anchor: { x: input.xOf(candidate.ci), y: candidate.py }, ...computed ? { ownStrokeClear: !0 } : {} }
814
+ });
815
+ });
816
+ }
817
+ function pointLabelSelection(input) {
818
+ let pointContent = input.contentOf("point", input.valueContent), content = pointContent ?? input.valueContent, mode = pointContent === null ? "none" : input.valueLabels;
819
+ return input.drawnSeries.flatMap((series, dataIdx) => {
820
+ if (input.labelOnly !== void 0 && !input.labelOnly.has(series.id)) return [];
821
+ let row = input.pv[input.rowOf.get(series)], drawn = row.flatMap((value, ci) => value === null ? [] : [ci]);
822
+ if (drawn.length === 0) return [];
823
+ let first = drawn[0], last = drawn[drawn.length - 1], values = drawn.map((ci) => row[ci]), [min, max] = [minOf(values), maxOf(values)], engine = mode === "all" ? drawn : mode === "extremes" ? drawn.filter((ci) => ci === first || ci === last || row[ci] === min || row[ci] === max) : mode === "ends" ? [first, last] : mode === "last" ? [last] : [], fcStart = mode === "none" || mode === "all" || input.variant === "line" || input.variant === "stacked-area" ? -1 : series.scenario === "FC" ? 0 : series.vals.findIndex((val) => val.scenario === "FC"), lastActual = fcStart > 0 ? lastActualIndex(series, fcStart, !1) : -1, extra = lastActual >= 0 && row[lastActual] !== null && !engine.includes(lastActual) ? lastActual : -1;
824
+ extra >= 0 && engine.push(extra);
825
+ let authored = input.valueLabelsAuthored && series.vals.every((cell) => cell.v === null || cell.labelOverride === !1 || typeof cell.labelOverride == "string") ? [] : drawn.filter((ci) => typeof series.vals[ci]?.labelOverride == "string"), flagged = input.flagged?.seriesId === series.id && pointContent !== null ? drawn.filter((ci) => input.flagged.at.has(ci)) : [], withheld = input.lastWithheld.has(series.id) ? last : -1, keepAuthoredLast = typeof series.vals[last]?.labelOverride == "string" && !input.lastCarried?.has(series.id), only = [.../* @__PURE__ */ new Set([...engine, ...authored, ...flagged])].filter((ci) => (ci !== withheld || keepAuthoredLast) && (ci !== first || !input.firstWithheld?.has(series.id))).sort((a, b) => a - b);
826
+ return only.length > 0 ? [{ series, dataIdx, row, content, only, ...extra >= 0 ? { lastActual: extra } : {} }] : [];
827
+ });
828
+ }
829
+ function defaultValueContent(variant, seriesValueContent) {
830
+ return seriesValueContent ?? (variant === "stacked100-area" ? ["percent"] : ["absolute"]);
831
+ }
832
+ var PLOT_END_AIR = 4;
833
+ function pointLabelEndRoom(input) {
834
+ let room = { left: 0, right: 0 }, last = input.cats.length - 1;
835
+ if (input.isStacked || last < 0) return room;
836
+ for (let pick of pointLabelSelection(input)) {
837
+ let categoryIndices = pick.only.filter((ci) => ci === 0 || ci === last);
838
+ for (let seed of pointLabelSeeds({ ...input, series: pick.series, row: pick.row, content: pick.content, categoryIndices })) {
839
+ if (seed.suppressed) continue;
840
+ seed.ci === 0 && (room.left = Math.max(room.left, seed.w / 2 + PLOT_END_AIR));
841
+ let words = seed.ci === last && input.endToDate?.ids.has(input.cats[last].id) ? toDateLabel(seed.text, input.labelFont, input.endToDate.words, input.endToDate.theme, input.endToDate.measure).size.width : seed.w;
842
+ seed.ci === last && (room.right = Math.max(room.right, words / 2 + PLOT_END_AIR));
843
+ }
844
+ }
845
+ return room;
846
+ }
847
+ function pointValueWidths(input) {
848
+ let widths = /* @__PURE__ */ new Map();
849
+ for (let { series, row, content, only } of pointLabelSelection(input))
850
+ for (let seed of pointLabelSeeds({ ...input, series, row, content, categoryIndices: only }))
851
+ seed.suppressed || widths.set(`${series.id}:${seed.ci}`, seed.w);
852
+ return widths;
853
+ }
854
+ function placePointValueLabels(input) {
855
+ let lost = { sliver: [], thinned: [] }, strokesOf = new Map(input.drawnSeries.map((series) => {
856
+ let row = input.pv[input.rowOf.get(series)], stroke = { runs: input.isStacked ? [] : input.drawnEdges?.get(series.id)?.runs ?? drawnRuns(row, series.interpolateGaps).map((run) => drawnStroke(run.map((ci) => ({ x: input.xOf(ci), y: input.y(row[ci]) })), input.interpolationFor(series))), queries: void 0 };
857
+ return [series.id, stroke];
858
+ }));
859
+ for (let { series, dataIdx, row, content, only, lastActual } of pointLabelSelection(input)) {
860
+ let seriesFont = input.focusFont && input.highlights.has(series.id) ? input.focusFont : input.labelFont, candidates = buildPointCandidates({ ...input, labelFont: seriesFont, series, dataIdx, row, content, categoryIndices: only });
861
+ for (let candidate of candidates) {
862
+ let divider = input.dividers.find((split) => split.ci === candidate.ci && Math.abs(split.x - candidate.x) < candidate.w / 2 + 3);
863
+ divider !== void 0 && (candidate.x = divider.x - 3 - candidate.w / 2);
864
+ }
865
+ let own = strokesOf.get(series.id), ownQueries = own.queries ??= own.runs.map(preparePolyline), others = [], otherQueries = [];
866
+ for (let [id, stroke] of strokesOf)
867
+ if (id !== series.id) {
868
+ for (let run of stroke.runs) others.push(run);
869
+ for (let query of stroke.queries ??= stroke.runs.map(preparePolyline)) otherQueries.push(query);
870
+ }
871
+ let edge = (cum) => drawnStroke(input.cats.map((_, ci) => ({ x: input.xOf(ci), y: input.y(cum[dataIdx][ci]) })), input.interpolationFor(series)), drawn = input.drawnEdges?.get(series.id), bandEdges = input.isStacked ? { top: drawn?.runs.flat() ?? edge(input.cumTop), bottom: drawn?.bottom ?? edge(input.cumBot) } : void 0, namedEnd = input.valueLabels !== "all" && !input.isStacked && !input.bump && (input.endNamed.has(series.id) || input.labelRequests.some((request) => request.kind === "series" && request.owner.seriesId === series.id));
872
+ pushPointRequests({ continued: input.drawnEdges !== void 0, highlighted: input.highlights.has(series.id) && !input.bump && input.variant === "line", regularRow: input.valueLabels === "all" && !input.isStacked, namedEnd, candidates, series, cats: input.cats, isStacked: input.isStacked, variant: input.variant, labelH: input.labelH, step: input.step, density: input.density, plot: input.plot, labelFont: seriesFont, labelRequests: input.labelRequests, ownQueries, others, otherQueries, xOf: input.xOf, besideLast: !input.endNamed.has(series.id), ...bandEdges ? { bandEdges } : {}, ...input.bump ? { bump: input.bump } : {}, topBand: input.isStacked && dataIdx === input.drawnSeries.length - 1, row, ...input.isStacked ? { painted: input.paintedAreaCats.get(series.id) } : {}, ...input.variant === "area" && input.drawnSeries.length > 1 && input.paintedAreaCats.has(series.id) ? { fillTo: input.y(0) } : {}, lost, restHidden: input.isStacked && input.restHidden?.(series) === !0, ...input.toDate ? { toDate: input.toDate } : {} });
873
+ let extra = lastActual === void 0 || typeof series.vals[lastActual]?.labelOverride == "string" ? void 0 : input.labelRequests.find((request) => request.id === `point:${series.id}:${input.cats[lastActual].id}`);
874
+ extra && (extra.quietWhenCrowded = !0, extra.redundant && extra.suppressedAs === "density" && delete extra.suppressedAs);
875
+ }
876
+ if (warnSliverLabels(input.warnings, lost.sliver, "widen or heighten the chart, or shorten the values with a coarser format"), lost.thinned.length > 0) {
877
+ let shown = lost.thinned.slice(0, 5).join(", ") + (lost.thinned.length > 5 ? ", ..." : "");
878
+ input.warnings.push({
879
+ code: "point-labels-thinned",
880
+ severity: "info",
881
+ message: `${lost.thinned.length} point value${lost.thinned.length === 1 ? " is" : "s are"} not printed because ${lost.thinned.length === 1 ? "it" : "each"} would overlap a neighbouring value of its series (${shown})`,
882
+ suggest: "widen the chart, or label fewer points"
883
+ });
884
+ }
885
+ }
886
+ function placeCategoryLabels(input) {
887
+ if (!input.show) return !1;
888
+ let rotated = input.plan.rotation !== 0, bottom = input.plot.y + input.plot.h;
889
+ return input.cats.forEach((category, ci) => {
890
+ let info = input.plan.infos[ci];
891
+ input.labelRequests.push({
892
+ id: `category:${category.id}`,
893
+ kind: "category",
894
+ owner: { categoryId: category.id },
895
+ text: category.label ?? category.id,
896
+ lines: info.lines,
897
+ ...categoryLineAlign(input.plan, ci),
898
+ ...info.title !== void 0 ? { title: info.title } : {},
899
+ typeRole: input.plan.typeRole,
900
+ font: input.plan.font,
901
+ priority: PRIORITY.endpoint,
902
+ redundant: !input.plan.keep[ci],
903
+ ...rotated ? { rotate: -45 } : {},
904
+ candidates: rotated ? [{ slot: "below", rect: rotatedClaimRect(input.xOf(ci), bottom + Math.max(9, info.h * Math.SQRT1_2 / 2 + 6), info.h), penalty: 0 }] : [{ slot: "below", rect: { x: input.plan.x(ci), y: bottom + 6, w: info.w, h: info.h }, penalty: 0 }]
905
+ });
906
+ }), pushAll(input.labelRequests, yearRowRequests(input.plan, bottom + 6)), !0;
907
+ }
908
+ function flaggedPoints(domain) {
909
+ let anomaly = domain.anomaly;
910
+ if (anomaly)
911
+ return { seriesId: anomaly.seriesId, at: new Set(domain.cats.flatMap((c, ci) => anomaly.model.flagByCategory.has(c.id) ? [ci] : [])) };
912
+ }
913
+
914
+ // src/core/charts/line/labelModes.ts
915
+ function lineLabelModes(options, variant, drawnSeries) {
916
+ let authored = options.seriesLabels, only = typeof authored == "object" && authored !== null ? authored.only : void 0, seriesSetting = options.labels === !1 ? !1 : options.labels?.series, content = Array.isArray(seriesSetting) ? seriesSetting : void 0, valueParts = content?.filter((part) => part !== "series"), series = seriesSetting === !1 ? "none" : typeof authored == "string" ? authored : content !== void 0 && !content.includes("series") ? "none" : only !== void 0 || content !== void 0 || !((variant === "line" || variant === "area") && drawnSeries === 1) ? "end" : "none", values = options.valueLabels ?? (valueParts?.length === 0 || variant === "bump" ? "none" : variant === "stacked100-area" || variant === "area" ? "ends" : "last");
917
+ return {
918
+ series,
919
+ values,
920
+ ...only !== void 0 && series === "end" ? { only: new Set(only) } : {},
921
+ ...valueParts !== void 0 && valueParts.length > 0 ? { seriesValueContent: valueParts } : {}
922
+ };
923
+ }
924
+
925
+ // src/core/charts/line/bump.ts
926
+ var BUMP_FOLDED = /* @__PURE__ */ Symbol("bumpFolded");
927
+ function validateBumpInput(input) {
928
+ let { options, targetsLength, dataSeries, cats } = input;
929
+ if (dataSeries.length < 2) throw new NormalizeError("bump-two-series", "series", "a rank chart needs at least two data-role series \u2014 one entity is a flat line at rank 1, which states nothing about who overtook whom");
930
+ if (cats.length < 2) throw new NormalizeError("bump-two-categories", "categories", "a rank chart needs at least two categories \u2014 crossings are the message and one period has none", "use chart type 'slope' for two points");
931
+ let conflicts = [
932
+ ["rebase100", !!options.rebase100],
933
+ ["ratioTier", options.ratioTier !== void 0],
934
+ ["gapFill", options.gapFill !== void 0],
935
+ ["fan", options.fan !== void 0],
936
+ ["targets", targetsLength > 0]
937
+ ];
938
+ for (let [name, present] of conflicts) if (present) throw new NormalizeError("bump-option-conflict", name, `'${name}' is defined on VALUES; variant 'bump' plots derived ranks, and applying it to a rank would produce a confident, wrong exhibit \u2014 remove '${name}' or drop variant 'bump'`);
939
+ }
940
+ function validateBumpIds(dataSeries) {
941
+ let idCounts = /* @__PURE__ */ new Map();
942
+ for (let series of dataSeries) idCounts.set(series.id, (idCounts.get(series.id) ?? 0) + 1);
943
+ let duplicateIds = [...idCounts.entries()].filter(([, count]) => count > 1).map(([id]) => id);
944
+ if (duplicateIds.length > 0) throw new NormalizeError(
945
+ "bump-duplicate-series-id",
946
+ "series",
947
+ `series id${duplicateIds.length === 1 ? "" : "s"} ${duplicateIds.map((id) => `'${id}'`).join(", ")} appear more than once \u2014 the ranking receipt is keyed by series id, so two entities under one id cannot both be ranked, drawn or described`,
948
+ "give every ranked entity its own id"
949
+ );
950
+ }
951
+ function warnBumpAxis(input) {
952
+ let { options, valueAxis, warnings } = input, sharedYDeclared = typeof options.scaleGroup?.y == "string", ignoredAxisOptions = [
953
+ valueAxis.min !== void 0 && !sharedYDeclared ? "min" : null,
954
+ valueAxis.max !== void 0 && !sharedYDeclared ? "max" : null,
955
+ valueAxis.break !== void 0 ? "break" : null
956
+ ].filter((name) => name !== null);
957
+ ignoredAxisOptions.length > 0 && warnings.push({
958
+ code: "bump-axis-option-ignored",
959
+ severity: "warn",
960
+ message: `valueAxis ${ignoredAxisOptions.map((name) => `'${name}'`).join(", ")} ignored \u2014 the rank domain is derived from the data (1 .. maxRank), not authored`
961
+ }), valueAxis.show === !1 && warnings.push({ code: "bump-axis-required", severity: "warn", message: "valueAxis.show:false ignored \u2014 a rank chart without rank ticks cannot be read; the axis is drawn" });
962
+ let printsValues = lineLabelModes(options, "bump", 0).values !== "none";
963
+ options.unit && !printsValues && warnings.push({ code: "bump-unit-ignored", severity: "warn", message: `unit '${options.unit}' ignored \u2014 the plotted quantity is rank, which has no unit`, suggest: "the plotted quantity is rank; put the measure in the subtitle" }), printsValues && !options.unit && !options.format && warnings.push({
964
+ code: "bump-values-unnamed",
965
+ severity: "warn",
966
+ message: "the printed values are the measure behind the ranks, and with no unit or format nothing on the page says what they are",
967
+ suggest: "set unit (each value carries it) or a format such as '1.0%', or valueLabels 'none'"
968
+ });
969
+ }
970
+ function prepareBump(input) {
971
+ let { isBump, options, valueAxis, targetsLength, seriesNorm, cats, warnings } = input, bumpDirection = options.bump?.direction ?? "higherIsBetter";
972
+ if (!isBump) return { bumpDirection, dataSeries: input.dataSeries, refSeries: input.refSeries };
973
+ validateBumpInput({ options, targetsLength, dataSeries: input.dataSeries, cats });
974
+ let refSeries = input.refSeries;
975
+ if (refSeries.length > 0) {
976
+ warnings.push({ code: "bump-reference-series-dropped", severity: "warn", message: `reference series ${refSeries.map((series) => `'${series.id}'`).join(", ")} name levels on the value scale, which the rank axis does not carry \u2014 dropped`, suggest: 'plot the reference on a value line chart, or give it role: "data" to rank it with the others' });
977
+ for (let series of refSeries) seriesNorm.splice(seriesNorm.indexOf(series), 1);
978
+ refSeries = [];
979
+ }
980
+ let empty = input.dataSeries.filter((series) => series.vals.every((cell) => cell.v === null));
981
+ if (empty.length > 0) {
982
+ warnings.push({ code: "bump-series-empty", severity: "warn", message: `${empty.map((series) => `'${series.id}'`).join(", ")} carry no value in any category and therefore hold no rank anywhere \u2014 dropped`, owner: { seriesId: empty[0].id } });
983
+ for (let series of empty) seriesNorm.splice(seriesNorm.indexOf(series), 1);
984
+ }
985
+ let dataSeries = seriesNorm.filter((series) => series.role !== "reference");
986
+ if (dataSeries.length < 2) throw new NormalizeError("bump-two-series", "series", `after dropping entities that hold no rank anywhere, ${dataSeries.length} data-role series remain \u2014 a rank chart needs at least two`);
987
+ validateBumpIds(dataSeries);
988
+ let bridging = dataSeries.filter((series) => series.interpolateGaps);
989
+ if (bridging.length > 0) {
990
+ warnings.push({ code: "bump-gap-bridging-disabled", severity: "warn", message: `gap bridging is forced off for ${bridging.map((series) => `'${series.id}'`).join(", ")} \u2014 bridging a period with no value would draw a rank the entity never held` });
991
+ for (let series of bridging) series.interpolateGaps = !1;
992
+ }
993
+ return warnBumpAxis({ options, valueAxis, warnings }), { bumpDirection, dataSeries, refSeries };
994
+ }
995
+ function deriveBumpRanks(input) {
996
+ let { isBump, direction, dataSeries, cats, pv, rowOf, fmt, format, warnings } = input;
997
+ if (!isBump) return;
998
+ let shown = /* @__PURE__ */ new Map(), read = (value) => {
999
+ let key = Object.is(value, -0) ? "-0" : value, text = shown.get(key);
1000
+ return text === void 0 && (text = fmt(value), shown.set(key, text)), text;
1001
+ }, sameToTheReader = (a, b) => a === b || read(a) === read(b), better = (a, b) => sameToTheReader(a, b) ? !1 : direction === "higherIsBetter" ? a > b : a < b, ranks = {}, participants = {}, ties = [], maxRank = 1;
1002
+ for (let series of dataSeries) ranks[series.id] = cats.map(() => null);
1003
+ cats.forEach((category, ci) => {
1004
+ let present = dataSeries.map((series) => ({ series, value: series.vals[ci].v })).filter((entry) => entry.value !== null);
1005
+ participants[category.id] = present.length;
1006
+ let byRank = /* @__PURE__ */ new Map();
1007
+ for (let entry of present) {
1008
+ let rank = 1 + present.filter((other) => better(other.value, entry.value)).length;
1009
+ ranks[entry.series.id][ci] = rank, maxRank = Math.max(maxRank, rank), byRank.set(rank, [...byRank.get(rank) ?? [], entry.series.id]);
1010
+ }
1011
+ for (let [rank, seriesIds] of [...byRank.entries()].sort((a, b) => a[0] - b[0]))
1012
+ seriesIds.length < 2 || (ties.push({ categoryId: category.id, rank, seriesIds }), warnings.push({ code: "bump-rank-tie", severity: "warn", message: `category '${category.id}': ${seriesIds.map((id) => `'${id}'`).join(", ")} share rank ${rank} \u2014 drawn at the same height, and the next rank is skipped (competition ranking)`, owner: { categoryId: category.id } }));
1013
+ });
1014
+ let census = cats.map((category) => participants[category.id]);
1015
+ new Set(census).size > 1 && warnings.push({ code: "bump-participants-vary", severity: "info", message: `the ranked field changes size across periods (${cats.map((category) => `${category.label ?? category.id}: ${participants[category.id]}`).join(", ")}) \u2014 rank ${maxRank} out of ${maxOf(census)} is not the same standing as rank ${maxRank} out of ${minOf(census)}` });
1016
+ for (let series of dataSeries) {
1017
+ let row = pv[rowOf.get(series)], seriesRanks = ranks[series.id];
1018
+ for (let ci = 0; ci < cats.length; ci++) row[ci] = seriesRanks[ci];
1019
+ }
1020
+ return { direction, method: "competition", maxRank, ranks, ties, participants, comparedAt: format ?? "auto" };
1021
+ }
1022
+ function bumpMethodNote(bump, format, strings) {
1023
+ if (!bump) return [];
1024
+ let words = { ...localeStrings(), ...strings };
1025
+ return [stringFields(words.rankMethod, {
1026
+ direction: bump.direction === "higherIsBetter" ? words.higherBetter : words.lowerBetter,
1027
+ format: format ? stringFields(words.rankFormat, { format }) : "",
1028
+ ring: bump.ties.length > 0 ? words.rankRing : ""
1029
+ })];
1030
+ }
1031
+ function buildBumpStartLabels(input) {
1032
+ let { isBump, endContent, dataSeries, pv, rowOf, cats, composeText, nameBlock } = input, startLabels = [];
1033
+ isBump && endContent && dataSeries.forEach((series, dataIdx) => {
1034
+ let ci = pv[rowOf.get(series)].findIndex((value) => value !== null);
1035
+ if (ci === -1) return;
1036
+ let name = composeText(endContent, null, null, cats[ci].label ?? cats[ci].id, series.label);
1037
+ if (!name) return;
1038
+ let { text, ...block } = foldBumpValue(name, input.folded?.get(`point:${series.id}:${cats[ci].id}`), (line) => nameBlock(line, series.id));
1039
+ startLabels.push({ id: `series-start:${series.id}`, kind: "series", s: series, dataIdx, ci, text, w: block.w, lines: block.lines, h: block.h, ...block.title !== void 0 ? { title: block.title } : {}, ...block.font ? { font: block.font } : {} });
1040
+ });
1041
+ let railStartLabels = startLabels.filter((label) => label.ci === 0);
1042
+ return { startLabels, startReserve: railStartLabels.length > 0 ? maxOf(railStartLabels.map((label) => label.w)) + 14 : 0 };
1043
+ }
1044
+ function renderBumpTies(theme, input) {
1045
+ let { bump, marks, nodes, occupied } = input;
1046
+ if (!bump || bump.ties.length === 0) return;
1047
+ let radius = 7;
1048
+ for (let tie of bump.ties) {
1049
+ let point = marks.series.find((item) => tie.seriesIds.includes(item.seriesId))?.points.find((item) => item.categoryId === tie.categoryId);
1050
+ if (!point) continue;
1051
+ let id = `tie:${tie.categoryId}:${tie.rank}`;
1052
+ nodes.push({
1053
+ t: "path",
1054
+ id,
1055
+ d: `M${fmtPathNumber(point.x - radius)} ${fmtPathNumber(point.y)}A${radius} ${radius} 0 1 0 ${fmtPathNumber(point.x + radius)} ${fmtPathNumber(point.y)}A${radius} ${radius} 0 1 0 ${fmtPathNumber(point.x - radius)} ${fmtPathNumber(point.y)}`,
1056
+ stroke: { token: "markInk" },
1057
+ width: strokeToken(theme, "mark"),
1058
+ owner: { categoryId: tie.categoryId },
1059
+ part: "tie",
1060
+ display: { value: `rank ${tie.rank}`, state: `${tie.seriesIds.length} tied` }
1061
+ }), occupied.claim({ x: point.x - radius, y: point.y - radius, w: radius * 2, h: radius * 2 }, "mark", { categoryId: tie.categoryId });
1062
+ }
1063
+ }
1064
+ function placeBumpTieLabels(input) {
1065
+ let { bump, marks, outsideRankBand, labelRequests, font, measure } = input, pointOf = (tie2) => marks.series.find((item) => item.seriesId === tie2.seriesIds[0])?.points.find((item) => item.categoryId === tie2.categoryId), tie = bump?.ties.find(pointOf);
1066
+ if (!tie) return;
1067
+ let point = pointOf(tie), words = { ...localeStrings(), ...input.strings }, text = `${words.tiedSymbol} ${words.tied}`, { width: w, height: h } = measure(text, font), word = measure(words.tied, font).width, radius = 7, slots = [
1068
+ // First above and right of the ring, clear of its line.
1069
+ ["aboveRightOfRing", { x: point.x + radius + 2, y: point.y - radius - h + 2, w: word, h }],
1070
+ ["aboveRing", { x: point.x - w / 2, y: point.y - radius - 2 - h, w, h }],
1071
+ ["belowRing", { x: point.x - w / 2, y: point.y + radius + 2, w, h }],
1072
+ ["rightOfRing", { x: point.x + radius + 3, y: point.y - h / 2, w, h }],
1073
+ ["leftOfRing", { x: point.x - radius - 3 - w, y: point.y - h / 2, w, h }]
1074
+ ];
1075
+ for (let dx of [12, -12 - w, 28, -28 - w, 48, -48 - w])
1076
+ for (let dy of [-h - 3, 3, -h - 14, 14]) slots.push(["besideRing", { x: point.x + dx, y: point.y + dy, w, h }]);
1077
+ let keyY = minOf(marks.series.flatMap((series) => series.points.map((point2) => point2.y))) - h - 10;
1078
+ for (let x of [point.x - w / 2, point.x + 12, point.x - w - 12]) slots.push(["tieKey", { x, y: keyY, w, h }]);
1079
+ labelRequests.push({
1080
+ id: `tieLabel:${tie.categoryId}:${tie.rank}`,
1081
+ kind: "scale",
1082
+ owner: { categoryId: tie.categoryId },
1083
+ text,
1084
+ lines: [text],
1085
+ typeRole: "axis",
1086
+ font,
1087
+ // The explanation of a mark outranks any value, a highlighted one too:
1088
+ // under valueLabels 'all' a value gives way, never the word for the ring.
1089
+ priority: PRIORITY.grandTotal,
1090
+ candidates: slots.filter(([slot, rect]) => slot === "tieKey" || !outsideRankBand(rect)).map(([slot, rect], penalty) => ({
1091
+ slot,
1092
+ rect,
1093
+ penalty,
1094
+ ...slot === "besideRing" ? { leaderFrom: point } : {},
1095
+ ...slot === "aboveRightOfRing" ? { lines: [words.tied] } : {}
1096
+ }))
1097
+ });
1098
+ }
1099
+ function joinTieValues(input) {
1100
+ let { bump, labelRequests, font, measure } = input;
1101
+ for (let tie of bump?.ties ?? []) {
1102
+ let ids = new Set(tie.seriesIds.map((id) => `point:${id}:${tie.categoryId}`)), values = labelRequests.filter((request) => ids.has(request.id));
1103
+ if (values.length === 0) continue;
1104
+ let note = labelRequests.find((request) => request.id === `tieLabel:${tie.categoryId}:${tie.rank}`), keep = note ? void 0 : values[0];
1105
+ for (let index = labelRequests.length - 1; index >= 0; index--) {
1106
+ let request = labelRequests[index];
1107
+ ids.has(request.id) && request !== keep && labelRequests.splice(index, 1);
1108
+ }
1109
+ if (!note) continue;
1110
+ let text = `${note.text} \xB7 ${values[0].text}`, w = measure(text, font).width, before = note.candidates[0]?.rect.w ?? w;
1111
+ note.text = text, note.lines = [text];
1112
+ let bare = note.candidates.find((candidate) => candidate.lines)?.lines?.[0], bareText = bare === void 0 ? void 0 : `${bare} \xB7 ${values[0].text}`, bareW = bareText === void 0 ? 0 : measure(bareText, font).width;
1113
+ note.candidates = note.candidates.map((candidate) => candidate.lines && bareText !== void 0 ? {
1114
+ ...candidate,
1115
+ lines: [bareText],
1116
+ rect: { ...candidate.rect, w: bareW }
1117
+ } : {
1118
+ ...candidate,
1119
+ rect: {
1120
+ ...candidate.rect,
1121
+ w,
1122
+ x: candidate.slot === "rightOfRing" ? candidate.rect.x : candidate.slot === "leftOfRing" ? candidate.rect.x + before - w : candidate.rect.x + before / 2 - w / 2
1123
+ }
1124
+ });
1125
+ }
1126
+ }
1127
+ function startLabelCandidates(input) {
1128
+ let { slots, desiredY, leaderFrom, width, height, outsideRankBand } = input;
1129
+ return slots.flatMap(([slot, rect, penalty]) => rect.x < 0 || rect.y < 0 || rect.x + rect.w > width || rect.y + rect.h > height || outsideRankBand(rect) ? [] : [{ slot, rect, penalty, ...leaderFrom && Math.abs(rect.y + rect.h / 2 - desiredY) > 3 ? { leaderFrom } : {} }]);
1130
+ }
1131
+ function pushStartLabel(input) {
1132
+ let { label, desiredY, leaderFrom, slots, size, outsideRankBand, endpointLeaderAnchors, labelRequests, labelFont, highlights, cats } = input;
1133
+ leaderFrom && endpointLeaderAnchors.set(label.id, leaderFrom), labelRequests.push({
1134
+ id: label.id,
1135
+ kind: "series",
1136
+ owner: { seriesId: label.s.id, categoryId: cats[label.ci].id },
1137
+ text: label.text,
1138
+ lines: label.lines,
1139
+ ...label.title !== void 0 ? { title: label.title } : {},
1140
+ typeRole: "label",
1141
+ font: label.font ?? labelFont,
1142
+ ...label.font ? { fontStep: label.font } : {},
1143
+ // A name says whose line it is: an entrant's first value, which takes the
1144
+ // seat over its point under valueLabels 'all', gives way to it.
1145
+ priority: PRIORITY.endpoint + 50 + (highlights.has(label.s.id) ? PRIORITY.highlightBonus : 0),
1146
+ candidates: startLabelCandidates({ slots, desiredY, leaderFrom, width: size.width, height: size.height, outsideRankBand }),
1147
+ // a name off its rank row takes a leader only where the leader
1148
+ // crosses no name and no rank number; else its next seat, else none.
1149
+ leaderClear: !0,
1150
+ leaderClearsAxis: !0
1151
+ });
1152
+ }
1153
+ function placeBumpStartLabels(input) {
1154
+ let { startLabels, marks, cats, plot, size, leftMargin, outsideRankBand, endpointLeaderAnchors, labelRequests, labelFont, highlights, warnings } = input, railLabels = startLabels.filter((label) => label.ci === 0), entrantLabels = startLabels.filter((label) => label.ci !== 0), anchorOf = (label) => marks.series.find((item) => item.seriesId === label.s.id)?.points.find((item) => item.categoryId === cats[label.ci].id) ?? null;
1155
+ if (railLabels.length > 0) {
1156
+ let anchors = railLabels.map(anchorOf), sizes = nameSpreadSizes(railLabels.map((label) => label.h), anchors.map((anchor) => anchor?.y)), items = anchors.map((anchor, index) => ({ desired: anchor?.y ?? plot.y + plot.h / 2, size: sizes[index] })), railSpread = spread1DResult(items, [plot.y, plot.y + plot.h], 2);
1157
+ warnSpreadOverflow(warnings, railSpread.fits, "start-rail labels exceed the plot height even after spreading \u2014 labels stay bounded but overlap; fewer series or a larger canvas fixes it");
1158
+ let spreadPositions = railSpread.fits ? railSpread.positions : spread1D(items, [plot.y, plot.y + plot.h], 2);
1159
+ railLabels.forEach((label, index) => {
1160
+ let anchor = anchors[index], desiredY = anchor?.y ?? plot.y + plot.h / 2, rect = { x: leftMargin - 6 - label.w, y: spreadPositions[index] - label.h / 2, w: label.w, h: label.h }, leaderFrom = anchor ? { x: Math.max(anchor.x - 4, rect.x + rect.w + 2), y: anchor.y } : void 0;
1161
+ pushStartLabel({ label, desiredY, leaderFrom, slots: [["lineStart", rect, 0], ["lineStartShifted", { ...rect, y: rect.y + label.h + 2 }, 1]], size, outsideRankBand, endpointLeaderAnchors, labelRequests, labelFont, highlights, cats });
1162
+ });
1163
+ }
1164
+ entrantLabels.forEach((label) => {
1165
+ let anchor = anchorOf(label), desiredY = anchor?.y ?? plot.y + plot.h / 2, rect = { x: (anchor?.x ?? plot.x) + 6, y: desiredY - label.h / 2, w: label.w, h: label.h }, leaderFrom = anchor ? { x: Math.min(anchor.x + 4, rect.x - 2), y: anchor.y } : void 0, left = { ...rect, x: (anchor?.x ?? plot.x) - Math.max(6, (input.valueWidth?.(label) ?? 0) / 2 + 4) - label.w };
1166
+ pushStartLabel({ label, desiredY, leaderFrom, slots: [["entrantStartLeft", left, 0], ["entrantStart", rect, 1], ["entrantStartAbove", { ...rect, y: rect.y - label.h - 4 }, 2], ["entrantStartBelow", { ...rect, y: rect.y + label.h + 4 }, 2]], size, outsideRankBand, endpointLeaderAnchors, labelRequests, labelFont, highlights, cats });
1167
+ });
1168
+ }
1169
+
1170
+ // src/core/charts/line/range.ts
1171
+ function cutEdge(edge, mode, lo, hi) {
1172
+ let points = edge.points;
1173
+ if (!points.length || points[0].x > hi || points[points.length - 1].x < lo) return { points: [] };
1174
+ let curve = edge.curve;
1175
+ for (let [x, start] of [[lo, !0], [hi, !1]]) {
1176
+ if (x < points[0].x || x > points[points.length - 1].x) continue;
1177
+ if (x === points[0].x) {
1178
+ if (!start) return { points: [points[0]] };
1179
+ continue;
1180
+ }
1181
+ if (x === points[points.length - 1].x) {
1182
+ if (start) return { points: [points[points.length - 1]] };
1183
+ continue;
1184
+ }
1185
+ let i = points.findIndex((p) => p.x >= x), a = points[i - 1], b = points[i], y = mode === "step-after" ? a.y : mode === "step-before" ? b.y : a.y + (b.y - a.y) * (x - a.x) / (b.x - a.x);
1186
+ if (curve && (curve = splitCurveSegmentsAtX(curve, x)[start ? 1 : 0], y = start ? curve[0].from.y : curve[curve.length - 1].to.y), b.x === x) points = start ? points.slice(i) : points.slice(0, i + 1);
1187
+ else {
1188
+ let boundary = { x, y, ci: start ? b.ci : a.ci };
1189
+ points = start ? [boundary, ...points.slice(i)] : [...points.slice(0, i), boundary];
1190
+ }
1191
+ }
1192
+ return { points, ...curve ? { curve } : {} };
1193
+ }
1194
+ function rangeCut(xs, indexes, lo, hi) {
1195
+ let first = indexes[0], last = indexes[indexes.length - 1];
1196
+ return { lo: xs[first - 1] < lo && xs[first] > lo, hi: xs[last + 1] > hi && xs[last] < hi };
1197
+ }
1198
+ function rangeIndexes(range) {
1199
+ let first = range.indexes[0], last = range.indexes[range.indexes.length - 1], before = range.cut.lo ? [first - 2, first - 1] : [], after = range.cut.hi ? [last + 1, last + 2] : [];
1200
+ return [...before, ...range.indexes, ...after].filter((i) => i >= 0 && i < range.xs.length);
1201
+ }
1202
+ function rangeRuns(range, rows, mode, interpolateGaps = !1) {
1203
+ let first = range.indexes[0], last = range.indexes[range.indexes.length - 1], indexes = rangeIndexes(range), visible = new Map(range.indexes.map((source, ci) => [source, ci])), runs = [], current = rows.map(() => []), flush = () => {
1204
+ if (current[0].length) {
1205
+ let edges = current.map((points) => cutEdge({ points, ...mode === "monotone" ? { curve: monotoneSegments(points) } : {} }, mode, range.lo, range.hi));
1206
+ edges[0].points.length && runs.push(edges);
1207
+ }
1208
+ current = rows.map(() => []);
1209
+ };
1210
+ for (let source of indexes) {
1211
+ if (range.invalid.has(source) || rows.some((row) => row[source] === null)) {
1212
+ (!interpolateGaps || source < first || source > last || range.invalid.has(source)) && flush();
1213
+ continue;
1214
+ }
1215
+ let ci = visible.get(source) ?? (source < first ? 0 : range.indexes.length - 1);
1216
+ rows.forEach((row, k) => current[k].push({ x: range.xs[source], y: row[source], ci }));
1217
+ }
1218
+ return flush(), runs;
1219
+ }
1220
+ function mapEdge(edge, x, y) {
1221
+ let point = (p) => ({ x: x(p.x), y: y(p.y) });
1222
+ return {
1223
+ points: edge.points.map((p) => ({ ...point(p), ci: p.ci })),
1224
+ ...edge.curve ? { curve: edge.curve.map((c) => ({ from: point(c.from), c1: point(c.c1), c2: point(c.c2), to: point(c.to) })) } : {}
1225
+ };
1226
+ }
1227
+ function edgePath(edge, path) {
1228
+ return edge.curve ? curvePathFromSegments(edge.curve) : path(edge.points);
1229
+ }
1230
+
1231
+ // src/core/charts/line/marks.ts
1232
+ function pathFor(points, mode) {
1233
+ if (mode === "linear") return linePath(points.map((point) => ({ x: point.x, y: point.y })));
1234
+ if (mode === "monotone") return monotonePath(points);
1235
+ if (points.length === 0) return "";
1236
+ let path = `M${fmtPathNumber(points[0].x)} ${fmtPathNumber(points[0].y)}`;
1237
+ for (let index = 1; index < points.length; index++) {
1238
+ let previous = points[index - 1], point = points[index], elbow = mode === "step-after" ? { x: point.x, y: previous.y } : { x: previous.x, y: point.y };
1239
+ path += `L${fmtPathNumber(elbow.x)} ${fmtPathNumber(elbow.y)}L${fmtPathNumber(point.x)} ${fmtPathNumber(point.y)}`;
1240
+ }
1241
+ return path;
1242
+ }
1243
+ function reversePathTail(points, mode) {
1244
+ if (points.length < 2) return "";
1245
+ if (mode === "monotone")
1246
+ return [...monotoneSegments(points)].reverse().map((segment) => `C${fmtPathNumber(segment.c2.x)} ${fmtPathNumber(segment.c2.y)} ${fmtPathNumber(segment.c1.x)} ${fmtPathNumber(segment.c1.y)} ${fmtPathNumber(segment.from.x)} ${fmtPathNumber(segment.from.y)}`).join("");
1247
+ let expanded = [points[0]];
1248
+ for (let index = 1; index < points.length; index++) {
1249
+ let previous = points[index - 1], point = points[index];
1250
+ mode === "step-after" && expanded.push({ x: point.x, y: previous.y }), mode === "step-before" && expanded.push({ x: previous.x, y: point.y }), expanded.push(point);
1251
+ }
1252
+ return [...expanded].reverse().slice(1).map((point) => `L${fmtPathNumber(point.x)} ${fmtPathNumber(point.y)}`).join("");
1253
+ }
1254
+ function createClaims(occupied, cats, inlineNamesEnabled) {
1255
+ let lineOwner = (seriesId, categoryId) => inlineNamesEnabled ? { seriesId } : { seriesId, categoryId }, segment = (a, b, categoryA, categoryB, seriesId, thick = 3) => {
1256
+ let chunks = Math.max(1, Math.min(8, Math.ceil(Math.max(Math.abs(b.x - a.x), Math.abs(b.y - a.y)) / 14)));
1257
+ for (let index = 0; index < chunks; index++) {
1258
+ let t0 = index / chunks, t1 = (index + 1) / chunks, x0 = a.x + (b.x - a.x) * t0, x1 = a.x + (b.x - a.x) * t1, y0 = a.y + (b.y - a.y) * t0, y1 = a.y + (b.y - a.y) * t1, category = (t0 + t1) / 2 < 0.5 ? categoryA : categoryB;
1259
+ occupied.claim({ x: Math.min(x0, x1) - thick / 2, y: Math.min(y0, y1) - thick / 2, w: Math.abs(x1 - x0) + thick, h: Math.abs(y1 - y0) + thick }, "mark", lineOwner(seriesId, category));
1260
+ }
1261
+ }, outline = (x0, x1, top0, top1, bot0, bot1, owner) => {
1262
+ let t = (top0 - bot0) / (top0 - bot0 - (top1 - bot1)), cross = { x: x0 + (x1 - x0) * t, y: top0 + (top1 - top0) * t }, polygons = t > 0 && t < 1 ? [[{ x: x0, y: top0 }, cross, { x: x0, y: bot0 }], [cross, { x: x1, y: top1 }, { x: x1, y: bot1 }]] : [[{ x: x0, y: top0 }, { x: x1, y: top1 }, { x: x1, y: bot1 }, { x: x0, y: bot0 }]];
1263
+ for (let polygon of polygons) {
1264
+ let xs = polygon.map((point) => point.x), ys = polygon.map((point) => point.y), x = minOf(xs), y = minOf(ys);
1265
+ occupied.claim({ x, y, w: maxOf(xs) - x, h: maxOf(ys) - y }, "mark", owner, AREA_FILL_PART, polygon);
1266
+ }
1267
+ };
1268
+ return { lineOwner, segment, areaPair: (xA, xB, topA, topB, botA, botB, categoryA, categoryB, seriesId, mode) => {
1269
+ let [t0, t1, b0, b1] = mode === "linear" ? [topA, topB, botA, botB] : mode === "step-after" ? [topA, topA, botA, botA] : [topB, topB, botB, botB], xM = (xA + xB) / 2, tM = (t0 + t1) / 2, bM = (b0 + b1) / 2;
1270
+ outline(xA, xM, t0, tM, b0, bM, lineOwner(seriesId, categoryA)), outline(xM, xB, tM, t1, bM, b1, lineOwner(seriesId, categoryB));
1271
+ }, linePair: (a, b, categoryA, categoryB, seriesId, mode) => {
1272
+ if (mode === "linear") return segment(a, b, categoryA, categoryB, seriesId);
1273
+ let elbow = mode === "step-after" ? { ci: b.ci, x: b.x, y: a.y } : { ci: a.ci, x: a.x, y: b.y };
1274
+ segment(a, elbow, categoryA, categoryA, seriesId), segment(elbow, b, categoryB, categoryB, seriesId);
1275
+ }, monotoneRun: (points, segments, seriesId) => {
1276
+ segments.forEach((curve) => {
1277
+ let index = 0;
1278
+ for (; index < points.length - 2 && points[index + 1].x <= curve.from.x; ) index++;
1279
+ let previous = curve.from;
1280
+ for (let sample = 1; sample <= 8; sample++) {
1281
+ let point = cubicPoint(curve, sample / 8);
1282
+ segment(previous, point, cats[points[index].ci].id, cats[points[index + 1].ci].id, seriesId), previous = point;
1283
+ }
1284
+ });
1285
+ } };
1286
+ }
1287
+ function forecastStart(series, cats) {
1288
+ return series.scenario === "FC" ? 0 : cats.findIndex((_, ci) => series.vals[ci].scenario === "FC");
1289
+ }
1290
+ function lastActualIndex(series, start, stacked) {
1291
+ let ci = start - 1;
1292
+ for (; !stacked && ci > 0 && series.vals[ci].v === null; ) ci--;
1293
+ return ci;
1294
+ }
1295
+ function forecastBoundaryX(boundary, xOf, at) {
1296
+ return at === "point" ? xOf(boundary.lastActualIndex) : (xOf(boundary.categoryIndex - 1) + xOf(boundary.categoryIndex)) / 2;
1297
+ }
1298
+ function buildSeriesGeometry(input, series, dataIdx) {
1299
+ let row = input.pv[input.rowOf.get(series)], runs = [], current = [];
1300
+ input.cats.forEach((_, ci) => {
1301
+ if (input.compositionInvalidAt(ci)) {
1302
+ current.length > 0 && runs.push(current), current = [];
1303
+ return;
1304
+ }
1305
+ if (row[ci] === null && !input.isStacked) {
1306
+ series.interpolateGaps || (current.length > 0 && runs.push(current), current = []);
1307
+ return;
1308
+ }
1309
+ let value = input.isStacked ? input.y(input.cumTop[dataIdx][ci]) : row[ci] === null ? null : input.y(row[ci]);
1310
+ value !== null && current.push({ ci, x: input.xOf(ci), y: value });
1311
+ }), current.length > 0 && runs.push(current);
1312
+ let interpolation = input.interpolationFor(series), allPoints = runs.flat();
1313
+ if (input.range && input.xOfValue) {
1314
+ let range = input.range, sourceRow = range.plotted[input.rowOf.get(series)], top = input.isStacked ? range.cumTop[dataIdx].map((v, i) => sourceRow[i] === null && (i <= range.indexes[0] || i >= range.indexes[range.indexes.length - 1]) ? null : v) : sourceRow, rows = input.isStacked ? [top, range.cumBot[dataIdx]] : [top], mapped = rangeRuns(range, rows, interpolation, series.interpolateGaps).map((edges) => edges.map((edge) => mapEdge(edge, input.xOfValue, input.y))), rangedRuns = mapped.map((edges) => edges[0].points), values = range.values.get(series.id), fc = series.scenario === "FC" ? 0 : values.findIndex((v) => v.scenario === "FC"), actual = fc - 1;
1315
+ for (; !input.isStacked && actual > 0 && values[actual].v === null; ) actual--;
1316
+ return {
1317
+ row,
1318
+ runs: rangedRuns,
1319
+ allPoints,
1320
+ interpolation,
1321
+ fcStart: forecastStart(series, input.cats),
1322
+ ...fc < 0 ? {} : { forecastX: input.xOfValue(fc === 0 ? range.lo : range.xs[actual]) },
1323
+ ...interpolation === "monotone" ? { monotoneByRun: new Map(rangedRuns.map((run, i) => [run, mapped[i][0].curve])) } : {},
1324
+ ...input.isStacked ? { bottomByRun: new Map(rangedRuns.map((run, i) => [run, { ...mapped[i][1], mode: interpolation }])) } : {}
1325
+ };
1326
+ }
1327
+ return {
1328
+ row,
1329
+ runs,
1330
+ allPoints,
1331
+ ...interpolation === "monotone" ? { monotoneByRun: new Map(runs.map((run) => [run, monotoneSegments(run)])) } : {},
1332
+ fcStart: forecastStart(series, input.cats),
1333
+ interpolation
1334
+ };
1335
+ }
1336
+ function splitAreaEdge(edge, x) {
1337
+ if (edge.curve) {
1338
+ let [before, after] = splitCurveSegmentsAtX(edge.curve, x);
1339
+ return [{ ...edge, curve: before }, { ...edge, curve: after }];
1340
+ }
1341
+ let index = edge.points.findIndex((point) => point.x >= x), to = edge.points[index];
1342
+ if (to.x === x)
1343
+ return [{ ...edge, points: edge.points.slice(0, index + 1) }, { ...edge, points: edge.points.slice(index) }];
1344
+ let from = edge.points[index - 1], y = edge.mode === "step-after" ? from.y : edge.mode === "step-before" ? to.y : from.y + (to.y - from.y) * ((x - from.x) / (to.x - from.x)), boundary = { x, y };
1345
+ return [
1346
+ { ...edge, points: [...edge.points.slice(0, index), boundary] },
1347
+ { ...edge, points: [boundary, ...edge.points.slice(index)] }
1348
+ ];
1349
+ }
1350
+ function closedAreaPath(upper, lower) {
1351
+ let top = upper.curve ? curvePathFromSegments(upper.curve) : pathFor(upper.points, upper.mode), end = lower.curve ? lower.curve[lower.curve.length - 1].to : lower.points[lower.points.length - 1], reverse = lower.curve ? [...lower.curve].reverse().map((segment) => `C${fmtPathNumber(segment.c2.x)} ${fmtPathNumber(segment.c2.y)} ${fmtPathNumber(segment.c1.x)} ${fmtPathNumber(segment.c1.y)} ${fmtPathNumber(segment.from.x)} ${fmtPathNumber(segment.from.y)}`).join("") : reversePathTail(lower.points, lower.mode);
1352
+ return `${top}L${fmtPathNumber(end.x)} ${fmtPathNumber(end.y)}${reverse}Z`;
1353
+ }
1354
+ function areaSections(upper, lower, forecastX) {
1355
+ let first = upper.points[0], last = upper.points[upper.points.length - 1];
1356
+ if (forecastX === void 0 || forecastX >= last.x) return [{ d: closedAreaPath(upper, lower), forecast: !1, upper, lower }];
1357
+ if (forecastX <= first.x) return [{ d: closedAreaPath(upper, lower), forecast: !0, upper, lower }];
1358
+ let [actualTop, forecastTop] = splitAreaEdge(upper, forecastX), [actualBottom, forecastBottom] = splitAreaEdge(lower, forecastX);
1359
+ return [
1360
+ { d: closedAreaPath(actualTop, actualBottom), forecast: !1, upper: actualTop, lower: actualBottom },
1361
+ { d: closedAreaPath(forecastTop, forecastBottom), forecast: !0, upper: forecastTop, lower: forecastBottom }
1362
+ ];
1363
+ }
1364
+ function edgePolyline(edge) {
1365
+ return edge.curve && edge.curve.length > 0 ? [edge.curve[0].from, ...edge.curve.flatMap((segment) => Array.from({ length: 16 }, (_, k) => cubicPoint(segment, (k + 1) / 16)))] : drawnStroke(edge.points, edge.mode);
1366
+ }
1367
+ function sideWalker(line) {
1368
+ let i = 1;
1369
+ return (x, side) => {
1370
+ if (x < line[0].x || x === line[0].x && side === "left") return line[0].y;
1371
+ for (; i < line.length && line[i].x < x; ) i++;
1372
+ let j = i;
1373
+ if (side === "right") for (; j < line.length && line[j].x <= x; ) j++;
1374
+ if (j >= line.length) return line[line.length - 1].y;
1375
+ let a = line[j - 1], b = line[j];
1376
+ return b.x === a.x ? b.y : a.y + (b.y - a.y) * (x - a.x) / (b.x - a.x);
1377
+ };
1378
+ }
1379
+ function areaInRect(top, bottom, rect) {
1380
+ let x0 = Math.max(top[0].x, bottom[0].x, rect.x), x1 = Math.min(top[top.length - 1].x, bottom[bottom.length - 1].x, rect.x + rect.w);
1381
+ if (!(x1 > x0)) return;
1382
+ let rows = [rect.y, rect.y + rect.h], crossings = (line) => line.flatMap((b, i) => {
1383
+ let a = line[i - 1];
1384
+ return a ? rows.flatMap((row) => (a.y - row) * (b.y - row) < 0 ? [a.x + (row - a.y) * (b.x - a.x) / (b.y - a.y)] : []) : [];
1385
+ }), sorted = (xs) => [...new Set(xs.filter((x) => x >= x0 && x <= x1))].sort((a, b) => a - b), breaks = sorted([x0, x1, ...top.map((p) => p.x), ...bottom.map((p) => p.x), ...crossings(top), ...crossings(bottom)]), [topA, bottomA] = [sideWalker(top), sideWalker(bottom)], gaps = breaks.map((x) => [topA(x, "left") - bottomA(x, "left"), topA(x, "right") - bottomA(x, "right")]), swaps = breaks.flatMap((p, i) => {
1386
+ let q = breaks[i + 1], gp = gaps[i][1], gq = gaps[i + 1]?.[0];
1387
+ return q !== void 0 && gq !== void 0 && gp * gq < 0 ? [p + (q - p) * gp / (gp - gq)] : [];
1388
+ }), clamp = (y) => Math.min(Math.max(y, rows[0]), rows[1]), [topB, bottomB] = [sideWalker(top), sideWalker(bottom)], upper = [], lower = [], open = !1;
1389
+ for (let x of sorted([...breaks, ...swaps]))
1390
+ for (let side of ["left", "right"]) {
1391
+ let t = topB(x, side), b = bottomB(x, side), u = { x, y: clamp(Math.min(t, b)) }, l = { x, y: clamp(Math.max(t, b)) };
1392
+ open ||= l.y - u.y > 0.01;
1393
+ let prevU = upper[upper.length - 1];
1394
+ (!prevU || prevU.x !== u.x || prevU.y !== u.y) && upper.push(u);
1395
+ let prevL = lower[lower.length - 1];
1396
+ (!prevL || prevL.x !== l.x || prevL.y !== l.y) && lower.push(l);
1397
+ }
1398
+ if (open)
1399
+ return { d: `${linePath(upper)}${[...lower].reverse().map((p) => `L${fmtPathNumber(p.x)} ${fmtPathNumber(p.y)}`).join("")}Z`, upper, lower };
1400
+ }
1401
+ function pieceHatchPath(upper, lower, gap) {
1402
+ let xs = [...new Set([...upper, ...lower].map((point) => point.x))].sort((a, b) => a - b), [up, low] = [sideWalker(upper), sideWalker(lower)];
1403
+ return xs.slice(0, -1).map((p, i) => {
1404
+ let q = xs[i + 1], stretch = (walk) => ({ points: [{ x: p, y: walk(p, "right") }, { x: q, y: walk(q, "left") }], mode: "linear" });
1405
+ return bandHatchPath(stretch(up), stretch(low), gap);
1406
+ }).join("");
1407
+ }
1408
+ var SHADING_OVER_FILL = 0.35;
1409
+ function shadingOverFills(shading, outlines, hatch) {
1410
+ return outlines.flatMap((outline, k) => {
1411
+ let piece = areaInRect(outline.top, outline.bottom, shading.rect);
1412
+ if (!piece) return [];
1413
+ let fill = mixedPaint(shading.fill, outline.paint, SHADING_OVER_FILL, "token" in outline.paint ? outline.paint.token : "background"), patterned = outline.forecast && !outline.stacked, node = { t: "path", id: `${shading.id}:over:${k}`, d: piece.d, fill, ...patterned ? { pattern: "hatch45" } : {}, owner: shading.owner, part: "shadingOverFill" };
1414
+ if (patterned || shading.pattern !== "hatch45" && !outline.forecast) return [node];
1415
+ let stripes = pieceHatchPath(piece.upper, piece.lower, hatch.gap);
1416
+ return stripes ? [node, {
1417
+ t: "path",
1418
+ id: `${shading.id}:over:${k}:hatch`,
1419
+ d: stripes,
1420
+ stroke: mixedPaint({ token: "background" }, fill, hatch.share, "token" in outline.paint ? outline.paint.token : "background"),
1421
+ width: hatch.width,
1422
+ owner: shading.owner,
1423
+ part: "shadingOverFill"
1424
+ }] : [node];
1425
+ });
1426
+ }
1427
+ function withoutEvents(annotations) {
1428
+ return annotations.filter((annotation) => annotation.kind !== "event");
1429
+ }
1430
+ function fillShadingKinds(annotations) {
1431
+ let kinds = /* @__PURE__ */ new Map();
1432
+ return annotations.forEach((annotation, index) => {
1433
+ let id = defaultAnnotationId(annotation, index);
1434
+ if (annotation.kind === "valueLine") kinds.set(id, "value");
1435
+ else {
1436
+ if (annotation.kind !== "band") return;
1437
+ annotation.style === "corridor" || annotation.style === "tolerance" || annotation.style === "attainment" ? kinds.set(id, "value") : (annotation.style ?? "shade") === "shade" && kinds.set(id, "era");
1438
+ }
1439
+ }), kinds;
1440
+ }
1441
+ function shadesFills(annotations) {
1442
+ return annotations.some((annotation) => annotation.kind === "band" && (annotation.style === "corridor" || annotation.style === "tolerance" || annotation.style === "attainment") || annotation.kind === "valueLine" && (annotation.tolerance !== void 0 || annotation.attainment !== void 0 && annotation.attainment !== !1));
1443
+ }
1444
+ function fillShadings(nodes, outlines, kinds, plot, ruleWidth, hatch) {
1445
+ let kindOf = (node) => node.t === "rect" && (node.part === "band" || node.part === "attainment") && !("token" in node.fill && node.fill.token === "background") ? kinds.get(node.owner.annotationId ?? "") : void 0, shadings = nodes.filter((node) => kindOf(node) === "value"), over = shadings.flatMap((node) => shadingOverFills(node, outlines, hatch)), grounds = shadings.flatMap((node) => outlines.flatMap((outline, k) => {
1446
+ let mix = over.find((piece) => piece.id === `${node.id}:over:${k}`);
1447
+ return mix && mix.t === "path" && mix.fill ? [{ seriesId: outline.seriesId, rect: node.rect, paint: mix.fill, ...mix.pattern === "hatch45" ? { pattern: "hatch45" } : {} }] : [];
1448
+ })), edges = nodes.filter((node) => kindOf(node) === "era").flatMap((node) => {
1449
+ let { x, y: top, w, h } = node.rect;
1450
+ return [x, x + w].filter((at) => at > plot.x + 0.5 && at < plot.x + plot.w - 0.5).map((at, k) => ({
1451
+ t: "line",
1452
+ id: `${node.id}:edge:${k}`,
1453
+ x1: at,
1454
+ y1: top,
1455
+ x2: at,
1456
+ y2: top + h,
1457
+ stroke: { token: "background" },
1458
+ width: ruleWidth,
1459
+ owner: node.owner,
1460
+ part: "bandEdge"
1461
+ }));
1462
+ });
1463
+ return { nodes: [...over, ...edges], grounds };
1464
+ }
1465
+ function regroundOnShadings(labels, grounds) {
1466
+ if (grounds.length !== 0)
1467
+ for (let label of labels) {
1468
+ let ink = label.ink;
1469
+ if (!("token" in ink) || ink.theme?.kind !== "contrast-ink" || label.owner.seriesId === void 0) continue;
1470
+ let { rect } = label, share = (ground) => {
1471
+ let w = Math.min(rect.x + rect.w, ground.rect.x + ground.rect.w) - Math.max(rect.x, ground.rect.x), h = Math.min(rect.y + rect.h, ground.rect.y + ground.rect.h) - Math.max(rect.y, ground.rect.y);
1472
+ return w > 0 && h > 0 ? w * h / Math.max(rect.w * rect.h, 1e-9) : 0;
1473
+ }, touched = grounds.filter((candidate) => candidate.seriesId === label.owner.seriesId && share(candidate) > 0), whole = touched.find((candidate) => share(candidate) > 0.999);
1474
+ whole ? label.ink = { ...ink, theme: { kind: "contrast-ink", fill: whole.paint, ...whole.pattern ? { pattern: whole.pattern } : {} } } : touched.length > 0 && (label.ink = { ...ink, theme: { ...ink.theme, also: touched.map((ground) => ground.paint) } });
1475
+ }
1476
+ }
1477
+ function bandHatchPath(upper, lower, gap) {
1478
+ let top = edgePolyline(upper), bottom = edgePolyline(lower);
1479
+ top.some((point) => point.y > polylineYAt2(bottom, point.x)) && ([top, bottom] = [bottom, top]);
1480
+ let x0 = Math.max(top[0].x, bottom[0].x), x1 = Math.min(top[top.length - 1].x, bottom[bottom.length - 1].x);
1481
+ if (!(x1 > x0)) return "";
1482
+ let breaks = [.../* @__PURE__ */ new Set([x0, x1, ...[...top, ...bottom].map((p) => p.x).filter((x) => x > x0 && x < x1)])].sort((a, b) => a - b), step = gap * Math.SQRT2, sums = breaks.flatMap((x) => [x + polylineYAt2(top, x), x + polylineYAt2(bottom, x)]), d = "";
1483
+ for (let c = Math.ceil(minOf(sums) / step) * step; c <= maxOf(sums); c += step) {
1484
+ let open, close, flush = () => {
1485
+ open !== void 0 && close !== void 0 && close - open > 0.01 && (d += `M${fmtPathNumber(open)} ${fmtPathNumber(c - open)}L${fmtPathNumber(close)} ${fmtPathNumber(c - close)}`), open = void 0, close = void 0;
1486
+ };
1487
+ for (let i = 0; i + 1 < breaks.length; i++) {
1488
+ let p = breaks[i], q = breaks[i + 1], over = (x) => c - x - polylineYAt2(top, x), under = (x) => polylineYAt2(bottom, x) - (c - x), lo = p, hi = q;
1489
+ for (let f of [over, under]) {
1490
+ let fp = f(p), fq = f(q);
1491
+ if (fp < 0 && fq < 0) {
1492
+ lo = 1 / 0;
1493
+ break;
1494
+ }
1495
+ if (fp < 0 || fq < 0) {
1496
+ let root = p + (q - p) * fp / (fp - fq);
1497
+ fp < 0 ? lo = Math.max(lo, root) : hi = Math.min(hi, root);
1498
+ }
1499
+ }
1500
+ if (lo >= hi) {
1501
+ flush();
1502
+ continue;
1503
+ }
1504
+ open !== void 0 && close !== void 0 && Math.abs(close - lo) < 1e-6 || (flush(), open = lo), close = hi;
1505
+ }
1506
+ flush();
1507
+ }
1508
+ return d;
1509
+ }
1510
+ function renderArea(input, series, dataIdx, entry, geometry, claims, paintedAreaCats, outlines) {
1511
+ if (input.isArea && input.isStacked && renderIsolatedStacks(input, series, dataIdx, entry, geometry, paintedAreaCats), !input.areaFilled(series) || !geometry.runs.some((run) => run.length >= 2)) return;
1512
+ let bottomAt = (ci) => input.isStacked ? input.y(input.cumBot[dataIdx][ci]) : input.baseY, fillRuns = !input.range && series.interpolateGaps && geometry.interpolation === "linear" && !input.hasSuppressed100 ? [geometry.allPoints] : geometry.runs.filter((run) => run.length >= 2), painted = paintedAreaCats.get(series.id) ?? /* @__PURE__ */ new Set();
1513
+ paintedAreaCats.set(series.id, painted);
1514
+ let forecastX = geometry.forecastX ?? (geometry.fcStart < 0 ? void 0 : geometry.fcStart === 0 ? input.xOf(0) : forecastBoundaryX({ categoryIndex: geometry.fcStart, lastActualIndex: lastActualIndex(series, geometry.fcStart, input.isStacked) }, input.xOf, "point"));
1515
+ fillRuns.forEach((run, runIndex) => {
1516
+ for (let point of run) painted.add(point.ci);
1517
+ let upper = { points: run, mode: geometry.interpolation, curve: geometry.monotoneByRun?.get(run) }, lower = geometry.bottomByRun?.get(run)?.points ?? run.map((point) => ({ x: point.x, y: bottomAt(point.ci) })), lowerMode = input.isStacked ? geometry.interpolation : "linear", lowerEdge = geometry.bottomByRun?.get(run) ?? { points: lower, mode: lowerMode, ...lowerMode === "monotone" ? { curve: monotoneSegments(lower) } : {} }, id = `mark:area:${series.id}${runIndex === 0 ? "" : `:${runIndex}`}`;
1518
+ areaSections(upper, lowerEdge, forecastX).forEach((section, index) => {
1519
+ let overlay = section.forecast && input.isStacked && input.hatch !== void 0, areaPaint = input.areaFillPaint(series, dataIdx, section.forecast), sep = section.forecast ? void 0 : othersSeparation(areaPaint, input.theme);
1520
+ outlines.push({ id: index === 0 ? id : `${id}:fc`, seriesId: series.id, top: edgePolyline(section.upper), bottom: edgePolyline(section.lower), paint: areaPaint, forecast: section.forecast, ...input.isStacked ? { stacked: !0 } : {} }), input.nodes.push({ t: "path", id: index === 0 ? id : `${id}:fc`, d: section.d, fill: areaPaint, ...section.forecast && !overlay ? { pattern: "hatch45" } : {}, ...sep ? { stroke: sep.stroke, width: sep.strokeWidth } : {}, ...!section.forecast && isOthersFill(areaPaint) ? { separation: { fill: areaPaint, backing: { token: "background" } } } : {}, owner: { seriesId: series.id }, part: "area" });
1521
+ let hatch = overlay ? bandHatchPath(section.upper, section.lower, input.hatch.gap) : "";
1522
+ hatch && input.nodes.push({ t: "path", id: `${id}:fc:hatch`, d: hatch, stroke: mixedPaint({ token: "background" }, areaPaint, input.hatch.share, "token" in areaPaint ? areaPaint.token : "background"), width: input.hatch.width, owner: { seriesId: series.id }, part: "forecastHatch" });
1523
+ }), entry.areaNodeId || (entry.areaNodeId = id);
1524
+ for (let index = 0; index + 1 < run.length; index++) {
1525
+ let from = run[index], to = run[index + 1];
1526
+ if (geometry.interpolation === "monotone") {
1527
+ let top = Math.min(from.y, to.y, lower[index].y, lower[index + 1].y), bottom = Math.max(from.y, to.y, lower[index].y, lower[index + 1].y);
1528
+ input.occupied.claim({ x: from.x, y: top, w: to.x - from.x, h: Math.max(bottom - top, 1) }, "mark", claims.lineOwner(series.id, input.cats[from.ci].id), AREA_FILL_PART);
1529
+ } else claims.areaPair(from.x, to.x, from.y, to.y, lower[index].y, lower[index + 1].y, input.cats[from.ci].id, input.cats[to.ci].id, series.id, geometry.interpolation);
1530
+ }
1531
+ });
1532
+ }
1533
+ function emitLinePath(input, series, dataIdx, entry, geometry, claims, run, runIndex, points, curve, dashed, solidHasPath) {
1534
+ if (geometry.monotoneByRun ? curve.length === 0 : points.length < 2) return;
1535
+ let id = `mark:line:${series.id}:${runIndex}${dashed ? ":fc" : ""}`, separator = input.isArea && input.isStacked && input.hatch !== void 0, dash = separator ? void 0 : dashed ? dashToken(input.theme, "reference") : input.dashOf(series, dataIdx), path = geometry.monotoneByRun ? curvePathFromSegments(curve) : pathFor(points, geometry.interpolation), filled = input.areaFilled(series);
1536
+ if (filled || input.nodes.push({ t: "path", id: `casing:${id}`, d: path, stroke: { token: "background" }, width: strokeToken(input.theme, "casing"), owner: { seriesId: series.id }, part: "lineCasing" }), input.nodes.push({ t: "path", id, d: path, stroke: separator ? { token: "background" } : dashed ? input.forecastLinePaint(series, dataIdx) : input.seriesPaint(series, dataIdx), width: separator ? strokeToken(input.theme, "rule") : input.lineWidthOf(series), ...dash ? { dash, lineCap: dash.join(",") === dashToken(input.theme, "dotted").join(",") ? "round" : "butt" } : {}, owner: { seriesId: series.id }, part: "line" }), input.lineHollowOf(series) && input.nodes.push({
1537
+ t: "path",
1538
+ id: `${id}:inner`,
1539
+ d: path,
1540
+ stroke: { token: "background" },
1541
+ width: strokeToken(input.theme, "hair"),
1542
+ ...dash ? { dash, lineCap: dash.join(",") === dashToken(input.theme, "dotted").join(",") ? "round" : "butt" } : {},
1543
+ owner: { seriesId: series.id },
1544
+ part: "lineInterior"
1545
+ }), dashed && !entry.fcPathNodeId && (entry.fcPathNodeId = id), !dashed && !entry.pathNodeId && (entry.pathNodeId = id), dashed && !entry.pathNodeId && !solidHasPath && (entry.pathNodeId = id), !filled)
1546
+ if (geometry.monotoneByRun) claims.monotoneRun(run, curve, series.id);
1547
+ else for (let index = 0; index + 1 < points.length; index++) claims.linePair(points[index], points[index + 1], input.cats[points[index].ci].id, input.cats[points[index + 1].ci].id, series.id, geometry.interpolation);
1548
+ }
1549
+ function renderIsolatedStacks(input, series, dataIdx, entry, geometry, paintedAreaCats) {
1550
+ let lone = geometry.runs.filter((run) => run.length === 1).map((run) => run[0]);
1551
+ if (lone.length === 0 || geometry.interpolation === "linear" && !input.hasSuppressed100 && geometry.allPoints.length >= 2) return;
1552
+ let painted = paintedAreaCats.get(series.id) ?? /* @__PURE__ */ new Set();
1553
+ paintedAreaCats.set(series.id, painted);
1554
+ let w = 32;
1555
+ for (let point of lone) {
1556
+ let top = input.y(input.cumTop[dataIdx][point.ci]), bottom = input.y(input.cumBot[dataIdx][point.ci]);
1557
+ if (!(bottom - top > 0)) continue;
1558
+ painted.add(point.ci);
1559
+ let rect = { x: Math.max(input.plot.x, Math.min(point.x - w / 2, input.plot.x + input.plot.w - w)), y: top, w, h: bottom - top }, owner = { seriesId: series.id, categoryId: input.cats[point.ci].id }, id = `mark:stack:${series.id}:${owner.categoryId}`, fill = input.areaFillPaint(series, dataIdx, !1), sep = othersSeparation(fill, input.theme);
1560
+ input.nodes.push({ t: "rect", id, rect, fill, ...sep ? { stroke: sep.stroke, strokeWidth: sep.strokeWidth } : {}, ...isOthersFill(fill) ? { separation: { fill, backing: { token: "background" } } } : {}, owner, part: "segment" }), entry.areaNodeId || (entry.areaNodeId = id), input.occupied.claim(rect, "mark", owner);
1561
+ }
1562
+ }
1563
+ function renderLinePaths(input, series, dataIdx, entry, geometry, claims) {
1564
+ input.variant !== "stacked100-area" && geometry.runs.forEach((run, runIndex) => {
1565
+ if (run.length < 2) return;
1566
+ let solidPoints = run, fcPoints = [], solidCurve = geometry.monotoneByRun?.get(run) ?? [], fcCurve = [];
1567
+ if (input.range && geometry.forecastX !== void 0) {
1568
+ let edge = { points: run, ...geometry.monotoneByRun ? { curve: solidCurve } : {} }, before = cutEdge(edge, geometry.interpolation, -1 / 0, geometry.forecastX), after = cutEdge(edge, geometry.interpolation, geometry.forecastX, 1 / 0);
1569
+ solidPoints = before.points, fcPoints = after.points, solidCurve = before.curve ?? [], fcCurve = after.curve ?? [];
1570
+ } else if (geometry.fcStart !== -1) {
1571
+ let splitAt = run.findIndex((point) => point.ci >= geometry.fcStart);
1572
+ splitAt === 0 ? (solidPoints = [], fcPoints = run, fcCurve = solidCurve, solidCurve = []) : splitAt > 0 && (solidPoints = run.slice(0, splitAt), fcPoints = run.slice(splitAt - 1), geometry.monotoneByRun && ([solidCurve, fcCurve] = splitCurveSegmentsAtX(solidCurve, run[splitAt - 1].x)));
1573
+ }
1574
+ let solidHasPath = geometry.monotoneByRun ? solidCurve.length > 0 : solidPoints.length >= 2;
1575
+ emitLinePath(input, series, dataIdx, entry, geometry, claims, run, runIndex, solidPoints, solidCurve, !1, solidHasPath), emitLinePath(input, series, dataIdx, entry, geometry, claims, run, runIndex, fcPoints, fcCurve, !0, solidHasPath), !input.areaFilled(series) && series.interpolateGaps && markBridgedGaps(input, series, dataIdx, geometry, run, runIndex);
1576
+ });
1577
+ }
1578
+ function markBridgedGaps(input, series, dataIdx, geometry, run, runIndex) {
1579
+ let curve = geometry.monotoneByRun?.get(run), paint = series.role === "reference" ? input.refPaintOf(series) : input.seriesPaint(series, dataIdx), width = series.role === "reference" ? strokeToken(input.theme, "rule") : input.lineWidthOf(series);
1580
+ for (let k = 0; k + 1 < run.length; k++) {
1581
+ let [a, b] = [run[k], run[k + 1]];
1582
+ if (b.ci - a.ci < 2) continue;
1583
+ let segment = curve?.[k], d = segment ? curvePathFromSegments([segment]) : pathFor([a, b], geometry.interpolation), id = `bridge:${series.id}:${runIndex}:${a.ci}`;
1584
+ input.nodes.push({ t: "path", id: `${id}:erase`, d, stroke: { token: "background" }, width: strokeToken(input.theme, "casing"), owner: { seriesId: series.id }, part: "lineCasing" }), input.nodes.push({ t: "path", id, d, stroke: paint, width, dash: dashToken(input.theme, "reference"), owner: { seriesId: series.id }, part: "gapBridge" });
1585
+ for (let ci = a.ci + 1; ci < b.ci; ci++) {
1586
+ let x = input.xOf(ci), t = (x - a.x) / (b.x - a.x), y = segment ? cubicPoint(segment, t).y : geometry.interpolation === "step-after" ? a.y : geometry.interpolation === "step-before" ? b.y : a.y + (b.y - a.y) * t;
1587
+ input.nodes.push(gapMarkerNode(input.theme, { id: `gap:${series.id}:${input.cats[ci].id}`, x, y, ink: paint, owner: { seriesId: series.id, categoryId: input.cats[ci].id } }));
1588
+ }
1589
+ }
1590
+ }
1591
+ function markerDisplay(input, series, row, ci) {
1592
+ let cell = series.vals[ci];
1593
+ return {
1594
+ value: input.rebased ? input.fmt(row[ci]) : cell.isPct ? cell.format ? input.seriesFmt({ ...series, format: cell.format })(cell.v) : input.authoredPctFmt(cell.v) : input.variant === "stacked100-area" ? input.shareTexts.get(`${input.cats[ci].id}\0${series.id}`) ?? input.pctFmt(row[ci]) : input.seriesFmt(cell.format ? { ...series, format: cell.format } : series)(input.absOf(series, ci)),
1595
+ ...input.bumpPointState(row, ci)
1596
+ };
1597
+ }
1598
+ function pushMarkerNode(input, series, dataIdx, row, point, shape, id) {
1599
+ let stroke = series.role === "reference" ? input.refPaintOf(series) : input.seriesPaint(series, dataIdx), hollow = input.hollowAt(series, point.ci), fill = hollow ? { token: "background" } : stroke, owner = { seriesId: series.id, categoryId: input.cats[point.ci].id }, display = markerDisplay(input, series, row, point.ci);
1600
+ shape === "circle" ? input.nodes.push({ t: "circle", id, cx: point.x, cy: point.y, r: 3, fill, ...hollow ? { stroke } : {}, owner, part: "marker", display }) : shape === "square" ? input.nodes.push({ t: "rect", id, rect: { x: point.x - 3, y: point.y - 3, w: 6, h: 6 }, fill, ...hollow ? { stroke, strokeWidth: strokeToken(input.theme, "mark") } : {}, owner, part: "marker", display }) : shape !== "none" && input.nodes.push({ t: "path", id, d: markerPath(shape, point), fill, ...hollow ? { stroke, width: strokeToken(input.theme, "mark") } : {}, owner, part: "marker", display });
1601
+ }
1602
+ function markerPath(shape, point) {
1603
+ return shape === "triangle" ? `M${fmtPathNumber(point.x)} ${fmtPathNumber(point.y - 3.5)}L${fmtPathNumber(point.x + 3.5)} ${fmtPathNumber(point.y + 3)}L${fmtPathNumber(point.x - 3.5)} ${fmtPathNumber(point.y + 3)}Z` : `M${fmtPathNumber(point.x)} ${fmtPathNumber(point.y - 4)}L${fmtPathNumber(point.x + 4)} ${fmtPathNumber(point.y)}L${fmtPathNumber(point.x)} ${fmtPathNumber(point.y + 4)}L${fmtPathNumber(point.x - 4)} ${fmtPathNumber(point.y)}Z`;
1604
+ }
1605
+ function renderMarkers(input, series, dataIdx, entry, geometry, claims) {
1606
+ geometry.allPoints.forEach((point) => {
1607
+ let shape = input.markerOf(series, dataIdx, point.ci);
1608
+ if (input.isStacked && geometry.row[point.ci] === null) {
1609
+ entry.points.push({ categoryId: input.cats[point.ci].id, x: point.x, y: point.y });
1610
+ return;
1611
+ }
1612
+ let nodeId;
1613
+ shape !== "none" && (nodeId = `marker:${series.id}:${input.cats[point.ci].id}`, pushMarkerNode(input, series, dataIdx, geometry.row, point, shape, nodeId), input.occupied.claim({ x: point.x - 4, y: point.y - 4, w: 8, h: 8 }, "mark", claims.lineOwner(series.id, input.cats[point.ci].id))), entry.points.push({ categoryId: input.cats[point.ci].id, x: point.x, y: point.y, ...nodeId ? { nodeId } : {} });
1614
+ });
1615
+ }
1616
+ function renderSeries(input, series, dataIdx, marks, paintedAreaCats, claims, outlines) {
1617
+ let entry = { seriesId: series.id, points: [] }, geometry = buildSeriesGeometry(input, series, dataIdx);
1618
+ return renderArea(input, series, dataIdx, entry, geometry, claims, paintedAreaCats, outlines), renderLinePaths(input, series, dataIdx, entry, geometry, claims), renderMarkers(input, series, dataIdx, entry, geometry, claims), renderLatestPointRing(input, series, geometry, claims), marks.series.push(entry), geometry;
1619
+ }
1620
+ var LATEST_RING_R = 4.5, LATEST_DOT_R = 2, latestRingReach = (theme) => LATEST_RING_R + strokeToken(theme, "mark") / 2;
1621
+ function renderLatestPointRing(input, series, geometry, claims) {
1622
+ if (input.latestPointSeries === void 0 || input.latestPointSeries !== series.id) return;
1623
+ let observed = geometry.allPoints.filter((point2) => geometry.row[point2.ci] !== null), point = observed[observed.length - 1];
1624
+ if (point === void 0) return;
1625
+ let categoryId = input.cats[point.ci].id, owner = { seriesId: series.id, categoryId }, display = markerDisplay(input, series, geometry.row, point.ci);
1626
+ input.nodes.push({
1627
+ t: "circle",
1628
+ id: `latest-ring:${series.id}`,
1629
+ cx: point.x,
1630
+ cy: point.y,
1631
+ r: LATEST_RING_R,
1632
+ fill: { token: "background" },
1633
+ stroke: { token: "highlight" },
1634
+ strokeWidth: strokeToken(input.theme, "mark"),
1635
+ owner,
1636
+ part: "marker",
1637
+ display
1638
+ }), input.nodes.push({
1639
+ t: "circle",
1640
+ id: `latest-dot:${series.id}`,
1641
+ cx: point.x,
1642
+ cy: point.y,
1643
+ r: LATEST_DOT_R,
1644
+ fill: { token: "markInk" },
1645
+ owner,
1646
+ part: "marker",
1647
+ display
1648
+ }), input.occupied.claim(
1649
+ { x: point.x - latestRingReach(input.theme), y: point.y - latestRingReach(input.theme), w: latestRingReach(input.theme) * 2, h: latestRingReach(input.theme) * 2 },
1650
+ "mark",
1651
+ claims.lineOwner(series.id, categoryId)
1652
+ );
1653
+ }
1654
+ function renderAreaSeparators(input, geometries, paintedAreaCats) {
1655
+ input.variant === "stacked100-area" && input.drawnSeries.slice(0, -1).forEach((series, index) => {
1656
+ let geometry = geometries[index], next = input.drawnSeries[index + 1];
1657
+ if (geometry.interpolation !== geometries[index + 1].interpolation) return;
1658
+ let painted = (band, ci, cj) => input.cumTop[band][ci] !== input.cumBot[band][ci] || input.cumTop[band][cj] !== input.cumBot[band][cj];
1659
+ geometry.runs.forEach((run, runIndex) => {
1660
+ let start = 0, emit = (end) => {
1661
+ if (end <= start) return;
1662
+ let curve = geometry.monotoneByRun?.get(run)?.slice(start, end), d = curve ? curvePathFromSegments(curve) : pathFor(run.slice(start, end + 1), geometry.interpolation);
1663
+ input.nodes.push({
1664
+ t: "path",
1665
+ id: `area-separator:${series.id}:${runIndex}:${start}`,
1666
+ d,
1667
+ stroke: { token: "background" },
1668
+ width: strokeToken(input.theme, "rule"),
1669
+ owner: { seriesId: series.id },
1670
+ part: "areaSeparator"
1671
+ });
1672
+ };
1673
+ for (let pointIndex = 0; pointIndex + 1 < run.length; pointIndex++) {
1674
+ let from = run[pointIndex].ci, to = run[pointIndex + 1].ci;
1675
+ [series.id, next.id].every((id) => paintedAreaCats.get(id)?.has(from) && paintedAreaCats.get(id)?.has(to)) && painted(index, from, to) && painted(index + 1, from, to) || (emit(pointIndex), start = pointIndex + 1);
1676
+ }
1677
+ emit(run.length - 1);
1678
+ });
1679
+ });
1680
+ }
1681
+ function renderInvalidComposition(input) {
1682
+ input.variant === "stacked100-area" && input.cats.forEach((category, ci) => {
1683
+ let glyph = input.nmCats100.has(category.id) ? NOT_MEANINGFUL : input.naCats100.has(category.id) ? input.naGlyph : null;
1684
+ if (!glyph) return;
1685
+ let size = input.measure(glyph, input.labelFont), x = input.xOf(ci), rect = { x: x - size.width / 2, y: input.baseY - size.height - 6, w: size.width, h: size.height };
1686
+ input.nodes.push({ t: "text", id: `nm:${category.id}`, x, y: rect.y, lines: [glyph], align: "middle", typeRole: "label", font: input.labelFont, ink: { token: "inkMuted" }, owner: { categoryId: category.id }, part: "nmMarker", display: { state: input.nmCats100.has(category.id) ? NOT_MEANINGFUL : NOT_AVAILABLE } }), input.occupied.claim(rect, "label", { categoryId: category.id });
1687
+ });
1688
+ }
1689
+ function renderReferences(input, claims) {
1690
+ input.refSeries.forEach((series) => {
1691
+ let geometry = buildSeriesGeometry({ ...input, isStacked: !1 }, series, 0), { interpolation, runs } = geometry;
1692
+ runs.forEach((points, runIndex) => {
1693
+ if (points.length === 1) {
1694
+ let point = points[0], categoryId = input.cats[point.ci].id, shape = input.markerOf(series, 0, point.ci);
1695
+ pushMarkerNode(input, series, 0, geometry.row, point, shape === "none" ? "circle" : shape, `marker:${series.id}:${categoryId}`), input.occupied.claim({ x: point.x - 4, y: point.y - 4, w: 8, h: 8 }, "mark", claims.lineOwner(series.id, categoryId));
1696
+ return;
1697
+ }
1698
+ if (points.length < 2) return;
1699
+ let curve = geometry.monotoneByRun?.get(points) ?? [];
1700
+ if (input.nodes.push({ t: "path", id: `ref:${series.id}${runIndex === 0 ? "" : `:${runIndex}`}`, d: interpolation === "monotone" ? curvePathFromSegments(curve) : pathFor(points, interpolation), stroke: input.refPaintOf(series), width: strokeToken(input.theme, "rule"), dash: dashToken(input.theme, "reference"), owner: { seriesId: series.id }, part: "referenceLine" }), interpolation === "monotone") claims.monotoneRun(points, curve, series.id);
1701
+ else for (let index = 0; index + 1 < points.length; index++) claims.linePair(points[index], points[index + 1], input.cats[points[index].ci].id, input.cats[points[index + 1].ci].id, series.id, interpolation);
1702
+ series.interpolateGaps && markBridgedGaps(input, series, 0, geometry, points, runIndex);
1703
+ });
1704
+ });
1705
+ }
1706
+ function renderLineMarks(input) {
1707
+ let analyticalSceneStart = input.nodes.length, baselineId = "axis:baseline";
1708
+ input.nodes.push({ t: "line", id: baselineId, x1: input.plot.x, y1: input.baseY, x2: input.plot.x + input.plot.w, y2: input.baseY, stroke: { token: "axis" }, width: strokeToken(input.theme, "rule"), owner: {}, part: "baseline" }), input.occupied.claim({ x: input.plot.x, y: input.baseY - 1, w: input.plot.w, h: 2 }, "axis", {});
1709
+ let marks = { series: [] }, paintedAreaCats = /* @__PURE__ */ new Map(), claims = createClaims(input.occupied, input.cats, input.inlineNamesEnabled), seriesStart = input.nodes.length, areaOutlines = [], geometries = input.drawnSeries.map((series, dataIdx) => renderSeries(input, series, dataIdx, marks, paintedAreaCats, claims, areaOutlines));
1710
+ if (!input.isStacked) {
1711
+ let highlight = new Set(input.drawnSeries.filter((series) => series.colorRole === "highlight" || input.highlights.has(series.id)).map((series) => series.id)), ink = input.nodes.splice(seriesStart), fill = (node) => node.part === "area" || node.part === "forecastHatch", raised = (node) => highlight.has(node.owner.seriesId) && (node.id.startsWith("mark:line:") || node.id.startsWith("casing:mark:line:") || node.part === "marker");
1712
+ pushAll(input.nodes, ink.filter(fill)), pushAll(input.nodes, ink.filter((node) => !fill(node) && !raised(node))), pushAll(input.nodes, ink.filter(raised));
1713
+ }
1714
+ renderAreaSeparators(input, geometries, paintedAreaCats), renderBumpTies(input.theme, { bump: input.bump, marks, nodes: input.nodes, occupied: input.occupied });
1715
+ for (let series of input.bumpOmitted ?? []) {
1716
+ let row = input.pv[input.rowOf.get(series)];
1717
+ marks.series.push({ seriesId: series.id, points: row.flatMap((rank, ci) => rank === null ? [] : [{ categoryId: input.cats[ci].id, x: input.xOf(ci), y: input.y(rank) }]) });
1718
+ }
1719
+ renderInvalidComposition(input), renderReferences(input, claims);
1720
+ let rangeEdges = input.range ? new Map(input.drawnSeries.map((series, i) => {
1721
+ let geometry = geometries[i];
1722
+ return [series.id, {
1723
+ runs: geometry.runs.map((run) => edgePolyline({ points: run, mode: geometry.interpolation, curve: geometry.monotoneByRun?.get(run) })),
1724
+ ...geometry.bottomByRun ? { bottom: geometry.runs.flatMap((run) => edgePolyline(geometry.bottomByRun.get(run))) } : {}
1725
+ }];
1726
+ })) : void 0;
1727
+ return { marks, baselineId, analyticalSceneStart, paintedAreaCats, areaOutlines, ...rangeEdges ? { rangeEdges } : {} };
1728
+ }
1729
+ function linearYAt(points, x) {
1730
+ if (points.length === 0) throw new Error("linearYAt on an empty run");
1731
+ if (points.length === 1 || x <= points[0].x) return points[0].y;
1732
+ if (x >= points[points.length - 1].x) return points[points.length - 1].y;
1733
+ let index = 0;
1734
+ for (; index < points.length - 2 && points[index + 1].x < x; ) index++;
1735
+ let from = points[index], to = points[index + 1];
1736
+ return from.y + (to.y - from.y) * ((x - from.x) / (to.x - from.x));
1737
+ }
1738
+ function sliceCurve(segment, fromT, toT) {
1739
+ if (fromT <= 0 && toT >= 1) return segment;
1740
+ let right = fromT <= 0 ? segment : splitCurve(segment, fromT)[1], normalizedTo = fromT >= 1 ? 1 : (toT - fromT) / (1 - fromT);
1741
+ return normalizedTo >= 1 ? right : splitCurve(right, normalizedTo)[0];
1742
+ }
1743
+ function monotonePathBetween(points, start, end) {
1744
+ let pieces = monotoneSegments(points).flatMap((segment) => {
1745
+ if (segment.to.x <= start.x || segment.from.x >= end.x) return [];
1746
+ let span = segment.to.x - segment.from.x, fromT = Math.max(0, (start.x - segment.from.x) / span), toT = Math.min(1, (end.x - segment.from.x) / span);
1747
+ return toT > fromT ? [sliceCurve(segment, fromT, toT)] : [];
1748
+ });
1749
+ return pieces.length === 0 ? `M${fmtPathNumber(start.x)} ${fmtPathNumber(start.y)}` : (pieces[0] = { ...pieces[0], from: { x: start.x, y: start.y } }, pieces[pieces.length - 1] = { ...pieces[pieces.length - 1], to: { x: end.x, y: end.y } }, `M${fmtPathNumber(start.x)} ${fmtPathNumber(start.y)}${pieces.map((segment) => `C${fmtPathNumber(segment.c1.x)} ${fmtPathNumber(segment.c1.y)} ${fmtPathNumber(segment.c2.x)} ${fmtPathNumber(segment.c2.y)} ${fmtPathNumber(segment.to.x)} ${fmtPathNumber(segment.to.y)}`).join("")}`);
1750
+ }
1751
+ function phaseBoundaries(phases, row, cats, xOf, y, forecast) {
1752
+ let values = cats.map((_, ci) => ({ x: xOf(ci), y: row[ci] })), curvePoints = values.map((point) => ({ x: point.x, y: y(point.y) })), internal = phases.phases.slice(1).map((phase, index) => {
1753
+ let leftIndex = cats.findIndex((category) => category.id === phases.phases[index].to), rightIndex = cats.findIndex((category) => category.id === phase.from), split = forecast.find((boundary) => boundary.categoryIndex === rightIndex), x = split ? forecastBoundaryX(split, xOf, "point") : (xOf(leftIndex) + xOf(rightIndex)) / 2, value = phases.interpolation === "monotone" ? monotoneYAt(values, x) : linearYAt(values, x);
1754
+ return { x, y: y(value), value, leftCategoryId: cats[leftIndex].id, rightCategoryId: cats[rightIndex].id };
1755
+ }), boundaries = [
1756
+ { x: values[0].x, y: curvePoints[0].y, value: values[0].y, leftCategoryId: cats[0].id, rightCategoryId: cats[0].id },
1757
+ ...internal,
1758
+ { x: values[values.length - 1].x, y: curvePoints[curvePoints.length - 1].y, value: values[values.length - 1].y, leftCategoryId: cats[cats.length - 1].id, rightCategoryId: cats[cats.length - 1].id }
1759
+ ], derived = { seriesId: phases.series.id, interpolation: phases.interpolation, pointwiseExact: !0, boundaries: internal.map(({ x, y: boundaryY, leftCategoryId, rightCategoryId }) => ({ x, y: boundaryY, leftCategoryId, rightCategoryId })) };
1760
+ return { curvePoints, boundaries, derived };
1761
+ }
1762
+ function rangePhaseSpans(phases, range, row, cats, xOfValue, y) {
1763
+ let edge = rangeRuns(range, [row], phases.interpolation)[0][0], authored = phases.authored ?? phases.phases, source = new Map(range.categories.map((category, index) => [category.id, index])), values = range.values.get(phases.series.id), fc = phases.series.scenario === "FC" ? 0 : values.findIndex((value) => value.scenario === "FC"), splits = authored.slice(1).map((phase, index) => {
1764
+ let left = source.get(authored[index].to), right = source.get(phase.from);
1765
+ return right === fc && fc > 0 ? range.xs[right - 1] : (range.xs[left] + range.xs[right]) / 2;
1766
+ }), first = edge.points[0].x, last = edge.points[edge.points.length - 1].x, inView = new Map(phases.phases.map((phase) => [phase.id, phase])), drawn = authored.flatMap((phase, index) => {
1767
+ let from = Math.max(first, index === 0 ? -1 / 0 : splits[index - 1]), to = Math.min(last, index === splits.length ? 1 / 0 : splits[index]), visible = inView.get(phase.id);
1768
+ return visible ? [{ phase: visible, from, to }] : to > from ? [{ phase: { ...phase, rank: phase.rank ?? index + 1 }, from, to }] : [];
1769
+ }), spans = drawn.map(({ from, to }) => cutEdge(edge, phases.interpolation, from, to)), stop = (x, value, leftCategoryId, rightCategoryId) => ({ x: xOfValue(x), y: y(value), value, leftCategoryId, rightCategoryId }), boundaries = [
1770
+ stop(drawn[0].from, spans[0].points[0].y, cats[0].id, cats[0].id),
1771
+ ...drawn.map(({ phase, to }, index) => {
1772
+ let span = spans[index], next = drawn[index + 1]?.phase;
1773
+ return next ? stop(to, span.points[span.points.length - 1].y, phase.to, next.from) : stop(to, span.points[span.points.length - 1].y, cats[cats.length - 1].id, cats[cats.length - 1].id);
1774
+ })
1775
+ ], derived = { seriesId: phases.series.id, interpolation: phases.interpolation, pointwiseExact: !0, boundaries: boundaries.slice(1, -1).map(({ x, y: boundaryY, leftCategoryId, rightCategoryId }) => ({ x, y: boundaryY, leftCategoryId, rightCategoryId })) };
1776
+ return {
1777
+ phases: drawn.map(({ phase }) => phase),
1778
+ outside: new Set(drawn.flatMap(({ phase }) => inView.has(phase.id) ? [] : [phase.id])),
1779
+ boundaries,
1780
+ spans: spans.map((span) => mapEdge(span, xOfValue, y)),
1781
+ derived
1782
+ };
1783
+ }
1784
+ function phasePaint(phase, index, paletteRamp, palette) {
1785
+ if (phase.tone) return { ...markRolePaint(phase.tone === "muted" ? "neutral" : phase.tone, !0), tint: 0.62 };
1786
+ let rank = phase.rank ?? index + 1;
1787
+ return paletteRamp ? { ...seriesPaint(rank - 1, palette), tint: 0.62 } : { token: `series-${rank}`, tint: 0.62 };
1788
+ }
1789
+ var PHASE_BAND_TINT = 0.84;
1790
+ function renderPhaseFills(theme, input) {
1791
+ if (!input.phases) return;
1792
+ let phases = input.phases, row = input.pv[input.rowOf.get(phases.series)], ranged = input.range && input.xOfValue ? rangePhaseSpans(phases, input.range, input.range.plotted[input.rowOf.get(phases.series)], input.cats, input.xOfValue, input.y) : void 0, resolved = ranged ?? phaseBoundaries(phases, row, input.cats, input.xOf, input.y, input.forecast), curvePoints = "curvePoints" in resolved ? resolved.curvePoints : [], drawn = ranged?.phases ?? phases.phases, plain = ranged ? phaseBoundaries(phases, row, input.cats, input.xOf, input.y, input.forecast).boundaries : void 0, fills = [], boundaries = [], phaseMarks = [], zeroY = input.y(0), banded = zeroY < input.plot.y - 0.5 || zeroY > input.plot.y + input.plot.h + 0.5;
1793
+ drawn.forEach((phase, index) => {
1794
+ let start = resolved.boundaries[index], end = resolved.boundaries[index + 1];
1795
+ if (banded) {
1796
+ let bandPaint = phasePaint(phase, index, input.paletteRamp, input.palette);
1797
+ fills.push({
1798
+ t: "path",
1799
+ id: `mark:phase:${phase.id}`,
1800
+ d: `M${fmtPathNumber(start.x)} ${fmtPathNumber(input.plot.y)}L${fmtPathNumber(end.x)} ${fmtPathNumber(input.plot.y)}L${fmtPathNumber(end.x)} ${fmtPathNumber(input.plot.y + input.plot.h)}L${fmtPathNumber(start.x)} ${fmtPathNumber(input.plot.y + input.plot.h)}Z`,
1801
+ fill: "tint" in bandPaint ? { ...bandPaint, tint: PHASE_BAND_TINT } : bandPaint,
1802
+ owner: { seriesId: phases.series.id, annotationId: phase.id },
1803
+ part: "phaseFill",
1804
+ display: { value: `${phase.label}: ${input.fmt(start.value)} to ${input.fmt(end.value)}` }
1805
+ });
1806
+ }
1807
+ let span = ranged?.spans[index], top = span ? edgePath(span, linePath) : phases.interpolation === "monotone" ? monotonePathBetween(curvePoints, start, end) : linePath([{ x: start.x, y: start.y }, ...curvePoints.filter((point) => point.x > start.x && point.x < end.x), { x: end.x, y: end.y }]), nodeId = `mark:phase:${phase.id}`;
1808
+ banded || fills.push({ t: "path", id: nodeId, d: `${top}L${fmtPathNumber(end.x)} ${fmtPathNumber(input.baseY)}L${fmtPathNumber(start.x)} ${fmtPathNumber(input.baseY)}Z`, fill: phasePaint(phase, index, input.paletteRamp, input.palette), stroke: { token: "axis" }, width: strokeToken(theme, "hair"), dash: dashToken(theme, "reference"), owner: { seriesId: phases.series.id, annotationId: phase.id }, part: "phaseFill", display: { value: `${phase.label}: ${input.fmt(start.value)} to ${input.fmt(end.value)}` } });
1809
+ let owner = { annotationId: phase.id }, tops = span ? edgePolyline({ ...span, mode: phases.interpolation }) : [start, ...curvePoints.filter((point) => point.x > start.x && point.x < end.x), end];
1810
+ if (!banded)
1811
+ if (!span && phases.interpolation === "monotone" || tops.some((point) => point.y > input.baseY))
1812
+ input.occupied.claim({ x: start.x, y: Math.min(start.y, end.y, input.baseY), w: Math.max(end.x - start.x, 1), h: Math.max(Math.max(start.y, end.y, input.baseY) - Math.min(start.y, end.y, input.baseY), 1) }, "mark", owner);
1813
+ else
1814
+ for (let i = 1; i < tops.length; i++) {
1815
+ let [a, b] = [tops[i - 1], tops[i]], y = Math.min(a.y, b.y);
1816
+ input.occupied.claim(
1817
+ { x: a.x, y, w: Math.max(b.x - a.x, 1), h: Math.max(input.baseY - y, 1) },
1818
+ "mark",
1819
+ owner,
1820
+ void 0,
1821
+ [{ x: a.x, y: a.y }, { x: b.x, y: b.y }, { x: b.x, y: input.baseY }, { x: a.x, y: input.baseY }]
1822
+ );
1823
+ }
1824
+ let labelId = `annotation:phase:${phase.id}`, text = phase.label, measured = input.measure(text, input.tickFont), seatX = (from, to) => Math.max(input.plot.x, Math.min((from + to) / 2 - measured.width / 2, input.plot.x + input.plot.w - measured.width)), x = seatX(start.x, end.x), own = plain ? phases.phases.findIndex((item) => item.id === phase.id) : -1, fallbackXs = own < 0 ? [] : [.../* @__PURE__ */ new Set([
1825
+ seatX(plain[own].x, plain[own + 1].x),
1826
+ seatX(input.xOf(input.cats.findIndex((category) => category.id === phase.to)) - measured.width, input.xOf(input.cats.findIndex((category) => category.id === phase.to))),
1827
+ seatX(input.xOf(input.cats.findIndex((category) => category.id === phase.from)), input.xOf(input.cats.findIndex((category) => category.id === phase.from)) + measured.width)
1828
+ ])].filter((at) => at !== x), headerTop = input.plot.y - input.phaseHeaderHeight;
1829
+ input.labelRequests.push({
1830
+ id: labelId,
1831
+ kind: "annotation",
1832
+ role: "caption",
1833
+ owner: { annotationId: phase.id },
1834
+ text,
1835
+ lines: [text],
1836
+ typeRole: "axis",
1837
+ font: input.tickFont,
1838
+ // A phase with no reading in view yields its name to the phases that have one.
1839
+ fontStep: input.tickFont,
1840
+ priority: ranged?.outside.has(phase.id) ? PRIORITY.extreme - 1 : PRIORITY.extreme,
1841
+ candidates: [
1842
+ { slot: "phaseTop", rect: { x, y: headerTop + 2, w: measured.width, h: measured.height }, penalty: 0 },
1843
+ { slot: "phaseTopLower", rect: { x, y: headerTop + 2 + measured.height, w: measured.width, h: measured.height }, penalty: 1 },
1844
+ ...fallbackXs.map((at, k) => ({ slot: "phaseTop", rect: { x: at, y: headerTop + 2, w: measured.width, h: measured.height }, penalty: 2 + k }))
1845
+ ]
1846
+ });
1847
+ let boundaryNodeId;
1848
+ index < drawn.length - 1 && (boundaryNodeId = `phase-boundary:${phase.id}:${drawn[index + 1].id}`, boundaries.push({ t: "line", id: boundaryNodeId, x1: end.x, y1: input.plot.y, x2: end.x, y2: input.plot.y + input.plot.h, stroke: { token: "leader" }, width: strokeToken(theme, "rule"), dash: dashToken(theme, "reference"), owner: { annotationId: drawn[index + 1].id }, part: "phaseBoundary", display: { value: input.fmt(end.value) } }), input.occupied.claim({ x: end.x - 0.5, y: input.plot.y, w: 1, h: input.plot.h }, "annotation", { annotationId: drawn[index + 1].id })), phaseMarks.push({ id: phase.id, nodeId, fromCategoryId: phase.from, toCategoryId: phase.to, x0: start.x, x1: end.x, y0: start.y, y1: end.y, labelId, ...boundaryNodeId ? { boundaryNodeId } : {} });
1849
+ }), input.marks.phases = phaseMarks;
1850
+ let analytical = input.nodes.splice(input.analyticalSceneStart), areas = analytical.filter((node) => node.part === "area"), baseline = analytical.filter((node) => node.part === "baseline"), foreground = analytical.filter((node) => node.part !== "area" && node.part !== "baseline");
1851
+ return pushAll(input.nodes, fills), pushAll(input.nodes, areas), pushAll(input.nodes, baseline), pushAll(input.nodes, boundaries), pushAll(input.nodes, foreground), resolved.derived;
1852
+ }
1853
+
1854
+ // src/core/charts/line/forecast.ts
1855
+ function forecastBoundaries(series, cats, annotations, phases, stacked) {
1856
+ let turning = series.flatMap((item) => {
1857
+ let start = forecastStart(item, cats);
1858
+ return start > 0 && item.vals.slice(0, start).some((v) => v.v !== null) && item.vals.slice(start).some((v) => v.v !== null) ? [{ start, lastActual: lastActualIndex(item, start, stacked) }] : [];
1859
+ }), transitions = turning.filter((item, index) => turning.findIndex((other) => other.start === item.start && other.lastActual === item.lastActual) === index).sort((a, b) => a.start + a.lastActual - b.start - b.lastActual || a.start - b.start), usedIds = new Set(cats.map((category) => category.id));
1860
+ return transitions.map(({ start: categoryIndex, lastActual }) => {
1861
+ let categoryId = cats[categoryIndex].id, atStart = transitions.filter((item) => item.start === categoryIndex), authored = lastActual === maxOf(atStart.map((item) => item.lastActual)), id = categoryId;
1862
+ if (atStart.length > 1) {
1863
+ for (id = `${categoryId}:from:${lastActual}`; usedIds.has(id); ) id += ":2";
1864
+ usedIds.add(id);
1865
+ }
1866
+ let bands = annotations.filter((ann) => ann.kind === "band" && ann.style === "bracket"), phase = phases?.phases.find((item) => item.from === categoryId);
1867
+ return {
1868
+ categoryIndex,
1869
+ categoryId,
1870
+ id,
1871
+ lastActualIndex: lastActual,
1872
+ labelled: authored && (bands.some((band) => band.from === categoryId && /^(fc|forecast)$/i.test(band.label?.trim() ?? "")) || !!phase && /^(fc|forecast)$/i.test(phase.label.trim())),
1873
+ divided: authored && (!!phase || bands.some((band) => band.from === categoryId && (band.divider === "start" || band.divider === "both") || band.to === cats[categoryIndex - 1].id && (band.divider === "end" || band.divider === "both")))
1874
+ };
1875
+ });
1876
+ }
1877
+ function forecastStroke(paint, theme, crossesBand) {
1878
+ let result = { token: "token" in paint ? paint.token : "neutral", theme: { kind: "line-forecast", base: paint, crossesBand } };
1879
+ return paintColor(theme, result), result;
1880
+ }
1881
+ function forecastDividerAt(domain) {
1882
+ return domain.isArea || domain.fan || domain.phases ? "point" : "band";
1883
+ }
1884
+ function placeForecastHeaders(boundaries, xOf, plot, headerY, font, measure, requests, occupied, header = localeStrings().forecastHeader, boundaryAt = "point", actual) {
1885
+ let measured = measure(header, font), actualSize = actual ? measure(actual, font) : void 0, ordered = [...boundaries].sort((a, b) => forecastBoundaryX(a, xOf, boundaryAt) - forecastBoundaryX(b, xOf, boundaryAt));
1886
+ for (let [index, boundary] of ordered.entries()) {
1887
+ let x = forecastBoundaryX(boundary, xOf, boundaryAt), end = ordered[index + 1] ? forecastBoundaryX(ordered[index + 1], xOf, boundaryAt) : plot.x + plot.w, annotationId = `forecast:${boundary.id}`;
1888
+ if (boundary.divided || occupied.claim({ x: x - 0.5, y: plot.y, w: 1, h: plot.h }, "annotation", { annotationId }, "forecastDivider"), boundary.labelled) continue;
1889
+ let at = (left) => ({ x: Math.max(x, Math.min(left, end - measured.width)), y: headerY + 2, w: measured.width, h: measured.height }), start = index > 0 ? forecastBoundaryX(ordered[index - 1], xOf, boundaryAt) + 4 : plot.x;
1890
+ if (actual && actualSize && ordered.length === 1 && x - 4 - actualSize.width >= start) {
1891
+ let actualId = `forecast:actual:${boundary.id}`;
1892
+ requests.push({
1893
+ id: actualId,
1894
+ kind: "annotation",
1895
+ role: "caption",
1896
+ owner: { annotationId },
1897
+ text: actual,
1898
+ lines: [actual],
1899
+ typeRole: "secondary",
1900
+ font,
1901
+ priority: PRIORITY.valueLine,
1902
+ candidates: [{ slot: "forecastTopActual", rect: { x: x - 4 - actualSize.width, y: headerY + 2, w: actualSize.width, h: actualSize.height }, penalty: 0 }]
1903
+ });
1904
+ }
1905
+ requests.push({
1906
+ id: annotationId,
1907
+ kind: "annotation",
1908
+ role: "caption",
1909
+ owner: { annotationId },
1910
+ text: header,
1911
+ lines: [header],
1912
+ typeRole: "secondary",
1913
+ font,
1914
+ priority: PRIORITY.valueLine,
1915
+ candidates: [
1916
+ { slot: "forecastTop", rect: at(x + 4), penalty: 0 },
1917
+ { slot: "forecastTopStart", rect: at(x), penalty: 1 },
1918
+ { slot: "forecastTopCentre", rect: at((x + end - measured.width) / 2), penalty: 2 },
1919
+ { slot: "forecastTopEnd", rect: at(end - measured.width - 4), penalty: 3 }
1920
+ ]
1921
+ });
1922
+ }
1923
+ }
1924
+ function actualHeader(domain) {
1925
+ if (!domain.isArea) return;
1926
+ let options = domain.options;
1927
+ if (options.strings?.forecastHeader === chartString2({ ...options, strings: void 0 }, "forecastHeader"))
1928
+ return chartString2(options, "actualHeader");
1929
+ }
1930
+ function emitForecastDividers(theme, boundaries, xOf, plot, nodes, at = "point") {
1931
+ for (let boundary of boundaries) {
1932
+ if (boundary.divided) continue;
1933
+ let x = forecastBoundaryX(boundary, xOf, at);
1934
+ nodes.push({
1935
+ t: "line",
1936
+ id: `forecast-divider:${boundary.id}`,
1937
+ x1: x,
1938
+ x2: x,
1939
+ y1: plot.y,
1940
+ y2: plot.y + plot.h,
1941
+ stroke: { token: "leader" },
1942
+ width: strokeToken(theme, "rule"),
1943
+ dash: dashToken(theme, "reference"),
1944
+ owner: { annotationId: `forecast:${boundary.id}` },
1945
+ part: "forecastDivider"
1946
+ });
1947
+ }
1948
+ }
1949
+ function backForecastAreaLabels(labels, series, cats, plot, bandFill, nodes) {
1950
+ for (let label of labels) {
1951
+ if (label.hidden || label.backing || !label.owner.seriesId || !label.owner.categoryId) continue;
1952
+ let dataIdx = series.findIndex((item) => item.id === label.owner.seriesId);
1953
+ if (dataIdx < 0) continue;
1954
+ let owner = series[dataIdx], start = forecastStart(owner, cats), ci = cats.findIndex((cat) => cat.id === label.owner.categoryId), lastActual = ci === start - 1 && label.slot.startsWith("insideBand");
1955
+ if (start < 0 || ci < start && !lastActual) continue;
1956
+ let x = label.rect.x + label.rect.w / 2, y = label.rect.y + label.rect.h / 2;
1957
+ if (!(x < plot.x || x > plot.x + plot.w || y < plot.y || y > plot.y + plot.h)) {
1958
+ if (label.slot.startsWith("insideBand")) {
1959
+ nodes.push({ t: "rect", id: `label-backing:${label.id}`, rect: inflate(label.rect, 1), fill: bandFill(owner, dataIdx, !lastActual), owner: label.owner, part: "labelBacking" });
1960
+ continue;
1961
+ }
1962
+ nodes.push({ t: "rect", id: `plate:${label.id}`, rect: labelPlate(label.rect), fill: { token: "background" }, radius: LABEL_PLATE_RADIUS, owner: label.owner, part: "labelPlate" }), label.halo = !1, "token" in label.ink && (label.ink.token === "ink" || label.ink.token === "inkInverse" || label.ink.theme?.kind === "contrast-ink") && (label.ink = { token: "ink" });
1963
+ }
1964
+ }
1965
+ }
1966
+
1967
+ // src/core/charts/line/means.ts
1968
+ function lineMeans(pv, rowOf, drawnSeries, cats, ownUnits) {
1969
+ let firstVals = pv[rowOf.get(drawnSeries[0])].filter((v) => v !== null), meanValue = firstVals.length > 0 ? firstVals.reduce((a, b) => a + b, 0) / firstVals.length : void 0, catIndex = new Map(cats.map((c, i) => [c.id, i]));
1970
+ return { meanValue, catIndex, meanValueFor: (scope) => {
1971
+ let s = scope.seriesId === void 0 ? drawnSeries[0] : drawnSeries.find((item) => item.id === scope.seriesId);
1972
+ if (!s)
1973
+ return {
1974
+ error: `series '${String(scope.seriesId)}' is not a drawn data series \u2014 the mean must be measured from plotted cells`
1975
+ };
1976
+ let row = pv[rowOf.get(s)], ci0 = 0, ci1 = cats.length - 1;
1977
+ if (scope.from !== void 0 && scope.to !== void 0) {
1978
+ let fi = catIndex.get(scope.from), ti = catIndex.get(scope.to);
1979
+ if (fi === void 0 || ti === void 0)
1980
+ return {
1981
+ error: `category span '${scope.from}'..'${scope.to}' names a category that does not exist`
1982
+ };
1983
+ if (fi > ti)
1984
+ return {
1985
+ error: `category span '${scope.from}'..'${scope.to}' is reversed \u2014 'from' must not come after 'to'`
1986
+ };
1987
+ ci0 = fi, ci1 = ti;
1988
+ }
1989
+ let vals = row.slice(ci0, ci1 + 1).filter((value) => value !== null);
1990
+ return vals.length === 0 ? { error: `series '${s.id}' has no plotted values in the requested span` } : {
1991
+ value: vals.reduce((a, b) => a + b, 0) / vals.length,
1992
+ seriesId: s.id,
1993
+ ...scope.from !== void 0 && scope.to !== void 0 ? { from: scope.from, to: scope.to } : {},
1994
+ ...ownUnits && s.format !== void 0 ? { format: s.format } : {}
1995
+ };
1996
+ } };
1997
+ }
1998
+ function lineValueStats(series, domainEpsilon, population) {
1999
+ return Object.fromEntries(series.map((series2) => {
2000
+ let values = (population?.get(series2.id) ?? series2.vals).flatMap((value) => value.v === null ? [] : [value.v]), range = values.length > 0 ? maxOf(values) - minOf(values) : 0, mean = values.length > 0 ? values.reduce((sum, value) => sum + value, 0) / values.length : 0;
2001
+ return [series2.id, { range, mean, relativeRange: range / Math.max(Math.abs(mean), domainEpsilon) }];
2002
+ }));
2003
+ }
2004
+
2005
+ // src/core/planLineStyle.ts
2006
+ function planLineStyle(scenario, theme) {
2007
+ return scenario === "PL" ? { width: strokeToken(theme, "data"), ink: "ink" } : void 0;
2008
+ }
2009
+
2010
+ // src/core/charts/line/fan.ts
2011
+ function validateDeclaration(input) {
2012
+ let { spec, seriesById, seriesNorm, variant, isArea, rebase100, gapFill } = input, named = [
2013
+ ["fan.of", spec.of],
2014
+ ...spec.bands.flatMap((band, k) => [
2015
+ [`fan.bands[${k}].low`, band.low],
2016
+ [`fan.bands[${k}].high`, band.high]
2017
+ ])
2018
+ ];
2019
+ for (let [path, id] of named)
2020
+ if (!seriesById.has(id)) throw new NormalizeError("fan-series-unknown", path, `fan names unknown series '${id}' \u2014 a band is DECLARED DATA, so every bound must exist in data.series`, `add a series with id '${id}', or point this bound at one of: ${seriesNorm.map((s) => `'${s.id}'`).join(", ")}`);
2021
+ spec.bands.forEach((band, k) => {
2022
+ if (typeof band.label != "string" || band.label.trim() === "") throw new NormalizeError("fan-band-unlabelled", `fan.bands[${k}].label`, `fan.bands[${k}] has no label \u2014 '80% predictive interval' and 'min/max of three scenarios' draw the same band and mean different things`, "add a label that says what the interval means, such as '80% predictive interval'");
2023
+ });
2024
+ let seen = /* @__PURE__ */ new Map([[spec.of, "fan.of"]]);
2025
+ for (let [path, id] of named.slice(1)) {
2026
+ let first = seen.get(id);
2027
+ if (first !== void 0) throw new NormalizeError("fan-series-reused", path, `series '${id}' is used twice by the fan (${first} and ${path}) \u2014 each bound and the centre must be its own series, or the bands drawn are not the bands declared`, "give each band its own low/high series; a shared bound means two intervals claim the same numbers");
2028
+ seen.set(id, path);
2029
+ }
2030
+ if (spec.bands.length > 4) throw new NormalizeError("fan-too-many-bands", "fan.bands", `${spec.bands.length} bands exceed the four the tint ladder can keep apart \u2014 past four the washes are indistinguishable and the exhibit claims a precision the reader cannot see`, "four nested intervals is the legibility limit; drop or merge bands");
2031
+ if (variant === "stacked-area" || variant === "stacked100-area") throw new NormalizeError("fan-composition-conflict", "variant", `variant '${variant}' stacks each series onto the ones below it; a band around one member of a composition bounds nothing the reader can see, because the member's own position depends on its neighbours' values`, "use variant 'line' for a fan, and a separate exhibit for the composition");
2032
+ if (isArea) throw new NormalizeError("fan-area-conflict", "variant", `variant '${variant}' fills from the trajectory down to the baseline with an opaque fill that paints OVER the lower half of every band \u2014 the reader would see only the upper edge of each interval, i.e. a one-sided uncertainty, while the legend key beside it names the whole interval`, "use variant 'line' for a fan \u2014 the fan IS the fill, and a second fill under it hides half of what it declares");
2033
+ if (rebase100) throw new NormalizeError("fan-rebase-conflict", "rebase100", "rebase100 divides EACH series by its OWN value at the base category, so the bounds and the centre are rescaled by different divisors and the bands stop nesting \u2014 the fan would still be drawn, and would be wrong", "rebase the numbers before authoring them, so centre and bounds share one base, or drop rebase100");
2034
+ if (gapFill) throw new NormalizeError("fan-gapfill-conflict", "gapFill", "gapFill and fan are two wash systems in one plot \u2014 a reader cannot tell an uncertainty band from a shaded difference, and the picture would answer neither question", "keep the fan and drop gapFill, or split them into two exhibits");
2035
+ }
2036
+ function buildBands(input) {
2037
+ let { spec, seriesById, cats, pv, rowOf } = input, catLabel = (ci) => cats[ci].label ?? cats[ci].id, bands = spec.bands.map((band) => ({
2038
+ low: seriesById.get(band.low),
2039
+ high: seriesById.get(band.high),
2040
+ label: band.label,
2041
+ widths: cats.map(() => null)
2042
+ }));
2043
+ return bands.forEach((band, k) => {
2044
+ let lowRow = pv[rowOf.get(band.low)], highRow = pv[rowOf.get(band.high)];
2045
+ cats.forEach((_, ci) => {
2046
+ let lo = lowRow[ci], hi = highRow[ci];
2047
+ if (!(lo === null || hi === null)) {
2048
+ if (lo > hi) throw new NormalizeError(
2049
+ "fan-band-inverted",
2050
+ `fan.bands[${k}]`,
2051
+ `band '${band.label}' is inverted at category '${catLabel(ci)}': low '${band.low.id}' = ${lo} is above high '${band.high.id}' = ${hi}`,
2052
+ "swap the low and high series ids for this band \u2014 the engine will not swap them for you, because a silently corrected bound hides which series is actually which"
2053
+ );
2054
+ band.widths[ci] = hi - lo;
2055
+ }
2056
+ });
2057
+ }), bands;
2058
+ }
2059
+ function validateNesting(input) {
2060
+ let { bands, cats, pv, rowOf } = input, row = (series) => pv[rowOf.get(series)];
2061
+ for (let k = 0; k + 1 < bands.length; k++) {
2062
+ let outer = bands[k], inner = bands[k + 1], [oLow, oHigh, iLow, iHigh] = [row(outer.low), row(outer.high), row(inner.low), row(inner.high)];
2063
+ for (let ci = 0; ci < cats.length; ci++) {
2064
+ let [ol, oh, il, ih] = [oLow[ci], oHigh[ci], iLow[ci], iHigh[ci]];
2065
+ if (!(ol === null || oh === null || il === null || ih === null) && (ol > il || oh < ih))
2066
+ throw new NormalizeError(
2067
+ "fan-bands-crossed",
2068
+ `fan.bands[${k + 1}]`,
2069
+ `bands are not nested at category '${cats[ci].label ?? cats[ci].id}': band ${k} '${outer.label}' spans ${ol}..${oh} and does not contain band ${k + 1} '${inner.label}' spanning ${il}..${ih} \u2014 bands must be authored OUTERMOST FIRST`,
2070
+ "reorder the bands outermost-first in the document, or fix the bound values; the engine will not reorder them, because a reordered fan hides an authoring error the reader can never see"
2071
+ );
2072
+ }
2073
+ }
2074
+ }
2075
+ function validateCenter(input) {
2076
+ let { of, ofRow, band, cats, pv, rowOf } = input, low = pv[rowOf.get(band.low)], high = pv[rowOf.get(band.high)];
2077
+ for (let ci = 0; ci < cats.length; ci++) {
2078
+ let [center, lo, hi] = [ofRow[ci], low[ci], high[ci]];
2079
+ if (!(center === null || lo === null || hi === null) && (center < lo || center > hi))
2080
+ throw new NormalizeError(
2081
+ "fan-center-outside-band",
2082
+ "fan.of",
2083
+ `the central series '${of.id}' = ${center} at category '${cats[ci].label ?? cats[ci].id}' lies outside its innermost band '${band.label}' (${lo}..${hi}) \u2014 the centre and the bounds do not describe the same quantity`,
2084
+ "check that fan.of names the central trajectory and that the bound series are aligned to the same categories; a fan whose centre escapes its own interval is drawing two different series as one"
2085
+ );
2086
+ }
2087
+ }
2088
+ function resolveFan(input) {
2089
+ let { spec, seriesById, seriesNorm, cats, variant, isArea, rebase100, gapFill, pv, rowOf, warnings } = input;
2090
+ if (!spec) return null;
2091
+ validateDeclaration({ spec, seriesById, seriesNorm, variant, isArea, rebase100, gapFill });
2092
+ let of = seriesById.get(spec.of), ofRow = pv[rowOf.get(of)];
2093
+ if (ofRow.every((value) => value === null)) throw new NormalizeError("fan-center-empty", "fan.of", `the central series '${of.id}' is null in every category \u2014 a fan with no trajectory is bands around nothing`, "give the central series values, or point fan.of at the series that carries the projection");
2094
+ let bands = buildBands({ spec, seriesById, cats, pv, rowOf });
2095
+ validateNesting({ bands, cats, pv, rowOf }), validateCenter({ of, ofRow, band: bands[bands.length - 1], cats, pv, rowOf });
2096
+ let boundIds = new Set(bands.flatMap((band) => [band.low.id, band.high.id])), origin = null;
2097
+ for (let ci = 0; ci < cats.length && origin === null; ci++)
2098
+ bands.some((band) => (band.widths[ci] ?? 0) > 0) && (origin = cats[ci].id);
2099
+ let row = (series) => pv[rowOf.get(series)], undeclaredAt = cats.filter((_, ci) => bands.some((band) => row(band.low)[ci] === null || row(band.high)[ci] === null)).map((category) => category.id);
2100
+ return origin === null && warnings.push({
2101
+ code: "fan-degenerate",
2102
+ severity: "warn",
2103
+ message: "every fan band has low === high in every category, so there is no interval to wash \u2014 the bounds are drawn as ordinary series instead of as a fan",
2104
+ suggest: "drop options.fan if the bounds are meant to coincide, or supply bounds that differ from each other"
2105
+ }), { of, bands, showBounds: spec.showBounds === !0, origin, boundIds, undeclaredAt };
2106
+ }
2107
+ function outerFanEdge(domain, bands) {
2108
+ let byId = new Map(domain.seriesNorm.map((series) => [series.id, series])), rowOfId = (id) => domain.pv[domain.rowOf.get(byId.get(id))];
2109
+ return bands.flatMap((band, index) => {
2110
+ let low = rowOfId(band.low), high = rowOfId(band.high);
2111
+ for (let ci = low.length - 1; ci >= 0; ci--) if (low[ci] !== null && high[ci] !== null) return [{ index, ci, low: low[ci], high: high[ci] }];
2112
+ return [];
2113
+ }).sort((a, b) => Math.abs(b.high - b.low) - Math.abs(a.high - a.low))[0];
2114
+ }
2115
+ function fanGapNote(fan, cats, strings) {
2116
+ if (!fan || fan.origin === null || fan.undeclaredAt.length === 0) return [];
2117
+ let label = (id) => cats.find((category) => category.id === id)?.label ?? id;
2118
+ return [disclosureNote(stringFields(strings?.fanGap ?? localeStrings().fanGap, { categories: fan.undeclaredAt.map(label).join(", ") }))];
2119
+ }
2120
+ function buildFanPaints(input) {
2121
+ let { fan, drawnSeries, seriesPaint: seriesPaint2, theme, anyHighlight, highlights } = input;
2122
+ if (!fan || fan.origin === null) return { fanLadder: [], fanCentrePaint: null, fanPaints: !1 };
2123
+ let centrePaint = seriesPaint2(fan.of, Math.max(0, drawnSeries.indexOf(fan.of)));
2124
+ return { fanLadder: fanPaintSteps(theme, centrePaint, fan.bands.length, fan.showBounds, fan.of.id, anyHighlight && !highlights.has(fan.of.id)).map((step, index) => ({ ...step, paint: {
2125
+ token: "token" in centrePaint ? centrePaint.token : "highlight",
2126
+ theme: { kind: "fan-step", base: centrePaint, bandCount: fan.bands.length, showBounds: fan.showBounds, index, seriesId: fan.of.id, deEmphasized: anyHighlight && !highlights.has(fan.of.id) }
2127
+ } })), fanCentrePaint: centrePaint, fanPaints: !0 };
2128
+ }
2129
+ function fanBoundText(lo, hi, fmt, spec) {
2130
+ let a = fmt(lo), b = fmt(hi);
2131
+ if (a !== b || !(hi > lo)) return [a, b];
2132
+ let plain = { ...defaultFormatSpec(spec.locale), thousandsSep: spec.thousandsSep };
2133
+ for (let digits = 1; digits <= 15; digits++)
2134
+ if (lo.toFixed(digits) !== hi.toFixed(digits)) return [formatWithSpec(lo, { ...plain, decimals: digits }), formatWithSpec(hi, { ...plain, decimals: digits })];
2135
+ return [formatExactNumber(lo, spec.locale), formatExactNumber(hi, spec.locale)];
2136
+ }
2137
+ function collectRuns(input) {
2138
+ let { lowRow, highRow, cats, compositionInvalidAt, xOf, y, gapCats } = input, runs = [], current = [];
2139
+ return cats.forEach((_, ci) => {
2140
+ let lo = lowRow[ci], hi = highRow[ci];
2141
+ if (lo === null || hi === null || compositionInvalidAt(ci)) {
2142
+ (lo === null || hi === null) && gapCats.add(cats[ci].id), current.length > 0 && runs.push(current), current = [];
2143
+ return;
2144
+ }
2145
+ current.push({ ci, x: xOf(ci), yLow: y(lo), yHigh: y(hi) });
2146
+ }), current.length > 0 && runs.push(current), runs;
2147
+ }
2148
+ function addFanRun(theme, input) {
2149
+ let { run, runIndex, band, bandIndex, lowRow, highRow, cats, interpolation, fanLadder, showBounds, pathFor: pathFor2, reversePathTail: reversePathTail2, fmt, occupied, fanNodes, hairNodes, gapCats } = input;
2150
+ if (run.length < 2) {
2151
+ for (let point of run) gapCats.add(cats[point.ci].id);
2152
+ return null;
2153
+ }
2154
+ let upper = input.edges?.[0]?.points ?? run.map((point) => ({ x: point.x, y: point.yHigh })), lower = input.edges?.[1]?.points ?? run.map((point) => ({ x: point.x, y: point.yLow })), upperPath = input.edges ? edgePath(input.edges[0], (points) => pathFor2([...points], interpolation)) : pathFor2(upper, interpolation), lowerCurve = input.edges?.[1]?.curve, reverse = lowerCurve ? [...lowerCurve].reverse().map((c) => `C${fmtPathNumber(c.c2.x)} ${fmtPathNumber(c.c2.y)} ${fmtPathNumber(c.c1.x)} ${fmtPathNumber(c.c1.y)} ${fmtPathNumber(c.from.x)} ${fmtPathNumber(c.from.y)}`).join("") : reversePathTail2(lower, interpolation), nodeId = `mark:fan:${bandIndex}:${runIndex}`, widestAt = run[0].ci;
2155
+ for (let point of run) (band.widths[point.ci] ?? 0) > (band.widths[widestAt] ?? 0) && (widestAt = point.ci);
2156
+ let [loText, hiText] = fanBoundText(lowRow[widestAt], highRow[widestAt], fmt, input.numberSpec);
2157
+ fanNodes.push({
2158
+ t: "path",
2159
+ id: nodeId,
2160
+ d: `${upperPath}L${fmtPathNumber(lower[lower.length - 1].x)} ${fmtPathNumber(lower[lower.length - 1].y)}${reverse}Z`,
2161
+ fill: fanLadder[bandIndex].paint,
2162
+ owner: {},
2163
+ part: "fanBand",
2164
+ display: { value: `${band.label}: ${numberRange(loText, hiText)} at ${cats[widestAt].label ?? cats[widestAt].id}${(band.widths[widestAt] ?? 0) > 0 ? " (widest)" : ""}` }
2165
+ });
2166
+ for (let k = 0; k + 1 < run.length; k++) {
2167
+ let a = run[k], b = run[k + 1], top = Math.min(a.yHigh, b.yHigh), bottom = Math.max(a.yLow, b.yLow);
2168
+ occupied.claim({ x: Math.min(a.x, b.x), y: top, w: Math.max(Math.abs(b.x - a.x), 1), h: Math.max(bottom - top, 1) }, "mark", {}, "fanBand");
2169
+ }
2170
+ if (showBounds) {
2171
+ let hairPaint = fanLadder[bandIndex + 1].paint;
2172
+ for (let [edge, points] of [["high", upper], ["low", lower]]) hairNodes.push({
2173
+ t: "path",
2174
+ id: `mark:fan-bound:${bandIndex}:${edge}:${runIndex}`,
2175
+ d: input.edges ? edgePath(input.edges[edge === "high" ? 0 : 1], (pts) => pathFor2([...pts], interpolation)) : pathFor2(points, interpolation),
2176
+ stroke: hairPaint,
2177
+ width: strokeToken(theme, "rule"),
2178
+ dash: dashToken(theme, "dotted"),
2179
+ lineCap: "round",
2180
+ owner: { seriesId: edge === "high" ? band.high.id : band.low.id },
2181
+ part: "fanBound",
2182
+ display: { value: `${band.label} ${edge}: ${fmt((edge === "high" ? highRow : lowRow)[widestAt])}` }
2183
+ });
2184
+ }
2185
+ return nodeId;
2186
+ }
2187
+ function renderFanWashes(theme, input) {
2188
+ let { fan, fanPaints, fanLadder, interpolationFor, pv, rowOf, cats, compositionInvalidAt, xOf, y, pathFor: pathFor2, reversePathTail: reversePathTail2, fmt, numberSpec, occupied, warnings, nodes, marks, analyticalSceneStart } = input;
2189
+ if (!fan || !fanPaints) return;
2190
+ let interpolation = interpolationFor(fan.of), fanNodes = [], hairNodes = [], fanMarks = [], gapCats = /* @__PURE__ */ new Set();
2191
+ if (fan.bands.forEach((band, bandIndex) => {
2192
+ let lowRow = pv[rowOf.get(band.low)], highRow = pv[rowOf.get(band.high)];
2193
+ input.range && cats.forEach((cat, ci) => {
2194
+ (lowRow[ci] === null || highRow[ci] === null) && gapCats.add(cat.id);
2195
+ });
2196
+ let edges = input.range && input.xOfValue ? rangeRuns(input.range, [input.range.plotted[rowOf.get(band.high)], input.range.plotted[rowOf.get(band.low)]], interpolation).map((run) => run.map((edge) => mapEdge(edge, input.xOfValue, y))) : void 0, nodeIds = (edges ? edges.map((run) => run[0].points.map((p, i) => ({ ci: p.ci, x: p.x, yHigh: p.y, yLow: run[1].points[i].y }))) : collectRuns({ lowRow, highRow, cats, compositionInvalidAt, xOf, y, gapCats })).map((run, runIndex) => addFanRun(theme, { ...edges ? { edges: edges[runIndex] } : {}, run, runIndex, band, bandIndex, lowRow, highRow, cats, interpolation, fanLadder, showBounds: fan.showBounds, pathFor: pathFor2, reversePathTail: reversePathTail2, fmt, numberSpec, occupied, fanNodes, hairNodes, gapCats })).filter((id) => id !== null);
2197
+ nodeIds.length > 0 && fanMarks.push({ bandIndex, nodeIds, low: band.low.id, high: band.high.id, label: band.label });
2198
+ }), gapCats.size > 0 && warnings.push({
2199
+ code: "fan-band-gap",
2200
+ severity: "warn",
2201
+ message: `a fan band has no drawable run at ${[...gapCats].map((id) => `'${id}'`).join(", ")} \u2014 a category where either bound is null ends the band there rather than bridging an interval that was never declared`,
2202
+ suggest: "supply both bounds at those categories, or accept the break"
2203
+ }), fanNodes.length === 0) return;
2204
+ marks.fan = fanMarks;
2205
+ let analyticalNodes = nodes.splice(analyticalSceneStart), areas = analyticalNodes.filter((node) => node.part === "area"), baseline = analyticalNodes.filter((node) => node.part === "baseline"), foreground = analyticalNodes.filter((node) => node.part !== "area" && node.part !== "baseline");
2206
+ pushAll(nodes, fanNodes), pushAll(nodes, areas), pushAll(nodes, hairNodes), pushAll(nodes, baseline), pushAll(nodes, foreground);
2207
+ }
2208
+
2209
+ // src/core/charts/line/paints.ts
2210
+ var MARKER_MAX_CATS = 12, BUMP_SHAPES = ["circle", "square", "triangle", "diamond"], BUMP_DASH_ROLES = [void 0, "reference", "dotted"], CONTEXT_LADDER_INK_SHARE = [0, 0.25, 0.45, 0.6, 0.72], LINE_GREY_LADDER_INK_SHARE = [0.65, 0.4, 0.78, 0.52], LINE_GREY_SHAPES = ["square", "diamond", "triangle"], HIGHLIGHT_FADE = 0.5, FADE_PAGE_FLOOR = 1.4, fadedPaint = (paint) => {
2211
+ let mixed = mixedPaint(paint, { token: "background" }, HIGHLIGHT_FADE, "token" in paint ? paint.token : "neutralLight");
2212
+ return "theme" in mixed && mixed.theme?.kind === "mix" ? { ...mixed, theme: { ...mixed.theme, pageFloor: FADE_PAGE_FLOOR } } : mixed;
2213
+ };
2214
+ function lineText(env, domain) {
2215
+ let { options, valueSpec, fmt } = domain, kindSetting = (kind) => {
2216
+ let l = options.labels;
2217
+ if (l === !1) return kind === "category" && labelsOffKeepsNames(options);
2218
+ let v = l?.[kind];
2219
+ return v === void 0 ? !0 : v;
2220
+ }, contentOf = (kind, dflt) => {
2221
+ let s = kindSetting(kind);
2222
+ return s === !1 ? null : Array.isArray(s) ? s : dflt;
2223
+ }, compose = (extra) => (content, abs, pct, catLabel, serLabel, unitSuffix = "", authoredPct = !1, source, categoryId) => {
2224
+ let parts = [], shareText = !authoredPct && source && categoryId !== void 0 ? domain.shareTexts.get(`${categoryId}\0${source.id}`) : void 0, lifted = (value, percent) => {
2225
+ let spec = seriesRasterFormatter(source?.format ?? options.format, domain.seriesNorm.flatMap((s) => s.vals.map((v) => v.v)), options.locale?.language, source?.unit ?? options.unit, options.target).spec;
2226
+ return formatWithSpec(value, {
2227
+ ...spec,
2228
+ decimals: Math.min(20, spec.decimals + extra),
2229
+ wholeFrom: void 0,
2230
+ currencyWhole: void 0,
2231
+ ...percent && !source?.format && !options.format ? { suffix: "%" } : {}
2232
+ });
2233
+ };
2234
+ for (let c of content)
2235
+ c === "absolute" && abs !== null ? parts.push(withUnit(extra ? lifted(abs, authoredPct) : (authoredPct && source && !source.format ? valueSpec.fmtPercent : source ? valueSpec.forSeries(source) : fmt)(abs), unitSuffix, !0)) : c === "percent" && pct !== null ? parts.push(shareText ?? (extra ? formatAutomaticPercent(pct, Math.min(20, (authoredPct ? Math.abs(pct) < 1 && pct !== 0 ? 1 : 0 : shareDecimals(pct)) + extra), !1, options.locale?.language) : authoredPct ? env.authoredPctFmt(pct) : env.pctFmt(pct))) : c === "category" && catLabel ? parts.push(catLabel) : c === "series" && serLabel && parts.push(serLabel);
2236
+ return parts.join(" ");
2237
+ }, composeText = compose(0), endExtra = env.isBump ? 0 : distinctDecimalLift(domain.drawnSeries.flatMap((series) => {
2238
+ let ci = domain.lastIdxOf.get(series.id);
2239
+ if (ci === void 0) return [];
2240
+ if (domain.shareTexts.has(`${domain.cats[ci].id}\0${series.id}`)) return [];
2241
+ let share = domain.variant === "stacked100-area", value = share ? domain.endpoints[series.id]?.value ?? null : domain.rebased ? domain.pv[domain.rowOf.get(series)][ci] : domain.absOf(series, ci);
2242
+ if (value === null) return [];
2243
+ let cell = series.vals[ci], source = domain.rebased ? void 0 : cell.format ? { ...series, format: cell.format } : series;
2244
+ return [{ value, format: (extra) => compose(extra)(share ? ["percent"] : ["absolute"], value, value, "", "", "", cell.isPct, source) }];
2245
+ })), composeEndText = endExtra ? compose(endExtra) : composeText, printsZero = (abs, authoredPct = !1, source) => valueSpec.roundsToZeroAt(abs, authoredPct && source && !source.format ? {} : source), { theme, measure } = env, tickFont = { family: theme.type.family, ...theme.type.axis }, labelFont = { family: theme.type.family, ...theme.type.label }, nameFont = labelFont;
2246
+ return { kindSetting, contentOf, composeText, composeEndText, printsZero, tickFont, secondaryFont: secondaryFont(theme), labelFont, nameFont, labelH: measure("0", labelFont).height };
2247
+ }
2248
+ function heroPlan(env, domain, warnings) {
2249
+ let { drawnSeries, fan, variant, options } = domain, activeFan = fan != null && fan.origin !== null, emphasis = options.emphasis ?? (activeFan ? "first" : "none"), heroEligible = !env.isBump && variant === "line" && // An active fan's centre is the subject even as the only drawn line (the
2250
+ // bounds are not in drawnSeries), so it stays eligible.
2251
+ (drawnSeries.length >= 2 || activeFan) && !env.anyHighlight && !env.paletteRamp && drawnSeries.every((s) => !s.fill && !s.colorRole && !s.scenario), heroMode = emphasis === "first" && heroEligible;
2252
+ options.emphasis === "first" && !heroMode && warnings.push({
2253
+ code: "line-emphasis-ignored",
2254
+ severity: "warn",
2255
+ message: "emphasis 'first' needs two or more plain lines; a single drawn series, a highlight, palette, series fill, colorRole or series-level scenario, or an area or bump variant keeps its own colours",
2256
+ suggest: "remove emphasis, or use highlight to pick the series that leads"
2257
+ });
2258
+ let heroId = heroMode ? fan && fan.origin !== null ? fan.of.id : drawnSeries[0].id : null;
2259
+ return !env.isBump && variant === "line" && !heroMode && !env.anyHighlight && drawnSeries.length > 3 && warnings.push({
2260
+ code: "line-peer-overload",
2261
+ severity: "info",
2262
+ message: `${drawnSeries.length} peer-styled lines are hard to follow \u2014 highlight one series, set emphasis 'first', or facet into small multiples (grid repeat)`
2263
+ }), { heroMode, heroId };
2264
+ }
2265
+ function bumpIdentity(env, domain, warnings) {
2266
+ let bumpRampLen = Math.max(1, (env.paletteRamp ?? env.theme.color.series).length), slot = (dataIdx) => {
2267
+ let shapeWrap = Math.floor(dataIdx / bumpRampLen), dashRole = BUMP_DASH_ROLES[Math.floor(shapeWrap / BUMP_SHAPES.length) % BUMP_DASH_ROLES.length];
2268
+ return {
2269
+ color: dataIdx % bumpRampLen,
2270
+ shape: BUMP_SHAPES[shapeWrap % BUMP_SHAPES.length],
2271
+ dash: dashRole ? dashToken(env.theme, dashRole) : void 0
2272
+ };
2273
+ };
2274
+ if (!env.isBump) return slot;
2275
+ let capacity = bumpRampLen * BUMP_SHAPES.length * BUMP_DASH_ROLES.length, autoIdentity = domain.dataSeries.filter((s) => !s.fill).length;
2276
+ if (autoIdentity > capacity)
2277
+ throw new NormalizeError(
2278
+ "bump-identity-exhausted",
2279
+ "series",
2280
+ `${autoIdentity} entities exceed the ${capacity} distinguishable identities theme '${env.theme.name}' can give a rank line (${bumpRampLen} ramp colours x ${BUMP_SHAPES.length} marker shapes x ${BUMP_DASH_ROLES.length} line styles) \u2014 past that two entities would be drawn identically and a crossing between them could not be read at all`,
2281
+ "rank fewer entities, give the extra series an explicit `fill`, or facet into small multiples with grid repeat"
2282
+ );
2283
+ if (autoIdentity > bumpRampLen) {
2284
+ let channels = autoIdentity > bumpRampLen * BUMP_SHAPES.length ? "the TRIPLE (colour, marker shape, line style)" : "the PAIR (colour, marker shape)";
2285
+ warnings.push({
2286
+ code: "bump-identity-crowded",
2287
+ severity: "info",
2288
+ message: `${autoIdentity} entities exceed the ${bumpRampLen}-colour ramp \u2014 identity is ${channels} from entity ${bumpRampLen + 1} on, so two lines of the same colour are told apart by their markers`
2289
+ });
2290
+ }
2291
+ return slot;
2292
+ }
2293
+ function bumpStoryPaintsOf(env, domain, grey) {
2294
+ if (!env.isBump || !env.anyHighlight || !grey) return;
2295
+ let story = [...env.highlights].filter((id) => domain.drawnSeries.some((s) => s.id === id));
2296
+ if (story.length === 0) return;
2297
+ let paints = bumpStoryPaints(env.theme, Math.min(story.length, 2));
2298
+ return {
2299
+ paintOf: (id) => {
2300
+ let index = story.indexOf(id);
2301
+ if (index < 0) return { token: "neutralLight" };
2302
+ if (index < 2) return paints[index];
2303
+ let paint = { token: "focus", theme: { kind: "bump-story", index, count: story.length } };
2304
+ return paintColor(env.theme, paint), paint;
2305
+ },
2306
+ isContext: (s) => !env.highlights.has(s.id) && !s.colorRole && !s.fill
2307
+ };
2308
+ }
2309
+ function linePaints(env, domain, warnings) {
2310
+ let { theme, highlights, anyHighlight, isBump, paletteRamp } = env, { options, cats, drawnSeries, dataSeries, isStacked, isArea, pv, rowOf } = domain, palette = paletteRamp ? options.palette : void 0, fade = anyHighlight && options.highlightMode === "fade", grey = (anyHighlight || drawnSeries.some((s) => !s.fill && s.colorRole === "highlight")) && !fade, faded = (paint, s) => fade && !highlights.has(s.id) ? fadedPaint(paint) : paint, css = (paint) => paintColor(theme, paint), markersOff = theme.marks?.lineMarkers === "none", paintCategoryIndex = new Map(cats.map((category, index) => [category.id, index])), shadedBandRanges = (options.annotations ?? []).flatMap((annotation) => {
2311
+ if (annotation.kind !== "band" || (annotation.style ?? "shade") !== "shade") return [];
2312
+ if (annotation.from === void 0 || annotation.to === void 0) return [];
2313
+ let from = paintCategoryIndex.get(annotation.from), to = paintCategoryIndex.get(annotation.to);
2314
+ return from === void 0 || to === void 0 ? [] : [[Math.min(from, to), Math.max(from, to)]];
2315
+ }), seriesCrossesShadedBand = (series2) => {
2316
+ if (shadedBandRanges.length === 0) return !1;
2317
+ if (isStacked) return !0;
2318
+ let indices = pv[rowOf.get(series2)].flatMap((value, index) => value === null ? [] : [index]);
2319
+ if (indices.some((index) => shadedBandRanges.some(([from, to]) => index >= from && index <= to))) return !0;
2320
+ for (let position = 1; position < indices.length; position++) {
2321
+ let left = indices[position - 1], right = indices[position];
2322
+ if (!(!series2.interpolateGaps && right !== left + 1) && shadedBandRanges.some(([from, to]) => left <= to && right >= from))
2323
+ return !0;
2324
+ }
2325
+ return !1;
2326
+ }, bandRules = /* @__PURE__ */ new Map(), shadeSafeStroke = (paint, series2, authored = paint) => {
2327
+ if (!seriesCrossesShadedBand(series2)) return paint;
2328
+ let authoredSource = series2.fill ? "fill" : anyHighlight && highlights.has(series2.id) ? "highlight" : null, source = { kind: "line-band", base: paint, seriesId: series2.id }, result = { token: "token" in paint ? paint.token : "inkMuted", theme: source };
2329
+ return css(result), authoredSource && bandRules.set(series2.id, { kind: "line-band-authored-contrast", base: paint, seriesId: series2.id, authoredSource, ...authored !== paint ? { authored } : {} }), result;
2330
+ }, areaLead = isArea && !isStacked && drawnSeries.length > 1 ? drawnSeries.find((s) => highlights.has(s.id) || s.colorRole === "highlight") ?? drawnSeries[0] : void 0;
2331
+ areaLead && warnings.push({
2332
+ code: "line-area-lead",
2333
+ severity: "info",
2334
+ message: `the area variant fills one series when it draws several, so no fill hides another or reads as a stacked band: '${areaLead.label}' is filled and the other ${drawnSeries.length - 1 === 1 ? "series is a line" : `${drawnSeries.length - 1} series are lines`}`,
2335
+ suggest: "highlight the series to fill; use variant 'stacked-area' when the series add up to a total, or 'line' to compare them as peers"
2336
+ });
2337
+ let areaFilled = (s) => isArea && !domain.phases && (areaLead === void 0 || s.id === areaLead.id), { heroMode, heroId } = heroPlan(env, domain, warnings), bumpSlot = bumpIdentity(env, domain, warnings), bumpStory = bumpStoryPaintsOf(env, domain, grey), contextRank = /* @__PURE__ */ new Map();
2338
+ for (let s of drawnSeries)
2339
+ (grey ? !highlights.has(s.id) && !s.colorRole && !s.fill : heroMode && s.id !== heroId) && contextRank.set(s.id, contextRank.size);
2340
+ let plainGrey = grey && !isBump && (domain.variant === "line" || areaLead !== void 0) && drawnSeries.every((s) => highlights.has(s.id) || contextRank.has(s.id) || s.colorRole === "highlight" || areaFilled(s)), contextRungCount = Math.min(CONTEXT_LADDER_INK_SHARE.length, contextRank.size), ladderPaint = (inkShare) => inkShare === 0 ? { token: "neutralLight" } : mixedPaint({ token: "neutralLight" }, { token: "markInk" }, 1 - inkShare, "neutralLight"), linesCross = (a, b) => {
2341
+ let rowA = pv[rowOf.get(a)], rowB = pv[rowOf.get(b)];
2342
+ return new Set(rowA.flatMap((value, index) => {
2343
+ let other = rowB[index];
2344
+ return value === null || other === null || other === void 0 || value === other ? [] : [Math.sign(value - other)];
2345
+ })).size === 2;
2346
+ }, contextSeries = drawnSeries.filter((s) => contextRank.has(s.id)), darkShare = (s) => LINE_GREY_LADDER_INK_SHARE[contextRank.get(s.id) % LINE_GREY_LADDER_INK_SHARE.length], crossingPairs = plainGrey && !isStacked ? contextSeries.flatMap((a, i) => contextSeries.slice(i + 1).filter((b) => linesCross(a, b)).map((b) => [darkShare(a), darkShare(b)])) : [], ladder = plainGrey && crossingPairs.every(([a, b]) => palettePerceptualDistance(css(ladderPaint(a)), css(ladderPaint(b))) >= PALETTE_NORMAL_FLOOR) ? LINE_GREY_LADDER_INK_SHARE : CONTEXT_LADDER_INK_SHARE, top = CONTEXT_LADDER_INK_SHARE[CONTEXT_LADDER_INK_SHARE.length - 1], ladderPaintOf = /* @__PURE__ */ new Map();
2347
+ for (let s of drawnSeries) {
2348
+ let rank = contextRank.get(s.id);
2349
+ if (rank === void 0) continue;
2350
+ let apartFrom = isStacked ? [] : drawnSeries.flatMap((other) => {
2351
+ let paint = ladderPaintOf.get(other.id);
2352
+ return paint && linesCross(s, other) ? [paint] : [];
2353
+ });
2354
+ if (crossingPairs.length > 0) {
2355
+ let result = { token: "neutralLight", theme: { kind: "line-apart", share: CONTEXT_LADDER_INK_SHARE[rank % CONTEXT_LADDER_INK_SHARE.length], top, apartFrom, darker: { share: darkShare(s), pairs: crossingPairs } } };
2356
+ css(result), ladderPaintOf.set(s.id, result);
2357
+ continue;
2358
+ }
2359
+ let share = ladder[rank % ladder.length];
2360
+ ladderPaintOf.set(s.id, apartFrom.length === 0 ? ladderPaint(share) : {
2361
+ token: "neutralLight",
2362
+ theme: { kind: "line-apart", share, top, apartFrom }
2363
+ });
2364
+ }
2365
+ let contextPaint = (s) => {
2366
+ let rank = (contextRank.get(s.id) ?? 0) % CONTEXT_LADDER_INK_SHARE.length;
2367
+ if (seriesCrossesShadedBand(s)) {
2368
+ let result = { token: "neutralLight", theme: { kind: "line-context", rank, rungCount: contextRungCount, seriesId: s.id } };
2369
+ return css(result), result;
2370
+ }
2371
+ return ladderPaintOf.get(s.id) ?? ladderPaint(ladder[rank % ladder.length]);
2372
+ }, planStyleOf = (s) => !areaFilled(s) && !isBump ? planLineStyle(s.scenario, theme) : void 0, lineHollowOf = (s) => planStyleOf(s) !== void 0, scenarioStyleOf = (s) => s.scenario === void 0 ? void 0 : {
2373
+ ...planStyleOf(s),
2374
+ ...options.scenarioStyle?.[s.scenario]
2375
+ }, areaTint = theme.marks?.areaTint, themedArea = (s) => areaTint !== void 0 && isArea && !isStacked && drawnSeries.length === 1 && !palette && !s.fill && !s.colorRole && !scenarioStyleOf(s)?.ink && s.scenario !== "PY" && s.scenario !== "PL", slots = rampSlots(theme, dataSeries.map((s) => {
2376
+ let ink = scenarioStyleOf(s)?.ink;
2377
+ return s.fill ? { css: s.fill } : isArea && grey && highlights.has(s.id) ? { token: "focus" } : s.colorRole ? markRolePaint(s.colorRole, isArea) : ink ? { token: ink } : void 0;
2378
+ }), palette, !grey && !heroMode && !isBump && options.emphasis !== "ordered" && dataSeries.length > 1 ? { labels: dataSeries.map((s) => s.label), warnings } : void 0), quietRest = options.emphasis === "ordered" && (options.othersShade ?? DEFAULT_OTHERS_SHADE) === "quietest" && dataSeries.some((s) => s.colorRole === "others" && !s.fill);
2379
+ quietRest && pushAll(warnings, othersShadeUnavailableWarnings(theme, { token: "markInk" }));
2380
+ let ordered = (s) => options.emphasis === "ordered" && !s.colorRole && !(grey && highlights.has(s.id)), series = (s, dataIdx) => {
2381
+ let paint, scenarioInk = scenarioStyleOf(s)?.ink;
2382
+ return themedArea(s) ? paint = { token: "markInk" } : s.fill ? paint = { css: s.fill } : ordered(s) ? paint = orderedRampPaint(dataIdx, dataSeries.length, quietRest) : bumpStory && !s.colorRole ? paint = bumpStory.paintOf(s.id) : grey ? paint = highlights.has(s.id) ? { token: "focus" } : s.colorRole ? markRolePaint(s.colorRole) : contextPaint(s) : heroMode ? paint = s.id === heroId ? { token: "markInk" } : contextPaint(s) : s.colorRole ? paint = markRolePaint(s.colorRole) : scenarioInk ? paint = { token: scenarioInk } : dataSeries.length === 1 ? paint = seriesPaint(dataIdx, palette, s.scenario) : paint = seriesPaint(isBump ? bumpSlot(dataIdx).color : slots[dataIdx] ?? dataIdx, palette), shadeSafeStroke(faded(paint, s), s, paint);
2383
+ }, areaFillOwn = (s, dataIdx, forecast = !1) => {
2384
+ if (themedArea(s)) return forecast ? { token: "focus" } : { token: "focus", tint: areaTint };
2385
+ if (s.fill) return { css: s.fill };
2386
+ if (ordered(s)) return orderedRampPaint(dataIdx, dataSeries.length, quietRest);
2387
+ if (grey && highlights.has(s.id)) return { token: "focus" };
2388
+ if (s.colorRole) return markRolePaint(s.colorRole, !0);
2389
+ let scenarioInk = scenarioStyleOf(s)?.ink;
2390
+ return scenarioInk ? { token: scenarioInk } : dataSeries.length === 1 ? seriesPaint(dataIdx, palette, s.scenario) : seriesPaint(slots[dataIdx] ?? dataIdx, palette);
2391
+ }, areaFill = (s, dataIdx, forecast = !1) => faded(areaFillOwn(s, dataIdx, forecast), s), keyPaint = (s, dataIdx) => areaFilled(s) && !themedArea(s) ? areaFill(s, dataIdx) : !isArea && s.scenario === "FC" && domain.variant !== "line" ? forecastStroke(series(s, dataIdx), theme, seriesCrossesShadedBand(s)) : series(s, dataIdx), { fanLadder, fanCentrePaint, fanPaints } = buildFanPaints({
2392
+ fan: domain.fan,
2393
+ drawnSeries,
2394
+ seriesPaint: series,
2395
+ paintCss: css,
2396
+ theme,
2397
+ anyHighlight,
2398
+ highlights
2399
+ }), dashOf = (s, dataIdx) => s.lineStyle === "dashed" ? dashToken(theme, "reference") : s.lineStyle === "dotted" ? dashToken(theme, "dotted") : isBump ? bumpSlot(dataIdx).dash : void 0, pointScenario = (s, ci) => s.vals[ci].scenario ?? s.scenario;
2400
+ return {
2401
+ css,
2402
+ bandRules: () => [...bandRules.values()],
2403
+ seriesCrossesShadedBand,
2404
+ series,
2405
+ areaFill,
2406
+ areaFilled,
2407
+ keyPaint,
2408
+ lineHollowOf,
2409
+ lineWidthOf: (s) => themedArea(s) ? strokeToken(theme, "data") : anyHighlight && highlights.has(s.id) ? strokeToken(theme, "focus") : heroId ? s.id === heroId ? strokeToken(theme, "focus") : strokeToken(theme, "data") : bumpStory?.isContext(s) ? strokeToken(theme, "mark") : scenarioStyleOf(s)?.width ?? strokeToken(theme, "data"),
2410
+ ref: (s) => s.fill ? { css: s.fill } : s.colorRole ? { token: markRoleToken(s.colorRole) } : { token: "ink" },
2411
+ dashOf,
2412
+ legendDashOf: (s, dataIdx) => s.scenario === "FC" ? dashToken(theme, "reference") : dashOf(s, dataIdx),
2413
+ // Bump ignores the density cutoff: the marker is what makes a crossing
2414
+ // readable. A partial period keeps a (hollow) marker where density drops
2415
+ // the rest. A theme without default markers drops them as the cutoff does.
2416
+ markerOf: (s, dataIdx, ci) => s.marker ?? (bumpStory ? bumpStory.isContext(s) ? "none" : "circle" : isBump ? bumpSlot(dataIdx).shape : isArea || (markersOff || cats.length > MARKER_MAX_CATS) && cats[ci].partial !== !0 ? "none" : contextRank.has(s.id) ? plainGrey ? LINE_GREY_SHAPES[contextRank.get(s.id) % LINE_GREY_SHAPES.length] : BUMP_SHAPES[contextRank.get(s.id) % BUMP_SHAPES.length] : "circle"),
2417
+ hollowAt: (s, ci) => {
2418
+ let sc = pointScenario(s, ci);
2419
+ return sc === "PY" || sc === "PL" || sc === "FC" || cats[ci].partial === !0;
2420
+ },
2421
+ pointScenario,
2422
+ // A bump point carries BOTH quantities: `display.value` stays the metric
2423
+ // and `display.state` names the rank the y position encodes.
2424
+ bumpPointState: (row, ci) => isBump && row[ci] !== null ? { state: `rank ${row[ci]}` } : {},
2425
+ heroMode,
2426
+ heroId,
2427
+ fanLadder,
2428
+ fanCentrePaint,
2429
+ fanPaints
2430
+ };
2431
+ }
2432
+
2433
+ // src/core/charts/line/referenceBands.ts
2434
+ var REFERENCE_BAND_MIN_PX = 4, COLUMN_WIDTH_FRACTION = 0.18, LANE_START = 4, LANE_STEP = 3, RUN_IN = 8, ENTRY_GAP = 4, EDGE_AIR = 4, LEVEL_TOLERANCE = 1.5;
2435
+ function wrapEntry(label, description, nameFont, textFont, maxWidth, measure) {
2436
+ let nameW = measure(label, nameFont).width, rows = [[]], widthOf = (row, words) => (row === 0 ? nameW : 0) + (words.length === 0 ? 0 : measure(`${row === 0 ? " " : ""}${words.join(" ")}`, textFont).width);
2437
+ for (let word of description?.split(/\s+/u) ?? []) {
2438
+ let row = rows.length - 1, next = [...rows[row], word];
2439
+ widthOf(row, next) <= maxWidth || row > 0 && rows[row].length === 0 ? rows[row] = next : rows.push([word]);
2440
+ }
2441
+ return { lines: rows.map((words, row) => {
2442
+ if (row > 0) return { text: words.join(" "), nameOnly: !1 };
2443
+ if (words.length === 0) return { text: label, nameOnly: !0 };
2444
+ let rest = ` ${words.join(" ")}`;
2445
+ return { text: `${label}${rest}`, runs: [{ text: label, weight: nameFont.weight }, { text: rest, weight: textFont.weight }], nameOnly: !1 };
2446
+ }), width: Math.max(...rows.map((words, row) => widthOf(row, words))) };
2447
+ }
2448
+ function planReferenceBandColumn(bands, canvasWidth, font, measure) {
2449
+ if (!bands?.length) return;
2450
+ let textFont = font, nameFont = font, widestName = maxOf(bands.map((band) => measure(band.label, nameFont).width)), maxWidth = Math.max(COLUMN_WIDTH_FRACTION * canvasWidth, widestName), taken = new Set(bands.flatMap((band) => band.id === void 0 ? [] : [band.id])), idOf = (index) => {
2451
+ let n = index + 1;
2452
+ for (; taken.has(`band-${n}`); ) n++;
2453
+ return taken.add(`band-${n}`), `band-${n}`;
2454
+ }, entries = bands.map((band, index) => {
2455
+ let low = band.value ?? band.low, high = band.value ?? band.high;
2456
+ return { id: band.id ?? idOf(index), low, high, label: band.label, description: band.description, ...wrapEntry(band.label, band.description, nameFont, textFont, maxWidth, measure) };
2457
+ }), gutter = LANE_START + LANE_STEP * (bands.length - 1) + RUN_IN, width = maxOf(entries.map((entry) => entry.width)), lineH = font.size * (font.lineHeight ?? 1.2);
2458
+ return {
2459
+ entries,
2460
+ gutter,
2461
+ reserve: gutter + width + EDGE_AIR,
2462
+ nameFont,
2463
+ textFont,
2464
+ lineH,
2465
+ minHeight: entries.reduce((sum, entry) => sum + entry.lines.length * lineH, 0) + Math.max(0, entries.length - 1) * ENTRY_GAP
2466
+ };
2467
+ }
2468
+ function overlapWarnings(entries, warnings) {
2469
+ entries.forEach((a, i) => {
2470
+ for (let b of entries.slice(i + 1))
2471
+ a.low > b.high || b.low > a.high || warnings.push({
2472
+ code: "reference-band-overlap",
2473
+ severity: "warn",
2474
+ message: `reference bands '${a.id}' and '${b.id}' overlap (${a.low}\u2013${a.high} and ${b.low}\u2013${b.high}), so the reader cannot tell which name a value in the shared span belongs to`,
2475
+ suggest: "give each band its own span, or merge the two into one band"
2476
+ });
2477
+ });
2478
+ }
2479
+ function unexplainedWarnings(entries, warnings) {
2480
+ for (let entry of entries)
2481
+ /\p{L}/u.test(`${entry.label} ${entry.description ?? ""}`) || warnings.push({
2482
+ code: "reference-band-unexplained",
2483
+ severity: "warn",
2484
+ message: `reference band '${entry.id}' is named '${entry.label}' only, which repeats the value axis without saying what the level means`,
2485
+ suggest: "add a description, such as 'typical cycle'"
2486
+ });
2487
+ }
2488
+ function layoutReferenceBands(theme, input) {
2489
+ let { column, plot, y, claims, warnings } = input, { entries, lineH } = column;
2490
+ overlapWarnings(entries, warnings), unexplainedWarnings(entries, warnings);
2491
+ let bands = [], nodes = [], bottom = plot.y + plot.h, levels = entries.map((entry) => {
2492
+ let a = y(entry.low), b = y(entry.high), h = Math.max(Math.abs(a - b), REFERENCE_BAND_MIN_PX), top = Math.min(Math.max((a + b) / 2 - h / 2, plot.y), bottom - h), owner = { annotationId: `referenceBand:${entry.id}` };
2493
+ return bands.push({ t: "rect", id: `referenceBand:${entry.id}`, rect: { x: plot.x, y: top, w: plot.w, h }, fill: { token: "neutralLight" }, owner, part: "referenceBand" }), top + h / 2;
2494
+ }), heights = entries.map((entry) => entry.lines.length * lineH), spread = spread1DResult(entries.map((_, i) => ({ desired: levels[i] - lineH / 2 + heights[i] / 2, size: heights[i] })), [plot.y, bottom], ENTRY_GAP);
2495
+ warnSpreadOverflow(warnings, spread.fits, `reference bands: the ${entries.length} names need more height than the plot has, so some touch; shorten the descriptions or drop a band`);
2496
+ let edge = plot.x + plot.w, nameX = edge + column.gutter, tops = spread.positions.map((centre, i) => centre - heights[i] / 2), shift = entries.map((_, i) => tops[i] + lineH / 2 - levels[i]), lane = /* @__PURE__ */ new Map(), byLevel = entries.map((_, i) => i).sort((a, b) => levels[a] - levels[b] || a - b);
2497
+ return byLevel.filter((i) => shift[i] < -LEVEL_TOLERANCE).forEach((i, k) => lane.set(i, k)), byLevel.reverse().filter((i) => shift[i] > LEVEL_TOLERANCE).forEach((i, k) => lane.set(i, k)), entries.forEach((entry, i) => {
2498
+ let owner = { annotationId: `referenceBand:${entry.id}` }, top = tops[i], k = lane.get(i);
2499
+ if (k !== void 0) {
2500
+ let from = levels[i], to = top + lineH / 2, elbow = edge + LANE_START + LANE_STEP * k;
2501
+ nodes.push({ t: "path", id: `referenceBand:${entry.id}:leader`, d: `M${edge} ${from}H${elbow}V${to}H${nameX - 2}`, stroke: { token: "leader" }, width: strokeToken(theme, "rule"), owner, part: "leader" }), claims.claim({ x: edge, y: from - 0.5, w: elbow - edge, h: 1 }, "annotation", owner, "referenceBandLeader"), claims.claim({ x: elbow - 0.5, y: Math.min(from, to), w: 1, h: Math.abs(to - from) }, "annotation", owner, "referenceBandLeader"), claims.claim({ x: elbow, y: to - 0.5, w: nameX - elbow, h: 1 }, "annotation", owner, "referenceBandLeader");
2502
+ }
2503
+ entry.lines.forEach((line, row) => {
2504
+ nodes.push({
2505
+ t: "text",
2506
+ id: `referenceBand:${entry.id}:line${row + 1}`,
2507
+ x: nameX,
2508
+ y: top + row * lineH,
2509
+ lines: [line.text],
2510
+ ...line.runs ? { runs: line.runs } : {},
2511
+ align: "start",
2512
+ typeRole: "label",
2513
+ font: line.nameOnly ? column.nameFont : column.textFont,
2514
+ ink: { token: "ink" },
2515
+ owner,
2516
+ part: "referenceBandLabel",
2517
+ role: "note"
2518
+ });
2519
+ }), claims.claim({ x: nameX, y: top, w: entry.width, h: heights[i] }, "annotation", owner, "referenceBandLabel");
2520
+ }), { bands, column: nodes };
2521
+ }
2522
+ function referenceBandsA11y(column, fmt, options) {
2523
+ if (!column) return "";
2524
+ let span = (entry) => entry.low === entry.high ? fmt(entry.low) : chartString2(options, "spanText", { v1: fmt(entry.low), v2: fmt(entry.high) });
2525
+ return chartString2(options, "referenceBandsSentence", { v1: column.entries.map((entry) => `${span(entry)} (${[entry.label, entry.description].filter(Boolean).join(" ")})`).join(", ") });
2526
+ }
2527
+
2528
+ // src/core/charts/line/adjacent.ts
2529
+ function lineSeriesAdjacentWarnings(input) {
2530
+ let byId = new Map(input.nodes.map((node) => [node.id, node])), categoryIndexes = new Map(input.cats.map((category, index) => [category.id, index])), samples = [];
2531
+ for (let mark of input.marks.series) {
2532
+ let index = input.drawnSeries.findIndex((series2) => series2.id === mark.seriesId);
2533
+ if (index < 0) continue;
2534
+ let filled = input.isArea && mark.areaNodeId !== void 0, nodeId = filled ? mark.areaNodeId : mark.pathNodeId ?? mark.fcPathNodeId ?? mark.points.find((point) => point.nodeId)?.nodeId, node = nodeId ? byId.get(nodeId) : void 0, paint = node && ("fill" in node && filled ? node.fill : "stroke" in node ? node.stroke : "fill" in node ? node.fill : void 0);
2535
+ if (!paint) continue;
2536
+ let css = input.paintCss(paint), series = input.drawnSeries[index], forecastStart2 = series.scenario === "FC" ? 0 : series.vals.findIndex((value) => value.scenario === "FC"), highlighted = input.highlights.has(mark.seriesId) || "token" in paint && (paint.token === "highlight" || paint.token === "focus");
2537
+ for (let point of mark.points) {
2538
+ let categoryIndex = categoryIndexes.get(point.categoryId);
2539
+ if (filled && !input.paintedAreaCats.get(mark.seriesId)?.has(categoryIndex)) continue;
2540
+ let hatched = filled && forecastStart2 >= 0 && categoryIndex >= forecastStart2;
2541
+ samples.push({
2542
+ seriesId: mark.seriesId,
2543
+ categoryId: point.categoryId,
2544
+ // A hatch in the series' own colour is read by its stripes, as adjacentSeries.ts reads bars;
2545
+ // only an ink hatch, one stripe colour for all, differs by its wash.
2546
+ css: hatched && input.theme.pattern.hatchColor === "ink" ? effectiveFill(css, "hatch45", input.theme) : css,
2547
+ highlighted,
2548
+ paint,
2549
+ ...hatched ? { pattern: "hatch45", byStripe: !0 } : {},
2550
+ from: input.isStacked ? input.cumBot[index][categoryIndex] : point.y,
2551
+ to: input.isStacked ? input.cumTop[index][categoryIndex] : point.y
2552
+ });
2553
+ }
2554
+ }
2555
+ return retainAdjacentWarningRule(samples, input.isStacked, input.capture), adjacentSeriesWarnings(samples, input.isStacked, input.theme);
2556
+ }
2557
+
2558
+ // src/core/charts/line/difference.ts
2559
+ function resolveGapFillSeries(input) {
2560
+ let { gapFill, seriesById, warnings } = input;
2561
+ if (!gapFill) return null;
2562
+ let [aId, bId] = gapFill.between, a = seriesById.get(aId), b = seriesById.get(bId);
2563
+ for (let missingId of [a ? null : aId, b ? null : bId])
2564
+ missingId !== null && warnings.push({
2565
+ code: "gapfill-unknown-series",
2566
+ severity: "error",
2567
+ message: `gapFill names unknown series '${missingId}'`,
2568
+ owner: { seriesId: missingId }
2569
+ });
2570
+ return a && b && a.id !== b.id ? [a, b] : (a && b && warnings.push({
2571
+ code: "gapfill-unknown-series",
2572
+ severity: "error",
2573
+ message: `gapFill requires two distinct series ids; received '${a.id}' twice`,
2574
+ owner: { seriesId: a.id }
2575
+ }), null);
2576
+ }
2577
+ function resolveInterpolation(input) {
2578
+ let { gapFillSeries, interpolationFor, warnings } = input, a = interpolationFor(gapFillSeries[0]), b = interpolationFor(gapFillSeries[1]);
2579
+ return a !== b ? (warnings.push({
2580
+ code: "gapfill-interpolation-conflict",
2581
+ severity: "warn",
2582
+ message: `gapFill boundaries use different interpolation (${a} vs ${b}) \u2014 fill suppressed rather than drawing a wash that follows neither curve`,
2583
+ suggest: "give both boundary series the same smooth setting"
2584
+ }), null) : a === "monotone" ? (warnings.push({
2585
+ code: "gapfill-monotone-unsupported",
2586
+ severity: "warn",
2587
+ message: "gapFill crossing partitions are linear/step exact but do not yet solve cubic intersections \u2014 fill suppressed while both monotone lines remain visible",
2588
+ suggest: "use interpolate:'linear' for this gapFill exhibit"
2589
+ }), null) : a;
2590
+ }
2591
+ function collectGapRegions(input) {
2592
+ let { cats, seriesA, seriesB, rowA, rowB, interpolation, compositionInvalidAt, xOf, y } = input, regions = [], active = null, samePoint = (a, b) => a.x === b.x && a.yA === b.yA && a.yB === b.yB, appendPiece = (sign, start, end) => {
2593
+ if (samePoint(start, end)) return;
2594
+ let tail = active?.points.at(-1);
2595
+ if (active?.sign === sign && tail?.x === start.x) {
2596
+ samePoint(tail, start) || active.points.push(start), samePoint(active.points.at(-1), end) || active.points.push(end);
2597
+ return;
2598
+ }
2599
+ active = { sign, points: [start, end] }, regions.push(active);
2600
+ }, connectsAcross = (series, fromCi, toCi) => series.interpolateGaps && (!input.range || fromCi >= input.range.indexes[0] && toCi <= input.range.indexes[input.range.indexes.length - 1]) || (input.range?.values.get(series.id) ?? series.vals).slice(fromCi + 1, toCi).every((value) => value.v !== null), previousCi = null;
2601
+ for (let ci of input.range ? rangeIndexes(input.range) : cats.keys()) {
2602
+ if (compositionInvalidAt(ci)) {
2603
+ active = null, previousCi = null;
2604
+ continue;
2605
+ }
2606
+ let a1 = rowA[ci], b1 = rowB[ci];
2607
+ if (!(a1 === null || b1 === null)) {
2608
+ if (previousCi !== null) {
2609
+ let a0 = rowA[previousCi], b0 = rowB[previousCi];
2610
+ if (!(a0 !== null && b0 !== null && connectsAcross(seriesA, previousCi, ci) && connectsAcross(seriesB, previousCi, ci))) active = null;
2611
+ else if (interpolation === "linear") {
2612
+ let start = { ci: previousCi, x: xOf(previousCi), yA: y(a0), yB: y(b0) }, end = { ci, x: xOf(ci), yA: y(a1), yB: y(b1) }, d0 = a0 - b0, d1 = a1 - b1;
2613
+ if (d0 * d1 < 0) {
2614
+ let fraction = d0 / (d0 - d1), crossingValue = a0 + (a1 - a0) * fraction, crossing = { ci, x: start.x + (end.x - start.x) * fraction, yA: y(crossingValue), yB: y(crossingValue) };
2615
+ appendPiece(d0 > 0 ? "positive" : "negative", start, crossing), active = null, appendPiece(d1 > 0 ? "positive" : "negative", crossing, end);
2616
+ } else {
2617
+ let nonzero = d0 !== 0 ? d0 : d1;
2618
+ nonzero !== 0 ? appendPiece(nonzero > 0 ? "positive" : "negative", start, end) : active = null;
2619
+ }
2620
+ } else {
2621
+ let heldCi = interpolation === "step-after" ? previousCi : ci, heldA = rowA[heldCi], heldB = rowB[heldCi], diff = heldA - heldB;
2622
+ diff === 0 ? active = null : appendPiece(diff > 0 ? "positive" : "negative", { ci: previousCi, x: xOf(previousCi), yA: y(heldA), yB: y(heldB) }, { ci, x: xOf(ci), yA: y(heldA), yB: y(heldB) });
2623
+ }
2624
+ }
2625
+ previousCi = ci;
2626
+ }
2627
+ }
2628
+ return regions;
2629
+ }
2630
+ function gapFillPaint(tone) {
2631
+ return separatedWashPaint(tone === "good" ? "goodFill" : tone === "bad" ? "badFill" : tone, "surface-gap");
2632
+ }
2633
+ function addGapRegion(input) {
2634
+ let { region, regionIndex, seriesA, seriesB, gapFill, cats, occupied, nodes, marks } = input;
2635
+ if (region.points.length < 2) return;
2636
+ let upper = region.points.map((point) => ({ x: point.x, y: point.yA })), lower = [...region.points].reverse().map((point) => ({ x: point.x, y: point.yB })), tone = region.sign === "positive" ? gapFill.positiveTone ?? "good" : gapFill.negativeTone ?? "bad", nodeId = `mark:gapfill:${seriesA.id}:${seriesB.id}:${regionIndex}`;
2637
+ nodes.push({
2638
+ t: "path",
2639
+ id: nodeId,
2640
+ d: `${linePath(upper)}${lower.map((point) => `L${fmtPathNumber(point.x)} ${fmtPathNumber(point.y)}`).join("")}Z`,
2641
+ fill: gapFillPaint(tone),
2642
+ owner: {},
2643
+ part: "gapFill"
2644
+ });
2645
+ for (let pointIndex = 0; pointIndex + 1 < region.points.length; pointIndex++) {
2646
+ let a = region.points[pointIndex], b = region.points[pointIndex + 1];
2647
+ occupied.claim({
2648
+ x: Math.min(a.x, b.x),
2649
+ y: Math.min(a.yA, a.yB, b.yA, b.yB),
2650
+ w: Math.max(Math.abs(b.x - a.x), 1),
2651
+ h: Math.max(Math.max(a.yA, a.yB, b.yA, b.yB) - Math.min(a.yA, a.yB, b.yA, b.yB), 1)
2652
+ }, "mark", {}, "gapFill");
2653
+ }
2654
+ marks.push({
2655
+ nodeId,
2656
+ sign: region.sign,
2657
+ fromCategoryId: cats[region.points[0].ci].id,
2658
+ toCategoryId: cats[region.points.at(-1).ci].id
2659
+ });
2660
+ }
2661
+ function renderGapFill(input) {
2662
+ let { gapFillSeries, gapFill, interpolationFor, pv, rowOf, cats, compositionInvalidAt, xOf, y, warnings, occupied, nodes, marks, analyticalSceneStart } = input;
2663
+ if (!gapFillSeries || !gapFill) return;
2664
+ let interpolation = resolveInterpolation({ gapFillSeries, interpolationFor, warnings });
2665
+ if (!interpolation) return;
2666
+ let [seriesA, seriesB] = gapFillSeries, range = input.range, regions = collectGapRegions({
2667
+ cats,
2668
+ seriesA,
2669
+ seriesB,
2670
+ rowA: pv[rowOf.get(seriesA)],
2671
+ rowB: pv[rowOf.get(seriesB)],
2672
+ interpolation,
2673
+ compositionInvalidAt,
2674
+ xOf,
2675
+ y,
2676
+ ...range && input.xOfValue ? {
2677
+ range,
2678
+ cats: range.categories,
2679
+ rowA: range.plotted[rowOf.get(seriesA)],
2680
+ rowB: range.plotted[rowOf.get(seriesB)],
2681
+ compositionInvalidAt: (ci) => range.invalid.has(ci),
2682
+ xOf: (ci) => input.xOfValue(range.xs[ci])
2683
+ } : {}
2684
+ });
2685
+ if (range && input.xOfValue) {
2686
+ let visible = new Map(range.indexes.map((source, ci) => [source, ci]));
2687
+ regions = regions.flatMap((region) => {
2688
+ let clipped = ["yA", "yB"].map((key) => cutEdge(
2689
+ { points: region.points.map((p) => ({ x: p.x, y: p[key], ci: visible.get(p.ci) ?? (p.ci < range.indexes[0] ? 0 : cats.length - 1) })) },
2690
+ "linear",
2691
+ input.xOfValue(range.lo),
2692
+ input.xOfValue(range.hi)
2693
+ ).points);
2694
+ return clipped[0].length < 2 ? [] : [{ sign: region.sign, points: clipped[0].map((p, i) => ({ ci: p.ci, x: p.x, yA: p.y, yB: clipped[1][i].y })) }];
2695
+ });
2696
+ }
2697
+ let gapFillNodes = [], gapFillMarks = [];
2698
+ if (regions.forEach((region, regionIndex) => addGapRegion({ region, regionIndex, seriesA, seriesB, gapFill, cats, occupied, nodes: gapFillNodes, marks: gapFillMarks })), gapFillNodes.length === 0) {
2699
+ warnings.push({ code: "gapfill-no-area", severity: "info", message: `gapFill '${seriesA.id}' vs '${seriesB.id}' has no non-zero shared region` });
2700
+ return;
2701
+ }
2702
+ marks.gapFills = gapFillMarks;
2703
+ let analyticalNodes = nodes.splice(analyticalSceneStart), areas = analyticalNodes.filter((node) => node.part === "area"), baseline = analyticalNodes.filter((node) => node.part === "baseline"), foreground = analyticalNodes.filter((node) => node.part !== "area" && node.part !== "baseline");
2704
+ pushAll(nodes, areas), pushAll(nodes, gapFillNodes), pushAll(nodes, baseline), pushAll(nodes, foreground);
2705
+ }
2706
+ function targetCandidates(cx, cy, measured) {
2707
+ return [
2708
+ { slot: "above", rect: { x: cx - measured.width / 2, y: cy - measured.height - 8, w: measured.width, h: measured.height }, penalty: 0 },
2709
+ { slot: "below", rect: { x: cx - measured.width / 2, y: cy + 8, w: measured.width, h: measured.height }, penalty: 1 },
2710
+ { slot: "right", rect: { x: cx + 9, y: cy - measured.height / 2, w: measured.width, h: measured.height }, penalty: 2 },
2711
+ { slot: "left", rect: { x: cx - measured.width - 9, y: cy - measured.height / 2, w: measured.width, h: measured.height }, penalty: 3 },
2712
+ // The quadrants a dashed goal path leaves free where it runs through the goal.
2713
+ { slot: "aboveRight", rect: { x: cx + 6, y: cy - measured.height - 6, w: measured.width, h: measured.height }, penalty: 4 },
2714
+ { slot: "belowLeft", rect: { x: cx - measured.width - 6, y: cy + 6, w: measured.width, h: measured.height }, penalty: 5 },
2715
+ { slot: "aboveLeft", rect: { x: cx - measured.width - 6, y: cy - measured.height - 6, w: measured.width, h: measured.height }, penalty: 6 },
2716
+ { slot: "belowRight", rect: { x: cx + 6, y: cy + 6, w: measured.width, h: measured.height }, penalty: 7 }
2717
+ ];
2718
+ }
2719
+ function namesValue(name, value) {
2720
+ let escaped = value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2721
+ return new RegExp(`(^|(?<!\\d)\\s)${escaped}[%).]*$`, "u").test(name.trim());
2722
+ }
2723
+ function addTarget(theme, input) {
2724
+ let { target, categoryOrder, xOf, y, nodes, occupied, fmt, labelFont, measure, labelRequests, plot, targetLabelIds } = input, right = Math.max(plot.x + plot.w, input.rightEdge ?? 0), cx = xOf(categoryOrder.get(target.at)), cy = y(target.value);
2725
+ nodes.push({ t: "circle", id: target.id, cx, cy, r: 4.5, fill: { token: "background" }, stroke: { token: "markInk" }, strokeWidth: strokeToken(theme, "mark"), owner: { seriesId: target.seriesId, categoryId: target.at, pointId: target.id }, part: "targetMarker", display: { value: fmt(target.value) } }), occupied.claim({ x: cx - 5, y: cy - 5, w: 10, h: 10 }, "mark", { seriesId: target.seriesId, categoryId: target.at, pointId: target.id }, "targetMarker");
2726
+ let labelId;
2727
+ if (target.label) {
2728
+ labelId = `target-label:${target.id}`, targetLabelIds.add(labelId);
2729
+ let targetFont = { ...labelFont, weight: emphasisWeight(theme) }, value = fmt(target.value), lines = namesValue(target.label, value) ? [target.label] : [target.label, value], text = lines.join(" "), measured = { width: Math.max(...lines.map((line) => measure(line, targetFont).width)), height: lines.length * measure(lines[0], targetFont).height };
2730
+ labelRequests.push({
2731
+ id: labelId,
2732
+ kind: "annotation",
2733
+ owner: { seriesId: target.seriesId, categoryId: target.at, pointId: target.id },
2734
+ text,
2735
+ lines,
2736
+ align: "middle",
2737
+ typeRole: "label",
2738
+ font: targetFont,
2739
+ priority: PRIORITY.extreme,
2740
+ candidates: targetCandidates(cx, cy, measured).filter((candidate) => candidate.rect.x >= plot.x && candidate.rect.y >= plot.y && candidate.rect.x + candidate.rect.w <= right && candidate.rect.y + candidate.rect.h <= plot.y + plot.h && // The label shares its series' owner, so the solver would let it sit on that series' line
2741
+ // and point markers; a goal's name there hides the point it is compared with. An area's
2742
+ // fill claims the same way, and a label may sit on that fill, so an area keeps every seat.
2743
+ (input.areaSeries || !occupied.hits(candidate.rect, 0, (claim) => !(claim.kind === "mark" && claim.part === void 0 && claim.owner.seriesId === target.seriesId))))
2744
+ });
2745
+ }
2746
+ return { seriesId: target.seriesId, categoryId: target.at, value: target.value, nodeId: target.id, ...labelId ? { labelId } : {} };
2747
+ }
2748
+ function renderTargets(theme, input) {
2749
+ let targetLabelIds = /* @__PURE__ */ new Set();
2750
+ if (input.targets.length === 0) return targetLabelIds;
2751
+ for (let seriesId of new Set(input.targets.map((target) => target.seriesId))) {
2752
+ let targets = input.targets.filter((target) => target.seriesId === seriesId), last = input.marks.series.find((mark) => mark.seriesId === seriesId)?.points.at(-1), lastIndex = last ? input.categoryOrder.get(last.categoryId) : void 0;
2753
+ if (!last || lastIndex === void 0) continue;
2754
+ let ahead = targets.filter((target) => input.categoryOrder.get(target.at) > lastIndex).sort((a, b) => input.categoryOrder.get(a.at) - input.categoryOrder.get(b.at));
2755
+ if (ahead.length === 0) continue;
2756
+ let path = [{ x: last.x, y: last.y }, ...ahead.map((target) => ({ x: input.xOf(input.categoryOrder.get(target.at)), y: input.y(target.value) }))];
2757
+ input.nodes.push({ t: "path", id: `target-path:${seriesId}`, d: path.map((point, i) => `${i === 0 ? "M" : "L"}${fmtPathNumber(point.x)} ${fmtPathNumber(point.y)}`).join(""), stroke: { token: "markInk" }, width: strokeToken(theme, "rule"), dash: dashToken(theme, "reference"), owner: { seriesId }, part: "targetPath" }), path.slice(1).forEach((point, i) => {
2758
+ let from = path[i];
2759
+ for (let k = 0; k < 8; k++) {
2760
+ let [x0, y0] = [from.x + (point.x - from.x) * k / 8, from.y + (point.y - from.y) * k / 8], [x1, y1] = [from.x + (point.x - from.x) * (k + 1) / 8, from.y + (point.y - from.y) * (k + 1) / 8];
2761
+ input.occupied.claim({ x: Math.min(x0, x1) - 1, y: Math.min(y0, y1) - 1, w: Math.abs(x1 - x0) + 2, h: Math.abs(y1 - y0) + 2 }, "mark", {}, "targetPath");
2762
+ }
2763
+ });
2764
+ }
2765
+ let targetMarks = input.targets.map((target) => addTarget(theme, { ...input, target, targetLabelIds, areaSeries: input.marks.series.some((mark) => mark.seriesId === target.seriesId && mark.areaNodeId !== void 0) }));
2766
+ return input.marks.targets = targetMarks, targetLabelIds;
2767
+ }
2768
+
2769
+ // src/core/charts/line/scene.ts
2770
+ var INTERVAL_TICK = 4, MIN_TICK_GAP = 2, BAND_HATCH_PITCH = Math.SQRT1_2, BAND_HATCH_SHARE = 0.45;
2771
+ function bandHatch(theme, hatchStrength) {
2772
+ return {
2773
+ gap: theme.pattern.hatchGap * hatchGapFactor({ strength: hatchStrength ?? HATCH_STRENGTH_DEFAULT.second, cue: "second" }) * BAND_HATCH_PITCH,
2774
+ width: strokeToken(theme, "hair"),
2775
+ share: BAND_HATCH_SHARE * (0.5 + 0.5 * (hatchStrength ?? HATCH_STRENGTH_DEFAULT.second) / 100) / (0.5 + 0.5 * HATCH_STRENGTH_DEFAULT.second / 100)
2776
+ };
2777
+ }
2778
+ function layoutLineMarks(env, domain, area, paints, text, reserves, warnings) {
2779
+ let { theme, measure, highlights } = env, { options, drawnSeries, pv, rowOf, cats, isStacked, isArea, compositionInvalidAt, cumTop, cumBot, interpolationFor, dLo, dHi } = domain, { plot, y, xOf } = area, { tickFont, labelFont } = text, nodes = [...area.frame.nodes], latestPointSeries = options.latestPoint === void 0 || options.latestPoint === "none" ? void 0 : typeof options.latestPoint == "object" ? options.latestPoint.series : (drawnSeries.find((s) => s.id === paints.heroId) ?? domain.dataSeries.find((s) => s.scenario === void 0 || s.scenario === "AC") ?? domain.dataSeries[0])?.id, claims = createOccupiedIndex({ x: 0, y: 0, w: env.size.width, h: env.size.height }), axes = [];
2780
+ if (area.axisShown || area.disclosedTicks) {
2781
+ let axisResult = layoutValueAxis(
2782
+ {
2783
+ scale: y,
2784
+ plot,
2785
+ orient: "y",
2786
+ // A plain line with a shown value axis draws light gridlines by default;
2787
+ // a panel that shares its scale with other panels keeps their (gridless) look.
2788
+ gridlines: options.valueAxis?.gridlines ?? ((domain.variant === "line" || domain.variant === "area" && domain.drawnSeries.length === 1) && options.valueAxis?.show === !0 && options.scaleGroup === void 0),
2789
+ format: area.axisFmt,
2790
+ ...area.axisTickSpec ? { formatSpec: area.axisTickSpec } : {},
2791
+ theme,
2792
+ measure,
2793
+ ...area.bumpTicks ? { ticks: area.bumpTicks, keepEndTicks: !0 } : {},
2794
+ ...!area.bumpTicks && area.disclosedTicks ? { ticks: area.disclosedTicks } : {},
2795
+ ...!area.bumpTicks && !area.disclosedTicks && area.stepTicks ? { ticks: area.stepTicks } : {}
2796
+ },
2797
+ claims
2798
+ );
2799
+ if (area.discloseNonzeroBaseline) {
2800
+ let glyph = straightBreakGlyph(theme, { x: plot.x, y: plot.y + plot.h - 7 }, "axis:y:baseline-disclosure", {}, { token: "axis" }, "baselineDisclosure");
2801
+ axisResult.nodes.push(...glyph.nodes), claims.claim(glyph.rect, "axis", {}, "baselineDisclosure"), axisResult.axis.baselineDisclosure = { value: area.baselineValue, rect: glyph.rect, nodeIds: glyph.nodeIds };
2802
+ }
2803
+ pushAll(nodes, axisResult.nodes), axes.push(axisResult.axis);
2804
+ }
2805
+ let tickXs = domain.autoSampled ? area.intervalTicks?.flatMap((tick, ci) => tick ? [xOf(ci)] : []) : void 0, crowded = tickXs?.some((x, k) => k > 0 && x - tickXs[k - 1] < MIN_TICK_GAP) === !0;
2806
+ if (area.intervalTicks?.forEach((tick, ci) => {
2807
+ if (!tick || crowded && !area.catPlan.keep[ci]) return;
2808
+ let x = xOf(ci), top = plot.y + plot.h;
2809
+ nodes.push({ t: "line", id: `axis:x:tick:${cats[ci].id}`, x1: x, y1: top, x2: x, y2: top + INTERVAL_TICK, stroke: { token: "axis" }, width: strokeToken(theme, "rule"), owner: { categoryId: cats[ci].id }, part: "tick" }), claims.claim({ x: x - 0.5, y: top, w: 1, h: INTERVAL_TICK }, "axis", { categoryId: cats[ci].id }, "tick");
2810
+ }), area.xTicks && area.xOfValue && area.showCategoryTickRow) {
2811
+ let top = plot.y + plot.h;
2812
+ area.xTicks.values.forEach((value, i) => {
2813
+ let x = round2(area.xOfValue(value));
2814
+ nodes.push({ t: "line", id: `axis:x:scale-tick:${i}`, x1: x, y1: top, x2: x, y2: top + INTERVAL_TICK, stroke: { token: "axis" }, width: strokeToken(theme, "rule"), owner: {}, part: "tick" }), claims.claim({ x: x - 0.5, y: top, w: 1, h: INTERVAL_TICK }, "axis", {}, "tick");
2815
+ });
2816
+ }
2817
+ let referenceBands = reserves.referenceBands ? layoutReferenceBands(theme, { column: reserves.referenceBands, plot: area.forecastPlot, y, claims, warnings }) : void 0;
2818
+ referenceBands && pushAll(nodes, referenceBands.bands);
2819
+ let headerRequests = area.axisTitle && area.axisShown ? [valueAxisTitleRequest(area.axisTitle, { x: area.frame.plot.x, y: area.axisTitleY }, "start", "axis:y:title")] : [];
2820
+ placeForecastHeaders(area.forecast, xOf, area.forecastPlot, area.forecastHeaderInPlot ? area.forecastPlot.y + 2 : area.forecastPlot.y - area.phaseHeaderHeight - area.forecastHeaderHeight, text.secondaryFont, measure, headerRequests, claims, options.strings.forecastHeader, forecastDividerAt(domain), actualHeader(domain));
2821
+ let baseY = dLo <= 0 && dHi >= 0 ? y(0) : plot.y + plot.h, rendered = renderLineMarks({
2822
+ theme,
2823
+ highlights: env.highlights,
2824
+ drawnSeries,
2825
+ refSeries: domain.refSeries,
2826
+ pv,
2827
+ rowOf,
2828
+ cats,
2829
+ isStacked,
2830
+ isArea,
2831
+ compositionInvalidAt,
2832
+ y,
2833
+ cumTop,
2834
+ cumBot,
2835
+ xOf,
2836
+ hasSuppressed100: domain.nmCats100.size > 0 || domain.naCats100.size > 0,
2837
+ baseY,
2838
+ plot,
2839
+ range: domain.x?.range,
2840
+ xOfValue: area.xOfValue,
2841
+ // A stacked band's forecast overlay is a second cue (hatchStrength). Its
2842
+ // stripes are the page colour at 45% over the band's own fill (one solid colour, not an opacity), hair
2843
+ // weight, 9.6 px apart along x at the default strength; lower strengths spread and fade them.
2844
+ hatch: bandHatch(theme, options.hatchStrength),
2845
+ seriesPaint: paints.series,
2846
+ areaFillPaint: paints.areaFill,
2847
+ areaFilled: paints.areaFilled,
2848
+ // A plain line's forecast keeps its colour; the dashes, open markers and divider mark it.
2849
+ forecastLinePaint: (series, index) => isArea || domain.variant === "line" ? paints.series(series, index) : forecastStroke(
2850
+ paints.series(series, index),
2851
+ theme,
2852
+ paints.seriesCrossesShadedBand(series)
2853
+ ),
2854
+ lineWidthOf: paints.lineWidthOf,
2855
+ lineHollowOf: paints.lineHollowOf,
2856
+ interpolationFor,
2857
+ dashOf: paints.dashOf,
2858
+ markerOf: paints.markerOf,
2859
+ hollowAt: paints.hollowAt,
2860
+ rebased: domain.rebased,
2861
+ variant: domain.variant,
2862
+ pctFmt: env.pctFmt,
2863
+ shareTexts: domain.shareTexts,
2864
+ authoredPctFmt: env.authoredPctFmt,
2865
+ fmt: domain.fmt,
2866
+ seriesFmt: domain.valueSpec.forSeries,
2867
+ absOf: domain.absOf,
2868
+ bumpPointState: paints.bumpPointState,
2869
+ inlineNamesEnabled: reserves.endpoint.inlineNamesEnabled,
2870
+ ...latestPointSeries === void 0 ? {} : { latestPointSeries },
2871
+ ...domain.bumpDerived ? { bump: domain.bumpDerived, bumpOmitted: domain.bumpOmitted } : {},
2872
+ nmCats100: domain.nmCats100,
2873
+ naCats100: domain.naCats100,
2874
+ naGlyph: notApplicableGlyph(options.strings),
2875
+ labelFont,
2876
+ measure,
2877
+ refPaintOf: paints.ref,
2878
+ nodes,
2879
+ occupied: claims
2880
+ }), { marks, analyticalSceneStart, paintedAreaCats } = rendered, paintWarningRules = [], before = warnings.filter((warning) => !["pie-ramp-crowded", "likert-ramp-invisible", "band-lightness-insufficient", "series-adjacent-similar", "highlight-reads-as-loss", "line-band-authored-contrast"].includes(warning.code)).length;
2881
+ pushAll(warnings, lineSeriesAdjacentWarnings({ marks, nodes, cats, drawnSeries, cumBot, cumTop, paintedAreaCats, isStacked, isArea, highlights, paintCss: paints.css, theme, capture: { rules: paintWarningRules, before } }));
2882
+ for (let rule of paints.bandRules())
2883
+ paintWarningRules.push({ ...rule, before }), pushAll(warnings, resolvePaintWarnings(theme, [{ ...rule, before }]));
2884
+ renderGapFill({
2885
+ range: domain.x?.range,
2886
+ xOfValue: area.xOfValue,
2887
+ gapFillSeries: domain.gapFillSeries,
2888
+ gapFill: options.gapFill,
2889
+ interpolationFor,
2890
+ pv,
2891
+ rowOf,
2892
+ cats,
2893
+ compositionInvalidAt,
2894
+ xOf,
2895
+ y,
2896
+ warnings,
2897
+ occupied: claims,
2898
+ nodes,
2899
+ marks,
2900
+ analyticalSceneStart
2901
+ }), renderFanWashes(theme, {
2902
+ range: domain.x?.range,
2903
+ xOfValue: area.xOfValue,
2904
+ fan: domain.fan,
2905
+ fanPaints: paints.fanPaints,
2906
+ fanLadder: paints.fanLadder,
2907
+ interpolationFor,
2908
+ pv,
2909
+ rowOf,
2910
+ cats,
2911
+ compositionInvalidAt,
2912
+ xOf,
2913
+ y,
2914
+ pathFor,
2915
+ reversePathTail,
2916
+ fmt: domain.fmt,
2917
+ numberSpec: domain.valueSpec.spec,
2918
+ occupied: claims,
2919
+ warnings,
2920
+ nodes,
2921
+ marks,
2922
+ analyticalSceneStart
2923
+ });
2924
+ let phaseRequests = [], phaseDerived = renderPhaseFills(theme, {
2925
+ range: domain.x?.range,
2926
+ xOfValue: area.xOfValue,
2927
+ phases: domain.phases,
2928
+ pv,
2929
+ rowOf,
2930
+ cats,
2931
+ xOf,
2932
+ y,
2933
+ baseY,
2934
+ plot: area.forecastPlot,
2935
+ phaseHeaderHeight: area.phaseHeaderHeight,
2936
+ paletteRamp: env.paletteRamp,
2937
+ palette: options.palette,
2938
+ fmt: domain.fmt,
2939
+ measure,
2940
+ tickFont,
2941
+ labelRequests: phaseRequests,
2942
+ occupied: claims,
2943
+ nodes,
2944
+ marks,
2945
+ analyticalSceneStart,
2946
+ forecast: area.forecast
2947
+ });
2948
+ drawLineTrends(theme, domain, area, paints, nodes, claims);
2949
+ let targetRequests = [], targetLabelIds = renderTargets(env.theme, {
2950
+ targets: domain.targets,
2951
+ categoryOrder: area.categoryOrder,
2952
+ xOf,
2953
+ y,
2954
+ nodes,
2955
+ occupied: claims,
2956
+ fmt: domain.fmt,
2957
+ labelFont,
2958
+ measure,
2959
+ labelRequests: targetRequests,
2960
+ plot,
2961
+ marks,
2962
+ rightEdge: env.size.width - 4
2963
+ }), { meanValue, meanValueFor } = lineMeans(domain.population?.plotted ?? pv, rowOf, drawnSeries, domain.population?.categories ?? cats, !domain.rebased && domain.variant !== "stacked100-area");
2964
+ return claimValueLines(reserves.annList, meanValue, meanValueFor, cats, area, claims), referenceBands && pushAll(nodes, referenceBands.column), {
2965
+ nodes,
2966
+ claims,
2967
+ axes,
2968
+ rendered,
2969
+ marks,
2970
+ paintWarningRules,
2971
+ headerRequests,
2972
+ phaseRequests,
2973
+ targetRequests,
2974
+ phaseDerived,
2975
+ targetLabelIds,
2976
+ baseY,
2977
+ meanValue,
2978
+ meanValueFor
2979
+ };
2980
+ }
2981
+ function claimValueLines(annList, meanValue, meanValueFor, cats, area, claims) {
2982
+ let { plot, y, xOf } = area, resolveBand = annList.some((ann) => ann.kind === "band" && ann.from !== void 0 && ann.to !== void 0 && !!ann.label) ? categoryBandFromCenters(cats.map((c) => c.id), plot, xOf, "x") : void 0;
2983
+ annList.forEach((ann, k) => {
2984
+ if (ann.kind !== "valueLine") return;
2985
+ let scoped = ann.seriesId !== void 0 || ann.from !== void 0 || ann.to !== void 0, v;
2986
+ if (!scoped) v = ann.value === "mean" || ann.value === void 0 ? meanValue : ann.value;
2987
+ else if ((ann.value === "mean" || ann.value === void 0) && ann.from === void 0 == (ann.to === void 0)) {
2988
+ let resolved = meanValueFor({ seriesId: ann.seriesId, from: ann.from, to: ann.to });
2989
+ v = "error" in resolved ? void 0 : resolved.value;
2990
+ }
2991
+ if (v === void 0) return;
2992
+ let fromBand = ann.from !== void 0 ? resolveBand?.(ann.from) : null, toBand = ann.to !== void 0 ? resolveBand?.(ann.to) : null, x0 = fromBand && toBand && "x" in fromBand && "x" in toBand ? Math.min(fromBand.x, toBand.x) : plot.x, x1 = fromBand && toBand && "x" in fromBand && "x" in toBand ? Math.max(fromBand.x + fromBand.w, toBand.x + toBand.w) : plot.x + plot.w;
2993
+ claims.claim({ x: x0, y: y(v) - 1, w: Math.max(x1 - x0, 0), h: 2 }, "annotation", { annotationId: ann.id ?? `valueLine-${k + 1}` });
2994
+ });
2995
+ }
2996
+
2997
+ export {
2998
+ trendTimeline,
2999
+ fitLineTrends,
3000
+ lineTrendLabel,
3001
+ lineTrendKeys,
3002
+ screenEdges,
3003
+ seatValuesOnGround,
3004
+ rangeCut,
3005
+ rangeRuns,
3006
+ pathFor,
3007
+ forecastBoundaryX,
3008
+ withoutEvents,
3009
+ fillShadingKinds,
3010
+ shadesFills,
3011
+ fillShadings,
3012
+ regroundOnShadings,
3013
+ markerPath,
3014
+ latestRingReach,
3015
+ END_LABEL_KEY,
3016
+ END_LABEL_WIDE,
3017
+ INLINE_FALLBACK,
3018
+ usesInlineFallback,
3019
+ usesEndLabelKey,
3020
+ fanEdgeInKey,
3021
+ usesWideEndLabels,
3022
+ lineFocusFont,
3023
+ endUnitSuffix,
3024
+ valueUnit,
3025
+ prepareEndpointLabels,
3026
+ placeInlineSeriesLabels,
3027
+ placeEndpointLabels,
3028
+ lineToDateIds,
3029
+ pointLabelSelection,
3030
+ defaultValueContent,
3031
+ PLOT_END_AIR,
3032
+ pointLabelEndRoom,
3033
+ pointValueWidths,
3034
+ placePointValueLabels,
3035
+ placeCategoryLabels,
3036
+ flaggedPoints,
3037
+ lineLabelModes,
3038
+ BUMP_FOLDED,
3039
+ prepareBump,
3040
+ deriveBumpRanks,
3041
+ bumpMethodNote,
3042
+ buildBumpStartLabels,
3043
+ placeBumpTieLabels,
3044
+ joinTieValues,
3045
+ placeBumpStartLabels,
3046
+ resolveGapFillSeries,
3047
+ gapFillPaint,
3048
+ resolveFan,
3049
+ outerFanEdge,
3050
+ fanGapNote,
3051
+ forecastBoundaries,
3052
+ forecastDividerAt,
3053
+ placeForecastHeaders,
3054
+ actualHeader,
3055
+ emitForecastDividers,
3056
+ backForecastAreaLabels,
3057
+ lineValueStats,
3058
+ planLineStyle,
3059
+ MARKER_MAX_CATS,
3060
+ lineText,
3061
+ linePaints,
3062
+ planReferenceBandColumn,
3063
+ referenceBandsA11y,
3064
+ bandHatch,
3065
+ layoutLineMarks
3066
+ };