p1-charts 0.2.0 → 0.4.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 (168) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/README.md +158 -4
  3. package/dist/CategoryBarChart-KYzsjGwg.js +715 -0
  4. package/dist/CategoryBarChart-KYzsjGwg.js.map +1 -0
  5. package/dist/ChartFrame-DOEsou-R.js +403 -0
  6. package/dist/ChartFrame-DOEsou-R.js.map +1 -0
  7. package/dist/ChartLegend-B8ZmIG2y.js +46 -0
  8. package/dist/ChartLegend-B8ZmIG2y.js.map +1 -0
  9. package/dist/{Heatmap-C1XcTUg1.js → Heatmap-Bwhf305C.js} +278 -272
  10. package/dist/Heatmap-Bwhf305C.js.map +1 -0
  11. package/dist/{PieLegend-BZsv9IbF.js → PieLegend-16E6W10x.js} +94 -111
  12. package/dist/PieLegend-16E6W10x.js.map +1 -0
  13. package/dist/PolarChart-C_vPz-3K.js +489 -0
  14. package/dist/PolarChart-C_vPz-3K.js.map +1 -0
  15. package/dist/Sparkline-BApLVWfg.js +110 -0
  16. package/dist/Sparkline-BApLVWfg.js.map +1 -0
  17. package/dist/{TimeSeriesChart-BIwJxgnD.js → TimeSeriesChart-BZMLERDZ.js} +530 -529
  18. package/dist/{TimeSeriesChart-BIwJxgnD.js.map → TimeSeriesChart-BZMLERDZ.js.map} +1 -1
  19. package/dist/category.d.ts +5 -2
  20. package/dist/category.d.ts.map +1 -1
  21. package/dist/category.js +4 -3
  22. package/dist/charts/CategoryBarChart/index.d.ts +3 -1
  23. package/dist/charts/CategoryBarChart/index.d.ts.map +1 -1
  24. package/dist/charts/Heatmap/index.d.ts.map +1 -1
  25. package/dist/charts/PolarChart/index.d.ts.map +1 -1
  26. package/dist/charts/ScatterChart/index.d.ts +1 -1
  27. package/dist/charts/ScatterChart/index.d.ts.map +1 -1
  28. package/dist/charts/Sparkline/index.d.ts +5 -2
  29. package/dist/charts/Sparkline/index.d.ts.map +1 -1
  30. package/dist/components/ChartFrame/index.d.ts +7 -0
  31. package/dist/components/ChartFrame/index.d.ts.map +1 -0
  32. package/dist/components/ChartLegend/index.d.ts +13 -0
  33. package/dist/components/ChartLegend/index.d.ts.map +1 -0
  34. package/dist/components/ChartStory/index.d.ts +7 -0
  35. package/dist/components/ChartStory/index.d.ts.map +1 -0
  36. package/dist/components/HeatmapCells/index.d.ts +1 -1
  37. package/dist/components/HeatmapCells/index.d.ts.map +1 -1
  38. package/dist/{css-C-rsk7-l.js → css-BTZA9hea.js} +2 -2
  39. package/dist/{css-C-rsk7-l.js.map → css-BTZA9hea.js.map} +1 -1
  40. package/dist/heatmap.js +1 -1
  41. package/dist/hooks/useMarkMemory.d.ts +9 -0
  42. package/dist/hooks/useMarkMemory.d.ts.map +1 -0
  43. package/dist/hooks/usePieTween.d.ts.map +1 -1
  44. package/dist/hooks/useSteps.d.ts +4 -0
  45. package/dist/hooks/useSteps.d.ts.map +1 -0
  46. package/dist/hooks/useTween.d.ts +12 -0
  47. package/dist/hooks/useTween.d.ts.map +1 -0
  48. package/dist/index.d.ts +16 -1
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/index.js +122 -117
  51. package/dist/index.js.map +1 -1
  52. package/dist/motion.utils-DFoqptDi.js +55 -0
  53. package/dist/motion.utils-DFoqptDi.js.map +1 -0
  54. package/dist/pie.js +1 -1
  55. package/dist/scatter.d.ts +4 -1
  56. package/dist/scatter.d.ts.map +1 -1
  57. package/dist/scatter.js +3 -2
  58. package/dist/series.js +1 -1
  59. package/dist/{tooltip.utils-D7xaBSUK.js → shared-C1pGJV4T.js} +3 -7
  60. package/dist/shared-C1pGJV4T.js.map +1 -0
  61. package/dist/sparkline.d.ts +1 -1
  62. package/dist/sparkline.d.ts.map +1 -1
  63. package/dist/sparkline.js +2 -2
  64. package/dist/standalone/p1-charts.standalone.js +13 -0
  65. package/dist/standalone.d.ts +27 -0
  66. package/dist/standalone.d.ts.map +1 -0
  67. package/dist/story.d.ts +11 -0
  68. package/dist/story.d.ts.map +1 -0
  69. package/dist/story.js +7 -0
  70. package/dist/theme.js +3 -3
  71. package/dist/{theme.utils-CP1XtGIe.js → theme.utils-DF_e8LxQ.js} +132 -113
  72. package/dist/theme.utils-DF_e8LxQ.js.map +1 -0
  73. package/dist/tooltip.utils-CXD_NapA.js +9 -0
  74. package/dist/tooltip.utils-CXD_NapA.js.map +1 -0
  75. package/dist/types/category.d.ts +26 -0
  76. package/dist/types/category.d.ts.map +1 -1
  77. package/dist/types/heatmap.d.ts +3 -0
  78. package/dist/types/heatmap.d.ts.map +1 -1
  79. package/dist/types/heatmapParts.d.ts +2 -0
  80. package/dist/types/heatmapParts.d.ts.map +1 -1
  81. package/dist/types/motion.d.ts +31 -0
  82. package/dist/types/motion.d.ts.map +1 -0
  83. package/dist/types/pie.d.ts +3 -4
  84. package/dist/types/pie.d.ts.map +1 -1
  85. package/dist/types/polar.d.ts +3 -0
  86. package/dist/types/polar.d.ts.map +1 -1
  87. package/dist/types/scatter.d.ts +34 -0
  88. package/dist/types/scatter.d.ts.map +1 -1
  89. package/dist/types/sparkline.d.ts +3 -0
  90. package/dist/types/sparkline.d.ts.map +1 -1
  91. package/dist/types/story.d.ts +73 -0
  92. package/dist/types/story.d.ts.map +1 -0
  93. package/dist/{useChartTheme-B06p_jvu.js → useChartTheme-D0bQ3LQq.js} +2 -2
  94. package/dist/{useChartTheme-B06p_jvu.js.map → useChartTheme-D0bQ3LQq.js.map} +1 -1
  95. package/dist/useControllable-Crsr0byh.js +11 -0
  96. package/dist/useControllable-Crsr0byh.js.map +1 -0
  97. package/dist/useMarkMemory-CLNY6TtT.js +15 -0
  98. package/dist/useMarkMemory-CLNY6TtT.js.map +1 -0
  99. package/dist/useTween-B0G0CcvM.js +46 -0
  100. package/dist/useTween-B0G0CcvM.js.map +1 -0
  101. package/dist/utils/category.utils.d.ts +15 -1
  102. package/dist/utils/category.utils.d.ts.map +1 -1
  103. package/dist/utils/color.utils.d.ts +9 -0
  104. package/dist/utils/color.utils.d.ts.map +1 -1
  105. package/dist/utils/csv.utils.d.ts +6 -0
  106. package/dist/utils/csv.utils.d.ts.map +1 -0
  107. package/dist/utils/motion.utils.d.ts +25 -0
  108. package/dist/utils/motion.utils.d.ts.map +1 -1
  109. package/dist/utils/pieTween.utils.d.ts +1 -1
  110. package/dist/utils/pieTween.utils.d.ts.map +1 -1
  111. package/dist/utils/scatter.utils.d.ts +17 -1
  112. package/dist/utils/scatter.utils.d.ts.map +1 -1
  113. package/dist/utils/sparkline.utils.d.ts +15 -0
  114. package/dist/utils/sparkline.utils.d.ts.map +1 -1
  115. package/dist/utils/theme.utils.d.ts +1 -1
  116. package/dist/utils/theme.utils.d.ts.map +1 -1
  117. package/dist/{visibility.utils-nMI5a_Et.js → visibility.utils-wuc3ZS8D.js} +18 -25
  118. package/dist/visibility.utils-wuc3ZS8D.js.map +1 -0
  119. package/package.json +16 -5
  120. package/src/category.ts +5 -1
  121. package/src/charts/CategoryBarChart/index.tsx +310 -62
  122. package/src/charts/Heatmap/index.tsx +4 -0
  123. package/src/charts/PolarChart/index.tsx +98 -5
  124. package/src/charts/ScatterChart/index.tsx +164 -18
  125. package/src/charts/Sparkline/index.tsx +54 -7
  126. package/src/components/ChartFrame/index.tsx +180 -0
  127. package/src/components/ChartLegend/index.tsx +46 -0
  128. package/src/components/ChartStory/index.tsx +184 -0
  129. package/src/components/HeatmapCells/index.tsx +5 -2
  130. package/src/hooks/useMarkMemory.ts +29 -0
  131. package/src/hooks/usePieTween.ts +9 -44
  132. package/src/hooks/useSteps.ts +77 -0
  133. package/src/hooks/useTween.ts +112 -0
  134. package/src/index.ts +24 -1
  135. package/src/scatter.ts +4 -1
  136. package/src/sparkline.ts +1 -1
  137. package/src/standalone.tsx +68 -0
  138. package/src/story.ts +19 -0
  139. package/src/types/category.ts +27 -0
  140. package/src/types/heatmap.ts +3 -0
  141. package/src/types/heatmapParts.ts +2 -0
  142. package/src/types/motion.ts +35 -0
  143. package/src/types/pie.ts +3 -3
  144. package/src/types/polar.ts +3 -0
  145. package/src/types/scatter.ts +23 -0
  146. package/src/types/sparkline.ts +3 -0
  147. package/src/types/story.ts +103 -0
  148. package/src/utils/category.utils.ts +111 -2
  149. package/src/utils/color.utils.ts +48 -0
  150. package/src/utils/csv.utils.ts +28 -0
  151. package/src/utils/motion.utils.ts +124 -0
  152. package/src/utils/pieTween.utils.ts +1 -2
  153. package/src/utils/scatter.utils.ts +22 -5
  154. package/src/utils/sparkline.utils.ts +69 -0
  155. package/src/utils/theme.utils.ts +18 -15
  156. package/dist/CategoryBarChart-YEJ9VB8h.js +0 -453
  157. package/dist/CategoryBarChart-YEJ9VB8h.js.map +0 -1
  158. package/dist/Heatmap-C1XcTUg1.js.map +0 -1
  159. package/dist/PieLegend-BZsv9IbF.js.map +0 -1
  160. package/dist/PolarChart-BUEhn3CI.js +0 -334
  161. package/dist/PolarChart-BUEhn3CI.js.map +0 -1
  162. package/dist/Sparkline-DtNhxGVo.js +0 -67
  163. package/dist/Sparkline-DtNhxGVo.js.map +0 -1
  164. package/dist/motion.utils-C1eaZJdQ.js +0 -9
  165. package/dist/motion.utils-C1eaZJdQ.js.map +0 -1
  166. package/dist/theme.utils-CP1XtGIe.js.map +0 -1
  167. package/dist/tooltip.utils-D7xaBSUK.js.map +0 -1
  168. package/dist/visibility.utils-nMI5a_Et.js.map +0 -1
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["sameInputs","histogramColorsFromTheme","textStyle","toSrgb","withAlpha","removesUndefinedDefault","defaultTheme","themeFromCssVariables","pickPaths","chartOptionsFromTheme","deepMerge","createTheme","referenceLine","themedLine","pieArcs","symmetricExtent","extent","tidyTree","quantize","assertNonNegative","sum","useHeatmapSteps","heatmapGrid","normaliseRange","pointerCell","HeatmapLegend","heatmapLayout","stepColor","useHeatmapSelection","cellAt","rangeStats","useHeatmapState","extremes","Heatmap","inRange","ChartThemeProvider","useChartTheme","useChart","toUnixSeconds","useWheelZoom","CandlestickChart","resolveBandStyles","isUp","aggregatePoints","toLinePoints","SeriesChart","histogramPriceLines","RibbonPrimitive","LineChart","histogramOptions","editorialChartOptions","HistogramChart","colorBars","patchSquareCanvasLabels","aggregate","TimeSeriesChart","BarChart","TimeRangePrimitive","timeToX","normalizePoints","bandAt","pieSlices","arcPath","PieChart","placeLabels","usePieState","PieLegend","CategoryBarChart","ScatterChart","PolarChart","Sparkline","bin","p1Theme","p1ThemeFromCss","p1Accents","p1CssVariables","worst","total","areas","smallest","largest","side2","side","total2","placeRow","row","index","vertical","free","thickness","offset","length","squarify","values","out","rect","area","value","order","b","a","rowAreas","indices","next","useNowLine","element","line","instance","timeScale","chart","place","x","now","visible","TimelinePane","HistogramPane","BAR_HEIGHT","MAX_GRID","defaultStyle","theme","height","timeline","text","typography","hash","key","char","palette","timeRangeStyler","overrides","timelineRanges","items","bar","start","end","state","etaTime","eta","startTime","unixTimes","seconds","times","time","timeGrid","known","first","last","step","size","from","to","usePaneRanges","entries","useRef","useEffect","list","panes","detach","entry","lanes","pane","lane","inputs","options","primitive","usePaneSeries","create","series","HistogramSeries","defaults","mode","optionInputs","dataInputs","over","positive","negative","lineInputs","i","ROOT","LABELS","LABEL","PLOT","FILL","NOW","DEFAULTS","NO_POINTS","formatValue","point","ChartPanes","forwardRef","container","nowLine","handlers","axisHeight","setAxisHeight","useState","hovered","setHovered","resolved","paneHeight","laneHeight","children","isValidElement","child","firstOptions","useMemo","ctrlWheelZoom","chartOptions","update","active","pointsAt","normalized","onMove","param","points","onClick","useImperativeHandle","ref","heights","nowLineTheme","nowStyle","labelsStyle","labelStyle","titleStyle","metaStyle","classNames","styles","axisLabel","ariaLabel","TimelineChart","props","id"],"sources":["../src/utils/squarify.utils.ts","../src/hooks/useNowLine.ts","../src/charts/TimelinePane/index.tsx","../src/charts/HistogramPane/index.tsx","../src/utils/timeline.utils.ts","../src/hooks/usePaneRanges.ts","../src/hooks/usePaneSeries.ts","../src/charts/ChartPanes/index.tsx","../src/charts/TimelineChart/index.tsx"],"sourcesContent":["import type { LayoutRect } from \"../types/layout.js\";\nimport { sum, extent, assertNonNegative } from \"./layout.utils.js\";\n\nfunction worst(areas: ReadonlyArray<number>, side: number) {\n const total = sum(areas);\n const [smallest, largest] = extent(areas);\n const side2 = side * side;\n const total2 = total * total;\n\n return Math.max((side2 * largest) / total2, total2 / (side2 * smallest));\n}\n\nfunction placeRow(\n row: ReadonlyArray<number>,\n areas: ReadonlyArray<number>,\n free: LayoutRect,\n out: LayoutRect[],\n): LayoutRect {\n const total = sum(row.map((index) => areas[index]!));\n const vertical = free.width >= free.height;\n const thickness = total / (vertical ? free.height : free.width);\n let offset = 0;\n\n for (const index of row) {\n const length = areas[index]! / thickness;\n out[index] = vertical\n ? { x: free.x, y: free.y + offset, width: thickness, height: length }\n : { x: free.x + offset, y: free.y, width: length, height: thickness };\n offset += length;\n }\n\n return vertical\n ? {\n ...free,\n x: free.x + thickness,\n width: Math.max(0, free.width - thickness),\n }\n : {\n ...free,\n y: free.y + thickness,\n height: Math.max(0, free.height - thickness),\n };\n}\n\nexport function squarify(\n values: ReadonlyArray<number>,\n rect: LayoutRect,\n): LayoutRect[] {\n assertNonNegative(\"squarify\", values);\n\n const out = values.map(() => ({ x: rect.x, y: rect.y, width: 0, height: 0 }));\n const total = sum(values);\n const area = Math.max(0, rect.width) * Math.max(0, rect.height);\n\n if (total === 0 || area === 0) return out;\n\n const areas = values.map((value) => (value * area) / total);\n const order = areas\n .map((_, index) => index)\n .filter((index) => areas[index]! > 0)\n .sort((a, b) => areas[b]! - areas[a]! || a - b);\n\n let free = { ...rect };\n let row: number[] = [];\n const rowAreas = (indices: number[]) => indices.map((index) => areas[index]!);\n\n for (const index of order) {\n const side = Math.min(free.width, free.height);\n const next = [...row, index];\n\n if (\n row.length === 0 ||\n worst(rowAreas(next), side) <= worst(rowAreas(row), side)\n ) {\n row = next;\n } else {\n free = placeRow(row, areas, free, out);\n row = [index];\n }\n }\n\n if (row.length > 0) placeRow(row, areas, free, out);\n\n return out;\n}\n","import { useEffect, type RefObject } from \"react\";\nimport { timeToX } from \"../utils/timeScale.utils.js\";\nimport type { ChartInstance } from \"../types/chart.js\";\n\nexport function useNowLine(\n instance: ChartInstance<\"Histogram\"> | null,\n line: RefObject<HTMLDivElement | null>,\n now: number | null,\n) {\n useEffect(() => {\n const element = line.current;\n\n if (!instance || !element) return;\n\n const { chart } = instance;\n const timeScale = chart.timeScale();\n\n const place = () => {\n const x = now === null ? null : timeToX(timeScale, now);\n const visible = x !== null && x >= 0 && x <= timeScale.width();\n\n element.style.display = visible ? \"block\" : \"none\";\n if (visible)\n element.style.transform = `translateX(${x + chart.priceScale(\"left\").width()}px)`;\n };\n\n place();\n timeScale.subscribeVisibleLogicalRangeChange(place);\n timeScale.subscribeSizeChange(place);\n\n return () => {\n timeScale.unsubscribeVisibleLogicalRangeChange(place);\n timeScale.unsubscribeSizeChange(place);\n };\n }, [instance, line, now]);\n}\n","import type { TimelinePaneProps } from \"../../types/timeline.js\";\n\nexport function TimelinePane(_props: TimelinePaneProps): null {\n return null;\n}\n","import type { HistogramPaneProps } from \"../../types/panes.js\";\n\nexport function HistogramPane(_props: HistogramPaneProps): null {\n return null;\n}\n","import type {\n TimelineItem,\n TimeRangeItem,\n TimeRangeStyle,\n} from \"../types/timeline.js\";\n\nimport type { Time } from \"../types/chart.js\";\nimport { deepMerge } from \"./merge.utils.js\";\nimport { toUnixSeconds } from \"./time.utils.js\";\nimport type { Theme } from \"../types/theme.js\";\n\nconst BAR_HEIGHT = 18;\nconst MAX_GRID = 5000;\n\nfunction defaultStyle(theme: Theme, key: string): TimeRangeStyle {\n const { palette, typography, timeline } = theme;\n const height = timeline.barHeight ?? BAR_HEIGHT;\n const text = (color: string) => ({ ...typography.label, color });\n const hash = [...key].reduce((sum, char) => sum + char.charCodeAt(0), 0);\n\n switch (key) {\n case \"active\":\n return {\n fill: palette.categorical[0] ?? palette.neutral,\n height,\n text: text(palette.background),\n };\n case \"confirmed\":\n return { fill: palette.grid, height, text: text(palette.text) };\n case \"tentative\":\n return {\n stroke: { color: palette.neutral, width: 1, style: \"dashed\" },\n height,\n text: text(palette.text),\n };\n case \"arrival\":\n return {\n hatch: { color: palette.neutral, spacing: 6, width: 1, opacity: 0.55 },\n height,\n };\n }\n\n const fill =\n palette.categorical[hash % palette.categorical.length] ?? palette.neutral;\n\n return { fill, height, text: text(palette.background) };\n}\n\nexport function timeRangeStyler(\n theme: Theme | null,\n overrides: Record<string, TimeRangeStyle> = {},\n): (key: string) => TimeRangeStyle {\n return (key) =>\n deepMerge<TimeRangeStyle>(\n theme && defaultStyle(theme, key),\n theme?.timeline.styles?.[key],\n overrides[key],\n );\n}\n\nexport function timelineRanges(\n items: ReadonlyArray<TimelineItem>,\n): TimeRangeItem[] {\n return items.flatMap(({ start, end, eta, state, label, color }) => {\n const bar = { from: start, to: end, key: state, label, color };\n const etaTime = eta === undefined ? null : toUnixSeconds(eta);\n const startTime = toUnixSeconds(start);\n\n return etaTime !== null && startTime !== null && etaTime < startTime\n ? [{ from: eta!, to: start, key: \"arrival\" }, bar]\n : [bar];\n });\n}\n\nexport function unixTimes(times: ReadonlyArray<Time>): number[] {\n const seconds = times\n .map(toUnixSeconds)\n .filter((time): time is number => time !== null);\n\n return [...new Set(seconds)].sort((a, b) => a - b);\n}\n\nexport function timeGrid(times: ReadonlyArray<Time>, step = 3600): number[] {\n const known = unixTimes(times);\n const first = known[0];\n const last = known[known.length - 1];\n\n if (first === undefined || last === undefined || !(step > 0)) return [];\n\n const size = Math.max(step, Math.ceil((last - first) / MAX_GRID));\n const from = Math.floor(first / size) * size;\n const to = Math.ceil(last / size) * size;\n\n return Array.from(\n { length: Math.max(1, (to - from) / size + 1) },\n (_, index) => from + index * size,\n );\n}\n","import { useEffect, useRef } from \"react\";\nimport { sameInputs } from \"../utils/merge.utils.js\";\nimport type { Theme } from \"../types/theme.js\";\nimport type { ChartInstance } from \"../types/chart.js\";\nimport { TimeRangePrimitive } from \"../primitives/TimeRangePrimitive.js\";\nimport type { RangeEntry, TimelinePaneProps } from \"../types/timeline.js\";\nimport { timelineRanges, timeRangeStyler } from \"../utils/timeline.utils.js\";\n\nexport function usePaneRanges(\n instance: ChartInstance<\"Histogram\"> | null,\n lanes: ReadonlyArray<TimelinePaneProps | null>,\n theme: Theme | null,\n) {\n const entries = useRef<Array<RangeEntry | undefined>>([]);\n\n useEffect(() => {\n entries.current = [];\n }, [instance]);\n\n useEffect(() => {\n if (!instance) return;\n\n const list = entries.current;\n const panes = instance.chart.panes();\n const detach = (entry: RangeEntry | undefined) =>\n entry?.pane.detachPrimitive(entry.primitive);\n\n lanes.forEach((lane, index) => {\n const pane = panes[index];\n let entry = list[index];\n\n if (entry && (!lane || entry.pane !== pane)) {\n detach(entry);\n entry = list[index] = undefined;\n }\n\n if (!lane || !pane) return;\n\n const inputs = [lane.items, lane.styles, theme];\n\n if (entry && sameInputs(entry.inputs, inputs)) return;\n\n const options = {\n items: timelineRanges(lane.items),\n style: timeRangeStyler(theme, lane.styles),\n };\n\n if (entry) {\n entry.primitive.applyOptions(options);\n entry.inputs = inputs;\n return;\n }\n\n const primitive = new TimeRangePrimitive(options);\n\n pane.attachPrimitive(primitive);\n list[index] = { pane, primitive, inputs };\n });\n\n list.splice(lanes.length).forEach(detach);\n });\n}\n","import {\n HistogramSeries,\n type LineData,\n type IPriceLine,\n type ISeriesApi,\n type UTCTimestamp,\n type HistogramSeriesPartialOptions,\n} from \"lightweight-charts\";\n\nimport {\n colorBars,\n histogramOptions,\n histogramPriceLines,\n} from \"../utils/histogram.utils.js\";\n\nimport {\n deepMerge,\n pickPaths,\n sameInputs,\n removesUndefinedDefault,\n} from \"../utils/merge.utils.js\";\n\nimport { normalizePoints } from \"../utils/data.utils.js\";\nimport type { NormalizedSeries } from \"../types/series.js\";\n\nimport {\n themedLine,\n referenceLine,\n histogramColorsFromTheme,\n} from \"../utils/theme.utils.js\";\n\nimport type { Theme } from \"../types/theme.js\";\nimport type { LinePoint } from \"../types/chart.js\";\nimport type { ChartInstance } from \"../types/chart.js\";\nimport { unixTimes } from \"../utils/timeline.utils.js\";\nimport { useEffect, useRef, type RefObject } from \"react\";\nimport type { PaneSeriesInput, HistogramPaneProps } from \"../types/panes.js\";\n\nexport interface PaneEntry {\n series: ISeriesApi<\"Histogram\">;\n defaults: HistogramSeriesPartialOptions;\n options: HistogramSeriesPartialOptions;\n optionInputs: unknown[];\n dataInputs: unknown[];\n lineInputs: unknown[];\n lines: IPriceLine[];\n normalized: NormalizedSeries<LinePoint, LineData>;\n}\n\nexport function usePaneSeries(\n instance: ChartInstance<\"Histogram\"> | null,\n panes: ReadonlyArray<PaneSeriesInput>,\n theme: Theme | null,\n): RefObject<PaneEntry[]> {\n const entries = useRef<PaneEntry[]>([]);\n\n useEffect(() => {\n entries.current = [];\n }, [instance]);\n\n useEffect(() => {\n if (!instance) return;\n\n const { chart } = instance;\n const list = entries.current;\n\n const create = (\n index: number,\n options: HistogramSeriesPartialOptions,\n optionInputs: unknown[],\n ): PaneEntry => {\n const series =\n index === 0\n ? instance.series\n : chart.addSeries(HistogramSeries, {}, index);\n const defaults = deepMerge<HistogramSeriesPartialOptions>(\n series.options(),\n );\n\n if (index > 0) {\n series.applyOptions(options);\n chart.panes()[index]?.setPreserveEmptyPane(true);\n }\n\n return {\n series,\n defaults,\n options,\n optionInputs,\n dataInputs: [],\n lineInputs: [],\n lines: [],\n normalized: normalizePoints([]),\n };\n };\n\n panes.forEach((pane, index) => {\n const mode = pane.mode ?? \"plain\";\n const optionInputs = [mode, pane.seriesOptions];\n const options = histogramOptions(mode, pane.seriesOptions);\n let entry = list[index];\n\n if (entry && index > 0 && !sameInputs(entry.optionInputs, optionInputs)) {\n if (removesUndefinedDefault(entry.defaults, entry.options, options)) {\n chart.removeSeries(entry.series);\n entry = undefined;\n } else {\n entry.series.applyOptions(\n deepMerge(pickPaths(entry.defaults, entry.options), options),\n );\n entry.options = options;\n entry.optionInputs = optionInputs;\n }\n }\n\n if (!entry) list[index] = entry = create(index, options, optionInputs);\n\n const { bar, over, positive, negative } = deepMerge<\n NonNullable<HistogramPaneProps[\"colors\"]>\n >(histogramColorsFromTheme(theme), pane.colors);\n const dataInputs = [\n pane.data,\n pane.whitespace,\n mode,\n pane.threshold,\n bar,\n over,\n positive,\n negative,\n ];\n\n if (!sameInputs(entry.dataInputs, dataInputs)) {\n entry.normalized = normalizePoints(pane.data);\n entry.series.setData(\n pane.whitespace\n ? unixTimes(pane.whitespace).map((time) => ({\n time: time as UTCTimestamp,\n }))\n : colorBars(entry.normalized.data, mode, pane.threshold, {\n bar,\n over,\n positive,\n negative,\n }),\n );\n entry.dataInputs = dataInputs;\n }\n\n const lineInputs = [\n mode,\n pane.threshold,\n pane.thresholdLine,\n pane.zeroLine,\n theme,\n ];\n\n if (!sameInputs(entry.lineInputs, lineInputs)) {\n const { series } = entry;\n\n entry.lines.forEach((line) => series.removePriceLine(line));\n entry.lines = histogramPriceLines(\n mode,\n pane.threshold,\n themedLine(\n referenceLine(theme, theme?.histogram.threshold, \"dashed\"),\n pane.thresholdLine,\n ),\n themedLine(\n referenceLine(theme, theme?.histogram.zero, \"solid\"),\n pane.zeroLine,\n ),\n ).map((line) => series.createPriceLine(line));\n entry.lineInputs = lineInputs;\n }\n\n chart.panes()[index]?.setStretchFactor(pane.height);\n });\n\n list.splice(panes.length).forEach((entry) => {\n if (entry.series !== instance.series) {\n chart.removeSeries(entry.series);\n return;\n }\n\n entry.lines.forEach((line) => entry.series.removePriceLine(line));\n entry.series.setData([]);\n });\n\n for (let i = chart.panes().length - 1; i >= Math.max(panes.length, 1); i--)\n chart.removePane(i);\n });\n\n return entries;\n}\n","import {\n useRef,\n useMemo,\n useState,\n Children,\n useEffect,\n forwardRef,\n isValidElement,\n type CSSProperties,\n useImperativeHandle,\n} from \"react\";\n\nimport {\n HistogramSeries,\n type DeepPartial,\n type ChartOptions,\n type MouseEventParams,\n} from \"lightweight-charts\";\n\nimport type {\n ChartPanesProps,\n ChartPanesHandle,\n PaneSeriesInput,\n HistogramPaneProps,\n} from \"../../types/panes.js\";\n\nimport {\n textStyle,\n defaultTheme,\n chartOptionsFromTheme,\n} from \"../../utils/theme.utils.js\";\n\nimport { useChart } from \"../../hooks/useChart.js\";\nimport type { ThemeLine } from \"../../types/theme.js\";\nimport type { LinePoint } from \"../../types/chart.js\";\nimport { useNowLine } from \"../../hooks/useNowLine.js\";\nimport { deepMerge } from \"../../utils/merge.utils.js\";\nimport { TimelinePane } from \"../TimelinePane/index.js\";\nimport { HistogramPane } from \"../HistogramPane/index.js\";\nimport { toUnixSeconds } from \"../../utils/time.utils.js\";\nimport { useWheelZoom } from \"../../hooks/useWheelZoom.js\";\nimport { useChartTheme } from \"../../hooks/useChartTheme.js\";\nimport { usePaneRanges } from \"../../hooks/usePaneRanges.js\";\nimport { usePaneSeries } from \"../../hooks/usePaneSeries.js\";\nimport type { TimelinePaneProps } from \"../../types/timeline.js\";\nimport { histogramOptions } from \"../../utils/histogram.utils.js\";\n\nconst ROOT: CSSProperties = { display: \"flex\" };\nconst LABELS: CSSProperties = { flex: \"none\" };\nconst LABEL: CSSProperties = { boxSizing: \"border-box\", overflow: \"hidden\" };\nconst PLOT: CSSProperties = { position: \"relative\", flex: 1, minWidth: 0 };\nconst FILL: CSSProperties = { position: \"absolute\", inset: 0 };\nconst NOW: CSSProperties = {\n position: \"absolute\",\n top: 0,\n left: 0,\n width: 1,\n display: \"none\",\n pointerEvents: \"none\",\n};\nconst DEFAULTS: DeepPartial<ChartOptions> = {\n layout: { panes: { enableResize: false } },\n};\n\nconst NO_POINTS: LinePoint[] = [];\n\nconst formatValue = (point: LinePoint) => point.value.toLocaleString();\n\nexport const ChartPanes = forwardRef<ChartPanesHandle | null, ChartPanesProps>(\n function ChartPanes(\n {\n children,\n now = null,\n axisLabel,\n chartOptions,\n ctrlWheelZoom = true,\n ariaLabel = \"Chart panes\",\n className,\n classNames = {},\n styles = {},\n onPaneClick,\n onPaneHover,\n onPaneLeave,\n theme,\n unstyled,\n },\n ref,\n ) {\n const container = useRef<HTMLDivElement>(null);\n const nowLine = useRef<HTMLDivElement>(null);\n const handlers = useRef({ onPaneClick, onPaneHover, onPaneLeave });\n const [axisHeight, setAxisHeight] = useState(0);\n const [hovered, setHovered] = useState<Array<LinePoint | null> | null>(\n null,\n );\n handlers.current = { onPaneClick, onPaneHover, onPaneLeave };\n\n const resolved = useChartTheme({ theme, unstyled });\n const paneHeight =\n resolved?.sizes.paneHeight ?? defaultTheme.sizes.paneHeight;\n const laneHeight = resolved?.sizes.laneHeight ?? paneHeight;\n const lanes: Array<TimelinePaneProps | null> = [];\n const panes: PaneSeriesInput[] = [];\n\n Children.forEach(children, (child) => {\n if (\n isValidElement<HistogramPaneProps>(child) &&\n child.type === HistogramPane\n ) {\n lanes.push(null);\n panes.push({\n ...child.props,\n height: child.props.height ?? paneHeight,\n });\n }\n if (\n isValidElement<TimelinePaneProps>(child) &&\n child.type === TimelinePane\n ) {\n const { label, meta, height = laneHeight, times } = child.props;\n\n lanes.push(child.props);\n panes.push({ label, meta, height, data: NO_POINTS, whitespace: times });\n }\n });\n\n const first = panes[0];\n const firstOptions = useMemo(\n () => histogramOptions(first?.mode ?? \"plain\", first?.seriesOptions),\n [first?.mode, first?.seriesOptions],\n );\n const options = useMemo(\n () =>\n deepMerge<DeepPartial<ChartOptions>>(\n chartOptionsFromTheme(resolved),\n DEFAULTS,\n ctrlWheelZoom && {\n handleScale: { mouseWheel: false },\n handleScroll: { mouseWheel: false },\n },\n chartOptions,\n ),\n [resolved, ctrlWheelZoom, chartOptions],\n );\n\n const instance = useChart(\n container,\n HistogramSeries,\n options,\n firstOptions,\n );\n const entries = usePaneSeries(instance, panes, resolved);\n usePaneRanges(instance, lanes, resolved);\n useWheelZoom(instance, container, ctrlWheelZoom);\n\n useEffect(() => {\n if (!instance) return;\n\n const timeScale = instance.chart.timeScale();\n const update = () => setAxisHeight(timeScale.height());\n\n update();\n timeScale.subscribeSizeChange(update);\n\n return () => timeScale.unsubscribeSizeChange(update);\n }, [instance]);\n\n useEffect(() => {\n if (!instance) return;\n\n const { chart } = instance;\n let active = false;\n\n const pointsAt = (time: number) =>\n entries.current.map(({ normalized }) => {\n const index = normalized.indexByTime.get(time);\n\n return index === undefined\n ? null\n : (normalized.points[index] ?? null);\n });\n\n const onMove = (param: MouseEventParams) => {\n if (param.time === undefined || !param.point) {\n if (!active) return;\n\n active = false;\n setHovered(null);\n handlers.current.onPaneLeave?.();\n return;\n }\n\n const time = Number(param.time);\n const points = pointsAt(time);\n\n active = true;\n setHovered(points);\n handlers.current.onPaneHover?.({ time, points });\n };\n\n const onClick = (param: MouseEventParams) => {\n if (param.time === undefined) return;\n\n const time = Number(param.time);\n\n handlers.current.onPaneClick?.({ time, points: pointsAt(time) });\n };\n\n chart.subscribeCrosshairMove(onMove);\n chart.subscribeClick(onClick);\n\n return () => {\n chart.unsubscribeCrosshairMove(onMove);\n chart.unsubscribeClick(onClick);\n };\n }, [instance, entries]);\n\n useNowLine(instance, nowLine, now === null ? null : toUnixSeconds(now));\n\n useImperativeHandle<ChartPanesHandle | null, ChartPanesHandle | null>(\n ref,\n () =>\n instance\n ? {\n chart: instance.chart,\n get series() {\n return entries.current.map((entry) => entry.series);\n },\n }\n : null,\n [instance, entries],\n );\n\n const heights = panes.map((pane) => pane.height);\n const nowLineTheme =\n resolved &&\n deepMerge<ThemeLine>({ color: resolved.palette.now }, resolved.panes.now);\n const nowStyle: CSSProperties = nowLineTheme\n ? {\n width: 0,\n borderLeft: `${nowLineTheme.width ?? 1}px ${nowLineTheme.style ?? \"solid\"} ${nowLineTheme.color}`,\n }\n : {};\n const labelsStyle: CSSProperties = { width: resolved?.sizes.paneLabel };\n const labelStyle: CSSProperties = { padding: resolved?.spacing.paneLabel };\n const titleStyle = textStyle(\n resolved\n ? deepMerge(resolved.typography.title, resolved.panes.title)\n : undefined,\n );\n const metaStyle = textStyle(\n resolved\n ? deepMerge(resolved.typography.value, resolved.panes.meta)\n : undefined,\n );\n const total =\n heights.reduce((sum, height) => sum + height, 0) +\n Math.max(0, panes.length - 1) +\n axisHeight;\n\n return (\n <div className={className} style={ROOT}>\n <div\n data-part=\"labels\"\n className={classNames.labels}\n style={{ ...LABELS, ...labelsStyle, ...styles.labels }}\n >\n {panes.map((pane, index) => {\n const point = hovered?.[index];\n\n return (\n <div\n key={index}\n data-part=\"label\"\n className={classNames.label}\n style={{\n ...LABEL,\n ...labelStyle,\n height: heights[index]! + (index > 0 ? 1 : 0),\n ...styles.label,\n }}\n >\n <div\n data-part=\"title\"\n className={classNames.title}\n style={{ ...titleStyle, ...styles.title }}\n >\n {pane.label}\n </div>\n <div\n data-part=\"meta\"\n className={classNames.meta}\n style={{ ...metaStyle, ...styles.meta }}\n >\n {point ? (pane.format ?? formatValue)(point) : pane.meta}\n </div>\n </div>\n );\n })}\n <div\n data-part=\"axis\"\n className={classNames.axis}\n style={{ ...LABEL, height: axisHeight, ...styles.axis }}\n >\n {axisLabel}\n </div>\n </div>\n <div\n data-part=\"plot\"\n className={classNames.plot}\n style={{ ...PLOT, height: total, ...styles.plot }}\n >\n <div ref={container} style={FILL} role=\"img\" aria-label={ariaLabel} />\n <div\n ref={nowLine}\n data-part=\"now\"\n className={classNames.now}\n style={{ ...NOW, ...nowStyle, bottom: axisHeight, ...styles.now }}\n aria-hidden=\"true\"\n />\n </div>\n </div>\n );\n },\n);\n","import { forwardRef, useMemo } from \"react\";\nimport { ChartPanes } from \"../ChartPanes/index.js\";\nimport { TimelinePane } from \"../TimelinePane/index.js\";\nimport { timeGrid } from \"../../utils/timeline.utils.js\";\nimport type { ChartPanesHandle } from \"../../types/panes.js\";\nimport type { TimelineChartProps } from \"../../types/timeline.js\";\n\nexport const TimelineChart = forwardRef<\n ChartPanesHandle | null,\n TimelineChartProps\n>(function TimelineChart({ lanes, step, ...props }, ref) {\n const times = useMemo(\n () =>\n timeGrid(\n lanes.flatMap((lane) =>\n lane.items.flatMap(({ start, end, eta }) =>\n eta === undefined ? [start, end] : [eta, start, end],\n ),\n ),\n step,\n ),\n [lanes, step],\n );\n\n return (\n <ChartPanes ref={ref} {...props}>\n {lanes.map(({ id, ...lane }, index) => (\n <TimelinePane\n key={id}\n {...lane}\n times={index === 0 ? times : undefined}\n />\n ))}\n </ChartPanes>\n );\n});\n"],"mappings":";;;;;;;;;;;;;;;;AAGA,SAAS4E,GAAM,GAA8B,GAAc;CACzD,IAAMC,IAAQzD,EAAI0D,CAAK,GACjB,CAACC,GAAUC,KAAWhE,EAAO8D,CAAK,GAClCG,IAAQC,IAAOA,GACfC,IAASN,IAAQA;CAEvB,OAAO,KAAK,IAAKI,IAAQD,IAAWG,GAAQA,KAAUF,IAAQF,EAAS;AACzE;AAEA,SAASK,GACP,GACA,GACA,GACA,GACY;CACZ,IAAMP,IAAQzD,EAAIiE,EAAI,KAAK,MAAUP,EAAMQ,EAAO,CAAC,GAC7CC,IAAWC,EAAK,SAASA,EAAK,QAC9BC,IAAYZ,KAASU,IAAWC,EAAK,SAASA,EAAK,QACrDE,IAAS;CAEb,KAAK,IAAMJ,KAASD,GAAK;EACvB,IAAMM,IAASb,EAAMQ,KAAUG;EAI/B,AAHA,EAAIH,KAASC,IACT;GAAE,GAAGC,EAAK;GAAG,GAAGA,EAAK,IAAIE;GAAQ,OAAOD;GAAW,QAAQE;EAAO,IAClE;GAAE,GAAGH,EAAK,IAAIE;GAAQ,GAAGF,EAAK;GAAG,OAAOG;GAAQ,QAAQF;EAAU,GACtE,KAAUE;CACZ;CAEA,OAAOJ,IACH;EACE,GAAGC;EACH,GAAGA,EAAK,IAAIC;EACZ,OAAO,KAAK,IAAI,GAAGD,EAAK,QAAQC,CAAS;CAC3C,IACA;EACE,GAAGD;EACH,GAAGA,EAAK,IAAIC;EACZ,QAAQ,KAAK,IAAI,GAAGD,EAAK,SAASC,CAAS;CAC7C;AACN;AAEA,SAAgBG,GACd,GACA,GACc;CACd,EAAkB,YAAYC,CAAM;CAEpC,IAAMC,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;CACS,CAAA;AAEhB,CAAC"}
1
+ {"version":3,"file":"index.js","names":["removesUndefinedDefault","histogramColorsFromTheme","textStyle","contrastRatio","readableInk","pickPaths","deepMerge","defaultTheme","themeFromCssVariables","withAlpha","chartOptionsFromTheme","toSrgb","createTheme","referenceLine","themedLine","sameInputs","quantize","tidyTree","pieArcs","assertNonNegative","sum","extent","symmetricExtent","useHeatmapSteps","heatmapGrid","normaliseRange","pointerCell","HeatmapLegend","heatmapLayout","stepColor","useHeatmapSelection","cellAt","rangeStats","useHeatmapState","extremes","Heatmap","inRange","linear","easeInOutCubic","easeOutCubic","ChartThemeProvider","useChartTheme","useChart","toUnixSeconds","useWheelZoom","CandlestickChart","resolveBandStyles","isUp","aggregatePoints","toLinePoints","SeriesChart","histogramPriceLines","RibbonPrimitive","LineChart","histogramOptions","editorialChartOptions","HistogramChart","colorBars","patchSquareCanvasLabels","aggregate","TimeSeriesChart","BarChart","TimeRangePrimitive","timeToX","normalizePoints","bandAt","pieSlices","arcPath","PieChart","placeLabels","usePieState","PieLegend","useTween","niceStep","niceExtent","CategoryBarChart","useMarkMemory","ChartLegend","ScatterChart","PolarChart","Sparkline","bin","p1Theme","p1ThemeFromCss","p1Accents","p1CssVariables","useSteps","ChartStory","downloadCsv","toCsv","ChartFrame","worst","total","areas","smallest","largest","side2","side","total2","placeRow","row","index","vertical","free","thickness","offset","length","squarify","values","out","rect","area","value","order","b","a","rowAreas","indices","next","useNowLine","element","line","instance","timeScale","chart","place","x","now","visible","TimelinePane","HistogramPane","BAR_HEIGHT","MAX_GRID","defaultStyle","theme","height","timeline","text","typography","hash","key","char","palette","timeRangeStyler","overrides","timelineRanges","items","bar","start","end","state","etaTime","eta","startTime","unixTimes","seconds","times","time","timeGrid","known","first","last","step","size","from","to","usePaneRanges","entries","useRef","useEffect","list","panes","detach","entry","lanes","pane","lane","inputs","options","primitive","usePaneSeries","create","series","HistogramSeries","defaults","mode","optionInputs","dataInputs","over","positive","negative","lineInputs","i","ROOT","LABELS","LABEL","PLOT","FILL","NOW","DEFAULTS","NO_POINTS","formatValue","point","ChartPanes","forwardRef","container","nowLine","handlers","axisHeight","setAxisHeight","useState","hovered","setHovered","resolved","paneHeight","laneHeight","children","isValidElement","child","firstOptions","useMemo","ctrlWheelZoom","chartOptions","update","active","pointsAt","normalized","onMove","param","points","onClick","useImperativeHandle","ref","heights","nowLineTheme","nowStyle","labelsStyle","labelStyle","titleStyle","metaStyle","classNames","styles","axisLabel","ariaLabel","TimelineChart","props","id"],"sources":["../src/utils/squarify.utils.ts","../src/hooks/useNowLine.ts","../src/charts/TimelinePane/index.tsx","../src/charts/HistogramPane/index.tsx","../src/utils/timeline.utils.ts","../src/hooks/usePaneRanges.ts","../src/hooks/usePaneSeries.ts","../src/charts/ChartPanes/index.tsx","../src/charts/TimelineChart/index.tsx"],"sourcesContent":["import type { LayoutRect } from \"../types/layout.js\";\nimport { sum, extent, assertNonNegative } from \"./layout.utils.js\";\n\nfunction worst(areas: ReadonlyArray<number>, side: number) {\n const total = sum(areas);\n const [smallest, largest] = extent(areas);\n const side2 = side * side;\n const total2 = total * total;\n\n return Math.max((side2 * largest) / total2, total2 / (side2 * smallest));\n}\n\nfunction placeRow(\n row: ReadonlyArray<number>,\n areas: ReadonlyArray<number>,\n free: LayoutRect,\n out: LayoutRect[],\n): LayoutRect {\n const total = sum(row.map((index) => areas[index]!));\n const vertical = free.width >= free.height;\n const thickness = total / (vertical ? free.height : free.width);\n let offset = 0;\n\n for (const index of row) {\n const length = areas[index]! / thickness;\n out[index] = vertical\n ? { x: free.x, y: free.y + offset, width: thickness, height: length }\n : { x: free.x + offset, y: free.y, width: length, height: thickness };\n offset += length;\n }\n\n return vertical\n ? {\n ...free,\n x: free.x + thickness,\n width: Math.max(0, free.width - thickness),\n }\n : {\n ...free,\n y: free.y + thickness,\n height: Math.max(0, free.height - thickness),\n };\n}\n\nexport function squarify(\n values: ReadonlyArray<number>,\n rect: LayoutRect,\n): LayoutRect[] {\n assertNonNegative(\"squarify\", values);\n\n const out = values.map(() => ({ x: rect.x, y: rect.y, width: 0, height: 0 }));\n const total = sum(values);\n const area = Math.max(0, rect.width) * Math.max(0, rect.height);\n\n if (total === 0 || area === 0) return out;\n\n const areas = values.map((value) => (value * area) / total);\n const order = areas\n .map((_, index) => index)\n .filter((index) => areas[index]! > 0)\n .sort((a, b) => areas[b]! - areas[a]! || a - b);\n\n let free = { ...rect };\n let row: number[] = [];\n const rowAreas = (indices: number[]) => indices.map((index) => areas[index]!);\n\n for (const index of order) {\n const side = Math.min(free.width, free.height);\n const next = [...row, index];\n\n if (\n row.length === 0 ||\n worst(rowAreas(next), side) <= worst(rowAreas(row), side)\n ) {\n row = next;\n } else {\n free = placeRow(row, areas, free, out);\n row = [index];\n }\n }\n\n if (row.length > 0) placeRow(row, areas, free, out);\n\n return out;\n}\n","import { useEffect, type RefObject } from \"react\";\nimport { timeToX } from \"../utils/timeScale.utils.js\";\nimport type { ChartInstance } from \"../types/chart.js\";\n\nexport function useNowLine(\n instance: ChartInstance<\"Histogram\"> | null,\n line: RefObject<HTMLDivElement | null>,\n now: number | null,\n) {\n useEffect(() => {\n const element = line.current;\n\n if (!instance || !element) return;\n\n const { chart } = instance;\n const timeScale = chart.timeScale();\n\n const place = () => {\n const x = now === null ? null : timeToX(timeScale, now);\n const visible = x !== null && x >= 0 && x <= timeScale.width();\n\n element.style.display = visible ? \"block\" : \"none\";\n if (visible)\n element.style.transform = `translateX(${x + chart.priceScale(\"left\").width()}px)`;\n };\n\n place();\n timeScale.subscribeVisibleLogicalRangeChange(place);\n timeScale.subscribeSizeChange(place);\n\n return () => {\n timeScale.unsubscribeVisibleLogicalRangeChange(place);\n timeScale.unsubscribeSizeChange(place);\n };\n }, [instance, line, now]);\n}\n","import type { TimelinePaneProps } from \"../../types/timeline.js\";\n\nexport function TimelinePane(_props: TimelinePaneProps): null {\n return null;\n}\n","import type { HistogramPaneProps } from \"../../types/panes.js\";\n\nexport function HistogramPane(_props: HistogramPaneProps): null {\n return null;\n}\n","import type {\n TimelineItem,\n TimeRangeItem,\n TimeRangeStyle,\n} from \"../types/timeline.js\";\n\nimport type { Time } from \"../types/chart.js\";\nimport { deepMerge } from \"./merge.utils.js\";\nimport { toUnixSeconds } from \"./time.utils.js\";\nimport type { Theme } from \"../types/theme.js\";\n\nconst BAR_HEIGHT = 18;\nconst MAX_GRID = 5000;\n\nfunction defaultStyle(theme: Theme, key: string): TimeRangeStyle {\n const { palette, typography, timeline } = theme;\n const height = timeline.barHeight ?? BAR_HEIGHT;\n const text = (color: string) => ({ ...typography.label, color });\n const hash = [...key].reduce((sum, char) => sum + char.charCodeAt(0), 0);\n\n switch (key) {\n case \"active\":\n return {\n fill: palette.categorical[0] ?? palette.neutral,\n height,\n text: text(palette.background),\n };\n case \"confirmed\":\n return { fill: palette.grid, height, text: text(palette.text) };\n case \"tentative\":\n return {\n stroke: { color: palette.neutral, width: 1, style: \"dashed\" },\n height,\n text: text(palette.text),\n };\n case \"arrival\":\n return {\n hatch: { color: palette.neutral, spacing: 6, width: 1, opacity: 0.55 },\n height,\n };\n }\n\n const fill =\n palette.categorical[hash % palette.categorical.length] ?? palette.neutral;\n\n return { fill, height, text: text(palette.background) };\n}\n\nexport function timeRangeStyler(\n theme: Theme | null,\n overrides: Record<string, TimeRangeStyle> = {},\n): (key: string) => TimeRangeStyle {\n return (key) =>\n deepMerge<TimeRangeStyle>(\n theme && defaultStyle(theme, key),\n theme?.timeline.styles?.[key],\n overrides[key],\n );\n}\n\nexport function timelineRanges(\n items: ReadonlyArray<TimelineItem>,\n): TimeRangeItem[] {\n return items.flatMap(({ start, end, eta, state, label, color }) => {\n const bar = { from: start, to: end, key: state, label, color };\n const etaTime = eta === undefined ? null : toUnixSeconds(eta);\n const startTime = toUnixSeconds(start);\n\n return etaTime !== null && startTime !== null && etaTime < startTime\n ? [{ from: eta!, to: start, key: \"arrival\" }, bar]\n : [bar];\n });\n}\n\nexport function unixTimes(times: ReadonlyArray<Time>): number[] {\n const seconds = times\n .map(toUnixSeconds)\n .filter((time): time is number => time !== null);\n\n return [...new Set(seconds)].sort((a, b) => a - b);\n}\n\nexport function timeGrid(times: ReadonlyArray<Time>, step = 3600): number[] {\n const known = unixTimes(times);\n const first = known[0];\n const last = known[known.length - 1];\n\n if (first === undefined || last === undefined || !(step > 0)) return [];\n\n const size = Math.max(step, Math.ceil((last - first) / MAX_GRID));\n const from = Math.floor(first / size) * size;\n const to = Math.ceil(last / size) * size;\n\n return Array.from(\n { length: Math.max(1, (to - from) / size + 1) },\n (_, index) => from + index * size,\n );\n}\n","import { useEffect, useRef } from \"react\";\nimport { sameInputs } from \"../utils/merge.utils.js\";\nimport type { Theme } from \"../types/theme.js\";\nimport type { ChartInstance } from \"../types/chart.js\";\nimport { TimeRangePrimitive } from \"../primitives/TimeRangePrimitive.js\";\nimport type { RangeEntry, TimelinePaneProps } from \"../types/timeline.js\";\nimport { timelineRanges, timeRangeStyler } from \"../utils/timeline.utils.js\";\n\nexport function usePaneRanges(\n instance: ChartInstance<\"Histogram\"> | null,\n lanes: ReadonlyArray<TimelinePaneProps | null>,\n theme: Theme | null,\n) {\n const entries = useRef<Array<RangeEntry | undefined>>([]);\n\n useEffect(() => {\n entries.current = [];\n }, [instance]);\n\n useEffect(() => {\n if (!instance) return;\n\n const list = entries.current;\n const panes = instance.chart.panes();\n const detach = (entry: RangeEntry | undefined) =>\n entry?.pane.detachPrimitive(entry.primitive);\n\n lanes.forEach((lane, index) => {\n const pane = panes[index];\n let entry = list[index];\n\n if (entry && (!lane || entry.pane !== pane)) {\n detach(entry);\n entry = list[index] = undefined;\n }\n\n if (!lane || !pane) return;\n\n const inputs = [lane.items, lane.styles, theme];\n\n if (entry && sameInputs(entry.inputs, inputs)) return;\n\n const options = {\n items: timelineRanges(lane.items),\n style: timeRangeStyler(theme, lane.styles),\n };\n\n if (entry) {\n entry.primitive.applyOptions(options);\n entry.inputs = inputs;\n return;\n }\n\n const primitive = new TimeRangePrimitive(options);\n\n pane.attachPrimitive(primitive);\n list[index] = { pane, primitive, inputs };\n });\n\n list.splice(lanes.length).forEach(detach);\n });\n}\n","import {\n HistogramSeries,\n type LineData,\n type IPriceLine,\n type ISeriesApi,\n type UTCTimestamp,\n type HistogramSeriesPartialOptions,\n} from \"lightweight-charts\";\n\nimport {\n colorBars,\n histogramOptions,\n histogramPriceLines,\n} from \"../utils/histogram.utils.js\";\n\nimport {\n deepMerge,\n pickPaths,\n sameInputs,\n removesUndefinedDefault,\n} from \"../utils/merge.utils.js\";\n\nimport { normalizePoints } from \"../utils/data.utils.js\";\nimport type { NormalizedSeries } from \"../types/series.js\";\n\nimport {\n themedLine,\n referenceLine,\n histogramColorsFromTheme,\n} from \"../utils/theme.utils.js\";\n\nimport type { Theme } from \"../types/theme.js\";\nimport type { LinePoint } from \"../types/chart.js\";\nimport type { ChartInstance } from \"../types/chart.js\";\nimport { unixTimes } from \"../utils/timeline.utils.js\";\nimport { useEffect, useRef, type RefObject } from \"react\";\nimport type { PaneSeriesInput, HistogramPaneProps } from \"../types/panes.js\";\n\nexport interface PaneEntry {\n series: ISeriesApi<\"Histogram\">;\n defaults: HistogramSeriesPartialOptions;\n options: HistogramSeriesPartialOptions;\n optionInputs: unknown[];\n dataInputs: unknown[];\n lineInputs: unknown[];\n lines: IPriceLine[];\n normalized: NormalizedSeries<LinePoint, LineData>;\n}\n\nexport function usePaneSeries(\n instance: ChartInstance<\"Histogram\"> | null,\n panes: ReadonlyArray<PaneSeriesInput>,\n theme: Theme | null,\n): RefObject<PaneEntry[]> {\n const entries = useRef<PaneEntry[]>([]);\n\n useEffect(() => {\n entries.current = [];\n }, [instance]);\n\n useEffect(() => {\n if (!instance) return;\n\n const { chart } = instance;\n const list = entries.current;\n\n const create = (\n index: number,\n options: HistogramSeriesPartialOptions,\n optionInputs: unknown[],\n ): PaneEntry => {\n const series =\n index === 0\n ? instance.series\n : chart.addSeries(HistogramSeries, {}, index);\n const defaults = deepMerge<HistogramSeriesPartialOptions>(\n series.options(),\n );\n\n if (index > 0) {\n series.applyOptions(options);\n chart.panes()[index]?.setPreserveEmptyPane(true);\n }\n\n return {\n series,\n defaults,\n options,\n optionInputs,\n dataInputs: [],\n lineInputs: [],\n lines: [],\n normalized: normalizePoints([]),\n };\n };\n\n panes.forEach((pane, index) => {\n const mode = pane.mode ?? \"plain\";\n const optionInputs = [mode, pane.seriesOptions];\n const options = histogramOptions(mode, pane.seriesOptions);\n let entry = list[index];\n\n if (entry && index > 0 && !sameInputs(entry.optionInputs, optionInputs)) {\n if (removesUndefinedDefault(entry.defaults, entry.options, options)) {\n chart.removeSeries(entry.series);\n entry = undefined;\n } else {\n entry.series.applyOptions(\n deepMerge(pickPaths(entry.defaults, entry.options), options),\n );\n entry.options = options;\n entry.optionInputs = optionInputs;\n }\n }\n\n if (!entry) list[index] = entry = create(index, options, optionInputs);\n\n const { bar, over, positive, negative } = deepMerge<\n NonNullable<HistogramPaneProps[\"colors\"]>\n >(histogramColorsFromTheme(theme), pane.colors);\n const dataInputs = [\n pane.data,\n pane.whitespace,\n mode,\n pane.threshold,\n bar,\n over,\n positive,\n negative,\n ];\n\n if (!sameInputs(entry.dataInputs, dataInputs)) {\n entry.normalized = normalizePoints(pane.data);\n entry.series.setData(\n pane.whitespace\n ? unixTimes(pane.whitespace).map((time) => ({\n time: time as UTCTimestamp,\n }))\n : colorBars(entry.normalized.data, mode, pane.threshold, {\n bar,\n over,\n positive,\n negative,\n }),\n );\n entry.dataInputs = dataInputs;\n }\n\n const lineInputs = [\n mode,\n pane.threshold,\n pane.thresholdLine,\n pane.zeroLine,\n theme,\n ];\n\n if (!sameInputs(entry.lineInputs, lineInputs)) {\n const { series } = entry;\n\n entry.lines.forEach((line) => series.removePriceLine(line));\n entry.lines = histogramPriceLines(\n mode,\n pane.threshold,\n themedLine(\n referenceLine(theme, theme?.histogram.threshold, \"dashed\"),\n pane.thresholdLine,\n ),\n themedLine(\n referenceLine(theme, theme?.histogram.zero, \"solid\"),\n pane.zeroLine,\n ),\n ).map((line) => series.createPriceLine(line));\n entry.lineInputs = lineInputs;\n }\n\n chart.panes()[index]?.setStretchFactor(pane.height);\n });\n\n list.splice(panes.length).forEach((entry) => {\n if (entry.series !== instance.series) {\n chart.removeSeries(entry.series);\n return;\n }\n\n entry.lines.forEach((line) => entry.series.removePriceLine(line));\n entry.series.setData([]);\n });\n\n for (let i = chart.panes().length - 1; i >= Math.max(panes.length, 1); i--)\n chart.removePane(i);\n });\n\n return entries;\n}\n","import {\n useRef,\n useMemo,\n useState,\n Children,\n useEffect,\n forwardRef,\n isValidElement,\n type CSSProperties,\n useImperativeHandle,\n} from \"react\";\n\nimport {\n HistogramSeries,\n type DeepPartial,\n type ChartOptions,\n type MouseEventParams,\n} from \"lightweight-charts\";\n\nimport type {\n ChartPanesProps,\n ChartPanesHandle,\n PaneSeriesInput,\n HistogramPaneProps,\n} from \"../../types/panes.js\";\n\nimport {\n textStyle,\n defaultTheme,\n chartOptionsFromTheme,\n} from \"../../utils/theme.utils.js\";\n\nimport { useChart } from \"../../hooks/useChart.js\";\nimport type { ThemeLine } from \"../../types/theme.js\";\nimport type { LinePoint } from \"../../types/chart.js\";\nimport { useNowLine } from \"../../hooks/useNowLine.js\";\nimport { deepMerge } from \"../../utils/merge.utils.js\";\nimport { TimelinePane } from \"../TimelinePane/index.js\";\nimport { HistogramPane } from \"../HistogramPane/index.js\";\nimport { toUnixSeconds } from \"../../utils/time.utils.js\";\nimport { useWheelZoom } from \"../../hooks/useWheelZoom.js\";\nimport { useChartTheme } from \"../../hooks/useChartTheme.js\";\nimport { usePaneRanges } from \"../../hooks/usePaneRanges.js\";\nimport { usePaneSeries } from \"../../hooks/usePaneSeries.js\";\nimport type { TimelinePaneProps } from \"../../types/timeline.js\";\nimport { histogramOptions } from \"../../utils/histogram.utils.js\";\n\nconst ROOT: CSSProperties = { display: \"flex\" };\nconst LABELS: CSSProperties = { flex: \"none\" };\nconst LABEL: CSSProperties = { boxSizing: \"border-box\", overflow: \"hidden\" };\nconst PLOT: CSSProperties = { position: \"relative\", flex: 1, minWidth: 0 };\nconst FILL: CSSProperties = { position: \"absolute\", inset: 0 };\nconst NOW: CSSProperties = {\n position: \"absolute\",\n top: 0,\n left: 0,\n width: 1,\n display: \"none\",\n pointerEvents: \"none\",\n};\nconst DEFAULTS: DeepPartial<ChartOptions> = {\n layout: { panes: { enableResize: false } },\n};\n\nconst NO_POINTS: LinePoint[] = [];\n\nconst formatValue = (point: LinePoint) => point.value.toLocaleString();\n\nexport const ChartPanes = forwardRef<ChartPanesHandle | null, ChartPanesProps>(\n function ChartPanes(\n {\n children,\n now = null,\n axisLabel,\n chartOptions,\n ctrlWheelZoom = true,\n ariaLabel = \"Chart panes\",\n className,\n classNames = {},\n styles = {},\n onPaneClick,\n onPaneHover,\n onPaneLeave,\n theme,\n unstyled,\n },\n ref,\n ) {\n const container = useRef<HTMLDivElement>(null);\n const nowLine = useRef<HTMLDivElement>(null);\n const handlers = useRef({ onPaneClick, onPaneHover, onPaneLeave });\n const [axisHeight, setAxisHeight] = useState(0);\n const [hovered, setHovered] = useState<Array<LinePoint | null> | null>(\n null,\n );\n handlers.current = { onPaneClick, onPaneHover, onPaneLeave };\n\n const resolved = useChartTheme({ theme, unstyled });\n const paneHeight =\n resolved?.sizes.paneHeight ?? defaultTheme.sizes.paneHeight;\n const laneHeight = resolved?.sizes.laneHeight ?? paneHeight;\n const lanes: Array<TimelinePaneProps | null> = [];\n const panes: PaneSeriesInput[] = [];\n\n Children.forEach(children, (child) => {\n if (\n isValidElement<HistogramPaneProps>(child) &&\n child.type === HistogramPane\n ) {\n lanes.push(null);\n panes.push({\n ...child.props,\n height: child.props.height ?? paneHeight,\n });\n }\n if (\n isValidElement<TimelinePaneProps>(child) &&\n child.type === TimelinePane\n ) {\n const { label, meta, height = laneHeight, times } = child.props;\n\n lanes.push(child.props);\n panes.push({ label, meta, height, data: NO_POINTS, whitespace: times });\n }\n });\n\n const first = panes[0];\n const firstOptions = useMemo(\n () => histogramOptions(first?.mode ?? \"plain\", first?.seriesOptions),\n [first?.mode, first?.seriesOptions],\n );\n const options = useMemo(\n () =>\n deepMerge<DeepPartial<ChartOptions>>(\n chartOptionsFromTheme(resolved),\n DEFAULTS,\n ctrlWheelZoom && {\n handleScale: { mouseWheel: false },\n handleScroll: { mouseWheel: false },\n },\n chartOptions,\n ),\n [resolved, ctrlWheelZoom, chartOptions],\n );\n\n const instance = useChart(\n container,\n HistogramSeries,\n options,\n firstOptions,\n );\n const entries = usePaneSeries(instance, panes, resolved);\n usePaneRanges(instance, lanes, resolved);\n useWheelZoom(instance, container, ctrlWheelZoom);\n\n useEffect(() => {\n if (!instance) return;\n\n const timeScale = instance.chart.timeScale();\n const update = () => setAxisHeight(timeScale.height());\n\n update();\n timeScale.subscribeSizeChange(update);\n\n return () => timeScale.unsubscribeSizeChange(update);\n }, [instance]);\n\n useEffect(() => {\n if (!instance) return;\n\n const { chart } = instance;\n let active = false;\n\n const pointsAt = (time: number) =>\n entries.current.map(({ normalized }) => {\n const index = normalized.indexByTime.get(time);\n\n return index === undefined\n ? null\n : (normalized.points[index] ?? null);\n });\n\n const onMove = (param: MouseEventParams) => {\n if (param.time === undefined || !param.point) {\n if (!active) return;\n\n active = false;\n setHovered(null);\n handlers.current.onPaneLeave?.();\n return;\n }\n\n const time = Number(param.time);\n const points = pointsAt(time);\n\n active = true;\n setHovered(points);\n handlers.current.onPaneHover?.({ time, points });\n };\n\n const onClick = (param: MouseEventParams) => {\n if (param.time === undefined) return;\n\n const time = Number(param.time);\n\n handlers.current.onPaneClick?.({ time, points: pointsAt(time) });\n };\n\n chart.subscribeCrosshairMove(onMove);\n chart.subscribeClick(onClick);\n\n return () => {\n chart.unsubscribeCrosshairMove(onMove);\n chart.unsubscribeClick(onClick);\n };\n }, [instance, entries]);\n\n useNowLine(instance, nowLine, now === null ? null : toUnixSeconds(now));\n\n useImperativeHandle<ChartPanesHandle | null, ChartPanesHandle | null>(\n ref,\n () =>\n instance\n ? {\n chart: instance.chart,\n get series() {\n return entries.current.map((entry) => entry.series);\n },\n }\n : null,\n [instance, entries],\n );\n\n const heights = panes.map((pane) => pane.height);\n const nowLineTheme =\n resolved &&\n deepMerge<ThemeLine>({ color: resolved.palette.now }, resolved.panes.now);\n const nowStyle: CSSProperties = nowLineTheme\n ? {\n width: 0,\n borderLeft: `${nowLineTheme.width ?? 1}px ${nowLineTheme.style ?? \"solid\"} ${nowLineTheme.color}`,\n }\n : {};\n const labelsStyle: CSSProperties = { width: resolved?.sizes.paneLabel };\n const labelStyle: CSSProperties = { padding: resolved?.spacing.paneLabel };\n const titleStyle = textStyle(\n resolved\n ? deepMerge(resolved.typography.title, resolved.panes.title)\n : undefined,\n );\n const metaStyle = textStyle(\n resolved\n ? deepMerge(resolved.typography.value, resolved.panes.meta)\n : undefined,\n );\n const total =\n heights.reduce((sum, height) => sum + height, 0) +\n Math.max(0, panes.length - 1) +\n axisHeight;\n\n return (\n <div className={className} style={ROOT}>\n <div\n data-part=\"labels\"\n className={classNames.labels}\n style={{ ...LABELS, ...labelsStyle, ...styles.labels }}\n >\n {panes.map((pane, index) => {\n const point = hovered?.[index];\n\n return (\n <div\n key={index}\n data-part=\"label\"\n className={classNames.label}\n style={{\n ...LABEL,\n ...labelStyle,\n height: heights[index]! + (index > 0 ? 1 : 0),\n ...styles.label,\n }}\n >\n <div\n data-part=\"title\"\n className={classNames.title}\n style={{ ...titleStyle, ...styles.title }}\n >\n {pane.label}\n </div>\n <div\n data-part=\"meta\"\n className={classNames.meta}\n style={{ ...metaStyle, ...styles.meta }}\n >\n {point ? (pane.format ?? formatValue)(point) : pane.meta}\n </div>\n </div>\n );\n })}\n <div\n data-part=\"axis\"\n className={classNames.axis}\n style={{ ...LABEL, height: axisHeight, ...styles.axis }}\n >\n {axisLabel}\n </div>\n </div>\n <div\n data-part=\"plot\"\n className={classNames.plot}\n style={{ ...PLOT, height: total, ...styles.plot }}\n >\n <div ref={container} style={FILL} role=\"img\" aria-label={ariaLabel} />\n <div\n ref={nowLine}\n data-part=\"now\"\n className={classNames.now}\n style={{ ...NOW, ...nowStyle, bottom: axisHeight, ...styles.now }}\n aria-hidden=\"true\"\n />\n </div>\n </div>\n );\n },\n);\n","import { forwardRef, useMemo } from \"react\";\nimport { ChartPanes } from \"../ChartPanes/index.js\";\nimport { TimelinePane } from \"../TimelinePane/index.js\";\nimport { timeGrid } from \"../../utils/timeline.utils.js\";\nimport type { ChartPanesHandle } from \"../../types/panes.js\";\nimport type { TimelineChartProps } from \"../../types/timeline.js\";\n\nexport const TimelineChart = forwardRef<\n ChartPanesHandle | null,\n TimelineChartProps\n>(function TimelineChart({ lanes, step, ...props }, ref) {\n const times = useMemo(\n () =>\n timeGrid(\n lanes.flatMap((lane) =>\n lane.items.flatMap(({ start, end, eta }) =>\n eta === undefined ? [start, end] : [eta, start, end],\n ),\n ),\n step,\n ),\n [lanes, step],\n );\n\n return (\n <ChartPanes ref={ref} {...props}>\n {lanes.map(({ id, ...lane }, index) => (\n <TimelinePane\n key={id}\n {...lane}\n times={index === 0 ? times : undefined}\n />\n ))}\n </ChartPanes>\n );\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAGA,SAAS2F,GAAM,GAA8B,GAAc;CACzD,IAAMC,IAAQxE,EAAIyE,CAAK,GACjB,CAACC,GAAUC,KAAW1E,EAAOwE,CAAK,GAClCG,IAAQC,IAAOA,GACfC,IAASN,IAAQA;CAEvB,OAAO,KAAK,IAAKI,IAAQD,IAAWG,GAAQA,KAAUF,IAAQF,EAAS;AACzE;AAEA,SAASK,GACP,GACA,GACA,GACA,GACY;CACZ,IAAMP,IAAQxE,EAAIgF,EAAI,KAAK,MAAUP,EAAMQ,EAAO,CAAC,GAC7CC,IAAWC,EAAK,SAASA,EAAK,QAC9BC,IAAYZ,KAASU,IAAWC,EAAK,SAASA,EAAK,QACrDE,IAAS;CAEb,KAAK,IAAMJ,KAASD,GAAK;EACvB,IAAMM,IAASb,EAAMQ,KAAUG;EAI/B,AAHA,EAAIH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AG3B,SAAuB,EAAE,UAAO,SAAM,GAAGyC,KAAS,GAAK;CACvD,IAAMzF,IAAQgE,QAEV9D,GACEgB,EAAM,SAAS,MACbE,EAAK,MAAM,SAAS,EAAE,UAAO,QAAK,aAChCxB,MAAQ,KAAA,IAAY,CAACJ,GAAOC,CAAG,IAAI;EAACG;EAAKJ;EAAOC;CAAG,CACrD,CACF,GACAa,CACF,GACF,CAACY,GAAOZ,CAAI,CACd;CAEA,OACE,kBAACyC,IAAD;EAAiB;EAAK,GAAI0C;EACvB,UAAAvE,EAAM,KAAK,EAAE,OAAI,GAAGE,KAAQ,MAC3B,kBAAC/C,GAAD;GAEE,GAAI+C;GACJ,OAAO3E,MAAU,IAAIuD,IAAQ,KAAA;EAC9B,GAHM0F,CAGN,CACF;CACS,CAAA;AAEhB,CAAC"}
@@ -0,0 +1,55 @@
1
+ "use client";
2
+ function e() {
3
+ return typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
4
+ }
5
+ var t = (e) => e, n = (e) => 1 - (1 - e) ** 3, r = (e) => e < .5 ? 4 * e * e * e : 1 - (-2 * e + 2) ** 3 / 2;
6
+ function i(e = !0) {
7
+ let t = typeof e == "object" ? e : {};
8
+ return {
9
+ duration: e === !1 ? 0 : Math.max(0, t.duration ?? 240),
10
+ easing: t.easing ?? r,
11
+ stagger: Math.max(0, t.stagger ?? 0),
12
+ appear: t.appear ?? !1
13
+ };
14
+ }
15
+ function a(e, t) {
16
+ let n = Object.keys(t);
17
+ return Object.keys(e).length === n.length && n.every((n) => {
18
+ let r = e[n], i = t[n];
19
+ return r !== void 0 && r.length === i.length && i.every((e, t) => r[t] === e);
20
+ });
21
+ }
22
+ function o(e, t, n, r = (e, t) => t) {
23
+ let i = {};
24
+ return Object.keys(t).forEach((a, o) => {
25
+ let s = t[a], c = e[a], l = c && c.length === s.length ? c : r(a, s), u = typeof n == "number" ? n : n(a, o);
26
+ i[a] = s.map((e, t) => {
27
+ let n = l[t] ?? e;
28
+ return n + (e - n) * u;
29
+ });
30
+ }), i;
31
+ }
32
+ function s(e, t, n) {
33
+ if (n.duration <= 0) return 1;
34
+ let r = (e - t * n.stagger) / n.duration;
35
+ return n.easing(Math.max(0, Math.min(1, r)));
36
+ }
37
+ function c(e, t) {
38
+ return t.duration + t.stagger * Math.max(0, e - 1);
39
+ }
40
+ function l(e, n = 16) {
41
+ return e === t ? "linear" : `linear(${Array.from({ length: n + 1 }, (t, r) => {
42
+ let i = e(r / n);
43
+ return Number.isFinite(i) ? Number(i.toFixed(4)) : r / n;
44
+ }).join(", ")})`;
45
+ }
46
+ function u(t, n) {
47
+ let { duration: r, easing: a } = i(t);
48
+ if (r <= 0 || e()) return;
49
+ let o = l(a);
50
+ return n.map((e) => `${e} ${r}ms ${o}`).join(", ");
51
+ }
52
+ //#endregion
53
+ export { i as a, s as c, t as i, c as l, r as n, e as o, n as r, a as s, u as t, o as u };
54
+
55
+ //# sourceMappingURL=motion.utils-DFoqptDi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"motion.utils-DFoqptDi.js","names":["prefersReducedMotion","linear","t","easeOutCubic","easeInOutCubic","motionSettings","options","animate","sameFrames","keys","b","a","left","key","right","index","value","tweenFrames","out","to","target","start","from","origin","enter","progress","begin","slot","staggeredProgress","settings","local","elapsed","totalDuration","count","cssEasing","easing","samples","cssTransition","duration","timing","properties","property"],"sources":["../src/utils/motion.utils.ts"],"sourcesContent":["import type {\n ChartAnimate,\n Easing,\n MotionFrames,\n MotionSettings,\n} from \"../types/motion.js\";\n\nexport const DURATION = 240;\n\nexport function prefersReducedMotion(): boolean {\n return (\n typeof window !== \"undefined\" &&\n typeof window.matchMedia === \"function\" &&\n window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches\n );\n}\n\nexport const linear: Easing = (t) => t;\nexport const easeOutCubic: Easing = (t) => 1 - (1 - t) ** 3;\nexport const easeInOutCubic: Easing = (t) =>\n t < 0.5 ? 4 * t * t * t : 1 - (-2 * t + 2) ** 3 / 2;\n\n/** `animate` as concrete settings. `false` gives a zero duration. */\nexport function motionSettings(animate: ChartAnimate = true): MotionSettings {\n const options = typeof animate === \"object\" ? animate : {};\n\n return {\n duration: animate === false ? 0 : Math.max(0, options.duration ?? DURATION),\n easing: options.easing ?? easeInOutCubic,\n stagger: Math.max(0, options.stagger ?? 0),\n appear: options.appear ?? false,\n };\n}\n\nexport function sameFrames(a: MotionFrames, b: MotionFrames): boolean {\n const keys = Object.keys(b);\n\n if (Object.keys(a).length !== keys.length) return false;\n\n return keys.every((key) => {\n const left = a[key];\n const right = b[key]!;\n\n return (\n left !== undefined &&\n left.length === right.length &&\n right.every((value, index) => left[index] === value)\n );\n });\n}\n\n/**\n * Blend two keyed frames at progress `t` (0–1, already eased). Keys only in\n * `to` start from `enter(key, to[key])`. Keys only in `from` are dropped.\n */\nexport function tweenFrames(\n from: MotionFrames,\n to: MotionFrames,\n t: number | ((key: string, index: number) => number),\n enter: (key: string, value: readonly number[]) => readonly number[] = (_key, value) => value,\n): Record<string, number[]> {\n const out: Record<string, number[]> = {};\n\n Object.keys(to).forEach((key, index) => {\n const target = to[key]!;\n const start = from[key];\n const origin = start && start.length === target.length ? start : enter(key, target);\n const progress = typeof t === \"number\" ? t : t(key, index);\n\n out[key] = target.map((value, slot) => {\n const begin = origin[slot] ?? value;\n\n return begin + (value - begin) * progress;\n });\n });\n\n return out;\n}\n\n/** Eased progress of the key at `index`, `elapsed` ms after the start. */\nexport function staggeredProgress(\n elapsed: number,\n index: number,\n settings: Pick<MotionSettings, \"duration\" | \"stagger\" | \"easing\">,\n): number {\n if (settings.duration <= 0) return 1;\n\n const local = (elapsed - index * settings.stagger) / settings.duration;\n\n return settings.easing(Math.max(0, Math.min(1, local)));\n}\n\n/** How long a tween over `count` keys takes, stagger included. */\nexport function totalDuration(\n count: number,\n settings: Pick<MotionSettings, \"duration\" | \"stagger\">,\n): number {\n return settings.duration + settings.stagger * Math.max(0, count - 1);\n}\n\n/** A JS easing as a CSS `linear()` timing function, sampled at `samples + 1` points. */\nexport function cssEasing(easing: Easing, samples = 16): string {\n if (easing === linear) return \"linear\";\n\n const points = Array.from({ length: samples + 1 }, (_, index) => {\n const value = easing(index / samples);\n\n return Number.isFinite(value) ? Number(value.toFixed(4)) : index / samples;\n });\n\n return `linear(${points.join(\", \")})`;\n}\n\n/**\n * A CSS `transition` for marks that only change colour or opacity, or\n * undefined when motion is off or reduced. The easing is sampled into\n * `linear()`, so a custom curve matches the tweened charts.\n */\nexport function cssTransition(\n animate: ChartAnimate | undefined,\n properties: readonly string[],\n): string | undefined {\n const { duration, easing } = motionSettings(animate);\n\n if (duration <= 0 || prefersReducedMotion()) return undefined;\n\n const timing = cssEasing(easing);\n\n return properties.map((property) => `${property} ${duration}ms ${timing}`).join(\", \");\n}\n"],"mappings":";AASA,SAAgBA,IAAgC;CAC9C,OACE,OAAO,SAAW,OAClB,OAAO,OAAO,cAAe,cAC7B,OAAO,WAAW,kCAAkC,CAAC,CAAC;AAE1D;AAEA,IAAaC,KAAkB,MAAMC,GACxBC,KAAwB,MAAM,KAAK,IAAID,MAAM,GAC7CE,KAA0B,MACrCF,IAAI,KAAM,IAAIA,IAAIA,IAAIA,IAAI,KAAK,KAAKA,IAAI,MAAM,IAAI;AAGpD,SAAgBG,EAAe,IAAwB,IAAsB;CAC3E,IAAMC,IAAU,OAAOC,KAAY,WAAWA,IAAU,CAAC;CAEzD,OAAO;EACL,UAAUA,MAAY,KAAQ,IAAI,KAAK,IAAI,GAAGD,EAAQ,YAAA,GAAoB;EAC1E,QAAQA,EAAQ,UAAUF;EAC1B,SAAS,KAAK,IAAI,GAAGE,EAAQ,WAAW,CAAC;EACzC,QAAQA,EAAQ,UAAU;CAC5B;AACF;AAEA,SAAgBE,EAAW,GAAiB,GAA0B;CACpE,IAAMC,IAAO,OAAO,KAAKC,CAAC;CAI1B,OAFI,OAAO,KAAKC,CAAC,CAAC,CAAC,WAAWF,EAAK,UAE5BA,EAAK,OAA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C,IAAID,IAAQqB;CACrE,CAEiB,CAAA,CAAO,KAAK,IAAI,EAAE;AACrC;AAOA,SAAgBC,EACd,GACA,GACoB;CACpB,IAAM,EAAE,aAAU,cAAWhC,EAAeE,CAAO;CAEnD,IAAI+B,KAAY,KAAKtC,EAAqB,GAAG;CAE7C,IAAMuC,IAASL,EAAUC,CAAM;CAE/B,OAAOK,EAAW,KAAK,MAAa,GAAGC,EAAS,GAAGH,EAAS,KAAKC,GAAQ,CAAC,CAAC,KAAK,IAAI;AACtF"}
package/dist/pie.js CHANGED
@@ -1,3 +1,3 @@
1
1
  "use client";
2
- import { a as e, i as t, n, o as r, r as i, t as a } from "./PieLegend-BZsv9IbF.js";
2
+ import { a as e, i as t, n, o as r, r as i, t as a } from "./PieLegend-16E6W10x.js";
3
3
  export { n as PieChart, a as PieLegend, t as arcPath, e as pieSlices, r as placeLabels, i as usePieState };
package/dist/scatter.d.ts CHANGED
@@ -1,7 +1,10 @@
1
1
  export { ScatterChart } from "./charts/ScatterChart/index.js";
2
2
  export { PolarChart } from "./charts/PolarChart/index.js";
3
3
  export { scatterLayout } from "./utils/scatter.utils.js";
4
+ export type { ScatterDomain } from "./utils/scatter.utils.js";
4
5
  export { sectorPath } from "./utils/polar.utils.js";
5
- export type { ScatterChartProps, ScatterSeries } from "./types/scatter.js";
6
+ export type { ScatterChartProps, ScatterReference, ScatterSeries } from "./types/scatter.js";
7
+ export { ChartLegend } from "./components/ChartLegend/index.js";
8
+ export type { ChartLegendItem } from "./components/ChartLegend/index.js";
6
9
  export type { PolarChartProps } from "./types/polar.js";
7
10
  //# sourceMappingURL=scatter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"scatter.d.ts","sourceRoot":"","sources":["../src/scatter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,YAAY,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC3E,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"scatter.d.ts","sourceRoot":"","sources":["../src/scatter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC7F,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAChE,YAAY,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACzE,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC"}
package/dist/scatter.js CHANGED
@@ -1,3 +1,4 @@
1
1
  "use client";
2
- import { i as e, n as t, r as n, t as r } from "./PolarChart-BUEhn3CI.js";
3
- export { r as PolarChart, n as ScatterChart, e as scatterLayout, t as sectorPath };
2
+ import { t as e } from "./ChartLegend-B8ZmIG2y.js";
3
+ import { i as t, n, r, t as i } from "./PolarChart-C_vPz-3K.js";
4
+ export { e as ChartLegend, i as PolarChart, r as ScatterChart, t as scatterLayout, n as sectorPath };
package/dist/series.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use client";
2
- import { a as e, g as t, i as n, l as r, n as i, o as a, r as o, t as s, u as c } from "./TimeSeriesChart-BIwJxgnD.js";
2
+ import { a as e, g as t, i as n, l as r, n as i, o as a, r as o, t as s, u as c } from "./TimeSeriesChart-BZMLERDZ.js";
3
3
  import { t as l } from "./bin.utils-Ch1y7YDn.js";
4
4
  export { c as BarChart, e as CandlestickChart, a as HistogramChart, r as LineChart, n as RibbonPrimitive, t as SeriesChart, s as TimeSeriesChart, l as bin, i as editorialChartOptions, o as patchSquareCanvasLabels };
@@ -13,12 +13,8 @@ var e = {
13
13
  overflow: "hidden",
14
14
  clipPath: "inset(50%)",
15
15
  whiteSpace: "nowrap"
16
- }, n = 8;
17
- function r([e, t], r, [i, a], [o, s]) {
18
- let c = (e, t, i) => e + r + t > i - n ? Math.max(n, e - r - t) : e + r;
19
- return [Math.round(c(e, i, o)), Math.round(c(t, a, s))];
20
- }
16
+ };
21
17
  //#endregion
