boardplot 0.0.0-stage → 0.53.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (818) hide show
  1. package/CHANGELOG.md +49 -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-VOJSJ66R.js +137 -0
  8. package/dist/annotateEngine-DLMFJZ67.js +30 -0
  9. package/dist/build-identity.json +6 -0
  10. package/dist/chunk-24BHMKDD.js +83 -0
  11. package/dist/chunk-263SZKIL.js +8 -0
  12. package/dist/chunk-27QADBDV.js +211 -0
  13. package/dist/chunk-2CVH5E57.js +128 -0
  14. package/dist/chunk-2DOR5SS6.js +446 -0
  15. package/dist/chunk-2EQE4E3I.js +22 -0
  16. package/dist/chunk-2FNNAPCI.js +24 -0
  17. package/dist/chunk-2L2Q53EP.js +251 -0
  18. package/dist/chunk-2LMCD3ZR.js +6 -0
  19. package/dist/chunk-2ND7ZITT.js +3069 -0
  20. package/dist/chunk-2QT5ZUHO.js +2937 -0
  21. package/dist/chunk-2RSG7JYI.js +24 -0
  22. package/dist/chunk-2V6CLH33.js +1392 -0
  23. package/dist/chunk-2VWJ5BGO.js +566 -0
  24. package/dist/chunk-2WNYRWHG.js +51 -0
  25. package/dist/chunk-323YZWYJ.js +548 -0
  26. package/dist/chunk-33PB4V6K.js +382 -0
  27. package/dist/chunk-33PLBIMA.js +176 -0
  28. package/dist/chunk-3A2IEBCN.js +195 -0
  29. package/dist/chunk-3D3D3D23.js +25 -0
  30. package/dist/chunk-3EZRM4YM.js +92 -0
  31. package/dist/chunk-3H2W76TB.js +2353 -0
  32. package/dist/chunk-3JEQGGVD.js +19 -0
  33. package/dist/chunk-3QWZAEW5.js +26 -0
  34. package/dist/chunk-3SIRPKMP.js +12 -0
  35. package/dist/chunk-3SQCCESO.js +1592 -0
  36. package/dist/chunk-3XHJHQWU.js +42 -0
  37. package/dist/chunk-4G2O2ZPJ.js +83 -0
  38. package/dist/chunk-4JLBVIGW.js +24 -0
  39. package/dist/chunk-4RRNJLCM.js +746 -0
  40. package/dist/chunk-4UVW5WU6.js +76 -0
  41. package/dist/chunk-4X66BTP5.js +344 -0
  42. package/dist/chunk-53OYF4ZT.js +687 -0
  43. package/dist/chunk-57ZGVAU3.js +179 -0
  44. package/dist/chunk-5HECRVXJ.js +62 -0
  45. package/dist/chunk-5LGSRWFC.js +63 -0
  46. package/dist/chunk-5LYXD6ME.js +1112 -0
  47. package/dist/chunk-66RFKRGO.js +28 -0
  48. package/dist/chunk-6KWIQ5KF.js +18 -0
  49. package/dist/chunk-6OCR6ITN.js +72 -0
  50. package/dist/chunk-6RBTTCQD.js +802 -0
  51. package/dist/chunk-6Y7EXYLR.js +563 -0
  52. package/dist/chunk-7CTKTIPF.js +613 -0
  53. package/dist/chunk-7EVIIADO.js +185 -0
  54. package/dist/chunk-7X2ZYVAX.js +89 -0
  55. package/dist/chunk-7X65ZQN4.js +38 -0
  56. package/dist/chunk-A4QZXLXF.js +7 -0
  57. package/dist/chunk-A6CQPJWR.js +49 -0
  58. package/dist/chunk-A7IEVBYI.js +35 -0
  59. package/dist/chunk-ACXX2JNL.js +6 -0
  60. package/dist/chunk-ADKCLH3Z.js +98 -0
  61. package/dist/chunk-ADWSGPH5.js +23 -0
  62. package/dist/chunk-AG2CJ4JY.js +203 -0
  63. package/dist/chunk-AHQ4L3BE.js +30 -0
  64. package/dist/chunk-AOQ6VF5H.js +6 -0
  65. package/dist/chunk-AQROQDLR.js +3303 -0
  66. package/dist/chunk-AWTG3RFF.js +85 -0
  67. package/dist/chunk-B54RN2FD.js +692 -0
  68. package/dist/chunk-B67K6OWJ.js +48 -0
  69. package/dist/chunk-B6GFKYBZ.js +40 -0
  70. package/dist/chunk-BBL3R5YZ.js +186 -0
  71. package/dist/chunk-BBRBCMNR.js +28 -0
  72. package/dist/chunk-BIDIGDGH.js +6 -0
  73. package/dist/chunk-BLFWUMTD.js +12 -0
  74. package/dist/chunk-BM6SFFWF.js +6 -0
  75. package/dist/chunk-BMRD6MAH.js +24 -0
  76. package/dist/chunk-BPKXEMRE.js +197 -0
  77. package/dist/chunk-BUPLB3EX.js +129 -0
  78. package/dist/chunk-BW5VLBSZ.js +15 -0
  79. package/dist/chunk-BWGRWGVA.js +295 -0
  80. package/dist/chunk-BWLOXQDV.js +131 -0
  81. package/dist/chunk-BWTX7LUG.js +203 -0
  82. package/dist/chunk-C54QLNE4.js +69 -0
  83. package/dist/chunk-CAQ5P4VN.js +296 -0
  84. package/dist/chunk-CCCEBIUZ.js +296 -0
  85. package/dist/chunk-CDZHNLO6.js +42 -0
  86. package/dist/chunk-CJGSJKPO.js +25 -0
  87. package/dist/chunk-CN7JRHST.js +25 -0
  88. package/dist/chunk-CNX7EGSU.js +266 -0
  89. package/dist/chunk-COYOTQC2.js +75 -0
  90. package/dist/chunk-CRNMNZJD.js +1161 -0
  91. package/dist/chunk-CUVUDK4O.js +68 -0
  92. package/dist/chunk-CWDHCSL2.js +2919 -0
  93. package/dist/chunk-CYOJZ3GQ.js +631 -0
  94. package/dist/chunk-D4SOADBD.js +19 -0
  95. package/dist/chunk-D7SHZDA3.js +1808 -0
  96. package/dist/chunk-DAVHGK27.js +657 -0
  97. package/dist/chunk-DCCJRLAJ.js +422 -0
  98. package/dist/chunk-DCTCUZ5L.js +51 -0
  99. package/dist/chunk-DDCB7ZA5.js +2511 -0
  100. package/dist/chunk-DDI2W4TR.js +149 -0
  101. package/dist/chunk-DIHUGBZO.js +61 -0
  102. package/dist/chunk-DJHIQWSG.js +25 -0
  103. package/dist/chunk-DO5OZJAO.js +302 -0
  104. package/dist/chunk-DOFYKPTC.js +18 -0
  105. package/dist/chunk-DRTA6JG5.js +160 -0
  106. package/dist/chunk-DRW6KGBK.js +1062 -0
  107. package/dist/chunk-DU4A5AOY.js +1156 -0
  108. package/dist/chunk-DYS7EIXY.js +294 -0
  109. package/dist/chunk-E4IQ6M4S.js +24 -0
  110. package/dist/chunk-EFUWFB64.js +24 -0
  111. package/dist/chunk-EHBB2Z4D.js +290 -0
  112. package/dist/chunk-EHVESNLV.js +30 -0
  113. package/dist/chunk-EJPVVGD7.js +67 -0
  114. package/dist/chunk-EKQK5D6G.js +14 -0
  115. package/dist/chunk-EUADDXAV.js +30 -0
  116. package/dist/chunk-F6CNPC4L.js +47 -0
  117. package/dist/chunk-FBAYZSFC.js +2806 -0
  118. package/dist/chunk-FBB4BWKN.js +30 -0
  119. package/dist/chunk-FF23FYQD.js +1269 -0
  120. package/dist/chunk-FG6EDGMI.js +53 -0
  121. package/dist/chunk-FHA3KMFC.js +43 -0
  122. package/dist/chunk-FIANWJXX.js +19 -0
  123. package/dist/chunk-FIWNDOMO.js +6 -0
  124. package/dist/chunk-FV3VF36K.js +2721 -0
  125. package/dist/chunk-G5FMTRG5.js +37 -0
  126. package/dist/chunk-GCBOHVDZ.js +229 -0
  127. package/dist/chunk-GDOW2KNP.js +19 -0
  128. package/dist/chunk-GTG3IGLF.js +2674 -0
  129. package/dist/chunk-GZTNTHSW.js +21 -0
  130. package/dist/chunk-H4H4O62O.js +46 -0
  131. package/dist/chunk-H5G7T35P.js +24 -0
  132. package/dist/chunk-H63XQ3OO.js +942 -0
  133. package/dist/chunk-H67RTX46.js +43 -0
  134. package/dist/chunk-HA4IPWMM.js +841 -0
  135. package/dist/chunk-HKYTOJLV.js +33 -0
  136. package/dist/chunk-HOAH5XBR.js +542 -0
  137. package/dist/chunk-HTYFQHRC.js +24 -0
  138. package/dist/chunk-HYY5V2KL.js +19 -0
  139. package/dist/chunk-HZI56ASJ.js +79 -0
  140. package/dist/chunk-I6VAWNNU.js +24 -0
  141. package/dist/chunk-IBXXZVG7.js +80 -0
  142. package/dist/chunk-IDDA5INB.js +60 -0
  143. package/dist/chunk-IK4BHOPZ.js +33 -0
  144. package/dist/chunk-IL5T7I2A.js +27 -0
  145. package/dist/chunk-ILSXT6KT.js +24 -0
  146. package/dist/chunk-IV2UXZXX.js +16 -0
  147. package/dist/chunk-IYEFEBRN.js +41 -0
  148. package/dist/chunk-IYMI7YI4.js +829 -0
  149. package/dist/chunk-J6I2YFJH.js +58 -0
  150. package/dist/chunk-JFBEAUJ6.js +24 -0
  151. package/dist/chunk-JR7Y5ONB.js +27 -0
  152. package/dist/chunk-JSEYUJUQ.js +836 -0
  153. package/dist/chunk-JYBT2JNY.js +61 -0
  154. package/dist/chunk-K3HSQPSM.js +24 -0
  155. package/dist/chunk-KAXJFL7N.js +43 -0
  156. package/dist/chunk-KDMKHR5A.js +32 -0
  157. package/dist/chunk-KKWZWP67.js +24 -0
  158. package/dist/chunk-KOJ5QETJ.js +8 -0
  159. package/dist/chunk-KPKXJYQH.js +19 -0
  160. package/dist/chunk-KSJVENRU.js +113 -0
  161. package/dist/chunk-KZJOV4QW.js +33 -0
  162. package/dist/chunk-KZS46KDY.js +58 -0
  163. package/dist/chunk-L3JWM7FR.js +50 -0
  164. package/dist/chunk-L4S6UFTL.js +26 -0
  165. package/dist/chunk-L6DJ4ZY5.js +2008 -0
  166. package/dist/chunk-L7RHB734.js +23 -0
  167. package/dist/chunk-LCWJS34U.js +38 -0
  168. package/dist/chunk-LFTAMH7I.js +24 -0
  169. package/dist/chunk-LFX7W4B7.js +113 -0
  170. package/dist/chunk-LINZPU5D.js +8 -0
  171. package/dist/chunk-LIWLBLCT.js +83 -0
  172. package/dist/chunk-LNKY5Z2X.js +23 -0
  173. package/dist/chunk-LS7HVBI7.js +24 -0
  174. package/dist/chunk-M4EUXOLU.js +170 -0
  175. package/dist/chunk-M4SPKUZE.js +7 -0
  176. package/dist/chunk-M4YLED7M.js +17 -0
  177. package/dist/chunk-MBKZYJRC.js +1424 -0
  178. package/dist/chunk-MCYM3RNF.js +227 -0
  179. package/dist/chunk-MF6IVSBJ.js +48 -0
  180. package/dist/chunk-MIAPBQCA.js +24 -0
  181. package/dist/chunk-MJZHFH5R.js +1075 -0
  182. package/dist/chunk-MQFCG4KS.js +1467 -0
  183. package/dist/chunk-MVV6RQMG.js +128 -0
  184. package/dist/chunk-MYMT5KJL.js +1182 -0
  185. package/dist/chunk-MZL6LGKO.js +587 -0
  186. package/dist/chunk-N23YFPPI.js +47 -0
  187. package/dist/chunk-N3G2FYDL.js +300 -0
  188. package/dist/chunk-N3TPMXS3.js +161 -0
  189. package/dist/chunk-N73IBH55.js +58 -0
  190. package/dist/chunk-N7J7CZS6.js +43 -0
  191. package/dist/chunk-NCB3YLHF.js +28 -0
  192. package/dist/chunk-NHQGRKEA.js +63 -0
  193. package/dist/chunk-NKIYLFXZ.js +2774 -0
  194. package/dist/chunk-NOSDEJ3K.js +25934 -0
  195. package/dist/chunk-NQDVMUHX.js +433 -0
  196. package/dist/chunk-NSSNYY6Y.js +58 -0
  197. package/dist/chunk-NY5NUFDZ.js +117 -0
  198. package/dist/chunk-O3S2KNIW.js +25 -0
  199. package/dist/chunk-O3VN6BTL.js +24 -0
  200. package/dist/chunk-ONZLC47B.js +88 -0
  201. package/dist/chunk-OQEBOVUO.js +30 -0
  202. package/dist/chunk-OUEGGWH7.js +24 -0
  203. package/dist/chunk-OURX73UJ.js +728 -0
  204. package/dist/chunk-P25VEGGX.js +24 -0
  205. package/dist/chunk-P26Z62UV.js +24 -0
  206. package/dist/chunk-P5RNWMZC.js +2984 -0
  207. package/dist/chunk-P6KZIZDV.js +987 -0
  208. package/dist/chunk-PEUSKIFV.js +168 -0
  209. package/dist/chunk-PFVTYFSL.js +24 -0
  210. package/dist/chunk-PWROWDZS.js +137 -0
  211. package/dist/chunk-Q3CV2JJ2.js +3650 -0
  212. package/dist/chunk-QBR6IKIX.js +50 -0
  213. package/dist/chunk-QGCEHR6S.js +13 -0
  214. package/dist/chunk-QHRE2M6V.js +26 -0
  215. package/dist/chunk-QKL7IY42.js +38 -0
  216. package/dist/chunk-QO6HEXIZ.js +272 -0
  217. package/dist/chunk-QOIVXZUF.js +24 -0
  218. package/dist/chunk-QPWRHDLZ.js +17 -0
  219. package/dist/chunk-QSXK6PJL.js +19 -0
  220. package/dist/chunk-QTZVVZ2A.js +54 -0
  221. package/dist/chunk-QWXWVPNE.js +18 -0
  222. package/dist/chunk-QY5ZKUWY.js +383 -0
  223. package/dist/chunk-QZAT46PP.js +95 -0
  224. package/dist/chunk-RA66JA3D.js +24 -0
  225. package/dist/chunk-REOPXBUR.js +600 -0
  226. package/dist/chunk-RGZGLKFB.js +648 -0
  227. package/dist/chunk-RL3NUWMY.js +3378 -0
  228. package/dist/chunk-RNOJSEES.js +16 -0
  229. package/dist/chunk-ROXO4R3J.js +16 -0
  230. package/dist/chunk-RPIW5T55.js +40 -0
  231. package/dist/chunk-RQ5DNYLG.js +10 -0
  232. package/dist/chunk-RZNYW7UP.js +133 -0
  233. package/dist/chunk-S32YYDIB.js +420 -0
  234. package/dist/chunk-S4QSJAGY.js +44 -0
  235. package/dist/chunk-S6UX7KB6.js +335 -0
  236. package/dist/chunk-SDSONLMZ.js +2546 -0
  237. package/dist/chunk-SGD3ZHID.js +250 -0
  238. package/dist/chunk-SKRSCTT5.js +28 -0
  239. package/dist/chunk-SMCDXUIO.js +24 -0
  240. package/dist/chunk-SPTPFY4S.js +528 -0
  241. package/dist/chunk-SREWFAAJ.js +90 -0
  242. package/dist/chunk-SS42FJVN.js +3875 -0
  243. package/dist/chunk-SVZDXFPX.js +891 -0
  244. package/dist/chunk-SZPTTNW7.js +16 -0
  245. package/dist/chunk-T3IGJARD.js +22 -0
  246. package/dist/chunk-TA3TFKYZ.js +86 -0
  247. package/dist/chunk-TBGUEF3M.js +939 -0
  248. package/dist/chunk-TGK6KUGN.js +331 -0
  249. package/dist/chunk-TJSND556.js +1783 -0
  250. package/dist/chunk-TKOJZQAJ.js +24 -0
  251. package/dist/chunk-TM4OC53S.js +97 -0
  252. package/dist/chunk-TNEHPP3H.js +18 -0
  253. package/dist/chunk-TWOREVKJ.js +1760 -0
  254. package/dist/chunk-TXS3U77A.js +60 -0
  255. package/dist/chunk-UB6ODJHO.js +134 -0
  256. package/dist/chunk-UBZXQIDR.js +24 -0
  257. package/dist/chunk-ULTSSIOU.js +38 -0
  258. package/dist/chunk-UMDEWWXT.js +33 -0
  259. package/dist/chunk-V6O6KVOA.js +347 -0
  260. package/dist/chunk-VABRPZVC.js +43 -0
  261. package/dist/chunk-VDAKTZQP.js +18 -0
  262. package/dist/chunk-VDAZPGR2.js +79 -0
  263. package/dist/chunk-VERLFNWR.js +25 -0
  264. package/dist/chunk-VH2UUU7K.js +24 -0
  265. package/dist/chunk-VJ3FCGQF.js +12 -0
  266. package/dist/chunk-VK5ZDV67.js +47 -0
  267. package/dist/chunk-VKQNDOAI.js +40 -0
  268. package/dist/chunk-VTEV3WVF.js +690 -0
  269. package/dist/chunk-VXZFQKBJ.js +21 -0
  270. package/dist/chunk-WI5ITCOH.js +22 -0
  271. package/dist/chunk-WLZ54FWG.js +120 -0
  272. package/dist/chunk-WYJEOMNY.js +31 -0
  273. package/dist/chunk-WZGJSQKN.js +29 -0
  274. package/dist/chunk-WZL4EEBS.js +11 -0
  275. package/dist/chunk-X4YNDLVA.js +54 -0
  276. package/dist/chunk-X6SUFTD7.js +17 -0
  277. package/dist/chunk-XB4KZ6WO.js +81 -0
  278. package/dist/chunk-XJI6SWFS.js +569 -0
  279. package/dist/chunk-XJP5DKIL.js +29 -0
  280. package/dist/chunk-XN4ARQ2W.js +47 -0
  281. package/dist/chunk-XN7MQO45.js +359 -0
  282. package/dist/chunk-XQCQZBGX.js +100 -0
  283. package/dist/chunk-XXOHXA3A.js +69 -0
  284. package/dist/chunk-XZOHR765.js +127 -0
  285. package/dist/chunk-YCNLQYTC.js +133 -0
  286. package/dist/chunk-YCRGWQBS.js +526 -0
  287. package/dist/chunk-YF2PYLC4.js +210 -0
  288. package/dist/chunk-YG5GUELW.js +935 -0
  289. package/dist/chunk-YS6KMYM4.js +91 -0
  290. package/dist/chunk-YWP7XFKD.js +12 -0
  291. package/dist/chunk-Z2MGTKDR.js +20 -0
  292. package/dist/chunk-Z6CL7AR6.js +24 -0
  293. package/dist/chunk-Z7X3RGGA.js +22 -0
  294. package/dist/chunk-ZF43WRG3.js +29 -0
  295. package/dist/chunk-ZMF7WEGG.js +60 -0
  296. package/dist/chunk-ZNHFLJSY.js +375 -0
  297. package/dist/chunk-ZQ4VFQID.js +76 -0
  298. package/dist/chunk-ZQF34VPS.js +72 -0
  299. package/dist/chunk-ZU425HNM.js +24 -0
  300. package/dist/chunk-ZZU5R5UU.js +24 -0
  301. package/dist/cli/index.js +9 -0
  302. package/dist/core-3VCCUFVX.js +32 -0
  303. package/dist/core-4BZQQSHS.js +33 -0
  304. package/dist/core-4VT4MHNB.js +38 -0
  305. package/dist/core-5535KXRD.js +40 -0
  306. package/dist/core-5HQBPCHL.js +35 -0
  307. package/dist/core-6RYHWUJO.js +35 -0
  308. package/dist/core-7BZJCIXN.js +35 -0
  309. package/dist/core-AJTVU6X7.js +37 -0
  310. package/dist/core-C6YUSTZI.js +57 -0
  311. package/dist/core-EEB7HTCL.js +33 -0
  312. package/dist/core-EFMVDWNH.js +38 -0
  313. package/dist/core-ETAGQBZO.js +34 -0
  314. package/dist/core-FVR3WZEC.js +36 -0
  315. package/dist/core-GCTFVYMH.js +29 -0
  316. package/dist/core-GES44OTS.js +33 -0
  317. package/dist/core-GGQREDSI.js +47 -0
  318. package/dist/core-HRYOV6QD.js +38 -0
  319. package/dist/core-IKD3EE3S.js +38 -0
  320. package/dist/core-JM4R426L.js +32 -0
  321. package/dist/core-KKQS3WI2.js +40 -0
  322. package/dist/core-LA6XDYG7.js +40 -0
  323. package/dist/core-MJ7JWQT5.js +37 -0
  324. package/dist/core-MLROKJ2M.js +53 -0
  325. package/dist/core-MR52YBRX.js +31 -0
  326. package/dist/core-NP4VHWXL.js +29 -0
  327. package/dist/core-NQLNZDX5.js +41 -0
  328. package/dist/core-NSIJEKLI.js +44 -0
  329. package/dist/core-OJUQLIQ5.js +35 -0
  330. package/dist/core-PB3VUQSS.js +32 -0
  331. package/dist/core-Q6VLFFYC.js +56 -0
  332. package/dist/core-QY7AVIKZ.js +51 -0
  333. package/dist/core-SBQMHWTA.js +52 -0
  334. package/dist/core-UHECQHJ2.js +38 -0
  335. package/dist/core-V5FV4NWL.js +56 -0
  336. package/dist/core-WGM4XUN3.js +58 -0
  337. package/dist/core-WUQVFARS.js +34 -0
  338. package/dist/core-Z2F3IGSR.js +42 -0
  339. package/dist/dataTable-3CPPIHB3.js +58 -0
  340. package/dist/engine-FXFBCWHB.js +961 -0
  341. package/dist/fixtures.d.ts +1 -0
  342. package/dist/fixtures.js +41 -0
  343. package/dist/fontTables-WYCZNRE7.js +18 -0
  344. package/dist/fonts.d.ts +1 -0
  345. package/dist/fonts.js +19 -0
  346. package/dist/geo/dach.d.ts +1 -0
  347. package/dist/geo/dach.js +14 -0
  348. package/dist/geo/de-states.d.ts +1 -0
  349. package/dist/geo/de-states.js +14 -0
  350. package/dist/geo/eu27.d.ts +1 -0
  351. package/dist/geo/eu27.js +14 -0
  352. package/dist/geo/europe.d.ts +1 -0
  353. package/dist/geo/europe.js +14 -0
  354. package/dist/geo/index.d.ts +1 -0
  355. package/dist/geo/index.js +41 -0
  356. package/dist/geo/us-states.d.ts +1 -0
  357. package/dist/geo/us-states.js +14 -0
  358. package/dist/geo/world.d.ts +1 -0
  359. package/dist/geo/world.js +14 -0
  360. package/dist/index.d.ts +1 -0
  361. package/dist/index.js +364 -0
  362. package/dist/main-YLKBTHJP.js +569 -0
  363. package/dist/mcp/server.js +1025 -0
  364. package/dist/module-SVEW5ZUE.js +137233 -0
  365. package/dist/react/bar.d.ts +1 -0
  366. package/dist/react/bar.js +81 -0
  367. package/dist/react/bartable.d.ts +1 -0
  368. package/dist/react/bartable.js +70 -0
  369. package/dist/react/box.d.ts +1 -0
  370. package/dist/react/box.js +65 -0
  371. package/dist/react/bullet.d.ts +1 -0
  372. package/dist/react/bullet.js +72 -0
  373. package/dist/react/butterfly.d.ts +1 -0
  374. package/dist/react/butterfly.js +66 -0
  375. package/dist/react/choropleth.d.ts +1 -0
  376. package/dist/react/choropleth.js +67 -0
  377. package/dist/react/cohort.d.ts +1 -0
  378. package/dist/react/cohort.js +70 -0
  379. package/dist/react/column.d.ts +1 -0
  380. package/dist/react/column.js +86 -0
  381. package/dist/react/combo.d.ts +1 -0
  382. package/dist/react/combo.js +86 -0
  383. package/dist/react/creative.d.ts +1 -0
  384. package/dist/react/creative.js +61 -0
  385. package/dist/react/diagram.d.ts +1 -0
  386. package/dist/react/diagram.js +60 -0
  387. package/dist/react/dimswitch.d.ts +1 -0
  388. package/dist/react/dimswitch.js +72 -0
  389. package/dist/react/dot.d.ts +1 -0
  390. package/dist/react/dot.js +70 -0
  391. package/dist/react/export.d.ts +1 -0
  392. package/dist/react/export.js +658 -0
  393. package/dist/react/funnel.d.ts +1 -0
  394. package/dist/react/funnel.js +63 -0
  395. package/dist/react/gantt.d.ts +1 -0
  396. package/dist/react/gantt.js +62 -0
  397. package/dist/react/grid.d.ts +1 -0
  398. package/dist/react/grid.js +67 -0
  399. package/dist/react/heatmap.d.ts +1 -0
  400. package/dist/react/heatmap.js +68 -0
  401. package/dist/react/histogram.d.ts +1 -0
  402. package/dist/react/histogram.js +86 -0
  403. package/dist/react/index.d.ts +1 -0
  404. package/dist/react/index.js +504 -0
  405. package/dist/react/kpi.d.ts +1 -0
  406. package/dist/react/kpi.js +67 -0
  407. package/dist/react/likert.d.ts +1 -0
  408. package/dist/react/likert.js +83 -0
  409. package/dist/react/line.d.ts +1 -0
  410. package/dist/react/line.js +81 -0
  411. package/dist/react/mekko.d.ts +1 -0
  412. package/dist/react/mekko.js +71 -0
  413. package/dist/react/pareto.d.ts +1 -0
  414. package/dist/react/pareto.js +90 -0
  415. package/dist/react/pie.d.ts +1 -0
  416. package/dist/react/pie.js +64 -0
  417. package/dist/react/prepare.d.ts +1 -0
  418. package/dist/react/prepare.js +278 -0
  419. package/dist/react/pvm.d.ts +1 -0
  420. package/dist/react/pvm.js +68 -0
  421. package/dist/react/pyramid.d.ts +1 -0
  422. package/dist/react/pyramid.js +67 -0
  423. package/dist/react/sankey.d.ts +1 -0
  424. package/dist/react/sankey.js +59 -0
  425. package/dist/react/scatter.d.ts +1 -0
  426. package/dist/react/scatter.js +63 -0
  427. package/dist/react/slope.d.ts +1 -0
  428. package/dist/react/slope.js +64 -0
  429. package/dist/react/sparkline.d.ts +1 -0
  430. package/dist/react/sparkline.js +59 -0
  431. package/dist/react/spec.d.ts +1 -0
  432. package/dist/react/spec.js +379 -0
  433. package/dist/react/status.d.ts +1 -0
  434. package/dist/react/status.js +64 -0
  435. package/dist/react/story.d.ts +1 -0
  436. package/dist/react/story.js +140 -0
  437. package/dist/react/table.d.ts +1 -0
  438. package/dist/react/table.js +69 -0
  439. package/dist/react/theme.d.ts +1 -0
  440. package/dist/react/theme.js +53 -0
  441. package/dist/react/tilemap.d.ts +1 -0
  442. package/dist/react/tilemap.js +66 -0
  443. package/dist/react/treemap.d.ts +1 -0
  444. package/dist/react/treemap.js +61 -0
  445. package/dist/react/variance.d.ts +1 -0
  446. package/dist/react/variance.js +65 -0
  447. package/dist/react/waffle.d.ts +1 -0
  448. package/dist/react/waffle.js +62 -0
  449. package/dist/react/waterfall.d.ts +1 -0
  450. package/dist/react/waterfall.js +68 -0
  451. package/dist/resvg-ZOVDIZTV.js +23 -0
  452. package/dist/rows.d.ts +1 -0
  453. package/dist/rows.js +23 -0
  454. package/dist/rowsModule-YVLAROIP.js +27 -0
  455. package/dist/schema-2K6C3U24.js +23 -0
  456. package/dist/schema-2KIHLTYI.js +23 -0
  457. package/dist/schema-4HY2MWZC.js +30 -0
  458. package/dist/schema-4S5CXHAO.js +24 -0
  459. package/dist/schema-5BKQV56C.js +27 -0
  460. package/dist/schema-5HA5DSYN.js +24 -0
  461. package/dist/schema-5NKJPSBD.js +23 -0
  462. package/dist/schema-65FOKNHK.js +43 -0
  463. package/dist/schema-6OHZWHUI.js +23 -0
  464. package/dist/schema-6RYJS2GM.js +24 -0
  465. package/dist/schema-6W4M3WJ4.js +23 -0
  466. package/dist/schema-7TLSFG6M.js +24 -0
  467. package/dist/schema-AMFRKUFS.js +27 -0
  468. package/dist/schema-B7CZPPB4.js +28 -0
  469. package/dist/schema-BNRNHGHQ.js +26 -0
  470. package/dist/schema-E4MRCGPZ.js +24 -0
  471. package/dist/schema-F3WYTR65.js +26 -0
  472. package/dist/schema-FA6XIHTW.js +23 -0
  473. package/dist/schema-GZNOW4LX.js +23 -0
  474. package/dist/schema-HEIDGCSL.js +23 -0
  475. package/dist/schema-JB2H6KPA.js +23 -0
  476. package/dist/schema-MPXZNWV3.js +23 -0
  477. package/dist/schema-NHNQK6XO.js +23 -0
  478. package/dist/schema-NN6UPDPW.js +23 -0
  479. package/dist/schema-O4YNAGIY.js +23 -0
  480. package/dist/schema-O7AKK232.js +29 -0
  481. package/dist/schema-OJCML6LV.js +24 -0
  482. package/dist/schema-ORTRMYI6.js +24 -0
  483. package/dist/schema-PJ6P52BC.js +23 -0
  484. package/dist/schema-RTWES6NR.js +24 -0
  485. package/dist/schema-S36SRYGO.js +24 -0
  486. package/dist/schema-S3TCLTYD.js +23 -0
  487. package/dist/schema-SWWMOLOR.js +54 -0
  488. package/dist/schema-WOSEZNKG.js +26 -0
  489. package/dist/schema-Y6KBWUUR.js +23 -0
  490. package/dist/schema-YQYTLKSW.js +23 -0
  491. package/dist/schema-ZUUUY3QS.js +33 -0
  492. package/dist/specValidation-VNWIKLHH.js +49 -0
  493. package/dist/theme.d.ts +1 -0
  494. package/dist/theme.js +24 -0
  495. package/dist/themeShapeRules-2D3KWSPQ.js +11 -0
  496. package/dist/types/core/a11y/accessibility.d.ts +43 -0
  497. package/dist/types/core/a11y/recordsShared.d.ts +44 -0
  498. package/dist/types/core/a11y/structuralRecords.d.ts +6 -0
  499. package/dist/types/core/a11y/types.d.ts +116 -0
  500. package/dist/types/core/annotate.d.ts +300 -0
  501. package/dist/types/core/annotateArms.d.ts +37 -0
  502. package/dist/types/core/annotateFields.d.ts +30 -0
  503. package/dist/types/core/annotateGapBracket.d.ts +66 -0
  504. package/dist/types/core/annotateLinks.d.ts +47 -0
  505. package/dist/types/core/annotateTargets.d.ts +90 -0
  506. package/dist/types/core/axis.d.ts +179 -0
  507. package/dist/types/core/bandSelect.d.ts +10 -0
  508. package/dist/types/core/bands.d.ts +14 -0
  509. package/dist/types/core/calendarLabels.d.ts +101 -0
  510. package/dist/types/core/charts/band/stacks.d.ts +155 -0
  511. package/dist/types/core/charts/bar/fixtures.d.ts +9 -0
  512. package/dist/types/core/charts/bar/layout.d.ts +95 -0
  513. package/dist/types/core/charts/bartable/fixtures.d.ts +4 -0
  514. package/dist/types/core/charts/bartable/types.d.ts +192 -0
  515. package/dist/types/core/charts/box/fixtures.d.ts +12 -0
  516. package/dist/types/core/charts/box/types.d.ts +110 -0
  517. package/dist/types/core/charts/bullet/fixtures.d.ts +11 -0
  518. package/dist/types/core/charts/butterfly/fixtures.d.ts +9 -0
  519. package/dist/types/core/charts/choropleth/fixtures.d.ts +3 -0
  520. package/dist/types/core/charts/choropleth/overlayTypes.d.ts +68 -0
  521. package/dist/types/core/charts/choropleth/types.d.ts +117 -0
  522. package/dist/types/core/charts/cohort/fixtures.d.ts +12 -0
  523. package/dist/types/core/charts/cohort/types.d.ts +165 -0
  524. package/dist/types/core/charts/column/anomaly.d.ts +204 -0
  525. package/dist/types/core/charts/column/fixtures.d.ts +12 -0
  526. package/dist/types/core/charts/column/layout.d.ts +116 -0
  527. package/dist/types/core/charts/column/model.d.ts +295 -0
  528. package/dist/types/core/charts/column/types.d.ts +56 -0
  529. package/dist/types/core/charts/combo/endpoints.d.ts +165 -0
  530. package/dist/types/core/charts/combo/fixtures.d.ts +12 -0
  531. package/dist/types/core/charts/combo/layout.d.ts +48 -0
  532. package/dist/types/core/charts/creative/fixtures.d.ts +4 -0
  533. package/dist/types/core/charts/creative/types.d.ts +73 -0
  534. package/dist/types/core/charts/diagram/fixtures.d.ts +3 -0
  535. package/dist/types/core/charts/dimswitch/compile.d.ts +20 -0
  536. package/dist/types/core/charts/dimswitch/fixtures.d.ts +3 -0
  537. package/dist/types/core/charts/dimswitch/types.d.ts +152 -0
  538. package/dist/types/core/charts/dot/fixtures.d.ts +11 -0
  539. package/dist/types/core/charts/funnel/fixtures.d.ts +11 -0
  540. package/dist/types/core/charts/gantt/fixtures.d.ts +9 -0
  541. package/dist/types/core/charts/gantt/layout.d.ts +63 -0
  542. package/dist/types/core/charts/grid/fixtures.d.ts +3 -0
  543. package/dist/types/core/charts/grid/metricStack.d.ts +108 -0
  544. package/dist/types/core/charts/grid/metricStackSchema.d.ts +74 -0
  545. package/dist/types/core/charts/grid/normalize.d.ts +99 -0
  546. package/dist/types/core/charts/grid/schema.d.ts +168 -0
  547. package/dist/types/core/charts/heatmap/fixtures.d.ts +11 -0
  548. package/dist/types/core/charts/histogram/fixtures.d.ts +15 -0
  549. package/dist/types/core/charts/histogram/types.d.ts +98 -0
  550. package/dist/types/core/charts/kpi/fixtures.d.ts +9 -0
  551. package/dist/types/core/charts/likert/fixtures.d.ts +11 -0
  552. package/dist/types/core/charts/likert/layout.d.ts +111 -0
  553. package/dist/types/core/charts/line/fixtures.d.ts +16 -0
  554. package/dist/types/core/charts/line/types.d.ts +6 -0
  555. package/dist/types/core/charts/mekko/fixtures.d.ts +13 -0
  556. package/dist/types/core/charts/pareto/fixtures.d.ts +5 -0
  557. package/dist/types/core/charts/pareto/layout.d.ts +68 -0
  558. package/dist/types/core/charts/pie/fixtures.d.ts +14 -0
  559. package/dist/types/core/charts/pvm/fixtures.d.ts +13 -0
  560. package/dist/types/core/charts/pvm/types.d.ts +118 -0
  561. package/dist/types/core/charts/pyramid/fixtures.d.ts +4 -0
  562. package/dist/types/core/charts/pyramid/types.d.ts +92 -0
  563. package/dist/types/core/charts/sankey/fixtures.d.ts +4 -0
  564. package/dist/types/core/charts/sankey/types.d.ts +116 -0
  565. package/dist/types/core/charts/scatter/fixtures.d.ts +12 -0
  566. package/dist/types/core/charts/scatter/types.d.ts +58 -0
  567. package/dist/types/core/charts/slope/fixtures.d.ts +13 -0
  568. package/dist/types/core/charts/sparkline/fixtures.d.ts +9 -0
  569. package/dist/types/core/charts/status/fixtures.d.ts +8 -0
  570. package/dist/types/core/charts/status/layout.d.ts +71 -0
  571. package/dist/types/core/charts/table/fitFormats.d.ts +67 -0
  572. package/dist/types/core/charts/table/fixtures.d.ts +7 -0
  573. package/dist/types/core/charts/table/resolve.d.ts +72 -0
  574. package/dist/types/core/charts/table/view.d.ts +156 -0
  575. package/dist/types/core/charts/tilemap/fixtures.d.ts +3 -0
  576. package/dist/types/core/charts/tilemap/types.d.ts +94 -0
  577. package/dist/types/core/charts/treemap/fixtures.d.ts +4 -0
  578. package/dist/types/core/charts/treemap/types.d.ts +78 -0
  579. package/dist/types/core/charts/variance/fixtures.d.ts +12 -0
  580. package/dist/types/core/charts/waffle/fixtures.d.ts +5 -0
  581. package/dist/types/core/charts/waffle/types.d.ts +117 -0
  582. package/dist/types/core/charts/waterfall/fixtures.d.ts +9 -0
  583. package/dist/types/core/claims/browser.d.ts +49 -0
  584. package/dist/types/core/claims/manifest.d.ts +22 -0
  585. package/dist/types/core/dateFormat.d.ts +39 -0
  586. package/dist/types/core/deferred.d.ts +121 -0
  587. package/dist/types/core/diagnostics/describe.d.ts +149 -0
  588. package/dist/types/core/diagnostics/jsonPatch.d.ts +36 -0
  589. package/dist/types/core/doc/bareChart.d.ts +2 -0
  590. package/dist/types/core/doc/diagnostics.d.ts +124 -0
  591. package/dist/types/core/doc/docExpand.d.ts +39 -0
  592. package/dist/types/core/doc/document.d.ts +43 -0
  593. package/dist/types/core/doc/ownedDocumentCopy.d.ts +5 -0
  594. package/dist/types/core/doc/specError.d.ts +6 -0
  595. package/dist/types/core/emptyData.d.ts +27 -0
  596. package/dist/types/core/eventLane.d.ts +208 -0
  597. package/dist/types/core/fontMetrics/index.d.ts +47 -0
  598. package/dist/types/core/fontMetrics/injected.d.ts +40 -0
  599. package/dist/types/core/fontMetrics/tableDocument.d.ts +73 -0
  600. package/dist/types/core/fontMetrics/tables.generated.d.ts +17 -0
  601. package/dist/types/core/footer.d.ts +59 -0
  602. package/dist/types/core/format.d.ts +149 -0
  603. package/dist/types/core/formatPrecision.d.ts +136 -0
  604. package/dist/types/core/formatSpec.d.ts +304 -0
  605. package/dist/types/core/frame.d.ts +583 -0
  606. package/dist/types/core/geo/packs/all.d.ts +7 -0
  607. package/dist/types/core/geo/packs/dach.d.ts +16 -0
  608. package/dist/types/core/geo/packs/de-states.d.ts +16 -0
  609. package/dist/types/core/geo/packs/eu27.d.ts +16 -0
  610. package/dist/types/core/geo/packs/europe.d.ts +16 -0
  611. package/dist/types/core/geo/packs/index.d.ts +22 -0
  612. package/dist/types/core/geo/packs/registry.d.ts +37 -0
  613. package/dist/types/core/geo/packs/us-states.d.ts +16 -0
  614. package/dist/types/core/geo/packs/world.d.ts +16 -0
  615. package/dist/types/core/geo/tiles/eu27.generated.d.ts +412 -0
  616. package/dist/types/core/geo/tiles/europe.generated.d.ts +842 -0
  617. package/dist/types/core/geo/tiles/index.d.ts +8 -0
  618. package/dist/types/core/geo/tiles/types.d.ts +36 -0
  619. package/dist/types/core/geo/tiles/us-states.generated.d.ts +952 -0
  620. package/dist/types/core/geo/tiles/world.generated.d.ts +968 -0
  621. package/dist/types/core/geo/types.d.ts +146 -0
  622. package/dist/types/core/geometry.d.ts +102 -0
  623. package/dist/types/core/grid/sharedScale.d.ts +82 -0
  624. package/dist/types/core/icons.d.ts +227 -0
  625. package/dist/types/core/inputError.d.ts +14 -0
  626. package/dist/types/core/isoDate.d.ts +2 -0
  627. package/dist/types/core/isoTime.d.ts +7 -0
  628. package/dist/types/core/label/categoryRow.d.ts +332 -0
  629. package/dist/types/core/label/occupied.d.ts +41 -0
  630. package/dist/types/core/label/ownership.d.ts +83 -0
  631. package/dist/types/core/label/solver.d.ts +384 -0
  632. package/dist/types/core/label/tickRow.d.ts +78 -0
  633. package/dist/types/core/live/types.d.ts +50 -0
  634. package/dist/types/core/normalize/shared.d.ts +56 -0
  635. package/dist/types/core/notes.d.ts +174 -0
  636. package/dist/types/core/othersShade.d.ts +9 -0
  637. package/dist/types/core/periodYears.d.ts +9 -0
  638. package/dist/types/core/polyline.d.ts +11 -0
  639. package/dist/types/core/rangeRules.d.ts +19 -0
  640. package/dist/types/core/ratioTier.d.ts +120 -0
  641. package/dist/types/core/readerStrings.d.ts +13 -0
  642. package/dist/types/core/reading.d.ts +120 -0
  643. package/dist/types/core/registry.d.ts +178 -0
  644. package/dist/types/core/repaintGeometry.d.ts +19 -0
  645. package/dist/types/core/request.d.ts +124 -0
  646. package/dist/types/core/rows.d.ts +47 -0
  647. package/dist/types/core/scale.d.ts +106 -0
  648. package/dist/types/core/schema/capability.d.ts +229 -0
  649. package/dist/types/core/schema/namedColumns.d.ts +45 -0
  650. package/dist/types/core/schema/reference.d.ts +31 -0
  651. package/dist/types/core/schema/refusals.d.ts +45 -0
  652. package/dist/types/core/schema/unknownKeys.d.ts +45 -0
  653. package/dist/types/core/seriesIdentity.d.ts +120 -0
  654. package/dist/types/core/shareRounding.d.ts +49 -0
  655. package/dist/types/core/sizing.d.ts +330 -0
  656. package/dist/types/core/staticFooter.d.ts +6 -0
  657. package/dist/types/core/story.d.ts +41 -0
  658. package/dist/types/core/structureCounts.d.ts +10 -0
  659. package/dist/types/core/svg/renderSvg.d.ts +51 -0
  660. package/dist/types/core/target.d.ts +89 -0
  661. package/dist/types/core/text.d.ts +113 -0
  662. package/dist/types/core/theme.d.ts +478 -0
  663. package/dist/types/core/themeFields.d.ts +11 -0
  664. package/dist/types/core/themeRules.d.ts +111 -0
  665. package/dist/types/core/themeShape.d.ts +87 -0
  666. package/dist/types/core/themeValidate.d.ts +15 -0
  667. package/dist/types/core/timeAxis.d.ts +106 -0
  668. package/dist/types/core/types/annotations.d.ts +227 -0
  669. package/dist/types/core/types/cell.d.ts +82 -0
  670. package/dist/types/core/types/data.d.ts +314 -0
  671. package/dist/types/core/types/diagram.d.ts +234 -0
  672. package/dist/types/core/types/index.d.ts +8 -0
  673. package/dist/types/core/types/options.d.ts +1583 -0
  674. package/dist/types/core/types/scene.d.ts +990 -0
  675. package/dist/types/core/types/sizing.d.ts +51 -0
  676. package/dist/types/core/types/table.d.ts +873 -0
  677. package/dist/types/core/types/theme.d.ts +806 -0
  678. package/dist/types/core/zoom.d.ts +106 -0
  679. package/dist/types/fixtures/index.d.ts +40 -0
  680. package/dist/types/fixtures/registry.d.ts +15 -0
  681. package/dist/types/fonts.d.ts +10 -0
  682. package/dist/types/index.d.ts +70 -0
  683. package/dist/types/react/BoardplotTheme.d.ts +9 -0
  684. package/dist/types/react/DimSwitchChart.d.ts +36 -0
  685. package/dist/types/react/ScaleGroup.d.ts +31 -0
  686. package/dist/types/react/SceneRenderer.d.ts +23 -0
  687. package/dist/types/react/SizePlaceholder.d.ts +51 -0
  688. package/dist/types/react/StoryFrame.d.ts +42 -0
  689. package/dist/types/react/TableChart.d.ts +220 -0
  690. package/dist/types/react/a11ySurface.d.ts +20 -0
  691. package/dist/types/react/barrelCharts.d.ts +1023 -0
  692. package/dist/types/react/charts/bar.d.ts +28 -0
  693. package/dist/types/react/charts/bartable.d.ts +27 -0
  694. package/dist/types/react/charts/box.d.ts +27 -0
  695. package/dist/types/react/charts/bullet.d.ts +28 -0
  696. package/dist/types/react/charts/butterfly.d.ts +28 -0
  697. package/dist/types/react/charts/choropleth.d.ts +27 -0
  698. package/dist/types/react/charts/cohort.d.ts +52 -0
  699. package/dist/types/react/charts/column.d.ts +27 -0
  700. package/dist/types/react/charts/combo.d.ts +7 -0
  701. package/dist/types/react/charts/creative.d.ts +27 -0
  702. package/dist/types/react/charts/diagram.d.ts +162 -0
  703. package/dist/types/react/charts/dimswitch.d.ts +6 -0
  704. package/dist/types/react/charts/dot.d.ts +28 -0
  705. package/dist/types/react/charts/funnel.d.ts +28 -0
  706. package/dist/types/react/charts/gantt.d.ts +28 -0
  707. package/dist/types/react/charts/grid.d.ts +29 -0
  708. package/dist/types/react/charts/heatmap.d.ts +28 -0
  709. package/dist/types/react/charts/histogram.d.ts +27 -0
  710. package/dist/types/react/charts/kpi.d.ts +28 -0
  711. package/dist/types/react/charts/likert.d.ts +27 -0
  712. package/dist/types/react/charts/line.d.ts +28 -0
  713. package/dist/types/react/charts/mekko.d.ts +28 -0
  714. package/dist/types/react/charts/pareto.d.ts +28 -0
  715. package/dist/types/react/charts/pie.d.ts +28 -0
  716. package/dist/types/react/charts/pvm.d.ts +27 -0
  717. package/dist/types/react/charts/pyramid.d.ts +27 -0
  718. package/dist/types/react/charts/sankey.d.ts +27 -0
  719. package/dist/types/react/charts/scatter.d.ts +28 -0
  720. package/dist/types/react/charts/slope.d.ts +28 -0
  721. package/dist/types/react/charts/sparkline.d.ts +28 -0
  722. package/dist/types/react/charts/status.d.ts +27 -0
  723. package/dist/types/react/charts/table.d.ts +6 -0
  724. package/dist/types/react/charts/tilemap.d.ts +27 -0
  725. package/dist/types/react/charts/treemap.d.ts +27 -0
  726. package/dist/types/react/charts/variance.d.ts +28 -0
  727. package/dist/types/react/charts/waffle.d.ts +28 -0
  728. package/dist/types/react/charts/waterfall.d.ts +28 -0
  729. package/dist/types/react/createChartComponent.d.ts +135 -0
  730. package/dist/types/react/export/clipboard.d.ts +8 -0
  731. package/dist/types/react/export/csv.d.ts +2 -0
  732. package/dist/types/react/export/frame.d.ts +35 -0
  733. package/dist/types/react/export/index.d.ts +7 -0
  734. package/dist/types/react/export/png.d.ts +14 -0
  735. package/dist/types/react/export/svg.d.ts +5 -0
  736. package/dist/types/react/export/types.d.ts +69 -0
  737. package/dist/types/react/export/useExport.d.ts +17 -0
  738. package/dist/types/react/exportLink.d.ts +49 -0
  739. package/dist/types/react/footerFrame.d.ts +25 -0
  740. package/dist/types/react/hover/dataTable.d.ts +13 -0
  741. package/dist/types/react/hover/engine.d.ts +210 -0
  742. package/dist/types/react/hover/keyboard.d.ts +44 -0
  743. package/dist/types/react/hover/labelCard.d.ts +170 -0
  744. package/dist/types/react/hover/placement.d.ts +49 -0
  745. package/dist/types/react/index.d.ts +16 -0
  746. package/dist/types/react/parseChartSpec.d.ts +16 -0
  747. package/dist/types/react/prepare.d.ts +32 -0
  748. package/dist/types/react/prepared.d.ts +53 -0
  749. package/dist/types/react/preparedTable.d.ts +15 -0
  750. package/dist/types/react/rowsInput.d.ts +55 -0
  751. package/dist/types/react/rowsModule.d.ts +18 -0
  752. package/dist/types/react/rowsStore.d.ts +50 -0
  753. package/dist/types/react/scale-group.d.ts +2 -0
  754. package/dist/types/react/scaleGroupContext.d.ts +22 -0
  755. package/dist/types/react/scenePaint.d.ts +10 -0
  756. package/dist/types/react/scrollState.d.ts +26 -0
  757. package/dist/types/react/spec.d.ts +82 -0
  758. package/dist/types/react/specValidation.d.ts +45 -0
  759. package/dist/types/react/story.d.ts +15 -0
  760. package/dist/types/react/theme.d.ts +9 -0
  761. package/dist/types/react/themeContext.d.ts +44 -0
  762. package/dist/types/react/useChartLayout.d.ts +22 -0
  763. package/dist/types/react/useContainerSize.d.ts +57 -0
  764. package/dist/types/react/useHover.d.ts +100 -0
  765. package/dist/types/react/useZoom.d.ts +50 -0
  766. package/dist/types/rows.d.ts +63 -0
  767. package/dist/types/tableLooks.d.ts +6 -0
  768. package/dist/types/theme.d.ts +3 -0
  769. package/dist/types/validate.d.ts +3 -0
  770. package/dist/validate.d.ts +1 -0
  771. package/dist/validate.js +223 -0
  772. package/docs/FONTS.md +68 -0
  773. package/docs/TELEMETRY.md +94 -0
  774. package/docs/manual.md +850 -0
  775. package/docs/reference/bar.md +222 -0
  776. package/docs/reference/bartable.md +143 -0
  777. package/docs/reference/box.md +93 -0
  778. package/docs/reference/bullet.md +118 -0
  779. package/docs/reference/butterfly.md +117 -0
  780. package/docs/reference/choropleth.md +148 -0
  781. package/docs/reference/cohort.md +149 -0
  782. package/docs/reference/column.md +275 -0
  783. package/docs/reference/combo.md +219 -0
  784. package/docs/reference/creative.md +147 -0
  785. package/docs/reference/diagram.md +191 -0
  786. package/docs/reference/dimswitch.md +1395 -0
  787. package/docs/reference/dot.md +117 -0
  788. package/docs/reference/fixtures.md +1089 -0
  789. package/docs/reference/funnel.md +121 -0
  790. package/docs/reference/gantt.md +138 -0
  791. package/docs/reference/grid.md +302 -0
  792. package/docs/reference/heatmap.md +127 -0
  793. package/docs/reference/histogram.md +77 -0
  794. package/docs/reference/kpi.md +115 -0
  795. package/docs/reference/likert.md +113 -0
  796. package/docs/reference/line.md +436 -0
  797. package/docs/reference/mekko.md +114 -0
  798. package/docs/reference/options.md +313 -0
  799. package/docs/reference/pareto.md +102 -0
  800. package/docs/reference/pie.md +114 -0
  801. package/docs/reference/pvm.md +114 -0
  802. package/docs/reference/pyramid.md +99 -0
  803. package/docs/reference/react.md +706 -0
  804. package/docs/reference/reading.md +28 -0
  805. package/docs/reference/sankey.md +110 -0
  806. package/docs/reference/scatter.md +211 -0
  807. package/docs/reference/slope.md +126 -0
  808. package/docs/reference/sparkline.md +74 -0
  809. package/docs/reference/status.md +107 -0
  810. package/docs/reference/table.md +673 -0
  811. package/docs/reference/theme.md +361 -0
  812. package/docs/reference/tilemap.md +121 -0
  813. package/docs/reference/treemap.md +86 -0
  814. package/docs/reference/variance.md +126 -0
  815. package/docs/reference/waffle.md +106 -0
  816. package/docs/reference/waterfall.md +164 -0
  817. package/llms.txt +57 -0
  818. package/package.json +437 -4
