@gearbox-protocol/ui-kit 4.0.0-next.63 → 4.0.0-next.64

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,17 +1,18 @@
1
- import { jsxs as U, jsx as w } from "react/jsx-runtime";
2
- import { createChart as ft, CrosshairMode as ht, LineStyle as ie, LineSeries as dt, AreaSeries as pt } from "lightweight-charts";
3
- import * as _e from "react";
4
- import { useRef as K, useState as oe, useEffect as W, useLayoutEffect as mt } from "react";
5
- import { resolveCSSColor as re, generateColorsFromBase as we } from "./colors.js";
6
- import { useIsMobile as gt } from "../../hooks/use-media-query.js";
1
+ import { jsxs as U, jsx as _ } from "react/jsx-runtime";
2
+ import { createChart as ut, CrosshairMode as ft, LineStyle as ie, LineSeries as ht, AreaSeries as dt } from "lightweight-charts";
3
+ import * as we from "react";
4
+ import { useRef as K, useState as oe, useEffect as W, useLayoutEffect as pt } from "react";
5
+ import { resolveCSSColor as re, generateColorsFromBase as _e } from "./colors.js";
6
+ import { useIsMobile as mt } from "../../hooks/use-media-query.js";
7
7
  import { cn as J } from "../../utils/cn.js";
8
- import { AXIS_TIME_EDGE_PADDING_PX as bt, getDefaultOptions as Ke, getDefaultSeries as St, AXIS_TICK_MARK_DENSITY as pe, getDefaultVerticalLine as vt, AXIS_FONT_SIZE as Ct, AXIS_EDGE_LABEL_PADDING_PX as Ze, AXIS_TOP_LABEL_PADDING_PX as qe } from "./default-config.js";
9
- import { formatExactValue as Pe, isRatioUnit as yt, getXFormatters as Je, createAdaptiveYAxisFormatter as xt } from "./formatters.js";
10
- import { GraphCurrentValue as _t } from "./graph-current-value.js";
8
+ import { AXIS_TIME_EDGE_PADDING_PX as gt, getDefaultOptions as He, getDefaultSeries as bt, AXIS_TICK_MARK_DENSITY as pe, getDefaultVerticalLine as St, AXIS_FONT_SIZE as vt, AXIS_EDGE_LABEL_PADDING_PX as Ke, AXIS_TOP_LABEL_PADDING_PX as Ze } from "./default-config.js";
9
+ import { formatExactValue as Pe, isRatioUnit as Ct, getXFormatters as qe, createAdaptiveYAxisFormatter as yt } from "./formatters.js";
10
+ import { GraphCurrentValue as xt } from "./graph-current-value.js";
11
11
  import { GraphTooltip as wt } from "./graph-tooltip.js";
12
- import { VertLine as Pt } from "./plugins/vertical-line.js";
12
+ import { VertLine as _t } from "./plugins/vertical-line.js";
13
+ import { resolvePriceScaleSides as Pt } from "./series-config.js";
13
14
  import { getSeriesColorPalette as Ye } from "./series-palette.js";
14
- import { pickMinMove as Tt, niceAxisRange as Rt } from "./y-axis-scale.js";
15
+ import { pickMinMove as Rt, niceAxisRange as Tt } from "./y-axis-scale.js";
15
16
  function ne(e) {
16
17
  return e.id ?? e.label;
17
18
  }
