boardplot 0.56.0 → 0.57.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 (468) hide show
  1. package/CHANGELOG.md +110 -0
  2. package/README.md +3 -3
  3. package/dist/{ReaderBox-GLCKYXBU.js → ReaderBox-GCIITQCX.js} +4 -4
  4. package/dist/{annotateEngine-QVNAE3EH.js → annotateEngine-JMZI6QEG.js} +1 -1
  5. package/dist/build-identity.json +3 -3
  6. package/dist/{chunk-CKGSGRP7.js → chunk-26WNBTWB.js} +20 -4
  7. package/dist/{chunk-UBCVBBJJ.js → chunk-2AJWRVZ2.js} +4 -3
  8. package/dist/{chunk-XMP2DNLI.js → chunk-2BHLRHF2.js} +2 -2
  9. package/dist/{chunk-2NRHD2G7.js → chunk-2HD5RY2U.js} +11 -3
  10. package/dist/{chunk-6QDMRPXI.js → chunk-2I76VFMZ.js} +184 -239
  11. package/dist/{chunk-XC5IRUEL.js → chunk-2KCK63DD.js} +2 -2
  12. package/dist/{chunk-ZEYBI47P.js → chunk-2WTD3GCR.js} +11 -3
  13. package/dist/{chunk-BTDGWHGJ.js → chunk-2X6XY4K4.js} +4 -4
  14. package/dist/{chunk-5S3JQ5AT.js → chunk-3DUGZ7ML.js} +149 -118
  15. package/dist/{chunk-JTFKRDDA.js → chunk-3LNVEE5Z.js} +1 -1
  16. package/dist/{chunk-JCAGVAB3.js → chunk-43PCSBVQ.js} +563 -10
  17. package/dist/{chunk-F2EVCJ4U.js → chunk-4JNHF6JW.js} +10 -10
  18. package/dist/{chunk-ECBUFKCP.js → chunk-4RN4OM6I.js} +3 -3
  19. package/dist/{chunk-A2GAWGVJ.js → chunk-4U2WSW6F.js} +20 -20
  20. package/dist/{chunk-CCDXK5NA.js → chunk-53OEKS4L.js} +5 -3
  21. package/dist/{chunk-YPYD6OJ3.js → chunk-54HEIM2A.js} +2 -2
  22. package/dist/{chunk-IGJ2G5C6.js → chunk-5H4HFRDO.js} +6 -6
  23. package/dist/{chunk-EMFUZKYK.js → chunk-5HTGSB6Y.js} +3 -3
  24. package/dist/{chunk-WXJ5MHLH.js → chunk-5JTRCSBN.js} +1 -1
  25. package/dist/{chunk-67QSW5RW.js → chunk-5P4MXWKP.js} +3 -3
  26. package/dist/{chunk-EBB4PYBN.js → chunk-5RHP7YTL.js} +5 -5
  27. package/dist/{chunk-VVXKFU72.js → chunk-5TUDYKNL.js} +35 -27
  28. package/dist/{chunk-HZUAEMN5.js → chunk-5WSIH4SR.js} +1 -1
  29. package/dist/{chunk-KF7HD3EH.js → chunk-62JZL6FW.js} +43 -35
  30. package/dist/{chunk-S7NRL66K.js → chunk-6EE6XEMA.js} +4 -4
  31. package/dist/chunk-6JXBLQJ2.js +32 -0
  32. package/dist/{chunk-KBJMLXNW.js → chunk-6KHRMK3I.js} +14 -14
  33. package/dist/{chunk-2DOEZ5QY.js → chunk-6LQKU6YN.js} +4 -4
  34. package/dist/chunk-6VU2XI3W.js +89 -0
  35. package/dist/{chunk-DQ7YMQVX.js → chunk-6WJOHZPW.js} +5 -5
  36. package/dist/{chunk-ZMPH2OC4.js → chunk-6XU5XGYV.js} +7 -8
  37. package/dist/{chunk-MAFPVR4G.js → chunk-6ZN2XJFI.js} +10 -5
  38. package/dist/{chunk-PQLAZEQV.js → chunk-72OJBDRB.js} +204 -59
  39. package/dist/{chunk-T2YDWT54.js → chunk-73O6AOAA.js} +43 -30
  40. package/dist/{chunk-4JHMCXOB.js → chunk-76UL4CT4.js} +60 -24
  41. package/dist/chunk-7BQK2UDV.js +13 -0
  42. package/dist/{chunk-7PPMT5EJ.js → chunk-7EQU2TUN.js} +300 -64
  43. package/dist/{chunk-2HTYGMMG.js → chunk-7FAO4ICF.js} +2 -2
  44. package/dist/{chunk-6WHWXCHJ.js → chunk-7MYJUJZV.js} +6 -2
  45. package/dist/{chunk-CB4CERXZ.js → chunk-7P7D6WXR.js} +11 -2
  46. package/dist/{chunk-RT66UTLJ.js → chunk-A33MFWHW.js} +2 -2
  47. package/dist/{chunk-4JC3SE4G.js → chunk-A6XCVOC5.js} +1 -1
  48. package/dist/{chunk-QWCLWFKC.js → chunk-AFA32LHN.js} +132 -36
  49. package/dist/{chunk-T2CYNDYU.js → chunk-AFGQXMKT.js} +235 -80
  50. package/dist/{chunk-HOU2MZHC.js → chunk-AKJO6N4K.js} +2 -2
  51. package/dist/{chunk-MRAP2UVV.js → chunk-ANNQJWDX.js} +10 -10
  52. package/dist/{chunk-LGNJCPFP.js → chunk-AOIZJ7GR.js} +7 -7
  53. package/dist/chunk-B5A7X2BA.js +44 -0
  54. package/dist/{chunk-SS4YGK3E.js → chunk-BDCKHLUB.js} +15 -15
  55. package/dist/{chunk-XHRUXZD7.js → chunk-BFDPY7JM.js} +10 -3
  56. package/dist/{chunk-BK6P6KMW.js → chunk-BM2A3IGQ.js} +1 -1
  57. package/dist/{chunk-GQT2SY2S.js → chunk-BO5EJBLH.js} +247 -127
  58. package/dist/chunk-BQIADGJB.js +23 -0
  59. package/dist/{chunk-PJBEJR2U.js → chunk-BY5JGQFZ.js} +24 -7
  60. package/dist/{chunk-SXD3OYAR.js → chunk-C5SQEYTQ.js} +76 -55
  61. package/dist/{chunk-3465633G.js → chunk-CEMXGMQN.js} +2 -2
  62. package/dist/{chunk-AMR4SUAN.js → chunk-CIDOL4FO.js} +5 -5
  63. package/dist/{chunk-E7V3OHQQ.js → chunk-CT4RFZO4.js} +6 -6
  64. package/dist/{chunk-7Q37C6GZ.js → chunk-CV3NC75L.js} +1 -1
  65. package/dist/{chunk-FFJGC2DX.js → chunk-D3PQAVFW.js} +22 -12
  66. package/dist/{chunk-52WNCUIN.js → chunk-D5G67OER.js} +1 -1
  67. package/dist/{chunk-MOS6WFWM.js → chunk-D5RAVZ5C.js} +6 -7
  68. package/dist/{chunk-FNRPQIQE.js → chunk-DJBMA4FW.js} +4 -4
  69. package/dist/{chunk-4DZFR52I.js → chunk-DPUCT567.js} +2 -2
  70. package/dist/{chunk-TE4M52AA.js → chunk-DYSEZVIJ.js} +18 -2
  71. package/dist/{chunk-SA46CNMS.js → chunk-ED7GLWTF.js} +4 -1
  72. package/dist/{chunk-R5MEBBAA.js → chunk-EDBUVDRI.js} +117 -67
  73. package/dist/{chunk-TUW5IYGA.js → chunk-EEBMK6T6.js} +6 -6
  74. package/dist/{chunk-RLMC5CUP.js → chunk-EEL2N4Y6.js} +7 -8
  75. package/dist/{chunk-CF4NMRN7.js → chunk-EFKFZNQC.js} +24 -18
  76. package/dist/{chunk-UPTXFTKH.js → chunk-EHNGPUTO.js} +6 -6
  77. package/dist/{chunk-BISJK67O.js → chunk-EHQLLZCQ.js} +48 -21
  78. package/dist/{chunk-U3A6FMSI.js → chunk-EWR6WVOV.js} +6 -6
  79. package/dist/{chunk-RMC4OONA.js → chunk-EY4OA4OF.js} +985 -663
  80. package/dist/{chunk-YYJORENB.js → chunk-F4JAGDPD.js} +5 -5
  81. package/dist/{chunk-ZY72LSQK.js → chunk-FAFUMSPR.js} +33 -24
  82. package/dist/{chunk-CYKXROFG.js → chunk-FERP4WS3.js} +19 -9
  83. package/dist/{chunk-N5HN5QGH.js → chunk-FF7MV4D4.js} +1 -1
  84. package/dist/{chunk-O7REHICC.js → chunk-FJKFYQ5I.js} +10 -10
  85. package/dist/chunk-FL3FQ2YA.js +27 -0
  86. package/dist/{chunk-YOOHNQ3L.js → chunk-FX5VZK5F.js} +4 -0
  87. package/dist/{chunk-7M2GK7XQ.js → chunk-G5BUGYIL.js} +68 -16
  88. package/dist/{chunk-QZIHKQRH.js → chunk-G5CELEUR.js} +6 -6
  89. package/dist/{chunk-ZJFJ2IKQ.js → chunk-GADI2DU7.js} +11 -10
  90. package/dist/{chunk-F6OLHND5.js → chunk-GAFEN3H7.js} +2 -2
  91. package/dist/{chunk-GM3EGUYW.js → chunk-GHFTKVJN.js} +1 -1
  92. package/dist/chunk-GKDUIDU6.js +138 -0
  93. package/dist/{chunk-OJ5CQV7H.js → chunk-GKQLKUMF.js} +186 -82
  94. package/dist/{chunk-EGGDPDYJ.js → chunk-GS5UG6QD.js} +1 -1
  95. package/dist/{chunk-5TWY3ZIC.js → chunk-H2POQ4LB.js} +5 -5
  96. package/dist/{chunk-KD5GOR2K.js → chunk-H3EWFSWI.js} +93 -52
  97. package/dist/{chunk-CHAS5A5B.js → chunk-H6EJ63QN.js} +18 -16
  98. package/dist/{chunk-GIHH6VC2.js → chunk-HB3TH7GY.js} +3 -3
  99. package/dist/{chunk-FMDNJ6PC.js → chunk-HC6WHTBX.js} +2 -2
  100. package/dist/{chunk-63Y3ROZ7.js → chunk-HDSHS2QZ.js} +45 -30
  101. package/dist/{chunk-KTHFHD6C.js → chunk-HFFKN7PA.js} +11 -6
  102. package/dist/{chunk-QSMGZOT5.js → chunk-HGPFEG2L.js} +7 -8
  103. package/dist/{chunk-2YO4WRJN.js → chunk-HVX2E26J.js} +35 -25
  104. package/dist/{chunk-KLB2QC24.js → chunk-I3DLERI7.js} +1 -1
  105. package/dist/{chunk-SPSGUFTI.js → chunk-I4NUYVP5.js} +1 -1
  106. package/dist/{chunk-LKMFMNQX.js → chunk-I5ZADE2U.js} +1 -1
  107. package/dist/{chunk-CPGASWNN.js → chunk-I65OLJ2X.js} +1 -1
  108. package/dist/{chunk-SRAV6FPB.js → chunk-I6QGYRY4.js} +3 -3
  109. package/dist/{chunk-NCLRZQR6.js → chunk-I7KDPCC7.js} +3 -3
  110. package/dist/{chunk-6EYTD777.js → chunk-IFURKTOL.js} +2 -2
  111. package/dist/{chunk-Y54LU4CU.js → chunk-IPWUBZ4P.js} +1 -1
  112. package/dist/{chunk-BIGQKCU7.js → chunk-IRXTNSZL.js} +9 -9
  113. package/dist/{chunk-2FKEF2AC.js → chunk-IUVJVMKS.js} +11 -11
  114. package/dist/{chunk-ZKJ5L35C.js → chunk-IVQT2E3Y.js} +28 -17
  115. package/dist/{chunk-7DAH2E4T.js → chunk-IW3YUMPI.js} +2 -2
  116. package/dist/chunk-IXM6BAM4.js +53 -0
  117. package/dist/{chunk-YMTXTQCN.js → chunk-IZRTNCJQ.js} +5 -5
  118. package/dist/{chunk-QGFKSDQO.js → chunk-J22ETKDJ.js} +2 -2
  119. package/dist/{chunk-HJRNBKIT.js → chunk-JARJP576.js} +3 -3
  120. package/dist/{chunk-DD6RVD3S.js → chunk-JHWDTV4K.js} +5 -1
  121. package/dist/{chunk-P4SMC4BY.js → chunk-JIH52I36.js} +79 -79
  122. package/dist/{chunk-KQCKK3LD.js → chunk-JKXJWCJ5.js} +69 -34
  123. package/dist/{chunk-WI5VOSQX.js → chunk-JMOBA5ES.js} +2 -2
  124. package/dist/{chunk-AGDDH6XY.js → chunk-JMXNXLAC.js} +5 -1
  125. package/dist/{chunk-R2IKOLBK.js → chunk-JRRSKCGG.js} +3 -3
  126. package/dist/{chunk-IVRYF7QA.js → chunk-JSA3ESEJ.js} +1 -1
  127. package/dist/{chunk-WBETBGSC.js → chunk-K6Y4HBK7.js} +31 -31
  128. package/dist/{chunk-Z55DXFWS.js → chunk-KAAB2DIV.js} +23 -13
  129. package/dist/{chunk-UZLR25BW.js → chunk-KF3ZHLHQ.js} +7 -8
  130. package/dist/{chunk-GELSK76Y.js → chunk-KGS5Z7SL.js} +3 -3
  131. package/dist/{chunk-E2ZUBP4Q.js → chunk-KIXNHDXS.js} +7 -8
  132. package/dist/{chunk-7VMEM3LN.js → chunk-KJLH5EHD.js} +26 -26
  133. package/dist/{chunk-KLIZXSBK.js → chunk-KLQKHA3T.js} +6 -6
  134. package/dist/chunk-KQ2WZ6BY.js +11 -0
  135. package/dist/{chunk-DF3XEFQ7.js → chunk-KUMJI5B6.js} +10 -10
  136. package/dist/{chunk-SE7MJ2LQ.js → chunk-L2XRUG4P.js} +7 -8
  137. package/dist/{chunk-JYBT2JNY.js → chunk-LE3LSEUL.js} +27 -2
  138. package/dist/{chunk-75WIUG2W.js → chunk-LFX5BERN.js} +140 -60
  139. package/dist/{chunk-MJPXHCBW.js → chunk-LGMV7ZV4.js} +4 -4
  140. package/dist/{chunk-3V62N3Z7.js → chunk-LO3AGGE3.js} +7 -8
  141. package/dist/{chunk-7KSUMFBK.js → chunk-LSKCKGCF.js} +5 -1
  142. package/dist/{chunk-NHC2ADGI.js → chunk-LSR3SBJ4.js} +45 -34
  143. package/dist/{chunk-V634AXDM.js → chunk-LUZ7HXBT.js} +1 -1
  144. package/dist/{chunk-5PPQIF4D.js → chunk-LW4ZQGVL.js} +2 -2
  145. package/dist/{chunk-H3IBJQ5A.js → chunk-M2OQK2FO.js} +1 -1
  146. package/dist/{chunk-4LTN7SND.js → chunk-M74H7QYD.js} +1 -1
  147. package/dist/{chunk-TXBO2LWM.js → chunk-MOQFYJ3F.js} +6 -6
  148. package/dist/{chunk-VPL3JYC6.js → chunk-MQ5EKWIG.js} +51 -9
  149. package/dist/{chunk-X3KCQEYZ.js → chunk-MTCDGSYW.js} +9 -1
  150. package/dist/{chunk-FCECYJVA.js → chunk-NCCDEUHD.js} +1 -1
  151. package/dist/{chunk-IGVAWAOK.js → chunk-NIDH22DI.js} +31 -7
  152. package/dist/{chunk-5DTCOOLU.js → chunk-NINK4G7U.js} +2 -2
  153. package/dist/{chunk-HHXIVFAU.js → chunk-NO7GRVUU.js} +10 -8
  154. package/dist/{chunk-X23SZHV5.js → chunk-NRYERHEI.js} +6 -6
  155. package/dist/{chunk-V5JQQMFQ.js → chunk-O4D27FKH.js} +1 -1
  156. package/dist/{chunk-I7H5DU34.js → chunk-O7Y6RJ4D.js} +21 -9
  157. package/dist/{chunk-2NN676RI.js → chunk-OAT6FWKL.js} +7 -8
  158. package/dist/{chunk-JHWYG7V5.js → chunk-OF7FMGH5.js} +6 -6
  159. package/dist/{chunk-GLQ3KCTY.js → chunk-OKM5LYYP.js} +7 -8
  160. package/dist/{chunk-JCIXYOND.js → chunk-OTGNVAI4.js} +2 -2
  161. package/dist/{chunk-EIL3KHAL.js → chunk-PSYPB22T.js} +3 -3
  162. package/dist/{chunk-JXBZIJCG.js → chunk-PYGEIPPH.js} +1 -1
  163. package/dist/{chunk-KZJ5VM6E.js → chunk-PZ3TQFSY.js} +15 -1
  164. package/dist/{chunk-K3VZ5QJK.js → chunk-Q7VPTN5X.js} +4 -4
  165. package/dist/{chunk-ZVM5TFGR.js → chunk-QFIRPOXR.js} +6 -2
  166. package/dist/{chunk-YHD2FZFP.js → chunk-QHPJ5ZKS.js} +6 -6
  167. package/dist/{chunk-QLANK3VN.js → chunk-QLWUFEKR.js} +6 -6
  168. package/dist/{chunk-64LJDGJH.js → chunk-QNLESRH6.js} +3 -1
  169. package/dist/{chunk-RJGCYGC3.js → chunk-QRZESG66.js} +38 -27
  170. package/dist/{chunk-76Q7E3TM.js → chunk-QYOZ46ZQ.js} +70 -23
  171. package/dist/{chunk-E555EDOQ.js → chunk-QZMLSK43.js} +221 -62
  172. package/dist/{chunk-NGA7ICG4.js → chunk-RDJ3ZU6O.js} +16 -13
  173. package/dist/{chunk-6MJUW5R5.js → chunk-RHBQ2Q5H.js} +95 -44
  174. package/dist/{chunk-ZYQYX66L.js → chunk-RHVP62HI.js} +6 -6
  175. package/dist/{chunk-F5BYLT3M.js → chunk-RMVCKO6N.js} +13 -11
  176. package/dist/chunk-RRPTQGRU.js +47 -0
  177. package/dist/{chunk-IRXVV65V.js → chunk-S2TSXUYP.js} +6 -6
  178. package/dist/{chunk-OG2YUVBW.js → chunk-SD6ENKTO.js} +7 -2
  179. package/dist/{chunk-6AMN7IKJ.js → chunk-SHAAMKN7.js} +43 -22
  180. package/dist/{chunk-DLUNQHFO.js → chunk-SHCW2TCA.js} +9 -9
  181. package/dist/{chunk-54ROMBU7.js → chunk-SSZB3VXG.js} +17 -17
  182. package/dist/chunk-SXAZDIGM.js +84 -0
  183. package/dist/{chunk-QHRE2M6V.js → chunk-T2L5H2WW.js} +4 -3
  184. package/dist/{chunk-RPIKNMZA.js → chunk-T3WCDDIL.js} +7 -2
  185. package/dist/{chunk-JIEVDGAF.js → chunk-T5MBORBK.js} +1 -1
  186. package/dist/{chunk-32LLDRPI.js → chunk-TDDSWNGD.js} +23 -15
  187. package/dist/{chunk-7VVHTOE7.js → chunk-TGR6PRKG.js} +2 -2
  188. package/dist/{chunk-QJWLNP64.js → chunk-TKERVBJ3.js} +7 -8
  189. package/dist/{chunk-43GGVT7W.js → chunk-TMXRTYGT.js} +10 -4
  190. package/dist/{chunk-BIVL764T.js → chunk-TQ5HHNM3.js} +2 -2
  191. package/dist/{chunk-WN3HEU3P.js → chunk-TWRFVW3J.js} +4 -2
  192. package/dist/{chunk-7FKY6YWU.js → chunk-TXMS7QUJ.js} +3 -3
  193. package/dist/{chunk-O6ZTIDWB.js → chunk-UBXIGE2P.js} +3 -2
  194. package/dist/{chunk-JTC5SEAQ.js → chunk-UCIAHSJK.js} +2 -2
  195. package/dist/{chunk-BVYIKLQ5.js → chunk-UD6U4EF5.js} +1 -1
  196. package/dist/{chunk-DMAMWUYY.js → chunk-UFZXZJJG.js} +5 -5
  197. package/dist/{chunk-SNQ7D5R7.js → chunk-UIHGGWES.js} +51 -11
  198. package/dist/{chunk-27OIGDRK.js → chunk-UP4JSNDR.js} +1 -1
  199. package/dist/{chunk-JEUL777U.js → chunk-USFIDSTO.js} +7 -5
  200. package/dist/{chunk-PZ46S2SY.js → chunk-V3UE3TB7.js} +2 -2
  201. package/dist/{chunk-KDSYZLF6.js → chunk-V5IFI3FV.js} +8 -1
  202. package/dist/{chunk-BSATR6ZO.js → chunk-V62B23VC.js} +13 -1
  203. package/dist/{chunk-WWGPTEQB.js → chunk-VFLMBA2M.js} +66 -16
  204. package/dist/{chunk-5P2TTHBZ.js → chunk-VM5CQ7CG.js} +2 -2
  205. package/dist/{chunk-UREXN6WG.js → chunk-VMGTNB6H.js} +6 -6
  206. package/dist/{chunk-2NSQIPAA.js → chunk-VT7PBGL2.js} +6 -6
  207. package/dist/{chunk-CXETOLPX.js → chunk-VY2NPB2Q.js} +1 -1
  208. package/dist/{chunk-F77TMAUY.js → chunk-VY67Q6CJ.js} +18 -18
  209. package/dist/{chunk-7STMIK2X.js → chunk-W5SVS4B6.js} +2 -2
  210. package/dist/{chunk-MD6DCQMA.js → chunk-W7Q6PLT4.js} +37 -37
  211. package/dist/{chunk-JVZTKQFS.js → chunk-WDAZ2MT4.js} +8 -4
  212. package/dist/{chunk-MZACASZY.js → chunk-WE5WVQE4.js} +13 -1
  213. package/dist/chunk-WJQX7HBH.js +54 -0
  214. package/dist/{chunk-MS7O3KDJ.js → chunk-WKWCNS6K.js} +6 -6
  215. package/dist/{chunk-4KQHKPB3.js → chunk-WSKZZ2ZB.js} +11 -12
  216. package/dist/{chunk-SMHZXHHD.js → chunk-WZB6R2ZX.js} +6 -4
  217. package/dist/{chunk-37PKNVLS.js → chunk-X5OVVMZX.js} +1 -1
  218. package/dist/{chunk-MPO5TVGF.js → chunk-XFCBH3TI.js} +3 -3
  219. package/dist/{chunk-CAJ54IEP.js → chunk-XJUZC53Y.js} +1 -1
  220. package/dist/chunk-XN7JDII2.js +2047 -0
  221. package/dist/{chunk-4KMZAK6J.js → chunk-XNV7VOIT.js} +4 -4
  222. package/dist/{chunk-YK2KWNTU.js → chunk-XR7VOF2V.js} +9 -7
  223. package/dist/{chunk-WTQAG2OT.js → chunk-XYUXB5VK.js} +8 -3
  224. package/dist/{chunk-QB5HV4IY.js → chunk-Y5IKCXQR.js} +7 -8
  225. package/dist/{chunk-FNMH5WEY.js → chunk-Y5WHM2Q5.js} +1 -1
  226. package/dist/{chunk-IGNBQT23.js → chunk-Y7Q3VEYC.js} +96 -5
  227. package/dist/{chunk-L6YVK6VC.js → chunk-YB6QGOCO.js} +1 -1
  228. package/dist/{chunk-BYCJ6TKI.js → chunk-YBYV56FS.js} +3 -3
  229. package/dist/{chunk-DLDDRXAI.js → chunk-YCUNFAEE.js} +77 -37
  230. package/dist/{chunk-V7F4F6JA.js → chunk-YFI5PN5O.js} +5 -7
  231. package/dist/{chunk-ZL6IHMOW.js → chunk-YGPLUENN.js} +88 -58
  232. package/dist/chunk-YGZEG3JV.js +123 -0
  233. package/dist/{chunk-JGFHNAHS.js → chunk-YJGFT63R.js} +8 -3
  234. package/dist/{chunk-XQMYQ4TN.js → chunk-YNHPPZ7S.js} +1 -1
  235. package/dist/{chunk-EZZ533MH.js → chunk-YO5UKKCQ.js} +1 -1
  236. package/dist/{chunk-YZZLIYPA.js → chunk-YTEJYLU7.js} +5 -1
  237. package/dist/{chunk-CCJP6QZO.js → chunk-Z257SH5U.js} +1 -1
  238. package/dist/{chunk-ETMHDCEH.js → chunk-Z2BDTZDT.js} +13 -11
  239. package/dist/{chunk-MOK3ZS6P.js → chunk-ZDD3MJ2H.js} +1 -1
  240. package/dist/{chunk-6364WO5D.js → chunk-ZNX5J7D7.js} +2 -2
  241. package/dist/{chunk-UZTQUPTB.js → chunk-ZSYU6LIH.js} +4 -4
  242. package/dist/{chunk-JFFREZGT.js → chunk-ZTSJ7NY6.js} +6 -2
  243. package/dist/chunk-ZV3SNRJI.js +122 -0
  244. package/dist/cli/index.js +1 -1
  245. package/dist/{core-MU4ALRR7.js → core-4M4RY7MX.js} +4 -1
  246. package/dist/{core-XW7UJFJZ.js → core-4PW4MXWR.js} +4 -1
  247. package/dist/{core-LB5M7XL4.js → core-5S5CJHBG.js} +5 -1
  248. package/dist/{core-LGJZUP6H.js → core-7TTM4KRP.js} +6 -1
  249. package/dist/{core-GSILPKUR.js → core-7XKNJM7Y.js} +4 -1
  250. package/dist/{core-JDFUZFRH.js → core-A7HXVSKB.js} +5 -1
  251. package/dist/{core-K3JX5WPM.js → core-AMWCZTOT.js} +2 -1
  252. package/dist/{core-BLHEJ5OK.js → core-AVA4XLQ2.js} +4 -1
  253. package/dist/{core-ILPXXC2Z.js → core-BJZEJ63L.js} +5 -1
  254. package/dist/{core-3KLQSYWB.js → core-CCB3IXGD.js} +4 -1
  255. package/dist/{core-BBNY2BX4.js → core-D2OIGYC7.js} +2 -1
  256. package/dist/{core-4RR6VSXM.js → core-DMDAXVMY.js} +3 -1
  257. package/dist/{core-HDNWVLJW.js → core-EMSJRGSE.js} +4 -1
  258. package/dist/{core-A5AKUB7H.js → core-FCSA74RT.js} +2 -1
  259. package/dist/{core-WZ4CHVYL.js → core-FTQBESDS.js} +3 -1
  260. package/dist/{core-G3LXHW73.js → core-GS4DXDDG.js} +4 -1
  261. package/dist/{core-H5HO2CED.js → core-JDZDBTID.js} +2 -1
  262. package/dist/{core-VKZSQFRG.js → core-L3UR75IJ.js} +2 -1
  263. package/dist/{core-AR2T32Y3.js → core-MAW4S3KA.js} +4 -1
  264. package/dist/{core-4HFVG4CP.js → core-N2JEWJ7D.js} +3 -1
  265. package/dist/{core-BOG33BFD.js → core-OBPTBKX6.js} +4 -1
  266. package/dist/{core-HTD5RHE7.js → core-OFPPRHYY.js} +5 -1
  267. package/dist/{core-ZLSQHZ3I.js → core-QFAVWFI3.js} +4 -1
  268. package/dist/{core-TCSW24N6.js → core-QM34237W.js} +4 -1
  269. package/dist/{core-WJNK7F2J.js → core-SKMHEA4Y.js} +5 -1
  270. package/dist/{core-7S3XMW5O.js → core-T3OSZOVV.js} +2 -1
  271. package/dist/{core-7Y5BZZON.js → core-UNX4ZV4M.js} +4 -1
  272. package/dist/{core-DFZMOO7E.js → core-VRVL6LIM.js} +5 -1
  273. package/dist/{core-J2JD5ODO.js → core-VT35VDVS.js} +4 -1
  274. package/dist/{core-TKZZZ6UW.js → core-VWYXK2R3.js} +4 -1
  275. package/dist/{core-E2XOSHPR.js → core-WNT6ZMRO.js} +5 -1
  276. package/dist/{core-RR2CAZC5.js → core-WP73P4CW.js} +4 -1
  277. package/dist/{core-DD62MWEW.js → core-WPEYRK6Y.js} +2 -1
  278. package/dist/{core-YMXYUGF5.js → core-WXZJ7V7S.js} +2 -1
  279. package/dist/{core-5UF44NDI.js → core-XKXDXALI.js} +3 -1
  280. package/dist/{core-GLOZY6Z7.js → core-ZACFV6XR.js} +2 -1
  281. package/dist/{core-QPSAYRFT.js → core-ZSERZGK6.js} +5 -1
  282. package/dist/{dataTable-CNDRVGA5.js → dataTable-7IO546LM.js} +10 -2
  283. package/dist/{engine-FVEIM3WV.js → engine-US3N6UCH.js} +17 -9
  284. package/dist/fixtures.js +3 -1
  285. package/dist/fonts.js +1 -1
  286. package/dist/geo/dach.js +1 -1
  287. package/dist/geo/de-states.js +1 -1
  288. package/dist/geo/eu27.js +1 -1
  289. package/dist/geo/europe.js +1 -1
  290. package/dist/geo/index.js +2 -2
  291. package/dist/geo/us-states.js +1 -1
  292. package/dist/geo/world.js +1 -1
  293. package/dist/index.js +31 -19
  294. package/dist/{main-THU6VIVU.js → main-2UWKGUHR.js} +27 -13
  295. package/dist/mcp/server.js +23 -13
  296. package/dist/react/bar.js +6 -1
  297. package/dist/react/bartable.js +8 -1
  298. package/dist/react/box.js +6 -1
  299. package/dist/react/bullet.js +7 -1
  300. package/dist/react/butterfly.js +6 -1
  301. package/dist/react/choropleth.js +8 -1
  302. package/dist/react/cohort.js +9 -1
  303. package/dist/react/column.js +6 -1
  304. package/dist/react/combo.js +6 -1
  305. package/dist/react/creative.js +8 -1
  306. package/dist/react/diagram.js +8 -1
  307. package/dist/react/dimswitch.js +6 -1
  308. package/dist/react/dot.js +6 -1
  309. package/dist/react/export.js +25 -18
  310. package/dist/react/funnel.js +6 -1
  311. package/dist/react/gantt.js +7 -1
  312. package/dist/react/grid.js +5 -1
  313. package/dist/react/heatmap.js +7 -1
  314. package/dist/react/histogram.js +6 -1
  315. package/dist/react/index.js +93 -84
  316. package/dist/react/kpi.js +7 -1
  317. package/dist/react/likert.js +6 -1
  318. package/dist/react/line.js +6 -1
  319. package/dist/react/mekko.js +6 -1
  320. package/dist/react/pareto.js +6 -1
  321. package/dist/react/pie.js +6 -1
  322. package/dist/react/prepare.js +35 -20
  323. package/dist/react/pvm.js +7 -1
  324. package/dist/react/pyramid.js +6 -1
  325. package/dist/react/sankey.js +8 -1
  326. package/dist/react/scatter.js +6 -1
  327. package/dist/react/slope.js +7 -1
  328. package/dist/react/sparkline.js +7 -1
  329. package/dist/react/spec.js +17 -11
  330. package/dist/react/status.js +7 -1
  331. package/dist/react/story.js +4 -2
  332. package/dist/react/table.js +6 -1
  333. package/dist/react/theme.js +8 -3
  334. package/dist/react/tilemap.js +7 -1
  335. package/dist/react/treemap.js +7 -1
  336. package/dist/react/variance.js +6 -1
  337. package/dist/react/waffle.js +7 -1
  338. package/dist/react/waterfall.js +7 -1
  339. package/dist/rows.js +3 -2
  340. package/dist/{rowsModule-LI6KOS46.js → rowsModule-DYDVHBAX.js} +2 -1
  341. package/dist/{schema-ZQSIR5UC.js → schema-3KMU5737.js} +1 -1
  342. package/dist/{schema-YLE4XXQQ.js → schema-4JRNXEZF.js} +3 -1
  343. package/dist/{schema-KPEPBGAX.js → schema-626QXX4G.js} +3 -1
  344. package/dist/{schema-72EEMYS3.js → schema-6PL46VXZ.js} +3 -1
  345. package/dist/{schema-JH57NFXJ.js → schema-6V5K3J2V.js} +4 -1
  346. package/dist/{schema-H2EC4GAQ.js → schema-A2XUZUCV.js} +3 -1
  347. package/dist/{schema-QPOBZUAR.js → schema-CNJ4Y6CT.js} +3 -1
  348. package/dist/{schema-5KDEQBBT.js → schema-DHMMGDTI.js} +3 -1
  349. package/dist/{schema-BKUFZLLI.js → schema-F2Q6MH7W.js} +3 -1
  350. package/dist/{schema-PL3EU6EQ.js → schema-FC6J6KZC.js} +5 -1
  351. package/dist/{schema-AXRDF6ND.js → schema-FGE5YK3S.js} +3 -1
  352. package/dist/{schema-5DUTAVO7.js → schema-FSYDLMGD.js} +1 -1
  353. package/dist/{schema-PQZWO3BP.js → schema-G5KSSI5W.js} +1 -1
  354. package/dist/{schema-25INXAMY.js → schema-GXOG4MXL.js} +1 -1
  355. package/dist/{schema-AMT7P7KB.js → schema-HEB6ZDI5.js} +3 -1
  356. package/dist/{schema-HH5HOORE.js → schema-I44IDRGD.js} +1 -1
  357. package/dist/{schema-VYECMPON.js → schema-IFTIMTS3.js} +1 -1
  358. package/dist/{schema-QCIE6M2P.js → schema-IUY7VYHJ.js} +3 -1
  359. package/dist/{schema-M5JBHQIV.js → schema-J4HCSD5C.js} +5 -2
  360. package/dist/{schema-B2GCEYXD.js → schema-JCU6LTYD.js} +1 -1
  361. package/dist/{schema-FDFQKIO5.js → schema-JJWORI7D.js} +3 -1
  362. package/dist/{schema-GNTKL5DN.js → schema-K4V4PYBO.js} +3 -1
  363. package/dist/{schema-L5U4OROI.js → schema-LGLQBRC4.js} +3 -1
  364. package/dist/{schema-THXXFY6I.js → schema-MD22QYZU.js} +1 -1
  365. package/dist/{schema-7NSV542V.js → schema-MGETMQYC.js} +3 -1
  366. package/dist/{schema-ZG6ZKFRZ.js → schema-MQB6CE5V.js} +3 -1
  367. package/dist/{schema-OU35XA3Z.js → schema-NMIYKGHE.js} +3 -1
  368. package/dist/{schema-5ZTGVQAJ.js → schema-NOBNFD2F.js} +3 -1
  369. package/dist/{schema-MMVPMJEF.js → schema-OXO2XY4Y.js} +1 -1
  370. package/dist/{schema-LOQ3AFC7.js → schema-PHIHMDVB.js} +1 -1
  371. package/dist/{schema-ZEVJMFLV.js → schema-UXWKA3PI.js} +3 -1
  372. package/dist/{schema-GN6GAIU5.js → schema-WBOPCTPC.js} +1 -1
  373. package/dist/{schema-BBTXTWYI.js → schema-WFGDVBJK.js} +1 -1
  374. package/dist/{schema-J7TNCZIP.js → schema-WX2RS4OU.js} +3 -1
  375. package/dist/{schema-QORUB6EK.js → schema-XIHAKX3B.js} +18 -1
  376. package/dist/{schema-R5Y6NVBH.js → schema-XRSORYBI.js} +3 -1
  377. package/dist/{schema-CGQID64D.js → schema-YDZCGL56.js} +3 -1
  378. package/dist/{specValidation-VHLGDEME.js → specValidation-XGELWQUU.js} +2 -1
  379. package/dist/theme.js +5 -1
  380. package/dist/types/core/charts/bartable/types.d.ts +14 -1
  381. package/dist/types/core/charts/box/types.d.ts +3 -1
  382. package/dist/types/core/charts/choropleth/layout.d.ts +1 -5
  383. package/dist/types/core/charts/choropleth/types.d.ts +19 -0
  384. package/dist/types/core/charts/cohort/types.d.ts +16 -3
  385. package/dist/types/core/charts/creative/types.d.ts +21 -0
  386. package/dist/types/core/charts/dimswitch/compile.d.ts +15 -2
  387. package/dist/types/core/charts/dimswitch/types.d.ts +24 -1
  388. package/dist/types/core/charts/gantt/calendar.d.ts +20 -0
  389. package/dist/types/core/charts/gantt/columns.d.ts +56 -0
  390. package/dist/types/core/charts/gantt/layout.d.ts +8 -2
  391. package/dist/types/core/charts/gantt/model.d.ts +296 -0
  392. package/dist/types/core/charts/grid/metricStack.d.ts +9 -0
  393. package/dist/types/core/charts/grid/metricStackSchema.d.ts +13 -0
  394. package/dist/types/core/charts/histogram/types.d.ts +8 -0
  395. package/dist/types/core/charts/likert/layout.d.ts +10 -8
  396. package/dist/types/core/charts/pvm/types.d.ts +9 -1
  397. package/dist/types/core/charts/pyramid/types.d.ts +3 -1
  398. package/dist/types/core/charts/sankey/types.d.ts +5 -1
  399. package/dist/types/core/charts/status/layout.d.ts +3 -0
  400. package/dist/types/core/charts/table/resolve.d.ts +14 -0
  401. package/dist/types/core/footer.d.ts +2 -0
  402. package/dist/types/core/formatSpec.d.ts +10 -0
  403. package/dist/types/core/frame.d.ts +1 -1
  404. package/dist/types/core/geo/types.d.ts +2 -0
  405. package/dist/types/core/geometry.d.ts +1 -1
  406. package/dist/types/core/normalize/shared.d.ts +2 -0
  407. package/dist/types/core/registry.d.ts +4 -5
  408. package/dist/types/core/request.d.ts +6 -0
  409. package/dist/types/core/schema/capability.d.ts +20 -7
  410. package/dist/types/core/schema/generatedColumns.d.ts +168 -0
  411. package/dist/types/core/text.d.ts +16 -0
  412. package/dist/types/core/themeGeometry.d.ts +9 -0
  413. package/dist/types/core/timeAxis.d.ts +6 -1
  414. package/dist/types/core/types/diagram.d.ts +7 -0
  415. package/dist/types/core/types/options.d.ts +83 -12
  416. package/dist/types/core/types/table.d.ts +21 -3
  417. package/dist/types/index.d.ts +2 -0
  418. package/dist/types/react/barrelCharts.d.ts +16 -5
  419. package/dist/types/react/charts/butterfly.d.ts +2 -2
  420. package/dist/types/react/charts/dot.d.ts +7 -1
  421. package/dist/types/react/charts/pareto.d.ts +4 -1
  422. package/dist/types/react/charts/variance.d.ts +3 -1
  423. package/dist/types/react/hover/labelCard.d.ts +11 -2
  424. package/dist/types/react/prepare.d.ts +7 -1
  425. package/dist/types/theme.d.ts +2 -0
  426. package/dist/validate.js +15 -5
  427. package/docs/manual.md +31 -3
  428. package/docs/reference/bar.md +3 -0
  429. package/docs/reference/bartable.md +16 -1
  430. package/docs/reference/box.md +8 -1
  431. package/docs/reference/bullet.md +12 -1
  432. package/docs/reference/butterfly.md +7 -1
  433. package/docs/reference/choropleth.md +14 -1
  434. package/docs/reference/cohort.md +25 -5
  435. package/docs/reference/column.md +1 -0
  436. package/docs/reference/combo.md +1 -0
  437. package/docs/reference/creative.md +13 -0
  438. package/docs/reference/diagram.md +5 -0
  439. package/docs/reference/dimswitch.md +50 -32
  440. package/docs/reference/dot.md +7 -2
  441. package/docs/reference/fixtures.md +57 -0
  442. package/docs/reference/funnel.md +5 -0
  443. package/docs/reference/gantt.md +10 -2
  444. package/docs/reference/grid.md +9 -2
  445. package/docs/reference/heatmap.md +6 -0
  446. package/docs/reference/histogram.md +2 -2
  447. package/docs/reference/kpi.md +5 -1
  448. package/docs/reference/likert.md +8 -0
  449. package/docs/reference/options.md +4 -3
  450. package/docs/reference/pareto.md +1 -1
  451. package/docs/reference/pvm.md +7 -1
  452. package/docs/reference/pyramid.md +6 -0
  453. package/docs/reference/react.md +1 -2
  454. package/docs/reference/sankey.md +6 -2
  455. package/docs/reference/slope.md +6 -0
  456. package/docs/reference/sparkline.md +1 -1
  457. package/docs/reference/status.md +7 -1
  458. package/docs/reference/table.md +16 -4
  459. package/docs/reference/tilemap.md +1 -1
  460. package/docs/reference/treemap.md +1 -1
  461. package/docs/reference/waffle.md +1 -1
  462. package/docs/reference/waterfall.md +4 -1
  463. package/package.json +1 -1
  464. package/dist/chunk-FG5L2LUK.js +0 -89
  465. package/dist/chunk-IFQN4GKK.js +0 -1852
  466. package/dist/chunk-O36WX56O.js +0 -13
  467. package/dist/chunk-WIVFIVFZ.js +0 -27
  468. package/dist/chunk-ZWNRLIFT.js +0 -24
