blazeplot 0.2.1 → 0.3.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 (76) hide show
  1. package/README.md +11 -2
  2. package/dist/Chart-BW9JaHs6.js +2903 -0
  3. package/dist/Chart-BW9JaHs6.js.map +1 -0
  4. package/dist/OverlayUtils-Cw1o8UH-.js +35 -0
  5. package/dist/OverlayUtils-Cw1o8UH-.js.map +1 -0
  6. package/dist/core/SeriesStore.d.ts +9 -0
  7. package/dist/core/SeriesStore.d.ts.map +1 -1
  8. package/dist/core/UniformRingBuffer.d.ts +67 -0
  9. package/dist/core/UniformRingBuffer.d.ts.map +1 -0
  10. package/dist/core/index.d.ts +3 -1
  11. package/dist/core/index.d.ts.map +1 -1
  12. package/dist/core/types.d.ts +13 -1
  13. package/dist/core/types.d.ts.map +1 -1
  14. package/dist/index.d.ts +5 -2
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +153 -2185
  17. package/dist/index.js.map +1 -1
  18. package/dist/interaction/AxisController.d.ts +45 -3
  19. package/dist/interaction/AxisController.d.ts.map +1 -1
  20. package/dist/interaction/index.d.ts +1 -0
  21. package/dist/interaction/index.d.ts.map +1 -1
  22. package/dist/linked.d.ts +3 -0
  23. package/dist/linked.d.ts.map +1 -0
  24. package/dist/linked.js +64 -0
  25. package/dist/linked.js.map +1 -0
  26. package/dist/plugins/annotations.d.ts +3 -0
  27. package/dist/plugins/annotations.d.ts.map +1 -0
  28. package/dist/plugins/annotations.js +163 -0
  29. package/dist/plugins/annotations.js.map +1 -0
  30. package/dist/plugins/crosshair.d.ts +3 -0
  31. package/dist/plugins/crosshair.d.ts.map +1 -0
  32. package/dist/plugins/crosshair.js +192 -0
  33. package/dist/plugins/crosshair.js.map +1 -0
  34. package/dist/plugins/interactions.js +87 -65
  35. package/dist/plugins/interactions.js.map +1 -1
  36. package/dist/plugins/navigator.d.ts +3 -0
  37. package/dist/plugins/navigator.d.ts.map +1 -0
  38. package/dist/plugins/navigator.js +147 -0
  39. package/dist/plugins/navigator.js.map +1 -0
  40. package/dist/plugins/selection.d.ts +3 -0
  41. package/dist/plugins/selection.d.ts.map +1 -0
  42. package/dist/plugins/selection.js +144 -0
  43. package/dist/plugins/selection.js.map +1 -0
  44. package/dist/plugins/tooltip.js +29 -45
  45. package/dist/plugins/tooltip.js.map +1 -1
  46. package/dist/react.d.ts +14 -0
  47. package/dist/react.d.ts.map +1 -0
  48. package/dist/react.js +30 -0
  49. package/dist/react.js.map +1 -0
  50. package/dist/render/ReglBackend.d.ts +1 -0
  51. package/dist/render/ReglBackend.d.ts.map +1 -1
  52. package/dist/render/Renderer.d.ts +1 -0
  53. package/dist/render/Renderer.d.ts.map +1 -1
  54. package/dist/render/types.d.ts +1 -0
  55. package/dist/render/types.d.ts.map +1 -1
  56. package/dist/ui/Annotations.d.ts +94 -0
  57. package/dist/ui/Annotations.d.ts.map +1 -0
  58. package/dist/ui/Chart.d.ts +83 -1
  59. package/dist/ui/Chart.d.ts.map +1 -1
  60. package/dist/ui/ChartLayout.d.ts +10 -0
  61. package/dist/ui/ChartLayout.d.ts.map +1 -1
  62. package/dist/ui/Crosshair.d.ts +60 -0
  63. package/dist/ui/Crosshair.d.ts.map +1 -0
  64. package/dist/ui/Interactions.d.ts.map +1 -1
  65. package/dist/ui/LinkedCharts.d.ts +23 -0
  66. package/dist/ui/LinkedCharts.d.ts.map +1 -0
  67. package/dist/ui/Navigator.d.ts +32 -0
  68. package/dist/ui/Navigator.d.ts.map +1 -0
  69. package/dist/ui/OverlayUtils.d.ts +17 -0
  70. package/dist/ui/OverlayUtils.d.ts.map +1 -0
  71. package/dist/ui/Selection.d.ts +64 -0
  72. package/dist/ui/Selection.d.ts.map +1 -0
  73. package/dist/ui/Tooltip.d.ts.map +1 -1
  74. package/dist/ui/theme.d.ts +12 -0
  75. package/dist/ui/theme.d.ts.map +1 -1
  76. package/package.json +35 -1