@@ -0,0 +1,2008 @@
1
+ import {
2
+ buildGeoScale,
3
+ chartString,
4
+ fitGeoLonLat,
5
+ geoLabelFont,
6
+ geoOverlayDiameter,
7
+ geoOverlayLegend,
8
+ geoPolarityCaption,
9
+ geoScaleHints,
10
+ geoStateCounts,
11
+ geoStateLabel,
12
+ geoStateLegend,
13
+ geoStatePattern,
14
+ geoStateSummary,
15
+ ingestGeoRegions,
16
+ renderGeoOverlays,
17
+ reserveGeoOverlayGlyphs
18
+ } from "./chunk-H63XQ3OO.js";
19
+ import {
20
+ geoOptionRefusals
21
+ } from "./chunk-LNKY5Z2X.js";
22
+ import {
23
+ prepareOutlineDistance
24
+ } from "./chunk-ADKCLH3Z.js";
25
+ import {
26
+ stepDownFont
27
+ } from "./chunk-ZQF34VPS.js";
28
+ import {
29
+ chartTheme
30
+ } from "./chunk-3QWZAEW5.js";
31
+ import {
32
+ rowDrivenHeight
33
+ } from "./chunk-GZTNTHSW.js";
34
+ import {
35
+ structureCount
36
+ } from "./chunk-LFX7W4B7.js";
37
+ import {
38
+ geoRegionIdIndex,
39
+ resolveGeoRegionId
40
+ } from "./chunk-IYEFEBRN.js";
41
+ import {
42
+ getGeoPack
43
+ } from "./chunk-IDDA5INB.js";
44
+ import {
45
+ levenshtein
46
+ } from "./chunk-FIANWJXX.js";
47
+ import {
48
+ chartSizing,
49
+ resolveSizing
50
+ } from "./chunk-RL3NUWMY.js";
51
+ import {
52
+ PRIORITY,
53
+ authoredNotes,
54
+ boxGap,
55
+ composedTextRole,
56
+ createOccupiedIndex,
57
+ frameTextOptions,
58
+ labelCtx,
59
+ labelsToNodes,
60
+ legendRequired,
61
+ rectHitsConvexPolygon,
62
+ rectLineDistance,
63
+ rectsOverlap,
64
+ round2,
65
+ solveFrame,
66
+ solveLabels,
67
+ unitPrinted
68
+ } from "./chunk-SS42FJVN.js";
69
+ import {
70
+ formatterFromExample
71
+ } from "./chunk-RGZGLKFB.js";
72
+ import {
73
+ autoDecimals,
74
+ formatAutomaticNumber
75
+ } from "./chunk-53OYF4ZT.js";
76
+ import {
77
+ canvasMargin,
78
+ dashToken,
79
+ effectiveFill,
80
+ emphasisWeight,
81
+ paintColor,
82
+ resolveSemanticPaletteTheme,
83
+ strokeToken,
84
+ textScaleOf
85
+ } from "./chunk-CWDHCSL2.js";
86
+ import {
87
+ NormalizeError,
88
+ TARGET_SIZE,
89
+ accessibleTitle,
90
+ resolveSize,
91
+ resolveSubtitle
92
+ } from "./chunk-SGD3ZHID.js";
93
+ import {
94
+ maxOf,
95
+ pushAll
96
+ } from "./chunk-WYJEOMNY.js";
97
+ import {
98
+ compareText,
99
+ defaultMeasurer,
100
+ wrapText
101
+ } from "./chunk-AG2CJ4JY.js";
102
+
103
+ // src/core/geo/decode.ts
104
+ var packedArcCache = /* @__PURE__ */ new WeakMap();
105
+ function decodeArc(arc, pack) {
106
+ let x = 0, y = 0, out = [];
107
+ for (let delta of arc)
108
+ x += delta[0], y += delta[1], out.push([
109
+ x * pack.transform.scale[0] + pack.transform.translate[0],
110
+ y * pack.transform.scale[1] + pack.transform.translate[1]
111
+ ]);
112
+ return out;
113
+ }
114
+ function arcAt(pack, index) {
115
+ let decoded = packedArcCache.get(pack);
116
+ return decoded || (decoded = decodePackedArcs(pack.arcs), packedArcCache.set(pack, decoded)), decoded[index];
117
+ }
118
+ function decodePackedArcs(packed) {
119
+ if (packed.encoding !== "delta-zigzag-varint-base64")
120
+ throw new Error(`unsupported geo arc encoding '${String(packed.encoding)}'`);
121
+ let binary = atob(packed.data), offset = 0, readVarint = () => {
122
+ let value = 0, shift = 0;
123
+ for (; offset < binary.length; ) {
124
+ let byte = binary.charCodeAt(offset++);
125
+ if (value += (byte & 127) * 2 ** shift, (byte & 128) === 0) return value;
126
+ if (shift += 7, shift > 49) throw new Error("geo packed arc varint exceeds the safe integer range");
127
+ }
128
+ throw new Error("geo packed arc payload ended inside a varint");
129
+ }, signed = (value) => value % 2 === 0 ? value / 2 : -(value + 1) / 2, arcs = packed.lengths.map(
130
+ (length) => Array.from({ length }, () => [signed(readVarint()), signed(readVarint())])
131
+ );
132
+ if (offset !== binary.length) throw new Error("geo packed arc payload has trailing bytes");
133
+ return arcs;
134
+ }
135
+ function arcByRef(pack, cache, ref) {
136
+ let index = ref < 0 ? ~ref : ref, decoded = cache.get(index);
137
+ if (!decoded) {
138
+ let arc = arcAt(pack, index);
139
+ if (!arc) throw new Error(`geo pack '${pack.id}' references missing arc ${index}`);
140
+ decoded = decodeArc(arc, pack), cache.set(index, decoded);
141
+ }
142
+ return ref < 0 ? decoded.slice().reverse() : decoded;
143
+ }
144
+ function decodeLine(pack, cache, refs) {
145
+ let line = [];
146
+ for (let ref of refs) {
147
+ let arc = arcByRef(pack, cache, ref);
148
+ for (let i = line.length === 0 ? 0 : 1; i < arc.length; i++) line.push(arc[i]);
149
+ }
150
+ return line;
151
+ }
152
+ function decodeRing(pack, cache, refs) {
153
+ let ring = decodeLine(pack, cache, refs);
154
+ if (ring.length > 0) {
155
+ let first = ring[0], last = ring[ring.length - 1];
156
+ (first[0] !== last[0] || first[1] !== last[1]) && ring.push(first);
157
+ }
158
+ return ring;
159
+ }
160
+ function decodePolygons(pack, cache, refs) {
161
+ return refs.map((polygon) => polygon.map((ring) => decodeRing(pack, cache, ring)));
162
+ }
163
+ var decodedPackCache = /* @__PURE__ */ new WeakMap();
164
+ function decodeGeoPack(pack) {
165
+ let known = decodedPackCache.get(pack);
166
+ if (known) return known;
167
+ let cache = /* @__PURE__ */ new Map(), regions = pack.regions.map((region) => ({
168
+ id: region.id,
169
+ aliases: region.aliases,
170
+ polygons: decodePolygons(pack, cache, region.polygons),
171
+ anchor: region.anchor,
172
+ geometryClass: region.geometryClass ?? "administrative",
173
+ microState: region.microState ?? !1,
174
+ ...region.marker ? { marker: region.marker } : {}
175
+ })), boundaries = (pack.boundaries ?? []).map((boundary) => ({
176
+ id: boundary.id,
177
+ geometryClass: boundary.geometryClass,
178
+ lines: boundary.lines.map((line) => decodeLine(pack, cache, line))
179
+ })), decoded = { pack, regions, boundaries };
180
+ return decodedPackCache.set(pack, decoded), decoded;
181
+ }
182
+ function fitDecodedGeoPack(decoded, frame, reuse) {
183
+ let [minX, minY, maxX, maxY] = decoded.pack.bounds, sx = frame.w / (maxX - minX), sy = frame.h / (maxY - minY), scale = sx < sy ? sx : sy, offsetX = frame.x + (frame.w - (maxX - minX) * scale) / 2 - minX * scale, offsetY = frame.y + (frame.h - (maxY - minY) * scale) / 2 - minY * scale, points = reuse !== void 0 && reuse.pack === decoded.pack && reuse.scale === scale && reuse.offsetX === offsetX && reuse.offsetY === offsetY ? reuse : void 0, fitPoint = (point) => [
184
+ point[0] * scale + offsetX,
185
+ point[1] * scale + offsetY
186
+ ];
187
+ return {
188
+ pack: decoded.pack,
189
+ frame,
190
+ scale,
191
+ offsetX,
192
+ offsetY,
193
+ regions: decoded.regions.map((region, index) => ({
194
+ id: region.id,
195
+ aliases: region.aliases,
196
+ polygons: points?.regions[index].polygons ?? region.polygons.map((polygon) => polygon.map((ring) => ring.map(fitPoint))),
197
+ anchor: {
198
+ ...region.anchor,
199
+ x: region.anchor.x * scale + offsetX,
200
+ y: region.anchor.y * scale + offsetY,
201
+ clearance: region.anchor.clearance * scale
202
+ },
203
+ geometryClass: region.geometryClass,
204
+ microState: region.microState,
205
+ ...region.marker ? {
206
+ marker: {
207
+ x: region.marker.x * scale + offsetX,
208
+ y: region.marker.y * scale + offsetY,
209
+ radius: region.marker.radius * scale
210
+ }
211
+ } : {}
212
+ })),
213
+ boundaries: decoded.boundaries.map((boundary, index) => ({
214
+ id: boundary.id,
215
+ geometryClass: boundary.geometryClass,
216
+ lines: points?.boundaries[index].lines ?? boundary.lines.map((line) => line.map(fitPoint))
217
+ }))
218
+ };
219
+ }
220
+ var lastFit;
221
+ function fitGeoPack(pack, frame) {
222
+ return lastFit = fitDecodedGeoPack(decodeGeoPack(pack), frame, lastFit);
223
+ }
224
+
225
+ // src/core/charts/choropleth/smallMembers.ts
226
+ function ringArea(ring) {
227
+ return Math.abs(ring.reduce((sum, point, index) => {
228
+ let next = ring[(index + 1) % ring.length];
229
+ return sum + point[0] * next[1] - next[0] * point[1];
230
+ }, 0)) / 2;
231
+ }
232
+ function smallRegionIds(pack, eligible, explicit, options) {
233
+ let threshold = options.smallRegionArea ?? (options.labels === "all" ? 0 : 1e-3);
234
+ if (threshold <= 0 || eligible.size === 0) return /* @__PURE__ */ new Set();
235
+ let area = (pack.bounds[2] - pack.bounds[0]) * (pack.bounds[3] - pack.bounds[1]);
236
+ return new Set(decodeGeoPack(pack).regions.filter((region) => !eligible.has(region.id) || explicit.has(region.id) || options.labelPlacements?.[`category:${region.id}`] !== void 0 ? !1 : region.polygons.reduce((total, polygon) => total + polygon.reduce(
237
+ (sum, ring, index) => sum + (index === 0 ? 1 : -1) * ringArea(ring),
238
+ 0
239
+ ), 0) / area < threshold).map((region) => region.id));
240
+ }
241
+ var RAMP_H = 8, TICK_BELOW = 4, RAMP_MIN_W = 160, TITLE_MAX_W = 240, SWATCH = 12, SWATCH_GAP = 5, BLOCK_GAP = 24, MAP_GAP = 12, MIN_MAP_H = 80, LABEL_GAP = 6;
242
+ function layoutMapKeys(input) {
243
+ return mapKeys({ ...input, dryRun: !1 });
244
+ }
245
+ function mapKeysSize(input) {
246
+ return mapKeys({ ...input, dryRun: !0 }).dry;
247
+ }
248
+ function mapKeys(input) {
249
+ try {
250
+ return mapKeysOnce(input);
251
+ } catch (error) {
252
+ if (input.classRanges || !(error instanceof NormalizeError) || error.code !== "geo-key-overflow") throw error;
253
+ return mapKeysOnce({ ...input, classRanges: !0 });
254
+ }
255
+ }
256
+ function mapKeysOnce(input) {
257
+ let { plot, scale, theme, measure, fmt, occupied } = input, nodes = [], font = { family: theme.type.family, ...theme.type.axis }, memberFont = { family: theme.type.family, ...theme.type.label }, heading = { ...font }, lineOf = (f) => f.size * (f.lineHeight ?? 1.2), rowH = Math.max(SWATCH + 6, Math.max(lineOf(font), lineOf(memberFont)) + 4), width = (text, f = font) => measure(text, f).width, { min, max, midpoint } = scale, noData = scale.legend.find((item) => item.id === "no-data"), noValueKeys = scale.legend.filter((item) => item.id === "no-data" || item.id === "not-in-data" || item.id.startsWith("state:")), hasRamp = min !== null && max !== null, classes = hasRamp && (max !== min || scale.explicitSteps) ? scale.edges ? scale.edges.length - 1 : input.classes : void 0, named = (value) => `${fmt(value)}${input.midpointLabel && value === midpoint ? ` ${input.midpointLabel}` : ""}`, edges = hasRamp ? classes ? scale.edges ?? Array.from({ length: classes + 1 }, (_, index) => min + index / classes * (max - min)) : max === min ? [min] : [min, max] : [], edgeText = scale.edgeFmt, ranges = classes && input.classRanges, tickEdges = classes ? edges.slice(1, -1) : edges, edgeTexts = ranges ? Array.from({ length: classes }, (_, i) => i === 0 ? `<${edgeText(edges[1])}` : i === classes - 1 ? `\u2265${edgeText(edges[i])}` : `${edgeText(edges[i])}\u2013<${edgeText(edges[i + 1])}`) : tickEdges.map((value) => classes ? edgeText(value) : named(value)), midIn = hasRamp && midpoint !== null && midpoint > min && midpoint < max && !(classes && input.midpointLabel === void 0 && tickEdges.includes(midpoint)), midText = midIn ? named(midpoint) : "", rowW = (label) => SWATCH + SWATCH_GAP + width(label), labelsWant = (f) => {
258
+ let widths = edgeTexts.map((text) => width(text, f));
259
+ return classes ? classes * (ranges ? maxOf(widths) + 2 * LABEL_GAP : maxOf(widths) * 1.5 + LABEL_GAP) : widths.reduce((sum, w) => sum + w + LABEL_GAP, 0) + (midIn ? width(midText, f) + LABEL_GAP : 0);
260
+ }, natural = Math.max(
261
+ RAMP_MIN_W,
262
+ Math.min(TITLE_MAX_W, input.title ? width(input.title, heading) : 0),
263
+ labelsWant(font),
264
+ maxOf(noValueKeys.map((item) => rowW(item.label)))
265
+ ), members = [...input.smallIds].sort(compareText).map((id) => ({
266
+ id,
267
+ code: shortestRegionName(input.pack.regions.find((region) => region.id === id), memberFont, measure),
268
+ value: input.values.get(id) ?? null,
269
+ state: input.states?.get(id),
270
+ listed: input.values.has(id)
271
+ })), textOf = (value, listed, state) => state ? geoStateLabel(state, input.options) : listed ? value === null ? chartString(input.options, "valueMissing") : fmt(value) : chartString(input.options, "notInData"), smallTitle = input.smallTitle, headerH = lineOf(heading) + 6, codeW = Math.max(0, maxOf(members.map((member) => width(member.code, memberFont)))), valueW = Math.max(0, maxOf(members.map((member) => width(textOf(member.value, member.listed, member.state), memberFont)))), columnGap = members.length > VALUE_TABLE_MAX_ROWS ? MAP_GAP / 2 : MAP_GAP, columnW = SWATCH + SWATCH_GAP + codeW + 12 + valueW + columnGap, smallBlock = (maxW, minRows) => {
272
+ let rows2 = Math.max(1, minRows, Math.ceil(members.length / Math.max(1, Math.floor((maxW + columnGap) / columnW)))), columns = Math.ceil(members.length / rows2);
273
+ return {
274
+ rows: rows2,
275
+ smallW: members.length ? Math.max(width(smallTitle, heading), columns * columnW - columnGap) : 0,
276
+ smallH: members.length ? headerH + Math.min(rows2, members.length) * rowH : 0
277
+ };
278
+ }, columnRows = (keyH2) => Math.floor((plot.h - keyH2 - BLOCK_GAP - headerH) / rowH), oneColumnW = members.length ? Math.max(width(smallTitle, heading), columnW - columnGap) : 0, labelDrop = classes && !ranges ? TICK_BELOW + 3 : 3, fitKey = (keyW2) => {
279
+ let at2 = (value) => {
280
+ if (!classes) return max === min ? 0 : (value - min) / (max - min) * keyW2;
281
+ let index = Math.min(edges.length - 2, Math.max(0, edges.slice(1).filter((edge) => value >= edge).length)), span = edges[index + 1] - edges[index];
282
+ return (index + (span ? (value - edges[index]) / span : 0)) / (edges.length - 1) * keyW2;
283
+ }, fontLadder = [font];
284
+ for (let next = stepDownFont(theme, font, "axis", input.target, input.textScale); next; next = stepDownFont(theme, next, "axis", input.target, input.textScale)) fontLadder.push(next);
285
+ let edgeLayout = (f, step, wrap = !1) => {
286
+ let place = (index, lines) => {
287
+ let w = Math.max(...lines.map((line) => width(line, f))), center = ranges ? (index + 0.5) / classes * keyW2 : at2(tickEdges[index]), left = Math.min(keyW2 - w, Math.max(0, center - w / 2));
288
+ return { index, lines, left, w, row: index % step };
289
+ }, placed = edgeTexts.map((text, index) => {
290
+ let wrapWidth = Math.max(1, keyW2 / 2 - LABEL_GAP), parts = ranges && text.includes("\u2013<") ? text.replace("\u2013<", `\u2013
291
+ <`).split(`
292
+ `) : [text], wrapped = wrap ? parts.map((part) => wrapText(part, f, wrapWidth, 3, measure)) : void 0;
293
+ return { ...place(index, wrapped?.flatMap((part) => part.lines) ?? [text]), truncated: wrapped?.some((part) => part.truncated) ?? !1 };
294
+ }), fits = placed.every((entry, i) => !entry.truncated && entry.w <= keyW2 && placed.slice(0, i).every((prior) => prior.row !== entry.row || prior.left + prior.w + LABEL_GAP <= entry.left));
295
+ return { placed, fits, place };
296
+ }, plan2 = (() => {
297
+ for (let f2 of fontLadder) {
298
+ let layout = edgeLayout(f2, 1);
299
+ if (layout.fits) return { f: f2, placed: layout.placed };
300
+ }
301
+ let f = fontLadder.at(-1);
302
+ for (let wrap of [!1, !0]) for (let step of [2, 3]) {
303
+ let layout = edgeLayout(f, step, wrap);
304
+ if (layout.fits) return { f, placed: layout.placed };
305
+ }
306
+ throw new NormalizeError("geo-key-overflow", "options.format", "Colour-key ticks do not fit after staggering and wrapping; use a shorter format or a wider canvas.");
307
+ })(), edgeFont2 = plan2.f, edgeLineH = lineOf(edgeFont2), rowLines = Math.max(1, maxOf(plan2.placed.map((entry) => entry.lines.length))), edgeRows = Math.max(1, maxOf(plan2.placed.map((entry) => entry.row + 1))), edgeRowGap = ranges ? 3 : 0, edgeRowPitch2 = rowLines * edgeLineH + edgeRowGap, edgeRowH = edgeRows * edgeRowPitch2 - edgeRowGap, midLines2 = midIn ? wrapText(midText, edgeFont2, keyW2, 2, measure).lines : [], midW = midIn ? Math.max(...midLines2.map((line) => width(line, edgeFont2))) : 0, midLeft2 = midIn ? Math.min(keyW2 - midW, Math.max(0, at2(midpoint) - midW / 2)) : 0, midAbove2 = midIn && (classes !== void 0 || midLines2.length > 1 || plan2.placed.some((entry) => midLeft2 < entry.left + entry.w + LABEL_GAP && midLeft2 + midW + LABEL_GAP > entry.left)), titleWrap2 = input.title ? wrapText(input.title, heading, keyW2, 2, measure) : void 0, titleLines2 = titleWrap2?.lines ?? [], y = titleLines2.length ? titleLines2.length * lineOf(heading) + 6 : 0, midLabelY2 = y;
308
+ midAbove2 && (y += midLines2.length * edgeLineH + 3);
309
+ let rampY2 = y;
310
+ hasRamp && (y += RAMP_H + labelDrop + Math.max(edgeRowH, midIn && !midAbove2 ? edgeLineH : 0));
311
+ let caption2 = hasRamp && input.caption ? wrapText(input.caption, edgeFont2, keyW2, 2, measure).lines : [], captionY2 = y + 3;
312
+ caption2.length && (y = captionY2 + caption2.length * edgeLineH);
313
+ let noDataY2 = y + (noValueKeys.length && hasRamp ? 6 : 0);
314
+ return noValueKeys.length && (y = noDataY2 + rowH * noValueKeys.length), { keyW: keyW2, at: at2, plan: plan2, edgeFont: edgeFont2, edgeRowPitch: edgeRowPitch2, midLines: midLines2, midLeft: midLeft2, midAbove: midAbove2, titleWrap: titleWrap2, titleLines: titleLines2, midLabelY: midLabelY2, rampY: rampY2, noDataY: noDataY2, keyH: y, caption: caption2, captionY: captionY2 };
315
+ }, position = input.position === "auto" ? "top" : input.position, besideCap = plot.w - (members.length ? BLOCK_GAP + oneColumnW : 0), { keyW, at, plan, edgeFont, edgeRowPitch, midLines, midLeft, midAbove, titleWrap, titleLines, midLabelY, rampY, noDataY, keyH, caption, captionY } = fitKey(position === "right" ? Math.max(1, Math.min(input.keyWidth ?? natural, plot.w / 2)) : Math.max(1, Math.min(input.keyWidth ?? natural, besideCap >= Math.min(natural, RAMP_MIN_W) ? besideCap : plot.w))), besideBlock = smallBlock(plot.w - keyW - BLOCK_GAP, Math.floor((keyH - headerH) / rowH)), underBlock = smallBlock(plot.w, 1), beside = position !== "right" && members.length > 0 && keyW + BLOCK_GAP + oneColumnW <= plot.w && Math.max(keyH, besideBlock.smallH) <= keyH + BLOCK_GAP + underBlock.smallH, { rows, smallW, smallH } = position === "right" ? smallBlock(1 / 0, columnRows(keyH)) : beside ? besideBlock : underBlock, stacked = !beside && members.length > 0, blocksW = beside ? keyW + (members.length ? BLOCK_GAP + smallW : 0) : Math.max(keyW, smallW), blocksH = beside ? Math.max(keyH, smallH) : keyH + (stacked ? BLOCK_GAP + smallH : 0), keyX = position === "right" ? plot.x + plot.w - blocksW : plot.x, keyY = position === "bottom" ? plot.y + plot.h - blocksH : plot.y, smallX = beside ? keyX + keyW + BLOCK_GAP : keyX, smallY = beside ? keyY : keyY + keyH + BLOCK_GAP, mapGap = input.compact ? 4 : MAP_GAP, minPlotH = position === "right" ? blocksH > plot.h ? blocksH : 0 : blocksH + mapGap + MIN_MAP_H;
316
+ if (input.dryRun) return { dry: { w: blocksW, h: blocksH } };
317
+ let mapPlot = position === "right" ? { ...plot, w: Math.max(10, plot.w - blocksW - MAP_GAP) } : { ...plot, y: position === "top" ? plot.y + blocksH + mapGap : plot.y, h: Math.max(10, plot.h - blocksH - mapGap) }, texts = [], addText = (id, lines, x, ty, f, role, title) => texts.push({ id, lines, x, y: ty, font: f, w: Math.max(...lines.map((line) => width(line, f))), h: lines.length * lineOf(f), role, ...title ? { title } : {} }), items = [];
318
+ if (titleLines.length && addText("legend-title", titleLines, keyX, keyY, heading, "caption", titleWrap.truncated ? input.title : void 0), hasRamp) {
319
+ let steps = classes ?? (max === min ? 1 : Math.max(1, Math.round(keyW / 4)));
320
+ for (let i = 0; i < steps; i++) {
321
+ let lo = min + i / steps * (max - min), hi = min + (i + 1) / steps * (max - min), value = steps === 1 ? min : !classes && midpoint !== null && midpoint >= lo && (midpoint < hi || i === steps - 1 && midpoint <= hi) ? midpoint : min + (i + 0.5) / steps * (max - min);
322
+ nodes.push({
323
+ t: "rect",
324
+ id: `legend-ramp:${i}`,
325
+ // Each slice overlaps the next by half a pixel so no seam shows between them.
326
+ rect: { x: keyX + i * keyW / steps, y: keyY + rampY, w: keyW / steps + (i < steps - 1 ? 0.5 : 0), h: RAMP_H },
327
+ fill: classes ? scale.legend[i].paint : scale.paint(value),
328
+ owner: {},
329
+ part: "swatch"
330
+ });
331
+ }
332
+ occupied.claim({ x: keyX, y: keyY + rampY, w: keyW, h: RAMP_H }, "legend", {}, "swatch");
333
+ let labelY = keyY + rampY + RAMP_H + labelDrop;
334
+ for (let entry of plan.placed) {
335
+ let text = edgeTexts[entry.index];
336
+ addText(
337
+ `legend-edge:${entry.index}`,
338
+ entry.lines,
339
+ keyX + entry.left,
340
+ labelY + entry.row * edgeRowPitch,
341
+ edgeFont,
342
+ composedTextRole(text),
343
+ entry.lines.join(" ") !== text ? text : void 0
344
+ ), classes && !ranges && nodes.push({ t: "line", id: `legend-tick:${entry.index}`, x1: keyX + at(tickEdges[entry.index]), x2: keyX + at(tickEdges[entry.index]), y1: keyY + rampY, y2: keyY + rampY + RAMP_H + TICK_BELOW, stroke: { token: "ink" }, width: strokeToken(theme, "rule"), owner: {}, part: "legendTick" });
345
+ }
346
+ if (midpoint !== null && midpoint >= min && midpoint <= max && max !== min) {
347
+ let tickX = keyX + at(midpoint);
348
+ nodes.push({
349
+ t: "line",
350
+ id: "legend-midpoint",
351
+ x1: tickX,
352
+ y1: keyY + rampY - 2,
353
+ x2: tickX,
354
+ y2: keyY + rampY + RAMP_H + 2,
355
+ stroke: { token: "ink" },
356
+ width: strokeToken(theme, "rule"),
357
+ owner: {},
358
+ part: "legendTick"
359
+ });
360
+ }
361
+ midIn && addText(
362
+ "legend-mid",
363
+ midLines,
364
+ keyX + midLeft,
365
+ midAbove ? keyY + midLabelY : labelY,
366
+ edgeFont,
367
+ composedTextRole(midText),
368
+ midLines.join(" ") !== midText ? midText : void 0
369
+ ), caption.length && addText("legend-caption", caption, keyX, keyY + captionY, edgeFont, "caption"), items.push({ id: "ramp", swatchNodeId: "legend-ramp:0", labelId: `label:${titleLines.length ? "legend-title" : "legend-edge:0"}` });
370
+ }
371
+ for (let [index, item] of noValueKeys.entries()) {
372
+ let ry = keyY + noDataY + index * rowH, rect = { x: keyX, y: ry + (rowH - SWATCH) / 2, w: SWATCH, h: SWATCH };
373
+ nodes.push({ t: "rect", id: `legend-swatch:${item.id}`, rect, fill: item.paint, ...item.hollow ? { pattern: "hollow" } : item.pattern ? { pattern: item.pattern } : {}, ...item.id === "not-in-data" ? { stroke: { token: "inkMuted" }, strokeWidth: strokeToken(theme, "hair") } : {}, owner: {}, part: "swatch" }), occupied.claim(rect, "legend", {}, "swatch"), addText(`legend-label:${item.id}`, [item.label], keyX + SWATCH + SWATCH_GAP, ry + (rowH - lineOf(font)) / 2, font, "caption"), items.push({ id: item.id, swatchNodeId: `legend-swatch:${item.id}`, labelId: `label:legend-label:${item.id}` });
374
+ }
375
+ let requests = texts.map((text) => ({
376
+ id: text.id,
377
+ kind: "scale",
378
+ typeRole: "axis",
379
+ owner: {},
380
+ text: text.lines.join(" "),
381
+ lines: text.lines,
382
+ font: text.font,
383
+ priority: PRIORITY.endpoint,
384
+ role: text.role,
385
+ ...text.title ? { title: text.title } : {},
386
+ candidates: [{ slot: `${text.id}:fixed`, rect: { x: text.x, y: text.y, w: text.w, h: text.h }, penalty: 0 }]
387
+ })), add = (id, label, rx, ry, kind, categoryId) => {
388
+ let selected = categoryId ? memberFont : heading, measured = measure(label, selected);
389
+ requests.push({
390
+ id,
391
+ kind,
392
+ typeRole: categoryId ? "label" : "axis",
393
+ owner: categoryId ? { categoryId } : {},
394
+ text: label,
395
+ lines: [label],
396
+ font: selected,
397
+ priority: PRIORITY.endpoint,
398
+ candidates: [{ slot: "smallMember", rect: { x: rx, y: ry + (rowH - measured.height) / 2, w: measured.width, h: measured.height }, penalty: 0 }],
399
+ // The block heading is a caption, not an annotation value,
400
+ // and so is the "No data" a null region reads out.
401
+ ...kind === "annotation" ? { role: "caption" } : { role: composedTextRole(label) }
402
+ });
403
+ };
404
+ if (members.length) {
405
+ let measured = measure(smallTitle, heading);
406
+ requests.push({
407
+ id: "small-members:title",
408
+ kind: "annotation",
409
+ typeRole: "axis",
410
+ owner: {},
411
+ text: smallTitle,
412
+ lines: [smallTitle],
413
+ font: heading,
414
+ priority: PRIORITY.endpoint,
415
+ role: "caption",
416
+ candidates: [{ slot: "smallMember", rect: { x: smallX, y: smallY, w: measured.width, h: measured.height }, penalty: 0 }]
417
+ });
418
+ }
419
+ members.forEach((member, index) => {
420
+ let left = smallX + Math.floor(index / rows) * columnW, ry = smallY + headerH + index % rows * rowH, rect = { x: left, y: ry + (rowH - SWATCH) / 2, w: SWATCH, h: SWATCH }, state = input.states?.get(member.id);
421
+ nodes.push({
422
+ t: "rect",
423
+ id: `small-member-swatch:${member.id}`,
424
+ rect,
425
+ fill: state ? { token: "inkMuted" } : member.listed ? member.value === null && noData ? noData.paint : scale.paint(member.value) : { token: "background" },
426
+ ...state ? { pattern: geoStatePattern(state) } : member.listed && member.value === null ? { pattern: "hatch45" } : {},
427
+ stroke: { token: "leader" },
428
+ strokeWidth: strokeToken(theme, "hair"),
429
+ owner: { categoryId: member.id },
430
+ part: "smallMemberSwatch"
431
+ }), occupied.claim(rect, "legend", { categoryId: member.id }, "smallMemberSwatch"), add(`category:${member.id}`, member.code, left + SWATCH + SWATCH_GAP, ry, "category", member.id);
432
+ let value = state ? geoStateLabel(state, input.options) : textOf(member.value, member.listed, member.state);
433
+ add(`small-member-value:${member.id}`, value, left + columnW - columnGap - width(value, memberFont), ry, "point", member.id);
434
+ });
435
+ let solved = solveLabels(requests, occupied, input.solveCtx), fontById = new Map(requests.map((request) => [request.id, request.font]));
436
+ pushAll(nodes, labelsToNodes(theme, solved.placed, (label) => fontById.get(label.id) ?? font));
437
+ let keyRect = { x: keyX, y: keyY, w: keyW, h: keyH };
438
+ return occupied.claim(keyRect, "legend", {}, "legend"), members.length && occupied.claim({ x: smallX, y: smallY, w: smallW, h: smallH }, "reserved", {}, "smallMembers"), {
439
+ ...solved,
440
+ nodes,
441
+ mapPlot,
442
+ blocks: { x: keyX, y: keyY, w: blocksW, h: blocksH },
443
+ position,
444
+ minPlotH,
445
+ legend: { rect: keyRect, items }
446
+ };
447
+ }
448
+ function shortestRegionName(region, font, measure) {
449
+ return [region.anchor.shortName, region.id].reduce((best, candidate) => {
450
+ let width = measure(candidate, font).width, bestWidth = measure(best, font).width;
451
+ return width < bestWidth || width === bestWidth && compareText(candidate, best) < 0 ? candidate : best;
452
+ });
453
+ }
454
+ var VALUE_TABLE_MAX_ROWS = 20, TABLE_COLUMN_GAP = 16, GROUP_GAP = 6, COLUMN_STRETCH = 1.6;
455
+ function valueTable(input) {
456
+ let { theme, measure } = input, regular = { family: theme.type.family, ...theme.type.label }, bold = { ...regular, weight: emphasisWeight(theme) }, fontOf = (id) => input.bold.has(id) ? bold : regular, lineH = regular.size * (regular.lineHeight ?? 1.2), rowH = Math.max(SWATCH + (input.compact ? 2 : 4), lineH + (input.compact ? 0.4 : 3)), columnGap = input.compact ? 8 : TABLE_COLUMN_GAP, rows = input.ids.map((id) => {
457
+ let state = input.states?.get(id), value = input.values.get(id) ?? null;
458
+ return {
459
+ id,
460
+ code: shortestRegionName(input.pack.regions.find((region) => region.id === id), fontOf(id), measure),
461
+ text: state ? geoStateLabel(state, input.options) : input.values.has(id) ? value === null ? chartString(input.options, "valueMissing") : input.fmt(value) : chartString(input.options, "notInData"),
462
+ value,
463
+ state,
464
+ listed: input.values.has(id)
465
+ };
466
+ }).sort((a, b) => (a.value === null || a.state ? 1 : 0) - (b.value === null || b.state ? 1 : 0) || (a.value !== null && b.value !== null && !a.state && !b.state ? b.value - a.value : 0) || compareText(a.code, b.code)), groupN = rows.slice(0, input.bold.size).every((row) => input.bold.has(row.id)) && input.bold.size < rows.length ? input.bold.size : 0, codeW = Math.max(0, maxOf(rows.map((row) => measure(row.code, fontOf(row.id)).width))), valueW = Math.max(input.unit ? measure(input.unit, bold).width : 0, maxOf(rows.map((row) => measure(row.text, fontOf(row.id)).width))), columnW = SWATCH + SWATCH_GAP + codeW + (input.compact ? 6 : 12) + valueW, caption = { family: theme.type.family, ...theme.type.footnote }, headerH = input.unit ? caption.size * (caption.lineHeight ?? 1.2) + 4 : 0, columnsOf = (perColumn) => Math.ceil(rows.length / Math.max(1, perColumn)), countsOf = (columns) => Array.from({ length: columns }, (_, i) => Math.floor(rows.length / columns) + (i < rows.length % columns ? 1 : 0)), columnWidth = (columns, width, full = !1) => width === void 0 ? columnW : Math.min(full ? 1 / 0 : columnW * COLUMN_STRETCH, Math.max(columnW, (width - (columns - 1) * columnGap) / columns)), groupGap = (columns) => groupN > 0 && groupN < countsOf(columns)[0] ? GROUP_GAP : 0, size = (perColumn, width, full = !1) => {
467
+ let columns = columnsOf(perColumn), w = columnWidth(columns, width, full);
468
+ return { w: columns * w + (columns - 1) * columnGap, h: headerH + countsOf(columns)[0] * rowH + groupGap(columns), columns };
469
+ }, rowsIn = (height) => Math.floor((height - headerH - (groupN ? GROUP_GAP : 0)) / rowH), columnsIn = (width) => Math.max(0, Math.floor((width + columnGap) / (columnW + columnGap))), rowsAcross = (width, keepGroup = !0) => {
470
+ let columns = Math.max(1, Math.min(columnsIn(width), groupN && keepGroup ? Math.floor(rows.length / (groupN + 1)) : 1 / 0));
471
+ return Math.ceil(rows.length / columns);
472
+ }, draw = (x, y, perColumn, occupied, solveCtx, width, full = !1) => {
473
+ let nodes = [], requests = [], { columns } = size(perColumn, width, full), colW = columnWidth(columns, width, full), text = (id, label, f, left, top, kind, categoryId) => {
474
+ let measured = measure(label, f);
475
+ requests.push({
476
+ id,
477
+ kind,
478
+ typeRole: categoryId ? "label" : "axis",
479
+ owner: categoryId ? { categoryId } : {},
480
+ text: label,
481
+ lines: [label],
482
+ font: f,
483
+ priority: PRIORITY.endpoint,
484
+ role: categoryId ? composedTextRole(label) : "caption",
485
+ candidates: [{ slot: "valueTable", rect: { x: left, y: top + (rowH - measured.height) / 2, w: measured.width, h: measured.height }, penalty: 0 }]
486
+ });
487
+ };
488
+ if (input.unit) {
489
+ let measured = measure(input.unit, caption);
490
+ requests.push({
491
+ id: "value-table-unit:0",
492
+ kind: "annotation",
493
+ typeRole: "footnote",
494
+ owner: {},
495
+ text: input.unit,
496
+ lines: [input.unit],
497
+ font: caption,
498
+ priority: PRIORITY.endpoint,
499
+ role: "caption",
500
+ candidates: [{ slot: "valueTable", rect: { x, y, w: measured.width, h: measured.height }, penalty: 0 }]
501
+ });
502
+ }
503
+ let counts = countsOf(columns), gap = groupGap(columns);
504
+ if (gap) {
505
+ let ruleY = y + headerH + groupN * rowH + gap / 2;
506
+ nodes.push({
507
+ t: "line",
508
+ id: "value-table-group-rule",
509
+ x1: x,
510
+ x2: x + colW,
511
+ y1: ruleY,
512
+ y2: ruleY,
513
+ stroke: { token: "rule" },
514
+ width: strokeToken(theme, "rule"),
515
+ owner: {},
516
+ part: "rowRule"
517
+ });
518
+ }
519
+ rows.forEach((row, index) => {
520
+ let column = 0, rowIndex = index;
521
+ for (; rowIndex >= counts[column]; ) rowIndex -= counts[column++];
522
+ let left = x + column * (colW + columnGap), top = y + headerH + rowIndex * rowH + (gap && rowIndex >= groupN ? gap : 0), rect = { x: left, y: top + (rowH - SWATCH) / 2, w: SWATCH, h: SWATCH };
523
+ nodes.push({
524
+ t: "rect",
525
+ id: `value-table-swatch:${row.id}`,
526
+ rect,
527
+ fill: row.state ? { token: "inkMuted" } : row.listed ? row.value === null ? input.scale.legend.find((item) => item.id === "no-data")?.paint ?? { token: "neutral" } : input.scale.paint(row.value) : { token: "background" },
528
+ ...row.state ? { pattern: geoStatePattern(row.state) } : row.listed && row.value === null ? { pattern: "hatch45" } : {},
529
+ stroke: { token: "leader" },
530
+ strokeWidth: strokeToken(theme, "hair"),
531
+ owner: { categoryId: row.id },
532
+ part: "smallMemberSwatch"
533
+ }), occupied.claim(rect, "legend", { categoryId: row.id }, "smallMemberSwatch");
534
+ let f = fontOf(row.id);
535
+ text(`value-table-code:${row.id}`, row.code, f, left + SWATCH + SWATCH_GAP, top, "category", row.id), text(`value-table-value:${row.id}`, row.text, f, left + colW - measure(row.text, f).width, top, "point", row.id);
536
+ });
537
+ let solved = solveLabels(requests, occupied, solveCtx), fontById = new Map(requests.map((request) => [request.id, request.font]));
538
+ pushAll(nodes, labelsToNodes(theme, solved.placed, (label) => fontById.get(label.id) ?? regular));
539
+ let block = { x, y, ...size(perColumn, width, full) };
540
+ return occupied.claim({ x: block.x, y: block.y, w: block.w, h: block.h }, "reserved", {}, "smallMembers"), { nodes, placed: solved.placed, decisions: solved.decisions, warnings: solved.warnings, rect: { x: block.x, y: block.y, w: block.w, h: block.h } };
541
+ };
542
+ return { rowCount: rows.length, rowH, headerH, columnW, size, rowsIn, rowsAcross, columnsIn, draw };
543
+ }
544
+
545
+ // src/core/charts/choropleth/outsideLabels.ts
546
+ function outsideLabelGuard(regions) {
547
+ let shapes = regions.map((region) => {
548
+ let pointCount = 0, minX = 1 / 0, minY = 1 / 0, maxX = -1 / 0, maxY = -1 / 0, polygons = region.polygons.map((polygon) => polygon.map((ring) => ring.map(([x2, y2]) => (pointCount++, minX = Math.min(minX, x2), minY = Math.min(minY, y2), maxX = Math.max(maxX, x2), maxY = Math.max(maxY, y2), { x: x2, y: y2 })))), rings = polygons.flat(), outlineDistance = prepareOutlineDistance(rings), marker = region.marker ?? { x: region.anchor.x, y: region.anchor.y, radius: 2.5 }, x = pointCount ? minX : marker.x - marker.radius, y = pointCount ? minY : marker.y - marker.radius, bounds = {
549
+ x,
550
+ y,
551
+ w: pointCount ? maxX - x : 2 * marker.radius,
552
+ h: pointCount ? maxY - y : 2 * marker.radius
553
+ };
554
+ return { id: region.id, polygons, rings, outlineDistance, marker, bounds, maxY, queries: /* @__PURE__ */ new Map() };
555
+ }), shapesById = /* @__PURE__ */ new Map();
556
+ for (let shape of shapes) shapesById.has(shape.id) || shapesById.set(shape.id, shape);
557
+ let contains = (shape, point) => point.y < shape.bounds.y || point.y >= shape.maxY ? !1 : shape.polygons.some((polygon) => polygon.reduce((inside, ring) => inside !== inRing(point, ring), !1)), distance = (shape, rect, ownDistance) => shape.polygons.length ? contains(shape, { x: rect.x, y: rect.y }) ? 0 : shape.outlineDistance(rect, ownDistance) : Math.max(0, rectLineDistance(rect, [shape.marker]) - shape.marker.radius), crossed = (shape, from, to) => {
558
+ if (!shape.polygons.length) return rectLineDistance({ x: shape.marker.x, y: shape.marker.y, w: 0, h: 0 }, [from, to]) < shape.marker.radius;
559
+ let dx = to.x - from.x, dy = to.y - from.y, cuts = [0, 1];
560
+ for (let ring of shape.rings) for (let i = 1; i < ring.length; i++) {
561
+ let a = ring[i - 1], b = ring[i], ex = b.x - a.x, ey = b.y - a.y, cross = dx * ey - dy * ex;
562
+ if (cross === 0) continue;
563
+ let t = ((a.x - from.x) * ey - (a.y - from.y) * ex) / cross, u = ((a.x - from.x) * dy - (a.y - from.y) * dx) / cross;
564
+ t > 0 && t < 1 && u >= 0 && u <= 1 && cuts.push(t);
565
+ }
566
+ return cuts.sort((a, b) => a - b), cuts.slice(1).some((end, i) => {
567
+ let t = (cuts[i] + end) / 2;
568
+ return end - cuts[i] > 1e-8 && contains(shape, { x: from.x + t * dx, y: from.y + t * dy });
569
+ });
570
+ }, numberKey = (value) => Object.is(value, -0) ? "-0" : String(value);
571
+ return (id, rect, from, to) => {
572
+ let own = shapesById.get(id), key = `${numberKey(rect.x)},${numberKey(rect.y)},${numberKey(rect.w)},${numberKey(rect.h)};` + (from && to ? `${numberKey(from[0])},${numberKey(from[1])},${numberKey(to[0])},${numberKey(to[1])}` : ""), cached = own.queries.get(key);
573
+ if (cached !== void 0) return cached;
574
+ let ownDistance = distance(own, rect), routeBox = from && to ? {
575
+ x: Math.min(from[0], to[0]),
576
+ y: Math.min(from[1], to[1]),
577
+ w: Math.abs(to[0] - from[0]),
578
+ h: Math.abs(to[1] - from[1])
579
+ } : void 0, fits = shapes.every((shape) => {
580
+ if (shape.id === id) return !0;
581
+ if (boxGap(shape.bounds, rect) <= ownDistance + 0.02) {
582
+ let otherDistance = distance(shape, rect, ownDistance);
583
+ if (otherDistance <= 0.02 || ownDistance >= otherDistance - 0.02) return !1;
584
+ }
585
+ return !routeBox || boxGap(shape.bounds, routeBox) > 0 || !crossed(shape, { x: from[0], y: from[1] }, { x: to[0], y: to[1] });
586
+ });
587
+ return own.queries.set(key, fits), fits;
588
+ };
589
+ }
590
+ function inRing(point, ring) {
591
+ let inside = !1;
592
+ for (let i = 0, j = ring.length - 1; i < ring.length; j = i++) {
593
+ let a = ring[i], b = ring[j];
594
+ a.y > point.y != b.y > point.y && point.x < a.x + (point.y - a.y) * (b.x - a.x) / (b.y - a.y) && (inside = !inside);
595
+ }
596
+ return inside;
597
+ }
598
+
599
+ // src/core/charts/choropleth/layout.ts
600
+ var MAP_PAD = 8, US_MAP_PAD_Y = 6, LEADER_GUTTER = 92, LEADER_GUTTER_SHARE = 0.22, CLEARANCE_TEXT_SPAN = 6, LEADER_LANE_GAP = 5, CLAIM_STEP = 4, HATCH_STEP = 7, WORLD_AUTO_LABEL_COUNT = 12, CALLOUT_MAX_LEADER = 60, CALLOUT_DIRECTIONS = 16, CALLOUT_STEP = 4, LABEL_MAX_COVER = 0.3, REGION_VALUES_DEFAULT_MAX = 10, LISTED_LEADER_FRACTION = 0.2, LISTED_PASSES = 4, TABLE_MAX_SHARE = 0.45, TABLE_GAP = 16, MAP_MAX_HEIGHT = 0.7, MAP_MAX_HEIGHT_PX = 560, STACKED_MAP_MAX_HEIGHT = 1, SIDE_MAP_MAX_PX = 640, SIDE_KEY_MIN_W = 160, SIDE_MIN_SHARE = 0.4, SIDE_MIN_MAP_W = 360, SIDE_ROWS = 8, KEY_TABLE_GAP = 24, MIN_MAP_AREA_H = 120, WORLD_LARGE_REGION_CLEARANCE = 14.5;
601
+ function layoutChoropleth(data, options = {}, listed, pass = 0, passes = /* @__PURE__ */ new Map(), omittedOverlays = /* @__PURE__ */ new Set()) {
602
+ let warnings = geoOptionRefusals(options, "choropleth"), pack = getGeoPack(data.pack), idIndex = geoRegionIdIndex(pack.regions), canonicalIds = idIndex.canonical, { valuesById, statesById } = ingestGeoRegions(data.regions, idIndex, { where: `pack '${pack.id}'`, regionWord: "pack region" }, warnings, (id, index) => {
603
+ let suggestion = nearestRegionId(id, [...canonicalIds.keys()], canonicalIds);
604
+ throw new NormalizeError(
605
+ "choropleth-unknown-region",
606
+ `regions[${index}].id`,
607
+ `region '${id}' is not present in pack '${pack.id}'`,
608
+ suggestion ? `did you mean '${suggestion}'?` : void 0
609
+ );
610
+ }), explicitLabelIds = resolveLabelRegionIds(
611
+ options.labelRegions ?? [],
612
+ idIndex,
613
+ pack
614
+ ), labelPolicy = resolveRegionLabelPolicy(
615
+ pack,
616
+ valuesById,
617
+ explicitLabelIds,
618
+ options.labels,
619
+ options.topN?.n
620
+ ), showListedEmptyMarkers = options.microStateMarkers ?? pack.id !== "world";
621
+ options.microStateMarkers !== void 0 && !pack.regions.some((region) => region.polygons.length === 0) && warnings.push({
622
+ code: "choropleth-micro-state-markers-unused",
623
+ severity: "error",
624
+ message: `microStateMarkers draws dots for micro-states without an outline, and pack '${pack.id}' has none, so it would change nothing`,
625
+ suggest: "drop microStateMarkers; it applies to the world pack",
626
+ field: ["options", "microStateMarkers"],
627
+ fix: [{ op: "remove", path: "/options/microStateMarkers" }]
628
+ });
629
+ let visibleMarkerIds = new Set(
630
+ pack.regions.filter(
631
+ (region) => region.polygons.length === 0 && (labelPolicy.eligibleIds.has(region.id) || valuesById.has(region.id) && ((valuesById.get(region.id) ?? null) !== null || showListedEmptyMarkers))
632
+ ).map((region) => region.id)
633
+ ), theme = resolveSemanticPaletteTheme(
634
+ chartTheme(options),
635
+ options.palette,
636
+ warnings
637
+ ), size = resolveSize(options.size), pinnedHeight = options[TARGET_SIZE]?.fixed.height ?? (typeof options.size == "string" || typeof options.size == "object" && options.size.height !== void 0), compactCard = size.width <= 400 && (options[TARGET_SIZE]?.fixed.height ?? (typeof options.size == "object" && options.size.height !== void 0)), compactPadding = compactCard && !data.overlays?.length ? 2 : void 0, tableGap = compactPadding !== void 0 ? 2 : compactCard ? 8 : TABLE_GAP, minMapHeight = compactPadding !== void 0 ? 68 : compactCard ? 80 : MIN_MAP_AREA_H, margin = canvasMargin(theme, size.width);
638
+ if (size.width < 480) {
639
+ for (let side of ["top", "right", "bottom", "left"]) margin[side] = Math.min(compactCard ? 8 : 12, margin[side]);
640
+ compactCard && (margin.top = margin.bottom = Math.min(5, margin.top, margin.bottom));
641
+ }
642
+ let measure = options.measure ?? defaultMeasurer, fmt = options.format ? formatterFromExample(options.format, options.locale?.language) : (value) => formatAutomaticNumber(value, { locale: options.locale?.language, decimals: autoDecimals(value) }), numericValues = [...valuesById.values()].filter((value) => value !== null);
643
+ numericValues.length === 0 && warnings.push({
644
+ code: "choropleth-no-values",
645
+ severity: "info",
646
+ message: `pack '${pack.id}' has no numeric observations; all ${pack.regions.length} regions render as no data`
647
+ });
648
+ let hasNoDataRegion = pack.regions.some(
649
+ (region) => valuesById.has(region.id) && valuesById.get(region.id) === null && !statesById.has(region.id)
650
+ ), scale = buildGeoScale(numericValues, options, fmt, hasNoDataRegion, theme, { token: "background" });
651
+ scale.edgeFmt = options.format !== void 0 ? scale.edgeFmt : (value) => {
652
+ let magnitude = Math.abs(value) >= 1e9 ? 1e9 : Math.abs(value) >= 1e6 ? 1e6 : Math.abs(value) >= 1e3 ? 1e3 : 1, scaled = value / magnitude, decimals = 0;
653
+ for (; decimals < 6 && !(Math.abs(Math.round(scaled * 10 ** decimals) - scaled * 10 ** decimals) < 1e-6); ) decimals++;
654
+ return formatAutomaticNumber(value, { locale: options.locale?.language, magnitude: "auto", decimals });
655
+ };
656
+ let visibleStates = pack.regions.filter((region) => region.polygons.length > 0 || visibleMarkerIds.has(region.id)).flatMap((region) => statesById.has(region.id) ? [statesById.get(region.id)] : []);
657
+ pushAll(scale.legend, geoStateLegend(visibleStates, options)), pack.regions.some((region) => !valuesById.has(region.id)) && scale.legend.push({
658
+ id: "not-in-data",
659
+ label: chartString(options, "notInData"),
660
+ paint: { token: "inkMuted" },
661
+ pattern: "outline",
662
+ hollow: !0
663
+ }), warnings.push(...geoScaleHints(numericValues, options, fmt));
664
+ let overlays = (data.overlays ?? []).filter((overlay) => !omittedOverlays.has(overlay.id)), overlayLegend = geoOverlayLegend(overlays, options.overlayTones, options.overlayMeasure, data.overlays ?? [], options);
665
+ pushAll(warnings, overlayLegend.warnings);
666
+ let legendOptions = legendRequired(options.legend, warnings, "choropleth", theme), occupied = createOccupiedIndex({ x: 0, y: 0, w: size.width, h: size.height }), userSource = options.source ? chartString(options, "userSourceClause", { v1: options.source }) : "", methodNote = options.methodNote === !0, policyFootnote = methodNote && labelPolicy.mode === "auto" && labelPolicy.eligibleIds.size < pack.regions.length ? chartString(options, "mapLabelPolicy", { v1: labelPolicy.topN }) : void 0, frameResult = solveFrame(
667
+ {
668
+ size,
669
+ margin: { ...margin, ...options.margin },
670
+ ...frameTextOptions(options),
671
+ // Footer rule: the author's source line, and the pack's licence credit
672
+ // apart, which the frame keeps visible where the licence requires it.
673
+ source: options.source,
674
+ ...pack.meta.credit ? { credit: pack.meta.credit } : { source: `${pack.meta.attribution}${userSource}` },
675
+ footnotes: [
676
+ // The pack credit may already hold the disclaimer; the method note
677
+ // does not print it a second time.
678
+ ...methodNote && pack.meta.chartNote && !(pack.meta.credit?.text ?? pack.meta.attribution).includes(pack.meta.chartNote) ? [pack.meta.chartNote] : [],
679
+ ...pack.meta.insetScaleNote ? [pack.meta.insetScaleNote] : [],
680
+ ...policyFootnote ? [policyFootnote] : [],
681
+ ...authoredNotes(options)
682
+ ],
683
+ // The colour key is drawn by layoutMapKeys beside the small members; the frame keeps the overlay key.
684
+ legend: { options: legendOptions, items: overlayLegend.items },
685
+ theme,
686
+ measure
687
+ },
688
+ occupied
689
+ ), solveCtx = labelCtx(theme, size, options, {
690
+ measure,
691
+ plot: frameResult.plot,
692
+ labelPad: 0
693
+ }), tableMode = options.valueTable ?? "auto", tableIds = pack.regions.filter((region) => valuesById.has(region.id) && (region.polygons.length > 0 || visibleMarkerIds.has(region.id))).map((region) => region.id), ranks = valueRanks(valuesById), topIds = new Set([...ranks].filter(([, rank]) => tableIds.length >= 4 && rank < Math.min(5, Math.ceil(tableIds.length / 4))).map(([id]) => id)), table = tableMode !== !1 && tableIds.length > 0 && (tableMode !== "auto" || tableIds.length <= VALUE_TABLE_MAX_ROWS && numericValues.length > 0) ? valueTable({
694
+ options,
695
+ ids: tableIds,
696
+ pack,
697
+ values: valuesById,
698
+ states: statesById,
699
+ scale,
700
+ fmt,
701
+ theme,
702
+ measure,
703
+ unit: compactCard && unitPrinted({ subtitle: resolveSubtitle(options.subtitle), unit: options.unit, unitShown: options.unitShown }) ? void 0 : options.unit,
704
+ compact: compactCard,
705
+ bold: topIds
706
+ }) : void 0, baseSmallIds = table ? /* @__PURE__ */ new Set() : smallRegionIds(pack, labelPolicy.eligibleIds, explicitLabelIds, options), smallIds = /* @__PURE__ */ new Set([...baseSmallIds, ...table ? [] : listed ?? []]), keyTitle = options.keyTitle, named = options.legend !== void 0 && options.legend !== "auto" || theme.legend?.required !== void 0, plot0 = frameResult.plot, yPad = pack.id === "us-states" ? US_MAP_PAD_Y : MAP_PAD, packAspect = (pack.bounds[3] - pack.bounds[1]) / (pack.bounds[2] - pack.bounds[0]), sideCapH = Math.min(MAP_MAX_HEIGHT * size.width, SIDE_MAP_MAX_PX), sideNaturalW = table ? Math.max(SIDE_KEY_MIN_W, table.size(Math.ceil(table.rowCount / Math.ceil(table.rowCount / SIDE_ROWS))).w) : 0, sideMapW = Math.min(plot0.w - tableGap - sideNaturalW, sideCapH / packAspect + 2 * MAP_PAD), sideBlockW = plot0.w - sideMapW - tableGap, sideMaxColumns = table ? table.columnsIn(sideBlockW) : 0, sideColumns = table ? Math.min(sideMaxColumns, Math.ceil(table.rowCount / SIDE_ROWS)) : 0, sideWanted = table !== void 0 && !named && tableMode !== "below" && sideColumns >= 1 && (tableMode === "side" || sideMapW >= SIDE_MIN_MAP_W), keyInput = {
707
+ options,
708
+ target: options.target,
709
+ textScale: textScaleOf(options),
710
+ compact: compactCard,
711
+ position: named ? legendOptions.position : "auto",
712
+ title: keyTitle,
713
+ scale,
714
+ classes: options.classes,
715
+ // A classed key labels its class joins on boundary ticks.
716
+ classRanges: !1,
717
+ midpointLabel: options.scale?.kind === "diverging" ? options.scale.midpointLabel : void 0,
718
+ // Which end is better; the band ranges say which class an edge joins.
719
+ caption: geoPolarityCaption(scale, options) ? `${geoPolarityCaption(scale, options)}.` : void 0,
720
+ // A small region the data never names has nothing to list: the map does not label it either.
721
+ smallIds: new Set([...smallIds].filter((id) => valuesById.has(id))),
722
+ pack,
723
+ values: valuesById,
724
+ states: statesById,
725
+ theme,
726
+ measure,
727
+ fmt,
728
+ occupied,
729
+ solveCtx,
730
+ // One list title at every width, for small regions and dropped labels alike.
731
+ smallTitle: chartString(options, "hiddenMapLabels")
732
+ }, sideKeyH = 0;
733
+ if (sideWanted) try {
734
+ sideKeyH = mapKeysSize({ ...keyInput, plot: { x: plot0.x + sideMapW + tableGap, y: plot0.y, w: sideBlockW, h: plot0.h }, keyWidth: sideBlockW }).h;
735
+ } catch (error) {
736
+ if (!(error instanceof NormalizeError) || error.code !== "geo-key-overflow") throw error;
737
+ sideWanted = !1;
738
+ }
739
+ let sideBlockFor = (columns) => sideKeyH + KEY_TABLE_GAP + table.size(Math.ceil(table.rowCount / columns), sideBlockW, !0).h;
740
+ if (sideWanted && pinnedHeight) for (; sideBlockFor(sideColumns) > plot0.h; ) {
741
+ if (sideColumns < sideMaxColumns) {
742
+ sideColumns++;
743
+ continue;
744
+ }
745
+ let wider = table.size(Math.ceil(table.rowCount / (sideColumns + 1))).w;
746
+ if (sideColumns + 1 > table.rowCount || plot0.w - tableGap - wider < SIDE_MIN_SHARE * plot0.w) break;
747
+ sideBlockW = wider, sideMapW = plot0.w - tableGap - wider, sideMaxColumns = table.columnsIn(sideBlockW), sideColumns++;
748
+ }
749
+ let sideForm = sideWanted && (tableMode === "side" || !pinnedHeight || sideBlockFor(sideColumns) <= plot0.h), sidePerColumn = sideForm ? Math.ceil(table.rowCount / sideColumns) : 0, sideMapH = Math.min(sideCapH, (sideMapW - 2 * MAP_PAD) * packAspect) + 2 * yPad, sideBlockH = sideForm ? sideBlockFor(sideColumns) : 0, sideBlockY = plot0.y + Math.max(0, (Math.min(plot0.h, sideMapH) - sideBlockH) / 2), small = layoutMapKeys({
750
+ ...keyInput,
751
+ plot: sideForm ? { x: plot0.x + sideMapW + tableGap, y: sideBlockY, w: sideBlockW, h: sideBlockH } : plot0,
752
+ // Over a stacked table the key spans the row; beside the map it spans the block.
753
+ ...sideForm ? { keyWidth: sideBlockW } : table && !named ? { keyWidth: plot0.w } : {}
754
+ }), area = sideForm ? plot0 : small.mapPlot, besideWanted = table !== void 0 && !sideForm && tableMode !== "below" && // A named legend, or a pinned canvas too short for the side block, keeps the older side table.
755
+ (tableMode === "side" || (named || sideWanted) && size.width >= 480 && table.size(table.rowCount).w + tableGap <= TABLE_MAX_SHARE * area.w), naturalMapH = (width, share = MAP_MAX_HEIGHT) => Math.min((width - 2 * MAP_PAD) * packAspect, share * size.width, MAP_MAX_HEIGHT_PX) + 2 * yPad, stackedShare = table && !named ? STACKED_MAP_MAX_HEIGHT : MAP_MAX_HEIGHT, naturalAreaH = table ? sideForm ? Math.max(sideMapH, sideBlockH) : besideWanted ? Math.max(naturalMapH(area.w - table.size(table.rowCount).w - tableGap), table.size(table.rowCount).h) : naturalMapH(area.w, stackedShare) + tableGap + table.size(table.rowsAcross(area.w), area.w).h : naturalMapH(area.w), mapArea = { ...area, h: Math.min(area.h, naturalAreaH) }, tablePlace;
756
+ if (sideForm && (mapArea = { ...plot0, w: sideMapW, h: Math.min(plot0.h, sideMapH) }, tablePlace = { x: small.blocks.x, y: small.blocks.y + small.blocks.h + KEY_TABLE_GAP, perColumn: sidePerColumn, width: sideBlockW, full: !0 }), table && besideWanted) {
757
+ let perColumn = Math.max(1, Math.min(table.rowCount, table.rowsIn(area.h))), block = table.size(perColumn);
758
+ if (tableMode === "side" || perColumn === table.rowCount && block.w + tableGap <= TABLE_MAX_SHARE * area.w) {
759
+ let mapW = Math.min(area.w - block.w - tableGap, (mapArea.h - 2 * yPad) / packAspect + 2 * MAP_PAD), offset = Math.max(0, (area.w - mapW - tableGap - block.w) / 2);
760
+ mapArea = { ...mapArea, x: area.x + offset, w: Math.max(10, mapW), h: Math.min(mapArea.h, naturalMapH(area.w - block.w - tableGap)) }, tablePlace = { x: mapArea.x + mapArea.w + tableGap, y: area.y, perColumn };
761
+ }
762
+ }
763
+ if (table && !tablePlace && tableMode !== "side") {
764
+ let perColumn = table.rowsAcross(area.w);
765
+ pinnedHeight && area.h - table.size(perColumn, area.w).h - tableGap < minMapHeight && (perColumn = table.rowsAcross(area.w, !1));
766
+ let block = table.size(perColumn, area.w);
767
+ (tableMode === "below" || !pinnedHeight || area.h - block.h - tableGap >= minMapHeight) && (naturalAreaH = naturalMapH(area.w, stackedShare) + tableGap + block.h, mapArea = { ...area, h: Math.max(10, Math.min(area.h - block.h - tableGap, naturalMapH(area.w, stackedShare))) }, tablePlace = { x: area.x + Math.max(0, (area.w - block.w) / 2), y: area.y + mapArea.h + tableGap, perColumn, width: area.w });
768
+ }
769
+ if (table && !tablePlace && tableMode === "auto") {
770
+ let fallback = layoutChoropleth(data, { ...options, valueTable: !1 }, listed, pass, /* @__PURE__ */ new Map(), omittedOverlays), valueLost = (geometry2) => geometry2.labels.some((label) => label.kind === "category" && label.hidden && label.hidden !== "redundant" && valuesById.get(label.owner.categoryId) != null && !geometry2.labels.some((cell) => cell.id === `small-member-value:${label.owner.categoryId}` && !cell.hidden));
771
+ return !fallback.refused && (fallback.sizing?.minHeight ?? 0) <= size.height && (fallback.sizing?.minWidth ?? 0) <= size.width && !valueLost(fallback) ? fallback : layoutChoropleth(data, { ...options, valueTable: "below" }, listed, pass, /* @__PURE__ */ new Map(), omittedOverlays);
772
+ }
773
+ table && !tablePlace && (mapArea = { ...area, h: Math.min(area.h, naturalMapH(area.w)) });
774
+ let tableDrawn = table && tablePlace ? table.draw(tablePlace.x, tablePlace.y, tablePlace.perColumn, occupied, solveCtx, tablePlace.width, tablePlace.full) : void 0, mapCtx = { ...solveCtx, plot: { ...solveCtx.plot, h: mapArea.y + mapArea.h - solveCtx.plot.y } }, naturalHeight = Math.ceil(size.height - area.h + naturalAreaH - 1e-6), mapLabels = {
775
+ ...labelPolicy,
776
+ eligibleIds: new Set([...labelPolicy.eligibleIds].filter((id) => !smallIds.has(id))),
777
+ leaderIds: new Set([...labelPolicy.leaderIds].filter((id) => !smallIds.has(id)))
778
+ };
779
+ smallIds.size && mapLabels.eligibleIds.size === 0 && (minMapHeight = Math.min(minMapHeight, 2 * (compactPadding ?? MAP_PAD) + 2 * theme.type.label.size)), tableDrawn && mapArea.h < MIN_MAP_AREA_H + theme.type.label.size * 6 && (mapLabels.eligibleIds.clear(), mapLabels.leaderIds.clear(), minMapHeight = Math.min(minMapHeight, 2 * (compactPadding ?? MAP_PAD) + 2 * theme.type.label.size));
780
+ let autoLabelled = [...labelPolicy.eligibleIds].filter((id) => !baseSmallIds.has(id)).length, regionValues = options.regionValues ?? (!tableDrawn && autoLabelled > 0 && autoLabelled <= REGION_VALUES_DEFAULT_MAX), withTable = tableDrawn ? { emphasis: topIds } : void 0, valueTexts = new Map(regionValues ? [...valuesById].flatMap(([id, value]) => value === null ? [] : [[id, fmt(value)]]) : []), plot = frameResult.plot, laneSpan = !tableDrawn && small.position !== "right" && small.blocks.x + small.blocks.w <= plot.x + plot.w - LEADER_GUTTER ? { y: plot.y, h: mapArea.y + mapArea.h - plot.y } : { y: mapArea.y, h: mapArea.h }, keyArea = { x: small.blocks.x - MAP_GAP, y: small.blocks.y - MAP_GAP, w: small.blocks.w + 2 * MAP_GAP, h: small.blocks.h + 2 * MAP_GAP }, underKey = (candidate) => candidate.fitted.regions.some((region) => region.polygons.some((polygon) => polygon.some((ring) => ring.some(([x, y]) => pointInRect(x, y, keyArea)))) || region.marker !== void 0 && pointInRect(region.marker.x, region.marker.y, keyArea)), reserved = mapArea.y - plot.y, prepared;
781
+ if (small.position === "top" && reserved > 0)
782
+ for (let share of [0, 0.25, 0.5, 0.75]) {
783
+ let top = plot.y + share * reserved, rect = { ...mapArea, y: top, h: mapArea.y + mapArea.h - top }, padding = mapLabels.eligibleIds.size ? void 0 : compactPadding;
784
+ if (certainlyUnderKey(pack, rect, padding, keyArea, measure, theme)) continue;
785
+ let candidate = prepareMapLayout(pack, rect, laneSpan, occupied, valuesById, mapLabels, visibleMarkerIds, theme, measure, mapCtx, valueTexts, padding, withTable);
786
+ if (!underKey(candidate)) {
787
+ prepared = candidate;
788
+ break;
789
+ }
790
+ }
791
+ let { labelLayout, mapFrame, fitted, leaderLanes, outsideFits } = prepared ?? prepareMapLayout(pack, mapArea, laneSpan, occupied, valuesById, mapLabels, visibleMarkerIds, theme, measure, mapCtx, valueTexts, mapLabels.eligibleIds.size ? void 0 : compactPadding, withTable), grow = rowDrivenHeight({ options, width: size.width, height: size.height, chromeH: 0, rowsH: naturalHeight });
792
+ if (grow !== void 0) return layoutChoropleth(data, { ...options, size: { width: size.width, height: grow } }, listed, pass, passes, omittedOverlays);
793
+ let glyphDiscs = [], nextOmitted = new Set(omittedOverlays);
794
+ if ((options[TARGET_SIZE]?.fixed.height !== !1 || size.height >= naturalHeight - 2 ? overlays : []).forEach((overlay, index) => {
795
+ let anchor = resolveChoroplethOverlayAnchor(overlay, index, fitted, idIndex, pack), radius = geoOverlayDiameter(overlay) / 2 * (overlay.glyph.kind === "marker" && overlay.glyph.shape === "square" ? Math.SQRT2 : 1);
796
+ glyphDiscs.some((prior) => Math.hypot(anchor.x - prior.x, anchor.y - prior.y) < radius + prior.radius) ? nextOmitted.add(overlay.id) : glyphDiscs.push({ ...anchor, radius });
797
+ }), nextOmitted.size > omittedOverlays.size) return layoutChoropleth(data, options, listed, pass, /* @__PURE__ */ new Map(), nextOmitted);
798
+ let nodes = [...frameResult.nodes], regionStroke = strokeToken(theme, "hair");
799
+ pushAll(warnings, small.warnings);
800
+ let marks = { regions: [], boundaries: [] }, labelPlans = [], chipOnlyNoData = [], undrawnUnlisted = 0;
801
+ for (let region of fitted.regions) {
802
+ let value = valuesById.get(region.id) ?? null, unlisted = !valuesById.has(region.id), state = statesById.get(region.id), noData = !unlisted && value === null && !state, owner = { categoryId: region.id }, pathNodeId = `region:${region.id}`, regionVisible = region.polygons.length > 0 || visibleMarkerIds.has(region.id);
803
+ if (unlisted && !regionVisible) {
804
+ undrawnUnlisted += 1;
805
+ continue;
806
+ }
807
+ let d = regionVisible ? region.polygons.length > 0 ? polygonsPath(region.polygons) : markerPath(
808
+ region.marker?.x ?? region.anchor.x,
809
+ region.marker?.y ?? region.anchor.y,
810
+ region.marker?.radius ?? 2.5,
811
+ regionStroke
812
+ ) : "", fill = state ? { token: "inkMuted" } : noData ? { token: "background" } : scale.paint(value);
813
+ nodes.push({
814
+ t: "path",
815
+ id: pathNodeId,
816
+ d,
817
+ fill,
818
+ stroke: { token: "inkMuted" },
819
+ width: regionStroke,
820
+ owner,
821
+ part: "region",
822
+ ...state ? { pattern: geoStatePattern(state) } : {},
823
+ display: state ? { state: geoStateLabel(state, options) } : unlisted ? { state: chartString(options, "notInData") } : noData ? { state: chartString(options, "valueMissing") } : { value: fmt(value) }
824
+ }), regionVisible && claimRegionMark(region, occupied);
825
+ let hatchNodeId;
826
+ if (noData) {
827
+ let segments = regionVisible ? hatchSegments(region, regionStroke) : [];
828
+ regionVisible && segments.length === 0 ? chipOnlyNoData.push(region.id) : (hatchNodeId = `region-hatch:${region.id}`, nodes.push({
829
+ t: "path",
830
+ id: hatchNodeId,
831
+ d: segmentsPath(segments),
832
+ stroke: { token: "neutral" },
833
+ width: strokeToken(theme, "hair"),
834
+ owner,
835
+ part: "noDataHatch"
836
+ }), claimHatchSegments(segments, occupied, region.id));
837
+ }
838
+ marks.regions.push({
839
+ id: region.id,
840
+ // The pack's name for the region, which the card and the accessible text print.
841
+ name: region.anchor.name,
842
+ pathNodeId,
843
+ ...hatchNodeId ? { hatchNodeId } : {},
844
+ value,
845
+ state: state ?? (unlisted ? "not-in-data" : noData ? "no-data" : "value"),
846
+ fill
847
+ }), mapLabels.eligibleIds.has(region.id) && labelPlans.push(labelPlanForRegion(
848
+ region,
849
+ leaderLanes.get(region.id),
850
+ theme,
851
+ measure,
852
+ fill,
853
+ labelPolicy.inlineMarkerIds.has(region.id),
854
+ valueTexts,
855
+ ranks.get(region.id) ?? ranks.size,
856
+ outsideFits,
857
+ state ? geoStatePattern(state) : void 0,
858
+ withTable?.emphasis.has(region.id) ?? !1,
859
+ withTable !== void 0
860
+ ));
861
+ }
862
+ for (let boundary of fitted.boundaries) {
863
+ let pathNodeId = `boundary:${boundary.id}`, stroke = { token: "leader" };
864
+ nodes.push({
865
+ t: "path",
866
+ id: pathNodeId,
867
+ d: boundaryPath(boundary),
868
+ stroke,
869
+ width: strokeToken(theme, "rule"),
870
+ dash: dashToken(theme, "reference"),
871
+ owner: {},
872
+ part: "disputedBoundary"
873
+ }), claimBoundaryMark(boundary, occupied), marks.boundaries.push({
874
+ id: boundary.id,
875
+ pathNodeId,
876
+ geometryClass: boundary.geometryClass,
877
+ stroke,
878
+ dash: dashToken(theme, "reference")
879
+ });
880
+ }
881
+ claimLeaderAnchors(fitted.regions, labelLayout.leaderIds, occupied), reserveGeoOverlayGlyphs(
882
+ overlays,
883
+ (overlay, index) => resolveChoroplethOverlayAnchor(overlay, index, fitted, idIndex, pack),
884
+ occupied
885
+ );
886
+ let solved = solveRegionLabels(labelPlans, occupied, mapCtx, outsideFits);
887
+ if (tableDrawn) for (let label of solved.placed) {
888
+ let id = label.owner.categoryId;
889
+ label.hidden && ["code", "value"].every((part) => tableDrawn.placed.some(
890
+ (cell) => cell.id === `value-table-${part}:${id}` && !cell.hidden
891
+ )) && (label.hidden = "redundant");
892
+ }
893
+ let movable = (label) => !table && pass < LISTED_PASSES && label.owner.categoryId !== void 0 && !smallIds.has(label.owner.categoryId), lost = solved.placed.filter((label) => movable(label) && label.hidden).map((label) => label.owner.categoryId), far = solved.placed.filter((label) => movable(label) && !label.hidden && label.leader !== void 0 && pathLength(label.leader.d) > Math.max(LISTED_LEADER_FRACTION * mapFrame.w, CALLOUT_MAX_LEADER)).map((label) => label.owner.categoryId);
894
+ pushAll(nodes, small.nodes), pushAll(nodes, tableDrawn?.nodes ?? []);
895
+ for (let node of labelsToNodes(theme, solved.placed, (label) => solved.fontByLabel.get(label.id)))
896
+ node.t === "path" && node.part === "leader" && (nodes.push({ ...node, id: `${node.id}:casing`, stroke: { token: "background" }, width: strokeToken(theme, "rule") + 2 * strokeToken(theme, "hair"), part: "leaderCasing" }), node.stroke = { token: "ink" }), nodes.push(node);
897
+ pushAll(warnings, solved.warnings), pushAll(warnings, tableDrawn?.warnings ?? []);
898
+ let overlayResult = renderGeoOverlays({
899
+ options,
900
+ overlays: data.overlays ?? [],
901
+ omitted: omittedOverlays,
902
+ toneNames: options.overlayTones,
903
+ overlayMeasure: options.overlayMeasure,
904
+ resolveAnchor: (overlay, index) => resolveChoroplethOverlayAnchor(overlay, index, fitted, idIndex, pack),
905
+ occupied,
906
+ solveCtx,
907
+ theme,
908
+ measure,
909
+ ignoredBaseParts: /* @__PURE__ */ new Set(["region", "noDataHatch"])
910
+ });
911
+ pushAll(nodes, overlayResult.nodes), pushAll(warnings, overlayResult.warnings), overlayResult.marks.length && (marks.overlays = overlayResult.marks);
912
+ let noDataCount = marks.regions.filter((mark) => mark.value === null).length + undrawnUnlisted, missingCount = marks.regions.filter((mark) => mark.state === "no-data").length, drawnUnlistedCount = marks.regions.filter((mark) => mark.state === "not-in-data").length, unlistedCount = drawnUnlistedCount + undrawnUnlisted, geometry = {
913
+ type: "choropleth",
914
+ size,
915
+ // Every choropleth draws the colour key, so its measured height is always
916
+ // published; the width only grows for a small-members block.
917
+ sizing: resolveSizing(chartSizing("choropleth"), size, {
918
+ ...smallIds.size ? { minWidth: size.width - frameResult.plot.w + (small.position === "right" ? small.blocks.w + 200 : Math.max(200, small.blocks.w)) } : {},
919
+ minHeight: Math.max(
920
+ size.height - frameResult.plot.h + small.minPlotH,
921
+ size.height - area.h + (table && tablePlace ? sideForm ? Math.max(minMapHeight, sideBlockH) : tablePlace.y === area.y ? Math.max(minMapHeight, table.size(tablePlace.perColumn).h) : minMapHeight + tableGap + table.size(table.rowsAcross(area.w), area.w).h : minMapHeight)
922
+ ),
923
+ naturalHeight
924
+ }),
925
+ plot: sideForm ? mapArea : small.mapPlot,
926
+ scene: nodes,
927
+ labels: [...solved.placed, ...small.placed, ...tableDrawn?.placed ?? [], ...overlayResult.labels],
928
+ axes: [],
929
+ annotations: [],
930
+ legend: frameResult.legend ? { rect: unionRect(small.legend.rect, frameResult.legend.rect), items: [...small.legend.items, ...frameResult.legend.items] } : small.legend,
931
+ frame: frameResult.frame,
932
+ marks,
933
+ derived: {
934
+ domain: { min: scale.min, max: scale.max, midpoint: scale.midpoint, polarity: scale.polarity },
935
+ legendRange: { min: scale.min, max: scale.max },
936
+ ...scale.edges ? { classEdges: scale.edges } : {},
937
+ noDataCount,
938
+ unlistedCount,
939
+ ...overlayResult.descriptions.length ? { overlayDescriptions: overlayResult.descriptions } : {},
940
+ mapFrame,
941
+ pack: {
942
+ id: pack.id,
943
+ hash: pack.meta.hash,
944
+ packRev: pack.meta.packRev,
945
+ worldview: pack.meta.worldview,
946
+ attribution: pack.meta.attribution
947
+ }
948
+ },
949
+ a11y: {
950
+ title: accessibleTitle(options.title, chartString(options, "choroplethTitle", { v1: pack.id })),
951
+ counts: [
952
+ ...geoStateCounts(visibleStates, options),
953
+ structureCount("regions", pack.regions.length, chartString(options, "regionCountPrefix", { v1: pack.regions.length })),
954
+ structureCount("regions", missingCount, chartString(options, "listedRegions", { v1: missingCount })),
955
+ ...drawnUnlistedCount ? [structureCount("regions", drawnUnlistedCount, void 0, options)] : [],
956
+ ...smallIds.size ? [structureCount("regions", smallIds.size, chartString(options, "regionsCount", { v1: smallIds.size }))] : [],
957
+ ...missingCount && chipOnlyNoData.length ? [structureCount("regions", chipOnlyNoData.length, chartString(options, "regionsPlural", { v1: chipOnlyNoData.length, v2: chipOnlyNoData.length === 1 ? "" : "s" }))] : []
958
+ ],
959
+ desc: chartString(options, "mapEqualArea", { v1: pack.regions.length }) + (scale.min === null ? chartString(options, "noNumericValues") : chartString(options, "mappedRange", { v1: fmt(scale.min), v2: fmt(scale.max) })) + // The inverted judgment is an encoding — hue must not carry it alone
960
+ // (variance appends the same phrase for its direction).
961
+ (scale.polarity === "lowerIsBetter" ? chartString(options, "lowerFavorable") : "") + (tableDrawn ? chartString(options, "mapTable", { v1: !sideForm && tablePlace.y > mapArea.y ? chartString(options, "under") : chartString(options, "beside") }) : smallIds.size ? chartString(options, "mapHiddenRegions", { v1: smallIds.size }) : "") + chartString(options, "mapMissingRegions", { v1: missingCount }) + (drawnUnlistedCount ? chartString(options, "mapUnlistedRegions", { v1: drawnUnlistedCount }) : "") + geoStateSummary(visibleStates, options) + (missingCount === 0 ? "" : chipOnlyNoData.length === 0 ? chartString(options, "mapMissingHatch") : chartString(options, "mapSmallMissing", { v1: chipOnlyNoData.length, v2: chipOnlyNoData.length === 1 ? " is" : "s are", v3: chipOnlyNoData.length === 1 ? "ies" : "y" })) + (overlayResult.descriptions.length ? chartString(options, "overlaysSentence", { v1: overlayResult.descriptions.join(" ") }) : "") + chartString(options, "sourceSentence", { v1: pack.meta.attribution, v2: userSource })
962
+ },
963
+ warnings,
964
+ debug: {
965
+ occupied: visibleOccupiedSnapshot(
966
+ occupied.snapshot(),
967
+ [...solved.placed, ...small.placed, ...tableDrawn?.placed ?? [], ...overlayResult.labels]
968
+ ),
969
+ decisions: [...solved.decisions, ...small.decisions, ...tableDrawn?.decisions ?? [], ...overlayResult.decisions]
970
+ }
971
+ }, hidden = (result) => result.labels.filter((label) => label.hidden).length;
972
+ if ((geometry.sizing?.minHeight ?? 0) > size.height + 1) return geometry;
973
+ for (let move of [[...lost, ...far], lost, lost.length ? [...labelPolicy.eligibleIds] : []]) {
974
+ if (!move.length) continue;
975
+ let ids = /* @__PURE__ */ new Set([...listed ?? [], ...move]), key = `${pass + 1}:${[...ids].sort().join(",")}`, next = passes.get(key) ?? layoutChoropleth(data, options, ids, pass + 1, passes, omittedOverlays), height = Math.ceil(Math.max(next.sizing?.minHeight ?? 0, next.sizing?.naturalHeight ?? 0));
976
+ if (options[TARGET_SIZE]?.fixed.height === !1 && height > next.size.height && height <= 1400) {
977
+ let taller = layoutChoropleth(data, { ...options, size: { width: size.width, height } }, ids, pass + 1, /* @__PURE__ */ new Map(), omittedOverlays);
978
+ hidden(taller) < hidden(geometry) && (next = taller);
979
+ }
980
+ if (passes.set(key, next), !next.labels.some((label) => label.hidden && label.slot === "smallMember") && (next.sizing?.minHeight ?? 0) <= next.size.height && hidden(next) <= hidden(geometry)) return next;
981
+ }
982
+ return geometry;
983
+ }
984
+ function prepareMapLayout(pack, plot, laneSpan, occupied, valuesById, labelPolicy, visibleMarkerIds, theme, measure, solveCtx, valueTexts, padding, withTable) {
985
+ let fits = /* @__PURE__ */ new Map(), fitMap = (frame) => {
986
+ let key = `${frame.x},${frame.y},${frame.w},${frame.h}`, prepared = fits.get(key);
987
+ if (!prepared) {
988
+ let fitted2 = fitGeoPack(pack, frame), outsideFits2 = outsideLabelGuard(fitted2.regions.filter((region) => region.polygons.length > 0 || visibleMarkerIds.has(region.id)));
989
+ prepared = { fitted: fitted2, outsideFits: outsideFits2 }, fits.set(key, prepared);
990
+ }
991
+ return prepared;
992
+ }, labelLayout = labelPolicy.eligibleIds.size > 0 ? resolveRegionLabelLayout(
993
+ pack,
994
+ plot,
995
+ { ...plot, ...laneSpan },
996
+ occupied.snapshot(),
997
+ valuesById,
998
+ labelPolicy.eligibleIds,
999
+ labelPolicy.leaderIds,
1000
+ labelPolicy.inlineMarkerIds,
1001
+ visibleMarkerIds,
1002
+ theme,
1003
+ measure,
1004
+ solveCtx,
1005
+ valueTexts,
1006
+ fitMap,
1007
+ withTable
1008
+ ) : { gutter: 0, leaderIds: /* @__PURE__ */ new Set() }, mapFrame = choroplethMapFrame(plot, labelLayout.gutter, pack.id, padding), mapFit = fitMap(mapFrame), { fitted, outsideFits } = mapFit, leaderLanes = buildLeaderLanes(
1009
+ mapFit,
1010
+ labelLayout.leaderIds,
1011
+ { ...plot, ...laneSpan },
1012
+ theme,
1013
+ measure,
1014
+ valueTexts
1015
+ );
1016
+ return { labelLayout, mapFrame, fitted, leaderLanes, outsideFits };
1017
+ }
1018
+ function resolveChoroplethOverlayAnchor(overlay, index, fitted, idIndex, pack) {
1019
+ if ("lon" in overlay.at) {
1020
+ let point;
1021
+ try {
1022
+ point = fitGeoLonLat(fitted, overlay.at.lon, overlay.at.lat);
1023
+ } catch (error) {
1024
+ throw new NormalizeError(
1025
+ "overlay-coordinate-invalid",
1026
+ `overlays[${index}].at`,
1027
+ `overlay '${overlay.id}' cannot be projected through pack '${pack.id}': ${error instanceof Error ? error.message : String(error)}`
1028
+ );
1029
+ }
1030
+ if (!point)
1031
+ throw new NormalizeError(
1032
+ "overlay-coordinate-unowned",
1033
+ `overlays[${index}].at`,
1034
+ `overlay '${overlay.id}' at longitude ${overlay.at.lon}, latitude ${overlay.at.lat} is not owned by any projection branch in pack '${pack.id}'`
1035
+ );
1036
+ return point;
1037
+ }
1038
+ let resolution = resolveGeoRegionId(idIndex, overlay.at.region);
1039
+ if (resolution.kind !== "resolved")
1040
+ throw new NormalizeError(
1041
+ "overlay-unknown-region",
1042
+ `overlays[${index}].at.region`,
1043
+ `overlay region '${overlay.at.region}' is not uniquely present in pack '${pack.id}'`,
1044
+ resolution.kind === "ambiguous" ? `use one of ${resolution.candidates.join(", ")}` : void 0
1045
+ );
1046
+ let region = fitted.regions.find((candidate) => candidate.id === resolution.id);
1047
+ if (!region)
1048
+ throw new NormalizeError(
1049
+ "overlay-unknown-region",
1050
+ `overlays[${index}].at.region`,
1051
+ `overlay region '${overlay.at.region}' is not present in fitted pack '${pack.id}'`
1052
+ );
1053
+ return { x: region.anchor.x, y: region.anchor.y };
1054
+ }
1055
+ function solveRegionLabels(plans, occupied, ctx, outsideFits, reads) {
1056
+ let pinOf = (plan) => ctx.pins[`category:${plan.region.id}`], ordered = [...plans].sort((a, b) => {
1057
+ let aPinned = pinOf(a) ? 1 : 0, bPinned = pinOf(b) ? 1 : 0;
1058
+ return aPinned !== bPinned ? bPinned - aPinned : b.priority - a.priority || compareText(a.region.id, b.region.id);
1059
+ }), result = {
1060
+ placed: [],
1061
+ decisions: [],
1062
+ warnings: [],
1063
+ fontByLabel: /* @__PURE__ */ new Map()
1064
+ }, solveCtx = { ...ctx, pins: {} }, unresolved = [];
1065
+ for (let plan of ordered) {
1066
+ let requestedPin = pinOf(plan);
1067
+ if (requestedPin) {
1068
+ let pinnedVariant = plan.variants.find(
1069
+ (variant) => variant.request.candidates.some((candidate) => candidate.slot === requestedPin)
1070
+ );
1071
+ if (pinnedVariant) {
1072
+ let backed = pinnedVariant.request.candidates.some((candidate) => candidate.needsBacking), pinned = solveLabels(
1073
+ [{ ...pinnedVariant.request, pinnedSlot: requestedPin }],
1074
+ backed ? withoutRegionMarks(occupied) : occupied,
1075
+ backed ? { ...solveCtx, labelPad: 4 } : solveCtx
1076
+ );
1077
+ appendRegionSolve(result, pinned, pinnedVariant.font, plan), claimLabelBacking(pinned.placed[0], occupied), claimSolvedLeader(pinned.placed[0], plan.region, occupied);
1078
+ continue;
1079
+ }
1080
+ result.warnings.push({
1081
+ code: "unknown-slot",
1082
+ severity: "warn",
1083
+ message: `label 'category:${plan.region.id}': unknown slot '${requestedPin}' \u2014 using automatic placement`,
1084
+ owner: { categoryId: plan.region.id },
1085
+ suggest: allPlanSlots(plan).join(", ")
1086
+ });
1087
+ }
1088
+ let tried = [], fallback, placed = !1;
1089
+ for (let variant of plan.variants.filter((candidate) => !candidate.leader && !candidate.callout)) {
1090
+ let backed = variant.request.candidates.some((candidate) => candidate.needsBacking), solveOccupied = backed ? withoutRegionMarks(occupied) : occupied, next = solveLabels(
1091
+ [variant.request],
1092
+ solveOccupied,
1093
+ backed ? { ...solveCtx, labelPad: 4 } : solveCtx
1094
+ );
1095
+ if (fallback = next, tried.push(...next.decisions[0]?.tried ?? []), !next.placed[0]?.hidden) {
1096
+ appendRegionSolve(result, next, variant.font, plan, tried), claimLabelBacking(next.placed[0], occupied), placed = !0;
1097
+ break;
1098
+ }
1099
+ }
1100
+ !placed && fallback && unresolved.push({ plan, tried, fallback });
1101
+ }
1102
+ unresolved.sort(
1103
+ (a, b) => b.plan.priority - a.plan.priority || compareText(a.plan.region.id, b.plan.region.id)
1104
+ );
1105
+ let escalated = unresolved.length;
1106
+ if (reads) for (; escalated > 0 && !reads(unresolved[escalated - 1].plan.region.id); ) escalated--;
1107
+ let solvedLeaders = [];
1108
+ for (let item of unresolved.slice(0, escalated)) {
1109
+ let callout = item.plan.variants.find((variant) => variant.callout);
1110
+ if (callout) {
1111
+ let candidates = callout.callout(occupied, ctx.plot), next2 = solveLabels([{ ...callout.request, candidates }], occupied, solveCtx), placed2 = next2.placed[0];
1112
+ if (placed2 && !placed2.hidden) {
1113
+ item.tried.push(...next2.decisions[0]?.tried ?? []), appendRegionSolve(result, next2, callout.font, item.plan, item.tried);
1114
+ let from = [item.plan.region.anchor.x, item.plan.region.anchor.y], to = calloutTerminus(from, placed2.rect);
1115
+ placed2.leader = { d: polylinePath([from, to]), curved: !1 }, claimLeaderRoute([from, to], occupied, item.plan.region.id);
1116
+ continue;
1117
+ }
1118
+ item.tried.push(...next2.decisions[0]?.tried ?? []);
1119
+ }
1120
+ let leaderVariant = item.plan.variants.find((variant) => variant.leader);
1121
+ if (!leaderVariant) {
1122
+ appendRegionSolve(result, item.fallback, item.plan.variants.at(-1).font, item.plan, item.tried);
1123
+ continue;
1124
+ }
1125
+ let next = solveLabels([leaderVariant.request], occupied, solveCtx), tried = [...item.tried, ...next.decisions[0]?.tried ?? []];
1126
+ appendRegionSolve(result, next, leaderVariant.font, item.plan, tried);
1127
+ let placed = next.placed[0];
1128
+ placed && !placed.hidden && placed.leader && (claimLabelBacking(placed, occupied), solvedLeaders.push({ placed, region: item.plan.region }));
1129
+ }
1130
+ return routeAndClaimLeaders(solvedLeaders, result.placed, ctx.plot, occupied, outsideFits), result;
1131
+ }
1132
+ function withoutRegionMarks(occupied) {
1133
+ let regionMark = (claim) => claim.kind === "mark" && (claim.part === "region" || claim.part === "noDataHatch");
1134
+ return {
1135
+ claim: (rect, kind, owner, part) => occupied.claim(rect, kind, owner, part),
1136
+ hits: (rect, pad = 0) => occupied.hits(rect, pad, regionMark),
1137
+ hitsWhich: (rect, pad = 0) => occupied.hitsWhich(rect, pad, regionMark),
1138
+ snapshot: () => occupied.snapshot()
1139
+ };
1140
+ }
1141
+ function claimLabelBacking(placed, occupied) {
1142
+ placed?.backing && !placed.hidden && occupied.claim(placed.backing, "reserved", placed.owner, "labelBacking");
1143
+ }
1144
+ function appendRegionSolve(result, next, font, plan, tried) {
1145
+ let placed = next.placed[0], decision = next.decisions[0];
1146
+ !placed || !decision || (placed.slots = allPlanSlots(plan), result.placed.push(placed), result.decisions.push(
1147
+ tried === void 0 ? decision : {
1148
+ ...decision,
1149
+ tried,
1150
+ reason: placed.hidden ? "full, compact, and leader escalation exhausted" : `candidate ${tried.length} free in full \u2192 compact \u2192 leader escalation`
1151
+ }
1152
+ ), result.warnings.push(...next.warnings), result.fontByLabel.set(placed.id, font));
1153
+ }
1154
+ function claimSolvedLeader(placed, region, occupied) {
1155
+ !placed || placed.hidden || !placed.leader || (placed.leader = { d: polylinePath([[region.anchor.x, region.anchor.y], leaderTarget([region.anchor.x, region.anchor.y], placed.rect)]), curved: !1 }, claimLeader(
1156
+ [region.anchor.x, region.anchor.y],
1157
+ leaderTarget([region.anchor.x, region.anchor.y], placed.rect),
1158
+ occupied,
1159
+ region.id
1160
+ ));
1161
+ }
1162
+ function routeAndClaimLeaders(leaders, labels, plot, occupied, outsideFits) {
1163
+ let obstacles = labels.filter((label) => !label.hidden);
1164
+ for (let { placed, region } of leaders) {
1165
+ let from = [region.anchor.x, region.anchor.y], route = leastCrossingLeaderRoute(
1166
+ from,
1167
+ leaderTarget(from, placed.rect),
1168
+ obstacles,
1169
+ region.id,
1170
+ plot,
1171
+ placed.rect,
1172
+ outsideFits
1173
+ );
1174
+ placed.leader = { d: polylinePath(route), curved: !1 }, claimLeaderRoute(route, occupied, region.id);
1175
+ }
1176
+ }
1177
+ function leastCrossingLeaderRoute(from, to, labels, regionId, plot, rect, outsideFits) {
1178
+ let gutterX = to[0] - 6, corridorY = /* @__PURE__ */ new Set([
1179
+ plot.y + 1,
1180
+ plot.y + plot.h - 1,
1181
+ from[1],
1182
+ to[1]
1183
+ ]);
1184
+ for (let label of labels) {
1185
+ if (label.owner.categoryId === regionId) continue;
1186
+ let rect2 = label.backing ?? label.rect;
1187
+ corridorY.add(Math.max(plot.y + 1, rect2.y - 3)), corridorY.add(Math.min(plot.y + plot.h - 1, rect2.y + rect2.h + 3));
1188
+ }
1189
+ let candidates = [
1190
+ [from, to],
1191
+ [from, [gutterX, from[1]], [gutterX, to[1]], to]
1192
+ ];
1193
+ for (let y of [...corridorY].sort((a, b) => a - b))
1194
+ candidates.push(
1195
+ [from, [from[0], y], [gutterX, y], [gutterX, to[1]], to],
1196
+ [from, [from[0] - 6, from[1]], [from[0] - 6, y], [gutterX, y], [gutterX, to[1]], to],
1197
+ [from, [from[0] + 6, from[1]], [from[0] + 6, y], [gutterX, y], [gutterX, to[1]], to]
1198
+ );
1199
+ let obstacles = labels.filter((label) => label.owner.categoryId && label.owner.categoryId !== regionId && !label.hidden), ranked = candidates.map((points, index) => ({ raw: points, points: dedupeRoute(points), length: routeLength(points), index })).sort((a, b) => a.length - b.length || a.points.length - b.points.length || a.index - b.index), best = ranked[0], fewest = 1 / 0;
1200
+ for (let candidate of ranked) {
1201
+ if (!candidate.points.slice(1).every((point, index) => outsideFits(regionId, rect, candidate.points[index], point))) continue;
1202
+ let crossings = routeLabelCrossings(candidate.raw, obstacles, regionId, fewest);
1203
+ if (crossings < fewest && (best = candidate, fewest = crossings, fewest === 0))
1204
+ break;
1205
+ }
1206
+ return best.points;
1207
+ }
1208
+ function routeLabelCrossings(points, labels, regionId, stopAt = 1 / 0) {
1209
+ let crossed = /* @__PURE__ */ new Set();
1210
+ for (let index = 1; index < points.length; index++) {
1211
+ let segmentRect = rectForSegment(points[index - 1], points[index]);
1212
+ for (let label of labels) {
1213
+ let id = label.owner.categoryId;
1214
+ if (!(!id || id === regionId || label.hidden) && rectsIntersect(segmentRect, label.backing ?? label.rect) && (crossed.add(id), crossed.size >= stopAt))
1215
+ return crossed.size;
1216
+ }
1217
+ }
1218
+ return crossed.size;
1219
+ }
1220
+ function routeLength(points) {
1221
+ let length = 0;
1222
+ for (let index = 1; index < points.length; index++)
1223
+ length += Math.hypot(
1224
+ points[index][0] - points[index - 1][0],
1225
+ points[index][1] - points[index - 1][1]
1226
+ );
1227
+ return length;
1228
+ }
1229
+ function dedupeRoute(points) {
1230
+ return points.filter(
1231
+ (point, index) => index === 0 || point[0] !== points[index - 1][0] || point[1] !== points[index - 1][1]
1232
+ );
1233
+ }
1234
+ function polylinePath(points) {
1235
+ return points.map((point, index) => `${index === 0 ? "M" : "L"}${coord(point)}`).join("");
1236
+ }
1237
+ function claimLeaderRoute(points, occupied, regionId) {
1238
+ for (let index = 1; index < points.length; index++)
1239
+ claimSegment(
1240
+ { a: points[index - 1], b: points[index] },
1241
+ occupied,
1242
+ regionId,
1243
+ "regionLeader"
1244
+ );
1245
+ }
1246
+ function rectForSegment(a, b) {
1247
+ return {
1248
+ x: Math.min(a[0], b[0]) - 0.6,
1249
+ y: Math.min(a[1], b[1]) - 0.6,
1250
+ w: Math.abs(b[0] - a[0]) + 1.2,
1251
+ h: Math.abs(b[1] - a[1]) + 1.2
1252
+ };
1253
+ }
1254
+ function unionRect(a, b) {
1255
+ let x = Math.min(a.x, b.x), y = Math.min(a.y, b.y);
1256
+ return { x, y, w: Math.max(a.x + a.w, b.x + b.w) - x, h: Math.max(a.y + a.h, b.y + b.h) - y };
1257
+ }
1258
+ function rectsIntersect(a, b) {
1259
+ return !(a.x + a.w <= b.x || b.x + b.w <= a.x || a.y + a.h <= b.y || b.y + b.h <= a.y);
1260
+ }
1261
+ function allPlanSlots(plan) {
1262
+ return plan.variants.flatMap(
1263
+ (variant) => variant.request.candidates.map((candidate) => candidate.slot)
1264
+ );
1265
+ }
1266
+ function resolveLabelRegionIds(requested, idIndex, pack) {
1267
+ let canonicalIds = idIndex.canonical, resolved = /* @__PURE__ */ new Set();
1268
+ return requested.forEach((id, index) => {
1269
+ let resolution = resolveGeoRegionId(idIndex, id);
1270
+ if (resolution.kind === "ambiguous")
1271
+ throw new NormalizeError(
1272
+ "choropleth-ambiguous-region",
1273
+ `labelRegions[${index}]`,
1274
+ `region '${id}' is ambiguous in pack '${pack.id}' \u2014 ${resolution.candidates.join(", ")} all answer to it`,
1275
+ `use one of ${resolution.candidates.join(", ")}`
1276
+ );
1277
+ if (resolution.kind === "unknown") {
1278
+ let suggestion = nearestRegionId(id, [...canonicalIds.keys()], canonicalIds);
1279
+ throw new NormalizeError(
1280
+ "choropleth-unknown-region",
1281
+ `labelRegions[${index}]`,
1282
+ `region '${id}' is not present in pack '${pack.id}'`,
1283
+ suggestion ? `did you mean '${suggestion}'?` : void 0
1284
+ );
1285
+ }
1286
+ resolved.add(resolution.id);
1287
+ }), resolved;
1288
+ }
1289
+ function resolveRegionLabelPolicy(pack, valuesById, explicitIds, option, requestedTopN) {
1290
+ let mode = option === !1 ? "none" : option ?? "auto", topN = pack.id === "world" ? Math.min(pack.regions.length, requestedTopN ?? WORLD_AUTO_LABEL_COUNT) : pack.regions.length;
1291
+ if (mode === "none")
1292
+ return {
1293
+ mode,
1294
+ eligibleIds: /* @__PURE__ */ new Set(),
1295
+ leaderIds: /* @__PURE__ */ new Set(),
1296
+ inlineMarkerIds: /* @__PURE__ */ new Set(),
1297
+ topN
1298
+ };
1299
+ if (mode === "all" || pack.id !== "world") {
1300
+ let eligibleIds2 = new Set(pack.regions.map((region) => region.id));
1301
+ return {
1302
+ mode,
1303
+ eligibleIds: eligibleIds2,
1304
+ leaderIds: new Set(eligibleIds2),
1305
+ inlineMarkerIds: /* @__PURE__ */ new Set(),
1306
+ topN
1307
+ };
1308
+ }
1309
+ let rankedIds = pack.regions.flatMap((region) => {
1310
+ let value = valuesById.get(region.id) ?? null;
1311
+ return value === null ? [] : [{ id: region.id, value }];
1312
+ }).sort(
1313
+ (a, b) => Math.abs(b.value) - Math.abs(a.value) || compareText(a.id, b.id)
1314
+ ).slice(0, topN).map((region) => region.id), largeRegionIds = pack.regions.flatMap((region) => (valuesById.get(region.id) ?? null) !== null && region.polygons.length > 0 && region.anchor.clearance >= WORLD_LARGE_REGION_CLEARANCE ? [region.id] : []), eligibleIds = /* @__PURE__ */ new Set([...explicitIds, ...rankedIds, ...largeRegionIds]), inlineMarkerIds = new Set(
1315
+ pack.regions.filter(
1316
+ (region) => region.polygons.length === 0 && eligibleIds.has(region.id) && !explicitIds.has(region.id)
1317
+ ).map((region) => region.id)
1318
+ );
1319
+ return {
1320
+ mode,
1321
+ eligibleIds,
1322
+ leaderIds: new Set(explicitIds),
1323
+ inlineMarkerIds,
1324
+ topN
1325
+ };
1326
+ }
1327
+ function resolveRegionLabelLayout(pack, plot, lanePlot, frameClaims, valuesById, labelIds, leaderEligibleIds, inlineMarkerIds, visibleMarkerIds, theme, measure, solveCtx, valueTexts, fitMap, withTable) {
1328
+ let gutter = 0, leaderIds = new Set(
1329
+ pack.regions.filter(
1330
+ (region) => region.marker && region.polygons.length === 0 && leaderEligibleIds.has(region.id) && (pack.id !== "world" || region.microState)
1331
+ ).map((region) => region.id)
1332
+ );
1333
+ if (leaderIds.size > 0) {
1334
+ let initialFit = fitGeoPack(pack, choroplethMapFrame(plot, 0, pack.id));
1335
+ gutter = measuredLeaderGutter(initialFit.regions, leaderIds, plot, theme, measure, valueTexts);
1336
+ }
1337
+ let ranks = valueRanks(valuesById);
1338
+ for (let iteration = 0; iteration <= pack.regions.length; iteration++) {
1339
+ let mapFrame = choroplethMapFrame(plot, gutter, pack.id), mapFit = fitMap(mapFrame), { fitted, outsideFits } = mapFit, lanes = buildLeaderLanes(mapFit, leaderIds, lanePlot, theme, measure, valueTexts), probeOccupied = createOccupiedIndex(solveCtx.canvas ?? plot);
1340
+ for (let claim of frameClaims)
1341
+ probeOccupied.claim(claim.rect, claim.kind, claim.owner, claim.part);
1342
+ for (let region of fitted.regions) {
1343
+ let regionVisible = region.polygons.length > 0 || visibleMarkerIds.has(region.id);
1344
+ regionVisible && claimRegionMark(region, probeOccupied), regionVisible && (valuesById.get(region.id) ?? null) === null && claimHatchSegments(hatchSegments(region, strokeToken(theme, "hair")), probeOccupied, region.id);
1345
+ }
1346
+ for (let boundary of fitted.boundaries) claimBoundaryMark(boundary, probeOccupied);
1347
+ claimLeaderAnchors(fitted.regions, leaderIds, probeOccupied);
1348
+ let plans = fitted.regions.filter((region) => labelIds.has(region.id)).map(
1349
+ (region) => labelPlanForRegion(
1350
+ region,
1351
+ lanes.get(region.id),
1352
+ theme,
1353
+ measure,
1354
+ { token: "background" },
1355
+ inlineMarkerIds.has(region.id),
1356
+ valueTexts,
1357
+ ranks.get(region.id) ?? ranks.size,
1358
+ outsideFits,
1359
+ void 0,
1360
+ withTable?.emphasis.has(region.id) ?? !1,
1361
+ withTable !== void 0
1362
+ )
1363
+ ), solved = solveRegionLabels(plans, probeOccupied, solveCtx, outsideFits, (id) => leaderEligibleIds.has(id) && !leaderIds.has(id)), regionsById = new Map(fitted.regions.map((region) => [region.id, region])), hiddenIds = solved.placed.flatMap((label) => {
1364
+ let id = label.owner.categoryId, region = id ? regionsById.get(id) : void 0;
1365
+ return label.hidden === "collision" && id && region && leaderEligibleIds.has(id) && (pack.id !== "world" || region.microState) ? [id] : [];
1366
+ }), candidateLanes = buildLeaderLanes(mapFit, /* @__PURE__ */ new Set([...leaderIds, ...hiddenIds]), lanePlot, theme, measure, valueTexts), safeIds = hiddenIds.filter((id) => {
1367
+ let region = regionsById.get(id), rect = candidateLanes.get(id).rect, from = [region.anchor.x, region.anchor.y];
1368
+ return outsideFits(id, rect, from, leaderTarget(from, rect));
1369
+ }), nextLeaderIds = /* @__PURE__ */ new Set([...leaderIds, ...safeIds]);
1370
+ if (nextLeaderIds.size === leaderIds.size) return { gutter, leaderIds };
1371
+ leaderIds = nextLeaderIds, gutter = measuredLeaderGutter(fitted.regions, leaderIds, plot, theme, measure, valueTexts);
1372
+ }
1373
+ return { gutter, leaderIds };
1374
+ }
1375
+ function claimLeaderAnchors(regions, leaderIds, occupied) {
1376
+ for (let region of regions)
1377
+ leaderIds.has(region.id) && occupied.claim(
1378
+ {
1379
+ x: region.anchor.x - 2,
1380
+ y: region.anchor.y - 2,
1381
+ w: 4,
1382
+ h: 4
1383
+ },
1384
+ "reserved",
1385
+ { categoryId: region.id },
1386
+ "leaderAnchor"
1387
+ );
1388
+ }
1389
+ function visibleOccupiedSnapshot(claims, labels) {
1390
+ let backings = labels.flatMap(
1391
+ (label) => !label.hidden && label.backing ? [{ rect: label.backing, ownerId: label.owner.categoryId }] : []
1392
+ );
1393
+ return claims.flatMap((claim) => {
1394
+ if (claim.kind !== "mark" || claim.part !== "region" && claim.part !== "noDataHatch")
1395
+ return [claim];
1396
+ let visible = [claim.rect];
1397
+ for (let backing of backings)
1398
+ backing.ownerId !== claim.owner.categoryId && (visible = visible.flatMap((rect) => subtractRect(rect, backing.rect)));
1399
+ return visible.map((rect) => ({ ...claim, rect }));
1400
+ });
1401
+ }
1402
+ function subtractRect(rect, cut) {
1403
+ let x1 = Math.max(rect.x, cut.x), y1 = Math.max(rect.y, cut.y), x2 = Math.min(rect.x + rect.w, cut.x + cut.w), y2 = Math.min(rect.y + rect.h, cut.y + cut.h);
1404
+ if (x1 >= x2 || y1 >= y2) return [rect];
1405
+ let pieces = [];
1406
+ return rect.y < y1 && pieces.push({ x: rect.x, y: rect.y, w: rect.w, h: y1 - rect.y }), y2 < rect.y + rect.h && pieces.push({ x: rect.x, y: y2, w: rect.w, h: rect.y + rect.h - y2 }), rect.x < x1 && pieces.push({ x: rect.x, y: y1, w: x1 - rect.x, h: y2 - y1 }), x2 < rect.x + rect.w && pieces.push({ x: x2, y: y1, w: rect.x + rect.w - x2, h: y2 - y1 }), pieces;
1407
+ }
1408
+ function certainlyUnderKey(pack, rect, padding, keyArea, measure, theme) {
1409
+ let font = geoLabelFont(theme);
1410
+ if (measure !== defaultMeasurer || !Number.isFinite(font.size) || !(font.letterSpacing === void 0 || Number.isFinite(font.letterSpacing))) return !1;
1411
+ let [minX, minY, maxX, maxY] = pack.bounds, bw = maxX - minX, bh = maxY - minY, xPad = padding ?? MAP_PAD, yPad = padding ?? (pack.id === "us-states" ? US_MAP_PAD_Y : MAP_PAD);
1412
+ if (![rect.x, rect.y, rect.w, rect.h, xPad, yPad, keyArea.x, keyArea.y, keyArea.w, keyArea.h, bw, bh, minX, minY].every(Number.isFinite) || !(bw > 0) || !(bh > 0) || !(rect.w >= 0)) return !1;
1413
+ let gMax = Math.min(LEADER_GUTTER, rect.w * LEADER_GUTTER_SHARE), fh = Math.max(10, rect.h - yPad * 2), fits = [0, gMax, rect.w - xPad * 2 - 10, rect.w - xPad * 2 - bw * fh / bh].filter((g) => g >= 0 && g <= gMax).map((g) => {
1414
+ let fw = Math.max(10, rect.w - xPad * 2 - g), sx = fw / bw, sy = fh / bh, scale = sx < sy ? sx : sy;
1415
+ return { scale, x: rect.x + xPad + (fw - bw * scale) / 2 - minX * scale, y: rect.y + yPad + (fh - bh * scale) / 2 - minY * scale, fw };
1416
+ }), magnitude = Math.max(
1417
+ Math.abs(keyArea.x),
1418
+ Math.abs(keyArea.y),
1419
+ Math.abs(keyArea.x + keyArea.w),
1420
+ Math.abs(keyArea.y + keyArea.h),
1421
+ Math.abs(rect.x) + xPad,
1422
+ Math.abs(rect.y) + yPad,
1423
+ rect.w,
1424
+ fh
1425
+ );
1426
+ for (let fit of fits)
1427
+ magnitude = Math.max(
1428
+ magnitude,
1429
+ fit.fw,
1430
+ Math.abs(fit.x),
1431
+ Math.abs(fit.y),
1432
+ Math.abs(minX * fit.scale),
1433
+ Math.abs(maxX * fit.scale),
1434
+ Math.abs(minY * fit.scale),
1435
+ Math.abs(maxY * fit.scale)
1436
+ );
1437
+ if (!(magnitude <= 2 ** 40)) return !1;
1438
+ let margin = 16 * Number.EPSILON * magnitude, inner = { x: keyArea.x + margin, y: keyArea.y + margin, w: keyArea.w - 2 * margin, h: keyArea.h - 2 * margin };
1439
+ if (!(inner.w >= 0 && inner.h >= 0)) return !1;
1440
+ let inside = (px, py) => fits.every((fit) => pointInRect(px * fit.scale + fit.x, py * fit.scale + fit.y, inner));
1441
+ for (let region of decodeGeoPack(pack).regions) {
1442
+ if (region.marker !== void 0 && inside(region.marker.x, region.marker.y)) return !0;
1443
+ for (let polygon of region.polygons) for (let ring of polygon) for (let [px, py] of ring) if (inside(px, py)) return !0;
1444
+ }
1445
+ return !1;
1446
+ }
1447
+ function choroplethMapFrame(plot, gutter, packId, padding) {
1448
+ let xPad = padding ?? MAP_PAD, yPad = padding ?? (packId === "us-states" ? US_MAP_PAD_Y : MAP_PAD);
1449
+ return {
1450
+ x: plot.x + xPad,
1451
+ y: plot.y + yPad,
1452
+ w: Math.max(10, plot.w - xPad * 2 - gutter),
1453
+ h: Math.max(10, plot.h - yPad * 2)
1454
+ };
1455
+ }
1456
+ function measuredLeaderGutter(regions, leaderIds, plot, theme, measure, valueTexts) {
1457
+ let compactFont = geoLabelFont(theme), maxWidth = regions.filter((region) => leaderIds.has(region.id)).reduce(
1458
+ (largest, region) => Math.max(largest, measure(regionLabelText(region, compactFont, measure, valueTexts), compactFont).width),
1459
+ 0
1460
+ );
1461
+ return Math.min(LEADER_GUTTER, plot.w * LEADER_GUTTER_SHARE, Math.max(28, maxWidth + 24));
1462
+ }
1463
+ function buildLeaderLanes(prepared, leaderIds, plot, theme, measure, valueTexts) {
1464
+ let { regions } = prepared.fitted, compactFont = geoLabelFont(theme), h = compactFont.size * (compactFont.lineHeight ?? 1.2), ordered = regions.filter((region) => leaderIds.has(region.id)).sort((a, b) => a.anchor.y - b.anchor.y || compareText(a.id, b.id));
1465
+ if (ordered.length === 0) return /* @__PURE__ */ new Map();
1466
+ let availableGap = ordered.length === 1 ? LEADER_LANE_GAP : (plot.h - ordered.length * h) / (ordered.length - 1), gap = Math.max(0, Math.min(LEADER_LANE_GAP, availableGap)), top = plot.y, bottom = plot.y + plot.h - h, y = ordered.map(
1467
+ (region) => Math.max(top, Math.min(bottom, region.anchor.y - h / 2))
1468
+ );
1469
+ for (let index = 1; index < y.length; index++)
1470
+ y[index] = Math.max(y[index], y[index - 1] + h + gap);
1471
+ if (y[y.length - 1] > bottom) {
1472
+ y[y.length - 1] = bottom;
1473
+ for (let index = y.length - 2; index >= 0; index--)
1474
+ y[index] = Math.min(y[index], y[index + 1] - h - gap);
1475
+ }
1476
+ if (y[0] < top) {
1477
+ y[0] = top;
1478
+ for (let index = 1; index < y.length; index++)
1479
+ y[index] = Math.max(y[index], y[index - 1] + h + gap);
1480
+ }
1481
+ let contentRight = prepared.contentRight ??= regions.reduce((right, region) => {
1482
+ if (region.polygons.length > 0)
1483
+ return Math.max(right, boundsOfPolygons(region.polygons)[2]);
1484
+ let marker = region.marker ?? {
1485
+ x: region.anchor.x,
1486
+ y: region.anchor.y,
1487
+ radius: 2.5
1488
+ };
1489
+ return Math.max(right, marker.x + marker.radius);
1490
+ }, plot.x), maxLabelWidth = ordered.reduce(
1491
+ (width, region) => Math.max(
1492
+ width,
1493
+ measure(regionLabelText(region, compactFont, measure, valueTexts), compactFont).width
1494
+ ),
1495
+ 0
1496
+ ), laneX = Math.min(plot.x + plot.w - maxLabelWidth, contentRight + 16);
1497
+ return new Map(
1498
+ ordered.map((region, index) => {
1499
+ let text = regionLabelText(region, compactFont, measure, valueTexts);
1500
+ return [
1501
+ region.id,
1502
+ {
1503
+ index,
1504
+ rect: {
1505
+ x: laneX,
1506
+ y: y[index],
1507
+ w: measure(text, compactFont).width,
1508
+ h
1509
+ }
1510
+ }
1511
+ ];
1512
+ })
1513
+ );
1514
+ }
1515
+ function labelPlanForRegion(region, leaderLane, theme, measure, insidePaint, markerInline, valueTexts, rank, outsideFits, pattern, emphasized = !1, crossingCallouts = !1) {
1516
+ let tierFont = geoLabelFont(theme), compactFont = emphasized ? { ...tierFont, weight: emphasisWeight(theme) } : tierFont, compactText = regionLabelText(region, compactFont, measure, valueTexts), priority = PRIORITY.interior + Math.max(0, 300 - rank), compact = regionLabelRequest(
1517
+ region,
1518
+ compactText,
1519
+ compactFont,
1520
+ priority,
1521
+ inlineRegionCandidates(region, compactText, compactFont, effectiveFill(paintColor(theme, insidePaint), pattern, theme), measure, insidePaint, pattern)
1522
+ ), variants = region.marker !== void 0 && region.polygons.length === 0 ? [{
1523
+ request: {
1524
+ ...compact,
1525
+ candidates: markerInline ? inlineMarkerCandidates(region, compactText, compactFont, measure).filter((candidate) => outsideFits(region.id, candidate.rect)) : []
1526
+ },
1527
+ font: compactFont,
1528
+ leader: !1
1529
+ }] : [
1530
+ { request: compact, font: compactFont, leader: !1 },
1531
+ /**
1532
+ * A region whose label does not fit on its own fill gets a callout
1533
+ * on the free side nearest it, on a short straight leader that
1534
+ * crosses no other region when a free side allows. A backed chip
1535
+ * beside the anchor would hide the neighbours' fill.
1536
+ */
1537
+ {
1538
+ request: regionLabelRequest(region, compactText, compactFont, priority, []),
1539
+ font: compactFont,
1540
+ leader: !1,
1541
+ callout: (occupied, plot) => {
1542
+ let strict = calloutCandidates(region, compactText, compactFont, measure, occupied, plot, outsideFits);
1543
+ return strict.length || !crossingCallouts ? strict : calloutCandidates(region, compactText, compactFont, measure, occupied, plot, () => !0);
1544
+ }
1545
+ }
1546
+ ];
1547
+ return leaderLane && variants.push({
1548
+ request: regionLabelRequest(
1549
+ region,
1550
+ compactText,
1551
+ compactFont,
1552
+ priority,
1553
+ [{
1554
+ slot: `leaderLane:${leaderLane.index + 1}`,
1555
+ rect: leaderLane.rect,
1556
+ penalty: 10,
1557
+ leaderFrom: { x: region.anchor.x, y: region.anchor.y }
1558
+ }].filter((candidate) => outsideFits(
1559
+ region.id,
1560
+ candidate.rect,
1561
+ [region.anchor.x, region.anchor.y],
1562
+ leaderTarget([region.anchor.x, region.anchor.y], candidate.rect)
1563
+ ))
1564
+ ),
1565
+ font: compactFont,
1566
+ leader: !0
1567
+ }), { region, priority, variants };
1568
+ }
1569
+ function regionLabelText(region, font, measure, valueTexts) {
1570
+ let code = shortestRegionName(region, font, measure), value = valueTexts.get(region.id);
1571
+ return value === void 0 ? code : `${code} ${value}`;
1572
+ }
1573
+ function backedSlotsAround(cx, cy, gap, text, font, measure, slotPrefix, basePenalty) {
1574
+ let w = measure(text, font).width, h = font.size * (font.lineHeight ?? 1.2);
1575
+ return [
1576
+ {
1577
+ slot: `${slotPrefix}Right`,
1578
+ rect: { x: cx + gap, y: cy - h / 2, w, h },
1579
+ penalty: basePenalty,
1580
+ needsBacking: !0,
1581
+ contrast: "box"
1582
+ },
1583
+ {
1584
+ slot: `${slotPrefix}Left`,
1585
+ rect: { x: cx - gap - w, y: cy - h / 2, w, h },
1586
+ penalty: basePenalty + 1,
1587
+ needsBacking: !0,
1588
+ contrast: "box"
1589
+ },
1590
+ {
1591
+ slot: `${slotPrefix}Above`,
1592
+ rect: { x: cx - w / 2, y: cy - gap - h, w, h },
1593
+ penalty: basePenalty + 2,
1594
+ needsBacking: !0,
1595
+ contrast: "box"
1596
+ },
1597
+ {
1598
+ slot: `${slotPrefix}Below`,
1599
+ rect: { x: cx - w / 2, y: cy + gap, w, h },
1600
+ penalty: basePenalty + 3,
1601
+ needsBacking: !0,
1602
+ contrast: "box"
1603
+ }
1604
+ ];
1605
+ }
1606
+ function inlineMarkerCandidates(region, text, font, measure) {
1607
+ let marker = region.marker ?? {
1608
+ x: region.anchor.x,
1609
+ y: region.anchor.y,
1610
+ radius: 2.5
1611
+ };
1612
+ return backedSlotsAround(marker.x, marker.y, marker.radius + 6, text, font, measure, "marker", 0);
1613
+ }
1614
+ function inlineRegionCandidates(region, text, font, insideFill, measure, insidePaint, insidePattern) {
1615
+ let measured = measure(text, font), lineH = font.size * (font.lineHeight ?? 1.2), w = measured.width, h = lineH, availableSpan = region.anchor.clearance * CLEARANCE_TEXT_SPAN;
1616
+ if (w > availableSpan || h > availableSpan || w * h > LABEL_MAX_COVER * polygonsArea(region.polygons)) return [];
1617
+ let decorate = (candidate) => (
1618
+ // Pattern strokes need the same page-colour halo as a hatched tile.
1619
+ { ...candidate, insideFill, insidePaint, ...insidePattern ? { insidePattern, needsBacking: !0 } : {} }
1620
+ ), gap = 3, center = {
1621
+ x: region.anchor.x - w / 2,
1622
+ y: region.anchor.y - h / 2,
1623
+ w,
1624
+ h
1625
+ }, prefix = "insideCompact", candidates = [
1626
+ decorate({ slot: `${prefix}Center`, rect: center, penalty: 3 }),
1627
+ decorate({
1628
+ slot: `${prefix}Above`,
1629
+ rect: { x: center.x, y: region.anchor.y - h - gap, w, h },
1630
+ penalty: 4
1631
+ }),
1632
+ decorate({
1633
+ slot: `${prefix}Below`,
1634
+ rect: { x: center.x, y: region.anchor.y + gap, w, h },
1635
+ penalty: 5
1636
+ })
1637
+ ];
1638
+ return [
1639
+ ["Up", 0, -3],
1640
+ ["Down", 0, 3],
1641
+ ["NudgeLeft", -3, 0],
1642
+ ["NudgeRight", 3, 0],
1643
+ ["UpLeft", -3, -3],
1644
+ ["UpRight", 3, -3],
1645
+ ["DownLeft", -3, 3],
1646
+ ["DownRight", 3, 3],
1647
+ ["FarUp", 0, -6],
1648
+ ["FarDown", 0, 6],
1649
+ ["FarLeft", -6, 0],
1650
+ ["FarRight", 6, 0]
1651
+ ].forEach(([name, dx, dy], index) => {
1652
+ candidates.push(decorate({
1653
+ slot: `insideCompact${name}`,
1654
+ rect: { x: center.x + dx, y: center.y + dy, w, h },
1655
+ penalty: 6 + index
1656
+ }));
1657
+ }), candidates.push(
1658
+ decorate({
1659
+ slot: "insideCompactLeft",
1660
+ rect: { x: region.anchor.x - w - gap, y: center.y, w, h },
1661
+ penalty: 18
1662
+ }),
1663
+ decorate({
1664
+ slot: "insideCompactRight",
1665
+ rect: { x: region.anchor.x + gap, y: center.y, w, h },
1666
+ penalty: 19
1667
+ }),
1668
+ decorate({
1669
+ slot: "insideCompactAboveLeft",
1670
+ rect: { x: region.anchor.x - w - gap, y: region.anchor.y - h - gap, w, h },
1671
+ penalty: 20
1672
+ }),
1673
+ decorate({
1674
+ slot: "insideCompactAboveRight",
1675
+ rect: { x: region.anchor.x + gap, y: region.anchor.y - h - gap, w, h },
1676
+ penalty: 21
1677
+ }),
1678
+ decorate({
1679
+ slot: "insideCompactBelowLeft",
1680
+ rect: { x: region.anchor.x - w - gap, y: region.anchor.y + gap, w, h },
1681
+ penalty: 22
1682
+ }),
1683
+ decorate({
1684
+ slot: "insideCompactBelowRight",
1685
+ rect: { x: region.anchor.x + gap, y: region.anchor.y + gap, w, h },
1686
+ penalty: 23
1687
+ })
1688
+ ), candidates;
1689
+ }
1690
+ function regionLabelRequest(region, text, font, priority, candidates) {
1691
+ return {
1692
+ id: `category:${region.id}`,
1693
+ kind: "category",
1694
+ typeRole: "label",
1695
+ owner: { categoryId: region.id },
1696
+ text,
1697
+ lines: [text],
1698
+ font,
1699
+ priority,
1700
+ candidates
1701
+ };
1702
+ }
1703
+ var regionPaths = /* @__PURE__ */ new WeakMap(), regionStrips = /* @__PURE__ */ new WeakMap(), regionHatches = /* @__PURE__ */ new WeakMap();
1704
+ function polygonsPath(polygons) {
1705
+ let d = regionPaths.get(polygons);
1706
+ return d === void 0 && regionPaths.set(polygons, d = polygonsPathOf(polygons)), d;
1707
+ }
1708
+ function polygonsPathOf(polygons) {
1709
+ let path = "";
1710
+ return polygons.forEach((polygon) => polygon.forEach((ring) => {
1711
+ if (ring.length !== 0) {
1712
+ path += `M${coord(ring[0])}`;
1713
+ for (let i = 1; i < ring.length; i++) i in ring && (path += `L${coord(ring[i])}`);
1714
+ path += "Z";
1715
+ }
1716
+ })), path;
1717
+ }
1718
+ function markerPath(cx, cy, radius, strokeWidth) {
1719
+ let r = round2(Math.max(radius - strokeWidth / 2, strokeWidth / 2));
1720
+ return `M${coord([cx - r, cy])}A${r},${r} 0 1 0 ${coord([cx + r, cy])}A${r},${r} 0 1 0 ${coord([cx - r, cy])}Z`;
1721
+ }
1722
+ function boundaryPath(boundary) {
1723
+ return boundary.lines.map((line) => polylinePath(line)).join("");
1724
+ }
1725
+ function minimumHatchTick(anchor, radius) {
1726
+ return [{
1727
+ a: [anchor.x - radius, anchor.y + radius],
1728
+ b: [anchor.x + radius, anchor.y - radius]
1729
+ }];
1730
+ }
1731
+ function hatchSegments(region, strokeWidth) {
1732
+ if (region.polygons.length === 0) {
1733
+ let markerRadius = region.marker?.radius ?? 2.5;
1734
+ if (markerRadius < Math.max(0.75, strokeWidth / 2)) return [];
1735
+ let pathRadius = Math.max(markerRadius - strokeWidth / 2, strokeWidth / 2);
1736
+ return minimumHatchTick(
1737
+ // centre on the DISC, not the anchor — the two can differ by a
1738
+ // fraction of a pixel and the budget is the disc.
1739
+ { x: region.marker?.x ?? region.anchor.x, y: region.marker?.y ?? region.anchor.y },
1740
+ Math.min(pathRadius / Math.SQRT2 - TICK_SERIALIZATION_EPS, HATCH_STEP / 2)
1741
+ );
1742
+ }
1743
+ if (region.anchor.clearance < Math.max(0.75, strokeWidth / 2)) return [];
1744
+ let segments = regionHatches.get(region.polygons);
1745
+ if (segments || regionHatches.set(region.polygons, segments = polygonHatchSegments(region.polygons, boundsOfPolygons(region.polygons))), segments.length > 0) return segments;
1746
+ let clearance = region.anchor.clearance;
1747
+ return clearance < Math.max(0.75, strokeWidth / 2) ? [] : minimumHatchTick(
1748
+ region.anchor,
1749
+ // Same two-decimal serialization reserve as the marker tick.
1750
+ Math.min(
1751
+ Math.sqrt((clearance * clearance - (strokeWidth / 2) ** 2) / 2) - TICK_SERIALIZATION_EPS,
1752
+ HATCH_STEP / 2
1753
+ )
1754
+ );
1755
+ }
1756
+ var TICK_SERIALIZATION_EPS = 0.015;
1757
+ function polygonHatchSegments(polygons, bounds) {
1758
+ let segments = [], start = Math.floor((bounds[0] + bounds[1]) / HATCH_STEP) * HATCH_STEP, end = bounds[2] + bounds[3];
1759
+ for (let diagonal = start; diagonal <= end; diagonal += HATCH_STEP)
1760
+ pushAll(segments, diagonalChords(polygons, diagonal));
1761
+ return segments;
1762
+ }
1763
+ function diagonalChords(polygons, diagonal) {
1764
+ let segments = [];
1765
+ for (let polygon of polygons) {
1766
+ let intersections = [];
1767
+ for (let ring of polygon)
1768
+ for (let i = 1; i < ring.length; i++) {
1769
+ let a = ring[i - 1], b = ring[i], fa = a[0] + a[1] - diagonal, fb = b[0] + b[1] - diagonal;
1770
+ if (fa <= 0 && fb > 0 || fb <= 0 && fa > 0) {
1771
+ let t = fa / (fa - fb);
1772
+ intersections.push([a[0] + t * (b[0] - a[0]), a[1] + t * (b[1] - a[1])]);
1773
+ }
1774
+ }
1775
+ intersections.sort((a, b) => a[0] - b[0] || a[1] - b[1]);
1776
+ for (let i = 0; i + 1 < intersections.length; i += 2)
1777
+ segments.push({ a: intersections[i], b: intersections[i + 1] });
1778
+ }
1779
+ return segments;
1780
+ }
1781
+ function segmentsPath(segments) {
1782
+ return segments.map((segment) => `M${coord(segment.a)}L${coord(segment.b)}`).join("");
1783
+ }
1784
+ function claimPolygonFill(polygons, occupied, regionId) {
1785
+ let strips = regionStrips.get(polygons);
1786
+ strips || regionStrips.set(polygons, strips = polygonFillStrips(polygons));
1787
+ for (let strip of strips) occupied.claim(strip, "mark", { categoryId: regionId }, "region");
1788
+ }
1789
+ function polygonFillStrips(polygons) {
1790
+ let strips = [];
1791
+ for (let polygon of polygons) {
1792
+ let bounds = boundsOfPolygons([polygon]), firstY = Math.floor(bounds[1] / CLAIM_STEP) * CLAIM_STEP + CLAIM_STEP / 2, rows = [];
1793
+ for (let y = firstY; y <= bounds[3]; y += CLAIM_STEP) rows.push(y);
1794
+ let crossing = rows.map(() => []);
1795
+ for (let ring of polygon)
1796
+ for (let i = 1; i < ring.length; i++) {
1797
+ let a = ring[i - 1], b = ring[i], low = Math.min(a[1], b[1]), high = Math.max(a[1], b[1]);
1798
+ if (!(low < high)) continue;
1799
+ let lo = 0, hi = rows.length;
1800
+ for (; lo < hi; ) {
1801
+ let mid = lo + hi >> 1;
1802
+ rows[mid] < low ? lo = mid + 1 : hi = mid;
1803
+ }
1804
+ for (let row = lo; row < rows.length && rows[row] < high; row++) crossing[row].push(a, b);
1805
+ }
1806
+ for (let row = 0; row < rows.length; row++) {
1807
+ let y = rows[row], edges = crossing[row], intersections = [];
1808
+ for (let i = 0; i < edges.length; i += 2) {
1809
+ let a = edges[i], b = edges[i + 1], t = (y - a[1]) / (b[1] - a[1]);
1810
+ intersections.push(a[0] + t * (b[0] - a[0]));
1811
+ }
1812
+ intersections.sort((a, b) => a - b);
1813
+ for (let i = 0; i + 1 < intersections.length; i += 2) {
1814
+ let x1 = intersections[i], x2 = intersections[i + 1];
1815
+ strips.push({ x: x1, y: y - CLAIM_STEP / 2, w: Math.max(0.5, x2 - x1), h: CLAIM_STEP });
1816
+ }
1817
+ }
1818
+ }
1819
+ return strips;
1820
+ }
1821
+ function claimRegionMark(region, occupied) {
1822
+ if (region.polygons.length > 0) {
1823
+ claimPolygonFill(region.polygons, occupied, region.id);
1824
+ return;
1825
+ }
1826
+ let marker = region.marker ?? {
1827
+ x: region.anchor.x,
1828
+ y: region.anchor.y,
1829
+ radius: 2.5
1830
+ };
1831
+ occupied.claim(
1832
+ {
1833
+ x: marker.x - marker.radius,
1834
+ y: marker.y - marker.radius,
1835
+ w: marker.radius * 2,
1836
+ h: marker.radius * 2
1837
+ },
1838
+ "mark",
1839
+ { categoryId: region.id },
1840
+ "region"
1841
+ );
1842
+ }
1843
+ function claimHatchSegments(segments, occupied, regionId) {
1844
+ for (let segment of segments) claimSegment(segment, occupied, regionId, "noDataHatch");
1845
+ }
1846
+ function claimSegment(segment, occupied, regionId, part) {
1847
+ claimOwnedSegment(segment, occupied, { categoryId: regionId }, part);
1848
+ }
1849
+ function claimOwnedSegment(segment, occupied, owner, part) {
1850
+ let dx = segment.b[0] - segment.a[0], dy = segment.b[1] - segment.a[1], slices = Math.max(1, Math.ceil(Math.hypot(dx, dy) / CLAIM_STEP));
1851
+ for (let index = 0; index < slices; index++) {
1852
+ let t1 = index / slices, t2 = (index + 1) / slices, a = [segment.a[0] + dx * t1, segment.a[1] + dy * t1], b = [segment.a[0] + dx * t2, segment.a[1] + dy * t2];
1853
+ occupied.claim(
1854
+ {
1855
+ x: Math.min(a[0], b[0]) - 0.6,
1856
+ y: Math.min(a[1], b[1]) - 0.6,
1857
+ w: Math.abs(b[0] - a[0]) + 1.2,
1858
+ h: Math.abs(b[1] - a[1]) + 1.2
1859
+ },
1860
+ "mark",
1861
+ owner,
1862
+ part
1863
+ );
1864
+ }
1865
+ }
1866
+ function claimBoundaryMark(boundary, occupied) {
1867
+ for (let line of boundary.lines)
1868
+ for (let index = 1; index < line.length; index++)
1869
+ claimOwnedSegment(
1870
+ { a: line[index - 1], b: line[index] },
1871
+ occupied,
1872
+ {},
1873
+ "disputedBoundary"
1874
+ );
1875
+ }
1876
+ function leaderTarget(from, rect) {
1877
+ return [
1878
+ from[0] <= rect.x ? rect.x : rect.x + rect.w,
1879
+ rect.y + rect.h / 2
1880
+ ];
1881
+ }
1882
+ function leaderPolyline(from, to) {
1883
+ let dx = to[0] - from[0], dy = to[1] - from[1];
1884
+ if (Math.abs(dx) <= 8 || Math.abs(dy) <= 8) return [from, to];
1885
+ let midpointX = from[0] + dx / 2;
1886
+ return Array.from({ length: 13 }, (_, index) => {
1887
+ let t = index / 12, inv = 1 - t;
1888
+ return [
1889
+ inv ** 3 * from[0] + 3 * inv ** 2 * t * midpointX + 3 * inv * t ** 2 * midpointX + t ** 3 * to[0],
1890
+ inv ** 3 * from[1] + 3 * inv ** 2 * t * from[1] + 3 * inv * t ** 2 * to[1] + t ** 3 * to[1]
1891
+ ];
1892
+ });
1893
+ }
1894
+ function claimLeader(from, to, occupied, regionId) {
1895
+ let points = leaderPolyline(from, to);
1896
+ for (let index = 1; index < points.length; index++)
1897
+ claimSegment(
1898
+ { a: points[index - 1], b: points[index] },
1899
+ occupied,
1900
+ regionId,
1901
+ "regionLeader"
1902
+ );
1903
+ }
1904
+ function boundsOfPolygons(polygons) {
1905
+ let minX = 1 / 0, minY = 1 / 0, maxX = -1 / 0, maxY = -1 / 0;
1906
+ for (let polygon of polygons)
1907
+ for (let ring of polygon)
1908
+ for (let point of ring)
1909
+ minX = Math.min(minX, point[0]), minY = Math.min(minY, point[1]), maxX = Math.max(maxX, point[0]), maxY = Math.max(maxY, point[1]);
1910
+ return [minX, minY, maxX, maxY];
1911
+ }
1912
+ function nearestRegionId(input, candidates, canonical) {
1913
+ let best;
1914
+ for (let candidate of candidates) {
1915
+ let distance = levenshtein(input.toUpperCase(), candidate.toUpperCase());
1916
+ (!best || distance < best.distance || distance === best.distance && candidate < best.id) && (best = { id: candidate, distance });
1917
+ }
1918
+ if (!(!best || best.distance > Math.max(2, Math.floor(input.length / 2))))
1919
+ return canonical.get(best.id);
1920
+ }
1921
+ function pointInRect(x, y, rect) {
1922
+ return x >= rect.x && x <= rect.x + rect.w && y >= rect.y && y <= rect.y + rect.h;
1923
+ }
1924
+ function pathLength(d) {
1925
+ let numbers = (d.match(/-?\d+(?:\.\d+)?/g) ?? []).map(Number), length = 0;
1926
+ for (let index = 2; index + 1 < numbers.length; index += 2)
1927
+ length += Math.hypot(numbers[index] - numbers[index - 2], numbers[index + 1] - numbers[index - 1]);
1928
+ return length;
1929
+ }
1930
+ function valueRanks(valuesById) {
1931
+ return new Map([...valuesById].flatMap(([id, value]) => value === null ? [] : [{ id, value }]).sort((a, b) => Math.abs(b.value) - Math.abs(a.value) || compareText(a.id, b.id)).map(({ id }, index) => [id, index]));
1932
+ }
1933
+ function polygonsArea(polygons) {
1934
+ return polygons.reduce((total, polygon) => total + polygon.reduce((sum, ring, index) => {
1935
+ let twice = 0;
1936
+ for (let i = 0; i < ring.length; i++) {
1937
+ let a = ring[i], b = ring[(i + 1) % ring.length];
1938
+ twice += a[0] * b[1] - b[0] * a[1];
1939
+ }
1940
+ return sum + (index === 0 ? 1 : -1) * Math.abs(twice) / 2;
1941
+ }, 0), 0);
1942
+ }
1943
+ function calloutTerminus(from, rect) {
1944
+ let box = { x: rect.x - 2, y: rect.y - 2, w: rect.w + 4, h: rect.h + 4 };
1945
+ return [Math.max(box.x, Math.min(from[0], box.x + box.w)), Math.max(box.y, Math.min(from[1], box.y + box.h))];
1946
+ }
1947
+ function calloutCandidates(region, text, font, measure, occupied, plot, outsideFits) {
1948
+ let w = measure(text, font).width, h = font.size * (font.lineHeight ?? 1.2), from = [region.anchor.x, region.anchor.y], candidates = [], blocker, taken = (claim) => (blocker = claim, !1);
1949
+ for (let k = 0; k < CALLOUT_DIRECTIONS; k++) {
1950
+ let angle = 2 * Math.PI * k / CALLOUT_DIRECTIONS, dx = Math.cos(angle), dy = Math.sin(angle), reach = Math.abs(dx) * (w / 2) + Math.abs(dy) * (h / 2);
1951
+ for (let d = Math.max(2, region.anchor.clearance); d <= 2 * CALLOUT_MAX_LEADER; d += Math.max(CALLOUT_STEP, d / 8)) {
1952
+ let rect = { x: from[0] + dx * (d + reach) - w / 2, y: from[1] + dy * (d + reach) - h / 2, w, h };
1953
+ if (rect.x < plot.x || rect.y < plot.y || rect.x + rect.w > plot.x + plot.w || rect.y + rect.h > plot.y + plot.h) break;
1954
+ if (blocker && !blocker.polygon && rectsOverlap(blocker.rect, rect, 2) || occupied.hits(rect, 2, taken) || !text.includes(" ") && occupied.hitsWhich(rect, 8).some((claim) => claim.kind === "label" && boxGap(rect, claim.rect) < 8 && Math.abs(rect.y + h / 2 - claim.rect.y - claim.rect.h / 2) < Math.min(h, claim.rect.h) / 2)) continue;
1955
+ let to = calloutTerminus(from, rect);
1956
+ if (!outsideFits(region.id, rect, from, to)) break;
1957
+ let length = Math.hypot(to[0] - from[0], to[1] - from[1]), crossesLabel = !1, samples = Math.max(1, Math.ceil(length / 3));
1958
+ occupied.hits(
1959
+ { x: Math.min(from[0], to[0]) - 0.5, y: Math.min(from[1], to[1]) - 0.5, w: Math.abs(to[0] - from[0]) + 1, h: Math.abs(to[1] - from[1]) + 1 },
1960
+ 1,
1961
+ (claim) => {
1962
+ if (claim.kind !== "label" && claim.part !== "regionLeader") return !0;
1963
+ let [x0, x1] = sampleSpan(from[0], to[0] - from[0], samples, claim.rect.x, claim.rect.x + claim.rect.w), [y0, y1] = sampleSpan(from[1], to[1] - from[1], samples, claim.rect.y, claim.rect.y + claim.rect.h);
1964
+ for (let i = Math.max(x0, y0); i <= Math.min(x1, y1); i++) {
1965
+ let x = from[0] + (to[0] - from[0]) * i / samples, y = from[1] + (to[1] - from[1]) * i / samples, box = { x: x - 0.5, y: y - 0.5, w: 1, h: 1 };
1966
+ if (!(!rectsOverlap(claim.rect, box, 0) || claim.polygon !== void 0 && !rectHitsConvexPolygon(box, claim.polygon, 0))) {
1967
+ crossesLabel = !0;
1968
+ break;
1969
+ }
1970
+ }
1971
+ return !crossesLabel;
1972
+ }
1973
+ ), crossesLabel || candidates.push({
1974
+ slot: `callout${k}`,
1975
+ rect,
1976
+ penalty: Math.round(length + (length > CALLOUT_MAX_LEADER ? 1e3 : 0))
1977
+ });
1978
+ break;
1979
+ }
1980
+ }
1981
+ return candidates.sort((a, b) => a.penalty - b.penalty || compareText(a.slot, b.slot));
1982
+ }
1983
+ function sampleSpan(start, delta, samples, lo, hi) {
1984
+ if (delta === 0) return [0, samples];
1985
+ let a = (lo - 0.5 - start) * samples / delta, b = (hi + 0.5 - start) * samples / delta;
1986
+ return [Math.max(0, Math.floor(Math.min(a, b)) - 1), Math.min(samples, Math.ceil(Math.max(a, b)) + 1)];
1987
+ }
1988
+ function coord(point) {
1989
+ return `${round2(point[0])},${round2(point[1])}`;
1990
+ }
1991
+
1992
+ // src/core/charts/choropleth/core.ts
1993
+ var choroplethCore = {
1994
+ type: "choropleth",
1995
+ sizing: chartSizing("choropleth"),
1996
+ title: "Choropleth map",
1997
+ summary: "Equal-area region map with deterministic pre-baked geometry and explicit missing-data traces",
1998
+ layout: layoutChoropleth,
1999
+ defaults: {
2000
+ scale: { kind: "sequential" },
2001
+ labels: "auto"
2002
+ },
2003
+ annotationKinds: []
2004
+ };
2005
+
2006
+ export {
2007
+ choroplethCore
2008
+ };