@gearbox-protocol/ui-kit 3.14.0-next.36 → 3.14.0-next.38

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.
@@ -1,12 +1,12 @@
1
- import { jsxs as re, jsx as T } from "react/jsx-runtime";
2
- import { createChart as Ue, CrosshairMode as et, LineStyle as Ge, LineSeries as tt, AreaSeries as ot } from "lightweight-charts";
1
+ import { jsxs as ne, jsx as w } from "react/jsx-runtime";
2
+ import { createChart as Ue, CrosshairMode as et, LineStyle as ee, LineSeries as tt, AreaSeries as ot } from "lightweight-charts";
3
3
  import * as Ce from "react";
4
- import { useRef as X, useState as Se, useEffect as W } from "react";
4
+ import { useRef as q, useState as ye, useEffect as E } from "react";
5
5
  import { useIsMobile as rt } from "../../hooks/use-media-query.js";
6
- import { cn as ne } from "../../utils/cn.js";
7
- import { resolveCSSColor as U, generateColorsFromBase as se, hslToHex as nt } from "../../utils/colors.js";
8
- import { getDefaultOptions as je, getDefaultSeries as lt, getDefaultVerticalLine as at } from "./default-config.js";
9
- import { getXFormatters as He, formatExactValue as xe, createAdaptiveYAxisFormatter as it } from "./formatters.js";
6
+ import { cn as le } from "../../utils/cn.js";
7
+ import { resolveCSSColor as U, generateColorsFromBase as ce, hslToHex as nt } from "../../utils/colors.js";
8
+ import { getDefaultOptions as je, getDefaultSeries as lt, getDefaultVerticalLine as it } from "./default-config.js";
9
+ import { getXFormatters as He, formatExactValue as xe, createAdaptiveYAxisFormatter as at } from "./formatters.js";
10
10
  import { GraphCurrentValue as st } from "./graph-current-value.js";
11
11
  import { GraphTooltip as ct } from "./graph-tooltip.js";
12
12
  import { VertLine as ut } from "./plugins/vertical-line.js";
