@tradecanvas/chart 1.69.0 → 1.71.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/dist/Chart.d.ts +19 -107
- package/dist/Chart.d.ts.map +1 -1
- package/dist/DataManager.d.ts +7 -0
- package/dist/DataManager.d.ts.map +1 -1
- package/dist/{LayoutSession-CoCMrrbh.js → LayoutSession-BOQCN6yY.js} +1165 -909
- package/dist/LayoutSession-BOQCN6yY.js.map +1 -0
- package/dist/LayoutSession-RF8OqOXy.cjs +2 -0
- package/dist/LayoutSession-RF8OqOXy.cjs.map +1 -0
- package/dist/SeriesStore.d.ts +2 -0
- package/dist/SeriesStore.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +60 -60
- package/dist/model/AlertWatch.d.ts +60 -0
- package/dist/model/AlertWatch.d.ts.map +1 -0
- package/dist/model/DisplaySeries.d.ts +50 -0
- package/dist/model/DisplaySeries.d.ts.map +1 -0
- package/dist/model/DrawingPanes.d.ts +24 -0
- package/dist/model/DrawingPanes.d.ts.map +1 -0
- package/dist/model/IndicatorHistory.d.ts +52 -0
- package/dist/model/IndicatorHistory.d.ts.map +1 -0
- package/dist/model/IndicatorPanes.d.ts +76 -0
- package/dist/model/IndicatorPanes.d.ts.map +1 -0
- package/dist/model/IndicatorSetup.d.ts +34 -0
- package/dist/model/IndicatorSetup.d.ts.map +1 -0
- package/dist/model/PaneLayout.d.ts +55 -0
- package/dist/model/PaneLayout.d.ts.map +1 -0
- package/dist/model/PriceFit.d.ts +75 -0
- package/dist/model/PriceFit.d.ts.map +1 -0
- package/dist/model/ReplayMarks.d.ts +42 -0
- package/dist/model/ReplayMarks.d.ts.map +1 -0
- package/dist/model/SymbolRequests.d.ts +34 -0
- package/dist/model/SymbolRequests.d.ts.map +1 -0
- package/dist/widget/WidgetIndicatorSettings.d.ts +1 -0
- package/dist/widget/WidgetIndicatorSettings.d.ts.map +1 -1
- package/dist/widget/index.cjs +4 -4
- package/dist/widget/index.cjs.map +1 -1
- package/dist/widget/index.js +544 -528
- package/dist/widget/index.js.map +1 -1
- package/dist/widget/settingsControls.d.ts +1 -0
- package/dist/widget/settingsControls.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/LayoutSession-BWC7O5R9.cjs +0 -2
- package/dist/LayoutSession-BWC7O5R9.cjs.map +0 -1
- package/dist/LayoutSession-CoCMrrbh.js.map +0 -1
- package/dist/PaneManager.d.ts +0 -19
- package/dist/PaneManager.d.ts.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { DARK_THEME as e, DEFAULT_PANEL_HEIGHT as t, LIGHT_THEME as n, LayerType as r, MIN_PANEL_HEIGHT as i, PHI as a, PRICE_AXIS_WIDTH as o, TIME_AXIS_HEIGHT as s, autoPricePrecision as c, barDateZone as l, barTimeUnit as u, barsAreDaily as d, chartStyleValue as f, computePriceLimits as p, computePriceRange as m, createMarketTheme as h, formatPrice as g, fractionTick as _, indicatorSource as v, isValidTimeZone as y, mergeBar as ee, niceNumber as te, normalizeBarTime as b, parseIndicatorSource as x, priceFormatterFor as ne, priceStepAt as re, readChartStyleOverrides as ie, readChartTypeOptions as ae, readIndicatorPlotStyles as oe, readPaneStyle as se, resolveChartTheme as ce, sessionMinute as S, setLocale as le, stepDecimals as ue, symbolTimeZone as C, tickBarCount as de, timeframeToMs as w, zonedDateFormatter as fe } from "@tradecanvas/commons";
|
|
2
|
-
import { AlertDragHandler as pe, AlertManager as me, Animator as he, AreaRenderer as ge, AxisDragHandler as _e, BarCountdown as ve, BarRenderer as ye, BaselineRenderer as be, CandlestickRenderer as xe, ChartLegend as Se, ChartStateManager as T, CompareRenderer as Ce, CompareSymbolIndicator as we, CompareSymbolPaneIndicator as Te, CorrelationCoefficientIndicator as Ee, CorrelationLogIndicator as De, CrosshairHandler as Oe, CrosshairTooltip as ke, CurrentPriceLine as Ae, DEFAULT_SESSION_HOURS as je, DataExporter as E, DepthHeatmapRenderer as Me, DrawingManager as Ne, DrawingRenderer as Pe, EquivolumeRenderer as Fe, EventBus as Ie, GridRenderer as Le, HLCAreaRenderer as Re, HiLoRenderer as ze, HollowCandleRenderer as Be, IndicatorEngine as Ve, InteractionManager as He, KagiRenderer as Ue, KeyboardHandler as We, LineRenderer as Ge, LineWithMarkersRenderer as Ke, MarketProfileRenderer as qe, MeasureOverlay as Je, PRICE_AXIS_ADD_STRIP as Ye, PRICE_SCALE_MARGIN as D, PanHandler as Xe, PaneResizeHandler as Ze, PeriodLevelsRenderer as Qe, PinnedTooltip as $e, PivotMarkersRenderer as et, PointAndFigureRenderer as tt, PriceAxis as nt, PriceAxisAddButton as rt, PriceLines as it, RenderEngine as at, RenkoRenderer as ot, ReplayManager as st, ResamplingAdapter as ct, ReshapeMemo as lt, SYMBOL_INDICATOR_IDS as
|
|
2
|
+
import { AlertDragHandler as pe, AlertManager as me, Animator as he, AreaRenderer as ge, AxisDragHandler as _e, BarCountdown as ve, BarRenderer as ye, BaselineRenderer as be, CandlestickRenderer as xe, ChartLegend as Se, ChartStateManager as T, CompareRenderer as Ce, CompareSymbolIndicator as we, CompareSymbolPaneIndicator as Te, CorrelationCoefficientIndicator as Ee, CorrelationLogIndicator as De, CrosshairHandler as Oe, CrosshairTooltip as ke, CurrentPriceLine as Ae, DEFAULT_SESSION_HOURS as je, DataExporter as E, DepthHeatmapRenderer as Me, DrawingManager as Ne, DrawingRenderer as Pe, EquivolumeRenderer as Fe, EventBus as Ie, GridRenderer as Le, HLCAreaRenderer as Re, HiLoRenderer as ze, HollowCandleRenderer as Be, IndicatorEngine as Ve, InteractionManager as He, KagiRenderer as Ue, KeyboardHandler as We, LineRenderer as Ge, LineWithMarkersRenderer as Ke, MarketProfileRenderer as qe, MeasureOverlay as Je, PRICE_AXIS_ADD_STRIP as Ye, PRICE_SCALE_MARGIN as D, PanHandler as Xe, PaneResizeHandler as Ze, PeriodLevelsRenderer as Qe, PinnedTooltip as $e, PivotMarkersRenderer as et, PointAndFigureRenderer as tt, PriceAxis as nt, PriceAxisAddButton as rt, PriceLines as it, RenderEngine as at, RenkoRenderer as ot, ReplayManager as st, ResamplingAdapter as ct, ReshapeMemo as lt, SYMBOL_INDICATOR_IDS as ut, SYMBOL_ZONE_WAIT_MS as dt, Screenshot as O, SelectionBoxOverlay as ft, SessionBreaks as pt, SessionShading as mt, SignalMarkerManager as ht, SpreadIndicator as gt, StepLineRenderer as _t, StreamManager as vt, SymbolSeriesStore as yt, TimeAxis as bt, TradeZoneManager as xt, TradingManager as St, TradingRenderer as Ct, UndoRedoManager as wt, Viewport as Tt, VolumeCandleRenderer as Et, VolumeProfileRenderer as Dt, VolumeRenderer as Ot, Watermark as kt, ZoomHandler as At, axisTimes as k, barTimeStepMs as jt, findDominantSwing as Mt, gpuContextsLeft as Nt, isPriceLevelAlert as Pt, isRegularSession as Ft, loadWebGL as It, mergeSessionHours as Lt, pointAndFigureColumns as Rt, rangePresetStart as zt, readAlertOptions as Bt, registerBuiltInDrawingTools as Vt, registerBuiltInIndicators as Ht, servesTimeframe as A, sourceParam as j, streamAdapterOf as Ut, timestampToBarIndex as M, toHeikinAshi as Wt, toKagi as Gt, toLineBreak as Kt, toRangeBars as qt, toRenko as Jt, whenGpuContextFree as Yt, withResampling as N, xToBarIndex as Xt, xToTime as P, yToPrice as Zt } from "@tradecanvas/core";
|
|
3
3
|
//#region src/regularHours.ts
|
|
4
|
-
var
|
|
5
|
-
function
|
|
4
|
+
var Qt = 864e5, $t = 10;
|
|
5
|
+
function en(e, t) {
|
|
6
6
|
let n = C(e);
|
|
7
7
|
if (!n || !y(n) || t.length < 2) return null;
|
|
8
8
|
let r = (e?.sessions ?? []).flatMap((e) => {
|
|
@@ -14,34 +14,34 @@ function $t(e, t) {
|
|
|
14
14
|
});
|
|
15
15
|
if (r.length === 0) return null;
|
|
16
16
|
let i = u(t), a = Infinity;
|
|
17
|
-
for (let e = Math.max(1, t.length -
|
|
17
|
+
for (let e = Math.max(1, t.length - $t); e < t.length; e++) {
|
|
18
18
|
let n = (t[e].time - t[e - 1].time) * i;
|
|
19
19
|
n > 0 && n < a && (a = n);
|
|
20
20
|
}
|
|
21
|
-
if (!(a <
|
|
21
|
+
if (!(a < Qt)) return null;
|
|
22
22
|
let o = {
|
|
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) => Ft(e * i, o);
|
|
29
29
|
}
|
|
30
30
|
//#endregion
|
|
31
31
|
//#region src/chartA11y.ts
|
|
32
|
-
var
|
|
32
|
+
var tn = {
|
|
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
|
+
}, F = (e, t) => e.replace(/\{(\w+)\}/g, (e, n) => n in t ? String(t[n]) : e), nn = [
|
|
40
40
|
"role",
|
|
41
41
|
"aria-roledescription",
|
|
42
42
|
"aria-label",
|
|
43
43
|
"aria-describedby"
|
|
44
|
-
],
|
|
44
|
+
], rn = 400, an = 1e3, on = class {
|
|
45
45
|
live;
|
|
46
46
|
help;
|
|
47
47
|
labels;
|
|
@@ -55,20 +55,20 @@ var en = {
|
|
|
55
55
|
};
|
|
56
56
|
constructor(e, t, n = {}) {
|
|
57
57
|
this.container = e, this.source = t, this.labels = {
|
|
58
|
-
...
|
|
58
|
+
...tn,
|
|
59
59
|
...n
|
|
60
60
|
};
|
|
61
|
-
for (let t of
|
|
62
|
-
e.setAttribute("role", "application"), this.help =
|
|
61
|
+
for (let t of nn) this.before.set(t, e.getAttribute(t));
|
|
62
|
+
e.setAttribute("role", "application"), this.help = sn("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 = sn("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
|
+
...tn,
|
|
67
67
|
...e
|
|
68
68
|
}, this.applyLabels();
|
|
69
69
|
}
|
|
70
70
|
refresh(e = !1) {
|
|
71
|
-
let t =
|
|
71
|
+
let t = an - (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 en = {
|
|
|
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
|
+
}, rn);
|
|
84
84
|
}
|
|
85
85
|
readBar(e) {
|
|
86
86
|
let t = this.source.bars();
|
|
@@ -93,13 +93,13 @@ var en = {
|
|
|
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(F(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: cn(i.volume ?? 0)
|
|
103
103
|
}));
|
|
104
104
|
}
|
|
105
105
|
destroy() {
|
|
@@ -118,7 +118,7 @@ var en = {
|
|
|
118
118
|
this.labels.typeName ? this.labels.typeName(t) : t,
|
|
119
119
|
this.source.timeframe()
|
|
120
120
|
].filter(Boolean).join(", ");
|
|
121
|
-
return
|
|
121
|
+
return F(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 en = {
|
|
|
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 F(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 en = {
|
|
|
140
140
|
this.live.textContent = e;
|
|
141
141
|
}
|
|
142
142
|
};
|
|
143
|
-
function
|
|
143
|
+
function sn(e, t) {
|
|
144
144
|
let n = document.createElement(e);
|
|
145
145
|
return n.className = t, Object.assign(n.style, {
|
|
146
146
|
position: "absolute",
|
|
@@ -154,17 +154,17 @@ function on(e, t) {
|
|
|
154
154
|
border: "0"
|
|
155
155
|
}), n;
|
|
156
156
|
}
|
|
157
|
-
function
|
|
157
|
+
function cn(e) {
|
|
158
158
|
return Number.isInteger(e) ? String(e) : e.toFixed(2);
|
|
159
159
|
}
|
|
160
160
|
//#endregion
|
|
161
161
|
//#region src/indicatorLabel.ts
|
|
162
|
-
var
|
|
162
|
+
var ln = 3, un = {
|
|
163
163
|
stochrsi: 4,
|
|
164
164
|
ichimoku: 4
|
|
165
165
|
};
|
|
166
|
-
function
|
|
167
|
-
let i = Object.keys(n || t).map((e) => t[e]).filter((e) => typeof e == "number" && Number.isFinite(e)).slice(0,
|
|
166
|
+
function dn(e, t, n, r) {
|
|
167
|
+
let i = Object.keys(n || t).map((e) => t[e]).filter((e) => typeof e == "number" && Number.isFinite(e)).slice(0, un[e] ?? ln).map((e) => String(Number(e.toFixed(4)))), a = typeof t.symbol == "string" && t.symbol ? [t.symbol] : [];
|
|
168
168
|
return [
|
|
169
169
|
e === "spread" && t.mode === "ratio" ? "Ratio" : r ?? e.toUpperCase(),
|
|
170
170
|
...a,
|
|
@@ -173,7 +173,7 @@ function un(e, t, n, r) {
|
|
|
173
173
|
}
|
|
174
174
|
//#endregion
|
|
175
175
|
//#region src/charts/ChartTypeStrategy.ts
|
|
176
|
-
function
|
|
176
|
+
function fn(e) {
|
|
177
177
|
switch (e) {
|
|
178
178
|
case "candlestick":
|
|
179
179
|
case "heikinAshi":
|
|
@@ -187,38 +187,38 @@ function dn(e) {
|
|
|
187
187
|
case "renko": return new ot();
|
|
188
188
|
case "kagi": return new Ue();
|
|
189
189
|
case "pointAndFigure": return new tt();
|
|
190
|
-
case "volumeCandles": return new
|
|
190
|
+
case "volumeCandles": return new Et();
|
|
191
191
|
case "equivolume": return new Fe();
|
|
192
192
|
case "hlcArea": return new Re();
|
|
193
|
-
case "stepLine": return new
|
|
193
|
+
case "stepLine": return new _t();
|
|
194
194
|
case "lineWithMarkers": return new Ke();
|
|
195
195
|
case "hiLo": return new ze();
|
|
196
196
|
default: return new xe();
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
|
-
function
|
|
199
|
+
function pn(e, t, n = {}, r, i) {
|
|
200
200
|
if (t.length === 0) return t;
|
|
201
201
|
switch (e) {
|
|
202
|
-
case "heikinAshi": return
|
|
202
|
+
case "heikinAshi": return Wt(t);
|
|
203
203
|
case "renko": {
|
|
204
204
|
let e = n.renko?.boxSize;
|
|
205
|
-
return typeof e == "number" ?
|
|
205
|
+
return typeof e == "number" ? Jt(t, { brickSize: e }, i) : Jt(t, {
|
|
206
206
|
brickSize: 0,
|
|
207
207
|
useATR: !0,
|
|
208
208
|
atrPeriod: n.renko?.atrPeriod ?? 14
|
|
209
209
|
}, i);
|
|
210
210
|
}
|
|
211
|
-
case "lineBreak": return
|
|
212
|
-
case "kagi": return
|
|
213
|
-
case "pointAndFigure": return
|
|
214
|
-
case "rangeBars": return
|
|
211
|
+
case "lineBreak": return Kt(t, n.lineBreak?.lines ?? 3);
|
|
212
|
+
case "kagi": return Gt(t, n.kagi?.reversal ?? 4, n.kagi?.reversalType ?? "percent", i);
|
|
213
|
+
case "pointAndFigure": return hn(t, n, i).columns;
|
|
214
|
+
case "rangeBars": return qt(t, {
|
|
215
215
|
rangeSize: wn(t, n, r),
|
|
216
216
|
includeForming: !0
|
|
217
217
|
}, i);
|
|
218
218
|
default: return t;
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
|
-
function
|
|
221
|
+
function mn(e) {
|
|
222
222
|
switch (e) {
|
|
223
223
|
case "heikinAshi":
|
|
224
224
|
case "renko":
|
|
@@ -229,36 +229,36 @@ function pn(e) {
|
|
|
229
229
|
default: return !1;
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
|
-
function
|
|
233
|
-
return e !== "heikinAshi" &&
|
|
232
|
+
function I(e) {
|
|
233
|
+
return e !== "heikinAshi" && mn(e);
|
|
234
234
|
}
|
|
235
|
-
function
|
|
236
|
-
return
|
|
235
|
+
function hn(e, t = {}, n) {
|
|
236
|
+
return Rt(e, vn(e, t), t.pointAndFigure?.reversal ?? 3, n);
|
|
237
237
|
}
|
|
238
|
-
var
|
|
239
|
-
function
|
|
238
|
+
var gn = 50, _n = .01;
|
|
239
|
+
function vn(e, t = {}) {
|
|
240
240
|
let n = t.pointAndFigure?.boxSize;
|
|
241
241
|
if (typeof n == "number") return n;
|
|
242
|
-
let r =
|
|
243
|
-
return r > 0 ?
|
|
242
|
+
let r = yn(e, e.length > 1 ? e.length - 1 : e.length);
|
|
243
|
+
return r > 0 ? L(te(r / gn, !0)) : Math.abs(e[e.length - 1]?.close ?? 0) * _n || 1;
|
|
244
244
|
}
|
|
245
|
-
function
|
|
245
|
+
function yn(e, t) {
|
|
246
246
|
let n = -Infinity, r = Infinity;
|
|
247
247
|
for (let i = 0; i < t; i++) e[i].high > n && (n = e[i].high), e[i].low < r && (r = e[i].low);
|
|
248
248
|
let i = n - r;
|
|
249
249
|
return Number.isFinite(i) ? i : 0;
|
|
250
250
|
}
|
|
251
|
-
var
|
|
251
|
+
var bn = 100, xn = 3, Sn = .01, Cn = 15, L = (e) => Number(e.toPrecision(Cn));
|
|
252
252
|
function wn(e, t = {}, n) {
|
|
253
253
|
let r = t.rangeBars?.range;
|
|
254
254
|
if (typeof r == "number") return r;
|
|
255
|
-
let i = e.length >=
|
|
256
|
-
return kn(
|
|
255
|
+
let i = e.length >= xn ? En(e) : 0, a = Math.abs(e[e.length - 1]?.close ?? 0);
|
|
256
|
+
return kn(L(te(i > 0 ? i : a * Sn || 1, !0)), n);
|
|
257
257
|
}
|
|
258
258
|
function Tn(e) {
|
|
259
259
|
let t = e.length - 1;
|
|
260
260
|
return {
|
|
261
|
-
from: Math.max(0, t -
|
|
261
|
+
from: Math.max(0, t - bn),
|
|
262
262
|
end: t
|
|
263
263
|
};
|
|
264
264
|
}
|
|
@@ -281,16 +281,16 @@ function On(e, t) {
|
|
|
281
281
|
return e === void 0 ? t : t === void 0 ? e : Math.max(e, t);
|
|
282
282
|
}
|
|
283
283
|
function kn(e, t) {
|
|
284
|
-
return t === void 0 || !(t > 0) ? e :
|
|
284
|
+
return t === void 0 || !(t > 0) ? e : L(Math.max(1, Math.round(e / t)) * t);
|
|
285
285
|
}
|
|
286
286
|
function An(e, t) {
|
|
287
287
|
let n = t?.(e);
|
|
288
|
-
return n ? n.createRenderer() :
|
|
288
|
+
return n ? n.createRenderer() : fn(e);
|
|
289
289
|
}
|
|
290
290
|
function jn(e, t, n, r, i, a) {
|
|
291
291
|
if (t.length === 0) return t;
|
|
292
292
|
let o = n?.(e);
|
|
293
|
-
return o?.transform ? o.transform(t) :
|
|
293
|
+
return o?.transform ? o.transform(t) : pn(e, t, r, i, a);
|
|
294
294
|
}
|
|
295
295
|
//#endregion
|
|
296
296
|
//#region src/state/AutoSaveScheduler.ts
|
|
@@ -340,47 +340,51 @@ function z(e) {
|
|
|
340
340
|
volume: e.volume === void 0 ? 0 : Math.max(0, e.volume)
|
|
341
341
|
};
|
|
342
342
|
}
|
|
343
|
-
function
|
|
343
|
+
function Pn(e, t) {
|
|
344
344
|
return e === t || e.time === t.time && e.open === t.open && e.high === t.high && e.low === t.low && e.close === t.close && e.volume === t.volume;
|
|
345
345
|
}
|
|
346
|
-
function
|
|
346
|
+
function Fn(e, t) {
|
|
347
347
|
for (let n = e.length - 1; n >= 0; n--) {
|
|
348
348
|
if (e[n].time === t) return n;
|
|
349
349
|
if (e[n].time < t) return -1;
|
|
350
350
|
}
|
|
351
351
|
return -1;
|
|
352
352
|
}
|
|
353
|
-
var
|
|
353
|
+
var In = {
|
|
354
354
|
index: -1,
|
|
355
355
|
changed: !1
|
|
356
356
|
};
|
|
357
|
-
function
|
|
357
|
+
function Ln(e, t) {
|
|
358
358
|
if (e.length === 0) return t;
|
|
359
359
|
let n = b(t);
|
|
360
360
|
return u(e) === 1 ? n : n / 1e3;
|
|
361
361
|
}
|
|
362
|
-
function
|
|
363
|
-
let n =
|
|
362
|
+
function Rn(e, t) {
|
|
363
|
+
let n = Ln(e, t.time);
|
|
364
364
|
return n === t.time ? t : {
|
|
365
365
|
...t,
|
|
366
366
|
time: n
|
|
367
367
|
};
|
|
368
368
|
}
|
|
369
|
-
var
|
|
369
|
+
var B = class {
|
|
370
370
|
data = [];
|
|
371
|
+
changes = 0;
|
|
371
372
|
withSeriesTime(e) {
|
|
372
|
-
return
|
|
373
|
+
return Rn(this.data, e);
|
|
373
374
|
}
|
|
374
375
|
getData() {
|
|
375
376
|
return this.data;
|
|
376
377
|
}
|
|
378
|
+
version() {
|
|
379
|
+
return this.changes;
|
|
380
|
+
}
|
|
377
381
|
setData(e) {
|
|
378
382
|
let t = [];
|
|
379
383
|
for (let n = 0; n < e.length; n++) {
|
|
380
384
|
let r = e[n];
|
|
381
385
|
R(r) && t.push(Nn(r) ? r : z(r));
|
|
382
386
|
}
|
|
383
|
-
this.data = t
|
|
387
|
+
this.data = t, this.changes++;
|
|
384
388
|
}
|
|
385
389
|
prependBars(e) {
|
|
386
390
|
let t = this.data.length > 0 ? this.data[0].time : Infinity, n = [];
|
|
@@ -393,54 +397,54 @@ var V = class {
|
|
|
393
397
|
n.sort((e, t) => e.time - t.time);
|
|
394
398
|
let r = 0;
|
|
395
399
|
for (let e = 0; e < n.length; e++) r > 0 && n[r - 1].time === n[e].time || (n[r++] = n[e]);
|
|
396
|
-
return n.length = r, this.data = n.concat(this.data), r;
|
|
400
|
+
return n.length = r, this.data = n.concat(this.data), this.changes++, r;
|
|
397
401
|
}
|
|
398
402
|
appendBar(e) {
|
|
399
|
-
R(e) && this.data.push(z(this.withSeriesTime(e)));
|
|
403
|
+
R(e) && (this.data.push(z(this.withSeriesTime(e))), this.changes++);
|
|
400
404
|
}
|
|
401
405
|
updateLastBar(e) {
|
|
402
406
|
if (!R(e)) return;
|
|
403
407
|
let t = z(this.withSeriesTime(e));
|
|
404
|
-
if (this.data.length === 0) {
|
|
408
|
+
if (this.changes++, this.data.length === 0) {
|
|
405
409
|
this.data.push(t);
|
|
406
410
|
return;
|
|
407
411
|
}
|
|
408
412
|
this.data[this.data.length - 1] = t;
|
|
409
413
|
}
|
|
410
414
|
replaceBar(e) {
|
|
411
|
-
if (!R(e)) return
|
|
412
|
-
let t = this.withSeriesTime(e), n =
|
|
413
|
-
if (n < 0) return
|
|
415
|
+
if (!R(e)) return In;
|
|
416
|
+
let t = this.withSeriesTime(e), n = Fn(this.data, t.time);
|
|
417
|
+
if (n < 0) return In;
|
|
414
418
|
let r = z(t);
|
|
415
|
-
return
|
|
419
|
+
return Pn(this.data[n], r) ? {
|
|
416
420
|
index: n,
|
|
417
421
|
changed: !1
|
|
418
|
-
} : (this.data[n] = r, {
|
|
422
|
+
} : (this.data[n] = r, this.changes++, {
|
|
419
423
|
index: n,
|
|
420
424
|
changed: !0
|
|
421
425
|
});
|
|
422
426
|
}
|
|
423
427
|
updateLastBarFromTick(e) {
|
|
424
|
-
this.data.length !== 0 && (!isFinite(e.price) || e.price < 0 || e.volume !== void 0 && (!isFinite(e.volume) || e.volume < 0) || (this.data[this.data.length - 1] = ee(this.data[this.data.length - 1], this.withSeriesTime(e))));
|
|
428
|
+
this.data.length !== 0 && (!isFinite(e.price) || e.price < 0 || e.volume !== void 0 && (!isFinite(e.volume) || e.volume < 0) || (this.data[this.data.length - 1] = ee(this.data[this.data.length - 1], this.withSeriesTime(e)), this.changes++));
|
|
425
429
|
}
|
|
426
430
|
getLength() {
|
|
427
431
|
return this.data.length;
|
|
428
432
|
}
|
|
429
433
|
clear() {
|
|
430
|
-
this.data = []
|
|
434
|
+
this.data = [], this.changes++;
|
|
431
435
|
}
|
|
432
|
-
},
|
|
436
|
+
}, V = {
|
|
433
437
|
to: "none",
|
|
434
438
|
index: -1,
|
|
435
439
|
changed: !1
|
|
436
440
|
};
|
|
437
|
-
function
|
|
441
|
+
function H(e, t) {
|
|
438
442
|
let n = e[e.length - 1];
|
|
439
443
|
if (!n) return "append";
|
|
440
444
|
let r = b(t.time), i = b(n.time);
|
|
441
445
|
return r > i ? "append" : r === i ? "update" : "stale";
|
|
442
446
|
}
|
|
443
|
-
function
|
|
447
|
+
function zn(e) {
|
|
444
448
|
return [
|
|
445
449
|
e.time,
|
|
446
450
|
e.open,
|
|
@@ -449,8 +453,8 @@ function Rn(e) {
|
|
|
449
453
|
e.close
|
|
450
454
|
].every(Number.isFinite);
|
|
451
455
|
}
|
|
452
|
-
var
|
|
453
|
-
shown = new
|
|
456
|
+
var Bn = class {
|
|
457
|
+
shown = new B();
|
|
454
458
|
whole = null;
|
|
455
459
|
aside = null;
|
|
456
460
|
shownRevision = 0;
|
|
@@ -466,6 +470,9 @@ var zn = class {
|
|
|
466
470
|
revision() {
|
|
467
471
|
return this.shownRevision;
|
|
468
472
|
}
|
|
473
|
+
version() {
|
|
474
|
+
return this.shown.version();
|
|
475
|
+
}
|
|
469
476
|
liveBars() {
|
|
470
477
|
return this.aside?.getData() ?? this.whole ?? this.shown.getData();
|
|
471
478
|
}
|
|
@@ -489,7 +496,7 @@ var zn = class {
|
|
|
489
496
|
}
|
|
490
497
|
let t = null, n = e;
|
|
491
498
|
if (this.whole) {
|
|
492
|
-
let r = this.whole[0]?.time, i = /* @__PURE__ */ new Set(), a = e.filter(
|
|
499
|
+
let r = this.whole[0]?.time, i = /* @__PURE__ */ new Set(), a = e.filter(zn).map((e) => this.inSeriesUnit(e)).filter((e) => (r === void 0 || e.time < r) && !i.has(e.time) && i.add(e.time)).sort((e, t) => e.time - t.time);
|
|
493
500
|
this.whole = [...a, ...this.whole];
|
|
494
501
|
let o = this.hoursFilter(this.whole);
|
|
495
502
|
t = a.length, n = o ? a.filter((e) => o(e.time)) : a;
|
|
@@ -501,8 +508,8 @@ var zn = class {
|
|
|
501
508
|
};
|
|
502
509
|
}
|
|
503
510
|
mergeSnapshot(e) {
|
|
504
|
-
if (this.aside) return this.aside.setData(
|
|
505
|
-
let t =
|
|
511
|
+
if (this.aside) return this.aside.setData(Vn(this.aside.getData(), e) ?? e), this.onLiveChange({ kind: "series" }), !0;
|
|
512
|
+
let t = Vn(this.whole ?? this.shown.getData(), e);
|
|
506
513
|
return t ? (this.shown.setData(this.regularOnly(t)), !0) : !1;
|
|
507
514
|
}
|
|
508
515
|
refilter() {
|
|
@@ -559,7 +566,7 @@ var zn = class {
|
|
|
559
566
|
mergeTick(e) {
|
|
560
567
|
if (this.aside) return this.aside.updateLastBarFromTick(e), this.wrote("aside", !1);
|
|
561
568
|
let t = this.whole ? this.hoursFilter(this.whole) : null;
|
|
562
|
-
if (t && this.whole && !t(
|
|
569
|
+
if (t && this.whole && !t(Ln(this.whole, e.time))) return this.wrote("hidden", !1);
|
|
563
570
|
let n = this.shown.getLength();
|
|
564
571
|
this.shown.updateLastBarFromTick(e);
|
|
565
572
|
let r = this.whole, i = this.shown.getData()[this.shown.getLength() - 1];
|
|
@@ -571,14 +578,14 @@ var zn = class {
|
|
|
571
578
|
}
|
|
572
579
|
placeStreamBar(e) {
|
|
573
580
|
if (this.aside) {
|
|
574
|
-
let t =
|
|
581
|
+
let t = H(this.aside.getData(), e);
|
|
575
582
|
return t === "append" ? this.aside.appendBar(e) : t === "update" && this.aside.updateLastBar(e), this.wrote(t === "stale" ? "none" : "aside", !1);
|
|
576
583
|
}
|
|
577
|
-
let t = this.inSeriesUnit(e), n =
|
|
584
|
+
let t = this.inSeriesUnit(e), n = H(this.whole ?? this.shown.getData(), t);
|
|
578
585
|
if (n === "stale") return this.wrote("none", !1);
|
|
579
586
|
let r = this.startWholeSeries(t, n);
|
|
580
587
|
if (!this.take(t, n)) return this.wrote("hidden", r);
|
|
581
|
-
let i = this.shown.getLength(), a =
|
|
588
|
+
let i = this.shown.getLength(), a = H(this.shown.getData(), t);
|
|
582
589
|
return a === "stale" ? {
|
|
583
590
|
to: "none",
|
|
584
591
|
before: i,
|
|
@@ -592,7 +599,7 @@ var zn = class {
|
|
|
592
599
|
replace(e) {
|
|
593
600
|
if (this.aside) {
|
|
594
601
|
let { index: t, changed: n } = this.aside.replaceBar(e);
|
|
595
|
-
return t < 0 ?
|
|
602
|
+
return t < 0 ? V : (n && this.onLiveChange({
|
|
596
603
|
kind: "bar",
|
|
597
604
|
time: this.aside.getData()[t].time
|
|
598
605
|
}), {
|
|
@@ -601,22 +608,22 @@ var zn = class {
|
|
|
601
608
|
changed: n
|
|
602
609
|
});
|
|
603
610
|
}
|
|
604
|
-
if (!R(e)) return
|
|
605
|
-
let t = this.inSeriesUnit(e), n = this.whole, r = n ?
|
|
611
|
+
if (!R(e)) return V;
|
|
612
|
+
let t = this.inSeriesUnit(e), n = this.whole, r = n ? Fn(n, t.time) : -1;
|
|
606
613
|
if (n) {
|
|
607
|
-
if (r < 0 || !R(n[r])) return
|
|
614
|
+
if (r < 0 || !R(n[r])) return V;
|
|
608
615
|
let e = this.hoursFilter(n);
|
|
609
616
|
if (e && !e(t.time)) return this.replaceHidden(n, r, t);
|
|
610
617
|
}
|
|
611
618
|
let { index: i, changed: a } = this.shown.replaceBar(t);
|
|
612
|
-
return i < 0 ?
|
|
619
|
+
return i < 0 ? V : (a && (n && (n[r] = this.shown.getData()[i]), this.shownRevision++), {
|
|
613
620
|
to: "shown",
|
|
614
621
|
index: i,
|
|
615
622
|
changed: a
|
|
616
623
|
});
|
|
617
624
|
}
|
|
618
625
|
beginReplay() {
|
|
619
|
-
this.aside || (this.aside = new
|
|
626
|
+
this.aside || (this.aside = new B(), this.aside.setData(this.whole ?? this.shown.getData()));
|
|
620
627
|
}
|
|
621
628
|
endReplay() {
|
|
622
629
|
let e = this.aside;
|
|
@@ -636,10 +643,10 @@ var zn = class {
|
|
|
636
643
|
this.shown.updateLastBar(e);
|
|
637
644
|
}
|
|
638
645
|
inSeriesUnit(e) {
|
|
639
|
-
return
|
|
646
|
+
return Rn(this.whole ?? this.shown.getData(), e);
|
|
640
647
|
}
|
|
641
648
|
replaceHidden(e, t, n) {
|
|
642
|
-
let r = z(n), i = !
|
|
649
|
+
let r = z(n), i = !Pn(e[t], r);
|
|
643
650
|
return i && (e[t] = r), {
|
|
644
651
|
to: "hidden",
|
|
645
652
|
index: -1,
|
|
@@ -673,14 +680,492 @@ var zn = class {
|
|
|
673
680
|
return !r || r(e.time);
|
|
674
681
|
}
|
|
675
682
|
};
|
|
676
|
-
function
|
|
683
|
+
function Vn(e, t) {
|
|
677
684
|
let n = t[0]?.time, r = 0;
|
|
678
685
|
for (; n !== void 0 && r < e.length && e[r].time < n;) r++;
|
|
679
686
|
return r === 0 || r === e.length ? null : e.slice(0, r).concat(t);
|
|
680
687
|
}
|
|
681
688
|
//#endregion
|
|
689
|
+
//#region src/model/PriceFit.ts
|
|
690
|
+
var Hn = a ** -7, Un = class {
|
|
691
|
+
auto;
|
|
692
|
+
preferred;
|
|
693
|
+
pending = !0;
|
|
694
|
+
arriving = !0;
|
|
695
|
+
constructor(e) {
|
|
696
|
+
this.auto = e, this.preferred = e;
|
|
697
|
+
}
|
|
698
|
+
isAuto() {
|
|
699
|
+
return this.auto;
|
|
700
|
+
}
|
|
701
|
+
shouldFit() {
|
|
702
|
+
return this.auto || this.pending;
|
|
703
|
+
}
|
|
704
|
+
setAuto(e, t) {
|
|
705
|
+
this.auto = e, this.preferred = e, !e && t && (this.arriving = !1);
|
|
706
|
+
}
|
|
707
|
+
hold() {
|
|
708
|
+
this.auto = !1, this.pending = !1;
|
|
709
|
+
}
|
|
710
|
+
resume() {
|
|
711
|
+
this.auto = !0;
|
|
712
|
+
}
|
|
713
|
+
newSeries(e) {
|
|
714
|
+
this.auto = this.preferred, this.pending = !0, this.arriving = e;
|
|
715
|
+
}
|
|
716
|
+
settle(e, t) {
|
|
717
|
+
if (!this.pending || t === 0 || e.chartRect.width <= 0) return;
|
|
718
|
+
let n = e.offset <= 0 && t * (e.barWidth + e.barSpacing) - e.offset <= e.chartRect.width;
|
|
719
|
+
this.arriving && n || (this.pending = !1);
|
|
720
|
+
}
|
|
721
|
+
fit(e, t, n, r) {
|
|
722
|
+
if (t.length === 0) return;
|
|
723
|
+
let i = Math.max(0, n.visibleRange.from), a = Math.min(n.visibleRange.to, t.length - 1), o = Gn(Gn(m(t, i, a, 0), r.overlayRange(i, a)), r.compareRange(t, n)), s = r.volumeRatio(t, i, a), c = s === null ? D : s + Hn;
|
|
724
|
+
e.setScaleMargins(e.isInvertScale() ? {
|
|
725
|
+
top: c,
|
|
726
|
+
bottom: D
|
|
727
|
+
} : {
|
|
728
|
+
top: D,
|
|
729
|
+
bottom: c
|
|
730
|
+
}), e.fitToPrices(o.min, o.max);
|
|
731
|
+
}
|
|
732
|
+
};
|
|
733
|
+
function Wn(e, t, n) {
|
|
734
|
+
for (let r = t; r <= n; r++) if (e[r].volume > 0) return !0;
|
|
735
|
+
return !1;
|
|
736
|
+
}
|
|
737
|
+
function Gn(e, t) {
|
|
738
|
+
return e ? t ? {
|
|
739
|
+
min: Math.min(e.min, t.min),
|
|
740
|
+
max: Math.max(e.max, t.max)
|
|
741
|
+
} : e : t;
|
|
742
|
+
}
|
|
743
|
+
//#endregion
|
|
744
|
+
//#region src/model/DisplaySeries.ts
|
|
745
|
+
var Kn = class {
|
|
746
|
+
series = null;
|
|
747
|
+
madeAt = null;
|
|
748
|
+
epoch = 0;
|
|
749
|
+
memo = new lt();
|
|
750
|
+
constructor(e) {
|
|
751
|
+
this.sources = e;
|
|
752
|
+
}
|
|
753
|
+
get() {
|
|
754
|
+
let e = this.sources.bars();
|
|
755
|
+
if (e.length === 0) return e;
|
|
756
|
+
let t = this.sources.chartType(), n = this.sources.chartTypeOptions(), r = t === "rangeBars" ? Dn(e, (e) => this.sources.stepAt(e)) : void 0, i = this.sources.version(), a = this.madeAt;
|
|
757
|
+
return this.series && a && a.version === i && a.type === t && a.options === n && a.step === r && a.epoch === this.epoch ? this.series : (this.series = this.make(t, e, n, r), this.madeAt = {
|
|
758
|
+
version: i,
|
|
759
|
+
type: t,
|
|
760
|
+
options: n,
|
|
761
|
+
step: r,
|
|
762
|
+
epoch: this.epoch
|
|
763
|
+
}, this.series);
|
|
764
|
+
}
|
|
765
|
+
invalidate() {
|
|
766
|
+
this.epoch++;
|
|
767
|
+
}
|
|
768
|
+
reset() {
|
|
769
|
+
this.invalidate(), this.memo.clear();
|
|
770
|
+
}
|
|
771
|
+
make(e, t, n, r) {
|
|
772
|
+
let { lookup: i } = this.sources;
|
|
773
|
+
if (e !== "pointAndFigure" || i(e)) return jn(e, t, i, n, r, this.memo);
|
|
774
|
+
let { columns: a, boxSize: o } = hn(t, n, this.memo);
|
|
775
|
+
return this.sources.onBoxSize(o), a;
|
|
776
|
+
}
|
|
777
|
+
}, qn = {
|
|
778
|
+
min: 0,
|
|
779
|
+
max: 100
|
|
780
|
+
}, Jn = class {
|
|
781
|
+
layout = null;
|
|
782
|
+
infos = null;
|
|
783
|
+
styles = /* @__PURE__ */ new Map();
|
|
784
|
+
constructor(e, t, n) {
|
|
785
|
+
this.manager = e, this.sources = t, this.onLayout = n;
|
|
786
|
+
}
|
|
787
|
+
resolved() {
|
|
788
|
+
return this.layout || (this.layout = this.manager.resolve(), this.onLayout(Yn(this.layout))), this.layout;
|
|
789
|
+
}
|
|
790
|
+
invalidate() {
|
|
791
|
+
this.layout = null, this.infos = null;
|
|
792
|
+
}
|
|
793
|
+
invalidateScales() {
|
|
794
|
+
this.infos = null;
|
|
795
|
+
}
|
|
796
|
+
panels(e) {
|
|
797
|
+
if (this.infos) return this.infos;
|
|
798
|
+
let t = e(), { from: n, to: r } = t.visibleRange;
|
|
799
|
+
return this.infos = this.resolved().panels.map((e) => {
|
|
800
|
+
let i = e.config.id, a = e.config.logScale ? this.sources.getPaneValueRange(i, n, r, !0) : null, o = a ?? this.sources.getPaneValueRange(i, n, r) ?? { ...qn }, s = this.styles.get(i);
|
|
801
|
+
return {
|
|
802
|
+
instanceId: i,
|
|
803
|
+
members: this.sources.getPaneMembers(i),
|
|
804
|
+
...s ? { style: s } : {},
|
|
805
|
+
rect: e.rect,
|
|
806
|
+
viewport: {
|
|
807
|
+
...t,
|
|
808
|
+
chartRect: {
|
|
809
|
+
x: e.rect.x,
|
|
810
|
+
y: e.rect.y + 20,
|
|
811
|
+
width: e.rect.width,
|
|
812
|
+
height: Math.max(0, e.rect.height - 20)
|
|
813
|
+
},
|
|
814
|
+
priceRange: o,
|
|
815
|
+
logScale: a !== null,
|
|
816
|
+
scaleMode: e.config.percentScale ? "percentage" : "regular",
|
|
817
|
+
scaleBaseline: e.config.percentScale ? this.baseline(i, n, r) : void 0,
|
|
818
|
+
formatPrice: void 0,
|
|
819
|
+
pricePrecision: void 0,
|
|
820
|
+
priceUnit: void 0,
|
|
821
|
+
invertScale: !!e.config.invertScale
|
|
822
|
+
}
|
|
823
|
+
};
|
|
824
|
+
}), this.infos;
|
|
825
|
+
}
|
|
826
|
+
timeAxisTop() {
|
|
827
|
+
let { mainChartRect: e, panels: t } = this.resolved(), n = t.filter((e) => e.config.position === "bottom").reduce((e, t) => e + t.rect.height, 0);
|
|
828
|
+
return e.y + e.height + n;
|
|
829
|
+
}
|
|
830
|
+
offChartType() {
|
|
831
|
+
let e = this.sources.getActiveIndicators(), t = new Set(e.filter((e) => e.offChartType).map((e) => e.instanceId)), n = /* @__PURE__ */ new Set();
|
|
832
|
+
for (let r of this.manager.getPanels()) {
|
|
833
|
+
let i = e.filter((e) => e.instanceId === r.id || e.pane === r.id);
|
|
834
|
+
i.length > 0 && i.every((e) => t.has(e.instanceId)) && n.add(r.id);
|
|
835
|
+
}
|
|
836
|
+
return n;
|
|
837
|
+
}
|
|
838
|
+
style(e) {
|
|
839
|
+
return this.styles.get(e);
|
|
840
|
+
}
|
|
841
|
+
setStyle(e, t) {
|
|
842
|
+
return JSON.stringify(t) === JSON.stringify(this.styles.get(e) ?? null) ? !1 : (t ? this.styles.set(e, t) : this.styles.delete(e), this.infos = null, !0);
|
|
843
|
+
}
|
|
844
|
+
passStyle(e, t) {
|
|
845
|
+
let n = this.styles.get(e);
|
|
846
|
+
this.styles.delete(e), t && n && this.styles.set(t, n), this.infos = null;
|
|
847
|
+
}
|
|
848
|
+
baseline(e, t, n) {
|
|
849
|
+
let r = this.sources.getOutput(e)?.series, i = this.sources.getIndicatorDescriptor(e);
|
|
850
|
+
if (!r || !i) return;
|
|
851
|
+
let a = i.plots?.[0]?.key;
|
|
852
|
+
for (let e = Math.max(0, t); e <= n && e < r.length; e++) {
|
|
853
|
+
let t = r[e];
|
|
854
|
+
if (!t) continue;
|
|
855
|
+
let n = a === void 0 ? Object.values(t).find((e) => typeof e == "number" && Number.isFinite(e)) : t[a];
|
|
856
|
+
if (typeof n == "number" && Number.isFinite(n) && n !== 0) return n;
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
};
|
|
860
|
+
function Yn(e) {
|
|
861
|
+
let t = e.mainChartRect, n = t.y, r = t.y + t.height;
|
|
862
|
+
for (let t of e.panels) t.config.position !== "top" && t.config.position !== "bottom" || (n = Math.min(n, t.rect.y), r = Math.max(r, t.rect.y + t.rect.height));
|
|
863
|
+
return {
|
|
864
|
+
top: n,
|
|
865
|
+
bottom: r
|
|
866
|
+
};
|
|
867
|
+
}
|
|
868
|
+
function Xn(e) {
|
|
869
|
+
return e.length > 0 ? { renames: e } : {};
|
|
870
|
+
}
|
|
871
|
+
var U = (e, t) => JSON.stringify(e) === JSON.stringify(t), Zn = class {
|
|
872
|
+
steps;
|
|
873
|
+
snapshot;
|
|
874
|
+
enabled;
|
|
875
|
+
now;
|
|
876
|
+
depth = 0;
|
|
877
|
+
edit = null;
|
|
878
|
+
renames = null;
|
|
879
|
+
constructor(e) {
|
|
880
|
+
this.steps = e.steps, this.snapshot = e.snapshot, this.enabled = e.enabled, this.now = e.now ?? (() => performance.now());
|
|
881
|
+
}
|
|
882
|
+
record(e, t) {
|
|
883
|
+
if (this.depth > 0 || !this.enabled()) return t();
|
|
884
|
+
let n = this.snapshot(), r = [], i = this.renames;
|
|
885
|
+
this.renames = r;
|
|
886
|
+
let a;
|
|
887
|
+
try {
|
|
888
|
+
a = this.quietly(t);
|
|
889
|
+
} finally {
|
|
890
|
+
this.renames = i;
|
|
891
|
+
}
|
|
892
|
+
let o = this.snapshot();
|
|
893
|
+
return U(n, o) || this.push(e, n, o, r), a;
|
|
894
|
+
}
|
|
895
|
+
push(e, t, n, r) {
|
|
896
|
+
let i = this.now(), a = this.steps.last(), o = a?.type === "indicators" ? a.indicators : void 0, s = e !== void 0 && o?.subject === e && i - (o.at ?? 0) < 800 && U(o.after, t), c = {
|
|
897
|
+
type: "indicators",
|
|
898
|
+
before: null,
|
|
899
|
+
after: null
|
|
900
|
+
};
|
|
901
|
+
s && o ? U(o.before, n) ? this.steps.dropLast() : this.steps.replaceLast({
|
|
902
|
+
...c,
|
|
903
|
+
indicators: {
|
|
904
|
+
...o,
|
|
905
|
+
after: n,
|
|
906
|
+
at: i,
|
|
907
|
+
...Xn([...o.renames ?? [], ...r])
|
|
908
|
+
}
|
|
909
|
+
}) : this.steps.push({
|
|
910
|
+
...c,
|
|
911
|
+
indicators: {
|
|
912
|
+
before: t,
|
|
913
|
+
after: n,
|
|
914
|
+
subject: e,
|
|
915
|
+
at: i,
|
|
916
|
+
...Xn(r)
|
|
917
|
+
}
|
|
918
|
+
});
|
|
919
|
+
}
|
|
920
|
+
quietly(e) {
|
|
921
|
+
this.depth++;
|
|
922
|
+
try {
|
|
923
|
+
return e();
|
|
924
|
+
} finally {
|
|
925
|
+
this.depth--;
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
renamed(e, t) {
|
|
929
|
+
this.renames?.push([e, t]);
|
|
930
|
+
}
|
|
931
|
+
begin(e) {
|
|
932
|
+
this.end(), this.enabled() && (this.edit = {
|
|
933
|
+
subject: e,
|
|
934
|
+
before: this.snapshot()
|
|
935
|
+
}, this.depth++);
|
|
936
|
+
}
|
|
937
|
+
end() {
|
|
938
|
+
let e = this.edit;
|
|
939
|
+
if (!e) return;
|
|
940
|
+
this.edit = null, this.depth--;
|
|
941
|
+
let t = this.snapshot();
|
|
942
|
+
U(t, e.before) || this.steps.push({
|
|
943
|
+
type: "indicators",
|
|
944
|
+
before: null,
|
|
945
|
+
after: null,
|
|
946
|
+
indicators: {
|
|
947
|
+
before: e.before,
|
|
948
|
+
after: t,
|
|
949
|
+
subject: e.subject,
|
|
950
|
+
at: this.now()
|
|
951
|
+
}
|
|
952
|
+
});
|
|
953
|
+
}
|
|
954
|
+
}, Qn = class {
|
|
955
|
+
constructor(e, t, n) {
|
|
956
|
+
this.members = e, this.slots = t, this.handover = n;
|
|
957
|
+
}
|
|
958
|
+
ownsPane(e) {
|
|
959
|
+
return this.slots.getPanels().some((t) => t.id === e);
|
|
960
|
+
}
|
|
961
|
+
paneOf(e) {
|
|
962
|
+
return this.members.getIndicatorConfig(e)?.pane ?? e;
|
|
963
|
+
}
|
|
964
|
+
hostOf(e, t) {
|
|
965
|
+
if (e === t) return null;
|
|
966
|
+
if (this.ownsPane(e)) return e;
|
|
967
|
+
let n = this.members.getIndicatorConfig(e)?.pane;
|
|
968
|
+
return n && n !== t ? n : null;
|
|
969
|
+
}
|
|
970
|
+
paneFor(e, t, n, r) {
|
|
971
|
+
if (n) return this.hostOf(n, r);
|
|
972
|
+
if (e.placement !== "overlay") return null;
|
|
973
|
+
let i = j(e), a = i ? x(t[i]) : null;
|
|
974
|
+
return a ? this.hostOf(a.instanceId, r) : null;
|
|
975
|
+
}
|
|
976
|
+
sourceOf(e) {
|
|
977
|
+
let t = this.members.getIndicatorDescriptor(e), n = t ? j(t) : null;
|
|
978
|
+
return n ? this.members.getIndicatorConfig(e)?.params[n] : void 0;
|
|
979
|
+
}
|
|
980
|
+
followSource(e, t) {
|
|
981
|
+
let n = this.members.getIndicatorDescriptor(e), r = this.members.getIndicatorConfig(e), i = n ? j(n) : null;
|
|
982
|
+
if (n?.placement !== "overlay" || !r || !i || r.params[i] === t) return !1;
|
|
983
|
+
let a = x(r.params[i]), o = a ? this.hostOf(a.instanceId, e) : x(t) ? null : r.pane ?? null;
|
|
984
|
+
return (o ?? void 0) === r.pane ? !1 : (this.members.setPane(e, o), !0);
|
|
985
|
+
}
|
|
986
|
+
moveHost(e, t) {
|
|
987
|
+
let n = this.members.getIndicatorConfig(e), r = this.members.getIndicatorDescriptor(e);
|
|
988
|
+
if (!n || !r) return;
|
|
989
|
+
let i = j(r);
|
|
990
|
+
if (r.placement === "overlay" && i && x(n.params[i])) return;
|
|
991
|
+
if (t === "price") return r.placement === "overlay" && n.pane ? null : void 0;
|
|
992
|
+
if (t === "new") return r.placement === "panel" && !this.ownsPane(e) ? null : void 0;
|
|
993
|
+
let a = this.hostOf(t, e);
|
|
994
|
+
return a && a !== n.pane && a !== e ? a : void 0;
|
|
995
|
+
}
|
|
996
|
+
isPanel(e) {
|
|
997
|
+
return this.members.getIndicatorDescriptor(e)?.placement === "panel";
|
|
998
|
+
}
|
|
999
|
+
detach(e, t = () => void 0) {
|
|
1000
|
+
if (!this.members.getIndicatorConfig(e)) return null;
|
|
1001
|
+
let n = this.members.getPaneMembers(e), r = this.ownsPane(e) ? n.find((e) => this.isPanel(e)) ?? null : null;
|
|
1002
|
+
this.members.removeIndicator(e), this.handover.passStyle(e, r), r ? (this.members.setPane(r, null), this.handover.renamePane(e, r)) : this.slots.removePanel(e);
|
|
1003
|
+
for (let e of n) e !== r && this.members.setPane(e, r), t(e);
|
|
1004
|
+
return n;
|
|
1005
|
+
}
|
|
1006
|
+
move(e, t) {
|
|
1007
|
+
let n = this.moveHost(e, t), r = this.members.getIndicatorConfig(e);
|
|
1008
|
+
if (n === void 0 || !r) return null;
|
|
1009
|
+
let i = r.pane, a = new Set([e]);
|
|
1010
|
+
if (this.ownsPane(e)) for (let t of this.leavePane(e, n)) a.add(t);
|
|
1011
|
+
if (this.members.setPane(e, n), t === "new") {
|
|
1012
|
+
this.slots.addPanel(e, "bottom");
|
|
1013
|
+
for (let t of this.members.getDependents(e)) this.members.getIndicatorConfig(t)?.pane === i && (this.members.setPane(t, e), a.add(t));
|
|
1014
|
+
}
|
|
1015
|
+
return [...a];
|
|
1016
|
+
}
|
|
1017
|
+
leavePane(e, t) {
|
|
1018
|
+
let n = this.members.getPaneMembers(e), r = new Set(this.members.getDependents(e)), i = n.filter((e) => !r.has(e)), a = i.find((e) => this.isPanel(e)) ?? null;
|
|
1019
|
+
if (this.handover.passStyle(e, a), a) {
|
|
1020
|
+
this.members.setPane(a, null), this.handover.renamePane(e, a);
|
|
1021
|
+
for (let e of i) e !== a && this.members.setPane(e, a);
|
|
1022
|
+
} else {
|
|
1023
|
+
this.slots.removePanel(e);
|
|
1024
|
+
for (let e of i) this.members.setPane(e, null);
|
|
1025
|
+
}
|
|
1026
|
+
this.handover.invalidateScales();
|
|
1027
|
+
for (let i of n) r.has(i) && this.members.setPane(i, t ?? e);
|
|
1028
|
+
return n;
|
|
1029
|
+
}
|
|
1030
|
+
};
|
|
1031
|
+
//#endregion
|
|
1032
|
+
//#region src/model/IndicatorSetup.ts
|
|
1033
|
+
function $n(e, t, n) {
|
|
1034
|
+
let r = t.getPanels(), i = t.getMaximizedPanel();
|
|
1035
|
+
return e.getActiveIndicators().map((t) => {
|
|
1036
|
+
let a = r.find((e) => e.id === t.instanceId), o = e.getIndicatorConfig(t.instanceId), s = a ? n(t.instanceId) : null;
|
|
1037
|
+
return {
|
|
1038
|
+
id: t.id,
|
|
1039
|
+
instanceId: t.instanceId,
|
|
1040
|
+
params: { ...t.params },
|
|
1041
|
+
position: a?.position,
|
|
1042
|
+
style: e.getIndicatorStyle(t.instanceId) ?? void 0,
|
|
1043
|
+
visible: t.visible,
|
|
1044
|
+
levels: o?.levels?.slice(),
|
|
1045
|
+
pane: t.pane,
|
|
1046
|
+
scale: o?.scale,
|
|
1047
|
+
...o?.intervals ? { intervals: e.getIntervals(t.instanceId) ?? void 0 } : {},
|
|
1048
|
+
...s ? { paneStyle: { ...s } } : {},
|
|
1049
|
+
...a ? {
|
|
1050
|
+
paneSize: a.size,
|
|
1051
|
+
paneOrder: r.indexOf(a),
|
|
1052
|
+
...a.collapsed ? { paneCollapsed: !0 } : {},
|
|
1053
|
+
...i === t.instanceId ? { paneMaximized: !0 } : {},
|
|
1054
|
+
...a.logScale ? { paneLog: !0 } : {},
|
|
1055
|
+
...a.invertScale ? { paneInvert: !0 } : {},
|
|
1056
|
+
...a.percentScale ? { panePercent: !0 } : {}
|
|
1057
|
+
} : {}
|
|
1058
|
+
};
|
|
1059
|
+
});
|
|
1060
|
+
}
|
|
1061
|
+
function er(e, t) {
|
|
1062
|
+
for (let [n, r] of t) n.paneSize !== void 0 && e.setPanelSize(r, n.paneSize), (n.paneSize !== void 0 || n.paneCollapsed) && e.setPanelCollapsed(r, !!n.paneCollapsed), n.paneSize !== void 0 && e.setPanelScale(r, {
|
|
1063
|
+
log: !!n.paneLog,
|
|
1064
|
+
invert: !!n.paneInvert,
|
|
1065
|
+
percent: !!n.panePercent
|
|
1066
|
+
});
|
|
1067
|
+
let n = t.filter(([e]) => e.paneOrder !== void 0).sort(([e], [t]) => (e.paneOrder ?? 0) - (t.paneOrder ?? 0)).map(([, e]) => e);
|
|
1068
|
+
n.length > 1 && e.orderPanels(n);
|
|
1069
|
+
let r = t.find(([e]) => e.paneMaximized);
|
|
1070
|
+
e.setMaximizedPanel(r ? r[1] : null);
|
|
1071
|
+
}
|
|
1072
|
+
function tr(e) {
|
|
1073
|
+
let t = new Map(e.map((e) => [e.instanceId, e])), n = [], r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = (e) => {
|
|
1074
|
+
if (r.has(e.instanceId) || i.has(e.instanceId)) return;
|
|
1075
|
+
i.add(e.instanceId);
|
|
1076
|
+
let o = [e.pane, ...Object.values(e.params).map((e) => x(e)?.instanceId)];
|
|
1077
|
+
for (let e of o) {
|
|
1078
|
+
let n = e ? t.get(e) : void 0;
|
|
1079
|
+
n && a(n);
|
|
1080
|
+
}
|
|
1081
|
+
i.delete(e.instanceId), r.add(e.instanceId), n.push(e);
|
|
1082
|
+
};
|
|
1083
|
+
for (let t of e) a(t);
|
|
1084
|
+
return n;
|
|
1085
|
+
}
|
|
1086
|
+
function nr(e, t) {
|
|
1087
|
+
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);
|
|
1088
|
+
}
|
|
1089
|
+
function rr(e, t) {
|
|
1090
|
+
let n = new Map(t.map((e) => [e.instanceId, e])), r = /* @__PURE__ */ new Set();
|
|
1091
|
+
for (let t of e) {
|
|
1092
|
+
let e = n.get(t.instanceId);
|
|
1093
|
+
e && nr(t, e) && ir(t, e) && r.add(t.instanceId);
|
|
1094
|
+
}
|
|
1095
|
+
for (let t of e) t.pane && !r.has(t.pane) && r.delete(t.instanceId);
|
|
1096
|
+
return r;
|
|
1097
|
+
}
|
|
1098
|
+
function ir(e, t) {
|
|
1099
|
+
let n = Object.keys(e.params);
|
|
1100
|
+
return n.length === Object.keys(t.params).length && n.every((e) => e in t.params);
|
|
1101
|
+
}
|
|
1102
|
+
function ar(e, t) {
|
|
1103
|
+
let n = { ...e };
|
|
1104
|
+
for (let [e, r] of Object.entries(n)) {
|
|
1105
|
+
let i = x(r), a = i && t.get(i.instanceId);
|
|
1106
|
+
a && (n[e] = v(a, i.key));
|
|
1107
|
+
}
|
|
1108
|
+
return n;
|
|
1109
|
+
}
|
|
1110
|
+
//#endregion
|
|
1111
|
+
//#region src/model/SymbolRequests.ts
|
|
1112
|
+
function or(e, t) {
|
|
1113
|
+
let n = t.symbol;
|
|
1114
|
+
return ut.has(e) && typeof n == "string" ? n.trim() : "";
|
|
1115
|
+
}
|
|
1116
|
+
var sr = class {
|
|
1117
|
+
asked = /* @__PURE__ */ new Set();
|
|
1118
|
+
constructor(e, t) {
|
|
1119
|
+
this.readers = e, this.held = t;
|
|
1120
|
+
}
|
|
1121
|
+
required() {
|
|
1122
|
+
let e = /* @__PURE__ */ new Set();
|
|
1123
|
+
for (let t of this.readers.getActiveIndicators()) {
|
|
1124
|
+
let n = or(t.id, t.params);
|
|
1125
|
+
n && e.add(n);
|
|
1126
|
+
}
|
|
1127
|
+
return [...e];
|
|
1128
|
+
}
|
|
1129
|
+
readersOf(e) {
|
|
1130
|
+
let t = e.trim();
|
|
1131
|
+
return this.readers.getActiveIndicators().filter((e) => ut.has(e.id) && String(e.params.symbol ?? "").trim() === t).map((e) => e.instanceId);
|
|
1132
|
+
}
|
|
1133
|
+
given(e) {
|
|
1134
|
+
this.asked.delete(e.trim());
|
|
1135
|
+
}
|
|
1136
|
+
forgetUnread() {
|
|
1137
|
+
let e = new Set(this.required());
|
|
1138
|
+
for (let t of this.asked) e.has(t) || this.asked.delete(t);
|
|
1139
|
+
}
|
|
1140
|
+
toAsk(e) {
|
|
1141
|
+
this.forgetUnread();
|
|
1142
|
+
let t = this.readers.getIndicatorConfig(e), n = t ? or(t.id, t.params) : "";
|
|
1143
|
+
return !n || this.held.has(n) || this.asked.has(n) ? null : (this.asked.add(n), n);
|
|
1144
|
+
}
|
|
1145
|
+
}, cr = (e, t) => e.x >= t.x && e.x <= t.x + t.width && e.y >= t.y && e.y <= t.y + t.height;
|
|
1146
|
+
function lr(e, t, n, r) {
|
|
1147
|
+
if (!cr(e, t)) {
|
|
1148
|
+
for (let t of n) {
|
|
1149
|
+
let n = r(t.id);
|
|
1150
|
+
if (n && cr(e, n.chartRect)) return t.id;
|
|
1151
|
+
}
|
|
1152
|
+
return null;
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
function ur(e, t, n, r) {
|
|
1156
|
+
if (!e || e.position !== "top" && e.position !== "bottom" || t) return null;
|
|
1157
|
+
let i = n();
|
|
1158
|
+
return !i || i.chartRect.height < 24 ? null : {
|
|
1159
|
+
...i,
|
|
1160
|
+
data: r()
|
|
1161
|
+
};
|
|
1162
|
+
}
|
|
1163
|
+
function dr(e, t, n) {
|
|
1164
|
+
return !n && e.some((e) => e.id === t);
|
|
1165
|
+
}
|
|
1166
|
+
//#endregion
|
|
682
1167
|
//#region src/HistoryPager.ts
|
|
683
|
-
var
|
|
1168
|
+
var fr = 5e3, pr = 6e4, mr = 500, hr = class {
|
|
684
1169
|
loader = null;
|
|
685
1170
|
pageSize = 500;
|
|
686
1171
|
loading = !1;
|
|
@@ -735,7 +1220,7 @@ var Vn = 5e3, Hn = 6e4, Un = 500, Wn = class {
|
|
|
735
1220
|
return n === this.seq ? (this.loading = !1, e instanceof Error && e.name === "AbortError" ? (this.emit({
|
|
736
1221
|
state: "loaded",
|
|
737
1222
|
count: 0
|
|
738
|
-
}), 0) : (this.failures++, this.retryAt = this.now() + Math.min(
|
|
1223
|
+
}), 0) : (this.failures++, this.retryAt = this.now() + Math.min(pr, fr * 2 ** (this.failures - 1)), this.emit({
|
|
739
1224
|
state: "error",
|
|
740
1225
|
count: 0,
|
|
741
1226
|
error: e instanceof Error ? e.message : String(e)
|
|
@@ -768,10 +1253,10 @@ var Vn = 5e3, Hn = 6e4, Un = 500, Wn = class {
|
|
|
768
1253
|
};
|
|
769
1254
|
//#endregion
|
|
770
1255
|
//#region src/ThemeManager.ts
|
|
771
|
-
function
|
|
1256
|
+
function gr(e, t) {
|
|
772
1257
|
return e.family === t.family && e.sizeSmall === t.sizeSmall && e.sizeMedium === t.sizeMedium && e.sizeLarge === t.sizeLarge;
|
|
773
1258
|
}
|
|
774
|
-
var
|
|
1259
|
+
var _r = class t {
|
|
775
1260
|
base;
|
|
776
1261
|
shape = null;
|
|
777
1262
|
font = null;
|
|
@@ -796,7 +1281,7 @@ var Kn = class t {
|
|
|
796
1281
|
return this.base;
|
|
797
1282
|
}
|
|
798
1283
|
setTheme(e) {
|
|
799
|
-
let n = t.read(e), r = this.font !== null &&
|
|
1284
|
+
let n = t.read(e), r = this.font !== null && gr(n.font, this.base.font);
|
|
800
1285
|
this.base = n, r || (this.themeFont = n.font), this.shape && (this.base = {
|
|
801
1286
|
...this.base,
|
|
802
1287
|
shape: {
|
|
@@ -878,7 +1363,7 @@ var Kn = class t {
|
|
|
878
1363
|
};
|
|
879
1364
|
//#endregion
|
|
880
1365
|
//#region src/style/styleOptions.ts
|
|
881
|
-
function
|
|
1366
|
+
function vr(e, t) {
|
|
882
1367
|
return t ? {
|
|
883
1368
|
...t.visible === void 0 ? {} : { [`crosshair.${e}.visible`]: t.visible },
|
|
884
1369
|
...t.color === void 0 ? {} : { [`crosshair.${e}.color`]: t.color },
|
|
@@ -886,22 +1371,22 @@ function qn(e, t) {
|
|
|
886
1371
|
...t.width === void 0 ? {} : { [`crosshair.${e}.width`]: t.width }
|
|
887
1372
|
} : {};
|
|
888
1373
|
}
|
|
889
|
-
function
|
|
1374
|
+
function yr(e) {
|
|
890
1375
|
let { grid: t, crosshair: n } = e, r = n?.vLine?.labelBackground ?? n?.hLine?.labelBackground;
|
|
891
1376
|
return {
|
|
892
1377
|
...t?.hLineColor === void 0 ? {} : { "grid.horizontal.color": t.hLineColor },
|
|
893
1378
|
...t?.hLineStyle === void 0 ? {} : { "grid.horizontal.style": t.hLineStyle },
|
|
894
1379
|
...t?.vLineColor === void 0 ? {} : { "grid.vertical.color": t.vLineColor },
|
|
895
1380
|
...t?.vLineStyle === void 0 ? {} : { "grid.vertical.style": t.vLineStyle },
|
|
896
|
-
...
|
|
897
|
-
...
|
|
1381
|
+
...vr("horizontal", n?.hLine),
|
|
1382
|
+
...vr("vertical", n?.vLine),
|
|
898
1383
|
...r === void 0 ? {} : { "crosshair.labelBackground": r },
|
|
899
1384
|
...e.overrides
|
|
900
1385
|
};
|
|
901
1386
|
}
|
|
902
1387
|
//#endregion
|
|
903
1388
|
//#region src/layout/LayoutManager.ts
|
|
904
|
-
var
|
|
1389
|
+
var br = 200, xr = 80, W = (e) => e.position === "top" || e.position === "bottom", Sr = class {
|
|
905
1390
|
panels = [];
|
|
906
1391
|
containerWidth = 0;
|
|
907
1392
|
containerHeight = 0;
|
|
@@ -918,8 +1403,8 @@ var Yn = 200, Xn = 80, W = (e) => e.position === "top" || e.position === "bottom
|
|
|
918
1403
|
this.panels.push({
|
|
919
1404
|
id: e,
|
|
920
1405
|
position: n,
|
|
921
|
-
size: r ?? (a ?
|
|
922
|
-
minSize: a ?
|
|
1406
|
+
size: r ?? (a ? br : t),
|
|
1407
|
+
minSize: a ? xr : i,
|
|
923
1408
|
content: {
|
|
924
1409
|
type: "indicator",
|
|
925
1410
|
indicatorInstanceId: e
|
|
@@ -988,7 +1473,7 @@ var Yn = 200, Xn = 80, W = (e) => e.position === "top" || e.position === "bottom
|
|
|
988
1473
|
let r = this.panels.find((t) => t.id === e);
|
|
989
1474
|
if (r) {
|
|
990
1475
|
let a = r.position === "left" || r.position === "right", o = n === "left" || n === "right";
|
|
991
|
-
r.position = n, a !== o && (r.size = o ?
|
|
1476
|
+
r.position = n, a !== o && (r.size = o ? br : t, r.minSize = o ? xr : i), o && (r.collapsed = void 0, this.maximized === e && (this.maximized = null));
|
|
992
1477
|
}
|
|
993
1478
|
}
|
|
994
1479
|
setPanelSize(e, t) {
|
|
@@ -1108,8 +1593,8 @@ var Yn = 200, Xn = 80, W = (e) => e.position === "top" || e.position === "bottom
|
|
|
1108
1593
|
getMainChartRect() {
|
|
1109
1594
|
return this.resolve().mainChartRect;
|
|
1110
1595
|
}
|
|
1111
|
-
},
|
|
1112
|
-
function
|
|
1596
|
+
}, Cr = 14, wr = 14, Tr = 22, Er = 4;
|
|
1597
|
+
function Dr(e) {
|
|
1113
1598
|
let { min: t, max: n, lastPrice: r, locale: i, fontFamily: a, fontSizeSmall: s, measure: l } = e, u = e.tagPrecision ?? c(t, n), d = u, f = r === null ? [t, n] : [
|
|
1114
1599
|
t,
|
|
1115
1600
|
n,
|
|
@@ -1118,16 +1603,16 @@ function nr(e) {
|
|
|
1118
1603
|
for (let t of f) {
|
|
1119
1604
|
if (!Number.isFinite(t)) continue;
|
|
1120
1605
|
let n = e.scaleLabel ? e.scaleLabel(t) : e.format ? e.format(t) : g(t, u, i), r = e.format ? n : g(t, d, i);
|
|
1121
|
-
p = Math.max(p, l(n, `500 ${s}px ${a}`) +
|
|
1606
|
+
p = Math.max(p, l(n, `500 ${s}px ${a}`) + Cr, l(r, `bold 11px ${a}`) + wr, l(r, `600 ${s}px ${a}`) + Tr);
|
|
1122
1607
|
}
|
|
1123
|
-
return p <= o ? o : Math.ceil(p /
|
|
1608
|
+
return p <= o ? o : Math.ceil(p / Er) * Er;
|
|
1124
1609
|
}
|
|
1125
|
-
function
|
|
1610
|
+
function Or(e, t) {
|
|
1126
1611
|
return t > e || t <= e - 12 ? t : e;
|
|
1127
1612
|
}
|
|
1128
1613
|
//#endregion
|
|
1129
1614
|
//#region src/layout/labelWidths.ts
|
|
1130
|
-
var
|
|
1615
|
+
var kr = 512, Ar = class {
|
|
1131
1616
|
widths = /* @__PURE__ */ new Map();
|
|
1132
1617
|
fonts;
|
|
1133
1618
|
forget = () => this.widths.clear();
|
|
@@ -1138,12 +1623,12 @@ var ir = 512, ar = class {
|
|
|
1138
1623
|
let r = `${t}\n${e}`, i = this.widths.get(r);
|
|
1139
1624
|
if (i !== void 0) return i;
|
|
1140
1625
|
let a = n();
|
|
1141
|
-
return this.widths.size >=
|
|
1626
|
+
return this.widths.size >= kr && this.widths.clear(), this.widths.set(r, a), a;
|
|
1142
1627
|
}
|
|
1143
1628
|
destroy() {
|
|
1144
1629
|
this.fonts?.removeEventListener("loadingdone", this.forget), this.widths.clear();
|
|
1145
1630
|
}
|
|
1146
|
-
},
|
|
1631
|
+
}, jr = class {
|
|
1147
1632
|
netY = 0;
|
|
1148
1633
|
travelX = 0;
|
|
1149
1634
|
engaged = !1;
|
|
@@ -1159,8 +1644,8 @@ var ir = 512, ar = class {
|
|
|
1159
1644
|
}
|
|
1160
1645
|
return this.engaged;
|
|
1161
1646
|
}
|
|
1162
|
-
},
|
|
1163
|
-
function
|
|
1647
|
+
}, Mr = 1;
|
|
1648
|
+
function Nr(e, t) {
|
|
1164
1649
|
return e.filter((e) => e.enabled !== !1 && (e.descriptor.layer ?? "overlay") === t);
|
|
1165
1650
|
}
|
|
1166
1651
|
function G(e) {
|
|
@@ -1174,24 +1659,24 @@ function G(e) {
|
|
|
1174
1659
|
//#endregion
|
|
1175
1660
|
//#region src/plugins/registry.ts
|
|
1176
1661
|
var K = /* @__PURE__ */ new Map();
|
|
1177
|
-
function
|
|
1662
|
+
function Pr(e) {
|
|
1178
1663
|
K.set(G(e), e);
|
|
1179
1664
|
}
|
|
1180
|
-
function
|
|
1665
|
+
function Fr(e) {
|
|
1181
1666
|
return K.delete(e);
|
|
1182
1667
|
}
|
|
1183
|
-
function
|
|
1668
|
+
function Ir() {
|
|
1184
1669
|
return [...K.values()];
|
|
1185
1670
|
}
|
|
1186
|
-
function
|
|
1671
|
+
function Lr() {
|
|
1187
1672
|
K.clear();
|
|
1188
1673
|
}
|
|
1189
1674
|
//#endregion
|
|
1190
1675
|
//#region src/plugins/PluginManager.ts
|
|
1191
|
-
var
|
|
1676
|
+
var Rr = class {
|
|
1192
1677
|
plugins = /* @__PURE__ */ new Map();
|
|
1193
1678
|
constructor(e, t = {}) {
|
|
1194
|
-
if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of
|
|
1679
|
+
if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of Ir()) this.add(e);
|
|
1195
1680
|
for (let e of t.plugins ?? []) this.add(e);
|
|
1196
1681
|
}
|
|
1197
1682
|
register(e) {
|
|
@@ -1221,15 +1706,15 @@ var pr = class {
|
|
|
1221
1706
|
add(e) {
|
|
1222
1707
|
this.plugins.set(G(e), e), e.kind === "indicator" && this.indicatorEngine.register(e.plugin);
|
|
1223
1708
|
}
|
|
1224
|
-
},
|
|
1709
|
+
}, zr = {
|
|
1225
1710
|
orderPlace: (e, t) => e.placeOrder(t),
|
|
1226
1711
|
orderModify: (e, t) => e.modifyOrder(t),
|
|
1227
1712
|
orderCancel: (e, t) => e.cancelOrder(t),
|
|
1228
1713
|
positionModify: (e, t) => e.modifyPosition(t),
|
|
1229
1714
|
positionClose: (e, t) => e.closePosition(t),
|
|
1230
|
-
positionReverse: (e, t, n) =>
|
|
1715
|
+
positionReverse: (e, t, n) => Br(e, t, n)
|
|
1231
1716
|
};
|
|
1232
|
-
async function
|
|
1717
|
+
async function Br(e, t, n) {
|
|
1233
1718
|
let { reversing: r } = n;
|
|
1234
1719
|
if (!r.has(t.positionId)) {
|
|
1235
1720
|
r.add(t.positionId);
|
|
@@ -1258,7 +1743,7 @@ async function hr(e, t, n) {
|
|
|
1258
1743
|
}
|
|
1259
1744
|
}
|
|
1260
1745
|
}
|
|
1261
|
-
function
|
|
1746
|
+
function Vr(e, t) {
|
|
1262
1747
|
let n = [], r = null, i = {
|
|
1263
1748
|
positions: () => r ?? t.getPositions?.() ?? [],
|
|
1264
1749
|
reversing: /* @__PURE__ */ new Set()
|
|
@@ -1268,8 +1753,8 @@ function gr(e, t) {
|
|
|
1268
1753
|
e.data && t.onFill?.(e.data);
|
|
1269
1754
|
};
|
|
1270
1755
|
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));
|
|
1271
|
-
for (let r of Object.keys(
|
|
1272
|
-
let a =
|
|
1756
|
+
for (let r of Object.keys(zr)) {
|
|
1757
|
+
let a = zr[r], o = t.onIntent(r, (n) => {
|
|
1273
1758
|
Promise.resolve(a(e, n, i)).catch((e) => t.onError({
|
|
1274
1759
|
message: `Execution command failed: ${r}`,
|
|
1275
1760
|
cause: e
|
|
@@ -1283,7 +1768,7 @@ function gr(e, t) {
|
|
|
1283
1768
|
}
|
|
1284
1769
|
//#endregion
|
|
1285
1770
|
//#region src/replay/ReplayStepLoader.ts
|
|
1286
|
-
var
|
|
1771
|
+
var Hr = 1e3, Ur = class {
|
|
1287
1772
|
pieces = /* @__PURE__ */ new Map();
|
|
1288
1773
|
asked = /* @__PURE__ */ new Set();
|
|
1289
1774
|
inFlight = !1;
|
|
@@ -1316,7 +1801,7 @@ var _r = 1e3, vr = class {
|
|
|
1316
1801
|
this.done = !0;
|
|
1317
1802
|
}
|
|
1318
1803
|
ask(e, t) {
|
|
1319
|
-
let { ratio: n, barMs: r, step: i, report: a } = this.options, o = Math.max(1, Math.floor(
|
|
1804
|
+
let { ratio: n, barMs: r, step: i, report: a } = this.options, o = Math.max(1, Math.floor(Hr / n)), s = Math.min(e.length, t + o), c = s < e.length ? e[s].time : e[e.length - 1].time + r, l = e.slice(t, s);
|
|
1320
1805
|
for (let e of l) this.asked.add(e.time);
|
|
1321
1806
|
this.inFlight = !0, a({
|
|
1322
1807
|
state: "loading",
|
|
@@ -1357,12 +1842,12 @@ var _r = 1e3, vr = class {
|
|
|
1357
1842
|
...n === void 0 ? {} : { error: n }
|
|
1358
1843
|
});
|
|
1359
1844
|
}
|
|
1360
|
-
},
|
|
1361
|
-
function
|
|
1362
|
-
let n = (e.high - e.low) *
|
|
1363
|
-
return t.filter((t) => t.close > e.high + n || t.close < e.low - n).length <= t.length *
|
|
1845
|
+
}, Wr = 1 / 3, Gr = .25, Kr = .5;
|
|
1846
|
+
function qr(e, t) {
|
|
1847
|
+
let n = (e.high - e.low) * Gr;
|
|
1848
|
+
return t.filter((t) => t.close > e.high + n || t.close < e.low - n).length <= t.length * Kr;
|
|
1364
1849
|
}
|
|
1365
|
-
function
|
|
1850
|
+
function Jr(e) {
|
|
1366
1851
|
return e.close >= e.open ? [
|
|
1367
1852
|
e.open,
|
|
1368
1853
|
e.low,
|
|
@@ -1375,22 +1860,22 @@ function Cr(e) {
|
|
|
1375
1860
|
e.close
|
|
1376
1861
|
];
|
|
1377
1862
|
}
|
|
1378
|
-
function
|
|
1379
|
-
let r =
|
|
1863
|
+
function Yr(e, t, n) {
|
|
1864
|
+
let r = Jr(e), i = [
|
|
1380
1865
|
1,
|
|
1381
1866
|
2,
|
|
1382
1867
|
3
|
|
1383
1868
|
].map((e) => Math.abs(r[e] - r[e - 1])), a = i[0] + i[1] + i[2], o = [], s = 0;
|
|
1384
1869
|
return r.forEach((r, c) => {
|
|
1385
|
-
c > 0 && (s += a > 0 ? i[c - 1] / a :
|
|
1870
|
+
c > 0 && (s += a > 0 ? i[c - 1] / a : Wr), !(c === 0 && t > 0) && o.push({
|
|
1386
1871
|
price: r,
|
|
1387
1872
|
time: e.time,
|
|
1388
1873
|
at: (t + s) / n
|
|
1389
1874
|
});
|
|
1390
1875
|
}), o;
|
|
1391
1876
|
}
|
|
1392
|
-
function
|
|
1393
|
-
let n = t.length > 0 &&
|
|
1877
|
+
function Xr(e, t = []) {
|
|
1878
|
+
let n = t.length > 0 && qr(e, t) ? t : [e], r = n.length, i = Zr(n.flatMap((e, t) => Yr(e, t, r)), e), a = n.reduce((e, t) => e + (t.volume ?? 0), 0), o = 0;
|
|
1394
1879
|
return {
|
|
1395
1880
|
bar: e,
|
|
1396
1881
|
points: i,
|
|
@@ -1400,7 +1885,7 @@ function Tr(e, t = []) {
|
|
|
1400
1885
|
}))
|
|
1401
1886
|
};
|
|
1402
1887
|
}
|
|
1403
|
-
function
|
|
1888
|
+
function Zr(e, t) {
|
|
1404
1889
|
let n = e.length - 1, r = e.map((e, r) => ({
|
|
1405
1890
|
...e,
|
|
1406
1891
|
price: r === 0 ? t.open : r === n ? t.close : Math.min(t.high, Math.max(t.low, e.price))
|
|
@@ -1415,7 +1900,7 @@ function Er(e, t) {
|
|
|
1415
1900
|
};
|
|
1416
1901
|
return i(t.high, (e, t) => e > t), i(t.low, (e, t) => e < t), r;
|
|
1417
1902
|
}
|
|
1418
|
-
function
|
|
1903
|
+
function Qr(e, t) {
|
|
1419
1904
|
let n = e.points;
|
|
1420
1905
|
if (t <= n[0].at) return n[0].price;
|
|
1421
1906
|
for (let e = 1; e < n.length; e++) if (t <= n[e].at) {
|
|
@@ -1424,8 +1909,8 @@ function Dr(e, t) {
|
|
|
1424
1909
|
}
|
|
1425
1910
|
return n[n.length - 1].price;
|
|
1426
1911
|
}
|
|
1427
|
-
var
|
|
1428
|
-
function
|
|
1912
|
+
var $r = (e) => Number.isFinite(e) ? Math.min(1, Math.max(0, e)) : 0;
|
|
1913
|
+
function ei(e, t) {
|
|
1429
1914
|
let n = 0, r = 0;
|
|
1430
1915
|
for (let i of e.volumeAt) {
|
|
1431
1916
|
if (t >= i.at) {
|
|
@@ -1436,10 +1921,10 @@ function kr(e, t) {
|
|
|
1436
1921
|
}
|
|
1437
1922
|
return n;
|
|
1438
1923
|
}
|
|
1439
|
-
function
|
|
1440
|
-
let n =
|
|
1924
|
+
function ti(e, t) {
|
|
1925
|
+
let n = $r(t);
|
|
1441
1926
|
if (n >= 1) return { ...e.bar };
|
|
1442
|
-
let r =
|
|
1927
|
+
let r = Qr(e, n), i = Math.max(e.points[0].price, r), a = Math.min(e.points[0].price, r);
|
|
1443
1928
|
for (let t of e.points) {
|
|
1444
1929
|
if (t.at > n) break;
|
|
1445
1930
|
i = Math.max(i, t.price), a = Math.min(a, t.price);
|
|
@@ -1450,11 +1935,11 @@ function Ar(e, t) {
|
|
|
1450
1935
|
high: i,
|
|
1451
1936
|
low: a,
|
|
1452
1937
|
close: r,
|
|
1453
|
-
volume:
|
|
1938
|
+
volume: ei(e, n)
|
|
1454
1939
|
};
|
|
1455
1940
|
}
|
|
1456
|
-
function
|
|
1457
|
-
let n =
|
|
1941
|
+
function ni(e, t) {
|
|
1942
|
+
let n = $r(t), r = 0;
|
|
1458
1943
|
for (let t of e.points) {
|
|
1459
1944
|
if (t.at > n) break;
|
|
1460
1945
|
r = t.at;
|
|
@@ -1467,12 +1952,12 @@ function q(e, t, n) {
|
|
|
1467
1952
|
if (a.at > n) break;
|
|
1468
1953
|
i = a.time, a.at > t && r.push([a.price, a.time]);
|
|
1469
1954
|
}
|
|
1470
|
-
let a =
|
|
1955
|
+
let a = Qr(e, n);
|
|
1471
1956
|
return (r.length === 0 || r[r.length - 1][0] !== a) && r.push([a, i]), r;
|
|
1472
1957
|
}
|
|
1473
1958
|
//#endregion
|
|
1474
1959
|
//#region src/replay/replayStep.ts
|
|
1475
|
-
var
|
|
1960
|
+
var ri = [
|
|
1476
1961
|
"1m",
|
|
1477
1962
|
"3m",
|
|
1478
1963
|
"5m",
|
|
@@ -1483,30 +1968,176 @@ var Mr = [
|
|
|
1483
1968
|
"4h",
|
|
1484
1969
|
"1d"
|
|
1485
1970
|
];
|
|
1486
|
-
function
|
|
1971
|
+
function ii(e, t) {
|
|
1487
1972
|
let n = w(e);
|
|
1488
|
-
return n > 0 ?
|
|
1973
|
+
return n > 0 ? ri.filter((e) => {
|
|
1489
1974
|
let r = w(e);
|
|
1490
1975
|
return r < n && n % r === 0 && t(e);
|
|
1491
1976
|
}) : [];
|
|
1492
1977
|
}
|
|
1493
|
-
function
|
|
1494
|
-
let r =
|
|
1978
|
+
function ai(e, t, n) {
|
|
1979
|
+
let r = ii(t, n);
|
|
1495
1980
|
if (e !== "auto") return r.includes(e) ? e : null;
|
|
1496
1981
|
let i = w(t);
|
|
1497
1982
|
return r.find((e) => i / w(e) <= 60) ?? null;
|
|
1498
1983
|
}
|
|
1499
1984
|
//#endregion
|
|
1985
|
+
//#region src/model/AlertWatch.ts
|
|
1986
|
+
function oi(e, t) {
|
|
1987
|
+
e.setBarTime(t.barTime);
|
|
1988
|
+
let n = new Map([["price", t.price]]);
|
|
1989
|
+
t.lines && si(e.getAlerts(), t.lines, n), e.checkChannels(n, { together: !0 }), e.checkDrawings(t.price);
|
|
1990
|
+
}
|
|
1991
|
+
function si(e, t, n) {
|
|
1992
|
+
let r = e.flatMap((e) => e.target ? [e.channel, e.target] : [e.channel]);
|
|
1993
|
+
for (let e of r) {
|
|
1994
|
+
if (n.has(e)) continue;
|
|
1995
|
+
let r = e.indexOf(":");
|
|
1996
|
+
if (r < 0) continue;
|
|
1997
|
+
let i = t(e.slice(0, r)), a = i?.[i.length - 1]?.[e.slice(r + 1)];
|
|
1998
|
+
typeof a == "number" && Number.isFinite(a) && n.set(e, a);
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
function ci(e, t, n, r) {
|
|
2002
|
+
let i = (e) => {
|
|
2003
|
+
let i = e.indexOf(":");
|
|
2004
|
+
if (i <= 0) return null;
|
|
2005
|
+
let a = e.slice(0, i), o = t.get(a);
|
|
2006
|
+
if (!o || r(a) !== void 0) return null;
|
|
2007
|
+
let s = n.filter((e) => r(e) === o);
|
|
2008
|
+
return s.length === 1 ? s[0] + e.slice(i) : null;
|
|
2009
|
+
};
|
|
2010
|
+
for (let t of e.getAlerts()) {
|
|
2011
|
+
let n = i(t.channel), r = t.target ? i(t.target) : null;
|
|
2012
|
+
if (!n && !r) continue;
|
|
2013
|
+
let { percent: a, bars: o, onBarClose: s, expiresAt: c } = t;
|
|
2014
|
+
e.removeAlert(t.id), e.addAlert(t.price, t.condition, t.message, t.repeating, n ?? t.channel, t.label, {
|
|
2015
|
+
...t.target ? { target: r ?? t.target } : {},
|
|
2016
|
+
...a === void 0 ? {} : { percent: a },
|
|
2017
|
+
...o === void 0 ? {} : { bars: o },
|
|
2018
|
+
...s ? { onBarClose: s } : {},
|
|
2019
|
+
...c === void 0 ? {} : { expiresAt: c }
|
|
2020
|
+
});
|
|
2021
|
+
}
|
|
2022
|
+
}
|
|
2023
|
+
function li(e, t) {
|
|
2024
|
+
let n = e.indexOf(":"), r = n > 0 ? t.get(e.slice(0, n)) : void 0;
|
|
2025
|
+
return r ? r + e.slice(n) : e;
|
|
2026
|
+
}
|
|
2027
|
+
var ui = [
|
|
2028
|
+
"crossing",
|
|
2029
|
+
"crossingUp",
|
|
2030
|
+
"crossingDown"
|
|
2031
|
+
];
|
|
2032
|
+
function di(e, t, n, r, i) {
|
|
2033
|
+
e.clearAlerts();
|
|
2034
|
+
for (let a of t) {
|
|
2035
|
+
if (a.triggered && !a.repeating || a.expired) continue;
|
|
2036
|
+
if (a.drawingId) {
|
|
2037
|
+
r(a.drawingId) && ui.includes(a.condition) && e.addDrawingAlert(a.drawingId, a.condition, a.message, a.repeating, a.label);
|
|
2038
|
+
continue;
|
|
2039
|
+
}
|
|
2040
|
+
let t = {
|
|
2041
|
+
...Bt(a),
|
|
2042
|
+
...a.target ? { target: li(a.target, n) } : {}
|
|
2043
|
+
};
|
|
2044
|
+
try {
|
|
2045
|
+
e.addAlert(a.price, a.condition, a.message, a.repeating, li(a.channel, n), a.label, t);
|
|
2046
|
+
} catch (e) {
|
|
2047
|
+
i(e);
|
|
2048
|
+
}
|
|
2049
|
+
}
|
|
2050
|
+
}
|
|
2051
|
+
var fi = class {
|
|
2052
|
+
kept = /* @__PURE__ */ new Map();
|
|
2053
|
+
constructor(e) {
|
|
2054
|
+
this.alerts = e;
|
|
2055
|
+
}
|
|
2056
|
+
removed(e) {
|
|
2057
|
+
let t = this.alerts.takeDrawingAlerts(e);
|
|
2058
|
+
t.length > 0 && this.kept.set(e, t);
|
|
2059
|
+
}
|
|
2060
|
+
created(e) {
|
|
2061
|
+
let t = this.kept.get(e);
|
|
2062
|
+
t && (this.kept.delete(e), this.alerts.restoreAlerts(t));
|
|
2063
|
+
}
|
|
2064
|
+
prune(e) {
|
|
2065
|
+
return this.kept.clear(), this.alerts.pruneDrawingAlerts(e);
|
|
2066
|
+
}
|
|
2067
|
+
};
|
|
2068
|
+
function J(e, t) {
|
|
2069
|
+
let n = 0, r = e.length;
|
|
2070
|
+
for (; n < r;) {
|
|
2071
|
+
let i = n + r >> 1;
|
|
2072
|
+
e[i].time < t ? n = i + 1 : r = i;
|
|
2073
|
+
}
|
|
2074
|
+
return n;
|
|
2075
|
+
}
|
|
2076
|
+
function Y(e, t) {
|
|
2077
|
+
let n = 0, r = e.length;
|
|
2078
|
+
for (; n < r;) {
|
|
2079
|
+
let i = n + r >> 1;
|
|
2080
|
+
e[i].time <= t ? n = i + 1 : r = i;
|
|
2081
|
+
}
|
|
2082
|
+
return n;
|
|
2083
|
+
}
|
|
2084
|
+
function pi(e) {
|
|
2085
|
+
let t = 0, n = 0;
|
|
2086
|
+
for (let r = 1; r < e.length; r++) e[r].low < e[t].low && (t = r), e[r].high > e[n].high && (n = r);
|
|
2087
|
+
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];
|
|
2088
|
+
return [...a ? [r, i] : [i, r], [o.close, o.time]];
|
|
2089
|
+
}
|
|
2090
|
+
function mi(e) {
|
|
2091
|
+
let t = [], n = Math.ceil(e.length / 500);
|
|
2092
|
+
for (let r = 0; r < e.length; r += n) t.push(...pi(e.slice(r, r + n)));
|
|
2093
|
+
return t;
|
|
2094
|
+
}
|
|
2095
|
+
function hi(e, t, n) {
|
|
2096
|
+
let r = e[t];
|
|
2097
|
+
return r ? n.time === null ? {
|
|
2098
|
+
marks: [[r.close, r.time]],
|
|
2099
|
+
fed: {
|
|
2100
|
+
time: r.time,
|
|
2101
|
+
fraction: n.fraction
|
|
2102
|
+
}
|
|
2103
|
+
} : r.time <= n.time ? null : {
|
|
2104
|
+
marks: mi(e.slice(Y(e, n.time), t + 1)),
|
|
2105
|
+
fed: {
|
|
2106
|
+
time: r.time,
|
|
2107
|
+
fraction: n.fraction
|
|
2108
|
+
}
|
|
2109
|
+
} : null;
|
|
2110
|
+
}
|
|
2111
|
+
function gi(e, t, n, r, i, a) {
|
|
2112
|
+
let o = e[t];
|
|
2113
|
+
if (!o) return null;
|
|
2114
|
+
let s = {
|
|
2115
|
+
time: o.time,
|
|
2116
|
+
fraction: r
|
|
2117
|
+
};
|
|
2118
|
+
if (i.time === null) return {
|
|
2119
|
+
marks: [[ti(n, r).close, o.time]],
|
|
2120
|
+
fed: s
|
|
2121
|
+
};
|
|
2122
|
+
if (o.time < i.time || o.time === i.time && r <= i.fraction) return null;
|
|
2123
|
+
if (o.time === i.time) return {
|
|
2124
|
+
marks: q(n, i.fraction, r),
|
|
2125
|
+
fed: s
|
|
2126
|
+
};
|
|
2127
|
+
let c = [], l = J(e, i.time);
|
|
2128
|
+
return e[l]?.time === i.time && i.fraction < 1 && c.push(...q(a(e, l), i.fraction, 1)), c.push(...mi(e.slice(Y(e, i.time), t))), c.push(...q(n, -1, r)), {
|
|
2129
|
+
marks: c,
|
|
2130
|
+
fed: s
|
|
2131
|
+
};
|
|
2132
|
+
}
|
|
2133
|
+
//#endregion
|
|
1500
2134
|
//#region src/Chart.ts
|
|
1501
|
-
var
|
|
1502
|
-
|
|
1503
|
-
max: 100
|
|
1504
|
-
}, Ir = "exchange", Lr = Ir;
|
|
1505
|
-
function Rr(e) {
|
|
2135
|
+
var _i = "exchange", vi = _i;
|
|
2136
|
+
function yi(e) {
|
|
1506
2137
|
if (typeof e == "string" && e !== "exchange" && !y(e)) throw RangeError(`Unknown time zone: ${e}`);
|
|
1507
2138
|
if (typeof e == "number" && !Number.isFinite(e)) throw RangeError(`Invalid UTC offset: ${e}`);
|
|
1508
2139
|
}
|
|
1509
|
-
function
|
|
2140
|
+
function bi(e, t) {
|
|
1510
2141
|
let { timeZone: n, timezone: r } = e, i = n !== void 0 && r !== void 0 && n !== r && n === t ? r : C(e);
|
|
1511
2142
|
return i === void 0 ? e : {
|
|
1512
2143
|
...e,
|
|
@@ -1514,20 +2145,16 @@ function zr(e, t) {
|
|
|
1514
2145
|
timezone: i
|
|
1515
2146
|
};
|
|
1516
2147
|
}
|
|
1517
|
-
var
|
|
1518
|
-
function Wr(e) {
|
|
1519
|
-
return e.length > 0 ? { renames: e } : {};
|
|
1520
|
-
}
|
|
1521
|
-
var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
2148
|
+
var xi = .08, Si = 20, Ci = 8, wi = 10, Ti = {
|
|
1522
2149
|
ArrowLeft: [-1, 0],
|
|
1523
2150
|
ArrowRight: [1, 0],
|
|
1524
2151
|
ArrowUp: [0, -1],
|
|
1525
2152
|
ArrowDown: [0, 1]
|
|
1526
|
-
},
|
|
1527
|
-
static version = "1.
|
|
2153
|
+
}, Ei = new Set(["horizontalLine", "crossLine"]), Di = new Set(["verticalLine", "crossLine"]), Oi = class {
|
|
2154
|
+
static version = "1.71.0";
|
|
1528
2155
|
engine;
|
|
1529
2156
|
viewport;
|
|
1530
|
-
series = new
|
|
2157
|
+
series = new Bn((e) => this.sessionKeep(e), (e) => this.followLiveChange(e));
|
|
1531
2158
|
themeManager;
|
|
1532
2159
|
layoutManager;
|
|
1533
2160
|
pluginManager;
|
|
@@ -1541,20 +2168,18 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
1541
2168
|
executionAdapter = null;
|
|
1542
2169
|
execTeardown = null;
|
|
1543
2170
|
autoScrollOnNewBar = !0;
|
|
1544
|
-
displayDataCache = null;
|
|
1545
2171
|
indicatorsOnDrawn = null;
|
|
1546
|
-
|
|
1547
|
-
displayDataStep;
|
|
2172
|
+
display;
|
|
1548
2173
|
indicatorUpdateFrom = null;
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
2174
|
+
panes;
|
|
2175
|
+
indicatorPanes;
|
|
2176
|
+
indicatorHistory;
|
|
1552
2177
|
lastBackground = null;
|
|
1553
2178
|
renderScheduled = !1;
|
|
1554
2179
|
renderDeferred = !1;
|
|
1555
2180
|
priceAxisWidth = o;
|
|
1556
2181
|
measureCtx;
|
|
1557
|
-
labelWidths = new
|
|
2182
|
+
labelWidths = new Ar();
|
|
1558
2183
|
containerSizeCache = null;
|
|
1559
2184
|
containerSizeCacheTime = 0;
|
|
1560
2185
|
lastEmittedRange = null;
|
|
@@ -1565,9 +2190,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
1565
2190
|
watermark;
|
|
1566
2191
|
barCountdown;
|
|
1567
2192
|
unrestoredIndicators = [];
|
|
1568
|
-
|
|
1569
|
-
indicatorEdit = null;
|
|
1570
|
-
removedDrawingAlerts = /* @__PURE__ */ new Map();
|
|
2193
|
+
drawingAlerts = null;
|
|
1571
2194
|
zoomAreaMode = !1;
|
|
1572
2195
|
priceAxisAddButton = new rt();
|
|
1573
2196
|
displayTz = null;
|
|
@@ -1599,7 +2222,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
1599
2222
|
signalMarkerManager;
|
|
1600
2223
|
tradeZoneManager;
|
|
1601
2224
|
measureOverlay;
|
|
1602
|
-
selectionBoxOverlay = new
|
|
2225
|
+
selectionBoxOverlay = new ft();
|
|
1603
2226
|
replayManager;
|
|
1604
2227
|
replayBarUnsub = null;
|
|
1605
2228
|
replaySeeking = !1;
|
|
@@ -1627,10 +2250,10 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
1627
2250
|
chartTypeOptions = {};
|
|
1628
2251
|
mainSeriesVisible = !0;
|
|
1629
2252
|
priceLines = new it();
|
|
1630
|
-
symbolSeries = new
|
|
2253
|
+
symbolSeries = new yt();
|
|
1631
2254
|
extendedHours = !0;
|
|
1632
2255
|
replayRestarting = !1;
|
|
1633
|
-
|
|
2256
|
+
symbolRequests;
|
|
1634
2257
|
gridRenderer;
|
|
1635
2258
|
priceAxis;
|
|
1636
2259
|
leftPriceAxis = new nt();
|
|
@@ -1648,9 +2271,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
1648
2271
|
priceFormatter = null;
|
|
1649
2272
|
priceUnit = null;
|
|
1650
2273
|
paneTitles = !0;
|
|
1651
|
-
|
|
1652
|
-
priceFitPending = !0;
|
|
1653
|
-
seriesArriving = !0;
|
|
2274
|
+
priceFit;
|
|
1654
2275
|
keyboardHandler = null;
|
|
1655
2276
|
a11y = null;
|
|
1656
2277
|
onWindowKeyDown = null;
|
|
@@ -1666,10 +2287,20 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
1666
2287
|
snapshotKey = null;
|
|
1667
2288
|
historyCheckQueued = !1;
|
|
1668
2289
|
constructor(e, t) {
|
|
1669
|
-
t.timeZone != null &&
|
|
2290
|
+
t.timeZone != null && yi(t.timeZone), this.container = e, this.options = {
|
|
1670
2291
|
...t,
|
|
1671
2292
|
chartType: t.chartType ?? "candlestick"
|
|
1672
|
-
}, this.numberLocale = t.numberLocale ?? "en-US", this.
|
|
2293
|
+
}, this.numberLocale = t.numberLocale ?? "en-US", this.priceFit = new Un(t.autoScale !== !1), this.display = new Kn({
|
|
2294
|
+
bars: () => this.series.bars(),
|
|
2295
|
+
version: () => this.series.version(),
|
|
2296
|
+
chartType: () => this.options.chartType,
|
|
2297
|
+
chartTypeOptions: () => this.chartTypeOptions,
|
|
2298
|
+
lookup: (e) => this.pluginManager.getChartType(e),
|
|
2299
|
+
stepAt: (e) => this.stepAt(e),
|
|
2300
|
+
onBoxSize: (e) => {
|
|
2301
|
+
this.chartRenderer instanceof tt && this.chartRenderer.setBoxSize(e);
|
|
2302
|
+
}
|
|
2303
|
+
});
|
|
1673
2304
|
let n = t.features ?? {};
|
|
1674
2305
|
this.features = {
|
|
1675
2306
|
drawings: n.drawings ?? !0,
|
|
@@ -1705,15 +2336,23 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
1705
2336
|
logScale: n.logScale ?? !0,
|
|
1706
2337
|
timeframes: n.timeframes ?? [],
|
|
1707
2338
|
defaultTimeframeFavorites: n.defaultTimeframeFavorites ?? []
|
|
1708
|
-
}, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", e.style.userSelect = "none", e.style.webkitUserSelect = "none", this.history = new
|
|
2339
|
+
}, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", e.style.userSelect = "none", e.style.webkitUserSelect = "none", this.history = new hr({
|
|
1709
2340
|
oldestTime: () => (this.replaySession ? this.series.liveBars() : this.series.bars())[0]?.time ?? null,
|
|
1710
2341
|
prepend: (e) => this.prependBars(e),
|
|
1711
2342
|
emit: (e) => this.eventBus.emit("historyLoad", e)
|
|
1712
|
-
}), this.themeManager = new
|
|
2343
|
+
}), this.themeManager = new _r(t.theme), this.themeManager.setChartType(this.options.chartType ?? "candlestick"), this.applyStyle(yr(t), "host", !1), this.layoutManager = new Sr(), this.indicatorEngine = new Ve(), this.panes = new Jn(this.layoutManager, this.indicatorEngine, (e) => this.crosshairHandler.setReportBounds(e)), this.indicatorPanes = new Qn(this.indicatorEngine, this.layoutManager, {
|
|
2344
|
+
passStyle: (e, t) => this.panes.passStyle(e, t),
|
|
2345
|
+
renamePane: (e, t) => this.renamePane(e, t),
|
|
2346
|
+
invalidateScales: () => this.panes.invalidateScales()
|
|
2347
|
+
}), this.symbolRequests = new sr(this.indicatorEngine, this.symbolSeries), this.pluginManager = new Rr(this.indicatorEngine, { plugins: t.plugins }), this.eventBus = new Ie(), Ht(this.indicatorEngine), this.indicatorEngine.register(new we(this.symbolSeries)), this.indicatorEngine.register(new Te(this.symbolSeries)), this.indicatorEngine.register(new gt(this.symbolSeries)), this.indicatorEngine.register(new Ee(this.symbolSeries)), this.indicatorEngine.register(new De(this.symbolSeries)), this.drawingManager = new Ne(), Vt(this.drawingManager), this.drawingRenderer = new Pe(this.drawingManager), this.drawingRenderer.setKeepOut(() => this.legendKeepOut()), this.drawingRenderer.setTimeFormat((e) => this.crosshairHandler.formatTime(e, this.getDisplayData())), this.drawingManager.setRequestRender(() => {
|
|
1713
2348
|
this.syncRenderContext(), this.engine.requestRender(r.Overlay), this.scheduleAutoSave();
|
|
1714
2349
|
}), this.drawingManager.setEventCallback((e, t) => {
|
|
1715
2350
|
this.followDrawingAlerts(e, t?.id), this.eventBus.emit(e, t), (e === "drawingCreate" || e === "drawingUpdate" || e === "drawingRemove") && this.announceStateChange();
|
|
1716
|
-
}), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new
|
|
2351
|
+
}), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new wt(), this.indicatorHistory = new Zn({
|
|
2352
|
+
steps: this.undoRedoManager,
|
|
2353
|
+
snapshot: () => this.getIndicatorSetup(),
|
|
2354
|
+
enabled: () => this.features.drawingUndoRedo
|
|
2355
|
+
});
|
|
1717
2356
|
let i = "";
|
|
1718
2357
|
this.undoRedoManager.setOnChange(() => {
|
|
1719
2358
|
let { canUndo: e, canRedo: t } = this.undoRedoManager.getState(), n = `${e}|${t}`;
|
|
@@ -1726,23 +2365,23 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
1726
2365
|
primary: e[0] ?? null
|
|
1727
2366
|
})), this.drawingManager.setForeignHistory((e, t) => {
|
|
1728
2367
|
e.type === "custom" ? e.custom?.[t]() : this.applyIndicatorStep(e, t);
|
|
1729
|
-
}), this.drawingManager.setDataGetter(() => this.series.bars(), () => this.series.revision()), this.drawingManager.setDisplayDataGetter(() => this.getDisplayData()), t.crosshair?.mode === "magnet" && this.features.drawingMagnet && this.drawingManager.setMagnetMode("magnet"), this.tradingManager = new
|
|
2368
|
+
}), this.drawingManager.setDataGetter(() => this.series.bars(), () => this.series.revision()), this.drawingManager.setDisplayDataGetter(() => this.getDisplayData()), t.crosshair?.mode === "magnet" && this.features.drawingMagnet && this.drawingManager.setMagnetMode("magnet"), this.tradingManager = new St({
|
|
1730
2369
|
enabled: this.features.trading,
|
|
1731
2370
|
contextMenu: { enabled: this.features.tradingContextMenu }
|
|
1732
|
-
}), this.tradingRenderer = new
|
|
2371
|
+
}), this.tradingRenderer = new Ct(this.tradingManager), this.tradingManager.setContainer(e), this.tradingManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradingManager.setEventCallback((e, t) => {
|
|
1733
2372
|
this.eventBus.emit(e, t);
|
|
1734
2373
|
}), this.engine = new at(e, t.maxPixelRatio);
|
|
1735
2374
|
let a = this.engine.dprManager.getContainerSize();
|
|
1736
|
-
if (this.viewport = new
|
|
2375
|
+
if (this.viewport = new Tt(a.width, a.height, t.minBarSpacing ?? 2, t.maxBarSpacing ?? 30, t.rightMargin ?? 5), t.barLayout && this.viewport.setBarLayout(t.barLayout), this.viewport.setPanLimits({
|
|
1737
2376
|
freePan: t.freePan ?? !0,
|
|
1738
2377
|
minVisibleBars: t.panLimits?.minVisibleBars ?? 3
|
|
1739
2378
|
}), t.minBarUnit !== void 0 && this.viewport.setMinBarUnit(t.minBarUnit), this.layoutManager.resize(a.width, a.height), this.engine.onContainerResize = (e) => {
|
|
1740
2379
|
if (e.width <= 0 || e.height <= 0) return;
|
|
1741
2380
|
let t = this.viewport.isAtEnd();
|
|
1742
2381
|
this.viewport.resize(e.width, e.height), this.layoutManager.resize(e.width, e.height), this.updateViewportAndRender(t), this.eventBus.emit("resize", e);
|
|
1743
|
-
}, this.chartRenderer = this.createChartRenderer(this.options.chartType), this.gridRenderer = new Le(), t.grid?.visible === !1 && this.gridRenderer.setVisible(!1), this.priceAxis = new nt(), this.priceAxis.setLocale(this.numberLocale), this.leftPriceAxis.setLocale(this.numberLocale), this.viewport.setNumberLocale(this.numberLocale), this.timeAxis = new
|
|
2382
|
+
}, this.chartRenderer = this.createChartRenderer(this.options.chartType), this.gridRenderer = new Le(), t.grid?.visible === !1 && this.gridRenderer.setVisible(!1), this.priceAxis = new nt(), this.priceAxis.setLocale(this.numberLocale), this.leftPriceAxis.setLocale(this.numberLocale), this.viewport.setNumberLocale(this.numberLocale), this.timeAxis = new bt(), this.timeAxis.setLocale(this.numberLocale), this.crosshairHandler = new Oe(), this.crosshairHandler.setLocale(this.numberLocale), this.applyTimeSpacing(), t.crosshair?.mode && this.crosshairHandler.setMode(t.crosshair.mode), this.crosshairHandler.setDataSource(() => this.crosshairSeries()), this.crosshairHandler.setCallback((e, t) => {
|
|
1744
2383
|
if (e !== null && t) {
|
|
1745
|
-
let n = this.crosshairSeries(), i = e >= 0 && e < n.length ? n[e] : void 0, a = e > 0 ? n[e - 1]?.close : void 0, o =
|
|
2384
|
+
let n = this.crosshairSeries(), i = e >= 0 && e < n.length ? n[e] : void 0, a = e > 0 ? n[e - 1]?.close : void 0, o = k(n), s = i ? o[e]?.time ?? i.time : void 0;
|
|
1746
2385
|
this.chartLegend.setHoverBar(i ?? null, e > 0 ? n[e - 1] ?? null : null), this.features.legend && this.engine.requestRender(r.Hover);
|
|
1747
2386
|
let c = this.viewport.getState(), l = t.y >= c.chartRect.y && t.y <= c.chartRect.y + c.chartRect.height;
|
|
1748
2387
|
if (i && l && this.features.crosshairTooltip) {
|
|
@@ -1754,7 +2393,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
1754
2393
|
prevClose: a,
|
|
1755
2394
|
priceRange: c.priceRange,
|
|
1756
2395
|
plot: c.chartRect,
|
|
1757
|
-
barStepMs:
|
|
2396
|
+
barStepMs: jt(o),
|
|
1758
2397
|
timeUnit: u(o)
|
|
1759
2398
|
});
|
|
1760
2399
|
} else this.crosshairTooltip.hide();
|
|
@@ -1772,12 +2411,12 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
1772
2411
|
}
|
|
1773
2412
|
}), this.chartLegend = new Se(), this.chartLegend.setChartType(this.options.chartType), this.chartLegend.setLocale(this.numberLocale), this.chartLegend.setResizeListener(() => {
|
|
1774
2413
|
this.eventBus.emit("legendResize", { bottom: this.getLegendBottom() }), this.engine.requestRender();
|
|
1775
|
-
}), this.watermark = new
|
|
2414
|
+
}), this.watermark = new kt(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new Ot(), this.volumeProfile = new Dt(), this.marketProfile = new qe(), this.depthHeatmap = new Me(), this.periodLevels = new Qe(), this.pivotMarkers = new et(), this.barCountdown = new ve(), this.barCountdown.setVisible(this.features.barCountdown), this.sessionBreaks = new pt(), this.sessionShading = new mt(), this.compareRenderer = new Ce(), t.sessionBreaks ? this.sessionBreaks.setConfig({
|
|
1776
2415
|
visible: t.sessionBreaks.visible ?? !0,
|
|
1777
2416
|
color: t.sessionBreaks.color,
|
|
1778
2417
|
lineStyle: t.sessionBreaks.lineStyle,
|
|
1779
2418
|
lineWidth: t.sessionBreaks.lineWidth
|
|
1780
|
-
}) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new he(), this.crosshairTooltip = new ke(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new $e(), this.pinnedTooltip.create(e), this.pinnedTooltip.setLocale(this.numberLocale), t.priceFormat && this.applyPriceFormat(t.priceFormat), t.chartTypeOptions && (this.chartTypeOptions = ae(t.chartTypeOptions)), t.highLowLines && this.priceLines.setHighLow(!0), t.shapes && this.themeManager.setShape(
|
|
2419
|
+
}) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new he(), this.crosshairTooltip = new ke(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new $e(), this.pinnedTooltip.create(e), this.pinnedTooltip.setLocale(this.numberLocale), t.priceFormat && this.applyPriceFormat(t.priceFormat), t.chartTypeOptions && (this.chartTypeOptions = ae(t.chartTypeOptions)), t.highLowLines && this.priceLines.setHighLow(!0), t.shapes && this.themeManager.setShape(Mi(t.shapes)), t.font && this.themeManager.setFont(ji(t.font)), this.priceLines.setPriceText((e) => this.formatPrice(e)), t.extendedHours === !1 && (this.extendedHours = !1), t.timeFormatter && this.applyTimeFormatter(t.timeFormatter), this.keyboardHandler = new We({
|
|
1781
2420
|
scrollBars: (e) => {
|
|
1782
2421
|
let t = this.viewport.getState().barWidth + this.viewport.getState().barSpacing;
|
|
1783
2422
|
this.viewport.scrollBy(e * t), this.updateViewportAndRender();
|
|
@@ -1794,7 +2433,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
1794
2433
|
},
|
|
1795
2434
|
fitContent: () => this.fitContent()
|
|
1796
2435
|
}), this.keyboardHandler.setEnabled(this.features.keyboard), t.a11y !== !1) {
|
|
1797
|
-
this.a11y = new
|
|
2436
|
+
this.a11y = new on(e, {
|
|
1798
2437
|
symbol: () => this.currentSymbol || this.symbolInfo?.symbol || "",
|
|
1799
2438
|
timeframe: () => this.streamTimeframe ?? "",
|
|
1800
2439
|
chartType: () => this.options.chartType ?? "candlestick",
|
|
@@ -1825,8 +2464,8 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
1825
2464
|
}
|
|
1826
2465
|
this.keyboardHandler.handleKey(e) && (e.preventDefault(), this.a11y?.viewMoved());
|
|
1827
2466
|
}
|
|
1828
|
-
}, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new Ae(), this.currentPriceLine.setLocale(this.numberLocale), this.priceAxis.setReservedPriceProvider(() => this.currentPriceLine.isVisible() ? this.currentPriceLine.getPrice() : null), this.alertManager = new me(), this.alertManager.setDrawingLevels((e) => this.drawingLevelsNow(e)), this.alertManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.compareRenderer.setReservedLevels(() => this.alertManager.getAlerts().filter(
|
|
1829
|
-
this.eventBus.emit("alertTriggered",
|
|
2467
|
+
}, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new Ae(), this.currentPriceLine.setLocale(this.numberLocale), this.priceAxis.setReservedPriceProvider(() => this.currentPriceLine.isVisible() ? this.currentPriceLine.getPrice() : null), this.alertManager = new me(), this.alertManager.setDrawingLevels((e) => this.drawingLevelsNow(e)), this.alertManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.drawingAlerts = new fi(this.alertManager), this.compareRenderer.setReservedLevels(() => this.alertManager.getAlerts().filter(Pt).map((e) => e.price)), this.alertManager.on("triggered", (e) => {
|
|
2468
|
+
this.eventBus.emit("alertTriggered", X(e)), this.eventBus.emit("dataUpdate", {
|
|
1830
2469
|
kind: "alert",
|
|
1831
2470
|
alert: "triggered",
|
|
1832
2471
|
alertId: e.id,
|
|
@@ -1834,14 +2473,14 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
1834
2473
|
message: e.message
|
|
1835
2474
|
});
|
|
1836
2475
|
}), this.alertManager.on("added", (e) => {
|
|
1837
|
-
this.eventBus.emit("alertAdd",
|
|
2476
|
+
this.eventBus.emit("alertAdd", X(e));
|
|
1838
2477
|
}), this.alertManager.on("removed", (e) => {
|
|
1839
2478
|
this.eventBus.emit("alertRemove", { id: e });
|
|
1840
2479
|
}), this.alertManager.on("expired", (e) => {
|
|
1841
|
-
this.eventBus.emit("alertExpired",
|
|
2480
|
+
this.eventBus.emit("alertExpired", X(e));
|
|
1842
2481
|
}), this.alertManager.on("updated", (e) => {
|
|
1843
|
-
this.eventBus.emit("alertUpdate",
|
|
1844
|
-
}), this.signalMarkerManager = new
|
|
2482
|
+
this.eventBus.emit("alertUpdate", X(e));
|
|
2483
|
+
}), this.signalMarkerManager = new ht(), this.signalMarkerManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.signalMarkerManager.setDataGetter(() => this.series.bars()), this.signalMarkerManager.on("added", (e) => {
|
|
1845
2484
|
this.eventBus.emit("signalMarkerAdd", {
|
|
1846
2485
|
id: e.id,
|
|
1847
2486
|
source: e.source,
|
|
@@ -1849,7 +2488,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
1849
2488
|
});
|
|
1850
2489
|
}), this.signalMarkerManager.on("removed", (e) => {
|
|
1851
2490
|
this.eventBus.emit("signalMarkerRemove", { id: e });
|
|
1852
|
-
}), this.tradeZoneManager = new
|
|
2491
|
+
}), this.tradeZoneManager = new xt(), this.tradeZoneManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradeZoneManager.setDataGetter(() => this.series.bars()), this.tradeZoneManager.on("added", (e) => {
|
|
1853
2492
|
this.eventBus.emit("tradeZoneAdd", {
|
|
1854
2493
|
id: e.id,
|
|
1855
2494
|
direction: e.direction
|
|
@@ -1865,20 +2504,20 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
1865
2504
|
}), this.replayManager.on("stateChange", (e) => {
|
|
1866
2505
|
this.replayRestarting || this.eventBus.emit("replayState", { state: e });
|
|
1867
2506
|
}), this.measureOverlay = new Je(), this.interactionManager = new He(e), this.features.panning) {
|
|
1868
|
-
let e = new
|
|
2507
|
+
let e = new jr();
|
|
1869
2508
|
this.interactionManager.setPanHandler(new Xe((t, n) => {
|
|
1870
|
-
t && this.viewport.scrollBy(t), e.step(t, n, this.
|
|
2509
|
+
t && this.viewport.scrollBy(t), e.step(t, n, this.priceFit.isAuto()) && n && (this.holdPriceScale(), this.viewport.panPriceRange(n)), this.updateViewportAndRender();
|
|
1871
2510
|
}, () => e.reset()));
|
|
1872
2511
|
}
|
|
1873
2512
|
if (this.interactionManager.setAxisStrips(() => ({
|
|
1874
2513
|
plot: this.viewport.getState().chartRect,
|
|
1875
|
-
timeAxisTop: this.timeAxisTop(),
|
|
2514
|
+
timeAxisTop: this.panes.timeAxisTop(),
|
|
1876
2515
|
left: {
|
|
1877
2516
|
width: this.isLeftPriceScaleShown() ? this.leftAxisWidth : 0,
|
|
1878
2517
|
scales: !this.indicatorEngine.hasLeftScaleOverlays()
|
|
1879
2518
|
}
|
|
1880
2519
|
})), this.features.zooming) {
|
|
1881
|
-
this.interactionManager.setZoomHandler(new
|
|
2520
|
+
this.interactionManager.setZoomHandler(new At((e, t) => {
|
|
1882
2521
|
this.viewport.zoom(e, t - this.viewport.getState().chartRect.x), this.updateViewportAndRender();
|
|
1883
2522
|
}));
|
|
1884
2523
|
let e = new _e((e) => {
|
|
@@ -1888,7 +2527,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
1888
2527
|
this.viewport.zoom(1 / e - 1, t / 2), this.updateViewportAndRender();
|
|
1889
2528
|
});
|
|
1890
2529
|
this.interactionManager.setAxisDragHandler(e, () => this.viewport.getState(), (e) => {
|
|
1891
|
-
e === "price" ? (this.
|
|
2530
|
+
e === "price" ? (this.priceFit.resume(), this.updateViewportAndRender()) : this.fitContent();
|
|
1892
2531
|
});
|
|
1893
2532
|
}
|
|
1894
2533
|
if (this.features.crosshair && this.interactionManager.setCrosshairHandler(this.crosshairHandler), this.features.drawings && (this.interactionManager.setDrawingManager(this.drawingManager, () => ({
|
|
@@ -1906,7 +2545,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
1906
2545
|
y: t.y
|
|
1907
2546
|
});
|
|
1908
2547
|
})), this.interactionManager.setChartContextMenu((e, t) => this.eventBus.hasListeners("chartContextMenu") ? (this.eventBus.emit("chartContextMenu", this.contextAt(e, t)), !0) : !1), this.applyPriceAxisAdd(), this.interactionManager.setPriceAxisAddButton(this.priceAxisAddButton, (e) => {
|
|
1909
|
-
let t =
|
|
2548
|
+
let t = Zt(e.y, this.viewport.getState());
|
|
1910
2549
|
Number.isFinite(t) && this.eventBus.emit("priceAxisAdd", {
|
|
1911
2550
|
price: t,
|
|
1912
2551
|
x: e.x,
|
|
@@ -1943,7 +2582,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
1943
2582
|
x: e.x,
|
|
1944
2583
|
y: e.y
|
|
1945
2584
|
}), t.length === 0) return;
|
|
1946
|
-
let r =
|
|
2585
|
+
let r = Xt(e.x, this.viewport.getState());
|
|
1947
2586
|
r < 0 || r >= t.length || this.eventBus.emit("barClick", {
|
|
1948
2587
|
bar: t[r],
|
|
1949
2588
|
barIndex: r,
|
|
@@ -1988,7 +2627,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
1988
2627
|
end: () => {
|
|
1989
2628
|
let e = this.selectionBoxOverlay.end();
|
|
1990
2629
|
if (e && this.zoomAreaMode) {
|
|
1991
|
-
if (e.x1 - e.x0 <
|
|
2630
|
+
if (e.x1 - e.x0 < Ci) return;
|
|
1992
2631
|
this.zoomToBox(e), this.setZoomAreaMode(!1);
|
|
1993
2632
|
return;
|
|
1994
2633
|
}
|
|
@@ -2023,10 +2662,8 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
2023
2662
|
this.loadDuringReplay(e);
|
|
2024
2663
|
return;
|
|
2025
2664
|
}
|
|
2026
|
-
this.snapshotKey = null, this.endReplaySession(), this.history.reset(), this.series.load(e), this.crosshairHandler.setData(this.series.bars()), this.
|
|
2027
|
-
let n = this.series.bars();
|
|
2028
|
-
this.seriesArriving = n.length === 0;
|
|
2029
|
-
let r = n[n.length - 1];
|
|
2665
|
+
this.snapshotKey = null, this.endReplaySession(), this.history.reset(), this.series.load(e), this.crosshairHandler.setData(this.series.bars()), this.display.reset(), this.sessionBreaks.invalidateCache(), this.priceFit.newSeries(this.series.length() === 0);
|
|
2666
|
+
let n = this.series.bars(), r = n[n.length - 1];
|
|
2030
2667
|
t || (this.alertManager.clearLastValues(), r && this.alertManager.seedLastValue("price", r.close)), this.recalcIndicators(n), r && this.currentPriceLine.setPrice(r.close), this.updateViewportAndRender(!0), this.fitFewColumns(), this.emitBars(n.length);
|
|
2031
2668
|
}
|
|
2032
2669
|
loadDuringReplay(e) {
|
|
@@ -2039,8 +2676,8 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
2039
2676
|
let t = this.getDisplayData(), n = Math.max(0, Math.min(t.length - 1, Math.floor(this.viewport.getState().visibleRange.from))), r = t[n]?.time, { added: i, taken: a } = this.series.prepend(e);
|
|
2040
2677
|
if (i === 0) return a;
|
|
2041
2678
|
let o = this.series.bars();
|
|
2042
|
-
if (this.crosshairHandler.setData(o), this.
|
|
2043
|
-
let e = Math.round(
|
|
2679
|
+
if (this.crosshairHandler.setData(o), this.display.reset(), this.sessionBreaks.invalidateCache(), this.pinnedTooltip.isPinned() && this.pinnedTooltip.unpin(), this.measureOverlay.end(), this.recalcIndicators(o), r !== void 0) {
|
|
2680
|
+
let e = Math.round(M(r, this.getDisplayData()));
|
|
2044
2681
|
this.viewport.prependBars(e - n);
|
|
2045
2682
|
}
|
|
2046
2683
|
return this.updateViewportAndRender(), a;
|
|
@@ -2052,7 +2689,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
2052
2689
|
return;
|
|
2053
2690
|
}
|
|
2054
2691
|
let n = this.series.bars();
|
|
2055
|
-
this.crosshairHandler.setData(n), this.
|
|
2692
|
+
this.crosshairHandler.setData(n), this.display.reset(), this.sessionBreaks.invalidateCache(), this.recalcIndicators(n), n.length > 0 && this.currentPriceLine.setPrice(n[n.length - 1].close), this.updateViewportAndRender(t), this.emitBars(n.length);
|
|
2056
2693
|
}
|
|
2057
2694
|
setHistoryLoader(e, t) {
|
|
2058
2695
|
this.historyFromStream = !1, this.hostHistoryLoader = e !== null, this.history.setLoader(e, t?.pageSize), this.checkHistory();
|
|
@@ -2068,16 +2705,16 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
2068
2705
|
}
|
|
2069
2706
|
checkHistory() {
|
|
2070
2707
|
this.historyCheckQueued || !this.history.hasLoader() || (this.historyCheckQueued = !0, queueMicrotask(() => {
|
|
2071
|
-
if (this.historyCheckQueued = !1, !this.replayPages() || !this.history.hasLoader() ||
|
|
2708
|
+
if (this.historyCheckQueued = !1, !this.replayPages() || !this.history.hasLoader() || I(this.options.chartType)) return;
|
|
2072
2709
|
let { visibleRange: e, chartRect: t } = this.viewport.getState();
|
|
2073
2710
|
if (t.width <= 0) return;
|
|
2074
2711
|
let { from: n, to: r } = e;
|
|
2075
|
-
this.history.maybeLoad(Math.max(0, Math.floor(n)), Math.max(
|
|
2712
|
+
this.history.maybeLoad(Math.max(0, Math.floor(n)), Math.max(Si, r - n));
|
|
2076
2713
|
}));
|
|
2077
2714
|
}
|
|
2078
2715
|
useStreamHistory(e, t, n = !0) {
|
|
2079
2716
|
if (this.hostHistoryLoader) return;
|
|
2080
|
-
let r =
|
|
2717
|
+
let r = N(e), i = r.fetchHistoryBefore, a = this.streamTimeframe;
|
|
2081
2718
|
if (!i || a === null || de(a) !== null) {
|
|
2082
2719
|
this.historyFromStream && this.history.setLoader(null), this.historyFromStream = !1;
|
|
2083
2720
|
return;
|
|
@@ -2088,33 +2725,31 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
2088
2725
|
appendBar(e) {
|
|
2089
2726
|
if (!R(e)) return;
|
|
2090
2727
|
let t = this.series.append(e);
|
|
2091
|
-
if (t.
|
|
2728
|
+
if (t.to !== "shown") {
|
|
2092
2729
|
this.takeLivePrice(e.close), t.to === "hidden" && this.scheduleRender();
|
|
2093
2730
|
return;
|
|
2094
2731
|
}
|
|
2095
2732
|
let n = this.autoScrollOnNewBar && this.viewport.isAtEnd(), r = t.before, i = this.series.bars();
|
|
2096
|
-
this.crosshairHandler.setData(i), this.
|
|
2733
|
+
this.crosshairHandler.setData(i), this.recalcIndicatorsFrom(i, i.length - 2), this.currentPriceLine.setPrice(e.close, i[i.length - 2]?.close), this.updateViewportAndRender(n), i.length !== r && this.emitBars(i.length), this.followLivePrice(e.close);
|
|
2097
2734
|
}
|
|
2098
2735
|
appendBars(e) {
|
|
2099
2736
|
if (e = e.filter(R), e.length === 0) return;
|
|
2100
2737
|
let t = e[e.length - 1].close, n = this.series.appendMany(e);
|
|
2101
|
-
if (n.
|
|
2738
|
+
if (n.shown === 0) {
|
|
2102
2739
|
this.takeLivePrice(t), n.aside || this.scheduleRender();
|
|
2103
2740
|
return;
|
|
2104
2741
|
}
|
|
2105
|
-
let r = this.autoScrollOnNewBar && this.viewport.isAtEnd(), i = n.before;
|
|
2106
|
-
this.displayDataCache = null;
|
|
2107
|
-
let a = this.series.bars();
|
|
2742
|
+
let r = this.autoScrollOnNewBar && this.viewport.isAtEnd(), i = n.before, a = this.series.bars();
|
|
2108
2743
|
this.recalcIndicatorsFrom(a, i - 1), this.crosshairHandler.setData(a), this.currentPriceLine.setPrice(t, a[a.length - 2]?.close), this.updateViewportAndRender(r), a.length !== i && this.emitBars(a.length), this.followLivePrice(t);
|
|
2109
2744
|
}
|
|
2110
2745
|
updateLastBar(e) {
|
|
2111
2746
|
if (!R(e)) return;
|
|
2112
2747
|
let t = this.series.updateLast(e);
|
|
2113
|
-
if (t.
|
|
2748
|
+
if (t.to !== "shown") {
|
|
2114
2749
|
this.takeLivePrice(e.close), t.to === "hidden" && this.scheduleRender();
|
|
2115
2750
|
return;
|
|
2116
2751
|
}
|
|
2117
|
-
this.currentPriceLine.setPrice(e.close)
|
|
2752
|
+
this.currentPriceLine.setPrice(e.close);
|
|
2118
2753
|
let n = this.series.bars();
|
|
2119
2754
|
this.recalcIndicatorsFrom(n, n.length - 1), this.followLivePrice(e.close), this.scheduleRender();
|
|
2120
2755
|
}
|
|
@@ -2125,7 +2760,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
2125
2760
|
this.takeLivePrice(e.price), t.to === "hidden" && this.scheduleRender();
|
|
2126
2761
|
return;
|
|
2127
2762
|
}
|
|
2128
|
-
this.currentPriceLine.setPrice(e.price)
|
|
2763
|
+
this.currentPriceLine.setPrice(e.price);
|
|
2129
2764
|
let n = this.series.bars();
|
|
2130
2765
|
this.recalcIndicatorsFrom(n, n.length - 1), this.followLivePrice(e.price), this.scheduleRender();
|
|
2131
2766
|
}
|
|
@@ -2136,7 +2771,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
2136
2771
|
}
|
|
2137
2772
|
showCorrection(e) {
|
|
2138
2773
|
let t = this.series.bars(), n = t[e];
|
|
2139
|
-
this.
|
|
2774
|
+
this.display.reset(), this.indicatorEngine.deferRecalculateFrom(t, e), this.announceIndicatorUpdate(e), e === t.length - 1 && (this.currentPriceLine.setPrice(n.close, t[e - 1]?.close), this.alertManager.seedLastValue("price", n.close)), this.refreshShownBar(e), this.eventBus.emit("dataUpdate", {
|
|
2140
2775
|
kind: "correction",
|
|
2141
2776
|
time: n.time,
|
|
2142
2777
|
index: e
|
|
@@ -2157,26 +2792,26 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
2157
2792
|
}
|
|
2158
2793
|
setChartType(e) {
|
|
2159
2794
|
let t = this.options.chartType ?? "candlestick";
|
|
2160
|
-
this.options.chartType = e, this.themeManager.setChartType(e), this.chartRenderer = this.createChartRenderer(e), this.
|
|
2795
|
+
this.options.chartType = e, this.themeManager.setChartType(e), this.chartRenderer = this.createChartRenderer(e), this.display.invalidate(), this.chartLegend.setChartType(e), this.applyTimeSpacing(), this.updateViewportAndRender(!0), this.fitFewColumns(), this.markStateChanged(), e !== t && this.eventBus.emit("chartTypeChange", {
|
|
2161
2796
|
type: e,
|
|
2162
2797
|
previous: t
|
|
2163
2798
|
});
|
|
2164
2799
|
}
|
|
2165
2800
|
fitFewColumns() {
|
|
2166
2801
|
let e = this.options.chartType;
|
|
2167
|
-
if (!
|
|
2802
|
+
if (!I(e) || this.pluginManager.getChartType(e)) return;
|
|
2168
2803
|
let t = this.getDisplayData().length, { chartRect: n, barWidth: r, barSpacing: i } = this.viewport.getState(), a = n.width / (r + i);
|
|
2169
2804
|
t > 0 && a > t + this.viewport.getRightMargin() && this.fitContent();
|
|
2170
2805
|
}
|
|
2171
2806
|
applyTimeSpacing() {
|
|
2172
|
-
let e = !this.tickStream && !
|
|
2807
|
+
let e = !this.tickStream && !I(this.options.chartType);
|
|
2173
2808
|
this.timeAxis.setTimesPastData(e), this.crosshairHandler.setTimesPastData(e);
|
|
2174
2809
|
}
|
|
2175
2810
|
setChartTypeOptions(e) {
|
|
2176
2811
|
this.chartTypeOptions = {
|
|
2177
2812
|
...this.chartTypeOptions,
|
|
2178
2813
|
...ae(e)
|
|
2179
|
-
}, this.
|
|
2814
|
+
}, this.updateViewportAndRender(!0), this.fitFewColumns(), this.a11y?.refresh(!0), this.markStateChanged();
|
|
2180
2815
|
}
|
|
2181
2816
|
getChartTypeOptions() {
|
|
2182
2817
|
return ae(this.chartTypeOptions);
|
|
@@ -2188,18 +2823,18 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
2188
2823
|
return this.extendedHours;
|
|
2189
2824
|
}
|
|
2190
2825
|
sessionKeep(e) {
|
|
2191
|
-
return this.extendedHours ? null :
|
|
2826
|
+
return this.extendedHours ? null : en(this.symbolInfo, e);
|
|
2192
2827
|
}
|
|
2193
2828
|
reapplyExtendedHours() {
|
|
2194
2829
|
if (!this.series.refilter()) return;
|
|
2195
2830
|
let e = this.series.bars();
|
|
2196
|
-
this.crosshairHandler.setData(e), this.
|
|
2831
|
+
this.crosshairHandler.setData(e), this.display.reset(), this.sessionBreaks.invalidateCache(), this.recalcIndicators(e), this.updateViewportAndRender(!0), this.emitBars(e.length);
|
|
2197
2832
|
}
|
|
2198
2833
|
quoteLines() {
|
|
2199
2834
|
return this.priceLines.setQuoteShown(this.replaySession === null), this.priceLines;
|
|
2200
2835
|
}
|
|
2201
2836
|
setShapes(e) {
|
|
2202
|
-
let t =
|
|
2837
|
+
let t = Mi(e);
|
|
2203
2838
|
t.tagRadius !== void 0 && (this.themeManager.setShape({
|
|
2204
2839
|
...this.themeManager.getTheme().shape,
|
|
2205
2840
|
...t
|
|
@@ -2211,7 +2846,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
2211
2846
|
setFont(e) {
|
|
2212
2847
|
if (e === null) this.themeManager.setFont(null);
|
|
2213
2848
|
else {
|
|
2214
|
-
let t =
|
|
2849
|
+
let t = ji(e);
|
|
2215
2850
|
if (Object.keys(t).length === 0) return;
|
|
2216
2851
|
this.themeManager.setFont(t);
|
|
2217
2852
|
}
|
|
@@ -2245,11 +2880,11 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
2245
2880
|
return this.priceLines.getBidAsk();
|
|
2246
2881
|
}
|
|
2247
2882
|
addIndicator(e, t, n = "bottom", r = {}) {
|
|
2248
|
-
return this.
|
|
2883
|
+
return this.indicatorHistory.record(void 0, () => this.addIndicatorNow(e, t ?? {}, n, r));
|
|
2249
2884
|
}
|
|
2250
2885
|
addIndicatorNow(e, t, n, r) {
|
|
2251
2886
|
if (!this.isIndicatorAllowed(e)) return null;
|
|
2252
|
-
let i = this.indicatorEngine.getAvailableIndicators().find((t) => t.id === e), a = i ? this.paneFor(i, t, r.pane) : null, o = this.indicatorEngine.addIndicator(e, t, this.indicatorBars(), {
|
|
2887
|
+
let i = this.indicatorEngine.getAvailableIndicators().find((t) => t.id === e), a = i ? this.indicatorPanes.paneFor(i, t, r.pane) : null, o = this.indicatorEngine.addIndicator(e, t, this.indicatorBars(), {
|
|
2253
2888
|
...a ? { pane: a } : {},
|
|
2254
2889
|
...r.scale === "left" ? { scale: "left" } : {},
|
|
2255
2890
|
...r.instanceId ? { instanceId: r.instanceId } : {}
|
|
@@ -2260,67 +2895,41 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
2260
2895
|
}), this.markStateChanged(), this.requestMissingSymbols(o), o;
|
|
2261
2896
|
}
|
|
2262
2897
|
setSymbolSeries(e, t) {
|
|
2263
|
-
e = e.trim(), this.symbolSeries.set(e, t), this.
|
|
2264
|
-
let n = this.
|
|
2265
|
-
|
|
2266
|
-
r
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
let e = new Set(this.getRequiredSymbols());
|
|
2270
|
-
for (let t of this.requestedSymbols) e.has(t) || this.requestedSymbols.delete(t);
|
|
2898
|
+
e = e.trim(), this.symbolSeries.set(e, t), this.symbolRequests.given(e);
|
|
2899
|
+
let n = this.symbolRequests.readersOf(e);
|
|
2900
|
+
if (n.length === 0) return;
|
|
2901
|
+
let r = this.indicatorBars();
|
|
2902
|
+
for (let e of n) this.indicatorEngine.updateIndicator(e, {}, r);
|
|
2903
|
+
this.announceIndicatorUpdate(0), this.updateViewportAndRender();
|
|
2271
2904
|
}
|
|
2272
2905
|
getSymbolSeries(e) {
|
|
2273
2906
|
return this.symbolSeries.get(e) ?? null;
|
|
2274
2907
|
}
|
|
2275
2908
|
getRequiredSymbols() {
|
|
2276
|
-
|
|
2277
|
-
for (let t of this.indicatorEngine.getActiveIndicators()) {
|
|
2278
|
-
let n = t.params.symbol;
|
|
2279
|
-
O.has(t.id) && typeof n == "string" && n.trim() && e.add(n.trim());
|
|
2280
|
-
}
|
|
2281
|
-
return [...e];
|
|
2909
|
+
return this.symbolRequests.required();
|
|
2282
2910
|
}
|
|
2283
2911
|
requestMissingSymbols(e) {
|
|
2284
|
-
this.
|
|
2285
|
-
|
|
2286
|
-
!n || this.symbolSeries.has(n) || this.requestedSymbols.has(n) || (this.requestedSymbols.add(n), this.eventBus.emit("symbolSeriesRequest", { symbol: n }));
|
|
2912
|
+
let t = this.symbolRequests.toAsk(e);
|
|
2913
|
+
t && this.eventBus.emit("symbolSeriesRequest", { symbol: t });
|
|
2287
2914
|
}
|
|
2288
2915
|
updateIndicator(e, t) {
|
|
2289
|
-
this.
|
|
2916
|
+
this.indicatorHistory.record(e, () => this.updateIndicatorNow(e, t));
|
|
2290
2917
|
}
|
|
2291
2918
|
updateIndicatorNow(e, t) {
|
|
2292
|
-
let n = this.
|
|
2919
|
+
let n = this.indicatorPanes.sourceOf(e);
|
|
2293
2920
|
this.indicatorEngine.updateIndicator(e, t, this.indicatorBars()), this.announceIndicatorUpdate(0), this.markStateChanged(), this.eventBus.emit("indicatorChange", {
|
|
2294
2921
|
instanceId: e,
|
|
2295
2922
|
change: "params"
|
|
2296
|
-
}), this.requestMissingSymbols(e)
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
(n ?? void 0) !== a.pane && (this.indicatorEngine.setPane(e, n), this.eventBus.emit("indicatorChange", {
|
|
2301
|
-
instanceId: e,
|
|
2302
|
-
change: "pane"
|
|
2303
|
-
}));
|
|
2304
|
-
}
|
|
2305
|
-
this.updateViewportAndRender();
|
|
2306
|
-
}
|
|
2307
|
-
paneFor(e, t, n, r) {
|
|
2308
|
-
if (n) return this.paneHostOf(n, r);
|
|
2309
|
-
if (e.placement !== "overlay") return null;
|
|
2310
|
-
let i = M(e), a = i ? x(t[i]) : null;
|
|
2311
|
-
return a ? this.paneHostOf(a.instanceId, r) : null;
|
|
2312
|
-
}
|
|
2313
|
-
paneHostOf(e, t) {
|
|
2314
|
-
if (e === t) return null;
|
|
2315
|
-
if (this.layoutManager.getPanels().some((t) => t.id === e)) return e;
|
|
2316
|
-
let n = this.indicatorEngine.getIndicatorConfig(e)?.pane;
|
|
2317
|
-
return n && n !== t ? n : null;
|
|
2923
|
+
}), this.requestMissingSymbols(e), this.indicatorPanes.followSource(e, n) && this.eventBus.emit("indicatorChange", {
|
|
2924
|
+
instanceId: e,
|
|
2925
|
+
change: "pane"
|
|
2926
|
+
}), this.updateViewportAndRender();
|
|
2318
2927
|
}
|
|
2319
2928
|
getIndicatorLevels(e) {
|
|
2320
2929
|
return this.indicatorEngine.getLevels(e);
|
|
2321
2930
|
}
|
|
2322
2931
|
setIndicatorScale(e, t) {
|
|
2323
|
-
return this.
|
|
2932
|
+
return this.indicatorHistory.record(e, () => this.setIndicatorScaleNow(e, t));
|
|
2324
2933
|
}
|
|
2325
2934
|
setIndicatorScaleNow(e, t) {
|
|
2326
2935
|
return this.indicatorEngine.setScale(e, t) ? (this.updateViewportAndRender(), this.markStateChanged(), this.eventBus.emit("indicatorChange", {
|
|
@@ -2353,8 +2962,8 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
2353
2962
|
return {
|
|
2354
2963
|
...e,
|
|
2355
2964
|
priceRange: {
|
|
2356
|
-
min: t.min - n *
|
|
2357
|
-
max: t.max + n *
|
|
2965
|
+
min: t.min - n * xi,
|
|
2966
|
+
max: t.max + n * xi
|
|
2358
2967
|
},
|
|
2359
2968
|
logScale: !1,
|
|
2360
2969
|
scaleMode: "regular",
|
|
@@ -2365,7 +2974,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
2365
2974
|
};
|
|
2366
2975
|
}
|
|
2367
2976
|
setIndicatorLevels(e, t) {
|
|
2368
|
-
this.
|
|
2977
|
+
this.indicatorHistory.record(e, () => this.setIndicatorLevelsNow(e, t));
|
|
2369
2978
|
}
|
|
2370
2979
|
setIndicatorLevelsNow(e, t) {
|
|
2371
2980
|
this.indicatorEngine.setLevels(e, t) && (this.updateViewportAndRender(), this.markStateChanged(), this.eventBus.emit("indicatorChange", {
|
|
@@ -2374,10 +2983,10 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
2374
2983
|
}));
|
|
2375
2984
|
}
|
|
2376
2985
|
removeIndicator(e) {
|
|
2377
|
-
this.
|
|
2986
|
+
this.indicatorHistory.record(void 0, () => this.removeIndicatorNow(e));
|
|
2378
2987
|
}
|
|
2379
2988
|
removeIndicators(e) {
|
|
2380
|
-
this.
|
|
2989
|
+
this.indicatorHistory.record(void 0, () => {
|
|
2381
2990
|
for (let t of e) this.removeIndicatorNow(t);
|
|
2382
2991
|
});
|
|
2383
2992
|
}
|
|
@@ -2388,16 +2997,10 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
2388
2997
|
this.markStateChanged(), this.updateViewportAndRender();
|
|
2389
2998
|
}
|
|
2390
2999
|
detachIndicator(e) {
|
|
2391
|
-
|
|
2392
|
-
let t = this.layoutManager.getPanels().find((t) => t.id === e), n = this.indicatorEngine.getPaneMembers(e), r = t ? n.find((e) => this.indicatorEngine.getIndicatorDescriptor(e)?.placement === "panel") ?? null : null;
|
|
2393
|
-
this.indicatorEngine.removeIndicator(e);
|
|
2394
|
-
let i = this.paneStyles.get(e);
|
|
2395
|
-
this.paneStyles.delete(e), r ? (this.indicatorEngine.setPane(r, null), this.renamePane(e, r), i && this.paneStyles.set(r, i)) : this.layoutManager.removePanel(e);
|
|
2396
|
-
for (let e of n) e !== r && this.indicatorEngine.setPane(e, r), this.eventBus.emit("indicatorChange", {
|
|
3000
|
+
this.indicatorPanes.detach(e, (e) => this.eventBus.emit("indicatorChange", {
|
|
2397
3001
|
instanceId: e,
|
|
2398
3002
|
change: "pane"
|
|
2399
|
-
});
|
|
2400
|
-
this.eventBus.emit("indicatorRemove", { instanceId: e }), this.forgetUnreadSymbols();
|
|
3003
|
+
})) && (this.eventBus.emit("indicatorRemove", { instanceId: e }), this.symbolRequests.forgetUnread());
|
|
2401
3004
|
}
|
|
2402
3005
|
getIndicatorStyle(e) {
|
|
2403
3006
|
return this.indicatorEngine.getIndicatorStyle(e);
|
|
@@ -2414,14 +3017,14 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
2414
3017
|
});
|
|
2415
3018
|
}
|
|
2416
3019
|
setPaneStyle(e, t) {
|
|
2417
|
-
let n = this.paneOf(e);
|
|
2418
|
-
this.layoutManager.getPanels().some((e) => e.id === n) && this.
|
|
3020
|
+
let n = this.indicatorPanes.paneOf(e);
|
|
3021
|
+
this.layoutManager.getPanels().some((e) => e.id === n) && this.indicatorHistory.record(n, () => this.setPaneStyleNow(n, t ? se(t) : null));
|
|
2419
3022
|
}
|
|
2420
3023
|
setPaneStyleNow(e, t) {
|
|
2421
|
-
|
|
3024
|
+
this.panes.setStyle(e, t) && (this.syncRenderContext(), this.engine.requestRender(), this.markStateChanged());
|
|
2422
3025
|
}
|
|
2423
3026
|
getPaneStyle(e) {
|
|
2424
|
-
let t = this.
|
|
3027
|
+
let t = this.panes.style(this.indicatorPanes.paneOf(e));
|
|
2425
3028
|
return t ? { ...t } : null;
|
|
2426
3029
|
}
|
|
2427
3030
|
getIndicatorOutput(e) {
|
|
@@ -2435,7 +3038,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
2435
3038
|
}
|
|
2436
3039
|
static indicators() {
|
|
2437
3040
|
let e = new Ve();
|
|
2438
|
-
return
|
|
3041
|
+
return Ht(e), e.getAvailableIndicators();
|
|
2439
3042
|
}
|
|
2440
3043
|
setPanelPosition(e, t) {
|
|
2441
3044
|
this.layoutManager.setPanelPosition(e, t), this.updateViewportAndRender(), this.eventBus.emit("indicatorChange", {
|
|
@@ -2450,96 +3053,52 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
2450
3053
|
}), this.markStateChanged();
|
|
2451
3054
|
}
|
|
2452
3055
|
moveIndicatorToPane(e, t) {
|
|
2453
|
-
return this.
|
|
3056
|
+
return this.indicatorHistory.record(e, () => this.moveIndicatorToPaneNow(e, t));
|
|
2454
3057
|
}
|
|
2455
3058
|
canMoveIndicatorToPane(e, t) {
|
|
2456
|
-
return this.
|
|
2457
|
-
}
|
|
2458
|
-
paneMoveHost(e, t) {
|
|
2459
|
-
let n = this.indicatorEngine.getIndicatorConfig(e), r = this.indicatorEngine.getIndicatorDescriptor(e);
|
|
2460
|
-
if (!n || !r) return;
|
|
2461
|
-
let i = M(r);
|
|
2462
|
-
if (r.placement === "overlay" && i && x(n.params[i])) return;
|
|
2463
|
-
if (t === "price") return r.placement === "overlay" && n.pane ? null : void 0;
|
|
2464
|
-
if (t === "new") {
|
|
2465
|
-
let t = this.layoutManager.getPanels().some((t) => t.id === e);
|
|
2466
|
-
return r.placement === "panel" && !t ? null : void 0;
|
|
2467
|
-
}
|
|
2468
|
-
let a = this.paneHostOf(t, e);
|
|
2469
|
-
return a && a !== n.pane && a !== e ? a : void 0;
|
|
3059
|
+
return this.indicatorPanes.moveHost(e, t) !== void 0;
|
|
2470
3060
|
}
|
|
2471
3061
|
moveIndicatorToPaneNow(e, t) {
|
|
2472
|
-
let n = this.
|
|
2473
|
-
if (n
|
|
2474
|
-
let
|
|
2475
|
-
if (a) {
|
|
2476
|
-
let t = this.indicatorEngine.getPaneMembers(e), r = new Set(this.indicatorEngine.getDependents(e)), i = t.filter((e) => !r.has(e)), a = i.find((e) => this.indicatorEngine.getIndicatorDescriptor(e)?.placement === "panel") ?? null, s = this.paneStyles.get(e);
|
|
2477
|
-
if (this.paneStyles.delete(e), a) {
|
|
2478
|
-
this.indicatorEngine.setPane(a, null), this.renamePane(e, a), s && this.paneStyles.set(a, s);
|
|
2479
|
-
for (let e of i) e !== a && this.indicatorEngine.setPane(e, a);
|
|
2480
|
-
} else {
|
|
2481
|
-
this.layoutManager.removePanel(e);
|
|
2482
|
-
for (let e of i) this.indicatorEngine.setPane(e, null);
|
|
2483
|
-
}
|
|
2484
|
-
this.panelInfoCache = null;
|
|
2485
|
-
for (let i of t) r.has(i) && this.indicatorEngine.setPane(i, n ?? e), o.add(i);
|
|
2486
|
-
}
|
|
2487
|
-
if (this.indicatorEngine.setPane(e, n), t === "new") {
|
|
2488
|
-
this.layoutManager.addPanel(e, "bottom");
|
|
2489
|
-
for (let t of this.indicatorEngine.getDependents(e)) this.indicatorEngine.getIndicatorConfig(t)?.pane === i && (this.indicatorEngine.setPane(t, e), o.add(t));
|
|
2490
|
-
}
|
|
2491
|
-
for (let e of o) this.eventBus.emit("indicatorChange", {
|
|
3062
|
+
let n = this.indicatorPanes.move(e, t);
|
|
3063
|
+
if (!n) return !1;
|
|
3064
|
+
for (let e of n) this.eventBus.emit("indicatorChange", {
|
|
2492
3065
|
instanceId: e,
|
|
2493
3066
|
change: "pane"
|
|
2494
3067
|
});
|
|
2495
3068
|
return this.updateViewportAndRender(), this.markStateChanged(), !0;
|
|
2496
3069
|
}
|
|
2497
3070
|
setPaneCollapsed(e, t) {
|
|
2498
|
-
let n = this.paneOf(e);
|
|
2499
|
-
return this.
|
|
3071
|
+
let n = this.indicatorPanes.paneOf(e);
|
|
3072
|
+
return this.indicatorHistory.record(n, () => this.paneChange(n, "collapsed", () => this.layoutManager.setPanelCollapsed(n, t)));
|
|
2500
3073
|
}
|
|
2501
3074
|
isPaneCollapsed(e) {
|
|
2502
|
-
return this.layoutManager.isPanelShownCollapsed(this.paneOf(e));
|
|
3075
|
+
return this.layoutManager.isPanelShownCollapsed(this.indicatorPanes.paneOf(e));
|
|
2503
3076
|
}
|
|
2504
3077
|
setMaximizedPane(e) {
|
|
2505
|
-
let t = e === null ? null : this.paneOf(e), n = t ?? this.layoutManager.getMaximizedPanel() ?? "";
|
|
2506
|
-
return this.
|
|
3078
|
+
let t = e === null ? null : this.indicatorPanes.paneOf(e), n = t ?? this.layoutManager.getMaximizedPanel() ?? "";
|
|
3079
|
+
return this.indicatorHistory.record(n, () => this.paneChange(n, "maximized", () => this.layoutManager.setMaximizedPanel(t)));
|
|
2507
3080
|
}
|
|
2508
3081
|
getMaximizedPane() {
|
|
2509
3082
|
return this.layoutManager.getMaximizedPanel();
|
|
2510
3083
|
}
|
|
2511
3084
|
setPaneScale(e, t) {
|
|
2512
|
-
let n = this.paneOf(e);
|
|
2513
|
-
return this.
|
|
3085
|
+
let n = this.indicatorPanes.paneOf(e);
|
|
3086
|
+
return this.indicatorHistory.record(n, () => this.paneChange(n, "scale", () => this.layoutManager.setPanelScale(n, t)));
|
|
2514
3087
|
}
|
|
2515
3088
|
getPaneScale(e) {
|
|
2516
|
-
let t = this.layoutManager.getPanels().find((t) => t.id === this.paneOf(e));
|
|
3089
|
+
let t = this.layoutManager.getPanels().find((t) => t.id === this.indicatorPanes.paneOf(e));
|
|
2517
3090
|
return {
|
|
2518
3091
|
log: !!t?.logScale,
|
|
2519
3092
|
invert: !!t?.invertScale,
|
|
2520
3093
|
percent: !!t?.percentScale
|
|
2521
3094
|
};
|
|
2522
3095
|
}
|
|
2523
|
-
paneBaseline(e, t, n) {
|
|
2524
|
-
let r = this.indicatorEngine.getOutput(e)?.series, i = this.indicatorEngine.getIndicatorDescriptor(e);
|
|
2525
|
-
if (!r || !i) return;
|
|
2526
|
-
let a = i.plots?.[0]?.key;
|
|
2527
|
-
for (let e = Math.max(0, t); e <= n && e < r.length; e++) {
|
|
2528
|
-
let t = r[e];
|
|
2529
|
-
if (!t) continue;
|
|
2530
|
-
let n = a === void 0 ? Object.values(t).find((e) => typeof e == "number" && Number.isFinite(e)) : t[a];
|
|
2531
|
-
if (typeof n == "number" && Number.isFinite(n) && n !== 0) return n;
|
|
2532
|
-
}
|
|
2533
|
-
}
|
|
2534
3096
|
movePane(e, t) {
|
|
2535
|
-
let n = this.paneOf(e);
|
|
2536
|
-
return this.
|
|
3097
|
+
let n = this.indicatorPanes.paneOf(e);
|
|
3098
|
+
return this.indicatorHistory.record(n, () => this.paneChange(n, "order", () => this.layoutManager.movePanel(n, t)));
|
|
2537
3099
|
}
|
|
2538
3100
|
canMovePane(e, t) {
|
|
2539
|
-
return this.layoutManager.canMovePanel(this.paneOf(e), t);
|
|
2540
|
-
}
|
|
2541
|
-
paneOf(e) {
|
|
2542
|
-
return this.indicatorEngine.getIndicatorConfig(e)?.pane ?? e;
|
|
3101
|
+
return this.layoutManager.canMovePanel(this.indicatorPanes.paneOf(e), t);
|
|
2543
3102
|
}
|
|
2544
3103
|
paneChange(e, t, n) {
|
|
2545
3104
|
return n() ? (this.updateViewportAndRender(), this.eventBus.emit("paneChange", {
|
|
@@ -2594,7 +3153,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
2594
3153
|
}), n;
|
|
2595
3154
|
}
|
|
2596
3155
|
isTimeAligned() {
|
|
2597
|
-
return
|
|
3156
|
+
return I(this.options.chartType) ? !1 : this.getDisplayData().length === this.series.length();
|
|
2598
3157
|
}
|
|
2599
3158
|
roundPrice(e) {
|
|
2600
3159
|
if (!Number.isFinite(e)) return e;
|
|
@@ -2683,7 +3242,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
2683
3242
|
}
|
|
2684
3243
|
autoFib() {
|
|
2685
3244
|
if (!this.features.drawings) return null;
|
|
2686
|
-
let e = this.getDisplayData(), t = this.viewport.getState(), n =
|
|
3245
|
+
let e = this.getDisplayData(), t = this.viewport.getState(), n = Mt(e, t.visibleRange.from, t.visibleRange.to);
|
|
2687
3246
|
return n ? this.addDrawing({
|
|
2688
3247
|
type: "fibRetracement",
|
|
2689
3248
|
anchors: [n[0], n[1]]
|
|
@@ -2696,9 +3255,9 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
2696
3255
|
return this.drawingManager.removeDrawings(e);
|
|
2697
3256
|
}
|
|
2698
3257
|
nudgeSelectedDrawings(e) {
|
|
2699
|
-
let t =
|
|
3258
|
+
let t = Ti[e.key];
|
|
2700
3259
|
if (!t || !this.features.drawings || e.ctrlKey || e.metaKey || e.altKey) return !1;
|
|
2701
|
-
let n = e.shiftKey ?
|
|
3260
|
+
let n = e.shiftKey ? wi : 1, r = {
|
|
2702
3261
|
...this.viewport.getState(),
|
|
2703
3262
|
data: this.getDisplayData()
|
|
2704
3263
|
};
|
|
@@ -2792,7 +3351,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
2792
3351
|
recordUndo(e) {
|
|
2793
3352
|
if (!this.features.drawingUndoRedo || typeof e?.undo != "function" || typeof e.redo != "function") return;
|
|
2794
3353
|
let t = performance.now(), n = this.undoRedoManager.last();
|
|
2795
|
-
if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at <
|
|
3354
|
+
if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at < 800) {
|
|
2796
3355
|
this.undoRedoManager.replaceLast({
|
|
2797
3356
|
...n,
|
|
2798
3357
|
custom: {
|
|
@@ -2839,7 +3398,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
2839
3398
|
x: t.x,
|
|
2840
3399
|
y: t.y
|
|
2841
3400
|
};
|
|
2842
|
-
if ((e === "plot" || e === "priceAxis") && (r.price =
|
|
3401
|
+
if ((e === "plot" || e === "priceAxis") && (r.price = Zt(t.y, n)), (e === "plot" || e === "timeAxis") && n.data.length > 0 && (r.time = P(t.x, n)), e === "pane") {
|
|
2843
3402
|
let e = this.getIndicatorPanes().find((e) => t.y >= e.rect.y && t.y <= e.rect.y + e.rect.height);
|
|
2844
3403
|
e && (r.pane = e.instanceId);
|
|
2845
3404
|
}
|
|
@@ -2869,7 +3428,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
2869
3428
|
...this.viewport.getState(),
|
|
2870
3429
|
data: this.getDisplayData()
|
|
2871
3430
|
};
|
|
2872
|
-
this.setVisibleRange(
|
|
3431
|
+
this.setVisibleRange(P(e.x0, t), P(e.x1, t));
|
|
2873
3432
|
}
|
|
2874
3433
|
lockAllDrawings() {
|
|
2875
3434
|
this.drawingManager.lockAllDrawings();
|
|
@@ -2914,7 +3473,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
2914
3473
|
for (let e of this.indicatorEngine.getActiveIndicators()) {
|
|
2915
3474
|
let t = this.indicatorEngine.getOutput(e.instanceId)?.series;
|
|
2916
3475
|
if (!t) continue;
|
|
2917
|
-
let r =
|
|
3476
|
+
let r = dn(e.id, e.params, e.descriptor.defaultConfig, e.descriptor.shortName), o = e.descriptor.plots ?? Object.keys(t.find((e) => e) ?? {}).map((e) => ({
|
|
2918
3477
|
key: e,
|
|
2919
3478
|
title: e
|
|
2920
3479
|
}));
|
|
@@ -2973,7 +3532,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
2973
3532
|
return this.indicatorEngine.getActiveIndicators();
|
|
2974
3533
|
}
|
|
2975
3534
|
setIndicatorVisible(e, t) {
|
|
2976
|
-
this.
|
|
3535
|
+
this.indicatorHistory.record(e, () => this.setIndicatorVisibleNow(e, t));
|
|
2977
3536
|
}
|
|
2978
3537
|
setIndicatorVisibleNow(e, t) {
|
|
2979
3538
|
this.indicatorEngine.setVisible(e, t) !== null && (this.updateViewportAndRender(), this.markStateChanged(), this.eventBus.emit("indicatorChange", {
|
|
@@ -2982,7 +3541,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
2982
3541
|
}));
|
|
2983
3542
|
}
|
|
2984
3543
|
setIndicatorIntervals(e, t) {
|
|
2985
|
-
this.
|
|
3544
|
+
this.indicatorHistory.record(e, () => this.setIndicatorIntervalsNow(e, t));
|
|
2986
3545
|
}
|
|
2987
3546
|
setIndicatorIntervalsNow(e, t) {
|
|
2988
3547
|
this.indicatorEngine.setIntervals(e, t) && (this.updateViewportAndRender(), this.markStateChanged(), this.eventBus.emit("indicatorChange", {
|
|
@@ -3001,7 +3560,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
3001
3560
|
} : null;
|
|
3002
3561
|
}
|
|
3003
3562
|
updateIndicatorStyle(e, t) {
|
|
3004
|
-
this.
|
|
3563
|
+
this.indicatorHistory.record(e, () => this.updateIndicatorStyleNow(e, t));
|
|
3005
3564
|
}
|
|
3006
3565
|
updateIndicatorStyleNow(e, t) {
|
|
3007
3566
|
let { plots: n, ...r } = t, i = n === void 0 ? void 0 : oe(n);
|
|
@@ -3104,21 +3663,12 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
3104
3663
|
this.replayTrades() || this.tradingManager.setCurrentPrice(e), this.features.alerts && this.checkAlerts(e);
|
|
3105
3664
|
}
|
|
3106
3665
|
checkAlerts(e) {
|
|
3107
|
-
let t = this.replaySession ? this.series.liveBars() : this.series.bars();
|
|
3108
|
-
this.alertManager
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
if (this.series.length() === 0) return;
|
|
3114
|
-
let t = this.alertManager.getAlerts().flatMap((e) => e.target ? [e.channel, e.target] : [e.channel]);
|
|
3115
|
-
for (let n of t) {
|
|
3116
|
-
if (e.has(n)) continue;
|
|
3117
|
-
let t = n.indexOf(":");
|
|
3118
|
-
if (t < 0) continue;
|
|
3119
|
-
let r = this.indicatorEngine.getOutput(n.slice(0, t))?.series, i = r?.[r.length - 1]?.[n.slice(t + 1)];
|
|
3120
|
-
typeof i == "number" && Number.isFinite(i) && e.set(n, i);
|
|
3121
|
-
}
|
|
3666
|
+
let t = this.replaySession ? this.series.liveBars() : this.series.bars(), n = this.replaySession || this.series.length() === 0 ? null : (e) => this.indicatorEngine.getOutput(e)?.series;
|
|
3667
|
+
oi(this.alertManager, {
|
|
3668
|
+
price: e,
|
|
3669
|
+
barTime: t.length > 0 ? t[t.length - 1].time : null,
|
|
3670
|
+
lines: n
|
|
3671
|
+
});
|
|
3122
3672
|
}
|
|
3123
3673
|
setTradingConfig(e) {
|
|
3124
3674
|
this.features.trading && this.tradingManager.setConfig(e);
|
|
@@ -3126,29 +3676,29 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
3126
3676
|
async connect(e) {
|
|
3127
3677
|
let t = {
|
|
3128
3678
|
...e,
|
|
3129
|
-
adapter:
|
|
3679
|
+
adapter: Ut(e),
|
|
3130
3680
|
feed: void 0
|
|
3131
3681
|
};
|
|
3132
|
-
if (!
|
|
3133
|
-
this.snapshotKey = null, this.holdReplayFor(t.symbol), this.disconnectStream(), this.streamManager = new
|
|
3682
|
+
if (!A(t.adapter, t.timeframe)) throw RangeError(`${t.adapter.name} cannot serve the ${t.timeframe} timeframe`);
|
|
3683
|
+
this.snapshotKey = null, this.holdReplayFor(t.symbol), this.disconnectStream(), this.streamManager = new vt(), this.streamManager.setTimeZone(this.studyZoneHeld ? this.studyZone : this.getExchangeTimeZone()), this.streamManager.on("snapshot", (e) => {
|
|
3134
3684
|
let n = this.streamSeriesKey(t.adapter);
|
|
3135
3685
|
n === this.snapshotKey && this.replaySession ? this.series.mergeSnapshot(e) : n === this.snapshotKey && this.series.length() > 0 ? this.mergeSnapshot(e) : (this.replaySession && this.useStreamHistory(t.adapter, t.historyPageSize, !1), this.setData(e)), this.snapshotKey = n, this.useStreamHistory(t.adapter, t.historyPageSize);
|
|
3136
3686
|
}), this.streamManager.on("barClose", (e) => {
|
|
3137
3687
|
if (!R(e)) return;
|
|
3138
3688
|
let t = this.series.placeStreamBar(e);
|
|
3139
|
-
if (t.
|
|
3689
|
+
if (t.to === "none") {
|
|
3140
3690
|
this.updateBar(e);
|
|
3141
3691
|
return;
|
|
3142
3692
|
}
|
|
3143
3693
|
if (t.to === "aside" && this.followLivePrice(e.close), t.to !== "shown") return;
|
|
3144
3694
|
let n = this.autoScrollOnNewBar && this.viewport.isAtEnd(), r = t.before, i = this.series.bars();
|
|
3145
|
-
this.crosshairHandler.setData(i), this.
|
|
3695
|
+
this.crosshairHandler.setData(i), this.recalcIndicatorsFrom(i, i.length - 2), this.updateViewportAndRender(n), i.length !== r && this.emitBars(i.length), this.followLivePrice(e.close);
|
|
3146
3696
|
}), this.streamManager.on("barCorrection", (e) => {
|
|
3147
3697
|
this.updateBar(e);
|
|
3148
3698
|
}), this.streamManager.on("barUpdate", (e) => {
|
|
3149
3699
|
if (!R(e)) return;
|
|
3150
3700
|
let t = this.series.placeStreamBar(e);
|
|
3151
|
-
if (t.
|
|
3701
|
+
if (t.to === "none" || (this.replaySession || this.currentPriceLine.setPrice(e.close), this.replaySession)) return;
|
|
3152
3702
|
let n = t.before;
|
|
3153
3703
|
if (t.to !== "shown") {
|
|
3154
3704
|
this.scheduleRender();
|
|
@@ -3192,7 +3742,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
3192
3742
|
}, 1e3);
|
|
3193
3743
|
}
|
|
3194
3744
|
streamSeriesKey(e) {
|
|
3195
|
-
let t =
|
|
3745
|
+
let t = N(e), n = this.streamTimeframe, r = t instanceof ct && n !== null ? t.bucketFor(this.currentSymbol, n) : null;
|
|
3196
3746
|
return `${this.currentSymbol}|${n}|${r?.timeZone ?? ""}`;
|
|
3197
3747
|
}
|
|
3198
3748
|
setStreamTarget(e, t) {
|
|
@@ -3215,7 +3765,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
3215
3765
|
async switchStream(e, t) {
|
|
3216
3766
|
if (!this.streamManager) return;
|
|
3217
3767
|
let n = this.streamAdapter;
|
|
3218
|
-
if (n && !
|
|
3768
|
+
if (n && !A(n, t)) throw RangeError(`${n.name} cannot serve the ${t} timeframe`);
|
|
3219
3769
|
this.holdReplayFor(e), this.setStreamTarget(e, t), this.historyFromStream && this.history.setLoader(null), this.barCountdown.setTimeframeMs(w(t)), n && this.resolveStreamSymbol(n, e), await this.streamManager.switchTo(e, t);
|
|
3220
3770
|
}
|
|
3221
3771
|
isIndicatorAllowed(e) {
|
|
@@ -3235,7 +3785,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
3235
3785
|
}
|
|
3236
3786
|
connectExecution(e, t = {}) {
|
|
3237
3787
|
if (!this.features.trading) throw Error("connectExecution requires features.trading to be enabled");
|
|
3238
|
-
this.disconnectExecution(), this.executionAdapter = e, this.execTeardown =
|
|
3788
|
+
this.disconnectExecution(), this.executionAdapter = e, this.execTeardown = Vr(e, {
|
|
3239
3789
|
onIntent: (e, t) => {
|
|
3240
3790
|
let n = (e) => t(e.payload);
|
|
3241
3791
|
return this.eventBus.on(e, n), () => this.eventBus.off(e, n);
|
|
@@ -3311,14 +3861,6 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
3311
3861
|
comparesDrawn() {
|
|
3312
3862
|
return this.isTimeAligned();
|
|
3313
3863
|
}
|
|
3314
|
-
panesOffChartType() {
|
|
3315
|
-
let e = this.indicatorEngine.getActiveIndicators(), t = new Set(e.filter((e) => e.offChartType).map((e) => e.instanceId)), n = /* @__PURE__ */ new Set();
|
|
3316
|
-
for (let r of this.layoutManager.getPanels()) {
|
|
3317
|
-
let i = e.filter((e) => e.instanceId === r.id || e.pane === r.id);
|
|
3318
|
-
i.length > 0 && i.every((e) => t.has(e.instanceId)) && n.add(r.id);
|
|
3319
|
-
}
|
|
3320
|
-
return n;
|
|
3321
|
-
}
|
|
3322
3864
|
clearCompareSymbols() {
|
|
3323
3865
|
let e = this.compareRenderer.getSymbols().map((e) => e.id);
|
|
3324
3866
|
this.compareRenderer.clear(), this.updateViewportAndRender();
|
|
@@ -3368,18 +3910,18 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
3368
3910
|
goToTime(e) {
|
|
3369
3911
|
let t = this.getDisplayData();
|
|
3370
3912
|
if (t.length === 0 || !Number.isFinite(e)) return -1;
|
|
3371
|
-
let n = Math.max(0, Math.min(t.length - 1, Math.floor(
|
|
3913
|
+
let n = Math.max(0, Math.min(t.length - 1, Math.floor(M(e, t)))), r = this.viewport.getState(), i = n * (r.barWidth + r.barSpacing) + r.barWidth / 2 - r.chartRect.width / 2;
|
|
3372
3914
|
return this.viewport.scrollBy(i - r.offset), this.updateViewportAndRender(), n;
|
|
3373
3915
|
}
|
|
3374
3916
|
setVisibleRangePreset(e) {
|
|
3375
3917
|
let t = this.getDisplayData();
|
|
3376
3918
|
if (t.length === 0) return;
|
|
3377
|
-
let n = t.length - 1, r = u(t), i =
|
|
3919
|
+
let n = t.length - 1, r = u(t), i = zt(e, t[n].time * r, this.displayTz), a = i === null ? null : i / r;
|
|
3378
3920
|
if (a === null || a < t[0].time) {
|
|
3379
3921
|
this.fitContent();
|
|
3380
3922
|
return;
|
|
3381
3923
|
}
|
|
3382
|
-
let o =
|
|
3924
|
+
let o = M(a, t), s = Math.min(n, e === "YTD" ? Math.ceil(o) : Math.floor(o) + 1);
|
|
3383
3925
|
this.viewport.zoomToBarRange(s, n + this.viewport.getRightMargin()), this.viewport.scrollToEnd(), this.updateViewportAndRender();
|
|
3384
3926
|
}
|
|
3385
3927
|
scrollToEnd() {
|
|
@@ -3404,7 +3946,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
3404
3946
|
setVisibleRange(e, t) {
|
|
3405
3947
|
let n = this.getDisplayData();
|
|
3406
3948
|
if (n.length === 0) return;
|
|
3407
|
-
let r =
|
|
3949
|
+
let r = M(Math.min(e, t), n), i = M(Math.max(e, t), n);
|
|
3408
3950
|
this.viewport.zoomToBarRange(r, i), this.updateViewportAndRender();
|
|
3409
3951
|
}
|
|
3410
3952
|
suspend() {
|
|
@@ -3544,13 +4086,13 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
3544
4086
|
}), this.engine.requestRender(r.Background);
|
|
3545
4087
|
}
|
|
3546
4088
|
setAutoScale(e) {
|
|
3547
|
-
this.
|
|
4089
|
+
this.priceFit.setAuto(e, this.series.length() > 0), this.updateViewportAndRender();
|
|
3548
4090
|
}
|
|
3549
4091
|
holdPriceScale() {
|
|
3550
|
-
this.
|
|
4092
|
+
this.priceFit.hold();
|
|
3551
4093
|
}
|
|
3552
4094
|
isAutoScale() {
|
|
3553
|
-
return this.
|
|
4095
|
+
return this.priceFit.isAuto();
|
|
3554
4096
|
}
|
|
3555
4097
|
setCrosshairMode(e) {
|
|
3556
4098
|
this.crosshairHandler.setMode(e), this.engine.requestRender(r.Hover);
|
|
@@ -3562,7 +4104,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
3562
4104
|
e ? this.crosshairHandler.onPointerMove(e) : this.crosshairHandler.onPointerLeave(), this.engine.requestRender(r.Hover);
|
|
3563
4105
|
}
|
|
3564
4106
|
setCrosshairTime(e) {
|
|
3565
|
-
let t = this.getDisplayData(), n = e === null || t.length === 0 ? null : Math.floor(
|
|
4107
|
+
let t = this.getDisplayData(), n = e === null || t.length === 0 ? null : Math.floor(M(e, t));
|
|
3566
4108
|
n !== this.crosshairHandler.getSyncedSlot() && (this.crosshairHandler.setSyncedSlot(n), this.showSyncedBar(n), this.engine.requestRender(r.Hover));
|
|
3567
4109
|
}
|
|
3568
4110
|
showSyncedBar(e) {
|
|
@@ -3572,7 +4114,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
3572
4114
|
}
|
|
3573
4115
|
let t = this.crosshairSeries(), n = e >= 0 && e < t.length ? t[e] : void 0, r = n && e > 0 ? t[e - 1] : void 0;
|
|
3574
4116
|
this.crosshairHandler.getPosition() || this.chartLegend.setHoverBar(n ?? null, r ?? null);
|
|
3575
|
-
let i = n ?
|
|
4117
|
+
let i = n ? k(t)[e]?.time ?? n.time : void 0;
|
|
3576
4118
|
this.eventBus.emit("crosshairSync", {
|
|
3577
4119
|
barIndex: e,
|
|
3578
4120
|
...n ? { bar: n } : {},
|
|
@@ -3651,7 +4193,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
3651
4193
|
return this.periodLevels.getPeriod();
|
|
3652
4194
|
}
|
|
3653
4195
|
setTimeZone(e) {
|
|
3654
|
-
|
|
4196
|
+
yi(e), this.timeZoneSetting = e, this.applyTimeZone();
|
|
3655
4197
|
}
|
|
3656
4198
|
getTimeZone() {
|
|
3657
4199
|
return this.timeZoneSetting;
|
|
@@ -3687,7 +4229,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
3687
4229
|
this.indicatorEngine.setExchangeTimeZone(e, t.length > 0 ? t : void 0) && t.length > 0 && this.announceIndicatorUpdate(0);
|
|
3688
4230
|
}
|
|
3689
4231
|
holdStudyZone() {
|
|
3690
|
-
this.endStudyZoneWait(), this.studyZoneHeld = !0, this.studyZoneTimer = setTimeout(() => this.releaseStudyZone(),
|
|
4232
|
+
this.endStudyZoneWait(), this.studyZoneHeld = !0, this.studyZoneTimer = setTimeout(() => this.releaseStudyZone(), dt);
|
|
3691
4233
|
}
|
|
3692
4234
|
endStudyZoneWait() {
|
|
3693
4235
|
this.studyZoneReleaseQueued = !1, this.studyZoneTimer !== null && (clearTimeout(this.studyZoneTimer), this.studyZoneTimer = null);
|
|
@@ -3716,7 +4258,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
3716
4258
|
}
|
|
3717
4259
|
useSymbolInfo(e) {
|
|
3718
4260
|
let t = e && this.symbolInfo?.symbol === e.symbol ? C(this.symbolInfo) : void 0;
|
|
3719
|
-
this.symbolInfo = e ?
|
|
4261
|
+
this.symbolInfo = e ? bi({
|
|
3720
4262
|
...e,
|
|
3721
4263
|
sessions: e.sessions?.map((e) => ({ ...e }))
|
|
3722
4264
|
}, t) : null, this.chartLegend.setExchange(this.symbolInfo?.exchange ?? ""), this.engine.requestRender(r.Hover), this.priceAxis.setPriceTick(this.symbolInfo?.minTick ?? null), this.marketConfig?.pricePrecision === void 0 && this.applyPricePrecision(this.symbolInfo?.pricePrecision ?? null);
|
|
@@ -3741,7 +4283,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
3741
4283
|
if (!e || typeof e != "object") return;
|
|
3742
4284
|
let t = this.currentSymbol, n = (e) => !e || e.toUpperCase() === t.toUpperCase();
|
|
3743
4285
|
if (!n(e.symbol)) return;
|
|
3744
|
-
let r = this.symbolInfo && n(this.symbolInfo.symbol) ? this.symbolInfo : null, i =
|
|
4286
|
+
let r = this.symbolInfo && n(this.symbolInfo.symbol) ? this.symbolInfo : null, i = bi({
|
|
3745
4287
|
...r,
|
|
3746
4288
|
...e,
|
|
3747
4289
|
symbol: e.symbol || r?.symbol || t
|
|
@@ -3749,7 +4291,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
3749
4291
|
r && JSON.stringify(i) === JSON.stringify(r) || (this.symbolInfoSeq++, this.setSymbolInfo(i));
|
|
3750
4292
|
}
|
|
3751
4293
|
resolveStreamSymbol(e, t) {
|
|
3752
|
-
let n =
|
|
4294
|
+
let n = N(e), r = n.resolveSymbol?.bind(n);
|
|
3753
4295
|
if (this.symbolInfo && this.symbolInfo.symbol !== t ? (r ? this.holdStudyZone() : this.studyZoneHeld = !1, this.useSymbolInfo(null)) : r && this.studyZoneHeld && this.holdStudyZone(), !r) {
|
|
3754
4296
|
this.releaseStudyZone();
|
|
3755
4297
|
return;
|
|
@@ -3780,7 +4322,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
3780
4322
|
return this.sessionShading.isVisible();
|
|
3781
4323
|
}
|
|
3782
4324
|
setSessionShadingConfig(e) {
|
|
3783
|
-
this.hostSessionHours =
|
|
4325
|
+
this.hostSessionHours = Lt(this.hostSessionHours, e), this.sessionShading.replaceConfig(this.hostSessionHours), this.engine.requestRender(r.Background);
|
|
3784
4326
|
}
|
|
3785
4327
|
setTooltipVisible(e) {
|
|
3786
4328
|
e || this.crosshairTooltip.hide();
|
|
@@ -3802,11 +4344,11 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
3802
4344
|
return this.waitForGpu(null), e === "canvas" ? (this.applyRenderer(null), "canvas") : this.engine.getGpu() ? "webgl" : this.takeGpu(e, t, !0);
|
|
3803
4345
|
}
|
|
3804
4346
|
async takeGpu(e, t, n) {
|
|
3805
|
-
let { gpu: r, reason: i } = await
|
|
3806
|
-
return t !== this.rendererToken || this.disposed ? (r?.destroy(), this.getRenderer()) : i === "limit" ?
|
|
4347
|
+
let { gpu: r, reason: i } = await It(e);
|
|
4348
|
+
return t !== this.rendererToken || this.disposed ? (r?.destroy(), this.getRenderer()) : i === "limit" ? Nt() > 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());
|
|
3807
4349
|
}
|
|
3808
4350
|
waitForGpu(e) {
|
|
3809
|
-
this.stopWaitingForGpu?.(), this.stopWaitingForGpu = e ?
|
|
4351
|
+
this.stopWaitingForGpu?.(), this.stopWaitingForGpu = e ? Yt(e) : null;
|
|
3810
4352
|
}
|
|
3811
4353
|
getRenderer() {
|
|
3812
4354
|
return this.engine.getGpu() ? "webgl" : "canvas";
|
|
@@ -3828,7 +4370,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
3828
4370
|
this.engine.getGpu() && this.engine.renderNow();
|
|
3829
4371
|
}
|
|
3830
4372
|
screenshot(e) {
|
|
3831
|
-
this.features.screenshot && (this.freshFrame(),
|
|
4373
|
+
this.features.screenshot && (this.freshFrame(), O.download(this.container, e, this.themeManager.getTheme().background));
|
|
3832
4374
|
}
|
|
3833
4375
|
async copyScreenshot() {
|
|
3834
4376
|
if (!this.features.screenshot) return !1;
|
|
@@ -3836,7 +4378,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
3836
4378
|
if (!t?.write || !e) return !1;
|
|
3837
4379
|
try {
|
|
3838
4380
|
this.freshFrame();
|
|
3839
|
-
let n =
|
|
4381
|
+
let n = O.toBlob(this.container, this.themeManager.getTheme().background).then((e) => {
|
|
3840
4382
|
if (!e) throw Error("No chart image to copy");
|
|
3841
4383
|
return e;
|
|
3842
4384
|
});
|
|
@@ -3854,10 +4396,10 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
3854
4396
|
}
|
|
3855
4397
|
}
|
|
3856
4398
|
screenshotDataURL() {
|
|
3857
|
-
return this.features.screenshot ? (this.freshFrame(),
|
|
4399
|
+
return this.features.screenshot ? (this.freshFrame(), O.toDataURL(this.container, this.themeManager.getTheme().background)) : null;
|
|
3858
4400
|
}
|
|
3859
4401
|
async screenshotBlob() {
|
|
3860
|
-
return this.features.screenshot ? (this.freshFrame(),
|
|
4402
|
+
return this.features.screenshot ? (this.freshFrame(), O.toBlob(this.container, this.themeManager.getTheme().background)) : null;
|
|
3861
4403
|
}
|
|
3862
4404
|
addAlert(e, t = "crossing", n, r = "price", i, a = {}) {
|
|
3863
4405
|
if (!this.features.alerts) return null;
|
|
@@ -3910,19 +4452,10 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
3910
4452
|
return this.drawingManager.priceAt(e, t[t.length - 1].time, n);
|
|
3911
4453
|
}
|
|
3912
4454
|
followDrawingAlerts(e, t) {
|
|
3913
|
-
|
|
3914
|
-
if (e === "drawingRemove") {
|
|
3915
|
-
let e = this.alertManager.takeDrawingAlerts(t);
|
|
3916
|
-
e.length > 0 && this.removedDrawingAlerts.set(t, e);
|
|
3917
|
-
} else if (e === "drawingCreate") {
|
|
3918
|
-
let e = this.removedDrawingAlerts.get(t);
|
|
3919
|
-
if (!e) return;
|
|
3920
|
-
this.removedDrawingAlerts.delete(t), this.alertManager.restoreAlerts(e);
|
|
3921
|
-
}
|
|
3922
|
-
}
|
|
4455
|
+
!t || !this.drawingAlerts || (e === "drawingRemove" ? this.drawingAlerts.removed(t) : e === "drawingCreate" && this.drawingAlerts.created(t));
|
|
3923
4456
|
}
|
|
3924
4457
|
dropOrphanDrawingAlerts() {
|
|
3925
|
-
this.
|
|
4458
|
+
this.drawingAlerts && this.drawingAlerts.prune(new Set(this.drawingManager.getDrawings().map((e) => e.id))) > 0 && this.markStateChanged();
|
|
3926
4459
|
}
|
|
3927
4460
|
addDrawingAlert(e, t = {}) {
|
|
3928
4461
|
if (!this.canAddDrawingAlert(e)) return null;
|
|
@@ -3985,24 +4518,24 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
3985
4518
|
let t = this.replaySession ? this.replayOffset : 0;
|
|
3986
4519
|
if (!this.replaySession) {
|
|
3987
4520
|
if (this.series.length() === 0) return;
|
|
3988
|
-
this.series.beginReplay(), this.replaySession =
|
|
4521
|
+
this.series.beginReplay(), this.replaySession = Li(this.currentSymbol);
|
|
3989
4522
|
}
|
|
3990
4523
|
let n = this.replaySession, { steps: r, startTime: i, hideHistory: a, revealMarks: o, step: s, ...c } = e ?? {};
|
|
3991
4524
|
c.animate = c.animate === !0;
|
|
3992
4525
|
let l = this.series.inHoursShown(this.series.liveBars()), u = t > 0 && i === void 0 && a !== !1, d = c.startIndex;
|
|
3993
|
-
i !== void 0 && d === void 0 ? d =
|
|
4526
|
+
i !== void 0 && d === void 0 ? d = J(l, i) : u && d !== void 0 && (d += t);
|
|
3994
4527
|
let f = u ? t : a && d !== void 0 && d > 0 ? Math.min(Math.floor(d), l.length - 1) : 0, p = f > 0 ? l.slice(f) : l;
|
|
3995
4528
|
d !== void 0 && (c.startIndex = d - f), n.windowTime = f > 0 ? p[0]?.time ?? null : null, n.steps = r ?? null, n.stepsSymbol = this.currentSymbol, n.until = null, n.animate = c.animate, n.step = c.animate ? s ?? null : null, this.replayRevealMarks = o !== !1, this.useReplayLoader(n, !0);
|
|
3996
4529
|
let m = r ? this.replayStepsOver(n, p, !0) : null;
|
|
3997
|
-
this.
|
|
4530
|
+
this.priceFit.resume(), this.buildReplay(p, m, f);
|
|
3998
4531
|
let h = this.replayStepsSeries;
|
|
3999
|
-
h && c.startIndex !== void 0 && (c.startIndex =
|
|
4532
|
+
h && c.startIndex !== void 0 && (c.startIndex = Wi(h, p, c.startIndex));
|
|
4000
4533
|
let g = h ?? p, _ = g[Math.max(0, Math.min(Math.floor(Number(c.startIndex ?? 0)) || 0, g.length - 1))];
|
|
4001
4534
|
this.revealReplayMarks(this.replayRevealMarks ? _?.time ?? null : null), n.held && (n.held.state = c.paused ? "paused" : "playing", c.paused = !0), !c.paused && c.startIndex !== void 0 && c.startIndex >= 1 && this.replaySeek(c.startIndex - 1), this.replayManager.play(c);
|
|
4002
4535
|
}
|
|
4003
4536
|
buildReplay(e, t, n) {
|
|
4004
4537
|
let r = this.replaySession?.animate === !0, i = r ? null : t;
|
|
4005
|
-
this.replayPieces = r && t ?
|
|
4538
|
+
this.replayPieces = r && t ? qi(t, e) : null, this.replayForming = null, this.replayOffset = n, this.replayStepsSeries = i, this.replayCoarse = e;
|
|
4006
4539
|
let a = this.replayRestarting;
|
|
4007
4540
|
this.replayRestarting = !0;
|
|
4008
4541
|
try {
|
|
@@ -4016,7 +4549,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
4016
4549
|
let n = t, a = e[t];
|
|
4017
4550
|
if (i) {
|
|
4018
4551
|
let r = i[t];
|
|
4019
|
-
n = Q(e, r.time), c = c !== null && s === t - 1 && n === o - 1 && c ?
|
|
4552
|
+
n = Q(e, r.time), c = c !== null && s === t - 1 && n === o - 1 && c ? Yi(c, r) : Gi(e[n], i, t), a = Ki(i, e, t, n) ? e[n] : c;
|
|
4020
4553
|
}
|
|
4021
4554
|
let u = this.replayForming;
|
|
4022
4555
|
this.replayForming = null, s = t;
|
|
@@ -4028,7 +4561,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
4028
4561
|
} else this.series.showReplayed([...e.slice(0, n), a]), this.recalcIndicators(this.series.bars());
|
|
4029
4562
|
o = d, this.replayCause === "older" && (this.viewport.prependBars(d - h), m = !1), this.currentPriceLine.setPrice(a.close, n > 0 ? e[n - 1].close : void 0), this.crosshairHandler.setData(this.series.bars());
|
|
4030
4563
|
let g = l[t + 1]?.time ?? l[t].time + (t > 0 ? l[t].time - l[t - 1].time : 1);
|
|
4031
|
-
this.replaySession && (this.replaySession.until = g), this.replayRevealMarks && this.revealReplayMarks(g), this.
|
|
4564
|
+
this.replaySession && (this.replaySession.until = g), this.replayRevealMarks && this.revealReplayMarks(g), this.display.reset(), this.updateViewportAndRender(m), r ? this.feedReplayForming(e, t, u?.index === t ? u.path : this.replayPathOf(e, t), 1) : this.feedReplaySteps(l, t);
|
|
4032
4565
|
let _ = this.replayCause === null ? p ? "play" : "seek" : "series";
|
|
4033
4566
|
this.eventBus.emit("replayStep", {
|
|
4034
4567
|
barIndex: n,
|
|
@@ -4040,7 +4573,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
4040
4573
|
});
|
|
4041
4574
|
}), r && (this.replayPhaseUnsub = this.replayManager.on("phase", ({ index: t, fraction: n }) => {
|
|
4042
4575
|
if (!e[t] || this.series.length() !== o || o !== t && o !== t + 1) return;
|
|
4043
|
-
let r = this.replayForming?.index === t ? this.replayForming.path : this.replayPathOf(e, t), i =
|
|
4576
|
+
let r = this.replayForming?.index === t ? this.replayForming.path : this.replayPathOf(e, t), i = Ji() ? ni(r, n) : n, a = o === t, s = a && this.autoScrollOnNewBar && this.viewport.isAtEnd(), c = ti(r, i);
|
|
4044
4577
|
a ? this.series.appendReplayed(c) : this.series.updateReplayed(c), o = t + 1, this.replayForming = {
|
|
4045
4578
|
index: t,
|
|
4046
4579
|
path: r
|
|
@@ -4050,27 +4583,27 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
4050
4583
|
drawFormingBar(e, t, n, r) {
|
|
4051
4584
|
this.currentPriceLine.setPrice(e.close, t);
|
|
4052
4585
|
let i = this.series.bars();
|
|
4053
|
-
if (this.recalcIndicatorsFrom(i, i.length - 1),
|
|
4586
|
+
if (this.recalcIndicatorsFrom(i, i.length - 1), !n) {
|
|
4054
4587
|
this.scheduleRender();
|
|
4055
4588
|
return;
|
|
4056
4589
|
}
|
|
4057
|
-
this.crosshairHandler.setData(i), this.
|
|
4590
|
+
this.crosshairHandler.setData(i), this.display.reset(), this.updateViewportAndRender(r);
|
|
4058
4591
|
}
|
|
4059
4592
|
replayPathOf(e, t) {
|
|
4060
4593
|
let n = e[t];
|
|
4061
|
-
return
|
|
4594
|
+
return Xr(n, this.replayPieces?.get(n.time) ?? this.replayLoader?.loader.piecesOf(n.time) ?? []);
|
|
4062
4595
|
}
|
|
4063
4596
|
loadReplaySteps(e, t) {
|
|
4064
4597
|
let n = this.replayLoader?.loader;
|
|
4065
4598
|
if (!n) return;
|
|
4066
4599
|
n.evictBefore(e[t].time);
|
|
4067
4600
|
let r = this.replayManager.getStepMs();
|
|
4068
|
-
n.ensure(e, t, Number.isFinite(r) && r > 0 ? Math.ceil(
|
|
4601
|
+
n.ensure(e, t, Number.isFinite(r) && r > 0 ? Math.ceil(Ni / r) : 1);
|
|
4069
4602
|
}
|
|
4070
4603
|
useReplayLoader(e, t) {
|
|
4071
|
-
let n = this.streamAdapter, r = this.streamTimeframe, i = e.step && n && r !== null ?
|
|
4604
|
+
let n = this.streamAdapter, r = this.streamTimeframe, i = e.step && n && r !== null ? ai(e.step, r, (e) => A(n, e)) : null, a = `${this.currentSymbol}|${r}|${i}`;
|
|
4072
4605
|
if (!t && this.replayLoader?.key === a || (this.replayLoader?.loader.dispose(), this.replayLoader = null, !i || !n || r === null)) return;
|
|
4073
|
-
let o =
|
|
4606
|
+
let o = N(n), s = o.fetchHistoryBefore, c = this.currentSymbol, l = w(r), u = new Ur({
|
|
4074
4607
|
source: s ? (e, t) => s.call(o, c, i, e, t) : null,
|
|
4075
4608
|
step: i,
|
|
4076
4609
|
ratio: Math.max(1, Math.round(l / w(i))),
|
|
@@ -4084,26 +4617,20 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
4084
4617
|
};
|
|
4085
4618
|
}
|
|
4086
4619
|
feedReplayForming(e, t, n, r) {
|
|
4087
|
-
let i = this.replaySession
|
|
4088
|
-
if (!i || !
|
|
4089
|
-
let
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
c.push(...q(n, -1, r));
|
|
4102
|
-
} else c.push(...q(n, i.fedFraction, r));
|
|
4103
|
-
i.fedTime = o.time, i.fedFraction = r;
|
|
4104
|
-
for (let [e, t] of c) a.setMarkPrice(e, t);
|
|
4105
|
-
let l = c[c.length - 1]?.[0];
|
|
4106
|
-
l !== void 0 && this.tradingManager.setCurrentPrice(l);
|
|
4620
|
+
let i = this.replaySession;
|
|
4621
|
+
if (!i || !this.executionAdapter?.setMarkPrice) return;
|
|
4622
|
+
let a = gi(e, t, n, r, {
|
|
4623
|
+
time: i.fedTime,
|
|
4624
|
+
fraction: i.fedFraction
|
|
4625
|
+
}, (e, t) => this.replayPathOf(e, t));
|
|
4626
|
+
a && (i.fedTime = a.fed.time, i.fedFraction = a.fed.fraction, this.feedReplayMarks(a.marks));
|
|
4627
|
+
}
|
|
4628
|
+
feedReplayMarks(e) {
|
|
4629
|
+
let t = this.executionAdapter;
|
|
4630
|
+
if (!t?.setMarkPrice) return;
|
|
4631
|
+
for (let [n, r] of e) t.setMarkPrice(n, r);
|
|
4632
|
+
let n = e[e.length - 1]?.[0];
|
|
4633
|
+
n !== void 0 && this.tradingManager.setCurrentPrice(n);
|
|
4107
4634
|
}
|
|
4108
4635
|
followLiveChange(e) {
|
|
4109
4636
|
let t = this.replaySession;
|
|
@@ -4114,9 +4641,9 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
4114
4641
|
if (!t) return;
|
|
4115
4642
|
let n = this.series.inHoursShown(this.series.liveBars());
|
|
4116
4643
|
if (n.length === 0) return;
|
|
4117
|
-
let r = t.windowTime === null ? 0 : Math.min(
|
|
4644
|
+
let r = t.windowTime === null ? 0 : Math.min(J(n, t.windowTime), n.length - 1), i = r > 0 ? n.slice(r) : n;
|
|
4118
4645
|
this.useReplayLoader(t, !1);
|
|
4119
|
-
let a = this.replayStepsOver(t, i), o = t.animate ? null : a, s = t.until === null ? 0 :
|
|
4646
|
+
let a = this.replayStepsOver(t, i), o = t.animate ? null : a, s = t.until === null ? 0 : Bi(o ?? i, t.until);
|
|
4120
4647
|
if (s < 0 && this.canPageBackForReplay(t)) {
|
|
4121
4648
|
this.holdReplay(), t.held && t.held.pagesBack++, queueMicrotask(() => void this.pageBackForReplay(t));
|
|
4122
4649
|
return;
|
|
@@ -4124,7 +4651,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
4124
4651
|
let c = this.getReplayState(), l = t.held !== null && (e === "hours" || e === "bar"), u = t.held?.state ?? c;
|
|
4125
4652
|
l || (t.held = null), t.symbol = this.currentSymbol;
|
|
4126
4653
|
let d = this.replayManager.remainingMs();
|
|
4127
|
-
this.clearBarHolders(), t.animate &&
|
|
4654
|
+
this.clearBarHolders(), t.animate && zi(t, this.replayCoarse, i);
|
|
4128
4655
|
let f = this.replayRestarting;
|
|
4129
4656
|
this.replayRestarting = !0, this.replayCause = e === "older" ? "older" : "series";
|
|
4130
4657
|
try {
|
|
@@ -4147,14 +4674,14 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
4147
4674
|
}
|
|
4148
4675
|
replayStepsOver(e, t, n = !1) {
|
|
4149
4676
|
if (!e.steps || e.stepsSymbol !== this.currentSymbol) return null;
|
|
4150
|
-
let r =
|
|
4151
|
-
return r && (n ||
|
|
4677
|
+
let r = Ui(this.series.inHoursShown(e.steps), t);
|
|
4678
|
+
return r && (n || Hi(r, t)) ? r : null;
|
|
4152
4679
|
}
|
|
4153
4680
|
canPageBackForReplay(e) {
|
|
4154
|
-
return this.history.hasLoader() && this.history.hasMore() && (e.held?.pagesBack ?? 0) <
|
|
4681
|
+
return this.history.hasLoader() && this.history.hasMore() && (e.held?.pagesBack ?? 0) < Pi;
|
|
4155
4682
|
}
|
|
4156
4683
|
async pageBackForReplay(e) {
|
|
4157
|
-
this.replaySession !== e || !e.held || await this.history.loadMore() > 0 || this.replaySession !== e || !e.held || (e.held.pagesBack =
|
|
4684
|
+
this.replaySession !== e || !e.held || await this.history.loadMore() > 0 || this.replaySession !== e || !e.held || (e.held.pagesBack = Pi, this.rebaseReplay("older"));
|
|
4158
4685
|
}
|
|
4159
4686
|
holdReplay() {
|
|
4160
4687
|
let e = this.replaySession;
|
|
@@ -4187,7 +4714,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
4187
4714
|
this.signalMarkerManager.setRevealUntil(e, t), this.tradeZoneManager.setRevealUntil(e, t);
|
|
4188
4715
|
}
|
|
4189
4716
|
replaySeekToTime(e) {
|
|
4190
|
-
!this.replaySession || !this.replayCoarse || this.replaySeek(Math.max(0,
|
|
4717
|
+
!this.replaySession || !this.replayCoarse || this.replaySeek(Math.max(0, Bi(this.replayStepsSeries ?? this.replayCoarse, e)));
|
|
4191
4718
|
}
|
|
4192
4719
|
feedReplayPrice(e, t) {
|
|
4193
4720
|
let n = this.executionAdapter;
|
|
@@ -4200,18 +4727,13 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
4200
4727
|
n !== void 0 && this.feedReplayPrice(n);
|
|
4201
4728
|
}
|
|
4202
4729
|
feedReplaySteps(e, t) {
|
|
4203
|
-
let n = this.replaySession
|
|
4204
|
-
if (!n || !
|
|
4205
|
-
|
|
4206
|
-
n.fedTime
|
|
4207
|
-
|
|
4208
|
-
}
|
|
4209
|
-
|
|
4210
|
-
let a = e.slice(X(e, n.fedTime), t + 1);
|
|
4211
|
-
n.fedTime = i.time;
|
|
4212
|
-
let o = Math.ceil(a.length / _i);
|
|
4213
|
-
for (let e = 0; e < a.length; e += o) for (let [t, n] of vi(a.slice(e, e + o))) r.setMarkPrice(t, n);
|
|
4214
|
-
this.tradingManager.setCurrentPrice(i.close);
|
|
4730
|
+
let n = this.replaySession;
|
|
4731
|
+
if (!n || !this.executionAdapter?.setMarkPrice) return;
|
|
4732
|
+
let r = hi(e, t, {
|
|
4733
|
+
time: n.fedTime,
|
|
4734
|
+
fraction: n.fedFraction
|
|
4735
|
+
});
|
|
4736
|
+
r && (n.fedTime = r.fed.time, this.feedReplayMarks(r.marks));
|
|
4215
4737
|
}
|
|
4216
4738
|
getReplayBarIndex() {
|
|
4217
4739
|
if (!this.replaySession) return -1;
|
|
@@ -4221,7 +4743,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
4221
4743
|
}
|
|
4222
4744
|
replaySeekToBar(e) {
|
|
4223
4745
|
let t = this.replayStepsSeries;
|
|
4224
|
-
this.replaySeek(t && this.replayCoarse ?
|
|
4746
|
+
this.replaySeek(t && this.replayCoarse ? Wi(t, this.replayCoarse, e) : e);
|
|
4225
4747
|
}
|
|
4226
4748
|
replayPause() {
|
|
4227
4749
|
this.setHeldState("paused") || this.replayManager.pause();
|
|
@@ -4262,7 +4784,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
4262
4784
|
let { x: r, y: c } = this.drawingManager.anchorPoint(t.type, e, n);
|
|
4263
4785
|
i = Math.min(i, r), a = Math.max(a, r), o = Math.min(o, c), s = Math.max(s, c);
|
|
4264
4786
|
}
|
|
4265
|
-
return
|
|
4787
|
+
return Ei.has(t.type) ? [i, a] = [r.x, r.x + r.width] : t.type === "horizontalRay" && (a = r.x + r.width), Di.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 ? {
|
|
4266
4788
|
x: i,
|
|
4267
4789
|
y: o,
|
|
4268
4790
|
width: a - i,
|
|
@@ -4311,26 +4833,23 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
4311
4833
|
});
|
|
4312
4834
|
}
|
|
4313
4835
|
restoreIndicators(e, t) {
|
|
4314
|
-
let n =
|
|
4836
|
+
let n = tr(e), r = /* @__PURE__ */ new Map();
|
|
4315
4837
|
this.unrestoredIndicators = [];
|
|
4316
4838
|
let i = new Set(this.indicatorEngine.getAvailableIndicators().map((e) => e.id)), a = [], o = /* @__PURE__ */ new Set();
|
|
4317
4839
|
if (t) {
|
|
4318
|
-
let e =
|
|
4319
|
-
for (let
|
|
4320
|
-
|
|
4321
|
-
|
|
4840
|
+
let e = this.getIndicatorSetup();
|
|
4841
|
+
for (let t of rr(e, n)) o.add(t);
|
|
4842
|
+
for (let t of e) o.has(t.instanceId) || this.removeIndicator(t.instanceId);
|
|
4843
|
+
let t = new Map(e.map((e) => [e.instanceId, e.pane]));
|
|
4844
|
+
for (let e = !0; e;) {
|
|
4845
|
+
e = !1;
|
|
4846
|
+
for (let n of [...o]) {
|
|
4847
|
+
let r = t.get(n);
|
|
4848
|
+
this.indicatorEngine.getIndicatorConfig(n) && !(r && !o.has(r)) || (this.indicatorEngine.getIndicatorConfig(n) && this.removeIndicator(n), o.delete(n), e = !0);
|
|
4849
|
+
}
|
|
4322
4850
|
}
|
|
4323
|
-
for (let e of t) o.has(e.instanceId) || this.removeIndicator(e.instanceId);
|
|
4324
|
-
for (let e of [...o]) this.indicatorEngine.getIndicatorConfig(e) || o.delete(e);
|
|
4325
4851
|
} else for (let e of this.indicatorEngine.getActiveIndicators()) this.removeIndicator(e.instanceId);
|
|
4326
|
-
let s = (e) =>
|
|
4327
|
-
let t = { ...e };
|
|
4328
|
-
for (let [e, n] of Object.entries(t)) {
|
|
4329
|
-
let i = x(n), a = i && r.get(i.instanceId);
|
|
4330
|
-
a && (t[e] = v(a, i.key));
|
|
4331
|
-
}
|
|
4332
|
-
return t;
|
|
4333
|
-
};
|
|
4852
|
+
let s = (e) => ar(e, r);
|
|
4334
4853
|
for (let e of n) {
|
|
4335
4854
|
let n = null;
|
|
4336
4855
|
if (o.has(e.instanceId)) {
|
|
@@ -4363,7 +4882,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
4363
4882
|
}
|
|
4364
4883
|
r.set(e.instanceId, n), a.push([e, n]), this.restoreLooks(n, e);
|
|
4365
4884
|
}
|
|
4366
|
-
return this.
|
|
4885
|
+
return this.indicatorEngine.orderIndicators(e.flatMap((e) => r.get(e.instanceId) ?? [])), er(this.layoutManager, a), this.updateViewportAndRender(), r;
|
|
4367
4886
|
}
|
|
4368
4887
|
restoreLooks(e, t) {
|
|
4369
4888
|
let { plots: n, ...r } = this.indicatorEngine.getIndicatorStyle(e) ?? {
|
|
@@ -4382,175 +4901,51 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
4382
4901
|
let c = t.intervals ?? null;
|
|
4383
4902
|
JSON.stringify(c) !== JSON.stringify(o?.intervals ?? null) && this.setIndicatorIntervalsNow(e, c), this.setPaneStyleNow(e, t.paneStyle ? se(t.paneStyle) : null);
|
|
4384
4903
|
}
|
|
4385
|
-
restorePanes(e) {
|
|
4386
|
-
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, {
|
|
4387
|
-
log: !!t.paneLog,
|
|
4388
|
-
invert: !!t.paneInvert,
|
|
4389
|
-
percent: !!t.panePercent
|
|
4390
|
-
});
|
|
4391
|
-
let t = e.filter(([e]) => e.paneOrder !== void 0).sort(([e], [t]) => (e.paneOrder ?? 0) - (t.paneOrder ?? 0)).map(([, e]) => e);
|
|
4392
|
-
t.length > 1 && this.layoutManager.orderPanels(t);
|
|
4393
|
-
let n = e.find(([e]) => e.paneMaximized);
|
|
4394
|
-
this.layoutManager.setMaximizedPanel(n ? n[1] : null);
|
|
4395
|
-
}
|
|
4396
4904
|
getIndicatorSetup() {
|
|
4397
|
-
|
|
4398
|
-
return [...this.indicatorEngine.getActiveIndicators().map((n) => {
|
|
4399
|
-
let r = e.find((e) => e.id === n.instanceId), i = this.indicatorEngine.getIndicatorConfig(n.instanceId);
|
|
4400
|
-
return {
|
|
4401
|
-
id: n.id,
|
|
4402
|
-
instanceId: n.instanceId,
|
|
4403
|
-
params: { ...n.params },
|
|
4404
|
-
position: r?.position,
|
|
4405
|
-
style: this.indicatorEngine.getIndicatorStyle(n.instanceId) ?? void 0,
|
|
4406
|
-
visible: n.visible,
|
|
4407
|
-
levels: i?.levels?.slice(),
|
|
4408
|
-
pane: n.pane,
|
|
4409
|
-
scale: i?.scale,
|
|
4410
|
-
...i?.intervals ? { intervals: this.indicatorEngine.getIntervals(n.instanceId) ?? void 0 } : {},
|
|
4411
|
-
...r && this.paneStyles.has(n.instanceId) ? { paneStyle: { ...this.paneStyles.get(n.instanceId) } } : {},
|
|
4412
|
-
...r ? {
|
|
4413
|
-
paneSize: r.size,
|
|
4414
|
-
paneOrder: e.indexOf(r),
|
|
4415
|
-
...r.collapsed ? { paneCollapsed: !0 } : {},
|
|
4416
|
-
...t === n.instanceId ? { paneMaximized: !0 } : {},
|
|
4417
|
-
...r.logScale ? { paneLog: !0 } : {},
|
|
4418
|
-
...r.invertScale ? { paneInvert: !0 } : {},
|
|
4419
|
-
...r.percentScale ? { panePercent: !0 } : {}
|
|
4420
|
-
} : {}
|
|
4421
|
-
};
|
|
4422
|
-
}), ...this.unrestoredIndicators];
|
|
4905
|
+
return [...$n(this.indicatorEngine, this.layoutManager, (e) => this.panes.style(e) ?? null), ...this.unrestoredIndicators];
|
|
4423
4906
|
}
|
|
4424
4907
|
applyIndicatorSetup(e) {
|
|
4425
|
-
this.features.indicators && this.
|
|
4426
|
-
let t = new Map(this.indicatorEngine.getActiveIndicators().map((e) => [e.instanceId, e.id])), n = this.
|
|
4908
|
+
this.features.indicators && this.indicatorHistory.record(void 0, () => {
|
|
4909
|
+
let t = new Map(this.indicatorEngine.getActiveIndicators().map((e) => [e.instanceId, e.id])), n = this.indicatorHistory.quietly(() => this.restoreIndicators(e, !1));
|
|
4427
4910
|
this.followIndicatorAlerts(t, [...n.values()]), this.markStateChanged();
|
|
4428
4911
|
});
|
|
4429
4912
|
}
|
|
4430
4913
|
followIndicatorAlerts(e, t) {
|
|
4431
|
-
|
|
4432
|
-
let n = (n) => {
|
|
4433
|
-
let r = n.indexOf(":");
|
|
4434
|
-
if (r <= 0) return null;
|
|
4435
|
-
let i = n.slice(0, r), a = e.get(i);
|
|
4436
|
-
if (!a || this.indicatorEngine.getIndicatorConfig(i)) return null;
|
|
4437
|
-
let o = t.filter((e) => this.indicatorEngine.getIndicatorConfig(e)?.id === a);
|
|
4438
|
-
return o.length === 1 ? o[0] + n.slice(r) : null;
|
|
4439
|
-
};
|
|
4440
|
-
for (let e of this.alertManager.getAlerts()) {
|
|
4441
|
-
let t = n(e.channel), r = e.target ? n(e.target) : null;
|
|
4442
|
-
if (!t && !r) continue;
|
|
4443
|
-
let { target: i, percent: a, bars: o, onBarClose: s, expiresAt: c } = e;
|
|
4444
|
-
this.alertManager.removeAlert(e.id), this.alertManager.addAlert(e.price, e.condition, e.message, e.repeating, t ?? e.channel, e.label, {
|
|
4445
|
-
...e.target ? { target: r ?? e.target } : {},
|
|
4446
|
-
...a === void 0 ? {} : { percent: a },
|
|
4447
|
-
...o === void 0 ? {} : { bars: o },
|
|
4448
|
-
...s ? { onBarClose: s } : {},
|
|
4449
|
-
...c === void 0 ? {} : { expiresAt: c }
|
|
4450
|
-
});
|
|
4451
|
-
}
|
|
4914
|
+
this.features.alerts && ci(this.alertManager, e, t, (e) => this.indicatorEngine.getIndicatorConfig(e)?.id);
|
|
4452
4915
|
}
|
|
4453
4916
|
beginIndicatorEdit(e) {
|
|
4454
|
-
this.
|
|
4455
|
-
subject: e,
|
|
4456
|
-
before: this.getIndicatorSetup()
|
|
4457
|
-
}, this.indicatorHistoryDepth++);
|
|
4917
|
+
this.indicatorHistory.begin(e);
|
|
4458
4918
|
}
|
|
4459
4919
|
endIndicatorEdit() {
|
|
4460
|
-
|
|
4461
|
-
if (!e) return;
|
|
4462
|
-
this.indicatorEdit = null, this.indicatorHistoryDepth--;
|
|
4463
|
-
let t = this.getIndicatorSetup();
|
|
4464
|
-
JSON.stringify(t) !== JSON.stringify(e.before) && this.undoRedoManager.push({
|
|
4465
|
-
type: "indicators",
|
|
4466
|
-
before: null,
|
|
4467
|
-
after: null,
|
|
4468
|
-
indicators: {
|
|
4469
|
-
before: e.before,
|
|
4470
|
-
after: t,
|
|
4471
|
-
subject: e.subject,
|
|
4472
|
-
at: performance.now()
|
|
4473
|
-
}
|
|
4474
|
-
});
|
|
4475
|
-
}
|
|
4476
|
-
withoutIndicatorHistory(e) {
|
|
4477
|
-
this.indicatorHistoryDepth++;
|
|
4478
|
-
try {
|
|
4479
|
-
return e();
|
|
4480
|
-
} finally {
|
|
4481
|
-
this.indicatorHistoryDepth--;
|
|
4482
|
-
}
|
|
4483
|
-
}
|
|
4484
|
-
recordIndicators(e, t) {
|
|
4485
|
-
if (this.indicatorHistoryDepth > 0 || !this.features.drawingUndoRedo) return t();
|
|
4486
|
-
let n = this.getIndicatorSetup(), r = [], i = this.paneRenames;
|
|
4487
|
-
this.paneRenames = r;
|
|
4488
|
-
let a;
|
|
4489
|
-
try {
|
|
4490
|
-
a = this.withoutIndicatorHistory(t);
|
|
4491
|
-
} finally {
|
|
4492
|
-
this.paneRenames = i;
|
|
4493
|
-
}
|
|
4494
|
-
let o = this.getIndicatorSetup();
|
|
4495
|
-
if (JSON.stringify(n) === JSON.stringify(o)) return a;
|
|
4496
|
-
let s = performance.now(), c = this.undoRedoManager.last(), l = e !== void 0 && c?.type === "indicators" && c.indicators?.subject === e && s - (c.indicators.at ?? 0) < Hr && JSON.stringify(c.indicators.after) === JSON.stringify(n), u = {
|
|
4497
|
-
type: "indicators",
|
|
4498
|
-
before: null,
|
|
4499
|
-
after: null
|
|
4500
|
-
};
|
|
4501
|
-
return l && c?.indicators ? JSON.stringify(c.indicators.before) === JSON.stringify(o) ? this.undoRedoManager.dropLast() : this.undoRedoManager.replaceLast({
|
|
4502
|
-
...u,
|
|
4503
|
-
indicators: {
|
|
4504
|
-
...c.indicators,
|
|
4505
|
-
after: o,
|
|
4506
|
-
at: s,
|
|
4507
|
-
...Wr([...c.indicators.renames ?? [], ...r])
|
|
4508
|
-
}
|
|
4509
|
-
}) : this.undoRedoManager.push({
|
|
4510
|
-
...u,
|
|
4511
|
-
indicators: {
|
|
4512
|
-
before: n,
|
|
4513
|
-
after: o,
|
|
4514
|
-
subject: e,
|
|
4515
|
-
at: s,
|
|
4516
|
-
...Wr(r)
|
|
4517
|
-
}
|
|
4518
|
-
}), a;
|
|
4920
|
+
this.indicatorHistory.end();
|
|
4519
4921
|
}
|
|
4520
4922
|
applyIndicatorStep(e, t) {
|
|
4521
4923
|
let n = e.indicators;
|
|
4522
4924
|
if (!n) return;
|
|
4523
|
-
this.
|
|
4925
|
+
this.replayingIndicatorStep = !0;
|
|
4926
|
+
try {
|
|
4927
|
+
this.indicatorHistory.quietly(() => this.restoreIndicators(t === "undo" ? n.before : n.after, !0));
|
|
4928
|
+
} finally {
|
|
4929
|
+
this.replayingIndicatorStep = !1;
|
|
4930
|
+
}
|
|
4524
4931
|
let r = n.renames ?? [], i = t === "undo" ? [...r].reverse().map(([e, t]) => [t, e]) : r;
|
|
4525
4932
|
for (let [e, t] of i) this.drawingManager.renamePanes(new Map([[e, t]]));
|
|
4526
4933
|
this.markStateChanged();
|
|
4527
4934
|
}
|
|
4528
4935
|
keptPaneDrawings = [];
|
|
4936
|
+
replayingIndicatorStep = !1;
|
|
4529
4937
|
takesDrawing(e, t) {
|
|
4530
|
-
return this.layoutManager.getPanels()
|
|
4938
|
+
return dr(this.layoutManager.getPanels(), e, !!this.drawingManager.getDescriptor(t)?.priceOnly);
|
|
4531
4939
|
}
|
|
4532
|
-
paneRenames = null;
|
|
4533
4940
|
renamePane(e, t) {
|
|
4534
|
-
this.layoutManager.renamePanel(e, t), this.drawingManager.renamePanes(new Map([[e, t]])), this.
|
|
4941
|
+
this.layoutManager.renamePanel(e, t), this.replayingIndicatorStep || this.drawingManager.renamePanes(new Map([[e, t]])), this.indicatorHistory.renamed(e, t);
|
|
4535
4942
|
}
|
|
4536
4943
|
drawingPaneAt(e) {
|
|
4537
|
-
|
|
4538
|
-
if (!t(this.viewport.getState().chartRect)) {
|
|
4539
|
-
for (let e of this.layoutManager.getPanels()) {
|
|
4540
|
-
let n = this.drawingPaneViewport(e.id);
|
|
4541
|
-
if (n && t(n.chartRect)) return e.id;
|
|
4542
|
-
}
|
|
4543
|
-
return null;
|
|
4544
|
-
}
|
|
4944
|
+
return lr(e, this.viewport.getState().chartRect, this.layoutManager.getPanels(), (e) => this.drawingPaneViewport(e));
|
|
4545
4945
|
}
|
|
4546
4946
|
drawingPaneViewport(e) {
|
|
4547
4947
|
let t = this.layoutManager.getPanels().find((t) => t.id === e);
|
|
4548
|
-
|
|
4549
|
-
let n = this.buildPanelRenderInfos().find((t) => t.instanceId === e);
|
|
4550
|
-
return !n || n.viewport.chartRect.height < Ur ? null : {
|
|
4551
|
-
...n.viewport,
|
|
4552
|
-
data: this.getDisplayData()
|
|
4553
|
-
};
|
|
4948
|
+
return ur(t, !!t && this.layoutManager.isPanelShownCollapsed(e), () => this.buildPanelRenderInfos().find((t) => t.instanceId === e)?.viewport, () => this.getDisplayData());
|
|
4554
4949
|
}
|
|
4555
4950
|
saveState(e) {
|
|
4556
4951
|
if (!this.features.saveLoad) return null;
|
|
@@ -4560,35 +4955,13 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
4560
4955
|
loadState(e) {
|
|
4561
4956
|
if (!this.features.saveLoad) return;
|
|
4562
4957
|
let t = T.deserialize(e);
|
|
4563
|
-
this.chartTypeOptions = t.chartTypeOptions ?? {}, this.
|
|
4564
|
-
let n = t.version >= 2 && this.features.indicators ? this.
|
|
4958
|
+
this.chartTypeOptions = t.chartTypeOptions ?? {}, this.display.reset(), 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");
|
|
4959
|
+
let n = t.version >= 2 && this.features.indicators ? this.indicatorHistory.quietly(() => this.restoreIndicators(t.indicators, !1)) : /* @__PURE__ */ new Map();
|
|
4565
4960
|
this.drawingManager.renamePanes(n);
|
|
4566
4961
|
let r = new Set(this.unrestoredIndicators.map((e) => e.instanceId)), i = this.drawingManager.getDrawings(), a = i.filter((e) => e.paneId === void 0 || this.takesDrawing(e.paneId, e.type));
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
if (e.triggered && !e.repeating) continue;
|
|
4571
|
-
let t = (e) => {
|
|
4572
|
-
let t = e.indexOf(":"), r = t > 0 ? n.get(e.slice(0, t)) : void 0;
|
|
4573
|
-
return r ? r + e.slice(t) : e;
|
|
4574
|
-
}, r = t(e.channel), i = {
|
|
4575
|
-
...zt(e),
|
|
4576
|
-
...e.target ? { target: t(e.target) } : {}
|
|
4577
|
-
};
|
|
4578
|
-
if (!e.expired) {
|
|
4579
|
-
if (e.drawingId) {
|
|
4580
|
-
this.drawingManager.hasPriceLevels(e.drawingId) && (e.condition === "crossing" || e.condition === "crossingUp" || e.condition === "crossingDown") && this.alertManager.addDrawingAlert(e.drawingId, e.condition, e.message, e.repeating, e.label);
|
|
4581
|
-
continue;
|
|
4582
|
-
}
|
|
4583
|
-
try {
|
|
4584
|
-
this.alertManager.addAlert(e.price, e.condition, e.message, e.repeating, r, e.label, i);
|
|
4585
|
-
} catch (e) {
|
|
4586
|
-
console.warn("Layout alert left out:", e);
|
|
4587
|
-
}
|
|
4588
|
-
}
|
|
4589
|
-
}
|
|
4590
|
-
}
|
|
4591
|
-
this.markStateChanged();
|
|
4962
|
+
this.keptPaneDrawings = i.filter((e) => e.paneId !== void 0 && r.has(e.paneId)), a.length !== i.length && this.drawingManager.setDrawings(a), this.undoRedoManager.clear(), t.alerts && this.features.alerts && di(this.alertManager, t.alerts, n, (e) => this.drawingManager.hasPriceLevels(e), (e) => {
|
|
4963
|
+
console.warn("Layout alert left out:", e);
|
|
4964
|
+
}), this.markStateChanged();
|
|
4592
4965
|
}
|
|
4593
4966
|
loadStateFromStorage(e) {
|
|
4594
4967
|
if (!this.features.saveLoad) return !1;
|
|
@@ -4661,17 +5034,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
4661
5034
|
return this.isTimeAligned() ? this.series.bars() : this.getDisplayData();
|
|
4662
5035
|
}
|
|
4663
5036
|
getDisplayData() {
|
|
4664
|
-
|
|
4665
|
-
if (this.displayDataCache && t === this.displayDataStep) return this.displayDataCache;
|
|
4666
|
-
if (e.length === 0) return e;
|
|
4667
|
-
let n = this.displaySeries(e, t);
|
|
4668
|
-
return this.displayDataCache = n, this.displayDataStep = t, n;
|
|
4669
|
-
}
|
|
4670
|
-
displaySeries(e, t) {
|
|
4671
|
-
let n = this.options.chartType, r = (e) => this.pluginManager.getChartType(e);
|
|
4672
|
-
if (n !== "pointAndFigure" || r(n)) return jn(n, e, r, this.chartTypeOptions, t, this.reshapeMemo);
|
|
4673
|
-
let { columns: i, boxSize: a } = mn(e, this.chartTypeOptions, this.reshapeMemo);
|
|
4674
|
-
return this.chartRenderer instanceof tt && this.chartRenderer.setBoxSize(a), i;
|
|
5037
|
+
return this.display.get();
|
|
4675
5038
|
}
|
|
4676
5039
|
recalcIndicatorsFrom(e, t) {
|
|
4677
5040
|
if (!this.isTimeAligned()) return this.recalcIndicators(e);
|
|
@@ -4683,7 +5046,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
4683
5046
|
}
|
|
4684
5047
|
exportBars() {
|
|
4685
5048
|
if (this.isTimeAligned()) return this.series.bars();
|
|
4686
|
-
let e = this.getDisplayData(), t =
|
|
5049
|
+
let e = this.getDisplayData(), t = k(e);
|
|
4687
5050
|
return e.map((e, n) => ({
|
|
4688
5051
|
...e,
|
|
4689
5052
|
time: t[n]?.time ?? e.time
|
|
@@ -4726,50 +5089,38 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
4726
5089
|
}
|
|
4727
5090
|
}
|
|
4728
5091
|
refitForTick() {
|
|
4729
|
-
this.
|
|
5092
|
+
this.panes.invalidateScales(), this.fitDataAndAxes(), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents();
|
|
4730
5093
|
}
|
|
4731
5094
|
applyDataToViewport(e = !1) {
|
|
4732
5095
|
let t = this.getDisplayData();
|
|
4733
|
-
this.syncIndicatorBars(t);
|
|
4734
|
-
let n = this.
|
|
4735
|
-
this.viewport.updateData(t, !1), e && (this.viewport.scrollToEnd(), this.viewport.updateData(t, !1));
|
|
4736
|
-
let r = this.viewport.getState();
|
|
5096
|
+
this.syncIndicatorBars(t), this.viewport.updateData(t, !1), e && (this.viewport.scrollToEnd(), this.viewport.updateData(t, !1));
|
|
5097
|
+
let n = this.viewport.getState();
|
|
4737
5098
|
if (t.length > 0) {
|
|
4738
|
-
let e = Math.max(0, Math.min(
|
|
5099
|
+
let e = Math.max(0, Math.min(n.visibleRange.from, t.length - 1));
|
|
4739
5100
|
this.viewport.setScaleBaseline(t[e]?.close);
|
|
4740
5101
|
}
|
|
4741
|
-
return
|
|
5102
|
+
return this.priceFit.shouldFit() && this.fitPriceScale(t, this.viewport.getState()), t;
|
|
4742
5103
|
}
|
|
4743
5104
|
fitPriceScale(e, t) {
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
} : {
|
|
4750
|
-
top: D,
|
|
4751
|
-
bottom: a
|
|
4752
|
-
}), this.viewport.fitToPrices(i.min, i.max);
|
|
5105
|
+
this.priceFit.fit(this.viewport, e, t, {
|
|
5106
|
+
overlayRange: (e, t) => this.indicatorEngine.getOverlayPriceRange(e, t),
|
|
5107
|
+
compareRange: (e, t) => this.features.compareSymbols && this.comparesDrawn() ? this.compareRenderer.getPriceRange(e, t) : null,
|
|
5108
|
+
volumeRatio: (e, t, n) => this.features.volume && this.volumeRenderer.isVisible() && Wn(e, t, n) ? this.volumeRenderer.getHeightRatio() : null
|
|
5109
|
+
});
|
|
4753
5110
|
}
|
|
4754
5111
|
updateViewportAndRender(e = !1) {
|
|
4755
|
-
this.indicatorEngine.setBarsTimed(this.comparesDrawn()), this.layoutManager.setPanelsAside(this.
|
|
5112
|
+
this.indicatorEngine.setBarsTimed(this.comparesDrawn()), this.layoutManager.setPanelsAside(this.panes.offChartType()), this.panes.invalidate(), this.layoutManager.setLeftAxisWidth(this.isLeftPriceScaleShown() ? this.leftAxisWidth : 0);
|
|
4756
5113
|
let t = this.getResolvedLayout();
|
|
4757
5114
|
this.viewport.setChartRect(t.mainChartRect), this.fitDataAndAxes(e), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents();
|
|
4758
5115
|
}
|
|
4759
5116
|
fitDataAndAxes(e = !1) {
|
|
4760
5117
|
let t = this.applyDataToViewport(e), n = this.fitPriceAxisWidth();
|
|
4761
|
-
this.leftViewport = this.computeLeftViewport(), (this.fitLeftAxisWidth() || n) && this.applyDataToViewport(e), this.
|
|
4762
|
-
}
|
|
4763
|
-
priceFitDone(e) {
|
|
4764
|
-
let { chartRect: t, offset: n, barWidth: r, barSpacing: i } = this.viewport.getState();
|
|
4765
|
-
if (e.length === 0 || t.width <= 0) return !1;
|
|
4766
|
-
let a = n <= 0 && e.length * (r + i) - n <= t.width;
|
|
4767
|
-
return !(this.seriesArriving && a);
|
|
5118
|
+
this.leftViewport = this.computeLeftViewport(), (this.fitLeftAxisWidth() || n) && this.applyDataToViewport(e), this.priceFit.settle(this.viewport.getState(), t.length);
|
|
4768
5119
|
}
|
|
4769
5120
|
fitLeftAxisWidth() {
|
|
4770
5121
|
let e = this.leftViewport;
|
|
4771
5122
|
if (!e) return !1;
|
|
4772
|
-
let t = this.themeManager.getTheme(), n =
|
|
5123
|
+
let t = this.themeManager.getTheme(), n = Dr({
|
|
4773
5124
|
min: e.priceRange.min,
|
|
4774
5125
|
max: e.priceRange.max,
|
|
4775
5126
|
lastPrice: null,
|
|
@@ -4778,12 +5129,12 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
4778
5129
|
fontFamily: t.font.family,
|
|
4779
5130
|
fontSizeSmall: t.font.sizeSmall,
|
|
4780
5131
|
measure: (e, t) => this.measureText(e, t)
|
|
4781
|
-
}), r =
|
|
4782
|
-
return r === this.leftAxisWidth ? !1 : (this.leftAxisWidth = r, this.layoutManager.setLeftAxisWidth(r), this.
|
|
5132
|
+
}), r = Or(this.leftAxisWidth, n);
|
|
5133
|
+
return r === this.leftAxisWidth ? !1 : (this.leftAxisWidth = r, this.layoutManager.setLeftAxisWidth(r), this.panes.invalidate(), this.viewport.setChartRect(this.getResolvedLayout().mainChartRect), !0);
|
|
4783
5134
|
}
|
|
4784
5135
|
fitPriceAxisWidth() {
|
|
4785
5136
|
if (!this.features.priceAxis) return !1;
|
|
4786
|
-
let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n =
|
|
5137
|
+
let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n = Dr({
|
|
4787
5138
|
min: e.min,
|
|
4788
5139
|
max: e.max,
|
|
4789
5140
|
lastPrice: this.currentPriceLine.getPrice(),
|
|
@@ -4794,14 +5145,14 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
4794
5145
|
fontFamily: t.font.family,
|
|
4795
5146
|
fontSizeSmall: t.font.sizeSmall,
|
|
4796
5147
|
measure: (e, t) => this.measureText(e, t)
|
|
4797
|
-
}), r =
|
|
4798
|
-
return r === this.priceAxisWidth ? !1 : (this.priceAxisWidth = r, this.layoutManager.setPriceAxisWidth(r), this.viewport.setPriceAxisWidth(r), this.
|
|
5148
|
+
}), r = Or(this.priceAxisWidth, n);
|
|
5149
|
+
return r === this.priceAxisWidth ? !1 : (this.priceAxisWidth = r, this.layoutManager.setPriceAxisWidth(r), this.viewport.setPriceAxisWidth(r), this.panes.invalidate(), this.viewport.setChartRect(this.getResolvedLayout().mainChartRect), !0);
|
|
4799
5150
|
}
|
|
4800
5151
|
measureText(e, t) {
|
|
4801
5152
|
let n = this.engine.layerManager.getLayer(r.Main)?.ctx;
|
|
4802
|
-
if (n?.canvas.isConnected) return this.labelWidths.get(e, t, () =>
|
|
5153
|
+
if (n?.canvas.isConnected) return this.labelWidths.get(e, t, () => ki(n, e, t));
|
|
4803
5154
|
let i = n ?? this.detachedMeasureContext();
|
|
4804
|
-
return i ?
|
|
5155
|
+
return i ? ki(i, e, t) : e.length * 7;
|
|
4805
5156
|
}
|
|
4806
5157
|
detachedMeasureContext() {
|
|
4807
5158
|
return this.measureCtx === void 0 && (this.measureCtx = typeof document < "u" ? document.createElement("canvas").getContext("2d") : null), this.measureCtx;
|
|
@@ -4825,57 +5176,18 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
4825
5176
|
})), this.lastEmittedBarWidth !== e.barWidth && (this.lastEmittedBarWidth = e.barWidth, this.eventBus.emit("zoomChange", { barWidth: e.barWidth })), this.checkHistory();
|
|
4826
5177
|
}
|
|
4827
5178
|
getResolvedLayout() {
|
|
4828
|
-
return this.
|
|
4829
|
-
}
|
|
4830
|
-
syncCrosshairBounds(e) {
|
|
4831
|
-
let t = e.mainChartRect, n = t.y, r = t.y + t.height;
|
|
4832
|
-
for (let t of e.panels) t.config.position !== "top" && t.config.position !== "bottom" || (n = Math.min(n, t.rect.y), r = Math.max(r, t.rect.y + t.rect.height));
|
|
4833
|
-
this.crosshairHandler.setReportBounds({
|
|
4834
|
-
top: n,
|
|
4835
|
-
bottom: r
|
|
4836
|
-
});
|
|
5179
|
+
return this.panes.resolved();
|
|
4837
5180
|
}
|
|
4838
5181
|
cachedContainerSize() {
|
|
4839
5182
|
let e = Date.now();
|
|
4840
5183
|
return (!this.containerSizeCache || e - this.containerSizeCacheTime > 500) && (this.containerSizeCache = this.engine.dprManager.getContainerSize(), this.containerSizeCacheTime = e), this.containerSizeCache;
|
|
4841
5184
|
}
|
|
4842
5185
|
buildPanelRenderInfos() {
|
|
4843
|
-
|
|
4844
|
-
let e = this.getResolvedLayout(), t = this.viewport.getState(), { from: n, to: r } = t.visibleRange, i = e.panels.map((e) => {
|
|
4845
|
-
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) ?? { ...Fr }, o = {
|
|
4846
|
-
x: e.rect.x,
|
|
4847
|
-
y: e.rect.y + 20,
|
|
4848
|
-
width: e.rect.width,
|
|
4849
|
-
height: Math.max(0, e.rect.height - 20)
|
|
4850
|
-
}, s = this.paneStyles.get(e.config.id);
|
|
4851
|
-
return {
|
|
4852
|
-
instanceId: e.config.id,
|
|
4853
|
-
members: this.indicatorEngine.getPaneMembers(e.config.id),
|
|
4854
|
-
...s ? { style: s } : {},
|
|
4855
|
-
rect: e.rect,
|
|
4856
|
-
viewport: {
|
|
4857
|
-
...t,
|
|
4858
|
-
chartRect: o,
|
|
4859
|
-
priceRange: a,
|
|
4860
|
-
logScale: i !== null,
|
|
4861
|
-
scaleMode: e.config.percentScale ? "percentage" : "regular",
|
|
4862
|
-
scaleBaseline: e.config.percentScale ? this.paneBaseline(e.config.id, n, r) : void 0,
|
|
4863
|
-
formatPrice: void 0,
|
|
4864
|
-
pricePrecision: void 0,
|
|
4865
|
-
priceUnit: void 0,
|
|
4866
|
-
invertScale: !!e.config.invertScale
|
|
4867
|
-
}
|
|
4868
|
-
};
|
|
4869
|
-
});
|
|
4870
|
-
return this.panelInfoCache = i, i;
|
|
4871
|
-
}
|
|
4872
|
-
timeAxisTop() {
|
|
4873
|
-
let e = this.getResolvedLayout(), t = e.panels.filter((e) => e.config.position === "bottom").reduce((e, t) => e + t.rect.height, 0);
|
|
4874
|
-
return e.mainChartRect.y + e.mainChartRect.height + t;
|
|
5186
|
+
return this.panes.panels(() => this.viewport.getState());
|
|
4875
5187
|
}
|
|
4876
5188
|
syncRenderContext() {
|
|
4877
5189
|
this.pinnedTooltip.isPinned() && this.pinnedTooltip.reposition(this.viewport.getState(), null, null, this.themeManager.getTheme());
|
|
4878
|
-
let e = this.features.indicators ? this.buildPanelRenderInfos() : [], t = this.timeAxisTop(), n = this.getDisplayData();
|
|
5190
|
+
let e = this.features.indicators ? this.buildPanelRenderInfos() : [], t = this.panes.timeAxisTop(), n = this.getDisplayData();
|
|
4879
5191
|
this.leftViewport = this.computeLeftViewport(), this.engine.setRenderContext({
|
|
4880
5192
|
leftViewport: this.leftViewport,
|
|
4881
5193
|
leftPriceAxis: this.leftPriceAxis,
|
|
@@ -4927,7 +5239,7 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
4927
5239
|
});
|
|
4928
5240
|
}
|
|
4929
5241
|
drawOverlayPlugins(e, t) {
|
|
4930
|
-
let n =
|
|
5242
|
+
let n = Nr(this.pluginManager.getOverlays(), t);
|
|
4931
5243
|
if (n.length === 0) return;
|
|
4932
5244
|
let r = {
|
|
4933
5245
|
viewport: this.viewport.getState(),
|
|
@@ -4948,33 +5260,16 @@ var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
|
4948
5260
|
};
|
|
4949
5261
|
}
|
|
4950
5262
|
};
|
|
4951
|
-
function
|
|
4952
|
-
let t = new Map(e.map((e) => [e.instanceId, e])), n = [], r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = (e) => {
|
|
4953
|
-
if (r.has(e.instanceId) || i.has(e.instanceId)) return;
|
|
4954
|
-
i.add(e.instanceId);
|
|
4955
|
-
let o = [e.pane, ...Object.values(e.params).map((e) => x(e)?.instanceId)];
|
|
4956
|
-
for (let e of o) {
|
|
4957
|
-
let n = e ? t.get(e) : void 0;
|
|
4958
|
-
n && a(n);
|
|
4959
|
-
}
|
|
4960
|
-
i.delete(e.instanceId), r.add(e.instanceId), n.push(e);
|
|
4961
|
-
};
|
|
4962
|
-
for (let t of e) a(t);
|
|
4963
|
-
return n;
|
|
4964
|
-
}
|
|
4965
|
-
function $r(e, t) {
|
|
4966
|
-
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);
|
|
4967
|
-
}
|
|
4968
|
-
function ei(e, t, n) {
|
|
5263
|
+
function ki(e, t, n) {
|
|
4969
5264
|
let r = e.font;
|
|
4970
5265
|
e.font = n;
|
|
4971
5266
|
let i = e.measureText(t).width;
|
|
4972
5267
|
return e.font = r, i;
|
|
4973
5268
|
}
|
|
4974
|
-
var
|
|
4975
|
-
function
|
|
5269
|
+
var Ai = 300;
|
|
5270
|
+
function ji(e) {
|
|
4976
5271
|
let t = {}, n = e.family;
|
|
4977
|
-
typeof n == "string" && n.trim() !== "" && n.length <=
|
|
5272
|
+
typeof n == "string" && n.trim() !== "" && n.length <= Ai && !/[;{}<>\\]|\/\*/.test(n) && (t.family = n);
|
|
4978
5273
|
for (let n of [
|
|
4979
5274
|
"sizeSmall",
|
|
4980
5275
|
"sizeMedium",
|
|
@@ -4985,21 +5280,11 @@ function ni(e) {
|
|
|
4985
5280
|
}
|
|
4986
5281
|
return t;
|
|
4987
5282
|
}
|
|
4988
|
-
function
|
|
5283
|
+
function Mi(e) {
|
|
4989
5284
|
let t = e.tagRadius;
|
|
4990
5285
|
return typeof t == "number" && Number.isFinite(t) && t >= 0 ? { tagRadius: Math.min(t, 999) } : {};
|
|
4991
5286
|
}
|
|
4992
|
-
function
|
|
4993
|
-
for (let r = t; r <= n; r++) if (e[r].volume > 0) return !0;
|
|
4994
|
-
return !1;
|
|
4995
|
-
}
|
|
4996
|
-
function ai(e, t) {
|
|
4997
|
-
return e ? t ? {
|
|
4998
|
-
min: Math.min(e.min, t.min),
|
|
4999
|
-
max: Math.max(e.max, t.max)
|
|
5000
|
-
} : e : t;
|
|
5001
|
-
}
|
|
5002
|
-
function J(e) {
|
|
5287
|
+
function X(e) {
|
|
5003
5288
|
return {
|
|
5004
5289
|
id: e.id,
|
|
5005
5290
|
price: e.price,
|
|
@@ -5014,14 +5299,8 @@ function J(e) {
|
|
|
5014
5299
|
bars: e.bars
|
|
5015
5300
|
};
|
|
5016
5301
|
}
|
|
5017
|
-
var
|
|
5018
|
-
|
|
5019
|
-
"line",
|
|
5020
|
-
"area",
|
|
5021
|
-
"bar",
|
|
5022
|
-
"hollowCandle"
|
|
5023
|
-
]), ci = 10, li = 50, ui = .001;
|
|
5024
|
-
function di(e) {
|
|
5302
|
+
var Ni = 8e3, Pi = 10, Fi = 50, Ii = .001;
|
|
5303
|
+
function Li(e) {
|
|
5025
5304
|
return {
|
|
5026
5305
|
price: null,
|
|
5027
5306
|
fedTime: null,
|
|
@@ -5036,71 +5315,48 @@ function di(e) {
|
|
|
5036
5315
|
held: null
|
|
5037
5316
|
};
|
|
5038
5317
|
}
|
|
5039
|
-
function
|
|
5318
|
+
function Ri(e, t) {
|
|
5040
5319
|
let n = e[t + 1];
|
|
5041
5320
|
return n ? n.time - e[t].time : Z(e);
|
|
5042
5321
|
}
|
|
5043
|
-
function
|
|
5322
|
+
function zi(e, t, n) {
|
|
5044
5323
|
let r = e.fedTime;
|
|
5045
5324
|
if (r === null || !t || t.length === 0 || n.length === 0) return;
|
|
5046
|
-
let i =
|
|
5325
|
+
let i = Ri(t, Q(t, r)), a = r + (Number.isFinite(i) ? e.fedFraction * i : 0), o = Q(n, a), s = n[o].time;
|
|
5047
5326
|
if (s > a) return;
|
|
5048
|
-
let c =
|
|
5327
|
+
let c = Ri(n, o);
|
|
5049
5328
|
if (a === s && o > 0) {
|
|
5050
5329
|
e.fedTime = n[o - 1].time, e.fedFraction = 1;
|
|
5051
5330
|
return;
|
|
5052
5331
|
}
|
|
5053
5332
|
e.fedTime = s, e.fedFraction = Number.isFinite(c) && c > 0 ? Math.min(1, (a - s) / c) : 0;
|
|
5054
5333
|
}
|
|
5055
|
-
function
|
|
5056
|
-
let n =
|
|
5334
|
+
function Bi(e, t) {
|
|
5335
|
+
let n = Y(e, t), r = e.length - 1;
|
|
5057
5336
|
return n > r && r >= 0 && e[r].time + Z(e) <= t ? r : Math.max(-1, n - 2);
|
|
5058
5337
|
}
|
|
5059
|
-
function
|
|
5338
|
+
function Vi(e) {
|
|
5060
5339
|
let t = Infinity;
|
|
5061
5340
|
for (let n = Math.max(1, e.length - 10); n < e.length; n++) t = Math.min(t, e[n].time - e[n - 1].time);
|
|
5062
5341
|
return t;
|
|
5063
5342
|
}
|
|
5064
|
-
function
|
|
5065
|
-
if (!(
|
|
5066
|
-
let n = Math.max(0, e.length -
|
|
5343
|
+
function Hi(e, t) {
|
|
5344
|
+
if (!(Vi(e) < Vi(t))) return !1;
|
|
5345
|
+
let n = Math.max(0, e.length - Fi);
|
|
5067
5346
|
for (let r = n; r < e.length; r++) {
|
|
5068
|
-
let n = t[Q(t, e[r].time)], i = (n.high - n.low) *
|
|
5347
|
+
let n = t[Q(t, e[r].time)], i = (n.high - n.low) * Ii + 2 ** -52;
|
|
5069
5348
|
if (e[r].close > n.high + i || e[r].close < n.low - i) return !1;
|
|
5070
5349
|
}
|
|
5071
5350
|
return !0;
|
|
5072
5351
|
}
|
|
5073
|
-
var _i = 500;
|
|
5074
|
-
function Y(e, t) {
|
|
5075
|
-
let n = 0, r = e.length;
|
|
5076
|
-
for (; n < r;) {
|
|
5077
|
-
let i = n + r >> 1;
|
|
5078
|
-
e[i].time < t ? n = i + 1 : r = i;
|
|
5079
|
-
}
|
|
5080
|
-
return n;
|
|
5081
|
-
}
|
|
5082
|
-
function X(e, t) {
|
|
5083
|
-
let n = 0, r = e.length;
|
|
5084
|
-
for (; n < r;) {
|
|
5085
|
-
let i = n + r >> 1;
|
|
5086
|
-
e[i].time <= t ? n = i + 1 : r = i;
|
|
5087
|
-
}
|
|
5088
|
-
return n;
|
|
5089
|
-
}
|
|
5090
|
-
function vi(e) {
|
|
5091
|
-
let t = 0, n = 0;
|
|
5092
|
-
for (let r = 1; r < e.length; r++) e[r].low < e[t].low && (t = r), e[r].high > e[n].high && (n = r);
|
|
5093
|
-
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];
|
|
5094
|
-
return [...a ? [r, i] : [i, r], [o.close, o.time]];
|
|
5095
|
-
}
|
|
5096
5352
|
function Z(e) {
|
|
5097
5353
|
let t = 0;
|
|
5098
5354
|
for (let n = Math.max(1, e.length - 10); n < e.length; n++) t = Math.max(t, e[n].time - e[n - 1].time);
|
|
5099
5355
|
return t > 0 ? t : Infinity;
|
|
5100
5356
|
}
|
|
5101
|
-
function
|
|
5357
|
+
function Ui(e, t) {
|
|
5102
5358
|
if (t.length === 0) return null;
|
|
5103
|
-
let n = t[t.length - 1].time + Z(t), r = e.filter((e) =>
|
|
5359
|
+
let n = t[t.length - 1].time + Z(t), r = e.filter((e) => zn(e) && e.time >= t[0].time && e.time < n).sort((e, t) => e.time - t.time), i = [];
|
|
5104
5360
|
for (let e of r) (i.length === 0 || i[i.length - 1].time !== e.time) && i.push(e);
|
|
5105
5361
|
if (i.length === 0) return null;
|
|
5106
5362
|
let a = t.findIndex((e) => e.time >= i[0].time);
|
|
@@ -5116,26 +5372,26 @@ function Q(e, t) {
|
|
|
5116
5372
|
}
|
|
5117
5373
|
return n;
|
|
5118
5374
|
}
|
|
5119
|
-
function
|
|
5375
|
+
function Wi(e, t, n) {
|
|
5120
5376
|
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;
|
|
5121
5377
|
for (let t = 0; t < e.length && e[t].time < i; t++) a = t;
|
|
5122
5378
|
return Math.max(0, a);
|
|
5123
5379
|
}
|
|
5124
|
-
function
|
|
5380
|
+
function Gi(e, t, n) {
|
|
5125
5381
|
let r = n;
|
|
5126
5382
|
for (; r > 0 && t[r - 1].time >= e.time;) r--;
|
|
5127
5383
|
let i = {
|
|
5128
5384
|
...t[r],
|
|
5129
5385
|
time: e.time
|
|
5130
5386
|
};
|
|
5131
|
-
for (let e = r + 1; e <= n; e++) i =
|
|
5387
|
+
for (let e = r + 1; e <= n; e++) i = Yi(i, t[e]);
|
|
5132
5388
|
return i;
|
|
5133
5389
|
}
|
|
5134
|
-
function
|
|
5390
|
+
function Ki(e, t, n, r) {
|
|
5135
5391
|
let i = e[n + 1], a = t[r + 1];
|
|
5136
5392
|
return i !== void 0 && a !== void 0 && i.time >= a.time;
|
|
5137
5393
|
}
|
|
5138
|
-
function
|
|
5394
|
+
function qi(e, t) {
|
|
5139
5395
|
let n = /* @__PURE__ */ new Map();
|
|
5140
5396
|
for (let r of e) {
|
|
5141
5397
|
let e = t[Q(t, r.time)].time, i = n.get(e);
|
|
@@ -5143,10 +5399,10 @@ function Ci(e, t) {
|
|
|
5143
5399
|
}
|
|
5144
5400
|
return n;
|
|
5145
5401
|
}
|
|
5146
|
-
function
|
|
5402
|
+
function Ji() {
|
|
5147
5403
|
return typeof matchMedia == "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
5148
5404
|
}
|
|
5149
|
-
function
|
|
5405
|
+
function Yi(e, t) {
|
|
5150
5406
|
return {
|
|
5151
5407
|
time: e.time,
|
|
5152
5408
|
open: e.open,
|
|
@@ -5158,26 +5414,26 @@ function Ti(e, t) {
|
|
|
5158
5414
|
}
|
|
5159
5415
|
//#endregion
|
|
5160
5416
|
//#region src/io/parseOHLCV.ts
|
|
5161
|
-
var
|
|
5417
|
+
var Xi = [
|
|
5162
5418
|
"time",
|
|
5163
5419
|
"timestamp",
|
|
5164
5420
|
"date",
|
|
5165
5421
|
"datetime",
|
|
5166
5422
|
"t"
|
|
5167
|
-
],
|
|
5423
|
+
], Zi = ["open", "o"], Qi = ["high", "h"], $i = ["low", "l"], ea = ["close", "c"], ta = [
|
|
5168
5424
|
"volume",
|
|
5169
5425
|
"vol",
|
|
5170
5426
|
"v"
|
|
5171
5427
|
];
|
|
5172
|
-
function
|
|
5428
|
+
function na(e) {
|
|
5173
5429
|
let t = e.trim();
|
|
5174
|
-
return t ? t[0] === "[" || t[0] === "{" ?
|
|
5430
|
+
return t ? t[0] === "[" || t[0] === "{" ? ra(t) : ia(t) : {
|
|
5175
5431
|
data: [],
|
|
5176
5432
|
rowCount: 0,
|
|
5177
5433
|
skipped: 0
|
|
5178
5434
|
};
|
|
5179
5435
|
}
|
|
5180
|
-
function
|
|
5436
|
+
function ra(e) {
|
|
5181
5437
|
let t;
|
|
5182
5438
|
try {
|
|
5183
5439
|
t = JSON.parse(e);
|
|
@@ -5187,19 +5443,19 @@ function Ni(e) {
|
|
|
5187
5443
|
if (!Array.isArray(t)) throw Error("Expected a JSON array of OHLCV rows");
|
|
5188
5444
|
let n = [], r = 0;
|
|
5189
5445
|
for (let e of t) {
|
|
5190
|
-
let t = Array.isArray(e) ?
|
|
5446
|
+
let t = Array.isArray(e) ? la(e) : ca(e);
|
|
5191
5447
|
t ? n.push(t) : r++;
|
|
5192
5448
|
}
|
|
5193
|
-
return
|
|
5449
|
+
return da(n, t.length, r);
|
|
5194
5450
|
}
|
|
5195
|
-
function
|
|
5451
|
+
function ia(e) {
|
|
5196
5452
|
let t = e.split(/\r?\n/).filter((e) => e.trim().length > 0);
|
|
5197
5453
|
if (t.length === 0) return {
|
|
5198
5454
|
data: [],
|
|
5199
5455
|
rowCount: 0,
|
|
5200
5456
|
skipped: 0
|
|
5201
5457
|
};
|
|
5202
|
-
let n =
|
|
5458
|
+
let n = aa(t[0]), r = oa(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? sa(r) : {
|
|
5203
5459
|
time: 0,
|
|
5204
5460
|
open: 1,
|
|
5205
5461
|
high: 2,
|
|
@@ -5210,7 +5466,7 @@ function Pi(e) {
|
|
|
5210
5466
|
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");
|
|
5211
5467
|
let o = [], s = 0;
|
|
5212
5468
|
for (let e = +!!i; e < t.length; e++) {
|
|
5213
|
-
let r =
|
|
5469
|
+
let r = oa(t[e], n), i = ua(r[a.time]), c = $(r[a.open]), l = $(r[a.high]), u = $(r[a.low]), d = $(r[a.close]), f = a.volume >= 0 ? Number(r[a.volume]) : 0;
|
|
5214
5470
|
if (i === null || ![
|
|
5215
5471
|
c,
|
|
5216
5472
|
l,
|
|
@@ -5229,9 +5485,9 @@ function Pi(e) {
|
|
|
5229
5485
|
volume: Number.isFinite(f) ? f : 0
|
|
5230
5486
|
});
|
|
5231
5487
|
}
|
|
5232
|
-
return
|
|
5488
|
+
return da(o, t.length - +!!i, s);
|
|
5233
5489
|
}
|
|
5234
|
-
function
|
|
5490
|
+
function aa(e) {
|
|
5235
5491
|
let t = {
|
|
5236
5492
|
",": 0,
|
|
5237
5493
|
";": 0,
|
|
@@ -5243,7 +5499,7 @@ function Fi(e) {
|
|
|
5243
5499
|
for (let [e, i] of Object.entries(t)) i > r && (n = e, r = i);
|
|
5244
5500
|
return n;
|
|
5245
5501
|
}
|
|
5246
|
-
function
|
|
5502
|
+
function oa(e, t) {
|
|
5247
5503
|
let n = [], r = "", i = !1;
|
|
5248
5504
|
for (let a = 0; a < e.length; a++) {
|
|
5249
5505
|
let o = e[a];
|
|
@@ -5251,25 +5507,25 @@ function Ii(e, t) {
|
|
|
5251
5507
|
}
|
|
5252
5508
|
return n.push(r), n;
|
|
5253
5509
|
}
|
|
5254
|
-
function
|
|
5510
|
+
function sa(e) {
|
|
5255
5511
|
let t = (t) => e.findIndex((e) => t.includes(e));
|
|
5256
5512
|
return {
|
|
5257
|
-
time: t(
|
|
5258
|
-
open: t(
|
|
5259
|
-
high: t(
|
|
5260
|
-
low: t(
|
|
5261
|
-
close: t(
|
|
5262
|
-
volume: t(
|
|
5513
|
+
time: t(Xi),
|
|
5514
|
+
open: t(Zi),
|
|
5515
|
+
high: t(Qi),
|
|
5516
|
+
low: t($i),
|
|
5517
|
+
close: t(ea),
|
|
5518
|
+
volume: t(ta)
|
|
5263
5519
|
};
|
|
5264
5520
|
}
|
|
5265
|
-
function
|
|
5521
|
+
function ca(e) {
|
|
5266
5522
|
let t = (t) => {
|
|
5267
5523
|
for (let n of t) {
|
|
5268
5524
|
if (e[n] !== void 0) return e[n];
|
|
5269
5525
|
let t = n.toUpperCase();
|
|
5270
5526
|
if (e[t] !== void 0) return e[t];
|
|
5271
5527
|
}
|
|
5272
|
-
}, n =
|
|
5528
|
+
}, n = ua(String(t(Xi) ?? "")), r = Number(t(Zi)), i = Number(t(Qi)), a = Number(t($i)), o = Number(t(ea)), s = Number(t(ta) ?? 0);
|
|
5273
5529
|
return n === null || ![
|
|
5274
5530
|
r,
|
|
5275
5531
|
i,
|
|
@@ -5284,9 +5540,9 @@ function Ri(e) {
|
|
|
5284
5540
|
volume: Number.isFinite(s) ? s : 0
|
|
5285
5541
|
};
|
|
5286
5542
|
}
|
|
5287
|
-
function
|
|
5543
|
+
function la(e) {
|
|
5288
5544
|
if (e.length < 5) return null;
|
|
5289
|
-
let t =
|
|
5545
|
+
let t = ua(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;
|
|
5290
5546
|
return t === null || ![
|
|
5291
5547
|
n,
|
|
5292
5548
|
r,
|
|
@@ -5304,7 +5560,7 @@ function zi(e) {
|
|
|
5304
5560
|
function $(e) {
|
|
5305
5561
|
return e === void 0 || e.trim() === "" ? NaN : Number(e);
|
|
5306
5562
|
}
|
|
5307
|
-
function
|
|
5563
|
+
function ua(e) {
|
|
5308
5564
|
let t = e.trim();
|
|
5309
5565
|
if (!t) return null;
|
|
5310
5566
|
let n = Number(t);
|
|
@@ -5312,7 +5568,7 @@ function Bi(e) {
|
|
|
5312
5568
|
let r = Date.parse(t);
|
|
5313
5569
|
return Number.isFinite(r) ? r : null;
|
|
5314
5570
|
}
|
|
5315
|
-
function
|
|
5571
|
+
function da(e, t, n) {
|
|
5316
5572
|
e.sort((e, t) => e.time - t.time);
|
|
5317
5573
|
let r = [];
|
|
5318
5574
|
for (let t of e) r.length > 0 && r[r.length - 1].time === t.time ? r[r.length - 1] = t : r.push(t);
|
|
@@ -5324,7 +5580,7 @@ function Vi(e, t, n) {
|
|
|
5324
5580
|
}
|
|
5325
5581
|
//#endregion
|
|
5326
5582
|
//#region src/io/DragDropImporter.ts
|
|
5327
|
-
var
|
|
5583
|
+
var fa = class {
|
|
5328
5584
|
host;
|
|
5329
5585
|
overlay = null;
|
|
5330
5586
|
callbacks;
|
|
@@ -5345,19 +5601,19 @@ var Hi = class {
|
|
|
5345
5601
|
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();
|
|
5346
5602
|
}
|
|
5347
5603
|
onDragEnter(e) {
|
|
5348
|
-
|
|
5604
|
+
pa(e) && (e.preventDefault(), this.depth++, this.showOverlay());
|
|
5349
5605
|
}
|
|
5350
5606
|
onDragOver(e) {
|
|
5351
|
-
|
|
5607
|
+
pa(e) && (e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = "copy"));
|
|
5352
5608
|
}
|
|
5353
5609
|
onDragLeave(e) {
|
|
5354
|
-
|
|
5610
|
+
pa(e) && (this.depth = Math.max(0, this.depth - 1), this.depth === 0 && this.hideOverlay());
|
|
5355
5611
|
}
|
|
5356
5612
|
async onDrop(e) {
|
|
5357
5613
|
e.preventDefault(), this.depth = 0, this.hideOverlay();
|
|
5358
5614
|
let t = e.dataTransfer?.files?.[0];
|
|
5359
5615
|
if (t) try {
|
|
5360
|
-
let e =
|
|
5616
|
+
let e = na(await t.text());
|
|
5361
5617
|
if (e.data.length === 0) throw Error(`No valid OHLCV rows found in "${t.name}"`);
|
|
5362
5618
|
this.callbacks.onData(e.data, e, t);
|
|
5363
5619
|
} catch (e) {
|
|
@@ -5388,12 +5644,12 @@ var Hi = class {
|
|
|
5388
5644
|
this.overlay?.remove(), this.overlay = null;
|
|
5389
5645
|
}
|
|
5390
5646
|
};
|
|
5391
|
-
function
|
|
5647
|
+
function pa(e) {
|
|
5392
5648
|
return e.dataTransfer?.types?.includes("Files") ?? !1;
|
|
5393
5649
|
}
|
|
5394
5650
|
//#endregion
|
|
5395
5651
|
//#region src/state/layoutStorage.ts
|
|
5396
|
-
function
|
|
5652
|
+
function ma(e) {
|
|
5397
5653
|
let t = {
|
|
5398
5654
|
id: e.id,
|
|
5399
5655
|
name: e.name,
|
|
@@ -5401,11 +5657,11 @@ function Wi(e) {
|
|
|
5401
5657
|
};
|
|
5402
5658
|
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;
|
|
5403
5659
|
}
|
|
5404
|
-
var
|
|
5405
|
-
function
|
|
5660
|
+
var ha = (e, t) => t.updatedAt - e.updatedAt;
|
|
5661
|
+
function ga(e) {
|
|
5406
5662
|
if (typeof e != "object" || !e) return null;
|
|
5407
5663
|
let t = e;
|
|
5408
|
-
return typeof t.id != "string" || !t.id || typeof t.name != "string" || typeof t.updatedAt != "number" || !Number.isFinite(t.updatedAt) ? null :
|
|
5664
|
+
return typeof t.id != "string" || !t.id || typeof t.name != "string" || typeof t.updatedAt != "number" || !Number.isFinite(t.updatedAt) ? null : ma({
|
|
5409
5665
|
id: t.id,
|
|
5410
5666
|
name: t.name,
|
|
5411
5667
|
updatedAt: t.updatedAt,
|
|
@@ -5414,17 +5670,17 @@ function Ki(e) {
|
|
|
5414
5670
|
kind: typeof t.kind == "string" ? t.kind : void 0
|
|
5415
5671
|
});
|
|
5416
5672
|
}
|
|
5417
|
-
function
|
|
5418
|
-
let t =
|
|
5673
|
+
function _a(e) {
|
|
5674
|
+
let t = ga(e), n = t ? e.content : void 0;
|
|
5419
5675
|
return t && typeof n == "string" ? {
|
|
5420
5676
|
...t,
|
|
5421
5677
|
content: n
|
|
5422
5678
|
} : null;
|
|
5423
5679
|
}
|
|
5424
|
-
function
|
|
5680
|
+
function va(e = []) {
|
|
5425
5681
|
let t = new Map(e.map((e) => [e.id, { ...e }]));
|
|
5426
5682
|
return {
|
|
5427
|
-
list: () => [...t.values()].map(
|
|
5683
|
+
list: () => [...t.values()].map(ma).sort(ha),
|
|
5428
5684
|
load: (e) => {
|
|
5429
5685
|
let n = t.get(e);
|
|
5430
5686
|
return n ? { ...n } : null;
|
|
@@ -5437,7 +5693,7 @@ function Ji(e = []) {
|
|
|
5437
5693
|
}
|
|
5438
5694
|
};
|
|
5439
5695
|
}
|
|
5440
|
-
function
|
|
5696
|
+
function ya(e = "tcw:layouts:") {
|
|
5441
5697
|
let t = `${e}index`, n = (t) => `${e}item:${t}`, r = () => {
|
|
5442
5698
|
let e;
|
|
5443
5699
|
try {
|
|
@@ -5445,10 +5701,10 @@ function Yi(e = "tcw:layouts:") {
|
|
|
5445
5701
|
} catch {
|
|
5446
5702
|
return [];
|
|
5447
5703
|
}
|
|
5448
|
-
return Array.isArray(e) ? e.map(
|
|
5704
|
+
return Array.isArray(e) ? e.map(ga).filter((e) => e !== null) : [];
|
|
5449
5705
|
}, i = (e) => localStorage.setItem(t, JSON.stringify(e));
|
|
5450
5706
|
return {
|
|
5451
|
-
list: () => r().sort(
|
|
5707
|
+
list: () => r().sort(ha),
|
|
5452
5708
|
load: (e) => {
|
|
5453
5709
|
let t = r().find((t) => t.id === e), i = t ? localStorage.getItem(n(e)) : null;
|
|
5454
5710
|
return t && i !== null ? {
|
|
@@ -5457,7 +5713,7 @@ function Yi(e = "tcw:layouts:") {
|
|
|
5457
5713
|
} : null;
|
|
5458
5714
|
},
|
|
5459
5715
|
save: (e) => {
|
|
5460
|
-
localStorage.setItem(n(e.id), e.content), i([...r().filter((t) => t.id !== e.id),
|
|
5716
|
+
localStorage.setItem(n(e.id), e.content), i([...r().filter((t) => t.id !== e.id), ma(e)]);
|
|
5461
5717
|
},
|
|
5462
5718
|
remove: (e) => {
|
|
5463
5719
|
i(r().filter((t) => t.id !== e)), localStorage.removeItem(n(e));
|
|
@@ -5466,14 +5722,14 @@ function Yi(e = "tcw:layouts:") {
|
|
|
5466
5722
|
}
|
|
5467
5723
|
//#endregion
|
|
5468
5724
|
//#region src/state/LayoutSession.ts
|
|
5469
|
-
var
|
|
5470
|
-
function
|
|
5725
|
+
var ba = 80;
|
|
5726
|
+
function xa(e) {
|
|
5471
5727
|
return e.replace(/\s+/g, " ").trim().slice(0, 80).trim() || null;
|
|
5472
5728
|
}
|
|
5473
|
-
function
|
|
5729
|
+
function Sa() {
|
|
5474
5730
|
return globalThis.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
5475
5731
|
}
|
|
5476
|
-
function
|
|
5732
|
+
function Ca(e) {
|
|
5477
5733
|
let { id: t, name: n, symbol: r, timeframe: i, updatedAt: a, kind: o } = e;
|
|
5478
5734
|
return {
|
|
5479
5735
|
id: t,
|
|
@@ -5484,7 +5740,7 @@ function $i(e) {
|
|
|
5484
5740
|
...o === void 0 ? {} : { kind: o }
|
|
5485
5741
|
};
|
|
5486
5742
|
}
|
|
5487
|
-
var
|
|
5743
|
+
var wa = class {
|
|
5488
5744
|
currentLayout = null;
|
|
5489
5745
|
savedContent = null;
|
|
5490
5746
|
dirty = !1;
|
|
@@ -5500,7 +5756,7 @@ var ea = class {
|
|
|
5500
5756
|
now;
|
|
5501
5757
|
newId;
|
|
5502
5758
|
constructor(e, t, n = {}) {
|
|
5503
|
-
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 ??
|
|
5759
|
+
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 ?? Sa;
|
|
5504
5760
|
}
|
|
5505
5761
|
current() {
|
|
5506
5762
|
return this.currentLayout;
|
|
@@ -5516,7 +5772,7 @@ var ea = class {
|
|
|
5516
5772
|
}
|
|
5517
5773
|
async list() {
|
|
5518
5774
|
let e = await this.storage.list();
|
|
5519
|
-
return Array.isArray(e) ? e.map(
|
|
5775
|
+
return Array.isArray(e) ? e.map(ga).filter((e) => e !== null && (e.kind ?? "chart") === this.kind).sort((e, t) => t.updatedAt - e.updatedAt) : [];
|
|
5520
5776
|
}
|
|
5521
5777
|
save() {
|
|
5522
5778
|
return this.queue(() => {
|
|
@@ -5525,12 +5781,12 @@ var ea = class {
|
|
|
5525
5781
|
});
|
|
5526
5782
|
}
|
|
5527
5783
|
saveAs(e) {
|
|
5528
|
-
let t =
|
|
5784
|
+
let t = xa(e);
|
|
5529
5785
|
return t ? this.queue(() => this.write(this.newId(), t)) : Promise.reject(/* @__PURE__ */ Error("A layout needs a name"));
|
|
5530
5786
|
}
|
|
5531
5787
|
open(e) {
|
|
5532
5788
|
return this.queue(async () => {
|
|
5533
|
-
let t =
|
|
5789
|
+
let t = _a(await this.storage.load(e));
|
|
5534
5790
|
if (!t || t.id !== e || (t.kind ?? "chart") !== this.kind || this.destroyed) return !1;
|
|
5535
5791
|
this.cancelTimer(), this.applying++;
|
|
5536
5792
|
try {
|
|
@@ -5540,13 +5796,13 @@ var ea = class {
|
|
|
5540
5796
|
} finally {
|
|
5541
5797
|
this.applying--;
|
|
5542
5798
|
}
|
|
5543
|
-
return this.cancelTimer(), this.currentLayout =
|
|
5799
|
+
return this.cancelTimer(), this.currentLayout = Ca(t), this.savedContent = this.host.capture().content, this.dirty = !1, this.notify(), !0;
|
|
5544
5800
|
});
|
|
5545
5801
|
}
|
|
5546
5802
|
rename(e, t) {
|
|
5547
|
-
let n =
|
|
5803
|
+
let n = xa(t);
|
|
5548
5804
|
return n ? this.queue(async () => {
|
|
5549
|
-
let t =
|
|
5805
|
+
let t = _a(await this.storage.load(e));
|
|
5550
5806
|
!t || t.id !== e || (await this.storage.save({
|
|
5551
5807
|
...t,
|
|
5552
5808
|
name: n
|
|
@@ -5624,7 +5880,7 @@ var ea = class {
|
|
|
5624
5880
|
content: n.content
|
|
5625
5881
|
};
|
|
5626
5882
|
await this.storage.save(r);
|
|
5627
|
-
let i =
|
|
5883
|
+
let i = Ca(r);
|
|
5628
5884
|
return this.currentLayout = i, this.savedContent = n.content, this.dirty = !1, this.notify(), i;
|
|
5629
5885
|
}
|
|
5630
5886
|
forget() {
|
|
@@ -5645,6 +5901,6 @@ var ea = class {
|
|
|
5645
5901
|
}
|
|
5646
5902
|
};
|
|
5647
5903
|
//#endregion
|
|
5648
|
-
export {
|
|
5904
|
+
export { mr as C, Pn as D, R as E, dn as O, _r as S, B as T, Fr as _, va as a, G as b, Oi as c, ii as d, ai as f, Pr as g, Ir as h, ya as i, vi as l, Lr as m, ba as n, fa as o, Rr as p, xa as r, na as s, wa as t, _i as u, Mr as v, fr as w, Sr as x, Nr as y };
|
|
5649
5905
|
|
|
5650
|
-
//# sourceMappingURL=LayoutSession-
|
|
5906
|
+
//# sourceMappingURL=LayoutSession-BOQCN6yY.js.map
|