@@ -28,7 +28,7 @@ import {
28
28
  collapsedHintWidth,
29
29
  columnTracks,
30
30
  encodingReserve,
31
- frameFillExtras,
31
+ frameFillAmounts,
32
32
  groupHeadingFaces,
33
33
  groupHeadingFloors,
34
34
  groupHeadingNeed,
@@ -44,13 +44,13 @@ import {
44
44
  strongColumnFont,
45
45
  tableFonts,
46
46
  wrapFloorWidth
47
- } from "./chunk-2YO4WRJN.js";
47
+ } from "./chunk-HVX2E26J.js";
48
48
  import {
49
49
  toneTextPaint
50
- } from "./chunk-BVYIKLQ5.js";
50
+ } from "./chunk-UD6U4EF5.js";
51
51
  import {
52
52
  fieldHeadText
53
- } from "./chunk-SPSGUFTI.js";
53
+ } from "./chunk-I4NUYVP5.js";
54
54
  import {
55
55
  operatorWidth,
56
56
  qualifierFont
@@ -58,19 +58,19 @@ import {
58
58
  import {
59
59
  bandFor
60
60
  } from "./chunk-263SZKIL.js";
61
- import {
62
- emptyIdRecord
63
- } from "./chunk-LINZPU5D.js";
64
61
  import {
65
62
  closestKey
66
- } from "./chunk-BSATR6ZO.js";
63
+ } from "./chunk-V62B23VC.js";
67
64
  import {
68
65
  caseInsensitiveValue,
69
66
  chartSizing,
67
+ copyPlannedValue,
70
68
  fitsSize,
71
69
  inputConversion,
70
+ memoExactInputKey,
71
+ ownPlanInput,
72
72
  resolveSizing
73
- } from "./chunk-T2CYNDYU.js";
73
+ } from "./chunk-AFGQXMKT.js";
74
74
  import {
75
75
  clamp,
76
76
  cleanDiff,
@@ -80,17 +80,23 @@ import {
80
80
  numericVariant,
81
81
  readDateFormat,
82
82
  unitPrinted
83
- } from "./chunk-4KQHKPB3.js";
83
+ } from "./chunk-WSKZZ2ZB.js";
84
84
  import {
85
85
  disclosureNote,
86
86
  disclosuresShown,
87
87
  footerType
88
- } from "./chunk-SMHZXHHD.js";
88
+ } from "./chunk-WZB6R2ZX.js";
89
+ import {
90
+ emptyIdRecord
91
+ } from "./chunk-LINZPU5D.js";
89
92
  import {
90
93
  AUTOMATIC_FORMAT,
94
+ LABEL_ONLY_ROW,
91
95
  MAGNITUDE_DIVISOR,
96
+ MAGNITUDE_FIGURES,
92
97
  MAGNITUDE_GROUP,
93
98
  MAGNITUDE_LABEL,
99
+ compileNumberFormat,
94
100
  differenceExample,
95
101
  effectiveScale,
96
102
  formatWithSpec,
@@ -102,11 +108,12 @@ import {
102
108
  specUnitKind,
103
109
  unitOfSpec,
104
110
  withChartMarks
105
- } from "./chunk-FFJGC2DX.js";
111
+ } from "./chunk-D3PQAVFW.js";
106
112
  import {
107
113
  MINUS,
108
114
  chartNumberMarks,
109
115
  currencyWholeNumbers,
116
+ currentSmallValues,
110
117
  formatExactNumber,
111
118
  intervalText,
112
119
  localeStrings,
@@ -130,7 +137,7 @@ import {
130
137
  tableEmphasis,
131
138
  tableHeadFloorPx,
132
139
  textScaleOf
133
- } from "./chunk-HJRNBKIT.js";
140
+ } from "./chunk-JARJP576.js";
134
141
  import {
135
142
  DEFAULT_TARGET,
136
143
  NormalizeError,
@@ -141,15 +148,15 @@ import {
141
148
  resolveSubtitle,
142
149
  scaleTextPx,
143
150
  targetFloorsPx
144
- } from "./chunk-YOOHNQ3L.js";
151
+ } from "./chunk-FX5VZK5F.js";
145
152
  import {
146
153
  maxOf,
147
154
  minOf,
148
155
  pushAll
149
156
  } from "./chunk-WYJEOMNY.js";
150
157
  import {
151
- twoLineWidth
152
- } from "./chunk-SNQ7D5R7.js";
158
+ lineBlockWidth
159
+ } from "./chunk-UIHGGWES.js";
153
160
 
154
161
  // src/core/charts/table/ladder.ts
