@gearbox-protocol/ui-kit 3.14.0-next.35 → 3.14.0-next.37

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