@gearbox-protocol/permissionless-ui 1.26.4 → 1.26.6

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