@@ -0,0 +1,3 @@
1
+ export { selectionPlugin } from '../ui/Selection.js';
2
+ export type { SelectionBounds, SelectionEvent, SelectionEventType, SelectionMode, SelectionPlotBounds, SelectionPlugin, SelectionPluginOptions, SelectionSamplePhase, SelectionSeriesSamples, SelectionState } from '../ui/Selection.js';
3
+ //# sourceMappingURL=selection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selection.d.ts","sourceRoot":"","sources":["../../src/plugins/selection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,kBAAkB,EAAE,aAAa,EAAE,mBAAmB,EAAE,eAAe,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,144 @@
1
+ //#region src/ui/Selection.ts
2
+ var e = "rgba(59, 130, 246, 0.16)", t = "rgba(147, 197, 253, 0.95)";
3
+ function n(e, t, n) {
4
+ return Math.max(t, Math.min(e, n));
5
+ }
6
+ function r(e, t, n, r) {
7
+ let i = Math.min(e[0], t[0]), a = Math.max(e[0], t[0]), o = Math.min(e[1], t[1]), s = Math.max(e[1], t[1]);
8
+ return {
9
+ xMin: r === "y-range" ? n.xMin : i,
10
+ xMax: r === "y-range" ? n.xMax : a,
11
+ yMin: r === "x-range" ? n.yMin : o,
12
+ yMax: r === "x-range" ? n.yMax : s
13
+ };
14
+ }
15
+ function i(e, t, r, i) {
16
+ if (r.width <= 0 || r.height <= 0) return null;
17
+ let a = n(e - r.left, 0, r.width), o = n(t - r.top, 0, r.height);
18
+ return [i.xMin + a / r.width * (i.xMax - i.xMin), i.yMax - o / r.height * (i.yMax - i.yMin)];
19
+ }
20
+ function a(e, t, r) {
21
+ let i = n(e.startX - t.left, 0, t.width), a = n(e.startY - t.top, 0, t.height), o = n(e.currentX - t.left, 0, t.width), s = n(e.currentY - t.top, 0, t.height);
22
+ return {
23
+ left: r === "y-range" ? 0 : Math.min(i, o),
24
+ top: r === "x-range" ? 0 : Math.min(a, s),
25
+ width: r === "y-range" ? t.width : Math.abs(o - i),
26
+ height: r === "x-range" ? t.height : Math.abs(s - a)
27
+ };
28
+ }
29
+ function o(e, t, n, r, i) {
30
+ let a = [], o = n === "x-range", s = {
31
+ xMin: t.xMin,
32
+ xMax: t.xMax,
33
+ yMin: -Infinity,
34
+ yMax: Infinity
35
+ };
36
+ for (let n of e) {
37
+ if (!n.visible || !o && n.yAxis !== r) continue;
38
+ let e = n.series.visibleIndexRange(s), c = [], l = 0;
39
+ for (let r = e.start; r < e.end; r++) {
40
+ let e = n.series.sampleAt(r);
41
+ e && (!o && (e.y < t.yMin || e.y > t.yMax) || (l++, c.length < i && c.push(e)));
42
+ }
43
+ l !== 0 && a.push({
44
+ series: n.series,
45
+ seriesIndex: n.index,
46
+ id: n.id,
47
+ name: n.name,
48
+ yAxis: n.yAxis,
49
+ samples: c,
50
+ total: l,
51
+ truncated: l > c.length
52
+ });
53
+ }
54
+ return a;
55
+ }
56
+ function s(n = {}) {
57
+ let s = n.mode ?? "xy", c = n.yAxis ?? "left", l = n.minDragDistancePx ?? 4, u = Math.max(0, Math.floor(n.maxSamplesPerSeries ?? 5e3)), d = n.samplePhase ?? "commit", f = null, p = null, m = null, h = null, g = (e, t) => {
58
+ if (!(!e || !n.onSeriesSelectionChange)) for (let r of e.getSeriesState()) {
59
+ let e = t?.samples.find((e) => e.series === r.series) ?? null;
60
+ n.onSeriesSelectionChange(r, e !== null, e, t);
61
+ }
62
+ }, _ = (e, t, r) => {
63
+ let i = {
64
+ type: e,
65
+ selection: t,
66
+ sourceEvent: r
67
+ };
68
+ n.onChange?.(i), e === "start" && n.onStart?.(i), e === "update" && n.onUpdate?.(i), e === "commit" && n.onCommit?.(i), e === "clear" && n.onClear?.(i);
69
+ }, v = (e) => {
70
+ if (p) {
71
+ if (!e || e.width <= 0 || e.height <= 0) {
72
+ p.style.display = "none";
73
+ return;
74
+ }
75
+ p.style.left = `${e.left}px`, p.style.top = `${e.top}px`, p.style.width = `${e.width}px`, p.style.height = `${e.height}px`, p.style.display = "block";
76
+ }
77
+ }, y = (e, t, n) => {
78
+ let l = e.canvas.getBoundingClientRect(), d = e.getViewport(c), f = i(t.startX, t.startY, l, d), p = i(t.currentX, t.currentY, l, d);
79
+ if (!f || !p) return null;
80
+ let m = r(f, p, d, s);
81
+ return {
82
+ mode: s,
83
+ yAxis: c,
84
+ bounds: m,
85
+ plotBounds: a(t, l, s),
86
+ samples: n ? o(e.getSeriesState(), m, s, c, u) : []
87
+ };
88
+ };
89
+ return {
90
+ install(r) {
91
+ f = r;
92
+ let i = r.canvas;
93
+ p = document.createElement("div"), p.className = n.className ?? "blazeplot-selection-brush", p.style.position = "absolute", p.style.display = "none", p.style.pointerEvents = "none", p.style.zIndex = String(n.zIndex ?? 26), p.style.border = `1px solid ${n.stroke ?? t}`, p.style.background = n.fill ?? e, r.plotElement.appendChild(p);
94
+ let a = (e) => {
95
+ if (m || e.button !== 0) return;
96
+ e.preventDefault(), i.setPointerCapture(e.pointerId), m = {
97
+ pointerId: e.pointerId,
98
+ startX: e.clientX,
99
+ startY: e.clientY,
100
+ currentX: e.clientX,
101
+ currentY: e.clientY
102
+ };
103
+ let t = y(r, m, d === "update");
104
+ v(t?.plotBounds ?? null), _("start", t, e);
105
+ }, o = (e) => {
106
+ if (!m || e.pointerId !== m.pointerId) return;
107
+ e.preventDefault(), m.currentX = e.clientX, m.currentY = e.clientY;
108
+ let t = y(r, m, d === "update");
109
+ v(t?.plotBounds ?? null), d === "update" && g(r, t), _("update", t, e);
110
+ }, s = (e, t) => {
111
+ if (!m || e.pointerId !== m.pointerId) return;
112
+ e.preventDefault();
113
+ let n = m;
114
+ m = null, i.hasPointerCapture(e.pointerId) && i.releasePointerCapture(e.pointerId);
115
+ let a = n.currentX - n.startX, o = n.currentY - n.startY;
116
+ if (!t || Math.hypot(a, o) < l) {
117
+ v(null);
118
+ return;
119
+ }
120
+ let s = y(r, n, d !== "none");
121
+ if (!s || s.bounds.xMax <= s.bounds.xMin || s.bounds.yMax <= s.bounds.yMin) {
122
+ v(null);
123
+ return;
124
+ }
125
+ h = s, v(s.plotBounds), g(r, s), r.emitSelect(s), _("commit", s, e);
126
+ }, c = (e) => s(e, !0), u = (e) => s(e, !1), b = (e) => {
127
+ n.clearOnEscape === !1 || e.key !== "Escape" || (h = null, v(null), g(r, null), r.emitSelect(null), _("clear", null, e));
128
+ };
129
+ return i.addEventListener("pointerdown", a), i.addEventListener("pointermove", o), i.addEventListener("pointerup", c), i.addEventListener("pointercancel", u), globalThis.addEventListener("keydown", b), () => {
130
+ i.removeEventListener("pointerdown", a), i.removeEventListener("pointermove", o), i.removeEventListener("pointerup", c), i.removeEventListener("pointercancel", u), globalThis.removeEventListener("keydown", b), p?.remove(), p = null, f = null, m = null, h = null;
131
+ };
132
+ },
133
+ clear() {
134
+ h = null, v(null), f?.emitSelect(null), g(f, null), _("clear", null);
135
+ },
136
+ getSelection() {
137
+ return h;
138
+ }
139
+ };
140
+ }
141
+ //#endregion
142
+ export { s as selectionPlugin };
143
+
144
+ //# sourceMappingURL=selection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selection.js","names":[],"sources":["../../src/ui/Selection.ts"],"sourcesContent":["import type { SeriesSample, SeriesYAxis, Viewport } from \"../core/types.js\";\nimport type { SeriesStore } from \"../core/SeriesStore.js\";\nimport type { Chart, ChartPlugin, ChartSeriesState } from \"./Chart.js\";\n\nexport type SelectionMode = \"x-range\" | \"y-range\" | \"xy\";\nexport type SelectionEventType = \"start\" | \"update\" | \"commit\" | \"clear\";\nexport type SelectionSamplePhase = \"commit\" | \"update\" | \"none\";\n\nexport interface SelectionBounds {\n readonly xMin: number;\n readonly xMax: number;\n readonly yMin: number;\n readonly yMax: number;\n}\n\nexport interface SelectionPlotBounds {\n readonly left: number;\n readonly top: number;\n readonly width: number;\n readonly height: number;\n}\n\nexport interface SelectionSeriesSamples {\n readonly series: SeriesStore;\n readonly seriesIndex: number;\n readonly id?: string;\n readonly name?: string;\n readonly yAxis: SeriesYAxis;\n readonly samples: readonly SeriesSample[];\n readonly total: number;\n readonly truncated: boolean;\n}\n\nexport interface SelectionState {\n readonly mode: SelectionMode;\n readonly yAxis: SeriesYAxis;\n readonly bounds: SelectionBounds;\n readonly plotBounds: SelectionPlotBounds;\n readonly samples: readonly SelectionSeriesSamples[];\n}\n\nexport interface SelectionEvent {\n readonly type: SelectionEventType;\n readonly selection: SelectionState | null;\n readonly sourceEvent?: PointerEvent | KeyboardEvent;\n}\n\nexport interface SelectionPluginOptions {\n readonly mode?: SelectionMode;\n readonly yAxis?: SeriesYAxis;\n readonly minDragDistancePx?: number;\n readonly maxSamplesPerSeries?: number;\n readonly samplePhase?: SelectionSamplePhase;\n readonly className?: string;\n readonly fill?: string;\n readonly stroke?: string;\n readonly zIndex?: number;\n readonly clearOnEscape?: boolean;\n readonly onStart?: (event: SelectionEvent) => void;\n readonly onUpdate?: (event: SelectionEvent) => void;\n readonly onCommit?: (event: SelectionEvent) => void;\n readonly onClear?: (event: SelectionEvent) => void;\n readonly onChange?: (event: SelectionEvent) => void;\n readonly onSeriesSelectionChange?: (series: ChartSeriesState, selected: boolean, samples: SelectionSeriesSamples | null, selection: SelectionState | null) => void;\n}\n\nexport interface SelectionPlugin extends ChartPlugin {\n clear(): void;\n getSelection(): SelectionState | null;\n}\n\ninterface DragState {\n readonly pointerId: number;\n readonly startX: number;\n readonly startY: number;\n currentX: number;\n currentY: number;\n}\n\nconst DEFAULT_FILL = \"rgba(59, 130, 246, 0.16)\";\nconst DEFAULT_STROKE = \"rgba(147, 197, 253, 0.95)\";\n\nfunction clamp(value: number, min: number, max: number): number {\n return Math.max(min, Math.min(value, max));\n}\n\nfunction normalizeBounds(a: [number, number], b: [number, number], current: Viewport, mode: SelectionMode): SelectionBounds {\n const xMin = Math.min(a[0], b[0]);\n const xMax = Math.max(a[0], b[0]);\n const yMin = Math.min(a[1], b[1]);\n const yMax = Math.max(a[1], b[1]);\n return {\n xMin: mode === \"y-range\" ? current.xMin : xMin,\n xMax: mode === \"y-range\" ? current.xMax : xMax,\n yMin: mode === \"x-range\" ? current.yMin : yMin,\n yMax: mode === \"x-range\" ? current.yMax : yMax,\n };\n}\n\nfunction pointerToData(clientX: number, clientY: number, rect: DOMRect, viewport: Viewport): [number, number] | null {\n if (rect.width <= 0 || rect.height <= 0) return null;\n const plotX = clamp(clientX - rect.left, 0, rect.width);\n const plotY = clamp(clientY - rect.top, 0, rect.height);\n return [\n viewport.xMin + (plotX / rect.width) * (viewport.xMax - viewport.xMin),\n viewport.yMax - (plotY / rect.height) * (viewport.yMax - viewport.yMin),\n ];\n}\n\nfunction plotBoundsForDrag(drag: DragState, rect: DOMRect, mode: SelectionMode): SelectionPlotBounds {\n const x0 = clamp(drag.startX - rect.left, 0, rect.width);\n const y0 = clamp(drag.startY - rect.top, 0, rect.height);\n const x1 = clamp(drag.currentX - rect.left, 0, rect.width);\n const y1 = clamp(drag.currentY - rect.top, 0, rect.height);\n const left = mode === \"y-range\" ? 0 : Math.min(x0, x1);\n const top = mode === \"x-range\" ? 0 : Math.min(y0, y1);\n const width = mode === \"y-range\" ? rect.width : Math.abs(x1 - x0);\n const height = mode === \"x-range\" ? rect.height : Math.abs(y1 - y0);\n return { left, top, width, height };\n}\n\nfunction collectSeriesSamples(\n seriesState: readonly ChartSeriesState[],\n bounds: SelectionBounds,\n mode: SelectionMode,\n yAxis: SeriesYAxis,\n maxSamplesPerSeries: number,\n): SelectionSeriesSamples[] {\n const results: SelectionSeriesSamples[] = [];\n const xOnly = mode === \"x-range\";\n const xViewport = { xMin: bounds.xMin, xMax: bounds.xMax, yMin: -Infinity, yMax: Infinity };\n\n for (const state of seriesState) {\n if (!state.visible) continue;\n if (!xOnly && state.yAxis !== yAxis) continue;\n\n const range = state.series.visibleIndexRange(xViewport);\n const samples: SeriesSample[] = [];\n let total = 0;\n for (let index = range.start; index < range.end; index++) {\n const sample = state.series.sampleAt(index);\n if (!sample) continue;\n if (!xOnly && (sample.y < bounds.yMin || sample.y > bounds.yMax)) continue;\n total++;\n if (samples.length < maxSamplesPerSeries) samples.push(sample);\n }\n\n if (total === 0) continue;\n results.push({\n series: state.series,\n seriesIndex: state.index,\n id: state.id,\n name: state.name,\n yAxis: state.yAxis,\n samples,\n total,\n truncated: total > samples.length,\n });\n }\n\n return results;\n}\n\nexport function selectionPlugin(options: SelectionPluginOptions = {}): SelectionPlugin {\n const mode = options.mode ?? \"xy\";\n const yAxis = options.yAxis ?? \"left\";\n const minDragDistancePx = options.minDragDistancePx ?? 4;\n const maxSamplesPerSeries = Math.max(0, Math.floor(options.maxSamplesPerSeries ?? 5_000));\n const samplePhase = options.samplePhase ?? \"commit\";\n let chartRef: Chart | null = null;\n let overlay: HTMLDivElement | null = null;\n let drag: DragState | null = null;\n let committedSelection: SelectionState | null = null;\n\n const notifySeriesSelection = (chart: Chart | null, selection: SelectionState | null): void => {\n if (!chart || !options.onSeriesSelectionChange) return;\n for (const series of chart.getSeriesState()) {\n const samples = selection?.samples.find((entry) => entry.series === series.series) ?? null;\n options.onSeriesSelectionChange(series, samples !== null, samples, selection);\n }\n };\n\n const emit = (type: SelectionEventType, selection: SelectionState | null, sourceEvent?: PointerEvent | KeyboardEvent): void => {\n const event: SelectionEvent = { type, selection, sourceEvent };\n options.onChange?.(event);\n if (type === \"start\") options.onStart?.(event);\n if (type === \"update\") options.onUpdate?.(event);\n if (type === \"commit\") options.onCommit?.(event);\n if (type === \"clear\") options.onClear?.(event);\n };\n\n const setOverlay = (plotBounds: SelectionPlotBounds | null): void => {\n if (!overlay) return;\n if (!plotBounds || plotBounds.width <= 0 || plotBounds.height <= 0) {\n overlay.style.display = \"none\";\n return;\n }\n overlay.style.left = `${plotBounds.left}px`;\n overlay.style.top = `${plotBounds.top}px`;\n overlay.style.width = `${plotBounds.width}px`;\n overlay.style.height = `${plotBounds.height}px`;\n overlay.style.display = \"block\";\n };\n\n const buildSelection = (chart: Chart, state: DragState, includeSamples: boolean): SelectionState | null => {\n const canvas = chart.canvas;\n const rect = canvas.getBoundingClientRect();\n const current = chart.getViewport(yAxis);\n const start = pointerToData(state.startX, state.startY, rect, current);\n const end = pointerToData(state.currentX, state.currentY, rect, current);\n if (!start || !end) return null;\n\n const bounds = normalizeBounds(start, end, current, mode);\n const plotBounds = plotBoundsForDrag(state, rect, mode);\n const samples = includeSamples\n ? collectSeriesSamples(chart.getSeriesState(), bounds, mode, yAxis, maxSamplesPerSeries)\n : [];\n return { mode, yAxis, bounds, plotBounds, samples };\n };\n\n return {\n install(chart: Chart) {\n chartRef = chart;\n const canvas = chart.canvas;\n overlay = document.createElement(\"div\");\n overlay.className = options.className ?? \"blazeplot-selection-brush\";\n overlay.style.position = \"absolute\";\n overlay.style.display = \"none\";\n overlay.style.pointerEvents = \"none\";\n overlay.style.zIndex = String(options.zIndex ?? 26);\n overlay.style.border = `1px solid ${options.stroke ?? DEFAULT_STROKE}`;\n overlay.style.background = options.fill ?? DEFAULT_FILL;\n chart.plotElement.appendChild(overlay);\n\n const onPointerDown = (event: PointerEvent): void => {\n if (drag || event.button !== 0) return;\n event.preventDefault();\n canvas.setPointerCapture(event.pointerId);\n drag = {\n pointerId: event.pointerId,\n startX: event.clientX,\n startY: event.clientY,\n currentX: event.clientX,\n currentY: event.clientY,\n };\n const selection = buildSelection(chart, drag, samplePhase === \"update\");\n setOverlay(selection?.plotBounds ?? null);\n emit(\"start\", selection, event);\n };\n\n const onPointerMove = (event: PointerEvent): void => {\n if (!drag || event.pointerId !== drag.pointerId) return;\n event.preventDefault();\n drag.currentX = event.clientX;\n drag.currentY = event.clientY;\n const selection = buildSelection(chart, drag, samplePhase === \"update\");\n setOverlay(selection?.plotBounds ?? null);\n if (samplePhase === \"update\") notifySeriesSelection(chart, selection);\n emit(\"update\", selection, event);\n };\n\n const finishDrag = (event: PointerEvent, commit: boolean): void => {\n if (!drag || event.pointerId !== drag.pointerId) return;\n event.preventDefault();\n const completed = drag;\n drag = null;\n if (canvas.hasPointerCapture(event.pointerId)) canvas.releasePointerCapture(event.pointerId);\n\n const dx = completed.currentX - completed.startX;\n const dy = completed.currentY - completed.startY;\n if (!commit || Math.hypot(dx, dy) < minDragDistancePx) {\n setOverlay(null);\n return;\n }\n\n const selection = buildSelection(chart, completed, samplePhase !== \"none\");\n if (!selection || selection.bounds.xMax <= selection.bounds.xMin || selection.bounds.yMax <= selection.bounds.yMin) {\n setOverlay(null);\n return;\n }\n\n committedSelection = selection;\n setOverlay(selection.plotBounds);\n notifySeriesSelection(chart, selection);\n chart.emitSelect(selection);\n emit(\"commit\", selection, event);\n };\n\n const onPointerUp = (event: PointerEvent): void => finishDrag(event, true);\n const onPointerCancel = (event: PointerEvent): void => finishDrag(event, false);\n const onKeyDown = (event: KeyboardEvent): void => {\n if (options.clearOnEscape === false || event.key !== \"Escape\") return;\n committedSelection = null;\n setOverlay(null);\n notifySeriesSelection(chart, null);\n chart.emitSelect(null);\n emit(\"clear\", null, event);\n };\n\n canvas.addEventListener(\"pointerdown\", onPointerDown);\n canvas.addEventListener(\"pointermove\", onPointerMove);\n canvas.addEventListener(\"pointerup\", onPointerUp);\n canvas.addEventListener(\"pointercancel\", onPointerCancel);\n globalThis.addEventListener(\"keydown\", onKeyDown);\n\n return () => {\n canvas.removeEventListener(\"pointerdown\", onPointerDown);\n canvas.removeEventListener(\"pointermove\", onPointerMove);\n canvas.removeEventListener(\"pointerup\", onPointerUp);\n canvas.removeEventListener(\"pointercancel\", onPointerCancel);\n globalThis.removeEventListener(\"keydown\", onKeyDown);\n overlay?.remove();\n overlay = null;\n chartRef = null;\n drag = null;\n committedSelection = null;\n };\n },\n clear(): void {\n committedSelection = null;\n setOverlay(null);\n chartRef?.emitSelect(null);\n notifySeriesSelection(chartRef, null);\n emit(\"clear\", null);\n },\n getSelection(): SelectionState | null {\n return committedSelection;\n },\n };\n}\n"],"mappings":";AA+EA,IAAM,IAAe,4BACf,IAAiB;AAEvB,SAAS,EAAM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AJA,IAAqB,MACrB,EAAW,IAAI,GACf,GAAU,WAAW,IAAI,GACzB,EAAsB,GAAU,IAAI,GACpC,EAAK,SAAS,IAAI;EACpB;EACA,eAAsC;GACpC,OAAO;EACT;CACF;AACF"}
@@ -1,61 +1,45 @@
1
+ import { a as e, i as t, r as n, t as r } from "../OverlayUtils-Cw1o8UH-.js";
1
2
  //#region src/ui/Tooltip.ts
