@tradecanvas/chart 1.70.0 → 1.71.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.
@@ -1,12 +1,12 @@
1
- import { DARK_THEME as e, DEFAULT_PANEL_HEIGHT as t, LIGHT_THEME as n, LayerType as r, MIN_PANEL_HEIGHT as i, PHI as a, PRICE_AXIS_WIDTH as o, TIME_AXIS_HEIGHT as s, autoPricePrecision as c, barDateZone as l, barTimeUnit as u, barsAreDaily as d, chartStyleValue as f, computePriceLimits as p, computePriceRange as m, createMarketTheme as h, formatPrice as g, fractionTick as _, indicatorSource as v, isValidTimeZone as y, mergeBar as ee, niceNumber as te, normalizeBarTime as b, parseIndicatorSource as x, priceFormatterFor as ne, priceStepAt as re, readChartStyleOverrides as ie, readChartTypeOptions as S, readIndicatorPlotStyles as ae, readPaneStyle as oe, resolveChartTheme as se, sessionMinute as C, setLocale as ce, stepDecimals as le, symbolTimeZone as w, tickBarCount as ue, timeframeToMs as T, 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 E, CompareRenderer as Se, CompareSymbolIndicator as Ce, CompareSymbolPaneIndicator as we, CorrelationCoefficientIndicator as Te, CorrelationLogIndicator as Ee, CrosshairHandler as De, CrosshairTooltip as Oe, CurrentPriceLine as ke, DEFAULT_SESSION_HOURS as Ae, DataExporter as D, DepthHeatmapRenderer as je, DrawingManager as Me, DrawingRenderer as Ne, EquivolumeRenderer as Pe, EventBus as Fe, GridRenderer as Ie, HLCAreaRenderer as Le, HiLoRenderer as Re, HollowCandleRenderer as ze, IndicatorEngine as Be, InteractionManager as Ve, KagiRenderer as He, KeyboardHandler as Ue, LineRenderer as We, LineWithMarkersRenderer as Ge, MarketProfileRenderer as Ke, MeasureOverlay as qe, PRICE_AXIS_ADD_STRIP as Je, PRICE_SCALE_MARGIN as O, PanHandler as Ye, PaneResizeHandler as Xe, PeriodLevelsRenderer as Ze, PinnedTooltip as Qe, PivotMarkersRenderer as $e, PointAndFigureRenderer as et, PriceAxis as tt, PriceAxisAddButton as nt, PriceLines as rt, RenderEngine as it, RenkoRenderer as at, ReplayManager as ot, ResamplingAdapter as st, ReshapeMemo as ct, SYMBOL_INDICATOR_IDS as lt, SYMBOL_ZONE_WAIT_MS as ut, Screenshot as k, SelectionBoxOverlay as dt, SessionBreaks as ft, SessionShading as pt, SignalMarkerManager as mt, SpreadIndicator as ht, StepLineRenderer as gt, StreamManager as _t, SymbolSeriesStore as vt, TimeAxis as yt, TradeZoneManager as bt, TradingManager as xt, TradingRenderer as St, UndoRedoManager as Ct, Viewport as wt, VolumeCandleRenderer as Tt, VolumeProfileRenderer as Et, VolumeRenderer as Dt, Watermark as Ot, ZoomHandler as kt, axisTimes as At, barTimeStepMs as jt, findDominantSwing as Mt, gpuContextsLeft as Nt, isPriceLevelAlert as Pt, isRegularSession as Ft, loadWebGL as It, mergeSessionHours as Lt, pointAndFigureColumns as Rt, rangePresetStart as zt, readAlertOptions as Bt, registerBuiltInDrawingTools as Vt, registerBuiltInIndicators as Ht, servesTimeframe as A, sourceParam as j, streamAdapterOf as Ut, timestampToBarIndex as M, toHeikinAshi as Wt, toKagi as Gt, toLineBreak as Kt, toRangeBars as qt, toRenko as Jt, whenGpuContextFree as Yt, withResampling as N, xToBarIndex as Xt, xToTime as P, yToPrice as Zt } from "@tradecanvas/core";
1
+ import { DARK_THEME as e, DEFAULT_PANEL_HEIGHT as t, LIGHT_THEME as n, LayerType as r, MIN_PANEL_HEIGHT as i, PHI as a, PRICE_AXIS_WIDTH as o, TIME_AXIS_HEIGHT as s, autoPricePrecision as c, barDateZone as l, barTimeUnit as u, barsAreDaily as d, chartStyleValue as f, computePriceLimits as p, computePriceRange as m, createMarketTheme as h, formatPrice as g, fractionTick as _, indicatorSource as v, isValidTimeZone as y, mergeBar as ee, niceNumber as te, normalizeBarTime as b, parseIndicatorSource as x, priceFormatterFor as ne, priceStepAt as re, readChartStyleOverrides as ie, readChartTypeOptions as ae, readIndicatorPlotStyles as oe, readPaneStyle as se, resolveChartTheme as ce, sessionMinute as S, setLocale as le, stepDecimals as ue, symbolTimeZone as C, tickBarCount as de, timeframeToMs as w, zonedDateFormatter as fe } from "@tradecanvas/commons";
2
+ import { AlertDragHandler as pe, AlertManager as me, Animator as he, AreaRenderer as ge, AxisDragHandler as _e, BarCountdown as ve, BarRenderer as ye, BaselineRenderer as be, CandlestickRenderer as xe, ChartLegend as Se, ChartStateManager as T, CompareRenderer as Ce, CompareSymbolIndicator as we, CompareSymbolPaneIndicator as Te, CorrelationCoefficientIndicator as Ee, CorrelationLogIndicator as De, CrosshairHandler as Oe, CrosshairTooltip as ke, CurrentPriceLine as Ae, DEFAULT_SESSION_HOURS as je, DataExporter as E, DepthHeatmapRenderer as Me, DrawingManager as Ne, DrawingRenderer as Pe, EquivolumeRenderer as Fe, EventBus as Ie, GridRenderer as Le, HLCAreaRenderer as Re, HiLoRenderer as ze, HollowCandleRenderer as Be, IndicatorEngine as Ve, InteractionManager as He, KagiRenderer as Ue, KeyboardHandler as We, LineRenderer as Ge, LineWithMarkersRenderer as Ke, MarketProfileRenderer as qe, MeasureOverlay as Je, PRICE_AXIS_ADD_STRIP as Ye, PRICE_SCALE_MARGIN as D, PanHandler as Xe, PaneResizeHandler as Ze, PeriodLevelsRenderer as Qe, PinnedTooltip as $e, PivotMarkersRenderer as et, PointAndFigureRenderer as tt, PriceAxis as nt, PriceAxisAddButton as rt, PriceLines as it, RenderEngine as at, RenkoRenderer as ot, ReplayManager as st, ResamplingAdapter as ct, ReshapeMemo as lt, SYMBOL_INDICATOR_IDS as ut, SYMBOL_ZONE_WAIT_MS as dt, Screenshot as O, SelectionBoxOverlay as ft, SessionBreaks as pt, SessionShading as mt, SignalMarkerManager as ht, SpreadIndicator as gt, StepLineRenderer as _t, StreamManager as vt, SymbolSeriesStore as yt, TimeAxis as bt, TradeZoneManager as xt, TradingManager as St, TradingRenderer as Ct, UndoRedoManager as wt, Viewport as Tt, VolumeCandleRenderer as Et, VolumeProfileRenderer as Dt, VolumeRenderer as Ot, Watermark as kt, ZoomHandler as At, axisTimes as k, barTimeStepMs as jt, findDominantSwing as Mt, gpuContextsLeft as Nt, isPriceLevelAlert as Pt, isRegularSession as Ft, loadWebGL as It, mergeSessionHours as Lt, pointAndFigureColumns as Rt, rangePresetStart as zt, readAlertOptions as Bt, registerBuiltInDrawingTools as Vt, registerBuiltInIndicators as Ht, servesTimeframe as A, sourceParam as j, streamAdapterOf as Ut, timestampToBarIndex as M, toHeikinAshi as Wt, toKagi as Gt, toLineBreak as Kt, toRangeBars as qt, toRenko as Jt, whenGpuContextFree as Yt, withResampling as N, xToBarIndex as Xt, xToTime as P, yToPrice as Zt } from "@tradecanvas/core";
3
3
  //#region src/regularHours.ts
4
4
  var Qt = 864e5, $t = 10;
