@gearbox-protocol/ui-kit 2.1.0-next.1 → 3.0.1

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 (69) hide show
  1. package/README.md +7 -87
  2. package/dist/cjs/components/assets-list-cell/assets-list-cell.cjs +1 -1
  3. package/dist/cjs/components/auth/connect-required.cjs +1 -1
  4. package/dist/cjs/components/auth/index.cjs +1 -1
  5. package/dist/cjs/components/auth/signin-required.cjs +1 -1
  6. package/dist/cjs/components/block-sync/block-sync.cjs +1 -1
  7. package/dist/cjs/components/checkbox/checkbox-labeled.cjs +1 -1
  8. package/dist/cjs/components/client-adapters/styled-rounded-image/styled-rounded-image.cjs +1 -1
  9. package/dist/cjs/components/complex-input/complex-input.cjs +1 -1
  10. package/dist/cjs/components/compound-apy/compound-apy.cjs +1 -1
  11. package/dist/cjs/components/detailed-page-title/detailed-page-title.cjs +1 -1
  12. package/dist/cjs/components/graph/graph.cjs +1 -1
  13. package/dist/cjs/components/index.cjs +1 -1
  14. package/dist/cjs/components/markdown-viewer/markdown-viewer.cjs +1 -1
  15. package/dist/cjs/components/next/index.cjs +1 -1
  16. package/dist/cjs/components/next/siwe-provider.cjs +1 -0
  17. package/dist/cjs/components/table/editable-grid-table.cjs +1 -1
  18. package/dist/cjs/components/table/editable-table.cjs +1 -1
  19. package/dist/cjs/components/time-to-liquidation/time-to-liquidation.cjs +1 -1
  20. package/dist/cjs/components/tokens-list-cell/tokens-list-cell.cjs +1 -1
  21. package/dist/cjs/components/with-copy/with-copy.cjs +1 -1
  22. package/dist/cjs/index.cjs +1 -1
  23. package/dist/esm/components/assets-list-cell/assets-list-cell.js +4 -3
  24. package/dist/esm/components/auth/connect-required.js +11 -18
  25. package/dist/esm/components/auth/index.js +4 -5
  26. package/dist/esm/components/auth/signin-required.js +23 -30
  27. package/dist/esm/components/block-sync/block-sync.js +4 -3
  28. package/dist/esm/components/checkbox/checkbox-labeled.js +2 -1
  29. package/dist/esm/components/client-adapters/styled-rounded-image/styled-rounded-image.js +2 -1
  30. package/dist/esm/components/complex-input/complex-input.js +4 -3
  31. package/dist/esm/components/compound-apy/compound-apy.js +4 -3
  32. package/dist/esm/components/detailed-page-title/detailed-page-title.js +2 -1
  33. package/dist/esm/components/graph/graph.js +192 -182
  34. package/dist/esm/components/index.js +607 -608
  35. package/dist/esm/components/markdown-viewer/markdown-viewer.js +4 -3
  36. package/dist/esm/components/next/index.js +8 -6
  37. package/dist/esm/components/next/{connectkit/siwe-provider.js → siwe-provider.js} +1 -1
  38. package/dist/esm/components/table/editable-grid-table.js +37 -36
  39. package/dist/esm/components/table/editable-table.js +18 -17
  40. package/dist/esm/components/time-to-liquidation/time-to-liquidation.js +2 -1
  41. package/dist/esm/components/tokens-list-cell/tokens-list-cell.js +4 -3
  42. package/dist/esm/components/with-copy/with-copy.js +4 -3
  43. package/dist/esm/index.js +767 -768
  44. package/dist/types/components/auth/connect-required.d.ts +11 -10
  45. package/dist/types/components/auth/index.d.ts +1 -1
  46. package/dist/types/components/auth/signin-required.d.ts +5 -7
  47. package/dist/types/components/auth/siwe-provider.d.ts +31 -0
  48. package/dist/types/components/filter/filter-modal.d.ts +1 -1
  49. package/dist/types/components/next/index.d.ts +1 -0
  50. package/dist/types/components/next/siwe-provider.d.ts +7 -0
  51. package/dist/types/components/simple-accordion/simple-accordion.d.ts +1 -1
  52. package/package.json +16 -22
  53. package/dist/cjs/components/auth/wallet-ui-context.cjs +0 -1
  54. package/dist/cjs/components/connectkit/connect-kit-wallet-adapter.cjs +0 -1
  55. package/dist/cjs/components/connectkit/index.cjs +0 -1
  56. package/dist/cjs/components/next/connectkit/index.cjs +0 -1
  57. package/dist/cjs/components/next/connectkit/siwe-provider.cjs +0 -1
  58. package/dist/esm/components/auth/wallet-ui-context.js +0 -13
  59. package/dist/esm/components/connectkit/connect-kit-wallet-adapter.js +0 -32
  60. package/dist/esm/components/connectkit/index.js +0 -6
  61. package/dist/esm/components/next/connectkit/index.js +0 -4
  62. package/dist/types/components/auth/wallet-ui-context.d.ts +0 -36
  63. package/dist/types/components/connectkit/connect-kit-wallet-adapter.d.ts +0 -12
  64. package/dist/types/components/connectkit/index.d.ts +0 -2
  65. package/dist/types/components/connectkit/siwe-provider.d.ts +0 -30
  66. package/dist/types/components/next/connectkit/index.d.ts +0 -1
  67. package/dist/types/components/next/connectkit/siwe-provider.d.ts +0 -8
  68. /package/dist/cjs/components/{connectkit → auth}/siwe-provider.cjs +0 -0
  69. /package/dist/esm/components/{connectkit → auth}/siwe-provider.js +0 -0
