@gearbox-protocol/ui-kit 3.1.0-next.1 → 3.1.0

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