@tetrascience-npm/tetrascience-react-ui 0.7.0-beta.108.1 → 0.7.0-beta.129.1

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 (439) hide show
  1. package/README.md +7 -3
  2. package/dist/components/ai/chain-of-thought.cjs +1 -1
  3. package/dist/components/ai/chain-of-thought.cjs.map +1 -1
  4. package/dist/components/ai/chain-of-thought.js +1 -1
  5. package/dist/components/ai/chain-of-thought.js.map +1 -1
  6. package/dist/components/ai/confirmation.cjs +1 -1
  7. package/dist/components/ai/confirmation.cjs.map +1 -1
  8. package/dist/components/ai/confirmation.js +1 -1
  9. package/dist/components/ai/confirmation.js.map +1 -1
  10. package/dist/components/ai/context.cjs +1 -1
  11. package/dist/components/ai/context.cjs.map +1 -1
  12. package/dist/components/ai/context.js +36 -35
  13. package/dist/components/ai/context.js.map +1 -1
  14. package/dist/components/ai/message.cjs +1 -1
  15. package/dist/components/ai/message.cjs.map +1 -1
  16. package/dist/components/ai/message.js +68 -68
  17. package/dist/components/ai/message.js.map +1 -1
  18. package/dist/components/ai/prompt-input.cjs +1 -1
  19. package/dist/components/ai/prompt-input.cjs.map +1 -1
  20. package/dist/components/ai/prompt-input.js +4 -2
  21. package/dist/components/ai/prompt-input.js.map +1 -1
  22. package/dist/components/ai/queue.cjs +1 -1
  23. package/dist/components/ai/queue.cjs.map +1 -1
  24. package/dist/components/ai/queue.js +9 -9
  25. package/dist/components/ai/queue.js.map +1 -1
  26. package/dist/components/ai/reasoning.cjs +1 -1
  27. package/dist/components/ai/reasoning.cjs.map +1 -1
  28. package/dist/components/ai/reasoning.js +67 -67
  29. package/dist/components/ai/reasoning.js.map +1 -1
  30. package/dist/components/ai/stream-status.cjs +1 -1
  31. package/dist/components/ai/stream-status.cjs.map +1 -1
  32. package/dist/components/ai/stream-status.js +41 -39
  33. package/dist/components/ai/stream-status.js.map +1 -1
  34. package/dist/components/ai/streamdown-code-plugin.cjs +2 -0
  35. package/dist/components/ai/streamdown-code-plugin.cjs.map +1 -0
  36. package/dist/components/ai/streamdown-code-plugin.js +42 -0
  37. package/dist/components/ai/streamdown-code-plugin.js.map +1 -0
  38. package/dist/components/ai/streamdown-plugins.cjs +2 -0
  39. package/dist/components/ai/streamdown-plugins.cjs.map +1 -0
  40. package/dist/components/ai/streamdown-plugins.js +14 -0
  41. package/dist/components/ai/streamdown-plugins.js.map +1 -0
  42. package/dist/components/ai/task.cjs +1 -1
  43. package/dist/components/ai/task.cjs.map +1 -1
  44. package/dist/components/ai/task.js +18 -11
  45. package/dist/components/ai/task.js.map +1 -1
  46. package/dist/components/ai/tool.cjs +1 -1
  47. package/dist/components/ai/tool.cjs.map +1 -1
  48. package/dist/components/ai/tool.js +51 -55
  49. package/dist/components/ai/tool.js.map +1 -1
  50. package/dist/components/ai/use-streamdown-plugins.cjs +2 -0
  51. package/dist/components/ai/use-streamdown-plugins.cjs.map +1 -0
  52. package/dist/components/ai/use-streamdown-plugins.js +25 -0
  53. package/dist/components/ai/use-streamdown-plugins.js.map +1 -0
  54. package/dist/components/charts/AreaPlot/AreaPlot.cjs +2 -0
  55. package/dist/components/charts/AreaPlot/AreaPlot.cjs.map +1 -0
  56. package/dist/components/charts/AreaPlot/AreaPlot.js +270 -0
  57. package/dist/components/charts/AreaPlot/AreaPlot.js.map +1 -0
  58. package/dist/components/charts/BarChart/BarChart.cjs +2 -0
  59. package/dist/components/charts/BarChart/BarChart.cjs.map +1 -0
  60. package/dist/components/charts/BarChart/BarChart.js +219 -0
  61. package/dist/components/charts/BarChart/BarChart.js.map +1 -0
  62. package/dist/components/charts/BoxPlot/BoxPlot.cjs +2 -0
  63. package/dist/components/charts/BoxPlot/BoxPlot.cjs.map +1 -0
  64. package/dist/components/charts/{Boxplot/Boxplot.js → BoxPlot/BoxPlot.js} +78 -79
  65. package/dist/components/charts/BoxPlot/BoxPlot.js.map +1 -0
  66. package/dist/components/charts/ChartTooltip/ChartTooltip.cjs +1 -1
  67. package/dist/components/charts/ChartTooltip/ChartTooltip.cjs.map +1 -1
  68. package/dist/components/charts/ChartTooltip/ChartTooltip.js +22 -22
  69. package/dist/components/charts/ChartTooltip/ChartTooltip.js.map +1 -1
  70. package/dist/components/charts/Chromatogram/Chromatogram.cjs +1 -1
  71. package/dist/components/charts/Chromatogram/Chromatogram.cjs.map +1 -1
  72. package/dist/components/charts/Chromatogram/Chromatogram.js +232 -170
  73. package/dist/components/charts/Chromatogram/Chromatogram.js.map +1 -1
  74. package/dist/components/charts/Chromatogram/annotations.cjs +2 -0
  75. package/dist/components/charts/Chromatogram/annotations.cjs.map +1 -0
  76. package/dist/components/charts/Chromatogram/annotations.js +137 -0
  77. package/dist/components/charts/Chromatogram/annotations.js.map +1 -0
  78. package/dist/components/charts/Chromatogram/boundaryMarkers.cjs.map +1 -0
  79. package/dist/components/charts/Chromatogram/boundaryMarkers.js.map +1 -0
  80. package/dist/components/charts/Chromatogram/constants.cjs.map +1 -0
  81. package/dist/components/charts/Chromatogram/constants.js.map +1 -0
  82. package/dist/components/charts/Chromatogram/dataProcessing.cjs.map +1 -0
  83. package/dist/components/charts/Chromatogram/dataProcessing.js.map +1 -0
  84. package/dist/components/charts/Chromatogram/peakDetection.cjs.map +1 -0
  85. package/dist/components/charts/Chromatogram/peakDetection.js.map +1 -0
  86. package/dist/components/charts/Chromatogram/plotBuilder.cjs +2 -0
  87. package/dist/components/charts/Chromatogram/plotBuilder.cjs.map +1 -0
  88. package/dist/components/charts/Chromatogram/plotBuilder.js +216 -0
  89. package/dist/components/charts/Chromatogram/plotBuilder.js.map +1 -0
  90. package/dist/components/charts/Chromatogram/regionOverlays.cjs.map +1 -0
  91. package/dist/components/charts/Chromatogram/regionOverlays.js.map +1 -0
  92. package/dist/components/charts/Electropherogram/Electropherogram.cjs +2 -0
  93. package/dist/components/charts/Electropherogram/Electropherogram.cjs.map +1 -0
  94. package/dist/components/charts/Electropherogram/Electropherogram.js +180 -0
  95. package/dist/components/charts/Electropherogram/Electropherogram.js.map +1 -0
  96. package/dist/components/charts/Histogram/Histogram.cjs +1 -1
  97. package/dist/components/charts/Histogram/Histogram.cjs.map +1 -1
  98. package/dist/components/charts/Histogram/Histogram.js +107 -108
  99. package/dist/components/charts/Histogram/Histogram.js.map +1 -1
  100. package/dist/components/charts/LinePlot/LinePlot.cjs +2 -0
  101. package/dist/components/charts/LinePlot/LinePlot.cjs.map +1 -0
  102. package/dist/components/charts/LinePlot/LinePlot.js +224 -0
  103. package/dist/components/charts/LinePlot/LinePlot.js.map +1 -0
  104. package/dist/components/charts/PieChart/PieChart.cjs +1 -1
  105. package/dist/components/charts/PieChart/PieChart.cjs.map +1 -1
  106. package/dist/components/charts/PieChart/PieChart.js +62 -61
  107. package/dist/components/charts/PieChart/PieChart.js.map +1 -1
  108. package/dist/components/charts/PlateMap/PlateMap.cjs +1 -1
  109. package/dist/components/charts/PlateMap/PlateMap.cjs.map +1 -1
  110. package/dist/components/charts/PlateMap/PlateMap.js +246 -242
  111. package/dist/components/charts/PlateMap/PlateMap.js.map +1 -1
  112. package/dist/components/charts/ScatterPlot/ScatterPlot.cjs +2 -0
  113. package/dist/components/charts/ScatterPlot/ScatterPlot.cjs.map +1 -0
  114. package/dist/components/charts/ScatterPlot/ScatterPlot.js +252 -0
  115. package/dist/components/charts/ScatterPlot/ScatterPlot.js.map +1 -0
  116. package/dist/components/charts/ScatterPlotInteractive/ScatterPlotInteractive.cjs +2 -0
  117. package/dist/components/charts/ScatterPlotInteractive/ScatterPlotInteractive.cjs.map +1 -0
  118. package/dist/components/charts/ScatterPlotInteractive/ScatterPlotInteractive.js +215 -0
  119. package/dist/components/charts/ScatterPlotInteractive/ScatterPlotInteractive.js.map +1 -0
  120. package/dist/components/charts/ScatterPlotInteractive/constants.cjs +2 -0
  121. package/dist/components/charts/ScatterPlotInteractive/constants.cjs.map +1 -0
  122. package/dist/components/charts/ScatterPlotInteractive/constants.js +38 -0
  123. package/dist/components/charts/ScatterPlotInteractive/constants.js.map +1 -0
  124. package/dist/components/charts/ScatterPlotInteractive/utils.cjs +2 -0
  125. package/dist/components/charts/ScatterPlotInteractive/utils.cjs.map +1 -0
  126. package/dist/components/charts/ScatterPlotInteractive/utils.js +261 -0
  127. package/dist/components/charts/ScatterPlotInteractive/utils.js.map +1 -0
  128. package/dist/components/charts/StackedChromatogram/StackedChromatogram.cjs +2 -0
  129. package/dist/components/charts/StackedChromatogram/StackedChromatogram.cjs.map +1 -0
  130. package/dist/components/charts/StackedChromatogram/StackedChromatogram.js +40 -0
  131. package/dist/components/charts/StackedChromatogram/StackedChromatogram.js.map +1 -0
  132. package/dist/components/charts/StackedChromatogram/transforms.cjs.map +1 -0
  133. package/dist/components/charts/StackedChromatogram/transforms.js.map +1 -0
  134. package/dist/components/charts/plotly-loader.cjs +2 -0
  135. package/dist/components/charts/plotly-loader.cjs.map +1 -0
  136. package/dist/components/charts/plotly-loader.js +22 -0
  137. package/dist/components/charts/plotly-loader.js.map +1 -0
  138. package/dist/components/composed/AssistantLayout/AssistantLayout.cjs +2 -0
  139. package/dist/components/composed/AssistantLayout/AssistantLayout.cjs.map +1 -0
  140. package/dist/components/composed/AssistantLayout/AssistantLayout.js +142 -0
  141. package/dist/components/composed/AssistantLayout/AssistantLayout.js.map +1 -0
  142. package/dist/components/composed/AssistantLayout/dockLayout.cjs +2 -0
  143. package/dist/components/composed/AssistantLayout/dockLayout.cjs.map +1 -0
  144. package/dist/components/composed/AssistantLayout/dockLayout.js +10 -0
  145. package/dist/components/composed/AssistantLayout/dockLayout.js.map +1 -0
  146. package/dist/components/composed/Chat/Chat.cjs +1 -1
  147. package/dist/components/composed/Chat/Chat.cjs.map +1 -1
  148. package/dist/components/composed/Chat/Chat.js +23 -23
  149. package/dist/components/composed/Chat/Chat.js.map +1 -1
  150. package/dist/components/composed/ConfirmDialog/ConfirmDialog.cjs +1 -1
  151. package/dist/components/composed/ConfirmDialog/ConfirmDialog.cjs.map +1 -1
  152. package/dist/components/composed/ConfirmDialog/ConfirmDialog.js +33 -29
  153. package/dist/components/composed/ConfirmDialog/ConfirmDialog.js.map +1 -1
  154. package/dist/components/composed/DataAppShell/CollapseButton.cjs +2 -0
  155. package/dist/components/composed/DataAppShell/CollapseButton.cjs.map +1 -0
  156. package/dist/components/composed/DataAppShell/CollapseButton.js +42 -0
  157. package/dist/components/composed/DataAppShell/CollapseButton.js.map +1 -0
  158. package/dist/components/composed/DataAppShell/DataAppShell.cjs +1 -1
  159. package/dist/components/composed/DataAppShell/DataAppShell.cjs.map +1 -1
  160. package/dist/components/composed/DataAppShell/DataAppShell.js +349 -313
  161. package/dist/components/composed/DataAppShell/DataAppShell.js.map +1 -1
  162. package/dist/components/composed/DataAppShell/PrimaryNav.cjs +2 -0
  163. package/dist/components/composed/DataAppShell/PrimaryNav.cjs.map +1 -0
  164. package/dist/components/composed/DataAppShell/PrimaryNav.js +268 -0
  165. package/dist/components/composed/DataAppShell/PrimaryNav.js.map +1 -0
  166. package/dist/components/composed/DataAppShell/RightPanel.cjs +2 -0
  167. package/dist/components/composed/DataAppShell/RightPanel.cjs.map +1 -0
  168. package/dist/components/composed/DataAppShell/RightPanel.js +282 -0
  169. package/dist/components/composed/DataAppShell/RightPanel.js.map +1 -0
  170. package/dist/components/composed/DataAppShell/SecondaryNav.cjs +2 -0
  171. package/dist/components/composed/DataAppShell/SecondaryNav.cjs.map +1 -0
  172. package/dist/components/composed/DataAppShell/SecondaryNav.js +364 -0
  173. package/dist/components/composed/DataAppShell/SecondaryNav.js.map +1 -0
  174. package/dist/components/composed/DataAppShell/ShellContext.cjs +2 -0
  175. package/dist/components/composed/DataAppShell/ShellContext.cjs.map +1 -0
  176. package/dist/components/composed/DataAppShell/ShellContext.js +23 -0
  177. package/dist/components/composed/DataAppShell/ShellContext.js.map +1 -0
  178. package/dist/components/composed/MoleculeStructure/MoleculeStructure.cjs +2 -0
  179. package/dist/components/composed/MoleculeStructure/MoleculeStructure.cjs.map +1 -0
  180. package/dist/components/composed/MoleculeStructure/MoleculeStructure.js +87 -0
  181. package/dist/components/composed/MoleculeStructure/MoleculeStructure.js.map +1 -0
  182. package/dist/components/composed/MoleculeStructure/rdkit-loader.cjs +2 -0
  183. package/dist/components/composed/MoleculeStructure/rdkit-loader.cjs.map +1 -0
  184. package/dist/components/composed/MoleculeStructure/rdkit-loader.js +89 -0
  185. package/dist/components/composed/MoleculeStructure/rdkit-loader.js.map +1 -0
  186. package/dist/components/composed/MoleculeStructure/use-rdkit.cjs +2 -0
  187. package/dist/components/composed/MoleculeStructure/use-rdkit.cjs.map +1 -0
  188. package/dist/components/composed/MoleculeStructure/use-rdkit.js +19 -0
  189. package/dist/components/composed/MoleculeStructure/use-rdkit.js.map +1 -0
  190. package/dist/components/composed/PlateMapEditor/ManifestFilterPopover.cjs +1 -1
  191. package/dist/components/composed/PlateMapEditor/ManifestFilterPopover.cjs.map +1 -1
  192. package/dist/components/composed/PlateMapEditor/ManifestFilterPopover.js +17 -17
  193. package/dist/components/composed/PlateMapEditor/ManifestFilterPopover.js.map +1 -1
  194. package/dist/components/composed/PlateMapEditor/PlateMapActionsMenu.cjs +1 -1
  195. package/dist/components/composed/PlateMapEditor/PlateMapActionsMenu.cjs.map +1 -1
  196. package/dist/components/composed/PlateMapEditor/PlateMapActionsMenu.js +33 -33
  197. package/dist/components/composed/PlateMapEditor/PlateMapActionsMenu.js.map +1 -1
  198. package/dist/components/composed/PlateMapEditor/PlateMapPlateSelector.cjs +1 -1
  199. package/dist/components/composed/PlateMapEditor/PlateMapPlateSelector.cjs.map +1 -1
  200. package/dist/components/composed/PlateMapEditor/PlateMapPlateSelector.js +7 -7
  201. package/dist/components/composed/PlateMapEditor/PlateMapPlateSelector.js.map +1 -1
  202. package/dist/components/composed/PlateMapEditor/PlatePaintGrid.cjs +1 -1
  203. package/dist/components/composed/PlateMapEditor/PlatePaintGrid.cjs.map +1 -1
  204. package/dist/components/composed/PlateMapEditor/PlatePaintGrid.js +1 -1
  205. package/dist/components/composed/PlateMapEditor/PlatePaintGrid.js.map +1 -1
  206. package/dist/components/composed/PlateMapEditor/WellLegend.cjs +1 -1
  207. package/dist/components/composed/PlateMapEditor/WellLegend.cjs.map +1 -1
  208. package/dist/components/composed/PlateMapEditor/WellLegend.js +24 -12
  209. package/dist/components/composed/PlateMapEditor/WellLegend.js.map +1 -1
  210. package/dist/components/composed/PlateMapEditor/WellManifestTable.cjs +1 -1
  211. package/dist/components/composed/PlateMapEditor/WellManifestTable.cjs.map +1 -1
  212. package/dist/components/composed/PlateMapEditor/WellManifestTable.js +1 -1
  213. package/dist/components/composed/PlateMapEditor/WellManifestTable.js.map +1 -1
  214. package/dist/components/composed/TdpSearch/components/DefaultFilters.cjs +1 -1
  215. package/dist/components/composed/TdpSearch/components/DefaultFilters.cjs.map +1 -1
  216. package/dist/components/composed/TdpSearch/components/DefaultFilters.js +3 -3
  217. package/dist/components/composed/TdpSearch/components/DefaultFilters.js.map +1 -1
  218. package/dist/components/composed/TopBar/TopBar.cjs +2 -0
  219. package/dist/components/composed/TopBar/TopBar.cjs.map +1 -0
  220. package/dist/components/composed/TopBar/TopBar.js +56 -0
  221. package/dist/components/composed/TopBar/TopBar.js.map +1 -0
  222. package/dist/components/composed/UserMenu/UserMenu.cjs +2 -0
  223. package/dist/components/composed/UserMenu/UserMenu.cjs.map +1 -0
  224. package/dist/components/composed/UserMenu/UserMenu.js +99 -0
  225. package/dist/components/composed/UserMenu/UserMenu.js.map +1 -0
  226. package/dist/components/composed/tdp-link.cjs +1 -1
  227. package/dist/components/composed/tdp-link.cjs.map +1 -1
  228. package/dist/components/composed/tdp-link.js +5 -5
  229. package/dist/components/composed/tdp-link.js.map +1 -1
  230. package/dist/components/ui/alert.cjs +1 -1
  231. package/dist/components/ui/alert.cjs.map +1 -1
  232. package/dist/components/ui/alert.js +12 -12
  233. package/dist/components/ui/alert.js.map +1 -1
  234. package/dist/components/ui/badge.cjs +1 -1
  235. package/dist/components/ui/badge.cjs.map +1 -1
  236. package/dist/components/ui/badge.js +14 -14
  237. package/dist/components/ui/badge.js.map +1 -1
  238. package/dist/components/ui/banner.cjs +1 -1
  239. package/dist/components/ui/banner.cjs.map +1 -1
  240. package/dist/components/ui/banner.js +17 -17
  241. package/dist/components/ui/banner.js.map +1 -1
  242. package/dist/components/ui/button.cjs +1 -1
  243. package/dist/components/ui/button.cjs.map +1 -1
  244. package/dist/components/ui/button.js +16 -16
  245. package/dist/components/ui/button.js.map +1 -1
  246. package/dist/components/ui/calendar.cjs +1 -1
  247. package/dist/components/ui/calendar.cjs.map +1 -1
  248. package/dist/components/ui/calendar.js +3 -3
  249. package/dist/components/ui/calendar.js.map +1 -1
  250. package/dist/components/ui/code-block.cjs +3 -3
  251. package/dist/components/ui/code-block.cjs.map +1 -1
  252. package/dist/components/ui/code-block.js +136 -118
  253. package/dist/components/ui/code-block.js.map +1 -1
  254. package/dist/components/ui/code-editor.cjs +1 -1
  255. package/dist/components/ui/code-editor.cjs.map +1 -1
  256. package/dist/components/ui/code-editor.js +14 -12
  257. package/dist/components/ui/code-editor.js.map +1 -1
  258. package/dist/components/ui/combobox.cjs +1 -1
  259. package/dist/components/ui/combobox.cjs.map +1 -1
  260. package/dist/components/ui/combobox.js +33 -29
  261. package/dist/components/ui/combobox.js.map +1 -1
  262. package/dist/components/ui/command.cjs +1 -1
  263. package/dist/components/ui/command.cjs.map +1 -1
  264. package/dist/components/ui/command.js +81 -77
  265. package/dist/components/ui/command.js.map +1 -1
  266. package/dist/components/ui/context-menu.cjs +1 -1
  267. package/dist/components/ui/context-menu.cjs.map +1 -1
  268. package/dist/components/ui/context-menu.js +13 -13
  269. package/dist/components/ui/context-menu.js.map +1 -1
  270. package/dist/components/ui/data-table/data-table-column-toggle.cjs +1 -1
  271. package/dist/components/ui/data-table/data-table-column-toggle.cjs.map +1 -1
  272. package/dist/components/ui/data-table/data-table-column-toggle.js +70 -62
  273. package/dist/components/ui/data-table/data-table-column-toggle.js.map +1 -1
  274. package/dist/components/ui/data-table/data-table-filter.cjs +1 -1
  275. package/dist/components/ui/data-table/data-table-filter.cjs.map +1 -1
  276. package/dist/components/ui/data-table/data-table-filter.js +24 -23
  277. package/dist/components/ui/data-table/data-table-filter.js.map +1 -1
  278. package/dist/components/ui/data-table/data-table-group.cjs +1 -1
  279. package/dist/components/ui/data-table/data-table-group.cjs.map +1 -1
  280. package/dist/components/ui/data-table/data-table-group.js +17 -16
  281. package/dist/components/ui/data-table/data-table-group.js.map +1 -1
  282. package/dist/components/ui/data-table/data-table-pagination.cjs +1 -1
  283. package/dist/components/ui/data-table/data-table-pagination.cjs.map +1 -1
  284. package/dist/components/ui/data-table/data-table-pagination.js +15 -15
  285. package/dist/components/ui/data-table/data-table-pagination.js.map +1 -1
  286. package/dist/components/ui/data-table/data-table.cjs +1 -1
  287. package/dist/components/ui/data-table/data-table.cjs.map +1 -1
  288. package/dist/components/ui/data-table/data-table.js +191 -190
  289. package/dist/components/ui/data-table/data-table.js.map +1 -1
  290. package/dist/components/ui/dialog.cjs +1 -1
  291. package/dist/components/ui/dialog.cjs.map +1 -1
  292. package/dist/components/ui/dialog.js +1 -1
  293. package/dist/components/ui/dialog.js.map +1 -1
  294. package/dist/components/ui/dropdown-menu.cjs +1 -1
  295. package/dist/components/ui/dropdown-menu.cjs.map +1 -1
  296. package/dist/components/ui/dropdown-menu.js +12 -4
  297. package/dist/components/ui/dropdown-menu.js.map +1 -1
  298. package/dist/components/ui/hover-card.cjs +1 -1
  299. package/dist/components/ui/hover-card.cjs.map +1 -1
  300. package/dist/components/ui/hover-card.js +3 -3
  301. package/dist/components/ui/hover-card.js.map +1 -1
  302. package/dist/components/ui/item.cjs +1 -1
  303. package/dist/components/ui/item.cjs.map +1 -1
  304. package/dist/components/ui/item.js +44 -36
  305. package/dist/components/ui/item.js.map +1 -1
  306. package/dist/components/ui/menubar.cjs +1 -1
  307. package/dist/components/ui/menubar.cjs.map +1 -1
  308. package/dist/components/ui/menubar.js +2 -2
  309. package/dist/components/ui/menubar.js.map +1 -1
  310. package/dist/components/ui/navigation-menu.cjs +1 -1
  311. package/dist/components/ui/navigation-menu.cjs.map +1 -1
  312. package/dist/components/ui/navigation-menu.js +1 -1
  313. package/dist/components/ui/navigation-menu.js.map +1 -1
  314. package/dist/components/ui/popover.cjs +1 -1
  315. package/dist/components/ui/popover.cjs.map +1 -1
  316. package/dist/components/ui/popover.js +1 -1
  317. package/dist/components/ui/popover.js.map +1 -1
  318. package/dist/components/ui/scroll-area.cjs +1 -1
  319. package/dist/components/ui/scroll-area.cjs.map +1 -1
  320. package/dist/components/ui/scroll-area.js +1 -0
  321. package/dist/components/ui/scroll-area.js.map +1 -1
  322. package/dist/components/ui/select.cjs +1 -1
  323. package/dist/components/ui/select.cjs.map +1 -1
  324. package/dist/components/ui/select.js +1 -1
  325. package/dist/components/ui/select.js.map +1 -1
  326. package/dist/components/ui/sheet.cjs +1 -1
  327. package/dist/components/ui/sheet.cjs.map +1 -1
  328. package/dist/components/ui/sheet.js +5 -5
  329. package/dist/components/ui/sheet.js.map +1 -1
  330. package/dist/components/ui/sidebar.cjs +1 -1
  331. package/dist/components/ui/sidebar.cjs.map +1 -1
  332. package/dist/components/ui/sidebar.js +2 -2
  333. package/dist/components/ui/sidebar.js.map +1 -1
  334. package/dist/components/ui/slider.cjs +1 -1
  335. package/dist/components/ui/slider.cjs.map +1 -1
  336. package/dist/components/ui/slider.js +10 -9
  337. package/dist/components/ui/slider.js.map +1 -1
  338. package/dist/components/ui/sonner.cjs +1 -1
  339. package/dist/components/ui/sonner.cjs.map +1 -1
  340. package/dist/components/ui/sonner.js +25 -10
  341. package/dist/components/ui/sonner.js.map +1 -1
  342. package/dist/components/ui/table.cjs +1 -1
  343. package/dist/components/ui/table.cjs.map +1 -1
  344. package/dist/components/ui/table.js +1 -0
  345. package/dist/components/ui/table.js.map +1 -1
  346. package/dist/components/ui/tabs.cjs +1 -1
  347. package/dist/components/ui/tabs.cjs.map +1 -1
  348. package/dist/components/ui/tabs.js +18 -18
  349. package/dist/components/ui/tabs.js.map +1 -1
  350. package/dist/components/ui/tetra-molecule-icon.cjs +2 -0
  351. package/dist/components/ui/tetra-molecule-icon.cjs.map +1 -0
  352. package/dist/components/ui/tetra-molecule-icon.js +49 -0
  353. package/dist/components/ui/tetra-molecule-icon.js.map +1 -0
  354. package/dist/components/ui/toggle-group.cjs +1 -1
  355. package/dist/components/ui/toggle-group.cjs.map +1 -1
  356. package/dist/components/ui/toggle-group.js +35 -31
  357. package/dist/components/ui/toggle-group.js.map +1 -1
  358. package/dist/hooks/use-plotly-theme.cjs +1 -1
  359. package/dist/hooks/use-plotly-theme.cjs.map +1 -1
  360. package/dist/hooks/use-plotly-theme.js +4 -3
  361. package/dist/hooks/use-plotly-theme.js.map +1 -1
  362. package/dist/index.cjs +1 -1
  363. package/dist/index.css +1 -1
  364. package/dist/index.d.ts +1073 -136
  365. package/dist/index.js +698 -647
  366. package/dist/index.js.map +1 -1
  367. package/dist/index.tailwind.css +1 -1
  368. package/dist/lib/shiki.cjs +2 -0
  369. package/dist/lib/shiki.cjs.map +1 -0
  370. package/dist/lib/shiki.js +72 -0
  371. package/dist/lib/shiki.js.map +1 -0
  372. package/package.json +23 -12
  373. package/dist/components/charts/AreaGraph/AreaGraph.cjs +0 -2
  374. package/dist/components/charts/AreaGraph/AreaGraph.cjs.map +0 -1
  375. package/dist/components/charts/AreaGraph/AreaGraph.js +0 -271
  376. package/dist/components/charts/AreaGraph/AreaGraph.js.map +0 -1
  377. package/dist/components/charts/BarGraph/BarGraph.cjs +0 -2
  378. package/dist/components/charts/BarGraph/BarGraph.cjs.map +0 -1
  379. package/dist/components/charts/BarGraph/BarGraph.js +0 -220
  380. package/dist/components/charts/BarGraph/BarGraph.js.map +0 -1
  381. package/dist/components/charts/Boxplot/Boxplot.cjs +0 -2
  382. package/dist/components/charts/Boxplot/Boxplot.cjs.map +0 -1
  383. package/dist/components/charts/Boxplot/Boxplot.js.map +0 -1
  384. package/dist/components/charts/ChromatogramChart/ChromatogramChart.cjs +0 -2
  385. package/dist/components/charts/ChromatogramChart/ChromatogramChart.cjs.map +0 -1
  386. package/dist/components/charts/ChromatogramChart/ChromatogramChart.js +0 -241
  387. package/dist/components/charts/ChromatogramChart/ChromatogramChart.js.map +0 -1
  388. package/dist/components/charts/ChromatogramChart/annotations.cjs +0 -2
  389. package/dist/components/charts/ChromatogramChart/annotations.cjs.map +0 -1
  390. package/dist/components/charts/ChromatogramChart/annotations.js +0 -136
  391. package/dist/components/charts/ChromatogramChart/annotations.js.map +0 -1
  392. package/dist/components/charts/ChromatogramChart/boundaryMarkers.cjs.map +0 -1
  393. package/dist/components/charts/ChromatogramChart/boundaryMarkers.js.map +0 -1
  394. package/dist/components/charts/ChromatogramChart/constants.cjs.map +0 -1
  395. package/dist/components/charts/ChromatogramChart/constants.js.map +0 -1
  396. package/dist/components/charts/ChromatogramChart/dataProcessing.cjs.map +0 -1
  397. package/dist/components/charts/ChromatogramChart/dataProcessing.js.map +0 -1
  398. package/dist/components/charts/ChromatogramChart/peakDetection.cjs.map +0 -1
  399. package/dist/components/charts/ChromatogramChart/peakDetection.js.map +0 -1
  400. package/dist/components/charts/ChromatogramChart/plotBuilder.cjs +0 -2
  401. package/dist/components/charts/ChromatogramChart/plotBuilder.cjs.map +0 -1
  402. package/dist/components/charts/ChromatogramChart/plotBuilder.js +0 -207
  403. package/dist/components/charts/ChromatogramChart/plotBuilder.js.map +0 -1
  404. package/dist/components/charts/ChromatogramChart/regionOverlays.cjs.map +0 -1
  405. package/dist/components/charts/ChromatogramChart/regionOverlays.js.map +0 -1
  406. package/dist/components/charts/DotPlot/DotPlot.cjs +0 -2
  407. package/dist/components/charts/DotPlot/DotPlot.cjs.map +0 -1
  408. package/dist/components/charts/DotPlot/DotPlot.js +0 -208
  409. package/dist/components/charts/DotPlot/DotPlot.js.map +0 -1
  410. package/dist/components/charts/Heatmap/Heatmap.cjs +0 -2
  411. package/dist/components/charts/Heatmap/Heatmap.cjs.map +0 -1
  412. package/dist/components/charts/Heatmap/Heatmap.js +0 -67
  413. package/dist/components/charts/Heatmap/Heatmap.js.map +0 -1
  414. package/dist/components/charts/LineGraph/LineGraph.cjs +0 -2
  415. package/dist/components/charts/LineGraph/LineGraph.cjs.map +0 -1
  416. package/dist/components/charts/LineGraph/LineGraph.js +0 -225
  417. package/dist/components/charts/LineGraph/LineGraph.js.map +0 -1
  418. package/dist/components/charts/ScatterGraph/ScatterGraph.cjs +0 -2
  419. package/dist/components/charts/ScatterGraph/ScatterGraph.cjs.map +0 -1
  420. package/dist/components/charts/ScatterGraph/ScatterGraph.js +0 -234
  421. package/dist/components/charts/ScatterGraph/ScatterGraph.js.map +0 -1
  422. package/dist/components/charts/StackedChromatogramChart/StackedChromatogramChart.cjs +0 -2
  423. package/dist/components/charts/StackedChromatogramChart/StackedChromatogramChart.cjs.map +0 -1
  424. package/dist/components/charts/StackedChromatogramChart/StackedChromatogramChart.js +0 -40
  425. package/dist/components/charts/StackedChromatogramChart/StackedChromatogramChart.js.map +0 -1
  426. package/dist/components/charts/StackedChromatogramChart/transforms.cjs.map +0 -1
  427. package/dist/components/charts/StackedChromatogramChart/transforms.js.map +0 -1
  428. /package/dist/components/charts/{ChromatogramChart → Chromatogram}/boundaryMarkers.cjs +0 -0
  429. /package/dist/components/charts/{ChromatogramChart → Chromatogram}/boundaryMarkers.js +0 -0
  430. /package/dist/components/charts/{ChromatogramChart → Chromatogram}/constants.cjs +0 -0
  431. /package/dist/components/charts/{ChromatogramChart → Chromatogram}/constants.js +0 -0
  432. /package/dist/components/charts/{ChromatogramChart → Chromatogram}/dataProcessing.cjs +0 -0
  433. /package/dist/components/charts/{ChromatogramChart → Chromatogram}/dataProcessing.js +0 -0
  434. /package/dist/components/charts/{ChromatogramChart → Chromatogram}/peakDetection.cjs +0 -0
  435. /package/dist/components/charts/{ChromatogramChart → Chromatogram}/peakDetection.js +0 -0
  436. /package/dist/components/charts/{ChromatogramChart → Chromatogram}/regionOverlays.cjs +0 -0
  437. /package/dist/components/charts/{ChromatogramChart → Chromatogram}/regionOverlays.js +0 -0
  438. /package/dist/components/charts/{StackedChromatogramChart → StackedChromatogram}/transforms.cjs +0 -0
  439. /package/dist/components/charts/{StackedChromatogramChart → StackedChromatogram}/transforms.js +0 -0
