@tradecanvas/chart 1.59.0 → 1.59.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Chart.d.ts +6 -0
- package/dist/Chart.d.ts.map +1 -1
- package/dist/{LayoutSession-4LPRXGdW.js → LayoutSession-BUp55Atp.js} +350 -346
- package/dist/LayoutSession-BUp55Atp.js.map +1 -0
- package/dist/LayoutSession-XCrRDjDs.cjs +2 -0
- package/dist/LayoutSession-XCrRDjDs.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/widget/index.cjs +2 -2
- package/dist/widget/index.cjs.map +1 -1
- package/dist/widget/index.js +1438 -1439
- package/dist/widget/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/LayoutSession-4LPRXGdW.js.map +0 -1
- package/dist/LayoutSession-C_t8-a0s.cjs +0 -2
- package/dist/LayoutSession-C_t8-a0s.cjs.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_SCALE_MARGIN as D, PanHandler 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, priceToY as Rt, rangePresetStart as zt, readAlertOptions as Bt, registerBuiltInDrawingTools as Vt, registerBuiltInIndicators as Ht, servesTimeframe as j, sourceParam as M, timeToX as Ut, timestampToBarIndex as N, toHeikinAshi as Wt, toKagi as Gt, toLineBreak as Kt, toRangeBars as qt, toRenko as Jt, whenGpuContextFree as Yt, withResampling as P, xToBarIndex as Xt, xToTime as F, yToPrice as Zt } from "@tradecanvas/core";
|
|
3
3
|
//#region src/regularHours.ts
|
|
4
|
-
var
|
|
5
|
-
function
|
|
4
|
+
var Qt = 864e5, $t = 10;
|
|
5
|
+
function en(e, t) {
|
|
6
6
|
let n = C(e);
|
|
7
7
|
if (!n || !y(n) || t.length < 2) return null;
|
|
8
8
|
let r = (e?.sessions ?? []).flatMap((e) => {
|
|
@@ -14,34 +14,34 @@ function $t(e, t) {
|
|
|
14
14
|
});
|
|
15
15
|
if (r.length === 0) return null;
|
|
16
16
|
let i = u(t), a = Infinity;
|
|
17
|
-
for (let e = Math.max(1, t.length -
|
|
17
|
+
for (let e = Math.max(1, t.length - $t); e < t.length; e++) {
|
|
18
18
|
let n = (t[e].time - t[e - 1].time) * i;
|
|
19
19
|
n > 0 && n < a && (a = n);
|
|
20
20
|
}
|
|
21
|
-
if (!(a <
|
|
21
|
+
if (!(a < Qt)) return null;
|
|
22
22
|
let o = {
|
|
23
23
|
timeZone: n,
|
|
24
24
|
windows: r,
|
|
25
25
|
startMinute: r[0].startMinute,
|
|
26
26
|
endMinute: r[r.length - 1].endMinute
|
|
27
27
|
};
|
|
28
|
-
return (e) =>
|
|
28
|
+
return (e) => Pt(e * i, o);
|
|
29
29
|
}
|
|
30
30
|
//#endregion
|
|
31
31
|
//#region src/chartA11y.ts
|
|
32
|
-
var
|
|
32
|
+
var tn = {
|
|
33
33
|
role: "chart",
|
|
34
34
|
summary: "{what}. Last price {close}.",
|
|
35
35
|
empty: "Chart, no data.",
|
|
36
36
|
view: "Showing {count} bars, {from} to {to}. High {high}, low {low}.",
|
|
37
37
|
bar: "{time}: open {open}, high {high}, low {low}, close {close}, volume {volume}.",
|
|
38
38
|
keys: "Arrow keys scroll and zoom, Home and End go to the start and the end. Comma and period read the bars one at a time."
|
|
39
|
-
}, 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), nn = [
|
|
40
40
|
"role",
|
|
41
41
|
"aria-roledescription",
|
|
42
42
|
"aria-label",
|
|
43
43
|
"aria-describedby"
|
|
44
|
-
],
|
|
44
|
+
], rn = 400, an = 1e3, on = class {
|
|
45
45
|
live;
|
|
46
46
|
help;
|
|
47
47
|
labels;
|
|
@@ -55,20 +55,20 @@ var en = {
|
|
|
55
55
|
};
|
|
56
56
|
constructor(e, t, n = {}) {
|
|
57
57
|
this.container = e, this.source = t, this.labels = {
|
|
58
|
-
...
|
|
58
|
+
...tn,
|
|
59
59
|
...n
|
|
60
60
|
};
|
|
61
|
-
for (let t of
|
|
62
|
-
e.setAttribute("role", "application"), this.help =
|
|
61
|
+
for (let t of nn) this.before.set(t, e.getAttribute(t));
|
|
62
|
+
e.setAttribute("role", "application"), this.help = sn("div", "tc-sr-only"), this.help.id = `tc-chart-keys-${Math.random().toString(36).slice(2, 10)}`, e.setAttribute("aria-describedby", this.help.id), this.live = sn("div", "tc-sr-only tc-sr-live"), this.live.setAttribute("aria-live", "polite"), this.live.setAttribute("aria-atomic", "true"), e.append(this.help, this.live), e.addEventListener("blur", this.onBlur), this.applyLabels();
|
|
63
63
|
}
|
|
64
64
|
setLabels(e) {
|
|
65
65
|
this.labels = {
|
|
66
|
-
...
|
|
66
|
+
...tn,
|
|
67
67
|
...e
|
|
68
68
|
}, this.applyLabels();
|
|
69
69
|
}
|
|
70
70
|
refresh(e = !1) {
|
|
71
|
-
let t =
|
|
71
|
+
let t = an - (Date.now() - this.summaryAt);
|
|
72
72
|
if (e || t <= 0 || this.container.getAttribute("aria-label") === this.labels.empty) {
|
|
73
73
|
this.summaryTimer && clearTimeout(this.summaryTimer), this.summaryTimer = null, this.summaryAt = Date.now(), this.container.setAttribute("aria-label", this.summary());
|
|
74
74
|
return;
|
|
@@ -80,7 +80,7 @@ var en = {
|
|
|
80
80
|
viewMoved() {
|
|
81
81
|
this.cursor = null, this.viewTimer && clearTimeout(this.viewTimer), this.viewTimer = setTimeout(() => {
|
|
82
82
|
this.viewTimer = null, this.say(this.viewText());
|
|
83
|
-
},
|
|
83
|
+
}, rn);
|
|
84
84
|
}
|
|
85
85
|
readBar(e) {
|
|
86
86
|
let t = this.source.bars();
|
|
@@ -99,7 +99,7 @@ var en = {
|
|
|
99
99
|
high: a(i.high),
|
|
100
100
|
low: a(i.low),
|
|
101
101
|
close: a(i.close),
|
|
102
|
-
volume:
|
|
102
|
+
volume: cn(i.volume ?? 0)
|
|
103
103
|
}));
|
|
104
104
|
}
|
|
105
105
|
destroy() {
|
|
@@ -140,7 +140,7 @@ var en = {
|
|
|
140
140
|
this.live.textContent = e;
|
|
141
141
|
}
|
|
142
142
|
};
|
|
143
|
-
function
|
|
143
|
+
function sn(e, t) {
|
|
144
144
|
let n = document.createElement(e);
|
|
145
145
|
return n.className = t, Object.assign(n.style, {
|
|
146
146
|
position: "absolute",
|
|
@@ -154,17 +154,17 @@ function on(e, t) {
|
|
|
154
154
|
border: "0"
|
|
155
155
|
}), n;
|
|
156
156
|
}
|
|
157
|
-
function
|
|
157
|
+
function cn(e) {
|
|
158
158
|
return Number.isInteger(e) ? String(e) : e.toFixed(2);
|
|
159
159
|
}
|
|
160
160
|
//#endregion
|
|
161
161
|
//#region src/indicatorLabel.ts
|
|
162
|
-
var
|
|
162
|
+
var ln = 3, un = {
|
|
163
163
|
stochrsi: 4,
|
|
164
164
|
ichimoku: 4
|
|
165
165
|
};
|
|
166
|
-
function
|
|
167
|
-
let i = Object.keys(n || t).map((e) => t[e]).filter((e) => typeof e == "number" && Number.isFinite(e)).slice(0,
|
|
166
|
+
function dn(e, t, n, r) {
|
|
167
|
+
let i = Object.keys(n || t).map((e) => t[e]).filter((e) => typeof e == "number" && Number.isFinite(e)).slice(0, un[e] ?? ln).map((e) => String(Number(e.toFixed(4)))), a = typeof t.symbol == "string" && t.symbol ? [t.symbol] : [];
|
|
168
168
|
return [
|
|
169
169
|
e === "spread" && t.mode === "ratio" ? "Ratio" : r ?? e.toUpperCase(),
|
|
170
170
|
...a,
|
|
@@ -173,7 +173,7 @@ function un(e, t, n, r) {
|
|
|
173
173
|
}
|
|
174
174
|
//#endregion
|
|
175
175
|
//#region src/charts/ChartTypeStrategy.ts
|
|
176
|
-
function
|
|
176
|
+
function fn(e) {
|
|
177
177
|
switch (e) {
|
|
178
178
|
case "candlestick":
|
|
179
179
|
case "heikinAshi":
|
|
@@ -184,41 +184,41 @@ function dn(e) {
|
|
|
184
184
|
case "bar": return new ye();
|
|
185
185
|
case "hollowCandle": return new Be();
|
|
186
186
|
case "baseline": return new be();
|
|
187
|
-
case "renko": return new
|
|
187
|
+
case "renko": return new ot();
|
|
188
188
|
case "kagi": return new Ue();
|
|
189
|
-
case "pointAndFigure": return new
|
|
190
|
-
case "volumeCandles": return new
|
|
189
|
+
case "pointAndFigure": return new tt();
|
|
190
|
+
case "volumeCandles": return new Tt();
|
|
191
191
|
case "equivolume": return new Fe();
|
|
192
192
|
case "hlcArea": return new Re();
|
|
193
|
-
case "stepLine": return new
|
|
193
|
+
case "stepLine": return new gt();
|
|
194
194
|
case "lineWithMarkers": return new Ke();
|
|
195
195
|
case "hiLo": return new ze();
|
|
196
196
|
default: return new xe();
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
|
-
function
|
|
199
|
+
function pn(e, t, n = {}, r, i) {
|
|
200
200
|
if (t.length === 0) return t;
|
|
201
201
|
switch (e) {
|
|
202
|
-
case "heikinAshi": return
|
|
202
|
+
case "heikinAshi": return Wt(t);
|
|
203
203
|
case "renko": {
|
|
204
204
|
let e = n.renko?.boxSize;
|
|
205
|
-
return typeof e == "number" ?
|
|
205
|
+
return typeof e == "number" ? Jt(t, { brickSize: e }, i) : Jt(t, {
|
|
206
206
|
brickSize: 0,
|
|
207
207
|
useATR: !0,
|
|
208
208
|
atrPeriod: n.renko?.atrPeriod ?? 14
|
|
209
209
|
}, i);
|
|
210
210
|
}
|
|
211
|
-
case "lineBreak": return
|
|
212
|
-
case "kagi": return
|
|
213
|
-
case "pointAndFigure": return
|
|
214
|
-
case "rangeBars": return
|
|
215
|
-
rangeSize:
|
|
211
|
+
case "lineBreak": return Kt(t, n.lineBreak?.lines ?? 3);
|
|
212
|
+
case "kagi": return Gt(t, n.kagi?.reversal ?? 4, n.kagi?.reversalType ?? "percent", i);
|
|
213
|
+
case "pointAndFigure": return hn(t, n, i).columns;
|
|
214
|
+
case "rangeBars": return qt(t, {
|
|
215
|
+
rangeSize: Tn(t, n, r),
|
|
216
216
|
includeForming: !0
|
|
217
217
|
}, i);
|
|
218
218
|
default: return t;
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
|
-
function
|
|
221
|
+
function mn(e) {
|
|
222
222
|
switch (e) {
|
|
223
223
|
case "heikinAshi":
|
|
224
224
|
case "renko":
|
|
@@ -230,71 +230,71 @@ function pn(e) {
|
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
232
|
function L(e) {
|
|
233
|
-
return e !== "heikinAshi" &&
|
|
233
|
+
return e !== "heikinAshi" && mn(e);
|
|
234
234
|
}
|
|
235
|
-
function
|
|
236
|
-
return
|
|
235
|
+
function hn(e, t = {}, n) {
|
|
236
|
+
return Lt(e, vn(e, t), t.pointAndFigure?.reversal ?? 3, n);
|
|
237
237
|
}
|
|
238
|
-
var
|
|
239
|
-
function
|
|
238
|
+
var gn = 50, _n = .01;
|
|
239
|
+
function vn(e, t = {}) {
|
|
240
240
|
let n = t.pointAndFigure?.boxSize;
|
|
241
241
|
if (typeof n == "number") return n;
|
|
242
|
-
let r =
|
|
243
|
-
return r > 0 ?
|
|
242
|
+
let r = yn(e, e.length > 1 ? e.length - 1 : e.length);
|
|
243
|
+
return r > 0 ? wn(te(r / gn, !0)) : Math.abs(e[e.length - 1]?.close ?? 0) * _n || 1;
|
|
244
244
|
}
|
|
245
|
-
function
|
|
245
|
+
function yn(e, t) {
|
|
246
246
|
let n = -Infinity, r = Infinity;
|
|
247
247
|
for (let i = 0; i < t; i++) e[i].high > n && (n = e[i].high), e[i].low < r && (r = e[i].low);
|
|
248
248
|
let i = n - r;
|
|
249
249
|
return Number.isFinite(i) ? i : 0;
|
|
250
250
|
}
|
|
251
|
-
var
|
|
252
|
-
function
|
|
251
|
+
var bn = 100, xn = 3, Sn = .01, Cn = 15, wn = (e) => Number(e.toPrecision(Cn));
|
|
252
|
+
function Tn(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 >= xn ? Dn(e) : 0, a = Math.abs(e[e.length - 1]?.close ?? 0);
|
|
256
|
+
return An(wn(te(i > 0 ? i : a * Sn || 1, !0)), n);
|
|
257
257
|
}
|
|
258
|
-
function
|
|
258
|
+
function En(e) {
|
|
259
259
|
let t = e.length - 1;
|
|
260
260
|
return {
|
|
261
|
-
from: Math.max(0, t -
|
|
261
|
+
from: Math.max(0, t - bn),
|
|
262
262
|
end: t
|
|
263
263
|
};
|
|
264
264
|
}
|
|
265
|
-
function
|
|
266
|
-
let { from: t, end: n } =
|
|
265
|
+
function Dn(e) {
|
|
266
|
+
let { from: t, end: n } = En(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 On(e, t) {
|
|
274
|
+
let { from: n, end: r } = En(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 On(e, t) {
|
|
281
|
-
return e === void 0 ? t : t === void 0 ? e : Math.max(e, t);
|
|
278
|
+
return kn(t(i), t(a));
|
|
282
279
|
}
|
|
283
280
|
function kn(e, t) {
|
|
284
|
-
return
|
|
281
|
+
return e === void 0 ? t : t === void 0 ? e : Math.max(e, t);
|
|
285
282
|
}
|
|
286
283
|
function An(e, t) {
|
|
284
|
+
return t === void 0 || !(t > 0) ? e : wn(Math.max(1, Math.round(e / t)) * t);
|
|
285
|
+
}
|
|
286
|
+
function jn(e, t) {
|
|
287
287
|
let n = t?.(e);
|
|
288
|
-
return n ? n.createRenderer() :
|
|
288
|
+
return n ? n.createRenderer() : fn(e);
|
|
289
289
|
}
|
|
290
|
-
function
|
|
290
|
+
function Mn(e, t, n, r, i, a) {
|
|
291
291
|
if (t.length === 0) return t;
|
|
292
292
|
let o = n?.(e);
|
|
293
|
-
return o?.transform ? o.transform(t) :
|
|
293
|
+
return o?.transform ? o.transform(t) : pn(e, t, r, i, a);
|
|
294
294
|
}
|
|
295
295
|
//#endregion
|
|
296
296
|
//#region src/state/AutoSaveScheduler.ts
|
|
297
|
-
var
|
|
297
|
+
var Nn = 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 Pn(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 Fn(e, t) {
|
|
347
347
|
for (let n = e.length - 1; n >= 0; n--) {
|
|
348
348
|
if (e[n].time === t) return n;
|
|
349
349
|
if (e[n].time < t) return -1;
|
|
350
350
|
}
|
|
351
351
|
return -1;
|
|
352
352
|
}
|
|
353
|
-
var
|
|
353
|
+
var In = {
|
|
354
354
|
index: -1,
|
|
355
355
|
changed: !1
|
|
356
356
|
};
|
|
357
|
-
function
|
|
357
|
+
function Ln(e, t) {
|
|
358
358
|
if (e.length === 0) return t;
|
|
359
359
|
let n = b(t);
|
|
360
360
|
return u(e) === 1 ? n : n / 1e3;
|
|
361
361
|
}
|
|
362
|
-
function
|
|
363
|
-
let n =
|
|
362
|
+
function Rn(e, t) {
|
|
363
|
+
let n = Ln(e, t.time);
|
|
364
364
|
return n === t.time ? t : {
|
|
365
365
|
...t,
|
|
366
366
|
time: n
|
|
@@ -369,7 +369,7 @@ function Ln(e, t) {
|
|
|
369
369
|
var V = class {
|
|
370
370
|
data = [];
|
|
371
371
|
withSeriesTime(e) {
|
|
372
|
-
return
|
|
372
|
+
return Rn(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(Pn(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(Pn(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 In;
|
|
412
|
+
let t = this.withSeriesTime(e), n = Fn(this.data, t.time);
|
|
413
|
+
if (n < 0) return In;
|
|
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 zn(e) {
|
|
444
444
|
return [
|
|
445
445
|
e.time,
|
|
446
446
|
e.open,
|
|
@@ -449,7 +449,7 @@ function Rn(e) {
|
|
|
449
449
|
e.close
|
|
450
450
|
].every(Number.isFinite);
|
|
451
451
|
}
|
|
452
|
-
var
|
|
452
|
+
var Bn = class {
|
|
453
453
|
shown = new V();
|
|
454
454
|
whole = null;
|
|
455
455
|
aside = null;
|
|
@@ -489,7 +489,7 @@ var zn = 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(zn).map((e) => this.inSeriesUnit(e)).filter((e) => (r === void 0 || e.time < r) && !i.has(e.time) && i.add(e.time)).sort((e, t) => e.time - t.time);
|
|
493
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 zn = 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(Vn(this.aside.getData(), e) ?? e), this.onLiveChange({ kind: "series" }), !0;
|
|
505
|
+
let t = Vn(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 zn = 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(Ln(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 zn = 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 ? Fn(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 zn = class {
|
|
|
636
636
|
this.shown.updateLastBar(e);
|
|
637
637
|
}
|
|
638
638
|
inSeriesUnit(e) {
|
|
639
|
-
return
|
|
639
|
+
return Rn(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 zn = class {
|
|
|
673
673
|
return !r || r(e.time);
|
|
674
674
|
}
|
|
675
675
|
};
|
|
676
|
-
function
|
|
676
|
+
function Vn(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 Hn = 5e3, Un = 6e4, Wn = 500, Gn = class {
|
|
684
684
|
loader = null;
|
|
685
685
|
pageSize = 500;
|
|
686
686
|
loading = !1;
|
|
@@ -732,7 +732,7 @@ var Vn = 5e3, Hn = 6e4, Un = 500, Wn = class {
|
|
|
732
732
|
try {
|
|
733
733
|
r = await e(t, this.pageSize);
|
|
734
734
|
} catch (e) {
|
|
735
|
-
return n === this.seq ? (this.loading = !1, this.failures++, this.retryAt = this.now() + Math.min(
|
|
735
|
+
return n === this.seq ? (this.loading = !1, this.failures++, this.retryAt = this.now() + Math.min(Un, Hn * 2 ** (this.failures - 1)), this.emit({
|
|
736
736
|
state: "error",
|
|
737
737
|
count: 0,
|
|
738
738
|
error: e instanceof Error ? e.message : String(e)
|
|
@@ -765,10 +765,10 @@ var Vn = 5e3, Hn = 6e4, Un = 500, Wn = class {
|
|
|
765
765
|
};
|
|
766
766
|
//#endregion
|
|
767
767
|
//#region src/ThemeManager.ts
|
|
768
|
-
function
|
|
768
|
+
function Kn(e, t) {
|
|
769
769
|
return e.family === t.family && e.sizeSmall === t.sizeSmall && e.sizeMedium === t.sizeMedium && e.sizeLarge === t.sizeLarge;
|
|
770
770
|
}
|
|
771
|
-
var
|
|
771
|
+
var qn = class t {
|
|
772
772
|
base;
|
|
773
773
|
shape = null;
|
|
774
774
|
font = null;
|
|
@@ -793,7 +793,7 @@ var Kn = class t {
|
|
|
793
793
|
return this.base;
|
|
794
794
|
}
|
|
795
795
|
setTheme(e) {
|
|
796
|
-
let n = t.read(e), r = this.font !== null &&
|
|
796
|
+
let n = t.read(e), r = this.font !== null && Kn(n.font, this.base.font);
|
|
797
797
|
this.base = n, r || (this.themeFont = n.font), this.shape && (this.base = {
|
|
798
798
|
...this.base,
|
|
799
799
|
shape: {
|
|
@@ -875,7 +875,7 @@ var Kn = class t {
|
|
|
875
875
|
};
|
|
876
876
|
//#endregion
|
|
877
877
|
//#region src/style/styleOptions.ts
|
|
878
|
-
function
|
|
878
|
+
function Jn(e, t) {
|
|
879
879
|
return t ? {
|
|
880
880
|
...t.visible === void 0 ? {} : { [`crosshair.${e}.visible`]: t.visible },
|
|
881
881
|
...t.color === void 0 ? {} : { [`crosshair.${e}.color`]: t.color },
|
|
@@ -883,22 +883,22 @@ function qn(e, t) {
|
|
|
883
883
|
...t.width === void 0 ? {} : { [`crosshair.${e}.width`]: t.width }
|
|
884
884
|
} : {};
|
|
885
885
|
}
|
|
886
|
-
function
|
|
886
|
+
function Yn(e) {
|
|
887
887
|
let { grid: t, crosshair: n } = e, r = n?.vLine?.labelBackground ?? n?.hLine?.labelBackground;
|
|
888
888
|
return {
|
|
889
889
|
...t?.hLineColor === void 0 ? {} : { "grid.horizontal.color": t.hLineColor },
|
|
890
890
|
...t?.hLineStyle === void 0 ? {} : { "grid.horizontal.style": t.hLineStyle },
|
|
891
891
|
...t?.vLineColor === void 0 ? {} : { "grid.vertical.color": t.vLineColor },
|
|
892
892
|
...t?.vLineStyle === void 0 ? {} : { "grid.vertical.style": t.vLineStyle },
|
|
893
|
-
...
|
|
894
|
-
...
|
|
893
|
+
...Jn("horizontal", n?.hLine),
|
|
894
|
+
...Jn("vertical", n?.vLine),
|
|
895
895
|
...r === void 0 ? {} : { "crosshair.labelBackground": r },
|
|
896
896
|
...e.overrides
|
|
897
897
|
};
|
|
898
898
|
}
|
|
899
899
|
//#endregion
|
|
900
900
|
//#region src/layout/LayoutManager.ts
|
|
901
|
-
var
|
|
901
|
+
var Xn = 200, Zn = 80, W = (e) => e.position === "top" || e.position === "bottom", Qn = class {
|
|
902
902
|
panels = [];
|
|
903
903
|
containerWidth = 0;
|
|
904
904
|
containerHeight = 0;
|
|
@@ -915,8 +915,8 @@ var Yn = 200, Xn = 80, W = (e) => e.position === "top" || e.position === "bottom
|
|
|
915
915
|
this.panels.push({
|
|
916
916
|
id: e,
|
|
917
917
|
position: n,
|
|
918
|
-
size: r ?? (a ?
|
|
919
|
-
minSize: a ?
|
|
918
|
+
size: r ?? (a ? Xn : t),
|
|
919
|
+
minSize: a ? Zn : i,
|
|
920
920
|
content: {
|
|
921
921
|
type: "indicator",
|
|
922
922
|
indicatorInstanceId: e
|
|
@@ -985,7 +985,7 @@ var Yn = 200, Xn = 80, W = (e) => e.position === "top" || e.position === "bottom
|
|
|
985
985
|
let r = this.panels.find((t) => t.id === e);
|
|
986
986
|
if (r) {
|
|
987
987
|
let a = r.position === "left" || r.position === "right", o = n === "left" || n === "right";
|
|
988
|
-
r.position = n, a !== o && (r.size = o ?
|
|
988
|
+
r.position = n, a !== o && (r.size = o ? Xn : t, r.minSize = o ? Zn : i), o && (r.collapsed = void 0, this.maximized === e && (this.maximized = null));
|
|
989
989
|
}
|
|
990
990
|
}
|
|
991
991
|
setPanelSize(e, t) {
|
|
@@ -1105,8 +1105,8 @@ var Yn = 200, Xn = 80, W = (e) => e.position === "top" || e.position === "bottom
|
|
|
1105
1105
|
getMainChartRect() {
|
|
1106
1106
|
return this.resolve().mainChartRect;
|
|
1107
1107
|
}
|
|
1108
|
-
},
|
|
1109
|
-
function
|
|
1108
|
+
}, $n = 14, er = 14, tr = 22, nr = 4;
|
|
1109
|
+
function rr(e) {
|
|
1110
1110
|
let { min: t, max: n, lastPrice: r, locale: i, fontFamily: a, fontSizeSmall: s, measure: l } = e, u = e.tagPrecision ?? c(t, n), d = u, f = r === null ? [t, n] : [
|
|
1111
1111
|
t,
|
|
1112
1112
|
n,
|
|
@@ -1115,16 +1115,16 @@ function nr(e) {
|
|
|
1115
1115
|
for (let t of f) {
|
|
1116
1116
|
if (!Number.isFinite(t)) continue;
|
|
1117
1117
|
let n = e.scaleLabel ? e.scaleLabel(t) : e.format ? e.format(t) : g(t, u, i), r = e.format ? n : g(t, d, i);
|
|
1118
|
-
p = Math.max(p, l(n, `500 ${s}px ${a}`) +
|
|
1118
|
+
p = Math.max(p, l(n, `500 ${s}px ${a}`) + $n, l(r, `bold 11px ${a}`) + er, l(r, `600 ${s}px ${a}`) + tr);
|
|
1119
1119
|
}
|
|
1120
|
-
return p <= o ? o : Math.ceil(p /
|
|
1120
|
+
return p <= o ? o : Math.ceil(p / nr) * nr;
|
|
1121
1121
|
}
|
|
1122
|
-
function
|
|
1122
|
+
function ir(e, t) {
|
|
1123
1123
|
return t > e || t <= e - 12 ? t : e;
|
|
1124
1124
|
}
|
|
1125
1125
|
//#endregion
|
|
1126
1126
|
//#region src/layout/labelWidths.ts
|
|
1127
|
-
var
|
|
1127
|
+
var ar = 512, or = class {
|
|
1128
1128
|
widths = /* @__PURE__ */ new Map();
|
|
1129
1129
|
fonts;
|
|
1130
1130
|
forget = () => this.widths.clear();
|
|
@@ -1135,12 +1135,12 @@ var ir = 512, ar = class {
|
|
|
1135
1135
|
let r = `${t}\n${e}`, i = this.widths.get(r);
|
|
1136
1136
|
if (i !== void 0) return i;
|
|
1137
1137
|
let a = n();
|
|
1138
|
-
return this.widths.size >=
|
|
1138
|
+
return this.widths.size >= ar && this.widths.clear(), this.widths.set(r, a), a;
|
|
1139
1139
|
}
|
|
1140
1140
|
destroy() {
|
|
1141
1141
|
this.fonts?.removeEventListener("loadingdone", this.forget), this.widths.clear();
|
|
1142
1142
|
}
|
|
1143
|
-
},
|
|
1143
|
+
}, sr = class {
|
|
1144
1144
|
netY = 0;
|
|
1145
1145
|
travelX = 0;
|
|
1146
1146
|
engaged = !1;
|
|
@@ -1156,8 +1156,8 @@ var ir = 512, ar = class {
|
|
|
1156
1156
|
}
|
|
1157
1157
|
return this.engaged;
|
|
1158
1158
|
}
|
|
1159
|
-
},
|
|
1160
|
-
function
|
|
1159
|
+
}, cr = 1;
|
|
1160
|
+
function lr(e, t) {
|
|
1161
1161
|
return e.filter((e) => e.enabled !== !1 && (e.descriptor.layer ?? "overlay") === t);
|
|
1162
1162
|
}
|
|
1163
1163
|
function G(e) {
|
|
@@ -1171,24 +1171,24 @@ function G(e) {
|
|
|
1171
1171
|
//#endregion
|
|
1172
1172
|
//#region src/plugins/registry.ts
|
|
1173
1173
|
var K = /* @__PURE__ */ new Map();
|
|
1174
|
-
function
|
|
1174
|
+
function ur(e) {
|
|
1175
1175
|
K.set(G(e), e);
|
|
1176
1176
|
}
|
|
1177
|
-
function
|
|
1177
|
+
function dr(e) {
|
|
1178
1178
|
return K.delete(e);
|
|
1179
1179
|
}
|
|
1180
|
-
function
|
|
1180
|
+
function fr() {
|
|
1181
1181
|
return [...K.values()];
|
|
1182
1182
|
}
|
|
1183
|
-
function
|
|
1183
|
+
function pr() {
|
|
1184
1184
|
K.clear();
|
|
1185
1185
|
}
|
|
1186
1186
|
//#endregion
|
|
1187
1187
|
//#region src/plugins/PluginManager.ts
|
|
1188
|
-
var
|
|
1188
|
+
var mr = class {
|
|
1189
1189
|
plugins = /* @__PURE__ */ new Map();
|
|
1190
1190
|
constructor(e, t = {}) {
|
|
1191
|
-
if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of
|
|
1191
|
+
if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of fr()) this.add(e);
|
|
1192
1192
|
for (let e of t.plugins ?? []) this.add(e);
|
|
1193
1193
|
}
|
|
1194
1194
|
register(e) {
|
|
@@ -1218,15 +1218,15 @@ var pr = class {
|
|
|
1218
1218
|
add(e) {
|
|
1219
1219
|
this.plugins.set(G(e), e), e.kind === "indicator" && this.indicatorEngine.register(e.plugin);
|
|
1220
1220
|
}
|
|
1221
|
-
},
|
|
1221
|
+
}, hr = {
|
|
1222
1222
|
orderPlace: (e, t) => e.placeOrder(t),
|
|
1223
1223
|
orderModify: (e, t) => e.modifyOrder(t),
|
|
1224
1224
|
orderCancel: (e, t) => e.cancelOrder(t),
|
|
1225
1225
|
positionModify: (e, t) => e.modifyPosition(t),
|
|
1226
1226
|
positionClose: (e, t) => e.closePosition(t),
|
|
1227
|
-
positionReverse: (e, t, n) =>
|
|
1227
|
+
positionReverse: (e, t, n) => gr(e, t, n)
|
|
1228
1228
|
};
|
|
1229
|
-
async function
|
|
1229
|
+
async function gr(e, t, n) {
|
|
1230
1230
|
let { reversing: r } = n;
|
|
1231
1231
|
if (!r.has(t.positionId)) {
|
|
1232
1232
|
r.add(t.positionId);
|
|
@@ -1255,7 +1255,7 @@ async function hr(e, t, n) {
|
|
|
1255
1255
|
}
|
|
1256
1256
|
}
|
|
1257
1257
|
}
|
|
1258
|
-
function
|
|
1258
|
+
function _r(e, t) {
|
|
1259
1259
|
let n = [], r = null, i = {
|
|
1260
1260
|
positions: () => r ?? t.getPositions?.() ?? [],
|
|
1261
1261
|
reversing: /* @__PURE__ */ new Set()
|
|
@@ -1265,8 +1265,8 @@ function gr(e, t) {
|
|
|
1265
1265
|
e.data && t.onFill?.(e.data);
|
|
1266
1266
|
};
|
|
1267
1267
|
e.on("orders", a), e.on("positions", o), e.on("error", s), e.on("fill", c), n.push(() => e.off("orders", a), () => e.off("positions", o), () => e.off("error", s), () => e.off("fill", c));
|
|
1268
|
-
for (let r of Object.keys(
|
|
1269
|
-
let a =
|
|
1268
|
+
for (let r of Object.keys(hr)) {
|
|
1269
|
+
let a = hr[r], o = t.onIntent(r, (n) => {
|
|
1270
1270
|
Promise.resolve(a(e, n, i)).catch((e) => t.onError({
|
|
1271
1271
|
message: `Execution command failed: ${r}`,
|
|
1272
1272
|
cause: e
|
|
@@ -1280,7 +1280,7 @@ function gr(e, t) {
|
|
|
1280
1280
|
}
|
|
1281
1281
|
//#endregion
|
|
1282
1282
|
//#region src/replay/ReplayStepLoader.ts
|
|
1283
|
-
var
|
|
1283
|
+
var vr = 1e3, yr = class {
|
|
1284
1284
|
pieces = /* @__PURE__ */ new Map();
|
|
1285
1285
|
asked = /* @__PURE__ */ new Set();
|
|
1286
1286
|
inFlight = !1;
|
|
@@ -1313,7 +1313,7 @@ var _r = 1e3, vr = class {
|
|
|
1313
1313
|
this.done = !0;
|
|
1314
1314
|
}
|
|
1315
1315
|
ask(e, t) {
|
|
1316
|
-
let { ratio: n, barMs: r, step: i, report: a } = this.options, o = Math.max(1, Math.floor(
|
|
1316
|
+
let { ratio: n, barMs: r, step: i, report: a } = this.options, o = Math.max(1, Math.floor(vr / n)), s = Math.min(e.length, t + o), c = s < e.length ? e[s].time : e[e.length - 1].time + r, l = e.slice(t, s);
|
|
1317
1317
|
for (let e of l) this.asked.add(e.time);
|
|
1318
1318
|
this.inFlight = !0, a({
|
|
1319
1319
|
state: "loading",
|
|
@@ -1354,12 +1354,12 @@ var _r = 1e3, vr = class {
|
|
|
1354
1354
|
...n === void 0 ? {} : { error: n }
|
|
1355
1355
|
});
|
|
1356
1356
|
}
|
|
1357
|
-
},
|
|
1358
|
-
function
|
|
1359
|
-
let n = (e.high - e.low) *
|
|
1360
|
-
return t.filter((t) => t.close > e.high + n || t.close < e.low - n).length <= t.length *
|
|
1357
|
+
}, br = 1 / 3, xr = .25, Sr = .5;
|
|
1358
|
+
function Cr(e, t) {
|
|
1359
|
+
let n = (e.high - e.low) * xr;
|
|
1360
|
+
return t.filter((t) => t.close > e.high + n || t.close < e.low - n).length <= t.length * Sr;
|
|
1361
1361
|
}
|
|
1362
|
-
function
|
|
1362
|
+
function wr(e) {
|
|
1363
1363
|
return e.close >= e.open ? [
|
|
1364
1364
|
e.open,
|
|
1365
1365
|
e.low,
|
|
@@ -1372,22 +1372,22 @@ function Cr(e) {
|
|
|
1372
1372
|
e.close
|
|
1373
1373
|
];
|
|
1374
1374
|
}
|
|
1375
|
-
function
|
|
1376
|
-
let r =
|
|
1375
|
+
function Tr(e, t, n) {
|
|
1376
|
+
let r = wr(e), i = [
|
|
1377
1377
|
1,
|
|
1378
1378
|
2,
|
|
1379
1379
|
3
|
|
1380
1380
|
].map((e) => Math.abs(r[e] - r[e - 1])), a = i[0] + i[1] + i[2], o = [], s = 0;
|
|
1381
1381
|
return r.forEach((r, c) => {
|
|
1382
|
-
c > 0 && (s += a > 0 ? i[c - 1] / a :
|
|
1382
|
+
c > 0 && (s += a > 0 ? i[c - 1] / a : br), !(c === 0 && t > 0) && o.push({
|
|
1383
1383
|
price: r,
|
|
1384
1384
|
time: e.time,
|
|
1385
1385
|
at: (t + s) / n
|
|
1386
1386
|
});
|
|
1387
1387
|
}), o;
|
|
1388
1388
|
}
|
|
1389
|
-
function
|
|
1390
|
-
let n = t.length > 0 &&
|
|
1389
|
+
function Er(e, t = []) {
|
|
1390
|
+
let n = t.length > 0 && Cr(e, t) ? t : [e], r = n.length, i = Dr(n.flatMap((e, t) => Tr(e, t, r)), e), a = n.reduce((e, t) => e + (t.volume ?? 0), 0), o = 0;
|
|
1391
1391
|
return {
|
|
1392
1392
|
bar: e,
|
|
1393
1393
|
points: i,
|
|
@@ -1397,7 +1397,7 @@ function Tr(e, t = []) {
|
|
|
1397
1397
|
}))
|
|
1398
1398
|
};
|
|
1399
1399
|
}
|
|
1400
|
-
function
|
|
1400
|
+
function Dr(e, t) {
|
|
1401
1401
|
let n = e.length - 1, r = e.map((e, r) => ({
|
|
1402
1402
|
...e,
|
|
1403
1403
|
price: r === 0 ? t.open : r === n ? t.close : Math.min(t.high, Math.max(t.low, e.price))
|
|
@@ -1412,7 +1412,7 @@ function Er(e, t) {
|
|
|
1412
1412
|
};
|
|
1413
1413
|
return i(t.high, (e, t) => e > t), i(t.low, (e, t) => e < t), r;
|
|
1414
1414
|
}
|
|
1415
|
-
function
|
|
1415
|
+
function Or(e, t) {
|
|
1416
1416
|
let n = e.points;
|
|
1417
1417
|
if (t <= n[0].at) return n[0].price;
|
|
1418
1418
|
for (let e = 1; e < n.length; e++) if (t <= n[e].at) {
|
|
@@ -1421,8 +1421,8 @@ function Dr(e, t) {
|
|
|
1421
1421
|
}
|
|
1422
1422
|
return n[n.length - 1].price;
|
|
1423
1423
|
}
|
|
1424
|
-
var
|
|
1425
|
-
function
|
|
1424
|
+
var kr = (e) => Number.isFinite(e) ? Math.min(1, Math.max(0, e)) : 0;
|
|
1425
|
+
function Ar(e, t) {
|
|
1426
1426
|
let n = 0, r = 0;
|
|
1427
1427
|
for (let i of e.volumeAt) {
|
|
1428
1428
|
if (t >= i.at) {
|
|
@@ -1433,10 +1433,10 @@ function kr(e, t) {
|
|
|
1433
1433
|
}
|
|
1434
1434
|
return n;
|
|
1435
1435
|
}
|
|
1436
|
-
function
|
|
1437
|
-
let n =
|
|
1436
|
+
function jr(e, t) {
|
|
1437
|
+
let n = kr(t);
|
|
1438
1438
|
if (n >= 1) return { ...e.bar };
|
|
1439
|
-
let r =
|
|
1439
|
+
let r = Or(e, n), i = Math.max(e.points[0].price, r), a = Math.min(e.points[0].price, r);
|
|
1440
1440
|
for (let t of e.points) {
|
|
1441
1441
|
if (t.at > n) break;
|
|
1442
1442
|
i = Math.max(i, t.price), a = Math.min(a, t.price);
|
|
@@ -1447,11 +1447,11 @@ function Ar(e, t) {
|
|
|
1447
1447
|
high: i,
|
|
1448
1448
|
low: a,
|
|
1449
1449
|
close: r,
|
|
1450
|
-
volume:
|
|
1450
|
+
volume: Ar(e, n)
|
|
1451
1451
|
};
|
|
1452
1452
|
}
|
|
1453
|
-
function
|
|
1454
|
-
let n =
|
|
1453
|
+
function Mr(e, t) {
|
|
1454
|
+
let n = kr(t), r = 0;
|
|
1455
1455
|
for (let t of e.points) {
|
|
1456
1456
|
if (t.at > n) break;
|
|
1457
1457
|
r = t.at;
|
|
@@ -1464,12 +1464,12 @@ function q(e, t, n) {
|
|
|
1464
1464
|
if (a.at > n) break;
|
|
1465
1465
|
i = a.time, a.at > t && r.push([a.price, a.time]);
|
|
1466
1466
|
}
|
|
1467
|
-
let a =
|
|
1467
|
+
let a = Or(e, n);
|
|
1468
1468
|
return (r.length === 0 || r[r.length - 1][0] !== a) && r.push([a, i]), r;
|
|
1469
1469
|
}
|
|
1470
1470
|
//#endregion
|
|
1471
1471
|
//#region src/replay/replayStep.ts
|
|
1472
|
-
var
|
|
1472
|
+
var Nr = [
|
|
1473
1473
|
"1m",
|
|
1474
1474
|
"3m",
|
|
1475
1475
|
"5m",
|
|
@@ -1480,30 +1480,30 @@ var Mr = [
|
|
|
1480
1480
|
"4h",
|
|
1481
1481
|
"1d"
|
|
1482
1482
|
];
|
|
1483
|
-
function
|
|
1483
|
+
function Pr(e, t) {
|
|
1484
1484
|
let n = w(e);
|
|
1485
|
-
return n > 0 ?
|
|
1485
|
+
return n > 0 ? Nr.filter((e) => {
|
|
1486
1486
|
let r = w(e);
|
|
1487
1487
|
return r < n && n % r === 0 && t(e);
|
|
1488
1488
|
}) : [];
|
|
1489
1489
|
}
|
|
1490
|
-
function
|
|
1491
|
-
let r =
|
|
1490
|
+
function Fr(e, t, n) {
|
|
1491
|
+
let r = Pr(t, n);
|
|
1492
1492
|
if (e !== "auto") return r.includes(e) ? e : null;
|
|
1493
1493
|
let i = w(t);
|
|
1494
1494
|
return r.find((e) => i / w(e) <= 60) ?? null;
|
|
1495
1495
|
}
|
|
1496
1496
|
//#endregion
|
|
1497
1497
|
//#region src/Chart.ts
|
|
1498
|
-
var
|
|
1498
|
+
var Ir = {
|
|
1499
1499
|
min: 0,
|
|
1500
1500
|
max: 100
|
|
1501
|
-
},
|
|
1502
|
-
function
|
|
1501
|
+
}, Lr = "exchange", Rr = Lr;
|
|
1502
|
+
function zr(e) {
|
|
1503
1503
|
if (typeof e == "string" && e !== "exchange" && !y(e)) throw RangeError(`Unknown time zone: ${e}`);
|
|
1504
1504
|
if (typeof e == "number" && !Number.isFinite(e)) throw RangeError(`Invalid UTC offset: ${e}`);
|
|
1505
1505
|
}
|
|
1506
|
-
function
|
|
1506
|
+
function Br(e, t) {
|
|
1507
1507
|
let { timeZone: n, timezone: r } = e, i = n !== void 0 && r !== void 0 && n !== r && n === t ? r : C(e);
|
|
1508
1508
|
return i === void 0 ? e : {
|
|
1509
1509
|
...e,
|
|
@@ -1511,11 +1511,11 @@ function zr(e, t) {
|
|
|
1511
1511
|
timezone: i
|
|
1512
1512
|
};
|
|
1513
1513
|
}
|
|
1514
|
-
var
|
|
1515
|
-
static version = "1.59.
|
|
1514
|
+
var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 20, Gr = 8, Kr = new Set(["horizontalLine", "crossLine"]), qr = new Set(["verticalLine", "crossLine"]), Jr = class {
|
|
1515
|
+
static version = "1.59.2";
|
|
1516
1516
|
engine;
|
|
1517
1517
|
viewport;
|
|
1518
|
-
series = new
|
|
1518
|
+
series = new Bn((e) => this.sessionKeep(e), (e) => this.followLiveChange(e));
|
|
1519
1519
|
themeManager;
|
|
1520
1520
|
layoutManager;
|
|
1521
1521
|
pluginManager;
|
|
@@ -1531,7 +1531,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
1531
1531
|
autoScrollOnNewBar = !0;
|
|
1532
1532
|
displayDataCache = null;
|
|
1533
1533
|
indicatorsOnDrawn = null;
|
|
1534
|
-
reshapeMemo = new
|
|
1534
|
+
reshapeMemo = new lt();
|
|
1535
1535
|
displayDataStep;
|
|
1536
1536
|
indicatorUpdateFrom = null;
|
|
1537
1537
|
resolvedLayoutCache = null;
|
|
@@ -1542,7 +1542,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
1542
1542
|
renderDeferred = !1;
|
|
1543
1543
|
priceAxisWidth = o;
|
|
1544
1544
|
measureCtx;
|
|
1545
|
-
labelWidths = new
|
|
1545
|
+
labelWidths = new or();
|
|
1546
1546
|
containerSizeCache = null;
|
|
1547
1547
|
containerSizeCacheTime = 0;
|
|
1548
1548
|
lastEmittedRange = null;
|
|
@@ -1557,7 +1557,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
1557
1557
|
indicatorEdit = null;
|
|
1558
1558
|
removedDrawingAlerts = /* @__PURE__ */ new Map();
|
|
1559
1559
|
zoomAreaMode = !1;
|
|
1560
|
-
priceAxisAddButton = new
|
|
1560
|
+
priceAxisAddButton = new rt();
|
|
1561
1561
|
displayTz = null;
|
|
1562
1562
|
timeZoneSetting = null;
|
|
1563
1563
|
symbolInfo = null;
|
|
@@ -1587,7 +1587,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
1587
1587
|
signalMarkerManager;
|
|
1588
1588
|
tradeZoneManager;
|
|
1589
1589
|
measureOverlay;
|
|
1590
|
-
selectionBoxOverlay = new
|
|
1590
|
+
selectionBoxOverlay = new dt();
|
|
1591
1591
|
replayManager;
|
|
1592
1592
|
replayBarUnsub = null;
|
|
1593
1593
|
replaySeeking = !1;
|
|
@@ -1602,7 +1602,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
1602
1602
|
replayForming = null;
|
|
1603
1603
|
replayPhaseUnsub = null;
|
|
1604
1604
|
undoRedoManager;
|
|
1605
|
-
autoSaveScheduler = new
|
|
1605
|
+
autoSaveScheduler = new Nn((e) => this.saveState(e));
|
|
1606
1606
|
animator;
|
|
1607
1607
|
crosshairTooltip;
|
|
1608
1608
|
pinnedTooltip;
|
|
@@ -1614,14 +1614,14 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
1614
1614
|
disposed = !1;
|
|
1615
1615
|
chartTypeOptions = {};
|
|
1616
1616
|
mainSeriesVisible = !0;
|
|
1617
|
-
priceLines = new
|
|
1618
|
-
symbolSeries = new
|
|
1617
|
+
priceLines = new it();
|
|
1618
|
+
symbolSeries = new vt();
|
|
1619
1619
|
extendedHours = !0;
|
|
1620
1620
|
replayRestarting = !1;
|
|
1621
1621
|
requestedSymbols = /* @__PURE__ */ new Set();
|
|
1622
1622
|
gridRenderer;
|
|
1623
1623
|
priceAxis;
|
|
1624
|
-
leftPriceAxis = new
|
|
1624
|
+
leftPriceAxis = new nt();
|
|
1625
1625
|
leftScaleRequested = !1;
|
|
1626
1626
|
leftAxisWidth = o;
|
|
1627
1627
|
leftViewport = null;
|
|
@@ -1654,7 +1654,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
1654
1654
|
snapshotKey = null;
|
|
1655
1655
|
historyCheckQueued = !1;
|
|
1656
1656
|
constructor(e, t) {
|
|
1657
|
-
t.timeZone != null &&
|
|
1657
|
+
t.timeZone != null && zr(t.timeZone), this.container = e, this.options = {
|
|
1658
1658
|
...t,
|
|
1659
1659
|
chartType: t.chartType ?? "candlestick"
|
|
1660
1660
|
}, this.numberLocale = t.numberLocale ?? "en-US", this.defaultAutoScale = t.autoScale !== !1;
|
|
@@ -1693,15 +1693,15 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
1693
1693
|
logScale: n.logScale ?? !0,
|
|
1694
1694
|
timeframes: n.timeframes ?? [],
|
|
1695
1695
|
defaultTimeframeFavorites: n.defaultTimeframeFavorites ?? []
|
|
1696
|
-
}, 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
|
|
1696
|
+
}, 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 Gn({
|
|
1697
1697
|
oldestTime: () => (this.replaySession ? this.series.liveBars() : this.series.bars())[0]?.time ?? null,
|
|
1698
1698
|
prepend: (e) => this.prependBars(e),
|
|
1699
1699
|
emit: (e) => this.eventBus.emit("historyLoad", e)
|
|
1700
|
-
}), this.themeManager = new
|
|
1700
|
+
}), this.themeManager = new qn(t.theme), this.themeManager.setChartType(this.options.chartType ?? "candlestick"), this.applyStyle(Yn(t), "host", !1), this.layoutManager = new Qn(), this.indicatorEngine = new Ve(), this.pluginManager = new mr(this.indicatorEngine, { plugins: t.plugins }), this.eventBus = new Ie(), Ht(this.indicatorEngine), this.indicatorEngine.register(new we(this.symbolSeries)), this.indicatorEngine.register(new Te(this.symbolSeries)), this.indicatorEngine.register(new ht(this.symbolSeries)), this.indicatorEngine.register(new Ee(this.symbolSeries)), this.indicatorEngine.register(new De(this.symbolSeries)), this.drawingManager = new Ne(), Vt(this.drawingManager), this.drawingRenderer = new Pe(this.drawingManager), this.drawingRenderer.setKeepOut(() => this.legendKeepOut()), this.drawingManager.setRequestRender(() => {
|
|
1701
1701
|
this.syncRenderContext(), this.engine.requestRender(r.Overlay), this.scheduleAutoSave();
|
|
1702
1702
|
}), this.drawingManager.setEventCallback((e, t) => {
|
|
1703
1703
|
this.followDrawingAlerts(e, t?.id), this.eventBus.emit(e, t), (e === "drawingCreate" || e === "drawingUpdate" || e === "drawingRemove") && this.announceStateChange();
|
|
1704
|
-
}), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new
|
|
1704
|
+
}), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new Ct();
|
|
1705
1705
|
let i = "";
|
|
1706
1706
|
this.undoRedoManager.setOnChange(() => {
|
|
1707
1707
|
let { canUndo: e, canRedo: t } = this.undoRedoManager.getState(), n = `${e}|${t}`;
|
|
@@ -1714,21 +1714,21 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
1714
1714
|
primary: e[0] ?? null
|
|
1715
1715
|
})), this.drawingManager.setForeignHistory((e, t) => {
|
|
1716
1716
|
e.type === "custom" ? e.custom?.[t]() : this.applyIndicatorStep(e, t);
|
|
1717
|
-
}), this.drawingManager.setDataGetter(() => this.series.bars(), () => this.series.revision()), this.drawingManager.setDisplayDataGetter(() => this.getDisplayData()), t.crosshair?.mode === "magnet" && this.features.drawingMagnet && this.drawingManager.setMagnetMode("magnet"), this.tradingManager = new
|
|
1717
|
+
}), this.drawingManager.setDataGetter(() => this.series.bars(), () => this.series.revision()), this.drawingManager.setDisplayDataGetter(() => this.getDisplayData()), t.crosshair?.mode === "magnet" && this.features.drawingMagnet && this.drawingManager.setMagnetMode("magnet"), this.tradingManager = new xt({
|
|
1718
1718
|
enabled: this.features.trading,
|
|
1719
1719
|
contextMenu: { enabled: this.features.tradingContextMenu }
|
|
1720
|
-
}), this.tradingRenderer = new
|
|
1720
|
+
}), this.tradingRenderer = new St(this.tradingManager), this.tradingManager.setContainer(e), this.tradingManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradingManager.setEventCallback((e, t) => {
|
|
1721
1721
|
this.eventBus.emit(e, t);
|
|
1722
|
-
}), this.engine = new
|
|
1722
|
+
}), this.engine = new at(e, t.maxPixelRatio);
|
|
1723
1723
|
let a = this.engine.dprManager.getContainerSize();
|
|
1724
|
-
if (this.viewport = new
|
|
1724
|
+
if (this.viewport = new wt(a.width, a.height, t.minBarSpacing ?? 2, t.maxBarSpacing ?? 30, t.rightMargin ?? 5), t.barLayout && this.viewport.setBarLayout(t.barLayout), this.viewport.setPanLimits({
|
|
1725
1725
|
freePan: t.freePan ?? !0,
|
|
1726
1726
|
minVisibleBars: t.panLimits?.minVisibleBars ?? 3
|
|
1727
1727
|
}), t.minBarUnit !== void 0 && this.viewport.setMinBarUnit(t.minBarUnit), this.layoutManager.resize(a.width, a.height), this.engine.onContainerResize = (e) => {
|
|
1728
1728
|
if (e.width <= 0 || e.height <= 0) return;
|
|
1729
1729
|
let t = this.viewport.isAtEnd();
|
|
1730
1730
|
this.viewport.resize(e.width, e.height), this.layoutManager.resize(e.width, e.height), this.updateViewportAndRender(t), this.eventBus.emit("resize", e);
|
|
1731
|
-
}, this.chartRenderer = this.createChartRenderer(this.options.chartType), this.gridRenderer = new Le(), t.grid?.visible === !1 && this.gridRenderer.setVisible(!1), this.priceAxis = new
|
|
1731
|
+
}, this.chartRenderer = this.createChartRenderer(this.options.chartType), this.gridRenderer = new Le(), t.grid?.visible === !1 && this.gridRenderer.setVisible(!1), this.priceAxis = new nt(), this.priceAxis.setLocale(this.numberLocale), this.leftPriceAxis.setLocale(this.numberLocale), this.viewport.setNumberLocale(this.numberLocale), this.timeAxis = new yt(), this.timeAxis.setLocale(this.numberLocale), this.crosshairHandler = new Oe(), this.crosshairHandler.setLocale(this.numberLocale), this.applyTimeSpacing(), t.crosshair?.mode && this.crosshairHandler.setMode(t.crosshair.mode), this.crosshairHandler.setDataSource(() => this.crosshairSeries()), this.crosshairHandler.setCallback((e, t) => {
|
|
1732
1732
|
if (e !== null && t) {
|
|
1733
1733
|
let n = this.crosshairSeries(), i = e >= 0 && e < n.length ? n[e] : void 0, a = e > 0 ? n[e - 1]?.close : void 0, o = A(n), s = i ? o[e]?.time ?? i.time : void 0;
|
|
1734
1734
|
this.chartLegend.setHoverBar(i ?? null, e > 0 ? n[e - 1] ?? null : null), this.features.legend && this.engine.requestRender(r.Hover);
|
|
@@ -1742,7 +1742,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
1742
1742
|
prevClose: a,
|
|
1743
1743
|
priceRange: c.priceRange,
|
|
1744
1744
|
plot: c.chartRect,
|
|
1745
|
-
barStepMs:
|
|
1745
|
+
barStepMs: At(o),
|
|
1746
1746
|
timeUnit: u(o)
|
|
1747
1747
|
});
|
|
1748
1748
|
} else this.crosshairTooltip.hide();
|
|
@@ -1760,12 +1760,12 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
1760
1760
|
}
|
|
1761
1761
|
}), this.chartLegend = new Se(), this.chartLegend.setChartType(this.options.chartType), this.chartLegend.setLocale(this.numberLocale), this.chartLegend.setResizeListener(() => {
|
|
1762
1762
|
this.eventBus.emit("legendResize", { bottom: this.getLegendBottom() }), this.engine.requestRender();
|
|
1763
|
-
}), this.watermark = new
|
|
1763
|
+
}), this.watermark = new Ot(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new Dt(), this.volumeProfile = new Et(), this.marketProfile = new qe(), this.depthHeatmap = new Me(), this.periodLevels = new Qe(), this.pivotMarkers = new et(), this.barCountdown = new ve(), this.barCountdown.setVisible(this.features.barCountdown), this.sessionBreaks = new ft(), this.sessionShading = new pt(), this.compareRenderer = new Ce(), t.sessionBreaks ? this.sessionBreaks.setConfig({
|
|
1764
1764
|
visible: t.sessionBreaks.visible ?? !0,
|
|
1765
1765
|
color: t.sessionBreaks.color,
|
|
1766
1766
|
lineStyle: t.sessionBreaks.lineStyle,
|
|
1767
1767
|
lineWidth: t.sessionBreaks.lineWidth
|
|
1768
|
-
}) : 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
|
|
1768
|
+
}) : 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(ei(t.shapes)), t.font && this.themeManager.setFont($r(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({
|
|
1769
1769
|
scrollBars: (e) => {
|
|
1770
1770
|
let t = this.viewport.getState().barWidth + this.viewport.getState().barSpacing;
|
|
1771
1771
|
this.viewport.scrollBy(e * t), this.updateViewportAndRender();
|
|
@@ -1782,7 +1782,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
1782
1782
|
},
|
|
1783
1783
|
fitContent: () => this.fitContent()
|
|
1784
1784
|
}), this.keyboardHandler.setEnabled(this.features.keyboard), t.a11y !== !1) {
|
|
1785
|
-
this.a11y = new
|
|
1785
|
+
this.a11y = new on(e, {
|
|
1786
1786
|
symbol: () => this.currentSymbol || this.symbolInfo?.symbol || "",
|
|
1787
1787
|
timeframe: () => this.streamTimeframe ?? "",
|
|
1788
1788
|
chartType: () => this.options.chartType ?? "candlestick",
|
|
@@ -1809,7 +1809,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
1809
1809
|
}
|
|
1810
1810
|
this.keyboardHandler.handleKey(e) && (e.preventDefault(), this.a11y?.viewMoved());
|
|
1811
1811
|
}
|
|
1812
|
-
}, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new Ae(), this.currentPriceLine.setLocale(this.numberLocale), this.priceAxis.setReservedPriceProvider(() => this.currentPriceLine.isVisible() ? this.currentPriceLine.getPrice() : null), this.alertManager = new me(), this.alertManager.setDrawingLevels((e) => this.drawingLevelsNow(e)), this.alertManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.compareRenderer.setReservedLevels(() => this.alertManager.getAlerts().filter(
|
|
1812
|
+
}, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new Ae(), this.currentPriceLine.setLocale(this.numberLocale), this.priceAxis.setReservedPriceProvider(() => this.currentPriceLine.isVisible() ? this.currentPriceLine.getPrice() : null), this.alertManager = new me(), this.alertManager.setDrawingLevels((e) => this.drawingLevelsNow(e)), this.alertManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.compareRenderer.setReservedLevels(() => this.alertManager.getAlerts().filter(Nt).map((e) => e.price)), this.alertManager.on("triggered", (e) => {
|
|
1813
1813
|
this.eventBus.emit("alertTriggered", J(e)), this.eventBus.emit("dataUpdate", {
|
|
1814
1814
|
kind: "alert",
|
|
1815
1815
|
alert: "triggered",
|
|
@@ -1825,7 +1825,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
1825
1825
|
this.eventBus.emit("alertExpired", J(e));
|
|
1826
1826
|
}), this.alertManager.on("updated", (e) => {
|
|
1827
1827
|
this.eventBus.emit("alertUpdate", J(e));
|
|
1828
|
-
}), this.signalMarkerManager = new
|
|
1828
|
+
}), this.signalMarkerManager = new mt(), this.signalMarkerManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.signalMarkerManager.setDataGetter(() => this.series.bars()), this.signalMarkerManager.on("added", (e) => {
|
|
1829
1829
|
this.eventBus.emit("signalMarkerAdd", {
|
|
1830
1830
|
id: e.id,
|
|
1831
1831
|
source: e.source,
|
|
@@ -1833,14 +1833,14 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
1833
1833
|
});
|
|
1834
1834
|
}), this.signalMarkerManager.on("removed", (e) => {
|
|
1835
1835
|
this.eventBus.emit("signalMarkerRemove", { id: e });
|
|
1836
|
-
}), this.tradeZoneManager = new
|
|
1836
|
+
}), this.tradeZoneManager = new bt(), this.tradeZoneManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradeZoneManager.setDataGetter(() => this.series.bars()), this.tradeZoneManager.on("added", (e) => {
|
|
1837
1837
|
this.eventBus.emit("tradeZoneAdd", {
|
|
1838
1838
|
id: e.id,
|
|
1839
1839
|
direction: e.direction
|
|
1840
1840
|
});
|
|
1841
1841
|
}), this.tradeZoneManager.on("removed", (e) => {
|
|
1842
1842
|
this.eventBus.emit("tradeZoneRemove", { id: e });
|
|
1843
|
-
}), this.replayManager = new
|
|
1843
|
+
}), this.replayManager = new st(), this.replayManager.on("complete", () => {
|
|
1844
1844
|
let e = this.getReplayBarIndex(), t = this.replayCoarse?.[e];
|
|
1845
1845
|
t && this.eventBus.emit("replayComplete", {
|
|
1846
1846
|
barIndex: e,
|
|
@@ -1849,8 +1849,8 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
1849
1849
|
}), this.replayManager.on("stateChange", (e) => {
|
|
1850
1850
|
this.replayRestarting || this.eventBus.emit("replayState", { state: e });
|
|
1851
1851
|
}), this.measureOverlay = new Je(), this.interactionManager = new He(e), this.features.panning) {
|
|
1852
|
-
let e = new
|
|
1853
|
-
this.interactionManager.setPanHandler(new
|
|
1852
|
+
let e = new sr();
|
|
1853
|
+
this.interactionManager.setPanHandler(new Xe((t, n) => {
|
|
1854
1854
|
t && this.viewport.scrollBy(t), e.step(t, n, this.options.autoScale !== !1) && n && (this.holdPriceScale(), this.viewport.panPriceRange(n)), this.updateViewportAndRender();
|
|
1855
1855
|
}, () => e.reset()));
|
|
1856
1856
|
}
|
|
@@ -1862,7 +1862,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
1862
1862
|
scales: !this.indicatorEngine.hasLeftScaleOverlays()
|
|
1863
1863
|
}
|
|
1864
1864
|
})), this.features.zooming) {
|
|
1865
|
-
this.interactionManager.setZoomHandler(new
|
|
1865
|
+
this.interactionManager.setZoomHandler(new kt((e, t) => {
|
|
1866
1866
|
this.viewport.zoom(e, t - this.viewport.getState().chartRect.x), this.updateViewportAndRender();
|
|
1867
1867
|
}));
|
|
1868
1868
|
let e = new _e((e) => {
|
|
@@ -1884,8 +1884,8 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
1884
1884
|
x: t.x,
|
|
1885
1885
|
y: t.y
|
|
1886
1886
|
});
|
|
1887
|
-
})), this.interactionManager.setChartContextMenu((e, t) => this.eventBus.hasListeners("chartContextMenu") ? (this.eventBus.emit("chartContextMenu", this.contextAt(e, t)), !0) : !1), this.
|
|
1888
|
-
let t =
|
|
1887
|
+
})), 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) => {
|
|
1888
|
+
let t = Zt(e.y, this.viewport.getState());
|
|
1889
1889
|
Number.isFinite(t) && this.eventBus.emit("priceAxisAdd", {
|
|
1890
1890
|
price: t,
|
|
1891
1891
|
x: e.x,
|
|
@@ -1898,7 +1898,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
1898
1898
|
let e = new pe(this.alertManager, () => this.viewport.getState());
|
|
1899
1899
|
this.interactionManager.setAlertDragHandler(e);
|
|
1900
1900
|
}
|
|
1901
|
-
let o = new
|
|
1901
|
+
let o = new Ze();
|
|
1902
1902
|
o.configure(() => this.getResolvedLayout(), (e, t) => this.setPanelSize(e, t)), this.interactionManager.setPaneResizeHandler(o), this.interactionManager.setAltClickHandler((e) => {
|
|
1903
1903
|
let t = this.getDisplayData();
|
|
1904
1904
|
if (t.length === 0) return;
|
|
@@ -1922,7 +1922,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
1922
1922
|
x: e.x,
|
|
1923
1923
|
y: e.y
|
|
1924
1924
|
}), t.length === 0) return;
|
|
1925
|
-
let r =
|
|
1925
|
+
let r = Xt(e.x, this.viewport.getState());
|
|
1926
1926
|
r < 0 || r >= t.length || this.eventBus.emit("barClick", {
|
|
1927
1927
|
bar: t[r],
|
|
1928
1928
|
barIndex: r,
|
|
@@ -1965,7 +1965,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
1965
1965
|
end: () => {
|
|
1966
1966
|
let e = this.selectionBoxOverlay.end();
|
|
1967
1967
|
if (e && this.zoomAreaMode) {
|
|
1968
|
-
if (e.x1 - e.x0 <
|
|
1968
|
+
if (e.x1 - e.x0 < Gr) return;
|
|
1969
1969
|
this.zoomToBox(e), this.setZoomAreaMode(!1);
|
|
1970
1970
|
return;
|
|
1971
1971
|
}
|
|
@@ -2049,7 +2049,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
2049
2049
|
let { visibleRange: e, chartRect: t } = this.viewport.getState();
|
|
2050
2050
|
if (t.width <= 0) return;
|
|
2051
2051
|
let { from: n, to: r } = e;
|
|
2052
|
-
this.history.maybeLoad(Math.max(0, Math.floor(n)), Math.max(
|
|
2052
|
+
this.history.maybeLoad(Math.max(0, Math.floor(n)), Math.max(Wr, r - n));
|
|
2053
2053
|
}));
|
|
2054
2054
|
}
|
|
2055
2055
|
useStreamHistory(e, t, n = !0) {
|
|
@@ -2165,7 +2165,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
2165
2165
|
return this.extendedHours;
|
|
2166
2166
|
}
|
|
2167
2167
|
sessionKeep(e) {
|
|
2168
|
-
return this.extendedHours ? null :
|
|
2168
|
+
return this.extendedHours ? null : en(this.symbolInfo, e);
|
|
2169
2169
|
}
|
|
2170
2170
|
reapplyExtendedHours() {
|
|
2171
2171
|
if (!this.series.refilter()) return;
|
|
@@ -2176,7 +2176,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
2176
2176
|
return this.priceLines.setQuoteShown(this.replaySession === null), this.priceLines;
|
|
2177
2177
|
}
|
|
2178
2178
|
setShapes(e) {
|
|
2179
|
-
let t =
|
|
2179
|
+
let t = ei(e);
|
|
2180
2180
|
t.tagRadius !== void 0 && (this.themeManager.setShape({
|
|
2181
2181
|
...this.themeManager.getTheme().shape,
|
|
2182
2182
|
...t
|
|
@@ -2188,7 +2188,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
2188
2188
|
setFont(e) {
|
|
2189
2189
|
if (e === null) this.themeManager.setFont(null);
|
|
2190
2190
|
else {
|
|
2191
|
-
let t =
|
|
2191
|
+
let t = $r(e);
|
|
2192
2192
|
if (Object.keys(t).length === 0) return;
|
|
2193
2193
|
this.themeManager.setFont(t);
|
|
2194
2194
|
}
|
|
@@ -2330,8 +2330,8 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
2330
2330
|
return {
|
|
2331
2331
|
...e,
|
|
2332
2332
|
priceRange: {
|
|
2333
|
-
min: t.min - n *
|
|
2334
|
-
max: t.max + n *
|
|
2333
|
+
min: t.min - n * Vr,
|
|
2334
|
+
max: t.max + n * Vr
|
|
2335
2335
|
},
|
|
2336
2336
|
logScale: !1,
|
|
2337
2337
|
scaleMode: "regular",
|
|
@@ -2412,7 +2412,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
2412
2412
|
}
|
|
2413
2413
|
static indicators() {
|
|
2414
2414
|
let e = new Ve();
|
|
2415
|
-
return
|
|
2415
|
+
return Ht(e), e.getAvailableIndicators();
|
|
2416
2416
|
}
|
|
2417
2417
|
setPanelPosition(e, t) {
|
|
2418
2418
|
this.layoutManager.setPanelPosition(e, t), this.updateViewportAndRender(), this.eventBus.emit("indicatorChange", {
|
|
@@ -2660,7 +2660,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
2660
2660
|
}
|
|
2661
2661
|
autoFib() {
|
|
2662
2662
|
if (!this.features.drawings) return null;
|
|
2663
|
-
let e = this.getDisplayData(), t = this.viewport.getState(), n =
|
|
2663
|
+
let e = this.getDisplayData(), t = this.viewport.getState(), n = jt(e, t.visibleRange.from, t.visibleRange.to);
|
|
2664
2664
|
return n ? this.addDrawing({
|
|
2665
2665
|
type: "fibRetracement",
|
|
2666
2666
|
anchors: [n[0], n[1]]
|
|
@@ -2738,7 +2738,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
2738
2738
|
recordUndo(e) {
|
|
2739
2739
|
if (!this.features.drawingUndoRedo || typeof e?.undo != "function" || typeof e.redo != "function") return;
|
|
2740
2740
|
let t = performance.now(), n = this.undoRedoManager.last();
|
|
2741
|
-
if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at <
|
|
2741
|
+
if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at < Ur) {
|
|
2742
2742
|
this.undoRedoManager.replaceLast({
|
|
2743
2743
|
...n,
|
|
2744
2744
|
custom: {
|
|
@@ -2785,14 +2785,18 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
2785
2785
|
x: t.x,
|
|
2786
2786
|
y: t.y
|
|
2787
2787
|
};
|
|
2788
|
-
if ((e === "plot" || e === "priceAxis") && (r.price =
|
|
2788
|
+
if ((e === "plot" || e === "priceAxis") && (r.price = Zt(t.y, n)), (e === "plot" || e === "timeAxis") && n.data.length > 0 && (r.time = F(t.x, n)), e === "pane") {
|
|
2789
2789
|
let e = this.getIndicatorPanes().find((e) => t.y >= e.rect.y && t.y <= e.rect.y + e.rect.height);
|
|
2790
2790
|
e && (r.pane = e.instanceId);
|
|
2791
2791
|
}
|
|
2792
2792
|
return r;
|
|
2793
2793
|
}
|
|
2794
|
+
applyPriceAxisAdd() {
|
|
2795
|
+
let e = this.features.priceAxisAddButton && this.features.crosshair;
|
|
2796
|
+
this.priceAxisAddButton.setEnabled(e), this.tradingManager.setTagInset(e ? Ye : 0);
|
|
2797
|
+
}
|
|
2794
2798
|
setPriceAxisAddButton(e) {
|
|
2795
|
-
this.features.priceAxisAddButton = e, this.
|
|
2799
|
+
this.features.priceAxisAddButton = e, this.applyPriceAxisAdd(), this.engine.requestRender(r.Overlay);
|
|
2796
2800
|
}
|
|
2797
2801
|
setEraserMode(e) {
|
|
2798
2802
|
e && this.setZoomAreaMode(!1), this.drawingManager.setEraser(e && this.features.drawings);
|
|
@@ -2856,7 +2860,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
2856
2860
|
for (let e of this.indicatorEngine.getActiveIndicators()) {
|
|
2857
2861
|
let t = this.indicatorEngine.getOutput(e.instanceId)?.series;
|
|
2858
2862
|
if (!t) continue;
|
|
2859
|
-
let r =
|
|
2863
|
+
let r = dn(e.id, e.params, e.descriptor.defaultConfig, e.descriptor.shortName), o = e.descriptor.plots ?? Object.keys(t.find((e) => e) ?? {}).map((e) => ({
|
|
2860
2864
|
key: e,
|
|
2861
2865
|
title: e
|
|
2862
2866
|
}));
|
|
@@ -3067,7 +3071,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
3067
3071
|
}
|
|
3068
3072
|
async connect(e) {
|
|
3069
3073
|
if (!j(e.adapter, e.timeframe)) throw RangeError(`${e.adapter.name} cannot serve the ${e.timeframe} timeframe`);
|
|
3070
|
-
this.snapshotKey = null, this.holdReplayFor(e.symbol), this.disconnectStream(), this.streamManager = new
|
|
3074
|
+
this.snapshotKey = null, this.holdReplayFor(e.symbol), this.disconnectStream(), this.streamManager = new _t(), this.streamManager.setTimeZone(this.studyZoneHeld ? this.studyZone : this.getExchangeTimeZone()), this.streamManager.on("snapshot", (t) => {
|
|
3071
3075
|
let n = this.streamSeriesKey(e.adapter);
|
|
3072
3076
|
n === this.snapshotKey && this.replaySession ? this.series.mergeSnapshot(t) : n === this.snapshotKey && this.series.length() > 0 ? this.mergeSnapshot(t) : (this.replaySession && this.useStreamHistory(e.adapter, e.historyPageSize, !1), this.setData(t)), this.snapshotKey = n, this.useStreamHistory(e.adapter, e.historyPageSize);
|
|
3073
3077
|
}), this.streamManager.on("barClose", (e) => {
|
|
@@ -3129,7 +3133,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
3129
3133
|
}, 1e3);
|
|
3130
3134
|
}
|
|
3131
3135
|
streamSeriesKey(e) {
|
|
3132
|
-
let t = P(e), n = this.streamTimeframe, r = t instanceof
|
|
3136
|
+
let t = P(e), n = this.streamTimeframe, r = t instanceof ct && n !== null ? t.bucketFor(this.currentSymbol, n) : null;
|
|
3133
3137
|
return `${this.currentSymbol}|${n}|${r?.timeZone ?? ""}`;
|
|
3134
3138
|
}
|
|
3135
3139
|
setStreamTarget(e, t) {
|
|
@@ -3172,7 +3176,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
3172
3176
|
}
|
|
3173
3177
|
connectExecution(e, t = {}) {
|
|
3174
3178
|
if (!this.features.trading) throw Error("connectExecution requires features.trading to be enabled");
|
|
3175
|
-
this.disconnectExecution(), this.executionAdapter = e, this.execTeardown =
|
|
3179
|
+
this.disconnectExecution(), this.executionAdapter = e, this.execTeardown = _r(e, {
|
|
3176
3180
|
onIntent: (e, t) => {
|
|
3177
3181
|
let n = (e) => t(e.payload);
|
|
3178
3182
|
return this.eventBus.on(e, n), () => this.eventBus.off(e, n);
|
|
@@ -3311,7 +3315,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
3311
3315
|
setVisibleRangePreset(e) {
|
|
3312
3316
|
let t = this.getDisplayData();
|
|
3313
3317
|
if (t.length === 0) return;
|
|
3314
|
-
let n = t.length - 1, r = u(t), i =
|
|
3318
|
+
let n = t.length - 1, r = u(t), i = zt(e, t[n].time * r, this.displayTz), a = i === null ? null : i / r;
|
|
3315
3319
|
if (a === null || a < t[0].time) {
|
|
3316
3320
|
this.fitContent();
|
|
3317
3321
|
return;
|
|
@@ -3588,7 +3592,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
3588
3592
|
return this.periodLevels.getPeriod();
|
|
3589
3593
|
}
|
|
3590
3594
|
setTimeZone(e) {
|
|
3591
|
-
|
|
3595
|
+
zr(e), this.timeZoneSetting = e, this.applyTimeZone();
|
|
3592
3596
|
}
|
|
3593
3597
|
getTimeZone() {
|
|
3594
3598
|
return this.timeZoneSetting;
|
|
@@ -3624,7 +3628,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
3624
3628
|
this.indicatorEngine.setExchangeTimeZone(e, t.length > 0 ? t : void 0) && t.length > 0 && this.announceIndicatorUpdate(0);
|
|
3625
3629
|
}
|
|
3626
3630
|
holdStudyZone() {
|
|
3627
|
-
this.endStudyZoneWait(), this.studyZoneHeld = !0, this.studyZoneTimer = setTimeout(() => this.releaseStudyZone(),
|
|
3631
|
+
this.endStudyZoneWait(), this.studyZoneHeld = !0, this.studyZoneTimer = setTimeout(() => this.releaseStudyZone(), ut);
|
|
3628
3632
|
}
|
|
3629
3633
|
endStudyZoneWait() {
|
|
3630
3634
|
this.studyZoneReleaseQueued = !1, this.studyZoneTimer !== null && (clearTimeout(this.studyZoneTimer), this.studyZoneTimer = null);
|
|
@@ -3653,7 +3657,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
3653
3657
|
}
|
|
3654
3658
|
useSymbolInfo(e) {
|
|
3655
3659
|
let t = e && this.symbolInfo?.symbol === e.symbol ? C(this.symbolInfo) : void 0;
|
|
3656
|
-
this.symbolInfo = e ?
|
|
3660
|
+
this.symbolInfo = e ? Br({
|
|
3657
3661
|
...e,
|
|
3658
3662
|
sessions: e.sessions?.map((e) => ({ ...e }))
|
|
3659
3663
|
}, 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);
|
|
@@ -3678,7 +3682,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
3678
3682
|
if (!e || typeof e != "object") return;
|
|
3679
3683
|
let t = this.currentSymbol, n = (e) => !e || e.toUpperCase() === t.toUpperCase();
|
|
3680
3684
|
if (!n(e.symbol)) return;
|
|
3681
|
-
let r = this.symbolInfo && n(this.symbolInfo.symbol) ? this.symbolInfo : null, i =
|
|
3685
|
+
let r = this.symbolInfo && n(this.symbolInfo.symbol) ? this.symbolInfo : null, i = Br({
|
|
3682
3686
|
...r,
|
|
3683
3687
|
...e,
|
|
3684
3688
|
symbol: e.symbol || r?.symbol || t
|
|
@@ -3717,7 +3721,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
3717
3721
|
return this.sessionShading.isVisible();
|
|
3718
3722
|
}
|
|
3719
3723
|
setSessionShadingConfig(e) {
|
|
3720
|
-
this.hostSessionHours =
|
|
3724
|
+
this.hostSessionHours = It(this.hostSessionHours, e), this.sessionShading.replaceConfig(this.hostSessionHours), this.engine.requestRender(r.Background);
|
|
3721
3725
|
}
|
|
3722
3726
|
setTooltipVisible(e) {
|
|
3723
3727
|
e || this.crosshairTooltip.hide();
|
|
@@ -3739,11 +3743,11 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
3739
3743
|
return this.waitForGpu(null), e === "canvas" ? (this.applyRenderer(null), "canvas") : this.engine.getGpu() ? "webgl" : this.takeGpu(e, t, !0);
|
|
3740
3744
|
}
|
|
3741
3745
|
async takeGpu(e, t, n) {
|
|
3742
|
-
let { gpu: r, reason: i } = await
|
|
3743
|
-
return t !== this.rendererToken || this.disposed ? (r?.destroy(), this.getRenderer()) : i === "limit" ?
|
|
3746
|
+
let { gpu: r, reason: i } = await Ft(e);
|
|
3747
|
+
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());
|
|
3744
3748
|
}
|
|
3745
3749
|
waitForGpu(e) {
|
|
3746
|
-
this.stopWaitingForGpu?.(), this.stopWaitingForGpu = e ?
|
|
3750
|
+
this.stopWaitingForGpu?.(), this.stopWaitingForGpu = e ? Yt(e) : null;
|
|
3747
3751
|
}
|
|
3748
3752
|
getRenderer() {
|
|
3749
3753
|
return this.engine.getGpu() ? "webgl" : "canvas";
|
|
@@ -3921,7 +3925,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
3921
3925
|
let t = this.replaySession ? this.replayOffset : 0;
|
|
3922
3926
|
if (!this.replaySession) {
|
|
3923
3927
|
if (this.series.length() === 0) return;
|
|
3924
|
-
this.series.beginReplay(), this.replaySession =
|
|
3928
|
+
this.series.beginReplay(), this.replaySession = ci(this.currentSymbol);
|
|
3925
3929
|
}
|
|
3926
3930
|
let n = this.replaySession, { steps: r, startTime: i, hideHistory: a, revealMarks: o, step: s, ...c } = e ?? {};
|
|
3927
3931
|
c.animate = c.animate === !0;
|
|
@@ -3932,13 +3936,13 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
3932
3936
|
let m = r ? this.replayStepsOver(n, p, !0) : null;
|
|
3933
3937
|
this.options.autoScale = !0, this.buildReplay(p, m, f);
|
|
3934
3938
|
let h = this.replayStepsSeries;
|
|
3935
|
-
h && c.startIndex !== void 0 && (c.startIndex =
|
|
3939
|
+
h && c.startIndex !== void 0 && (c.startIndex = _i(h, p, c.startIndex));
|
|
3936
3940
|
let g = h ?? p, _ = g[Math.max(0, Math.min(Math.floor(Number(c.startIndex ?? 0)) || 0, g.length - 1))];
|
|
3937
3941
|
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);
|
|
3938
3942
|
}
|
|
3939
3943
|
buildReplay(e, t, n) {
|
|
3940
3944
|
let r = this.replaySession?.animate === !0, i = r ? null : t;
|
|
3941
|
-
this.replayPieces = r && t ?
|
|
3945
|
+
this.replayPieces = r && t ? bi(t, e) : null, this.replayForming = null, this.replayOffset = n, this.replayStepsSeries = i, this.replayCoarse = e;
|
|
3942
3946
|
let a = this.replayRestarting;
|
|
3943
3947
|
this.replayRestarting = !0;
|
|
3944
3948
|
try {
|
|
@@ -3952,7 +3956,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
3952
3956
|
let n = t, a = e[t];
|
|
3953
3957
|
if (i) {
|
|
3954
3958
|
let r = i[t];
|
|
3955
|
-
n = Q(e, r.time), c = c !== null && s === t - 1 && n === o - 1 && c ?
|
|
3959
|
+
n = Q(e, r.time), c = c !== null && s === t - 1 && n === o - 1 && c ? Si(c, r) : vi(e[n], i, t), a = yi(i, e, t, n) ? e[n] : c;
|
|
3956
3960
|
}
|
|
3957
3961
|
let u = this.replayForming;
|
|
3958
3962
|
this.replayForming = null, s = t;
|
|
@@ -3976,7 +3980,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
3976
3980
|
});
|
|
3977
3981
|
}), r && (this.replayPhaseUnsub = this.replayManager.on("phase", ({ index: t, fraction: n }) => {
|
|
3978
3982
|
if (!e[t] || this.series.length() !== o || o !== t && o !== t + 1) return;
|
|
3979
|
-
let r = this.replayForming?.index === t ? this.replayForming.path : this.replayPathOf(e, t), i =
|
|
3983
|
+
let r = this.replayForming?.index === t ? this.replayForming.path : this.replayPathOf(e, t), i = xi() ? Mr(r, n) : n, a = o === t, s = a && this.autoScrollOnNewBar && this.viewport.isAtEnd(), c = jr(r, i);
|
|
3980
3984
|
a ? this.series.appendReplayed(c) : this.series.updateReplayed(c), o = t + 1, this.replayForming = {
|
|
3981
3985
|
index: t,
|
|
3982
3986
|
path: r
|
|
@@ -3986,7 +3990,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
3986
3990
|
drawFormingBar(e, t, n, r) {
|
|
3987
3991
|
this.currentPriceLine.setPrice(e.close, t);
|
|
3988
3992
|
let i = this.series.bars();
|
|
3989
|
-
if (this.recalcIndicatorsFrom(i, i.length - 1), (n || !
|
|
3993
|
+
if (this.recalcIndicatorsFrom(i, i.length - 1), (n || !ii.has(this.options.chartType)) && (this.displayDataCache = null), !n) {
|
|
3990
3994
|
this.scheduleRender();
|
|
3991
3995
|
return;
|
|
3992
3996
|
}
|
|
@@ -3994,19 +3998,19 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
3994
3998
|
}
|
|
3995
3999
|
replayPathOf(e, t) {
|
|
3996
4000
|
let n = e[t];
|
|
3997
|
-
return
|
|
4001
|
+
return Er(n, this.replayPieces?.get(n.time) ?? this.replayLoader?.loader.piecesOf(n.time) ?? []);
|
|
3998
4002
|
}
|
|
3999
4003
|
loadReplaySteps(e, t) {
|
|
4000
4004
|
let n = this.replayLoader?.loader;
|
|
4001
4005
|
if (!n) return;
|
|
4002
4006
|
n.evictBefore(e[t].time);
|
|
4003
4007
|
let r = this.replayManager.getStepMs();
|
|
4004
|
-
n.ensure(e, t, Number.isFinite(r) && r > 0 ? Math.ceil(
|
|
4008
|
+
n.ensure(e, t, Number.isFinite(r) && r > 0 ? Math.ceil(ri / r) : 1);
|
|
4005
4009
|
}
|
|
4006
4010
|
useReplayLoader(e, t) {
|
|
4007
|
-
let n = this.streamAdapter, r = this.streamTimeframe, i = e.step && n && r !== null ?
|
|
4011
|
+
let n = this.streamAdapter, r = this.streamTimeframe, i = e.step && n && r !== null ? Fr(e.step, r, (e) => j(n, e)) : null, a = `${this.currentSymbol}|${r}|${i}`;
|
|
4008
4012
|
if (!t && this.replayLoader?.key === a || (this.replayLoader?.loader.dispose(), this.replayLoader = null, !i || !n || r === null)) return;
|
|
4009
|
-
let o = P(n), s = o.fetchHistoryBefore, c = this.currentSymbol, l = w(r), u = new
|
|
4013
|
+
let o = P(n), s = o.fetchHistoryBefore, c = this.currentSymbol, l = w(r), u = new yr({
|
|
4010
4014
|
source: s ? (e, t) => s.call(o, c, i, e, t) : null,
|
|
4011
4015
|
step: i,
|
|
4012
4016
|
ratio: Math.max(1, Math.round(l / w(i))),
|
|
@@ -4024,7 +4028,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
4024
4028
|
if (!i || !a?.setMarkPrice || !o) return;
|
|
4025
4029
|
let s = i.fedTime;
|
|
4026
4030
|
if (s === null) {
|
|
4027
|
-
i.fedTime = o.time, i.fedFraction = r, this.feedReplayPrice(
|
|
4031
|
+
i.fedTime = o.time, i.fedFraction = r, this.feedReplayPrice(jr(n, r).close, o.time);
|
|
4028
4032
|
return;
|
|
4029
4033
|
}
|
|
4030
4034
|
if (o.time < s || o.time === s && r <= i.fedFraction) return;
|
|
@@ -4032,8 +4036,8 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
4032
4036
|
if (o.time > s) {
|
|
4033
4037
|
let a = Y(e, s);
|
|
4034
4038
|
e[a]?.time === s && i.fedFraction < 1 && c.push(...q(this.replayPathOf(e, a), i.fedFraction, 1));
|
|
4035
|
-
let o = e.slice(X(e, s), t), l = Math.ceil(o.length /
|
|
4036
|
-
for (let e = 0; e < o.length; e += l) c.push(...
|
|
4039
|
+
let o = e.slice(X(e, s), t), l = Math.ceil(o.length / mi);
|
|
4040
|
+
for (let e = 0; e < o.length; e += l) c.push(...hi(o.slice(e, e + l)));
|
|
4037
4041
|
c.push(...q(n, -1, r));
|
|
4038
4042
|
} else c.push(...q(n, i.fedFraction, r));
|
|
4039
4043
|
i.fedTime = o.time, i.fedFraction = r;
|
|
@@ -4052,7 +4056,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
4052
4056
|
if (n.length === 0) return;
|
|
4053
4057
|
let r = t.windowTime === null ? 0 : Math.min(Y(n, t.windowTime), n.length - 1), i = r > 0 ? n.slice(r) : n;
|
|
4054
4058
|
this.useReplayLoader(t, !1);
|
|
4055
|
-
let a = this.replayStepsOver(t, i), o = t.animate ? null : a, s = t.until === null ? 0 :
|
|
4059
|
+
let a = this.replayStepsOver(t, i), o = t.animate ? null : a, s = t.until === null ? 0 : di(o ?? i, t.until);
|
|
4056
4060
|
if (s < 0 && this.canPageBackForReplay(t)) {
|
|
4057
4061
|
this.holdReplay(), t.held && t.held.pagesBack++, queueMicrotask(() => void this.pageBackForReplay(t));
|
|
4058
4062
|
return;
|
|
@@ -4060,7 +4064,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
4060
4064
|
let c = this.getReplayState(), l = t.held !== null && (e === "hours" || e === "bar"), u = t.held?.state ?? c;
|
|
4061
4065
|
l || (t.held = null), t.symbol = this.currentSymbol;
|
|
4062
4066
|
let d = this.replayManager.remainingMs();
|
|
4063
|
-
this.clearBarHolders(), t.animate &&
|
|
4067
|
+
this.clearBarHolders(), t.animate && ui(t, this.replayCoarse, i);
|
|
4064
4068
|
let f = this.replayRestarting;
|
|
4065
4069
|
this.replayRestarting = !0, this.replayCause = e === "older" ? "older" : "series";
|
|
4066
4070
|
try {
|
|
@@ -4083,14 +4087,14 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
4083
4087
|
}
|
|
4084
4088
|
replayStepsOver(e, t, n = !1) {
|
|
4085
4089
|
if (!e.steps || e.stepsSymbol !== this.currentSymbol) return null;
|
|
4086
|
-
let r =
|
|
4087
|
-
return r && (n ||
|
|
4090
|
+
let r = gi(this.series.inHoursShown(e.steps), t);
|
|
4091
|
+
return r && (n || pi(r, t)) ? r : null;
|
|
4088
4092
|
}
|
|
4089
4093
|
canPageBackForReplay(e) {
|
|
4090
|
-
return this.history.hasLoader() && this.history.hasMore() && (e.held?.pagesBack ?? 0) <
|
|
4094
|
+
return this.history.hasLoader() && this.history.hasMore() && (e.held?.pagesBack ?? 0) < ai;
|
|
4091
4095
|
}
|
|
4092
4096
|
async pageBackForReplay(e) {
|
|
4093
|
-
this.replaySession !== e || !e.held || await this.history.loadMore() > 0 || this.replaySession !== e || !e.held || (e.held.pagesBack =
|
|
4097
|
+
this.replaySession !== e || !e.held || await this.history.loadMore() > 0 || this.replaySession !== e || !e.held || (e.held.pagesBack = ai, this.rebaseReplay("older"));
|
|
4094
4098
|
}
|
|
4095
4099
|
holdReplay() {
|
|
4096
4100
|
let e = this.replaySession;
|
|
@@ -4123,7 +4127,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
4123
4127
|
this.signalMarkerManager.setRevealUntil(e, t), this.tradeZoneManager.setRevealUntil(e, t);
|
|
4124
4128
|
}
|
|
4125
4129
|
replaySeekToTime(e) {
|
|
4126
|
-
!this.replaySession || !this.replayCoarse || this.replaySeek(Math.max(0,
|
|
4130
|
+
!this.replaySession || !this.replayCoarse || this.replaySeek(Math.max(0, di(this.replayStepsSeries ?? this.replayCoarse, e)));
|
|
4127
4131
|
}
|
|
4128
4132
|
feedReplayPrice(e, t) {
|
|
4129
4133
|
let n = this.executionAdapter;
|
|
@@ -4145,8 +4149,8 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
4145
4149
|
if (i.time <= n.fedTime) return;
|
|
4146
4150
|
let a = e.slice(X(e, n.fedTime), t + 1);
|
|
4147
4151
|
n.fedTime = i.time;
|
|
4148
|
-
let o = Math.ceil(a.length /
|
|
4149
|
-
for (let e = 0; e < a.length; e += o) for (let [t, n] of
|
|
4152
|
+
let o = Math.ceil(a.length / mi);
|
|
4153
|
+
for (let e = 0; e < a.length; e += o) for (let [t, n] of hi(a.slice(e, e + o))) r.setMarkPrice(t, n);
|
|
4150
4154
|
this.tradingManager.setCurrentPrice(i.close);
|
|
4151
4155
|
}
|
|
4152
4156
|
getReplayBarIndex() {
|
|
@@ -4157,7 +4161,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
4157
4161
|
}
|
|
4158
4162
|
replaySeekToBar(e) {
|
|
4159
4163
|
let t = this.replayStepsSeries;
|
|
4160
|
-
this.replaySeek(t && this.replayCoarse ?
|
|
4164
|
+
this.replaySeek(t && this.replayCoarse ? _i(t, this.replayCoarse, e) : e);
|
|
4161
4165
|
}
|
|
4162
4166
|
replayPause() {
|
|
4163
4167
|
this.setHeldState("paused") || this.replayManager.pause();
|
|
@@ -4193,10 +4197,10 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
4193
4197
|
data: this.getDisplayData()
|
|
4194
4198
|
}, r = n.chartRect, i = Infinity, a = -Infinity, o = Infinity, s = -Infinity;
|
|
4195
4199
|
for (let e of t.anchors) {
|
|
4196
|
-
let t =
|
|
4200
|
+
let t = Ut(e.time, n), r = Rt(e.price, n);
|
|
4197
4201
|
i = Math.min(i, t), a = Math.max(a, t), o = Math.min(o, r), s = Math.max(s, r);
|
|
4198
4202
|
}
|
|
4199
|
-
return
|
|
4203
|
+
return Kr.has(t.type) ? [i, a] = [r.x, r.x + r.width] : t.type === "horizontalRay" && (a = r.x + r.width), qr.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 ? {
|
|
4200
4204
|
x: i,
|
|
4201
4205
|
y: o,
|
|
4202
4206
|
width: a - i,
|
|
@@ -4245,14 +4249,14 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
4245
4249
|
});
|
|
4246
4250
|
}
|
|
4247
4251
|
restoreIndicators(e, t) {
|
|
4248
|
-
let n =
|
|
4252
|
+
let n = Yr(e), r = /* @__PURE__ */ new Map();
|
|
4249
4253
|
this.unrestoredIndicators = [];
|
|
4250
4254
|
let i = new Set(this.indicatorEngine.getAvailableIndicators().map((e) => e.id)), a = [], o = /* @__PURE__ */ new Set();
|
|
4251
4255
|
if (t) {
|
|
4252
4256
|
let e = new Map(n.map((e) => [e.instanceId, e])), t = this.getIndicatorSetup();
|
|
4253
4257
|
for (let n of t) {
|
|
4254
4258
|
let t = e.get(n.instanceId);
|
|
4255
|
-
t &&
|
|
4259
|
+
t && Xr(n, t) && o.add(n.instanceId);
|
|
4256
4260
|
}
|
|
4257
4261
|
for (let e of t) o.has(e.instanceId) || this.removeIndicator(e.instanceId);
|
|
4258
4262
|
for (let e of [...o]) this.indicatorEngine.getIndicatorConfig(e) || o.delete(e);
|
|
@@ -4419,7 +4423,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
4419
4423
|
if (this.indicatorHistoryDepth > 0 || !this.features.drawingUndoRedo) return t();
|
|
4420
4424
|
let n = this.getIndicatorSetup(), r = this.withoutIndicatorHistory(t), i = this.getIndicatorSetup();
|
|
4421
4425
|
if (JSON.stringify(n) === JSON.stringify(i)) return r;
|
|
4422
|
-
let a = performance.now(), o = this.undoRedoManager.last(), s = e !== void 0 && o?.type === "indicators" && o.indicators?.subject === e && a - (o.indicators.at ?? 0) <
|
|
4426
|
+
let a = performance.now(), o = this.undoRedoManager.last(), s = e !== void 0 && o?.type === "indicators" && o.indicators?.subject === e && a - (o.indicators.at ?? 0) < Ur && JSON.stringify(o.indicators.after) === JSON.stringify(n), c = {
|
|
4423
4427
|
type: "indicators",
|
|
4424
4428
|
before: null,
|
|
4425
4429
|
after: null
|
|
@@ -4463,7 +4467,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
4463
4467
|
let t = e.indexOf(":"), r = t > 0 ? n.get(e.slice(0, t)) : void 0;
|
|
4464
4468
|
return r ? r + e.slice(t) : e;
|
|
4465
4469
|
}, r = t(e.channel), i = {
|
|
4466
|
-
...
|
|
4470
|
+
...Bt(e),
|
|
4467
4471
|
...e.target ? { target: t(e.target) } : {}
|
|
4468
4472
|
};
|
|
4469
4473
|
if (!e.expired) {
|
|
@@ -4530,7 +4534,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
4530
4534
|
}
|
|
4531
4535
|
setFeatures(e) {
|
|
4532
4536
|
let t = this.getLegendBottom();
|
|
4533
|
-
Object.assign(this.features, e), e.legend !== void 0 && this.getLegendBottom() !== t && this.eventBus.emit("legendResize", { bottom: this.getLegendBottom() }), (e.crosshair === !1 || e.crosshairTooltip === !1) && this.crosshairTooltip.hide(), e.grid !== void 0 && this.engine.requestRender(r.Background), e.volume !== void 0 && (this.volumeRenderer.setVisible(e.volume), this.updateViewportAndRender()), e.drawings === !1 && this.drawingManager.setActiveTool(null), e.trading === !1 && (this.tradingManager.setOrders([]), this.tradingManager.setPositions([])), e.keyboard !== void 0 && this.keyboardHandler?.setEnabled(e.keyboard), this.engine.requestRender();
|
|
4537
|
+
Object.assign(this.features, e), e.legend !== void 0 && this.getLegendBottom() !== t && this.eventBus.emit("legendResize", { bottom: this.getLegendBottom() }), (e.crosshair === !1 || e.crosshairTooltip === !1) && this.crosshairTooltip.hide(), (e.priceAxisAddButton !== void 0 || e.crosshair !== void 0) && (this.applyPriceAxisAdd(), this.engine.requestRender(r.Overlay)), e.grid !== void 0 && this.engine.requestRender(r.Background), e.volume !== void 0 && (this.volumeRenderer.setVisible(e.volume), this.updateViewportAndRender()), e.drawings === !1 && this.drawingManager.setActiveTool(null), e.trading === !1 && (this.tradingManager.setOrders([]), this.tradingManager.setPositions([])), e.keyboard !== void 0 && this.keyboardHandler?.setEnabled(e.keyboard), this.engine.requestRender();
|
|
4534
4538
|
}
|
|
4535
4539
|
resize() {
|
|
4536
4540
|
let e = this.engine.dprManager.readContainerSize();
|
|
@@ -4545,14 +4549,14 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
4545
4549
|
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 = "";
|
|
4546
4550
|
}
|
|
4547
4551
|
createChartRenderer(e) {
|
|
4548
|
-
let t =
|
|
4552
|
+
let t = jn(e, (e) => this.pluginManager.getChartType(e));
|
|
4549
4553
|
return t instanceof ze && t.setPriceText((e) => this.formatPrice(e)), t;
|
|
4550
4554
|
}
|
|
4551
4555
|
crosshairSeries() {
|
|
4552
4556
|
return this.isTimeAligned() ? this.series.bars() : this.getDisplayData();
|
|
4553
4557
|
}
|
|
4554
4558
|
getDisplayData() {
|
|
4555
|
-
let e = this.series.bars(), t = this.options.chartType === "rangeBars" ?
|
|
4559
|
+
let e = this.series.bars(), t = this.options.chartType === "rangeBars" ? On(e, (e) => this.stepAt(e)) : void 0;
|
|
4556
4560
|
if (this.displayDataCache && t === this.displayDataStep) return this.displayDataCache;
|
|
4557
4561
|
if (e.length === 0) return e;
|
|
4558
4562
|
let n = this.displaySeries(e, t);
|
|
@@ -4560,9 +4564,9 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
4560
4564
|
}
|
|
4561
4565
|
displaySeries(e, t) {
|
|
4562
4566
|
let n = this.options.chartType, r = (e) => this.pluginManager.getChartType(e);
|
|
4563
|
-
if (n !== "pointAndFigure" || r(n)) return
|
|
4564
|
-
let { columns: i, boxSize: a } =
|
|
4565
|
-
return this.chartRenderer instanceof
|
|
4567
|
+
if (n !== "pointAndFigure" || r(n)) return Mn(n, e, r, this.chartTypeOptions, t, this.reshapeMemo);
|
|
4568
|
+
let { columns: i, boxSize: a } = hn(e, this.chartTypeOptions, this.reshapeMemo);
|
|
4569
|
+
return this.chartRenderer instanceof tt && this.chartRenderer.setBoxSize(a), i;
|
|
4566
4570
|
}
|
|
4567
4571
|
recalcIndicatorsFrom(e, t) {
|
|
4568
4572
|
if (!this.isTimeAligned()) return this.recalcIndicators(e);
|
|
@@ -4633,7 +4637,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
4633
4637
|
}
|
|
4634
4638
|
fitPriceScale(e, t) {
|
|
4635
4639
|
if (e.length === 0) return;
|
|
4636
|
-
let n = Math.max(0, t.visibleRange.from), r = Math.min(t.visibleRange.to, e.length - 1), i =
|
|
4640
|
+
let n = Math.max(0, t.visibleRange.from), r = Math.min(t.visibleRange.to, e.length - 1), i = ni(ni(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() && ti(e, n, r) ? this.volumeRenderer.getHeightRatio() + Hr : D;
|
|
4637
4641
|
this.viewport.setScaleMargins(this.viewport.isInvertScale() ? {
|
|
4638
4642
|
top: a,
|
|
4639
4643
|
bottom: D
|
|
@@ -4660,7 +4664,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
4660
4664
|
fitLeftAxisWidth() {
|
|
4661
4665
|
let e = this.leftViewport;
|
|
4662
4666
|
if (!e) return !1;
|
|
4663
|
-
let t = this.themeManager.getTheme(), n =
|
|
4667
|
+
let t = this.themeManager.getTheme(), n = rr({
|
|
4664
4668
|
min: e.priceRange.min,
|
|
4665
4669
|
max: e.priceRange.max,
|
|
4666
4670
|
lastPrice: null,
|
|
@@ -4669,12 +4673,12 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
4669
4673
|
fontFamily: t.font.family,
|
|
4670
4674
|
fontSizeSmall: t.font.sizeSmall,
|
|
4671
4675
|
measure: (e, t) => this.measureText(e, t)
|
|
4672
|
-
}), r =
|
|
4676
|
+
}), r = ir(this.leftAxisWidth, n);
|
|
4673
4677
|
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);
|
|
4674
4678
|
}
|
|
4675
4679
|
fitPriceAxisWidth() {
|
|
4676
4680
|
if (!this.features.priceAxis) return !1;
|
|
4677
|
-
let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n =
|
|
4681
|
+
let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n = rr({
|
|
4678
4682
|
min: e.min,
|
|
4679
4683
|
max: e.max,
|
|
4680
4684
|
lastPrice: this.currentPriceLine.getPrice(),
|
|
@@ -4685,14 +4689,14 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
4685
4689
|
fontFamily: t.font.family,
|
|
4686
4690
|
fontSizeSmall: t.font.sizeSmall,
|
|
4687
4691
|
measure: (e, t) => this.measureText(e, t)
|
|
4688
|
-
}), r =
|
|
4692
|
+
}), r = ir(this.priceAxisWidth, n);
|
|
4689
4693
|
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);
|
|
4690
4694
|
}
|
|
4691
4695
|
measureText(e, t) {
|
|
4692
4696
|
let n = this.engine.layerManager.getLayer(r.Main)?.ctx;
|
|
4693
|
-
if (n?.canvas.isConnected) return this.labelWidths.get(e, t, () =>
|
|
4697
|
+
if (n?.canvas.isConnected) return this.labelWidths.get(e, t, () => Zr(n, e, t));
|
|
4694
4698
|
let i = n ?? this.detachedMeasureContext();
|
|
4695
|
-
return i ?
|
|
4699
|
+
return i ? Zr(i, e, t) : e.length * 7;
|
|
4696
4700
|
}
|
|
4697
4701
|
detachedMeasureContext() {
|
|
4698
4702
|
return this.measureCtx === void 0 && (this.measureCtx = typeof document < "u" ? document.createElement("canvas").getContext("2d") : null), this.measureCtx;
|
|
@@ -4733,7 +4737,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
4733
4737
|
buildPanelRenderInfos() {
|
|
4734
4738
|
if (this.panelInfoCache) return this.panelInfoCache;
|
|
4735
4739
|
let e = this.getResolvedLayout(), t = this.viewport.getState(), { from: n, to: r } = t.visibleRange, i = e.panels.map((e) => {
|
|
4736
|
-
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) ?? { ...
|
|
4740
|
+
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) ?? { ...Ir }, o = {
|
|
4737
4741
|
x: e.rect.x,
|
|
4738
4742
|
y: e.rect.y + 20,
|
|
4739
4743
|
width: e.rect.width,
|
|
@@ -4818,7 +4822,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
4818
4822
|
});
|
|
4819
4823
|
}
|
|
4820
4824
|
drawOverlayPlugins(e, t) {
|
|
4821
|
-
let n =
|
|
4825
|
+
let n = lr(this.pluginManager.getOverlays(), t);
|
|
4822
4826
|
if (n.length === 0) return;
|
|
4823
4827
|
let r = {
|
|
4824
4828
|
viewport: this.viewport.getState(),
|
|
@@ -4839,7 +4843,7 @@ var Br = .08, Vr = a ** -7, Hr = 800, Ur = 20, Wr = 8, Gr = new Set(["horizontal
|
|
|
4839
4843
|
};
|
|
4840
4844
|
}
|
|
4841
4845
|
};
|
|
4842
|
-
function
|
|
4846
|
+
function Yr(e) {
|
|
4843
4847
|
let t = new Map(e.map((e) => [e.instanceId, e])), n = [], r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = (e) => {
|
|
4844
4848
|
if (r.has(e.instanceId) || i.has(e.instanceId)) return;
|
|
4845
4849
|
i.add(e.instanceId);
|
|
@@ -4853,19 +4857,19 @@ function Jr(e) {
|
|
|
4853
4857
|
for (let t of e) a(t);
|
|
4854
4858
|
return n;
|
|
4855
4859
|
}
|
|
4856
|
-
function
|
|
4860
|
+
function Xr(e, t) {
|
|
4857
4861
|
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);
|
|
4858
4862
|
}
|
|
4859
|
-
function
|
|
4863
|
+
function Zr(e, t, n) {
|
|
4860
4864
|
let r = e.font;
|
|
4861
4865
|
e.font = n;
|
|
4862
4866
|
let i = e.measureText(t).width;
|
|
4863
4867
|
return e.font = r, i;
|
|
4864
4868
|
}
|
|
4865
|
-
var
|
|
4866
|
-
function
|
|
4869
|
+
var Qr = 300;
|
|
4870
|
+
function $r(e) {
|
|
4867
4871
|
let t = {}, n = e.family;
|
|
4868
|
-
typeof n == "string" && n.trim() !== "" && n.length <=
|
|
4872
|
+
typeof n == "string" && n.trim() !== "" && n.length <= Qr && !/[;{}<>\\]|\/\*/.test(n) && (t.family = n);
|
|
4869
4873
|
for (let n of [
|
|
4870
4874
|
"sizeSmall",
|
|
4871
4875
|
"sizeMedium",
|
|
@@ -4876,15 +4880,15 @@ function Qr(e) {
|
|
|
4876
4880
|
}
|
|
4877
4881
|
return t;
|
|
4878
4882
|
}
|
|
4879
|
-
function
|
|
4883
|
+
function ei(e) {
|
|
4880
4884
|
let t = e.tagRadius;
|
|
4881
4885
|
return typeof t == "number" && Number.isFinite(t) && t >= 0 ? { tagRadius: Math.min(t, 999) } : {};
|
|
4882
4886
|
}
|
|
4883
|
-
function
|
|
4887
|
+
function ti(e, t, n) {
|
|
4884
4888
|
for (let r = t; r <= n; r++) if (e[r].volume > 0) return !0;
|
|
4885
4889
|
return !1;
|
|
4886
4890
|
}
|
|
4887
|
-
function
|
|
4891
|
+
function ni(e, t) {
|
|
4888
4892
|
return e ? t ? {
|
|
4889
4893
|
min: Math.min(e.min, t.min),
|
|
4890
4894
|
max: Math.max(e.max, t.max)
|
|
@@ -4905,14 +4909,14 @@ function J(e) {
|
|
|
4905
4909
|
bars: e.bars
|
|
4906
4910
|
};
|
|
4907
4911
|
}
|
|
4908
|
-
var
|
|
4912
|
+
var ri = 8e3, ii = new Set([
|
|
4909
4913
|
"candlestick",
|
|
4910
4914
|
"line",
|
|
4911
4915
|
"area",
|
|
4912
4916
|
"bar",
|
|
4913
4917
|
"hollowCandle"
|
|
4914
|
-
]),
|
|
4915
|
-
function
|
|
4918
|
+
]), ai = 10, oi = 50, si = .001;
|
|
4919
|
+
function ci(e) {
|
|
4916
4920
|
return {
|
|
4917
4921
|
price: null,
|
|
4918
4922
|
fedTime: null,
|
|
@@ -4927,41 +4931,41 @@ function si(e) {
|
|
|
4927
4931
|
held: null
|
|
4928
4932
|
};
|
|
4929
4933
|
}
|
|
4930
|
-
function
|
|
4934
|
+
function li(e, t) {
|
|
4931
4935
|
let n = e[t + 1];
|
|
4932
4936
|
return n ? n.time - e[t].time : Z(e);
|
|
4933
4937
|
}
|
|
4934
|
-
function
|
|
4938
|
+
function ui(e, t, n) {
|
|
4935
4939
|
let r = e.fedTime;
|
|
4936
4940
|
if (r === null || !t || t.length === 0 || n.length === 0) return;
|
|
4937
|
-
let i =
|
|
4941
|
+
let i = li(t, Q(t, r)), a = r + (Number.isFinite(i) ? e.fedFraction * i : 0), o = Q(n, a), s = n[o].time;
|
|
4938
4942
|
if (s > a) return;
|
|
4939
|
-
let c =
|
|
4943
|
+
let c = li(n, o);
|
|
4940
4944
|
if (a === s && o > 0) {
|
|
4941
4945
|
e.fedTime = n[o - 1].time, e.fedFraction = 1;
|
|
4942
4946
|
return;
|
|
4943
4947
|
}
|
|
4944
4948
|
e.fedTime = s, e.fedFraction = Number.isFinite(c) && c > 0 ? Math.min(1, (a - s) / c) : 0;
|
|
4945
4949
|
}
|
|
4946
|
-
function
|
|
4950
|
+
function di(e, t) {
|
|
4947
4951
|
let n = X(e, t), r = e.length - 1;
|
|
4948
4952
|
return n > r && r >= 0 && e[r].time + Z(e) <= t ? r : Math.max(-1, n - 2);
|
|
4949
4953
|
}
|
|
4950
|
-
function
|
|
4954
|
+
function fi(e) {
|
|
4951
4955
|
let t = Infinity;
|
|
4952
4956
|
for (let n = Math.max(1, e.length - 10); n < e.length; n++) t = Math.min(t, e[n].time - e[n - 1].time);
|
|
4953
4957
|
return t;
|
|
4954
4958
|
}
|
|
4955
|
-
function
|
|
4956
|
-
if (!(
|
|
4957
|
-
let n = Math.max(0, e.length -
|
|
4959
|
+
function pi(e, t) {
|
|
4960
|
+
if (!(fi(e) < fi(t))) return !1;
|
|
4961
|
+
let n = Math.max(0, e.length - oi);
|
|
4958
4962
|
for (let r = n; r < e.length; r++) {
|
|
4959
|
-
let n = t[Q(t, e[r].time)], i = (n.high - n.low) *
|
|
4963
|
+
let n = t[Q(t, e[r].time)], i = (n.high - n.low) * si + 2 ** -52;
|
|
4960
4964
|
if (e[r].close > n.high + i || e[r].close < n.low - i) return !1;
|
|
4961
4965
|
}
|
|
4962
4966
|
return !0;
|
|
4963
4967
|
}
|
|
4964
|
-
var
|
|
4968
|
+
var mi = 500;
|
|
4965
4969
|
function Y(e, t) {
|
|
4966
4970
|
let n = 0, r = e.length;
|
|
4967
4971
|
for (; n < r;) {
|
|
@@ -4978,7 +4982,7 @@ function X(e, t) {
|
|
|
4978
4982
|
}
|
|
4979
4983
|
return n;
|
|
4980
4984
|
}
|
|
4981
|
-
function
|
|
4985
|
+
function hi(e) {
|
|
4982
4986
|
let t = 0, n = 0;
|
|
4983
4987
|
for (let r = 1; r < e.length; r++) e[r].low < e[t].low && (t = r), e[r].high > e[n].high && (n = r);
|
|
4984
4988
|
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];
|
|
@@ -4989,9 +4993,9 @@ function Z(e) {
|
|
|
4989
4993
|
for (let n = Math.max(1, e.length - 10); n < e.length; n++) t = Math.max(t, e[n].time - e[n - 1].time);
|
|
4990
4994
|
return t > 0 ? t : Infinity;
|
|
4991
4995
|
}
|
|
4992
|
-
function
|
|
4996
|
+
function gi(e, t) {
|
|
4993
4997
|
if (t.length === 0) return null;
|
|
4994
|
-
let n = t[t.length - 1].time + Z(t), r = e.filter((e) =>
|
|
4998
|
+
let n = t[t.length - 1].time + Z(t), r = e.filter((e) => zn(e) && e.time >= t[0].time && e.time < n).sort((e, t) => e.time - t.time), i = [];
|
|
4995
4999
|
for (let e of r) (i.length === 0 || i[i.length - 1].time !== e.time) && i.push(e);
|
|
4996
5000
|
if (i.length === 0) return null;
|
|
4997
5001
|
let a = t.findIndex((e) => e.time >= i[0].time);
|
|
@@ -5007,26 +5011,26 @@ function Q(e, t) {
|
|
|
5007
5011
|
}
|
|
5008
5012
|
return n;
|
|
5009
5013
|
}
|
|
5010
|
-
function
|
|
5014
|
+
function _i(e, t, n) {
|
|
5011
5015
|
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;
|
|
5012
5016
|
for (let t = 0; t < e.length && e[t].time < i; t++) a = t;
|
|
5013
5017
|
return Math.max(0, a);
|
|
5014
5018
|
}
|
|
5015
|
-
function
|
|
5019
|
+
function vi(e, t, n) {
|
|
5016
5020
|
let r = n;
|
|
5017
5021
|
for (; r > 0 && t[r - 1].time >= e.time;) r--;
|
|
5018
5022
|
let i = {
|
|
5019
5023
|
...t[r],
|
|
5020
5024
|
time: e.time
|
|
5021
5025
|
};
|
|
5022
|
-
for (let e = r + 1; e <= n; e++) i =
|
|
5026
|
+
for (let e = r + 1; e <= n; e++) i = Si(i, t[e]);
|
|
5023
5027
|
return i;
|
|
5024
5028
|
}
|
|
5025
|
-
function
|
|
5029
|
+
function yi(e, t, n, r) {
|
|
5026
5030
|
let i = e[n + 1], a = t[r + 1];
|
|
5027
5031
|
return i !== void 0 && a !== void 0 && i.time >= a.time;
|
|
5028
5032
|
}
|
|
5029
|
-
function
|
|
5033
|
+
function bi(e, t) {
|
|
5030
5034
|
let n = /* @__PURE__ */ new Map();
|
|
5031
5035
|
for (let r of e) {
|
|
5032
5036
|
let e = t[Q(t, r.time)].time, i = n.get(e);
|
|
@@ -5034,10 +5038,10 @@ function yi(e, t) {
|
|
|
5034
5038
|
}
|
|
5035
5039
|
return n;
|
|
5036
5040
|
}
|
|
5037
|
-
function
|
|
5041
|
+
function xi() {
|
|
5038
5042
|
return typeof matchMedia == "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
5039
5043
|
}
|
|
5040
|
-
function
|
|
5044
|
+
function Si(e, t) {
|
|
5041
5045
|
return {
|
|
5042
5046
|
time: e.time,
|
|
5043
5047
|
open: e.open,
|
|
@@ -5049,26 +5053,26 @@ function xi(e, t) {
|
|
|
5049
5053
|
}
|
|
5050
5054
|
//#endregion
|
|
5051
5055
|
//#region src/io/parseOHLCV.ts
|
|
5052
|
-
var
|
|
5056
|
+
var Ci = [
|
|
5053
5057
|
"time",
|
|
5054
5058
|
"timestamp",
|
|
5055
5059
|
"date",
|
|
5056
5060
|
"datetime",
|
|
5057
5061
|
"t"
|
|
5058
|
-
],
|
|
5062
|
+
], wi = ["open", "o"], Ti = ["high", "h"], Ei = ["low", "l"], Di = ["close", "c"], Oi = [
|
|
5059
5063
|
"volume",
|
|
5060
5064
|
"vol",
|
|
5061
5065
|
"v"
|
|
5062
5066
|
];
|
|
5063
|
-
function
|
|
5067
|
+
function ki(e) {
|
|
5064
5068
|
let t = e.trim();
|
|
5065
|
-
return t ? t[0] === "[" || t[0] === "{" ?
|
|
5069
|
+
return t ? t[0] === "[" || t[0] === "{" ? Ai(t) : ji(t) : {
|
|
5066
5070
|
data: [],
|
|
5067
5071
|
rowCount: 0,
|
|
5068
5072
|
skipped: 0
|
|
5069
5073
|
};
|
|
5070
5074
|
}
|
|
5071
|
-
function
|
|
5075
|
+
function Ai(e) {
|
|
5072
5076
|
let t;
|
|
5073
5077
|
try {
|
|
5074
5078
|
t = JSON.parse(e);
|
|
@@ -5078,19 +5082,19 @@ function ki(e) {
|
|
|
5078
5082
|
if (!Array.isArray(t)) throw Error("Expected a JSON array of OHLCV rows");
|
|
5079
5083
|
let n = [], r = 0;
|
|
5080
5084
|
for (let e of t) {
|
|
5081
|
-
let t = Array.isArray(e) ?
|
|
5085
|
+
let t = Array.isArray(e) ? Ii(e) : Fi(e);
|
|
5082
5086
|
t ? n.push(t) : r++;
|
|
5083
5087
|
}
|
|
5084
|
-
return
|
|
5088
|
+
return Ri(n, t.length, r);
|
|
5085
5089
|
}
|
|
5086
|
-
function
|
|
5090
|
+
function ji(e) {
|
|
5087
5091
|
let t = e.split(/\r?\n/).filter((e) => e.trim().length > 0);
|
|
5088
5092
|
if (t.length === 0) return {
|
|
5089
5093
|
data: [],
|
|
5090
5094
|
rowCount: 0,
|
|
5091
5095
|
skipped: 0
|
|
5092
5096
|
};
|
|
5093
|
-
let n =
|
|
5097
|
+
let n = Mi(t[0]), r = Ni(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? Pi(r) : {
|
|
5094
5098
|
time: 0,
|
|
5095
5099
|
open: 1,
|
|
5096
5100
|
high: 2,
|
|
@@ -5101,7 +5105,7 @@ function Ai(e) {
|
|
|
5101
5105
|
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");
|
|
5102
5106
|
let o = [], s = 0;
|
|
5103
5107
|
for (let e = +!!i; e < t.length; e++) {
|
|
5104
|
-
let r =
|
|
5108
|
+
let r = Ni(t[e], n), i = Li(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;
|
|
5105
5109
|
if (i === null || ![
|
|
5106
5110
|
c,
|
|
5107
5111
|
l,
|
|
@@ -5120,9 +5124,9 @@ function Ai(e) {
|
|
|
5120
5124
|
volume: Number.isFinite(f) ? f : 0
|
|
5121
5125
|
});
|
|
5122
5126
|
}
|
|
5123
|
-
return
|
|
5127
|
+
return Ri(o, t.length - +!!i, s);
|
|
5124
5128
|
}
|
|
5125
|
-
function
|
|
5129
|
+
function Mi(e) {
|
|
5126
5130
|
let t = {
|
|
5127
5131
|
",": 0,
|
|
5128
5132
|
";": 0,
|
|
@@ -5134,7 +5138,7 @@ function ji(e) {
|
|
|
5134
5138
|
for (let [e, i] of Object.entries(t)) i > r && (n = e, r = i);
|
|
5135
5139
|
return n;
|
|
5136
5140
|
}
|
|
5137
|
-
function
|
|
5141
|
+
function Ni(e, t) {
|
|
5138
5142
|
let n = [], r = "", i = !1;
|
|
5139
5143
|
for (let a = 0; a < e.length; a++) {
|
|
5140
5144
|
let o = e[a];
|
|
@@ -5142,25 +5146,25 @@ function Mi(e, t) {
|
|
|
5142
5146
|
}
|
|
5143
5147
|
return n.push(r), n;
|
|
5144
5148
|
}
|
|
5145
|
-
function
|
|
5149
|
+
function Pi(e) {
|
|
5146
5150
|
let t = (t) => e.findIndex((e) => t.includes(e));
|
|
5147
5151
|
return {
|
|
5148
|
-
time: t(
|
|
5149
|
-
open: t(
|
|
5150
|
-
high: t(
|
|
5151
|
-
low: t(
|
|
5152
|
-
close: t(
|
|
5153
|
-
volume: t(
|
|
5152
|
+
time: t(Ci),
|
|
5153
|
+
open: t(wi),
|
|
5154
|
+
high: t(Ti),
|
|
5155
|
+
low: t(Ei),
|
|
5156
|
+
close: t(Di),
|
|
5157
|
+
volume: t(Oi)
|
|
5154
5158
|
};
|
|
5155
5159
|
}
|
|
5156
|
-
function
|
|
5160
|
+
function Fi(e) {
|
|
5157
5161
|
let t = (t) => {
|
|
5158
5162
|
for (let n of t) {
|
|
5159
5163
|
if (e[n] !== void 0) return e[n];
|
|
5160
5164
|
let t = n.toUpperCase();
|
|
5161
5165
|
if (e[t] !== void 0) return e[t];
|
|
5162
5166
|
}
|
|
5163
|
-
}, n =
|
|
5167
|
+
}, n = Li(String(t(Ci) ?? "")), r = Number(t(wi)), i = Number(t(Ti)), a = Number(t(Ei)), o = Number(t(Di)), s = Number(t(Oi) ?? 0);
|
|
5164
5168
|
return n === null || ![
|
|
5165
5169
|
r,
|
|
5166
5170
|
i,
|
|
@@ -5175,9 +5179,9 @@ function Pi(e) {
|
|
|
5175
5179
|
volume: Number.isFinite(s) ? s : 0
|
|
5176
5180
|
};
|
|
5177
5181
|
}
|
|
5178
|
-
function
|
|
5182
|
+
function Ii(e) {
|
|
5179
5183
|
if (e.length < 5) return null;
|
|
5180
|
-
let t =
|
|
5184
|
+
let t = Li(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;
|
|
5181
5185
|
return t === null || ![
|
|
5182
5186
|
n,
|
|
5183
5187
|
r,
|
|
@@ -5195,7 +5199,7 @@ function Fi(e) {
|
|
|
5195
5199
|
function $(e) {
|
|
5196
5200
|
return e === void 0 || e.trim() === "" ? NaN : Number(e);
|
|
5197
5201
|
}
|
|
5198
|
-
function
|
|
5202
|
+
function Li(e) {
|
|
5199
5203
|
let t = e.trim();
|
|
5200
5204
|
if (!t) return null;
|
|
5201
5205
|
let n = Number(t);
|
|
@@ -5203,7 +5207,7 @@ function Ii(e) {
|
|
|
5203
5207
|
let r = Date.parse(t);
|
|
5204
5208
|
return Number.isFinite(r) ? r : null;
|
|
5205
5209
|
}
|
|
5206
|
-
function
|
|
5210
|
+
function Ri(e, t, n) {
|
|
5207
5211
|
e.sort((e, t) => e.time - t.time);
|
|
5208
5212
|
let r = [];
|
|
5209
5213
|
for (let t of e) r.length > 0 && r[r.length - 1].time === t.time ? r[r.length - 1] = t : r.push(t);
|
|
@@ -5215,7 +5219,7 @@ function Li(e, t, n) {
|
|
|
5215
5219
|
}
|
|
5216
5220
|
//#endregion
|
|
5217
5221
|
//#region src/io/DragDropImporter.ts
|
|
5218
|
-
var
|
|
5222
|
+
var zi = class {
|
|
5219
5223
|
host;
|
|
5220
5224
|
overlay = null;
|
|
5221
5225
|
callbacks;
|
|
@@ -5236,19 +5240,19 @@ var Ri = class {
|
|
|
5236
5240
|
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();
|
|
5237
5241
|
}
|
|
5238
5242
|
onDragEnter(e) {
|
|
5239
|
-
|
|
5243
|
+
Bi(e) && (e.preventDefault(), this.depth++, this.showOverlay());
|
|
5240
5244
|
}
|
|
5241
5245
|
onDragOver(e) {
|
|
5242
|
-
|
|
5246
|
+
Bi(e) && (e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = "copy"));
|
|
5243
5247
|
}
|
|
5244
5248
|
onDragLeave(e) {
|
|
5245
|
-
|
|
5249
|
+
Bi(e) && (this.depth = Math.max(0, this.depth - 1), this.depth === 0 && this.hideOverlay());
|
|
5246
5250
|
}
|
|
5247
5251
|
async onDrop(e) {
|
|
5248
5252
|
e.preventDefault(), this.depth = 0, this.hideOverlay();
|
|
5249
5253
|
let t = e.dataTransfer?.files?.[0];
|
|
5250
5254
|
if (t) try {
|
|
5251
|
-
let e =
|
|
5255
|
+
let e = ki(await t.text());
|
|
5252
5256
|
if (e.data.length === 0) throw Error(`No valid OHLCV rows found in "${t.name}"`);
|
|
5253
5257
|
this.callbacks.onData(e.data, e, t);
|
|
5254
5258
|
} catch (e) {
|
|
@@ -5279,12 +5283,12 @@ var Ri = class {
|
|
|
5279
5283
|
this.overlay?.remove(), this.overlay = null;
|
|
5280
5284
|
}
|
|
5281
5285
|
};
|
|
5282
|
-
function
|
|
5286
|
+
function Bi(e) {
|
|
5283
5287
|
return e.dataTransfer?.types?.includes("Files") ?? !1;
|
|
5284
5288
|
}
|
|
5285
5289
|
//#endregion
|
|
5286
5290
|
//#region src/state/layoutStorage.ts
|
|
5287
|
-
function
|
|
5291
|
+
function Vi(e) {
|
|
5288
5292
|
let t = {
|
|
5289
5293
|
id: e.id,
|
|
5290
5294
|
name: e.name,
|
|
@@ -5292,11 +5296,11 @@ function Bi(e) {
|
|
|
5292
5296
|
};
|
|
5293
5297
|
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;
|
|
5294
5298
|
}
|
|
5295
|
-
var
|
|
5296
|
-
function
|
|
5299
|
+
var Hi = (e, t) => t.updatedAt - e.updatedAt;
|
|
5300
|
+
function Ui(e) {
|
|
5297
5301
|
if (typeof e != "object" || !e) return null;
|
|
5298
5302
|
let t = e;
|
|
5299
|
-
return typeof t.id != "string" || !t.id || typeof t.name != "string" || typeof t.updatedAt != "number" || !Number.isFinite(t.updatedAt) ? null :
|
|
5303
|
+
return typeof t.id != "string" || !t.id || typeof t.name != "string" || typeof t.updatedAt != "number" || !Number.isFinite(t.updatedAt) ? null : Vi({
|
|
5300
5304
|
id: t.id,
|
|
5301
5305
|
name: t.name,
|
|
5302
5306
|
updatedAt: t.updatedAt,
|
|
@@ -5305,17 +5309,17 @@ function Hi(e) {
|
|
|
5305
5309
|
kind: typeof t.kind == "string" ? t.kind : void 0
|
|
5306
5310
|
});
|
|
5307
5311
|
}
|
|
5308
|
-
function
|
|
5309
|
-
let t =
|
|
5312
|
+
function Wi(e) {
|
|
5313
|
+
let t = Ui(e), n = t ? e.content : void 0;
|
|
5310
5314
|
return t && typeof n == "string" ? {
|
|
5311
5315
|
...t,
|
|
5312
5316
|
content: n
|
|
5313
5317
|
} : null;
|
|
5314
5318
|
}
|
|
5315
|
-
function
|
|
5319
|
+
function Gi(e = []) {
|
|
5316
5320
|
let t = new Map(e.map((e) => [e.id, { ...e }]));
|
|
5317
5321
|
return {
|
|
5318
|
-
list: () => [...t.values()].map(
|
|
5322
|
+
list: () => [...t.values()].map(Vi).sort(Hi),
|
|
5319
5323
|
load: (e) => {
|
|
5320
5324
|
let n = t.get(e);
|
|
5321
5325
|
return n ? { ...n } : null;
|
|
@@ -5328,7 +5332,7 @@ function Wi(e = []) {
|
|
|
5328
5332
|
}
|
|
5329
5333
|
};
|
|
5330
5334
|
}
|
|
5331
|
-
function
|
|
5335
|
+
function Ki(e = "tcw:layouts:") {
|
|
5332
5336
|
let t = `${e}index`, n = (t) => `${e}item:${t}`, r = () => {
|
|
5333
5337
|
let e;
|
|
5334
5338
|
try {
|
|
@@ -5336,10 +5340,10 @@ function Gi(e = "tcw:layouts:") {
|
|
|
5336
5340
|
} catch {
|
|
5337
5341
|
return [];
|
|
5338
5342
|
}
|
|
5339
|
-
return Array.isArray(e) ? e.map(
|
|
5343
|
+
return Array.isArray(e) ? e.map(Ui).filter((e) => e !== null) : [];
|
|
5340
5344
|
}, i = (e) => localStorage.setItem(t, JSON.stringify(e));
|
|
5341
5345
|
return {
|
|
5342
|
-
list: () => r().sort(
|
|
5346
|
+
list: () => r().sort(Hi),
|
|
5343
5347
|
load: (e) => {
|
|
5344
5348
|
let t = r().find((t) => t.id === e), i = t ? localStorage.getItem(n(e)) : null;
|
|
5345
5349
|
return t && i !== null ? {
|
|
@@ -5348,7 +5352,7 @@ function Gi(e = "tcw:layouts:") {
|
|
|
5348
5352
|
} : null;
|
|
5349
5353
|
},
|
|
5350
5354
|
save: (e) => {
|
|
5351
|
-
localStorage.setItem(n(e.id), e.content), i([...r().filter((t) => t.id !== e.id),
|
|
5355
|
+
localStorage.setItem(n(e.id), e.content), i([...r().filter((t) => t.id !== e.id), Vi(e)]);
|
|
5352
5356
|
},
|
|
5353
5357
|
remove: (e) => {
|
|
5354
5358
|
i(r().filter((t) => t.id !== e)), localStorage.removeItem(n(e));
|
|
@@ -5357,14 +5361,14 @@ function Gi(e = "tcw:layouts:") {
|
|
|
5357
5361
|
}
|
|
5358
5362
|
//#endregion
|
|
5359
5363
|
//#region src/state/LayoutSession.ts
|
|
5360
|
-
var
|
|
5361
|
-
function
|
|
5364
|
+
var qi = 80;
|
|
5365
|
+
function Ji(e) {
|
|
5362
5366
|
return e.replace(/\s+/g, " ").trim().slice(0, 80).trim() || null;
|
|
5363
5367
|
}
|
|
5364
|
-
function
|
|
5368
|
+
function Yi() {
|
|
5365
5369
|
return globalThis.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
5366
5370
|
}
|
|
5367
|
-
function
|
|
5371
|
+
function Xi(e) {
|
|
5368
5372
|
let { id: t, name: n, symbol: r, timeframe: i, updatedAt: a, kind: o } = e;
|
|
5369
5373
|
return {
|
|
5370
5374
|
id: t,
|
|
@@ -5375,7 +5379,7 @@ function Yi(e) {
|
|
|
5375
5379
|
...o === void 0 ? {} : { kind: o }
|
|
5376
5380
|
};
|
|
5377
5381
|
}
|
|
5378
|
-
var
|
|
5382
|
+
var Zi = class {
|
|
5379
5383
|
currentLayout = null;
|
|
5380
5384
|
savedContent = null;
|
|
5381
5385
|
dirty = !1;
|
|
@@ -5391,7 +5395,7 @@ var Xi = class {
|
|
|
5391
5395
|
now;
|
|
5392
5396
|
newId;
|
|
5393
5397
|
constructor(e, t, n = {}) {
|
|
5394
|
-
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 ??
|
|
5398
|
+
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 ?? Yi;
|
|
5395
5399
|
}
|
|
5396
5400
|
current() {
|
|
5397
5401
|
return this.currentLayout;
|
|
@@ -5407,7 +5411,7 @@ var Xi = class {
|
|
|
5407
5411
|
}
|
|
5408
5412
|
async list() {
|
|
5409
5413
|
let e = await this.storage.list();
|
|
5410
|
-
return Array.isArray(e) ? e.map(
|
|
5414
|
+
return Array.isArray(e) ? e.map(Ui).filter((e) => e !== null && (e.kind ?? "chart") === this.kind).sort((e, t) => t.updatedAt - e.updatedAt) : [];
|
|
5411
5415
|
}
|
|
5412
5416
|
save() {
|
|
5413
5417
|
return this.queue(() => {
|
|
@@ -5416,12 +5420,12 @@ var Xi = class {
|
|
|
5416
5420
|
});
|
|
5417
5421
|
}
|
|
5418
5422
|
saveAs(e) {
|
|
5419
|
-
let t =
|
|
5423
|
+
let t = Ji(e);
|
|
5420
5424
|
return t ? this.queue(() => this.write(this.newId(), t)) : Promise.reject(/* @__PURE__ */ Error("A layout needs a name"));
|
|
5421
5425
|
}
|
|
5422
5426
|
open(e) {
|
|
5423
5427
|
return this.queue(async () => {
|
|
5424
|
-
let t =
|
|
5428
|
+
let t = Wi(await this.storage.load(e));
|
|
5425
5429
|
if (!t || t.id !== e || (t.kind ?? "chart") !== this.kind || this.destroyed) return !1;
|
|
5426
5430
|
this.cancelTimer(), this.applying++;
|
|
5427
5431
|
try {
|
|
@@ -5431,13 +5435,13 @@ var Xi = class {
|
|
|
5431
5435
|
} finally {
|
|
5432
5436
|
this.applying--;
|
|
5433
5437
|
}
|
|
5434
|
-
return this.cancelTimer(), this.currentLayout =
|
|
5438
|
+
return this.cancelTimer(), this.currentLayout = Xi(t), this.savedContent = this.host.capture().content, this.dirty = !1, this.notify(), !0;
|
|
5435
5439
|
});
|
|
5436
5440
|
}
|
|
5437
5441
|
rename(e, t) {
|
|
5438
|
-
let n =
|
|
5442
|
+
let n = Ji(t);
|
|
5439
5443
|
return n ? this.queue(async () => {
|
|
5440
|
-
let t =
|
|
5444
|
+
let t = Wi(await this.storage.load(e));
|
|
5441
5445
|
!t || t.id !== e || (await this.storage.save({
|
|
5442
5446
|
...t,
|
|
5443
5447
|
name: n
|
|
@@ -5515,7 +5519,7 @@ var Xi = class {
|
|
|
5515
5519
|
content: n.content
|
|
5516
5520
|
};
|
|
5517
5521
|
await this.storage.save(r);
|
|
5518
|
-
let i =
|
|
5522
|
+
let i = Xi(r);
|
|
5519
5523
|
return this.currentLayout = i, this.savedContent = n.content, this.dirty = !1, this.notify(), i;
|
|
5520
5524
|
}
|
|
5521
5525
|
forget() {
|
|
@@ -5536,6 +5540,6 @@ var Xi = class {
|
|
|
5536
5540
|
}
|
|
5537
5541
|
};
|
|
5538
5542
|
//#endregion
|
|
5539
|
-
export {
|
|
5543
|
+
export { Wn as C, B as D, R as E, dn as O, qn as S, V as T, dr as _, Gi as a, G as b, Jr as c, Pr as d, Fr as f, ur as g, fr as h, Ki as i, Rr as l, pr as m, qi as n, zi as o, mr as p, Ji as r, ki as s, Zi as t, Lr as u, cr as v, Hn as w, Qn as x, lr as y };
|
|
5540
5544
|
|
|
5541
|
-
//# sourceMappingURL=LayoutSession-
|
|
5545
|
+
//# sourceMappingURL=LayoutSession-BUp55Atp.js.map
|