@senvenli/react 0.0.0-stage → 0.1.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 (636) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +32 -2
  3. package/dist/action/button-group.d.ts +26 -0
  4. package/dist/action/button-group.js +12 -0
  5. package/dist/action/button-group.js.map +1 -0
  6. package/dist/action/button.d.ts +42 -0
  7. package/dist/action/button.js +58 -0
  8. package/dist/action/button.js.map +1 -0
  9. package/dist/action/close-button.d.ts +12 -0
  10. package/dist/action/close-button.js +13 -0
  11. package/dist/action/close-button.js.map +1 -0
  12. package/dist/action/copy-button.d.ts +21 -0
  13. package/dist/action/copy-button.js +38 -0
  14. package/dist/action/copy-button.js.map +1 -0
  15. package/dist/action/fab.d.ts +29 -0
  16. package/dist/action/fab.js +57 -0
  17. package/dist/action/fab.js.map +1 -0
  18. package/dist/action/files.d.ts +70 -0
  19. package/dist/action/files.js +156 -0
  20. package/dist/action/files.js.map +1 -0
  21. package/dist/action/index.d.ts +23 -0
  22. package/dist/action/index.js +16 -0
  23. package/dist/action/index.js.map +1 -0
  24. package/dist/action/language-names.d.ts +19 -0
  25. package/dist/action/language-names.js +79 -0
  26. package/dist/action/language-names.js.map +1 -0
  27. package/dist/action/language-switcher.d.ts +57 -0
  28. package/dist/action/language-switcher.js +53 -0
  29. package/dist/action/language-switcher.js.map +1 -0
  30. package/dist/action/link-button.d.ts +57 -0
  31. package/dist/action/link-button.js +48 -0
  32. package/dist/action/link-button.js.map +1 -0
  33. package/dist/action/link.d.ts +24 -0
  34. package/dist/action/link.js +18 -0
  35. package/dist/action/link.js.map +1 -0
  36. package/dist/action/pressable.d.ts +40 -0
  37. package/dist/action/pressable.js +65 -0
  38. package/dist/action/pressable.js.map +1 -0
  39. package/dist/action/styles.d.ts +60 -0
  40. package/dist/action/styles.js +109 -0
  41. package/dist/action/styles.js.map +1 -0
  42. package/dist/action/theme-script.d.ts +12 -0
  43. package/dist/action/theme-script.js +23 -0
  44. package/dist/action/theme-script.js.map +1 -0
  45. package/dist/action/theme-switcher.d.ts +43 -0
  46. package/dist/action/theme-switcher.js +260 -0
  47. package/dist/action/theme-switcher.js.map +1 -0
  48. package/dist/action/theme-toggle.d.ts +43 -0
  49. package/dist/action/theme-toggle.js +259 -0
  50. package/dist/action/theme-toggle.js.map +1 -0
  51. package/dist/action/toggle.d.ts +44 -0
  52. package/dist/action/toggle.js +28 -0
  53. package/dist/action/toggle.js.map +1 -0
  54. package/dist/action/touch-target.d.ts +9 -0
  55. package/dist/action/touch-target.js +14 -0
  56. package/dist/action/touch-target.js.map +1 -0
  57. package/dist/charts/axis-width.d.ts +186 -0
  58. package/dist/charts/axis-width.js +1262 -0
  59. package/dist/charts/axis-width.js.map +1 -0
  60. package/dist/charts/bar-public.d.ts +16 -0
  61. package/dist/charts/bar-public.js +16 -0
  62. package/dist/charts/bar-public.js.map +1 -0
  63. package/dist/charts/chart-parts.d.ts +136 -0
  64. package/dist/charts/chart-parts.js +160 -0
  65. package/dist/charts/chart-parts.js.map +1 -0
  66. package/dist/charts/core-charts.d.ts +157 -0
  67. package/dist/charts/core-charts.js +505 -0
  68. package/dist/charts/core-charts.js.map +1 -0
  69. package/dist/charts/index.d.ts +12 -0
  70. package/dist/charts/index.js +8 -0
  71. package/dist/charts/index.js.map +1 -0
  72. package/dist/charts/list-charts.d.ts +124 -0
  73. package/dist/charts/list-charts.js +308 -0
  74. package/dist/charts/list-charts.js.map +1 -0
  75. package/dist/charts/more-charts.d.ts +138 -0
  76. package/dist/charts/more-charts.js +284 -0
  77. package/dist/charts/more-charts.js.map +1 -0
  78. package/dist/charts/report-charts.d.ts +138 -0
  79. package/dist/charts/report-charts.js +370 -0
  80. package/dist/charts/report-charts.js.map +1 -0
  81. package/dist/charts/value-tick.d.ts +178 -0
  82. package/dist/charts/value-tick.js +240 -0
  83. package/dist/charts/value-tick.js.map +1 -0
  84. package/dist/collection/data-table-url-hook.d.ts +34 -0
  85. package/dist/collection/data-table-url-hook.js +70 -0
  86. package/dist/collection/data-table-url-hook.js.map +1 -0
  87. package/dist/collection/data-table-url.d.ts +30 -0
  88. package/dist/collection/data-table-url.js +48 -0
  89. package/dist/collection/data-table-url.js.map +1 -0
  90. package/dist/collection/data-table.d.ts +112 -0
  91. package/dist/collection/data-table.js +188 -0
  92. package/dist/collection/data-table.js.map +1 -0
  93. package/dist/collection/grid-list-public.d.ts +18 -0
  94. package/dist/collection/grid-list-public.js +19 -0
  95. package/dist/collection/grid-list-public.js.map +1 -0
  96. package/dist/collection/grid-list.d.ts +73 -0
  97. package/dist/collection/grid-list.js +46 -0
  98. package/dist/collection/grid-list.js.map +1 -0
  99. package/dist/collection/index.d.ts +14 -0
  100. package/dist/collection/index.js +8 -0
  101. package/dist/collection/index.js.map +1 -0
  102. package/dist/collection/list.d.ts +61 -0
  103. package/dist/collection/list.js +38 -0
  104. package/dist/collection/list.js.map +1 -0
  105. package/dist/collection/selection-checkbox.d.ts +5 -0
  106. package/dist/collection/selection-checkbox.js +13 -0
  107. package/dist/collection/selection-checkbox.js.map +1 -0
  108. package/dist/collection/table.d.ts +91 -0
  109. package/dist/collection/table.js +183 -0
  110. package/dist/collection/table.js.map +1 -0
  111. package/dist/collection/tree.d.ts +31 -0
  112. package/dist/collection/tree.js +22 -0
  113. package/dist/collection/tree.js.map +1 -0
  114. package/dist/color/color.d.ts +87 -0
  115. package/dist/color/color.js +200 -0
  116. package/dist/color/color.js.map +1 -0
  117. package/dist/color/contrast.d.ts +34 -0
  118. package/dist/color/contrast.js +44 -0
  119. package/dist/color/contrast.js.map +1 -0
  120. package/dist/color/index.d.ts +4 -0
  121. package/dist/color/index.js +5 -0
  122. package/dist/color/index.js.map +1 -0
  123. package/dist/date/calendar.d.ts +71 -0
  124. package/dist/date/calendar.js +291 -0
  125. package/dist/date/calendar.js.map +1 -0
  126. package/dist/date/fields.d.ts +174 -0
  127. package/dist/date/fields.js +250 -0
  128. package/dist/date/fields.js.map +1 -0
  129. package/dist/date/index.d.ts +7 -0
  130. package/dist/date/index.js +6 -0
  131. package/dist/date/index.js.map +1 -0
  132. package/dist/date/month-grid.d.ts +31 -0
  133. package/dist/date/month-grid.js +115 -0
  134. package/dist/date/month-grid.js.map +1 -0
  135. package/dist/date/pickers.d.ts +118 -0
  136. package/dist/date/pickers.js +176 -0
  137. package/dist/date/pickers.js.map +1 -0
  138. package/dist/date/public.d.ts +25 -0
  139. package/dist/date/public.js +24 -0
  140. package/dist/date/public.js.map +1 -0
  141. package/dist/date/segments.d.ts +153 -0
  142. package/dist/date/segments.js +433 -0
  143. package/dist/date/segments.js.map +1 -0
  144. package/dist/defaults.d.ts +74 -0
  145. package/dist/defaults.js +100 -0
  146. package/dist/defaults.js.map +1 -0
  147. package/dist/density.d.ts +2 -0
  148. package/dist/density.js +2 -0
  149. package/dist/density.js.map +1 -0
  150. package/dist/display/avatar.d.ts +29 -0
  151. package/dist/display/avatar.js +71 -0
  152. package/dist/display/avatar.js.map +1 -0
  153. package/dist/display/badge.d.ts +65 -0
  154. package/dist/display/badge.js +99 -0
  155. package/dist/display/badge.js.map +1 -0
  156. package/dist/display/card.d.ts +72 -0
  157. package/dist/display/card.js +91 -0
  158. package/dist/display/card.js.map +1 -0
  159. package/dist/display/carousel.d.ts +47 -0
  160. package/dist/display/carousel.js +214 -0
  161. package/dist/display/carousel.js.map +1 -0
  162. package/dist/display/description-list.d.ts +25 -0
  163. package/dist/display/description-list.js +36 -0
  164. package/dist/display/description-list.js.map +1 -0
  165. package/dist/display/icon-aliases.d.ts +1 -0
  166. package/dist/display/icon-aliases.js +259 -0
  167. package/dist/display/icon-aliases.js.map +1 -0
  168. package/dist/display/icon-names.d.ts +4 -0
  169. package/dist/display/icon-names.js +2 -0
  170. package/dist/display/icon-names.js.map +1 -0
  171. package/dist/display/icon.d.ts +51 -0
  172. package/dist/display/icon.js +96 -0
  173. package/dist/display/icon.js.map +1 -0
  174. package/dist/display/image-crop.d.ts +106 -0
  175. package/dist/display/image-crop.js +117 -0
  176. package/dist/display/image-crop.js.map +1 -0
  177. package/dist/display/image-cropper.d.ts +68 -0
  178. package/dist/display/image-cropper.js +284 -0
  179. package/dist/display/image-cropper.js.map +1 -0
  180. package/dist/display/image-viewer.d.ts +54 -0
  181. package/dist/display/image-viewer.js +84 -0
  182. package/dist/display/image-viewer.js.map +1 -0
  183. package/dist/display/image.d.ts +26 -0
  184. package/dist/display/image.js +17 -0
  185. package/dist/display/image.js.map +1 -0
  186. package/dist/display/index.d.ts +29 -0
  187. package/dist/display/index.js +16 -0
  188. package/dist/display/index.js.map +1 -0
  189. package/dist/display/iso-chip.d.ts +19 -0
  190. package/dist/display/iso-chip.js +21 -0
  191. package/dist/display/iso-chip.js.map +1 -0
  192. package/dist/display/kbd.d.ts +11 -0
  193. package/dist/display/kbd.js +33 -0
  194. package/dist/display/kbd.js.map +1 -0
  195. package/dist/display/lozenge.d.ts +30 -0
  196. package/dist/display/lozenge.js +55 -0
  197. package/dist/display/lozenge.js.map +1 -0
  198. package/dist/display/scroll-area.d.ts +29 -0
  199. package/dist/display/scroll-area.js +95 -0
  200. package/dist/display/scroll-area.js.map +1 -0
  201. package/dist/display/separator.d.ts +13 -0
  202. package/dist/display/separator.js +24 -0
  203. package/dist/display/separator.js.map +1 -0
  204. package/dist/display/stat.d.ts +35 -0
  205. package/dist/display/stat.js +41 -0
  206. package/dist/display/stat.js.map +1 -0
  207. package/dist/display/timeline.d.ts +44 -0
  208. package/dist/display/timeline.js +111 -0
  209. package/dist/display/timeline.js.map +1 -0
  210. package/dist/display/typography.d.ts +37 -0
  211. package/dist/display/typography.js +53 -0
  212. package/dist/display/typography.js.map +1 -0
  213. package/dist/display/visually-hidden.d.ts +14 -0
  214. package/dist/display/visually-hidden.js +10 -0
  215. package/dist/display/visually-hidden.js.map +1 -0
  216. package/dist/feedback/banner.d.ts +46 -0
  217. package/dist/feedback/banner.js +157 -0
  218. package/dist/feedback/banner.js.map +1 -0
  219. package/dist/feedback/cooldown.d.ts +17 -0
  220. package/dist/feedback/cooldown.js +59 -0
  221. package/dist/feedback/cooldown.js.map +1 -0
  222. package/dist/feedback/empty-state.d.ts +35 -0
  223. package/dist/feedback/empty-state.js +39 -0
  224. package/dist/feedback/empty-state.js.map +1 -0
  225. package/dist/feedback/index.d.ts +12 -0
  226. package/dist/feedback/index.js +11 -0
  227. package/dist/feedback/index.js.map +1 -0
  228. package/dist/feedback/meter.d.ts +33 -0
  229. package/dist/feedback/meter.js +42 -0
  230. package/dist/feedback/meter.js.map +1 -0
  231. package/dist/feedback/motion.d.ts +9 -0
  232. package/dist/feedback/motion.js +57 -0
  233. package/dist/feedback/motion.js.map +1 -0
  234. package/dist/feedback/progress.d.ts +39 -0
  235. package/dist/feedback/progress.js +68 -0
  236. package/dist/feedback/progress.js.map +1 -0
  237. package/dist/feedback/skeleton.d.ts +48 -0
  238. package/dist/feedback/skeleton.js +61 -0
  239. package/dist/feedback/skeleton.js.map +1 -0
  240. package/dist/feedback/spinner.d.ts +19 -0
  241. package/dist/feedback/spinner.js +29 -0
  242. package/dist/feedback/spinner.js.map +1 -0
  243. package/dist/feedback/status-dot.d.ts +23 -0
  244. package/dist/feedback/status-dot.js +37 -0
  245. package/dist/feedback/status-dot.js.map +1 -0
  246. package/dist/form/countries.d.ts +34 -0
  247. package/dist/form/countries.js +273 -0
  248. package/dist/form/countries.js.map +1 -0
  249. package/dist/form/data-attributes.d.ts +11 -0
  250. package/dist/form/data-attributes.js +22 -0
  251. package/dist/form/data-attributes.js.map +1 -0
  252. package/dist/form/field-parts.d.ts +113 -0
  253. package/dist/form/field-parts.js +178 -0
  254. package/dist/form/field-parts.js.map +1 -0
  255. package/dist/form/field.d.ts +36 -0
  256. package/dist/form/field.js +65 -0
  257. package/dist/form/field.js.map +1 -0
  258. package/dist/form/files.d.ts +70 -0
  259. package/dist/form/files.js +156 -0
  260. package/dist/form/files.js.map +1 -0
  261. package/dist/form/form.d.ts +40 -0
  262. package/dist/form/form.js +74 -0
  263. package/dist/form/form.js.map +1 -0
  264. package/dist/form/image-crop.d.ts +106 -0
  265. package/dist/form/image-crop.js +117 -0
  266. package/dist/form/image-crop.js.map +1 -0
  267. package/dist/form/image-cropper.d.ts +68 -0
  268. package/dist/form/image-cropper.js +284 -0
  269. package/dist/form/image-cropper.js.map +1 -0
  270. package/dist/form/index.d.ts +24 -0
  271. package/dist/form/index.js +15 -0
  272. package/dist/form/index.js.map +1 -0
  273. package/dist/form/input-group.d.ts +63 -0
  274. package/dist/form/input-group.js +63 -0
  275. package/dist/form/input-group.js.map +1 -0
  276. package/dist/form/input-otp.d.ts +35 -0
  277. package/dist/form/input-otp.js +83 -0
  278. package/dist/form/input-otp.js.map +1 -0
  279. package/dist/form/input.d.ts +36 -0
  280. package/dist/form/input.js +41 -0
  281. package/dist/form/input.js.map +1 -0
  282. package/dist/form/number-field.d.ts +84 -0
  283. package/dist/form/number-field.js +81 -0
  284. package/dist/form/number-field.js.map +1 -0
  285. package/dist/form/otp-field.d.ts +37 -0
  286. package/dist/form/otp-field.js +116 -0
  287. package/dist/form/otp-field.js.map +1 -0
  288. package/dist/form/password-field.d.ts +61 -0
  289. package/dist/form/password-field.js +61 -0
  290. package/dist/form/password-field.js.map +1 -0
  291. package/dist/form/phone-field.d.ts +104 -0
  292. package/dist/form/phone-field.js +275 -0
  293. package/dist/form/phone-field.js.map +1 -0
  294. package/dist/form/phone-paste.d.ts +24 -0
  295. package/dist/form/phone-paste.js +40 -0
  296. package/dist/form/phone-paste.js.map +1 -0
  297. package/dist/form/phone.d.ts +159 -0
  298. package/dist/form/phone.js +309 -0
  299. package/dist/form/phone.js.map +1 -0
  300. package/dist/form/search-field.d.ts +29 -0
  301. package/dist/form/search-field.js +23 -0
  302. package/dist/form/search-field.js.map +1 -0
  303. package/dist/form/styles.d.ts +31 -0
  304. package/dist/form/styles.js +43 -0
  305. package/dist/form/styles.js.map +1 -0
  306. package/dist/form/text-area.d.ts +70 -0
  307. package/dist/form/text-area.js +93 -0
  308. package/dist/form/text-area.js.map +1 -0
  309. package/dist/form/text-field.d.ts +131 -0
  310. package/dist/form/text-field.js +59 -0
  311. package/dist/form/text-field.js.map +1 -0
  312. package/dist/form/validation.d.ts +145 -0
  313. package/dist/form/validation.js +136 -0
  314. package/dist/form/validation.js.map +1 -0
  315. package/dist/i18n.d.ts +438 -0
  316. package/dist/i18n.js +948 -0
  317. package/dist/i18n.js.map +1 -0
  318. package/dist/index.d.ts +9 -0
  319. package/dist/index.js +7 -0
  320. package/dist/index.js.map +1 -0
  321. package/dist/intl-locale.d.ts +30 -0
  322. package/dist/intl-locale.js +83 -0
  323. package/dist/intl-locale.js.map +1 -0
  324. package/dist/layers.d.ts +32 -0
  325. package/dist/layers.js +33 -0
  326. package/dist/layers.js.map +1 -0
  327. package/dist/layout/auth-form-layout.d.ts +71 -0
  328. package/dist/layout/auth-form-layout.js +61 -0
  329. package/dist/layout/auth-form-layout.js.map +1 -0
  330. package/dist/layout/auth-layout.d.ts +59 -0
  331. package/dist/layout/auth-layout.js +26 -0
  332. package/dist/layout/auth-layout.js.map +1 -0
  333. package/dist/layout/box.d.ts +26 -0
  334. package/dist/layout/box.js +16 -0
  335. package/dist/layout/box.js.map +1 -0
  336. package/dist/layout/grid.d.ts +27 -0
  337. package/dist/layout/grid.js +26 -0
  338. package/dist/layout/grid.js.map +1 -0
  339. package/dist/layout/index.d.ts +16 -0
  340. package/dist/layout/index.js +12 -0
  341. package/dist/layout/index.js.map +1 -0
  342. package/dist/layout/pressable.d.ts +40 -0
  343. package/dist/layout/pressable.js +65 -0
  344. package/dist/layout/pressable.js.map +1 -0
  345. package/dist/layout/reset-sent-card.d.ts +39 -0
  346. package/dist/layout/reset-sent-card.js +22 -0
  347. package/dist/layout/reset-sent-card.js.map +1 -0
  348. package/dist/layout/scroll-area.d.ts +29 -0
  349. package/dist/layout/scroll-area.js +95 -0
  350. package/dist/layout/scroll-area.js.map +1 -0
  351. package/dist/layout/section.d.ts +41 -0
  352. package/dist/layout/section.js +22 -0
  353. package/dist/layout/section.js.map +1 -0
  354. package/dist/layout/split.d.ts +50 -0
  355. package/dist/layout/split.js +35 -0
  356. package/dist/layout/split.js.map +1 -0
  357. package/dist/layout/stack.d.ts +44 -0
  358. package/dist/layout/stack.js +36 -0
  359. package/dist/layout/stack.js.map +1 -0
  360. package/dist/layout/tokens.d.ts +33 -0
  361. package/dist/layout/tokens.js +85 -0
  362. package/dist/layout/tokens.js.map +1 -0
  363. package/dist/layout/toolbar.d.ts +37 -0
  364. package/dist/layout/toolbar.js +334 -0
  365. package/dist/layout/toolbar.js.map +1 -0
  366. package/dist/navigate-context.d.ts +12 -0
  367. package/dist/navigate-context.js +13 -0
  368. package/dist/navigate-context.js.map +1 -0
  369. package/dist/navigation/accordion.d.ts +40 -0
  370. package/dist/navigation/accordion.js +33 -0
  371. package/dist/navigation/accordion.js.map +1 -0
  372. package/dist/navigation/bottom-nav.d.ts +29 -0
  373. package/dist/navigation/bottom-nav.js +48 -0
  374. package/dist/navigation/bottom-nav.js.map +1 -0
  375. package/dist/navigation/brand-link-context.d.ts +8 -0
  376. package/dist/navigation/brand-link-context.js +9 -0
  377. package/dist/navigation/brand-link-context.js.map +1 -0
  378. package/dist/navigation/breadcrumbs.d.ts +36 -0
  379. package/dist/navigation/breadcrumbs.js +51 -0
  380. package/dist/navigation/breadcrumbs.js.map +1 -0
  381. package/dist/navigation/dock.d.ts +27 -0
  382. package/dist/navigation/dock.js +47 -0
  383. package/dist/navigation/dock.js.map +1 -0
  384. package/dist/navigation/footer.d.ts +43 -0
  385. package/dist/navigation/footer.js +43 -0
  386. package/dist/navigation/footer.js.map +1 -0
  387. package/dist/navigation/index.d.ts +22 -0
  388. package/dist/navigation/index.js +17 -0
  389. package/dist/navigation/index.js.map +1 -0
  390. package/dist/navigation/language-names.d.ts +19 -0
  391. package/dist/navigation/language-names.js +79 -0
  392. package/dist/navigation/language-names.js.map +1 -0
  393. package/dist/navigation/language-switcher.d.ts +55 -0
  394. package/dist/navigation/language-switcher.js +53 -0
  395. package/dist/navigation/language-switcher.js.map +1 -0
  396. package/dist/navigation/nav-panel.d.ts +18 -0
  397. package/dist/navigation/nav-panel.js +51 -0
  398. package/dist/navigation/nav-panel.js.map +1 -0
  399. package/dist/navigation/navbar.d.ts +73 -0
  400. package/dist/navigation/navbar.js +64 -0
  401. package/dist/navigation/navbar.js.map +1 -0
  402. package/dist/navigation/page-header.d.ts +37 -0
  403. package/dist/navigation/page-header.js +50 -0
  404. package/dist/navigation/page-header.js.map +1 -0
  405. package/dist/navigation/pagination.d.ts +25 -0
  406. package/dist/navigation/pagination.js +51 -0
  407. package/dist/navigation/pagination.js.map +1 -0
  408. package/dist/navigation/panel-header.d.ts +37 -0
  409. package/dist/navigation/panel-header.js +50 -0
  410. package/dist/navigation/panel-header.js.map +1 -0
  411. package/dist/navigation/sidebar-script.d.ts +12 -0
  412. package/dist/navigation/sidebar-script.js +20 -0
  413. package/dist/navigation/sidebar-script.js.map +1 -0
  414. package/dist/navigation/sidebar.d.ts +149 -0
  415. package/dist/navigation/sidebar.js +332 -0
  416. package/dist/navigation/sidebar.js.map +1 -0
  417. package/dist/navigation/skip-link.d.ts +12 -0
  418. package/dist/navigation/skip-link.js +30 -0
  419. package/dist/navigation/skip-link.js.map +1 -0
  420. package/dist/navigation/stepper.d.ts +50 -0
  421. package/dist/navigation/stepper.js +96 -0
  422. package/dist/navigation/stepper.js.map +1 -0
  423. package/dist/navigation/tabs.d.ts +84 -0
  424. package/dist/navigation/tabs.js +118 -0
  425. package/dist/navigation/tabs.js.map +1 -0
  426. package/dist/navigation/toolbar.d.ts +37 -0
  427. package/dist/navigation/toolbar.js +334 -0
  428. package/dist/navigation/toolbar.js.map +1 -0
  429. package/dist/overlay/alert-dialog.d.ts +63 -0
  430. package/dist/overlay/alert-dialog.js +76 -0
  431. package/dist/overlay/alert-dialog.js.map +1 -0
  432. package/dist/overlay/command-palette.d.ts +53 -0
  433. package/dist/overlay/command-palette.js +130 -0
  434. package/dist/overlay/command-palette.js.map +1 -0
  435. package/dist/overlay/command.d.ts +53 -0
  436. package/dist/overlay/command.js +129 -0
  437. package/dist/overlay/command.js.map +1 -0
  438. package/dist/overlay/context-menu.d.ts +29 -0
  439. package/dist/overlay/context-menu.js +58 -0
  440. package/dist/overlay/context-menu.js.map +1 -0
  441. package/dist/overlay/dialog.d.ts +162 -0
  442. package/dist/overlay/dialog.js +174 -0
  443. package/dist/overlay/dialog.js.map +1 -0
  444. package/dist/overlay/drawer.d.ts +41 -0
  445. package/dist/overlay/drawer.js +114 -0
  446. package/dist/overlay/drawer.js.map +1 -0
  447. package/dist/overlay/floating.d.ts +142 -0
  448. package/dist/overlay/floating.js +226 -0
  449. package/dist/overlay/floating.js.map +1 -0
  450. package/dist/overlay/hover-card.d.ts +19 -0
  451. package/dist/overlay/hover-card.js +31 -0
  452. package/dist/overlay/hover-card.js.map +1 -0
  453. package/dist/overlay/index.d.ts +18 -0
  454. package/dist/overlay/index.js +12 -0
  455. package/dist/overlay/index.js.map +1 -0
  456. package/dist/overlay/overlay-base.d.ts +105 -0
  457. package/dist/overlay/overlay-base.js +250 -0
  458. package/dist/overlay/overlay-base.js.map +1 -0
  459. package/dist/overlay/overlay.d.ts +299 -0
  460. package/dist/overlay/overlay.js +558 -0
  461. package/dist/overlay/overlay.js.map +1 -0
  462. package/dist/overlay/toast.d.ts +58 -0
  463. package/dist/overlay/toast.js +145 -0
  464. package/dist/overlay/toast.js.map +1 -0
  465. package/dist/provider.d.ts +26 -0
  466. package/dist/provider.js +30 -0
  467. package/dist/provider.js.map +1 -0
  468. package/dist/selection/autocomplete.d.ts +54 -0
  469. package/dist/selection/autocomplete.js +122 -0
  470. package/dist/selection/autocomplete.js.map +1 -0
  471. package/dist/selection/checkbox.d.ts +56 -0
  472. package/dist/selection/checkbox.js +49 -0
  473. package/dist/selection/checkbox.js.map +1 -0
  474. package/dist/selection/choice-size.d.ts +26 -0
  475. package/dist/selection/choice-size.js +50 -0
  476. package/dist/selection/choice-size.js.map +1 -0
  477. package/dist/selection/choice-text.d.ts +21 -0
  478. package/dist/selection/choice-text.js +33 -0
  479. package/dist/selection/choice-text.js.map +1 -0
  480. package/dist/selection/combobox.d.ts +173 -0
  481. package/dist/selection/combobox.js +410 -0
  482. package/dist/selection/combobox.js.map +1 -0
  483. package/dist/selection/index.d.ts +20 -0
  484. package/dist/selection/index.js +13 -0
  485. package/dist/selection/index.js.map +1 -0
  486. package/dist/selection/list-box.d.ts +30 -0
  487. package/dist/selection/list-box.js +16 -0
  488. package/dist/selection/list-box.js.map +1 -0
  489. package/dist/selection/listbox.d.ts +44 -0
  490. package/dist/selection/listbox.js +49 -0
  491. package/dist/selection/listbox.js.map +1 -0
  492. package/dist/selection/match.d.ts +20 -0
  493. package/dist/selection/match.js +57 -0
  494. package/dist/selection/match.js.map +1 -0
  495. package/dist/selection/multi-select.d.ts +72 -0
  496. package/dist/selection/multi-select.js +138 -0
  497. package/dist/selection/multi-select.js.map +1 -0
  498. package/dist/selection/radio-card.d.ts +31 -0
  499. package/dist/selection/radio-card.js +29 -0
  500. package/dist/selection/radio-card.js.map +1 -0
  501. package/dist/selection/radio.d.ts +72 -0
  502. package/dist/selection/radio.js +64 -0
  503. package/dist/selection/radio.js.map +1 -0
  504. package/dist/selection/select-public.d.ts +19 -0
  505. package/dist/selection/select-public.js +24 -0
  506. package/dist/selection/select-public.js.map +1 -0
  507. package/dist/selection/select.d.ts +72 -0
  508. package/dist/selection/select.js +69 -0
  509. package/dist/selection/select.js.map +1 -0
  510. package/dist/selection/slider.d.ts +16 -0
  511. package/dist/selection/slider.js +44 -0
  512. package/dist/selection/slider.js.map +1 -0
  513. package/dist/selection/styles.d.ts +26 -0
  514. package/dist/selection/styles.js +78 -0
  515. package/dist/selection/styles.js.map +1 -0
  516. package/dist/selection/switch.d.ts +24 -0
  517. package/dist/selection/switch.js +27 -0
  518. package/dist/selection/switch.js.map +1 -0
  519. package/dist/selection/tag-group.d.ts +38 -0
  520. package/dist/selection/tag-group.js +45 -0
  521. package/dist/selection/tag-group.js.map +1 -0
  522. package/dist/tone.d.ts +6 -0
  523. package/dist/tone.js +2 -0
  524. package/dist/tone.js.map +1 -0
  525. package/dist/utils.d.ts +9 -0
  526. package/dist/utils.js +42 -0
  527. package/dist/utils.js.map +1 -0
  528. package/manifest/component.full.schema.json +391 -0
  529. package/manifest/component.schema.json +279 -0
  530. package/manifests/accordion.json +299 -0
  531. package/manifests/alert-dialog.json +261 -0
  532. package/manifests/area-chart.json +338 -0
  533. package/manifests/autocomplete.json +299 -0
  534. package/manifests/avatar.json +253 -0
  535. package/manifests/badge.json +288 -0
  536. package/manifests/banner.json +185 -0
  537. package/manifests/bar-chart.json +454 -0
  538. package/manifests/bar-list.json +262 -0
  539. package/manifests/bottom-nav.json +139 -0
  540. package/manifests/box.json +3450 -0
  541. package/manifests/breadcrumbs.json +199 -0
  542. package/manifests/button-group.json +2294 -0
  543. package/manifests/button.json +1211 -0
  544. package/manifests/calendar-heatmap.json +218 -0
  545. package/manifests/calendar.json +299 -0
  546. package/manifests/card.json +308 -0
  547. package/manifests/carousel.json +263 -0
  548. package/manifests/chart-parts.json +309 -0
  549. package/manifests/checkbox.json +998 -0
  550. package/manifests/close-button.json +1000 -0
  551. package/manifests/color-field.json +276 -0
  552. package/manifests/color-picker.json +161 -0
  553. package/manifests/color-swatch-picker.json +220 -0
  554. package/manifests/color-swatch.json +140 -0
  555. package/manifests/combobox.json +581 -0
  556. package/manifests/command.json +275 -0
  557. package/manifests/composed-chart.json +287 -0
  558. package/manifests/context-menu.json +148 -0
  559. package/manifests/copy-button.json +192 -0
  560. package/manifests/data-table.json +334 -0
  561. package/manifests/date-field.json +302 -0
  562. package/manifests/date-picker.json +472 -0
  563. package/manifests/description-list.json +201 -0
  564. package/manifests/dialog.json +322 -0
  565. package/manifests/donut-chart.json +264 -0
  566. package/manifests/drawer.json +211 -0
  567. package/manifests/empty-state.json +185 -0
  568. package/manifests/fab.json +172 -0
  569. package/manifests/field.json +209 -0
  570. package/manifests/file-upload.json +791 -0
  571. package/manifests/form.json +829 -0
  572. package/manifests/funnel-chart.json +223 -0
  573. package/manifests/gauge-chart.json +252 -0
  574. package/manifests/grid-list.json +335 -0
  575. package/manifests/grid.json +3482 -0
  576. package/manifests/heading.json +183 -0
  577. package/manifests/heatmap.json +265 -0
  578. package/manifests/hover-card.json +172 -0
  579. package/manifests/icon.json +201 -0
  580. package/manifests/image-cropper.json +295 -0
  581. package/manifests/image-viewer.json +198 -0
  582. package/manifests/image.json +193 -0
  583. package/manifests/index.json +2035 -0
  584. package/manifests/input-group.json +3571 -0
  585. package/manifests/input.json +1557 -0
  586. package/manifests/kbd.json +98 -0
  587. package/manifests/language-switcher.json +274 -0
  588. package/manifests/line-chart.json +342 -0
  589. package/manifests/link.json +867 -0
  590. package/manifests/list-box.json +213 -0
  591. package/manifests/menu.json +453 -0
  592. package/manifests/meter.json +145 -0
  593. package/manifests/navbar.json +281 -0
  594. package/manifests/otp-field.json +1029 -0
  595. package/manifests/page-header.json +164 -0
  596. package/manifests/pagination.json +181 -0
  597. package/manifests/popover.json +205 -0
  598. package/manifests/pressable.json +367 -0
  599. package/manifests/progress.json +282 -0
  600. package/manifests/radar-chart.json +229 -0
  601. package/manifests/radial-chart.json +195 -0
  602. package/manifests/radio.json +975 -0
  603. package/manifests/scatter-chart.json +277 -0
  604. package/manifests/scroll-area.json +127 -0
  605. package/manifests/section.json +169 -0
  606. package/manifests/select.json +474 -0
  607. package/manifests/separator.json +119 -0
  608. package/manifests/sidebar.json +584 -0
  609. package/manifests/skeleton.json +235 -0
  610. package/manifests/skip-link.json +89 -0
  611. package/manifests/slider.json +706 -0
  612. package/manifests/sparkline.json +208 -0
  613. package/manifests/spinner.json +105 -0
  614. package/manifests/split.json +6618 -0
  615. package/manifests/stack.json +3541 -0
  616. package/manifests/stat.json +192 -0
  617. package/manifests/stepper.json +279 -0
  618. package/manifests/switch.json +205 -0
  619. package/manifests/table.json +375 -0
  620. package/manifests/tabs.json +438 -0
  621. package/manifests/tag-group.json +264 -0
  622. package/manifests/text-area.json +1136 -0
  623. package/manifests/text.json +244 -0
  624. package/manifests/theme-switcher.json +152 -0
  625. package/manifests/time-field.json +284 -0
  626. package/manifests/timeline.json +196 -0
  627. package/manifests/toast.json +87 -0
  628. package/manifests/toggle-button.json +1489 -0
  629. package/manifests/toolbar.json +145 -0
  630. package/manifests/tooltip.json +181 -0
  631. package/manifests/tracker.json +192 -0
  632. package/manifests/tree.json +245 -0
  633. package/manifests/visually-hidden.json +114 -0
  634. package/package.json +117 -3
  635. package/styles/base.css +56 -0
  636. package/styles/theme.css +154 -0
