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

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,30 +1,30 @@
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 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";
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(s, g, m) {
18
+ this._yTop = s, this._yBottom = g, this._color = m;
19
19
  }
20
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);
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);
24
24
  });
25
25
  }
26
26
  }
27
- class ft {
27
+ class ht {
28
28
  _source;
29
29
  _yTop = null;
30
30
  _yBottom = null;
@@ -40,17 +40,17 @@ class ft {
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(s, g, m, d) {
53
+ this.series = s, this.priceTop = g, this.priceBottom = m, this.color = d, this._paneViews = [new ht(this)];
54
54
  }
55
55
  updateAllViews() {
56
56
  for (const s of this._paneViews) s.update();
@@ -59,18 +59,18 @@ class ht {
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,
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(
64
+ d,
65
65
  s !== "none" && s !== "%" && s !== "$" ? s : void 0,
66
- f
67
- ) : String(h);
68
- return { labelText: m, valueStr: w };
66
+ g
67
+ ) : String(d);
68
+ return { labelText: m, valueStr: N };
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, s) {
71
+ for (let g = o.length - 1; g >= 0; g--)
72
+ if (Number(o[g].time) <= s)
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
+ ], 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 };
197
197
  }
198
198
  function Lt({
199
- series: t,
199
+ series: o,
200
200
  className: s,
201
- showLegend: f = !1,
201
+ showLegend: g = !1,
202
202
  onUnselectSeries: m,
203
- xMeasureUnit: h = "time",
204
- yMeasureUnit: w = "token",
205
- optionsOverrides: X,
206
- verticalLineOptions: b,
207
- priceLineOptions: V,
208
- zoneOptions: E,
209
- currentValueDecimals: ie,
210
- useSharedPriceScale: I = !1,
203
+ xMeasureUnit: d = "time",
204
+ yMeasureUnit: N = "token",
205
+ optionsOverrides: q,
206
+ verticalLineOptions: x,
207
+ priceLineOptions: k,
208
+ zoneOptions: A,
209
+ currentValueDecimals: ce,
210
+ useSharedPriceScale: $ = !1,
211
211
  dualYAxis: L = !1,
212
212
  defaultVisiblePriceScaleId: we = "right",
213
213
  leftPriceScaleTitle: Te,
214
- rightPriceScaleTitle: pt,
215
- showCurrentValue: je = !0,
216
- graphTitle: se,
214
+ rightPriceScaleTitle: vt,
215
+ showCurrentValue: qe = !0,
216
+ graphTitle: ue,
217
217
  yScaleMin: Ne,
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), 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];
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, y.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 ? Ne : 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, u) => {
335
+ const {
336
+ formatter: B,
337
+ tickmarksFormatter: S,
338
+ updateVisibleRange: z,
339
+ 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)
346
+ 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);
353
+ }
354
+ e.size > 0 && c.push(f(u, B, e));
355
+ }
356
+ else {
357
+ const r = G.map((u) => u.value), e = new Set(
358
+ o.filter((u) => u.data.length > 0).map((u) => u.label)
359
+ );
360
+ c.push(f(r, N, e));
361
+ }
362
+ Pe.current = c;
363
+ const b = /* @__PURE__ */ new Map();
364
+ for (const r of c)
365
+ for (const e of r.labels)
366
+ b.set(e, r);
367
+ const v = je();
368
+ t.applyOptions({
340
369
  localization: {
341
- ...P.localization || {},
370
+ ...v.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
+ ...v.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 _ = (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(
356
385
  "hsl(var(--foreground))",
357
386
  "rgb(0, 0, 0)"
358
387
  );
359
- e.applyOptions({
388
+ t.applyOptions({
360
389
  ...L && {
361
390
  defaultVisiblePriceScaleId: we
362
391
  },
363
392
  leftPriceScale: {
364
- ...P.leftPriceScale || {},
365
- visible: L && !T,
366
- textColor: D,
393
+ ...v.leftPriceScale || {},
394
+ visible: L && !R,
395
+ textColor: M,
367
396
  ...L && Te && {
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
+ ...v.rightPriceScale || {},
402
+ visible: L ? !R : !P,
403
+ textColor: M,
404
+ ...p && !L && {
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 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));
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 De = 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 ?? De?.label;
425
+ if (!e) continue;
426
+ const u = oe.get(e) ?? [];
427
+ u.push(r.price), oe.set(e, u);
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 ?? De?.label;
432
+ 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);
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], u = Xe(r), B = e.lineColor ?? e.color ?? u.line;
438
+ let S, z;
439
+ if (e.lineColor ?? e.color)
440
+ if (e.topColor && e.bottomColor)
441
+ S = e.topColor, z = e.bottomColor;
442
+ else if (e.topColor) {
443
+ const h = se(B);
444
+ S = e.topColor, z = h.bottomColor;
445
+ } else if (e.bottomColor)
446
+ S = se(B).topColor, z = e.bottomColor;
418
447
  else {
419
- const u = le(K);
420
- H = u.topColor, O = u.bottomColor;
448
+ const h = se(B);
449
+ S = 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
+ S = e.topColor || u.top, z = e.bottomColor || u.bottom;
453
+ if (e.data.length === 0) {
454
+ const h = y.current.get(e.label);
455
+ h && (t.removeSeries(h), y.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 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",
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 = ($ || !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);
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 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,
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 D = y.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), 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);
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,
474
- ...pe
475
- }) : M = e.addSeries(tt, {
476
- ...Be,
477
- ...pe
478
- }), M.setData(J), p.current.set(r.label, M)), Y++;
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, {
502
+ ...Q,
503
+ ...be
504
+ }) : D = t.addSeries(ot, {
505
+ ...Q,
506
+ ...be
507
+ }), D.setData(Y), y.current.set(e.label, D)), te++;
479
508
  }
480
509
  if (L)
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"), u = {
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(u), e?.applyOptions(u);
493
522
  } catch {
494
523
  }
495
- else if (N && de.length > 0)
496
- for (const o of de)
524
+ else if (C && 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 (!C)
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 || p ? 0 : 0.1,
561
+ ...p && {
533
562
  top: 0.3
534
563
  }
535
564
  },
@@ -537,141 +566,148 @@ 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 && ($ || !C) && 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((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 });
551
580
  }
