@gearbox-protocol/ui-kit 4.0.0-next.57 → 4.0.0-next.58
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.
- package/dist/cjs/components/graph/graph.cjs +1 -1
- package/dist/cjs/components/graph/index.cjs +1 -1
- package/dist/cjs/components/index.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/esm/components/graph/graph.js +488 -478
- package/dist/esm/components/graph/index.js +18 -17
- package/dist/esm/components/index.js +323 -322
- package/dist/esm/index.js +410 -409
- package/dist/types/components/graph/graph.d.ts +25 -4
- package/package.json +1 -1
|
@@ -1,42 +1,56 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { createChart as ht, CrosshairMode as
|
|
3
|
-
import * as
|
|
4
|
-
import { useRef as K, useState as
|
|
1
|
+
import { jsxs as U, jsx as w } from "react/jsx-runtime";
|
|
2
|
+
import { createChart as ht, CrosshairMode as gt, LineStyle as ie, LineSeries as pt, AreaSeries as dt } from "lightweight-charts";
|
|
3
|
+
import * as we from "react";
|
|
4
|
+
import { useRef as K, useState as oe, useEffect as G, useLayoutEffect as mt } from "react";
|
|
5
5
|
import { useIsMobile as bt } from "../../hooks/use-media-query.js";
|
|
6
6
|
import { cn as O } from "../../utils/cn.js";
|
|
7
|
-
import { hslToHex as St, generateColorsFromBase as
|
|
8
|
-
import { getDefaultOptions as
|
|
9
|
-
import { formatExactValue as
|
|
7
|
+
import { hslToHex as St, generateColorsFromBase as de, resolveCSSColor as re } from "../../utils/colors.js";
|
|
8
|
+
import { AXIS_TIME_EDGE_PADDING_PX as vt, getDefaultOptions as Ze, getDefaultSeries as Ct, AXIS_TICK_MARK_DENSITY as pe, getDefaultVerticalLine as yt, AXIS_FONT_SIZE as xt, AXIS_EDGE_LABEL_PADDING_PX as qe, AXIS_TOP_LABEL_PADDING_PX as Oe } from "./default-config.js";
|
|
9
|
+
import { formatExactValue as Pe, isRatioUnit as _t, getXFormatters as Je, createAdaptiveYAxisFormatter as wt } from "./formatters.js";
|
|
10
10
|
import { GraphCurrentValue as Pt } from "./graph-current-value.js";
|
|
11
|
-
import { GraphTooltip as
|
|
11
|
+
import { GraphTooltip as Tt } from "./graph-tooltip.js";
|
|
12
12
|
import { VertLine as Rt } from "./plugins/vertical-line.js";
|
|
13
|
-
import { pickMinMove as
|
|
14
|
-
function
|
|
13
|
+
import { pickMinMove as Nt, niceAxisRange as Vt } from "./y-axis-scale.js";
|
|
14
|
+
function ne(e) {
|
|
15
15
|
return e.id ?? e.label;
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function kt({
|
|
18
|
+
lastIndex: e,
|
|
19
|
+
width: i,
|
|
20
|
+
padLeft: c,
|
|
21
|
+
padRight: f,
|
|
22
|
+
paddingPx: h = vt
|
|
23
|
+
}) {
|
|
24
|
+
if (e < 0) return null;
|
|
25
|
+
const u = (c || f) && i > 0 ? h * Math.max(e, 1) / i : 0;
|
|
26
|
+
return {
|
|
27
|
+
from: c && u !== 0 ? -u : 0,
|
|
28
|
+
to: f ? e + u : e
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function Qe(e, i, c) {
|
|
18
32
|
if (!c)
|
|
19
33
|
return e.values().next().value;
|
|
20
|
-
const
|
|
21
|
-
if (
|
|
22
|
-
const h = i.find((
|
|
23
|
-
return h ? e.get(
|
|
34
|
+
const f = e.get(c);
|
|
35
|
+
if (f) return f;
|
|
36
|
+
const h = i.find((u) => u.id === c || u.label === c);
|
|
37
|
+
return h ? e.get(ne(h)) : void 0;
|
|
24
38
|
}
|
|
25
39
|
class Lt {
|
|
26
40
|
_yTop;
|
|
27
41
|
_yBottom;
|
|
28
42
|
_color;
|
|
29
|
-
constructor(i, c,
|
|
30
|
-
this._yTop = i, this._yBottom = c, this._color =
|
|
43
|
+
constructor(i, c, f) {
|
|
44
|
+
this._yTop = i, this._yBottom = c, this._color = f;
|
|
31
45
|
}
|
|
32
46
|
draw(i) {
|
|
33
47
|
i.useBitmapCoordinateSpace((c) => {
|
|
34
|
-
const
|
|
35
|
-
|
|
48
|
+
const f = c.context, h = c.verticalPixelRatio, u = this._yTop === null ? 0 : this._yTop * h, S = this._yBottom === null ? c.bitmapSize.height : this._yBottom * h, P = Math.min(u, S), D = Math.max(u, S);
|
|
49
|
+
f.fillStyle = this._color, f.fillRect(0, P, c.bitmapSize.width, D - P);
|
|
36
50
|
});
|
|
37
51
|
}
|
|
38
52
|
}
|
|
39
|
-
class
|
|
53
|
+
class Mt {
|
|
40
54
|
_source;
|
|
41
55
|
_yTop = null;
|
|
42
56
|
_yBottom = null;
|
|
@@ -55,14 +69,14 @@ class kt {
|
|
|
55
69
|
return new Lt(this._yTop, this._yBottom, this._source.color);
|
|
56
70
|
}
|
|
57
71
|
}
|
|
58
|
-
class
|
|
72
|
+
class Dt {
|
|
59
73
|
series;
|
|
60
74
|
priceTop;
|
|
61
75
|
priceBottom;
|
|
62
76
|
color;
|
|
63
77
|
_paneViews;
|
|
64
|
-
constructor(i, c,
|
|
65
|
-
this.series = i, this.priceTop = c, this.priceBottom =
|
|
78
|
+
constructor(i, c, f, h) {
|
|
79
|
+
this.series = i, this.priceTop = c, this.priceBottom = f, this.color = h, this._paneViews = [new Mt(this)];
|
|
66
80
|
}
|
|
67
81
|
updateAllViews() {
|
|
68
82
|
for (const i of this._paneViews) i.update();
|
|
@@ -73,35 +87,35 @@ class Mt {
|
|
|
73
87
|
}
|
|
74
88
|
function It(e, i) {
|
|
75
89
|
switch (e) {
|
|
76
|
-
case
|
|
90
|
+
case ie.Dotted:
|
|
77
91
|
return [i, i];
|
|
78
|
-
case
|
|
92
|
+
case ie.Dashed:
|
|
79
93
|
return [2 * i, 2 * i];
|
|
80
|
-
case
|
|
94
|
+
case ie.LargeDashed:
|
|
81
95
|
return [6 * i, 6 * i];
|
|
82
|
-
case
|
|
96
|
+
case ie.SparseDotted:
|
|
83
97
|
return [i, 4 * i];
|
|
84
98
|
default:
|
|
85
99
|
return [];
|
|
86
100
|
}
|
|
87
101
|
}
|
|
88
|
-
class
|
|
102
|
+
class Et {
|
|
89
103
|
_y;
|
|
90
104
|
_color;
|
|
91
105
|
_lineWidth;
|
|
92
106
|
_lineStyle;
|
|
93
|
-
constructor(i, c,
|
|
94
|
-
this._y = i, this._color = c, this._lineWidth =
|
|
107
|
+
constructor(i, c, f, h) {
|
|
108
|
+
this._y = i, this._color = c, this._lineWidth = f, this._lineStyle = h;
|
|
95
109
|
}
|
|
96
110
|
draw(i) {
|
|
97
111
|
i.useBitmapCoordinateSpace((c) => {
|
|
98
112
|
if (this._y === null) return;
|
|
99
|
-
const
|
|
100
|
-
|
|
113
|
+
const f = c.context, h = c.verticalPixelRatio, u = Math.max(1, Math.round(this._lineWidth * h)), S = Math.round(this._y * h);
|
|
114
|
+
f.save(), f.strokeStyle = this._color, f.lineWidth = u, f.setLineDash(It(this._lineStyle, u)), f.beginPath(), f.moveTo(0, S), f.lineTo(c.bitmapSize.width, S), f.stroke(), f.restore();
|
|
101
115
|
});
|
|
102
116
|
}
|
|
103
117
|
}
|
|
104
|
-
class
|
|
118
|
+
class Bt {
|
|
105
119
|
_source;
|
|
106
120
|
_y = null;
|
|
107
121
|
constructor(i) {
|
|
@@ -120,7 +134,7 @@ class Et {
|
|
|
120
134
|
return "top";
|
|
121
135
|
}
|
|
122
136
|
renderer() {
|
|
123
|
-
return new
|
|
137
|
+
return new Et(
|
|
124
138
|
this._y,
|
|
125
139
|
this._source.color,
|
|
126
140
|
this._source.lineWidth,
|
|
@@ -128,15 +142,15 @@ class Et {
|
|
|
128
142
|
);
|
|
129
143
|
}
|
|
130
144
|
}
|
|
131
|
-
class
|
|
145
|
+
class Ft {
|
|
132
146
|
series;
|
|
133
147
|
price;
|
|
134
148
|
color;
|
|
135
149
|
lineWidth;
|
|
136
150
|
lineStyle;
|
|
137
151
|
_paneViews;
|
|
138
|
-
constructor(i, c,
|
|
139
|
-
this.series = i, this.price = c, this.color =
|
|
152
|
+
constructor(i, c, f, h, u) {
|
|
153
|
+
this.series = i, this.price = c, this.color = f, this.lineWidth = h, this.lineStyle = u, this._paneViews = [new Bt(this)];
|
|
140
154
|
}
|
|
141
155
|
updateAllViews() {
|
|
142
156
|
for (const i of this._paneViews) i.update();
|
|
@@ -145,29 +159,29 @@ class Bt {
|
|
|
145
159
|
return this._paneViews;
|
|
146
160
|
}
|
|
147
161
|
}
|
|
148
|
-
function
|
|
149
|
-
const
|
|
162
|
+
function zt(e, i, c) {
|
|
163
|
+
const f = e.labelText ?? "", h = e.value, u = h === void 0 ? "" : typeof h == "number" ? i === "$" ? `$${Pe(h, void 0, c)}` : i === "%" ? `${Pe(h, void 0, c)}%` : Pe(
|
|
150
164
|
h,
|
|
151
165
|
i !== "none" && i !== "%" && i !== "$" && !_t(i) ? i : void 0,
|
|
152
166
|
c
|
|
153
167
|
) : String(h);
|
|
154
|
-
return { labelText:
|
|
168
|
+
return { labelText: f, valueStr: u };
|
|
155
169
|
}
|
|
156
|
-
const
|
|
157
|
-
function
|
|
158
|
-
const
|
|
170
|
+
const Ye = 4;
|
|
171
|
+
function At(e, i, c) {
|
|
172
|
+
const f = { left: e, transform: "translateX(-50%)" };
|
|
159
173
|
if (i <= 0 || !c || c <= 0)
|
|
160
|
-
return
|
|
161
|
-
const h = c / 2,
|
|
162
|
-
return S <
|
|
174
|
+
return f;
|
|
175
|
+
const h = c / 2, u = Ye + h, S = i - Ye - h;
|
|
176
|
+
return S < u ? { left: i / 2, transform: "translateX(-50%)" } : { left: Math.min(Math.max(e, u), S), transform: "translateX(-50%)" };
|
|
163
177
|
}
|
|
164
|
-
function
|
|
178
|
+
function Gt(e, i) {
|
|
165
179
|
for (let c = e.length - 1; c >= 0; c--)
|
|
166
180
|
if (Number(e[c].time) <= i)
|
|
167
181
|
return e[c].value;
|
|
168
182
|
return 0;
|
|
169
183
|
}
|
|
170
|
-
const
|
|
184
|
+
const Te = [
|
|
171
185
|
// 0 green (emerald)
|
|
172
186
|
{
|
|
173
187
|
line: "#02c39a",
|
|
@@ -282,105 +296,105 @@ const ke = [
|
|
|
282
296
|
top: "rgba(71, 85, 105, 0.56)",
|
|
283
297
|
bottom: "rgba(71, 85, 105, 0.04)"
|
|
284
298
|
}
|
|
285
|
-
],
|
|
286
|
-
function
|
|
287
|
-
if (e <
|
|
288
|
-
return
|
|
289
|
-
const c = (e -
|
|
290
|
-
return { line:
|
|
299
|
+
], Wt = 137.5;
|
|
300
|
+
function Ue(e) {
|
|
301
|
+
if (e < Te.length)
|
|
302
|
+
return Te[e];
|
|
303
|
+
const c = (e - Te.length) * Wt % 360, f = St(c, 70, 50), { topColor: h, bottomColor: u } = de(f);
|
|
304
|
+
return { line: f, top: h, bottom: u };
|
|
291
305
|
}
|
|
292
|
-
function
|
|
306
|
+
function ro({
|
|
293
307
|
series: e,
|
|
294
308
|
className: i,
|
|
295
309
|
showLegend: c = !1,
|
|
296
|
-
onUnselectSeries:
|
|
310
|
+
onUnselectSeries: f,
|
|
297
311
|
xMeasureUnit: h = "time",
|
|
298
|
-
yMeasureUnit:
|
|
312
|
+
yMeasureUnit: u = "token",
|
|
299
313
|
optionsOverrides: S,
|
|
300
314
|
verticalLineOptions: P,
|
|
301
|
-
priceLineOptions:
|
|
302
|
-
zoneOptions:
|
|
303
|
-
currentValueDecimals:
|
|
315
|
+
priceLineOptions: D,
|
|
316
|
+
zoneOptions: z,
|
|
317
|
+
currentValueDecimals: le,
|
|
304
318
|
useSharedPriceScale: Z = !1,
|
|
305
|
-
dualYAxis:
|
|
306
|
-
defaultVisiblePriceScaleId:
|
|
307
|
-
leftPriceScaleTitle:
|
|
308
|
-
rightPriceScaleTitle:
|
|
309
|
-
showCurrentValue:
|
|
310
|
-
graphTitle:
|
|
311
|
-
yScaleMin:
|
|
312
|
-
yScaleMinMultiple:
|
|
313
|
-
visibleTimeFrom:
|
|
314
|
-
disableZoom:
|
|
315
|
-
hideDefaultTooltip:
|
|
319
|
+
dualYAxis: I = !1,
|
|
320
|
+
defaultVisiblePriceScaleId: Re = "right",
|
|
321
|
+
leftPriceScaleTitle: Ne,
|
|
322
|
+
rightPriceScaleTitle: $t,
|
|
323
|
+
showCurrentValue: et = !0,
|
|
324
|
+
graphTitle: me,
|
|
325
|
+
yScaleMin: Ve,
|
|
326
|
+
yScaleMinMultiple: ke,
|
|
327
|
+
visibleTimeFrom: ae,
|
|
328
|
+
disableZoom: Le = !1,
|
|
329
|
+
hideDefaultTooltip: be = !1
|
|
316
330
|
}) {
|
|
317
|
-
const E = K(null),
|
|
331
|
+
const E = K(null), N = K(/* @__PURE__ */ new Map()), Se = K(!1), Me = K(!0), De = K([]), se = K(0), B = K(null), ve = K(null), Ie = K(null), T = bt(), ce = we.useMemo(() => e.flatMap((t) => t.data), [e]), tt = we.useMemo(() => {
|
|
318
332
|
if (e.length > 0) {
|
|
319
333
|
const t = e[e.length - 1];
|
|
320
334
|
if (t.data.length > 0)
|
|
321
335
|
return t.data[t.data.length - 1];
|
|
322
336
|
}
|
|
323
|
-
}, [e]), [
|
|
324
|
-
if (!
|
|
337
|
+
}, [e]), [Ee, Ce] = oe(() => {
|
|
338
|
+
if (!tt) return;
|
|
325
339
|
const t = /* @__PURE__ */ new Map();
|
|
326
|
-
for (const
|
|
327
|
-
|
|
340
|
+
for (const a of e)
|
|
341
|
+
a.data.length > 0 && t.set(a.label, a.data[a.data.length - 1]);
|
|
328
342
|
return t;
|
|
329
|
-
}), [
|
|
343
|
+
}), [Be, J] = oe(null), [Fe, ze] = oe([]), [ot, Ae] = oe(0), Ge = K(/* @__PURE__ */ new Map()), [rt, nt] = oe({}), [Q, it] = oe(0);
|
|
330
344
|
G(() => {
|
|
331
345
|
const t = () => {
|
|
332
346
|
try {
|
|
333
|
-
if (B.current &&
|
|
334
|
-
const
|
|
335
|
-
E.current.resize(
|
|
347
|
+
if (B.current && Ae(B.current.clientWidth), E.current && B.current) {
|
|
348
|
+
const l = B.current.clientWidth, s = B.current.clientHeight;
|
|
349
|
+
E.current.resize(l, s);
|
|
336
350
|
try {
|
|
337
|
-
|
|
351
|
+
se.current = E.current.paneSize().height;
|
|
338
352
|
} catch {
|
|
339
353
|
}
|
|
340
354
|
}
|
|
341
355
|
} catch {
|
|
342
356
|
}
|
|
343
|
-
},
|
|
344
|
-
return
|
|
345
|
-
|
|
357
|
+
}, a = B.current, r = a ? new ResizeObserver(t) : null;
|
|
358
|
+
return Ie.current = r, a && r?.observe(a), () => {
|
|
359
|
+
a && r?.unobserve(a), r?.disconnect(), Ie.current = null;
|
|
346
360
|
};
|
|
347
361
|
}, []), G(() => {
|
|
348
|
-
if (!
|
|
349
|
-
const t =
|
|
362
|
+
if (!ve.current || Se.current) return;
|
|
363
|
+
const t = Ze(), a = re(
|
|
350
364
|
"hsl(var(--muted-foreground))",
|
|
351
365
|
"rgb(163, 163, 163)"
|
|
352
|
-
),
|
|
366
|
+
), r = ht(ve.current, {
|
|
353
367
|
...t,
|
|
354
368
|
leftPriceScale: {
|
|
355
369
|
...t.leftPriceScale || {},
|
|
356
370
|
visible: !1,
|
|
357
|
-
textColor:
|
|
371
|
+
textColor: a
|
|
358
372
|
},
|
|
359
373
|
rightPriceScale: {
|
|
360
374
|
...t.rightPriceScale || {},
|
|
361
|
-
visible: !
|
|
362
|
-
textColor:
|
|
375
|
+
visible: !T,
|
|
376
|
+
textColor: a
|
|
363
377
|
},
|
|
364
|
-
...
|
|
378
|
+
...T && {
|
|
365
379
|
crosshair: {
|
|
366
380
|
...t.crosshair,
|
|
367
|
-
mode:
|
|
381
|
+
mode: gt.Magnet
|
|
368
382
|
}
|
|
369
383
|
}
|
|
370
384
|
});
|
|
371
|
-
E.current =
|
|
385
|
+
E.current = r, Se.current = !0;
|
|
372
386
|
try {
|
|
373
|
-
|
|
387
|
+
se.current = r.paneSize().height;
|
|
374
388
|
} catch {
|
|
375
|
-
|
|
389
|
+
se.current = 0;
|
|
376
390
|
}
|
|
377
|
-
return
|
|
378
|
-
|
|
391
|
+
return it((l) => l + 1), () => {
|
|
392
|
+
r.remove(), E.current = null, Se.current = !1, N.current.clear();
|
|
379
393
|
};
|
|
380
|
-
}, [
|
|
394
|
+
}, [T]), G(() => {
|
|
381
395
|
const t = E.current;
|
|
382
396
|
t && t.applyOptions(
|
|
383
|
-
|
|
397
|
+
Le ? {
|
|
384
398
|
handleScale: {
|
|
385
399
|
mouseWheel: !1,
|
|
386
400
|
pinch: !1,
|
|
@@ -408,225 +422,225 @@ function oo({
|
|
|
408
422
|
}
|
|
409
423
|
}
|
|
410
424
|
);
|
|
411
|
-
}, [
|
|
425
|
+
}, [Q, Le]), G(() => {
|
|
412
426
|
const t = E.current;
|
|
413
427
|
!t || !S || t.applyOptions(S);
|
|
414
|
-
}, [
|
|
428
|
+
}, [Q, S]), G(() => {
|
|
415
429
|
const t = E.current;
|
|
416
430
|
if (!t || e.length === 0) return;
|
|
417
|
-
const
|
|
431
|
+
const r = e.filter((n) => n.data.length > 0).length <= 1 ? Ve : ke, l = h === "time" ? Je(h, ce) : Je(h), s = /* @__PURE__ */ new Map();
|
|
418
432
|
{
|
|
419
|
-
let
|
|
433
|
+
let n = 0;
|
|
420
434
|
for (const o of e)
|
|
421
435
|
o.data.length !== 0 && (s.set(
|
|
422
436
|
o.label,
|
|
423
|
-
o.priceScaleId ?? (
|
|
424
|
-
),
|
|
437
|
+
o.priceScaleId ?? (n === 0 ? "left" : "right")
|
|
438
|
+
), n++);
|
|
425
439
|
}
|
|
426
|
-
const
|
|
427
|
-
const { formatter:
|
|
428
|
-
yScaleMin:
|
|
440
|
+
const p = (n, o, g) => {
|
|
441
|
+
const { formatter: L, tickmarksFormatter: k, updateVisibleRange: F } = wt(n, o, {
|
|
442
|
+
yScaleMin: r
|
|
429
443
|
});
|
|
430
|
-
return { formatter:
|
|
431
|
-
},
|
|
432
|
-
if (
|
|
433
|
-
for (const
|
|
434
|
-
const o = /* @__PURE__ */ new Set(),
|
|
435
|
-
let
|
|
436
|
-
for (const
|
|
437
|
-
if (
|
|
438
|
-
o.size === 0 &&
|
|
439
|
-
for (const
|
|
444
|
+
return { formatter: L, tickmarksFormatter: k, updateVisibleRange: F, labels: g };
|
|
445
|
+
}, d = [];
|
|
446
|
+
if (I)
|
|
447
|
+
for (const n of ["left", "right"]) {
|
|
448
|
+
const o = /* @__PURE__ */ new Set(), g = [];
|
|
449
|
+
let L = u;
|
|
450
|
+
for (const k of e)
|
|
451
|
+
if (k.data.length !== 0 && s.get(k.label) === n) {
|
|
452
|
+
o.size === 0 && k.yMeasureUnit && (L = k.yMeasureUnit), o.add(k.label);
|
|
453
|
+
for (const F of k.data) g.push(F.value);
|
|
440
454
|
}
|
|
441
|
-
o.size > 0 &&
|
|
455
|
+
o.size > 0 && d.push(p(g, L, o));
|
|
442
456
|
}
|
|
443
457
|
else {
|
|
444
|
-
const
|
|
445
|
-
e.filter((
|
|
458
|
+
const n = ce.map((g) => g.value), o = new Set(
|
|
459
|
+
e.filter((g) => g.data.length > 0).map((g) => g.label)
|
|
446
460
|
);
|
|
447
|
-
|
|
461
|
+
d.push(p(n, u, o));
|
|
448
462
|
}
|
|
449
|
-
|
|
450
|
-
const
|
|
451
|
-
for (const
|
|
452
|
-
for (const o of
|
|
453
|
-
|
|
454
|
-
const
|
|
463
|
+
De.current = d;
|
|
464
|
+
const y = /* @__PURE__ */ new Map();
|
|
465
|
+
for (const n of d)
|
|
466
|
+
for (const o of n.labels)
|
|
467
|
+
y.set(o, n);
|
|
468
|
+
const x = Ze();
|
|
455
469
|
t.applyOptions({
|
|
456
470
|
localization: {
|
|
457
|
-
...
|
|
471
|
+
...x.localization || {},
|
|
458
472
|
// biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
|
|
459
|
-
timeFormatter: (
|
|
473
|
+
timeFormatter: (n) => (
|
|
460
474
|
// biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
|
|
461
|
-
|
|
475
|
+
l.timeFormatter(parseFloat(n), void 0)
|
|
462
476
|
)
|
|
463
477
|
},
|
|
464
478
|
timeScale: {
|
|
465
|
-
...
|
|
479
|
+
...x.timeScale || {},
|
|
466
480
|
...S?.timeScale,
|
|
467
481
|
// biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
|
|
468
|
-
tickMarkFormatter:
|
|
482
|
+
tickMarkFormatter: l.tickMarkFormatter,
|
|
469
483
|
minBarSpacing: 0
|
|
470
484
|
}
|
|
471
485
|
});
|
|
472
|
-
const v = !
|
|
486
|
+
const v = !I && e.length > 1 && !Z, W = I ? T : e.length > 1 && !Z || T, V = re(
|
|
473
487
|
"hsl(var(--muted-foreground))",
|
|
474
488
|
"rgb(163, 163, 163)"
|
|
475
489
|
);
|
|
476
490
|
t.applyOptions({
|
|
477
|
-
...
|
|
478
|
-
defaultVisiblePriceScaleId:
|
|
491
|
+
...I && {
|
|
492
|
+
defaultVisiblePriceScaleId: Re
|
|
479
493
|
},
|
|
480
494
|
leftPriceScale: {
|
|
481
|
-
...
|
|
495
|
+
...x.leftPriceScale || {},
|
|
482
496
|
...S?.leftPriceScale,
|
|
483
|
-
visible:
|
|
484
|
-
textColor:
|
|
485
|
-
...
|
|
497
|
+
visible: I && !T,
|
|
498
|
+
textColor: V,
|
|
499
|
+
...I && Ne && {
|
|
486
500
|
// lightweight-charts uses scale margins; title shown via localization if needed
|
|
487
501
|
}
|
|
488
502
|
},
|
|
489
503
|
rightPriceScale: {
|
|
490
|
-
...
|
|
504
|
+
...x.rightPriceScale || {},
|
|
491
505
|
...S?.rightPriceScale,
|
|
492
|
-
visible:
|
|
493
|
-
textColor:
|
|
506
|
+
visible: I ? !T : !W,
|
|
507
|
+
textColor: V
|
|
494
508
|
}
|
|
495
509
|
});
|
|
496
|
-
const
|
|
497
|
-
for (const
|
|
498
|
-
if (!X.has(
|
|
499
|
-
const o =
|
|
500
|
-
o && (t.removeSeries(o),
|
|
510
|
+
const Y = new Set(N.current.keys()), X = new Set(e.map(ne));
|
|
511
|
+
for (const n of Y)
|
|
512
|
+
if (!X.has(n)) {
|
|
513
|
+
const o = N.current.get(n);
|
|
514
|
+
o && (t.removeSeries(o), N.current.delete(n));
|
|
501
515
|
}
|
|
502
|
-
const
|
|
516
|
+
const m = Ct(), M = [];
|
|
503
517
|
let R = 0;
|
|
504
|
-
const $ = e.find((
|
|
505
|
-
if (
|
|
506
|
-
for (const
|
|
507
|
-
if (!Number.isFinite(
|
|
508
|
-
const o =
|
|
518
|
+
const $ = e.find((n) => n.data.length > 0), C = /* @__PURE__ */ new Map();
|
|
519
|
+
if (D && D.length > 0)
|
|
520
|
+
for (const n of D) {
|
|
521
|
+
if (!Number.isFinite(n.price)) continue;
|
|
522
|
+
const o = n.seriesLabel ?? $?.label;
|
|
509
523
|
if (!o) continue;
|
|
510
|
-
const
|
|
511
|
-
|
|
524
|
+
const g = C.get(o) ?? [];
|
|
525
|
+
g.push(n.price), C.set(o, g);
|
|
512
526
|
}
|
|
513
|
-
if (
|
|
514
|
-
for (const
|
|
515
|
-
const o =
|
|
527
|
+
if (z && z.length > 0)
|
|
528
|
+
for (const n of z) {
|
|
529
|
+
const o = n.seriesLabel ?? $?.label;
|
|
516
530
|
if (!o) continue;
|
|
517
|
-
const
|
|
518
|
-
Number.isFinite(
|
|
531
|
+
const g = C.get(o) ?? [];
|
|
532
|
+
Number.isFinite(n.priceTop) && g.push(n.priceTop), Number.isFinite(n.priceBottom) && g.push(n.priceBottom), C.set(o, g);
|
|
519
533
|
}
|
|
520
|
-
for (let
|
|
521
|
-
const o = e[
|
|
522
|
-
let
|
|
534
|
+
for (let n = 0; n < e.length; n++) {
|
|
535
|
+
const o = e[n], g = ne(o), L = Ue(n), k = o.lineColor ?? o.color ?? L.line;
|
|
536
|
+
let F, q;
|
|
523
537
|
if (o.lineColor ?? o.color)
|
|
524
538
|
if (o.topColor && o.bottomColor)
|
|
525
|
-
|
|
539
|
+
F = o.topColor, q = o.bottomColor;
|
|
526
540
|
else if (o.topColor) {
|
|
527
|
-
const b =
|
|
528
|
-
|
|
541
|
+
const b = de(k);
|
|
542
|
+
F = o.topColor, q = b.bottomColor;
|
|
529
543
|
} else if (o.bottomColor)
|
|
530
|
-
|
|
544
|
+
F = de(k).topColor, q = o.bottomColor;
|
|
531
545
|
else {
|
|
532
|
-
const b =
|
|
533
|
-
|
|
546
|
+
const b = de(k);
|
|
547
|
+
F = b.topColor, q = b.bottomColor;
|
|
534
548
|
}
|
|
535
549
|
else
|
|
536
|
-
|
|
550
|
+
F = o.topColor || L.top, q = o.bottomColor || L.bottom;
|
|
537
551
|
if (o.data.length === 0) {
|
|
538
|
-
const b =
|
|
539
|
-
b && (t.removeSeries(b),
|
|
552
|
+
const b = N.current.get(g);
|
|
553
|
+
b && (t.removeSeries(b), N.current.delete(g));
|
|
540
554
|
continue;
|
|
541
555
|
}
|
|
542
|
-
const
|
|
556
|
+
const ue = o.data.length > 0 ? Math.min(...o.data.map((b) => b.value)) : 0, he = o.data.length > 0 ? Math.max(...o.data.map((b) => b.value)) : 0, lt = ue < 0, at = o.data.some((b) => b.value === 0), st = !lt && at, Xe = Nt(he - ue), $e = I ? o.priceScaleId ?? (R === 0 ? "left" : "right") : Z || !v || R === 0 ? "right" : `scale-${R}`;
|
|
543
557
|
v && M.push({
|
|
544
|
-
priceScaleId:
|
|
558
|
+
priceScaleId: $e || "right",
|
|
545
559
|
seriesIndex: R
|
|
546
560
|
});
|
|
547
|
-
const
|
|
561
|
+
const ye = (Z || !v) && r !== void 0 && typeof r == "number", ct = C.get(o.label) ?? [], ut = (b) => {
|
|
548
562
|
const _ = b();
|
|
549
563
|
if (_?.priceRange) {
|
|
550
|
-
|
|
564
|
+
ye && (_.priceRange.minValue = r);
|
|
551
565
|
for (const j of ct)
|
|
552
566
|
j < _.priceRange.minValue && (_.priceRange.minValue = j), j > _.priceRange.maxValue && (_.priceRange.maxValue = j);
|
|
553
|
-
const
|
|
554
|
-
if (
|
|
567
|
+
const te = ye ? r : st && _.priceRange.minValue >= 0 ? 0 : void 0, ge = se.current > 0 ? se.current : B.current?.clientHeight ?? 0;
|
|
568
|
+
if (ge > 0) {
|
|
555
569
|
const j = Vt({
|
|
556
570
|
min: _.priceRange.minValue,
|
|
557
571
|
max: _.priceRange.maxValue,
|
|
558
|
-
floor:
|
|
559
|
-
scaleHeightPx:
|
|
572
|
+
floor: te,
|
|
573
|
+
scaleHeightPx: ge,
|
|
560
574
|
fontSizePx: xt,
|
|
561
|
-
tickMarkDensity:
|
|
562
|
-
minMove:
|
|
563
|
-
edgePaddingPx:
|
|
564
|
-
edgePaddingTopPx:
|
|
575
|
+
tickMarkDensity: pe,
|
|
576
|
+
minMove: Xe,
|
|
577
|
+
edgePaddingPx: qe,
|
|
578
|
+
edgePaddingTopPx: Oe
|
|
565
579
|
});
|
|
566
580
|
_.priceRange.minValue = j.min, _.priceRange.maxValue = j.max;
|
|
567
581
|
}
|
|
568
582
|
_.margins = {
|
|
569
|
-
above:
|
|
570
|
-
below:
|
|
583
|
+
above: Oe,
|
|
584
|
+
below: qe
|
|
571
585
|
};
|
|
572
586
|
}
|
|
573
587
|
return _;
|
|
574
|
-
},
|
|
575
|
-
lineColor:
|
|
576
|
-
topColor:
|
|
577
|
-
bottomColor:
|
|
578
|
-
priceScaleId:
|
|
588
|
+
}, He = y.get(o.label) ?? d[0], je = He.formatter, ft = He.tickmarksFormatter, xe = {
|
|
589
|
+
lineColor: k,
|
|
590
|
+
topColor: F,
|
|
591
|
+
bottomColor: q,
|
|
592
|
+
priceScaleId: $e,
|
|
579
593
|
...o.seriesType === "line" && {
|
|
580
|
-
lineStyle: o.lineStyle ??
|
|
594
|
+
lineStyle: o.lineStyle ?? ie.Solid
|
|
581
595
|
},
|
|
582
596
|
priceFormat: {
|
|
583
597
|
type: "custom",
|
|
584
|
-
minMove:
|
|
585
|
-
formatter:
|
|
586
|
-
b <
|
|
587
|
-
) :
|
|
598
|
+
minMove: Xe,
|
|
599
|
+
formatter: ye && typeof r == "number" ? (b) => je(
|
|
600
|
+
b < r ? r : b
|
|
601
|
+
) : je,
|
|
588
602
|
tickmarksFormatter: ft
|
|
589
603
|
},
|
|
590
604
|
autoscaleInfoProvider: ut
|
|
591
|
-
},
|
|
592
|
-
let A =
|
|
593
|
-
const
|
|
605
|
+
}, Ke = o.seriesType === "line";
|
|
606
|
+
let A = N.current.get(g);
|
|
607
|
+
const ee = o.data.map((b) => ({
|
|
594
608
|
...b,
|
|
595
609
|
time: b.time
|
|
596
610
|
}));
|
|
597
|
-
if (
|
|
598
|
-
const b = Number(
|
|
599
|
-
for (let
|
|
600
|
-
j.push({ time:
|
|
601
|
-
|
|
611
|
+
if (ae !== void 0 && ee.length > 0 && Number(ee[0].time) > ae) {
|
|
612
|
+
const b = Number(ee[0].time), _ = b - ae, te = 86400, ge = _ > 180 * te ? 7 * te : _ > 30 * te ? te : 6 * 3600, j = [];
|
|
613
|
+
for (let _e = ae; _e < b; _e += ge)
|
|
614
|
+
j.push({ time: _e });
|
|
615
|
+
ee.unshift(...j);
|
|
602
616
|
}
|
|
603
|
-
A && A.seriesType() !== (
|
|
604
|
-
...
|
|
605
|
-
...
|
|
606
|
-
}) : A = t.addSeries(
|
|
607
|
-
...
|
|
608
|
-
...
|
|
609
|
-
}), A.setData(
|
|
617
|
+
A && A.seriesType() !== (Ke ? "Line" : "Area") && (t.removeSeries(A), N.current.delete(g), A = void 0), A ? (A.applyOptions(xe), A.setData(ee)) : (Ke ? A = t.addSeries(pt, {
|
|
618
|
+
...m,
|
|
619
|
+
...xe
|
|
620
|
+
}) : A = t.addSeries(dt, {
|
|
621
|
+
...m,
|
|
622
|
+
...xe
|
|
623
|
+
}), A.setData(ee), N.current.set(g, A)), R++;
|
|
610
624
|
}
|
|
611
|
-
if (
|
|
625
|
+
if (I)
|
|
612
626
|
try {
|
|
613
|
-
const
|
|
614
|
-
visible: !
|
|
627
|
+
const n = t.priceScale("left"), o = t.priceScale("right"), g = {
|
|
628
|
+
visible: !T,
|
|
615
629
|
autoScale: !0,
|
|
616
630
|
scaleMargins: { top: 0, bottom: 0 },
|
|
617
631
|
alignLabels: !0,
|
|
618
632
|
entireTextOnly: !1,
|
|
619
|
-
tickMarkDensity:
|
|
620
|
-
textColor:
|
|
633
|
+
tickMarkDensity: pe,
|
|
634
|
+
textColor: V,
|
|
621
635
|
...S?.rightPriceScale
|
|
622
636
|
};
|
|
623
|
-
|
|
637
|
+
n?.applyOptions(g), o?.applyOptions(g);
|
|
624
638
|
} catch {
|
|
625
639
|
}
|
|
626
640
|
else if (v && M.length > 0)
|
|
627
|
-
for (const
|
|
641
|
+
for (const n of M)
|
|
628
642
|
try {
|
|
629
|
-
const o = t.priceScale(
|
|
643
|
+
const o = t.priceScale(n.priceScaleId);
|
|
630
644
|
o && o.applyOptions({
|
|
631
645
|
visible: !1,
|
|
632
646
|
autoScale: !0,
|
|
@@ -636,20 +650,20 @@ function oo({
|
|
|
636
650
|
},
|
|
637
651
|
alignLabels: !0,
|
|
638
652
|
entireTextOnly: !1,
|
|
639
|
-
tickMarkDensity:
|
|
640
|
-
textColor:
|
|
653
|
+
tickMarkDensity: pe,
|
|
654
|
+
textColor: V
|
|
641
655
|
});
|
|
642
656
|
} catch (o) {
|
|
643
657
|
console.warn(
|
|
644
|
-
`Failed to configure price scale ${
|
|
658
|
+
`Failed to configure price scale ${n.priceScaleId} for series ${n.seriesIndex}:`,
|
|
645
659
|
o
|
|
646
660
|
);
|
|
647
661
|
}
|
|
648
662
|
else if (!v)
|
|
649
663
|
try {
|
|
650
|
-
const
|
|
651
|
-
|
|
652
|
-
visible: !
|
|
664
|
+
const n = t.priceScale("right");
|
|
665
|
+
n && n.applyOptions({
|
|
666
|
+
visible: !T,
|
|
653
667
|
autoScale: !0,
|
|
654
668
|
scaleMargins: {
|
|
655
669
|
top: 0,
|
|
@@ -657,313 +671,308 @@ function oo({
|
|
|
657
671
|
},
|
|
658
672
|
alignLabels: !0,
|
|
659
673
|
entireTextOnly: !1,
|
|
660
|
-
tickMarkDensity:
|
|
661
|
-
textColor:
|
|
674
|
+
tickMarkDensity: pe,
|
|
675
|
+
textColor: V,
|
|
662
676
|
...S?.rightPriceScale
|
|
663
677
|
});
|
|
664
678
|
} catch {
|
|
665
679
|
}
|
|
666
|
-
if (
|
|
680
|
+
if (r !== void 0 && !T && (Z || !v) && t.applyOptions({
|
|
667
681
|
handleScroll: {
|
|
668
682
|
vertTouchDrag: !1
|
|
669
683
|
}
|
|
670
|
-
}),
|
|
671
|
-
const
|
|
672
|
-
if (
|
|
673
|
-
const
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
};
|
|
684
|
+
}), ce.length > 0) {
|
|
685
|
+
const n = ce.map((g) => Number(g.time)).filter((g) => Number.isFinite(g)), o = new Set(n).size - 1;
|
|
686
|
+
if (o >= 0) {
|
|
687
|
+
const g = () => {
|
|
688
|
+
const L = t.timeScale();
|
|
689
|
+
if (h !== "time") {
|
|
690
|
+
L.applyOptions({
|
|
691
|
+
fixLeftEdge: !0,
|
|
692
|
+
fixRightEdge: !0
|
|
693
|
+
}), L.setVisibleLogicalRange({ from: 0, to: o });
|
|
694
|
+
return;
|
|
695
|
+
}
|
|
696
|
+
const k = I && !T, F = I ? !T : !W, q = !k, ue = !F;
|
|
697
|
+
L.applyOptions({
|
|
698
|
+
fixLeftEdge: !q,
|
|
699
|
+
fixRightEdge: !ue
|
|
700
|
+
});
|
|
701
|
+
const he = kt({
|
|
702
|
+
lastIndex: o,
|
|
703
|
+
width: L.width(),
|
|
704
|
+
padLeft: q,
|
|
705
|
+
padRight: ue
|
|
706
|
+
});
|
|
707
|
+
he && L.setVisibleLogicalRange(he);
|
|
708
|
+
};
|
|
709
|
+
try {
|
|
710
|
+
g();
|
|
711
|
+
} catch {
|
|
699
712
|
try {
|
|
700
|
-
t.timeScale().
|
|
713
|
+
t.timeScale().fitContent(), g();
|
|
701
714
|
} catch {
|
|
702
|
-
try {
|
|
703
|
-
t.timeScale().fitContent(), T();
|
|
704
|
-
} catch {
|
|
705
|
-
}
|
|
706
715
|
}
|
|
707
716
|
}
|
|
708
717
|
}
|
|
709
718
|
}
|
|
710
|
-
|
|
719
|
+
Me.current && (Me.current = !1), S && t.applyOptions(S);
|
|
711
720
|
const H = /* @__PURE__ */ new Map();
|
|
712
|
-
for (const
|
|
713
|
-
|
|
714
|
-
|
|
721
|
+
for (const n of e)
|
|
722
|
+
n.data.length > 0 && H.set(n.label, n.data[n.data.length - 1]);
|
|
723
|
+
Ce(H.size > 0 ? H : void 0);
|
|
715
724
|
}, [
|
|
716
|
-
|
|
725
|
+
Q,
|
|
717
726
|
e,
|
|
718
|
-
|
|
727
|
+
ce,
|
|
719
728
|
h,
|
|
720
|
-
|
|
721
|
-
|
|
729
|
+
u,
|
|
730
|
+
T,
|
|
722
731
|
Z,
|
|
723
|
-
D,
|
|
724
|
-
Me,
|
|
725
|
-
Ie,
|
|
726
|
-
De,
|
|
727
|
-
Ee,
|
|
728
|
-
Y,
|
|
729
732
|
I,
|
|
730
|
-
|
|
733
|
+
Re,
|
|
734
|
+
Ne,
|
|
735
|
+
Ve,
|
|
736
|
+
ke,
|
|
737
|
+
ae,
|
|
738
|
+
D,
|
|
739
|
+
z,
|
|
731
740
|
S
|
|
732
741
|
]), G(() => {
|
|
733
742
|
const t = E.current;
|
|
734
743
|
if (!t || e.length === 0) return;
|
|
735
|
-
const
|
|
736
|
-
let
|
|
744
|
+
const a = e.length === 1;
|
|
745
|
+
let r;
|
|
737
746
|
for (const s of e)
|
|
738
747
|
if (s.data.length > 0) {
|
|
739
|
-
|
|
748
|
+
r = s.data[s.data.length - 1].time;
|
|
740
749
|
break;
|
|
741
750
|
}
|
|
742
|
-
if (!
|
|
743
|
-
const
|
|
744
|
-
const { time:
|
|
745
|
-
if (!
|
|
751
|
+
if (!r) return;
|
|
752
|
+
const l = (s) => {
|
|
753
|
+
const { time: p = r, seriesData: d, point: y } = s || {}, x = e[0], v = x ? N.current.get(ne(x)) : void 0;
|
|
754
|
+
if (!y || !p) {
|
|
746
755
|
const X = /* @__PURE__ */ new Map();
|
|
747
|
-
for (const
|
|
748
|
-
|
|
749
|
-
if (
|
|
756
|
+
for (const m of e)
|
|
757
|
+
m.data.length > 0 && X.set(m.label, m.data[m.data.length - 1]);
|
|
758
|
+
if (Ce(X.size > 0 ? X : void 0), a || Z || be)
|
|
750
759
|
J(null);
|
|
751
|
-
else if (v &&
|
|
752
|
-
const
|
|
753
|
-
if (
|
|
754
|
-
const R = t.timeScale().timeToCoordinate(
|
|
760
|
+
else if (v && r) {
|
|
761
|
+
const m = e[0];
|
|
762
|
+
if (m && m.data.length > 0) {
|
|
763
|
+
const R = t.timeScale().timeToCoordinate(r), $ = m.data[m.data.length - 1].value, C = v.priceToCoordinate($);
|
|
755
764
|
R !== null && C !== null && J({ x: R, y: C });
|
|
756
765
|
}
|
|
757
766
|
}
|
|
758
767
|
return;
|
|
759
768
|
}
|
|
760
769
|
const W = /* @__PURE__ */ new Map();
|
|
761
|
-
let
|
|
770
|
+
let V, Y = v;
|
|
762
771
|
for (let X = 0; X < e.length; X++) {
|
|
763
|
-
const
|
|
772
|
+
const m = e[X], M = N.current.get(ne(m));
|
|
764
773
|
if (!M) continue;
|
|
765
|
-
const R =
|
|
774
|
+
const R = d?.get(M), $ = R && "value" in R ? R.value : void 0;
|
|
766
775
|
let C;
|
|
767
776
|
if ($ !== void 0)
|
|
768
777
|
C = $;
|
|
769
|
-
else if (
|
|
770
|
-
const H = Number(
|
|
771
|
-
H <
|
|
778
|
+
else if (a) {
|
|
779
|
+
const H = Number(p), n = m.data.length > 0 ? Number(m.data[0].time) : Number.POSITIVE_INFINITY;
|
|
780
|
+
H < n ? C = Number.NaN : C = m.data[m.data.length - 1]?.value ?? 0;
|
|
772
781
|
} else {
|
|
773
|
-
const H =
|
|
774
|
-
if (Number(
|
|
775
|
-
C =
|
|
782
|
+
const H = m.data.length > 0 ? Number(m.data[0].time) : Number.POSITIVE_INFINITY;
|
|
783
|
+
if (Number(p) < H) continue;
|
|
784
|
+
C = Gt(m.data, Number(p));
|
|
776
785
|
}
|
|
777
|
-
Number.isNaN(C) || (
|
|
786
|
+
Number.isNaN(C) || (V === void 0 && (V = C, Y = M), W.set(m.label, { value: C, time: p }));
|
|
778
787
|
}
|
|
779
|
-
if (
|
|
780
|
-
const
|
|
781
|
-
if (
|
|
788
|
+
if (Ce(W), V !== void 0 && Y) {
|
|
789
|
+
const m = t.timeScale().timeToCoordinate(p), M = Y.priceToCoordinate(V);
|
|
790
|
+
if (m !== null && M !== null) {
|
|
782
791
|
const R = B.current;
|
|
783
792
|
if (R) {
|
|
784
793
|
const $ = R.querySelector(
|
|
785
794
|
".LightweightChart"
|
|
786
795
|
);
|
|
787
796
|
if ($) {
|
|
788
|
-
const C = $.getBoundingClientRect(), H = R.getBoundingClientRect(),
|
|
789
|
-
J({ x:
|
|
797
|
+
const C = $.getBoundingClientRect(), H = R.getBoundingClientRect(), n = m + (C.left - H.left), o = M + (C.top - H.top);
|
|
798
|
+
J({ x: n, y: o });
|
|
790
799
|
} else
|
|
791
|
-
J({ x:
|
|
800
|
+
J({ x: m, y: M });
|
|
792
801
|
} else
|
|
793
|
-
J({ x:
|
|
802
|
+
J({ x: m, y: M });
|
|
794
803
|
} else
|
|
795
804
|
J(null);
|
|
796
805
|
} else
|
|
797
806
|
J(null);
|
|
798
807
|
};
|
|
799
|
-
return t.subscribeCrosshairMove(
|
|
800
|
-
const s = e[0],
|
|
801
|
-
if (
|
|
802
|
-
const
|
|
803
|
-
|
|
808
|
+
return t.subscribeCrosshairMove(l), T && t.subscribeClick(l), !a && !Z && !be && requestAnimationFrame(() => {
|
|
809
|
+
const s = e[0], p = s ? N.current.get(ne(s)) : void 0;
|
|
810
|
+
if (p && r && s.data.length > 0) {
|
|
811
|
+
const y = t.timeScale().timeToCoordinate(r), x = s.data[s.data.length - 1].value, v = p.priceToCoordinate(x);
|
|
812
|
+
y !== null && v !== null && J({ x: y, y: v });
|
|
804
813
|
}
|
|
805
814
|
}), () => {
|
|
806
|
-
t.unsubscribeCrosshairMove(
|
|
815
|
+
t.unsubscribeCrosshairMove(l), T && t.unsubscribeClick(l);
|
|
807
816
|
};
|
|
808
|
-
}, [e, Z,
|
|
817
|
+
}, [e, Z, T, be]), G(() => {
|
|
809
818
|
const t = E.current;
|
|
810
819
|
if (!t || e.length === 0) return;
|
|
811
|
-
const
|
|
812
|
-
const
|
|
813
|
-
if (
|
|
814
|
-
const s =
|
|
820
|
+
const a = t.timeScale(), r = () => {
|
|
821
|
+
const l = De.current;
|
|
822
|
+
if (l.length === 0) return;
|
|
823
|
+
const s = a.getVisibleRange();
|
|
815
824
|
if (!s) return;
|
|
816
|
-
const
|
|
817
|
-
for (const
|
|
818
|
-
const
|
|
825
|
+
const p = Number(s.from), d = Number(s.to);
|
|
826
|
+
for (const y of l) {
|
|
827
|
+
const x = [];
|
|
819
828
|
for (const v of e)
|
|
820
|
-
if (
|
|
829
|
+
if (y.labels.has(v.label))
|
|
821
830
|
for (const W of v.data) {
|
|
822
|
-
const
|
|
823
|
-
|
|
831
|
+
const V = Number(W.time);
|
|
832
|
+
V >= p && V <= d && x.push(W.value);
|
|
824
833
|
}
|
|
825
|
-
|
|
834
|
+
x.length > 0 && y.updateVisibleRange(x);
|
|
826
835
|
}
|
|
827
836
|
};
|
|
828
|
-
return
|
|
829
|
-
|
|
830
|
-
|
|
837
|
+
return a.subscribeVisibleLogicalRangeChange(r), () => {
|
|
838
|
+
a.unsubscribeVisibleLogicalRangeChange(
|
|
839
|
+
r
|
|
831
840
|
);
|
|
832
841
|
};
|
|
833
842
|
}, [e]), G(() => {
|
|
834
|
-
const t = E.current,
|
|
835
|
-
if (t &&
|
|
836
|
-
const
|
|
837
|
-
for (const
|
|
838
|
-
const
|
|
839
|
-
...
|
|
840
|
-
...
|
|
843
|
+
const t = E.current, a = Array.from(N.current.values()), r = [];
|
|
844
|
+
if (t && a.length > 0 && P) {
|
|
845
|
+
const l = yt(), s = a[0];
|
|
846
|
+
for (const p of P) {
|
|
847
|
+
const d = {
|
|
848
|
+
...l,
|
|
849
|
+
...p.options || {}
|
|
841
850
|
};
|
|
842
|
-
|
|
843
|
-
const
|
|
844
|
-
s.attachPrimitive(
|
|
851
|
+
d.color && (d.color = re(d.color, d.color));
|
|
852
|
+
const y = new Rt(t, s, p.xCoordinate, d);
|
|
853
|
+
s.attachPrimitive(y), r.push(y);
|
|
845
854
|
}
|
|
846
855
|
}
|
|
847
856
|
return () => {
|
|
848
|
-
if (
|
|
849
|
-
const
|
|
850
|
-
for (const s of
|
|
857
|
+
if (a.length > 0) {
|
|
858
|
+
const l = a[0];
|
|
859
|
+
for (const s of r)
|
|
851
860
|
try {
|
|
852
|
-
|
|
861
|
+
l.detachPrimitive(s);
|
|
853
862
|
} catch {
|
|
854
863
|
}
|
|
855
864
|
}
|
|
856
865
|
};
|
|
857
|
-
}, [P, e,
|
|
858
|
-
const t = [],
|
|
859
|
-
if (
|
|
860
|
-
const
|
|
866
|
+
}, [P, e, Q]), G(() => {
|
|
867
|
+
const t = [], a = [];
|
|
868
|
+
if (D && D.length > 0) {
|
|
869
|
+
const r = re(
|
|
861
870
|
"hsl(var(--destructive))",
|
|
862
871
|
"rgb(239, 68, 68)"
|
|
863
872
|
);
|
|
864
|
-
for (const
|
|
865
|
-
if (!Number.isFinite(
|
|
866
|
-
const s =
|
|
867
|
-
|
|
873
|
+
for (const l of D) {
|
|
874
|
+
if (!Number.isFinite(l.price)) continue;
|
|
875
|
+
const s = Qe(
|
|
876
|
+
N.current,
|
|
868
877
|
e,
|
|
869
|
-
|
|
878
|
+
l.seriesLabel
|
|
870
879
|
);
|
|
871
880
|
if (!s) continue;
|
|
872
|
-
const
|
|
873
|
-
price:
|
|
874
|
-
color:
|
|
875
|
-
lineWidth:
|
|
876
|
-
lineStyle:
|
|
877
|
-
axisLabelVisible:
|
|
878
|
-
title:
|
|
881
|
+
const p = l.color ? re(l.color, l.color) : r, d = l.lineWidth ?? 1, y = l.lineStyle ?? ie.Dashed, x = s.createPriceLine({
|
|
882
|
+
price: l.price,
|
|
883
|
+
color: p,
|
|
884
|
+
lineWidth: d,
|
|
885
|
+
lineStyle: y,
|
|
886
|
+
axisLabelVisible: l.axisLabelVisible ?? !0,
|
|
887
|
+
title: l.title ?? ""
|
|
879
888
|
});
|
|
880
|
-
t.push({ series: s, line:
|
|
881
|
-
const v = new
|
|
889
|
+
t.push({ series: s, line: x });
|
|
890
|
+
const v = new Ft(
|
|
882
891
|
s,
|
|
883
|
-
|
|
892
|
+
l.price,
|
|
893
|
+
p,
|
|
884
894
|
d,
|
|
885
|
-
|
|
886
|
-
x
|
|
895
|
+
y
|
|
887
896
|
);
|
|
888
|
-
s.attachPrimitive(v),
|
|
897
|
+
s.attachPrimitive(v), a.push({ series: s, primitive: v });
|
|
889
898
|
}
|
|
890
899
|
}
|
|
891
900
|
return () => {
|
|
892
|
-
for (const { series:
|
|
901
|
+
for (const { series: r, primitive: l } of a)
|
|
893
902
|
try {
|
|
894
|
-
|
|
903
|
+
r.detachPrimitive(l);
|
|
895
904
|
} catch {
|
|
896
905
|
}
|
|
897
|
-
for (const { series:
|
|
906
|
+
for (const { series: r, line: l } of t)
|
|
898
907
|
try {
|
|
899
|
-
|
|
908
|
+
r.removePriceLine(l);
|
|
900
909
|
} catch {
|
|
901
910
|
}
|
|
902
911
|
};
|
|
903
|
-
}, [
|
|
912
|
+
}, [D, e, Q]), G(() => {
|
|
904
913
|
const t = [];
|
|
905
|
-
if (
|
|
906
|
-
const
|
|
907
|
-
for (const
|
|
908
|
-
const
|
|
909
|
-
|
|
914
|
+
if (z && z.length > 0) {
|
|
915
|
+
const a = "rgba(239, 68, 68, 0.12)";
|
|
916
|
+
for (const r of z) {
|
|
917
|
+
const l = Qe(
|
|
918
|
+
N.current,
|
|
910
919
|
e,
|
|
911
|
-
|
|
920
|
+
r.seriesLabel
|
|
912
921
|
);
|
|
913
|
-
if (!
|
|
914
|
-
const s =
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
922
|
+
if (!l) continue;
|
|
923
|
+
const s = r.color ? re(r.color, a) : a, p = new Dt(
|
|
924
|
+
l,
|
|
925
|
+
r.priceTop,
|
|
926
|
+
r.priceBottom,
|
|
918
927
|
s
|
|
919
928
|
);
|
|
920
|
-
|
|
929
|
+
l.attachPrimitive(p), t.push({ series: l, zone: p });
|
|
921
930
|
}
|
|
922
931
|
}
|
|
923
932
|
return () => {
|
|
924
|
-
for (const { series:
|
|
933
|
+
for (const { series: a, zone: r } of t)
|
|
925
934
|
try {
|
|
926
|
-
|
|
935
|
+
a.detachPrimitive(r);
|
|
927
936
|
} catch {
|
|
928
937
|
}
|
|
929
938
|
};
|
|
930
|
-
}, [
|
|
939
|
+
}, [z, e, Q]), G(() => {
|
|
931
940
|
const t = E.current;
|
|
932
941
|
if (!t || !P?.length) {
|
|
933
|
-
|
|
942
|
+
ze([]);
|
|
934
943
|
return;
|
|
935
944
|
}
|
|
936
|
-
const
|
|
937
|
-
const s = t.timeScale(),
|
|
938
|
-
|
|
945
|
+
const a = () => {
|
|
946
|
+
const s = t.timeScale(), p = P.map((d) => s.timeToCoordinate(d.xCoordinate) ?? null);
|
|
947
|
+
ze(p), B.current && Ae(B.current.clientWidth);
|
|
939
948
|
};
|
|
940
|
-
|
|
941
|
-
const
|
|
942
|
-
|
|
949
|
+
a();
|
|
950
|
+
const r = t.timeScale(), l = () => {
|
|
951
|
+
a();
|
|
943
952
|
};
|
|
944
|
-
return
|
|
945
|
-
|
|
953
|
+
return r.subscribeVisibleLogicalRangeChange(l), () => {
|
|
954
|
+
r.unsubscribeVisibleLogicalRangeChange(l);
|
|
946
955
|
};
|
|
947
|
-
}, [P, e,
|
|
948
|
-
|
|
949
|
-
const
|
|
950
|
-
let
|
|
951
|
-
for (const [
|
|
956
|
+
}, [P, e, Q]), mt(() => {
|
|
957
|
+
nt((t) => {
|
|
958
|
+
const a = {};
|
|
959
|
+
let r = !1;
|
|
960
|
+
for (const [l, s] of Ge.current) {
|
|
952
961
|
if (!s) continue;
|
|
953
|
-
const
|
|
954
|
-
l
|
|
962
|
+
const p = s.offsetWidth;
|
|
963
|
+
a[l] = p, t[l] !== p && (r = !0);
|
|
955
964
|
}
|
|
956
|
-
return Object.keys(t).length !== Object.keys(
|
|
965
|
+
return Object.keys(t).length !== Object.keys(a).length && (r = !0), r ? a : t;
|
|
957
966
|
});
|
|
958
967
|
});
|
|
959
|
-
const
|
|
960
|
-
if (
|
|
968
|
+
const fe = e.length === 1, We = we.useMemo(() => {
|
|
969
|
+
if (fe && e.length > 0) {
|
|
961
970
|
const t = e[0];
|
|
962
971
|
if (t.data.length > 0)
|
|
963
972
|
return t.data[t.data.length - 1];
|
|
964
973
|
}
|
|
965
|
-
}, [
|
|
966
|
-
return /* @__PURE__ */
|
|
974
|
+
}, [fe, e]);
|
|
975
|
+
return /* @__PURE__ */ U(
|
|
967
976
|
"div",
|
|
968
977
|
{
|
|
969
978
|
ref: B,
|
|
@@ -972,71 +981,71 @@ function oo({
|
|
|
972
981
|
i
|
|
973
982
|
),
|
|
974
983
|
children: [
|
|
975
|
-
|
|
984
|
+
me != null && me !== !1 && fe ? /* @__PURE__ */ w("div", { className: "absolute top-2 left-2 right-2 z-[100] pointer-events-none", children: /* @__PURE__ */ w("div", { className: "text-xl sm:text-2xl font-semibold text-foreground whitespace-nowrap overflow-hidden text-ellipsis", children: me }) }) : et && fe && We && /* @__PURE__ */ w(
|
|
976
985
|
Pt,
|
|
977
986
|
{
|
|
978
|
-
point:
|
|
987
|
+
point: We,
|
|
979
988
|
xMeasureUnit: h,
|
|
980
|
-
yMeasureUnit:
|
|
981
|
-
decimals:
|
|
989
|
+
yMeasureUnit: u,
|
|
990
|
+
decimals: le
|
|
982
991
|
}
|
|
983
992
|
),
|
|
984
|
-
|
|
985
|
-
|
|
993
|
+
Ee && Be && /* @__PURE__ */ w(
|
|
994
|
+
Tt,
|
|
986
995
|
{
|
|
987
|
-
points:
|
|
996
|
+
points: Ee,
|
|
988
997
|
xMeasureUnit: h,
|
|
989
|
-
yMeasureUnit:
|
|
998
|
+
yMeasureUnit: u,
|
|
990
999
|
series: e,
|
|
991
|
-
position:
|
|
1000
|
+
position: Be,
|
|
992
1001
|
containerRef: B,
|
|
993
|
-
decimals:
|
|
1002
|
+
decimals: le
|
|
994
1003
|
}
|
|
995
1004
|
),
|
|
996
|
-
c && /* @__PURE__ */ w(
|
|
997
|
-
P && P.length > 0 &&
|
|
1005
|
+
c && /* @__PURE__ */ w(Xt, { series: e, onUnselect: f }),
|
|
1006
|
+
P && P.length > 0 && Fe.length === P.length && /* @__PURE__ */ w(
|
|
998
1007
|
"div",
|
|
999
1008
|
{
|
|
1000
1009
|
className: "absolute inset-0 z-[5] pointer-events-none",
|
|
1001
1010
|
"aria-hidden": !0,
|
|
1002
|
-
children: P.map((t,
|
|
1003
|
-
const
|
|
1004
|
-
if (
|
|
1005
|
-
const { labelText: s, valueStr:
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
),
|
|
1010
|
-
if (!(s ||
|
|
1011
|
-
const
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1011
|
+
children: P.map((t, a) => {
|
|
1012
|
+
const r = Fe[a], l = t.options ?? {};
|
|
1013
|
+
if (r === null) return null;
|
|
1014
|
+
const { labelText: s, valueStr: p } = zt(
|
|
1015
|
+
l,
|
|
1016
|
+
u,
|
|
1017
|
+
le
|
|
1018
|
+
), d = l.tooltipText ?? "";
|
|
1019
|
+
if (!(s || p || d)) return null;
|
|
1020
|
+
const x = l.labelBackgroundColor ?? l.color ?? "hsl(var(--background))", v = l.labelTextColor ?? "hsl(var(--foreground))", W = `${String(t.xCoordinate)}-${s}-${d}`, V = At(
|
|
1021
|
+
r,
|
|
1022
|
+
ot,
|
|
1023
|
+
rt[a]
|
|
1015
1024
|
);
|
|
1016
|
-
return /* @__PURE__ */
|
|
1025
|
+
return /* @__PURE__ */ U(
|
|
1017
1026
|
"div",
|
|
1018
1027
|
{
|
|
1019
|
-
ref: (
|
|
1020
|
-
|
|
1028
|
+
ref: (Y) => {
|
|
1029
|
+
Ge.current.set(a, Y);
|
|
1021
1030
|
},
|
|
1022
1031
|
className: O(
|
|
1023
1032
|
"group absolute top-2 px-2 py-1 rounded text-xs font-medium whitespace-nowrap shadow-sm border border-border",
|
|
1024
|
-
|
|
1033
|
+
d && "pointer-events-auto cursor-default"
|
|
1025
1034
|
),
|
|
1026
1035
|
style: {
|
|
1027
|
-
...
|
|
1028
|
-
backgroundColor:
|
|
1036
|
+
...V,
|
|
1037
|
+
backgroundColor: x,
|
|
1029
1038
|
color: v
|
|
1030
1039
|
},
|
|
1031
1040
|
children: [
|
|
1032
1041
|
s && /* @__PURE__ */ w("span", { className: "block", children: s }),
|
|
1033
|
-
|
|
1034
|
-
|
|
1042
|
+
p && /* @__PURE__ */ w("span", { className: O("block", s && "mt-0.5"), children: p }),
|
|
1043
|
+
d && /* @__PURE__ */ w(
|
|
1035
1044
|
"span",
|
|
1036
1045
|
{
|
|
1037
1046
|
className: "pointer-events-none absolute right-0 top-full z-10 mt-1 hidden w-[280px] whitespace-normal rounded border border-border bg-popover px-2.5 py-1.5 text-left leading-snug text-popover-foreground shadow-md group-hover:block",
|
|
1038
1047
|
role: "tooltip",
|
|
1039
|
-
children:
|
|
1048
|
+
children: d
|
|
1040
1049
|
}
|
|
1041
1050
|
)
|
|
1042
1051
|
]
|
|
@@ -1049,7 +1058,7 @@ function oo({
|
|
|
1049
1058
|
/* @__PURE__ */ w(
|
|
1050
1059
|
"div",
|
|
1051
1060
|
{
|
|
1052
|
-
ref:
|
|
1061
|
+
ref: ve,
|
|
1053
1062
|
className: "LightweightChart w-full h-full overflow-hidden"
|
|
1054
1063
|
}
|
|
1055
1064
|
)
|
|
@@ -1057,30 +1066,30 @@ function oo({
|
|
|
1057
1066
|
}
|
|
1058
1067
|
);
|
|
1059
1068
|
}
|
|
1060
|
-
function
|
|
1069
|
+
function Xt({
|
|
1061
1070
|
series: e,
|
|
1062
1071
|
markers: i,
|
|
1063
1072
|
onUnselect: c,
|
|
1064
|
-
inline:
|
|
1073
|
+
inline: f = !1
|
|
1065
1074
|
}) {
|
|
1066
|
-
const h = e.every((
|
|
1067
|
-
return /* @__PURE__ */
|
|
1075
|
+
const h = e.every((u) => u.data.length === 0);
|
|
1076
|
+
return /* @__PURE__ */ U(
|
|
1068
1077
|
"div",
|
|
1069
1078
|
{
|
|
1070
1079
|
className: O(
|
|
1071
1080
|
"flex flex-wrap",
|
|
1072
|
-
|
|
1081
|
+
f ? "items-center justify-center gap-6" : "absolute top-0 left-2 z-[10] gap-2"
|
|
1073
1082
|
),
|
|
1074
1083
|
children: [
|
|
1075
|
-
e.map((
|
|
1076
|
-
const P =
|
|
1077
|
-
return /* @__PURE__ */
|
|
1084
|
+
e.map((u, S) => {
|
|
1085
|
+
const P = Ue(S), D = (u.lineColor ?? u.color) || P.line, z = !h && u.data.length === 0;
|
|
1086
|
+
return /* @__PURE__ */ U(
|
|
1078
1087
|
"div",
|
|
1079
1088
|
{
|
|
1080
1089
|
className: O(
|
|
1081
1090
|
"flex shrink-0 items-center gap-1.5",
|
|
1082
|
-
!
|
|
1083
|
-
|
|
1091
|
+
!f && "px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border",
|
|
1092
|
+
z && "opacity-50"
|
|
1084
1093
|
),
|
|
1085
1094
|
children: [
|
|
1086
1095
|
/* @__PURE__ */ w(
|
|
@@ -1088,21 +1097,21 @@ function Wt({
|
|
|
1088
1097
|
{
|
|
1089
1098
|
className: O(
|
|
1090
1099
|
"shrink-0",
|
|
1091
|
-
|
|
1100
|
+
f ? "size-2 rounded-full" : "h-3 w-3 rounded-sm"
|
|
1092
1101
|
),
|
|
1093
|
-
style: { backgroundColor:
|
|
1102
|
+
style: { backgroundColor: D }
|
|
1094
1103
|
}
|
|
1095
1104
|
),
|
|
1096
|
-
/* @__PURE__ */
|
|
1105
|
+
/* @__PURE__ */ U(
|
|
1097
1106
|
"span",
|
|
1098
1107
|
{
|
|
1099
1108
|
className: O(
|
|
1100
1109
|
"font-medium text-foreground",
|
|
1101
|
-
|
|
1110
|
+
f ? "text-sm" : "text-[10px] sm:text-xs"
|
|
1102
1111
|
),
|
|
1103
1112
|
children: [
|
|
1104
|
-
|
|
1105
|
-
|
|
1113
|
+
u.label,
|
|
1114
|
+
z && " (no data)"
|
|
1106
1115
|
]
|
|
1107
1116
|
}
|
|
1108
1117
|
),
|
|
@@ -1110,12 +1119,12 @@ function Wt({
|
|
|
1110
1119
|
"button",
|
|
1111
1120
|
{
|
|
1112
1121
|
type: "button",
|
|
1113
|
-
onClick: (
|
|
1114
|
-
|
|
1122
|
+
onClick: (le) => {
|
|
1123
|
+
le.stopPropagation(), c(u.label);
|
|
1115
1124
|
},
|
|
1116
1125
|
className: "ml-1 flex items-center justify-center w-4 h-4 rounded-sm hover:bg-muted transition-colors cursor-pointer",
|
|
1117
|
-
"aria-label": `Remove ${
|
|
1118
|
-
children: /* @__PURE__ */
|
|
1126
|
+
"aria-label": `Remove ${u.label}`,
|
|
1127
|
+
children: /* @__PURE__ */ U(
|
|
1119
1128
|
"svg",
|
|
1120
1129
|
{
|
|
1121
1130
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -1140,22 +1149,22 @@ function Wt({
|
|
|
1140
1149
|
)
|
|
1141
1150
|
]
|
|
1142
1151
|
},
|
|
1143
|
-
|
|
1152
|
+
u.id ?? u.label
|
|
1144
1153
|
);
|
|
1145
1154
|
}),
|
|
1146
|
-
i?.map((
|
|
1155
|
+
i?.map((u) => /* @__PURE__ */ U(
|
|
1147
1156
|
"div",
|
|
1148
1157
|
{
|
|
1149
1158
|
className: O(
|
|
1150
1159
|
"flex shrink-0 items-center gap-1.5",
|
|
1151
|
-
!
|
|
1160
|
+
!f && "px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border"
|
|
1152
1161
|
),
|
|
1153
1162
|
children: [
|
|
1154
1163
|
/* @__PURE__ */ w(
|
|
1155
1164
|
"div",
|
|
1156
1165
|
{
|
|
1157
1166
|
className: "h-3 w-0.5 shrink-0",
|
|
1158
|
-
style: { backgroundColor:
|
|
1167
|
+
style: { backgroundColor: u.color }
|
|
1159
1168
|
}
|
|
1160
1169
|
),
|
|
1161
1170
|
/* @__PURE__ */ w(
|
|
@@ -1163,27 +1172,28 @@ function Wt({
|
|
|
1163
1172
|
{
|
|
1164
1173
|
className: O(
|
|
1165
1174
|
"font-medium text-foreground",
|
|
1166
|
-
|
|
1175
|
+
f ? "text-sm" : "text-[10px] sm:text-xs"
|
|
1167
1176
|
),
|
|
1168
|
-
children:
|
|
1177
|
+
children: u.label
|
|
1169
1178
|
}
|
|
1170
1179
|
)
|
|
1171
1180
|
]
|
|
1172
1181
|
},
|
|
1173
|
-
|
|
1182
|
+
u.id
|
|
1174
1183
|
))
|
|
1175
1184
|
]
|
|
1176
1185
|
}
|
|
1177
1186
|
);
|
|
1178
1187
|
}
|
|
1179
1188
|
export {
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
+
Te as DEFAULT_SERIES_COLORS,
|
|
1190
|
+
ro as Graph,
|
|
1191
|
+
Xt as GraphLegend,
|
|
1192
|
+
Ye as VERTICAL_LINE_LABEL_EDGE_PADDING,
|
|
1193
|
+
Ue as getSeriesColorPalette,
|
|
1194
|
+
Gt as getStepForwardValue,
|
|
1195
|
+
At as getVerticalLineLabelStyle,
|
|
1196
|
+
zt as getVerticalLineTooltipContent,
|
|
1197
|
+
ne as seriesIdentity,
|
|
1198
|
+
kt as visibleLogicalRangeFor
|
|
1189
1199
|
};
|