@tradecanvas/chart 1.23.0 → 1.24.0
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/README.md +1 -1
- package/dist/Chart.d.ts +13 -0
- package/dist/Chart.d.ts.map +1 -1
- package/dist/LayoutSession-CdiNNoci.cjs +2 -0
- package/dist/LayoutSession-CdiNNoci.cjs.map +1 -0
- package/dist/{LayoutSession-B7RJJGZJ.js → LayoutSession-CrMUvvtP.js} +335 -317
- package/dist/LayoutSession-CrMUvvtP.js.map +1 -0
- package/dist/i18n-C040vB8g.cjs +2 -0
- package/dist/i18n-C040vB8g.cjs.map +1 -0
- package/dist/{i18n-fBzhlejv.js → i18n-FG3D2x5m.js} +3 -1
- package/dist/i18n-FG3D2x5m.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/widget/ChartWidget.d.ts +16 -0
- package/dist/widget/ChartWidget.d.ts.map +1 -1
- package/dist/widget/WidgetDrawingStyle.d.ts +4 -0
- package/dist/widget/WidgetDrawingStyle.d.ts.map +1 -1
- package/dist/widget/WidgetSelectionToolbar.d.ts +75 -0
- package/dist/widget/WidgetSelectionToolbar.d.ts.map +1 -0
- package/dist/widget/index.cjs +112 -3
- package/dist/widget/index.cjs.map +1 -1
- package/dist/widget/index.js +996 -738
- package/dist/widget/index.js.map +1 -1
- package/dist/widget/locales/ar.d.ts.map +1 -1
- package/dist/widget/locales/cs.d.ts.map +1 -1
- package/dist/widget/locales/da.d.ts.map +1 -1
- package/dist/widget/locales/de.d.ts.map +1 -1
- package/dist/widget/locales/el.d.ts.map +1 -1
- package/dist/widget/locales/en.d.ts +1 -0
- package/dist/widget/locales/en.d.ts.map +1 -1
- package/dist/widget/locales/es.d.ts.map +1 -1
- package/dist/widget/locales/et.d.ts.map +1 -1
- package/dist/widget/locales/fa.d.ts.map +1 -1
- package/dist/widget/locales/fr.d.ts.map +1 -1
- package/dist/widget/locales/he.d.ts.map +1 -1
- package/dist/widget/locales/hu.d.ts.map +1 -1
- package/dist/widget/locales/id.d.ts.map +1 -1
- package/dist/widget/locales/index.cjs +1 -1
- package/dist/widget/locales/index.cjs.map +1 -1
- package/dist/widget/locales/index.js +29 -1
- package/dist/widget/locales/index.js.map +1 -1
- package/dist/widget/locales/it.d.ts.map +1 -1
- package/dist/widget/locales/ja.d.ts.map +1 -1
- package/dist/widget/locales/ko.d.ts.map +1 -1
- package/dist/widget/locales/ms.d.ts.map +1 -1
- package/dist/widget/locales/nb.d.ts.map +1 -1
- package/dist/widget/locales/nl.d.ts.map +1 -1
- package/dist/widget/locales/pl.d.ts.map +1 -1
- package/dist/widget/locales/pt.d.ts.map +1 -1
- package/dist/widget/locales/ro.d.ts.map +1 -1
- package/dist/widget/locales/ru.d.ts.map +1 -1
- package/dist/widget/locales/sk.d.ts.map +1 -1
- package/dist/widget/locales/sv.d.ts.map +1 -1
- package/dist/widget/locales/th.d.ts.map +1 -1
- package/dist/widget/locales/tr.d.ts.map +1 -1
- package/dist/widget/locales/vi.d.ts.map +1 -1
- package/dist/widget/locales/zh.d.ts.map +1 -1
- package/dist/widget/locales/zhHant.d.ts.map +1 -1
- package/dist/widget/widgetFeatures.d.ts +1 -1
- package/dist/widget/widgetFeatures.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/LayoutSession-B7RJJGZJ.js.map +0 -1
- package/dist/LayoutSession-b3U60maf.cjs +0 -2
- package/dist/LayoutSession-b3U60maf.cjs.map +0 -1
- package/dist/i18n-CIHfGH-4.cjs +0 -2
- package/dist/i18n-CIHfGH-4.cjs.map +0 -1
- package/dist/i18n-fBzhlejv.js.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { DARK_THEME as e, DEFAULT_PANEL_HEIGHT as t, LIGHT_THEME as n, LayerType as r, MIN_PANEL_HEIGHT as i, PRICE_AXIS_WIDTH as a, TIME_AXIS_HEIGHT as o, autoPricePrecision as s, chartStyleValue as c, computePriceLimits as l, formatPrice as u, fractionTick as d, indicatorSource as f, isValidTimeZone as p, mergeBar as m, normalizeBarTime as h, parseIndicatorSource as g, priceFormatterFor as _, priceStepAt as v, readChartStyleOverrides as
|
|
2
|
-
import { AlertDragHandler as
|
|
1
|
+
import { DARK_THEME as e, DEFAULT_PANEL_HEIGHT as t, LIGHT_THEME as n, LayerType as r, MIN_PANEL_HEIGHT as i, PRICE_AXIS_WIDTH as a, TIME_AXIS_HEIGHT as o, autoPricePrecision as s, chartStyleValue as c, computePriceLimits as l, formatPrice as u, fractionTick as d, indicatorSource as f, isValidTimeZone as p, mergeBar as m, normalizeBarTime as h, parseIndicatorSource as g, priceFormatterFor as _, priceStepAt as v, readChartStyleOverrides as y, readChartTypeOptions as b, readIndicatorPlotStyles as ee, readPaneStyle as x, resolveChartTheme as te, sessionMinute as S, setLocale as ne, stepDecimals as re, tickBarCount as ie, timeframeToMs as ae, volumeColor as oe, zonedDateFormatter as se } from "@tradecanvas/commons";
|
|
2
|
+
import { AlertDragHandler as ce, AlertManager as le, Animator as ue, AreaRenderer as de, AxisDragHandler as fe, BarCountdown as pe, BarRenderer as me, BaselineRenderer as he, CandlestickRenderer as ge, ChartLegend as _e, ChartStateManager as C, CompareRenderer as ve, CompareSymbolIndicator as ye, CorrelationCoefficientIndicator as be, CorrelationLogIndicator as xe, CrosshairHandler as Se, CrosshairTooltip as Ce, CurrentPriceLine as we, DEFAULT_SESSION_HOURS as Te, DataExporter as w, DepthHeatmapRenderer as Ee, DrawingManager as De, DrawingRenderer as Oe, EquivolumeRenderer as ke, EventBus as Ae, GridRenderer as je, HLCAreaRenderer as Me, HiLoRenderer as T, HollowCandleRenderer as Ne, IndicatorEngine as E, InteractionManager as Pe, KagiRenderer as Fe, KeyboardHandler as Ie, LineRenderer as Le, LineWithMarkersRenderer as Re, MarketProfileRenderer as ze, MeasureOverlay as Be, PanHandler as Ve, PaneResizeHandler as He, PeriodLevelsRenderer as Ue, PinnedTooltip as We, PivotMarkersRenderer as Ge, PointAndFigureRenderer as D, PriceAxis as O, PriceAxisAddButton as Ke, PriceLines as qe, RenderEngine as Je, RenkoRenderer as Ye, ReplayManager as Xe, Screenshot as k, SelectionBoxOverlay as Ze, SessionBreaks as Qe, SessionShading as $e, SignalMarkerManager as et, SpreadIndicator as tt, StepLineRenderer as nt, StreamManager as rt, SymbolSeriesStore as it, TimeAxis as at, TradeZoneManager as ot, TradingManager as st, TradingRenderer as ct, UndoRedoManager as lt, Viewport as ut, VolumeCandleRenderer as dt, VolumeProfileRenderer as ft, VolumeRenderer as pt, Watermark as mt, ZoomHandler as ht, barTimeStepMs as gt, findDominantSwing as _t, gpuContextsLeft as vt, isRegularSession as yt, loadWebGL as bt, mergeSessionHours as xt, priceToY as St, rangePresetStart as Ct, readAlertOptions as wt, registerBuiltInDrawingTools as Tt, registerBuiltInIndicators as A, servesTimeframe as j, sourceParam as M, timeToX as Et, timestampToBarIndex as N, toHeikinAshi as Dt, toKagi as Ot, toLineBreak as kt, toPointAndFigure as At, toRangeBars as jt, toRenko as P, whenGpuContextFree as Mt, withResampling as Nt, xToBarIndex as Pt, xToTime as F, yToPrice as Ft } from "@tradecanvas/core";
|
|
3
3
|
//#region src/regularHours.ts
|
|
4
|
-
var
|
|
5
|
-
function
|
|
4
|
+
var It = 864e5, Lt = 10;
|
|
5
|
+
function Rt(e, t) {
|
|
6
6
|
let n = e?.timezone;
|
|
7
7
|
if (!n || !p(n) || t.length < 2) return null;
|
|
8
8
|
let r = (e?.sessions ?? []).flatMap((e) => {
|
|
9
|
-
let t =
|
|
9
|
+
let t = S(e.start), n = S(e.end);
|
|
10
10
|
return t === null || n === null ? [] : [{
|
|
11
11
|
startMinute: t,
|
|
12
12
|
endMinute: n
|
|
@@ -14,34 +14,34 @@ function Ht(e, t) {
|
|
|
14
14
|
});
|
|
15
15
|
if (r.length === 0) return null;
|
|
16
16
|
let i = Infinity;
|
|
17
|
-
for (let e = Math.max(1, t.length -
|
|
17
|
+
for (let e = Math.max(1, t.length - Lt); e < t.length; e++) {
|
|
18
18
|
let n = h(t[e].time) - h(t[e - 1].time);
|
|
19
19
|
n > 0 && n < i && (i = n);
|
|
20
20
|
}
|
|
21
|
-
if (!(i <
|
|
21
|
+
if (!(i < It)) return null;
|
|
22
22
|
let a = {
|
|
23
23
|
timeZone: n,
|
|
24
24
|
windows: r,
|
|
25
25
|
startMinute: r[0].startMinute,
|
|
26
26
|
endMinute: r[r.length - 1].endMinute
|
|
27
27
|
};
|
|
28
|
-
return (e) =>
|
|
28
|
+
return (e) => yt(h(e), a);
|
|
29
29
|
}
|
|
30
30
|
//#endregion
|
|
31
31
|
//#region src/chartA11y.ts
|
|
32
|
-
var
|
|
32
|
+
var zt = {
|
|
33
33
|
role: "chart",
|
|
34
34
|
summary: "{what}. Last price {close}.",
|
|
35
35
|
empty: "Chart, no data.",
|
|
36
36
|
view: "Showing {count} bars, {from} to {to}. High {high}, low {low}.",
|
|
37
37
|
bar: "{time}: open {open}, high {high}, low {low}, close {close}, volume {volume}.",
|
|
38
38
|
keys: "Arrow keys scroll and zoom, Home and End go to the start and the end. Comma and period read the bars one at a time."
|
|
39
|
-
},
|
|
39
|
+
}, I = (e, t) => e.replace(/\{(\w+)\}/g, (e, n) => n in t ? String(t[n]) : e), Bt = [
|
|
40
40
|
"role",
|
|
41
41
|
"aria-roledescription",
|
|
42
42
|
"aria-label",
|
|
43
43
|
"aria-describedby"
|
|
44
|
-
],
|
|
44
|
+
], Vt = 400, Ht = 1e3, Ut = class {
|
|
45
45
|
live;
|
|
46
46
|
help;
|
|
47
47
|
labels;
|
|
@@ -55,20 +55,20 @@ var Ut = {
|
|
|
55
55
|
};
|
|
56
56
|
constructor(e, t, n = {}) {
|
|
57
57
|
this.container = e, this.source = t, this.labels = {
|
|
58
|
-
...
|
|
58
|
+
...zt,
|
|
59
59
|
...n
|
|
60
60
|
};
|
|
61
|
-
for (let t of
|
|
62
|
-
e.setAttribute("role", "application"), this.help =
|
|
61
|
+
for (let t of Bt) this.before.set(t, e.getAttribute(t));
|
|
62
|
+
e.setAttribute("role", "application"), this.help = Wt("div", "tc-sr-only"), this.help.id = `tc-chart-keys-${Math.random().toString(36).slice(2, 10)}`, e.setAttribute("aria-describedby", this.help.id), this.live = Wt("div", "tc-sr-only tc-sr-live"), this.live.setAttribute("aria-live", "polite"), this.live.setAttribute("aria-atomic", "true"), e.append(this.help, this.live), e.addEventListener("blur", this.onBlur), this.applyLabels();
|
|
63
63
|
}
|
|
64
64
|
setLabels(e) {
|
|
65
65
|
this.labels = {
|
|
66
|
-
...
|
|
66
|
+
...zt,
|
|
67
67
|
...e
|
|
68
68
|
}, this.applyLabels();
|
|
69
69
|
}
|
|
70
70
|
refresh(e = !1) {
|
|
71
|
-
let t =
|
|
71
|
+
let t = Ht - (Date.now() - this.summaryAt);
|
|
72
72
|
if (e || t <= 0 || this.container.getAttribute("aria-label") === this.labels.empty) {
|
|
73
73
|
this.summaryTimer && clearTimeout(this.summaryTimer), this.summaryTimer = null, this.summaryAt = Date.now(), this.container.setAttribute("aria-label", this.summary());
|
|
74
74
|
return;
|
|
@@ -80,7 +80,7 @@ var Ut = {
|
|
|
80
80
|
viewMoved() {
|
|
81
81
|
this.cursor = null, this.viewTimer && clearTimeout(this.viewTimer), this.viewTimer = setTimeout(() => {
|
|
82
82
|
this.viewTimer = null, this.say(this.viewText());
|
|
83
|
-
},
|
|
83
|
+
}, Vt);
|
|
84
84
|
}
|
|
85
85
|
readBar(e) {
|
|
86
86
|
let t = this.source.bars();
|
|
@@ -93,13 +93,13 @@ var Ut = {
|
|
|
93
93
|
let i = t[this.cursor];
|
|
94
94
|
this.source.showBar(i.time);
|
|
95
95
|
let a = this.source.formatPrice;
|
|
96
|
-
this.say(
|
|
96
|
+
this.say(I(this.labels.bar, {
|
|
97
97
|
time: this.source.formatTime(i.time),
|
|
98
98
|
open: a(i.open),
|
|
99
99
|
high: a(i.high),
|
|
100
100
|
low: a(i.low),
|
|
101
101
|
close: a(i.close),
|
|
102
|
-
volume:
|
|
102
|
+
volume: Gt(i.volume ?? 0)
|
|
103
103
|
}));
|
|
104
104
|
}
|
|
105
105
|
destroy() {
|
|
@@ -118,7 +118,7 @@ var Ut = {
|
|
|
118
118
|
this.labels.typeName ? this.labels.typeName(t) : t,
|
|
119
119
|
this.source.timeframe()
|
|
120
120
|
].filter(Boolean).join(", ");
|
|
121
|
-
return
|
|
121
|
+
return I(this.labels.summary, {
|
|
122
122
|
what: n,
|
|
123
123
|
close: this.source.formatPrice(e[e.length - 1].close)
|
|
124
124
|
});
|
|
@@ -128,7 +128,7 @@ var Ut = {
|
|
|
128
128
|
if (e.length === 0) return this.labels.empty;
|
|
129
129
|
let t = this.source.visibleRange(), n = Math.max(0, Math.min(e.length - 1, Math.ceil(t.from))), r = Math.max(n, Math.min(e.length - 1, Math.floor(t.to))), i = -Infinity, a = Infinity;
|
|
130
130
|
for (let t = n; t <= r; t++) i = Math.max(i, e[t].high), a = Math.min(a, e[t].low);
|
|
131
|
-
return
|
|
131
|
+
return I(this.labels.view, {
|
|
132
132
|
count: r - n + 1,
|
|
133
133
|
from: this.source.formatTime(e[n].time),
|
|
134
134
|
to: this.source.formatTime(e[r].time),
|
|
@@ -140,7 +140,7 @@ var Ut = {
|
|
|
140
140
|
this.live.textContent = e;
|
|
141
141
|
}
|
|
142
142
|
};
|
|
143
|
-
function
|
|
143
|
+
function Wt(e, t) {
|
|
144
144
|
let n = document.createElement(e);
|
|
145
145
|
return n.className = t, Object.assign(n.style, {
|
|
146
146
|
position: "absolute",
|
|
@@ -154,12 +154,12 @@ function Jt(e, t) {
|
|
|
154
154
|
border: "0"
|
|
155
155
|
}), n;
|
|
156
156
|
}
|
|
157
|
-
function
|
|
157
|
+
function Gt(e) {
|
|
158
158
|
return Number.isInteger(e) ? String(e) : e.toFixed(2);
|
|
159
159
|
}
|
|
160
160
|
//#endregion
|
|
161
161
|
//#region src/indicatorLabel.ts
|
|
162
|
-
function
|
|
162
|
+
function Kt(e, t, n, r) {
|
|
163
163
|
let i = Object.keys(n || t).map((e) => t[e]).filter((e) => typeof e == "number" && Number.isFinite(e)).slice(0, 3).map((e) => String(Number(e.toFixed(4)))), a = typeof t.symbol == "string" && t.symbol ? [t.symbol] : [];
|
|
164
164
|
return [
|
|
165
165
|
e === "spread" && t.mode === "ratio" ? "Ratio" : r ?? e.toUpperCase(),
|
|
@@ -169,52 +169,52 @@ function Xt(e, t, n, r) {
|
|
|
169
169
|
}
|
|
170
170
|
//#endregion
|
|
171
171
|
//#region src/charts/ChartTypeStrategy.ts
|
|
172
|
-
function
|
|
172
|
+
function qt(e) {
|
|
173
173
|
switch (e) {
|
|
174
174
|
case "candlestick":
|
|
175
175
|
case "heikinAshi":
|
|
176
176
|
case "lineBreak":
|
|
177
|
-
case "rangeBars": return new
|
|
178
|
-
case "line": return new
|
|
179
|
-
case "area": return new
|
|
180
|
-
case "bar": return new
|
|
181
|
-
case "hollowCandle": return new
|
|
182
|
-
case "baseline": return new
|
|
183
|
-
case "renko": return new
|
|
184
|
-
case "kagi": return new
|
|
185
|
-
case "pointAndFigure": return new
|
|
186
|
-
case "volumeCandles": return new
|
|
187
|
-
case "equivolume": return new
|
|
188
|
-
case "hlcArea": return new
|
|
189
|
-
case "stepLine": return new
|
|
190
|
-
case "lineWithMarkers": return new
|
|
191
|
-
case "hiLo": return new
|
|
192
|
-
default: return new
|
|
177
|
+
case "rangeBars": return new ge();
|
|
178
|
+
case "line": return new Le();
|
|
179
|
+
case "area": return new de();
|
|
180
|
+
case "bar": return new me();
|
|
181
|
+
case "hollowCandle": return new Ne();
|
|
182
|
+
case "baseline": return new he();
|
|
183
|
+
case "renko": return new Ye();
|
|
184
|
+
case "kagi": return new Fe();
|
|
185
|
+
case "pointAndFigure": return new D();
|
|
186
|
+
case "volumeCandles": return new dt();
|
|
187
|
+
case "equivolume": return new ke();
|
|
188
|
+
case "hlcArea": return new Me();
|
|
189
|
+
case "stepLine": return new nt();
|
|
190
|
+
case "lineWithMarkers": return new Re();
|
|
191
|
+
case "hiLo": return new T();
|
|
192
|
+
default: return new ge();
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
|
-
function
|
|
195
|
+
function Jt(e, t, n = {}) {
|
|
196
196
|
if (t.length === 0) return t;
|
|
197
197
|
switch (e) {
|
|
198
|
-
case "heikinAshi": return
|
|
198
|
+
case "heikinAshi": return Dt(t);
|
|
199
199
|
case "renko": {
|
|
200
200
|
let e = n.renko?.boxSize;
|
|
201
|
-
return typeof e == "number" ?
|
|
201
|
+
return typeof e == "number" ? P(t, { brickSize: e }) : P(t, {
|
|
202
202
|
brickSize: 0,
|
|
203
203
|
useATR: !0,
|
|
204
204
|
atrPeriod: n.renko?.atrPeriod ?? 14
|
|
205
205
|
});
|
|
206
206
|
}
|
|
207
|
-
case "lineBreak": return
|
|
208
|
-
case "kagi": return
|
|
209
|
-
case "pointAndFigure": return
|
|
207
|
+
case "lineBreak": return kt(t, n.lineBreak?.lines ?? 3);
|
|
208
|
+
case "kagi": return Ot(t, n.kagi?.reversal ?? 4, n.kagi?.reversalType ?? "percent");
|
|
209
|
+
case "pointAndFigure": return At(t, Xt(t, n), n.pointAndFigure?.reversal ?? 3);
|
|
210
210
|
case "rangeBars": {
|
|
211
211
|
let e = n.rangeBars?.range;
|
|
212
|
-
return
|
|
212
|
+
return jt(t, { rangeSize: typeof e == "number" ? e : Zt(t) * .005 });
|
|
213
213
|
}
|
|
214
214
|
default: return t;
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
-
function
|
|
217
|
+
function Yt(e) {
|
|
218
218
|
switch (e) {
|
|
219
219
|
case "heikinAshi":
|
|
220
220
|
case "renko":
|
|
@@ -225,30 +225,30 @@ function $t(e) {
|
|
|
225
225
|
default: return !1;
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
|
-
function
|
|
229
|
-
return e !== "heikinAshi" &&
|
|
228
|
+
function L(e) {
|
|
229
|
+
return e !== "heikinAshi" && Yt(e);
|
|
230
230
|
}
|
|
231
|
-
function
|
|
231
|
+
function Xt(e, t = {}) {
|
|
232
232
|
let n = t.pointAndFigure?.boxSize;
|
|
233
|
-
return typeof n == "number" ? n :
|
|
233
|
+
return typeof n == "number" ? n : Zt(e) * .01;
|
|
234
234
|
}
|
|
235
|
-
function
|
|
235
|
+
function Zt(e) {
|
|
236
236
|
let t = 0;
|
|
237
237
|
for (let n of e) t += n.close;
|
|
238
238
|
return t / e.length;
|
|
239
239
|
}
|
|
240
|
-
function
|
|
240
|
+
function Qt(e, t) {
|
|
241
241
|
let n = t?.(e);
|
|
242
|
-
return n ? n.createRenderer() :
|
|
242
|
+
return n ? n.createRenderer() : qt(e);
|
|
243
243
|
}
|
|
244
|
-
function
|
|
244
|
+
function $t(e, t, n, r) {
|
|
245
245
|
if (t.length === 0) return t;
|
|
246
246
|
let i = n?.(e);
|
|
247
|
-
return i?.transform ? i.transform(t) :
|
|
247
|
+
return i?.transform ? i.transform(t) : Jt(e, t, r);
|
|
248
248
|
}
|
|
249
249
|
//#endregion
|
|
250
250
|
//#region src/state/AutoSaveScheduler.ts
|
|
251
|
-
var
|
|
251
|
+
var en = class {
|
|
252
252
|
timer = null;
|
|
253
253
|
delayMs = 0;
|
|
254
254
|
key = null;
|
|
@@ -278,15 +278,15 @@ var nn = class {
|
|
|
278
278
|
};
|
|
279
279
|
//#endregion
|
|
280
280
|
//#region src/DataManager.ts
|
|
281
|
-
function
|
|
281
|
+
function R(e) {
|
|
282
282
|
if (!e || typeof e.time != "number" || !Number.isFinite(e.time)) return !1;
|
|
283
283
|
let { open: t, high: n, low: r, close: i } = e;
|
|
284
284
|
return !(!isFinite(t) || !isFinite(n) || !isFinite(r) || !isFinite(i) || t < 0 || n < 0 || r < 0 || i < 0 || n < r || e.volume !== void 0 && (!isFinite(e.volume) || e.volume < 0));
|
|
285
285
|
}
|
|
286
|
-
function
|
|
286
|
+
function tn(e) {
|
|
287
287
|
return e.volume !== void 0 && e.high >= e.open && e.high >= e.close && e.low <= e.open && e.low <= e.close;
|
|
288
288
|
}
|
|
289
|
-
function
|
|
289
|
+
function z(e) {
|
|
290
290
|
return {
|
|
291
291
|
...e,
|
|
292
292
|
high: Math.max(e.open, e.high, e.low, e.close),
|
|
@@ -294,7 +294,7 @@ function I(e) {
|
|
|
294
294
|
volume: e.volume === void 0 ? 0 : Math.max(0, e.volume)
|
|
295
295
|
};
|
|
296
296
|
}
|
|
297
|
-
var
|
|
297
|
+
var B = class {
|
|
298
298
|
data = [];
|
|
299
299
|
getData() {
|
|
300
300
|
return this.data;
|
|
@@ -303,7 +303,7 @@ var L = class {
|
|
|
303
303
|
let t = [];
|
|
304
304
|
for (let n = 0; n < e.length; n++) {
|
|
305
305
|
let r = e[n];
|
|
306
|
-
|
|
306
|
+
R(r) && t.push(tn(r) ? r : z(r));
|
|
307
307
|
}
|
|
308
308
|
this.data = t;
|
|
309
309
|
}
|
|
@@ -311,7 +311,7 @@ var L = class {
|
|
|
311
311
|
let t = this.data.length > 0 ? this.data[0].time : Infinity, n = [];
|
|
312
312
|
for (let r = 0; r < e.length; r++) {
|
|
313
313
|
let i = e[r];
|
|
314
|
-
!
|
|
314
|
+
!R(i) || i.time >= t || n.push(tn(i) ? i : z(i));
|
|
315
315
|
}
|
|
316
316
|
if (n.length === 0) return 0;
|
|
317
317
|
n.sort((e, t) => e.time - t.time);
|
|
@@ -320,11 +320,11 @@ var L = class {
|
|
|
320
320
|
return n.length = r, this.data = n.concat(this.data), r;
|
|
321
321
|
}
|
|
322
322
|
appendBar(e) {
|
|
323
|
-
|
|
323
|
+
R(e) && this.data.push(z(e));
|
|
324
324
|
}
|
|
325
325
|
updateLastBar(e) {
|
|
326
|
-
if (!
|
|
327
|
-
let t =
|
|
326
|
+
if (!R(e)) return;
|
|
327
|
+
let t = z(e);
|
|
328
328
|
if (this.data.length === 0) {
|
|
329
329
|
this.data.push(t);
|
|
330
330
|
return;
|
|
@@ -340,7 +340,7 @@ var L = class {
|
|
|
340
340
|
clear() {
|
|
341
341
|
this.data = [];
|
|
342
342
|
}
|
|
343
|
-
},
|
|
343
|
+
}, nn = 5e3, rn = 6e4, an = 500, on = class {
|
|
344
344
|
loader = null;
|
|
345
345
|
pageSize = 500;
|
|
346
346
|
loading = !1;
|
|
@@ -381,7 +381,7 @@ var L = class {
|
|
|
381
381
|
try {
|
|
382
382
|
r = await e(t, this.pageSize);
|
|
383
383
|
} catch (e) {
|
|
384
|
-
return n === this.seq ? (this.loading = !1, this.failures++, this.retryAt = this.now() + Math.min(rn,
|
|
384
|
+
return n === this.seq ? (this.loading = !1, this.failures++, this.retryAt = this.now() + Math.min(rn, nn * 2 ** (this.failures - 1)), this.emit({
|
|
385
385
|
state: "error",
|
|
386
386
|
count: 0,
|
|
387
387
|
error: e instanceof Error ? e.message : String(e)
|
|
@@ -411,7 +411,7 @@ var L = class {
|
|
|
411
411
|
now() {
|
|
412
412
|
return this.host.now ? this.host.now() : Date.now();
|
|
413
413
|
}
|
|
414
|
-
},
|
|
414
|
+
}, sn = class t {
|
|
415
415
|
base;
|
|
416
416
|
shape = null;
|
|
417
417
|
chartType = "candlestick";
|
|
@@ -428,7 +428,7 @@ var L = class {
|
|
|
428
428
|
return i;
|
|
429
429
|
}
|
|
430
430
|
getTheme() {
|
|
431
|
-
return this.effective ??=
|
|
431
|
+
return this.effective ??= te(this.base, this.chartType, this.merged()), this.effective;
|
|
432
432
|
}
|
|
433
433
|
getBaseTheme() {
|
|
434
434
|
return this.base;
|
|
@@ -497,7 +497,7 @@ var L = class {
|
|
|
497
497
|
};
|
|
498
498
|
//#endregion
|
|
499
499
|
//#region src/style/styleOptions.ts
|
|
500
|
-
function
|
|
500
|
+
function cn(e, t) {
|
|
501
501
|
return t ? {
|
|
502
502
|
...t.visible === void 0 ? {} : { [`crosshair.${e}.visible`]: t.visible },
|
|
503
503
|
...t.color === void 0 ? {} : { [`crosshair.${e}.color`]: t.color },
|
|
@@ -505,22 +505,22 @@ function B(e, t) {
|
|
|
505
505
|
...t.width === void 0 ? {} : { [`crosshair.${e}.width`]: t.width }
|
|
506
506
|
} : {};
|
|
507
507
|
}
|
|
508
|
-
function
|
|
508
|
+
function ln(e) {
|
|
509
509
|
let { grid: t, crosshair: n } = e, r = n?.vLine?.labelBackground ?? n?.hLine?.labelBackground;
|
|
510
510
|
return {
|
|
511
511
|
...t?.hLineColor === void 0 ? {} : { "grid.horizontal.color": t.hLineColor },
|
|
512
512
|
...t?.hLineStyle === void 0 ? {} : { "grid.horizontal.style": t.hLineStyle },
|
|
513
513
|
...t?.vLineColor === void 0 ? {} : { "grid.vertical.color": t.vLineColor },
|
|
514
514
|
...t?.vLineStyle === void 0 ? {} : { "grid.vertical.style": t.vLineStyle },
|
|
515
|
-
...
|
|
516
|
-
...
|
|
515
|
+
...cn("horizontal", n?.hLine),
|
|
516
|
+
...cn("vertical", n?.vLine),
|
|
517
517
|
...r === void 0 ? {} : { "crosshair.labelBackground": r },
|
|
518
518
|
...e.overrides
|
|
519
519
|
};
|
|
520
520
|
}
|
|
521
521
|
//#endregion
|
|
522
522
|
//#region src/layout/LayoutManager.ts
|
|
523
|
-
var
|
|
523
|
+
var un = 200, dn = 80, V = (e) => e.position === "top" || e.position === "bottom", fn = class {
|
|
524
524
|
panels = [];
|
|
525
525
|
containerWidth = 0;
|
|
526
526
|
containerHeight = 0;
|
|
@@ -536,8 +536,8 @@ var cn = 200, ln = 80, V = (e) => e.position === "top" || e.position === "bottom
|
|
|
536
536
|
this.panels.push({
|
|
537
537
|
id: e,
|
|
538
538
|
position: n,
|
|
539
|
-
size: r ?? (a ?
|
|
540
|
-
minSize: a ?
|
|
539
|
+
size: r ?? (a ? un : t),
|
|
540
|
+
minSize: a ? dn : i,
|
|
541
541
|
content: {
|
|
542
542
|
type: "indicator",
|
|
543
543
|
indicatorInstanceId: e
|
|
@@ -606,7 +606,7 @@ var cn = 200, ln = 80, V = (e) => e.position === "top" || e.position === "bottom
|
|
|
606
606
|
let r = this.panels.find((t) => t.id === e);
|
|
607
607
|
if (r) {
|
|
608
608
|
let a = r.position === "left" || r.position === "right", o = n === "left" || n === "right";
|
|
609
|
-
r.position = n, a !== o && (r.size = o ?
|
|
609
|
+
r.position = n, a !== o && (r.size = o ? un : t, r.minSize = o ? dn : i), o && (r.collapsed = void 0, this.maximized === e && (this.maximized = null));
|
|
610
610
|
}
|
|
611
611
|
}
|
|
612
612
|
setPanelSize(e, t) {
|
|
@@ -722,8 +722,8 @@ var cn = 200, ln = 80, V = (e) => e.position === "top" || e.position === "bottom
|
|
|
722
722
|
getMainChartRect() {
|
|
723
723
|
return this.resolve().mainChartRect;
|
|
724
724
|
}
|
|
725
|
-
},
|
|
726
|
-
function
|
|
725
|
+
}, pn = 14, mn = 14, hn = 22, gn = 4;
|
|
726
|
+
function _n(e) {
|
|
727
727
|
let { min: t, max: n, lastPrice: r, locale: i, fontFamily: o, fontSizeSmall: c, measure: l } = e, d = e.tagPrecision ?? s(t, n), f = d, p = r === null ? [t, n] : [
|
|
728
728
|
t,
|
|
729
729
|
n,
|
|
@@ -732,14 +732,14 @@ function hn(e) {
|
|
|
732
732
|
for (let t of p) {
|
|
733
733
|
if (!Number.isFinite(t)) continue;
|
|
734
734
|
let n = e.scaleLabel ? e.scaleLabel(t) : e.format ? e.format(t) : u(t, d, i), r = e.format ? n : u(t, f, i);
|
|
735
|
-
m = Math.max(m, l(n, `500 ${c}px ${o}`) +
|
|
735
|
+
m = Math.max(m, l(n, `500 ${c}px ${o}`) + pn, l(r, `bold 11px ${o}`) + mn, l(r, `600 ${c}px ${o}`) + hn);
|
|
736
736
|
}
|
|
737
|
-
return m <= a ? a : Math.ceil(m /
|
|
737
|
+
return m <= a ? a : Math.ceil(m / gn) * gn;
|
|
738
738
|
}
|
|
739
|
-
function
|
|
739
|
+
function vn(e, t) {
|
|
740
740
|
return t > e || t <= e - 12 ? t : e;
|
|
741
741
|
}
|
|
742
|
-
var
|
|
742
|
+
var yn = class {
|
|
743
743
|
netY = 0;
|
|
744
744
|
travelX = 0;
|
|
745
745
|
engaged = !1;
|
|
@@ -755,8 +755,8 @@ var _n = class {
|
|
|
755
755
|
}
|
|
756
756
|
return this.engaged;
|
|
757
757
|
}
|
|
758
|
-
},
|
|
759
|
-
function
|
|
758
|
+
}, bn = 1;
|
|
759
|
+
function xn(e, t) {
|
|
760
760
|
return e.filter((e) => e.enabled !== !1 && (e.descriptor.layer ?? "overlay") === t);
|
|
761
761
|
}
|
|
762
762
|
function H(e) {
|
|
@@ -770,24 +770,24 @@ function H(e) {
|
|
|
770
770
|
//#endregion
|
|
771
771
|
//#region src/plugins/registry.ts
|
|
772
772
|
var U = /* @__PURE__ */ new Map();
|
|
773
|
-
function
|
|
773
|
+
function Sn(e) {
|
|
774
774
|
U.set(H(e), e);
|
|
775
775
|
}
|
|
776
|
-
function
|
|
776
|
+
function Cn(e) {
|
|
777
777
|
return U.delete(e);
|
|
778
778
|
}
|
|
779
|
-
function
|
|
779
|
+
function wn() {
|
|
780
780
|
return [...U.values()];
|
|
781
781
|
}
|
|
782
|
-
function
|
|
782
|
+
function Tn() {
|
|
783
783
|
U.clear();
|
|
784
784
|
}
|
|
785
785
|
//#endregion
|
|
786
786
|
//#region src/plugins/PluginManager.ts
|
|
787
|
-
var
|
|
787
|
+
var En = class {
|
|
788
788
|
plugins = /* @__PURE__ */ new Map();
|
|
789
789
|
constructor(e, t = {}) {
|
|
790
|
-
if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of
|
|
790
|
+
if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of wn()) this.add(e);
|
|
791
791
|
for (let e of t.plugins ?? []) this.add(e);
|
|
792
792
|
}
|
|
793
793
|
register(e) {
|
|
@@ -817,15 +817,15 @@ var W = class {
|
|
|
817
817
|
add(e) {
|
|
818
818
|
this.plugins.set(H(e), e), e.kind === "indicator" && this.indicatorEngine.register(e.plugin);
|
|
819
819
|
}
|
|
820
|
-
},
|
|
820
|
+
}, Dn = {
|
|
821
821
|
orderPlace: (e, t) => e.placeOrder(t),
|
|
822
822
|
orderModify: (e, t) => e.modifyOrder(t),
|
|
823
823
|
orderCancel: (e, t) => e.cancelOrder(t),
|
|
824
824
|
positionModify: (e, t) => e.modifyPosition(t),
|
|
825
825
|
positionClose: (e, t) => e.closePosition(t),
|
|
826
|
-
positionReverse: (e, t, n) =>
|
|
826
|
+
positionReverse: (e, t, n) => On(e, t, n)
|
|
827
827
|
};
|
|
828
|
-
async function
|
|
828
|
+
async function On(e, t, n) {
|
|
829
829
|
let { reversing: r } = n;
|
|
830
830
|
if (!r.has(t.positionId)) {
|
|
831
831
|
r.add(t.positionId);
|
|
@@ -854,7 +854,7 @@ async function Tn(e, t, n) {
|
|
|
854
854
|
}
|
|
855
855
|
}
|
|
856
856
|
}
|
|
857
|
-
function
|
|
857
|
+
function kn(e, t) {
|
|
858
858
|
let n = [], r = null, i = {
|
|
859
859
|
positions: () => r ?? t.getPositions?.() ?? [],
|
|
860
860
|
reversing: /* @__PURE__ */ new Set()
|
|
@@ -864,8 +864,8 @@ function En(e, t) {
|
|
|
864
864
|
e.data && t.onFill?.(e.data);
|
|
865
865
|
};
|
|
866
866
|
e.on("orders", a), e.on("positions", o), e.on("error", s), e.on("fill", c), n.push(() => e.off("orders", a), () => e.off("positions", o), () => e.off("error", s), () => e.off("fill", c));
|
|
867
|
-
for (let r of Object.keys(
|
|
868
|
-
let a =
|
|
867
|
+
for (let r of Object.keys(Dn)) {
|
|
868
|
+
let a = Dn[r], o = t.onIntent(r, (n) => {
|
|
869
869
|
Promise.resolve(a(e, n, i)).catch((e) => t.onError({
|
|
870
870
|
message: `Execution command failed: ${r}`,
|
|
871
871
|
cause: e
|
|
@@ -879,16 +879,16 @@ function En(e, t) {
|
|
|
879
879
|
}
|
|
880
880
|
//#endregion
|
|
881
881
|
//#region src/Chart.ts
|
|
882
|
-
var
|
|
882
|
+
var An = {
|
|
883
883
|
min: 0,
|
|
884
884
|
max: 100
|
|
885
|
-
},
|
|
886
|
-
function
|
|
885
|
+
}, jn = 0xe8d4a51000, Mn = "exchange";
|
|
886
|
+
function Nn(e) {
|
|
887
887
|
if (typeof e == "string" && e !== "exchange" && !p(e)) throw RangeError(`Unknown time zone: ${e}`);
|
|
888
888
|
if (typeof e == "number" && !Number.isFinite(e)) throw RangeError(`Invalid UTC offset: ${e}`);
|
|
889
889
|
}
|
|
890
|
-
var
|
|
891
|
-
static version = "1.
|
|
890
|
+
var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine", "crossLine"]), Bn = new Set(["verticalLine", "crossLine"]), Vn = class {
|
|
891
|
+
static version = "1.24.0";
|
|
892
892
|
engine;
|
|
893
893
|
viewport;
|
|
894
894
|
dataManager;
|
|
@@ -926,14 +926,14 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
926
926
|
indicatorHistoryDepth = 0;
|
|
927
927
|
removedDrawingAlerts = /* @__PURE__ */ new Map();
|
|
928
928
|
zoomAreaMode = !1;
|
|
929
|
-
priceAxisAddButton = new
|
|
929
|
+
priceAxisAddButton = new Ke();
|
|
930
930
|
displayTz = null;
|
|
931
931
|
timezoneSetting = null;
|
|
932
932
|
symbolInfo = null;
|
|
933
933
|
symbolInfoSeq = 0;
|
|
934
934
|
sessionBreaks;
|
|
935
935
|
sessionShading;
|
|
936
|
-
hostSessionHours = { ...
|
|
936
|
+
hostSessionHours = { ...Te };
|
|
937
937
|
compareRenderer;
|
|
938
938
|
countdownInterval = null;
|
|
939
939
|
volumeRenderer;
|
|
@@ -946,7 +946,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
946
946
|
signalMarkerManager;
|
|
947
947
|
tradeZoneManager;
|
|
948
948
|
measureOverlay;
|
|
949
|
-
selectionBoxOverlay = new
|
|
949
|
+
selectionBoxOverlay = new Ze();
|
|
950
950
|
replayManager;
|
|
951
951
|
replayBarUnsub = null;
|
|
952
952
|
replaySeeking = !1;
|
|
@@ -956,7 +956,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
956
956
|
replayRevealMarks = !0;
|
|
957
957
|
replayOffset = 0;
|
|
958
958
|
undoRedoManager;
|
|
959
|
-
autoSaveScheduler = new
|
|
959
|
+
autoSaveScheduler = new en((e) => this.saveState(e));
|
|
960
960
|
animator;
|
|
961
961
|
crosshairTooltip;
|
|
962
962
|
pinnedTooltip;
|
|
@@ -968,15 +968,15 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
968
968
|
disposed = !1;
|
|
969
969
|
chartTypeOptions = {};
|
|
970
970
|
mainSeriesVisible = !0;
|
|
971
|
-
priceLines = new
|
|
972
|
-
symbolSeries = new
|
|
971
|
+
priceLines = new qe();
|
|
972
|
+
symbolSeries = new it();
|
|
973
973
|
extendedHours = !0;
|
|
974
974
|
replayRestarting = !1;
|
|
975
975
|
fullSeries = null;
|
|
976
976
|
requestedSymbols = /* @__PURE__ */ new Set();
|
|
977
977
|
gridRenderer;
|
|
978
978
|
priceAxis;
|
|
979
|
-
leftPriceAxis = new
|
|
979
|
+
leftPriceAxis = new O();
|
|
980
980
|
leftScaleRequested = !1;
|
|
981
981
|
leftAxisWidth = a;
|
|
982
982
|
leftViewport = null;
|
|
@@ -1007,7 +1007,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1007
1007
|
snapshotKey = null;
|
|
1008
1008
|
historyCheckQueued = !1;
|
|
1009
1009
|
constructor(e, t) {
|
|
1010
|
-
t.timeZone != null &&
|
|
1010
|
+
t.timeZone != null && Nn(t.timeZone), this.container = e, this.options = {
|
|
1011
1011
|
...t,
|
|
1012
1012
|
chartType: t.chartType ?? "candlestick"
|
|
1013
1013
|
}, this.numberLocale = t.numberLocale ?? "en-US", this.defaultAutoScale = t.autoScale !== !1;
|
|
@@ -1045,15 +1045,15 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1045
1045
|
logScale: n.logScale ?? !0,
|
|
1046
1046
|
timeframes: n.timeframes ?? [],
|
|
1047
1047
|
defaultTimeframeFavorites: n.defaultTimeframeFavorites ?? []
|
|
1048
|
-
}, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", e.style.userSelect = "none", e.style.webkitUserSelect = "none", this.dataManager = new
|
|
1048
|
+
}, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", e.style.userSelect = "none", e.style.webkitUserSelect = "none", this.dataManager = new B(), this.history = new on({
|
|
1049
1049
|
oldestTime: () => this.dataManager.getData()[0]?.time ?? null,
|
|
1050
1050
|
prepend: (e) => this.prependBars(e),
|
|
1051
1051
|
emit: (e) => this.eventBus.emit("historyLoad", e)
|
|
1052
|
-
}), this.themeManager = new
|
|
1052
|
+
}), this.themeManager = new sn(t.theme), this.themeManager.setChartType(this.options.chartType ?? "candlestick"), this.applyStyle(ln(t), "host", !1), this.layoutManager = new fn(), this.indicatorEngine = new E(), this.pluginManager = new En(this.indicatorEngine, { plugins: t.plugins }), this.eventBus = new Ae(), A(this.indicatorEngine), this.indicatorEngine.register(new ye(this.symbolSeries)), this.indicatorEngine.register(new tt(this.symbolSeries)), this.indicatorEngine.register(new be(this.symbolSeries)), this.indicatorEngine.register(new xe(this.symbolSeries)), this.drawingManager = new De(), Tt(this.drawingManager), this.drawingRenderer = new Oe(this.drawingManager), this.drawingManager.setRequestRender(() => {
|
|
1053
1053
|
this.syncRenderContext(), this.engine.requestRender(r.Overlay), this.scheduleAutoSave();
|
|
1054
1054
|
}), this.drawingManager.setEventCallback((e, t) => {
|
|
1055
1055
|
this.followDrawingAlerts(e, t?.id), this.eventBus.emit(e, t), (e === "drawingCreate" || e === "drawingUpdate" || e === "drawingRemove") && this.announceStateChange();
|
|
1056
|
-
}), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new
|
|
1056
|
+
}), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new lt();
|
|
1057
1057
|
let i = "";
|
|
1058
1058
|
this.undoRedoManager.setOnChange(() => {
|
|
1059
1059
|
let { canUndo: e, canRedo: t } = this.undoRedoManager.getState(), n = `${e}|${t}`;
|
|
@@ -1066,21 +1066,21 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1066
1066
|
primary: e[0] ?? null
|
|
1067
1067
|
})), this.drawingManager.setForeignHistory((e, t) => {
|
|
1068
1068
|
e.type === "custom" ? e.custom?.[t]() : this.applyIndicatorStep(e, t);
|
|
1069
|
-
}), this.drawingManager.setDataGetter(() => this.dataManager.getData()), this.drawingManager.setDisplayDataGetter(() => this.getDisplayData()), t.crosshair?.mode === "magnet" && this.features.drawingMagnet && this.drawingManager.setMagnetMode("magnet"), this.tradingManager = new
|
|
1069
|
+
}), this.drawingManager.setDataGetter(() => this.dataManager.getData()), this.drawingManager.setDisplayDataGetter(() => this.getDisplayData()), t.crosshair?.mode === "magnet" && this.features.drawingMagnet && this.drawingManager.setMagnetMode("magnet"), this.tradingManager = new st({
|
|
1070
1070
|
enabled: this.features.trading,
|
|
1071
1071
|
contextMenu: { enabled: this.features.tradingContextMenu }
|
|
1072
|
-
}), this.tradingRenderer = new
|
|
1072
|
+
}), this.tradingRenderer = new ct(this.tradingManager), this.tradingManager.setContainer(e), this.tradingManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradingManager.setEventCallback((e, t) => {
|
|
1073
1073
|
this.eventBus.emit(e, t);
|
|
1074
|
-
}), this.engine = new
|
|
1074
|
+
}), this.engine = new Je(e);
|
|
1075
1075
|
let a = this.engine.dprManager.getContainerSize();
|
|
1076
|
-
if (this.viewport = new
|
|
1076
|
+
if (this.viewport = new ut(a.width, a.height, t.minBarSpacing ?? 2, t.maxBarSpacing ?? 30, t.rightMargin ?? 5), this.viewport.setPanLimits({
|
|
1077
1077
|
freePan: t.freePan ?? !0,
|
|
1078
1078
|
minVisibleBars: t.panLimits?.minVisibleBars ?? 3
|
|
1079
1079
|
}), this.layoutManager.resize(a.width, a.height), this.engine.onContainerResize = (e) => {
|
|
1080
1080
|
if (e.width <= 0 || e.height <= 0) return;
|
|
1081
1081
|
let t = this.viewport.isAtEnd();
|
|
1082
1082
|
this.viewport.resize(e.width, e.height), this.layoutManager.resize(e.width, e.height), this.updateViewportAndRender(t);
|
|
1083
|
-
}, this.chartRenderer = this.createChartRenderer(this.options.chartType), this.gridRenderer = new
|
|
1083
|
+
}, this.chartRenderer = this.createChartRenderer(this.options.chartType), this.gridRenderer = new je(), t.grid?.visible === !1 && this.gridRenderer.setVisible(!1), this.priceAxis = new O(), this.priceAxis.setLocale(this.numberLocale), this.leftPriceAxis.setLocale(this.numberLocale), this.timeAxis = new at(), this.crosshairHandler = new Se(), this.crosshairHandler.setLocale(this.numberLocale), this.applyTimeSpacing(), t.crosshair?.mode && this.crosshairHandler.setMode(t.crosshair.mode), this.crosshairHandler.setCallback((e, t) => {
|
|
1084
1084
|
if (e !== null && t) {
|
|
1085
1085
|
let n = this.dataManager.getData(), r = e < n.length ? n[e] : void 0;
|
|
1086
1086
|
this.chartLegend.setHoverBar(r ?? null);
|
|
@@ -1089,19 +1089,19 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1089
1089
|
prevClose: e > 0 ? n[e - 1]?.close : void 0,
|
|
1090
1090
|
priceRange: i.priceRange,
|
|
1091
1091
|
plot: i.chartRect,
|
|
1092
|
-
barStepMs:
|
|
1092
|
+
barStepMs: gt(n)
|
|
1093
1093
|
}) : this.crosshairTooltip.hide(), this.pinnedTooltip.isPinned() && this.pinnedTooltip.reposition(this.viewport.getState(), r ?? null, e, this.themeManager.getTheme()), this.eventBus.emit("crosshairMove", {
|
|
1094
1094
|
point: t,
|
|
1095
1095
|
bar: r,
|
|
1096
1096
|
barIndex: e
|
|
1097
1097
|
});
|
|
1098
1098
|
} else this.crosshairTooltip.hide(), this.chartLegend.setHoverBar(null), this.eventBus.emit("crosshairLeave", {});
|
|
1099
|
-
}), this.chartLegend = new
|
|
1099
|
+
}), this.chartLegend = new _e(), this.chartLegend.setChartType(this.options.chartType), this.chartLegend.setLocale(this.numberLocale), this.watermark = new mt(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new pt(), this.volumeProfile = new ft(), this.marketProfile = new ze(), this.depthHeatmap = new Ee(), this.periodLevels = new Ue(), this.pivotMarkers = new Ge(), this.barCountdown = new pe(), this.barCountdown.setVisible(this.features.barCountdown), this.sessionBreaks = new Qe(), this.sessionBreaks.setLocale(this.numberLocale), this.sessionShading = new $e(), this.compareRenderer = new ve(), t.sessionBreaks ? this.sessionBreaks.setConfig({
|
|
1100
1100
|
visible: t.sessionBreaks.visible ?? !0,
|
|
1101
1101
|
color: t.sessionBreaks.color,
|
|
1102
1102
|
lineStyle: t.sessionBreaks.lineStyle,
|
|
1103
1103
|
lineWidth: t.sessionBreaks.lineWidth
|
|
1104
|
-
}) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new
|
|
1104
|
+
}) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new ue(), this.crosshairTooltip = new Ce(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new We(), this.pinnedTooltip.create(e), t.priceFormat && this.applyPriceFormat(t.priceFormat), t.chartTypeOptions && (this.chartTypeOptions = b(t.chartTypeOptions)), t.highLowLines && this.priceLines.setHighLow(!0), t.shapes && this.themeManager.setShape(Wn(t.shapes)), this.priceLines.setPriceText((e) => this.formatPrice(e)), t.extendedHours === !1 && (this.extendedHours = !1), t.timeFormatter && this.applyTimeFormatter(t.timeFormatter), this.keyboardHandler = new Ie({
|
|
1105
1105
|
scrollBars: (e) => {
|
|
1106
1106
|
let t = this.viewport.getState().barWidth + this.viewport.getState().barSpacing;
|
|
1107
1107
|
this.viewport.scrollBy(e * t), this.updateViewportAndRender();
|
|
@@ -1118,17 +1118,17 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1118
1118
|
},
|
|
1119
1119
|
fitContent: () => this.fitContent()
|
|
1120
1120
|
}), this.keyboardHandler.setEnabled(this.features.keyboard), t.a11y !== !1) {
|
|
1121
|
-
this.a11y = new
|
|
1121
|
+
this.a11y = new Ut(e, {
|
|
1122
1122
|
symbol: () => this.currentSymbol || this.symbolInfo?.symbol || "",
|
|
1123
1123
|
timeframe: () => this.streamTimeframe ?? "",
|
|
1124
1124
|
chartType: () => this.options.chartType ?? "candlestick",
|
|
1125
1125
|
bars: () => this.getDisplayData(),
|
|
1126
1126
|
visibleRange: () => this.viewport.getState().visibleRange,
|
|
1127
1127
|
formatPrice: (e) => this.formatPrice(e),
|
|
1128
|
-
formatTime: (e) =>
|
|
1128
|
+
formatTime: (e) => se(this.numberLocale || "en-US", {
|
|
1129
1129
|
dateStyle: "medium",
|
|
1130
1130
|
timeStyle: "short"
|
|
1131
|
-
}, this.displayTz)(e >
|
|
1131
|
+
}, this.displayTz)(e > jn ? e : e * 1e3),
|
|
1132
1132
|
showBar: (e) => this.setCrosshairTime(e)
|
|
1133
1133
|
}, t.a11y?.labels);
|
|
1134
1134
|
for (let e of [
|
|
@@ -1148,22 +1148,22 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1148
1148
|
}
|
|
1149
1149
|
this.keyboardHandler.handleKey(e) && (e.preventDefault(), this.a11y?.viewMoved());
|
|
1150
1150
|
}
|
|
1151
|
-
}, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new
|
|
1152
|
-
this.eventBus.emit("alertTriggered",
|
|
1151
|
+
}, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new we(), this.currentPriceLine.setLocale(this.numberLocale), this.priceAxis.setReservedPriceProvider(() => this.currentPriceLine.isVisible() ? this.currentPriceLine.getPrice() : null), this.alertManager = new le(), this.alertManager.setDrawingLevels((e) => this.drawingLevelsNow(e)), this.alertManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.alertManager.on("triggered", (e) => {
|
|
1152
|
+
this.eventBus.emit("alertTriggered", G(e)), this.eventBus.emit("dataUpdate", {
|
|
1153
1153
|
alert: "triggered",
|
|
1154
1154
|
alertId: e.id,
|
|
1155
1155
|
price: e.price,
|
|
1156
1156
|
message: e.message
|
|
1157
1157
|
});
|
|
1158
1158
|
}), this.alertManager.on("added", (e) => {
|
|
1159
|
-
this.eventBus.emit("alertAdd",
|
|
1159
|
+
this.eventBus.emit("alertAdd", G(e));
|
|
1160
1160
|
}), this.alertManager.on("removed", (e) => {
|
|
1161
1161
|
this.eventBus.emit("alertRemove", { id: e });
|
|
1162
1162
|
}), this.alertManager.on("expired", (e) => {
|
|
1163
|
-
this.eventBus.emit("alertExpired",
|
|
1163
|
+
this.eventBus.emit("alertExpired", G(e));
|
|
1164
1164
|
}), this.alertManager.on("updated", (e) => {
|
|
1165
|
-
this.eventBus.emit("alertUpdate",
|
|
1166
|
-
}), this.signalMarkerManager = new
|
|
1165
|
+
this.eventBus.emit("alertUpdate", G(e));
|
|
1166
|
+
}), this.signalMarkerManager = new et(), this.signalMarkerManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.signalMarkerManager.setDataGetter(() => this.dataManager.getData()), this.signalMarkerManager.on("added", (e) => {
|
|
1167
1167
|
this.eventBus.emit("signalMarkerAdd", {
|
|
1168
1168
|
id: e.id,
|
|
1169
1169
|
source: e.source,
|
|
@@ -1171,14 +1171,14 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1171
1171
|
});
|
|
1172
1172
|
}), this.signalMarkerManager.on("removed", (e) => {
|
|
1173
1173
|
this.eventBus.emit("signalMarkerRemove", { id: e });
|
|
1174
|
-
}), this.tradeZoneManager = new
|
|
1174
|
+
}), this.tradeZoneManager = new ot(), this.tradeZoneManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradeZoneManager.setDataGetter(() => this.dataManager.getData()), this.tradeZoneManager.on("added", (e) => {
|
|
1175
1175
|
this.eventBus.emit("tradeZoneAdd", {
|
|
1176
1176
|
id: e.id,
|
|
1177
1177
|
direction: e.direction
|
|
1178
1178
|
});
|
|
1179
1179
|
}), this.tradeZoneManager.on("removed", (e) => {
|
|
1180
1180
|
this.eventBus.emit("tradeZoneRemove", { id: e });
|
|
1181
|
-
}), this.replayManager = new
|
|
1181
|
+
}), this.replayManager = new Xe(), this.replayManager.on("complete", () => {
|
|
1182
1182
|
let e = this.getReplayBarIndex(), t = this.replayCoarse?.[e];
|
|
1183
1183
|
t && this.eventBus.emit("replayComplete", {
|
|
1184
1184
|
barIndex: e,
|
|
@@ -1186,9 +1186,9 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1186
1186
|
});
|
|
1187
1187
|
}), this.replayManager.on("stateChange", (e) => {
|
|
1188
1188
|
this.replayRestarting || this.eventBus.emit("replayState", { state: e });
|
|
1189
|
-
}), this.measureOverlay = new
|
|
1190
|
-
let e = new
|
|
1191
|
-
this.interactionManager.setPanHandler(new
|
|
1189
|
+
}), this.measureOverlay = new Be(), this.interactionManager = new Pe(e), this.features.panning) {
|
|
1190
|
+
let e = new yn();
|
|
1191
|
+
this.interactionManager.setPanHandler(new Ve((t, n) => {
|
|
1192
1192
|
t && this.viewport.scrollBy(t), e.step(t, n, this.options.autoScale !== !1) && n && (this.options.autoScale = !1, this.viewport.panPriceRange(n)), this.updateViewportAndRender();
|
|
1193
1193
|
}, () => e.reset()));
|
|
1194
1194
|
}
|
|
@@ -1200,10 +1200,10 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1200
1200
|
scales: !this.indicatorEngine.hasLeftScaleOverlays()
|
|
1201
1201
|
}
|
|
1202
1202
|
})), this.features.zooming) {
|
|
1203
|
-
this.interactionManager.setZoomHandler(new
|
|
1203
|
+
this.interactionManager.setZoomHandler(new ht((e, t) => {
|
|
1204
1204
|
this.viewport.zoom(e, t - this.viewport.getState().chartRect.x), this.updateViewportAndRender();
|
|
1205
1205
|
}));
|
|
1206
|
-
let e = new
|
|
1206
|
+
let e = new fe((e) => {
|
|
1207
1207
|
this.options.autoScale = !1, this.viewport.scalePriceRange(e), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents();
|
|
1208
1208
|
}, (e) => {
|
|
1209
1209
|
let t = this.viewport.getState().chartRect.width;
|
|
@@ -1223,7 +1223,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1223
1223
|
y: t.y
|
|
1224
1224
|
});
|
|
1225
1225
|
})), this.interactionManager.setChartContextMenu((e, t) => this.eventBus.hasListeners("chartContextMenu") ? (this.eventBus.emit("chartContextMenu", this.contextAt(e, t)), !0) : !1), this.priceAxisAddButton.setEnabled(this.features.priceAxisAddButton && this.features.crosshair), this.interactionManager.setPriceAxisAddButton(this.priceAxisAddButton, (e) => {
|
|
1226
|
-
let t =
|
|
1226
|
+
let t = Ft(e.y, this.viewport.getState());
|
|
1227
1227
|
Number.isFinite(t) && this.eventBus.emit("priceAxisAdd", {
|
|
1228
1228
|
price: t,
|
|
1229
1229
|
x: e.x,
|
|
@@ -1233,10 +1233,10 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1233
1233
|
...this.viewport.getState(),
|
|
1234
1234
|
data: this.getDisplayData()
|
|
1235
1235
|
})), this.features.alerts) {
|
|
1236
|
-
let e = new
|
|
1236
|
+
let e = new ce(this.alertManager, () => this.viewport.getState());
|
|
1237
1237
|
this.interactionManager.setAlertDragHandler(e);
|
|
1238
1238
|
}
|
|
1239
|
-
let o = new
|
|
1239
|
+
let o = new He();
|
|
1240
1240
|
o.configure(() => this.getResolvedLayout(), (e, t) => this.setPanelSize(e, t)), this.interactionManager.setPaneResizeHandler(o), this.interactionManager.setAltClickHandler((e) => {
|
|
1241
1241
|
let t = this.getDisplayData();
|
|
1242
1242
|
if (t.length === 0) return;
|
|
@@ -1260,7 +1260,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1260
1260
|
x: e.x,
|
|
1261
1261
|
y: e.y
|
|
1262
1262
|
}), t.length === 0) return;
|
|
1263
|
-
let r =
|
|
1263
|
+
let r = Pt(e.x, this.viewport.getState());
|
|
1264
1264
|
r < 0 || r >= t.length || this.eventBus.emit("barClick", {
|
|
1265
1265
|
bar: t[r],
|
|
1266
1266
|
barIndex: r,
|
|
@@ -1300,7 +1300,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1300
1300
|
end: () => {
|
|
1301
1301
|
let e = this.selectionBoxOverlay.end();
|
|
1302
1302
|
if (e && this.zoomAreaMode) {
|
|
1303
|
-
if (e.x1 - e.x0 <
|
|
1303
|
+
if (e.x1 - e.x0 < Rn) return;
|
|
1304
1304
|
this.zoomToBox(e), this.setZoomAreaMode(!1);
|
|
1305
1305
|
return;
|
|
1306
1306
|
}
|
|
@@ -1337,7 +1337,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1337
1337
|
if (this.replaySession) return 0;
|
|
1338
1338
|
let t = null;
|
|
1339
1339
|
if (this.fullSeries) {
|
|
1340
|
-
let n = this.fullSeries[0]?.time, r = /* @__PURE__ */ new Set(), i = e.filter((e) =>
|
|
1340
|
+
let n = this.fullSeries[0]?.time, r = /* @__PURE__ */ new Set(), i = e.filter((e) => Qn(e) && (n === void 0 || e.time < n) && !r.has(e.time) && r.add(e.time)).sort((e, t) => e.time - t.time);
|
|
1341
1341
|
this.fullSeries = [...i, ...this.fullSeries];
|
|
1342
1342
|
let a = this.sessionKeep(this.fullSeries);
|
|
1343
1343
|
t = i.length, e = a ? i.filter((e) => a(e.time)) : i;
|
|
@@ -1346,7 +1346,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1346
1346
|
if (a === 0) return t ?? 0;
|
|
1347
1347
|
let o = this.dataManager.getData();
|
|
1348
1348
|
if (this.crosshairHandler.setData(o), this.displayDataCache = null, this.sessionBreaks.invalidateCache(), this.pinnedTooltip.isPinned() && this.pinnedTooltip.unpin(), this.measureOverlay.end(), this.recalcIndicators(o), i !== void 0) {
|
|
1349
|
-
let e = Math.round(
|
|
1349
|
+
let e = Math.round(N(i, this.getDisplayData()));
|
|
1350
1350
|
this.viewport.prependBars(e - r);
|
|
1351
1351
|
}
|
|
1352
1352
|
return this.updateViewportAndRender(), t ?? a;
|
|
@@ -1377,15 +1377,15 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1377
1377
|
}
|
|
1378
1378
|
checkHistory() {
|
|
1379
1379
|
this.historyCheckQueued || !this.history.hasLoader() || (this.historyCheckQueued = !0, queueMicrotask(() => {
|
|
1380
|
-
if (this.historyCheckQueued = !1, this.replaySession || !this.history.hasLoader() ||
|
|
1380
|
+
if (this.historyCheckQueued = !1, this.replaySession || !this.history.hasLoader() || L(this.options.chartType)) return;
|
|
1381
1381
|
let { from: e, to: t } = this.viewport.getState().visibleRange;
|
|
1382
|
-
this.history.maybeLoad(Math.max(0, Math.floor(e)), Math.max(
|
|
1382
|
+
this.history.maybeLoad(Math.max(0, Math.floor(e)), Math.max(Ln, t - e));
|
|
1383
1383
|
}));
|
|
1384
1384
|
}
|
|
1385
1385
|
useStreamHistory(e, t) {
|
|
1386
1386
|
if (this.hostHistoryLoader) return;
|
|
1387
|
-
let n =
|
|
1388
|
-
if (!r || i === null ||
|
|
1387
|
+
let n = Nt(e), r = n.fetchHistoryBefore, i = this.streamTimeframe;
|
|
1388
|
+
if (!r || i === null || ie(i) !== null) {
|
|
1389
1389
|
this.historyFromStream && this.history.setLoader(null), this.historyFromStream = !1;
|
|
1390
1390
|
return;
|
|
1391
1391
|
}
|
|
@@ -1451,17 +1451,17 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1451
1451
|
});
|
|
1452
1452
|
}
|
|
1453
1453
|
applyTimeSpacing() {
|
|
1454
|
-
let e = !this.tickStream && !
|
|
1454
|
+
let e = !this.tickStream && !L(this.options.chartType);
|
|
1455
1455
|
this.timeAxis.setTimesPastData(e), this.crosshairHandler.setTimesPastData(e);
|
|
1456
1456
|
}
|
|
1457
1457
|
setChartTypeOptions(e) {
|
|
1458
1458
|
this.chartTypeOptions = {
|
|
1459
1459
|
...this.chartTypeOptions,
|
|
1460
|
-
...
|
|
1460
|
+
...b(e)
|
|
1461
1461
|
}, this.displayDataCache = null, this.updateViewportAndRender(!0), this.markStateChanged();
|
|
1462
1462
|
}
|
|
1463
1463
|
getChartTypeOptions() {
|
|
1464
|
-
return
|
|
1464
|
+
return b(this.chartTypeOptions);
|
|
1465
1465
|
}
|
|
1466
1466
|
setExtendedHours(e) {
|
|
1467
1467
|
e !== this.extendedHours && (this.extendedHours = e, this.reapplyExtendedHours(), this.markStateChanged());
|
|
@@ -1470,7 +1470,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1470
1470
|
return this.extendedHours;
|
|
1471
1471
|
}
|
|
1472
1472
|
sessionKeep(e) {
|
|
1473
|
-
return this.extendedHours ? null :
|
|
1473
|
+
return this.extendedHours ? null : Rt(this.symbolInfo, e);
|
|
1474
1474
|
}
|
|
1475
1475
|
shownBars(e) {
|
|
1476
1476
|
let t = this.sessionKeep(e);
|
|
@@ -1481,7 +1481,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1481
1481
|
return this.fullSeries = t ? e.slice() : null, t ? e.filter((e) => t(e.time)) : e;
|
|
1482
1482
|
}
|
|
1483
1483
|
placeStreamBar(e) {
|
|
1484
|
-
let t =
|
|
1484
|
+
let t = K(this.dataManager.getData(), e);
|
|
1485
1485
|
return t === "stale" ? !1 : (t === "append" ? this.dataManager.appendBar(e) : this.dataManager.updateLastBar(e), !0);
|
|
1486
1486
|
}
|
|
1487
1487
|
takeBar(e, t) {
|
|
@@ -1511,7 +1511,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1511
1511
|
return this.priceLines.setQuoteShown(this.replaySession === null), this.priceLines;
|
|
1512
1512
|
}
|
|
1513
1513
|
setShapes(e) {
|
|
1514
|
-
let t =
|
|
1514
|
+
let t = Wn(e);
|
|
1515
1515
|
t.tagRadius !== void 0 && (this.themeManager.setShape({
|
|
1516
1516
|
...this.themeManager.getTheme().shape,
|
|
1517
1517
|
...t
|
|
@@ -1556,7 +1556,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1556
1556
|
setSymbolSeries(e, t) {
|
|
1557
1557
|
e = e.trim(), this.symbolSeries.set(e, t), this.requestedSymbols.delete(e);
|
|
1558
1558
|
let n = this.dataManager.getData(), r = !1;
|
|
1559
|
-
for (let t of this.indicatorEngine.getActiveIndicators()) !
|
|
1559
|
+
for (let t of this.indicatorEngine.getActiveIndicators()) !W.has(t.id) || String(t.params.symbol ?? "").trim() !== e.trim() || (this.indicatorEngine.updateIndicator(t.instanceId, {}, n), r = !0);
|
|
1560
1560
|
r && (this.announceIndicatorUpdate(0), this.updateViewportAndRender());
|
|
1561
1561
|
}
|
|
1562
1562
|
forgetUnreadSymbols() {
|
|
@@ -1570,20 +1570,20 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1570
1570
|
let e = /* @__PURE__ */ new Set();
|
|
1571
1571
|
for (let t of this.indicatorEngine.getActiveIndicators()) {
|
|
1572
1572
|
let n = t.params.symbol;
|
|
1573
|
-
|
|
1573
|
+
W.has(t.id) && typeof n == "string" && n.trim() && e.add(n.trim());
|
|
1574
1574
|
}
|
|
1575
1575
|
return [...e];
|
|
1576
1576
|
}
|
|
1577
1577
|
requestMissingSymbols(e) {
|
|
1578
1578
|
this.forgetUnreadSymbols();
|
|
1579
|
-
let t = this.indicatorEngine.getIndicatorConfig(e), n = t &&
|
|
1579
|
+
let t = this.indicatorEngine.getIndicatorConfig(e), n = t && W.has(t.id) && typeof t.params.symbol == "string" ? t.params.symbol.trim() : "";
|
|
1580
1580
|
!n || this.symbolSeries.has(n) || this.requestedSymbols.has(n) || (this.requestedSymbols.add(n), this.eventBus.emit("symbolSeriesRequest", { symbol: n }));
|
|
1581
1581
|
}
|
|
1582
1582
|
updateIndicator(e, t) {
|
|
1583
1583
|
this.recordIndicators(e, () => this.updateIndicatorNow(e, t));
|
|
1584
1584
|
}
|
|
1585
1585
|
updateIndicatorNow(e, t) {
|
|
1586
|
-
let n = this.indicatorEngine.getIndicatorDescriptor(e), r = n ?
|
|
1586
|
+
let n = this.indicatorEngine.getIndicatorDescriptor(e), r = n ? M(n) : null, i = r ? this.indicatorEngine.getIndicatorConfig(e)?.params[r] : void 0;
|
|
1587
1587
|
this.indicatorEngine.updateIndicator(e, t, this.dataManager.getData()), this.announceIndicatorUpdate(0), this.markStateChanged(), this.eventBus.emit("indicatorChange", {
|
|
1588
1588
|
instanceId: e,
|
|
1589
1589
|
change: "params"
|
|
@@ -1601,7 +1601,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1601
1601
|
paneFor(e, t, n, r) {
|
|
1602
1602
|
if (n) return this.paneHostOf(n, r);
|
|
1603
1603
|
if (e.placement !== "overlay") return null;
|
|
1604
|
-
let i =
|
|
1604
|
+
let i = M(e), a = i ? g(t[i]) : null;
|
|
1605
1605
|
return a ? this.paneHostOf(a.instanceId, r) : null;
|
|
1606
1606
|
}
|
|
1607
1607
|
paneHostOf(e, t) {
|
|
@@ -1644,8 +1644,8 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1644
1644
|
return {
|
|
1645
1645
|
...e,
|
|
1646
1646
|
priceRange: {
|
|
1647
|
-
min: t.min - n *
|
|
1648
|
-
max: t.max + n *
|
|
1647
|
+
min: t.min - n * Fn,
|
|
1648
|
+
max: t.max + n * Fn
|
|
1649
1649
|
},
|
|
1650
1650
|
logScale: !1,
|
|
1651
1651
|
scaleMode: "regular",
|
|
@@ -1692,7 +1692,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1692
1692
|
this.indicatorEngine.setStyleDefaults(e, null);
|
|
1693
1693
|
return;
|
|
1694
1694
|
}
|
|
1695
|
-
let { plots: n, ...r } = t, i = n === void 0 ? void 0 :
|
|
1695
|
+
let { plots: n, ...r } = t, i = n === void 0 ? void 0 : ee(n);
|
|
1696
1696
|
this.indicatorEngine.setStyleDefaults(e, {
|
|
1697
1697
|
...r,
|
|
1698
1698
|
...i ? { plots: i } : {}
|
|
@@ -1700,7 +1700,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1700
1700
|
}
|
|
1701
1701
|
setPaneStyle(e, t) {
|
|
1702
1702
|
let n = this.paneOf(e);
|
|
1703
|
-
this.layoutManager.getPanels().some((e) => e.id === n) && this.recordIndicators(n, () => this.setPaneStyleNow(n, t ?
|
|
1703
|
+
this.layoutManager.getPanels().some((e) => e.id === n) && this.recordIndicators(n, () => this.setPaneStyleNow(n, t ? x(t) : null));
|
|
1704
1704
|
}
|
|
1705
1705
|
setPaneStyleNow(e, t) {
|
|
1706
1706
|
JSON.stringify(t) !== JSON.stringify(this.paneStyles.get(e) ?? null) && (t ? this.paneStyles.set(e, t) : this.paneStyles.delete(e), this.panelInfoCache = null, this.syncRenderContext(), this.engine.requestRender(), this.markStateChanged());
|
|
@@ -1719,8 +1719,8 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1719
1719
|
return this.pluginManager;
|
|
1720
1720
|
}
|
|
1721
1721
|
static indicators() {
|
|
1722
|
-
let e = new
|
|
1723
|
-
return
|
|
1722
|
+
let e = new E();
|
|
1723
|
+
return A(e), e.getAvailableIndicators();
|
|
1724
1724
|
}
|
|
1725
1725
|
setPanelPosition(e, t) {
|
|
1726
1726
|
this.layoutManager.setPanelPosition(e, t), this.updateViewportAndRender(), this.eventBus.emit("indicatorChange", {
|
|
@@ -1743,7 +1743,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1743
1743
|
paneMoveHost(e, t) {
|
|
1744
1744
|
let n = this.indicatorEngine.getIndicatorConfig(e), r = this.indicatorEngine.getIndicatorDescriptor(e);
|
|
1745
1745
|
if (!n || !r) return;
|
|
1746
|
-
let i =
|
|
1746
|
+
let i = M(r);
|
|
1747
1747
|
if (r.placement === "overlay" && i && g(n.params[i])) return;
|
|
1748
1748
|
if (t === "price") return r.placement === "overlay" && n.pane ? null : void 0;
|
|
1749
1749
|
if (t === "new") {
|
|
@@ -1850,12 +1850,12 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1850
1850
|
return this.features.legend ? e + this.chartLegend.getHeight() : e;
|
|
1851
1851
|
}
|
|
1852
1852
|
isTimeAligned() {
|
|
1853
|
-
return
|
|
1853
|
+
return L(this.options.chartType) ? !1 : this.getDisplayData().length === this.dataManager.getLength();
|
|
1854
1854
|
}
|
|
1855
1855
|
roundPrice(e) {
|
|
1856
1856
|
if (!Number.isFinite(e)) return e;
|
|
1857
1857
|
let t = this.stepAt(e);
|
|
1858
|
-
if (t !== void 0) return Number((Math.round(e / t) * t).toFixed(
|
|
1858
|
+
if (t !== void 0) return Number((Math.round(e / t) * t).toFixed(re(t)));
|
|
1859
1859
|
let { min: n, max: r } = this.viewport.getState().priceRange;
|
|
1860
1860
|
return Number(e.toFixed(this.marketPricePrecision ?? s(n, r)));
|
|
1861
1861
|
}
|
|
@@ -1936,7 +1936,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
1936
1936
|
}
|
|
1937
1937
|
autoFib() {
|
|
1938
1938
|
if (!this.features.drawings) return null;
|
|
1939
|
-
let e = this.getDisplayData(), t = this.viewport.getState(), n =
|
|
1939
|
+
let e = this.getDisplayData(), t = this.viewport.getState(), n = _t(e, t.visibleRange.from, t.visibleRange.to);
|
|
1940
1940
|
return n ? this.addDrawing({
|
|
1941
1941
|
type: "fibRetracement",
|
|
1942
1942
|
anchors: [n[0], n[1]]
|
|
@@ -2011,7 +2011,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
2011
2011
|
recordUndo(e) {
|
|
2012
2012
|
if (!this.features.drawingUndoRedo || typeof e?.undo != "function" || typeof e.redo != "function") return;
|
|
2013
2013
|
let t = performance.now(), n = this.undoRedoManager.last();
|
|
2014
|
-
if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at <
|
|
2014
|
+
if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at < In) {
|
|
2015
2015
|
this.undoRedoManager.replaceLast({
|
|
2016
2016
|
...n,
|
|
2017
2017
|
custom: {
|
|
@@ -2058,7 +2058,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
2058
2058
|
x: t.x,
|
|
2059
2059
|
y: t.y
|
|
2060
2060
|
};
|
|
2061
|
-
if ((e === "plot" || e === "priceAxis") && (r.price =
|
|
2061
|
+
if ((e === "plot" || e === "priceAxis") && (r.price = Ft(t.y, n)), (e === "plot" || e === "timeAxis") && n.data.length > 0 && (r.time = F(t.x, n)), e === "pane") {
|
|
2062
2062
|
let e = this.getIndicatorPanes().find((e) => t.y >= e.rect.y && t.y <= e.rect.y + e.rect.height);
|
|
2063
2063
|
e && (r.pane = e.instanceId);
|
|
2064
2064
|
}
|
|
@@ -2084,7 +2084,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
2084
2084
|
...this.viewport.getState(),
|
|
2085
2085
|
data: this.getDisplayData()
|
|
2086
2086
|
};
|
|
2087
|
-
this.setVisibleRange(
|
|
2087
|
+
this.setVisibleRange(F(e.x0, t), F(e.x1, t));
|
|
2088
2088
|
}
|
|
2089
2089
|
lockAllDrawings() {
|
|
2090
2090
|
this.drawingManager.lockAllDrawings();
|
|
@@ -2129,7 +2129,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
2129
2129
|
for (let e of this.indicatorEngine.getActiveIndicators()) {
|
|
2130
2130
|
let t = this.indicatorEngine.getOutput(e.instanceId)?.series;
|
|
2131
2131
|
if (!t) continue;
|
|
2132
|
-
let r =
|
|
2132
|
+
let r = Kt(e.id, e.params, e.descriptor.defaultConfig, e.descriptor.shortName), o = e.descriptor.plots ?? Object.keys(t.find((e) => e) ?? {}).map((e) => ({
|
|
2133
2133
|
key: e,
|
|
2134
2134
|
title: e
|
|
2135
2135
|
}));
|
|
@@ -2153,11 +2153,11 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
2153
2153
|
}
|
|
2154
2154
|
getExportText(e = "csv", t = {}) {
|
|
2155
2155
|
let { bars: n, columns: r } = this.getExportData(t);
|
|
2156
|
-
return e === "json" ?
|
|
2156
|
+
return e === "json" ? w.toJSON(n, r) : w.toCSV(n, r);
|
|
2157
2157
|
}
|
|
2158
2158
|
download(e, t, n) {
|
|
2159
2159
|
let r = this.getExportText(e, n);
|
|
2160
|
-
e === "json" ?
|
|
2160
|
+
e === "json" ? w.download(r, t ?? "chart-data.json", "application/json") : w.download(r, t ?? "chart-data.csv", "text/csv");
|
|
2161
2161
|
}
|
|
2162
2162
|
setAutoSave(e, t = 5e3) {
|
|
2163
2163
|
this.autoSaveScheduler.enable(e, t);
|
|
@@ -2207,7 +2207,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
2207
2207
|
this.recordIndicators(e, () => this.updateIndicatorStyleNow(e, t));
|
|
2208
2208
|
}
|
|
2209
2209
|
updateIndicatorStyleNow(e, t) {
|
|
2210
|
-
let { plots: n, ...r } = t, i = n === void 0 ? void 0 :
|
|
2210
|
+
let { plots: n, ...r } = t, i = n === void 0 ? void 0 : ee(n);
|
|
2211
2211
|
this.indicatorEngine.updateIndicatorStyle(e, {
|
|
2212
2212
|
...r,
|
|
2213
2213
|
...i ? { plots: i } : {}
|
|
@@ -2317,8 +2317,8 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
2317
2317
|
this.features.trading && this.tradingManager.setConfig(e);
|
|
2318
2318
|
}
|
|
2319
2319
|
async connect(e) {
|
|
2320
|
-
if (!
|
|
2321
|
-
this.snapshotKey = null, this.replayStop(), this.disconnectStream(), this.streamManager = new
|
|
2320
|
+
if (!j(e.adapter, e.timeframe)) throw RangeError(`${e.adapter.name} cannot serve the ${e.timeframe} timeframe`);
|
|
2321
|
+
this.snapshotKey = null, this.replayStop(), this.disconnectStream(), this.streamManager = new rt(), this.streamManager.on("snapshot", (t) => {
|
|
2322
2322
|
let n = `${this.currentSymbol}|${this.streamTimeframe}`;
|
|
2323
2323
|
this.replaySession ? this.replaySession.live.setData(t) : n === this.snapshotKey && this.dataManager.getLength() > 0 ? this.mergeSnapshot(t) : this.setData(t), this.snapshotKey = n, this.useStreamHistory(e.adapter, e.historyPageSize);
|
|
2324
2324
|
}), this.streamManager.on("barClose", (e) => {
|
|
@@ -2326,7 +2326,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
2326
2326
|
this.replaySession.live.appendBar(e);
|
|
2327
2327
|
return;
|
|
2328
2328
|
}
|
|
2329
|
-
let t =
|
|
2329
|
+
let t = K(this.fullSeries ?? this.dataManager.getData(), e);
|
|
2330
2330
|
if (t === "stale" || !this.takeBar(e, t)) return;
|
|
2331
2331
|
let n = this.autoScrollOnNewBar && this.viewport.isAtEnd();
|
|
2332
2332
|
if (!this.placeStreamBar(e)) return;
|
|
@@ -2338,7 +2338,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
2338
2338
|
return;
|
|
2339
2339
|
}
|
|
2340
2340
|
this.currentPriceLine.setPrice(e.close);
|
|
2341
|
-
let t =
|
|
2341
|
+
let t = K(this.fullSeries ?? this.dataManager.getData(), e);
|
|
2342
2342
|
if (t === "stale" || !this.takeBar(e, t) || !this.placeStreamBar(e)) {
|
|
2343
2343
|
this.scheduleRender();
|
|
2344
2344
|
return;
|
|
@@ -2367,14 +2367,14 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
2367
2367
|
}), this.streamManager.on("symbolInfo", (e) => this.applyFeedSymbolInfo(e)), this.autoScrollOnNewBar = e.autoScroll !== !1, this.setStreamTarget(e.symbol, e.timeframe), this.streamAdapter = e.adapter;
|
|
2368
2368
|
let t = this.streamManager;
|
|
2369
2369
|
if (this.resolveStreamSymbol(e.adapter, e.symbol), await t.connect(e), this.streamManager !== t) return;
|
|
2370
|
-
let n =
|
|
2370
|
+
let n = ae(e.timeframe);
|
|
2371
2371
|
this.barCountdown.setTimeframeMs(n), this.countdownInterval && clearInterval(this.countdownInterval), this.countdownInterval = setInterval(() => {
|
|
2372
2372
|
this.barCountdown.isVisible() && this.engine.requestRender(r.Hover);
|
|
2373
2373
|
}, 1e3);
|
|
2374
2374
|
}
|
|
2375
2375
|
setStreamTarget(e, t) {
|
|
2376
2376
|
let n = this.announcedSymbol, r = this.announcedTimeframe;
|
|
2377
|
-
this.currentSymbol = e, this.streamTimeframe = t, this.tickStream =
|
|
2377
|
+
this.currentSymbol = e, this.streamTimeframe = t, this.tickStream = ie(t) !== null, this.applyTimeSpacing(), e !== n && (this.announcedSymbol = e, this.eventBus.emit("symbolChange", {
|
|
2378
2378
|
symbol: e,
|
|
2379
2379
|
previous: n
|
|
2380
2380
|
})), t !== r && (this.announcedTimeframe = t, this.eventBus.emit("timeframeChange", {
|
|
@@ -2385,8 +2385,8 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
2385
2385
|
async switchStream(e, t) {
|
|
2386
2386
|
if (!this.streamManager) return;
|
|
2387
2387
|
let n = this.streamAdapter;
|
|
2388
|
-
if (n && !
|
|
2389
|
-
this.setStreamTarget(e, t), this.historyFromStream && this.history.setLoader(null), this.barCountdown.setTimeframeMs(
|
|
2388
|
+
if (n && !j(n, t)) throw RangeError(`${n.name} cannot serve the ${t} timeframe`);
|
|
2389
|
+
this.setStreamTarget(e, t), this.historyFromStream && this.history.setLoader(null), this.barCountdown.setTimeframeMs(ae(t)), n && this.resolveStreamSymbol(n, e), await this.streamManager.switchTo(e, t);
|
|
2390
2390
|
}
|
|
2391
2391
|
isTimeframeAllowed(e) {
|
|
2392
2392
|
let t = this.features.timeframes;
|
|
@@ -2401,7 +2401,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
2401
2401
|
}
|
|
2402
2402
|
connectExecution(e, t = {}) {
|
|
2403
2403
|
if (!this.features.trading) throw Error("connectExecution requires features.trading to be enabled");
|
|
2404
|
-
this.disconnectExecution(), this.executionAdapter = e, this.execTeardown =
|
|
2404
|
+
this.disconnectExecution(), this.executionAdapter = e, this.execTeardown = kn(e, {
|
|
2405
2405
|
onIntent: (e, t) => {
|
|
2406
2406
|
let n = (e) => t(e.payload);
|
|
2407
2407
|
return this.eventBus.on(e, n), () => this.eventBus.off(e, n);
|
|
@@ -2492,18 +2492,18 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
2492
2492
|
goToTime(e) {
|
|
2493
2493
|
let t = this.getDisplayData();
|
|
2494
2494
|
if (t.length === 0 || !Number.isFinite(e)) return -1;
|
|
2495
|
-
let n = Math.max(0, Math.min(t.length - 1, Math.floor(
|
|
2495
|
+
let n = Math.max(0, Math.min(t.length - 1, Math.floor(N(e, t)))), r = this.viewport.getState(), i = n * (r.barWidth + r.barSpacing) + r.barWidth / 2 - r.chartRect.width / 2;
|
|
2496
2496
|
return this.viewport.scrollBy(i - r.offset), this.updateViewportAndRender(), n;
|
|
2497
2497
|
}
|
|
2498
2498
|
setVisibleRangePreset(e) {
|
|
2499
2499
|
let t = this.getDisplayData();
|
|
2500
2500
|
if (t.length === 0) return;
|
|
2501
|
-
let n = t.length - 1, r = t[n].time >
|
|
2501
|
+
let n = t.length - 1, r = t[n].time > jn ? 1 : 1e3, i = Ct(e, t[n].time * r, this.displayTz), a = i === null ? null : i / r;
|
|
2502
2502
|
if (a === null || a < t[0].time) {
|
|
2503
2503
|
this.fitContent();
|
|
2504
2504
|
return;
|
|
2505
2505
|
}
|
|
2506
|
-
let o =
|
|
2506
|
+
let o = N(a, t), s = Math.min(n, e === "YTD" ? Math.ceil(o) : Math.floor(o) + 1);
|
|
2507
2507
|
this.viewport.zoomToBarRange(s, n + this.viewport.getRightMargin()), this.viewport.scrollToEnd(), this.updateViewportAndRender();
|
|
2508
2508
|
}
|
|
2509
2509
|
scrollToEnd() {
|
|
@@ -2517,7 +2517,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
2517
2517
|
setVisibleRange(e, t) {
|
|
2518
2518
|
let n = this.dataManager.getData();
|
|
2519
2519
|
if (n.length === 0) return;
|
|
2520
|
-
let r =
|
|
2520
|
+
let r = N(Math.min(e, t), n), i = N(Math.max(e, t), n);
|
|
2521
2521
|
this.viewport.zoomToBarRange(r, i), this.updateViewportAndRender();
|
|
2522
2522
|
}
|
|
2523
2523
|
setPanLimits(e) {
|
|
@@ -2560,7 +2560,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
2560
2560
|
this.applyStyle(e, t.layer ?? "host", !0);
|
|
2561
2561
|
}
|
|
2562
2562
|
setOverrides(e, t = {}) {
|
|
2563
|
-
let n = t.layer ?? "host", { overrides: r, rejected: i } =
|
|
2563
|
+
let n = t.layer ?? "host", { overrides: r, rejected: i } = y(e);
|
|
2564
2564
|
i.length > 0 && console.warn(`Style overrides left out (unknown key or value): ${i.join(", ")}`);
|
|
2565
2565
|
let a = Object.fromEntries(Object.entries(r).filter(([, e]) => e !== null));
|
|
2566
2566
|
this.themeManager.setOverrides(a, n) && this.styleChanged(n);
|
|
@@ -2579,7 +2579,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
2579
2579
|
return this.themeManager.getStyleValue(e);
|
|
2580
2580
|
}
|
|
2581
2581
|
applyStyle(e, t, n) {
|
|
2582
|
-
let { overrides: r, rejected: i } =
|
|
2582
|
+
let { overrides: r, rejected: i } = y(e);
|
|
2583
2583
|
i.length > 0 && console.warn(`Style overrides left out (unknown key or value): ${i.join(", ")}`), this.themeManager.applyOverrides(r, t) && n && this.styleChanged(t);
|
|
2584
2584
|
}
|
|
2585
2585
|
styleChanged(e) {
|
|
@@ -2609,7 +2609,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
2609
2609
|
e ? this.crosshairHandler.onPointerMove(e) : this.crosshairHandler.onPointerLeave(), this.engine.requestRender(r.Hover);
|
|
2610
2610
|
}
|
|
2611
2611
|
setCrosshairTime(e) {
|
|
2612
|
-
let t = this.getDisplayData(), n = e === null || t.length === 0 ? null : Math.floor(
|
|
2612
|
+
let t = this.getDisplayData(), n = e === null || t.length === 0 ? null : Math.floor(N(e, t));
|
|
2613
2613
|
n !== this.crosshairHandler.getSyncedSlot() && (this.crosshairHandler.setSyncedSlot(n), this.engine.requestRender(r.Hover));
|
|
2614
2614
|
}
|
|
2615
2615
|
getData() {
|
|
@@ -2671,7 +2671,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
2671
2671
|
this.periodLevels.setPeriod(e), this.engine.requestRender(r.Main);
|
|
2672
2672
|
}
|
|
2673
2673
|
setTimezone(e) {
|
|
2674
|
-
|
|
2674
|
+
Nn(e), this.timezoneSetting = e, this.applyTimezone();
|
|
2675
2675
|
}
|
|
2676
2676
|
getTimezone() {
|
|
2677
2677
|
return this.timezoneSetting;
|
|
@@ -2689,7 +2689,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
2689
2689
|
sessions: e.sessions?.map((e) => ({ ...e }))
|
|
2690
2690
|
} : null, this.priceAxis.setPriceTick(this.symbolInfo?.minTick ?? null), this.marketConfig?.pricePrecision === void 0 && this.applyPricePrecision(this.symbolInfo?.pricePrecision ?? null);
|
|
2691
2691
|
let t = (this.symbolInfo?.sessions ?? []).flatMap((e) => {
|
|
2692
|
-
let t =
|
|
2692
|
+
let t = S(e.start), n = S(e.end);
|
|
2693
2693
|
return t === null || n === null ? [] : [{
|
|
2694
2694
|
startMinute: t,
|
|
2695
2695
|
endMinute: n
|
|
@@ -2746,7 +2746,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
2746
2746
|
return this.sessionShading.isVisible();
|
|
2747
2747
|
}
|
|
2748
2748
|
setSessionShadingConfig(e) {
|
|
2749
|
-
this.hostSessionHours =
|
|
2749
|
+
this.hostSessionHours = xt(this.hostSessionHours, e), this.sessionShading.replaceConfig(this.hostSessionHours), this.engine.requestRender(r.Background);
|
|
2750
2750
|
}
|
|
2751
2751
|
setTooltipVisible(e) {
|
|
2752
2752
|
e || this.crosshairTooltip.hide();
|
|
@@ -2765,11 +2765,11 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
2765
2765
|
return this.waitForGpu(null), e === "canvas" ? (this.applyRenderer(null), "canvas") : this.engine.getGpu() ? "webgl" : this.takeGpu(e, t, !0);
|
|
2766
2766
|
}
|
|
2767
2767
|
async takeGpu(e, t, n) {
|
|
2768
|
-
let { gpu: r, reason: i } = await
|
|
2769
|
-
return t !== this.rendererToken || this.disposed ? (r?.destroy(), this.getRenderer()) : i === "limit" ?
|
|
2768
|
+
let { gpu: r, reason: i } = await bt(e);
|
|
2769
|
+
return t !== this.rendererToken || this.disposed ? (r?.destroy(), this.getRenderer()) : i === "limit" ? vt() > 0 ? this.takeGpu(e, t, n) : (this.waitForGpu(() => void this.takeGpu(e, t, !1)), n && this.applyRenderer(null, "limit"), this.getRenderer()) : ((r || n) && this.applyRenderer(r, i), this.getRenderer());
|
|
2770
2770
|
}
|
|
2771
2771
|
waitForGpu(e) {
|
|
2772
|
-
this.stopWaitingForGpu?.(), this.stopWaitingForGpu = e ?
|
|
2772
|
+
this.stopWaitingForGpu?.(), this.stopWaitingForGpu = e ? Mt(e) : null;
|
|
2773
2773
|
}
|
|
2774
2774
|
getRenderer() {
|
|
2775
2775
|
return this.engine.getGpu() ? "webgl" : "canvas";
|
|
@@ -2787,23 +2787,23 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
2787
2787
|
this.engine.getGpu() && this.engine.renderNow();
|
|
2788
2788
|
}
|
|
2789
2789
|
screenshot(e) {
|
|
2790
|
-
this.features.screenshot && (this.freshFrame(),
|
|
2790
|
+
this.features.screenshot && (this.freshFrame(), k.download(this.container, e, this.themeManager.getTheme().background));
|
|
2791
2791
|
}
|
|
2792
2792
|
async copyScreenshot() {
|
|
2793
2793
|
if (!this.features.screenshot) return !1;
|
|
2794
2794
|
try {
|
|
2795
2795
|
this.freshFrame();
|
|
2796
|
-
let e = await
|
|
2796
|
+
let e = await k.toBlob(this.container, this.themeManager.getTheme().background), t = globalThis.ClipboardItem;
|
|
2797
2797
|
return !e || !navigator.clipboard?.write || !t ? !1 : (await navigator.clipboard.write([new t({ "image/png": e })]), !0);
|
|
2798
2798
|
} catch {
|
|
2799
2799
|
return !1;
|
|
2800
2800
|
}
|
|
2801
2801
|
}
|
|
2802
2802
|
screenshotDataURL() {
|
|
2803
|
-
return this.features.screenshot ? (this.freshFrame(),
|
|
2803
|
+
return this.features.screenshot ? (this.freshFrame(), k.toDataURL(this.container, this.themeManager.getTheme().background)) : null;
|
|
2804
2804
|
}
|
|
2805
2805
|
async screenshotBlob() {
|
|
2806
|
-
return this.features.screenshot ? (this.freshFrame(),
|
|
2806
|
+
return this.features.screenshot ? (this.freshFrame(), k.toBlob(this.container, this.themeManager.getTheme().background)) : null;
|
|
2807
2807
|
}
|
|
2808
2808
|
addAlert(e, t = "crossing", n, r = "price", i, a = {}) {
|
|
2809
2809
|
if (!this.features.alerts) return null;
|
|
@@ -2931,7 +2931,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
2931
2931
|
let t = this.replaySession ? this.replayOffset : 0;
|
|
2932
2932
|
if (!this.replaySession) {
|
|
2933
2933
|
if (this.dataManager.getLength() === 0) return;
|
|
2934
|
-
let e = new
|
|
2934
|
+
let e = new B();
|
|
2935
2935
|
e.setData(this.fullSeries ?? this.dataManager.getData()), this.replaySession = {
|
|
2936
2936
|
live: e,
|
|
2937
2937
|
price: null,
|
|
@@ -2939,23 +2939,23 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
2939
2939
|
};
|
|
2940
2940
|
}
|
|
2941
2941
|
let { steps: n, startTime: r, hideHistory: i, revealMarks: a, ...o } = e ?? {}, s = this.shownBars(this.replaySession.live.getData()), c = t > 0 && r === void 0 && i !== !1, l = o.startIndex;
|
|
2942
|
-
r !== void 0 && l === void 0 ? l =
|
|
2942
|
+
r !== void 0 && l === void 0 ? l = qn(s, r) : c && l !== void 0 && (l += t);
|
|
2943
2943
|
let u = c ? t : i && l !== void 0 && l > 0 ? Math.min(Math.floor(l), s.length - 1) : 0, d = u > 0 ? s.slice(u) : s;
|
|
2944
2944
|
l !== void 0 && (o.startIndex = l - u), this.replayOffset = u, this.replayRevealMarks = a !== !1;
|
|
2945
|
-
let f = n ?
|
|
2945
|
+
let f = n ? Zn(n, d) : null;
|
|
2946
2946
|
this.replayStepsSeries = f, this.replayCoarse = d, this.options.autoScale = !0, this.replayRestarting = !0;
|
|
2947
2947
|
try {
|
|
2948
2948
|
this.replayManager.load(f ?? d);
|
|
2949
2949
|
} finally {
|
|
2950
2950
|
this.replayRestarting = !1;
|
|
2951
2951
|
}
|
|
2952
|
-
f && o.startIndex !== void 0 && (o.startIndex =
|
|
2952
|
+
f && o.startIndex !== void 0 && (o.startIndex = er(f, d, o.startIndex)), this.replayBarUnsub?.();
|
|
2953
2953
|
let p = -1, m = -1, h = null, g = f ?? d;
|
|
2954
2954
|
this.replayBarUnsub = this.replayManager.on("bar", ({ index: e }) => {
|
|
2955
2955
|
let t = e, n = d[e];
|
|
2956
2956
|
if (f) {
|
|
2957
2957
|
let r = f[e];
|
|
2958
|
-
t =
|
|
2958
|
+
t = $n(d, r.time), h = h !== null && m === e - 1 && t === p - 1 && h ? nr(h, r) : tr(d[t], f, e), n = h;
|
|
2959
2959
|
}
|
|
2960
2960
|
m = e;
|
|
2961
2961
|
let r = t + 1, i = p > 0 && r >= p && this.dataManager.getLength() === p, a = !(i && !this.replaySeeking) || this.autoScrollOnNewBar && this.viewport.isAtEnd();
|
|
@@ -3007,20 +3007,20 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
3007
3007
|
return;
|
|
3008
3008
|
}
|
|
3009
3009
|
if (i.time <= n.fedTime) return;
|
|
3010
|
-
let a = e.slice(
|
|
3010
|
+
let a = e.slice(Jn(e, n.fedTime), t + 1);
|
|
3011
3011
|
n.fedTime = i.time;
|
|
3012
|
-
let o = Math.ceil(a.length /
|
|
3013
|
-
for (let e = 0; e < a.length; e += o) for (let [t, n] of
|
|
3012
|
+
let o = Math.ceil(a.length / Kn);
|
|
3013
|
+
for (let e = 0; e < a.length; e += o) for (let [t, n] of Yn(a.slice(e, e + o))) r.setMarkPrice(t, n);
|
|
3014
3014
|
this.tradingManager.setCurrentPrice(i.close);
|
|
3015
3015
|
}
|
|
3016
3016
|
getReplayBarIndex() {
|
|
3017
3017
|
if (!this.replaySession) return -1;
|
|
3018
3018
|
let { current: e } = this.replayManager.getProgress(), t = this.replayStepsSeries;
|
|
3019
|
-
return t && this.replayCoarse ?
|
|
3019
|
+
return t && this.replayCoarse ? $n(this.replayCoarse, t[e]?.time ?? -Infinity) : e;
|
|
3020
3020
|
}
|
|
3021
3021
|
replaySeekToBar(e) {
|
|
3022
3022
|
let t = this.replayStepsSeries;
|
|
3023
|
-
this.replaySeek(t && this.replayCoarse ?
|
|
3023
|
+
this.replaySeek(t && this.replayCoarse ? er(t, this.replayCoarse, e) : e);
|
|
3024
3024
|
}
|
|
3025
3025
|
replayPause() {
|
|
3026
3026
|
this.replayManager.pause();
|
|
@@ -3044,6 +3044,24 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
3044
3044
|
height: r
|
|
3045
3045
|
};
|
|
3046
3046
|
}
|
|
3047
|
+
getDrawingRect(e) {
|
|
3048
|
+
let t = this.drawingManager.getDrawings().find((t) => t.id === e);
|
|
3049
|
+
if (!t || !t.visible || t.anchors.length === 0) return null;
|
|
3050
|
+
let n = {
|
|
3051
|
+
...this.viewport.getState(),
|
|
3052
|
+
data: this.getDisplayData()
|
|
3053
|
+
}, r = n.chartRect, i = Infinity, a = -Infinity, o = Infinity, s = -Infinity;
|
|
3054
|
+
for (let e of t.anchors) {
|
|
3055
|
+
let t = Et(e.time, n), r = St(e.price, n);
|
|
3056
|
+
i = Math.min(i, t), a = Math.max(a, t), o = Math.min(o, r), s = Math.max(s, r);
|
|
3057
|
+
}
|
|
3058
|
+
return zn.has(t.type) ? [i, a] = [r.x, r.x + r.width] : t.type === "horizontalRay" && (a = r.x + r.width), Bn.has(t.type) && ([o, s] = [r.y, r.y + r.height]), i = Math.max(i, r.x), a = Math.min(a, r.x + r.width), o = Math.max(o, r.y), s = Math.min(s, r.y + r.height), i <= a && o <= s ? {
|
|
3059
|
+
x: i,
|
|
3060
|
+
y: o,
|
|
3061
|
+
width: a - i,
|
|
3062
|
+
height: s - o
|
|
3063
|
+
} : null;
|
|
3064
|
+
}
|
|
3047
3065
|
endReplaySession() {
|
|
3048
3066
|
this.replaySession && (this.returnMarkToLive(), this.replaySession = null, this.replayStepsSeries = null, this.replayCoarse = null, this.replayBarUnsub?.(), this.replayBarUnsub = null, this.replayManager.stop(), this.replayOffset = 0, this.revealReplayMarks(null));
|
|
3049
3067
|
}
|
|
@@ -3065,7 +3083,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
3065
3083
|
return this.replayManager.getProgress();
|
|
3066
3084
|
}
|
|
3067
3085
|
captureSnapshot() {
|
|
3068
|
-
return
|
|
3086
|
+
return C.capture({
|
|
3069
3087
|
getDrawings: () => this.getDrawings(),
|
|
3070
3088
|
getTheme: () => this.themeManager.getBaseTheme(),
|
|
3071
3089
|
getAlerts: () => this.getAlerts(),
|
|
@@ -3078,14 +3096,14 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
3078
3096
|
});
|
|
3079
3097
|
}
|
|
3080
3098
|
restoreIndicators(e, t) {
|
|
3081
|
-
let n =
|
|
3099
|
+
let n = Hn(e), r = /* @__PURE__ */ new Map();
|
|
3082
3100
|
this.unrestoredIndicators = [];
|
|
3083
3101
|
let i = new Set(this.indicatorEngine.getAvailableIndicators().map((e) => e.id)), a = [], o = /* @__PURE__ */ new Set();
|
|
3084
3102
|
if (t) {
|
|
3085
3103
|
let e = new Map(n.map((e) => [e.instanceId, e])), t = this.getIndicatorSetup();
|
|
3086
3104
|
for (let n of t) {
|
|
3087
3105
|
let t = e.get(n.instanceId);
|
|
3088
|
-
t &&
|
|
3106
|
+
t && Un(n, t) && o.add(n.instanceId);
|
|
3089
3107
|
}
|
|
3090
3108
|
for (let e of t) o.has(e.instanceId) || this.removeIndicator(e.instanceId);
|
|
3091
3109
|
for (let e of [...o]) this.indicatorEngine.getIndicatorConfig(e) || o.delete(e);
|
|
@@ -3145,7 +3163,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
3145
3163
|
let o = this.indicatorEngine.getIndicatorConfig(e);
|
|
3146
3164
|
(t.visible ?? !0) !== (o?.visible ?? !0) && this.setIndicatorVisible(e, t.visible ?? !0);
|
|
3147
3165
|
let s = t.levels ?? null;
|
|
3148
|
-
JSON.stringify(s) !== JSON.stringify(o?.levels ?? null) && this.setIndicatorLevels(e, s), this.setPaneStyleNow(e, t.paneStyle ?
|
|
3166
|
+
JSON.stringify(s) !== JSON.stringify(o?.levels ?? null) && this.setIndicatorLevels(e, s), this.setPaneStyleNow(e, t.paneStyle ? x(t.paneStyle) : null);
|
|
3149
3167
|
}
|
|
3150
3168
|
restorePanes(e) {
|
|
3151
3169
|
for (let [t, n] of e) t.paneSize !== void 0 && this.layoutManager.setPanelSize(n, t.paneSize), (t.paneSize !== void 0 || t.paneCollapsed) && this.layoutManager.setPanelCollapsed(n, !!t.paneCollapsed), t.paneSize !== void 0 && this.layoutManager.setPanelScale(n, {
|
|
@@ -3226,7 +3244,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
3226
3244
|
if (this.indicatorHistoryDepth > 0 || !this.features.drawingUndoRedo) return t();
|
|
3227
3245
|
let n = this.getIndicatorSetup(), r = this.withoutIndicatorHistory(t), i = this.getIndicatorSetup();
|
|
3228
3246
|
if (JSON.stringify(n) === JSON.stringify(i)) return r;
|
|
3229
|
-
let a = performance.now(), o = this.undoRedoManager.last(), s = e !== void 0 && o?.type === "indicators" && o.indicators?.subject === e && a - (o.indicators.at ?? 0) <
|
|
3247
|
+
let a = performance.now(), o = this.undoRedoManager.last(), s = e !== void 0 && o?.type === "indicators" && o.indicators?.subject === e && a - (o.indicators.at ?? 0) < In && JSON.stringify(o.indicators.after) === JSON.stringify(n), c = {
|
|
3230
3248
|
type: "indicators",
|
|
3231
3249
|
before: null,
|
|
3232
3250
|
after: null
|
|
@@ -3254,12 +3272,12 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
3254
3272
|
}
|
|
3255
3273
|
saveState(e) {
|
|
3256
3274
|
if (!this.features.saveLoad) return null;
|
|
3257
|
-
let t = this.captureSnapshot(), n =
|
|
3258
|
-
return e &&
|
|
3275
|
+
let t = this.captureSnapshot(), n = C.serialize(t);
|
|
3276
|
+
return e && C.saveToStorage(e, t), n;
|
|
3259
3277
|
}
|
|
3260
3278
|
loadState(e) {
|
|
3261
3279
|
if (!this.features.saveLoad) return;
|
|
3262
|
-
let t =
|
|
3280
|
+
let t = C.deserialize(e);
|
|
3263
3281
|
this.chartTypeOptions = t.chartTypeOptions ?? {}, this.displayDataCache = null, t.chartType && this.setChartType(t.chartType), t.drawings && this.setDrawings(t.drawings), (t.theme === "dark" || t.theme === "light") && this.setTheme(t.theme), t.version >= 3 && this.themeManager.setUserOverrides(t.overrides ?? {}) && this.styleChanged("user");
|
|
3264
3282
|
let n = t.version >= 2 && this.features.indicators ? this.withoutIndicatorHistory(() => this.restoreIndicators(t.indicators, !1)) : /* @__PURE__ */ new Map();
|
|
3265
3283
|
if (this.undoRedoManager.clear(), t.alerts && this.features.alerts) {
|
|
@@ -3270,7 +3288,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
3270
3288
|
let t = e.indexOf(":"), r = t > 0 ? n.get(e.slice(0, t)) : void 0;
|
|
3271
3289
|
return r ? r + e.slice(t) : e;
|
|
3272
3290
|
}, r = t(e.channel), i = {
|
|
3273
|
-
...
|
|
3291
|
+
...wt(e),
|
|
3274
3292
|
...e.target ? { target: t(e.target) } : {}
|
|
3275
3293
|
};
|
|
3276
3294
|
if (!e.expired) {
|
|
@@ -3290,19 +3308,19 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
3290
3308
|
}
|
|
3291
3309
|
loadStateFromStorage(e) {
|
|
3292
3310
|
if (!this.features.saveLoad) return !1;
|
|
3293
|
-
let t =
|
|
3294
|
-
return t ? (this.loadState(
|
|
3311
|
+
let t = C.loadFromStorage(e);
|
|
3312
|
+
return t ? (this.loadState(C.serialize(t)), !0) : !1;
|
|
3295
3313
|
}
|
|
3296
3314
|
downloadState(e) {
|
|
3297
|
-
this.features.saveLoad &&
|
|
3315
|
+
this.features.saveLoad && C.downloadFile(this.captureSnapshot(), e);
|
|
3298
3316
|
}
|
|
3299
3317
|
async loadStateFromFile() {
|
|
3300
3318
|
if (!this.features.saveLoad) return;
|
|
3301
|
-
let e = await
|
|
3302
|
-
this.loadState(
|
|
3319
|
+
let e = await C.loadFromFile();
|
|
3320
|
+
this.loadState(C.serialize(e));
|
|
3303
3321
|
}
|
|
3304
3322
|
setLocale(e) {
|
|
3305
|
-
|
|
3323
|
+
ne(e), this.engine.requestRender();
|
|
3306
3324
|
}
|
|
3307
3325
|
setNumberLocale(e) {
|
|
3308
3326
|
this.numberLocale = e, this.priceAxis.setLocale(e), this.leftPriceAxis.setLocale(e), this.crosshairHandler.setLocale(e), this.chartLegend.setLocale(e), this.crosshairTooltip.setLocale(e), this.sessionBreaks.setLocale(e), this.currentPriceLine.setLocale(e), this.updateViewportAndRender();
|
|
@@ -3318,15 +3336,15 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
3318
3336
|
candleDown: e.colorScheme.down,
|
|
3319
3337
|
candleUpWick: e.colorScheme.up,
|
|
3320
3338
|
candleDownWick: e.colorScheme.down,
|
|
3321
|
-
volumeUp:
|
|
3322
|
-
volumeDown:
|
|
3339
|
+
volumeUp: oe(e.colorScheme.up),
|
|
3340
|
+
volumeDown: oe(e.colorScheme.down)
|
|
3323
3341
|
};
|
|
3324
3342
|
this.themeManager.setTheme(t);
|
|
3325
3343
|
}
|
|
3326
3344
|
e.pricePrecision !== void 0 && this.applyPricePrecision(e.pricePrecision), this.updateViewportAndRender();
|
|
3327
3345
|
}
|
|
3328
3346
|
applyPricePrecision(e) {
|
|
3329
|
-
this.marketPricePrecision = e, this.priceAxis.setPricePrecision(e), this.tradingManager.setConfig({ pricePrecision: e ?? void 0 }), this.alertManager.setPricePrecision(e ??
|
|
3347
|
+
this.marketPricePrecision = e, this.priceAxis.setPricePrecision(e), this.tradingManager.setConfig({ pricePrecision: e ?? void 0 }), this.alertManager.setPricePrecision(e ?? Pn), this.streamManager?.priceLine.setPricePrecision(e), this.currentPriceLine.setPricePrecision(e), this.crosshairHandler.setPricePrecision(e), this.chartLegend.setPricePrecision(e), this.crosshairTooltip.setPricePrecision(e);
|
|
3330
3348
|
}
|
|
3331
3349
|
getMarket() {
|
|
3332
3350
|
return this.marketConfig;
|
|
@@ -3363,15 +3381,15 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
3363
3381
|
this.disposed = !0, this.waitForGpu(null), this.countdownInterval && clearInterval(this.countdownInterval), this.history.setLoader(null), this.disableAutoSave(), this.disconnectStream(), this.disconnectExecution(), this.onWindowKeyDown &&= (window.removeEventListener("keydown", this.onWindowKeyDown), null), this.keyboardHandler = null, this.a11y?.destroy(), this.a11y = null, this.interactionManager.detach(), this.tradingManager.destroy(), this.animator.dispose(), this.crosshairTooltip.destroy(), this.pinnedTooltip.destroy(), this.replayRestarting = !0, this.replayManager.dispose(), this.alertManager.dispose(), this.undoRedoManager.clear(), this.engine.destroy(), this.eventBus.destroy(), this.container.innerHTML = "";
|
|
3364
3382
|
}
|
|
3365
3383
|
createChartRenderer(e) {
|
|
3366
|
-
let t =
|
|
3367
|
-
return t instanceof
|
|
3384
|
+
let t = Qt(e, (e) => this.pluginManager.getChartType(e));
|
|
3385
|
+
return t instanceof T && t.setPriceText((e) => this.formatPrice(e)), t;
|
|
3368
3386
|
}
|
|
3369
3387
|
getDisplayData() {
|
|
3370
3388
|
if (this.displayDataCache) return this.displayDataCache;
|
|
3371
3389
|
let e = this.dataManager.getData();
|
|
3372
3390
|
if (e.length === 0) return e;
|
|
3373
|
-
let t =
|
|
3374
|
-
return this.chartRenderer instanceof
|
|
3391
|
+
let t = $t(this.options.chartType, e, (e) => this.pluginManager.getChartType(e), this.chartTypeOptions);
|
|
3392
|
+
return this.chartRenderer instanceof D && !this.pluginManager.getChartType(this.options.chartType) && this.chartRenderer.setBoxSize(Xt(e, this.chartTypeOptions)), this.displayDataCache = t, t;
|
|
3375
3393
|
}
|
|
3376
3394
|
recalcIndicatorsFrom(e, t) {
|
|
3377
3395
|
this.indicatorEngine.recalculateFrom(e, t), this.announceIndicatorUpdate(t);
|
|
@@ -3406,7 +3424,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
3406
3424
|
this.viewport.setScaleBaseline(t[e]?.close);
|
|
3407
3425
|
}
|
|
3408
3426
|
if (n) {
|
|
3409
|
-
let e =
|
|
3427
|
+
let e = Gn(this.indicatorEngine.getOverlayPriceRange(r.visibleRange.from, Math.min(r.visibleRange.to, t.length - 1)), this.features.compareSymbols ? this.compareRenderer.getPriceRange(t, r) : null);
|
|
3410
3428
|
if (e) {
|
|
3411
3429
|
let t = r.priceRange, n = Math.min(t.min, e.min), i = Math.max(t.max, e.max);
|
|
3412
3430
|
if (n < t.min || i > t.max) {
|
|
@@ -3430,7 +3448,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
3430
3448
|
fitLeftAxisWidth() {
|
|
3431
3449
|
let e = this.leftViewport;
|
|
3432
3450
|
if (!e) return !1;
|
|
3433
|
-
let t = this.themeManager.getTheme(), n =
|
|
3451
|
+
let t = this.themeManager.getTheme(), n = _n({
|
|
3434
3452
|
min: e.priceRange.min,
|
|
3435
3453
|
max: e.priceRange.max,
|
|
3436
3454
|
lastPrice: null,
|
|
@@ -3439,12 +3457,12 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
3439
3457
|
fontFamily: t.font.family,
|
|
3440
3458
|
fontSizeSmall: t.font.sizeSmall,
|
|
3441
3459
|
measure: (e, t) => this.measureText(e, t)
|
|
3442
|
-
}), r =
|
|
3460
|
+
}), r = vn(this.leftAxisWidth, n);
|
|
3443
3461
|
return r === this.leftAxisWidth ? !1 : (this.leftAxisWidth = r, this.layoutManager.setLeftAxisWidth(r), this.resolvedLayoutCache = null, this.panelInfoCache = null, this.viewport.setChartRect(this.getResolvedLayout().mainChartRect), !0);
|
|
3444
3462
|
}
|
|
3445
3463
|
fitPriceAxisWidth() {
|
|
3446
3464
|
if (!this.features.priceAxis) return !1;
|
|
3447
|
-
let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n =
|
|
3465
|
+
let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n = _n({
|
|
3448
3466
|
min: e.min,
|
|
3449
3467
|
max: e.max,
|
|
3450
3468
|
lastPrice: this.currentPriceLine.getPrice(),
|
|
@@ -3455,7 +3473,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
3455
3473
|
fontFamily: t.font.family,
|
|
3456
3474
|
fontSizeSmall: t.font.sizeSmall,
|
|
3457
3475
|
measure: (e, t) => this.measureText(e, t)
|
|
3458
|
-
}), r =
|
|
3476
|
+
}), r = vn(this.priceAxisWidth, n);
|
|
3459
3477
|
return r === this.priceAxisWidth ? !1 : (this.priceAxisWidth = r, this.layoutManager.setPriceAxisWidth(r), this.viewport.setPriceAxisWidth(r), this.resolvedLayoutCache = null, this.panelInfoCache = null, this.viewport.setChartRect(this.getResolvedLayout().mainChartRect), !0);
|
|
3460
3478
|
}
|
|
3461
3479
|
measureText(e, t) {
|
|
@@ -3499,7 +3517,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
3499
3517
|
buildPanelRenderInfos() {
|
|
3500
3518
|
if (this.panelInfoCache) return this.panelInfoCache;
|
|
3501
3519
|
let e = this.getResolvedLayout(), t = this.viewport.getState(), { from: n, to: r } = t.visibleRange, i = e.panels.map((e) => {
|
|
3502
|
-
let i = e.config.logScale ? this.indicatorEngine.getPaneValueRange(e.config.id, n, r, !0) : null, a = i ?? this.indicatorEngine.getPaneValueRange(e.config.id, n, r) ?? { ...
|
|
3520
|
+
let i = e.config.logScale ? this.indicatorEngine.getPaneValueRange(e.config.id, n, r, !0) : null, a = i ?? this.indicatorEngine.getPaneValueRange(e.config.id, n, r) ?? { ...An }, o = {
|
|
3503
3521
|
x: e.rect.x,
|
|
3504
3522
|
y: e.rect.y + 20,
|
|
3505
3523
|
width: e.rect.width,
|
|
@@ -3581,7 +3599,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
3581
3599
|
});
|
|
3582
3600
|
}
|
|
3583
3601
|
drawOverlayPlugins(e, t) {
|
|
3584
|
-
let n =
|
|
3602
|
+
let n = xn(this.pluginManager.getOverlays(), t);
|
|
3585
3603
|
if (n.length === 0) return;
|
|
3586
3604
|
let r = {
|
|
3587
3605
|
viewport: this.viewport.getState(),
|
|
@@ -3602,7 +3620,7 @@ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
|
|
|
3602
3620
|
};
|
|
3603
3621
|
}
|
|
3604
3622
|
};
|
|
3605
|
-
function
|
|
3623
|
+
function Hn(e) {
|
|
3606
3624
|
let t = new Map(e.map((e) => [e.instanceId, e])), n = [], r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = (e) => {
|
|
3607
3625
|
if (r.has(e.instanceId) || i.has(e.instanceId)) return;
|
|
3608
3626
|
i.add(e.instanceId);
|
|
@@ -3616,26 +3634,26 @@ function Ln(e) {
|
|
|
3616
3634
|
for (let t of e) a(t);
|
|
3617
3635
|
return n;
|
|
3618
3636
|
}
|
|
3619
|
-
function
|
|
3637
|
+
function Un(e, t) {
|
|
3620
3638
|
return e.id === t.id && (e.pane ?? null) === (t.pane ?? null) && (e.scale ?? null) === (t.scale ?? null) && e.position === void 0 == (t.position === void 0);
|
|
3621
3639
|
}
|
|
3622
|
-
function
|
|
3640
|
+
function Wn(e) {
|
|
3623
3641
|
let t = e.tagRadius;
|
|
3624
3642
|
return typeof t == "number" && Number.isFinite(t) && t >= 0 ? { tagRadius: Math.min(t, 999) } : {};
|
|
3625
3643
|
}
|
|
3626
|
-
var
|
|
3644
|
+
var W = new Set([
|
|
3627
3645
|
"compareSymbol",
|
|
3628
3646
|
"spread",
|
|
3629
3647
|
"correlation",
|
|
3630
3648
|
"correlationlog"
|
|
3631
3649
|
]);
|
|
3632
|
-
function
|
|
3650
|
+
function Gn(e, t) {
|
|
3633
3651
|
return e ? t ? {
|
|
3634
3652
|
min: Math.min(e.min, t.min),
|
|
3635
3653
|
max: Math.max(e.max, t.max)
|
|
3636
3654
|
} : e : t;
|
|
3637
3655
|
}
|
|
3638
|
-
function
|
|
3656
|
+
function G(e) {
|
|
3639
3657
|
return {
|
|
3640
3658
|
id: e.id,
|
|
3641
3659
|
price: e.price,
|
|
@@ -3650,8 +3668,8 @@ function K(e) {
|
|
|
3650
3668
|
bars: e.bars
|
|
3651
3669
|
};
|
|
3652
3670
|
}
|
|
3653
|
-
var
|
|
3654
|
-
function
|
|
3671
|
+
var Kn = 500;
|
|
3672
|
+
function qn(e, t) {
|
|
3655
3673
|
let n = 0, r = e.length;
|
|
3656
3674
|
for (; n < r;) {
|
|
3657
3675
|
let i = n + r >> 1;
|
|
@@ -3659,7 +3677,7 @@ function Hn(e, t) {
|
|
|
3659
3677
|
}
|
|
3660
3678
|
return n;
|
|
3661
3679
|
}
|
|
3662
|
-
function
|
|
3680
|
+
function Jn(e, t) {
|
|
3663
3681
|
let n = 0, r = e.length;
|
|
3664
3682
|
for (; n < r;) {
|
|
3665
3683
|
let i = n + r >> 1;
|
|
@@ -3667,20 +3685,20 @@ function Un(e, t) {
|
|
|
3667
3685
|
}
|
|
3668
3686
|
return n;
|
|
3669
3687
|
}
|
|
3670
|
-
function
|
|
3688
|
+
function Yn(e) {
|
|
3671
3689
|
let t = 0, n = 0;
|
|
3672
3690
|
for (let r = 1; r < e.length; r++) e[r].low < e[t].low && (t = r), e[r].high > e[n].high && (n = r);
|
|
3673
3691
|
let r = [e[t].low, e[t].time], i = [e[n].high, e[n].time], a = t === n ? e[t].close >= e[t].open : t < n, o = e[e.length - 1];
|
|
3674
3692
|
return [...a ? [r, i] : [i, r], [o.close, o.time]];
|
|
3675
3693
|
}
|
|
3676
|
-
function
|
|
3694
|
+
function Xn(e) {
|
|
3677
3695
|
let t = 0;
|
|
3678
3696
|
for (let n = Math.max(1, e.length - 10); n < e.length; n++) t = Math.max(t, e[n].time - e[n - 1].time);
|
|
3679
3697
|
return t > 0 ? t : Infinity;
|
|
3680
3698
|
}
|
|
3681
|
-
function
|
|
3699
|
+
function Zn(e, t) {
|
|
3682
3700
|
if (t.length === 0) return null;
|
|
3683
|
-
let n = t[t.length - 1].time +
|
|
3701
|
+
let n = t[t.length - 1].time + Xn(t), r = e.filter((e) => Qn(e) && e.time >= t[0].time && e.time < n).sort((e, t) => e.time - t.time), i = [];
|
|
3684
3702
|
for (let e of r) (i.length === 0 || i[i.length - 1].time !== e.time) && i.push(e);
|
|
3685
3703
|
if (i.length === 0) return null;
|
|
3686
3704
|
let a = t.findIndex((e) => e.time >= i[0].time);
|
|
@@ -3688,7 +3706,7 @@ function Kn(e, t) {
|
|
|
3688
3706
|
let o = t.slice(0, a), s = i.filter((e) => e.time >= t[a].time);
|
|
3689
3707
|
return [...o, ...s];
|
|
3690
3708
|
}
|
|
3691
|
-
function
|
|
3709
|
+
function Qn(e) {
|
|
3692
3710
|
return [
|
|
3693
3711
|
e.time,
|
|
3694
3712
|
e.open,
|
|
@@ -3697,7 +3715,7 @@ function qn(e) {
|
|
|
3697
3715
|
e.close
|
|
3698
3716
|
].every(Number.isFinite);
|
|
3699
3717
|
}
|
|
3700
|
-
function
|
|
3718
|
+
function $n(e, t) {
|
|
3701
3719
|
let n = 0, r = e.length - 1;
|
|
3702
3720
|
for (; n < r;) {
|
|
3703
3721
|
let i = n + r + 1 >> 1;
|
|
@@ -3705,22 +3723,22 @@ function Jn(e, t) {
|
|
|
3705
3723
|
}
|
|
3706
3724
|
return n;
|
|
3707
3725
|
}
|
|
3708
|
-
function
|
|
3726
|
+
function er(e, t, n) {
|
|
3709
3727
|
let r = Math.max(0, Math.min(Math.floor(Number.isFinite(n) ? n : 0), t.length - 1)), i = r + 1 < t.length ? t[r + 1].time : Infinity, a = -1;
|
|
3710
3728
|
for (let t = 0; t < e.length && e[t].time < i; t++) a = t;
|
|
3711
3729
|
return Math.max(0, a);
|
|
3712
3730
|
}
|
|
3713
|
-
function
|
|
3731
|
+
function tr(e, t, n) {
|
|
3714
3732
|
let r = n;
|
|
3715
3733
|
for (; r > 0 && t[r - 1].time >= e.time;) r--;
|
|
3716
3734
|
let i = {
|
|
3717
3735
|
...t[r],
|
|
3718
3736
|
time: e.time
|
|
3719
3737
|
};
|
|
3720
|
-
for (let e = r + 1; e <= n; e++) i =
|
|
3738
|
+
for (let e = r + 1; e <= n; e++) i = nr(i, t[e]);
|
|
3721
3739
|
return i;
|
|
3722
3740
|
}
|
|
3723
|
-
function
|
|
3741
|
+
function nr(e, t) {
|
|
3724
3742
|
return {
|
|
3725
3743
|
time: e.time,
|
|
3726
3744
|
open: e.open,
|
|
@@ -3730,7 +3748,7 @@ function Zn(e, t) {
|
|
|
3730
3748
|
volume: (e.volume ?? 0) + (t.volume ?? 0)
|
|
3731
3749
|
};
|
|
3732
3750
|
}
|
|
3733
|
-
function
|
|
3751
|
+
function K(e, t) {
|
|
3734
3752
|
let n = e[e.length - 1];
|
|
3735
3753
|
if (!n) return "append";
|
|
3736
3754
|
let r = h(t.time), i = h(n.time);
|
|
@@ -3738,26 +3756,26 @@ function q(e, t) {
|
|
|
3738
3756
|
}
|
|
3739
3757
|
//#endregion
|
|
3740
3758
|
//#region src/io/parseOHLCV.ts
|
|
3741
|
-
var
|
|
3759
|
+
var rr = [
|
|
3742
3760
|
"time",
|
|
3743
3761
|
"timestamp",
|
|
3744
3762
|
"date",
|
|
3745
3763
|
"datetime",
|
|
3746
3764
|
"t"
|
|
3747
|
-
],
|
|
3765
|
+
], ir = ["open", "o"], ar = ["high", "h"], or = ["low", "l"], sr = ["close", "c"], cr = [
|
|
3748
3766
|
"volume",
|
|
3749
3767
|
"vol",
|
|
3750
3768
|
"v"
|
|
3751
3769
|
];
|
|
3752
|
-
function
|
|
3770
|
+
function lr(e) {
|
|
3753
3771
|
let t = e.trim();
|
|
3754
|
-
return t ? t[0] === "[" || t[0] === "{" ?
|
|
3772
|
+
return t ? t[0] === "[" || t[0] === "{" ? ur(t) : dr(t) : {
|
|
3755
3773
|
data: [],
|
|
3756
3774
|
rowCount: 0,
|
|
3757
3775
|
skipped: 0
|
|
3758
3776
|
};
|
|
3759
3777
|
}
|
|
3760
|
-
function
|
|
3778
|
+
function ur(e) {
|
|
3761
3779
|
let t;
|
|
3762
3780
|
try {
|
|
3763
3781
|
t = JSON.parse(e);
|
|
@@ -3767,19 +3785,19 @@ function ar(e) {
|
|
|
3767
3785
|
if (!Array.isArray(t)) throw Error("Expected a JSON array of OHLCV rows");
|
|
3768
3786
|
let n = [], r = 0;
|
|
3769
3787
|
for (let e of t) {
|
|
3770
|
-
let t = Array.isArray(e) ?
|
|
3788
|
+
let t = Array.isArray(e) ? gr(e) : hr(e);
|
|
3771
3789
|
t ? n.push(t) : r++;
|
|
3772
3790
|
}
|
|
3773
|
-
return
|
|
3791
|
+
return _r(n, t.length, r);
|
|
3774
3792
|
}
|
|
3775
|
-
function
|
|
3793
|
+
function dr(e) {
|
|
3776
3794
|
let t = e.split(/\r?\n/).filter((e) => e.trim().length > 0);
|
|
3777
3795
|
if (t.length === 0) return {
|
|
3778
3796
|
data: [],
|
|
3779
3797
|
rowCount: 0,
|
|
3780
3798
|
skipped: 0
|
|
3781
3799
|
};
|
|
3782
|
-
let n =
|
|
3800
|
+
let n = fr(t[0]), r = pr(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? mr(r) : {
|
|
3783
3801
|
time: 0,
|
|
3784
3802
|
open: 1,
|
|
3785
3803
|
high: 2,
|
|
@@ -3790,7 +3808,7 @@ function or(e) {
|
|
|
3790
3808
|
if (a.time < 0 || a.open < 0 || a.high < 0 || a.low < 0 || a.close < 0) throw Error("CSV is missing required column(s): time, open, high, low, close");
|
|
3791
3809
|
let o = [], s = 0;
|
|
3792
3810
|
for (let e = +!!i; e < t.length; e++) {
|
|
3793
|
-
let r =
|
|
3811
|
+
let r = pr(t[e], n), i = J(r[a.time]), c = q(r[a.open]), l = q(r[a.high]), u = q(r[a.low]), d = q(r[a.close]), f = a.volume >= 0 ? Number(r[a.volume]) : 0;
|
|
3794
3812
|
if (i === null || ![
|
|
3795
3813
|
c,
|
|
3796
3814
|
l,
|
|
@@ -3809,9 +3827,9 @@ function or(e) {
|
|
|
3809
3827
|
volume: Number.isFinite(f) ? f : 0
|
|
3810
3828
|
});
|
|
3811
3829
|
}
|
|
3812
|
-
return
|
|
3830
|
+
return _r(o, t.length - +!!i, s);
|
|
3813
3831
|
}
|
|
3814
|
-
function
|
|
3832
|
+
function fr(e) {
|
|
3815
3833
|
let t = {
|
|
3816
3834
|
",": 0,
|
|
3817
3835
|
";": 0,
|
|
@@ -3823,7 +3841,7 @@ function sr(e) {
|
|
|
3823
3841
|
for (let [e, i] of Object.entries(t)) i > r && (n = e, r = i);
|
|
3824
3842
|
return n;
|
|
3825
3843
|
}
|
|
3826
|
-
function
|
|
3844
|
+
function pr(e, t) {
|
|
3827
3845
|
let n = [], r = "", i = !1;
|
|
3828
3846
|
for (let a = 0; a < e.length; a++) {
|
|
3829
3847
|
let o = e[a];
|
|
@@ -3831,25 +3849,25 @@ function cr(e, t) {
|
|
|
3831
3849
|
}
|
|
3832
3850
|
return n.push(r), n;
|
|
3833
3851
|
}
|
|
3834
|
-
function
|
|
3852
|
+
function mr(e) {
|
|
3835
3853
|
let t = (t) => e.findIndex((e) => t.includes(e));
|
|
3836
3854
|
return {
|
|
3837
|
-
time: t(
|
|
3838
|
-
open: t(
|
|
3839
|
-
high: t(
|
|
3840
|
-
low: t(
|
|
3841
|
-
close: t(
|
|
3842
|
-
volume: t(
|
|
3855
|
+
time: t(rr),
|
|
3856
|
+
open: t(ir),
|
|
3857
|
+
high: t(ar),
|
|
3858
|
+
low: t(or),
|
|
3859
|
+
close: t(sr),
|
|
3860
|
+
volume: t(cr)
|
|
3843
3861
|
};
|
|
3844
3862
|
}
|
|
3845
|
-
function
|
|
3863
|
+
function hr(e) {
|
|
3846
3864
|
let t = (t) => {
|
|
3847
3865
|
for (let n of t) {
|
|
3848
3866
|
if (e[n] !== void 0) return e[n];
|
|
3849
3867
|
let t = n.toUpperCase();
|
|
3850
3868
|
if (e[t] !== void 0) return e[t];
|
|
3851
3869
|
}
|
|
3852
|
-
}, n =
|
|
3870
|
+
}, n = J(String(t(rr) ?? "")), r = Number(t(ir)), i = Number(t(ar)), a = Number(t(or)), o = Number(t(sr)), s = Number(t(cr) ?? 0);
|
|
3853
3871
|
return n === null || ![
|
|
3854
3872
|
r,
|
|
3855
3873
|
i,
|
|
@@ -3864,9 +3882,9 @@ function ur(e) {
|
|
|
3864
3882
|
volume: Number.isFinite(s) ? s : 0
|
|
3865
3883
|
};
|
|
3866
3884
|
}
|
|
3867
|
-
function
|
|
3885
|
+
function gr(e) {
|
|
3868
3886
|
if (e.length < 5) return null;
|
|
3869
|
-
let t =
|
|
3887
|
+
let t = J(String(e[0])), n = Number(e[1]), r = Number(e[2]), i = Number(e[3]), a = Number(e[4]), o = e.length >= 6 ? Number(e[5]) : 0;
|
|
3870
3888
|
return t === null || ![
|
|
3871
3889
|
n,
|
|
3872
3890
|
r,
|
|
@@ -3881,10 +3899,10 @@ function dr(e) {
|
|
|
3881
3899
|
volume: Number.isFinite(o) ? o : 0
|
|
3882
3900
|
};
|
|
3883
3901
|
}
|
|
3884
|
-
function
|
|
3902
|
+
function q(e) {
|
|
3885
3903
|
return e === void 0 || e.trim() === "" ? NaN : Number(e);
|
|
3886
3904
|
}
|
|
3887
|
-
function
|
|
3905
|
+
function J(e) {
|
|
3888
3906
|
let t = e.trim();
|
|
3889
3907
|
if (!t) return null;
|
|
3890
3908
|
let n = Number(t);
|
|
@@ -3892,7 +3910,7 @@ function Y(e) {
|
|
|
3892
3910
|
let r = Date.parse(t);
|
|
3893
3911
|
return Number.isFinite(r) ? r : null;
|
|
3894
3912
|
}
|
|
3895
|
-
function
|
|
3913
|
+
function _r(e, t, n) {
|
|
3896
3914
|
e.sort((e, t) => e.time - t.time);
|
|
3897
3915
|
let r = [];
|
|
3898
3916
|
for (let t of e) r.length > 0 && r[r.length - 1].time === t.time ? r[r.length - 1] = t : r.push(t);
|
|
@@ -3904,7 +3922,7 @@ function fr(e, t, n) {
|
|
|
3904
3922
|
}
|
|
3905
3923
|
//#endregion
|
|
3906
3924
|
//#region src/io/DragDropImporter.ts
|
|
3907
|
-
var
|
|
3925
|
+
var vr = class {
|
|
3908
3926
|
host;
|
|
3909
3927
|
overlay = null;
|
|
3910
3928
|
callbacks;
|
|
@@ -3925,19 +3943,19 @@ var pr = class {
|
|
|
3925
3943
|
this.host.removeEventListener("dragenter", this.bound.dragenter), this.host.removeEventListener("dragover", this.bound.dragover), this.host.removeEventListener("dragleave", this.bound.dragleave), this.host.removeEventListener("drop", this.bound.drop), this.hideOverlay();
|
|
3926
3944
|
}
|
|
3927
3945
|
onDragEnter(e) {
|
|
3928
|
-
|
|
3946
|
+
Y(e) && (e.preventDefault(), this.depth++, this.showOverlay());
|
|
3929
3947
|
}
|
|
3930
3948
|
onDragOver(e) {
|
|
3931
|
-
|
|
3949
|
+
Y(e) && (e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = "copy"));
|
|
3932
3950
|
}
|
|
3933
3951
|
onDragLeave(e) {
|
|
3934
|
-
|
|
3952
|
+
Y(e) && (this.depth = Math.max(0, this.depth - 1), this.depth === 0 && this.hideOverlay());
|
|
3935
3953
|
}
|
|
3936
3954
|
async onDrop(e) {
|
|
3937
3955
|
e.preventDefault(), this.depth = 0, this.hideOverlay();
|
|
3938
3956
|
let t = e.dataTransfer?.files?.[0];
|
|
3939
3957
|
if (t) try {
|
|
3940
|
-
let e =
|
|
3958
|
+
let e = lr(await t.text());
|
|
3941
3959
|
if (e.data.length === 0) throw Error(`No valid OHLCV rows found in "${t.name}"`);
|
|
3942
3960
|
this.callbacks.onData(e.data, e, t);
|
|
3943
3961
|
} catch (e) {
|
|
@@ -3968,12 +3986,12 @@ var pr = class {
|
|
|
3968
3986
|
this.overlay?.remove(), this.overlay = null;
|
|
3969
3987
|
}
|
|
3970
3988
|
};
|
|
3971
|
-
function
|
|
3989
|
+
function Y(e) {
|
|
3972
3990
|
return e.dataTransfer?.types?.includes("Files") ?? !1;
|
|
3973
3991
|
}
|
|
3974
3992
|
//#endregion
|
|
3975
3993
|
//#region src/state/layoutStorage.ts
|
|
3976
|
-
function
|
|
3994
|
+
function X(e) {
|
|
3977
3995
|
let t = {
|
|
3978
3996
|
id: e.id,
|
|
3979
3997
|
name: e.name,
|
|
@@ -3981,11 +3999,11 @@ function Z(e) {
|
|
|
3981
3999
|
};
|
|
3982
4000
|
return e.symbol !== void 0 && (t.symbol = e.symbol), e.timeframe !== void 0 && (t.timeframe = e.timeframe), e.kind !== void 0 && (t.kind = e.kind), t;
|
|
3983
4001
|
}
|
|
3984
|
-
var
|
|
4002
|
+
var Z = (e, t) => t.updatedAt - e.updatedAt;
|
|
3985
4003
|
function Q(e) {
|
|
3986
4004
|
if (typeof e != "object" || !e) return null;
|
|
3987
4005
|
let t = e;
|
|
3988
|
-
return typeof t.id != "string" || !t.id || typeof t.name != "string" || typeof t.updatedAt != "number" || !Number.isFinite(t.updatedAt) ? null :
|
|
4006
|
+
return typeof t.id != "string" || !t.id || typeof t.name != "string" || typeof t.updatedAt != "number" || !Number.isFinite(t.updatedAt) ? null : X({
|
|
3989
4007
|
id: t.id,
|
|
3990
4008
|
name: t.name,
|
|
3991
4009
|
updatedAt: t.updatedAt,
|
|
@@ -3994,17 +4012,17 @@ function Q(e) {
|
|
|
3994
4012
|
kind: typeof t.kind == "string" ? t.kind : void 0
|
|
3995
4013
|
});
|
|
3996
4014
|
}
|
|
3997
|
-
function
|
|
4015
|
+
function yr(e) {
|
|
3998
4016
|
let t = Q(e), n = t ? e.content : void 0;
|
|
3999
4017
|
return t && typeof n == "string" ? {
|
|
4000
4018
|
...t,
|
|
4001
4019
|
content: n
|
|
4002
4020
|
} : null;
|
|
4003
4021
|
}
|
|
4004
|
-
function
|
|
4022
|
+
function br(e = []) {
|
|
4005
4023
|
let t = new Map(e.map((e) => [e.id, { ...e }]));
|
|
4006
4024
|
return {
|
|
4007
|
-
list: () => [...t.values()].map(
|
|
4025
|
+
list: () => [...t.values()].map(X).sort(Z),
|
|
4008
4026
|
load: (e) => {
|
|
4009
4027
|
let n = t.get(e);
|
|
4010
4028
|
return n ? { ...n } : null;
|
|
@@ -4017,7 +4035,7 @@ function gr(e = []) {
|
|
|
4017
4035
|
}
|
|
4018
4036
|
};
|
|
4019
4037
|
}
|
|
4020
|
-
function
|
|
4038
|
+
function xr(e = "tcw:layouts:") {
|
|
4021
4039
|
let t = `${e}index`, n = (t) => `${e}item:${t}`, r = () => {
|
|
4022
4040
|
let e;
|
|
4023
4041
|
try {
|
|
@@ -4028,7 +4046,7 @@ function _r(e = "tcw:layouts:") {
|
|
|
4028
4046
|
return Array.isArray(e) ? e.map(Q).filter((e) => e !== null) : [];
|
|
4029
4047
|
}, i = (e) => localStorage.setItem(t, JSON.stringify(e));
|
|
4030
4048
|
return {
|
|
4031
|
-
list: () => r().sort(
|
|
4049
|
+
list: () => r().sort(Z),
|
|
4032
4050
|
load: (e) => {
|
|
4033
4051
|
let t = r().find((t) => t.id === e), i = t ? localStorage.getItem(n(e)) : null;
|
|
4034
4052
|
return t && i !== null ? {
|
|
@@ -4037,7 +4055,7 @@ function _r(e = "tcw:layouts:") {
|
|
|
4037
4055
|
} : null;
|
|
4038
4056
|
},
|
|
4039
4057
|
save: (e) => {
|
|
4040
|
-
localStorage.setItem(n(e.id), e.content), i([...r().filter((t) => t.id !== e.id),
|
|
4058
|
+
localStorage.setItem(n(e.id), e.content), i([...r().filter((t) => t.id !== e.id), X(e)]);
|
|
4041
4059
|
},
|
|
4042
4060
|
remove: (e) => {
|
|
4043
4061
|
i(r().filter((t) => t.id !== e)), localStorage.removeItem(n(e));
|
|
@@ -4046,14 +4064,14 @@ function _r(e = "tcw:layouts:") {
|
|
|
4046
4064
|
}
|
|
4047
4065
|
//#endregion
|
|
4048
4066
|
//#region src/state/LayoutSession.ts
|
|
4049
|
-
var
|
|
4067
|
+
var Sr = 80;
|
|
4050
4068
|
function $(e) {
|
|
4051
4069
|
return e.replace(/\s+/g, " ").trim().slice(0, 80).trim() || null;
|
|
4052
4070
|
}
|
|
4053
|
-
function
|
|
4071
|
+
function Cr() {
|
|
4054
4072
|
return globalThis.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
4055
4073
|
}
|
|
4056
|
-
function
|
|
4074
|
+
function wr(e) {
|
|
4057
4075
|
let { id: t, name: n, symbol: r, timeframe: i, updatedAt: a, kind: o } = e;
|
|
4058
4076
|
return {
|
|
4059
4077
|
id: t,
|
|
@@ -4064,7 +4082,7 @@ function br(e) {
|
|
|
4064
4082
|
...o === void 0 ? {} : { kind: o }
|
|
4065
4083
|
};
|
|
4066
4084
|
}
|
|
4067
|
-
var
|
|
4085
|
+
var Tr = class {
|
|
4068
4086
|
currentLayout = null;
|
|
4069
4087
|
savedContent = null;
|
|
4070
4088
|
dirty = !1;
|
|
@@ -4080,7 +4098,7 @@ var xr = class {
|
|
|
4080
4098
|
now;
|
|
4081
4099
|
newId;
|
|
4082
4100
|
constructor(e, t, n = {}) {
|
|
4083
|
-
this.storage = e, this.host = t, this.options = n, this.autoSave = n.autoSave ?? !0, this.debounceMs = n.debounceMs ?? 1500, this.kind = n.kind ?? "chart", this.now = n.now ?? Date.now, this.newId = n.newId ??
|
|
4101
|
+
this.storage = e, this.host = t, this.options = n, this.autoSave = n.autoSave ?? !0, this.debounceMs = n.debounceMs ?? 1500, this.kind = n.kind ?? "chart", this.now = n.now ?? Date.now, this.newId = n.newId ?? Cr;
|
|
4084
4102
|
}
|
|
4085
4103
|
current() {
|
|
4086
4104
|
return this.currentLayout;
|
|
@@ -4110,7 +4128,7 @@ var xr = class {
|
|
|
4110
4128
|
}
|
|
4111
4129
|
open(e) {
|
|
4112
4130
|
return this.queue(async () => {
|
|
4113
|
-
let t =
|
|
4131
|
+
let t = yr(await this.storage.load(e));
|
|
4114
4132
|
if (!t || t.id !== e || (t.kind ?? "chart") !== this.kind || this.destroyed) return !1;
|
|
4115
4133
|
this.cancelTimer(), this.applying++;
|
|
4116
4134
|
try {
|
|
@@ -4120,13 +4138,13 @@ var xr = class {
|
|
|
4120
4138
|
} finally {
|
|
4121
4139
|
this.applying--;
|
|
4122
4140
|
}
|
|
4123
|
-
return this.cancelTimer(), this.currentLayout =
|
|
4141
|
+
return this.cancelTimer(), this.currentLayout = wr(t), this.savedContent = this.host.capture().content, this.dirty = !1, this.notify(), !0;
|
|
4124
4142
|
});
|
|
4125
4143
|
}
|
|
4126
4144
|
rename(e, t) {
|
|
4127
4145
|
let n = $(t);
|
|
4128
4146
|
return n ? this.queue(async () => {
|
|
4129
|
-
let t =
|
|
4147
|
+
let t = yr(await this.storage.load(e));
|
|
4130
4148
|
!t || t.id !== e || (await this.storage.save({
|
|
4131
4149
|
...t,
|
|
4132
4150
|
name: n
|
|
@@ -4204,7 +4222,7 @@ var xr = class {
|
|
|
4204
4222
|
content: n.content
|
|
4205
4223
|
};
|
|
4206
4224
|
await this.storage.save(r);
|
|
4207
|
-
let i =
|
|
4225
|
+
let i = wr(r);
|
|
4208
4226
|
return this.currentLayout = i, this.savedContent = n.content, this.dirty = !1, this.notify(), i;
|
|
4209
4227
|
}
|
|
4210
4228
|
forget() {
|
|
@@ -4225,6 +4243,6 @@ var xr = class {
|
|
|
4225
4243
|
}
|
|
4226
4244
|
};
|
|
4227
4245
|
//#endregion
|
|
4228
|
-
export {
|
|
4246
|
+
export { Kt as C, B as S, H as _, br as a, an as b, Vn as c, Tn as d, wn as f, xn as g, bn as h, xr as i, Mn as l, Cn as m, Sr as n, vr as o, Sn as p, $ as r, lr as s, Tr as t, En as u, fn as v, nn as x, sn as y };
|
|
4229
4247
|
|
|
4230
|
-
//# sourceMappingURL=LayoutSession-
|
|
4248
|
+
//# sourceMappingURL=LayoutSession-CrMUvvtP.js.map
|