velo-plot 3.1.0 → 4.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/dist/{ChartCore-AnR_3Xkb.js → ChartCore-KYG2HTcK.js} +1349 -1213
  2. package/dist/ChartCore-KYG2HTcK.js.map +1 -0
  3. package/dist/{PluginRegistry-CzMHebYP.js → PluginRegistry-CDf_jcnp.js} +2 -2
  4. package/dist/{PluginRegistry-CzMHebYP.js.map → PluginRegistry-CDf_jcnp.js.map} +1 -1
  5. package/dist/SVGDocumentBuilder-C-uLkcFW.js +83 -0
  6. package/dist/SVGDocumentBuilder-C-uLkcFW.js.map +1 -0
  7. package/dist/angular-hooks.js +1 -1
  8. package/dist/angular.js +4 -4
  9. package/dist/{chartSyncBridge-D_rCtbFq.js → chartSyncBridge-C1uRy0ZS.js} +3 -3
  10. package/dist/{chartSyncBridge-D_rCtbFq.js.map → chartSyncBridge-C1uRy0ZS.js.map} +1 -1
  11. package/dist/core/chart/ChartCore.d.ts +7 -3
  12. package/dist/core/chart/ChartRenderLoop.d.ts +5 -0
  13. package/dist/core/chart/ChartRenderer.d.ts +9 -0
  14. package/dist/core/chart/ChartSetup.d.ts +1 -0
  15. package/dist/core/chart/exporter/SVGExporter.d.ts +9 -7
  16. package/dist/core/chart/exporter/svg/SVGDocumentBuilder.d.ts +27 -0
  17. package/dist/core/chart/exporter/svg/SVGExportContext.d.ts +147 -0
  18. package/dist/core/chart/exporter/svg/SVGOrchestrator.d.ts +3 -0
  19. package/dist/core/chart/exporter/svg/SVGThemeAdapter.d.ts +22 -0
  20. package/dist/core/chart/exporter/svg/__tests__/testFixtures.d.ts +46 -0
  21. package/dist/core/chart/exporter/svg/__tests__/visualTestUtils.d.ts +12 -0
  22. package/dist/core/chart/exporter/svg/overlay/axes.d.ts +4 -0
  23. package/dist/core/chart/exporter/svg/overlay/border.d.ts +4 -0
  24. package/dist/core/chart/exporter/svg/overlay/errorBars.d.ts +7 -0
  25. package/dist/core/chart/exporter/svg/overlay/grid.d.ts +4 -0
  26. package/dist/core/chart/exporter/svg/overlay/index.d.ts +12 -0
  27. package/dist/core/chart/exporter/svg/overlay/legend.d.ts +4 -0
  28. package/dist/core/chart/exporter/svg/overlay/pluginCharts.d.ts +6 -0
  29. package/dist/core/chart/exporter/svg/overlay/polarGrid.d.ts +4 -0
  30. package/dist/core/chart/exporter/svg/overlay/specialChart.d.ts +15 -0
  31. package/dist/core/chart/exporter/svg/overlay/title.d.ts +4 -0
  32. package/dist/core/chart/exporter/svg/plugins/annotations.d.ts +5 -0
  33. package/dist/core/chart/exporter/svg/plugins/brokenAxis.d.ts +20 -0
  34. package/dist/core/chart/exporter/svg/plugins/latex.d.ts +9 -0
  35. package/dist/core/chart/exporter/svg/plugins/register.d.ts +8 -0
  36. package/dist/core/chart/exporter/svg/plugins/regression.d.ts +33 -0
  37. package/dist/core/chart/exporter/svg/plugins/roi.d.ts +12 -0
  38. package/dist/core/chart/exporter/svg/plugins/tradeMarkers.d.ts +3 -0
  39. package/dist/core/chart/exporter/svg/plugins/types.d.ts +28 -0
  40. package/dist/core/chart/exporter/svg/plugins/watermark.d.ts +13 -0
  41. package/dist/core/chart/exporter/svg/series/band.d.ts +6 -0
  42. package/dist/core/chart/exporter/svg/series/bar.d.ts +6 -0
  43. package/dist/core/chart/exporter/svg/series/boxplot.d.ts +6 -0
  44. package/dist/core/chart/exporter/svg/series/candlestick.d.ts +6 -0
  45. package/dist/core/chart/exporter/svg/series/finitePoints.d.ts +6 -0
  46. package/dist/core/chart/exporter/svg/series/gauge.d.ts +5 -0
  47. package/dist/core/chart/exporter/svg/series/heatmap.d.ts +6 -0
  48. package/dist/core/chart/exporter/svg/series/indicator.d.ts +6 -0
  49. package/dist/core/chart/exporter/svg/series/line.d.ts +12 -0
  50. package/dist/core/chart/exporter/svg/series/polar.d.ts +6 -0
  51. package/dist/core/chart/exporter/svg/series/radar.d.ts +5 -0
  52. package/dist/core/chart/exporter/svg/series/registry.d.ts +10 -0
  53. package/dist/core/chart/exporter/svg/series/sankey.d.ts +5 -0
  54. package/dist/core/chart/exporter/svg/series/scatter.d.ts +1 -0
  55. package/dist/core/chart/exporter/svg/series/ternary.d.ts +7 -0
  56. package/dist/core/chart/exporter/svg/series/waterfall.d.ts +6 -0
  57. package/dist/core/chart/exporter/svg/seriesAtTimestamp.d.ts +4 -0
  58. package/dist/core/chart/exporter/svg/seriesUtils.d.ts +3 -0
  59. package/dist/core/chart/exporter/svg/symbols.d.ts +5 -0
  60. package/dist/core/chart/exporter/svg/tickUtils.d.ts +9 -0
  61. package/dist/core/chart/mountSVGString.d.ts +5 -0
  62. package/dist/core/chart/types.d.ts +2 -2
  63. package/dist/core/stacked/StackSVGComposer.d.ts +14 -0
  64. package/dist/core/stacked/index.d.ts +3 -2
  65. package/dist/core/stacked/types.d.ts +12 -4
  66. package/dist/createStackedChart-DjA3aJAu.js +2761 -0
  67. package/dist/createStackedChart-DjA3aJAu.js.map +1 -0
  68. package/dist/{hooks-DH-3bewj.js → hooks-4wQH27r9.js} +3 -3
  69. package/dist/{hooks-DH-3bewj.js.map → hooks-4wQH27r9.js.map} +1 -1
  70. package/dist/index-Bj-xyXY6.js +582 -0
  71. package/dist/index-Bj-xyXY6.js.map +1 -0
  72. package/dist/plugins/PluginManager.d.ts +5 -0
  73. package/dist/plugins/annotations.js +8 -7
  74. package/dist/plugins/annotations.js.map +1 -1
  75. package/dist/plugins/broken-axis.js +198 -152
  76. package/dist/plugins/broken-axis.js.map +1 -1
  77. package/dist/plugins/forecasting.js +273 -258
  78. package/dist/plugins/forecasting.js.map +1 -1
  79. package/dist/plugins/ml-integration.js +107 -93
  80. package/dist/plugins/ml-integration.js.map +1 -1
  81. package/dist/plugins/radar/types.d.ts +11 -0
  82. package/dist/plugins/radar.js +64 -53
  83. package/dist/plugins/radar.js.map +1 -1
  84. package/dist/plugins/roi/index.d.ts +2 -0
  85. package/dist/plugins/roi.js +184 -145
  86. package/dist/plugins/roi.js.map +1 -1
  87. package/dist/plugins/snapshot.js +20 -15
  88. package/dist/plugins/snapshot.js.map +1 -1
  89. package/dist/plugins/types.d.ts +4 -0
  90. package/dist/react.js +2 -2
  91. package/dist/regression-HNdyk1Dm.js +28 -0
  92. package/dist/regression-HNdyk1Dm.js.map +1 -0
  93. package/dist/renderer/ChartSeriesRenderer.d.ts +3 -2
  94. package/dist/renderer/SVGChartRenderer.d.ts +15 -0
  95. package/dist/renderer/SankeyRenderer.d.ts +1 -0
  96. package/dist/renderer/registerSVG.d.ts +5 -0
  97. package/dist/renderer/sankeyLayout.d.ts +29 -0
  98. package/dist/scientific.js +2 -2
  99. package/dist/solid.js +2 -2
  100. package/dist/svelte.js +2 -2
  101. package/dist/tickUtils-B_X-ha13.js +41 -0
  102. package/dist/tickUtils-B_X-ha13.js.map +1 -0
  103. package/dist/trading.js +3 -3
  104. package/dist/types.d.ts +2 -1
  105. package/dist/velo-plot.full.js +1107 -1292
  106. package/dist/velo-plot.full.js.map +1 -1
  107. package/dist/velo-plot.js +2 -2
  108. package/dist/vue/VeloPlot.vue.d.ts +1 -1
  109. package/dist/vue/index.d.ts +33 -33
  110. package/dist/vue.js +2 -2
  111. package/package.json +6 -1
  112. package/dist/ChartCore-AnR_3Xkb.js.map +0 -1
  113. package/dist/createStackedChart-DqcLCFGS.js +0 -1338
  114. package/dist/createStackedChart-DqcLCFGS.js.map +0 -1
  115. package/dist/index-Cv6ZDLWf.js +0 -521
  116. package/dist/index-Cv6ZDLWf.js.map +0 -1