@@ -0,0 +1,1262 @@
1
+ import { getNiceTickValues } from "recharts";
2
+ import { localWords } from "../intl-locale.js";
3
+ /*
4
+ * How wide a vertical axis must be for its ticks, and how a tick or a bar-end label fits the room
5
+ * it has. Shared by every chart with a value axis; not exported from the package.
6
+ *
7
+ * Recharts draws a tick on a vertical axis 8px in from the plot (its tick size, 6px, and tick margin, 2px, also
8
+ * with the tick line off), and keeps a tick on one line only while the tick, measured, is narrower than the
9
+ * width it is given (strictly: `width < given`). Each tick is given the axis's width less those 8px
10
+ * ({@link tickWrapWidth}): the room it has between the axis's outer edge and where it is drawn. So an axis 8px
11
+ * wider than its longest tick's estimate draws that tick whole, on one line.
12
+ *
13
+ * A tick is estimated by {@link textWidth}: each character at the widest Geist or its fallback draws it at 11px,
14
+ * so a tick is never wider than its estimate, before the web font loads too.
15
+ */
16
+ /** Recharts' tick size and tick margin: where a vertical axis draws its ticks from the plot's edge. */
17
+ export const TICK_INSET = 8;
18
+ /**
19
+ * Past this an axis would squeeze the plot, so a value axis the DS sizes is never wider (an axis that
20
+ * grew for an unbreakable tick left a 320px chart a 26px plot). A tick estimated longer than the room the clamped
21
+ * axis leaves it (128px less the 8px inset) wraps between its units, as each tick's width is that room; one that
22
+ * cannot is shown compact by the DS's ticks ({@link tickText}); what still does not fit is clipped within the axis
23
+ * by the tick itself (value-tick's ValueTick), its reading start kept, its whole text its accessible name and hover
24
+ * title: never over the plot, never past the chart's edge.
25
+ */
26
+ export const AXIS_MAX = 128;
27
+ /**
28
+ * @internal A value as Recharts plots it on a number axis (its `makeNumber`): a number (a `Number` object too), or
29
+ * a string or date that converts to one, when the result is finite; `undefined` otherwise (a gap: null, missing,
30
+ * "abc", NaN). `"1500000"` is drawn at 1,500,000, so it counts wherever the plotted values count and is shown
31
+ * wherever they are shown (the data table, the tooltip).
32
+ */
33
+ export function chartNumber(value) {
34
+ if (typeof value !== "number" && !(value instanceof Number) && typeof value !== "string" && !(value instanceof Date))
35
+ return undefined;
36
+ const number = Number(value);
37
+ return Number.isFinite(number) ? number : undefined;
38
+ }
39
+ /*
40
+ * Character widths in hundredths of a px at 11px, measured in Chromium: each
41
+ * character alone, the widest it is drawn by any face a chart may use, hinted to whole pixels (as Linux draws) and at
42
+ * its true advance (as macOS and Windows draw): Geist; the "Geist Fallback" apps get from next/font (Arial at
43
+ * size-adjust 104.76%, as a Next.js build emits it), drawn before Geist loads; Arial (as Liberation Sans, its metric
44
+ * twin); system-ui, Noto Sans and DejaVu Sans, which draw what the others lack. Kerning only narrows a pair, and a
45
+ * mark set on a letter (an accent, once decomposed; a vowel sign in an Indic script) takes no room of its own, so a
46
+ * text is never wider than the sum of its characters. Each character is measured in pages of 31 languages too, as
47
+ * Chromium picks an Arabic, Persian, Indic or Han fallback face by the page's language (ar-EG draws Arabic-Indic
48
+ * figures wider than ar). Checked against every number Intl formats (246 locales, every numbering system; decimal,
49
+ * currency by symbol, code and name, compact short and long, percent, units), each drawn in a page of its own
50
+ * language (36,489 strings): none is wider than its estimate in any of the faces.
51
+ */
52
+ /** Every base character of Latin (to Latin Extended-B), Greek, Cyrillic, Armenian, Hebrew and Arabic, the spaces, punctuation and currency signs. */
53
+ const MEASURED = [
54
+ [125, "\u200a"],
55
+ [200, "ۥ\u2006⁄"],
56
+ [250, "\u2009\u202f"],
57
+ [275, "՛՝′"],
58
+ [300, "լյויןٱٲٳ\u2005\u205f"],
59
+ [304, "'"],
60
+ [307, "ijl"],
61
+ [325, "ıłƚǃȷɉͿϳіјֈ؞اـٴ"],
62
+ [350, " ,.\u00a0ՙ՚۔\u2008‘’‚‛⁞"],
63
+ [372, ":;"],
64
+ [374, "I"],
65
+ [375, "ƗǀΙІӀӏ։"],
66
+ [400, "·ŀſƖ͵ι՜ז،؛٫٬ۦ\u2004‐‑⁏⁚⁝"],
67
+ [425, "؍ۯ⁁"],
68
+ [430, "()[]"],
69
+ [433, "t"],
70
+ [434, "f"],
71
+ [443, "!"],
72
+ [450, "¡²³¹ŧƫƭչٵہۃ″‸‹›⁅⁆"],
73
+ [455, "r"],
74
+ [475, "ɍ"],
75
+ [500, "-\\ƪ՞ւ֊גנ׳؋ٶۄۅۉۊۏ۽‶⁒"],
76
+ [507, "\""],
77
+ [525, "ªºȴȶϝءدذڈډڊڋڌڍڎڏڐۮ"],
78
+ [528, "/"],
79
+ [550, "`°´¸ɂ՟շرزوڑڒړڗژڙۆۇۈۋ۾‾"],
80
+ [575, "ljȝէ“”„‟"],
81
+ [600, "szƨƶƾȥȿɀɈεζϯгзѕѯґҙӷԑԼץװױײ؏؟ةه٠١٢٤٥٦٩٪٭ڔږە۰۱۲۴۵۶۹ۼ\u2002․‼‽⁃"],
82
+ [607, "*c|"],
83
+ [625, "¦ijƈǁȼͱͻͼͽνξϲсэєҁҫջךכר‖⁎"],
84
+ [649, "k"],
85
+ [650, "¨ĸƙƽͺ΄κςχϛвтғҭӻԇԯל٣٧٨۳۷۸•‣‴⁊⁖"],
86
+ [652, "vxy"],
87
+ [675, "ƛɏγλτϮкухчь҂ҍҐқҝҟүұҳҹӌӽӿԟօ"],
88
+ [700, "$?JL_abdeghnopqu{}¢£¤¥§«¯µ»ðþđĿŁŋƀƃƅƌƍƐƒƞƥƹƺƻƿǂǝǥȜȣȽɁɇɋΓδηθμορυϐϑϙϡϧϫϭϱϵ϶ϸϼЈГабеоряђѮѳҏҕҮҰҷһӄәӡөӶԁԐԛԩԭՒբեզըիծկհձղճմնոսվրցքבדעצعغمٷڕڠ۩‒–‗†‡‷₣₤₫₰₶₸₺"],
89
+ [704, "FT"],
90
+ [725, "¶¿ßøŦƑƩƬƮȾͰͳͷΣΤβσϏϜЗТилнпћџҘҬԓԧԷգժռףפ״؆؇جحخځڂڃڄڅچڇڿ⁋⁌⁍₮"],
91
+ [750, "ƷƸƼαϗϟϥϰцѣҋҒңӆӈӊӠӺԍդۿ\u2007₹"],
92
+ [755, "Z"],
93
+ [775, "ħƔƵǷȢȤΖдҩԥՐ"],
94
+ [800, "ABEKPSVXYÞƂƄƋƎƦƧȺɃɅɆɎΑΒΔΕΚΛΞΡΥΧπφϕϞϨϩϷϻЅАБВЕКРУХЧЬъѫѵҌҎҔҚҜҞҲҸҺӃӋӼӾԀԆԏԞԬԮԻՀՉՏאהחטםמסקתلڵڶڷڸھ€₭₱₳₷₽"],
95
+ [825, "ƘƴȠҶҽҿԦԨԲԵԸԿՅՆՈՍՑթ֏نڹںڻڼڽ"],
96
+ [850, "ͶϤϪЛмѻԒԳԴԶԺՁՂՃՇՋՔ؉ؠؽؾؿۑ⁈⁉₾"],
97
+ [858, "&"],
98
+ [875, "ϦѧӅӎԤՖ₴"],
99
+ [900, "CDGHNOQRUÐØĐʼnŊƁƆƇƉƏƓƝƟƤƱƲƳǤȻɄɊɌΗΘΝΟΠΩψϒϘϚϬϴϹϽϾϿЄЏДИНОПСЦЭЯыѢѥѲҀҊҢҪҵӇӉӘӨԌԎԚԝՄՊՌՎՓՕֆև֍֎שׯ؝قىيٯڧڨیێې‿⁀⁐⁔⁗⁛₡₢₦₲₵₻₼₿⃀⃁"],
100
+ [901, "w"],
101
+ [922, "#+<=>^~"],
102
+ [925, "¬±×÷ωѡѿҡԱ⁕⁘⁙⁜−"],
103
+ [950, "IJƣȡȵͲϖФюҠԹԾٸ"],
104
+ [975, "njϠѦѱҥҨԗ₠"],
105
+ [1000, "MƊLjΜΦΨϣϺЂЋМЪжфњѪѭѰѴҗԅԖԡ؎ػؼكکګڬڭڮگڰڱڲڳڴۍ₪"],
106
+ [1025, "ĦшҧӍԣԽՠ؈طظڟ⁇"],
107
+ [1050, "щѺҼҾے"],
108
+ [1072, "m"],
109
+ [1075, "¼½¾ապտփ₥"],
110
+ [1100, "%W©®æƕȸȹϢЫљѤҴӕԃԉԋԕԙԜխ؊بتثٮٹٺٻټٽپٿڀ۞‥‧‵※⁑⁓₩\u3000"],
111
+ [1125, "NjѩҤԄ"],
112
+ [1150, "œƜѽԘفڡڢڣڤڥڦ"],
113
+ [1200, "@ÆŒƢЖШЮҖӔԂԈԠڪ\u2003—―…"],
114
+ [1225, "ǶЊЩѹԊԢ"],
115
+ [1250, "⁂"],
116
+ [1300, "džLJdzЉѨѬԔԫ"],
117
+ [1325, "﷼"],
118
+ [1350, "Ѹسشښڛڜۺ"],
119
+ [1400, "ѼҦ₧₨₯"],
120
+ [1450, "صضڝڞۻ"],
121
+ [1500, "DžNJDz‰"],
122
+ [1550, "Ԫ"],
123
+ [1600, "DŽDZѠѾ"],
124
+ [1925, "‱"],
125
+ [7950, "﷽"],
126
+ ];
127
+ /** Proportional figures (labels), "0" to "9": Geist's "0" is its widest. */
128
+ const PROPORTIONAL_FIGURES = [729, 700, 700, 700, 700, 700, 700, 700, 700, 700];
129
+ /** Tabular figures (axis ticks, `tabular-nums`): 7px in every face (Geist's are 7px hinted, 6.6px at their true advance). */
130
+ const TABULAR_FIGURE = 700;
131
+ const GLYPHS = new Map(MEASURED.flatMap(([width, chars]) => Array.from(chars, (char) => [char, width])));
132
+ /**
133
+ * Any other letter, spacing mark or figure, by its script: the widest measured in it (Han and kana 1em; Tamil and
134
+ * Myanmar letters and vowel signs up to 28px, "ஔ"). A script missing here, or one the browser's regular expressions
135
+ * do not know yet, counts at 36px, the widest letter of any script (a cuneiform sign).
136
+ */
137
+ const SCRIPT_WIDTHS = [
138
+ [1100, "Adlam Anatolian_Hieroglyphs Bamum Bopomofo Carian Caucasian_Albanian Chorasmian Cypriot Cypro_Minoan Deseret Dives_Akuru Dogra Elbasan Gothic Han Hangul Hanifi_Rohingya Hatran Hebrew Hiragana Imperial_Aramaic Kaithi Katakana Kawi Kayah_Li Kharoshthi Khitan_Small_Script Lisu Lycian Lydian Makasar Marchen Modi Mro Multani Nabataean Nag_Mundari Nandinagari Nko Nushu Nyiakeng_Puachue_Hmong Ol_Chiki Old_North_Arabian Old_Permic Old_South_Arabian Old_Turkic Old_Uyghur Osage Osmanya Pahawh_Hmong Pau_Cin_Hau Phoenician Rejang Runic Shavian Siddham Sora_Sompeng Syloti_Nagri Tai_Le Takri Tangsa Tangut Thai Tibetan Tifinagh Toto Vithkuqi Wancho Warang_Citi Yezidi Yi"],
139
+ [1300, "Bassa_Vah Batak Bengali Bhaiksuki Brahmi Buhid Chakma Coptic Devanagari Elymaic Georgian Gujarati Gunjala_Gondi Hanunoo Khojki Lao Lepcha Mahajani Mandaic Meetei_Mayek Old_Hungarian Palmyrene Phags_Pa Samaritan Sharada Tagalog Tagbanwa Thaana Zanabazar_Square"],
140
+ [1550, "Ahom Avestan Buginese Cherokee Cyrillic Duployan Ethiopic Glagolitic Greek Inscriptional_Pahlavi Inscriptional_Parthian Khmer Khudawadi Latin Limbu Linear_A Manichaean Masaram_Gondi Medefaidrin Mende_Kikakui Miao Mongolian New_Tai_Lue Ogham Old_Sogdian Psalter_Pahlavi Soyombo Syriac Tai_Tham Tai_Viet Tirhuta Ugaritic Vai"],
141
+ [1800, "Armenian Canadian_Aboriginal Cham Gurmukhi Javanese Meroitic_Hieroglyphs Newa Old_Italic Oriya Saurashtra Sogdian"],
142
+ [2200, "Balinese Egyptian_Hieroglyphs Kannada Linear_B Meroitic_Cursive Old_Persian Sinhala Sundanese Telugu"],
143
+ [2400, "Malayalam"],
144
+ [2800, "Arabic Myanmar Tamil"],
145
+ [2400, "Common Inherited"],
146
+ ];
147
+ const UNKNOWN_LETTER = 3600;
148
+ const SCRIPTS = SCRIPT_WIDTHS.flatMap(([width, names]) => names.split(" ").flatMap((name) => {
149
+ try {
150
+ return [[new RegExp(`\\p{Script=${name}}`, "u"), width]];
151
+ }
152
+ catch {
153
+ return [];
154
+ }
155
+ }));
156
+ /** Any other space; any other sign or punctuation mark (the widest measured, "⸻", 31.25px). */
157
+ const OTHER_SPACE = 1200;
158
+ const OTHER_SIGN = 3125;
159
+ function charWidth(char, tabular) {
160
+ if (char >= "0" && char <= "9")
161
+ return tabular ? TABULAR_FIGURE : PROPORTIONAL_FIGURES[char.charCodeAt(0) - 48];
162
+ const known = GLYPHS.get(char);
163
+ if (known !== undefined)
164
+ return known;
165
+ // Format and bidi marks (U+200F, U+061C…) and marks set on a letter take no room.
166
+ if (/[\p{Cf}\p{Mn}\p{Me}]/u.test(char))
167
+ return 0;
168
+ if (/[\p{L}\p{N}\p{Mc}]/u.test(char)) {
169
+ for (const [script, width] of SCRIPTS)
170
+ if (script.test(char))
171
+ return width;
172
+ return UNKNOWN_LETTER;
173
+ }
174
+ if (/\s/u.test(char))
175
+ return OTHER_SPACE;
176
+ return OTHER_SIGN;
177
+ }
178
+ /**
179
+ * @internal A text's width in px as drawn at 11px, estimated from its characters: the sum of each
180
+ * character's widest width (see above), accents decomposed (a Turkish "ş" counts as an "s"), rounded up. Never
181
+ * under the text as any of the measured faces draws it, Geist's next/font fallback included, in any script: a figure
182
+ * 7px, "." and "," 3.5px, the space 3.5px, "€" 8px, "%" 11px, a Latin letter 3–11px ("W" 11px), a Cyrillic or
183
+ * Greek one up to 16px ("Ѡ"), an Arabic one up to 14.5px. `tabular` for `tabular-nums` figures (axis ticks),
184
+ * proportional otherwise (labels). The same on the server, in tests and before the web font loads, so a layout sized
185
+ * by it never moves after the first render.
186
+ */
187
+ export function textWidth(text, figures = "proportional") {
188
+ let hundredths = 0;
189
+ for (const char of text.normalize("NFD"))
190
+ hundredths += charWidth(char, figures === "tabular");
191
+ return Math.ceil(hundredths / 100);
192
+ }
193
+ /**
194
+ * The axis's width for these ticks: the longest's {@link textWidth} (in tabular figures, as ticks are drawn), plus
195
+ * the 8px inset and any further room the axis holds beside its ticks (an axis name), within min–128px.
196
+ *
197
+ * With the chart's `locale`, ticks as the axis shows them ({@link tickText}): when a tick does not fit the room
198
+ * the 128px axis leaves it, even between its units, every tick is shown with its figures compact and exact
199
+ * ("€ 150 Tn", "€ 2,25 Mn"), and the axis is sized for the longest line of those, so a compact axis is no wider
200
+ * than its ticks. Never past 128px: a tick that still does not fit (a formatter's long word against a figure) is
201
+ * clipped within the axis by the tick (value-tick's ValueTick), never the plot squeezed for it.
202
+ *
203
+ * The ticks are drawn in the room the axis then gives them (its width less the inset and `room`): no wider than
204
+ * the 120px (less `room`) they are laid out in here, and no narrower than their longest line, and in any room
205
+ * between those {@link tickText} lays them out the same (what did not fit the wider room fits no narrower one, and
206
+ * each line kept fits both), so the ticks drawn are the ones the axis was sized for. `values` are the values the ticks
207
+ * were formatted from ({@link formattedValues}), as the ticks are given them, so both read the figures alike.
208
+ */
209
+ export function tickAxisWidth(ticks, min, room = 0, locale, values) {
210
+ const texts = [...ticks];
211
+ let longest = 0;
212
+ for (const tick of texts)
213
+ longest = Math.max(longest, textWidth(tick, "tabular"));
214
+ const whole = Math.min(AXIS_MAX, Math.max(min, longest + TICK_INSET + room));
215
+ // Under the clamp every tick has the room of the longest, on one line; only at it may one not fit.
216
+ const tickRoom = tickWrapWidth(whole, room);
217
+ if (locale === undefined || whole < AXIS_MAX || !compactsAxis(texts, tickRoom))
218
+ return whole;
219
+ let shown = 0;
220
+ for (const tick of texts)
221
+ for (const line of tickText(tick, tickRoom, locale, texts, values).lines)
222
+ shown = Math.max(shown, textWidth(line, "tabular"));
223
+ return Math.min(AXIS_MAX, Math.max(min, shown + TICK_INSET + room));
224
+ }
225
+ /** The px a value tick's line takes (its 11px font, one line under the last, `dy` 1em). */
226
+ const TICK_LINE = 11;
227
+ /**
228
+ * @internal How far a value axis's top tick stands above its gridline, past one line: a
229
+ * tick is centered on its gridline, so a tick of `n` lines reaches (n − 1) half-lines higher than a one-line tick,
230
+ * and the chart's top margin (which holds a one-line tick's upper half) takes that much more, so the tick stays
231
+ * inside the chart ("€ 1.500.000 net | this month" passed the svg's top by 4px). `top` is the topmost tick as formatted,
232
+ * `axisTexts` every tick of the axis, `values` the values they were formatted from, `room` what the tick is given; 0
233
+ * for a one-line top tick.
234
+ */
235
+ export function tickOverhang(top, room, locale, axisTexts = [], values) {
236
+ if (top === undefined)
237
+ return 0;
238
+ const { lines } = tickText(top, room, locale, axisTexts, values);
239
+ return Math.ceil(((lines.length - 1) * TICK_LINE) / 2);
240
+ }
241
+ /**
242
+ * The width Recharts may give each tick of an axis this wide before it wraps the tick at a space: the axis less
243
+ * its 8px inset and any room beside the ticks. Below the 128px clamp it is never reached (the axis was sized for
244
+ * the longest tick); at the clamp it is exactly the room left, so a longer tick wraps rather than crossing the
245
+ * axis's outer edge.
246
+ */
247
+ export function tickWrapWidth(axisWidth, room = 0) {
248
+ return Math.max(0, axisWidth - TICK_INSET - room);
249
+ }
250
+ /**
251
+ * The ticks Recharts draws on a value axis whose domain is `[0, "auto"]` (its default): the range of the
252
+ * values, always with zero in it, extended to Recharts' own nice ticks (its public `getNiceTickValues`, as the
253
+ * axis calls it). Values count as Recharts plots them ({@link chartNumber}): numeric strings among them; a gap
254
+ * is left out, as the plot leaves it out. `allowDecimals: false` keeps the steps whole, as the axis's own
255
+ * `allowDecimals` does: counts read 0 / 1 / 2 / 3, never 0.7 / 1.4 / 2.1.
256
+ */
257
+ export function valueAxisTicks(values, tickCount, allowDecimals = true) {
258
+ let low = 0;
259
+ let high = 0;
260
+ for (const value of values) {
261
+ const number = chartNumber(value);
262
+ if (number === undefined)
263
+ continue;
264
+ low = Math.min(low, number);
265
+ high = Math.max(high, number);
266
+ }
267
+ return getNiceTickValues([low, high], tickCount, allowDecimals, "adaptive");
268
+ }
269
+ /**
270
+ * The width of a value axis over these values: its ticks as Recharts computes them, formatted as the axis
271
+ * formats them, through {@link tickAxisWidth} (with the chart's `locale`, as the axis shows them).
272
+ */
273
+ export function valueAxisWidth(values, format, options) {
274
+ const ticks = valueAxisTicks(values, options.tickCount, options.allowDecimals);
275
+ return tickAxisWidth(ticks.map(format), options.min, 0, options.locale, formattedValues(ticks, format));
276
+ }
277
+ /* ── Units and lines ─────────────────────────────────────────── */
278
+ /**
279
+ * The spaces a label may break at, as Recharts' Text breaks: ordinary ones only. A no-break space (U+00A0, U+202F)
280
+ * is where Intl keeps a figure together ("1\u00a0450\u00a0000,00\u00a0€" in ru, fr), so it never parts.
281
+ */
282
+ const BREAK = /([ \t\n\f\r\v\u2028\u2029]+)/;
283
+ /** The ordinary spaces at a text's start, and a word (up to the next ordinary space): as a label breaks. */
284
+ const SPACES_AHEAD = /^[ \t\n\f\r\v\u2028\u2029]+/;
285
+ const WORD_AHEAD = /^[^ \t\n\f\r\v\u2028\u2029]+/;
286
+ const LETTER = /\p{L}/u;
287
+ const DIGIT = /\p{Nd}/u;
288
+ /** A word that ends in a separator: a comma (Latin, Arabic, CJK), a semicolon, a slash, a bar, a middle dot or a dash. */
289
+ const SEPARATED = /[,،、,;؛;/|·•–—]$/u;
290
+ /** A label's words, each with the ordinary spaces before it. */
291
+ function wordsOf(text) {
292
+ const parts = text.split(BREAK);
293
+ const words = [];
294
+ for (let index = 0; index < parts.length; index += 2) {
295
+ const word = parts[index];
296
+ if (word !== "")
297
+ words.push({ space: index === 0 ? "" : parts[index - 1], word });
298
+ }
299
+ return words;
300
+ }
301
+ /** Whether a figure stands ahead of `from`, before the next word with a letter: a separator there parts two figures. */
302
+ function figureAhead(words, from) {
303
+ for (let at = from; at < words.length; at += 1) {
304
+ const { word } = words[at];
305
+ if (DIGIT.test(word))
306
+ return true;
307
+ if (LETTER.test(word))
308
+ return false;
309
+ }
310
+ return false;
311
+ }
312
+ /**
313
+ * @internal A label's unbreakable units, each with the spaces before it. A label breaks only at a space
314
+ * between two words that both hold a letter: a space beside a word without one (a figure, a currency sign, a minus,
315
+ * a "%", a "/") never breaks. So a figure keeps the words a formatter writes against it, whatever they are and in any
316
+ * locale: its sign and currency sign ("€ -350.000", "48.920,00 €", "% 12", "– 350.000 €"), its currency code or name
317
+ * ("1.450.000 TL", "TRY 1.450.000", "1.450.000,00 Türk"), its unit ("-12.000 km", "120 km / h") and magnitude
318
+ * ("€ 1,2 Mn", "-1,2 milyon", "-1.2 مليون"), and a word qualifying it ("€ 12.000.000 net", "total € 1.450.000");
319
+ * only a phrase parts, between its own words ("124 orders | this month", "1.450.000,00 Türk | lirası"). No word list:
320
+ * what a figure keeps is decided by where the formatter puts it, so it holds for any formatter and locale. A label
321
+ * also breaks after a separator that ends a word between two figures, each with its words: a ","
322
+ * or a "/" with a figure before it and another ahead, before the next word with a letter: "12 orders, | 3 canceled",
323
+ * "€ 900.000 / | € 1.450.000 target", "€ 900 – | € 1.450", so a label of several figures wraps between them, each
324
+ * figure still with its own words. A separator with no figure before it is a sign ("– 350.000 €"), and one with no
325
+ * figure ahead parts no figures ("120 km / h", "€ 1.450.000 | target"): neither breaks. The one rule for
326
+ * bar-end labels and value ticks.
327
+ */
328
+ export function textUnits(text) {
329
+ const words = wordsOf(text);
330
+ const units = [];
331
+ words.forEach(({ space, word }, at) => {
332
+ const lettered = LETTER.test(word);
333
+ const last = units.at(-1);
334
+ // `lettered` on a unit is its last word's: a break needs a letter on both sides of the space, or a separator
335
+ // between two figures before it.
336
+ const separates = last !== undefined && SEPARATED.test(last.unit) && DIGIT.test(last.unit) && figureAhead(words, at);
337
+ if (last && !(last.lettered && lettered) && !separates) {
338
+ last.unit += space + word;
339
+ last.lettered = lettered;
340
+ }
341
+ else
342
+ units.push({ space: units.length === 0 ? "" : space, unit: word, lettered });
343
+ });
344
+ return units.map(({ space, unit }) => ({ space, unit }));
345
+ }
346
+ const joinUnits = (units) => units.map((unit, index) => (index === 0 ? unit.unit : unit.space + unit.unit)).join("");
347
+ /**
348
+ * Units laid into lines: each line as long as fits the room by {@link textWidth}. When a unit is wider than the room
349
+ * the text stays one line (wider than the room, the caller places or shortens it): breaking it would only add lines
350
+ * that still overflow.
351
+ */
352
+ function unitLines(units, room, figures) {
353
+ if (units.some(({ unit }) => textWidth(unit, figures) > room))
354
+ return units.length > 0 ? [joinUnits(units)] : [];
355
+ const lines = [];
356
+ let line = "";
357
+ for (const { space, unit } of units) {
358
+ const joined = line === "" ? unit : line + space + unit;
359
+ if (line !== "" && textWidth(joined, figures) > room) {
360
+ lines.push(line);
361
+ line = unit;
362
+ }
363
+ else {
364
+ line = joined;
365
+ }
366
+ }
367
+ if (line !== "")
368
+ lines.push(line);
369
+ return lines;
370
+ }
371
+ /**
372
+ * @internal A text's lines for the room it has: whole when it fits, otherwise broken between its units
373
+ * ({@link textUnits}: never beside a figure), each line as long as fits, by the same estimate as the room. When a
374
+ * unit is wider than the room, the whole text on one line, wider than the room.
375
+ */
376
+ export function textLines(text, room, figures = "proportional") {
377
+ if (textWidth(text, figures) <= room)
378
+ return [text];
379
+ const lines = unitLines(textUnits(text), room, figures);
380
+ return lines.length > 0 ? lines : [text];
381
+ }
382
+ const fitsRoom = (lines, room) => lines.every((line) => textWidth(line, "tabular") <= room);
383
+ /** Whether a tick fits its room, whole or between its units. */
384
+ const tickFits = (text, room) => fitsRoom(textLines(text, room, "tabular"), room);
385
+ /** Whether an axis shows its figures compact: one of its ticks does not fit the room, even between its units. */
386
+ const compactsAxis = (texts, room) => texts.some((text) => !tickFits(text, room));
387
+ /* ── Compact figures ─────────────────────────────────────────── */
388
+ /**
389
+ * A figure as a formatter writes it: digits of one script with the group and decimal marks between them
390
+ * ("150.000.000", "1\u00a0450\u00a0000,5", "١٥٠٬٠٠٠"); a plain space only as a group mark (three digits after it).
391
+ */
392
+ const FIGURE = /\p{Nd}+(?:(?:[.,'’\u00a0\u202f\u2009٫٬]|\x20(?=\p{Nd}{3}(?!\p{Nd})))\p{Nd}+)*/gu;
393
+ /** Intl's names for the digit scripts a formatter may write in, by their zero. */
394
+ const NUMBERING = new Map([
395
+ [0x30, "latn"],
396
+ [0x660, "arab"],
397
+ [0x6f0, "arabext"],
398
+ [0x966, "deva"],
399
+ [0x9e6, "beng"],
400
+ [0xe50, "thai"],
401
+ [0xff10, "fullwide"],
402
+ ]);
403
+ /**
404
+ * Marks that only ever group a figure's digits: the spaces, the apostrophes (de-CH) and the Arabic thousands
405
+ * separator. The Arabic decimal separator only ever is the decimal mark. "." and "," are either, by the formatter's
406
+ * locale, which need not be the chart's.
407
+ */
408
+ const GROUP_MARK = /[\x20\u00a0\u2009\u202f'’٬]/;
409
+ const DECIMAL_MARK = "٫";
410
+ /** The zero of a digit's script: Unicode puts each script's ten digits in a row. */
411
+ function digitZero(code) {
412
+ let start = code;
413
+ while (DIGIT.test(String.fromCodePoint(start - 1)))
414
+ start -= 1;
415
+ return code - ((code - start) % 10);
416
+ }
417
+ const formats = new Map();
418
+ function numberFormat(locale, options) {
419
+ const key = `${locale}|${JSON.stringify(options)}`;
420
+ let format = formats.get(key);
421
+ if (!format) {
422
+ format = new Intl.NumberFormat(locale, options);
423
+ formats.set(key, format);
424
+ }
425
+ return format;
426
+ }
427
+ function figureMarks(figure) {
428
+ let digits = "";
429
+ const marks = [];
430
+ for (const char of figure) {
431
+ const code = char.codePointAt(0);
432
+ if (DIGIT.test(char))
433
+ digits += String(code - digitZero(code));
434
+ else
435
+ marks.push({ mark: char, at: digits.length });
436
+ }
437
+ return { digits, marks };
438
+ }
439
+ /**
440
+ * Where these roles put a figure's decimal point, when a formatter writes figures so: one decimal
441
+ * mark at most, once, after every group mark; one group mark, the digits grouped as Intl groups them, in threes
442
+ * ("1.450.000") or in the Indian way, twos then the last three ("1,45,00,000"), the first group one to three digits
443
+ * (one or two in the Indian way) and never a leading zero. Undefined otherwise: "15.10.2026", "192.168.1.1",
444
+ * "0555 123" and "1.4500" are not figures any formatter writes.
445
+ */
446
+ function pointOf({ digits, marks }, roles) {
447
+ const decimals = marks.filter(({ mark }) => roles.get(mark) === "decimal");
448
+ const groups = marks.filter(({ mark }) => roles.get(mark) === "group");
449
+ if (decimals.length > 1)
450
+ return undefined;
451
+ const point = decimals[0]?.at ?? digits.length;
452
+ if (groups.length === 0)
453
+ return point;
454
+ if (new Set(groups.map(({ mark }) => mark)).size > 1 || groups.some(({ at }) => at >= point) || digits[0] === "0")
455
+ return undefined;
456
+ const bounds = [0, ...groups.map(({ at }) => at), point];
457
+ const [first, ...rest] = bounds.slice(1).map((bound, index) => bound - bounds[index]);
458
+ const threes = first <= 3 && rest.every((size) => size === 3);
459
+ const indian = first <= 2 && rest.at(-1) === 3 && rest.slice(0, -1).every((size) => size === 2);
460
+ return first >= 1 && (threes || indian) ? point : undefined;
461
+ }
462
+ /**
463
+ * Every reading of a figure a formatter may have written ({@link pointOf}): the spaces, the apostrophes (de-CH) and
464
+ * the Arabic thousands separator only ever group; the Arabic decimal separator only ever is the decimal mark; "." and
465
+ * "," are either, by the formatter's locale, which need not be the chart's. None for marks no formatter writes, one
466
+ * when the marks prove themselves ("1.450.000", "1.450.000,5", "0,500"), two when they cannot tell ("1,500": fifteen
467
+ * hundred in en, one and a half in de).
468
+ */
469
+ function readingsOf(figure) {
470
+ const distinct = [...new Set(figure.marks.map(({ mark }) => mark))];
471
+ const choices = distinct.map((mark) => (GROUP_MARK.test(mark) ? ["group"] : mark === DECIMAL_MARK ? ["decimal"] : ["group", "decimal"]));
472
+ const readings = [];
473
+ const walk = (at, roles) => {
474
+ if (at === distinct.length) {
475
+ const point = pointOf(figure, roles);
476
+ if (point !== undefined)
477
+ readings.push({ roles: new Map(roles), point });
478
+ return;
479
+ }
480
+ for (const role of choices[at])
481
+ walk(at + 1, new Map(roles).set(distinct[at], role));
482
+ };
483
+ walk(0, new Map());
484
+ return readings;
485
+ }
486
+ /**
487
+ * Whether a reading agrees with what the axis proves: one formatter writes every tick of an axis, with one group mark
488
+ * and one decimal mark, so a mark proven to group never is the decimal mark, and a mark is not a role another mark
489
+ * proved. `proven` also asks that each mark's role be proven, by the mark itself or by the other mark's.
490
+ */
491
+ function agrees(reading, { group, decimal }, proven) {
492
+ for (const [mark, role] of reading.roles) {
493
+ const same = role === "group" ? group : decimal;
494
+ const other = role === "group" ? decimal : group;
495
+ if (other.has(mark) || [...same].some((each) => each !== mark))
496
+ return false;
497
+ if (proven && !same.has(mark) && ![...other].some((each) => each !== mark))
498
+ return false;
499
+ }
500
+ return true;
501
+ }
502
+ /**
503
+ * Whether a figure read so is the value it was formatted from: equal to it, as rounded to the figure's last
504
+ * significant digit (a formatter rounds to its fraction or significant digits: "1.450.000" for 1,450,000.4 or, at
505
+ * two significant digits, for 1,452,345). The readings of a figure differ a thousandfold, so at most one is.
506
+ */
507
+ function writesValue({ digits }, point, value) {
508
+ const figure = Number(`${digits.slice(0, point) || "0"}.${digits.slice(point) || "0"}`);
509
+ const lastSignificant = Math.max(...[...digits].map((digit, at) => (digit === "0" ? -1 : at)));
510
+ const place = point - 1 - (lastSignificant < 0 ? digits.length - 1 : lastSignificant);
511
+ const difference = Math.abs(figure - Math.abs(value));
512
+ return difference <= 0.5 * 10 ** place * (1 + 1e-9) || difference <= Math.abs(value) * 4 * Number.EPSILON;
513
+ }
514
+ /** @internal These values as `format` writes them ({@link FormattedValues}); a value that is not a finite number is left out. */
515
+ export function formattedValues(values, format) {
516
+ const map = new Map();
517
+ for (const value of values) {
518
+ const number = chartNumber(value);
519
+ if (number !== undefined)
520
+ map.set(format(number), number);
521
+ }
522
+ return map;
523
+ }
524
+ /**
525
+ * What the figures of an axis prove of their marks ("1,500" from a de formatter in an en chart was read
526
+ * as fifteen hundred, "1.5K"). With the values the ticks were formatted from, outright: the reading
527
+ * under which a figure is its tick's value is the formatter's ("€60,000" of 60,000 proves "," groups; "1,500" of 1.5
528
+ * that it is the decimal mark). A figure that is no value of its text (a formatter's own scaling, an identifier)
529
+ * proves nothing. Only without values, by the figures alone: a mark a figure proves by its own marks
530
+ * ({@link readingsOf}, one reading) holds for the others.
531
+ */
532
+ function markRoles(texts, values) {
533
+ const group = new Set();
534
+ const decimal = new Set();
535
+ const known = values ? texts.flatMap((text) => (values.has(text) ? [[text, values.get(text)]] : [])) : [];
536
+ const byValue = known.length > 0;
537
+ const prove = (reading) => {
538
+ for (const [mark, role] of reading.roles)
539
+ (role === "group" ? group : decimal).add(mark);
540
+ };
541
+ if (byValue) {
542
+ for (const [text, value] of known) {
543
+ for (const [match] of text.matchAll(FIGURE)) {
544
+ const figure = figureMarks(match);
545
+ const matching = readingsOf(figure).filter((reading) => writesValue(figure, reading.point, value));
546
+ if (matching.length === 1)
547
+ prove(matching[0]);
548
+ }
549
+ }
550
+ }
551
+ else {
552
+ for (const text of texts) {
553
+ for (const [match] of text.matchAll(FIGURE)) {
554
+ const readings = readingsOf(figureMarks(match));
555
+ if (readings.length === 1)
556
+ prove(readings[0]);
557
+ }
558
+ }
559
+ }
560
+ // Proven both ways (two formatters, or a figure that only seemed one): proven neither.
561
+ for (const mark of [...group]) {
562
+ if (decimal.delete(mark))
563
+ group.delete(mark);
564
+ }
565
+ return { group, decimal, byValue };
566
+ }
567
+ /**
568
+ * A figure read by the one reading ({@link readingsOf}) that agrees with what its axis proves ({@link markRoles}):
569
+ * with values, only a reading the values prove; without, one its own marks or the axis's figures leave. Undefined
570
+ * where no reading or more than one remains, so it is kept as written rather than misread (never by the chart's
571
+ * locale, which need not be the formatter's), and under 1,000, which is short already.
572
+ */
573
+ function readFigure(figure, roles) {
574
+ const zero = digitZero(figure.codePointAt(0));
575
+ const numbering = NUMBERING.get(zero);
576
+ const marks = figureMarks(figure);
577
+ const readings = readingsOf(marks).filter((reading) => agrees(reading, roles, roles.byValue));
578
+ if (readings.length !== 1)
579
+ return undefined;
580
+ const { point } = readings[0];
581
+ const whole = marks.digits.slice(0, point).replace(/^0+(?=\d)/, "");
582
+ if (whole.length < 4)
583
+ return undefined;
584
+ return { value: `${whole}.${marks.digits.slice(point) || "0"}`, zero, numbering };
585
+ }
586
+ /**
587
+ * A figure compact with exactly these fraction digits, or with as many as it needs (up to 20) when none are given:
588
+ * then it is exact. In the locale and the figure's own digits.
589
+ */
590
+ function compactParts(figure, locale, digits) {
591
+ const fraction = digits === undefined ? { maximumFractionDigits: 20 } : { minimumFractionDigits: digits, maximumFractionDigits: digits };
592
+ return numberFormat(locale, { notation: "compact", numberingSystem: figure.numbering ?? "latn", ...fraction }).formatToParts(figure.value);
593
+ }
594
+ /** A figure's exact compact form: the magnitude Intl writes it in ("Mn", "ترليون"; none where a locale keeps it whole, as de under a million) and the fraction digits it needs. */
595
+ function exactCompact(figure, locale) {
596
+ const parts = compactParts(figure, locale);
597
+ const magnitude = parts.filter((part) => part.type === "compact").map((part) => part.value).join("");
598
+ const digits = parts.filter((part) => part.type === "fraction").reduce((sum, part) => sum + Array.from(part.value).length, 0);
599
+ return { magnitude: `${figure.numbering ?? figure.zero}|${magnitude}`, digits };
600
+ }
601
+ /**
602
+ * The figures of an axis written short, in the chart's locale and the figure's own digits, always
603
+ * exactly, so a tick never names a value its gridline does not stand at ("₺2,25 Tn", never Intl's "₺2,3 Tn" of two
604
+ * significant digits; "€ 1,95 Mn", never "€ 2 Mn"):
605
+ * - compact, in the fewest words its locale has; `padded`, the figures of one magnitude with the same fraction
606
+ * digits, as many as the one of them that needs most ("€ 1,50 Mn" beside "€ 2,25 Mn"; "€ 750 B" beside them keeps
607
+ * its own none); otherwise each with only the digits it needs ("€ 1,5 Mn"): still exact, and narrower, for an axis
608
+ * whose padded ticks do not fit;
609
+ * - `scientific`, in scientific notation, exact ("1,5E29 €"), where that is narrower than compact: a figure past the
610
+ * largest magnitude its locale names, which compact keeps with every digit above it ("150 000 000 000 000 000 трлн
611
+ * €", "15,000,000,000,000京"). When an axis takes it is {@link shortText}'s, by fit.
612
+ * Undefined under 1,000, where the figure's marks cannot be read for certain ({@link readFigure}), and where the
613
+ * short form is no shorter than the figure as written ("1.450.000.000.007" stays): the figure is then kept as written.
614
+ */
615
+ function axisFigures(texts, locale, values, figures) {
616
+ const roles = markRoles(texts, values);
617
+ const digits = new Map();
618
+ const forms = new Map();
619
+ const formsOf = (match) => {
620
+ if (forms.has(match))
621
+ return forms.get(match);
622
+ const figure = readFigure(match, roles);
623
+ // A script Intl has no name for: its own digits for the Latin ones.
624
+ const own = (text) => (figure?.numbering ? text : text.replace(/[0-9]/g, (digit) => String.fromCodePoint(figure.zero + Number(digit))));
625
+ const exact = figure && exactCompact(figure, locale);
626
+ const found = figure && exact && {
627
+ exact,
628
+ compact: (padded) => own(compactParts(figure, locale, padded ? Math.max(exact.digits, digits.get(exact.magnitude) ?? 0) : exact.digits).map((part) => part.value).join("")),
629
+ scientific: own(numberFormat(locale, { notation: "scientific", numberingSystem: figure.numbering ?? "latn", maximumFractionDigits: 20 }).format(figure.value)),
630
+ };
631
+ forms.set(match, found);
632
+ return found;
633
+ };
634
+ const matches = texts.flatMap((text) => [...text.matchAll(FIGURE)].map(([match]) => match));
635
+ for (const match of matches) {
636
+ const found = formsOf(match);
637
+ if (found)
638
+ digits.set(found.exact.magnitude, Math.max(digits.get(found.exact.magnitude) ?? 0, found.exact.digits));
639
+ }
640
+ return (match, padded, scientific) => {
641
+ const found = formsOf(match);
642
+ if (!found)
643
+ return undefined;
644
+ const compact = found.compact(padded);
645
+ const written = scientific && textWidth(found.scientific, figures) < textWidth(compact, figures) ? found.scientific : compact;
646
+ // Exact can be long ("1,450000000007 Tn"): a figure is written short only where that is shorter.
647
+ return textWidth(written, figures) < textWidth(match, figures) ? written : undefined;
648
+ };
649
+ }
650
+ /** Each unit with its figures written by `write` in place (a currency, a sign, a unit word stay as the formatter wrote them). */
651
+ function shownText(units, write) {
652
+ let text = "";
653
+ let first = -1;
654
+ let last = -1;
655
+ let end = -1;
656
+ const shown = units.map(({ space, unit }, index) => {
657
+ if (index > 0)
658
+ text += space;
659
+ let written = "";
660
+ let from = 0;
661
+ for (const match of unit.matchAll(FIGURE)) {
662
+ written += unit.slice(from, match.index);
663
+ last = text.length + written.length;
664
+ if (first < 0)
665
+ first = last;
666
+ written += write(match[0]) ?? match[0];
667
+ end = text.length + written.length;
668
+ from = match.index + match[0].length;
669
+ }
670
+ written += unit.slice(from);
671
+ text += written;
672
+ return { space, unit: written };
673
+ });
674
+ return { units: shown, text, figures: first < 0 ? undefined : { first, last, end } };
675
+ }
676
+ /* ── The last resort ─────────────────────────────── */
677
+ /** The scripts written right to left whose letters are bidi class AL (Arabic letters) and R (the others), UAX #9. */
678
+ const AL_SCRIPT = /[\p{Script=Arabic}\p{Script=Syriac}\p{Script=Thaana}\p{Script=Hanifi_Rohingya}]/u;
679
+ const R_SCRIPT = /[\p{Script=Hebrew}\p{Script=Nko}\p{Script=Samaritan}\p{Script=Mandaic}\p{Script=Adlam}\p{Script=Mende_Kikakui}\p{Script=Yezidi}]/u;
680
+ const RTL_LETTER = { test: (char) => LETTER.test(char) && (AL_SCRIPT.test(char) || R_SCRIPT.test(char)) };
681
+ /** A sign that is a figure's unit: a currency sign, a percent or per-mille sign. */
682
+ const UNIT_SIGN = /[\p{Sc}%‰‱]/u;
683
+ /** Words as they are compared with Intl's: format and bidi marks left out, every space one plain space. */
684
+ const plain = (text) => text.replace(/\p{Cf}/gu, "").replace(/\s+/gu, " ").trim();
685
+ /** The longest affix: a currency name or a unit runs to a few words ("Bosna-Hersek konvertibl markı"). */
686
+ const AFFIX_WORDS = 4;
687
+ const affixesByLocale = new Map();
688
+ /**
689
+ * What Intl writes against a figure in the chart's locale: every currency's ISO code, symbol, narrow symbol and name
690
+ * (each plural form), every unit short, narrow and long (each plural form), and the magnitudes of its compact
691
+ * notation, short and long. Intl's own words, not a list of the DS's: what makes a word a figure's currency or unit
692
+ * rather than a qualifier ("Türk lirası", "ج.م.", "km" against "net", "this month"). Built once a locale, and only for a
693
+ * tick that reaches the last resort.
694
+ */
695
+ function affixes(locale) {
696
+ const known = affixesByLocale.get(locale);
697
+ if (known)
698
+ return known;
699
+ const units = new Set();
700
+ const magnitudes = new Set();
701
+ const add = (set, parts, type) => {
702
+ for (const part of parts)
703
+ if (part.type === type && plain(part.value) !== "")
704
+ set.add(plain(part.value));
705
+ };
706
+ const plural = new Intl.PluralRules(locale);
707
+ // One number of each plural form the locale has, as names and long units change with it.
708
+ const samples = [...new Map([0, 1, 2, 3, 5, 11, 21, 100, 0.5, 1.5].map((value) => [plural.select(value), value])).values()];
709
+ const supported = (key) => (typeof Intl.supportedValuesOf === "function" ? Intl.supportedValuesOf(key) : []);
710
+ for (const currency of supported("currency")) {
711
+ units.add(currency);
712
+ for (const currencyDisplay of ["symbol", "narrowSymbol"])
713
+ add(units, new Intl.NumberFormat(locale, { style: "currency", currency, currencyDisplay }).formatToParts(1), "currency");
714
+ const named = new Intl.NumberFormat(locale, { style: "currency", currency, currencyDisplay: "name" });
715
+ for (const sample of samples) {
716
+ const parts = named.formatToParts(sample);
717
+ add(units, parts, "currency");
718
+ // An app writes Bosnian currency names through localWords ("eura", not Intl's "evra"): both are unit words.
719
+ add(units, parts.map((part) => ({ ...part, value: localWords(locale, part.value) })), "currency");
720
+ }
721
+ }
722
+ for (const unit of supported("unit")) {
723
+ for (const unitDisplay of ["short", "narrow", "long"]) {
724
+ const format = new Intl.NumberFormat(locale, { style: "unit", unit, unitDisplay });
725
+ for (const sample of samples)
726
+ add(units, format.formatToParts(sample), "unit");
727
+ }
728
+ }
729
+ for (const compactDisplay of ["short", "long"]) {
730
+ const format = new Intl.NumberFormat(locale, { notation: "compact", compactDisplay });
731
+ for (let power = 3; power <= 18; power += 1)
732
+ for (const lead of [1, 2, 5])
733
+ add(magnitudes, format.formatToParts(lead * 10 ** power), "compact");
734
+ }
735
+ const found = { units, magnitudes };
736
+ affixesByLocale.set(locale, found);
737
+ return found;
738
+ }
739
+ /** The length of the longest phrase of `set` that `text` starts with, as whole words; 0 for none. */
740
+ function phraseAhead(text, set) {
741
+ const words = [];
742
+ let at = 0;
743
+ const ends = [];
744
+ while (words.length < AFFIX_WORDS) {
745
+ const space = words.length === 0 ? "" : SPACES_AHEAD.exec(text.slice(at))?.[0];
746
+ if (space === undefined)
747
+ break;
748
+ const word = WORD_AHEAD.exec(text.slice(at + space.length))?.[0];
749
+ if (word === undefined)
750
+ break;
751
+ words.push(word);
752
+ at += space.length + word.length;
753
+ ends.push(at);
754
+ }
755
+ for (let count = words.length; count > 0; count -= 1)
756
+ if (set.has(plain(words.slice(0, count).join(" "))))
757
+ return ends[count - 1];
758
+ return 0;
759
+ }
760
+ /** The length of the longest phrase of `set` that `text` ends with, as whole words; 0 for none. */
761
+ function phraseBehind(text, set) {
762
+ const words = wordsOf(trimBreaks(text));
763
+ for (let count = Math.min(AFFIX_WORDS, words.length); count > 0; count -= 1) {
764
+ const phrase = words.slice(-count);
765
+ if (set.has(plain(phrase.map(({ word }) => word).join(" "))))
766
+ return phrase.reduce((sum, { space, word }, index) => sum + (index === 0 ? 0 : space.length) + word.length, 0) + (text.length - trimBreaks(text).length);
767
+ }
768
+ return 0;
769
+ }
770
+ /** A text without the ordinary spaces at its end (a no-break space stays: it is part of a word). */
771
+ const trimBreaks = (text) => text.replace(/[ \t\n\f\r\v\u2028\u2029]+$/, "");
772
+ /**
773
+ * Where a figure's group starts, from the figure at `at`: its own word ("-€150", "\u200f١٥٠"), the words before it with no
774
+ * letter (a currency sign, a sign: "€ ", "– "), and, when those hold no currency or percent sign, the currency or
775
+ * unit Intl writes right before it ("TRY ", "US$ "). `unit` when the figure has its currency or unit there.
776
+ */
777
+ function groupStart(text, at, units) {
778
+ let start = at;
779
+ while (start > 0 && !BREAK.test(text[start - 1]))
780
+ start -= 1;
781
+ let unit = UNIT_SIGN.test(text.slice(start, at));
782
+ for (;;) {
783
+ const before = text.slice(0, start);
784
+ const word = wordsOf(before).at(-1);
785
+ if (!word || DIGIT.test(word.word))
786
+ break;
787
+ const wordStart = trimBreaks(before).length - word.word.length;
788
+ if (!LETTER.test(word.word)) {
789
+ start = wordStart;
790
+ if (UNIT_SIGN.test(word.word))
791
+ unit = true;
792
+ continue;
793
+ }
794
+ if (!unit) {
795
+ const phrase = phraseBehind(before, units);
796
+ if (phrase > 0) {
797
+ start -= phrase;
798
+ unit = true;
799
+ }
800
+ }
801
+ break;
802
+ }
803
+ return { start, unit };
804
+ }
805
+ /**
806
+ * Where a figure's group ends, from the end of the last figure (`at`, a compact magnitude with it): the rest of its
807
+ * word ("1,5 MnTL"); then, word by word, a word with no letter (a currency sign, a "%", a "/"), with the word it
808
+ * holds to after it ("/ h"); a magnitude the formatter wrote ("1,5 milyon"); the currency or unit Intl writes in the
809
+ * chart's locale ("Türk lirası", "km", "ج.م."), and, when the figure has none yet, the first word after it as its unit
810
+ * (a formatter's own: "1.450.000 TL", "124 orders"). What follows is a qualifier ("net", "this month").
811
+ */
812
+ function groupEnd(text, at, unit, found) {
813
+ const rest = WORD_AHEAD.exec(text.slice(at))?.[0] ?? "";
814
+ let end = at + rest.length;
815
+ // A currency or unit Intl joins to the figure's word with a no-break space ("ترليون\u00a0ج.م.") is its unit too.
816
+ let hasUnit = unit || UNIT_SIGN.test(rest) || rest.split(/[\u00a0\u202f]/).some((piece) => found.units.has(plain(piece)));
817
+ let held = false;
818
+ let magnitude = true;
819
+ for (;;) {
820
+ const space = SPACES_AHEAD.exec(text.slice(end))?.[0];
821
+ if (space === undefined)
822
+ break;
823
+ const from = end + space.length;
824
+ const word = WORD_AHEAD.exec(text.slice(from))?.[0];
825
+ if (word === undefined)
826
+ break;
827
+ if (!LETTER.test(word)) {
828
+ end = from + word.length;
829
+ hasUnit ||= UNIT_SIGN.test(word);
830
+ held = SEPARATED.test(word);
831
+ continue;
832
+ }
833
+ const ahead = text.slice(from);
834
+ const scale = magnitude ? phraseAhead(ahead, found.magnitudes) : 0;
835
+ if (scale > 0) {
836
+ end = from + scale;
837
+ magnitude = false;
838
+ continue;
839
+ }
840
+ // Intl's currency or unit is the figure's even beside its sign ("₺150 Tn Türk lirası", tr's currency name); a
841
+ // first word is when the figure has none; after a separator with no figure ahead ("km / h") the word holds to
842
+ // it, as textUnits holds it.
843
+ const named = phraseAhead(ahead, found.units);
844
+ if (named > 0 || !hasUnit || held) {
845
+ end = from + (named || word.length);
846
+ hasUnit = true;
847
+ held = false;
848
+ magnitude = false;
849
+ continue;
850
+ }
851
+ break;
852
+ }
853
+ return end;
854
+ }
855
+ /** Extended Arabic-Indic figures (Persian, Urdu): bidi class EN, as European figures are (see readsRightToLeft's extension). */
856
+ const EXTENDED_ARABIC_FIGURE = /[\u06f0-\u06f9]/u;
857
+ /** The isolate initiators (LRI, RLI, FSI) and their terminator (PDI), whose content UAX #9's rule P2 passes over. */
858
+ const ISOLATE_INITIATOR = /[\u2066\u2067\u2068]/u;
859
+ const PDI = "\u2069";
860
+ /**
861
+ * @internal Whether a text reads from the right, by its first strong character: UAX #9's rule P2, as a
862
+ * browser decides `dir="auto"` and `unicode-bidi: plaintext`, with one extension.
863
+ *
864
+ * P2: the first character of bidi class L, R or AL decides, passing over what an isolate (LRI, RLI or FSI to its PDI,
865
+ * or to the end without one) holds. A right-to-left mark or letter (R, AL; the Arabic letter mark U+061C is AL) reads
866
+ * from the right; a left-to-right mark or any other letter, or a figure of class L ("१५०"), from the left. Figures of
867
+ * class EN or AN, signs, currency signs, spaces and punctuation are weak or neutral and decide nothing: "150 ترليون",
868
+ * "€ 50 ترليون", "0 كم" and "150 ترليون TL" (Intl's "ar", "ar-MA", "ur" write Latin figures) read from the right,
869
+ * their first letter Arabic, as "\u200f١٥٠ ترليون €" and "إجمالي € 1.450.000" do; "€ 1.450.000 net", "150 трлн €"
870
+ * and "\u200e-150 ترليون" from the left. A line with no strong character ("€ 1.450.000", "%12,4") reads left to
871
+ * right, the plot's direction.
872
+ *
873
+ * The extension: before any strong character, an Arabic-Indic figure or Arabic number sign (class AN, U+0660–0669,
874
+ * U+0600–0605 and the Arabic separators) or an Extended Arabic-Indic figure (U+06F0–06F9, class EN like the European
875
+ * figures) also decides right to left, where P2 would leave "١٥٠" or "۱۵۰" to the plot's left-to-right direction. The
876
+ * reason: only right-to-left locales write these figures (Arabic, Persian, Urdu, Pashto, Sorani…), so such a line is
877
+ * given the direction the rest of its axis reads in, which is also the side a clipped line keeps in view
878
+ * (clipDirection). The figures themselves are drawn in the same order either way (EN and AN figures are laid out left to
879
+ * right at any level), and the line's anchor follows its direction (value-tick's anchorFor), so it stands where it
880
+ * stood. What can differ is a neutral or a Latin word after the figures: measured in Chromium over Intl's output (26
881
+ * locales, 9 styles, 7 values; 106 lines where the extension decides and P2 would not), for every Arabic locale (ar,
882
+ * ar-EG, ar-SA, ar-IQ, ar-SY, ar-YE, ar-SD) and "ur" it changes nothing drawn, as Intl writes an Arabic letter mark (AL)
883
+ * or a right-to-left mark where a sign or a symbol would move; in fa (scientific notation only), fa-AF, ur-IN, ps, ckb,
884
+ * sd, ks, pa-Arab, uz-Arab, mzn and lrc (60 lines) a sign, percent sign, currency or Latin unit after the figures stands
885
+ * on their left, as a right-to-left reader reads it ("١٣ ٪" in ckb, "۱۲٫۵ km" in ps), where P2 would put it on the right.
886
+ *
887
+ * The direction every tick and label line is drawn in (value-tick's lineDirection), and a clipped line's own direction
888
+ * (clipDirection), so its reading start stays in view.
889
+ */
890
+ export function readsRightToLeft(text) {
891
+ let isolates = 0;
892
+ for (const char of text) {
893
+ if (ISOLATE_INITIATOR.test(char)) {
894
+ isolates += 1;
895
+ continue;
896
+ }
897
+ if (char === PDI) {
898
+ isolates = Math.max(0, isolates - 1);
899
+ continue;
900
+ }
901
+ if (isolates > 0)
902
+ continue;
903
+ const type = bidiClass(char);
904
+ if (type === "R" || type === "AL")
905
+ return true;
906
+ if (type === "L")
907
+ return false;
908
+ // The extension above (not P2).
909
+ if (type === "AN" || EXTENDED_ARABIC_FIGURE.test(char))
910
+ return true;
911
+ }
912
+ return false;
913
+ }
914
+ function bidiClass(char) {
915
+ if (char === "\u200e")
916
+ return "L";
917
+ if (char === "\u200f")
918
+ return "R";
919
+ if (/[\u061c\u060b\u060d\u061b\u061d-\u061f\u066d\u06d4]/u.test(char))
920
+ return "AL";
921
+ if (/[\u0600-\u0605\u0660-\u0669\u066b\u066c\u06dd\u0890\u0891\u08e2\u{10d30}-\u{10d39}]/u.test(char))
922
+ return "AN";
923
+ // European figures (and their full-width, mathematical and Extended Arabic-Indic forms) are EN; the figures of a
924
+ // right-to-left script (N'Ko, Adlam) are R; every other script's figures ("१५०", "๑๕๐") are L.
925
+ if (/[0-9\u06f0-\u06f9\uff10-\uff19\u{1d7ce}-\u{1d7ff}\u{1fbf0}-\u{1fbf9}]/u.test(char))
926
+ return "EN";
927
+ if (/\p{Nd}/u.test(char))
928
+ return R_SCRIPT.test(char) ? "R" : "L";
929
+ if (/[\p{Mn}\p{Me}]/u.test(char))
930
+ return "NSM";
931
+ if (/\p{Cf}/u.test(char))
932
+ return "BN";
933
+ if (AL_SCRIPT.test(char) && /\p{L}/u.test(char))
934
+ return "AL";
935
+ if (R_SCRIPT.test(char) && /\p{L}/u.test(char))
936
+ return "R";
937
+ if (/[\p{L}\p{Mc}]/u.test(char))
938
+ return "L";
939
+ if (/[+\-\u207a\u207b\u208a\u208b\u2212\ufb29\ufe62\ufe63\uff0b\uff0d]/u.test(char))
940
+ return "ES";
941
+ if (/[\p{Sc}#%°‰‱\u066a\u0609\u060a\u2030-\u2034]/u.test(char))
942
+ return "ET";
943
+ if (/[,.:/\u00a0\u060c\u202f\u2044\ufe50\ufe52\ufe55\uff0c\uff0e\uff0f\uff1a]/u.test(char))
944
+ return "CS";
945
+ if (/\s/u.test(char))
946
+ return "WS";
947
+ return "ON";
948
+ }
949
+ /**
950
+ * A line's characters in the order a browser draws them from the left, in a paragraph of this direction: the Unicode
951
+ * bidirectional algorithm (UAX #9: its weak, neutral and implicit rules and its reordering) for a line without
952
+ * explicit embeddings, as a chart's ticks and labels are. Format marks keep the level before them.
953
+ */
954
+ function visualOrder(chars, rtl) {
955
+ const base = rtl ? 1 : 0;
956
+ const edge = rtl ? "R" : "L";
957
+ const types = chars.map(bidiClass);
958
+ const kept = types.flatMap((type, at) => (type === "BN" ? [] : [at]));
959
+ const t = kept.map((at) => types[at]);
960
+ // W1–W3: a mark takes the class before it; a European figure after Arabic letters is an Arabic one; AL is R.
961
+ let strong = edge;
962
+ t.forEach((type, at) => {
963
+ if (type === "NSM")
964
+ t[at] = at === 0 ? edge : t[at - 1];
965
+ if (t[at] === "L" || t[at] === "R" || t[at] === "AL")
966
+ strong = t[at];
967
+ if (t[at] === "EN" && strong === "AL")
968
+ t[at] = "AN";
969
+ });
970
+ t.forEach((type, at) => {
971
+ if (type === "AL")
972
+ t[at] = "R";
973
+ });
974
+ // W4: one separator between two figures of a kind joins them.
975
+ for (let at = 1; at < t.length - 1; at += 1) {
976
+ const [before, after] = [t[at - 1], t[at + 1]];
977
+ if (t[at] === "ES" && before === "EN" && after === "EN")
978
+ t[at] = "EN";
979
+ else if (t[at] === "CS" && before === after && (before === "EN" || before === "AN"))
980
+ t[at] = before;
981
+ }
982
+ // W5: a run of terminators beside a European figure is one.
983
+ for (let at = 0; at < t.length; at += 1) {
984
+ if (t[at] !== "ET")
985
+ continue;
986
+ let end = at;
987
+ while (end < t.length && t[end] === "ET")
988
+ end += 1;
989
+ if (t[at - 1] === "EN" || t[end] === "EN")
990
+ for (let each = at; each < end; each += 1)
991
+ t[each] = "EN";
992
+ at = end;
993
+ }
994
+ // W6, W7: other separators and terminators are neutral; a European figure after Latin letters is Latin.
995
+ strong = edge;
996
+ t.forEach((type, at) => {
997
+ if (type === "ES" || type === "ET" || type === "CS")
998
+ t[at] = "ON";
999
+ if (t[at] === "L" || t[at] === "R")
1000
+ strong = t[at];
1001
+ if (t[at] === "EN" && strong === "L")
1002
+ t[at] = "L";
1003
+ });
1004
+ // N1, N2: neutrals between two of one direction (figures count as R) take it; others the paragraph's.
1005
+ const direction = (type) => (type === undefined ? edge : type === "L" ? "L" : "R");
1006
+ for (let at = 0; at < t.length; at += 1) {
1007
+ if (t[at] !== "WS" && t[at] !== "ON")
1008
+ continue;
1009
+ let end = at;
1010
+ while (end < t.length && (t[end] === "WS" || t[end] === "ON"))
1011
+ end += 1;
1012
+ const before = direction(t[at - 1]);
1013
+ const resolved = before === direction(t[end]) ? before : edge;
1014
+ for (let each = at; each < end; each += 1)
1015
+ t[each] = resolved;
1016
+ at = end;
1017
+ }
1018
+ // I1, I2: the implicit levels.
1019
+ const levels = new Array(chars.length).fill(base);
1020
+ kept.forEach((index, at) => {
1021
+ const type = t[at];
1022
+ levels[index] = rtl ? (type === "R" ? 1 : 2) : type === "L" ? 0 : type === "R" ? 1 : 2;
1023
+ });
1024
+ types.forEach((type, at) => {
1025
+ if (type === "BN")
1026
+ levels[at] = at === 0 ? base : levels[at - 1];
1027
+ });
1028
+ // L2: from the highest level to the lowest odd one, each run at or above it reversed.
1029
+ const order = chars.map((_, at) => at);
1030
+ const highest = Math.max(base, ...levels);
1031
+ const lowestOdd = Math.min(...levels.filter((level) => level % 2 === 1), highest + 1);
1032
+ for (let level = highest; level >= lowestOdd && level > 0; level -= 1) {
1033
+ for (let at = 0; at < order.length; at += 1) {
1034
+ if (levels[order[at]] < level)
1035
+ continue;
1036
+ let end = at;
1037
+ while (end < order.length && levels[order[end]] >= level)
1038
+ end += 1;
1039
+ order.splice(at, end - at, ...order.slice(at, end).reverse());
1040
+ at = end;
1041
+ }
1042
+ }
1043
+ return order;
1044
+ }
1045
+ /**
1046
+ * @internal The direction a clipped line is laid out in, so its reading start, its first character,
1047
+ * is drawn inside its clip: the clip's start edge holds the paragraph's start (its left in "ltr", its right in "rtl"),
1048
+ * and the characters a browser draws between that edge and the first one ({@link visualOrder}, at their
1049
+ * {@link textWidth}) push it in. The line's own direction ({@link readsRightToLeft}) where its first character then
1050
+ * fits within `room` ("\u200f١٥٠ ترليون €xxxx" in "rtl", its figure at the right edge); otherwise the other where it
1051
+ * does ("\u200f1.45M €xxxx", whose right-to-left mark leads a left-to-right run: in "rtl" that run would stand at
1052
+ * the right edge with its figure at its far left, clipped; in "ltr" the figure is at the left edge); otherwise the
1053
+ * one that brings it nearer the edge.
1054
+ */
1055
+ export function clipDirection(line, room, figures = "proportional") {
1056
+ const chars = Array.from(line.normalize("NFC"));
1057
+ const first = chars.findIndex((char) => !/[\p{Cf}\p{Mn}\p{Me}\s]/u.test(char));
1058
+ const own = readsRightToLeft(line) ? "rtl" : "ltr";
1059
+ if (first < 0)
1060
+ return own;
1061
+ const width = (char) => textWidth(char, figures);
1062
+ const reach = (rtl) => {
1063
+ const order = visualOrder(chars, rtl);
1064
+ const at = order.indexOf(first);
1065
+ const before = rtl ? order.slice(at + 1) : order.slice(0, at);
1066
+ return before.reduce((sum, index) => sum + width(chars[index]), 0) + width(chars[first]);
1067
+ };
1068
+ const other = own === "rtl" ? "ltr" : "rtl";
1069
+ const [ownReach, otherReach] = [reach(own === "rtl"), reach(other === "rtl")];
1070
+ if (ownReach <= room)
1071
+ return own;
1072
+ if (otherReach <= room)
1073
+ return other;
1074
+ return otherReach < ownReach ? other : own;
1075
+ }
1076
+ /** A line ending in "…", which after a right-to-left word takes a right-to-left mark (U+200F, no width), so it stays at that word's end. */
1077
+ function ended(line) {
1078
+ const lastLetter = Array.from(line).reverse().find((char) => LETTER.test(char));
1079
+ return `${line}…${lastLetter && RTL_LETTER.test(lastLetter) ? "‏" : ""}`;
1080
+ }
1081
+ /**
1082
+ * The most whole words of `words` from their start that fit the room on a line of `base` (none when `base` is ""),
1083
+ * with "…" after them when some are left out: the line, and whether any were. "…" is left out only where it alone
1084
+ * does not fit after `base`.
1085
+ */
1086
+ function wordsThatFit(base, words, room, figures) {
1087
+ const join = (count) => words.slice(0, count).reduce((line, { space, word }) => (line === "" ? word : line + space + word), base);
1088
+ const all = join(words.length);
1089
+ if (textWidth(all, figures) <= room)
1090
+ return { line: all, dropped: false };
1091
+ for (let count = words.length - 1; count >= 0; count -= 1) {
1092
+ const line = ended(join(count).trimEnd());
1093
+ if (textWidth(line, figures) <= room)
1094
+ return { line, dropped: true };
1095
+ }
1096
+ return { line: base, dropped: words.length > 0 };
1097
+ }
1098
+ /**
1099
+ * The last resort for a text that does not fit its room even with its figures short:
1100
+ * words that are not the figure's are dropped, whole, and "…" stands for them. A text's figure group is never dropped
1101
+ * or cut: from the first figure's sign and currency (or the currency or unit Intl writes before it, "TRY") to the
1102
+ * last figure, its magnitude and its own currency or unit after it ({@link groupEnd}: "€ 150 Tn", "150 Tn Türk
1103
+ * lirası", "1,5 ترليون TL", "‏١٥٠ ترليون ج.م.‏"), its units broken only as {@link textUnits} breaks them. After it,
1104
+ * qualifiers ("net", "this month") stand on its last line while they fit, and "…" after the last kept. A phrase before it
1105
+ * ("Total order revenue") stands on a line of its own above, as many of its words as fit and "…" after them, so
1106
+ * a text takes at most one more line than its figure group: "Total…" over "€ 145 Tn net…", and none more than
1107
+ * `maxLines` (a tick under the plot: its band's), the phrase before it then dropped. A text with no figure
1108
+ * keeps its first word as that group. What is kept and still does not fit (a formatter's long word against a
1109
+ * figure) is clipped by the tick or label, its reading start kept. `dropped` when words were.
1110
+ */
1111
+ function lastResort(shown, room, locale, figures, maxLines = Number.POSITIVE_INFINITY) {
1112
+ const { text } = shown;
1113
+ let start;
1114
+ let end;
1115
+ if (shown.figures) {
1116
+ const found = affixes(locale);
1117
+ start = groupStart(text, shown.figures.first, found.units).start;
1118
+ end = groupEnd(text, shown.figures.end, groupStart(text, shown.figures.last, found.units).unit, found);
1119
+ }
1120
+ else {
1121
+ start = SPACES_AHEAD.exec(text)?.[0].length ?? 0;
1122
+ end = start + (WORD_AHEAD.exec(text.slice(start))?.[0].length ?? 0);
1123
+ }
1124
+ // The group parts only between its figures, after a separator ("€ 900.000 / | € 1.450.000"), never from its own
1125
+ // magnitude, currency or unit ("1,45 Mn TL"); and, as any label, not at all when a part is wider than the room
1126
+ // (breaking it would only add lines that still overflow).
1127
+ const parts = [];
1128
+ for (const unit of textUnits(text.slice(start, end))) {
1129
+ const last = parts.at(-1);
1130
+ if (last && !(SEPARATED.test(last.unit) && DIGIT.test(unit.unit)))
1131
+ last.unit += unit.space + unit.unit;
1132
+ else
1133
+ parts.push({ ...unit });
1134
+ }
1135
+ const group = linesWithin(parts, room, figures, maxLines);
1136
+ const after = wordsThatFit(group.pop() ?? "", wordsOf(text.slice(end)), room, figures);
1137
+ const lines = [...group, after.line];
1138
+ const lead = wordsOf(text.slice(0, start));
1139
+ if (lead.length === 0)
1140
+ return { lines, dropped: after.dropped };
1141
+ const before = wordsThatFit("", lead, room, figures);
1142
+ // Above the figure's lines only where its band holds one more (a tick under the plot holds few).
1143
+ const above = textWidth(before.line, figures) <= room && lines.length < maxLines;
1144
+ return { lines: above ? [before.line, ...lines] : lines, dropped: after.dropped || before.dropped || !above };
1145
+ }
1146
+ /**
1147
+ * Units in lines of `room` ({@link unitLines}), or, where that takes more than `maxLines` lines, in the narrowest wider
1148
+ * room that takes no more (the x band guard). For a value tick under the plot, which nothing clips
1149
+ * sideways (Recharts spaces those ticks by the whole formatted tick on one line) but whose band below the plot holds
1150
+ * only so many lines (Recharts' 30px x axis: two 11px lines under its 8px inset); past them a line stood past the
1151
+ * svg's bottom, into the axis name or the legend under it. Its lines then grow wider, never taller: every line is still
1152
+ * part of the one-line text Recharts spaced the ticks by, so it never reaches a neighbor or the chart's edge, and no
1153
+ * word is dropped or written in scientific notation (never under the plot). Greedy breaking takes no more lines in
1154
+ * a wider room, so the room is found by halving.
1155
+ */
1156
+ function linesWithin(units, room, figures, maxLines) {
1157
+ const lines = unitLines(units, room, figures);
1158
+ if (lines.length <= maxLines)
1159
+ return lines;
1160
+ let low = room;
1161
+ let high = textWidth(joinUnits(units), figures);
1162
+ while (high - low > 1) {
1163
+ const middle = Math.floor((low + high) / 2);
1164
+ if (unitLines(units, middle, figures).length <= maxLines)
1165
+ high = middle;
1166
+ else
1167
+ low = middle;
1168
+ }
1169
+ return unitLines(units, high, figures);
1170
+ }
1171
+ /**
1172
+ * The one chain by which a value tick and a bar-end label are shortened, each step
1173
+ * only when the one before does not fit (`fit`: every line within its limit), the same on the server and in the
1174
+ * browser:
1175
+ * 1. whole, or broken between its units ({@link textLines});
1176
+ * 2. its figures short and exact ({@link axisFigures}): compact, in the fewest words its locale has; or, only where
1177
+ * a line would otherwise be clipped, in scientific notation: where
1178
+ * the text clips (`fit.clips`), its figure group, the least it keeps at the last (step 3), is still wider than its
1179
+ * limit compact, so compact it would be clipped even with its other words dropped for "…", and in scientific
1180
+ * notation it fits ("1,5E29 €", "€1.5E29" for ja's "€15,000,000,000,000京"; never where compact fits, as
1181
+ * "1500兆", nor where neither does, as scientific notation would then be clipped too). The trigger is the clip,
1182
+ * never the magnitude, so it is the same in every locale;
1183
+ * 3. the words that are not its figure's dropped and "…" for them ({@link lastResort}): never a word cut, never a
1184
+ * figure, its magnitude or its currency or unit.
1185
+ * What still does not fit is clipped by the tick or the label, its reading start in view. Where nothing but the
1186
+ * chart's own edge clips a text (a value tick under the plot: the tick moves in from the chart's edges, value-tick's
1187
+ * ValueTick), the chain stops at step 2's compact form, the readable one ("€ 1.5 ترليون", "12 млн km / h"), wider than
1188
+ * its room or not: never scientific notation, never "…", unless a line of the axis is wider than the whole chart
1189
+ * (`fit.edge`), which the svg's edge would cut: then the chain goes on for every tick of that axis, with the chart's
1190
+ * width as its limit.
1191
+ * `axis` is every text the same formatter wrote beside this one (a value axis's ticks): the step an axis takes, every
1192
+ * tick of it takes, so an axis never mixes "€ 9.000.000.000.000" with "€ 12 Tn", nor "€ 900 Tn" with "€ 1,5E29": when
1193
+ * one tick of an axis beside the plot would be clipped compact and is not in scientific notation, the whole axis is in
1194
+ * scientific notation, its other ticks too, which alone would not be clipped (one notation on an axis, so its ticks
1195
+ * read against one another). The figures of one magnitude share their fraction digits ("€ 1,50 Mn", "€ 2,25 Mn")
1196
+ * where those all fit, or each has only the digits it needs ("€ 1,5 Mn", "€ 2,25 Mn"). `values` are what proves how
1197
+ * the formatter writes its marks ({@link markRoles}). `shortened` when the lines are not the text as written, which
1198
+ * the tick or label then carries whole for assistive technology and as a hover title. The tooltip and the data table
1199
+ * always show the values whole.
1200
+ */
1201
+ function shortText(text, axis, fit) {
1202
+ const { room, limit, figures, locale } = fit;
1203
+ const fits = (lines) => lines.every((line) => textWidth(line, figures) <= limit);
1204
+ // In lines of the room, between its units: a tick's as written, so a tick takes at most one more line than its
1205
+ // figure group; a label's as shown, a compact magnitude a word of its own ("€ 1,45 млн | target").
1206
+ const lay = (shown) => linesWithin(fit.rebreak ? textUnits(shown.text) : shown.units, room, figures, fit.maxLines);
1207
+ // As written: whole where it fits, else broken between its units, in at most `maxLines` lines.
1208
+ const written = (each) => (textWidth(each, figures) <= room ? [each] : linesWithin(textUnits(each), room, figures, fit.maxLines));
1209
+ const texts = [text, ...axis];
1210
+ if (texts.every((each) => fits(written(each))))
1211
+ return { lines: written(text), shortened: false };
1212
+ const short = axisFigures(texts, locale, fit.values, figures);
1213
+ const write = (each, padded, scientific) => shownText(textUnits(each), (figure) => short(figure, padded, scientific));
1214
+ // What a text keeps at the last, its figure group, fits: whole, or with its other words dropped.
1215
+ const keeps = (shown) => fits(lay(shown)) || fits(lastResort(shown, limit, locale, figures, fit.maxLines).lines);
1216
+ // Scientific notation only where a text clips and it, and only it, keeps that text from being clipped: then for the
1217
+ // whole axis. Never where nothing clips.
1218
+ const scientific = fit.clips && texts.some((each) => !keeps(write(each, false, false)) && keeps(write(each, false, true)));
1219
+ const padded = !scientific && texts.every((each) => fits(lay(write(each, true, false))));
1220
+ // Under the plot only the chart's own edge cuts a tick (it is moved in from the edges, as a category tick is): a line
1221
+ // no wider than the chart stands compact; one wider would be cut there, so the chain goes on with the chart's width
1222
+ // as the limit the clip gives a tick beside the plot (scientific notation where that alone fits, else qualifiers
1223
+ // dropped for "…"). That is decided once for the axis, as every step is: when one tick's compact line
1224
+ // would pass the edge, every tick of the axis goes on, so an axis never mixes "€80.000.000.000.000.000 Tn" with
1225
+ // "€1,2E29".
1226
+ const edge = fit.edge;
1227
+ if (!fit.clips && edge !== undefined && texts.some((each) => lay(write(each, padded, false)).some((line) => textWidth(line, figures) > edge))) {
1228
+ return shortText(text, axis, { ...fit, clips: true, limit: edge });
1229
+ }
1230
+ const shown = write(text, padded, scientific);
1231
+ const lines = lay(shown);
1232
+ // Where nothing clips, compact is the last step: wider than its room or not, the text is read whole.
1233
+ if (fits(lines) || !fit.clips)
1234
+ return { lines, shortened: shown.text !== text };
1235
+ const resort = lastResort(shown, limit, locale, figures, fit.maxLines);
1236
+ return { lines: resort.lines, shortened: resort.dropped || shown.text !== text };
1237
+ }
1238
+ /**
1239
+ * @internal A value tick as its axis shows it in `room`: {@link shortText}'s chain, in tabular figures,
1240
+ * every tick of its axis (`axisTexts`, written by the same formatter from `values`) taking the same step. `clips` for
1241
+ * a tick beside the plot (a vertical axis), whose line still wider than the room is clipped by the tick within the
1242
+ * axis (value-tick's ValueTick); `false` for one under the plot (a horizontal axis), which nothing clips: it is at
1243
+ * most compact, never in scientific notation nor shortened with "…", and may stand wider than its room.
1244
+ * `maxLines`, the lines its band holds under the plot: a tick that would take more is laid out wider, in no more
1245
+ * ({@link linesWithin}). `edge`, the chart's width under the plot: the one bound a tick there has, as the svg's edge
1246
+ * cuts what passes it; only an axis with a line wider than the whole chart takes the chain's last steps there, every
1247
+ * tick of it.
1248
+ */
1249
+ export function tickText(text, room, locale, axisTexts = [], values, clips = true, maxLines = Number.POSITIVE_INFINITY, edge) {
1250
+ return shortText(text, axisTexts, { room, limit: room, figures: "tabular", locale, values, rebreak: false, clips, maxLines, edge });
1251
+ }
1252
+ /**
1253
+ * @internal A bar-end label as it stands at its bar's end: {@link shortText}'s chain,
1254
+ * the value ticks' own, in proportional figures. Its lines are laid out in `room` (to the chart's edge, or the plot's
1255
+ * start); a line may pass it up to `limit` (back over its own bar), and only what passes that is shortened. `values`
1256
+ * are the chart's labels by their text, each with the total it was formatted from: what proves how the formatter
1257
+ * writes its marks. A line still wider than `limit` is clipped by the label (core-charts' BarEndLabel).
1258
+ */
1259
+ export function labelText(text, room, limit, locale, values) {
1260
+ return shortText(text, [], { room, limit: Math.max(room, limit), figures: "proportional", locale, values, rebreak: true, clips: true, maxLines: Number.POSITIVE_INFINITY });
1261
+ }
1262
+ //# sourceMappingURL=axis-width.js.map