155
162
  var COHORT_GRID = {
@@ -680,11 +687,130 @@ function columnHeaderAffix(column) {
680
687
  let affix = [column.scenario, column.unitLabel].filter(Boolean).join(", ");
681
688
  return `${affix ? ` (${affix})` : ""}${column.partial ? ` ${PARTIAL_MARKER}` : ""}`;
682
689
  }
690
+ var preparedData = /* @__PURE__ */ new WeakMap(), sharedPreparedData = /* @__PURE__ */ new Map(), MAX_SHARED_KEY_CHARS = 128 * 1024, MAX_SHARED_TOTAL_CHARS = 2 * 1024 * 1024, sharedKeyChars = 0, modelSymbols = new Map([AUTOMATIC_FORMAT, MAGNITUDE_GROUP, MAGNITUDE_FIGURES, ZERO_LIFT, LABEL_ONLY_ROW].map((symbol, index) => [symbol, index]));
691
+ function modelContentKey(value) {
692
+ let parts = [], seen = /* @__PURE__ */ new Map(), active = /* @__PURE__ */ new Set(), supported = !0, write = (value2) => {
693
+ if (!supported) return;
694
+ if (value2 === null) {
695
+ parts.push("null;");
696
+ return;
697
+ }
698
+ switch (typeof value2) {
699
+ case "undefined":
700
+ parts.push("undefined;");
701
+ return;
702
+ case "string":
703
+ parts.push("s", JSON.stringify(value2));
704
+ return;
705
+ case "boolean":
706
+ parts.push(value2 ? "true;" : "false;");
707
+ return;
708
+ case "number":
709
+ parts.push("n", Object.is(value2, -0) ? "-0" : String(value2), ";");
710
+ return;
711
+ case "object":
712
+ break;
713
+ default:
714
+ supported = !1;
715
+ return;
716
+ }
717
+ let prototype = Object.getPrototypeOf(value2), array = Array.isArray(value2);
718
+ if (!array && prototype !== Object.prototype && prototype !== null) {
719
+ supported = !1;
720
+ return;
721
+ }
722
+ let known = seen.get(value2);
723
+ if (known !== void 0) {
724
+ if (active.has(value2)) {
725
+ supported = !1;
726
+ return;
727
+ }
728
+ parts.push("ref", String(known), ";");
729
+ return;
730
+ }
731
+ seen.set(value2, seen.size), active.add(value2), parts.push(array ? `array${value2.length}{` : prototype === null ? "record{" : "object{");
732
+ for (let key of Reflect.ownKeys(value2)) {
733
+ if (array && key === "length") continue;
734
+ if (!("value" in Object.getOwnPropertyDescriptor(value2, key))) {
735
+ supported = !1;
736
+ return;
737
+ }
738
+ if (typeof key == "symbol") {
739
+ let index = modelSymbols.get(key);
740
+ if (index === void 0) {
741
+ supported = !1;
742
+ return;
743
+ }
744
+ parts.push("symbol", String(index), ":");
745
+ } else parts.push("key", JSON.stringify(key), ":");
746
+ write(Reflect.get(value2, key));
747
+ }
748
+ parts.push("}"), active.delete(value2);
749
+ };
750
+ return write(value), supported ? parts.join("") : void 0;
751
+ }
752
+ function prepareTableData(data, options = {}, magnitudeSource = data) {
753
+ return withSmallValues(options.smallValues, () => {
754
+ let theme = resolveTheme(options.theme), semantic = {
755
+ locale: options.locale,
756
+ strings: options.strings,
757
+ variant: options.variant,
758
+ density: isCohortDensity(options.density ?? "regular"),
759
+ nulls: options.nulls,
760
+ levelOffset: options.levelOffset,
761
+ columnHeads: options.columnHeads,
762
+ disclosures: disclosuresShown(options),
763
+ highlight: options.highlight,
764
+ sort: options.sort,
765
+ topN: options.topN,
766
+ format: options.format,
767
+ unit: options.unit,
768
+ magnitude: options.magnitude,
769
+ target: options.target,
770
+ subtitle: options.subtitle,
771
+ unitShown: options.unitShown,
772
+ encodings: options.encodings,
773
+ signs: options.signs,
774
+ driverTones: options.driverTones,
775
+ judgements: options.judgements,
776
+ totalPosition: options.totalPosition,
777
+ colorblindSafe: options.colorblindSafe,
778
+ theme: { glyphs: theme.table?.glyphs, noPrevious: theme.table?.noPrevious, dataGap: theme.table?.dataGap },
779
+ // Top-N ranks the complete formatted table before folding it. Its inner resolution must retain the current precision.
780
+ ...options.topN ? { columnVisibility: options.columnVisibility, [ZERO_LIFT]: options[ZERO_LIFT] } : {}
781
+ }, dataContent = memoExactInputKey(data, modelContentKey), magnitudeContent = magnitudeSource === data ? "same;" : memoExactInputKey(magnitudeSource, modelContentKey), semanticContent = modelContentKey([semantic, currentSmallValues()]), content = dataContent === void 0 || magnitudeContent === void 0 || semanticContent === void 0 ? void 0 : dataContent.length + ":" + dataContent + magnitudeContent.length + ":" + magnitudeContent + semanticContent, key = content, models = key === void 0 ? void 0 : preparedData.get(data);
782
+ !models && key !== void 0 && preparedData.set(data, models = /* @__PURE__ */ new Map());
783
+ let model = key === void 0 ? void 0 : models.get(key) ?? (content === void 0 ? void 0 : sharedPreparedData.get(content));
784
+ if (!model) {
785
+ let before = zeroLifts.count;
786
+ try {
787
+ let owned = copyPlannedValue(data);
788
+ ownPlanInput(owned);
789
+ let { theme: authoredTheme, measure: _measure, ...kept } = options;
790
+ model = compileTableData(owned, { ...copyPlannedValue(kept), theme: authoredTheme }, magnitudeSource === data ? owned : copyPlannedValue(magnitudeSource)), ownPlanInput(model);
791
+ } finally {
792
+ zeroLifts.count = before;
793
+ }
794
+ if (content !== void 0 && content.length <= MAX_SHARED_KEY_CHARS) {
795
+ for (sharedKeyChars += content.length; sharedPreparedData.size >= 32 || sharedKeyChars > MAX_SHARED_TOTAL_CHARS; ) {
796
+ let oldest = sharedPreparedData.keys().next().value;
797
+ sharedKeyChars -= oldest.length, sharedPreparedData.delete(oldest);
798
+ }
799
+ sharedPreparedData.set(content, model);
800
+ }
801
+ }
802
+ return key !== void 0 && !models.has(key) && (models.size >= 32 && models.delete(models.keys().next().value), models.set(key, model)), model;
803
+ });
804
+ }
805
+ function resolvePreparedTable(model, options = {}) {
806
+ return withSmallValues(options.smallValues, () => model.resolve(options));
807
+ }
683
808
  function resolveTable(data, options = {}, magnitudeSource = data) {
684
- return withSmallValues(options.smallValues, () => resolveTableIn(data, options, magnitudeSource));
809
+ let borrowed = resolvePreparedTable(prepareTableData(data, options, magnitudeSource), options), owned = copyPlannedValue(borrowed);
810
+ return evaluatedStates.set(owned, evaluatedStates.get(borrowed)), owned;
685
811
  }
686
- function resolveTableIn(data, options, magnitudeSource) {
687
- let liftsBefore = zeroLifts.count, liftMode = options[ZERO_LIFT], automaticAs = (on) => on && liftMode !== "none" ? liftMode ?? !0 : !1, formats = /* @__PURE__ */ new Map(), markedLanguage = options.locale?.language, parseFormatExample2 = (example) => {
812
+ function compileTableData(data, options, magnitudeSource) {
813
+ let source = data, modelLiftsBefore = zeroLifts.count, formats = /* @__PURE__ */ new Map(), markedLanguage = options.locale?.language, parseFormatExample2 = (example) => {
688
814
  let spec = formats.get(example);
689
815
  return spec === void 0 && (spec = parseFormatExample(example), spec.locale = markedLanguage, formats.set(example, spec)), { ...spec };
690
816
  }, warnings = [], datePatterns = /* @__PURE__ */ new Map();
@@ -749,7 +875,7 @@ function resolveTableIn(data, options, magnitudeSource) {
749
875
  }
750
876
  });
751
877
  }
752
- let records = [], autoFootnotes = /* @__PURE__ */ new Set(), lowerJudged = /* @__PURE__ */ new Set(), higherJudged = /* @__PURE__ */ new Set(), partialColumnIds = /* @__PURE__ */ new Set(), highlightedRows = new Set(resolveHighlight(options.highlight));
878
+ let records = [], autoFootnotes = /* @__PURE__ */ new Set(), partialColumnIds = /* @__PURE__ */ new Set(), headMarksPartial = disclosuresShown(options) && options.columnHeads !== !1, highlightedRows = new Set(resolveHighlight(options.highlight));
753
879
  assertTableRankOptions(options);
754
880
  let folded = applyTableTopN(data, options);
755
881
  data = folded.data;
@@ -767,7 +893,7 @@ function resolveTableIn(data, options, magnitudeSource) {
767
893
  `exactly one rowLabel column required, found ${rowLabelCols.length}`
768
894
  );
769
895
  validateGroups(data, colById), validateCalcRefs(columns, colById);
770
- let toggleResolution = resolveColumnToggles(data, options, colById, warnings), flat = flattenRows(data.rows), flatById = new Map(flat.map((row) => [row.id, row])), calcRunIds = new Set(columns.filter((c) => c.kind === "value" || c.kind === "computed" && calcPreservesScale(c.calc)).map((c) => c.id)), predecessorIds = new Set(columns.filter((c) => c.kind === "value" || c.kind === "computed").map((c) => c.id));
896
+ let toggleResolution = resolveColumnToggles(data, { ...options, columnVisibility: void 0 }, colById, warnings), toggleWarningAt = warnings.length, flat = flattenRows(data.rows), flatById = new Map(flat.map((row) => [row.id, row])), calcRunIds = new Set(columns.filter((c) => c.kind === "value" || c.kind === "computed" && calcPreservesScale(c.calc)).map((c) => c.id)), predecessorIds = new Set(columns.filter((c) => c.kind === "value" || c.kind === "computed").map((c) => c.id));
771
897
  if (![...calcRunIds].some((id) => predecessorIds.has(previousColumnInGroup(data.columnGroups ?? [], id) ?? "")))
772
898
  for (let row of flat)
773
899
  row.calc === void 0 || !calcRefs(row.calc).some((ref) => typeof ref != "string" && ref.previous === !0) || warnings.push({
@@ -787,7 +913,7 @@ function resolveTableIn(data, options, magnitudeSource) {
787
913
  let kept = list.filter((child) => child.inline !== !0);
788
914
  kept.length > 0 && treeChildrenOf.set(parentId, kept);
789
915
  }
790
- let expansion = resolveExpansion(flat, treeChildrenOf, options, warnings, generatedOthers), signTo = (row, stop) => contributionSignOf(row, (id) => flatById.get(id), stop), summandCache = /* @__PURE__ */ new Map(), summandsOf = (parentId) => {
916
+ let expansionWarningAt = warnings.length, expansion = resolveExpansion(flat, treeChildrenOf, {}, warnings, generatedOthers), signTo = (row, stop) => contributionSignOf(row, (id) => flatById.get(id), stop), summandCache = /* @__PURE__ */ new Map(), summandsOf = (parentId) => {
791
917
  let cached = summandCache.get(parentId);
792
918
  if (cached) return cached;
793
919
  let hoisted = [], dissolveSections = (pid) => {
@@ -902,7 +1028,7 @@ function resolveTableIn(data, options, magnitudeSource) {
902
1028
  message: `'${row.id}'.'${col.id}' is '${glyphs[inherited]}' because ${blockers.map((b) => `child '${b.id}' is ${STATE_REASON[b.state]}`).join(", ")} (column nulls policy 'propagate')`
903
1029
  }), derived = { raw: null, state: inherited };
904
1030
  } else
905
- blockers.length > 0 && (autoFootnotes.add(PARTIAL_FOOTNOTE), partialColumnIds.add(col.id)), derived = { raw: cleanSum(inputs.map((input) => input.value)), state: "value", ...blockers.length > 0 || partialKid ? { partial: !0, skipped: skippedKey([...blockers.map((b) => b.id), ...skippedKids]) } : {} };
1031
+ blockers.length > 0 && (options.columnHeads !== !1 && autoFootnotes.add(PARTIAL_FOOTNOTE), partialColumnIds.add(col.id)), derived = { raw: cleanSum(inputs.map((input) => input.value)), state: "value", ...blockers.length > 0 || partialKid ? { partial: !0, skipped: skippedKey([...blockers.map((b) => b.id), ...skippedKids]) } : {} };
906
1032
  let policy = row.totalPolicy ?? (authored.raw !== null ? "validate" : "derive");
907
1033
  return policy === "source" ? authored.raw === null ? derived : { raw: authored.raw, state: "value" } : policy === "validate" && authored.raw !== null ? (noSummands ? unauditedRecord() : records.push({
908
1034
  rowId: row.id,
@@ -962,548 +1088,608 @@ function resolveTableIn(data, options, magnitudeSource) {
962
1088
  owner: { rowId, colId }
963
1089
  });
964
1090
  }
965
- let locale = localeDefaults(options.locale), sourceRows = magnitudeSource === data ? flatById : new Map(flattenRows(magnitudeSource.rows).map((row) => [row.id, row])), sourceColumns = new Map(magnitudeSource.columns.map((col) => [col.id, col])), scales = (example) => scalesWithMagnitude(parseFormatExample2(example)), specs = /* @__PURE__ */ new Map(), formatExamples = /* @__PURE__ */ new Map(), localeDerivedColumns = /* @__PURE__ */ new Set();
966
- for (let col of [...valueCols, ...computedCols]) {
967
- let inherited = col.kind === "computed" && !calcPreservesScale(col.calc) ? void 0 : options.format, authoredExample = col.format ?? inherited, example = authoredExample ?? defaultExample(col);
968
- authoredExample === void 0 && localeDerivedColumns.add(col.id), formatExamples.set(col.id, example);
969
- let spec = parseFormatExample2(example), sourceExample = sourceColumns.get(col.id)?.format ?? inherited;
970
- spec.automatic = automaticAs(sourceExample === void 0 && options.unit === void 0 && options.magnitude !== "million" && options.magnitude !== "thousand"), authoredExample === void 0 && currencyWholeNumbers(options.unit, options.target) && (col.kind !== "computed" || calcPreservesScale(col.calc)) && (spec.currencyWhole = !0), scales(sourceColumns.get(col.id)?.format ?? inherited ?? defaultExample(col)) && (options.magnitude === "million" || options.magnitude === "thousand") && forceScale(spec, options.magnitude === "million" ? "m" : "k", locale.thousands), sourceExample !== void 0 && holdAuthoredScale(spec, locale.thousands), specs.set(col.id, spec);
971
- }
972
- let rowSpecs = /* @__PURE__ */ new Map(), rowById = /* @__PURE__ */ new Map(), forcedMagnitude = options.magnitude === "million" ? "m" : options.magnitude === "thousand" ? "k" : void 0, authoredSpec = (example, sourceExample = example) => {
973
- let spec = parseFormatExample2(example);
974
- return forcedMagnitude !== void 0 && scales(sourceExample) && forceScale(spec, forcedMagnitude, locale.thousands), spec;
975
- }, cellsOfRow = /* @__PURE__ */ new Map(), rowCells = (row) => {
976
- let cells = cellsOfRow.get(row.id);
977
- return cells === void 0 && cellsOfRow.set(row.id, cells = rowCellsUncached(row)), cells;
978
- }, rowValues = (row) => rowCells(row).map(([, value]) => value), rowCellsUncached = (row) => valueCols.filter((col) => col.format === void 0 && cellFormat(row.cells[col.id]) === void 0 && !(data.columnToggles ?? []).some((toggle) => toggle.columns.includes(col.id) && (options.columnVisibility?.[toggle.id] ?? toggle.defaultVisible ?? !1) === !1)).flatMap((col) => {
979
- let raw = rawState.get(row.id)?.get(col.id)?.raw;
980
- return typeof raw == "number" ? [[col.id, raw]] : [];
981
- }), largest = (values) => values.reduce((n, v) => Math.max(n, Math.abs(v)), 0), groupOf = (row) => sourceRows.get(row.id)?.[MAGNITUDE_GROUP], groupMax = /* @__PURE__ */ new Map(), groupColumns = /* @__PURE__ */ new Map();
982
- for (let row of flat) {
983
- let group = groupOf(row);
984
- if (group === void 0) continue;
985
- groupMax.set(group, Math.max(groupMax.get(group) ?? 0, largest(rowValues(row))));
986
- let columns2 = groupColumns.get(group);
987
- columns2 === void 0 && groupColumns.set(group, columns2 = /* @__PURE__ */ new Map());
988
- for (let [colId, value] of rowCells(row)) {
989
- let column = columns2.get(colId);
990
- column === void 0 ? columns2.set(colId, [value]) : column.push(value);
1091
+ let rawWarnings = warnings, rawRecords = records, rawFootnotes = autoFootnotes, rawCells = rawState, childGroups = childrenOf, rawLifts = zeroLifts.count - modelLiftsBefore, rowIds = flat.map((row) => row.id), rowIndex = new Map(rowIds.map((id, index) => [id, index])), columnIndex = new Map(columnIds.map((id, index) => [id, index])), formatted = /* @__PURE__ */ new Map();
1092
+ return { source, rowIds, columnIds, rowIndex, columnIndex, resolve(current) {
1093
+ let formatKey = JSON.stringify([current.columnVisibility, current[ZERO_LIFT]]), display = formatted.get(formatKey);
1094
+ if (display)
1095
+ zeroLifts.count += display.lifts;
1096
+ else {
1097
+ let before = zeroLifts.count;
1098
+ display = { result: formatTable({ ...options, columnVisibility: current.columnVisibility, [ZERO_LIFT]: current[ZERO_LIFT] }), lifts: zeroLifts.count - before, views: /* @__PURE__ */ new Map() }, formatted.size >= 32 && formatted.delete(formatted.keys().next().value), formatted.set(formatKey, display);
991
1099
  }
992
- }
993
- let groupCellSpecs = /* @__PURE__ */ new Map();
994
- for (let row of flat) {
995
- rowById.set(row.id, row);
996
- let example = row.format ?? (row.scale ? row.scale === "percent" ? "1.2%" : "1,234" : void 0) ?? (row.calc && calcYieldsPoints(row.calc) ? `1${locale.decimal}2%` : void 0);
997
- if (example) {
998
- let spec = authoredSpec(example, sourceRows.get(row.id)?.format ?? example), authoredRow = sourceRows.get(row.id);
999
- authoredRow?.format !== void 0 && authoredRow[AUTOMATIC_FORMAT] !== !0 && holdAuthoredScale(spec, locale.thousands);
1000
- let group = groupOf(row), rowScale = row.scale === "money" || row.scale === "perUnit";
1001
- if (rowScale || specUnitKind(spec) === "number") {
1002
- let values = rowValues(row), max = group === void 0 ? largest(values) : groupMax.get(group), climb = (from) => max >= 1e9 ? "bn" : max >= 1e6 ? "m" : max >= from ? "k" : "none", authoredFormat = sourceRows.get(row.id)?.format !== void 0;
1003
- if (rowScale && !spec.magnitudeInAffix && !spec.exponent && !spec.ordinal) {
1004
- let heldMoney = row.scale === "money" && forcedMagnitude !== void 0;
1005
- if (spec.magnitude = heldMoney ? forcedMagnitude : row.scale === "money" ? climb(1e3) : "none", row.scale === "money")
1006
- spec.decimals = max >= 1e3 && !(heldMoney && forcedMagnitude === "k" && max >= 1e5) ? 1 : 0;
1007
- else if ((!authoredFormat || values.every(Number.isInteger)) && (spec.decimals = max >= 10 ? 0 : 1, !authoredFormat))
1008
- for (let value of values)
1009
- for (; value !== 0 && spec.decimals < 20 && Math.abs(roundedNumber(value, spec) - value) > Math.abs(value) * 0.01; ) spec.decimals++;
1010
- spec.prefix = "", spec.suffix = "", spec.lockMagnitude = heldMoney, spec.rollMagnitude = !1, spec.thousandsSep === "" && (spec.thousandsSep = locale.thousands);
1011
- } else row.scale === "count" && !authoredFormat && max >= 1e6 && spec.magnitude === "none" && !spec.signed && (spec.magnitude = climb(1 / 0), spec.decimals = 1, spec.lockMagnitude = !1, spec.rollMagnitude = !1);
1012
- let smallMoney = !spec.magnitudeInAffix && !spec.exponent && !spec.ordinal && !rowScale && forcedMagnitude && scales(example) && values.every((v) => Math.abs(v) < 1e3), changeLine = row.inline === !0 || spec.signed;
1013
- if (smallMoney || !changeLine && group === void 0 && values.some((v) => v !== 0 && roundedNumber(v, spec) === 0)) {
1014
- if (!spec.magnitudeInAffix && (smallMoney || !rowScale && spec.lockMagnitude && spec.magnitude === "k" || row.scale === "money" && spec.magnitude === "k")) {
1015
- let authored = parseFormatExample2(example);
1016
- spec.decimals = !rowScale && authored.magnitude === "none" ? authored.decimals : 0, spec.magnitude = "none";
1017
- }
1018
- spec.decimals = values.reduce((decimals, value) => nonzeroDecimals(value / MAGNITUDE_DIVISOR[spec.magnitude], decimals), spec.decimals);
1019
- }
1020
- if (!changeLine && (spec.magnitude !== "none" || group !== void 0 && row.scale === "money") && !(spec.lockMagnitude && spec.magnitude === "k") && (row.scale === "money" || row.scale === "count" && !authoredFormat))
1021
- if (group === void 0)
1022
- for (let value of values)
1023
- for (; value !== 0 && spec.decimals < 20 && Math.abs(roundedNumber(value, spec) - value) > Math.abs(value) * 0.01; ) spec.decimals++;
1024
- else {
1025
- let columns2 = groupColumns.get(group);
1026
- for (let column of columns2.values())
1027
- for (let value of column)
1028
- for (; value !== 0 && spec.decimals < 20 && Math.abs(roundedNumber(value, spec) - value) > max * 0.01; ) spec.decimals++;
1029
- let inRow = /* @__PURE__ */ new Map();
1030
- for (let [colId, column] of columns2) {
1031
- let cellSpec = { ...spec }, bound = largest(column) * 0.01;
1032
- for (let value of column)
1033
- for (; value !== 0 && cellSpec.decimals < 20 && Math.abs(roundedNumber(value, cellSpec) - value) > bound; ) cellSpec.decimals++;
1034
- inRow.set(colId, cellSpec);
1100
+ zeroLifts.count += rawLifts;
1101
+ let viewKey = JSON.stringify(current.expansion), view = display.views.get(viewKey ?? "");
1102
+ if (!view) {
1103
+ let toggleWarnings = [], expansionWarnings = [], toggles = toggleResolution.toggles.map((toggle) => ({ ...toggle, visible: current.columnVisibility?.[toggle.id] ?? toggle.defaultVisible }));
1104
+ columnVisibilityWarnings(toggles, current, toggleWarnings);
1105
+ let expanded = resolveExpansion(flat, treeChildrenOf, current, expansionWarnings, generatedOthers), base = display.result, rows = base.table.rows.map((row) => row.hasChildren ? { ...row, defaultExpanded: expanded.get(row.id) } : row.inlineRows ? { ...row } : row), rowsById = new Map(rows.map((row) => [row.id, row]));
1106
+ for (let index = 0; index < rows.length; index++) {
1107
+ let row = rows[index];
1108
+ row.inlineRows && (row.inlineRows = row.inlineRows.map((line) => rowsById.get(line.id)));
1109
+ }
1110
+ view = { ...base, table: { ...base.table, rows, columnToggles: toggles }, warnings: [
1111
+ ...base.warnings.slice(0, toggleWarningAt),
1112
+ ...toggleWarnings,
1113
+ ...base.warnings.slice(toggleWarningAt, expansionWarningAt),
1114
+ ...expansionWarnings,
1115
+ ...base.warnings.slice(expansionWarningAt)
1116
+ ] }, evaluatedStates.set(view, evaluatedStates.get(base)), display.views.size >= 32 && display.views.delete(display.views.keys().next().value), display.views.set(viewKey ?? "", view);
1117
+ }
1118
+ return view;
1119
+ } };
1120
+ function formatTable(options2) {
1121
+ let liftsBefore = zeroLifts.count, liftMode = options2[ZERO_LIFT], automaticAs = (on) => on && liftMode !== "none" ? liftMode ?? !0 : !1, warnings2 = rawWarnings.slice(), records2 = rawRecords.map((record) => ({ ...record })), autoFootnotes2 = new Set(rawFootnotes), lowerJudged = /* @__PURE__ */ new Set(), higherJudged = /* @__PURE__ */ new Set(), rawState2 = new Map([...rawCells].map(([id, cells]) => [id, new Map(cells)]));
1122
+ partitionLeafIds.set(rawState2, partitionLeafIds.get(rawCells));
1123
+ let childrenOf2 = new Map([...childGroups].map(([id, rows]) => [id, rows.slice()])), locale = localeDefaults(options2.locale), sourceRows = magnitudeSource === data ? flatById : new Map(flattenRows(magnitudeSource.rows).map((row) => [row.id, row])), sourceColumns = new Map(magnitudeSource.columns.map((col) => [col.id, col])), scales = (example) => scalesWithMagnitude(parseFormatExample2(example)), specs = /* @__PURE__ */ new Map(), formatExamples = /* @__PURE__ */ new Map(), localeDerivedColumns = /* @__PURE__ */ new Set();
1124
+ for (let col of [...valueCols, ...computedCols]) {
1125
+ let inherited = col.kind === "computed" && !calcPreservesScale(col.calc) ? void 0 : options2.format, authoredExample = col.format ?? inherited, example = authoredExample ?? defaultExample(col);
1126
+ authoredExample === void 0 && localeDerivedColumns.add(col.id), formatExamples.set(col.id, example);
1127
+ let spec = parseFormatExample2(example), sourceExample = sourceColumns.get(col.id)?.format ?? inherited;
1128
+ spec.automatic = automaticAs(sourceExample === void 0 && options2.unit === void 0 && options2.magnitude !== "million" && options2.magnitude !== "thousand"), authoredExample === void 0 && currencyWholeNumbers(options2.unit, options2.target) && (col.kind !== "computed" || calcPreservesScale(col.calc)) && (spec.currencyWhole = !0), scales(sourceColumns.get(col.id)?.format ?? inherited ?? defaultExample(col)) && (options2.magnitude === "million" || options2.magnitude === "thousand") && forceScale(spec, options2.magnitude === "million" ? "m" : "k", locale.thousands), sourceExample !== void 0 && holdAuthoredScale(spec, locale.thousands), specs.set(col.id, spec);
1129
+ }
1130
+ let rowSpecs = /* @__PURE__ */ new Map(), rowById = /* @__PURE__ */ new Map(), forcedMagnitude = options2.magnitude === "million" ? "m" : options2.magnitude === "thousand" ? "k" : void 0, authoredSpec = (example, sourceExample = example) => {
1131
+ let spec = parseFormatExample2(example);
1132
+ return forcedMagnitude !== void 0 && scales(sourceExample) && forceScale(spec, forcedMagnitude, locale.thousands), spec;
1133
+ }, cellsOfRow = /* @__PURE__ */ new Map(), rowCells = (row) => {
1134
+ let cells = cellsOfRow.get(row.id);
1135
+ return cells === void 0 && cellsOfRow.set(row.id, cells = rowCellsUncached(row)), cells;
1136
+ }, rowValues = (row) => rowCells(row).map(([, value]) => value), rowCellsUncached = (row) => valueCols.filter((col) => col.format === void 0 && cellFormat(row.cells[col.id]) === void 0 && !(data.columnToggles ?? []).some((toggle) => toggle.columns.includes(col.id) && (options2.columnVisibility?.[toggle.id] ?? toggle.defaultVisible ?? !1) === !1)).flatMap((col) => {
1137
+ let raw = rawState2.get(row.id)?.get(col.id)?.raw;
1138
+ return typeof raw == "number" ? [[col.id, raw]] : [];
1139
+ }), largest = (values) => values.reduce((n, v) => Math.max(n, Math.abs(v)), 0), groupOf = (row) => sourceRows.get(row.id)?.[MAGNITUDE_GROUP], groupMax = /* @__PURE__ */ new Map(), groupColumns = /* @__PURE__ */ new Map();
1140
+ for (let row of flat) {
1141
+ let group = groupOf(row);
1142
+ if (group === void 0) continue;
1143
+ let kept = sourceRows.get(row.id)?.[MAGNITUDE_FIGURES], figures = kept === void 0 ? rowCells(row) : [...rowCells(row), ...kept];
1144
+ groupMax.set(group, Math.max(groupMax.get(group) ?? 0, largest(kept === void 0 ? rowValues(row) : figures.map(([, value]) => value))));
1145
+ let columns2 = groupColumns.get(group);
1146
+ columns2 === void 0 && groupColumns.set(group, columns2 = /* @__PURE__ */ new Map());
1147
+ for (let [colId, value] of figures) {
1148
+ let column = columns2.get(colId);
1149
+ column === void 0 ? columns2.set(colId, [value]) : column.push(value);
1150
+ }
1151
+ }
1152
+ let groupCellSpecs = /* @__PURE__ */ new Map();
1153
+ for (let row of flat) {
1154
+ rowById.set(row.id, row);
1155
+ let example = row.format ?? (row.scale ? row.scale === "percent" ? "1.2%" : "1,234" : void 0) ?? (row.calc && calcYieldsPoints(row.calc) ? `1${locale.decimal}2%` : void 0);
1156
+ if (example) {
1157
+ let spec = authoredSpec(example, sourceRows.get(row.id)?.format ?? example), authoredRow = sourceRows.get(row.id);
1158
+ authoredRow?.format !== void 0 && authoredRow[AUTOMATIC_FORMAT] !== !0 && holdAuthoredScale(spec, locale.thousands);
1159
+ let group = groupOf(row), rowScale = row.scale === "money" || row.scale === "perUnit";
1160
+ if (rowScale || specUnitKind(spec) === "number") {
1161
+ let values = rowValues(row), max = group === void 0 ? largest(values) : groupMax.get(group), climb = (from) => max >= 1e9 ? "bn" : max >= 1e6 ? "m" : max >= from ? "k" : "none", authoredFormat = sourceRows.get(row.id)?.format !== void 0;
1162
+ if (rowScale && !spec.magnitudeInAffix && !spec.exponent && !spec.ordinal) {
1163
+ let heldMoney = row.scale === "money" && forcedMagnitude !== void 0;
1164
+ if (spec.magnitude = heldMoney ? forcedMagnitude : row.scale === "money" ? climb(1e3) : "none", row.scale === "money")
1165
+ spec.decimals = max >= 1e3 && !(heldMoney && forcedMagnitude === "k" && max >= 1e5) ? 1 : 0;
1166
+ else if ((!authoredFormat || values.every(Number.isInteger)) && (spec.decimals = max >= 10 ? 0 : 1, !authoredFormat))
1167
+ for (let value of values)
1168
+ for (; value !== 0 && spec.decimals < 20 && Math.abs(roundedNumber(value, spec) - value) > Math.abs(value) * 0.01; ) spec.decimals++;
1169
+ spec.prefix = "", spec.suffix = "", spec.lockMagnitude = heldMoney, spec.rollMagnitude = !1, spec.thousandsSep === "" && (spec.thousandsSep = locale.thousands);
1170
+ } else row.scale === "count" && !authoredFormat && max >= 1e6 && spec.magnitude === "none" && !spec.signed && (spec.magnitude = climb(1 / 0), spec.decimals = 1, spec.lockMagnitude = !1, spec.rollMagnitude = !1);
1171
+ let smallMoney = !spec.magnitudeInAffix && !spec.exponent && !spec.ordinal && !rowScale && forcedMagnitude && scales(example) && values.every((v) => Math.abs(v) < 1e3), changeLine = row.inline === !0 || spec.signed;
1172
+ if (smallMoney || !changeLine && group === void 0 && values.some((v) => v !== 0 && roundedNumber(v, spec) === 0)) {
1173
+ if (!spec.magnitudeInAffix && (smallMoney || !rowScale && spec.lockMagnitude && spec.magnitude === "k" || row.scale === "money" && spec.magnitude === "k")) {
1174
+ let authored = parseFormatExample2(example);
1175
+ spec.decimals = !rowScale && authored.magnitude === "none" ? authored.decimals : 0, spec.magnitude = "none";
1035
1176
  }
1036
- groupCellSpecs.set(row.id, inRow);
1177
+ spec.decimals = values.reduce((decimals, value) => nonzeroDecimals(value / MAGNITUDE_DIVISOR[spec.magnitude], decimals), spec.decimals);
1037
1178
  }
1179
+ if (!changeLine && (spec.magnitude !== "none" || group !== void 0 && row.scale === "money") && !(spec.lockMagnitude && spec.magnitude === "k") && (row.scale === "money" || row.scale === "count" && !authoredFormat))
1180
+ if (group === void 0)
1181
+ for (let value of values)
1182
+ for (; value !== 0 && spec.decimals < 20 && Math.abs(roundedNumber(value, spec) - value) > Math.abs(value) * 0.01; ) spec.decimals++;
1183
+ else {
1184
+ let columns2 = groupColumns.get(group);
1185
+ for (let column of columns2.values())
1186
+ for (let value of column)
1187
+ for (; value !== 0 && spec.decimals < 20 && Math.abs(roundedNumber(value, spec) - value) > max * 0.01; ) spec.decimals++;
1188
+ let inRow = /* @__PURE__ */ new Map();
1189
+ for (let [colId, column] of columns2) {
1190
+ let cellSpec = { ...spec }, bound = largest(column) * 0.01;
1191
+ for (let value of column)
1192
+ for (; value !== 0 && cellSpec.decimals < 20 && Math.abs(roundedNumber(value, cellSpec) - value) > bound; ) cellSpec.decimals++;
1193
+ inRow.set(colId, cellSpec);
1194
+ }
1195
+ groupCellSpecs.set(row.id, inRow);
1196
+ }
1197
+ }
1198
+ let sourceRow = sourceRows.get(row.id);
1199
+ spec.automatic = automaticAs(group !== void 0 || (sourceRow?.format === void 0 || sourceRow[AUTOMATIC_FORMAT] === !0) && options2.format === void 0 && options2.unit === void 0 && forcedMagnitude === void 0);
1200
+ for (let cellSpec of groupCellSpecs.get(row.id)?.values() ?? []) cellSpec.automatic = spec.automatic;
1201
+ rowSpecs.set(row.id, spec);
1202
+ }
1203
+ }
1204
+ let cellSpecs = /* @__PURE__ */ new Map(), cellFormatCols = [...valueCols, ...computedCols];
1205
+ for (let row of flat)
1206
+ for (let col of cellFormatCols) {
1207
+ let example = cellFormat(row.cells[col.id]);
1208
+ if (example !== void 0) {
1209
+ let sourceRow = sourceRows.get(row.id), sourceColumn = sourceColumns.get(col.id), sourceExample = cellFormat(sourceRow?.cells[col.id]) ?? sourceColumn?.format ?? sourceRow?.format ?? options2.format ?? defaultExample(col), inRow = cellSpecs.get(row.id);
1210
+ inRow || cellSpecs.set(row.id, inRow = /* @__PURE__ */ new Map());
1211
+ let spec = authoredSpec(example, sourceExample), sourceCell = sourceRow?.cells[col.id];
1212
+ cellFormat(sourceRow?.cells[col.id]) !== void 0 && sourceCell?.[AUTOMATIC_FORMAT] !== !0 && holdAuthoredScale(spec, locale.thousands), sourceCell?.[AUTOMATIC_FORMAT] === !0 && (spec.automatic = automaticAs(!0)), inRow.set(col.id, spec);
1213
+ }
1038
1214
  }
1039
- let sourceRow = sourceRows.get(row.id);
1040
- spec.automatic = automaticAs(group !== void 0 || (sourceRow?.format === void 0 || sourceRow[AUTOMATIC_FORMAT] === !0) && options.format === void 0 && options.unit === void 0 && forcedMagnitude === void 0);
1041
- for (let cellSpec of groupCellSpecs.get(row.id)?.values() ?? []) cellSpec.automatic = spec.automatic;
1042
- rowSpecs.set(row.id, spec);
1043
- }
1044
- }
1045
- let cellSpecs = /* @__PURE__ */ new Map(), cellFormatCols = [...valueCols, ...computedCols];
1046
- for (let row of flat)
1047
- for (let col of cellFormatCols) {
1048
- let example = cellFormat(row.cells[col.id]);
1049
- if (example !== void 0) {
1050
- let sourceRow = sourceRows.get(row.id), sourceColumn = sourceColumns.get(col.id), sourceExample = cellFormat(sourceRow?.cells[col.id]) ?? sourceColumn?.format ?? sourceRow?.format ?? options.format ?? defaultExample(col), inRow = cellSpecs.get(row.id);
1051
- inRow || cellSpecs.set(row.id, inRow = /* @__PURE__ */ new Map());
1052
- let spec = authoredSpec(example, sourceExample), sourceCell = sourceRow?.cells[col.id];
1053
- cellFormat(sourceRow?.cells[col.id]) !== void 0 && sourceCell?.[AUTOMATIC_FORMAT] !== !0 && holdAuthoredScale(spec, locale.thousands), sourceCell?.[AUTOMATIC_FORMAT] === !0 && (spec.automatic = automaticAs(!0)), inRow.set(col.id, spec);
1215
+ let cellNamesOtherUnit = (rowId, colId, spec) => {
1216
+ let own = cellSpecs.get(rowId)?.get(colId);
1217
+ return own !== void 0 && typeof rawState2.get(rowId)?.get(colId)?.raw == "number" && unitOfSpec(own) !== unitOfSpec(spec);
1218
+ }, hoistedRowUnits = /* @__PURE__ */ new Map();
1219
+ if (forcedMagnitude !== void 0)
1220
+ for (let [rowId, spec] of rowSpecs) {
1221
+ if (rowById.get(rowId)?.scale === "money" || rowById.get(rowId)?.scale === "perUnit" || rowById.get(rowId)?.calc !== void 0 || !scales(sourceRows.get(rowId)?.format ?? "1,234") || valueCols.some((col) => cellNamesOtherUnit(rowId, col.id, spec))) continue;
1222
+ let unit = spec.magnitude === "none" ? null : unitOfSpec(spec);
1223
+ unit !== null && hoistedRowUnits.set(rowId, unit);
1224
+ }
1225
+ let ownFormatColumns = new Set([...valueCols, ...computedCols].filter(columnOwnsFormat).map((col) => col.id)), rowFormattedColumns = /* @__PURE__ */ new Set();
1226
+ for (let row of flat)
1227
+ if (!(row.calc || !rowSpecs.has(row.id)))
1228
+ for (let col of valueCols)
1229
+ !ownFormatColumns.has(col.id) && typeof rawState2.get(row.id)?.get(col.id)?.raw == "number" && rowFormattedColumns.add(col.id);
1230
+ let hoistedUnitSet = new Set(hoistedRowUnits.values()), figureRows = flat.filter((row) => !row.calc && valueCols.some((col) => typeof rawState2.get(row.id)?.get(col.id)?.raw == "number")), headUnit = figureRows.length > 1 && hoistedUnitSet.size === 1 && figureRows.every((row) => hoistedRowUnits.has(row.id)) ? [...hoistedUnitSet][0] : void 0;
1231
+ function defaultExample(col) {
1232
+ if (col.kind === "computed" && calcYieldsPoints(col.calc)) return `1${locale.decimal}2%`;
1233
+ if (options2.magnitude === "million") return `1${locale.thousands}234${locale.decimal}2m`;
1234
+ if (options2.magnitude === "thousand") return `1${locale.thousands}234k`;
1235
+ let colId = col.id, maxAbs = 0, values = [];
1236
+ for (let r of flat) {
1237
+ let s = rawState2.get(r.id).get(colId);
1238
+ s && typeof s.raw == "number" && (maxAbs = Math.max(maxAbs, Math.abs(s.raw)), values.push(s.raw));
1054
1239
  }
1240
+ if (maxAbs >= 1e9) return `1${locale.decimal}2bn`;
1241
+ if (maxAbs >= 1e6) return `1${locale.decimal}2m`;
1242
+ if (maxAbs >= 100) return `1${locale.thousands}234`;
1243
+ let decimals = typicalDecimals(values);
1244
+ return decimals > 1 ? `0${locale.decimal}${"1234".slice(0, decimals)}` : `1${locale.decimal}2`;
1055
1245
  }
1056
- let cellNamesOtherUnit = (rowId, colId, spec) => {
1057
- let own = cellSpecs.get(rowId)?.get(colId);
1058
- return own !== void 0 && typeof rawState.get(rowId)?.get(colId)?.raw == "number" && unitOfSpec(own) !== unitOfSpec(spec);
1059
- }, hoistedRowUnits = /* @__PURE__ */ new Map();
1060
- if (forcedMagnitude !== void 0)
1061
- for (let [rowId, spec] of rowSpecs) {
1062
- if (rowById.get(rowId)?.scale === "money" || rowById.get(rowId)?.scale === "perUnit" || rowById.get(rowId)?.calc !== void 0 || !scales(sourceRows.get(rowId)?.format ?? "1,234") || valueCols.some((col) => cellNamesOtherUnit(rowId, col.id, spec))) continue;
1063
- let unit = spec.magnitude === "none" ? null : unitOfSpec(spec);
1064
- unit !== null && hoistedRowUnits.set(rowId, unit);
1065
- }
1066
- let ownFormatColumns = new Set([...valueCols, ...computedCols].filter(columnOwnsFormat).map((col) => col.id)), rowFormattedColumns = /* @__PURE__ */ new Set();
1067
- for (let row of flat)
1068
- if (!(row.calc || !rowSpecs.has(row.id)))
1069
- for (let col of valueCols)
1070
- !ownFormatColumns.has(col.id) && typeof rawState.get(row.id)?.get(col.id)?.raw == "number" && rowFormattedColumns.add(col.id);
1071
- let hoistedUnitSet = new Set(hoistedRowUnits.values()), figureRows = flat.filter((row) => !row.calc && valueCols.some((col) => typeof rawState.get(row.id)?.get(col.id)?.raw == "number")), headUnit = figureRows.length > 1 && hoistedUnitSet.size === 1 && figureRows.every((row) => hoistedRowUnits.has(row.id)) ? [...hoistedUnitSet][0] : void 0;
1072
- function defaultExample(col) {
1073
- if (col.kind === "computed" && calcYieldsPoints(col.calc)) return `1${locale.decimal}2%`;
1074
- if (options.magnitude === "million") return `1${locale.thousands}234${locale.decimal}2m`;
1075
- if (options.magnitude === "thousand") return `1${locale.thousands}234k`;
1076
- let colId = col.id, maxAbs = 0, values = [];
1077
- for (let r of flat) {
1078
- let s = rawState.get(r.id).get(colId);
1079
- s && typeof s.raw == "number" && (maxAbs = Math.max(maxAbs, Math.abs(s.raw)), values.push(s.raw));
1080
- }
1081
- if (maxAbs >= 1e9) return `1${locale.decimal}2bn`;
1082
- if (maxAbs >= 1e6) return `1${locale.decimal}2m`;
1083
- if (maxAbs >= 100) return `1${locale.thousands}234`;
1084
- let decimals = typicalDecimals(values);
1085
- return decimals > 1 ? `0${locale.decimal}${"1234".slice(0, decimals)}` : `1${locale.decimal}2`;
1086
- }
1087
- let unitByCol = /* @__PURE__ */ new Map(), rollsOff = (colId, spec) => spec.magnitude !== "none" && flat.some((row) => {
1088
- if (rowSpecs.has(row.id) && (row.calc !== void 0 || row.inline === !0 || !ownFormatColumns.has(colId)) || cellSpecs.get(row.id)?.has(colId)) return !1;
1089
- let raw = rawState.get(row.id)?.get(colId)?.raw;
1090
- return typeof raw == "number" && raw !== 0 && effectiveScale(Math.abs(raw), spec).magnitude !== spec.magnitude;
1091
- }), lettersInCells = /* @__PURE__ */ new Set();
1092
- for (let col of [...valueCols, ...computedCols]) {
1093
- let spec = specs.get(col.id);
1094
- !rowFormattedColumns.has(col.id) && (rollsOff(col.id, spec) || flat.some((row) => cellNamesOtherUnit(row.id, col.id, spec))) && lettersInCells.add(col.id), unitByCol.set(col.id, rowFormattedColumns.has(col.id) || lettersInCells.has(col.id) ? null : unitOfSpec(spec));
1095
- }
1096
- let headerUnitFor = (id) => unitByCol.get(id) ?? (rowFormattedColumns.has(id) ? headUnit ?? null : null), headerScaledFor = (id) => unitByCol.get(id) != null ? specs.get(id).magnitude !== "none" : rowFormattedColumns.has(id) && headUnit !== void 0 && figureRows.some((row) => (rowSpecs.get(row.id)?.magnitude ?? "none") !== "none"), distinctUnits = [...new Set([...unitByCol.keys()].map(headerUnitFor).filter((u) => u !== null))], candidateUnit = distinctUnits.length === 1 && [...valueCols, ...computedCols].every((col) => {
1097
- let kind = specUnitKind(specs.get(col.id));
1098
- return kind === "percent" || kind === "pp" || headerUnitFor(col.id) === distinctUnits[0];
1099
- }) ? distinctUnits[0] : void 0, frameCarriesUnit = unitPrinted({
1100
- subtitle: resolveSubtitle(options.subtitle),
1101
- unit: candidateUnit,
1102
- unitShown: options.unitShown
1103
- }), authoredUnit = typeof options.unit == "string" ? options.unit.trim() : void 0, scaleWords = (authoredUnit?.split(/[\s$€£¥()]+/) ?? []).filter((word) => Object.values(MAGNITUDE_LABEL).some((label) => label !== "" && sameUnit(word, label))), bareScale = candidateUnit !== void 0 && [...[...valueCols, ...computedCols].map((col) => specs.get(col.id)), ...rowSpecs.values()].every((spec) => specUnitKind(spec) !== "number" || spec.prefix.trim() === "" && spec.suffix.trim() === ""), carriesScale = scaleWords.some((word) => sameUnit(word, candidateUnit ?? "")), composes = bareScale && !!authoredUnit && (carriesScale || scaleWords.length === 0 && /^(?:[A-Z]{3}|\p{Sc})$/u.test(authoredUnit)), composedUnit = composes ? carriesScale ? authoredUnit : `${authoredUnit} ${candidateUnit}` : candidateUnit, uniformUnit = composedUnit && frameCarriesUnit ? composedUnit : null;
1104
- uniformUnit !== null && options.unit !== void 0 && options.unit !== uniformUnit && !composes && warnings.push({
1105
- code: "table-unit-overridden",
1106
- severity: "warn",
1107
- field: ["options", "unit"],
1108
- message: `options.unit '${options.unit}' is not printed. The table prints '${uniformUnit}' because its column formats resolve that shared unit.`,
1109
- suggest: "Remove options.unit so the column formats supply the unit.",
1110
- fix: [{ op: "remove", path: "/options/unit" }]
1111
- });
1112
- let rowOverridesColumn = (rowId) => {
1113
- let row = rowById.get(rowId);
1114
- return row?.calc !== void 0 || row?.inline === !0;
1115
- }, specFor = (colId, rowId) => {
1116
- let cellSpec = rowId ? cellSpecs.get(rowId)?.get(colId) : void 0;
1117
- if (cellSpec) return cellSpec;
1118
- let rowSpec = rowId ? rowSpecs.get(rowId) : void 0;
1119
- return rowSpec && (rowOverridesColumn(rowId) || !ownFormatColumns.has(colId)) ? groupCellSpecs.get(rowId)?.get(colId) ?? rowSpec : specs.get(colId);
1120
- }, formatNumber = (raw, colId, rowId, lift = !0) => {
1121
- let cellSpec = rowId ? cellSpecs.get(rowId)?.get(colId) : void 0, rowSpec = rowId ? rowSpecs.get(rowId) : void 0, rowPath = rowSpec !== void 0 && (rowOverridesColumn(rowId) || !ownFormatColumns.has(colId)), base = rowPath ? rowSpec : specs.get(colId);
1122
- if (cellSpec && !sameUnit2(cellSpec, base)) return formatWithSpec(raw, lift ? cellSpec : { ...cellSpec, automatic: !1 });
1123
- let decimals = cellSpec?.decimals ?? (rowPath ? groupCellSpecs.get(rowId)?.get(colId)?.decimals : void 0) ?? base.decimals;
1124
- if (rowPath) {
1125
- if (raw === 0 && lift && !cellSpec && groupOf(rowById.get(rowId)) !== void 0) return "0";
1126
- let hoisted = rowId !== void 0 && hoistedRowUnits.has(rowId), automatic = lift && (cellSpec ? cellSpec.automatic : rowSpec.automatic);
1127
- return hoisted ? formatWithSpec(raw, { ...rowSpec, decimals, automatic, prefix: "", suffix: "", magnitudeInAffix: !0 }) : formatWithSpec(raw, { ...rowSpec, decimals, automatic });
1128
- }
1129
- let spec = { ...specs.get(colId), decimals, ...cellSpec ? { currencyWhole: void 0, automatic: cellSpec.automatic } : {}, ...lift ? {} : { automatic: !1 } }, rendered = unitByCol.get(colId) == null ? formatWithSpec(raw, spec) : formatWithSpec(raw, { ...spec, prefix: "", suffix: "", magnitudeInAffix: !0 });
1130
- return localeDerivedColumns.has(colId) && locale.minusGlyph === "-" && rendered.startsWith(MINUS) ? `-${rendered.slice(MINUS.length)}` : rendered;
1131
- }, madeNm = /* @__PURE__ */ new Set();
1132
- for (let record of records) {
1133
- if (record.kind !== "calc" || record.state !== "value") continue;
1134
- let baseInput = record.op === "percentDelta($0,$1)" ? record.inputs[1] : void 0, nearZeroBase = baseInput !== void 0 && baseInput.value !== null && !/[1-9]/.test(formatNumber(baseInput.value, baseInput.colId, baseInput.rowId, !1));
1135
- !nearZeroBase && (madeNm.size === 0 || !record.inputs.some((input) => madeNm.has(JSON.stringify([input.rowId, input.colId])))) || (record.raw = null, record.state = "nm", rawState.get(record.rowId)?.set(record.colId, { raw: null, state: "nm" }), madeNm.add(JSON.stringify([record.rowId, record.colId])), nearZeroBase && autoFootnotes.add(options.strings?.nearZeroChange ?? localeStrings(options.locale?.language).nearZeroChange));
1136
- }
1137
- let displayOverride = /* @__PURE__ */ new Map(), overrideAmount = /* @__PURE__ */ new Map();
1138
- for (let col of computedCols) {
1139
- if (!("op" in col.calc) || col.calc.op !== "share") continue;
1140
- let spec = specs.get(col.id);
1141
- reconcileShares(col.id, spec);
1142
- }
1143
- function reconcileShares(colId, spec) {
1144
- let entries = [
1145
- ...leafRows.map((r) => ({ r, s: rawState.get(r.id).get(colId), shown: !0 })),
1146
- ...hiddenLeaves.map(([id, h]) => ({ r: { id }, s: h.states.get(colId), shown: !1 }))
1147
- ].filter((e) => e.s?.state === "value" && typeof e.s.raw == "number"), LAST = Number.MAX_SAFE_INTEGER;
1148
- if (entries.sort((a, b) => (folded.leafOrder.get(a.r.id) ?? LAST) - (folded.leafOrder.get(b.r.id) ?? LAST)), entries.length !== leafRows.length + hiddenLeaves.length || entries.length === 0) return;
1149
- let decimals = spec.decimals ?? 1, unit = Math.pow(10, -decimals), floors = entries.map((e) => Math.floor(e.s.raw / unit) * unit), remainders = entries.map((e, i) => e.s.raw - floors[i]), deficit = Math.round((100 - floors.reduce((a, b) => a + b, 0)) / unit), ownPrecision = entries.map((e) => {
1150
- let cellSpec = cellSpecs.get(e.r.id)?.get(colId);
1151
- return cellSpec !== void 0 && (cellSpec.decimals ?? 1) !== decimals;
1152
- }), order = entries.map((_, i) => i).filter((i) => !ownPrecision[i]).sort((a, b) => remainders[b] - remainders[a] || a - b), adjusted = /* @__PURE__ */ new Set();
1153
- for (let i of order) {
1154
- if (deficit <= 0) break;
1155
- adjusted.add(i), deficit--;
1156
- }
1157
- entries.forEach((e, i) => {
1158
- if (ownPrecision[i] || !e.shown) return;
1159
- let shown = floors[i] + (adjusted.has(i) ? unit : 0), cellSpec = cellSpecs.get(e.r.id)?.get(colId);
1160
- displayOverride.set(tableCellKey(e.r.id, colId), shown === 0 && e.s.raw > 0 && spec.automatic && !cellSpec ? `<${formatNumber(unit, colId)}` : formatNumber(shown, colId, e.r.id)), overrideAmount.set(tableCellKey(e.r.id, colId), shown), adjusted.has(i) && Math.abs(shown - e.s.raw) > 1e-9 && records.push({
1161
- rowId: e.r.id,
1162
- colId,
1163
- op: "share-reconcile",
1164
- // The display UNIT is half the calculation: this record says "the
1165
- // exact share, rounded up by one unit". With only the exact share in
1166
- // the receipt, the adjustment could not be checked against anything.
1167
- inputs: [
1168
- { rowId: e.r.id, colId, value: e.s.raw },
1169
- { rowId: SHARE_UNIT_ROW_ID, colId, value: unit }
1170
- ],
1171
- raw: shown,
1172
- state: "value",
1173
- displayed: formatNumber(shown, colId, e.r.id),
1174
- kind: "rounding-adjustment"
1175
- });
1176
- });
1177
- }
1178
- for (let col of [...valueCols, ...computedCols]) {
1179
- if (col.kind === "computed" ? calcYieldsPoints(col.calc) : col.percentScale === "points") continue;
1180
- let spec = col.kind === "computed" || col.format ? specs.get(col.id) : void 0;
1181
- if (!spec || !(spec.suffix ?? "").includes("%")) continue;
1182
- let vals = flat.map((r) => rawState.get(r.id).get(col.id)).filter((s) => !!s && typeof s.raw == "number");
1183
- vals.length > 0 && vals.every((v) => Math.abs(v.raw) <= 1.5) && warnings.push({
1184
- code: "percent-scale-suspect",
1185
- severity: "warn",
1186
- message: col.kind === "computed" ? `column '${col.id}': the format is percent but every computed value is within \xB11.5 \u2014 percent columns carry POINTS, and a ratio calc yields a FRACTION (0.42 renders "0.4%"); multiply by 100 (mul(div(a,b), lit 100)) or drop the '%'` : `column '${col.id}': every value is within \xB11.5 but the format is percent \u2014 percent values are authored in POINTS (6.2 \u2192 "6.2%"); these look like fractions`,
1187
- ...col.kind === "value" ? { suggest: "values already in points: set percentScale: 'points' on the column" } : {}
1188
- });
1189
- }
1190
- for (let row of flat) {
1191
- let rowSpec = rowSpecs.get(row.id);
1192
- if (!rowSpec || row.calc || !(rowSpec.suffix ?? "").includes("%")) continue;
1193
- let vals = valueCols.filter((col) => !ownFormatColumns.has(col.id) && col.percentScale !== "points").map((col) => rawState.get(row.id).get(col.id)).filter((s) => !!s && typeof s.raw == "number");
1194
- vals.length > 0 && vals.every((v) => Math.abs(v.raw) <= 1.5) && warnings.push({
1195
- code: "percent-scale-suspect",
1246
+ let unitByCol = /* @__PURE__ */ new Map(), rollsOff = (colId, spec) => spec.magnitude !== "none" && flat.some((row) => {
1247
+ if (rowSpecs.has(row.id) && (row.calc !== void 0 || row.inline === !0 || !ownFormatColumns.has(colId)) || cellSpecs.get(row.id)?.has(colId)) return !1;
1248
+ let raw = rawState2.get(row.id)?.get(colId)?.raw;
1249
+ return typeof raw == "number" && raw !== 0 && effectiveScale(Math.abs(raw), spec).magnitude !== spec.magnitude;
1250
+ }), lettersInCells = /* @__PURE__ */ new Set();
1251
+ for (let col of [...valueCols, ...computedCols]) {
1252
+ let spec = specs.get(col.id);
1253
+ !rowFormattedColumns.has(col.id) && (rollsOff(col.id, spec) || flat.some((row) => cellNamesOtherUnit(row.id, col.id, spec))) && lettersInCells.add(col.id), unitByCol.set(col.id, rowFormattedColumns.has(col.id) || lettersInCells.has(col.id) ? null : unitOfSpec(spec));
1254
+ }
1255
+ let headerUnitFor = (id) => unitByCol.get(id) ?? (rowFormattedColumns.has(id) ? headUnit ?? null : null), headerScaledFor = (id) => unitByCol.get(id) != null ? specs.get(id).magnitude !== "none" : rowFormattedColumns.has(id) && headUnit !== void 0 && figureRows.some((row) => (rowSpecs.get(row.id)?.magnitude ?? "none") !== "none"), distinctUnits = [...new Set([...unitByCol.keys()].map(headerUnitFor).filter((u) => u !== null))], candidateUnit = distinctUnits.length === 1 && [...valueCols, ...computedCols].every((col) => {
1256
+ let kind = specUnitKind(specs.get(col.id));
1257
+ return kind === "percent" || kind === "pp" || headerUnitFor(col.id) === distinctUnits[0];
1258
+ }) ? distinctUnits[0] : void 0, frameCarriesUnit = unitPrinted({
1259
+ subtitle: resolveSubtitle(options2.subtitle),
1260
+ unit: candidateUnit,
1261
+ unitShown: options2.unitShown
1262
+ }), authoredUnit = typeof options2.unit == "string" ? options2.unit.trim() : void 0, scaleWords = (authoredUnit?.split(/[\s$€£¥()]+/) ?? []).filter((word) => Object.values(MAGNITUDE_LABEL).some((label) => label !== "" && sameUnit(word, label))), bareScale = candidateUnit !== void 0 && [...[...valueCols, ...computedCols].map((col) => specs.get(col.id)), ...rowSpecs.values()].every((spec) => specUnitKind(spec) !== "number" || spec.prefix.trim() === "" && spec.suffix.trim() === ""), carriesScale = scaleWords.some((word) => sameUnit(word, candidateUnit ?? "")), composes = bareScale && !!authoredUnit && (carriesScale || scaleWords.length === 0 && /^(?:[A-Z]{3}|\p{Sc})$/u.test(authoredUnit)), composedUnit = composes ? carriesScale ? authoredUnit : `${authoredUnit} ${candidateUnit}` : candidateUnit, uniformUnit = composedUnit && frameCarriesUnit ? composedUnit : null;
1263
+ uniformUnit !== null && options2.unit !== void 0 && options2.unit !== uniformUnit && !composes && warnings2.push({
1264
+ code: "table-unit-overridden",
1196
1265
  severity: "warn",
1197
- message: `row '${row.id}': every value is within \xB11.5 but the row format is percent \u2014 percent values are authored in POINTS (6.2 \u2192 "6.2%"); these look like fractions`
1266
+ field: ["options", "unit"],
1267
+ message: `options.unit '${options2.unit}' is not printed. The table prints '${uniformUnit}' because its column formats resolve that shared unit.`,
1268
+ suggest: "Remove options.unit so the column formats supply the unit.",
1269
+ fix: [{ op: "remove", path: "/options/unit" }]
1198
1270
  });
1199
- }
1200
- for (let row of flat) {
1201
- if (row.role === "section") continue;
1202
- let kids = summandsOf(row.id);
1203
- if (kids.length !== 0)
1204
- for (let col of valueCols) {
1205
- if (aggregateFor(col, row) !== "sum") continue;
1206
- let spec = specFor(col.id, row.id), p = rawState.get(row.id).get(col.id);
1207
- if (p.state !== "value" || typeof p.raw != "number") continue;
1208
- let childRaw = kids.map((k) => rawState.get(k.id).get(col.id)).filter((s) => s.state === "value" && typeof s.raw == "number").map((s, i) => s.raw * signTo(kids[i], row.id));
1209
- if (childRaw.length !== kids.length) continue;
1210
- let rawSum = childRaw.reduce((a, b) => a + b, 0), rawGap = p.raw - rawSum, noise = floatNoise(p.raw, rawSum), parentShown = roundedNumber(p.raw, spec), childShown = childRaw.map((value, i) => roundedNumber(value, specFor(col.id, kids[i].id))), displayGap = parentShown - childShown.reduce((a, b) => a + b, 0), roundingGap = Math.abs(rawGap) > noise ? displayGap - rawGap : displayGap, inputs = [
1211
- { rowId: row.id, colId: col.id, value: p.raw, role: "raw" },
1212
- { rowId: row.id, colId: col.id, value: parentShown, role: "displayed" },
1213
- ...kids.flatMap((k, i) => [
1214
- { rowId: k.id, colId: col.id, value: childRaw[i], role: "raw" },
1215
- { rowId: k.id, colId: col.id, value: childShown[i], role: "displayed" }
1216
- ])
1217
- ], unitOf2 = (candidate) => Math.pow(10, -candidate.decimals) * MAGNITUDE_DIVISOR[candidate.magnitude], displayUnit = Math.min(unitOf2(spec), minOf(kids.map((k) => unitOf2(specFor(col.id, k.id)))));
1218
- Math.abs(roundingGap) > displayUnit * 0.5 && (autoFootnotes.add(ROUNDING_FOOTNOTE), records.push({
1219
- rowId: row.id,
1220
- colId: col.id,
1221
- op: "rounding-gap",
1222
- inputs,
1223
- raw: roundingGap,
1271
+ let rowOverridesColumn = (rowId) => {
1272
+ let row = rowById.get(rowId);
1273
+ return row?.calc !== void 0 || row?.inline === !0;
1274
+ }, specFor = (colId, rowId) => {
1275
+ let cellSpec = rowId ? cellSpecs.get(rowId)?.get(colId) : void 0;
1276
+ if (cellSpec) return cellSpec;
1277
+ let rowSpec = rowId ? rowSpecs.get(rowId) : void 0;
1278
+ return rowSpec && (rowOverridesColumn(rowId) || !ownFormatColumns.has(colId)) ? groupCellSpecs.get(rowId)?.get(colId) ?? rowSpec : specs.get(colId);
1279
+ }, displayFormats = /* @__PURE__ */ new Map(), displayFormat = (base, decimals, automatic, hoisted, clearCurrency = !1) => {
1280
+ let variants = displayFormats.get(base);
1281
+ variants || displayFormats.set(base, variants = /* @__PURE__ */ new Map());
1282
+ let key = `${decimals}:${automatic}:${hoisted}:${clearCurrency}`, format = variants.get(key);
1283
+ if (!format) {
1284
+ let spec = {
1285
+ ...base,
1286
+ decimals,
1287
+ automatic,
1288
+ ...clearCurrency ? { currencyWhole: void 0 } : {},
1289
+ ...hoisted ? { prefix: "", suffix: "", magnitudeInAffix: !0 } : {}
1290
+ };
1291
+ variants.set(key, format = compileNumberFormat(spec));
1292
+ }
1293
+ return format;
1294
+ }, formatNumber = (raw, colId, rowId, lift = !0) => {
1295
+ let cellSpec = rowId ? cellSpecs.get(rowId)?.get(colId) : void 0, rowSpec = rowId ? rowSpecs.get(rowId) : void 0, rowPath = rowSpec !== void 0 && (rowOverridesColumn(rowId) || !ownFormatColumns.has(colId)), base = rowPath ? rowSpec : specs.get(colId);
1296
+ if (cellSpec && !sameUnit2(cellSpec, base)) return displayFormat(cellSpec, cellSpec.decimals, lift ? cellSpec.automatic : !1, !1)(raw);
1297
+ let decimals = cellSpec?.decimals ?? (rowPath ? groupCellSpecs.get(rowId)?.get(colId)?.decimals : void 0) ?? base.decimals;
1298
+ if (rowPath) {
1299
+ if (raw === 0 && lift && !cellSpec && groupOf(rowById.get(rowId)) !== void 0) return "0";
1300
+ let hoisted = rowId !== void 0 && hoistedRowUnits.has(rowId), automatic2 = lift && (cellSpec ? cellSpec.automatic : rowSpec.automatic);
1301
+ return displayFormat(rowSpec, decimals, automatic2, hoisted)(raw);
1302
+ }
1303
+ let automatic = lift ? cellSpec ? cellSpec.automatic : base.automatic : !1, rendered = displayFormat(base, decimals, automatic, unitByCol.get(colId) != null, cellSpec !== void 0)(raw);
1304
+ return localeDerivedColumns.has(colId) && locale.minusGlyph === "-" && rendered.startsWith(MINUS) ? `-${rendered.slice(MINUS.length)}` : rendered;
1305
+ }, madeNm = /* @__PURE__ */ new Set();
1306
+ for (let record of records2) {
1307
+ if (record.kind !== "calc" || record.state !== "value") continue;
1308
+ let baseInput = record.op === "percentDelta($0,$1)" ? record.inputs[1] : void 0, nearZeroBase = baseInput !== void 0 && baseInput.value !== null && !/[1-9]/.test(formatNumber(baseInput.value, baseInput.colId, baseInput.rowId, !1));
1309
+ !nearZeroBase && (madeNm.size === 0 || !record.inputs.some((input) => madeNm.has(JSON.stringify([input.rowId, input.colId])))) || (record.raw = null, record.state = "nm", rawState2.get(record.rowId)?.set(record.colId, { raw: null, state: "nm" }), madeNm.add(JSON.stringify([record.rowId, record.colId])), nearZeroBase && autoFootnotes2.add(options2.strings?.nearZeroChange ?? localeStrings(options2.locale?.language).nearZeroChange));
1310
+ }
1311
+ let displayOverride = /* @__PURE__ */ new Map(), overrideAmount = /* @__PURE__ */ new Map();
1312
+ for (let col of computedCols) {
1313
+ if (!("op" in col.calc) || col.calc.op !== "share") continue;
1314
+ let spec = specs.get(col.id);
1315
+ reconcileShares(col.id, spec);
1316
+ }
1317
+ function reconcileShares(colId, spec) {
1318
+ let entries = [
1319
+ ...leafRows.map((r) => ({ r, s: rawState2.get(r.id).get(colId), shown: !0 })),
1320
+ ...hiddenLeaves.map(([id, h]) => ({ r: { id }, s: h.states.get(colId), shown: !1 }))
1321
+ ].filter((e) => e.s?.state === "value" && typeof e.s.raw == "number"), LAST = Number.MAX_SAFE_INTEGER;
1322
+ if (entries.sort((a, b) => (folded.leafOrder.get(a.r.id) ?? LAST) - (folded.leafOrder.get(b.r.id) ?? LAST)), entries.length !== leafRows.length + hiddenLeaves.length || entries.length === 0) return;
1323
+ let decimals = spec.decimals ?? 1, unit = Math.pow(10, -decimals), floors = entries.map((e) => Math.floor(e.s.raw / unit) * unit), remainders = entries.map((e, i) => e.s.raw - floors[i]), deficit = Math.round((100 - floors.reduce((a, b) => a + b, 0)) / unit), ownPrecision = entries.map((e) => {
1324
+ let cellSpec = cellSpecs.get(e.r.id)?.get(colId);
1325
+ return cellSpec !== void 0 && (cellSpec.decimals ?? 1) !== decimals;
1326
+ }), order = entries.map((_, i) => i).filter((i) => !ownPrecision[i]).sort((a, b) => remainders[b] - remainders[a] || a - b), adjusted = /* @__PURE__ */ new Set();
1327
+ for (let i of order) {
1328
+ if (deficit <= 0) break;
1329
+ adjusted.add(i), deficit--;
1330
+ }
1331
+ entries.forEach((e, i) => {
1332
+ if (ownPrecision[i] || !e.shown) return;
1333
+ let shown = floors[i] + (adjusted.has(i) ? unit : 0), cellSpec = cellSpecs.get(e.r.id)?.get(colId);
1334
+ displayOverride.set(tableCellKey(e.r.id, colId), shown === 0 && e.s.raw > 0 && spec.automatic && !cellSpec ? `<${formatNumber(unit, colId)}` : formatNumber(shown, colId, e.r.id)), overrideAmount.set(tableCellKey(e.r.id, colId), shown), adjusted.has(i) && Math.abs(shown - e.s.raw) > 1e-9 && records2.push({
1335
+ rowId: e.r.id,
1336
+ colId,
1337
+ op: "share-reconcile",
1338
+ // The display UNIT is half the calculation: this record says "the
1339
+ // exact share, rounded up by one unit". With only the exact share in
1340
+ // the receipt, the adjustment could not be checked against anything.
1341
+ inputs: [
1342
+ { rowId: e.r.id, colId, value: e.s.raw },
1343
+ { rowId: SHARE_UNIT_ROW_ID, colId, value: unit }
1344
+ ],
1345
+ raw: shown,
1224
1346
  state: "value",
1225
- displayed: "",
1347
+ displayed: formatNumber(shown, colId, e.r.id),
1226
1348
  kind: "rounding-adjustment"
1227
- }));
1228
- }
1229
- }
1230
- for (let column of columns)
1231
- (column.kind === "value" || column.kind === "computed") && column.align === "left" && warnings.push({
1232
- code: "align-override-suspect",
1233
- severity: "warn",
1234
- message: `column '${column.id}' forces a numeric column left \u2014 right alignment is the comparison-safe default`,
1235
- owner: { colId: column.id }
1236
- });
1237
- let resolvedColumns = columns.map((c) => ({
1238
- id: c.id,
1239
- kind: c.kind,
1240
- label: c.label ?? (c.kind === "rowLabel" ? "" : c.id),
1241
- ...c.subLabel === void 0 ? {} : { subLabel: c.subLabel },
1242
- format: c.kind === "value" || c.kind === "computed" ? formatExamples.get(c.id) : c.kind === "date" ? c.format : void 0,
1243
- scenario: c.kind === "value" ? c.scenario : void 0,
1244
- polarity: c.kind === "value" || c.kind === "computed" ? c.polarity : void 0,
1245
- aggregate: c.kind === "value" ? c.aggregate ?? (nonAdditiveFormat(c.format) ? "none" : "sum") : "none",
1246
- groupId: data.columnGroups?.find((g) => g.columns.includes(c.id))?.id,
1247
- toggleGroup: toggleResolution.membership.get(c.id),
1248
- width: c.width,
1249
- maxWidth: c.kind === "rowLabel" ? c.maxWidth : void 0,
1250
- maxTextWidth: c.kind === "rowLabel" ? c.maxTextWidth : void 0,
1251
- wrap: c.kind === "text" ? c.wrap : void 0,
1252
- statusMark: c.kind === "status" && c.mark === "square" ? "square" : void 0,
1253
- unitLabel: uniformUnit === null && (c.kind === "value" || c.kind === "computed") ? headerUnitFor(c.id) ?? void 0 : void 0,
1254
- ...uniformUnit === null && (c.kind === "value" || c.kind === "computed") && headerUnitFor(c.id) !== null && headerScaledFor(c.id) ? { unitScaled: !0 } : {},
1255
- ...lettersInCells.has(c.id) ? { magnitudeInCells: !0 } : {},
1256
- encoding: c.kind === "encoding" ? c.encoding : void 0,
1257
- cellEncoding: resolveCellEncoding(encodingFor(options.encodings, c.id), specs.get(c.id)?.suffix.includes("%") === !0),
1258
- // The preset's own two column decisions: a benchmark's first
1259
- // column is the subject and carries the header's weight, a receipts
1260
- // table's dates sit under each other on the right.
1261
- emphasis: c.emphasis ?? (c.kind === "rowLabel" ? language.labelEmphasis : void 0),
1262
- ...c.band === void 0 ? {} : { band: c.band },
1263
- ...c.noteLine === void 0 ? {} : { noteLine: c.noteLine },
1264
- // A cohort grid centres its figures: every cell in a period column is
1265
- // the same two or three digits, and a right edge would draw a ragged
1266
- // column of gaps. A column that names its own alignment, the
1267
- // cohort size beside the label, keeps it.
1268
- align: c.align ?? (c.kind === "value" || c.kind === "computed" ? isCohortDensity(options.density ?? "regular") ? "center" : "right" : c.kind === "status" ? "center" : c.kind === "date" && language.datesRight ? "right" : "left")
1269
- })), driverToneMode = options.driverTones ?? "grouped";
1270
- function driverToneOf(row) {
1271
- return driverToneMode !== "grouped" ? driverToneMode === "always" : row.parentId !== null && flatById.get(row.parentId)?.role !== "section";
1272
- }
1273
- function memoIndentStep(row) {
1274
- if (row.relation !== "ofWhich" || row.kind !== void 0 || row.parentId === null) return;
1275
- let siblings = treeChildrenOf.get(row.parentId) ?? [];
1276
- if (!siblings.slice(0, siblings.findIndex((sibling) => sibling.id === row.id)).some((sibling) => sibling.relation !== "ofWhich")) return;
1277
- let parentStep = ladderStep(flatById.get(row.parentId), flatById, levelOffset);
1278
- return parentStep < ladderStep(row, flatById, levelOffset) ? parentStep : void 0;
1279
- }
1280
- let resolvedRows = flat.map((row) => {
1281
- let cells = emptyIdRecord();
1282
- for (let col of columns)
1283
- cells[col.id] = resolveCell(row, col);
1284
- let hasChildren = (treeChildrenOf.get(row.id) ?? []).length > 0, indentStep = memoIndentStep(row);
1285
- return {
1286
- id: row.id,
1287
- label: row.label,
1288
- ...row.parentId === null ? {} : { parentId: row.parentId },
1289
- hasChildren,
1290
- ...hasChildren ? { defaultExpanded: expansion.get(row.id) } : {},
1291
- level: row.level,
1292
- step: ladderStep(row, flatById, levelOffset),
1293
- ...indentStep === void 0 ? {} : { indentStep },
1294
- ...row.kind === void 0 ? {} : { kind: row.kind },
1295
- ...row.kind === "driver" && driverToneOf(row) ? { driverTone: !0 } : {},
1296
- ...row.sign === void 0 ? {} : { sign: row.sign },
1297
- ...row.final === void 0 ? {} : { final: row.final },
1298
- ...options.signs === "operators" ? { operator: row.sign === -1 ? "\u2212" : row.kind === "result" ? "=" : row.operator } : {},
1299
- ...row.divider === !0 ? { divider: !0 } : {},
1300
- role: row.role,
1301
- relation: row.relation,
1302
- order: row.order,
1303
- ...row.polarity === void 0 ? {} : { polarity: row.polarity },
1304
- ...row.inline === !0 ? { inline: !0, inlineGroup: row.inlineGroup ?? row.id } : {},
1305
- highlightTone: highlightedRows.has(row.id) ? rowHighlightTone(cells) : void 0,
1306
- // A forced magnitude wins: it is a claim about the whole table, and
1307
- // the letter it hoists out of the cells has to be the one the label
1308
- // prints. Without one the author's own affix stands.
1309
- ...hoistedRowUnits.has(row.id) ? headUnit === void 0 ? { unitAffix: row.kind === "member" && row.unitAffix ? `${row.unitAffix.split(",")[0]}, ${hoistedRowUnits.get(row.id)}` : hoistedRowUnits.get(row.id) } : {} : row.unitAffix === void 0 ? {} : { unitAffix: row.unitAffix },
1310
- ...row.spacer === void 0 ? {} : { spacer: row.spacer },
1311
- ...hasChildren && row.foldable === !1 ? { foldable: !1 } : {},
1312
- ...row.badge === void 0 ? {} : { badge: { text: row.badge.text, tone: row.badge.tone ?? "neutral" } },
1313
- cells
1314
- };
1315
- });
1316
- {
1317
- let resolvedById = new Map(resolvedRows.map((row) => [row.id, row]));
1318
- for (let [parentId, list] of childrenOf) {
1319
- if (parentId === null) continue;
1320
- let lines = list.filter((child) => child.inline === !0).map((child) => resolvedById.get(child.id));
1321
- lines.length > 0 && (resolvedById.get(parentId).inlineRows = lines);
1322
- }
1323
- }
1324
- function judgementTone(tone, strong) {
1325
- return options.judgements === "exceptions" && (tone === "warn" || tone === "good" && !strong) ? "neutral" : tone;
1326
- }
1327
- function blankInputs(row, col) {
1328
- let calc = row.calc ?? (col.kind === "computed" ? col.calc : void 0);
1329
- if (calc === void 0) return !1;
1330
- let gaps = calcRefs(calc).flatMap((ref) => {
1331
- let rowId = typeof ref == "string" ? row.id : ref.row, colId = typeof ref == "string" ? ref : ref.col ?? (ref.previous ? previousColumnInGroup(data.columnGroups ?? [], col.id) : col.id);
1332
- if (colId === null) return [];
1333
- let state = rawState.get(rowId)?.get(colId);
1334
- return state !== void 0 && state.state === "missing" ? [{ rowId, colId }] : [];
1335
- });
1336
- return gaps.length > 0 && gaps.every(({ rowId, colId }) => {
1337
- let input = flatById.get(rowId), cell = input?.cells[colId];
1338
- return ((isCellObject(cell) ? cell.missing : void 0) ?? input?.missing) === "blank";
1349
+ });
1350
+ });
1351
+ }
1352
+ for (let col of [...valueCols, ...computedCols]) {
1353
+ if (col.kind === "computed" ? calcYieldsPoints(col.calc) : col.percentScale === "points") continue;
1354
+ let spec = col.kind === "computed" || col.format ? specs.get(col.id) : void 0;
1355
+ if (!spec || !(spec.suffix ?? "").includes("%")) continue;
1356
+ let vals = flat.map((r) => rawState2.get(r.id).get(col.id)).filter((s) => !!s && typeof s.raw == "number");
1357
+ vals.length > 0 && vals.every((v) => Math.abs(v.raw) <= 1.5) && warnings2.push({
1358
+ code: "percent-scale-suspect",
1359
+ severity: "warn",
1360
+ message: col.kind === "computed" ? `column '${col.id}': the format is percent but every computed value is within \xB11.5 \u2014 percent columns carry POINTS, and a ratio calc yields a FRACTION (0.42 renders "0.4%"); multiply by 100 (mul(div(a,b), lit 100)) or drop the '%'` : `column '${col.id}': every value is within \xB11.5 but the format is percent \u2014 percent values are authored in POINTS (6.2 \u2192 "6.2%"); these look like fractions`,
1361
+ ...col.kind === "value" ? { suggest: "values already in points: set percentScale: 'points' on the column" } : {}
1362
+ });
1363
+ }
1364
+ for (let row of flat) {
1365
+ let rowSpec = rowSpecs.get(row.id);
1366
+ if (!rowSpec || row.calc || !(rowSpec.suffix ?? "").includes("%")) continue;
1367
+ let vals = valueCols.filter((col) => !ownFormatColumns.has(col.id) && col.percentScale !== "points").map((col) => rawState2.get(row.id).get(col.id)).filter((s) => !!s && typeof s.raw == "number");
1368
+ vals.length > 0 && vals.every((v) => Math.abs(v.raw) <= 1.5) && warnings2.push({
1369
+ code: "percent-scale-suspect",
1370
+ severity: "warn",
1371
+ message: `row '${row.id}': every value is within \xB11.5 but the row format is percent \u2014 percent values are authored in POINTS (6.2 \u2192 "6.2%"); these look like fractions`
1372
+ });
1373
+ }
1374
+ for (let row of flat) {
1375
+ if (row.role === "section") continue;
1376
+ let kids = summandsOf(row.id);
1377
+ if (kids.length !== 0)
1378
+ for (let col of valueCols) {
1379
+ if (aggregateFor(col, row) !== "sum") continue;
1380
+ let spec = specFor(col.id, row.id), p = rawState2.get(row.id).get(col.id);
1381
+ if (p.state !== "value" || typeof p.raw != "number") continue;
1382
+ let childRaw = kids.map((k) => rawState2.get(k.id).get(col.id)).filter((s) => s.state === "value" && typeof s.raw == "number").map((s, i) => s.raw * signTo(kids[i], row.id));
1383
+ if (childRaw.length !== kids.length) continue;
1384
+ let rawSum = childRaw.reduce((a, b) => a + b, 0), rawGap = p.raw - rawSum, noise = floatNoise(p.raw, rawSum), parentShown = roundedNumber(p.raw, spec), childShown = childRaw.map((value, i) => roundedNumber(value, specFor(col.id, kids[i].id))), displayGap = parentShown - childShown.reduce((a, b) => a + b, 0), roundingGap = Math.abs(rawGap) > noise ? displayGap - rawGap : displayGap, inputs = [
1385
+ { rowId: row.id, colId: col.id, value: p.raw, role: "raw" },
1386
+ { rowId: row.id, colId: col.id, value: parentShown, role: "displayed" },
1387
+ ...kids.flatMap((k, i) => [
1388
+ { rowId: k.id, colId: col.id, value: childRaw[i], role: "raw" },
1389
+ { rowId: k.id, colId: col.id, value: childShown[i], role: "displayed" }
1390
+ ])
1391
+ ], unitOf2 = (candidate) => Math.pow(10, -candidate.decimals) * MAGNITUDE_DIVISOR[candidate.magnitude], displayUnit = Math.min(unitOf2(spec), minOf(kids.map((k) => unitOf2(specFor(col.id, k.id)))));
1392
+ Math.abs(roundingGap) > displayUnit * 0.5 && (autoFootnotes2.add(ROUNDING_FOOTNOTE), records2.push({
1393
+ rowId: row.id,
1394
+ colId: col.id,
1395
+ op: "rounding-gap",
1396
+ inputs,
1397
+ raw: roundingGap,
1398
+ state: "value",
1399
+ displayed: "",
1400
+ kind: "rounding-adjustment"
1401
+ }));
1402
+ }
1403
+ }
1404
+ for (let column of columns)
1405
+ (column.kind === "value" || column.kind === "computed") && column.align === "left" && warnings2.push({
1406
+ code: "align-override-suspect",
1407
+ severity: "warn",
1408
+ message: `column '${column.id}' forces a numeric column left \u2014 right alignment is the comparison-safe default`,
1409
+ owner: { colId: column.id }
1410
+ });
1411
+ let resolvedColumns = columns.map((c) => ({
1412
+ id: c.id,
1413
+ kind: c.kind,
1414
+ label: c.label ?? (c.kind === "rowLabel" ? "" : c.id),
1415
+ ...c.subLabel === void 0 ? {} : { subLabel: c.subLabel },
1416
+ format: c.kind === "value" || c.kind === "computed" ? formatExamples.get(c.id) : c.kind === "date" ? c.format : void 0,
1417
+ scenario: c.kind === "value" ? c.scenario : void 0,
1418
+ polarity: c.kind === "value" || c.kind === "computed" ? c.polarity : void 0,
1419
+ aggregate: c.kind === "value" ? c.aggregate ?? (nonAdditiveFormat(c.format) ? "none" : "sum") : "none",
1420
+ groupId: data.columnGroups?.find((g) => g.columns.includes(c.id))?.id,
1421
+ toggleGroup: toggleResolution.membership.get(c.id),
1422
+ width: c.width,
1423
+ maxWidth: c.kind === "rowLabel" ? c.maxWidth : void 0,
1424
+ maxTextWidth: c.kind === "rowLabel" ? c.maxTextWidth : void 0,
1425
+ wrap: c.kind === "text" ? c.wrap : void 0,
1426
+ statusMark: c.kind === "status" && c.mark === "square" ? "square" : void 0,
1427
+ unitLabel: uniformUnit === null && (c.kind === "value" || c.kind === "computed") ? headerUnitFor(c.id) ?? void 0 : void 0,
1428
+ ...uniformUnit === null && (c.kind === "value" || c.kind === "computed") && headerUnitFor(c.id) !== null && headerScaledFor(c.id) ? { unitScaled: !0 } : {},
1429
+ ...lettersInCells.has(c.id) ? { magnitudeInCells: !0 } : {},
1430
+ encoding: c.kind === "encoding" ? c.encoding : void 0,
1431
+ cellEncoding: resolveCellEncoding(encodingFor(options2.encodings, c.id), specs.get(c.id)?.suffix.includes("%") === !0),
1432
+ // The preset's own two column decisions: a benchmark's first
1433
+ // column is the subject and carries the header's weight, a receipts
1434
+ // table's dates sit under each other on the right.
1435
+ emphasis: c.emphasis ?? (c.kind === "rowLabel" ? language.labelEmphasis : void 0),
1436
+ ...c.band === void 0 ? {} : { band: c.band },
1437
+ ...c.noteLine === void 0 ? {} : { noteLine: c.noteLine },
1438
+ ...c.headAlign === void 0 ? {} : { headAlign: c.headAlign },
1439
+ // A cohort grid centres its figures: every cell in a period column is
1440
+ // the same two or three digits, and a right edge would draw a ragged
1441
+ // column of gaps. A column that names its own alignment, the
1442
+ // cohort size beside the label, keeps it.
1443
+ align: c.align ?? (c.kind === "value" || c.kind === "computed" ? isCohortDensity(options2.density ?? "regular") ? "center" : "right" : c.kind === "status" ? "center" : c.kind === "date" && language.datesRight ? "right" : "left")
1444
+ })), driverToneMode = options2.driverTones ?? "grouped";
1445
+ function driverToneOf(row) {
1446
+ return driverToneMode !== "grouped" ? driverToneMode === "always" : row.parentId !== null && flatById.get(row.parentId)?.role !== "section";
1447
+ }
1448
+ function memoIndentStep(row) {
1449
+ if (row.relation !== "ofWhich" || row.kind !== void 0 || row.parentId === null) return;
1450
+ let siblings = treeChildrenOf.get(row.parentId) ?? [];
1451
+ if (!siblings.slice(0, siblings.findIndex((sibling) => sibling.id === row.id)).some((sibling) => sibling.relation !== "ofWhich")) return;
1452
+ let parentStep = ladderStep(flatById.get(row.parentId), flatById, levelOffset);
1453
+ return parentStep < ladderStep(row, flatById, levelOffset) ? parentStep : void 0;
1454
+ }
1455
+ let resolvedRows = flat.map((row) => {
1456
+ let cells = emptyIdRecord();
1457
+ for (let col of columns)
1458
+ cells[col.id] = resolveCell(row, col);
1459
+ let hasChildren = (treeChildrenOf.get(row.id) ?? []).length > 0, indentStep = memoIndentStep(row);
1460
+ return {
1461
+ id: row.id,
1462
+ label: row.label,
1463
+ ...row.parentId === null ? {} : { parentId: row.parentId },
1464
+ hasChildren,
1465
+ ...hasChildren ? { defaultExpanded: expansion.get(row.id) } : {},
1466
+ level: row.level,
1467
+ step: ladderStep(row, flatById, levelOffset),
1468
+ ...indentStep === void 0 ? {} : { indentStep },
1469
+ ...row.kind === void 0 ? {} : { kind: row.kind },
1470
+ ...row.kind === "driver" && driverToneOf(row) ? { driverTone: !0 } : {},
1471
+ ...row.sign === void 0 ? {} : { sign: row.sign },
1472
+ ...row.final === void 0 ? {} : { final: row.final },
1473
+ ...options2.signs === "operators" ? { operator: row.sign === -1 ? "\u2212" : row.kind === "result" ? "=" : row.operator } : {},
1474
+ ...row.divider === !0 ? { divider: !0 } : {},
1475
+ role: row.role,
1476
+ relation: row.relation,
1477
+ order: row.order,
1478
+ ...row.polarity === void 0 ? {} : { polarity: row.polarity },
1479
+ ...row.inline === !0 ? { inline: !0, inlineGroup: row.inlineGroup ?? row.id } : {},
1480
+ highlightTone: highlightedRows.has(row.id) ? rowHighlightTone(cells) : void 0,
1481
+ // A forced magnitude wins: it is a claim about the whole table, and
1482
+ // the letter it hoists out of the cells has to be the one the label
1483
+ // prints. Without one the author's own affix stands.
1484
+ ...hoistedRowUnits.has(row.id) ? headUnit === void 0 ? { unitAffix: row.kind === "member" && row.unitAffix ? `${row.unitAffix.split(",")[0]}, ${hoistedRowUnits.get(row.id)}` : hoistedRowUnits.get(row.id) } : {} : row.unitAffix === void 0 ? {} : { unitAffix: row.unitAffix },
1485
+ ...row.spacer === void 0 ? {} : { spacer: row.spacer },
1486
+ ...hasChildren && row.foldable === !1 ? { foldable: !1 } : {},
1487
+ ...row.badge === void 0 ? {} : { badge: { text: row.badge.text, tone: row.badge.tone ?? "neutral" } },
1488
+ cells
1489
+ };
1339
1490
  });
1340
- }
1341
- function resolveCell(row, col) {
1342
- let authored = row.cells[col.id], obj = isCellObject(authored) ? authored : void 0, missing = obj?.missing ?? row.missing, missingGlyph = missing === void 0 ? tableMissingGlyph : missing === "blank" ? "" : glyphs.missing, base = {
1343
- rowId: row.id,
1344
- colId: col.id,
1345
- kind: col.kind,
1346
- raw: null,
1347
- state: "missing",
1348
- displayed: "",
1349
- tone: judgementTone(obj?.tone ?? "neutral", obj?.strong),
1350
- note: obj?.note,
1351
- href: obj?.href,
1352
- ...obj?.heat === !1 ? { heat: !1 } : {},
1353
- ...obj?.strong === !0 && obj.tone !== void 0 && obj.tone !== "neutral" ? { strong: !0 } : {},
1354
- ...typeof obj?.bar == "number" && Number.isFinite(obj.bar) ? { bar: Math.min(1, Math.max(0, obj.bar)) } : {},
1355
- ...(col.kind === "value" || col.kind === "computed") && obj?.format !== void 0 ? { format: obj.format } : {},
1356
- scenario: col.kind === "value" ? col.scenario : void 0,
1357
- role: row.role,
1358
- relation: row.relation,
1359
- level: row.level
1360
- };
1361
- if (row.role === "section" && col.kind !== "rowLabel")
1362
- return { ...base, state: "na", displayed: "" };
1363
- if (obj?.state && col.kind !== "rowLabel" && col.kind !== "encoding")
1364
- return { ...base, raw: null, state: obj.state, displayed: glyphs[obj.state], tone: "neutral", ...obj.muted === !0 ? { deEmphasized: !0 } : {} };
1365
- switch (col.kind) {
1366
- case "rowLabel":
1367
- return { ...base, raw: row.label, state: "value", displayed: row.label };
1368
- case "value":
1369
- case "computed": {
1370
- let evaluated = rawState.get(row.id).get(col.id), s = evaluated ?? { raw: null, state: "missing" }, displayed, negated = !1;
1371
- if (s.state !== "value" || typeof s.raw != "number") {
1372
- let state = s.state === "value" ? "missing" : s.state, noPreviousColumn = row.calc !== void 0 && JSON.stringify(row.calc).includes('"previous":true') && previousColumnInGroup(data.columnGroups ?? [], col.id) === null, noPreviousValue = state === "na" && previousPlaceholders && noPreviousColumn;
1373
- displayed = state === "missing" && gapWord && missing === void 0 && evaluated !== void 0 && !(noPreviousColumn && noPrevious === "missing") && !blankInputs(row, col) ? glyphs.na : state === "missing" || noPreviousValue ? missingGlyph : glyphs[state];
1374
- } else {
1375
- let relativeChange = (row.inline === !0 || row.calc !== void 0 || col.kind === "computed") && (specUnitKind(specFor(col.id, row.id)) !== "number" || row.calc !== void 0 && calcYieldsPoints(row.calc) || col.kind === "computed" && calcYieldsPoints(col.calc)), negate = (options.signs ?? "signed") === "signed" && row.kind !== "driver" && row.kind !== "result" && !relativeChange && signTo(row, null) === -1 && (col.kind !== "computed" || row.calc !== void 0 || calcFlipsWithInputs(col.calc));
1376
- negated = negate && s.raw !== 0, displayed = (negate ? void 0 : displayOverride.get(tableCellKey(row.id, col.id))) ?? formatNumber(negate && s.raw !== 0 ? -s.raw : s.raw, col.id, row.id), negate && locale.minusGlyph === "-" && (displayed = displayed.replace(MINUS, "-")), s.partial && !(disclosuresShown(options) && partialColumnIds.has(col.id)) && (displayed = `${displayed} ${options.strings?.incomplete ?? localeStrings(options.locale?.language).incomplete}`);
1491
+ {
1492
+ let resolvedById = new Map(resolvedRows.map((row) => [row.id, row]));
1493
+ for (let [parentId, list] of childrenOf2) {
1494
+ if (parentId === null) continue;
1495
+ let lines = list.filter((child) => child.inline === !0).map((child) => resolvedById.get(child.id));
1496
+ lines.length > 0 && (resolvedById.get(parentId).inlineRows = lines);
1497
+ }
1498
+ }
1499
+ function judgementTone(tone, strong) {
1500
+ return options2.judgements === "exceptions" && (tone === "warn" || tone === "good" && !strong) ? "neutral" : tone;
1501
+ }
1502
+ function blankInputs(row, col) {
1503
+ let calc = row.calc ?? (col.kind === "computed" ? col.calc : void 0);
1504
+ if (calc === void 0) return !1;
1505
+ let gaps = calcRefs(calc).flatMap((ref) => {
1506
+ let rowId = typeof ref == "string" ? row.id : ref.row, colId = typeof ref == "string" ? ref : ref.col ?? (ref.previous ? previousColumnInGroup(data.columnGroups ?? [], col.id) : col.id);
1507
+ if (colId === null) return [];
1508
+ let state = rawState2.get(rowId)?.get(colId);
1509
+ return state !== void 0 && state.state === "missing" ? [{ rowId, colId }] : [];
1510
+ });
1511
+ return gaps.length > 0 && gaps.every(({ rowId, colId }) => {
1512
+ let input = flatById.get(rowId), cell = input?.cells[colId];
1513
+ return ((isCellObject(cell) ? cell.missing : void 0) ?? input?.missing) === "blank";
1514
+ });
1515
+ }
1516
+ function resolveCell(row, col) {
1517
+ let authored = row.cells[col.id], obj = isCellObject(authored) ? authored : void 0, missing = obj?.missing ?? row.missing, missingGlyph = missing === void 0 ? tableMissingGlyph : missing === "blank" ? "" : glyphs.missing, base = {
1518
+ rowId: row.id,
1519
+ colId: col.id,
1520
+ kind: col.kind,
1521
+ raw: null,
1522
+ state: "missing",
1523
+ displayed: "",
1524
+ tone: judgementTone(obj?.tone ?? "neutral", obj?.strong),
1525
+ note: obj?.note,
1526
+ href: obj?.href,
1527
+ ...obj?.heat === !1 ? { heat: !1 } : {},
1528
+ ...obj?.strong === !0 && obj.tone !== void 0 && obj.tone !== "neutral" ? { strong: !0 } : {},
1529
+ ...typeof obj?.bar == "number" && Number.isFinite(obj.bar) ? { bar: Math.min(1, Math.max(0, obj.bar)) } : {},
1530
+ ...(col.kind === "value" || col.kind === "computed") && obj?.format !== void 0 ? { format: obj.format } : {},
1531
+ scenario: col.kind === "value" ? col.scenario : void 0,
1532
+ role: row.role,
1533
+ relation: row.relation,
1534
+ level: row.level
1535
+ };
1536
+ if (row.role === "section" && col.kind !== "rowLabel")
1537
+ return { ...base, state: "na", displayed: "" };
1538
+ if (obj?.state && col.kind !== "rowLabel" && col.kind !== "encoding")
1539
+ return { ...base, raw: null, state: obj.state, displayed: glyphs[obj.state], tone: "neutral", ...obj.muted === !0 ? { deEmphasized: !0 } : {} };
1540
+ switch (col.kind) {
1541
+ case "rowLabel":
1542
+ return { ...base, raw: row.label, state: "value", displayed: row.label };
1543
+ case "value":
1544
+ case "computed": {
1545
+ let evaluated = rawState2.get(row.id).get(col.id), s = evaluated ?? { raw: null, state: "missing" }, displayed, negated = !1;
1546
+ if (s.state !== "value" || typeof s.raw != "number") {
1547
+ let state = s.state === "value" ? "missing" : s.state, noPreviousColumn = row.calc !== void 0 && JSON.stringify(row.calc).includes('"previous":true') && previousColumnInGroup(data.columnGroups ?? [], col.id) === null, noPreviousValue = state === "na" && previousPlaceholders && noPreviousColumn;
1548
+ displayed = state === "missing" && gapWord && missing === void 0 && evaluated !== void 0 && !(noPreviousColumn && noPrevious === "missing") && !blankInputs(row, col) ? glyphs.na : state === "missing" || noPreviousValue ? missingGlyph : glyphs[state];
1549
+ } else {
1550
+ let relativeChange = (row.inline === !0 || row.calc !== void 0 || col.kind === "computed") && (specUnitKind(specFor(col.id, row.id)) !== "number" || row.calc !== void 0 && calcYieldsPoints(row.calc) || col.kind === "computed" && calcYieldsPoints(col.calc)), negate = (options2.signs ?? "signed") === "signed" && row.kind !== "driver" && row.kind !== "result" && !relativeChange && signTo(row, null) === -1 && (col.kind !== "computed" || row.calc !== void 0 || calcFlipsWithInputs(col.calc));
1551
+ negated = negate && s.raw !== 0, displayed = (negate ? void 0 : displayOverride.get(tableCellKey(row.id, col.id))) ?? formatNumber(negate && s.raw !== 0 ? -s.raw : s.raw, col.id, row.id), negate && locale.minusGlyph === "-" && (displayed = displayed.replace(MINUS, "-")), s.partial && !(headMarksPartial && partialColumnIds.has(col.id)) && (displayed = `${displayed} ${options2.strings?.incomplete ?? localeStrings(options2.locale?.language).incomplete}`);
1552
+ }
1553
+ let band = obj?.bands !== void 0 && s.state === "value" && typeof s.raw == "number" ? bandFor(s.raw, obj.bands) : void 0, bandIndex = band === void 0 ? -1 : obj.bands.indexOf(band), tone = obj?.tone ?? band?.tone ?? "neutral", deEmphasized, judgmentRow = row.relation === "additive" || row.calc !== void 0 || row.inline === !0 && row.polarity !== void 0, polarity = col.polarity !== void 0 ? row.polarity ?? col.polarity : row.calc !== void 0 || row.inline === !0 || specFor(col.id, row.id).signed ? row.polarity : void 0;
1554
+ if (s.state === "value" && typeof s.raw == "number" && judgmentRow) {
1555
+ if (polarity && !obj?.tone && band === void 0 && roundedNumber(s.raw, specFor(col.id, row.id)) !== 0) {
1556
+ let goodSign = polarity === "higherIsBetter" ? 1 : -1;
1557
+ tone = Math.sign(s.raw) === goodSign ? "good" : "bad";
1558
+ let measure = row.polarity === void 0 ? col.label ?? col.id : row.inline === !0 && row.parentId !== null ? flatById.get(row.parentId)?.label ?? row.label : row.label;
1559
+ (polarity === "lowerIsBetter" ? lowerJudged : higherJudged).add(measure);
1560
+ }
1561
+ let mat = col.materiality, threshold = specs.get(col.id).suffix.includes("%") ? mat?.pct : mat?.abs;
1562
+ threshold !== void 0 && Math.abs(s.raw) < threshold && (deEmphasized = !0, tone = "neutral");
1563
+ }
1564
+ obj?.muted === !0 && (deEmphasized = !0, tone = "neutral"), tone = judgementTone(tone, obj?.strong);
1565
+ let reconciled = overrideAmount.get(tableCellKey(row.id, col.id)), zero = tone === "neutral" && !deEmphasized && s.state === "value" && typeof s.raw == "number" && (reconciled !== void 0 ? Math.abs(reconciled) < 1e-9 : roundedNumber(s.raw, specFor(col.id, row.id)) === 0);
1566
+ return {
1567
+ ...base,
1568
+ raw: s.raw,
1569
+ state: s.state,
1570
+ displayed,
1571
+ tone,
1572
+ deEmphasized,
1573
+ polarity,
1574
+ ...zero ? { zero: !0 } : {},
1575
+ ...negated ? { negated: !0 } : {},
1576
+ ...band === void 0 ? {} : { band: { to: band.to, ...bandIndex > 0 ? { from: obj.bands[bandIndex - 1].to } : {}, ...band.label === void 0 ? {} : { label: band.label } } }
1577
+ };
1377
1578
  }
1378
- let band = obj?.bands !== void 0 && s.state === "value" && typeof s.raw == "number" ? bandFor(s.raw, obj.bands) : void 0, bandIndex = band === void 0 ? -1 : obj.bands.indexOf(band), tone = obj?.tone ?? band?.tone ?? "neutral", deEmphasized, judgmentRow = row.relation === "additive" || row.calc !== void 0 || row.inline === !0 && row.polarity !== void 0, polarity = col.polarity !== void 0 ? row.polarity ?? col.polarity : row.calc !== void 0 || row.inline === !0 || specFor(col.id, row.id).signed ? row.polarity : void 0;
1379
- if (s.state === "value" && typeof s.raw == "number" && judgmentRow) {
1380
- if (polarity && !obj?.tone && band === void 0 && roundedNumber(s.raw, specFor(col.id, row.id)) !== 0) {
1381
- let goodSign = polarity === "higherIsBetter" ? 1 : -1;
1382
- tone = Math.sign(s.raw) === goodSign ? "good" : "bad";
1383
- let measure = row.polarity === void 0 ? col.label ?? col.id : row.inline === !0 && row.parentId !== null ? flatById.get(row.parentId)?.label ?? row.label : row.label;
1384
- (polarity === "lowerIsBetter" ? lowerJudged : higherJudged).add(measure);
1579
+ case "status": {
1580
+ let given = typeof authored == "number" ? authored : obj?.v, written = typeof authored == "string" ? authored : typeof given == "string" ? given : null, v = written;
1581
+ if (typeof given == "number")
1582
+ return warnings2.push({
1583
+ code: "status-value-number",
1584
+ severity: "warn",
1585
+ message: `status cell rows[${row.id}].cells[${col.id}] holds the number ${given} and draws the missing dash; write one of: ${STATUS_VALUES.join(" \xB7 ")}, or use a text column with a cell tone. A later release refuses a number here.`,
1586
+ owner: { rowId: row.id, colId: col.id }
1587
+ }), { ...base, displayed: missingGlyph };
1588
+ if (v !== null && !STATUS_VALUES.includes(v)) {
1589
+ let converted = caseInsensitiveValue(v, STATUS_VALUES) ?? (Object.hasOwn(STATUS_WORDS, v.toLowerCase()) ? STATUS_WORDS[v.toLowerCase()] : void 0);
1590
+ if (converted !== void 0) {
1591
+ let rowPath = (rows, base2) => {
1592
+ for (let [index, candidate] of rows.entries()) {
1593
+ let path = [...base2, index];
1594
+ if (candidate.id === row.id) return path;
1595
+ let child = candidate.children && rowPath(candidate.children, [...path, "children"]);
1596
+ if (child) return child;
1597
+ }
1598
+ }, field = [...rowPath(data.rows, ["data", "rows"]), "cells", col.id, ...obj ? ["v"] : []];
1599
+ warnings2.push(inputConversion(field, v, converted)), v = converted;
1600
+ }
1385
1601
  }
1386
- let mat = col.materiality, threshold = specs.get(col.id).suffix.includes("%") ? mat?.pct : mat?.abs;
1387
- threshold !== void 0 && Math.abs(s.raw) < threshold && (deEmphasized = !0, tone = "neutral");
1602
+ if (v !== null && !STATUS_VALUES.includes(v))
1603
+ throw new NormalizeError(
1604
+ "status-value-invalid",
1605
+ `rows[${row.id}].cells[${col.id}]`,
1606
+ `status '${v}' is not one of: ${STATUS_VALUES.join(" \xB7 ")}; for free status text use a text column with a cell tone`,
1607
+ "Use on-track, at-risk, off-track, done or pending, or green, amber, yellow or red (any case). For free status text use a text column with a cell tone."
1608
+ );
1609
+ if (v === null) return { ...base, displayed: missingGlyph };
1610
+ let tone = v === "off-track" ? "bad" : v === "at-risk" ? "warn" : v === "done" || v === "on-track" ? "good" : "neutral", labels = col.kind === "status" ? col.labels : void 0, displayed = written === v ? labels?.[v] ?? v : labels?.[written] ?? labels?.[v] ?? v;
1611
+ return { ...base, raw: v, state: "value", displayed, tone: judgementTone(tone, obj?.strong) };
1388
1612
  }
1389
- obj?.muted === !0 && (deEmphasized = !0, tone = "neutral"), tone = judgementTone(tone, obj?.strong);
1390
- let reconciled = overrideAmount.get(tableCellKey(row.id, col.id)), zero = tone === "neutral" && !deEmphasized && s.state === "value" && typeof s.raw == "number" && (reconciled !== void 0 ? Math.abs(reconciled) < 1e-9 : roundedNumber(s.raw, specFor(col.id, row.id)) === 0);
1391
- return {
1392
- ...base,
1393
- raw: s.raw,
1394
- state: s.state,
1395
- displayed,
1396
- tone,
1397
- deEmphasized,
1398
- polarity,
1399
- ...zero ? { zero: !0 } : {},
1400
- ...negated ? { negated: !0 } : {},
1401
- ...band === void 0 ? {} : { band: { to: band.to, ...bandIndex > 0 ? { from: obj.bands[bandIndex - 1].to } : {}, ...band.label === void 0 ? {} : { label: band.label } } }
1402
- };
1403
- }
1404
- case "status": {
1405
- let given = typeof authored == "number" ? authored : obj?.v, written = typeof authored == "string" ? authored : typeof given == "string" ? given : null, v = written;
1406
- if (typeof given == "number")
1407
- return warnings.push({
1408
- code: "status-value-number",
1613
+ case "date": {
1614
+ let given = typeof authored == "number" ? authored : obj?.v, v = typeof authored == "string" ? authored : typeof given == "string" ? given : null;
1615
+ if (typeof given == "number" && warnings2.push({
1616
+ code: "date-value-number",
1409
1617
  severity: "warn",
1410
- message: `status cell rows[${row.id}].cells[${col.id}] holds the number ${given} and draws the missing dash; write one of: ${STATUS_VALUES.join(" \xB7 ")}, or use a text column with a cell tone. A later release refuses a number here.`,
1618
+ message: `date cell rows[${row.id}].cells[${col.id}] holds the number ${given} and draws the missing dash; write an ISO date (YYYY-MM-DD), or use a value or text column.`,
1411
1619
  owner: { rowId: row.id, colId: col.id }
1412
- }), { ...base, displayed: missingGlyph };
1413
- if (v !== null && !STATUS_VALUES.includes(v)) {
1414
- let converted = caseInsensitiveValue(v, STATUS_VALUES) ?? (Object.hasOwn(STATUS_WORDS, v.toLowerCase()) ? STATUS_WORDS[v.toLowerCase()] : void 0);
1415
- if (converted !== void 0) {
1416
- let rowPath = (rows, base2) => {
1417
- for (let [index, candidate] of rows.entries()) {
1418
- let path = [...base2, index];
1419
- if (candidate.id === row.id) return path;
1420
- let child = candidate.children && rowPath(candidate.children, [...path, "children"]);
1421
- if (child) return child;
1422
- }
1423
- }, field = [...rowPath(data.rows, ["data", "rows"]), "cells", col.id, ...obj ? ["v"] : []];
1424
- warnings.push(inputConversion(field, v, converted)), v = converted;
1425
- }
1620
+ }), v === null) return { ...base, displayed: missingGlyph };
1621
+ let d = parseISODate(v);
1622
+ if (!d)
1623
+ throw new NormalizeError(
1624
+ "date-invalid",
1625
+ `rows[${row.id}].cells[${col.id}]`,
1626
+ `'${v}' is not an ISO date (YYYY-MM-DD)`
1627
+ );
1628
+ let pattern = datePatterns.get(col.id);
1629
+ return { ...base, raw: v, state: "value", displayed: formatDate(d, pattern, options2.locale?.language) };
1426
1630
  }
1427
- if (v !== null && !STATUS_VALUES.includes(v))
1428
- throw new NormalizeError(
1429
- "status-value-invalid",
1430
- `rows[${row.id}].cells[${col.id}]`,
1431
- `status '${v}' is not one of: ${STATUS_VALUES.join(" \xB7 ")}; for free status text use a text column with a cell tone`,
1432
- "Use on-track, at-risk, off-track, done or pending, or green, amber, yellow or red (any case). For free status text use a text column with a cell tone."
1433
- );
1434
- if (v === null) return { ...base, displayed: missingGlyph };
1435
- let tone = v === "off-track" ? "bad" : v === "at-risk" ? "warn" : v === "done" || v === "on-track" ? "good" : "neutral", labels = col.kind === "status" ? col.labels : void 0, displayed = written === v ? labels?.[v] ?? v : labels?.[written] ?? labels?.[v] ?? v;
1436
- return { ...base, raw: v, state: "value", displayed, tone: judgementTone(tone, obj?.strong) };
1437
- }
1438
- case "date": {
1439
- let given = typeof authored == "number" ? authored : obj?.v, v = typeof authored == "string" ? authored : typeof given == "string" ? given : null;
1440
- if (typeof given == "number" && warnings.push({
1441
- code: "date-value-number",
1442
- severity: "warn",
1443
- message: `date cell rows[${row.id}].cells[${col.id}] holds the number ${given} and draws the missing dash; write an ISO date (YYYY-MM-DD), or use a value or text column.`,
1444
- owner: { rowId: row.id, colId: col.id }
1445
- }), v === null) return { ...base, displayed: missingGlyph };
1446
- let d = parseISODate(v);
1447
- if (!d)
1448
- throw new NormalizeError(
1449
- "date-invalid",
1450
- `rows[${row.id}].cells[${col.id}]`,
1451
- `'${v}' is not an ISO date (YYYY-MM-DD)`
1452
- );
1453
- let pattern = datePatterns.get(col.id);
1454
- return { ...base, raw: v, state: "value", displayed: formatDate(d, pattern, options.locale?.language) };
1455
- }
1456
- case "text": {
1457
- let v = typeof authored == "string" ? authored : typeof authored == "number" ? String(authored) : obj?.v !== void 0 ? String(obj.v) : null;
1458
- return v === null && !obj?.note ? { ...base, displayed: "" } : { ...base, raw: v, state: "value", displayed: v ?? "" };
1631
+ case "text": {
1632
+ let v = typeof authored == "string" ? authored : typeof authored == "number" ? String(authored) : obj?.v !== void 0 ? String(obj.v) : null;
1633
+ return v === null && !obj?.note ? { ...base, displayed: "" } : { ...base, raw: v, state: "value", displayed: v ?? "" };
1634
+ }
1635
+ case "encoding":
1636
+ return { ...base, state: "value", displayed: "" };
1459
1637
  }
1460
- case "encoding":
1461
- return { ...base, state: "value", displayed: "" };
1462
1638
  }
1639
+ stampRecordDisplay(records2, resolvedRows, formatNumber), sortSiblingGroups(childrenOf2, resolvedRows, resolvedColumns, options2, generatedOthers);
1640
+ let totalPos = options2.totalPosition ?? language.totalPosition, ordered = orderRows(resolvedRows, childrenOf2, totalPos);
1641
+ ordered.forEach((r, i) => r.order = i);
1642
+ for (let row of ordered) {
1643
+ if (!generatedOthers.has(row.id) || !row.hasChildren) continue;
1644
+ let members = (treeChildrenOf.get(row.id) ?? []).map((child) => child.label);
1645
+ autoFootnotes2.add(`${row.label} groups ${members.join(", ")}.`);
1646
+ }
1647
+ resolvedColumns.filter((column) => (column.kind === "value" || column.kind === "computed") && column.cellEncoding?.type === "heat" && (column.cellEncoding.scale ?? "column") === "column" && column.cellEncoding.cap === void 0).length > 1 && autoFootnotes2.add(HEAT_COLUMN_FOOTNOTE);
1648
+ let statusNote = statusDirectionNote(resolvedColumns, heatRanges(resolvedColumns, ordered), options2.colorblindSafe === !0);
1649
+ if (statusNote !== void 0 && autoFootnotes2.add(statusNote), resolvedColumns.some((column) => column.cellEncoding?.type === "arrow" && column.cellEncoding.scale === "relative" && column.kind === "computed" && column.polarity) && autoFootnotes2.add(ARROW_FOOTNOTE), lowerJudged.size && higherJudged.size) {
1650
+ let [fewer, word] = lowerJudged.size <= higherJudged.size ? [lowerJudged, "Lower"] : [higherJudged, "Higher"];
1651
+ autoFootnotes2.add(`${options2.colorblindSafe === !0 ? "The good tone" : "Green"} marks a favourable change. ${word} is better for ${[...fewer].join(", ")}.`);
1652
+ }
1653
+ let footnotes = [...autoFootnotes2];
1654
+ if (headMarksPartial) for (let column of resolvedColumns) partialColumnIds.has(column.id) && (column.partial = !0);
1655
+ if (options2.columnHeads === !1) {
1656
+ let units = [...new Set(resolvedColumns.flatMap((column) => column.unitLabel ?? []))];
1657
+ units.length > 0 && warnings2.push({
1658
+ code: "column-heads-unit-hidden",
1659
+ severity: "warn",
1660
+ field: ["options", "columnHeads"],
1661
+ message: `columnHeads: false removes the only print of the unit ${units.join(", ")}`,
1662
+ suggest: "Name the unit in the subtitle or a footnote, or use formats that print it in each cell."
1663
+ });
1664
+ }
1665
+ let result = {
1666
+ ...zeroLifts.count === liftsBefore && rawLifts === 0 ? {} : { lifted: !0 },
1667
+ table: {
1668
+ columns: resolvedColumns,
1669
+ columnGroups: (data.columnGroups ?? []).map((g) => ({
1670
+ id: g.id,
1671
+ label: g.label,
1672
+ columnIds: g.columns,
1673
+ ...g.band === void 0 ? {} : { band: g.band },
1674
+ ...g.note === void 0 ? {} : { note: g.note },
1675
+ ...g.spacer === void 0 ? {} : { spacer: g.spacer },
1676
+ ...g.heading === void 0 ? {} : { heading: g.heading },
1677
+ ...g.hoverSeries === void 0 ? {} : { hoverSeries: g.hoverSeries }
1678
+ })),
1679
+ columnToggles: toggleResolution.toggles,
1680
+ rows: ordered,
1681
+ unit: uniformUnit ?? void 0,
1682
+ ...data.levelNouns === void 0 ? {} : { levelNouns: data.levelNouns },
1683
+ footnotes,
1684
+ ...partialColumnIds.size > 0 ? { partialColumnIds: [...partialColumnIds] } : {},
1685
+ ...options2.colorblindSafe === !0 ? { colorblindSafe: !0 } : {},
1686
+ provenance: {}
1687
+ },
1688
+ computedCells: records2,
1689
+ warnings: warnings2
1690
+ };
1691
+ return evaluatedStates.set(result, rawState2), result;
1463
1692
  }
1464
- stampRecordDisplay(records, resolvedRows, formatNumber), sortSiblingGroups(childrenOf, resolvedRows, resolvedColumns, options, generatedOthers);
1465
- let totalPos = options.totalPosition ?? language.totalPosition, ordered = orderRows(resolvedRows, childrenOf, totalPos);
1466
- ordered.forEach((r, i) => r.order = i);
1467
- for (let row of ordered) {
1468
- if (!generatedOthers.has(row.id) || !row.hasChildren) continue;
1469
- let members = (treeChildrenOf.get(row.id) ?? []).map((child) => child.label);
1470
- autoFootnotes.add(`${row.label} groups ${members.join(", ")}.`);
1471
- }
1472
- resolvedColumns.filter((column) => (column.kind === "value" || column.kind === "computed") && column.cellEncoding?.type === "heat" && (column.cellEncoding.scale ?? "column") === "column" && column.cellEncoding.cap === void 0).length > 1 && autoFootnotes.add(HEAT_COLUMN_FOOTNOTE);
1473
- let statusNote = statusDirectionNote(resolvedColumns, heatRanges(resolvedColumns, ordered), options.colorblindSafe === !0);
1474
- if (statusNote !== void 0 && autoFootnotes.add(statusNote), resolvedColumns.some((column) => column.cellEncoding?.type === "arrow" && column.cellEncoding.scale === "relative" && column.kind === "computed" && column.polarity) && autoFootnotes.add(ARROW_FOOTNOTE), lowerJudged.size && higherJudged.size) {
1475
- let [fewer, word] = lowerJudged.size <= higherJudged.size ? [lowerJudged, "Lower"] : [higherJudged, "Higher"];
1476
- autoFootnotes.add(`${options.colorblindSafe === !0 ? "The good tone" : "Green"} marks a favourable change. ${word} is better for ${[...fewer].join(", ")}.`);
1477
- }
1478
- let footnotes = [...autoFootnotes];
1479
- if (disclosuresShown(options)) for (let column of resolvedColumns) partialColumnIds.has(column.id) && (column.partial = !0);
1480
- let result = {
1481
- ...zeroLifts.count === liftsBefore ? {} : { lifted: !0 },
1482
- table: {
1483
- columns: resolvedColumns,
1484
- columnGroups: (data.columnGroups ?? []).map((g) => ({
1485
- id: g.id,
1486
- label: g.label,
1487
- columnIds: g.columns,
1488
- ...g.band === void 0 ? {} : { band: g.band },
1489
- ...g.note === void 0 ? {} : { note: g.note },
1490
- ...g.spacer === void 0 ? {} : { spacer: g.spacer },
1491
- ...g.heading === void 0 ? {} : { heading: g.heading },
1492
- ...g.hoverSeries === void 0 ? {} : { hoverSeries: g.hoverSeries }
1493
- })),
1494
- columnToggles: toggleResolution.toggles,
1495
- rows: ordered,
1496
- unit: uniformUnit ?? void 0,
1497
- ...data.levelNouns === void 0 ? {} : { levelNouns: data.levelNouns },
1498
- footnotes,
1499
- ...partialColumnIds.size > 0 ? { partialColumnIds: [...partialColumnIds] } : {},
1500
- ...options.colorblindSafe === !0 ? { colorblindSafe: !0 } : {},
1501
- provenance: {}
1502
- },
1503
- computedCells: records,
1504
- warnings
1505
- };
1506
- return evaluatedStates.set(result, rawState), result;
1507
1693
  }
1508
1694
  var HEAT_DEFAULT_ALPHA = 0.18, HEAT_STATUS_ALPHA = 0.26;
1509
1695
  function encodingFor(encodings, columnId) {
@@ -1663,6 +1849,7 @@ function flattenRows(rows) {
1663
1849
  level,
1664
1850
  order: order++,
1665
1851
  ...row[MAGNITUDE_GROUP] === void 0 ? {} : { [MAGNITUDE_GROUP]: row[MAGNITUDE_GROUP] },
1852
+ ...row[MAGNITUDE_FIGURES] === void 0 ? {} : { [MAGNITUDE_FIGURES]: row[MAGNITUDE_FIGURES] },
1666
1853
  ...row[AUTOMATIC_FORMAT] === !0 ? { [AUTOMATIC_FORMAT]: !0 } : {}
1667
1854
  });
1668
1855
  for (let child of row.children ?? []) walk(child, row.id, level + 1);
@@ -1765,13 +1952,7 @@ function resolveColumnToggles(data, options, colById, warnings) {
1765
1952
  `every member of toggle '${toggle.id}' must belong to one columnGroup, or none of them to any`
1766
1953
  );
1767
1954
  }
1768
- for (let toggleId of Object.keys(options.columnVisibility ?? {}))
1769
- toggleIds.has(toggleId) || warnings.push({
1770
- code: "column-visibility-ref-unknown",
1771
- severity: "warn",
1772
- message: `columnVisibility references unknown toggle '${toggleId}' \u2014 no columns were changed`
1773
- });
1774
- return {
1955
+ return columnVisibilityWarnings(data.columnToggles ?? [], options, warnings), {
1775
1956
  membership,
1776
1957
  toggles: (data.columnToggles ?? []).map((toggle) => {
1777
1958
  let defaultVisible = toggle.defaultVisible ?? !1;
@@ -1785,6 +1966,15 @@ function resolveColumnToggles(data, options, colById, warnings) {
1785
1966
  })
1786
1967
  };
1787
1968
  }
1969
+ function columnVisibilityWarnings(toggles, options, warnings) {
1970
+ let ids = new Set(toggles.map((toggle) => toggle.id));
1971
+ for (let toggleId of Object.keys(options.columnVisibility ?? {}))
1972
+ ids.has(toggleId) || warnings.push({
1973
+ code: "column-visibility-ref-unknown",
1974
+ severity: "warn",
1975
+ message: `columnVisibility references unknown toggle '${toggleId}' \u2014 no columns were changed`
1976
+ });
1977
+ }
1788
1978
  function validateGroups(data, colById) {
1789
1979
  let groups = data.columnGroups ?? [], claimed = /* @__PURE__ */ new Map(), columnIndex = new Map(data.columns.map((column, index) => [column.id, index]));
1790
1980
  for (let g of groups) {
@@ -2302,19 +2492,36 @@ function inCellBarMaxima(rows, columns) {
2302
2492
 
2303
2493
  // src/core/charts/table/widths.ts
2304
2494
  var FLEX_MIN = 80, HEAT_ONLY_CELL_W = 22;
2305
- function tableWidths(table, theme, measure, options = {}, view = {}) {
2495
+ function tableWidths(table, theme, measure, options = {}, view = {}, probe) {
2496
+ if (options.columnHeads !== !1) return tableWidthsWithHeads(table, theme, measure, options, view, probe);
2497
+ let { columnHeads: _heads, ...withHeads } = options, bare = (columns) => columns.map((col) => {
2498
+ let { subLabel: _sub, unitLabel: _unit, partial: _partial, scenario: _scenario, ...rest } = col;
2499
+ return { ...rest, label: "" };
2500
+ });
2501
+ return tableWidthsWithHeads({ ...table, columns: bare(table.columns), columnGroups: table.columnGroups.map((group) => ({ ...group, heading: !1 })) }, theme, measure, withHeads, {
2502
+ ...view,
2503
+ ...view.columns === void 0 ? {} : { columns: bare(view.columns) },
2504
+ ...view.allColumns === void 0 ? {} : { allColumns: bare(view.allColumns) },
2505
+ ...view.defaultColumns === void 0 ? {} : { defaultColumns: bare(view.defaultColumns) }
2506
+ }, probe);
2507
+ }
2508
+ function tableWidthsWithHeads(table, theme, measure, options, view, probe) {
2306
2509
  let { defaultColumns, ...own } = view, shown = own.columns ?? visibleColumns(table);
2307
2510
  if (own.scroll && defaultColumns !== void 0 && (defaultColumns.length !== shown.length || defaultColumns.some((col, index) => col.id !== shown[index].id))) {
2308
- let base = tableWidths(table, theme, measure, options, { ...own, columns: defaultColumns }), track = base.tracks.find((entry) => entry.id === defaultColumns.find((col) => col.kind === "rowLabel")?.id)?.width;
2511
+ let base = tableWidthsWithHeads(table, theme, measure, options, { ...own, columns: defaultColumns }), track = base.tracks.find((entry) => entry.id === defaultColumns.find((col) => col.kind === "rowLabel")?.id)?.width;
2309
2512
  track !== void 0 && base.labelNeed !== void 0 && (own.labelKeep = Math.min(track, Math.max(base.labelNeed, base.labelBeforeFill ?? 0)));
2310
2513
  }
2311
- let regular = tableWidthsOnce(table, theme, measure, options, own), count = (view.columns ?? visibleColumns(table)).length, densePad = count >= 25 ? 3 : count >= DENSE_COLUMNS ? 5 : regular.cellPadX;
2514
+ let regular = tableWidthsOnce(table, theme, measure, options, own, probe);
2515
+ if ("widthMiss" in regular) return regular;
2516
+ let count = (view.columns ?? visibleColumns(table)).length, densePad = count >= 25 ? 3 : count >= DENSE_COLUMNS ? 5 : regular.cellPadX;
2312
2517
  if (options.cellPadX !== void 0 || densePad >= regular.cellPadX || Math.max(regular.minimumW, regular.totalW) <= (view.available ?? 1 / 0)) return regular;
2313
- let dense = tableWidthsOnce(table, theme, measure, { ...options, cellPadX: densePad }, own), regularOverflow = regular.warnings.find((warning) => warning.code === "table-overflow");
2518
+ let dense = tableWidthsOnce(table, theme, measure, { ...options, cellPadX: densePad }, own);
2519
+ if ("widthMiss" in dense) return dense;
2520
+ let regularOverflow = regular.warnings.find((warning) => warning.code === "table-overflow");
2314
2521
  return regularOverflow && (dense.warnings = dense.warnings.map((warning) => warning.code === "table-overflow" ? regularOverflow : warning)), dense;
2315
2522
  }
2316
- function tableWidthsOnce(table, theme, measure, options = {}, view = {}) {
2317
- let cols = view.columns ?? visibleColumns(table), rows = view.rows ?? visibleRows(table), fullRows = view.fullRows ?? table.rows, widthRows = view.widthRows ?? table.rows, available = view.available ?? 1 / 0, spacerBefore = /* @__PURE__ */ new Map();
2523
+ function measureTableTracks(table, theme, measure, options, view) {
2524
+ let cols = view.columns ?? visibleColumns(table), columnIndex = new Map(cols.map((col, index) => [col.id, index])), rows = view.rows ?? visibleRows(table), fullRows = view.fullRows ?? table.rows, widthRows = view.widthRows ?? table.rows, spacerBefore = /* @__PURE__ */ new Map();
2318
2525
  for (let group of table.columnGroups) {
2319
2526
  if (group.spacer === void 0 || group.spacer <= 0) continue;
2320
2527
  let ordered = view.allColumns ?? cols, first = ordered.find((col) => group.columnIds.includes(col.id));
@@ -2327,13 +2534,7 @@ function tableWidthsOnce(table, theme, measure, options = {}, view = {}) {
2327
2534
  let first = cols.find((col) => col.groupId === groupId);
2328
2535
  return first && view.groupStart.has(first.id) ? 1 : 0;
2329
2536
  }
2330
- }, headingFaces = (faces) => groupHeadingFaces(view.trailingTracking ? { ...faces.group, letterSpacing: Math.round((faces.group.letterSpacing ?? 0) * 1e3) / 1e3 } : faces.group), warnings = [], ladder = levelLadder(theme, options.density ?? "regular", options.target, textScaleOf(options)), regularFonts = tableFonts(theme, ladder), rowById = new Map([...widthRows, ...rows].map((row) => [row.id, row])), hasChanges = new Set(table.rows.filter((row) => visibleInlineRows(row, options.inlineVisibility).length > 0).map((row) => row.id)), cellStep = (cell) => rowById.get(cell.rowId)?.step ?? cell.level, indentStep = (cell) => rowById.get(cell.rowId)?.indentStep ?? cellStep(cell), childCount = treeChildCounts(table), isTree = fullRows.some((row) => row.hasChildren), indents = labelIndents(cellPadX2, options.labelIndent, view.withMarks ?? options.outlineMarks === !0), operatorSlot = operatorWidth(rows, theme), rowIndent = (level) => (isTree ? indents.base + level * indents.step : 0) + operatorSlot, inlineFont2 = (level, signed) => inlineFont(theme, ladder, level, signed);
2331
- function cellFont(cell) {
2332
- let row = rowById.get(cell.rowId), kind = row?.kind, totalFace = kind === void 0 || kind !== "subtotal" && kind !== "result" && kind !== "driver" && (kind !== "member" && kind !== "measure" || theme.table?.weights?.figures?.[kind] === void 0);
2333
- if (cell.role === "total" && cell.kind !== "rowLabel" && totalFace) return regularFonts.totalValue;
2334
- let font = kindFont(rowFont(theme, ladder, regularFonts, cell.role, cellStep(cell), row?.hasChildren === !0, hasChanges.has(cell.rowId)), kind, cell.kind === "rowLabel", theme);
2335
- return cell.state === "value" ? strongColumnFont(font, cols.find((col) => col.id === cell.colId), cell, kind, theme) : font;
2336
- }
2537
+ }, headingFaces = (faces) => groupHeadingFaces(view.trailingTracking ? { ...faces.group, letterSpacing: Math.round((faces.group.letterSpacing ?? 0) * 1e3) / 1e3 } : faces.group), { ladder, regularFonts, cellStep, indentStep, childCount, cellFont, inlineFont: inlineFont2, hasChanges, bodyWidths } = measuredTypography(table, theme, measure, options, view, cols, rows, widthRows), isTree = fullRows.some((row) => row.hasChildren), indents = labelIndents(cellPadX2, options.labelIndent, view.withMarks ?? options.outlineMarks === !0), operatorSlot = operatorWidth(rows, theme), rowIndent = (level) => (isTree ? indents.base + level * indents.step : 0) + operatorSlot;
2337
2538
  function affixRoom(row, font) {
2338
2539
  return row.unitAffix === void 0 ? 0 : theme.table?.qualifier === void 0 ? measure(` ${row.unitAffix}`, inlineFont2(row.step, !1)).width : measure(row.unitAffix, qualifierFont(font, theme)).width + (theme.table.qualifier.gap ?? 4);
2339
2540
  }
@@ -2342,9 +2543,10 @@ function tableWidthsOnce(table, theme, measure, options = {}, view = {}) {
2342
2543
  return view.headGlue === !1 ? text : text.replace(/ (\S{1,2})$/u, "\xA0$1");
2343
2544
  };
2344
2545
  function trackWidths(faces) {
2345
- let widths2 = /* @__PURE__ */ new Map(), minimumWidths2 = /* @__PURE__ */ new Map(), wrappedOneLines = /* @__PURE__ */ new Map(), context = {
2546
+ let widths = [], minimumWidths = [], wrappedOneLines = [], context = {
2346
2547
  theme,
2347
2548
  measure,
2549
+ bodyWidths,
2348
2550
  fonts: faces,
2349
2551
  cellFont,
2350
2552
  inlineFont: inlineFont2,
@@ -2366,49 +2568,49 @@ function tableWidthsOnce(table, theme, measure, options = {}, view = {}) {
2366
2568
  hint: (row) => collapsedHintWidth(row, table.levelNouns, childCount.get(row.id) ?? 0, measure, faces.hint),
2367
2569
  ...view.headLines === void 0 ? {} : { headLines: view.headLines }
2368
2570
  };
2369
- for (let col of cols) {
2370
- let heatOnlyWidth = Math.max(HEAT_ONLY_CELL_W, Math.ceil((view.scroll ? headerContentWidth(col, context) : measure(columnHeaderText(col), faces.header).width) + 2 * cellPadX2)), intrinsicWidth = figures || !heatColumn(col) ? intrinsicColumnWidth(col, widthRows, context) : heatOnlyWidth, endRule = col.width === void 0 && (figures || !heatColumn(col)) && view.groupEnd?.has(col.id) ? 1 : 0;
2571
+ for (let index = 0; index < cols.length; index++) {
2572
+ let col = cols[index], heatOnlyWidth = Math.max(HEAT_ONLY_CELL_W, Math.ceil((view.scroll ? headerContentWidth(col, context) : measure(columnHeaderText(col), faces.header).width) + 2 * cellPadX2)), intrinsicWidth = figures || !heatColumn(col) ? intrinsicColumnWidth(col, widthRows, context) : heatOnlyWidth, endRule = col.width === void 0 && (figures || !heatColumn(col)) && view.groupEnd?.has(col.id) ? 1 : 0;
2371
2573
  if (col.kind === "encoding") {
2372
2574
  let track = (authoredTrackWidth(col, widthRows, context) ?? intrinsicWidth) + endRule;
2373
- widths2.set(col.id, track), minimumWidths2.set(col.id, track);
2575
+ widths[index] = track, minimumWidths[index] = track;
2374
2576
  continue;
2375
2577
  }
2376
2578
  let headerW = view.scroll ? headerContentWidth(col, context) : measure(columnHeaderText(col), faces.header).width + (context.headerReserve?.(col) ?? 0), minimumWidth = col.wrap ? wrapFloorWidth(col, widthRows, headerW, context) : col.kind === "rowLabel" ? intrinsicColumnWidth(col, widthRows, { ...context, hint: void 0 }) : intrinsicWidth;
2377
- minimumWidths2.set(col.id, minimumWidth);
2378
- let wrapped = view.scroll && col.wrap && col.width === void 0 && (figures || !heatColumn(col)), authoredContext = col.kind === "rowLabel" ? { ...context, twoLineLabels: options.rowLabelLines !== 1 } : context, authored = col.kind === "rowLabel" && col.width !== void 0 && intrinsicWidth <= col.width ? col.width : authoredTrackWidth(col, widthRows, authoredContext);
2379
- widths2.set(col.id, figures || !heatColumn(col) ? authored ?? (wrapped ? minimumWidth : intrinsicWidth) : heatOnlyWidth), wrapped && wrappedOneLines.set(col.id, intrinsicWidth);
2579
+ minimumWidths[index] = minimumWidth;
2580
+ let wrapped = view.scroll && col.wrap && col.width === void 0 && (figures || !heatColumn(col)), authoredContext = col.kind === "rowLabel" ? { ...context, labelLines: options.rowLabelLines ?? 2 } : context, authored = col.kind === "rowLabel" && col.width !== void 0 && intrinsicWidth <= col.width ? col.width : authoredTrackWidth(col, widthRows, authoredContext);
2581
+ widths[index] = figures || !heatColumn(col) ? authored ?? (wrapped ? minimumWidth : intrinsicWidth) : heatOnlyWidth, wrapped && wrappedOneLines.push({ index, width: intrinsicWidth });
2380
2582
  let extra = (col.kind === "rowLabel" ? labelLead : 0) + endRule;
2381
- if (extra > 0) for (let target of [widths2, minimumWidths2]) target.set(col.id, target.get(col.id) + extra);
2583
+ if (extra > 0) for (let target of [widths, minimumWidths]) target[index] = target[index] + extra;
2382
2584
  }
2383
2585
  {
2384
2586
  let groupFaces = headingFaces(faces), drawn = cols.map((col) => col.id), isFixed = (id) => {
2385
2587
  let col = cols.find((candidate) => candidate.id === id);
2386
2588
  return col !== void 0 && (col.width !== void 0 || !figures && heatColumn(col));
2387
2589
  };
2388
- for (let target of [widths2, minimumWidths2]) {
2389
- let floors = groupHeadingFloors(table.columnGroups, drawn, (id) => target.get(id) ?? 0, isFixed, groupFaces, measure, groupCell);
2390
- for (let [id, extra] of floors) target.set(id, target.get(id) + extra);
2590
+ for (let target of [widths, minimumWidths]) {
2591
+ let floors = groupHeadingFloors(table.columnGroups, drawn, (id) => target[columnIndex.get(id)] ?? 0, isFixed, groupFaces, measure, groupCell);
2592
+ for (let [id, extra] of floors) target[columnIndex.get(id)] = target[columnIndex.get(id)] + extra;
2391
2593
  }
2392
2594
  }
2393
2595
  let chipFloor = sectionChipFloor(widthRows, { ...context, hint: void 0 });
2394
2596
  if (labelColumn !== void 0)
2395
- for (let [target, floor] of [[widths2, sectionChipFloor(widthRows, context)], [minimumWidths2, chipFloor]]) {
2597
+ for (let [target, floor] of [[widths, sectionChipFloor(widthRows, context)], [minimumWidths, chipFloor]]) {
2396
2598
  let span = chipSpan(target);
2397
- span < floor && target.set(labelColumn.id, target.get(labelColumn.id) + floor - span);
2599
+ span < floor && (target[columnIndex.get(labelColumn.id)] = target[columnIndex.get(labelColumn.id)] + floor - span);
2398
2600
  }
2399
2601
  let labelFloor = options[LABEL_WRAP_FLOOR] === !0 && labelColumn !== void 0 ? labelWrapFloor(labelColumn, faces) + labelLead : 0;
2400
- if (labelFloor > 0) for (let target of [widths2, minimumWidths2]) target.set(labelColumn.id, Math.max(target.get(labelColumn.id), labelFloor));
2602
+ if (labelFloor > 0) for (let target of [widths, minimumWidths]) target[columnIndex.get(labelColumn.id)] = Math.max(target[columnIndex.get(labelColumn.id)], labelFloor);
2401
2603
  view.scroll && labelColumn?.width === void 0 && labelColumn !== void 0 && (labelFloor = Math.max(labelFloor, view.labelKeep ?? 0, intrinsicColumnWidth(labelColumn, widthRows, {
2402
2604
  ...context,
2403
2605
  hint: void 0,
2404
- twoLineLabels: options.rowLabelLines !== 1
2606
+ labelLines: options.rowLabelLines ?? 2
2405
2607
  }) + labelLead + (view.groupEnd?.has(labelColumn.id) ? 1 : 0)));
2406
- let wrapFloors = /* @__PURE__ */ new Map(), wouldWrap = cols.filter((col) => {
2608
+ let wrapFloors = [], wouldWrap = cols.filter((col) => {
2407
2609
  if (col.kind !== "text" || col.wrap || col.width !== void 0) return !1;
2408
2610
  let floor = wrapFloorWidth(col, widthRows, measure(columnHeaderText(col), faces.header).width, context);
2409
- return floor >= minimumWidths2.get(col.id) ? !1 : (wrapFloors.set(col.id, floor), !0);
2611
+ return floor >= minimumWidths[columnIndex.get(col.id)] ? !1 : (wrapFloors[columnIndex.get(col.id)] = floor, !0);
2410
2612
  });
2411
- return { widths: widths2, minimumWidths: minimumWidths2, context, wouldWrap, wrapFloors, chipFloor, labelFloor, wrappedOneLines };
2613
+ return { widths, minimumWidths, context, wouldWrap, wrapFloors, chipFloor, labelFloor, wrappedOneLines };
2412
2614
  }
2413
2615
  function labelWrapFloor(col, faces) {
2414
2616
  let text = rowIndent(0) + Math.max(0, ...columnHeaderText(col).split(/\s+/).map((word) => measure(word, faces.header).width)), unit = 0, open = new Set(rows.map((row) => row.parentId));
@@ -2416,7 +2618,7 @@ function tableWidthsOnce(table, theme, measure, options = {}, view = {}) {
2416
2618
  let cell = row.cells[col.id];
2417
2619
  if (row.role === "section" || row.inline === !0 || !cell?.displayed) continue;
2418
2620
  let font = cellFont(cell), indent = rowIndent(indentStep(cell));
2419
- if (text = Math.max(text, indent + (options.rowLabelLines === 1 ? measure(cell.displayed, font).width : twoLineWidth(cell.displayed, font, measure, !0))), row.unitAffix !== void 0 && !(row.kind === "member" && open.has(row.id))) {
2621
+ if (text = Math.max(text, indent + lineBlockWidth(cell.displayed, options.rowLabelLines ?? 2, font, measure, !0)), row.unitAffix !== void 0 && !(row.kind === "member" && open.has(row.id))) {
2420
2622
  let unitFont = theme.table?.qualifier === void 0 ? { ...inlineFont2(row.step, !1), ...font.style ? { style: font.style } : {} } : qualifierFont(font, theme);
2421
2623
  unit = Math.max(unit, indent + measure(row.unitAffix, unitFont).width);
2422
2624
  }
@@ -2426,76 +2628,194 @@ function tableWidthsOnce(table, theme, measure, options = {}, view = {}) {
2426
2628
  return Math.ceil(Math.max(text + 2 * cellPadX2, unit + cellPadX2));
2427
2629
  }
2428
2630
  function chipSpan(target) {
2429
- return cols.slice(cols.indexOf(labelColumn)).reduce((sum, col) => sum + (target.get(col.id) ?? 0), 0);
2430
- }
2431
- let sumOf = (map) => [...map.values()].reduce((a, b) => a + b, spacerTotal), regular = trackWidths(regularFonts), dense = cols.length >= DENSE_COLUMNS ? trackWidths(tableFonts(theme, ladder, cols.length)) : void 0, wrapMinimumWidth = dense === void 0 && table.columnGroups.length === 0 && regular.chipFloor === 0 ? cols.reduce((sum, col) => sum + (regular.wrapFloors.get(col.id) ?? regular.minimumWidths.get(col.id)), spacerTotal) : void 0, regularHeadsFit = dense === void 0 || headsFit(
2631
+ return cols.slice(cols.indexOf(labelColumn)).reduce((sum, col) => sum + (target[columnIndex.get(col.id)] ?? 0), 0);
2632
+ }
2633
+ let sumOf = (values) => values.reduce((a, b) => a + b, spacerTotal), oneLineLabelWidth, uncutLabelWidth = () => oneLineLabelWidth ??= Math.ceil(Math.max(0, maxOf(rows.map((row) => {
2634
+ let cell = row.cells[labelColumn.id];
2635
+ if (row.role === "section" || !cell?.displayed) return 0;
2636
+ let font = cellFont(cell);
2637
+ return measure(cell.displayed, font).width + affixRoom(row, font) + rowIndent(indentStep(cell)) + 2 * cellPadX2;
2638
+ })))), regular = trackWidths(regularFonts), denseFonts = cols.length >= DENSE_COLUMNS ? tableFonts(theme, ladder, cols.length) : void 0, dense = denseFonts === void 0 ? void 0 : denseFonts.header.letterSpacing === regularFonts.header.letterSpacing ? regular : trackWidths(denseFonts), sizing = dense ?? regular, reach = spacerTotal;
2639
+ for (let index = 0; index < cols.length; index++) {
2640
+ let col = cols[index], width = sizing.widths[index] ?? 0, minimum = sizing.minimumWidths[index] ?? width;
2641
+ reach += col.kind !== "rowLabel" && col.kind !== "text" ? wideTable ? Math.min(width, minimum) : width : Math.min(width, shrinkFloorWidth(col, wideTable, sizing.minimumWidths[index], sizing.labelFloor), col.kind === "rowLabel" ? minimum : width);
2642
+ }
2643
+ let minimumW = Math.max(sumOf(sizing.minimumWidths), reach), wrapMinimumWidth = dense === void 0 && table.columnGroups.length === 0 && regular.chipFloor === 0 ? cols.reduce((sum, _col, index) => sum + (regular.wrapFloors[index] ?? regular.minimumWidths[index]), spacerTotal) : void 0, regularHeadsFit = dense === void 0 || headsFit(
2432
2644
  cols,
2433
2645
  table.columnGroups,
2434
- (id) => regular.widths.get(id) ?? 0,
2646
+ (id) => regular.widths[columnIndex.get(id)] ?? 0,
2435
2647
  figures,
2436
2648
  regular.context,
2437
2649
  headingFaces(regularFonts),
2438
2650
  groupCell
2439
- ), chosen = dense !== void 0 && (!regularHeadsFit || !view.scroll && sumOf(regular.widths) > available) ? dense : regular, fonts = chosen.context.fonts, widths = chosen.widths, minimumWidths = chosen.minimumWidths, sizingMinimums = (dense ?? regular).minimumWidths, sizingTracks = new Map((dense ?? regular).widths);
2440
- if (view.scroll && view.fit === void 0 && Number.isFinite(available) && chosen.wrappedOneLines.size > 0) {
2441
- let want = [...chosen.wrappedOneLines].reduce((sum, [id, oneLine]) => sum + Math.max(0, oneLine - widths.get(id)), 0), share = Math.max(0, Math.min(want, available - sumOf(widths)));
2442
- if (share > 0) for (let [id, oneLine] of chosen.wrappedOneLines) {
2443
- let natural = widths.get(id);
2444
- widths.set(id, Math.floor(natural + share * Math.max(0, oneLine - natural) / want));
2651
+ ), columnIds = cols.map((col) => col.id), indices = cols.map((_col, index) => index), labelIndices = indices.filter((index) => cols[index].kind === "rowLabel" && (!view.scroll || cols[index].width === void 0)), textIndices = view.scroll ? [] : indices.filter((index) => cols[index].kind === "text"), compactIndices = view.scroll ? [] : indices.filter((index) => cols[index].kind !== "rowLabel" && cols[index].kind !== "text"), growingIndices = indices.filter((index) => {
2652
+ let col = cols[index];
2653
+ return col.width === void 0 && (col.kind === "value" || col.kind === "computed") && (figures || !heatColumn(col));
2654
+ });
2655
+ return { cols, columnIds, columnIndex, indices, labelIndices, textIndices, compactIndices, growingIndices, rows, widthRows, spacerBefore, spacerTotal, figures, wideTable, cellPadX: cellPadX2, labelColumn, labelLead, groupCell, headingFaces, regularFonts, cellStep, indentStep, childCount, indents, operatorSlot, rowIndent, cellFont, affixRoom, columnHeaderText, chipSpan, sumOf, hasChanges, uncutLabelWidth, regular, dense, minimumW, wrapMinimumWidth, regularHeadsFit };
2656
+ }
2657
+ var measuredTables = /* @__PURE__ */ new WeakMap(), measureIds = /* @__PURE__ */ new WeakMap(), nextMeasureId = 0, measureId = (fn) => {
2658
+ if (fn === void 0) return;
2659
+ let id = measureIds.get(fn);
2660
+ return id === void 0 && measureIds.set(fn, id = nextMeasureId++), id;
2661
+ };
2662
+ function measurementTheme(theme) {
2663
+ let table = theme.table;
2664
+ return [
2665
+ theme.type,
2666
+ table?.head && [table.head.size, table.head.weight, table.head.tracking, table.head.case],
2667
+ table?.section && [table.section.size, table.section.weight, table.section.tracking, table.section.case],
2668
+ table?.fixedType,
2669
+ table?.rows !== void 0,
2670
+ table?.weights,
2671
+ table?.driver?.italic,
2672
+ table?.qualifier,
2673
+ table?.operator?.width
2674
+ ];
2675
+ }
2676
+ function prepareWidthTypography(table, theme, options, cols, rows, widthRows) {
2677
+ let ladder = levelLadder(theme, options.density ?? "regular", options.target, textScaleOf(options)), regularFonts = tableFonts(theme, ladder), rowById = new Map([...widthRows, ...rows].map((row) => [row.id, row])), colById = new Map(cols.map((col) => [col.id, col])), hasChanges = new Set(table.rows.filter((row) => visibleInlineRows(row, options.inlineVisibility).length > 0).map((row) => row.id)), cellStep = (cell) => rowById.get(cell.rowId)?.step ?? cell.level, indentStep = (cell) => rowById.get(cell.rowId)?.indentStep ?? cellStep(cell), childCount = treeChildCounts(table), inlineFont2 = (level, signed) => inlineFont(theme, ladder, level, signed), cellIndex = /* @__PURE__ */ new Map(), cellFonts = [];
2678
+ function makeCellFont(cell) {
2679
+ let row = rowById.get(cell.rowId), kind = row?.kind, totalFace = kind === void 0 || kind !== "subtotal" && kind !== "result" && kind !== "driver" && (kind !== "member" && kind !== "measure" || theme.table?.weights?.figures?.[kind] === void 0);
2680
+ if (cell.role === "total" && cell.kind !== "rowLabel" && totalFace) return regularFonts.totalValue;
2681
+ let font = kindFont(rowFont(theme, ladder, regularFonts, cell.role, cellStep(cell), row?.hasChildren === !0, hasChanges.has(cell.rowId)), kind, cell.kind === "rowLabel", theme);
2682
+ return cell.state === "value" ? strongColumnFont(font, colById.get(cell.colId), cell, kind, theme) : font;
2683
+ }
2684
+ for (let row of rowById.values()) for (let col of cols) {
2685
+ let cell = row.cells[col.id];
2686
+ cell === void 0 || cellIndex.has(cell) || (cellIndex.set(cell, cellFonts.length), cellFonts.push(makeCellFont(cell)));
2687
+ }
2688
+ function cellFont(cell) {
2689
+ let index = cellIndex.get(cell);
2690
+ return index === void 0 ? makeCellFont(cell) : cellFonts[index];
2691
+ }
2692
+ let bodyWidths = {
2693
+ columnIndex: new Map(cols.map((col, index) => [col.id, index])),
2694
+ columns: cols.map(() => [])
2695
+ };
2696
+ return { ladder, regularFonts, cellStep, indentStep, childCount, cellFont, inlineFont: inlineFont2, hasChanges, bodyWidths };
2697
+ }
2698
+ var measuredBodies = /* @__PURE__ */ new WeakMap();
2699
+ function measuredTypography(table, theme, measure, options, view, cols, rows, widthRows) {
2700
+ let key = JSON.stringify([
2701
+ measurementTheme(theme),
2702
+ measureId(measure),
2703
+ measureId(view.slack),
2704
+ // Ordinary densities change row air only. Cohort densities also change the measured type.
2705
+ isCohortDensity(options.density ?? "regular") ? options.density : void 0,
2706
+ options.target,
2707
+ textScaleOf(options),
2708
+ options.inlineVisibility,
2709
+ cols.map((col) => col.id),
2710
+ rows.map((row) => row.id),
2711
+ widthRows.map((row) => row.id)
2712
+ ]), variants = measuredBodies.get(table);
2713
+ variants || measuredBodies.set(table, variants = /* @__PURE__ */ new Map());
2714
+ let measured = variants.get(key);
2715
+ return measured || (variants.size >= 64 && variants.delete(variants.keys().next().value), variants.set(key, measured = prepareWidthTypography(table, theme, options, cols, rows, widthRows))), measured;
2716
+ }
2717
+ function measuredTable(table, theme, measure, options, view) {
2718
+ let ids = (entries) => entries?.map((entry) => entry.id), key = JSON.stringify([
2719
+ measurementTheme(theme),
2720
+ measureId(measure),
2721
+ measureId(view.slack),
2722
+ isCohortDensity(options.density ?? "regular") ? options.density : void 0,
2723
+ options.target,
2724
+ textScaleOf(options),
2725
+ options.cellPadX,
2726
+ options.labelIndent,
2727
+ options.outlineMarks,
2728
+ options.figures,
2729
+ options.inlineVisibility,
2730
+ options.rowLabelLines,
2731
+ options[LABEL_WRAP_FLOOR],
2732
+ ids(view.columns),
2733
+ ids(view.rows),
2734
+ ids(view.widthRows),
2735
+ ids(view.fullRows),
2736
+ ids(view.allColumns),
2737
+ view.spacerTotal,
2738
+ view.scroll,
2739
+ view.headLines,
2740
+ view.headGlue,
2741
+ view.withMarks,
2742
+ view.trailingTracking,
2743
+ view.sortable && [...view.sortable],
2744
+ view.groupStart && [...view.groupStart],
2745
+ view.groupEnd && [...view.groupEnd],
2746
+ view.leadWidth,
2747
+ view.labelKeep
2748
+ ]), variants = measuredTables.get(table);
2749
+ variants || measuredTables.set(table, variants = /* @__PURE__ */ new Map());
2750
+ let measured = variants.get(key);
2751
+ return measured || (variants.size >= 64 && variants.delete(variants.keys().next().value), variants.set(key, measured = measureTableTracks(table, theme, measure, options, view))), measured;
2752
+ }
2753
+ function prepareTableWidthRung(table, theme, measure, options, view) {
2754
+ return { table, theme, measure, options, view, measured: measuredTable(table, theme, measure, options, view) };
2755
+ }
2756
+ function solveTableWidthRung(rung, available, options = rung.options, probe) {
2757
+ let { table, theme, measure, view } = rung, { cols, columnIds, columnIndex, indices, labelIndices, textIndices, compactIndices, growingIndices, widthRows, spacerBefore, spacerTotal, figures, wideTable, cellPadX: cellPadX2, labelColumn, labelLead, groupCell, headingFaces, regularFonts, cellStep, indentStep, childCount, indents, operatorSlot, rowIndent, cellFont, columnHeaderText, chipSpan, sumOf, hasChanges, uncutLabelWidth, regular, dense, minimumW, wrapMinimumWidth, regularHeadsFit } = rung.measured, warnings = [], chosen = dense !== void 0 && (!regularHeadsFit || !view.scroll && sumOf(regular.widths) > available) ? dense : regular, fonts = chosen.context.fonts, widths = chosen.widths.slice(), minimumWidths = chosen.minimumWidths, sizingMinimums = (dense ?? regular).minimumWidths;
2758
+ if (view.scroll && view.fit === void 0 && Number.isFinite(available) && chosen.wrappedOneLines.length > 0) {
2759
+ let want = chosen.wrappedOneLines.reduce((sum, entry) => sum + Math.max(0, entry.width - widths[entry.index]), 0), share = Math.max(0, Math.min(want, available - sumOf(widths)));
2760
+ if (share > 0) for (let { index, width: oneLine } of chosen.wrappedOneLines) {
2761
+ let natural = widths[index];
2762
+ widths[index] = Math.floor(natural + share * Math.max(0, oneLine - natural) / want);
2445
2763
  }
2446
2764
  }
2447
- let canShrink = (col) => !view.scroll || col.width === void 0 && col.kind === "rowLabel", flexIds = cols.filter((c) => canShrink(c) && (c.kind === "rowLabel" || c.kind === "text")).map((c) => c.id), totalW = sumOf(widths), floorFlexIds = cols.filter((col) => col.kind === "rowLabel" || col.kind === "text").map((col) => col.id), minimumW = Math.max(sumOf(sizingMinimums), sumOf(shrinkReach(cols, floorFlexIds, wideTable, sizingTracks, sizingMinimums, (dense ?? regular).labelFloor)));
2448
- if (totalW > available && flexIds.length > 0) {
2449
- let deficit = totalW - available, beforeShrink = new Map(widths), floorOf = (col) => view.scroll ? chosen.labelFloor : shrinkFloorWidth(col, wideTable, minimumWidths, chosen.labelFloor);
2450
- for (let col of cols.filter((c) => canShrink(c) && c.kind === "rowLabel")) {
2451
- let take = Math.min(deficit, Math.max(0, widths.get(col.id) - Math.max(minimumWidths.get(col.id), view.scroll ? view.labelKeep ?? 0 : 0)));
2452
- take > 0 && (widths.set(col.id, widths.get(col.id) - take), deficit -= take);
2765
+ let totalW = sumOf(widths);
2766
+ if (probe && !view.scroll && options.cellPadX !== void 0 && cellPadX2 === probe.footerInset && probe.canvasWidth < probe.canvasWidth - available + minimumW)
2767
+ return { widthMiss: !0, minimumW, totalW, cellPadX: cellPadX2 };
2768
+ if (totalW > available && labelIndices.length + textIndices.length > 0) {
2769
+ let deficit = totalW - available, beforeShrink = widths.slice(), floorOf = (index) => view.scroll ? chosen.labelFloor : shrinkFloorWidth(cols[index], wideTable, minimumWidths[index], chosen.labelFloor);
2770
+ for (let index of labelIndices) {
2771
+ let take = Math.min(deficit, Math.max(0, widths[index] - Math.max(minimumWidths[index], view.scroll ? view.labelKeep ?? 0 : 0)));
2772
+ take > 0 && (widths[index] = widths[index] - take, deficit -= take);
2453
2773
  }
2454
2774
  for (let kind of ["text", "rowLabel"]) {
2455
2775
  if (deficit <= 0) break;
2456
- let shrinkable = cols.filter((c) => canShrink(c) && c.kind === kind).map((col) => ({
2457
- id: col.id,
2458
- room: Math.max(0, widths.get(col.id) - floorOf(col))
2776
+ let shrinkable = (kind === "text" ? textIndices : labelIndices).map((index) => ({
2777
+ index,
2778
+ room: Math.max(0, widths[index] - floorOf(index))
2459
2779
  })).filter((f) => f.room > 0), totalRoom = shrinkable.reduce((a, f) => a + f.room, 0);
2460
2780
  if (totalRoom <= 0) continue;
2461
2781
  let take = Math.min(deficit, totalRoom);
2462
2782
  for (let f of shrinkable) {
2463
2783
  let cut2 = take * f.room / totalRoom;
2464
- widths.set(f.id, Math.round(widths.get(f.id) - cut2));
2784
+ widths[f.index] = Math.round(widths[f.index] - cut2);
2465
2785
  }
2466
2786
  deficit -= take;
2467
2787
  }
2468
2788
  if (deficit <= 0) {
2469
- let flex = cols.filter((col) => canShrink(col) && (col.kind === "rowLabel" || col.kind === "text"));
2789
+ let flex = indices.filter((index) => labelIndices.includes(index) || textIndices.includes(index));
2470
2790
  for (let over = Math.ceil(sumOf(widths) - available); over > 0; over--) {
2471
- let roomOf2 = (col) => widths.get(col.id) - floorOf(col), widest = flex.reduce((best, col) => best === void 0 || roomOf2(col) > roomOf2(best) ? col : best, void 0);
2791
+ let roomOf2 = (index) => widths[index] - floorOf(index), widest = flex.reduce((best, index) => best === void 0 || roomOf2(index) > roomOf2(best) ? index : best, void 0);
2472
2792
  if (widest === void 0 || roomOf2(widest) < 1) break;
2473
- widths.set(widest.id, widths.get(widest.id) - 1);
2793
+ widths[widest] = widths[widest] - 1;
2474
2794
  }
2475
2795
  }
2476
2796
  let remaining = Math.ceil(sumOf(widths) - available);
2477
2797
  if (remaining > 0 && wideTable) {
2478
- let compactable = cols.filter((col) => canShrink(col) && col.kind !== "rowLabel" && col.kind !== "text").map((col) => col.id);
2798
+ let compactable = compactIndices;
2479
2799
  for (; remaining > 0; ) {
2480
- let changed = !1;
2481
- for (let id of compactable) {
2800
+ let open = compactable.filter((index) => widths[index] > minimumWidths[index]);
2801
+ if (open.length === 0) break;
2802
+ let rounds = Math.max(1, Math.min(Math.floor(remaining / open.length), ...open.map((index) => Math.ceil(widths[index] - minimumWidths[index]))));
2803
+ for (let index of open) {
2482
2804
  if (remaining <= 0) break;
2483
- let current = widths.get(id), minimum = minimumWidths.get(id);
2484
- current <= minimum || (widths.set(id, current - 1), remaining--, changed = !0);
2805
+ widths[index] = widths[index] - rounds, remaining -= rounds;
2485
2806
  }
2486
- if (!changed) break;
2487
2807
  }
2488
2808
  }
2489
- let printsUncut = (col) => col.wrap ? minimumWidths.get(col.id) : intrinsicColumnWidth(col, widthRows, { ...chosen.context, hint: void 0, twoLineLabels: !0 }), flexText = cols.filter((col) => canShrink(col) && col.kind === "text" && col.width === void 0), gapOf = (col) => ({ id: col.id, gap: printsUncut(col) - widths.get(col.id) }), cutGaps = flexText.filter((col) => widths.get(col.id) < beforeShrink.get(col.id)).map(gapOf), wants = cutGaps.filter((entry) => entry.gap > 0), gaps = wants.length === 0 ? [] : flexText.map((col) => cutGaps.find((entry) => entry.id === col.id) ?? gapOf(col)), wanted = wants.reduce((sum, entry) => sum + entry.gap, 0), groupFaces = headingFaces(fonts), spare = new Map(table.columnGroups.filter((group) => group.heading !== !1).map((group) => [
2809
+ let printsUncut = (col) => col.wrap ? minimumWidths[columnIndex.get(col.id)] : intrinsicColumnWidth(col, widthRows, { ...chosen.context, hint: void 0, labelLines: 2 }), flexText = textIndices.map((index) => cols[index]).filter((col) => col.width === void 0), gapOf = (col) => ({ id: col.id, gap: printsUncut(col) - widths[columnIndex.get(col.id)] }), cutGaps = flexText.filter((col) => widths[columnIndex.get(col.id)] < beforeShrink[columnIndex.get(col.id)]).map(gapOf), wants = cutGaps.filter((entry) => entry.gap > 0), gaps = wants.length === 0 ? [] : flexText.map((col) => cutGaps.find((entry) => entry.id === col.id) ?? gapOf(col)), wanted = wants.reduce((sum, entry) => sum + entry.gap, 0), groupFaces = headingFaces(fonts), spare = new Map(table.columnGroups.filter((group) => group.heading !== !1).map((group) => [
2490
2810
  group.id,
2491
- cols.filter((col) => group.columnIds.includes(col.id)).reduce((sum, col) => sum + widths.get(col.id), 0) - groupHeadingNeed(group, groupFaces, measure, groupCell)
2811
+ cols.filter((col) => group.columnIds.includes(col.id)).reduce((sum, col) => sum + widths[columnIndex.get(col.id)], 0) - groupHeadingNeed(group, groupFaces, measure, groupCell)
2492
2812
  ])), donors = gaps.filter((entry) => entry.gap < 0).map((entry) => ({
2493
2813
  id: entry.id,
2494
2814
  slack: Math.floor(-entry.gap),
2495
2815
  groups: table.columnGroups.filter((group) => spare.has(group.id) && group.columnIds.includes(entry.id))
2496
2816
  })), roomOf = (donor) => Math.max(0, Math.min(donor.slack, ...donor.groups.map((group) => spare.get(group.id)))), rooms = donors.map(roomOf), given = rooms.reduce((sum, room2) => sum + room2, 0), move = Math.floor(Math.min(wanted, given)), moved = 0, cut = (donor, amount) => {
2497
2817
  let take = Math.min(amount, roomOf(donor));
2498
- widths.set(donor.id, widths.get(donor.id) - take), donor.slack -= take;
2818
+ widths[columnIndex.get(donor.id)] = widths[columnIndex.get(donor.id)] - take, donor.slack -= take;
2499
2819
  for (let group of donor.groups) spare.set(group.id, spare.get(group.id) - take);
2500
2820
  moved += take;
2501
2821
  };
@@ -2508,12 +2828,12 @@ function tableWidthsOnce(table, theme, measure, options = {}, view = {}) {
2508
2828
  let toTake = moved;
2509
2829
  for (let [index, entry] of wants.entries()) {
2510
2830
  let add = index === wants.length - 1 ? toTake : Math.min(toTake, Math.floor(moved * entry.gap / wanted));
2511
- widths.set(entry.id, widths.get(entry.id) + add), toTake -= add;
2831
+ widths[columnIndex.get(entry.id)] = widths[columnIndex.get(entry.id)] + add, toTake -= add;
2512
2832
  }
2513
2833
  }
2514
- labelColumn !== void 0 && chipSpan(widths) < chosen.chipFloor && widths.set(labelColumn.id, widths.get(labelColumn.id) + chosen.chipFloor - chipSpan(widths));
2834
+ labelColumn !== void 0 && chipSpan(widths) < chosen.chipFloor && (widths[columnIndex.get(labelColumn.id)] = widths[columnIndex.get(labelColumn.id)] + chosen.chipFloor - chipSpan(widths));
2515
2835
  }
2516
- let narrowed = cols.some((col) => col.width !== void 0 && (figures || !heatColumn(col)) && widths.get(col.id) < col.width);
2836
+ let narrowed = cols.some((col) => col.width !== void 0 && (figures || !heatColumn(col)) && widths[columnIndex.get(col.id)] < col.width);
2517
2837
  if (narrowed || sumOf(widths) > available) {
2518
2838
  let margin = resolveCanvasOptions(options).margin, frameWidth = Math.ceil(totalW);
2519
2839
  for (let pass = 0; pass < 4; pass++) {
@@ -2532,24 +2852,25 @@ function tableWidthsOnce(table, theme, measure, options = {}, view = {}) {
2532
2852
  fix: [{ op: "add", path: "/options/size", value: { width: frameWidth, ...height === void 0 ? {} : { height } } }]
2533
2853
  });
2534
2854
  }
2535
- let grownFrom = /* @__PURE__ */ new Map(), grow = (id, add) => {
2536
- grownFrom.has(id) || grownFrom.set(id, widths.get(id)), widths.set(id, widths.get(id) + add);
2855
+ let grownFrom = [], grow = (id, add) => {
2856
+ let index = columnIndex.get(id);
2857
+ grownFrom[index] === void 0 && (grownFrom[index] = widths[index]), widths[index] = widths[index] + add;
2537
2858
  }, room = Number.isFinite(available) ? Math.floor(available - sumOf(widths)) : 1 / 0;
2538
2859
  if (Number.isFinite(available) && options.frameFill !== "none")
2539
2860
  for (let col of cols) {
2540
2861
  if (room < 1) break;
2541
2862
  if (col.width === void 0 || col.kind !== "value" && col.kind !== "computed" || !figures && heatColumn(col)) continue;
2542
- let add = Math.min(room, Math.ceil(minimumWidths.get(col.id) - widths.get(col.id)));
2863
+ let add = Math.min(room, Math.ceil(minimumWidths[columnIndex.get(col.id)] - widths[columnIndex.get(col.id)]));
2543
2864
  add < 1 || (grow(col.id, add), room -= add);
2544
2865
  }
2545
- for (let [id, short] of groupHeadingFloors(table.columnGroups, cols.map((col) => col.id), (member) => widths.get(member) ?? 0, () => !1, headingFaces(fonts), measure, groupCell)) {
2866
+ for (let [id, short] of groupHeadingFloors(table.columnGroups, columnIds, (member) => widths[columnIndex.get(member)] ?? 0, () => !1, headingFaces(fonts), measure, groupCell)) {
2546
2867
  let add = options.frameFill === "none" ? 0 : Math.max(0, Math.min(room, Math.ceil(short)));
2547
2868
  add >= 1 && (grow(id, add), room -= add);
2548
2869
  let group = table.columnGroups.find((candidate) => candidate.columnIds.includes(id)), wraps = () => !view.scroll && groupHeadingWrap(
2549
2870
  group,
2550
2871
  headingFaces(fonts),
2551
2872
  measure,
2552
- cols.filter((col) => group.columnIds.includes(col.id)).reduce((sum, col) => sum + widths.get(col.id), 0) - 2 * cellPadX2 - (groupCell.startRule?.(group.id) ?? 0)
2873
+ cols.filter((col) => group.columnIds.includes(col.id)).reduce((sum, col) => sum + widths[columnIndex.get(col.id)], 0) - 2 * cellPadX2 - (groupCell.startRule?.(group.id) ?? 0)
2553
2874
  ) !== void 0;
2554
2875
  short - add > 0.5 && !wraps() && warnings.push({
2555
2876
  code: "table-group-heading-overflow",
@@ -2559,24 +2880,25 @@ function tableWidthsOnce(table, theme, measure, options = {}, view = {}) {
2559
2880
  });
2560
2881
  }
2561
2882
  for (let col of cols) if (figures || !heatColumn(col)) {
2562
- let grown = grownFrom.get(col.id), track = grown ?? widths.get(col.id), minimum = col.kind === "rowLabel" && col.width !== void 0 && minimumWidths.get(col.id) > track ? intrinsicColumnWidth(col, widthRows, { ...chosen.context, twoLineLabels: options.rowLabelLines !== 1 }) : minimumWidths.get(col.id), found = authoredWidthWarnings(col, table.columns.findIndex((authored) => authored.id === col.id), track, minimum, chosen.context);
2563
- warnings.push(...grown === void 0 ? found : found.filter((warning) => warning.code === "table-column-widened" || widths.get(col.id) < minimumWidths.get(col.id)));
2883
+ let grown = grownFrom[columnIndex.get(col.id)], track = grown ?? widths[columnIndex.get(col.id)], minimum = col.kind === "rowLabel" && col.width !== void 0 && minimumWidths[columnIndex.get(col.id)] > track ? intrinsicColumnWidth(col, widthRows, { ...chosen.context, labelLines: options.rowLabelLines ?? 2 }) : minimumWidths[columnIndex.get(col.id)], found = authoredWidthWarnings(col, table.columns.findIndex((authored) => authored.id === col.id), track, minimum, chosen.context);
2884
+ warnings.push(...grown === void 0 ? found : found.filter((warning) => warning.code === "table-column-widened" || widths[columnIndex.get(col.id)] < minimumWidths[columnIndex.get(col.id)]));
2564
2885
  }
2565
2886
  let rowToFrame = (options.rowExtent ?? "frame") === "frame";
2566
2887
  if (Number.isFinite(available) && options.lastTrackFlex === !0 && !rowToFrame && cols.length > 0) {
2567
2888
  let slack = available - sumOf(widths), lastCol = cols[cols.length - 1];
2568
- slack > 0 && lastCol.width === void 0 && widths.set(lastCol.id, widths.get(lastCol.id) + slack);
2889
+ slack > 0 && lastCol.width === void 0 && (widths[columnIndex.get(lastCol.id)] = widths[columnIndex.get(lastCol.id)] + slack);
2569
2890
  }
2570
- let beforeFill = new Map(widths);
2891
+ let beforeFill = widths.slice();
2571
2892
  if (Number.isFinite(available) && rowToFrame && options.frameFill !== "none") {
2572
- let growing = cols.filter((col) => col.width === void 0 && (col.kind === "value" || col.kind === "computed") && (figures || !heatColumn(col))), extras = frameFillExtras(
2573
- growing.map((col) => ({ id: col.id, width: widths.get(col.id) })),
2574
- available - sumOf(widths),
2575
- options.maxGrowth,
2576
- labelColumn?.width === void 0 ? labelColumn?.id : void 0
2577
- ), labelCap = labelColumn?.maxWidth;
2578
- labelColumn !== void 0 && labelCap !== void 0 && extras.has(labelColumn.id) && extras.set(labelColumn.id, Math.max(0, Math.min(extras.get(labelColumn.id), labelCap - widths.get(labelColumn.id))));
2579
- for (let [id, extra] of extras) widths.set(id, widths.get(id) + extra);
2893
+ let extras = frameFillAmounts(growingIndices.map((index) => widths[index]), available - sumOf(widths), options.maxGrowth);
2894
+ for (let item = 0; item < extras.values.length; item++) {
2895
+ let index = growingIndices[item];
2896
+ widths[index] = widths[index] + extras.values[item];
2897
+ }
2898
+ if (labelColumn !== void 0 && labelColumn.width === void 0 && extras.remainder > 0) {
2899
+ let index = columnIndex.get(labelColumn.id), extra = labelColumn.maxWidth === void 0 ? extras.remainder : Math.max(0, Math.min(extras.remainder, labelColumn.maxWidth - widths[index]));
2900
+ widths[index] = widths[index] + extra;
2901
+ }
2580
2902
  }
2581
2903
  let labelNeed;
2582
2904
  if (labelColumn !== void 0 && labelColumn.width === void 0) {
@@ -2584,36 +2906,31 @@ function tableWidthsOnce(table, theme, measure, options = {}, view = {}) {
2584
2906
  { ...labelColumn, maxWidth: void 0, maxTextWidth: void 0 },
2585
2907
  widthRows,
2586
2908
  { ...chosen.context, hint: void 0 }
2587
- ) + labelLead : Math.ceil(Math.max(0, maxOf(rows.map((row) => {
2588
- let cell = row.cells[labelId];
2589
- if (row.role === "section" || !cell?.displayed) return 0;
2590
- let font = cellFont(cell);
2591
- return measure(cell.displayed, font).width + affixRoom(row, font) + rowIndent(indentStep(cell)) + 2 * cellPadX2;
2592
- })))), cap = labelColumn.maxWidth !== void 0 && options[SOFT_LABEL_CAP] !== !0 ? labelColumn.maxWidth : 1 / 0;
2909
+ ) + labelLead : uncutLabelWidth(), cap = labelColumn.maxWidth !== void 0 && options[SOFT_LABEL_CAP] !== !0 ? labelColumn.maxWidth : 1 / 0;
2593
2910
  labelNeed = Math.min(need, cap);
2594
- let short = labelNeed - widths.get(labelId);
2911
+ let short = labelNeed - widths[columnIndex.get(labelId)];
2595
2912
  if (short > 0) {
2596
2913
  let outside = Number.isFinite(available) ? Math.min(short, Math.max(0, Math.floor(available - sumOf(widths)))) : 0;
2597
- widths.set(labelId, widths.get(labelId) + outside), short -= outside;
2598
- let grown = cols.filter((col) => col.id !== labelId && widths.get(col.id) > beforeFill.get(col.id)), total = grown.reduce((sum, col) => sum + widths.get(col.id) - beforeFill.get(col.id), 0), take = Math.min(short, Math.floor(total)), left = take;
2914
+ widths[columnIndex.get(labelId)] = widths[columnIndex.get(labelId)] + outside, short -= outside;
2915
+ let grown = cols.filter((col) => col.id !== labelId && widths[columnIndex.get(col.id)] > beforeFill[columnIndex.get(col.id)]), total = grown.reduce((sum, col) => sum + widths[columnIndex.get(col.id)] - beforeFill[columnIndex.get(col.id)], 0), take = Math.min(short, Math.floor(total)), left = take;
2599
2916
  for (let [index, col] of grown.entries()) {
2600
- let extra = widths.get(col.id) - beforeFill.get(col.id), back = index === grown.length - 1 ? Math.min(left, Math.floor(extra)) : Math.min(left, Math.floor(take * extra / total));
2601
- widths.set(col.id, widths.get(col.id) - back), left -= back;
2917
+ let extra = widths[columnIndex.get(col.id)] - beforeFill[columnIndex.get(col.id)], back = index === grown.length - 1 ? Math.min(left, Math.floor(extra)) : Math.min(left, Math.floor(take * extra / total));
2918
+ widths[columnIndex.get(col.id)] = widths[columnIndex.get(col.id)] - back, left -= back;
2602
2919
  }
2603
- widths.set(labelId, widths.get(labelId) + take - left);
2920
+ widths[columnIndex.get(labelId)] = widths[columnIndex.get(labelId)] + take - left;
2604
2921
  }
2605
2922
  }
2606
- let tracks = columnTracks((view.allColumns ?? cols).map((col) => ({ id: col.id, natural: widths.get(col.id) ?? 0 })), {
2923
+ let tracks = columnTracks((view.allColumns ?? cols).map((col) => ({ id: col.id, natural: widths[columnIndex.get(col.id)] ?? 0 })), {
2607
2924
  fit: rowToFrame ? "content" : view.fit,
2608
2925
  available: Number.isFinite(available) && (!view.scroll || view.fit !== void 0) ? Math.max(0, available - spacerTotal) : void 0,
2609
2926
  anchorId: (view.allColumns ?? cols)[0]?.id,
2610
- hidden: view.allColumns === void 0 ? void 0 : new Set(view.allColumns.filter((col) => !widths.has(col.id)).map((col) => col.id)),
2927
+ hidden: view.allColumns === void 0 ? void 0 : new Set(view.allColumns.filter((col) => !columnIndex.has(col.id)).map((col) => col.id)),
2611
2928
  fixed: new Set(cols.filter((col) => col.width !== void 0 || !figures && heatColumn(col)).map((col) => col.id)),
2612
2929
  ...options.maxGrowth === !1 ? {} : { maxGrowth: options.maxGrowth ?? DEFAULT_TRACK_GROWTH }
2613
- }), labelsWrap = labelColumn !== void 0 && labelNeed !== void 0 && widths.get(labelColumn.id) < labelNeed, gridTracks = tracks.flatMap((track, index) => {
2930
+ }), labelsWrap = labelColumn !== void 0 && labelNeed !== void 0 && widths[columnIndex.get(labelColumn.id)] < labelNeed, gridTracks = tracks.flatMap((track, index) => {
2614
2931
  let spacer = spacerBefore.get(track.id), drawn = index === 0 && (view.frameStart ?? 0) > 0 ? { ...track, width: track.width + view.frameStart } : track;
2615
2932
  return spacer === void 0 ? [drawn] : [{ id: `bp-spacer:${track.id}`, natural: spacer, width: spacer }, drawn];
2616
- }), labelBeforeFill = labelColumn === void 0 ? void 0 : beforeFill.get(labelColumn.id);
2933
+ }), labelBeforeFill = labelColumn === void 0 ? void 0 : beforeFill[columnIndex.get(labelColumn.id)];
2617
2934
  return {
2618
2935
  tracks,
2619
2936
  gridTracks,
@@ -2622,6 +2939,7 @@ function tableWidthsOnce(table, theme, measure, options = {}, view = {}) {
2622
2939
  labelNeed,
2623
2940
  labelBeforeFill,
2624
2941
  labelsWrap,
2942
+ columnIndex,
2625
2943
  widths,
2626
2944
  minimumWidths,
2627
2945
  sizingMinimums,
@@ -2629,7 +2947,7 @@ function tableWidthsOnce(table, theme, measure, options = {}, view = {}) {
2629
2947
  minimumW,
2630
2948
  fonts,
2631
2949
  regularFonts,
2632
- context: chosen.context,
2950
+ context: chosen.context.theme === theme ? chosen.context : { ...chosen.context, theme },
2633
2951
  wouldWrap: (dense ?? regular).wouldWrap,
2634
2952
  wrapMinimumWidth,
2635
2953
  warnings,
@@ -2645,16 +2963,16 @@ function tableWidthsOnce(table, theme, measure, options = {}, view = {}) {
2645
2963
  hasChanges
2646
2964
  };
2647
2965
  }
2648
- function shrinkFloorWidth(col, wideTable, minimumWidths, labelFloor = 0) {
2649
- return col.kind === "rowLabel" ? Math.min(col.width ?? 1 / 0, Math.max(wideTable ? 180 : FLEX_MIN, labelFloor)) : col.kind === "text" && col.wrap ? Math.max(FLEX_MIN, minimumWidths.get(col.id) ?? FLEX_MIN) : FLEX_MIN;
2966
+ function materializeTableWidthPlan(plan) {
2967
+ let { columnIndex, ...rest } = plan, map = (values) => new Map([...columnIndex].map(([id, index]) => [id, values[index]]));
2968
+ return { ...rest, widths: map(plan.widths), minimumWidths: map(plan.minimumWidths), sizingMinimums: map(plan.sizingMinimums) };
2650
2969
  }
2651
- function shrinkReach(cols, flexIds, wideTable, drawn, minimumWidths, labelFloor = 0) {
2652
- return new Map(cols.map((col) => {
2653
- let width = drawn.get(col.id) ?? 0, minimum = minimumWidths.get(col.id) ?? width;
2654
- if (!flexIds.includes(col.id)) return [col.id, wideTable ? Math.min(width, minimum) : width];
2655
- let floor = shrinkFloorWidth(col, wideTable, minimumWidths, labelFloor);
2656
- return [col.id, Math.min(width, floor, col.kind === "rowLabel" ? minimum : width)];
2657
- }));
2970
+ function tableWidthsOnce(table, theme, measure, options = {}, view = {}, probe) {
2971
+ let result = solveTableWidthRung(prepareTableWidthRung(table, theme, measure, options, view), view.available ?? 1 / 0, options, probe);
2972
+ return result.widthMiss === !0 ? result : materializeTableWidthPlan(result);
2973
+ }
2974
+ function shrinkFloorWidth(col, wideTable, minimumWidth, labelFloor = 0) {
2975
+ return col.kind === "rowLabel" ? Math.min(col.width ?? 1 / 0, Math.max(wideTable ? 180 : FLEX_MIN, labelFloor)) : col.kind === "text" && col.wrap ? Math.max(FLEX_MIN, minimumWidth ?? FLEX_MIN) : FLEX_MIN;
2658
2976
  }
2659
2977
  function tableDisplayFloor(table, theme, options, target, width, frame) {
2660
2978
  let ladder = levelLadder(theme, options.density ?? "regular", target, textScaleOf(options)), fonts = tableFonts(theme, ladder), floors = targetFloorsPx(target), scale = 0.9, include = (size, role) => {
@@ -2664,7 +2982,7 @@ function tableDisplayFloor(table, theme, options, target, width, frame) {
2664
2982
  let includeHead = (size) => {
2665
2983
  scale = Math.max(scale, tableHeadFloorPx(target) / size);
2666
2984
  };
2667
- table.columns.length && includeHead(fonts.header.size), table.columns.some((column) => column.subLabel) && includeHead(fonts.sub.size), table.columnGroups.some((group) => group.heading !== !1) && includeHead(fonts.group.size);
2985
+ options.columnHeads !== !1 && (table.columns.length && includeHead(fonts.header.size), table.columns.some((column) => column.subLabel) && includeHead(fonts.sub.size), table.columnGroups.some((group) => group.heading !== !1) && includeHead(fonts.group.size));
2668
2986
  for (let row of table.rows) {
2669
2987
  if (row.inline) continue;
2670
2988
  let hasChanges = visibleInlineRows(row, options.inlineVisibility).length > 0;
@@ -2704,6 +3022,8 @@ export {
2704
3022
  emitHeat,
2705
3023
  ZERO_LIFT,
2706
3024
  columnHeaderAffix,
3025
+ prepareTableData,
3026
+ resolvePreparedTable,
2707
3027
  resolveTable,
2708
3028
  cellHoldsNumber,
2709
3029
  numericCell,
@@ -2728,6 +3048,8 @@ export {
2728
3048
  groupSpans,
2729
3049
  inCellBarMaxima,
2730
3050
  tableWidths,
3051
+ prepareTableWidthRung,
3052
+ solveTableWidthRung,
2731
3053
  tableDisplayFloor,
2732
3054
  belowTableViewportFloor,
2733
3055
  tableFrameMode