552
581
  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);
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);
557
586
  }, [
558
- t,
587
+ o,
559
588
  G,
560
- h,
561
- w,
562
- T,
563
- I,
589
+ d,
590
+ N,
591
+ R,
592
+ $,
564
593
  L,
565
594
  we,
566
595
  Te,
567
596
  Ne,
568
597
  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;
598
+ 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;
576
605
  let l;
577
- for (const i of t)
606
+ for (const i of o)
578
607
  if (i.data.length > 0) {
579
608
  l = i.data[i.data.length - 1].time;
580
609
  break;
581
610
  }
582
611
  if (!l) return;
583
612
  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)
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)
590
619
  j(null);
591
620
  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 });
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 });
596
625
  }
597
626
  }
598
627
  return;
599
628
  }
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;
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;
609
638
  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;
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;
612
641
  } 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 }));
642
+ V = mt(p.data, Number(f));
643
+ Number.isNaN(V) || (_ === void 0 && (_ = V), H.set(p.label, { value: V, time: f }));
615
644
  }
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(
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(
622
651
  ".LightweightChart"
623
652
  );
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 });
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 });
627
656
  } else
628
- j({ x: d, y: R });
657
+ j({ x: p, y: C });
629
658
  } else
630
- j({ x: d, y: R });
659
+ j({ x: p, y: C });
631
660
  } else
632
661
  j(null);
633
662
  } else
634
663
  j(null);
635
664
  };
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 });
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 });
641
670
  }