5
5
  function en(e, t) {
6
- let n = w(e);
6
+ let n = C(e);
7
7
  if (!n || !y(n) || t.length < 2) return null;
8
8
  let r = (e?.sessions ?? []).flatMap((e) => {
9
- let t = C(e.start), n = C(e.end);
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
@@ -178,22 +178,22 @@ function fn(e) {
178
178
  case "candlestick":
179
179
  case "heikinAshi":
180
180
  case "lineBreak":
181
- case "rangeBars": return new be();
182
- case "line": return new We();
183
- case "area": return new he();
184
- case "bar": return new ve();
185
- case "hollowCandle": return new ze();
186
- case "baseline": return new ye();
187
- case "renko": return new at();
188
- case "kagi": return new He();
189
- case "pointAndFigure": return new et();
190
- case "volumeCandles": return new Tt();
191
- case "equivolume": return new Pe();
192
- case "hlcArea": return new Le();
193
- case "stepLine": return new gt();
194
- case "lineWithMarkers": return new Ge();
195
- case "hiLo": return new Re();
196
- default: return new be();
181
+ case "rangeBars": return new xe();
182
+ case "line": return new Ge();
183
+ case "area": return new ge();
184
+ case "bar": return new ye();
185
+ case "hollowCandle": return new Be();
186
+ case "baseline": return new be();
187
+ case "renko": return new ot();
188
+ case "kagi": return new Ue();
189
+ case "pointAndFigure": return new tt();
190
+ case "volumeCandles": return new Et();
191
+ case "equivolume": return new Fe();
192
+ case "hlcArea": return new Re();
193
+ case "stepLine": return new _t();
194
+ case "lineWithMarkers": return new Ke();
195
+ case "hiLo": return new ze();
196
+ default: return new xe();
197
197
  }
198
198
  }
199
199
  function pn(e, t, n = {}, r, i) {
@@ -340,37 +340,37 @@ function z(e) {
340
340
  volume: e.volume === void 0 ? 0 : Math.max(0, e.volume)
341
341
  };
342
342
  }
343
- function B(e, t) {
343
+ function Pn(e, t) {
344
344
  return e === t || e.time === t.time && e.open === t.open && e.high === t.high && e.low === t.low && e.close === t.close && e.volume === t.volume;
345
345
  }
346
- function Pn(e, t) {
346
+ function Fn(e, t) {
347
347
  for (let n = e.length - 1; n >= 0; n--) {
348
348
  if (e[n].time === t) return n;
349
349
  if (e[n].time < t) return -1;
350
350
  }
351
351
  return -1;
352
352
  }
353
- var Fn = {
353
+ var In = {
354
354
  index: -1,
355
355
  changed: !1
356
356
  };
357
- function In(e, t) {
357
+ function Ln(e, t) {
358
358
  if (e.length === 0) return t;
359
359
  let n = b(t);
360
360
  return u(e) === 1 ? n : n / 1e3;
361
361
  }
362
- function Ln(e, t) {
363
- let n = In(e, t.time);
362
+ function Rn(e, t) {
363
+ let n = Ln(e, t.time);
364
364
  return n === t.time ? t : {
365
365
  ...t,
366
366
  time: n
367
367
  };
368
368
  }
369
- var V = class {
369
+ var B = class {
370
370
  data = [];
371
371
  changes = 0;
372
372
  withSeriesTime(e) {
373
- return Ln(this.data, e);
373
+ return Rn(this.data, e);
374
374
  }
375
375
  getData() {
376
376
  return this.data;
@@ -412,11 +412,11 @@ var V = class {
412
412
  this.data[this.data.length - 1] = t;
413
413
  }
414
414
  replaceBar(e) {
415
- if (!R(e)) return Fn;
416
- let t = this.withSeriesTime(e), n = Pn(this.data, t.time);
417
- if (n < 0) return Fn;
415
+ if (!R(e)) return In;
416
+ let t = this.withSeriesTime(e), n = Fn(this.data, t.time);
417
+ if (n < 0) return In;
418
418
  let r = z(t);
419
- return B(this.data[n], r) ? {
419
+ return Pn(this.data[n], r) ? {
420
420
  index: n,
421
421
  changed: !1
422
422
  } : (this.data[n] = r, this.changes++, {
@@ -433,18 +433,18 @@ var V = class {
433
433
  clear() {
434
434
  this.data = [], this.changes++;
435
435
  }
436
- }, H = {
436
+ }, V = {
437
437
  to: "none",
438
438
  index: -1,
439
439
  changed: !1
440
440
  };
441
- function U(e, t) {
441
+ function H(e, t) {
442
442
  let n = e[e.length - 1];
443
443
  if (!n) return "append";
444
444
  let r = b(t.time), i = b(n.time);
445
445
  return r > i ? "append" : r === i ? "update" : "stale";
446
446
  }
447
- function Rn(e) {
447
+ function zn(e) {
448
448
  return [
449
449
  e.time,
450
450
  e.open,
@@ -453,8 +453,8 @@ function Rn(e) {
453
453
  e.close
454
454
  ].every(Number.isFinite);
455
455
  }
456
- var zn = class {
457
- shown = new V();
456
+ var Bn = class {
457
+ shown = new B();
458
458
  whole = null;
459
459
  aside = null;
460
460
  shownRevision = 0;
@@ -496,7 +496,7 @@ var zn = class {
496
496
  }
497
497
  let t = null, n = e;
498
498
  if (this.whole) {
499
- let r = this.whole[0]?.time, i = /* @__PURE__ */ new Set(), a = e.filter(Rn).map((e) => this.inSeriesUnit(e)).filter((e) => (r === void 0 || e.time < r) && !i.has(e.time) && i.add(e.time)).sort((e, t) => e.time - t.time);
499
+ let r = this.whole[0]?.time, i = /* @__PURE__ */ new Set(), a = e.filter(zn).map((e) => this.inSeriesUnit(e)).filter((e) => (r === void 0 || e.time < r) && !i.has(e.time) && i.add(e.time)).sort((e, t) => e.time - t.time);
500
500
  this.whole = [...a, ...this.whole];
501
501
  let o = this.hoursFilter(this.whole);
502
502
  t = a.length, n = o ? a.filter((e) => o(e.time)) : a;
@@ -508,8 +508,8 @@ var zn = class {
508
508
  };
509
509
  }
510
510
  mergeSnapshot(e) {
511
- if (this.aside) return this.aside.setData(Bn(this.aside.getData(), e) ?? e), this.onLiveChange({ kind: "series" }), !0;
512
- let t = Bn(this.whole ?? this.shown.getData(), e);
511
+ if (this.aside) return this.aside.setData(Vn(this.aside.getData(), e) ?? e), this.onLiveChange({ kind: "series" }), !0;
512
+ let t = Vn(this.whole ?? this.shown.getData(), e);
513
513
  return t ? (this.shown.setData(this.regularOnly(t)), !0) : !1;
514
514
  }
515
515
  refilter() {
@@ -566,7 +566,7 @@ var zn = class {
566
566
  mergeTick(e) {
567
567
  if (this.aside) return this.aside.updateLastBarFromTick(e), this.wrote("aside", !1);
568
568
  let t = this.whole ? this.hoursFilter(this.whole) : null;
569
- if (t && this.whole && !t(In(this.whole, e.time))) return this.wrote("hidden", !1);
569
+ if (t && this.whole && !t(Ln(this.whole, e.time))) return this.wrote("hidden", !1);
570
570
  let n = this.shown.getLength();
571
571
  this.shown.updateLastBarFromTick(e);
572
572
  let r = this.whole, i = this.shown.getData()[this.shown.getLength() - 1];
@@ -578,14 +578,14 @@ var zn = class {
578
578
  }
579
579
  placeStreamBar(e) {
580
580
  if (this.aside) {
581
- let t = U(this.aside.getData(), e);
581
+ let t = H(this.aside.getData(), e);
582
582
  return t === "append" ? this.aside.appendBar(e) : t === "update" && this.aside.updateLastBar(e), this.wrote(t === "stale" ? "none" : "aside", !1);
583
583
  }
584
- let t = this.inSeriesUnit(e), n = U(this.whole ?? this.shown.getData(), t);
584
+ let t = this.inSeriesUnit(e), n = H(this.whole ?? this.shown.getData(), t);
585
585
  if (n === "stale") return this.wrote("none", !1);
586
586
  let r = this.startWholeSeries(t, n);
587
587
  if (!this.take(t, n)) return this.wrote("hidden", r);
588
- let i = this.shown.getLength(), a = U(this.shown.getData(), t);
588
+ let i = this.shown.getLength(), a = H(this.shown.getData(), t);
589
589
  return a === "stale" ? {
590
590
  to: "none",
591
591
  before: i,
@@ -599,7 +599,7 @@ var zn = class {
599
599
  replace(e) {
600
600
  if (this.aside) {
601
601
  let { index: t, changed: n } = this.aside.replaceBar(e);
602
- return t < 0 ? H : (n && this.onLiveChange({
602
+ return t < 0 ? V : (n && this.onLiveChange({
603
603
  kind: "bar",
604
604
  time: this.aside.getData()[t].time
605
605
  }), {
@@ -608,22 +608,22 @@ var zn = class {
608
608
  changed: n
609
609
  });
610
610
  }
611
- if (!R(e)) return H;
612
- let t = this.inSeriesUnit(e), n = this.whole, r = n ? Pn(n, t.time) : -1;
611
+ if (!R(e)) return V;
612
+ let t = this.inSeriesUnit(e), n = this.whole, r = n ? Fn(n, t.time) : -1;
613
613
  if (n) {
614
- if (r < 0 || !R(n[r])) return H;
614
+ if (r < 0 || !R(n[r])) return V;
615
615
  let e = this.hoursFilter(n);
616
616
  if (e && !e(t.time)) return this.replaceHidden(n, r, t);
617
617
  }
618
618
  let { index: i, changed: a } = this.shown.replaceBar(t);
619
- return i < 0 ? H : (a && (n && (n[r] = this.shown.getData()[i]), this.shownRevision++), {
619
+ return i < 0 ? V : (a && (n && (n[r] = this.shown.getData()[i]), this.shownRevision++), {
620
620
  to: "shown",
621
621
  index: i,
622
622
  changed: a
623
623
  });
624
624
  }
625
625
  beginReplay() {
626
- this.aside || (this.aside = new V(), this.aside.setData(this.whole ?? this.shown.getData()));
626
+ this.aside || (this.aside = new B(), this.aside.setData(this.whole ?? this.shown.getData()));
627
627
  }
628
628
  endReplay() {
629
629
  let e = this.aside;
@@ -643,10 +643,10 @@ var zn = class {
643
643
  this.shown.updateLastBar(e);
644
644
  }
645
645
  inSeriesUnit(e) {
646
- return Ln(this.whole ?? this.shown.getData(), e);
646
+ return Rn(this.whole ?? this.shown.getData(), e);
647
647
  }
648
648
  replaceHidden(e, t, n) {
649
- let r = z(n), i = !B(e[t], r);
649
+ let r = z(n), i = !Pn(e[t], r);
650
650
  return i && (e[t] = r), {
651
651
  to: "hidden",
652
652
  index: -1,
@@ -680,14 +680,14 @@ var zn = class {
680
680
  return !r || r(e.time);
681
681
  }
682
682
  };
683
- function Bn(e, t) {
683
+ function Vn(e, t) {
684
684
  let n = t[0]?.time, r = 0;
685
685
  for (; n !== void 0 && r < e.length && e[r].time < n;) r++;
686
686
  return r === 0 || r === e.length ? null : e.slice(0, r).concat(t);
687
687
  }
688
688
  //#endregion
689
689
  //#region src/model/PriceFit.ts
690
- var Vn = a ** -7, Hn = class {
690
+ var Hn = a ** -7, Un = class {
691
691
  auto;
692
692
  preferred;
693
693
  pending = !0;
@@ -720,21 +720,21 @@ var Vn = a ** -7, Hn = class {
720
720
  }
721
721
  fit(e, t, n, r) {
722
722
  if (t.length === 0) return;
723
- let i = Math.max(0, n.visibleRange.from), a = Math.min(n.visibleRange.to, t.length - 1), o = Wn(Wn(m(t, i, a, 0), r.overlayRange(i, a)), r.compareRange(t, n)), s = r.volumeRatio(t, i, a), c = s === null ? O : s + Vn;
723
+ let i = Math.max(0, n.visibleRange.from), a = Math.min(n.visibleRange.to, t.length - 1), o = Gn(Gn(m(t, i, a, 0), r.overlayRange(i, a)), r.compareRange(t, n)), s = r.volumeRatio(t, i, a), c = s === null ? D : s + Hn;
724
724
  e.setScaleMargins(e.isInvertScale() ? {
725
725
  top: c,
726
- bottom: O
726
+ bottom: D
727
727
  } : {
728
- top: O,
728
+ top: D,
729
729
  bottom: c
730
730
  }), e.fitToPrices(o.min, o.max);
731
731
  }
732
732
  };
733
- function Un(e, t, n) {
733
+ function Wn(e, t, n) {
734
734
  for (let r = t; r <= n; r++) if (e[r].volume > 0) return !0;
735
735
  return !1;
736
736
  }
737
- function Wn(e, t) {
737
+ function Gn(e, t) {
738
738
  return e ? t ? {
739
739
  min: Math.min(e.min, t.min),
740
740
  max: Math.max(e.max, t.max)
@@ -742,11 +742,11 @@ function Wn(e, t) {
742
742
  }
743
743
  //#endregion
744
744
  //#region src/model/DisplaySeries.ts
745
- var Gn = class {
745
+ var Kn = class {
746
746
  series = null;
747
747
  madeAt = null;
748
748
  epoch = 0;
749
- memo = new ct();
749
+ memo = new lt();
750
750
  constructor(e) {
751
751
  this.sources = e;
752
752
  }
@@ -774,10 +774,10 @@ var Gn = class {
774
774
  let { columns: a, boxSize: o } = hn(t, n, this.memo);
775
775
  return this.sources.onBoxSize(o), a;
776
776
  }
777
- }, Kn = {
777
+ }, qn = {
778
778
  min: 0,
779
779
  max: 100
780
- }, qn = class {
780
+ }, Jn = class {
781
781
  layout = null;
782
782
  infos = null;
783
783
  styles = /* @__PURE__ */ new Map();
@@ -785,7 +785,7 @@ var Gn = class {
785
785
  this.manager = e, this.sources = t, this.onLayout = n;
786
786
  }
787
787
  resolved() {
788
- return this.layout || (this.layout = this.manager.resolve(), this.onLayout(Jn(this.layout))), this.layout;
788
+ return this.layout || (this.layout = this.manager.resolve(), this.onLayout(Yn(this.layout))), this.layout;
789
789
  }
790
790
  invalidate() {
791
791
  this.layout = null, this.infos = null;
@@ -797,7 +797,7 @@ var Gn = class {
797
797
  if (this.infos) return this.infos;
798
798
  let t = e(), { from: n, to: r } = t.visibleRange;
799
799
  return this.infos = this.resolved().panels.map((e) => {
800
- let i = e.config.id, a = e.config.logScale ? this.sources.getPaneValueRange(i, n, r, !0) : null, o = a ?? this.sources.getPaneValueRange(i, n, r) ?? { ...Kn }, s = this.styles.get(i);
800
+ let i = e.config.id, a = e.config.logScale ? this.sources.getPaneValueRange(i, n, r, !0) : null, o = a ?? this.sources.getPaneValueRange(i, n, r) ?? { ...qn }, s = this.styles.get(i);
801
801
  return {
802
802
  instanceId: i,
803
803
  members: this.sources.getPaneMembers(i),
@@ -857,7 +857,7 @@ var Gn = class {
857
857
  }
858
858
  }
859
859
  };
860
- function Jn(e) {
860
+ function Yn(e) {
861
861
  let t = e.mainChartRect, n = t.y, r = t.y + t.height;
862
862
  for (let t of e.panels) t.config.position !== "top" && t.config.position !== "bottom" || (n = Math.min(n, t.rect.y), r = Math.max(r, t.rect.y + t.rect.height));
863
863
  return {
@@ -865,10 +865,10 @@ function Jn(e) {
865
865
  bottom: r
866
866
  };
867
867
  }
868
- function Yn(e) {
868
+ function Xn(e) {
869
869
  return e.length > 0 ? { renames: e } : {};
870
870
  }
871
- var W = (e, t) => JSON.stringify(e) === JSON.stringify(t), Xn = class {
871
+ var U = (e, t) => JSON.stringify(e) === JSON.stringify(t), Zn = class {
872
872
  steps;
873
873
  snapshot;
874
874
  enabled;
@@ -890,21 +890,21 @@ var W = (e, t) => JSON.stringify(e) === JSON.stringify(t), Xn = class {
890
890
  this.renames = i;
891
891
  }
892
892
  let o = this.snapshot();
893
- return W(n, o) || this.push(e, n, o, r), a;
893
+ return U(n, o) || this.push(e, n, o, r), a;
894
894
  }
895
895
  push(e, t, n, r) {
896
- let i = this.now(), a = this.steps.last(), o = a?.type === "indicators" ? a.indicators : void 0, s = e !== void 0 && o?.subject === e && i - (o.at ?? 0) < 800 && W(o.after, t), c = {
896
+ let i = this.now(), a = this.steps.last(), o = a?.type === "indicators" ? a.indicators : void 0, s = e !== void 0 && o?.subject === e && i - (o.at ?? 0) < 800 && U(o.after, t), c = {
897
897
  type: "indicators",
898
898
  before: null,
899
899
  after: null
900
900
  };
901
- s && o ? W(o.before, n) ? this.steps.dropLast() : this.steps.replaceLast({
901
+ s && o ? U(o.before, n) ? this.steps.dropLast() : this.steps.replaceLast({
902
902
  ...c,
903
903
  indicators: {
904
904
  ...o,
905
905
  after: n,
906
906
  at: i,
907
- ...Yn([...o.renames ?? [], ...r])
907
+ ...Xn([...o.renames ?? [], ...r])
908
908
  }
909
909
  }) : this.steps.push({
910
910
  ...c,
@@ -913,7 +913,7 @@ var W = (e, t) => JSON.stringify(e) === JSON.stringify(t), Xn = class {
913
913
  after: n,
914
914
  subject: e,
915
915
  at: i,
916
- ...Yn(r)
916
+ ...Xn(r)
917
917
  }
918
918
  });
919
919
  }
@@ -939,7 +939,7 @@ var W = (e, t) => JSON.stringify(e) === JSON.stringify(t), Xn = class {
939
939
  if (!e) return;
940
940
  this.edit = null, this.depth--;
941
941
  let t = this.snapshot();
942
- W(t, e.before) || this.steps.push({
942
+ U(t, e.before) || this.steps.push({
943
943
  type: "indicators",
944
944
  before: null,
945
945
  after: null,
@@ -951,7 +951,7 @@ var W = (e, t) => JSON.stringify(e) === JSON.stringify(t), Xn = class {
951
951
  }
952
952
  });
953
953
  }
954
- }, Zn = class {
954
+ }, Qn = class {
955
955
  constructor(e, t, n) {
956
956
  this.members = e, this.slots = t, this.handover = n;
957
957
  }
@@ -1030,7 +1030,7 @@ var W = (e, t) => JSON.stringify(e) === JSON.stringify(t), Xn = class {
1030
1030
  };
1031
1031
  //#endregion
1032
1032
  //#region src/model/IndicatorSetup.ts
1033
- function Qn(e, t, n) {
1033
+ function $n(e, t, n) {
1034
1034
  let r = t.getPanels(), i = t.getMaximizedPanel();
1035
1035
  return e.getActiveIndicators().map((t) => {
1036
1036
  let a = r.find((e) => e.id === t.instanceId), o = e.getIndicatorConfig(t.instanceId), s = a ? n(t.instanceId) : null;
@@ -1058,7 +1058,7 @@ function Qn(e, t, n) {
1058
1058
  };
1059
1059
  });
1060
1060
  }
1061
- function $n(e, t) {
1061
+ function er(e, t) {
1062
1062
  for (let [n, r] of t) n.paneSize !== void 0 && e.setPanelSize(r, n.paneSize), (n.paneSize !== void 0 || n.paneCollapsed) && e.setPanelCollapsed(r, !!n.paneCollapsed), n.paneSize !== void 0 && e.setPanelScale(r, {
1063
1063
  log: !!n.paneLog,
1064
1064
  invert: !!n.paneInvert,
@@ -1069,7 +1069,7 @@ function $n(e, t) {
1069
1069
  let r = t.find(([e]) => e.paneMaximized);
1070
1070
  e.setMaximizedPanel(r ? r[1] : null);
1071
1071
  }
1072
- function er(e) {
1072
+ function tr(e) {
1073
1073
  let t = new Map(e.map((e) => [e.instanceId, e])), n = [], r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = (e) => {
1074
1074
  if (r.has(e.instanceId) || i.has(e.instanceId)) return;
1075
1075
  i.add(e.instanceId);
@@ -1083,23 +1083,23 @@ function er(e) {
1083
1083
  for (let t of e) a(t);
1084
1084
  return n;
1085
1085
  }
1086
- function tr(e, t) {
1086
+ function nr(e, t) {
1087
1087
  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);
1088
1088
  }
1089
- function nr(e, t) {
1089
+ function rr(e, t) {
1090
1090
  let n = new Map(t.map((e) => [e.instanceId, e])), r = /* @__PURE__ */ new Set();
1091
1091
  for (let t of e) {
1092
1092
  let e = n.get(t.instanceId);
1093
- e && tr(t, e) && rr(t, e) && r.add(t.instanceId);
1093
+ e && nr(t, e) && ir(t, e) && r.add(t.instanceId);
1094
1094
  }
1095
1095
  for (let t of e) t.pane && !r.has(t.pane) && r.delete(t.instanceId);
1096
1096
  return r;
1097
1097
  }
1098
- function rr(e, t) {
1098
+ function ir(e, t) {
1099
1099
  let n = Object.keys(e.params);
1100
1100
  return n.length === Object.keys(t.params).length && n.every((e) => e in t.params);
1101
1101
  }
1102
- function ir(e, t) {
1102
+ function ar(e, t) {
1103
1103
  let n = { ...e };
1104
1104
  for (let [e, r] of Object.entries(n)) {
1105
1105
  let i = x(r), a = i && t.get(i.instanceId);
@@ -1109,11 +1109,11 @@ function ir(e, t) {
1109
1109
  }
1110
1110
  //#endregion
1111
1111
  //#region src/model/SymbolRequests.ts
1112
- function ar(e, t) {
1112
+ function or(e, t) {
1113
1113
  let n = t.symbol;
1114
- return lt.has(e) && typeof n == "string" ? n.trim() : "";
1114
+ return ut.has(e) && typeof n == "string" ? n.trim() : "";
1115
1115
  }
1116
- var or = class {
1116
+ var sr = class {
1117
1117
  asked = /* @__PURE__ */ new Set();
1118
1118
  constructor(e, t) {
1119
1119
  this.readers = e, this.held = t;
@@ -1121,14 +1121,14 @@ var or = class {
1121
1121
  required() {
1122
1122
  let e = /* @__PURE__ */ new Set();
1123
1123
  for (let t of this.readers.getActiveIndicators()) {
1124
- let n = ar(t.id, t.params);
1124
+ let n = or(t.id, t.params);
1125
1125
  n && e.add(n);
1126
1126
  }
1127
1127
  return [...e];
1128
1128
  }
1129
1129
  readersOf(e) {
1130
1130
  let t = e.trim();
1131
- return this.readers.getActiveIndicators().filter((e) => lt.has(e.id) && String(e.params.symbol ?? "").trim() === t).map((e) => e.instanceId);
1131
+ return this.readers.getActiveIndicators().filter((e) => ut.has(e.id) && String(e.params.symbol ?? "").trim() === t).map((e) => e.instanceId);
1132
1132
  }
1133
1133
  given(e) {
1134
1134
  this.asked.delete(e.trim());
@@ -1139,20 +1139,20 @@ var or = class {
1139
1139
  }
1140
1140
  toAsk(e) {
1141
1141
  this.forgetUnread();
1142
- let t = this.readers.getIndicatorConfig(e), n = t ? ar(t.id, t.params) : "";
1142
+ let t = this.readers.getIndicatorConfig(e), n = t ? or(t.id, t.params) : "";
1143
1143
  return !n || this.held.has(n) || this.asked.has(n) ? null : (this.asked.add(n), n);
1144
1144
  }
1145
- }, sr = (e, t) => e.x >= t.x && e.x <= t.x + t.width && e.y >= t.y && e.y <= t.y + t.height;
1146
- function cr(e, t, n, r) {
1147
- if (!sr(e, t)) {
1145
+ }, cr = (e, t) => e.x >= t.x && e.x <= t.x + t.width && e.y >= t.y && e.y <= t.y + t.height;
1146
+ function lr(e, t, n, r) {
1147
+ if (!cr(e, t)) {
1148
1148
  for (let t of n) {
1149
1149
  let n = r(t.id);
1150
- if (n && sr(e, n.chartRect)) return t.id;
1150
+ if (n && cr(e, n.chartRect)) return t.id;
1151
1151
  }
1152
1152
  return null;
1153
1153
  }
1154
1154
  }
1155
- function lr(e, t, n, r) {
1155
+ function ur(e, t, n, r) {
1156
1156
  if (!e || e.position !== "top" && e.position !== "bottom" || t) return null;
1157
1157
  let i = n();
1158
1158
  return !i || i.chartRect.height < 24 ? null : {
@@ -1160,12 +1160,12 @@ function lr(e, t, n, r) {
1160
1160
  data: r()
1161
1161
  };
1162
1162
  }
1163
- function ur(e, t, n) {
1163
+ function dr(e, t, n) {
1164
1164
  return !n && e.some((e) => e.id === t);
1165
1165
  }
1166
1166
  //#endregion
1167
1167
  //#region src/HistoryPager.ts
1168
- var dr = 5e3, fr = 6e4, pr = 500, mr = class {
1168
+ var fr = 5e3, pr = 6e4, mr = 500, hr = class {
1169
1169
  loader = null;
1170
1170
  pageSize = 500;
1171
1171
  loading = !1;
@@ -1220,7 +1220,7 @@ var dr = 5e3, fr = 6e4, pr = 500, mr = class {
1220
1220
  return n === this.seq ? (this.loading = !1, e instanceof Error && e.name === "AbortError" ? (this.emit({
1221
1221
  state: "loaded",
1222
1222
  count: 0
1223
- }), 0) : (this.failures++, this.retryAt = this.now() + Math.min(fr, dr * 2 ** (this.failures - 1)), this.emit({
1223
+ }), 0) : (this.failures++, this.retryAt = this.now() + Math.min(pr, fr * 2 ** (this.failures - 1)), this.emit({
1224
1224
  state: "error",
1225
1225
  count: 0,
1226
1226
  error: e instanceof Error ? e.message : String(e)
@@ -1253,10 +1253,10 @@ var dr = 5e3, fr = 6e4, pr = 500, mr = class {
1253
1253
  };
1254
1254
  //#endregion
1255
1255
  //#region src/ThemeManager.ts
1256
- function hr(e, t) {
1256
+ function gr(e, t) {
1257
1257
  return e.family === t.family && e.sizeSmall === t.sizeSmall && e.sizeMedium === t.sizeMedium && e.sizeLarge === t.sizeLarge;
1258
1258
  }
1259
- var gr = class t {
1259
+ var _r = class t {
1260
1260
  base;
1261
1261
  shape = null;
1262
1262
  font = null;
@@ -1275,13 +1275,13 @@ var gr = class t {
1275
1275
  return i;
1276
1276
  }
1277
1277
  getTheme() {
1278
- return this.effective ??= se(this.base, this.chartType, this.merged()), this.effective;
1278
+ return this.effective ??= ce(this.base, this.chartType, this.merged()), this.effective;
1279
1279
  }
1280
1280
  getBaseTheme() {
1281
1281
  return this.base;
1282
1282
  }
1283
1283
  setTheme(e) {
1284
- let n = t.read(e), r = this.font !== null && hr(n.font, this.base.font);
1284
+ let n = t.read(e), r = this.font !== null && gr(n.font, this.base.font);
1285
1285
  this.base = n, r || (this.themeFont = n.font), this.shape && (this.base = {
1286
1286
  ...this.base,
1287
1287
  shape: {
@@ -1363,7 +1363,7 @@ var gr = class t {
1363
1363
  };
1364
1364
  //#endregion
1365
1365
  //#region src/style/styleOptions.ts
1366
- function _r(e, t) {
1366
+ function vr(e, t) {
1367
1367
  return t ? {
1368
1368
  ...t.visible === void 0 ? {} : { [`crosshair.${e}.visible`]: t.visible },
1369
1369
  ...t.color === void 0 ? {} : { [`crosshair.${e}.color`]: t.color },
@@ -1371,22 +1371,22 @@ function _r(e, t) {
1371
1371
  ...t.width === void 0 ? {} : { [`crosshair.${e}.width`]: t.width }
1372
1372
  } : {};
1373
1373
  }
1374
- function vr(e) {
1374
+ function yr(e) {
1375
1375
  let { grid: t, crosshair: n } = e, r = n?.vLine?.labelBackground ?? n?.hLine?.labelBackground;
1376
1376
  return {
1377
1377
  ...t?.hLineColor === void 0 ? {} : { "grid.horizontal.color": t.hLineColor },
1378
1378
  ...t?.hLineStyle === void 0 ? {} : { "grid.horizontal.style": t.hLineStyle },
1379
1379
  ...t?.vLineColor === void 0 ? {} : { "grid.vertical.color": t.vLineColor },
1380
1380
  ...t?.vLineStyle === void 0 ? {} : { "grid.vertical.style": t.vLineStyle },
1381
- ..._r("horizontal", n?.hLine),
1382
- ..._r("vertical", n?.vLine),
1381
+ ...vr("horizontal", n?.hLine),
1382
+ ...vr("vertical", n?.vLine),
1383
1383
  ...r === void 0 ? {} : { "crosshair.labelBackground": r },
1384
1384
  ...e.overrides
1385
1385
  };
1386
1386
  }
1387
1387
  //#endregion
1388
1388
  //#region src/layout/LayoutManager.ts
1389
- var yr = 200, br = 80, G = (e) => e.position === "top" || e.position === "bottom", xr = class {
1389
+ var br = 200, xr = 80, W = (e) => e.position === "top" || e.position === "bottom", Sr = class {
1390
1390
  panels = [];
1391
1391
  containerWidth = 0;
1392
1392
  containerHeight = 0;
@@ -1403,8 +1403,8 @@ var yr = 200, br = 80, G = (e) => e.position === "top" || e.position === "bottom
1403
1403
  this.panels.push({
1404
1404
  id: e,
1405
1405
  position: n,
1406
- size: r ?? (a ? yr : t),
1407
- minSize: a ? br : i,
1406
+ size: r ?? (a ? br : t),
1407
+ minSize: a ? xr : i,
1408
1408
  content: {
1409
1409
  type: "indicator",
1410
1410
  indicatorInstanceId: e
@@ -1423,14 +1423,14 @@ var yr = 200, br = 80, G = (e) => e.position === "top" || e.position === "bottom
1423
1423
  }
1424
1424
  setPanelCollapsed(e, t) {
1425
1425
  let n = this.panels.find((t) => t.id === e);
1426
- return !n || !G(n) || this.maximized === null && !!n.collapsed === t ? !1 : (this.maximized = null, n.collapsed = t || void 0, !0);
1426
+ return !n || !W(n) || this.maximized === null && !!n.collapsed === t ? !1 : (this.maximized = null, n.collapsed = t || void 0, !0);
1427
1427
  }
1428
1428
  isPanelCollapsed(e) {
1429
1429
  return !!this.panels.find((t) => t.id === e)?.collapsed;
1430
1430
  }
1431
1431
  isPanelShownCollapsed(e) {
1432
1432
  let t = this.panels.find((t) => t.id === e);
1433
- return !t || !G(t) ? !1 : this.maximized === null ? !!t.collapsed : this.maximized !== e;
1433
+ return !t || !W(t) ? !1 : this.maximized === null ? !!t.collapsed : this.maximized !== e;
1434
1434
  }
1435
1435
  setPanelScale(e, t) {
1436
1436
  let n = this.panels.find((t) => t.id === e);
@@ -1446,7 +1446,7 @@ var yr = 200, br = 80, G = (e) => e.position === "top" || e.position === "bottom
1446
1446
  }
1447
1447
  setMaximizedPanel(e) {
1448
1448
  let t = e === null ? null : this.panels.find((t) => t.id === e);
1449
- return e !== null && (!t || !G(t)) || this.maximized === e ? !1 : (this.maximized = e, t && (t.collapsed = void 0), !0);
1449
+ return e !== null && (!t || !W(t)) || this.maximized === e ? !1 : (this.maximized = e, t && (t.collapsed = void 0), !0);
1450
1450
  }
1451
1451
  getMaximizedPanel() {
1452
1452
  return this.maximized;
@@ -1467,19 +1467,19 @@ var yr = 200, br = 80, G = (e) => e.position === "top" || e.position === "bottom
1467
1467
  this.panels = [...this.panels].sort((e, n) => t(e) - t(n));
1468
1468
  }
1469
1469
  shownSize(e, t) {
1470
- return G(e) ? this.maximized ? e.id === this.maximized ? t : 20 : e.collapsed ? 20 : e.size : e.size;
1470
+ return W(e) ? this.maximized ? e.id === this.maximized ? t : 20 : e.collapsed ? 20 : e.size : e.size;
1471
1471
  }
1472
1472
  setPanelPosition(e, n) {
1473
1473
  let r = this.panels.find((t) => t.id === e);
1474
1474
  if (r) {
1475
1475
  let a = r.position === "left" || r.position === "right", o = n === "left" || n === "right";
1476
- r.position = n, a !== o && (r.size = o ? yr : t, r.minSize = o ? br : i), o && (r.collapsed = void 0, this.maximized === e && (this.maximized = null));
1476
+ r.position = n, a !== o && (r.size = o ? br : t, r.minSize = o ? xr : i), o && (r.collapsed = void 0, this.maximized === e && (this.maximized = null));
1477
1477
  }
1478
1478
  }
1479
1479
  setPanelSize(e, t) {
1480
1480
  let n = this.panels.find((t) => t.id === e);
1481
1481
  if (n) {
1482
- let e = G(n) ? this.containerHeight - s - 48 : this.containerWidth / 2, r = e > n.minSize ? Math.min(t, e) : t;
1482
+ let e = W(n) ? this.containerHeight - s - 48 : this.containerWidth / 2, r = e > n.minSize ? Math.min(t, e) : t;
1483
1483
  n.size = Math.max(n.minSize, r), n.collapsed = void 0, this.maximized = null;
1484
1484
  }
1485
1485
  }
@@ -1593,8 +1593,8 @@ var yr = 200, br = 80, G = (e) => e.position === "top" || e.position === "bottom
1593
1593
  getMainChartRect() {
1594
1594
  return this.resolve().mainChartRect;
1595
1595
  }
1596
- }, Sr = 14, Cr = 14, wr = 22, Tr = 4;
1597
- function Er(e) {
1596
+ }, Cr = 14, wr = 14, Tr = 22, Er = 4;
1597
+ function Dr(e) {
1598
1598
  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] : [
1599
1599
  t,
1600
1600
  n,
@@ -1603,16 +1603,16 @@ function Er(e) {
1603
1603
  for (let t of f) {
1604
1604
  if (!Number.isFinite(t)) continue;
1605
1605
  let n = e.scaleLabel ? e.scaleLabel(t) : e.format ? e.format(t) : g(t, u, i), r = e.format ? n : g(t, d, i);
1606
- p = Math.max(p, l(n, `500 ${s}px ${a}`) + Sr, l(r, `bold 11px ${a}`) + Cr, l(r, `600 ${s}px ${a}`) + wr);
1606
+ p = Math.max(p, l(n, `500 ${s}px ${a}`) + Cr, l(r, `bold 11px ${a}`) + wr, l(r, `600 ${s}px ${a}`) + Tr);
1607
1607
  }
1608
- return p <= o ? o : Math.ceil(p / Tr) * Tr;
1608
+ return p <= o ? o : Math.ceil(p / Er) * Er;
1609
1609
  }
1610
- function Dr(e, t) {
1610
+ function Or(e, t) {
1611
1611
  return t > e || t <= e - 12 ? t : e;
1612
1612
  }
1613
1613
  //#endregion
1614
1614
  //#region src/layout/labelWidths.ts
1615
- var Or = 512, kr = class {
1615
+ var kr = 512, Ar = class {
1616
1616
  widths = /* @__PURE__ */ new Map();
1617
1617
  fonts;
1618
1618
  forget = () => this.widths.clear();
@@ -1623,12 +1623,12 @@ var Or = 512, kr = class {
1623
1623
  let r = `${t}\n${e}`, i = this.widths.get(r);
1624
1624
  if (i !== void 0) return i;
1625
1625
  let a = n();
1626
- return this.widths.size >= Or && this.widths.clear(), this.widths.set(r, a), a;
1626
+ return this.widths.size >= kr && this.widths.clear(), this.widths.set(r, a), a;
1627
1627
  }
1628
1628
  destroy() {
1629
1629
  this.fonts?.removeEventListener("loadingdone", this.forget), this.widths.clear();
1630
1630
  }
1631
- }, Ar = class {
1631
+ }, jr = class {
1632
1632
  netY = 0;
1633
1633
  travelX = 0;
1634
1634
  engaged = !1;
@@ -1644,11 +1644,11 @@ var Or = 512, kr = class {
1644
1644
  }
1645
1645
  return this.engaged;
1646
1646
  }
1647
- }, jr = 1;
1648
- function Mr(e, t) {
1647
+ }, Mr = 1;
1648
+ function Nr(e, t) {
1649
1649
  return e.filter((e) => e.enabled !== !1 && (e.descriptor.layer ?? "overlay") === t);
1650
1650
  }
1651
- function K(e) {
1651
+ function G(e) {
1652
1652
  switch (e.kind) {
1653
1653
  case "indicator": return `indicator:${e.plugin.descriptor.id}`;
1654
1654
  case "drawing": return `drawing:${e.plugin.descriptor.type}`;
@@ -1658,25 +1658,25 @@ function K(e) {
1658
1658
  }
1659
1659
  //#endregion
1660
1660
  //#region src/plugins/registry.ts
1661
- var q = /* @__PURE__ */ new Map();
1662
- function Nr(e) {
1663
- q.set(K(e), e);
1664
- }
1661
+ var K = /* @__PURE__ */ new Map();
1665
1662
  function Pr(e) {
1666
- return q.delete(e);
1663
+ K.set(G(e), e);
1667
1664
  }
1668
- function Fr() {
1669
- return [...q.values()];
1665
+ function Fr(e) {
1666
+ return K.delete(e);
1670
1667
  }
1671
1668
  function Ir() {
1672
- q.clear();
1669
+ return [...K.values()];
1670
+ }
1671
+ function Lr() {
1672
+ K.clear();
1673
1673
  }
1674
1674
  //#endregion
1675
1675
  //#region src/plugins/PluginManager.ts
1676
- var Lr = class {
1676
+ var Rr = class {
1677
1677
  plugins = /* @__PURE__ */ new Map();
1678
1678
  constructor(e, t = {}) {
1679
- if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of Fr()) this.add(e);
1679
+ if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of Ir()) this.add(e);
1680
1680
  for (let e of t.plugins ?? []) this.add(e);
1681
1681
  }
1682
1682
  register(e) {
@@ -1704,17 +1704,17 @@ var Lr = class {
1704
1704
  return e;
1705
1705
  }
1706
1706
  add(e) {
1707
- this.plugins.set(K(e), e), e.kind === "indicator" && this.indicatorEngine.register(e.plugin);
1707
+ this.plugins.set(G(e), e), e.kind === "indicator" && this.indicatorEngine.register(e.plugin);
1708
1708
  }
1709
- }, Rr = {
1709
+ }, zr = {
1710
1710
  orderPlace: (e, t) => e.placeOrder(t),
1711
1711
  orderModify: (e, t) => e.modifyOrder(t),
1712
1712
  orderCancel: (e, t) => e.cancelOrder(t),
1713
1713
  positionModify: (e, t) => e.modifyPosition(t),
1714
1714
  positionClose: (e, t) => e.closePosition(t),
1715
- positionReverse: (e, t, n) => zr(e, t, n)
1715
+ positionReverse: (e, t, n) => Br(e, t, n)
1716
1716
  };
1717
- async function zr(e, t, n) {
1717
+ async function Br(e, t, n) {
1718
1718
  let { reversing: r } = n;
1719
1719
  if (!r.has(t.positionId)) {
1720
1720
  r.add(t.positionId);
@@ -1743,7 +1743,7 @@ async function zr(e, t, n) {
1743
1743
  }
1744
1744
  }
1745
1745
  }
1746
- function Br(e, t) {
1746
+ function Vr(e, t) {
1747
1747
  let n = [], r = null, i = {
1748
1748
  positions: () => r ?? t.getPositions?.() ?? [],
1749
1749
  reversing: /* @__PURE__ */ new Set()
@@ -1753,8 +1753,8 @@ function Br(e, t) {
1753
1753
  e.data && t.onFill?.(e.data);
1754
1754
  };
1755
1755
  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));
1756
- for (let r of Object.keys(Rr)) {
1757
- let a = Rr[r], o = t.onIntent(r, (n) => {
1756
+ for (let r of Object.keys(zr)) {
1757
+ let a = zr[r], o = t.onIntent(r, (n) => {
1758
1758
  Promise.resolve(a(e, n, i)).catch((e) => t.onError({
1759
1759
  message: `Execution command failed: ${r}`,
1760
1760
  cause: e
@@ -1768,7 +1768,7 @@ function Br(e, t) {
1768
1768
  }
1769
1769
  //#endregion
1770
1770
  //#region src/replay/ReplayStepLoader.ts
1771
- var Vr = 1e3, Hr = class {
1771
+ var Hr = 1e3, Ur = class {
1772
1772
  pieces = /* @__PURE__ */ new Map();
1773
1773
  asked = /* @__PURE__ */ new Set();
1774
1774
  inFlight = !1;
@@ -1801,7 +1801,7 @@ var Vr = 1e3, Hr = class {
1801
1801
  this.done = !0;
1802
1802
  }
1803
1803
  ask(e, t) {
1804
- let { ratio: n, barMs: r, step: i, report: a } = this.options, o = Math.max(1, Math.floor(Vr / n)), s = Math.min(e.length, t + o), c = s < e.length ? e[s].time : e[e.length - 1].time + r, l = e.slice(t, s);
1804
+ let { ratio: n, barMs: r, step: i, report: a } = this.options, o = Math.max(1, Math.floor(Hr / 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);
1805
1805
  for (let e of l) this.asked.add(e.time);
1806
1806
  this.inFlight = !0, a({
1807
1807
  state: "loading",
@@ -1842,12 +1842,12 @@ var Vr = 1e3, Hr = class {
1842
1842
  ...n === void 0 ? {} : { error: n }
1843
1843
  });
1844
1844
  }
1845
- }, Ur = 1 / 3, Wr = .25, Gr = .5;
1846
- function Kr(e, t) {
1847
- let n = (e.high - e.low) * Wr;
1848
- return t.filter((t) => t.close > e.high + n || t.close < e.low - n).length <= t.length * Gr;
1845
+ }, Wr = 1 / 3, Gr = .25, Kr = .5;
1846
+ function qr(e, t) {
1847
+ let n = (e.high - e.low) * Gr;
1848
+ return t.filter((t) => t.close > e.high + n || t.close < e.low - n).length <= t.length * Kr;
1849
1849
  }
1850
- function qr(e) {
1850
+ function Jr(e) {
1851
1851
  return e.close >= e.open ? [
1852
1852
  e.open,
1853
1853
  e.low,
@@ -1860,22 +1860,22 @@ function qr(e) {
1860
1860
  e.close
1861
1861
  ];
1862
1862
  }
1863
- function Jr(e, t, n) {
1864
- let r = qr(e), i = [
1863
+ function Yr(e, t, n) {
1864
+ let r = Jr(e), i = [
1865
1865
  1,
1866
1866
  2,
1867
1867
  3
1868
1868
  ].map((e) => Math.abs(r[e] - r[e - 1])), a = i[0] + i[1] + i[2], o = [], s = 0;
1869
1869
  return r.forEach((r, c) => {
1870
- c > 0 && (s += a > 0 ? i[c - 1] / a : Ur), !(c === 0 && t > 0) && o.push({
1870
+ c > 0 && (s += a > 0 ? i[c - 1] / a : Wr), !(c === 0 && t > 0) && o.push({
1871
1871
  price: r,
1872
1872
  time: e.time,
1873
1873
  at: (t + s) / n
1874
1874
  });
1875
1875
  }), o;
1876
1876
  }
1877
- function Yr(e, t = []) {
1878
- let n = t.length > 0 && Kr(e, t) ? t : [e], r = n.length, i = Xr(n.flatMap((e, t) => Jr(e, t, r)), e), a = n.reduce((e, t) => e + (t.volume ?? 0), 0), o = 0;
1877
+ function Xr(e, t = []) {
1878
+ let n = t.length > 0 && qr(e, t) ? t : [e], r = n.length, i = Zr(n.flatMap((e, t) => Yr(e, t, r)), e), a = n.reduce((e, t) => e + (t.volume ?? 0), 0), o = 0;
1879
1879
  return {
1880
1880
  bar: e,
1881
1881
  points: i,
@@ -1885,7 +1885,7 @@ function Yr(e, t = []) {
1885
1885
  }))
1886
1886
  };
1887
1887
  }
1888
- function Xr(e, t) {
1888
+ function Zr(e, t) {
1889
1889
  let n = e.length - 1, r = e.map((e, r) => ({
1890
1890
  ...e,
1891
1891
  price: r === 0 ? t.open : r === n ? t.close : Math.min(t.high, Math.max(t.low, e.price))
@@ -1900,7 +1900,7 @@ function Xr(e, t) {
1900
1900
  };
1901
1901
  return i(t.high, (e, t) => e > t), i(t.low, (e, t) => e < t), r;
1902
1902
  }
1903
- function Zr(e, t) {
1903
+ function Qr(e, t) {
1904
1904
  let n = e.points;
1905
1905
  if (t <= n[0].at) return n[0].price;
1906
1906
  for (let e = 1; e < n.length; e++) if (t <= n[e].at) {
@@ -1909,8 +1909,8 @@ function Zr(e, t) {
1909
1909
  }
1910
1910
  return n[n.length - 1].price;
1911
1911
  }
1912
- var Qr = (e) => Number.isFinite(e) ? Math.min(1, Math.max(0, e)) : 0;
1913
- function $r(e, t) {
1912
+ var $r = (e) => Number.isFinite(e) ? Math.min(1, Math.max(0, e)) : 0;
1913
+ function ei(e, t) {
1914
1914
  let n = 0, r = 0;
1915
1915
  for (let i of e.volumeAt) {
1916
1916
  if (t >= i.at) {
@@ -1921,10 +1921,10 @@ function $r(e, t) {
1921
1921
  }
1922
1922
  return n;
1923
1923
  }
1924
- function ei(e, t) {
1925
- let n = Qr(t);
1924
+ function ti(e, t) {
1925
+ let n = $r(t);
1926
1926
  if (n >= 1) return { ...e.bar };
1927
- let r = Zr(e, n), i = Math.max(e.points[0].price, r), a = Math.min(e.points[0].price, r);
1927
+ let r = Qr(e, n), i = Math.max(e.points[0].price, r), a = Math.min(e.points[0].price, r);
1928
1928
  for (let t of e.points) {
1929
1929
  if (t.at > n) break;
1930
1930
  i = Math.max(i, t.price), a = Math.min(a, t.price);
@@ -1935,29 +1935,29 @@ function ei(e, t) {
1935
1935
  high: i,
1936
1936
  low: a,
1937
1937
  close: r,
1938
- volume: $r(e, n)
1938
+ volume: ei(e, n)
1939
1939
  };
1940
1940
  }
1941
- function ti(e, t) {
1942
- let n = Qr(t), r = 0;
1941
+ function ni(e, t) {
1942
+ let n = $r(t), r = 0;
1943
1943
  for (let t of e.points) {
1944
1944
  if (t.at > n) break;
1945
1945
  r = t.at;
1946
1946
  }
1947
1947
  return r;
1948
1948
  }
1949
- function J(e, t, n) {
1949
+ function q(e, t, n) {
1950
1950
  let r = [], i = e.bar.time;
1951
1951
  for (let a of e.points) {
1952
1952
  if (a.at > n) break;
1953
1953
  i = a.time, a.at > t && r.push([a.price, a.time]);
1954
1954
  }
1955
- let a = Zr(e, n);
1955
+ let a = Qr(e, n);
1956
1956
  return (r.length === 0 || r[r.length - 1][0] !== a) && r.push([a, i]), r;
1957
1957
  }
1958
1958
  //#endregion
1959
1959
  //#region src/replay/replayStep.ts
1960
- var ni = [
1960
+ var ri = [
1961
1961
  "1m",
1962
1962
  "3m",
1963
1963
  "5m",
@@ -1968,44 +1968,193 @@ var ni = [
1968
1968
  "4h",
1969
1969
  "1d"
1970
1970
  ];
1971
- function ri(e, t) {
1972
- let n = T(e);
1973
- return n > 0 ? ni.filter((e) => {
1974
- let r = T(e);
1971
+ function ii(e, t) {
1972
+ let n = w(e);
1973
+ return n > 0 ? ri.filter((e) => {
1974
+ let r = w(e);
1975
1975
  return r < n && n % r === 0 && t(e);
1976
1976
  }) : [];
1977
1977
  }
1978
- function ii(e, t, n) {
1979
- let r = ri(t, n);
1978
+ function ai(e, t, n) {
1979
+ let r = ii(t, n);
1980
1980
  if (e !== "auto") return r.includes(e) ? e : null;
1981
- let i = T(t);
1982
- return r.find((e) => i / T(e) <= 60) ?? null;
1981
+ let i = w(t);
1982
+ return r.find((e) => i / w(e) <= 60) ?? null;
1983
+ }
1984
+ //#endregion
1985
+ //#region src/model/AlertWatch.ts
1986
+ function oi(e, t) {
1987
+ e.setBarTime(t.barTime);
1988
+ let n = new Map([["price", t.price]]);
1989
+ t.lines && si(e.getAlerts(), t.lines, n), e.checkChannels(n, { together: !0 }), e.checkDrawings(t.price);
1990
+ }
1991
+ function si(e, t, n) {
1992
+ let r = e.flatMap((e) => e.target ? [e.channel, e.target] : [e.channel]);
1993
+ for (let e of r) {
1994
+ if (n.has(e)) continue;
1995
+ let r = e.indexOf(":");
1996
+ if (r < 0) continue;
1997
+ let i = t(e.slice(0, r)), a = i?.[i.length - 1]?.[e.slice(r + 1)];
1998
+ typeof a == "number" && Number.isFinite(a) && n.set(e, a);
1999
+ }
2000
+ }
2001
+ function ci(e, t, n, r) {
2002
+ let i = (e) => {
2003
+ let i = e.indexOf(":");
2004
+ if (i <= 0) return null;
2005
+ let a = e.slice(0, i), o = t.get(a);
2006
+ if (!o || r(a) !== void 0) return null;
2007
+ let s = n.filter((e) => r(e) === o);
2008
+ return s.length === 1 ? s[0] + e.slice(i) : null;
2009
+ };
2010
+ for (let t of e.getAlerts()) {
2011
+ let n = i(t.channel), r = t.target ? i(t.target) : null;
2012
+ if (!n && !r) continue;
2013
+ let { percent: a, bars: o, onBarClose: s, expiresAt: c } = t;
2014
+ e.removeAlert(t.id), e.addAlert(t.price, t.condition, t.message, t.repeating, n ?? t.channel, t.label, {
2015
+ ...t.target ? { target: r ?? t.target } : {},
2016
+ ...a === void 0 ? {} : { percent: a },
2017
+ ...o === void 0 ? {} : { bars: o },
2018
+ ...s ? { onBarClose: s } : {},
2019
+ ...c === void 0 ? {} : { expiresAt: c }
2020
+ });
2021
+ }
2022
+ }
2023
+ function li(e, t) {
2024
+ let n = e.indexOf(":"), r = n > 0 ? t.get(e.slice(0, n)) : void 0;
2025
+ return r ? r + e.slice(n) : e;
2026
+ }
2027
+ var ui = [
2028
+ "crossing",
2029
+ "crossingUp",
2030
+ "crossingDown"
2031
+ ];
2032
+ function di(e, t, n, r, i) {
2033
+ e.clearAlerts();
2034
+ for (let a of t) {
2035
+ if (a.triggered && !a.repeating || a.expired) continue;
2036
+ if (a.drawingId) {
2037
+ r(a.drawingId) && ui.includes(a.condition) && e.addDrawingAlert(a.drawingId, a.condition, a.message, a.repeating, a.label);
2038
+ continue;
2039
+ }
2040
+ let t = {
2041
+ ...Bt(a),
2042
+ ...a.target ? { target: li(a.target, n) } : {}
2043
+ };
2044
+ try {
2045
+ e.addAlert(a.price, a.condition, a.message, a.repeating, li(a.channel, n), a.label, t);
2046
+ } catch (e) {
2047
+ i(e);
2048
+ }
2049
+ }
2050
+ }
2051
+ var fi = class {
2052
+ kept = /* @__PURE__ */ new Map();
2053
+ constructor(e) {
2054
+ this.alerts = e;
2055
+ }
2056
+ removed(e) {
2057
+ let t = this.alerts.takeDrawingAlerts(e);
2058
+ t.length > 0 && this.kept.set(e, t);
2059
+ }
2060
+ created(e) {
2061
+ let t = this.kept.get(e);
2062
+ t && (this.kept.delete(e), this.alerts.restoreAlerts(t));
2063
+ }
2064
+ prune(e) {
2065
+ return this.kept.clear(), this.alerts.pruneDrawingAlerts(e);
2066
+ }
2067
+ };
2068
+ function J(e, t) {
2069
+ let n = 0, r = e.length;
2070
+ for (; n < r;) {
2071
+ let i = n + r >> 1;
2072
+ e[i].time < t ? n = i + 1 : r = i;
2073
+ }
2074
+ return n;
2075
+ }
2076
+ function Y(e, t) {
2077
+ let n = 0, r = e.length;
2078
+ for (; n < r;) {
2079
+ let i = n + r >> 1;
2080
+ e[i].time <= t ? n = i + 1 : r = i;
2081
+ }
2082
+ return n;
2083
+ }
2084
+ function pi(e) {
2085
+ let t = 0, n = 0;
2086
+ for (let r = 1; r < e.length; r++) e[r].low < e[t].low && (t = r), e[r].high > e[n].high && (n = r);
2087
+ 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];
2088
+ return [...a ? [r, i] : [i, r], [o.close, o.time]];
2089
+ }
2090
+ function mi(e) {
2091
+ let t = [], n = Math.ceil(e.length / 500);
2092
+ for (let r = 0; r < e.length; r += n) t.push(...pi(e.slice(r, r + n)));
2093
+ return t;
2094
+ }
2095
+ function hi(e, t, n) {
2096
+ let r = e[t];
2097
+ return r ? n.time === null ? {
2098
+ marks: [[r.close, r.time]],
2099
+ fed: {
2100
+ time: r.time,
2101
+ fraction: n.fraction
2102
+ }
2103
+ } : r.time <= n.time ? null : {
2104
+ marks: mi(e.slice(Y(e, n.time), t + 1)),
2105
+ fed: {
2106
+ time: r.time,
2107
+ fraction: n.fraction
2108
+ }
2109
+ } : null;
2110
+ }
2111
+ function gi(e, t, n, r, i, a) {
2112
+ let o = e[t];
2113
+ if (!o) return null;
2114
+ let s = {
2115
+ time: o.time,
2116
+ fraction: r
2117
+ };
2118
+ if (i.time === null) return {
2119
+ marks: [[ti(n, r).close, o.time]],
2120
+ fed: s
2121
+ };
2122
+ if (o.time < i.time || o.time === i.time && r <= i.fraction) return null;
2123
+ if (o.time === i.time) return {
2124
+ marks: q(n, i.fraction, r),
2125
+ fed: s
2126
+ };
2127
+ let c = [], l = J(e, i.time);
2128
+ return e[l]?.time === i.time && i.fraction < 1 && c.push(...q(a(e, l), i.fraction, 1)), c.push(...mi(e.slice(Y(e, i.time), t))), c.push(...q(n, -1, r)), {
2129
+ marks: c,
2130
+ fed: s
2131
+ };
1983
2132
  }
1984
2133
  //#endregion
1985
2134
  //#region src/Chart.ts
1986
- var ai = "exchange", oi = ai;
1987
- function si(e) {
2135
+ var _i = "exchange", vi = _i;
2136
+ function yi(e) {
1988
2137
  if (typeof e == "string" && e !== "exchange" && !y(e)) throw RangeError(`Unknown time zone: ${e}`);
1989
2138
  if (typeof e == "number" && !Number.isFinite(e)) throw RangeError(`Invalid UTC offset: ${e}`);
1990
2139
  }
1991
- function ci(e, t) {
1992
- let { timeZone: n, timezone: r } = e, i = n !== void 0 && r !== void 0 && n !== r && n === t ? r : w(e);
2140
+ function bi(e, t) {
2141
+ let { timeZone: n, timezone: r } = e, i = n !== void 0 && r !== void 0 && n !== r && n === t ? r : C(e);
1993
2142
  return i === void 0 ? e : {
1994
2143
  ...e,
1995
2144
  timeZone: i,
1996
2145
  timezone: i
1997
2146
  };
1998
2147
  }
1999
- var li = .08, ui = 20, di = 8, fi = 10, pi = {
2148
+ var xi = .08, Si = 20, Ci = 8, wi = 10, Ti = {
2000
2149
  ArrowLeft: [-1, 0],
2001
2150
  ArrowRight: [1, 0],
2002
2151
  ArrowUp: [0, -1],
2003
2152
  ArrowDown: [0, 1]
2004
- }, mi = new Set(["horizontalLine", "crossLine"]), hi = new Set(["verticalLine", "crossLine"]), gi = class {
2005
- static version = "1.70.0";
2153
+ }, Ei = new Set(["horizontalLine", "crossLine"]), Di = new Set(["verticalLine", "crossLine"]), Oi = class {
2154
+ static version = "1.71.0";
2006
2155
  engine;
2007
2156
  viewport;
2008
- series = new zn((e) => this.sessionKeep(e), (e) => this.followLiveChange(e));
2157
+ series = new Bn((e) => this.sessionKeep(e), (e) => this.followLiveChange(e));
2009
2158
  themeManager;
2010
2159
  layoutManager;
2011
2160
  pluginManager;
@@ -2030,7 +2179,7 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
2030
2179
  renderDeferred = !1;
2031
2180
  priceAxisWidth = o;
2032
2181
  measureCtx;
2033
- labelWidths = new kr();
2182
+ labelWidths = new Ar();
2034
2183
  containerSizeCache = null;
2035
2184
  containerSizeCacheTime = 0;
2036
2185
  lastEmittedRange = null;
@@ -2041,9 +2190,9 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
2041
2190
  watermark;
2042
2191
  barCountdown;
2043
2192
  unrestoredIndicators = [];
2044
- removedDrawingAlerts = /* @__PURE__ */ new Map();
2193
+ drawingAlerts = null;
2045
2194
  zoomAreaMode = !1;
2046
- priceAxisAddButton = new nt();
2195
+ priceAxisAddButton = new rt();
2047
2196
  displayTz = null;
2048
2197
  timeZoneSetting = null;
2049
2198
  symbolInfo = null;
@@ -2054,7 +2203,7 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
2054
2203
  studyZoneReleaseQueued = !1;
2055
2204
  sessionBreaks;
2056
2205
  sessionShading;
2057
- hostSessionHours = { ...Ae };
2206
+ hostSessionHours = { ...je };
2058
2207
  compareRenderer;
2059
2208
  countdownInterval = null;
2060
2209
  pausedFor = {
@@ -2073,7 +2222,7 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
2073
2222
  signalMarkerManager;
2074
2223
  tradeZoneManager;
2075
2224
  measureOverlay;
2076
- selectionBoxOverlay = new dt();
2225
+ selectionBoxOverlay = new ft();
2077
2226
  replayManager;
2078
2227
  replayBarUnsub = null;
2079
2228
  replaySeeking = !1;
@@ -2100,14 +2249,14 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
2100
2249
  disposed = !1;
2101
2250
  chartTypeOptions = {};
2102
2251
  mainSeriesVisible = !0;
2103
- priceLines = new rt();
2104
- symbolSeries = new vt();
2252
+ priceLines = new it();
2253
+ symbolSeries = new yt();
2105
2254
  extendedHours = !0;
2106
2255
  replayRestarting = !1;
2107
2256
  symbolRequests;
2108
2257
  gridRenderer;
2109
2258
  priceAxis;
2110
- leftPriceAxis = new tt();
2259
+ leftPriceAxis = new nt();
2111
2260
  leftScaleRequested = !1;
2112
2261
  leftAxisWidth = o;
2113
2262
  leftViewport = null;
@@ -2138,10 +2287,10 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
2138
2287
  snapshotKey = null;
2139
2288
  historyCheckQueued = !1;
2140
2289
  constructor(e, t) {
2141
- t.timeZone != null && si(t.timeZone), this.container = e, this.options = {
2290
+ t.timeZone != null && yi(t.timeZone), this.container = e, this.options = {
2142
2291
  ...t,
2143
2292
  chartType: t.chartType ?? "candlestick"
2144
- }, this.numberLocale = t.numberLocale ?? "en-US", this.priceFit = new Hn(t.autoScale !== !1), this.display = new Gn({
2293
+ }, this.numberLocale = t.numberLocale ?? "en-US", this.priceFit = new Un(t.autoScale !== !1), this.display = new Kn({
2145
2294
  bars: () => this.series.bars(),
2146
2295
  version: () => this.series.version(),
2147
2296
  chartType: () => this.options.chartType,
@@ -2149,7 +2298,7 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
2149
2298
  lookup: (e) => this.pluginManager.getChartType(e),
2150
2299
  stepAt: (e) => this.stepAt(e),
2151
2300
  onBoxSize: (e) => {
2152
- this.chartRenderer instanceof et && this.chartRenderer.setBoxSize(e);
2301
+ this.chartRenderer instanceof tt && this.chartRenderer.setBoxSize(e);
2153
2302
  }
2154
2303
  });
2155
2304
  let n = t.features ?? {};
@@ -2187,19 +2336,19 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
2187
2336
  logScale: n.logScale ?? !0,
2188
2337
  timeframes: n.timeframes ?? [],
2189
2338
  defaultTimeframeFavorites: n.defaultTimeframeFavorites ?? []
2190
- }, 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 mr({
2339
+ }, 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 hr({
2191
2340
  oldestTime: () => (this.replaySession ? this.series.liveBars() : this.series.bars())[0]?.time ?? null,
2192
2341
  prepend: (e) => this.prependBars(e),
2193
2342
  emit: (e) => this.eventBus.emit("historyLoad", e)
2194
- }), this.themeManager = new gr(t.theme), this.themeManager.setChartType(this.options.chartType ?? "candlestick"), this.applyStyle(vr(t), "host", !1), this.layoutManager = new xr(), this.indicatorEngine = new Be(), this.panes = new qn(this.layoutManager, this.indicatorEngine, (e) => this.crosshairHandler.setReportBounds(e)), this.indicatorPanes = new Zn(this.indicatorEngine, this.layoutManager, {
2343
+ }), this.themeManager = new _r(t.theme), this.themeManager.setChartType(this.options.chartType ?? "candlestick"), this.applyStyle(yr(t), "host", !1), this.layoutManager = new Sr(), this.indicatorEngine = new Ve(), this.panes = new Jn(this.layoutManager, this.indicatorEngine, (e) => this.crosshairHandler.setReportBounds(e)), this.indicatorPanes = new Qn(this.indicatorEngine, this.layoutManager, {
2195
2344
  passStyle: (e, t) => this.panes.passStyle(e, t),
2196
2345
  renamePane: (e, t) => this.renamePane(e, t),
2197
2346
  invalidateScales: () => this.panes.invalidateScales()
2198
- }), this.symbolRequests = new or(this.indicatorEngine, this.symbolSeries), this.pluginManager = new Lr(this.indicatorEngine, { plugins: t.plugins }), this.eventBus = new Fe(), Ht(this.indicatorEngine), this.indicatorEngine.register(new Ce(this.symbolSeries)), this.indicatorEngine.register(new we(this.symbolSeries)), this.indicatorEngine.register(new ht(this.symbolSeries)), this.indicatorEngine.register(new Te(this.symbolSeries)), this.indicatorEngine.register(new Ee(this.symbolSeries)), this.drawingManager = new Me(), Vt(this.drawingManager), this.drawingRenderer = new Ne(this.drawingManager), this.drawingRenderer.setKeepOut(() => this.legendKeepOut()), this.drawingRenderer.setTimeFormat((e) => this.crosshairHandler.formatTime(e, this.getDisplayData())), this.drawingManager.setRequestRender(() => {
2347
+ }), this.symbolRequests = new sr(this.indicatorEngine, this.symbolSeries), this.pluginManager = new Rr(this.indicatorEngine, { plugins: t.plugins }), this.eventBus = new Ie(), Ht(this.indicatorEngine), this.indicatorEngine.register(new we(this.symbolSeries)), this.indicatorEngine.register(new Te(this.symbolSeries)), this.indicatorEngine.register(new gt(this.symbolSeries)), this.indicatorEngine.register(new Ee(this.symbolSeries)), this.indicatorEngine.register(new De(this.symbolSeries)), this.drawingManager = new Ne(), Vt(this.drawingManager), this.drawingRenderer = new Pe(this.drawingManager), this.drawingRenderer.setKeepOut(() => this.legendKeepOut()), this.drawingRenderer.setTimeFormat((e) => this.crosshairHandler.formatTime(e, this.getDisplayData())), this.drawingManager.setRequestRender(() => {
2199
2348
  this.syncRenderContext(), this.engine.requestRender(r.Overlay), this.scheduleAutoSave();
2200
2349
  }), this.drawingManager.setEventCallback((e, t) => {
2201
2350
  this.followDrawingAlerts(e, t?.id), this.eventBus.emit(e, t), (e === "drawingCreate" || e === "drawingUpdate" || e === "drawingRemove") && this.announceStateChange();
2202
- }), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new Ct(), this.indicatorHistory = new Xn({
2351
+ }), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new wt(), this.indicatorHistory = new Zn({
2203
2352
  steps: this.undoRedoManager,
2204
2353
  snapshot: () => this.getIndicatorSetup(),
2205
2354
  enabled: () => this.features.drawingUndoRedo
@@ -2216,23 +2365,23 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
2216
2365
  primary: e[0] ?? null
2217
2366
  })), this.drawingManager.setForeignHistory((e, t) => {
2218
2367
  e.type === "custom" ? e.custom?.[t]() : this.applyIndicatorStep(e, t);
2219
- }), this.drawingManager.setDataGetter(() => this.series.bars(), () => this.series.revision()), this.drawingManager.setDisplayDataGetter(() => this.getDisplayData()), t.crosshair?.mode === "magnet" && this.features.drawingMagnet && this.drawingManager.setMagnetMode("magnet"), this.tradingManager = new xt({
2368
+ }), 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 St({
2220
2369
  enabled: this.features.trading,
2221
2370
  contextMenu: { enabled: this.features.tradingContextMenu }
2222
- }), this.tradingRenderer = new St(this.tradingManager), this.tradingManager.setContainer(e), this.tradingManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradingManager.setEventCallback((e, t) => {
2371
+ }), this.tradingRenderer = new Ct(this.tradingManager), this.tradingManager.setContainer(e), this.tradingManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradingManager.setEventCallback((e, t) => {
2223
2372
  this.eventBus.emit(e, t);
2224
- }), this.engine = new it(e, t.maxPixelRatio);
2373
+ }), this.engine = new at(e, t.maxPixelRatio);
2225
2374
  let a = this.engine.dprManager.getContainerSize();
2226
- if (this.viewport = new wt(a.width, a.height, t.minBarSpacing ?? 2, t.maxBarSpacing ?? 30, t.rightMargin ?? 5), t.barLayout && this.viewport.setBarLayout(t.barLayout), this.viewport.setPanLimits({
2375
+ if (this.viewport = new Tt(a.width, a.height, t.minBarSpacing ?? 2, t.maxBarSpacing ?? 30, t.rightMargin ?? 5), t.barLayout && this.viewport.setBarLayout(t.barLayout), this.viewport.setPanLimits({
2227
2376
  freePan: t.freePan ?? !0,
2228
2377
  minVisibleBars: t.panLimits?.minVisibleBars ?? 3
2229
2378
  }), t.minBarUnit !== void 0 && this.viewport.setMinBarUnit(t.minBarUnit), this.layoutManager.resize(a.width, a.height), this.engine.onContainerResize = (e) => {
2230
2379
  if (e.width <= 0 || e.height <= 0) return;
2231
2380
  let t = this.viewport.isAtEnd();
2232
2381
  this.viewport.resize(e.width, e.height), this.layoutManager.resize(e.width, e.height), this.updateViewportAndRender(t), this.eventBus.emit("resize", e);
2233
- }, this.chartRenderer = this.createChartRenderer(this.options.chartType), this.gridRenderer = new Ie(), t.grid?.visible === !1 && this.gridRenderer.setVisible(!1), this.priceAxis = new tt(), this.priceAxis.setLocale(this.numberLocale), this.leftPriceAxis.setLocale(this.numberLocale), this.viewport.setNumberLocale(this.numberLocale), this.timeAxis = new yt(), this.timeAxis.setLocale(this.numberLocale), this.crosshairHandler = new De(), 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) => {
2382
+ }, this.chartRenderer = this.createChartRenderer(this.options.chartType), this.gridRenderer = new Le(), t.grid?.visible === !1 && this.gridRenderer.setVisible(!1), this.priceAxis = new nt(), this.priceAxis.setLocale(this.numberLocale), this.leftPriceAxis.setLocale(this.numberLocale), this.viewport.setNumberLocale(this.numberLocale), this.timeAxis = new bt(), this.timeAxis.setLocale(this.numberLocale), this.crosshairHandler = new Oe(), this.crosshairHandler.setLocale(this.numberLocale), this.applyTimeSpacing(), t.crosshair?.mode && this.crosshairHandler.setMode(t.crosshair.mode), this.crosshairHandler.setDataSource(() => this.crosshairSeries()), this.crosshairHandler.setCallback((e, t) => {
2234
2383
  if (e !== null && t) {
2235
- let n = this.crosshairSeries(), i = e >= 0 && e < n.length ? n[e] : void 0, a = e > 0 ? n[e - 1]?.close : void 0, o = At(n), s = i ? o[e]?.time ?? i.time : void 0;
2384
+ let n = this.crosshairSeries(), i = e >= 0 && e < n.length ? n[e] : void 0, a = e > 0 ? n[e - 1]?.close : void 0, o = k(n), s = i ? o[e]?.time ?? i.time : void 0;
2236
2385
  this.chartLegend.setHoverBar(i ?? null, e > 0 ? n[e - 1] ?? null : null), this.features.legend && this.engine.requestRender(r.Hover);
2237
2386
  let c = this.viewport.getState(), l = t.y >= c.chartRect.y && t.y <= c.chartRect.y + c.chartRect.height;
2238
2387
  if (i && l && this.features.crosshairTooltip) {
@@ -2260,14 +2409,14 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
2260
2409
  let e = this.crosshairHandler.getSyncedSlot();
2261
2410
  e !== null && this.showSyncedBar(e);
2262
2411
  }
2263
- }), this.chartLegend = new xe(), this.chartLegend.setChartType(this.options.chartType), this.chartLegend.setLocale(this.numberLocale), this.chartLegend.setResizeListener(() => {
2412
+ }), this.chartLegend = new Se(), this.chartLegend.setChartType(this.options.chartType), this.chartLegend.setLocale(this.numberLocale), this.chartLegend.setResizeListener(() => {
2264
2413
  this.eventBus.emit("legendResize", { bottom: this.getLegendBottom() }), this.engine.requestRender();
2265
- }), this.watermark = new Ot(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new Dt(), this.volumeProfile = new Et(), this.marketProfile = new Ke(), this.depthHeatmap = new je(), this.periodLevels = new Ze(), this.pivotMarkers = new $e(), this.barCountdown = new _e(), this.barCountdown.setVisible(this.features.barCountdown), this.sessionBreaks = new ft(), this.sessionShading = new pt(), this.compareRenderer = new Se(), t.sessionBreaks ? this.sessionBreaks.setConfig({
2414
+ }), this.watermark = new kt(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new Ot(), this.volumeProfile = new Dt(), this.marketProfile = new qe(), this.depthHeatmap = new Me(), this.periodLevels = new Qe(), this.pivotMarkers = new et(), this.barCountdown = new ve(), this.barCountdown.setVisible(this.features.barCountdown), this.sessionBreaks = new pt(), this.sessionShading = new mt(), this.compareRenderer = new Ce(), t.sessionBreaks ? this.sessionBreaks.setConfig({
2266
2415
  visible: t.sessionBreaks.visible ?? !0,
2267
2416
  color: t.sessionBreaks.color,
2268
2417
  lineStyle: t.sessionBreaks.lineStyle,
2269
2418
  lineWidth: t.sessionBreaks.lineWidth
2270
- }) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new me(), this.crosshairTooltip = new Oe(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new Qe(), this.pinnedTooltip.create(e), this.pinnedTooltip.setLocale(this.numberLocale), t.priceFormat && this.applyPriceFormat(t.priceFormat), t.chartTypeOptions && (this.chartTypeOptions = S(t.chartTypeOptions)), t.highLowLines && this.priceLines.setHighLow(!0), t.shapes && this.themeManager.setShape(bi(t.shapes)), t.font && this.themeManager.setFont(yi(t.font)), this.priceLines.setPriceText((e) => this.formatPrice(e)), t.extendedHours === !1 && (this.extendedHours = !1), t.timeFormatter && this.applyTimeFormatter(t.timeFormatter), this.keyboardHandler = new Ue({
2419
+ }) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new he(), this.crosshairTooltip = new ke(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new $e(), this.pinnedTooltip.create(e), this.pinnedTooltip.setLocale(this.numberLocale), t.priceFormat && this.applyPriceFormat(t.priceFormat), t.chartTypeOptions && (this.chartTypeOptions = ae(t.chartTypeOptions)), t.highLowLines && this.priceLines.setHighLow(!0), t.shapes && this.themeManager.setShape(Mi(t.shapes)), t.font && this.themeManager.setFont(ji(t.font)), this.priceLines.setPriceText((e) => this.formatPrice(e)), t.extendedHours === !1 && (this.extendedHours = !1), t.timeFormatter && this.applyTimeFormatter(t.timeFormatter), this.keyboardHandler = new We({
2271
2420
  scrollBars: (e) => {
2272
2421
  let t = this.viewport.getState().barWidth + this.viewport.getState().barSpacing;
2273
2422
  this.viewport.scrollBy(e * t), this.updateViewportAndRender();
@@ -2315,8 +2464,8 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
2315
2464
  }
2316
2465
  this.keyboardHandler.handleKey(e) && (e.preventDefault(), this.a11y?.viewMoved());
2317
2466
  }
2318
- }, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new ke(), 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(Pt).map((e) => e.price)), this.alertManager.on("triggered", (e) => {
2319
- this.eventBus.emit("alertTriggered", Y(e)), this.eventBus.emit("dataUpdate", {
2467
+ }, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new Ae(), this.currentPriceLine.setLocale(this.numberLocale), this.priceAxis.setReservedPriceProvider(() => this.currentPriceLine.isVisible() ? this.currentPriceLine.getPrice() : null), this.alertManager = new me(), this.alertManager.setDrawingLevels((e) => this.drawingLevelsNow(e)), this.alertManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.drawingAlerts = new fi(this.alertManager), this.compareRenderer.setReservedLevels(() => this.alertManager.getAlerts().filter(Pt).map((e) => e.price)), this.alertManager.on("triggered", (e) => {
2468
+ this.eventBus.emit("alertTriggered", X(e)), this.eventBus.emit("dataUpdate", {
2320
2469
  kind: "alert",
2321
2470
  alert: "triggered",
2322
2471
  alertId: e.id,
@@ -2324,14 +2473,14 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
2324
2473
  message: e.message
2325
2474
  });
2326
2475
  }), this.alertManager.on("added", (e) => {
2327
- this.eventBus.emit("alertAdd", Y(e));
2476
+ this.eventBus.emit("alertAdd", X(e));
2328
2477
  }), this.alertManager.on("removed", (e) => {
2329
2478
  this.eventBus.emit("alertRemove", { id: e });
2330
2479
  }), this.alertManager.on("expired", (e) => {
2331
- this.eventBus.emit("alertExpired", Y(e));
2480
+ this.eventBus.emit("alertExpired", X(e));
2332
2481
  }), this.alertManager.on("updated", (e) => {
2333
- this.eventBus.emit("alertUpdate", Y(e));
2334
- }), this.signalMarkerManager = new mt(), this.signalMarkerManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.signalMarkerManager.setDataGetter(() => this.series.bars()), this.signalMarkerManager.on("added", (e) => {
2482
+ this.eventBus.emit("alertUpdate", X(e));
2483
+ }), this.signalMarkerManager = new ht(), this.signalMarkerManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.signalMarkerManager.setDataGetter(() => this.series.bars()), this.signalMarkerManager.on("added", (e) => {
2335
2484
  this.eventBus.emit("signalMarkerAdd", {
2336
2485
  id: e.id,
2337
2486
  source: e.source,
@@ -2339,14 +2488,14 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
2339
2488
  });
2340
2489
  }), this.signalMarkerManager.on("removed", (e) => {
2341
2490
  this.eventBus.emit("signalMarkerRemove", { id: e });
2342
- }), this.tradeZoneManager = new bt(), this.tradeZoneManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradeZoneManager.setDataGetter(() => this.series.bars()), this.tradeZoneManager.on("added", (e) => {
2491
+ }), this.tradeZoneManager = new xt(), this.tradeZoneManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradeZoneManager.setDataGetter(() => this.series.bars()), this.tradeZoneManager.on("added", (e) => {
2343
2492
  this.eventBus.emit("tradeZoneAdd", {
2344
2493
  id: e.id,
2345
2494
  direction: e.direction
2346
2495
  });
2347
2496
  }), this.tradeZoneManager.on("removed", (e) => {
2348
2497
  this.eventBus.emit("tradeZoneRemove", { id: e });
2349
- }), this.replayManager = new ot(), this.replayManager.on("complete", () => {
2498
+ }), this.replayManager = new st(), this.replayManager.on("complete", () => {
2350
2499
  let e = this.getReplayBarIndex(), t = this.replayCoarse?.[e];
2351
2500
  t && this.eventBus.emit("replayComplete", {
2352
2501
  barIndex: e,
@@ -2354,9 +2503,9 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
2354
2503
  });
2355
2504
  }), this.replayManager.on("stateChange", (e) => {
2356
2505
  this.replayRestarting || this.eventBus.emit("replayState", { state: e });
2357
- }), this.measureOverlay = new qe(), this.interactionManager = new Ve(e), this.features.panning) {
2358
- let e = new Ar();
2359
- this.interactionManager.setPanHandler(new Ye((t, n) => {
2506
+ }), this.measureOverlay = new Je(), this.interactionManager = new He(e), this.features.panning) {
2507
+ let e = new jr();
2508
+ this.interactionManager.setPanHandler(new Xe((t, n) => {
2360
2509
  t && this.viewport.scrollBy(t), e.step(t, n, this.priceFit.isAuto()) && n && (this.holdPriceScale(), this.viewport.panPriceRange(n)), this.updateViewportAndRender();
2361
2510
  }, () => e.reset()));
2362
2511
  }
@@ -2368,10 +2517,10 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
2368
2517
  scales: !this.indicatorEngine.hasLeftScaleOverlays()
2369
2518
  }
2370
2519
  })), this.features.zooming) {
2371
- this.interactionManager.setZoomHandler(new kt((e, t) => {
2520
+ this.interactionManager.setZoomHandler(new At((e, t) => {
2372
2521
  this.viewport.zoom(e, t - this.viewport.getState().chartRect.x), this.updateViewportAndRender();
2373
2522
  }));
2374
- let e = new ge((e) => {
2523
+ let e = new _e((e) => {
2375
2524
  this.holdPriceScale(), this.viewport.scalePriceRange(e), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents();
2376
2525
  }, (e) => {
2377
2526
  let t = this.viewport.getState().chartRect.width;
@@ -2406,10 +2555,10 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
2406
2555
  ...this.viewport.getState(),
2407
2556
  data: this.getDisplayData()
2408
2557
  })), this.features.alerts) {
2409
- let e = new fe(this.alertManager, () => this.viewport.getState());
2558
+ let e = new pe(this.alertManager, () => this.viewport.getState());
2410
2559
  this.interactionManager.setAlertDragHandler(e);
2411
2560
  }
2412
- let o = new Xe();
2561
+ let o = new Ze();
2413
2562
  o.configure(() => this.getResolvedLayout(), (e, t) => this.setPanelSize(e, t)), this.interactionManager.setPaneResizeHandler(o), this.interactionManager.setAltClickHandler((e) => {
2414
2563
  let t = this.getDisplayData();
2415
2564
  if (t.length === 0) return;
@@ -2478,7 +2627,7 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
2478
2627
  end: () => {
2479
2628
  let e = this.selectionBoxOverlay.end();
2480
2629
  if (e && this.zoomAreaMode) {
2481
- if (e.x1 - e.x0 < di) return;
2630
+ if (e.x1 - e.x0 < Ci) return;
2482
2631
  this.zoomToBox(e), this.setZoomAreaMode(!1);
2483
2632
  return;
2484
2633
  }
@@ -2560,13 +2709,13 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
2560
2709
  let { visibleRange: e, chartRect: t } = this.viewport.getState();
2561
2710
  if (t.width <= 0) return;
2562
2711
  let { from: n, to: r } = e;
2563
- this.history.maybeLoad(Math.max(0, Math.floor(n)), Math.max(ui, r - n));
2712
+ this.history.maybeLoad(Math.max(0, Math.floor(n)), Math.max(Si, r - n));
2564
2713
  }));
2565
2714
  }
2566
2715
  useStreamHistory(e, t, n = !0) {
2567
2716
  if (this.hostHistoryLoader) return;
2568
2717
  let r = N(e), i = r.fetchHistoryBefore, a = this.streamTimeframe;
2569
- if (!i || a === null || ue(a) !== null) {
2718
+ if (!i || a === null || de(a) !== null) {
2570
2719
  this.historyFromStream && this.history.setLoader(null), this.historyFromStream = !1;
2571
2720
  return;
2572
2721
  }
@@ -2661,11 +2810,11 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
2661
2810
  setChartTypeOptions(e) {
2662
2811
  this.chartTypeOptions = {
2663
2812
  ...this.chartTypeOptions,
2664
- ...S(e)
2813
+ ...ae(e)
2665
2814
  }, this.updateViewportAndRender(!0), this.fitFewColumns(), this.a11y?.refresh(!0), this.markStateChanged();
2666
2815
  }
2667
2816
  getChartTypeOptions() {
2668
- return S(this.chartTypeOptions);
2817
+ return ae(this.chartTypeOptions);
2669
2818
  }
2670
2819
  setExtendedHours(e) {
2671
2820
  e !== this.extendedHours && (this.extendedHours = e, this.reapplyExtendedHours(), this.markStateChanged());
@@ -2685,7 +2834,7 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
2685
2834
  return this.priceLines.setQuoteShown(this.replaySession === null), this.priceLines;
2686
2835
  }
2687
2836
  setShapes(e) {
2688
- let t = bi(e);
2837
+ let t = Mi(e);
2689
2838
  t.tagRadius !== void 0 && (this.themeManager.setShape({
2690
2839
  ...this.themeManager.getTheme().shape,
2691
2840
  ...t
@@ -2697,7 +2846,7 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
2697
2846
  setFont(e) {
2698
2847
  if (e === null) this.themeManager.setFont(null);
2699
2848
  else {
2700
- let t = yi(e);
2849
+ let t = ji(e);
2701
2850
  if (Object.keys(t).length === 0) return;
2702
2851
  this.themeManager.setFont(t);
2703
2852
  }
@@ -2813,8 +2962,8 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
2813
2962
  return {
2814
2963
  ...e,
2815
2964
  priceRange: {
2816
- min: t.min - n * li,
2817
- max: t.max + n * li
2965
+ min: t.min - n * xi,
2966
+ max: t.max + n * xi
2818
2967
  },
2819
2968
  logScale: !1,
2820
2969
  scaleMode: "regular",
@@ -2861,7 +3010,7 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
2861
3010
  this.indicatorEngine.setStyleDefaults(e, null);
2862
3011
  return;
2863
3012
  }
2864
- let { plots: n, ...r } = t, i = n === void 0 ? void 0 : ae(n);
3013
+ let { plots: n, ...r } = t, i = n === void 0 ? void 0 : oe(n);
2865
3014
  this.indicatorEngine.setStyleDefaults(e, {
2866
3015
  ...r,
2867
3016
  ...i ? { plots: i } : {}
@@ -2869,7 +3018,7 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
2869
3018
  }
2870
3019
  setPaneStyle(e, t) {
2871
3020
  let n = this.indicatorPanes.paneOf(e);
2872
- this.layoutManager.getPanels().some((e) => e.id === n) && this.indicatorHistory.record(n, () => this.setPaneStyleNow(n, t ? oe(t) : null));
3021
+ this.layoutManager.getPanels().some((e) => e.id === n) && this.indicatorHistory.record(n, () => this.setPaneStyleNow(n, t ? se(t) : null));
2873
3022
  }
2874
3023
  setPaneStyleNow(e, t) {
2875
3024
  this.panes.setStyle(e, t) && (this.syncRenderContext(), this.engine.requestRender(), this.markStateChanged());
@@ -2888,7 +3037,7 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
2888
3037
  return this.pluginManager;
2889
3038
  }
2890
3039
  static indicators() {
2891
- let e = new Be();
3040
+ let e = new Ve();
2892
3041
  return Ht(e), e.getAvailableIndicators();
2893
3042
  }
2894
3043
  setPanelPosition(e, t) {
@@ -3009,7 +3158,7 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
3009
3158
  roundPrice(e) {
3010
3159
  if (!Number.isFinite(e)) return e;
3011
3160
  let t = this.stepAt(e);
3012
- if (t !== void 0) return Number((Math.round(e / t) * t).toFixed(le(t)));
3161
+ if (t !== void 0) return Number((Math.round(e / t) * t).toFixed(ue(t)));
3013
3162
  let { min: n, max: r } = this.viewport.getState().priceRange;
3014
3163
  return Number(e.toFixed(this.marketPricePrecision ?? c(n, r)));
3015
3164
  }
@@ -3106,9 +3255,9 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
3106
3255
  return this.drawingManager.removeDrawings(e);
3107
3256
  }
3108
3257
  nudgeSelectedDrawings(e) {
3109
- let t = pi[e.key];
3258
+ let t = Ti[e.key];
3110
3259
  if (!t || !this.features.drawings || e.ctrlKey || e.metaKey || e.altKey) return !1;
3111
- let n = e.shiftKey ? fi : 1, r = {
3260
+ let n = e.shiftKey ? wi : 1, r = {
3112
3261
  ...this.viewport.getState(),
3113
3262
  data: this.getDisplayData()
3114
3263
  };
@@ -3257,7 +3406,7 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
3257
3406
  }
3258
3407
  applyPriceAxisAdd() {
3259
3408
  let e = this.features.priceAxisAddButton && this.features.crosshair;
3260
- this.priceAxisAddButton.setEnabled(e), this.tradingManager.setTagInset(e ? Je : 0);
3409
+ this.priceAxisAddButton.setEnabled(e), this.tradingManager.setTagInset(e ? Ye : 0);
3261
3410
  }
3262
3411
  setPriceAxisAddButton(e) {
3263
3412
  this.features.priceAxisAddButton = e, this.applyPriceAxisAdd(), this.engine.requestRender(r.Overlay);
@@ -3348,11 +3497,11 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
3348
3497
  }
3349
3498
  getExportText(e = "csv", t = {}) {
3350
3499
  let { bars: n, columns: r } = this.getExportData(t);
3351
- return e === "json" ? D.toJSON(n, r) : D.toCSV(n, r);
3500
+ return e === "json" ? E.toJSON(n, r) : E.toCSV(n, r);
3352
3501
  }
3353
3502
  download(e, t, n) {
3354
3503
  let r = this.getExportText(e, n);
3355
- e === "json" ? D.download(r, t ?? "chart-data.json", "application/json") : D.download(r, t ?? "chart-data.csv", "text/csv");
3504
+ e === "json" ? E.download(r, t ?? "chart-data.json", "application/json") : E.download(r, t ?? "chart-data.csv", "text/csv");
3356
3505
  }
3357
3506
  setAutoSave(e, t = 5e3) {
3358
3507
  this.autoSaveScheduler.enable(e, t);
@@ -3414,7 +3563,7 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
3414
3563
  this.indicatorHistory.record(e, () => this.updateIndicatorStyleNow(e, t));
3415
3564
  }
3416
3565
  updateIndicatorStyleNow(e, t) {
3417
- let { plots: n, ...r } = t, i = n === void 0 ? void 0 : ae(n);
3566
+ let { plots: n, ...r } = t, i = n === void 0 ? void 0 : oe(n);
3418
3567
  this.indicatorEngine.updateIndicatorStyle(e, {
3419
3568
  ...r,
3420
3569
  ...i ? { plots: i } : {}
@@ -3514,21 +3663,12 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
3514
3663
  this.replayTrades() || this.tradingManager.setCurrentPrice(e), this.features.alerts && this.checkAlerts(e);
3515
3664
  }
3516
3665
  checkAlerts(e) {
3517
- let t = this.replaySession ? this.series.liveBars() : this.series.bars();
3518
- this.alertManager.setBarTime(t.length > 0 ? t[t.length - 1].time : null);
3519
- let n = new Map([["price", e]]);
3520
- this.replaySession || this.collectIndicatorValues(n), this.alertManager.checkChannels(n, { together: !0 }), this.alertManager.checkDrawings(e);
3521
- }
3522
- collectIndicatorValues(e) {
3523
- if (this.series.length() === 0) return;
3524
- let t = this.alertManager.getAlerts().flatMap((e) => e.target ? [e.channel, e.target] : [e.channel]);
3525
- for (let n of t) {
3526
- if (e.has(n)) continue;
3527
- let t = n.indexOf(":");
3528
- if (t < 0) continue;
3529
- let r = this.indicatorEngine.getOutput(n.slice(0, t))?.series, i = r?.[r.length - 1]?.[n.slice(t + 1)];
3530
- typeof i == "number" && Number.isFinite(i) && e.set(n, i);
3531
- }
3666
+ let t = this.replaySession ? this.series.liveBars() : this.series.bars(), n = this.replaySession || this.series.length() === 0 ? null : (e) => this.indicatorEngine.getOutput(e)?.series;
3667
+ oi(this.alertManager, {
3668
+ price: e,
3669
+ barTime: t.length > 0 ? t[t.length - 1].time : null,
3670
+ lines: n
3671
+ });
3532
3672
  }
3533
3673
  setTradingConfig(e) {
3534
3674
  this.features.trading && this.tradingManager.setConfig(e);
@@ -3540,7 +3680,7 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
3540
3680
  feed: void 0
3541
3681
  };
3542
3682
  if (!A(t.adapter, t.timeframe)) throw RangeError(`${t.adapter.name} cannot serve the ${t.timeframe} timeframe`);
3543
- this.snapshotKey = null, this.holdReplayFor(t.symbol), this.disconnectStream(), this.streamManager = new _t(), this.streamManager.setTimeZone(this.studyZoneHeld ? this.studyZone : this.getExchangeTimeZone()), this.streamManager.on("snapshot", (e) => {
3683
+ this.snapshotKey = null, this.holdReplayFor(t.symbol), this.disconnectStream(), this.streamManager = new vt(), this.streamManager.setTimeZone(this.studyZoneHeld ? this.studyZone : this.getExchangeTimeZone()), this.streamManager.on("snapshot", (e) => {
3544
3684
  let n = this.streamSeriesKey(t.adapter);
3545
3685
  n === this.snapshotKey && this.replaySession ? this.series.mergeSnapshot(e) : n === this.snapshotKey && this.series.length() > 0 ? this.mergeSnapshot(e) : (this.replaySession && this.useStreamHistory(t.adapter, t.historyPageSize, !1), this.setData(e)), this.snapshotKey = n, this.useStreamHistory(t.adapter, t.historyPageSize);
3546
3686
  }), this.streamManager.on("barClose", (e) => {
@@ -3596,18 +3736,18 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
3596
3736
  }), this.streamManager.on("symbolInfo", (e) => this.applyFeedSymbolInfo(e)), this.autoScrollOnNewBar = t.autoScroll !== !1, this.setStreamTarget(t.symbol, t.timeframe), this.streamAdapter = t.adapter;
3597
3737
  let n = this.streamManager;
3598
3738
  if (this.resolveStreamSymbol(t.adapter, t.symbol), await n.connect(t), this.streamManager !== n) return;
3599
- let i = T(t.timeframe);
3739
+ let i = w(t.timeframe);
3600
3740
  this.barCountdown.setTimeframeMs(i), this.countdownInterval && clearInterval(this.countdownInterval), this.countdownInterval = setInterval(() => {
3601
3741
  this.barCountdown.isVisible() && this.engine.requestRender(r.Hover);
3602
3742
  }, 1e3);
3603
3743
  }
3604
3744
  streamSeriesKey(e) {
3605
- let t = N(e), n = this.streamTimeframe, r = t instanceof st && n !== null ? t.bucketFor(this.currentSymbol, n) : null;
3745
+ let t = N(e), n = this.streamTimeframe, r = t instanceof ct && n !== null ? t.bucketFor(this.currentSymbol, n) : null;
3606
3746
  return `${this.currentSymbol}|${n}|${r?.timeZone ?? ""}`;
3607
3747
  }
3608
3748
  setStreamTarget(e, t) {
3609
3749
  let n = this.announcedSymbol;
3610
- 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", {
3750
+ this.currentSymbol = e, this.streamTimeframe = t, this.tickStream = de(t) !== null, this.applyTimeSpacing(), e !== n && this.chartLegend.setSymbol(e), e !== n && (this.announcedSymbol = e, this.eventBus.emit("symbolChange", {
3611
3751
  symbol: e,
3612
3752
  previous: n
3613
3753
  })), this.useTimeframe(t);
@@ -3626,7 +3766,7 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
3626
3766
  if (!this.streamManager) return;
3627
3767
  let n = this.streamAdapter;
3628
3768
  if (n && !A(n, t)) throw RangeError(`${n.name} cannot serve the ${t} timeframe`);
3629
- this.holdReplayFor(e), this.setStreamTarget(e, t), this.historyFromStream && this.history.setLoader(null), this.barCountdown.setTimeframeMs(T(t)), n && this.resolveStreamSymbol(n, e), await this.streamManager.switchTo(e, t);
3769
+ 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);
3630
3770
  }
3631
3771
  isIndicatorAllowed(e) {
3632
3772
  let t = this.features.indicatorIds;
@@ -3645,7 +3785,7 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
3645
3785
  }
3646
3786
  connectExecution(e, t = {}) {
3647
3787
  if (!this.features.trading) throw Error("connectExecution requires features.trading to be enabled");
3648
- this.disconnectExecution(), this.executionAdapter = e, this.execTeardown = Br(e, {
3788
+ this.disconnectExecution(), this.executionAdapter = e, this.execTeardown = Vr(e, {
3649
3789
  onIntent: (e, t) => {
3650
3790
  let n = (e) => t(e.payload);
3651
3791
  return this.eventBus.on(e, n), () => this.eventBus.off(e, n);
@@ -3974,7 +4114,7 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
3974
4114
  }
3975
4115
  let t = this.crosshairSeries(), n = e >= 0 && e < t.length ? t[e] : void 0, r = n && e > 0 ? t[e - 1] : void 0;
3976
4116
  this.crosshairHandler.getPosition() || this.chartLegend.setHoverBar(n ?? null, r ?? null);
3977
- let i = n ? At(t)[e]?.time ?? n.time : void 0;
4117
+ let i = n ? k(t)[e]?.time ?? n.time : void 0;
3978
4118
  this.eventBus.emit("crosshairSync", {
3979
4119
  barIndex: e,
3980
4120
  ...n ? { bar: n } : {},
@@ -4053,7 +4193,7 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
4053
4193
  return this.periodLevels.getPeriod();
4054
4194
  }
4055
4195
  setTimeZone(e) {
4056
- si(e), this.timeZoneSetting = e, this.applyTimeZone();
4196
+ yi(e), this.timeZoneSetting = e, this.applyTimeZone();
4057
4197
  }
4058
4198
  getTimeZone() {
4059
4199
  return this.timeZoneSetting;
@@ -4062,7 +4202,7 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
4062
4202
  return this.displayTz;
4063
4203
  }
4064
4204
  getExchangeTimeZone() {
4065
- return [w(this.symbolInfo), this.marketConfig?.timeZone].find((e) => e && y(e)) ?? null;
4205
+ return [C(this.symbolInfo), this.marketConfig?.timeZone].find((e) => e && y(e)) ?? null;
4066
4206
  }
4067
4207
  setTimezone(e) {
4068
4208
  this.setTimeZone(e);
@@ -4089,7 +4229,7 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
4089
4229
  this.indicatorEngine.setExchangeTimeZone(e, t.length > 0 ? t : void 0) && t.length > 0 && this.announceIndicatorUpdate(0);
4090
4230
  }
4091
4231
  holdStudyZone() {
4092
- this.endStudyZoneWait(), this.studyZoneHeld = !0, this.studyZoneTimer = setTimeout(() => this.releaseStudyZone(), ut);
4232
+ this.endStudyZoneWait(), this.studyZoneHeld = !0, this.studyZoneTimer = setTimeout(() => this.releaseStudyZone(), dt);
4093
4233
  }
4094
4234
  endStudyZoneWait() {
4095
4235
  this.studyZoneReleaseQueued = !1, this.studyZoneTimer !== null && (clearTimeout(this.studyZoneTimer), this.studyZoneTimer = null);
@@ -4104,7 +4244,7 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
4104
4244
  }
4105
4245
  spokenBarTime(e) {
4106
4246
  let t = this.getDisplayData(), n = e * u(t), r = this.numberLocale || "en-US";
4107
- return d(t) === !0 ? de(r, { dateStyle: "medium" }, l(n, this.displayTz, this.getExchangeTimeZone()))(n) : de(r, {
4247
+ return d(t) === !0 ? fe(r, { dateStyle: "medium" }, l(n, this.displayTz, this.getExchangeTimeZone()))(n) : fe(r, {
4108
4248
  dateStyle: "medium",
4109
4249
  timeStyle: "short"
4110
4250
  }, this.displayTz)(n);
@@ -4117,18 +4257,18 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
4117
4257
  this.studyZoneHeld = !1, this.endStudyZoneWait(), this.useSymbolInfo(e);
4118
4258
  }
4119
4259
  useSymbolInfo(e) {
4120
- let t = e && this.symbolInfo?.symbol === e.symbol ? w(this.symbolInfo) : void 0;
4121
- this.symbolInfo = e ? ci({
4260
+ let t = e && this.symbolInfo?.symbol === e.symbol ? C(this.symbolInfo) : void 0;
4261
+ this.symbolInfo = e ? bi({
4122
4262
  ...e,
4123
4263
  sessions: e.sessions?.map((e) => ({ ...e }))
4124
4264
  }, 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);
4125
4265
  let n = (this.symbolInfo?.sessions ?? []).flatMap((e) => {
4126
- let t = C(e.start), n = C(e.end);
4266
+ let t = S(e.start), n = S(e.end);
4127
4267
  return t === null || n === null ? [] : [{
4128
4268
  startMinute: t,
4129
4269
  endMinute: n
4130
4270
  }];
4131
- }), i = w(this.symbolInfo);
4271
+ }), i = C(this.symbolInfo);
4132
4272
  this.sessionShading.replaceConfig(n.length > 0 && i && y(i) ? {
4133
4273
  timeZone: i,
4134
4274
  windows: n,
@@ -4143,11 +4283,11 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
4143
4283
  if (!e || typeof e != "object") return;
4144
4284
  let t = this.currentSymbol, n = (e) => !e || e.toUpperCase() === t.toUpperCase();
4145
4285
  if (!n(e.symbol)) return;
4146
- let r = this.symbolInfo && n(this.symbolInfo.symbol) ? this.symbolInfo : null, i = ci({
4286
+ let r = this.symbolInfo && n(this.symbolInfo.symbol) ? this.symbolInfo : null, i = bi({
4147
4287
  ...r,
4148
4288
  ...e,
4149
4289
  symbol: e.symbol || r?.symbol || t
4150
- }, w(r));
4290
+ }, C(r));
4151
4291
  r && JSON.stringify(i) === JSON.stringify(r) || (this.symbolInfoSeq++, this.setSymbolInfo(i));
4152
4292
  }
4153
4293
  resolveStreamSymbol(e, t) {
@@ -4230,7 +4370,7 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
4230
4370
  this.engine.getGpu() && this.engine.renderNow();
4231
4371
  }
4232
4372
  screenshot(e) {
4233
- this.features.screenshot && (this.freshFrame(), k.download(this.container, e, this.themeManager.getTheme().background));
4373
+ this.features.screenshot && (this.freshFrame(), O.download(this.container, e, this.themeManager.getTheme().background));
4234
4374
  }
4235
4375
  async copyScreenshot() {
4236
4376
  if (!this.features.screenshot) return !1;
@@ -4238,7 +4378,7 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
4238
4378
  if (!t?.write || !e) return !1;
4239
4379
  try {
4240
4380
  this.freshFrame();
4241
- let n = k.toBlob(this.container, this.themeManager.getTheme().background).then((e) => {
4381
+ let n = O.toBlob(this.container, this.themeManager.getTheme().background).then((e) => {
4242
4382
  if (!e) throw Error("No chart image to copy");
4243
4383
  return e;
4244
4384
  });
@@ -4256,10 +4396,10 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
4256
4396
  }
4257
4397
  }
4258
4398
  screenshotDataURL() {
4259
- return this.features.screenshot ? (this.freshFrame(), k.toDataURL(this.container, this.themeManager.getTheme().background)) : null;
4399
+ return this.features.screenshot ? (this.freshFrame(), O.toDataURL(this.container, this.themeManager.getTheme().background)) : null;
4260
4400
  }
4261
4401
  async screenshotBlob() {
4262
- return this.features.screenshot ? (this.freshFrame(), k.toBlob(this.container, this.themeManager.getTheme().background)) : null;
4402
+ return this.features.screenshot ? (this.freshFrame(), O.toBlob(this.container, this.themeManager.getTheme().background)) : null;
4263
4403
  }
4264
4404
  addAlert(e, t = "crossing", n, r = "price", i, a = {}) {
4265
4405
  if (!this.features.alerts) return null;
@@ -4312,19 +4452,10 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
4312
4452
  return this.drawingManager.priceAt(e, t[t.length - 1].time, n);
4313
4453
  }
4314
4454
  followDrawingAlerts(e, t) {
4315
- if (!(!t || !this.alertManager)) {
4316
- if (e === "drawingRemove") {
4317
- let e = this.alertManager.takeDrawingAlerts(t);
4318
- e.length > 0 && this.removedDrawingAlerts.set(t, e);
4319
- } else if (e === "drawingCreate") {
4320
- let e = this.removedDrawingAlerts.get(t);
4321
- if (!e) return;
4322
- this.removedDrawingAlerts.delete(t), this.alertManager.restoreAlerts(e);
4323
- }
4324
- }
4455
+ !t || !this.drawingAlerts || (e === "drawingRemove" ? this.drawingAlerts.removed(t) : e === "drawingCreate" && this.drawingAlerts.created(t));
4325
4456
  }
4326
4457
  dropOrphanDrawingAlerts() {
4327
- this.removedDrawingAlerts.clear(), this.alertManager && this.alertManager.pruneDrawingAlerts(new Set(this.drawingManager.getDrawings().map((e) => e.id))) > 0 && this.markStateChanged();
4458
+ this.drawingAlerts && this.drawingAlerts.prune(new Set(this.drawingManager.getDrawings().map((e) => e.id))) > 0 && this.markStateChanged();
4328
4459
  }
4329
4460
  addDrawingAlert(e, t = {}) {
4330
4461
  if (!this.canAddDrawingAlert(e)) return null;
@@ -4387,24 +4518,24 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
4387
4518
  let t = this.replaySession ? this.replayOffset : 0;
4388
4519
  if (!this.replaySession) {
4389
4520
  if (this.series.length() === 0) return;
4390
- this.series.beginReplay(), this.replaySession = Ti(this.currentSymbol);
4521
+ this.series.beginReplay(), this.replaySession = Li(this.currentSymbol);
4391
4522
  }
4392
4523
  let n = this.replaySession, { steps: r, startTime: i, hideHistory: a, revealMarks: o, step: s, ...c } = e ?? {};
4393
4524
  c.animate = c.animate === !0;
4394
4525
  let l = this.series.inHoursShown(this.series.liveBars()), u = t > 0 && i === void 0 && a !== !1, d = c.startIndex;
4395
- i !== void 0 && d === void 0 ? d = X(l, i) : u && d !== void 0 && (d += t);
4526
+ i !== void 0 && d === void 0 ? d = J(l, i) : u && d !== void 0 && (d += t);
4396
4527
  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;
4397
4528
  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);
4398
4529
  let m = r ? this.replayStepsOver(n, p, !0) : null;
4399
4530
  this.priceFit.resume(), this.buildReplay(p, m, f);
4400
4531
  let h = this.replayStepsSeries;
4401
- h && c.startIndex !== void 0 && (c.startIndex = Fi(h, p, c.startIndex));
4532
+ h && c.startIndex !== void 0 && (c.startIndex = Wi(h, p, c.startIndex));
4402
4533
  let g = h ?? p, _ = g[Math.max(0, Math.min(Math.floor(Number(c.startIndex ?? 0)) || 0, g.length - 1))];
4403
4534
  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);
4404
4535
  }
4405
4536
  buildReplay(e, t, n) {
4406
4537
  let r = this.replaySession?.animate === !0, i = r ? null : t;
4407
- this.replayPieces = r && t ? Ri(t, e) : null, this.replayForming = null, this.replayOffset = n, this.replayStepsSeries = i, this.replayCoarse = e;
4538
+ this.replayPieces = r && t ? qi(t, e) : null, this.replayForming = null, this.replayOffset = n, this.replayStepsSeries = i, this.replayCoarse = e;
4408
4539
  let a = this.replayRestarting;
4409
4540
  this.replayRestarting = !0;
4410
4541
  try {
@@ -4418,7 +4549,7 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
4418
4549
  let n = t, a = e[t];
4419
4550
  if (i) {
4420
4551
  let r = i[t];
4421
- n = Q(e, r.time), c = c !== null && s === t - 1 && n === o - 1 && c ? Bi(c, r) : Ii(e[n], i, t), a = Li(i, e, t, n) ? e[n] : c;
4552
+ n = Q(e, r.time), c = c !== null && s === t - 1 && n === o - 1 && c ? Yi(c, r) : Gi(e[n], i, t), a = Ki(i, e, t, n) ? e[n] : c;
4422
4553
  }
4423
4554
  let u = this.replayForming;
4424
4555
  this.replayForming = null, s = t;
@@ -4442,7 +4573,7 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
4442
4573
  });
4443
4574
  }), r && (this.replayPhaseUnsub = this.replayManager.on("phase", ({ index: t, fraction: n }) => {
4444
4575
  if (!e[t] || this.series.length() !== o || o !== t && o !== t + 1) return;
4445
- let r = this.replayForming?.index === t ? this.replayForming.path : this.replayPathOf(e, t), i = zi() ? ti(r, n) : n, a = o === t, s = a && this.autoScrollOnNewBar && this.viewport.isAtEnd(), c = ei(r, i);
4576
+ let r = this.replayForming?.index === t ? this.replayForming.path : this.replayPathOf(e, t), i = Ji() ? ni(r, n) : n, a = o === t, s = a && this.autoScrollOnNewBar && this.viewport.isAtEnd(), c = ti(r, i);
4446
4577
  a ? this.series.appendReplayed(c) : this.series.updateReplayed(c), o = t + 1, this.replayForming = {
4447
4578
  index: t,
4448
4579
  path: r
@@ -4460,22 +4591,22 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
4460
4591
  }
4461
4592
  replayPathOf(e, t) {
4462
4593
  let n = e[t];
4463
- return Yr(n, this.replayPieces?.get(n.time) ?? this.replayLoader?.loader.piecesOf(n.time) ?? []);
4594
+ return Xr(n, this.replayPieces?.get(n.time) ?? this.replayLoader?.loader.piecesOf(n.time) ?? []);
4464
4595
  }
4465
4596
  loadReplaySteps(e, t) {
4466
4597
  let n = this.replayLoader?.loader;
4467
4598
  if (!n) return;
4468
4599
  n.evictBefore(e[t].time);
4469
4600
  let r = this.replayManager.getStepMs();
4470
- n.ensure(e, t, Number.isFinite(r) && r > 0 ? Math.ceil(xi / r) : 1);
4601
+ n.ensure(e, t, Number.isFinite(r) && r > 0 ? Math.ceil(Ni / r) : 1);
4471
4602
  }
4472
4603
  useReplayLoader(e, t) {
4473
- let n = this.streamAdapter, r = this.streamTimeframe, i = e.step && n && r !== null ? ii(e.step, r, (e) => A(n, e)) : null, a = `${this.currentSymbol}|${r}|${i}`;
4604
+ let n = this.streamAdapter, r = this.streamTimeframe, i = e.step && n && r !== null ? ai(e.step, r, (e) => A(n, e)) : null, a = `${this.currentSymbol}|${r}|${i}`;
4474
4605
  if (!t && this.replayLoader?.key === a || (this.replayLoader?.loader.dispose(), this.replayLoader = null, !i || !n || r === null)) return;
4475
- let o = N(n), s = o.fetchHistoryBefore, c = this.currentSymbol, l = T(r), u = new Hr({
4606
+ let o = N(n), s = o.fetchHistoryBefore, c = this.currentSymbol, l = w(r), u = new Ur({
4476
4607
  source: s ? (e, t) => s.call(o, c, i, e, t) : null,
4477
4608
  step: i,
4478
- ratio: Math.max(1, Math.round(l / T(i))),
4609
+ ratio: Math.max(1, Math.round(l / w(i))),
4479
4610
  barMs: l,
4480
4611
  keep: (e) => this.series.inHoursShown(e),
4481
4612
  report: (e) => this.eventBus.emit("replayStepsLoad", e)
@@ -4486,26 +4617,20 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
4486
4617
  };
4487
4618
  }
4488
4619
  feedReplayForming(e, t, n, r) {
4489
- let i = this.replaySession, a = this.executionAdapter, o = e[t];
4490
- if (!i || !a?.setMarkPrice || !o) return;
4491
- let s = i.fedTime;
4492
- if (s === null) {
4493
- i.fedTime = o.time, i.fedFraction = r, this.feedReplayPrice(ei(n, r).close, o.time);
4494
- return;
4495
- }
4496
- if (o.time < s || o.time === s && r <= i.fedFraction) return;
4497
- let c = [];
4498
- if (o.time > s) {
4499
- let a = X(e, s);
4500
- e[a]?.time === s && i.fedFraction < 1 && c.push(...J(this.replayPathOf(e, a), i.fedFraction, 1));
4501
- let o = e.slice(Z(e, s), t), l = Math.ceil(o.length / ji);
4502
- for (let e = 0; e < o.length; e += l) c.push(...Mi(o.slice(e, e + l)));
4503
- c.push(...J(n, -1, r));
4504
- } else c.push(...J(n, i.fedFraction, r));
4505
- i.fedTime = o.time, i.fedFraction = r;
4506
- for (let [e, t] of c) a.setMarkPrice(e, t);
4507
- let l = c[c.length - 1]?.[0];
4508
- l !== void 0 && this.tradingManager.setCurrentPrice(l);
4620
+ let i = this.replaySession;
4621
+ if (!i || !this.executionAdapter?.setMarkPrice) return;
4622
+ let a = gi(e, t, n, r, {
4623
+ time: i.fedTime,
4624
+ fraction: i.fedFraction
4625
+ }, (e, t) => this.replayPathOf(e, t));
4626
+ a && (i.fedTime = a.fed.time, i.fedFraction = a.fed.fraction, this.feedReplayMarks(a.marks));
4627
+ }
4628
+ feedReplayMarks(e) {
4629
+ let t = this.executionAdapter;
4630
+ if (!t?.setMarkPrice) return;
4631
+ for (let [n, r] of e) t.setMarkPrice(n, r);
4632
+ let n = e[e.length - 1]?.[0];
4633
+ n !== void 0 && this.tradingManager.setCurrentPrice(n);
4509
4634
  }
4510
4635
  followLiveChange(e) {
4511
4636
  let t = this.replaySession;
@@ -4516,9 +4641,9 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
4516
4641
  if (!t) return;
4517
4642
  let n = this.series.inHoursShown(this.series.liveBars());
4518
4643
  if (n.length === 0) return;
4519
- let r = t.windowTime === null ? 0 : Math.min(X(n, t.windowTime), n.length - 1), i = r > 0 ? n.slice(r) : n;
4644
+ let r = t.windowTime === null ? 0 : Math.min(J(n, t.windowTime), n.length - 1), i = r > 0 ? n.slice(r) : n;
4520
4645
  this.useReplayLoader(t, !1);
4521
- let a = this.replayStepsOver(t, i), o = t.animate ? null : a, s = t.until === null ? 0 : Oi(o ?? i, t.until);
4646
+ let a = this.replayStepsOver(t, i), o = t.animate ? null : a, s = t.until === null ? 0 : Bi(o ?? i, t.until);
4522
4647
  if (s < 0 && this.canPageBackForReplay(t)) {
4523
4648
  this.holdReplay(), t.held && t.held.pagesBack++, queueMicrotask(() => void this.pageBackForReplay(t));
4524
4649
  return;
@@ -4526,7 +4651,7 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
4526
4651
  let c = this.getReplayState(), l = t.held !== null && (e === "hours" || e === "bar"), u = t.held?.state ?? c;
4527
4652
  l || (t.held = null), t.symbol = this.currentSymbol;
4528
4653
  let d = this.replayManager.remainingMs();
4529
- this.clearBarHolders(), t.animate && Di(t, this.replayCoarse, i);
4654
+ this.clearBarHolders(), t.animate && zi(t, this.replayCoarse, i);
4530
4655
  let f = this.replayRestarting;
4531
4656
  this.replayRestarting = !0, this.replayCause = e === "older" ? "older" : "series";
4532
4657
  try {
@@ -4549,14 +4674,14 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
4549
4674
  }
4550
4675
  replayStepsOver(e, t, n = !1) {
4551
4676
  if (!e.steps || e.stepsSymbol !== this.currentSymbol) return null;
4552
- let r = Pi(this.series.inHoursShown(e.steps), t);
4553
- return r && (n || Ai(r, t)) ? r : null;
4677
+ let r = Ui(this.series.inHoursShown(e.steps), t);
4678
+ return r && (n || Hi(r, t)) ? r : null;
4554
4679
  }
4555
4680
  canPageBackForReplay(e) {
4556
- return this.history.hasLoader() && this.history.hasMore() && (e.held?.pagesBack ?? 0) < Si;
4681
+ return this.history.hasLoader() && this.history.hasMore() && (e.held?.pagesBack ?? 0) < Pi;
4557
4682
  }
4558
4683
  async pageBackForReplay(e) {
4559
- this.replaySession !== e || !e.held || await this.history.loadMore() > 0 || this.replaySession !== e || !e.held || (e.held.pagesBack = Si, this.rebaseReplay("older"));
4684
+ this.replaySession !== e || !e.held || await this.history.loadMore() > 0 || this.replaySession !== e || !e.held || (e.held.pagesBack = Pi, this.rebaseReplay("older"));
4560
4685
  }
4561
4686
  holdReplay() {
4562
4687
  let e = this.replaySession;
@@ -4589,7 +4714,7 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
4589
4714
  this.signalMarkerManager.setRevealUntil(e, t), this.tradeZoneManager.setRevealUntil(e, t);
4590
4715
  }
4591
4716
  replaySeekToTime(e) {
4592
- !this.replaySession || !this.replayCoarse || this.replaySeek(Math.max(0, Oi(this.replayStepsSeries ?? this.replayCoarse, e)));
4717
+ !this.replaySession || !this.replayCoarse || this.replaySeek(Math.max(0, Bi(this.replayStepsSeries ?? this.replayCoarse, e)));
4593
4718
  }
4594
4719
  feedReplayPrice(e, t) {
4595
4720
  let n = this.executionAdapter;
@@ -4602,18 +4727,13 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
4602
4727
  n !== void 0 && this.feedReplayPrice(n);
4603
4728
  }
4604
4729
  feedReplaySteps(e, t) {
4605
- let n = this.replaySession, r = this.executionAdapter, i = e[t];
4606
- if (!n || !r?.setMarkPrice || !i) return;
4607
- if (n.fedTime === null) {
4608
- n.fedTime = i.time, this.feedReplayPrice(i.close, i.time);
4609
- return;
4610
- }
4611
- if (i.time <= n.fedTime) return;
4612
- let a = e.slice(Z(e, n.fedTime), t + 1);
4613
- n.fedTime = i.time;
4614
- let o = Math.ceil(a.length / ji);
4615
- for (let e = 0; e < a.length; e += o) for (let [t, n] of Mi(a.slice(e, e + o))) r.setMarkPrice(t, n);
4616
- this.tradingManager.setCurrentPrice(i.close);
4730
+ let n = this.replaySession;
4731
+ if (!n || !this.executionAdapter?.setMarkPrice) return;
4732
+ let r = hi(e, t, {
4733
+ time: n.fedTime,
4734
+ fraction: n.fedFraction
4735
+ });
4736
+ r && (n.fedTime = r.fed.time, this.feedReplayMarks(r.marks));
4617
4737
  }
4618
4738
  getReplayBarIndex() {
4619
4739
  if (!this.replaySession) return -1;
@@ -4623,7 +4743,7 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
4623
4743
  }
4624
4744
  replaySeekToBar(e) {
4625
4745
  let t = this.replayStepsSeries;
4626
- this.replaySeek(t && this.replayCoarse ? Fi(t, this.replayCoarse, e) : e);
4746
+ this.replaySeek(t && this.replayCoarse ? Wi(t, this.replayCoarse, e) : e);
4627
4747
  }
4628
4748
  replayPause() {
4629
4749
  this.setHeldState("paused") || this.replayManager.pause();
@@ -4664,7 +4784,7 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
4664
4784
  let { x: r, y: c } = this.drawingManager.anchorPoint(t.type, e, n);
4665
4785
  i = Math.min(i, r), a = Math.max(a, r), o = Math.min(o, c), s = Math.max(s, c);
4666
4786
  }
4667
- return mi.has(t.type) ? [i, a] = [r.x, r.x + r.width] : t.type === "horizontalRay" && (a = r.x + r.width), hi.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 ? {
4787
+ return Ei.has(t.type) ? [i, a] = [r.x, r.x + r.width] : t.type === "horizontalRay" && (a = r.x + r.width), Di.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 ? {
4668
4788
  x: i,
4669
4789
  y: o,
4670
4790
  width: a - i,
@@ -4700,7 +4820,7 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
4700
4820
  };
4701
4821
  }
4702
4822
  captureSnapshot() {
4703
- return E.capture({
4823
+ return T.capture({
4704
4824
  getDrawings: () => [...this.getDrawings().filter((e) => e.paneId === void 0 || this.layoutManager.getPanels().some((t) => t.id === e.paneId)), ...this.keptPaneDrawings],
4705
4825
  getTheme: () => this.themeManager.getBaseTheme(),
4706
4826
  getAlerts: () => this.getAlerts(),
@@ -4713,12 +4833,12 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
4713
4833
  });
4714
4834
  }
4715
4835
  restoreIndicators(e, t) {
4716
- let n = er(e), r = /* @__PURE__ */ new Map();
4836
+ let n = tr(e), r = /* @__PURE__ */ new Map();
4717
4837
  this.unrestoredIndicators = [];
4718
4838
  let i = new Set(this.indicatorEngine.getAvailableIndicators().map((e) => e.id)), a = [], o = /* @__PURE__ */ new Set();
4719
4839
  if (t) {
4720
4840
  let e = this.getIndicatorSetup();
4721
- for (let t of nr(e, n)) o.add(t);
4841
+ for (let t of rr(e, n)) o.add(t);
4722
4842
  for (let t of e) o.has(t.instanceId) || this.removeIndicator(t.instanceId);
4723
4843
  let t = new Map(e.map((e) => [e.instanceId, e.pane]));
4724
4844
  for (let e = !0; e;) {
@@ -4729,7 +4849,7 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
4729
4849
  }
4730
4850
  }
4731
4851
  } else for (let e of this.indicatorEngine.getActiveIndicators()) this.removeIndicator(e.instanceId);
4732
- let s = (e) => ir(e, r);
4852
+ let s = (e) => ar(e, r);
4733
4853
  for (let e of n) {
4734
4854
  let n = null;
4735
4855
  if (o.has(e.instanceId)) {
@@ -4762,7 +4882,7 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
4762
4882
  }
4763
4883
  r.set(e.instanceId, n), a.push([e, n]), this.restoreLooks(n, e);
4764
4884
  }
4765
- return this.indicatorEngine.orderIndicators(e.flatMap((e) => r.get(e.instanceId) ?? [])), $n(this.layoutManager, a), this.updateViewportAndRender(), r;
4885
+ return this.indicatorEngine.orderIndicators(e.flatMap((e) => r.get(e.instanceId) ?? [])), er(this.layoutManager, a), this.updateViewportAndRender(), r;
4766
4886
  }
4767
4887
  restoreLooks(e, t) {
4768
4888
  let { plots: n, ...r } = this.indicatorEngine.getIndicatorStyle(e) ?? {
@@ -4779,10 +4899,10 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
4779
4899
  let s = t.levels ?? null;
4780
4900
  JSON.stringify(s) !== JSON.stringify(o?.levels ?? null) && this.setIndicatorLevels(e, s);
4781
4901
  let c = t.intervals ?? null;
4782
- JSON.stringify(c) !== JSON.stringify(o?.intervals ?? null) && this.setIndicatorIntervalsNow(e, c), this.setPaneStyleNow(e, t.paneStyle ? oe(t.paneStyle) : null);
4902
+ JSON.stringify(c) !== JSON.stringify(o?.intervals ?? null) && this.setIndicatorIntervalsNow(e, c), this.setPaneStyleNow(e, t.paneStyle ? se(t.paneStyle) : null);
4783
4903
  }
4784
4904
  getIndicatorSetup() {
4785
- return [...Qn(this.indicatorEngine, this.layoutManager, (e) => this.panes.style(e) ?? null), ...this.unrestoredIndicators];
4905
+ return [...$n(this.indicatorEngine, this.layoutManager, (e) => this.panes.style(e) ?? null), ...this.unrestoredIndicators];
4786
4906
  }
4787
4907
  applyIndicatorSetup(e) {
4788
4908
  this.features.indicators && this.indicatorHistory.record(void 0, () => {
@@ -4791,27 +4911,7 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
4791
4911
  });
4792
4912
  }
4793
4913
  followIndicatorAlerts(e, t) {
4794
- if (!this.features.alerts) return;
4795
- let n = (n) => {
4796
- let r = n.indexOf(":");
4797
- if (r <= 0) return null;
4798
- let i = n.slice(0, r), a = e.get(i);
4799
- if (!a || this.indicatorEngine.getIndicatorConfig(i)) return null;
4800
- let o = t.filter((e) => this.indicatorEngine.getIndicatorConfig(e)?.id === a);
4801
- return o.length === 1 ? o[0] + n.slice(r) : null;
4802
- };
4803
- for (let e of this.alertManager.getAlerts()) {
4804
- let t = n(e.channel), r = e.target ? n(e.target) : null;
4805
- if (!t && !r) continue;
4806
- let { target: i, percent: a, bars: o, onBarClose: s, expiresAt: c } = e;
4807
- this.alertManager.removeAlert(e.id), this.alertManager.addAlert(e.price, e.condition, e.message, e.repeating, t ?? e.channel, e.label, {
4808
- ...e.target ? { target: r ?? e.target } : {},
4809
- ...a === void 0 ? {} : { percent: a },
4810
- ...o === void 0 ? {} : { bars: o },
4811
- ...s ? { onBarClose: s } : {},
4812
- ...c === void 0 ? {} : { expiresAt: c }
4813
- });
4814
- }
4914
+ this.features.alerts && ci(this.alertManager, e, t, (e) => this.indicatorEngine.getIndicatorConfig(e)?.id);
4815
4915
  }
4816
4916
  beginIndicatorEdit(e) {
4817
4917
  this.indicatorHistory.begin(e);
@@ -4835,71 +4935,49 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
4835
4935
  keptPaneDrawings = [];
4836
4936
  replayingIndicatorStep = !1;
4837
4937
  takesDrawing(e, t) {
4838
- return ur(this.layoutManager.getPanels(), e, !!this.drawingManager.getDescriptor(t)?.priceOnly);
4938
+ return dr(this.layoutManager.getPanels(), e, !!this.drawingManager.getDescriptor(t)?.priceOnly);
4839
4939
  }
4840
4940
  renamePane(e, t) {
4841
4941
  this.layoutManager.renamePanel(e, t), this.replayingIndicatorStep || this.drawingManager.renamePanes(new Map([[e, t]])), this.indicatorHistory.renamed(e, t);
4842
4942
  }
4843
4943
  drawingPaneAt(e) {
4844
- return cr(e, this.viewport.getState().chartRect, this.layoutManager.getPanels(), (e) => this.drawingPaneViewport(e));
4944
+ return lr(e, this.viewport.getState().chartRect, this.layoutManager.getPanels(), (e) => this.drawingPaneViewport(e));
4845
4945
  }
4846
4946
  drawingPaneViewport(e) {
4847
4947
  let t = this.layoutManager.getPanels().find((t) => t.id === e);
4848
- return lr(t, !!t && this.layoutManager.isPanelShownCollapsed(e), () => this.buildPanelRenderInfos().find((t) => t.instanceId === e)?.viewport, () => this.getDisplayData());
4948
+ return ur(t, !!t && this.layoutManager.isPanelShownCollapsed(e), () => this.buildPanelRenderInfos().find((t) => t.instanceId === e)?.viewport, () => this.getDisplayData());
4849
4949
  }
4850
4950
  saveState(e) {
4851
4951
  if (!this.features.saveLoad) return null;
4852
- let t = this.captureSnapshot(), n = E.serialize(t);
4853
- return e && E.saveToStorage(e, t), n;
4952
+ let t = this.captureSnapshot(), n = T.serialize(t);
4953
+ return e && T.saveToStorage(e, t), n;
4854
4954
  }
4855
4955
  loadState(e) {
4856
4956
  if (!this.features.saveLoad) return;
4857
- let t = E.deserialize(e);
4957
+ let t = T.deserialize(e);
4858
4958
  this.chartTypeOptions = t.chartTypeOptions ?? {}, this.display.reset(), t.chartType && this.setChartType(t.chartType), t.drawings && this.setDrawings(t.drawings), (t.theme === "dark" || t.theme === "light") && this.setTheme(t.theme), t.version >= 3 && this.themeManager.setUserOverrides(t.overrides ?? {}) && this.styleChanged("user");
4859
4959
  let n = t.version >= 2 && this.features.indicators ? this.indicatorHistory.quietly(() => this.restoreIndicators(t.indicators, !1)) : /* @__PURE__ */ new Map();
4860
4960
  this.drawingManager.renamePanes(n);
4861
4961
  let r = new Set(this.unrestoredIndicators.map((e) => e.instanceId)), i = this.drawingManager.getDrawings(), a = i.filter((e) => e.paneId === void 0 || this.takesDrawing(e.paneId, e.type));
4862
- if (this.keptPaneDrawings = i.filter((e) => e.paneId !== void 0 && r.has(e.paneId)), a.length !== i.length && this.drawingManager.setDrawings(a), this.undoRedoManager.clear(), t.alerts && this.features.alerts) {
4863
- this.alertManager.clearAlerts();
4864
- for (let e of t.alerts) {
4865
- if (e.triggered && !e.repeating) continue;
4866
- let t = (e) => {
4867
- let t = e.indexOf(":"), r = t > 0 ? n.get(e.slice(0, t)) : void 0;
4868
- return r ? r + e.slice(t) : e;
4869
- }, r = t(e.channel), i = {
4870
- ...Bt(e),
4871
- ...e.target ? { target: t(e.target) } : {}
4872
- };
4873
- if (!e.expired) {
4874
- if (e.drawingId) {
4875
- this.drawingManager.hasPriceLevels(e.drawingId) && (e.condition === "crossing" || e.condition === "crossingUp" || e.condition === "crossingDown") && this.alertManager.addDrawingAlert(e.drawingId, e.condition, e.message, e.repeating, e.label);
4876
- continue;
4877
- }
4878
- try {
4879
- this.alertManager.addAlert(e.price, e.condition, e.message, e.repeating, r, e.label, i);
4880
- } catch (e) {
4881
- console.warn("Layout alert left out:", e);
4882
- }
4883
- }
4884
- }
4885
- }
4886
- this.markStateChanged();
4962
+ this.keptPaneDrawings = i.filter((e) => e.paneId !== void 0 && r.has(e.paneId)), a.length !== i.length && this.drawingManager.setDrawings(a), this.undoRedoManager.clear(), t.alerts && this.features.alerts && di(this.alertManager, t.alerts, n, (e) => this.drawingManager.hasPriceLevels(e), (e) => {
4963
+ console.warn("Layout alert left out:", e);
4964
+ }), this.markStateChanged();
4887
4965
  }
4888
4966
  loadStateFromStorage(e) {
4889
4967
  if (!this.features.saveLoad) return !1;
4890
- let t = E.loadFromStorage(e);
4891
- return t ? (this.loadState(E.serialize(t)), !0) : !1;
4968
+ let t = T.loadFromStorage(e);
4969
+ return t ? (this.loadState(T.serialize(t)), !0) : !1;
4892
4970
  }
4893
4971
  downloadState(e) {
4894
- this.features.saveLoad && E.downloadFile(this.captureSnapshot(), e);
4972
+ this.features.saveLoad && T.downloadFile(this.captureSnapshot(), e);
4895
4973
  }
4896
4974
  async loadStateFromFile() {
4897
4975
  if (!this.features.saveLoad) return;
4898
- let e = await E.loadFromFile();
4899
- this.loadState(E.serialize(e));
4976
+ let e = await T.loadFromFile();
4977
+ this.loadState(T.serialize(e));
4900
4978
  }
4901
4979
  setLocale(e) {
4902
- ce(e), this.engine.requestRender();
4980
+ le(e), this.engine.requestRender();
4903
4981
  }
4904
4982
  setNumberLocale(e) {
4905
4983
  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();
@@ -4950,7 +5028,7 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
4950
5028
  }
4951
5029
  createChartRenderer(e) {
4952
5030
  let t = An(e, (e) => this.pluginManager.getChartType(e));
4953
- return t instanceof Re && t.setPriceText((e) => this.formatPrice(e)), t;
5031
+ return t instanceof ze && t.setPriceText((e) => this.formatPrice(e)), t;
4954
5032
  }
4955
5033
  crosshairSeries() {
4956
5034
  return this.isTimeAligned() ? this.series.bars() : this.getDisplayData();
@@ -4968,7 +5046,7 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
4968
5046
  }
4969
5047
  exportBars() {
4970
5048
  if (this.isTimeAligned()) return this.series.bars();
4971
- let e = this.getDisplayData(), t = At(e);
5049
+ let e = this.getDisplayData(), t = k(e);
4972
5050
  return e.map((e, n) => ({
4973
5051
  ...e,
4974
5052
  time: t[n]?.time ?? e.time
@@ -5027,7 +5105,7 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
5027
5105
  this.priceFit.fit(this.viewport, e, t, {
5028
5106
  overlayRange: (e, t) => this.indicatorEngine.getOverlayPriceRange(e, t),
5029
5107
  compareRange: (e, t) => this.features.compareSymbols && this.comparesDrawn() ? this.compareRenderer.getPriceRange(e, t) : null,
5030
- volumeRatio: (e, t, n) => this.features.volume && this.volumeRenderer.isVisible() && Un(e, t, n) ? this.volumeRenderer.getHeightRatio() : null
5108
+ volumeRatio: (e, t, n) => this.features.volume && this.volumeRenderer.isVisible() && Wn(e, t, n) ? this.volumeRenderer.getHeightRatio() : null
5031
5109
  });
5032
5110
  }
5033
5111
  updateViewportAndRender(e = !1) {
@@ -5042,7 +5120,7 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
5042
5120
  fitLeftAxisWidth() {
5043
5121
  let e = this.leftViewport;
5044
5122
  if (!e) return !1;
5045
- let t = this.themeManager.getTheme(), n = Er({
5123
+ let t = this.themeManager.getTheme(), n = Dr({
5046
5124
  min: e.priceRange.min,
5047
5125
  max: e.priceRange.max,
5048
5126
  lastPrice: null,
@@ -5051,12 +5129,12 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
5051
5129
  fontFamily: t.font.family,
5052
5130
  fontSizeSmall: t.font.sizeSmall,
5053
5131
  measure: (e, t) => this.measureText(e, t)
5054
- }), r = Dr(this.leftAxisWidth, n);
5132
+ }), r = Or(this.leftAxisWidth, n);
5055
5133
  return r === this.leftAxisWidth ? !1 : (this.leftAxisWidth = r, this.layoutManager.setLeftAxisWidth(r), this.panes.invalidate(), this.viewport.setChartRect(this.getResolvedLayout().mainChartRect), !0);
5056
5134
  }
5057
5135
  fitPriceAxisWidth() {
5058
5136
  if (!this.features.priceAxis) return !1;
5059
- let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n = Er({
5137
+ let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n = Dr({
5060
5138
  min: e.min,
5061
5139
  max: e.max,
5062
5140
  lastPrice: this.currentPriceLine.getPrice(),
@@ -5067,14 +5145,14 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
5067
5145
  fontFamily: t.font.family,
5068
5146
  fontSizeSmall: t.font.sizeSmall,
5069
5147
  measure: (e, t) => this.measureText(e, t)
5070
- }), r = Dr(this.priceAxisWidth, n);
5148
+ }), r = Or(this.priceAxisWidth, n);
5071
5149
  return r === this.priceAxisWidth ? !1 : (this.priceAxisWidth = r, this.layoutManager.setPriceAxisWidth(r), this.viewport.setPriceAxisWidth(r), this.panes.invalidate(), this.viewport.setChartRect(this.getResolvedLayout().mainChartRect), !0);
5072
5150
  }
5073
5151
  measureText(e, t) {
5074
5152
  let n = this.engine.layerManager.getLayer(r.Main)?.ctx;
5075
- if (n?.canvas.isConnected) return this.labelWidths.get(e, t, () => _i(n, e, t));
5153
+ if (n?.canvas.isConnected) return this.labelWidths.get(e, t, () => ki(n, e, t));
5076
5154
  let i = n ?? this.detachedMeasureContext();
5077
- return i ? _i(i, e, t) : e.length * 7;
5155
+ return i ? ki(i, e, t) : e.length * 7;
5078
5156
  }
5079
5157
  detachedMeasureContext() {
5080
5158
  return this.measureCtx === void 0 && (this.measureCtx = typeof document < "u" ? document.createElement("canvas").getContext("2d") : null), this.measureCtx;
@@ -5161,7 +5239,7 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
5161
5239
  });
5162
5240
  }
5163
5241
  drawOverlayPlugins(e, t) {
5164
- let n = Mr(this.pluginManager.getOverlays(), t);
5242
+ let n = Nr(this.pluginManager.getOverlays(), t);
5165
5243
  if (n.length === 0) return;
5166
5244
  let r = {
5167
5245
  viewport: this.viewport.getState(),
@@ -5182,16 +5260,16 @@ var li = .08, ui = 20, di = 8, fi = 10, pi = {
5182
5260
  };
5183
5261
  }
5184
5262
  };
5185
- function _i(e, t, n) {
5263
+ function ki(e, t, n) {
5186
5264
  let r = e.font;
5187
5265
  e.font = n;
5188
5266
  let i = e.measureText(t).width;
5189
5267
  return e.font = r, i;
5190
5268
  }
5191
- var vi = 300;
5192
- function yi(e) {
5269
+ var Ai = 300;
5270
+ function ji(e) {
5193
5271
  let t = {}, n = e.family;
5194
- typeof n == "string" && n.trim() !== "" && n.length <= vi && !/[;{}<>\\]|\/\*/.test(n) && (t.family = n);
5272
+ typeof n == "string" && n.trim() !== "" && n.length <= Ai && !/[;{}<>\\]|\/\*/.test(n) && (t.family = n);
5195
5273
  for (let n of [
5196
5274
  "sizeSmall",
5197
5275
  "sizeMedium",
@@ -5202,11 +5280,11 @@ function yi(e) {
5202
5280
  }
5203
5281
  return t;
5204
5282
  }
5205
- function bi(e) {
5283
+ function Mi(e) {
5206
5284
  let t = e.tagRadius;
5207
5285
  return typeof t == "number" && Number.isFinite(t) && t >= 0 ? { tagRadius: Math.min(t, 999) } : {};
5208
5286
  }
5209
- function Y(e) {
5287
+ function X(e) {
5210
5288
  return {
5211
5289
  id: e.id,
5212
5290
  price: e.price,
@@ -5221,8 +5299,8 @@ function Y(e) {
5221
5299
  bars: e.bars
5222
5300
  };
5223
5301
  }
5224
- var xi = 8e3, Si = 10, Ci = 50, wi = .001;
5225
- function Ti(e) {
5302
+ var Ni = 8e3, Pi = 10, Fi = 50, Ii = .001;
5303
+ function Li(e) {
5226
5304
  return {
5227
5305
  price: null,
5228
5306
  fedTime: null,
@@ -5237,71 +5315,48 @@ function Ti(e) {
5237
5315
  held: null
5238
5316
  };
5239
5317
  }
5240
- function Ei(e, t) {
5318
+ function Ri(e, t) {
5241
5319
  let n = e[t + 1];
5242
- return n ? n.time - e[t].time : Ni(e);
5320
+ return n ? n.time - e[t].time : Z(e);
5243
5321
  }
5244
- function Di(e, t, n) {
5322
+ function zi(e, t, n) {
5245
5323
  let r = e.fedTime;
5246
5324
  if (r === null || !t || t.length === 0 || n.length === 0) return;
5247
- let i = Ei(t, Q(t, r)), a = r + (Number.isFinite(i) ? e.fedFraction * i : 0), o = Q(n, a), s = n[o].time;
5325
+ let i = Ri(t, Q(t, r)), a = r + (Number.isFinite(i) ? e.fedFraction * i : 0), o = Q(n, a), s = n[o].time;
5248
5326
  if (s > a) return;
5249
- let c = Ei(n, o);
5327
+ let c = Ri(n, o);
5250
5328
  if (a === s && o > 0) {
5251
5329
  e.fedTime = n[o - 1].time, e.fedFraction = 1;
5252
5330
  return;
5253
5331
  }
5254
5332
  e.fedTime = s, e.fedFraction = Number.isFinite(c) && c > 0 ? Math.min(1, (a - s) / c) : 0;
5255
5333
  }
5256
- function Oi(e, t) {
5257
- let n = Z(e, t), r = e.length - 1;
5258
- return n > r && r >= 0 && e[r].time + Ni(e) <= t ? r : Math.max(-1, n - 2);
5334
+ function Bi(e, t) {
5335
+ let n = Y(e, t), r = e.length - 1;
5336
+ return n > r && r >= 0 && e[r].time + Z(e) <= t ? r : Math.max(-1, n - 2);
5259
5337
  }
5260
- function ki(e) {
5338
+ function Vi(e) {
5261
5339
  let t = Infinity;
5262
5340
  for (let n = Math.max(1, e.length - 10); n < e.length; n++) t = Math.min(t, e[n].time - e[n - 1].time);
5263
5341
  return t;
5264
5342
  }
5265
- function Ai(e, t) {
5266
- if (!(ki(e) < ki(t))) return !1;
5267
- let n = Math.max(0, e.length - Ci);
5343
+ function Hi(e, t) {
5344
+ if (!(Vi(e) < Vi(t))) return !1;
5345
+ let n = Math.max(0, e.length - Fi);
5268
5346
  for (let r = n; r < e.length; r++) {
5269
- let n = t[Q(t, e[r].time)], i = (n.high - n.low) * wi + 2 ** -52;
5347
+ let n = t[Q(t, e[r].time)], i = (n.high - n.low) * Ii + 2 ** -52;
5270
5348
  if (e[r].close > n.high + i || e[r].close < n.low - i) return !1;
5271
5349
  }
5272
5350
  return !0;
5273
5351
  }
5274
- var ji = 500;
5275
- function X(e, t) {
5276
- let n = 0, r = e.length;
5277
- for (; n < r;) {
5278
- let i = n + r >> 1;
5279
- e[i].time < t ? n = i + 1 : r = i;
5280
- }
5281
- return n;
5282
- }
5283
- function Z(e, t) {
5284
- let n = 0, r = e.length;
5285
- for (; n < r;) {
5286
- let i = n + r >> 1;
5287
- e[i].time <= t ? n = i + 1 : r = i;
5288
- }
5289
- return n;
5290
- }
5291
- function Mi(e) {
5292
- let t = 0, n = 0;
5293
- for (let r = 1; r < e.length; r++) e[r].low < e[t].low && (t = r), e[r].high > e[n].high && (n = r);
5294
- 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];
5295
- return [...a ? [r, i] : [i, r], [o.close, o.time]];
5296
- }
5297
- function Ni(e) {
5352
+ function Z(e) {
5298
5353
  let t = 0;
5299
5354
  for (let n = Math.max(1, e.length - 10); n < e.length; n++) t = Math.max(t, e[n].time - e[n - 1].time);
5300
5355
  return t > 0 ? t : Infinity;
5301
5356
  }
5302
- function Pi(e, t) {
5357
+ function Ui(e, t) {
5303
5358
  if (t.length === 0) return null;
5304
- let n = t[t.length - 1].time + Ni(t), r = e.filter((e) => Rn(e) && e.time >= t[0].time && e.time < n).sort((e, t) => e.time - t.time), i = [];
5359
+ let n = t[t.length - 1].time + Z(t), r = e.filter((e) => zn(e) && e.time >= t[0].time && e.time < n).sort((e, t) => e.time - t.time), i = [];
5305
5360
  for (let e of r) (i.length === 0 || i[i.length - 1].time !== e.time) && i.push(e);
5306
5361
  if (i.length === 0) return null;
5307
5362
  let a = t.findIndex((e) => e.time >= i[0].time);
@@ -5317,26 +5372,26 @@ function Q(e, t) {
5317
5372
  }
5318
5373
  return n;
5319
5374
  }
5320
- function Fi(e, t, n) {
5375
+ function Wi(e, t, n) {
5321
5376
  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;
5322
5377
  for (let t = 0; t < e.length && e[t].time < i; t++) a = t;
5323
5378
  return Math.max(0, a);
5324
5379
  }
5325
- function Ii(e, t, n) {
5380
+ function Gi(e, t, n) {
5326
5381
  let r = n;
5327
5382
  for (; r > 0 && t[r - 1].time >= e.time;) r--;
5328
5383
  let i = {
5329
5384
  ...t[r],
5330
5385
  time: e.time
5331
5386
  };
5332
- for (let e = r + 1; e <= n; e++) i = Bi(i, t[e]);
5387
+ for (let e = r + 1; e <= n; e++) i = Yi(i, t[e]);
5333
5388
  return i;
5334
5389
  }
5335
- function Li(e, t, n, r) {
5390
+ function Ki(e, t, n, r) {
5336
5391
  let i = e[n + 1], a = t[r + 1];
5337
5392
  return i !== void 0 && a !== void 0 && i.time >= a.time;
5338
5393
  }
5339
- function Ri(e, t) {
5394
+ function qi(e, t) {
5340
5395
  let n = /* @__PURE__ */ new Map();
5341
5396
  for (let r of e) {
5342
5397
  let e = t[Q(t, r.time)].time, i = n.get(e);
@@ -5344,10 +5399,10 @@ function Ri(e, t) {
5344
5399
  }
5345
5400
  return n;
5346
5401
  }
5347
- function zi() {
5402
+ function Ji() {
5348
5403
  return typeof matchMedia == "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
5349
5404
  }
5350
- function Bi(e, t) {
5405
+ function Yi(e, t) {
5351
5406
  return {
5352
5407
  time: e.time,
5353
5408
  open: e.open,
@@ -5359,26 +5414,26 @@ function Bi(e, t) {
5359
5414
  }
5360
5415
  //#endregion
5361
5416
  //#region src/io/parseOHLCV.ts
5362
- var Vi = [
5417
+ var Xi = [
5363
5418
  "time",
5364
5419
  "timestamp",
5365
5420
  "date",
5366
5421
  "datetime",
5367
5422
  "t"
5368
- ], Hi = ["open", "o"], Ui = ["high", "h"], Wi = ["low", "l"], Gi = ["close", "c"], Ki = [
5423
+ ], Zi = ["open", "o"], Qi = ["high", "h"], $i = ["low", "l"], ea = ["close", "c"], ta = [
5369
5424
  "volume",
5370
5425
  "vol",
5371
5426
  "v"
5372
5427
  ];
5373
- function qi(e) {
5428
+ function na(e) {
5374
5429
  let t = e.trim();
5375
- return t ? t[0] === "[" || t[0] === "{" ? Ji(t) : Yi(t) : {
5430
+ return t ? t[0] === "[" || t[0] === "{" ? ra(t) : ia(t) : {
5376
5431
  data: [],
5377
5432
  rowCount: 0,
5378
5433
  skipped: 0
5379
5434
  };
5380
5435
  }
5381
- function Ji(e) {
5436
+ function ra(e) {
5382
5437
  let t;
5383
5438
  try {
5384
5439
  t = JSON.parse(e);
@@ -5388,19 +5443,19 @@ function Ji(e) {
5388
5443
  if (!Array.isArray(t)) throw Error("Expected a JSON array of OHLCV rows");
5389
5444
  let n = [], r = 0;
5390
5445
  for (let e of t) {
5391
- let t = Array.isArray(e) ? ea(e) : $i(e);
5446
+ let t = Array.isArray(e) ? la(e) : ca(e);
5392
5447
  t ? n.push(t) : r++;
5393
5448
  }
5394
- return na(n, t.length, r);
5449
+ return da(n, t.length, r);
5395
5450
  }
5396
- function Yi(e) {
5451
+ function ia(e) {
5397
5452
  let t = e.split(/\r?\n/).filter((e) => e.trim().length > 0);
5398
5453
  if (t.length === 0) return {
5399
5454
  data: [],
5400
5455
  rowCount: 0,
5401
5456
  skipped: 0
5402
5457
  };
5403
- let n = Xi(t[0]), r = Zi(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? Qi(r) : {
5458
+ let n = aa(t[0]), r = oa(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? sa(r) : {
5404
5459
  time: 0,
5405
5460
  open: 1,
5406
5461
  high: 2,
@@ -5411,7 +5466,7 @@ function Yi(e) {
5411
5466
  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");
5412
5467
  let o = [], s = 0;
5413
5468
  for (let e = +!!i; e < t.length; e++) {
5414
- let r = Zi(t[e], n), i = ta(r[a.time]), c = $(r[a.open]), l = $(r[a.high]), u = $(r[a.low]), d = $(r[a.close]), f = a.volume >= 0 ? Number(r[a.volume]) : 0;
5469
+ let r = oa(t[e], n), i = ua(r[a.time]), c = $(r[a.open]), l = $(r[a.high]), u = $(r[a.low]), d = $(r[a.close]), f = a.volume >= 0 ? Number(r[a.volume]) : 0;
5415
5470
  if (i === null || ![
5416
5471
  c,
5417
5472
  l,
@@ -5430,9 +5485,9 @@ function Yi(e) {
5430
5485
  volume: Number.isFinite(f) ? f : 0
5431
5486
  });
5432
5487
  }
5433
- return na(o, t.length - +!!i, s);
5488
+ return da(o, t.length - +!!i, s);
5434
5489
  }
5435
- function Xi(e) {
5490
+ function aa(e) {
5436
5491
  let t = {
5437
5492
  ",": 0,
5438
5493
  ";": 0,
@@ -5444,7 +5499,7 @@ function Xi(e) {
5444
5499
  for (let [e, i] of Object.entries(t)) i > r && (n = e, r = i);
5445
5500
  return n;
5446
5501
  }
5447
- function Zi(e, t) {
5502
+ function oa(e, t) {
5448
5503
  let n = [], r = "", i = !1;
5449
5504
  for (let a = 0; a < e.length; a++) {
5450
5505
  let o = e[a];
@@ -5452,25 +5507,25 @@ function Zi(e, t) {
5452
5507
  }
5453
5508
  return n.push(r), n;
5454
5509
  }
5455
- function Qi(e) {
5510
+ function sa(e) {
5456
5511
  let t = (t) => e.findIndex((e) => t.includes(e));
5457
5512
  return {
5458
- time: t(Vi),
5459
- open: t(Hi),
5460
- high: t(Ui),
5461
- low: t(Wi),
5462
- close: t(Gi),
5463
- volume: t(Ki)
5513
+ time: t(Xi),
5514
+ open: t(Zi),
5515
+ high: t(Qi),
5516
+ low: t($i),
5517
+ close: t(ea),
5518
+ volume: t(ta)
5464
5519
  };
5465
5520
  }
5466
- function $i(e) {
5521
+ function ca(e) {
5467
5522
  let t = (t) => {
5468
5523
  for (let n of t) {
5469
5524
  if (e[n] !== void 0) return e[n];
5470
5525
  let t = n.toUpperCase();
5471
5526
  if (e[t] !== void 0) return e[t];
5472
5527
  }
5473
- }, n = ta(String(t(Vi) ?? "")), r = Number(t(Hi)), i = Number(t(Ui)), a = Number(t(Wi)), o = Number(t(Gi)), s = Number(t(Ki) ?? 0);
5528
+ }, n = ua(String(t(Xi) ?? "")), r = Number(t(Zi)), i = Number(t(Qi)), a = Number(t($i)), o = Number(t(ea)), s = Number(t(ta) ?? 0);
5474
5529
  return n === null || ![
5475
5530
  r,
5476
5531
  i,
@@ -5485,9 +5540,9 @@ function $i(e) {
5485
5540
  volume: Number.isFinite(s) ? s : 0
5486
5541
  };
5487
5542
  }
5488
- function ea(e) {
5543
+ function la(e) {
5489
5544
  if (e.length < 5) return null;
5490
- let t = ta(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;
5545
+ let t = ua(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;
5491
5546
  return t === null || ![
5492
5547
  n,
5493
5548
  r,
@@ -5505,7 +5560,7 @@ function ea(e) {
5505
5560
  function $(e) {
5506
5561
  return e === void 0 || e.trim() === "" ? NaN : Number(e);
5507
5562
  }
5508
- function ta(e) {
5563
+ function ua(e) {
5509
5564
  let t = e.trim();
5510
5565
  if (!t) return null;
5511
5566
  let n = Number(t);
@@ -5513,7 +5568,7 @@ function ta(e) {
5513
5568
  let r = Date.parse(t);
5514
5569
  return Number.isFinite(r) ? r : null;
5515
5570
  }
5516
- function na(e, t, n) {
5571
+ function da(e, t, n) {
5517
5572
  e.sort((e, t) => e.time - t.time);
5518
5573
  let r = [];
5519
5574
  for (let t of e) r.length > 0 && r[r.length - 1].time === t.time ? r[r.length - 1] = t : r.push(t);
@@ -5525,7 +5580,7 @@ function na(e, t, n) {
5525
5580
  }
5526
5581
  //#endregion
5527
5582
  //#region src/io/DragDropImporter.ts
5528
- var ra = class {
5583
+ var fa = class {
5529
5584
  host;
5530
5585
  overlay = null;
5531
5586
  callbacks;
@@ -5546,19 +5601,19 @@ var ra = class {
5546
5601
  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();
5547
5602
  }
5548
5603
  onDragEnter(e) {
5549
- ia(e) && (e.preventDefault(), this.depth++, this.showOverlay());
5604
+ pa(e) && (e.preventDefault(), this.depth++, this.showOverlay());
5550
5605
  }
5551
5606
  onDragOver(e) {
5552
- ia(e) && (e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = "copy"));
5607
+ pa(e) && (e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = "copy"));
5553
5608
  }
5554
5609
  onDragLeave(e) {
5555
- ia(e) && (this.depth = Math.max(0, this.depth - 1), this.depth === 0 && this.hideOverlay());
5610
+ pa(e) && (this.depth = Math.max(0, this.depth - 1), this.depth === 0 && this.hideOverlay());
5556
5611
  }
5557
5612
  async onDrop(e) {
5558
5613
  e.preventDefault(), this.depth = 0, this.hideOverlay();
5559
5614
  let t = e.dataTransfer?.files?.[0];
5560
5615
  if (t) try {
5561
- let e = qi(await t.text());
5616
+ let e = na(await t.text());
5562
5617
  if (e.data.length === 0) throw Error(`No valid OHLCV rows found in "${t.name}"`);
5563
5618
  this.callbacks.onData(e.data, e, t);
5564
5619
  } catch (e) {
@@ -5589,12 +5644,12 @@ var ra = class {
5589
5644
  this.overlay?.remove(), this.overlay = null;
5590
5645
  }
5591
5646
  };
5592
- function ia(e) {
5647
+ function pa(e) {
5593
5648
  return e.dataTransfer?.types?.includes("Files") ?? !1;
5594
5649
  }
5595
5650
  //#endregion
5596
5651
  //#region src/state/layoutStorage.ts
5597
- function aa(e) {
5652
+ function ma(e) {
5598
5653
  let t = {
5599
5654
  id: e.id,
5600
5655
  name: e.name,
@@ -5602,11 +5657,11 @@ function aa(e) {
5602
5657
  };
5603
5658
  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;
5604
5659
  }
5605
- var oa = (e, t) => t.updatedAt - e.updatedAt;
5606
- function sa(e) {
5660
+ var ha = (e, t) => t.updatedAt - e.updatedAt;
5661
+ function ga(e) {
5607
5662
  if (typeof e != "object" || !e) return null;
5608
5663
  let t = e;
5609
- return typeof t.id != "string" || !t.id || typeof t.name != "string" || typeof t.updatedAt != "number" || !Number.isFinite(t.updatedAt) ? null : aa({
5664
+ return typeof t.id != "string" || !t.id || typeof t.name != "string" || typeof t.updatedAt != "number" || !Number.isFinite(t.updatedAt) ? null : ma({
5610
5665
  id: t.id,
5611
5666
  name: t.name,
5612
5667
  updatedAt: t.updatedAt,
@@ -5615,17 +5670,17 @@ function sa(e) {
5615
5670
  kind: typeof t.kind == "string" ? t.kind : void 0
5616
5671
  });
5617
5672
  }
5618
- function ca(e) {
5619
- let t = sa(e), n = t ? e.content : void 0;
5673
+ function _a(e) {
5674
+ let t = ga(e), n = t ? e.content : void 0;
5620
5675
  return t && typeof n == "string" ? {
5621
5676
  ...t,
5622
5677
  content: n
5623
5678
  } : null;
5624
5679
  }
5625
- function la(e = []) {
5680
+ function va(e = []) {
5626
5681
  let t = new Map(e.map((e) => [e.id, { ...e }]));
5627
5682
  return {
5628
- list: () => [...t.values()].map(aa).sort(oa),
5683
+ list: () => [...t.values()].map(ma).sort(ha),
5629
5684
  load: (e) => {
5630
5685
  let n = t.get(e);
5631
5686
  return n ? { ...n } : null;
@@ -5638,7 +5693,7 @@ function la(e = []) {
5638
5693
  }
5639
5694
  };
5640
5695
  }
5641
- function ua(e = "tcw:layouts:") {
5696
+ function ya(e = "tcw:layouts:") {
5642
5697
  let t = `${e}index`, n = (t) => `${e}item:${t}`, r = () => {
5643
5698
  let e;
5644
5699
  try {
@@ -5646,10 +5701,10 @@ function ua(e = "tcw:layouts:") {
5646
5701
  } catch {
5647
5702
  return [];
5648
5703
  }
5649
- return Array.isArray(e) ? e.map(sa).filter((e) => e !== null) : [];
5704
+ return Array.isArray(e) ? e.map(ga).filter((e) => e !== null) : [];
5650
5705
  }, i = (e) => localStorage.setItem(t, JSON.stringify(e));
5651
5706
  return {
5652
- list: () => r().sort(oa),
5707
+ list: () => r().sort(ha),
5653
5708
  load: (e) => {
5654
5709
  let t = r().find((t) => t.id === e), i = t ? localStorage.getItem(n(e)) : null;
5655
5710
  return t && i !== null ? {
@@ -5658,7 +5713,7 @@ function ua(e = "tcw:layouts:") {
5658
5713
  } : null;
5659
5714
  },
5660
5715
  save: (e) => {
5661
- localStorage.setItem(n(e.id), e.content), i([...r().filter((t) => t.id !== e.id), aa(e)]);
5716
+ localStorage.setItem(n(e.id), e.content), i([...r().filter((t) => t.id !== e.id), ma(e)]);
5662
5717
  },
5663
5718
  remove: (e) => {
5664
5719
  i(r().filter((t) => t.id !== e)), localStorage.removeItem(n(e));
@@ -5667,14 +5722,14 @@ function ua(e = "tcw:layouts:") {
5667
5722
  }
5668
5723
  //#endregion
5669
5724
  //#region src/state/LayoutSession.ts
5670
- var da = 80;
5671
- function fa(e) {
5725
+ var ba = 80;
5726
+ function xa(e) {
5672
5727
  return e.replace(/\s+/g, " ").trim().slice(0, 80).trim() || null;
5673
5728
  }
5674
- function pa() {
5729
+ function Sa() {
5675
5730
  return globalThis.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
5676
5731
  }
5677
- function ma(e) {
5732
+ function Ca(e) {
5678
5733
  let { id: t, name: n, symbol: r, timeframe: i, updatedAt: a, kind: o } = e;
5679
5734
  return {
5680
5735
  id: t,
@@ -5685,7 +5740,7 @@ function ma(e) {
5685
5740
  ...o === void 0 ? {} : { kind: o }
5686
5741
  };
5687
5742
  }
5688
- var ha = class {
5743
+ var wa = class {
5689
5744
  currentLayout = null;
5690
5745
  savedContent = null;
5691
5746
  dirty = !1;
@@ -5701,7 +5756,7 @@ var ha = class {
5701
5756
  now;
5702
5757
  newId;
5703
5758
  constructor(e, t, n = {}) {
5704
- 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 ?? pa;
5759
+ 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 ?? Sa;
5705
5760
  }
5706
5761
  current() {
5707
5762
  return this.currentLayout;
@@ -5717,7 +5772,7 @@ var ha = class {
5717
5772
  }
5718
5773
  async list() {
5719
5774
  let e = await this.storage.list();
5720
- return Array.isArray(e) ? e.map(sa).filter((e) => e !== null && (e.kind ?? "chart") === this.kind).sort((e, t) => t.updatedAt - e.updatedAt) : [];
5775
+ return Array.isArray(e) ? e.map(ga).filter((e) => e !== null && (e.kind ?? "chart") === this.kind).sort((e, t) => t.updatedAt - e.updatedAt) : [];
5721
5776
  }
5722
5777
  save() {
5723
5778
  return this.queue(() => {
@@ -5726,12 +5781,12 @@ var ha = class {
5726
5781
  });
5727
5782
  }
5728
5783
  saveAs(e) {
5729
- let t = fa(e);
5784
+ let t = xa(e);
5730
5785
  return t ? this.queue(() => this.write(this.newId(), t)) : Promise.reject(/* @__PURE__ */ Error("A layout needs a name"));
5731
5786
  }
5732
5787
  open(e) {
5733
5788
  return this.queue(async () => {
5734
- let t = ca(await this.storage.load(e));
5789
+ let t = _a(await this.storage.load(e));
5735
5790
  if (!t || t.id !== e || (t.kind ?? "chart") !== this.kind || this.destroyed) return !1;
5736
5791
  this.cancelTimer(), this.applying++;
5737
5792
  try {
@@ -5741,13 +5796,13 @@ var ha = class {
5741
5796
  } finally {
5742
5797
  this.applying--;
5743
5798
  }
5744
- return this.cancelTimer(), this.currentLayout = ma(t), this.savedContent = this.host.capture().content, this.dirty = !1, this.notify(), !0;
5799
+ return this.cancelTimer(), this.currentLayout = Ca(t), this.savedContent = this.host.capture().content, this.dirty = !1, this.notify(), !0;
5745
5800
  });
5746
5801
  }
5747
5802
  rename(e, t) {
5748
- let n = fa(t);
5803
+ let n = xa(t);
5749
5804
  return n ? this.queue(async () => {
5750
- let t = ca(await this.storage.load(e));
5805
+ let t = _a(await this.storage.load(e));
5751
5806
  !t || t.id !== e || (await this.storage.save({
5752
5807
  ...t,
5753
5808
  name: n
@@ -5825,7 +5880,7 @@ var ha = class {
5825
5880
  content: n.content
5826
5881
  };
5827
5882
  await this.storage.save(r);
5828
- let i = ma(r);
5883
+ let i = Ca(r);
5829
5884
  return this.currentLayout = i, this.savedContent = n.content, this.dirty = !1, this.notify(), i;
5830
5885
  }
5831
5886
  forget() {
@@ -5846,6 +5901,6 @@ var ha = class {
5846
5901
  }
5847
5902
  };
5848
5903
  //#endregion
5849
- export { pr as C, B as D, R as E, dn as O, gr as S, V as T, Pr as _, la as a, K as b, gi as c, ri as d, ii as f, Nr as g, Fr as h, ua as i, oi as l, Ir as m, da as n, ra as o, Lr as p, fa as r, qi as s, ha as t, ai as u, jr as v, dr as w, xr as x, Mr as y };
5904
+ export { mr as C, Pn as D, R as E, dn as O, _r as S, B as T, Fr as _, va as a, G as b, Oi as c, ii as d, ai as f, Pr as g, Ir as h, ya as i, vi as l, Lr as m, ba as n, fa as o, Rr as p, xa as r, na as s, wa as t, _i as u, Mr as v, fr as w, Sr as x, Nr as y };
5850
5905
 
5851
- //# sourceMappingURL=LayoutSession-Bcy79w0l.js.map
5906
+ //# sourceMappingURL=LayoutSession-BOQCN6yY.js.map