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