@@ -0,0 +1,2761 @@
1
+ import { S as Ne, a2 as qe, a3 as Ue, y as wt, a4 as xe, j as Ze, k as Qe, U as we, a5 as mt, c as re, a6 as Ke } from "./ChartCore-KYG2HTcK.js";
2
+ import { c as Je } from "./index-CaXWSOTk.js";
3
+ import { f as i, e as N, S as to } from "./SVGDocumentBuilder-C-uLkcFW.js";
4
+ import { p as Pt, r as eo, g as ae, a as oo, b as ve } from "./tickUtils-B_X-ha13.js";
5
+ import { g as no, h as io } from "./axisFormat-Sz4WIJfQ.js";
6
+ import { f as so, m as ro, e as ao, s as co, r as lo, a as ho } from "./indicators--eJGmVox.js";
7
+ import { n as fo, W as uo } from "./pool-DZ8shSqv.js";
8
+ function ri(t, o, e) {
9
+ const n = Math.min(t.length, o.length), s = new Float32Array(n * 6 * 2), r = e * 0.5;
10
+ for (let c = 0; c < n; c++) {
11
+ const a = t[c], l = o[c], h = c * 12, d = a - r, f = a + r, g = 0, u = l;
12
+ s[h + 0] = d, s[h + 1] = g, s[h + 2] = f, s[h + 3] = g, s[h + 4] = d, s[h + 5] = u, s[h + 6] = d, s[h + 7] = u, s[h + 8] = f, s[h + 9] = g, s[h + 10] = f, s[h + 11] = u;
13
+ }
14
+ return s;
15
+ }
16
+ function yo(t) {
17
+ if (t.length < 2) return 1;
18
+ let o = 1 / 0;
19
+ for (let e = 1; e < t.length; e++) {
20
+ const n = Math.abs(t[e] - t[e - 1]);
21
+ n > 0 && n < o && (o = n);
22
+ }
23
+ return o === 1 / 0 ? 1 : o * 0.8;
24
+ }
25
+ function go(t, o, e) {
26
+ const { nodes: n, links: s } = t, {
27
+ nodeWidth: r = 18,
28
+ nodePadding: c = 12,
29
+ palette: a = ["#6366f1", "#10b981", "#3b82f6", "#f43f5e", "#f59e0b"],
30
+ linkOpacity: l = 0.4,
31
+ showLabels: h = !0
32
+ } = o;
33
+ if (!s.length) return null;
34
+ const d = 1.8, f = e.width / d, g = e.height / d, u = (e.width - f) / 2, y = (e.height - g) / 2, p = {
35
+ x: e.x + u,
36
+ y: e.y + y,
37
+ width: f,
38
+ height: g
39
+ }, $ = /* @__PURE__ */ new Set();
40
+ s.forEach((P) => {
41
+ $.add(P.source), $.add(P.target);
42
+ });
43
+ const m = Array.from($), w = /* @__PURE__ */ new Map(), v = new Set(s.map((P) => P.target));
44
+ m.filter((P) => !v.has(P)).forEach((P) => w.set(P, 0));
45
+ let k = !0;
46
+ for (; k; )
47
+ k = !1, s.forEach((P) => {
48
+ const O = w.get(P.source);
49
+ if (O !== void 0) {
50
+ const j = w.get(P.target), _ = O + 1;
51
+ (j === void 0 || _ > j) && (w.set(P.target, _), k = !0);
52
+ }
53
+ });
54
+ m.forEach((P) => {
55
+ w.get(P) === void 0 && w.set(P, 0);
56
+ });
57
+ const C = Math.max(...Array.from(w.values())), A = Array.from({ length: C + 1 }, () => []);
58
+ m.forEach((P) => A[w.get(P)].push(P));
59
+ const S = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Map();
60
+ s.forEach((P) => {
61
+ E.set(P.source, (E.get(P.source) || 0) + P.value), S.set(P.target, (S.get(P.target) || 0) + P.value);
62
+ });
63
+ const R = (P) => Math.max(S.get(P) || 0, E.get(P) || 0);
64
+ let D = 0;
65
+ A.forEach((P) => {
66
+ let O = 0;
67
+ P.forEach((j) => {
68
+ O += R(j);
69
+ }), O > D && (D = O);
70
+ });
71
+ const z = /* @__PURE__ */ new Map(), T = A.length, F = (p.width - r) / Math.max(1, T - 1);
72
+ A.forEach((P, O) => {
73
+ const j = p.x + O * F, _ = [];
74
+ let tt = 0;
75
+ P.forEach((Z) => {
76
+ const rt = R(Z), nt = D > 0 ? rt / D * (p.height * 0.9) : 20;
77
+ _.push(nt), tt += nt;
78
+ });
79
+ const et = (P.length - 1) * c, ot = tt + et;
80
+ let Q = p.y + (p.height - ot) / 2;
81
+ P.forEach((Z, rt) => {
82
+ const nt = _[rt];
83
+ let at = a[rt % a.length];
84
+ if (n.length > 0) {
85
+ const $t = n.find((Lt) => Lt.id === Z);
86
+ $t != null && $t.color && (at = $t.color);
87
+ }
88
+ z.set(Z, {
89
+ x: j,
90
+ y: Q,
91
+ width: r,
92
+ height: nt,
93
+ color: at,
94
+ value: R(Z)
95
+ }), Q += nt + c;
96
+ });
97
+ });
98
+ const Y = /* @__PURE__ */ new Map(), B = /* @__PURE__ */ new Map(), V = [];
99
+ return s.forEach((P) => {
100
+ const O = z.get(P.source), j = z.get(P.target);
101
+ if (!O || !j) return;
102
+ const _ = Y.get(P.source) || 0, tt = B.get(P.target) || 0, et = E.get(P.source) || 1, ot = S.get(P.target) || 1, Q = P.value / et * O.height, Z = P.value / ot * j.height;
103
+ V.push({
104
+ source: O,
105
+ target: j,
106
+ sourceOffset: _,
107
+ targetOffset: tt,
108
+ sourceTotal: et,
109
+ targetTotal: ot,
110
+ value: P.value,
111
+ link: P
112
+ }), Y.set(P.source, _ + Q), B.set(P.target, tt + Z);
113
+ }), {
114
+ workingArea: p,
115
+ nodeRegistry: z,
116
+ links: V,
117
+ nodeInValue: S,
118
+ nodeOutValue: E,
119
+ style: { nodeWidth: r, nodePadding: c, palette: a, linkOpacity: l, showLabels: h }
120
+ };
121
+ }
122
+ function po(t, o) {
123
+ let e = t.length;
124
+ for (let n = 0; n < t.length; n++)
125
+ if (t[n] > o) {
126
+ e = Math.max(1, n);
127
+ break;
128
+ }
129
+ return e;
130
+ }
131
+ function K(t, o) {
132
+ if (t)
133
+ return Float32Array.from(t.subarray(0, o));
134
+ }
135
+ function $o(t, o) {
136
+ return {
137
+ x: Float32Array.from(t.x.subarray(0, o)),
138
+ y: t.y ? Float32Array.from(t.y.subarray(0, o)) : new Float32Array(0),
139
+ yError: K(t.yError, o),
140
+ yErrorPlus: K(t.yErrorPlus, o),
141
+ yErrorMinus: K(t.yErrorMinus, o),
142
+ xError: K(t.xError, o),
143
+ xErrorPlus: K(t.xErrorPlus, o),
144
+ xErrorMinus: K(t.xErrorMinus, o),
145
+ y2: K(t.y2, o),
146
+ open: K(t.open, o),
147
+ high: K(t.high, o),
148
+ low: K(t.low, o),
149
+ close: K(t.close, o)
150
+ };
151
+ }
152
+ function mo(t, o) {
153
+ return t.map((e) => {
154
+ var r;
155
+ const n = e.getData();
156
+ if (!((r = n.x) != null && r.length)) return e;
157
+ const s = po(n.x, o);
158
+ return s >= n.x.length ? e : new Ne({
159
+ id: e.getId(),
160
+ type: e.getType(),
161
+ name: e.getName(),
162
+ yAxisId: e.getYAxisId(),
163
+ style: e.getStyle(),
164
+ visible: e.isVisible(),
165
+ data: $o(n, s),
166
+ markers: e.getMarkers()
167
+ });
168
+ });
169
+ }
170
+ function xo(t, o, e, n) {
171
+ const s = [];
172
+ let r = 0, c = 0;
173
+ const a = 65, l = Array.from(o.keys()), h = n && l.includes(n) ? [n, ...l.filter((d) => d !== n)] : l;
174
+ for (const d of h) {
175
+ const f = o.get(d);
176
+ if (!f) continue;
177
+ const g = e.get(d), u = (g == null ? void 0 : g.position) === "right" ? "right" : "left", y = u === "left" ? r : c;
178
+ s.push({ id: d, scale: f, options: g, position: u, offset: y }), u === "left" ? r += a : c += a;
179
+ }
180
+ return s;
181
+ }
182
+ function wo(t) {
183
+ if (t.getAlerts)
184
+ try {
185
+ return t.getAlerts();
186
+ } catch {
187
+ return [];
188
+ }
189
+ }
190
+ function vo(t) {
191
+ const o = t.yAxisOptionsMap ?? /* @__PURE__ */ new Map(), e = t.options ?? {}, n = t.yAxes;
192
+ if (n.size === 0)
193
+ throw new Error("SVG export requires at least one Y scale");
194
+ return {
195
+ series: t.series,
196
+ viewBounds: t.viewBounds,
197
+ plotArea: t.plotArea,
198
+ xScale: t.xScale,
199
+ yAxes: n,
200
+ yAxisLayouts: xo(
201
+ t.plotArea,
202
+ n,
203
+ o,
204
+ e.primaryYAxisId ?? t.primaryYAxisId
205
+ ),
206
+ theme: t.theme,
207
+ width: t.width,
208
+ height: t.height,
209
+ xAxisOptions: t.xAxisOptions ?? e.xAxis,
210
+ yAxisOptionsMap: o,
211
+ primaryYAxisId: e.primaryYAxisId ?? t.primaryYAxisId,
212
+ titleOptions: t.titleOptions,
213
+ layout: t.layout ?? {},
214
+ businessDayMapping: t.businessDayMapping,
215
+ showLegend: t.showLegend ?? !1,
216
+ legendSeries: t.series.filter((s) => s.isVisible()),
217
+ cursor: t.cursor,
218
+ selection: t.selection,
219
+ alerts: t.alerts,
220
+ options: e,
221
+ pluginContexts: t.pluginContexts ?? [],
222
+ pluginManager: t.pluginManager
223
+ };
224
+ }
225
+ function bo(t, o = {}) {
226
+ var c, a, l, h, d, f, g;
227
+ const e = t.container.getBoundingClientRect();
228
+ let n = t.getAllSeries();
229
+ const s = ((c = t.getHoveredSeriesId) == null ? void 0 : c.call(t)) ?? null;
230
+ n = qe(n, s, (u) => u.getId()), o.at != null && Number.isFinite(o.at) && (n = mo(n, o.at));
231
+ const r = t.getPlotArea();
232
+ return Ue(
233
+ r,
234
+ t.viewBounds,
235
+ t.xScale,
236
+ t.yScales,
237
+ t.yAxisOptionsMap,
238
+ t.xAxisOptions,
239
+ t.primaryYAxisId,
240
+ ((a = t.getLayout) == null ? void 0 : a.call(t)) ?? {}
241
+ ), vo({
242
+ series: n,
243
+ viewBounds: t.viewBounds,
244
+ plotArea: r,
245
+ xScale: t.xScale,
246
+ yAxes: t.yScales,
247
+ theme: t.theme,
248
+ width: e.width || t.container.clientWidth,
249
+ height: e.height || t.container.clientHeight,
250
+ options: o,
251
+ xAxisOptions: t.xAxisOptions,
252
+ yAxisOptionsMap: t.yAxisOptionsMap,
253
+ primaryYAxisId: t.primaryYAxisId,
254
+ titleOptions: t.titleOptions ?? ((h = (l = t.getLayout) == null ? void 0 : l.call(t)) == null ? void 0 : h.title),
255
+ layout: (d = t.getLayout) == null ? void 0 : d.call(t),
256
+ businessDayMapping: ((f = t.getBusinessDayMapping) == null ? void 0 : f.call(t)) ?? null,
257
+ showLegend: t.showLegend ?? !1,
258
+ cursor: ((g = t.getCursorPosition) == null ? void 0 : g.call(t)) ?? null,
259
+ selection: t.selectionRect ?? null,
260
+ alerts: wo(t),
261
+ pluginManager: t.pluginManager
262
+ });
263
+ }
264
+ function be(t) {
265
+ if (!(!t || t.length === 0))
266
+ return t.join(",");
267
+ }
268
+ function ke(t) {
269
+ return {
270
+ stroke: t.grid.majorColor,
271
+ strokeWidth: t.grid.majorWidth,
272
+ strokeDasharray: be(t.grid.majorDash)
273
+ };
274
+ }
275
+ function ko(t) {
276
+ return {
277
+ stroke: t.grid.minorColor,
278
+ strokeWidth: t.grid.minorWidth,
279
+ strokeDasharray: be(t.grid.minorDash)
280
+ };
281
+ }
282
+ function Se(t, o) {
283
+ const e = o === "x" ? t.xAxis : t.yAxis;
284
+ return {
285
+ stroke: e.lineColor,
286
+ strokeWidth: e.lineWidth ?? 2
287
+ };
288
+ }
289
+ function Me(t, o) {
290
+ return {
291
+ stroke: (o === "x" ? t.xAxis : t.yAxis).tickColor,
292
+ strokeWidth: 1
293
+ };
294
+ }
295
+ function Ae(t, o) {
296
+ const e = o === "x" ? t.xAxis : t.yAxis;
297
+ return {
298
+ fill: e.labelColor,
299
+ fontSize: e.labelSize,
300
+ fontFamily: e.fontFamily || "sans-serif"
301
+ };
302
+ }
303
+ function pt(t) {
304
+ const o = [
305
+ `stroke="${t.stroke}"`,
306
+ `stroke-width="${t.strokeWidth}"`
307
+ ];
308
+ return t.strokeOpacity !== void 0 && o.push(`stroke-opacity="${t.strokeOpacity}"`), t.strokeDasharray && o.push(`stroke-dasharray="${t.strokeDasharray}"`), o.join(" ");
309
+ }
310
+ function bt(t, o, e) {
311
+ const n = [
312
+ `fill="${t.fill}"`,
313
+ `font-size="${t.fontSize}"`,
314
+ `font-family="${t.fontFamily}"`
315
+ ];
316
+ return t.fontWeight && n.push(`font-weight="${t.fontWeight}"`), o && n.push(`text-anchor="${o}"`), e && n.push(`dominant-baseline="${e}"`), n.join(" ");
317
+ }
318
+ function So(t, o) {
319
+ var f, g;
320
+ if (!t.theme.grid.visible) return;
321
+ const e = Pt(t.yAxes, t.primaryYAxisId);
322
+ if (!e) return;
323
+ const { plotArea: n, xScale: s, theme: r } = t, c = ((f = t.xAxisOptions) == null ? void 0 : f.tickCount) ?? 8, a = ((g = t.yAxisOptionsMap.get(t.primaryYAxisId ?? "default")) == null ? void 0 : g.tickCount) ?? 6, l = eo(s, c), h = e.ticks(a), d = pt(ke(r));
324
+ for (const u of l) {
325
+ const y = wt(s.transform(u));
326
+ y >= n.x && y <= n.x + n.width && o.push(
327
+ "grid",
328
+ `<line x1="${i(y)}" y1="${i(n.y)}" x2="${i(y)}" y2="${i(n.y + n.height)}" ${d}/>`
329
+ );
330
+ }
331
+ for (const u of h) {
332
+ const y = wt(e.transform(u));
333
+ y >= n.y && y <= n.y + n.height && o.push(
334
+ "grid",
335
+ `<line x1="${i(n.x)}" y1="${i(y)}" x2="${i(n.x + n.width)}" y2="${i(y)}" ${d}/>`
336
+ );
337
+ }
338
+ if (r.grid.showMinor) {
339
+ const u = pt(ko(r)), y = ae(l, r.grid.minorDivisions), p = ae(h, r.grid.minorDivisions);
340
+ for (const $ of y) {
341
+ const m = wt(s.transform($));
342
+ m >= n.x && m <= n.x + n.width && o.push(
343
+ "grid",
344
+ `<line x1="${i(m)}" y1="${i(n.y)}" x2="${i(m)}" y2="${i(n.y + n.height)}" ${u}/>`
345
+ );
346
+ }
347
+ for (const $ of p) {
348
+ const m = wt(e.transform($));
349
+ m >= n.y && m <= n.y + n.height && o.push(
350
+ "grid",
351
+ `<line x1="${i(n.x)}" y1="${i(m)}" x2="${i(n.x + n.width)}" y2="${i(m)}" ${u}/>`
352
+ );
353
+ }
354
+ }
355
+ }
356
+ function Mo(t, o) {
357
+ Ao(t, o);
358
+ for (const e of t.yAxisLayouts)
359
+ Co(t, o, e);
360
+ }
361
+ function Ao(t, o) {
362
+ var v;
363
+ const { plotArea: e, xScale: n, theme: s, xAxisOptions: r } = t;
364
+ if ((r == null ? void 0 : r.visible) === !1) return;
365
+ const c = s.xAxis, a = (r == null ? void 0 : r.tickCount) ?? 8, l = oo(n, a, t.businessDayMapping), h = wt(e.y + e.height), d = (r == null ? void 0 : r.showLine) !== !1, f = (r == null ? void 0 : r.showTicks) !== !1, g = (r == null ? void 0 : r.showLabels) !== !1, u = n.domain[1] - n.domain[0];
366
+ d && o.push(
367
+ "axes",
368
+ `<line x1="${i(e.x)}" y1="${i(h)}" x2="${i(e.x + e.width)}" y2="${i(h)}" ${pt(Se(s, "x"))}/>`
369
+ );
370
+ const y = Ae(s, "x"), p = pt(Me(s, "x")), $ = [];
371
+ for (const b of l) {
372
+ const k = xe(n.transform(b));
373
+ if (k >= e.x && k <= e.x + e.width) {
374
+ const C = g ? no(b, r, u, t.businessDayMapping ?? void 0) : "";
375
+ (!g || C) && $.push({ x: k, label: C });
376
+ }
377
+ }
378
+ let m = !1;
379
+ if (g && $.length > 1) {
380
+ const k = Math.max(...$.map((A) => A.label.length)) * c.labelSize * 0.6;
381
+ let C = 1 / 0;
382
+ for (let A = 1; A < $.length; A++)
383
+ C = Math.min(C, $[A].x - $[A - 1].x);
384
+ m = k + 8 > C;
385
+ }
386
+ for (const b of $)
387
+ if (f && o.push(
388
+ "axes",
389
+ `<line x1="${i(b.x)}" y1="${i(h)}" x2="${i(b.x)}" y2="${i(h + c.tickLength)}" ${p}/>`
390
+ ), g && b.label) {
391
+ const k = h + c.tickLength + (m ? 6 : 3) + c.labelSize * 0.75;
392
+ m ? o.push(
393
+ "axes",
394
+ `<text x="${i(b.x)}" y="${i(k)}" ${bt(y, "end", "auto")} transform="rotate(-45 ${i(b.x)} ${i(k)})">${N(b.label)}</text>`
395
+ ) : o.push(
396
+ "axes",
397
+ `<text x="${i(b.x)}" y="${i(k)}" ${bt(y, "middle")}>${N(b.label)}</text>`
398
+ );
399
+ }
400
+ const w = r == null ? void 0 : r.label;
401
+ if (w) {
402
+ const b = e.y + e.height + (((v = t.layout.xAxisLayout) == null ? void 0 : v.titleGap) ?? 45);
403
+ o.push(
404
+ "axes",
405
+ `<text x="${i(e.x + e.width / 2)}" y="${i(b)}" ${bt({ ...y, fill: c.titleColor, fontSize: c.titleSize }, "middle")}>${N(w)}</text>`
406
+ );
407
+ }
408
+ }
409
+ function Co(t, o, e) {
410
+ var b;
411
+ const { plotArea: n, theme: s } = t, { scale: r, options: c, position: a, offset: l } = e;
412
+ if ((c == null ? void 0 : c.visible) === !1) return;
413
+ const h = s.yAxis, d = (c == null ? void 0 : c.tickCount) ?? 6, f = r.ticks(d), g = (c == null ? void 0 : c.showLine) !== !1, u = (c == null ? void 0 : c.showTicks) !== !1, y = (c == null ? void 0 : c.showLabels) !== !1, p = wt(
414
+ a === "left" ? n.x - l : n.x + n.width + l
415
+ ), $ = a === "left" ? -1 : 1;
416
+ g && o.push(
417
+ "axes",
418
+ `<line x1="${i(p)}" y1="${i(n.y)}" x2="${i(p)}" y2="${i(n.y + n.height)}" ${pt(Se(s, "y"))}/>`
419
+ );
420
+ const m = Ae(s, "y"), w = pt(Me(s, "y"));
421
+ for (const k of f) {
422
+ const C = xe(r.transform(k));
423
+ if (!(C < n.y || C > n.y + n.height) && (u && o.push(
424
+ "axes",
425
+ `<line x1="${i(p)}" y1="${i(C)}" x2="${i(p + h.tickLength * $)}" y2="${i(C)}" ${w}/>`
426
+ ), y)) {
427
+ const A = p + (h.tickLength + 3) * $, S = a === "left" ? "end" : "start";
428
+ o.push(
429
+ "axes",
430
+ `<text x="${i(A)}" y="${i(C + h.labelSize * 0.35)}" ${bt(m, S)}>${N(io(k, c))}</text>`
431
+ );
432
+ }
433
+ }
434
+ const v = c == null ? void 0 : c.label;
435
+ if (v) {
436
+ const k = ((b = t.layout.yAxisLayout) == null ? void 0 : b.titleGap) ?? 50, C = a === "left" ? p - k : p + k, A = n.y + n.height / 2, S = a === "left" ? -90 : 90;
437
+ o.push(
438
+ "axes",
439
+ `<text x="${i(C)}" y="${i(A)}" ${bt({ ...m, fill: h.titleColor, fontSize: h.titleSize }, "middle")} transform="rotate(${S} ${i(C)} ${i(A)})">${N(v)}</text>`
440
+ );
441
+ }
442
+ }
443
+ function Po(t, o) {
444
+ var p, $;
445
+ const e = t.titleOptions;
446
+ if (!(e != null && e.visible) || !e.text) return;
447
+ const { plotArea: n } = t, s = e.fontSize ?? 16, r = e.fontFamily ?? "Inter, system-ui, sans-serif", c = e.fontWeight ?? 600, a = e.color ?? "#ffffff", l = e.align ?? "center";
448
+ let h;
449
+ l === "left" ? h = n.x : l === "right" ? h = n.x + n.width : h = n.x + n.width / 2;
450
+ const d = typeof e.padding == "number" ? e.padding : 10, f = ((p = e.padding) == null ? void 0 : p.top) ?? d, g = (($ = e.padding) == null ? void 0 : $.bottom) ?? d, u = e.position === "bottom" ? n.y + n.height + g + s : n.y - f, y = l === "left" ? "start" : l === "right" ? "end" : "middle";
451
+ o.push(
452
+ "title",
453
+ `<text x="${i(h)}" y="${i(u)}" fill="${a}" font-size="${s}" font-family="${N(r)}" font-weight="${c}" text-anchor="${y}">${N(e.text)}</text>`
454
+ );
455
+ }
456
+ function Io(t, o) {
457
+ const { plotArea: e, theme: n } = t;
458
+ o.push(
459
+ "border",
460
+ `<rect x="${i(e.x)}" y="${i(e.y)}" width="${i(e.width)}" height="${i(e.height)}" fill="none" stroke="${n.plotBorderColor}" stroke-width="1"/>`
461
+ );
462
+ }
463
+ function It(t, o, e, n, s, r = 1, c) {
464
+ const a = n / 2, l = `fill="${s}" fill-opacity="${r}"`, h = "";
465
+ switch (t) {
466
+ case "square":
467
+ return `<rect x="${i(o - a)}" y="${i(e - a)}" width="${i(n)}" height="${i(n)}" ${l}${h}/>`;
468
+ case "diamond":
469
+ return `<polygon points="${i(o)},${i(e - a)} ${i(o + a)},${i(e)} ${i(o)},${i(e + a)} ${i(o - a)},${i(e)}" ${l}${h}/>`;
470
+ case "triangle":
471
+ return `<polygon points="${i(o)},${i(e - a)} ${i(o + a)},${i(e + a)} ${i(o - a)},${i(e + a)}" ${l}${h}/>`;
472
+ case "triangleDown":
473
+ return `<polygon points="${i(o)},${i(e + a)} ${i(o + a)},${i(e - a)} ${i(o - a)},${i(e - a)}" ${l}${h}/>`;
474
+ case "cross":
475
+ return `<g stroke="${s}" stroke-width="1" stroke-opacity="${r}"><line x1="${i(o - a)}" y1="${i(e)}" x2="${i(o + a)}" y2="${i(e)}"/><line x1="${i(o)}" y1="${i(e - a)}" x2="${i(o)}" y2="${i(e + a)}"/></g>`;
476
+ case "x": {
477
+ const d = a * 0.707;
478
+ return `<g stroke="${s}" stroke-width="1" stroke-opacity="${r}"><line x1="${i(o - d)}" y1="${i(e - d)}" x2="${i(o + d)}" y2="${i(e + d)}"/><line x1="${i(o + d)}" y1="${i(e - d)}" x2="${i(o - d)}" y2="${i(e + d)}"/></g>`;
479
+ }
480
+ case "star": {
481
+ const d = [];
482
+ for (let f = 0; f < 5; f++) {
483
+ const g = (18 + f * 72) / 180 * Math.PI, u = (54 + f * 72) / 180 * Math.PI;
484
+ d.push(`${i(o + a * Math.cos(g))},${i(e - a * Math.sin(g))}`), d.push(`${i(o + a * 0.4 * Math.cos(u))},${i(e - a * 0.4 * Math.sin(u))}`);
485
+ }
486
+ return `<polygon points="${d.join(" ")}" ${l}${h}/>`;
487
+ }
488
+ case "circle":
489
+ default:
490
+ return `<circle cx="${i(o)}" cy="${i(e)}" r="${i(a)}" ${l}${h}/>`;
491
+ }
492
+ }
493
+ function Lo(t, o) {
494
+ if (t.options.includeLegend === !1 || !t.showLegend && t.options.includeLegend !== !0) return;
495
+ const e = t.theme.legend;
496
+ if (!(e != null && e.visible)) return;
497
+ const n = t.legendSeries;
498
+ if (n.length === 0) return;
499
+ const { plotArea: s } = t, r = 160, c = e.padding * 2 + n.length * (e.swatchSize + e.itemGap) - e.itemGap;
500
+ let a = s.x + s.width - r - 10, l = s.y + 10;
501
+ const h = e.position ?? "top-right";
502
+ h.includes("left") && (a = s.x + 10), h.includes("bottom") && (l = s.y + s.height - c - 10), o.push(
503
+ "legend",
504
+ `<rect x="${i(a)}" y="${i(l)}" width="${i(r)}" height="${i(c)}" fill="${e.backgroundColor}" fill-opacity="0.8" stroke="${e.borderColor ?? "transparent"}" rx="4"/>`
505
+ ), n.forEach((d, f) => {
506
+ const g = d.getStyle(), u = g.color ?? "#fff", y = g.opacity ?? 1, p = l + e.padding + f * (e.swatchSize + e.itemGap), $ = a + e.padding, m = p + e.swatchSize / 2, w = $ + e.swatchSize / 2, v = e.swatchSize, b = String(d.getType()).toLowerCase(), k = g.symbol ?? "circle";
507
+ b === "scatter" || b.includes("scatter") ? (o.push("legend", It(k, w, m, v * 0.9, u, y)), b.includes("+") && o.push(
508
+ "legend",
509
+ `<line x1="${i($)}" y1="${i(m)}" x2="${i($ + v)}" y2="${i(m)}" stroke="${u}" stroke-width="2" stroke-opacity="${y}"/>`
510
+ )) : o.push(
511
+ "legend",
512
+ `<line x1="${i($)}" y1="${i(m)}" x2="${i($ + v)}" y2="${i(m)}" stroke="${u}" stroke-width="2" stroke-opacity="${y}"/>`
513
+ ), o.push(
514
+ "legend",
515
+ `<text x="${i(a + e.padding + e.swatchSize + 8)}" y="${i(m + e.fontSize * 0.35)}" fill="${e.textColor}" font-size="${e.fontSize}" font-family="${e.fontFamily}">${N(d.getName())}</text>`
516
+ );
517
+ });
518
+ }
519
+ function J(t, o = "series") {
520
+ return typeof t.getId == "function" ? t.getId() : o;
521
+ }
522
+ function Do(t, o, e, n, s) {
523
+ if (typeof t.hasErrorData != "function" || !t.hasErrorData()) return;
524
+ const r = t.getData(), c = t.getStyle(), a = c.errorBars ?? {};
525
+ if (a.visible === !1) return;
526
+ const l = a.color ?? c.color ?? "#ff0055", h = a.width ?? 1, d = a.capWidth ?? 6, f = a.showCaps !== !1, g = a.opacity ?? 0.7, u = a.direction ?? "both", y = `vp-clip-eb-${J(t)}`;
527
+ s.registerClipPath(
528
+ y,
529
+ `<rect x="${i(o.x)}" y="${i(o.y)}" width="${i(o.width)}" height="${i(o.height)}"/>`
530
+ );
531
+ for (let p = 0; p < r.x.length; p++) {
532
+ const $ = e.transform(r.x[p]), m = n.transform(r.y[p]);
533
+ if ($ < o.x || $ > o.x + o.width || m < o.y || m > o.y + o.height) continue;
534
+ const w = t.getYError(p);
535
+ if (w) {
536
+ const [b, k] = w, C = r.y[p], A = n.transform(C + k), S = n.transform(C - b);
537
+ (u === "both" || u === "positive") && s.push(
538
+ "errorBars",
539
+ `<g clip-path="url(#${y})" stroke="${l}" stroke-width="${h}" stroke-opacity="${g}"><line x1="${i($)}" y1="${i(m)}" x2="${i($)}" y2="${i(A)}"/>${f ? `<line x1="${i($ - d / 2)}" y1="${i(A)}" x2="${i($ + d / 2)}" y2="${i(A)}"/>` : ""}</g>`
540
+ ), (u === "both" || u === "negative") && s.push(
541
+ "errorBars",
542
+ `<g clip-path="url(#${y})" stroke="${l}" stroke-width="${h}" stroke-opacity="${g}"><line x1="${i($)}" y1="${i(m)}" x2="${i($)}" y2="${i(S)}"/>${f ? `<line x1="${i($ - d / 2)}" y1="${i(S)}" x2="${i($ + d / 2)}" y2="${i(S)}"/>` : ""}</g>`
543
+ );
544
+ }
545
+ const v = t.getXError(p);
546
+ if (v) {
547
+ const [b, k] = v, C = r.x[p], A = e.transform(C + k), S = e.transform(C - b);
548
+ (u === "both" || u === "positive") && s.push(
549
+ "errorBars",
550
+ `<g clip-path="url(#${y})" stroke="${l}" stroke-width="${h}" stroke-opacity="${g}"><line x1="${i($)}" y1="${i(m)}" x2="${i(A)}" y2="${i(m)}"/>${f ? `<line x1="${i(A)}" y1="${i(m - d / 2)}" x2="${i(A)}" y2="${i(m + d / 2)}"/>` : ""}</g>`
551
+ ), (u === "both" || u === "negative") && s.push(
552
+ "errorBars",
553
+ `<g clip-path="url(#${y})" stroke="${l}" stroke-width="${h}" stroke-opacity="${g}"><line x1="${i($)}" y1="${i(m)}" x2="${i(S)}" y2="${i(m)}"/>${f ? `<line x1="${i(S)}" y1="${i(m - d / 2)}" x2="${i(S)}" y2="${i(m + d / 2)}"/>` : ""}</g>`
554
+ );
555
+ }
556
+ }
557
+ }
558
+ function zo(t, o) {
559
+ for (const e of t.series) {
560
+ if (!e.isVisible()) continue;
561
+ const n = ve(t.yAxes, e.getYAxisId(), t.primaryYAxisId);
562
+ n && Do(e, t.plotArea, t.xScale, n, o);
563
+ }
564
+ }
565
+ function Eo(t) {
566
+ var l;
567
+ let o = !1, e = !1, n = !1, s = 0, r = "degrees", c = 5, a = 12;
568
+ for (const h of t) {
569
+ if (!h.isVisible()) continue;
570
+ const d = h.getType();
571
+ if (d === "polar") {
572
+ o = !0;
573
+ const f = (l = h.getPolarData) == null ? void 0 : l.call(h);
574
+ if (f) {
575
+ for (let u = 0; u < f.r.length; u++)
576
+ s = Math.max(s, Math.abs(f.r[u]));
577
+ const g = h.getStyle();
578
+ g.angleMode && (r = g.angleMode), g.radialDivisions && (c = g.radialDivisions), g.angularDivisions && (a = g.angularDivisions);
579
+ }
580
+ } else d === "gauge" ? e = !0 : d === "sankey" && (n = !0);
581
+ }
582
+ return {
583
+ isSpecialChart: o || e || n,
584
+ hasPolarSeries: o,
585
+ hasGaugeSeries: e,
586
+ hasSankeySeries: n,
587
+ maxRadius: s,
588
+ polarAngleMode: r,
589
+ polarRadialDivisions: c,
590
+ polarAngularDivisions: a
591
+ };
592
+ }
593
+ function To(t) {
594
+ return Eo(t.series);
595
+ }
596
+ function Fo(t, o, e, n, s) {
597
+ if (!t.theme.grid.visible) return;
598
+ const r = Pt(t.yAxes, t.primaryYAxisId);
599
+ if (!r) return;
600
+ const { plotArea: c, xScale: a } = t, l = a.transform(0), h = r.transform(0), d = pt(ke(t.theme)), f = [
601
+ { x: c.x, y: c.y },
602
+ { x: c.x + c.width, y: c.y },
603
+ { x: c.x, y: c.y + c.height },
604
+ { x: c.x + c.width, y: c.y + c.height }
605
+ ];
606
+ let g = 0;
607
+ for (const p of f) {
608
+ const $ = Math.hypot(p.x - l, p.y - h);
609
+ g = Math.max(g, $);
610
+ }
611
+ const u = "vp-clip-polar-grid";
612
+ o.registerClipPath(
613
+ u,
614
+ `<rect x="${i(c.x)}" y="${i(c.y)}" width="${i(c.width)}" height="${i(c.height)}"/>`
615
+ );
616
+ for (let p = 1; p <= e; p++) {
617
+ const $ = p / e * g;
618
+ o.push(
619
+ "grid",
620
+ `<circle clip-path="url(#${u})" cx="${i(l)}" cy="${i(h)}" r="${i($)}" fill="none" ${d}/>`
621
+ );
622
+ }
623
+ const y = s === "degrees" ? 360 / n * (Math.PI / 180) : 2 * Math.PI / n;
624
+ for (let p = 0; p < n; p++) {
625
+ const $ = p * y;
626
+ o.push(
627
+ "grid",
628
+ `<line clip-path="url(#${u})" x1="${i(l)}" y1="${i(h)}" x2="${i(l + g * Math.cos($))}" y2="${i(h - g * Math.sin($))}" ${d}/>`
629
+ );
630
+ }
631
+ }
632
+ function Ro(t) {
633
+ var e, n, s;
634
+ const o = (e = t.pluginManager) == null ? void 0 : e.get("velo-plot-radar");
635
+ return ((s = (n = o == null ? void 0 : o.api) == null ? void 0 : n.getSVGExportData) == null ? void 0 : s.call(n)) ?? null;
636
+ }
637
+ function Bo(t) {
638
+ const o = Ro(t);
639
+ return o != null && o.categories.length > 0;
640
+ }
641
+ function Wo(t, o) {
642
+ var e;
643
+ if (o || Bo(t)) return !0;
644
+ if (((e = t.xAxisOptions) == null ? void 0 : e.visible) === !1) {
645
+ let n = !0;
646
+ if (t.yAxisOptionsMap.forEach((s) => {
647
+ s.visible !== !1 && (n = !1);
648
+ }), n) return !0;
649
+ }
650
+ return !1;
651
+ }
652
+ function Oo(t, o) {
653
+ var c;
654
+ if (!t.options.includeCursor || !t.cursor) return;
655
+ const { plotArea: e, cursor: n, theme: s } = t, r = ((c = s.cursor) == null ? void 0 : c.lineColor) ?? "rgba(255,255,255,0.5)";
656
+ o.push(
657
+ "cursor",
658
+ `<line x1="${i(n.x)}" y1="${i(e.y)}" x2="${i(n.x)}" y2="${i(e.y + e.height)}" stroke="${r}" stroke-width="1" stroke-dasharray="4,4"/>`
659
+ ), o.push(
660
+ "cursor",
661
+ `<line x1="${i(e.x)}" y1="${i(n.y)}" x2="${i(e.x + e.width)}" y2="${i(n.y)}" stroke="${r}" stroke-width="1" stroke-dasharray="4,4"/>`
662
+ );
663
+ }
664
+ function Ho(t, o) {
665
+ if (!t.options.includeSelection || !t.selection) return;
666
+ const { selection: e } = t;
667
+ o.push(
668
+ "cursor",
669
+ `<rect x="${i(e.x)}" y="${i(e.y)}" width="${i(e.width)}" height="${i(e.height)}" fill="rgba(100,149,237,0.15)" stroke="cornflowerblue" stroke-width="1"/>`
670
+ );
671
+ }
672
+ function Yo(t, o) {
673
+ var r;
674
+ if (!((r = t.alerts) != null && r.length)) return;
675
+ const { plotArea: e, alerts: n } = t, s = t.yAxes.get(t.primaryYAxisId ?? "default");
676
+ if (s)
677
+ for (const c of n) {
678
+ const a = s.transform(c.price);
679
+ if (a < e.y || a > e.y + e.height) continue;
680
+ const l = c.direction === "below" ? "#ef5350" : "#26a69a";
681
+ o.push(
682
+ "plugins",
683
+ `<line x1="${i(e.x)}" y1="${i(a)}" x2="${i(e.x + e.width)}" y2="${i(a)}" stroke="${l}" stroke-width="1" stroke-dasharray="6,4"/>`
684
+ );
685
+ }
686
+ }
687
+ function Xo(t, o) {
688
+ const e = To(t), n = Wo(t, e.isSpecialChart);
689
+ e.hasPolarSeries && e.maxRadius > 0 ? Fo(
690
+ t,
691
+ o,
692
+ e.polarRadialDivisions,
693
+ e.polarAngularDivisions,
694
+ e.polarAngleMode
695
+ ) : n || So(t, o), zo(t, o), n || Mo(t, o), Io(t, o), Po(t, o), Lo(t, o), Oo(t, o), Ho(t, o), Yo(t, o);
696
+ }
697
+ function Ce(t, o, e) {
698
+ const n = [];
699
+ for (let s = 0; s < t.length; s++)
700
+ !Number.isFinite(t[s]) || !Number.isFinite(o[s]) || e && !Number.isFinite(e[s]) || n.push(s);
701
+ return n;
702
+ }
703
+ function Go(t, o, e, n, s) {
704
+ const r = [];
705
+ let c = [], a = -2;
706
+ for (const l of t)
707
+ a >= 0 && l !== a + 1 && (c.length >= 2 && r.push(c), c = []), c.push(`${i(n.transform(o[l]))},${i(s.transform(e[l]))}`), a = l;
708
+ return c.length >= 2 && r.push(c), r;
709
+ }
710
+ function Vo(t, o, e, n) {
711
+ const s = [], r = n === "before" || n === "center" ? n : "after";
712
+ for (let c = 0; c < t.x.length; c++) {
713
+ const a = o.transform(t.x[c]), l = e.transform(t.y[c]);
714
+ if (c === 0) {
715
+ s.push(`${i(a)},${i(l)}`);
716
+ continue;
717
+ }
718
+ const h = o.transform(t.x[c - 1]), d = e.transform(t.y[c - 1]);
719
+ if (r === "after")
720
+ s.push(`${i(a)},${i(d)}`), s.push(`${i(a)},${i(l)}`);
721
+ else if (r === "before")
722
+ s.push(`${i(h)},${i(l)}`), s.push(`${i(a)},${i(l)}`);
723
+ else {
724
+ const f = (h + a) / 2;
725
+ s.push(`${i(f)},${i(d)}`), s.push(`${i(f)},${i(l)}`), s.push(`${i(a)},${i(l)}`);
726
+ }
727
+ }
728
+ return s;
729
+ }
730
+ function kt(t, o, e, n, s) {
731
+ const r = t.getData();
732
+ if (!r || r.x.length === 0) return;
733
+ const c = t.getStyle(), a = t.getType(), l = c.color ?? "#ff0055", h = c.width ?? 1.5, d = c.opacity ?? 1, f = c.dash, g = `vp-clip-${J(t)}`;
734
+ s.registerClipPath(
735
+ g,
736
+ `<rect x="${i(o.x)}" y="${i(o.y)}" width="${i(o.width)}" height="${i(o.height)}"/>`
737
+ );
738
+ const u = f != null && f.length ? ` stroke-dasharray="${f.join(",")}"` : "", p = a === "step" || a === "step+scatter" ? "miter" : "round";
739
+ if (a === "step" || a === "step+scatter") {
740
+ const $ = Vo(r, e, n, c.stepMode || "after");
741
+ $.length >= 2 && s.push(
742
+ "series",
743
+ `<polyline clip-path="url(#${g})" points="${$.join(" ")}" fill="none" stroke="${l}" stroke-width="${h}" stroke-opacity="${d}" stroke-linejoin="${p}"${u}/>`
744
+ );
745
+ } else {
746
+ const $ = Go(
747
+ Ce(r.x, r.y),
748
+ r.x,
749
+ r.y,
750
+ e,
751
+ n
752
+ );
753
+ for (const m of $)
754
+ s.push(
755
+ "series",
756
+ `<polyline clip-path="url(#${g})" points="${m.join(" ")}" fill="none" stroke="${l}" stroke-width="${h}" stroke-opacity="${d}" stroke-linejoin="${p}"${u}/>`
757
+ );
758
+ }
759
+ (a === "line+scatter" || a === "step+scatter") && Pe(t, o, e, n, s, !0);
760
+ }
761
+ function Pe(t, o, e, n, s, r = !1) {
762
+ !r && t.getType();
763
+ const c = t.getData();
764
+ if (!c || c.x.length === 0) return;
765
+ const a = t.getStyle(), l = a.color ?? "#ff0055", h = a.opacity ?? 1, d = a.pointSize ?? 4, f = a.symbol ?? "circle";
766
+ for (let g = 0; g < c.x.length; g++) {
767
+ const u = e.transform(c.x[g]), y = n.transform(c.y[g]);
768
+ s.push("series", It(f, u, y, d, l, h));
769
+ }
770
+ }
771
+ function Ie(t, o, e, n, s) {
772
+ Pe(t, o, e, n, s);
773
+ }
774
+ function Le(t, o, e, n, s) {
775
+ const r = t.getData();
776
+ if (!r || r.x.length === 0) return;
777
+ const c = t.getStyle(), a = c.color ?? "#ff0055", l = c.opacity ?? 1, h = e.domain[1] - e.domain[0], d = c.barWidth ?? yo(r.x), f = h > 0 ? d / h * o.width : c.barWidth || 5, g = c.baseline ?? 0, u = n.transform(g), y = `vp-clip-bar-${J(t)}`;
778
+ s.registerClipPath(
779
+ y,
780
+ `<rect x="${i(o.x)}" y="${i(o.y)}" width="${i(o.width)}" height="${i(o.height)}"/>`
781
+ );
782
+ for (let p = 0; p < r.x.length; p++) {
783
+ const $ = e.transform(r.x[p]), m = n.transform(r.y[p]), w = Math.min(m, u), v = Math.max(1, Math.abs(m - u));
784
+ s.push(
785
+ "series",
786
+ `<rect clip-path="url(#${y})" x="${i($ - f / 2)}" y="${i(w)}" width="${i(f)}" height="${i(v)}" fill="${a}" fill-opacity="${l}"/>`
787
+ );
788
+ }
789
+ }
790
+ function Ft(t, o, e, n, s) {
791
+ const r = t.getData();
792
+ if (!r || r.x.length === 0) return;
793
+ const c = t.getStyle(), a = t.getType(), l = c.color ?? "#ff0055", h = c.opacity ?? 1, d = c.width ?? 1, f = c.fillOpacity ?? h * 0.3, g = a === "area" ? new Float32Array(r.x.length).fill(c.baseline ?? 0) : r.y2 ?? new Float32Array(r.x.length).fill(0), u = Ce(r.x, r.y, g);
794
+ if (u.length < 2) return;
795
+ const y = [];
796
+ for (const m of u)
797
+ y.push(`${i(e.transform(r.x[m]))},${i(n.transform(r.y[m]))}`);
798
+ for (let m = u.length - 1; m >= 0; m--) {
799
+ const w = u[m];
800
+ y.push(`${i(e.transform(r.x[w]))},${i(n.transform(g[w]))}`);
801
+ }
802
+ const p = `vp-clip-band-${J(t)}`;
803
+ s.registerClipPath(
804
+ p,
805
+ `<rect x="${i(o.x)}" y="${i(o.y)}" width="${i(o.width)}" height="${i(o.height)}"/>`
806
+ );
807
+ let $ = `fill="${l}" fill-opacity="${f}"`;
808
+ c.gradient && ($ = `fill="url(#${s.registerLinearGradient(0, 0, 0, 1, [
809
+ { offset: "0%", color: l, opacity: f },
810
+ { offset: "100%", color: l, opacity: 0 }
811
+ ])})"`), s.push(
812
+ "series",
813
+ `<polygon clip-path="url(#${p})" points="${y.join(" ")}" ${$} stroke="${l}" stroke-width="${d}" stroke-opacity="${h}"/>`
814
+ );
815
+ }
816
+ function De(t, o, e, n, s) {
817
+ const r = t.getData();
818
+ if (!(r != null && r.open) || !r.high || !r.low || !r.close || r.x.length === 0) return;
819
+ const c = t.getStyle(), a = e.domain[1] - e.domain[0], l = c.barWidth ?? 0.8, h = a > 0 ? l / a * o.width : c.barWidth || 5, d = c.bullishColor || "#26a69a", f = c.bearishColor || "#ef5350", g = c.hollow === !0, u = `vp-clip-candle-${J(t)}`;
820
+ s.registerClipPath(
821
+ u,
822
+ `<rect x="${i(o.x)}" y="${i(o.y)}" width="${i(o.width)}" height="${i(o.height)}"/>`
823
+ );
824
+ for (let y = 0; y < r.x.length; y++) {
825
+ const p = r.close[y] >= r.open[y], $ = e.transform(r.x[y]), m = n.transform(r.open[y]), w = n.transform(r.close[y]), v = n.transform(r.high[y]), b = n.transform(r.low[y]), k = p ? d : f;
826
+ s.push(
827
+ "series",
828
+ `<line clip-path="url(#${u})" x1="${i($)}" y1="${i(v)}" x2="${i($)}" y2="${i(b)}" stroke="${k}" stroke-width="1"/>`
829
+ );
830
+ const C = Math.min(m, w), A = Math.max(1, Math.abs(m - w)), S = g && p ? "none" : k, E = g && p ? k : "none";
831
+ s.push(
832
+ "series",
833
+ `<rect clip-path="url(#${u})" x="${i($ - h / 2)}" y="${i(C)}" width="${i(h)}" height="${i(A)}" fill="${S}" stroke="${E}" stroke-width="1"/>`
834
+ );
835
+ }
836
+ }
837
+ const ce = 1e4;
838
+ function jo(t, o, e, n) {
839
+ const s = e === o ? 0.5 : (t - o) / (e - o);
840
+ if (n === "viridis") {
841
+ const c = Math.round(68 + s * 150), a = Math.round(1 + s * 180), l = Math.round(84 + (1 - s) * 50);
842
+ return `rgb(${c},${a},${l})`;
843
+ }
844
+ const r = Math.round(s * 255);
845
+ return `rgb(${r},${Math.round(r * 0.4)},${255 - r})`;
846
+ }
847
+ function _o(t, o, e, n, s) {
848
+ var C, A;
849
+ const r = (C = t.getHeatmapData) == null ? void 0 : C.call(t);
850
+ if (!r) return;
851
+ const { xValues: c, yValues: a, zValues: l } = r, h = c.length, d = a.length, f = h * d, g = ((A = t.getHeatmapStyle) == null ? void 0 : A.call(t)) ?? t.getStyle(), u = g.colorScale, y = (u == null ? void 0 : u.name) ?? g.colormap ?? "viridis";
852
+ let p = u == null ? void 0 : u.min, $ = u == null ? void 0 : u.max;
853
+ if (p === void 0 || $ === void 0) {
854
+ p = 1 / 0, $ = -1 / 0;
855
+ for (let S = 0; S < l.length; S++)
856
+ l[S] < p && (p = l[S]), l[S] > $ && ($ = l[S]);
857
+ }
858
+ (!Number.isFinite(p) || !Number.isFinite($)) && (p = 0, $ = 1);
859
+ const m = h > 1 ? Math.abs(c[1] - c[0]) : 1, w = d > 1 ? Math.abs(a[1] - a[0]) : 1, v = m / 2, b = w / 2;
860
+ f > ce && console.warn(
861
+ `[VeloPlot] Heatmap SVG export: ${f} cells exceeds budget (${ce}). Consider raster fallback.`
862
+ );
863
+ const k = `vp-clip-hm-${J(t)}`;
864
+ s.registerClipPath(
865
+ k,
866
+ `<rect x="${i(o.x)}" y="${i(o.y)}" width="${i(o.width)}" height="${i(o.height)}"/>`
867
+ );
868
+ for (let S = 0; S < d; S++)
869
+ for (let E = 0; E < h; E++) {
870
+ const R = l[S * h + E], D = e.transform(c[E] - v), z = e.transform(c[E] + v), T = n.transform(a[S] - b), F = n.transform(a[S] + b), Y = Math.min(D, z), B = Math.min(T, F), V = Math.max(1, Math.abs(z - D)), P = Math.max(1, Math.abs(F - T)), O = jo(R, p, $, y);
871
+ s.push(
872
+ "series",
873
+ `<rect clip-path="url(#${k})" x="${i(Y)}" y="${i(B)}" width="${i(V)}" height="${i(P)}" fill="${O}"/>`
874
+ );
875
+ }
876
+ }
877
+ function No(t, o, e) {
878
+ const n = [];
879
+ for (let s = 0; s < t.length / 2; s++) {
880
+ const r = o.transform(t[s * 2]), c = e.transform(t[s * 2 + 1]);
881
+ n.push(`${i(r)},${i(c)}`);
882
+ }
883
+ return n;
884
+ }
885
+ function qo(t, o, e, n, s) {
886
+ var m;
887
+ const r = (m = t.getPolarData) == null ? void 0 : m.call(t);
888
+ if (!r) return;
889
+ const c = t.getStyle(), a = c.color ?? "#ff0055", l = c.opacity ?? 1, h = c.width ?? 1.5, d = c.fillOpacity ?? l * 0.2, f = c.angleMode ?? "degrees", g = c.closePath !== !1, u = !!c.fill, y = `vp-clip-polar-${J(t)}`;
890
+ if (s.registerClipPath(
891
+ y,
892
+ `<rect x="${i(o.x)}" y="${i(o.y)}" width="${i(o.width)}" height="${i(o.height)}"/>`
893
+ ), u) {
894
+ const w = Ze(r, f, g), v = e.transform(0), b = n.transform(0), k = w.length / 6;
895
+ for (let C = 0; C < k; C++) {
896
+ const A = C * 6, S = [
897
+ `${i(v)},${i(b)}`,
898
+ `${i(e.transform(w[A + 2]))},${i(n.transform(w[A + 3]))}`,
899
+ `${i(e.transform(w[A + 4]))},${i(n.transform(w[A + 5]))}`
900
+ ];
901
+ s.push(
902
+ "series",
903
+ `<polygon clip-path="url(#${y})" points="${S.join(" ")}" fill="${a}" fill-opacity="${d}" stroke="none"/>`
904
+ );
905
+ }
906
+ }
907
+ const p = Qe(r, f, g), $ = No(p, e, n);
908
+ $.length !== 0 && s.push(
909
+ "series",
910
+ `<polyline clip-path="url(#${y})" points="${$.join(" ")}" fill="none" stroke="${a}" stroke-width="${h}" stroke-opacity="${l}"/>`
911
+ );
912
+ }
913
+ function Uo(t, o, e) {
914
+ var C, A;
915
+ const n = (C = t.getGaugeData) == null ? void 0 : C.call(t), s = ((A = t.getGaugeStyle) == null ? void 0 : A.call(t)) ?? t.getStyle();
916
+ if (!n) return;
917
+ const r = o.x + o.width / 2, c = o.y + o.height * 0.65, a = Math.min(o.width, o.height) * 0.35, l = n.min ?? 0, h = n.max ?? 100, d = n.value ?? 0, f = Math.PI, g = 0, u = Math.max(0, Math.min(1, (d - l) / (h - l))), y = (S, E, R) => {
918
+ const D = r + S * Math.cos(E), z = c - S * Math.sin(E), T = r + S * Math.cos(R), F = c - S * Math.sin(R), Y = R - E > Math.PI ? 1 : 0;
919
+ return `M ${i(D)} ${i(z)} A ${i(S)} ${i(S)} 0 ${Y} 1 ${i(T)} ${i(F)}`;
920
+ }, p = s.trackColor ?? "#333", $ = s.color ?? "#3b82f6";
921
+ e.push("series", `<path d="${y(a, f, g)}" fill="none" stroke="${p}" stroke-width="12" stroke-linecap="round"/>`);
922
+ const m = f - u * Math.PI;
923
+ e.push("series", `<path d="${y(a, f, m)}" fill="none" stroke="${$}" stroke-width="12" stroke-linecap="round"/>`);
924
+ const w = a - 8, v = r + w * Math.cos(m), b = c - w * Math.sin(m);
925
+ e.push("series", `<line x1="${i(r)}" y1="${i(c)}" x2="${i(v)}" y2="${i(b)}" stroke="${$}" stroke-width="2"/>`), e.push("series", `<circle cx="${i(r)}" cy="${i(c)}" r="4" fill="${$}"/>`);
926
+ const k = s.label ?? `${d}`;
927
+ e.push(
928
+ "series",
929
+ `<text x="${i(r)}" y="${i(c + 30)}" fill="${$}" font-size="18" font-weight="600" text-anchor="middle">${N(String(k))}</text>`
930
+ );
931
+ }
932
+ function Zo(t, o, e) {
933
+ var p, $, m;
934
+ const n = (p = t.getSankeyData) == null ? void 0 : p.call(t), s = (($ = t.getSankeyStyle) == null ? void 0 : $.call(t)) ?? t.getStyle();
935
+ if (!((m = n == null ? void 0 : n.links) != null && m.length)) return;
936
+ const r = go(n, s, o);
937
+ if (!r) return;
938
+ const { nodeRegistry: c, links: a, nodeOutValue: l, nodeInValue: h, workingArea: d } = r, { linkOpacity: f, showLabels: g, nodeWidth: u } = r.style, y = "vp-clip-sankey";
939
+ e.registerClipPath(
940
+ y,
941
+ `<rect x="${i(o.x)}" y="${i(o.y)}" width="${i(o.width)}" height="${i(o.height)}"/>`
942
+ );
943
+ for (const w of a) {
944
+ const v = w.source, b = w.target, k = w.sourceOffset, C = w.targetOffset, A = l.get(w.link.source) || 1, S = h.get(w.link.target) || 1, E = w.link.value / A * v.height, R = w.link.value / S * b.height, D = v.x + v.width, z = v.y + k, T = z + E, F = b.x, Y = b.y + C, B = Y + R, V = (F - D) * 0.5, P = e.registerLinearGradient(D, (z + T) / 2, F, (Y + B) / 2, [
945
+ { offset: "0%", color: v.color },
946
+ { offset: "100%", color: b.color }
947
+ ]);
948
+ e.push(
949
+ "series",
950
+ `<path clip-path="url(#${y})" d="M ${i(D)} ${i(z)} C ${i(D + V)} ${i(z)}, ${i(F - V)} ${i(Y)}, ${i(F)} ${i(Y)} L ${i(F)} ${i(B)} C ${i(F - V)} ${i(B)}, ${i(D + V)} ${i(T)}, ${i(D)} ${i(T)} Z" fill="url(#${P})" fill-opacity="${f}" stroke="${v.color}" stroke-opacity="${f * 0.3}" stroke-width="0.5"/>`
951
+ );
952
+ }
953
+ c.forEach((w) => {
954
+ e.push(
955
+ "series",
956
+ `<rect clip-path="url(#${y})" x="${i(w.x)}" y="${i(w.y)}" width="${i(w.width)}" height="${i(w.height)}" fill="${w.color}"/>`
957
+ );
958
+ }), g && c.forEach((w, v) => {
959
+ let b = String(v);
960
+ const k = n.nodes.find((S) => S.id === v);
961
+ k != null && k.name && (b = k.name);
962
+ const C = w.x <= d.x + 5, A = w.x >= d.x + d.width - u - 5;
963
+ C ? e.push(
964
+ "series",
965
+ `<text clip-path="url(#${y})" x="${i(w.x - 10)}" y="${i(w.y + w.height / 2)}" fill="#ffffff" font-size="11" font-weight="700" text-anchor="end" dominant-baseline="middle">${N(b)}</text>`
966
+ ) : A ? e.push(
967
+ "series",
968
+ `<text clip-path="url(#${y})" x="${i(w.x + w.width + 10)}" y="${i(w.y + w.height / 2)}" fill="#ffffff" font-size="11" font-weight="700" text-anchor="start" dominant-baseline="middle">${N(b)}</text>`
969
+ ) : e.push(
970
+ "series",
971
+ `<text clip-path="url(#${y})" x="${i(w.x + w.width / 2)}" y="${i(w.y - 10)}" fill="#ffffff" font-size="11" font-weight="700" text-anchor="middle">${N(b)}</text>`
972
+ );
973
+ });
974
+ }
975
+ function Qo(t, o, e, n, s) {
976
+ var p;
977
+ const r = t.getData(), a = t.getStyle().color ?? "#ff0055", l = o.x + o.width / 2, h = o.y + o.height - 20, d = Math.min(o.width, o.height) - 40, f = d * Math.sqrt(3) / 2, g = { x: l, y: h }, u = { x: l - d / 2, y: h - f }, y = { x: l + d / 2, y: h - f };
978
+ s.push(
979
+ "series",
980
+ `<polygon points="${i(g.x)},${i(g.y)} ${i(u.x)},${i(u.y)} ${i(y.x)},${i(y.y)}" fill="none" stroke="${a}" stroke-width="1"/>`
981
+ );
982
+ for (let $ = 1; $ <= 4; $++) {
983
+ const m = $ / 5, w = { x: g.x + (u.x - g.x) * m, y: g.y + (u.y - g.y) * m }, v = { x: g.x + (y.x - g.x) * m, y: g.y + (y.y - g.y) * m };
984
+ s.push("grid", `<line x1="${i(w.x)}" y1="${i(w.y)}" x2="${i(v.x)}" y2="${i(v.y)}" stroke="${a}" stroke-opacity="0.2"/>`);
985
+ }
986
+ if ((p = r == null ? void 0 : r.x) != null && p.length)
987
+ for (let $ = 0; $ < r.x.length; $++) {
988
+ const m = r.x[$], w = r.y[$], v = 1 - m - w, b = m * u.x + w * y.x + v * g.x, k = m * u.y + w * y.y + v * g.y;
989
+ s.push("series", It("circle", b, k, 6, a));
990
+ }
991
+ }
992
+ function Ko(t, o, e, n, s) {
993
+ var $;
994
+ const r = t.getData();
995
+ if (!(($ = r == null ? void 0 : r.x) != null && $.length)) return;
996
+ const c = t.getStyle(), a = c.positiveColor ?? "#22c55e", l = c.negativeColor ?? "#ef4444", h = c.subtotalColor ?? "#3b82f6", d = c.connectorColor ?? "#64748b", f = c.waterfallTypes ?? [], g = e.domain[1] - e.domain[0], u = g > 0 ? (c.barWidth ?? 0.8) / g * o.width : 20;
997
+ let y = 0;
998
+ const p = `vp-clip-wf-${J(t)}`;
999
+ s.registerClipPath(
1000
+ p,
1001
+ `<rect x="${i(o.x)}" y="${i(o.y)}" width="${i(o.width)}" height="${i(o.height)}"/>`
1002
+ );
1003
+ for (let m = 0; m < r.x.length; m++) {
1004
+ const w = r.y[m], v = f[m] ?? (w >= 0 ? "positive" : "negative"), b = e.transform(r.x[m]);
1005
+ let k, C, A;
1006
+ v === "subtotal" ? (k = n.transform(0), C = n.transform(y), A = h) : v === "total" ? (k = n.transform(0), C = n.transform(y + w), y += w, A = h) : (k = n.transform(y), y += w, C = n.transform(y), A = w >= 0 ? a : l);
1007
+ const S = Math.min(k, C), E = Math.max(1, Math.abs(C - k));
1008
+ if (s.push(
1009
+ "series",
1010
+ `<rect clip-path="url(#${p})" x="${i(b - u / 2)}" y="${i(S)}" width="${i(u)}" height="${i(E)}" fill="${A}" fill-opacity="0.9"/>`
1011
+ ), m > 0 && c.showConnectors !== !1) {
1012
+ const R = e.transform(r.x[m - 1]), D = n.transform(y - w);
1013
+ s.push(
1014
+ "series",
1015
+ `<line x1="${i(R + u / 2)}" y1="${i(D)}" x2="${i(b - u / 2)}" y2="${i(D)}" stroke="${d}" stroke-width="1" stroke-opacity="0.6"/>`
1016
+ );
1017
+ }
1018
+ }
1019
+ }
1020
+ function Jo(t, o, e, n, s) {
1021
+ var $, m, w;
1022
+ const r = t.getData();
1023
+ if (!(($ = r == null ? void 0 : r.x) != null && $.length) || !r.median) return;
1024
+ const c = t.getStyle(), a = c.color ?? "#ff0055", l = c.opacity ?? 1, h = e.domain[1] - e.domain[0], d = h > 0 ? (c.barWidth ?? 0.6) / h * o.width : 16, f = r.q1, g = r.q3, u = r.low, y = r.high, p = `vp-clip-box-${J(t)}`;
1025
+ s.registerClipPath(
1026
+ p,
1027
+ `<rect x="${i(o.x)}" y="${i(o.y)}" width="${i(o.width)}" height="${i(o.height)}"/>`
1028
+ );
1029
+ for (let v = 0; v < r.x.length; v++) {
1030
+ const b = e.transform(r.x[v]), k = f ? n.transform(f[v]) : n.transform(r.y[v]), C = g ? n.transform(g[v]) : n.transform(((m = r.y2) == null ? void 0 : m[v]) ?? r.y[v]), A = n.transform(r.median[v]), S = u ? n.transform(u[v]) : k, E = y ? n.transform(y[v]) : C, R = Math.min(k, C), D = Math.max(1, Math.abs(C - k));
1031
+ s.push("series", `<line clip-path="url(#${p})" x1="${i(b)}" y1="${i(S)}" x2="${i(b)}" y2="${i(E)}" stroke="${a}" stroke-width="1"/>`), s.push("series", `<rect clip-path="url(#${p})" x="${i(b - d / 2)}" y="${i(R)}" width="${i(d)}" height="${i(D)}" fill="${a}" fill-opacity="${l * 0.3}" stroke="${a}"/>`), s.push("series", `<line clip-path="url(#${p})" x1="${i(b - d / 2)}" y1="${i(A)}" x2="${i(b + d / 2)}" y2="${i(A)}" stroke="${a}" stroke-width="2"/>`);
1032
+ const z = (w = r.outliers) == null ? void 0 : w[v];
1033
+ if (z)
1034
+ for (const T of z)
1035
+ s.push("series", It("circle", e.transform(T.x), n.transform(T.y), 4, a, l));
1036
+ }
1037
+ }
1038
+ function yt(t) {
1039
+ return t instanceof Float32Array || t instanceof Float64Array ? t : Float32Array.from(t);
1040
+ }
1041
+ function tn(t) {
1042
+ const o = new Float32Array(t.length), e = new Float32Array(t.length);
1043
+ for (let n = 0; n < t.length; n++) {
1044
+ const s = t[n];
1045
+ o[n] = s > 0 ? s : 0, e[n] = s < 0 ? s : 0;
1046
+ }
1047
+ return { positive: o, negative: e };
1048
+ }
1049
+ function en(t, o, e) {
1050
+ if (t === void 0 || t === "zero") return 0;
1051
+ if (typeof t == "number") return t;
1052
+ const n = e.find((r) => r.id === t);
1053
+ return n ? yt(n.y)[o] ?? 0 : 0;
1054
+ }
1055
+ function on(t, o, e, n, s) {
1056
+ const r = t.length;
1057
+ if (r === 0) return [];
1058
+ if (r === 1) {
1059
+ const f = o[0] >= e(0) ? n : s;
1060
+ return [{ points: [{ x: t[0], y: o[0] }], color: f }];
1061
+ }
1062
+ const c = [];
1063
+ let a = null;
1064
+ const l = (f) => o[f] >= e(f) ? n : s, h = (f, g, u) => {
1065
+ !a || a.color !== u ? (a != null && a.points.length && c.push(a), a = { points: [{ x: f, y: g }], color: u }) : a.points.push({ x: f, y: g });
1066
+ }, d = () => {
1067
+ a != null && a.points.length && (c.push(a), a = null);
1068
+ };
1069
+ h(t[0], o[0], l(0));
1070
+ for (let f = 1; f < r; f++) {
1071
+ const g = o[f - 1], u = o[f], y = e(f - 1), p = e(f), $ = g >= y, m = u >= p;
1072
+ if ($ === m) {
1073
+ h(t[f], o[f], l(f));
1074
+ continue;
1075
+ }
1076
+ const w = u - g - (p - y), v = Math.max(0, Math.min(1, (y - g) / w)), b = t[f - 1] + v * (t[f] - t[f - 1]), k = g + v * (u - g), C = $ ? n : s, A = m ? n : s;
1077
+ h(b, k, C), d(), h(b, k, A), h(t[f], o[f], l(f));
1078
+ }
1079
+ return d(), c;
1080
+ }
1081
+ function nn(t, o, e, n, s, r, c, a) {
1082
+ const l = s.colorZones, d = on(
1083
+ e,
1084
+ n,
1085
+ (f) => en(l.ref, f, r),
1086
+ l.aboveColor,
1087
+ l.belowColor
1088
+ );
1089
+ for (let f = 0; f < d.length; f++) {
1090
+ const g = d[f];
1091
+ g.points.length < 2 || t.push({
1092
+ id: `${o}-${a}-${f}`,
1093
+ type: "line",
1094
+ visible: c,
1095
+ data: {
1096
+ x: Float32Array.from(g.points.map((u) => u.x)),
1097
+ y: Float32Array.from(g.points.map((u) => u.y))
1098
+ },
1099
+ style: {
1100
+ color: g.color,
1101
+ width: s.width ?? 2,
1102
+ opacity: s.opacity ?? 1
1103
+ }
1104
+ });
1105
+ }
1106
+ }
1107
+ const sn = {
1108
+ baselineColor: "rgba(255,255,255,0.35)",
1109
+ baselineWidth: 1,
1110
+ baselineDash: [4, 4],
1111
+ peakColor: "#ff00ff",
1112
+ troughColor: "#00ffff",
1113
+ peakSize: 6,
1114
+ troughSize: 6
1115
+ };
1116
+ function St(t) {
1117
+ var h, d, f, g;
1118
+ const { id: o, data: e, style: n = {}, visible: s = !0 } = t, r = { ...sn, ...n }, c = yt(e.x), a = c.length, l = [];
1119
+ if ((h = e.fills) != null && h.length)
1120
+ for (let u = 0; u < e.fills.length; u++) {
1121
+ const y = e.fills[u], p = y.id ?? `${o}-fill-${u}`;
1122
+ l.push({
1123
+ id: p,
1124
+ type: "band",
1125
+ visible: s,
1126
+ data: {
1127
+ x: c,
1128
+ y: yt(y.upper),
1129
+ y2: yt(y.lower)
1130
+ },
1131
+ style: {
1132
+ color: y.color ?? "rgba(100, 80, 180, 0.25)",
1133
+ opacity: y.opacity ?? 0.35
1134
+ }
1135
+ });
1136
+ }
1137
+ if (e.histogram) {
1138
+ const u = yt(e.histogram.y), { positive: y, negative: p } = tn(u), $ = e.histogram.barWidth, m = $ !== void 0 ? { barWidth: $ } : {};
1139
+ l.push({
1140
+ id: `${o}-hist-pos`,
1141
+ type: "bar",
1142
+ visible: s,
1143
+ data: { x: c, y },
1144
+ style: {
1145
+ color: e.histogram.positiveColor ?? "#26a69a",
1146
+ opacity: e.histogram.opacity ?? 0.85,
1147
+ ...m
1148
+ }
1149
+ }), l.push({
1150
+ id: `${o}-hist-neg`,
1151
+ type: "bar",
1152
+ visible: s,
1153
+ data: { x: c, y: p },
1154
+ style: {
1155
+ color: e.histogram.negativeColor ?? "#ef5350",
1156
+ opacity: e.histogram.opacity ?? 0.85,
1157
+ ...m
1158
+ }
1159
+ });
1160
+ }
1161
+ if ((d = e.lines) != null && d.length)
1162
+ for (let u = 0; u < e.lines.length; u++) {
1163
+ const y = e.lines[u], p = y.id ?? `${o}-line-${u}`, $ = yt(y.y);
1164
+ if (y.colorZones) {
1165
+ nn(l, p, c, $, y, e.lines, s, "zone");
1166
+ continue;
1167
+ }
1168
+ l.push({
1169
+ id: p,
1170
+ type: "line",
1171
+ visible: s,
1172
+ data: { x: c, y: $ },
1173
+ style: {
1174
+ color: y.color ?? (u === 0 ? "#00e5ff" : "#e040fb"),
1175
+ width: y.width ?? 2,
1176
+ opacity: y.opacity ?? 1
1177
+ }
1178
+ });
1179
+ }
1180
+ if (e.baseline !== void 0 && a >= 2) {
1181
+ const u = e.baseline;
1182
+ l.push({
1183
+ id: `${o}-baseline`,
1184
+ type: "line",
1185
+ visible: s,
1186
+ data: {
1187
+ x: Float32Array.from([c[0], c[a - 1]]),
1188
+ y: Float32Array.from([u, u])
1189
+ },
1190
+ style: {
1191
+ color: r.baselineColor,
1192
+ width: r.baselineWidth,
1193
+ lineDash: r.baselineDash,
1194
+ opacity: 1
1195
+ }
1196
+ });
1197
+ }
1198
+ if ((f = e.referenceLines) != null && f.length)
1199
+ for (let u = 0; u < e.referenceLines.length; u++) {
1200
+ const y = e.referenceLines[u];
1201
+ l.push({
1202
+ id: `${o}-ref-${u}`,
1203
+ type: "line",
1204
+ visible: s,
1205
+ data: {
1206
+ x: Float32Array.from([c[0], c[a - 1]]),
1207
+ y: Float32Array.from([y.y, y.y])
1208
+ },
1209
+ style: {
1210
+ color: y.color ?? "rgba(255,255,255,0.2)",
1211
+ width: y.width ?? 1,
1212
+ lineDash: y.dash ?? [2, 4],
1213
+ opacity: 0.8
1214
+ }
1215
+ });
1216
+ }
1217
+ if ((g = e.markers) != null && g.length) {
1218
+ const u = e.markers.filter((p) => p.kind === "peak"), y = e.markers.filter((p) => p.kind === "trough");
1219
+ u.length && l.push({
1220
+ id: `${o}-peaks`,
1221
+ type: "scatter",
1222
+ visible: s,
1223
+ data: {
1224
+ x: Float32Array.from(u.map((p) => p.x)),
1225
+ y: Float32Array.from(u.map((p) => p.y))
1226
+ },
1227
+ style: {
1228
+ color: r.peakColor,
1229
+ pointSize: r.peakSize,
1230
+ opacity: 1
1231
+ }
1232
+ }), y.length && l.push({
1233
+ id: `${o}-troughs`,
1234
+ type: "scatter",
1235
+ visible: s,
1236
+ data: {
1237
+ x: Float32Array.from(y.map((p) => p.x)),
1238
+ y: Float32Array.from(y.map((p) => p.y))
1239
+ },
1240
+ style: {
1241
+ color: r.troughColor,
1242
+ pointSize: r.troughSize,
1243
+ opacity: 1
1244
+ }
1245
+ });
1246
+ }
1247
+ return l;
1248
+ }
1249
+ function ai(t) {
1250
+ return St(t);
1251
+ }
1252
+ function ci(t, o, e = 3) {
1253
+ const n = yt(t), s = yt(o), r = [], c = Math.max(1, e);
1254
+ for (let a = c; a < s.length - c; a++) {
1255
+ let l = !0, h = !0;
1256
+ for (let d = a - c; d <= a + c; d++)
1257
+ d !== a && (s[d] >= s[a] && (l = !1), s[d] <= s[a] && (h = !1));
1258
+ l ? r.push({ x: n[a], y: s[a], kind: "peak" }) : h && r.push({ x: n[a], y: s[a], kind: "trough" });
1259
+ }
1260
+ return r;
1261
+ }
1262
+ function rn(t, o, e, n, s) {
1263
+ const r = t.indicatorOptions;
1264
+ if (!r) {
1265
+ console.warn(`[VeloPlot] Indicator series "${J(t)}" missing indicatorOptions for SVG export`);
1266
+ return;
1267
+ }
1268
+ const c = St(r);
1269
+ for (const a of c) {
1270
+ const l = {
1271
+ isVisible: () => !0,
1272
+ getYAxisId: () => t.getYAxisId(),
1273
+ getData: () => a.data ?? { x: new Float32Array(0), y: new Float32Array(0) },
1274
+ getStyle: () => a.style ?? {},
1275
+ getType: () => a.type ?? "line",
1276
+ getId: () => `${J(t)}-${a.id ?? a.type}`,
1277
+ getName: () => a.name ?? a.id ?? "indicator",
1278
+ hasErrorData: () => !1
1279
+ }, h = a.type ?? "line";
1280
+ h === "bar" ? Le(l, o, e, n, s) : h === "band" || h === "area" ? Ft(l, o, e, n, s) : h === "scatter" ? Ie(l, o, e, n, s) : kt(l, o, e, n, s);
1281
+ }
1282
+ }
1283
+ const ze = /* @__PURE__ */ new Map();
1284
+ function G(t, o) {
1285
+ ze.set(t, o);
1286
+ }
1287
+ G("line", (t, o, e, n, s) => kt(t, o, e, n, s));
1288
+ G("step", (t, o, e, n, s) => kt(t, o, e, n, s));
1289
+ G("step+scatter", (t, o, e, n, s) => kt(t, o, e, n, s));
1290
+ G("line+scatter", (t, o, e, n, s) => kt(t, o, e, n, s));
1291
+ G("scatter", (t, o, e, n, s) => Ie(t, o, e, n, s));
1292
+ G("bar", (t, o, e, n, s) => Le(t, o, e, n, s));
1293
+ G("band", (t, o, e, n, s) => Ft(t, o, e, n, s));
1294
+ G("area", (t, o, e, n, s) => Ft(t, o, e, n, s));
1295
+ G("candlestick", (t, o, e, n, s) => De(t, o, e, n, s));
1296
+ G("heikin-ashi", (t, o, e, n, s) => De(t, o, e, n, s));
1297
+ G("heatmap", (t, o, e, n, s) => _o(t, o, e, n, s));
1298
+ G("polar", (t, o, e, n, s) => qo(t, o, e, n, s));
1299
+ G("gauge", (t, o, e, n, s) => Uo(t, o, s));
1300
+ G("sankey", (t, o, e, n, s) => Zo(t, o, s));
1301
+ G("ternary", (t, o, e, n, s) => Qo(t, o, e, n, s));
1302
+ G("waterfall", (t, o, e, n, s) => Ko(t, o, e, n, s));
1303
+ G("boxplot", (t, o, e, n, s) => Jo(t, o, e, n, s));
1304
+ G("indicator", (t, o, e, n, s) => rn(t, o, e, n, s));
1305
+ G("radar", () => {
1306
+ });
1307
+ function an(t, o) {
1308
+ var n, s, r, c;
1309
+ const e = /* @__PURE__ */ new Set();
1310
+ for (const a of t.series) {
1311
+ if (!a.isVisible()) continue;
1312
+ const l = a.getType(), h = ze.get(l), d = ve(t.yAxes, a.getYAxisId(), t.primaryYAxisId);
1313
+ if (!d) continue;
1314
+ if (!h) {
1315
+ e.has(l) || (console.warn(`[VeloPlot] No SVG exporter for series type "${l}"`), e.add(l));
1316
+ continue;
1317
+ }
1318
+ const f = a.getData();
1319
+ (l === "heatmap" ? !((n = a.getHeatmapData) != null && n.call(a)) : l === "polar" ? !((s = a.getPolarData) != null && s.call(a)) : l === "gauge" ? !((r = a.getGaugeData) != null && r.call(a)) : l === "sankey" ? !((c = a.getSankeyData) != null && c.call(a)) : l !== "indicator" && (!f || f.x.length === 0)) && l !== "gauge" && l !== "indicator" || h(a, t.plotArea, t.xScale, d, o, t);
1320
+ }
1321
+ }
1322
+ const le = /* @__PURE__ */ new WeakMap();
1323
+ function cn(t, o) {
1324
+ let e = le.get(t);
1325
+ e || (e = /* @__PURE__ */ new Map(), le.set(t, e));
1326
+ let n = e.get(o);
1327
+ return n || (n = `vp-arrow-${e.size}`, t.registerArrowMarker(n, o), e.set(o, n)), n;
1328
+ }
1329
+ function lt(t, o, e, n) {
1330
+ const s = Pt(t.yScales) || [...t.yScales.values()][0];
1331
+ return s ? { px: t.xScale.transform(o), py: s.transform(e) } : { px: 0, py: 0 };
1332
+ }
1333
+ function ln(t, o) {
1334
+ var c;
1335
+ if (t.visible === !1) return [];
1336
+ const { plotArea: e } = o, n = [], r = 'clip-path="url(#vp-clip-ann)"';
1337
+ switch (t.type) {
1338
+ case "horizontal-line": {
1339
+ const a = lt(o, 0, t.y).py, l = o.xScale.transform(t.xMin ?? o.viewBounds.xMin), h = o.xScale.transform(t.xMax ?? o.viewBounds.xMax), d = t.color ?? "#ff0055", f = (c = t.lineDash) != null && c.length ? ` stroke-dasharray="${t.lineDash.join(",")}"` : "";
1340
+ if (n.push(
1341
+ `<line x1="${i(l)}" y1="${i(a)}" x2="${i(h)}" y2="${i(a)}" stroke="${d}" stroke-width="${t.lineWidth ?? 1}"${f}/>`
1342
+ ), t.label) {
1343
+ const g = t.labelPosition === "right" ? h - 4 : t.labelPosition === "left" ? l + 4 : (l + h) / 2;
1344
+ n.push(
1345
+ `<text x="${i(g)}" y="${i(a - 4)}" fill="${d}" font-size="11" text-anchor="${t.labelPosition === "right" ? "end" : t.labelPosition === "left" ? "start" : "middle"}">${N(t.label)}</text>`
1346
+ );
1347
+ }
1348
+ break;
1349
+ }
1350
+ case "vertical-line": {
1351
+ const a = lt(o, t.x, 0).px, l = o.yScales.values().next().value.transform(t.yMin ?? o.viewBounds.yMin), h = o.yScales.values().next().value.transform(t.yMax ?? o.viewBounds.yMax), d = t.color ?? "#ff0055";
1352
+ n.push(
1353
+ `<line x1="${i(a)}" y1="${i(Math.min(l, h))}" x2="${i(a)}" y2="${i(Math.max(l, h))}" stroke="${d}" stroke-width="${t.lineWidth ?? 1}"/>`
1354
+ );
1355
+ break;
1356
+ }
1357
+ case "rectangle": {
1358
+ const a = lt(o, t.xMin, t.yMax), l = lt(o, t.xMax, t.yMin), h = Math.min(a.px, l.px), d = Math.min(a.py, l.py), f = Math.abs(l.px - a.px), g = Math.abs(l.py - a.py);
1359
+ n.push(
1360
+ `<rect x="${i(h)}" y="${i(d)}" width="${i(f)}" height="${i(g)}" fill="${t.fillColor ?? "rgba(100,149,237,0.2)"}" stroke="${t.strokeColor ?? "#6495ed"}" stroke-width="${t.strokeWidth ?? 1}"/>`
1361
+ );
1362
+ break;
1363
+ }
1364
+ case "band": {
1365
+ const a = t.yMin ?? o.viewBounds.yMin, l = t.yMax ?? o.viewBounds.yMax, h = lt(o, 0, a).py, d = lt(o, 0, l).py, f = Math.min(h, d), g = Math.abs(d - h);
1366
+ n.push(
1367
+ `<rect x="${i(e.x)}" y="${i(f)}" width="${i(e.width)}" height="${i(g)}" fill="${t.fillColor ?? "rgba(100,149,237,0.15)"}"/>`
1368
+ );
1369
+ break;
1370
+ }
1371
+ case "text": {
1372
+ const a = lt(o, t.x, t.y), l = t.color ?? "#fff", h = t.rotation ? ` transform="rotate(${t.rotation} ${i(a.px)} ${i(a.py)})"` : "";
1373
+ n.push(
1374
+ `<text x="${i(a.px)}" y="${i(a.py)}" fill="${l}" font-size="${t.fontSize ?? 12}" font-family="${t.fontFamily ?? "sans-serif"}" text-anchor="middle"${h}>${N(t.text)}</text>`
1375
+ );
1376
+ break;
1377
+ }
1378
+ case "arrow": {
1379
+ const a = lt(o, t.x1, t.y1), l = lt(o, t.x2, t.y2), h = t.color ?? "#ff0055", d = o.builder ? cn(o.builder, h) : "vp-arrow";
1380
+ n.push(
1381
+ `<line x1="${i(a.px)}" y1="${i(a.py)}" x2="${i(l.px)}" y2="${i(l.py)}" stroke="${h}" stroke-width="${t.lineWidth ?? 2}" marker-end="url(#${d})"/>`
1382
+ );
1383
+ break;
1384
+ }
1385
+ }
1386
+ return n.map((a) => `<g ${r}>${a}</g>`);
1387
+ }
1388
+ function Ee(t, o) {
1389
+ if (!t.builder || !o.length) return;
1390
+ const { plotArea: e } = t;
1391
+ t.builder.registerClipPath(
1392
+ "vp-clip-ann",
1393
+ `<rect x="${i(e.x)}" y="${i(e.y)}" width="${i(e.width)}" height="${i(e.height)}"/>`
1394
+ );
1395
+ const n = [...o].filter((s) => s.visible !== !1).sort((s, r) => (s.zIndex ?? 0) - (r.zIndex ?? 0));
1396
+ for (const s of n)
1397
+ for (const r of ln(s, t))
1398
+ t.builder.push("plugins", r);
1399
+ }
1400
+ function Te(t) {
1401
+ var e, n, s;
1402
+ if (!t.builder) return;
1403
+ const o = Pt(t.yScales);
1404
+ if (o)
1405
+ for (const r of t.series) {
1406
+ if (!r.isVisible() || r.getType() !== "candlestick") continue;
1407
+ const c = ((e = r.getMarkers) == null ? void 0 : e.call(r)) ?? [], a = r.getData();
1408
+ if ((n = a == null ? void 0 : a.x) != null && n.length)
1409
+ for (const l of c) {
1410
+ let h = 0, d = 1 / 0;
1411
+ for (let m = 0; m < a.x.length; m++) {
1412
+ const w = Math.abs(a.x[m] - l.time);
1413
+ w < d && (d = w, h = m);
1414
+ }
1415
+ const f = t.xScale.transform(a.x[h]), g = o.transform(((s = a.high) == null ? void 0 : s[h]) ?? a.y[h]), u = l.shape === "arrowUp" || l.position === "belowBar", y = l.color ?? (u ? "#26a69a" : "#ef5350"), p = u ? g + 12 : g - 12, $ = u ? `${i(f)},${i(p - 6)} ${i(f - 5)},${i(p + 4)} ${i(f + 5)},${i(p + 4)}` : `${i(f)},${i(p + 6)} ${i(f - 5)},${i(p - 4)} ${i(f + 5)},${i(p - 4)}`;
1416
+ t.builder.push("plugins", `<polygon points="${$}" fill="${y}"/>`);
1417
+ }
1418
+ }
1419
+ }
1420
+ function hn(t) {
1421
+ return Math.abs(Math.cos(t)) < 0.1 ? "middle" : Math.cos(t) > 0 ? "start" : "end";
1422
+ }
1423
+ function fn(t) {
1424
+ return Math.abs(Math.sin(t)) < 0.1 ? "middle" : Math.sin(t) > 0 ? "hanging" : "alphabetic";
1425
+ }
1426
+ function dn(t, o, e) {
1427
+ var g, u, y, p, $, m, w;
1428
+ const { plotArea: n } = t, s = n.x + n.width / 2, r = n.y + n.height / 2, c = Math.min(n.width, n.height) / 2 * 0.8, a = e.categories.length;
1429
+ if (a === 0) return;
1430
+ const l = 2 * Math.PI / a, h = ((g = e.gridStyle) == null ? void 0 : g.color) ?? "rgba(255, 255, 255, 0.1)", d = ((u = e.gridStyle) == null ? void 0 : u.width) ?? 1, f = (p = (y = e.gridStyle) == null ? void 0 : y.lineDash) != null && p.length ? ` stroke-dasharray="${e.gridStyle.lineDash.join(",")}"` : "";
1431
+ for (let v = 1; v <= e.gridLevels; v++) {
1432
+ const b = v / e.gridLevels * c, k = [];
1433
+ for (let C = 0; C < a; C++) {
1434
+ const A = C * l - Math.PI / 2;
1435
+ k.push(`${i(s + b * Math.cos(A))},${i(r + b * Math.sin(A))}`);
1436
+ }
1437
+ o.push(
1438
+ "grid",
1439
+ `<polygon points="${k.join(" ")}" fill="none" stroke="${h}" stroke-width="${d}"${f}/>`
1440
+ );
1441
+ }
1442
+ for (let v = 0; v < a; v++) {
1443
+ const b = v * l - Math.PI / 2, k = s + c * Math.cos(b), C = r + c * Math.sin(b);
1444
+ if (o.push(
1445
+ "grid",
1446
+ `<line x1="${i(s)}" y1="${i(r)}" x2="${i(k)}" y2="${i(C)}" stroke="${h}" stroke-width="${d}"/>`
1447
+ ), e.showLabels) {
1448
+ const A = c + 25, S = s + A * Math.cos(b), E = r + A * Math.sin(b), R = (($ = e.labelStyle) == null ? void 0 : $.color) ?? "#94a3b8", D = ((m = e.labelStyle) == null ? void 0 : m.fontSize) ?? 12, z = ((w = e.labelStyle) == null ? void 0 : w.fontFamily) ?? "sans-serif";
1449
+ o.push(
1450
+ "axes",
1451
+ `<text x="${i(S)}" y="${i(E)}" fill="${R}" font-size="${D}" font-family="${N(z)}" text-anchor="${hn(b)}" dominant-baseline="${fn(b)}">${N(e.categories[v])}</text>`
1452
+ );
1453
+ }
1454
+ }
1455
+ for (const v of e.series)
1456
+ un(o, e, v, s, r, c, l);
1457
+ }
1458
+ function un(t, o, e, n, s, r, c) {
1459
+ var u, y, p, $, m, w;
1460
+ if (e.points.length === 0) return;
1461
+ const a = [];
1462
+ for (let v = 0; v < o.categories.length; v++) {
1463
+ const b = o.categories[v], k = e.points.find((E) => E.category === b), A = (k ? k.value : 0) / o.maxValue * r, S = v * c - Math.PI / 2;
1464
+ a.push(`${i(n + A * Math.cos(S))},${i(s + A * Math.sin(S))}`);
1465
+ }
1466
+ const l = ((u = e.style) == null ? void 0 : u.color) ?? "#00f2ff", h = ((y = e.style) == null ? void 0 : y.fillColor) ?? ((p = e.style) != null && p.color ? `${e.style.color}33` : "rgba(0, 242, 255, 0.2)"), d = (($ = e.style) == null ? void 0 : $.opacity) ?? 1, f = ((m = e.style) == null ? void 0 : m.width) ?? 2, g = ((w = e.style) == null ? void 0 : w.pointSize) ?? 0;
1467
+ if (t.push(
1468
+ "series",
1469
+ `<polygon points="${a.join(" ")}" fill="${h}" stroke="${l}" stroke-width="${f}" stroke-opacity="${d}" fill-opacity="${d}"/>`
1470
+ ), g > 0) {
1471
+ const v = g / 2;
1472
+ for (let b = 0; b < o.categories.length; b++) {
1473
+ const k = o.categories[b], C = e.points.find((z) => z.category === k), S = (C ? C.value : 0) / o.maxValue * r, E = b * c - Math.PI / 2, R = n + S * Math.cos(E), D = s + S * Math.sin(E);
1474
+ t.push("series", `<circle cx="${i(R)}" cy="${i(D)}" r="${i(v)}" fill="${l}"/>`);
1475
+ }
1476
+ }
1477
+ }
1478
+ const Fe = /* @__PURE__ */ new Map();
1479
+ function Re(t, o) {
1480
+ Fe.set(t, o);
1481
+ }
1482
+ function yn(t, o) {
1483
+ for (const [, e] of Fe)
1484
+ e({ ...t, builder: o });
1485
+ if (t._elements && t._layer)
1486
+ for (const e of t._elements)
1487
+ o.push(t._layer, e);
1488
+ }
1489
+ Re("velo-plot-annotations", (t) => {
1490
+ const o = t._annotations;
1491
+ o != null && o.length && Ee(t, o);
1492
+ });
1493
+ Re("velo-plot-trade-markers", Te);
1494
+ function gn(t, o) {
1495
+ var c, a, l, h, d, f;
1496
+ const e = t.get("velo-plot-annotations"), n = (a = (c = e == null ? void 0 : e.api) == null ? void 0 : c.getManager) == null ? void 0 : a.call(c);
1497
+ n && o.builder && ((l = o.exportContext) == null ? void 0 : l.options.includeAnnotations) !== !1 && Ee(o, n.getAll()), Te(o);
1498
+ const s = t.get("velo-plot-radar"), r = (d = (h = s == null ? void 0 : s.api) == null ? void 0 : h.getSVGExportData) == null ? void 0 : d.call(h);
1499
+ r && o.builder && o.exportContext && dn(o.exportContext, o.builder, r), yn(o, o.builder), (f = t.notifyExportSVG) == null || f.call(t, o);
1500
+ }
1501
+ function pn(t, o, e) {
1502
+ if (!t.builder) return;
1503
+ const n = t.plotArea.x + t.plotArea.width / 2, s = t.plotArea.y + t.plotArea.height / 2, r = (e == null ? void 0 : e.opacity) ?? 0.12, c = (e == null ? void 0 : e.rotation) ?? -30, a = (e == null ? void 0 : e.color) ?? "#ffffff";
1504
+ t.builder.push(
1505
+ "plugins",
1506
+ `<text x="${i(n)}" y="${i(s)}" fill="${a}" fill-opacity="${r}" font-size="48" font-weight="700" text-anchor="middle" transform="rotate(${c} ${i(n)} ${i(s)})">${N(o)}</text>`
1507
+ );
1508
+ }
1509
+ function li(t, o) {
1510
+ if (!t.builder) return;
1511
+ const { plotArea: e } = t, n = t.yScales.values().next().value;
1512
+ for (const s of o) {
1513
+ const r = s.color ?? "rgba(59,130,246,0.1)";
1514
+ if (s.axis === "x") {
1515
+ const c = t.xScale.transform(s.min), a = t.xScale.transform(s.max);
1516
+ t.builder.push(
1517
+ "plugins",
1518
+ `<rect x="${i(Math.min(c, a))}" y="${i(e.y)}" width="${i(Math.abs(a - c))}" height="${i(e.height)}" fill="${r}"/>`
1519
+ );
1520
+ } else if (n) {
1521
+ const c = n.transform(s.min), a = n.transform(s.max);
1522
+ t.builder.push(
1523
+ "plugins",
1524
+ `<rect x="${i(e.x)}" y="${i(Math.min(c, a))}" width="${i(e.width)}" height="${i(Math.abs(a - c))}" fill="${r}"/>`
1525
+ );
1526
+ }
1527
+ }
1528
+ }
1529
+ function $n(t) {
1530
+ const o = new to(
1531
+ t.width,
1532
+ t.height,
1533
+ t.theme.xAxis.fontFamily || "sans-serif"
1534
+ );
1535
+ if (o.resetGradientCounter(), Xo(t, o), an(t, o), t.options.includeOverlays !== !1) {
1536
+ const e = {
1537
+ series: t.series,
1538
+ viewBounds: t.viewBounds,
1539
+ plotArea: t.plotArea,
1540
+ xScale: t.xScale,
1541
+ yScales: t.yAxes,
1542
+ theme: t.theme,
1543
+ width: t.width,
1544
+ height: t.height,
1545
+ builder: o,
1546
+ exportContext: t
1547
+ };
1548
+ t.pluginManager && gn(t.pluginManager, e), t.options.watermarkText && pn(e, t.options.watermarkText, { opacity: 0.4, rotation: 0, color: "rgba(128,128,128,0.4)" });
1549
+ }
1550
+ return o.build(t.theme.backgroundColor, t.options.ariaLabel);
1551
+ }
1552
+ function mn(t) {
1553
+ const e = {
1554
+ id: t.seriesId ?? `${t.id}-indicator`,
1555
+ data: t.data,
1556
+ style: t.style,
1557
+ name: t.label
1558
+ }, n = St(e);
1559
+ return {
1560
+ id: t.id,
1561
+ height: t.height ?? 0.25,
1562
+ showXAxis: t.showXAxis,
1563
+ yRange: t.yRange,
1564
+ chart: {
1565
+ yAxis: {
1566
+ label: t.label ?? "Indicator",
1567
+ auto: t.yRange === void 0 || t.yRange === "auto",
1568
+ tickCount: t.tickCount ?? 5,
1569
+ scientific: !1
1570
+ },
1571
+ // X-axis visibility is owned by createStackedChart (sharedXAxis / showXAxis).
1572
+ // Do not force labels off here — the new bottom pane must show dates.
1573
+ animations: !1,
1574
+ loading: !1,
1575
+ showLegend: !1
1576
+ },
1577
+ series: n
1578
+ };
1579
+ }
1580
+ const xn = 5e3;
1581
+ let gt = null, Tt = !1;
1582
+ function Be(t) {
1583
+ const o = performance.now();
1584
+ switch (t.indicator) {
1585
+ case "rsi":
1586
+ return {
1587
+ id: t.id,
1588
+ type: "indicator-result",
1589
+ indicator: "rsi",
1590
+ values: lo(t.data, t.period ?? 14),
1591
+ duration: performance.now() - o
1592
+ };
1593
+ case "sma":
1594
+ return {
1595
+ id: t.id,
1596
+ type: "indicator-result",
1597
+ indicator: "sma",
1598
+ values: co(t.data, t.period ?? 14),
1599
+ duration: performance.now() - o
1600
+ };
1601
+ case "ema":
1602
+ return {
1603
+ id: t.id,
1604
+ type: "indicator-result",
1605
+ indicator: "ema",
1606
+ values: ao(t.data, t.period ?? 14),
1607
+ duration: performance.now() - o
1608
+ };
1609
+ case "macd": {
1610
+ const e = ro(
1611
+ t.data,
1612
+ t.fastPeriod ?? 12,
1613
+ t.slowPeriod ?? 26,
1614
+ t.signalPeriod ?? 9
1615
+ );
1616
+ return {
1617
+ id: t.id,
1618
+ type: "indicator-result",
1619
+ indicator: "macd",
1620
+ ...e,
1621
+ duration: performance.now() - o
1622
+ };
1623
+ }
1624
+ case "bollingerBands": {
1625
+ const e = so(t.data, t.period ?? 20, t.stdDev ?? 2);
1626
+ return {
1627
+ id: t.id,
1628
+ type: "indicator-result",
1629
+ indicator: "bollingerBands",
1630
+ ...e,
1631
+ duration: performance.now() - o
1632
+ };
1633
+ }
1634
+ default:
1635
+ throw new Error(`Unknown indicator: ${t.indicator}`);
1636
+ }
1637
+ }
1638
+ function wn() {
1639
+ return gt || (gt = new uo(
1640
+ () => new Worker(new URL(
1641
+ /* @vite-ignore */
1642
+ "/assets/indicator.worker-bv0zC4EX.js",
1643
+ import.meta.url
1644
+ ), { type: "module" }),
1645
+ {
1646
+ poolSize: 2,
1647
+ syncFallback: !0,
1648
+ // Short timeout — if the worker is silent (broken Vite URL), don't stall UI.
1649
+ timeoutMs: 250,
1650
+ syncHandler: Be
1651
+ }
1652
+ )), gt;
1653
+ }
1654
+ function Mt(t) {
1655
+ return t instanceof Float32Array || t instanceof Float64Array ? t : Float32Array.from(t);
1656
+ }
1657
+ function he(t) {
1658
+ return {
1659
+ values: t.values,
1660
+ signal: t.signal,
1661
+ upper: t.upper,
1662
+ lower: t.lower,
1663
+ histogram: t.histogram,
1664
+ duration: t.duration
1665
+ };
1666
+ }
1667
+ async function At(t) {
1668
+ const e = { id: fo(t.indicator), type: "indicator", ...t };
1669
+ if (Tt || t.data.length < xn)
1670
+ return he(Be(e));
1671
+ const n = performance.now(), s = await wn().run(e);
1672
+ return performance.now() - n >= 200 && (Tt = !0), he(s);
1673
+ }
1674
+ async function vn(t, o = 14) {
1675
+ return At({ indicator: "rsi", data: Mt(t), period: o });
1676
+ }
1677
+ async function bn(t, o = 14) {
1678
+ return At({ indicator: "sma", data: Mt(t), period: o });
1679
+ }
1680
+ async function kn(t, o = 14) {
1681
+ return At({ indicator: "ema", data: Mt(t), period: o });
1682
+ }
1683
+ async function Sn(t, o = 12, e = 26, n = 9) {
1684
+ return At({
1685
+ indicator: "macd",
1686
+ data: Mt(t),
1687
+ fastPeriod: o,
1688
+ slowPeriod: e,
1689
+ signalPeriod: n
1690
+ });
1691
+ }
1692
+ async function Mn(t, o = 20, e = 2) {
1693
+ return At({ indicator: "bollingerBands", data: Mt(t), period: o, stdDev: e });
1694
+ }
1695
+ function hi() {
1696
+ gt == null || gt.destroy(), gt = null, Tt = !1;
1697
+ }
1698
+ function An(t) {
1699
+ return t === "bollingerBands" ? "bollinger" : t;
1700
+ }
1701
+ function We(t) {
1702
+ const o = t.getData(), e = o.x;
1703
+ if (!(e != null && e.length))
1704
+ throw new Error("[addIndicator] Source series has no X data");
1705
+ const n = t.getType();
1706
+ let s;
1707
+ if (n === "candlestick" ? s = o.close ?? o.y : s = o.y, !(s != null && s.length))
1708
+ throw new Error("[addIndicator] Source series has no price/Y data");
1709
+ return { x: e, prices: s };
1710
+ }
1711
+ function Cn(t) {
1712
+ const o = t.getData(), e = o.x;
1713
+ if (!(e != null && e.length))
1714
+ throw new Error("[addIndicator] Source series has no X data");
1715
+ const n = o.open ?? o.y, s = o.high ?? o.y, r = o.low ?? o.y, c = o.close ?? o.y;
1716
+ if (!(n != null && n.length) || !(s != null && s.length) || !(r != null && r.length) || !(c != null && c.length))
1717
+ throw new Error("[addIndicator] Source series has no OHLC data — use candlestick");
1718
+ return { x: e, open: n, high: s, low: r, close: c };
1719
+ }
1720
+ function Rt(t, o) {
1721
+ if (o) {
1722
+ const s = t.getSeries(o);
1723
+ if (!s) throw new Error(`[addIndicator] Source series "${o}" not found`);
1724
+ return s;
1725
+ }
1726
+ const n = t.getAllSeries().find((s) => {
1727
+ const r = s.getType();
1728
+ return r === "candlestick" || r === "line" || r === "bar";
1729
+ });
1730
+ if (!n)
1731
+ throw new Error("[addIndicator] No line/candlestick/bar series found — pass sourceSeriesId");
1732
+ return n;
1733
+ }
1734
+ async function Oe(t, o, e, n = {}, s) {
1735
+ const r = An(t), c = n.id ?? r, a = o instanceof Float32Array || o instanceof Float64Array ? o : Float32Array.from(o);
1736
+ switch (r) {
1737
+ case "rsi": {
1738
+ const l = n.period ?? 14, { values: h } = await vn(e, l);
1739
+ return {
1740
+ id: c,
1741
+ preset: "rsi",
1742
+ placement: "oscillator",
1743
+ yRange: [0, 100],
1744
+ data: {
1745
+ x: a,
1746
+ lines: [{ id: "rsi", y: h, color: "#ab47bc", width: 1.5 }],
1747
+ referenceLines: [
1748
+ { y: 70, color: "rgba(239, 83, 80, 0.5)", dash: [4, 4] },
1749
+ { y: 30, color: "rgba(38, 166, 154, 0.5)", dash: [4, 4] }
1750
+ ]
1751
+ }
1752
+ };
1753
+ }
1754
+ case "macd": {
1755
+ const l = n.fastPeriod ?? 12, h = n.slowPeriod ?? 26, d = n.signalPeriod ?? 9, f = await Sn(e, l, h, d);
1756
+ return {
1757
+ id: c,
1758
+ preset: "macd",
1759
+ placement: "oscillator",
1760
+ data: {
1761
+ x: a,
1762
+ histogram: {
1763
+ y: f.histogram ?? new Float32Array(e.length),
1764
+ positiveColor: "#26a69a",
1765
+ negativeColor: "#ef5350"
1766
+ },
1767
+ lines: [
1768
+ { id: "macd", y: f.values, color: "#42a5f5", width: 1.5 },
1769
+ { id: "signal", y: f.signal ?? f.values, color: "#ff9800", width: 1 }
1770
+ ],
1771
+ baseline: 0
1772
+ }
1773
+ };
1774
+ }
1775
+ case "bollinger": {
1776
+ const l = n.period ?? 20, h = n.stdDev ?? 2, d = await Mn(e, l, h), f = d.upper ?? d.values, g = d.lower ?? d.values;
1777
+ return {
1778
+ id: c,
1779
+ preset: "bollinger",
1780
+ placement: "overlay",
1781
+ data: {
1782
+ x: a,
1783
+ lines: [{ id: "mid", y: d.values, color: "rgba(99, 102, 241, 0.9)", width: 1 }],
1784
+ fills: [
1785
+ {
1786
+ id: "band",
1787
+ upper: f,
1788
+ lower: g,
1789
+ color: "rgba(99, 102, 241, 0.15)"
1790
+ }
1791
+ ]
1792
+ }
1793
+ };
1794
+ }
1795
+ case "ema": {
1796
+ const l = n.period ?? 14, { values: h } = await kn(e, l);
1797
+ return {
1798
+ id: c,
1799
+ preset: "ema",
1800
+ placement: "overlay",
1801
+ data: {
1802
+ x: a,
1803
+ lines: [{ id: "ema", y: h, color: "#ffd54f", width: 1.5 }]
1804
+ }
1805
+ };
1806
+ }
1807
+ case "sma": {
1808
+ const l = n.period ?? 14, { values: h } = await bn(e, l);
1809
+ return {
1810
+ id: c,
1811
+ preset: "sma",
1812
+ placement: "overlay",
1813
+ data: {
1814
+ x: a,
1815
+ lines: [{ id: "sma", y: h, color: "#4fc3f7", width: 1.5 }]
1816
+ }
1817
+ };
1818
+ }
1819
+ case "stochastic": {
1820
+ if (!s)
1821
+ throw new Error("[addIndicator] stochastic requires a candlestick source series");
1822
+ const l = Cn(s), h = n.period ?? 14, d = n.signalPeriod ?? 3, f = ho(l, h, d);
1823
+ return {
1824
+ id: c,
1825
+ preset: "stochastic",
1826
+ placement: "oscillator",
1827
+ yRange: [0, 100],
1828
+ data: {
1829
+ x: a,
1830
+ lines: [
1831
+ { id: "k", y: f.values, color: "#42a5f5", width: 1.5 },
1832
+ { id: "d", y: f.signal ?? f.values, color: "#ff9800", width: 1 }
1833
+ ],
1834
+ referenceLines: [
1835
+ { y: 80, color: "rgba(239, 83, 80, 0.5)", dash: [4, 4] },
1836
+ { y: 20, color: "rgba(38, 166, 154, 0.5)", dash: [4, 4] }
1837
+ ]
1838
+ }
1839
+ };
1840
+ }
1841
+ default:
1842
+ throw new Error(`[addIndicator] Unknown preset: ${t}`);
1843
+ }
1844
+ }
1845
+ function Pn(t, o) {
1846
+ for (const e of [...t.getAllSeries()]) {
1847
+ const n = e.getId();
1848
+ (n === o || n.startsWith(`${o}-`)) && t.removeSeries(n);
1849
+ }
1850
+ }
1851
+ async function In(t, o, e = {}) {
1852
+ const n = Rt(t, e.sourceSeriesId), { x: s, prices: r } = We(n);
1853
+ return Oe(o, s, r, e, n);
1854
+ }
1855
+ async function Ln(t, o, e = {}) {
1856
+ var l;
1857
+ if (e.pane === "new")
1858
+ throw new Error(
1859
+ "[addIndicator] pane: 'new' requires createStackedChart — use buildIndicatorPaneFromPreset() instead"
1860
+ );
1861
+ const n = Rt(t, e.sourceSeriesId), s = e.yAxisId ?? ((l = n.getYAxisId) == null ? void 0 : l.call(n)), r = await In(t, o, e);
1862
+ Pn(t, r.id);
1863
+ const c = St({
1864
+ id: r.id,
1865
+ data: r.data,
1866
+ name: e.label ?? r.id.toUpperCase()
1867
+ }), a = [];
1868
+ for (const h of c)
1869
+ t.addSeries({
1870
+ ...h,
1871
+ yAxisId: s ?? h.yAxisId
1872
+ }), a.push(h.id);
1873
+ return {
1874
+ id: r.id,
1875
+ preset: o,
1876
+ placement: r.placement,
1877
+ seriesIds: a
1878
+ };
1879
+ }
1880
+ async function Dn(t, o, e, n, s) {
1881
+ const r = await Oe(t, o, e, n, s);
1882
+ return mn({
1883
+ id: n.id ?? r.id,
1884
+ height: n.height ?? 0.25,
1885
+ label: n.label ?? r.id.toUpperCase(),
1886
+ yRange: n.yRange ?? r.yRange ?? "auto",
1887
+ tickCount: n.tickCount,
1888
+ showXAxis: n.showXAxis,
1889
+ seriesId: n.seriesId,
1890
+ style: n.style,
1891
+ data: r.data
1892
+ });
1893
+ }
1894
+ const Ct = 5, Bt = 1 / 6, He = { top: 4, bottom: 8, left: 4 }, Ye = { bottom: 55 };
1895
+ function zn(t) {
1896
+ if (typeof t == "number") return t;
1897
+ switch (t) {
1898
+ case "8k":
1899
+ return 8;
1900
+ case "4k":
1901
+ return 4;
1902
+ case "2k":
1903
+ return 2;
1904
+ default:
1905
+ return 1;
1906
+ }
1907
+ }
1908
+ function En(t) {
1909
+ return new Promise((o, e) => {
1910
+ const n = new Image();
1911
+ n.onload = () => o(n), n.onerror = e, n.src = t;
1912
+ });
1913
+ }
1914
+ function fe(t, o) {
1915
+ const e = t.getBoundingClientRect();
1916
+ return {
1917
+ x: e.left - o.left,
1918
+ y: e.top - o.top,
1919
+ width: e.width,
1920
+ height: e.height
1921
+ };
1922
+ }
1923
+ async function Tn(t, o, e, n, s, r = {}) {
1924
+ var $;
1925
+ const {
1926
+ format: c = "png",
1927
+ quality: a = 0.92,
1928
+ resolution: l = "standard",
1929
+ includeBackground: h = !0,
1930
+ includeDividers: d = !0,
1931
+ transparent: f = !1
1932
+ } = r, g = zn(l), y = ((($ = e[0]) == null ? void 0 : $.getDPR()) ?? (typeof window < "u" ? window.devicePixelRatio : 1)) * g, p = e.map((m) => m.getDPR());
1933
+ try {
1934
+ if (g > 1) {
1935
+ for (const S of e)
1936
+ typeof S.setDevicePixelRatioOverride == "function" ? S.setDevicePixelRatioOverride(y) : S.setDPR(y), S.render();
1937
+ await new Promise((S) => requestAnimationFrame(S)), await new Promise((S) => requestAnimationFrame(S)), await new Promise((S) => setTimeout(S, 50));
1938
+ }
1939
+ const m = t.getBoundingClientRect(), w = Math.max(1, Math.round(m.width * y)), v = Math.max(1, Math.round(m.height * y)), b = document.createElement("canvas");
1940
+ b.width = w, b.height = v;
1941
+ const k = b.getContext("2d");
1942
+ if (!k) throw new Error("Failed to create export canvas");
1943
+ !f && h && (k.fillStyle = s || "#ffffff", k.fillRect(0, 0, w, v));
1944
+ const C = c === "jpeg" ? "jpeg" : "png";
1945
+ for (let S = 0; S < o.length; S++) {
1946
+ const E = fe(o[S], m), R = e[S].exportImage(C), D = await En(R);
1947
+ k.drawImage(
1948
+ D,
1949
+ Math.round(E.x * y),
1950
+ Math.round(E.y * y),
1951
+ Math.round(E.width * y),
1952
+ Math.round(E.height * y)
1953
+ );
1954
+ }
1955
+ if (d && n.length) {
1956
+ k.fillStyle = "rgba(128, 128, 128, 0.35)";
1957
+ for (const S of n) {
1958
+ const E = fe(S, m);
1959
+ k.fillRect(
1960
+ Math.round(E.x * y),
1961
+ Math.round(E.y * y),
1962
+ Math.max(1, Math.round(E.width * y)),
1963
+ Math.max(1, Math.round(E.height * y))
1964
+ );
1965
+ }
1966
+ }
1967
+ const A = c === "jpeg" ? "image/jpeg" : c === "webp" ? "image/webp" : "image/png";
1968
+ return b.toDataURL(A, a);
1969
+ } finally {
1970
+ if (g > 1)
1971
+ for (let m = 0; m < e.length; m++)
1972
+ typeof e[m].setDevicePixelRatioOverride == "function" ? e[m].setDevicePixelRatioOverride(null) : e[m].setDPR(p[m]), e[m].render();
1973
+ }
1974
+ }
1975
+ function Xe(t, o) {
1976
+ const e = t.getBoundingClientRect();
1977
+ return {
1978
+ x: e.left - o.left,
1979
+ y: e.top - o.top,
1980
+ width: e.width,
1981
+ height: e.height
1982
+ };
1983
+ }
1984
+ function Fn(t, o, e) {
1985
+ const n = t.getBoundingClientRect();
1986
+ return o.map((s, r) => {
1987
+ const c = Xe(s, n);
1988
+ return {
1989
+ chart: e[r],
1990
+ wrapper: s,
1991
+ offsetX: c.x,
1992
+ offsetY: c.y,
1993
+ width: c.width,
1994
+ height: c.height
1995
+ };
1996
+ });
1997
+ }
1998
+ function Rn(t, o, e, n, s = {}) {
1999
+ var g, u;
2000
+ const r = t.getBoundingClientRect(), c = Math.max(1, Math.round(r.width)), a = Math.max(1, Math.round(r.height)), l = s.backgroundColor ?? ((u = (g = e[0]) == null ? void 0 : g.theme) == null ? void 0 : u.backgroundColor) ?? "#111111", h = s.includeBackground !== !1, d = Fn(t, o, e), f = [
2001
+ `<svg width="${c}" height="${a}" viewBox="0 0 ${c} ${a}" xmlns="http://www.w3.org/2000/svg">`
2002
+ ];
2003
+ h && f.push(`<rect width="100%" height="100%" fill="${l}"/>`);
2004
+ for (const y of d) {
2005
+ const p = y.chart, m = $n(
2006
+ bo(p, {
2007
+ ...s,
2008
+ includeLegend: s.includeLegend ?? p.showLegend
2009
+ })
2010
+ ).replace(/^<svg[^>]*>/, "").replace(/<\/svg>\s*$/, "");
2011
+ f.push(`<g transform="translate(${y.offsetX.toFixed(1)},${y.offsetY.toFixed(1)})">`), f.push(m), f.push("</g>");
2012
+ }
2013
+ if (s.includeDividers !== !1)
2014
+ for (const y of n) {
2015
+ const p = Xe(y, r);
2016
+ p.height <= p.width ? f.push(
2017
+ `<line x1="${p.x.toFixed(1)}" y1="${(p.y + p.height / 2).toFixed(1)}" x2="${(p.x + p.width).toFixed(1)}" y2="${(p.y + p.height / 2).toFixed(1)}" stroke="rgba(128,128,128,0.5)" stroke-width="1"/>`
2018
+ ) : f.push(
2019
+ `<line x1="${(p.x + p.width / 2).toFixed(1)}" y1="${p.y.toFixed(1)}" x2="${(p.x + p.width / 2).toFixed(1)}" y2="${(p.y + p.height).toFixed(1)}" stroke="rgba(128,128,128,0.5)" stroke-width="1"/>`
2020
+ );
2021
+ }
2022
+ return f.push("</svg>"), f.join(`
2023
+ `);
2024
+ }
2025
+ function de(t, o, e, n, s, r = {}) {
2026
+ return Rn(t, o, e, n, {
2027
+ ...r,
2028
+ backgroundColor: r.backgroundColor ?? s
2029
+ });
2030
+ }
2031
+ const U = "velo-pane-divider", st = "velo-pane-resizing";
2032
+ function Bn(t) {
2033
+ if (typeof document > "u") return;
2034
+ let o = document.getElementById("velo-pane-divider-styles");
2035
+ o || (o = document.createElement("style"), o.id = "velo-pane-divider-styles", document.head.appendChild(o));
2036
+ const n = t === "horizontal" ? "ew-resize" : "ns-resize";
2037
+ o.textContent = `
2038
+ .${U} {
2039
+ flex: 0 0 var(--velo-divider-size, 6px);
2040
+ position: relative;
2041
+ cursor: ${n};
2042
+ touch-action: none;
2043
+ z-index: 20;
2044
+ background: transparent;
2045
+ user-select: none;
2046
+ }
2047
+ .${U}::after {
2048
+ content: "";
2049
+ position: absolute;
2050
+ background: rgba(128, 128, 128, 0.35);
2051
+ transition: background 0.15s;
2052
+ }
2053
+ .${U}[data-direction="vertical"]::after {
2054
+ left: 0;
2055
+ right: 0;
2056
+ top: 50%;
2057
+ transform: translateY(-50%);
2058
+ height: 1px;
2059
+ }
2060
+ .${U}[data-direction="horizontal"]::after {
2061
+ top: 0;
2062
+ bottom: 0;
2063
+ left: 50%;
2064
+ transform: translateX(-50%);
2065
+ width: 1px;
2066
+ }
2067
+ .${U}:hover::after,
2068
+ .${st} .${U}::after {
2069
+ background: rgba(0, 242, 255, 0.65);
2070
+ }
2071
+ .${U}[data-direction="vertical"]:hover::after,
2072
+ .${st} .${U}[data-direction="vertical"]::after {
2073
+ height: 2px;
2074
+ }
2075
+ .${U}[data-direction="horizontal"]:hover::after,
2076
+ .${st} .${U}[data-direction="horizontal"]::after {
2077
+ width: 2px;
2078
+ }
2079
+ .${U}-handle {
2080
+ position: absolute;
2081
+ left: 50%;
2082
+ top: 50%;
2083
+ transform: translate(-50%, -50%);
2084
+ width: 32px;
2085
+ height: 12px;
2086
+ display: flex;
2087
+ align-items: center;
2088
+ justify-content: center;
2089
+ opacity: 0;
2090
+ transition: opacity 0.15s;
2091
+ pointer-events: none;
2092
+ color: rgba(0, 242, 255, 0.9);
2093
+ font-size: 10px;
2094
+ line-height: 1;
2095
+ }
2096
+ .${U}:hover .${U}-handle,
2097
+ .${st} .${U}-handle {
2098
+ opacity: 1;
2099
+ }
2100
+ .${st} {
2101
+ cursor: ${n} !important;
2102
+ }
2103
+ .${st} * {
2104
+ cursor: ${n} !important;
2105
+ }
2106
+ .${st} [data-pane-id] {
2107
+ position: relative !important;
2108
+ overflow: hidden !important;
2109
+ }
2110
+ `;
2111
+ }
2112
+ function Wn(t, o) {
2113
+ return t.map(
2114
+ (e) => o ? e.getBoundingClientRect().width : e.getBoundingClientRect().height
2115
+ );
2116
+ }
2117
+ function On(t, o, e, n, s) {
2118
+ return (t == null ? void 0 : t(o, e)) ?? Wn(n, s);
2119
+ }
2120
+ function Hn(t, o, e) {
2121
+ const n = document.createElement("div");
2122
+ n.className = U, n.dataset.dividerIndex = String(t), n.dataset.direction = e, n.style.setProperty("--velo-divider-size", `${o}px`);
2123
+ const s = document.createElement("div");
2124
+ return s.className = `${U}-handle`, s.textContent = e === "horizontal" ? "⇔" : "⇕", n.appendChild(s), n;
2125
+ }
2126
+ function Yn(t, o) {
2127
+ const e = o === "horizontal" ? "min-width:0;" : "min-height:0;";
2128
+ return typeof t == "number" ? `flex:${t} 1 0;${e}` : `flex:1 1 ${t};${e}`;
2129
+ }
2130
+ function Ge(t, o, e = Bt, n = 0) {
2131
+ if (o < 1 || t <= 0) return 1;
2132
+ const s = t * e, r = Math.max(n, s);
2133
+ return Math.min(r, t / o);
2134
+ }
2135
+ function Xn(t, o, e = Bt, n = 0) {
2136
+ return Ge(t, o, e, n);
2137
+ }
2138
+ function zt(t, o) {
2139
+ const e = t.length;
2140
+ if (e === 0) return t;
2141
+ const n = Math.max(1, Math.round(o)), s = t.reduce((l, h) => l + h, 0);
2142
+ if (s <= 0) {
2143
+ const l = Math.floor(n / e), h = t.map(() => l);
2144
+ return h[e - 1] = n - l * (e - 1), h;
2145
+ }
2146
+ const r = t.map((l) => l / s * n), c = [];
2147
+ let a = 0;
2148
+ for (let l = 0; l < e - 1; l++)
2149
+ c.push(Math.max(1, Math.round(r[l]))), a += c[l];
2150
+ return c.push(Math.max(1, n - a)), c;
2151
+ }
2152
+ function Gn(t, o, e, n, s = {}) {
2153
+ const r = s.direction ?? "vertical", c = r === "horizontal";
2154
+ Bn(r);
2155
+ const a = s.minPaneRatio ?? Bt, l = s.minPanePx ?? 0, h = s.dividerSize ?? 6, d = o.length, f = ($) => c ? Xn($, d, a, l) : Ge($, d, a, l), g = [], u = [];
2156
+ if (o.length < 2)
2157
+ return { dividers: g, destroy: () => {
2158
+ } };
2159
+ const y = () => {
2160
+ const $ = g.length * h, m = c ? t.clientWidth : t.clientHeight;
2161
+ return Math.max(1, m - $);
2162
+ }, p = ($, m, w, v) => {
2163
+ var D;
2164
+ const b = y(), k = f(b), C = v.reduce(
2165
+ (z, T, F) => F === $ || F === m ? z : z + T,
2166
+ 0
2167
+ ), A = b - C;
2168
+ let S = v[$] + w;
2169
+ S = Math.max(k, Math.min(A - k, S));
2170
+ const E = A - S;
2171
+ v[$] = S, v[m] = E;
2172
+ const R = n.reduce((z, T) => z + T, 0);
2173
+ if (n[$] = S / b * R, n[m] = E / b * R, (D = s.onDragMove) == null || D.call(s, v, $, m), s.onResize) {
2174
+ const z = {};
2175
+ for (let T = 0; T < e.length; T++)
2176
+ z[e[T]] = n[T];
2177
+ s.onResize(z);
2178
+ }
2179
+ };
2180
+ for (let $ = 0; $ < o.length - 1; $++) {
2181
+ const m = Hn($, h, r);
2182
+ o[$].after(m), g.push(m);
2183
+ const v = (b) => {
2184
+ var E;
2185
+ b.preventDefault(), m.setPointerCapture(b.pointerId), t.classList.add(st);
2186
+ const k = On(
2187
+ s.onDragStart,
2188
+ $,
2189
+ $ + 1,
2190
+ o,
2191
+ c
2192
+ );
2193
+ (E = s.onDragMove) == null || E.call(s, k, $, $ + 1);
2194
+ let C = c ? b.clientX : b.clientY;
2195
+ const A = (R) => {
2196
+ const D = c ? R.clientX : R.clientY, z = D - C;
2197
+ C = D, z !== 0 && p($, $ + 1, z, k);
2198
+ }, S = (R) => {
2199
+ var D;
2200
+ m.releasePointerCapture(R.pointerId), t.classList.remove(st), m.removeEventListener("pointermove", A), m.removeEventListener("pointerup", S), m.removeEventListener("pointercancel", S), (D = s.onDragEnd) == null || D.call(s, k);
2201
+ };
2202
+ m.addEventListener("pointermove", A), m.addEventListener("pointerup", S), m.addEventListener("pointercancel", S);
2203
+ };
2204
+ m.addEventListener("pointerdown", v), u.push(() => m.removeEventListener("pointerdown", v));
2205
+ }
2206
+ return {
2207
+ dividers: g,
2208
+ destroy: () => {
2209
+ for (const $ of u) $();
2210
+ for (const $ of g) $.remove();
2211
+ t.classList.remove(st);
2212
+ }
2213
+ };
2214
+ }
2215
+ function Vn(t, o, e = "vertical") {
2216
+ for (let n = 0; n < t.length; n++)
2217
+ t[n].style.cssText = `${Yn(o[n], e)}position:relative;overflow:hidden;`;
2218
+ }
2219
+ function ue(t) {
2220
+ return typeof t == "number" ? t : 1;
2221
+ }
2222
+ function jn(t, o = 6) {
2223
+ if (!Number.isFinite(t) || t <= 0) return o;
2224
+ const e = Math.floor(t / 36);
2225
+ return Math.max(2, Math.min(o, e));
2226
+ }
2227
+ function _n(t, o = 8) {
2228
+ if (!Number.isFinite(t) || t <= 0) return o;
2229
+ const e = Math.floor(t / 72);
2230
+ return Math.max(2, Math.min(o, e));
2231
+ }
2232
+ function ye(t) {
2233
+ var e;
2234
+ return t ? ((e = (Array.isArray(t) ? t : [t])[0]) == null ? void 0 : e.tickCount) ?? 6 : 6;
2235
+ }
2236
+ function Nn(t) {
2237
+ const o = t.wrapper.clientHeight, e = t.wrapper.clientWidth, n = jn(o, t.baseYTickCount);
2238
+ if (t.chart.updateYAxis("default", { tickCount: n }), t.showXAxis) {
2239
+ const s = _n(e, t.baseXTickCount);
2240
+ t.chart.updateXAxis({ tickCount: s });
2241
+ }
2242
+ }
2243
+ function ge(t) {
2244
+ for (const o of t) Nn(o);
2245
+ }
2246
+ function Ve(t) {
2247
+ const o = t ? Array.isArray(t) ? t : [t] : [{}];
2248
+ let e = 0, n = 0;
2249
+ for (const s of o)
2250
+ s.position === "right" ? n++ : e++;
2251
+ return { left: Math.max(1, e), right: n };
2252
+ }
2253
+ function qn(t, o) {
2254
+ var n;
2255
+ let e = 0;
2256
+ for (const s of t) {
2257
+ const { left: r } = Ve((n = s.chart) == null ? void 0 : n.yAxis);
2258
+ e = Math.max(e, (r - 1) * 65);
2259
+ }
2260
+ return o + e;
2261
+ }
2262
+ function Un(t, o) {
2263
+ var n;
2264
+ let e = 0;
2265
+ for (const s of t) {
2266
+ const { right: r } = Ve((n = s.chart) == null ? void 0 : n.yAxis);
2267
+ e = Math.max(e, r * 65);
2268
+ }
2269
+ return o + e;
2270
+ }
2271
+ function Zn(t, o) {
2272
+ return `flex:${t} 1 0;${o === "horizontal" ? "min-width:0;" : "min-height:0;"}`;
2273
+ }
2274
+ function pe(t) {
2275
+ const o = t.reduce((e, n) => e + n, 0);
2276
+ if (o <= 0) {
2277
+ const e = 1 / Math.max(1, t.length);
2278
+ for (let n = 0; n < t.length; n++) t[n] = e;
2279
+ return;
2280
+ }
2281
+ for (let e = 0; e < t.length; e++) t[e] /= o;
2282
+ }
2283
+ function $e(t) {
2284
+ if (!(t != null && t.length)) return [];
2285
+ const o = [];
2286
+ for (const e of t)
2287
+ e.type === "indicator" ? o.push(...St(e)) : o.push(e);
2288
+ return o;
2289
+ }
2290
+ function me(t, o, e, n, s, r, c, a, l, h, d) {
2291
+ var F, Y, B, V, P, O, j, _, tt, et, ot, Q, Z, rt, nt;
2292
+ const f = n === 0, g = n === s - 1, u = l === "horizontal", p = !u && e.sharedXAxis !== "none" && !c, m = u && (e.sharedYAxis ?? "left") !== "none" && !a, v = (e.gap ?? 0) > 0 ? He : { top: 0, bottom: 0, left: 0 }, b = u ? {
2293
+ top: r.top,
2294
+ right: g ? r.right : v.left,
2295
+ left: m ? v.left : r.left,
2296
+ bottom: r.bottom
2297
+ } : {
2298
+ top: f ? r.top : v.top,
2299
+ right: r.right,
2300
+ left: r.left,
2301
+ bottom: p ? v.bottom : g ? ((Y = (F = e.layout) == null ? void 0 : F.margins) == null ? void 0 : Y.bottom) ?? Ye.bottom : r.bottom
2302
+ }, k = {
2303
+ ...d && ((V = (B = t.chart) == null ? void 0 : B.xAxis) == null ? void 0 : V.type) !== "time" ? d : {},
2304
+ ...e.xAxis ?? {},
2305
+ ...((P = t.chart) == null ? void 0 : P.xAxis) ?? {}
2306
+ }, C = {
2307
+ ...k,
2308
+ showLine: c ? k.showLine ?? !0 : !1,
2309
+ showTicks: c ? k.showTicks ?? !0 : !1,
2310
+ showLabels: c ? k.showLabels ?? !0 : !1
2311
+ }, A = ((O = t.chart) == null ? void 0 : O.yAxis) ?? {}, E = (Array.isArray(A) ? A : [A]).map((at) => ({
2312
+ ...at,
2313
+ showLine: a ? at.showLine ?? !0 : !1,
2314
+ showTicks: a ? at.showTicks ?? !0 : !1,
2315
+ showLabels: a ? at.showLabels ?? !0 : !1
2316
+ })), R = Array.isArray((j = t.chart) == null ? void 0 : j.yAxis) ? E : E[0];
2317
+ (t.interactive ?? !0) || (o.style.pointerEvents = "none");
2318
+ const z = t.chart ?? {};
2319
+ return {
2320
+ ...h && !z.renderer ? { ...z, renderer: h } : z,
2321
+ id: t.id,
2322
+ container: o,
2323
+ showLegend: ((_ = t.chart) == null ? void 0 : _.showLegend) ?? e.showLegend ?? !1,
2324
+ theme: ((tt = t.chart) == null ? void 0 : tt.theme) ?? e.theme,
2325
+ devicePixelRatio: e.devicePixelRatio ?? ((et = t.chart) == null ? void 0 : et.devicePixelRatio),
2326
+ loading: ((ot = t.chart) == null ? void 0 : ot.loading) ?? !1,
2327
+ xAxis: C,
2328
+ yAxis: R,
2329
+ layout: we({
2330
+ ...e.layout,
2331
+ ...(Q = t.chart) == null ? void 0 : Q.layout,
2332
+ margins: { ...b, ...(Z = e.layout) == null ? void 0 : Z.margins, ...(nt = (rt = t.chart) == null ? void 0 : rt.layout) == null ? void 0 : nt.margins }
2333
+ })
2334
+ };
2335
+ }
2336
+ function xt() {
2337
+ return "position:absolute;inset:0;width:100%;height:100%;min-width:0;min-height:0;";
2338
+ }
2339
+ function Et(t, o, e, n) {
2340
+ const s = o > 0 && e > 0 ? n === "horizontal" ? `margin-left:${o}px;` : `margin-top:${o}px;` : "";
2341
+ return `${Zn(t, n)}position:relative;overflow:hidden;${s}`;
2342
+ }
2343
+ function Qn(t, o, e) {
2344
+ return t === !1 ? {
2345
+ axis: "none",
2346
+ syncCursor: !1,
2347
+ syncZoom: !1,
2348
+ syncPan: !1,
2349
+ bidirectional: !0,
2350
+ masterId: void 0
2351
+ } : {
2352
+ axis: e === "horizontal" ? "y" : "x",
2353
+ bidirectional: !0,
2354
+ masterId: o,
2355
+ syncCursor: !0,
2356
+ syncZoom: !0,
2357
+ syncPan: !0,
2358
+ ...typeof t == "object" ? t : {}
2359
+ };
2360
+ }
2361
+ function fi(t) {
2362
+ var Vt, jt, _t, Nt, qt, Ut, Zt, Qt, Kt, Jt, te, ee;
2363
+ const { container: o, panes: e } = t;
2364
+ if (!o) throw new Error("[StackedChart] container is required");
2365
+ if (e.length < 1 || e.length > Ct)
2366
+ throw new Error(`[StackedChart] panes must be 1–${Ct}`);
2367
+ const n = t.masterPaneId ?? e[0].id, s = t.direction ?? "vertical", r = s === "horizontal", c = t.sharedXAxis ?? "bottom", a = t.sharedYAxis ?? "left", l = t.gap ?? 0, h = t.resizable, d = !!h, f = typeof h == "object" ? h.dividerSize ?? 6 : 6, g = (jt = (Vt = e.find((x) => {
2368
+ var M;
2369
+ return (M = x.chart) == null ? void 0 : M.renderer;
2370
+ })) == null ? void 0 : Vt.chart) == null ? void 0 : jt.renderer, u = e.find((x) => x.id === n) ?? e[0], y = ((Nt = (_t = u == null ? void 0 : u.chart) == null ? void 0 : _t.xAxis) == null ? void 0 : Nt.type) === "time" ? u.chart.xAxis : void 0, p = we(t.layout), $ = ((qt = p.margins) == null ? void 0 : qt.left) ?? mt.left, m = ((Ut = p.margins) == null ? void 0 : Ut.right) ?? mt.right, w = ((Zt = p.margins) == null ? void 0 : Zt.top) ?? mt.top, v = qn(e, $), b = Un(e, m), k = o.style.height, C = o.style.width, A = o.style.minHeight, S = o.style.minWidth, E = getComputedStyle(o), R = o.offsetHeight || parseInt(E.height, 10) || 0;
2371
+ o.replaceChildren(), o.style.display = "flex", o.style.flexDirection = r ? "row" : "column", o.style.boxSizing = "border-box", o.style.overflow = "hidden", o.style.position = "relative", o.style.maxWidth = "none", o.style.maxHeight = "none", o.style.width = C || "100%", o.style.minWidth = S || "0", k ? o.style.height = k : R > 0 ? o.style.height = `${R}px` : (o.style.height = "100%", o.style.minHeight = A || "320px"), A ? o.style.minHeight = A : o.style.minHeight || (o.style.minHeight = "0");
2372
+ const D = e.map((x) => x.id), z = e.map((x) => ue(x.height));
2373
+ pe(z);
2374
+ const T = /* @__PURE__ */ new Map(), F = [], Y = [];
2375
+ let B = null, V = !1, P = 0, O = 0, j = null;
2376
+ const _ = (x) => {
2377
+ const M = Array.from({ length: F.length }, (I, L) => L);
2378
+ for (const I of M) {
2379
+ const L = T.get(D[I]);
2380
+ L && L.resize();
2381
+ }
2382
+ ge(
2383
+ M.map((I) => Y[I]).filter(Boolean)
2384
+ );
2385
+ }, tt = () => {
2386
+ P || (P = requestAnimationFrame(() => {
2387
+ P = 0, !V && _();
2388
+ }));
2389
+ }, et = new ResizeObserver(() => {
2390
+ V || tt();
2391
+ });
2392
+ et.observe(o);
2393
+ const ot = () => {
2394
+ for (let x = 0; x < F.length; x++)
2395
+ F[x].style.cssText = Et(z[x], l, x, s);
2396
+ }, Q = () => {
2397
+ const x = (F.length - 1) * f;
2398
+ return r ? Math.max(1, o.clientWidth - x) : Math.max(1, o.clientHeight - x);
2399
+ }, Z = () => {
2400
+ for (const x of F) {
2401
+ const M = x.firstElementChild;
2402
+ M && (M.style.cssText = xt());
2403
+ }
2404
+ }, rt = () => {
2405
+ const x = Q(), M = F.map(
2406
+ (L) => r ? L.getBoundingClientRect().width : L.getBoundingClientRect().height
2407
+ );
2408
+ if (M.reduce((L, W) => L + W, 0) <= 0) {
2409
+ const L = Math.floor(x / Math.max(1, F.length));
2410
+ return F.map(
2411
+ (W, X) => X === F.length - 1 ? x - L * (F.length - 1) : L
2412
+ );
2413
+ }
2414
+ return zt(M, x);
2415
+ }, nt = (x) => {
2416
+ const M = zt(x, Q());
2417
+ for (let I = 0; I < F.length; I++) {
2418
+ const L = Math.max(1, M[I]), W = l > 0 && I > 0 ? r ? `margin-left:${l}px;` : `margin-top:${l}px;` : "", X = r ? "width" : "height";
2419
+ F[I].style.cssText = `${X}:${L}px;flex:0 0 auto;min-height:0;min-width:0;position:relative;overflow:hidden;${W}`;
2420
+ const H = F[I].firstElementChild;
2421
+ H && (H.style.cssText = xt());
2422
+ }
2423
+ for (let I = 0; I < x.length; I++) x[I] = M[I];
2424
+ }, at = () => {
2425
+ if (O = 0, !V || !j) return;
2426
+ const { sizes: x, leadingIdx: M, trailingIdx: I } = j;
2427
+ nt(x);
2428
+ for (const L of [M, I]) {
2429
+ const W = T.get(D[L]);
2430
+ W && (W.resize(), ge([Y[L]]));
2431
+ }
2432
+ }, $t = (x, M, I) => {
2433
+ j = { sizes: x, leadingIdx: M, trailingIdx: I }, !O && (O = requestAnimationFrame(at));
2434
+ }, Lt = (x) => {
2435
+ const M = x.reduce((L, W) => L + W, 0);
2436
+ if (M <= 0) return;
2437
+ const I = z.reduce((L, W) => L + W, 0);
2438
+ for (let L = 0; L < z.length; L++)
2439
+ z[L] = x[L] / M * I;
2440
+ }, Wt = (x) => {
2441
+ var M;
2442
+ for (const I of T.values())
2443
+ (M = I.setResizeSuspended) == null || M.call(I, x);
2444
+ }, je = (x, M) => {
2445
+ var I, L, W, X, H, it;
2446
+ for (let q = 0; q < D.length; q++)
2447
+ q === x || q === M || (L = (I = T.get(D[q])) == null ? void 0 : I.setResizeSuspended) == null || L.call(I, !0);
2448
+ (X = (W = T.get(D[x])) == null ? void 0 : W.setResizeSuspended) == null || X.call(W, !1), (it = (H = T.get(D[M])) == null ? void 0 : H.setResizeSuspended) == null || it.call(H, !1);
2449
+ }, Ot = r ? ((Kt = (Qt = t.layout) == null ? void 0 : Qt.margins) == null ? void 0 : Kt.bottom) ?? Ye.bottom : mt.bottom;
2450
+ for (let x = 0; x < e.length; x++) {
2451
+ const M = e[x], I = x === 0, L = x === e.length - 1, W = r ? M.showXAxis ?? !0 : M.showXAxis ?? (c === "bottom" ? L : !0), X = r ? M.showYAxis ?? (a === "left" ? I : !0) : M.showYAxis ?? !0, H = document.createElement("div");
2452
+ H.dataset.paneId = M.id, H.style.cssText = Et(z[x], l, x, s);
2453
+ const it = document.createElement("div");
2454
+ it.style.cssText = xt(), H.appendChild(it), o.appendChild(H), F.push(H);
2455
+ const q = re(
2456
+ me(
2457
+ M,
2458
+ it,
2459
+ t,
2460
+ x,
2461
+ e.length,
2462
+ {
2463
+ left: r && !X ? mt.left : v,
2464
+ right: b,
2465
+ top: w,
2466
+ bottom: Ot
2467
+ },
2468
+ W,
2469
+ X,
2470
+ s,
2471
+ g,
2472
+ y
2473
+ )
2474
+ );
2475
+ it.style.cssText = xt();
2476
+ const ft = $e(M.series);
2477
+ if (ft.length)
2478
+ for (const dt of ft) q.addSeries(dt);
2479
+ M.yRange && M.yRange !== "auto" && q.zoom({ y: M.yRange, animate: !1 }), T.set(M.id, q), Y.push({
2480
+ chart: q,
2481
+ wrapper: H,
2482
+ baseYTickCount: ye((Jt = M.chart) == null ? void 0 : Jt.yAxis),
2483
+ baseXTickCount: ((ee = (te = M.chart) == null ? void 0 : te.xAxis) == null ? void 0 : ee.tickCount) ?? 8,
2484
+ showXAxis: W
2485
+ });
2486
+ }
2487
+ const Ht = () => {
2488
+ if (B == null || B.destroy(), B = null, !d || F.length < 2) return;
2489
+ const x = typeof h == "object" ? {
2490
+ minPaneRatio: h.minPaneRatio,
2491
+ minPanePx: h.minPanePx,
2492
+ dividerSize: h.dividerSize
2493
+ } : {};
2494
+ B = Gn(
2495
+ o,
2496
+ F,
2497
+ D,
2498
+ z,
2499
+ {
2500
+ direction: s,
2501
+ ...x,
2502
+ onDragStart: (M, I) => (V = !0, Wt(!0), je(M, I), rt()),
2503
+ onDragMove: (M, I, L) => {
2504
+ $t(M, I, L);
2505
+ },
2506
+ onDragEnd: (M) => {
2507
+ O && (cancelAnimationFrame(O), O = 0), j = null, V = !1;
2508
+ const I = zt(M, Q());
2509
+ Lt(I), Z(), ot(), Wt(!1), _();
2510
+ }
2511
+ }
2512
+ );
2513
+ };
2514
+ Ht();
2515
+ const vt = T.get(n);
2516
+ if (!vt)
2517
+ throw new Error(`[StackedChart] masterPaneId "${n}" not found in panes`);
2518
+ const ht = Je(
2519
+ Array.from(T.values()),
2520
+ Qn(t.sync, n, s)
2521
+ ), Dt = () => {
2522
+ const x = vt.theme ?? vt.baseTheme;
2523
+ return (x == null ? void 0 : x.backgroundColor) ?? "#ffffff";
2524
+ }, Yt = () => {
2525
+ const M = Date.now();
2526
+ return new Promise((L) => {
2527
+ const W = () => {
2528
+ const X = Ke();
2529
+ if (X.pending === 0 && !X.isProcessing || Date.now() - M > 8e3) {
2530
+ L();
2531
+ return;
2532
+ }
2533
+ setTimeout(W, 50);
2534
+ };
2535
+ W();
2536
+ }).then(() => new Promise((L) => {
2537
+ requestAnimationFrame(() => {
2538
+ _(), L();
2539
+ });
2540
+ }));
2541
+ }, Xt = async (x = {}) => {
2542
+ if (x.format === "svg") {
2543
+ for (const L of T.values()) L.render();
2544
+ const I = de(
2545
+ o,
2546
+ F,
2547
+ Array.from(T.values()),
2548
+ (B == null ? void 0 : B.dividers) ?? [],
2549
+ Dt(),
2550
+ x
2551
+ );
2552
+ if (x.download) {
2553
+ const L = document.createElement("a");
2554
+ L.download = `${x.fileName ?? "velo-plot-stack"}.svg`, L.href = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(I)}`, document.body.appendChild(L), L.click(), document.body.removeChild(L);
2555
+ }
2556
+ return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(I)}`;
2557
+ }
2558
+ await Yt();
2559
+ for (const I of T.values()) I.render();
2560
+ await new Promise((I) => requestAnimationFrame(I));
2561
+ const M = await Tn(
2562
+ o,
2563
+ F,
2564
+ Array.from(T.values()),
2565
+ (B == null ? void 0 : B.dividers) ?? [],
2566
+ Dt(),
2567
+ x
2568
+ );
2569
+ if (x.download) {
2570
+ const I = x.format === "jpeg" ? "jpg" : x.format ?? "png", L = document.createElement("a");
2571
+ L.download = `${x.fileName ?? "velo-plot-stack"}.${I}`, L.href = M, document.body.appendChild(L), L.click(), document.body.removeChild(L);
2572
+ }
2573
+ return M;
2574
+ }, Gt = (x) => {
2575
+ var oe, ne, ie;
2576
+ if (T.size >= Ct)
2577
+ throw new Error(`[StackedChart] Cannot exceed ${Ct} panes`);
2578
+ if (T.has(x.id))
2579
+ throw new Error(`[StackedChart] Pane "${x.id}" already exists`);
2580
+ if (!r && c === "bottom" && D.length > 0) {
2581
+ const ct = D[D.length - 1], ut = T.get(ct), se = Y[Y.length - 1];
2582
+ ut == null || ut.updateXAxis({
2583
+ showLabels: !1,
2584
+ showTicks: !1,
2585
+ showLine: !1
2586
+ }), ut == null || ut.updateLayout({
2587
+ margins: {
2588
+ bottom: l > 0 ? He.bottom : 0
2589
+ }
2590
+ }), se && (se.showXAxis = !1);
2591
+ }
2592
+ const M = ue(x.height ?? 0.25), I = z.reduce((ct, ut) => ct + ut, 0), L = I > 0 ? (1 - M) / I : 1;
2593
+ for (let ct = 0; ct < z.length; ct++) z[ct] *= L;
2594
+ const W = D.length;
2595
+ D.push(x.id), z.push(M), pe(z);
2596
+ const X = document.createElement("div");
2597
+ X.dataset.paneId = x.id, X.style.cssText = Et(z[W], l, W, s);
2598
+ const H = document.createElement("div");
2599
+ H.style.cssText = xt(), X.appendChild(H), o.appendChild(X), F.push(X), ot();
2600
+ const q = r ? x.showXAxis ?? !0 : x.showXAxis ?? (c === "bottom" ? !0 : !0), ft = r ? x.showYAxis ?? (a === "left" ? W === 0 : !0) : x.showYAxis ?? !0, dt = re(
2601
+ me(
2602
+ x,
2603
+ H,
2604
+ t,
2605
+ W,
2606
+ D.length,
2607
+ {
2608
+ left: r && !ft ? mt.left : v,
2609
+ right: b,
2610
+ top: w,
2611
+ bottom: Ot
2612
+ },
2613
+ q,
2614
+ ft,
2615
+ s,
2616
+ g,
2617
+ y
2618
+ )
2619
+ );
2620
+ H.style.cssText = xt();
2621
+ const _e = $e(x.series);
2622
+ for (const ct of _e) dt.addSeries(ct);
2623
+ return x.yRange && x.yRange !== "auto" && dt.zoom({ y: x.yRange, animate: !1 }), T.set(x.id, dt), Y.push({
2624
+ chart: dt,
2625
+ wrapper: X,
2626
+ baseYTickCount: ye((oe = x.chart) == null ? void 0 : oe.yAxis),
2627
+ baseXTickCount: ((ie = (ne = x.chart) == null ? void 0 : ne.xAxis) == null ? void 0 : ie.tickCount) ?? 8,
2628
+ showXAxis: q
2629
+ }), ht.add(dt), Ht(), _(), dt;
2630
+ };
2631
+ return {
2632
+ container: o,
2633
+ getPane(x) {
2634
+ return T.get(x);
2635
+ },
2636
+ /** @deprecated Prefer `getPane(id)`. **Removed in v4.0.** */
2637
+ getChart(x) {
2638
+ return T.get(x);
2639
+ },
2640
+ getPanes() {
2641
+ return Array.from(T.values());
2642
+ },
2643
+ getMaster() {
2644
+ return vt;
2645
+ },
2646
+ getGroup() {
2647
+ return ht;
2648
+ },
2649
+ fitAll(x) {
2650
+ ht.fitAll(x);
2651
+ },
2652
+ resetAll() {
2653
+ ht.resetAll();
2654
+ },
2655
+ resize() {
2656
+ _();
2657
+ },
2658
+ getPaneRatios() {
2659
+ const x = {};
2660
+ for (let M = 0; M < D.length; M++)
2661
+ x[D[M]] = z[M];
2662
+ return x;
2663
+ },
2664
+ setPaneRatios(x) {
2665
+ for (let M = 0; M < D.length; M++) {
2666
+ const I = D[M];
2667
+ x[I] !== void 0 && (z[M] = x[I]);
2668
+ }
2669
+ Vn(F, z, s), _();
2670
+ },
2671
+ setSyncAxis(x) {
2672
+ ht.syncAxis(x);
2673
+ },
2674
+ getSyncAxis() {
2675
+ return ht.getOptions().axis ?? "x";
2676
+ },
2677
+ setSyncOptions(x) {
2678
+ ht.updateOptions(x);
2679
+ },
2680
+ whenReady() {
2681
+ return Yt();
2682
+ },
2683
+ exportImage(x) {
2684
+ return Xt(x);
2685
+ },
2686
+ exportSVG(x) {
2687
+ for (const M of T.values()) M.render();
2688
+ return de(
2689
+ o,
2690
+ F,
2691
+ Array.from(T.values()),
2692
+ (B == null ? void 0 : B.dividers) ?? [],
2693
+ Dt(),
2694
+ x
2695
+ );
2696
+ },
2697
+ snapshot(x) {
2698
+ return Xt(x);
2699
+ },
2700
+ addPane(x) {
2701
+ return Gt(x);
2702
+ },
2703
+ async addIndicator(x, M = {}) {
2704
+ var q;
2705
+ const I = vt;
2706
+ if (M.pane !== "new")
2707
+ return { ...await Ln(I, x, M), chart: I };
2708
+ const L = Rt(I, M.sourceSeriesId), { x: W, prices: X } = We(L), H = await Dn(x, W, X, {
2709
+ id: M.id ?? x,
2710
+ label: M.label ?? x.toUpperCase(),
2711
+ height: M.paneHeight ?? 0.25,
2712
+ showXAxis: M.showXAxis,
2713
+ period: M.period,
2714
+ fastPeriod: M.fastPeriod,
2715
+ slowPeriod: M.slowPeriod,
2716
+ signalPeriod: M.signalPeriod,
2717
+ stdDev: M.stdDev
2718
+ }, L), it = Gt(H);
2719
+ return {
2720
+ id: H.id,
2721
+ preset: x,
2722
+ placement: "oscillator",
2723
+ seriesIds: ((q = H.series) == null ? void 0 : q.map((ft) => ft.id)) ?? [],
2724
+ paneId: H.id,
2725
+ chart: it
2726
+ };
2727
+ },
2728
+ destroy() {
2729
+ P && cancelAnimationFrame(P), O && cancelAnimationFrame(O), et.disconnect(), B == null || B.destroy(), ht.destroy();
2730
+ for (const x of T.values()) x.destroy();
2731
+ T.clear(), o.replaceChildren();
2732
+ }
2733
+ };
2734
+ }
2735
+ export {
2736
+ Ct as S,
2737
+ Ln as a,
2738
+ Mn as b,
2739
+ fi as c,
2740
+ hi as d,
2741
+ kn as e,
2742
+ Dn as f,
2743
+ In as g,
2744
+ yo as h,
2745
+ ri as i,
2746
+ go as j,
2747
+ $n as k,
2748
+ bo as l,
2749
+ Sn as m,
2750
+ St as n,
2751
+ pn as o,
2752
+ li as p,
2753
+ Bt as q,
2754
+ vn as r,
2755
+ bn as s,
2756
+ ai as t,
2757
+ mn as u,
2758
+ Oe as v,
2759
+ ci as w
2760
+ };
2761
+ //# sourceMappingURL=createStackedChart-DjA3aJAu.js.map