@tradecanvas/chart 1.52.0 → 1.53.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Chart.d.ts +104 -7
- package/dist/Chart.d.ts.map +1 -1
- package/dist/HistoryPager.d.ts +12 -2
- package/dist/HistoryPager.d.ts.map +1 -1
- package/dist/{LayoutSession-4SLt8-0u.js → LayoutSession-D7uQq3jX.js} +805 -315
- package/dist/LayoutSession-D7uQq3jX.js.map +1 -0
- package/dist/LayoutSession-nlhT-EH7.cjs +2 -0
- package/dist/LayoutSession-nlhT-EH7.cjs.map +1 -0
- package/dist/SeriesStore.d.ts +27 -4
- package/dist/SeriesStore.d.ts.map +1 -1
- package/dist/{i18n-C7b-2BJ5.js → i18n-CwCzRLKW.js} +21 -1
- package/dist/i18n-CwCzRLKW.js.map +1 -0
- package/dist/i18n-D7B7uFrN.cjs +2 -0
- package/dist/i18n-D7B7uFrN.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +29 -29
- package/dist/replay/ReplayStepLoader.d.ts +52 -0
- package/dist/replay/ReplayStepLoader.d.ts.map +1 -0
- package/dist/replay/intrabarPath.d.ts +44 -0
- package/dist/replay/intrabarPath.d.ts.map +1 -0
- package/dist/replay/replayStep.d.ts +18 -0
- package/dist/replay/replayStep.d.ts.map +1 -0
- package/dist/widget/ChartWidget.d.ts +91 -4
- package/dist/widget/ChartWidget.d.ts.map +1 -1
- package/dist/widget/ChartWidgetGrid.d.ts.map +1 -1
- package/dist/widget/WidgetHotkeySheet.d.ts.map +1 -1
- package/dist/widget/WidgetReplayBar.d.ts +101 -23
- package/dist/widget/WidgetReplayBar.d.ts.map +1 -1
- package/dist/widget/index.cjs +298 -157
- package/dist/widget/index.cjs.map +1 -1
- package/dist/widget/index.js +1734 -1422
- package/dist/widget/index.js.map +1 -1
- package/dist/widget/locales/ar.d.ts.map +1 -1
- package/dist/widget/locales/cs.d.ts.map +1 -1
- package/dist/widget/locales/da.d.ts.map +1 -1
- package/dist/widget/locales/de.d.ts.map +1 -1
- package/dist/widget/locales/el.d.ts.map +1 -1
- package/dist/widget/locales/en.d.ts +11 -0
- package/dist/widget/locales/en.d.ts.map +1 -1
- package/dist/widget/locales/es.d.ts.map +1 -1
- package/dist/widget/locales/et.d.ts.map +1 -1
- package/dist/widget/locales/fa.d.ts.map +1 -1
- package/dist/widget/locales/fr.d.ts.map +1 -1
- package/dist/widget/locales/he.d.ts.map +1 -1
- package/dist/widget/locales/hu.d.ts.map +1 -1
- package/dist/widget/locales/id.d.ts.map +1 -1
- package/dist/widget/locales/index.cjs +1 -1
- package/dist/widget/locales/index.cjs.map +1 -1
- package/dist/widget/locales/index.js +281 -1
- package/dist/widget/locales/index.js.map +1 -1
- package/dist/widget/locales/it.d.ts.map +1 -1
- package/dist/widget/locales/ja.d.ts.map +1 -1
- package/dist/widget/locales/ko.d.ts.map +1 -1
- package/dist/widget/locales/ms.d.ts.map +1 -1
- package/dist/widget/locales/nb.d.ts.map +1 -1
- package/dist/widget/locales/nl.d.ts.map +1 -1
- package/dist/widget/locales/pl.d.ts.map +1 -1
- package/dist/widget/locales/pt.d.ts.map +1 -1
- package/dist/widget/locales/ro.d.ts.map +1 -1
- package/dist/widget/locales/ru.d.ts.map +1 -1
- package/dist/widget/locales/sk.d.ts.map +1 -1
- package/dist/widget/locales/sv.d.ts.map +1 -1
- package/dist/widget/locales/th.d.ts.map +1 -1
- package/dist/widget/locales/tr.d.ts.map +1 -1
- package/dist/widget/locales/vi.d.ts.map +1 -1
- package/dist/widget/locales/zh.d.ts.map +1 -1
- package/dist/widget/locales/zhHant.d.ts.map +1 -1
- package/dist/widget/types.d.ts +15 -0
- package/dist/widget/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/LayoutSession-4SLt8-0u.js.map +0 -1
- package/dist/LayoutSession-BOtFzvMm.cjs +0 -2
- package/dist/LayoutSession-BOtFzvMm.cjs.map +0 -1
- package/dist/i18n-BjW5GVrO.cjs +0 -2
- package/dist/i18n-BjW5GVrO.cjs.map +0 -1
- package/dist/i18n-C7b-2BJ5.js.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { DARK_THEME as e, DEFAULT_PANEL_HEIGHT as t, LIGHT_THEME as n, LayerType as r, MIN_PANEL_HEIGHT as i, PHI as a, PRICE_AXIS_WIDTH as o, TIME_AXIS_HEIGHT as s, autoPricePrecision as c, barDateZone as l, barTimeUnit as u, barsAreDaily as d, chartStyleValue as f, computePriceLimits as p, computePriceRange as m, formatPrice as h, fractionTick as g, indicatorSource as _, isValidTimeZone as v, mergeBar as ee, niceNumber as te, normalizeBarTime as y, parseIndicatorSource as b, priceFormatterFor as ne, priceStepAt as re, readChartStyleOverrides as
|
|
2
|
-
import { AlertDragHandler as fe, AlertManager as pe, Animator as me, AreaRenderer as he, AxisDragHandler as ge, BarCountdown as _e, BarRenderer as ve, BaselineRenderer as ye, CandlestickRenderer as be, ChartLegend as xe, ChartStateManager as T, CompareRenderer as Se, CompareSymbolIndicator as Ce, CorrelationCoefficientIndicator as we, CorrelationLogIndicator as Te, CrosshairHandler as Ee, CrosshairTooltip as De, CurrentPriceLine as Oe, DEFAULT_SESSION_HOURS as ke, DataExporter as E, DepthHeatmapRenderer as Ae, DrawingManager as je, DrawingRenderer as Me, EquivolumeRenderer as Ne, EventBus as Pe, GridRenderer as Fe, HLCAreaRenderer as Ie, HiLoRenderer as
|
|
1
|
+
import { DARK_THEME as e, DEFAULT_PANEL_HEIGHT as t, LIGHT_THEME as n, LayerType as r, MIN_PANEL_HEIGHT as i, PHI as a, PRICE_AXIS_WIDTH as o, TIME_AXIS_HEIGHT as s, autoPricePrecision as c, barDateZone as l, barTimeUnit as u, barsAreDaily as d, chartStyleValue as f, computePriceLimits as p, computePriceRange as m, formatPrice as h, fractionTick as g, indicatorSource as _, isValidTimeZone as v, mergeBar as ee, niceNumber as te, normalizeBarTime as y, parseIndicatorSource as b, priceFormatterFor as ne, priceStepAt as re, readChartStyleOverrides as ie, readChartTypeOptions as x, readIndicatorPlotStyles as ae, readPaneStyle as oe, resolveChartTheme as se, sessionMinute as S, setLocale as ce, stepDecimals as le, symbolTimeZone as C, tickBarCount as ue, timeframeToMs as w, zonedDateFormatter as de } from "@tradecanvas/commons";
|
|
2
|
+
import { AlertDragHandler as fe, AlertManager as pe, Animator as me, AreaRenderer as he, AxisDragHandler as ge, BarCountdown as _e, BarRenderer as ve, BaselineRenderer as ye, CandlestickRenderer as be, ChartLegend as xe, ChartStateManager as T, CompareRenderer as Se, CompareSymbolIndicator as Ce, CorrelationCoefficientIndicator as we, CorrelationLogIndicator as Te, CrosshairHandler as Ee, CrosshairTooltip as De, CurrentPriceLine as Oe, DEFAULT_SESSION_HOURS as ke, DataExporter as E, DepthHeatmapRenderer as Ae, DrawingManager as je, DrawingRenderer as Me, EquivolumeRenderer as Ne, EventBus as Pe, GridRenderer as Fe, HLCAreaRenderer as Ie, HiLoRenderer as Le, HollowCandleRenderer as Re, IndicatorEngine as ze, InteractionManager as Be, KagiRenderer as Ve, KeyboardHandler as He, LineRenderer as Ue, LineWithMarkersRenderer as We, MarketProfileRenderer as Ge, MeasureOverlay as Ke, PRICE_SCALE_MARGIN as D, PanHandler as qe, PaneResizeHandler as Je, PeriodLevelsRenderer as Ye, PinnedTooltip as Xe, PivotMarkersRenderer as Ze, PointAndFigureRenderer as Qe, PriceAxis as $e, PriceAxisAddButton as et, PriceLines as tt, RenderEngine as nt, RenkoRenderer as rt, ReplayManager as it, ResamplingAdapter as at, ReshapeMemo as ot, SYMBOL_INDICATOR_IDS as O, SYMBOL_ZONE_WAIT_MS as st, Screenshot as k, SelectionBoxOverlay as ct, SessionBreaks as lt, SessionShading as ut, SignalMarkerManager as dt, SpreadIndicator as ft, StepLineRenderer as pt, StreamManager as mt, SymbolSeriesStore as ht, TimeAxis as gt, TradeZoneManager as _t, TradingManager as vt, TradingRenderer as yt, UndoRedoManager as bt, Viewport as xt, VolumeCandleRenderer as St, VolumeProfileRenderer as Ct, VolumeRenderer as wt, Watermark as Tt, ZoomHandler as Et, barTimeStepMs as Dt, findDominantSwing as Ot, gpuContextsLeft as kt, isPriceLevelAlert as At, isRegularSession as jt, loadWebGL as Mt, mergeSessionHours as Nt, pointAndFigureColumns as Pt, priceToY as Ft, rangePresetStart as It, readAlertOptions as Lt, registerBuiltInDrawingTools as Rt, registerBuiltInIndicators as zt, servesTimeframe as A, sourceParam as j, timeToX as Bt, timestampToBarIndex as M, toHeikinAshi as Vt, toKagi as Ht, toLineBreak as Ut, toRangeBars as Wt, toRenko as Gt, whenGpuContextFree as Kt, withResampling as N, xToBarIndex as qt, xToTime as P, yToPrice as Jt } from "@tradecanvas/core";
|
|
3
3
|
//#region src/regularHours.ts
|
|
4
4
|
var Yt = 864e5, Xt = 10;
|
|
5
5
|
function Zt(e, t) {
|
|
6
|
-
let n =
|
|
6
|
+
let n = C(e);
|
|
7
7
|
if (!n || !v(n) || t.length < 2) return null;
|
|
8
8
|
let r = (e?.sessions ?? []).flatMap((e) => {
|
|
9
|
-
let t =
|
|
9
|
+
let t = S(e.start), n = S(e.end);
|
|
10
10
|
return t === null || n === null ? [] : [{
|
|
11
11
|
startMinute: t,
|
|
12
12
|
endMinute: n
|
|
@@ -25,7 +25,7 @@ function Zt(e, t) {
|
|
|
25
25
|
startMinute: r[0].startMinute,
|
|
26
26
|
endMinute: r[r.length - 1].endMinute
|
|
27
27
|
};
|
|
28
|
-
return (e) =>
|
|
28
|
+
return (e) => jt(e * i, o);
|
|
29
29
|
}
|
|
30
30
|
//#endregion
|
|
31
31
|
//#region src/chartA11y.ts
|
|
@@ -175,20 +175,20 @@ function sn(e) {
|
|
|
175
175
|
case "heikinAshi":
|
|
176
176
|
case "lineBreak":
|
|
177
177
|
case "rangeBars": return new be();
|
|
178
|
-
case "line": return new
|
|
178
|
+
case "line": return new Ue();
|
|
179
179
|
case "area": return new he();
|
|
180
180
|
case "bar": return new ve();
|
|
181
|
-
case "hollowCandle": return new
|
|
181
|
+
case "hollowCandle": return new Re();
|
|
182
182
|
case "baseline": return new ye();
|
|
183
|
-
case "renko": return new
|
|
184
|
-
case "kagi": return new
|
|
185
|
-
case "pointAndFigure": return new
|
|
186
|
-
case "volumeCandles": return new
|
|
183
|
+
case "renko": return new rt();
|
|
184
|
+
case "kagi": return new Ve();
|
|
185
|
+
case "pointAndFigure": return new Qe();
|
|
186
|
+
case "volumeCandles": return new St();
|
|
187
187
|
case "equivolume": return new Ne();
|
|
188
188
|
case "hlcArea": return new Ie();
|
|
189
|
-
case "stepLine": return new
|
|
190
|
-
case "lineWithMarkers": return new
|
|
191
|
-
case "hiLo": return new
|
|
189
|
+
case "stepLine": return new pt();
|
|
190
|
+
case "lineWithMarkers": return new We();
|
|
191
|
+
case "hiLo": return new Le();
|
|
192
192
|
default: return new be();
|
|
193
193
|
}
|
|
194
194
|
}
|
|
@@ -230,7 +230,7 @@ function I(e) {
|
|
|
230
230
|
}
|
|
231
231
|
function un(e, t = {}, n) {
|
|
232
232
|
let r = t.pointAndFigure?.boxSize;
|
|
233
|
-
return
|
|
233
|
+
return Pt(e, typeof r == "number" ? r : dn(e) * .01, t.pointAndFigure?.reversal ?? 3, n);
|
|
234
234
|
}
|
|
235
235
|
function dn(e) {
|
|
236
236
|
let t = 0;
|
|
@@ -443,8 +443,8 @@ var Mn = class {
|
|
|
443
443
|
whole = null;
|
|
444
444
|
aside = null;
|
|
445
445
|
shownRevision = 0;
|
|
446
|
-
constructor(e) {
|
|
447
|
-
this.hoursFilter = e;
|
|
446
|
+
constructor(e, t = () => {}) {
|
|
447
|
+
this.hoursFilter = e, this.onLiveChange = t;
|
|
448
448
|
}
|
|
449
449
|
bars() {
|
|
450
450
|
return this.shown.getData();
|
|
@@ -459,9 +459,23 @@ var Mn = class {
|
|
|
459
459
|
return this.aside?.getData() ?? this.whole ?? this.shown.getData();
|
|
460
460
|
}
|
|
461
461
|
load(e) {
|
|
462
|
+
if (this.aside) {
|
|
463
|
+
this.aside.setData(e), this.onLiveChange({ kind: "series" });
|
|
464
|
+
return;
|
|
465
|
+
}
|
|
462
466
|
this.shown.setData(this.regularOnly(e));
|
|
463
467
|
}
|
|
464
468
|
prepend(e) {
|
|
469
|
+
if (this.aside) {
|
|
470
|
+
let t = this.aside.prependBars(e);
|
|
471
|
+
return t > 0 && this.onLiveChange({
|
|
472
|
+
kind: "older",
|
|
473
|
+
taken: t
|
|
474
|
+
}), {
|
|
475
|
+
added: 0,
|
|
476
|
+
taken: t
|
|
477
|
+
};
|
|
478
|
+
}
|
|
465
479
|
let t = null, n = e;
|
|
466
480
|
if (this.whole) {
|
|
467
481
|
let r = this.whole[0]?.time, i = /* @__PURE__ */ new Set(), a = e.filter(jn).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);
|
|
@@ -476,12 +490,12 @@ var Mn = class {
|
|
|
476
490
|
};
|
|
477
491
|
}
|
|
478
492
|
mergeSnapshot(e) {
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
return
|
|
493
|
+
if (this.aside) return this.aside.setData(Nn(this.aside.getData(), e) ?? e), this.onLiveChange({ kind: "series" }), !0;
|
|
494
|
+
let t = Nn(this.whole ?? this.shown.getData(), e);
|
|
495
|
+
return t ? (this.shown.setData(this.regularOnly(t)), !0) : !1;
|
|
482
496
|
}
|
|
483
497
|
refilter() {
|
|
484
|
-
if (this.aside) return !1;
|
|
498
|
+
if (this.aside) return this.onLiveChange({ kind: "hours" }), !1;
|
|
485
499
|
let e = this.whole ?? this.shown.getData().slice();
|
|
486
500
|
return !this.whole && !this.hoursFilter(e) ? !1 : (this.shown.setData(this.regularOnly(e)), !0);
|
|
487
501
|
}
|
|
@@ -567,11 +581,14 @@ var Mn = class {
|
|
|
567
581
|
replace(e) {
|
|
568
582
|
if (this.aside) {
|
|
569
583
|
let { index: t, changed: n } = this.aside.replaceBar(e);
|
|
570
|
-
return t < 0 ? V : {
|
|
584
|
+
return t < 0 ? V : (n && this.onLiveChange({
|
|
585
|
+
kind: "bar",
|
|
586
|
+
time: this.aside.getData()[t].time
|
|
587
|
+
}), {
|
|
571
588
|
to: "aside",
|
|
572
589
|
index: -1,
|
|
573
590
|
changed: n
|
|
574
|
-
};
|
|
591
|
+
});
|
|
575
592
|
}
|
|
576
593
|
if (!L(e)) return V;
|
|
577
594
|
let t = this.inSeriesUnit(e), n = this.whole, r = n ? Dn(n, t.time) : -1;
|
|
@@ -587,9 +604,6 @@ var Mn = class {
|
|
|
587
604
|
changed: a
|
|
588
605
|
});
|
|
589
606
|
}
|
|
590
|
-
loadAside(e) {
|
|
591
|
-
this.aside?.setData(e);
|
|
592
|
-
}
|
|
593
607
|
beginReplay() {
|
|
594
608
|
this.aside || (this.aside = new B(), this.aside.setData(this.whole ?? this.shown.getData()));
|
|
595
609
|
}
|
|
@@ -647,7 +661,15 @@ var Mn = class {
|
|
|
647
661
|
let r = this.hoursFilter(n);
|
|
648
662
|
return !r || r(e.time);
|
|
649
663
|
}
|
|
650
|
-
}
|
|
664
|
+
};
|
|
665
|
+
function Nn(e, t) {
|
|
666
|
+
let n = t[0]?.time, r = 0;
|
|
667
|
+
for (; n !== void 0 && r < e.length && e[r].time < n;) r++;
|
|
668
|
+
return r === 0 || r === e.length ? null : e.slice(0, r).concat(t);
|
|
669
|
+
}
|
|
670
|
+
//#endregion
|
|
671
|
+
//#region src/HistoryPager.ts
|
|
672
|
+
var Pn = 5e3, Fn = 6e4, In = 500, Ln = class {
|
|
651
673
|
loader = null;
|
|
652
674
|
pageSize = 500;
|
|
653
675
|
loading = !1;
|
|
@@ -655,6 +677,7 @@ var Mn = class {
|
|
|
655
677
|
failures = 0;
|
|
656
678
|
retryAt = 0;
|
|
657
679
|
seq = 0;
|
|
680
|
+
inFlight = null;
|
|
658
681
|
constructor(e) {
|
|
659
682
|
this.host = e;
|
|
660
683
|
}
|
|
@@ -665,7 +688,12 @@ var Mn = class {
|
|
|
665
688
|
return this.loader !== null;
|
|
666
689
|
}
|
|
667
690
|
reset() {
|
|
668
|
-
this.seq
|
|
691
|
+
this.seq++;
|
|
692
|
+
let e = this.loading;
|
|
693
|
+
this.loading = !1, this.exhausted = !1, this.failures = 0, this.retryAt = 0, e && this.emit({
|
|
694
|
+
state: "loaded",
|
|
695
|
+
count: 0
|
|
696
|
+
});
|
|
669
697
|
}
|
|
670
698
|
isLoading() {
|
|
671
699
|
return this.loading;
|
|
@@ -676,7 +704,12 @@ var Mn = class {
|
|
|
676
704
|
maybeLoad(e, t) {
|
|
677
705
|
e >= t || !this.canLoad() || this.failures >= 5 || this.now() < this.retryAt || this.loadMore();
|
|
678
706
|
}
|
|
679
|
-
|
|
707
|
+
loadMore() {
|
|
708
|
+
if (this.loading && this.inFlight) return this.inFlight;
|
|
709
|
+
let e = this.loadPage();
|
|
710
|
+
return this.inFlight = e, e;
|
|
711
|
+
}
|
|
712
|
+
async loadPage() {
|
|
680
713
|
let e = this.loader, t = this.host.oldestTime();
|
|
681
714
|
if (!e || !this.canLoad() || t === null) return 0;
|
|
682
715
|
let n = this.seq;
|
|
@@ -688,7 +721,7 @@ var Mn = class {
|
|
|
688
721
|
try {
|
|
689
722
|
r = await e(t, this.pageSize);
|
|
690
723
|
} catch (e) {
|
|
691
|
-
return n === this.seq ? (this.loading = !1, this.failures++, this.retryAt = this.now() + Math.min(
|
|
724
|
+
return n === this.seq ? (this.loading = !1, this.failures++, this.retryAt = this.now() + Math.min(Fn, Pn * 2 ** (this.failures - 1)), this.emit({
|
|
692
725
|
state: "error",
|
|
693
726
|
count: 0,
|
|
694
727
|
error: e instanceof Error ? e.message : String(e)
|
|
@@ -721,10 +754,10 @@ var Mn = class {
|
|
|
721
754
|
};
|
|
722
755
|
//#endregion
|
|
723
756
|
//#region src/ThemeManager.ts
|
|
724
|
-
function
|
|
757
|
+
function Rn(e, t) {
|
|
725
758
|
return e.family === t.family && e.sizeSmall === t.sizeSmall && e.sizeMedium === t.sizeMedium && e.sizeLarge === t.sizeLarge;
|
|
726
759
|
}
|
|
727
|
-
var
|
|
760
|
+
var zn = class t {
|
|
728
761
|
base;
|
|
729
762
|
shape = null;
|
|
730
763
|
font = null;
|
|
@@ -743,13 +776,13 @@ var Rn = class t {
|
|
|
743
776
|
return i;
|
|
744
777
|
}
|
|
745
778
|
getTheme() {
|
|
746
|
-
return this.effective ??=
|
|
779
|
+
return this.effective ??= se(this.base, this.chartType, this.merged()), this.effective;
|
|
747
780
|
}
|
|
748
781
|
getBaseTheme() {
|
|
749
782
|
return this.base;
|
|
750
783
|
}
|
|
751
784
|
setTheme(e) {
|
|
752
|
-
let n = t.read(e), r = this.font !== null &&
|
|
785
|
+
let n = t.read(e), r = this.font !== null && Rn(n.font, this.base.font);
|
|
753
786
|
this.base = n, r || (this.themeFont = n.font), this.shape && (this.base = {
|
|
754
787
|
...this.base,
|
|
755
788
|
shape: {
|
|
@@ -831,7 +864,7 @@ var Rn = class t {
|
|
|
831
864
|
};
|
|
832
865
|
//#endregion
|
|
833
866
|
//#region src/style/styleOptions.ts
|
|
834
|
-
function
|
|
867
|
+
function Bn(e, t) {
|
|
835
868
|
return t ? {
|
|
836
869
|
...t.visible === void 0 ? {} : { [`crosshair.${e}.visible`]: t.visible },
|
|
837
870
|
...t.color === void 0 ? {} : { [`crosshair.${e}.color`]: t.color },
|
|
@@ -839,22 +872,22 @@ function zn(e, t) {
|
|
|
839
872
|
...t.width === void 0 ? {} : { [`crosshair.${e}.width`]: t.width }
|
|
840
873
|
} : {};
|
|
841
874
|
}
|
|
842
|
-
function
|
|
875
|
+
function Vn(e) {
|
|
843
876
|
let { grid: t, crosshair: n } = e, r = n?.vLine?.labelBackground ?? n?.hLine?.labelBackground;
|
|
844
877
|
return {
|
|
845
878
|
...t?.hLineColor === void 0 ? {} : { "grid.horizontal.color": t.hLineColor },
|
|
846
879
|
...t?.hLineStyle === void 0 ? {} : { "grid.horizontal.style": t.hLineStyle },
|
|
847
880
|
...t?.vLineColor === void 0 ? {} : { "grid.vertical.color": t.vLineColor },
|
|
848
881
|
...t?.vLineStyle === void 0 ? {} : { "grid.vertical.style": t.vLineStyle },
|
|
849
|
-
...
|
|
850
|
-
...
|
|
882
|
+
...Bn("horizontal", n?.hLine),
|
|
883
|
+
...Bn("vertical", n?.vLine),
|
|
851
884
|
...r === void 0 ? {} : { "crosshair.labelBackground": r },
|
|
852
885
|
...e.overrides
|
|
853
886
|
};
|
|
854
887
|
}
|
|
855
888
|
//#endregion
|
|
856
889
|
//#region src/layout/LayoutManager.ts
|
|
857
|
-
var
|
|
890
|
+
var Hn = 200, Un = 80, U = (e) => e.position === "top" || e.position === "bottom", Wn = class {
|
|
858
891
|
panels = [];
|
|
859
892
|
containerWidth = 0;
|
|
860
893
|
containerHeight = 0;
|
|
@@ -870,8 +903,8 @@ var Vn = 200, Hn = 80, U = (e) => e.position === "top" || e.position === "bottom
|
|
|
870
903
|
this.panels.push({
|
|
871
904
|
id: e,
|
|
872
905
|
position: n,
|
|
873
|
-
size: r ?? (a ?
|
|
874
|
-
minSize: a ?
|
|
906
|
+
size: r ?? (a ? Hn : t),
|
|
907
|
+
minSize: a ? Un : i,
|
|
875
908
|
content: {
|
|
876
909
|
type: "indicator",
|
|
877
910
|
indicatorInstanceId: e
|
|
@@ -940,7 +973,7 @@ var Vn = 200, Hn = 80, U = (e) => e.position === "top" || e.position === "bottom
|
|
|
940
973
|
let r = this.panels.find((t) => t.id === e);
|
|
941
974
|
if (r) {
|
|
942
975
|
let a = r.position === "left" || r.position === "right", o = n === "left" || n === "right";
|
|
943
|
-
r.position = n, a !== o && (r.size = o ?
|
|
976
|
+
r.position = n, a !== o && (r.size = o ? Hn : t, r.minSize = o ? Un : i), o && (r.collapsed = void 0, this.maximized === e && (this.maximized = null));
|
|
944
977
|
}
|
|
945
978
|
}
|
|
946
979
|
setPanelSize(e, t) {
|
|
@@ -1056,8 +1089,8 @@ var Vn = 200, Hn = 80, U = (e) => e.position === "top" || e.position === "bottom
|
|
|
1056
1089
|
getMainChartRect() {
|
|
1057
1090
|
return this.resolve().mainChartRect;
|
|
1058
1091
|
}
|
|
1059
|
-
},
|
|
1060
|
-
function
|
|
1092
|
+
}, Gn = 14, Kn = 14, qn = 22, Jn = 4;
|
|
1093
|
+
function Yn(e) {
|
|
1061
1094
|
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] : [
|
|
1062
1095
|
t,
|
|
1063
1096
|
n,
|
|
@@ -1066,16 +1099,16 @@ function Jn(e) {
|
|
|
1066
1099
|
for (let t of f) {
|
|
1067
1100
|
if (!Number.isFinite(t)) continue;
|
|
1068
1101
|
let n = e.scaleLabel ? e.scaleLabel(t) : e.format ? e.format(t) : h(t, u, i), r = e.format ? n : h(t, d, i);
|
|
1069
|
-
p = Math.max(p, l(n, `500 ${s}px ${a}`) +
|
|
1102
|
+
p = Math.max(p, l(n, `500 ${s}px ${a}`) + Gn, l(r, `bold 11px ${a}`) + Kn, l(r, `600 ${s}px ${a}`) + qn);
|
|
1070
1103
|
}
|
|
1071
|
-
return p <= o ? o : Math.ceil(p /
|
|
1104
|
+
return p <= o ? o : Math.ceil(p / Jn) * Jn;
|
|
1072
1105
|
}
|
|
1073
|
-
function
|
|
1106
|
+
function Xn(e, t) {
|
|
1074
1107
|
return t > e || t <= e - 12 ? t : e;
|
|
1075
1108
|
}
|
|
1076
1109
|
//#endregion
|
|
1077
1110
|
//#region src/layout/labelWidths.ts
|
|
1078
|
-
var
|
|
1111
|
+
var Zn = 512, Qn = class {
|
|
1079
1112
|
widths = /* @__PURE__ */ new Map();
|
|
1080
1113
|
fonts;
|
|
1081
1114
|
forget = () => this.widths.clear();
|
|
@@ -1086,12 +1119,12 @@ var Xn = 512, Zn = class {
|
|
|
1086
1119
|
let r = `${t}\n${e}`, i = this.widths.get(r);
|
|
1087
1120
|
if (i !== void 0) return i;
|
|
1088
1121
|
let a = n();
|
|
1089
|
-
return this.widths.size >=
|
|
1122
|
+
return this.widths.size >= Zn && this.widths.clear(), this.widths.set(r, a), a;
|
|
1090
1123
|
}
|
|
1091
1124
|
destroy() {
|
|
1092
1125
|
this.fonts?.removeEventListener("loadingdone", this.forget), this.widths.clear();
|
|
1093
1126
|
}
|
|
1094
|
-
},
|
|
1127
|
+
}, $n = class {
|
|
1095
1128
|
netY = 0;
|
|
1096
1129
|
travelX = 0;
|
|
1097
1130
|
engaged = !1;
|
|
@@ -1107,8 +1140,8 @@ var Xn = 512, Zn = class {
|
|
|
1107
1140
|
}
|
|
1108
1141
|
return this.engaged;
|
|
1109
1142
|
}
|
|
1110
|
-
},
|
|
1111
|
-
function
|
|
1143
|
+
}, er = 1;
|
|
1144
|
+
function tr(e, t) {
|
|
1112
1145
|
return e.filter((e) => e.enabled !== !1 && (e.descriptor.layer ?? "overlay") === t);
|
|
1113
1146
|
}
|
|
1114
1147
|
function W(e) {
|
|
@@ -1122,24 +1155,24 @@ function W(e) {
|
|
|
1122
1155
|
//#endregion
|
|
1123
1156
|
//#region src/plugins/registry.ts
|
|
1124
1157
|
var G = /* @__PURE__ */ new Map();
|
|
1125
|
-
function
|
|
1158
|
+
function nr(e) {
|
|
1126
1159
|
G.set(W(e), e);
|
|
1127
1160
|
}
|
|
1128
|
-
function
|
|
1161
|
+
function rr(e) {
|
|
1129
1162
|
return G.delete(e);
|
|
1130
1163
|
}
|
|
1131
|
-
function
|
|
1164
|
+
function ir() {
|
|
1132
1165
|
return [...G.values()];
|
|
1133
1166
|
}
|
|
1134
|
-
function
|
|
1167
|
+
function ar() {
|
|
1135
1168
|
G.clear();
|
|
1136
1169
|
}
|
|
1137
1170
|
//#endregion
|
|
1138
1171
|
//#region src/plugins/PluginManager.ts
|
|
1139
|
-
var
|
|
1172
|
+
var or = class {
|
|
1140
1173
|
plugins = /* @__PURE__ */ new Map();
|
|
1141
1174
|
constructor(e, t = {}) {
|
|
1142
|
-
if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of
|
|
1175
|
+
if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of ir()) this.add(e);
|
|
1143
1176
|
for (let e of t.plugins ?? []) this.add(e);
|
|
1144
1177
|
}
|
|
1145
1178
|
register(e) {
|
|
@@ -1169,15 +1202,15 @@ var ar = class {
|
|
|
1169
1202
|
add(e) {
|
|
1170
1203
|
this.plugins.set(W(e), e), e.kind === "indicator" && this.indicatorEngine.register(e.plugin);
|
|
1171
1204
|
}
|
|
1172
|
-
},
|
|
1205
|
+
}, sr = {
|
|
1173
1206
|
orderPlace: (e, t) => e.placeOrder(t),
|
|
1174
1207
|
orderModify: (e, t) => e.modifyOrder(t),
|
|
1175
1208
|
orderCancel: (e, t) => e.cancelOrder(t),
|
|
1176
1209
|
positionModify: (e, t) => e.modifyPosition(t),
|
|
1177
1210
|
positionClose: (e, t) => e.closePosition(t),
|
|
1178
|
-
positionReverse: (e, t, n) =>
|
|
1211
|
+
positionReverse: (e, t, n) => cr(e, t, n)
|
|
1179
1212
|
};
|
|
1180
|
-
async function
|
|
1213
|
+
async function cr(e, t, n) {
|
|
1181
1214
|
let { reversing: r } = n;
|
|
1182
1215
|
if (!r.has(t.positionId)) {
|
|
1183
1216
|
r.add(t.positionId);
|
|
@@ -1206,7 +1239,7 @@ async function sr(e, t, n) {
|
|
|
1206
1239
|
}
|
|
1207
1240
|
}
|
|
1208
1241
|
}
|
|
1209
|
-
function
|
|
1242
|
+
function lr(e, t) {
|
|
1210
1243
|
let n = [], r = null, i = {
|
|
1211
1244
|
positions: () => r ?? t.getPositions?.() ?? [],
|
|
1212
1245
|
reversing: /* @__PURE__ */ new Set()
|
|
@@ -1216,8 +1249,8 @@ function cr(e, t) {
|
|
|
1216
1249
|
e.data && t.onFill?.(e.data);
|
|
1217
1250
|
};
|
|
1218
1251
|
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));
|
|
1219
|
-
for (let r of Object.keys(
|
|
1220
|
-
let a =
|
|
1252
|
+
for (let r of Object.keys(sr)) {
|
|
1253
|
+
let a = sr[r], o = t.onIntent(r, (n) => {
|
|
1221
1254
|
Promise.resolve(a(e, n, i)).catch((e) => t.onError({
|
|
1222
1255
|
message: `Execution command failed: ${r}`,
|
|
1223
1256
|
cause: e
|
|
@@ -1230,28 +1263,243 @@ function cr(e, t) {
|
|
|
1230
1263
|
};
|
|
1231
1264
|
}
|
|
1232
1265
|
//#endregion
|
|
1266
|
+
//#region src/replay/ReplayStepLoader.ts
|
|
1267
|
+
var ur = 1e3, dr = class {
|
|
1268
|
+
pieces = /* @__PURE__ */ new Map();
|
|
1269
|
+
asked = /* @__PURE__ */ new Set();
|
|
1270
|
+
inFlight = !1;
|
|
1271
|
+
lastAsk = -Infinity;
|
|
1272
|
+
done = !1;
|
|
1273
|
+
now;
|
|
1274
|
+
constructor(e) {
|
|
1275
|
+
this.options = e, this.now = e.now ?? (() => Date.now());
|
|
1276
|
+
}
|
|
1277
|
+
piecesOf(e) {
|
|
1278
|
+
return this.pieces.get(e);
|
|
1279
|
+
}
|
|
1280
|
+
ensure(e, t, n) {
|
|
1281
|
+
if (this.done || this.inFlight) return;
|
|
1282
|
+
if (!this.options.source) {
|
|
1283
|
+
this.finish("end", 0);
|
|
1284
|
+
return;
|
|
1285
|
+
}
|
|
1286
|
+
let r = Math.min(e.length, t + Math.max(1, n)), i = t;
|
|
1287
|
+
for (; i < r && this.asked.has(e[i].time);) i++;
|
|
1288
|
+
if (i >= r) return;
|
|
1289
|
+
let a = this.now();
|
|
1290
|
+
a - this.lastAsk < 500 || (this.lastAsk = a, this.ask(e, i));
|
|
1291
|
+
}
|
|
1292
|
+
evictBefore(e) {
|
|
1293
|
+
for (let t of this.pieces.keys()) t < e && this.pieces.delete(t);
|
|
1294
|
+
for (let t of this.asked) t < e && this.asked.delete(t);
|
|
1295
|
+
}
|
|
1296
|
+
dispose() {
|
|
1297
|
+
this.done = !0;
|
|
1298
|
+
}
|
|
1299
|
+
ask(e, t) {
|
|
1300
|
+
let { ratio: n, barMs: r, step: i, report: a } = this.options, o = Math.max(1, Math.floor(ur / 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);
|
|
1301
|
+
for (let e of l) this.asked.add(e.time);
|
|
1302
|
+
this.inFlight = !0, a({
|
|
1303
|
+
state: "loading",
|
|
1304
|
+
step: i,
|
|
1305
|
+
count: 0
|
|
1306
|
+
}), this.options.source(c, l.length * n).then((e) => this.take(l, c, e), (e) => {
|
|
1307
|
+
this.done || (this.inFlight = !1, this.finish("error", 0, e instanceof Error ? e.message : String(e)));
|
|
1308
|
+
});
|
|
1309
|
+
}
|
|
1310
|
+
take(e, t, n) {
|
|
1311
|
+
if (this.done) return;
|
|
1312
|
+
if (this.inFlight = !1, n.length === 0) {
|
|
1313
|
+
this.options.report({
|
|
1314
|
+
state: "end",
|
|
1315
|
+
step: this.options.step,
|
|
1316
|
+
count: 0
|
|
1317
|
+
});
|
|
1318
|
+
return;
|
|
1319
|
+
}
|
|
1320
|
+
let r = n.reduce((e, t) => Math.min(e, t.time), Infinity), i = this.options.keep([...n].sort((e, t) => e.time - t.time)), a = 0, o = 0;
|
|
1321
|
+
e.forEach((n, s) => {
|
|
1322
|
+
let c = s + 1 < e.length ? e[s + 1].time : t;
|
|
1323
|
+
for (; o < i.length && i[o].time < n.time;) o++;
|
|
1324
|
+
let l = o;
|
|
1325
|
+
for (; o < i.length && i[o].time < c;) o++;
|
|
1326
|
+
o > l && r <= n.time && (this.pieces.set(n.time, i.slice(l, o)), a += o - l);
|
|
1327
|
+
}), this.options.report({
|
|
1328
|
+
state: "loaded",
|
|
1329
|
+
step: this.options.step,
|
|
1330
|
+
count: a
|
|
1331
|
+
});
|
|
1332
|
+
}
|
|
1333
|
+
finish(e, t, n) {
|
|
1334
|
+
this.done = !0, this.options.report({
|
|
1335
|
+
state: e,
|
|
1336
|
+
step: this.options.step,
|
|
1337
|
+
count: t,
|
|
1338
|
+
...n === void 0 ? {} : { error: n }
|
|
1339
|
+
});
|
|
1340
|
+
}
|
|
1341
|
+
}, fr = 1 / 3, pr = .25, mr = .5;
|
|
1342
|
+
function hr(e, t) {
|
|
1343
|
+
let n = (e.high - e.low) * pr;
|
|
1344
|
+
return t.filter((t) => t.close > e.high + n || t.close < e.low - n).length <= t.length * mr;
|
|
1345
|
+
}
|
|
1346
|
+
function gr(e) {
|
|
1347
|
+
return e.close >= e.open ? [
|
|
1348
|
+
e.open,
|
|
1349
|
+
e.low,
|
|
1350
|
+
e.high,
|
|
1351
|
+
e.close
|
|
1352
|
+
] : [
|
|
1353
|
+
e.open,
|
|
1354
|
+
e.high,
|
|
1355
|
+
e.low,
|
|
1356
|
+
e.close
|
|
1357
|
+
];
|
|
1358
|
+
}
|
|
1359
|
+
function _r(e, t, n) {
|
|
1360
|
+
let r = gr(e), i = [
|
|
1361
|
+
1,
|
|
1362
|
+
2,
|
|
1363
|
+
3
|
|
1364
|
+
].map((e) => Math.abs(r[e] - r[e - 1])), a = i[0] + i[1] + i[2], o = [], s = 0;
|
|
1365
|
+
return r.forEach((r, c) => {
|
|
1366
|
+
c > 0 && (s += a > 0 ? i[c - 1] / a : fr), !(c === 0 && t > 0) && o.push({
|
|
1367
|
+
price: r,
|
|
1368
|
+
time: e.time,
|
|
1369
|
+
at: (t + s) / n
|
|
1370
|
+
});
|
|
1371
|
+
}), o;
|
|
1372
|
+
}
|
|
1373
|
+
function vr(e, t = []) {
|
|
1374
|
+
let n = t.length > 0 && hr(e, t) ? t : [e], r = n.length, i = yr(n.flatMap((e, t) => _r(e, t, r)), e), a = n.reduce((e, t) => e + (t.volume ?? 0), 0), o = 0;
|
|
1375
|
+
return {
|
|
1376
|
+
bar: e,
|
|
1377
|
+
points: i,
|
|
1378
|
+
volumeAt: n.map((t, n) => (o += a > 0 ? (t.volume ?? 0) / a * (e.volume ?? 0) : (e.volume ?? 0) / r, {
|
|
1379
|
+
at: (n + 1) / r,
|
|
1380
|
+
volume: o
|
|
1381
|
+
}))
|
|
1382
|
+
};
|
|
1383
|
+
}
|
|
1384
|
+
function yr(e, t) {
|
|
1385
|
+
let n = e.length - 1, r = e.map((e, r) => ({
|
|
1386
|
+
...e,
|
|
1387
|
+
price: r === 0 ? t.open : r === n ? t.close : Math.min(t.high, Math.max(t.low, e.price))
|
|
1388
|
+
})), i = (e, t) => {
|
|
1389
|
+
if (r[0].price === e || r[n].price === e || n < 2) return;
|
|
1390
|
+
let i = 1;
|
|
1391
|
+
for (let e = 2; e < n; e++) t(r[e].price, r[i].price) && (i = e);
|
|
1392
|
+
r[i] = {
|
|
1393
|
+
...r[i],
|
|
1394
|
+
price: e
|
|
1395
|
+
};
|
|
1396
|
+
};
|
|
1397
|
+
return i(t.high, (e, t) => e > t), i(t.low, (e, t) => e < t), r;
|
|
1398
|
+
}
|
|
1399
|
+
function br(e, t) {
|
|
1400
|
+
let n = e.points;
|
|
1401
|
+
if (t <= n[0].at) return n[0].price;
|
|
1402
|
+
for (let e = 1; e < n.length; e++) if (t <= n[e].at) {
|
|
1403
|
+
let r = n[e].at - n[e - 1].at;
|
|
1404
|
+
return r > 0 ? n[e - 1].price + (n[e].price - n[e - 1].price) * (t - n[e - 1].at) / r : n[e].price;
|
|
1405
|
+
}
|
|
1406
|
+
return n[n.length - 1].price;
|
|
1407
|
+
}
|
|
1408
|
+
var xr = (e) => Number.isFinite(e) ? Math.min(1, Math.max(0, e)) : 0;
|
|
1409
|
+
function Sr(e, t) {
|
|
1410
|
+
let n = 0, r = 0;
|
|
1411
|
+
for (let i of e.volumeAt) {
|
|
1412
|
+
if (t >= i.at) {
|
|
1413
|
+
n = i.volume, r = i.at;
|
|
1414
|
+
continue;
|
|
1415
|
+
}
|
|
1416
|
+
return n + (i.volume - n) * (t - r) / (i.at - r);
|
|
1417
|
+
}
|
|
1418
|
+
return n;
|
|
1419
|
+
}
|
|
1420
|
+
function Cr(e, t) {
|
|
1421
|
+
let n = xr(t);
|
|
1422
|
+
if (n >= 1) return { ...e.bar };
|
|
1423
|
+
let r = br(e, n), i = Math.max(e.points[0].price, r), a = Math.min(e.points[0].price, r);
|
|
1424
|
+
for (let t of e.points) {
|
|
1425
|
+
if (t.at > n) break;
|
|
1426
|
+
i = Math.max(i, t.price), a = Math.min(a, t.price);
|
|
1427
|
+
}
|
|
1428
|
+
return {
|
|
1429
|
+
time: e.bar.time,
|
|
1430
|
+
open: e.points[0].price,
|
|
1431
|
+
high: i,
|
|
1432
|
+
low: a,
|
|
1433
|
+
close: r,
|
|
1434
|
+
volume: Sr(e, n)
|
|
1435
|
+
};
|
|
1436
|
+
}
|
|
1437
|
+
function wr(e, t) {
|
|
1438
|
+
let n = xr(t), r = 0;
|
|
1439
|
+
for (let t of e.points) {
|
|
1440
|
+
if (t.at > n) break;
|
|
1441
|
+
r = t.at;
|
|
1442
|
+
}
|
|
1443
|
+
return r;
|
|
1444
|
+
}
|
|
1445
|
+
function K(e, t, n) {
|
|
1446
|
+
let r = [], i = e.bar.time;
|
|
1447
|
+
for (let a of e.points) {
|
|
1448
|
+
if (a.at > n) break;
|
|
1449
|
+
i = a.time, a.at > t && r.push([a.price, a.time]);
|
|
1450
|
+
}
|
|
1451
|
+
let a = br(e, n);
|
|
1452
|
+
return (r.length === 0 || r[r.length - 1][0] !== a) && r.push([a, i]), r;
|
|
1453
|
+
}
|
|
1454
|
+
//#endregion
|
|
1455
|
+
//#region src/replay/replayStep.ts
|
|
1456
|
+
var Tr = [
|
|
1457
|
+
"1m",
|
|
1458
|
+
"3m",
|
|
1459
|
+
"5m",
|
|
1460
|
+
"15m",
|
|
1461
|
+
"30m",
|
|
1462
|
+
"1h",
|
|
1463
|
+
"2h",
|
|
1464
|
+
"4h",
|
|
1465
|
+
"1d"
|
|
1466
|
+
];
|
|
1467
|
+
function Er(e, t) {
|
|
1468
|
+
let n = w(e);
|
|
1469
|
+
return n > 0 ? Tr.filter((e) => {
|
|
1470
|
+
let r = w(e);
|
|
1471
|
+
return r < n && n % r === 0 && t(e);
|
|
1472
|
+
}) : [];
|
|
1473
|
+
}
|
|
1474
|
+
function Dr(e, t, n) {
|
|
1475
|
+
let r = Er(t, n);
|
|
1476
|
+
if (e !== "auto") return r.includes(e) ? e : null;
|
|
1477
|
+
let i = w(t);
|
|
1478
|
+
return r.find((e) => i / w(e) <= 60) ?? null;
|
|
1479
|
+
}
|
|
1480
|
+
//#endregion
|
|
1233
1481
|
//#region src/Chart.ts
|
|
1234
|
-
var
|
|
1482
|
+
var Or = {
|
|
1235
1483
|
min: 0,
|
|
1236
1484
|
max: 100
|
|
1237
|
-
},
|
|
1238
|
-
function
|
|
1485
|
+
}, kr = "exchange", Ar = kr;
|
|
1486
|
+
function jr(e) {
|
|
1239
1487
|
if (typeof e == "string" && e !== "exchange" && !v(e)) throw RangeError(`Unknown time zone: ${e}`);
|
|
1240
1488
|
if (typeof e == "number" && !Number.isFinite(e)) throw RangeError(`Invalid UTC offset: ${e}`);
|
|
1241
1489
|
}
|
|
1242
|
-
function
|
|
1243
|
-
let { timeZone: n, timezone: r } = e, i = n !== void 0 && r !== void 0 && n !== r && n === t ? r :
|
|
1490
|
+
function Mr(e, t) {
|
|
1491
|
+
let { timeZone: n, timezone: r } = e, i = n !== void 0 && r !== void 0 && n !== r && n === t ? r : C(e);
|
|
1244
1492
|
return i === void 0 ? e : {
|
|
1245
1493
|
...e,
|
|
1246
1494
|
timeZone: i,
|
|
1247
1495
|
timezone: i
|
|
1248
1496
|
};
|
|
1249
1497
|
}
|
|
1250
|
-
var
|
|
1251
|
-
static version = "1.
|
|
1498
|
+
var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontalLine", "crossLine"]), zr = new Set(["verticalLine", "crossLine"]), Br = class {
|
|
1499
|
+
static version = "1.53.0";
|
|
1252
1500
|
engine;
|
|
1253
1501
|
viewport;
|
|
1254
|
-
series = new Mn((e) => this.sessionKeep(e));
|
|
1502
|
+
series = new Mn((e) => this.sessionKeep(e), (e) => this.followLiveChange(e));
|
|
1255
1503
|
themeManager;
|
|
1256
1504
|
layoutManager;
|
|
1257
1505
|
pluginManager;
|
|
@@ -1266,7 +1514,7 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
1266
1514
|
execTeardown = null;
|
|
1267
1515
|
autoScrollOnNewBar = !0;
|
|
1268
1516
|
displayDataCache = null;
|
|
1269
|
-
reshapeMemo = new
|
|
1517
|
+
reshapeMemo = new ot();
|
|
1270
1518
|
displayDataStep;
|
|
1271
1519
|
indicatorUpdateFrom = null;
|
|
1272
1520
|
resolvedLayoutCache = null;
|
|
@@ -1277,7 +1525,7 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
1277
1525
|
renderDeferred = !1;
|
|
1278
1526
|
priceAxisWidth = o;
|
|
1279
1527
|
measureCtx;
|
|
1280
|
-
labelWidths = new
|
|
1528
|
+
labelWidths = new Qn();
|
|
1281
1529
|
containerSizeCache = null;
|
|
1282
1530
|
containerSizeCacheTime = 0;
|
|
1283
1531
|
lastEmittedRange = null;
|
|
@@ -1291,7 +1539,7 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
1291
1539
|
indicatorEdit = null;
|
|
1292
1540
|
removedDrawingAlerts = /* @__PURE__ */ new Map();
|
|
1293
1541
|
zoomAreaMode = !1;
|
|
1294
|
-
priceAxisAddButton = new
|
|
1542
|
+
priceAxisAddButton = new et();
|
|
1295
1543
|
displayTz = null;
|
|
1296
1544
|
timeZoneSetting = null;
|
|
1297
1545
|
symbolInfo = null;
|
|
@@ -1321,15 +1569,20 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
1321
1569
|
signalMarkerManager;
|
|
1322
1570
|
tradeZoneManager;
|
|
1323
1571
|
measureOverlay;
|
|
1324
|
-
selectionBoxOverlay = new
|
|
1572
|
+
selectionBoxOverlay = new ct();
|
|
1325
1573
|
replayManager;
|
|
1326
1574
|
replayBarUnsub = null;
|
|
1327
1575
|
replaySeeking = !1;
|
|
1328
1576
|
replaySession = null;
|
|
1577
|
+
replayCause = null;
|
|
1329
1578
|
replayStepsSeries = null;
|
|
1330
1579
|
replayCoarse = null;
|
|
1331
1580
|
replayRevealMarks = !0;
|
|
1332
1581
|
replayOffset = 0;
|
|
1582
|
+
replayPieces = null;
|
|
1583
|
+
replayLoader = null;
|
|
1584
|
+
replayForming = null;
|
|
1585
|
+
replayPhaseUnsub = null;
|
|
1333
1586
|
undoRedoManager;
|
|
1334
1587
|
autoSaveScheduler = new Tn((e) => this.saveState(e));
|
|
1335
1588
|
animator;
|
|
@@ -1343,14 +1596,14 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
1343
1596
|
disposed = !1;
|
|
1344
1597
|
chartTypeOptions = {};
|
|
1345
1598
|
mainSeriesVisible = !0;
|
|
1346
|
-
priceLines = new
|
|
1347
|
-
symbolSeries = new
|
|
1599
|
+
priceLines = new tt();
|
|
1600
|
+
symbolSeries = new ht();
|
|
1348
1601
|
extendedHours = !0;
|
|
1349
1602
|
replayRestarting = !1;
|
|
1350
1603
|
requestedSymbols = /* @__PURE__ */ new Set();
|
|
1351
1604
|
gridRenderer;
|
|
1352
1605
|
priceAxis;
|
|
1353
|
-
leftPriceAxis = new
|
|
1606
|
+
leftPriceAxis = new $e();
|
|
1354
1607
|
leftScaleRequested = !1;
|
|
1355
1608
|
leftAxisWidth = o;
|
|
1356
1609
|
leftViewport = null;
|
|
@@ -1383,7 +1636,7 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
1383
1636
|
snapshotKey = null;
|
|
1384
1637
|
historyCheckQueued = !1;
|
|
1385
1638
|
constructor(e, t) {
|
|
1386
|
-
t.timeZone != null &&
|
|
1639
|
+
t.timeZone != null && jr(t.timeZone), this.container = e, this.options = {
|
|
1387
1640
|
...t,
|
|
1388
1641
|
chartType: t.chartType ?? "candlestick"
|
|
1389
1642
|
}, this.numberLocale = t.numberLocale ?? "en-US", this.defaultAutoScale = t.autoScale !== !1;
|
|
@@ -1421,15 +1674,15 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
1421
1674
|
logScale: n.logScale ?? !0,
|
|
1422
1675
|
timeframes: n.timeframes ?? [],
|
|
1423
1676
|
defaultTimeframeFavorites: n.defaultTimeframeFavorites ?? []
|
|
1424
|
-
}, 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
|
|
1425
|
-
oldestTime: () => this.series.bars()[0]?.time ?? null,
|
|
1677
|
+
}, 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 Ln({
|
|
1678
|
+
oldestTime: () => (this.replaySession ? this.series.liveBars() : this.series.bars())[0]?.time ?? null,
|
|
1426
1679
|
prepend: (e) => this.prependBars(e),
|
|
1427
1680
|
emit: (e) => this.eventBus.emit("historyLoad", e)
|
|
1428
|
-
}), this.themeManager = new
|
|
1681
|
+
}), this.themeManager = new zn(t.theme), this.themeManager.setChartType(this.options.chartType ?? "candlestick"), this.applyStyle(Vn(t), "host", !1), this.layoutManager = new Wn(), this.indicatorEngine = new ze(), this.pluginManager = new or(this.indicatorEngine, { plugins: t.plugins }), this.eventBus = new Pe(), zt(this.indicatorEngine), this.indicatorEngine.register(new Ce(this.symbolSeries)), this.indicatorEngine.register(new ft(this.symbolSeries)), this.indicatorEngine.register(new we(this.symbolSeries)), this.indicatorEngine.register(new Te(this.symbolSeries)), this.drawingManager = new je(), Rt(this.drawingManager), this.drawingRenderer = new Me(this.drawingManager), this.drawingManager.setRequestRender(() => {
|
|
1429
1682
|
this.syncRenderContext(), this.engine.requestRender(r.Overlay), this.scheduleAutoSave();
|
|
1430
1683
|
}), this.drawingManager.setEventCallback((e, t) => {
|
|
1431
1684
|
this.followDrawingAlerts(e, t?.id), this.eventBus.emit(e, t), (e === "drawingCreate" || e === "drawingUpdate" || e === "drawingRemove") && this.announceStateChange();
|
|
1432
|
-
}), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new
|
|
1685
|
+
}), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new bt();
|
|
1433
1686
|
let i = "";
|
|
1434
1687
|
this.undoRedoManager.setOnChange(() => {
|
|
1435
1688
|
let { canUndo: e, canRedo: t } = this.undoRedoManager.getState(), n = `${e}|${t}`;
|
|
@@ -1442,21 +1695,21 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
1442
1695
|
primary: e[0] ?? null
|
|
1443
1696
|
})), this.drawingManager.setForeignHistory((e, t) => {
|
|
1444
1697
|
e.type === "custom" ? e.custom?.[t]() : this.applyIndicatorStep(e, t);
|
|
1445
|
-
}), 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
|
|
1698
|
+
}), 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 vt({
|
|
1446
1699
|
enabled: this.features.trading,
|
|
1447
1700
|
contextMenu: { enabled: this.features.tradingContextMenu }
|
|
1448
|
-
}), this.tradingRenderer = new
|
|
1701
|
+
}), this.tradingRenderer = new yt(this.tradingManager), this.tradingManager.setContainer(e), this.tradingManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradingManager.setEventCallback((e, t) => {
|
|
1449
1702
|
this.eventBus.emit(e, t);
|
|
1450
|
-
}), this.engine = new
|
|
1703
|
+
}), this.engine = new nt(e, t.maxPixelRatio);
|
|
1451
1704
|
let a = this.engine.dprManager.getContainerSize();
|
|
1452
|
-
if (this.viewport = new
|
|
1705
|
+
if (this.viewport = new xt(a.width, a.height, t.minBarSpacing ?? 2, t.maxBarSpacing ?? 30, t.rightMargin ?? 5), t.barLayout && this.viewport.setBarLayout(t.barLayout), this.viewport.setPanLimits({
|
|
1453
1706
|
freePan: t.freePan ?? !0,
|
|
1454
1707
|
minVisibleBars: t.panLimits?.minVisibleBars ?? 3
|
|
1455
1708
|
}), t.minBarUnit !== void 0 && this.viewport.setMinBarUnit(t.minBarUnit), this.layoutManager.resize(a.width, a.height), this.engine.onContainerResize = (e) => {
|
|
1456
1709
|
if (e.width <= 0 || e.height <= 0) return;
|
|
1457
1710
|
let t = this.viewport.isAtEnd();
|
|
1458
|
-
this.viewport.resize(e.width, e.height), this.layoutManager.resize(e.width, e.height), this.updateViewportAndRender(t);
|
|
1459
|
-
}, this.chartRenderer = this.createChartRenderer(this.options.chartType), this.gridRenderer = new Fe(), t.grid?.visible === !1 && this.gridRenderer.setVisible(!1), this.priceAxis = new
|
|
1711
|
+
this.viewport.resize(e.width, e.height), this.layoutManager.resize(e.width, e.height), this.updateViewportAndRender(t), this.eventBus.emit("resize", e);
|
|
1712
|
+
}, this.chartRenderer = this.createChartRenderer(this.options.chartType), this.gridRenderer = new Fe(), t.grid?.visible === !1 && this.gridRenderer.setVisible(!1), this.priceAxis = new $e(), this.priceAxis.setLocale(this.numberLocale), this.leftPriceAxis.setLocale(this.numberLocale), this.viewport.setNumberLocale(this.numberLocale), this.timeAxis = new gt(), this.timeAxis.setLocale(this.numberLocale), this.crosshairHandler = new Ee(), 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) => {
|
|
1460
1713
|
if (e !== null && t) {
|
|
1461
1714
|
let n = this.crosshairSeries(), r = e >= 0 && e < n.length ? n[e] : void 0;
|
|
1462
1715
|
this.chartLegend.setHoverBar(r ?? null, e > 0 ? n[e - 1] ?? null : null);
|
|
@@ -1465,7 +1718,7 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
1465
1718
|
prevClose: e > 0 ? n[e - 1]?.close : void 0,
|
|
1466
1719
|
priceRange: i.priceRange,
|
|
1467
1720
|
plot: i.chartRect,
|
|
1468
|
-
barStepMs:
|
|
1721
|
+
barStepMs: Dt(n),
|
|
1469
1722
|
timeUnit: u(n)
|
|
1470
1723
|
}) : this.crosshairTooltip.hide(), this.pinnedTooltip.isPinned() && this.pinnedTooltip.reposition(this.viewport.getState(), r ?? null, e, this.themeManager.getTheme()), this.eventBus.emit("crosshairMove", {
|
|
1471
1724
|
point: t,
|
|
@@ -1473,12 +1726,12 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
1473
1726
|
barIndex: e
|
|
1474
1727
|
});
|
|
1475
1728
|
} else this.crosshairTooltip.hide(), this.chartLegend.setHoverBar(null), this.eventBus.emit("crosshairLeave", {});
|
|
1476
|
-
}), this.chartLegend = new xe(), this.chartLegend.setChartType(this.options.chartType), this.chartLegend.setLocale(this.numberLocale), this.watermark = new
|
|
1729
|
+
}), this.chartLegend = new xe(), this.chartLegend.setChartType(this.options.chartType), this.chartLegend.setLocale(this.numberLocale), this.watermark = new Tt(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new wt(), this.volumeProfile = new Ct(), this.marketProfile = new Ge(), this.depthHeatmap = new Ae(), this.periodLevels = new Ye(), this.pivotMarkers = new Ze(), this.barCountdown = new _e(), this.barCountdown.setVisible(this.features.barCountdown), this.sessionBreaks = new lt(), this.sessionShading = new ut(), this.compareRenderer = new Se(), t.sessionBreaks ? this.sessionBreaks.setConfig({
|
|
1477
1730
|
visible: t.sessionBreaks.visible ?? !0,
|
|
1478
1731
|
color: t.sessionBreaks.color,
|
|
1479
1732
|
lineStyle: t.sessionBreaks.lineStyle,
|
|
1480
1733
|
lineWidth: t.sessionBreaks.lineWidth
|
|
1481
|
-
}) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new me(), this.crosshairTooltip = new De(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new
|
|
1734
|
+
}) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new me(), this.crosshairTooltip = new De(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new Xe(), this.pinnedTooltip.create(e), this.pinnedTooltip.setLocale(this.numberLocale), t.priceFormat && this.applyPriceFormat(t.priceFormat), t.chartTypeOptions && (this.chartTypeOptions = x(t.chartTypeOptions)), t.highLowLines && this.priceLines.setHighLow(!0), t.shapes && this.themeManager.setShape(Kr(t.shapes)), t.font && this.themeManager.setFont(Gr(t.font)), this.priceLines.setPriceText((e) => this.formatPrice(e)), t.extendedHours === !1 && (this.extendedHours = !1), t.timeFormatter && this.applyTimeFormatter(t.timeFormatter), this.keyboardHandler = new He({
|
|
1482
1735
|
scrollBars: (e) => {
|
|
1483
1736
|
let t = this.viewport.getState().barWidth + this.viewport.getState().barSpacing;
|
|
1484
1737
|
this.viewport.scrollBy(e * t), this.updateViewportAndRender();
|
|
@@ -1522,8 +1775,8 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
1522
1775
|
}
|
|
1523
1776
|
this.keyboardHandler.handleKey(e) && (e.preventDefault(), this.a11y?.viewMoved());
|
|
1524
1777
|
}
|
|
1525
|
-
}, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new Oe(), this.currentPriceLine.setLocale(this.numberLocale), this.priceAxis.setReservedPriceProvider(() => this.currentPriceLine.isVisible() ? this.currentPriceLine.getPrice() : null), this.alertManager = new pe(), this.alertManager.setDrawingLevels((e) => this.drawingLevelsNow(e)), this.alertManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.compareRenderer.setReservedLevels(() => this.alertManager.getAlerts().filter(
|
|
1526
|
-
this.eventBus.emit("alertTriggered",
|
|
1778
|
+
}, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new Oe(), this.currentPriceLine.setLocale(this.numberLocale), this.priceAxis.setReservedPriceProvider(() => this.currentPriceLine.isVisible() ? this.currentPriceLine.getPrice() : null), this.alertManager = new pe(), this.alertManager.setDrawingLevels((e) => this.drawingLevelsNow(e)), this.alertManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.compareRenderer.setReservedLevels(() => this.alertManager.getAlerts().filter(At).map((e) => e.price)), this.alertManager.on("triggered", (e) => {
|
|
1779
|
+
this.eventBus.emit("alertTriggered", q(e)), this.eventBus.emit("dataUpdate", {
|
|
1527
1780
|
kind: "alert",
|
|
1528
1781
|
alert: "triggered",
|
|
1529
1782
|
alertId: e.id,
|
|
@@ -1531,14 +1784,14 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
1531
1784
|
message: e.message
|
|
1532
1785
|
});
|
|
1533
1786
|
}), this.alertManager.on("added", (e) => {
|
|
1534
|
-
this.eventBus.emit("alertAdd",
|
|
1787
|
+
this.eventBus.emit("alertAdd", q(e));
|
|
1535
1788
|
}), this.alertManager.on("removed", (e) => {
|
|
1536
1789
|
this.eventBus.emit("alertRemove", { id: e });
|
|
1537
1790
|
}), this.alertManager.on("expired", (e) => {
|
|
1538
|
-
this.eventBus.emit("alertExpired",
|
|
1791
|
+
this.eventBus.emit("alertExpired", q(e));
|
|
1539
1792
|
}), this.alertManager.on("updated", (e) => {
|
|
1540
|
-
this.eventBus.emit("alertUpdate",
|
|
1541
|
-
}), this.signalMarkerManager = new
|
|
1793
|
+
this.eventBus.emit("alertUpdate", q(e));
|
|
1794
|
+
}), this.signalMarkerManager = new dt(), this.signalMarkerManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.signalMarkerManager.setDataGetter(() => this.series.bars()), this.signalMarkerManager.on("added", (e) => {
|
|
1542
1795
|
this.eventBus.emit("signalMarkerAdd", {
|
|
1543
1796
|
id: e.id,
|
|
1544
1797
|
source: e.source,
|
|
@@ -1546,14 +1799,14 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
1546
1799
|
});
|
|
1547
1800
|
}), this.signalMarkerManager.on("removed", (e) => {
|
|
1548
1801
|
this.eventBus.emit("signalMarkerRemove", { id: e });
|
|
1549
|
-
}), this.tradeZoneManager = new
|
|
1802
|
+
}), this.tradeZoneManager = new _t(), this.tradeZoneManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradeZoneManager.setDataGetter(() => this.series.bars()), this.tradeZoneManager.on("added", (e) => {
|
|
1550
1803
|
this.eventBus.emit("tradeZoneAdd", {
|
|
1551
1804
|
id: e.id,
|
|
1552
1805
|
direction: e.direction
|
|
1553
1806
|
});
|
|
1554
1807
|
}), this.tradeZoneManager.on("removed", (e) => {
|
|
1555
1808
|
this.eventBus.emit("tradeZoneRemove", { id: e });
|
|
1556
|
-
}), this.replayManager = new
|
|
1809
|
+
}), this.replayManager = new it(), this.replayManager.on("complete", () => {
|
|
1557
1810
|
let e = this.getReplayBarIndex(), t = this.replayCoarse?.[e];
|
|
1558
1811
|
t && this.eventBus.emit("replayComplete", {
|
|
1559
1812
|
barIndex: e,
|
|
@@ -1561,9 +1814,9 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
1561
1814
|
});
|
|
1562
1815
|
}), this.replayManager.on("stateChange", (e) => {
|
|
1563
1816
|
this.replayRestarting || this.eventBus.emit("replayState", { state: e });
|
|
1564
|
-
}), this.measureOverlay = new
|
|
1565
|
-
let e = new
|
|
1566
|
-
this.interactionManager.setPanHandler(new
|
|
1817
|
+
}), this.measureOverlay = new Ke(), this.interactionManager = new Be(e), this.features.panning) {
|
|
1818
|
+
let e = new $n();
|
|
1819
|
+
this.interactionManager.setPanHandler(new qe((t, n) => {
|
|
1567
1820
|
t && this.viewport.scrollBy(t), e.step(t, n, this.options.autoScale !== !1) && n && (this.holdPriceScale(), this.viewport.panPriceRange(n)), this.updateViewportAndRender();
|
|
1568
1821
|
}, () => e.reset()));
|
|
1569
1822
|
}
|
|
@@ -1575,7 +1828,7 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
1575
1828
|
scales: !this.indicatorEngine.hasLeftScaleOverlays()
|
|
1576
1829
|
}
|
|
1577
1830
|
})), this.features.zooming) {
|
|
1578
|
-
this.interactionManager.setZoomHandler(new
|
|
1831
|
+
this.interactionManager.setZoomHandler(new Et((e, t) => {
|
|
1579
1832
|
this.viewport.zoom(e, t - this.viewport.getState().chartRect.x), this.updateViewportAndRender();
|
|
1580
1833
|
}));
|
|
1581
1834
|
let e = new ge((e) => {
|
|
@@ -1611,7 +1864,7 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
1611
1864
|
let e = new fe(this.alertManager, () => this.viewport.getState());
|
|
1612
1865
|
this.interactionManager.setAlertDragHandler(e);
|
|
1613
1866
|
}
|
|
1614
|
-
let o = new
|
|
1867
|
+
let o = new Je();
|
|
1615
1868
|
o.configure(() => this.getResolvedLayout(), (e, t) => this.setPanelSize(e, t)), this.interactionManager.setPaneResizeHandler(o), this.interactionManager.setAltClickHandler((e) => {
|
|
1616
1869
|
let t = this.getDisplayData();
|
|
1617
1870
|
if (t.length === 0) return;
|
|
@@ -1678,7 +1931,7 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
1678
1931
|
end: () => {
|
|
1679
1932
|
let e = this.selectionBoxOverlay.end();
|
|
1680
1933
|
if (e && this.zoomAreaMode) {
|
|
1681
|
-
if (e.x1 - e.x0 <
|
|
1934
|
+
if (e.x1 - e.x0 < Lr) return;
|
|
1682
1935
|
this.zoomToBox(e), this.setZoomAreaMode(!1);
|
|
1683
1936
|
return;
|
|
1684
1937
|
}
|
|
@@ -1709,14 +1962,23 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
1709
1962
|
this.loadSeries(e, !1);
|
|
1710
1963
|
}
|
|
1711
1964
|
loadSeries(e, t) {
|
|
1965
|
+
if (this.replaySession && !t && e.length > 0 && !this.replayEndsFor(this.currentSymbol)) {
|
|
1966
|
+
this.loadDuringReplay(e);
|
|
1967
|
+
return;
|
|
1968
|
+
}
|
|
1712
1969
|
this.snapshotKey = null, this.endReplaySession(), this.history.reset(), this.series.load(e), this.crosshairHandler.setData(this.series.bars()), this.displayDataCache = null, this.reshapeMemo.clear(), this.sessionBreaks.invalidateCache(), this.options.autoScale = this.defaultAutoScale, this.priceFitPending = !0;
|
|
1713
1970
|
let n = this.series.bars();
|
|
1714
1971
|
this.seriesArriving = n.length === 0;
|
|
1715
1972
|
let r = n[n.length - 1];
|
|
1716
1973
|
t || (this.alertManager.clearLastValues(), r && this.alertManager.seedLastValue("price", r.close)), this.recalcIndicators(n), r && this.currentPriceLine.setPrice(r.close), this.updateViewportAndRender(!0), this.emitBars(n.length);
|
|
1717
1974
|
}
|
|
1975
|
+
loadDuringReplay(e) {
|
|
1976
|
+
this.snapshotKey = null, this.history.reset(), this.alertManager.clearLastValues();
|
|
1977
|
+
let t = e[e.length - 1];
|
|
1978
|
+
t && L(t) && this.alertManager.seedLastValue("price", t.close), this.replaySession && (this.replaySession.price = null), this.series.load(e);
|
|
1979
|
+
}
|
|
1718
1980
|
prependBars(e) {
|
|
1719
|
-
if (this.replaySession) return
|
|
1981
|
+
if (this.replaySession) return this.series.prepend(e).taken;
|
|
1720
1982
|
let t = this.getDisplayData(), n = Math.max(0, Math.min(t.length - 1, Math.floor(this.viewport.getState().visibleRange.from))), r = t[n]?.time, { added: i, taken: a } = this.series.prepend(e);
|
|
1721
1983
|
if (i === 0) return a;
|
|
1722
1984
|
let o = this.series.bars();
|
|
@@ -1739,7 +2001,7 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
1739
2001
|
this.historyFromStream = !1, this.hostHistoryLoader = e !== null, this.history.setLoader(e, t?.pageSize), this.checkHistory();
|
|
1740
2002
|
}
|
|
1741
2003
|
loadMoreHistory() {
|
|
1742
|
-
return this.
|
|
2004
|
+
return this.replayPages() ? this.history.loadMore() : Promise.resolve(0);
|
|
1743
2005
|
}
|
|
1744
2006
|
hasMoreHistory() {
|
|
1745
2007
|
return this.history.hasLoader() && this.history.hasMore();
|
|
@@ -1749,22 +2011,22 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
1749
2011
|
}
|
|
1750
2012
|
checkHistory() {
|
|
1751
2013
|
this.historyCheckQueued || !this.history.hasLoader() || (this.historyCheckQueued = !0, queueMicrotask(() => {
|
|
1752
|
-
if (this.historyCheckQueued = !1, this.
|
|
2014
|
+
if (this.historyCheckQueued = !1, !this.replayPages() || !this.history.hasLoader() || I(this.options.chartType)) return;
|
|
1753
2015
|
let { visibleRange: e, chartRect: t } = this.viewport.getState();
|
|
1754
2016
|
if (t.width <= 0) return;
|
|
1755
2017
|
let { from: n, to: r } = e;
|
|
1756
|
-
this.history.maybeLoad(Math.max(0, Math.floor(n)), Math.max(
|
|
2018
|
+
this.history.maybeLoad(Math.max(0, Math.floor(n)), Math.max(Ir, r - n));
|
|
1757
2019
|
}));
|
|
1758
2020
|
}
|
|
1759
|
-
useStreamHistory(e, t) {
|
|
2021
|
+
useStreamHistory(e, t, n = !0) {
|
|
1760
2022
|
if (this.hostHistoryLoader) return;
|
|
1761
|
-
let
|
|
1762
|
-
if (!
|
|
2023
|
+
let r = N(e), i = r.fetchHistoryBefore, a = this.streamTimeframe;
|
|
2024
|
+
if (!i || a === null || ue(a) !== null) {
|
|
1763
2025
|
this.historyFromStream && this.history.setLoader(null), this.historyFromStream = !1;
|
|
1764
2026
|
return;
|
|
1765
2027
|
}
|
|
1766
|
-
let
|
|
1767
|
-
this.history.setLoader((e, t) =>
|
|
2028
|
+
let o = this.currentSymbol;
|
|
2029
|
+
this.history.setLoader((e, t) => i.call(r, o, a, e, t), t), this.historyFromStream = !0, n && this.checkHistory();
|
|
1768
2030
|
}
|
|
1769
2031
|
appendBar(e) {
|
|
1770
2032
|
if (!L(e)) return;
|
|
@@ -1850,11 +2112,11 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
1850
2112
|
setChartTypeOptions(e) {
|
|
1851
2113
|
this.chartTypeOptions = {
|
|
1852
2114
|
...this.chartTypeOptions,
|
|
1853
|
-
...
|
|
2115
|
+
...x(e)
|
|
1854
2116
|
}, this.displayDataCache = null, this.updateViewportAndRender(!0), this.a11y?.refresh(!0), this.markStateChanged();
|
|
1855
2117
|
}
|
|
1856
2118
|
getChartTypeOptions() {
|
|
1857
|
-
return
|
|
2119
|
+
return x(this.chartTypeOptions);
|
|
1858
2120
|
}
|
|
1859
2121
|
setExtendedHours(e) {
|
|
1860
2122
|
e !== this.extendedHours && (this.extendedHours = e, this.reapplyExtendedHours(), this.markStateChanged());
|
|
@@ -1874,7 +2136,7 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
1874
2136
|
return this.priceLines.setQuoteShown(this.replaySession === null), this.priceLines;
|
|
1875
2137
|
}
|
|
1876
2138
|
setShapes(e) {
|
|
1877
|
-
let t =
|
|
2139
|
+
let t = Kr(e);
|
|
1878
2140
|
t.tagRadius !== void 0 && (this.themeManager.setShape({
|
|
1879
2141
|
...this.themeManager.getTheme().shape,
|
|
1880
2142
|
...t
|
|
@@ -1886,7 +2148,7 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
1886
2148
|
setFont(e) {
|
|
1887
2149
|
if (e === null) this.themeManager.setFont(null);
|
|
1888
2150
|
else {
|
|
1889
|
-
let t =
|
|
2151
|
+
let t = Gr(e);
|
|
1890
2152
|
if (Object.keys(t).length === 0) return;
|
|
1891
2153
|
this.themeManager.setFont(t);
|
|
1892
2154
|
}
|
|
@@ -1937,7 +2199,7 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
1937
2199
|
setSymbolSeries(e, t) {
|
|
1938
2200
|
e = e.trim(), this.symbolSeries.set(e, t), this.requestedSymbols.delete(e);
|
|
1939
2201
|
let n = this.series.bars(), r = !1;
|
|
1940
|
-
for (let t of this.indicatorEngine.getActiveIndicators()) !
|
|
2202
|
+
for (let t of this.indicatorEngine.getActiveIndicators()) !O.has(t.id) || String(t.params.symbol ?? "").trim() !== e.trim() || (this.indicatorEngine.updateIndicator(t.instanceId, {}, n), r = !0);
|
|
1941
2203
|
r && (this.announceIndicatorUpdate(0), this.updateViewportAndRender());
|
|
1942
2204
|
}
|
|
1943
2205
|
forgetUnreadSymbols() {
|
|
@@ -1951,13 +2213,13 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
1951
2213
|
let e = /* @__PURE__ */ new Set();
|
|
1952
2214
|
for (let t of this.indicatorEngine.getActiveIndicators()) {
|
|
1953
2215
|
let n = t.params.symbol;
|
|
1954
|
-
|
|
2216
|
+
O.has(t.id) && typeof n == "string" && n.trim() && e.add(n.trim());
|
|
1955
2217
|
}
|
|
1956
2218
|
return [...e];
|
|
1957
2219
|
}
|
|
1958
2220
|
requestMissingSymbols(e) {
|
|
1959
2221
|
this.forgetUnreadSymbols();
|
|
1960
|
-
let t = this.indicatorEngine.getIndicatorConfig(e), n = t &&
|
|
2222
|
+
let t = this.indicatorEngine.getIndicatorConfig(e), n = t && O.has(t.id) && typeof t.params.symbol == "string" ? t.params.symbol.trim() : "";
|
|
1961
2223
|
!n || this.symbolSeries.has(n) || this.requestedSymbols.has(n) || (this.requestedSymbols.add(n), this.eventBus.emit("symbolSeriesRequest", { symbol: n }));
|
|
1962
2224
|
}
|
|
1963
2225
|
updateIndicator(e, t) {
|
|
@@ -2028,8 +2290,8 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
2028
2290
|
return {
|
|
2029
2291
|
...e,
|
|
2030
2292
|
priceRange: {
|
|
2031
|
-
min: t.min - n *
|
|
2032
|
-
max: t.max + n *
|
|
2293
|
+
min: t.min - n * Nr,
|
|
2294
|
+
max: t.max + n * Nr
|
|
2033
2295
|
},
|
|
2034
2296
|
logScale: !1,
|
|
2035
2297
|
scaleMode: "regular",
|
|
@@ -2082,7 +2344,7 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
2082
2344
|
this.indicatorEngine.setStyleDefaults(e, null);
|
|
2083
2345
|
return;
|
|
2084
2346
|
}
|
|
2085
|
-
let { plots: n, ...r } = t, i = n === void 0 ? void 0 :
|
|
2347
|
+
let { plots: n, ...r } = t, i = n === void 0 ? void 0 : ae(n);
|
|
2086
2348
|
this.indicatorEngine.setStyleDefaults(e, {
|
|
2087
2349
|
...r,
|
|
2088
2350
|
...i ? { plots: i } : {}
|
|
@@ -2090,7 +2352,7 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
2090
2352
|
}
|
|
2091
2353
|
setPaneStyle(e, t) {
|
|
2092
2354
|
let n = this.paneOf(e);
|
|
2093
|
-
this.layoutManager.getPanels().some((e) => e.id === n) && this.recordIndicators(n, () => this.setPaneStyleNow(n, t ?
|
|
2355
|
+
this.layoutManager.getPanels().some((e) => e.id === n) && this.recordIndicators(n, () => this.setPaneStyleNow(n, t ? oe(t) : null));
|
|
2094
2356
|
}
|
|
2095
2357
|
setPaneStyleNow(e, t) {
|
|
2096
2358
|
JSON.stringify(t) !== JSON.stringify(this.paneStyles.get(e) ?? null) && (t ? this.paneStyles.set(e, t) : this.paneStyles.delete(e), this.panelInfoCache = null, this.syncRenderContext(), this.engine.requestRender(), this.markStateChanged());
|
|
@@ -2109,8 +2371,8 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
2109
2371
|
return this.pluginManager;
|
|
2110
2372
|
}
|
|
2111
2373
|
static indicators() {
|
|
2112
|
-
let e = new
|
|
2113
|
-
return
|
|
2374
|
+
let e = new ze();
|
|
2375
|
+
return zt(e), e.getAvailableIndicators();
|
|
2114
2376
|
}
|
|
2115
2377
|
setPanelPosition(e, t) {
|
|
2116
2378
|
this.layoutManager.setPanelPosition(e, t), this.updateViewportAndRender(), this.eventBus.emit("indicatorChange", {
|
|
@@ -2248,7 +2510,7 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
2248
2510
|
roundPrice(e) {
|
|
2249
2511
|
if (!Number.isFinite(e)) return e;
|
|
2250
2512
|
let t = this.stepAt(e);
|
|
2251
|
-
if (t !== void 0) return Number((Math.round(e / t) * t).toFixed(
|
|
2513
|
+
if (t !== void 0) return Number((Math.round(e / t) * t).toFixed(le(t)));
|
|
2252
2514
|
let { min: n, max: r } = this.viewport.getState().priceRange;
|
|
2253
2515
|
return Number(e.toFixed(this.marketPricePrecision ?? c(n, r)));
|
|
2254
2516
|
}
|
|
@@ -2332,7 +2594,7 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
2332
2594
|
}
|
|
2333
2595
|
autoFib() {
|
|
2334
2596
|
if (!this.features.drawings) return null;
|
|
2335
|
-
let e = this.getDisplayData(), t = this.viewport.getState(), n =
|
|
2597
|
+
let e = this.getDisplayData(), t = this.viewport.getState(), n = Ot(e, t.visibleRange.from, t.visibleRange.to);
|
|
2336
2598
|
return n ? this.addDrawing({
|
|
2337
2599
|
type: "fibRetracement",
|
|
2338
2600
|
anchors: [n[0], n[1]]
|
|
@@ -2410,7 +2672,7 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
2410
2672
|
recordUndo(e) {
|
|
2411
2673
|
if (!this.features.drawingUndoRedo || typeof e?.undo != "function" || typeof e.redo != "function") return;
|
|
2412
2674
|
let t = performance.now(), n = this.undoRedoManager.last();
|
|
2413
|
-
if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at <
|
|
2675
|
+
if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at < Fr) {
|
|
2414
2676
|
this.undoRedoManager.replaceLast({
|
|
2415
2677
|
...n,
|
|
2416
2678
|
custom: {
|
|
@@ -2618,7 +2880,7 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
2618
2880
|
this.recordIndicators(e, () => this.updateIndicatorStyleNow(e, t));
|
|
2619
2881
|
}
|
|
2620
2882
|
updateIndicatorStyleNow(e, t) {
|
|
2621
|
-
let { plots: n, ...r } = t, i = n === void 0 ? void 0 :
|
|
2883
|
+
let { plots: n, ...r } = t, i = n === void 0 ? void 0 : ae(n);
|
|
2622
2884
|
this.indicatorEngine.updateIndicatorStyle(e, {
|
|
2623
2885
|
...r,
|
|
2624
2886
|
...i ? { plots: i } : {}
|
|
@@ -2737,10 +2999,10 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
2737
2999
|
this.features.trading && this.tradingManager.setConfig(e);
|
|
2738
3000
|
}
|
|
2739
3001
|
async connect(e) {
|
|
2740
|
-
if (!
|
|
2741
|
-
this.snapshotKey = null, this.
|
|
3002
|
+
if (!A(e.adapter, e.timeframe)) throw RangeError(`${e.adapter.name} cannot serve the ${e.timeframe} timeframe`);
|
|
3003
|
+
this.snapshotKey = null, this.holdReplayFor(e.symbol), this.disconnectStream(), this.streamManager = new mt(), this.streamManager.setTimeZone(this.studyZoneHeld ? this.studyZone : this.getExchangeTimeZone()), this.streamManager.on("snapshot", (t) => {
|
|
2742
3004
|
let n = this.streamSeriesKey(e.adapter);
|
|
2743
|
-
this.replaySession ? this.series.
|
|
3005
|
+
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);
|
|
2744
3006
|
}), this.streamManager.on("barClose", (e) => {
|
|
2745
3007
|
if (!L(e)) return;
|
|
2746
3008
|
let t = this.series.placeStreamBar(e);
|
|
@@ -2794,18 +3056,18 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
2794
3056
|
}), this.streamManager.on("symbolInfo", (e) => this.applyFeedSymbolInfo(e)), this.autoScrollOnNewBar = e.autoScroll !== !1, this.setStreamTarget(e.symbol, e.timeframe), this.streamAdapter = e.adapter;
|
|
2795
3057
|
let t = this.streamManager;
|
|
2796
3058
|
if (this.resolveStreamSymbol(e.adapter, e.symbol), await t.connect(e), this.streamManager !== t) return;
|
|
2797
|
-
let n =
|
|
3059
|
+
let n = w(e.timeframe);
|
|
2798
3060
|
this.barCountdown.setTimeframeMs(n), this.countdownInterval && clearInterval(this.countdownInterval), this.countdownInterval = setInterval(() => {
|
|
2799
3061
|
this.barCountdown.isVisible() && this.engine.requestRender(r.Hover);
|
|
2800
3062
|
}, 1e3);
|
|
2801
3063
|
}
|
|
2802
3064
|
streamSeriesKey(e) {
|
|
2803
|
-
let t = N(e), n = this.streamTimeframe, r = t instanceof
|
|
3065
|
+
let t = N(e), n = this.streamTimeframe, r = t instanceof at && n !== null ? t.bucketFor(this.currentSymbol, n) : null;
|
|
2804
3066
|
return `${this.currentSymbol}|${n}|${r?.timeZone ?? ""}`;
|
|
2805
3067
|
}
|
|
2806
3068
|
setStreamTarget(e, t) {
|
|
2807
3069
|
let n = this.announcedSymbol;
|
|
2808
|
-
this.currentSymbol = e, this.streamTimeframe = t, this.tickStream =
|
|
3070
|
+
this.currentSymbol = e, this.streamTimeframe = t, this.tickStream = ue(t) !== null, this.applyTimeSpacing(), e !== n && this.chartLegend.setSymbol(e), e !== n && (this.announcedSymbol = e, this.eventBus.emit("symbolChange", {
|
|
2809
3071
|
symbol: e,
|
|
2810
3072
|
previous: n
|
|
2811
3073
|
})), this.useTimeframe(t);
|
|
@@ -2823,8 +3085,8 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
2823
3085
|
async switchStream(e, t) {
|
|
2824
3086
|
if (!this.streamManager) return;
|
|
2825
3087
|
let n = this.streamAdapter;
|
|
2826
|
-
if (n && !
|
|
2827
|
-
this.setStreamTarget(e, t), this.historyFromStream && this.history.setLoader(null), this.barCountdown.setTimeframeMs(
|
|
3088
|
+
if (n && !A(n, t)) throw RangeError(`${n.name} cannot serve the ${t} timeframe`);
|
|
3089
|
+
this.holdReplayFor(e), this.setStreamTarget(e, t), this.historyFromStream && this.history.setLoader(null), this.barCountdown.setTimeframeMs(w(t)), n && this.resolveStreamSymbol(n, e), await this.streamManager.switchTo(e, t);
|
|
2828
3090
|
}
|
|
2829
3091
|
isIndicatorAllowed(e) {
|
|
2830
3092
|
let t = this.features.indicatorIds;
|
|
@@ -2839,11 +3101,11 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
2839
3101
|
this.isTimeframeAllowed(e) && await this.switchStream(this.currentSymbol, e);
|
|
2840
3102
|
}
|
|
2841
3103
|
disconnectStream() {
|
|
2842
|
-
this.symbolInfoSeq++, this.releaseStudyZoneAfterCaller(), this.priceLines.setBidAsk(null), this.streamManager &&= (this.streamManager.dispose(), null), this.historyFromStream &&= (this.history.setLoader(null), !1), this.streamAdapter = null, this.tickStream = !1, this.applyTimeSpacing();
|
|
3104
|
+
this.symbolInfoSeq++, this.releaseStudyZoneAfterCaller(), this.priceLines.setBidAsk(null), this.streamManager &&= (this.streamManager.dispose(), null), this.historyFromStream &&= (this.history.setLoader(null), !1), this.replayLoader?.loader.dispose(), this.replayLoader = null, this.streamAdapter = null, this.tickStream = !1, this.applyTimeSpacing();
|
|
2843
3105
|
}
|
|
2844
3106
|
connectExecution(e, t = {}) {
|
|
2845
3107
|
if (!this.features.trading) throw Error("connectExecution requires features.trading to be enabled");
|
|
2846
|
-
this.disconnectExecution(), this.executionAdapter = e, this.execTeardown =
|
|
3108
|
+
this.disconnectExecution(), this.executionAdapter = e, this.execTeardown = lr(e, {
|
|
2847
3109
|
onIntent: (e, t) => {
|
|
2848
3110
|
let n = (e) => t(e.payload);
|
|
2849
3111
|
return this.eventBus.on(e, n), () => this.eventBus.off(e, n);
|
|
@@ -2974,7 +3236,7 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
2974
3236
|
setVisibleRangePreset(e) {
|
|
2975
3237
|
let t = this.getDisplayData();
|
|
2976
3238
|
if (t.length === 0) return;
|
|
2977
|
-
let n = t.length - 1, r = u(t), i =
|
|
3239
|
+
let n = t.length - 1, r = u(t), i = It(e, t[n].time * r, this.displayTz), a = i === null ? null : i / r;
|
|
2978
3240
|
if (a === null || a < t[0].time) {
|
|
2979
3241
|
this.fitContent();
|
|
2980
3242
|
return;
|
|
@@ -3110,7 +3372,7 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
3110
3372
|
this.applyStyle(e, t.layer ?? "host", !0);
|
|
3111
3373
|
}
|
|
3112
3374
|
setOverrides(e, t = {}) {
|
|
3113
|
-
let n = t.layer ?? "host", { overrides: r, rejected: i } =
|
|
3375
|
+
let n = t.layer ?? "host", { overrides: r, rejected: i } = ie(e);
|
|
3114
3376
|
i.length > 0 && console.warn(`Style overrides left out (unknown key or value): ${i.join(", ")}`);
|
|
3115
3377
|
let a = Object.fromEntries(Object.entries(r).filter(([, e]) => e !== null));
|
|
3116
3378
|
this.themeManager.setOverrides(a, n) && this.styleChanged(n);
|
|
@@ -3129,7 +3391,7 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
3129
3391
|
return this.themeManager.getStyleValue(e);
|
|
3130
3392
|
}
|
|
3131
3393
|
applyStyle(e, t, n) {
|
|
3132
|
-
let { overrides: r, rejected: i } =
|
|
3394
|
+
let { overrides: r, rejected: i } = ie(e);
|
|
3133
3395
|
i.length > 0 && console.warn(`Style overrides left out (unknown key or value): ${i.join(", ")}`), this.themeManager.applyOverrides(r, t) && n && this.styleChanged(t);
|
|
3134
3396
|
}
|
|
3135
3397
|
styleChanged(e) {
|
|
@@ -3236,7 +3498,7 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
3236
3498
|
return this.periodLevels.getPeriod();
|
|
3237
3499
|
}
|
|
3238
3500
|
setTimeZone(e) {
|
|
3239
|
-
|
|
3501
|
+
jr(e), this.timeZoneSetting = e, this.applyTimeZone();
|
|
3240
3502
|
}
|
|
3241
3503
|
getTimeZone() {
|
|
3242
3504
|
return this.timeZoneSetting;
|
|
@@ -3245,7 +3507,7 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
3245
3507
|
return this.displayTz;
|
|
3246
3508
|
}
|
|
3247
3509
|
getExchangeTimeZone() {
|
|
3248
|
-
return [
|
|
3510
|
+
return [C(this.symbolInfo), this.marketConfig?.timeZone].find((e) => e && v(e)) ?? null;
|
|
3249
3511
|
}
|
|
3250
3512
|
setTimezone(e) {
|
|
3251
3513
|
this.setTimeZone(e);
|
|
@@ -3272,7 +3534,7 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
3272
3534
|
this.indicatorEngine.setExchangeTimeZone(e, t.length > 0 ? t : void 0) && t.length > 0 && this.announceIndicatorUpdate(0);
|
|
3273
3535
|
}
|
|
3274
3536
|
holdStudyZone() {
|
|
3275
|
-
this.endStudyZoneWait(), this.studyZoneHeld = !0, this.studyZoneTimer = setTimeout(() => this.releaseStudyZone(),
|
|
3537
|
+
this.endStudyZoneWait(), this.studyZoneHeld = !0, this.studyZoneTimer = setTimeout(() => this.releaseStudyZone(), st);
|
|
3276
3538
|
}
|
|
3277
3539
|
endStudyZoneWait() {
|
|
3278
3540
|
this.studyZoneReleaseQueued = !1, this.studyZoneTimer !== null && (clearTimeout(this.studyZoneTimer), this.studyZoneTimer = null);
|
|
@@ -3300,18 +3562,18 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
3300
3562
|
this.studyZoneHeld = !1, this.endStudyZoneWait(), this.useSymbolInfo(e);
|
|
3301
3563
|
}
|
|
3302
3564
|
useSymbolInfo(e) {
|
|
3303
|
-
let t = e && this.symbolInfo?.symbol === e.symbol ?
|
|
3304
|
-
this.symbolInfo = e ?
|
|
3565
|
+
let t = e && this.symbolInfo?.symbol === e.symbol ? C(this.symbolInfo) : void 0;
|
|
3566
|
+
this.symbolInfo = e ? Mr({
|
|
3305
3567
|
...e,
|
|
3306
3568
|
sessions: e.sessions?.map((e) => ({ ...e }))
|
|
3307
3569
|
}, 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);
|
|
3308
3570
|
let n = (this.symbolInfo?.sessions ?? []).flatMap((e) => {
|
|
3309
|
-
let t =
|
|
3571
|
+
let t = S(e.start), n = S(e.end);
|
|
3310
3572
|
return t === null || n === null ? [] : [{
|
|
3311
3573
|
startMinute: t,
|
|
3312
3574
|
endMinute: n
|
|
3313
3575
|
}];
|
|
3314
|
-
}), i =
|
|
3576
|
+
}), i = C(this.symbolInfo);
|
|
3315
3577
|
this.sessionShading.replaceConfig(n.length > 0 && i && v(i) ? {
|
|
3316
3578
|
timeZone: i,
|
|
3317
3579
|
windows: n,
|
|
@@ -3326,11 +3588,11 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
3326
3588
|
if (!e || typeof e != "object") return;
|
|
3327
3589
|
let t = this.currentSymbol, n = (e) => !e || e.toUpperCase() === t.toUpperCase();
|
|
3328
3590
|
if (!n(e.symbol)) return;
|
|
3329
|
-
let r = this.symbolInfo && n(this.symbolInfo.symbol) ? this.symbolInfo : null, i =
|
|
3591
|
+
let r = this.symbolInfo && n(this.symbolInfo.symbol) ? this.symbolInfo : null, i = Mr({
|
|
3330
3592
|
...r,
|
|
3331
3593
|
...e,
|
|
3332
3594
|
symbol: e.symbol || r?.symbol || t
|
|
3333
|
-
},
|
|
3595
|
+
}, C(r));
|
|
3334
3596
|
r && JSON.stringify(i) === JSON.stringify(r) || (this.symbolInfoSeq++, this.setSymbolInfo(i));
|
|
3335
3597
|
}
|
|
3336
3598
|
resolveStreamSymbol(e, t) {
|
|
@@ -3365,7 +3627,7 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
3365
3627
|
return this.sessionShading.isVisible();
|
|
3366
3628
|
}
|
|
3367
3629
|
setSessionShadingConfig(e) {
|
|
3368
|
-
this.hostSessionHours =
|
|
3630
|
+
this.hostSessionHours = Nt(this.hostSessionHours, e), this.sessionShading.replaceConfig(this.hostSessionHours), this.engine.requestRender(r.Background);
|
|
3369
3631
|
}
|
|
3370
3632
|
setTooltipVisible(e) {
|
|
3371
3633
|
e || this.crosshairTooltip.hide();
|
|
@@ -3387,8 +3649,8 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
3387
3649
|
return this.waitForGpu(null), e === "canvas" ? (this.applyRenderer(null), "canvas") : this.engine.getGpu() ? "webgl" : this.takeGpu(e, t, !0);
|
|
3388
3650
|
}
|
|
3389
3651
|
async takeGpu(e, t, n) {
|
|
3390
|
-
let { gpu: r, reason: i } = await
|
|
3391
|
-
return t !== this.rendererToken || this.disposed ? (r?.destroy(), this.getRenderer()) : i === "limit" ?
|
|
3652
|
+
let { gpu: r, reason: i } = await Mt(e);
|
|
3653
|
+
return t !== this.rendererToken || this.disposed ? (r?.destroy(), this.getRenderer()) : i === "limit" ? kt() > 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());
|
|
3392
3654
|
}
|
|
3393
3655
|
waitForGpu(e) {
|
|
3394
3656
|
this.stopWaitingForGpu?.(), this.stopWaitingForGpu = e ? Kt(e) : null;
|
|
@@ -3413,7 +3675,7 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
3413
3675
|
this.engine.getGpu() && this.engine.renderNow();
|
|
3414
3676
|
}
|
|
3415
3677
|
screenshot(e) {
|
|
3416
|
-
this.features.screenshot && (this.freshFrame(),
|
|
3678
|
+
this.features.screenshot && (this.freshFrame(), k.download(this.container, e, this.themeManager.getTheme().background));
|
|
3417
3679
|
}
|
|
3418
3680
|
async copyScreenshot() {
|
|
3419
3681
|
if (!this.features.screenshot) return !1;
|
|
@@ -3421,7 +3683,7 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
3421
3683
|
if (!t?.write || !e) return !1;
|
|
3422
3684
|
try {
|
|
3423
3685
|
this.freshFrame();
|
|
3424
|
-
let n =
|
|
3686
|
+
let n = k.toBlob(this.container, this.themeManager.getTheme().background).then((e) => {
|
|
3425
3687
|
if (!e) throw Error("No chart image to copy");
|
|
3426
3688
|
return e;
|
|
3427
3689
|
});
|
|
@@ -3439,10 +3701,10 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
3439
3701
|
}
|
|
3440
3702
|
}
|
|
3441
3703
|
screenshotDataURL() {
|
|
3442
|
-
return this.features.screenshot ? (this.freshFrame(),
|
|
3704
|
+
return this.features.screenshot ? (this.freshFrame(), k.toDataURL(this.container, this.themeManager.getTheme().background)) : null;
|
|
3443
3705
|
}
|
|
3444
3706
|
async screenshotBlob() {
|
|
3445
|
-
return this.features.screenshot ? (this.freshFrame(),
|
|
3707
|
+
return this.features.screenshot ? (this.freshFrame(), k.toBlob(this.container, this.themeManager.getTheme().background)) : null;
|
|
3446
3708
|
}
|
|
3447
3709
|
addAlert(e, t = "crossing", n, r = "price", i, a = {}) {
|
|
3448
3710
|
if (!this.features.alerts) return null;
|
|
@@ -3566,65 +3828,212 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
3566
3828
|
}
|
|
3567
3829
|
replayStart(e) {
|
|
3568
3830
|
if (!this.features.replay) return;
|
|
3569
|
-
this.history.reset();
|
|
3570
3831
|
let t = this.replaySession ? this.replayOffset : 0;
|
|
3571
3832
|
if (!this.replaySession) {
|
|
3572
3833
|
if (this.series.length() === 0) return;
|
|
3573
|
-
this.series.beginReplay(), this.replaySession =
|
|
3574
|
-
price: null,
|
|
3575
|
-
fedTime: null
|
|
3576
|
-
};
|
|
3834
|
+
this.series.beginReplay(), this.replaySession = ei(this.currentSymbol);
|
|
3577
3835
|
}
|
|
3578
|
-
let { steps:
|
|
3579
|
-
|
|
3580
|
-
let
|
|
3581
|
-
|
|
3582
|
-
let f =
|
|
3583
|
-
|
|
3836
|
+
let n = this.replaySession, { steps: r, startTime: i, hideHistory: a, revealMarks: o, step: s, ...c } = e ?? {};
|
|
3837
|
+
c.animate = c.animate === !0;
|
|
3838
|
+
let l = this.series.inHoursShown(this.series.liveBars()), u = t > 0 && i === void 0 && a !== !1, d = c.startIndex;
|
|
3839
|
+
i !== void 0 && d === void 0 ? d = J(l, i) : u && d !== void 0 && (d += t);
|
|
3840
|
+
let f = u ? t : a && d !== void 0 && d > 0 ? Math.min(Math.floor(d), l.length - 1) : 0, p = f > 0 ? l.slice(f) : l;
|
|
3841
|
+
d !== void 0 && (c.startIndex = d - f), n.windowTime = f > 0 ? p[0]?.time ?? null : null, n.steps = r ?? null, n.stepsSymbol = this.currentSymbol, n.until = null, n.animate = c.animate, n.step = c.animate ? s ?? null : null, this.replayRevealMarks = o !== !1, this.useReplayLoader(n, !0);
|
|
3842
|
+
let m = r ? this.replayStepsOver(n, p, !0) : null;
|
|
3843
|
+
this.options.autoScale = !0, this.buildReplay(p, m, f);
|
|
3844
|
+
let h = this.replayStepsSeries;
|
|
3845
|
+
h && c.startIndex !== void 0 && (c.startIndex = li(h, p, c.startIndex));
|
|
3846
|
+
let g = h ?? p, _ = g[Math.max(0, Math.min(Math.floor(Number(c.startIndex ?? 0)) || 0, g.length - 1))];
|
|
3847
|
+
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);
|
|
3848
|
+
}
|
|
3849
|
+
buildReplay(e, t, n) {
|
|
3850
|
+
let r = this.replaySession?.animate === !0, i = r ? null : t;
|
|
3851
|
+
this.replayPieces = r && t ? fi(t, e) : null, this.replayForming = null, this.replayOffset = n, this.replayStepsSeries = i, this.replayCoarse = e;
|
|
3852
|
+
let a = this.replayRestarting;
|
|
3853
|
+
this.replayRestarting = !0;
|
|
3584
3854
|
try {
|
|
3585
|
-
this.replayManager.load(
|
|
3855
|
+
this.replayManager.load(i ?? e);
|
|
3586
3856
|
} finally {
|
|
3587
|
-
this.replayRestarting =
|
|
3857
|
+
this.replayRestarting = a;
|
|
3588
3858
|
}
|
|
3589
|
-
|
|
3590
|
-
let
|
|
3591
|
-
this.replayBarUnsub = this.replayManager.on("bar", ({ index:
|
|
3592
|
-
let
|
|
3593
|
-
if (f) {
|
|
3594
|
-
let r = f[e];
|
|
3595
|
-
t = Ir(d, r.time), h = h !== null && m === e - 1 && t === p - 1 && h ? zr(h, r) : Rr(d[t], f, e), n = h;
|
|
3596
|
-
}
|
|
3597
|
-
m = e;
|
|
3598
|
-
let r = t + 1, i = p > 0 && r >= p && this.series.length() === p, a = !(i && !this.replaySeeking) || this.autoScrollOnNewBar && this.viewport.isAtEnd();
|
|
3859
|
+
this.replayBarUnsub?.(), this.replayPhaseUnsub?.();
|
|
3860
|
+
let o = -1, s = -1, c = null, l = i ?? e;
|
|
3861
|
+
this.replayBarUnsub = this.replayManager.on("bar", ({ index: t }) => {
|
|
3862
|
+
let n = t, a = e[t];
|
|
3599
3863
|
if (i) {
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
let
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3864
|
+
let r = i[t];
|
|
3865
|
+
n = Z(e, r.time), c = c !== null && s === t - 1 && n === o - 1 && c ? mi(c, r) : ui(e[n], i, t), a = di(i, e, t, n) ? e[n] : c;
|
|
3866
|
+
}
|
|
3867
|
+
let u = this.replayForming;
|
|
3868
|
+
this.replayForming = null, s = t;
|
|
3869
|
+
let d = n + 1, f = o > 0 && d >= o && this.series.length() === o, p = f && !this.replaySeeking, m = !p || this.autoScrollOnNewBar && this.viewport.isAtEnd(), h = this.series.length();
|
|
3870
|
+
if (f) {
|
|
3871
|
+
d > o && this.series.updateReplayed(e[o - 1]);
|
|
3872
|
+
for (let t = o; t < d - 1; t++) this.series.appendReplayed(e[t]);
|
|
3873
|
+
d > o ? this.series.appendReplayed(a) : this.series.updateReplayed(a), this.recalcIndicatorsFrom(this.series.bars(), Math.max(0, o - 1));
|
|
3874
|
+
} else this.series.showReplayed([...e.slice(0, n), a]), this.recalcIndicators(this.series.bars());
|
|
3875
|
+
o = d, this.replayCause === "older" && (this.viewport.prependBars(d - h), m = !1), this.currentPriceLine.setPrice(a.close, n > 0 ? e[n - 1].close : void 0), this.crosshairHandler.setData(this.series.bars());
|
|
3876
|
+
let g = l[t + 1]?.time ?? l[t].time + (t > 0 ? l[t].time - l[t - 1].time : 1);
|
|
3877
|
+
this.replaySession && (this.replaySession.until = g), this.replayRevealMarks && this.revealReplayMarks(g), this.displayDataCache = null, this.reshapeMemo.clear(), this.updateViewportAndRender(m), r ? this.feedReplayForming(e, t, u?.index === t ? u.path : this.replayPathOf(e, t), 1) : this.feedReplaySteps(l, t);
|
|
3878
|
+
let _ = this.replayCause === null ? p ? "play" : "seek" : "series";
|
|
3879
|
+
this.eventBus.emit("replayStep", {
|
|
3880
|
+
barIndex: n,
|
|
3881
|
+
time: e[n].time,
|
|
3882
|
+
stepTime: l[t].time,
|
|
3883
|
+
until: g,
|
|
3884
|
+
total: e.length,
|
|
3885
|
+
cause: _
|
|
3611
3886
|
});
|
|
3887
|
+
}), r && (this.replayPhaseUnsub = this.replayManager.on("phase", ({ index: t, fraction: n }) => {
|
|
3888
|
+
if (!e[t] || this.series.length() !== o || o !== t && o !== t + 1) return;
|
|
3889
|
+
let r = this.replayForming?.index === t ? this.replayForming.path : this.replayPathOf(e, t), i = pi() ? wr(r, n) : n, a = o === t, s = a && this.autoScrollOnNewBar && this.viewport.isAtEnd(), c = Cr(r, i);
|
|
3890
|
+
a ? this.series.appendReplayed(c) : this.series.updateReplayed(c), o = t + 1, this.replayForming = {
|
|
3891
|
+
index: t,
|
|
3892
|
+
path: r
|
|
3893
|
+
}, this.drawFormingBar(c, t > 0 ? e[t - 1].close : void 0, a, s), this.feedReplayForming(e, t, r, i), this.loadReplaySteps(e, t);
|
|
3894
|
+
}));
|
|
3895
|
+
}
|
|
3896
|
+
drawFormingBar(e, t, n, r) {
|
|
3897
|
+
this.currentPriceLine.setPrice(e.close, t);
|
|
3898
|
+
let i = this.series.bars();
|
|
3899
|
+
if (this.recalcIndicatorsFrom(i, i.length - 1), (n || !Xr.has(this.options.chartType)) && (this.displayDataCache = null), !n) {
|
|
3900
|
+
this.scheduleRender();
|
|
3901
|
+
return;
|
|
3902
|
+
}
|
|
3903
|
+
this.crosshairHandler.setData(i), this.reshapeMemo.clear(), this.updateViewportAndRender(r);
|
|
3904
|
+
}
|
|
3905
|
+
replayPathOf(e, t) {
|
|
3906
|
+
let n = e[t];
|
|
3907
|
+
return vr(n, this.replayPieces?.get(n.time) ?? this.replayLoader?.loader.piecesOf(n.time) ?? []);
|
|
3908
|
+
}
|
|
3909
|
+
loadReplaySteps(e, t) {
|
|
3910
|
+
let n = this.replayLoader?.loader;
|
|
3911
|
+
if (!n) return;
|
|
3912
|
+
n.evictBefore(e[t].time);
|
|
3913
|
+
let r = this.replayManager.getStepMs();
|
|
3914
|
+
n.ensure(e, t, Number.isFinite(r) && r > 0 ? Math.ceil(Yr / r) : 1);
|
|
3915
|
+
}
|
|
3916
|
+
useReplayLoader(e, t) {
|
|
3917
|
+
let n = this.streamAdapter, r = this.streamTimeframe, i = e.step && n && r !== null ? Dr(e.step, r, (e) => A(n, e)) : null, a = `${this.currentSymbol}|${r}|${i}`;
|
|
3918
|
+
if (!t && this.replayLoader?.key === a || (this.replayLoader?.loader.dispose(), this.replayLoader = null, !i || !n || r === null)) return;
|
|
3919
|
+
let o = N(n), s = o.fetchHistoryBefore, c = this.currentSymbol, l = w(r), u = new dr({
|
|
3920
|
+
source: s ? (e, t) => s.call(o, c, i, e, t) : null,
|
|
3921
|
+
step: i,
|
|
3922
|
+
ratio: Math.max(1, Math.round(l / w(i))),
|
|
3923
|
+
barMs: l,
|
|
3924
|
+
keep: (e) => this.series.inHoursShown(e),
|
|
3925
|
+
report: (e) => this.eventBus.emit("replayStepsLoad", e)
|
|
3612
3926
|
});
|
|
3613
|
-
|
|
3614
|
-
|
|
3927
|
+
this.replayLoader = {
|
|
3928
|
+
key: a,
|
|
3929
|
+
loader: u
|
|
3930
|
+
};
|
|
3931
|
+
}
|
|
3932
|
+
feedReplayForming(e, t, n, r) {
|
|
3933
|
+
let i = this.replaySession, a = this.executionAdapter, o = e[t];
|
|
3934
|
+
if (!i || !a?.setMarkPrice || !o) return;
|
|
3935
|
+
let s = i.fedTime;
|
|
3936
|
+
if (s === null) {
|
|
3937
|
+
i.fedTime = o.time, i.fedFraction = r, this.feedReplayPrice(Cr(n, r).close, o.time);
|
|
3938
|
+
return;
|
|
3939
|
+
}
|
|
3940
|
+
if (o.time < s || o.time === s && r <= i.fedFraction) return;
|
|
3941
|
+
let c = [];
|
|
3942
|
+
if (o.time > s) {
|
|
3943
|
+
let a = J(e, s);
|
|
3944
|
+
e[a]?.time === s && i.fedFraction < 1 && c.push(...K(this.replayPathOf(e, a), i.fedFraction, 1));
|
|
3945
|
+
let o = e.slice(Y(e, s), t), l = Math.ceil(o.length / oi);
|
|
3946
|
+
for (let e = 0; e < o.length; e += l) c.push(...si(o.slice(e, e + l)));
|
|
3947
|
+
c.push(...K(n, -1, r));
|
|
3948
|
+
} else c.push(...K(n, i.fedFraction, r));
|
|
3949
|
+
i.fedTime = o.time, i.fedFraction = r;
|
|
3950
|
+
for (let [e, t] of c) a.setMarkPrice(e, t);
|
|
3951
|
+
let l = c[c.length - 1]?.[0];
|
|
3952
|
+
l !== void 0 && this.tradingManager.setCurrentPrice(l);
|
|
3953
|
+
}
|
|
3954
|
+
followLiveChange(e) {
|
|
3955
|
+
let t = this.replaySession;
|
|
3956
|
+
t && (e.kind === "bar" && !(t.until !== null && e.time < t.until) || this.rebaseReplay(e.kind));
|
|
3957
|
+
}
|
|
3958
|
+
rebaseReplay(e) {
|
|
3959
|
+
let t = this.replaySession;
|
|
3960
|
+
if (!t) return;
|
|
3961
|
+
let n = this.series.inHoursShown(this.series.liveBars());
|
|
3962
|
+
if (n.length === 0) return;
|
|
3963
|
+
let r = t.windowTime === null ? 0 : Math.min(J(n, t.windowTime), n.length - 1), i = r > 0 ? n.slice(r) : n;
|
|
3964
|
+
this.useReplayLoader(t, !1);
|
|
3965
|
+
let a = this.replayStepsOver(t, i), o = t.animate ? null : a, s = t.until === null ? 0 : ri(o ?? i, t.until);
|
|
3966
|
+
if (s < 0 && this.canPageBackForReplay(t)) {
|
|
3967
|
+
this.holdReplay(), t.held && t.held.pagesBack++, queueMicrotask(() => void this.pageBackForReplay(t));
|
|
3968
|
+
return;
|
|
3969
|
+
}
|
|
3970
|
+
let c = this.getReplayState(), l = t.held !== null && (e === "hours" || e === "bar"), u = t.held?.state ?? c;
|
|
3971
|
+
l || (t.held = null), t.symbol = this.currentSymbol;
|
|
3972
|
+
let d = this.replayManager.remainingMs();
|
|
3973
|
+
this.clearBarHolders(), t.animate && ni(t, this.replayCoarse, i);
|
|
3974
|
+
let f = this.replayRestarting;
|
|
3975
|
+
this.replayRestarting = !0, this.replayCause = e === "older" ? "older" : "series";
|
|
3976
|
+
try {
|
|
3977
|
+
this.buildReplay(i, a, r), this.restartReplayAt(Math.max(0, s), d, !l && u === "playing");
|
|
3978
|
+
} finally {
|
|
3979
|
+
this.replayRestarting = f, this.replayCause = null;
|
|
3980
|
+
}
|
|
3981
|
+
let p = this.getReplayState();
|
|
3982
|
+
p !== c && !f && this.eventBus.emit("replayState", { state: p }), this.emitBars(this.series.length());
|
|
3983
|
+
}
|
|
3984
|
+
restartReplayAt(e, t, n) {
|
|
3985
|
+
this.replayManager.play({
|
|
3986
|
+
paused: !0,
|
|
3987
|
+
startIndex: e,
|
|
3988
|
+
...t === null ? {} : { duration: t }
|
|
3989
|
+
}), n && this.replayManager.resume();
|
|
3990
|
+
}
|
|
3991
|
+
clearBarHolders() {
|
|
3992
|
+
this.pinnedTooltip.isPinned() && this.pinnedTooltip.unpin(), this.measureOverlay.end(), this.sessionBreaks.invalidateCache();
|
|
3993
|
+
}
|
|
3994
|
+
replayStepsOver(e, t, n = !1) {
|
|
3995
|
+
if (!e.steps || e.stepsSymbol !== this.currentSymbol) return null;
|
|
3996
|
+
let r = ci(this.series.inHoursShown(e.steps), t);
|
|
3997
|
+
return r && (n || ai(r, t)) ? r : null;
|
|
3998
|
+
}
|
|
3999
|
+
canPageBackForReplay(e) {
|
|
4000
|
+
return this.history.hasLoader() && this.history.hasMore() && (e.held?.pagesBack ?? 0) < Zr;
|
|
4001
|
+
}
|
|
4002
|
+
async pageBackForReplay(e) {
|
|
4003
|
+
this.replaySession !== e || !e.held || await this.history.loadMore() > 0 || this.replaySession !== e || !e.held || (e.held.pagesBack = Zr, this.rebaseReplay("older"));
|
|
4004
|
+
}
|
|
4005
|
+
holdReplay() {
|
|
4006
|
+
let e = this.replaySession;
|
|
4007
|
+
if (!e || e.held) return;
|
|
4008
|
+
let t = this.replayManager.getState() === "playing" ? "playing" : "paused", n = this.replayRestarting;
|
|
4009
|
+
this.replayRestarting = !0;
|
|
4010
|
+
try {
|
|
4011
|
+
this.replayManager.pause();
|
|
4012
|
+
} finally {
|
|
4013
|
+
this.replayRestarting = n;
|
|
4014
|
+
}
|
|
4015
|
+
e.held = {
|
|
4016
|
+
state: t,
|
|
4017
|
+
pagesBack: 0
|
|
4018
|
+
};
|
|
4019
|
+
}
|
|
4020
|
+
holdReplayFor(e) {
|
|
4021
|
+
this.replaySession && (this.replayEndsFor(e) ? this.replayStop() : this.holdReplay());
|
|
4022
|
+
}
|
|
4023
|
+
replayEndsFor(e) {
|
|
4024
|
+
let t = this.replaySession;
|
|
4025
|
+
return t !== null && this.replayTrades() && e !== t.symbol;
|
|
4026
|
+
}
|
|
4027
|
+
replayPages() {
|
|
4028
|
+
let e = this.replaySession;
|
|
4029
|
+
return e === null || e.windowTime === null && e.held === null;
|
|
3615
4030
|
}
|
|
3616
4031
|
revealReplayMarks(e) {
|
|
3617
4032
|
let t = e !== null && this.replayOffset > 0 ? this.replayCoarse?.[0]?.time ?? -Infinity : -Infinity;
|
|
3618
4033
|
this.signalMarkerManager.setRevealUntil(e, t), this.tradeZoneManager.setRevealUntil(e, t);
|
|
3619
4034
|
}
|
|
3620
4035
|
replaySeekToTime(e) {
|
|
3621
|
-
|
|
3622
|
-
let t = this.replayStepsSeries ?? this.replayCoarse, n = 0, r = t.length - 1;
|
|
3623
|
-
for (; n < r;) {
|
|
3624
|
-
let i = n + r + 1 >> 1;
|
|
3625
|
-
t[i].time < e ? n = i : r = i - 1;
|
|
3626
|
-
}
|
|
3627
|
-
this.replaySeek(n);
|
|
4036
|
+
!this.replaySession || !this.replayCoarse || this.replaySeek(Math.max(0, ri(this.replayStepsSeries ?? this.replayCoarse, e)));
|
|
3628
4037
|
}
|
|
3629
4038
|
feedReplayPrice(e, t) {
|
|
3630
4039
|
let n = this.executionAdapter;
|
|
@@ -3644,26 +4053,31 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
3644
4053
|
return;
|
|
3645
4054
|
}
|
|
3646
4055
|
if (i.time <= n.fedTime) return;
|
|
3647
|
-
let a = e.slice(
|
|
4056
|
+
let a = e.slice(Y(e, n.fedTime), t + 1);
|
|
3648
4057
|
n.fedTime = i.time;
|
|
3649
|
-
let o = Math.ceil(a.length /
|
|
3650
|
-
for (let e = 0; e < a.length; e += o) for (let [t, n] of
|
|
4058
|
+
let o = Math.ceil(a.length / oi);
|
|
4059
|
+
for (let e = 0; e < a.length; e += o) for (let [t, n] of si(a.slice(e, e + o))) r.setMarkPrice(t, n);
|
|
3651
4060
|
this.tradingManager.setCurrentPrice(i.close);
|
|
3652
4061
|
}
|
|
3653
4062
|
getReplayBarIndex() {
|
|
3654
4063
|
if (!this.replaySession) return -1;
|
|
4064
|
+
if (this.replayForming) return this.replayForming.index;
|
|
3655
4065
|
let { current: e } = this.replayManager.getProgress(), t = this.replayStepsSeries;
|
|
3656
|
-
return t && this.replayCoarse ?
|
|
4066
|
+
return t && this.replayCoarse ? Z(this.replayCoarse, t[e]?.time ?? -Infinity) : e;
|
|
3657
4067
|
}
|
|
3658
4068
|
replaySeekToBar(e) {
|
|
3659
4069
|
let t = this.replayStepsSeries;
|
|
3660
|
-
this.replaySeek(t && this.replayCoarse ?
|
|
4070
|
+
this.replaySeek(t && this.replayCoarse ? li(t, this.replayCoarse, e) : e);
|
|
3661
4071
|
}
|
|
3662
4072
|
replayPause() {
|
|
3663
|
-
this.replayManager.pause();
|
|
4073
|
+
this.setHeldState("paused") || this.replayManager.pause();
|
|
3664
4074
|
}
|
|
3665
4075
|
replayResume() {
|
|
3666
|
-
this.replayManager.resume();
|
|
4076
|
+
this.setHeldState("playing") || this.replayManager.resume();
|
|
4077
|
+
}
|
|
4078
|
+
setHeldState(e) {
|
|
4079
|
+
let t = this.replaySession?.held;
|
|
4080
|
+
return t ? (t.state !== e && (t.state = e, this.eventBus.emit("replayState", { state: e })), !0) : !1;
|
|
3667
4081
|
}
|
|
3668
4082
|
replayStop() {
|
|
3669
4083
|
let e = this.replaySession, t = this.endReplaySession();
|
|
@@ -3689,10 +4103,10 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
3689
4103
|
data: this.getDisplayData()
|
|
3690
4104
|
}, r = n.chartRect, i = Infinity, a = -Infinity, o = Infinity, s = -Infinity;
|
|
3691
4105
|
for (let e of t.anchors) {
|
|
3692
|
-
let t = Bt(e.time, n), r =
|
|
4106
|
+
let t = Bt(e.time, n), r = Ft(e.price, n);
|
|
3693
4107
|
i = Math.min(i, t), a = Math.max(a, t), o = Math.min(o, r), s = Math.max(s, r);
|
|
3694
4108
|
}
|
|
3695
|
-
return
|
|
4109
|
+
return Rr.has(t.type) ? [i, a] = [r.x, r.x + r.width] : t.type === "horizontalRay" && (a = r.x + r.width), zr.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 ? {
|
|
3696
4110
|
x: i,
|
|
3697
4111
|
y: o,
|
|
3698
4112
|
width: a - i,
|
|
@@ -3703,7 +4117,7 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
3703
4117
|
if (!this.replaySession) return null;
|
|
3704
4118
|
this.returnMarkToLive();
|
|
3705
4119
|
let e = this.series.endReplay();
|
|
3706
|
-
return this.replaySession = null, this.replayStepsSeries = null, this.replayCoarse = null, this.replayBarUnsub?.(), this.replayBarUnsub = null, this.replayManager.stop(), this.replayOffset = 0, this.revealReplayMarks(null), e;
|
|
4120
|
+
return this.replaySession = null, this.replayStepsSeries = null, this.replayCoarse = null, this.replayBarUnsub?.(), this.replayBarUnsub = null, this.replayPhaseUnsub?.(), this.replayPhaseUnsub = null, this.replayLoader?.loader.dispose(), this.replayLoader = null, this.replayPieces = null, this.replayForming = null, this.replayManager.stop(), this.replayOffset = 0, this.revealReplayMarks(null), e;
|
|
3707
4121
|
}
|
|
3708
4122
|
replaySeek(e) {
|
|
3709
4123
|
this.replaySeeking = !0;
|
|
@@ -3717,10 +4131,15 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
3717
4131
|
this.replayManager.setSpeed(e);
|
|
3718
4132
|
}
|
|
3719
4133
|
getReplayState() {
|
|
3720
|
-
return this.replayManager.getState();
|
|
4134
|
+
return this.replaySession?.held?.state ?? this.replayManager.getState();
|
|
3721
4135
|
}
|
|
3722
4136
|
getReplayProgress() {
|
|
3723
|
-
|
|
4137
|
+
let e = this.replaySession, t = e ? this.replayCoarse?.[this.getReplayBarIndex()] : void 0;
|
|
4138
|
+
return {
|
|
4139
|
+
...this.replayManager.getProgress(),
|
|
4140
|
+
time: e?.until != null && t ? t.time : null,
|
|
4141
|
+
until: e?.until ?? null
|
|
4142
|
+
};
|
|
3724
4143
|
}
|
|
3725
4144
|
captureSnapshot() {
|
|
3726
4145
|
return T.capture({
|
|
@@ -3736,14 +4155,14 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
3736
4155
|
});
|
|
3737
4156
|
}
|
|
3738
4157
|
restoreIndicators(e, t) {
|
|
3739
|
-
let n =
|
|
4158
|
+
let n = Vr(e), r = /* @__PURE__ */ new Map();
|
|
3740
4159
|
this.unrestoredIndicators = [];
|
|
3741
4160
|
let i = new Set(this.indicatorEngine.getAvailableIndicators().map((e) => e.id)), a = [], o = /* @__PURE__ */ new Set();
|
|
3742
4161
|
if (t) {
|
|
3743
4162
|
let e = new Map(n.map((e) => [e.instanceId, e])), t = this.getIndicatorSetup();
|
|
3744
4163
|
for (let n of t) {
|
|
3745
4164
|
let t = e.get(n.instanceId);
|
|
3746
|
-
t &&
|
|
4165
|
+
t && Hr(n, t) && o.add(n.instanceId);
|
|
3747
4166
|
}
|
|
3748
4167
|
for (let e of t) o.has(e.instanceId) || this.removeIndicator(e.instanceId);
|
|
3749
4168
|
for (let e of [...o]) this.indicatorEngine.getIndicatorConfig(e) || o.delete(e);
|
|
@@ -3805,7 +4224,7 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
3805
4224
|
let s = t.levels ?? null;
|
|
3806
4225
|
JSON.stringify(s) !== JSON.stringify(o?.levels ?? null) && this.setIndicatorLevels(e, s);
|
|
3807
4226
|
let c = t.intervals ?? null;
|
|
3808
|
-
JSON.stringify(c) !== JSON.stringify(o?.intervals ?? null) && this.setIndicatorIntervalsNow(e, c), this.setPaneStyleNow(e, t.paneStyle ?
|
|
4227
|
+
JSON.stringify(c) !== JSON.stringify(o?.intervals ?? null) && this.setIndicatorIntervalsNow(e, c), this.setPaneStyleNow(e, t.paneStyle ? oe(t.paneStyle) : null);
|
|
3809
4228
|
}
|
|
3810
4229
|
restorePanes(e) {
|
|
3811
4230
|
for (let [t, n] of e) t.paneSize !== void 0 && this.layoutManager.setPanelSize(n, t.paneSize), (t.paneSize !== void 0 || t.paneCollapsed) && this.layoutManager.setPanelCollapsed(n, !!t.paneCollapsed), t.paneSize !== void 0 && this.layoutManager.setPanelScale(n, {
|
|
@@ -3910,7 +4329,7 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
3910
4329
|
if (this.indicatorHistoryDepth > 0 || !this.features.drawingUndoRedo) return t();
|
|
3911
4330
|
let n = this.getIndicatorSetup(), r = this.withoutIndicatorHistory(t), i = this.getIndicatorSetup();
|
|
3912
4331
|
if (JSON.stringify(n) === JSON.stringify(i)) return r;
|
|
3913
|
-
let a = performance.now(), o = this.undoRedoManager.last(), s = e !== void 0 && o?.type === "indicators" && o.indicators?.subject === e && a - (o.indicators.at ?? 0) <
|
|
4332
|
+
let a = performance.now(), o = this.undoRedoManager.last(), s = e !== void 0 && o?.type === "indicators" && o.indicators?.subject === e && a - (o.indicators.at ?? 0) < Fr && JSON.stringify(o.indicators.after) === JSON.stringify(n), c = {
|
|
3914
4333
|
type: "indicators",
|
|
3915
4334
|
before: null,
|
|
3916
4335
|
after: null
|
|
@@ -3954,7 +4373,7 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
3954
4373
|
let t = e.indexOf(":"), r = t > 0 ? n.get(e.slice(0, t)) : void 0;
|
|
3955
4374
|
return r ? r + e.slice(t) : e;
|
|
3956
4375
|
}, r = t(e.channel), i = {
|
|
3957
|
-
...
|
|
4376
|
+
...Lt(e),
|
|
3958
4377
|
...e.target ? { target: t(e.target) } : {}
|
|
3959
4378
|
};
|
|
3960
4379
|
if (!e.expired) {
|
|
@@ -3986,7 +4405,7 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
3986
4405
|
this.loadState(T.serialize(e));
|
|
3987
4406
|
}
|
|
3988
4407
|
setLocale(e) {
|
|
3989
|
-
|
|
4408
|
+
ce(e), this.engine.requestRender();
|
|
3990
4409
|
}
|
|
3991
4410
|
setNumberLocale(e) {
|
|
3992
4411
|
this.numberLocale = e, this.viewport.setNumberLocale(e), this.priceAxis.setLocale(e), this.leftPriceAxis.setLocale(e), this.crosshairHandler.setLocale(e), this.timeAxis.setLocale(e), this.chartLegend.setLocale(e), this.crosshairTooltip.setLocale(e), this.pinnedTooltip.setLocale(e), this.currentPriceLine.setLocale(e), this.updateViewportAndRender();
|
|
@@ -4046,7 +4465,7 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
4046
4465
|
}
|
|
4047
4466
|
createChartRenderer(e) {
|
|
4048
4467
|
let t = Cn(e, (e) => this.pluginManager.getChartType(e));
|
|
4049
|
-
return t instanceof
|
|
4468
|
+
return t instanceof Le && t.setPriceText((e) => this.formatPrice(e)), t;
|
|
4050
4469
|
}
|
|
4051
4470
|
crosshairSeries() {
|
|
4052
4471
|
return this.isTimeAligned() ? this.series.bars() : this.getDisplayData();
|
|
@@ -4062,7 +4481,7 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
4062
4481
|
let n = this.options.chartType, r = (e) => this.pluginManager.getChartType(e);
|
|
4063
4482
|
if (n !== "pointAndFigure" || r(n)) return wn(n, e, r, this.chartTypeOptions, t, this.reshapeMemo);
|
|
4064
4483
|
let { columns: i, boxSize: a } = un(e, this.chartTypeOptions, this.reshapeMemo);
|
|
4065
|
-
return this.chartRenderer instanceof
|
|
4484
|
+
return this.chartRenderer instanceof Qe && this.chartRenderer.setBoxSize(a), i;
|
|
4066
4485
|
}
|
|
4067
4486
|
recalcIndicatorsFrom(e, t) {
|
|
4068
4487
|
this.indicatorEngine.recalculateFrom(e, t), this.announceIndicatorUpdate(t);
|
|
@@ -4115,12 +4534,12 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
4115
4534
|
}
|
|
4116
4535
|
fitPriceScale(e, t) {
|
|
4117
4536
|
if (e.length === 0) return;
|
|
4118
|
-
let n = Math.max(0, t.visibleRange.from), r = Math.min(t.visibleRange.to, e.length - 1), i =
|
|
4537
|
+
let n = Math.max(0, t.visibleRange.from), r = Math.min(t.visibleRange.to, e.length - 1), i = Jr(Jr(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() && qr(e, n, r) ? this.volumeRenderer.getHeightRatio() + Pr : D;
|
|
4119
4538
|
this.viewport.setScaleMargins(this.viewport.isInvertScale() ? {
|
|
4120
4539
|
top: a,
|
|
4121
|
-
bottom:
|
|
4540
|
+
bottom: D
|
|
4122
4541
|
} : {
|
|
4123
|
-
top:
|
|
4542
|
+
top: D,
|
|
4124
4543
|
bottom: a
|
|
4125
4544
|
}), this.viewport.fitToPrices(i.min, i.max);
|
|
4126
4545
|
}
|
|
@@ -4142,7 +4561,7 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
4142
4561
|
fitLeftAxisWidth() {
|
|
4143
4562
|
let e = this.leftViewport;
|
|
4144
4563
|
if (!e) return !1;
|
|
4145
|
-
let t = this.themeManager.getTheme(), n =
|
|
4564
|
+
let t = this.themeManager.getTheme(), n = Yn({
|
|
4146
4565
|
min: e.priceRange.min,
|
|
4147
4566
|
max: e.priceRange.max,
|
|
4148
4567
|
lastPrice: null,
|
|
@@ -4151,12 +4570,12 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
4151
4570
|
fontFamily: t.font.family,
|
|
4152
4571
|
fontSizeSmall: t.font.sizeSmall,
|
|
4153
4572
|
measure: (e, t) => this.measureText(e, t)
|
|
4154
|
-
}), r =
|
|
4573
|
+
}), r = Xn(this.leftAxisWidth, n);
|
|
4155
4574
|
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);
|
|
4156
4575
|
}
|
|
4157
4576
|
fitPriceAxisWidth() {
|
|
4158
4577
|
if (!this.features.priceAxis) return !1;
|
|
4159
|
-
let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n =
|
|
4578
|
+
let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n = Yn({
|
|
4160
4579
|
min: e.min,
|
|
4161
4580
|
max: e.max,
|
|
4162
4581
|
lastPrice: this.currentPriceLine.getPrice(),
|
|
@@ -4167,14 +4586,14 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
4167
4586
|
fontFamily: t.font.family,
|
|
4168
4587
|
fontSizeSmall: t.font.sizeSmall,
|
|
4169
4588
|
measure: (e, t) => this.measureText(e, t)
|
|
4170
|
-
}), r =
|
|
4589
|
+
}), r = Xn(this.priceAxisWidth, n);
|
|
4171
4590
|
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);
|
|
4172
4591
|
}
|
|
4173
4592
|
measureText(e, t) {
|
|
4174
4593
|
let n = this.engine.layerManager.getLayer(r.Main)?.ctx;
|
|
4175
|
-
if (n?.canvas.isConnected) return this.labelWidths.get(e, t, () =>
|
|
4594
|
+
if (n?.canvas.isConnected) return this.labelWidths.get(e, t, () => Ur(n, e, t));
|
|
4176
4595
|
let i = n ?? this.detachedMeasureContext();
|
|
4177
|
-
return i ?
|
|
4596
|
+
return i ? Ur(i, e, t) : e.length * 7;
|
|
4178
4597
|
}
|
|
4179
4598
|
detachedMeasureContext() {
|
|
4180
4599
|
return this.measureCtx === void 0 && (this.measureCtx = typeof document < "u" ? document.createElement("canvas").getContext("2d") : null), this.measureCtx;
|
|
@@ -4215,7 +4634,7 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
4215
4634
|
buildPanelRenderInfos() {
|
|
4216
4635
|
if (this.panelInfoCache) return this.panelInfoCache;
|
|
4217
4636
|
let e = this.getResolvedLayout(), t = this.viewport.getState(), { from: n, to: r } = t.visibleRange, i = e.panels.map((e) => {
|
|
4218
|
-
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) ?? { ...
|
|
4637
|
+
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) ?? { ...Or }, o = {
|
|
4219
4638
|
x: e.rect.x,
|
|
4220
4639
|
y: e.rect.y + 20,
|
|
4221
4640
|
width: e.rect.width,
|
|
@@ -4299,7 +4718,7 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
4299
4718
|
});
|
|
4300
4719
|
}
|
|
4301
4720
|
drawOverlayPlugins(e, t) {
|
|
4302
|
-
let n =
|
|
4721
|
+
let n = tr(this.pluginManager.getOverlays(), t);
|
|
4303
4722
|
if (n.length === 0) return;
|
|
4304
4723
|
let r = {
|
|
4305
4724
|
viewport: this.viewport.getState(),
|
|
@@ -4320,7 +4739,7 @@ var mr = .08, hr = a ** -7, gr = 800, _r = 20, vr = 8, yr = new Set(["horizontal
|
|
|
4320
4739
|
};
|
|
4321
4740
|
}
|
|
4322
4741
|
};
|
|
4323
|
-
function
|
|
4742
|
+
function Vr(e) {
|
|
4324
4743
|
let t = new Map(e.map((e) => [e.instanceId, e])), n = [], r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = (e) => {
|
|
4325
4744
|
if (r.has(e.instanceId) || i.has(e.instanceId)) return;
|
|
4326
4745
|
i.add(e.instanceId);
|
|
@@ -4334,19 +4753,19 @@ function Sr(e) {
|
|
|
4334
4753
|
for (let t of e) a(t);
|
|
4335
4754
|
return n;
|
|
4336
4755
|
}
|
|
4337
|
-
function
|
|
4756
|
+
function Hr(e, t) {
|
|
4338
4757
|
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);
|
|
4339
4758
|
}
|
|
4340
|
-
function
|
|
4759
|
+
function Ur(e, t, n) {
|
|
4341
4760
|
let r = e.font;
|
|
4342
4761
|
e.font = n;
|
|
4343
4762
|
let i = e.measureText(t).width;
|
|
4344
4763
|
return e.font = r, i;
|
|
4345
4764
|
}
|
|
4346
|
-
var
|
|
4347
|
-
function
|
|
4765
|
+
var Wr = 300;
|
|
4766
|
+
function Gr(e) {
|
|
4348
4767
|
let t = {}, n = e.family;
|
|
4349
|
-
typeof n == "string" && n.trim() !== "" && n.length <=
|
|
4768
|
+
typeof n == "string" && n.trim() !== "" && n.length <= Wr && !/[;{}<>\\]|\/\*/.test(n) && (t.family = n);
|
|
4350
4769
|
for (let n of [
|
|
4351
4770
|
"sizeSmall",
|
|
4352
4771
|
"sizeMedium",
|
|
@@ -4357,21 +4776,21 @@ function Er(e) {
|
|
|
4357
4776
|
}
|
|
4358
4777
|
return t;
|
|
4359
4778
|
}
|
|
4360
|
-
function
|
|
4779
|
+
function Kr(e) {
|
|
4361
4780
|
let t = e.tagRadius;
|
|
4362
4781
|
return typeof t == "number" && Number.isFinite(t) && t >= 0 ? { tagRadius: Math.min(t, 999) } : {};
|
|
4363
4782
|
}
|
|
4364
|
-
function
|
|
4783
|
+
function qr(e, t, n) {
|
|
4365
4784
|
for (let r = t; r <= n; r++) if (e[r].volume > 0) return !0;
|
|
4366
4785
|
return !1;
|
|
4367
4786
|
}
|
|
4368
|
-
function
|
|
4787
|
+
function Jr(e, t) {
|
|
4369
4788
|
return e ? t ? {
|
|
4370
4789
|
min: Math.min(e.min, t.min),
|
|
4371
4790
|
max: Math.max(e.max, t.max)
|
|
4372
4791
|
} : e : t;
|
|
4373
4792
|
}
|
|
4374
|
-
function
|
|
4793
|
+
function q(e) {
|
|
4375
4794
|
return {
|
|
4376
4795
|
id: e.id,
|
|
4377
4796
|
price: e.price,
|
|
@@ -4386,8 +4805,64 @@ function K(e) {
|
|
|
4386
4805
|
bars: e.bars
|
|
4387
4806
|
};
|
|
4388
4807
|
}
|
|
4389
|
-
var
|
|
4390
|
-
|
|
4808
|
+
var Yr = 8e3, Xr = new Set([
|
|
4809
|
+
"candlestick",
|
|
4810
|
+
"line",
|
|
4811
|
+
"area",
|
|
4812
|
+
"bar",
|
|
4813
|
+
"hollowCandle"
|
|
4814
|
+
]), Zr = 10, Qr = 50, $r = .001;
|
|
4815
|
+
function ei(e) {
|
|
4816
|
+
return {
|
|
4817
|
+
price: null,
|
|
4818
|
+
fedTime: null,
|
|
4819
|
+
fedFraction: 1,
|
|
4820
|
+
animate: !1,
|
|
4821
|
+
step: null,
|
|
4822
|
+
until: null,
|
|
4823
|
+
windowTime: null,
|
|
4824
|
+
steps: null,
|
|
4825
|
+
stepsSymbol: e,
|
|
4826
|
+
symbol: e,
|
|
4827
|
+
held: null
|
|
4828
|
+
};
|
|
4829
|
+
}
|
|
4830
|
+
function ti(e, t) {
|
|
4831
|
+
let n = e[t + 1];
|
|
4832
|
+
return n ? n.time - e[t].time : X(e);
|
|
4833
|
+
}
|
|
4834
|
+
function ni(e, t, n) {
|
|
4835
|
+
let r = e.fedTime;
|
|
4836
|
+
if (r === null || !t || t.length === 0 || n.length === 0) return;
|
|
4837
|
+
let i = ti(t, Z(t, r)), a = r + (Number.isFinite(i) ? e.fedFraction * i : 0), o = Z(n, a), s = n[o].time;
|
|
4838
|
+
if (s > a) return;
|
|
4839
|
+
let c = ti(n, o);
|
|
4840
|
+
if (a === s && o > 0) {
|
|
4841
|
+
e.fedTime = n[o - 1].time, e.fedFraction = 1;
|
|
4842
|
+
return;
|
|
4843
|
+
}
|
|
4844
|
+
e.fedTime = s, e.fedFraction = Number.isFinite(c) && c > 0 ? Math.min(1, (a - s) / c) : 0;
|
|
4845
|
+
}
|
|
4846
|
+
function ri(e, t) {
|
|
4847
|
+
let n = Y(e, t), r = e.length - 1;
|
|
4848
|
+
return n > r && r >= 0 && e[r].time + X(e) <= t ? r : Math.max(-1, n - 2);
|
|
4849
|
+
}
|
|
4850
|
+
function ii(e) {
|
|
4851
|
+
let t = Infinity;
|
|
4852
|
+
for (let n = Math.max(1, e.length - 10); n < e.length; n++) t = Math.min(t, e[n].time - e[n - 1].time);
|
|
4853
|
+
return t;
|
|
4854
|
+
}
|
|
4855
|
+
function ai(e, t) {
|
|
4856
|
+
if (!(ii(e) < ii(t))) return !1;
|
|
4857
|
+
let n = Math.max(0, e.length - Qr);
|
|
4858
|
+
for (let r = n; r < e.length; r++) {
|
|
4859
|
+
let n = t[Z(t, e[r].time)], i = (n.high - n.low) * $r + 2 ** -52;
|
|
4860
|
+
if (e[r].close > n.high + i || e[r].close < n.low - i) return !1;
|
|
4861
|
+
}
|
|
4862
|
+
return !0;
|
|
4863
|
+
}
|
|
4864
|
+
var oi = 500;
|
|
4865
|
+
function J(e, t) {
|
|
4391
4866
|
let n = 0, r = e.length;
|
|
4392
4867
|
for (; n < r;) {
|
|
4393
4868
|
let i = n + r >> 1;
|
|
@@ -4395,7 +4870,7 @@ function jr(e, t) {
|
|
|
4395
4870
|
}
|
|
4396
4871
|
return n;
|
|
4397
4872
|
}
|
|
4398
|
-
function
|
|
4873
|
+
function Y(e, t) {
|
|
4399
4874
|
let n = 0, r = e.length;
|
|
4400
4875
|
for (; n < r;) {
|
|
4401
4876
|
let i = n + r >> 1;
|
|
@@ -4403,20 +4878,20 @@ function Mr(e, t) {
|
|
|
4403
4878
|
}
|
|
4404
4879
|
return n;
|
|
4405
4880
|
}
|
|
4406
|
-
function
|
|
4881
|
+
function si(e) {
|
|
4407
4882
|
let t = 0, n = 0;
|
|
4408
4883
|
for (let r = 1; r < e.length; r++) e[r].low < e[t].low && (t = r), e[r].high > e[n].high && (n = r);
|
|
4409
4884
|
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];
|
|
4410
4885
|
return [...a ? [r, i] : [i, r], [o.close, o.time]];
|
|
4411
4886
|
}
|
|
4412
|
-
function
|
|
4887
|
+
function X(e) {
|
|
4413
4888
|
let t = 0;
|
|
4414
4889
|
for (let n = Math.max(1, e.length - 10); n < e.length; n++) t = Math.max(t, e[n].time - e[n - 1].time);
|
|
4415
4890
|
return t > 0 ? t : Infinity;
|
|
4416
4891
|
}
|
|
4417
|
-
function
|
|
4892
|
+
function ci(e, t) {
|
|
4418
4893
|
if (t.length === 0) return null;
|
|
4419
|
-
let n = t[t.length - 1].time +
|
|
4894
|
+
let n = t[t.length - 1].time + X(t), r = e.filter((e) => jn(e) && e.time >= t[0].time && e.time < n).sort((e, t) => e.time - t.time), i = [];
|
|
4420
4895
|
for (let e of r) (i.length === 0 || i[i.length - 1].time !== e.time) && i.push(e);
|
|
4421
4896
|
if (i.length === 0) return null;
|
|
4422
4897
|
let a = t.findIndex((e) => e.time >= i[0].time);
|
|
@@ -4424,7 +4899,7 @@ function Fr(e, t) {
|
|
|
4424
4899
|
let o = t.slice(0, a), s = i.filter((e) => e.time >= t[a].time);
|
|
4425
4900
|
return [...o, ...s];
|
|
4426
4901
|
}
|
|
4427
|
-
function
|
|
4902
|
+
function Z(e, t) {
|
|
4428
4903
|
let n = 0, r = e.length - 1;
|
|
4429
4904
|
for (; n < r;) {
|
|
4430
4905
|
let i = n + r + 1 >> 1;
|
|
@@ -4432,22 +4907,37 @@ function Ir(e, t) {
|
|
|
4432
4907
|
}
|
|
4433
4908
|
return n;
|
|
4434
4909
|
}
|
|
4435
|
-
function
|
|
4910
|
+
function li(e, t, n) {
|
|
4436
4911
|
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;
|
|
4437
4912
|
for (let t = 0; t < e.length && e[t].time < i; t++) a = t;
|
|
4438
4913
|
return Math.max(0, a);
|
|
4439
4914
|
}
|
|
4440
|
-
function
|
|
4915
|
+
function ui(e, t, n) {
|
|
4441
4916
|
let r = n;
|
|
4442
4917
|
for (; r > 0 && t[r - 1].time >= e.time;) r--;
|
|
4443
4918
|
let i = {
|
|
4444
4919
|
...t[r],
|
|
4445
4920
|
time: e.time
|
|
4446
4921
|
};
|
|
4447
|
-
for (let e = r + 1; e <= n; e++) i =
|
|
4922
|
+
for (let e = r + 1; e <= n; e++) i = mi(i, t[e]);
|
|
4448
4923
|
return i;
|
|
4449
4924
|
}
|
|
4450
|
-
function
|
|
4925
|
+
function di(e, t, n, r) {
|
|
4926
|
+
let i = e[n + 1], a = t[r + 1];
|
|
4927
|
+
return i !== void 0 && a !== void 0 && i.time >= a.time;
|
|
4928
|
+
}
|
|
4929
|
+
function fi(e, t) {
|
|
4930
|
+
let n = /* @__PURE__ */ new Map();
|
|
4931
|
+
for (let r of e) {
|
|
4932
|
+
let e = t[Z(t, r.time)].time, i = n.get(e);
|
|
4933
|
+
i ? i.push(r) : n.set(e, [r]);
|
|
4934
|
+
}
|
|
4935
|
+
return n;
|
|
4936
|
+
}
|
|
4937
|
+
function pi() {
|
|
4938
|
+
return typeof matchMedia == "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
4939
|
+
}
|
|
4940
|
+
function mi(e, t) {
|
|
4451
4941
|
return {
|
|
4452
4942
|
time: e.time,
|
|
4453
4943
|
open: e.open,
|
|
@@ -4459,26 +4949,26 @@ function zr(e, t) {
|
|
|
4459
4949
|
}
|
|
4460
4950
|
//#endregion
|
|
4461
4951
|
//#region src/io/parseOHLCV.ts
|
|
4462
|
-
var
|
|
4952
|
+
var hi = [
|
|
4463
4953
|
"time",
|
|
4464
4954
|
"timestamp",
|
|
4465
4955
|
"date",
|
|
4466
4956
|
"datetime",
|
|
4467
4957
|
"t"
|
|
4468
|
-
],
|
|
4958
|
+
], gi = ["open", "o"], _i = ["high", "h"], vi = ["low", "l"], yi = ["close", "c"], bi = [
|
|
4469
4959
|
"volume",
|
|
4470
4960
|
"vol",
|
|
4471
4961
|
"v"
|
|
4472
4962
|
];
|
|
4473
|
-
function
|
|
4963
|
+
function xi(e) {
|
|
4474
4964
|
let t = e.trim();
|
|
4475
|
-
return t ? t[0] === "[" || t[0] === "{" ?
|
|
4965
|
+
return t ? t[0] === "[" || t[0] === "{" ? Si(t) : Ci(t) : {
|
|
4476
4966
|
data: [],
|
|
4477
4967
|
rowCount: 0,
|
|
4478
4968
|
skipped: 0
|
|
4479
4969
|
};
|
|
4480
4970
|
}
|
|
4481
|
-
function
|
|
4971
|
+
function Si(e) {
|
|
4482
4972
|
let t;
|
|
4483
4973
|
try {
|
|
4484
4974
|
t = JSON.parse(e);
|
|
@@ -4488,19 +4978,19 @@ function Kr(e) {
|
|
|
4488
4978
|
if (!Array.isArray(t)) throw Error("Expected a JSON array of OHLCV rows");
|
|
4489
4979
|
let n = [], r = 0;
|
|
4490
4980
|
for (let e of t) {
|
|
4491
|
-
let t = Array.isArray(e) ?
|
|
4981
|
+
let t = Array.isArray(e) ? Oi(e) : Di(e);
|
|
4492
4982
|
t ? n.push(t) : r++;
|
|
4493
4983
|
}
|
|
4494
|
-
return
|
|
4984
|
+
return Ai(n, t.length, r);
|
|
4495
4985
|
}
|
|
4496
|
-
function
|
|
4986
|
+
function Ci(e) {
|
|
4497
4987
|
let t = e.split(/\r?\n/).filter((e) => e.trim().length > 0);
|
|
4498
4988
|
if (t.length === 0) return {
|
|
4499
4989
|
data: [],
|
|
4500
4990
|
rowCount: 0,
|
|
4501
4991
|
skipped: 0
|
|
4502
4992
|
};
|
|
4503
|
-
let n =
|
|
4993
|
+
let n = wi(t[0]), r = Ti(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? Ei(r) : {
|
|
4504
4994
|
time: 0,
|
|
4505
4995
|
open: 1,
|
|
4506
4996
|
high: 2,
|
|
@@ -4511,7 +5001,7 @@ function qr(e) {
|
|
|
4511
5001
|
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");
|
|
4512
5002
|
let o = [], s = 0;
|
|
4513
5003
|
for (let e = +!!i; e < t.length; e++) {
|
|
4514
|
-
let r =
|
|
5004
|
+
let r = Ti(t[e], n), i = ki(r[a.time]), c = Q(r[a.open]), l = Q(r[a.high]), u = Q(r[a.low]), d = Q(r[a.close]), f = a.volume >= 0 ? Number(r[a.volume]) : 0;
|
|
4515
5005
|
if (i === null || ![
|
|
4516
5006
|
c,
|
|
4517
5007
|
l,
|
|
@@ -4530,9 +5020,9 @@ function qr(e) {
|
|
|
4530
5020
|
volume: Number.isFinite(f) ? f : 0
|
|
4531
5021
|
});
|
|
4532
5022
|
}
|
|
4533
|
-
return
|
|
5023
|
+
return Ai(o, t.length - +!!i, s);
|
|
4534
5024
|
}
|
|
4535
|
-
function
|
|
5025
|
+
function wi(e) {
|
|
4536
5026
|
let t = {
|
|
4537
5027
|
",": 0,
|
|
4538
5028
|
";": 0,
|
|
@@ -4544,7 +5034,7 @@ function Jr(e) {
|
|
|
4544
5034
|
for (let [e, i] of Object.entries(t)) i > r && (n = e, r = i);
|
|
4545
5035
|
return n;
|
|
4546
5036
|
}
|
|
4547
|
-
function
|
|
5037
|
+
function Ti(e, t) {
|
|
4548
5038
|
let n = [], r = "", i = !1;
|
|
4549
5039
|
for (let a = 0; a < e.length; a++) {
|
|
4550
5040
|
let o = e[a];
|
|
@@ -4552,25 +5042,25 @@ function Yr(e, t) {
|
|
|
4552
5042
|
}
|
|
4553
5043
|
return n.push(r), n;
|
|
4554
5044
|
}
|
|
4555
|
-
function
|
|
5045
|
+
function Ei(e) {
|
|
4556
5046
|
let t = (t) => e.findIndex((e) => t.includes(e));
|
|
4557
5047
|
return {
|
|
4558
|
-
time: t(
|
|
4559
|
-
open: t(
|
|
4560
|
-
high: t(
|
|
4561
|
-
low: t(
|
|
4562
|
-
close: t(
|
|
4563
|
-
volume: t(
|
|
5048
|
+
time: t(hi),
|
|
5049
|
+
open: t(gi),
|
|
5050
|
+
high: t(_i),
|
|
5051
|
+
low: t(vi),
|
|
5052
|
+
close: t(yi),
|
|
5053
|
+
volume: t(bi)
|
|
4564
5054
|
};
|
|
4565
5055
|
}
|
|
4566
|
-
function
|
|
5056
|
+
function Di(e) {
|
|
4567
5057
|
let t = (t) => {
|
|
4568
5058
|
for (let n of t) {
|
|
4569
5059
|
if (e[n] !== void 0) return e[n];
|
|
4570
5060
|
let t = n.toUpperCase();
|
|
4571
5061
|
if (e[t] !== void 0) return e[t];
|
|
4572
5062
|
}
|
|
4573
|
-
}, n =
|
|
5063
|
+
}, n = ki(String(t(hi) ?? "")), r = Number(t(gi)), i = Number(t(_i)), a = Number(t(vi)), o = Number(t(yi)), s = Number(t(bi) ?? 0);
|
|
4574
5064
|
return n === null || ![
|
|
4575
5065
|
r,
|
|
4576
5066
|
i,
|
|
@@ -4585,9 +5075,9 @@ function Zr(e) {
|
|
|
4585
5075
|
volume: Number.isFinite(s) ? s : 0
|
|
4586
5076
|
};
|
|
4587
5077
|
}
|
|
4588
|
-
function
|
|
5078
|
+
function Oi(e) {
|
|
4589
5079
|
if (e.length < 5) return null;
|
|
4590
|
-
let t =
|
|
5080
|
+
let t = ki(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;
|
|
4591
5081
|
return t === null || ![
|
|
4592
5082
|
n,
|
|
4593
5083
|
r,
|
|
@@ -4602,10 +5092,10 @@ function Qr(e) {
|
|
|
4602
5092
|
volume: Number.isFinite(o) ? o : 0
|
|
4603
5093
|
};
|
|
4604
5094
|
}
|
|
4605
|
-
function
|
|
5095
|
+
function Q(e) {
|
|
4606
5096
|
return e === void 0 || e.trim() === "" ? NaN : Number(e);
|
|
4607
5097
|
}
|
|
4608
|
-
function
|
|
5098
|
+
function ki(e) {
|
|
4609
5099
|
let t = e.trim();
|
|
4610
5100
|
if (!t) return null;
|
|
4611
5101
|
let n = Number(t);
|
|
@@ -4613,7 +5103,7 @@ function Y(e) {
|
|
|
4613
5103
|
let r = Date.parse(t);
|
|
4614
5104
|
return Number.isFinite(r) ? r : null;
|
|
4615
5105
|
}
|
|
4616
|
-
function
|
|
5106
|
+
function Ai(e, t, n) {
|
|
4617
5107
|
e.sort((e, t) => e.time - t.time);
|
|
4618
5108
|
let r = [];
|
|
4619
5109
|
for (let t of e) r.length > 0 && r[r.length - 1].time === t.time ? r[r.length - 1] = t : r.push(t);
|
|
@@ -4625,7 +5115,7 @@ function $r(e, t, n) {
|
|
|
4625
5115
|
}
|
|
4626
5116
|
//#endregion
|
|
4627
5117
|
//#region src/io/DragDropImporter.ts
|
|
4628
|
-
var
|
|
5118
|
+
var ji = class {
|
|
4629
5119
|
host;
|
|
4630
5120
|
overlay = null;
|
|
4631
5121
|
callbacks;
|
|
@@ -4646,19 +5136,19 @@ var ei = class {
|
|
|
4646
5136
|
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();
|
|
4647
5137
|
}
|
|
4648
5138
|
onDragEnter(e) {
|
|
4649
|
-
|
|
5139
|
+
Mi(e) && (e.preventDefault(), this.depth++, this.showOverlay());
|
|
4650
5140
|
}
|
|
4651
5141
|
onDragOver(e) {
|
|
4652
|
-
|
|
5142
|
+
Mi(e) && (e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = "copy"));
|
|
4653
5143
|
}
|
|
4654
5144
|
onDragLeave(e) {
|
|
4655
|
-
|
|
5145
|
+
Mi(e) && (this.depth = Math.max(0, this.depth - 1), this.depth === 0 && this.hideOverlay());
|
|
4656
5146
|
}
|
|
4657
5147
|
async onDrop(e) {
|
|
4658
5148
|
e.preventDefault(), this.depth = 0, this.hideOverlay();
|
|
4659
5149
|
let t = e.dataTransfer?.files?.[0];
|
|
4660
5150
|
if (t) try {
|
|
4661
|
-
let e =
|
|
5151
|
+
let e = xi(await t.text());
|
|
4662
5152
|
if (e.data.length === 0) throw Error(`No valid OHLCV rows found in "${t.name}"`);
|
|
4663
5153
|
this.callbacks.onData(e.data, e, t);
|
|
4664
5154
|
} catch (e) {
|
|
@@ -4689,12 +5179,12 @@ var ei = class {
|
|
|
4689
5179
|
this.overlay?.remove(), this.overlay = null;
|
|
4690
5180
|
}
|
|
4691
5181
|
};
|
|
4692
|
-
function
|
|
5182
|
+
function Mi(e) {
|
|
4693
5183
|
return e.dataTransfer?.types?.includes("Files") ?? !1;
|
|
4694
5184
|
}
|
|
4695
5185
|
//#endregion
|
|
4696
5186
|
//#region src/state/layoutStorage.ts
|
|
4697
|
-
function
|
|
5187
|
+
function Ni(e) {
|
|
4698
5188
|
let t = {
|
|
4699
5189
|
id: e.id,
|
|
4700
5190
|
name: e.name,
|
|
@@ -4702,11 +5192,11 @@ function Z(e) {
|
|
|
4702
5192
|
};
|
|
4703
5193
|
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;
|
|
4704
5194
|
}
|
|
4705
|
-
var
|
|
4706
|
-
function
|
|
5195
|
+
var Pi = (e, t) => t.updatedAt - e.updatedAt;
|
|
5196
|
+
function Fi(e) {
|
|
4707
5197
|
if (typeof e != "object" || !e) return null;
|
|
4708
5198
|
let t = e;
|
|
4709
|
-
return typeof t.id != "string" || !t.id || typeof t.name != "string" || typeof t.updatedAt != "number" || !Number.isFinite(t.updatedAt) ? null :
|
|
5199
|
+
return typeof t.id != "string" || !t.id || typeof t.name != "string" || typeof t.updatedAt != "number" || !Number.isFinite(t.updatedAt) ? null : Ni({
|
|
4710
5200
|
id: t.id,
|
|
4711
5201
|
name: t.name,
|
|
4712
5202
|
updatedAt: t.updatedAt,
|
|
@@ -4715,17 +5205,17 @@ function Q(e) {
|
|
|
4715
5205
|
kind: typeof t.kind == "string" ? t.kind : void 0
|
|
4716
5206
|
});
|
|
4717
5207
|
}
|
|
4718
|
-
function
|
|
4719
|
-
let t =
|
|
5208
|
+
function Ii(e) {
|
|
5209
|
+
let t = Fi(e), n = t ? e.content : void 0;
|
|
4720
5210
|
return t && typeof n == "string" ? {
|
|
4721
5211
|
...t,
|
|
4722
5212
|
content: n
|
|
4723
5213
|
} : null;
|
|
4724
5214
|
}
|
|
4725
|
-
function
|
|
5215
|
+
function Li(e = []) {
|
|
4726
5216
|
let t = new Map(e.map((e) => [e.id, { ...e }]));
|
|
4727
5217
|
return {
|
|
4728
|
-
list: () => [...t.values()].map(
|
|
5218
|
+
list: () => [...t.values()].map(Ni).sort(Pi),
|
|
4729
5219
|
load: (e) => {
|
|
4730
5220
|
let n = t.get(e);
|
|
4731
5221
|
return n ? { ...n } : null;
|
|
@@ -4738,7 +5228,7 @@ function ri(e = []) {
|
|
|
4738
5228
|
}
|
|
4739
5229
|
};
|
|
4740
5230
|
}
|
|
4741
|
-
function
|
|
5231
|
+
function Ri(e = "tcw:layouts:") {
|
|
4742
5232
|
let t = `${e}index`, n = (t) => `${e}item:${t}`, r = () => {
|
|
4743
5233
|
let e;
|
|
4744
5234
|
try {
|
|
@@ -4746,10 +5236,10 @@ function ii(e = "tcw:layouts:") {
|
|
|
4746
5236
|
} catch {
|
|
4747
5237
|
return [];
|
|
4748
5238
|
}
|
|
4749
|
-
return Array.isArray(e) ? e.map(
|
|
5239
|
+
return Array.isArray(e) ? e.map(Fi).filter((e) => e !== null) : [];
|
|
4750
5240
|
}, i = (e) => localStorage.setItem(t, JSON.stringify(e));
|
|
4751
5241
|
return {
|
|
4752
|
-
list: () => r().sort(
|
|
5242
|
+
list: () => r().sort(Pi),
|
|
4753
5243
|
load: (e) => {
|
|
4754
5244
|
let t = r().find((t) => t.id === e), i = t ? localStorage.getItem(n(e)) : null;
|
|
4755
5245
|
return t && i !== null ? {
|
|
@@ -4758,7 +5248,7 @@ function ii(e = "tcw:layouts:") {
|
|
|
4758
5248
|
} : null;
|
|
4759
5249
|
},
|
|
4760
5250
|
save: (e) => {
|
|
4761
|
-
localStorage.setItem(n(e.id), e.content), i([...r().filter((t) => t.id !== e.id),
|
|
5251
|
+
localStorage.setItem(n(e.id), e.content), i([...r().filter((t) => t.id !== e.id), Ni(e)]);
|
|
4762
5252
|
},
|
|
4763
5253
|
remove: (e) => {
|
|
4764
5254
|
i(r().filter((t) => t.id !== e)), localStorage.removeItem(n(e));
|
|
@@ -4767,14 +5257,14 @@ function ii(e = "tcw:layouts:") {
|
|
|
4767
5257
|
}
|
|
4768
5258
|
//#endregion
|
|
4769
5259
|
//#region src/state/LayoutSession.ts
|
|
4770
|
-
var
|
|
5260
|
+
var zi = 80;
|
|
4771
5261
|
function $(e) {
|
|
4772
5262
|
return e.replace(/\s+/g, " ").trim().slice(0, 80).trim() || null;
|
|
4773
5263
|
}
|
|
4774
|
-
function
|
|
5264
|
+
function Bi() {
|
|
4775
5265
|
return globalThis.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
4776
5266
|
}
|
|
4777
|
-
function
|
|
5267
|
+
function Vi(e) {
|
|
4778
5268
|
let { id: t, name: n, symbol: r, timeframe: i, updatedAt: a, kind: o } = e;
|
|
4779
5269
|
return {
|
|
4780
5270
|
id: t,
|
|
@@ -4785,7 +5275,7 @@ function si(e) {
|
|
|
4785
5275
|
...o === void 0 ? {} : { kind: o }
|
|
4786
5276
|
};
|
|
4787
5277
|
}
|
|
4788
|
-
var
|
|
5278
|
+
var Hi = class {
|
|
4789
5279
|
currentLayout = null;
|
|
4790
5280
|
savedContent = null;
|
|
4791
5281
|
dirty = !1;
|
|
@@ -4801,7 +5291,7 @@ var ci = class {
|
|
|
4801
5291
|
now;
|
|
4802
5292
|
newId;
|
|
4803
5293
|
constructor(e, t, n = {}) {
|
|
4804
|
-
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 ??
|
|
5294
|
+
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 ?? Bi;
|
|
4805
5295
|
}
|
|
4806
5296
|
current() {
|
|
4807
5297
|
return this.currentLayout;
|
|
@@ -4817,7 +5307,7 @@ var ci = class {
|
|
|
4817
5307
|
}
|
|
4818
5308
|
async list() {
|
|
4819
5309
|
let e = await this.storage.list();
|
|
4820
|
-
return Array.isArray(e) ? e.map(
|
|
5310
|
+
return Array.isArray(e) ? e.map(Fi).filter((e) => e !== null && (e.kind ?? "chart") === this.kind).sort((e, t) => t.updatedAt - e.updatedAt) : [];
|
|
4821
5311
|
}
|
|
4822
5312
|
save() {
|
|
4823
5313
|
return this.queue(() => {
|
|
@@ -4831,7 +5321,7 @@ var ci = class {
|
|
|
4831
5321
|
}
|
|
4832
5322
|
open(e) {
|
|
4833
5323
|
return this.queue(async () => {
|
|
4834
|
-
let t =
|
|
5324
|
+
let t = Ii(await this.storage.load(e));
|
|
4835
5325
|
if (!t || t.id !== e || (t.kind ?? "chart") !== this.kind || this.destroyed) return !1;
|
|
4836
5326
|
this.cancelTimer(), this.applying++;
|
|
4837
5327
|
try {
|
|
@@ -4841,13 +5331,13 @@ var ci = class {
|
|
|
4841
5331
|
} finally {
|
|
4842
5332
|
this.applying--;
|
|
4843
5333
|
}
|
|
4844
|
-
return this.cancelTimer(), this.currentLayout =
|
|
5334
|
+
return this.cancelTimer(), this.currentLayout = Vi(t), this.savedContent = this.host.capture().content, this.dirty = !1, this.notify(), !0;
|
|
4845
5335
|
});
|
|
4846
5336
|
}
|
|
4847
5337
|
rename(e, t) {
|
|
4848
5338
|
let n = $(t);
|
|
4849
5339
|
return n ? this.queue(async () => {
|
|
4850
|
-
let t =
|
|
5340
|
+
let t = Ii(await this.storage.load(e));
|
|
4851
5341
|
!t || t.id !== e || (await this.storage.save({
|
|
4852
5342
|
...t,
|
|
4853
5343
|
name: n
|
|
@@ -4925,7 +5415,7 @@ var ci = class {
|
|
|
4925
5415
|
content: n.content
|
|
4926
5416
|
};
|
|
4927
5417
|
await this.storage.save(r);
|
|
4928
|
-
let i =
|
|
5418
|
+
let i = Vi(r);
|
|
4929
5419
|
return this.currentLayout = i, this.savedContent = n.content, this.dirty = !1, this.notify(), i;
|
|
4930
5420
|
}
|
|
4931
5421
|
forget() {
|
|
@@ -4946,6 +5436,6 @@ var ci = class {
|
|
|
4946
5436
|
}
|
|
4947
5437
|
};
|
|
4948
5438
|
//#endregion
|
|
4949
|
-
export {
|
|
5439
|
+
export { In as C, z as D, L as E, on as O, zn as S, B as T, rr as _, Li as a, W as b, Br as c, Er as d, Dr as f, nr as g, ir as h, Ri as i, Ar as l, ar as m, zi as n, ji as o, or as p, $ as r, xi as s, Hi as t, kr as u, er as v, Pn as w, Wn as x, tr as y };
|
|
4950
5440
|
|
|
4951
|
-
//# sourceMappingURL=LayoutSession-
|
|
5441
|
+
//# sourceMappingURL=LayoutSession-D7uQq3jX.js.map
|