@@ -1,67 +1,67 @@
1
- import { jsxs as I, jsx as u } from "react/jsx-runtime";
2
- import A from "plotly.js-dist";
3
- import G, { useRef as k, useMemo as x, useEffect as V } from "react";
4
- import { useChartTooltip as J } from "../ChartTooltip/ChartTooltip.js";
5
- import { useElementSize as K } from "../../../hooks/use-element-size.js";
6
- import { usePlotlyTheme as Q } from "../../../hooks/use-plotly-theme.js";
7
- import { cn as _ } from "../../../lib/utils.js";
8
- import { CHART_COLORS as Z } from "../../../utils/colors.js";
1
+ import { jsxs as _, jsx as d } from "react/jsx-runtime";
2
+ import J, { useRef as k, useMemo as y, useEffect as V } from "react";
3
+ import { useChartTooltip as K } from "../ChartTooltip/ChartTooltip.js";
4
+ import { loadPlotly as Q, getLoadedPlotly as j } from "../plotly-loader.js";
5
+ import { useElementSize as Z } from "../../../hooks/use-element-size.js";
6
+ import { usePlotlyTheme as tt, CHART_FONT_FAMILY as E } from "../../../hooks/use-plotly-theme.js";
7
+ import { cn as F } from "../../../lib/utils.js";
8
+ import { CHART_COLORS as ot } from "../../../utils/colors.js";
9
9
  /* empty css */
