@tradecanvas/chart 1.49.1 → 1.51.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/Chart.d.ts +32 -1
- package/dist/Chart.d.ts.map +1 -1
- package/dist/LayoutSession-DuV9kpdQ.cjs +2 -0
- package/dist/LayoutSession-DuV9kpdQ.cjs.map +1 -0
- package/dist/{LayoutSession-BlSkHp80.js → LayoutSession-Qkx1huV-.js} +380 -292
- package/dist/LayoutSession-Qkx1huV-.js.map +1 -0
- package/dist/ThemeManager.d.ts +7 -1
- package/dist/ThemeManager.d.ts.map +1 -1
- package/dist/finance/performanceData.d.ts +17 -2
- package/dist/finance/performanceData.d.ts.map +1 -1
- package/dist/i18n-Bg_UJSNs.cjs +2 -0
- package/dist/i18n-Bg_UJSNs.cjs.map +1 -0
- package/dist/{i18n-DjzoHpMJ.js → i18n-DFTQ73Cz.js} +15 -1
- package/dist/i18n-DFTQ73Cz.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +116 -115
- package/dist/index.js.map +1 -1
- package/dist/layout/labelWidths.d.ts +16 -0
- package/dist/layout/labelWidths.d.ts.map +1 -0
- package/dist/widget/ChartWidget.d.ts +46 -4
- package/dist/widget/ChartWidget.d.ts.map +1 -1
- package/dist/widget/WatchlistStore.d.ts.map +1 -1
- package/dist/widget/WidgetContextMenu.d.ts +25 -3
- package/dist/widget/WidgetContextMenu.d.ts.map +1 -1
- package/dist/widget/WidgetHotkeySheet.d.ts.map +1 -1
- package/dist/widget/WidgetIndicatorLegend.d.ts +2 -0
- package/dist/widget/WidgetIndicatorLegend.d.ts.map +1 -1
- package/dist/widget/WidgetLayoutsUI.d.ts.map +1 -1
- package/dist/widget/WidgetStatusBar.d.ts +110 -3
- package/dist/widget/WidgetStatusBar.d.ts.map +1 -1
- package/dist/widget/WidgetSymbolSearch.d.ts +73 -20
- package/dist/widget/WidgetSymbolSearch.d.ts.map +1 -1
- package/dist/widget/WidgetToolbar.d.ts +65 -6
- package/dist/widget/WidgetToolbar.d.ts.map +1 -1
- package/dist/widget/WidgetTradeMenu.d.ts.map +1 -1
- package/dist/widget/hostButtons.d.ts +5 -2
- package/dist/widget/hostButtons.d.ts.map +1 -1
- package/dist/widget/index.cjs +466 -119
- package/dist/widget/index.cjs.map +1 -1
- package/dist/widget/index.d.ts +1 -1
- package/dist/widget/index.d.ts.map +1 -1
- package/dist/widget/index.js +2317 -1738
- 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/selectMenu.d.ts.map +1 -1
- package/dist/widget/symbolBadge.d.ts +26 -0
- package/dist/widget/symbolBadge.d.ts.map +1 -0
- package/dist/widget/symbolCatalog.d.ts +62 -0
- package/dist/widget/symbolCatalog.d.ts.map +1 -0
- package/dist/widget/symbolCell.d.ts +8 -0
- package/dist/widget/symbolCell.d.ts.map +1 -0
- package/dist/widget/symbolInfoView.d.ts +3 -0
- package/dist/widget/symbolInfoView.d.ts.map +1 -1
- package/dist/widget/symbolMatch.d.ts +38 -0
- package/dist/widget/symbolMatch.d.ts.map +1 -0
- package/dist/widget/symbolSearchFilters.d.ts +52 -0
- package/dist/widget/symbolSearchFilters.d.ts.map +1 -0
- package/dist/widget/types.d.ts +28 -4
- package/dist/widget/types.d.ts.map +1 -1
- package/dist/widget/widgetUI.d.ts +16 -2
- package/dist/widget/widgetUI.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/LayoutSession-B-IfDpYQ.cjs +0 -2
- package/dist/LayoutSession-B-IfDpYQ.cjs.map +0 -1
- package/dist/LayoutSession-BlSkHp80.js.map +0 -1
- package/dist/i18n-DVeWlg64.cjs +0 -2
- package/dist/i18n-DVeWlg64.cjs.map +0 -1
- package/dist/i18n-DjzoHpMJ.js.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { DARK_THEME as e, DEFAULT_PANEL_HEIGHT as t, LIGHT_THEME as n, LayerType as r, MIN_PANEL_HEIGHT as i, PHI as a, PRICE_AXIS_WIDTH as o, TIME_AXIS_HEIGHT as s, autoPricePrecision as c, barTimeUnit as l, chartStyleValue as u, computePriceLimits as d, computePriceRange as f, formatPrice as p, fractionTick as m, indicatorSource as h, isValidTimeZone as g, mergeBar as _, normalizeBarTime as v, parseIndicatorSource as y, priceFormatterFor as ee, priceStepAt as te, readChartStyleOverrides as
|
|
2
|
-
import { AlertDragHandler as
|
|
1
|
+
import { DARK_THEME as e, DEFAULT_PANEL_HEIGHT as t, LIGHT_THEME as n, LayerType as r, MIN_PANEL_HEIGHT as i, PHI as a, PRICE_AXIS_WIDTH as o, TIME_AXIS_HEIGHT as s, autoPricePrecision as c, barTimeUnit as l, chartStyleValue as u, computePriceLimits as d, computePriceRange as f, formatPrice as p, fractionTick as m, indicatorSource as h, isValidTimeZone as g, mergeBar as _, normalizeBarTime as v, parseIndicatorSource as y, priceFormatterFor as ee, priceStepAt as te, readChartStyleOverrides as b, readChartTypeOptions as x, readIndicatorPlotStyles as ne, readPaneStyle as re, resolveChartTheme as ie, sessionMinute as S, setLocale as ae, stepDecimals as oe, symbolTimeZone as C, tickBarCount as se, timeframeToMs as ce, zonedDateFormatter as le } from "@tradecanvas/commons";
|
|
2
|
+
import { AlertDragHandler as ue, AlertManager as de, Animator as fe, AreaRenderer as pe, AxisDragHandler as me, BarCountdown as he, BarRenderer as ge, BaselineRenderer as _e, CandlestickRenderer as ve, ChartLegend as ye, ChartStateManager as w, CompareRenderer as be, CompareSymbolIndicator as xe, CorrelationCoefficientIndicator as Se, CorrelationLogIndicator as Ce, CrosshairHandler as we, CrosshairTooltip as Te, CurrentPriceLine as Ee, DEFAULT_SESSION_HOURS as De, DataExporter as T, DepthHeatmapRenderer as Oe, DrawingManager as ke, DrawingRenderer as Ae, EquivolumeRenderer as je, EventBus as Me, GridRenderer as Ne, HLCAreaRenderer as Pe, HiLoRenderer as Fe, HollowCandleRenderer as Ie, IndicatorEngine as Le, InteractionManager as Re, KagiRenderer as ze, KeyboardHandler as Be, LineRenderer as Ve, LineWithMarkersRenderer as He, MarketProfileRenderer as Ue, MeasureOverlay as We, PRICE_SCALE_MARGIN as E, PanHandler as Ge, PaneResizeHandler as Ke, PeriodLevelsRenderer as qe, PinnedTooltip as Je, PivotMarkersRenderer as Ye, PointAndFigureRenderer as D, PriceAxis as Xe, PriceAxisAddButton as Ze, PriceLines as Qe, RenderEngine as $e, RenkoRenderer as et, ReplayManager as tt, SYMBOL_INDICATOR_IDS as O, Screenshot as k, SelectionBoxOverlay as nt, SessionBreaks as rt, SessionShading as it, SignalMarkerManager as at, SpreadIndicator as ot, StepLineRenderer as st, StreamManager as ct, SymbolSeriesStore as lt, TimeAxis as ut, TradeZoneManager as dt, TradingManager as ft, TradingRenderer as pt, UndoRedoManager as mt, Viewport as ht, VolumeCandleRenderer as gt, VolumeProfileRenderer as _t, VolumeRenderer as vt, Watermark as yt, ZoomHandler as bt, barTimeStepMs as xt, findDominantSwing as St, gpuContextsLeft as Ct, isRegularSession as wt, loadWebGL as Tt, mergeSessionHours as Et, priceToY as Dt, rangePresetStart as Ot, readAlertOptions as kt, registerBuiltInDrawingTools as At, registerBuiltInIndicators as jt, servesTimeframe as Mt, sourceParam as A, timeToX as Nt, timestampToBarIndex as j, toHeikinAshi as Pt, toKagi as Ft, toLineBreak as It, toPointAndFigure as Lt, toRangeBars as Rt, toRenko as zt, whenGpuContextFree as Bt, withResampling as Vt, xToBarIndex as Ht, xToTime as M, yToPrice as N } from "@tradecanvas/core";
|
|
3
3
|
//#region src/regularHours.ts
|
|
4
|
-
var
|
|
5
|
-
function
|
|
6
|
-
let n =
|
|
4
|
+
var Ut = 864e5, Wt = 10;
|
|
5
|
+
function Gt(e, t) {
|
|
6
|
+
let n = C(e);
|
|
7
7
|
if (!n || !g(n) || t.length < 2) return null;
|
|
8
8
|
let r = (e?.sessions ?? []).flatMap((e) => {
|
|
9
|
-
let t =
|
|
9
|
+
let t = S(e.start), n = S(e.end);
|
|
10
10
|
return t === null || n === null ? [] : [{
|
|
11
11
|
startMinute: t,
|
|
12
12
|
endMinute: n
|
|
@@ -14,34 +14,34 @@ function Ht(e, t) {
|
|
|
14
14
|
});
|
|
15
15
|
if (r.length === 0) return null;
|
|
16
16
|
let i = l(t), a = Infinity;
|
|
17
|
-
for (let e = Math.max(1, t.length -
|
|
17
|
+
for (let e = Math.max(1, t.length - Wt); 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 < Ut)) return null;
|
|
22
22
|
let o = {
|
|
23
23
|
timeZone: n,
|
|
24
24
|
windows: r,
|
|
25
25
|
startMinute: r[0].startMinute,
|
|
26
26
|
endMinute: r[r.length - 1].endMinute
|
|
27
27
|
};
|
|
28
|
-
return (e) =>
|
|
28
|
+
return (e) => wt(e * i, o);
|
|
29
29
|
}
|
|
30
30
|
//#endregion
|
|
31
31
|
//#region src/chartA11y.ts
|
|
32
|
-
var
|
|
32
|
+
var P = {
|
|
33
33
|
role: "chart",
|
|
34
34
|
summary: "{what}. Last price {close}.",
|
|
35
35
|
empty: "Chart, no data.",
|
|
36
36
|
view: "Showing {count} bars, {from} to {to}. High {high}, low {low}.",
|
|
37
37
|
bar: "{time}: open {open}, high {high}, low {low}, close {close}, volume {volume}.",
|
|
38
38
|
keys: "Arrow keys scroll and zoom, Home and End go to the start and the end. Comma and period read the bars one at a time."
|
|
39
|
-
},
|
|
39
|
+
}, F = (e, t) => e.replace(/\{(\w+)\}/g, (e, n) => n in t ? String(t[n]) : e), Kt = [
|
|
40
40
|
"role",
|
|
41
41
|
"aria-roledescription",
|
|
42
42
|
"aria-label",
|
|
43
43
|
"aria-describedby"
|
|
44
|
-
],
|
|
44
|
+
], qt = 400, Jt = 1e3, Yt = class {
|
|
45
45
|
live;
|
|
46
46
|
help;
|
|
47
47
|
labels;
|
|
@@ -55,20 +55,20 @@ var Ut = {
|
|
|
55
55
|
};
|
|
56
56
|
constructor(e, t, n = {}) {
|
|
57
57
|
this.container = e, this.source = t, this.labels = {
|
|
58
|
-
...
|
|
58
|
+
...P,
|
|
59
59
|
...n
|
|
60
60
|
};
|
|
61
|
-
for (let t of
|
|
62
|
-
e.setAttribute("role", "application"), this.help =
|
|
61
|
+
for (let t of Kt) this.before.set(t, e.getAttribute(t));
|
|
62
|
+
e.setAttribute("role", "application"), this.help = I("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 = I("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
|
+
...P,
|
|
67
67
|
...e
|
|
68
68
|
}, this.applyLabels();
|
|
69
69
|
}
|
|
70
70
|
refresh(e = !1) {
|
|
71
|
-
let t =
|
|
71
|
+
let t = Jt - (Date.now() - this.summaryAt);
|
|
72
72
|
if (e || t <= 0 || this.container.getAttribute("aria-label") === this.labels.empty) {
|
|
73
73
|
this.summaryTimer && clearTimeout(this.summaryTimer), this.summaryTimer = null, this.summaryAt = Date.now(), this.container.setAttribute("aria-label", this.summary());
|
|
74
74
|
return;
|
|
@@ -80,7 +80,7 @@ var Ut = {
|
|
|
80
80
|
viewMoved() {
|
|
81
81
|
this.cursor = null, this.viewTimer && clearTimeout(this.viewTimer), this.viewTimer = setTimeout(() => {
|
|
82
82
|
this.viewTimer = null, this.say(this.viewText());
|
|
83
|
-
},
|
|
83
|
+
}, qt);
|
|
84
84
|
}
|
|
85
85
|
readBar(e) {
|
|
86
86
|
let t = this.source.bars();
|
|
@@ -93,13 +93,13 @@ var Ut = {
|
|
|
93
93
|
let i = t[this.cursor];
|
|
94
94
|
this.source.showBar(i.time);
|
|
95
95
|
let a = this.source.formatPrice;
|
|
96
|
-
this.say(
|
|
96
|
+
this.say(F(this.labels.bar, {
|
|
97
97
|
time: this.source.formatTime(i.time),
|
|
98
98
|
open: a(i.open),
|
|
99
99
|
high: a(i.high),
|
|
100
100
|
low: a(i.low),
|
|
101
101
|
close: a(i.close),
|
|
102
|
-
volume:
|
|
102
|
+
volume: Xt(i.volume ?? 0)
|
|
103
103
|
}));
|
|
104
104
|
}
|
|
105
105
|
destroy() {
|
|
@@ -118,7 +118,7 @@ var Ut = {
|
|
|
118
118
|
this.labels.typeName ? this.labels.typeName(t) : t,
|
|
119
119
|
this.source.timeframe()
|
|
120
120
|
].filter(Boolean).join(", ");
|
|
121
|
-
return
|
|
121
|
+
return F(this.labels.summary, {
|
|
122
122
|
what: n,
|
|
123
123
|
close: this.source.formatPrice(e[e.length - 1].close)
|
|
124
124
|
});
|
|
@@ -128,7 +128,7 @@ var Ut = {
|
|
|
128
128
|
if (e.length === 0) return this.labels.empty;
|
|
129
129
|
let t = this.source.visibleRange(), n = Math.max(0, Math.min(e.length - 1, Math.ceil(t.from))), r = Math.max(n, Math.min(e.length - 1, Math.floor(t.to))), i = -Infinity, a = Infinity;
|
|
130
130
|
for (let t = n; t <= r; t++) i = Math.max(i, e[t].high), a = Math.min(a, e[t].low);
|
|
131
|
-
return
|
|
131
|
+
return F(this.labels.view, {
|
|
132
132
|
count: r - n + 1,
|
|
133
133
|
from: this.source.formatTime(e[n].time),
|
|
134
134
|
to: this.source.formatTime(e[r].time),
|
|
@@ -140,7 +140,7 @@ var Ut = {
|
|
|
140
140
|
this.live.textContent = e;
|
|
141
141
|
}
|
|
142
142
|
};
|
|
143
|
-
function
|
|
143
|
+
function I(e, t) {
|
|
144
144
|
let n = document.createElement(e);
|
|
145
145
|
return n.className = t, Object.assign(n.style, {
|
|
146
146
|
position: "absolute",
|
|
@@ -154,12 +154,12 @@ function Jt(e, t) {
|
|
|
154
154
|
border: "0"
|
|
155
155
|
}), n;
|
|
156
156
|
}
|
|
157
|
-
function
|
|
157
|
+
function Xt(e) {
|
|
158
158
|
return Number.isInteger(e) ? String(e) : e.toFixed(2);
|
|
159
159
|
}
|
|
160
160
|
//#endregion
|
|
161
161
|
//#region src/indicatorLabel.ts
|
|
162
|
-
function
|
|
162
|
+
function L(e, t, n, r) {
|
|
163
163
|
let i = Object.keys(n || t).map((e) => t[e]).filter((e) => typeof e == "number" && Number.isFinite(e)).slice(0, 3).map((e) => String(Number(e.toFixed(4)))), a = typeof t.symbol == "string" && t.symbol ? [t.symbol] : [];
|
|
164
164
|
return [
|
|
165
165
|
e === "spread" && t.mode === "ratio" ? "Ratio" : r ?? e.toUpperCase(),
|
|
@@ -174,42 +174,42 @@ function Zt(e) {
|
|
|
174
174
|
case "candlestick":
|
|
175
175
|
case "heikinAshi":
|
|
176
176
|
case "lineBreak":
|
|
177
|
-
case "rangeBars": return new
|
|
178
|
-
case "line": return new
|
|
179
|
-
case "area": return new
|
|
180
|
-
case "bar": return new
|
|
181
|
-
case "hollowCandle": return new
|
|
182
|
-
case "baseline": return new
|
|
183
|
-
case "renko": return new
|
|
184
|
-
case "kagi": return new
|
|
185
|
-
case "pointAndFigure": return new
|
|
186
|
-
case "volumeCandles": return new
|
|
187
|
-
case "equivolume": return new
|
|
188
|
-
case "hlcArea": return new
|
|
189
|
-
case "stepLine": return new
|
|
190
|
-
case "lineWithMarkers": return new
|
|
191
|
-
case "hiLo": return new
|
|
192
|
-
default: return new
|
|
177
|
+
case "rangeBars": return new ve();
|
|
178
|
+
case "line": return new Ve();
|
|
179
|
+
case "area": return new pe();
|
|
180
|
+
case "bar": return new ge();
|
|
181
|
+
case "hollowCandle": return new Ie();
|
|
182
|
+
case "baseline": return new _e();
|
|
183
|
+
case "renko": return new et();
|
|
184
|
+
case "kagi": return new ze();
|
|
185
|
+
case "pointAndFigure": return new D();
|
|
186
|
+
case "volumeCandles": return new gt();
|
|
187
|
+
case "equivolume": return new je();
|
|
188
|
+
case "hlcArea": return new Pe();
|
|
189
|
+
case "stepLine": return new st();
|
|
190
|
+
case "lineWithMarkers": return new He();
|
|
191
|
+
case "hiLo": return new Fe();
|
|
192
|
+
default: return new ve();
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
function Qt(e, t, n = {}) {
|
|
196
196
|
if (t.length === 0) return t;
|
|
197
197
|
switch (e) {
|
|
198
|
-
case "heikinAshi": return
|
|
198
|
+
case "heikinAshi": return Pt(t);
|
|
199
199
|
case "renko": {
|
|
200
200
|
let e = n.renko?.boxSize;
|
|
201
|
-
return typeof e == "number" ?
|
|
201
|
+
return typeof e == "number" ? zt(t, { brickSize: e }) : zt(t, {
|
|
202
202
|
brickSize: 0,
|
|
203
203
|
useATR: !0,
|
|
204
204
|
atrPeriod: n.renko?.atrPeriod ?? 14
|
|
205
205
|
});
|
|
206
206
|
}
|
|
207
|
-
case "lineBreak": return
|
|
208
|
-
case "kagi": return
|
|
209
|
-
case "pointAndFigure": return
|
|
207
|
+
case "lineBreak": return It(t, n.lineBreak?.lines ?? 3);
|
|
208
|
+
case "kagi": return Ft(t, n.kagi?.reversal ?? 4, n.kagi?.reversalType ?? "percent");
|
|
209
|
+
case "pointAndFigure": return Lt(t, en(t, n), n.pointAndFigure?.reversal ?? 3);
|
|
210
210
|
case "rangeBars": {
|
|
211
211
|
let e = n.rangeBars?.range;
|
|
212
|
-
return
|
|
212
|
+
return Rt(t, { rangeSize: typeof e == "number" ? e : tn(t) * .005 });
|
|
213
213
|
}
|
|
214
214
|
default: return t;
|
|
215
215
|
}
|
|
@@ -619,15 +619,23 @@ var un = class {
|
|
|
619
619
|
now() {
|
|
620
620
|
return this.host.now ? this.host.now() : Date.now();
|
|
621
621
|
}
|
|
622
|
-
}
|
|
622
|
+
};
|
|
623
|
+
//#endregion
|
|
624
|
+
//#region src/ThemeManager.ts
|
|
625
|
+
function hn(e, t) {
|
|
626
|
+
return e.family === t.family && e.sizeSmall === t.sizeSmall && e.sizeMedium === t.sizeMedium && e.sizeLarge === t.sizeLarge;
|
|
627
|
+
}
|
|
628
|
+
var gn = class t {
|
|
623
629
|
base;
|
|
624
630
|
shape = null;
|
|
631
|
+
font = null;
|
|
632
|
+
themeFont;
|
|
625
633
|
chartType = "candlestick";
|
|
626
634
|
host = {};
|
|
627
635
|
user = /* @__PURE__ */ new Map();
|
|
628
636
|
effective = null;
|
|
629
637
|
constructor(e) {
|
|
630
|
-
this.base = t.read(e);
|
|
638
|
+
this.base = t.read(e), this.themeFont = this.base.font;
|
|
631
639
|
}
|
|
632
640
|
static read(t) {
|
|
633
641
|
if (!t || t === "dark") return { ...e };
|
|
@@ -636,20 +644,39 @@ var un = class {
|
|
|
636
644
|
return i;
|
|
637
645
|
}
|
|
638
646
|
getTheme() {
|
|
639
|
-
return this.effective ??=
|
|
647
|
+
return this.effective ??= ie(this.base, this.chartType, this.merged()), this.effective;
|
|
640
648
|
}
|
|
641
649
|
getBaseTheme() {
|
|
642
650
|
return this.base;
|
|
643
651
|
}
|
|
644
652
|
setTheme(e) {
|
|
645
|
-
|
|
653
|
+
let n = t.read(e), r = this.font !== null && hn(n.font, this.base.font);
|
|
654
|
+
this.base = n, r || (this.themeFont = n.font), this.shape && (this.base = {
|
|
646
655
|
...this.base,
|
|
647
656
|
shape: {
|
|
648
657
|
...this.base.shape,
|
|
649
658
|
...this.shape
|
|
650
659
|
}
|
|
660
|
+
}), this.font && (this.base = {
|
|
661
|
+
...this.base,
|
|
662
|
+
font: {
|
|
663
|
+
...this.themeFont,
|
|
664
|
+
...this.font
|
|
665
|
+
}
|
|
651
666
|
}), this.effective = null;
|
|
652
667
|
}
|
|
668
|
+
setFont(e) {
|
|
669
|
+
this.font = e ? {
|
|
670
|
+
...this.font,
|
|
671
|
+
...e
|
|
672
|
+
} : null, this.base = {
|
|
673
|
+
...this.base,
|
|
674
|
+
font: this.font ? {
|
|
675
|
+
...this.themeFont,
|
|
676
|
+
...this.font
|
|
677
|
+
} : this.themeFont
|
|
678
|
+
}, this.effective = null;
|
|
679
|
+
}
|
|
653
680
|
setShape(e) {
|
|
654
681
|
this.shape = e ? { ...e } : null, this.base = {
|
|
655
682
|
...this.base,
|
|
@@ -705,7 +732,7 @@ var un = class {
|
|
|
705
732
|
};
|
|
706
733
|
//#endregion
|
|
707
734
|
//#region src/style/styleOptions.ts
|
|
708
|
-
function
|
|
735
|
+
function _n(e, t) {
|
|
709
736
|
return t ? {
|
|
710
737
|
...t.visible === void 0 ? {} : { [`crosshair.${e}.visible`]: t.visible },
|
|
711
738
|
...t.color === void 0 ? {} : { [`crosshair.${e}.color`]: t.color },
|
|
@@ -713,22 +740,22 @@ function gn(e, t) {
|
|
|
713
740
|
...t.width === void 0 ? {} : { [`crosshair.${e}.width`]: t.width }
|
|
714
741
|
} : {};
|
|
715
742
|
}
|
|
716
|
-
function
|
|
743
|
+
function vn(e) {
|
|
717
744
|
let { grid: t, crosshair: n } = e, r = n?.vLine?.labelBackground ?? n?.hLine?.labelBackground;
|
|
718
745
|
return {
|
|
719
746
|
...t?.hLineColor === void 0 ? {} : { "grid.horizontal.color": t.hLineColor },
|
|
720
747
|
...t?.hLineStyle === void 0 ? {} : { "grid.horizontal.style": t.hLineStyle },
|
|
721
748
|
...t?.vLineColor === void 0 ? {} : { "grid.vertical.color": t.vLineColor },
|
|
722
749
|
...t?.vLineStyle === void 0 ? {} : { "grid.vertical.style": t.vLineStyle },
|
|
723
|
-
...
|
|
724
|
-
...
|
|
750
|
+
..._n("horizontal", n?.hLine),
|
|
751
|
+
..._n("vertical", n?.vLine),
|
|
725
752
|
...r === void 0 ? {} : { "crosshair.labelBackground": r },
|
|
726
753
|
...e.overrides
|
|
727
754
|
};
|
|
728
755
|
}
|
|
729
756
|
//#endregion
|
|
730
757
|
//#region src/layout/LayoutManager.ts
|
|
731
|
-
var
|
|
758
|
+
var yn = 200, bn = 80, U = (e) => e.position === "top" || e.position === "bottom", xn = class {
|
|
732
759
|
panels = [];
|
|
733
760
|
containerWidth = 0;
|
|
734
761
|
containerHeight = 0;
|
|
@@ -744,8 +771,8 @@ var vn = 200, yn = 80, U = (e) => e.position === "top" || e.position === "bottom
|
|
|
744
771
|
this.panels.push({
|
|
745
772
|
id: e,
|
|
746
773
|
position: n,
|
|
747
|
-
size: r ?? (a ?
|
|
748
|
-
minSize: a ?
|
|
774
|
+
size: r ?? (a ? yn : t),
|
|
775
|
+
minSize: a ? bn : i,
|
|
749
776
|
content: {
|
|
750
777
|
type: "indicator",
|
|
751
778
|
indicatorInstanceId: e
|
|
@@ -814,7 +841,7 @@ var vn = 200, yn = 80, U = (e) => e.position === "top" || e.position === "bottom
|
|
|
814
841
|
let r = this.panels.find((t) => t.id === e);
|
|
815
842
|
if (r) {
|
|
816
843
|
let a = r.position === "left" || r.position === "right", o = n === "left" || n === "right";
|
|
817
|
-
r.position = n, a !== o && (r.size = o ?
|
|
844
|
+
r.position = n, a !== o && (r.size = o ? yn : t, r.minSize = o ? bn : i), o && (r.collapsed = void 0, this.maximized === e && (this.maximized = null));
|
|
818
845
|
}
|
|
819
846
|
}
|
|
820
847
|
setPanelSize(e, t) {
|
|
@@ -930,8 +957,8 @@ var vn = 200, yn = 80, U = (e) => e.position === "top" || e.position === "bottom
|
|
|
930
957
|
getMainChartRect() {
|
|
931
958
|
return this.resolve().mainChartRect;
|
|
932
959
|
}
|
|
933
|
-
},
|
|
934
|
-
function
|
|
960
|
+
}, Sn = 14, Cn = 14, wn = 22, Tn = 4;
|
|
961
|
+
function En(e) {
|
|
935
962
|
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] : [
|
|
936
963
|
t,
|
|
937
964
|
n,
|
|
@@ -940,14 +967,32 @@ function Tn(e) {
|
|
|
940
967
|
for (let t of f) {
|
|
941
968
|
if (!Number.isFinite(t)) continue;
|
|
942
969
|
let n = e.scaleLabel ? e.scaleLabel(t) : e.format ? e.format(t) : p(t, u, i), r = e.format ? n : p(t, d, i);
|
|
943
|
-
m = Math.max(m, l(n, `500 ${s}px ${a}`) +
|
|
970
|
+
m = Math.max(m, l(n, `500 ${s}px ${a}`) + Sn, l(r, `bold 11px ${a}`) + Cn, l(r, `600 ${s}px ${a}`) + wn);
|
|
944
971
|
}
|
|
945
|
-
return m <= o ? o : Math.ceil(m /
|
|
972
|
+
return m <= o ? o : Math.ceil(m / Tn) * Tn;
|
|
946
973
|
}
|
|
947
|
-
function
|
|
974
|
+
function Dn(e, t) {
|
|
948
975
|
return t > e || t <= e - 12 ? t : e;
|
|
949
976
|
}
|
|
950
|
-
|
|
977
|
+
//#endregion
|
|
978
|
+
//#region src/layout/labelWidths.ts
|
|
979
|
+
var On = 512, kn = class {
|
|
980
|
+
widths = /* @__PURE__ */ new Map();
|
|
981
|
+
fonts;
|
|
982
|
+
forget = () => this.widths.clear();
|
|
983
|
+
constructor() {
|
|
984
|
+
this.fonts = typeof document < "u" ? document.fonts ?? null : null, this.fonts?.addEventListener("loadingdone", this.forget);
|
|
985
|
+
}
|
|
986
|
+
get(e, t, n) {
|
|
987
|
+
let r = `${t}\n${e}`, i = this.widths.get(r);
|
|
988
|
+
if (i !== void 0) return i;
|
|
989
|
+
let a = n();
|
|
990
|
+
return this.widths.size >= On && this.widths.clear(), this.widths.set(r, a), a;
|
|
991
|
+
}
|
|
992
|
+
destroy() {
|
|
993
|
+
this.fonts?.removeEventListener("loadingdone", this.forget), this.widths.clear();
|
|
994
|
+
}
|
|
995
|
+
}, An = class {
|
|
951
996
|
netY = 0;
|
|
952
997
|
travelX = 0;
|
|
953
998
|
engaged = !1;
|
|
@@ -963,11 +1008,11 @@ var Dn = class {
|
|
|
963
1008
|
}
|
|
964
1009
|
return this.engaged;
|
|
965
1010
|
}
|
|
966
|
-
},
|
|
967
|
-
function
|
|
1011
|
+
}, jn = 1;
|
|
1012
|
+
function W(e, t) {
|
|
968
1013
|
return e.filter((e) => e.enabled !== !1 && (e.descriptor.layer ?? "overlay") === t);
|
|
969
1014
|
}
|
|
970
|
-
function
|
|
1015
|
+
function G(e) {
|
|
971
1016
|
switch (e.kind) {
|
|
972
1017
|
case "indicator": return `indicator:${e.plugin.descriptor.id}`;
|
|
973
1018
|
case "drawing": return `drawing:${e.plugin.descriptor.type}`;
|
|
@@ -977,25 +1022,25 @@ function W(e) {
|
|
|
977
1022
|
}
|
|
978
1023
|
//#endregion
|
|
979
1024
|
//#region src/plugins/registry.ts
|
|
980
|
-
var
|
|
981
|
-
function
|
|
982
|
-
|
|
1025
|
+
var K = /* @__PURE__ */ new Map();
|
|
1026
|
+
function Mn(e) {
|
|
1027
|
+
K.set(G(e), e);
|
|
983
1028
|
}
|
|
984
|
-
function
|
|
985
|
-
return
|
|
1029
|
+
function Nn(e) {
|
|
1030
|
+
return K.delete(e);
|
|
986
1031
|
}
|
|
987
|
-
function
|
|
988
|
-
return [...
|
|
1032
|
+
function Pn() {
|
|
1033
|
+
return [...K.values()];
|
|
989
1034
|
}
|
|
990
|
-
function
|
|
991
|
-
|
|
1035
|
+
function Fn() {
|
|
1036
|
+
K.clear();
|
|
992
1037
|
}
|
|
993
1038
|
//#endregion
|
|
994
1039
|
//#region src/plugins/PluginManager.ts
|
|
995
|
-
var
|
|
1040
|
+
var In = class {
|
|
996
1041
|
plugins = /* @__PURE__ */ new Map();
|
|
997
1042
|
constructor(e, t = {}) {
|
|
998
|
-
if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of
|
|
1043
|
+
if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of Pn()) this.add(e);
|
|
999
1044
|
for (let e of t.plugins ?? []) this.add(e);
|
|
1000
1045
|
}
|
|
1001
1046
|
register(e) {
|
|
@@ -1023,17 +1068,17 @@ var Pn = class {
|
|
|
1023
1068
|
return e;
|
|
1024
1069
|
}
|
|
1025
1070
|
add(e) {
|
|
1026
|
-
this.plugins.set(
|
|
1071
|
+
this.plugins.set(G(e), e), e.kind === "indicator" && this.indicatorEngine.register(e.plugin);
|
|
1027
1072
|
}
|
|
1028
|
-
},
|
|
1073
|
+
}, Ln = {
|
|
1029
1074
|
orderPlace: (e, t) => e.placeOrder(t),
|
|
1030
1075
|
orderModify: (e, t) => e.modifyOrder(t),
|
|
1031
1076
|
orderCancel: (e, t) => e.cancelOrder(t),
|
|
1032
1077
|
positionModify: (e, t) => e.modifyPosition(t),
|
|
1033
1078
|
positionClose: (e, t) => e.closePosition(t),
|
|
1034
|
-
positionReverse: (e, t, n) =>
|
|
1079
|
+
positionReverse: (e, t, n) => Rn(e, t, n)
|
|
1035
1080
|
};
|
|
1036
|
-
async function
|
|
1081
|
+
async function Rn(e, t, n) {
|
|
1037
1082
|
let { reversing: r } = n;
|
|
1038
1083
|
if (!r.has(t.positionId)) {
|
|
1039
1084
|
r.add(t.positionId);
|
|
@@ -1062,7 +1107,7 @@ async function In(e, t, n) {
|
|
|
1062
1107
|
}
|
|
1063
1108
|
}
|
|
1064
1109
|
}
|
|
1065
|
-
function
|
|
1110
|
+
function zn(e, t) {
|
|
1066
1111
|
let n = [], r = null, i = {
|
|
1067
1112
|
positions: () => r ?? t.getPositions?.() ?? [],
|
|
1068
1113
|
reversing: /* @__PURE__ */ new Set()
|
|
@@ -1072,8 +1117,8 @@ function Ln(e, t) {
|
|
|
1072
1117
|
e.data && t.onFill?.(e.data);
|
|
1073
1118
|
};
|
|
1074
1119
|
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));
|
|
1075
|
-
for (let r of Object.keys(
|
|
1076
|
-
let a =
|
|
1120
|
+
for (let r of Object.keys(Ln)) {
|
|
1121
|
+
let a = Ln[r], o = t.onIntent(r, (n) => {
|
|
1077
1122
|
Promise.resolve(a(e, n, i)).catch((e) => t.onError({
|
|
1078
1123
|
message: `Execution command failed: ${r}`,
|
|
1079
1124
|
cause: e
|
|
@@ -1087,24 +1132,24 @@ function Ln(e, t) {
|
|
|
1087
1132
|
}
|
|
1088
1133
|
//#endregion
|
|
1089
1134
|
//#region src/Chart.ts
|
|
1090
|
-
var
|
|
1135
|
+
var Bn = {
|
|
1091
1136
|
min: 0,
|
|
1092
1137
|
max: 100
|
|
1093
|
-
},
|
|
1094
|
-
function
|
|
1138
|
+
}, Vn = "exchange", Hn = Vn;
|
|
1139
|
+
function Un(e) {
|
|
1095
1140
|
if (typeof e == "string" && e !== "exchange" && !g(e)) throw RangeError(`Unknown time zone: ${e}`);
|
|
1096
1141
|
if (typeof e == "number" && !Number.isFinite(e)) throw RangeError(`Invalid UTC offset: ${e}`);
|
|
1097
1142
|
}
|
|
1098
|
-
function
|
|
1099
|
-
let { timeZone: n, timezone: r } = e, i = n !== void 0 && r !== void 0 && n !== r && n === t ? r :
|
|
1143
|
+
function Wn(e, t) {
|
|
1144
|
+
let { timeZone: n, timezone: r } = e, i = n !== void 0 && r !== void 0 && n !== r && n === t ? r : C(e);
|
|
1100
1145
|
return i === void 0 ? e : {
|
|
1101
1146
|
...e,
|
|
1102
1147
|
timeZone: i,
|
|
1103
1148
|
timezone: i
|
|
1104
1149
|
};
|
|
1105
1150
|
}
|
|
1106
|
-
var
|
|
1107
|
-
static version = "1.
|
|
1151
|
+
var Gn = .08, Kn = a ** -7, qn = 800, Jn = 20, Yn = 8, Xn = new Set(["horizontalLine", "crossLine"]), Zn = new Set(["verticalLine", "crossLine"]), Qn = class {
|
|
1152
|
+
static version = "1.51.0";
|
|
1108
1153
|
engine;
|
|
1109
1154
|
viewport;
|
|
1110
1155
|
series = new un((e) => this.sessionKeep(e));
|
|
@@ -1131,6 +1176,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
1131
1176
|
renderDeferred = !1;
|
|
1132
1177
|
priceAxisWidth = o;
|
|
1133
1178
|
measureCtx;
|
|
1179
|
+
labelWidths = new kn();
|
|
1134
1180
|
containerSizeCache = null;
|
|
1135
1181
|
containerSizeCacheTime = 0;
|
|
1136
1182
|
lastEmittedRange = null;
|
|
@@ -1144,14 +1190,14 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
1144
1190
|
indicatorEdit = null;
|
|
1145
1191
|
removedDrawingAlerts = /* @__PURE__ */ new Map();
|
|
1146
1192
|
zoomAreaMode = !1;
|
|
1147
|
-
priceAxisAddButton = new
|
|
1193
|
+
priceAxisAddButton = new Ze();
|
|
1148
1194
|
displayTz = null;
|
|
1149
1195
|
timeZoneSetting = null;
|
|
1150
1196
|
symbolInfo = null;
|
|
1151
1197
|
symbolInfoSeq = 0;
|
|
1152
1198
|
sessionBreaks;
|
|
1153
1199
|
sessionShading;
|
|
1154
|
-
hostSessionHours = { ...
|
|
1200
|
+
hostSessionHours = { ...De };
|
|
1155
1201
|
compareRenderer;
|
|
1156
1202
|
countdownInterval = null;
|
|
1157
1203
|
pausedFor = {
|
|
@@ -1170,7 +1216,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
1170
1216
|
signalMarkerManager;
|
|
1171
1217
|
tradeZoneManager;
|
|
1172
1218
|
measureOverlay;
|
|
1173
|
-
selectionBoxOverlay = new
|
|
1219
|
+
selectionBoxOverlay = new nt();
|
|
1174
1220
|
replayManager;
|
|
1175
1221
|
replayBarUnsub = null;
|
|
1176
1222
|
replaySeeking = !1;
|
|
@@ -1192,14 +1238,14 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
1192
1238
|
disposed = !1;
|
|
1193
1239
|
chartTypeOptions = {};
|
|
1194
1240
|
mainSeriesVisible = !0;
|
|
1195
|
-
priceLines = new
|
|
1196
|
-
symbolSeries = new
|
|
1241
|
+
priceLines = new Qe();
|
|
1242
|
+
symbolSeries = new lt();
|
|
1197
1243
|
extendedHours = !0;
|
|
1198
1244
|
replayRestarting = !1;
|
|
1199
1245
|
requestedSymbols = /* @__PURE__ */ new Set();
|
|
1200
1246
|
gridRenderer;
|
|
1201
1247
|
priceAxis;
|
|
1202
|
-
leftPriceAxis = new
|
|
1248
|
+
leftPriceAxis = new Xe();
|
|
1203
1249
|
leftScaleRequested = !1;
|
|
1204
1250
|
leftAxisWidth = o;
|
|
1205
1251
|
leftViewport = null;
|
|
@@ -1230,7 +1276,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
1230
1276
|
snapshotKey = null;
|
|
1231
1277
|
historyCheckQueued = !1;
|
|
1232
1278
|
constructor(e, t) {
|
|
1233
|
-
t.timeZone != null &&
|
|
1279
|
+
t.timeZone != null && Un(t.timeZone), this.container = e, this.options = {
|
|
1234
1280
|
...t,
|
|
1235
1281
|
chartType: t.chartType ?? "candlestick"
|
|
1236
1282
|
}, this.numberLocale = t.numberLocale ?? "en-US", this.defaultAutoScale = t.autoScale !== !1;
|
|
@@ -1272,11 +1318,11 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
1272
1318
|
oldestTime: () => this.series.bars()[0]?.time ?? null,
|
|
1273
1319
|
prepend: (e) => this.prependBars(e),
|
|
1274
1320
|
emit: (e) => this.eventBus.emit("historyLoad", e)
|
|
1275
|
-
}), this.themeManager = new
|
|
1321
|
+
}), this.themeManager = new gn(t.theme), this.themeManager.setChartType(this.options.chartType ?? "candlestick"), this.applyStyle(vn(t), "host", !1), this.layoutManager = new xn(), this.indicatorEngine = new Le(), this.pluginManager = new In(this.indicatorEngine, { plugins: t.plugins }), this.eventBus = new Me(), jt(this.indicatorEngine), this.indicatorEngine.register(new xe(this.symbolSeries)), this.indicatorEngine.register(new ot(this.symbolSeries)), this.indicatorEngine.register(new Se(this.symbolSeries)), this.indicatorEngine.register(new Ce(this.symbolSeries)), this.drawingManager = new ke(), At(this.drawingManager), this.drawingRenderer = new Ae(this.drawingManager), this.drawingManager.setRequestRender(() => {
|
|
1276
1322
|
this.syncRenderContext(), this.engine.requestRender(r.Overlay), this.scheduleAutoSave();
|
|
1277
1323
|
}), this.drawingManager.setEventCallback((e, t) => {
|
|
1278
1324
|
this.followDrawingAlerts(e, t?.id), this.eventBus.emit(e, t), (e === "drawingCreate" || e === "drawingUpdate" || e === "drawingRemove") && this.announceStateChange();
|
|
1279
|
-
}), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new
|
|
1325
|
+
}), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new mt();
|
|
1280
1326
|
let i = "";
|
|
1281
1327
|
this.undoRedoManager.setOnChange(() => {
|
|
1282
1328
|
let { canUndo: e, canRedo: t } = this.undoRedoManager.getState(), n = `${e}|${t}`;
|
|
@@ -1289,21 +1335,21 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
1289
1335
|
primary: e[0] ?? null
|
|
1290
1336
|
})), this.drawingManager.setForeignHistory((e, t) => {
|
|
1291
1337
|
e.type === "custom" ? e.custom?.[t]() : this.applyIndicatorStep(e, t);
|
|
1292
|
-
}), this.drawingManager.setDataGetter(() => this.series.bars()), this.drawingManager.setDisplayDataGetter(() => this.getDisplayData()), t.crosshair?.mode === "magnet" && this.features.drawingMagnet && this.drawingManager.setMagnetMode("magnet"), this.tradingManager = new
|
|
1338
|
+
}), this.drawingManager.setDataGetter(() => this.series.bars()), this.drawingManager.setDisplayDataGetter(() => this.getDisplayData()), t.crosshair?.mode === "magnet" && this.features.drawingMagnet && this.drawingManager.setMagnetMode("magnet"), this.tradingManager = new ft({
|
|
1293
1339
|
enabled: this.features.trading,
|
|
1294
1340
|
contextMenu: { enabled: this.features.tradingContextMenu }
|
|
1295
|
-
}), this.tradingRenderer = new
|
|
1341
|
+
}), this.tradingRenderer = new pt(this.tradingManager), this.tradingManager.setContainer(e), this.tradingManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradingManager.setEventCallback((e, t) => {
|
|
1296
1342
|
this.eventBus.emit(e, t);
|
|
1297
|
-
}), this.engine = new
|
|
1343
|
+
}), this.engine = new $e(e, t.maxPixelRatio);
|
|
1298
1344
|
let a = this.engine.dprManager.getContainerSize();
|
|
1299
|
-
if (this.viewport = new
|
|
1345
|
+
if (this.viewport = new ht(a.width, a.height, t.minBarSpacing ?? 2, t.maxBarSpacing ?? 30, t.rightMargin ?? 5), t.barLayout && this.viewport.setBarLayout(t.barLayout), this.viewport.setPanLimits({
|
|
1300
1346
|
freePan: t.freePan ?? !0,
|
|
1301
1347
|
minVisibleBars: t.panLimits?.minVisibleBars ?? 3
|
|
1302
1348
|
}), t.minBarUnit !== void 0 && this.viewport.setMinBarUnit(t.minBarUnit), this.layoutManager.resize(a.width, a.height), this.engine.onContainerResize = (e) => {
|
|
1303
1349
|
if (e.width <= 0 || e.height <= 0) return;
|
|
1304
1350
|
let t = this.viewport.isAtEnd();
|
|
1305
1351
|
this.viewport.resize(e.width, e.height), this.layoutManager.resize(e.width, e.height), this.updateViewportAndRender(t);
|
|
1306
|
-
}, this.chartRenderer = this.createChartRenderer(this.options.chartType), this.gridRenderer = new
|
|
1352
|
+
}, this.chartRenderer = this.createChartRenderer(this.options.chartType), this.gridRenderer = new Ne(), t.grid?.visible === !1 && this.gridRenderer.setVisible(!1), this.priceAxis = new Xe(), this.priceAxis.setLocale(this.numberLocale), this.leftPriceAxis.setLocale(this.numberLocale), this.viewport.setNumberLocale(this.numberLocale), this.timeAxis = new ut(), this.timeAxis.setLocale(this.numberLocale), this.crosshairHandler = new we(), 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) => {
|
|
1307
1353
|
if (e !== null && t) {
|
|
1308
1354
|
let n = this.crosshairSeries(), r = e >= 0 && e < n.length ? n[e] : void 0;
|
|
1309
1355
|
this.chartLegend.setHoverBar(r ?? null, e > 0 ? n[e - 1] ?? null : null);
|
|
@@ -1312,7 +1358,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
1312
1358
|
prevClose: e > 0 ? n[e - 1]?.close : void 0,
|
|
1313
1359
|
priceRange: i.priceRange,
|
|
1314
1360
|
plot: i.chartRect,
|
|
1315
|
-
barStepMs:
|
|
1361
|
+
barStepMs: xt(n),
|
|
1316
1362
|
timeUnit: l(n)
|
|
1317
1363
|
}) : this.crosshairTooltip.hide(), this.pinnedTooltip.isPinned() && this.pinnedTooltip.reposition(this.viewport.getState(), r ?? null, e, this.themeManager.getTheme()), this.eventBus.emit("crosshairMove", {
|
|
1318
1364
|
point: t,
|
|
@@ -1320,12 +1366,12 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
1320
1366
|
barIndex: e
|
|
1321
1367
|
});
|
|
1322
1368
|
} else this.crosshairTooltip.hide(), this.chartLegend.setHoverBar(null), this.eventBus.emit("crosshairLeave", {});
|
|
1323
|
-
}), this.chartLegend = new
|
|
1369
|
+
}), this.chartLegend = new ye(), this.chartLegend.setChartType(this.options.chartType), this.chartLegend.setLocale(this.numberLocale), this.watermark = new yt(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new vt(), this.volumeProfile = new _t(), this.marketProfile = new Ue(), this.depthHeatmap = new Oe(), this.periodLevels = new qe(), this.pivotMarkers = new Ye(), this.barCountdown = new he(), this.barCountdown.setVisible(this.features.barCountdown), this.sessionBreaks = new rt(), this.sessionShading = new it(), this.compareRenderer = new be(), t.sessionBreaks ? this.sessionBreaks.setConfig({
|
|
1324
1370
|
visible: t.sessionBreaks.visible ?? !0,
|
|
1325
1371
|
color: t.sessionBreaks.color,
|
|
1326
1372
|
lineStyle: t.sessionBreaks.lineStyle,
|
|
1327
1373
|
lineWidth: t.sessionBreaks.lineWidth
|
|
1328
|
-
}) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new
|
|
1374
|
+
}) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new fe(), this.crosshairTooltip = new Te(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new Je(), this.pinnedTooltip.create(e), t.priceFormat && this.applyPriceFormat(t.priceFormat), t.chartTypeOptions && (this.chartTypeOptions = x(t.chartTypeOptions)), t.highLowLines && this.priceLines.setHighLow(!0), t.shapes && this.themeManager.setShape(ir(t.shapes)), t.font && this.themeManager.setFont(rr(t.font)), this.priceLines.setPriceText((e) => this.formatPrice(e)), t.extendedHours === !1 && (this.extendedHours = !1), t.timeFormatter && this.applyTimeFormatter(t.timeFormatter), this.keyboardHandler = new Be({
|
|
1329
1375
|
scrollBars: (e) => {
|
|
1330
1376
|
let t = this.viewport.getState().barWidth + this.viewport.getState().barSpacing;
|
|
1331
1377
|
this.viewport.scrollBy(e * t), this.updateViewportAndRender();
|
|
@@ -1342,14 +1388,14 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
1342
1388
|
},
|
|
1343
1389
|
fitContent: () => this.fitContent()
|
|
1344
1390
|
}), this.keyboardHandler.setEnabled(this.features.keyboard), t.a11y !== !1) {
|
|
1345
|
-
this.a11y = new
|
|
1391
|
+
this.a11y = new Yt(e, {
|
|
1346
1392
|
symbol: () => this.currentSymbol || this.symbolInfo?.symbol || "",
|
|
1347
1393
|
timeframe: () => this.streamTimeframe ?? "",
|
|
1348
1394
|
chartType: () => this.options.chartType ?? "candlestick",
|
|
1349
1395
|
bars: () => this.getDisplayData(),
|
|
1350
1396
|
visibleRange: () => this.viewport.getState().visibleRange,
|
|
1351
1397
|
formatPrice: (e) => this.formatPrice(e),
|
|
1352
|
-
formatTime: (e) =>
|
|
1398
|
+
formatTime: (e) => le(this.numberLocale || "en-US", {
|
|
1353
1399
|
dateStyle: "medium",
|
|
1354
1400
|
timeStyle: "short"
|
|
1355
1401
|
}, this.displayTz)(e * l(this.getDisplayData())),
|
|
@@ -1372,8 +1418,8 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
1372
1418
|
}
|
|
1373
1419
|
this.keyboardHandler.handleKey(e) && (e.preventDefault(), this.a11y?.viewMoved());
|
|
1374
1420
|
}
|
|
1375
|
-
}, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new
|
|
1376
|
-
this.eventBus.emit("alertTriggered",
|
|
1421
|
+
}, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new Ee(), this.currentPriceLine.setLocale(this.numberLocale), this.priceAxis.setReservedPriceProvider(() => this.currentPriceLine.isVisible() ? this.currentPriceLine.getPrice() : null), this.alertManager = new de(), this.alertManager.setDrawingLevels((e) => this.drawingLevelsNow(e)), this.alertManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.alertManager.on("triggered", (e) => {
|
|
1422
|
+
this.eventBus.emit("alertTriggered", q(e)), this.eventBus.emit("dataUpdate", {
|
|
1377
1423
|
kind: "alert",
|
|
1378
1424
|
alert: "triggered",
|
|
1379
1425
|
alertId: e.id,
|
|
@@ -1381,14 +1427,14 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
1381
1427
|
message: e.message
|
|
1382
1428
|
});
|
|
1383
1429
|
}), this.alertManager.on("added", (e) => {
|
|
1384
|
-
this.eventBus.emit("alertAdd",
|
|
1430
|
+
this.eventBus.emit("alertAdd", q(e));
|
|
1385
1431
|
}), this.alertManager.on("removed", (e) => {
|
|
1386
1432
|
this.eventBus.emit("alertRemove", { id: e });
|
|
1387
1433
|
}), this.alertManager.on("expired", (e) => {
|
|
1388
|
-
this.eventBus.emit("alertExpired",
|
|
1434
|
+
this.eventBus.emit("alertExpired", q(e));
|
|
1389
1435
|
}), this.alertManager.on("updated", (e) => {
|
|
1390
|
-
this.eventBus.emit("alertUpdate",
|
|
1391
|
-
}), this.signalMarkerManager = new
|
|
1436
|
+
this.eventBus.emit("alertUpdate", q(e));
|
|
1437
|
+
}), this.signalMarkerManager = new at(), this.signalMarkerManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.signalMarkerManager.setDataGetter(() => this.series.bars()), this.signalMarkerManager.on("added", (e) => {
|
|
1392
1438
|
this.eventBus.emit("signalMarkerAdd", {
|
|
1393
1439
|
id: e.id,
|
|
1394
1440
|
source: e.source,
|
|
@@ -1396,14 +1442,14 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
1396
1442
|
});
|
|
1397
1443
|
}), this.signalMarkerManager.on("removed", (e) => {
|
|
1398
1444
|
this.eventBus.emit("signalMarkerRemove", { id: e });
|
|
1399
|
-
}), this.tradeZoneManager = new
|
|
1445
|
+
}), this.tradeZoneManager = new dt(), this.tradeZoneManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradeZoneManager.setDataGetter(() => this.series.bars()), this.tradeZoneManager.on("added", (e) => {
|
|
1400
1446
|
this.eventBus.emit("tradeZoneAdd", {
|
|
1401
1447
|
id: e.id,
|
|
1402
1448
|
direction: e.direction
|
|
1403
1449
|
});
|
|
1404
1450
|
}), this.tradeZoneManager.on("removed", (e) => {
|
|
1405
1451
|
this.eventBus.emit("tradeZoneRemove", { id: e });
|
|
1406
|
-
}), this.replayManager = new
|
|
1452
|
+
}), this.replayManager = new tt(), this.replayManager.on("complete", () => {
|
|
1407
1453
|
let e = this.getReplayBarIndex(), t = this.replayCoarse?.[e];
|
|
1408
1454
|
t && this.eventBus.emit("replayComplete", {
|
|
1409
1455
|
barIndex: e,
|
|
@@ -1411,9 +1457,9 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
1411
1457
|
});
|
|
1412
1458
|
}), this.replayManager.on("stateChange", (e) => {
|
|
1413
1459
|
this.replayRestarting || this.eventBus.emit("replayState", { state: e });
|
|
1414
|
-
}), this.measureOverlay = new
|
|
1415
|
-
let e = new
|
|
1416
|
-
this.interactionManager.setPanHandler(new
|
|
1460
|
+
}), this.measureOverlay = new We(), this.interactionManager = new Re(e), this.features.panning) {
|
|
1461
|
+
let e = new An();
|
|
1462
|
+
this.interactionManager.setPanHandler(new Ge((t, n) => {
|
|
1417
1463
|
t && this.viewport.scrollBy(t), e.step(t, n, this.options.autoScale !== !1) && n && (this.options.autoScale = !1, this.viewport.panPriceRange(n)), this.updateViewportAndRender();
|
|
1418
1464
|
}, () => e.reset()));
|
|
1419
1465
|
}
|
|
@@ -1425,10 +1471,10 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
1425
1471
|
scales: !this.indicatorEngine.hasLeftScaleOverlays()
|
|
1426
1472
|
}
|
|
1427
1473
|
})), this.features.zooming) {
|
|
1428
|
-
this.interactionManager.setZoomHandler(new
|
|
1474
|
+
this.interactionManager.setZoomHandler(new bt((e, t) => {
|
|
1429
1475
|
this.viewport.zoom(e, t - this.viewport.getState().chartRect.x), this.updateViewportAndRender();
|
|
1430
1476
|
}));
|
|
1431
|
-
let e = new
|
|
1477
|
+
let e = new me((e) => {
|
|
1432
1478
|
this.options.autoScale = !1, this.viewport.scalePriceRange(e), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents();
|
|
1433
1479
|
}, (e) => {
|
|
1434
1480
|
let t = this.viewport.getState().chartRect.width;
|
|
@@ -1448,7 +1494,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
1448
1494
|
y: t.y
|
|
1449
1495
|
});
|
|
1450
1496
|
})), this.interactionManager.setChartContextMenu((e, t) => this.eventBus.hasListeners("chartContextMenu") ? (this.eventBus.emit("chartContextMenu", this.contextAt(e, t)), !0) : !1), this.priceAxisAddButton.setEnabled(this.features.priceAxisAddButton && this.features.crosshair), this.interactionManager.setPriceAxisAddButton(this.priceAxisAddButton, (e) => {
|
|
1451
|
-
let t =
|
|
1497
|
+
let t = N(e.y, this.viewport.getState());
|
|
1452
1498
|
Number.isFinite(t) && this.eventBus.emit("priceAxisAdd", {
|
|
1453
1499
|
price: t,
|
|
1454
1500
|
x: e.x,
|
|
@@ -1458,10 +1504,10 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
1458
1504
|
...this.viewport.getState(),
|
|
1459
1505
|
data: this.getDisplayData()
|
|
1460
1506
|
})), this.features.alerts) {
|
|
1461
|
-
let e = new
|
|
1507
|
+
let e = new ue(this.alertManager, () => this.viewport.getState());
|
|
1462
1508
|
this.interactionManager.setAlertDragHandler(e);
|
|
1463
1509
|
}
|
|
1464
|
-
let o = new
|
|
1510
|
+
let o = new Ke();
|
|
1465
1511
|
o.configure(() => this.getResolvedLayout(), (e, t) => this.setPanelSize(e, t)), this.interactionManager.setPaneResizeHandler(o), this.interactionManager.setAltClickHandler((e) => {
|
|
1466
1512
|
let t = this.getDisplayData();
|
|
1467
1513
|
if (t.length === 0) return;
|
|
@@ -1485,7 +1531,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
1485
1531
|
x: e.x,
|
|
1486
1532
|
y: e.y
|
|
1487
1533
|
}), t.length === 0) return;
|
|
1488
|
-
let r =
|
|
1534
|
+
let r = Ht(e.x, this.viewport.getState());
|
|
1489
1535
|
r < 0 || r >= t.length || this.eventBus.emit("barClick", {
|
|
1490
1536
|
bar: t[r],
|
|
1491
1537
|
barIndex: r,
|
|
@@ -1528,7 +1574,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
1528
1574
|
end: () => {
|
|
1529
1575
|
let e = this.selectionBoxOverlay.end();
|
|
1530
1576
|
if (e && this.zoomAreaMode) {
|
|
1531
|
-
if (e.x1 - e.x0 <
|
|
1577
|
+
if (e.x1 - e.x0 < Yn) return;
|
|
1532
1578
|
this.zoomToBox(e), this.setZoomAreaMode(!1);
|
|
1533
1579
|
return;
|
|
1534
1580
|
}
|
|
@@ -1569,7 +1615,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
1569
1615
|
if (i === 0) return a;
|
|
1570
1616
|
let o = this.series.bars();
|
|
1571
1617
|
if (this.crosshairHandler.setData(o), this.displayDataCache = null, this.sessionBreaks.invalidateCache(), this.pinnedTooltip.isPinned() && this.pinnedTooltip.unpin(), this.measureOverlay.end(), this.recalcIndicators(o), r !== void 0) {
|
|
1572
|
-
let e = Math.round(
|
|
1618
|
+
let e = Math.round(j(r, this.getDisplayData()));
|
|
1573
1619
|
this.viewport.prependBars(e - n);
|
|
1574
1620
|
}
|
|
1575
1621
|
return this.updateViewportAndRender(), a;
|
|
@@ -1601,13 +1647,13 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
1601
1647
|
let { visibleRange: e, chartRect: t } = this.viewport.getState();
|
|
1602
1648
|
if (t.width <= 0) return;
|
|
1603
1649
|
let { from: n, to: r } = e;
|
|
1604
|
-
this.history.maybeLoad(Math.max(0, Math.floor(n)), Math.max(
|
|
1650
|
+
this.history.maybeLoad(Math.max(0, Math.floor(n)), Math.max(Jn, r - n));
|
|
1605
1651
|
}));
|
|
1606
1652
|
}
|
|
1607
1653
|
useStreamHistory(e, t) {
|
|
1608
1654
|
if (this.hostHistoryLoader) return;
|
|
1609
|
-
let n =
|
|
1610
|
-
if (!r || i === null ||
|
|
1655
|
+
let n = Vt(e), r = n.fetchHistoryBefore, i = this.streamTimeframe;
|
|
1656
|
+
if (!r || i === null || se(i) !== null) {
|
|
1611
1657
|
this.historyFromStream && this.history.setLoader(null), this.historyFromStream = !1;
|
|
1612
1658
|
return;
|
|
1613
1659
|
}
|
|
@@ -1675,11 +1721,11 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
1675
1721
|
setChartTypeOptions(e) {
|
|
1676
1722
|
this.chartTypeOptions = {
|
|
1677
1723
|
...this.chartTypeOptions,
|
|
1678
|
-
...
|
|
1724
|
+
...x(e)
|
|
1679
1725
|
}, this.displayDataCache = null, this.updateViewportAndRender(!0), this.markStateChanged();
|
|
1680
1726
|
}
|
|
1681
1727
|
getChartTypeOptions() {
|
|
1682
|
-
return
|
|
1728
|
+
return x(this.chartTypeOptions);
|
|
1683
1729
|
}
|
|
1684
1730
|
setExtendedHours(e) {
|
|
1685
1731
|
e !== this.extendedHours && (this.extendedHours = e, this.reapplyExtendedHours(), this.markStateChanged());
|
|
@@ -1688,7 +1734,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
1688
1734
|
return this.extendedHours;
|
|
1689
1735
|
}
|
|
1690
1736
|
sessionKeep(e) {
|
|
1691
|
-
return this.extendedHours ? null :
|
|
1737
|
+
return this.extendedHours ? null : Gt(this.symbolInfo, e);
|
|
1692
1738
|
}
|
|
1693
1739
|
reapplyExtendedHours() {
|
|
1694
1740
|
if (!this.series.refilter()) return;
|
|
@@ -1699,7 +1745,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
1699
1745
|
return this.priceLines.setQuoteShown(this.replaySession === null), this.priceLines;
|
|
1700
1746
|
}
|
|
1701
1747
|
setShapes(e) {
|
|
1702
|
-
let t =
|
|
1748
|
+
let t = ir(e);
|
|
1703
1749
|
t.tagRadius !== void 0 && (this.themeManager.setShape({
|
|
1704
1750
|
...this.themeManager.getTheme().shape,
|
|
1705
1751
|
...t
|
|
@@ -1708,6 +1754,24 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
1708
1754
|
getShapes() {
|
|
1709
1755
|
return { ...this.themeManager.getTheme().shape };
|
|
1710
1756
|
}
|
|
1757
|
+
setFont(e) {
|
|
1758
|
+
if (e === null) this.themeManager.setFont(null);
|
|
1759
|
+
else {
|
|
1760
|
+
let t = rr(e);
|
|
1761
|
+
if (Object.keys(t).length === 0) return;
|
|
1762
|
+
this.themeManager.setFont(t);
|
|
1763
|
+
}
|
|
1764
|
+
this.updateViewportAndRender();
|
|
1765
|
+
}
|
|
1766
|
+
getFont() {
|
|
1767
|
+
return { ...this.themeManager.getTheme().font };
|
|
1768
|
+
}
|
|
1769
|
+
setBarLayout(e) {
|
|
1770
|
+
e !== "golden" && e !== "classic" || e === this.viewport.getBarLayout() || (this.viewport.setBarLayout(e), this.updateViewportAndRender());
|
|
1771
|
+
}
|
|
1772
|
+
getBarLayout() {
|
|
1773
|
+
return this.viewport.getBarLayout();
|
|
1774
|
+
}
|
|
1711
1775
|
setMainSeriesVisible(e) {
|
|
1712
1776
|
this.mainSeriesVisible = e, this.syncRenderContext(), this.engine.requestRender();
|
|
1713
1777
|
}
|
|
@@ -1744,7 +1808,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
1744
1808
|
setSymbolSeries(e, t) {
|
|
1745
1809
|
e = e.trim(), this.symbolSeries.set(e, t), this.requestedSymbols.delete(e);
|
|
1746
1810
|
let n = this.series.bars(), r = !1;
|
|
1747
|
-
for (let t of this.indicatorEngine.getActiveIndicators()) !
|
|
1811
|
+
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);
|
|
1748
1812
|
r && (this.announceIndicatorUpdate(0), this.updateViewportAndRender());
|
|
1749
1813
|
}
|
|
1750
1814
|
forgetUnreadSymbols() {
|
|
@@ -1758,20 +1822,20 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
1758
1822
|
let e = /* @__PURE__ */ new Set();
|
|
1759
1823
|
for (let t of this.indicatorEngine.getActiveIndicators()) {
|
|
1760
1824
|
let n = t.params.symbol;
|
|
1761
|
-
|
|
1825
|
+
O.has(t.id) && typeof n == "string" && n.trim() && e.add(n.trim());
|
|
1762
1826
|
}
|
|
1763
1827
|
return [...e];
|
|
1764
1828
|
}
|
|
1765
1829
|
requestMissingSymbols(e) {
|
|
1766
1830
|
this.forgetUnreadSymbols();
|
|
1767
|
-
let t = this.indicatorEngine.getIndicatorConfig(e), n = t &&
|
|
1831
|
+
let t = this.indicatorEngine.getIndicatorConfig(e), n = t && O.has(t.id) && typeof t.params.symbol == "string" ? t.params.symbol.trim() : "";
|
|
1768
1832
|
!n || this.symbolSeries.has(n) || this.requestedSymbols.has(n) || (this.requestedSymbols.add(n), this.eventBus.emit("symbolSeriesRequest", { symbol: n }));
|
|
1769
1833
|
}
|
|
1770
1834
|
updateIndicator(e, t) {
|
|
1771
1835
|
this.recordIndicators(e, () => this.updateIndicatorNow(e, t));
|
|
1772
1836
|
}
|
|
1773
1837
|
updateIndicatorNow(e, t) {
|
|
1774
|
-
let n = this.indicatorEngine.getIndicatorDescriptor(e), r = n ?
|
|
1838
|
+
let n = this.indicatorEngine.getIndicatorDescriptor(e), r = n ? A(n) : null, i = r ? this.indicatorEngine.getIndicatorConfig(e)?.params[r] : void 0;
|
|
1775
1839
|
this.indicatorEngine.updateIndicator(e, t, this.series.bars()), this.announceIndicatorUpdate(0), this.markStateChanged(), this.eventBus.emit("indicatorChange", {
|
|
1776
1840
|
instanceId: e,
|
|
1777
1841
|
change: "params"
|
|
@@ -1789,7 +1853,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
1789
1853
|
paneFor(e, t, n, r) {
|
|
1790
1854
|
if (n) return this.paneHostOf(n, r);
|
|
1791
1855
|
if (e.placement !== "overlay") return null;
|
|
1792
|
-
let i =
|
|
1856
|
+
let i = A(e), a = i ? y(t[i]) : null;
|
|
1793
1857
|
return a ? this.paneHostOf(a.instanceId, r) : null;
|
|
1794
1858
|
}
|
|
1795
1859
|
paneHostOf(e, t) {
|
|
@@ -1832,8 +1896,8 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
1832
1896
|
return {
|
|
1833
1897
|
...e,
|
|
1834
1898
|
priceRange: {
|
|
1835
|
-
min: t.min - n *
|
|
1836
|
-
max: t.max + n *
|
|
1899
|
+
min: t.min - n * Gn,
|
|
1900
|
+
max: t.max + n * Gn
|
|
1837
1901
|
},
|
|
1838
1902
|
logScale: !1,
|
|
1839
1903
|
scaleMode: "regular",
|
|
@@ -1885,7 +1949,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
1885
1949
|
this.indicatorEngine.setStyleDefaults(e, null);
|
|
1886
1950
|
return;
|
|
1887
1951
|
}
|
|
1888
|
-
let { plots: n, ...r } = t, i = n === void 0 ? void 0 :
|
|
1952
|
+
let { plots: n, ...r } = t, i = n === void 0 ? void 0 : ne(n);
|
|
1889
1953
|
this.indicatorEngine.setStyleDefaults(e, {
|
|
1890
1954
|
...r,
|
|
1891
1955
|
...i ? { plots: i } : {}
|
|
@@ -1893,7 +1957,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
1893
1957
|
}
|
|
1894
1958
|
setPaneStyle(e, t) {
|
|
1895
1959
|
let n = this.paneOf(e);
|
|
1896
|
-
this.layoutManager.getPanels().some((e) => e.id === n) && this.recordIndicators(n, () => this.setPaneStyleNow(n, t ?
|
|
1960
|
+
this.layoutManager.getPanels().some((e) => e.id === n) && this.recordIndicators(n, () => this.setPaneStyleNow(n, t ? re(t) : null));
|
|
1897
1961
|
}
|
|
1898
1962
|
setPaneStyleNow(e, t) {
|
|
1899
1963
|
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());
|
|
@@ -1912,8 +1976,8 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
1912
1976
|
return this.pluginManager;
|
|
1913
1977
|
}
|
|
1914
1978
|
static indicators() {
|
|
1915
|
-
let e = new
|
|
1916
|
-
return
|
|
1979
|
+
let e = new Le();
|
|
1980
|
+
return jt(e), e.getAvailableIndicators();
|
|
1917
1981
|
}
|
|
1918
1982
|
setPanelPosition(e, t) {
|
|
1919
1983
|
this.layoutManager.setPanelPosition(e, t), this.updateViewportAndRender(), this.eventBus.emit("indicatorChange", {
|
|
@@ -1936,7 +2000,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
1936
2000
|
paneMoveHost(e, t) {
|
|
1937
2001
|
let n = this.indicatorEngine.getIndicatorConfig(e), r = this.indicatorEngine.getIndicatorDescriptor(e);
|
|
1938
2002
|
if (!n || !r) return;
|
|
1939
|
-
let i =
|
|
2003
|
+
let i = A(r);
|
|
1940
2004
|
if (r.placement === "overlay" && i && y(n.params[i])) return;
|
|
1941
2005
|
if (t === "price") return r.placement === "overlay" && n.pane ? null : void 0;
|
|
1942
2006
|
if (t === "new") {
|
|
@@ -2048,7 +2112,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
2048
2112
|
roundPrice(e) {
|
|
2049
2113
|
if (!Number.isFinite(e)) return e;
|
|
2050
2114
|
let t = this.stepAt(e);
|
|
2051
|
-
if (t !== void 0) return Number((Math.round(e / t) * t).toFixed(
|
|
2115
|
+
if (t !== void 0) return Number((Math.round(e / t) * t).toFixed(oe(t)));
|
|
2052
2116
|
let { min: n, max: r } = this.viewport.getState().priceRange;
|
|
2053
2117
|
return Number(e.toFixed(this.marketPricePrecision ?? c(n, r)));
|
|
2054
2118
|
}
|
|
@@ -2132,7 +2196,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
2132
2196
|
}
|
|
2133
2197
|
autoFib() {
|
|
2134
2198
|
if (!this.features.drawings) return null;
|
|
2135
|
-
let e = this.getDisplayData(), t = this.viewport.getState(), n =
|
|
2199
|
+
let e = this.getDisplayData(), t = this.viewport.getState(), n = St(e, t.visibleRange.from, t.visibleRange.to);
|
|
2136
2200
|
return n ? this.addDrawing({
|
|
2137
2201
|
type: "fibRetracement",
|
|
2138
2202
|
anchors: [n[0], n[1]]
|
|
@@ -2210,7 +2274,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
2210
2274
|
recordUndo(e) {
|
|
2211
2275
|
if (!this.features.drawingUndoRedo || typeof e?.undo != "function" || typeof e.redo != "function") return;
|
|
2212
2276
|
let t = performance.now(), n = this.undoRedoManager.last();
|
|
2213
|
-
if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at <
|
|
2277
|
+
if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at < qn) {
|
|
2214
2278
|
this.undoRedoManager.replaceLast({
|
|
2215
2279
|
...n,
|
|
2216
2280
|
custom: {
|
|
@@ -2257,7 +2321,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
2257
2321
|
x: t.x,
|
|
2258
2322
|
y: t.y
|
|
2259
2323
|
};
|
|
2260
|
-
if ((e === "plot" || e === "priceAxis") && (r.price =
|
|
2324
|
+
if ((e === "plot" || e === "priceAxis") && (r.price = N(t.y, n)), (e === "plot" || e === "timeAxis") && n.data.length > 0 && (r.time = M(t.x, n)), e === "pane") {
|
|
2261
2325
|
let e = this.getIndicatorPanes().find((e) => t.y >= e.rect.y && t.y <= e.rect.y + e.rect.height);
|
|
2262
2326
|
e && (r.pane = e.instanceId);
|
|
2263
2327
|
}
|
|
@@ -2283,7 +2347,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
2283
2347
|
...this.viewport.getState(),
|
|
2284
2348
|
data: this.getDisplayData()
|
|
2285
2349
|
};
|
|
2286
|
-
this.setVisibleRange(
|
|
2350
|
+
this.setVisibleRange(M(e.x0, t), M(e.x1, t));
|
|
2287
2351
|
}
|
|
2288
2352
|
lockAllDrawings() {
|
|
2289
2353
|
this.drawingManager.lockAllDrawings();
|
|
@@ -2328,7 +2392,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
2328
2392
|
for (let e of this.indicatorEngine.getActiveIndicators()) {
|
|
2329
2393
|
let t = this.indicatorEngine.getOutput(e.instanceId)?.series;
|
|
2330
2394
|
if (!t) continue;
|
|
2331
|
-
let r =
|
|
2395
|
+
let r = L(e.id, e.params, e.descriptor.defaultConfig, e.descriptor.shortName), o = e.descriptor.plots ?? Object.keys(t.find((e) => e) ?? {}).map((e) => ({
|
|
2332
2396
|
key: e,
|
|
2333
2397
|
title: e
|
|
2334
2398
|
}));
|
|
@@ -2352,11 +2416,11 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
2352
2416
|
}
|
|
2353
2417
|
getExportText(e = "csv", t = {}) {
|
|
2354
2418
|
let { bars: n, columns: r } = this.getExportData(t);
|
|
2355
|
-
return e === "json" ?
|
|
2419
|
+
return e === "json" ? T.toJSON(n, r) : T.toCSV(n, r);
|
|
2356
2420
|
}
|
|
2357
2421
|
download(e, t, n) {
|
|
2358
2422
|
let r = this.getExportText(e, n);
|
|
2359
|
-
e === "json" ?
|
|
2423
|
+
e === "json" ? T.download(r, t ?? "chart-data.json", "application/json") : T.download(r, t ?? "chart-data.csv", "text/csv");
|
|
2360
2424
|
}
|
|
2361
2425
|
setAutoSave(e, t = 5e3) {
|
|
2362
2426
|
this.autoSaveScheduler.enable(e, t);
|
|
@@ -2418,7 +2482,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
2418
2482
|
this.recordIndicators(e, () => this.updateIndicatorStyleNow(e, t));
|
|
2419
2483
|
}
|
|
2420
2484
|
updateIndicatorStyleNow(e, t) {
|
|
2421
|
-
let { plots: n, ...r } = t, i = n === void 0 ? void 0 :
|
|
2485
|
+
let { plots: n, ...r } = t, i = n === void 0 ? void 0 : ne(n);
|
|
2422
2486
|
this.indicatorEngine.updateIndicatorStyle(e, {
|
|
2423
2487
|
...r,
|
|
2424
2488
|
...i ? { plots: i } : {}
|
|
@@ -2537,8 +2601,8 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
2537
2601
|
this.features.trading && this.tradingManager.setConfig(e);
|
|
2538
2602
|
}
|
|
2539
2603
|
async connect(e) {
|
|
2540
|
-
if (!
|
|
2541
|
-
this.snapshotKey = null, this.replayStop(), this.disconnectStream(), this.streamManager = new
|
|
2604
|
+
if (!Mt(e.adapter, e.timeframe)) throw RangeError(`${e.adapter.name} cannot serve the ${e.timeframe} timeframe`);
|
|
2605
|
+
this.snapshotKey = null, this.replayStop(), this.disconnectStream(), this.streamManager = new ct(), this.streamManager.on("snapshot", (t) => {
|
|
2542
2606
|
let n = `${this.currentSymbol}|${this.streamTimeframe}`;
|
|
2543
2607
|
this.replaySession ? this.series.loadAside(t) : n === this.snapshotKey && this.series.length() > 0 ? this.mergeSnapshot(t) : this.setData(t), this.snapshotKey = n, this.useStreamHistory(e.adapter, e.historyPageSize);
|
|
2544
2608
|
}), this.streamManager.on("barClose", (e) => {
|
|
@@ -2589,14 +2653,14 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
2589
2653
|
}), this.streamManager.on("symbolInfo", (e) => this.applyFeedSymbolInfo(e)), this.autoScrollOnNewBar = e.autoScroll !== !1, this.setStreamTarget(e.symbol, e.timeframe), this.streamAdapter = e.adapter;
|
|
2590
2654
|
let t = this.streamManager;
|
|
2591
2655
|
if (this.resolveStreamSymbol(e.adapter, e.symbol), await t.connect(e), this.streamManager !== t) return;
|
|
2592
|
-
let n =
|
|
2656
|
+
let n = ce(e.timeframe);
|
|
2593
2657
|
this.barCountdown.setTimeframeMs(n), this.countdownInterval && clearInterval(this.countdownInterval), this.countdownInterval = setInterval(() => {
|
|
2594
2658
|
this.barCountdown.isVisible() && this.engine.requestRender(r.Hover);
|
|
2595
2659
|
}, 1e3);
|
|
2596
2660
|
}
|
|
2597
2661
|
setStreamTarget(e, t) {
|
|
2598
2662
|
let n = this.announcedSymbol;
|
|
2599
|
-
this.currentSymbol = e, this.streamTimeframe = t, this.tickStream =
|
|
2663
|
+
this.currentSymbol = e, this.streamTimeframe = t, this.tickStream = se(t) !== null, this.applyTimeSpacing(), e !== n && this.chartLegend.setSymbol(e), e !== n && (this.announcedSymbol = e, this.eventBus.emit("symbolChange", {
|
|
2600
2664
|
symbol: e,
|
|
2601
2665
|
previous: n
|
|
2602
2666
|
})), this.useTimeframe(t);
|
|
@@ -2614,8 +2678,8 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
2614
2678
|
async switchStream(e, t) {
|
|
2615
2679
|
if (!this.streamManager) return;
|
|
2616
2680
|
let n = this.streamAdapter;
|
|
2617
|
-
if (n && !
|
|
2618
|
-
this.setStreamTarget(e, t), this.historyFromStream && this.history.setLoader(null), this.barCountdown.setTimeframeMs(
|
|
2681
|
+
if (n && !Mt(n, t)) throw RangeError(`${n.name} cannot serve the ${t} timeframe`);
|
|
2682
|
+
this.setStreamTarget(e, t), this.historyFromStream && this.history.setLoader(null), this.barCountdown.setTimeframeMs(ce(t)), n && this.resolveStreamSymbol(n, e), await this.streamManager.switchTo(e, t);
|
|
2619
2683
|
}
|
|
2620
2684
|
isIndicatorAllowed(e) {
|
|
2621
2685
|
let t = this.features.indicatorIds;
|
|
@@ -2634,7 +2698,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
2634
2698
|
}
|
|
2635
2699
|
connectExecution(e, t = {}) {
|
|
2636
2700
|
if (!this.features.trading) throw Error("connectExecution requires features.trading to be enabled");
|
|
2637
|
-
this.disconnectExecution(), this.executionAdapter = e, this.execTeardown =
|
|
2701
|
+
this.disconnectExecution(), this.executionAdapter = e, this.execTeardown = zn(e, {
|
|
2638
2702
|
onIntent: (e, t) => {
|
|
2639
2703
|
let n = (e) => t(e.payload);
|
|
2640
2704
|
return this.eventBus.on(e, n), () => this.eventBus.off(e, n);
|
|
@@ -2725,18 +2789,18 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
2725
2789
|
goToTime(e) {
|
|
2726
2790
|
let t = this.getDisplayData();
|
|
2727
2791
|
if (t.length === 0 || !Number.isFinite(e)) return -1;
|
|
2728
|
-
let n = Math.max(0, Math.min(t.length - 1, Math.floor(
|
|
2792
|
+
let n = Math.max(0, Math.min(t.length - 1, Math.floor(j(e, t)))), r = this.viewport.getState(), i = n * (r.barWidth + r.barSpacing) + r.barWidth / 2 - r.chartRect.width / 2;
|
|
2729
2793
|
return this.viewport.scrollBy(i - r.offset), this.updateViewportAndRender(), n;
|
|
2730
2794
|
}
|
|
2731
2795
|
setVisibleRangePreset(e) {
|
|
2732
2796
|
let t = this.getDisplayData();
|
|
2733
2797
|
if (t.length === 0) return;
|
|
2734
|
-
let n = t.length - 1, r = l(t), i =
|
|
2798
|
+
let n = t.length - 1, r = l(t), i = Ot(e, t[n].time * r, this.displayTz), a = i === null ? null : i / r;
|
|
2735
2799
|
if (a === null || a < t[0].time) {
|
|
2736
2800
|
this.fitContent();
|
|
2737
2801
|
return;
|
|
2738
2802
|
}
|
|
2739
|
-
let o =
|
|
2803
|
+
let o = j(a, t), s = Math.min(n, e === "YTD" ? Math.ceil(o) : Math.floor(o) + 1);
|
|
2740
2804
|
this.viewport.zoomToBarRange(s, n + this.viewport.getRightMargin()), this.viewport.scrollToEnd(), this.updateViewportAndRender();
|
|
2741
2805
|
}
|
|
2742
2806
|
scrollToEnd() {
|
|
@@ -2761,7 +2825,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
2761
2825
|
setVisibleRange(e, t) {
|
|
2762
2826
|
let n = this.getDisplayData();
|
|
2763
2827
|
if (n.length === 0) return;
|
|
2764
|
-
let r =
|
|
2828
|
+
let r = j(Math.min(e, t), n), i = j(Math.max(e, t), n);
|
|
2765
2829
|
this.viewport.zoomToBarRange(r, i), this.updateViewportAndRender();
|
|
2766
2830
|
}
|
|
2767
2831
|
suspend() {
|
|
@@ -2867,7 +2931,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
2867
2931
|
this.applyStyle(e, t.layer ?? "host", !0);
|
|
2868
2932
|
}
|
|
2869
2933
|
setOverrides(e, t = {}) {
|
|
2870
|
-
let n = t.layer ?? "host", { overrides: r, rejected: i } =
|
|
2934
|
+
let n = t.layer ?? "host", { overrides: r, rejected: i } = b(e);
|
|
2871
2935
|
i.length > 0 && console.warn(`Style overrides left out (unknown key or value): ${i.join(", ")}`);
|
|
2872
2936
|
let a = Object.fromEntries(Object.entries(r).filter(([, e]) => e !== null));
|
|
2873
2937
|
this.themeManager.setOverrides(a, n) && this.styleChanged(n);
|
|
@@ -2886,7 +2950,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
2886
2950
|
return this.themeManager.getStyleValue(e);
|
|
2887
2951
|
}
|
|
2888
2952
|
applyStyle(e, t, n) {
|
|
2889
|
-
let { overrides: r, rejected: i } =
|
|
2953
|
+
let { overrides: r, rejected: i } = b(e);
|
|
2890
2954
|
i.length > 0 && console.warn(`Style overrides left out (unknown key or value): ${i.join(", ")}`), this.themeManager.applyOverrides(r, t) && n && this.styleChanged(t);
|
|
2891
2955
|
}
|
|
2892
2956
|
styleChanged(e) {
|
|
@@ -2916,7 +2980,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
2916
2980
|
e ? this.crosshairHandler.onPointerMove(e) : this.crosshairHandler.onPointerLeave(), this.engine.requestRender(r.Hover);
|
|
2917
2981
|
}
|
|
2918
2982
|
setCrosshairTime(e) {
|
|
2919
|
-
let t = this.getDisplayData(), n = e === null || t.length === 0 ? null : Math.floor(
|
|
2983
|
+
let t = this.getDisplayData(), n = e === null || t.length === 0 ? null : Math.floor(j(e, t));
|
|
2920
2984
|
n !== this.crosshairHandler.getSyncedSlot() && (this.crosshairHandler.setSyncedSlot(n), this.engine.requestRender(r.Hover));
|
|
2921
2985
|
}
|
|
2922
2986
|
getData() {
|
|
@@ -2978,7 +3042,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
2978
3042
|
this.periodLevels.setPeriod(e), this.engine.requestRender(r.Main);
|
|
2979
3043
|
}
|
|
2980
3044
|
setTimeZone(e) {
|
|
2981
|
-
|
|
3045
|
+
Un(e), this.timeZoneSetting = e, this.applyTimeZone();
|
|
2982
3046
|
}
|
|
2983
3047
|
getTimeZone() {
|
|
2984
3048
|
return this.timeZoneSetting;
|
|
@@ -2987,7 +3051,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
2987
3051
|
return this.displayTz;
|
|
2988
3052
|
}
|
|
2989
3053
|
getExchangeTimeZone() {
|
|
2990
|
-
return [
|
|
3054
|
+
return [C(this.symbolInfo), this.marketConfig?.timeZone].find((e) => e && g(e)) ?? null;
|
|
2991
3055
|
}
|
|
2992
3056
|
setTimezone(e) {
|
|
2993
3057
|
this.setTimeZone(e);
|
|
@@ -3009,18 +3073,18 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
3009
3073
|
this.displayTz = e, this.timeAxis.setTimezoneOffset(e), this.crosshairHandler.setTimezoneOffset(e), this.crosshairTooltip.setTimezoneOffset(e), this.pinnedTooltip.setTimezone(e), this.sessionBreaks.setTimezone(e), this.engine.requestRender();
|
|
3010
3074
|
}
|
|
3011
3075
|
setSymbolInfo(e) {
|
|
3012
|
-
let t = e && this.symbolInfo?.symbol === e.symbol ?
|
|
3013
|
-
this.symbolInfo = e ?
|
|
3076
|
+
let t = e && this.symbolInfo?.symbol === e.symbol ? C(this.symbolInfo) : void 0;
|
|
3077
|
+
this.symbolInfo = e ? Wn({
|
|
3014
3078
|
...e,
|
|
3015
3079
|
sessions: e.sessions?.map((e) => ({ ...e }))
|
|
3016
3080
|
}, 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);
|
|
3017
3081
|
let n = (this.symbolInfo?.sessions ?? []).flatMap((e) => {
|
|
3018
|
-
let t =
|
|
3082
|
+
let t = S(e.start), n = S(e.end);
|
|
3019
3083
|
return t === null || n === null ? [] : [{
|
|
3020
3084
|
startMinute: t,
|
|
3021
3085
|
endMinute: n
|
|
3022
3086
|
}];
|
|
3023
|
-
}), i =
|
|
3087
|
+
}), i = C(this.symbolInfo);
|
|
3024
3088
|
this.sessionShading.replaceConfig(n.length > 0 && i && g(i) ? {
|
|
3025
3089
|
timeZone: i,
|
|
3026
3090
|
windows: n,
|
|
@@ -3035,11 +3099,11 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
3035
3099
|
if (!e || typeof e != "object") return;
|
|
3036
3100
|
let t = this.currentSymbol, n = (e) => !e || e.toUpperCase() === t.toUpperCase();
|
|
3037
3101
|
if (!n(e.symbol)) return;
|
|
3038
|
-
let r = this.symbolInfo && n(this.symbolInfo.symbol) ? this.symbolInfo : null, i =
|
|
3102
|
+
let r = this.symbolInfo && n(this.symbolInfo.symbol) ? this.symbolInfo : null, i = Wn({
|
|
3039
3103
|
...r,
|
|
3040
3104
|
...e,
|
|
3041
3105
|
symbol: e.symbol || r?.symbol || t
|
|
3042
|
-
},
|
|
3106
|
+
}, C(r));
|
|
3043
3107
|
r && JSON.stringify(i) === JSON.stringify(r) || (this.symbolInfoSeq++, this.setSymbolInfo(i));
|
|
3044
3108
|
}
|
|
3045
3109
|
resolveStreamSymbol(e, t) {
|
|
@@ -3069,7 +3133,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
3069
3133
|
return this.sessionShading.isVisible();
|
|
3070
3134
|
}
|
|
3071
3135
|
setSessionShadingConfig(e) {
|
|
3072
|
-
this.hostSessionHours =
|
|
3136
|
+
this.hostSessionHours = Et(this.hostSessionHours, e), this.sessionShading.replaceConfig(this.hostSessionHours), this.engine.requestRender(r.Background);
|
|
3073
3137
|
}
|
|
3074
3138
|
setTooltipVisible(e) {
|
|
3075
3139
|
e || this.crosshairTooltip.hide();
|
|
@@ -3088,11 +3152,11 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
3088
3152
|
return this.waitForGpu(null), e === "canvas" ? (this.applyRenderer(null), "canvas") : this.engine.getGpu() ? "webgl" : this.takeGpu(e, t, !0);
|
|
3089
3153
|
}
|
|
3090
3154
|
async takeGpu(e, t, n) {
|
|
3091
|
-
let { gpu: r, reason: i } = await
|
|
3092
|
-
return t !== this.rendererToken || this.disposed ? (r?.destroy(), this.getRenderer()) : i === "limit" ?
|
|
3155
|
+
let { gpu: r, reason: i } = await Tt(e);
|
|
3156
|
+
return t !== this.rendererToken || this.disposed ? (r?.destroy(), this.getRenderer()) : i === "limit" ? Ct() > 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());
|
|
3093
3157
|
}
|
|
3094
3158
|
waitForGpu(e) {
|
|
3095
|
-
this.stopWaitingForGpu?.(), this.stopWaitingForGpu = e ?
|
|
3159
|
+
this.stopWaitingForGpu?.(), this.stopWaitingForGpu = e ? Bt(e) : null;
|
|
3096
3160
|
}
|
|
3097
3161
|
getRenderer() {
|
|
3098
3162
|
return this.engine.getGpu() ? "webgl" : "canvas";
|
|
@@ -3114,23 +3178,23 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
3114
3178
|
this.engine.getGpu() && this.engine.renderNow();
|
|
3115
3179
|
}
|
|
3116
3180
|
screenshot(e) {
|
|
3117
|
-
this.features.screenshot && (this.freshFrame(),
|
|
3181
|
+
this.features.screenshot && (this.freshFrame(), k.download(this.container, e, this.themeManager.getTheme().background));
|
|
3118
3182
|
}
|
|
3119
3183
|
async copyScreenshot() {
|
|
3120
3184
|
if (!this.features.screenshot) return !1;
|
|
3121
3185
|
try {
|
|
3122
3186
|
this.freshFrame();
|
|
3123
|
-
let e = await
|
|
3187
|
+
let e = await k.toBlob(this.container, this.themeManager.getTheme().background), t = globalThis.ClipboardItem;
|
|
3124
3188
|
return !e || !navigator.clipboard?.write || !t ? !1 : (await navigator.clipboard.write([new t({ "image/png": e })]), !0);
|
|
3125
3189
|
} catch {
|
|
3126
3190
|
return !1;
|
|
3127
3191
|
}
|
|
3128
3192
|
}
|
|
3129
3193
|
screenshotDataURL() {
|
|
3130
|
-
return this.features.screenshot ? (this.freshFrame(),
|
|
3194
|
+
return this.features.screenshot ? (this.freshFrame(), k.toDataURL(this.container, this.themeManager.getTheme().background)) : null;
|
|
3131
3195
|
}
|
|
3132
3196
|
async screenshotBlob() {
|
|
3133
|
-
return this.features.screenshot ? (this.freshFrame(),
|
|
3197
|
+
return this.features.screenshot ? (this.freshFrame(), k.toBlob(this.container, this.themeManager.getTheme().background)) : null;
|
|
3134
3198
|
}
|
|
3135
3199
|
addAlert(e, t = "crossing", n, r = "price", i, a = {}) {
|
|
3136
3200
|
if (!this.features.alerts) return null;
|
|
@@ -3264,23 +3328,23 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
3264
3328
|
};
|
|
3265
3329
|
}
|
|
3266
3330
|
let { steps: n, startTime: r, hideHistory: i, revealMarks: a, ...o } = e ?? {}, s = this.series.inHoursShown(this.series.liveBars()), c = t > 0 && r === void 0 && i !== !1, l = o.startIndex;
|
|
3267
|
-
r !== void 0 && l === void 0 ? l =
|
|
3331
|
+
r !== void 0 && l === void 0 ? l = cr(s, r) : c && l !== void 0 && (l += t);
|
|
3268
3332
|
let u = c ? t : i && l !== void 0 && l > 0 ? Math.min(Math.floor(l), s.length - 1) : 0, d = u > 0 ? s.slice(u) : s;
|
|
3269
3333
|
l !== void 0 && (o.startIndex = l - u), this.replayOffset = u, this.replayRevealMarks = a !== !1;
|
|
3270
|
-
let f = n ?
|
|
3334
|
+
let f = n ? fr(n, d) : null;
|
|
3271
3335
|
this.replayStepsSeries = f, this.replayCoarse = d, this.options.autoScale = !0, this.replayRestarting = !0;
|
|
3272
3336
|
try {
|
|
3273
3337
|
this.replayManager.load(f ?? d);
|
|
3274
3338
|
} finally {
|
|
3275
3339
|
this.replayRestarting = !1;
|
|
3276
3340
|
}
|
|
3277
|
-
f && o.startIndex !== void 0 && (o.startIndex =
|
|
3341
|
+
f && o.startIndex !== void 0 && (o.startIndex = mr(f, d, o.startIndex)), this.replayBarUnsub?.();
|
|
3278
3342
|
let p = -1, m = -1, h = null, g = f ?? d;
|
|
3279
3343
|
this.replayBarUnsub = this.replayManager.on("bar", ({ index: e }) => {
|
|
3280
3344
|
let t = e, n = d[e];
|
|
3281
3345
|
if (f) {
|
|
3282
3346
|
let r = f[e];
|
|
3283
|
-
t =
|
|
3347
|
+
t = pr(d, r.time), h = h !== null && m === e - 1 && t === p - 1 && h ? gr(h, r) : hr(d[t], f, e), n = h;
|
|
3284
3348
|
}
|
|
3285
3349
|
m = e;
|
|
3286
3350
|
let r = t + 1, i = p > 0 && r >= p && this.series.length() === p, a = !(i && !this.replaySeeking) || this.autoScrollOnNewBar && this.viewport.isAtEnd();
|
|
@@ -3332,20 +3396,20 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
3332
3396
|
return;
|
|
3333
3397
|
}
|
|
3334
3398
|
if (i.time <= n.fedTime) return;
|
|
3335
|
-
let a = e.slice(
|
|
3399
|
+
let a = e.slice(lr(e, n.fedTime), t + 1);
|
|
3336
3400
|
n.fedTime = i.time;
|
|
3337
|
-
let o = Math.ceil(a.length /
|
|
3338
|
-
for (let e = 0; e < a.length; e += o) for (let [t, n] of
|
|
3401
|
+
let o = Math.ceil(a.length / sr);
|
|
3402
|
+
for (let e = 0; e < a.length; e += o) for (let [t, n] of ur(a.slice(e, e + o))) r.setMarkPrice(t, n);
|
|
3339
3403
|
this.tradingManager.setCurrentPrice(i.close);
|
|
3340
3404
|
}
|
|
3341
3405
|
getReplayBarIndex() {
|
|
3342
3406
|
if (!this.replaySession) return -1;
|
|
3343
3407
|
let { current: e } = this.replayManager.getProgress(), t = this.replayStepsSeries;
|
|
3344
|
-
return t && this.replayCoarse ?
|
|
3408
|
+
return t && this.replayCoarse ? pr(this.replayCoarse, t[e]?.time ?? -Infinity) : e;
|
|
3345
3409
|
}
|
|
3346
3410
|
replaySeekToBar(e) {
|
|
3347
3411
|
let t = this.replayStepsSeries;
|
|
3348
|
-
this.replaySeek(t && this.replayCoarse ?
|
|
3412
|
+
this.replaySeek(t && this.replayCoarse ? mr(t, this.replayCoarse, e) : e);
|
|
3349
3413
|
}
|
|
3350
3414
|
replayPause() {
|
|
3351
3415
|
this.replayManager.pause();
|
|
@@ -3377,10 +3441,10 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
3377
3441
|
data: this.getDisplayData()
|
|
3378
3442
|
}, r = n.chartRect, i = Infinity, a = -Infinity, o = Infinity, s = -Infinity;
|
|
3379
3443
|
for (let e of t.anchors) {
|
|
3380
|
-
let t =
|
|
3444
|
+
let t = Nt(e.time, n), r = Dt(e.price, n);
|
|
3381
3445
|
i = Math.min(i, t), a = Math.max(a, t), o = Math.min(o, r), s = Math.max(s, r);
|
|
3382
3446
|
}
|
|
3383
|
-
return
|
|
3447
|
+
return Xn.has(t.type) ? [i, a] = [r.x, r.x + r.width] : t.type === "horizontalRay" && (a = r.x + r.width), Zn.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 ? {
|
|
3384
3448
|
x: i,
|
|
3385
3449
|
y: o,
|
|
3386
3450
|
width: a - i,
|
|
@@ -3411,7 +3475,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
3411
3475
|
return this.replayManager.getProgress();
|
|
3412
3476
|
}
|
|
3413
3477
|
captureSnapshot() {
|
|
3414
|
-
return
|
|
3478
|
+
return w.capture({
|
|
3415
3479
|
getDrawings: () => this.getDrawings(),
|
|
3416
3480
|
getTheme: () => this.themeManager.getBaseTheme(),
|
|
3417
3481
|
getAlerts: () => this.getAlerts(),
|
|
@@ -3424,14 +3488,14 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
3424
3488
|
});
|
|
3425
3489
|
}
|
|
3426
3490
|
restoreIndicators(e, t) {
|
|
3427
|
-
let n =
|
|
3491
|
+
let n = $n(e), r = /* @__PURE__ */ new Map();
|
|
3428
3492
|
this.unrestoredIndicators = [];
|
|
3429
3493
|
let i = new Set(this.indicatorEngine.getAvailableIndicators().map((e) => e.id)), a = [], o = /* @__PURE__ */ new Set();
|
|
3430
3494
|
if (t) {
|
|
3431
3495
|
let e = new Map(n.map((e) => [e.instanceId, e])), t = this.getIndicatorSetup();
|
|
3432
3496
|
for (let n of t) {
|
|
3433
3497
|
let t = e.get(n.instanceId);
|
|
3434
|
-
t &&
|
|
3498
|
+
t && er(n, t) && o.add(n.instanceId);
|
|
3435
3499
|
}
|
|
3436
3500
|
for (let e of t) o.has(e.instanceId) || this.removeIndicator(e.instanceId);
|
|
3437
3501
|
for (let e of [...o]) this.indicatorEngine.getIndicatorConfig(e) || o.delete(e);
|
|
@@ -3493,7 +3557,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
3493
3557
|
let s = t.levels ?? null;
|
|
3494
3558
|
JSON.stringify(s) !== JSON.stringify(o?.levels ?? null) && this.setIndicatorLevels(e, s);
|
|
3495
3559
|
let c = t.intervals ?? null;
|
|
3496
|
-
JSON.stringify(c) !== JSON.stringify(o?.intervals ?? null) && this.setIndicatorIntervalsNow(e, c), this.setPaneStyleNow(e, t.paneStyle ?
|
|
3560
|
+
JSON.stringify(c) !== JSON.stringify(o?.intervals ?? null) && this.setIndicatorIntervalsNow(e, c), this.setPaneStyleNow(e, t.paneStyle ? re(t.paneStyle) : null);
|
|
3497
3561
|
}
|
|
3498
3562
|
restorePanes(e) {
|
|
3499
3563
|
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, {
|
|
@@ -3598,7 +3662,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
3598
3662
|
if (this.indicatorHistoryDepth > 0 || !this.features.drawingUndoRedo) return t();
|
|
3599
3663
|
let n = this.getIndicatorSetup(), r = this.withoutIndicatorHistory(t), i = this.getIndicatorSetup();
|
|
3600
3664
|
if (JSON.stringify(n) === JSON.stringify(i)) return r;
|
|
3601
|
-
let a = performance.now(), o = this.undoRedoManager.last(), s = e !== void 0 && o?.type === "indicators" && o.indicators?.subject === e && a - (o.indicators.at ?? 0) <
|
|
3665
|
+
let a = performance.now(), o = this.undoRedoManager.last(), s = e !== void 0 && o?.type === "indicators" && o.indicators?.subject === e && a - (o.indicators.at ?? 0) < qn && JSON.stringify(o.indicators.after) === JSON.stringify(n), c = {
|
|
3602
3666
|
type: "indicators",
|
|
3603
3667
|
before: null,
|
|
3604
3668
|
after: null
|
|
@@ -3626,12 +3690,12 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
3626
3690
|
}
|
|
3627
3691
|
saveState(e) {
|
|
3628
3692
|
if (!this.features.saveLoad) return null;
|
|
3629
|
-
let t = this.captureSnapshot(), n =
|
|
3630
|
-
return e &&
|
|
3693
|
+
let t = this.captureSnapshot(), n = w.serialize(t);
|
|
3694
|
+
return e && w.saveToStorage(e, t), n;
|
|
3631
3695
|
}
|
|
3632
3696
|
loadState(e) {
|
|
3633
3697
|
if (!this.features.saveLoad) return;
|
|
3634
|
-
let t =
|
|
3698
|
+
let t = w.deserialize(e);
|
|
3635
3699
|
this.chartTypeOptions = t.chartTypeOptions ?? {}, this.displayDataCache = null, t.chartType && this.setChartType(t.chartType), t.drawings && this.setDrawings(t.drawings), (t.theme === "dark" || t.theme === "light") && this.setTheme(t.theme), t.version >= 3 && this.themeManager.setUserOverrides(t.overrides ?? {}) && this.styleChanged("user");
|
|
3636
3700
|
let n = t.version >= 2 && this.features.indicators ? this.withoutIndicatorHistory(() => this.restoreIndicators(t.indicators, !1)) : /* @__PURE__ */ new Map();
|
|
3637
3701
|
if (this.undoRedoManager.clear(), t.alerts && this.features.alerts) {
|
|
@@ -3642,7 +3706,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
3642
3706
|
let t = e.indexOf(":"), r = t > 0 ? n.get(e.slice(0, t)) : void 0;
|
|
3643
3707
|
return r ? r + e.slice(t) : e;
|
|
3644
3708
|
}, r = t(e.channel), i = {
|
|
3645
|
-
...
|
|
3709
|
+
...kt(e),
|
|
3646
3710
|
...e.target ? { target: t(e.target) } : {}
|
|
3647
3711
|
};
|
|
3648
3712
|
if (!e.expired) {
|
|
@@ -3662,22 +3726,22 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
3662
3726
|
}
|
|
3663
3727
|
loadStateFromStorage(e) {
|
|
3664
3728
|
if (!this.features.saveLoad) return !1;
|
|
3665
|
-
let t =
|
|
3666
|
-
return t ? (this.loadState(
|
|
3729
|
+
let t = w.loadFromStorage(e);
|
|
3730
|
+
return t ? (this.loadState(w.serialize(t)), !0) : !1;
|
|
3667
3731
|
}
|
|
3668
3732
|
downloadState(e) {
|
|
3669
|
-
this.features.saveLoad &&
|
|
3733
|
+
this.features.saveLoad && w.downloadFile(this.captureSnapshot(), e);
|
|
3670
3734
|
}
|
|
3671
3735
|
async loadStateFromFile() {
|
|
3672
3736
|
if (!this.features.saveLoad) return;
|
|
3673
|
-
let e = await
|
|
3674
|
-
this.loadState(
|
|
3737
|
+
let e = await w.loadFromFile();
|
|
3738
|
+
this.loadState(w.serialize(e));
|
|
3675
3739
|
}
|
|
3676
3740
|
setLocale(e) {
|
|
3677
|
-
|
|
3741
|
+
ae(e), this.engine.requestRender();
|
|
3678
3742
|
}
|
|
3679
3743
|
setNumberLocale(e) {
|
|
3680
|
-
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.
|
|
3744
|
+
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.currentPriceLine.setLocale(e), this.updateViewportAndRender();
|
|
3681
3745
|
}
|
|
3682
3746
|
getNumberLocale() {
|
|
3683
3747
|
return this.numberLocale;
|
|
@@ -3730,11 +3794,11 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
3730
3794
|
this.viewport.resize(e.width, e.height), this.layoutManager.resize(e.width, e.height), this.updateViewportAndRender(n), this.eventBus.emit("resize", e);
|
|
3731
3795
|
}
|
|
3732
3796
|
destroy() {
|
|
3733
|
-
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.container.innerHTML = "";
|
|
3797
|
+
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 = "";
|
|
3734
3798
|
}
|
|
3735
3799
|
createChartRenderer(e) {
|
|
3736
3800
|
let t = nn(e, (e) => this.pluginManager.getChartType(e));
|
|
3737
|
-
return t instanceof
|
|
3801
|
+
return t instanceof Fe && t.setPriceText((e) => this.formatPrice(e)), t;
|
|
3738
3802
|
}
|
|
3739
3803
|
crosshairSeries() {
|
|
3740
3804
|
return this.isTimeAligned() ? this.series.bars() : this.getDisplayData();
|
|
@@ -3744,7 +3808,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
3744
3808
|
let e = this.series.bars();
|
|
3745
3809
|
if (e.length === 0) return e;
|
|
3746
3810
|
let t = rn(this.options.chartType, e, (e) => this.pluginManager.getChartType(e), this.chartTypeOptions);
|
|
3747
|
-
return this.chartRenderer instanceof
|
|
3811
|
+
return this.chartRenderer instanceof D && !this.pluginManager.getChartType(this.options.chartType) && this.chartRenderer.setBoxSize(en(e, this.chartTypeOptions)), this.displayDataCache = t, t;
|
|
3748
3812
|
}
|
|
3749
3813
|
recalcIndicatorsFrom(e, t) {
|
|
3750
3814
|
this.indicatorEngine.recalculateFrom(e, t), this.announceIndicatorUpdate(t);
|
|
@@ -3797,12 +3861,12 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
3797
3861
|
}
|
|
3798
3862
|
fitPriceScale(e, t) {
|
|
3799
3863
|
if (e.length === 0) return;
|
|
3800
|
-
let n = Math.max(0, t.visibleRange.from), r = Math.min(t.visibleRange.to, e.length - 1), i =
|
|
3864
|
+
let n = Math.max(0, t.visibleRange.from), r = Math.min(t.visibleRange.to, e.length - 1), i = or(or(f(e, n, r, 0), this.indicatorEngine.getOverlayPriceRange(n, r)), this.features.compareSymbols ? this.compareRenderer.getPriceRange(e, t) : null), a = this.features.volume && this.volumeRenderer.isVisible() && ar(e, n, r) ? this.volumeRenderer.getHeightRatio() + Kn : E;
|
|
3801
3865
|
this.viewport.setScaleMargins(this.viewport.isInvertScale() ? {
|
|
3802
3866
|
top: a,
|
|
3803
|
-
bottom:
|
|
3867
|
+
bottom: E
|
|
3804
3868
|
} : {
|
|
3805
|
-
top:
|
|
3869
|
+
top: E,
|
|
3806
3870
|
bottom: a
|
|
3807
3871
|
}), this.viewport.fitToPrices(i.min, i.max);
|
|
3808
3872
|
}
|
|
@@ -3819,7 +3883,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
3819
3883
|
fitLeftAxisWidth() {
|
|
3820
3884
|
let e = this.leftViewport;
|
|
3821
3885
|
if (!e) return !1;
|
|
3822
|
-
let t = this.themeManager.getTheme(), n =
|
|
3886
|
+
let t = this.themeManager.getTheme(), n = En({
|
|
3823
3887
|
min: e.priceRange.min,
|
|
3824
3888
|
max: e.priceRange.max,
|
|
3825
3889
|
lastPrice: null,
|
|
@@ -3828,12 +3892,12 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
3828
3892
|
fontFamily: t.font.family,
|
|
3829
3893
|
fontSizeSmall: t.font.sizeSmall,
|
|
3830
3894
|
measure: (e, t) => this.measureText(e, t)
|
|
3831
|
-
}), r =
|
|
3895
|
+
}), r = Dn(this.leftAxisWidth, n);
|
|
3832
3896
|
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);
|
|
3833
3897
|
}
|
|
3834
3898
|
fitPriceAxisWidth() {
|
|
3835
3899
|
if (!this.features.priceAxis) return !1;
|
|
3836
|
-
let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n =
|
|
3900
|
+
let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n = En({
|
|
3837
3901
|
min: e.min,
|
|
3838
3902
|
max: e.max,
|
|
3839
3903
|
lastPrice: this.currentPriceLine.getPrice(),
|
|
@@ -3844,13 +3908,17 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
3844
3908
|
fontFamily: t.font.family,
|
|
3845
3909
|
fontSizeSmall: t.font.sizeSmall,
|
|
3846
3910
|
measure: (e, t) => this.measureText(e, t)
|
|
3847
|
-
}), r =
|
|
3911
|
+
}), r = Dn(this.priceAxisWidth, n);
|
|
3848
3912
|
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);
|
|
3849
3913
|
}
|
|
3850
3914
|
measureText(e, t) {
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3915
|
+
let n = this.engine.layerManager.getLayer(r.Main)?.ctx;
|
|
3916
|
+
if (n?.canvas.isConnected) return this.labelWidths.get(e, t, () => tr(n, e, t));
|
|
3917
|
+
let i = n ?? this.detachedMeasureContext();
|
|
3918
|
+
return i ? tr(i, e, t) : e.length * 7;
|
|
3919
|
+
}
|
|
3920
|
+
detachedMeasureContext() {
|
|
3921
|
+
return this.measureCtx === void 0 && (this.measureCtx = typeof document < "u" ? document.createElement("canvas").getContext("2d") : null), this.measureCtx;
|
|
3854
3922
|
}
|
|
3855
3923
|
emitViewportEvents() {
|
|
3856
3924
|
let e = this.viewport.getState(), t = Math.max(0, Math.floor(e.visibleRange.from)), n = Math.max(t, Math.ceil(e.visibleRange.to));
|
|
@@ -3888,7 +3956,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
3888
3956
|
buildPanelRenderInfos() {
|
|
3889
3957
|
if (this.panelInfoCache) return this.panelInfoCache;
|
|
3890
3958
|
let e = this.getResolvedLayout(), t = this.viewport.getState(), { from: n, to: r } = t.visibleRange, i = e.panels.map((e) => {
|
|
3891
|
-
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) ?? { ...
|
|
3959
|
+
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) ?? { ...Bn }, o = {
|
|
3892
3960
|
x: e.rect.x,
|
|
3893
3961
|
y: e.rect.y + 20,
|
|
3894
3962
|
width: e.rect.width,
|
|
@@ -3970,7 +4038,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
3970
4038
|
});
|
|
3971
4039
|
}
|
|
3972
4040
|
drawOverlayPlugins(e, t) {
|
|
3973
|
-
let n =
|
|
4041
|
+
let n = W(this.pluginManager.getOverlays(), t);
|
|
3974
4042
|
if (n.length === 0) return;
|
|
3975
4043
|
let r = {
|
|
3976
4044
|
viewport: this.viewport.getState(),
|
|
@@ -3991,7 +4059,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
|
|
|
3991
4059
|
};
|
|
3992
4060
|
}
|
|
3993
4061
|
};
|
|
3994
|
-
function
|
|
4062
|
+
function $n(e) {
|
|
3995
4063
|
let t = new Map(e.map((e) => [e.instanceId, e])), n = [], r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = (e) => {
|
|
3996
4064
|
if (r.has(e.instanceId) || i.has(e.instanceId)) return;
|
|
3997
4065
|
i.add(e.instanceId);
|
|
@@ -4005,24 +4073,44 @@ function Zn(e) {
|
|
|
4005
4073
|
for (let t of e) a(t);
|
|
4006
4074
|
return n;
|
|
4007
4075
|
}
|
|
4008
|
-
function
|
|
4076
|
+
function er(e, t) {
|
|
4009
4077
|
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);
|
|
4010
4078
|
}
|
|
4011
|
-
function
|
|
4079
|
+
function tr(e, t, n) {
|
|
4080
|
+
let r = e.font;
|
|
4081
|
+
e.font = n;
|
|
4082
|
+
let i = e.measureText(t).width;
|
|
4083
|
+
return e.font = r, i;
|
|
4084
|
+
}
|
|
4085
|
+
var nr = 300;
|
|
4086
|
+
function rr(e) {
|
|
4087
|
+
let t = {}, n = e.family;
|
|
4088
|
+
typeof n == "string" && n.trim() !== "" && n.length <= nr && !/[;{}<>\\]|\/\*/.test(n) && (t.family = n);
|
|
4089
|
+
for (let n of [
|
|
4090
|
+
"sizeSmall",
|
|
4091
|
+
"sizeMedium",
|
|
4092
|
+
"sizeLarge"
|
|
4093
|
+
]) {
|
|
4094
|
+
let r = e[n];
|
|
4095
|
+
typeof r == "number" && Number.isFinite(r) && r > 0 && (t[n] = r);
|
|
4096
|
+
}
|
|
4097
|
+
return t;
|
|
4098
|
+
}
|
|
4099
|
+
function ir(e) {
|
|
4012
4100
|
let t = e.tagRadius;
|
|
4013
4101
|
return typeof t == "number" && Number.isFinite(t) && t >= 0 ? { tagRadius: Math.min(t, 999) } : {};
|
|
4014
4102
|
}
|
|
4015
|
-
function
|
|
4103
|
+
function ar(e, t, n) {
|
|
4016
4104
|
for (let r = t; r <= n; r++) if (e[r].volume > 0) return !0;
|
|
4017
4105
|
return !1;
|
|
4018
4106
|
}
|
|
4019
|
-
function
|
|
4107
|
+
function or(e, t) {
|
|
4020
4108
|
return e ? t ? {
|
|
4021
4109
|
min: Math.min(e.min, t.min),
|
|
4022
4110
|
max: Math.max(e.max, t.max)
|
|
4023
4111
|
} : e : t;
|
|
4024
4112
|
}
|
|
4025
|
-
function
|
|
4113
|
+
function q(e) {
|
|
4026
4114
|
return {
|
|
4027
4115
|
id: e.id,
|
|
4028
4116
|
price: e.price,
|
|
@@ -4037,8 +4125,8 @@ function K(e) {
|
|
|
4037
4125
|
bars: e.bars
|
|
4038
4126
|
};
|
|
4039
4127
|
}
|
|
4040
|
-
var
|
|
4041
|
-
function
|
|
4128
|
+
var sr = 500;
|
|
4129
|
+
function cr(e, t) {
|
|
4042
4130
|
let n = 0, r = e.length;
|
|
4043
4131
|
for (; n < r;) {
|
|
4044
4132
|
let i = n + r >> 1;
|
|
@@ -4046,7 +4134,7 @@ function rr(e, t) {
|
|
|
4046
4134
|
}
|
|
4047
4135
|
return n;
|
|
4048
4136
|
}
|
|
4049
|
-
function
|
|
4137
|
+
function lr(e, t) {
|
|
4050
4138
|
let n = 0, r = e.length;
|
|
4051
4139
|
for (; n < r;) {
|
|
4052
4140
|
let i = n + r >> 1;
|
|
@@ -4054,20 +4142,20 @@ function ir(e, t) {
|
|
|
4054
4142
|
}
|
|
4055
4143
|
return n;
|
|
4056
4144
|
}
|
|
4057
|
-
function
|
|
4145
|
+
function ur(e) {
|
|
4058
4146
|
let t = 0, n = 0;
|
|
4059
4147
|
for (let r = 1; r < e.length; r++) e[r].low < e[t].low && (t = r), e[r].high > e[n].high && (n = r);
|
|
4060
4148
|
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];
|
|
4061
4149
|
return [...a ? [r, i] : [i, r], [o.close, o.time]];
|
|
4062
4150
|
}
|
|
4063
|
-
function
|
|
4151
|
+
function dr(e) {
|
|
4064
4152
|
let t = 0;
|
|
4065
4153
|
for (let n = Math.max(1, e.length - 10); n < e.length; n++) t = Math.max(t, e[n].time - e[n - 1].time);
|
|
4066
4154
|
return t > 0 ? t : Infinity;
|
|
4067
4155
|
}
|
|
4068
|
-
function
|
|
4156
|
+
function fr(e, t) {
|
|
4069
4157
|
if (t.length === 0) return null;
|
|
4070
|
-
let n = t[t.length - 1].time +
|
|
4158
|
+
let n = t[t.length - 1].time + dr(t), r = e.filter((e) => ln(e) && e.time >= t[0].time && e.time < n).sort((e, t) => e.time - t.time), i = [];
|
|
4071
4159
|
for (let e of r) (i.length === 0 || i[i.length - 1].time !== e.time) && i.push(e);
|
|
4072
4160
|
if (i.length === 0) return null;
|
|
4073
4161
|
let a = t.findIndex((e) => e.time >= i[0].time);
|
|
@@ -4075,7 +4163,7 @@ function sr(e, t) {
|
|
|
4075
4163
|
let o = t.slice(0, a), s = i.filter((e) => e.time >= t[a].time);
|
|
4076
4164
|
return [...o, ...s];
|
|
4077
4165
|
}
|
|
4078
|
-
function
|
|
4166
|
+
function pr(e, t) {
|
|
4079
4167
|
let n = 0, r = e.length - 1;
|
|
4080
4168
|
for (; n < r;) {
|
|
4081
4169
|
let i = n + r + 1 >> 1;
|
|
@@ -4083,22 +4171,22 @@ function cr(e, t) {
|
|
|
4083
4171
|
}
|
|
4084
4172
|
return n;
|
|
4085
4173
|
}
|
|
4086
|
-
function
|
|
4174
|
+
function mr(e, t, n) {
|
|
4087
4175
|
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;
|
|
4088
4176
|
for (let t = 0; t < e.length && e[t].time < i; t++) a = t;
|
|
4089
4177
|
return Math.max(0, a);
|
|
4090
4178
|
}
|
|
4091
|
-
function
|
|
4179
|
+
function hr(e, t, n) {
|
|
4092
4180
|
let r = n;
|
|
4093
4181
|
for (; r > 0 && t[r - 1].time >= e.time;) r--;
|
|
4094
4182
|
let i = {
|
|
4095
4183
|
...t[r],
|
|
4096
4184
|
time: e.time
|
|
4097
4185
|
};
|
|
4098
|
-
for (let e = r + 1; e <= n; e++) i =
|
|
4186
|
+
for (let e = r + 1; e <= n; e++) i = gr(i, t[e]);
|
|
4099
4187
|
return i;
|
|
4100
4188
|
}
|
|
4101
|
-
function
|
|
4189
|
+
function gr(e, t) {
|
|
4102
4190
|
return {
|
|
4103
4191
|
time: e.time,
|
|
4104
4192
|
open: e.open,
|
|
@@ -4110,26 +4198,26 @@ function ur(e, t) {
|
|
|
4110
4198
|
}
|
|
4111
4199
|
//#endregion
|
|
4112
4200
|
//#region src/io/parseOHLCV.ts
|
|
4113
|
-
var
|
|
4201
|
+
var _r = [
|
|
4114
4202
|
"time",
|
|
4115
4203
|
"timestamp",
|
|
4116
4204
|
"date",
|
|
4117
4205
|
"datetime",
|
|
4118
4206
|
"t"
|
|
4119
|
-
],
|
|
4207
|
+
], vr = ["open", "o"], yr = ["high", "h"], br = ["low", "l"], xr = ["close", "c"], Sr = [
|
|
4120
4208
|
"volume",
|
|
4121
4209
|
"vol",
|
|
4122
4210
|
"v"
|
|
4123
4211
|
];
|
|
4124
|
-
function
|
|
4212
|
+
function Cr(e) {
|
|
4125
4213
|
let t = e.trim();
|
|
4126
|
-
return t ? t[0] === "[" || t[0] === "{" ?
|
|
4214
|
+
return t ? t[0] === "[" || t[0] === "{" ? wr(t) : Tr(t) : {
|
|
4127
4215
|
data: [],
|
|
4128
4216
|
rowCount: 0,
|
|
4129
4217
|
skipped: 0
|
|
4130
4218
|
};
|
|
4131
4219
|
}
|
|
4132
|
-
function
|
|
4220
|
+
function wr(e) {
|
|
4133
4221
|
let t;
|
|
4134
4222
|
try {
|
|
4135
4223
|
t = JSON.parse(e);
|
|
@@ -4139,19 +4227,19 @@ function vr(e) {
|
|
|
4139
4227
|
if (!Array.isArray(t)) throw Error("Expected a JSON array of OHLCV rows");
|
|
4140
4228
|
let n = [], r = 0;
|
|
4141
4229
|
for (let e of t) {
|
|
4142
|
-
let t = Array.isArray(e) ?
|
|
4230
|
+
let t = Array.isArray(e) ? Ar(e) : kr(e);
|
|
4143
4231
|
t ? n.push(t) : r++;
|
|
4144
4232
|
}
|
|
4145
|
-
return
|
|
4233
|
+
return jr(n, t.length, r);
|
|
4146
4234
|
}
|
|
4147
|
-
function
|
|
4235
|
+
function Tr(e) {
|
|
4148
4236
|
let t = e.split(/\r?\n/).filter((e) => e.trim().length > 0);
|
|
4149
4237
|
if (t.length === 0) return {
|
|
4150
4238
|
data: [],
|
|
4151
4239
|
rowCount: 0,
|
|
4152
4240
|
skipped: 0
|
|
4153
4241
|
};
|
|
4154
|
-
let n =
|
|
4242
|
+
let n = Er(t[0]), r = Dr(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? Or(r) : {
|
|
4155
4243
|
time: 0,
|
|
4156
4244
|
open: 1,
|
|
4157
4245
|
high: 2,
|
|
@@ -4162,7 +4250,7 @@ function yr(e) {
|
|
|
4162
4250
|
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");
|
|
4163
4251
|
let o = [], s = 0;
|
|
4164
4252
|
for (let e = +!!i; e < t.length; e++) {
|
|
4165
|
-
let r =
|
|
4253
|
+
let r = Dr(t[e], n), i = Y(r[a.time]), c = J(r[a.open]), l = J(r[a.high]), u = J(r[a.low]), d = J(r[a.close]), f = a.volume >= 0 ? Number(r[a.volume]) : 0;
|
|
4166
4254
|
if (i === null || ![
|
|
4167
4255
|
c,
|
|
4168
4256
|
l,
|
|
@@ -4181,9 +4269,9 @@ function yr(e) {
|
|
|
4181
4269
|
volume: Number.isFinite(f) ? f : 0
|
|
4182
4270
|
});
|
|
4183
4271
|
}
|
|
4184
|
-
return
|
|
4272
|
+
return jr(o, t.length - +!!i, s);
|
|
4185
4273
|
}
|
|
4186
|
-
function
|
|
4274
|
+
function Er(e) {
|
|
4187
4275
|
let t = {
|
|
4188
4276
|
",": 0,
|
|
4189
4277
|
";": 0,
|
|
@@ -4195,7 +4283,7 @@ function br(e) {
|
|
|
4195
4283
|
for (let [e, i] of Object.entries(t)) i > r && (n = e, r = i);
|
|
4196
4284
|
return n;
|
|
4197
4285
|
}
|
|
4198
|
-
function
|
|
4286
|
+
function Dr(e, t) {
|
|
4199
4287
|
let n = [], r = "", i = !1;
|
|
4200
4288
|
for (let a = 0; a < e.length; a++) {
|
|
4201
4289
|
let o = e[a];
|
|
@@ -4203,25 +4291,25 @@ function xr(e, t) {
|
|
|
4203
4291
|
}
|
|
4204
4292
|
return n.push(r), n;
|
|
4205
4293
|
}
|
|
4206
|
-
function
|
|
4294
|
+
function Or(e) {
|
|
4207
4295
|
let t = (t) => e.findIndex((e) => t.includes(e));
|
|
4208
4296
|
return {
|
|
4209
|
-
time: t(
|
|
4210
|
-
open: t(
|
|
4211
|
-
high: t(
|
|
4212
|
-
low: t(
|
|
4213
|
-
close: t(
|
|
4214
|
-
volume: t(
|
|
4297
|
+
time: t(_r),
|
|
4298
|
+
open: t(vr),
|
|
4299
|
+
high: t(yr),
|
|
4300
|
+
low: t(br),
|
|
4301
|
+
close: t(xr),
|
|
4302
|
+
volume: t(Sr)
|
|
4215
4303
|
};
|
|
4216
4304
|
}
|
|
4217
|
-
function
|
|
4305
|
+
function kr(e) {
|
|
4218
4306
|
let t = (t) => {
|
|
4219
4307
|
for (let n of t) {
|
|
4220
4308
|
if (e[n] !== void 0) return e[n];
|
|
4221
4309
|
let t = n.toUpperCase();
|
|
4222
4310
|
if (e[t] !== void 0) return e[t];
|
|
4223
4311
|
}
|
|
4224
|
-
}, n = Y(String(t(
|
|
4312
|
+
}, n = Y(String(t(_r) ?? "")), r = Number(t(vr)), i = Number(t(yr)), a = Number(t(br)), o = Number(t(xr)), s = Number(t(Sr) ?? 0);
|
|
4225
4313
|
return n === null || ![
|
|
4226
4314
|
r,
|
|
4227
4315
|
i,
|
|
@@ -4236,7 +4324,7 @@ function Cr(e) {
|
|
|
4236
4324
|
volume: Number.isFinite(s) ? s : 0
|
|
4237
4325
|
};
|
|
4238
4326
|
}
|
|
4239
|
-
function
|
|
4327
|
+
function Ar(e) {
|
|
4240
4328
|
if (e.length < 5) return null;
|
|
4241
4329
|
let t = Y(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;
|
|
4242
4330
|
return t === null || ![
|
|
@@ -4264,7 +4352,7 @@ function Y(e) {
|
|
|
4264
4352
|
let r = Date.parse(t);
|
|
4265
4353
|
return Number.isFinite(r) ? r : null;
|
|
4266
4354
|
}
|
|
4267
|
-
function
|
|
4355
|
+
function jr(e, t, n) {
|
|
4268
4356
|
e.sort((e, t) => e.time - t.time);
|
|
4269
4357
|
let r = [];
|
|
4270
4358
|
for (let t of e) r.length > 0 && r[r.length - 1].time === t.time ? r[r.length - 1] = t : r.push(t);
|
|
@@ -4276,7 +4364,7 @@ function Tr(e, t, n) {
|
|
|
4276
4364
|
}
|
|
4277
4365
|
//#endregion
|
|
4278
4366
|
//#region src/io/DragDropImporter.ts
|
|
4279
|
-
var
|
|
4367
|
+
var Mr = class {
|
|
4280
4368
|
host;
|
|
4281
4369
|
overlay = null;
|
|
4282
4370
|
callbacks;
|
|
@@ -4309,7 +4397,7 @@ var Er = class {
|
|
|
4309
4397
|
e.preventDefault(), this.depth = 0, this.hideOverlay();
|
|
4310
4398
|
let t = e.dataTransfer?.files?.[0];
|
|
4311
4399
|
if (t) try {
|
|
4312
|
-
let e =
|
|
4400
|
+
let e = Cr(await t.text());
|
|
4313
4401
|
if (e.data.length === 0) throw Error(`No valid OHLCV rows found in "${t.name}"`);
|
|
4314
4402
|
this.callbacks.onData(e.data, e, t);
|
|
4315
4403
|
} catch (e) {
|
|
@@ -4353,7 +4441,7 @@ function Z(e) {
|
|
|
4353
4441
|
};
|
|
4354
4442
|
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;
|
|
4355
4443
|
}
|
|
4356
|
-
var
|
|
4444
|
+
var Nr = (e, t) => t.updatedAt - e.updatedAt;
|
|
4357
4445
|
function Q(e) {
|
|
4358
4446
|
if (typeof e != "object" || !e) return null;
|
|
4359
4447
|
let t = e;
|
|
@@ -4366,17 +4454,17 @@ function Q(e) {
|
|
|
4366
4454
|
kind: typeof t.kind == "string" ? t.kind : void 0
|
|
4367
4455
|
});
|
|
4368
4456
|
}
|
|
4369
|
-
function
|
|
4457
|
+
function Pr(e) {
|
|
4370
4458
|
let t = Q(e), n = t ? e.content : void 0;
|
|
4371
4459
|
return t && typeof n == "string" ? {
|
|
4372
4460
|
...t,
|
|
4373
4461
|
content: n
|
|
4374
4462
|
} : null;
|
|
4375
4463
|
}
|
|
4376
|
-
function
|
|
4464
|
+
function Fr(e = []) {
|
|
4377
4465
|
let t = new Map(e.map((e) => [e.id, { ...e }]));
|
|
4378
4466
|
return {
|
|
4379
|
-
list: () => [...t.values()].map(Z).sort(
|
|
4467
|
+
list: () => [...t.values()].map(Z).sort(Nr),
|
|
4380
4468
|
load: (e) => {
|
|
4381
4469
|
let n = t.get(e);
|
|
4382
4470
|
return n ? { ...n } : null;
|
|
@@ -4389,7 +4477,7 @@ function kr(e = []) {
|
|
|
4389
4477
|
}
|
|
4390
4478
|
};
|
|
4391
4479
|
}
|
|
4392
|
-
function
|
|
4480
|
+
function Ir(e = "tcw:layouts:") {
|
|
4393
4481
|
let t = `${e}index`, n = (t) => `${e}item:${t}`, r = () => {
|
|
4394
4482
|
let e;
|
|
4395
4483
|
try {
|
|
@@ -4400,7 +4488,7 @@ function Ar(e = "tcw:layouts:") {
|
|
|
4400
4488
|
return Array.isArray(e) ? e.map(Q).filter((e) => e !== null) : [];
|
|
4401
4489
|
}, i = (e) => localStorage.setItem(t, JSON.stringify(e));
|
|
4402
4490
|
return {
|
|
4403
|
-
list: () => r().sort(
|
|
4491
|
+
list: () => r().sort(Nr),
|
|
4404
4492
|
load: (e) => {
|
|
4405
4493
|
let t = r().find((t) => t.id === e), i = t ? localStorage.getItem(n(e)) : null;
|
|
4406
4494
|
return t && i !== null ? {
|
|
@@ -4418,14 +4506,14 @@ function Ar(e = "tcw:layouts:") {
|
|
|
4418
4506
|
}
|
|
4419
4507
|
//#endregion
|
|
4420
4508
|
//#region src/state/LayoutSession.ts
|
|
4421
|
-
var
|
|
4509
|
+
var Lr = 80;
|
|
4422
4510
|
function $(e) {
|
|
4423
4511
|
return e.replace(/\s+/g, " ").trim().slice(0, 80).trim() || null;
|
|
4424
4512
|
}
|
|
4425
|
-
function
|
|
4513
|
+
function Rr() {
|
|
4426
4514
|
return globalThis.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
4427
4515
|
}
|
|
4428
|
-
function
|
|
4516
|
+
function zr(e) {
|
|
4429
4517
|
let { id: t, name: n, symbol: r, timeframe: i, updatedAt: a, kind: o } = e;
|
|
4430
4518
|
return {
|
|
4431
4519
|
id: t,
|
|
@@ -4436,7 +4524,7 @@ function Nr(e) {
|
|
|
4436
4524
|
...o === void 0 ? {} : { kind: o }
|
|
4437
4525
|
};
|
|
4438
4526
|
}
|
|
4439
|
-
var
|
|
4527
|
+
var Br = class {
|
|
4440
4528
|
currentLayout = null;
|
|
4441
4529
|
savedContent = null;
|
|
4442
4530
|
dirty = !1;
|
|
@@ -4452,7 +4540,7 @@ var Pr = class {
|
|
|
4452
4540
|
now;
|
|
4453
4541
|
newId;
|
|
4454
4542
|
constructor(e, t, n = {}) {
|
|
4455
|
-
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 ??
|
|
4543
|
+
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 ?? Rr;
|
|
4456
4544
|
}
|
|
4457
4545
|
current() {
|
|
4458
4546
|
return this.currentLayout;
|
|
@@ -4482,7 +4570,7 @@ var Pr = class {
|
|
|
4482
4570
|
}
|
|
4483
4571
|
open(e) {
|
|
4484
4572
|
return this.queue(async () => {
|
|
4485
|
-
let t =
|
|
4573
|
+
let t = Pr(await this.storage.load(e));
|
|
4486
4574
|
if (!t || t.id !== e || (t.kind ?? "chart") !== this.kind || this.destroyed) return !1;
|
|
4487
4575
|
this.cancelTimer(), this.applying++;
|
|
4488
4576
|
try {
|
|
@@ -4492,13 +4580,13 @@ var Pr = class {
|
|
|
4492
4580
|
} finally {
|
|
4493
4581
|
this.applying--;
|
|
4494
4582
|
}
|
|
4495
|
-
return this.cancelTimer(), this.currentLayout =
|
|
4583
|
+
return this.cancelTimer(), this.currentLayout = zr(t), this.savedContent = this.host.capture().content, this.dirty = !1, this.notify(), !0;
|
|
4496
4584
|
});
|
|
4497
4585
|
}
|
|
4498
4586
|
rename(e, t) {
|
|
4499
4587
|
let n = $(t);
|
|
4500
4588
|
return n ? this.queue(async () => {
|
|
4501
|
-
let t =
|
|
4589
|
+
let t = Pr(await this.storage.load(e));
|
|
4502
4590
|
!t || t.id !== e || (await this.storage.save({
|
|
4503
4591
|
...t,
|
|
4504
4592
|
name: n
|
|
@@ -4576,7 +4664,7 @@ var Pr = class {
|
|
|
4576
4664
|
content: n.content
|
|
4577
4665
|
};
|
|
4578
4666
|
await this.storage.save(r);
|
|
4579
|
-
let i =
|
|
4667
|
+
let i = zr(r);
|
|
4580
4668
|
return this.currentLayout = i, this.savedContent = n.content, this.dirty = !1, this.notify(), i;
|
|
4581
4669
|
}
|
|
4582
4670
|
forget() {
|
|
@@ -4597,6 +4685,6 @@ var Pr = class {
|
|
|
4597
4685
|
}
|
|
4598
4686
|
};
|
|
4599
4687
|
//#endregion
|
|
4600
|
-
export { V as C, dn as S,
|
|
4688
|
+
export { V as C, dn as S, L as T, W as _, Fr as a, gn as b, Qn as c, In as d, Fn as f, jn as g, Nn as h, Ir as i, Hn as l, Mn as m, Lr as n, Mr as o, Pn as p, $ as r, Cr as s, Br as t, Vn as u, G as v, z as w, pn as x, xn as y };
|
|
4601
4689
|
|
|
4602
|
-
//# sourceMappingURL=LayoutSession-
|
|
4690
|
+
//# sourceMappingURL=LayoutSession-Qkx1huV-.js.map
|