@tradecanvas/chart 1.68.0 → 1.69.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/Chart.d.ts +5 -1
- package/dist/Chart.d.ts.map +1 -1
- package/dist/HistoryPager.d.ts.map +1 -1
- package/dist/LayoutSession-BWC7O5R9.cjs +2 -0
- package/dist/LayoutSession-BWC7O5R9.cjs.map +1 -0
- package/dist/{LayoutSession-uM_94Qwk.js → LayoutSession-CoCMrrbh.js} +331 -323
- package/dist/LayoutSession-CoCMrrbh.js.map +1 -0
- package/dist/grid/ChartGrid.d.ts +5 -5
- package/dist/grid/ChartGrid.d.ts.map +1 -1
- 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 +69 -69
- package/dist/index.js.map +1 -1
- package/dist/widget/ChartWidget.d.ts +1 -1
- package/dist/widget/ChartWidget.d.ts.map +1 -1
- package/dist/widget/ChartWidgetGrid.d.ts +2 -2
- package/dist/widget/ChartWidgetGrid.d.ts.map +1 -1
- package/dist/widget/index.cjs +22 -22
- package/dist/widget/index.cjs.map +1 -1
- package/dist/widget/index.js +1774 -1761
- package/dist/widget/index.js.map +1 -1
- package/dist/widget/types.d.ts +8 -1
- package/dist/widget/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/LayoutSession-BW_2uPzn.cjs +0 -2
- package/dist/LayoutSession-BW_2uPzn.cjs.map +0 -1
- package/dist/LayoutSession-uM_94Qwk.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { DARK_THEME as e, DEFAULT_PANEL_HEIGHT as t, LIGHT_THEME as n, LayerType as r, MIN_PANEL_HEIGHT as i, PHI as a, PRICE_AXIS_WIDTH as o, TIME_AXIS_HEIGHT as s, autoPricePrecision as c, barDateZone as l, barTimeUnit as u, barsAreDaily as d, chartStyleValue as f, computePriceLimits as p, computePriceRange as m, createMarketTheme as h, formatPrice as g, fractionTick as _, indicatorSource as v, isValidTimeZone as y, mergeBar as ee, niceNumber as te, normalizeBarTime as b, parseIndicatorSource as x, priceFormatterFor as ne, priceStepAt as re, readChartStyleOverrides as ie, readChartTypeOptions as ae, readIndicatorPlotStyles as oe, readPaneStyle as se, resolveChartTheme as ce, sessionMinute as S, setLocale as le, stepDecimals as ue, symbolTimeZone as C, tickBarCount as de, timeframeToMs as w, zonedDateFormatter as fe } from "@tradecanvas/commons";
|
|
2
|
-
import { AlertDragHandler as pe, AlertManager as me, Animator as he, AreaRenderer as ge, AxisDragHandler as _e, BarCountdown as ve, BarRenderer as ye, BaselineRenderer as be, CandlestickRenderer as xe, ChartLegend as Se, ChartStateManager as T, CompareRenderer as Ce, CompareSymbolIndicator as we, CompareSymbolPaneIndicator as Te, CorrelationCoefficientIndicator as Ee, CorrelationLogIndicator as De, CrosshairHandler as Oe, CrosshairTooltip as ke, CurrentPriceLine as Ae, DEFAULT_SESSION_HOURS as je, DataExporter as E, DepthHeatmapRenderer as Me, DrawingManager as Ne, DrawingRenderer as Pe, EquivolumeRenderer as Fe, EventBus as Ie, GridRenderer as Le, HLCAreaRenderer as Re, HiLoRenderer as ze, HollowCandleRenderer as Be, IndicatorEngine as Ve, InteractionManager as He, KagiRenderer as Ue, KeyboardHandler as We, LineRenderer as Ge, LineWithMarkersRenderer as Ke, MarketProfileRenderer as qe, MeasureOverlay as Je, PRICE_AXIS_ADD_STRIP as Ye, PRICE_SCALE_MARGIN as D, PanHandler as Xe, PaneResizeHandler as Ze, PeriodLevelsRenderer as Qe, PinnedTooltip as $e, PivotMarkersRenderer as et, PointAndFigureRenderer as tt, PriceAxis as nt, PriceAxisAddButton as rt, PriceLines as it, RenderEngine as at, RenkoRenderer as ot, ReplayManager as st, ResamplingAdapter as ct, ReshapeMemo as lt, SYMBOL_INDICATOR_IDS as O, SYMBOL_ZONE_WAIT_MS as ut, Screenshot as k, SelectionBoxOverlay as dt, SessionBreaks as ft, SessionShading as pt, SignalMarkerManager as mt, SpreadIndicator as ht, StepLineRenderer as gt, StreamManager as _t, SymbolSeriesStore as vt, TimeAxis as yt, TradeZoneManager as bt, TradingManager as xt, TradingRenderer as St, UndoRedoManager as Ct, Viewport as wt, VolumeCandleRenderer as Tt, VolumeProfileRenderer as Et, VolumeRenderer as Dt, Watermark as Ot, ZoomHandler as kt, axisTimes as A, barTimeStepMs as At, findDominantSwing as jt, gpuContextsLeft as Mt, isPriceLevelAlert as Nt, isRegularSession as Pt, loadWebGL as Ft, mergeSessionHours as It, pointAndFigureColumns as Lt, rangePresetStart as Rt, readAlertOptions as zt, registerBuiltInDrawingTools as Bt, registerBuiltInIndicators as Vt, servesTimeframe as j, sourceParam as M, timestampToBarIndex as N, toHeikinAshi as
|
|
2
|
+
import { AlertDragHandler as pe, AlertManager as me, Animator as he, AreaRenderer as ge, AxisDragHandler as _e, BarCountdown as ve, BarRenderer as ye, BaselineRenderer as be, CandlestickRenderer as xe, ChartLegend as Se, ChartStateManager as T, CompareRenderer as Ce, CompareSymbolIndicator as we, CompareSymbolPaneIndicator as Te, CorrelationCoefficientIndicator as Ee, CorrelationLogIndicator as De, CrosshairHandler as Oe, CrosshairTooltip as ke, CurrentPriceLine as Ae, DEFAULT_SESSION_HOURS as je, DataExporter as E, DepthHeatmapRenderer as Me, DrawingManager as Ne, DrawingRenderer as Pe, EquivolumeRenderer as Fe, EventBus as Ie, GridRenderer as Le, HLCAreaRenderer as Re, HiLoRenderer as ze, HollowCandleRenderer as Be, IndicatorEngine as Ve, InteractionManager as He, KagiRenderer as Ue, KeyboardHandler as We, LineRenderer as Ge, LineWithMarkersRenderer as Ke, MarketProfileRenderer as qe, MeasureOverlay as Je, PRICE_AXIS_ADD_STRIP as Ye, PRICE_SCALE_MARGIN as D, PanHandler as Xe, PaneResizeHandler as Ze, PeriodLevelsRenderer as Qe, PinnedTooltip as $e, PivotMarkersRenderer as et, PointAndFigureRenderer as tt, PriceAxis as nt, PriceAxisAddButton as rt, PriceLines as it, RenderEngine as at, RenkoRenderer as ot, ReplayManager as st, ResamplingAdapter as ct, ReshapeMemo as lt, SYMBOL_INDICATOR_IDS as O, SYMBOL_ZONE_WAIT_MS as ut, Screenshot as k, SelectionBoxOverlay as dt, SessionBreaks as ft, SessionShading as pt, SignalMarkerManager as mt, SpreadIndicator as ht, StepLineRenderer as gt, StreamManager as _t, SymbolSeriesStore as vt, TimeAxis as yt, TradeZoneManager as bt, TradingManager as xt, TradingRenderer as St, UndoRedoManager as Ct, Viewport as wt, VolumeCandleRenderer as Tt, VolumeProfileRenderer as Et, VolumeRenderer as Dt, Watermark as Ot, ZoomHandler as kt, axisTimes as A, barTimeStepMs as At, findDominantSwing as jt, gpuContextsLeft as Mt, isPriceLevelAlert as Nt, isRegularSession as Pt, loadWebGL as Ft, mergeSessionHours as It, pointAndFigureColumns as Lt, rangePresetStart as Rt, readAlertOptions as zt, registerBuiltInDrawingTools as Bt, registerBuiltInIndicators as Vt, servesTimeframe as j, sourceParam as M, streamAdapterOf as Ht, timestampToBarIndex as N, toHeikinAshi as Ut, toKagi as Wt, toLineBreak as Gt, toRangeBars as Kt, toRenko as qt, whenGpuContextFree as Jt, withResampling as P, xToBarIndex as Yt, xToTime as F, yToPrice as Xt } from "@tradecanvas/core";
|
|
3
3
|
//#region src/regularHours.ts
|
|
4
|
-
var
|
|
5
|
-
function
|
|
4
|
+
var Zt = 864e5, Qt = 10;
|
|
5
|
+
function $t(e, t) {
|
|
6
6
|
let n = C(e);
|
|
7
7
|
if (!n || !y(n) || t.length < 2) return null;
|
|
8
8
|
let r = (e?.sessions ?? []).flatMap((e) => {
|
|
@@ -14,11 +14,11 @@ function Qt(e, t) {
|
|
|
14
14
|
});
|
|
15
15
|
if (r.length === 0) return null;
|
|
16
16
|
let i = u(t), a = Infinity;
|
|
17
|
-
for (let e = Math.max(1, t.length -
|
|
17
|
+
for (let e = Math.max(1, t.length - Qt); 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 < Zt)) return null;
|
|
22
22
|
let o = {
|
|
23
23
|
timeZone: n,
|
|
24
24
|
windows: r,
|
|
@@ -29,19 +29,19 @@ function Qt(e, t) {
|
|
|
29
29
|
}
|
|
30
30
|
//#endregion
|
|
31
31
|
//#region src/chartA11y.ts
|
|
32
|
-
var
|
|
32
|
+
var en = {
|
|
33
33
|
role: "chart",
|
|
34
34
|
summary: "{what}. Last price {close}.",
|
|
35
35
|
empty: "Chart, no data.",
|
|
36
36
|
view: "Showing {count} bars, {from} to {to}. High {high}, low {low}.",
|
|
37
37
|
bar: "{time}: open {open}, high {high}, low {low}, close {close}, volume {volume}.",
|
|
38
38
|
keys: "Arrow keys scroll and zoom, Home and End go to the start and the end. Comma and period read the bars one at a time."
|
|
39
|
-
}, I = (e, t) => e.replace(/\{(\w+)\}/g, (e, n) => n in t ? String(t[n]) : e),
|
|
39
|
+
}, I = (e, t) => e.replace(/\{(\w+)\}/g, (e, n) => n in t ? String(t[n]) : e), tn = [
|
|
40
40
|
"role",
|
|
41
41
|
"aria-roledescription",
|
|
42
42
|
"aria-label",
|
|
43
43
|
"aria-describedby"
|
|
44
|
-
],
|
|
44
|
+
], nn = 400, rn = 1e3, an = class {
|
|
45
45
|
live;
|
|
46
46
|
help;
|
|
47
47
|
labels;
|
|
@@ -55,20 +55,20 @@ var $t = {
|
|
|
55
55
|
};
|
|
56
56
|
constructor(e, t, n = {}) {
|
|
57
57
|
this.container = e, this.source = t, this.labels = {
|
|
58
|
-
|
|
58
|
+
...en,
|
|
59
59
|
...n
|
|
60
60
|
};
|
|
61
|
-
for (let t of
|
|
62
|
-
e.setAttribute("role", "application"), this.help =
|
|
61
|
+
for (let t of tn) this.before.set(t, e.getAttribute(t));
|
|
62
|
+
e.setAttribute("role", "application"), this.help = on("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 = on("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
|
+
...en,
|
|
67
67
|
...e
|
|
68
68
|
}, this.applyLabels();
|
|
69
69
|
}
|
|
70
70
|
refresh(e = !1) {
|
|
71
|
-
let t =
|
|
71
|
+
let t = rn - (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 $t = {
|
|
|
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
|
+
}, nn);
|
|
84
84
|
}
|
|
85
85
|
readBar(e) {
|
|
86
86
|
let t = this.source.bars();
|
|
@@ -99,7 +99,7 @@ var $t = {
|
|
|
99
99
|
high: a(i.high),
|
|
100
100
|
low: a(i.low),
|
|
101
101
|
close: a(i.close),
|
|
102
|
-
volume:
|
|
102
|
+
volume: sn(i.volume ?? 0)
|
|
103
103
|
}));
|
|
104
104
|
}
|
|
105
105
|
destroy() {
|
|
@@ -140,7 +140,7 @@ var $t = {
|
|
|
140
140
|
this.live.textContent = e;
|
|
141
141
|
}
|
|
142
142
|
};
|
|
143
|
-
function
|
|
143
|
+
function on(e, t) {
|
|
144
144
|
let n = document.createElement(e);
|
|
145
145
|
return n.className = t, Object.assign(n.style, {
|
|
146
146
|
position: "absolute",
|
|
@@ -154,17 +154,17 @@ function an(e, t) {
|
|
|
154
154
|
border: "0"
|
|
155
155
|
}), n;
|
|
156
156
|
}
|
|
157
|
-
function
|
|
157
|
+
function sn(e) {
|
|
158
158
|
return Number.isInteger(e) ? String(e) : e.toFixed(2);
|
|
159
159
|
}
|
|
160
160
|
//#endregion
|
|
161
161
|
//#region src/indicatorLabel.ts
|
|
162
|
-
var
|
|
162
|
+
var cn = 3, ln = {
|
|
163
163
|
stochrsi: 4,
|
|
164
164
|
ichimoku: 4
|
|
165
165
|
};
|
|
166
|
-
function
|
|
167
|
-
let i = Object.keys(n || t).map((e) => t[e]).filter((e) => typeof e == "number" && Number.isFinite(e)).slice(0,
|
|
166
|
+
function un(e, t, n, r) {
|
|
167
|
+
let i = Object.keys(n || t).map((e) => t[e]).filter((e) => typeof e == "number" && Number.isFinite(e)).slice(0, ln[e] ?? cn).map((e) => String(Number(e.toFixed(4)))), a = typeof t.symbol == "string" && t.symbol ? [t.symbol] : [];
|
|
168
168
|
return [
|
|
169
169
|
e === "spread" && t.mode === "ratio" ? "Ratio" : r ?? e.toUpperCase(),
|
|
170
170
|
...a,
|
|
@@ -173,7 +173,7 @@ function ln(e, t, n, r) {
|
|
|
173
173
|
}
|
|
174
174
|
//#endregion
|
|
175
175
|
//#region src/charts/ChartTypeStrategy.ts
|
|
176
|
-
function
|
|
176
|
+
function dn(e) {
|
|
177
177
|
switch (e) {
|
|
178
178
|
case "candlestick":
|
|
179
179
|
case "heikinAshi":
|
|
@@ -196,29 +196,29 @@ function un(e) {
|
|
|
196
196
|
default: return new xe();
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
|
-
function
|
|
199
|
+
function fn(e, t, n = {}, r, i) {
|
|
200
200
|
if (t.length === 0) return t;
|
|
201
201
|
switch (e) {
|
|
202
|
-
case "heikinAshi": return
|
|
202
|
+
case "heikinAshi": return Ut(t);
|
|
203
203
|
case "renko": {
|
|
204
204
|
let e = n.renko?.boxSize;
|
|
205
|
-
return typeof e == "number" ?
|
|
205
|
+
return typeof e == "number" ? qt(t, { brickSize: e }, i) : qt(t, {
|
|
206
206
|
brickSize: 0,
|
|
207
207
|
useATR: !0,
|
|
208
208
|
atrPeriod: n.renko?.atrPeriod ?? 14
|
|
209
209
|
}, i);
|
|
210
210
|
}
|
|
211
|
-
case "lineBreak": return
|
|
212
|
-
case "kagi": return
|
|
213
|
-
case "pointAndFigure": return
|
|
214
|
-
case "rangeBars": return
|
|
215
|
-
rangeSize:
|
|
211
|
+
case "lineBreak": return Gt(t, n.lineBreak?.lines ?? 3);
|
|
212
|
+
case "kagi": return Wt(t, n.kagi?.reversal ?? 4, n.kagi?.reversalType ?? "percent", i);
|
|
213
|
+
case "pointAndFigure": return mn(t, n, i).columns;
|
|
214
|
+
case "rangeBars": return Kt(t, {
|
|
215
|
+
rangeSize: wn(t, n, r),
|
|
216
216
|
includeForming: !0
|
|
217
217
|
}, i);
|
|
218
218
|
default: return t;
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
|
-
function
|
|
221
|
+
function pn(e) {
|
|
222
222
|
switch (e) {
|
|
223
223
|
case "heikinAshi":
|
|
224
224
|
case "renko":
|
|
@@ -230,71 +230,71 @@ function fn(e) {
|
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
232
|
function L(e) {
|
|
233
|
-
return e !== "heikinAshi" &&
|
|
233
|
+
return e !== "heikinAshi" && pn(e);
|
|
234
234
|
}
|
|
235
|
-
function
|
|
236
|
-
return Lt(e,
|
|
235
|
+
function mn(e, t = {}, n) {
|
|
236
|
+
return Lt(e, _n(e, t), t.pointAndFigure?.reversal ?? 3, n);
|
|
237
237
|
}
|
|
238
|
-
var
|
|
239
|
-
function
|
|
238
|
+
var hn = 50, gn = .01;
|
|
239
|
+
function _n(e, t = {}) {
|
|
240
240
|
let n = t.pointAndFigure?.boxSize;
|
|
241
241
|
if (typeof n == "number") return n;
|
|
242
|
-
let r =
|
|
243
|
-
return r > 0 ?
|
|
242
|
+
let r = vn(e, e.length > 1 ? e.length - 1 : e.length);
|
|
243
|
+
return r > 0 ? Cn(te(r / hn, !0)) : Math.abs(e[e.length - 1]?.close ?? 0) * gn || 1;
|
|
244
244
|
}
|
|
245
|
-
function
|
|
245
|
+
function vn(e, t) {
|
|
246
246
|
let n = -Infinity, r = Infinity;
|
|
247
247
|
for (let i = 0; i < t; i++) e[i].high > n && (n = e[i].high), e[i].low < r && (r = e[i].low);
|
|
248
248
|
let i = n - r;
|
|
249
249
|
return Number.isFinite(i) ? i : 0;
|
|
250
250
|
}
|
|
251
|
-
var
|
|
252
|
-
function
|
|
251
|
+
var yn = 100, bn = 3, xn = .01, Sn = 15, Cn = (e) => Number(e.toPrecision(Sn));
|
|
252
|
+
function wn(e, t = {}, n) {
|
|
253
253
|
let r = t.rangeBars?.range;
|
|
254
254
|
if (typeof r == "number") return r;
|
|
255
|
-
let i = e.length >=
|
|
256
|
-
return
|
|
255
|
+
let i = e.length >= bn ? En(e) : 0, a = Math.abs(e[e.length - 1]?.close ?? 0);
|
|
256
|
+
return kn(Cn(te(i > 0 ? i : a * xn || 1, !0)), n);
|
|
257
257
|
}
|
|
258
|
-
function
|
|
258
|
+
function Tn(e) {
|
|
259
259
|
let t = e.length - 1;
|
|
260
260
|
return {
|
|
261
|
-
from: Math.max(0, t -
|
|
261
|
+
from: Math.max(0, t - yn),
|
|
262
262
|
end: t
|
|
263
263
|
};
|
|
264
264
|
}
|
|
265
|
-
function
|
|
266
|
-
let { from: t, end: n } =
|
|
265
|
+
function En(e) {
|
|
266
|
+
let { from: t, end: n } = Tn(e), r = 0;
|
|
267
267
|
for (let i = t; i < n; i++) {
|
|
268
268
|
let { high: t, low: n } = e[i], a = i > 0 ? e[i - 1].close : n;
|
|
269
269
|
r += Math.max(t - n, Math.abs(t - a), Math.abs(n - a));
|
|
270
270
|
}
|
|
271
271
|
return n > t ? r / (n - t) : 0;
|
|
272
272
|
}
|
|
273
|
-
function
|
|
274
|
-
let { from: n, end: r } =
|
|
273
|
+
function Dn(e, t) {
|
|
274
|
+
let { from: n, end: r } = Tn(e);
|
|
275
275
|
if (r <= n) return t(e[e.length - 1]?.close ?? 0);
|
|
276
276
|
let i = -Infinity, a = Infinity;
|
|
277
277
|
for (let t = n; t < r; t++) i = Math.max(i, e[t].high), a = Math.min(a, e[t].low);
|
|
278
|
-
return
|
|
279
|
-
}
|
|
280
|
-
function Dn(e, t) {
|
|
281
|
-
return e === void 0 ? t : t === void 0 ? e : Math.max(e, t);
|
|
278
|
+
return On(t(i), t(a));
|
|
282
279
|
}
|
|
283
280
|
function On(e, t) {
|
|
284
|
-
return
|
|
281
|
+
return e === void 0 ? t : t === void 0 ? e : Math.max(e, t);
|
|
285
282
|
}
|
|
286
283
|
function kn(e, t) {
|
|
284
|
+
return t === void 0 || !(t > 0) ? e : Cn(Math.max(1, Math.round(e / t)) * t);
|
|
285
|
+
}
|
|
286
|
+
function An(e, t) {
|
|
287
287
|
let n = t?.(e);
|
|
288
|
-
return n ? n.createRenderer() :
|
|
288
|
+
return n ? n.createRenderer() : dn(e);
|
|
289
289
|
}
|
|
290
|
-
function
|
|
290
|
+
function jn(e, t, n, r, i, a) {
|
|
291
291
|
if (t.length === 0) return t;
|
|
292
292
|
let o = n?.(e);
|
|
293
|
-
return o?.transform ? o.transform(t) :
|
|
293
|
+
return o?.transform ? o.transform(t) : fn(e, t, r, i, a);
|
|
294
294
|
}
|
|
295
295
|
//#endregion
|
|
296
296
|
//#region src/state/AutoSaveScheduler.ts
|
|
297
|
-
var
|
|
297
|
+
var Mn = class {
|
|
298
298
|
timer = null;
|
|
299
299
|
delayMs = 0;
|
|
300
300
|
key = null;
|
|
@@ -329,7 +329,7 @@ function R(e) {
|
|
|
329
329
|
let { open: t, high: n, low: r, close: i } = e;
|
|
330
330
|
return !(!isFinite(t) || !isFinite(n) || !isFinite(r) || !isFinite(i) || t < 0 || n < 0 || r < 0 || i < 0 || n < r || e.volume !== void 0 && (!isFinite(e.volume) || e.volume < 0));
|
|
331
331
|
}
|
|
332
|
-
function
|
|
332
|
+
function Nn(e) {
|
|
333
333
|
return e.volume !== void 0 && e.high >= e.open && e.high >= e.close && e.low <= e.open && e.low <= e.close;
|
|
334
334
|
}
|
|
335
335
|
function z(e) {
|
|
@@ -343,24 +343,24 @@ function z(e) {
|
|
|
343
343
|
function B(e, t) {
|
|
344
344
|
return e === t || e.time === t.time && e.open === t.open && e.high === t.high && e.low === t.low && e.close === t.close && e.volume === t.volume;
|
|
345
345
|
}
|
|
346
|
-
function
|
|
346
|
+
function Pn(e, t) {
|
|
347
347
|
for (let n = e.length - 1; n >= 0; n--) {
|
|
348
348
|
if (e[n].time === t) return n;
|
|
349
349
|
if (e[n].time < t) return -1;
|
|
350
350
|
}
|
|
351
351
|
return -1;
|
|
352
352
|
}
|
|
353
|
-
var
|
|
353
|
+
var Fn = {
|
|
354
354
|
index: -1,
|
|
355
355
|
changed: !1
|
|
356
356
|
};
|
|
357
|
-
function
|
|
357
|
+
function In(e, t) {
|
|
358
358
|
if (e.length === 0) return t;
|
|
359
359
|
let n = b(t);
|
|
360
360
|
return u(e) === 1 ? n : n / 1e3;
|
|
361
361
|
}
|
|
362
|
-
function
|
|
363
|
-
let n =
|
|
362
|
+
function Ln(e, t) {
|
|
363
|
+
let n = In(e, t.time);
|
|
364
364
|
return n === t.time ? t : {
|
|
365
365
|
...t,
|
|
366
366
|
time: n
|
|
@@ -369,7 +369,7 @@ function In(e, t) {
|
|
|
369
369
|
var V = class {
|
|
370
370
|
data = [];
|
|
371
371
|
withSeriesTime(e) {
|
|
372
|
-
return
|
|
372
|
+
return Ln(this.data, e);
|
|
373
373
|
}
|
|
374
374
|
getData() {
|
|
375
375
|
return this.data;
|
|
@@ -378,7 +378,7 @@ var V = class {
|
|
|
378
378
|
let t = [];
|
|
379
379
|
for (let n = 0; n < e.length; n++) {
|
|
380
380
|
let r = e[n];
|
|
381
|
-
R(r) && t.push(
|
|
381
|
+
R(r) && t.push(Nn(r) ? r : z(r));
|
|
382
382
|
}
|
|
383
383
|
this.data = t;
|
|
384
384
|
}
|
|
@@ -387,7 +387,7 @@ var V = class {
|
|
|
387
387
|
for (let r = 0; r < e.length; r++) {
|
|
388
388
|
if (!R(e[r])) continue;
|
|
389
389
|
let i = this.withSeriesTime(e[r]);
|
|
390
|
-
i.time >= t || n.push(
|
|
390
|
+
i.time >= t || n.push(Nn(i) ? i : z(i));
|
|
391
391
|
}
|
|
392
392
|
if (n.length === 0) return 0;
|
|
393
393
|
n.sort((e, t) => e.time - t.time);
|
|
@@ -408,9 +408,9 @@ var V = class {
|
|
|
408
408
|
this.data[this.data.length - 1] = t;
|
|
409
409
|
}
|
|
410
410
|
replaceBar(e) {
|
|
411
|
-
if (!R(e)) return
|
|
412
|
-
let t = this.withSeriesTime(e), n =
|
|
413
|
-
if (n < 0) return
|
|
411
|
+
if (!R(e)) return Fn;
|
|
412
|
+
let t = this.withSeriesTime(e), n = Pn(this.data, t.time);
|
|
413
|
+
if (n < 0) return Fn;
|
|
414
414
|
let r = z(t);
|
|
415
415
|
return B(this.data[n], r) ? {
|
|
416
416
|
index: n,
|
|
@@ -440,7 +440,7 @@ function U(e, t) {
|
|
|
440
440
|
let r = b(t.time), i = b(n.time);
|
|
441
441
|
return r > i ? "append" : r === i ? "update" : "stale";
|
|
442
442
|
}
|
|
443
|
-
function
|
|
443
|
+
function Rn(e) {
|
|
444
444
|
return [
|
|
445
445
|
e.time,
|
|
446
446
|
e.open,
|
|
@@ -449,7 +449,7 @@ function Ln(e) {
|
|
|
449
449
|
e.close
|
|
450
450
|
].every(Number.isFinite);
|
|
451
451
|
}
|
|
452
|
-
var
|
|
452
|
+
var zn = class {
|
|
453
453
|
shown = new V();
|
|
454
454
|
whole = null;
|
|
455
455
|
aside = null;
|
|
@@ -489,7 +489,7 @@ var Rn = class {
|
|
|
489
489
|
}
|
|
490
490
|
let t = null, n = e;
|
|
491
491
|
if (this.whole) {
|
|
492
|
-
let r = this.whole[0]?.time, i = /* @__PURE__ */ new Set(), a = e.filter(
|
|
492
|
+
let r = this.whole[0]?.time, i = /* @__PURE__ */ new Set(), a = e.filter(Rn).map((e) => this.inSeriesUnit(e)).filter((e) => (r === void 0 || e.time < r) && !i.has(e.time) && i.add(e.time)).sort((e, t) => e.time - t.time);
|
|
493
493
|
this.whole = [...a, ...this.whole];
|
|
494
494
|
let o = this.hoursFilter(this.whole);
|
|
495
495
|
t = a.length, n = o ? a.filter((e) => o(e.time)) : a;
|
|
@@ -501,8 +501,8 @@ var Rn = class {
|
|
|
501
501
|
};
|
|
502
502
|
}
|
|
503
503
|
mergeSnapshot(e) {
|
|
504
|
-
if (this.aside) return this.aside.setData(
|
|
505
|
-
let t =
|
|
504
|
+
if (this.aside) return this.aside.setData(Bn(this.aside.getData(), e) ?? e), this.onLiveChange({ kind: "series" }), !0;
|
|
505
|
+
let t = Bn(this.whole ?? this.shown.getData(), e);
|
|
506
506
|
return t ? (this.shown.setData(this.regularOnly(t)), !0) : !1;
|
|
507
507
|
}
|
|
508
508
|
refilter() {
|
|
@@ -559,7 +559,7 @@ var Rn = class {
|
|
|
559
559
|
mergeTick(e) {
|
|
560
560
|
if (this.aside) return this.aside.updateLastBarFromTick(e), this.wrote("aside", !1);
|
|
561
561
|
let t = this.whole ? this.hoursFilter(this.whole) : null;
|
|
562
|
-
if (t && this.whole && !t(
|
|
562
|
+
if (t && this.whole && !t(In(this.whole, e.time))) return this.wrote("hidden", !1);
|
|
563
563
|
let n = this.shown.getLength();
|
|
564
564
|
this.shown.updateLastBarFromTick(e);
|
|
565
565
|
let r = this.whole, i = this.shown.getData()[this.shown.getLength() - 1];
|
|
@@ -602,7 +602,7 @@ var Rn = class {
|
|
|
602
602
|
});
|
|
603
603
|
}
|
|
604
604
|
if (!R(e)) return H;
|
|
605
|
-
let t = this.inSeriesUnit(e), n = this.whole, r = n ?
|
|
605
|
+
let t = this.inSeriesUnit(e), n = this.whole, r = n ? Pn(n, t.time) : -1;
|
|
606
606
|
if (n) {
|
|
607
607
|
if (r < 0 || !R(n[r])) return H;
|
|
608
608
|
let e = this.hoursFilter(n);
|
|
@@ -636,7 +636,7 @@ var Rn = class {
|
|
|
636
636
|
this.shown.updateLastBar(e);
|
|
637
637
|
}
|
|
638
638
|
inSeriesUnit(e) {
|
|
639
|
-
return
|
|
639
|
+
return Ln(this.whole ?? this.shown.getData(), e);
|
|
640
640
|
}
|
|
641
641
|
replaceHidden(e, t, n) {
|
|
642
642
|
let r = z(n), i = !B(e[t], r);
|
|
@@ -673,14 +673,14 @@ var Rn = class {
|
|
|
673
673
|
return !r || r(e.time);
|
|
674
674
|
}
|
|
675
675
|
};
|
|
676
|
-
function
|
|
676
|
+
function Bn(e, t) {
|
|
677
677
|
let n = t[0]?.time, r = 0;
|
|
678
678
|
for (; n !== void 0 && r < e.length && e[r].time < n;) r++;
|
|
679
679
|
return r === 0 || r === e.length ? null : e.slice(0, r).concat(t);
|
|
680
680
|
}
|
|
681
681
|
//#endregion
|
|
682
682
|
//#region src/HistoryPager.ts
|
|
683
|
-
var
|
|
683
|
+
var Vn = 5e3, Hn = 6e4, Un = 500, Wn = class {
|
|
684
684
|
loader = null;
|
|
685
685
|
pageSize = 500;
|
|
686
686
|
loading = !1;
|
|
@@ -732,11 +732,14 @@ var Bn = 5e3, Vn = 6e4, Hn = 500, Un = class {
|
|
|
732
732
|
try {
|
|
733
733
|
r = await e(t, this.pageSize);
|
|
734
734
|
} catch (e) {
|
|
735
|
-
return n === this.seq ? (this.loading = !1,
|
|
735
|
+
return n === this.seq ? (this.loading = !1, e instanceof Error && e.name === "AbortError" ? (this.emit({
|
|
736
|
+
state: "loaded",
|
|
737
|
+
count: 0
|
|
738
|
+
}), 0) : (this.failures++, this.retryAt = this.now() + Math.min(Hn, Vn * 2 ** (this.failures - 1)), this.emit({
|
|
736
739
|
state: "error",
|
|
737
740
|
count: 0,
|
|
738
741
|
error: e instanceof Error ? e.message : String(e)
|
|
739
|
-
}), 0) : 0;
|
|
742
|
+
}), 0)) : 0;
|
|
740
743
|
}
|
|
741
744
|
if (n !== this.seq) return 0;
|
|
742
745
|
this.loading = !1, this.failures = 0, this.retryAt = 0;
|
|
@@ -765,10 +768,10 @@ var Bn = 5e3, Vn = 6e4, Hn = 500, Un = class {
|
|
|
765
768
|
};
|
|
766
769
|
//#endregion
|
|
767
770
|
//#region src/ThemeManager.ts
|
|
768
|
-
function
|
|
771
|
+
function Gn(e, t) {
|
|
769
772
|
return e.family === t.family && e.sizeSmall === t.sizeSmall && e.sizeMedium === t.sizeMedium && e.sizeLarge === t.sizeLarge;
|
|
770
773
|
}
|
|
771
|
-
var
|
|
774
|
+
var Kn = class t {
|
|
772
775
|
base;
|
|
773
776
|
shape = null;
|
|
774
777
|
font = null;
|
|
@@ -793,7 +796,7 @@ var Gn = class t {
|
|
|
793
796
|
return this.base;
|
|
794
797
|
}
|
|
795
798
|
setTheme(e) {
|
|
796
|
-
let n = t.read(e), r = this.font !== null &&
|
|
799
|
+
let n = t.read(e), r = this.font !== null && Gn(n.font, this.base.font);
|
|
797
800
|
this.base = n, r || (this.themeFont = n.font), this.shape && (this.base = {
|
|
798
801
|
...this.base,
|
|
799
802
|
shape: {
|
|
@@ -875,7 +878,7 @@ var Gn = class t {
|
|
|
875
878
|
};
|
|
876
879
|
//#endregion
|
|
877
880
|
//#region src/style/styleOptions.ts
|
|
878
|
-
function
|
|
881
|
+
function qn(e, t) {
|
|
879
882
|
return t ? {
|
|
880
883
|
...t.visible === void 0 ? {} : { [`crosshair.${e}.visible`]: t.visible },
|
|
881
884
|
...t.color === void 0 ? {} : { [`crosshair.${e}.color`]: t.color },
|
|
@@ -883,22 +886,22 @@ function Kn(e, t) {
|
|
|
883
886
|
...t.width === void 0 ? {} : { [`crosshair.${e}.width`]: t.width }
|
|
884
887
|
} : {};
|
|
885
888
|
}
|
|
886
|
-
function
|
|
889
|
+
function Jn(e) {
|
|
887
890
|
let { grid: t, crosshair: n } = e, r = n?.vLine?.labelBackground ?? n?.hLine?.labelBackground;
|
|
888
891
|
return {
|
|
889
892
|
...t?.hLineColor === void 0 ? {} : { "grid.horizontal.color": t.hLineColor },
|
|
890
893
|
...t?.hLineStyle === void 0 ? {} : { "grid.horizontal.style": t.hLineStyle },
|
|
891
894
|
...t?.vLineColor === void 0 ? {} : { "grid.vertical.color": t.vLineColor },
|
|
892
895
|
...t?.vLineStyle === void 0 ? {} : { "grid.vertical.style": t.vLineStyle },
|
|
893
|
-
...
|
|
894
|
-
...
|
|
896
|
+
...qn("horizontal", n?.hLine),
|
|
897
|
+
...qn("vertical", n?.vLine),
|
|
895
898
|
...r === void 0 ? {} : { "crosshair.labelBackground": r },
|
|
896
899
|
...e.overrides
|
|
897
900
|
};
|
|
898
901
|
}
|
|
899
902
|
//#endregion
|
|
900
903
|
//#region src/layout/LayoutManager.ts
|
|
901
|
-
var
|
|
904
|
+
var Yn = 200, Xn = 80, W = (e) => e.position === "top" || e.position === "bottom", Zn = class {
|
|
902
905
|
panels = [];
|
|
903
906
|
containerWidth = 0;
|
|
904
907
|
containerHeight = 0;
|
|
@@ -915,8 +918,8 @@ var Jn = 200, Yn = 80, W = (e) => e.position === "top" || e.position === "bottom
|
|
|
915
918
|
this.panels.push({
|
|
916
919
|
id: e,
|
|
917
920
|
position: n,
|
|
918
|
-
size: r ?? (a ?
|
|
919
|
-
minSize: a ?
|
|
921
|
+
size: r ?? (a ? Yn : t),
|
|
922
|
+
minSize: a ? Xn : i,
|
|
920
923
|
content: {
|
|
921
924
|
type: "indicator",
|
|
922
925
|
indicatorInstanceId: e
|
|
@@ -985,7 +988,7 @@ var Jn = 200, Yn = 80, W = (e) => e.position === "top" || e.position === "bottom
|
|
|
985
988
|
let r = this.panels.find((t) => t.id === e);
|
|
986
989
|
if (r) {
|
|
987
990
|
let a = r.position === "left" || r.position === "right", o = n === "left" || n === "right";
|
|
988
|
-
r.position = n, a !== o && (r.size = o ?
|
|
991
|
+
r.position = n, a !== o && (r.size = o ? Yn : t, r.minSize = o ? Xn : i), o && (r.collapsed = void 0, this.maximized === e && (this.maximized = null));
|
|
989
992
|
}
|
|
990
993
|
}
|
|
991
994
|
setPanelSize(e, t) {
|
|
@@ -1105,8 +1108,8 @@ var Jn = 200, Yn = 80, W = (e) => e.position === "top" || e.position === "bottom
|
|
|
1105
1108
|
getMainChartRect() {
|
|
1106
1109
|
return this.resolve().mainChartRect;
|
|
1107
1110
|
}
|
|
1108
|
-
},
|
|
1109
|
-
function
|
|
1111
|
+
}, Qn = 14, $n = 14, er = 22, tr = 4;
|
|
1112
|
+
function nr(e) {
|
|
1110
1113
|
let { min: t, max: n, lastPrice: r, locale: i, fontFamily: a, fontSizeSmall: s, measure: l } = e, u = e.tagPrecision ?? c(t, n), d = u, f = r === null ? [t, n] : [
|
|
1111
1114
|
t,
|
|
1112
1115
|
n,
|
|
@@ -1115,16 +1118,16 @@ function tr(e) {
|
|
|
1115
1118
|
for (let t of f) {
|
|
1116
1119
|
if (!Number.isFinite(t)) continue;
|
|
1117
1120
|
let n = e.scaleLabel ? e.scaleLabel(t) : e.format ? e.format(t) : g(t, u, i), r = e.format ? n : g(t, d, i);
|
|
1118
|
-
p = Math.max(p, l(n, `500 ${s}px ${a}`) +
|
|
1121
|
+
p = Math.max(p, l(n, `500 ${s}px ${a}`) + Qn, l(r, `bold 11px ${a}`) + $n, l(r, `600 ${s}px ${a}`) + er);
|
|
1119
1122
|
}
|
|
1120
|
-
return p <= o ? o : Math.ceil(p /
|
|
1123
|
+
return p <= o ? o : Math.ceil(p / tr) * tr;
|
|
1121
1124
|
}
|
|
1122
|
-
function
|
|
1125
|
+
function rr(e, t) {
|
|
1123
1126
|
return t > e || t <= e - 12 ? t : e;
|
|
1124
1127
|
}
|
|
1125
1128
|
//#endregion
|
|
1126
1129
|
//#region src/layout/labelWidths.ts
|
|
1127
|
-
var
|
|
1130
|
+
var ir = 512, ar = class {
|
|
1128
1131
|
widths = /* @__PURE__ */ new Map();
|
|
1129
1132
|
fonts;
|
|
1130
1133
|
forget = () => this.widths.clear();
|
|
@@ -1135,12 +1138,12 @@ var rr = 512, ir = class {
|
|
|
1135
1138
|
let r = `${t}\n${e}`, i = this.widths.get(r);
|
|
1136
1139
|
if (i !== void 0) return i;
|
|
1137
1140
|
let a = n();
|
|
1138
|
-
return this.widths.size >=
|
|
1141
|
+
return this.widths.size >= ir && this.widths.clear(), this.widths.set(r, a), a;
|
|
1139
1142
|
}
|
|
1140
1143
|
destroy() {
|
|
1141
1144
|
this.fonts?.removeEventListener("loadingdone", this.forget), this.widths.clear();
|
|
1142
1145
|
}
|
|
1143
|
-
},
|
|
1146
|
+
}, or = class {
|
|
1144
1147
|
netY = 0;
|
|
1145
1148
|
travelX = 0;
|
|
1146
1149
|
engaged = !1;
|
|
@@ -1156,8 +1159,8 @@ var rr = 512, ir = class {
|
|
|
1156
1159
|
}
|
|
1157
1160
|
return this.engaged;
|
|
1158
1161
|
}
|
|
1159
|
-
},
|
|
1160
|
-
function
|
|
1162
|
+
}, sr = 1;
|
|
1163
|
+
function cr(e, t) {
|
|
1161
1164
|
return e.filter((e) => e.enabled !== !1 && (e.descriptor.layer ?? "overlay") === t);
|
|
1162
1165
|
}
|
|
1163
1166
|
function G(e) {
|
|
@@ -1171,24 +1174,24 @@ function G(e) {
|
|
|
1171
1174
|
//#endregion
|
|
1172
1175
|
//#region src/plugins/registry.ts
|
|
1173
1176
|
var K = /* @__PURE__ */ new Map();
|
|
1174
|
-
function
|
|
1177
|
+
function lr(e) {
|
|
1175
1178
|
K.set(G(e), e);
|
|
1176
1179
|
}
|
|
1177
|
-
function
|
|
1180
|
+
function ur(e) {
|
|
1178
1181
|
return K.delete(e);
|
|
1179
1182
|
}
|
|
1180
|
-
function
|
|
1183
|
+
function dr() {
|
|
1181
1184
|
return [...K.values()];
|
|
1182
1185
|
}
|
|
1183
|
-
function
|
|
1186
|
+
function fr() {
|
|
1184
1187
|
K.clear();
|
|
1185
1188
|
}
|
|
1186
1189
|
//#endregion
|
|
1187
1190
|
//#region src/plugins/PluginManager.ts
|
|
1188
|
-
var
|
|
1191
|
+
var pr = class {
|
|
1189
1192
|
plugins = /* @__PURE__ */ new Map();
|
|
1190
1193
|
constructor(e, t = {}) {
|
|
1191
|
-
if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of
|
|
1194
|
+
if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of dr()) this.add(e);
|
|
1192
1195
|
for (let e of t.plugins ?? []) this.add(e);
|
|
1193
1196
|
}
|
|
1194
1197
|
register(e) {
|
|
@@ -1218,15 +1221,15 @@ var fr = class {
|
|
|
1218
1221
|
add(e) {
|
|
1219
1222
|
this.plugins.set(G(e), e), e.kind === "indicator" && this.indicatorEngine.register(e.plugin);
|
|
1220
1223
|
}
|
|
1221
|
-
},
|
|
1224
|
+
}, mr = {
|
|
1222
1225
|
orderPlace: (e, t) => e.placeOrder(t),
|
|
1223
1226
|
orderModify: (e, t) => e.modifyOrder(t),
|
|
1224
1227
|
orderCancel: (e, t) => e.cancelOrder(t),
|
|
1225
1228
|
positionModify: (e, t) => e.modifyPosition(t),
|
|
1226
1229
|
positionClose: (e, t) => e.closePosition(t),
|
|
1227
|
-
positionReverse: (e, t, n) =>
|
|
1230
|
+
positionReverse: (e, t, n) => hr(e, t, n)
|
|
1228
1231
|
};
|
|
1229
|
-
async function
|
|
1232
|
+
async function hr(e, t, n) {
|
|
1230
1233
|
let { reversing: r } = n;
|
|
1231
1234
|
if (!r.has(t.positionId)) {
|
|
1232
1235
|
r.add(t.positionId);
|
|
@@ -1255,7 +1258,7 @@ async function mr(e, t, n) {
|
|
|
1255
1258
|
}
|
|
1256
1259
|
}
|
|
1257
1260
|
}
|
|
1258
|
-
function
|
|
1261
|
+
function gr(e, t) {
|
|
1259
1262
|
let n = [], r = null, i = {
|
|
1260
1263
|
positions: () => r ?? t.getPositions?.() ?? [],
|
|
1261
1264
|
reversing: /* @__PURE__ */ new Set()
|
|
@@ -1265,8 +1268,8 @@ function hr(e, t) {
|
|
|
1265
1268
|
e.data && t.onFill?.(e.data);
|
|
1266
1269
|
};
|
|
1267
1270
|
e.on("orders", a), e.on("positions", o), e.on("error", s), e.on("fill", c), n.push(() => e.off("orders", a), () => e.off("positions", o), () => e.off("error", s), () => e.off("fill", c));
|
|
1268
|
-
for (let r of Object.keys(
|
|
1269
|
-
let a =
|
|
1271
|
+
for (let r of Object.keys(mr)) {
|
|
1272
|
+
let a = mr[r], o = t.onIntent(r, (n) => {
|
|
1270
1273
|
Promise.resolve(a(e, n, i)).catch((e) => t.onError({
|
|
1271
1274
|
message: `Execution command failed: ${r}`,
|
|
1272
1275
|
cause: e
|
|
@@ -1280,7 +1283,7 @@ function hr(e, t) {
|
|
|
1280
1283
|
}
|
|
1281
1284
|
//#endregion
|
|
1282
1285
|
//#region src/replay/ReplayStepLoader.ts
|
|
1283
|
-
var
|
|
1286
|
+
var _r = 1e3, vr = class {
|
|
1284
1287
|
pieces = /* @__PURE__ */ new Map();
|
|
1285
1288
|
asked = /* @__PURE__ */ new Set();
|
|
1286
1289
|
inFlight = !1;
|
|
@@ -1313,7 +1316,7 @@ var gr = 1e3, _r = class {
|
|
|
1313
1316
|
this.done = !0;
|
|
1314
1317
|
}
|
|
1315
1318
|
ask(e, t) {
|
|
1316
|
-
let { ratio: n, barMs: r, step: i, report: a } = this.options, o = Math.max(1, Math.floor(
|
|
1319
|
+
let { ratio: n, barMs: r, step: i, report: a } = this.options, o = Math.max(1, Math.floor(_r / n)), s = Math.min(e.length, t + o), c = s < e.length ? e[s].time : e[e.length - 1].time + r, l = e.slice(t, s);
|
|
1317
1320
|
for (let e of l) this.asked.add(e.time);
|
|
1318
1321
|
this.inFlight = !0, a({
|
|
1319
1322
|
state: "loading",
|
|
@@ -1354,12 +1357,12 @@ var gr = 1e3, _r = class {
|
|
|
1354
1357
|
...n === void 0 ? {} : { error: n }
|
|
1355
1358
|
});
|
|
1356
1359
|
}
|
|
1357
|
-
},
|
|
1358
|
-
function
|
|
1359
|
-
let n = (e.high - e.low) *
|
|
1360
|
-
return t.filter((t) => t.close > e.high + n || t.close < e.low - n).length <= t.length *
|
|
1360
|
+
}, yr = 1 / 3, br = .25, xr = .5;
|
|
1361
|
+
function Sr(e, t) {
|
|
1362
|
+
let n = (e.high - e.low) * br;
|
|
1363
|
+
return t.filter((t) => t.close > e.high + n || t.close < e.low - n).length <= t.length * xr;
|
|
1361
1364
|
}
|
|
1362
|
-
function
|
|
1365
|
+
function Cr(e) {
|
|
1363
1366
|
return e.close >= e.open ? [
|
|
1364
1367
|
e.open,
|
|
1365
1368
|
e.low,
|
|
@@ -1372,22 +1375,22 @@ function Sr(e) {
|
|
|
1372
1375
|
e.close
|
|
1373
1376
|
];
|
|
1374
1377
|
}
|
|
1375
|
-
function
|
|
1376
|
-
let r =
|
|
1378
|
+
function wr(e, t, n) {
|
|
1379
|
+
let r = Cr(e), i = [
|
|
1377
1380
|
1,
|
|
1378
1381
|
2,
|
|
1379
1382
|
3
|
|
1380
1383
|
].map((e) => Math.abs(r[e] - r[e - 1])), a = i[0] + i[1] + i[2], o = [], s = 0;
|
|
1381
1384
|
return r.forEach((r, c) => {
|
|
1382
|
-
c > 0 && (s += a > 0 ? i[c - 1] / a :
|
|
1385
|
+
c > 0 && (s += a > 0 ? i[c - 1] / a : yr), !(c === 0 && t > 0) && o.push({
|
|
1383
1386
|
price: r,
|
|
1384
1387
|
time: e.time,
|
|
1385
1388
|
at: (t + s) / n
|
|
1386
1389
|
});
|
|
1387
1390
|
}), o;
|
|
1388
1391
|
}
|
|
1389
|
-
function
|
|
1390
|
-
let n = t.length > 0 &&
|
|
1392
|
+
function Tr(e, t = []) {
|
|
1393
|
+
let n = t.length > 0 && Sr(e, t) ? t : [e], r = n.length, i = Er(n.flatMap((e, t) => wr(e, t, r)), e), a = n.reduce((e, t) => e + (t.volume ?? 0), 0), o = 0;
|
|
1391
1394
|
return {
|
|
1392
1395
|
bar: e,
|
|
1393
1396
|
points: i,
|
|
@@ -1397,7 +1400,7 @@ function wr(e, t = []) {
|
|
|
1397
1400
|
}))
|
|
1398
1401
|
};
|
|
1399
1402
|
}
|
|
1400
|
-
function
|
|
1403
|
+
function Er(e, t) {
|
|
1401
1404
|
let n = e.length - 1, r = e.map((e, r) => ({
|
|
1402
1405
|
...e,
|
|
1403
1406
|
price: r === 0 ? t.open : r === n ? t.close : Math.min(t.high, Math.max(t.low, e.price))
|
|
@@ -1412,7 +1415,7 @@ function Tr(e, t) {
|
|
|
1412
1415
|
};
|
|
1413
1416
|
return i(t.high, (e, t) => e > t), i(t.low, (e, t) => e < t), r;
|
|
1414
1417
|
}
|
|
1415
|
-
function
|
|
1418
|
+
function Dr(e, t) {
|
|
1416
1419
|
let n = e.points;
|
|
1417
1420
|
if (t <= n[0].at) return n[0].price;
|
|
1418
1421
|
for (let e = 1; e < n.length; e++) if (t <= n[e].at) {
|
|
@@ -1421,8 +1424,8 @@ function Er(e, t) {
|
|
|
1421
1424
|
}
|
|
1422
1425
|
return n[n.length - 1].price;
|
|
1423
1426
|
}
|
|
1424
|
-
var
|
|
1425
|
-
function
|
|
1427
|
+
var Or = (e) => Number.isFinite(e) ? Math.min(1, Math.max(0, e)) : 0;
|
|
1428
|
+
function kr(e, t) {
|
|
1426
1429
|
let n = 0, r = 0;
|
|
1427
1430
|
for (let i of e.volumeAt) {
|
|
1428
1431
|
if (t >= i.at) {
|
|
@@ -1433,10 +1436,10 @@ function Or(e, t) {
|
|
|
1433
1436
|
}
|
|
1434
1437
|
return n;
|
|
1435
1438
|
}
|
|
1436
|
-
function
|
|
1437
|
-
let n =
|
|
1439
|
+
function Ar(e, t) {
|
|
1440
|
+
let n = Or(t);
|
|
1438
1441
|
if (n >= 1) return { ...e.bar };
|
|
1439
|
-
let r =
|
|
1442
|
+
let r = Dr(e, n), i = Math.max(e.points[0].price, r), a = Math.min(e.points[0].price, r);
|
|
1440
1443
|
for (let t of e.points) {
|
|
1441
1444
|
if (t.at > n) break;
|
|
1442
1445
|
i = Math.max(i, t.price), a = Math.min(a, t.price);
|
|
@@ -1447,11 +1450,11 @@ function kr(e, t) {
|
|
|
1447
1450
|
high: i,
|
|
1448
1451
|
low: a,
|
|
1449
1452
|
close: r,
|
|
1450
|
-
volume:
|
|
1453
|
+
volume: kr(e, n)
|
|
1451
1454
|
};
|
|
1452
1455
|
}
|
|
1453
|
-
function
|
|
1454
|
-
let n =
|
|
1456
|
+
function jr(e, t) {
|
|
1457
|
+
let n = Or(t), r = 0;
|
|
1455
1458
|
for (let t of e.points) {
|
|
1456
1459
|
if (t.at > n) break;
|
|
1457
1460
|
r = t.at;
|
|
@@ -1464,12 +1467,12 @@ function q(e, t, n) {
|
|
|
1464
1467
|
if (a.at > n) break;
|
|
1465
1468
|
i = a.time, a.at > t && r.push([a.price, a.time]);
|
|
1466
1469
|
}
|
|
1467
|
-
let a =
|
|
1470
|
+
let a = Dr(e, n);
|
|
1468
1471
|
return (r.length === 0 || r[r.length - 1][0] !== a) && r.push([a, i]), r;
|
|
1469
1472
|
}
|
|
1470
1473
|
//#endregion
|
|
1471
1474
|
//#region src/replay/replayStep.ts
|
|
1472
|
-
var
|
|
1475
|
+
var Mr = [
|
|
1473
1476
|
"1m",
|
|
1474
1477
|
"3m",
|
|
1475
1478
|
"5m",
|
|
@@ -1480,30 +1483,30 @@ var jr = [
|
|
|
1480
1483
|
"4h",
|
|
1481
1484
|
"1d"
|
|
1482
1485
|
];
|
|
1483
|
-
function
|
|
1486
|
+
function Nr(e, t) {
|
|
1484
1487
|
let n = w(e);
|
|
1485
|
-
return n > 0 ?
|
|
1488
|
+
return n > 0 ? Mr.filter((e) => {
|
|
1486
1489
|
let r = w(e);
|
|
1487
1490
|
return r < n && n % r === 0 && t(e);
|
|
1488
1491
|
}) : [];
|
|
1489
1492
|
}
|
|
1490
|
-
function
|
|
1491
|
-
let r =
|
|
1493
|
+
function Pr(e, t, n) {
|
|
1494
|
+
let r = Nr(t, n);
|
|
1492
1495
|
if (e !== "auto") return r.includes(e) ? e : null;
|
|
1493
1496
|
let i = w(t);
|
|
1494
1497
|
return r.find((e) => i / w(e) <= 60) ?? null;
|
|
1495
1498
|
}
|
|
1496
1499
|
//#endregion
|
|
1497
1500
|
//#region src/Chart.ts
|
|
1498
|
-
var
|
|
1501
|
+
var Fr = {
|
|
1499
1502
|
min: 0,
|
|
1500
1503
|
max: 100
|
|
1501
|
-
},
|
|
1502
|
-
function
|
|
1504
|
+
}, Ir = "exchange", Lr = Ir;
|
|
1505
|
+
function Rr(e) {
|
|
1503
1506
|
if (typeof e == "string" && e !== "exchange" && !y(e)) throw RangeError(`Unknown time zone: ${e}`);
|
|
1504
1507
|
if (typeof e == "number" && !Number.isFinite(e)) throw RangeError(`Invalid UTC offset: ${e}`);
|
|
1505
1508
|
}
|
|
1506
|
-
function
|
|
1509
|
+
function zr(e, t) {
|
|
1507
1510
|
let { timeZone: n, timezone: r } = e, i = n !== void 0 && r !== void 0 && n !== r && n === t ? r : C(e);
|
|
1508
1511
|
return i === void 0 ? e : {
|
|
1509
1512
|
...e,
|
|
@@ -1511,20 +1514,20 @@ function Rr(e, t) {
|
|
|
1511
1514
|
timezone: i
|
|
1512
1515
|
};
|
|
1513
1516
|
}
|
|
1514
|
-
var
|
|
1515
|
-
function
|
|
1517
|
+
var Br = .08, Vr = a ** -7, Hr = 800, Ur = 24;
|
|
1518
|
+
function Wr(e) {
|
|
1516
1519
|
return e.length > 0 ? { renames: e } : {};
|
|
1517
1520
|
}
|
|
1518
|
-
var
|
|
1521
|
+
var Gr = 20, Kr = 8, qr = 10, Jr = {
|
|
1519
1522
|
ArrowLeft: [-1, 0],
|
|
1520
1523
|
ArrowRight: [1, 0],
|
|
1521
1524
|
ArrowUp: [0, -1],
|
|
1522
1525
|
ArrowDown: [0, 1]
|
|
1523
|
-
},
|
|
1524
|
-
static version = "1.
|
|
1526
|
+
}, Yr = new Set(["horizontalLine", "crossLine"]), Xr = new Set(["verticalLine", "crossLine"]), Zr = class {
|
|
1527
|
+
static version = "1.69.0";
|
|
1525
1528
|
engine;
|
|
1526
1529
|
viewport;
|
|
1527
|
-
series = new
|
|
1530
|
+
series = new zn((e) => this.sessionKeep(e), (e) => this.followLiveChange(e));
|
|
1528
1531
|
themeManager;
|
|
1529
1532
|
layoutManager;
|
|
1530
1533
|
pluginManager;
|
|
@@ -1551,7 +1554,7 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
1551
1554
|
renderDeferred = !1;
|
|
1552
1555
|
priceAxisWidth = o;
|
|
1553
1556
|
measureCtx;
|
|
1554
|
-
labelWidths = new
|
|
1557
|
+
labelWidths = new ar();
|
|
1555
1558
|
containerSizeCache = null;
|
|
1556
1559
|
containerSizeCacheTime = 0;
|
|
1557
1560
|
lastEmittedRange = null;
|
|
@@ -1611,7 +1614,7 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
1611
1614
|
replayForming = null;
|
|
1612
1615
|
replayPhaseUnsub = null;
|
|
1613
1616
|
undoRedoManager;
|
|
1614
|
-
autoSaveScheduler = new
|
|
1617
|
+
autoSaveScheduler = new Mn((e) => this.saveState(e));
|
|
1615
1618
|
animator;
|
|
1616
1619
|
crosshairTooltip;
|
|
1617
1620
|
pinnedTooltip;
|
|
@@ -1663,7 +1666,7 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
1663
1666
|
snapshotKey = null;
|
|
1664
1667
|
historyCheckQueued = !1;
|
|
1665
1668
|
constructor(e, t) {
|
|
1666
|
-
t.timeZone != null &&
|
|
1669
|
+
t.timeZone != null && Rr(t.timeZone), this.container = e, this.options = {
|
|
1667
1670
|
...t,
|
|
1668
1671
|
chartType: t.chartType ?? "candlestick"
|
|
1669
1672
|
}, this.numberLocale = t.numberLocale ?? "en-US", this.defaultAutoScale = t.autoScale !== !1;
|
|
@@ -1702,11 +1705,11 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
1702
1705
|
logScale: n.logScale ?? !0,
|
|
1703
1706
|
timeframes: n.timeframes ?? [],
|
|
1704
1707
|
defaultTimeframeFavorites: n.defaultTimeframeFavorites ?? []
|
|
1705
|
-
}, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", e.style.userSelect = "none", e.style.webkitUserSelect = "none", this.history = new
|
|
1708
|
+
}, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", e.style.userSelect = "none", e.style.webkitUserSelect = "none", this.history = new Wn({
|
|
1706
1709
|
oldestTime: () => (this.replaySession ? this.series.liveBars() : this.series.bars())[0]?.time ?? null,
|
|
1707
1710
|
prepend: (e) => this.prependBars(e),
|
|
1708
1711
|
emit: (e) => this.eventBus.emit("historyLoad", e)
|
|
1709
|
-
}), this.themeManager = new
|
|
1712
|
+
}), this.themeManager = new Kn(t.theme), this.themeManager.setChartType(this.options.chartType ?? "candlestick"), this.applyStyle(Jn(t), "host", !1), this.layoutManager = new Zn(), this.indicatorEngine = new Ve(), this.pluginManager = new pr(this.indicatorEngine, { plugins: t.plugins }), this.eventBus = new Ie(), Vt(this.indicatorEngine), this.indicatorEngine.register(new we(this.symbolSeries)), this.indicatorEngine.register(new Te(this.symbolSeries)), this.indicatorEngine.register(new ht(this.symbolSeries)), this.indicatorEngine.register(new Ee(this.symbolSeries)), this.indicatorEngine.register(new De(this.symbolSeries)), this.drawingManager = new Ne(), Bt(this.drawingManager), this.drawingRenderer = new Pe(this.drawingManager), this.drawingRenderer.setKeepOut(() => this.legendKeepOut()), this.drawingRenderer.setTimeFormat((e) => this.crosshairHandler.formatTime(e, this.getDisplayData())), this.drawingManager.setRequestRender(() => {
|
|
1710
1713
|
this.syncRenderContext(), this.engine.requestRender(r.Overlay), this.scheduleAutoSave();
|
|
1711
1714
|
}), this.drawingManager.setEventCallback((e, t) => {
|
|
1712
1715
|
this.followDrawingAlerts(e, t?.id), this.eventBus.emit(e, t), (e === "drawingCreate" || e === "drawingUpdate" || e === "drawingRemove") && this.announceStateChange();
|
|
@@ -1774,7 +1777,7 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
1774
1777
|
color: t.sessionBreaks.color,
|
|
1775
1778
|
lineStyle: t.sessionBreaks.lineStyle,
|
|
1776
1779
|
lineWidth: t.sessionBreaks.lineWidth
|
|
1777
|
-
}) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new he(), this.crosshairTooltip = new ke(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new $e(), this.pinnedTooltip.create(e), this.pinnedTooltip.setLocale(this.numberLocale), t.priceFormat && this.applyPriceFormat(t.priceFormat), t.chartTypeOptions && (this.chartTypeOptions = ae(t.chartTypeOptions)), t.highLowLines && this.priceLines.setHighLow(!0), t.shapes && this.themeManager.setShape(
|
|
1780
|
+
}) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new he(), this.crosshairTooltip = new ke(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new $e(), this.pinnedTooltip.create(e), this.pinnedTooltip.setLocale(this.numberLocale), t.priceFormat && this.applyPriceFormat(t.priceFormat), t.chartTypeOptions && (this.chartTypeOptions = ae(t.chartTypeOptions)), t.highLowLines && this.priceLines.setHighLow(!0), t.shapes && this.themeManager.setShape(ri(t.shapes)), t.font && this.themeManager.setFont(ni(t.font)), this.priceLines.setPriceText((e) => this.formatPrice(e)), t.extendedHours === !1 && (this.extendedHours = !1), t.timeFormatter && this.applyTimeFormatter(t.timeFormatter), this.keyboardHandler = new We({
|
|
1778
1781
|
scrollBars: (e) => {
|
|
1779
1782
|
let t = this.viewport.getState().barWidth + this.viewport.getState().barSpacing;
|
|
1780
1783
|
this.viewport.scrollBy(e * t), this.updateViewportAndRender();
|
|
@@ -1791,7 +1794,7 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
1791
1794
|
},
|
|
1792
1795
|
fitContent: () => this.fitContent()
|
|
1793
1796
|
}), this.keyboardHandler.setEnabled(this.features.keyboard), t.a11y !== !1) {
|
|
1794
|
-
this.a11y = new
|
|
1797
|
+
this.a11y = new an(e, {
|
|
1795
1798
|
symbol: () => this.currentSymbol || this.symbolInfo?.symbol || "",
|
|
1796
1799
|
timeframe: () => this.streamTimeframe ?? "",
|
|
1797
1800
|
chartType: () => this.options.chartType ?? "candlestick",
|
|
@@ -1862,7 +1865,7 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
1862
1865
|
}), this.replayManager.on("stateChange", (e) => {
|
|
1863
1866
|
this.replayRestarting || this.eventBus.emit("replayState", { state: e });
|
|
1864
1867
|
}), this.measureOverlay = new Je(), this.interactionManager = new He(e), this.features.panning) {
|
|
1865
|
-
let e = new
|
|
1868
|
+
let e = new or();
|
|
1866
1869
|
this.interactionManager.setPanHandler(new Xe((t, n) => {
|
|
1867
1870
|
t && this.viewport.scrollBy(t), e.step(t, n, this.options.autoScale !== !1) && n && (this.holdPriceScale(), this.viewport.panPriceRange(n)), this.updateViewportAndRender();
|
|
1868
1871
|
}, () => e.reset()));
|
|
@@ -1903,7 +1906,7 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
1903
1906
|
y: t.y
|
|
1904
1907
|
});
|
|
1905
1908
|
})), this.interactionManager.setChartContextMenu((e, t) => this.eventBus.hasListeners("chartContextMenu") ? (this.eventBus.emit("chartContextMenu", this.contextAt(e, t)), !0) : !1), this.applyPriceAxisAdd(), this.interactionManager.setPriceAxisAddButton(this.priceAxisAddButton, (e) => {
|
|
1906
|
-
let t =
|
|
1909
|
+
let t = Xt(e.y, this.viewport.getState());
|
|
1907
1910
|
Number.isFinite(t) && this.eventBus.emit("priceAxisAdd", {
|
|
1908
1911
|
price: t,
|
|
1909
1912
|
x: e.x,
|
|
@@ -1940,7 +1943,7 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
1940
1943
|
x: e.x,
|
|
1941
1944
|
y: e.y
|
|
1942
1945
|
}), t.length === 0) return;
|
|
1943
|
-
let r =
|
|
1946
|
+
let r = Yt(e.x, this.viewport.getState());
|
|
1944
1947
|
r < 0 || r >= t.length || this.eventBus.emit("barClick", {
|
|
1945
1948
|
bar: t[r],
|
|
1946
1949
|
barIndex: r,
|
|
@@ -1985,7 +1988,7 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
1985
1988
|
end: () => {
|
|
1986
1989
|
let e = this.selectionBoxOverlay.end();
|
|
1987
1990
|
if (e && this.zoomAreaMode) {
|
|
1988
|
-
if (e.x1 - e.x0 <
|
|
1991
|
+
if (e.x1 - e.x0 < Kr) return;
|
|
1989
1992
|
this.zoomToBox(e), this.setZoomAreaMode(!1);
|
|
1990
1993
|
return;
|
|
1991
1994
|
}
|
|
@@ -2069,7 +2072,7 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
2069
2072
|
let { visibleRange: e, chartRect: t } = this.viewport.getState();
|
|
2070
2073
|
if (t.width <= 0) return;
|
|
2071
2074
|
let { from: n, to: r } = e;
|
|
2072
|
-
this.history.maybeLoad(Math.max(0, Math.floor(n)), Math.max(
|
|
2075
|
+
this.history.maybeLoad(Math.max(0, Math.floor(n)), Math.max(Gr, r - n));
|
|
2073
2076
|
}));
|
|
2074
2077
|
}
|
|
2075
2078
|
useStreamHistory(e, t, n = !0) {
|
|
@@ -2185,7 +2188,7 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
2185
2188
|
return this.extendedHours;
|
|
2186
2189
|
}
|
|
2187
2190
|
sessionKeep(e) {
|
|
2188
|
-
return this.extendedHours ? null :
|
|
2191
|
+
return this.extendedHours ? null : $t(this.symbolInfo, e);
|
|
2189
2192
|
}
|
|
2190
2193
|
reapplyExtendedHours() {
|
|
2191
2194
|
if (!this.series.refilter()) return;
|
|
@@ -2196,7 +2199,7 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
2196
2199
|
return this.priceLines.setQuoteShown(this.replaySession === null), this.priceLines;
|
|
2197
2200
|
}
|
|
2198
2201
|
setShapes(e) {
|
|
2199
|
-
let t =
|
|
2202
|
+
let t = ri(e);
|
|
2200
2203
|
t.tagRadius !== void 0 && (this.themeManager.setShape({
|
|
2201
2204
|
...this.themeManager.getTheme().shape,
|
|
2202
2205
|
...t
|
|
@@ -2208,7 +2211,7 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
2208
2211
|
setFont(e) {
|
|
2209
2212
|
if (e === null) this.themeManager.setFont(null);
|
|
2210
2213
|
else {
|
|
2211
|
-
let t =
|
|
2214
|
+
let t = ni(e);
|
|
2212
2215
|
if (Object.keys(t).length === 0) return;
|
|
2213
2216
|
this.themeManager.setFont(t);
|
|
2214
2217
|
}
|
|
@@ -2350,8 +2353,8 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
2350
2353
|
return {
|
|
2351
2354
|
...e,
|
|
2352
2355
|
priceRange: {
|
|
2353
|
-
min: t.min - n *
|
|
2354
|
-
max: t.max + n *
|
|
2356
|
+
min: t.min - n * Br,
|
|
2357
|
+
max: t.max + n * Br
|
|
2355
2358
|
},
|
|
2356
2359
|
logScale: !1,
|
|
2357
2360
|
scaleMode: "regular",
|
|
@@ -2693,9 +2696,9 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
2693
2696
|
return this.drawingManager.removeDrawings(e);
|
|
2694
2697
|
}
|
|
2695
2698
|
nudgeSelectedDrawings(e) {
|
|
2696
|
-
let t =
|
|
2699
|
+
let t = Jr[e.key];
|
|
2697
2700
|
if (!t || !this.features.drawings || e.ctrlKey || e.metaKey || e.altKey) return !1;
|
|
2698
|
-
let n = e.shiftKey ?
|
|
2701
|
+
let n = e.shiftKey ? qr : 1, r = {
|
|
2699
2702
|
...this.viewport.getState(),
|
|
2700
2703
|
data: this.getDisplayData()
|
|
2701
2704
|
};
|
|
@@ -2789,7 +2792,7 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
2789
2792
|
recordUndo(e) {
|
|
2790
2793
|
if (!this.features.drawingUndoRedo || typeof e?.undo != "function" || typeof e.redo != "function") return;
|
|
2791
2794
|
let t = performance.now(), n = this.undoRedoManager.last();
|
|
2792
|
-
if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at <
|
|
2795
|
+
if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at < Hr) {
|
|
2793
2796
|
this.undoRedoManager.replaceLast({
|
|
2794
2797
|
...n,
|
|
2795
2798
|
custom: {
|
|
@@ -2836,7 +2839,7 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
2836
2839
|
x: t.x,
|
|
2837
2840
|
y: t.y
|
|
2838
2841
|
};
|
|
2839
|
-
if ((e === "plot" || e === "priceAxis") && (r.price =
|
|
2842
|
+
if ((e === "plot" || e === "priceAxis") && (r.price = Xt(t.y, n)), (e === "plot" || e === "timeAxis") && n.data.length > 0 && (r.time = F(t.x, n)), e === "pane") {
|
|
2840
2843
|
let e = this.getIndicatorPanes().find((e) => t.y >= e.rect.y && t.y <= e.rect.y + e.rect.height);
|
|
2841
2844
|
e && (r.pane = e.instanceId);
|
|
2842
2845
|
}
|
|
@@ -2911,7 +2914,7 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
2911
2914
|
for (let e of this.indicatorEngine.getActiveIndicators()) {
|
|
2912
2915
|
let t = this.indicatorEngine.getOutput(e.instanceId)?.series;
|
|
2913
2916
|
if (!t) continue;
|
|
2914
|
-
let r =
|
|
2917
|
+
let r = un(e.id, e.params, e.descriptor.defaultConfig, e.descriptor.shortName), o = e.descriptor.plots ?? Object.keys(t.find((e) => e) ?? {}).map((e) => ({
|
|
2915
2918
|
key: e,
|
|
2916
2919
|
title: e
|
|
2917
2920
|
}));
|
|
@@ -3121,10 +3124,15 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
3121
3124
|
this.features.trading && this.tradingManager.setConfig(e);
|
|
3122
3125
|
}
|
|
3123
3126
|
async connect(e) {
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3127
|
+
let t = {
|
|
3128
|
+
...e,
|
|
3129
|
+
adapter: Ht(e),
|
|
3130
|
+
feed: void 0
|
|
3131
|
+
};
|
|
3132
|
+
if (!j(t.adapter, t.timeframe)) throw RangeError(`${t.adapter.name} cannot serve the ${t.timeframe} timeframe`);
|
|
3133
|
+
this.snapshotKey = null, this.holdReplayFor(t.symbol), this.disconnectStream(), this.streamManager = new _t(), this.streamManager.setTimeZone(this.studyZoneHeld ? this.studyZone : this.getExchangeTimeZone()), this.streamManager.on("snapshot", (e) => {
|
|
3134
|
+
let n = this.streamSeriesKey(t.adapter);
|
|
3135
|
+
n === this.snapshotKey && this.replaySession ? this.series.mergeSnapshot(e) : n === this.snapshotKey && this.series.length() > 0 ? this.mergeSnapshot(e) : (this.replaySession && this.useStreamHistory(t.adapter, t.historyPageSize, !1), this.setData(e)), this.snapshotKey = n, this.useStreamHistory(t.adapter, t.historyPageSize);
|
|
3128
3136
|
}), this.streamManager.on("barClose", (e) => {
|
|
3129
3137
|
if (!R(e)) return;
|
|
3130
3138
|
let t = this.series.placeStreamBar(e);
|
|
@@ -3175,11 +3183,11 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
3175
3183
|
kind: "error",
|
|
3176
3184
|
error: e.message
|
|
3177
3185
|
});
|
|
3178
|
-
}), this.streamManager.on("symbolInfo", (e) => this.applyFeedSymbolInfo(e)), this.autoScrollOnNewBar =
|
|
3179
|
-
let
|
|
3180
|
-
if (this.resolveStreamSymbol(
|
|
3181
|
-
let
|
|
3182
|
-
this.barCountdown.setTimeframeMs(
|
|
3186
|
+
}), this.streamManager.on("symbolInfo", (e) => this.applyFeedSymbolInfo(e)), this.autoScrollOnNewBar = t.autoScroll !== !1, this.setStreamTarget(t.symbol, t.timeframe), this.streamAdapter = t.adapter;
|
|
3187
|
+
let n = this.streamManager;
|
|
3188
|
+
if (this.resolveStreamSymbol(t.adapter, t.symbol), await n.connect(t), this.streamManager !== n) return;
|
|
3189
|
+
let i = w(t.timeframe);
|
|
3190
|
+
this.barCountdown.setTimeframeMs(i), this.countdownInterval && clearInterval(this.countdownInterval), this.countdownInterval = setInterval(() => {
|
|
3183
3191
|
this.barCountdown.isVisible() && this.engine.requestRender(r.Hover);
|
|
3184
3192
|
}, 1e3);
|
|
3185
3193
|
}
|
|
@@ -3227,7 +3235,7 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
3227
3235
|
}
|
|
3228
3236
|
connectExecution(e, t = {}) {
|
|
3229
3237
|
if (!this.features.trading) throw Error("connectExecution requires features.trading to be enabled");
|
|
3230
|
-
this.disconnectExecution(), this.executionAdapter = e, this.execTeardown =
|
|
3238
|
+
this.disconnectExecution(), this.executionAdapter = e, this.execTeardown = gr(e, {
|
|
3231
3239
|
onIntent: (e, t) => {
|
|
3232
3240
|
let n = (e) => t(e.payload);
|
|
3233
3241
|
return this.eventBus.on(e, n), () => this.eventBus.off(e, n);
|
|
@@ -3643,7 +3651,7 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
3643
3651
|
return this.periodLevels.getPeriod();
|
|
3644
3652
|
}
|
|
3645
3653
|
setTimeZone(e) {
|
|
3646
|
-
|
|
3654
|
+
Rr(e), this.timeZoneSetting = e, this.applyTimeZone();
|
|
3647
3655
|
}
|
|
3648
3656
|
getTimeZone() {
|
|
3649
3657
|
return this.timeZoneSetting;
|
|
@@ -3708,7 +3716,7 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
3708
3716
|
}
|
|
3709
3717
|
useSymbolInfo(e) {
|
|
3710
3718
|
let t = e && this.symbolInfo?.symbol === e.symbol ? C(this.symbolInfo) : void 0;
|
|
3711
|
-
this.symbolInfo = e ?
|
|
3719
|
+
this.symbolInfo = e ? zr({
|
|
3712
3720
|
...e,
|
|
3713
3721
|
sessions: e.sessions?.map((e) => ({ ...e }))
|
|
3714
3722
|
}, 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);
|
|
@@ -3733,7 +3741,7 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
3733
3741
|
if (!e || typeof e != "object") return;
|
|
3734
3742
|
let t = this.currentSymbol, n = (e) => !e || e.toUpperCase() === t.toUpperCase();
|
|
3735
3743
|
if (!n(e.symbol)) return;
|
|
3736
|
-
let r = this.symbolInfo && n(this.symbolInfo.symbol) ? this.symbolInfo : null, i =
|
|
3744
|
+
let r = this.symbolInfo && n(this.symbolInfo.symbol) ? this.symbolInfo : null, i = zr({
|
|
3737
3745
|
...r,
|
|
3738
3746
|
...e,
|
|
3739
3747
|
symbol: e.symbol || r?.symbol || t
|
|
@@ -3798,7 +3806,7 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
3798
3806
|
return t !== this.rendererToken || this.disposed ? (r?.destroy(), this.getRenderer()) : i === "limit" ? Mt() > 0 ? this.takeGpu(e, t, n) : (this.waitForGpu(() => void this.takeGpu(e, t, !1)), n && this.applyRenderer(null, "limit"), this.getRenderer()) : ((r || n) && this.applyRenderer(r, i), this.getRenderer());
|
|
3799
3807
|
}
|
|
3800
3808
|
waitForGpu(e) {
|
|
3801
|
-
this.stopWaitingForGpu?.(), this.stopWaitingForGpu = e ?
|
|
3809
|
+
this.stopWaitingForGpu?.(), this.stopWaitingForGpu = e ? Jt(e) : null;
|
|
3802
3810
|
}
|
|
3803
3811
|
getRenderer() {
|
|
3804
3812
|
return this.engine.getGpu() ? "webgl" : "canvas";
|
|
@@ -3977,7 +3985,7 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
3977
3985
|
let t = this.replaySession ? this.replayOffset : 0;
|
|
3978
3986
|
if (!this.replaySession) {
|
|
3979
3987
|
if (this.series.length() === 0) return;
|
|
3980
|
-
this.series.beginReplay(), this.replaySession =
|
|
3988
|
+
this.series.beginReplay(), this.replaySession = di(this.currentSymbol);
|
|
3981
3989
|
}
|
|
3982
3990
|
let n = this.replaySession, { steps: r, startTime: i, hideHistory: a, revealMarks: o, step: s, ...c } = e ?? {};
|
|
3983
3991
|
c.animate = c.animate === !0;
|
|
@@ -3988,13 +3996,13 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
3988
3996
|
let m = r ? this.replayStepsOver(n, p, !0) : null;
|
|
3989
3997
|
this.options.autoScale = !0, this.buildReplay(p, m, f);
|
|
3990
3998
|
let h = this.replayStepsSeries;
|
|
3991
|
-
h && c.startIndex !== void 0 && (c.startIndex =
|
|
3999
|
+
h && c.startIndex !== void 0 && (c.startIndex = bi(h, p, c.startIndex));
|
|
3992
4000
|
let g = h ?? p, _ = g[Math.max(0, Math.min(Math.floor(Number(c.startIndex ?? 0)) || 0, g.length - 1))];
|
|
3993
4001
|
this.revealReplayMarks(this.replayRevealMarks ? _?.time ?? null : null), n.held && (n.held.state = c.paused ? "paused" : "playing", c.paused = !0), !c.paused && c.startIndex !== void 0 && c.startIndex >= 1 && this.replaySeek(c.startIndex - 1), this.replayManager.play(c);
|
|
3994
4002
|
}
|
|
3995
4003
|
buildReplay(e, t, n) {
|
|
3996
4004
|
let r = this.replaySession?.animate === !0, i = r ? null : t;
|
|
3997
|
-
this.replayPieces = r && t ?
|
|
4005
|
+
this.replayPieces = r && t ? Ci(t, e) : null, this.replayForming = null, this.replayOffset = n, this.replayStepsSeries = i, this.replayCoarse = e;
|
|
3998
4006
|
let a = this.replayRestarting;
|
|
3999
4007
|
this.replayRestarting = !0;
|
|
4000
4008
|
try {
|
|
@@ -4008,7 +4016,7 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
4008
4016
|
let n = t, a = e[t];
|
|
4009
4017
|
if (i) {
|
|
4010
4018
|
let r = i[t];
|
|
4011
|
-
n = Q(e, r.time), c = c !== null && s === t - 1 && n === o - 1 && c ?
|
|
4019
|
+
n = Q(e, r.time), c = c !== null && s === t - 1 && n === o - 1 && c ? Ti(c, r) : xi(e[n], i, t), a = Si(i, e, t, n) ? e[n] : c;
|
|
4012
4020
|
}
|
|
4013
4021
|
let u = this.replayForming;
|
|
4014
4022
|
this.replayForming = null, s = t;
|
|
@@ -4032,7 +4040,7 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
4032
4040
|
});
|
|
4033
4041
|
}), r && (this.replayPhaseUnsub = this.replayManager.on("phase", ({ index: t, fraction: n }) => {
|
|
4034
4042
|
if (!e[t] || this.series.length() !== o || o !== t && o !== t + 1) return;
|
|
4035
|
-
let r = this.replayForming?.index === t ? this.replayForming.path : this.replayPathOf(e, t), i =
|
|
4043
|
+
let r = this.replayForming?.index === t ? this.replayForming.path : this.replayPathOf(e, t), i = wi() ? jr(r, n) : n, a = o === t, s = a && this.autoScrollOnNewBar && this.viewport.isAtEnd(), c = Ar(r, i);
|
|
4036
4044
|
a ? this.series.appendReplayed(c) : this.series.updateReplayed(c), o = t + 1, this.replayForming = {
|
|
4037
4045
|
index: t,
|
|
4038
4046
|
path: r
|
|
@@ -4042,7 +4050,7 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
4042
4050
|
drawFormingBar(e, t, n, r) {
|
|
4043
4051
|
this.currentPriceLine.setPrice(e.close, t);
|
|
4044
4052
|
let i = this.series.bars();
|
|
4045
|
-
if (this.recalcIndicatorsFrom(i, i.length - 1), (n || !
|
|
4053
|
+
if (this.recalcIndicatorsFrom(i, i.length - 1), (n || !si.has(this.options.chartType)) && (this.displayDataCache = null), !n) {
|
|
4046
4054
|
this.scheduleRender();
|
|
4047
4055
|
return;
|
|
4048
4056
|
}
|
|
@@ -4050,19 +4058,19 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
4050
4058
|
}
|
|
4051
4059
|
replayPathOf(e, t) {
|
|
4052
4060
|
let n = e[t];
|
|
4053
|
-
return
|
|
4061
|
+
return Tr(n, this.replayPieces?.get(n.time) ?? this.replayLoader?.loader.piecesOf(n.time) ?? []);
|
|
4054
4062
|
}
|
|
4055
4063
|
loadReplaySteps(e, t) {
|
|
4056
4064
|
let n = this.replayLoader?.loader;
|
|
4057
4065
|
if (!n) return;
|
|
4058
4066
|
n.evictBefore(e[t].time);
|
|
4059
4067
|
let r = this.replayManager.getStepMs();
|
|
4060
|
-
n.ensure(e, t, Number.isFinite(r) && r > 0 ? Math.ceil(
|
|
4068
|
+
n.ensure(e, t, Number.isFinite(r) && r > 0 ? Math.ceil(oi / r) : 1);
|
|
4061
4069
|
}
|
|
4062
4070
|
useReplayLoader(e, t) {
|
|
4063
|
-
let n = this.streamAdapter, r = this.streamTimeframe, i = e.step && n && r !== null ?
|
|
4071
|
+
let n = this.streamAdapter, r = this.streamTimeframe, i = e.step && n && r !== null ? Pr(e.step, r, (e) => j(n, e)) : null, a = `${this.currentSymbol}|${r}|${i}`;
|
|
4064
4072
|
if (!t && this.replayLoader?.key === a || (this.replayLoader?.loader.dispose(), this.replayLoader = null, !i || !n || r === null)) return;
|
|
4065
|
-
let o = P(n), s = o.fetchHistoryBefore, c = this.currentSymbol, l = w(r), u = new
|
|
4073
|
+
let o = P(n), s = o.fetchHistoryBefore, c = this.currentSymbol, l = w(r), u = new vr({
|
|
4066
4074
|
source: s ? (e, t) => s.call(o, c, i, e, t) : null,
|
|
4067
4075
|
step: i,
|
|
4068
4076
|
ratio: Math.max(1, Math.round(l / w(i))),
|
|
@@ -4080,7 +4088,7 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
4080
4088
|
if (!i || !a?.setMarkPrice || !o) return;
|
|
4081
4089
|
let s = i.fedTime;
|
|
4082
4090
|
if (s === null) {
|
|
4083
|
-
i.fedTime = o.time, i.fedFraction = r, this.feedReplayPrice(
|
|
4091
|
+
i.fedTime = o.time, i.fedFraction = r, this.feedReplayPrice(Ar(n, r).close, o.time);
|
|
4084
4092
|
return;
|
|
4085
4093
|
}
|
|
4086
4094
|
if (o.time < s || o.time === s && r <= i.fedFraction) return;
|
|
@@ -4088,8 +4096,8 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
4088
4096
|
if (o.time > s) {
|
|
4089
4097
|
let a = Y(e, s);
|
|
4090
4098
|
e[a]?.time === s && i.fedFraction < 1 && c.push(...q(this.replayPathOf(e, a), i.fedFraction, 1));
|
|
4091
|
-
let o = e.slice(X(e, s), t), l = Math.ceil(o.length /
|
|
4092
|
-
for (let e = 0; e < o.length; e += l) c.push(...
|
|
4099
|
+
let o = e.slice(X(e, s), t), l = Math.ceil(o.length / _i);
|
|
4100
|
+
for (let e = 0; e < o.length; e += l) c.push(...vi(o.slice(e, e + l)));
|
|
4093
4101
|
c.push(...q(n, -1, r));
|
|
4094
4102
|
} else c.push(...q(n, i.fedFraction, r));
|
|
4095
4103
|
i.fedTime = o.time, i.fedFraction = r;
|
|
@@ -4108,7 +4116,7 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
4108
4116
|
if (n.length === 0) return;
|
|
4109
4117
|
let r = t.windowTime === null ? 0 : Math.min(Y(n, t.windowTime), n.length - 1), i = r > 0 ? n.slice(r) : n;
|
|
4110
4118
|
this.useReplayLoader(t, !1);
|
|
4111
|
-
let a = this.replayStepsOver(t, i), o = t.animate ? null : a, s = t.until === null ? 0 :
|
|
4119
|
+
let a = this.replayStepsOver(t, i), o = t.animate ? null : a, s = t.until === null ? 0 : mi(o ?? i, t.until);
|
|
4112
4120
|
if (s < 0 && this.canPageBackForReplay(t)) {
|
|
4113
4121
|
this.holdReplay(), t.held && t.held.pagesBack++, queueMicrotask(() => void this.pageBackForReplay(t));
|
|
4114
4122
|
return;
|
|
@@ -4116,7 +4124,7 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
4116
4124
|
let c = this.getReplayState(), l = t.held !== null && (e === "hours" || e === "bar"), u = t.held?.state ?? c;
|
|
4117
4125
|
l || (t.held = null), t.symbol = this.currentSymbol;
|
|
4118
4126
|
let d = this.replayManager.remainingMs();
|
|
4119
|
-
this.clearBarHolders(), t.animate &&
|
|
4127
|
+
this.clearBarHolders(), t.animate && pi(t, this.replayCoarse, i);
|
|
4120
4128
|
let f = this.replayRestarting;
|
|
4121
4129
|
this.replayRestarting = !0, this.replayCause = e === "older" ? "older" : "series";
|
|
4122
4130
|
try {
|
|
@@ -4139,14 +4147,14 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
4139
4147
|
}
|
|
4140
4148
|
replayStepsOver(e, t, n = !1) {
|
|
4141
4149
|
if (!e.steps || e.stepsSymbol !== this.currentSymbol) return null;
|
|
4142
|
-
let r =
|
|
4143
|
-
return r && (n ||
|
|
4150
|
+
let r = yi(this.series.inHoursShown(e.steps), t);
|
|
4151
|
+
return r && (n || gi(r, t)) ? r : null;
|
|
4144
4152
|
}
|
|
4145
4153
|
canPageBackForReplay(e) {
|
|
4146
|
-
return this.history.hasLoader() && this.history.hasMore() && (e.held?.pagesBack ?? 0) <
|
|
4154
|
+
return this.history.hasLoader() && this.history.hasMore() && (e.held?.pagesBack ?? 0) < ci;
|
|
4147
4155
|
}
|
|
4148
4156
|
async pageBackForReplay(e) {
|
|
4149
|
-
this.replaySession !== e || !e.held || await this.history.loadMore() > 0 || this.replaySession !== e || !e.held || (e.held.pagesBack =
|
|
4157
|
+
this.replaySession !== e || !e.held || await this.history.loadMore() > 0 || this.replaySession !== e || !e.held || (e.held.pagesBack = ci, this.rebaseReplay("older"));
|
|
4150
4158
|
}
|
|
4151
4159
|
holdReplay() {
|
|
4152
4160
|
let e = this.replaySession;
|
|
@@ -4179,7 +4187,7 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
4179
4187
|
this.signalMarkerManager.setRevealUntil(e, t), this.tradeZoneManager.setRevealUntil(e, t);
|
|
4180
4188
|
}
|
|
4181
4189
|
replaySeekToTime(e) {
|
|
4182
|
-
!this.replaySession || !this.replayCoarse || this.replaySeek(Math.max(0,
|
|
4190
|
+
!this.replaySession || !this.replayCoarse || this.replaySeek(Math.max(0, mi(this.replayStepsSeries ?? this.replayCoarse, e)));
|
|
4183
4191
|
}
|
|
4184
4192
|
feedReplayPrice(e, t) {
|
|
4185
4193
|
let n = this.executionAdapter;
|
|
@@ -4201,8 +4209,8 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
4201
4209
|
if (i.time <= n.fedTime) return;
|
|
4202
4210
|
let a = e.slice(X(e, n.fedTime), t + 1);
|
|
4203
4211
|
n.fedTime = i.time;
|
|
4204
|
-
let o = Math.ceil(a.length /
|
|
4205
|
-
for (let e = 0; e < a.length; e += o) for (let [t, n] of
|
|
4212
|
+
let o = Math.ceil(a.length / _i);
|
|
4213
|
+
for (let e = 0; e < a.length; e += o) for (let [t, n] of vi(a.slice(e, e + o))) r.setMarkPrice(t, n);
|
|
4206
4214
|
this.tradingManager.setCurrentPrice(i.close);
|
|
4207
4215
|
}
|
|
4208
4216
|
getReplayBarIndex() {
|
|
@@ -4213,7 +4221,7 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
4213
4221
|
}
|
|
4214
4222
|
replaySeekToBar(e) {
|
|
4215
4223
|
let t = this.replayStepsSeries;
|
|
4216
|
-
this.replaySeek(t && this.replayCoarse ?
|
|
4224
|
+
this.replaySeek(t && this.replayCoarse ? bi(t, this.replayCoarse, e) : e);
|
|
4217
4225
|
}
|
|
4218
4226
|
replayPause() {
|
|
4219
4227
|
this.setHeldState("paused") || this.replayManager.pause();
|
|
@@ -4254,7 +4262,7 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
4254
4262
|
let { x: r, y: c } = this.drawingManager.anchorPoint(t.type, e, n);
|
|
4255
4263
|
i = Math.min(i, r), a = Math.max(a, r), o = Math.min(o, c), s = Math.max(s, c);
|
|
4256
4264
|
}
|
|
4257
|
-
return
|
|
4265
|
+
return Yr.has(t.type) ? [i, a] = [r.x, r.x + r.width] : t.type === "horizontalRay" && (a = r.x + r.width), Xr.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 ? {
|
|
4258
4266
|
x: i,
|
|
4259
4267
|
y: o,
|
|
4260
4268
|
width: a - i,
|
|
@@ -4303,14 +4311,14 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
4303
4311
|
});
|
|
4304
4312
|
}
|
|
4305
4313
|
restoreIndicators(e, t) {
|
|
4306
|
-
let n =
|
|
4314
|
+
let n = Qr(e), r = /* @__PURE__ */ new Map();
|
|
4307
4315
|
this.unrestoredIndicators = [];
|
|
4308
4316
|
let i = new Set(this.indicatorEngine.getAvailableIndicators().map((e) => e.id)), a = [], o = /* @__PURE__ */ new Set();
|
|
4309
4317
|
if (t) {
|
|
4310
4318
|
let e = new Map(n.map((e) => [e.instanceId, e])), t = this.getIndicatorSetup();
|
|
4311
4319
|
for (let n of t) {
|
|
4312
4320
|
let t = e.get(n.instanceId);
|
|
4313
|
-
t &&
|
|
4321
|
+
t && $r(n, t) && o.add(n.instanceId);
|
|
4314
4322
|
}
|
|
4315
4323
|
for (let e of t) o.has(e.instanceId) || this.removeIndicator(e.instanceId);
|
|
4316
4324
|
for (let e of [...o]) this.indicatorEngine.getIndicatorConfig(e) || o.delete(e);
|
|
@@ -4485,7 +4493,7 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
4485
4493
|
}
|
|
4486
4494
|
let o = this.getIndicatorSetup();
|
|
4487
4495
|
if (JSON.stringify(n) === JSON.stringify(o)) return a;
|
|
4488
|
-
let s = performance.now(), c = this.undoRedoManager.last(), l = e !== void 0 && c?.type === "indicators" && c.indicators?.subject === e && s - (c.indicators.at ?? 0) <
|
|
4496
|
+
let s = performance.now(), c = this.undoRedoManager.last(), l = e !== void 0 && c?.type === "indicators" && c.indicators?.subject === e && s - (c.indicators.at ?? 0) < Hr && JSON.stringify(c.indicators.after) === JSON.stringify(n), u = {
|
|
4489
4497
|
type: "indicators",
|
|
4490
4498
|
before: null,
|
|
4491
4499
|
after: null
|
|
@@ -4496,7 +4504,7 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
4496
4504
|
...c.indicators,
|
|
4497
4505
|
after: o,
|
|
4498
4506
|
at: s,
|
|
4499
|
-
...
|
|
4507
|
+
...Wr([...c.indicators.renames ?? [], ...r])
|
|
4500
4508
|
}
|
|
4501
4509
|
}) : this.undoRedoManager.push({
|
|
4502
4510
|
...u,
|
|
@@ -4505,7 +4513,7 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
4505
4513
|
after: o,
|
|
4506
4514
|
subject: e,
|
|
4507
4515
|
at: s,
|
|
4508
|
-
...
|
|
4516
|
+
...Wr(r)
|
|
4509
4517
|
}
|
|
4510
4518
|
}), a;
|
|
4511
4519
|
}
|
|
@@ -4539,7 +4547,7 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
4539
4547
|
let t = this.layoutManager.getPanels().find((t) => t.id === e);
|
|
4540
4548
|
if (!t || t.position !== "top" && t.position !== "bottom" || this.layoutManager.isPanelShownCollapsed(e)) return null;
|
|
4541
4549
|
let n = this.buildPanelRenderInfos().find((t) => t.instanceId === e);
|
|
4542
|
-
return !n || n.viewport.chartRect.height <
|
|
4550
|
+
return !n || n.viewport.chartRect.height < Ur ? null : {
|
|
4543
4551
|
...n.viewport,
|
|
4544
4552
|
data: this.getDisplayData()
|
|
4545
4553
|
};
|
|
@@ -4646,14 +4654,14 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
4646
4654
|
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 = "";
|
|
4647
4655
|
}
|
|
4648
4656
|
createChartRenderer(e) {
|
|
4649
|
-
let t =
|
|
4657
|
+
let t = An(e, (e) => this.pluginManager.getChartType(e));
|
|
4650
4658
|
return t instanceof ze && t.setPriceText((e) => this.formatPrice(e)), t;
|
|
4651
4659
|
}
|
|
4652
4660
|
crosshairSeries() {
|
|
4653
4661
|
return this.isTimeAligned() ? this.series.bars() : this.getDisplayData();
|
|
4654
4662
|
}
|
|
4655
4663
|
getDisplayData() {
|
|
4656
|
-
let e = this.series.bars(), t = this.options.chartType === "rangeBars" ?
|
|
4664
|
+
let e = this.series.bars(), t = this.options.chartType === "rangeBars" ? Dn(e, (e) => this.stepAt(e)) : void 0;
|
|
4657
4665
|
if (this.displayDataCache && t === this.displayDataStep) return this.displayDataCache;
|
|
4658
4666
|
if (e.length === 0) return e;
|
|
4659
4667
|
let n = this.displaySeries(e, t);
|
|
@@ -4661,8 +4669,8 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
4661
4669
|
}
|
|
4662
4670
|
displaySeries(e, t) {
|
|
4663
4671
|
let n = this.options.chartType, r = (e) => this.pluginManager.getChartType(e);
|
|
4664
|
-
if (n !== "pointAndFigure" || r(n)) return
|
|
4665
|
-
let { columns: i, boxSize: a } =
|
|
4672
|
+
if (n !== "pointAndFigure" || r(n)) return jn(n, e, r, this.chartTypeOptions, t, this.reshapeMemo);
|
|
4673
|
+
let { columns: i, boxSize: a } = mn(e, this.chartTypeOptions, this.reshapeMemo);
|
|
4666
4674
|
return this.chartRenderer instanceof tt && this.chartRenderer.setBoxSize(a), i;
|
|
4667
4675
|
}
|
|
4668
4676
|
recalcIndicatorsFrom(e, t) {
|
|
@@ -4734,7 +4742,7 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
4734
4742
|
}
|
|
4735
4743
|
fitPriceScale(e, t) {
|
|
4736
4744
|
if (e.length === 0) return;
|
|
4737
|
-
let n = Math.max(0, t.visibleRange.from), r = Math.min(t.visibleRange.to, e.length - 1), i =
|
|
4745
|
+
let n = Math.max(0, t.visibleRange.from), r = Math.min(t.visibleRange.to, e.length - 1), i = ai(ai(m(e, n, r, 0), this.indicatorEngine.getOverlayPriceRange(n, r)), this.features.compareSymbols && this.comparesDrawn() ? this.compareRenderer.getPriceRange(e, t) : null), a = this.features.volume && this.volumeRenderer.isVisible() && ii(e, n, r) ? this.volumeRenderer.getHeightRatio() + Vr : D;
|
|
4738
4746
|
this.viewport.setScaleMargins(this.viewport.isInvertScale() ? {
|
|
4739
4747
|
top: a,
|
|
4740
4748
|
bottom: D
|
|
@@ -4761,7 +4769,7 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
4761
4769
|
fitLeftAxisWidth() {
|
|
4762
4770
|
let e = this.leftViewport;
|
|
4763
4771
|
if (!e) return !1;
|
|
4764
|
-
let t = this.themeManager.getTheme(), n =
|
|
4772
|
+
let t = this.themeManager.getTheme(), n = nr({
|
|
4765
4773
|
min: e.priceRange.min,
|
|
4766
4774
|
max: e.priceRange.max,
|
|
4767
4775
|
lastPrice: null,
|
|
@@ -4770,12 +4778,12 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
4770
4778
|
fontFamily: t.font.family,
|
|
4771
4779
|
fontSizeSmall: t.font.sizeSmall,
|
|
4772
4780
|
measure: (e, t) => this.measureText(e, t)
|
|
4773
|
-
}), r =
|
|
4781
|
+
}), r = rr(this.leftAxisWidth, n);
|
|
4774
4782
|
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);
|
|
4775
4783
|
}
|
|
4776
4784
|
fitPriceAxisWidth() {
|
|
4777
4785
|
if (!this.features.priceAxis) return !1;
|
|
4778
|
-
let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n =
|
|
4786
|
+
let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n = nr({
|
|
4779
4787
|
min: e.min,
|
|
4780
4788
|
max: e.max,
|
|
4781
4789
|
lastPrice: this.currentPriceLine.getPrice(),
|
|
@@ -4786,14 +4794,14 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
4786
4794
|
fontFamily: t.font.family,
|
|
4787
4795
|
fontSizeSmall: t.font.sizeSmall,
|
|
4788
4796
|
measure: (e, t) => this.measureText(e, t)
|
|
4789
|
-
}), r =
|
|
4797
|
+
}), r = rr(this.priceAxisWidth, n);
|
|
4790
4798
|
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);
|
|
4791
4799
|
}
|
|
4792
4800
|
measureText(e, t) {
|
|
4793
4801
|
let n = this.engine.layerManager.getLayer(r.Main)?.ctx;
|
|
4794
|
-
if (n?.canvas.isConnected) return this.labelWidths.get(e, t, () =>
|
|
4802
|
+
if (n?.canvas.isConnected) return this.labelWidths.get(e, t, () => ei(n, e, t));
|
|
4795
4803
|
let i = n ?? this.detachedMeasureContext();
|
|
4796
|
-
return i ?
|
|
4804
|
+
return i ? ei(i, e, t) : e.length * 7;
|
|
4797
4805
|
}
|
|
4798
4806
|
detachedMeasureContext() {
|
|
4799
4807
|
return this.measureCtx === void 0 && (this.measureCtx = typeof document < "u" ? document.createElement("canvas").getContext("2d") : null), this.measureCtx;
|
|
@@ -4834,7 +4842,7 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
4834
4842
|
buildPanelRenderInfos() {
|
|
4835
4843
|
if (this.panelInfoCache) return this.panelInfoCache;
|
|
4836
4844
|
let e = this.getResolvedLayout(), t = this.viewport.getState(), { from: n, to: r } = t.visibleRange, i = e.panels.map((e) => {
|
|
4837
|
-
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) ?? { ...
|
|
4845
|
+
let i = e.config.logScale ? this.indicatorEngine.getPaneValueRange(e.config.id, n, r, !0) : null, a = i ?? this.indicatorEngine.getPaneValueRange(e.config.id, n, r) ?? { ...Fr }, o = {
|
|
4838
4846
|
x: e.rect.x,
|
|
4839
4847
|
y: e.rect.y + 20,
|
|
4840
4848
|
width: e.rect.width,
|
|
@@ -4919,7 +4927,7 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
4919
4927
|
});
|
|
4920
4928
|
}
|
|
4921
4929
|
drawOverlayPlugins(e, t) {
|
|
4922
|
-
let n =
|
|
4930
|
+
let n = cr(this.pluginManager.getOverlays(), t);
|
|
4923
4931
|
if (n.length === 0) return;
|
|
4924
4932
|
let r = {
|
|
4925
4933
|
viewport: this.viewport.getState(),
|
|
@@ -4940,7 +4948,7 @@ var Wr = 20, Gr = 8, Kr = 10, qr = {
|
|
|
4940
4948
|
};
|
|
4941
4949
|
}
|
|
4942
4950
|
};
|
|
4943
|
-
function
|
|
4951
|
+
function Qr(e) {
|
|
4944
4952
|
let t = new Map(e.map((e) => [e.instanceId, e])), n = [], r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = (e) => {
|
|
4945
4953
|
if (r.has(e.instanceId) || i.has(e.instanceId)) return;
|
|
4946
4954
|
i.add(e.instanceId);
|
|
@@ -4954,19 +4962,19 @@ function Zr(e) {
|
|
|
4954
4962
|
for (let t of e) a(t);
|
|
4955
4963
|
return n;
|
|
4956
4964
|
}
|
|
4957
|
-
function
|
|
4965
|
+
function $r(e, t) {
|
|
4958
4966
|
return e.id === t.id && (e.pane ?? null) === (t.pane ?? null) && (e.scale ?? null) === (t.scale ?? null) && e.position === void 0 == (t.position === void 0);
|
|
4959
4967
|
}
|
|
4960
|
-
function
|
|
4968
|
+
function ei(e, t, n) {
|
|
4961
4969
|
let r = e.font;
|
|
4962
4970
|
e.font = n;
|
|
4963
4971
|
let i = e.measureText(t).width;
|
|
4964
4972
|
return e.font = r, i;
|
|
4965
4973
|
}
|
|
4966
|
-
var
|
|
4967
|
-
function
|
|
4974
|
+
var ti = 300;
|
|
4975
|
+
function ni(e) {
|
|
4968
4976
|
let t = {}, n = e.family;
|
|
4969
|
-
typeof n == "string" && n.trim() !== "" && n.length <=
|
|
4977
|
+
typeof n == "string" && n.trim() !== "" && n.length <= ti && !/[;{}<>\\]|\/\*/.test(n) && (t.family = n);
|
|
4970
4978
|
for (let n of [
|
|
4971
4979
|
"sizeSmall",
|
|
4972
4980
|
"sizeMedium",
|
|
@@ -4977,15 +4985,15 @@ function ti(e) {
|
|
|
4977
4985
|
}
|
|
4978
4986
|
return t;
|
|
4979
4987
|
}
|
|
4980
|
-
function
|
|
4988
|
+
function ri(e) {
|
|
4981
4989
|
let t = e.tagRadius;
|
|
4982
4990
|
return typeof t == "number" && Number.isFinite(t) && t >= 0 ? { tagRadius: Math.min(t, 999) } : {};
|
|
4983
4991
|
}
|
|
4984
|
-
function
|
|
4992
|
+
function ii(e, t, n) {
|
|
4985
4993
|
for (let r = t; r <= n; r++) if (e[r].volume > 0) return !0;
|
|
4986
4994
|
return !1;
|
|
4987
4995
|
}
|
|
4988
|
-
function
|
|
4996
|
+
function ai(e, t) {
|
|
4989
4997
|
return e ? t ? {
|
|
4990
4998
|
min: Math.min(e.min, t.min),
|
|
4991
4999
|
max: Math.max(e.max, t.max)
|
|
@@ -5006,14 +5014,14 @@ function J(e) {
|
|
|
5006
5014
|
bars: e.bars
|
|
5007
5015
|
};
|
|
5008
5016
|
}
|
|
5009
|
-
var
|
|
5017
|
+
var oi = 8e3, si = new Set([
|
|
5010
5018
|
"candlestick",
|
|
5011
5019
|
"line",
|
|
5012
5020
|
"area",
|
|
5013
5021
|
"bar",
|
|
5014
5022
|
"hollowCandle"
|
|
5015
|
-
]),
|
|
5016
|
-
function
|
|
5023
|
+
]), ci = 10, li = 50, ui = .001;
|
|
5024
|
+
function di(e) {
|
|
5017
5025
|
return {
|
|
5018
5026
|
price: null,
|
|
5019
5027
|
fedTime: null,
|
|
@@ -5028,41 +5036,41 @@ function ui(e) {
|
|
|
5028
5036
|
held: null
|
|
5029
5037
|
};
|
|
5030
5038
|
}
|
|
5031
|
-
function
|
|
5039
|
+
function fi(e, t) {
|
|
5032
5040
|
let n = e[t + 1];
|
|
5033
5041
|
return n ? n.time - e[t].time : Z(e);
|
|
5034
5042
|
}
|
|
5035
|
-
function
|
|
5043
|
+
function pi(e, t, n) {
|
|
5036
5044
|
let r = e.fedTime;
|
|
5037
5045
|
if (r === null || !t || t.length === 0 || n.length === 0) return;
|
|
5038
|
-
let i =
|
|
5046
|
+
let i = fi(t, Q(t, r)), a = r + (Number.isFinite(i) ? e.fedFraction * i : 0), o = Q(n, a), s = n[o].time;
|
|
5039
5047
|
if (s > a) return;
|
|
5040
|
-
let c =
|
|
5048
|
+
let c = fi(n, o);
|
|
5041
5049
|
if (a === s && o > 0) {
|
|
5042
5050
|
e.fedTime = n[o - 1].time, e.fedFraction = 1;
|
|
5043
5051
|
return;
|
|
5044
5052
|
}
|
|
5045
5053
|
e.fedTime = s, e.fedFraction = Number.isFinite(c) && c > 0 ? Math.min(1, (a - s) / c) : 0;
|
|
5046
5054
|
}
|
|
5047
|
-
function
|
|
5055
|
+
function mi(e, t) {
|
|
5048
5056
|
let n = X(e, t), r = e.length - 1;
|
|
5049
5057
|
return n > r && r >= 0 && e[r].time + Z(e) <= t ? r : Math.max(-1, n - 2);
|
|
5050
5058
|
}
|
|
5051
|
-
function
|
|
5059
|
+
function hi(e) {
|
|
5052
5060
|
let t = Infinity;
|
|
5053
5061
|
for (let n = Math.max(1, e.length - 10); n < e.length; n++) t = Math.min(t, e[n].time - e[n - 1].time);
|
|
5054
5062
|
return t;
|
|
5055
5063
|
}
|
|
5056
|
-
function
|
|
5057
|
-
if (!(
|
|
5058
|
-
let n = Math.max(0, e.length -
|
|
5064
|
+
function gi(e, t) {
|
|
5065
|
+
if (!(hi(e) < hi(t))) return !1;
|
|
5066
|
+
let n = Math.max(0, e.length - li);
|
|
5059
5067
|
for (let r = n; r < e.length; r++) {
|
|
5060
|
-
let n = t[Q(t, e[r].time)], i = (n.high - n.low) *
|
|
5068
|
+
let n = t[Q(t, e[r].time)], i = (n.high - n.low) * ui + 2 ** -52;
|
|
5061
5069
|
if (e[r].close > n.high + i || e[r].close < n.low - i) return !1;
|
|
5062
5070
|
}
|
|
5063
5071
|
return !0;
|
|
5064
5072
|
}
|
|
5065
|
-
var
|
|
5073
|
+
var _i = 500;
|
|
5066
5074
|
function Y(e, t) {
|
|
5067
5075
|
let n = 0, r = e.length;
|
|
5068
5076
|
for (; n < r;) {
|
|
@@ -5079,7 +5087,7 @@ function X(e, t) {
|
|
|
5079
5087
|
}
|
|
5080
5088
|
return n;
|
|
5081
5089
|
}
|
|
5082
|
-
function
|
|
5090
|
+
function vi(e) {
|
|
5083
5091
|
let t = 0, n = 0;
|
|
5084
5092
|
for (let r = 1; r < e.length; r++) e[r].low < e[t].low && (t = r), e[r].high > e[n].high && (n = r);
|
|
5085
5093
|
let r = [e[t].low, e[t].time], i = [e[n].high, e[n].time], a = t === n ? e[t].close >= e[t].open : t < n, o = e[e.length - 1];
|
|
@@ -5090,9 +5098,9 @@ function Z(e) {
|
|
|
5090
5098
|
for (let n = Math.max(1, e.length - 10); n < e.length; n++) t = Math.max(t, e[n].time - e[n - 1].time);
|
|
5091
5099
|
return t > 0 ? t : Infinity;
|
|
5092
5100
|
}
|
|
5093
|
-
function
|
|
5101
|
+
function yi(e, t) {
|
|
5094
5102
|
if (t.length === 0) return null;
|
|
5095
|
-
let n = t[t.length - 1].time + Z(t), r = e.filter((e) =>
|
|
5103
|
+
let n = t[t.length - 1].time + Z(t), r = e.filter((e) => Rn(e) && e.time >= t[0].time && e.time < n).sort((e, t) => e.time - t.time), i = [];
|
|
5096
5104
|
for (let e of r) (i.length === 0 || i[i.length - 1].time !== e.time) && i.push(e);
|
|
5097
5105
|
if (i.length === 0) return null;
|
|
5098
5106
|
let a = t.findIndex((e) => e.time >= i[0].time);
|
|
@@ -5108,26 +5116,26 @@ function Q(e, t) {
|
|
|
5108
5116
|
}
|
|
5109
5117
|
return n;
|
|
5110
5118
|
}
|
|
5111
|
-
function
|
|
5119
|
+
function bi(e, t, n) {
|
|
5112
5120
|
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;
|
|
5113
5121
|
for (let t = 0; t < e.length && e[t].time < i; t++) a = t;
|
|
5114
5122
|
return Math.max(0, a);
|
|
5115
5123
|
}
|
|
5116
|
-
function
|
|
5124
|
+
function xi(e, t, n) {
|
|
5117
5125
|
let r = n;
|
|
5118
5126
|
for (; r > 0 && t[r - 1].time >= e.time;) r--;
|
|
5119
5127
|
let i = {
|
|
5120
5128
|
...t[r],
|
|
5121
5129
|
time: e.time
|
|
5122
5130
|
};
|
|
5123
|
-
for (let e = r + 1; e <= n; e++) i =
|
|
5131
|
+
for (let e = r + 1; e <= n; e++) i = Ti(i, t[e]);
|
|
5124
5132
|
return i;
|
|
5125
5133
|
}
|
|
5126
|
-
function
|
|
5134
|
+
function Si(e, t, n, r) {
|
|
5127
5135
|
let i = e[n + 1], a = t[r + 1];
|
|
5128
5136
|
return i !== void 0 && a !== void 0 && i.time >= a.time;
|
|
5129
5137
|
}
|
|
5130
|
-
function
|
|
5138
|
+
function Ci(e, t) {
|
|
5131
5139
|
let n = /* @__PURE__ */ new Map();
|
|
5132
5140
|
for (let r of e) {
|
|
5133
5141
|
let e = t[Q(t, r.time)].time, i = n.get(e);
|
|
@@ -5135,10 +5143,10 @@ function Si(e, t) {
|
|
|
5135
5143
|
}
|
|
5136
5144
|
return n;
|
|
5137
5145
|
}
|
|
5138
|
-
function
|
|
5146
|
+
function wi() {
|
|
5139
5147
|
return typeof matchMedia == "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
5140
5148
|
}
|
|
5141
|
-
function
|
|
5149
|
+
function Ti(e, t) {
|
|
5142
5150
|
return {
|
|
5143
5151
|
time: e.time,
|
|
5144
5152
|
open: e.open,
|
|
@@ -5150,26 +5158,26 @@ function wi(e, t) {
|
|
|
5150
5158
|
}
|
|
5151
5159
|
//#endregion
|
|
5152
5160
|
//#region src/io/parseOHLCV.ts
|
|
5153
|
-
var
|
|
5161
|
+
var Ei = [
|
|
5154
5162
|
"time",
|
|
5155
5163
|
"timestamp",
|
|
5156
5164
|
"date",
|
|
5157
5165
|
"datetime",
|
|
5158
5166
|
"t"
|
|
5159
|
-
],
|
|
5167
|
+
], Di = ["open", "o"], Oi = ["high", "h"], ki = ["low", "l"], Ai = ["close", "c"], ji = [
|
|
5160
5168
|
"volume",
|
|
5161
5169
|
"vol",
|
|
5162
5170
|
"v"
|
|
5163
5171
|
];
|
|
5164
|
-
function
|
|
5172
|
+
function Mi(e) {
|
|
5165
5173
|
let t = e.trim();
|
|
5166
|
-
return t ? t[0] === "[" || t[0] === "{" ?
|
|
5174
|
+
return t ? t[0] === "[" || t[0] === "{" ? Ni(t) : Pi(t) : {
|
|
5167
5175
|
data: [],
|
|
5168
5176
|
rowCount: 0,
|
|
5169
5177
|
skipped: 0
|
|
5170
5178
|
};
|
|
5171
5179
|
}
|
|
5172
|
-
function
|
|
5180
|
+
function Ni(e) {
|
|
5173
5181
|
let t;
|
|
5174
5182
|
try {
|
|
5175
5183
|
t = JSON.parse(e);
|
|
@@ -5179,19 +5187,19 @@ function Mi(e) {
|
|
|
5179
5187
|
if (!Array.isArray(t)) throw Error("Expected a JSON array of OHLCV rows");
|
|
5180
5188
|
let n = [], r = 0;
|
|
5181
5189
|
for (let e of t) {
|
|
5182
|
-
let t = Array.isArray(e) ?
|
|
5190
|
+
let t = Array.isArray(e) ? zi(e) : Ri(e);
|
|
5183
5191
|
t ? n.push(t) : r++;
|
|
5184
5192
|
}
|
|
5185
|
-
return
|
|
5193
|
+
return Vi(n, t.length, r);
|
|
5186
5194
|
}
|
|
5187
|
-
function
|
|
5195
|
+
function Pi(e) {
|
|
5188
5196
|
let t = e.split(/\r?\n/).filter((e) => e.trim().length > 0);
|
|
5189
5197
|
if (t.length === 0) return {
|
|
5190
5198
|
data: [],
|
|
5191
5199
|
rowCount: 0,
|
|
5192
5200
|
skipped: 0
|
|
5193
5201
|
};
|
|
5194
|
-
let n =
|
|
5202
|
+
let n = Fi(t[0]), r = Ii(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? Li(r) : {
|
|
5195
5203
|
time: 0,
|
|
5196
5204
|
open: 1,
|
|
5197
5205
|
high: 2,
|
|
@@ -5202,7 +5210,7 @@ function Ni(e) {
|
|
|
5202
5210
|
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");
|
|
5203
5211
|
let o = [], s = 0;
|
|
5204
5212
|
for (let e = +!!i; e < t.length; e++) {
|
|
5205
|
-
let r =
|
|
5213
|
+
let r = Ii(t[e], n), i = Bi(r[a.time]), c = $(r[a.open]), l = $(r[a.high]), u = $(r[a.low]), d = $(r[a.close]), f = a.volume >= 0 ? Number(r[a.volume]) : 0;
|
|
5206
5214
|
if (i === null || ![
|
|
5207
5215
|
c,
|
|
5208
5216
|
l,
|
|
@@ -5221,9 +5229,9 @@ function Ni(e) {
|
|
|
5221
5229
|
volume: Number.isFinite(f) ? f : 0
|
|
5222
5230
|
});
|
|
5223
5231
|
}
|
|
5224
|
-
return
|
|
5232
|
+
return Vi(o, t.length - +!!i, s);
|
|
5225
5233
|
}
|
|
5226
|
-
function
|
|
5234
|
+
function Fi(e) {
|
|
5227
5235
|
let t = {
|
|
5228
5236
|
",": 0,
|
|
5229
5237
|
";": 0,
|
|
@@ -5235,7 +5243,7 @@ function Pi(e) {
|
|
|
5235
5243
|
for (let [e, i] of Object.entries(t)) i > r && (n = e, r = i);
|
|
5236
5244
|
return n;
|
|
5237
5245
|
}
|
|
5238
|
-
function
|
|
5246
|
+
function Ii(e, t) {
|
|
5239
5247
|
let n = [], r = "", i = !1;
|
|
5240
5248
|
for (let a = 0; a < e.length; a++) {
|
|
5241
5249
|
let o = e[a];
|
|
@@ -5243,25 +5251,25 @@ function Fi(e, t) {
|
|
|
5243
5251
|
}
|
|
5244
5252
|
return n.push(r), n;
|
|
5245
5253
|
}
|
|
5246
|
-
function
|
|
5254
|
+
function Li(e) {
|
|
5247
5255
|
let t = (t) => e.findIndex((e) => t.includes(e));
|
|
5248
5256
|
return {
|
|
5249
|
-
time: t(
|
|
5250
|
-
open: t(
|
|
5251
|
-
high: t(
|
|
5252
|
-
low: t(
|
|
5253
|
-
close: t(
|
|
5254
|
-
volume: t(
|
|
5257
|
+
time: t(Ei),
|
|
5258
|
+
open: t(Di),
|
|
5259
|
+
high: t(Oi),
|
|
5260
|
+
low: t(ki),
|
|
5261
|
+
close: t(Ai),
|
|
5262
|
+
volume: t(ji)
|
|
5255
5263
|
};
|
|
5256
5264
|
}
|
|
5257
|
-
function
|
|
5265
|
+
function Ri(e) {
|
|
5258
5266
|
let t = (t) => {
|
|
5259
5267
|
for (let n of t) {
|
|
5260
5268
|
if (e[n] !== void 0) return e[n];
|
|
5261
5269
|
let t = n.toUpperCase();
|
|
5262
5270
|
if (e[t] !== void 0) return e[t];
|
|
5263
5271
|
}
|
|
5264
|
-
}, n =
|
|
5272
|
+
}, n = Bi(String(t(Ei) ?? "")), r = Number(t(Di)), i = Number(t(Oi)), a = Number(t(ki)), o = Number(t(Ai)), s = Number(t(ji) ?? 0);
|
|
5265
5273
|
return n === null || ![
|
|
5266
5274
|
r,
|
|
5267
5275
|
i,
|
|
@@ -5276,9 +5284,9 @@ function Li(e) {
|
|
|
5276
5284
|
volume: Number.isFinite(s) ? s : 0
|
|
5277
5285
|
};
|
|
5278
5286
|
}
|
|
5279
|
-
function
|
|
5287
|
+
function zi(e) {
|
|
5280
5288
|
if (e.length < 5) return null;
|
|
5281
|
-
let t =
|
|
5289
|
+
let t = Bi(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;
|
|
5282
5290
|
return t === null || ![
|
|
5283
5291
|
n,
|
|
5284
5292
|
r,
|
|
@@ -5296,7 +5304,7 @@ function Ri(e) {
|
|
|
5296
5304
|
function $(e) {
|
|
5297
5305
|
return e === void 0 || e.trim() === "" ? NaN : Number(e);
|
|
5298
5306
|
}
|
|
5299
|
-
function
|
|
5307
|
+
function Bi(e) {
|
|
5300
5308
|
let t = e.trim();
|
|
5301
5309
|
if (!t) return null;
|
|
5302
5310
|
let n = Number(t);
|
|
@@ -5304,7 +5312,7 @@ function zi(e) {
|
|
|
5304
5312
|
let r = Date.parse(t);
|
|
5305
5313
|
return Number.isFinite(r) ? r : null;
|
|
5306
5314
|
}
|
|
5307
|
-
function
|
|
5315
|
+
function Vi(e, t, n) {
|
|
5308
5316
|
e.sort((e, t) => e.time - t.time);
|
|
5309
5317
|
let r = [];
|
|
5310
5318
|
for (let t of e) r.length > 0 && r[r.length - 1].time === t.time ? r[r.length - 1] = t : r.push(t);
|
|
@@ -5316,7 +5324,7 @@ function Bi(e, t, n) {
|
|
|
5316
5324
|
}
|
|
5317
5325
|
//#endregion
|
|
5318
5326
|
//#region src/io/DragDropImporter.ts
|
|
5319
|
-
var
|
|
5327
|
+
var Hi = class {
|
|
5320
5328
|
host;
|
|
5321
5329
|
overlay = null;
|
|
5322
5330
|
callbacks;
|
|
@@ -5337,19 +5345,19 @@ var Vi = class {
|
|
|
5337
5345
|
this.host.removeEventListener("dragenter", this.bound.dragenter), this.host.removeEventListener("dragover", this.bound.dragover), this.host.removeEventListener("dragleave", this.bound.dragleave), this.host.removeEventListener("drop", this.bound.drop), this.hideOverlay();
|
|
5338
5346
|
}
|
|
5339
5347
|
onDragEnter(e) {
|
|
5340
|
-
|
|
5348
|
+
Ui(e) && (e.preventDefault(), this.depth++, this.showOverlay());
|
|
5341
5349
|
}
|
|
5342
5350
|
onDragOver(e) {
|
|
5343
|
-
|
|
5351
|
+
Ui(e) && (e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = "copy"));
|
|
5344
5352
|
}
|
|
5345
5353
|
onDragLeave(e) {
|
|
5346
|
-
|
|
5354
|
+
Ui(e) && (this.depth = Math.max(0, this.depth - 1), this.depth === 0 && this.hideOverlay());
|
|
5347
5355
|
}
|
|
5348
5356
|
async onDrop(e) {
|
|
5349
5357
|
e.preventDefault(), this.depth = 0, this.hideOverlay();
|
|
5350
5358
|
let t = e.dataTransfer?.files?.[0];
|
|
5351
5359
|
if (t) try {
|
|
5352
|
-
let e =
|
|
5360
|
+
let e = Mi(await t.text());
|
|
5353
5361
|
if (e.data.length === 0) throw Error(`No valid OHLCV rows found in "${t.name}"`);
|
|
5354
5362
|
this.callbacks.onData(e.data, e, t);
|
|
5355
5363
|
} catch (e) {
|
|
@@ -5380,12 +5388,12 @@ var Vi = class {
|
|
|
5380
5388
|
this.overlay?.remove(), this.overlay = null;
|
|
5381
5389
|
}
|
|
5382
5390
|
};
|
|
5383
|
-
function
|
|
5391
|
+
function Ui(e) {
|
|
5384
5392
|
return e.dataTransfer?.types?.includes("Files") ?? !1;
|
|
5385
5393
|
}
|
|
5386
5394
|
//#endregion
|
|
5387
5395
|
//#region src/state/layoutStorage.ts
|
|
5388
|
-
function
|
|
5396
|
+
function Wi(e) {
|
|
5389
5397
|
let t = {
|
|
5390
5398
|
id: e.id,
|
|
5391
5399
|
name: e.name,
|
|
@@ -5393,11 +5401,11 @@ function Ui(e) {
|
|
|
5393
5401
|
};
|
|
5394
5402
|
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;
|
|
5395
5403
|
}
|
|
5396
|
-
var
|
|
5397
|
-
function
|
|
5404
|
+
var Gi = (e, t) => t.updatedAt - e.updatedAt;
|
|
5405
|
+
function Ki(e) {
|
|
5398
5406
|
if (typeof e != "object" || !e) return null;
|
|
5399
5407
|
let t = e;
|
|
5400
|
-
return typeof t.id != "string" || !t.id || typeof t.name != "string" || typeof t.updatedAt != "number" || !Number.isFinite(t.updatedAt) ? null :
|
|
5408
|
+
return typeof t.id != "string" || !t.id || typeof t.name != "string" || typeof t.updatedAt != "number" || !Number.isFinite(t.updatedAt) ? null : Wi({
|
|
5401
5409
|
id: t.id,
|
|
5402
5410
|
name: t.name,
|
|
5403
5411
|
updatedAt: t.updatedAt,
|
|
@@ -5406,17 +5414,17 @@ function Gi(e) {
|
|
|
5406
5414
|
kind: typeof t.kind == "string" ? t.kind : void 0
|
|
5407
5415
|
});
|
|
5408
5416
|
}
|
|
5409
|
-
function
|
|
5410
|
-
let t =
|
|
5417
|
+
function qi(e) {
|
|
5418
|
+
let t = Ki(e), n = t ? e.content : void 0;
|
|
5411
5419
|
return t && typeof n == "string" ? {
|
|
5412
5420
|
...t,
|
|
5413
5421
|
content: n
|
|
5414
5422
|
} : null;
|
|
5415
5423
|
}
|
|
5416
|
-
function
|
|
5424
|
+
function Ji(e = []) {
|
|
5417
5425
|
let t = new Map(e.map((e) => [e.id, { ...e }]));
|
|
5418
5426
|
return {
|
|
5419
|
-
list: () => [...t.values()].map(
|
|
5427
|
+
list: () => [...t.values()].map(Wi).sort(Gi),
|
|
5420
5428
|
load: (e) => {
|
|
5421
5429
|
let n = t.get(e);
|
|
5422
5430
|
return n ? { ...n } : null;
|
|
@@ -5429,7 +5437,7 @@ function qi(e = []) {
|
|
|
5429
5437
|
}
|
|
5430
5438
|
};
|
|
5431
5439
|
}
|
|
5432
|
-
function
|
|
5440
|
+
function Yi(e = "tcw:layouts:") {
|
|
5433
5441
|
let t = `${e}index`, n = (t) => `${e}item:${t}`, r = () => {
|
|
5434
5442
|
let e;
|
|
5435
5443
|
try {
|
|
@@ -5437,10 +5445,10 @@ function Ji(e = "tcw:layouts:") {
|
|
|
5437
5445
|
} catch {
|
|
5438
5446
|
return [];
|
|
5439
5447
|
}
|
|
5440
|
-
return Array.isArray(e) ? e.map(
|
|
5448
|
+
return Array.isArray(e) ? e.map(Ki).filter((e) => e !== null) : [];
|
|
5441
5449
|
}, i = (e) => localStorage.setItem(t, JSON.stringify(e));
|
|
5442
5450
|
return {
|
|
5443
|
-
list: () => r().sort(
|
|
5451
|
+
list: () => r().sort(Gi),
|
|
5444
5452
|
load: (e) => {
|
|
5445
5453
|
let t = r().find((t) => t.id === e), i = t ? localStorage.getItem(n(e)) : null;
|
|
5446
5454
|
return t && i !== null ? {
|
|
@@ -5449,7 +5457,7 @@ function Ji(e = "tcw:layouts:") {
|
|
|
5449
5457
|
} : null;
|
|
5450
5458
|
},
|
|
5451
5459
|
save: (e) => {
|
|
5452
|
-
localStorage.setItem(n(e.id), e.content), i([...r().filter((t) => t.id !== e.id),
|
|
5460
|
+
localStorage.setItem(n(e.id), e.content), i([...r().filter((t) => t.id !== e.id), Wi(e)]);
|
|
5453
5461
|
},
|
|
5454
5462
|
remove: (e) => {
|
|
5455
5463
|
i(r().filter((t) => t.id !== e)), localStorage.removeItem(n(e));
|
|
@@ -5458,14 +5466,14 @@ function Ji(e = "tcw:layouts:") {
|
|
|
5458
5466
|
}
|
|
5459
5467
|
//#endregion
|
|
5460
5468
|
//#region src/state/LayoutSession.ts
|
|
5461
|
-
var
|
|
5462
|
-
function
|
|
5469
|
+
var Xi = 80;
|
|
5470
|
+
function Zi(e) {
|
|
5463
5471
|
return e.replace(/\s+/g, " ").trim().slice(0, 80).trim() || null;
|
|
5464
5472
|
}
|
|
5465
|
-
function
|
|
5473
|
+
function Qi() {
|
|
5466
5474
|
return globalThis.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
5467
5475
|
}
|
|
5468
|
-
function
|
|
5476
|
+
function $i(e) {
|
|
5469
5477
|
let { id: t, name: n, symbol: r, timeframe: i, updatedAt: a, kind: o } = e;
|
|
5470
5478
|
return {
|
|
5471
5479
|
id: t,
|
|
@@ -5476,7 +5484,7 @@ function Qi(e) {
|
|
|
5476
5484
|
...o === void 0 ? {} : { kind: o }
|
|
5477
5485
|
};
|
|
5478
5486
|
}
|
|
5479
|
-
var
|
|
5487
|
+
var ea = class {
|
|
5480
5488
|
currentLayout = null;
|
|
5481
5489
|
savedContent = null;
|
|
5482
5490
|
dirty = !1;
|
|
@@ -5492,7 +5500,7 @@ var $i = class {
|
|
|
5492
5500
|
now;
|
|
5493
5501
|
newId;
|
|
5494
5502
|
constructor(e, t, n = {}) {
|
|
5495
|
-
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 ??
|
|
5503
|
+
this.storage = e, this.host = t, this.options = n, this.autoSave = n.autoSave ?? !0, this.debounceMs = n.debounceMs ?? 1500, this.kind = n.kind ?? "chart", this.now = n.now ?? Date.now, this.newId = n.newId ?? Qi;
|
|
5496
5504
|
}
|
|
5497
5505
|
current() {
|
|
5498
5506
|
return this.currentLayout;
|
|
@@ -5508,7 +5516,7 @@ var $i = class {
|
|
|
5508
5516
|
}
|
|
5509
5517
|
async list() {
|
|
5510
5518
|
let e = await this.storage.list();
|
|
5511
|
-
return Array.isArray(e) ? e.map(
|
|
5519
|
+
return Array.isArray(e) ? e.map(Ki).filter((e) => e !== null && (e.kind ?? "chart") === this.kind).sort((e, t) => t.updatedAt - e.updatedAt) : [];
|
|
5512
5520
|
}
|
|
5513
5521
|
save() {
|
|
5514
5522
|
return this.queue(() => {
|
|
@@ -5517,12 +5525,12 @@ var $i = class {
|
|
|
5517
5525
|
});
|
|
5518
5526
|
}
|
|
5519
5527
|
saveAs(e) {
|
|
5520
|
-
let t =
|
|
5528
|
+
let t = Zi(e);
|
|
5521
5529
|
return t ? this.queue(() => this.write(this.newId(), t)) : Promise.reject(/* @__PURE__ */ Error("A layout needs a name"));
|
|
5522
5530
|
}
|
|
5523
5531
|
open(e) {
|
|
5524
5532
|
return this.queue(async () => {
|
|
5525
|
-
let t =
|
|
5533
|
+
let t = qi(await this.storage.load(e));
|
|
5526
5534
|
if (!t || t.id !== e || (t.kind ?? "chart") !== this.kind || this.destroyed) return !1;
|
|
5527
5535
|
this.cancelTimer(), this.applying++;
|
|
5528
5536
|
try {
|
|
@@ -5532,13 +5540,13 @@ var $i = class {
|
|
|
5532
5540
|
} finally {
|
|
5533
5541
|
this.applying--;
|
|
5534
5542
|
}
|
|
5535
|
-
return this.cancelTimer(), this.currentLayout =
|
|
5543
|
+
return this.cancelTimer(), this.currentLayout = $i(t), this.savedContent = this.host.capture().content, this.dirty = !1, this.notify(), !0;
|
|
5536
5544
|
});
|
|
5537
5545
|
}
|
|
5538
5546
|
rename(e, t) {
|
|
5539
|
-
let n =
|
|
5547
|
+
let n = Zi(t);
|
|
5540
5548
|
return n ? this.queue(async () => {
|
|
5541
|
-
let t =
|
|
5549
|
+
let t = qi(await this.storage.load(e));
|
|
5542
5550
|
!t || t.id !== e || (await this.storage.save({
|
|
5543
5551
|
...t,
|
|
5544
5552
|
name: n
|
|
@@ -5616,7 +5624,7 @@ var $i = class {
|
|
|
5616
5624
|
content: n.content
|
|
5617
5625
|
};
|
|
5618
5626
|
await this.storage.save(r);
|
|
5619
|
-
let i =
|
|
5627
|
+
let i = $i(r);
|
|
5620
5628
|
return this.currentLayout = i, this.savedContent = n.content, this.dirty = !1, this.notify(), i;
|
|
5621
5629
|
}
|
|
5622
5630
|
forget() {
|
|
@@ -5637,6 +5645,6 @@ var $i = class {
|
|
|
5637
5645
|
}
|
|
5638
5646
|
};
|
|
5639
5647
|
//#endregion
|
|
5640
|
-
export {
|
|
5648
|
+
export { Un as C, B as D, R as E, un as O, Kn as S, V as T, ur as _, Ji as a, G as b, Zr as c, Nr as d, Pr as f, lr as g, dr as h, Yi as i, Lr as l, fr as m, Xi as n, Hi as o, pr as p, Zi as r, Mi as s, ea as t, Ir as u, sr as v, Vn as w, Zn as x, cr as y };
|
|
5641
5649
|
|
|
5642
|
-
//# sourceMappingURL=LayoutSession-
|
|
5650
|
+
//# sourceMappingURL=LayoutSession-CoCMrrbh.js.map
|