10
- const tt = -0.5, ot = (r) => r.reduce((e, s) => e + s, 0) / r.length, et = (r, c) => {
11
- const s = r.map((i) => Math.pow(i - c, 2)).reduce((i, a) => i + a, 0) / r.length;
12
- return Math.sqrt(s);
13
- }, nt = (r, c, e, s, i = 100) => {
14
- const a = [], p = [], g = (s - e) / (i - 1);
15
- for (let n = 0; n < i; n++) {
16
- const o = e + n * g;
17
- a.push(o);
18
- const b = tt * Math.pow((o - r) / c, 2), z = 1 / (c * Math.sqrt(2 * Math.PI)) * Math.exp(b);
19
- p.push(z);
10
+ const et = -0.5, nt = (r) => r.reduce((n, a) => n + a, 0) / r.length, rt = (r, l) => {
11
+ const a = r.map((c) => Math.pow(c - l, 2)).reduce((c, s) => c + s, 0) / r.length;
12
+ return Math.sqrt(a);
13
+ }, it = (r, l, n, a, c = 100) => {
14
+ const s = [], g = [], x = (a - n) / (c - 1);
15
+ for (let o = 0; o < c; o++) {
16
+ const e = n + o * x;
17
+ s.push(e);
18
+ const b = et * Math.pow((e - r) / l, 2), z = 1 / (l * Math.sqrt(2 * Math.PI)) * Math.exp(b);
19
+ g.push(z);
20
20
  }
21
- return { x: a, y: p };
22
- }, rt = (r, c, e) => {
23
- const s = Math.ceil((e.end - e.start) / e.size), i = Array(s).fill(0);
24
- c.forEach((n) => {
25
- if (n >= e.start && n <= e.end) {
26
- const o = Math.floor((n - e.start) / e.size);
27
- i[o]++;
21
+ return { x: s, y: g };
22
+ }, ct = (r, l, n) => {
23
+ const a = Math.ceil((n.end - n.start) / n.size), c = Array(a).fill(0);
24
+ l.forEach((o) => {
25
+ if (o >= n.start && o <= n.end) {
26
+ const e = Math.floor((o - n.start) / n.size);
27
+ c[e]++;
28
28
  }
29
29
  });
30
- const a = Math.max(...i), p = Math.max(...r), g = a / p;
31
- return r.map((n) => n * g);
32
- }, ft = ({
30
+ const s = Math.max(...c), g = Math.max(...r), x = s / g;
31
+ return r.map((o) => o * x);
32
+ }, gt = ({
33
33
  dataSeries: r,
34
- width: c,
35
- height: e,
36
- title: s = "Histogram",
37
- xTitle: i = "X Axis",
38
- yTitle: a = "Frequency",
39
- bargap: p = 0.2,
40
- showDistributionLine: g = !1
34
+ width: l,
35
+ height: n,
36
+ title: a = "Histogram",
37
+ xTitle: c = "X Axis",
38
+ yTitle: s = "Frequency",
39
+ bargap: g = 0.2,
40
+ showDistributionLine: x = !1
41
41
  }) => {
42
- const n = k(null), o = Q(), { bindTooltip: b, tooltipElement: z } = J({ xLabel: i, yLabel: a }), [j, q] = K(), m = c ?? q.width, f = e ?? q.height, B = m > 0 && f > 0, X = c === void 0, D = e === void 0, M = k({ width: m, height: f });
43
- M.current = { width: m, height: f };
44
- const R = k(!1), C = k({ width: 0, height: 0 }), N = x(
42
+ const o = k(null), e = tt(), { bindTooltip: b, tooltipElement: z } = K({ xLabel: c, yLabel: s }), [X, P] = Z(), f = l ?? P.width, p = n ?? P.height, q = f > 0 && p > 0, Y = l === void 0, D = n === void 0, M = k({ width: f, height: p });
43
+ M.current = { width: f, height: p };
44
+ const L = k(!1), C = k({ width: 0, height: 0 }), N = y(
45
45
  () => Array.isArray(r) ? r : [r],
46
46
  [r]
47
- ), F = x(() => N.length > 1 ? "stack" : void 0, [N.length]), L = Z, y = x(() => N.map((t, d) => {
48
- const h = typeof t.showDistributionLine > "u" ? g : t.showDistributionLine;
47
+ ), B = y(() => N.length > 1 ? "stack" : void 0, [N.length]), R = ot, v = y(() => N.map((t, u) => {
48
+ const h = typeof t.showDistributionLine > "u" ? x : t.showDistributionLine;
49
49
  return {
50
50
  ...t,
51
- color: t.color || L[d % L.length],
51
+ color: t.color || R[u % R.length],
52
52
  opacity: h ? 0.5 : t.opacity || 1,
53
53
  showDistributionLine: h,
54
54
  lineWidth: t.lineWidth || 3
55
55
  };
56
- }), [N, g, L]), E = o.gridColor, P = x(
57
- () => y.map((t) => ({
56
+ }), [N, x, R]), A = e.gridColor, I = y(
57
+ () => v.map((t) => ({
58
58
  type: "histogram",
59
59
  x: t.x,
60
60
  name: t.name,
61
61
  marker: {
62
62
  color: t.color,
63
63
  line: {
64
- color: o.paperBg,
64
+ color: e.paperBg,
65
65
  width: 1
66
66
  },
67
67
  opacity: t.opacity
@@ -70,28 +70,28 @@ const tt = -0.5, ot = (r) => r.reduce((e, s) => e + s, 0) / r.length, et = (r, c
70
70
  xbins: t.xbins,
71
71
  hoverinfo: "none"
72
72
  })),
73
- [y, o]
74
- ), O = x(
75
- () => y.filter((t) => t.showDistributionLine).map((t) => {
76
- const d = ot(t.x), h = et(t.x, d), w = Math.min(...t.x), l = Math.max(...t.x), v = l - w, W = w - v * 0.1, H = l + v * 0.1, Y = t.xbins || {
77
- start: W,
78
- end: H,
79
- size: v / 10
80
- }, T = nt(
81
- d,
73
+ [v, e]
74
+ ), O = y(
75
+ () => v.filter((t) => t.showDistributionLine).map((t) => {
76
+ const u = nt(t.x), h = rt(t.x, u), m = Math.min(...t.x), i = Math.max(...t.x), w = i - m, S = m - w * 0.1, W = i + w * 0.1, $ = t.xbins || {
77
+ start: S,
78
+ end: W,
79
+ size: w / 10
80
+ }, T = it(
81
+ u,
82
82
  h,
83
+ S,
83
84
  W,
84
- H,
85
85
  100
86
- ), $ = rt(
86
+ ), G = ct(
87
87
  T.y,
88
88
  t.x,
89
- Y
89
+ $
90
90
  );
91
91
  return {
92
92
  type: "scatter",
93
93
  x: T.x,
94
- y: $,
94
+ y: G,
95
95
  mode: "lines",
96
96
  name: `${t.name} Distribution`,
97
97
  line: {
@@ -101,111 +101,110 @@ const tt = -0.5, ot = (r) => r.reduce((e, s) => e + s, 0) / r.length, et = (r, c
101
101
  hoverinfo: "none"
102
102
  };
103
103
  }),
104
- [y]
105
- ), S = x(
106
- () => [...P, ...O],
107
- [P, O]
104
+ [v]
105
+ ), H = y(
106
+ () => [...I, ...O],
107
+ [I, O]
108
108
  );
109
109
  V(() => {
110
- if (!n.current || !B) return;
110
+ if (!o.current || !q) return;
111
111
  const t = {
112
112
  width: M.current.width,
113
113
  height: M.current.height,
114
114
  font: {
115
- family: "Inter, sans-serif"
115
+ family: E
116
116
  },
117
117
  showlegend: !1,
118
118
  margin: { l: 90, r: 40, b: 80, t: 40 },
119
119
  xaxis: {
120
120
  title: {
121
- text: i,
121
+ text: c,
122
122
  font: {
123
123
  size: 16,
124
- color: o.textSecondary,
125
- family: "Inter, sans-serif",
124
+ color: e.textSecondary,
125
+ family: E,
126
126
  weight: 400
127
127
  },
128
128
  standoff: 20
129
129
  },
130
- gridcolor: E,
131
- tickcolor: o.tickColor,
130
+ gridcolor: A,
131
+ tickcolor: e.tickColor,
132
132
  ticklen: 8,
133
133
  tickwidth: 1,
134
134
  ticks: "outside",
135
- linecolor: o.lineColor,
135
+ linecolor: e.lineColor,
136
136
  linewidth: 1,
137
137
  zeroline: !1,
138
138
  automargin: !0
139
139
  },
140
140
  yaxis: {
141
141
  title: {
142
- text: a,
142
+ text: s,
143
143
  font: {
144
144
  size: 16,
145
- color: o.textSecondary,
146
- family: "Inter, sans-serif",
145
+ color: e.textSecondary,
146
+ family: E,
147
147
  weight: 400
148
148
  },
149
149
  standoff: 20
150
150
  },
151
- gridcolor: E,
152
- tickcolor: o.tickColor,
151
+ gridcolor: A,
152
+ tickcolor: e.tickColor,
153
153
  ticklen: 8,
154
154
  tickwidth: 1,
155
155
  ticks: "outside",
156
- linecolor: o.lineColor,
156
+ linecolor: e.lineColor,
157
157
  linewidth: 1,
158
158
  zeroline: !1,
159
159
  rangemode: "tozero",
160
160
  automargin: !0
161
161
  },
162
- barmode: F,
163
- bargap: p,
164
- paper_bgcolor: o.paperBg,
165
- plot_bgcolor: o.plotBg
166
- }, d = {
162
+ barmode: B,
163
+ bargap: g,
164
+ paper_bgcolor: e.paperBg,
165
+ plot_bgcolor: e.plotBg
166
+ }, u = {
167
167
  // Sizing is driven from the measured container; disable Plotly's own
168
168
  // window-resize responsiveness (it can't see container resizes).
169
169
  responsive: !1,
170
170
  displayModeBar: !1,
171
171
  displaylogo: !1
172
172
  };
173
- A.newPlot(n.current, S, t, d), b(n.current);
174
- const h = n.current;
175
- return R.current = !0, C.current = { ...M.current }, () => {
176
- h && (A.purge(h), R.current = !1);
173
+ let h = !1, m = null;
174
+ return Q().then((i) => {
175
+ h || !o.current || (i.newPlot(o.current, H, t, u), b(o.current), m = o.current, L.current = !0, C.current = { ...M.current });
176
+ }), () => {
177
+ h = !0, m && (j().purge(m), L.current = !1);
177
178
  };
178
- }, [B, i, a, p, S, F, E, o, b]), V(() => {
179
- const t = n.current;
180
- !t || !R.current || m <= 0 || f <= 0 || C.current.width === m && C.current.height === f || (C.current = { width: m, height: f }, A.relayout(t, { width: m, height: f }).catch(
181
- () => {
182
- }
183
- ));
184
- }, [m, f]);
179
+ }, [q, c, s, g, H, B, A, e, b]), V(() => {
180
+ const t = o.current;
181
+ !t || !L.current || f <= 0 || p <= 0 || C.current.width === f && C.current.height === p || (C.current = { width: f, height: p }, j().relayout(t, { width: f, height: p }).catch(() => {
182
+ }));
183
+ }, [f, p]);
185
184
  const U = ({ series: t }) => {
186
- const d = t.map((l, v) => /* @__PURE__ */ u(G.Fragment, { children: /* @__PURE__ */ I("div", { className: "legend-item", children: [
187
- /* @__PURE__ */ u("span", { className: "color-box", style: { background: l.color } }),
188
- l.name,
189
- v < t.length - 1 && /* @__PURE__ */ u("span", { className: "divider" })
190
- ] }) }, l.name)), h = [], w = 6;
191
- for (let l = 0; l < d.length; l += w)
185
+ const u = t.map((i, w) => /* @__PURE__ */ d(J.Fragment, { children: /* @__PURE__ */ _("div", { className: "legend-item", children: [
186
+ /* @__PURE__ */ d("span", { className: "color-box", style: { background: i.color } }),
187
+ i.name,
188
+ w < t.length - 1 && /* @__PURE__ */ d("span", { className: "divider" })
189
+ ] }) }, i.name)), h = [], m = 6;
190
+ for (let i = 0; i < u.length; i += m)
192
191
  h.push(
193
- /* @__PURE__ */ u("div", { className: "legend-row", children: d.slice(l, l + w) }, l)
192
+ /* @__PURE__ */ d("div", { className: "legend-row", children: u.slice(i, i + m) }, i)
194
193
  );
195
- return /* @__PURE__ */ u("div", { className: "legend-container", children: h });
194
+ return /* @__PURE__ */ d("div", { className: "legend-container", children: h });
196
195
  };
197
- return /* @__PURE__ */ I(
196
+ return /* @__PURE__ */ _(
198
197
  "div",
199
198
  {
200
- className: _("histogram-container relative", X && "w-full", D && "h-full"),
201
- style: c === void 0 ? void 0 : { width: c },
199
+ className: F("histogram-container relative", Y && "w-full", D && "h-full"),
200
+ style: l === void 0 ? void 0 : { width: l },
202
201
  children: [
203
- /* @__PURE__ */ I("div", { className: _("chart-container", D && "flex h-full flex-col"), children: [
204
- s && /* @__PURE__ */ u("div", { className: "title-container", children: /* @__PURE__ */ u("h2", { className: "title", children: s }) }),
205
- /* @__PURE__ */ u("div", { ref: j, className: _(D && "min-h-0 flex-1"), children: /* @__PURE__ */ u(
202
+ /* @__PURE__ */ _("div", { className: F("chart-container", D && "flex h-full flex-col"), children: [
203
+ a && /* @__PURE__ */ d("div", { className: "title-container", children: /* @__PURE__ */ d("h2", { className: "title", children: a }) }),
204
+ /* @__PURE__ */ d("div", { ref: X, className: F(D && "min-h-0 flex-1"), children: /* @__PURE__ */ d(
206
205
  "div",
207
206
  {
208
- ref: n,
207
+ ref: o,
209
208
  style: {
210
209
  width: "100%",
211
210
  height: "100%",
@@ -213,7 +212,7 @@ const tt = -0.5, ot = (r) => r.reduce((e, s) => e + s, 0) / r.length, et = (r, c
213
212
  }
214
213
  }
215
214
  ) }),
216
- /* @__PURE__ */ u(U, { series: y })
215
+ /* @__PURE__ */ d(U, { series: v })
217
216
  ] }),
218
217
  z
219
218
  ]
@@ -221,6 +220,6 @@ const tt = -0.5, ot = (r) => r.reduce((e, s) => e + s, 0) / r.length, et = (r, c
221
220
  );
222
221
  };
223
222
  export {
224
- ft as Histogram
223
+ gt as Histogram
225
224
  };
226
225
  //# sourceMappingURL=Histogram.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Histogram.js","sources":["../../../../src/components/charts/Histogram/Histogram.tsx"],"sourcesContent":["import Plotly from \"plotly.js-dist\";\nimport React, { useEffect, useRef, useMemo } from \"react\";\n\nimport { useChartTooltip } from \"../ChartTooltip\";\n\nimport { useElementSize } from \"@/hooks/use-element-size\";\nimport { usePlotlyTheme } from \"@/hooks/use-plotly-theme\";\nimport { cn } from \"@/lib/utils\";\nimport { CHART_COLORS } from \"@/utils/colors\";\nimport \"./Histogram.scss\";\n\n/** Exponent coefficient for normal distribution calculation */\nconst NORMAL_DISTRIBUTION_EXPONENT_COEFF = -0.5;\n\ninterface HistogramDataSeries {\n x: number[];\n name: string;\n color?: string;\n autobinx?: boolean;\n xbins?: {\n start: number;\n end: number;\n size: number;\n };\n opacity?: number;\n showDistributionLine?: boolean;\n lineWidth?: number;\n}\n\ntype HistogramProps = {\n dataSeries: HistogramDataSeries | HistogramDataSeries[];\n /**\n * Fixed width in pixels. When omitted, the chart fills its container and\n * tracks the container's width via a `ResizeObserver`.\n */\n width?: number;\n /**\n * Fixed height in pixels. When omitted, the chart fills its container and\n * tracks the container's height via a `ResizeObserver`.\n */\n height?: number;\n title?: string;\n xTitle?: string;\n yTitle?: string;\n bargap?: number;\n showDistributionLine?: boolean;\n};\n\nconst calculateMean = (data: number[]): number => {\n const sum = data.reduce((acc, val) => acc + val, 0);\n return sum / data.length;\n};\n\nconst calculateStdDev = (data: number[], mean: number): number => {\n const squaredDiffs = data.map((value) => Math.pow(value - mean, 2));\n const variance =\n squaredDiffs.reduce((acc, val) => acc + val, 0) / data.length;\n return Math.sqrt(variance);\n};\n\nconst generateNormalDistributionPoints = (\n mean: number,\n stdDev: number,\n start: number,\n end: number,\n points = 100\n): { x: number[]; y: number[] } => {\n const xValues: number[] = [];\n const yValues: number[] = [];\n\n const step = (end - start) / (points - 1);\n\n for (let i = 0; i < points; i++) {\n const x = start + i * step;\n xValues.push(x);\n\n const exponent = NORMAL_DISTRIBUTION_EXPONENT_COEFF * Math.pow((x - mean) / stdDev, 2);\n const y = (1 / (stdDev * Math.sqrt(2 * Math.PI))) * Math.exp(exponent);\n yValues.push(y);\n }\n\n return { x: xValues, y: yValues };\n};\n\nconst scaleDistributionCurve = (\n yValues: number[],\n histogramData: number[],\n bins: { start: number; end: number; size: number }\n): number[] => {\n const binCount = Math.ceil((bins.end - bins.start) / bins.size);\n const binFrequencies = Array(binCount).fill(0);\n\n histogramData.forEach((value) => {\n if (value >= bins.start && value <= bins.end) {\n const binIndex = Math.floor((value - bins.start) / bins.size);\n binFrequencies[binIndex]++;\n }\n });\n\n const maxBinFrequency = Math.max(...binFrequencies);\n const maxCurveValue = Math.max(...yValues);\n\n const scaleFactor = maxBinFrequency / maxCurveValue;\n\n return yValues.map((y) => y * scaleFactor);\n};\n\nconst Histogram: React.FC<HistogramProps> = ({\n dataSeries,\n width,\n height,\n title = \"Histogram\",\n xTitle = \"X Axis\",\n yTitle = \"Frequency\",\n bargap = 0.2,\n showDistributionLine = false,\n}) => {\n const plotRef = useRef<HTMLDivElement>(null);\n const theme = usePlotlyTheme();\n const { bindTooltip, tooltipElement } = useChartTooltip({ xLabel: xTitle, yLabel: yTitle });\n\n // Omitted width/height → fill the container and track its measured size;\n // explicit pixel values override. Histogram has its own HTML title + legend,\n // so we measure a wrapper around just the Plotly canvas. See AreaGraph for\n // the reference pattern.\n const [plotAreaRef, measured] = useElementSize<HTMLDivElement>();\n const resolvedWidth = width ?? measured.width;\n const resolvedHeight = height ?? measured.height;\n const hasSize = resolvedWidth > 0 && resolvedHeight > 0;\n // Fill is per-dimension: omit width to fill the container width, omit height\n // to fill its height (so e.g. a fixed width with a container-driven height works).\n const fillWidth = width === undefined;\n const fillHeight = height === undefined;\n const sizeRef = useRef({ width: resolvedWidth, height: resolvedHeight });\n sizeRef.current = { width: resolvedWidth, height: resolvedHeight };\n const plotInitedRef = useRef(false);\n // Size last applied to the plot, so the resize effect can skip a redundant\n // relayout right after newPlot already drew at that size.\n const appliedSizeRef = useRef({ width: 0, height: 0 });\n const seriesArray = useMemo(\n () => (Array.isArray(dataSeries) ? dataSeries : [dataSeries]),\n [dataSeries],\n );\n const effectiveBarMode = useMemo<\n \"stack\" | \"group\" | \"overlay\" | \"relative\" | undefined\n >(() => (seriesArray.length > 1 ? \"stack\" : undefined), [seriesArray.length]);\n\n const defaultColors = CHART_COLORS;\n\n const seriesWithColors = useMemo(() => {\n return seriesArray.map((series, index) => {\n const hasDistributionLine =\n typeof series.showDistributionLine === \"undefined\"\n ? showDistributionLine\n : series.showDistributionLine;\n\n return {\n ...series,\n color: series.color || defaultColors[index % defaultColors.length],\n opacity: hasDistributionLine ? 0.5 : series.opacity || 1,\n showDistributionLine: hasDistributionLine,\n lineWidth: series.lineWidth || 3,\n };\n });\n }, [seriesArray, showDistributionLine, defaultColors]);\n\n const gridColor = theme.gridColor;\n\n const histogramData = useMemo(\n () =>\n seriesWithColors.map((series) => ({\n type: \"histogram\" as const,\n x: series.x,\n name: series.name,\n marker: {\n color: series.color,\n line: {\n color: theme.paperBg,\n width: 1,\n },\n opacity: series.opacity,\n },\n autobinx: series.autobinx,\n xbins: series.xbins,\n hoverinfo: \"none\" as const,\n })),\n [seriesWithColors, theme],\n );\n\n const distributionLines = useMemo(\n () =>\n seriesWithColors\n .filter((series) => series.showDistributionLine)\n .map((series) => {\n const mean = calculateMean(series.x);\n const stdDev = calculateStdDev(series.x, mean);\n\n const min = Math.min(...series.x);\n const max = Math.max(...series.x);\n const range = max - min;\n const start = min - range * 0.1;\n const end = max + range * 0.1;\n\n const bins = series.xbins || {\n start: start,\n end: end,\n size: range / 10,\n };\n\n const curvePoints = generateNormalDistributionPoints(\n mean,\n stdDev,\n start,\n end,\n 100,\n );\n\n const scaledYValues = scaleDistributionCurve(\n curvePoints.y,\n series.x,\n bins,\n );\n\n return {\n type: \"scatter\" as const,\n x: curvePoints.x,\n y: scaledYValues,\n mode: \"lines\" as const,\n name: `${series.name} Distribution`,\n line: {\n color: series.color,\n width: series.lineWidth,\n },\n hoverinfo: \"none\" as const,\n };\n }),\n [seriesWithColors],\n );\n\n const plotData = useMemo(\n () => [...histogramData, ...distributionLines],\n [histogramData, distributionLines],\n );\n\n useEffect(() => {\n if (!plotRef.current || !hasSize) return;\n\n const layout = {\n width: sizeRef.current.width,\n height: sizeRef.current.height,\n font: {\n family: \"Inter, sans-serif\",\n },\n showlegend: false,\n margin: { l: 90, r: 40, b: 80, t: 40 },\n xaxis: {\n title: {\n text: xTitle,\n font: {\n size: 16,\n color: theme.textSecondary,\n family: \"Inter, sans-serif\",\n weight: 400,\n },\n standoff: 20,\n },\n gridcolor: gridColor,\n tickcolor: theme.tickColor,\n ticklen: 8,\n tickwidth: 1,\n ticks: \"outside\" as const,\n linecolor: theme.lineColor,\n linewidth: 1,\n zeroline: false,\n automargin: true,\n },\n yaxis: {\n title: {\n text: yTitle,\n font: {\n size: 16,\n color: theme.textSecondary,\n family: \"Inter, sans-serif\",\n weight: 400,\n },\n standoff: 20,\n },\n gridcolor: gridColor,\n tickcolor: theme.tickColor,\n ticklen: 8,\n tickwidth: 1,\n ticks: \"outside\" as const,\n linecolor: theme.lineColor,\n linewidth: 1,\n zeroline: false,\n rangemode: \"tozero\" as const,\n automargin: true,\n },\n barmode: effectiveBarMode,\n bargap: bargap,\n paper_bgcolor: theme.paperBg,\n plot_bgcolor: theme.plotBg,\n };\n\n const config = {\n // Sizing is driven from the measured container; disable Plotly's own\n // window-resize responsiveness (it can't see container resizes).\n responsive: false,\n displayModeBar: false,\n displaylogo: false,\n };\n\n Plotly.newPlot(plotRef.current, plotData, layout, config);\n bindTooltip(plotRef.current);\n\n // Capture ref value for cleanup\n const plotElement = plotRef.current;\n plotInitedRef.current = true;\n appliedSizeRef.current = { ...sizeRef.current };\n\n return () => {\n if (plotElement) {\n Plotly.purge(plotElement);\n plotInitedRef.current = false;\n }\n };\n }, [hasSize, xTitle, yTitle, bargap, plotData, effectiveBarMode, gridColor, theme, bindTooltip]);\n\n // Resize in place when the measured/overridden size changes — cheaper than\n // recreating the plot, and it preserves tooltip/event bindings.\n useEffect(() => {\n const plotElement = plotRef.current;\n if (!plotElement || !plotInitedRef.current || resolvedWidth <= 0 || resolvedHeight <= 0) {\n return;\n }\n // newPlot already drew at the current size; skip the redundant relayout\n // (it would queue an automargin redraw that can reject if we unmount first).\n if (\n appliedSizeRef.current.width === resolvedWidth &&\n appliedSizeRef.current.height === resolvedHeight\n ) {\n return;\n }\n appliedSizeRef.current = { width: resolvedWidth, height: resolvedHeight };\n // Swallow rejections from a relayout that races an unmount/purge.\n void Plotly.relayout(plotElement, { width: resolvedWidth, height: resolvedHeight }).catch(\n () => {},\n );\n }, [resolvedWidth, resolvedHeight]);\n\n const ChartLegend: React.FC<{\n series: Array<{ name: string; color: string }>;\n }> = ({ series }) => {\n const items = series.map((item, i) => (\n <React.Fragment key={item.name}>\n <div className=\"legend-item\">\n <span className=\"color-box\" style={{ background: item.color }} />\n {item.name}\n {i < series.length - 1 && <span className=\"divider\" />}\n </div>\n </React.Fragment>\n ));\n\n const rows = [];\n const rowSize = 6;\n for (let i = 0; i < items.length; i += rowSize) {\n rows.push(\n <div className=\"legend-row\" key={i}>\n {items.slice(i, i + rowSize)}\n </div>\n );\n }\n\n return <div className=\"legend-container\">{rows}</div>;\n };\n\n return (\n <div\n className={cn(\"histogram-container relative\", fillWidth && \"w-full\", fillHeight && \"h-full\")}\n style={width === undefined ? undefined : { width }}\n >\n <div className={cn(\"chart-container\", fillHeight && \"flex h-full flex-col\")}>\n {title && (\n <div className=\"title-container\">\n <h2 className=\"title\">{title}</h2>\n </div>\n )}\n {/* Measured plot area — flexes to fill the space left by the title and\n legend in fill mode, so the Plotly canvas tracks it. */}\n <div ref={plotAreaRef} className={cn(fillHeight && \"min-h-0 flex-1\")}>\n <div\n ref={plotRef}\n style={{\n width: \"100%\",\n height: \"100%\",\n margin: \"0\",\n }}\n />\n </div>\n <ChartLegend series={seriesWithColors} />\n </div>\n {tooltipElement}\n </div>\n );\n};\n\nexport { Histogram };\nexport type { HistogramDataSeries, HistogramProps };\n"],"names":["NORMAL_DISTRIBUTION_EXPONENT_COEFF","calculateMean","data","acc","val","calculateStdDev","mean","variance","value","generateNormalDistributionPoints","stdDev","start","end","points","xValues","yValues","step","i","x","exponent","y","scaleDistributionCurve","histogramData","bins","binCount","binFrequencies","binIndex","maxBinFrequency","maxCurveValue","scaleFactor","Histogram","dataSeries","width","height","title","xTitle","yTitle","bargap","showDistributionLine","plotRef","useRef","theme","usePlotlyTheme","bindTooltip","tooltipElement","useChartTooltip","plotAreaRef","measured","useElementSize","resolvedWidth","resolvedHeight","hasSize","fillWidth","fillHeight","sizeRef","plotInitedRef","appliedSizeRef","seriesArray","useMemo","effectiveBarMode","defaultColors","CHART_COLORS","seriesWithColors","series","index","hasDistributionLine","gridColor","distributionLines","min","max","range","curvePoints","scaledYValues","plotData","useEffect","layout","config","Plotly","plotElement","ChartLegend","items","item","jsx","React","jsxs","rows","rowSize","cn"],"mappings":";;;;;;;;;AAYA,MAAMA,KAAqC,MAoCrCC,KAAgB,CAACC,MACTA,EAAK,OAAO,CAACC,GAAKC,MAAQD,IAAMC,GAAK,CAAC,IACrCF,EAAK,QAGdG,KAAkB,CAACH,GAAgBI,MAAyB;AAEhE,QAAMC,IADeL,EAAK,IAAI,CAACM,MAAU,KAAK,IAAIA,IAAQF,GAAM,CAAC,CAAC,EAEnD,OAAO,CAACH,GAAKC,MAAQD,IAAMC,GAAK,CAAC,IAAIF,EAAK;AACzD,SAAO,KAAK,KAAKK,CAAQ;AAC3B,GAEME,KAAmC,CACvCH,GACAI,GACAC,GACAC,GACAC,IAAS,QACwB;AACjC,QAAMC,IAAoB,CAAA,GACpBC,IAAoB,CAAA,GAEpBC,KAAQJ,IAAMD,MAAUE,IAAS;AAEvC,WAASI,IAAI,GAAGA,IAAIJ,GAAQI,KAAK;AAC/B,UAAMC,IAAIP,IAAQM,IAAID;AACtB,IAAAF,EAAQ,KAAKI,CAAC;AAEd,UAAMC,IAAWnB,KAAqC,KAAK,KAAKkB,IAAIZ,KAAQI,GAAQ,CAAC,GAC/EU,IAAK,KAAKV,IAAS,KAAK,KAAK,IAAI,KAAK,EAAE,KAAM,KAAK,IAAIS,CAAQ;AACrE,IAAAJ,EAAQ,KAAKK,CAAC;AAAA,EAChB;AAEA,SAAO,EAAE,GAAGN,GAAS,GAAGC,EAAA;AAC1B,GAEMM,KAAyB,CAC7BN,GACAO,GACAC,MACa;AACb,QAAMC,IAAW,KAAK,MAAMD,EAAK,MAAMA,EAAK,SAASA,EAAK,IAAI,GACxDE,IAAiB,MAAMD,CAAQ,EAAE,KAAK,CAAC;AAE7C,EAAAF,EAAc,QAAQ,CAACd,MAAU;AAC/B,QAAIA,KAASe,EAAK,SAASf,KAASe,EAAK,KAAK;AAC5C,YAAMG,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KACC,gBAAAgD,EAAC,SAAI,WAAU,mBACb,4BAAC,MAAA,EAAG,WAAU,SAAS,UAAAhD,EAAA,CAAM,EAAA,CAC/B;AAAA,UAIF,gBAAAgD,EAAC,SAAI,KAAKpC,GAAa,WAAWyC,EAAGlC,KAAc,gBAAgB,GACjE,UAAA,gBAAA6B;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,KAAK3C;AAAA,cACL,OAAO;AAAA,gBACL,OAAO;AAAA,gBACP,QAAQ;AAAA,gBACR,QAAQ;AAAA,cAAA;AAAA,YACV;AAAA,UAAA,GAEJ;AAAA,UACA,gBAAA2C,EAACH,GAAA,EAAY,QAAQjB,EAAA,CAAkB;AAAA,QAAA,GACzC;AAAA,QACClB;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGP;"}
1
+ {"version":3,"file":"Histogram.js","sources":["../../../../src/components/charts/Histogram/Histogram.tsx"],"sourcesContent":["import React, { useEffect, useRef, useMemo } from \"react\";\n\nimport { useChartTooltip } from \"../ChartTooltip\";\nimport { getLoadedPlotly, loadPlotly } from \"../plotly-loader\";\n\nimport { useElementSize } from \"@/hooks/use-element-size\";\nimport { CHART_FONT_FAMILY, usePlotlyTheme } from \"@/hooks/use-plotly-theme\";\nimport { cn } from \"@/lib/utils\";\nimport { CHART_COLORS } from \"@/utils/colors\";\nimport \"./Histogram.scss\";\n\n/** Exponent coefficient for normal distribution calculation */\nconst NORMAL_DISTRIBUTION_EXPONENT_COEFF = -0.5;\n\ninterface HistogramDataSeries {\n x: number[];\n name: string;\n color?: string;\n autobinx?: boolean;\n xbins?: {\n start: number;\n end: number;\n size: number;\n };\n opacity?: number;\n showDistributionLine?: boolean;\n lineWidth?: number;\n}\n\ntype HistogramProps = {\n dataSeries: HistogramDataSeries | HistogramDataSeries[];\n /**\n * Fixed width in pixels. When omitted, the chart fills its container and\n * tracks the container's width via a `ResizeObserver`.\n */\n width?: number;\n /**\n * Fixed height in pixels. When omitted, the chart fills its container and\n * tracks the container's height via a `ResizeObserver`.\n */\n height?: number;\n title?: string;\n xTitle?: string;\n yTitle?: string;\n bargap?: number;\n showDistributionLine?: boolean;\n};\n\nconst calculateMean = (data: number[]): number => {\n const sum = data.reduce((acc, val) => acc + val, 0);\n return sum / data.length;\n};\n\nconst calculateStdDev = (data: number[], mean: number): number => {\n const squaredDiffs = data.map((value) => Math.pow(value - mean, 2));\n const variance =\n squaredDiffs.reduce((acc, val) => acc + val, 0) / data.length;\n return Math.sqrt(variance);\n};\n\nconst generateNormalDistributionPoints = (\n mean: number,\n stdDev: number,\n start: number,\n end: number,\n points = 100\n): { x: number[]; y: number[] } => {\n const xValues: number[] = [];\n const yValues: number[] = [];\n\n const step = (end - start) / (points - 1);\n\n for (let i = 0; i < points; i++) {\n const x = start + i * step;\n xValues.push(x);\n\n const exponent = NORMAL_DISTRIBUTION_EXPONENT_COEFF * Math.pow((x - mean) / stdDev, 2);\n const y = (1 / (stdDev * Math.sqrt(2 * Math.PI))) * Math.exp(exponent);\n yValues.push(y);\n }\n\n return { x: xValues, y: yValues };\n};\n\nconst scaleDistributionCurve = (\n yValues: number[],\n histogramData: number[],\n bins: { start: number; end: number; size: number }\n): number[] => {\n const binCount = Math.ceil((bins.end - bins.start) / bins.size);\n const binFrequencies = Array(binCount).fill(0);\n\n histogramData.forEach((value) => {\n if (value >= bins.start && value <= bins.end) {\n const binIndex = Math.floor((value - bins.start) / bins.size);\n binFrequencies[binIndex]++;\n }\n });\n\n const maxBinFrequency = Math.max(...binFrequencies);\n const maxCurveValue = Math.max(...yValues);\n\n const scaleFactor = maxBinFrequency / maxCurveValue;\n\n return yValues.map((y) => y * scaleFactor);\n};\n\nconst Histogram: React.FC<HistogramProps> = ({\n dataSeries,\n width,\n height,\n title = \"Histogram\",\n xTitle = \"X Axis\",\n yTitle = \"Frequency\",\n bargap = 0.2,\n showDistributionLine = false,\n}) => {\n const plotRef = useRef<HTMLDivElement>(null);\n const theme = usePlotlyTheme();\n const { bindTooltip, tooltipElement } = useChartTooltip({ xLabel: xTitle, yLabel: yTitle });\n\n // Omitted width/height → fill the container and track its measured size;\n // explicit pixel values override. Histogram has its own HTML title + legend,\n // so we measure a wrapper around just the Plotly canvas. See AreaPlot for\n // the reference pattern.\n const [plotAreaRef, measured] = useElementSize<HTMLDivElement>();\n const resolvedWidth = width ?? measured.width;\n const resolvedHeight = height ?? measured.height;\n const hasSize = resolvedWidth > 0 && resolvedHeight > 0;\n // Fill is per-dimension: omit width to fill the container width, omit height\n // to fill its height (so e.g. a fixed width with a container-driven height works).\n const fillWidth = width === undefined;\n const fillHeight = height === undefined;\n const sizeRef = useRef({ width: resolvedWidth, height: resolvedHeight });\n sizeRef.current = { width: resolvedWidth, height: resolvedHeight };\n const plotInitedRef = useRef(false);\n // Size last applied to the plot, so the resize effect can skip a redundant\n // relayout right after newPlot already drew at that size.\n const appliedSizeRef = useRef({ width: 0, height: 0 });\n const seriesArray = useMemo(\n () => (Array.isArray(dataSeries) ? dataSeries : [dataSeries]),\n [dataSeries],\n );\n const effectiveBarMode = useMemo<\n \"stack\" | \"group\" | \"overlay\" | \"relative\" | undefined\n >(() => (seriesArray.length > 1 ? \"stack\" : undefined), [seriesArray.length]);\n\n const defaultColors = CHART_COLORS;\n\n const seriesWithColors = useMemo(() => {\n return seriesArray.map((series, index) => {\n const hasDistributionLine =\n typeof series.showDistributionLine === \"undefined\"\n ? showDistributionLine\n : series.showDistributionLine;\n\n return {\n ...series,\n color: series.color || defaultColors[index % defaultColors.length],\n opacity: hasDistributionLine ? 0.5 : series.opacity || 1,\n showDistributionLine: hasDistributionLine,\n lineWidth: series.lineWidth || 3,\n };\n });\n }, [seriesArray, showDistributionLine, defaultColors]);\n\n const gridColor = theme.gridColor;\n\n const histogramData = useMemo(\n () =>\n seriesWithColors.map((series) => ({\n type: \"histogram\" as const,\n x: series.x,\n name: series.name,\n marker: {\n color: series.color,\n line: {\n color: theme.paperBg,\n width: 1,\n },\n opacity: series.opacity,\n },\n autobinx: series.autobinx,\n xbins: series.xbins,\n hoverinfo: \"none\" as const,\n })),\n [seriesWithColors, theme],\n );\n\n const distributionLines = useMemo(\n () =>\n seriesWithColors\n .filter((series) => series.showDistributionLine)\n .map((series) => {\n const mean = calculateMean(series.x);\n const stdDev = calculateStdDev(series.x, mean);\n\n const min = Math.min(...series.x);\n const max = Math.max(...series.x);\n const range = max - min;\n const start = min - range * 0.1;\n const end = max + range * 0.1;\n\n const bins = series.xbins || {\n start: start,\n end: end,\n size: range / 10,\n };\n\n const curvePoints = generateNormalDistributionPoints(\n mean,\n stdDev,\n start,\n end,\n 100,\n );\n\n const scaledYValues = scaleDistributionCurve(\n curvePoints.y,\n series.x,\n bins,\n );\n\n return {\n type: \"scatter\" as const,\n x: curvePoints.x,\n y: scaledYValues,\n mode: \"lines\" as const,\n name: `${series.name} Distribution`,\n line: {\n color: series.color,\n width: series.lineWidth,\n },\n hoverinfo: \"none\" as const,\n };\n }),\n [seriesWithColors],\n );\n\n const plotData = useMemo(\n () => [...histogramData, ...distributionLines],\n [histogramData, distributionLines],\n );\n\n useEffect(() => {\n if (!plotRef.current || !hasSize) return;\n\n const layout = {\n width: sizeRef.current.width,\n height: sizeRef.current.height,\n font: {\n family: CHART_FONT_FAMILY,\n },\n showlegend: false,\n margin: { l: 90, r: 40, b: 80, t: 40 },\n xaxis: {\n title: {\n text: xTitle,\n font: {\n size: 16,\n color: theme.textSecondary,\n family: CHART_FONT_FAMILY,\n weight: 400,\n },\n standoff: 20,\n },\n gridcolor: gridColor,\n tickcolor: theme.tickColor,\n ticklen: 8,\n tickwidth: 1,\n ticks: \"outside\" as const,\n linecolor: theme.lineColor,\n linewidth: 1,\n zeroline: false,\n automargin: true,\n },\n yaxis: {\n title: {\n text: yTitle,\n font: {\n size: 16,\n color: theme.textSecondary,\n family: CHART_FONT_FAMILY,\n weight: 400,\n },\n standoff: 20,\n },\n gridcolor: gridColor,\n tickcolor: theme.tickColor,\n ticklen: 8,\n tickwidth: 1,\n ticks: \"outside\" as const,\n linecolor: theme.lineColor,\n linewidth: 1,\n zeroline: false,\n rangemode: \"tozero\" as const,\n automargin: true,\n },\n barmode: effectiveBarMode,\n bargap: bargap,\n paper_bgcolor: theme.paperBg,\n plot_bgcolor: theme.plotBg,\n };\n\n const config = {\n // Sizing is driven from the measured container; disable Plotly's own\n // window-resize responsiveness (it can't see container resizes).\n responsive: false,\n displayModeBar: false,\n displaylogo: false,\n };\n\n // Plotly is loaded lazily so it stays out of the consumer's main chunk\n // (SW-2007); the draw is skipped if the effect re-runs or unmounts first.\n let cancelled = false;\n let plotElement: HTMLDivElement | null = null;\n void loadPlotly().then((plotly) => {\n if (cancelled || !plotRef.current) return;\n plotly.newPlot(plotRef.current, plotData, layout, config);\n bindTooltip(plotRef.current);\n\n // Capture ref value for cleanup\n plotElement = plotRef.current;\n plotInitedRef.current = true;\n appliedSizeRef.current = { ...sizeRef.current };\n });\n\n return () => {\n cancelled = true;\n if (plotElement) {\n getLoadedPlotly().purge(plotElement);\n plotInitedRef.current = false;\n }\n };\n }, [hasSize, xTitle, yTitle, bargap, plotData, effectiveBarMode, gridColor, theme, bindTooltip]);\n\n // Resize in place when the measured/overridden size changes — cheaper than\n // recreating the plot, and it preserves tooltip/event bindings.\n useEffect(() => {\n const plotElement = plotRef.current;\n if (!plotElement || !plotInitedRef.current || resolvedWidth <= 0 || resolvedHeight <= 0) {\n return;\n }\n // newPlot already drew at the current size; skip the redundant relayout\n // (it would queue an automargin redraw that can reject if we unmount first).\n if (\n appliedSizeRef.current.width === resolvedWidth &&\n appliedSizeRef.current.height === resolvedHeight\n ) {\n return;\n }\n appliedSizeRef.current = { width: resolvedWidth, height: resolvedHeight };\n // Swallow rejections from a relayout that races an unmount/purge.\n // plotInitedRef guarantees Plotly finished loading, so sync access is safe.\n void getLoadedPlotly()\n .relayout(plotElement, { width: resolvedWidth, height: resolvedHeight })\n .catch(() => {});\n }, [resolvedWidth, resolvedHeight]);\n\n const ChartLegend: React.FC<{\n series: Array<{ name: string; color: string }>;\n }> = ({ series }) => {\n const items = series.map((item, i) => (\n <React.Fragment key={item.name}>\n <div className=\"legend-item\">\n <span className=\"color-box\" style={{ background: item.color }} />\n {item.name}\n {i < series.length - 1 && <span className=\"divider\" />}\n </div>\n </React.Fragment>\n ));\n\n const rows = [];\n const rowSize = 6;\n for (let i = 0; i < items.length; i += rowSize) {\n rows.push(\n <div className=\"legend-row\" key={i}>\n {items.slice(i, i + rowSize)}\n </div>\n );\n }\n\n return <div className=\"legend-container\">{rows}</div>;\n };\n\n return (\n <div\n className={cn(\"histogram-container relative\", fillWidth && \"w-full\", fillHeight && \"h-full\")}\n style={width === undefined ? undefined : { width }}\n >\n <div className={cn(\"chart-container\", fillHeight && \"flex h-full flex-col\")}>\n {title && (\n <div className=\"title-container\">\n <h2 className=\"title\">{title}</h2>\n </div>\n )}\n {/* Measured plot area — flexes to fill the space left by the title and\n legend in fill mode, so the Plotly canvas tracks it. */}\n <div ref={plotAreaRef} className={cn(fillHeight && \"min-h-0 flex-1\")}>\n <div\n ref={plotRef}\n style={{\n width: \"100%\",\n height: \"100%\",\n margin: \"0\",\n }}\n />\n </div>\n <ChartLegend series={seriesWithColors} />\n </div>\n {tooltipElement}\n </div>\n );\n};\n\nexport { Histogram };\nexport type { HistogramDataSeries, HistogramProps };\n"],"names":["NORMAL_DISTRIBUTION_EXPONENT_COEFF","calculateMean","data","acc","val","calculateStdDev","mean","variance","value","generateNormalDistributionPoints","stdDev","start","end","points","xValues","yValues","step","i","x","exponent","y","scaleDistributionCurve","histogramData","bins","binCount","binFrequencies","binIndex","maxBinFrequency","maxCurveValue","scaleFactor","Histogram","dataSeries","width","height","title","xTitle","yTitle","bargap","showDistributionLine","plotRef","useRef","theme","usePlotlyTheme","bindTooltip","tooltipElement","useChartTooltip","plotAreaRef","measured","useElementSize","resolvedWidth","resolvedHeight","hasSize","fillWidth","fillHeight","sizeRef","plotInitedRef","appliedSizeRef","seriesArray","useMemo","effectiveBarMode","defaultColors","CHART_COLORS","seriesWithColors","series","index","hasDistributionLine","gridColor","distributionLines","min","max","range","curvePoints","scaledYValues","plotData","useEffect","layout","CHART_FONT_FAMILY","config","cancelled","plotElement","loadPlotly","plotly","getLoadedPlotly","ChartLegend","items","item","jsx","React","jsxs","rows","rowSize","cn"],"mappings":";;;;;;;;;AAYA,MAAMA,KAAqC,MAoCrCC,KAAgB,CAACC,MACTA,EAAK,OAAO,CAACC,GAAKC,MAAQD,IAAMC,GAAK,CAAC,IACrCF,EAAK,QAGdG,KAAkB,CAACH,GAAgBI,MAAyB;AAEhE,QAAMC,IADeL,EAAK,IAAI,CAACM,MAAU,KAAK,IAAIA,IAAQF,GAAM,CAAC,CAAC,EAEnD,OAAO,CAACH,GAAKC,MAAQD,IAAMC,GAAK,CAAC,IAAIF,EAAK;AACzD,SAAO,KAAK,KAAKK,CAAQ;AAC3B,GAEME,KAAmC,CACvCH,GACAI,GACAC,GACAC,GACAC,IAAS,QACwB;AACjC,QAAMC,IAAoB,CAAA,GACpBC,IAAoB,CAAA,GAEpBC,KAAQJ,IAAMD,MAAUE,IAAS;AAEvC,WAASI,IAAI,GAAGA,IAAIJ,GAAQI,KAAK;AAC/B,UAAMC,IAAIP,IAAQM,IAAID;AACtB,IAAAF,EAAQ,KAAKI,CAAC;AAEd,UAAMC,IAAWnB,KAAqC,KAAK,KAAKkB,IAAIZ,KAAQI,GAAQ,CAAC,GAC/EU,IAAK,KAAKV,IAAS,KAAK,KAAK,IAAI,KAAK,EAAE,KAAM,KAAK,IAAIS,CAAQ;AACrE,IAAAJ,EAAQ,KAAKK,CAAC;AAAA,EAChB;AAEA,SAAO,EAAE,GAAGN,GAAS,GAAGC,EAAA;AAC1B,GAEMM,KAAyB,CAC7BN,GACAO,GACAC,MACa;AACb,QAAMC,IAAW,KAAK,MAAMD,EAAK,MAAMA,EAAK,SAASA,EAAK,IAAI,GACxDE,IAAiB,MAAMD,CAAQ,EAAE,KAAK,CAAC;AAE7C,EAAAF,EAAc,QAAQ,CAACd,MAAU;AA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,OAAOrB,MAAU,SAAY,SAAY,EAAE,OAAAA,EAAA;AAAA,MAE3C,UAAA;AAAA,QAAA,gBAAAwD,EAAC,SAAI,WAAWG,EAAG,mBAAmBtC,KAAc,sBAAsB,GACvE,UAAA;AAAA,UAAAnB,KACC,gBAAAoD,EAAC,SAAI,WAAU,mBACb,4BAAC,MAAA,EAAG,WAAU,SAAS,UAAApD,EAAA,CAAM,EAAA,CAC/B;AAAA,UAIF,gBAAAoD,EAAC,SAAI,KAAKxC,GAAa,WAAW6C,EAAGtC,KAAc,gBAAgB,GACjE,UAAA,gBAAAiC;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,KAAK/C;AAAA,cACL,OAAO;AAAA,gBACL,OAAO;AAAA,gBACP,QAAQ;AAAA,gBACR,QAAQ;AAAA,cAAA;AAAA,YACV;AAAA,UAAA,GAEJ;AAAA,UACA,gBAAA+C,EAACH,GAAA,EAAY,QAAQrB,EAAA,CAAkB;AAAA,QAAA,GACzC;AAAA,QACClB;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGP;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const H=require("react/jsx-runtime"),n=require("react"),V=require("../ChartTooltip/ChartTooltip.cjs"),N=require("../plotly-loader.cjs"),B=require("../../../hooks/use-element-size.cjs"),h=require("../../../hooks/use-plotly-theme.cjs"),G=require("../../../lib/utils.cjs"),W=require("../../../utils/colors.cjs"),D=60,J=30,K=({dataSeries:d,width:T,height:R,xRange:L,yRange:g,variant:y="lines",xTitle:b,yTitle:k,title:p,xTickText:M})=>{const u=n.useRef(null),o=h.usePlotlyTheme(),{bindTooltip:v,tooltipElement:S}=V.useChartTooltip({xLabel:b,yLabel:k}),[X,I]=B.useElementSize(),s=T??I.width,a=R??I.height,P=s>0&&a>0,j=T===void 0,U=R===void 0,_=n.useRef({width:s,height:a});_.current={width:s,height:a};const C=n.useRef(!1),w=n.useRef({width:0,height:0}),{yMin:z,yMax:F}=n.useMemo(()=>{let t=Number.MAX_VALUE,e=Number.MIN_VALUE,l=Number.MAX_VALUE,i=Number.MIN_VALUE;d.forEach(A=>{A.x.forEach(c=>{t=Math.min(t,c),e=Math.max(e,c)}),A.y.forEach(c=>{l=Math.min(l,c),i=Math.max(i,c)})});const m=(e-t)*.1,r=(i-l)*.1;return{xMin:t-m,xMax:e+m,yMin:l-r,yMax:i+r}},[d]),f=n.useMemo(()=>g||[z,F],[g,z,F]),O=n.useMemo(()=>{const t=f[1]-f[0];let e=Math.pow(10,Math.floor(Math.log10(t)));t/e>10&&(e=e*2),t/e<4&&(e=e/2);const l=[];let i=Math.ceil(f[0]/e)*e;for(;i<=f[1];)l.push(i),i+=e;return l},[f]),x=n.useMemo(()=>[...new Set(d.flatMap(t=>t.x))].sort((t,e)=>t-e),[d]),Y=!!M&&M.length===x.length,q=n.useMemo(()=>{switch(y){case"lines+markers":case"lines+markers+error_bars":return"lines+markers";default:return"lines"}},[y]),E=n.useMemo(()=>({tickcolor:o.tickColor,ticklen:12,tickwidth:1,ticks:"outside",tickfont:{size:16,color:o.textColor,family:h.CHART_FONT_FAMILY,weight:400},linecolor:o.lineColor,linewidth:1,position:0,zeroline:!1}),[o]);return n.useEffect(()=>{if(!u.current||!P)return;const t=d.map((r,A)=>{const c=W.seriesColor(A,r.color);return{x:r.x,y:r.y,type:"scatter",mode:q,name:r.name,hoverinfo:"none",line:{color:c,width:1.5},marker:y==="lines"?{opacity:0}:{color:c,size:8,symbol:r.symbol||"triangle-up"},error_y:y==="lines+markers+error_bars"?r.error_y||{type:"data",array:r.y.map(()=>10),visible:!0,color:c,thickness:1,width:5}:void 0}}),e={...p?{title:{text:p,font:{size:32,family:h.CHART_FONT_FAMILY,color:o.textColor}}}:{},width:_.current.width,height:_.current.height,margin:{l:80,r:30,b:96,t:p?D:J,pad:10},paper_bgcolor:o.paperBg,plot_bgcolor:o.plotBg,font:{family:h.CHART_FONT_FAMILY},dragmode:!1,xaxis:{title:{text:b,font:{size:16,color:o.textSecondary,family:h.CHART_FONT_FAMILY,weight:400},standoff:32},gridcolor:o.gridColor,range:L,autorange:!L,tickmode:"array",tickvals:x,ticktext:Y?M:x.map(String),showgrid:!0,automargin:!0,...E},yaxis:{title:{text:k,font:{size:16,color:o.textSecondary,family:h.CHART_FONT_FAMILY,weight:400},standoff:30},gridcolor:o.gridColor,range:g,autorange:!g,tickmode:"array",tickvals:O,showgrid:!0,automargin:!0,...E},legend:{x:.5,y:0,xanchor:"center",yanchor:"bottom",yref:"container",orientation:"h",font:{size:16,color:o.legendColor,family:h.CHART_FONT_FAMILY,weight:500}},showlegend:!0},l={responsive:!1,displayModeBar:!1,displaylogo:!1};let i=!1,m=null;return N.loadPlotly().then(r=>{i||!u.current||(r.newPlot(u.current,t,e,l),v(u.current),m=u.current,C.current=!0,w.current={..._.current})}),()=>{i=!0,m&&(N.getLoadedPlotly().purge(m),C.current=!1)}},[d,P,L,g,b,k,p,q,E,x,O,Y,M,f,y,o,v]),n.useEffect(()=>{const t=u.current;!t||!C.current||s<=0||a<=0||w.current.width===s&&w.current.height===a||(w.current={width:s,height:a},N.getLoadedPlotly().relayout(t,{width:s,height:a}).catch(()=>{}))},[s,a]),H.jsxs("div",{ref:X,className:G.cn("relative",j&&"w-full",U&&"h-full"),children:[H.jsx("div",{ref:u,style:{width:"100%",height:"100%"}}),S]})};exports.LinePlot=K;
2
+ //# sourceMappingURL=LinePlot.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LinePlot.cjs","sources":["../../../../src/components/charts/LinePlot/LinePlot.tsx"],"sourcesContent":["import React, { useEffect, useRef, useMemo } from \"react\";\n\nimport { useChartTooltip } from \"../ChartTooltip\";\nimport { getLoadedPlotly, loadPlotly } from \"../plotly-loader\";\n\nimport { useElementSize } from \"@/hooks/use-element-size\";\nimport { CHART_FONT_FAMILY, usePlotlyTheme } from \"@/hooks/use-plotly-theme\";\nimport { cn } from \"@/lib/utils\";\nimport { seriesColor } from \"@/utils/colors\";\n\ntype MarkerSymbol =\n | \"circle\"\n | \"circle-open\"\n | \"circle-dot\"\n | \"circle-open-dot\"\n | \"square\"\n | \"square-open\"\n | \"square-dot\"\n | \"square-open-dot\"\n | \"diamond\"\n | \"diamond-open\"\n | \"diamond-dot\"\n | \"diamond-open-dot\"\n | \"cross\"\n | \"cross-open\"\n | \"cross-dot\"\n | \"cross-open-dot\"\n | \"x\"\n | \"x-open\"\n | \"x-dot\"\n | \"x-open-dot\"\n | \"triangle-up\"\n | \"triangle-up-open\"\n | \"triangle-up-dot\"\n | \"triangle-up-open-dot\"\n | \"triangle-down\"\n | \"triangle-down-open\"\n | \"triangle-down-dot\"\n | \"triangle-down-open-dot\"\n | \"triangle-left\"\n | \"triangle-left-open\"\n | \"triangle-left-dot\"\n | \"triangle-left-open-dot\"\n | \"triangle-right\"\n | \"triangle-right-open\"\n | \"triangle-right-dot\"\n | \"triangle-right-open-dot\"\n | \"triangle-ne\"\n | \"triangle-ne-open\"\n | \"triangle-ne-dot\"\n | \"triangle-ne-open-dot\"\n | \"triangle-se\"\n | \"triangle-se-open\"\n | \"triangle-se-dot\"\n | \"triangle-se-open-dot\"\n | \"triangle-sw\"\n | \"triangle-sw-open\"\n | \"triangle-sw-dot\"\n | \"triangle-sw-open-dot\"\n | \"triangle-nw\"\n | \"triangle-nw-open\"\n | \"triangle-nw-dot\"\n | \"triangle-nw-open-dot\"\n | \"pentagon\"\n | \"pentagon-open\"\n | \"pentagon-dot\"\n | \"pentagon-open-dot\"\n | \"hexagon\"\n | \"hexagon-open\"\n | \"hexagon-dot\"\n | \"hexagon-open-dot\"\n | \"hexagon2\"\n | \"hexagon2-open\"\n | \"hexagon2-dot\"\n | \"hexagon2-open-dot\"\n | \"octagon\"\n | \"octagon-open\"\n | \"octagon-dot\"\n | \"octagon-open-dot\"\n | \"star\"\n | \"star-open\"\n | \"star-dot\"\n | \"star-open-dot\"\n | \"hexagram\"\n | \"hexagram-open\"\n | \"hexagram-dot\"\n | \"hexagram-open-dot\"\n | \"star-triangle-up\"\n | \"star-triangle-up-open\"\n | \"star-triangle-up-dot\"\n | \"star-triangle-up-open-dot\"\n | \"star-triangle-down\"\n | \"star-triangle-down-open\"\n | \"star-triangle-down-dot\"\n | \"star-triangle-down-open-dot\"\n | \"star-square\"\n | \"star-square-open\"\n | \"star-square-dot\"\n | \"star-square-open-dot\"\n | \"star-diamond\"\n | \"star-diamond-open\"\n | \"star-diamond-dot\"\n | \"star-diamond-open-dot\"\n | \"diamond-tall\"\n | \"diamond-tall-open\"\n | \"diamond-tall-dot\"\n | \"diamond-tall-open-dot\"\n | \"diamond-wide\"\n | \"diamond-wide-open\"\n | \"diamond-wide-dot\"\n | \"diamond-wide-open-dot\"\n | \"hourglass\"\n | \"hourglass-open\"\n | \"bowtie\"\n | \"bowtie-open\"\n | \"circle-cross\"\n | \"circle-cross-open\"\n | \"circle-x\"\n | \"circle-x-open\"\n | \"square-cross\"\n | \"square-cross-open\"\n | \"square-x\"\n | \"square-x-open\"\n | \"diamond-cross\"\n | \"diamond-cross-open\"\n | \"diamond-x\"\n | \"diamond-x-open\"\n | \"cross-thin\"\n | \"cross-thin-open\"\n | \"x-thin\"\n | \"x-thin-open\"\n | \"asterisk\"\n | \"asterisk-open\"\n | \"hash\"\n | \"hash-open\"\n | \"hash-dot\"\n | \"hash-open-dot\"\n | \"y-up\"\n | \"y-up-open\"\n | \"y-down\"\n | \"y-down-open\"\n | \"y-left\"\n | \"y-left-open\"\n | \"y-right\"\n | \"y-right-open\"\n | \"line-ew\"\n | \"line-ew-open\"\n | \"line-ns\"\n | \"line-ns-open\"\n | \"line-ne\"\n | \"line-ne-open\"\n | \"line-nw\"\n | \"line-nw-open\"\n | \"arrow\"\n | \"arrow-open\"\n | \"arrow-wide\"\n | \"arrow-wide-open\";\n\ninterface LineDataSeries {\n x: number[];\n y: number[];\n name: string;\n /** Optional color override (auto-assigned from CHART_COLORS if not provided) */\n color?: string;\n symbol?: MarkerSymbol;\n error_y?: {\n type: \"data\";\n array: number[];\n visible: boolean;\n };\n}\n\ntype LinePlotVariant = \"lines\" | \"lines+markers\" | \"lines+markers+error_bars\";\n\n/** Top margin reserving room for the 32px title; reduced when no title is set */\nconst TITLE_MARGIN_TOP = 60;\nconst NO_TITLE_MARGIN_TOP = 30;\n\ntype LinePlotProps = {\n dataSeries: LineDataSeries[];\n /**\n * Fixed width in pixels. When omitted, the chart fills its container and\n * tracks the container's width via a `ResizeObserver`.\n */\n width?: number;\n /**\n * Fixed height in pixels. When omitted, the chart fills its container and\n * tracks the container's height via a `ResizeObserver`.\n */\n height?: number;\n xRange?: [number, number];\n yRange?: [number, number];\n variant?: LinePlotVariant;\n xTitle?: string;\n yTitle?: string;\n title?: string;\n /**\n * Categorical labels for the x-axis ticks. When provided, the x data values\n * still drive line positioning but the displayed tick labels match these\n * strings in order (e.g. [\"Mon\", \"Tue\", …]). Should align 1:1 with the\n * unique, ordered x values across all series.\n */\n xTickText?: string[];\n};\n\nconst LinePlot: React.FC<LinePlotProps> = ({\n dataSeries,\n width,\n height,\n xRange,\n yRange,\n variant = \"lines\",\n xTitle,\n yTitle,\n title,\n xTickText,\n}) => {\n const plotRef = useRef<HTMLDivElement>(null);\n const theme = usePlotlyTheme();\n const { bindTooltip, tooltipElement } = useChartTooltip({ xLabel: xTitle, yLabel: yTitle });\n\n // Omitted width/height → fill the container and track its measured size;\n // explicit pixel values override. See AreaPlot for the reference pattern.\n const [containerRef, measured] = useElementSize<HTMLDivElement>();\n const resolvedWidth = width ?? measured.width;\n const resolvedHeight = height ?? measured.height;\n const hasSize = resolvedWidth > 0 && resolvedHeight > 0;\n // Fill is per-dimension: omit width to fill the container width, omit height\n // to fill its height (so e.g. a fixed width with a container-driven height works).\n const fillWidth = width === undefined;\n const fillHeight = height === undefined;\n const sizeRef = useRef({ width: resolvedWidth, height: resolvedHeight });\n sizeRef.current = { width: resolvedWidth, height: resolvedHeight };\n const plotInitedRef = useRef(false);\n // Size last applied to the plot, so the resize effect can skip a redundant\n // relayout right after newPlot already drew at that size.\n const appliedSizeRef = useRef({ width: 0, height: 0 });\n\n const { yMin, yMax } = useMemo(() => {\n let minX = Number.MAX_VALUE;\n let maxX = Number.MIN_VALUE;\n let minY = Number.MAX_VALUE;\n let maxY = Number.MIN_VALUE;\n\n dataSeries.forEach((series) => {\n series.x.forEach((x) => {\n minX = Math.min(minX, x);\n maxX = Math.max(maxX, x);\n });\n series.y.forEach((y) => {\n minY = Math.min(minY, y);\n maxY = Math.max(maxY, y);\n });\n });\n\n const xPadding = (maxX - minX) * 0.1;\n const yPadding = (maxY - minY) * 0.1;\n\n return {\n xMin: minX - xPadding,\n xMax: maxX + xPadding,\n yMin: minY - yPadding,\n yMax: maxY + yPadding,\n };\n }, [dataSeries]);\n\n const effectiveYRange = useMemo(\n () => yRange || [yMin, yMax],\n [yRange, yMin, yMax],\n );\n\n const yTicks = useMemo(() => {\n const range = effectiveYRange[1] - effectiveYRange[0];\n let step = Math.pow(10, Math.floor(Math.log10(range)));\n\n if (range / step > 10) step = step * 2;\n if (range / step < 4) step = step / 2;\n\n const ticks = [];\n let current = Math.ceil(effectiveYRange[0] / step) * step;\n while (current <= effectiveYRange[1]) {\n ticks.push(current);\n current += step;\n }\n return ticks;\n }, [effectiveYRange]);\n\n const xTicks = useMemo(\n () => [...new Set(dataSeries.flatMap((s) => s.x))].sort((a, b) => a - b),\n [dataSeries],\n );\n\n // Only apply categorical labels when they align 1:1 with the tick positions;\n // a mismatch would silently mis-label ticks, so fall back to numeric ticks.\n const useCategoricalX = !!xTickText && xTickText.length === xTicks.length;\n\n const mode = useMemo((): \"lines\" | \"lines+markers\" => {\n switch (variant) {\n case \"lines+markers\":\n case \"lines+markers+error_bars\":\n return \"lines+markers\";\n default:\n return \"lines\";\n }\n }, [variant]);\n\n const tickOptions = useMemo(\n () => ({\n tickcolor: theme.tickColor,\n ticklen: 12,\n tickwidth: 1,\n ticks: \"outside\" as const,\n tickfont: {\n size: 16,\n color: theme.textColor,\n family: CHART_FONT_FAMILY,\n weight: 400,\n },\n linecolor: theme.lineColor,\n linewidth: 1,\n position: 0,\n zeroline: false,\n }),\n [theme],\n );\n\n useEffect(() => {\n if (!plotRef.current || !hasSize) return;\n\n const plotData = dataSeries.map((series, index) => {\n const color = seriesColor(index, series.color);\n return {\n x: series.x,\n y: series.y,\n type: \"scatter\" as const,\n mode: mode,\n name: series.name,\n hoverinfo: \"none\" as const,\n line: {\n color,\n width: 1.5,\n },\n marker:\n variant === \"lines\"\n ? { opacity: 0 }\n : {\n color,\n size: 8,\n symbol: series.symbol || \"triangle-up\",\n },\n error_y:\n variant === \"lines+markers+error_bars\"\n ? series.error_y || {\n type: \"data\" as const,\n array: series.y.map(() => 10),\n visible: true,\n color,\n thickness: 1,\n width: 5,\n }\n : undefined,\n };\n });\n\n const layout = {\n ...(title\n ? {\n title: {\n text: title,\n font: {\n size: 32,\n family: CHART_FONT_FAMILY,\n color: theme.textColor,\n },\n },\n }\n : {}),\n width: sizeRef.current.width,\n height: sizeRef.current.height,\n margin: {\n l: 80,\n r: 30,\n // Reserve room for tick labels, the x-axis title, and the\n // container-anchored bottom legend stacked beneath them.\n b: 96,\n t: title ? TITLE_MARGIN_TOP : NO_TITLE_MARGIN_TOP,\n pad: 10,\n },\n paper_bgcolor: theme.paperBg,\n plot_bgcolor: theme.plotBg,\n font: {\n family: CHART_FONT_FAMILY,\n },\n dragmode: false as const,\n xaxis: {\n title: {\n text: xTitle,\n font: {\n size: 16,\n color: theme.textSecondary,\n family: CHART_FONT_FAMILY,\n weight: 400,\n },\n standoff: 32,\n },\n gridcolor: theme.gridColor,\n range: xRange,\n autorange: !xRange,\n tickmode: \"array\" as const,\n tickvals: xTicks,\n ticktext: useCategoricalX ? xTickText : xTicks.map(String),\n showgrid: true,\n // Reserve space for tick labels + the axis title so the bottom legend\n // can't overlap them at small sizes (SW-2157).\n automargin: true,\n ...tickOptions,\n },\n yaxis: {\n title: {\n text: yTitle,\n font: {\n size: 16,\n color: theme.textSecondary,\n family: CHART_FONT_FAMILY,\n weight: 400,\n },\n standoff: 30,\n },\n gridcolor: theme.gridColor,\n range: yRange,\n autorange: !yRange,\n tickmode: \"array\" as const,\n tickvals: yTicks,\n showgrid: true,\n automargin: true,\n ...tickOptions,\n },\n legend: {\n // Anchor to the bottom of the container (not the plot area) so the\n // legend always clears the x-axis tick labels + title — a paper-relative\n // fractional offset collapses into the ticks at small heights (SW-2157).\n x: 0.5,\n y: 0,\n xanchor: \"center\" as const,\n yanchor: \"bottom\" as const,\n yref: \"container\" as const,\n orientation: \"h\" as const,\n font: {\n size: 16,\n color: theme.legendColor,\n family: CHART_FONT_FAMILY,\n weight: 500,\n },\n },\n showlegend: true,\n };\n\n const config = {\n // Sizing is driven from the measured container; disable Plotly's own\n // window-resize responsiveness (it can't see container resizes).\n responsive: false,\n displayModeBar: false,\n displaylogo: false,\n };\n\n // Plotly is loaded lazily so it stays out of the consumer's main chunk\n // (SW-2007); the draw is skipped if the effect re-runs or unmounts first.\n let cancelled = false;\n let plotElement: HTMLDivElement | null = null;\n void loadPlotly().then((plotly) => {\n if (cancelled || !plotRef.current) return;\n plotly.newPlot(plotRef.current, plotData, layout, config);\n bindTooltip(plotRef.current);\n\n // Capture ref value for cleanup\n plotElement = plotRef.current;\n plotInitedRef.current = true;\n appliedSizeRef.current = { ...sizeRef.current };\n });\n\n return () => {\n cancelled = true;\n if (plotElement) {\n getLoadedPlotly().purge(plotElement);\n plotInitedRef.current = false;\n }\n };\n }, [dataSeries, hasSize, xRange, yRange, xTitle, yTitle, title, mode, tickOptions, xTicks, yTicks, useCategoricalX, xTickText, effectiveYRange, variant, theme, bindTooltip]);\n\n // Resize in place when the measured/overridden size changes — cheaper than\n // recreating the plot, and it preserves tooltip/event bindings.\n useEffect(() => {\n const plotElement = plotRef.current;\n if (!plotElement || !plotInitedRef.current || resolvedWidth <= 0 || resolvedHeight <= 0) {\n return;\n }\n // newPlot already drew at the current size; skip the redundant relayout\n // (it would queue an automargin redraw that can reject if we unmount first).\n if (\n appliedSizeRef.current.width === resolvedWidth &&\n appliedSizeRef.current.height === resolvedHeight\n ) {\n return;\n }\n appliedSizeRef.current = { width: resolvedWidth, height: resolvedHeight };\n // Swallow rejections from a relayout that races an unmount/purge.\n // plotInitedRef guarantees Plotly finished loading, so sync access is safe.\n void getLoadedPlotly()\n .relayout(plotElement, { width: resolvedWidth, height: resolvedHeight })\n .catch(() => {});\n }, [resolvedWidth, resolvedHeight]);\n\n return (\n <div ref={containerRef} className={cn(\"relative\", fillWidth && \"w-full\", fillHeight && \"h-full\")}>\n <div ref={plotRef} style={{ width: \"100%\", height: \"100%\" }} />\n {tooltipElement}\n </div>\n );\n};\n\nexport { LinePlot };\nexport type { LineDataSeries, LinePlotVariant, LinePlotProps, MarkerSymbol };\n"],"names":["TITLE_MARGIN_TOP","NO_TITLE_MARGIN_TOP","LinePlot","dataSeries","width","height","xRange","yRange","variant","xTitle","yTitle","title","xTickText","plotRef","useRef","theme","usePlotlyTheme","bindTooltip","tooltipElement","useChartTooltip","containerRef","measured","useElementSize","resolvedWidth","resolvedHeight","hasSize","fillWidth","fillHeight","sizeRef","plotInitedRef","appliedSizeRef","yMin","yMax","useMemo","minX","maxX","minY","maxY","series","x","y","xPadding","yPadding","effectiveYRange","yTicks","range","step","ticks","current","xTicks","s","a","b","useCategoricalX","mode","tickOptions","CHART_FONT_FAMILY","useEffect","plotData","index","color","seriesColor","layout","config","cancelled","plotElement","loadPlotly","plotly","getLoadedPlotly","jsxs","cn","jsx"],"mappings":"qYA+KMA,EAAmB,GACnBC,EAAsB,GA6BtBC,EAAoC,CAAC,CACzC,WAAAC,EACA,MAAAC,EACA,OAAAC,EACA,OAAAC,EACA,OAAAC,EACA,QAAAC,EAAU,QACV,OAAAC,EACA,OAAAC,EACA,MAAAC,EACA,UAAAC,CACF,IAAM,CACJ,MAAMC,EAAUC,EAAAA,OAAuB,IAAI,EACrCC,EAAQC,EAAAA,eAAA,EACR,CAAE,YAAAC,EAAa,e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