@tradecanvas/chart 1.64.0 → 1.66.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/Chart.d.ts +7 -1
- package/dist/Chart.d.ts.map +1 -1
- package/dist/{LayoutSession-DZQnpjh_.js → LayoutSession-BQVAQhdo.js} +417 -417
- package/dist/{LayoutSession-DZQnpjh_.js.map → LayoutSession-BQVAQhdo.js.map} +1 -1
- package/dist/{LayoutSession-CQPAkjfQ.cjs → LayoutSession-Bgd4YHx7.cjs} +2 -2
- package/dist/{LayoutSession-CQPAkjfQ.cjs.map → LayoutSession-Bgd4YHx7.cjs.map} +1 -1
- package/dist/i18n-BsstZ9md.cjs +2 -0
- package/dist/i18n-BsstZ9md.cjs.map +1 -0
- package/dist/{i18n-Cl_yo051.js → i18n-DUmd4Z_r.js} +15 -1
- package/dist/i18n-DUmd4Z_r.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/widget/ChartWidget.d.ts.map +1 -1
- package/dist/widget/WidgetDrawingSettings.d.ts +2 -0
- package/dist/widget/WidgetDrawingSettings.d.ts.map +1 -1
- package/dist/widget/WidgetObjectTree.d.ts +36 -0
- package/dist/widget/WidgetObjectTree.d.ts.map +1 -1
- package/dist/widget/drawingSettingsTabs.d.ts.map +1 -1
- package/dist/widget/index.cjs +39 -21
- package/dist/widget/index.cjs.map +1 -1
- package/dist/widget/index.js +1163 -1050
- package/dist/widget/index.js.map +1 -1
- package/dist/widget/locales/ar.d.ts.map +1 -1
- package/dist/widget/locales/cs.d.ts.map +1 -1
- package/dist/widget/locales/da.d.ts.map +1 -1
- package/dist/widget/locales/de.d.ts.map +1 -1
- package/dist/widget/locales/el.d.ts.map +1 -1
- package/dist/widget/locales/en.d.ts +7 -0
- package/dist/widget/locales/en.d.ts.map +1 -1
- package/dist/widget/locales/es.d.ts.map +1 -1
- package/dist/widget/locales/et.d.ts.map +1 -1
- package/dist/widget/locales/fa.d.ts.map +1 -1
- package/dist/widget/locales/fr.d.ts.map +1 -1
- package/dist/widget/locales/he.d.ts.map +1 -1
- package/dist/widget/locales/hu.d.ts.map +1 -1
- package/dist/widget/locales/id.d.ts.map +1 -1
- package/dist/widget/locales/index.cjs +1 -1
- package/dist/widget/locales/index.cjs.map +1 -1
- package/dist/widget/locales/index.js +197 -1
- package/dist/widget/locales/index.js.map +1 -1
- package/dist/widget/locales/it.d.ts.map +1 -1
- package/dist/widget/locales/ja.d.ts.map +1 -1
- package/dist/widget/locales/ko.d.ts.map +1 -1
- package/dist/widget/locales/ms.d.ts.map +1 -1
- package/dist/widget/locales/nb.d.ts.map +1 -1
- package/dist/widget/locales/nl.d.ts.map +1 -1
- package/dist/widget/locales/pl.d.ts.map +1 -1
- package/dist/widget/locales/pt.d.ts.map +1 -1
- package/dist/widget/locales/ro.d.ts.map +1 -1
- package/dist/widget/locales/ru.d.ts.map +1 -1
- package/dist/widget/locales/sk.d.ts.map +1 -1
- package/dist/widget/locales/sv.d.ts.map +1 -1
- package/dist/widget/locales/th.d.ts.map +1 -1
- package/dist/widget/locales/tr.d.ts.map +1 -1
- package/dist/widget/locales/vi.d.ts.map +1 -1
- package/dist/widget/locales/zh.d.ts.map +1 -1
- package/dist/widget/locales/zhHant.d.ts.map +1 -1
- package/dist/widget/widgetConfig.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/i18n-Cl_yo051.js.map +0 -1
- package/dist/i18n-DPhG3PTA.cjs +0 -2
- package/dist/i18n-DPhG3PTA.cjs.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { DARK_THEME as e, DEFAULT_PANEL_HEIGHT as t, LIGHT_THEME as n, LayerType as r, MIN_PANEL_HEIGHT as i, 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
|
|
2
|
-
import { AlertDragHandler as
|
|
1
|
+
import { DARK_THEME as e, DEFAULT_PANEL_HEIGHT as t, LIGHT_THEME as n, LayerType as r, MIN_PANEL_HEIGHT as i, 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 O, SYMBOL_ZONE_WAIT_MS as ut, Screenshot as k, SelectionBoxOverlay as dt, SessionBreaks as ft, SessionShading as pt, SignalMarkerManager as mt, SpreadIndicator as ht, StepLineRenderer as gt, StreamManager as _t, SymbolSeriesStore as vt, TimeAxis as yt, TradeZoneManager as bt, TradingManager as xt, TradingRenderer as St, UndoRedoManager as Ct, Viewport as wt, VolumeCandleRenderer as Tt, VolumeProfileRenderer as Et, VolumeRenderer as Dt, Watermark as Ot, ZoomHandler as kt, axisTimes as A, barTimeStepMs as At, findDominantSwing as jt, gpuContextsLeft as Mt, isPriceLevelAlert as Nt, isRegularSession as Pt, loadWebGL as Ft, mergeSessionHours as It, pointAndFigureColumns as Lt, rangePresetStart as Rt, readAlertOptions as zt, registerBuiltInDrawingTools as Bt, registerBuiltInIndicators as Vt, servesTimeframe as j, sourceParam as M, timestampToBarIndex as N, toHeikinAshi as Ht, toKagi as Ut, toLineBreak as Wt, toRangeBars as Gt, toRenko as Kt, whenGpuContextFree as qt, withResampling as P, xToBarIndex as Jt, xToTime as F, yToPrice as Yt } from "@tradecanvas/core";
|
|
3
3
|
//#region src/regularHours.ts
|
|
4
|
-
var
|
|
5
|
-
function
|
|
6
|
-
let n =
|
|
4
|
+
var Xt = 864e5, Zt = 10;
|
|
5
|
+
function Qt(e, t) {
|
|
6
|
+
let n = C(e);
|
|
7
7
|
if (!n || !y(n) || t.length < 2) return null;
|
|
8
8
|
let r = (e?.sessions ?? []).flatMap((e) => {
|
|
9
|
-
let t =
|
|
9
|
+
let t = S(e.start), n = S(e.end);
|
|
10
10
|
return t === null || n === null ? [] : [{
|
|
11
11
|
startMinute: t,
|
|
12
12
|
endMinute: n
|
|
@@ -14,11 +14,11 @@ function en(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 - Zt); 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 < Xt)) return null;
|
|
22
22
|
let o = {
|
|
23
23
|
timeZone: n,
|
|
24
24
|
windows: r,
|
|
@@ -29,19 +29,19 @@ function en(e, t) {
|
|
|
29
29
|
}
|
|
30
30
|
//#endregion
|
|
31
31
|
//#region src/chartA11y.ts
|
|
32
|
-
var
|
|
32
|
+
var $t = {
|
|
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
|
-
}, I = (e, t) => e.replace(/\{(\w+)\}/g, (e, n) => n in t ? String(t[n]) : e),
|
|
39
|
+
}, I = (e, t) => e.replace(/\{(\w+)\}/g, (e, n) => n in t ? String(t[n]) : e), en = [
|
|
40
40
|
"role",
|
|
41
41
|
"aria-roledescription",
|
|
42
42
|
"aria-label",
|
|
43
43
|
"aria-describedby"
|
|
44
|
-
],
|
|
44
|
+
], tn = 400, nn = 1e3, rn = class {
|
|
45
45
|
live;
|
|
46
46
|
help;
|
|
47
47
|
labels;
|
|
@@ -55,20 +55,20 @@ var tn = {
|
|
|
55
55
|
};
|
|
56
56
|
constructor(e, t, n = {}) {
|
|
57
57
|
this.container = e, this.source = t, this.labels = {
|
|
58
|
-
|
|
58
|
+
...$t,
|
|
59
59
|
...n
|
|
60
60
|
};
|
|
61
|
-
for (let t of
|
|
62
|
-
e.setAttribute("role", "application"), this.help =
|
|
61
|
+
for (let t of en) this.before.set(t, e.getAttribute(t));
|
|
62
|
+
e.setAttribute("role", "application"), this.help = an("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 = an("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
|
+
...$t,
|
|
67
67
|
...e
|
|
68
68
|
}, this.applyLabels();
|
|
69
69
|
}
|
|
70
70
|
refresh(e = !1) {
|
|
71
|
-
let t =
|
|
71
|
+
let t = nn - (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 tn = {
|
|
|
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
|
+
}, tn);
|
|
84
84
|
}
|
|
85
85
|
readBar(e) {
|
|
86
86
|
let t = this.source.bars();
|
|
@@ -99,7 +99,7 @@ var tn = {
|
|
|
99
99
|
high: a(i.high),
|
|
100
100
|
low: a(i.low),
|
|
101
101
|
close: a(i.close),
|
|
102
|
-
volume:
|
|
102
|
+
volume: on(i.volume ?? 0)
|
|
103
103
|
}));
|
|
104
104
|
}
|
|
105
105
|
destroy() {
|
|
@@ -140,7 +140,7 @@ var tn = {
|
|
|
140
140
|
this.live.textContent = e;
|
|
141
141
|
}
|
|
142
142
|
};
|
|
143
|
-
function
|
|
143
|
+
function an(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 sn(e, t) {
|
|
|
154
154
|
border: "0"
|
|
155
155
|
}), n;
|
|
156
156
|
}
|
|
157
|
-
function
|
|
157
|
+
function on(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 sn = 3, cn = {
|
|
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 ln(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, cn[e] ?? sn).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,52 +173,52 @@ function dn(e, t, n, r) {
|
|
|
173
173
|
}
|
|
174
174
|
//#endregion
|
|
175
175
|
//#region src/charts/ChartTypeStrategy.ts
|
|
176
|
-
function
|
|
176
|
+
function un(e) {
|
|
177
177
|
switch (e) {
|
|
178
178
|
case "candlestick":
|
|
179
179
|
case "heikinAshi":
|
|
180
180
|
case "lineBreak":
|
|
181
|
-
case "rangeBars": return new
|
|
182
|
-
case "line": return new
|
|
183
|
-
case "area": return new
|
|
184
|
-
case "bar": return new
|
|
185
|
-
case "hollowCandle": return new
|
|
186
|
-
case "baseline": return new
|
|
187
|
-
case "renko": return new
|
|
188
|
-
case "kagi": return new
|
|
189
|
-
case "pointAndFigure": return new
|
|
190
|
-
case "volumeCandles": return new
|
|
191
|
-
case "equivolume": return new
|
|
192
|
-
case "hlcArea": return new
|
|
193
|
-
case "stepLine": return new
|
|
194
|
-
case "lineWithMarkers": return new
|
|
195
|
-
case "hiLo": return new
|
|
196
|
-
default: return new
|
|
181
|
+
case "rangeBars": return new xe();
|
|
182
|
+
case "line": return new Ge();
|
|
183
|
+
case "area": return new ge();
|
|
184
|
+
case "bar": return new ye();
|
|
185
|
+
case "hollowCandle": return new Be();
|
|
186
|
+
case "baseline": return new be();
|
|
187
|
+
case "renko": return new ot();
|
|
188
|
+
case "kagi": return new Ue();
|
|
189
|
+
case "pointAndFigure": return new tt();
|
|
190
|
+
case "volumeCandles": return new Tt();
|
|
191
|
+
case "equivolume": return new Fe();
|
|
192
|
+
case "hlcArea": return new Re();
|
|
193
|
+
case "stepLine": return new gt();
|
|
194
|
+
case "lineWithMarkers": return new Ke();
|
|
195
|
+
case "hiLo": return new ze();
|
|
196
|
+
default: return new xe();
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
|
-
function
|
|
199
|
+
function dn(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 Ht(t);
|
|
203
203
|
case "renko": {
|
|
204
204
|
let e = n.renko?.boxSize;
|
|
205
|
-
return typeof e == "number" ?
|
|
205
|
+
return typeof e == "number" ? Kt(t, { brickSize: e }, i) : Kt(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
|
|
215
|
-
rangeSize:
|
|
211
|
+
case "lineBreak": return Wt(t, n.lineBreak?.lines ?? 3);
|
|
212
|
+
case "kagi": return Ut(t, n.kagi?.reversal ?? 4, n.kagi?.reversalType ?? "percent", i);
|
|
213
|
+
case "pointAndFigure": return pn(t, n, i).columns;
|
|
214
|
+
case "rangeBars": return Gt(t, {
|
|
215
|
+
rangeSize: Cn(t, n, r),
|
|
216
216
|
includeForming: !0
|
|
217
217
|
}, i);
|
|
218
218
|
default: return t;
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
|
-
function
|
|
221
|
+
function fn(e) {
|
|
222
222
|
switch (e) {
|
|
223
223
|
case "heikinAshi":
|
|
224
224
|
case "renko":
|
|
@@ -230,71 +230,71 @@ function mn(e) {
|
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
232
|
function L(e) {
|
|
233
|
-
return e !== "heikinAshi" &&
|
|
233
|
+
return e !== "heikinAshi" && fn(e);
|
|
234
234
|
}
|
|
235
|
-
function
|
|
236
|
-
return Lt(e,
|
|
235
|
+
function pn(e, t = {}, n) {
|
|
236
|
+
return Lt(e, gn(e, t), t.pointAndFigure?.reversal ?? 3, n);
|
|
237
237
|
}
|
|
238
|
-
var
|
|
239
|
-
function
|
|
238
|
+
var mn = 50, hn = .01;
|
|
239
|
+
function gn(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 = _n(e, e.length > 1 ? e.length - 1 : e.length);
|
|
243
|
+
return r > 0 ? Sn(te(r / mn, !0)) : Math.abs(e[e.length - 1]?.close ?? 0) * hn || 1;
|
|
244
244
|
}
|
|
245
|
-
function
|
|
245
|
+
function _n(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
|
|
252
|
-
function
|
|
251
|
+
var vn = 100, yn = 3, bn = .01, xn = 15, Sn = (e) => Number(e.toPrecision(xn));
|
|
252
|
+
function Cn(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
|
|
255
|
+
let i = e.length >= yn ? Tn(e) : 0, a = Math.abs(e[e.length - 1]?.close ?? 0);
|
|
256
|
+
return On(Sn(te(i > 0 ? i : a * bn || 1, !0)), n);
|
|
257
257
|
}
|
|
258
|
-
function
|
|
258
|
+
function wn(e) {
|
|
259
259
|
let t = e.length - 1;
|
|
260
260
|
return {
|
|
261
|
-
from: Math.max(0, t -
|
|
261
|
+
from: Math.max(0, t - vn),
|
|
262
262
|
end: t
|
|
263
263
|
};
|
|
264
264
|
}
|
|
265
|
-
function
|
|
266
|
-
let { from: t, end: n } =
|
|
265
|
+
function Tn(e) {
|
|
266
|
+
let { from: t, end: n } = wn(e), r = 0;
|
|
267
267
|
for (let i = t; i < n; i++) {
|
|
268
268
|
let { high: t, low: n } = e[i], a = i > 0 ? e[i - 1].close : n;
|
|
269
269
|
r += Math.max(t - n, Math.abs(t - a), Math.abs(n - a));
|
|
270
270
|
}
|
|
271
271
|
return n > t ? r / (n - t) : 0;
|
|
272
272
|
}
|
|
273
|
-
function
|
|
274
|
-
let { from: n, end: r } =
|
|
273
|
+
function En(e, t) {
|
|
274
|
+
let { from: n, end: r } = wn(e);
|
|
275
275
|
if (r <= n) return t(e[e.length - 1]?.close ?? 0);
|
|
276
276
|
let i = -Infinity, a = Infinity;
|
|
277
277
|
for (let t = n; t < r; t++) i = Math.max(i, e[t].high), a = Math.min(a, e[t].low);
|
|
278
|
-
return
|
|
278
|
+
return Dn(t(i), t(a));
|
|
279
279
|
}
|
|
280
|
-
function
|
|
280
|
+
function Dn(e, t) {
|
|
281
281
|
return e === void 0 ? t : t === void 0 ? e : Math.max(e, t);
|
|
282
282
|
}
|
|
283
|
-
function
|
|
284
|
-
return t === void 0 || !(t > 0) ? e :
|
|
283
|
+
function On(e, t) {
|
|
284
|
+
return t === void 0 || !(t > 0) ? e : Sn(Math.max(1, Math.round(e / t)) * t);
|
|
285
285
|
}
|
|
286
|
-
function
|
|
286
|
+
function kn(e, t) {
|
|
287
287
|
let n = t?.(e);
|
|
288
|
-
return n ? n.createRenderer() :
|
|
288
|
+
return n ? n.createRenderer() : un(e);
|
|
289
289
|
}
|
|
290
|
-
function
|
|
290
|
+
function An(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) : dn(e, t, r, i, a);
|
|
294
294
|
}
|
|
295
295
|
//#endregion
|
|
296
296
|
//#region src/state/AutoSaveScheduler.ts
|
|
297
|
-
var
|
|
297
|
+
var jn = class {
|
|
298
298
|
timer = null;
|
|
299
299
|
delayMs = 0;
|
|
300
300
|
key = null;
|
|
@@ -329,7 +329,7 @@ function R(e) {
|
|
|
329
329
|
let { open: t, high: n, low: r, close: i } = e;
|
|
330
330
|
return !(!isFinite(t) || !isFinite(n) || !isFinite(r) || !isFinite(i) || t < 0 || n < 0 || r < 0 || i < 0 || n < r || e.volume !== void 0 && (!isFinite(e.volume) || e.volume < 0));
|
|
331
331
|
}
|
|
332
|
-
function
|
|
332
|
+
function Mn(e) {
|
|
333
333
|
return e.volume !== void 0 && e.high >= e.open && e.high >= e.close && e.low <= e.open && e.low <= e.close;
|
|
334
334
|
}
|
|
335
335
|
function z(e) {
|
|
@@ -343,24 +343,24 @@ function z(e) {
|
|
|
343
343
|
function B(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 Nn(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 Pn = {
|
|
354
354
|
index: -1,
|
|
355
355
|
changed: !1
|
|
356
356
|
};
|
|
357
|
-
function
|
|
357
|
+
function Fn(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 In(e, t) {
|
|
363
|
+
let n = Fn(e, t.time);
|
|
364
364
|
return n === t.time ? t : {
|
|
365
365
|
...t,
|
|
366
366
|
time: n
|
|
@@ -369,7 +369,7 @@ function Rn(e, t) {
|
|
|
369
369
|
var V = class {
|
|
370
370
|
data = [];
|
|
371
371
|
withSeriesTime(e) {
|
|
372
|
-
return
|
|
372
|
+
return In(this.data, e);
|
|
373
373
|
}
|
|
374
374
|
getData() {
|
|
375
375
|
return this.data;
|
|
@@ -378,7 +378,7 @@ var V = class {
|
|
|
378
378
|
let t = [];
|
|
379
379
|
for (let n = 0; n < e.length; n++) {
|
|
380
380
|
let r = e[n];
|
|
381
|
-
R(r) && t.push(
|
|
381
|
+
R(r) && t.push(Mn(r) ? r : z(r));
|
|
382
382
|
}
|
|
383
383
|
this.data = t;
|
|
384
384
|
}
|
|
@@ -387,7 +387,7 @@ var V = class {
|
|
|
387
387
|
for (let r = 0; r < e.length; r++) {
|
|
388
388
|
if (!R(e[r])) continue;
|
|
389
389
|
let i = this.withSeriesTime(e[r]);
|
|
390
|
-
i.time >= t || n.push(
|
|
390
|
+
i.time >= t || n.push(Mn(i) ? i : z(i));
|
|
391
391
|
}
|
|
392
392
|
if (n.length === 0) return 0;
|
|
393
393
|
n.sort((e, t) => e.time - t.time);
|
|
@@ -408,9 +408,9 @@ var V = class {
|
|
|
408
408
|
this.data[this.data.length - 1] = t;
|
|
409
409
|
}
|
|
410
410
|
replaceBar(e) {
|
|
411
|
-
if (!R(e)) return
|
|
412
|
-
let t = this.withSeriesTime(e), n =
|
|
413
|
-
if (n < 0) return
|
|
411
|
+
if (!R(e)) return Pn;
|
|
412
|
+
let t = this.withSeriesTime(e), n = Nn(this.data, t.time);
|
|
413
|
+
if (n < 0) return Pn;
|
|
414
414
|
let r = z(t);
|
|
415
415
|
return B(this.data[n], r) ? {
|
|
416
416
|
index: n,
|
|
@@ -440,7 +440,7 @@ function U(e, t) {
|
|
|
440
440
|
let r = b(t.time), i = b(n.time);
|
|
441
441
|
return r > i ? "append" : r === i ? "update" : "stale";
|
|
442
442
|
}
|
|
443
|
-
function
|
|
443
|
+
function Ln(e) {
|
|
444
444
|
return [
|
|
445
445
|
e.time,
|
|
446
446
|
e.open,
|
|
@@ -449,7 +449,7 @@ function zn(e) {
|
|
|
449
449
|
e.close
|
|
450
450
|
].every(Number.isFinite);
|
|
451
451
|
}
|
|
452
|
-
var
|
|
452
|
+
var Rn = class {
|
|
453
453
|
shown = new V();
|
|
454
454
|
whole = null;
|
|
455
455
|
aside = null;
|
|
@@ -489,7 +489,7 @@ var Bn = class {
|
|
|
489
489
|
}
|
|
490
490
|
let t = null, n = e;
|
|
491
491
|
if (this.whole) {
|
|
492
|
-
let r = this.whole[0]?.time, i = /* @__PURE__ */ new Set(), a = e.filter(
|
|
492
|
+
let r = this.whole[0]?.time, i = /* @__PURE__ */ new Set(), a = e.filter(Ln).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
493
|
this.whole = [...a, ...this.whole];
|
|
494
494
|
let o = this.hoursFilter(this.whole);
|
|
495
495
|
t = a.length, n = o ? a.filter((e) => o(e.time)) : a;
|
|
@@ -501,8 +501,8 @@ var Bn = class {
|
|
|
501
501
|
};
|
|
502
502
|
}
|
|
503
503
|
mergeSnapshot(e) {
|
|
504
|
-
if (this.aside) return this.aside.setData(
|
|
505
|
-
let t =
|
|
504
|
+
if (this.aside) return this.aside.setData(zn(this.aside.getData(), e) ?? e), this.onLiveChange({ kind: "series" }), !0;
|
|
505
|
+
let t = zn(this.whole ?? this.shown.getData(), e);
|
|
506
506
|
return t ? (this.shown.setData(this.regularOnly(t)), !0) : !1;
|
|
507
507
|
}
|
|
508
508
|
refilter() {
|
|
@@ -559,7 +559,7 @@ var Bn = class {
|
|
|
559
559
|
mergeTick(e) {
|
|
560
560
|
if (this.aside) return this.aside.updateLastBarFromTick(e), this.wrote("aside", !1);
|
|
561
561
|
let t = this.whole ? this.hoursFilter(this.whole) : null;
|
|
562
|
-
if (t && this.whole && !t(
|
|
562
|
+
if (t && this.whole && !t(Fn(this.whole, e.time))) return this.wrote("hidden", !1);
|
|
563
563
|
let n = this.shown.getLength();
|
|
564
564
|
this.shown.updateLastBarFromTick(e);
|
|
565
565
|
let r = this.whole, i = this.shown.getData()[this.shown.getLength() - 1];
|
|
@@ -602,7 +602,7 @@ var Bn = class {
|
|
|
602
602
|
});
|
|
603
603
|
}
|
|
604
604
|
if (!R(e)) return H;
|
|
605
|
-
let t = this.inSeriesUnit(e), n = this.whole, r = n ?
|
|
605
|
+
let t = this.inSeriesUnit(e), n = this.whole, r = n ? Nn(n, t.time) : -1;
|
|
606
606
|
if (n) {
|
|
607
607
|
if (r < 0 || !R(n[r])) return H;
|
|
608
608
|
let e = this.hoursFilter(n);
|
|
@@ -636,7 +636,7 @@ var Bn = class {
|
|
|
636
636
|
this.shown.updateLastBar(e);
|
|
637
637
|
}
|
|
638
638
|
inSeriesUnit(e) {
|
|
639
|
-
return
|
|
639
|
+
return In(this.whole ?? this.shown.getData(), e);
|
|
640
640
|
}
|
|
641
641
|
replaceHidden(e, t, n) {
|
|
642
642
|
let r = z(n), i = !B(e[t], r);
|
|
@@ -673,14 +673,14 @@ var Bn = class {
|
|
|
673
673
|
return !r || r(e.time);
|
|
674
674
|
}
|
|
675
675
|
};
|
|
676
|
-
function
|
|
676
|
+
function zn(e, t) {
|
|
677
677
|
let n = t[0]?.time, r = 0;
|
|
678
678
|
for (; n !== void 0 && r < e.length && e[r].time < n;) r++;
|
|
679
679
|
return r === 0 || r === e.length ? null : e.slice(0, r).concat(t);
|
|
680
680
|
}
|
|
681
681
|
//#endregion
|
|
682
682
|
//#region src/HistoryPager.ts
|
|
683
|
-
var
|
|
683
|
+
var Bn = 5e3, Vn = 6e4, Hn = 500, Un = class {
|
|
684
684
|
loader = null;
|
|
685
685
|
pageSize = 500;
|
|
686
686
|
loading = !1;
|
|
@@ -732,7 +732,7 @@ var Hn = 5e3, Un = 6e4, Wn = 500, Gn = class {
|
|
|
732
732
|
try {
|
|
733
733
|
r = await e(t, this.pageSize);
|
|
734
734
|
} catch (e) {
|
|
735
|
-
return n === this.seq ? (this.loading = !1, this.failures++, this.retryAt = this.now() + Math.min(
|
|
735
|
+
return n === this.seq ? (this.loading = !1, this.failures++, this.retryAt = this.now() + Math.min(Vn, Bn * 2 ** (this.failures - 1)), this.emit({
|
|
736
736
|
state: "error",
|
|
737
737
|
count: 0,
|
|
738
738
|
error: e instanceof Error ? e.message : String(e)
|
|
@@ -765,10 +765,10 @@ var Hn = 5e3, Un = 6e4, Wn = 500, Gn = class {
|
|
|
765
765
|
};
|
|
766
766
|
//#endregion
|
|
767
767
|
//#region src/ThemeManager.ts
|
|
768
|
-
function
|
|
768
|
+
function Wn(e, t) {
|
|
769
769
|
return e.family === t.family && e.sizeSmall === t.sizeSmall && e.sizeMedium === t.sizeMedium && e.sizeLarge === t.sizeLarge;
|
|
770
770
|
}
|
|
771
|
-
var
|
|
771
|
+
var Gn = class t {
|
|
772
772
|
base;
|
|
773
773
|
shape = null;
|
|
774
774
|
font = null;
|
|
@@ -787,13 +787,13 @@ var qn = class t {
|
|
|
787
787
|
return i;
|
|
788
788
|
}
|
|
789
789
|
getTheme() {
|
|
790
|
-
return this.effective ??=
|
|
790
|
+
return this.effective ??= ce(this.base, this.chartType, this.merged()), this.effective;
|
|
791
791
|
}
|
|
792
792
|
getBaseTheme() {
|
|
793
793
|
return this.base;
|
|
794
794
|
}
|
|
795
795
|
setTheme(e) {
|
|
796
|
-
let n = t.read(e), r = this.font !== null &&
|
|
796
|
+
let n = t.read(e), r = this.font !== null && Wn(n.font, this.base.font);
|
|
797
797
|
this.base = n, r || (this.themeFont = n.font), this.shape && (this.base = {
|
|
798
798
|
...this.base,
|
|
799
799
|
shape: {
|
|
@@ -875,7 +875,7 @@ var qn = class t {
|
|
|
875
875
|
};
|
|
876
876
|
//#endregion
|
|
877
877
|
//#region src/style/styleOptions.ts
|
|
878
|
-
function
|
|
878
|
+
function Kn(e, t) {
|
|
879
879
|
return t ? {
|
|
880
880
|
...t.visible === void 0 ? {} : { [`crosshair.${e}.visible`]: t.visible },
|
|
881
881
|
...t.color === void 0 ? {} : { [`crosshair.${e}.color`]: t.color },
|
|
@@ -883,22 +883,22 @@ function Jn(e, t) {
|
|
|
883
883
|
...t.width === void 0 ? {} : { [`crosshair.${e}.width`]: t.width }
|
|
884
884
|
} : {};
|
|
885
885
|
}
|
|
886
|
-
function
|
|
886
|
+
function qn(e) {
|
|
887
887
|
let { grid: t, crosshair: n } = e, r = n?.vLine?.labelBackground ?? n?.hLine?.labelBackground;
|
|
888
888
|
return {
|
|
889
889
|
...t?.hLineColor === void 0 ? {} : { "grid.horizontal.color": t.hLineColor },
|
|
890
890
|
...t?.hLineStyle === void 0 ? {} : { "grid.horizontal.style": t.hLineStyle },
|
|
891
891
|
...t?.vLineColor === void 0 ? {} : { "grid.vertical.color": t.vLineColor },
|
|
892
892
|
...t?.vLineStyle === void 0 ? {} : { "grid.vertical.style": t.vLineStyle },
|
|
893
|
-
...
|
|
894
|
-
...
|
|
893
|
+
...Kn("horizontal", n?.hLine),
|
|
894
|
+
...Kn("vertical", n?.vLine),
|
|
895
895
|
...r === void 0 ? {} : { "crosshair.labelBackground": r },
|
|
896
896
|
...e.overrides
|
|
897
897
|
};
|
|
898
898
|
}
|
|
899
899
|
//#endregion
|
|
900
900
|
//#region src/layout/LayoutManager.ts
|
|
901
|
-
var
|
|
901
|
+
var Jn = 200, Yn = 80, W = (e) => e.position === "top" || e.position === "bottom", Xn = class {
|
|
902
902
|
panels = [];
|
|
903
903
|
containerWidth = 0;
|
|
904
904
|
containerHeight = 0;
|
|
@@ -915,8 +915,8 @@ var Xn = 200, Zn = 80, W = (e) => e.position === "top" || e.position === "bottom
|
|
|
915
915
|
this.panels.push({
|
|
916
916
|
id: e,
|
|
917
917
|
position: n,
|
|
918
|
-
size: r ?? (a ?
|
|
919
|
-
minSize: a ?
|
|
918
|
+
size: r ?? (a ? Jn : t),
|
|
919
|
+
minSize: a ? Yn : i,
|
|
920
920
|
content: {
|
|
921
921
|
type: "indicator",
|
|
922
922
|
indicatorInstanceId: e
|
|
@@ -985,7 +985,7 @@ var Xn = 200, Zn = 80, W = (e) => e.position === "top" || e.position === "bottom
|
|
|
985
985
|
let r = this.panels.find((t) => t.id === e);
|
|
986
986
|
if (r) {
|
|
987
987
|
let a = r.position === "left" || r.position === "right", o = n === "left" || n === "right";
|
|
988
|
-
r.position = n, a !== o && (r.size = o ?
|
|
988
|
+
r.position = n, a !== o && (r.size = o ? Jn : t, r.minSize = o ? Yn : i), o && (r.collapsed = void 0, this.maximized === e && (this.maximized = null));
|
|
989
989
|
}
|
|
990
990
|
}
|
|
991
991
|
setPanelSize(e, t) {
|
|
@@ -1105,8 +1105,8 @@ var Xn = 200, Zn = 80, W = (e) => e.position === "top" || e.position === "bottom
|
|
|
1105
1105
|
getMainChartRect() {
|
|
1106
1106
|
return this.resolve().mainChartRect;
|
|
1107
1107
|
}
|
|
1108
|
-
},
|
|
1109
|
-
function
|
|
1108
|
+
}, Zn = 14, Qn = 14, $n = 22, er = 4;
|
|
1109
|
+
function tr(e) {
|
|
1110
1110
|
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] : [
|
|
1111
1111
|
t,
|
|
1112
1112
|
n,
|
|
@@ -1115,16 +1115,16 @@ function rr(e) {
|
|
|
1115
1115
|
for (let t of f) {
|
|
1116
1116
|
if (!Number.isFinite(t)) continue;
|
|
1117
1117
|
let n = e.scaleLabel ? e.scaleLabel(t) : e.format ? e.format(t) : g(t, u, i), r = e.format ? n : g(t, d, i);
|
|
1118
|
-
p = Math.max(p, l(n, `500 ${s}px ${a}`) +
|
|
1118
|
+
p = Math.max(p, l(n, `500 ${s}px ${a}`) + Zn, l(r, `bold 11px ${a}`) + Qn, l(r, `600 ${s}px ${a}`) + $n);
|
|
1119
1119
|
}
|
|
1120
|
-
return p <= o ? o : Math.ceil(p /
|
|
1120
|
+
return p <= o ? o : Math.ceil(p / er) * er;
|
|
1121
1121
|
}
|
|
1122
|
-
function
|
|
1122
|
+
function nr(e, t) {
|
|
1123
1123
|
return t > e || t <= e - 12 ? t : e;
|
|
1124
1124
|
}
|
|
1125
1125
|
//#endregion
|
|
1126
1126
|
//#region src/layout/labelWidths.ts
|
|
1127
|
-
var
|
|
1127
|
+
var rr = 512, ir = class {
|
|
1128
1128
|
widths = /* @__PURE__ */ new Map();
|
|
1129
1129
|
fonts;
|
|
1130
1130
|
forget = () => this.widths.clear();
|
|
@@ -1135,12 +1135,12 @@ var ar = 512, or = class {
|
|
|
1135
1135
|
let r = `${t}\n${e}`, i = this.widths.get(r);
|
|
1136
1136
|
if (i !== void 0) return i;
|
|
1137
1137
|
let a = n();
|
|
1138
|
-
return this.widths.size >=
|
|
1138
|
+
return this.widths.size >= rr && this.widths.clear(), this.widths.set(r, a), a;
|
|
1139
1139
|
}
|
|
1140
1140
|
destroy() {
|
|
1141
1141
|
this.fonts?.removeEventListener("loadingdone", this.forget), this.widths.clear();
|
|
1142
1142
|
}
|
|
1143
|
-
},
|
|
1143
|
+
}, ar = class {
|
|
1144
1144
|
netY = 0;
|
|
1145
1145
|
travelX = 0;
|
|
1146
1146
|
engaged = !1;
|
|
@@ -1156,8 +1156,8 @@ var ar = 512, or = class {
|
|
|
1156
1156
|
}
|
|
1157
1157
|
return this.engaged;
|
|
1158
1158
|
}
|
|
1159
|
-
},
|
|
1160
|
-
function
|
|
1159
|
+
}, or = 1;
|
|
1160
|
+
function sr(e, t) {
|
|
1161
1161
|
return e.filter((e) => e.enabled !== !1 && (e.descriptor.layer ?? "overlay") === t);
|
|
1162
1162
|
}
|
|
1163
1163
|
function G(e) {
|
|
@@ -1171,24 +1171,24 @@ function G(e) {
|
|
|
1171
1171
|
//#endregion
|
|
1172
1172
|
//#region src/plugins/registry.ts
|
|
1173
1173
|
var K = /* @__PURE__ */ new Map();
|
|
1174
|
-
function
|
|
1174
|
+
function cr(e) {
|
|
1175
1175
|
K.set(G(e), e);
|
|
1176
1176
|
}
|
|
1177
|
-
function
|
|
1177
|
+
function lr(e) {
|
|
1178
1178
|
return K.delete(e);
|
|
1179
1179
|
}
|
|
1180
|
-
function
|
|
1180
|
+
function ur() {
|
|
1181
1181
|
return [...K.values()];
|
|
1182
1182
|
}
|
|
1183
|
-
function
|
|
1183
|
+
function dr() {
|
|
1184
1184
|
K.clear();
|
|
1185
1185
|
}
|
|
1186
1186
|
//#endregion
|
|
1187
1187
|
//#region src/plugins/PluginManager.ts
|
|
1188
|
-
var
|
|
1188
|
+
var fr = class {
|
|
1189
1189
|
plugins = /* @__PURE__ */ new Map();
|
|
1190
1190
|
constructor(e, t = {}) {
|
|
1191
|
-
if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of
|
|
1191
|
+
if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of ur()) this.add(e);
|
|
1192
1192
|
for (let e of t.plugins ?? []) this.add(e);
|
|
1193
1193
|
}
|
|
1194
1194
|
register(e) {
|
|
@@ -1218,15 +1218,15 @@ var mr = class {
|
|
|
1218
1218
|
add(e) {
|
|
1219
1219
|
this.plugins.set(G(e), e), e.kind === "indicator" && this.indicatorEngine.register(e.plugin);
|
|
1220
1220
|
}
|
|
1221
|
-
},
|
|
1221
|
+
}, pr = {
|
|
1222
1222
|
orderPlace: (e, t) => e.placeOrder(t),
|
|
1223
1223
|
orderModify: (e, t) => e.modifyOrder(t),
|
|
1224
1224
|
orderCancel: (e, t) => e.cancelOrder(t),
|
|
1225
1225
|
positionModify: (e, t) => e.modifyPosition(t),
|
|
1226
1226
|
positionClose: (e, t) => e.closePosition(t),
|
|
1227
|
-
positionReverse: (e, t, n) =>
|
|
1227
|
+
positionReverse: (e, t, n) => mr(e, t, n)
|
|
1228
1228
|
};
|
|
1229
|
-
async function
|
|
1229
|
+
async function mr(e, t, n) {
|
|
1230
1230
|
let { reversing: r } = n;
|
|
1231
1231
|
if (!r.has(t.positionId)) {
|
|
1232
1232
|
r.add(t.positionId);
|
|
@@ -1255,7 +1255,7 @@ async function gr(e, t, n) {
|
|
|
1255
1255
|
}
|
|
1256
1256
|
}
|
|
1257
1257
|
}
|
|
1258
|
-
function
|
|
1258
|
+
function hr(e, t) {
|
|
1259
1259
|
let n = [], r = null, i = {
|
|
1260
1260
|
positions: () => r ?? t.getPositions?.() ?? [],
|
|
1261
1261
|
reversing: /* @__PURE__ */ new Set()
|
|
@@ -1265,8 +1265,8 @@ function _r(e, t) {
|
|
|
1265
1265
|
e.data && t.onFill?.(e.data);
|
|
1266
1266
|
};
|
|
1267
1267
|
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));
|
|
1268
|
-
for (let r of Object.keys(
|
|
1269
|
-
let a =
|
|
1268
|
+
for (let r of Object.keys(pr)) {
|
|
1269
|
+
let a = pr[r], o = t.onIntent(r, (n) => {
|
|
1270
1270
|
Promise.resolve(a(e, n, i)).catch((e) => t.onError({
|
|
1271
1271
|
message: `Execution command failed: ${r}`,
|
|
1272
1272
|
cause: e
|
|
@@ -1280,7 +1280,7 @@ function _r(e, t) {
|
|
|
1280
1280
|
}
|
|
1281
1281
|
//#endregion
|
|
1282
1282
|
//#region src/replay/ReplayStepLoader.ts
|
|
1283
|
-
var
|
|
1283
|
+
var gr = 1e3, _r = class {
|
|
1284
1284
|
pieces = /* @__PURE__ */ new Map();
|
|
1285
1285
|
asked = /* @__PURE__ */ new Set();
|
|
1286
1286
|
inFlight = !1;
|
|
@@ -1313,7 +1313,7 @@ var vr = 1e3, yr = class {
|
|
|
1313
1313
|
this.done = !0;
|
|
1314
1314
|
}
|
|
1315
1315
|
ask(e, t) {
|
|
1316
|
-
let { ratio: n, barMs: r, step: i, report: a } = this.options, o = Math.max(1, Math.floor(
|
|
1316
|
+
let { ratio: n, barMs: r, step: i, report: a } = this.options, o = Math.max(1, Math.floor(gr / 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);
|
|
1317
1317
|
for (let e of l) this.asked.add(e.time);
|
|
1318
1318
|
this.inFlight = !0, a({
|
|
1319
1319
|
state: "loading",
|
|
@@ -1354,12 +1354,12 @@ var vr = 1e3, yr = class {
|
|
|
1354
1354
|
...n === void 0 ? {} : { error: n }
|
|
1355
1355
|
});
|
|
1356
1356
|
}
|
|
1357
|
-
},
|
|
1358
|
-
function
|
|
1359
|
-
let n = (e.high - e.low) *
|
|
1360
|
-
return t.filter((t) => t.close > e.high + n || t.close < e.low - n).length <= t.length *
|
|
1357
|
+
}, vr = 1 / 3, yr = .25, br = .5;
|
|
1358
|
+
function xr(e, t) {
|
|
1359
|
+
let n = (e.high - e.low) * yr;
|
|
1360
|
+
return t.filter((t) => t.close > e.high + n || t.close < e.low - n).length <= t.length * br;
|
|
1361
1361
|
}
|
|
1362
|
-
function
|
|
1362
|
+
function Sr(e) {
|
|
1363
1363
|
return e.close >= e.open ? [
|
|
1364
1364
|
e.open,
|
|
1365
1365
|
e.low,
|
|
@@ -1372,22 +1372,22 @@ function wr(e) {
|
|
|
1372
1372
|
e.close
|
|
1373
1373
|
];
|
|
1374
1374
|
}
|
|
1375
|
-
function
|
|
1376
|
-
let r =
|
|
1375
|
+
function Cr(e, t, n) {
|
|
1376
|
+
let r = Sr(e), i = [
|
|
1377
1377
|
1,
|
|
1378
1378
|
2,
|
|
1379
1379
|
3
|
|
1380
1380
|
].map((e) => Math.abs(r[e] - r[e - 1])), a = i[0] + i[1] + i[2], o = [], s = 0;
|
|
1381
1381
|
return r.forEach((r, c) => {
|
|
1382
|
-
c > 0 && (s += a > 0 ? i[c - 1] / a :
|
|
1382
|
+
c > 0 && (s += a > 0 ? i[c - 1] / a : vr), !(c === 0 && t > 0) && o.push({
|
|
1383
1383
|
price: r,
|
|
1384
1384
|
time: e.time,
|
|
1385
1385
|
at: (t + s) / n
|
|
1386
1386
|
});
|
|
1387
1387
|
}), o;
|
|
1388
1388
|
}
|
|
1389
|
-
function
|
|
1390
|
-
let n = t.length > 0 &&
|
|
1389
|
+
function wr(e, t = []) {
|
|
1390
|
+
let n = t.length > 0 && xr(e, t) ? t : [e], r = n.length, i = Tr(n.flatMap((e, t) => Cr(e, t, r)), e), a = n.reduce((e, t) => e + (t.volume ?? 0), 0), o = 0;
|
|
1391
1391
|
return {
|
|
1392
1392
|
bar: e,
|
|
1393
1393
|
points: i,
|
|
@@ -1397,7 +1397,7 @@ function Er(e, t = []) {
|
|
|
1397
1397
|
}))
|
|
1398
1398
|
};
|
|
1399
1399
|
}
|
|
1400
|
-
function
|
|
1400
|
+
function Tr(e, t) {
|
|
1401
1401
|
let n = e.length - 1, r = e.map((e, r) => ({
|
|
1402
1402
|
...e,
|
|
1403
1403
|
price: r === 0 ? t.open : r === n ? t.close : Math.min(t.high, Math.max(t.low, e.price))
|
|
@@ -1412,7 +1412,7 @@ function Dr(e, t) {
|
|
|
1412
1412
|
};
|
|
1413
1413
|
return i(t.high, (e, t) => e > t), i(t.low, (e, t) => e < t), r;
|
|
1414
1414
|
}
|
|
1415
|
-
function
|
|
1415
|
+
function Er(e, t) {
|
|
1416
1416
|
let n = e.points;
|
|
1417
1417
|
if (t <= n[0].at) return n[0].price;
|
|
1418
1418
|
for (let e = 1; e < n.length; e++) if (t <= n[e].at) {
|
|
@@ -1421,8 +1421,8 @@ function Or(e, t) {
|
|
|
1421
1421
|
}
|
|
1422
1422
|
return n[n.length - 1].price;
|
|
1423
1423
|
}
|
|
1424
|
-
var
|
|
1425
|
-
function
|
|
1424
|
+
var Dr = (e) => Number.isFinite(e) ? Math.min(1, Math.max(0, e)) : 0;
|
|
1425
|
+
function Or(e, t) {
|
|
1426
1426
|
let n = 0, r = 0;
|
|
1427
1427
|
for (let i of e.volumeAt) {
|
|
1428
1428
|
if (t >= i.at) {
|
|
@@ -1433,10 +1433,10 @@ function Ar(e, t) {
|
|
|
1433
1433
|
}
|
|
1434
1434
|
return n;
|
|
1435
1435
|
}
|
|
1436
|
-
function
|
|
1437
|
-
let n =
|
|
1436
|
+
function kr(e, t) {
|
|
1437
|
+
let n = Dr(t);
|
|
1438
1438
|
if (n >= 1) return { ...e.bar };
|
|
1439
|
-
let r =
|
|
1439
|
+
let r = Er(e, n), i = Math.max(e.points[0].price, r), a = Math.min(e.points[0].price, r);
|
|
1440
1440
|
for (let t of e.points) {
|
|
1441
1441
|
if (t.at > n) break;
|
|
1442
1442
|
i = Math.max(i, t.price), a = Math.min(a, t.price);
|
|
@@ -1447,11 +1447,11 @@ function jr(e, t) {
|
|
|
1447
1447
|
high: i,
|
|
1448
1448
|
low: a,
|
|
1449
1449
|
close: r,
|
|
1450
|
-
volume:
|
|
1450
|
+
volume: Or(e, n)
|
|
1451
1451
|
};
|
|
1452
1452
|
}
|
|
1453
|
-
function
|
|
1454
|
-
let n =
|
|
1453
|
+
function Ar(e, t) {
|
|
1454
|
+
let n = Dr(t), r = 0;
|
|
1455
1455
|
for (let t of e.points) {
|
|
1456
1456
|
if (t.at > n) break;
|
|
1457
1457
|
r = t.at;
|
|
@@ -1464,12 +1464,12 @@ function q(e, t, n) {
|
|
|
1464
1464
|
if (a.at > n) break;
|
|
1465
1465
|
i = a.time, a.at > t && r.push([a.price, a.time]);
|
|
1466
1466
|
}
|
|
1467
|
-
let a =
|
|
1467
|
+
let a = Er(e, n);
|
|
1468
1468
|
return (r.length === 0 || r[r.length - 1][0] !== a) && r.push([a, i]), r;
|
|
1469
1469
|
}
|
|
1470
1470
|
//#endregion
|
|
1471
1471
|
//#region src/replay/replayStep.ts
|
|
1472
|
-
var
|
|
1472
|
+
var jr = [
|
|
1473
1473
|
"1m",
|
|
1474
1474
|
"3m",
|
|
1475
1475
|
"5m",
|
|
@@ -1480,51 +1480,51 @@ var Nr = [
|
|
|
1480
1480
|
"4h",
|
|
1481
1481
|
"1d"
|
|
1482
1482
|
];
|
|
1483
|
-
function
|
|
1484
|
-
let n =
|
|
1485
|
-
return n > 0 ?
|
|
1486
|
-
let r =
|
|
1483
|
+
function Mr(e, t) {
|
|
1484
|
+
let n = w(e);
|
|
1485
|
+
return n > 0 ? jr.filter((e) => {
|
|
1486
|
+
let r = w(e);
|
|
1487
1487
|
return r < n && n % r === 0 && t(e);
|
|
1488
1488
|
}) : [];
|
|
1489
1489
|
}
|
|
1490
|
-
function
|
|
1491
|
-
let r =
|
|
1490
|
+
function Nr(e, t, n) {
|
|
1491
|
+
let r = Mr(t, n);
|
|
1492
1492
|
if (e !== "auto") return r.includes(e) ? e : null;
|
|
1493
|
-
let i =
|
|
1494
|
-
return r.find((e) => i /
|
|
1493
|
+
let i = w(t);
|
|
1494
|
+
return r.find((e) => i / w(e) <= 60) ?? null;
|
|
1495
1495
|
}
|
|
1496
1496
|
//#endregion
|
|
1497
1497
|
//#region src/Chart.ts
|
|
1498
|
-
var
|
|
1498
|
+
var Pr = {
|
|
1499
1499
|
min: 0,
|
|
1500
1500
|
max: 100
|
|
1501
|
-
},
|
|
1502
|
-
function
|
|
1501
|
+
}, Fr = "exchange", Ir = Fr;
|
|
1502
|
+
function Lr(e) {
|
|
1503
1503
|
if (typeof e == "string" && e !== "exchange" && !y(e)) throw RangeError(`Unknown time zone: ${e}`);
|
|
1504
1504
|
if (typeof e == "number" && !Number.isFinite(e)) throw RangeError(`Invalid UTC offset: ${e}`);
|
|
1505
1505
|
}
|
|
1506
|
-
function
|
|
1507
|
-
let { timeZone: n, timezone: r } = e, i = n !== void 0 && r !== void 0 && n !== r && n === t ? r :
|
|
1506
|
+
function Rr(e, t) {
|
|
1507
|
+
let { timeZone: n, timezone: r } = e, i = n !== void 0 && r !== void 0 && n !== r && n === t ? r : C(e);
|
|
1508
1508
|
return i === void 0 ? e : {
|
|
1509
1509
|
...e,
|
|
1510
1510
|
timeZone: i,
|
|
1511
1511
|
timezone: i
|
|
1512
1512
|
};
|
|
1513
1513
|
}
|
|
1514
|
-
var
|
|
1515
|
-
function
|
|
1514
|
+
var zr = .08, Br = a ** -7, Vr = 800, Hr = 24;
|
|
1515
|
+
function Ur(e) {
|
|
1516
1516
|
return e.length > 0 ? { renames: e } : {};
|
|
1517
1517
|
}
|
|
1518
|
-
var
|
|
1518
|
+
var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
1519
1519
|
ArrowLeft: [-1, 0],
|
|
1520
1520
|
ArrowRight: [1, 0],
|
|
1521
1521
|
ArrowUp: [0, -1],
|
|
1522
1522
|
ArrowDown: [0, 1]
|
|
1523
|
-
},
|
|
1524
|
-
static version = "1.
|
|
1523
|
+
}, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set(["verticalLine", "crossLine"]), Xr = class {
|
|
1524
|
+
static version = "1.66.0";
|
|
1525
1525
|
engine;
|
|
1526
1526
|
viewport;
|
|
1527
|
-
series = new
|
|
1527
|
+
series = new Rn((e) => this.sessionKeep(e), (e) => this.followLiveChange(e));
|
|
1528
1528
|
themeManager;
|
|
1529
1529
|
layoutManager;
|
|
1530
1530
|
pluginManager;
|
|
@@ -1540,7 +1540,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
1540
1540
|
autoScrollOnNewBar = !0;
|
|
1541
1541
|
displayDataCache = null;
|
|
1542
1542
|
indicatorsOnDrawn = null;
|
|
1543
|
-
reshapeMemo = new
|
|
1543
|
+
reshapeMemo = new lt();
|
|
1544
1544
|
displayDataStep;
|
|
1545
1545
|
indicatorUpdateFrom = null;
|
|
1546
1546
|
resolvedLayoutCache = null;
|
|
@@ -1551,7 +1551,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
1551
1551
|
renderDeferred = !1;
|
|
1552
1552
|
priceAxisWidth = o;
|
|
1553
1553
|
measureCtx;
|
|
1554
|
-
labelWidths = new
|
|
1554
|
+
labelWidths = new ir();
|
|
1555
1555
|
containerSizeCache = null;
|
|
1556
1556
|
containerSizeCacheTime = 0;
|
|
1557
1557
|
lastEmittedRange = null;
|
|
@@ -1566,7 +1566,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
1566
1566
|
indicatorEdit = null;
|
|
1567
1567
|
removedDrawingAlerts = /* @__PURE__ */ new Map();
|
|
1568
1568
|
zoomAreaMode = !1;
|
|
1569
|
-
priceAxisAddButton = new
|
|
1569
|
+
priceAxisAddButton = new rt();
|
|
1570
1570
|
displayTz = null;
|
|
1571
1571
|
timeZoneSetting = null;
|
|
1572
1572
|
symbolInfo = null;
|
|
@@ -1577,7 +1577,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
1577
1577
|
studyZoneReleaseQueued = !1;
|
|
1578
1578
|
sessionBreaks;
|
|
1579
1579
|
sessionShading;
|
|
1580
|
-
hostSessionHours = { ...
|
|
1580
|
+
hostSessionHours = { ...je };
|
|
1581
1581
|
compareRenderer;
|
|
1582
1582
|
countdownInterval = null;
|
|
1583
1583
|
pausedFor = {
|
|
@@ -1596,7 +1596,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
1596
1596
|
signalMarkerManager;
|
|
1597
1597
|
tradeZoneManager;
|
|
1598
1598
|
measureOverlay;
|
|
1599
|
-
selectionBoxOverlay = new
|
|
1599
|
+
selectionBoxOverlay = new dt();
|
|
1600
1600
|
replayManager;
|
|
1601
1601
|
replayBarUnsub = null;
|
|
1602
1602
|
replaySeeking = !1;
|
|
@@ -1611,7 +1611,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
1611
1611
|
replayForming = null;
|
|
1612
1612
|
replayPhaseUnsub = null;
|
|
1613
1613
|
undoRedoManager;
|
|
1614
|
-
autoSaveScheduler = new
|
|
1614
|
+
autoSaveScheduler = new jn((e) => this.saveState(e));
|
|
1615
1615
|
animator;
|
|
1616
1616
|
crosshairTooltip;
|
|
1617
1617
|
pinnedTooltip;
|
|
@@ -1623,14 +1623,14 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
1623
1623
|
disposed = !1;
|
|
1624
1624
|
chartTypeOptions = {};
|
|
1625
1625
|
mainSeriesVisible = !0;
|
|
1626
|
-
priceLines = new
|
|
1627
|
-
symbolSeries = new
|
|
1626
|
+
priceLines = new it();
|
|
1627
|
+
symbolSeries = new vt();
|
|
1628
1628
|
extendedHours = !0;
|
|
1629
1629
|
replayRestarting = !1;
|
|
1630
1630
|
requestedSymbols = /* @__PURE__ */ new Set();
|
|
1631
1631
|
gridRenderer;
|
|
1632
1632
|
priceAxis;
|
|
1633
|
-
leftPriceAxis = new
|
|
1633
|
+
leftPriceAxis = new nt();
|
|
1634
1634
|
leftScaleRequested = !1;
|
|
1635
1635
|
leftAxisWidth = o;
|
|
1636
1636
|
leftViewport = null;
|
|
@@ -1663,7 +1663,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
1663
1663
|
snapshotKey = null;
|
|
1664
1664
|
historyCheckQueued = !1;
|
|
1665
1665
|
constructor(e, t) {
|
|
1666
|
-
t.timeZone != null &&
|
|
1666
|
+
t.timeZone != null && Lr(t.timeZone), this.container = e, this.options = {
|
|
1667
1667
|
...t,
|
|
1668
1668
|
chartType: t.chartType ?? "candlestick"
|
|
1669
1669
|
}, this.numberLocale = t.numberLocale ?? "en-US", this.defaultAutoScale = t.autoScale !== !1;
|
|
@@ -1702,15 +1702,15 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
1702
1702
|
logScale: n.logScale ?? !0,
|
|
1703
1703
|
timeframes: n.timeframes ?? [],
|
|
1704
1704
|
defaultTimeframeFavorites: n.defaultTimeframeFavorites ?? []
|
|
1705
|
-
}, 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
|
|
1705
|
+
}, 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 Un({
|
|
1706
1706
|
oldestTime: () => (this.replaySession ? this.series.liveBars() : this.series.bars())[0]?.time ?? null,
|
|
1707
1707
|
prepend: (e) => this.prependBars(e),
|
|
1708
1708
|
emit: (e) => this.eventBus.emit("historyLoad", e)
|
|
1709
|
-
}), this.themeManager = new
|
|
1709
|
+
}), this.themeManager = new Gn(t.theme), this.themeManager.setChartType(this.options.chartType ?? "candlestick"), this.applyStyle(qn(t), "host", !1), this.layoutManager = new Xn(), this.indicatorEngine = new Ve(), this.pluginManager = new fr(this.indicatorEngine, { plugins: t.plugins }), this.eventBus = new Ie(), Vt(this.indicatorEngine), this.indicatorEngine.register(new we(this.symbolSeries)), this.indicatorEngine.register(new Te(this.symbolSeries)), this.indicatorEngine.register(new ht(this.symbolSeries)), this.indicatorEngine.register(new Ee(this.symbolSeries)), this.indicatorEngine.register(new De(this.symbolSeries)), this.drawingManager = new Ne(), Bt(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(() => {
|
|
1710
1710
|
this.syncRenderContext(), this.engine.requestRender(r.Overlay), this.scheduleAutoSave();
|
|
1711
1711
|
}), this.drawingManager.setEventCallback((e, t) => {
|
|
1712
1712
|
this.followDrawingAlerts(e, t?.id), this.eventBus.emit(e, t), (e === "drawingCreate" || e === "drawingUpdate" || e === "drawingRemove") && this.announceStateChange();
|
|
1713
|
-
}), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new
|
|
1713
|
+
}), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new Ct();
|
|
1714
1714
|
let i = "";
|
|
1715
1715
|
this.undoRedoManager.setOnChange(() => {
|
|
1716
1716
|
let { canUndo: e, canRedo: t } = this.undoRedoManager.getState(), n = `${e}|${t}`;
|
|
@@ -1723,23 +1723,23 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
1723
1723
|
primary: e[0] ?? null
|
|
1724
1724
|
})), this.drawingManager.setForeignHistory((e, t) => {
|
|
1725
1725
|
e.type === "custom" ? e.custom?.[t]() : this.applyIndicatorStep(e, t);
|
|
1726
|
-
}), 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
|
|
1726
|
+
}), 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 xt({
|
|
1727
1727
|
enabled: this.features.trading,
|
|
1728
1728
|
contextMenu: { enabled: this.features.tradingContextMenu }
|
|
1729
|
-
}), this.tradingRenderer = new
|
|
1729
|
+
}), this.tradingRenderer = new St(this.tradingManager), this.tradingManager.setContainer(e), this.tradingManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradingManager.setEventCallback((e, t) => {
|
|
1730
1730
|
this.eventBus.emit(e, t);
|
|
1731
|
-
}), this.engine = new
|
|
1731
|
+
}), this.engine = new at(e, t.maxPixelRatio);
|
|
1732
1732
|
let a = this.engine.dprManager.getContainerSize();
|
|
1733
|
-
if (this.viewport = new
|
|
1733
|
+
if (this.viewport = new wt(a.width, a.height, t.minBarSpacing ?? 2, t.maxBarSpacing ?? 30, t.rightMargin ?? 5), t.barLayout && this.viewport.setBarLayout(t.barLayout), this.viewport.setPanLimits({
|
|
1734
1734
|
freePan: t.freePan ?? !0,
|
|
1735
1735
|
minVisibleBars: t.panLimits?.minVisibleBars ?? 3
|
|
1736
1736
|
}), t.minBarUnit !== void 0 && this.viewport.setMinBarUnit(t.minBarUnit), this.layoutManager.resize(a.width, a.height), this.engine.onContainerResize = (e) => {
|
|
1737
1737
|
if (e.width <= 0 || e.height <= 0) return;
|
|
1738
1738
|
let t = this.viewport.isAtEnd();
|
|
1739
1739
|
this.viewport.resize(e.width, e.height), this.layoutManager.resize(e.width, e.height), this.updateViewportAndRender(t), this.eventBus.emit("resize", e);
|
|
1740
|
-
}, this.chartRenderer = this.createChartRenderer(this.options.chartType), this.gridRenderer = new
|
|
1740
|
+
}, 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 yt(), 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) => {
|
|
1741
1741
|
if (e !== null && t) {
|
|
1742
|
-
let n = this.crosshairSeries(), i = e >= 0 && e < n.length ? n[e] : void 0, a = e > 0 ? n[e - 1]?.close : void 0, o =
|
|
1742
|
+
let n = this.crosshairSeries(), i = e >= 0 && e < n.length ? n[e] : void 0, a = e > 0 ? n[e - 1]?.close : void 0, o = A(n), s = i ? o[e]?.time ?? i.time : void 0;
|
|
1743
1743
|
this.chartLegend.setHoverBar(i ?? null, e > 0 ? n[e - 1] ?? null : null), this.features.legend && this.engine.requestRender(r.Hover);
|
|
1744
1744
|
let c = this.viewport.getState(), l = t.y >= c.chartRect.y && t.y <= c.chartRect.y + c.chartRect.height;
|
|
1745
1745
|
if (i && l && this.features.crosshairTooltip) {
|
|
@@ -1767,14 +1767,14 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
1767
1767
|
let e = this.crosshairHandler.getSyncedSlot();
|
|
1768
1768
|
e !== null && this.showSyncedBar(e);
|
|
1769
1769
|
}
|
|
1770
|
-
}), this.chartLegend = new
|
|
1770
|
+
}), this.chartLegend = new Se(), this.chartLegend.setChartType(this.options.chartType), this.chartLegend.setLocale(this.numberLocale), this.chartLegend.setResizeListener(() => {
|
|
1771
1771
|
this.eventBus.emit("legendResize", { bottom: this.getLegendBottom() }), this.engine.requestRender();
|
|
1772
|
-
}), this.watermark = new
|
|
1772
|
+
}), this.watermark = new Ot(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new Dt(), this.volumeProfile = new Et(), 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 ft(), this.sessionShading = new pt(), this.compareRenderer = new Ce(), t.sessionBreaks ? this.sessionBreaks.setConfig({
|
|
1773
1773
|
visible: t.sessionBreaks.visible ?? !0,
|
|
1774
1774
|
color: t.sessionBreaks.color,
|
|
1775
1775
|
lineStyle: t.sessionBreaks.lineStyle,
|
|
1776
1776
|
lineWidth: t.sessionBreaks.lineWidth
|
|
1777
|
-
}) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new
|
|
1777
|
+
}) : 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(ni(t.shapes)), t.font && this.themeManager.setFont(ti(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({
|
|
1778
1778
|
scrollBars: (e) => {
|
|
1779
1779
|
let t = this.viewport.getState().barWidth + this.viewport.getState().barSpacing;
|
|
1780
1780
|
this.viewport.scrollBy(e * t), this.updateViewportAndRender();
|
|
@@ -1791,7 +1791,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
1791
1791
|
},
|
|
1792
1792
|
fitContent: () => this.fitContent()
|
|
1793
1793
|
}), this.keyboardHandler.setEnabled(this.features.keyboard), t.a11y !== !1) {
|
|
1794
|
-
this.a11y = new
|
|
1794
|
+
this.a11y = new rn(e, {
|
|
1795
1795
|
symbol: () => this.currentSymbol || this.symbolInfo?.symbol || "",
|
|
1796
1796
|
timeframe: () => this.streamTimeframe ?? "",
|
|
1797
1797
|
chartType: () => this.options.chartType ?? "candlestick",
|
|
@@ -1822,7 +1822,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
1822
1822
|
}
|
|
1823
1823
|
this.keyboardHandler.handleKey(e) && (e.preventDefault(), this.a11y?.viewMoved());
|
|
1824
1824
|
}
|
|
1825
|
-
}, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new
|
|
1825
|
+
}, 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(Nt).map((e) => e.price)), this.alertManager.on("triggered", (e) => {
|
|
1826
1826
|
this.eventBus.emit("alertTriggered", J(e)), this.eventBus.emit("dataUpdate", {
|
|
1827
1827
|
kind: "alert",
|
|
1828
1828
|
alert: "triggered",
|
|
@@ -1838,7 +1838,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
1838
1838
|
this.eventBus.emit("alertExpired", J(e));
|
|
1839
1839
|
}), this.alertManager.on("updated", (e) => {
|
|
1840
1840
|
this.eventBus.emit("alertUpdate", J(e));
|
|
1841
|
-
}), this.signalMarkerManager = new
|
|
1841
|
+
}), this.signalMarkerManager = new mt(), this.signalMarkerManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.signalMarkerManager.setDataGetter(() => this.series.bars()), this.signalMarkerManager.on("added", (e) => {
|
|
1842
1842
|
this.eventBus.emit("signalMarkerAdd", {
|
|
1843
1843
|
id: e.id,
|
|
1844
1844
|
source: e.source,
|
|
@@ -1846,14 +1846,14 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
1846
1846
|
});
|
|
1847
1847
|
}), this.signalMarkerManager.on("removed", (e) => {
|
|
1848
1848
|
this.eventBus.emit("signalMarkerRemove", { id: e });
|
|
1849
|
-
}), this.tradeZoneManager = new
|
|
1849
|
+
}), this.tradeZoneManager = new bt(), this.tradeZoneManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradeZoneManager.setDataGetter(() => this.series.bars()), this.tradeZoneManager.on("added", (e) => {
|
|
1850
1850
|
this.eventBus.emit("tradeZoneAdd", {
|
|
1851
1851
|
id: e.id,
|
|
1852
1852
|
direction: e.direction
|
|
1853
1853
|
});
|
|
1854
1854
|
}), this.tradeZoneManager.on("removed", (e) => {
|
|
1855
1855
|
this.eventBus.emit("tradeZoneRemove", { id: e });
|
|
1856
|
-
}), this.replayManager = new
|
|
1856
|
+
}), this.replayManager = new st(), this.replayManager.on("complete", () => {
|
|
1857
1857
|
let e = this.getReplayBarIndex(), t = this.replayCoarse?.[e];
|
|
1858
1858
|
t && this.eventBus.emit("replayComplete", {
|
|
1859
1859
|
barIndex: e,
|
|
@@ -1861,9 +1861,9 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
1861
1861
|
});
|
|
1862
1862
|
}), this.replayManager.on("stateChange", (e) => {
|
|
1863
1863
|
this.replayRestarting || this.eventBus.emit("replayState", { state: e });
|
|
1864
|
-
}), this.measureOverlay = new
|
|
1865
|
-
let e = new
|
|
1866
|
-
this.interactionManager.setPanHandler(new
|
|
1864
|
+
}), this.measureOverlay = new Je(), this.interactionManager = new He(e), this.features.panning) {
|
|
1865
|
+
let e = new ar();
|
|
1866
|
+
this.interactionManager.setPanHandler(new Xe((t, n) => {
|
|
1867
1867
|
t && this.viewport.scrollBy(t), e.step(t, n, this.options.autoScale !== !1) && n && (this.holdPriceScale(), this.viewport.panPriceRange(n)), this.updateViewportAndRender();
|
|
1868
1868
|
}, () => e.reset()));
|
|
1869
1869
|
}
|
|
@@ -1875,10 +1875,10 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
1875
1875
|
scales: !this.indicatorEngine.hasLeftScaleOverlays()
|
|
1876
1876
|
}
|
|
1877
1877
|
})), this.features.zooming) {
|
|
1878
|
-
this.interactionManager.setZoomHandler(new
|
|
1878
|
+
this.interactionManager.setZoomHandler(new kt((e, t) => {
|
|
1879
1879
|
this.viewport.zoom(e, t - this.viewport.getState().chartRect.x), this.updateViewportAndRender();
|
|
1880
1880
|
}));
|
|
1881
|
-
let e = new
|
|
1881
|
+
let e = new _e((e) => {
|
|
1882
1882
|
this.holdPriceScale(), this.viewport.scalePriceRange(e), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents();
|
|
1883
1883
|
}, (e) => {
|
|
1884
1884
|
let t = this.viewport.getState().chartRect.width;
|
|
@@ -1903,7 +1903,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
1903
1903
|
y: t.y
|
|
1904
1904
|
});
|
|
1905
1905
|
})), 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) => {
|
|
1906
|
-
let t =
|
|
1906
|
+
let t = Yt(e.y, this.viewport.getState());
|
|
1907
1907
|
Number.isFinite(t) && this.eventBus.emit("priceAxisAdd", {
|
|
1908
1908
|
price: t,
|
|
1909
1909
|
x: e.x,
|
|
@@ -1913,10 +1913,10 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
1913
1913
|
...this.viewport.getState(),
|
|
1914
1914
|
data: this.getDisplayData()
|
|
1915
1915
|
})), this.features.alerts) {
|
|
1916
|
-
let e = new
|
|
1916
|
+
let e = new pe(this.alertManager, () => this.viewport.getState());
|
|
1917
1917
|
this.interactionManager.setAlertDragHandler(e);
|
|
1918
1918
|
}
|
|
1919
|
-
let o = new
|
|
1919
|
+
let o = new Ze();
|
|
1920
1920
|
o.configure(() => this.getResolvedLayout(), (e, t) => this.setPanelSize(e, t)), this.interactionManager.setPaneResizeHandler(o), this.interactionManager.setAltClickHandler((e) => {
|
|
1921
1921
|
let t = this.getDisplayData();
|
|
1922
1922
|
if (t.length === 0) return;
|
|
@@ -1940,7 +1940,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
1940
1940
|
x: e.x,
|
|
1941
1941
|
y: e.y
|
|
1942
1942
|
}), t.length === 0) return;
|
|
1943
|
-
let r =
|
|
1943
|
+
let r = Jt(e.x, this.viewport.getState());
|
|
1944
1944
|
r < 0 || r >= t.length || this.eventBus.emit("barClick", {
|
|
1945
1945
|
bar: t[r],
|
|
1946
1946
|
barIndex: r,
|
|
@@ -1985,7 +1985,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
1985
1985
|
end: () => {
|
|
1986
1986
|
let e = this.selectionBoxOverlay.end();
|
|
1987
1987
|
if (e && this.zoomAreaMode) {
|
|
1988
|
-
if (e.x1 - e.x0 <
|
|
1988
|
+
if (e.x1 - e.x0 < Gr) return;
|
|
1989
1989
|
this.zoomToBox(e), this.setZoomAreaMode(!1);
|
|
1990
1990
|
return;
|
|
1991
1991
|
}
|
|
@@ -2069,13 +2069,13 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
2069
2069
|
let { visibleRange: e, chartRect: t } = this.viewport.getState();
|
|
2070
2070
|
if (t.width <= 0) return;
|
|
2071
2071
|
let { from: n, to: r } = e;
|
|
2072
|
-
this.history.maybeLoad(Math.max(0, Math.floor(n)), Math.max(
|
|
2072
|
+
this.history.maybeLoad(Math.max(0, Math.floor(n)), Math.max(Wr, r - n));
|
|
2073
2073
|
}));
|
|
2074
2074
|
}
|
|
2075
2075
|
useStreamHistory(e, t, n = !0) {
|
|
2076
2076
|
if (this.hostHistoryLoader) return;
|
|
2077
2077
|
let r = P(e), i = r.fetchHistoryBefore, a = this.streamTimeframe;
|
|
2078
|
-
if (!i || a === null ||
|
|
2078
|
+
if (!i || a === null || de(a) !== null) {
|
|
2079
2079
|
this.historyFromStream && this.history.setLoader(null), this.historyFromStream = !1;
|
|
2080
2080
|
return;
|
|
2081
2081
|
}
|
|
@@ -2172,11 +2172,11 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
2172
2172
|
setChartTypeOptions(e) {
|
|
2173
2173
|
this.chartTypeOptions = {
|
|
2174
2174
|
...this.chartTypeOptions,
|
|
2175
|
-
...
|
|
2175
|
+
...ae(e)
|
|
2176
2176
|
}, this.displayDataCache = null, this.updateViewportAndRender(!0), this.fitFewColumns(), this.a11y?.refresh(!0), this.markStateChanged();
|
|
2177
2177
|
}
|
|
2178
2178
|
getChartTypeOptions() {
|
|
2179
|
-
return
|
|
2179
|
+
return ae(this.chartTypeOptions);
|
|
2180
2180
|
}
|
|
2181
2181
|
setExtendedHours(e) {
|
|
2182
2182
|
e !== this.extendedHours && (this.extendedHours = e, this.reapplyExtendedHours(), this.markStateChanged());
|
|
@@ -2185,7 +2185,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
2185
2185
|
return this.extendedHours;
|
|
2186
2186
|
}
|
|
2187
2187
|
sessionKeep(e) {
|
|
2188
|
-
return this.extendedHours ? null :
|
|
2188
|
+
return this.extendedHours ? null : Qt(this.symbolInfo, e);
|
|
2189
2189
|
}
|
|
2190
2190
|
reapplyExtendedHours() {
|
|
2191
2191
|
if (!this.series.refilter()) return;
|
|
@@ -2196,7 +2196,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
2196
2196
|
return this.priceLines.setQuoteShown(this.replaySession === null), this.priceLines;
|
|
2197
2197
|
}
|
|
2198
2198
|
setShapes(e) {
|
|
2199
|
-
let t =
|
|
2199
|
+
let t = ni(e);
|
|
2200
2200
|
t.tagRadius !== void 0 && (this.themeManager.setShape({
|
|
2201
2201
|
...this.themeManager.getTheme().shape,
|
|
2202
2202
|
...t
|
|
@@ -2208,7 +2208,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
2208
2208
|
setFont(e) {
|
|
2209
2209
|
if (e === null) this.themeManager.setFont(null);
|
|
2210
2210
|
else {
|
|
2211
|
-
let t =
|
|
2211
|
+
let t = ti(e);
|
|
2212
2212
|
if (Object.keys(t).length === 0) return;
|
|
2213
2213
|
this.themeManager.setFont(t);
|
|
2214
2214
|
}
|
|
@@ -2259,7 +2259,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
2259
2259
|
setSymbolSeries(e, t) {
|
|
2260
2260
|
e = e.trim(), this.symbolSeries.set(e, t), this.requestedSymbols.delete(e);
|
|
2261
2261
|
let n = this.indicatorBars(), r = !1;
|
|
2262
|
-
for (let t of this.indicatorEngine.getActiveIndicators()) !
|
|
2262
|
+
for (let t of this.indicatorEngine.getActiveIndicators()) !O.has(t.id) || String(t.params.symbol ?? "").trim() !== e.trim() || (this.indicatorEngine.updateIndicator(t.instanceId, {}, n), r = !0);
|
|
2263
2263
|
r && (this.announceIndicatorUpdate(0), this.updateViewportAndRender());
|
|
2264
2264
|
}
|
|
2265
2265
|
forgetUnreadSymbols() {
|
|
@@ -2273,13 +2273,13 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
2273
2273
|
let e = /* @__PURE__ */ new Set();
|
|
2274
2274
|
for (let t of this.indicatorEngine.getActiveIndicators()) {
|
|
2275
2275
|
let n = t.params.symbol;
|
|
2276
|
-
|
|
2276
|
+
O.has(t.id) && typeof n == "string" && n.trim() && e.add(n.trim());
|
|
2277
2277
|
}
|
|
2278
2278
|
return [...e];
|
|
2279
2279
|
}
|
|
2280
2280
|
requestMissingSymbols(e) {
|
|
2281
2281
|
this.forgetUnreadSymbols();
|
|
2282
|
-
let t = this.indicatorEngine.getIndicatorConfig(e), n = t &&
|
|
2282
|
+
let t = this.indicatorEngine.getIndicatorConfig(e), n = t && O.has(t.id) && typeof t.params.symbol == "string" ? t.params.symbol.trim() : "";
|
|
2283
2283
|
!n || this.symbolSeries.has(n) || this.requestedSymbols.has(n) || (this.requestedSymbols.add(n), this.eventBus.emit("symbolSeriesRequest", { symbol: n }));
|
|
2284
2284
|
}
|
|
2285
2285
|
updateIndicator(e, t) {
|
|
@@ -2350,8 +2350,8 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
2350
2350
|
return {
|
|
2351
2351
|
...e,
|
|
2352
2352
|
priceRange: {
|
|
2353
|
-
min: t.min - n *
|
|
2354
|
-
max: t.max + n *
|
|
2353
|
+
min: t.min - n * zr,
|
|
2354
|
+
max: t.max + n * zr
|
|
2355
2355
|
},
|
|
2356
2356
|
logScale: !1,
|
|
2357
2357
|
scaleMode: "regular",
|
|
@@ -2404,7 +2404,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
2404
2404
|
this.indicatorEngine.setStyleDefaults(e, null);
|
|
2405
2405
|
return;
|
|
2406
2406
|
}
|
|
2407
|
-
let { plots: n, ...r } = t, i = n === void 0 ? void 0 :
|
|
2407
|
+
let { plots: n, ...r } = t, i = n === void 0 ? void 0 : oe(n);
|
|
2408
2408
|
this.indicatorEngine.setStyleDefaults(e, {
|
|
2409
2409
|
...r,
|
|
2410
2410
|
...i ? { plots: i } : {}
|
|
@@ -2412,7 +2412,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
2412
2412
|
}
|
|
2413
2413
|
setPaneStyle(e, t) {
|
|
2414
2414
|
let n = this.paneOf(e);
|
|
2415
|
-
this.layoutManager.getPanels().some((e) => e.id === n) && this.recordIndicators(n, () => this.setPaneStyleNow(n, t ?
|
|
2415
|
+
this.layoutManager.getPanels().some((e) => e.id === n) && this.recordIndicators(n, () => this.setPaneStyleNow(n, t ? se(t) : null));
|
|
2416
2416
|
}
|
|
2417
2417
|
setPaneStyleNow(e, t) {
|
|
2418
2418
|
JSON.stringify(t) !== JSON.stringify(this.paneStyles.get(e) ?? null) && (t ? this.paneStyles.set(e, t) : this.paneStyles.delete(e), this.panelInfoCache = null, this.syncRenderContext(), this.engine.requestRender(), this.markStateChanged());
|
|
@@ -2431,8 +2431,8 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
2431
2431
|
return this.pluginManager;
|
|
2432
2432
|
}
|
|
2433
2433
|
static indicators() {
|
|
2434
|
-
let e = new
|
|
2435
|
-
return
|
|
2434
|
+
let e = new Ve();
|
|
2435
|
+
return Vt(e), e.getAvailableIndicators();
|
|
2436
2436
|
}
|
|
2437
2437
|
setPanelPosition(e, t) {
|
|
2438
2438
|
this.layoutManager.setPanelPosition(e, t), this.updateViewportAndRender(), this.eventBus.emit("indicatorChange", {
|
|
@@ -2596,7 +2596,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
2596
2596
|
roundPrice(e) {
|
|
2597
2597
|
if (!Number.isFinite(e)) return e;
|
|
2598
2598
|
let t = this.stepAt(e);
|
|
2599
|
-
if (t !== void 0) return Number((Math.round(e / t) * t).toFixed(
|
|
2599
|
+
if (t !== void 0) return Number((Math.round(e / t) * t).toFixed(ue(t)));
|
|
2600
2600
|
let { min: n, max: r } = this.viewport.getState().priceRange;
|
|
2601
2601
|
return Number(e.toFixed(this.marketPricePrecision ?? c(n, r)));
|
|
2602
2602
|
}
|
|
@@ -2693,9 +2693,9 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
2693
2693
|
return this.drawingManager.removeDrawings(e);
|
|
2694
2694
|
}
|
|
2695
2695
|
nudgeSelectedDrawings(e) {
|
|
2696
|
-
let t =
|
|
2696
|
+
let t = qr[e.key];
|
|
2697
2697
|
if (!t || !this.features.drawings || e.ctrlKey || e.metaKey || e.altKey) return !1;
|
|
2698
|
-
let n = e.shiftKey ?
|
|
2698
|
+
let n = e.shiftKey ? Kr : 1, r = {
|
|
2699
2699
|
...this.viewport.getState(),
|
|
2700
2700
|
data: this.getDisplayData()
|
|
2701
2701
|
};
|
|
@@ -2779,7 +2779,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
2779
2779
|
recordUndo(e) {
|
|
2780
2780
|
if (!this.features.drawingUndoRedo || typeof e?.undo != "function" || typeof e.redo != "function") return;
|
|
2781
2781
|
let t = performance.now(), n = this.undoRedoManager.last();
|
|
2782
|
-
if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at <
|
|
2782
|
+
if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at < Vr) {
|
|
2783
2783
|
this.undoRedoManager.replaceLast({
|
|
2784
2784
|
...n,
|
|
2785
2785
|
custom: {
|
|
@@ -2826,7 +2826,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
2826
2826
|
x: t.x,
|
|
2827
2827
|
y: t.y
|
|
2828
2828
|
};
|
|
2829
|
-
if ((e === "plot" || e === "priceAxis") && (r.price =
|
|
2829
|
+
if ((e === "plot" || e === "priceAxis") && (r.price = Yt(t.y, n)), (e === "plot" || e === "timeAxis") && n.data.length > 0 && (r.time = F(t.x, n)), e === "pane") {
|
|
2830
2830
|
let e = this.getIndicatorPanes().find((e) => t.y >= e.rect.y && t.y <= e.rect.y + e.rect.height);
|
|
2831
2831
|
e && (r.pane = e.instanceId);
|
|
2832
2832
|
}
|
|
@@ -2834,7 +2834,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
2834
2834
|
}
|
|
2835
2835
|
applyPriceAxisAdd() {
|
|
2836
2836
|
let e = this.features.priceAxisAddButton && this.features.crosshair;
|
|
2837
|
-
this.priceAxisAddButton.setEnabled(e), this.tradingManager.setTagInset(e ?
|
|
2837
|
+
this.priceAxisAddButton.setEnabled(e), this.tradingManager.setTagInset(e ? Ye : 0);
|
|
2838
2838
|
}
|
|
2839
2839
|
setPriceAxisAddButton(e) {
|
|
2840
2840
|
this.features.priceAxisAddButton = e, this.applyPriceAxisAdd(), this.engine.requestRender(r.Overlay);
|
|
@@ -2901,7 +2901,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
2901
2901
|
for (let e of this.indicatorEngine.getActiveIndicators()) {
|
|
2902
2902
|
let t = this.indicatorEngine.getOutput(e.instanceId)?.series;
|
|
2903
2903
|
if (!t) continue;
|
|
2904
|
-
let r =
|
|
2904
|
+
let r = ln(e.id, e.params, e.descriptor.defaultConfig, e.descriptor.shortName), o = e.descriptor.plots ?? Object.keys(t.find((e) => e) ?? {}).map((e) => ({
|
|
2905
2905
|
key: e,
|
|
2906
2906
|
title: e
|
|
2907
2907
|
}));
|
|
@@ -2925,11 +2925,11 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
2925
2925
|
}
|
|
2926
2926
|
getExportText(e = "csv", t = {}) {
|
|
2927
2927
|
let { bars: n, columns: r } = this.getExportData(t);
|
|
2928
|
-
return e === "json" ?
|
|
2928
|
+
return e === "json" ? E.toJSON(n, r) : E.toCSV(n, r);
|
|
2929
2929
|
}
|
|
2930
2930
|
download(e, t, n) {
|
|
2931
2931
|
let r = this.getExportText(e, n);
|
|
2932
|
-
e === "json" ?
|
|
2932
|
+
e === "json" ? E.download(r, t ?? "chart-data.json", "application/json") : E.download(r, t ?? "chart-data.csv", "text/csv");
|
|
2933
2933
|
}
|
|
2934
2934
|
setAutoSave(e, t = 5e3) {
|
|
2935
2935
|
this.autoSaveScheduler.enable(e, t);
|
|
@@ -2991,7 +2991,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
2991
2991
|
this.recordIndicators(e, () => this.updateIndicatorStyleNow(e, t));
|
|
2992
2992
|
}
|
|
2993
2993
|
updateIndicatorStyleNow(e, t) {
|
|
2994
|
-
let { plots: n, ...r } = t, i = n === void 0 ? void 0 :
|
|
2994
|
+
let { plots: n, ...r } = t, i = n === void 0 ? void 0 : oe(n);
|
|
2995
2995
|
this.indicatorEngine.updateIndicatorStyle(e, {
|
|
2996
2996
|
...r,
|
|
2997
2997
|
...i ? { plots: i } : {}
|
|
@@ -3112,7 +3112,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
3112
3112
|
}
|
|
3113
3113
|
async connect(e) {
|
|
3114
3114
|
if (!j(e.adapter, e.timeframe)) throw RangeError(`${e.adapter.name} cannot serve the ${e.timeframe} timeframe`);
|
|
3115
|
-
this.snapshotKey = null, this.holdReplayFor(e.symbol), this.disconnectStream(), this.streamManager = new
|
|
3115
|
+
this.snapshotKey = null, this.holdReplayFor(e.symbol), this.disconnectStream(), this.streamManager = new _t(), this.streamManager.setTimeZone(this.studyZoneHeld ? this.studyZone : this.getExchangeTimeZone()), this.streamManager.on("snapshot", (t) => {
|
|
3116
3116
|
let n = this.streamSeriesKey(e.adapter);
|
|
3117
3117
|
n === this.snapshotKey && this.replaySession ? this.series.mergeSnapshot(t) : n === this.snapshotKey && this.series.length() > 0 ? this.mergeSnapshot(t) : (this.replaySession && this.useStreamHistory(e.adapter, e.historyPageSize, !1), this.setData(t)), this.snapshotKey = n, this.useStreamHistory(e.adapter, e.historyPageSize);
|
|
3118
3118
|
}), this.streamManager.on("barClose", (e) => {
|
|
@@ -3168,18 +3168,18 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
3168
3168
|
}), this.streamManager.on("symbolInfo", (e) => this.applyFeedSymbolInfo(e)), this.autoScrollOnNewBar = e.autoScroll !== !1, this.setStreamTarget(e.symbol, e.timeframe), this.streamAdapter = e.adapter;
|
|
3169
3169
|
let t = this.streamManager;
|
|
3170
3170
|
if (this.resolveStreamSymbol(e.adapter, e.symbol), await t.connect(e), this.streamManager !== t) return;
|
|
3171
|
-
let n =
|
|
3171
|
+
let n = w(e.timeframe);
|
|
3172
3172
|
this.barCountdown.setTimeframeMs(n), this.countdownInterval && clearInterval(this.countdownInterval), this.countdownInterval = setInterval(() => {
|
|
3173
3173
|
this.barCountdown.isVisible() && this.engine.requestRender(r.Hover);
|
|
3174
3174
|
}, 1e3);
|
|
3175
3175
|
}
|
|
3176
3176
|
streamSeriesKey(e) {
|
|
3177
|
-
let t = P(e), n = this.streamTimeframe, r = t instanceof
|
|
3177
|
+
let t = P(e), n = this.streamTimeframe, r = t instanceof ct && n !== null ? t.bucketFor(this.currentSymbol, n) : null;
|
|
3178
3178
|
return `${this.currentSymbol}|${n}|${r?.timeZone ?? ""}`;
|
|
3179
3179
|
}
|
|
3180
3180
|
setStreamTarget(e, t) {
|
|
3181
3181
|
let n = this.announcedSymbol;
|
|
3182
|
-
this.currentSymbol = e, this.streamTimeframe = t, this.tickStream =
|
|
3182
|
+
this.currentSymbol = e, this.streamTimeframe = t, this.tickStream = de(t) !== null, this.applyTimeSpacing(), e !== n && this.chartLegend.setSymbol(e), e !== n && (this.announcedSymbol = e, this.eventBus.emit("symbolChange", {
|
|
3183
3183
|
symbol: e,
|
|
3184
3184
|
previous: n
|
|
3185
3185
|
})), this.useTimeframe(t);
|
|
@@ -3198,7 +3198,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
3198
3198
|
if (!this.streamManager) return;
|
|
3199
3199
|
let n = this.streamAdapter;
|
|
3200
3200
|
if (n && !j(n, t)) throw RangeError(`${n.name} cannot serve the ${t} timeframe`);
|
|
3201
|
-
this.holdReplayFor(e), this.setStreamTarget(e, t), this.historyFromStream && this.history.setLoader(null), this.barCountdown.setTimeframeMs(
|
|
3201
|
+
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);
|
|
3202
3202
|
}
|
|
3203
3203
|
isIndicatorAllowed(e) {
|
|
3204
3204
|
let t = this.features.indicatorIds;
|
|
@@ -3217,7 +3217,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
3217
3217
|
}
|
|
3218
3218
|
connectExecution(e, t = {}) {
|
|
3219
3219
|
if (!this.features.trading) throw Error("connectExecution requires features.trading to be enabled");
|
|
3220
|
-
this.disconnectExecution(), this.executionAdapter = e, this.execTeardown =
|
|
3220
|
+
this.disconnectExecution(), this.executionAdapter = e, this.execTeardown = hr(e, {
|
|
3221
3221
|
onIntent: (e, t) => {
|
|
3222
3222
|
let n = (e) => t(e.payload);
|
|
3223
3223
|
return this.eventBus.on(e, n), () => this.eventBus.off(e, n);
|
|
@@ -3356,7 +3356,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
3356
3356
|
setVisibleRangePreset(e) {
|
|
3357
3357
|
let t = this.getDisplayData();
|
|
3358
3358
|
if (t.length === 0) return;
|
|
3359
|
-
let n = t.length - 1, r = u(t), i =
|
|
3359
|
+
let n = t.length - 1, r = u(t), i = Rt(e, t[n].time * r, this.displayTz), a = i === null ? null : i / r;
|
|
3360
3360
|
if (a === null || a < t[0].time) {
|
|
3361
3361
|
this.fitContent();
|
|
3362
3362
|
return;
|
|
@@ -3554,7 +3554,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
3554
3554
|
}
|
|
3555
3555
|
let t = this.crosshairSeries(), n = e >= 0 && e < t.length ? t[e] : void 0, r = n && e > 0 ? t[e - 1] : void 0;
|
|
3556
3556
|
this.crosshairHandler.getPosition() || this.chartLegend.setHoverBar(n ?? null, r ?? null);
|
|
3557
|
-
let i = n ?
|
|
3557
|
+
let i = n ? A(t)[e]?.time ?? n.time : void 0;
|
|
3558
3558
|
this.eventBus.emit("crosshairSync", {
|
|
3559
3559
|
barIndex: e,
|
|
3560
3560
|
...n ? { bar: n } : {},
|
|
@@ -3633,7 +3633,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
3633
3633
|
return this.periodLevels.getPeriod();
|
|
3634
3634
|
}
|
|
3635
3635
|
setTimeZone(e) {
|
|
3636
|
-
|
|
3636
|
+
Lr(e), this.timeZoneSetting = e, this.applyTimeZone();
|
|
3637
3637
|
}
|
|
3638
3638
|
getTimeZone() {
|
|
3639
3639
|
return this.timeZoneSetting;
|
|
@@ -3642,7 +3642,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
3642
3642
|
return this.displayTz;
|
|
3643
3643
|
}
|
|
3644
3644
|
getExchangeTimeZone() {
|
|
3645
|
-
return [
|
|
3645
|
+
return [C(this.symbolInfo), this.marketConfig?.timeZone].find((e) => e && y(e)) ?? null;
|
|
3646
3646
|
}
|
|
3647
3647
|
setTimezone(e) {
|
|
3648
3648
|
this.setTimeZone(e);
|
|
@@ -3669,7 +3669,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
3669
3669
|
this.indicatorEngine.setExchangeTimeZone(e, t.length > 0 ? t : void 0) && t.length > 0 && this.announceIndicatorUpdate(0);
|
|
3670
3670
|
}
|
|
3671
3671
|
holdStudyZone() {
|
|
3672
|
-
this.endStudyZoneWait(), this.studyZoneHeld = !0, this.studyZoneTimer = setTimeout(() => this.releaseStudyZone(),
|
|
3672
|
+
this.endStudyZoneWait(), this.studyZoneHeld = !0, this.studyZoneTimer = setTimeout(() => this.releaseStudyZone(), ut);
|
|
3673
3673
|
}
|
|
3674
3674
|
endStudyZoneWait() {
|
|
3675
3675
|
this.studyZoneReleaseQueued = !1, this.studyZoneTimer !== null && (clearTimeout(this.studyZoneTimer), this.studyZoneTimer = null);
|
|
@@ -3684,7 +3684,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
3684
3684
|
}
|
|
3685
3685
|
spokenBarTime(e) {
|
|
3686
3686
|
let t = this.getDisplayData(), n = e * u(t), r = this.numberLocale || "en-US";
|
|
3687
|
-
return d(t) === !0 ?
|
|
3687
|
+
return d(t) === !0 ? fe(r, { dateStyle: "medium" }, l(n, this.displayTz, this.getExchangeTimeZone()))(n) : fe(r, {
|
|
3688
3688
|
dateStyle: "medium",
|
|
3689
3689
|
timeStyle: "short"
|
|
3690
3690
|
}, this.displayTz)(n);
|
|
@@ -3697,18 +3697,18 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
3697
3697
|
this.studyZoneHeld = !1, this.endStudyZoneWait(), this.useSymbolInfo(e);
|
|
3698
3698
|
}
|
|
3699
3699
|
useSymbolInfo(e) {
|
|
3700
|
-
let t = e && this.symbolInfo?.symbol === e.symbol ?
|
|
3701
|
-
this.symbolInfo = e ?
|
|
3700
|
+
let t = e && this.symbolInfo?.symbol === e.symbol ? C(this.symbolInfo) : void 0;
|
|
3701
|
+
this.symbolInfo = e ? Rr({
|
|
3702
3702
|
...e,
|
|
3703
3703
|
sessions: e.sessions?.map((e) => ({ ...e }))
|
|
3704
3704
|
}, 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);
|
|
3705
3705
|
let n = (this.symbolInfo?.sessions ?? []).flatMap((e) => {
|
|
3706
|
-
let t =
|
|
3706
|
+
let t = S(e.start), n = S(e.end);
|
|
3707
3707
|
return t === null || n === null ? [] : [{
|
|
3708
3708
|
startMinute: t,
|
|
3709
3709
|
endMinute: n
|
|
3710
3710
|
}];
|
|
3711
|
-
}), i =
|
|
3711
|
+
}), i = C(this.symbolInfo);
|
|
3712
3712
|
this.sessionShading.replaceConfig(n.length > 0 && i && y(i) ? {
|
|
3713
3713
|
timeZone: i,
|
|
3714
3714
|
windows: n,
|
|
@@ -3723,11 +3723,11 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
3723
3723
|
if (!e || typeof e != "object") return;
|
|
3724
3724
|
let t = this.currentSymbol, n = (e) => !e || e.toUpperCase() === t.toUpperCase();
|
|
3725
3725
|
if (!n(e.symbol)) return;
|
|
3726
|
-
let r = this.symbolInfo && n(this.symbolInfo.symbol) ? this.symbolInfo : null, i =
|
|
3726
|
+
let r = this.symbolInfo && n(this.symbolInfo.symbol) ? this.symbolInfo : null, i = Rr({
|
|
3727
3727
|
...r,
|
|
3728
3728
|
...e,
|
|
3729
3729
|
symbol: e.symbol || r?.symbol || t
|
|
3730
|
-
},
|
|
3730
|
+
}, C(r));
|
|
3731
3731
|
r && JSON.stringify(i) === JSON.stringify(r) || (this.symbolInfoSeq++, this.setSymbolInfo(i));
|
|
3732
3732
|
}
|
|
3733
3733
|
resolveStreamSymbol(e, t) {
|
|
@@ -3788,7 +3788,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
3788
3788
|
return t !== this.rendererToken || this.disposed ? (r?.destroy(), this.getRenderer()) : i === "limit" ? Mt() > 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());
|
|
3789
3789
|
}
|
|
3790
3790
|
waitForGpu(e) {
|
|
3791
|
-
this.stopWaitingForGpu?.(), this.stopWaitingForGpu = e ?
|
|
3791
|
+
this.stopWaitingForGpu?.(), this.stopWaitingForGpu = e ? qt(e) : null;
|
|
3792
3792
|
}
|
|
3793
3793
|
getRenderer() {
|
|
3794
3794
|
return this.engine.getGpu() ? "webgl" : "canvas";
|
|
@@ -3810,7 +3810,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
3810
3810
|
this.engine.getGpu() && this.engine.renderNow();
|
|
3811
3811
|
}
|
|
3812
3812
|
screenshot(e) {
|
|
3813
|
-
this.features.screenshot && (this.freshFrame(),
|
|
3813
|
+
this.features.screenshot && (this.freshFrame(), k.download(this.container, e, this.themeManager.getTheme().background));
|
|
3814
3814
|
}
|
|
3815
3815
|
async copyScreenshot() {
|
|
3816
3816
|
if (!this.features.screenshot) return !1;
|
|
@@ -3818,7 +3818,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
3818
3818
|
if (!t?.write || !e) return !1;
|
|
3819
3819
|
try {
|
|
3820
3820
|
this.freshFrame();
|
|
3821
|
-
let n =
|
|
3821
|
+
let n = k.toBlob(this.container, this.themeManager.getTheme().background).then((e) => {
|
|
3822
3822
|
if (!e) throw Error("No chart image to copy");
|
|
3823
3823
|
return e;
|
|
3824
3824
|
});
|
|
@@ -3836,10 +3836,10 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
3836
3836
|
}
|
|
3837
3837
|
}
|
|
3838
3838
|
screenshotDataURL() {
|
|
3839
|
-
return this.features.screenshot ? (this.freshFrame(),
|
|
3839
|
+
return this.features.screenshot ? (this.freshFrame(), k.toDataURL(this.container, this.themeManager.getTheme().background)) : null;
|
|
3840
3840
|
}
|
|
3841
3841
|
async screenshotBlob() {
|
|
3842
|
-
return this.features.screenshot ? (this.freshFrame(),
|
|
3842
|
+
return this.features.screenshot ? (this.freshFrame(), k.toBlob(this.container, this.themeManager.getTheme().background)) : null;
|
|
3843
3843
|
}
|
|
3844
3844
|
addAlert(e, t = "crossing", n, r = "price", i, a = {}) {
|
|
3845
3845
|
if (!this.features.alerts) return null;
|
|
@@ -3967,7 +3967,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
3967
3967
|
let t = this.replaySession ? this.replayOffset : 0;
|
|
3968
3968
|
if (!this.replaySession) {
|
|
3969
3969
|
if (this.series.length() === 0) return;
|
|
3970
|
-
this.series.beginReplay(), this.replaySession =
|
|
3970
|
+
this.series.beginReplay(), this.replaySession = ui(this.currentSymbol);
|
|
3971
3971
|
}
|
|
3972
3972
|
let n = this.replaySession, { steps: r, startTime: i, hideHistory: a, revealMarks: o, step: s, ...c } = e ?? {};
|
|
3973
3973
|
c.animate = c.animate === !0;
|
|
@@ -3978,13 +3978,13 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
3978
3978
|
let m = r ? this.replayStepsOver(n, p, !0) : null;
|
|
3979
3979
|
this.options.autoScale = !0, this.buildReplay(p, m, f);
|
|
3980
3980
|
let h = this.replayStepsSeries;
|
|
3981
|
-
h && c.startIndex !== void 0 && (c.startIndex =
|
|
3981
|
+
h && c.startIndex !== void 0 && (c.startIndex = yi(h, p, c.startIndex));
|
|
3982
3982
|
let g = h ?? p, _ = g[Math.max(0, Math.min(Math.floor(Number(c.startIndex ?? 0)) || 0, g.length - 1))];
|
|
3983
3983
|
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);
|
|
3984
3984
|
}
|
|
3985
3985
|
buildReplay(e, t, n) {
|
|
3986
3986
|
let r = this.replaySession?.animate === !0, i = r ? null : t;
|
|
3987
|
-
this.replayPieces = r && t ?
|
|
3987
|
+
this.replayPieces = r && t ? Si(t, e) : null, this.replayForming = null, this.replayOffset = n, this.replayStepsSeries = i, this.replayCoarse = e;
|
|
3988
3988
|
let a = this.replayRestarting;
|
|
3989
3989
|
this.replayRestarting = !0;
|
|
3990
3990
|
try {
|
|
@@ -3998,7 +3998,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
3998
3998
|
let n = t, a = e[t];
|
|
3999
3999
|
if (i) {
|
|
4000
4000
|
let r = i[t];
|
|
4001
|
-
n = Q(e, r.time), c = c !== null && s === t - 1 && n === o - 1 && c ?
|
|
4001
|
+
n = Q(e, r.time), c = c !== null && s === t - 1 && n === o - 1 && c ? wi(c, r) : bi(e[n], i, t), a = xi(i, e, t, n) ? e[n] : c;
|
|
4002
4002
|
}
|
|
4003
4003
|
let u = this.replayForming;
|
|
4004
4004
|
this.replayForming = null, s = t;
|
|
@@ -4022,7 +4022,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4022
4022
|
});
|
|
4023
4023
|
}), r && (this.replayPhaseUnsub = this.replayManager.on("phase", ({ index: t, fraction: n }) => {
|
|
4024
4024
|
if (!e[t] || this.series.length() !== o || o !== t && o !== t + 1) return;
|
|
4025
|
-
let r = this.replayForming?.index === t ? this.replayForming.path : this.replayPathOf(e, t), i =
|
|
4025
|
+
let r = this.replayForming?.index === t ? this.replayForming.path : this.replayPathOf(e, t), i = Ci() ? Ar(r, n) : n, a = o === t, s = a && this.autoScrollOnNewBar && this.viewport.isAtEnd(), c = kr(r, i);
|
|
4026
4026
|
a ? this.series.appendReplayed(c) : this.series.updateReplayed(c), o = t + 1, this.replayForming = {
|
|
4027
4027
|
index: t,
|
|
4028
4028
|
path: r
|
|
@@ -4032,7 +4032,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4032
4032
|
drawFormingBar(e, t, n, r) {
|
|
4033
4033
|
this.currentPriceLine.setPrice(e.close, t);
|
|
4034
4034
|
let i = this.series.bars();
|
|
4035
|
-
if (this.recalcIndicatorsFrom(i, i.length - 1), (n || !
|
|
4035
|
+
if (this.recalcIndicatorsFrom(i, i.length - 1), (n || !oi.has(this.options.chartType)) && (this.displayDataCache = null), !n) {
|
|
4036
4036
|
this.scheduleRender();
|
|
4037
4037
|
return;
|
|
4038
4038
|
}
|
|
@@ -4040,22 +4040,22 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4040
4040
|
}
|
|
4041
4041
|
replayPathOf(e, t) {
|
|
4042
4042
|
let n = e[t];
|
|
4043
|
-
return
|
|
4043
|
+
return wr(n, this.replayPieces?.get(n.time) ?? this.replayLoader?.loader.piecesOf(n.time) ?? []);
|
|
4044
4044
|
}
|
|
4045
4045
|
loadReplaySteps(e, t) {
|
|
4046
4046
|
let n = this.replayLoader?.loader;
|
|
4047
4047
|
if (!n) return;
|
|
4048
4048
|
n.evictBefore(e[t].time);
|
|
4049
4049
|
let r = this.replayManager.getStepMs();
|
|
4050
|
-
n.ensure(e, t, Number.isFinite(r) && r > 0 ? Math.ceil(
|
|
4050
|
+
n.ensure(e, t, Number.isFinite(r) && r > 0 ? Math.ceil(ai / r) : 1);
|
|
4051
4051
|
}
|
|
4052
4052
|
useReplayLoader(e, t) {
|
|
4053
|
-
let n = this.streamAdapter, r = this.streamTimeframe, i = e.step && n && r !== null ?
|
|
4053
|
+
let n = this.streamAdapter, r = this.streamTimeframe, i = e.step && n && r !== null ? Nr(e.step, r, (e) => j(n, e)) : null, a = `${this.currentSymbol}|${r}|${i}`;
|
|
4054
4054
|
if (!t && this.replayLoader?.key === a || (this.replayLoader?.loader.dispose(), this.replayLoader = null, !i || !n || r === null)) return;
|
|
4055
|
-
let o = P(n), s = o.fetchHistoryBefore, c = this.currentSymbol, l =
|
|
4055
|
+
let o = P(n), s = o.fetchHistoryBefore, c = this.currentSymbol, l = w(r), u = new _r({
|
|
4056
4056
|
source: s ? (e, t) => s.call(o, c, i, e, t) : null,
|
|
4057
4057
|
step: i,
|
|
4058
|
-
ratio: Math.max(1, Math.round(l /
|
|
4058
|
+
ratio: Math.max(1, Math.round(l / w(i))),
|
|
4059
4059
|
barMs: l,
|
|
4060
4060
|
keep: (e) => this.series.inHoursShown(e),
|
|
4061
4061
|
report: (e) => this.eventBus.emit("replayStepsLoad", e)
|
|
@@ -4070,7 +4070,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4070
4070
|
if (!i || !a?.setMarkPrice || !o) return;
|
|
4071
4071
|
let s = i.fedTime;
|
|
4072
4072
|
if (s === null) {
|
|
4073
|
-
i.fedTime = o.time, i.fedFraction = r, this.feedReplayPrice(
|
|
4073
|
+
i.fedTime = o.time, i.fedFraction = r, this.feedReplayPrice(kr(n, r).close, o.time);
|
|
4074
4074
|
return;
|
|
4075
4075
|
}
|
|
4076
4076
|
if (o.time < s || o.time === s && r <= i.fedFraction) return;
|
|
@@ -4078,8 +4078,8 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4078
4078
|
if (o.time > s) {
|
|
4079
4079
|
let a = Y(e, s);
|
|
4080
4080
|
e[a]?.time === s && i.fedFraction < 1 && c.push(...q(this.replayPathOf(e, a), i.fedFraction, 1));
|
|
4081
|
-
let o = e.slice(X(e, s), t), l = Math.ceil(o.length /
|
|
4082
|
-
for (let e = 0; e < o.length; e += l) c.push(...
|
|
4081
|
+
let o = e.slice(X(e, s), t), l = Math.ceil(o.length / gi);
|
|
4082
|
+
for (let e = 0; e < o.length; e += l) c.push(..._i(o.slice(e, e + l)));
|
|
4083
4083
|
c.push(...q(n, -1, r));
|
|
4084
4084
|
} else c.push(...q(n, i.fedFraction, r));
|
|
4085
4085
|
i.fedTime = o.time, i.fedFraction = r;
|
|
@@ -4098,7 +4098,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4098
4098
|
if (n.length === 0) return;
|
|
4099
4099
|
let r = t.windowTime === null ? 0 : Math.min(Y(n, t.windowTime), n.length - 1), i = r > 0 ? n.slice(r) : n;
|
|
4100
4100
|
this.useReplayLoader(t, !1);
|
|
4101
|
-
let a = this.replayStepsOver(t, i), o = t.animate ? null : a, s = t.until === null ? 0 :
|
|
4101
|
+
let a = this.replayStepsOver(t, i), o = t.animate ? null : a, s = t.until === null ? 0 : pi(o ?? i, t.until);
|
|
4102
4102
|
if (s < 0 && this.canPageBackForReplay(t)) {
|
|
4103
4103
|
this.holdReplay(), t.held && t.held.pagesBack++, queueMicrotask(() => void this.pageBackForReplay(t));
|
|
4104
4104
|
return;
|
|
@@ -4106,7 +4106,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4106
4106
|
let c = this.getReplayState(), l = t.held !== null && (e === "hours" || e === "bar"), u = t.held?.state ?? c;
|
|
4107
4107
|
l || (t.held = null), t.symbol = this.currentSymbol;
|
|
4108
4108
|
let d = this.replayManager.remainingMs();
|
|
4109
|
-
this.clearBarHolders(), t.animate &&
|
|
4109
|
+
this.clearBarHolders(), t.animate && fi(t, this.replayCoarse, i);
|
|
4110
4110
|
let f = this.replayRestarting;
|
|
4111
4111
|
this.replayRestarting = !0, this.replayCause = e === "older" ? "older" : "series";
|
|
4112
4112
|
try {
|
|
@@ -4129,14 +4129,14 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4129
4129
|
}
|
|
4130
4130
|
replayStepsOver(e, t, n = !1) {
|
|
4131
4131
|
if (!e.steps || e.stepsSymbol !== this.currentSymbol) return null;
|
|
4132
|
-
let r =
|
|
4133
|
-
return r && (n ||
|
|
4132
|
+
let r = vi(this.series.inHoursShown(e.steps), t);
|
|
4133
|
+
return r && (n || hi(r, t)) ? r : null;
|
|
4134
4134
|
}
|
|
4135
4135
|
canPageBackForReplay(e) {
|
|
4136
|
-
return this.history.hasLoader() && this.history.hasMore() && (e.held?.pagesBack ?? 0) <
|
|
4136
|
+
return this.history.hasLoader() && this.history.hasMore() && (e.held?.pagesBack ?? 0) < si;
|
|
4137
4137
|
}
|
|
4138
4138
|
async pageBackForReplay(e) {
|
|
4139
|
-
this.replaySession !== e || !e.held || await this.history.loadMore() > 0 || this.replaySession !== e || !e.held || (e.held.pagesBack =
|
|
4139
|
+
this.replaySession !== e || !e.held || await this.history.loadMore() > 0 || this.replaySession !== e || !e.held || (e.held.pagesBack = si, this.rebaseReplay("older"));
|
|
4140
4140
|
}
|
|
4141
4141
|
holdReplay() {
|
|
4142
4142
|
let e = this.replaySession;
|
|
@@ -4169,7 +4169,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4169
4169
|
this.signalMarkerManager.setRevealUntil(e, t), this.tradeZoneManager.setRevealUntil(e, t);
|
|
4170
4170
|
}
|
|
4171
4171
|
replaySeekToTime(e) {
|
|
4172
|
-
!this.replaySession || !this.replayCoarse || this.replaySeek(Math.max(0,
|
|
4172
|
+
!this.replaySession || !this.replayCoarse || this.replaySeek(Math.max(0, pi(this.replayStepsSeries ?? this.replayCoarse, e)));
|
|
4173
4173
|
}
|
|
4174
4174
|
feedReplayPrice(e, t) {
|
|
4175
4175
|
let n = this.executionAdapter;
|
|
@@ -4191,8 +4191,8 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4191
4191
|
if (i.time <= n.fedTime) return;
|
|
4192
4192
|
let a = e.slice(X(e, n.fedTime), t + 1);
|
|
4193
4193
|
n.fedTime = i.time;
|
|
4194
|
-
let o = Math.ceil(a.length /
|
|
4195
|
-
for (let e = 0; e < a.length; e += o) for (let [t, n] of
|
|
4194
|
+
let o = Math.ceil(a.length / gi);
|
|
4195
|
+
for (let e = 0; e < a.length; e += o) for (let [t, n] of _i(a.slice(e, e + o))) r.setMarkPrice(t, n);
|
|
4196
4196
|
this.tradingManager.setCurrentPrice(i.close);
|
|
4197
4197
|
}
|
|
4198
4198
|
getReplayBarIndex() {
|
|
@@ -4203,7 +4203,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4203
4203
|
}
|
|
4204
4204
|
replaySeekToBar(e) {
|
|
4205
4205
|
let t = this.replayStepsSeries;
|
|
4206
|
-
this.replaySeek(t && this.replayCoarse ?
|
|
4206
|
+
this.replaySeek(t && this.replayCoarse ? yi(t, this.replayCoarse, e) : e);
|
|
4207
4207
|
}
|
|
4208
4208
|
replayPause() {
|
|
4209
4209
|
this.setHeldState("paused") || this.replayManager.pause();
|
|
@@ -4241,10 +4241,10 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4241
4241
|
if (!n) return null;
|
|
4242
4242
|
let r = n.chartRect, i = Infinity, a = -Infinity, o = Infinity, s = -Infinity;
|
|
4243
4243
|
for (let e of t.anchors) {
|
|
4244
|
-
let
|
|
4245
|
-
i = Math.min(i,
|
|
4244
|
+
let { x: r, y: c } = this.drawingManager.anchorPoint(t.type, e, n);
|
|
4245
|
+
i = Math.min(i, r), a = Math.max(a, r), o = Math.min(o, c), s = Math.max(s, c);
|
|
4246
4246
|
}
|
|
4247
|
-
return
|
|
4247
|
+
return Jr.has(t.type) ? [i, a] = [r.x, r.x + r.width] : t.type === "horizontalRay" && (a = r.x + r.width), Yr.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 ? {
|
|
4248
4248
|
x: i,
|
|
4249
4249
|
y: o,
|
|
4250
4250
|
width: a - i,
|
|
@@ -4280,7 +4280,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4280
4280
|
};
|
|
4281
4281
|
}
|
|
4282
4282
|
captureSnapshot() {
|
|
4283
|
-
return
|
|
4283
|
+
return T.capture({
|
|
4284
4284
|
getDrawings: () => [...this.getDrawings().filter((e) => e.paneId === void 0 || this.layoutManager.getPanels().some((t) => t.id === e.paneId)), ...this.keptPaneDrawings],
|
|
4285
4285
|
getTheme: () => this.themeManager.getBaseTheme(),
|
|
4286
4286
|
getAlerts: () => this.getAlerts(),
|
|
@@ -4293,14 +4293,14 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4293
4293
|
});
|
|
4294
4294
|
}
|
|
4295
4295
|
restoreIndicators(e, t) {
|
|
4296
|
-
let n =
|
|
4296
|
+
let n = Zr(e), r = /* @__PURE__ */ new Map();
|
|
4297
4297
|
this.unrestoredIndicators = [];
|
|
4298
4298
|
let i = new Set(this.indicatorEngine.getAvailableIndicators().map((e) => e.id)), a = [], o = /* @__PURE__ */ new Set();
|
|
4299
4299
|
if (t) {
|
|
4300
4300
|
let e = new Map(n.map((e) => [e.instanceId, e])), t = this.getIndicatorSetup();
|
|
4301
4301
|
for (let n of t) {
|
|
4302
4302
|
let t = e.get(n.instanceId);
|
|
4303
|
-
t &&
|
|
4303
|
+
t && Qr(n, t) && o.add(n.instanceId);
|
|
4304
4304
|
}
|
|
4305
4305
|
for (let e of t) o.has(e.instanceId) || this.removeIndicator(e.instanceId);
|
|
4306
4306
|
for (let e of [...o]) this.indicatorEngine.getIndicatorConfig(e) || o.delete(e);
|
|
@@ -4362,7 +4362,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4362
4362
|
let s = t.levels ?? null;
|
|
4363
4363
|
JSON.stringify(s) !== JSON.stringify(o?.levels ?? null) && this.setIndicatorLevels(e, s);
|
|
4364
4364
|
let c = t.intervals ?? null;
|
|
4365
|
-
JSON.stringify(c) !== JSON.stringify(o?.intervals ?? null) && this.setIndicatorIntervalsNow(e, c), this.setPaneStyleNow(e, t.paneStyle ?
|
|
4365
|
+
JSON.stringify(c) !== JSON.stringify(o?.intervals ?? null) && this.setIndicatorIntervalsNow(e, c), this.setPaneStyleNow(e, t.paneStyle ? se(t.paneStyle) : null);
|
|
4366
4366
|
}
|
|
4367
4367
|
restorePanes(e) {
|
|
4368
4368
|
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, {
|
|
@@ -4475,7 +4475,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4475
4475
|
}
|
|
4476
4476
|
let o = this.getIndicatorSetup();
|
|
4477
4477
|
if (JSON.stringify(n) === JSON.stringify(o)) return a;
|
|
4478
|
-
let s = performance.now(), c = this.undoRedoManager.last(), l = e !== void 0 && c?.type === "indicators" && c.indicators?.subject === e && s - (c.indicators.at ?? 0) <
|
|
4478
|
+
let s = performance.now(), c = this.undoRedoManager.last(), l = e !== void 0 && c?.type === "indicators" && c.indicators?.subject === e && s - (c.indicators.at ?? 0) < Vr && JSON.stringify(c.indicators.after) === JSON.stringify(n), u = {
|
|
4479
4479
|
type: "indicators",
|
|
4480
4480
|
before: null,
|
|
4481
4481
|
after: null
|
|
@@ -4486,7 +4486,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4486
4486
|
...c.indicators,
|
|
4487
4487
|
after: o,
|
|
4488
4488
|
at: s,
|
|
4489
|
-
...
|
|
4489
|
+
...Ur([...c.indicators.renames ?? [], ...r])
|
|
4490
4490
|
}
|
|
4491
4491
|
}) : this.undoRedoManager.push({
|
|
4492
4492
|
...u,
|
|
@@ -4495,7 +4495,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4495
4495
|
after: o,
|
|
4496
4496
|
subject: e,
|
|
4497
4497
|
at: s,
|
|
4498
|
-
...
|
|
4498
|
+
...Ur(r)
|
|
4499
4499
|
}
|
|
4500
4500
|
}), a;
|
|
4501
4501
|
}
|
|
@@ -4529,19 +4529,19 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4529
4529
|
let t = this.layoutManager.getPanels().find((t) => t.id === e);
|
|
4530
4530
|
if (!t || t.position !== "top" && t.position !== "bottom" || this.layoutManager.isPanelShownCollapsed(e)) return null;
|
|
4531
4531
|
let n = this.buildPanelRenderInfos().find((t) => t.instanceId === e);
|
|
4532
|
-
return !n || n.viewport.chartRect.height <
|
|
4532
|
+
return !n || n.viewport.chartRect.height < Hr ? null : {
|
|
4533
4533
|
...n.viewport,
|
|
4534
4534
|
data: this.getDisplayData()
|
|
4535
4535
|
};
|
|
4536
4536
|
}
|
|
4537
4537
|
saveState(e) {
|
|
4538
4538
|
if (!this.features.saveLoad) return null;
|
|
4539
|
-
let t = this.captureSnapshot(), n =
|
|
4540
|
-
return e &&
|
|
4539
|
+
let t = this.captureSnapshot(), n = T.serialize(t);
|
|
4540
|
+
return e && T.saveToStorage(e, t), n;
|
|
4541
4541
|
}
|
|
4542
4542
|
loadState(e) {
|
|
4543
4543
|
if (!this.features.saveLoad) return;
|
|
4544
|
-
let t =
|
|
4544
|
+
let t = T.deserialize(e);
|
|
4545
4545
|
this.chartTypeOptions = t.chartTypeOptions ?? {}, this.displayDataCache = null, this.reshapeMemo.clear(), 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");
|
|
4546
4546
|
let n = t.version >= 2 && this.features.indicators ? this.withoutIndicatorHistory(() => this.restoreIndicators(t.indicators, !1)) : /* @__PURE__ */ new Map();
|
|
4547
4547
|
this.drawingManager.renamePanes(n);
|
|
@@ -4554,7 +4554,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4554
4554
|
let t = e.indexOf(":"), r = t > 0 ? n.get(e.slice(0, t)) : void 0;
|
|
4555
4555
|
return r ? r + e.slice(t) : e;
|
|
4556
4556
|
}, r = t(e.channel), i = {
|
|
4557
|
-
...
|
|
4557
|
+
...zt(e),
|
|
4558
4558
|
...e.target ? { target: t(e.target) } : {}
|
|
4559
4559
|
};
|
|
4560
4560
|
if (!e.expired) {
|
|
@@ -4574,19 +4574,19 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4574
4574
|
}
|
|
4575
4575
|
loadStateFromStorage(e) {
|
|
4576
4576
|
if (!this.features.saveLoad) return !1;
|
|
4577
|
-
let t =
|
|
4578
|
-
return t ? (this.loadState(
|
|
4577
|
+
let t = T.loadFromStorage(e);
|
|
4578
|
+
return t ? (this.loadState(T.serialize(t)), !0) : !1;
|
|
4579
4579
|
}
|
|
4580
4580
|
downloadState(e) {
|
|
4581
|
-
this.features.saveLoad &&
|
|
4581
|
+
this.features.saveLoad && T.downloadFile(this.captureSnapshot(), e);
|
|
4582
4582
|
}
|
|
4583
4583
|
async loadStateFromFile() {
|
|
4584
4584
|
if (!this.features.saveLoad) return;
|
|
4585
|
-
let e = await
|
|
4586
|
-
this.loadState(
|
|
4585
|
+
let e = await T.loadFromFile();
|
|
4586
|
+
this.loadState(T.serialize(e));
|
|
4587
4587
|
}
|
|
4588
4588
|
setLocale(e) {
|
|
4589
|
-
|
|
4589
|
+
le(e), this.engine.requestRender();
|
|
4590
4590
|
}
|
|
4591
4591
|
setNumberLocale(e) {
|
|
4592
4592
|
this.numberLocale = e, this.viewport.setNumberLocale(e), this.priceAxis.setLocale(e), this.leftPriceAxis.setLocale(e), this.crosshairHandler.setLocale(e), this.timeAxis.setLocale(e), this.chartLegend.setLocale(e), this.crosshairTooltip.setLocale(e), this.pinnedTooltip.setLocale(e), this.currentPriceLine.setLocale(e), this.updateViewportAndRender();
|
|
@@ -4636,14 +4636,14 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4636
4636
|
this.disposed = !0, this.stopWatchingVisibility?.(), this.stopWatchingVisibility = null, this.waitForGpu(null), this.countdownInterval && clearInterval(this.countdownInterval), this.history.setLoader(null), this.disableAutoSave(), this.disconnectStream(), this.disconnectExecution(), this.onWindowKeyDown &&= (window.removeEventListener("keydown", this.onWindowKeyDown), null), this.keyboardHandler = null, this.a11y?.destroy(), this.a11y = null, this.interactionManager.detach(), this.tradingManager.destroy(), this.animator.dispose(), this.crosshairTooltip.destroy(), this.pinnedTooltip.destroy(), this.replayRestarting = !0, this.replayManager.dispose(), this.alertManager.dispose(), this.undoRedoManager.clear(), this.engine.destroy(), this.eventBus.destroy(), this.labelWidths.destroy(), this.container.innerHTML = "";
|
|
4637
4637
|
}
|
|
4638
4638
|
createChartRenderer(e) {
|
|
4639
|
-
let t =
|
|
4640
|
-
return t instanceof
|
|
4639
|
+
let t = kn(e, (e) => this.pluginManager.getChartType(e));
|
|
4640
|
+
return t instanceof ze && t.setPriceText((e) => this.formatPrice(e)), t;
|
|
4641
4641
|
}
|
|
4642
4642
|
crosshairSeries() {
|
|
4643
4643
|
return this.isTimeAligned() ? this.series.bars() : this.getDisplayData();
|
|
4644
4644
|
}
|
|
4645
4645
|
getDisplayData() {
|
|
4646
|
-
let e = this.series.bars(), t = this.options.chartType === "rangeBars" ?
|
|
4646
|
+
let e = this.series.bars(), t = this.options.chartType === "rangeBars" ? En(e, (e) => this.stepAt(e)) : void 0;
|
|
4647
4647
|
if (this.displayDataCache && t === this.displayDataStep) return this.displayDataCache;
|
|
4648
4648
|
if (e.length === 0) return e;
|
|
4649
4649
|
let n = this.displaySeries(e, t);
|
|
@@ -4651,9 +4651,9 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4651
4651
|
}
|
|
4652
4652
|
displaySeries(e, t) {
|
|
4653
4653
|
let n = this.options.chartType, r = (e) => this.pluginManager.getChartType(e);
|
|
4654
|
-
if (n !== "pointAndFigure" || r(n)) return
|
|
4655
|
-
let { columns: i, boxSize: a } =
|
|
4656
|
-
return this.chartRenderer instanceof
|
|
4654
|
+
if (n !== "pointAndFigure" || r(n)) return An(n, e, r, this.chartTypeOptions, t, this.reshapeMemo);
|
|
4655
|
+
let { columns: i, boxSize: a } = pn(e, this.chartTypeOptions, this.reshapeMemo);
|
|
4656
|
+
return this.chartRenderer instanceof tt && this.chartRenderer.setBoxSize(a), i;
|
|
4657
4657
|
}
|
|
4658
4658
|
recalcIndicatorsFrom(e, t) {
|
|
4659
4659
|
if (!this.isTimeAligned()) return this.recalcIndicators(e);
|
|
@@ -4665,7 +4665,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4665
4665
|
}
|
|
4666
4666
|
exportBars() {
|
|
4667
4667
|
if (this.isTimeAligned()) return this.series.bars();
|
|
4668
|
-
let e = this.getDisplayData(), t =
|
|
4668
|
+
let e = this.getDisplayData(), t = A(e);
|
|
4669
4669
|
return e.map((e, n) => ({
|
|
4670
4670
|
...e,
|
|
4671
4671
|
time: t[n]?.time ?? e.time
|
|
@@ -4724,12 +4724,12 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4724
4724
|
}
|
|
4725
4725
|
fitPriceScale(e, t) {
|
|
4726
4726
|
if (e.length === 0) return;
|
|
4727
|
-
let n = Math.max(0, t.visibleRange.from), r = Math.min(t.visibleRange.to, e.length - 1), i =
|
|
4727
|
+
let n = Math.max(0, t.visibleRange.from), r = Math.min(t.visibleRange.to, e.length - 1), i = ii(ii(m(e, n, r, 0), this.indicatorEngine.getOverlayPriceRange(n, r)), this.features.compareSymbols && this.comparesDrawn() ? this.compareRenderer.getPriceRange(e, t) : null), a = this.features.volume && this.volumeRenderer.isVisible() && ri(e, n, r) ? this.volumeRenderer.getHeightRatio() + Br : D;
|
|
4728
4728
|
this.viewport.setScaleMargins(this.viewport.isInvertScale() ? {
|
|
4729
4729
|
top: a,
|
|
4730
|
-
bottom:
|
|
4730
|
+
bottom: D
|
|
4731
4731
|
} : {
|
|
4732
|
-
top:
|
|
4732
|
+
top: D,
|
|
4733
4733
|
bottom: a
|
|
4734
4734
|
}), this.viewport.fitToPrices(i.min, i.max);
|
|
4735
4735
|
}
|
|
@@ -4751,7 +4751,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4751
4751
|
fitLeftAxisWidth() {
|
|
4752
4752
|
let e = this.leftViewport;
|
|
4753
4753
|
if (!e) return !1;
|
|
4754
|
-
let t = this.themeManager.getTheme(), n =
|
|
4754
|
+
let t = this.themeManager.getTheme(), n = tr({
|
|
4755
4755
|
min: e.priceRange.min,
|
|
4756
4756
|
max: e.priceRange.max,
|
|
4757
4757
|
lastPrice: null,
|
|
@@ -4760,12 +4760,12 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4760
4760
|
fontFamily: t.font.family,
|
|
4761
4761
|
fontSizeSmall: t.font.sizeSmall,
|
|
4762
4762
|
measure: (e, t) => this.measureText(e, t)
|
|
4763
|
-
}), r =
|
|
4763
|
+
}), r = nr(this.leftAxisWidth, n);
|
|
4764
4764
|
return r === this.leftAxisWidth ? !1 : (this.leftAxisWidth = r, this.layoutManager.setLeftAxisWidth(r), this.resolvedLayoutCache = null, this.panelInfoCache = null, this.viewport.setChartRect(this.getResolvedLayout().mainChartRect), !0);
|
|
4765
4765
|
}
|
|
4766
4766
|
fitPriceAxisWidth() {
|
|
4767
4767
|
if (!this.features.priceAxis) return !1;
|
|
4768
|
-
let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n =
|
|
4768
|
+
let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n = tr({
|
|
4769
4769
|
min: e.min,
|
|
4770
4770
|
max: e.max,
|
|
4771
4771
|
lastPrice: this.currentPriceLine.getPrice(),
|
|
@@ -4776,14 +4776,14 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4776
4776
|
fontFamily: t.font.family,
|
|
4777
4777
|
fontSizeSmall: t.font.sizeSmall,
|
|
4778
4778
|
measure: (e, t) => this.measureText(e, t)
|
|
4779
|
-
}), r =
|
|
4779
|
+
}), r = nr(this.priceAxisWidth, n);
|
|
4780
4780
|
return r === this.priceAxisWidth ? !1 : (this.priceAxisWidth = r, this.layoutManager.setPriceAxisWidth(r), this.viewport.setPriceAxisWidth(r), this.resolvedLayoutCache = null, this.panelInfoCache = null, this.viewport.setChartRect(this.getResolvedLayout().mainChartRect), !0);
|
|
4781
4781
|
}
|
|
4782
4782
|
measureText(e, t) {
|
|
4783
4783
|
let n = this.engine.layerManager.getLayer(r.Main)?.ctx;
|
|
4784
|
-
if (n?.canvas.isConnected) return this.labelWidths.get(e, t, () =>
|
|
4784
|
+
if (n?.canvas.isConnected) return this.labelWidths.get(e, t, () => $r(n, e, t));
|
|
4785
4785
|
let i = n ?? this.detachedMeasureContext();
|
|
4786
|
-
return i ?
|
|
4786
|
+
return i ? $r(i, e, t) : e.length * 7;
|
|
4787
4787
|
}
|
|
4788
4788
|
detachedMeasureContext() {
|
|
4789
4789
|
return this.measureCtx === void 0 && (this.measureCtx = typeof document < "u" ? document.createElement("canvas").getContext("2d") : null), this.measureCtx;
|
|
@@ -4824,7 +4824,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4824
4824
|
buildPanelRenderInfos() {
|
|
4825
4825
|
if (this.panelInfoCache) return this.panelInfoCache;
|
|
4826
4826
|
let e = this.getResolvedLayout(), t = this.viewport.getState(), { from: n, to: r } = t.visibleRange, i = e.panels.map((e) => {
|
|
4827
|
-
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) ?? { ...
|
|
4827
|
+
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) ?? { ...Pr }, o = {
|
|
4828
4828
|
x: e.rect.x,
|
|
4829
4829
|
y: e.rect.y + 20,
|
|
4830
4830
|
width: e.rect.width,
|
|
@@ -4909,7 +4909,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4909
4909
|
});
|
|
4910
4910
|
}
|
|
4911
4911
|
drawOverlayPlugins(e, t) {
|
|
4912
|
-
let n =
|
|
4912
|
+
let n = sr(this.pluginManager.getOverlays(), t);
|
|
4913
4913
|
if (n.length === 0) return;
|
|
4914
4914
|
let r = {
|
|
4915
4915
|
viewport: this.viewport.getState(),
|
|
@@ -4930,7 +4930,7 @@ var Kr = 20, qr = 8, Jr = 10, Yr = {
|
|
|
4930
4930
|
};
|
|
4931
4931
|
}
|
|
4932
4932
|
};
|
|
4933
|
-
function
|
|
4933
|
+
function Zr(e) {
|
|
4934
4934
|
let t = new Map(e.map((e) => [e.instanceId, e])), n = [], r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = (e) => {
|
|
4935
4935
|
if (r.has(e.instanceId) || i.has(e.instanceId)) return;
|
|
4936
4936
|
i.add(e.instanceId);
|
|
@@ -4944,19 +4944,19 @@ function $r(e) {
|
|
|
4944
4944
|
for (let t of e) a(t);
|
|
4945
4945
|
return n;
|
|
4946
4946
|
}
|
|
4947
|
-
function
|
|
4947
|
+
function Qr(e, t) {
|
|
4948
4948
|
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);
|
|
4949
4949
|
}
|
|
4950
|
-
function
|
|
4950
|
+
function $r(e, t, n) {
|
|
4951
4951
|
let r = e.font;
|
|
4952
4952
|
e.font = n;
|
|
4953
4953
|
let i = e.measureText(t).width;
|
|
4954
4954
|
return e.font = r, i;
|
|
4955
4955
|
}
|
|
4956
|
-
var
|
|
4957
|
-
function
|
|
4956
|
+
var ei = 300;
|
|
4957
|
+
function ti(e) {
|
|
4958
4958
|
let t = {}, n = e.family;
|
|
4959
|
-
typeof n == "string" && n.trim() !== "" && n.length <=
|
|
4959
|
+
typeof n == "string" && n.trim() !== "" && n.length <= ei && !/[;{}<>\\]|\/\*/.test(n) && (t.family = n);
|
|
4960
4960
|
for (let n of [
|
|
4961
4961
|
"sizeSmall",
|
|
4962
4962
|
"sizeMedium",
|
|
@@ -4967,15 +4967,15 @@ function ri(e) {
|
|
|
4967
4967
|
}
|
|
4968
4968
|
return t;
|
|
4969
4969
|
}
|
|
4970
|
-
function
|
|
4970
|
+
function ni(e) {
|
|
4971
4971
|
let t = e.tagRadius;
|
|
4972
4972
|
return typeof t == "number" && Number.isFinite(t) && t >= 0 ? { tagRadius: Math.min(t, 999) } : {};
|
|
4973
4973
|
}
|
|
4974
|
-
function
|
|
4974
|
+
function ri(e, t, n) {
|
|
4975
4975
|
for (let r = t; r <= n; r++) if (e[r].volume > 0) return !0;
|
|
4976
4976
|
return !1;
|
|
4977
4977
|
}
|
|
4978
|
-
function
|
|
4978
|
+
function ii(e, t) {
|
|
4979
4979
|
return e ? t ? {
|
|
4980
4980
|
min: Math.min(e.min, t.min),
|
|
4981
4981
|
max: Math.max(e.max, t.max)
|
|
@@ -4996,14 +4996,14 @@ function J(e) {
|
|
|
4996
4996
|
bars: e.bars
|
|
4997
4997
|
};
|
|
4998
4998
|
}
|
|
4999
|
-
var
|
|
4999
|
+
var ai = 8e3, oi = new Set([
|
|
5000
5000
|
"candlestick",
|
|
5001
5001
|
"line",
|
|
5002
5002
|
"area",
|
|
5003
5003
|
"bar",
|
|
5004
5004
|
"hollowCandle"
|
|
5005
|
-
]),
|
|
5006
|
-
function
|
|
5005
|
+
]), si = 10, ci = 50, li = .001;
|
|
5006
|
+
function ui(e) {
|
|
5007
5007
|
return {
|
|
5008
5008
|
price: null,
|
|
5009
5009
|
fedTime: null,
|
|
@@ -5018,41 +5018,41 @@ function fi(e) {
|
|
|
5018
5018
|
held: null
|
|
5019
5019
|
};
|
|
5020
5020
|
}
|
|
5021
|
-
function
|
|
5021
|
+
function di(e, t) {
|
|
5022
5022
|
let n = e[t + 1];
|
|
5023
5023
|
return n ? n.time - e[t].time : Z(e);
|
|
5024
5024
|
}
|
|
5025
|
-
function
|
|
5025
|
+
function fi(e, t, n) {
|
|
5026
5026
|
let r = e.fedTime;
|
|
5027
5027
|
if (r === null || !t || t.length === 0 || n.length === 0) return;
|
|
5028
|
-
let i =
|
|
5028
|
+
let i = di(t, Q(t, r)), a = r + (Number.isFinite(i) ? e.fedFraction * i : 0), o = Q(n, a), s = n[o].time;
|
|
5029
5029
|
if (s > a) return;
|
|
5030
|
-
let c =
|
|
5030
|
+
let c = di(n, o);
|
|
5031
5031
|
if (a === s && o > 0) {
|
|
5032
5032
|
e.fedTime = n[o - 1].time, e.fedFraction = 1;
|
|
5033
5033
|
return;
|
|
5034
5034
|
}
|
|
5035
5035
|
e.fedTime = s, e.fedFraction = Number.isFinite(c) && c > 0 ? Math.min(1, (a - s) / c) : 0;
|
|
5036
5036
|
}
|
|
5037
|
-
function
|
|
5037
|
+
function pi(e, t) {
|
|
5038
5038
|
let n = X(e, t), r = e.length - 1;
|
|
5039
5039
|
return n > r && r >= 0 && e[r].time + Z(e) <= t ? r : Math.max(-1, n - 2);
|
|
5040
5040
|
}
|
|
5041
|
-
function
|
|
5041
|
+
function mi(e) {
|
|
5042
5042
|
let t = Infinity;
|
|
5043
5043
|
for (let n = Math.max(1, e.length - 10); n < e.length; n++) t = Math.min(t, e[n].time - e[n - 1].time);
|
|
5044
5044
|
return t;
|
|
5045
5045
|
}
|
|
5046
|
-
function
|
|
5047
|
-
if (!(
|
|
5048
|
-
let n = Math.max(0, e.length -
|
|
5046
|
+
function hi(e, t) {
|
|
5047
|
+
if (!(mi(e) < mi(t))) return !1;
|
|
5048
|
+
let n = Math.max(0, e.length - ci);
|
|
5049
5049
|
for (let r = n; r < e.length; r++) {
|
|
5050
|
-
let n = t[Q(t, e[r].time)], i = (n.high - n.low) *
|
|
5050
|
+
let n = t[Q(t, e[r].time)], i = (n.high - n.low) * li + 2 ** -52;
|
|
5051
5051
|
if (e[r].close > n.high + i || e[r].close < n.low - i) return !1;
|
|
5052
5052
|
}
|
|
5053
5053
|
return !0;
|
|
5054
5054
|
}
|
|
5055
|
-
var
|
|
5055
|
+
var gi = 500;
|
|
5056
5056
|
function Y(e, t) {
|
|
5057
5057
|
let n = 0, r = e.length;
|
|
5058
5058
|
for (; n < r;) {
|
|
@@ -5069,7 +5069,7 @@ function X(e, t) {
|
|
|
5069
5069
|
}
|
|
5070
5070
|
return n;
|
|
5071
5071
|
}
|
|
5072
|
-
function
|
|
5072
|
+
function _i(e) {
|
|
5073
5073
|
let t = 0, n = 0;
|
|
5074
5074
|
for (let r = 1; r < e.length; r++) e[r].low < e[t].low && (t = r), e[r].high > e[n].high && (n = r);
|
|
5075
5075
|
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];
|
|
@@ -5080,9 +5080,9 @@ function Z(e) {
|
|
|
5080
5080
|
for (let n = Math.max(1, e.length - 10); n < e.length; n++) t = Math.max(t, e[n].time - e[n - 1].time);
|
|
5081
5081
|
return t > 0 ? t : Infinity;
|
|
5082
5082
|
}
|
|
5083
|
-
function
|
|
5083
|
+
function vi(e, t) {
|
|
5084
5084
|
if (t.length === 0) return null;
|
|
5085
|
-
let n = t[t.length - 1].time + Z(t), r = e.filter((e) =>
|
|
5085
|
+
let n = t[t.length - 1].time + Z(t), r = e.filter((e) => Ln(e) && e.time >= t[0].time && e.time < n).sort((e, t) => e.time - t.time), i = [];
|
|
5086
5086
|
for (let e of r) (i.length === 0 || i[i.length - 1].time !== e.time) && i.push(e);
|
|
5087
5087
|
if (i.length === 0) return null;
|
|
5088
5088
|
let a = t.findIndex((e) => e.time >= i[0].time);
|
|
@@ -5098,26 +5098,26 @@ function Q(e, t) {
|
|
|
5098
5098
|
}
|
|
5099
5099
|
return n;
|
|
5100
5100
|
}
|
|
5101
|
-
function
|
|
5101
|
+
function yi(e, t, n) {
|
|
5102
5102
|
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;
|
|
5103
5103
|
for (let t = 0; t < e.length && e[t].time < i; t++) a = t;
|
|
5104
5104
|
return Math.max(0, a);
|
|
5105
5105
|
}
|
|
5106
|
-
function
|
|
5106
|
+
function bi(e, t, n) {
|
|
5107
5107
|
let r = n;
|
|
5108
5108
|
for (; r > 0 && t[r - 1].time >= e.time;) r--;
|
|
5109
5109
|
let i = {
|
|
5110
5110
|
...t[r],
|
|
5111
5111
|
time: e.time
|
|
5112
5112
|
};
|
|
5113
|
-
for (let e = r + 1; e <= n; e++) i =
|
|
5113
|
+
for (let e = r + 1; e <= n; e++) i = wi(i, t[e]);
|
|
5114
5114
|
return i;
|
|
5115
5115
|
}
|
|
5116
|
-
function
|
|
5116
|
+
function xi(e, t, n, r) {
|
|
5117
5117
|
let i = e[n + 1], a = t[r + 1];
|
|
5118
5118
|
return i !== void 0 && a !== void 0 && i.time >= a.time;
|
|
5119
5119
|
}
|
|
5120
|
-
function
|
|
5120
|
+
function Si(e, t) {
|
|
5121
5121
|
let n = /* @__PURE__ */ new Map();
|
|
5122
5122
|
for (let r of e) {
|
|
5123
5123
|
let e = t[Q(t, r.time)].time, i = n.get(e);
|
|
@@ -5125,10 +5125,10 @@ function wi(e, t) {
|
|
|
5125
5125
|
}
|
|
5126
5126
|
return n;
|
|
5127
5127
|
}
|
|
5128
|
-
function
|
|
5128
|
+
function Ci() {
|
|
5129
5129
|
return typeof matchMedia == "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
5130
5130
|
}
|
|
5131
|
-
function
|
|
5131
|
+
function wi(e, t) {
|
|
5132
5132
|
return {
|
|
5133
5133
|
time: e.time,
|
|
5134
5134
|
open: e.open,
|
|
@@ -5140,26 +5140,26 @@ function Ei(e, t) {
|
|
|
5140
5140
|
}
|
|
5141
5141
|
//#endregion
|
|
5142
5142
|
//#region src/io/parseOHLCV.ts
|
|
5143
|
-
var
|
|
5143
|
+
var Ti = [
|
|
5144
5144
|
"time",
|
|
5145
5145
|
"timestamp",
|
|
5146
5146
|
"date",
|
|
5147
5147
|
"datetime",
|
|
5148
5148
|
"t"
|
|
5149
|
-
],
|
|
5149
|
+
], Ei = ["open", "o"], Di = ["high", "h"], Oi = ["low", "l"], ki = ["close", "c"], Ai = [
|
|
5150
5150
|
"volume",
|
|
5151
5151
|
"vol",
|
|
5152
5152
|
"v"
|
|
5153
5153
|
];
|
|
5154
|
-
function
|
|
5154
|
+
function ji(e) {
|
|
5155
5155
|
let t = e.trim();
|
|
5156
|
-
return t ? t[0] === "[" || t[0] === "{" ?
|
|
5156
|
+
return t ? t[0] === "[" || t[0] === "{" ? Mi(t) : Ni(t) : {
|
|
5157
5157
|
data: [],
|
|
5158
5158
|
rowCount: 0,
|
|
5159
5159
|
skipped: 0
|
|
5160
5160
|
};
|
|
5161
5161
|
}
|
|
5162
|
-
function
|
|
5162
|
+
function Mi(e) {
|
|
5163
5163
|
let t;
|
|
5164
5164
|
try {
|
|
5165
5165
|
t = JSON.parse(e);
|
|
@@ -5169,19 +5169,19 @@ function Pi(e) {
|
|
|
5169
5169
|
if (!Array.isArray(t)) throw Error("Expected a JSON array of OHLCV rows");
|
|
5170
5170
|
let n = [], r = 0;
|
|
5171
5171
|
for (let e of t) {
|
|
5172
|
-
let t = Array.isArray(e) ?
|
|
5172
|
+
let t = Array.isArray(e) ? Ri(e) : Li(e);
|
|
5173
5173
|
t ? n.push(t) : r++;
|
|
5174
5174
|
}
|
|
5175
|
-
return
|
|
5175
|
+
return Bi(n, t.length, r);
|
|
5176
5176
|
}
|
|
5177
|
-
function
|
|
5177
|
+
function Ni(e) {
|
|
5178
5178
|
let t = e.split(/\r?\n/).filter((e) => e.trim().length > 0);
|
|
5179
5179
|
if (t.length === 0) return {
|
|
5180
5180
|
data: [],
|
|
5181
5181
|
rowCount: 0,
|
|
5182
5182
|
skipped: 0
|
|
5183
5183
|
};
|
|
5184
|
-
let n =
|
|
5184
|
+
let n = Pi(t[0]), r = Fi(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? Ii(r) : {
|
|
5185
5185
|
time: 0,
|
|
5186
5186
|
open: 1,
|
|
5187
5187
|
high: 2,
|
|
@@ -5192,7 +5192,7 @@ function Fi(e) {
|
|
|
5192
5192
|
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");
|
|
5193
5193
|
let o = [], s = 0;
|
|
5194
5194
|
for (let e = +!!i; e < t.length; e++) {
|
|
5195
|
-
let r =
|
|
5195
|
+
let r = Fi(t[e], n), i = zi(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;
|
|
5196
5196
|
if (i === null || ![
|
|
5197
5197
|
c,
|
|
5198
5198
|
l,
|
|
@@ -5211,9 +5211,9 @@ function Fi(e) {
|
|
|
5211
5211
|
volume: Number.isFinite(f) ? f : 0
|
|
5212
5212
|
});
|
|
5213
5213
|
}
|
|
5214
|
-
return
|
|
5214
|
+
return Bi(o, t.length - +!!i, s);
|
|
5215
5215
|
}
|
|
5216
|
-
function
|
|
5216
|
+
function Pi(e) {
|
|
5217
5217
|
let t = {
|
|
5218
5218
|
",": 0,
|
|
5219
5219
|
";": 0,
|
|
@@ -5225,7 +5225,7 @@ function Ii(e) {
|
|
|
5225
5225
|
for (let [e, i] of Object.entries(t)) i > r && (n = e, r = i);
|
|
5226
5226
|
return n;
|
|
5227
5227
|
}
|
|
5228
|
-
function
|
|
5228
|
+
function Fi(e, t) {
|
|
5229
5229
|
let n = [], r = "", i = !1;
|
|
5230
5230
|
for (let a = 0; a < e.length; a++) {
|
|
5231
5231
|
let o = e[a];
|
|
@@ -5233,25 +5233,25 @@ function Li(e, t) {
|
|
|
5233
5233
|
}
|
|
5234
5234
|
return n.push(r), n;
|
|
5235
5235
|
}
|
|
5236
|
-
function
|
|
5236
|
+
function Ii(e) {
|
|
5237
5237
|
let t = (t) => e.findIndex((e) => t.includes(e));
|
|
5238
5238
|
return {
|
|
5239
|
-
time: t(
|
|
5240
|
-
open: t(
|
|
5241
|
-
high: t(
|
|
5242
|
-
low: t(
|
|
5243
|
-
close: t(
|
|
5244
|
-
volume: t(
|
|
5239
|
+
time: t(Ti),
|
|
5240
|
+
open: t(Ei),
|
|
5241
|
+
high: t(Di),
|
|
5242
|
+
low: t(Oi),
|
|
5243
|
+
close: t(ki),
|
|
5244
|
+
volume: t(Ai)
|
|
5245
5245
|
};
|
|
5246
5246
|
}
|
|
5247
|
-
function
|
|
5247
|
+
function Li(e) {
|
|
5248
5248
|
let t = (t) => {
|
|
5249
5249
|
for (let n of t) {
|
|
5250
5250
|
if (e[n] !== void 0) return e[n];
|
|
5251
5251
|
let t = n.toUpperCase();
|
|
5252
5252
|
if (e[t] !== void 0) return e[t];
|
|
5253
5253
|
}
|
|
5254
|
-
}, n =
|
|
5254
|
+
}, n = zi(String(t(Ti) ?? "")), r = Number(t(Ei)), i = Number(t(Di)), a = Number(t(Oi)), o = Number(t(ki)), s = Number(t(Ai) ?? 0);
|
|
5255
5255
|
return n === null || ![
|
|
5256
5256
|
r,
|
|
5257
5257
|
i,
|
|
@@ -5266,9 +5266,9 @@ function zi(e) {
|
|
|
5266
5266
|
volume: Number.isFinite(s) ? s : 0
|
|
5267
5267
|
};
|
|
5268
5268
|
}
|
|
5269
|
-
function
|
|
5269
|
+
function Ri(e) {
|
|
5270
5270
|
if (e.length < 5) return null;
|
|
5271
|
-
let t =
|
|
5271
|
+
let t = zi(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;
|
|
5272
5272
|
return t === null || ![
|
|
5273
5273
|
n,
|
|
5274
5274
|
r,
|
|
@@ -5286,7 +5286,7 @@ function Bi(e) {
|
|
|
5286
5286
|
function $(e) {
|
|
5287
5287
|
return e === void 0 || e.trim() === "" ? NaN : Number(e);
|
|
5288
5288
|
}
|
|
5289
|
-
function
|
|
5289
|
+
function zi(e) {
|
|
5290
5290
|
let t = e.trim();
|
|
5291
5291
|
if (!t) return null;
|
|
5292
5292
|
let n = Number(t);
|
|
@@ -5294,7 +5294,7 @@ function Vi(e) {
|
|
|
5294
5294
|
let r = Date.parse(t);
|
|
5295
5295
|
return Number.isFinite(r) ? r : null;
|
|
5296
5296
|
}
|
|
5297
|
-
function
|
|
5297
|
+
function Bi(e, t, n) {
|
|
5298
5298
|
e.sort((e, t) => e.time - t.time);
|
|
5299
5299
|
let r = [];
|
|
5300
5300
|
for (let t of e) r.length > 0 && r[r.length - 1].time === t.time ? r[r.length - 1] = t : r.push(t);
|
|
@@ -5306,7 +5306,7 @@ function Hi(e, t, n) {
|
|
|
5306
5306
|
}
|
|
5307
5307
|
//#endregion
|
|
5308
5308
|
//#region src/io/DragDropImporter.ts
|
|
5309
|
-
var
|
|
5309
|
+
var Vi = class {
|
|
5310
5310
|
host;
|
|
5311
5311
|
overlay = null;
|
|
5312
5312
|
callbacks;
|
|
@@ -5327,19 +5327,19 @@ var Ui = class {
|
|
|
5327
5327
|
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();
|
|
5328
5328
|
}
|
|
5329
5329
|
onDragEnter(e) {
|
|
5330
|
-
|
|
5330
|
+
Hi(e) && (e.preventDefault(), this.depth++, this.showOverlay());
|
|
5331
5331
|
}
|
|
5332
5332
|
onDragOver(e) {
|
|
5333
|
-
|
|
5333
|
+
Hi(e) && (e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = "copy"));
|
|
5334
5334
|
}
|
|
5335
5335
|
onDragLeave(e) {
|
|
5336
|
-
|
|
5336
|
+
Hi(e) && (this.depth = Math.max(0, this.depth - 1), this.depth === 0 && this.hideOverlay());
|
|
5337
5337
|
}
|
|
5338
5338
|
async onDrop(e) {
|
|
5339
5339
|
e.preventDefault(), this.depth = 0, this.hideOverlay();
|
|
5340
5340
|
let t = e.dataTransfer?.files?.[0];
|
|
5341
5341
|
if (t) try {
|
|
5342
|
-
let e =
|
|
5342
|
+
let e = ji(await t.text());
|
|
5343
5343
|
if (e.data.length === 0) throw Error(`No valid OHLCV rows found in "${t.name}"`);
|
|
5344
5344
|
this.callbacks.onData(e.data, e, t);
|
|
5345
5345
|
} catch (e) {
|
|
@@ -5370,12 +5370,12 @@ var Ui = class {
|
|
|
5370
5370
|
this.overlay?.remove(), this.overlay = null;
|
|
5371
5371
|
}
|
|
5372
5372
|
};
|
|
5373
|
-
function
|
|
5373
|
+
function Hi(e) {
|
|
5374
5374
|
return e.dataTransfer?.types?.includes("Files") ?? !1;
|
|
5375
5375
|
}
|
|
5376
5376
|
//#endregion
|
|
5377
5377
|
//#region src/state/layoutStorage.ts
|
|
5378
|
-
function
|
|
5378
|
+
function Ui(e) {
|
|
5379
5379
|
let t = {
|
|
5380
5380
|
id: e.id,
|
|
5381
5381
|
name: e.name,
|
|
@@ -5383,11 +5383,11 @@ function Gi(e) {
|
|
|
5383
5383
|
};
|
|
5384
5384
|
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;
|
|
5385
5385
|
}
|
|
5386
|
-
var
|
|
5387
|
-
function
|
|
5386
|
+
var Wi = (e, t) => t.updatedAt - e.updatedAt;
|
|
5387
|
+
function Gi(e) {
|
|
5388
5388
|
if (typeof e != "object" || !e) return null;
|
|
5389
5389
|
let t = e;
|
|
5390
|
-
return typeof t.id != "string" || !t.id || typeof t.name != "string" || typeof t.updatedAt != "number" || !Number.isFinite(t.updatedAt) ? null :
|
|
5390
|
+
return typeof t.id != "string" || !t.id || typeof t.name != "string" || typeof t.updatedAt != "number" || !Number.isFinite(t.updatedAt) ? null : Ui({
|
|
5391
5391
|
id: t.id,
|
|
5392
5392
|
name: t.name,
|
|
5393
5393
|
updatedAt: t.updatedAt,
|
|
@@ -5396,17 +5396,17 @@ function qi(e) {
|
|
|
5396
5396
|
kind: typeof t.kind == "string" ? t.kind : void 0
|
|
5397
5397
|
});
|
|
5398
5398
|
}
|
|
5399
|
-
function
|
|
5400
|
-
let t =
|
|
5399
|
+
function Ki(e) {
|
|
5400
|
+
let t = Gi(e), n = t ? e.content : void 0;
|
|
5401
5401
|
return t && typeof n == "string" ? {
|
|
5402
5402
|
...t,
|
|
5403
5403
|
content: n
|
|
5404
5404
|
} : null;
|
|
5405
5405
|
}
|
|
5406
|
-
function
|
|
5406
|
+
function qi(e = []) {
|
|
5407
5407
|
let t = new Map(e.map((e) => [e.id, { ...e }]));
|
|
5408
5408
|
return {
|
|
5409
|
-
list: () => [...t.values()].map(
|
|
5409
|
+
list: () => [...t.values()].map(Ui).sort(Wi),
|
|
5410
5410
|
load: (e) => {
|
|
5411
5411
|
let n = t.get(e);
|
|
5412
5412
|
return n ? { ...n } : null;
|
|
@@ -5419,7 +5419,7 @@ function Yi(e = []) {
|
|
|
5419
5419
|
}
|
|
5420
5420
|
};
|
|
5421
5421
|
}
|
|
5422
|
-
function
|
|
5422
|
+
function Ji(e = "tcw:layouts:") {
|
|
5423
5423
|
let t = `${e}index`, n = (t) => `${e}item:${t}`, r = () => {
|
|
5424
5424
|
let e;
|
|
5425
5425
|
try {
|
|
@@ -5427,10 +5427,10 @@ function Xi(e = "tcw:layouts:") {
|
|
|
5427
5427
|
} catch {
|
|
5428
5428
|
return [];
|
|
5429
5429
|
}
|
|
5430
|
-
return Array.isArray(e) ? e.map(
|
|
5430
|
+
return Array.isArray(e) ? e.map(Gi).filter((e) => e !== null) : [];
|
|
5431
5431
|
}, i = (e) => localStorage.setItem(t, JSON.stringify(e));
|
|
5432
5432
|
return {
|
|
5433
|
-
list: () => r().sort(
|
|
5433
|
+
list: () => r().sort(Wi),
|
|
5434
5434
|
load: (e) => {
|
|
5435
5435
|
let t = r().find((t) => t.id === e), i = t ? localStorage.getItem(n(e)) : null;
|
|
5436
5436
|
return t && i !== null ? {
|
|
@@ -5439,7 +5439,7 @@ function Xi(e = "tcw:layouts:") {
|
|
|
5439
5439
|
} : null;
|
|
5440
5440
|
},
|
|
5441
5441
|
save: (e) => {
|
|
5442
|
-
localStorage.setItem(n(e.id), e.content), i([...r().filter((t) => t.id !== e.id),
|
|
5442
|
+
localStorage.setItem(n(e.id), e.content), i([...r().filter((t) => t.id !== e.id), Ui(e)]);
|
|
5443
5443
|
},
|
|
5444
5444
|
remove: (e) => {
|
|
5445
5445
|
i(r().filter((t) => t.id !== e)), localStorage.removeItem(n(e));
|
|
@@ -5448,14 +5448,14 @@ function Xi(e = "tcw:layouts:") {
|
|
|
5448
5448
|
}
|
|
5449
5449
|
//#endregion
|
|
5450
5450
|
//#region src/state/LayoutSession.ts
|
|
5451
|
-
var
|
|
5452
|
-
function
|
|
5451
|
+
var Yi = 80;
|
|
5452
|
+
function Xi(e) {
|
|
5453
5453
|
return e.replace(/\s+/g, " ").trim().slice(0, 80).trim() || null;
|
|
5454
5454
|
}
|
|
5455
|
-
function
|
|
5455
|
+
function Zi() {
|
|
5456
5456
|
return globalThis.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
5457
5457
|
}
|
|
5458
|
-
function
|
|
5458
|
+
function Qi(e) {
|
|
5459
5459
|
let { id: t, name: n, symbol: r, timeframe: i, updatedAt: a, kind: o } = e;
|
|
5460
5460
|
return {
|
|
5461
5461
|
id: t,
|
|
@@ -5466,7 +5466,7 @@ function ea(e) {
|
|
|
5466
5466
|
...o === void 0 ? {} : { kind: o }
|
|
5467
5467
|
};
|
|
5468
5468
|
}
|
|
5469
|
-
var
|
|
5469
|
+
var $i = class {
|
|
5470
5470
|
currentLayout = null;
|
|
5471
5471
|
savedContent = null;
|
|
5472
5472
|
dirty = !1;
|
|
@@ -5482,7 +5482,7 @@ var ta = class {
|
|
|
5482
5482
|
now;
|
|
5483
5483
|
newId;
|
|
5484
5484
|
constructor(e, t, n = {}) {
|
|
5485
|
-
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 ??
|
|
5485
|
+
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 ?? Zi;
|
|
5486
5486
|
}
|
|
5487
5487
|
current() {
|
|
5488
5488
|
return this.currentLayout;
|
|
@@ -5498,7 +5498,7 @@ var ta = class {
|
|
|
5498
5498
|
}
|
|
5499
5499
|
async list() {
|
|
5500
5500
|
let e = await this.storage.list();
|
|
5501
|
-
return Array.isArray(e) ? e.map(
|
|
5501
|
+
return Array.isArray(e) ? e.map(Gi).filter((e) => e !== null && (e.kind ?? "chart") === this.kind).sort((e, t) => t.updatedAt - e.updatedAt) : [];
|
|
5502
5502
|
}
|
|
5503
5503
|
save() {
|
|
5504
5504
|
return this.queue(() => {
|
|
@@ -5507,12 +5507,12 @@ var ta = class {
|
|
|
5507
5507
|
});
|
|
5508
5508
|
}
|
|
5509
5509
|
saveAs(e) {
|
|
5510
|
-
let t =
|
|
5510
|
+
let t = Xi(e);
|
|
5511
5511
|
return t ? this.queue(() => this.write(this.newId(), t)) : Promise.reject(/* @__PURE__ */ Error("A layout needs a name"));
|
|
5512
5512
|
}
|
|
5513
5513
|
open(e) {
|
|
5514
5514
|
return this.queue(async () => {
|
|
5515
|
-
let t =
|
|
5515
|
+
let t = Ki(await this.storage.load(e));
|
|
5516
5516
|
if (!t || t.id !== e || (t.kind ?? "chart") !== this.kind || this.destroyed) return !1;
|
|
5517
5517
|
this.cancelTimer(), this.applying++;
|
|
5518
5518
|
try {
|
|
@@ -5522,13 +5522,13 @@ var ta = class {
|
|
|
5522
5522
|
} finally {
|
|
5523
5523
|
this.applying--;
|
|
5524
5524
|
}
|
|
5525
|
-
return this.cancelTimer(), this.currentLayout =
|
|
5525
|
+
return this.cancelTimer(), this.currentLayout = Qi(t), this.savedContent = this.host.capture().content, this.dirty = !1, this.notify(), !0;
|
|
5526
5526
|
});
|
|
5527
5527
|
}
|
|
5528
5528
|
rename(e, t) {
|
|
5529
|
-
let n =
|
|
5529
|
+
let n = Xi(t);
|
|
5530
5530
|
return n ? this.queue(async () => {
|
|
5531
|
-
let t =
|
|
5531
|
+
let t = Ki(await this.storage.load(e));
|
|
5532
5532
|
!t || t.id !== e || (await this.storage.save({
|
|
5533
5533
|
...t,
|
|
5534
5534
|
name: n
|
|
@@ -5606,7 +5606,7 @@ var ta = class {
|
|
|
5606
5606
|
content: n.content
|
|
5607
5607
|
};
|
|
5608
5608
|
await this.storage.save(r);
|
|
5609
|
-
let i =
|
|
5609
|
+
let i = Qi(r);
|
|
5610
5610
|
return this.currentLayout = i, this.savedContent = n.content, this.dirty = !1, this.notify(), i;
|
|
5611
5611
|
}
|
|
5612
5612
|
forget() {
|
|
@@ -5627,6 +5627,6 @@ var ta = class {
|
|
|
5627
5627
|
}
|
|
5628
5628
|
};
|
|
5629
5629
|
//#endregion
|
|
5630
|
-
export {
|
|
5630
|
+
export { Hn as C, B as D, R as E, ln as O, Gn as S, V as T, lr as _, qi as a, G as b, Xr as c, Mr as d, Nr as f, cr as g, ur as h, Ji as i, Ir as l, dr as m, Yi as n, Vi as o, fr as p, Xi as r, ji as s, $i as t, Fr as u, or as v, Bn as w, Xn as x, sr as y };
|
|
5631
5631
|
|
|
5632
|
-
//# sourceMappingURL=LayoutSession-
|
|
5632
|
+
//# sourceMappingURL=LayoutSession-BQVAQhdo.js.map
|