22
- export { t as n, e as r, r as t };
18
+ export { e as n, t };
23
19
 
24
- //# sourceMappingURL=tooltip.utils-D7xaBSUK.js.map
20
+ //# sourceMappingURL=shared-C1pGJV4T.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared-C1pGJV4T.js","names":["TOOLTIP","SR_ONLY"],"sources":["../src/styles/shared.ts"],"sourcesContent":["import type { CSSProperties } from \"react\";\n\nexport const TOOLTIP: CSSProperties = {\n position: \"absolute\",\n left: 0,\n top: 0,\n zIndex: 1,\n pointerEvents: \"none\",\n};\nexport const SR_ONLY: CSSProperties = {\n position: \"absolute\",\n width: 1,\n height: 1,\n overflow: \"hidden\",\n clipPath: \"inset(50%)\",\n whiteSpace: \"nowrap\",\n};\n"],"mappings":";;AAEA,IAAaA,IAAyB;CACpC,UAAU;CACV,MAAM;CACN,KAAK;CACL,QAAQ;CACR,eAAe;AACjB,GACaC,IAAyB;CACpC,UAAU;CACV,OAAO;CACP,QAAQ;CACR,UAAU;CACV,UAAU;CACV,YAAY;AACd"}
@@ -1,5 +1,5 @@
1
1
  export { Sparkline } from "./charts/Sparkline/index.js";
2
- export { sparklinePaths } from "./utils/sparkline.utils.js";
2
+ export { sparklinePaths, sparklineShapes, shiftOffset } from "./utils/sparkline.utils.js";
3
3
  export type { SparklineProps } from "./types/sparkline.js";
4
4
  export type { SparklineDatum } from "./utils/sparkline.utils.js";
5
5
  //# sourceMappingURL=sparkline.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sparkline.d.ts","sourceRoot":"","sources":["../src/sparkline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,YAAY,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC"}
1
+ {"version":3,"file":"sparkline.d.ts","sourceRoot":"","sources":["../src/sparkline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE1F,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,YAAY,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC"}
package/dist/sparkline.js CHANGED
@@ -1,3 +1,3 @@
1
1
  "use client";
2
- import { n as e, t } from "./Sparkline-DtNhxGVo.js";
3
- export { t as Sparkline, e as sparklinePaths };
2
+ import { i as e, n as t, r as n, t as r } from "./Sparkline-BApLVWfg.js";
3
+ export { r as Sparkline, t as shiftOffset, n as sparklinePaths, e as sparklineShapes };