@@ -1,22 +1,22 @@
1
- import { jsxs as j, jsx as h } from "react/jsx-runtime";
2
- import { createChart as It, CrosshairMode as zt, AreaSeries as $t } from "lightweight-charts";
1
+ import { jsxs as X, jsx as h } from "react/jsx-runtime";
2
+ import { createChart as At, CrosshairMode as It, AreaSeries as zt } from "lightweight-charts";
3
3
  import * as lt from "react";
4
- import { useRef as M, useState as it, useEffect as D } from "react";
5
- import { useIsMobile as Dt } from "../../hooks/use-media-query.js";
4
+ import { useRef as z, useState as it, useEffect as E } from "react";
5
+ import { useIsMobile as $t } from "../../hooks/use-media-query.js";
6
6
  import { cn as ut } from "../../utils/cn.js";
7
- import { resolveCSSColor as wt, generateColorsFromBase as q, hslToHex as Et } from "../../utils/colors.js";
8
- import { getDefaultOptions as Rt, getDefaultSeries as Gt, getDefaultVerticalLine as Ot } from "./default-config.js";
9
- import { getXFormatters as yt, createAdaptiveYAxisFormatter as Bt, formatExactValue as st } from "./formatters.js";
10
- import { GraphCurrentValue as Yt } from "./graph-current-value.js";
11
- import { GraphTooltip as Ht } from "./graph-tooltip.js";
7
+ import { resolveCSSColor as wt, generateColorsFromBase as K, hslToHex as Dt } from "../../utils/colors.js";
8
+ import { getDefaultOptions as Rt, getDefaultSeries as Et, getDefaultVerticalLine as Gt } from "./default-config.js";
9
+ import { getXFormatters as Vt, createAdaptiveYAxisFormatter as Bt, formatExactValue as st } from "./formatters.js";
10
+ import { GraphCurrentValue as Ot } from "./graph-current-value.js";
11
+ import { GraphTooltip as Yt } from "./graph-tooltip.js";
12
12
  import { VertLine as jt } from "./plugins/vertical-line.js";