@@ -20,7 +21,7 @@ function Nt({
20
21
  width: i,
21
22
  padLeft: c,
22
23
  padRight: f,
23
- paddingPx: h = bt
24
+ paddingPx: h = gt
24
25
  }) {
25
26
  if (e < 0) return null;
26
27
  const u = (c || f) && i > 0 ? h * Math.max(e, 1) / i : 0;
@@ -29,7 +30,7 @@ function Nt({
29
30
  to: f ? e + u : e
30
31
  };
31
32
  }
32
- function Qe(e, i, c) {
33
+ function Je(e, i, c) {
33
34
  if (!c)
34
35
  return e.values().next().value;
35
36
  const f = e.get(c);
@@ -163,17 +164,17 @@ class Bt {
163
164
  function Et(e, i, c) {
164
165
  const f = e.labelText ?? "", h = e.value, u = h === void 0 ? "" : typeof h == "number" ? i === "$" ? `$${Pe(h, void 0, c)}` : i === "%" ? `${Pe(h, void 0, c)}%` : Pe(
165
166
  h,
166
- i !== "none" && i !== "%" && i !== "$" && !yt(i) ? i : void 0,
167
+ i !== "none" && i !== "%" && i !== "$" && !Ct(i) ? i : void 0,
167
168
  c
168
169
  ) : String(h);
169
170
  return { labelText: f, valueStr: u };
170
171
  }
171
- const Oe = 4;
172
+ const Qe = 4;
172
173
  function Ft(e, i, c) {
173
174
  const f = { left: e, transform: "translateX(-50%)" };
174
175
  if (i <= 0 || !c || c <= 0)
175
176
  return f;
176
- const h = c / 2, u = Oe + h, S = i - Oe - h;
177
+ const h = c / 2, u = Qe + h, S = i - Qe - h;
177
178
  return S < u ? { left: i / 2, transform: "translateX(-50%)" } : { left: Math.min(Math.max(e, u), S), transform: "translateX(-50%)" };
178
179
  }
179
180
  function zt(e, i) {
@@ -192,88 +193,86 @@ function to({
192
193
  optionsOverrides: S,
193
194
  verticalLineOptions: P,
194
195
  priceLineOptions: D,
195
- zoneOptions: z,
196
- currentValueDecimals: le,
196
+ zoneOptions: F,
197
+ currentValueDecimals: se,
197
198
  useSharedPriceScale: Z = !1,
198
- dualYAxis: I = !1,
199
- defaultVisiblePriceScaleId: Te = "right",
200
- leftPriceScaleTitle: Re,
201
- rightPriceScaleTitle: Wt,
202
- showCurrentValue: Ue = !0,
199
+ dualYAxis: z = !1,
200
+ defaultVisiblePriceScaleId: Re = "right",
201
+ showCurrentValue: Oe = !0,
203
202
  graphTitle: me,
204
- yScaleMin: Ne,
205
- yScaleMinMultiple: Ve,
206
- visibleTimeFrom: se,
207
- disableZoom: ke = !1,
203
+ yScaleMin: Te,
204
+ yScaleMinMultiple: Ne,
205
+ visibleTimeFrom: le,
206
+ disableZoom: Ve = !1,
208
207
  hideDefaultTooltip: ge = !1
209
208
  }) {
210
- const B = K(null), N = K(/* @__PURE__ */ new Map()), be = K(!1), Le = K(!0), Me = K([]), ae = K(0), E = K(null), Se = K(null), De = K(null), T = gt(), ce = _e.useMemo(() => e.flatMap((t) => t.data), [e]), et = _e.useMemo(() => {
209
+ const I = K(null), N = K(/* @__PURE__ */ new Map()), be = K(!1), ke = K(!0), Le = K([]), ae = K(0), B = K(null), Se = K(null), Me = K(null), R = mt(), ce = we.useMemo(() => e.flatMap((t) => t.data), [e]), Ue = we.useMemo(() => {
211
210
  if (e.length > 0) {
212
211
  const t = e[e.length - 1];
213
212
  if (t.data.length > 0)
214
213
  return t.data[t.data.length - 1];
215
214
  }
216
- }, [e]), [Ie, ve] = oe(() => {
217
- if (!et) return;
215
+ }, [e]), [De, ve] = oe(() => {
216
+ if (!Ue) return;
218
217
  const t = /* @__PURE__ */ new Map();
219
- for (const s of e)
220
- s.data.length > 0 && t.set(s.label, s.data[s.data.length - 1]);
218
+ for (const l of e)
219
+ l.data.length > 0 && t.set(l.label, l.data[l.data.length - 1]);
221
220
  return t;
222
- }), [Be, Q] = oe(null), [Ee, Fe] = oe([]), [tt, ze] = oe(0), Ae = K(/* @__PURE__ */ new Map()), [ot, rt] = oe({}), [O, nt] = oe(0);
221
+ }), [Ie, Q] = oe(null), [Be, Ee] = oe([]), [et, Fe] = oe(0), ze = K(/* @__PURE__ */ new Map()), [tt, ot] = oe({}), [Y, rt] = oe(0);
223
222
  W(() => {
224
223
  const t = () => {
225
224
  try {
226
- if (E.current && ze(E.current.clientWidth), B.current && E.current) {
227
- const l = E.current.clientWidth, a = E.current.clientHeight;
228
- B.current.resize(l, a);
225
+ if (B.current && Fe(B.current.clientWidth), I.current && B.current) {
226
+ const s = B.current.clientWidth, a = B.current.clientHeight;
227
+ I.current.resize(s, a);
229
228
  try {
230
- ae.current = B.current.paneSize().height;
229
+ ae.current = I.current.paneSize().height;
231
230
  } catch {
232
231
  }
233
232
  }
234
233
  } catch {
235
234
  }
236
- }, s = E.current, r = s ? new ResizeObserver(t) : null;
237
- return De.current = r, s && r?.observe(s), () => {
238
- s && r?.unobserve(s), r?.disconnect(), De.current = null;
235
+ }, l = B.current, r = l ? new ResizeObserver(t) : null;
236
+ return Me.current = r, l && r?.observe(l), () => {
237
+ l && r?.unobserve(l), r?.disconnect(), Me.current = null;
239
238
  };
240
239
  }, []), W(() => {
241
240
  if (!Se.current || be.current) return;
242
- const t = Ke(), s = re(
241
+ const t = He(), l = re(
243
242
  "hsl(var(--muted-foreground))",
244
243
  "rgb(163, 163, 163)"
245
- ), r = ft(Se.current, {
244
+ ), r = ut(Se.current, {
246
245
  ...t,
247
246
  leftPriceScale: {
248
247
  ...t.leftPriceScale || {},
249
248
  visible: !1,
250
- textColor: s
249
+ textColor: l
251
250
  },
252
251
  rightPriceScale: {
253
252
  ...t.rightPriceScale || {},
254
- visible: !T,
255
- textColor: s
253
+ visible: !R,
254
+ textColor: l
256
255
  },
257
- ...T && {
256
+ ...R && {
258
257
  crosshair: {
259
258
  ...t.crosshair,
260
- mode: ht.Magnet
259
+ mode: ft.Magnet
261
260
  }
262
261
  }
263
262
  });
264
- B.current = r, be.current = !0;
263
+ I.current = r, be.current = !0;
265
264
  try {
266
265
  ae.current = r.paneSize().height;
267
266
  } catch {
268
267
  ae.current = 0;
269
268
  }
270
- return nt((l) => l + 1), () => {
271
- r.remove(), B.current = null, be.current = !1, N.current.clear();
269
+ return rt((s) => s + 1), () => {
270
+ r.remove(), I.current = null, be.current = !1, N.current.clear();
272
271
  };
273
- }, [T]), W(() => {
274
- const t = B.current;
272
+ }, [R]), W(() => {
273
+ const t = I.current;
275
274
  t && t.applyOptions(
276
- ke ? {
275
+ Ve ? {
277
276
  handleScale: {
278
277
  mouseWheel: !1,
279
278
  pinch: !1,
@@ -301,35 +300,31 @@ function to({
301
300
  }
302
301
  }
303
302
  );
304
- }, [O, ke]), W(() => {
305
- const t = B.current;
303
+ }, [Y, Ve]), W(() => {
304
+ const t = I.current;
306
305
  !t || !S || t.applyOptions(S);
307
- }, [O, S]), W(() => {
308
- const t = B.current;
306
+ }, [Y, S]), W(() => {
307
+ const t = I.current;
309
308
  if (!t || e.length === 0) return;
310
- const r = e.filter((n) => n.data.length > 0).length <= 1 ? Ne : Ve, l = h === "time" ? Je(h, ce) : Je(h), a = /* @__PURE__ */ new Map();
311
- {
312
- let n = 0;
313
- for (const o of e)
314
- o.data.length !== 0 && (a.set(
315
- o.label,
316
- o.priceScaleId ?? (n === 0 ? "left" : "right")
317
- ), n++);
318
- }
319
- const p = (n, o, d) => {
320
- const { formatter: L, tickmarksFormatter: k, updateVisibleRange: F } = xt(n, o, {
309
+ const r = e.filter((n) => n.data.length > 0).length <= 1 ? Te : Ne, s = h === "time" ? qe(h, ce) : qe(h), a = new Map(
310
+ Pt(e).map(({ series: n, side: o }) => [
311
+ n.label,
312
+ o
313
+ ])
314
+ ), p = (n, o, d) => {
315
+ const { formatter: L, tickmarksFormatter: k, updateVisibleRange: E } = yt(n, o, {
321
316
  yScaleMin: r
322
317
  });
323
- return { formatter: L, tickmarksFormatter: k, updateVisibleRange: F, labels: d };
318
+ return { formatter: L, tickmarksFormatter: k, updateVisibleRange: E, labels: d };
324
319
  }, m = [];
325
- if (I)
320
+ if (z)
326
321
  for (const n of ["left", "right"]) {
327
322
  const o = /* @__PURE__ */ new Set(), d = [];
328
323
  let L = u;
329
324
  for (const k of e)
330
325
  if (k.data.length !== 0 && a.get(k.label) === n) {
331
326
  o.size === 0 && k.yMeasureUnit && (L = k.yMeasureUnit), o.add(k.label);
332
- for (const F of k.data) d.push(F.value);
327
+ for (const E of k.data) d.push(E.value);
333
328
  }
334
329
  o.size > 0 && m.push(p(d, L, o));
335
330
  }
@@ -339,61 +334,58 @@ function to({
339
334
  );
340
335
  m.push(p(n, u, o));
341
336
  }
342
- Me.current = m;
337
+ Le.current = m;
343
338
  const y = /* @__PURE__ */ new Map();
344
339
  for (const n of m)
345
340
  for (const o of n.labels)
346
341
  y.set(o, n);
347
- const x = Ke();
342
+ const x = He();
348
343
  t.applyOptions({
349
344
  localization: {
350
345
  ...x.localization || {},
351
346
  // biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
352
347
  timeFormatter: (n) => (
353
348
  // biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
354
- l.timeFormatter(parseFloat(n), void 0)
349
+ s.timeFormatter(parseFloat(n), void 0)
355
350
  )
356
351
  },
357
352
  timeScale: {
358
353
  ...x.timeScale || {},
359
354
  ...S?.timeScale,
360
355
  // biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
361
- tickMarkFormatter: l.tickMarkFormatter,
356
+ tickMarkFormatter: s.tickMarkFormatter,
362
357
  minBarSpacing: 0
363
358
  }
364
359
  });
365
- const v = !I && e.length > 1 && !Z, X = I ? T : e.length > 1 && !Z || T, V = re(
360
+ const v = !z && e.length > 1 && !Z, X = z ? R : e.length > 1 && !Z || R, V = re(
366
361
  "hsl(var(--muted-foreground))",
367
362
  "rgb(163, 163, 163)"
368
363
  );
369
364
  t.applyOptions({
370
- ...I && {
371
- defaultVisiblePriceScaleId: Te
365
+ ...z && {
366
+ defaultVisiblePriceScaleId: Re
372
367
  },
373
368
  leftPriceScale: {
374
369
  ...x.leftPriceScale || {},
375
370
  ...S?.leftPriceScale,
376
- visible: I && !T,
377
- textColor: V,
378
- ...I && Re && {
379
- // lightweight-charts uses scale margins; title shown via localization if needed
380
- }
371
+ visible: z && !R,
372
+ textColor: V
381
373
  },
382
374
  rightPriceScale: {
383
375
  ...x.rightPriceScale || {},
384
376
  ...S?.rightPriceScale,
385
- visible: I ? !T : !X,
377
+ visible: z ? !R : !X,
386
378
  textColor: V
387
379
  }
388
380
  });
389
- const Y = new Set(N.current.keys()), $ = new Set(e.map(ne));
390
- for (const n of Y)
381
+ const O = new Set(N.current.keys()), $ = new Set(e.map(ne));
382
+ for (const n of O)
391
383
  if (!$.has(n)) {
392
384
  const o = N.current.get(n);
393
385
  o && (t.removeSeries(o), N.current.delete(n));
394
386
  }
395
- const g = St(), M = [];
396
- let R = 0;
387
+ const g = bt(), M = [];
388
+ let T = 0;
397
389
  const G = e.find((n) => n.data.length > 0), C = /* @__PURE__ */ new Map();
398
390
  if (D && D.length > 0)
399
391
  for (const n of D) {
@@ -403,8 +395,8 @@ function to({
403
395
  const d = C.get(o) ?? [];
404
396
  d.push(n.price), C.set(o, d);
405
397
  }
406
- if (z && z.length > 0)
407
- for (const n of z) {
398
+ if (F && F.length > 0)
399
+ for (const n of F) {
408
400
  const o = n.seriesLabel ?? G?.label;
409
401
  if (!o) continue;
410
402
  const d = C.get(o) ?? [];
@@ -412,99 +404,99 @@ function to({
412
404
  }
413
405
  for (let n = 0; n < e.length; n++) {
414
406
  const o = e[n], d = ne(o), L = Ye(n), k = o.lineColor ?? o.color ?? L.line;
415
- let F, q;
407
+ let E, q;
416
408
  if (o.lineColor ?? o.color)
417
409
  if (o.topColor && o.bottomColor)
418
- F = o.topColor, q = o.bottomColor;
410
+ E = o.topColor, q = o.bottomColor;
419
411
  else if (o.topColor) {
420
- const b = we(k);
421
- F = o.topColor, q = b.bottomColor;
412
+ const b = _e(k);
413
+ E = o.topColor, q = b.bottomColor;
422
414
  } else if (o.bottomColor)
423
- F = we(k).topColor, q = o.bottomColor;
415
+ E = _e(k).topColor, q = o.bottomColor;
424
416
  else {
425
- const b = we(k);
426
- F = b.topColor, q = b.bottomColor;
417
+ const b = _e(k);
418
+ E = b.topColor, q = b.bottomColor;
427
419
  }
428
420
  else
429
- F = o.topColor || L.top, q = o.bottomColor || L.bottom;
421
+ E = o.topColor || L.top, q = o.bottomColor || L.bottom;
430
422
  if (o.data.length === 0) {
431
423
  const b = N.current.get(d);
432
424
  b && (t.removeSeries(b), N.current.delete(d));
433
425
  continue;
434
426
  }
435
- const ue = o.data.length > 0 ? Math.min(...o.data.map((b) => b.value)) : 0, he = o.data.length > 0 ? Math.max(...o.data.map((b) => b.value)) : 0, it = ue < 0, lt = o.data.some((b) => b.value === 0), st = !it && lt, Xe = Tt(he - ue), $e = I ? o.priceScaleId ?? (R === 0 ? "left" : "right") : Z || !v || R === 0 ? "right" : `scale-${R}`;
427
+ const ue = o.data.length > 0 ? Math.min(...o.data.map((b) => b.value)) : 0, he = o.data.length > 0 ? Math.max(...o.data.map((b) => b.value)) : 0, nt = ue < 0, it = o.data.some((b) => b.value === 0), st = !nt && it, We = Rt(he - ue), Xe = z ? o.priceScaleId ?? (T === 0 ? "left" : "right") : Z || !v || T === 0 ? "right" : `scale-${T}`;
436
428
  v && M.push({
437
- priceScaleId: $e || "right",
438
- seriesIndex: R
429
+ priceScaleId: Xe || "right",
430
+ seriesIndex: T
439
431
  });
440
- const Ce = (Z || !v) && r !== void 0 && typeof r == "number", at = C.get(o.label) ?? [], ct = (b) => {
441
- const _ = b();
442
- if (_?.priceRange) {
443
- Ce && (_.priceRange.minValue = r);
444
- for (const H of at)
445
- H < _.priceRange.minValue && (_.priceRange.minValue = H), H > _.priceRange.maxValue && (_.priceRange.maxValue = H);
446
- const te = Ce ? r : st && _.priceRange.minValue >= 0 ? 0 : void 0, de = ae.current > 0 ? ae.current : E.current?.clientHeight ?? 0;
432
+ const Ce = (Z || !v) && r !== void 0 && typeof r == "number", lt = C.get(o.label) ?? [], at = (b) => {
433
+ const w = b();
434
+ if (w?.priceRange) {
435
+ Ce && (w.priceRange.minValue = r);
436
+ for (const H of lt)
437
+ H < w.priceRange.minValue && (w.priceRange.minValue = H), H > w.priceRange.maxValue && (w.priceRange.maxValue = H);
438
+ const te = Ce ? r : st && w.priceRange.minValue >= 0 ? 0 : void 0, de = ae.current > 0 ? ae.current : B.current?.clientHeight ?? 0;
447
439
  if (de > 0) {
448
- const H = Rt({
449
- min: _.priceRange.minValue,
450
- max: _.priceRange.maxValue,
440
+ const H = Tt({
441
+ min: w.priceRange.minValue,
442
+ max: w.priceRange.maxValue,
451
443
  floor: te,
452
444
  scaleHeightPx: de,
453
- fontSizePx: Ct,
445
+ fontSizePx: vt,
454
446
  tickMarkDensity: pe,
455
- minMove: Xe,
456
- edgePaddingPx: Ze,
457
- edgePaddingTopPx: qe
447
+ minMove: We,
448
+ edgePaddingPx: Ke,
449
+ edgePaddingTopPx: Ze
458
450
  });
459
- _.priceRange.minValue = H.min, _.priceRange.maxValue = H.max;
451
+ w.priceRange.minValue = H.min, w.priceRange.maxValue = H.max;
460
452
  }
461
- _.margins = {
462
- above: qe,
463
- below: Ze
453
+ w.margins = {
454
+ above: Ze,
455
+ below: Ke
464
456
  };
465
457
  }
466
- return _;
467
- }, Ge = y.get(o.label) ?? m[0], je = Ge.formatter, ut = Ge.tickmarksFormatter, ye = {
458
+ return w;
459
+ }, $e = y.get(o.label) ?? m[0], Ge = $e.formatter, ct = $e.tickmarksFormatter, ye = {
468
460
  lineColor: k,
469
- topColor: F,
461
+ topColor: E,
470
462
  bottomColor: q,
471
- priceScaleId: $e,
463
+ priceScaleId: Xe,
472
464
  ...o.seriesType === "line" && {
473
465
  lineStyle: o.lineStyle ?? ie.Solid
474
466
  },
475
467
  priceFormat: {
476
468
  type: "custom",
477
- minMove: Xe,
478
- formatter: Ce && typeof r == "number" ? (b) => je(
469
+ minMove: We,
470
+ formatter: Ce && typeof r == "number" ? (b) => Ge(
479
471
  b < r ? r : b
480
- ) : je,
481
- tickmarksFormatter: ut
472
+ ) : Ge,
473
+ tickmarksFormatter: ct
482
474
  },
483
- autoscaleInfoProvider: ct
484
- }, He = o.seriesType === "line";
475
+ autoscaleInfoProvider: at
476
+ }, je = o.seriesType === "line";
485
477
  let A = N.current.get(d);
486
478
  const ee = o.data.map((b) => ({
487
479
  ...b,
488
480
  time: b.time
489
481
  }));
490
- if (se !== void 0 && ee.length > 0 && Number(ee[0].time) > se) {
491
- const b = Number(ee[0].time), _ = b - se, te = 86400, de = _ > 180 * te ? 7 * te : _ > 30 * te ? te : 6 * 3600, H = [];
492
- for (let xe = se; xe < b; xe += de)
482
+ if (le !== void 0 && ee.length > 0 && Number(ee[0].time) > le) {
483
+ const b = Number(ee[0].time), w = b - le, te = 86400, de = w > 180 * te ? 7 * te : w > 30 * te ? te : 6 * 3600, H = [];
484
+ for (let xe = le; xe < b; xe += de)
493
485
  H.push({ time: xe });
494
486
  ee.unshift(...H);
495
487
  }
496
- A && A.seriesType() !== (He ? "Line" : "Area") && (t.removeSeries(A), N.current.delete(d), A = void 0), A ? (A.applyOptions(ye), A.setData(ee)) : (He ? A = t.addSeries(dt, {
488
+ A && A.seriesType() !== (je ? "Line" : "Area") && (t.removeSeries(A), N.current.delete(d), A = void 0), A ? (A.applyOptions(ye), A.setData(ee)) : (je ? A = t.addSeries(ht, {
497
489
  ...g,
498
490
  ...ye
499
- }) : A = t.addSeries(pt, {
491
+ }) : A = t.addSeries(dt, {
500
492
  ...g,
501
493
  ...ye
502
- }), A.setData(ee), N.current.set(d, A)), R++;
494
+ }), A.setData(ee), N.current.set(d, A)), T++;
503
495
  }
504
- if (I)
496
+ if (z)
505
497
  try {
506
498
  const n = t.priceScale("left"), o = t.priceScale("right"), d = {
507
- visible: !T,
499
+ visible: !R,
508
500
  autoScale: !0,
509
501
  scaleMargins: { top: 0, bottom: 0 },
510
502
  alignLabels: !0,
@@ -542,7 +534,7 @@ function to({
542
534
  try {
543
535
  const n = t.priceScale("right");
544
536
  n && n.applyOptions({
545
- visible: !T,
537
+ visible: !R,
546
538
  autoScale: !0,
547
539
  scaleMargins: {
548
540
  top: 0,
@@ -556,7 +548,7 @@ function to({
556
548
  });
557
549
  } catch {
558
550
  }
559
- if (r !== void 0 && !T && (Z || !v) && t.applyOptions({
551
+ if (r !== void 0 && !R && (Z || !v) && t.applyOptions({
560
552
  handleScroll: {
561
553
  vertTouchDrag: !1
562
554
  }
@@ -572,7 +564,7 @@ function to({
572
564
  }), L.setVisibleLogicalRange({ from: 0, to: o });
573
565
  return;
574
566
  }
575
- const k = I && !T, F = I ? !T : !X, q = !k, ue = !F;
567
+ const k = z && !R, E = z ? !R : !X, q = !k, ue = !E;
576
568
  L.applyOptions({
577
569
  fixLeftEdge: !q,
578
570
  fixRightEdge: !ue
@@ -595,32 +587,31 @@ function to({
595
587
  }
596
588
  }
597
589
  }
598
- Le.current && (Le.current = !1), S && t.applyOptions(S);
590
+ ke.current && (ke.current = !1), S && t.applyOptions(S);
599
591
  const j = /* @__PURE__ */ new Map();
600
592
  for (const n of e)
601
593
  n.data.length > 0 && j.set(n.label, n.data[n.data.length - 1]);
602
594
  ve(j.size > 0 ? j : void 0);
603
595
  }, [
604
- O,
596
+ Y,
605
597
  e,
606
598
  ce,
607
599
  h,
608
600
  u,
609
- T,
601
+ R,
610
602
  Z,
611
- I,
612
- Te,
603
+ z,
613
604
  Re,
605
+ Te,
614
606
  Ne,
615
- Ve,
616
- se,
607
+ le,
617
608
  D,
618
- z,
609
+ F,
619
610
  S
620
611
  ]), W(() => {
621
- const t = B.current;
612
+ const t = I.current;
622
613
  if (!t || e.length === 0) return;
623
- const s = e.length === 1;
614
+ const l = e.length === 1;
624
615
  let r;
625
616
  for (const a of e)
626
617
  if (a.data.length > 0) {
@@ -628,33 +619,33 @@ function to({
628
619
  break;
629
620
  }
630
621
  if (!r) return;
631
- const l = (a) => {
622
+ const s = (a) => {
632
623
  const { time: p = r, seriesData: m, point: y } = a || {}, x = e[0], v = x ? N.current.get(ne(x)) : void 0;
633
624
  if (!y || !p) {
634
625
  const $ = /* @__PURE__ */ new Map();
635
626
  for (const g of e)
636
627
  g.data.length > 0 && $.set(g.label, g.data[g.data.length - 1]);
637
- if (ve($.size > 0 ? $ : void 0), s || Z || ge)
628
+ if (ve($.size > 0 ? $ : void 0), l || Z || ge)
638
629
  Q(null);
639
630
  else if (v && r) {
640
631
  const g = e[0];
641
632
  if (g && g.data.length > 0) {
642
- const R = t.timeScale().timeToCoordinate(r), G = g.data[g.data.length - 1].value, C = v.priceToCoordinate(G);
643
- R !== null && C !== null && Q({ x: R, y: C });
633
+ const T = t.timeScale().timeToCoordinate(r), G = g.data[g.data.length - 1].value, C = v.priceToCoordinate(G);
634
+ T !== null && C !== null && Q({ x: T, y: C });
644
635
  }
645
636
  }
646
637
  return;
647
638
  }
648
639
  const X = /* @__PURE__ */ new Map();
649
- let V, Y = v;
640
+ let V, O = v;
650
641
  for (let $ = 0; $ < e.length; $++) {
651
642
  const g = e[$], M = N.current.get(ne(g));
652
643
  if (!M) continue;
653
- const R = m?.get(M), G = R && "value" in R ? R.value : void 0;
644
+ const T = m?.get(M), G = T && "value" in T ? T.value : void 0;
654
645
  let C;
655
646
  if (G !== void 0)
656
647
  C = G;
657
- else if (s) {
648
+ else if (l) {
658
649
  const j = Number(p), n = g.data.length > 0 ? Number(g.data[0].time) : Number.POSITIVE_INFINITY;
659
650
  j < n ? C = Number.NaN : C = g.data[g.data.length - 1]?.value ?? 0;
660
651
  } else {
@@ -662,18 +653,18 @@ function to({
662
653
  if (Number(p) < j) continue;
663
654
  C = zt(g.data, Number(p));
664
655
  }
665
- Number.isNaN(C) || (V === void 0 && (V = C, Y = M), X.set(g.label, { value: C, time: p }));
656
+ Number.isNaN(C) || (V === void 0 && (V = C, O = M), X.set(g.label, { value: C, time: p }));
666
657
  }
667
- if (ve(X), V !== void 0 && Y) {
668
- const g = t.timeScale().timeToCoordinate(p), M = Y.priceToCoordinate(V);
658
+ if (ve(X), V !== void 0 && O) {
659
+ const g = t.timeScale().timeToCoordinate(p), M = O.priceToCoordinate(V);
669
660
  if (g !== null && M !== null) {
670
- const R = E.current;
671
- if (R) {
672
- const G = R.querySelector(
661
+ const T = B.current;
662
+ if (T) {
663
+ const G = T.querySelector(
673
664
  ".LightweightChart"
674
665
  );
675
666
  if (G) {
676
- const C = G.getBoundingClientRect(), j = R.getBoundingClientRect(), n = g + (C.left - j.left), o = M + (C.top - j.top);
667
+ const C = G.getBoundingClientRect(), j = T.getBoundingClientRect(), n = g + (C.left - j.left), o = M + (C.top - j.top);
677
668
  Q({ x: n, y: o });
678
669
  } else
679
670
  Q({ x: g, y: M });
@@ -684,25 +675,25 @@ function to({
684
675
  } else
685
676
  Q(null);
686
677
  };
687
- return t.subscribeCrosshairMove(l), T && t.subscribeClick(l), !s && !Z && !ge && requestAnimationFrame(() => {
678
+ return t.subscribeCrosshairMove(s), R && t.subscribeClick(s), !l && !Z && !ge && requestAnimationFrame(() => {
688
679
  const a = e[0], p = a ? N.current.get(ne(a)) : void 0;
689
680
  if (p && r && a.data.length > 0) {
690
681
  const y = t.timeScale().timeToCoordinate(r), x = a.data[a.data.length - 1].value, v = p.priceToCoordinate(x);
691
682
  y !== null && v !== null && Q({ x: y, y: v });
692
683
  }
693
684
  }), () => {
694
- t.unsubscribeCrosshairMove(l), T && t.unsubscribeClick(l);
685
+ t.unsubscribeCrosshairMove(s), R && t.unsubscribeClick(s);
695
686
  };
696
- }, [e, Z, T, ge]), W(() => {
697
- const t = B.current;
687
+ }, [e, Z, R, ge]), W(() => {
688
+ const t = I.current;
698
689
  if (!t || e.length === 0) return;
699
- const s = t.timeScale(), r = () => {
700
- const l = Me.current;
701
- if (l.length === 0) return;
702
- const a = s.getVisibleRange();
690
+ const l = t.timeScale(), r = () => {
691
+ const s = Le.current;
692
+ if (s.length === 0) return;
693
+ const a = l.getVisibleRange();
703
694
  if (!a) return;
704
695
  const p = Number(a.from), m = Number(a.to);
705
- for (const y of l) {
696
+ for (const y of s) {
706
697
  const x = [];
707
698
  for (const v of e)
708
699
  if (y.labels.has(v.label))
@@ -713,138 +704,138 @@ function to({
713
704
  x.length > 0 && y.updateVisibleRange(x);
714
705
  }
715
706
  };
716
- return s.subscribeVisibleLogicalRangeChange(r), () => {
717
- s.unsubscribeVisibleLogicalRangeChange(
707
+ return l.subscribeVisibleLogicalRangeChange(r), () => {
708
+ l.unsubscribeVisibleLogicalRangeChange(
718
709
  r
719
710
  );
720
711
  };
721
712
  }, [e]), W(() => {
722
- const t = B.current, s = Array.from(N.current.values()), r = [];
723
- if (t && s.length > 0 && P) {
724
- const l = vt(), a = s[0];
713
+ const t = I.current, l = Array.from(N.current.values()), r = [];
714
+ if (t && l.length > 0 && P) {
715
+ const s = St(), a = l[0];
725
716
  for (const p of P) {
726
717
  const m = {
727
- ...l,
718
+ ...s,
728
719
  ...p.options || {}
729
720
  };
730
721
  m.color && (m.color = re(m.color, m.color));
731
- const y = new Pt(t, a, p.xCoordinate, m);
722
+ const y = new _t(t, a, p.xCoordinate, m);
732
723
  a.attachPrimitive(y), r.push(y);
733
724
  }
734
725
  }
735
726
  return () => {
736
- if (s.length > 0) {
737
- const l = s[0];
727
+ if (l.length > 0) {
728
+ const s = l[0];
738
729
  for (const a of r)
739
730
  try {
740
- l.detachPrimitive(a);
731
+ s.detachPrimitive(a);
741
732
  } catch {
742
733
  }
743
734
  }
744
735
  };
745
- }, [P, e, O]), W(() => {
746
- const t = [], s = [];
736
+ }, [P, e, Y]), W(() => {
737
+ const t = [], l = [];
747
738
  if (D && D.length > 0) {
748
739
  const r = re(
749
740
  "hsl(var(--destructive))",
750
741
  "rgb(239, 68, 68)"
751
742
  );
752
- for (const l of D) {
753
- if (!Number.isFinite(l.price)) continue;
754
- const a = Qe(
743
+ for (const s of D) {
744
+ if (!Number.isFinite(s.price)) continue;
745
+ const a = Je(
755
746
  N.current,
756
747
  e,
757
- l.seriesLabel
748
+ s.seriesLabel
758
749
  );
759
750
  if (!a) continue;
760
- const p = l.color ? re(l.color, l.color) : r, m = l.lineWidth ?? 1, y = l.lineStyle ?? ie.Dashed, x = a.createPriceLine({
761
- price: l.price,
751
+ const p = s.color ? re(s.color, s.color) : r, m = s.lineWidth ?? 1, y = s.lineStyle ?? ie.Dashed, x = a.createPriceLine({
752
+ price: s.price,
762
753
  color: p,
763
754
  lineWidth: m,
764
755
  lineStyle: y,
765
- axisLabelVisible: l.axisLabelVisible ?? !0,
766
- title: l.title ?? ""
756
+ axisLabelVisible: s.axisLabelVisible ?? !0,
757
+ title: s.title ?? ""
767
758
  });
768
759
  t.push({ series: a, line: x });
769
760
  const v = new Bt(
770
761
  a,
771
- l.price,
762
+ s.price,
772
763
  p,
773
764
  m,
774
765
  y
775
766
  );
776
- a.attachPrimitive(v), s.push({ series: a, primitive: v });
767
+ a.attachPrimitive(v), l.push({ series: a, primitive: v });
777
768
  }
778
769
  }
779
770
  return () => {
780
- for (const { series: r, primitive: l } of s)
771
+ for (const { series: r, primitive: s } of l)
781
772
  try {
782
- r.detachPrimitive(l);
773
+ r.detachPrimitive(s);
783
774
  } catch {
784
775
  }
785
- for (const { series: r, line: l } of t)
776
+ for (const { series: r, line: s } of t)
786
777
  try {
787
- r.removePriceLine(l);
778
+ r.removePriceLine(s);
788
779
  } catch {
789
780
  }
790
781
  };
791
- }, [D, e, O]), W(() => {
782
+ }, [D, e, Y]), W(() => {
792
783
  const t = [];
793
- if (z && z.length > 0) {
794
- const s = "rgba(239, 68, 68, 0.12)";
795
- for (const r of z) {
796
- const l = Qe(
784
+ if (F && F.length > 0) {
785
+ const l = "rgba(239, 68, 68, 0.12)";
786
+ for (const r of F) {
787
+ const s = Je(
797
788
  N.current,
798
789
  e,
799
790
  r.seriesLabel
800
791
  );
801
- if (!l) continue;
802
- const a = r.color ? re(r.color, s) : s, p = new Lt(
803
- l,
792
+ if (!s) continue;
793
+ const a = r.color ? re(r.color, l) : l, p = new Lt(
794
+ s,
804
795
  r.priceTop,
805
796
  r.priceBottom,
806
797
  a
807
798
  );
808
- l.attachPrimitive(p), t.push({ series: l, zone: p });
799
+ s.attachPrimitive(p), t.push({ series: s, zone: p });
809
800
  }
810
801
  }
811
802
  return () => {
812
- for (const { series: s, zone: r } of t)
803
+ for (const { series: l, zone: r } of t)
813
804
  try {
814
- s.detachPrimitive(r);
805
+ l.detachPrimitive(r);
815
806
  } catch {
816
807
  }
817
808
  };
818
- }, [z, e, O]), W(() => {
819
- const t = B.current;
809
+ }, [F, e, Y]), W(() => {
810
+ const t = I.current;
820
811
  if (!t || !P?.length) {
821
- Fe([]);
812
+ Ee([]);
822
813
  return;
823
814
  }
824
- const s = () => {
815
+ const l = () => {
825
816
  const a = t.timeScale(), p = P.map((m) => a.timeToCoordinate(m.xCoordinate) ?? null);
826
- Fe(p), E.current && ze(E.current.clientWidth);
817
+ Ee(p), B.current && Fe(B.current.clientWidth);
827
818
  };
828
- s();
829
- const r = t.timeScale(), l = () => {
830
- s();
819
+ l();
820
+ const r = t.timeScale(), s = () => {
821
+ l();
831
822
  };
832
- return r.subscribeVisibleLogicalRangeChange(l), () => {
833
- r.unsubscribeVisibleLogicalRangeChange(l);
823
+ return r.subscribeVisibleLogicalRangeChange(s), () => {
824
+ r.unsubscribeVisibleLogicalRangeChange(s);
834
825
  };
835
- }, [P, e, O]), mt(() => {
836
- rt((t) => {
837
- const s = {};
826
+ }, [P, e, Y]), pt(() => {
827
+ ot((t) => {
828
+ const l = {};
838
829
  let r = !1;
839
- for (const [l, a] of Ae.current) {
830
+ for (const [s, a] of ze.current) {
840
831
  if (!a) continue;
841
832
  const p = a.offsetWidth;
842
- s[l] = p, t[l] !== p && (r = !0);
833
+ l[s] = p, t[s] !== p && (r = !0);
843
834
  }
844
- return Object.keys(t).length !== Object.keys(s).length && (r = !0), r ? s : t;
835
+ return Object.keys(t).length !== Object.keys(l).length && (r = !0), r ? l : t;
845
836
  });
846
837
  });
847
- const fe = e.length === 1, We = _e.useMemo(() => {
838
+ const fe = e.length === 1, Ae = we.useMemo(() => {
848
839
  if (fe && e.length > 0) {
849
840
  const t = e[0];
850
841
  if (t.data.length > 0)
@@ -854,58 +845,58 @@ function to({
854
845
  return /* @__PURE__ */ U(
855
846
  "div",
856
847
  {
857
- ref: E,
848
+ ref: B,
858
849
  className: J(
859
850
  "relative z-[1] w-full h-full overflow-hidden p-0",
860
851
  i
861
852
  ),
862
853
  children: [
863
- me != null && me !== !1 && fe ? /* @__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: me }) }) : Ue && fe && We && /* @__PURE__ */ w(
864
- _t,
854
+ me != null && me !== !1 && fe ? /* @__PURE__ */ _("div", { className: "absolute top-2 left-2 right-2 z-[100] pointer-events-none", children: /* @__PURE__ */ _("div", { className: "text-xl sm:text-2xl font-semibold text-foreground whitespace-nowrap overflow-hidden text-ellipsis", children: me }) }) : Oe && fe && Ae && /* @__PURE__ */ _(
855
+ xt,
865
856
  {
866
- point: We,
857
+ point: Ae,
867
858
  xMeasureUnit: h,
868
859
  yMeasureUnit: u,
869
- decimals: le
860
+ decimals: se
870
861
  }
871
862
  ),
872
- Ie && Be && /* @__PURE__ */ w(
863
+ De && Ie && /* @__PURE__ */ _(
873
864
  wt,
874
865
  {
875
- points: Ie,
866
+ points: De,
876
867
  xMeasureUnit: h,
877
868
  yMeasureUnit: u,
878
869
  series: e,
879
- position: Be,
880
- containerRef: E,
881
- decimals: le
870
+ position: Ie,
871
+ containerRef: B,
872
+ decimals: se
882
873
  }
883
874
  ),
884
- c && /* @__PURE__ */ w(At, { series: e, onUnselect: f }),
885
- P && P.length > 0 && Ee.length === P.length && /* @__PURE__ */ w(
875
+ c && /* @__PURE__ */ _(At, { series: e, onUnselect: f }),
876
+ P && P.length > 0 && Be.length === P.length && /* @__PURE__ */ _(
886
877
  "div",
887
878
  {
888
879
  className: "absolute inset-0 z-[5] pointer-events-none",
889
880
  "aria-hidden": !0,
890
- children: P.map((t, s) => {
891
- const r = Ee[s], l = t.options ?? {};
881
+ children: P.map((t, l) => {
882
+ const r = Be[l], s = t.options ?? {};
892
883
  if (r === null) return null;
893
884
  const { labelText: a, valueStr: p } = Et(
894
- l,
885
+ s,
895
886
  u,
896
- le
897
- ), m = l.tooltipText ?? "";
887
+ se
888
+ ), m = s.tooltipText ?? "";
898
889
  if (!(a || p || m)) return null;
899
- const x = l.labelBackgroundColor ?? l.color ?? "hsl(var(--background))", v = l.labelTextColor ?? "hsl(var(--foreground))", X = `${String(t.xCoordinate)}-${a}-${m}`, V = Ft(
890
+ const x = s.labelBackgroundColor ?? s.color ?? "hsl(var(--background))", v = s.labelTextColor ?? "hsl(var(--foreground))", X = `${String(t.xCoordinate)}-${a}-${m}`, V = Ft(
900
891
  r,
901
- tt,
902
- ot[s]
892
+ et,
893
+ tt[l]
903
894
  );
904
895
  return /* @__PURE__ */ U(
905
896
  "div",
906
897
  {
907
- ref: (Y) => {
908
- Ae.current.set(s, Y);
898
+ ref: (O) => {
899
+ ze.current.set(l, O);
909
900
  },
910
901
  className: J(
911
902
  "group absolute top-2 px-2 py-1 rounded text-xs font-medium whitespace-nowrap shadow-sm border border-border",
@@ -917,9 +908,9 @@ function to({
917
908
  color: v
918
909
  },
919
910
  children: [
920
- a && /* @__PURE__ */ w("span", { className: "block", children: a }),
921
- p && /* @__PURE__ */ w("span", { className: J("block", a && "mt-0.5"), children: p }),
922
- m && /* @__PURE__ */ w(
911
+ a && /* @__PURE__ */ _("span", { className: "block", children: a }),
912
+ p && /* @__PURE__ */ _("span", { className: J("block", a && "mt-0.5"), children: p }),
913
+ m && /* @__PURE__ */ _(
923
914
  "span",
924
915
  {
925
916
  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",
@@ -934,7 +925,7 @@ function to({
934
925
  })
935
926
  }
936
927
  ),
937
- /* @__PURE__ */ w(
928
+ /* @__PURE__ */ _(
938
929
  "div",
939
930
  {
940
931
  ref: Se,
@@ -961,17 +952,17 @@ function At({
961
952
  ),
962
953
  children: [
963
954
  e.map((u, S) => {
964
- const P = Ye(S), D = (u.lineColor ?? u.color) || P.line, z = !h && u.data.length === 0;
955
+ const P = Ye(S), D = (u.lineColor ?? u.color) || P.line, F = !h && u.data.length === 0;
965
956
  return /* @__PURE__ */ U(
966
957
  "div",
967
958
  {
968
959
  className: J(
969
960
  "flex shrink-0 items-center gap-1.5",
970
961
  !f && "px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border",
971
- z && "opacity-50"
962
+ F && "opacity-50"
972
963
  ),
973
964
  children: [
974
- /* @__PURE__ */ w(
965
+ /* @__PURE__ */ _(
975
966
  "div",
976
967
  {
977
968
  className: J(
@@ -990,16 +981,16 @@ function At({
990
981
  ),
991
982
  children: [
992
983
  u.label,
993
- z && " (no data)"
984
+ F && " (no data)"
994
985
  ]
995
986
  }
996
987
  ),
997
- c && /* @__PURE__ */ w(
988
+ c && /* @__PURE__ */ _(
998
989
  "button",
999
990
  {
1000
991
  type: "button",
1001
- onClick: (le) => {
1002
- le.stopPropagation(), c(u.label);
992
+ onClick: (se) => {
993
+ se.stopPropagation(), c(u.label);
1003
994
  },
1004
995
  className: "ml-1 flex items-center justify-center w-4 h-4 rounded-sm hover:bg-muted transition-colors cursor-pointer",
1005
996
  "aria-label": `Remove ${u.label}`,
@@ -1018,9 +1009,9 @@ function At({
1018
1009
  className: "text-muted-foreground hover:text-foreground",
1019
1010
  "aria-hidden": "true",
1020
1011
  children: [
1021
- /* @__PURE__ */ w("title", { children: "Close" }),
1022
- /* @__PURE__ */ w("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
1023
- /* @__PURE__ */ w("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
1012
+ /* @__PURE__ */ _("title", { children: "Close" }),
1013
+ /* @__PURE__ */ _("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
1014
+ /* @__PURE__ */ _("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
1024
1015
  ]
1025
1016
  }
1026
1017
  )
@@ -1039,14 +1030,14 @@ function At({
1039
1030
  !f && "px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border"
1040
1031
  ),
1041
1032
  children: [
1042
- /* @__PURE__ */ w(
1033
+ /* @__PURE__ */ _(
1043
1034
  "div",
1044
1035
  {
1045
1036
  className: "h-3 w-0.5 shrink-0",
1046
1037
  style: { backgroundColor: u.color }
1047
1038
  }
1048
1039
  ),
1049
- /* @__PURE__ */ w(
1040
+ /* @__PURE__ */ _(
1050
1041
  "span",
1051
1042
  {
1052
1043
  className: J(
@@ -1067,7 +1058,7 @@ function At({
1067
1058
  export {
1068
1059
  to as Graph,
1069
1060
  At as GraphLegend,
1070
- Oe as VERTICAL_LINE_LABEL_EDGE_PADDING,
1061
+ Qe as VERTICAL_LINE_LABEL_EDGE_PADDING,
1071
1062
  zt as getStepForwardValue,
1072
1063
  Ft as getVerticalLineLabelStyle,
1073
1064
  Et as getVerticalLineTooltipContent,