@@ -14,13 +14,13 @@ class ft {
14
14
  _yTop;
15
15
  _yBottom;
16
16
  _color;
17
- constructor(s, g, m) {
18
- this._yTop = s, this._yBottom = g, this._color = m;
17
+ constructor(l, f, c) {
18
+ this._yTop = l, this._yBottom = f, this._color = c;
19
19
  }
20
- draw(s) {
21
- s.useBitmapCoordinateSpace((g) => {
22
- const m = g.context, d = g.verticalPixelRatio, N = this._yTop === null ? 0 : this._yTop * d, q = this._yBottom === null ? g.bitmapSize.height : this._yBottom * d, x = Math.min(N, q), k = Math.max(N, q);
23
- m.fillStyle = this._color, m.fillRect(0, x, g.bitmapSize.width, k - x);
20
+ draw(l) {
21
+ l.useBitmapCoordinateSpace((f) => {
22
+ const c = f.context, d = f.verticalPixelRatio, v = this._yTop === null ? 0 : this._yTop * d, F = this._yBottom === null ? f.bitmapSize.height : this._yBottom * d, x = Math.min(v, F), M = Math.max(v, F);
23
+ c.fillStyle = this._color, c.fillRect(0, x, f.bitmapSize.width, M - x);
24
24
  });
25
25
  }
26
26
  }
@@ -28,12 +28,12 @@ class ht {
28
28
  _source;
29
29
  _yTop = null;
30
30
  _yBottom = null;
31
- constructor(s) {
32
- this._source = s;
31
+ constructor(l) {
32
+ this._source = l;
33
33
  }
34
34
  update() {
35
- const s = this._source.series;
36
- this._yTop = this._source.priceTop === void 0 ? null : s.priceToCoordinate(this._source.priceTop), this._yBottom = this._source.priceBottom === void 0 ? null : s.priceToCoordinate(this._source.priceBottom);
35
+ const l = this._source.series;
36
+ this._yTop = this._source.priceTop === void 0 ? null : l.priceToCoordinate(this._source.priceTop), this._yBottom = this._source.priceBottom === void 0 ? null : l.priceToCoordinate(this._source.priceBottom);
37
37
  }
38
38
  /** Draw beneath the series line/area so the data stays readable. */
39
39
  zOrder() {
@@ -43,37 +43,111 @@ class ht {
43
43
  return new ft(this._yTop, this._yBottom, this._source.color);
44
44
  }
45
45
  }
46
- class gt {
46
+ class dt {
47
47
  series;
48
48
  priceTop;
49
49
  priceBottom;
50
50
  color;
51
51
  _paneViews;
52
- constructor(s, g, m, d) {
53
- this.series = s, this.priceTop = g, this.priceBottom = m, this.color = d, this._paneViews = [new ht(this)];
52
+ constructor(l, f, c, d) {
53
+ this.series = l, this.priceTop = f, this.priceBottom = c, this.color = d, this._paneViews = [new ht(this)];
54
54
  }
55
55
  updateAllViews() {
56
- for (const s of this._paneViews) s.update();
56
+ for (const l of this._paneViews) l.update();
57
57
  }
58
58
  paneViews() {
59
59
  return this._paneViews;
60
60
  }
61
61
  }
62
- function dt(o, s, g) {
63
- const m = o.labelText ?? "", d = o.value, N = d === void 0 ? "" : typeof d == "number" ? s === "$" ? `$${xe(d, void 0, g)}` : s === "%" ? `${xe(d, void 0, g)}%` : xe(
62
+ function pt(t, l) {
63
+ switch (t) {
64
+ case ee.Dotted:
65
+ return [l, l];
66
+ case ee.Dashed:
67
+ return [2 * l, 2 * l];
68
+ case ee.LargeDashed:
69
+ return [6 * l, 6 * l];
70
+ case ee.SparseDotted:
71
+ return [l, 4 * l];
72
+ default:
73
+ return [];
74
+ }
75
+ }
76
+ class mt {
77
+ _y;
78
+ _color;
79
+ _lineWidth;
80
+ _lineStyle;
81
+ constructor(l, f, c, d) {
82
+ this._y = l, this._color = f, this._lineWidth = c, this._lineStyle = d;
83
+ }
84
+ draw(l) {
85
+ l.useBitmapCoordinateSpace((f) => {
86
+ if (this._y === null) return;
87
+ const c = f.context, d = f.verticalPixelRatio, v = Math.max(1, Math.round(this._lineWidth * d)), F = Math.round(this._y * d);
88
+ c.save(), c.strokeStyle = this._color, c.lineWidth = v, c.setLineDash(pt(this._lineStyle, v)), c.beginPath(), c.moveTo(0, F), c.lineTo(f.bitmapSize.width, F), c.stroke(), c.restore();
89
+ });
90
+ }
91
+ }
92
+ class gt {
93
+ _source;
94
+ _y = null;
95
+ constructor(l) {
96
+ this._source = l;
97
+ }
98
+ update() {
99
+ this._y = this._source.series.priceToCoordinate(this._source.price);
100
+ }
101
+ /**
102
+ * Draw on the top pane (top canvas) so a liquidation price line stays above
103
+ * every series' area/line fill, price zones and the crosshair — native
104
+ * `createPriceLine` only draws in the "normal" group and can be hidden behind
105
+ * a later series in multi-series charts.
106
+ */
107
+ zOrder() {
108
+ return "top";
109
+ }
110
+ renderer() {
111
+ return new mt(
112
+ this._y,
113
+ this._source.color,
114
+ this._source.lineWidth,
115
+ this._source.lineStyle
116
+ );
117
+ }
118
+ }
119
+ class bt {
120
+ series;
121
+ price;
122
+ color;
123
+ lineWidth;
124
+ lineStyle;
125
+ _paneViews;
126
+ constructor(l, f, c, d, v) {
127
+ this.series = l, this.price = f, this.color = c, this.lineWidth = d, this.lineStyle = v, this._paneViews = [new gt(this)];
128
+ }
129
+ updateAllViews() {
130
+ for (const l of this._paneViews) l.update();
131
+ }
132
+ paneViews() {
133
+ return this._paneViews;
134
+ }
135
+ }
136
+ function vt(t, l, f) {
137
+ const c = t.labelText ?? "", d = t.value, v = d === void 0 ? "" : typeof d == "number" ? l === "$" ? `$${xe(d, void 0, f)}` : l === "%" ? `${xe(d, void 0, f)}%` : xe(
64
138
  d,
65
- s !== "none" && s !== "%" && s !== "$" ? s : void 0,
66
- g
139
+ l !== "none" && l !== "%" && l !== "$" ? l : void 0,
140
+ f
67
141
  ) : String(d);
68
- return { labelText: m, valueStr: N };
142
+ return { labelText: c, valueStr: v };
69
143
  }
70
- function mt(o, s) {
71
- for (let g = o.length - 1; g >= 0; g--)
72
- if (Number(o[g].time) <= s)
73
- return o[g].value;
144
+ function St(t, l) {
145
+ for (let f = t.length - 1; f >= 0; f--)
146
+ if (Number(t[f].time) <= l)
147
+ return t[f].value;
74
148
  return 0;
75
149
  }
76
- const ye = [
150
+ const we = [
77
151
  // 0 green (emerald)
78
152
  {
79
153
  line: "#02c39a",
@@ -188,70 +262,70 @@ const ye = [
188
262
  top: "rgba(71, 85, 105, 0.56)",
189
263
  bottom: "rgba(71, 85, 105, 0.04)"
190
264
  }
191
- ], pt = 137.5;
192
- function Xe(o) {
193
- if (o < ye.length)
194
- return ye[o];
195
- const g = (o - ye.length) * pt % 360, m = nt(g, 70, 50), { topColor: d, bottomColor: N } = se(m);
196
- return { line: m, top: d, bottom: N };
265
+ ], Ct = 137.5;
266
+ function Oe(t) {
267
+ if (t < we.length)
268
+ return we[t];
269
+ const f = (t - we.length) * Ct % 360, c = nt(f, 70, 50), { topColor: d, bottomColor: v } = ce(c);
270
+ return { line: c, top: d, bottom: v };
197
271
  }
198
- function Lt({
199
- series: o,
200
- className: s,
201
- showLegend: g = !1,
202
- onUnselectSeries: m,
272
+ function Bt({
273
+ series: t,
274
+ className: l,
275
+ showLegend: f = !1,
276
+ onUnselectSeries: c,
203
277
  xMeasureUnit: d = "time",
204
- yMeasureUnit: N = "token",
205
- optionsOverrides: q,
278
+ yMeasureUnit: v = "token",
279
+ optionsOverrides: F,
206
280
  verticalLineOptions: x,
207
- priceLineOptions: k,
208
- zoneOptions: A,
209
- currentValueDecimals: ce,
210
- useSharedPriceScale: $ = !1,
211
- dualYAxis: L = !1,
212
- defaultVisiblePriceScaleId: we = "right",
213
- leftPriceScaleTitle: Te,
214
- rightPriceScaleTitle: vt,
215
- showCurrentValue: qe = !0,
216
- graphTitle: ue,
217
- yScaleMin: Ne,
281
+ priceLineOptions: M,
282
+ zoneOptions: j,
283
+ currentValueDecimals: ue,
284
+ useSharedPriceScale: A = !1,
285
+ dualYAxis: D = !1,
286
+ defaultVisiblePriceScaleId: _e = "right",
287
+ leftPriceScaleTitle: Ne,
288
+ rightPriceScaleTitle: xt,
289
+ showCurrentValue: Xe = !0,
290
+ graphTitle: fe,
291
+ yScaleMin: Te,
218
292
  yScaleMinMultiple: Ve,
219
293
  visibleTimeFrom: Z,
220
- disableZoom: le = !1,
221
- hideDefaultTooltip: fe = !1
294
+ disableZoom: ie = !1,
295
+ hideDefaultTooltip: he = !1
222
296
  }) {
223
- const I = X(null), y = X(/* @__PURE__ */ new Map()), he = X(!1), Re = X(!0), Pe = X([]), K = X(null), ge = X(null), ae = X(null), R = rt(), G = Ce.useMemo(() => o.flatMap((t) => t.data), [o]), Ze = Ce.useMemo(() => {
224
- if (o.length > 0) {
225
- const t = o[o.length - 1];
226
- if (t.data.length > 0)
227
- return t.data[t.data.length - 1];
297
+ const z = q(null), C = q(/* @__PURE__ */ new Map()), de = q(!1), Pe = q(!0), Re = q([]), K = q(null), pe = q(null), ae = q(null), V = rt(), H = Ce.useMemo(() => t.flatMap((o) => o.data), [t]), qe = Ce.useMemo(() => {
298
+ if (t.length > 0) {
299
+ const o = t[t.length - 1];
300
+ if (o.data.length > 0)
301
+ return o.data[o.data.length - 1];
228
302
  }
229
- }, [o]), [Me, de] = Se(() => {
230
- if (!Ze) return;
231
- const t = /* @__PURE__ */ new Map();
232
- for (const a of o)
233
- a.data.length > 0 && t.set(a.label, a.data[a.data.length - 1]);
234
- return t;
235
- }), [ke, j] = Se(null), [Le, _e] = Se([]);
236
- W(() => {
237
- const t = () => {
303
+ }, [t]), [Le, me] = ye(() => {
304
+ if (!qe) return;
305
+ const o = /* @__PURE__ */ new Map();
306
+ for (const s of t)
307
+ s.data.length > 0 && o.set(s.label, s.data[s.data.length - 1]);
308
+ return o;
309
+ }), [Me, O] = ye(null), [ke, De] = ye([]);
310
+ E(() => {
311
+ const o = () => {
238
312
  try {
239
- if (I.current && K.current) {
240
- const n = K.current.clientWidth, i = K.current.clientHeight;
241
- I.current.resize(n, i);
313
+ if (z.current && K.current) {
314
+ const a = K.current.clientWidth, i = K.current.clientHeight;
315
+ z.current.resize(a, i);
242
316
  }
243
317
  } catch {
244
318
  }
245
- }, a = K.current, l = a ? new ResizeObserver(t) : null;
246
- return ae.current = l, a && l?.observe(a), () => {
247
- a && l?.unobserve(a), l?.disconnect(), ae.current = null;
319
+ }, s = K.current, n = s ? new ResizeObserver(o) : null;
320
+ return ae.current = n, s && n?.observe(s), () => {
321
+ s && n?.unobserve(s), n?.disconnect(), ae.current = null;
248
322
  };
249
- }, []), W(() => {
250
- if (!ge.current || he.current) return;
251
- const t = je(), a = U(
323
+ }, []), E(() => {
324
+ if (!pe.current || de.current) return;
325
+ const o = je(), s = U(
252
326
  "hsl(var(--foreground))",
253
327
  "rgb(0, 0, 0)"
254
- ), l = le ? {
328
+ ), n = ie ? {
255
329
  handleScale: {
256
330
  mouseWheel: !1,
257
331
  pinch: !1,
@@ -264,34 +338,34 @@ function Lt({
264
338
  horzTouchDrag: !1,
265
339
  vertTouchDrag: !1
266
340
  }
267
- } : {}, n = Ue(ge.current, {
268
- ...t,
341
+ } : {}, a = Ue(pe.current, {
342
+ ...o,
269
343
  leftPriceScale: {
270
- ...t.leftPriceScale || {},
344
+ ...o.leftPriceScale || {},
271
345
  visible: !1,
272
- textColor: a
346
+ textColor: s
273
347
  },
274
348
  rightPriceScale: {
275
- ...t.rightPriceScale || {},
276
- visible: !R,
277
- textColor: a
349
+ ...o.rightPriceScale || {},
350
+ visible: !V,
351
+ textColor: s
278
352
  },
279
- ...R && {
353
+ ...V && {
280
354
  crosshair: {
281
- ...t.crosshair,
355
+ ...o.crosshair,
282
356
  mode: et.Magnet
283
357
  }
284
358
  },
285
- ...l,
286
- ...q
359
+ ...n,
360
+ ...F
287
361
  });
288
- return I.current = n, he.current = !0, () => {
289
- ae.current?.disconnect(), ae.current = null, n.remove(), I.current = null, he.current = !1, y.current.clear();
362
+ return z.current = a, de.current = !0, () => {
363
+ ae.current?.disconnect(), ae.current = null, a.remove(), z.current = null, de.current = !1, C.current.clear();
290
364
  };
291
- }, [R, q, le]), W(() => {
292
- const t = I.current;
293
- t && t.applyOptions(
294
- le ? {
365
+ }, [V, F, ie]), E(() => {
366
+ const o = z.current;
367
+ o && o.applyOptions(
368
+ ie ? {
295
369
  handleScale: {
296
370
  mouseWheel: !1,
297
371
  pinch: !1,
@@ -319,89 +393,89 @@ function Lt({
319
393
  }
320
394
  }
321
395
  );
322
- }, [le]), W(() => {
323
- const t = I.current;
324
- if (!t || o.length === 0) return;
325
- const l = o.filter((r) => r.data.length > 0).length <= 1 ? Ne : Ve, n = d === "time" ? He(d, G) : He(d), i = /* @__PURE__ */ new Map();
396
+ }, [ie]), E(() => {
397
+ const o = z.current;
398
+ if (!o || t.length === 0) return;
399
+ const n = t.filter((r) => r.data.length > 0).length <= 1 ? Te : Ve, a = d === "time" ? He(d, H) : He(d), i = /* @__PURE__ */ new Map();
326
400
  {
327
401
  let r = 0;
328
- for (const e of o)
402
+ for (const e of t)
329
403
  e.data.length !== 0 && (i.set(
330
404
  e.label,
331
405
  e.priceScaleId ?? (r === 0 ? "left" : "right")
332
406
  ), r++);
333
407
  }
334
- const f = (r, e, u) => {
408
+ const u = (r, e, p) => {
335
409
  const {
336
- formatter: B,
337
- tickmarksFormatter: S,
338
- updateVisibleRange: z,
410
+ formatter: k,
411
+ tickmarksFormatter: T,
412
+ updateVisibleRange: $,
339
413
  updateLastValues: Fe
340
- } = it(r, e, {
341
- yScaleMin: l
342
- }), pe = o.filter((O) => O.data.length > 0 && u.has(O.label)).map((O) => O.data[O.data.length - 1].value);
343
- return Fe(pe), { formatter: B, tickmarksFormatter: S, updateVisibleRange: z, labels: u };
344
- }, c = [];
345
- if (L)
414
+ } = at(r, e, {
415
+ yScaleMin: n
416
+ }), be = t.filter((J) => J.data.length > 0 && p.has(J.label)).map((J) => J.data[J.data.length - 1].value);
417
+ return Fe(be), { formatter: k, tickmarksFormatter: T, updateVisibleRange: $, labels: p };
418
+ }, h = [];
419
+ if (D)
346
420
  for (const r of ["left", "right"]) {
347
- const e = /* @__PURE__ */ new Set(), u = [];
348
- let B = N;
349
- for (const S of o)
350
- if (S.data.length !== 0 && i.get(S.label) === r) {
351
- e.size === 0 && S.yMeasureUnit && (B = S.yMeasureUnit), e.add(S.label);
352
- for (const z of S.data) u.push(z.value);
421
+ const e = /* @__PURE__ */ new Set(), p = [];
422
+ let k = v;
423
+ for (const T of t)
424
+ if (T.data.length !== 0 && i.get(T.label) === r) {
425
+ e.size === 0 && T.yMeasureUnit && (k = T.yMeasureUnit), e.add(T.label);
426
+ for (const $ of T.data) p.push($.value);
353
427
  }
354
- e.size > 0 && c.push(f(u, B, e));
428
+ e.size > 0 && h.push(u(p, k, e));
355
429
  }
356
430
  else {
357
- const r = G.map((u) => u.value), e = new Set(
358
- o.filter((u) => u.data.length > 0).map((u) => u.label)
431
+ const r = H.map((p) => p.value), e = new Set(
432
+ t.filter((p) => p.data.length > 0).map((p) => p.label)
359
433
  );
360
- c.push(f(r, N, e));
434
+ h.push(u(r, v, e));
361
435
  }
362
- Pe.current = c;
436
+ Re.current = h;
363
437
  const b = /* @__PURE__ */ new Map();
364
- for (const r of c)
438
+ for (const r of h)
365
439
  for (const e of r.labels)
366
440
  b.set(e, r);
367
- const v = je();
368
- t.applyOptions({
441
+ const S = je();
442
+ o.applyOptions({
369
443
  localization: {
370
- ...v.localization || {},
444
+ ...S.localization || {},
371
445
  // biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
372
446
  timeFormatter: (r) => (
373
447
  // biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
374
- n.timeFormatter(parseFloat(r), void 0)
448
+ a.timeFormatter(parseFloat(r), void 0)
375
449
  )
376
450
  },
377
451
  timeScale: {
378
- ...v.timeScale || {},
452
+ ...S.timeScale || {},
379
453
  // biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
380
- tickMarkFormatter: n.tickMarkFormatter,
454
+ tickMarkFormatter: a.tickMarkFormatter,
381
455
  minBarSpacing: 0
382
456
  }
383
457
  });
384
- const _ = (G.length > 0 ? Math.min(...G.map((r) => r.value)) : 0) < 0, w = G.some((r) => r.value === 0), p = !_ && w, C = !L && o.length > 1 && !$, P = L ? R : o.length > 1 && !$ || R, M = U(
458
+ const P = (H.length > 0 ? Math.min(...H.map((r) => r.value)) : 0) < 0, _ = H.some((r) => r.value === 0), m = !P && _, y = !D && t.length > 1 && !A, R = D ? V : t.length > 1 && !A || V, L = U(
385
459
  "hsl(var(--foreground))",
386
460
  "rgb(0, 0, 0)"
387
461
  );
388
- t.applyOptions({
389
- ...L && {
390
- defaultVisiblePriceScaleId: we
462
+ o.applyOptions({
463
+ ...D && {
464
+ defaultVisiblePriceScaleId: _e
391
465
  },
392
466
  leftPriceScale: {
393
- ...v.leftPriceScale || {},
394
- visible: L && !R,
395
- textColor: M,
396
- ...L && Te && {
467
+ ...S.leftPriceScale || {},
468
+ visible: D && !V,
469
+ textColor: L,
470
+ ...D && Ne && {
397
471
  // lightweight-charts uses scale margins; title shown via localization if needed
398
472
  }
399
473
  },
400
474
  rightPriceScale: {
401
- ...v.rightPriceScale || {},
402
- visible: L ? !R : !P,
403
- textColor: M,
404
- ...p && !L && {
475
+ ...S.rightPriceScale || {},
476
+ visible: D ? !V : !R,
477
+ textColor: L,
478
+ ...m && !D && {
405
479
  scaleMargins: {
406
480
  top: 0.3,
407
481
  bottom: 0
@@ -409,122 +483,122 @@ function Lt({
409
483
  }
410
484
  }
411
485
  });
412
- const V = new Set(y.current.keys()), J = new Set(o.map((r) => r.label));
413
- for (const r of V)
414
- if (!J.has(r)) {
415
- const e = y.current.get(r);
416
- e && (t.removeSeries(e), y.current.delete(r));
486
+ const N = new Set(C.current.keys()), X = new Set(t.map((r) => r.label));
487
+ for (const r of N)
488
+ if (!X.has(r)) {
489
+ const e = C.current.get(r);
490
+ e && (o.removeSeries(e), C.current.delete(r));
417
491
  }
418
- const Q = lt(), ee = [];
419
- let te = 0;
420
- const De = o.find((r) => r.data.length > 0), oe = /* @__PURE__ */ new Map();
421
- if (k && k.length > 0)
422
- for (const r of k) {
492
+ const Q = lt(), te = [];
493
+ let oe = 0;
494
+ const Be = t.find((r) => r.data.length > 0), re = /* @__PURE__ */ new Map();
495
+ if (M && M.length > 0)
496
+ for (const r of M) {
423
497
  if (!Number.isFinite(r.price)) continue;
424
- const e = r.seriesLabel ?? De?.label;
498
+ const e = r.seriesLabel ?? Be?.label;
425
499
  if (!e) continue;
426
- const u = oe.get(e) ?? [];
427
- u.push(r.price), oe.set(e, u);
500
+ const p = re.get(e) ?? [];
501
+ p.push(r.price), re.set(e, p);
428
502
  }
429
- if (A && A.length > 0)
430
- for (const r of A) {
431
- const e = r.seriesLabel ?? De?.label;
503
+ if (j && j.length > 0)
504
+ for (const r of j) {
505
+ const e = r.seriesLabel ?? Be?.label;
432
506
  if (!e) continue;
433
- const u = oe.get(e) ?? [];
434
- Number.isFinite(r.priceTop) && u.push(r.priceTop), Number.isFinite(r.priceBottom) && u.push(r.priceBottom), oe.set(e, u);
507
+ const p = re.get(e) ?? [];
508
+ Number.isFinite(r.priceTop) && p.push(r.priceTop), Number.isFinite(r.priceBottom) && p.push(r.priceBottom), re.set(e, p);
435
509
  }
436
- for (let r = 0; r < o.length; r++) {
437
- const e = o[r], u = Xe(r), B = e.lineColor ?? e.color ?? u.line;
438
- let S, z;
510
+ for (let r = 0; r < t.length; r++) {
511
+ const e = t[r], p = Oe(r), k = e.lineColor ?? e.color ?? p.line;
512
+ let T, $;
439
513
  if (e.lineColor ?? e.color)
440
514
  if (e.topColor && e.bottomColor)
441
- S = e.topColor, z = e.bottomColor;
515
+ T = e.topColor, $ = e.bottomColor;
442
516
  else if (e.topColor) {
443
- const h = se(B);
444
- S = e.topColor, z = h.bottomColor;
517
+ const g = ce(k);
518
+ T = e.topColor, $ = g.bottomColor;
445
519
  } else if (e.bottomColor)
446
- S = se(B).topColor, z = e.bottomColor;
520
+ T = ce(k).topColor, $ = e.bottomColor;
447
521
  else {
448
- const h = se(B);
449
- S = h.topColor, z = h.bottomColor;
522
+ const g = ce(k);
523
+ T = g.topColor, $ = g.bottomColor;
450
524
  }
451
525
  else
452
- S = e.topColor || u.top, z = e.bottomColor || u.bottom;
526
+ T = e.topColor || p.top, $ = e.bottomColor || p.bottom;
453
527
  if (e.data.length === 0) {
454
- const h = y.current.get(e.label);
455
- h && (t.removeSeries(h), y.current.delete(e.label));
528
+ const g = C.current.get(e.label);
529
+ g && (o.removeSeries(g), C.current.delete(e.label));
456
530
  continue;
457
531
  }
458
- const pe = (e.data.length > 0 ? Math.min(...e.data.map((h) => h.value)) : 0) < 0, O = e.data.some((h) => h.value === 0), Ke = !pe && O, Ie = L ? e.priceScaleId ?? (te === 0 ? "left" : "right") : $ || !C || te === 0 ? "right" : `scale-${te}`;
459
- C && ee.push({
460
- priceScaleId: Ie || "right",
461
- shouldPreventNegativeAxis: Ke,
462
- seriesIndex: te
532
+ const be = (e.data.length > 0 ? Math.min(...e.data.map((g) => g.value)) : 0) < 0, J = e.data.some((g) => g.value === 0), Ze = !be && J, ze = D ? e.priceScaleId ?? (oe === 0 ? "left" : "right") : A || !y || oe === 0 ? "right" : `scale-${oe}`;
533
+ y && te.push({
534
+ priceScaleId: ze || "right",
535
+ shouldPreventNegativeAxis: Ze,
536
+ seriesIndex: oe
463
537
  });
464
- const ze = ($ || !C) && l !== void 0 && typeof l == "number", Oe = oe.get(e.label) ?? [], Je = (h) => {
465
- const F = h();
466
- if (F?.priceRange) {
467
- ze && (F.priceRange.minValue = l);
468
- for (const E of Oe)
469
- E < F.priceRange.minValue && (F.priceRange.minValue = E), E > F.priceRange.maxValue && (F.priceRange.maxValue = E);
538
+ const We = (A || !y) && n !== void 0 && typeof n == "number", Ke = re.get(e.label) ?? [], Je = (g) => {
539
+ const B = g();
540
+ if (B?.priceRange) {
541
+ We && (B.priceRange.minValue = n);
542
+ for (const G of Ke)
543
+ G < B.priceRange.minValue && (B.priceRange.minValue = G), G > B.priceRange.maxValue && (B.priceRange.maxValue = G);
470
544
  }
471
- return F;
472
- }, We = b.get(e.label) ?? c[0], $e = We.formatter, Qe = We.tickmarksFormatter, be = {
473
- lineColor: B,
474
- topColor: S,
475
- bottomColor: z,
476
- priceScaleId: Ie,
545
+ return B;
546
+ }, $e = b.get(e.label) ?? h[0], Ee = $e.formatter, Qe = $e.tickmarksFormatter, ve = {
547
+ lineColor: k,
548
+ topColor: T,
549
+ bottomColor: $,
550
+ priceScaleId: ze,
477
551
  ...e.seriesType === "line" && {
478
- lineStyle: e.lineStyle ?? Ge.Solid
552
+ lineStyle: e.lineStyle ?? ee.Solid
479
553
  },
480
554
  priceFormat: {
481
555
  type: "custom",
482
556
  minMove: 0.01,
483
- formatter: ze && typeof l == "number" ? (h) => $e(
484
- h < l ? l : h
485
- ) : $e,
557
+ formatter: We && typeof n == "number" ? (g) => Ee(
558
+ g < n ? n : g
559
+ ) : Ee,
486
560
  tickmarksFormatter: Qe
487
561
  },
488
562
  autoscaleInfoProvider: Je
489
- }, Ee = e.seriesType === "line";
490
- let D = y.current.get(e.label);
491
- const Y = e.data.map((h) => ({
492
- ...h,
493
- time: h.time
563
+ }, Ae = e.seriesType === "line";
564
+ let I = C.current.get(e.label);
565
+ const Y = e.data.map((g) => ({
566
+ ...g,
567
+ time: g.time
494
568
  }));
495
569
  if (Z !== void 0 && Y.length > 0 && Number(Y[0].time) > Z) {
496
- const h = Number(Y[0].time), F = h - Z, E = 86400, Ye = F > 180 * E ? 7 * E : F > 30 * E ? E : 6 * 3600, Ae = [];
497
- for (let ve = Z; ve < h; ve += Ye)
498
- Ae.push({ time: ve });
499
- Y.unshift(...Ae);
570
+ const g = Number(Y[0].time), B = g - Z, G = 86400, Ye = B > 180 * G ? 7 * G : B > 30 * G ? G : 6 * 3600, Ge = [];
571
+ for (let Se = Z; Se < g; Se += Ye)
572
+ Ge.push({ time: Se });
573
+ Y.unshift(...Ge);
500
574
  }
501
- D && D.seriesType() !== (Ee ? "Line" : "Area") && (t.removeSeries(D), y.current.delete(e.label), D = void 0), D ? (D.applyOptions(be), D.setData(Y)) : (Ee ? D = t.addSeries(tt, {
575
+ I && I.seriesType() !== (Ae ? "Line" : "Area") && (o.removeSeries(I), C.current.delete(e.label), I = void 0), I ? (I.applyOptions(ve), I.setData(Y)) : (Ae ? I = o.addSeries(tt, {
502
576
  ...Q,
503
- ...be
504
- }) : D = t.addSeries(ot, {
577
+ ...ve
578
+ }) : I = o.addSeries(ot, {
505
579
  ...Q,
506
- ...be
507
- }), D.setData(Y), y.current.set(e.label, D)), te++;
580
+ ...ve
581
+ }), I.setData(Y), C.current.set(e.label, I)), oe++;
508
582
  }
509
- if (L)
583
+ if (D)
510
584
  try {
511
- const r = t.priceScale("left"), e = t.priceScale("right"), u = {
512
- visible: !R,
585
+ const r = o.priceScale("left"), e = o.priceScale("right"), p = {
586
+ visible: !V,
513
587
  autoScale: !0,
514
588
  scaleMargins: { top: 0.1, bottom: 0.1 },
515
589
  alignLabels: !0,
516
590
  borderVisible: !0,
517
591
  borderColor: "rgba(224, 227, 235, 0.1)",
518
592
  entireTextOnly: !1,
519
- textColor: M
593
+ textColor: L
520
594
  };
521
- r?.applyOptions(u), e?.applyOptions(u);
595
+ r?.applyOptions(p), e?.applyOptions(p);
522
596
  } catch {
523
597
  }
524
- else if (C && ee.length > 0)
525
- for (const r of ee)
598
+ else if (y && te.length > 0)
599
+ for (const r of te)
526
600
  try {
527
- const e = t.priceScale(r.priceScaleId);
601
+ const e = o.priceScale(r.priceScaleId);
528
602
  e && e.applyOptions({
529
603
  visible: !1,
530
604
  autoScale: !0,
@@ -540,7 +614,7 @@ function Lt({
540
614
  borderVisible: !0,
541
615
  borderColor: "rgba(224, 227, 235, 0.1)",
542
616
  entireTextOnly: !1,
543
- textColor: M
617
+ textColor: L
544
618
  });
545
619
  } catch (e) {
546
620
  console.warn(
@@ -548,17 +622,17 @@ function Lt({
548
622
  e
549
623
  );
550
624
  }
551
- else if (!C)
625
+ else if (!y)
552
626
  try {
553
- const r = t.priceScale("right");
627
+ const r = o.priceScale("right");
554
628
  r && r.applyOptions({
555
- visible: !R,
629
+ visible: !V,
556
630
  autoScale: !0,
557
631
  scaleMargins: {
558
632
  top: 0.1,
559
633
  // No bottom margin when yScaleMin is set so the scale doesn't extend below the minimum (avoids negative labels like -10M)
560
- bottom: l !== void 0 || p ? 0 : 0.1,
561
- ...p && {
634
+ bottom: n !== void 0 || m ? 0 : 0.1,
635
+ ...m && {
562
636
  top: 0.3
563
637
  }
564
638
  },
@@ -566,297 +640,324 @@ function Lt({
566
640
  borderVisible: !0,
567
641
  borderColor: "rgba(224, 227, 235, 0.1)",
568
642
  entireTextOnly: !1,
569
- textColor: M
643
+ textColor: L
570
644
  });
571
645
  } catch {
572
646
  }
573
- if (l !== void 0 && !R && ($ || !C) && t.applyOptions({
647
+ if (n !== void 0 && !V && (A || !y) && o.applyOptions({
574
648
  handleScroll: {
575
649
  vertTouchDrag: !1
576
650
  }
577
- }), G.length > 0) {
578
- const r = G.map((S) => Number(S.time)), e = Math.min(...r), u = Z !== void 0 ? Math.min(Z, e) : e, B = Math.max(...r);
579
- t.timeScale().setVisibleRange({ from: u, to: B });
651
+ }), H.length > 0) {
652
+ const r = H.map((e) => Number(e.time)).filter((e) => Number.isFinite(e));
653
+ if (r.length > 0) {
654
+ const e = Math.min(...r), p = Z !== void 0 ? Math.min(Z, e) : e, k = Math.max(...r);
655
+ if (Number(p) <= Number(k))
656
+ try {
657
+ o.timeScale().setVisibleRange({ from: p, to: k });
658
+ } catch {
659
+ try {
660
+ o.timeScale().fitContent();
661
+ } catch {
662
+ }
663
+ }
664
+ }
580
665
  }
581
- Re.current && (Re.current = !1);
582
- const me = /* @__PURE__ */ new Map();
583
- for (const r of o)
584
- r.data.length > 0 && me.set(r.label, r.data[r.data.length - 1]);
585
- de(me.size > 0 ? me : void 0);
666
+ Pe.current && (Pe.current = !1);
667
+ const ge = /* @__PURE__ */ new Map();
668
+ for (const r of t)
669
+ r.data.length > 0 && ge.set(r.label, r.data[r.data.length - 1]);
670
+ me(ge.size > 0 ? ge : void 0);
586
671
  }, [
587
- o,
588
- G,
672
+ t,
673
+ H,
589
674
  d,
590
- N,
591
- R,
592
- $,
593
- L,
594
- we,
595
- Te,
675
+ v,
676
+ V,
677
+ A,
678
+ D,
679
+ _e,
596
680
  Ne,
681
+ Te,
597
682
  Ve,
598
683
  Z,
599
- k,
600
- A
601
- ]), W(() => {
602
- const t = I.current;
603
- if (!t || o.length === 0) return;
604
- const a = o.length === 1;
605
- let l;
606
- for (const i of o)
684
+ M,
685
+ j
686
+ ]), E(() => {
687
+ const o = z.current;
688
+ if (!o || t.length === 0) return;
689
+ const s = t.length === 1;
690
+ let n;
691
+ for (const i of t)
607
692
  if (i.data.length > 0) {
608
- l = i.data[i.data.length - 1].time;
693
+ n = i.data[i.data.length - 1].time;
609
694
  break;
610
695
  }
611
- if (!l) return;
612
- const n = (i) => {
613
- const { time: f = l, seriesData: c, point: b } = i || {}, v = Array.from(y.current.values());
614
- if (!b || !f) {
615
- const w = /* @__PURE__ */ new Map();
616
- for (const p of o)
617
- p.data.length > 0 && w.set(p.label, p.data[p.data.length - 1]);
618
- if (de(w.size > 0 ? w : void 0), a || $ || fe)
619
- j(null);
620
- else if (v[0] && l) {
621
- const C = t.timeScale().timeToCoordinate(l), P = o[0];
622
- if (P.data.length > 0) {
623
- const M = P.data[P.data.length - 1].value, V = v[0].priceToCoordinate(M);
624
- C !== null && V !== null && j({ x: C, y: V });
696
+ if (!n) return;
697
+ const a = (i) => {
698
+ const { time: u = n, seriesData: h, point: b } = i || {}, S = Array.from(C.current.values());
699
+ if (!b || !u) {
700
+ const _ = /* @__PURE__ */ new Map();
701
+ for (const m of t)
702
+ m.data.length > 0 && _.set(m.label, m.data[m.data.length - 1]);
703
+ if (me(_.size > 0 ? _ : void 0), s || A || he)
704
+ O(null);
705
+ else if (S[0] && n) {
706
+ const y = o.timeScale().timeToCoordinate(n), R = t[0];
707
+ if (R.data.length > 0) {
708
+ const L = R.data[R.data.length - 1].value, N = S[0].priceToCoordinate(L);
709
+ y !== null && N !== null && O({ x: y, y: N });
625
710
  }
626
711
  }
627
712
  return;
628
713
  }
629
- const H = /* @__PURE__ */ new Map();
630
- let _;
631
- for (let w = 0; w < o.length; w++) {
632
- const p = o[w], C = v[w];
633
- if (!C) continue;
634
- const P = c?.get(C), M = P && "value" in P ? P.value : void 0;
635
- let V;
636
- if (M !== void 0)
637
- V = M;
638
- else if (a) {
639
- const J = Number(f), Q = p.data.length > 0 ? Number(p.data[0].time) : Number.POSITIVE_INFINITY;
640
- J < Q ? V = Number.NaN : V = p.data[p.data.length - 1]?.value ?? 0;
641
- } else
642
- V = mt(p.data, Number(f));
643
- Number.isNaN(V) || (_ === void 0 && (_ = V), H.set(p.label, { value: V, time: f }));
714
+ const W = /* @__PURE__ */ new Map();
715
+ let P;
716
+ for (let _ = 0; _ < t.length; _++) {
717
+ const m = t[_], y = C.current.get(m.label);
718
+ if (!y) continue;
719
+ const R = h?.get(y), L = R && "value" in R ? R.value : void 0;
720
+ let N;
721
+ if (L !== void 0)
722
+ N = L;
723
+ else if (s) {
724
+ const X = Number(u), Q = m.data.length > 0 ? Number(m.data[0].time) : Number.POSITIVE_INFINITY;
725
+ X < Q ? N = Number.NaN : N = m.data[m.data.length - 1]?.value ?? 0;
726
+ } else {
727
+ const X = m.data.length > 0 ? Number(m.data[0].time) : Number.POSITIVE_INFINITY;
728
+ if (Number(u) < X) continue;
729
+ N = St(m.data, Number(u));
730
+ }
731
+ Number.isNaN(N) || (P === void 0 && (P = N), W.set(m.label, { value: N, time: u }));
644
732
  }
645
- if (de(H), _ !== void 0 && v[0]) {
646
- const p = t.timeScale().timeToCoordinate(f), C = v[0].priceToCoordinate(_);
647
- if (p !== null && C !== null) {
648
- const P = K.current;
649
- if (P) {
650
- const M = P.querySelector(
733
+ if (me(W), P !== void 0 && S[0]) {
734
+ const m = o.timeScale().timeToCoordinate(u), y = S[0].priceToCoordinate(P);
735
+ if (m !== null && y !== null) {
736
+ const R = K.current;
737
+ if (R) {
738
+ const L = R.querySelector(
651
739
  ".LightweightChart"
652
740
  );
653
- if (M) {
654
- const V = M.getBoundingClientRect(), J = P.getBoundingClientRect(), Q = p + (V.left - J.left), ee = C + (V.top - J.top);
655
- j({ x: Q, y: ee });
741
+ if (L) {
742
+ const N = L.getBoundingClientRect(), X = R.getBoundingClientRect(), Q = m + (N.left - X.left), te = y + (N.top - X.top);
743
+ O({ x: Q, y: te });
656
744
  } else
657
- j({ x: p, y: C });
745
+ O({ x: m, y });
658
746
  } else
659
- j({ x: p, y: C });
747
+ O({ x: m, y });
660
748
  } else
661
- j(null);
749
+ O(null);
662
750
  } else
663
- j(null);
751
+ O(null);
664
752
  };
665
- return t.subscribeCrosshairMove(n), R && t.subscribeClick(n), !a && !$ && !fe && requestAnimationFrame(() => {
666
- const i = Array.from(y.current.values());
667
- if (i[0] && l && o[0]?.data.length > 0) {
668
- const c = t.timeScale().timeToCoordinate(l), b = o[0].data[o[0].data.length - 1].value, v = i[0].priceToCoordinate(b);
669
- c !== null && v !== null && j({ x: c, y: v });
753
+ return o.subscribeCrosshairMove(a), V && o.subscribeClick(a), !s && !A && !he && requestAnimationFrame(() => {
754
+ const i = Array.from(C.current.values());
755
+ if (i[0] && n && t[0]?.data.length > 0) {
756
+ const h = o.timeScale().timeToCoordinate(n), b = t[0].data[t[0].data.length - 1].value, S = i[0].priceToCoordinate(b);
757
+ h !== null && S !== null && O({ x: h, y: S });
670
758
  }
671
759
  }), () => {
672
- t.unsubscribeCrosshairMove(n), R && t.unsubscribeClick(n);
760
+ o.unsubscribeCrosshairMove(a), V && o.unsubscribeClick(a);
673
761
  };
674
- }, [o, $, R, fe]), W(() => {
675
- const t = I.current;
676
- if (!t || o.length === 0) return;
677
- const a = t.timeScale(), l = () => {
678
- const n = Pe.current;
679
- if (n.length === 0) return;
680
- const i = a.getVisibleRange();
762
+ }, [t, A, V, he]), E(() => {
763
+ const o = z.current;
764
+ if (!o || t.length === 0) return;
765
+ const s = o.timeScale(), n = () => {
766
+ const a = Re.current;
767
+ if (a.length === 0) return;
768
+ const i = s.getVisibleRange();
681
769
  if (!i) return;
682
- const f = Number(i.from), c = Number(i.to);
683
- for (const b of n) {
684
- const v = [];
685
- for (const H of o)
686
- if (b.labels.has(H.label))
687
- for (const _ of H.data) {
688
- const w = Number(_.time);
689
- w >= f && w <= c && v.push(_.value);
770
+ const u = Number(i.from), h = Number(i.to);
771
+ for (const b of a) {
772
+ const S = [];
773
+ for (const W of t)
774
+ if (b.labels.has(W.label))
775
+ for (const P of W.data) {
776
+ const _ = Number(P.time);
777
+ _ >= u && _ <= h && S.push(P.value);
690
778
  }
691
- v.length > 0 && b.updateVisibleRange(v);
779
+ S.length > 0 && b.updateVisibleRange(S);
692
780
  }
693
781
  };
694
- return a.subscribeVisibleLogicalRangeChange(l), () => {
695
- a.unsubscribeVisibleLogicalRangeChange(
696
- l
782
+ return s.subscribeVisibleLogicalRangeChange(n), () => {
783
+ s.unsubscribeVisibleLogicalRangeChange(
784
+ n
697
785
  );
698
786
  };
699
- }, [o]), W(() => {
700
- const t = I.current, a = Array.from(y.current.values()), l = [];
701
- if (t && a.length > 0 && x) {
702
- const n = at(), i = a[0];
703
- for (const f of x) {
704
- const c = {
705
- ...n,
706
- ...f.options || {}
787
+ }, [t]), E(() => {
788
+ const o = z.current, s = Array.from(C.current.values()), n = [];
789
+ if (o && s.length > 0 && x) {
790
+ const a = it(), i = s[0];
791
+ for (const u of x) {
792
+ const h = {
793
+ ...a,
794
+ ...u.options || {}
707
795
  };
708
- c.color && (c.color = U(c.color, c.color));
709
- const b = new ut(t, i, f.xCoordinate, c);
710
- i.attachPrimitive(b), l.push(b);
796
+ h.color && (h.color = U(h.color, h.color));
797
+ const b = new ut(o, i, u.xCoordinate, h);
798
+ i.attachPrimitive(b), n.push(b);
711
799
  }
712
800
  }
713
801
  return () => {
714
- if (a.length > 0) {
715
- const n = a[0];
716
- for (const i of l)
717
- n.detachPrimitive(i);
802
+ if (s.length > 0) {
803
+ const a = s[0];
804
+ for (const i of n)
805
+ a.detachPrimitive(i);
718
806
  }
719
807
  };
720
- }, [x, o]), W(() => {
721
- const t = [];
722
- if (k && k.length > 0) {
723
- const a = Array.from(y.current.values())[0], l = U(
808
+ }, [x, t]), E(() => {
809
+ const o = [], s = [];
810
+ if (M && M.length > 0) {
811
+ const n = Array.from(C.current.values())[0], a = U(
724
812
  "hsl(var(--destructive))",
725
813
  "rgb(239, 68, 68)"
726
814
  );
727
- for (const n of k) {
728
- if (!Number.isFinite(n.price)) continue;
729
- const i = n.seriesLabel ? y.current.get(n.seriesLabel) : a;
730
- if (!i) continue;
731
- const f = i.createPriceLine({
732
- price: n.price,
733
- color: n.color ? U(n.color, n.color) : l,
734
- lineWidth: n.lineWidth ?? 1,
735
- lineStyle: n.lineStyle ?? Ge.Dashed,
736
- axisLabelVisible: n.axisLabelVisible ?? !0,
737
- title: n.title ?? ""
815
+ for (const i of M) {
816
+ if (!Number.isFinite(i.price)) continue;
817
+ const u = i.seriesLabel ? C.current.get(i.seriesLabel) : n;
818
+ if (!u) continue;
819
+ const h = i.color ? U(i.color, i.color) : a, b = i.lineWidth ?? 1, S = i.lineStyle ?? ee.Dashed, W = u.createPriceLine({
820
+ price: i.price,
821
+ color: h,
822
+ lineWidth: b,
823
+ lineStyle: S,
824
+ axisLabelVisible: i.axisLabelVisible ?? !0,
825
+ title: i.title ?? ""
738
826
  });
739
- t.push({ series: i, line: f });
827
+ o.push({ series: u, line: W });
828
+ const P = new bt(
829
+ u,
830
+ i.price,
831
+ h,
832
+ b,
833
+ S
834
+ );
835
+ u.attachPrimitive(P), s.push({ series: u, primitive: P });
740
836
  }
741
837
  }
742
838
  return () => {
743
- for (const { series: a, line: l } of t)
839
+ for (const { series: n, primitive: a } of s)
744
840
  try {
745
- a.removePriceLine(l);
841
+ n.detachPrimitive(a);
842
+ } catch {
843
+ }
844
+ for (const { series: n, line: a } of o)
845
+ try {
846
+ n.removePriceLine(a);
746
847
  } catch {
747
848
  }
748
849
  };
749
- }, [k, o]), W(() => {
750
- const t = [];
751
- if (A && A.length > 0) {
752
- const a = Array.from(y.current.values())[0], l = "rgba(239, 68, 68, 0.12)";
753
- for (const n of A) {
754
- const i = n.seriesLabel ? y.current.get(n.seriesLabel) : a;
850
+ }, [M, t]), E(() => {
851
+ const o = [];
852
+ if (j && j.length > 0) {
853
+ const s = Array.from(C.current.values())[0], n = "rgba(239, 68, 68, 0.12)";
854
+ for (const a of j) {
855
+ const i = a.seriesLabel ? C.current.get(a.seriesLabel) : s;
755
856
  if (!i) continue;
756
- const f = n.color ? U(n.color, l) : l, c = new gt(
857
+ const u = a.color ? U(a.color, n) : n, h = new dt(
757
858
  i,
758
- n.priceTop,
759
- n.priceBottom,
760
- f
859
+ a.priceTop,
860
+ a.priceBottom,
861
+ u
761
862
  );
762
- i.attachPrimitive(c), t.push({ series: i, zone: c });
863
+ i.attachPrimitive(h), o.push({ series: i, zone: h });
763
864
  }
764
865
  }
765
866
  return () => {
766
- for (const { series: a, zone: l } of t)
867
+ for (const { series: s, zone: n } of o)
767
868
  try {
768
- a.detachPrimitive(l);
869
+ s.detachPrimitive(n);
769
870
  } catch {
770
871
  }
771
872
  };
772
- }, [A, o]), W(() => {
773
- const t = I.current;
774
- if (!t || !x?.length) {
775
- _e([]);
873
+ }, [j, t]), E(() => {
874
+ const o = z.current;
875
+ if (!o || !x?.length) {
876
+ De([]);
776
877
  return;
777
878
  }
778
- const a = () => {
779
- const i = t.timeScale(), f = x.map((c) => i.timeToCoordinate(c.xCoordinate) ?? null);
780
- _e(f);
879
+ const s = () => {
880
+ const i = o.timeScale(), u = x.map((h) => i.timeToCoordinate(h.xCoordinate) ?? null);
881
+ De(u);
781
882
  };
782
- a();
783
- const l = t.timeScale(), n = () => {
784
- a();
883
+ s();
884
+ const n = o.timeScale(), a = () => {
885
+ s();
785
886
  };
786
- return l.subscribeVisibleLogicalRangeChange(n), () => {
787
- l.unsubscribeVisibleLogicalRangeChange(n);
887
+ return n.subscribeVisibleLogicalRangeChange(a), () => {
888
+ n.unsubscribeVisibleLogicalRangeChange(a);
788
889
  };
789
- }, [x, o]);
790
- const ie = o.length === 1, Be = Ce.useMemo(() => {
791
- if (ie && o.length > 0) {
792
- const t = o[0];
793
- if (t.data.length > 0)
794
- return t.data[t.data.length - 1];
890
+ }, [x, t]);
891
+ const se = t.length === 1, Ie = Ce.useMemo(() => {
892
+ if (se && t.length > 0) {
893
+ const o = t[0];
894
+ if (o.data.length > 0)
895
+ return o.data[o.data.length - 1];
795
896
  }
796
- }, [ie, o]);
797
- return /* @__PURE__ */ re(
897
+ }, [se, t]);
898
+ return /* @__PURE__ */ ne(
798
899
  "div",
799
900
  {
800
901
  ref: K,
801
- className: ne(
902
+ className: le(
802
903
  "relative z-[1] w-full h-full overflow-hidden p-0",
803
- s
904
+ l
804
905
  ),
805
906
  children: [
806
- ue != null && ue !== !1 && ie ? /* @__PURE__ */ T("div", { className: "absolute top-2 left-2 right-2 z-[100] pointer-events-none", children: /* @__PURE__ */ T("div", { className: "text-xl sm:text-2xl font-semibold text-foreground whitespace-nowrap overflow-hidden text-ellipsis", children: ue }) }) : qe && ie && Be && /* @__PURE__ */ T(
907
+ fe != null && fe !== !1 && se ? /* @__PURE__ */ w("div", { className: "absolute top-2 left-2 right-2 z-[100] pointer-events-none", children: /* @__PURE__ */ w("div", { className: "text-xl sm:text-2xl font-semibold text-foreground whitespace-nowrap overflow-hidden text-ellipsis", children: fe }) }) : Xe && se && Ie && /* @__PURE__ */ w(
807
908
  st,
808
909
  {
809
- point: Be,
910
+ point: Ie,
810
911
  xMeasureUnit: d,
811
- yMeasureUnit: N,
812
- decimals: ce
912
+ yMeasureUnit: v,
913
+ decimals: ue
813
914
  }
814
915
  ),
815
- Me && ke && /* @__PURE__ */ T(
916
+ Le && Me && /* @__PURE__ */ w(
816
917
  ct,
817
918
  {
818
- points: Me,
919
+ points: Le,
819
920
  xMeasureUnit: d,
820
- yMeasureUnit: N,
821
- series: o,
822
- position: ke,
921
+ yMeasureUnit: v,
922
+ series: t,
923
+ position: Me,
823
924
  containerRef: K,
824
- decimals: ce
925
+ decimals: ue
825
926
  }
826
927
  ),
827
- g && /* @__PURE__ */ T(bt, { series: o, onUnselect: m }),
828
- x && x.length > 0 && Le.length === x.length && /* @__PURE__ */ T(
928
+ f && /* @__PURE__ */ w(yt, { series: t, onUnselect: c }),
929
+ x && x.length > 0 && ke.length === x.length && /* @__PURE__ */ w(
829
930
  "div",
830
931
  {
831
932
  className: "absolute inset-0 z-[5] pointer-events-none",
832
933
  "aria-hidden": !0,
833
- children: x.map((t, a) => {
834
- const l = Le[a], n = t.options ?? {}, i = n.showLabel !== !1;
835
- if (l === null || !i) return null;
836
- const { labelText: f, valueStr: c } = dt(
837
- n,
838
- N,
839
- ce
840
- ), b = n.tooltipText ?? "";
841
- if (!(f || c || b)) return null;
842
- const H = n.labelBackgroundColor ?? n.color ?? "hsl(var(--background))", _ = n.labelTextColor ?? "hsl(var(--foreground))", w = `${String(t.xCoordinate)}-${f}-${b}`;
843
- return /* @__PURE__ */ re(
934
+ children: x.map((o, s) => {
935
+ const n = ke[s], a = o.options ?? {}, i = a.showLabel !== !1;
936
+ if (n === null || !i) return null;
937
+ const { labelText: u, valueStr: h } = vt(
938
+ a,
939
+ v,
940
+ ue
941
+ ), b = a.tooltipText ?? "";
942
+ if (!(u || h || b)) return null;
943
+ const W = a.labelBackgroundColor ?? a.color ?? "hsl(var(--background))", P = a.labelTextColor ?? "hsl(var(--foreground))", _ = `${String(o.xCoordinate)}-${u}-${b}`;
944
+ return /* @__PURE__ */ ne(
844
945
  "div",
845
946
  {
846
- className: ne(
947
+ className: le(
847
948
  "group absolute top-2 px-2 py-1 rounded text-xs font-medium whitespace-nowrap shadow-sm border border-border",
848
949
  b && "pointer-events-auto cursor-default"
849
950
  ),
850
951
  style: {
851
- left: l,
952
+ left: n,
852
953
  transform: "translateX(-50%)",
853
- backgroundColor: H,
854
- color: _
954
+ backgroundColor: W,
955
+ color: P
855
956
  },
856
957
  children: [
857
- f && /* @__PURE__ */ T("span", { className: "block", children: f }),
858
- c && /* @__PURE__ */ T("span", { className: ne("block", f && "mt-0.5"), children: c }),
859
- b && /* @__PURE__ */ T(
958
+ u && /* @__PURE__ */ w("span", { className: "block", children: u }),
959
+ h && /* @__PURE__ */ w("span", { className: le("block", u && "mt-0.5"), children: h }),
960
+ b && /* @__PURE__ */ w(
860
961
  "span",
861
962
  {
862
963
  className: "pointer-events-none absolute right-0 top-full z-10 mt-1 hidden w-[280px] whitespace-normal rounded border border-border bg-popover px-2.5 py-1.5 text-left leading-snug text-popover-foreground shadow-md group-hover:block",
@@ -866,15 +967,15 @@ function Lt({
866
967
  )
867
968
  ]
868
969
  },
869
- w
970
+ _
870
971
  );
871
972
  })
872
973
  }
873
974
  ),
874
- /* @__PURE__ */ T(
975
+ /* @__PURE__ */ w(
875
976
  "div",
876
977
  {
877
- ref: ge,
978
+ ref: pe,
878
979
  className: "LightweightChart w-full h-full overflow-hidden"
879
980
  }
880
981
  )
@@ -882,49 +983,49 @@ function Lt({
882
983
  }
883
984
  );
884
985
  }
885
- function bt({
886
- series: o,
887
- onUnselect: s,
888
- inline: g = !1
986
+ function yt({
987
+ series: t,
988
+ onUnselect: l,
989
+ inline: f = !1
889
990
  }) {
890
- return /* @__PURE__ */ T(
991
+ return /* @__PURE__ */ w(
891
992
  "div",
892
993
  {
893
- className: ne(
994
+ className: le(
894
995
  "flex flex-wrap gap-2",
895
- g ? "items-center" : "absolute top-0 left-2 z-[10]"
996
+ f ? "items-center" : "absolute top-0 left-2 z-[10]"
896
997
  ),
897
- children: o.map((m, d) => {
898
- const N = Xe(d), q = (m.lineColor ?? m.color) || N.line, x = m.data.length === 0;
899
- return /* @__PURE__ */ re(
998
+ children: t.map((c, d) => {
999
+ const v = Oe(d), F = (c.lineColor ?? c.color) || v.line, x = c.data.length === 0;
1000
+ return /* @__PURE__ */ ne(
900
1001
  "div",
901
1002
  {
902
- className: ne(
1003
+ className: le(
903
1004
  "flex items-center gap-1.5 px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border",
904
1005
  x && "opacity-50"
905
1006
  ),
906
1007
  children: [
907
- /* @__PURE__ */ T(
1008
+ /* @__PURE__ */ w(
908
1009
  "div",
909
1010
  {
910
1011
  className: "w-3 h-3 rounded-sm",
911
- style: { backgroundColor: q }
1012
+ style: { backgroundColor: F }
912
1013
  }
913
1014
  ),
914
- /* @__PURE__ */ re("span", { className: "text-[10px] sm:text-xs font-medium text-foreground", children: [
915
- m.label,
1015
+ /* @__PURE__ */ ne("span", { className: "text-[10px] sm:text-xs font-medium text-foreground", children: [
1016
+ c.label,
916
1017
  x && " (no data)"
917
1018
  ] }),
918
- s && /* @__PURE__ */ T(
1019
+ l && /* @__PURE__ */ w(
919
1020
  "button",
920
1021
  {
921
1022
  type: "button",
922
- onClick: (k) => {
923
- k.stopPropagation(), s(m.label);
1023
+ onClick: (M) => {
1024
+ M.stopPropagation(), l(c.label);
924
1025
  },
925
1026
  className: "ml-1 flex items-center justify-center w-4 h-4 rounded-sm hover:bg-muted transition-colors cursor-pointer",
926
- "aria-label": `Remove ${m.label}`,
927
- children: /* @__PURE__ */ re(
1027
+ "aria-label": `Remove ${c.label}`,
1028
+ children: /* @__PURE__ */ ne(
928
1029
  "svg",
929
1030
  {
930
1031
  xmlns: "http://www.w3.org/2000/svg",
@@ -939,9 +1040,9 @@ function bt({
939
1040
  className: "text-muted-foreground hover:text-foreground",
940
1041
  "aria-hidden": "true",
941
1042
  children: [
942
- /* @__PURE__ */ T("title", { children: "Close" }),
943
- /* @__PURE__ */ T("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
944
- /* @__PURE__ */ T("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
1043
+ /* @__PURE__ */ w("title", { children: "Close" }),
1044
+ /* @__PURE__ */ w("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
1045
+ /* @__PURE__ */ w("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
945
1046
  ]
946
1047
  }
947
1048
  )
@@ -949,17 +1050,17 @@ function bt({
949
1050
  )
950
1051
  ]
951
1052
  },
952
- m.label
1053
+ c.label
953
1054
  );
954
1055
  })
955
1056
  }
956
1057
  );
957
1058
  }
958
1059
  export {
959
- ye as DEFAULT_SERIES_COLORS,
960
- Lt as Graph,
961
- bt as GraphLegend,
962
- Xe as getSeriesColorPalette,
963
- mt as getStepForwardValue,
964
- dt as getVerticalLineTooltipContent
1060
+ we as DEFAULT_SERIES_COLORS,
1061
+ Bt as Graph,
1062
+ yt as GraphLegend,
1063
+ Oe as getSeriesColorPalette,
1064
+ St as getStepForwardValue,
1065
+ vt as getVerticalLineTooltipContent
965
1066
  };