13
- function Wt(e, v, m) {
14
- const A = e.labelText ?? "", f = e.value, S = f === void 0 ? "" : typeof f == "number" ? v === "$" ? `$${st(f, void 0, m)}` : v === "%" ? `${st(f, void 0, m)}%` : st(
13
+ function Ht(e, v, m) {
14
+ const F = e.labelText ?? "", f = e.value, w = f === void 0 ? "" : typeof f == "number" ? v === "$" ? `$${st(f, void 0, m)}` : v === "%" ? `${st(f, void 0, m)}%` : st(
15
15
  f,
16
16
  v !== "none" && v !== "%" && v !== "$" ? v : void 0,
17
17
  m
18
18
  ) : String(f);
19
- return { labelText: A, valueStr: S };
19
+ return { labelText: F, valueStr: w };
20
20
  }
21
21
  const ct = [
22
22
  // 0 green (emerald)
@@ -133,63 +133,60 @@ const ct = [
133
133
  top: "rgba(71, 85, 105, 0.56)",
134
134
  bottom: "rgba(71, 85, 105, 0.04)"
135
135
  }
136
- ], _t = 137.5;
137
- function Vt(e) {
136
+ ], Wt = 137.5;
137
+ function yt(e) {
138
138
  if (e < ct.length)
139
139
  return ct[e];
140
- const m = (e - ct.length) * _t % 360, A = Et(m, 70, 50), { topColor: f, bottomColor: S } = q(A);
141
- return { line: A, top: f, bottom: S };
140
+ const m = (e - ct.length) * Wt % 360, F = Dt(m, 70, 50), { topColor: f, bottomColor: w } = K(F);
141
+ return { line: F, top: f, bottom: w };
142
142
  }
143
- function se({
143
+ function ie({
144
144
  series: e,
145
145
  className: v,
146
146
  showLegend: m = !1,
147
- onUnselectSeries: A,
147
+ onUnselectSeries: F,
148
148
  xMeasureUnit: f = "time",
149
- yMeasureUnit: S = "token",
150
- optionsOverrides: Y,
149
+ yMeasureUnit: w = "token",
150
+ optionsOverrides: W,
151
151
  verticalLineOptions: C,
152
- currentValueDecimals: Z,
153
- useSharedPriceScale: V = !1,
152
+ currentValueDecimals: J,
153
+ useSharedPriceScale: k = !1,
154
154
  showCurrentValue: kt = !0,
155
- graphTitle: K,
155
+ graphTitle: Q,
156
156
  yScaleMin: ft,
157
- yScaleMinMultiple: dt
157
+ yScaleMinMultiple: gt
158
158
  }) {
159
- const k = M(null), w = M(/* @__PURE__ */ new Map()), J = M(!1), gt = M(!0), Q = M(
159
+ const N = z(null), R = z(/* @__PURE__ */ new Map()), U = z(!1), mt = z(!0), tt = z(
160
160
  null
161
- ), Nt = M(null), $ = M(null), U = M(null), W = M(null), y = Dt(), I = lt.useMemo(() => e.flatMap((t) => t.data), [e]), Pt = lt.useMemo(() => {
161
+ ), Nt = z(null), $ = z(null), et = z(null), y = $t(), M = lt.useMemo(() => e.flatMap((t) => t.data), [e]), Lt = lt.useMemo(() => {
162
162
  if (e.length > 0) {
163
163
  const t = e[e.length - 1];
164
164
  if (t.data.length > 0)
165
165
  return t.data[t.data.length - 1];
166
166
  }
167
- }, [e]), [mt, tt] = it(() => {
168
- if (!Pt) return;
167
+ }, [e]), [dt, ot] = it(() => {
168
+ if (!Lt) return;
169
169
  const t = /* @__PURE__ */ new Map();
170
170
  for (const a of e)
171
171
  a.data.length > 0 && t.set(a.label, a.data[a.data.length - 1]);
172
172
  return t;
173
- }), [bt, z] = it(null), [ht, pt] = it([]);
174
- D(() => {
173
+ }), [bt, A] = it(null), [ht, pt] = it([]);
174
+ E(() => {
175
175
  const t = () => {
176
- try {
177
- if (k.current && $.current) {
178
- const l = $.current.clientWidth, s = $.current.clientHeight;
179
- k.current.resize(l, s);
180
- }
181
- } catch {
176
+ if (N.current && $.current) {
177
+ const l = $.current.clientWidth, s = $.current.clientHeight;
178
+ N.current.resize(l, s);
182
179
  }
183
180
  }, a = $.current, r = a ? new ResizeObserver(t) : null;
184
- return W.current = r, a && r?.observe(a), () => {
185
- a && r?.unobserve(a), r?.disconnect(), W.current = null;
181
+ return a && r?.observe(a), () => {
182
+ a && r?.unobserve(a);
186
183
  };
187
- }, []), D(() => {
188
- if (!U.current || J.current) return;
184
+ }, []), E(() => {
185
+ if (!et.current || U.current) return;
189
186
  const t = Rt(), a = wt(
190
187
  "hsl(var(--foreground))",
191
188
  "rgb(0, 0, 0)"
192
- ), r = It(U.current, {
189
+ ), r = At(et.current, {
193
190
  ...t,
194
191
  rightPriceScale: {
195
192
  ...t.rightPriceScale || {},
@@ -199,32 +196,32 @@ function se({
199
196
  ...y && {
200
197
  crosshair: {
201
198
  ...t.crosshair,
202
- mode: zt.Magnet
199
+ mode: It.Magnet
203
200
  }
204
201
  },
205
- ...Y
202
+ ...W
206
203
  });
207
- return k.current = r, J.current = !0, () => {
208
- W.current?.disconnect(), W.current = null, r.remove(), k.current = null, J.current = !1, w.current.clear();
204
+ return N.current = r, U.current = !0, () => {
205
+ r.remove(), N.current = null, U.current = !1, R.current.clear();
209
206
  };
210
- }, [y, Y]), D(() => {
211
- const t = k.current;
207
+ }, [y, W]), E(() => {
208
+ const t = N.current;
212
209
  if (!t || e.length === 0) return;
213
- const r = e.filter((o) => o.data.length > 0).length <= 1 ? ft : dt, l = f === "time" ? yt(f, I) : yt(f), s = I.map((o) => o.value), {
210
+ const r = e.filter((o) => o.data.length > 0).length <= 1 ? ft : gt, l = f === "time" ? Vt(f, M) : Vt(f), s = M.map((o) => o.value), {
214
211
  formatter: c,
215
212
  tickmarksFormatter: u,
216
- updateVisibleRange: N,
217
- updateLastValues: d
218
- } = Bt(s, S, {
213
+ updateVisibleRange: L,
214
+ updateLastValues: g
215
+ } = Bt(s, w, {
219
216
  yScaleMin: r
220
217
  });
221
- Q.current = N, Nt.current = d;
218
+ tt.current = L, Nt.current = g;
222
219
  const P = e.filter((o) => o.data.length > 0).map((o) => o.data[o.data.length - 1].value);
223
- d(P);
224
- const L = Rt();
220
+ g(P);
221
+ const T = Rt();
225
222
  t.applyOptions({
226
223
  localization: {
227
- ...L.localization || {},
224
+ ...T.localization || {},
228
225
  // biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
229
226
  timeFormatter: (o) => (
230
227
  // biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
@@ -232,21 +229,21 @@ function se({
232
229
  )
233
230
  },
234
231
  timeScale: {
235
- ...L.timeScale || {},
232
+ ...T.timeScale || {},
236
233
  // biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
237
234
  tickMarkFormatter: l.tickMarkFormatter,
238
235
  minBarSpacing: 0
239
236
  }
240
237
  });
241
- const g = (I.length > 0 ? Math.min(...I.map((o) => o.value)) : 0) < 0, x = I.some((o) => o.value === 0), b = !g && x, p = e.length > 1 && !V, T = e.length > 1 && !V || y, F = wt(
238
+ const d = (M.length > 0 ? Math.min(...M.map((o) => o.value)) : 0) < 0, x = M.some((o) => o.value === 0), b = !d && x, p = e.length > 1 && !k, S = e.length > 1 && !k || y, I = wt(
242
239
  "hsl(var(--foreground))",
243
240
  "rgb(0, 0, 0)"
244
241
  );
245
242
  t.applyOptions({
246
243
  rightPriceScale: {
247
- ...L.rightPriceScale || {},
248
- visible: !T,
249
- textColor: F,
244
+ ...T.rightPriceScale || {},
245
+ visible: !S,
246
+ textColor: I,
250
247
  ...b && {
251
248
  scaleMargins: {
252
249
  top: 0.3,
@@ -255,46 +252,46 @@ function se({
255
252
  }
256
253
  }
257
254
  });
258
- const et = new Set(w.current.keys()), ot = new Set(e.map((o) => o.label));
259
- for (const o of et)
260
- if (!ot.has(o)) {
261
- const n = w.current.get(o);
262
- n && (t.removeSeries(n), w.current.delete(o));
255
+ const D = new Set(R.current.keys()), G = new Set(e.map((o) => o.label));
256
+ for (const o of D)
257
+ if (!G.has(o)) {
258
+ const n = R.current.get(o);
259
+ n && (t.removeSeries(n), R.current.delete(o));
263
260
  }
264
- const Lt = Gt(), rt = [];
265
- let X = 0;
261
+ const B = Et(), rt = [];
262
+ let Z = 0;
266
263
  for (let o = 0; o < e.length; o++) {
267
- const n = e[o], H = Vt(o), E = n.lineColor ?? n.color ?? H.line;
268
- let G, O;
264
+ const n = e[o], _ = yt(o), O = n.lineColor ?? n.color ?? _.line;
265
+ let Y, j;
269
266
  if (n.lineColor ?? n.color)
270
267
  if (n.topColor && n.bottomColor)
271
- G = n.topColor, O = n.bottomColor;
268
+ Y = n.topColor, j = n.bottomColor;
272
269
  else if (n.topColor) {
273
- const i = q(E);
274
- G = n.topColor, O = i.bottomColor;
270
+ const i = K(O);
271
+ Y = n.topColor, j = i.bottomColor;
275
272
  } else if (n.bottomColor)
276
- G = q(E).topColor, O = n.bottomColor;
273
+ Y = K(O).topColor, j = n.bottomColor;
277
274
  else {
278
- const i = q(E);
279
- G = i.topColor, O = i.bottomColor;
275
+ const i = K(O);
276
+ Y = i.topColor, j = i.bottomColor;
280
277
  }
281
278
  else
282
- G = n.topColor || H.top, O = n.bottomColor || H.bottom;
279
+ Y = n.topColor || _.top, j = n.bottomColor || _.bottom;
283
280
  if (n.data.length === 0) {
284
- const i = w.current.get(n.label);
285
- i && (t.removeSeries(i), w.current.delete(n.label));
281
+ const i = R.current.get(n.label);
282
+ i && (t.removeSeries(i), R.current.delete(n.label));
286
283
  continue;
287
284
  }
288
- const Tt = (n.data.length > 0 ? Math.min(...n.data.map((i) => i.value)) : 0) < 0, Ft = n.data.some((i) => i.value === 0), Mt = !Tt && Ft, Ct = V || !p || X === 0 ? "right" : `scale-${X}`;
285
+ const Pt = (n.data.length > 0 ? Math.min(...n.data.map((i) => i.value)) : 0) < 0, Tt = n.data.some((i) => i.value === 0), Ft = !Pt && Tt, Ct = k || !p || Z === 0 ? "right" : `scale-${Z}`;
289
286
  p && rt.push({
290
287
  priceScaleId: Ct || "right",
291
- shouldPreventNegativeAxis: Mt,
292
- seriesIndex: X
288
+ shouldPreventNegativeAxis: Ft,
289
+ seriesIndex: Z
293
290
  });
294
- const xt = (V || !p) && r !== void 0 && typeof r == "number", St = {
295
- lineColor: E,
296
- topColor: G,
297
- bottomColor: O,
291
+ const xt = (k || !p) && r !== void 0 && typeof r == "number", St = {
292
+ lineColor: O,
293
+ topColor: Y,
294
+ bottomColor: j,
298
295
  priceScaleId: Ct,
299
296
  priceFormat: {
300
297
  type: "custom",
@@ -308,27 +305,27 @@ function se({
308
305
  if (!xt) return i();
309
306
  const at = i();
310
307
  if (at?.priceRange) {
311
- const At = r;
312
- at.priceRange.minValue = At;
308
+ const Mt = r;
309
+ at.priceRange.minValue = Mt;
313
310
  }
314
311
  return at;
315
312
  }
316
313
  };
317
- let B = w.current.get(n.label);
318
- B ? (B.applyOptions(St), B.setData(
314
+ let H = R.current.get(n.label);
315
+ H ? (H.applyOptions(St), H.setData(
319
316
  n.data.map((i) => ({
320
317
  ...i,
321
318
  time: i.time
322
319
  }))
323
- )) : (B = t.addSeries($t, {
324
- ...Lt,
320
+ )) : (H = t.addSeries(zt, {
321
+ ...B,
325
322
  ...St
326
- }), B.setData(
323
+ }), H.setData(
327
324
  n.data.map((i) => ({
328
325
  ...i,
329
326
  time: i.time
330
327
  }))
331
- ), w.current.set(n.label, B)), X++;
328
+ ), R.current.set(n.label, H)), Z++;
332
329
  }
333
330
  if (p && rt.length > 0)
334
331
  for (const o of rt)
@@ -349,7 +346,7 @@ function se({
349
346
  borderVisible: !0,
350
347
  borderColor: "rgba(224, 227, 235, 0.1)",
351
348
  entireTextOnly: !1,
352
- textColor: F
349
+ textColor: I
353
350
  });
354
351
  } catch (n) {
355
352
  console.warn(
@@ -375,34 +372,34 @@ function se({
375
372
  borderVisible: !0,
376
373
  borderColor: "rgba(224, 227, 235, 0.1)",
377
374
  entireTextOnly: !1,
378
- textColor: F
375
+ textColor: I
379
376
  });
380
377
  } catch {
381
378
  }
382
- if (r !== void 0 && !y && (V || !p) && t.applyOptions({
379
+ if (r !== void 0 && !y && (k || !p) && t.applyOptions({
383
380
  handleScroll: {
384
381
  vertTouchDrag: !1
385
382
  }
386
- }), I.length > 0) {
387
- const o = I.map((E) => Number(E.time)), n = Math.min(...o), H = Math.max(...o);
388
- t.timeScale().setVisibleRange({ from: n, to: H });
383
+ }), M.length > 0) {
384
+ const o = M.map((O) => Number(O.time)), n = Math.min(...o), _ = Math.max(...o);
385
+ t.timeScale().setVisibleRange({ from: n, to: _ });
389
386
  }
390
- gt.current && (gt.current = !1);
387
+ mt.current && (mt.current = !1);
391
388
  const nt = /* @__PURE__ */ new Map();
392
389
  for (const o of e)
393
390
  o.data.length > 0 && nt.set(o.label, o.data[o.data.length - 1]);
394
- tt(nt.size > 0 ? nt : void 0);
391
+ ot(nt.size > 0 ? nt : void 0);
395
392
  }, [
396
393
  e,
397
- I,
394
+ M,
398
395
  f,
399
- S,
396
+ w,
400
397
  y,
401
- V,
398
+ k,
402
399
  ft,
403
- dt
404
- ]), D(() => {
405
- const t = k.current;
400
+ gt
401
+ ]), E(() => {
402
+ const t = N.current;
406
403
  if (!t || e.length === 0) return;
407
404
  const a = e.length === 1;
408
405
  let r;
@@ -413,83 +410,96 @@ function se({
413
410
  }
414
411
  if (!r) return;
415
412
  const l = (s) => {
416
- const { time: c = r, seriesData: u, point: N } = s || {}, d = Array.from(w.current.values());
417
- if (!N || !c) {
418
- const R = /* @__PURE__ */ new Map();
419
- for (const g of e)
420
- g.data.length > 0 && R.set(g.label, g.data[g.data.length - 1]);
421
- if (tt(R.size > 0 ? R : void 0), a || V)
422
- z(null);
423
- else if (d[0] && r) {
413
+ const { time: c = r, seriesData: u, point: L } = s || {}, g = Array.from(R.current.values());
414
+ if (!L || !c) {
415
+ const V = /* @__PURE__ */ new Map();
416
+ for (const d of e)
417
+ d.data.length > 0 && V.set(d.label, d.data[d.data.length - 1]);
418
+ if (ot(V.size > 0 ? V : void 0), a || k)
419
+ A(null);
420
+ else if (g[0] && r) {
424
421
  const x = t.timeScale().timeToCoordinate(r), b = e[0];
425
422
  if (b.data.length > 0) {
426
- const p = b.data[b.data.length - 1].value, T = d[0].priceToCoordinate(p);
427
- x !== null && T !== null && z({ x, y: T });
423
+ const p = b.data[b.data.length - 1].value, S = g[0].priceToCoordinate(p);
424
+ x !== null && S !== null && A({ x, y: S });
428
425
  }
429
426
  }
430
427
  return;
431
428
  }
432
429
  const P = /* @__PURE__ */ new Map();
433
- let L;
434
- for (let R = 0; R < e.length; R++) {
435
- const g = e[R], x = d[R];
430
+ let T;
431
+ for (let V = 0; V < e.length; V++) {
432
+ const d = e[V], x = g[V];
436
433
  if (!x) continue;
437
- const b = u?.get(x), p = b && "value" in b ? b.value : void 0, T = g.data[g.data.length - 1], F = p !== void 0 ? p : T?.value ?? 0;
438
- R === 0 && (L = F), P.set(g.label, { value: F, time: c });
434
+ const b = u?.get(x), p = b && "value" in b ? b.value : void 0;
435
+ let S;
436
+ if (p !== void 0)
437
+ S = p;
438
+ else {
439
+ const I = Number(c), D = d.data;
440
+ let G = 0;
441
+ for (let B = D.length - 1; B >= 0; B--)
442
+ if (Number(D[B].time) <= I) {
443
+ G = D[B].value;
444
+ break;
445
+ }
446
+ S = G;
447
+ }
448
+ V === 0 && (T = S), P.set(d.label, { value: S, time: c });
439
449
  }
440
- if (tt(P), L !== void 0 && d[0]) {
441
- const g = t.timeScale().timeToCoordinate(c), x = d[0].priceToCoordinate(L);
442
- if (g !== null && x !== null) {
450
+ if (ot(P), T !== void 0 && g[0]) {
451
+ const d = t.timeScale().timeToCoordinate(c), x = g[0].priceToCoordinate(T);
452
+ if (d !== null && x !== null) {
443
453
  const b = $.current;
444
454
  if (b) {
445
455
  const p = b.querySelector(
446
456
  ".LightweightChart"
447
457
  );
448
458
  if (p) {
449
- const T = p.getBoundingClientRect(), F = b.getBoundingClientRect(), et = g + (T.left - F.left), ot = x + (T.top - F.top);
450
- z({ x: et, y: ot });
459
+ const S = p.getBoundingClientRect(), I = b.getBoundingClientRect(), D = d + (S.left - I.left), G = x + (S.top - I.top);
460
+ A({ x: D, y: G });
451
461
  } else
452
- z({ x: g, y: x });
462
+ A({ x: d, y: x });
453
463
  } else
454
- z({ x: g, y: x });
464
+ A({ x: d, y: x });
455
465
  } else
456
- z(null);
466
+ A(null);
457
467
  } else
458
- z(null);
468
+ A(null);
459
469
  };
460
- return t.subscribeCrosshairMove(l), y && t.subscribeClick(l), !a && !V && requestAnimationFrame(() => {
461
- const s = Array.from(w.current.values());
470
+ return t.subscribeCrosshairMove(l), y && t.subscribeClick(l), !a && !k && requestAnimationFrame(() => {
471
+ const s = Array.from(R.current.values());
462
472
  if (s[0] && r && e[0]?.data.length > 0) {
463
- const u = t.timeScale().timeToCoordinate(r), N = e[0].data[e[0].data.length - 1].value, d = s[0].priceToCoordinate(N);
464
- u !== null && d !== null && z({ x: u, y: d });
473
+ const u = t.timeScale().timeToCoordinate(r), L = e[0].data[e[0].data.length - 1].value, g = s[0].priceToCoordinate(L);
474
+ u !== null && g !== null && A({ x: u, y: g });
465
475
  }
466
476
  }), () => {
467
477
  t.unsubscribeCrosshairMove(l), y && t.unsubscribeClick(l);
468
478
  };
469
- }, [e, V, y]), D(() => {
470
- const t = k.current;
479
+ }, [e, k, y]), E(() => {
480
+ const t = N.current;
471
481
  if (!t || e.length === 0) return;
472
482
  const a = t.timeScale(), r = () => {
473
- if (!Q.current) return;
483
+ if (!tt.current) return;
474
484
  const l = a.getVisibleRange();
475
485
  if (!l) return;
476
486
  const s = Number(l.from), c = Number(l.to), u = [];
477
- for (const N of e)
478
- for (const d of N.data) {
479
- const P = Number(d.time);
480
- P >= s && P <= c && u.push(d.value);
487
+ for (const L of e)
488
+ for (const g of L.data) {
489
+ const P = Number(g.time);
490
+ P >= s && P <= c && u.push(g.value);
481
491
  }
482
- u.length > 0 && Q.current(u);
492
+ u.length > 0 && tt.current(u);
483
493
  };
484
494
  return a.subscribeVisibleLogicalRangeChange(r), () => {
485
495
  a.unsubscribeVisibleLogicalRangeChange(
486
496
  r
487
497
  );
488
498
  };
489
- }, [e]), D(() => {
490
- const t = k.current, a = Array.from(w.current.values()), r = [];
499
+ }, [e]), E(() => {
500
+ const t = N.current, a = Array.from(R.current.values()), r = [];
491
501
  if (t && a.length > 0 && C) {
492
- const l = Ot(), s = a[0];
502
+ const l = Gt(), s = a[0];
493
503
  for (const c of C) {
494
504
  const u = new jt(t, s, c.xCoordinate, {
495
505
  ...l,
@@ -505,8 +515,8 @@ function se({
505
515
  l.detachPrimitive(s);
506
516
  }
507
517
  };
508
- }, [C]), D(() => {
509
- const t = k.current;
518
+ }, [C]), E(() => {
519
+ const t = N.current;
510
520
  if (!t || !C?.length) {
511
521
  pt([]);
512
522
  return;
@@ -523,14 +533,14 @@ function se({
523
533
  r.unsubscribeVisibleLogicalRangeChange(l);
524
534
  };
525
535
  }, [C]);
526
- const _ = e.length === 1, vt = lt.useMemo(() => {
527
- if (_ && e.length > 0) {
536
+ const q = e.length === 1, vt = lt.useMemo(() => {
537
+ if (q && e.length > 0) {
528
538
  const t = e[0];
529
539
  if (t.data.length > 0)
530
540
  return t.data[t.data.length - 1];
531
541
  }
532
- }, [_, e]);
533
- return /* @__PURE__ */ j(
542
+ }, [q, e]);
543
+ return /* @__PURE__ */ X(
534
544
  "div",
535
545
  {
536
546
  ref: $,
@@ -539,28 +549,28 @@ function se({
539
549
  v
540
550
  ),
541
551
  children: [
542
- K != null && K !== !1 && _ ? /* @__PURE__ */ h("div", { className: "absolute top-2 left-2 right-2 z-[100] pointer-events-none", children: /* @__PURE__ */ h("div", { className: "text-xl sm:text-2xl font-semibold text-foreground whitespace-nowrap overflow-hidden text-ellipsis", children: K }) }) : kt && _ && vt && /* @__PURE__ */ h(
543
- Yt,
552
+ Q != null && Q !== !1 && q ? /* @__PURE__ */ h("div", { className: "absolute top-2 left-2 right-2 z-[100] pointer-events-none", children: /* @__PURE__ */ h("div", { className: "text-xl sm:text-2xl font-semibold text-foreground whitespace-nowrap overflow-hidden text-ellipsis", children: Q }) }) : kt && q && vt && /* @__PURE__ */ h(
553
+ Ot,
544
554
  {
545
555
  point: vt,
546
556
  xMeasureUnit: f,
547
- yMeasureUnit: S,
548
- decimals: Z
557
+ yMeasureUnit: w,
558
+ decimals: J
549
559
  }
550
560
  ),
551
- mt && bt && /* @__PURE__ */ h(
552
- Ht,
561
+ dt && bt && /* @__PURE__ */ h(
562
+ Yt,
553
563
  {
554
- points: mt,
564
+ points: dt,
555
565
  xMeasureUnit: f,
556
- yMeasureUnit: S,
566
+ yMeasureUnit: w,
557
567
  series: e,
558
568
  position: bt,
559
569
  containerRef: $,
560
- decimals: Z
570
+ decimals: J
561
571
  }
562
572
  ),
563
- m && /* @__PURE__ */ h(Xt, { series: e, onUnselect: A }),
573
+ m && /* @__PURE__ */ h(_t, { series: e, onUnselect: F }),
564
574
  C && C.length > 0 && ht.length === C.length && /* @__PURE__ */ h(
565
575
  "div",
566
576
  {
@@ -569,21 +579,21 @@ function se({
569
579
  children: C.map((t, a) => {
570
580
  const r = ht[a], l = t.options ?? {}, s = l.showLabel !== !1;
571
581
  if (r === null || !s) return null;
572
- const { labelText: c, valueStr: u } = Wt(
582
+ const { labelText: c, valueStr: u } = Ht(
573
583
  l,
574
- S,
575
- Z
584
+ w,
585
+ J
576
586
  );
577
587
  if (!(c || u)) return null;
578
- const d = l.labelBackgroundColor ?? l.color ?? "hsl(var(--background))", P = l.labelTextColor ?? "hsl(var(--foreground))", L = `${String(t.xCoordinate)}-${c}`;
579
- return /* @__PURE__ */ j(
588
+ const g = l.labelBackgroundColor ?? l.color ?? "hsl(var(--background))", P = l.labelTextColor ?? "hsl(var(--foreground))", T = `${String(t.xCoordinate)}-${c}`;
589
+ return /* @__PURE__ */ X(
580
590
  "div",
581
591
  {
582
592
  className: "absolute top-2 px-2 py-1 rounded text-xs font-medium whitespace-nowrap shadow-sm border border-border",
583
593
  style: {
584
594
  left: r,
585
595
  transform: "translateX(-50%)",
586
- backgroundColor: d,
596
+ backgroundColor: g,
587
597
  color: P
588
598
  },
589
599
  children: [
@@ -591,7 +601,7 @@ function se({
591
601
  u && /* @__PURE__ */ h("span", { className: ut("block", c && "mt-0.5"), children: u })
592
602
  ]
593
603
  },
594
- L
604
+ T
595
605
  );
596
606
  })
597
607
  }
@@ -599,7 +609,7 @@ function se({
599
609
  /* @__PURE__ */ h(
600
610
  "div",
601
611
  {
602
- ref: U,
612
+ ref: et,
603
613
  className: "LightweightChart w-full h-full overflow-hidden"
604
614
  }
605
615
  )
@@ -607,30 +617,30 @@ function se({
607
617
  }
608
618
  );
609
619
  }
610
- function Xt({
620
+ function _t({
611
621
  series: e,
612
622
  onUnselect: v
613
623
  }) {
614
- return /* @__PURE__ */ h("div", { className: "absolute top-0 left-2 z-[10] flex flex-wrap gap-2", children: e.map((m, A) => {
615
- const f = Vt(A), S = (m.lineColor ?? m.color) || f.line, Y = m.data.length === 0;
616
- return /* @__PURE__ */ j(
624
+ return /* @__PURE__ */ h("div", { className: "absolute top-0 left-2 z-[10] flex flex-wrap gap-2", children: e.map((m, F) => {
625
+ const f = yt(F), w = (m.lineColor ?? m.color) || f.line, W = m.data.length === 0;
626
+ return /* @__PURE__ */ X(
617
627
  "div",
618
628
  {
619
629
  className: ut(
620
630
  "flex items-center gap-1.5 px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border",
621
- Y && "opacity-50"
631
+ W && "opacity-50"
622
632
  ),
623
633
  children: [
624
634
  /* @__PURE__ */ h(
625
635
  "div",
626
636
  {
627
637
  className: "w-3 h-3 rounded-sm",
628
- style: { backgroundColor: S }
638
+ style: { backgroundColor: w }
629
639
  }
630
640
  ),
631
- /* @__PURE__ */ j("span", { className: "text-[10px] sm:text-xs font-medium text-foreground", children: [
641
+ /* @__PURE__ */ X("span", { className: "text-[10px] sm:text-xs font-medium text-foreground", children: [
632
642
  m.label,
633
- Y && " (no data)"
643
+ W && " (no data)"
634
644
  ] }),
635
645
  v && /* @__PURE__ */ h(
636
646
  "button",
@@ -641,7 +651,7 @@ function Xt({
641
651
  },
642
652
  className: "ml-1 flex items-center justify-center w-4 h-4 rounded-sm hover:bg-muted transition-colors cursor-pointer",
643
653
  "aria-label": `Remove ${m.label}`,
644
- children: /* @__PURE__ */ j(
654
+ children: /* @__PURE__ */ X(
645
655
  "svg",
646
656
  {
647
657
  xmlns: "http://www.w3.org/2000/svg",
@@ -672,7 +682,7 @@ function Xt({
672
682
  }
673
683
  export {
674
684
  ct as DEFAULT_SERIES_COLORS,
675
- se as Graph,
676
- Vt as getSeriesColorPalette,
677
- Wt as getVerticalLineTooltipContent
685
+ ie as Graph,
686
+ yt as getSeriesColorPalette,
687
+ Ht as getVerticalLineTooltipContent
678
688
  };