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