@mechane-ai/elements 0.46.0 → 0.47.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 (276) hide show
  1. package/README.md +306 -33
  2. package/dist/ai.js +4 -4
  3. package/dist/catalog.json +2382 -33
  4. package/dist/categorical-values-DdfGIowV.js +107 -0
  5. package/dist/cells--Bd1fQFR.js +384 -0
  6. package/dist/chart-link-AE_xuxiP.js +35 -0
  7. package/dist/chart-tones-ei3BC2AL.js +27 -0
  8. package/dist/charts/cartesian.js +1 -2958
  9. package/dist/charts/cells.js +1 -0
  10. package/dist/charts/comparison.js +1 -0
  11. package/dist/charts/distribution.js +1 -781
  12. package/dist/charts/figure.js +3404 -0
  13. package/dist/charts/graph.js +1 -655
  14. package/dist/charts/hierarchy.js +1 -121
  15. package/dist/charts/image.js +1 -0
  16. package/dist/charts/matrix.js +3 -644
  17. package/dist/charts/plot.js +15 -0
  18. package/dist/charts/relationship.js +1 -0
  19. package/dist/charts/text.js +1 -0
  20. package/dist/charts/timeline.js +1 -266
  21. package/dist/charts/transforms.js +677 -0
  22. package/dist/charts/trend.js +1 -0
  23. package/dist/charts.js +8 -3
  24. package/dist/collections.js +1 -2195
  25. package/dist/color-legend-CIo7DhXB.js +62 -0
  26. package/dist/dates-Cww8UR_n.js +810 -0
  27. package/dist/dumbbell-plot-B2ZTgQaI.js +508 -0
  28. package/dist/embedding-map-CGM_k6lC.js +1929 -0
  29. package/dist/feedback.js +1 -1
  30. package/dist/figure-format-B8kRZMlo.js +36 -0
  31. package/dist/figure-frame-wRkIEAwe.js +270 -0
  32. package/dist/forms/dates.js +1 -810
  33. package/dist/heatmap-scale-Zte6Ya-g.js +20 -0
  34. package/dist/image-grid-CVA4SOy_.js +598 -0
  35. package/dist/kits/evaluation.js +431 -0
  36. package/dist/kits/explainers.js +452 -0
  37. package/dist/kits/interpretability.js +1033 -0
  38. package/dist/kits/operations.js +239 -0
  39. package/dist/kits/training.js +335 -0
  40. package/dist/label-place-Z0fryBZb.js +42 -0
  41. package/dist/locate-Bcg3QcP4.js +11 -0
  42. package/dist/packages/charts/src/cartesian/bar-chart.d.ts +40 -21
  43. package/dist/packages/charts/src/cartesian/bar-data.d.ts +15 -4
  44. package/dist/packages/charts/src/cartesian/bar-overlays.d.ts +7 -3
  45. package/dist/packages/charts/src/cartesian/breakdown-bar.d.ts +10 -8
  46. package/dist/packages/charts/src/cartesian/bridge-chart.d.ts +20 -16
  47. package/dist/packages/charts/src/cartesian/bridge-data.d.ts +5 -4
  48. package/dist/packages/charts/src/cartesian/composition-bars.d.ts +8 -4
  49. package/dist/packages/charts/src/cartesian/index.d.ts +5 -5
  50. package/dist/packages/charts/src/cartesian/reference-lines.d.ts +25 -18
  51. package/dist/packages/charts/src/cartesian/scatter-plot.d.ts +30 -25
  52. package/dist/packages/charts/src/cartesian/sparkline.d.ts +14 -2
  53. package/dist/packages/charts/src/cartesian/time-series-bands.d.ts +3 -2
  54. package/dist/packages/charts/src/cartesian/time-series-data.d.ts +12 -2
  55. package/dist/packages/charts/src/cartesian/time-series-line.d.ts +2 -2
  56. package/dist/packages/charts/src/cartesian/time-series-overlays.d.ts +6 -4
  57. package/dist/packages/charts/src/cartesian/time-series.d.ts +60 -36
  58. package/dist/packages/charts/src/cartesian/value-labels.d.ts +22 -0
  59. package/dist/packages/charts/src/categorical-values.d.ts +1 -1
  60. package/dist/packages/charts/src/cells/bar-cell.d.ts +13 -0
  61. package/dist/packages/charts/src/cells/cell-layout.d.ts +81 -0
  62. package/dist/packages/charts/src/cells/change-cell.d.ts +17 -0
  63. package/dist/packages/charts/src/cells/heat-cell.d.ts +19 -0
  64. package/dist/packages/charts/src/cells/index.d.ts +11 -0
  65. package/dist/packages/charts/src/cells/interval-cell.d.ts +16 -0
  66. package/dist/packages/charts/src/cells/spark-cell.d.ts +22 -0
  67. package/dist/packages/charts/src/chart-frame.d.ts +14 -7
  68. package/dist/packages/charts/src/chart-grid.d.ts +19 -0
  69. package/dist/packages/charts/src/chart-input.d.ts +1 -9
  70. package/dist/packages/charts/src/chart-link.d.ts +56 -0
  71. package/dist/packages/charts/src/chart.d.ts +0 -8
  72. package/dist/packages/charts/src/comparison/bullet-bar.d.ts +34 -0
  73. package/dist/packages/charts/src/comparison/comparison-plot.d.ts +54 -0
  74. package/dist/packages/charts/src/comparison/dot-plot.d.ts +41 -0
  75. package/dist/packages/charts/src/comparison/dumbbell-plot.d.ts +33 -0
  76. package/dist/packages/charts/src/comparison/index.d.ts +6 -0
  77. package/dist/packages/charts/src/distribution/box-plot.d.ts +40 -0
  78. package/dist/packages/charts/src/distribution/distribution-input.d.ts +5 -3
  79. package/dist/packages/charts/src/distribution/distribution-plot.d.ts +28 -161
  80. package/dist/packages/charts/src/distribution/ecdf.d.ts +16 -15
  81. package/dist/packages/charts/src/distribution/group-plot-input.d.ts +35 -0
  82. package/dist/packages/charts/src/distribution/group-plot-layout.d.ts +79 -0
  83. package/dist/packages/charts/src/distribution/group-plot.d.ts +73 -0
  84. package/dist/packages/charts/src/distribution/histogram.d.ts +16 -16
  85. package/dist/packages/charts/src/distribution/index.d.ts +11 -0
  86. package/dist/packages/charts/src/distribution/interval-plot.d.ts +16 -13
  87. package/dist/packages/charts/src/distribution/ranked-bars.d.ts +17 -14
  88. package/dist/packages/charts/src/distribution/ridgeline.d.ts +34 -0
  89. package/dist/packages/charts/src/distribution/strip-plot.d.ts +37 -0
  90. package/dist/packages/charts/src/distribution/violin-plot.d.ts +34 -0
  91. package/dist/packages/charts/src/figure/figure-format.d.ts +34 -0
  92. package/dist/packages/charts/src/figure/figure-frame.d.ts +47 -0
  93. package/dist/packages/charts/src/figure/figure-props.d.ts +54 -0
  94. package/dist/packages/charts/src/figure/tone-scope.d.ts +32 -0
  95. package/dist/packages/charts/src/graph/attribution-graph.d.ts +62 -0
  96. package/dist/packages/charts/src/graph/attribution-layout.d.ts +88 -0
  97. package/dist/packages/charts/src/graph/flow-diagram.d.ts +14 -15
  98. package/dist/packages/charts/src/graph/flow-layout.d.ts +4 -2
  99. package/dist/packages/charts/src/graph/graph-canvas.d.ts +33 -0
  100. package/dist/packages/charts/src/graph/index.d.ts +6 -2
  101. package/dist/packages/charts/src/graph/relation-graph.d.ts +24 -13
  102. package/dist/packages/charts/src/graph/tree-diagram.d.ts +41 -0
  103. package/dist/packages/charts/src/graph/tree-layout.d.ts +71 -0
  104. package/dist/packages/charts/src/hierarchy/area-mark.d.ts +17 -0
  105. package/dist/packages/charts/src/hierarchy/icicle.d.ts +35 -0
  106. package/dist/packages/charts/src/hierarchy/index.d.ts +2 -0
  107. package/dist/packages/charts/src/hierarchy/partition-layout.d.ts +25 -0
  108. package/dist/packages/charts/src/hierarchy/treemap-layout.d.ts +26 -0
  109. package/dist/packages/charts/src/hierarchy/treemap.d.ts +11 -9
  110. package/dist/packages/charts/src/image/attribution-legend.d.ts +13 -0
  111. package/dist/packages/charts/src/image/attribution-overlay.d.ts +50 -0
  112. package/dist/packages/charts/src/image/attribution-ramp.d.ts +16 -0
  113. package/dist/packages/charts/src/image/image-atlas.d.ts +37 -0
  114. package/dist/packages/charts/src/image/image-fill.d.ts +9 -0
  115. package/dist/packages/charts/src/image/image-grid.d.ts +26 -0
  116. package/dist/packages/charts/src/image/image-input.d.ts +27 -0
  117. package/dist/packages/charts/src/image/image-tile.d.ts +27 -0
  118. package/dist/packages/charts/src/image/index.d.ts +7 -0
  119. package/dist/packages/charts/src/index.d.ts +15 -1
  120. package/dist/packages/charts/src/matrix/attention-matrix.d.ts +41 -0
  121. package/dist/packages/charts/src/matrix/calendar-heatmap.d.ts +37 -0
  122. package/dist/packages/charts/src/matrix/color-legend.d.ts +9 -2
  123. package/dist/packages/charts/src/matrix/confusion-matrix.d.ts +36 -0
  124. package/dist/packages/charts/src/matrix/correlation-matrix.d.ts +34 -0
  125. package/dist/packages/charts/src/matrix/heatmap-scale.d.ts +8 -2
  126. package/dist/packages/charts/src/matrix/index.d.ts +14 -3
  127. package/dist/packages/charts/src/matrix/matrix-cells.d.ts +27 -3
  128. package/dist/packages/charts/src/matrix/matrix-figure.d.ts +50 -0
  129. package/dist/packages/charts/src/matrix/matrix-mark.d.ts +34 -0
  130. package/dist/packages/charts/src/matrix/matrix-presets.d.ts +20 -0
  131. package/dist/packages/charts/src/matrix/matrix-range.d.ts +45 -0
  132. package/dist/packages/charts/src/matrix/matrix-strip.d.ts +13 -14
  133. package/dist/packages/charts/src/matrix/matrix-types.d.ts +40 -0
  134. package/dist/packages/charts/src/matrix/matrix.d.ts +13 -11
  135. package/dist/packages/charts/src/matrix/token-heatmap.d.ts +16 -10
  136. package/dist/packages/charts/src/plot/contours.d.ts +45 -0
  137. package/dist/packages/charts/src/plot/index.d.ts +49 -0
  138. package/dist/packages/charts/src/plot/label-place.d.ts +35 -0
  139. package/dist/packages/charts/src/plot/locate.d.ts +18 -0
  140. package/dist/packages/charts/src/plot/path.d.ts +39 -0
  141. package/dist/packages/charts/src/plot/plot-axes.d.ts +20 -0
  142. package/dist/packages/charts/src/plot/plot-layout.d.ts +221 -0
  143. package/dist/packages/charts/src/plot/plot-marks.d.ts +124 -0
  144. package/dist/packages/charts/src/plot/plot-surface.d.ts +32 -0
  145. package/dist/packages/charts/src/plot/render/density-layer.d.ts +17 -0
  146. package/dist/packages/charts/src/plot/render/hit-index.d.ts +37 -0
  147. package/dist/packages/charts/src/plot/render/plot-viewport.d.ts +39 -0
  148. package/dist/packages/charts/src/plot/render/point-layer.d.ts +41 -0
  149. package/dist/packages/charts/src/plot/render/theme-colors.d.ts +15 -0
  150. package/dist/packages/charts/src/plot/scale.d.ts +48 -0
  151. package/dist/packages/charts/src/plot/ticks.d.ts +34 -0
  152. package/dist/packages/charts/src/plot-width.d.ts +3 -2
  153. package/dist/packages/charts/src/relationship/contour-plot.d.ts +61 -0
  154. package/dist/packages/charts/src/relationship/density-map.d.ts +45 -0
  155. package/dist/packages/charts/src/relationship/embedding-map.d.ts +75 -0
  156. package/dist/packages/charts/src/relationship/index.d.ts +11 -0
  157. package/dist/packages/charts/src/relationship/level-legend.d.ts +11 -0
  158. package/dist/packages/charts/src/relationship/measures.d.ts +85 -0
  159. package/dist/packages/charts/src/relationship/parallel-coordinates.d.ts +30 -0
  160. package/dist/packages/charts/src/relationship/range-controls.d.ts +20 -0
  161. package/dist/packages/charts/src/relationship/scatter-matrix.d.ts +20 -0
  162. package/dist/packages/charts/src/spec/chart-guide.d.ts +21 -0
  163. package/dist/packages/charts/src/spec/figure-registry.d.ts +44 -0
  164. package/dist/packages/charts/src/spec/figure-spec.d.ts +147 -0
  165. package/dist/packages/charts/src/spec/figure-text.d.ts +8 -0
  166. package/dist/packages/charts/src/spec/figure.d.ts +12 -0
  167. package/dist/packages/charts/src/spec/guide-data.d.ts +85 -0
  168. package/dist/packages/charts/src/spec/index.d.ts +10 -0
  169. package/dist/packages/charts/src/spec/validate-figure.d.ts +15 -0
  170. package/dist/packages/charts/src/text/index.d.ts +11 -0
  171. package/dist/packages/charts/src/text/token-examples.d.ts +42 -0
  172. package/dist/packages/charts/src/text/token-grid.d.ts +47 -0
  173. package/dist/packages/charts/src/text/token-links.d.ts +49 -0
  174. package/dist/packages/charts/src/text/token-predictions.d.ts +38 -0
  175. package/dist/packages/charts/src/text/token-scale.d.ts +20 -0
  176. package/dist/packages/charts/src/text/token-text.d.ts +39 -0
  177. package/dist/packages/charts/src/timeline/event-strip.d.ts +70 -0
  178. package/dist/packages/charts/src/timeline/index.d.ts +3 -1
  179. package/dist/packages/charts/src/timeline/waterfall.d.ts +24 -13
  180. package/dist/packages/charts/src/transforms/bins.d.ts +91 -0
  181. package/dist/packages/charts/src/transforms/density.d.ts +53 -0
  182. package/dist/packages/charts/src/transforms/fits.d.ts +50 -0
  183. package/dist/packages/charts/src/transforms/index.d.ts +19 -0
  184. package/dist/packages/charts/src/transforms/matrices.d.ts +49 -0
  185. package/dist/packages/charts/src/transforms/quantiles.d.ts +96 -0
  186. package/dist/packages/charts/src/transforms/ranks.d.ts +44 -0
  187. package/dist/packages/charts/src/transforms/runs.d.ts +47 -0
  188. package/dist/packages/charts/src/transforms/sampling.d.ts +75 -0
  189. package/dist/packages/charts/src/transforms/smoothing.d.ts +41 -0
  190. package/dist/packages/charts/src/transforms/values.d.ts +70 -0
  191. package/dist/packages/charts/src/trend/bump-chart.d.ts +33 -0
  192. package/dist/packages/charts/src/trend/column-figure.d.ts +38 -0
  193. package/dist/packages/charts/src/trend/column-positions.d.ts +21 -0
  194. package/dist/packages/charts/src/trend/curve-chart.d.ts +69 -0
  195. package/dist/packages/charts/src/trend/end-labels.d.ts +40 -0
  196. package/dist/packages/charts/src/trend/horizon-chart.d.ts +37 -0
  197. package/dist/packages/charts/src/trend/index.d.ts +10 -0
  198. package/dist/packages/charts/src/trend/line-locate.d.ts +21 -0
  199. package/dist/packages/charts/src/trend/runs-chart.d.ts +50 -0
  200. package/dist/packages/charts/src/trend/slope-chart.d.ts +35 -0
  201. package/dist/packages/kits/src/evaluation/evaluation-data.d.ts +31 -0
  202. package/dist/packages/kits/src/evaluation/index.d.ts +8 -0
  203. package/dist/packages/kits/src/evaluation/leaderboard-cells.d.ts +62 -0
  204. package/dist/packages/kits/src/evaluation/leaderboard.d.ts +59 -0
  205. package/dist/packages/kits/src/evaluation/model-comparison.d.ts +59 -0
  206. package/dist/packages/kits/src/evaluation/score-breakdown.d.ts +33 -0
  207. package/dist/packages/kits/src/explainers/bound-value.d.ts +29 -0
  208. package/dist/packages/kits/src/explainers/figures.d.ts +31 -0
  209. package/dist/packages/kits/src/explainers/index.d.ts +8 -0
  210. package/dist/packages/kits/src/explainers/linked-target.d.ts +22 -0
  211. package/dist/packages/kits/src/explainers/story-steps.d.ts +46 -0
  212. package/dist/packages/kits/src/explainers/term.d.ts +29 -0
  213. package/dist/packages/kits/src/interpretability/attention-head-grid.d.ts +56 -0
  214. package/dist/packages/kits/src/interpretability/attribution-workbench.d.ts +29 -0
  215. package/dist/packages/kits/src/interpretability/embedding-atlas.d.ts +41 -0
  216. package/dist/packages/kits/src/interpretability/feature-card.d.ts +33 -0
  217. package/dist/packages/kits/src/interpretability/feature-list.d.ts +51 -0
  218. package/dist/packages/kits/src/interpretability/feature-logits.d.ts +23 -0
  219. package/dist/packages/kits/src/interpretability/features.d.ts +70 -0
  220. package/dist/packages/kits/src/interpretability/index.d.ts +16 -0
  221. package/dist/packages/kits/src/interpretability/kit-styles.d.ts +118 -0
  222. package/dist/packages/kits/src/interpretability/logit-lens.d.ts +50 -0
  223. package/dist/packages/kits/src/interpretability/node-panel.d.ts +32 -0
  224. package/dist/packages/kits/src/interpretability/shared-link.d.ts +8 -0
  225. package/dist/packages/kits/src/interpretability/steering-panel.d.ts +52 -0
  226. package/dist/packages/kits/src/operations/budget-board.d.ts +49 -0
  227. package/dist/packages/kits/src/operations/incident-timeline.d.ts +30 -0
  228. package/dist/packages/kits/src/operations/index.d.ts +6 -0
  229. package/dist/packages/kits/src/operations/service-health.d.ts +66 -0
  230. package/dist/packages/kits/src/training/index.d.ts +8 -0
  231. package/dist/packages/kits/src/training/run-dashboard.d.ts +49 -0
  232. package/dist/packages/kits/src/training/run-legend.d.ts +21 -0
  233. package/dist/packages/kits/src/training/run-marker.d.ts +5 -0
  234. package/dist/packages/kits/src/training/run-state.d.ts +7 -0
  235. package/dist/packages/kits/src/training/run-table.d.ts +63 -0
  236. package/dist/packages/kits/src/training/runs-overview.d.ts +20 -0
  237. package/dist/packages/kits/src/training/runs.d.ts +34 -0
  238. package/dist/path-BglsXpnO.js +59 -0
  239. package/dist/plot-axes-DJkLW4wk.js +100 -0
  240. package/dist/plot-layout-BEuoOHbs.js +911 -0
  241. package/dist/plot-marks-A64v7aTw.js +226 -0
  242. package/dist/plot-surface-CJTIqtck.js +51 -0
  243. package/dist/plot-width-DcqtSgzb.js +124 -0
  244. package/dist/point-layer-C-EYETAt.js +655 -0
  245. package/dist/reference-lines-CWA8VeUR.js +82 -0
  246. package/dist/scale-C2xgZyZN.js +63 -0
  247. package/dist/slope-chart-DT22h_ym.js +1279 -0
  248. package/dist/{src-DVHlknB6.js → src-CExIrXPC.js} +169 -193
  249. package/dist/src-D5NXRJZe.js +2195 -0
  250. package/dist/src-DIS0YOj0.js +44 -0
  251. package/dist/styles2.css +453 -62
  252. package/dist/time-series-IB3CB93O.js +2668 -0
  253. package/dist/token-heatmap-C00DnoNO.js +1354 -0
  254. package/dist/token-predictions-Cxx29iDr.js +1093 -0
  255. package/dist/tone-scope-DKiSw-JR.js +32 -0
  256. package/dist/tree-diagram-DsckNKaW.js +1629 -0
  257. package/dist/treemap-9_DpLCW9.js +472 -0
  258. package/dist/values-963L6n1m.js +65 -0
  259. package/dist/violin-plot-BhPHKXsN.js +1291 -0
  260. package/dist/waterfall-CGksuTy5.js +576 -0
  261. package/package.json +57 -4
  262. package/recipes/allocation-report.tsx +15 -7
  263. package/skills/extend-elements/SKILL.md +60 -0
  264. package/skills/review-elements/SKILL.md +43 -1
  265. package/skills/upgrade-elements/SKILL.md +3 -1
  266. package/skills/upgrade-elements/references/releases.md +184 -0
  267. package/skills/use-elements/SKILL.md +19 -13
  268. package/skills/use-elements/references/charts.md +362 -41
  269. package/skills/use-elements/references/figures.md +173 -0
  270. package/skills/use-elements/references/kits.md +198 -0
  271. package/dist/categorical-values-BXi-rJuv.js +0 -74
  272. package/dist/chart-data-CIJVWCYt.js +0 -21
  273. package/dist/chart-frame-BaxKn_MB.js +0 -236
  274. package/dist/chart-input-Bm82_9Rd.js +0 -22
  275. package/dist/chart-theme-4zprJ3rW.js +0 -404
  276. package/dist/plot-width-v2c_rA20.js +0 -63
