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