642
671
  }), () => {
643
- e.unsubscribeCrosshairMove(n), T && e.unsubscribeClick(n);
672
+ t.unsubscribeCrosshairMove(n), R && t.unsubscribeClick(n);
644
673
  };
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);
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();
681
+ 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);
690
+ }
691
+ v.length > 0 && b.updateVisibleRange(v);
692
+ }
659
693
  };
660
694
  return a.subscribeVisibleLogicalRangeChange(l), () => {
661
695
  a.unsubscribeVisibleLogicalRangeChange(
662
696
  l
663
697
  );
664
698
  };
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, {
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 = {
671
705
  ...n,
672
- ...c.options || {}
673
- });
674
- i.attachPrimitive(g), l.push(g);
706
+ ...f.options || {}
707
+ };
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);
675
711
  }
676
712
  }
677
713
  return () => {
@@ -681,153 +717,164 @@ function Lt({
681
717
  n.detachPrimitive(i);
682
718
  }
683
719
  };
684
- }, [b, t]), F(() => {
685
- const e = [];
686
- if (V && V.length > 0) {
687
- const a = Array.from(p.current.values())[0], l = ee(
720
+ }, [x, o]), W(() => {
721
+ const t = [];
722
+ if (k && k.length > 0) {
723
+ const a = Array.from(y.current.values())[0], l = U(
688
724
  "hsl(var(--destructive))",
689
725
  "rgb(239, 68, 68)"
690
726
  );
691
- for (const n of V) {
727
+ for (const n of k) {
692
728
  if (!Number.isFinite(n.price)) continue;
693
- const i = n.seriesLabel ? p.current.get(n.seriesLabel) : a;
729
+ const i = n.seriesLabel ? y.current.get(n.seriesLabel) : a;
694
730
  if (!i) continue;
695
- const c = i.createPriceLine({
731
+ const f = i.createPriceLine({
696
732
  price: n.price,
697
- color: n.color ? ee(n.color, n.color) : l,
733
+ color: n.color ? U(n.color, n.color) : l,
698
734
  lineWidth: n.lineWidth ?? 1,
699
- lineStyle: n.lineStyle ?? Ae.Dashed,
735
+ lineStyle: n.lineStyle ?? Ge.Dashed,
700
736
  axisLabelVisible: n.axisLabelVisible ?? !0,
701
737
  title: n.title ?? ""
702
738
  });
703
- e.push({ series: i, line: c });
739
+ t.push({ series: i, line: f });
704
740
  }
705
741
  }
706
742
  return () => {
707
- for (const { series: a, line: l } of e)
743
+ for (const { series: a, line: l } of t)
708
744
  try {
709
745
  a.removePriceLine(l);
710
746
  } catch {
711
747
  }
712
748
  };
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;
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;
719
755
  if (!i) continue;
720
- const c = n.color ? ee(n.color, l) : l, g = new ht(
756
+ const f = n.color ? U(n.color, l) : l, c = new gt(
721
757
  i,
722
758
  n.priceTop,
723
759
  n.priceBottom,
724
- c
760
+ f
725
761
  );
726
- i.attachPrimitive(g), e.push({ series: i, zone: g });
762
+ i.attachPrimitive(c), t.push({ series: i, zone: c });
727
763
  }
728
764
  }
729
765
  return () => {
730
- for (const { series: a, zone: l } of e)
766
+ for (const { series: a, zone: l } of t)
731
767
  try {
732
768
  a.detachPrimitive(l);
733
769
  } catch {
734
770
  }
735
771
  };
736
- }, [E, t]), F(() => {
737
- const e = k.current;
738
- if (!e || !b?.length) {
739
- Le([]);
772
+ }, [A, o]), W(() => {
773
+ const t = I.current;
774
+ if (!t || !x?.length) {
775
+ _e([]);
740
776
  return;
741
777
  }
742
778
  const a = () => {
743
- const i = e.timeScale(), c = b.map((g) => i.timeToCoordinate(g.xCoordinate) ?? null);
744
- Le(c);
779
+ const i = t.timeScale(), f = x.map((c) => i.timeToCoordinate(c.xCoordinate) ?? null);
780
+ _e(f);
745
781
  };
746
782
  a();
747
- const l = e.timeScale(), n = () => {
783
+ const l = t.timeScale(), n = () => {
748
784
  a();
749
785
  };
750
786
  return l.subscribeVisibleLogicalRangeChange(n), () => {
751
787
  l.unsubscribeVisibleLogicalRangeChange(n);
752
788
  };
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];
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];
759
795
  }
760
- }, [ne, t]);
761
- return /* @__PURE__ */ te(
796
+ }, [ie, o]);
797
+ return /* @__PURE__ */ re(
762
798
  "div",
763
799
  {
764
- ref: Z,
765
- className: ae(
800
+ ref: K,
801
+ className: ne(
766
802
  "relative z-[1] w-full h-full overflow-hidden p-0",
767
803
  s
768
804
  ),
769
805
  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,
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(
807
+ st,
772
808
  {
773
- point: ke,
774
- xMeasureUnit: h,
775
- yMeasureUnit: w,
776
- decimals: ie
809
+ point: Be,
810
+ xMeasureUnit: d,
811
+ yMeasureUnit: N,
812
+ decimals: ce
777
813
  }
778
814
  ),
779
- Pe && Me && /* @__PURE__ */ y(
780
- st,
815
+ Me && ke && /* @__PURE__ */ T(
816
+ ct,
781
817
  {
782
- points: Pe,
783
- xMeasureUnit: h,
784
- yMeasureUnit: w,
785
- series: t,
786
- position: Me,
787
- containerRef: Z,
788
- decimals: ie
818
+ points: Me,
819
+ xMeasureUnit: d,
820
+ yMeasureUnit: N,
821
+ series: o,
822
+ position: ke,
823
+ containerRef: K,
824
+ decimals: ce
789
825
  }
790
826
  ),
791
- f && /* @__PURE__ */ y(bt, { series: t, onUnselect: m }),
792
- b && b.length > 0 && _e.length === b.length && /* @__PURE__ */ y(
827
+ g && /* @__PURE__ */ T(bt, { series: o, onUnselect: m }),
828
+ x && x.length > 0 && Le.length === x.length && /* @__PURE__ */ T(
793
829
  "div",
794
830
  {
795
831
  className: "absolute inset-0 z-[5] pointer-events-none",
796
832
  "aria-hidden": !0,
797
- children: b.map((e, a) => {
798
- const l = _e[a], n = e.options ?? {}, i = n.showLabel !== !1;
833
+ children: x.map((t, a) => {
834
+ const l = Le[a], n = t.options ?? {}, i = n.showLabel !== !1;
799
835
  if (l === null || !i) return null;
800
- const { labelText: c, valueStr: g } = gt(
836
+ const { labelText: f, valueStr: c } = dt(
801
837
  n,
802
- 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(
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(
808
844
  "div",
809
845
  {
810
- className: "absolute top-2 px-2 py-1 rounded text-xs font-medium whitespace-nowrap shadow-sm border border-border",
846
+ className: ne(
847
+ "group absolute top-2 px-2 py-1 rounded text-xs font-medium whitespace-nowrap shadow-sm border border-border",
848
+ b && "pointer-events-auto cursor-default"
849
+ ),
811
850
  style: {
812
851
  left: l,
813
852
  transform: "translateX(-50%)",
814
- backgroundColor: v,
815
- color: W
853
+ backgroundColor: H,
854
+ color: _
816
855
  },
817
856
  children: [
818
- c && /* @__PURE__ */ y("span", { className: "block", children: c }),
819
- g && /* @__PURE__ */ y("span", { className: ae("block", c && "mt-0.5"), children: g })
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(
860
+ "span",
861
+ {
862
+ 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",
863
+ role: "tooltip",
864
+ children: b
865
+ }
866
+ )
820
867
  ]
821
868
  },
822
- P
869
+ w
823
870
  );
824
871
  })
825
872
  }
826
873
  ),
827
- /* @__PURE__ */ y(
874
+ /* @__PURE__ */ T(
828
875
  "div",
829
876
  {
830
- ref: he,
877
+ ref: ge,
831
878
  className: "LightweightChart w-full h-full overflow-hidden"
832
879
  }
833
880
  )
@@ -836,48 +883,48 @@ function Lt({
836
883
  );
837
884
  }
838
885
  function bt({
839
- series: t,
886
+ series: o,
840
887
  onUnselect: s,
841
- inline: f = !1
888
+ inline: g = !1
842
889
  }) {
843
- return /* @__PURE__ */ y(
890
+ return /* @__PURE__ */ T(
844
891
  "div",
845
892
  {
846
- className: ae(
893
+ className: ne(
847
894
  "flex flex-wrap gap-2",
848
- f ? "items-center" : "absolute top-0 left-2 z-[10]"
895
+ g ? "items-center" : "absolute top-0 left-2 z-[10]"
849
896
  ),
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(
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(
853
900
  "div",
854
901
  {
855
- className: ae(
902
+ className: ne(
856
903
  "flex items-center gap-1.5 px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border",
857
- b && "opacity-50"
904
+ x && "opacity-50"
858
905
  ),
859
906
  children: [
860
- /* @__PURE__ */ y(
907
+ /* @__PURE__ */ T(
861
908
  "div",
862
909
  {
863
910
  className: "w-3 h-3 rounded-sm",
864
- style: { backgroundColor: X }
911
+ style: { backgroundColor: q }
865
912
  }
866
913
  ),
867
- /* @__PURE__ */ te("span", { className: "text-[10px] sm:text-xs font-medium text-foreground", children: [
914
+ /* @__PURE__ */ re("span", { className: "text-[10px] sm:text-xs font-medium text-foreground", children: [
868
915
  m.label,
869
- b && " (no data)"
916
+ x && " (no data)"
870
917
  ] }),
871
- s && /* @__PURE__ */ y(
918
+ s && /* @__PURE__ */ T(
872
919
  "button",
873
920
  {
874
921
  type: "button",
875
- onClick: (V) => {
876
- V.stopPropagation(), s(m.label);
922
+ onClick: (k) => {
923
+ k.stopPropagation(), s(m.label);
877
924
  },
878
925
  className: "ml-1 flex items-center justify-center w-4 h-4 rounded-sm hover:bg-muted transition-colors cursor-pointer",
879
926
  "aria-label": `Remove ${m.label}`,
880
- children: /* @__PURE__ */ te(
927
+ children: /* @__PURE__ */ re(
881
928
  "svg",
882
929
  {
883
930
  xmlns: "http://www.w3.org/2000/svg",
@@ -892,9 +939,9 @@ function bt({
892
939
  className: "text-muted-foreground hover:text-foreground",
893
940
  "aria-hidden": "true",
894
941
  children: [
895
- /* @__PURE__ */ y("title", { children: "Close" }),
896
- /* @__PURE__ */ y("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
897
- /* @__PURE__ */ y("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
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" })
898
945
  ]
899
946
  }
900
947
  )
@@ -912,7 +959,7 @@ export {
912
959
  ye as DEFAULT_SERIES_COLORS,
913
960
  Lt as Graph,
914
961
  bt as GraphLegend,
915
- Ge as getSeriesColorPalette,
962
+ Xe as getSeriesColorPalette,
916
963
  mt as getStepForwardValue,
917
- gt as getVerticalLineTooltipContent
964
+ dt as getVerticalLineTooltipContent
918
965
  };