@@ -0,0 +1,2668 @@
1
+ import { k as e } from "./src-CpdJlDhO.js";
2
+ import { g as t } from "./src-1EHkSFS-.js";
3
+ import { d as n, u as r } from "./src-CExIrXPC.js";
4
+ import { n as i, t as a } from "./chart-tones-ei3BC2AL.js";
5
+ import { A as o, O as s, S as c, T as l, a as u, b as d, c as f, i as p, k as m, m as h, n as g, o as _, p as v, w as ee } from "./plot-layout-BEuoOHbs.js";
6
+ import { i as y, n as b, r as x, t as S } from "./categorical-values-DdfGIowV.js";
7
+ import { a as C } from "./tone-scope-DKiSw-JR.js";
8
+ import { n as w, r as te, t as T } from "./figure-format-B8kRZMlo.js";
9
+ import { a as E, i as D, o as O, r as k, t as A } from "./scale-C2xgZyZN.js";
10
+ import { t as ne } from "./chart-cursor-1mFd48Jc.js";
11
+ import { c as re, i as ie, l as ae, n as j, o as M, r as oe, s as N, t as se } from "./figure-frame-wRkIEAwe.js";
12
+ import { n as P, t as F } from "./plot-width-DcqtSgzb.js";
13
+ import { t as ce } from "./plot-axes-DJkLW4wk.js";
14
+ import { a as I, c as L, d as R, f as le, i as z, l as ue, n as B, o as de, r as V, s as fe, t as pe } from "./plot-marks-A64v7aTw.js";
15
+ import { n as me, r as he, t as ge } from "./plot-surface-CJTIqtck.js";
16
+ import { n as _e, t as ve } from "./reference-lines-CWA8VeUR.js";
17
+ import { n as ye, r as be, t as xe } from "./path-BglsXpnO.js";
18
+ import { t as Se } from "./locate-Bcg3QcP4.js";
19
+ import * as H from "@stylexjs/stylex";
20
+ import { createParts as U } from "@ui-sdk/react/primitive";
21
+ import { useEffect as Ce, useId as W, useRef as we, useState as G } from "react";
22
+ import { bindDrag as K, createChange as q, createSpans as Te, definePrimitive as Ee, dispatch as De } from "@ui-sdk/core";
23
+ import { Fragment as Oe, jsx as J, jsxs as Y } from "react/jsx-runtime";
24
+ // packages/charts/src/cartesian/bar-data.ts
25
+ function ke({ composition: e, series: t, categoryIds: n, domain: r }) {
26
+ if (e === void 0) return;
27
+ if (e.buckets.length !== n.length) return "Composition requires one explicit bucket per category.";
28
+ let i = e.annotation;
29
+ if (i !== void 0) {
30
+ if (!n.includes(i.categoryId) || !Number.isFinite(i.value)) return "A bar annotation requires an existing category and a finite value.";
31
+ if (i.value < r[0] || i.value > r[1]) return "A bar annotation must fit the supplied domain.";
32
+ }
33
+ for (let [n, i] of e.buckets.entries()) if (i.kind !== "gap") {
34
+ if (!Number.isFinite(i.total) || i.total < r[0] || i.total > r[1]) return "Context totals must be finite and inside the supplied domain.";
35
+ if (i.kind === "parts") {
36
+ let e = t.map((e) => e.values[n]);
37
+ if (e.some((e) => e != null && e < 0)) return "Composition parts require nonnegative reported values.";
38
+ if (e.reduce((e, t) => e + (t ?? 0), 0) > r[1] || i.total < 0) return "Composition parts must fit the supplied positive domain.";
39
+ }
40
+ }
41
+ }
42
+ var X = 6;
43
+ function Z(e, t) {
44
+ return e === null ? !0 : e === void 0 || !Number.isFinite(e) ? !1 : e >= t[0] && e <= t[1];
45
+ }
46
+ function Q({ marker: e, categoryCount: t, domain: n }) {
47
+ let r = e.kind === "tick" ? [e.values] : [e.lower, e.upper];
48
+ if (r.some((e) => e.length !== t)) return "Every bar marker requires one explicit value per category.";
49
+ if (r.some((e) => e.some((e) => !Z(e, n)))) return "Bar marker values must be finite and within the supplied domain.";
50
+ if (e.kind === "range") for (let [t, n] of e.lower.entries()) {
51
+ let r = e.upper[t] ?? null;
52
+ if (n === null != (r === null) || n !== null && r !== null && n > r) return "A range marker needs both bounds, with the lower bound at most the upper bound, or neither.";
53
+ }
54
+ }
55
+ function Ae({ markers: e, annotations: t, emphasizedCategoryIds: n, seriesIds: r, categoryIds: i, domain: a }) {
56
+ if (e.length > X) return `Supply at most ${X} bar markers.`;
57
+ let o = [...e, ...t];
58
+ if (new Set(o.map((e) => e.id)).size !== o.length || r.some((e) => o.some((t) => t.id === e))) return "Bar series, markers, and annotations require distinct identifiers.";
59
+ for (let t of e) {
60
+ if (!r.includes(t.seriesId)) return "Each bar marker must refer to a supplied series.";
61
+ let e = Q({
62
+ marker: t,
63
+ categoryCount: i.length,
64
+ domain: a
65
+ });
66
+ if (e !== void 0) return e;
67
+ }
68
+ for (let e of t) {
69
+ let t = e.seriesId === void 0 || r.includes(e.seriesId), n = e.label.trim() !== "";
70
+ if (!(i.includes(e.categoryId) && t && n)) return "Each bar annotation needs a label, a supplied category, and a supplied series when it names one.";
71
+ }
72
+ if (new Set(t.map((e) => JSON.stringify([e.categoryId, e.seriesId ?? null]))).size !== t.length) return "Each bar can hold one annotation.";
73
+ if (new Set(n).size !== n.length || n.some((e) => !i.includes(e))) return "Emphasized categories must be unique supplied categories.";
74
+ }
75
+ function je({ marker: e, index: t, valueText: n }) {
76
+ if (e.kind === "tick") return n(e.values[t] ?? null);
77
+ let r = e.lower[t] ?? null, i = e.upper[t] ?? null;
78
+ return r === null || i === null ? n(null) : `${n(r)} – ${n(i)}`;
79
+ }
80
+ function Me(e, t) {
81
+ return e.kind === "tick" ? e.values[t] ?? null : e.upper[t] ?? null;
82
+ }
83
+ // packages/charts/src/cartesian/value-labels.ts
84
+ var Ne = 6.5, Pe = 14, Fe = 6, Ie = .5;
85
+ function Le(e, t) {
86
+ let n = (e.text.length + t.text.length) * Ne * Ie + Fe;
87
+ return Math.abs(e.x - t.x) < n && Math.abs(e.y - t.y) < Pe;
88
+ }
89
+ function Re(e) {
90
+ return e.filter((t, n) => e.slice(0, n).every((e) => !Le(t, e)));
91
+ }
92
+ function ze({ x: e, text: t, left: n, right: r }) {
93
+ let i = t.length * Ne * Ie;
94
+ return e - i < n ? {
95
+ x: n,
96
+ anchor: "start"
97
+ } : e + i > r ? {
98
+ x: r,
99
+ anchor: "end"
100
+ } : {
101
+ x: e,
102
+ anchor: "middle"
103
+ };
104
+ }
105
+ // packages/charts/src/cartesian/bar-overlays.tsx
106
+ var Be = 3, Ve = 14, He = .6, Ue = .5;
107
+ function We({ marker: e, index: t, span: n, base: r, y: i }) {
108
+ let a = n.x + n.width * Ue;
109
+ if (e.kind === "tick") {
110
+ let o = e.values[t] ?? null;
111
+ if (o === null) return [];
112
+ let s = {
113
+ key: "tick",
114
+ x1: n.x - Be,
115
+ x2: n.x + n.width + Be,
116
+ y1: i(o),
117
+ y2: i(o)
118
+ };
119
+ return r !== null && r !== o ? [{
120
+ key: "stem",
121
+ x1: a,
122
+ x2: a,
123
+ y1: i(r),
124
+ y2: i(o)
125
+ }, s] : [s];
126
+ }
127
+ let o = e.lower[t] ?? null, s = e.upper[t] ?? null;
128
+ if (o === null || s === null) return [];
129
+ let c = Math.min(Ve, n.width * He) * Ue;
130
+ return [
131
+ {
132
+ key: "whisker",
133
+ x1: a,
134
+ x2: a,
135
+ y1: i(o),
136
+ y2: i(s)
137
+ },
138
+ {
139
+ key: "upper",
140
+ x1: a - c,
141
+ x2: a + c,
142
+ y1: i(s),
143
+ y2: i(s)
144
+ },
145
+ {
146
+ key: "lower",
147
+ x1: a - c,
148
+ x2: a + c,
149
+ y1: i(o),
150
+ y2: i(o)
151
+ }
152
+ ];
153
+ }
154
+ function Ge({ markers: e, categoryIds: t, span: n, barTop: r, y: i, isReceded: a }) {
155
+ return /* @__PURE__ */ J("g", { children: e.map((e) => /* @__PURE__ */ J("g", { children: t.map((t, o) => {
156
+ let s = We({
157
+ marker: e,
158
+ index: o,
159
+ span: n(t, e.seriesId),
160
+ base: r(o, e.seriesId),
161
+ y: i
162
+ });
163
+ return /* @__PURE__ */ J("g", {
164
+ ...H.props(P.emphasis, a(t) && P.receded),
165
+ children: s.map(({ key: t, ...n }) => /* @__PURE__ */ J(fe, {
166
+ ...n,
167
+ tone: e.tone ?? "neutral"
168
+ }, t))
169
+ }, t);
170
+ }) }, e.id)) });
171
+ }
172
+ function Ke({ annotations: e, left: t, right: n }) {
173
+ return /* @__PURE__ */ J("g", {
174
+ "aria-hidden": !0,
175
+ children: Re(e).map((e) => {
176
+ let r = ze({
177
+ x: e.x,
178
+ text: e.text,
179
+ left: t,
180
+ right: n
181
+ });
182
+ return /* @__PURE__ */ J("g", {
183
+ ...H.props(P.emphasis, e.isReceded && P.receded),
184
+ children: /* @__PURE__ */ J(L, {
185
+ x: r.x,
186
+ y: e.y,
187
+ anchor: r.anchor,
188
+ children: e.text
189
+ })
190
+ }, e.id);
191
+ })
192
+ });
193
+ }
194
+ // packages/charts/src/cartesian/composition-bars.tsx
195
+ var qe = {
196
+ mark: {
197
+ k3nNDw: "x1hj3fc7",
198
+ k1ekBW: "xwcsmn1",
199
+ kIyJzY: "xtitasy x12w9bfk",
200
+ kAMwcw: "x1faw7qm",
201
+ $$css: !0
202
+ },
203
+ geometry: (e, t) => [{
204
+ k3aq6I: e == null ? e : "xsqj5wx",
205
+ kSiTet: t == null ? t : "xb4nw82",
206
+ $$css: !0
207
+ }, {
208
+ "--x-transform": e ?? void 0,
209
+ "--x-opacity": t ?? void 0
210
+ }]
211
+ }, Je = .18, Ye = .3;
212
+ function Xe({ bucket: e, series: t, focusedSeries: n, index: r, x: i, width: a, y: o, isSelected: s, isInspected: c, highlighted: l, toneOf: u }) {
213
+ let d = n !== void 0, f = n !== void 0 && !t.some((e) => e.id === n.id) ? [...t, n] : t;
214
+ function p(e, t) {
215
+ let n = o(t), r = o(t + e);
216
+ return `translateY(${Math.min(n, r)}px) scaleY(${Math.max(+(e === 0), Math.abs(r - n))})`;
217
+ }
218
+ let m = d ? Je : +(e.kind === "total");
219
+ return /* @__PURE__ */ Y(Oe, { children: [e.kind !== "gap" && /* @__PURE__ */ J("g", {
220
+ ...H.props(qe.mark, qe.geometry(p(e.total, 0), m)),
221
+ children: /* @__PURE__ */ J(V, {
222
+ x: i,
223
+ y: 0,
224
+ width: a,
225
+ height: 1,
226
+ tone: "neutral",
227
+ isSelected: s,
228
+ isInspected: c
229
+ })
230
+ }), f.map((o, f) => {
231
+ let m = o.values[r];
232
+ if (m == null) return null;
233
+ let h = d ? 0 : t.slice(0, f).reduce((e, t) => e + (t.values[r] ?? 0), 0), g = d ? n.id === o.id : e.kind === "parts", _ = l != null && l !== o.id, v = g ? !d && _ ? Ye : 1 : 0;
234
+ return /* @__PURE__ */ J("g", {
235
+ ...H.props(qe.mark, qe.geometry(p(m, h), v)),
236
+ children: /* @__PURE__ */ J(V, {
237
+ x: i,
238
+ y: 0,
239
+ width: a,
240
+ height: 1,
241
+ tone: u(o.id),
242
+ isSelected: s,
243
+ isInspected: c
244
+ })
245
+ }, o.id);
246
+ })] });
247
+ }
248
+ // packages/charts/src/cartesian/bar-chart.tsx
249
+ var Ze = { placeholder: {
250
+ kqGvvJ: "x1we84gm",
251
+ $$css: !0
252
+ } }, Qe = 18, $e = 8, et = 14, tt = .08, nt = 8, rt = 8, it = .5;
253
+ function at({ legend: e, layoutLegend: t, notes: n, children: r, inspectionId: i, label: a, summary: o, rows: s = [], x: c = 0, width: l = 0, offset: u, data: d, isLoading: f = !1, ...p }) {
254
+ let m = f && e.length === 0 && p.report?.seriesValues === void 0;
255
+ return /* @__PURE__ */ Y(j, {
256
+ ...p,
257
+ series: e,
258
+ seriesLegend: m ? /* @__PURE__ */ J(N, {}) : /* @__PURE__ */ J(M, {
259
+ id: i,
260
+ label: a,
261
+ summary: o,
262
+ legend: e,
263
+ hasSeriesSummary: p.report?.seriesValues !== void 0,
264
+ layoutLegend: t,
265
+ rows: s,
266
+ notes: n,
267
+ x: c,
268
+ width: l,
269
+ offset: u
270
+ }),
271
+ children: [d !== void 0 && /* @__PURE__ */ J(ae, { ...d }), r]
272
+ });
273
+ }
274
+ function ot() {
275
+ let e = C();
276
+ return (t) => t.map((t, n) => ({
277
+ id: t.id,
278
+ label: t.label,
279
+ tone: e({
280
+ id: t.id,
281
+ tone: t.tone,
282
+ index: n
283
+ })
284
+ }));
285
+ }
286
+ function st({ title: e = "Loading chart", series: t = [], height: n = "compact", ...i }) {
287
+ let a = W(), o = ot()(t);
288
+ return /* @__PURE__ */ J("div", {
289
+ "aria-hidden": !0,
290
+ inert: !0,
291
+ children: /* @__PURE__ */ J(at, {
292
+ ...i,
293
+ title: e,
294
+ status: "loading",
295
+ legend: o,
296
+ inspectionId: a,
297
+ isLoading: !0,
298
+ children: /* @__PURE__ */ J("div", {
299
+ ...H.props(P.plot, Ze.placeholder),
300
+ children: /* @__PURE__ */ J(r, { height: f[n] })
301
+ })
302
+ })
303
+ });
304
+ }
305
+ function ct(e, t) {
306
+ return Array.from({ length: t }, (t, n) => e.reduce((e, t) => e + Math.max(0, t.values[n] ?? 0), 0));
307
+ }
308
+ function lt({ categories: e, series: t, domain: n, mode: r }) {
309
+ if (e.length > x.items || t.length > x.series) return `Choose a window with at most ${x.items} categories and ${x.series} series.`;
310
+ if (O(n) !== void 0 || n[0] > 0 || n[1] < 0) return "The bar domain must be finite, increasing, and include zero.";
311
+ if (!o(e) || !o(t)) return "Bar categories and series require unique identifiers.";
312
+ for (let i of t) {
313
+ if (i.values.length !== e.length) return "Every series requires one explicit value per category.";
314
+ if (i.values.some((e) => e !== null && E(e, n))) return "Bar values must be finite and within the supplied domain.";
315
+ if (r === "stacked" && i.values.some((e) => e === null || e < 0)) return "Stacked bars require present nonnegative values.";
316
+ }
317
+ if (r === "stacked" && ct(t, e.length).some((e) => e > n[1])) return "Stacked bar totals must fit the supplied domain.";
318
+ }
319
+ function ut({ categories: e, series: t, mode: n, composition: r, referenceLines: i, markers: a }) {
320
+ let o = n === "stacked" || r !== void 0, s = t.flatMap((e) => e.values), c = o ? ct(t, e.length) : [], l = r?.focusedSeries?.values ?? [], u = r?.buckets.map((e) => e.kind === "gap" ? null : e.total) ?? [], d = a.flatMap((e) => e.kind === "tick" ? e.values : [...e.lower, ...e.upper]);
321
+ return [
322
+ ...s,
323
+ ...c,
324
+ ...l,
325
+ ...u,
326
+ ...d,
327
+ ...i.map((e) => e.value),
328
+ ...r?.annotation === void 0 ? [] : [r.annotation.value]
329
+ ];
330
+ }
331
+ function dt({ categories: e, series: t, domain: n, mode: r = "grouped", valueFormat: i, tickFormat: a, valueLabel: o, highlighted: s, selected: c, onSelectedChange: l, height: d = "compact", composition: f, referenceLines: h = [], markers: g = [], annotations: _ = [], emphasizedCategoryIds: v = [], ...y }) {
332
+ let { emptyLabel: b = "No categories", ...x } = y, { locale: S, title: w } = x, T = f?.focusedSeries, E = W(), D = W(), { ref: O, width: k, height: ie } = he(d), ae = C(), j = ot();
333
+ if (x.status === "loading") return /* @__PURE__ */ J(st, {
334
+ ...x,
335
+ series: t,
336
+ height: d
337
+ });
338
+ let M = n ?? u({
339
+ values: ut({
340
+ categories: e,
341
+ series: t,
342
+ mode: r,
343
+ composition: f,
344
+ referenceLines: h,
345
+ markers: g
346
+ }),
347
+ isZeroBased: !0
348
+ }), N = T === void 0 ? void 0 : lt({
349
+ categories: e,
350
+ series: [T],
351
+ domain: M,
352
+ mode: "grouped"
353
+ }), F = lt({
354
+ categories: e,
355
+ series: t,
356
+ domain: M,
357
+ mode: r
358
+ }) ?? N, I = e.map((e) => e.id), L = Ae({
359
+ markers: g,
360
+ annotations: _,
361
+ emphasizedCategoryIds: v,
362
+ seriesIds: [...t, ...T === void 0 ? [] : [T]].map((e) => e.id),
363
+ categoryIds: I,
364
+ domain: M
365
+ }) ?? _e({
366
+ lines: h,
367
+ domain: M
368
+ }), R = F ?? ke({
369
+ composition: f,
370
+ series: t,
371
+ categoryIds: I,
372
+ domain: M
373
+ }) ?? L;
374
+ if (R !== void 0) return /* @__PURE__ */ J(oe, {
375
+ ...x,
376
+ message: R
377
+ });
378
+ function z(e) {
379
+ return te({
380
+ value: e,
381
+ locale: S,
382
+ format: i
383
+ });
384
+ }
385
+ let ue = T !== void 0 && !t.some((e) => e.id === T.id), B = [...t, ...ue ? [T] : []], de = new Map(B.map((e, t) => [e.id, ae({
386
+ id: e.id,
387
+ tone: e.tone,
388
+ index: t
389
+ })]));
390
+ function fe(e) {
391
+ return de.get(e) ?? "neutral";
392
+ }
393
+ let pe = f === void 0 ? void 0 : {
394
+ id: E,
395
+ label: f.contextLabel,
396
+ tone: "neutral",
397
+ values: f.buckets.map((e) => e.kind === "gap" ? null : e.total)
398
+ }, ye = pe === void 0 ? t : [pe, ...B], be = (T !== void 0 && pe !== void 0 ? [T, pe] : t).map((e) => ({
399
+ id: e.id,
400
+ label: e.label,
401
+ tone: e.id === E ? "neutral" : fe(e.id)
402
+ })), xe = g.map((e) => ({
403
+ id: e.id,
404
+ label: e.label,
405
+ tone: e.tone ?? "neutral",
406
+ shape: e.kind
407
+ }));
408
+ function Se(n) {
409
+ let r = e[n], i = f?.buckets[n], a = T !== void 0 && pe !== void 0 ? [T, pe] : pe === void 0 || i?.kind === "parts" ? t : [], o = i === void 0 ? void 0 : i.kind === "gap" ? "No reported value" : z(i.total), s = a.map((e) => ({
410
+ id: e.id,
411
+ label: e.label,
412
+ tone: e.id === E ? "neutral" : fe(e.id),
413
+ value: z(e.values[n] ?? null)
414
+ })), c = g.map((e) => ({
415
+ id: e.id,
416
+ label: e.label,
417
+ tone: e.tone ?? "neutral",
418
+ shape: e.kind,
419
+ value: je({
420
+ marker: e,
421
+ index: n,
422
+ valueText: z
423
+ })
424
+ })), l = h.map((e) => ({
425
+ id: e.id,
426
+ label: e.label,
427
+ tone: e.tone ?? "neutral",
428
+ shape: "dashed",
429
+ value: z(e.value)
430
+ }));
431
+ return {
432
+ category: r,
433
+ label: r?.label,
434
+ summary: o,
435
+ rows: r === void 0 ? [] : [
436
+ ...s,
437
+ ...c,
438
+ ...l
439
+ ],
440
+ notes: _.filter((e) => e.categoryId === r?.id).map((e) => e.label)
441
+ };
442
+ }
443
+ let U = f?.annotation, Ce = _.length > 0 || U !== void 0, we = p({
444
+ width: k,
445
+ height: ie,
446
+ direction: "columns",
447
+ categories: e.map((e) => ({
448
+ id: e.id,
449
+ label: e.axisLabel ?? e.label
450
+ })),
451
+ value: {
452
+ label: o ?? "",
453
+ format: i,
454
+ tickFormat: a
455
+ },
456
+ valueDomain: M,
457
+ locale: S,
458
+ topInset: Ce ? Qe : 0,
459
+ hasValueTitle: o !== void 0
460
+ }), { box: G, band: K } = we, q = we.value.position, Te = A({
461
+ ids: t.map((e) => e.id),
462
+ range: [0, K.bandwidth],
463
+ padding: tt
464
+ }), Ee = r === "stacked" || f !== void 0;
465
+ function De(e) {
466
+ return K.start(e) ?? G.left;
467
+ }
468
+ function Oe(e) {
469
+ return De(e) + K.bandwidth * it;
470
+ }
471
+ function X(e, t) {
472
+ let n = De(e);
473
+ return Ee ? {
474
+ x: n,
475
+ width: K.bandwidth
476
+ } : {
477
+ x: n + (Te.start(t) ?? 0),
478
+ width: Te.bandwidth
479
+ };
480
+ }
481
+ function Z(e, n) {
482
+ if (!Ee) return t.find((e) => e.id === n)?.values[e] ?? null;
483
+ let r = t.flatMap((t) => [t.values[e] ?? null].filter((e) => e !== null));
484
+ return r.length === 0 ? null : r.reduce((e, t) => e + t, 0);
485
+ }
486
+ function Q(e, n) {
487
+ let r = (n === void 0 ? t : t.filter((e) => e.id === n)).flatMap((t) => [t.values[e] ?? null].filter((e) => e !== null)), i = Ee ? r.reduce((e, t) => e + Math.max(0, t), 0) : Math.max(0, ...r), a = f?.buckets[e], o = a === void 0 || a.kind === "gap" ? 0 : a.total, s = g.filter((e) => n === void 0 || e.seriesId === n).flatMap((t) => [Me(t, e)].filter((e) => e !== null));
488
+ return Math.max(0, i, o, ...s);
489
+ }
490
+ function Ne(e) {
491
+ return Math.max(et, q(e) - $e);
492
+ }
493
+ let Pe = {
494
+ label: `${w} observations`,
495
+ columns: [{
496
+ id: "category",
497
+ label: "Category"
498
+ }, {
499
+ id: "value",
500
+ label: "Value"
501
+ }],
502
+ rows: [...e.map((e, t) => ({
503
+ id: e.id,
504
+ values: [e.label, [
505
+ ...ye.map((e) => `${e.label}: ${z(e.values[t] ?? null)}`),
506
+ ...g.map((e) => `${e.label}: ${je({
507
+ marker: e,
508
+ index: t,
509
+ valueText: z
510
+ })}`),
511
+ ..._.filter((t) => t.categoryId === e.id).map((e) => e.label)
512
+ ].join(" · ")]
513
+ })), ...h.map((e) => ({
514
+ id: `reference:${e.id}`,
515
+ values: [e.label, z(e.value)]
516
+ }))]
517
+ };
518
+ return /* @__PURE__ */ J(ee, {
519
+ items: e,
520
+ readout: (e) => re(Se(I.indexOf(e))),
521
+ locate: (e) => K.idAt(e.x / e.width * G.width),
522
+ selected: c ?? null,
523
+ onSelect: l,
524
+ render: (n, { inspected: i, cursor: a }) => {
525
+ let u = Se(I.indexOf(i ?? ""));
526
+ function d(e) {
527
+ let t = v.includes(e);
528
+ return v.length > 0 && !t && i !== e;
529
+ }
530
+ let p = U === void 0 || !I.includes(U.categoryId) ? [] : [{
531
+ id: `composition:${U.categoryId}`,
532
+ text: U.label,
533
+ x: Oe(U.categoryId),
534
+ y: Ne(U.value),
535
+ isReceded: d(U.categoryId)
536
+ }], ee = _.map((e) => {
537
+ let t = e.seriesId === void 0 ? {
538
+ x: De(e.categoryId),
539
+ width: K.bandwidth
540
+ } : X(e.categoryId, e.seriesId);
541
+ return {
542
+ id: e.id,
543
+ text: e.label,
544
+ x: t.x + t.width * it,
545
+ y: Ne(Q(I.indexOf(e.categoryId), e.seriesId)),
546
+ isReceded: d(e.categoryId)
547
+ };
548
+ }), y = [...p, ...ee];
549
+ return /* @__PURE__ */ J(at, {
550
+ ...x,
551
+ figure: n,
552
+ legend: [...be, ...xe],
553
+ layoutLegend: [...j(t), ...xe],
554
+ notes: u.notes,
555
+ inspectionId: D,
556
+ label: u.label,
557
+ titleDetail: u.category === void 0 ? void 0 : [u.category.axisLabel ?? u.category.label, u.summary].filter(Boolean).join(" · "),
558
+ summary: u.summary,
559
+ rows: u.rows,
560
+ x: Oe(i ?? ""),
561
+ width: k,
562
+ offset: K.bandwidth * it + rt,
563
+ data: Pe,
564
+ children: e.length === 0 || t.length === 0 && f === void 0 ? /* @__PURE__ */ J(se, { children: b }) : /* @__PURE__ */ Y(me, {
565
+ plotRef: O,
566
+ box: G,
567
+ label: m({
568
+ title: w,
569
+ marks: "categories",
570
+ isSelectable: l !== void 0
571
+ }),
572
+ readoutId: D,
573
+ children: [
574
+ /* @__PURE__ */ J(ce, {
575
+ box: G,
576
+ xTicks: we.bandTicks,
577
+ yTicks: we.valueTicks,
578
+ yTitle: o
579
+ }),
580
+ /* @__PURE__ */ Y(ge, {
581
+ box: G,
582
+ children: [
583
+ e.map((e, n) => {
584
+ let a = f?.buckets[n], o = {
585
+ isSelected: c === e.id,
586
+ isInspected: i === e.id
587
+ };
588
+ return a === void 0 ? t.map((i, a) => {
589
+ let c = i.values[n];
590
+ if (c == null) return null;
591
+ let l = r === "stacked" ? t.slice(0, a).reduce((e, t) => e + (t.values[n] ?? 0), 0) : 0, u = q(l), f = q(l + c), p = s != null && s !== i.id, m = X(e.id, i.id);
592
+ return /* @__PURE__ */ J(V, {
593
+ ...o,
594
+ x: m.x,
595
+ y: Math.min(u, f),
596
+ width: m.width,
597
+ height: Math.max(+(c === 0), Math.abs(f - u)),
598
+ tone: fe(i.id),
599
+ emphasis: p || d(e.id) ? "receded" : "normal"
600
+ }, `${e.id}:${i.id}`);
601
+ }) : /* @__PURE__ */ J("g", {
602
+ ...H.props(P.emphasis, d(e.id) && P.receded),
603
+ children: /* @__PURE__ */ J(Xe, {
604
+ ...o,
605
+ bucket: a,
606
+ series: t,
607
+ focusedSeries: T,
608
+ index: n,
609
+ x: De(e.id),
610
+ width: K.bandwidth,
611
+ y: q,
612
+ highlighted: s,
613
+ toneOf: fe
614
+ })
615
+ }, e.id);
616
+ }),
617
+ /* @__PURE__ */ J(le, {
618
+ x1: G.left,
619
+ x2: G.right,
620
+ y1: q(0),
621
+ y2: q(0)
622
+ }),
623
+ /* @__PURE__ */ J(Ge, {
624
+ markers: g,
625
+ categoryIds: I,
626
+ span: X,
627
+ barTop: Z,
628
+ y: q,
629
+ isReceded: d
630
+ })
631
+ ]
632
+ }),
633
+ /* @__PURE__ */ J(ve, {
634
+ lines: h,
635
+ box: G,
636
+ position: q,
637
+ valueText: z,
638
+ avoid: Re(y)
639
+ }),
640
+ /* @__PURE__ */ J(Ke, {
641
+ annotations: y,
642
+ left: G.left,
643
+ right: G.right
644
+ }),
645
+ a !== null && /* @__PURE__ */ J(ne, {
646
+ x: Oe(a),
647
+ top: G.top,
648
+ bottom: G.bottom,
649
+ width: Math.max(nt, K.bandwidth)
650
+ })
651
+ ]
652
+ })
653
+ });
654
+ }
655
+ });
656
+ }
657
+ // packages/charts/src/cartesian/breakdown-bar.tsx
658
+ var ft = {
659
+ kzqmXN: "x5lhr3w",
660
+ kGVxlE: "x1iotiob",
661
+ kZKoxP: "x5yr21d",
662
+ $$css: !0
663
+ }, pt = { segment: (e, t, n) => [
664
+ ft,
665
+ {
666
+ kWkggS: t == null ? t : "xl8spv7",
667
+ $$css: !0
668
+ },
669
+ {
670
+ "--x-width": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(`${e}%`),
671
+ "--x-backgroundColor": t ?? void 0,
672
+ "--x-boxShadow": `inset 0 0 0 1px ${n}` == null ? void 0 : `inset 0 0 0 1px ${n}`
673
+ }
674
+ ] }, mt = 100;
675
+ function ht({ items: e, total: t, valueFormat: n, selected: r, onSelectedChange: o, ...s }) {
676
+ let { emptyLabel: c = "No values", ...l } = s, { locale: u, title: d } = l, f = C();
677
+ if (l.status === "loading") return /* @__PURE__ */ J(ie, {
678
+ ...l,
679
+ height: "compact"
680
+ });
681
+ let p = y(e), m = e.reduce((e, t) => e + (t.value ?? 0), 0), h = 2 ** -52 * Math.max(m, t, 1) * e.length;
682
+ if (p !== void 0) return /* @__PURE__ */ J(oe, {
683
+ ...l,
684
+ message: p
685
+ });
686
+ if (!Number.isFinite(t) || t < 0 || m - t > h) return /* @__PURE__ */ J(oe, {
687
+ ...l,
688
+ message: "The total must be finite and at least the sum of recorded values."
689
+ });
690
+ function g(e) {
691
+ return te({
692
+ value: e,
693
+ locale: u,
694
+ format: n
695
+ });
696
+ }
697
+ let _ = e.map((e, t) => ({
698
+ id: e.id,
699
+ label: e.label,
700
+ valueLabel: g(e.value),
701
+ tone: f({
702
+ id: e.id,
703
+ tone: e.tone,
704
+ index: t
705
+ })
706
+ }));
707
+ return /* @__PURE__ */ J(ee, {
708
+ items: b(_),
709
+ arrows: "both",
710
+ selected: r ?? null,
711
+ onSelect: o,
712
+ render: (n, r) => /* @__PURE__ */ J(j, {
713
+ ...l,
714
+ figure: n,
715
+ children: e.length === 0 ? /* @__PURE__ */ J(se, { children: c }) : /* @__PURE__ */ Y(Oe, { children: [
716
+ /* @__PURE__ */ J("div", {
717
+ "aria-hidden": !0,
718
+ className: "x78zum5 x170jfvy xb3r6kr x1r7kqkb xmkeg23 x1y0btm7 x1ey3b81 x1jfksii",
719
+ children: e.map((e, n) => {
720
+ let r = _[n]?.tone ?? "neutral";
721
+ return e.value === null ? null : /* @__PURE__ */ J("span", { ...H.props(pt.segment(t === 0 ? 0 : e.value / t * mt, a[r], i[r])) }, e.id);
722
+ })
723
+ }),
724
+ /* @__PURE__ */ J(S, {
725
+ title: d,
726
+ items: _,
727
+ view: o === void 0 ? void 0 : r
728
+ }),
729
+ t - m > h && /* @__PURE__ */ Y("p", {
730
+ className: "x153jb6y x1ghz6dp xy8obcc",
731
+ children: [
732
+ "Unassigned portion: ",
733
+ g(t - m),
734
+ " of ",
735
+ g(t)
736
+ ]
737
+ })
738
+ ] })
739
+ })
740
+ });
741
+ }
742
+ // packages/charts/src/cartesian/bridge-data.ts
743
+ function gt(e) {
744
+ return e.kind !== "change" || e.value === null ? "neutral" : e.value < 0 ? "negative" : "positive";
745
+ }
746
+ function _t(e) {
747
+ let t = e.map((e) => e.kind === "total" ? 0 : e.value);
748
+ return e[0]?.kind !== "start" || t.includes(null) ? null : t.reduce((e, t) => e + (t ?? 0), 0);
749
+ }
750
+ function vt({ step: e, before: t, after: n }) {
751
+ let r = e.tone ?? gt(e);
752
+ switch (e.kind) {
753
+ case "start": return {
754
+ step: e,
755
+ from: 0,
756
+ to: e.value,
757
+ tone: r
758
+ };
759
+ case "total": return {
760
+ step: e,
761
+ from: n === null ? null : 0,
762
+ to: n,
763
+ tone: r
764
+ };
765
+ case "change": return {
766
+ step: e,
767
+ from: t,
768
+ to: n,
769
+ tone: r
770
+ };
771
+ }
772
+ }
773
+ function yt(e) {
774
+ return e.map((t, n) => vt({
775
+ step: t,
776
+ before: _t(e.slice(0, n)),
777
+ after: _t(e.slice(0, n + 1))
778
+ }));
779
+ }
780
+ function bt(e) {
781
+ let t = e.flatMap((e) => [e.from, e.to].filter((e) => e !== null)), n = Math.min(0, ...t), r = Math.max(0, ...t);
782
+ return n === r ? [n, n + 1] : [n, r];
783
+ }
784
+ function xt({ steps: e, domain: t }) {
785
+ if (e.length > x.items) return `Choose a bridge with at most ${x.items} steps.`;
786
+ if (!o(e)) return "Bridge steps require unique identifiers.";
787
+ if (e.length > 0 && e[0]?.kind !== "start") return "A bridge begins with one start step.";
788
+ if (e.filter((e) => e.kind === "start").length > 1) return "A bridge has exactly one start step.";
789
+ if (e.some((e) => {
790
+ let t = e.kind === "total" ? null : e.value;
791
+ return t !== null && !Number.isFinite(t);
792
+ })) return "Bridge values must be finite numbers or explicit missing changes.";
793
+ let n = bt(yt(e));
794
+ if (t === void 0) return Number.isFinite(n[0]) && Number.isFinite(n[1]) ? void 0 : "Running totals must stay finite.";
795
+ let r = t[0] <= n[0] && t[1] >= n[1];
796
+ if (!D(t) || !r) return "The bridge domain must be finite, increasing, and contain zero and every running total.";
797
+ }
798
+ // packages/charts/src/cartesian/bridge-chart.tsx
799
+ var St = 12, Ct = 6, wt = 14, Tt = 12, Et = 8, Dt = 8, Ot = .5;
800
+ function kt(e) {
801
+ return typeof e == "function" ? (t) => t === 0 ? e(0) : `${t > 0 ? "+" : "−"}${e(Math.abs(t))}` : {
802
+ ...e,
803
+ signDisplay: "exceptZero"
804
+ };
805
+ }
806
+ function At({ level: e, valueText: t, changeText: n }) {
807
+ return e.step.kind === "change" && e.step.value !== null ? n(e.step.value) : e.to === null ? "—" : t(e.to);
808
+ }
809
+ function jt({ level: e, valueText: t, changeText: n }) {
810
+ return e.step.kind === "change" ? e.step.value === null ? T : n(e.step.value) : e.to === null ? T : t(e.to);
811
+ }
812
+ function Mt({ level: e, valueText: t }) {
813
+ return e.from === null || e.to === null ? T : `${t(e.from)} → ${t(e.to)}`;
814
+ }
815
+ function Nt(e, t, n) {
816
+ if (e.from === null || e.to === null) {
817
+ let r = Math.min(n - Tt, t(e.from ?? 0) - Tt * Ot);
818
+ return {
819
+ isKnown: !1,
820
+ top: r,
821
+ height: Tt,
822
+ labelY: r - Ct
823
+ };
824
+ }
825
+ let r = Math.max(e.from, e.to), i = Math.min(e.from, e.to), a = t(r), o = r <= 0 && i < 0;
826
+ return {
827
+ isKnown: !0,
828
+ top: a,
829
+ height: Math.max(1, t(i) - a),
830
+ labelY: o ? t(i) + wt : a - Ct
831
+ };
832
+ }
833
+ function Pt({ steps: e, valueFormat: t, changeFormat: n = kt(t), tickFormat: r, valueLabel: i, domain: a, referenceLines: o = [], selected: s, onSelectedChange: c, height: l = "regular", ...d }) {
834
+ let { emptyLabel: f = "No steps", ...h } = d, { locale: g, title: _ } = h, v = he(l), y = W();
835
+ if (h.status === "loading") return /* @__PURE__ */ J(ie, {
836
+ ...h,
837
+ height: l
838
+ });
839
+ let b = yt(e), x = bt(b), S = a ?? u({ values: [...x, ...o.map((e) => e.value)] }), C = xt({
840
+ steps: e,
841
+ domain: a
842
+ }) ?? _e({
843
+ lines: o,
844
+ domain: S
845
+ });
846
+ if (C !== void 0) return /* @__PURE__ */ J(oe, {
847
+ ...h,
848
+ message: C
849
+ });
850
+ function w(e) {
851
+ return (t) => te({
852
+ value: t,
853
+ locale: g,
854
+ format: e
855
+ });
856
+ }
857
+ let T = w(t), E = w(n), D = o.map((e) => ({
858
+ id: e.id,
859
+ label: e.label,
860
+ tone: e.tone ?? "neutral",
861
+ shape: "dashed",
862
+ value: T(e.value)
863
+ }));
864
+ function O(e) {
865
+ let t = b.find((t) => t.step.id === e);
866
+ if (t === void 0) return {
867
+ level: t,
868
+ label: void 0,
869
+ summary: void 0,
870
+ rows: []
871
+ };
872
+ let n = t.step.kind === "change" ? [{
873
+ id: "running",
874
+ label: "Running total",
875
+ tone: "neutral",
876
+ value: Mt({
877
+ level: t,
878
+ valueText: T
879
+ })
880
+ }] : [];
881
+ return {
882
+ level: t,
883
+ label: t.step.label,
884
+ summary: jt({
885
+ level: t,
886
+ valueText: T,
887
+ changeText: E
888
+ }),
889
+ rows: [...n, ...D]
890
+ };
891
+ }
892
+ let k = p({
893
+ width: v.width,
894
+ height: v.height,
895
+ direction: "columns",
896
+ categories: b.map((e) => ({
897
+ id: e.step.id,
898
+ label: e.step.axisLabel ?? e.step.label
899
+ })),
900
+ value: {
901
+ label: i ?? "",
902
+ format: t,
903
+ tickFormat: r
904
+ },
905
+ valueDomain: S,
906
+ locale: g,
907
+ topInset: St,
908
+ hasValueTitle: i !== void 0
909
+ }), { box: A, band: N } = k, P = k.value.position, F = b.map((e) => ({
910
+ id: e.step.id,
911
+ label: e.step.label
912
+ }));
913
+ function I(e) {
914
+ return N.start(e) ?? A.left;
915
+ }
916
+ function R(e) {
917
+ return I(e) + N.bandwidth * Ot;
918
+ }
919
+ let ue = Re([...b.filter((e) => e.step.kind !== "change"), ...b.filter((e) => e.step.kind === "change")].map((e) => ({
920
+ id: e.step.id,
921
+ isTotal: e.step.kind !== "change",
922
+ text: At({
923
+ level: e,
924
+ valueText: T,
925
+ changeText: E
926
+ }),
927
+ x: R(e.step.id),
928
+ y: Nt(e, P, A.bottom).labelY
929
+ })));
930
+ return /* @__PURE__ */ J(ee, {
931
+ items: F,
932
+ readout: (e) => re(O(e)),
933
+ locate: (e) => N.idAt(e.x / e.width * A.width),
934
+ selected: s ?? null,
935
+ onSelect: c,
936
+ render: (e, { inspected: t, cursor: n }) => {
937
+ let r = O(t);
938
+ return /* @__PURE__ */ Y(j, {
939
+ ...h,
940
+ figure: e,
941
+ titleDetail: r.level === void 0 ? void 0 : `${r.label} · ${r.summary}`,
942
+ children: [
943
+ /* @__PURE__ */ J(ae, {
944
+ label: `${_} steps`,
945
+ columns: [
946
+ {
947
+ id: "step",
948
+ label: "Step"
949
+ },
950
+ {
951
+ id: "value",
952
+ label: "Value"
953
+ },
954
+ {
955
+ id: "running",
956
+ label: "Running total"
957
+ }
958
+ ],
959
+ rows: [...b.map((e) => ({
960
+ id: e.step.id,
961
+ values: [
962
+ e.step.label,
963
+ jt({
964
+ level: e,
965
+ valueText: T,
966
+ changeText: E
967
+ }),
968
+ e.step.kind === "change" ? Mt({
969
+ level: e,
970
+ valueText: T
971
+ }) : jt({
972
+ level: e,
973
+ valueText: T,
974
+ changeText: E
975
+ })
976
+ ]
977
+ })), ...o.map((e) => ({
978
+ id: `reference:${e.id}`,
979
+ values: [
980
+ e.label,
981
+ T(e.value),
982
+ ""
983
+ ]
984
+ }))]
985
+ }),
986
+ /* @__PURE__ */ J(M, {
987
+ id: y,
988
+ label: r.label,
989
+ summary: r.summary,
990
+ legend: [],
991
+ hasLegend: !1,
992
+ rows: r.rows,
993
+ x: R(t ?? ""),
994
+ width: v.width,
995
+ offset: N.bandwidth * Ot + Dt
996
+ }),
997
+ b.length === 0 ? /* @__PURE__ */ J(se, { children: f }) : /* @__PURE__ */ Y(me, {
998
+ plotRef: v.ref,
999
+ box: A,
1000
+ label: m({
1001
+ title: _,
1002
+ marks: "steps",
1003
+ isSelectable: c !== void 0
1004
+ }),
1005
+ readoutId: y,
1006
+ children: [
1007
+ /* @__PURE__ */ J(ce, {
1008
+ box: A,
1009
+ xTicks: k.bandTicks,
1010
+ yTicks: k.valueTicks,
1011
+ yTitle: i
1012
+ }),
1013
+ /* @__PURE__ */ Y(ge, {
1014
+ box: A,
1015
+ children: [
1016
+ b.map((e, t) => {
1017
+ let n = b[t + 1];
1018
+ return n === void 0 || e.to === null || n.from === null ? null : /* @__PURE__ */ J(z, {
1019
+ x1: I(e.step.id) + N.bandwidth,
1020
+ x2: I(n.step.id),
1021
+ y1: P(e.to),
1022
+ y2: P(e.to)
1023
+ }, `connector:${e.step.id}`);
1024
+ }),
1025
+ b.map((e) => {
1026
+ let n = Nt(e, P, A.bottom);
1027
+ return /* @__PURE__ */ J(V, {
1028
+ x: I(e.step.id),
1029
+ y: n.top,
1030
+ width: N.bandwidth,
1031
+ height: n.height,
1032
+ tone: n.isKnown ? e.tone : "neutral",
1033
+ isHollow: !n.isKnown,
1034
+ isSelected: s === e.step.id,
1035
+ isInspected: t === e.step.id
1036
+ }, e.step.id);
1037
+ }),
1038
+ /* @__PURE__ */ J(le, {
1039
+ x1: A.left,
1040
+ x2: A.right,
1041
+ y1: P(0),
1042
+ y2: P(0)
1043
+ })
1044
+ ]
1045
+ }),
1046
+ /* @__PURE__ */ J(ve, {
1047
+ lines: o,
1048
+ box: A,
1049
+ position: P,
1050
+ valueText: T,
1051
+ avoid: ue,
1052
+ marks: b.map((e) => {
1053
+ let t = Nt(e, P, A.bottom);
1054
+ return {
1055
+ left: I(e.step.id),
1056
+ right: I(e.step.id) + N.bandwidth,
1057
+ top: t.top,
1058
+ bottom: t.top + t.height
1059
+ };
1060
+ })
1061
+ }),
1062
+ /* @__PURE__ */ J("g", {
1063
+ "aria-hidden": !0,
1064
+ children: ue.map((e) => /* @__PURE__ */ J(L, {
1065
+ x: e.x,
1066
+ y: e.y,
1067
+ anchor: "middle",
1068
+ isStrong: e.isTotal,
1069
+ children: e.text
1070
+ }, e.id))
1071
+ }),
1072
+ n !== null && /* @__PURE__ */ J(ne, {
1073
+ x: R(n),
1074
+ top: A.top,
1075
+ bottom: A.bottom,
1076
+ width: Math.max(Et, N.bandwidth)
1077
+ })
1078
+ ]
1079
+ })
1080
+ ]
1081
+ });
1082
+ }
1083
+ });
1084
+ }
1085
+ // packages/charts/src/cartesian/scatter-plot.tsx
1086
+ var Ft = { points: 1e3 }, It = {
1087
+ target: {
1088
+ kVAEAm: "x10l6tqk",
1089
+ k1xSpc: "xrvj5dj",
1090
+ kgQiWS: "x1ku5rj1",
1091
+ kzqmXN: "x187nhsf",
1092
+ kZKoxP: "xn3w4p2",
1093
+ k3aq6I: "x11lhmoz",
1094
+ kMzoRj: "xc342km",
1095
+ kmVPX3: "x1717udv",
1096
+ kWkggS: "xjbqb8w",
1097
+ kkrTdU: "x1ypdohk",
1098
+ kfzvcC: "x67bb7w",
1099
+ k3XXqK: "x1t137rt",
1100
+ kPJHz1: "x13qnu6",
1101
+ kZs9gx: "x19rmrnh",
1102
+ k7shQP: "x9v5kkp",
1103
+ kiEn40: "x175ew0f",
1104
+ kmCx7Z: "xwycy1x",
1105
+ kJrEVn: "x15ajoc",
1106
+ kLz2MD: "x13ljvab",
1107
+ k1CtGv: "xzgvv12",
1108
+ $$css: !0
1109
+ },
1110
+ location: (e, t) => [{
1111
+ kbCHJM: e == null ? e : "xgq9j65",
1112
+ k87sOh: t == null ? t : "xjbys53",
1113
+ $$css: !0
1114
+ }, {
1115
+ "--x-left": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(e),
1116
+ "--x-top": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(t)
1117
+ }],
1118
+ ring: {
1119
+ kzqmXN: "xsmyaan",
1120
+ kZKoxP: "x1kpxq89",
1121
+ kaIpWk: "x16rqkct",
1122
+ $$css: !0
1123
+ }
1124
+ };
1125
+ function Lt(e, t) {
1126
+ return !e.every(Number.isFinite) || e[0] > e[1] ? !1 : e[0] >= t[0] && e[1] <= t[1];
1127
+ }
1128
+ function Rt(e, t) {
1129
+ return Number.isFinite(e) && e > 0 && e <= t[1] - t[0];
1130
+ }
1131
+ function zt({ points: e, x: t, y: n, xDomain: r, yDomain: i, range: a, onRangeChange: s, rangeStep: c }) {
1132
+ let l = O(r, t.scale) ?? O(i, n.scale);
1133
+ if (l !== void 0) return l;
1134
+ if (e.length > Ft.points) return `This plot exceeds the ${Ft.points}-point render limit. Supply a smaller, labelled sample.`;
1135
+ if (!o(e)) return "Scatter points must have unique identifiers.";
1136
+ if (e.some((e) => !Number.isFinite(e.x) || !Number.isFinite(e.y))) return "Scatter coordinates must be finite.";
1137
+ if (e.some((e) => E(e.x, r) || E(e.y, i))) return "Scatter coordinates fall outside the declared domain. Widen the domain or supply a labelled window of points.";
1138
+ if (s !== void 0) {
1139
+ if (c === void 0 || !Rt(c.x, r) || !Rt(c.y, i)) return "Range selection steps must be finite, positive, and no larger than their domain span.";
1140
+ if (a != null && (!Lt(a.x, r) || !Lt(a.y, i))) return "The selected range must have finite, ordered bounds inside the declared domain.";
1141
+ }
1142
+ }
1143
+ function Bt(e, t) {
1144
+ return [Math.min(e, t), Math.max(e, t)];
1145
+ }
1146
+ function Vt(e) {
1147
+ let { points: t, x: n, y: r, range: i, onRangeChange: a, rangeStep: o, selected: d, onSelectedChange: f, height: p = "regular", ...h } = e, { emptyLabel: v = "No points were supplied.", ...y } = h, { locale: b, title: x } = y, S = W(), w = he(p), T = C(), [E, D] = G(null), O = we(null);
1148
+ if (Ce(() => () => O.current?.(), []), y.status === "loading") return /* @__PURE__ */ J(ie, {
1149
+ ...y,
1150
+ height: p
1151
+ });
1152
+ let k = n.domain ?? u({
1153
+ values: t.map((e) => e.x),
1154
+ scale: n.scale
1155
+ }), A = r.domain ?? u({
1156
+ values: t.map((e) => e.y),
1157
+ scale: r.scale
1158
+ }), ne = zt({
1159
+ points: t,
1160
+ x: n,
1161
+ y: r,
1162
+ xDomain: k,
1163
+ yDomain: A,
1164
+ range: i,
1165
+ onRangeChange: a,
1166
+ rangeStep: o
1167
+ }), re = i ?? null;
1168
+ if (ne !== void 0) return /* @__PURE__ */ J(oe, {
1169
+ ...y,
1170
+ message: ne
1171
+ });
1172
+ let M = _({
1173
+ width: w.width,
1174
+ height: w.height,
1175
+ x: n,
1176
+ y: r,
1177
+ xDomain: k,
1178
+ yDomain: A,
1179
+ locale: b
1180
+ }), { box: N } = M;
1181
+ function F(e) {
1182
+ return te({
1183
+ value: e,
1184
+ locale: b,
1185
+ format: n.format
1186
+ });
1187
+ }
1188
+ function L(e) {
1189
+ return te({
1190
+ value: e,
1191
+ locale: b,
1192
+ format: r.format
1193
+ });
1194
+ }
1195
+ let R = t.map((e) => ({
1196
+ id: e.id,
1197
+ label: `${e.label}, ${n.label}: ${F(e.x)}, ${r.label}: ${L(e.y)}`
1198
+ })), le = t.map((e, t) => ({
1199
+ ...e,
1200
+ tone: T({
1201
+ id: e.id,
1202
+ tone: e.tone,
1203
+ index: t
1204
+ }),
1205
+ left: M.x.position(e.x),
1206
+ top: M.y.position(e.y)
1207
+ })), z = new Map(le.map((e) => [e.id, {
1208
+ left: e.left,
1209
+ top: e.top,
1210
+ right: e.left,
1211
+ bottom: e.top
1212
+ }])), ue = E === null ? i : {
1213
+ x: Bt(E.start.x, E.end.x),
1214
+ y: Bt(E.start.y, E.end.y)
1215
+ };
1216
+ function B(e, t, n) {
1217
+ let r = e.getBoundingClientRect(), i = (t - r.left) / r.width * N.width, a = (n - r.top) / r.height * N.height;
1218
+ return {
1219
+ x: M.x.valueAt(Math.min(N.right, Math.max(N.left, i))),
1220
+ y: M.y.valueAt(Math.min(N.bottom, Math.max(N.top, a)))
1221
+ };
1222
+ }
1223
+ function de(t) {
1224
+ let n = t.button === 0 && t.pointerType !== "touch", r = t.currentTarget, i = r.parentElement, o = t.target instanceof Element && t.target.closest("[data-brush]") !== null, s = n && o;
1225
+ if (a === void 0 || O.current !== null || !s || i === null) return;
1226
+ let c = B(r, t.clientX, t.clientY);
1227
+ D({
1228
+ start: c,
1229
+ end: c
1230
+ }), O.current = K(i, t.nativeEvent, {
1231
+ cancelOnEscape: !0,
1232
+ onMove: ({ x: e, y: t }) => D({
1233
+ start: c,
1234
+ end: B(r, e, t)
1235
+ }),
1236
+ onEnd: (t, n) => {
1237
+ if (O.current = null, D(null), n) return;
1238
+ let i = B(r, t.clientX, t.clientY), a = {
1239
+ x: Bt(c.x, i.x),
1240
+ y: Bt(c.y, i.y)
1241
+ };
1242
+ De({ options: () => e }, "onRangeChange", a, {
1243
+ reason: "drag",
1244
+ event: t
1245
+ });
1246
+ }
1247
+ });
1248
+ }
1249
+ return /* @__PURE__ */ J(ee, {
1250
+ items: R,
1251
+ place: (e) => z.get(e),
1252
+ selected: d ?? null,
1253
+ onSelect: f,
1254
+ render: (e, { inspected: i, cursor: u }) => /* @__PURE__ */ Y(j, {
1255
+ ...y,
1256
+ figure: e,
1257
+ footer: /* @__PURE__ */ J(c, {
1258
+ id: S,
1259
+ children: s(R, i)
1260
+ }),
1261
+ children: [
1262
+ t.length === 0 ? /* @__PURE__ */ J(se, { children: v }) : /* @__PURE__ */ Y(me, {
1263
+ plotRef: w.ref,
1264
+ box: N,
1265
+ label: m({
1266
+ title: x,
1267
+ isSelectable: f !== void 0
1268
+ }),
1269
+ readoutId: S,
1270
+ onPointerDown: de,
1271
+ overlay: le.map((e, t) => /* @__PURE__ */ J(l, {
1272
+ value: e.id,
1273
+ render: /* @__PURE__ */ J("button", {
1274
+ type: "button",
1275
+ tabIndex: -1,
1276
+ title: e.label,
1277
+ "aria-label": R[t]?.label,
1278
+ "aria-pressed": f === void 0 ? void 0 : d === e.id
1279
+ }),
1280
+ ...H.props(It.target, It.location(e.left, e.top)),
1281
+ children: /* @__PURE__ */ J("span", {
1282
+ "aria-hidden": !0,
1283
+ ...H.props(It.ring, u === e.id && P.cursor)
1284
+ })
1285
+ }, e.id)),
1286
+ children: [
1287
+ /* @__PURE__ */ J(ce, {
1288
+ box: N,
1289
+ xTicks: M.xTicks,
1290
+ yTicks: M.yTicks,
1291
+ xTitle: g(n),
1292
+ yTitle: g(r),
1293
+ grid: "both"
1294
+ }),
1295
+ a !== void 0 && /* @__PURE__ */ J("rect", {
1296
+ "data-brush": "",
1297
+ x: N.left,
1298
+ y: N.top,
1299
+ width: N.innerWidth,
1300
+ height: N.innerHeight,
1301
+ className: "xsid9ct xy6m8k3"
1302
+ }),
1303
+ /* @__PURE__ */ Y(ge, {
1304
+ box: N,
1305
+ children: [ue != null && /* @__PURE__ */ J(Ht, {
1306
+ range: ue,
1307
+ plot: M
1308
+ }), le.map((e) => /* @__PURE__ */ J(I, {
1309
+ x: e.left,
1310
+ y: e.top,
1311
+ tone: e.tone,
1312
+ isInspected: i === e.id,
1313
+ isSelected: d === e.id
1314
+ }, e.id))]
1315
+ })
1316
+ ]
1317
+ }),
1318
+ a !== void 0 && o !== void 0 && /* @__PURE__ */ J(Wt, {
1319
+ x: n,
1320
+ y: r,
1321
+ xDomain: k,
1322
+ yDomain: A,
1323
+ range: re,
1324
+ rangeStep: o,
1325
+ locale: b,
1326
+ onRangeChange: a
1327
+ }),
1328
+ /* @__PURE__ */ J(ae, {
1329
+ label: `${x} points`,
1330
+ columns: [
1331
+ {
1332
+ id: "point",
1333
+ label: "Point"
1334
+ },
1335
+ {
1336
+ id: "x",
1337
+ label: n.label
1338
+ },
1339
+ {
1340
+ id: "y",
1341
+ label: r.label
1342
+ }
1343
+ ],
1344
+ rows: t.map((e) => ({
1345
+ id: e.id,
1346
+ values: [
1347
+ e.label,
1348
+ F(e.x),
1349
+ L(e.y)
1350
+ ]
1351
+ }))
1352
+ })
1353
+ ]
1354
+ })
1355
+ });
1356
+ }
1357
+ function Ht({ range: e, plot: t }) {
1358
+ let n = t.x.position(e.x[0]), r = t.y.position(e.y[1]);
1359
+ return /* @__PURE__ */ J("rect", {
1360
+ x: n,
1361
+ y: r,
1362
+ width: t.x.position(e.x[1]) - n,
1363
+ height: t.y.position(e.y[0]) - r,
1364
+ className: "x1e0kj8g xv7c1pl x1tg5nk6 xnpr05h x15lqr97 x47corl"
1365
+ });
1366
+ }
1367
+ function Ut({ axis: e, domain: n, value: r, step: i, locale: a, onChange: o }) {
1368
+ function s(t) {
1369
+ return te({
1370
+ value: t,
1371
+ locale: a,
1372
+ format: e.format
1373
+ });
1374
+ }
1375
+ return /* @__PURE__ */ Y(t.Root, {
1376
+ value: [...r],
1377
+ format: e.format,
1378
+ min: n[0],
1379
+ max: n[1],
1380
+ step: i,
1381
+ locale: a,
1382
+ onValueChange: (e, t) => o(e, t),
1383
+ children: [/* @__PURE__ */ Y("div", {
1384
+ className: "x78zum5 x1a02dak x1qughib x1hnptsi x153jb6y xy8obcc xj0a0fe",
1385
+ children: [/* @__PURE__ */ J(t.Label, { children: e.label }), /* @__PURE__ */ Y("span", { children: [
1386
+ s(r[0]),
1387
+ " – ",
1388
+ s(r[1])
1389
+ ] })]
1390
+ }), /* @__PURE__ */ J(t.Control, { children: /* @__PURE__ */ Y(t.Track, { children: [
1391
+ /* @__PURE__ */ J(t.Indicator, {}),
1392
+ /* @__PURE__ */ J(t.Thumb, {
1393
+ index: 0,
1394
+ "aria-label": `${e.label} minimum`
1395
+ }),
1396
+ /* @__PURE__ */ J(t.Thumb, {
1397
+ index: 1,
1398
+ "aria-label": `${e.label} maximum`
1399
+ })
1400
+ ] }) })]
1401
+ });
1402
+ }
1403
+ function Wt({ x: t, y: n, xDomain: r, yDomain: i, range: a, rangeStep: o, locale: s, onRangeChange: c }) {
1404
+ let l = a ?? {
1405
+ x: r,
1406
+ y: i
1407
+ };
1408
+ return /* @__PURE__ */ Y("fieldset", {
1409
+ className: "xrvj5dj x1n8ia3y x1xxf3xd xc342km x1717udv xeuugli",
1410
+ children: [
1411
+ /* @__PURE__ */ J("legend", {
1412
+ className: "x153jb6y xy8obcc x1jfksii",
1413
+ children: "Drag with a mouse, or adjust these bounds to select a coordinate range."
1414
+ }),
1415
+ /* @__PURE__ */ J(Ut, {
1416
+ axis: t,
1417
+ domain: r,
1418
+ value: l.x,
1419
+ step: o.x,
1420
+ locale: s,
1421
+ onChange: (e, t) => c({
1422
+ x: e,
1423
+ y: l.y
1424
+ }, t)
1425
+ }),
1426
+ /* @__PURE__ */ J(Ut, {
1427
+ axis: n,
1428
+ domain: i,
1429
+ value: l.y,
1430
+ step: o.y,
1431
+ locale: s,
1432
+ onChange: (e, t) => c({
1433
+ x: l.x,
1434
+ y: e
1435
+ }, t)
1436
+ }),
1437
+ /* @__PURE__ */ J(e, {
1438
+ type: "button",
1439
+ disabled: a === null,
1440
+ onClick: (e) => {
1441
+ De({ options: () => ({ onRangeChange: c }) }, "onRangeChange", null, {
1442
+ reason: "clear-press",
1443
+ event: e.nativeEvent
1444
+ });
1445
+ },
1446
+ children: "Clear range"
1447
+ })
1448
+ ]
1449
+ });
1450
+ }
1451
+ // packages/charts/src/cartesian/time-series-data.ts
1452
+ var $ = {
1453
+ series: 12,
1454
+ pointsPerSeries: 2e3,
1455
+ markers: 200,
1456
+ panels: 12
1457
+ }, Gt = .01;
1458
+ function Kt({ series: e, isStacked: t, markers: n, timeline: r = [] }) {
1459
+ let i = e[0]?.points.map((e) => e.timestamp) ?? r;
1460
+ if (e.length > $.series || i.length > $.pointsPerSeries || n.length > $.markers) return `Choose a window with at most ${$.series} series, ${$.pointsPerSeries} observations per series, and ${$.markers} markers.`;
1461
+ if (!o(e) || !o(n)) return "Series and markers require unique identifiers.";
1462
+ for (let n of e) {
1463
+ if (n.points.length !== i.length) return "Every series must supply the same observation timestamps.";
1464
+ let e = Zt({
1465
+ points: n.points,
1466
+ timestamps: i,
1467
+ isStacked: t
1468
+ });
1469
+ if (e !== void 0) return e;
1470
+ }
1471
+ for (let t of n) {
1472
+ let n = qt({
1473
+ marker: t,
1474
+ series: e,
1475
+ timestamps: i
1476
+ });
1477
+ if (n !== void 0) return n;
1478
+ }
1479
+ let a = e.flatMap((e) => e.points.flatMap((e) => e.value === null ? [] : [e.value])), s = Math.max(0, ...a) - Math.min(0, ...a), c = (i.at(-1) ?? 0) - (i[0] ?? 0);
1480
+ if (!Number.isFinite(s) || !Number.isFinite(c)) return "The elapsed-time and value ranges must be finite.";
1481
+ if (t && i.some((t, n) => !Number.isFinite(e.reduce((e, t) => e + (t.points[n]?.value ?? 0), 0)))) return "Stacked observation totals must be finite.";
1482
+ }
1483
+ function qt({ marker: e, series: t, timestamps: n }) {
1484
+ if (e.kind === "event") {
1485
+ let t = n[0] ?? 0, r = n.at(-1) ?? t, i = e.timestamp >= t && e.timestamp <= r;
1486
+ return Number.isFinite(e.timestamp) && i ? void 0 : "Every event marker must fall inside the observed time range.";
1487
+ }
1488
+ if (!n.includes(e.timestamp)) return "Every time and point marker must align with an observation timestamp.";
1489
+ if (e.kind !== "time") return t.find((t) => t.id === e.seriesId)?.points.find((t) => t.timestamp === e.timestamp)?.value === e.value ? void 0 : "Point markers must reference the recorded series value.";
1490
+ }
1491
+ function Jt({ series: e, markers: t, timestampUnit: n, isStacked: r }) {
1492
+ return JSON.stringify([
1493
+ n,
1494
+ r,
1495
+ e.map((e) => [
1496
+ e.id,
1497
+ e.label,
1498
+ e.tone,
1499
+ e.points.map((e) => [e.timestamp, e.value])
1500
+ ]),
1501
+ t.map((e) => [
1502
+ e.id,
1503
+ e.kind,
1504
+ e.timestamp,
1505
+ e.label,
1506
+ e.seriesId,
1507
+ e.value
1508
+ ])
1509
+ ]);
1510
+ }
1511
+ function Yt(e, t) {
1512
+ if (e !== t) return [e, t];
1513
+ let n = Math.max(1, Math.abs(e) * Gt), r = e - n, i = t + n;
1514
+ return [Number.isFinite(r) ? r : e, Number.isFinite(i) ? i : t];
1515
+ }
1516
+ function Xt({ series: e, isStacked: t, tones: n }) {
1517
+ let r = e.filter((e) => e.tone === void 0);
1518
+ return e.map((i, a) => {
1519
+ let o = r.findIndex((e) => e.id === i.id), s = n({
1520
+ id: i.id,
1521
+ tone: i.tone,
1522
+ index: o
1523
+ }), c = i.points.map((n, r) => {
1524
+ let i = t ? e.slice(0, a).reduce((e, t) => e + (t.points[r]?.value ?? 0), 0) : 0;
1525
+ return {
1526
+ ...n,
1527
+ base: i
1528
+ };
1529
+ });
1530
+ return {
1531
+ id: i.id,
1532
+ label: i.label,
1533
+ tone: s,
1534
+ points: c
1535
+ };
1536
+ });
1537
+ }
1538
+ function Zt({ points: e, timestamps: t, isStacked: n }) {
1539
+ for (let [r, i] of e.entries()) {
1540
+ let a = e[r - 1], o = a !== void 0 && i.timestamp <= a.timestamp;
1541
+ if (!Number.isFinite(i.timestamp) || i.timestamp !== t[r] || o) return "Observation timestamps must be finite, aligned, and strictly increasing.";
1542
+ if (i.value !== null && !Number.isFinite(i.value)) return "Observations must be finite numbers or explicit missing values.";
1543
+ if (n && (i.value === null || i.value < 0)) return "Stacked observations must be present and nonnegative.";
1544
+ }
1545
+ }
1546
+ // packages/charts/src/cartesian/time-series-line.tsx
1547
+ function Qt({ series: e, x: t, y: n, pointRadius: r = 3 }) {
1548
+ let i = e.points.findLastIndex((e) => e.value !== null);
1549
+ return /* @__PURE__ */ Y(Oe, { children: [/* @__PURE__ */ J("path", {
1550
+ d: be(e.points.map((e) => ({
1551
+ x: t(e.timestamp),
1552
+ y: e.value === null ? null : n(e.value + e.base)
1553
+ }))),
1554
+ fill: "none",
1555
+ stroke: a[e.tone],
1556
+ ...H.props(P.mark)
1557
+ }), e.points.filter((t, n) => {
1558
+ if (t.value === null) return !1;
1559
+ let r = e.points[n - 1]?.value === null || e.points[n + 1]?.value === null;
1560
+ return e.points.length === 1 || n === i || r;
1561
+ }).map((i) => /* @__PURE__ */ J("circle", {
1562
+ cx: t(i.timestamp),
1563
+ cy: n((i.value ?? 0) + i.base),
1564
+ r,
1565
+ fill: a[e.tone]
1566
+ }, i.timestamp))] });
1567
+ }
1568
+ // packages/charts/src/cartesian/sparkline.tsx
1569
+ var $t = {
1570
+ minimum: "Lowest",
1571
+ maximum: "Highest",
1572
+ last: "Latest"
1573
+ }, en = 2.5, tn = 3, nn = {
1574
+ inline: {
1575
+ width: 128,
1576
+ height: 32
1577
+ },
1578
+ figure: { height: 48 }
1579
+ };
1580
+ function rn({ points: e, marked: t }) {
1581
+ let n = e.flatMap((e) => e.value === null ? [] : [{
1582
+ ...e,
1583
+ value: e.value
1584
+ }]), r = n.map((e) => e.value), i = {
1585
+ minimum: n.find((e) => e.value === Math.min(...r)),
1586
+ maximum: n.find((e) => e.value === Math.max(...r)),
1587
+ last: n.at(-1)
1588
+ };
1589
+ return t.flatMap((e) => {
1590
+ let t = i[e];
1591
+ return t === void 0 ? [] : [{
1592
+ kind: e,
1593
+ point: t
1594
+ }];
1595
+ });
1596
+ }
1597
+ function an({ title: e, summary: t, unit: n, timestampUnit: r, series: i, valueDomain: o, markedPoints: s = [], baseline: c, layout: l = "inline" }) {
1598
+ let u = W(), f = F(), p = l === "figure", m = p ? f.width : nn.inline.width, h = p ? nn.figure.height : nn.inline.height, g = W(), _ = C(), v = on({
1599
+ title: e,
1600
+ summary: t,
1601
+ unit: n,
1602
+ series: i,
1603
+ valueDomain: o,
1604
+ markedPoints: s,
1605
+ baseline: c
1606
+ }), ee = i.points.some((e) => e.value !== null);
1607
+ if (v !== void 0 || !ee) return /* @__PURE__ */ J("span", {
1608
+ role: "img",
1609
+ "aria-label": `${e}. ${t} Values in ${n}; timestamps in ${r}. ${v ?? "No recorded values. Missing observations remain unavailable."}`,
1610
+ title: v ?? "No recorded values",
1611
+ className: "x2pejg6 x10w6t97 x2lah0s xxymvpz x3nfvp2 x6s0dn4 xl56j7k x153jb6y x1hz01jw xy8obcc",
1612
+ children: v === void 0 ? "No data" : "Invalid trend"
1613
+ });
1614
+ let y = i.points[0]?.timestamp ?? 0, b = i.points.at(-1)?.timestamp ?? y, x = k({
1615
+ domain: Yt(y, b),
1616
+ range: [tn, m - tn]
1617
+ }).position, S = k({
1618
+ domain: o,
1619
+ range: [h - tn, tn]
1620
+ }).position, w = Xt({
1621
+ series: [i],
1622
+ isStacked: !1,
1623
+ tones: _
1624
+ })[0], te = a[w?.tone ?? "series1"], T = rn({
1625
+ points: i.points,
1626
+ marked: s
1627
+ }), E = T.map(({ kind: e, point: t }) => `${$t[e]}: ${t.value} ${n}.`).join(" "), D = c === void 0 ? "" : `Reference: ${c} ${n}.`, O = /* @__PURE__ */ Y("svg", {
1628
+ role: "img",
1629
+ "aria-labelledby": u,
1630
+ "aria-describedby": g,
1631
+ focusable: "false",
1632
+ viewBox: `0 0 ${m} ${h}`,
1633
+ width: m,
1634
+ height: h,
1635
+ ...{
1636
+ 0: { className: "x1rg5ohu x2pejg6 x10w6t97 x2lah0s xxymvpz" },
1637
+ 1: { className: "x1lliihq xh8yej3 xt7dq6l" }
1638
+ }[!!p | 0],
1639
+ children: [
1640
+ /* @__PURE__ */ J("title", {
1641
+ id: u,
1642
+ children: e
1643
+ }),
1644
+ /* @__PURE__ */ Y("desc", {
1645
+ id: g,
1646
+ children: [
1647
+ t,
1648
+ " Values in ",
1649
+ n,
1650
+ "; timestamps in ",
1651
+ r,
1652
+ ". Displayed value domain: ",
1653
+ o[0],
1654
+ " to",
1655
+ " ",
1656
+ o[1],
1657
+ " ",
1658
+ n,
1659
+ ". ",
1660
+ E,
1661
+ " ",
1662
+ D
1663
+ ]
1664
+ }),
1665
+ c !== void 0 && /* @__PURE__ */ J("line", {
1666
+ x1: tn,
1667
+ x2: m - tn,
1668
+ y1: S(c),
1669
+ y2: S(c),
1670
+ className: "x1crw9hw xnpr05h xbw2l0c x13efnbd"
1671
+ }),
1672
+ w !== void 0 && /* @__PURE__ */ J(Qt, {
1673
+ series: w,
1674
+ x,
1675
+ y: S,
1676
+ pointRadius: 2
1677
+ }),
1678
+ T.map(({ kind: e, point: t }) => e === "last" ? /* @__PURE__ */ J("circle", {
1679
+ cx: x(t.timestamp),
1680
+ cy: S(t.value),
1681
+ r: en,
1682
+ fill: te
1683
+ }, e) : /* @__PURE__ */ J("circle", {
1684
+ cx: x(t.timestamp),
1685
+ cy: S(t.value),
1686
+ r: en,
1687
+ stroke: te,
1688
+ className: "x1fytgo2 x1r6sdyr x13efnbd"
1689
+ }, e))
1690
+ ]
1691
+ });
1692
+ return p ? /* @__PURE__ */ J(d, {
1693
+ title: e,
1694
+ description: t,
1695
+ children: /* @__PURE__ */ J("div", {
1696
+ ref: f.ref,
1697
+ className: "x1lliihq xeuugli",
1698
+ children: O
1699
+ })
1700
+ }) : O;
1701
+ }
1702
+ function on({ title: e, summary: t, unit: n, series: r, valueDomain: i, markedPoints: a, baseline: o }) {
1703
+ if (e.trim() === "" || t.trim() === "" || n.trim() === "") return "A trend requires a title, a readable summary, and a value unit.";
1704
+ if (!D(i)) return "The displayed value domain must have finite, increasing bounds.";
1705
+ let s = Kt({
1706
+ series: [r],
1707
+ isStacked: !1,
1708
+ markers: []
1709
+ });
1710
+ if (s !== void 0) return s;
1711
+ if (r.points.some((e) => e.value !== null && (e.value < i[0] || e.value > i[1]))) return "Every recorded value must be inside the declared value domain.";
1712
+ if (new Set(a).size !== a.length) return "Mark each recorded point at most once.";
1713
+ if (!(o === void 0 || o >= i[0] && o <= i[1])) return "The reference value must be inside the declared value domain.";
1714
+ }
1715
+ // packages/charts/src/cartesian/time-series-bands.ts
1716
+ var sn = {
1717
+ bands: 4,
1718
+ crossings: 4
1719
+ };
1720
+ function cn(e) {
1721
+ let t = [
1722
+ e.lower,
1723
+ e.center,
1724
+ e.upper
1725
+ ].filter((e) => e !== null);
1726
+ return t.some((e) => !Number.isFinite(e)) ? "Band values must be finite numbers or explicit missing values." : e.lower === null == (e.upper === null) ? t.every((e, n) => n === 0 || (t[n - 1] ?? e) <= e) ? void 0 : "Band values must satisfy lower ≤ center ≤ upper." : "A band observation needs both bounds or neither.";
1727
+ }
1728
+ function ln({ bands: e, crossings: t, series: n, timestamps: r }) {
1729
+ if (e.length > sn.bands || t.length > sn.crossings) return `Supply at most ${sn.bands} bands and ${sn.crossings} crossings.`;
1730
+ if (!o([...n, ...e]) || !o(t)) return "Series, bands, and crossings require unique identifiers.";
1731
+ for (let t of e) {
1732
+ if (t.points.length !== r.length || t.points.some((e, t) => e.timestamp !== r[t])) return "Every band must supply the same observation timestamps as the series.";
1733
+ let e = t.points.map(cn).find((e) => e !== void 0);
1734
+ if (e !== void 0) return e;
1735
+ }
1736
+ let i = new Set([...n, ...e].map((e) => e.id));
1737
+ for (let e of t) if (!(i.has(e.seriesId) && e.label.trim() !== "") || !Number.isFinite(e.value)) return "Each crossing needs a label, a finite value, and a supplied series or band.";
1738
+ }
1739
+ function un({ series: e, bands: t, tones: n }) {
1740
+ let r = e.filter((e) => e.tone === void 0).length, i = t.filter((e) => e.tone === void 0);
1741
+ return t.map((e) => {
1742
+ let t = r + i.findIndex((t) => t.id === e.id);
1743
+ return {
1744
+ ...e,
1745
+ tone: n({
1746
+ id: e.id,
1747
+ tone: e.tone,
1748
+ index: t
1749
+ })
1750
+ };
1751
+ });
1752
+ }
1753
+ function dn({ start: e, end: t, value: n, direction: r }) {
1754
+ let i = e > n && t <= n, a = e < n && t >= n;
1755
+ switch (r) {
1756
+ case "falling": return i;
1757
+ case "rising": return a;
1758
+ case void 0: return i || a;
1759
+ }
1760
+ }
1761
+ function fn({ points: e, crossing: t }) {
1762
+ let n = e.flatMap((t, n) => {
1763
+ let r = e[n + 1];
1764
+ return t.value === null || r === void 0 || r.value === null ? [] : [{
1765
+ start: t.timestamp,
1766
+ end: r.timestamp,
1767
+ from: t.value,
1768
+ to: r.value
1769
+ }];
1770
+ }).find(({ from: e, to: n }) => dn({
1771
+ start: e,
1772
+ end: n,
1773
+ value: t.value,
1774
+ direction: t.direction
1775
+ }));
1776
+ if (n === void 0) return;
1777
+ let r = (t.value - n.from) / (n.to - n.from);
1778
+ return n.start + r * (n.end - n.start);
1779
+ }
1780
+ function pn({ crossings: e, series: t, bands: n }) {
1781
+ return e.map((e) => ({
1782
+ crossing: e,
1783
+ timestamp: fn({
1784
+ points: t.find((t) => t.id === e.seriesId)?.points ?? n.find((t) => t.id === e.seriesId)?.points.map((e) => ({
1785
+ timestamp: e.timestamp,
1786
+ value: e.center
1787
+ })) ?? [],
1788
+ crossing: e
1789
+ })
1790
+ }));
1791
+ }
1792
+ function mn(e, t) {
1793
+ let n = Math.min(...e.map((e) => Math.abs(e - t)));
1794
+ return e.find((e) => Math.abs(e - t) === n);
1795
+ }
1796
+ function hn(e) {
1797
+ return e.flatMap((e) => e.points.flatMap((e) => [
1798
+ e.lower,
1799
+ e.center,
1800
+ e.upper
1801
+ ].filter((e) => e !== null)));
1802
+ }
1803
+ // packages/charts/src/chart-range.tsx
1804
+ var gn = "axis", _n = "selected", vn = "drawn";
1805
+ function yn({ value: e }) {
1806
+ return {
1807
+ value: e,
1808
+ spans: e === null ? [] : [{
1809
+ id: _n,
1810
+ track: gn,
1811
+ start: e[0],
1812
+ end: e[1]
1813
+ }]
1814
+ };
1815
+ }
1816
+ function bn(e, t) {
1817
+ let { draft: n } = e;
1818
+ return n?.action === "draw" ? t.filter((e) => e.id === n.id) : t;
1819
+ }
1820
+ var xn = Ee({
1821
+ name: "chart-range",
1822
+ options: {
1823
+ value: "value",
1824
+ onValueChange: "callback",
1825
+ min: "number",
1826
+ max: "number",
1827
+ step: "number",
1828
+ describe: "value"
1829
+ },
1830
+ controlled: ["value"],
1831
+ state: (e) => ({
1832
+ ...yn(e),
1833
+ draft: null
1834
+ }),
1835
+ sync: yn,
1836
+ api: (e) => {
1837
+ let t = q(e);
1838
+ function n(n, { id: r, action: i, reason: a, event: o }) {
1839
+ let s = i === "delete" ? void 0 : n.find((e) => e.id === r), c = s === void 0 ? null : [s.start, s.end], l = t("value", c, o === void 0 ? { reason: a } : {
1840
+ reason: a,
1841
+ event: o
1842
+ });
1843
+ return l && i === "delete" && e.element("root")?.querySelector("[tabindex=\"0\"]:not([data-span-id])")?.focus(), l;
1844
+ }
1845
+ let r = Te(e, {
1846
+ key: "spans",
1847
+ draft: "draft",
1848
+ axis: "x",
1849
+ min: () => e.options().min,
1850
+ max: () => e.options().max,
1851
+ step: () => e.options().step,
1852
+ create: (e) => ({
1853
+ ...e,
1854
+ id: vn
1855
+ }),
1856
+ label: (t) => e.options().describe([t.start, t.end]),
1857
+ createAutoScroll: !1,
1858
+ set: (e, t) => n(e, t)
1859
+ });
1860
+ return {
1861
+ spans: r,
1862
+ shown(t) {
1863
+ return bn(t, r.spans(t)).map((t) => ({
1864
+ id: t.id,
1865
+ label: e.options().describe([t.start, t.end])
1866
+ }));
1867
+ },
1868
+ draw(e) {
1869
+ e.button === 0 && e.pointerType !== "touch" && r.trackPointerdown(e, gn);
1870
+ },
1871
+ setRange(n, r) {
1872
+ let { min: i, max: a, step: o } = e.options(), s = [Number(n), Number(r)].map((e) => i + Math.round((e - i) / o) * o), c = Math.max(i, Math.min(...s)), l = Math.min(a, Math.max(...s));
1873
+ if (!Number.isFinite(c) || !Number.isFinite(l) || c >= l) throw Error(`Give a start and a later end between ${i} and ${a}.`);
1874
+ return t("value", [c, l], { reason: "imperative" });
1875
+ },
1876
+ clear() {
1877
+ return t("value", null, { reason: "imperative" });
1878
+ }
1879
+ };
1880
+ },
1881
+ slots: (e) => ({
1882
+ root: e({
1883
+ role: "group",
1884
+ state: (e, { api: t }) => ({ spans: t.shown(e) }),
1885
+ on: { pointerdown: (e, { api: t }) => t.draw(e) }
1886
+ }),
1887
+ track: e({ bind: (e, { api: t }) => t.spans.bindTrack(e, gn) }),
1888
+ span: e({
1889
+ role: "group",
1890
+ props: { value: "string" },
1891
+ attrs: (e, { api: t, key: n }) => {
1892
+ let r = t.spans.spans(e).find((e) => e.id === n);
1893
+ return {
1894
+ ...t.spans.spanAttrs(e, n),
1895
+ tabindex: "0",
1896
+ style: r === void 0 ? void 0 : t.spans.spanStyle(r)
1897
+ };
1898
+ },
1899
+ bind: (e, { api: t, key: n }) => t.spans.bindSpan(e, n),
1900
+ on: {
1901
+ pointerdown: (e, { api: t, key: n }) => t.spans.spanPointerdown(e, n),
1902
+ keydown: (e, { api: t, key: n }) => {
1903
+ t.spans.keydown(e, n);
1904
+ }
1905
+ }
1906
+ })
1907
+ }),
1908
+ agent: { actions: ["setRange", "clear"] }
1909
+ }), Sn = U(xn, {
1910
+ root: "div",
1911
+ track: "div",
1912
+ span: "div"
1913
+ }), Cn = Sn.Root, wn = Sn.Track, Tn = Sn.Span, En = {
1914
+ kVAEAm: "x10l6tqk",
1915
+ k87sOh: "x13vifvy",
1916
+ kfzvcC: "x47corl",
1917
+ $$css: !0
1918
+ }, Dn = { track: (e, t, n) => [
1919
+ En,
1920
+ {
1921
+ kbCHJM: e == null ? e : "xgq9j65",
1922
+ kzqmXN: t == null ? t : "x5lhr3w",
1923
+ kZKoxP: n == null ? n : "x16ye13r",
1924
+ $$css: !0
1925
+ },
1926
+ {
1927
+ "--x-left": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(e),
1928
+ "--x-width": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(t),
1929
+ "--x-height": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(n)
1930
+ }
1931
+ ] };
1932
+ function On({ left: e, width: t, height: n, label: r, children: i, ...a }) {
1933
+ return /* @__PURE__ */ J(Cn, {
1934
+ ...a,
1935
+ "aria-label": r,
1936
+ className: "x1n2onr6 xeuugli",
1937
+ render: (r, { spans: a }) => /* @__PURE__ */ Y("div", {
1938
+ ...r,
1939
+ children: [i, /* @__PURE__ */ J(wn, {
1940
+ ...H.props(Dn.track(e, t, n)),
1941
+ children: a.map((e) => /* @__PURE__ */ Y(Tn, {
1942
+ value: e.id,
1943
+ "aria-label": `Selected range, ${e.label}. Use arrow keys to move it, Shift and an arrow to move its end, and Delete to clear it.`,
1944
+ className: "x10l6tqk x13vifvy x5yr21d x9f619 x1qatu44 x1l0rsgs x1616tdu xbsl7fq xbm8b0d x1n2ykn x1t137rt x19rmrnh x9v5kkp x13qnu6 x1bqaal",
1945
+ children: [
1946
+ /* @__PURE__ */ J("span", { className: "x10l6tqk x67bb7w x5ve5x3 x7it7wx x1ey2m1c xdk7pt x1jm3nie x1o753nm x1jzqe4 x3onkmb" }),
1947
+ /* @__PURE__ */ J("span", {
1948
+ "data-span-edge": "start",
1949
+ className: "x10l6tqk x67bb7w x5ve5x3 x13vifvy x5yr21d x1fsd2vl x7eptgl x1765b1"
1950
+ }),
1951
+ /* @__PURE__ */ J("span", {
1952
+ "data-span-edge": "end",
1953
+ className: "x10l6tqk x67bb7w x5ve5x3 x13vifvy x5yr21d x1fsd2vl x7eptgl xpa5qit"
1954
+ })
1955
+ ]
1956
+ }, e.id))
1957
+ })]
1958
+ })
1959
+ });
1960
+ }
1961
+ // packages/charts/src/cartesian/time-series-overlays.tsx
1962
+ var kn = 16, An = 6, jn = 6.5, Mn = 4;
1963
+ function Nn({ instants: e, x: t, right: n, ends: r }) {
1964
+ let [i, ...a] = e;
1965
+ if (i === void 0) return [];
1966
+ let o = t(i.timestamp), s = i.label.length * jn + An, c = o + s > n ? "end" : "start", l = c === "start" ? o : o - s, u = c === "start" ? o + s : o, d = r.findIndex((e) => l > e), f = d === -1 ? Math.min(r.length, 1) : d, p = [
1967
+ ...r.slice(0, f),
1968
+ Math.max(u, r[f] ?? u),
1969
+ ...r.slice(f + 1)
1970
+ ];
1971
+ return [{
1972
+ ...i,
1973
+ lane: f,
1974
+ anchor: c
1975
+ }, ...Nn({
1976
+ instants: a,
1977
+ x: t,
1978
+ right: n,
1979
+ ends: p
1980
+ })];
1981
+ }
1982
+ function Pn({ instants: e, x: t, right: n }) {
1983
+ return Nn({
1984
+ instants: e.toSorted((e, t) => e.timestamp - t.timestamp),
1985
+ x: t,
1986
+ right: n,
1987
+ ends: []
1988
+ });
1989
+ }
1990
+ function Fn(e) {
1991
+ return Math.max(0, ...e.map((e) => e.lane + 1)) * kn;
1992
+ }
1993
+ function In({ bands: e, x: t, y: n }) {
1994
+ return /* @__PURE__ */ J("g", { children: e.map((e) => {
1995
+ function r(t) {
1996
+ return e.points.map((e) => {
1997
+ let r = t(e);
1998
+ return r === null ? null : n(r);
1999
+ });
2000
+ }
2001
+ let i = r((e) => e.lower), a = r((e) => e.upper), o = r((e) => e.center), s = e.points.map((e) => t(e.timestamp));
2002
+ return /* @__PURE__ */ Y("g", { children: [/* @__PURE__ */ J(B, {
2003
+ d: xe(s.map((e, t) => ({
2004
+ x: e,
2005
+ y0: i[t] ?? null,
2006
+ y1: a[t] ?? null
2007
+ }))),
2008
+ tone: e.tone
2009
+ }), /* @__PURE__ */ J(ue, {
2010
+ d: be(s.map((e, t) => ({
2011
+ x: e,
2012
+ y: o[t] ?? null
2013
+ }))),
2014
+ tone: e.tone
2015
+ })] }, e.id);
2016
+ }) });
2017
+ }
2018
+ function Ln({ placed: e, x: t, y: n, top: r, bottom: i }) {
2019
+ let a = r - Fn(e);
2020
+ return /* @__PURE__ */ J("g", {
2021
+ "aria-hidden": !0,
2022
+ children: e.map((e) => {
2023
+ let r = t(e.timestamp), o = a + (e.lane + 1 / 2) * kn, s = e.anchor === "start" ? r + An : r - An;
2024
+ return /* @__PURE__ */ Y("g", { children: [
2025
+ /* @__PURE__ */ J(de, {
2026
+ x: r,
2027
+ top: o,
2028
+ bottom: i
2029
+ }),
2030
+ /* @__PURE__ */ J(L, {
2031
+ x: s,
2032
+ y: o + Mn,
2033
+ anchor: e.anchor,
2034
+ children: e.label
2035
+ }),
2036
+ e.value !== void 0 && /* @__PURE__ */ J(R, {
2037
+ x: r,
2038
+ y: n(e.value)
2039
+ })
2040
+ ] }, e.id);
2041
+ })
2042
+ });
2043
+ }
2044
+ // packages/charts/src/cartesian/time-series.tsx
2045
+ var Rn = {
2046
+ seconds: 1e3,
2047
+ milliseconds: 1
2048
+ }, zn = 24, Bn = 12, Vn = 2.5, Hn = 4, Un = {
2049
+ line: "line",
2050
+ area: "swatch"
2051
+ };
2052
+ function Wn(e, t) {
2053
+ return e * Rn[t];
2054
+ }
2055
+ function Gn({ format: e, tickFormat: t, label: n = "" }) {
2056
+ return {
2057
+ label: n,
2058
+ format: e,
2059
+ tickFormat: t
2060
+ };
2061
+ }
2062
+ function Kn({ series: e, isStacked: t, isZeroBased: n, bands: r, crossings: i }) {
2063
+ let a = (e[0]?.points ?? []).map((t, n) => e.reduce((e, t) => e + (t.points[n]?.value ?? 0), 0)), o = t ? a : e.flatMap((e) => e.points.map((e) => e.value));
2064
+ return u({
2065
+ values: [
2066
+ ...o,
2067
+ ...hn(r),
2068
+ ...i.map((e) => e.value)
2069
+ ],
2070
+ isZeroBased: n
2071
+ });
2072
+ }
2073
+ function qn({ bands: e, crossings: t }) {
2074
+ return JSON.stringify([e.map((e) => [
2075
+ e.id,
2076
+ e.label,
2077
+ e.rangeLabel,
2078
+ e.tone,
2079
+ e.points.map((e) => [
2080
+ e.timestamp,
2081
+ e.lower,
2082
+ e.center,
2083
+ e.upper
2084
+ ])
2085
+ ]), t.map((e) => [
2086
+ e.id,
2087
+ e.seriesId,
2088
+ e.value,
2089
+ e.label,
2090
+ e.direction
2091
+ ])]);
2092
+ }
2093
+ function Jn({ bands: e, timestamp: t, valueText: n }) {
2094
+ return e.flatMap((e) => {
2095
+ let r = e.points.find((e) => e.timestamp === t), i = r?.center ?? null, a = r?.lower !== null && r?.upper !== null && r !== void 0;
2096
+ return [{
2097
+ id: e.id,
2098
+ label: e.label,
2099
+ tone: e.tone,
2100
+ shape: "band",
2101
+ value: n(i)
2102
+ }, {
2103
+ id: `${e.id}:range`,
2104
+ label: e.rangeLabel,
2105
+ tone: e.tone,
2106
+ shape: "band",
2107
+ value: a ? `${n(r.lower)} – ${n(r.upper)}` : n(null)
2108
+ }];
2109
+ });
2110
+ }
2111
+ function Yn({ found: e, timeText: t }) {
2112
+ return e.timestamp === void 0 ? `${e.crossing.label} · Not reached in this range` : `About ${t(e.timestamp)} · ${e.crossing.label}`;
2113
+ }
2114
+ function Xn(e) {
2115
+ return /* @__PURE__ */ J(nr, {
2116
+ ...e,
2117
+ kind: "line",
2118
+ isStacked: !1
2119
+ });
2120
+ }
2121
+ function Zn({ isStacked: e = !1, ...t }) {
2122
+ return /* @__PURE__ */ J(nr, {
2123
+ ...t,
2124
+ kind: "area",
2125
+ isStacked: e
2126
+ });
2127
+ }
2128
+ function Qn(e) {
2129
+ return /* @__PURE__ */ J($n, { ...e });
2130
+ }
2131
+ function $n({ series: e, height: t = "compact", showTimeAxis: i = !0, ...a }) {
2132
+ let o = W(), s = C(), c = Xt({
2133
+ series: e.map((e) => ({
2134
+ ...e,
2135
+ points: []
2136
+ })),
2137
+ isStacked: !1,
2138
+ tones: s
2139
+ });
2140
+ return /* @__PURE__ */ J("div", {
2141
+ "aria-hidden": !0,
2142
+ inert: !0,
2143
+ className: "xeuugli",
2144
+ children: /* @__PURE__ */ J(j, {
2145
+ ...a,
2146
+ status: "loading",
2147
+ series: c,
2148
+ seriesLegend: /* @__PURE__ */ J(M, {
2149
+ id: o,
2150
+ label: void 0,
2151
+ legend: c,
2152
+ rows: [],
2153
+ x: 0,
2154
+ width: 0,
2155
+ hasSeriesSummary: a.report?.seriesValues !== void 0
2156
+ }),
2157
+ children: /* @__PURE__ */ J("div", {
2158
+ className: "xrvj5dj x1n8ia3y",
2159
+ children: /* @__PURE__ */ Y("div", {
2160
+ className: "xeuugli",
2161
+ children: [/* @__PURE__ */ J(r, { height: f[t] - zn }), /* @__PURE__ */ J("div", {
2162
+ className: "x78zum5 x6s0dn4 x1qughib x8zbtdt xxk0z11",
2163
+ children: i && /* @__PURE__ */ Y(Oe, { children: [/* @__PURE__ */ J(n, { width: "8ch" }), /* @__PURE__ */ J(n, { width: "8ch" })] })
2164
+ })]
2165
+ })
2166
+ })
2167
+ })
2168
+ });
2169
+ }
2170
+ function er({ charts: e, timestampUnit: t, timeFormat: n, height: r = "compact", locale: i, status: a }) {
2171
+ let s = we(null), [c, l] = G(), u = JSON.stringify(e.map((e) => [
2172
+ e.id,
2173
+ e.title,
2174
+ Jt({
2175
+ series: e.series,
2176
+ markers: e.markers ?? [],
2177
+ timestampUnit: t,
2178
+ isStacked: !1
2179
+ })
2180
+ ])), d = JSON.stringify(e[0]?.series[0]?.points.map((e) => e.timestamp) ?? []), p = e.every((e) => JSON.stringify(e.series[0]?.points.map((e) => e.timestamp) ?? []) === d);
2181
+ if (c !== void 0 && c.signature !== u && l(void 0), a === "loading") return /* @__PURE__ */ J(tr, {
2182
+ charts: e,
2183
+ height: r,
2184
+ locale: i
2185
+ });
2186
+ if (!p || !o(e)) return /* @__PURE__ */ J(oe, {
2187
+ title: "Small multiples",
2188
+ locale: i,
2189
+ message: "Charts need unique identifiers and aligned observation timestamps."
2190
+ });
2191
+ if (e.length > $.panels) return /* @__PURE__ */ J(oe, {
2192
+ title: "Small multiples",
2193
+ locale: i,
2194
+ message: `Choose at most ${$.panels} panels.`
2195
+ });
2196
+ if (e.length === 0) return /* @__PURE__ */ J(j, {
2197
+ title: "Small multiples",
2198
+ locale: i,
2199
+ children: /* @__PURE__ */ J(se, { children: "No charts" })
2200
+ });
2201
+ let m = h({
2202
+ height: f[r],
2203
+ locale: i,
2204
+ hasValueTitle: e.some((e) => e.valueLabel !== void 0),
2205
+ axes: e.map((e) => ({
2206
+ axis: Gn({
2207
+ format: e.valueFormat,
2208
+ tickFormat: e.tickFormat,
2209
+ label: e.valueLabel
2210
+ }),
2211
+ domain: Kn({
2212
+ series: e.series,
2213
+ isStacked: !1,
2214
+ isZeroBased: !1,
2215
+ bands: e.bands ?? [],
2216
+ crossings: []
2217
+ })
2218
+ }))
2219
+ }), g = e.every((e) => e.report !== void 0);
2220
+ return /* @__PURE__ */ J("div", {
2221
+ ref: s,
2222
+ ...{
2223
+ 0: { className: "xrvj5dj x1j825kq" },
2224
+ 1: { className: "xrvj5dj xxhr3t" }
2225
+ }[!!g | 0],
2226
+ children: e.map(({ id: o, ...d }, f) => /* @__PURE__ */ J("div", {
2227
+ ...{
2228
+ 0: {},
2229
+ 1: { className: "x1y332i5" }
2230
+ }[!!(g && f > 0) | 0],
2231
+ children: /* @__PURE__ */ J(nr, {
2232
+ ...d,
2233
+ locale: i,
2234
+ status: a,
2235
+ timestampUnit: t,
2236
+ timeFormat: n,
2237
+ height: r,
2238
+ kind: "line",
2239
+ isStacked: !1,
2240
+ sharedInspection: {
2241
+ id: c?.signature === u ? c.id : null,
2242
+ isSource: c?.chartId === o,
2243
+ onChange: (e) => l(e === null ? void 0 : {
2244
+ id: e,
2245
+ signature: u,
2246
+ chartId: o
2247
+ }),
2248
+ within: (e) => s.current?.contains(e) === !0
2249
+ },
2250
+ gutter: m,
2251
+ showTimeAxis: f === e.length - 1
2252
+ })
2253
+ }, o))
2254
+ });
2255
+ }
2256
+ function tr({ charts: e, height: t, locale: n }) {
2257
+ if (!o(e) || e.length > $.panels) return /* @__PURE__ */ J(oe, {
2258
+ title: "Small multiples",
2259
+ locale: n,
2260
+ message: `Choose at most ${$.panels} panels with unique identifiers.`
2261
+ });
2262
+ let r = e.every((e) => e.report !== void 0);
2263
+ return /* @__PURE__ */ J("div", {
2264
+ "aria-hidden": !0,
2265
+ inert: !0,
2266
+ ...{
2267
+ 0: { className: "xrvj5dj x1j825kq" },
2268
+ 1: { className: "xrvj5dj xxhr3t" }
2269
+ }[!!r | 0],
2270
+ children: e.map(({ id: i, ...a }, o) => /* @__PURE__ */ J("div", {
2271
+ ...{
2272
+ 0: {},
2273
+ 1: { className: "x1y332i5" }
2274
+ }[!!(r && o > 0) | 0],
2275
+ children: /* @__PURE__ */ J($n, {
2276
+ ...a,
2277
+ locale: n,
2278
+ height: t,
2279
+ showTimeAxis: o === e.length - 1
2280
+ })
2281
+ }, i))
2282
+ });
2283
+ }
2284
+ function nr({ series: t, timestampUnit: n, timeFormat: r, valueFormat: i, tickFormat: a, valueLabel: o, markers: s = [], height: c = "compact", kind: l, isStacked: u, sharedInspection: d, gutter: f, showTimeAxis: p = !0, bands: h = [], crossings: g = [], range: _ = null, onRangeChange: y, rangeStep: b, emptyLabel: x = "No observations", ...S }) {
2285
+ let { title: T, locale: E, report: D } = S, O = C(), k = he(c), A = W(), ie = h[0]?.points.map((e) => e.timestamp) ?? [], N = t[0]?.points.map((e) => e.timestamp) ?? ie, P = Kt({
2286
+ series: t,
2287
+ isStacked: u,
2288
+ markers: s,
2289
+ timeline: ie
2290
+ }) ?? ln({
2291
+ bands: h,
2292
+ crossings: g,
2293
+ series: t,
2294
+ timestamps: N
2295
+ }) ?? rr({
2296
+ range: _,
2297
+ rangeStep: b,
2298
+ isSelectable: y !== void 0,
2299
+ timeline: N
2300
+ }), F = P === void 0 ? Xt({
2301
+ series: t,
2302
+ isStacked: u,
2303
+ tones: O
2304
+ }) : [], L = P === void 0 ? un({
2305
+ series: t,
2306
+ bands: h,
2307
+ tones: O
2308
+ }) : [], z = F[0]?.points ?? L[0]?.points ?? [];
2309
+ function B(e) {
2310
+ return w({
2311
+ timestamp: Wn(e, n),
2312
+ locale: E,
2313
+ format: r
2314
+ });
2315
+ }
2316
+ function V(e) {
2317
+ return te({
2318
+ value: e,
2319
+ locale: E,
2320
+ format: i
2321
+ });
2322
+ }
2323
+ let fe = z.map(({ timestamp: e }) => ({
2324
+ id: String(e),
2325
+ label: B(e)
2326
+ })), _e = `${Jt({
2327
+ series: t,
2328
+ markers: s,
2329
+ timestampUnit: n,
2330
+ isStacked: u
2331
+ })}${qn({
2332
+ bands: h,
2333
+ crossings: g
2334
+ })}`, ve = [...F.map(({ id: e, label: t, tone: n }) => ({
2335
+ id: e,
2336
+ label: t,
2337
+ tone: n,
2338
+ shape: Un[l]
2339
+ })), ...L.map(({ id: e, label: t, tone: n }) => ({
2340
+ id: e,
2341
+ label: t,
2342
+ tone: n,
2343
+ shape: "band"
2344
+ }))], H = D?.seriesValues !== void 0;
2345
+ if (S.status === "loading") return /* @__PURE__ */ J($n, {
2346
+ ...S,
2347
+ series: t,
2348
+ height: c,
2349
+ showTimeAxis: p
2350
+ });
2351
+ if (P !== void 0) return /* @__PURE__ */ J(oe, {
2352
+ ...S,
2353
+ message: P
2354
+ });
2355
+ if (z.length === 0) return /* @__PURE__ */ J(j, {
2356
+ ...S,
2357
+ series: ve,
2358
+ children: /* @__PURE__ */ J(se, { children: x })
2359
+ });
2360
+ let U = z.map((e) => e.timestamp), Ce = pn({
2361
+ crossings: g,
2362
+ series: t,
2363
+ bands: h
2364
+ }), we = [...s.flatMap((e) => e.kind === "event" ? [e] : []), ...Ce.flatMap(({ crossing: e, timestamp: t }) => t === void 0 ? [] : [{
2365
+ id: e.id,
2366
+ timestamp: t,
2367
+ label: e.label,
2368
+ value: e.value
2369
+ }])];
2370
+ function G(e) {
2371
+ return {
2372
+ label: e === void 0 ? void 0 : B(e),
2373
+ rows: [...F.map((t) => {
2374
+ let n = t.points.find((t) => t.timestamp === e);
2375
+ return {
2376
+ id: t.id,
2377
+ label: t.label,
2378
+ tone: t.tone,
2379
+ value: V(n?.value ?? null)
2380
+ };
2381
+ }), ...Jn({
2382
+ bands: L,
2383
+ timestamp: e,
2384
+ valueText: V
2385
+ })],
2386
+ notes: [...s.filter((t) => t.kind !== "event" && t.timestamp === e).map((e) => e.label), ...we.filter((t) => mn(U, t.timestamp) === e).map((e) => `${e.label} · ${B(e.timestamp)}`)]
2387
+ };
2388
+ }
2389
+ let K = U[0] ?? 0, q = U.at(-1) ?? K, Te = {
2390
+ width: k.width,
2391
+ height: k.height,
2392
+ value: Gn({
2393
+ format: i,
2394
+ tickFormat: a,
2395
+ label: o
2396
+ }),
2397
+ valueDomain: Kn({
2398
+ series: t,
2399
+ isStacked: u,
2400
+ isZeroBased: l === "area",
2401
+ bands: h,
2402
+ crossings: g
2403
+ }),
2404
+ timeDomain: Yt(Wn(K, n), Wn(q, n)),
2405
+ timeFormat: r,
2406
+ locale: E,
2407
+ gutter: f,
2408
+ hasValueTitle: o !== void 0
2409
+ }, Ee = v(Te), Oe = Pn({
2410
+ instants: we,
2411
+ x: (e) => Ee.x.position(Wn(e, n)),
2412
+ right: Ee.box.right
2413
+ }), ke = v({
2414
+ ...Te,
2415
+ topInset: Fn(Oe)
2416
+ }), { box: X } = ke;
2417
+ function Z(e) {
2418
+ return ke.x.position(Wn(e, n));
2419
+ }
2420
+ let Q = ke.y.position;
2421
+ function Ae(e) {
2422
+ return `${B(e[0])} to ${B(e[1])}`;
2423
+ }
2424
+ let je = y !== void 0 && b !== void 0 && q !== K ? {
2425
+ onRangeChange: y,
2426
+ rangeStep: b
2427
+ } : void 0, Me = U.map((e) => ({
2428
+ id: String(e),
2429
+ x: Z(e),
2430
+ y: 0
2431
+ }));
2432
+ return /* @__PURE__ */ J("div", {
2433
+ className: "xeuugli",
2434
+ children: /* @__PURE__ */ J(ee, {
2435
+ items: fe,
2436
+ readout: (e) => re(G(Number(e))),
2437
+ locate: Se({
2438
+ marks: Me,
2439
+ width: X.width,
2440
+ height: X.height,
2441
+ axis: "x"
2442
+ }),
2443
+ revision: _e,
2444
+ inspected: d?.id,
2445
+ onInspectedChange: d?.onChange,
2446
+ within: d?.within,
2447
+ render: (t, { inspected: r, cursor: i }) => {
2448
+ let a = r === null ? void 0 : Number(r), c = G(d === void 0 || d.isSource ? a : void 0), f = /* @__PURE__ */ Y(me, {
2449
+ plotRef: k.ref,
2450
+ box: X,
2451
+ label: m({
2452
+ title: T,
2453
+ marks: "observations",
2454
+ isSelectable: !1
2455
+ }),
2456
+ readoutId: A,
2457
+ children: [
2458
+ /* @__PURE__ */ J(ce, {
2459
+ box: X,
2460
+ xTicks: p ? ke.xTicks : [],
2461
+ yTicks: ke.yTicks,
2462
+ yTitle: o
2463
+ }),
2464
+ /* @__PURE__ */ Y(ge, {
2465
+ box: X,
2466
+ children: [
2467
+ /* @__PURE__ */ J(In, {
2468
+ bands: L,
2469
+ x: Z,
2470
+ y: Q
2471
+ }),
2472
+ F.map((e) => {
2473
+ let t = e.points.map((e) => ({
2474
+ x: Z(e.timestamp),
2475
+ y: e.value === null ? null : Q(e.value + e.base)
2476
+ })), n = e.points.map((e) => ({
2477
+ x: Z(e.timestamp),
2478
+ y0: e.value === null ? null : Q(e.base),
2479
+ y1: e.value === null ? null : Q(e.value + e.base)
2480
+ }));
2481
+ return /* @__PURE__ */ Y("g", { children: [
2482
+ l === "area" && /* @__PURE__ */ J(pe, {
2483
+ d: xe(n),
2484
+ tone: e.tone,
2485
+ isPale: !u
2486
+ }),
2487
+ /* @__PURE__ */ J(ue, {
2488
+ d: be(t),
2489
+ tone: e.tone
2490
+ }),
2491
+ ye(t).map((t) => /* @__PURE__ */ J(I, {
2492
+ x: t.x,
2493
+ y: t.y,
2494
+ tone: e.tone,
2495
+ radius: Vn
2496
+ }, t.x))
2497
+ ] }, e.id);
2498
+ }),
2499
+ g.map((e) => /* @__PURE__ */ J(le, {
2500
+ x1: X.left,
2501
+ x2: X.right,
2502
+ y1: Q(e.value),
2503
+ y2: Q(e.value)
2504
+ }, e.id)),
2505
+ s.map((e) => {
2506
+ if (e.kind === "time") return /* @__PURE__ */ J(de, {
2507
+ x: Z(e.timestamp),
2508
+ top: X.top,
2509
+ bottom: X.bottom
2510
+ }, e.id);
2511
+ let t = F.find((t) => t.id === e.seriesId)?.points.find((t) => t.timestamp === e.timestamp)?.base;
2512
+ return e.kind === "point" ? /* @__PURE__ */ J(R, {
2513
+ x: Z(e.timestamp),
2514
+ y: Q(e.value + (t ?? 0))
2515
+ }, e.id) : void 0;
2516
+ }),
2517
+ a !== void 0 && /* @__PURE__ */ J(de, {
2518
+ x: Z(a),
2519
+ top: X.top,
2520
+ bottom: X.bottom
2521
+ }),
2522
+ a !== void 0 && F.flatMap((e) => {
2523
+ let t = e.points.find((e) => e.timestamp === a);
2524
+ return t === void 0 || t.value === null ? [] : [/* @__PURE__ */ J(I, {
2525
+ x: Z(t.timestamp),
2526
+ y: Q(t.value + t.base),
2527
+ tone: e.tone,
2528
+ isInspected: !0
2529
+ }, e.id)];
2530
+ })
2531
+ ]
2532
+ }),
2533
+ /* @__PURE__ */ J(Ln, {
2534
+ placed: Oe,
2535
+ x: Z,
2536
+ y: Q,
2537
+ top: X.top,
2538
+ bottom: X.bottom
2539
+ }),
2540
+ i !== null && /* @__PURE__ */ J(ne, {
2541
+ x: Z(Number(i)),
2542
+ top: X.top,
2543
+ bottom: X.bottom,
2544
+ width: Bn
2545
+ })
2546
+ ]
2547
+ });
2548
+ return /* @__PURE__ */ Y(j, {
2549
+ ...S,
2550
+ figure: t,
2551
+ titleDetail: H ? void 0 : c.label,
2552
+ series: ve,
2553
+ seriesLegend: /* @__PURE__ */ J(M, {
2554
+ id: A,
2555
+ label: c.label,
2556
+ legend: ve,
2557
+ rows: c.rows,
2558
+ x: Z(a ?? K),
2559
+ width: X.width,
2560
+ notes: c.notes,
2561
+ hasSeriesSummary: H
2562
+ }),
2563
+ children: [/* @__PURE__ */ J(ae, {
2564
+ label: `${T} observations`,
2565
+ columns: [
2566
+ {
2567
+ id: "time",
2568
+ label: `Time (${n})`
2569
+ },
2570
+ ...F.map((e) => ({
2571
+ id: `series:${e.id}`,
2572
+ label: e.label
2573
+ })),
2574
+ ...L.flatMap((e) => [{
2575
+ id: `band:${e.id}`,
2576
+ label: e.label
2577
+ }, {
2578
+ id: `band-range:${e.id}`,
2579
+ label: `${e.label}: ${e.rangeLabel}`
2580
+ }])
2581
+ ],
2582
+ rows: z.map((e, t) => ({
2583
+ id: e.timestamp,
2584
+ values: [
2585
+ B(e.timestamp),
2586
+ ...F.map((e) => V(e.points[t]?.value ?? null)),
2587
+ ...Jn({
2588
+ bands: L,
2589
+ timestamp: e.timestamp,
2590
+ valueText: V
2591
+ }).map((e) => e.value)
2592
+ ]
2593
+ }))
2594
+ }), /* @__PURE__ */ Y("div", {
2595
+ className: "xrvj5dj x1n8ia3y",
2596
+ children: [
2597
+ je === void 0 ? f : /* @__PURE__ */ J(On, {
2598
+ value: _,
2599
+ onValueChange: je.onRangeChange,
2600
+ min: K,
2601
+ max: q,
2602
+ step: je.rangeStep,
2603
+ describe: Ae,
2604
+ label: `${T} time range`,
2605
+ left: Z(K),
2606
+ width: Z(q) - Z(K),
2607
+ height: X.bottom,
2608
+ children: f
2609
+ }),
2610
+ je !== void 0 && /* @__PURE__ */ Y("div", {
2611
+ className: "x78zum5 x1a02dak x6s0dn4 x1qughib x1hnptsi x153jb6y xy8obcc xas2l8k xj0a0fe",
2612
+ children: [/* @__PURE__ */ J("span", { children: _ === null ? "Drag on the plot with a mouse to select a range of time." : `Selected range: ${Ae(_)}` }), _ === null ? /* @__PURE__ */ J(e, {
2613
+ type: "button",
2614
+ onClick: (e) => {
2615
+ De({ options: () => je }, "onRangeChange", ir({
2616
+ first: K,
2617
+ last: q,
2618
+ step: je.rangeStep
2619
+ }), {
2620
+ reason: "trigger-press",
2621
+ event: e.nativeEvent
2622
+ });
2623
+ },
2624
+ children: "Select a range"
2625
+ }) : /* @__PURE__ */ J(e, {
2626
+ type: "button",
2627
+ onClick: (e) => {
2628
+ De({ options: () => je }, "onRangeChange", null, {
2629
+ reason: "clear-press",
2630
+ event: e.nativeEvent
2631
+ });
2632
+ },
2633
+ children: "Clear range"
2634
+ })]
2635
+ }),
2636
+ s.length + Ce.length > 0 && /* @__PURE__ */ Y("ul", {
2637
+ className: "x78zum5 x1a02dak x1n8ia3y x1ghz6dp x1717udv xe8uvvx xy8obcc x153jb6y xj0a0fe",
2638
+ children: [s.map((e) => /* @__PURE__ */ Y("li", { children: [
2639
+ B(e.timestamp),
2640
+ " · ",
2641
+ e.label,
2642
+ e.kind === "point" && ` · ${V(e.value)}`
2643
+ ] }, e.id)), Ce.map((e) => /* @__PURE__ */ J("li", { children: Yn({
2644
+ found: e,
2645
+ timeText: B
2646
+ }) }, e.crossing.id))]
2647
+ })
2648
+ ]
2649
+ })]
2650
+ });
2651
+ }
2652
+ })
2653
+ });
2654
+ }
2655
+ function rr({ range: e, rangeStep: t, isSelectable: n, timeline: r }) {
2656
+ let i = r[0], a = r.at(-1);
2657
+ if (!n || i === void 0 || a === void 0) return;
2658
+ let o = a - i;
2659
+ if (o !== 0) {
2660
+ if (t === void 0 || !Number.isFinite(t) || t <= 0 || t > o) return "A selectable range needs a rangeStep that is finite, positive, and no longer than the observed time.";
2661
+ if (e !== null && (!(e[0] >= i && e[1] <= a) || e[0] >= e[1])) return "The selected range must have ordered ends inside the observed time.";
2662
+ }
2663
+ }
2664
+ function ir({ first: e, last: t, step: n }) {
2665
+ let r = Math.max(1, Math.round((t - e) / Hn / n)) * n, i = Math.min(e + r, t - n);
2666
+ return [i, Math.min(t, Math.max(i + n, t - r))];
2667
+ }
2668
+ export { Qn as a, $ as c, Pt as d, ht as f, tr as i, Vt as l, st as m, Xn as n, sn as o, dt as p, er as r, an as s, Zn as t, Ft as u };