2
- function e(e) {
3
- return e.name ?? e.id ?? `${e.mode} ${e.seriesIndex + 1}`;
3
+ function i(e, n, i) {
4
+ t(n, e.items, e, i, (e) => `(${r(e.x)}, ${r(e.y)})`);
4
5
  }
5
- function t(e) {
6
- if (!Number.isFinite(e)) return String(e);
7
- let t = Math.abs(e);
8
- return t > 0 && (t < .001 || t >= 1e6) ? e.toExponential(3) : Number(e.toPrecision(6)).toString();
6
+ function a(e, t, r) {
7
+ n(e, t.clientX, t.clientY, {
8
+ offsetX: r.offsetX ?? 12,
9
+ offsetY: r.offsetY ?? 12
10
+ });
9
11
  }
10
- function n(e) {
11
- return `rgba(${Math.round(e[0] * 255)}, ${Math.round(e[1] * 255)}, ${Math.round(e[2] * 255)}, ${e[3]})`;
12
- }
13
- function r(r, i, a) {
14
- let o = Math.max(1, ...r.items.map((t) => e(t).length)), s = "";
15
- for (let i of r.items) {
16
- let c = a ? a(i, r) : `(${t(i.x)}, ${t(i.y)})`, l = n(i.series.style.color);
17
- s && (s += "<br>"), s += `<span style="color:${l}">\u2588</span> ${e(i).padEnd(o)} ${c}`;
18
- }
19
- i.innerHTML = s;
20
- }
21
- function i(e, t, n) {
22
- return Math.min(n, Math.max(t, e));
23
- }
24
- function a(e, t, n) {
25
- let r = n.offsetX ?? 12, a = n.offsetY ?? 12, o = e.getBoundingClientRect(), s = e.ownerDocument, c = Math.max(1, globalThis.innerWidth || s.documentElement.clientWidth), l = Math.max(1, globalThis.innerHeight || s.documentElement.clientHeight), u = i(t.clientX + r, 4, Math.max(4, c - o.width - 4)), d = i(t.clientY + a, 4, Math.max(4, l - o.height - 4));
26
- e.style.transform = `translate(${u}px, ${d}px)`;
27
- }
28
- function o(e = {}) {
29
- return { install(t) {
30
- let i = document.createElement("div");
31
- i.className = e.className ?? "blazeplot-tooltip", i.style.position = "fixed", i.style.left = "0", i.style.top = "0", i.style.zIndex = String(e.zIndex ?? 1e4), i.style.display = "none", i.style.pointerEvents = "none", i.style.background = e.backgroundColor ?? t.theme.tooltipBackgroundColor, i.style.color = e.textColor ?? t.theme.tooltipTextColor, i.style.font = e.font ?? t.theme.tooltipFont, i.style.padding = "8px 10px", i.style.whiteSpace = "pre", (t.rootElement.ownerDocument.body ?? t.rootElement).appendChild(i);
12
+ function o(t = {}) {
13
+ return { install(n) {
14
+ let r = document.createElement("div");
15
+ r.className = t.className ?? "blazeplot-tooltip", r.style.position = "fixed", r.style.left = "0", r.style.top = "0", r.style.zIndex = String(t.zIndex ?? 1e4), r.style.display = "none", r.style.pointerEvents = "none", r.style.background = t.backgroundColor ?? n.theme.tooltipBackgroundColor, r.style.color = t.textColor ?? n.theme.tooltipTextColor, r.style.font = t.font ?? n.theme.tooltipFont, r.style.padding = "8px 10px", r.style.whiteSpace = "pre", (n.rootElement.ownerDocument.body ?? n.rootElement).appendChild(r);
32
16
  let o = document.createElement("div");
33
- o.className = "blazeplot-tooltip-markers", o.style.position = "absolute", o.style.inset = "0", o.style.zIndex = "25", o.style.pointerEvents = "none", t.plotElement.appendChild(o);
17
+ o.className = "blazeplot-tooltip-markers", o.style.position = "absolute", o.style.inset = "0", o.style.zIndex = "25", o.style.pointerEvents = "none", n.plotElement.appendChild(o);
34
18
  let s = 0, c = () => {
35
- if (e.lockWidth === !1) return;
36
- let t = Math.ceil(i.getBoundingClientRect().width);
37
- t <= s || (s = t, i.style.minWidth = `${s}px`);
19
+ if (t.lockWidth === !1) return;
20
+ let e = Math.ceil(r.getBoundingClientRect().width);
21
+ e <= s || (s = e, r.style.minWidth = `${s}px`);
38
22
  }, l = () => {
39
- s = 0, i.style.minWidth = "";
23
+ s = 0, r.style.minWidth = "";
40
24
  }, u = () => {
41
- i.style.background = e.backgroundColor ?? t.theme.tooltipBackgroundColor, i.style.color = e.textColor ?? t.theme.tooltipTextColor, i.style.font = e.font ?? t.theme.tooltipFont;
42
- }, d = (t) => {
43
- if (o.replaceChildren(), !(e.highlight === !1 || !t)) for (let e of t.items) {
44
- let t = document.createElement("div");
45
- t.style.position = "absolute", t.style.left = `${e.plotX}px`, t.style.top = `${e.plotY}px`, t.style.width = "10px", t.style.height = "10px", t.style.border = "2px solid #f8fafc", t.style.borderRadius = "999px", t.style.background = n(e.series.style.color), t.style.boxShadow = "0 0 0 1px rgba(4, 8, 16, 0.85)", t.style.transform = "translate(-50%, -50%)", o.appendChild(t);
25
+ r.style.background = t.backgroundColor ?? n.theme.tooltipBackgroundColor, r.style.color = t.textColor ?? n.theme.tooltipTextColor, r.style.font = t.font ?? n.theme.tooltipFont;
26
+ }, d = (n) => {
27
+ if (o.replaceChildren(), !(t.highlight === !1 || !n)) for (let t of n.items) {
28
+ let n = document.createElement("div");
29
+ n.style.position = "absolute", n.style.left = `${t.plotX}px`, n.style.top = `${t.plotY}px`, n.style.width = "10px", n.style.height = "10px", n.style.border = "2px solid #f8fafc", n.style.borderRadius = "999px", n.style.background = e(t.series.style.color), n.style.boxShadow = "0 0 0 1px rgba(4, 8, 16, 0.85)", n.style.transform = "translate(-50%, -50%)", o.appendChild(n);
46
30
  }
47
- }, f = (n) => {
48
- let o = n !== null && (e.mode !== void 0 && e.mode !== n.mode || e.group !== void 0 && e.group !== n.group || e.maxDistancePx !== void 0 && e.maxDistancePx !== n.maxDistancePx) ? t.pick(n.clientX, n.clientY, e) : n;
31
+ }, f = (e) => {
32
+ let o = e !== null && (t.mode !== void 0 && t.mode !== e.mode || t.group !== void 0 && t.group !== e.group || t.maxDistancePx !== void 0 && t.maxDistancePx !== e.maxDistancePx) ? n.pick(e.clientX, e.clientY, t) : e;
49
33
  if (d(o), !o || o.items.length === 0) {
50
- i.style.display = "none", l();
34
+ r.style.display = "none", l();
51
35
  return;
52
36
  }
53
- e.render ? e.render(o, i, t) : r(o, i, e.formatter), i.style.display = "block", c(), a(i, o, e);
54
- }, p = t.subscribe("hover", f), m = t.subscribe("themechange", () => {
55
- u(), f(t.getHoverState());
37
+ t.render ? t.render(o, r, n) : i(o, r, t.formatter), r.style.display = "block", c(), a(r, o, t);
38
+ }, p = n.subscribe("hover", f), m = n.subscribe("themechange", () => {
39
+ u(), f(n.getHoverState());
56
40
  });
57
41
  return u(), () => {
58
- p(), m(), o.remove(), i.remove();
42
+ p(), m(), o.remove(), r.remove();
59
43
  };
60
44
  } };
61
45
  }
@@ -1 +1 @@
1
- {"version":3,"file":"tooltip.js","names":[],"sources":["../../src/ui/Tooltip.ts"],"sourcesContent":["import type { Chart, ChartHoverState, ChartPickGroup, ChartPickItem, ChartPickMode, ChartPlugin } from \"./Chart.js\";\n\nexport interface TooltipPluginOptions {\n readonly className?: string;\n readonly mode?: ChartPickMode;\n readonly group?: ChartPickGroup;\n readonly maxDistancePx?: number;\n readonly offsetX?: number;\n readonly offsetY?: number;\n readonly highlight?: boolean;\n readonly backgroundColor?: string;\n readonly textColor?: string;\n readonly font?: string;\n readonly zIndex?: number;\n readonly lockWidth?: boolean;\n readonly formatter?: (item: ChartPickItem, state: ChartHoverState) => string;\n readonly render?: (state: ChartHoverState, container: HTMLElement, chart: Chart) => void;\n}\n\nfunction labelOf(item: ChartPickItem): string {\n return item.name ?? item.id ?? `${item.mode} ${item.seriesIndex + 1}`;\n}\n\nfunction formatNumber(value: number): string {\n if (!Number.isFinite(value)) return String(value);\n const abs = Math.abs(value);\n if (abs > 0 && (abs < 1e-3 || abs >= 1e6)) return value.toExponential(3);\n return Number(value.toPrecision(6)).toString();\n}\n\nfunction rgba(color: readonly [number, number, number, number]): string {\n return `rgba(${Math.round(color[0] * 255)}, ${Math.round(color[1] * 255)}, ${Math.round(color[2] * 255)}, ${color[3]})`;\n}\n\nfunction renderDefaultTooltip(\n state: ChartHoverState,\n container: HTMLElement,\n formatter: TooltipPluginOptions[\"formatter\"],\n): void {\n const pad = Math.max(1, ...state.items.map((item) => labelOf(item).length));\n let html = \"\";\n for (const item of state.items) {\n const value = formatter ? formatter(item, state) : `(${formatNumber(item.x)}, ${formatNumber(item.y)})`;\n const color = rgba(item.series.style.color);\n if (html) html += \"<br>\";\n html += `<span style=\"color:${color}\">\\u2588</span> ${labelOf(item).padEnd(pad)} ${value}`;\n }\n container.innerHTML = html;\n}\n\nfunction clamp(value: number, min: number, max: number): number {\n return Math.min(max, Math.max(min, value));\n}\n\nfunction placeTooltip(\n container: HTMLElement,\n state: ChartHoverState,\n options: TooltipPluginOptions,\n): void {\n const offsetX = options.offsetX ?? 12;\n const offsetY = options.offsetY ?? 12;\n const tooltipRect = container.getBoundingClientRect();\n const margin = 4;\n const doc = container.ownerDocument;\n const viewportWidth = Math.max(1, globalThis.innerWidth || doc.documentElement.clientWidth);\n const viewportHeight = Math.max(1, globalThis.innerHeight || doc.documentElement.clientHeight);\n\n const viewportX = clamp(\n state.clientX + offsetX,\n margin,\n Math.max(margin, viewportWidth - tooltipRect.width - margin),\n );\n const viewportY = clamp(\n state.clientY + offsetY,\n margin,\n Math.max(margin, viewportHeight - tooltipRect.height - margin),\n );\n container.style.transform = `translate(${viewportX}px, ${viewportY}px)`;\n}\n\nexport function tooltipPlugin(options: TooltipPluginOptions = {}): ChartPlugin {\n return {\n install(chart: Chart) {\n const container = document.createElement(\"div\");\n container.className = options.className ?? \"blazeplot-tooltip\";\n container.style.position = \"fixed\";\n container.style.left = \"0\";\n container.style.top = \"0\";\n container.style.zIndex = String(options.zIndex ?? 10_000);\n container.style.display = \"none\";\n container.style.pointerEvents = \"none\";\n container.style.background = options.backgroundColor ?? chart.theme.tooltipBackgroundColor;\n container.style.color = options.textColor ?? chart.theme.tooltipTextColor;\n container.style.font = options.font ?? chart.theme.tooltipFont;\n container.style.padding = \"8px 10px\";\n container.style.whiteSpace = \"pre\";\n const tooltipParent = chart.rootElement.ownerDocument.body ?? chart.rootElement;\n tooltipParent.appendChild(container);\n\n const markerLayer = document.createElement(\"div\");\n markerLayer.className = \"blazeplot-tooltip-markers\";\n markerLayer.style.position = \"absolute\";\n markerLayer.style.inset = \"0\";\n markerLayer.style.zIndex = \"25\";\n markerLayer.style.pointerEvents = \"none\";\n chart.plotElement.appendChild(markerLayer);\n\n let lockedTooltipWidth = 0;\n\n const lockTooltipWidth = (): void => {\n if (options.lockWidth === false) return;\n const width = Math.ceil(container.getBoundingClientRect().width);\n if (width <= lockedTooltipWidth) return;\n lockedTooltipWidth = width;\n container.style.minWidth = `${lockedTooltipWidth}px`;\n };\n\n const resetTooltipWidth = (): void => {\n lockedTooltipWidth = 0;\n container.style.minWidth = \"\";\n };\n\n const applyTheme = (): void => {\n container.style.background = options.backgroundColor ?? chart.theme.tooltipBackgroundColor;\n container.style.color = options.textColor ?? chart.theme.tooltipTextColor;\n container.style.font = options.font ?? chart.theme.tooltipFont;\n };\n\n const renderMarkers = (state: ChartHoverState | null): void => {\n markerLayer.replaceChildren();\n if (options.highlight === false || !state) return;\n\n for (const item of state.items) {\n const marker = document.createElement(\"div\");\n marker.style.position = \"absolute\";\n marker.style.left = `${item.plotX}px`;\n marker.style.top = `${item.plotY}px`;\n marker.style.width = \"10px\";\n marker.style.height = \"10px\";\n marker.style.border = \"2px solid #f8fafc\";\n marker.style.borderRadius = \"999px\";\n marker.style.background = rgba(item.series.style.color);\n marker.style.boxShadow = \"0 0 0 1px rgba(4, 8, 16, 0.85)\";\n marker.style.transform = \"translate(-50%, -50%)\";\n markerLayer.appendChild(marker);\n }\n };\n\n const render = (state: ChartHoverState | null): void => {\n const shouldRepick = state !== null && (\n (options.mode !== undefined && options.mode !== state.mode) ||\n (options.group !== undefined && options.group !== state.group) ||\n (options.maxDistancePx !== undefined && options.maxDistancePx !== state.maxDistancePx)\n );\n const effectiveState = shouldRepick ? chart.pick(state.clientX, state.clientY, options) : state;\n\n renderMarkers(effectiveState);\n if (!effectiveState || effectiveState.items.length === 0) {\n container.style.display = \"none\";\n resetTooltipWidth();\n return;\n }\n\n if (options.render) {\n options.render(effectiveState, container, chart);\n } else {\n renderDefaultTooltip(effectiveState, container, options.formatter);\n }\n\n container.style.display = \"block\";\n lockTooltipWidth();\n placeTooltip(container, effectiveState, options);\n };\n\n const unsubscribeHover = chart.subscribe(\"hover\", render);\n const unsubscribeTheme = chart.subscribe(\"themechange\", () => {\n applyTheme();\n render(chart.getHoverState());\n });\n applyTheme();\n return () => {\n unsubscribeHover();\n unsubscribeTheme();\n markerLayer.remove();\n container.remove();\n };\n },\n };\n}\n"],"mappings":";AAmBA,SAAS,EAAQ,GAA6B;CAC5C,OAAO,EAAK,QAAQ,EAAK,MAAM,GAAG,EAAK,KAAK,GAAG,EAAK,cAAc;AACpE;AAEA,SAAS,EAAa,GAAuB;CAC3C,IAAI,CAAC,OAAO,SAAS,CAAK,GAAG,OAAO,OAAO,CAAK;CAChD,IAAM,IAAM,KAAK,IAAI,CAAK;CAE1B,OADI,IAAM,MAAM,IAAM,QAAQ,KAAO,OAAa,EAAM,cAAc,CAAC,IAChE,OAAO,EAAM,YAAY,CAAC,CAAC,EAAE,SAAS;AAC/C;AAEA,SAAS,EAAK,GAA0D;CACtE,OAAO,QAAQ,KAAK,MAAM,EAAM,KAAK,GAAG,EAAE,IAAI,KAAK,MAAM,EAAM,KAAK,GAAG,EAAE,IAAI,KAAK,MAAM,EAAM,KAAK,GAAG,EAAE,IAAI,EAAM,GAAG;AACvH;AAEA,SAAS,EACP,GACA,GACA,GACM;CACN,IAAM,IAAM,KAAK,IAAI,GAAG,GAAG,EAAM,MAAM,KAAK,MAAS,EAAQ,CAAI,EAAE,MAAM,CAAC,GACtE,IAAO;CACX,KAAK,IAAM,KAAQ,EAAM,OAAO;EAC9B,IAAM,IAAQ,IAAY,EAAU,GAAM,CAAK,IAAI,IAAI,EAAa,EAAK,CAAC,EAAE,IAAI,EAAa,EAAK,CAAC,EAAE,IA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Y,yBACzB,EAAY,YAAY,CAAM;GAChC;EACF,GAEM,KAAU,MAAwC;GAMtD,IAAM,IALe,MAAU,SAC5B,EAAQ,SAAS,KAAA,KAAa,EAAQ,SAAS,EAAM,QACrD,EAAQ,UAAU,KAAA,KAAa,EAAQ,UAAU,EAAM,SACvD,EAAQ,kBAAkB,KAAA,KAAa,EAAQ,kBAAkB,EAAM,iBAEpC,EAAM,KAAK,EAAM,SAAS,EAAM,SAAS,CAAO,IAAI;GAG1F,IADA,EAAc,CAAc,GACxB,CAAC,KAAkB,EAAe,MAAM,WAAW,GAAG;IAExD,AADA,EAAU,MAAM,UAAU,QAC1B,EAAkB;IAClB;GACF;GAUA,AARI,EAAQ,SACV,EAAQ,OAAO,GAAgB,GAAW,CAAK,IAE/C,EAAqB,GAAgB,GAAW,EAAQ,SAAS,GAGnE,EAAU,MAAM,UAAU,SAC1B,EAAiB,GACjB,EAAa,GAAW,GAAgB,CAAO;EACjD,GAEM,IAAmB,EAAM,UAAU,SAAS,CAAM,GAClD,IAAmB,EAAM,UAAU,qBAAqB;GAE5D,AADA,EAAW,GACX,EAAO,EAAM,cAAc,CAAC;EAC9B,CAAC;EAED,OADA,EAAW,SACE;GAIX,AAHA,EAAiB,GACjB,EAAiB,GACjB,EAAY,OAAO,GACnB,EAAU,OAAO;EACnB;CACF,EACF;AACF"}
1
+ {"version":3,"file":"tooltip.js","names":[],"sources":["../../src/ui/Tooltip.ts"],"sourcesContent":["import type { Chart, ChartHoverState, ChartPickGroup, ChartPickItem, ChartPickMode, ChartPlugin } from \"./Chart.js\";\nimport { formatCompactNumber, placeFixedWithinViewport, renderPickItems, rgba } from \"./OverlayUtils.js\";\n\nexport interface TooltipPluginOptions {\n readonly className?: string;\n readonly mode?: ChartPickMode;\n readonly group?: ChartPickGroup;\n readonly maxDistancePx?: number;\n readonly offsetX?: number;\n readonly offsetY?: number;\n readonly highlight?: boolean;\n readonly backgroundColor?: string;\n readonly textColor?: string;\n readonly font?: string;\n readonly zIndex?: number;\n readonly lockWidth?: boolean;\n readonly formatter?: (item: ChartPickItem, state: ChartHoverState) => string;\n readonly render?: (state: ChartHoverState, container: HTMLElement, chart: Chart) => void;\n}\n\nfunction renderDefaultTooltip(state: ChartHoverState, container: HTMLElement, formatter: TooltipPluginOptions[\"formatter\"]): void {\n renderPickItems(\n container,\n state.items,\n state,\n formatter,\n (item) => `(${formatCompactNumber(item.x)}, ${formatCompactNumber(item.y)})`,\n );\n}\n\nfunction placeTooltip(container: HTMLElement, state: ChartHoverState, options: TooltipPluginOptions): void {\n placeFixedWithinViewport(container, state.clientX, state.clientY, {\n offsetX: options.offsetX ?? 12,\n offsetY: options.offsetY ?? 12,\n });\n}\n\nexport function tooltipPlugin(options: TooltipPluginOptions = {}): ChartPlugin {\n return {\n install(chart: Chart) {\n const container = document.createElement(\"div\");\n container.className = options.className ?? \"blazeplot-tooltip\";\n container.style.position = \"fixed\";\n container.style.left = \"0\";\n container.style.top = \"0\";\n container.style.zIndex = String(options.zIndex ?? 10_000);\n container.style.display = \"none\";\n container.style.pointerEvents = \"none\";\n container.style.background = options.backgroundColor ?? chart.theme.tooltipBackgroundColor;\n container.style.color = options.textColor ?? chart.theme.tooltipTextColor;\n container.style.font = options.font ?? chart.theme.tooltipFont;\n container.style.padding = \"8px 10px\";\n container.style.whiteSpace = \"pre\";\n const tooltipParent = chart.rootElement.ownerDocument.body ?? chart.rootElement;\n tooltipParent.appendChild(container);\n\n const markerLayer = document.createElement(\"div\");\n markerLayer.className = \"blazeplot-tooltip-markers\";\n markerLayer.style.position = \"absolute\";\n markerLayer.style.inset = \"0\";\n markerLayer.style.zIndex = \"25\";\n markerLayer.style.pointerEvents = \"none\";\n chart.plotElement.appendChild(markerLayer);\n\n let lockedTooltipWidth = 0;\n\n const lockTooltipWidth = (): void => {\n if (options.lockWidth === false) return;\n const width = Math.ceil(container.getBoundingClientRect().width);\n if (width <= lockedTooltipWidth) return;\n lockedTooltipWidth = width;\n container.style.minWidth = `${lockedTooltipWidth}px`;\n };\n\n const resetTooltipWidth = (): void => {\n lockedTooltipWidth = 0;\n container.style.minWidth = \"\";\n };\n\n const applyTheme = (): void => {\n container.style.background = options.backgroundColor ?? chart.theme.tooltipBackgroundColor;\n container.style.color = options.textColor ?? chart.theme.tooltipTextColor;\n container.style.font = options.font ?? chart.theme.tooltipFont;\n };\n\n const renderMarkers = (state: ChartHoverState | null): void => {\n markerLayer.replaceChildren();\n if (options.highlight === false || !state) return;\n\n for (const item of state.items) {\n const marker = document.createElement(\"div\");\n marker.style.position = \"absolute\";\n marker.style.left = `${item.plotX}px`;\n marker.style.top = `${item.plotY}px`;\n marker.style.width = \"10px\";\n marker.style.height = \"10px\";\n marker.style.border = \"2px solid #f8fafc\";\n marker.style.borderRadius = \"999px\";\n marker.style.background = rgba(item.series.style.color);\n marker.style.boxShadow = \"0 0 0 1px rgba(4, 8, 16, 0.85)\";\n marker.style.transform = \"translate(-50%, -50%)\";\n markerLayer.appendChild(marker);\n }\n };\n\n const render = (state: ChartHoverState | null): void => {\n const shouldRepick = state !== null && (\n (options.mode !== undefined && options.mode !== state.mode) ||\n (options.group !== undefined && options.group !== state.group) ||\n (options.maxDistancePx !== undefined && options.maxDistancePx !== state.maxDistancePx)\n );\n const effectiveState = shouldRepick ? chart.pick(state.clientX, state.clientY, options) : state;\n\n renderMarkers(effectiveState);\n if (!effectiveState || effectiveState.items.length === 0) {\n container.style.display = \"none\";\n resetTooltipWidth();\n return;\n }\n\n if (options.render) {\n options.render(effectiveState, container, chart);\n } else {\n renderDefaultTooltip(effectiveState, container, options.formatter);\n }\n\n container.style.display = \"block\";\n lockTooltipWidth();\n placeTooltip(container, effectiveState, options);\n };\n\n const unsubscribeHover = chart.subscribe(\"hover\", render);\n const unsubscribeTheme = chart.subscribe(\"themechange\", () => {\n applyTheme();\n render(chart.getHoverState());\n });\n applyTheme();\n return () => {\n unsubscribeHover();\n unsubscribeTheme();\n markerLayer.remove();\n container.remove();\n };\n },\n };\n}\n"],"mappings":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AK,IAE/C,EAAqB,GAAgB,GAAW,EAAQ,SAAS,GAGnE,EAAU,MAAM,UAAU,SAC1B,EAAiB,GACjB,EAAa,GAAW,GAAgB,CAAO;EACjD,GAEM,IAAmB,EAAM,UAAU,SAAS,CAAM,GAClD,IAAmB,EAAM,UAAU,qBAAqB;GAE5D,AADA,EAAW,GACX,EAAO,EAAM,cAAc,CAAC;EAC9B,CAAC;EAED,OADA,EAAW,SACE;GAIX,AAHA,EAAiB,GACjB,EAAiB,GACjB,EAAY,OAAO,GACnB,EAAU,OAAO;EACnB;CACF,EACF;AACF"}
@@ -0,0 +1,14 @@
1
+ import { Chart, ChartOptions } from './ui/Chart.js';
2
+ import * as React from "react";
3
+ export interface BlazeChartProps {
4
+ readonly options?: ChartOptions;
5
+ readonly className?: string;
6
+ readonly style?: React.CSSProperties;
7
+ readonly chartRef?: React.Ref<Chart | null>;
8
+ readonly onChart?: (chart: Chart) => void;
9
+ }
10
+ export declare const BlazeChart: (props: BlazeChartProps & {
11
+ ref?: React.Ref<Chart | null> | undefined;
12
+ }) => React.ReactElement | null;
13
+ export default BlazeChart;
14
+ //# sourceMappingURL=react.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,OAAO,CAAC,EAAE,YAAY,CAAC;IAChC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IACrC,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;IAC5C,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAC3C;AAWD,eAAO,MAAM,UAAU;;+BA+BrB,CAAC;AAEH,eAAe,UAAU,CAAC"}
package/dist/react.js ADDED
@@ -0,0 +1,30 @@
1
+ import { t as e } from "./Chart-BW9JaHs6.js";
2
+ import * as t from "react";
3
+ //#region src/react.ts
4
+ function n(e, t) {
5
+ e && (typeof e == "function" ? e(t) : e.current = t);
6
+ }
7
+ var r = t.forwardRef(function(r, i) {
8
+ let a = t.useRef(null), o = t.useRef(null);
9
+ return t.useLayoutEffect(() => {
10
+ let t = a.current;
11
+ if (!t) return;
12
+ let s = new e(t, r.options);
13
+ return o.current = s, n(i, s), n(r.chartRef, s), r.onChart?.(s), () => {
14
+ s.dispose(), o.current = null, n(i, null), n(r.chartRef, null);
15
+ };
16
+ }, [r.options]), t.useEffect(() => {
17
+ o.current?.resize();
18
+ }), t.createElement("div", {
19
+ ref: a,
20
+ className: r.className,
21
+ style: r.style ?? {
22
+ width: "100%",
23
+ height: "100%"
24
+ }
25
+ });
26
+ });
27
+ //#endregion
28
+ export { r as BlazeChart, r as default };
29
+
30
+ //# sourceMappingURL=react.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react.js","names":[],"sources":["../src/react.ts"],"sourcesContent":["import * as React from \"react\";\nimport { Chart } from \"./ui/Chart.js\";\nimport type { ChartOptions } from \"./ui/Chart.js\";\n\nexport interface BlazeChartProps {\n readonly options?: ChartOptions;\n readonly className?: string;\n readonly style?: React.CSSProperties;\n readonly chartRef?: React.Ref<Chart | null>;\n readonly onChart?: (chart: Chart) => void;\n}\n\nfunction setRef<T>(ref: React.Ref<T> | undefined, value: T | null): void {\n if (!ref) return;\n if (typeof ref === \"function\") {\n ref(value);\n } else {\n (ref as { current: T | null }).current = value;\n }\n}\n\nexport const BlazeChart = React.forwardRef<Chart | null, BlazeChartProps>(function BlazeChart(props, forwardedRef) {\n const hostRef = React.useRef<HTMLDivElement | null>(null);\n const chartRef = React.useRef<Chart | null>(null);\n\n React.useLayoutEffect(() => {\n const host = hostRef.current;\n if (!host) return;\n\n const chart = new Chart(host, props.options);\n chartRef.current = chart;\n setRef(forwardedRef, chart);\n setRef(props.chartRef, chart);\n props.onChart?.(chart);\n\n return () => {\n chart.dispose();\n chartRef.current = null;\n setRef(forwardedRef, null);\n setRef(props.chartRef, null);\n };\n }, [props.options]);\n\n React.useEffect(() => {\n chartRef.current?.resize();\n });\n\n return React.createElement(\"div\", {\n ref: hostRef,\n className: props.className,\n style: props.style ?? { width: \"100%\", height: \"100%\" },\n });\n});\n\nexport default BlazeChart;\n"],"mappings":";;;AAYA,SAAS,EAAU,GAA+B,GAAuB;CAClE,MACD,OAAO,KAAQ,aACjB,EAAI,CAAK,IAET,EAA+B,UAAU;AAE7C;AAEA,IAAa,IAAa,EAAM,WAA0C,SAAoB,GAAO,GAAc;CACjH,IAAM,IAAU,EAAM,OAA8B,IAAI,GAClD,IAAW,EAAM,OAAqB,IAAI;CAwBhD,OAtBA,EAAM,sBAAsB;EAC1B,IAAM,IAAO,EAAQ;EACrB,IAAI,CAAC,GAAM;EAEX,IAAM,IAAQ,IAAI,EAAM,GAAM,EAAM,OAAO;EAM3C,OALA,EAAS,UAAU,GACnB,EAAO,GAAc,CAAK,GAC1B,EAAO,EAAM,UAAU,CAAK,GAC5B,EAAM,UAAU,CAAK,SAER;GAIX,AAHA,EAAM,QAAQ,GACd,EAAS,UAAU,MACnB,EAAO,GAAc,IAAI,GACzB,EAAO,EAAM,UAAU,IAAI;EAC7B;CACF,GAAG,CAAC,EAAM,OAAO,CAAC,GAElB,EAAM,gBAAgB;EACpB,EAAS,SAAS,OAAO;CAC3B,CAAC,GAEM,EAAM,cAAc,OAAO;EAChC,KAAK;EACL,WAAW,EAAM;EACjB,OAAO,EAAM,SAAS;GAAE,OAAO;GAAQ,QAAQ;EAAO;CACxD,CAAC;AACH,CAAC"}
@@ -15,6 +15,7 @@ export declare class ReglBackend implements GpuBackend {
15
15
  dispose(resource: GpuResource): void;
16
16
  clear(r: number, g: number, b: number, a: number): void;
17
17
  viewport(x: number, y: number, w: number, h: number): void;
18
+ getContext(): WebGL2RenderingContext;
18
19
  destroy(): void;
19
20
  private createDrawCommand;
20
21
  private resolveAttribute;
@@ -1 +1 @@
1
- {"version":3,"file":"ReglBackend.d.ts","sourceRoot":"","sources":["../../src/render/ReglBackend.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAA+B,MAAM,YAAY,CAAC;AA8BpI,qBAAa,WAAY,YAAW,UAAU;IAC5C,OAAO,CAAC,EAAE,CAAyB;IACnC,OAAO,CAAC,IAAI,CAAO;IACnB,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,aAAa,CAAa;IAClC,OAAO,CAAC,YAAY,CAAuC;IAC3D,OAAO,CAAC,UAAU,CAA+D;IACjF,QAAQ,CAAC,YAAY,EAAE,UAAU,CAAC,cAAc,CAAC,CAAC;gBAEtC,MAAM,EAAE,iBAAiB;IAiCrC,YAAY,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS;IASzC,YAAY,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY,GAAG,WAAW,EAAE,MAAM,GAAE,MAAU,GAAG,IAAI;IAS3F,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU;IAQrD,IAAI,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI;IAuC1B,OAAO,CAAC,QAAQ,EAAE,WAAW,GAAG,IAAI;IAMpC,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI;IAIvD,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM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CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI;IAS1D,UAAU,IAAI,sBAAsB;IAIpC,OAAO,IAAI,IAAI;IAKf,OAAO,CAAC,iBAAiB;IAkCzB,OAAO,CAAC,gBAAgB;IAcxB,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,eAAe;CAUxB"}
@@ -25,6 +25,7 @@ export declare class Renderer {
25
25
  updateFloatBuffer(buffer: GpuBuffer, data: Float32Array, floatCount?: number): void;
26
26
  viewport(x: number, y: number, width: number, height: number): void;
27
27
  setXOrigin(origin: number): void;
28
+ getWebGLContext(): WebGL2RenderingContext | null;
28
29
  drawLines(positions: GpuBuffer, count: number, style: SeriesStyle, camera: Camera2D): void;
29
30
  drawLineStrip(positions: GpuBuffer, count: number, style: SeriesStyle, camera: Camera2D): void;
30
31
  drawClipLineStrip(positions: GpuBuffer, count: number, style: SeriesStyle): void;
@@ -1 +1 @@
1
- {"version":3,"file":"Renderer.d.ts","sourceRoot":"","sources":["../../src/render/Renderer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,KAAK,EAAiB,UAAU,EAAE,SAAS,EAAc,MAAM,YAAY,CAAC;AACnF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AASpD,qBAAa,QAAQ;IAeP,OAAO,CAAC,OAAO;IAd3B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAa;IACzC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAa;IAC5C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAa;IAC1C,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAa;IAChD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IACxC,OAAO,CAAC,QA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AS,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,GAAG,IAAI;IAgB9F,iBAAiB,CACf,cAAc,EAAE,SAAS,EACzB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,QAAQ,GACf,IAAI;IAuBP,sBAAsB,CACpB,cAAc,EAAE,SAAS,EACzB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,QAAQ,GACf,IAAI;IAwBP,gBAAgB,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,GAAG,IAAI;IAIvG,OAAO,CAAC,iBAAiB;IAgBzB,OAAO,CAAC,qBAAqB;IAgB7B,OAAO,CAAC,iBAAiB;IAmBzB,OAAO,CAAC,mBAAmB;IAS3B,OAAO,IAAI,IAAI;CAGhB"}
@@ -9,6 +9,7 @@ export interface GpuBackend {
9
9
  dispose(resource: GpuResource): void;
10
10
  clear(r: number, g: number, b: number, a: number): void;
11
11
  viewport(x: number, y: number, w: number, h: number): void;
12
+ getContext?(): WebGL2RenderingContext | null;
12
13
  destroy(): void;
13
14
  }
14
15
  export interface GpuCapabilities {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/render/types.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,cAAc,EAAE,OAAO,MAAM,CAAC;AAC5C,OAAO,CAAC,MAAM,eAAe,EAAE,OAAO,MAAM,CAAC;AAE7C,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,YAAY,EAAE,eAAe,CAAC;IACvC,YAAY,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS,CAAC;IAC1C,YAAY,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY,GAAG,WAAW,EAAE,MAAM,CAAC,EAAE,MAAM,G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AAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,QAAQ,GAAG,OAAO,GAAG,YAAY,GAAG,WAAW,GAAG,gBAAgB,CAAC;IACvF,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;IAC1D,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,aAAa,CAAC,CAAC,CAAC;IACzE,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC;CAC/B"}
@@ -0,0 +1,94 @@
1
+ import { ChartPlugin } from './Chart.js';
2
+ import { SeriesYAxis } from '../core/types.js';
3
+ export interface AnnotationLabelOptions {
4
+ readonly text: string;
5
+ readonly position?: "start" | "center" | "end" | "top" | "bottom" | "left" | "right";
6
+ readonly color?: string;
7
+ readonly font?: string;
8
+ readonly offsetX?: number;
9
+ readonly offsetY?: number;
10
+ }
11
+ export interface AnnotationBase {
12
+ readonly id?: string;
13
+ readonly visible?: boolean;
14
+ readonly yAxis?: SeriesYAxis;
15
+ readonly className?: string;
16
+ readonly label?: string | AnnotationLabelOptions;
17
+ }
18
+ export interface XLineAnnotation extends AnnotationBase {
19
+ readonly type: "x-line";
20
+ readonly x: number;
21
+ readonly color?: string;
22
+ readonly width?: number;
23
+ readonly dash?: string;
24
+ }
25
+ export interface YLineAnnotation extends AnnotationBase {
26
+ readonly type: "y-line";
27
+ readonly y: number;
28
+ readonly color?: string;
29
+ readonly width?: number;
30
+ readonly dash?: string;
31
+ }
32
+ export interface XRangeAnnotation extends AnnotationBase {
33
+ readonly type: "x-range";
34
+ readonly xMin: number;
35
+ readonly xMax: number;
36
+ readonly fillColor?: string;
37
+ readonly borderColor?: string;
38
+ readonly borderWidth?: number;
39
+ }
40
+ export interface YRangeAnnotation extends AnnotationBase {
41
+ readonly type: "y-range";
42
+ readonly yMin: number;
43
+ readonly yMax: number;
44
+ readonly fillColor?: string;
45
+ readonly borderColor?: string;
46
+ readonly borderWidth?: number;
47
+ }
48
+ export interface BoxAnnotation extends AnnotationBase {
49
+ readonly type: "box";
50
+ readonly xMin: number;
51
+ readonly xMax: number;
52
+ readonly yMin: number;
53
+ readonly yMax: number;
54
+ readonly fillColor?: string;
55
+ readonly borderColor?: string;
56
+ readonly borderWidth?: number;
57
+ }
58
+ export interface PointAnnotation extends AnnotationBase {
59
+ readonly type: "point";
60
+ readonly x: number;
61
+ readonly y: number;
62
+ readonly radius?: number;
63
+ readonly color?: string;
64
+ readonly strokeColor?: string;
65
+ readonly strokeWidth?: number;
66
+ readonly shape?: "circle" | "diamond" | "cross";
67
+ }
68
+ export interface LabelAnnotation extends AnnotationBase {
69
+ readonly type: "label";
70
+ readonly x: number;
71
+ readonly y: number;
72
+ readonly text: string;
73
+ readonly color?: string;
74
+ readonly font?: string;
75
+ readonly backgroundColor?: string;
76
+ }
77
+ export type Annotation = XLineAnnotation | YLineAnnotation | XRangeAnnotation | YRangeAnnotation | BoxAnnotation | PointAnnotation | LabelAnnotation;
78
+ export interface AnnotationsPluginOptions {
79
+ readonly annotations?: readonly Annotation[];
80
+ readonly className?: string;
81
+ readonly defaultColor?: string;
82
+ readonly defaultFillColor?: string;
83
+ readonly defaultFont?: string;
84
+ readonly zIndex?: number;
85
+ }
86
+ export interface AnnotationsPlugin extends ChartPlugin {
87
+ add(annotation: Annotation): void;
88
+ remove(id: string): boolean;
89
+ clear(): void;
90
+ setAnnotations(annotations: readonly Annotation[]): void;
91
+ getAnnotations(): readonly Annotation[];
92
+ }
93
+ export declare function annotationsPlugin(options?: AnnotationsPluginOptions): AnnotationsPlugin;
94
+ //# sourceMappingURL=Annotations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Annotations.d.ts","sourceRoot":"","sources":["../../src/ui/Annotations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,WAAW,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;IACrF,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,sBAAsB,CAAC;CAClD;AAED,MAAM,WAAW,eAAgB,SAAQ,cAAc;IACrD,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,KAAK,CAAC,EAAE,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