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

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