@gearbox-protocol/ui-kit 3.14.0-next.37 → 3.14.0-next.38
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,12 +1,12 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { createChart as Ue, CrosshairMode as et, LineStyle as
|
|
1
|
+
import { jsxs as ne, jsx as w } from "react/jsx-runtime";
|
|
2
|
+
import { createChart as Ue, CrosshairMode as et, LineStyle as ee, LineSeries as tt, AreaSeries as ot } from "lightweight-charts";
|
|
3
3
|
import * as Ce from "react";
|
|
4
|
-
import { useRef as
|
|
4
|
+
import { useRef as q, useState as ye, useEffect as E } from "react";
|
|
5
5
|
import { useIsMobile as rt } from "../../hooks/use-media-query.js";
|
|
6
|
-
import { cn as
|
|
7
|
-
import { resolveCSSColor as U, generateColorsFromBase as
|
|
8
|
-
import { getDefaultOptions as je, getDefaultSeries as lt, getDefaultVerticalLine as
|
|
9
|
-
import { getXFormatters as He, formatExactValue as xe, createAdaptiveYAxisFormatter as
|
|
6
|
+
import { cn as le } from "../../utils/cn.js";
|
|
7
|
+
import { resolveCSSColor as U, generateColorsFromBase as ce, hslToHex as nt } from "../../utils/colors.js";
|
|
8
|
+
import { getDefaultOptions as je, getDefaultSeries as lt, getDefaultVerticalLine as it } from "./default-config.js";
|
|
9
|
+
import { getXFormatters as He, formatExactValue as xe, createAdaptiveYAxisFormatter as at } from "./formatters.js";
|
|
10
10
|
import { GraphCurrentValue as st } from "./graph-current-value.js";
|
|
11
11
|
import { GraphTooltip as ct } from "./graph-tooltip.js";
|
|
12
12
|
import { VertLine as ut } from "./plugins/vertical-line.js";
|
|
@@ -14,13 +14,13 @@ class ft {
|
|
|
14
14
|
_yTop;
|
|
15
15
|
_yBottom;
|
|
16
16
|
_color;
|
|
17
|
-
constructor(
|
|
18
|
-
this._yTop =
|
|
17
|
+
constructor(l, f, c) {
|
|
18
|
+
this._yTop = l, this._yBottom = f, this._color = c;
|
|
19
19
|
}
|
|
20
|
-
draw(
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
20
|
+
draw(l) {
|
|
21
|
+
l.useBitmapCoordinateSpace((f) => {
|
|
22
|
+
const c = f.context, d = f.verticalPixelRatio, v = this._yTop === null ? 0 : this._yTop * d, F = this._yBottom === null ? f.bitmapSize.height : this._yBottom * d, x = Math.min(v, F), M = Math.max(v, F);
|
|
23
|
+
c.fillStyle = this._color, c.fillRect(0, x, f.bitmapSize.width, M - x);
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
}
|
|
@@ -28,12 +28,12 @@ class ht {
|
|
|
28
28
|
_source;
|
|
29
29
|
_yTop = null;
|
|
30
30
|
_yBottom = null;
|
|
31
|
-
constructor(
|
|
32
|
-
this._source =
|
|
31
|
+
constructor(l) {
|
|
32
|
+
this._source = l;
|
|
33
33
|
}
|
|
34
34
|
update() {
|
|
35
|
-
const
|
|
36
|
-
this._yTop = this._source.priceTop === void 0 ? null :
|
|
35
|
+
const l = this._source.series;
|
|
36
|
+
this._yTop = this._source.priceTop === void 0 ? null : l.priceToCoordinate(this._source.priceTop), this._yBottom = this._source.priceBottom === void 0 ? null : l.priceToCoordinate(this._source.priceBottom);
|
|
37
37
|
}
|
|
38
38
|
/** Draw beneath the series line/area so the data stays readable. */
|
|
39
39
|
zOrder() {
|
|
@@ -43,37 +43,111 @@ class ht {
|
|
|
43
43
|
return new ft(this._yTop, this._yBottom, this._source.color);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
class
|
|
46
|
+
class dt {
|
|
47
47
|
series;
|
|
48
48
|
priceTop;
|
|
49
49
|
priceBottom;
|
|
50
50
|
color;
|
|
51
51
|
_paneViews;
|
|
52
|
-
constructor(
|
|
53
|
-
this.series =
|
|
52
|
+
constructor(l, f, c, d) {
|
|
53
|
+
this.series = l, this.priceTop = f, this.priceBottom = c, this.color = d, this._paneViews = [new ht(this)];
|
|
54
|
+
}
|
|
55
|
+
updateAllViews() {
|
|
56
|
+
for (const l of this._paneViews) l.update();
|
|
57
|
+
}
|
|
58
|
+
paneViews() {
|
|
59
|
+
return this._paneViews;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function pt(t, l) {
|
|
63
|
+
switch (t) {
|
|
64
|
+
case ee.Dotted:
|
|
65
|
+
return [l, l];
|
|
66
|
+
case ee.Dashed:
|
|
67
|
+
return [2 * l, 2 * l];
|
|
68
|
+
case ee.LargeDashed:
|
|
69
|
+
return [6 * l, 6 * l];
|
|
70
|
+
case ee.SparseDotted:
|
|
71
|
+
return [l, 4 * l];
|
|
72
|
+
default:
|
|
73
|
+
return [];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
class mt {
|
|
77
|
+
_y;
|
|
78
|
+
_color;
|
|
79
|
+
_lineWidth;
|
|
80
|
+
_lineStyle;
|
|
81
|
+
constructor(l, f, c, d) {
|
|
82
|
+
this._y = l, this._color = f, this._lineWidth = c, this._lineStyle = d;
|
|
83
|
+
}
|
|
84
|
+
draw(l) {
|
|
85
|
+
l.useBitmapCoordinateSpace((f) => {
|
|
86
|
+
if (this._y === null) return;
|
|
87
|
+
const c = f.context, d = f.verticalPixelRatio, v = Math.max(1, Math.round(this._lineWidth * d)), F = Math.round(this._y * d);
|
|
88
|
+
c.save(), c.strokeStyle = this._color, c.lineWidth = v, c.setLineDash(pt(this._lineStyle, v)), c.beginPath(), c.moveTo(0, F), c.lineTo(f.bitmapSize.width, F), c.stroke(), c.restore();
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
class gt {
|
|
93
|
+
_source;
|
|
94
|
+
_y = null;
|
|
95
|
+
constructor(l) {
|
|
96
|
+
this._source = l;
|
|
97
|
+
}
|
|
98
|
+
update() {
|
|
99
|
+
this._y = this._source.series.priceToCoordinate(this._source.price);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Draw on the top pane (top canvas) so a liquidation price line stays above
|
|
103
|
+
* every series' area/line fill, price zones and the crosshair — native
|
|
104
|
+
* `createPriceLine` only draws in the "normal" group and can be hidden behind
|
|
105
|
+
* a later series in multi-series charts.
|
|
106
|
+
*/
|
|
107
|
+
zOrder() {
|
|
108
|
+
return "top";
|
|
109
|
+
}
|
|
110
|
+
renderer() {
|
|
111
|
+
return new mt(
|
|
112
|
+
this._y,
|
|
113
|
+
this._source.color,
|
|
114
|
+
this._source.lineWidth,
|
|
115
|
+
this._source.lineStyle
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
class bt {
|
|
120
|
+
series;
|
|
121
|
+
price;
|
|
122
|
+
color;
|
|
123
|
+
lineWidth;
|
|
124
|
+
lineStyle;
|
|
125
|
+
_paneViews;
|
|
126
|
+
constructor(l, f, c, d, v) {
|
|
127
|
+
this.series = l, this.price = f, this.color = c, this.lineWidth = d, this.lineStyle = v, this._paneViews = [new gt(this)];
|
|
54
128
|
}
|
|
55
129
|
updateAllViews() {
|
|
56
|
-
for (const
|
|
130
|
+
for (const l of this._paneViews) l.update();
|
|
57
131
|
}
|
|
58
132
|
paneViews() {
|
|
59
133
|
return this._paneViews;
|
|
60
134
|
}
|
|
61
135
|
}
|
|
62
|
-
function
|
|
63
|
-
const
|
|
136
|
+
function vt(t, l, f) {
|
|
137
|
+
const c = t.labelText ?? "", d = t.value, v = d === void 0 ? "" : typeof d == "number" ? l === "$" ? `$${xe(d, void 0, f)}` : l === "%" ? `${xe(d, void 0, f)}%` : xe(
|
|
64
138
|
d,
|
|
65
|
-
|
|
66
|
-
|
|
139
|
+
l !== "none" && l !== "%" && l !== "$" ? l : void 0,
|
|
140
|
+
f
|
|
67
141
|
) : String(d);
|
|
68
|
-
return { labelText:
|
|
142
|
+
return { labelText: c, valueStr: v };
|
|
69
143
|
}
|
|
70
|
-
function
|
|
71
|
-
for (let
|
|
72
|
-
if (Number(
|
|
73
|
-
return
|
|
144
|
+
function St(t, l) {
|
|
145
|
+
for (let f = t.length - 1; f >= 0; f--)
|
|
146
|
+
if (Number(t[f].time) <= l)
|
|
147
|
+
return t[f].value;
|
|
74
148
|
return 0;
|
|
75
149
|
}
|
|
76
|
-
const
|
|
150
|
+
const we = [
|
|
77
151
|
// 0 green (emerald)
|
|
78
152
|
{
|
|
79
153
|
line: "#02c39a",
|
|
@@ -188,70 +262,70 @@ const ye = [
|
|
|
188
262
|
top: "rgba(71, 85, 105, 0.56)",
|
|
189
263
|
bottom: "rgba(71, 85, 105, 0.04)"
|
|
190
264
|
}
|
|
191
|
-
],
|
|
192
|
-
function
|
|
193
|
-
if (
|
|
194
|
-
return
|
|
195
|
-
const
|
|
196
|
-
return { line:
|
|
265
|
+
], Ct = 137.5;
|
|
266
|
+
function Oe(t) {
|
|
267
|
+
if (t < we.length)
|
|
268
|
+
return we[t];
|
|
269
|
+
const f = (t - we.length) * Ct % 360, c = nt(f, 70, 50), { topColor: d, bottomColor: v } = ce(c);
|
|
270
|
+
return { line: c, top: d, bottom: v };
|
|
197
271
|
}
|
|
198
|
-
function
|
|
199
|
-
series:
|
|
200
|
-
className:
|
|
201
|
-
showLegend:
|
|
202
|
-
onUnselectSeries:
|
|
272
|
+
function Bt({
|
|
273
|
+
series: t,
|
|
274
|
+
className: l,
|
|
275
|
+
showLegend: f = !1,
|
|
276
|
+
onUnselectSeries: c,
|
|
203
277
|
xMeasureUnit: d = "time",
|
|
204
|
-
yMeasureUnit:
|
|
205
|
-
optionsOverrides:
|
|
278
|
+
yMeasureUnit: v = "token",
|
|
279
|
+
optionsOverrides: F,
|
|
206
280
|
verticalLineOptions: x,
|
|
207
|
-
priceLineOptions:
|
|
208
|
-
zoneOptions:
|
|
209
|
-
currentValueDecimals:
|
|
210
|
-
useSharedPriceScale:
|
|
211
|
-
dualYAxis:
|
|
212
|
-
defaultVisiblePriceScaleId:
|
|
281
|
+
priceLineOptions: M,
|
|
282
|
+
zoneOptions: j,
|
|
283
|
+
currentValueDecimals: ue,
|
|
284
|
+
useSharedPriceScale: A = !1,
|
|
285
|
+
dualYAxis: D = !1,
|
|
286
|
+
defaultVisiblePriceScaleId: _e = "right",
|
|
213
287
|
leftPriceScaleTitle: Ne,
|
|
214
|
-
rightPriceScaleTitle:
|
|
215
|
-
showCurrentValue:
|
|
216
|
-
graphTitle:
|
|
288
|
+
rightPriceScaleTitle: xt,
|
|
289
|
+
showCurrentValue: Xe = !0,
|
|
290
|
+
graphTitle: fe,
|
|
217
291
|
yScaleMin: Te,
|
|
218
292
|
yScaleMinMultiple: Ve,
|
|
219
293
|
visibleTimeFrom: Z,
|
|
220
|
-
disableZoom:
|
|
221
|
-
hideDefaultTooltip:
|
|
294
|
+
disableZoom: ie = !1,
|
|
295
|
+
hideDefaultTooltip: he = !1
|
|
222
296
|
}) {
|
|
223
|
-
const
|
|
224
|
-
if (
|
|
225
|
-
const
|
|
226
|
-
if (
|
|
227
|
-
return
|
|
297
|
+
const z = q(null), C = q(/* @__PURE__ */ new Map()), de = q(!1), Pe = q(!0), Re = q([]), K = q(null), pe = q(null), ae = q(null), V = rt(), H = Ce.useMemo(() => t.flatMap((o) => o.data), [t]), qe = Ce.useMemo(() => {
|
|
298
|
+
if (t.length > 0) {
|
|
299
|
+
const o = t[t.length - 1];
|
|
300
|
+
if (o.data.length > 0)
|
|
301
|
+
return o.data[o.data.length - 1];
|
|
228
302
|
}
|
|
229
|
-
}, [
|
|
230
|
-
if (!
|
|
231
|
-
const
|
|
232
|
-
for (const
|
|
233
|
-
|
|
234
|
-
return
|
|
235
|
-
}), [
|
|
236
|
-
|
|
237
|
-
const
|
|
303
|
+
}, [t]), [Le, me] = ye(() => {
|
|
304
|
+
if (!qe) return;
|
|
305
|
+
const o = /* @__PURE__ */ new Map();
|
|
306
|
+
for (const s of t)
|
|
307
|
+
s.data.length > 0 && o.set(s.label, s.data[s.data.length - 1]);
|
|
308
|
+
return o;
|
|
309
|
+
}), [Me, O] = ye(null), [ke, De] = ye([]);
|
|
310
|
+
E(() => {
|
|
311
|
+
const o = () => {
|
|
238
312
|
try {
|
|
239
|
-
if (
|
|
240
|
-
const
|
|
241
|
-
|
|
313
|
+
if (z.current && K.current) {
|
|
314
|
+
const a = K.current.clientWidth, i = K.current.clientHeight;
|
|
315
|
+
z.current.resize(a, i);
|
|
242
316
|
}
|
|
243
317
|
} catch {
|
|
244
318
|
}
|
|
245
|
-
},
|
|
246
|
-
return ae.current =
|
|
247
|
-
|
|
319
|
+
}, s = K.current, n = s ? new ResizeObserver(o) : null;
|
|
320
|
+
return ae.current = n, s && n?.observe(s), () => {
|
|
321
|
+
s && n?.unobserve(s), n?.disconnect(), ae.current = null;
|
|
248
322
|
};
|
|
249
|
-
}, []),
|
|
250
|
-
if (!
|
|
251
|
-
const
|
|
323
|
+
}, []), E(() => {
|
|
324
|
+
if (!pe.current || de.current) return;
|
|
325
|
+
const o = je(), s = U(
|
|
252
326
|
"hsl(var(--foreground))",
|
|
253
327
|
"rgb(0, 0, 0)"
|
|
254
|
-
),
|
|
328
|
+
), n = ie ? {
|
|
255
329
|
handleScale: {
|
|
256
330
|
mouseWheel: !1,
|
|
257
331
|
pinch: !1,
|
|
@@ -264,34 +338,34 @@ function Lt({
|
|
|
264
338
|
horzTouchDrag: !1,
|
|
265
339
|
vertTouchDrag: !1
|
|
266
340
|
}
|
|
267
|
-
} : {},
|
|
268
|
-
...
|
|
341
|
+
} : {}, a = Ue(pe.current, {
|
|
342
|
+
...o,
|
|
269
343
|
leftPriceScale: {
|
|
270
|
-
...
|
|
344
|
+
...o.leftPriceScale || {},
|
|
271
345
|
visible: !1,
|
|
272
|
-
textColor:
|
|
346
|
+
textColor: s
|
|
273
347
|
},
|
|
274
348
|
rightPriceScale: {
|
|
275
|
-
...
|
|
276
|
-
visible: !
|
|
277
|
-
textColor:
|
|
349
|
+
...o.rightPriceScale || {},
|
|
350
|
+
visible: !V,
|
|
351
|
+
textColor: s
|
|
278
352
|
},
|
|
279
|
-
...
|
|
353
|
+
...V && {
|
|
280
354
|
crosshair: {
|
|
281
|
-
...
|
|
355
|
+
...o.crosshair,
|
|
282
356
|
mode: et.Magnet
|
|
283
357
|
}
|
|
284
358
|
},
|
|
285
|
-
...
|
|
286
|
-
...
|
|
359
|
+
...n,
|
|
360
|
+
...F
|
|
287
361
|
});
|
|
288
|
-
return
|
|
289
|
-
ae.current?.disconnect(), ae.current = null,
|
|
362
|
+
return z.current = a, de.current = !0, () => {
|
|
363
|
+
ae.current?.disconnect(), ae.current = null, a.remove(), z.current = null, de.current = !1, C.current.clear();
|
|
290
364
|
};
|
|
291
|
-
}, [
|
|
292
|
-
const
|
|
293
|
-
|
|
294
|
-
|
|
365
|
+
}, [V, F, ie]), E(() => {
|
|
366
|
+
const o = z.current;
|
|
367
|
+
o && o.applyOptions(
|
|
368
|
+
ie ? {
|
|
295
369
|
handleScale: {
|
|
296
370
|
mouseWheel: !1,
|
|
297
371
|
pinch: !1,
|
|
@@ -319,89 +393,89 @@ function Lt({
|
|
|
319
393
|
}
|
|
320
394
|
}
|
|
321
395
|
);
|
|
322
|
-
}, [
|
|
323
|
-
const
|
|
324
|
-
if (!
|
|
325
|
-
const
|
|
396
|
+
}, [ie]), E(() => {
|
|
397
|
+
const o = z.current;
|
|
398
|
+
if (!o || t.length === 0) return;
|
|
399
|
+
const n = t.filter((r) => r.data.length > 0).length <= 1 ? Te : Ve, a = d === "time" ? He(d, H) : He(d), i = /* @__PURE__ */ new Map();
|
|
326
400
|
{
|
|
327
401
|
let r = 0;
|
|
328
|
-
for (const e of
|
|
402
|
+
for (const e of t)
|
|
329
403
|
e.data.length !== 0 && (i.set(
|
|
330
404
|
e.label,
|
|
331
405
|
e.priceScaleId ?? (r === 0 ? "left" : "right")
|
|
332
406
|
), r++);
|
|
333
407
|
}
|
|
334
|
-
const
|
|
408
|
+
const u = (r, e, p) => {
|
|
335
409
|
const {
|
|
336
|
-
formatter:
|
|
337
|
-
tickmarksFormatter:
|
|
338
|
-
updateVisibleRange:
|
|
339
|
-
updateLastValues:
|
|
340
|
-
} =
|
|
341
|
-
yScaleMin:
|
|
342
|
-
}), be =
|
|
343
|
-
return
|
|
344
|
-
},
|
|
345
|
-
if (
|
|
410
|
+
formatter: k,
|
|
411
|
+
tickmarksFormatter: T,
|
|
412
|
+
updateVisibleRange: $,
|
|
413
|
+
updateLastValues: Fe
|
|
414
|
+
} = at(r, e, {
|
|
415
|
+
yScaleMin: n
|
|
416
|
+
}), be = t.filter((J) => J.data.length > 0 && p.has(J.label)).map((J) => J.data[J.data.length - 1].value);
|
|
417
|
+
return Fe(be), { formatter: k, tickmarksFormatter: T, updateVisibleRange: $, labels: p };
|
|
418
|
+
}, h = [];
|
|
419
|
+
if (D)
|
|
346
420
|
for (const r of ["left", "right"]) {
|
|
347
|
-
const e = /* @__PURE__ */ new Set(),
|
|
348
|
-
let
|
|
349
|
-
for (const
|
|
350
|
-
if (
|
|
351
|
-
e.size === 0 &&
|
|
352
|
-
for (const
|
|
421
|
+
const e = /* @__PURE__ */ new Set(), p = [];
|
|
422
|
+
let k = v;
|
|
423
|
+
for (const T of t)
|
|
424
|
+
if (T.data.length !== 0 && i.get(T.label) === r) {
|
|
425
|
+
e.size === 0 && T.yMeasureUnit && (k = T.yMeasureUnit), e.add(T.label);
|
|
426
|
+
for (const $ of T.data) p.push($.value);
|
|
353
427
|
}
|
|
354
|
-
e.size > 0 &&
|
|
428
|
+
e.size > 0 && h.push(u(p, k, e));
|
|
355
429
|
}
|
|
356
430
|
else {
|
|
357
|
-
const r =
|
|
358
|
-
|
|
431
|
+
const r = H.map((p) => p.value), e = new Set(
|
|
432
|
+
t.filter((p) => p.data.length > 0).map((p) => p.label)
|
|
359
433
|
);
|
|
360
|
-
|
|
434
|
+
h.push(u(r, v, e));
|
|
361
435
|
}
|
|
362
|
-
|
|
363
|
-
const
|
|
364
|
-
for (const r of
|
|
436
|
+
Re.current = h;
|
|
437
|
+
const b = /* @__PURE__ */ new Map();
|
|
438
|
+
for (const r of h)
|
|
365
439
|
for (const e of r.labels)
|
|
366
|
-
|
|
367
|
-
const
|
|
368
|
-
|
|
440
|
+
b.set(e, r);
|
|
441
|
+
const S = je();
|
|
442
|
+
o.applyOptions({
|
|
369
443
|
localization: {
|
|
370
|
-
...
|
|
444
|
+
...S.localization || {},
|
|
371
445
|
// biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
|
|
372
446
|
timeFormatter: (r) => (
|
|
373
447
|
// biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
|
|
374
|
-
|
|
448
|
+
a.timeFormatter(parseFloat(r), void 0)
|
|
375
449
|
)
|
|
376
450
|
},
|
|
377
451
|
timeScale: {
|
|
378
|
-
...
|
|
452
|
+
...S.timeScale || {},
|
|
379
453
|
// biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
|
|
380
|
-
tickMarkFormatter:
|
|
454
|
+
tickMarkFormatter: a.tickMarkFormatter,
|
|
381
455
|
minBarSpacing: 0
|
|
382
456
|
}
|
|
383
457
|
});
|
|
384
|
-
const
|
|
458
|
+
const P = (H.length > 0 ? Math.min(...H.map((r) => r.value)) : 0) < 0, _ = H.some((r) => r.value === 0), m = !P && _, y = !D && t.length > 1 && !A, R = D ? V : t.length > 1 && !A || V, L = U(
|
|
385
459
|
"hsl(var(--foreground))",
|
|
386
460
|
"rgb(0, 0, 0)"
|
|
387
461
|
);
|
|
388
|
-
|
|
389
|
-
...
|
|
390
|
-
defaultVisiblePriceScaleId:
|
|
462
|
+
o.applyOptions({
|
|
463
|
+
...D && {
|
|
464
|
+
defaultVisiblePriceScaleId: _e
|
|
391
465
|
},
|
|
392
466
|
leftPriceScale: {
|
|
393
|
-
...
|
|
394
|
-
visible:
|
|
395
|
-
textColor:
|
|
396
|
-
...
|
|
467
|
+
...S.leftPriceScale || {},
|
|
468
|
+
visible: D && !V,
|
|
469
|
+
textColor: L,
|
|
470
|
+
...D && Ne && {
|
|
397
471
|
// lightweight-charts uses scale margins; title shown via localization if needed
|
|
398
472
|
}
|
|
399
473
|
},
|
|
400
474
|
rightPriceScale: {
|
|
401
|
-
...
|
|
402
|
-
visible:
|
|
403
|
-
textColor:
|
|
404
|
-
...m && !
|
|
475
|
+
...S.rightPriceScale || {},
|
|
476
|
+
visible: D ? !V : !R,
|
|
477
|
+
textColor: L,
|
|
478
|
+
...m && !D && {
|
|
405
479
|
scaleMargins: {
|
|
406
480
|
top: 0.3,
|
|
407
481
|
bottom: 0
|
|
@@ -409,122 +483,122 @@ function Lt({
|
|
|
409
483
|
}
|
|
410
484
|
}
|
|
411
485
|
});
|
|
412
|
-
const
|
|
413
|
-
for (const r of
|
|
414
|
-
if (!
|
|
415
|
-
const e =
|
|
416
|
-
e && (
|
|
486
|
+
const N = new Set(C.current.keys()), X = new Set(t.map((r) => r.label));
|
|
487
|
+
for (const r of N)
|
|
488
|
+
if (!X.has(r)) {
|
|
489
|
+
const e = C.current.get(r);
|
|
490
|
+
e && (o.removeSeries(e), C.current.delete(r));
|
|
417
491
|
}
|
|
418
|
-
const Q = lt(),
|
|
419
|
-
let
|
|
420
|
-
const
|
|
421
|
-
if (
|
|
422
|
-
for (const r of
|
|
492
|
+
const Q = lt(), te = [];
|
|
493
|
+
let oe = 0;
|
|
494
|
+
const Be = t.find((r) => r.data.length > 0), re = /* @__PURE__ */ new Map();
|
|
495
|
+
if (M && M.length > 0)
|
|
496
|
+
for (const r of M) {
|
|
423
497
|
if (!Number.isFinite(r.price)) continue;
|
|
424
|
-
const e = r.seriesLabel ??
|
|
498
|
+
const e = r.seriesLabel ?? Be?.label;
|
|
425
499
|
if (!e) continue;
|
|
426
|
-
const
|
|
427
|
-
|
|
500
|
+
const p = re.get(e) ?? [];
|
|
501
|
+
p.push(r.price), re.set(e, p);
|
|
428
502
|
}
|
|
429
|
-
if (
|
|
430
|
-
for (const r of
|
|
431
|
-
const e = r.seriesLabel ??
|
|
503
|
+
if (j && j.length > 0)
|
|
504
|
+
for (const r of j) {
|
|
505
|
+
const e = r.seriesLabel ?? Be?.label;
|
|
432
506
|
if (!e) continue;
|
|
433
|
-
const
|
|
434
|
-
Number.isFinite(r.priceTop) &&
|
|
507
|
+
const p = re.get(e) ?? [];
|
|
508
|
+
Number.isFinite(r.priceTop) && p.push(r.priceTop), Number.isFinite(r.priceBottom) && p.push(r.priceBottom), re.set(e, p);
|
|
435
509
|
}
|
|
436
|
-
for (let r = 0; r <
|
|
437
|
-
const e =
|
|
438
|
-
let
|
|
510
|
+
for (let r = 0; r < t.length; r++) {
|
|
511
|
+
const e = t[r], p = Oe(r), k = e.lineColor ?? e.color ?? p.line;
|
|
512
|
+
let T, $;
|
|
439
513
|
if (e.lineColor ?? e.color)
|
|
440
514
|
if (e.topColor && e.bottomColor)
|
|
441
|
-
|
|
515
|
+
T = e.topColor, $ = e.bottomColor;
|
|
442
516
|
else if (e.topColor) {
|
|
443
|
-
const
|
|
444
|
-
|
|
517
|
+
const g = ce(k);
|
|
518
|
+
T = e.topColor, $ = g.bottomColor;
|
|
445
519
|
} else if (e.bottomColor)
|
|
446
|
-
|
|
520
|
+
T = ce(k).topColor, $ = e.bottomColor;
|
|
447
521
|
else {
|
|
448
|
-
const
|
|
449
|
-
|
|
522
|
+
const g = ce(k);
|
|
523
|
+
T = g.topColor, $ = g.bottomColor;
|
|
450
524
|
}
|
|
451
525
|
else
|
|
452
|
-
|
|
526
|
+
T = e.topColor || p.top, $ = e.bottomColor || p.bottom;
|
|
453
527
|
if (e.data.length === 0) {
|
|
454
|
-
const
|
|
455
|
-
|
|
528
|
+
const g = C.current.get(e.label);
|
|
529
|
+
g && (o.removeSeries(g), C.current.delete(e.label));
|
|
456
530
|
continue;
|
|
457
531
|
}
|
|
458
|
-
const be = (e.data.length > 0 ? Math.min(...e.data.map((
|
|
459
|
-
|
|
460
|
-
priceScaleId:
|
|
461
|
-
shouldPreventNegativeAxis:
|
|
462
|
-
seriesIndex:
|
|
532
|
+
const be = (e.data.length > 0 ? Math.min(...e.data.map((g) => g.value)) : 0) < 0, J = e.data.some((g) => g.value === 0), Ze = !be && J, ze = D ? e.priceScaleId ?? (oe === 0 ? "left" : "right") : A || !y || oe === 0 ? "right" : `scale-${oe}`;
|
|
533
|
+
y && te.push({
|
|
534
|
+
priceScaleId: ze || "right",
|
|
535
|
+
shouldPreventNegativeAxis: Ze,
|
|
536
|
+
seriesIndex: oe
|
|
463
537
|
});
|
|
464
|
-
const
|
|
465
|
-
const
|
|
466
|
-
if (
|
|
467
|
-
|
|
468
|
-
for (const
|
|
469
|
-
|
|
538
|
+
const We = (A || !y) && n !== void 0 && typeof n == "number", Ke = re.get(e.label) ?? [], Je = (g) => {
|
|
539
|
+
const B = g();
|
|
540
|
+
if (B?.priceRange) {
|
|
541
|
+
We && (B.priceRange.minValue = n);
|
|
542
|
+
for (const G of Ke)
|
|
543
|
+
G < B.priceRange.minValue && (B.priceRange.minValue = G), G > B.priceRange.maxValue && (B.priceRange.maxValue = G);
|
|
470
544
|
}
|
|
471
|
-
return
|
|
472
|
-
},
|
|
473
|
-
lineColor:
|
|
474
|
-
topColor:
|
|
475
|
-
bottomColor:
|
|
476
|
-
priceScaleId:
|
|
545
|
+
return B;
|
|
546
|
+
}, $e = b.get(e.label) ?? h[0], Ee = $e.formatter, Qe = $e.tickmarksFormatter, ve = {
|
|
547
|
+
lineColor: k,
|
|
548
|
+
topColor: T,
|
|
549
|
+
bottomColor: $,
|
|
550
|
+
priceScaleId: ze,
|
|
477
551
|
...e.seriesType === "line" && {
|
|
478
|
-
lineStyle: e.lineStyle ??
|
|
552
|
+
lineStyle: e.lineStyle ?? ee.Solid
|
|
479
553
|
},
|
|
480
554
|
priceFormat: {
|
|
481
555
|
type: "custom",
|
|
482
556
|
minMove: 0.01,
|
|
483
|
-
formatter:
|
|
484
|
-
|
|
485
|
-
) :
|
|
557
|
+
formatter: We && typeof n == "number" ? (g) => Ee(
|
|
558
|
+
g < n ? n : g
|
|
559
|
+
) : Ee,
|
|
486
560
|
tickmarksFormatter: Qe
|
|
487
561
|
},
|
|
488
562
|
autoscaleInfoProvider: Je
|
|
489
|
-
},
|
|
490
|
-
let
|
|
491
|
-
const Y = e.data.map((
|
|
492
|
-
...
|
|
493
|
-
time:
|
|
563
|
+
}, Ae = e.seriesType === "line";
|
|
564
|
+
let I = C.current.get(e.label);
|
|
565
|
+
const Y = e.data.map((g) => ({
|
|
566
|
+
...g,
|
|
567
|
+
time: g.time
|
|
494
568
|
}));
|
|
495
569
|
if (Z !== void 0 && Y.length > 0 && Number(Y[0].time) > Z) {
|
|
496
|
-
const
|
|
497
|
-
for (let
|
|
498
|
-
|
|
499
|
-
Y.unshift(...
|
|
570
|
+
const g = Number(Y[0].time), B = g - Z, G = 86400, Ye = B > 180 * G ? 7 * G : B > 30 * G ? G : 6 * 3600, Ge = [];
|
|
571
|
+
for (let Se = Z; Se < g; Se += Ye)
|
|
572
|
+
Ge.push({ time: Se });
|
|
573
|
+
Y.unshift(...Ge);
|
|
500
574
|
}
|
|
501
|
-
|
|
575
|
+
I && I.seriesType() !== (Ae ? "Line" : "Area") && (o.removeSeries(I), C.current.delete(e.label), I = void 0), I ? (I.applyOptions(ve), I.setData(Y)) : (Ae ? I = o.addSeries(tt, {
|
|
502
576
|
...Q,
|
|
503
|
-
...
|
|
504
|
-
}) :
|
|
577
|
+
...ve
|
|
578
|
+
}) : I = o.addSeries(ot, {
|
|
505
579
|
...Q,
|
|
506
|
-
...
|
|
507
|
-
}),
|
|
580
|
+
...ve
|
|
581
|
+
}), I.setData(Y), C.current.set(e.label, I)), oe++;
|
|
508
582
|
}
|
|
509
|
-
if (
|
|
583
|
+
if (D)
|
|
510
584
|
try {
|
|
511
|
-
const r =
|
|
512
|
-
visible: !
|
|
585
|
+
const r = o.priceScale("left"), e = o.priceScale("right"), p = {
|
|
586
|
+
visible: !V,
|
|
513
587
|
autoScale: !0,
|
|
514
588
|
scaleMargins: { top: 0.1, bottom: 0.1 },
|
|
515
589
|
alignLabels: !0,
|
|
516
590
|
borderVisible: !0,
|
|
517
591
|
borderColor: "rgba(224, 227, 235, 0.1)",
|
|
518
592
|
entireTextOnly: !1,
|
|
519
|
-
textColor:
|
|
593
|
+
textColor: L
|
|
520
594
|
};
|
|
521
|
-
r?.applyOptions(
|
|
595
|
+
r?.applyOptions(p), e?.applyOptions(p);
|
|
522
596
|
} catch {
|
|
523
597
|
}
|
|
524
|
-
else if (
|
|
525
|
-
for (const r of
|
|
598
|
+
else if (y && te.length > 0)
|
|
599
|
+
for (const r of te)
|
|
526
600
|
try {
|
|
527
|
-
const e =
|
|
601
|
+
const e = o.priceScale(r.priceScaleId);
|
|
528
602
|
e && e.applyOptions({
|
|
529
603
|
visible: !1,
|
|
530
604
|
autoScale: !0,
|
|
@@ -540,7 +614,7 @@ function Lt({
|
|
|
540
614
|
borderVisible: !0,
|
|
541
615
|
borderColor: "rgba(224, 227, 235, 0.1)",
|
|
542
616
|
entireTextOnly: !1,
|
|
543
|
-
textColor:
|
|
617
|
+
textColor: L
|
|
544
618
|
});
|
|
545
619
|
} catch (e) {
|
|
546
620
|
console.warn(
|
|
@@ -548,16 +622,16 @@ function Lt({
|
|
|
548
622
|
e
|
|
549
623
|
);
|
|
550
624
|
}
|
|
551
|
-
else if (!
|
|
625
|
+
else if (!y)
|
|
552
626
|
try {
|
|
553
|
-
const r =
|
|
627
|
+
const r = o.priceScale("right");
|
|
554
628
|
r && r.applyOptions({
|
|
555
|
-
visible: !
|
|
629
|
+
visible: !V,
|
|
556
630
|
autoScale: !0,
|
|
557
631
|
scaleMargins: {
|
|
558
632
|
top: 0.1,
|
|
559
633
|
// No bottom margin when yScaleMin is set so the scale doesn't extend below the minimum (avoids negative labels like -10M)
|
|
560
|
-
bottom:
|
|
634
|
+
bottom: n !== void 0 || m ? 0 : 0.1,
|
|
561
635
|
...m && {
|
|
562
636
|
top: 0.3
|
|
563
637
|
}
|
|
@@ -566,326 +640,342 @@ function Lt({
|
|
|
566
640
|
borderVisible: !0,
|
|
567
641
|
borderColor: "rgba(224, 227, 235, 0.1)",
|
|
568
642
|
entireTextOnly: !1,
|
|
569
|
-
textColor:
|
|
643
|
+
textColor: L
|
|
570
644
|
});
|
|
571
645
|
} catch {
|
|
572
646
|
}
|
|
573
|
-
if (
|
|
647
|
+
if (n !== void 0 && !V && (A || !y) && o.applyOptions({
|
|
574
648
|
handleScroll: {
|
|
575
649
|
vertTouchDrag: !1
|
|
576
650
|
}
|
|
577
|
-
}),
|
|
578
|
-
const r =
|
|
651
|
+
}), H.length > 0) {
|
|
652
|
+
const r = H.map((e) => Number(e.time)).filter((e) => Number.isFinite(e));
|
|
579
653
|
if (r.length > 0) {
|
|
580
|
-
const e = Math.min(...r),
|
|
581
|
-
if (Number(
|
|
654
|
+
const e = Math.min(...r), p = Z !== void 0 ? Math.min(Z, e) : e, k = Math.max(...r);
|
|
655
|
+
if (Number(p) <= Number(k))
|
|
582
656
|
try {
|
|
583
|
-
|
|
657
|
+
o.timeScale().setVisibleRange({ from: p, to: k });
|
|
584
658
|
} catch {
|
|
585
659
|
try {
|
|
586
|
-
|
|
660
|
+
o.timeScale().fitContent();
|
|
587
661
|
} catch {
|
|
588
662
|
}
|
|
589
663
|
}
|
|
590
664
|
}
|
|
591
665
|
}
|
|
592
|
-
|
|
593
|
-
const
|
|
594
|
-
for (const r of
|
|
595
|
-
r.data.length > 0 &&
|
|
596
|
-
|
|
666
|
+
Pe.current && (Pe.current = !1);
|
|
667
|
+
const ge = /* @__PURE__ */ new Map();
|
|
668
|
+
for (const r of t)
|
|
669
|
+
r.data.length > 0 && ge.set(r.label, r.data[r.data.length - 1]);
|
|
670
|
+
me(ge.size > 0 ? ge : void 0);
|
|
597
671
|
}, [
|
|
598
|
-
|
|
599
|
-
|
|
672
|
+
t,
|
|
673
|
+
H,
|
|
600
674
|
d,
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
675
|
+
v,
|
|
676
|
+
V,
|
|
677
|
+
A,
|
|
678
|
+
D,
|
|
679
|
+
_e,
|
|
606
680
|
Ne,
|
|
607
681
|
Te,
|
|
608
682
|
Ve,
|
|
609
683
|
Z,
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
]),
|
|
613
|
-
const
|
|
614
|
-
if (!
|
|
615
|
-
const
|
|
616
|
-
let
|
|
617
|
-
for (const i of
|
|
684
|
+
M,
|
|
685
|
+
j
|
|
686
|
+
]), E(() => {
|
|
687
|
+
const o = z.current;
|
|
688
|
+
if (!o || t.length === 0) return;
|
|
689
|
+
const s = t.length === 1;
|
|
690
|
+
let n;
|
|
691
|
+
for (const i of t)
|
|
618
692
|
if (i.data.length > 0) {
|
|
619
|
-
|
|
693
|
+
n = i.data[i.data.length - 1].time;
|
|
620
694
|
break;
|
|
621
695
|
}
|
|
622
|
-
if (!
|
|
623
|
-
const
|
|
624
|
-
const { time:
|
|
625
|
-
if (!
|
|
626
|
-
const
|
|
627
|
-
for (const m of
|
|
628
|
-
m.data.length > 0 &&
|
|
629
|
-
if (
|
|
630
|
-
|
|
631
|
-
else if (
|
|
632
|
-
const
|
|
633
|
-
if (
|
|
634
|
-
const
|
|
635
|
-
|
|
696
|
+
if (!n) return;
|
|
697
|
+
const a = (i) => {
|
|
698
|
+
const { time: u = n, seriesData: h, point: b } = i || {}, S = Array.from(C.current.values());
|
|
699
|
+
if (!b || !u) {
|
|
700
|
+
const _ = /* @__PURE__ */ new Map();
|
|
701
|
+
for (const m of t)
|
|
702
|
+
m.data.length > 0 && _.set(m.label, m.data[m.data.length - 1]);
|
|
703
|
+
if (me(_.size > 0 ? _ : void 0), s || A || he)
|
|
704
|
+
O(null);
|
|
705
|
+
else if (S[0] && n) {
|
|
706
|
+
const y = o.timeScale().timeToCoordinate(n), R = t[0];
|
|
707
|
+
if (R.data.length > 0) {
|
|
708
|
+
const L = R.data[R.data.length - 1].value, N = S[0].priceToCoordinate(L);
|
|
709
|
+
y !== null && N !== null && O({ x: y, y: N });
|
|
636
710
|
}
|
|
637
711
|
}
|
|
638
712
|
return;
|
|
639
713
|
}
|
|
640
|
-
const
|
|
641
|
-
let
|
|
642
|
-
for (let
|
|
643
|
-
const m =
|
|
644
|
-
if (!
|
|
645
|
-
const
|
|
646
|
-
let
|
|
647
|
-
if (
|
|
648
|
-
|
|
649
|
-
else if (
|
|
650
|
-
const
|
|
651
|
-
|
|
652
|
-
} else
|
|
653
|
-
|
|
654
|
-
|
|
714
|
+
const W = /* @__PURE__ */ new Map();
|
|
715
|
+
let P;
|
|
716
|
+
for (let _ = 0; _ < t.length; _++) {
|
|
717
|
+
const m = t[_], y = C.current.get(m.label);
|
|
718
|
+
if (!y) continue;
|
|
719
|
+
const R = h?.get(y), L = R && "value" in R ? R.value : void 0;
|
|
720
|
+
let N;
|
|
721
|
+
if (L !== void 0)
|
|
722
|
+
N = L;
|
|
723
|
+
else if (s) {
|
|
724
|
+
const X = Number(u), Q = m.data.length > 0 ? Number(m.data[0].time) : Number.POSITIVE_INFINITY;
|
|
725
|
+
X < Q ? N = Number.NaN : N = m.data[m.data.length - 1]?.value ?? 0;
|
|
726
|
+
} else {
|
|
727
|
+
const X = m.data.length > 0 ? Number(m.data[0].time) : Number.POSITIVE_INFINITY;
|
|
728
|
+
if (Number(u) < X) continue;
|
|
729
|
+
N = St(m.data, Number(u));
|
|
730
|
+
}
|
|
731
|
+
Number.isNaN(N) || (P === void 0 && (P = N), W.set(m.label, { value: N, time: u }));
|
|
655
732
|
}
|
|
656
|
-
if (
|
|
657
|
-
const m =
|
|
658
|
-
if (m !== null &&
|
|
659
|
-
const
|
|
660
|
-
if (
|
|
661
|
-
const
|
|
733
|
+
if (me(W), P !== void 0 && S[0]) {
|
|
734
|
+
const m = o.timeScale().timeToCoordinate(u), y = S[0].priceToCoordinate(P);
|
|
735
|
+
if (m !== null && y !== null) {
|
|
736
|
+
const R = K.current;
|
|
737
|
+
if (R) {
|
|
738
|
+
const L = R.querySelector(
|
|
662
739
|
".LightweightChart"
|
|
663
740
|
);
|
|
664
|
-
if (
|
|
665
|
-
const
|
|
666
|
-
|
|
741
|
+
if (L) {
|
|
742
|
+
const N = L.getBoundingClientRect(), X = R.getBoundingClientRect(), Q = m + (N.left - X.left), te = y + (N.top - X.top);
|
|
743
|
+
O({ x: Q, y: te });
|
|
667
744
|
} else
|
|
668
|
-
|
|
745
|
+
O({ x: m, y });
|
|
669
746
|
} else
|
|
670
|
-
|
|
747
|
+
O({ x: m, y });
|
|
671
748
|
} else
|
|
672
|
-
|
|
749
|
+
O(null);
|
|
673
750
|
} else
|
|
674
|
-
|
|
751
|
+
O(null);
|
|
675
752
|
};
|
|
676
|
-
return
|
|
677
|
-
const i = Array.from(
|
|
678
|
-
if (i[0] &&
|
|
679
|
-
const
|
|
680
|
-
|
|
753
|
+
return o.subscribeCrosshairMove(a), V && o.subscribeClick(a), !s && !A && !he && requestAnimationFrame(() => {
|
|
754
|
+
const i = Array.from(C.current.values());
|
|
755
|
+
if (i[0] && n && t[0]?.data.length > 0) {
|
|
756
|
+
const h = o.timeScale().timeToCoordinate(n), b = t[0].data[t[0].data.length - 1].value, S = i[0].priceToCoordinate(b);
|
|
757
|
+
h !== null && S !== null && O({ x: h, y: S });
|
|
681
758
|
}
|
|
682
759
|
}), () => {
|
|
683
|
-
|
|
760
|
+
o.unsubscribeCrosshairMove(a), V && o.unsubscribeClick(a);
|
|
684
761
|
};
|
|
685
|
-
}, [
|
|
686
|
-
const
|
|
687
|
-
if (!
|
|
688
|
-
const
|
|
689
|
-
const
|
|
690
|
-
if (
|
|
691
|
-
const i =
|
|
762
|
+
}, [t, A, V, he]), E(() => {
|
|
763
|
+
const o = z.current;
|
|
764
|
+
if (!o || t.length === 0) return;
|
|
765
|
+
const s = o.timeScale(), n = () => {
|
|
766
|
+
const a = Re.current;
|
|
767
|
+
if (a.length === 0) return;
|
|
768
|
+
const i = s.getVisibleRange();
|
|
692
769
|
if (!i) return;
|
|
693
|
-
const
|
|
694
|
-
for (const
|
|
695
|
-
const
|
|
696
|
-
for (const
|
|
697
|
-
if (
|
|
698
|
-
for (const
|
|
699
|
-
const
|
|
700
|
-
|
|
770
|
+
const u = Number(i.from), h = Number(i.to);
|
|
771
|
+
for (const b of a) {
|
|
772
|
+
const S = [];
|
|
773
|
+
for (const W of t)
|
|
774
|
+
if (b.labels.has(W.label))
|
|
775
|
+
for (const P of W.data) {
|
|
776
|
+
const _ = Number(P.time);
|
|
777
|
+
_ >= u && _ <= h && S.push(P.value);
|
|
701
778
|
}
|
|
702
|
-
|
|
779
|
+
S.length > 0 && b.updateVisibleRange(S);
|
|
703
780
|
}
|
|
704
781
|
};
|
|
705
|
-
return
|
|
706
|
-
|
|
707
|
-
|
|
782
|
+
return s.subscribeVisibleLogicalRangeChange(n), () => {
|
|
783
|
+
s.unsubscribeVisibleLogicalRangeChange(
|
|
784
|
+
n
|
|
708
785
|
);
|
|
709
786
|
};
|
|
710
|
-
}, [
|
|
711
|
-
const
|
|
712
|
-
if (
|
|
713
|
-
const
|
|
714
|
-
for (const
|
|
715
|
-
const
|
|
716
|
-
...
|
|
717
|
-
...
|
|
787
|
+
}, [t]), E(() => {
|
|
788
|
+
const o = z.current, s = Array.from(C.current.values()), n = [];
|
|
789
|
+
if (o && s.length > 0 && x) {
|
|
790
|
+
const a = it(), i = s[0];
|
|
791
|
+
for (const u of x) {
|
|
792
|
+
const h = {
|
|
793
|
+
...a,
|
|
794
|
+
...u.options || {}
|
|
718
795
|
};
|
|
719
|
-
|
|
720
|
-
const
|
|
721
|
-
i.attachPrimitive(
|
|
796
|
+
h.color && (h.color = U(h.color, h.color));
|
|
797
|
+
const b = new ut(o, i, u.xCoordinate, h);
|
|
798
|
+
i.attachPrimitive(b), n.push(b);
|
|
722
799
|
}
|
|
723
800
|
}
|
|
724
801
|
return () => {
|
|
725
|
-
if (
|
|
726
|
-
const
|
|
727
|
-
for (const i of
|
|
728
|
-
|
|
802
|
+
if (s.length > 0) {
|
|
803
|
+
const a = s[0];
|
|
804
|
+
for (const i of n)
|
|
805
|
+
a.detachPrimitive(i);
|
|
729
806
|
}
|
|
730
807
|
};
|
|
731
|
-
}, [x,
|
|
732
|
-
const
|
|
733
|
-
if (
|
|
734
|
-
const
|
|
808
|
+
}, [x, t]), E(() => {
|
|
809
|
+
const o = [], s = [];
|
|
810
|
+
if (M && M.length > 0) {
|
|
811
|
+
const n = Array.from(C.current.values())[0], a = U(
|
|
735
812
|
"hsl(var(--destructive))",
|
|
736
813
|
"rgb(239, 68, 68)"
|
|
737
814
|
);
|
|
738
|
-
for (const
|
|
739
|
-
if (!Number.isFinite(
|
|
740
|
-
const
|
|
741
|
-
if (!
|
|
742
|
-
const
|
|
743
|
-
price:
|
|
744
|
-
color:
|
|
745
|
-
lineWidth:
|
|
746
|
-
lineStyle:
|
|
747
|
-
axisLabelVisible:
|
|
748
|
-
title:
|
|
815
|
+
for (const i of M) {
|
|
816
|
+
if (!Number.isFinite(i.price)) continue;
|
|
817
|
+
const u = i.seriesLabel ? C.current.get(i.seriesLabel) : n;
|
|
818
|
+
if (!u) continue;
|
|
819
|
+
const h = i.color ? U(i.color, i.color) : a, b = i.lineWidth ?? 1, S = i.lineStyle ?? ee.Dashed, W = u.createPriceLine({
|
|
820
|
+
price: i.price,
|
|
821
|
+
color: h,
|
|
822
|
+
lineWidth: b,
|
|
823
|
+
lineStyle: S,
|
|
824
|
+
axisLabelVisible: i.axisLabelVisible ?? !0,
|
|
825
|
+
title: i.title ?? ""
|
|
749
826
|
});
|
|
750
|
-
|
|
827
|
+
o.push({ series: u, line: W });
|
|
828
|
+
const P = new bt(
|
|
829
|
+
u,
|
|
830
|
+
i.price,
|
|
831
|
+
h,
|
|
832
|
+
b,
|
|
833
|
+
S
|
|
834
|
+
);
|
|
835
|
+
u.attachPrimitive(P), s.push({ series: u, primitive: P });
|
|
751
836
|
}
|
|
752
837
|
}
|
|
753
838
|
return () => {
|
|
754
|
-
for (const { series:
|
|
839
|
+
for (const { series: n, primitive: a } of s)
|
|
755
840
|
try {
|
|
756
|
-
|
|
841
|
+
n.detachPrimitive(a);
|
|
842
|
+
} catch {
|
|
843
|
+
}
|
|
844
|
+
for (const { series: n, line: a } of o)
|
|
845
|
+
try {
|
|
846
|
+
n.removePriceLine(a);
|
|
757
847
|
} catch {
|
|
758
848
|
}
|
|
759
849
|
};
|
|
760
|
-
}, [
|
|
761
|
-
const
|
|
762
|
-
if (
|
|
763
|
-
const
|
|
764
|
-
for (const
|
|
765
|
-
const i =
|
|
850
|
+
}, [M, t]), E(() => {
|
|
851
|
+
const o = [];
|
|
852
|
+
if (j && j.length > 0) {
|
|
853
|
+
const s = Array.from(C.current.values())[0], n = "rgba(239, 68, 68, 0.12)";
|
|
854
|
+
for (const a of j) {
|
|
855
|
+
const i = a.seriesLabel ? C.current.get(a.seriesLabel) : s;
|
|
766
856
|
if (!i) continue;
|
|
767
|
-
const
|
|
857
|
+
const u = a.color ? U(a.color, n) : n, h = new dt(
|
|
768
858
|
i,
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
859
|
+
a.priceTop,
|
|
860
|
+
a.priceBottom,
|
|
861
|
+
u
|
|
772
862
|
);
|
|
773
|
-
i.attachPrimitive(
|
|
863
|
+
i.attachPrimitive(h), o.push({ series: i, zone: h });
|
|
774
864
|
}
|
|
775
865
|
}
|
|
776
866
|
return () => {
|
|
777
|
-
for (const { series:
|
|
867
|
+
for (const { series: s, zone: n } of o)
|
|
778
868
|
try {
|
|
779
|
-
|
|
869
|
+
s.detachPrimitive(n);
|
|
780
870
|
} catch {
|
|
781
871
|
}
|
|
782
872
|
};
|
|
783
|
-
}, [
|
|
784
|
-
const
|
|
785
|
-
if (!
|
|
786
|
-
|
|
873
|
+
}, [j, t]), E(() => {
|
|
874
|
+
const o = z.current;
|
|
875
|
+
if (!o || !x?.length) {
|
|
876
|
+
De([]);
|
|
787
877
|
return;
|
|
788
878
|
}
|
|
789
|
-
const
|
|
790
|
-
const i =
|
|
791
|
-
|
|
879
|
+
const s = () => {
|
|
880
|
+
const i = o.timeScale(), u = x.map((h) => i.timeToCoordinate(h.xCoordinate) ?? null);
|
|
881
|
+
De(u);
|
|
792
882
|
};
|
|
793
|
-
|
|
794
|
-
const
|
|
795
|
-
|
|
883
|
+
s();
|
|
884
|
+
const n = o.timeScale(), a = () => {
|
|
885
|
+
s();
|
|
796
886
|
};
|
|
797
|
-
return
|
|
798
|
-
|
|
887
|
+
return n.subscribeVisibleLogicalRangeChange(a), () => {
|
|
888
|
+
n.unsubscribeVisibleLogicalRangeChange(a);
|
|
799
889
|
};
|
|
800
|
-
}, [x,
|
|
801
|
-
const
|
|
802
|
-
if (
|
|
803
|
-
const
|
|
804
|
-
if (
|
|
805
|
-
return
|
|
890
|
+
}, [x, t]);
|
|
891
|
+
const se = t.length === 1, Ie = Ce.useMemo(() => {
|
|
892
|
+
if (se && t.length > 0) {
|
|
893
|
+
const o = t[0];
|
|
894
|
+
if (o.data.length > 0)
|
|
895
|
+
return o.data[o.data.length - 1];
|
|
806
896
|
}
|
|
807
|
-
}, [
|
|
808
|
-
return /* @__PURE__ */
|
|
897
|
+
}, [se, t]);
|
|
898
|
+
return /* @__PURE__ */ ne(
|
|
809
899
|
"div",
|
|
810
900
|
{
|
|
811
901
|
ref: K,
|
|
812
|
-
className:
|
|
902
|
+
className: le(
|
|
813
903
|
"relative z-[1] w-full h-full overflow-hidden p-0",
|
|
814
|
-
|
|
904
|
+
l
|
|
815
905
|
),
|
|
816
906
|
children: [
|
|
817
|
-
|
|
907
|
+
fe != null && fe !== !1 && se ? /* @__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: fe }) }) : Xe && se && Ie && /* @__PURE__ */ w(
|
|
818
908
|
st,
|
|
819
909
|
{
|
|
820
|
-
point:
|
|
910
|
+
point: Ie,
|
|
821
911
|
xMeasureUnit: d,
|
|
822
|
-
yMeasureUnit:
|
|
823
|
-
decimals:
|
|
912
|
+
yMeasureUnit: v,
|
|
913
|
+
decimals: ue
|
|
824
914
|
}
|
|
825
915
|
),
|
|
826
|
-
|
|
916
|
+
Le && Me && /* @__PURE__ */ w(
|
|
827
917
|
ct,
|
|
828
918
|
{
|
|
829
|
-
points:
|
|
919
|
+
points: Le,
|
|
830
920
|
xMeasureUnit: d,
|
|
831
|
-
yMeasureUnit:
|
|
832
|
-
series:
|
|
833
|
-
position:
|
|
921
|
+
yMeasureUnit: v,
|
|
922
|
+
series: t,
|
|
923
|
+
position: Me,
|
|
834
924
|
containerRef: K,
|
|
835
|
-
decimals:
|
|
925
|
+
decimals: ue
|
|
836
926
|
}
|
|
837
927
|
),
|
|
838
|
-
|
|
839
|
-
x && x.length > 0 &&
|
|
928
|
+
f && /* @__PURE__ */ w(yt, { series: t, onUnselect: c }),
|
|
929
|
+
x && x.length > 0 && ke.length === x.length && /* @__PURE__ */ w(
|
|
840
930
|
"div",
|
|
841
931
|
{
|
|
842
932
|
className: "absolute inset-0 z-[5] pointer-events-none",
|
|
843
933
|
"aria-hidden": !0,
|
|
844
|
-
children: x.map((
|
|
845
|
-
const
|
|
846
|
-
if (
|
|
847
|
-
const { labelText:
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
),
|
|
852
|
-
if (!(
|
|
853
|
-
const
|
|
854
|
-
return /* @__PURE__ */
|
|
934
|
+
children: x.map((o, s) => {
|
|
935
|
+
const n = ke[s], a = o.options ?? {}, i = a.showLabel !== !1;
|
|
936
|
+
if (n === null || !i) return null;
|
|
937
|
+
const { labelText: u, valueStr: h } = vt(
|
|
938
|
+
a,
|
|
939
|
+
v,
|
|
940
|
+
ue
|
|
941
|
+
), b = a.tooltipText ?? "";
|
|
942
|
+
if (!(u || h || b)) return null;
|
|
943
|
+
const W = a.labelBackgroundColor ?? a.color ?? "hsl(var(--background))", P = a.labelTextColor ?? "hsl(var(--foreground))", _ = `${String(o.xCoordinate)}-${u}-${b}`;
|
|
944
|
+
return /* @__PURE__ */ ne(
|
|
855
945
|
"div",
|
|
856
946
|
{
|
|
857
|
-
className:
|
|
947
|
+
className: le(
|
|
858
948
|
"group absolute top-2 px-2 py-1 rounded text-xs font-medium whitespace-nowrap shadow-sm border border-border",
|
|
859
|
-
|
|
949
|
+
b && "pointer-events-auto cursor-default"
|
|
860
950
|
),
|
|
861
951
|
style: {
|
|
862
|
-
left:
|
|
952
|
+
left: n,
|
|
863
953
|
transform: "translateX(-50%)",
|
|
864
|
-
backgroundColor:
|
|
865
|
-
color:
|
|
954
|
+
backgroundColor: W,
|
|
955
|
+
color: P
|
|
866
956
|
},
|
|
867
957
|
children: [
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
958
|
+
u && /* @__PURE__ */ w("span", { className: "block", children: u }),
|
|
959
|
+
h && /* @__PURE__ */ w("span", { className: le("block", u && "mt-0.5"), children: h }),
|
|
960
|
+
b && /* @__PURE__ */ w(
|
|
871
961
|
"span",
|
|
872
962
|
{
|
|
873
963
|
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",
|
|
874
964
|
role: "tooltip",
|
|
875
|
-
children:
|
|
965
|
+
children: b
|
|
876
966
|
}
|
|
877
967
|
)
|
|
878
968
|
]
|
|
879
969
|
},
|
|
880
|
-
|
|
970
|
+
_
|
|
881
971
|
);
|
|
882
972
|
})
|
|
883
973
|
}
|
|
884
974
|
),
|
|
885
|
-
/* @__PURE__ */
|
|
975
|
+
/* @__PURE__ */ w(
|
|
886
976
|
"div",
|
|
887
977
|
{
|
|
888
|
-
ref:
|
|
978
|
+
ref: pe,
|
|
889
979
|
className: "LightweightChart w-full h-full overflow-hidden"
|
|
890
980
|
}
|
|
891
981
|
)
|
|
@@ -893,49 +983,49 @@ function Lt({
|
|
|
893
983
|
}
|
|
894
984
|
);
|
|
895
985
|
}
|
|
896
|
-
function
|
|
897
|
-
series:
|
|
898
|
-
onUnselect:
|
|
899
|
-
inline:
|
|
986
|
+
function yt({
|
|
987
|
+
series: t,
|
|
988
|
+
onUnselect: l,
|
|
989
|
+
inline: f = !1
|
|
900
990
|
}) {
|
|
901
|
-
return /* @__PURE__ */
|
|
991
|
+
return /* @__PURE__ */ w(
|
|
902
992
|
"div",
|
|
903
993
|
{
|
|
904
|
-
className:
|
|
994
|
+
className: le(
|
|
905
995
|
"flex flex-wrap gap-2",
|
|
906
|
-
|
|
996
|
+
f ? "items-center" : "absolute top-0 left-2 z-[10]"
|
|
907
997
|
),
|
|
908
|
-
children:
|
|
909
|
-
const
|
|
910
|
-
return /* @__PURE__ */
|
|
998
|
+
children: t.map((c, d) => {
|
|
999
|
+
const v = Oe(d), F = (c.lineColor ?? c.color) || v.line, x = c.data.length === 0;
|
|
1000
|
+
return /* @__PURE__ */ ne(
|
|
911
1001
|
"div",
|
|
912
1002
|
{
|
|
913
|
-
className:
|
|
1003
|
+
className: le(
|
|
914
1004
|
"flex items-center gap-1.5 px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border",
|
|
915
1005
|
x && "opacity-50"
|
|
916
1006
|
),
|
|
917
1007
|
children: [
|
|
918
|
-
/* @__PURE__ */
|
|
1008
|
+
/* @__PURE__ */ w(
|
|
919
1009
|
"div",
|
|
920
1010
|
{
|
|
921
1011
|
className: "w-3 h-3 rounded-sm",
|
|
922
|
-
style: { backgroundColor:
|
|
1012
|
+
style: { backgroundColor: F }
|
|
923
1013
|
}
|
|
924
1014
|
),
|
|
925
|
-
/* @__PURE__ */
|
|
926
|
-
|
|
1015
|
+
/* @__PURE__ */ ne("span", { className: "text-[10px] sm:text-xs font-medium text-foreground", children: [
|
|
1016
|
+
c.label,
|
|
927
1017
|
x && " (no data)"
|
|
928
1018
|
] }),
|
|
929
|
-
|
|
1019
|
+
l && /* @__PURE__ */ w(
|
|
930
1020
|
"button",
|
|
931
1021
|
{
|
|
932
1022
|
type: "button",
|
|
933
|
-
onClick: (
|
|
934
|
-
|
|
1023
|
+
onClick: (M) => {
|
|
1024
|
+
M.stopPropagation(), l(c.label);
|
|
935
1025
|
},
|
|
936
1026
|
className: "ml-1 flex items-center justify-center w-4 h-4 rounded-sm hover:bg-muted transition-colors cursor-pointer",
|
|
937
|
-
"aria-label": `Remove ${
|
|
938
|
-
children: /* @__PURE__ */
|
|
1027
|
+
"aria-label": `Remove ${c.label}`,
|
|
1028
|
+
children: /* @__PURE__ */ ne(
|
|
939
1029
|
"svg",
|
|
940
1030
|
{
|
|
941
1031
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -950,9 +1040,9 @@ function pt({
|
|
|
950
1040
|
className: "text-muted-foreground hover:text-foreground",
|
|
951
1041
|
"aria-hidden": "true",
|
|
952
1042
|
children: [
|
|
953
|
-
/* @__PURE__ */
|
|
954
|
-
/* @__PURE__ */
|
|
955
|
-
/* @__PURE__ */
|
|
1043
|
+
/* @__PURE__ */ w("title", { children: "Close" }),
|
|
1044
|
+
/* @__PURE__ */ w("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
|
|
1045
|
+
/* @__PURE__ */ w("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
|
|
956
1046
|
]
|
|
957
1047
|
}
|
|
958
1048
|
)
|
|
@@ -960,17 +1050,17 @@ function pt({
|
|
|
960
1050
|
)
|
|
961
1051
|
]
|
|
962
1052
|
},
|
|
963
|
-
|
|
1053
|
+
c.label
|
|
964
1054
|
);
|
|
965
1055
|
})
|
|
966
1056
|
}
|
|
967
1057
|
);
|
|
968
1058
|
}
|
|
969
1059
|
export {
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
1060
|
+
we as DEFAULT_SERIES_COLORS,
|
|
1061
|
+
Bt as Graph,
|
|
1062
|
+
yt as GraphLegend,
|
|
1063
|
+
Oe as getSeriesColorPalette,
|
|
1064
|
+
St as getStepForwardValue,
|
|
1065
|
+
vt as getVerticalLineTooltipContent
|
|
976
1066
|
};
|