@tradecanvas/chart 1.12.0 → 1.14.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.
Files changed (64) hide show
  1. package/README.md +57 -1
  2. package/dist/Chart.d.ts +77 -7
  3. package/dist/Chart.d.ts.map +1 -1
  4. package/dist/{LayoutSession-2yRujs2S.js → LayoutSession-BTfv1oBV.js} +548 -368
  5. package/dist/LayoutSession-BTfv1oBV.js.map +1 -0
  6. package/dist/LayoutSession-DG3i7kbY.cjs +2 -0
  7. package/dist/LayoutSession-DG3i7kbY.cjs.map +1 -0
  8. package/dist/ThemeManager.d.ts +36 -2
  9. package/dist/ThemeManager.d.ts.map +1 -1
  10. package/dist/frameworks/syncIndicators.d.ts +23 -0
  11. package/dist/frameworks/syncIndicators.d.ts.map +1 -0
  12. package/dist/index.cjs +1 -1
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.ts +4 -2
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +55 -30
  17. package/dist/index.js.map +1 -1
  18. package/dist/style/styleOptions.d.ts +8 -0
  19. package/dist/style/styleOptions.d.ts.map +1 -0
  20. package/dist/widget/ChartWidget.d.ts +58 -1
  21. package/dist/widget/ChartWidget.d.ts.map +1 -1
  22. package/dist/widget/ChartWidgetGrid.d.ts +16 -1
  23. package/dist/widget/ChartWidgetGrid.d.ts.map +1 -1
  24. package/dist/widget/WidgetAccountPanel.d.ts.map +1 -1
  25. package/dist/widget/WidgetAlertsPanel.d.ts.map +1 -1
  26. package/dist/widget/WidgetChartNav.d.ts.map +1 -1
  27. package/dist/widget/WidgetContextMenu.d.ts.map +1 -1
  28. package/dist/widget/WidgetDataWindow.d.ts.map +1 -1
  29. package/dist/widget/WidgetDepthLadder.d.ts.map +1 -1
  30. package/dist/widget/WidgetDrawingSettings.d.ts.map +1 -1
  31. package/dist/widget/WidgetDrawingSidebar.d.ts +9 -1
  32. package/dist/widget/WidgetDrawingSidebar.d.ts.map +1 -1
  33. package/dist/widget/WidgetGoToDate.d.ts.map +1 -1
  34. package/dist/widget/WidgetIndicatorLegend.d.ts.map +1 -1
  35. package/dist/widget/WidgetObjectTree.d.ts.map +1 -1
  36. package/dist/widget/WidgetReplayBar.d.ts.map +1 -1
  37. package/dist/widget/WidgetStatusBar.d.ts +10 -1
  38. package/dist/widget/WidgetStatusBar.d.ts.map +1 -1
  39. package/dist/widget/WidgetStyles.d.ts.map +1 -1
  40. package/dist/widget/WidgetSymbolInfo.d.ts.map +1 -1
  41. package/dist/widget/WidgetToolbar.d.ts +6 -0
  42. package/dist/widget/WidgetToolbar.d.ts.map +1 -1
  43. package/dist/widget/hostButtons.d.ts +5 -0
  44. package/dist/widget/hostButtons.d.ts.map +1 -0
  45. package/dist/widget/hostMenus.d.ts +7 -0
  46. package/dist/widget/hostMenus.d.ts.map +1 -0
  47. package/dist/widget/index.cjs +45 -12
  48. package/dist/widget/index.cjs.map +1 -1
  49. package/dist/widget/index.d.ts +3 -1
  50. package/dist/widget/index.d.ts.map +1 -1
  51. package/dist/widget/index.js +1585 -1137
  52. package/dist/widget/index.js.map +1 -1
  53. package/dist/widget/legendValues.d.ts +4 -2
  54. package/dist/widget/legendValues.d.ts.map +1 -1
  55. package/dist/widget/types.d.ts +96 -0
  56. package/dist/widget/types.d.ts.map +1 -1
  57. package/dist/widget/widgetConfig.d.ts +12 -0
  58. package/dist/widget/widgetConfig.d.ts.map +1 -1
  59. package/dist/widget/widgetFeatures.d.ts +74 -0
  60. package/dist/widget/widgetFeatures.d.ts.map +1 -0
  61. package/package.json +3 -3
  62. package/dist/LayoutSession-1uhJw0L7.cjs +0 -2
  63. package/dist/LayoutSession-1uhJw0L7.cjs.map +0 -1
  64. package/dist/LayoutSession-2yRujs2S.js.map +0 -1
@@ -1,12 +1,12 @@
1
- import { DARK_THEME as e, DEFAULT_PANEL_HEIGHT as t, LIGHT_THEME as n, LayerType as r, MIN_PANEL_HEIGHT as i, PRICE_AXIS_WIDTH as a, TIME_AXIS_HEIGHT as o, autoPricePrecision as s, computePriceLimits as c, formatPrice as l, fractionTick as u, indicatorSource as d, isValidTimeZone as f, mergeBar as p, normalizeBarTime as m, parseIndicatorSource as h, priceFormatterFor as g, readChartTypeOptions as _, sessionMinute as v, setLocale as ee, stepDecimals as te, tickBarCount as ne, timeframeToMs as y, volumeColor as b, zonedDateFormatter as re } from "@tradecanvas/commons";
2
- import { AlertDragHandler as ie, AlertManager as ae, Animator as oe, AreaRenderer as se, AxisDragHandler as ce, BarCountdown as le, BarRenderer as ue, BaselineRenderer as de, CandlestickRenderer as fe, ChartLegend as pe, ChartStateManager as x, CompareRenderer as me, CompareSymbolIndicator as he, CorrelationCoefficientIndicator as ge, CorrelationLogIndicator as _e, CrosshairHandler as ve, CrosshairTooltip as ye, CurrentPriceLine as be, DEFAULT_SESSION_HOURS as xe, DataExporter as S, DepthHeatmapRenderer as Se, DrawingManager as Ce, DrawingRenderer as we, EquivolumeRenderer as Te, EventBus as Ee, GridRenderer as De, HLCAreaRenderer as Oe, HiLoRenderer as C, HollowCandleRenderer as ke, IndicatorEngine as w, InteractionManager as Ae, KagiRenderer as je, KeyboardHandler as Me, LineRenderer as Ne, LineWithMarkersRenderer as Pe, MarketProfileRenderer as Fe, MeasureOverlay as Ie, PanHandler as Le, PaneResizeHandler as Re, PeriodLevelsRenderer as ze, PinnedTooltip as Be, PivotMarkersRenderer as Ve, PointAndFigureRenderer as T, PriceAxis as E, PriceAxisAddButton as He, PriceLines as Ue, RenderEngine as We, RenkoRenderer as Ge, ReplayManager as Ke, Screenshot as D, SelectionBoxOverlay as qe, SessionBreaks as Je, SessionShading as Ye, SignalMarkerManager as Xe, SpreadIndicator as Ze, StepLineRenderer as Qe, StreamManager as $e, SymbolSeriesStore as et, TimeAxis as tt, TradeZoneManager as nt, TradingManager as rt, TradingRenderer as it, UndoRedoManager as at, Viewport as ot, VolumeCandleRenderer as st, VolumeProfileRenderer as ct, VolumeRenderer as lt, Watermark as ut, ZoomHandler as dt, barTimeStepMs as ft, findDominantSwing as pt, gpuContextsLeft as mt, isRegularSession as ht, loadWebGL as gt, mergeSessionHours as _t, rangePresetStart as vt, readAlertOptions as yt, registerBuiltInDrawingTools as bt, registerBuiltInIndicators as O, servesTimeframe as k, sourceParam as A, timestampToBarIndex as j, toHeikinAshi as xt, toKagi as St, toLineBreak as Ct, toPointAndFigure as wt, toRangeBars as Tt, toRenko as M, whenGpuContextFree as Et, withResampling as Dt, xToBarIndex as Ot, xToTime as N, yToPrice as P } 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, PRICE_AXIS_WIDTH as a, TIME_AXIS_HEIGHT as o, autoPricePrecision as s, chartStyleValue as c, computePriceLimits as l, formatPrice as u, fractionTick as d, indicatorSource as f, isValidTimeZone as p, mergeBar as m, normalizeBarTime as h, parseIndicatorSource as g, priceFormatterFor as _, readChartStyleOverrides as v, readChartTypeOptions as y, readIndicatorPlotStyles as ee, readPaneStyle as b, resolveChartTheme as te, sessionMinute as x, setLocale as ne, stepDecimals as re, tickBarCount as ie, timeframeToMs as ae, volumeColor as oe, zonedDateFormatter as se } from "@tradecanvas/commons";
2
+ import { AlertDragHandler as ce, AlertManager as le, Animator as ue, AreaRenderer as de, AxisDragHandler as fe, BarCountdown as pe, BarRenderer as me, BaselineRenderer as he, CandlestickRenderer as ge, ChartLegend as _e, ChartStateManager as S, CompareRenderer as ve, CompareSymbolIndicator as ye, CorrelationCoefficientIndicator as be, CorrelationLogIndicator as xe, CrosshairHandler as Se, CrosshairTooltip as Ce, CurrentPriceLine as we, DEFAULT_SESSION_HOURS as Te, DataExporter as C, DepthHeatmapRenderer as Ee, DrawingManager as De, DrawingRenderer as Oe, EquivolumeRenderer as ke, EventBus as Ae, GridRenderer as je, HLCAreaRenderer as Me, HiLoRenderer as w, HollowCandleRenderer as Ne, IndicatorEngine as Pe, InteractionManager as Fe, KagiRenderer as Ie, KeyboardHandler as Le, LineRenderer as Re, LineWithMarkersRenderer as ze, MarketProfileRenderer as Be, MeasureOverlay as Ve, PanHandler as He, PaneResizeHandler as Ue, PeriodLevelsRenderer as We, PinnedTooltip as Ge, PivotMarkersRenderer as Ke, PointAndFigureRenderer as qe, PriceAxis as Je, PriceAxisAddButton as Ye, PriceLines as Xe, RenderEngine as Ze, RenkoRenderer as Qe, ReplayManager as $e, Screenshot as T, SelectionBoxOverlay as et, SessionBreaks as tt, SessionShading as nt, SignalMarkerManager as rt, SpreadIndicator as it, StepLineRenderer as at, StreamManager as ot, SymbolSeriesStore as st, TimeAxis as ct, TradeZoneManager as lt, TradingManager as ut, TradingRenderer as dt, UndoRedoManager as ft, Viewport as pt, VolumeCandleRenderer as mt, VolumeProfileRenderer as ht, VolumeRenderer as gt, Watermark as _t, ZoomHandler as vt, barTimeStepMs as yt, findDominantSwing as bt, gpuContextsLeft as xt, isRegularSession as St, loadWebGL as Ct, mergeSessionHours as wt, rangePresetStart as Tt, readAlertOptions as Et, registerBuiltInDrawingTools as Dt, registerBuiltInIndicators as E, servesTimeframe as Ot, sourceParam as D, timestampToBarIndex as O, toHeikinAshi as kt, toKagi as At, toLineBreak as jt, toPointAndFigure as Mt, toRangeBars as Nt, toRenko as Pt, whenGpuContextFree as Ft, withResampling as It, xToBarIndex as Lt, xToTime as k, yToPrice as Rt } from "@tradecanvas/core";
3
3
  //#region src/regularHours.ts
4
- var kt = 864e5, At = 10;
5
- function jt(e, t) {
4
+ var zt = 864e5, Bt = 10;
5
+ function Vt(e, t) {
6
6
  let n = e?.timezone;
7
- if (!n || !f(n) || t.length < 2) return null;
7
+ if (!n || !p(n) || t.length < 2) return null;
8
8
  let r = (e?.sessions ?? []).flatMap((e) => {
9
- let t = v(e.start), n = v(e.end);
9
+ let t = x(e.start), n = x(e.end);
10
10
  return t === null || n === null ? [] : [{
11
11
  startMinute: t,
12
12
  endMinute: n
@@ -14,34 +14,34 @@ function jt(e, t) {
14
14
  });
15
15
  if (r.length === 0) return null;
16
16
  let i = Infinity;
17
- for (let e = Math.max(1, t.length - At); e < t.length; e++) {
18
- let n = m(t[e].time) - m(t[e - 1].time);
17
+ for (let e = Math.max(1, t.length - Bt); e < t.length; e++) {
18
+ let n = h(t[e].time) - h(t[e - 1].time);
19
19
  n > 0 && n < i && (i = n);
20
20
  }
21
- if (!(i < kt)) return null;
21
+ if (!(i < zt)) return null;
22
22
  let a = {
23
23
  timeZone: n,
24
24
  windows: r,
25
25
  startMinute: r[0].startMinute,
26
26
  endMinute: r[r.length - 1].endMinute
27
27
  };
28
- return (e) => ht(m(e), a);
28
+ return (e) => St(h(e), a);
29
29
  }
30
30
  //#endregion
31
31
  //#region src/chartA11y.ts
32
- var F = {
32
+ var Ht = {
33
33
  role: "chart",
34
34
  summary: "{what}. Last price {close}.",
35
35
  empty: "Chart, no data.",
36
36
  view: "Showing {count} bars, {from} to {to}. High {high}, low {low}.",
37
37
  bar: "{time}: open {open}, high {high}, low {low}, close {close}, volume {volume}.",
38
38
  keys: "Arrow keys scroll and zoom, Home and End go to the start and the end. Comma and period read the bars one at a time."
39
- }, I = (e, t) => e.replace(/\{(\w+)\}/g, (e, n) => n in t ? String(t[n]) : e), Mt = [
39
+ }, A = (e, t) => e.replace(/\{(\w+)\}/g, (e, n) => n in t ? String(t[n]) : e), Ut = [
40
40
  "role",
41
41
  "aria-roledescription",
42
42
  "aria-label",
43
43
  "aria-describedby"
44
- ], Nt = 400, Pt = 1e3, Ft = class {
44
+ ], Wt = 400, Gt = 1e3, Kt = class {
45
45
  live;
46
46
  help;
47
47
  labels;
@@ -55,20 +55,20 @@ var F = {
55
55
  };
56
56
  constructor(e, t, n = {}) {
57
57
  this.container = e, this.source = t, this.labels = {
58
- ...F,
58
+ ...Ht,
59
59
  ...n
60
60
  };
61
- for (let t of Mt) this.before.set(t, e.getAttribute(t));
62
- e.setAttribute("role", "application"), this.help = L("div", "tc-sr-only"), this.help.id = `tc-chart-keys-${Math.random().toString(36).slice(2, 10)}`, e.setAttribute("aria-describedby", this.help.id), this.live = L("div", "tc-sr-only tc-sr-live"), this.live.setAttribute("aria-live", "polite"), this.live.setAttribute("aria-atomic", "true"), e.append(this.help, this.live), e.addEventListener("blur", this.onBlur), this.applyLabels();
61
+ for (let t of Ut) this.before.set(t, e.getAttribute(t));
62
+ e.setAttribute("role", "application"), this.help = qt("div", "tc-sr-only"), this.help.id = `tc-chart-keys-${Math.random().toString(36).slice(2, 10)}`, e.setAttribute("aria-describedby", this.help.id), this.live = qt("div", "tc-sr-only tc-sr-live"), this.live.setAttribute("aria-live", "polite"), this.live.setAttribute("aria-atomic", "true"), e.append(this.help, this.live), e.addEventListener("blur", this.onBlur), this.applyLabels();
63
63
  }
64
64
  setLabels(e) {
65
65
  this.labels = {
66
- ...F,
66
+ ...Ht,
67
67
  ...e
68
68
  }, this.applyLabels();
69
69
  }
70
70
  refresh(e = !1) {
71
- let t = Pt - (Date.now() - this.summaryAt);
71
+ let t = Gt - (Date.now() - this.summaryAt);
72
72
  if (e || t <= 0 || this.container.getAttribute("aria-label") === this.labels.empty) {
73
73
  this.summaryTimer && clearTimeout(this.summaryTimer), this.summaryTimer = null, this.summaryAt = Date.now(), this.container.setAttribute("aria-label", this.summary());
74
74
  return;
@@ -80,7 +80,7 @@ var F = {
80
80
  viewMoved() {
81
81
  this.cursor = null, this.viewTimer && clearTimeout(this.viewTimer), this.viewTimer = setTimeout(() => {
82
82
  this.viewTimer = null, this.say(this.viewText());
83
- }, Nt);
83
+ }, Wt);
84
84
  }
85
85
  readBar(e) {
86
86
  let t = this.source.bars();
@@ -93,13 +93,13 @@ var F = {
93
93
  let i = t[this.cursor];
94
94
  this.source.showBar(i.time);
95
95
  let a = this.source.formatPrice;
96
- this.say(I(this.labels.bar, {
96
+ this.say(A(this.labels.bar, {
97
97
  time: this.source.formatTime(i.time),
98
98
  open: a(i.open),
99
99
  high: a(i.high),
100
100
  low: a(i.low),
101
101
  close: a(i.close),
102
- volume: It(i.volume ?? 0)
102
+ volume: Jt(i.volume ?? 0)
103
103
  }));
104
104
  }
105
105
  destroy() {
@@ -118,7 +118,7 @@ var F = {
118
118
  this.labels.typeName ? this.labels.typeName(t) : t,
119
119
  this.source.timeframe()
120
120
  ].filter(Boolean).join(", ");
121
- return I(this.labels.summary, {
121
+ return A(this.labels.summary, {
122
122
  what: n,
123
123
  close: this.source.formatPrice(e[e.length - 1].close)
124
124
  });
@@ -128,7 +128,7 @@ var F = {
128
128
  if (e.length === 0) return this.labels.empty;
129
129
  let t = this.source.visibleRange(), n = Math.max(0, Math.min(e.length - 1, Math.ceil(t.from))), r = Math.max(n, Math.min(e.length - 1, Math.floor(t.to))), i = -Infinity, a = Infinity;
130
130
  for (let t = n; t <= r; t++) i = Math.max(i, e[t].high), a = Math.min(a, e[t].low);
131
- return I(this.labels.view, {
131
+ return A(this.labels.view, {
132
132
  count: r - n + 1,
133
133
  from: this.source.formatTime(e[n].time),
134
134
  to: this.source.formatTime(e[r].time),
@@ -140,7 +140,7 @@ var F = {
140
140
  this.live.textContent = e;
141
141
  }
142
142
  };
143
- function L(e, t) {
143
+ function qt(e, t) {
144
144
  let n = document.createElement(e);
145
145
  return n.className = t, Object.assign(n.style, {
146
146
  position: "absolute",
@@ -154,12 +154,12 @@ function L(e, t) {
154
154
  border: "0"
155
155
  }), n;
156
156
  }
157
- function It(e) {
157
+ function Jt(e) {
158
158
  return Number.isInteger(e) ? String(e) : e.toFixed(2);
159
159
  }
160
160
  //#endregion
161
161
  //#region src/indicatorLabel.ts
162
- function Lt(e, t, n, r) {
162
+ function Yt(e, t, n, r) {
163
163
  let i = Object.keys(n || t).map((e) => t[e]).filter((e) => typeof e == "number" && Number.isFinite(e)).slice(0, 3).map((e) => String(Number(e.toFixed(4)))), a = typeof t.symbol == "string" && t.symbol ? [t.symbol] : [];
164
164
  return [
165
165
  e === "spread" && t.mode === "ratio" ? "Ratio" : r ?? e.toUpperCase(),
@@ -169,52 +169,52 @@ function Lt(e, t, n, r) {
169
169
  }
170
170
  //#endregion
171
171
  //#region src/charts/ChartTypeStrategy.ts
172
- function Rt(e) {
172
+ function Xt(e) {
173
173
  switch (e) {
174
174
  case "candlestick":
175
175
  case "heikinAshi":
176
176
  case "lineBreak":
177
- case "rangeBars": return new fe();
178
- case "line": return new Ne();
179
- case "area": return new se();
180
- case "bar": return new ue();
181
- case "hollowCandle": return new ke();
182
- case "baseline": return new de();
183
- case "renko": return new Ge();
184
- case "kagi": return new je();
185
- case "pointAndFigure": return new T();
186
- case "volumeCandles": return new st();
187
- case "equivolume": return new Te();
188
- case "hlcArea": return new Oe();
189
- case "stepLine": return new Qe();
190
- case "lineWithMarkers": return new Pe();
191
- case "hiLo": return new C();
192
- default: return new fe();
193
- }
194
- }
195
- function zt(e, t, n = {}) {
177
+ case "rangeBars": return new ge();
178
+ case "line": return new Re();
179
+ case "area": return new de();
180
+ case "bar": return new me();
181
+ case "hollowCandle": return new Ne();
182
+ case "baseline": return new he();
183
+ case "renko": return new Qe();
184
+ case "kagi": return new Ie();
185
+ case "pointAndFigure": return new qe();
186
+ case "volumeCandles": return new mt();
187
+ case "equivolume": return new ke();
188
+ case "hlcArea": return new Me();
189
+ case "stepLine": return new at();
190
+ case "lineWithMarkers": return new ze();
191
+ case "hiLo": return new w();
192
+ default: return new ge();
193
+ }
194
+ }
195
+ function Zt(e, t, n = {}) {
196
196
  if (t.length === 0) return t;
197
197
  switch (e) {
198
- case "heikinAshi": return xt(t);
198
+ case "heikinAshi": return kt(t);
199
199
  case "renko": {
200
200
  let e = n.renko?.boxSize;
201
- return typeof e == "number" ? M(t, { brickSize: e }) : M(t, {
201
+ return typeof e == "number" ? Pt(t, { brickSize: e }) : Pt(t, {
202
202
  brickSize: 0,
203
203
  useATR: !0,
204
204
  atrPeriod: n.renko?.atrPeriod ?? 14
205
205
  });
206
206
  }
207
- case "lineBreak": return Ct(t, n.lineBreak?.lines ?? 3);
208
- case "kagi": return St(t, n.kagi?.reversal ?? 4, n.kagi?.reversalType ?? "percent");
209
- case "pointAndFigure": return wt(t, Ht(t, n), n.pointAndFigure?.reversal ?? 3);
207
+ case "lineBreak": return jt(t, n.lineBreak?.lines ?? 3);
208
+ case "kagi": return At(t, n.kagi?.reversal ?? 4, n.kagi?.reversalType ?? "percent");
209
+ case "pointAndFigure": return Mt(t, en(t, n), n.pointAndFigure?.reversal ?? 3);
210
210
  case "rangeBars": {
211
211
  let e = n.rangeBars?.range;
212
- return Tt(t, { rangeSize: typeof e == "number" ? e : Ut(t) * .005 });
212
+ return Nt(t, { rangeSize: typeof e == "number" ? e : j(t) * .005 });
213
213
  }
214
214
  default: return t;
215
215
  }
216
216
  }
217
- function Bt(e) {
217
+ function Qt(e) {
218
218
  switch (e) {
219
219
  case "heikinAshi":
220
220
  case "renko":
@@ -225,30 +225,30 @@ function Bt(e) {
225
225
  default: return !1;
226
226
  }
227
227
  }
228
- function Vt(e) {
229
- return e !== "heikinAshi" && Bt(e);
228
+ function $t(e) {
229
+ return e !== "heikinAshi" && Qt(e);
230
230
  }
231
- function Ht(e, t = {}) {
231
+ function en(e, t = {}) {
232
232
  let n = t.pointAndFigure?.boxSize;
233
- return typeof n == "number" ? n : Ut(e) * .01;
233
+ return typeof n == "number" ? n : j(e) * .01;
234
234
  }
235
- function Ut(e) {
235
+ function j(e) {
236
236
  let t = 0;
237
237
  for (let n of e) t += n.close;
238
238
  return t / e.length;
239
239
  }
240
- function Wt(e, t) {
240
+ function tn(e, t) {
241
241
  let n = t?.(e);
242
- return n ? n.createRenderer() : Rt(e);
242
+ return n ? n.createRenderer() : Xt(e);
243
243
  }
244
- function Gt(e, t, n, r) {
244
+ function nn(e, t, n, r) {
245
245
  if (t.length === 0) return t;
246
246
  let i = n?.(e);
247
- return i?.transform ? i.transform(t) : zt(e, t, r);
247
+ return i?.transform ? i.transform(t) : Zt(e, t, r);
248
248
  }
249
249
  //#endregion
250
250
  //#region src/state/AutoSaveScheduler.ts
251
- var Kt = class {
251
+ var rn = class {
252
252
  timer = null;
253
253
  delayMs = 0;
254
254
  key = null;
@@ -278,15 +278,15 @@ var Kt = class {
278
278
  };
279
279
  //#endregion
280
280
  //#region src/DataManager.ts
281
- function R(e) {
281
+ function M(e) {
282
282
  if (!e || typeof e.time != "number" || !Number.isFinite(e.time)) return !1;
283
283
  let { open: t, high: n, low: r, close: i } = e;
284
284
  return !(!isFinite(t) || !isFinite(n) || !isFinite(r) || !isFinite(i) || t < 0 || n < 0 || r < 0 || i < 0 || n < r || e.volume !== void 0 && (!isFinite(e.volume) || e.volume < 0));
285
285
  }
286
- function qt(e) {
286
+ function N(e) {
287
287
  return e.volume !== void 0 && e.high >= e.open && e.high >= e.close && e.low <= e.open && e.low <= e.close;
288
288
  }
289
- function z(e) {
289
+ function P(e) {
290
290
  return {
291
291
  ...e,
292
292
  high: Math.max(e.open, e.high, e.low, e.close),
@@ -294,7 +294,7 @@ function z(e) {
294
294
  volume: e.volume === void 0 ? 0 : Math.max(0, e.volume)
295
295
  };
296
296
  }
297
- var B = class {
297
+ var F = class {
298
298
  data = [];
299
299
  getData() {
300
300
  return this.data;
@@ -303,7 +303,7 @@ var B = class {
303
303
  let t = [];
304
304
  for (let n = 0; n < e.length; n++) {
305
305
  let r = e[n];
306
- R(r) && t.push(qt(r) ? r : z(r));
306
+ M(r) && t.push(N(r) ? r : P(r));
307
307
  }
308
308
  this.data = t;
309
309
  }
@@ -311,7 +311,7 @@ var B = class {
311
311
  let t = this.data.length > 0 ? this.data[0].time : Infinity, n = [];
312
312
  for (let r = 0; r < e.length; r++) {
313
313
  let i = e[r];
314
- !R(i) || i.time >= t || n.push(qt(i) ? i : z(i));
314
+ !M(i) || i.time >= t || n.push(N(i) ? i : P(i));
315
315
  }
316
316
  if (n.length === 0) return 0;
317
317
  n.sort((e, t) => e.time - t.time);
@@ -320,11 +320,11 @@ var B = class {
320
320
  return n.length = r, this.data = n.concat(this.data), r;
321
321
  }
322
322
  appendBar(e) {
323
- R(e) && this.data.push(z(e));
323
+ M(e) && this.data.push(P(e));
324
324
  }
325
325
  updateLastBar(e) {
326
- if (!R(e)) return;
327
- let t = z(e);
326
+ if (!M(e)) return;
327
+ let t = P(e);
328
328
  if (this.data.length === 0) {
329
329
  this.data.push(t);
330
330
  return;
@@ -332,7 +332,7 @@ var B = class {
332
332
  this.data[this.data.length - 1] = t;
333
333
  }
334
334
  updateLastBarFromTick(e) {
335
- this.data.length !== 0 && (!isFinite(e.price) || e.price < 0 || e.volume !== void 0 && (!isFinite(e.volume) || e.volume < 0) || (this.data[this.data.length - 1] = p(this.data[this.data.length - 1], e)));
335
+ this.data.length !== 0 && (!isFinite(e.price) || e.price < 0 || e.volume !== void 0 && (!isFinite(e.volume) || e.volume < 0) || (this.data[this.data.length - 1] = m(this.data[this.data.length - 1], e)));
336
336
  }
337
337
  getLength() {
338
338
  return this.data.length;
@@ -340,7 +340,7 @@ var B = class {
340
340
  clear() {
341
341
  this.data = [];
342
342
  }
343
- }, Jt = 5e3, Yt = 6e4, Xt = 500, Zt = class {
343
+ }, I = 5e3, an = 6e4, on = 500, sn = class {
344
344
  loader = null;
345
345
  pageSize = 500;
346
346
  loading = !1;
@@ -381,7 +381,7 @@ var B = class {
381
381
  try {
382
382
  r = await e(t, this.pageSize);
383
383
  } catch (e) {
384
- return n === this.seq ? (this.loading = !1, this.failures++, this.retryAt = this.now() + Math.min(Yt, Jt * 2 ** (this.failures - 1)), this.emit({
384
+ return n === this.seq ? (this.loading = !1, this.failures++, this.retryAt = this.now() + Math.min(an, I * 2 ** (this.failures - 1)), this.emit({
385
385
  state: "error",
386
386
  count: 0,
387
387
  error: e instanceof Error ? e.message : String(e)
@@ -411,34 +411,116 @@ var B = class {
411
411
  now() {
412
412
  return this.host.now ? this.host.now() : Date.now();
413
413
  }
414
- }, Qt = class {
415
- theme;
414
+ }, L = class t {
415
+ base;
416
416
  shape = null;
417
- constructor(t) {
418
- !t || t === "dark" ? this.theme = { ...e } : t === "light" ? this.theme = { ...n } : this.theme = { ...t };
417
+ chartType = "candlestick";
418
+ host = {};
419
+ user = /* @__PURE__ */ new Map();
420
+ effective = null;
421
+ constructor(e) {
422
+ this.base = t.read(e);
423
+ }
424
+ static read(t) {
425
+ if (!t || t === "dark") return { ...e };
426
+ if (t === "light") return { ...n };
427
+ let { style: r, ...i } = t;
428
+ return i;
419
429
  }
420
430
  getTheme() {
421
- return this.theme;
431
+ return this.effective ??= te(this.base, this.chartType, this.merged()), this.effective;
432
+ }
433
+ getBaseTheme() {
434
+ return this.base;
422
435
  }
423
- setTheme(t) {
424
- t === "dark" ? this.theme = { ...e } : t === "light" ? this.theme = { ...n } : this.theme = { ...t }, this.shape && (this.theme = {
425
- ...this.theme,
436
+ setTheme(e) {
437
+ this.base = t.read(e), this.shape && (this.base = {
438
+ ...this.base,
426
439
  shape: {
427
- ...this.theme.shape,
440
+ ...this.base.shape,
428
441
  ...this.shape
429
442
  }
430
- });
443
+ }), this.effective = null;
431
444
  }
432
445
  setShape(e) {
433
- this.shape = e ? { ...e } : null, this.theme = {
434
- ...this.theme,
446
+ this.shape = e ? { ...e } : null, this.base = {
447
+ ...this.base,
435
448
  shape: e ? {
436
- ...this.theme.shape,
449
+ ...this.base.shape,
437
450
  ...e
438
- } : this.theme.shape
451
+ } : this.base.shape
452
+ }, this.effective = null;
453
+ }
454
+ setChartType(e) {
455
+ e !== this.chartType && (this.chartType = e, this.effective = null);
456
+ }
457
+ applyOverrides(e, t) {
458
+ let n = { ...this.layer(t) };
459
+ for (let [t, r] of Object.entries(e)) r == null ? delete n[t] : n[t] = r;
460
+ return this.setLayer(t, n);
461
+ }
462
+ setOverrides(e, t) {
463
+ return this.setLayer(t, { ...e });
464
+ }
465
+ resetOverrides(e, t) {
466
+ if (!t) return this.setLayer(e, {});
467
+ let n = { ...this.layer(e) };
468
+ for (let e of t) delete n[e];
469
+ return this.setLayer(e, n);
470
+ }
471
+ getOverrides(e) {
472
+ return { ...this.layer(e) };
473
+ }
474
+ getUserOverrides() {
475
+ let e = {};
476
+ for (let [t, n] of this.user) Object.keys(n).length > 0 && (e[t] = { ...n });
477
+ return e;
478
+ }
479
+ setUserOverrides(e) {
480
+ return JSON.stringify(e) === JSON.stringify(this.getUserOverrides()) ? !1 : (this.user = new Map(Object.entries(e).map(([e, t]) => [e, { ...t }])), this.effective = null, !0);
481
+ }
482
+ getStyleValue(e) {
483
+ return c(this.base, this.merged(), e, this.chartType);
484
+ }
485
+ layer(e) {
486
+ return e === "host" ? this.host : this.user.get(this.base.name) ?? {};
487
+ }
488
+ setLayer(e, t) {
489
+ return JSON.stringify(t) === JSON.stringify(this.layer(e)) ? !1 : (e === "host" ? this.host = t : Object.keys(t).length > 0 ? this.user.set(this.base.name, t) : this.user.delete(this.base.name), this.effective = null, !0);
490
+ }
491
+ merged() {
492
+ return {
493
+ ...this.host,
494
+ ...this.user.get(this.base.name)
439
495
  };
440
496
  }
441
- }, $t = 200, en = 80, V = (e) => e.position === "top" || e.position === "bottom", tn = class {
497
+ };
498
+ //#endregion
499
+ //#region src/style/styleOptions.ts
500
+ function R(e, t) {
501
+ return t ? {
502
+ ...t.visible === void 0 ? {} : { [`crosshair.${e}.visible`]: t.visible },
503
+ ...t.color === void 0 ? {} : { [`crosshair.${e}.color`]: t.color },
504
+ ...t.style === void 0 ? {} : { [`crosshair.${e}.style`]: t.style },
505
+ ...t.width === void 0 ? {} : { [`crosshair.${e}.width`]: t.width }
506
+ } : {};
507
+ }
508
+ function cn(e) {
509
+ let { grid: t, crosshair: n } = e, r = n?.vLine?.labelBackground ?? n?.hLine?.labelBackground;
510
+ return {
511
+ ...t?.hLineColor === void 0 ? {} : { "grid.horizontal.color": t.hLineColor },
512
+ ...t?.hLineStyle === void 0 ? {} : { "grid.horizontal.style": t.hLineStyle },
513
+ ...t?.vLineColor === void 0 ? {} : { "grid.vertical.color": t.vLineColor },
514
+ ...t?.vLineStyle === void 0 ? {} : { "grid.vertical.style": t.vLineStyle },
515
+ ...R("horizontal", n?.hLine),
516
+ ...R("vertical", n?.vLine),
517
+ ...r === void 0 ? {} : { "crosshair.labelBackground": r },
518
+ ...e.overrides
519
+ };
520
+ }
521
+ //#endregion
522
+ //#region src/layout/LayoutManager.ts
523
+ var z = 200, B = 80, V = (e) => e.position === "top" || e.position === "bottom", ln = class {
442
524
  panels = [];
443
525
  containerWidth = 0;
444
526
  containerHeight = 0;
@@ -454,8 +536,8 @@ var B = class {
454
536
  this.panels.push({
455
537
  id: e,
456
538
  position: n,
457
- size: r ?? (a ? $t : t),
458
- minSize: a ? en : i,
539
+ size: r ?? (a ? z : t),
540
+ minSize: a ? B : i,
459
541
  content: {
460
542
  type: "indicator",
461
543
  indicatorInstanceId: e
@@ -524,7 +606,7 @@ var B = class {
524
606
  let r = this.panels.find((t) => t.id === e);
525
607
  if (r) {
526
608
  let a = r.position === "left" || r.position === "right", o = n === "left" || n === "right";
527
- r.position = n, a !== o && (r.size = o ? $t : t, r.minSize = o ? en : i), o && (r.collapsed = void 0, this.maximized === e && (this.maximized = null));
609
+ r.position = n, a !== o && (r.size = o ? z : t, r.minSize = o ? B : i), o && (r.collapsed = void 0, this.maximized === e && (this.maximized = null));
528
610
  }
529
611
  }
530
612
  setPanelSize(e, t) {
@@ -640,24 +722,24 @@ var B = class {
640
722
  getMainChartRect() {
641
723
  return this.resolve().mainChartRect;
642
724
  }
643
- }, nn = 14, rn = 14, an = 22, on = 4;
644
- function sn(e) {
645
- let { min: t, max: n, lastPrice: r, locale: i, fontFamily: o, fontSizeSmall: c, measure: u } = e, d = s(t, n), f = e.tagPrecision ?? d, p = r === null ? [t, n] : [
725
+ }, un = 14, dn = 14, fn = 22, pn = 4;
726
+ function mn(e) {
727
+ let { min: t, max: n, lastPrice: r, locale: i, fontFamily: o, fontSizeSmall: c, measure: l } = e, d = s(t, n), f = e.tagPrecision ?? d, p = r === null ? [t, n] : [
646
728
  t,
647
729
  n,
648
730
  r
649
731
  ], m = a;
650
732
  for (let t of p) {
651
733
  if (!Number.isFinite(t)) continue;
652
- let n = e.format ? e.format(t) : l(t, d, i), r = e.format ? n : l(t, f, i);
653
- m = Math.max(m, u(n, `500 ${c}px ${o}`) + nn, u(r, `bold 11px ${o}`) + rn, u(r, `600 ${c}px ${o}`) + an);
734
+ let n = e.format ? e.format(t) : u(t, d, i), r = e.format ? n : u(t, f, i);
735
+ m = Math.max(m, l(n, `500 ${c}px ${o}`) + un, l(r, `bold 11px ${o}`) + dn, l(r, `600 ${c}px ${o}`) + fn);
654
736
  }
655
- return m <= a ? a : Math.ceil(m / on) * on;
737
+ return m <= a ? a : Math.ceil(m / pn) * pn;
656
738
  }
657
- function cn(e, t) {
739
+ function hn(e, t) {
658
740
  return t > e || t <= e - 12 ? t : e;
659
741
  }
660
- var ln = class {
742
+ var gn = class {
661
743
  netY = 0;
662
744
  travelX = 0;
663
745
  engaged = !1;
@@ -673,8 +755,8 @@ var ln = class {
673
755
  }
674
756
  return this.engaged;
675
757
  }
676
- }, un = 1;
677
- function dn(e, t) {
758
+ }, _n = 1;
759
+ function vn(e, t) {
678
760
  return e.filter((e) => (e.descriptor.layer ?? "overlay") === t);
679
761
  }
680
762
  function H(e) {
@@ -688,24 +770,24 @@ function H(e) {
688
770
  //#endregion
689
771
  //#region src/plugins/registry.ts
690
772
  var U = /* @__PURE__ */ new Map();
691
- function fn(e) {
773
+ function yn(e) {
692
774
  U.set(H(e), e);
693
775
  }
694
- function pn(e) {
776
+ function bn(e) {
695
777
  return U.delete(e);
696
778
  }
697
- function mn() {
779
+ function W() {
698
780
  return [...U.values()];
699
781
  }
700
- function hn() {
782
+ function xn() {
701
783
  U.clear();
702
784
  }
703
785
  //#endregion
704
786
  //#region src/plugins/PluginManager.ts
705
- var gn = class {
787
+ var Sn = class {
706
788
  plugins = /* @__PURE__ */ new Map();
707
789
  constructor(e, t = {}) {
708
- if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of mn()) this.add(e);
790
+ if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of W()) this.add(e);
709
791
  for (let e of t.plugins ?? []) this.add(e);
710
792
  }
711
793
  register(e) {
@@ -735,15 +817,15 @@ var gn = class {
735
817
  add(e) {
736
818
  this.plugins.set(H(e), e), e.kind === "indicator" && this.indicatorEngine.register(e.plugin);
737
819
  }
738
- }, _n = {
820
+ }, Cn = {
739
821
  orderPlace: (e, t) => e.placeOrder(t),
740
822
  orderModify: (e, t) => e.modifyOrder(t),
741
823
  orderCancel: (e, t) => e.cancelOrder(t),
742
824
  positionModify: (e, t) => e.modifyPosition(t),
743
825
  positionClose: (e, t) => e.closePosition(t),
744
- positionReverse: (e, t, n) => vn(e, t, n)
826
+ positionReverse: (e, t, n) => wn(e, t, n)
745
827
  };
746
- async function vn(e, t, n) {
828
+ async function wn(e, t, n) {
747
829
  let { reversing: r } = n;
748
830
  if (!r.has(t.positionId)) {
749
831
  r.add(t.positionId);
@@ -772,7 +854,7 @@ async function vn(e, t, n) {
772
854
  }
773
855
  }
774
856
  }
775
- function yn(e, t) {
857
+ function Tn(e, t) {
776
858
  let n = [], r = null, i = {
777
859
  positions: () => r ?? t.getPositions?.() ?? [],
778
860
  reversing: /* @__PURE__ */ new Set()
@@ -782,8 +864,8 @@ function yn(e, t) {
782
864
  e.data && t.onFill?.(e.data);
783
865
  };
784
866
  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));
785
- for (let r of Object.keys(_n)) {
786
- let a = _n[r], o = t.onIntent(r, (n) => {
867
+ for (let r of Object.keys(Cn)) {
868
+ let a = Cn[r], o = t.onIntent(r, (n) => {
787
869
  Promise.resolve(a(e, n, i)).catch((e) => t.onError({
788
870
  message: `Execution command failed: ${r}`,
789
871
  cause: e
@@ -797,16 +879,16 @@ function yn(e, t) {
797
879
  }
798
880
  //#endregion
799
881
  //#region src/Chart.ts
800
- var bn = {
882
+ var En = {
801
883
  min: 0,
802
884
  max: 100
803
- }, xn = 0xe8d4a51000, Sn = "exchange";
804
- function Cn(e) {
805
- if (typeof e == "string" && e !== "exchange" && !f(e)) throw RangeError(`Unknown time zone: ${e}`);
885
+ }, Dn = 0xe8d4a51000, On = "exchange";
886
+ function kn(e) {
887
+ if (typeof e == "string" && e !== "exchange" && !p(e)) throw RangeError(`Unknown time zone: ${e}`);
806
888
  if (typeof e == "number" && !Number.isFinite(e)) throw RangeError(`Invalid UTC offset: ${e}`);
807
889
  }
808
- var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
809
- static version = "1.12.0";
890
+ var An = 2, jn = .08, Mn = 800, Nn = 20, Pn = 8, Fn = class {
891
+ static version = "1.14.0";
810
892
  engine;
811
893
  viewport;
812
894
  dataManager;
@@ -827,6 +909,8 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
827
909
  indicatorUpdateFrom = null;
828
910
  resolvedLayoutCache = null;
829
911
  panelInfoCache = null;
912
+ paneStyles = /* @__PURE__ */ new Map();
913
+ lastBackground = null;
830
914
  renderScheduled = !1;
831
915
  priceAxisWidth = a;
832
916
  measureCtx;
@@ -842,14 +926,14 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
842
926
  indicatorHistoryDepth = 0;
843
927
  removedDrawingAlerts = /* @__PURE__ */ new Map();
844
928
  zoomAreaMode = !1;
845
- priceAxisAddButton = new He();
929
+ priceAxisAddButton = new Ye();
846
930
  displayTz = null;
847
931
  timezoneSetting = null;
848
932
  symbolInfo = null;
849
933
  symbolInfoSeq = 0;
850
934
  sessionBreaks;
851
935
  sessionShading;
852
- hostSessionHours = { ...xe };
936
+ hostSessionHours = { ...Te };
853
937
  compareRenderer;
854
938
  countdownInterval = null;
855
939
  volumeRenderer;
@@ -862,15 +946,17 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
862
946
  signalMarkerManager;
863
947
  tradeZoneManager;
864
948
  measureOverlay;
865
- selectionBoxOverlay = new qe();
949
+ selectionBoxOverlay = new et();
866
950
  replayManager;
867
951
  replayBarUnsub = null;
868
952
  replaySeeking = !1;
869
953
  replaySession = null;
870
954
  replayStepsSeries = null;
871
955
  replayCoarse = null;
956
+ replayRevealMarks = !0;
957
+ replayOffset = 0;
872
958
  undoRedoManager;
873
- autoSaveScheduler = new Kt((e) => this.saveState(e));
959
+ autoSaveScheduler = new rn((e) => this.saveState(e));
874
960
  animator;
875
961
  crosshairTooltip;
876
962
  pinnedTooltip;
@@ -882,15 +968,15 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
882
968
  disposed = !1;
883
969
  chartTypeOptions = {};
884
970
  mainSeriesVisible = !0;
885
- priceLines = new Ue();
886
- symbolSeries = new et();
971
+ priceLines = new Xe();
972
+ symbolSeries = new st();
887
973
  extendedHours = !0;
888
974
  replayRestarting = !1;
889
975
  fullSeries = null;
890
976
  requestedSymbols = /* @__PURE__ */ new Set();
891
977
  gridRenderer;
892
978
  priceAxis;
893
- leftPriceAxis = new E();
979
+ leftPriceAxis = new Je();
894
980
  leftScaleRequested = !1;
895
981
  leftAxisWidth = a;
896
982
  leftViewport = null;
@@ -920,7 +1006,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
920
1006
  snapshotKey = null;
921
1007
  historyCheckQueued = !1;
922
1008
  constructor(e, t) {
923
- t.timeZone != null && Cn(t.timeZone), this.container = e, this.options = {
1009
+ t.timeZone != null && kn(t.timeZone), this.container = e, this.options = {
924
1010
  ...t,
925
1011
  chartType: t.chartType ?? "candlestick"
926
1012
  }, this.numberLocale = t.numberLocale ?? "en-US", this.defaultAutoScale = t.autoScale !== !1;
@@ -958,15 +1044,15 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
958
1044
  logScale: n.logScale ?? !0,
959
1045
  timeframes: n.timeframes ?? [],
960
1046
  defaultTimeframeFavorites: n.defaultTimeframeFavorites ?? []
961
- }, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", e.style.userSelect = "none", e.style.webkitUserSelect = "none", this.dataManager = new B(), this.history = new Zt({
1047
+ }, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", e.style.userSelect = "none", e.style.webkitUserSelect = "none", this.dataManager = new F(), this.history = new sn({
962
1048
  oldestTime: () => this.dataManager.getData()[0]?.time ?? null,
963
1049
  prepend: (e) => this.prependBars(e),
964
1050
  emit: (e) => this.eventBus.emit("historyLoad", e)
965
- }), this.themeManager = new Qt(t.theme), this.layoutManager = new tn(), this.indicatorEngine = new w(), this.pluginManager = new gn(this.indicatorEngine, { plugins: t.plugins }), this.eventBus = new Ee(), O(this.indicatorEngine), this.indicatorEngine.register(new he(this.symbolSeries)), this.indicatorEngine.register(new Ze(this.symbolSeries)), this.indicatorEngine.register(new ge(this.symbolSeries)), this.indicatorEngine.register(new _e(this.symbolSeries)), this.drawingManager = new Ce(), bt(this.drawingManager), this.drawingRenderer = new we(this.drawingManager), this.drawingManager.setRequestRender(() => {
1051
+ }), this.themeManager = new L(t.theme), this.themeManager.setChartType(this.options.chartType ?? "candlestick"), this.applyStyle(cn(t), "host", !1), this.layoutManager = new ln(), this.indicatorEngine = new Pe(), this.pluginManager = new Sn(this.indicatorEngine, { plugins: t.plugins }), this.eventBus = new Ae(), E(this.indicatorEngine), this.indicatorEngine.register(new ye(this.symbolSeries)), this.indicatorEngine.register(new it(this.symbolSeries)), this.indicatorEngine.register(new be(this.symbolSeries)), this.indicatorEngine.register(new xe(this.symbolSeries)), this.drawingManager = new De(), Dt(this.drawingManager), this.drawingRenderer = new Oe(this.drawingManager), this.drawingManager.setRequestRender(() => {
966
1052
  this.syncRenderContext(), this.engine.requestRender(r.Overlay), this.scheduleAutoSave();
967
1053
  }), this.drawingManager.setEventCallback((e, t) => {
968
1054
  this.followDrawingAlerts(e, t?.id), this.eventBus.emit(e, t), (e === "drawingCreate" || e === "drawingUpdate" || e === "drawingRemove") && this.announceStateChange();
969
- }), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new at();
1055
+ }), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new ft();
970
1056
  let i = "";
971
1057
  this.undoRedoManager.setOnChange(() => {
972
1058
  let { canUndo: e, canRedo: t } = this.undoRedoManager.getState(), n = `${e}|${t}`;
@@ -979,21 +1065,21 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
979
1065
  primary: e[0] ?? null
980
1066
  })), this.drawingManager.setForeignHistory((e, t) => {
981
1067
  e.type === "custom" ? e.custom?.[t]() : this.applyIndicatorStep(e, t);
982
- }), this.drawingManager.setDataGetter(() => this.dataManager.getData()), this.drawingManager.setDisplayDataGetter(() => this.getDisplayData()), t.crosshair?.mode === "magnet" && this.features.drawingMagnet && this.drawingManager.setMagnetMode("magnet"), this.tradingManager = new rt({
1068
+ }), this.drawingManager.setDataGetter(() => this.dataManager.getData()), this.drawingManager.setDisplayDataGetter(() => this.getDisplayData()), t.crosshair?.mode === "magnet" && this.features.drawingMagnet && this.drawingManager.setMagnetMode("magnet"), this.tradingManager = new ut({
983
1069
  enabled: this.features.trading,
984
1070
  contextMenu: { enabled: this.features.tradingContextMenu }
985
- }), this.tradingRenderer = new it(this.tradingManager), this.tradingManager.setContainer(e), this.tradingManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradingManager.setEventCallback((e, t) => {
1071
+ }), this.tradingRenderer = new dt(this.tradingManager), this.tradingManager.setContainer(e), this.tradingManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradingManager.setEventCallback((e, t) => {
986
1072
  this.eventBus.emit(e, t);
987
- }), this.engine = new We(e);
1073
+ }), this.engine = new Ze(e);
988
1074
  let a = this.engine.dprManager.getContainerSize();
989
- if (this.viewport = new ot(a.width, a.height, t.minBarSpacing ?? 2, t.maxBarSpacing ?? 30, t.rightMargin ?? 5), this.viewport.setPanLimits({
1075
+ if (this.viewport = new pt(a.width, a.height, t.minBarSpacing ?? 2, t.maxBarSpacing ?? 30, t.rightMargin ?? 5), this.viewport.setPanLimits({
990
1076
  freePan: t.freePan ?? !0,
991
1077
  minVisibleBars: t.panLimits?.minVisibleBars ?? 3
992
1078
  }), this.layoutManager.resize(a.width, a.height), this.engine.onContainerResize = (e) => {
993
1079
  if (e.width <= 0 || e.height <= 0) return;
994
1080
  let t = this.viewport.isAtEnd();
995
1081
  this.viewport.resize(e.width, e.height), this.layoutManager.resize(e.width, e.height), this.updateViewportAndRender(t);
996
- }, this.chartRenderer = this.createChartRenderer(this.options.chartType), this.gridRenderer = new De(), t.grid?.visible === !1 && this.gridRenderer.setVisible(!1), this.priceAxis = new E(), this.priceAxis.setLocale(this.numberLocale), this.leftPriceAxis.setLocale(this.numberLocale), this.timeAxis = new tt(), this.crosshairHandler = new ve(), this.crosshairHandler.setLocale(this.numberLocale), t.crosshair?.mode && this.crosshairHandler.setMode(t.crosshair.mode), this.crosshairHandler.setCallback((e, t) => {
1082
+ }, this.chartRenderer = this.createChartRenderer(this.options.chartType), this.gridRenderer = new je(), t.grid?.visible === !1 && this.gridRenderer.setVisible(!1), this.priceAxis = new Je(), this.priceAxis.setLocale(this.numberLocale), this.leftPriceAxis.setLocale(this.numberLocale), this.timeAxis = new ct(), this.crosshairHandler = new Se(), this.crosshairHandler.setLocale(this.numberLocale), t.crosshair?.mode && this.crosshairHandler.setMode(t.crosshair.mode), this.crosshairHandler.setCallback((e, t) => {
997
1083
  if (e !== null && t) {
998
1084
  let n = this.dataManager.getData(), r = e < n.length ? n[e] : void 0;
999
1085
  this.chartLegend.setHoverBar(r ?? null);
@@ -1002,19 +1088,19 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1002
1088
  prevClose: e > 0 ? n[e - 1]?.close : void 0,
1003
1089
  priceRange: i.priceRange,
1004
1090
  plot: i.chartRect,
1005
- barStepMs: ft(n)
1091
+ barStepMs: yt(n)
1006
1092
  }) : this.crosshairTooltip.hide(), this.pinnedTooltip.isPinned() && this.pinnedTooltip.reposition(this.viewport.getState(), r ?? null, e, this.themeManager.getTheme()), this.eventBus.emit("crosshairMove", {
1007
1093
  point: t,
1008
1094
  bar: r,
1009
1095
  barIndex: e
1010
1096
  });
1011
1097
  } else this.crosshairTooltip.hide(), this.chartLegend.setHoverBar(null), this.eventBus.emit("crosshairLeave", {});
1012
- }), this.chartLegend = new pe(), this.chartLegend.setChartType(this.options.chartType), this.chartLegend.setLocale(this.numberLocale), this.watermark = new ut(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new lt(), this.volumeProfile = new ct(), this.marketProfile = new Fe(), this.depthHeatmap = new Se(), this.periodLevels = new ze(), this.pivotMarkers = new Ve(), this.barCountdown = new le(), this.barCountdown.setVisible(this.features.barCountdown), this.sessionBreaks = new Je(), this.sessionBreaks.setLocale(this.numberLocale), this.sessionShading = new Ye(), this.compareRenderer = new me(), t.sessionBreaks ? this.sessionBreaks.setConfig({
1098
+ }), this.chartLegend = new _e(), this.chartLegend.setChartType(this.options.chartType), this.chartLegend.setLocale(this.numberLocale), this.watermark = new _t(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new gt(), this.volumeProfile = new ht(), this.marketProfile = new Be(), this.depthHeatmap = new Ee(), this.periodLevels = new We(), this.pivotMarkers = new Ke(), this.barCountdown = new pe(), this.barCountdown.setVisible(this.features.barCountdown), this.sessionBreaks = new tt(), this.sessionBreaks.setLocale(this.numberLocale), this.sessionShading = new nt(), this.compareRenderer = new ve(), t.sessionBreaks ? this.sessionBreaks.setConfig({
1013
1099
  visible: t.sessionBreaks.visible ?? !0,
1014
1100
  color: t.sessionBreaks.color,
1015
1101
  lineStyle: t.sessionBreaks.lineStyle,
1016
1102
  lineWidth: t.sessionBreaks.lineWidth
1017
- }) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new oe(), this.crosshairTooltip = new ye(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new Be(), this.pinnedTooltip.create(e), t.priceFormat && this.applyPriceFormat(t.priceFormat), t.chartTypeOptions && (this.chartTypeOptions = _(t.chartTypeOptions)), t.highLowLines && this.priceLines.setHighLow(!0), t.shapes && this.themeManager.setShape(Mn(t.shapes)), this.priceLines.setPriceText((e) => this.formatPrice(e)), t.extendedHours === !1 && (this.extendedHours = !1), t.timeFormatter && this.applyTimeFormatter(t.timeFormatter), this.keyboardHandler = new Me({
1103
+ }) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new ue(), this.crosshairTooltip = new Ce(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new Ge(), this.pinnedTooltip.create(e), t.priceFormat && this.applyPriceFormat(t.priceFormat), t.chartTypeOptions && (this.chartTypeOptions = y(t.chartTypeOptions)), t.highLowLines && this.priceLines.setHighLow(!0), t.shapes && this.themeManager.setShape(Rn(t.shapes)), this.priceLines.setPriceText((e) => this.formatPrice(e)), t.extendedHours === !1 && (this.extendedHours = !1), t.timeFormatter && this.applyTimeFormatter(t.timeFormatter), this.keyboardHandler = new Le({
1018
1104
  scrollBars: (e) => {
1019
1105
  let t = this.viewport.getState().barWidth + this.viewport.getState().barSpacing;
1020
1106
  this.viewport.scrollBy(e * t), this.updateViewportAndRender();
@@ -1031,17 +1117,17 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1031
1117
  },
1032
1118
  fitContent: () => this.fitContent()
1033
1119
  }), this.keyboardHandler.setEnabled(this.features.keyboard), t.a11y !== !1) {
1034
- this.a11y = new Ft(e, {
1120
+ this.a11y = new Kt(e, {
1035
1121
  symbol: () => this.currentSymbol || this.symbolInfo?.symbol || "",
1036
1122
  timeframe: () => this.streamTimeframe ?? "",
1037
1123
  chartType: () => this.options.chartType ?? "candlestick",
1038
1124
  bars: () => this.getDisplayData(),
1039
1125
  visibleRange: () => this.viewport.getState().visibleRange,
1040
1126
  formatPrice: (e) => this.formatPrice(e),
1041
- formatTime: (e) => re(this.numberLocale || "en-US", {
1127
+ formatTime: (e) => se(this.numberLocale || "en-US", {
1042
1128
  dateStyle: "medium",
1043
1129
  timeStyle: "short"
1044
- }, this.displayTz)(e > xn ? e : e * 1e3),
1130
+ }, this.displayTz)(e > Dn ? e : e * 1e3),
1045
1131
  showBar: (e) => this.setCrosshairTime(e)
1046
1132
  }, t.a11y?.labels);
1047
1133
  for (let e of [
@@ -1061,22 +1147,22 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1061
1147
  }
1062
1148
  this.keyboardHandler.handleKey(e) && (e.preventDefault(), this.a11y?.viewMoved());
1063
1149
  }
1064
- }, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new be(), this.currentPriceLine.setLocale(this.numberLocale), this.priceAxis.setReservedPriceProvider(() => this.currentPriceLine.isVisible() ? this.currentPriceLine.getPrice() : null), this.alertManager = new ae(), this.alertManager.setDrawingLevels((e) => this.drawingLevelsNow(e)), this.alertManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.alertManager.on("triggered", (e) => {
1065
- this.eventBus.emit("alertTriggered", G(e)), this.eventBus.emit("dataUpdate", {
1150
+ }, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new we(), this.currentPriceLine.setLocale(this.numberLocale), this.priceAxis.setReservedPriceProvider(() => this.currentPriceLine.isVisible() ? this.currentPriceLine.getPrice() : null), this.alertManager = new le(), this.alertManager.setDrawingLevels((e) => this.drawingLevelsNow(e)), this.alertManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.alertManager.on("triggered", (e) => {
1151
+ this.eventBus.emit("alertTriggered", K(e)), this.eventBus.emit("dataUpdate", {
1066
1152
  alert: "triggered",
1067
1153
  alertId: e.id,
1068
1154
  price: e.price,
1069
1155
  message: e.message
1070
1156
  });
1071
1157
  }), this.alertManager.on("added", (e) => {
1072
- this.eventBus.emit("alertAdd", G(e));
1158
+ this.eventBus.emit("alertAdd", K(e));
1073
1159
  }), this.alertManager.on("removed", (e) => {
1074
1160
  this.eventBus.emit("alertRemove", { id: e });
1075
1161
  }), this.alertManager.on("expired", (e) => {
1076
- this.eventBus.emit("alertExpired", G(e));
1162
+ this.eventBus.emit("alertExpired", K(e));
1077
1163
  }), this.alertManager.on("updated", (e) => {
1078
- this.eventBus.emit("alertUpdate", G(e));
1079
- }), this.signalMarkerManager = new Xe(), this.signalMarkerManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.signalMarkerManager.setDataGetter(() => this.dataManager.getData()), this.signalMarkerManager.on("added", (e) => {
1164
+ this.eventBus.emit("alertUpdate", K(e));
1165
+ }), this.signalMarkerManager = new rt(), this.signalMarkerManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.signalMarkerManager.setDataGetter(() => this.dataManager.getData()), this.signalMarkerManager.on("added", (e) => {
1080
1166
  this.eventBus.emit("signalMarkerAdd", {
1081
1167
  id: e.id,
1082
1168
  source: e.source,
@@ -1084,18 +1170,24 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1084
1170
  });
1085
1171
  }), this.signalMarkerManager.on("removed", (e) => {
1086
1172
  this.eventBus.emit("signalMarkerRemove", { id: e });
1087
- }), this.tradeZoneManager = new nt(), this.tradeZoneManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradeZoneManager.setDataGetter(() => this.dataManager.getData()), this.tradeZoneManager.on("added", (e) => {
1173
+ }), this.tradeZoneManager = new lt(), this.tradeZoneManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradeZoneManager.setDataGetter(() => this.dataManager.getData()), this.tradeZoneManager.on("added", (e) => {
1088
1174
  this.eventBus.emit("tradeZoneAdd", {
1089
1175
  id: e.id,
1090
1176
  direction: e.direction
1091
1177
  });
1092
1178
  }), this.tradeZoneManager.on("removed", (e) => {
1093
1179
  this.eventBus.emit("tradeZoneRemove", { id: e });
1094
- }), this.replayManager = new Ke(), this.replayManager.on("stateChange", (e) => {
1180
+ }), this.replayManager = new $e(), this.replayManager.on("complete", () => {
1181
+ let e = this.getReplayBarIndex(), t = this.replayCoarse?.[e];
1182
+ t && this.eventBus.emit("replayComplete", {
1183
+ barIndex: e,
1184
+ time: t.time
1185
+ });
1186
+ }), this.replayManager.on("stateChange", (e) => {
1095
1187
  this.replayRestarting || this.eventBus.emit("replayState", { state: e });
1096
- }), this.measureOverlay = new Ie(), this.interactionManager = new Ae(e), this.features.panning) {
1097
- let e = new ln();
1098
- this.interactionManager.setPanHandler(new Le((t, n) => {
1188
+ }), this.measureOverlay = new Ve(), this.interactionManager = new Fe(e), this.features.panning) {
1189
+ let e = new gn();
1190
+ this.interactionManager.setPanHandler(new He((t, n) => {
1099
1191
  t && this.viewport.scrollBy(t), e.step(t, n, this.options.autoScale !== !1) && n && (this.options.autoScale = !1, this.viewport.panPriceRange(n)), this.updateViewportAndRender();
1100
1192
  }, () => e.reset()));
1101
1193
  }
@@ -1107,10 +1199,10 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1107
1199
  scales: !this.indicatorEngine.hasLeftScaleOverlays()
1108
1200
  }
1109
1201
  })), this.features.zooming) {
1110
- this.interactionManager.setZoomHandler(new dt((e, t) => {
1202
+ this.interactionManager.setZoomHandler(new vt((e, t) => {
1111
1203
  this.viewport.zoom(e, t - this.viewport.getState().chartRect.x), this.updateViewportAndRender();
1112
1204
  }));
1113
- let e = new ce((e) => {
1205
+ let e = new fe((e) => {
1114
1206
  this.options.autoScale = !1, this.viewport.scalePriceRange(e), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents();
1115
1207
  }, (e) => {
1116
1208
  let t = this.viewport.getState().chartRect.width;
@@ -1130,7 +1222,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1130
1222
  y: t.y
1131
1223
  });
1132
1224
  })), this.interactionManager.setChartContextMenu((e, t) => this.eventBus.hasListeners("chartContextMenu") ? (this.eventBus.emit("chartContextMenu", this.contextAt(e, t)), !0) : !1), this.priceAxisAddButton.setEnabled(this.features.priceAxisAddButton && this.features.crosshair), this.interactionManager.setPriceAxisAddButton(this.priceAxisAddButton, (e) => {
1133
- let t = P(e.y, this.viewport.getState());
1225
+ let t = Rt(e.y, this.viewport.getState());
1134
1226
  Number.isFinite(t) && this.eventBus.emit("priceAxisAdd", {
1135
1227
  price: t,
1136
1228
  x: e.x,
@@ -1140,10 +1232,10 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1140
1232
  ...this.viewport.getState(),
1141
1233
  data: this.getDisplayData()
1142
1234
  })), this.features.alerts) {
1143
- let e = new ie(this.alertManager, () => this.viewport.getState());
1235
+ let e = new ce(this.alertManager, () => this.viewport.getState());
1144
1236
  this.interactionManager.setAlertDragHandler(e);
1145
1237
  }
1146
- let o = new Re();
1238
+ let o = new Ue();
1147
1239
  o.configure(() => this.getResolvedLayout(), (e, t) => this.setPanelSize(e, t)), this.interactionManager.setPaneResizeHandler(o), this.interactionManager.setAltClickHandler((e) => {
1148
1240
  let t = this.getDisplayData();
1149
1241
  if (t.length === 0) return;
@@ -1167,7 +1259,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1167
1259
  x: e.x,
1168
1260
  y: e.y
1169
1261
  }), t.length === 0) return;
1170
- let r = Ot(e.x, this.viewport.getState());
1262
+ let r = Lt(e.x, this.viewport.getState());
1171
1263
  r < 0 || r >= t.length || this.eventBus.emit("barClick", {
1172
1264
  bar: t[r],
1173
1265
  barIndex: r,
@@ -1207,7 +1299,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1207
1299
  end: () => {
1208
1300
  let e = this.selectionBoxOverlay.end();
1209
1301
  if (e && this.zoomAreaMode) {
1210
- if (e.x1 - e.x0 < On) return;
1302
+ if (e.x1 - e.x0 < Pn) return;
1211
1303
  this.zoomToBox(e), this.setZoomAreaMode(!1);
1212
1304
  return;
1213
1305
  }
@@ -1244,7 +1336,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1244
1336
  if (this.replaySession) return 0;
1245
1337
  let t = null;
1246
1338
  if (this.fullSeries) {
1247
- let n = this.fullSeries[0]?.time, r = /* @__PURE__ */ new Set(), i = e.filter((e) => zn(e) && (n === void 0 || e.time < n) && !r.has(e.time) && r.add(e.time)).sort((e, t) => e.time - t.time);
1339
+ let n = this.fullSeries[0]?.time, r = /* @__PURE__ */ new Set(), i = e.filter((e) => Kn(e) && (n === void 0 || e.time < n) && !r.has(e.time) && r.add(e.time)).sort((e, t) => e.time - t.time);
1248
1340
  this.fullSeries = [...i, ...this.fullSeries];
1249
1341
  let a = this.sessionKeep(this.fullSeries);
1250
1342
  t = i.length, e = a ? i.filter((e) => a(e.time)) : i;
@@ -1253,7 +1345,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1253
1345
  if (a === 0) return t ?? 0;
1254
1346
  let o = this.dataManager.getData();
1255
1347
  if (this.crosshairHandler.setData(o), this.displayDataCache = null, this.sessionBreaks.invalidateCache(), this.pinnedTooltip.isPinned() && this.pinnedTooltip.unpin(), this.measureOverlay.end(), this.recalcIndicators(o), i !== void 0) {
1256
- let e = Math.round(j(i, this.getDisplayData()));
1348
+ let e = Math.round(O(i, this.getDisplayData()));
1257
1349
  this.viewport.prependBars(e - r);
1258
1350
  }
1259
1351
  return this.updateViewportAndRender(), t ?? a;
@@ -1284,15 +1376,15 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1284
1376
  }
1285
1377
  checkHistory() {
1286
1378
  this.historyCheckQueued || !this.history.hasLoader() || (this.historyCheckQueued = !0, queueMicrotask(() => {
1287
- if (this.historyCheckQueued = !1, this.replaySession || !this.history.hasLoader() || Vt(this.options.chartType)) return;
1379
+ if (this.historyCheckQueued = !1, this.replaySession || !this.history.hasLoader() || $t(this.options.chartType)) return;
1288
1380
  let { from: e, to: t } = this.viewport.getState().visibleRange;
1289
- this.history.maybeLoad(Math.max(0, Math.floor(e)), Math.max(Dn, t - e));
1381
+ this.history.maybeLoad(Math.max(0, Math.floor(e)), Math.max(Nn, t - e));
1290
1382
  }));
1291
1383
  }
1292
1384
  useStreamHistory(e, t) {
1293
1385
  if (this.hostHistoryLoader) return;
1294
- let n = Dt(e), r = n.fetchHistoryBefore, i = this.streamTimeframe;
1295
- if (!r || i === null || ne(i) !== null) {
1386
+ let n = It(e), r = n.fetchHistoryBefore, i = this.streamTimeframe;
1387
+ if (!r || i === null || ie(i) !== null) {
1296
1388
  this.historyFromStream && this.history.setLoader(null), this.historyFromStream = !1;
1297
1389
  return;
1298
1390
  }
@@ -1352,7 +1444,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1352
1444
  }
1353
1445
  setChartType(e) {
1354
1446
  let t = this.options.chartType ?? "candlestick";
1355
- this.options.chartType = e, this.chartRenderer = this.createChartRenderer(e), this.chartLegend.setChartType(e), this.displayDataCache = null, this.updateViewportAndRender(!0), this.markStateChanged(), e !== t && this.eventBus.emit("chartTypeChange", {
1447
+ this.options.chartType = e, this.themeManager.setChartType(e), this.chartRenderer = this.createChartRenderer(e), this.chartLegend.setChartType(e), this.displayDataCache = null, this.updateViewportAndRender(!0), this.markStateChanged(), e !== t && this.eventBus.emit("chartTypeChange", {
1356
1448
  type: e,
1357
1449
  previous: t
1358
1450
  });
@@ -1360,11 +1452,11 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1360
1452
  setChartTypeOptions(e) {
1361
1453
  this.chartTypeOptions = {
1362
1454
  ...this.chartTypeOptions,
1363
- ..._(e)
1455
+ ...y(e)
1364
1456
  }, this.displayDataCache = null, this.updateViewportAndRender(!0), this.markStateChanged();
1365
1457
  }
1366
1458
  getChartTypeOptions() {
1367
- return _(this.chartTypeOptions);
1459
+ return y(this.chartTypeOptions);
1368
1460
  }
1369
1461
  setExtendedHours(e) {
1370
1462
  e !== this.extendedHours && (this.extendedHours = e, this.reapplyExtendedHours(), this.markStateChanged());
@@ -1373,7 +1465,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1373
1465
  return this.extendedHours;
1374
1466
  }
1375
1467
  sessionKeep(e) {
1376
- return this.extendedHours ? null : jt(this.symbolInfo, e);
1468
+ return this.extendedHours ? null : Vt(this.symbolInfo, e);
1377
1469
  }
1378
1470
  shownBars(e) {
1379
1471
  let t = this.sessionKeep(e);
@@ -1384,7 +1476,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1384
1476
  return this.fullSeries = t ? e.slice() : null, t ? e.filter((e) => t(e.time)) : e;
1385
1477
  }
1386
1478
  placeStreamBar(e) {
1387
- let t = K(this.dataManager.getData(), e);
1479
+ let t = q(this.dataManager.getData(), e);
1388
1480
  return t === "stale" ? !1 : (t === "append" ? this.dataManager.appendBar(e) : this.dataManager.updateLastBar(e), !0);
1389
1481
  }
1390
1482
  takeBar(e, t) {
@@ -1414,7 +1506,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1414
1506
  return this.priceLines.setQuoteShown(this.replaySession === null), this.priceLines;
1415
1507
  }
1416
1508
  setShapes(e) {
1417
- let t = Mn(e);
1509
+ let t = Rn(e);
1418
1510
  t.tagRadius !== void 0 && (this.themeManager.setShape({
1419
1511
  ...this.themeManager.getTheme().shape,
1420
1512
  ...t
@@ -1459,7 +1551,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1459
1551
  setSymbolSeries(e, t) {
1460
1552
  e = e.trim(), this.symbolSeries.set(e, t), this.requestedSymbols.delete(e);
1461
1553
  let n = this.dataManager.getData(), r = !1;
1462
- for (let t of this.indicatorEngine.getActiveIndicators()) !W.has(t.id) || String(t.params.symbol ?? "").trim() !== e.trim() || (this.indicatorEngine.updateIndicator(t.instanceId, {}, n), r = !0);
1554
+ for (let t of this.indicatorEngine.getActiveIndicators()) !G.has(t.id) || String(t.params.symbol ?? "").trim() !== e.trim() || (this.indicatorEngine.updateIndicator(t.instanceId, {}, n), r = !0);
1463
1555
  r && (this.announceIndicatorUpdate(0), this.updateViewportAndRender());
1464
1556
  }
1465
1557
  forgetUnreadSymbols() {
@@ -1473,27 +1565,27 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1473
1565
  let e = /* @__PURE__ */ new Set();
1474
1566
  for (let t of this.indicatorEngine.getActiveIndicators()) {
1475
1567
  let n = t.params.symbol;
1476
- W.has(t.id) && typeof n == "string" && n.trim() && e.add(n.trim());
1568
+ G.has(t.id) && typeof n == "string" && n.trim() && e.add(n.trim());
1477
1569
  }
1478
1570
  return [...e];
1479
1571
  }
1480
1572
  requestMissingSymbols(e) {
1481
1573
  this.forgetUnreadSymbols();
1482
- let t = this.indicatorEngine.getIndicatorConfig(e), n = t && W.has(t.id) && typeof t.params.symbol == "string" ? t.params.symbol.trim() : "";
1574
+ let t = this.indicatorEngine.getIndicatorConfig(e), n = t && G.has(t.id) && typeof t.params.symbol == "string" ? t.params.symbol.trim() : "";
1483
1575
  !n || this.symbolSeries.has(n) || this.requestedSymbols.has(n) || (this.requestedSymbols.add(n), this.eventBus.emit("symbolSeriesRequest", { symbol: n }));
1484
1576
  }
1485
1577
  updateIndicator(e, t) {
1486
1578
  this.recordIndicators(e, () => this.updateIndicatorNow(e, t));
1487
1579
  }
1488
1580
  updateIndicatorNow(e, t) {
1489
- let n = this.indicatorEngine.getIndicatorDescriptor(e), r = n ? A(n) : null, i = r ? this.indicatorEngine.getIndicatorConfig(e)?.params[r] : void 0;
1581
+ let n = this.indicatorEngine.getIndicatorDescriptor(e), r = n ? D(n) : null, i = r ? this.indicatorEngine.getIndicatorConfig(e)?.params[r] : void 0;
1490
1582
  this.indicatorEngine.updateIndicator(e, t, this.dataManager.getData()), this.announceIndicatorUpdate(0), this.markStateChanged(), this.eventBus.emit("indicatorChange", {
1491
1583
  instanceId: e,
1492
1584
  change: "params"
1493
1585
  }), this.requestMissingSymbols(e);
1494
1586
  let a = this.indicatorEngine.getIndicatorConfig(e);
1495
1587
  if (n?.placement === "overlay" && a && r && a.params[r] !== i) {
1496
- let t = h(a.params[r]), n = t ? this.paneHostOf(t.instanceId, e) : h(i) ? null : a.pane ?? null;
1588
+ let t = g(a.params[r]), n = t ? this.paneHostOf(t.instanceId, e) : g(i) ? null : a.pane ?? null;
1497
1589
  (n ?? void 0) !== a.pane && (this.indicatorEngine.setPane(e, n), this.eventBus.emit("indicatorChange", {
1498
1590
  instanceId: e,
1499
1591
  change: "pane"
@@ -1504,7 +1596,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1504
1596
  paneFor(e, t, n, r) {
1505
1597
  if (n) return this.paneHostOf(n, r);
1506
1598
  if (e.placement !== "overlay") return null;
1507
- let i = A(e), a = i ? h(t[i]) : null;
1599
+ let i = D(e), a = i ? g(t[i]) : null;
1508
1600
  return a ? this.paneHostOf(a.instanceId, r) : null;
1509
1601
  }
1510
1602
  paneHostOf(e, t) {
@@ -1547,8 +1639,8 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1547
1639
  return {
1548
1640
  ...e,
1549
1641
  priceRange: {
1550
- min: t.min - n * Tn,
1551
- max: t.max + n * Tn
1642
+ min: t.min - n * jn,
1643
+ max: t.max + n * jn
1552
1644
  },
1553
1645
  logScale: !1,
1554
1646
  scaleMode: "regular",
@@ -1578,7 +1670,9 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1578
1670
  detachIndicator(e) {
1579
1671
  if (!this.indicatorEngine.getIndicatorConfig(e)) return;
1580
1672
  let t = this.layoutManager.getPanels().find((t) => t.id === e), n = this.indicatorEngine.getPaneMembers(e), r = t ? n.find((e) => this.indicatorEngine.getIndicatorDescriptor(e)?.placement === "panel") ?? null : null;
1581
- this.indicatorEngine.removeIndicator(e), r ? (this.indicatorEngine.setPane(r, null), this.layoutManager.renamePanel(e, r)) : this.layoutManager.removePanel(e);
1673
+ this.indicatorEngine.removeIndicator(e);
1674
+ let i = this.paneStyles.get(e);
1675
+ this.paneStyles.delete(e), r ? (this.indicatorEngine.setPane(r, null), this.layoutManager.renamePanel(e, r), i && this.paneStyles.set(r, i)) : this.layoutManager.removePanel(e);
1582
1676
  for (let e of n) e !== r && this.indicatorEngine.setPane(e, r), this.eventBus.emit("indicatorChange", {
1583
1677
  instanceId: e,
1584
1678
  change: "pane"
@@ -1588,6 +1682,28 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1588
1682
  getIndicatorStyle(e) {
1589
1683
  return this.indicatorEngine.getIndicatorStyle(e);
1590
1684
  }
1685
+ setIndicatorDefaults(e, t) {
1686
+ if (!t) {
1687
+ this.indicatorEngine.setStyleDefaults(e, null);
1688
+ return;
1689
+ }
1690
+ let { plots: n, ...r } = t, i = n === void 0 ? void 0 : ee(n);
1691
+ this.indicatorEngine.setStyleDefaults(e, {
1692
+ ...r,
1693
+ ...i ? { plots: i } : {}
1694
+ });
1695
+ }
1696
+ setPaneStyle(e, t) {
1697
+ let n = this.paneOf(e);
1698
+ this.layoutManager.getPanels().some((e) => e.id === n) && this.recordIndicators(n, () => this.setPaneStyleNow(n, t ? b(t) : null));
1699
+ }
1700
+ setPaneStyleNow(e, t) {
1701
+ JSON.stringify(t) !== JSON.stringify(this.paneStyles.get(e) ?? null) && (t ? this.paneStyles.set(e, t) : this.paneStyles.delete(e), this.panelInfoCache = null, this.syncRenderContext(), this.engine.requestRender(), this.markStateChanged());
1702
+ }
1703
+ getPaneStyle(e) {
1704
+ let t = this.paneStyles.get(this.paneOf(e));
1705
+ return t ? { ...t } : null;
1706
+ }
1591
1707
  getIndicatorOutput(e) {
1592
1708
  return this.indicatorEngine.getOutput(e);
1593
1709
  }
@@ -1598,8 +1714,8 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1598
1714
  return this.pluginManager;
1599
1715
  }
1600
1716
  static indicators() {
1601
- let e = new w();
1602
- return O(e), e.getAvailableIndicators();
1717
+ let e = new Pe();
1718
+ return E(e), e.getAvailableIndicators();
1603
1719
  }
1604
1720
  setPanelPosition(e, t) {
1605
1721
  this.layoutManager.setPanelPosition(e, t), this.updateViewportAndRender(), this.eventBus.emit("indicatorChange", {
@@ -1622,8 +1738,8 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1622
1738
  paneMoveHost(e, t) {
1623
1739
  let n = this.indicatorEngine.getIndicatorConfig(e), r = this.indicatorEngine.getIndicatorDescriptor(e);
1624
1740
  if (!n || !r) return;
1625
- let i = A(r);
1626
- if (r.placement === "overlay" && i && h(n.params[i])) return;
1741
+ let i = D(r);
1742
+ if (r.placement === "overlay" && i && g(n.params[i])) return;
1627
1743
  if (t === "price") return r.placement === "overlay" && n.pane ? null : void 0;
1628
1744
  if (t === "new") {
1629
1745
  let t = this.layoutManager.getPanels().some((t) => t.id === e);
@@ -1637,14 +1753,15 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1637
1753
  if (n === void 0 || !r) return !1;
1638
1754
  let i = r.pane, a = this.layoutManager.getPanels().some((t) => t.id === e), o = new Set([e]);
1639
1755
  if (a) {
1640
- let t = this.indicatorEngine.getPaneMembers(e), r = new Set(this.indicatorEngine.getDependents(e)), i = t.filter((e) => !r.has(e)), a = i.find((e) => this.indicatorEngine.getIndicatorDescriptor(e)?.placement === "panel") ?? null;
1641
- if (a) {
1642
- this.indicatorEngine.setPane(a, null), this.layoutManager.renamePanel(e, a);
1756
+ let t = this.indicatorEngine.getPaneMembers(e), r = new Set(this.indicatorEngine.getDependents(e)), i = t.filter((e) => !r.has(e)), a = i.find((e) => this.indicatorEngine.getIndicatorDescriptor(e)?.placement === "panel") ?? null, s = this.paneStyles.get(e);
1757
+ if (this.paneStyles.delete(e), a) {
1758
+ this.indicatorEngine.setPane(a, null), this.layoutManager.renamePanel(e, a), s && this.paneStyles.set(a, s);
1643
1759
  for (let e of i) e !== a && this.indicatorEngine.setPane(e, a);
1644
1760
  } else {
1645
1761
  this.layoutManager.removePanel(e);
1646
1762
  for (let e of i) this.indicatorEngine.setPane(e, null);
1647
1763
  }
1764
+ this.panelInfoCache = null;
1648
1765
  for (let i of t) r.has(i) && this.indicatorEngine.setPane(i, n ?? e), o.add(i);
1649
1766
  }
1650
1767
  if (this.indicatorEngine.setPane(e, n), t === "new") {
@@ -1728,12 +1845,12 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1728
1845
  return this.features.legend ? e + this.chartLegend.getHeight() : e;
1729
1846
  }
1730
1847
  isTimeAligned() {
1731
- return Vt(this.options.chartType) ? !1 : this.getDisplayData().length === this.dataManager.getLength();
1848
+ return $t(this.options.chartType) ? !1 : this.getDisplayData().length === this.dataManager.getLength();
1732
1849
  }
1733
1850
  roundPrice(e) {
1734
1851
  if (!Number.isFinite(e)) return e;
1735
1852
  let t = this.symbolInfo?.minTick ?? this.priceUnit ?? void 0;
1736
- if (t !== void 0 && t > 0) return Number((Math.round(e / t) * t).toFixed(te(t)));
1853
+ if (t !== void 0 && t > 0) return Number((Math.round(e / t) * t).toFixed(re(t)));
1737
1854
  let { min: n, max: r } = this.viewport.getState().priceRange;
1738
1855
  return Number(e.toFixed(this.marketPricePrecision ?? s(n, r)));
1739
1856
  }
@@ -1744,7 +1861,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1744
1861
  return this.priceFormatter;
1745
1862
  }
1746
1863
  applyPriceFormat(e) {
1747
- this.priceFormatter = g(e), this.priceUnit = e && typeof e != "function" ? u(e) : null, this.viewport.setPriceFormat(this.priceFormatter, this.priceUnit), this.crosshairTooltip.setPriceFormatter(this.priceFormatter), this.pinnedTooltip.setPriceFormatter(this.priceFormatter);
1864
+ this.priceFormatter = _(e), this.priceUnit = e && typeof e != "function" ? d(e) : null, this.viewport.setPriceFormat(this.priceFormatter, this.priceUnit), this.crosshairTooltip.setPriceFormatter(this.priceFormatter), this.pinnedTooltip.setPriceFormatter(this.priceFormatter);
1748
1865
  }
1749
1866
  setTimeFormatter(e) {
1750
1867
  this.applyTimeFormatter(e), this.engine.requestRender();
@@ -1755,7 +1872,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1755
1872
  formatPrice(e) {
1756
1873
  if (this.priceFormatter) return this.priceFormatter(e);
1757
1874
  let { min: t, max: n } = this.viewport.getState().priceRange;
1758
- return l(e, this.marketPricePrecision ?? s(t, n), this.numberLocale);
1875
+ return u(e, this.marketPricePrecision ?? s(t, n), this.numberLocale);
1759
1876
  }
1760
1877
  setDrawingTool(e) {
1761
1878
  this.features.drawings && (e && this.features.drawingTools.length > 0 && !this.features.drawingTools.includes(e) || (e && this.setZoomAreaMode(!1), this.drawingManager.setActiveTool(e)));
@@ -1800,7 +1917,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1800
1917
  }
1801
1918
  autoFib() {
1802
1919
  if (!this.features.drawings) return null;
1803
- let e = this.getDisplayData(), t = this.viewport.getState(), n = pt(e, t.visibleRange.from, t.visibleRange.to);
1920
+ let e = this.getDisplayData(), t = this.viewport.getState(), n = bt(e, t.visibleRange.from, t.visibleRange.to);
1804
1921
  return n ? this.addDrawing({
1805
1922
  type: "fibRetracement",
1806
1923
  anchors: [n[0], n[1]]
@@ -1875,7 +1992,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1875
1992
  recordUndo(e) {
1876
1993
  if (!this.features.drawingUndoRedo || typeof e?.undo != "function" || typeof e.redo != "function") return;
1877
1994
  let t = performance.now(), n = this.undoRedoManager.last();
1878
- if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at < En) {
1995
+ if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at < Mn) {
1879
1996
  this.undoRedoManager.replaceLast({
1880
1997
  ...n,
1881
1998
  custom: {
@@ -1922,7 +2039,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1922
2039
  x: t.x,
1923
2040
  y: t.y
1924
2041
  };
1925
- if ((e === "plot" || e === "priceAxis") && (r.price = P(t.y, n)), (e === "plot" || e === "timeAxis") && n.data.length > 0 && (r.time = N(t.x, n)), e === "pane") {
2042
+ if ((e === "plot" || e === "priceAxis") && (r.price = Rt(t.y, n)), (e === "plot" || e === "timeAxis") && n.data.length > 0 && (r.time = k(t.x, n)), e === "pane") {
1926
2043
  let e = this.getIndicatorPanes().find((e) => t.y >= e.rect.y && t.y <= e.rect.y + e.rect.height);
1927
2044
  e && (r.pane = e.instanceId);
1928
2045
  }
@@ -1948,7 +2065,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1948
2065
  ...this.viewport.getState(),
1949
2066
  data: this.getDisplayData()
1950
2067
  };
1951
- this.setVisibleRange(N(e.x0, t), N(e.x1, t));
2068
+ this.setVisibleRange(k(e.x0, t), k(e.x1, t));
1952
2069
  }
1953
2070
  lockAllDrawings() {
1954
2071
  this.drawingManager.lockAllDrawings();
@@ -1993,7 +2110,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
1993
2110
  for (let e of this.indicatorEngine.getActiveIndicators()) {
1994
2111
  let t = this.indicatorEngine.getOutput(e.instanceId)?.series;
1995
2112
  if (!t) continue;
1996
- let r = Lt(e.id, e.params, e.descriptor.defaultConfig, e.descriptor.shortName), o = e.descriptor.plots ?? Object.keys(t.find((e) => e) ?? {}).map((e) => ({
2113
+ let r = Yt(e.id, e.params, e.descriptor.defaultConfig, e.descriptor.shortName), o = e.descriptor.plots ?? Object.keys(t.find((e) => e) ?? {}).map((e) => ({
1997
2114
  key: e,
1998
2115
  title: e
1999
2116
  }));
@@ -2017,11 +2134,11 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2017
2134
  }
2018
2135
  getExportText(e = "csv", t = {}) {
2019
2136
  let { bars: n, columns: r } = this.getExportData(t);
2020
- return e === "json" ? S.toJSON(n, r) : S.toCSV(n, r);
2137
+ return e === "json" ? C.toJSON(n, r) : C.toCSV(n, r);
2021
2138
  }
2022
2139
  download(e, t, n) {
2023
2140
  let r = this.getExportText(e, n);
2024
- e === "json" ? S.download(r, t ?? "chart-data.json", "application/json") : S.download(r, t ?? "chart-data.csv", "text/csv");
2141
+ e === "json" ? C.download(r, t ?? "chart-data.json", "application/json") : C.download(r, t ?? "chart-data.csv", "text/csv");
2025
2142
  }
2026
2143
  setAutoSave(e, t = 5e3) {
2027
2144
  this.autoSaveScheduler.enable(e, t);
@@ -2071,7 +2188,11 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2071
2188
  this.recordIndicators(e, () => this.updateIndicatorStyleNow(e, t));
2072
2189
  }
2073
2190
  updateIndicatorStyleNow(e, t) {
2074
- this.indicatorEngine.updateIndicatorStyle(e, t), this.engine.requestRender(), this.markStateChanged(), this.eventBus.emit("indicatorChange", {
2191
+ let { plots: n, ...r } = t, i = n === void 0 ? void 0 : ee(n);
2192
+ this.indicatorEngine.updateIndicatorStyle(e, {
2193
+ ...r,
2194
+ ...i ? { plots: i } : {}
2195
+ }), this.engine.requestRender(), this.markStateChanged(), this.eventBus.emit("indicatorChange", {
2075
2196
  instanceId: e,
2076
2197
  change: "style"
2077
2198
  });
@@ -2177,8 +2298,8 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2177
2298
  this.features.trading && this.tradingManager.setConfig(e);
2178
2299
  }
2179
2300
  async connect(e) {
2180
- if (!k(e.adapter, e.timeframe)) throw RangeError(`${e.adapter.name} cannot serve the ${e.timeframe} timeframe`);
2181
- this.snapshotKey = null, this.replayStop(), this.disconnectStream(), this.streamManager = new $e(), this.streamManager.on("snapshot", (t) => {
2301
+ if (!Ot(e.adapter, e.timeframe)) throw RangeError(`${e.adapter.name} cannot serve the ${e.timeframe} timeframe`);
2302
+ this.snapshotKey = null, this.replayStop(), this.disconnectStream(), this.streamManager = new ot(), this.streamManager.on("snapshot", (t) => {
2182
2303
  let n = `${this.currentSymbol}|${this.streamTimeframe}`;
2183
2304
  this.replaySession ? this.replaySession.live.setData(t) : n === this.snapshotKey && this.dataManager.getLength() > 0 ? this.mergeSnapshot(t) : this.setData(t), this.snapshotKey = n, this.useStreamHistory(e.adapter, e.historyPageSize);
2184
2305
  }), this.streamManager.on("barClose", (e) => {
@@ -2186,7 +2307,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2186
2307
  this.replaySession.live.appendBar(e);
2187
2308
  return;
2188
2309
  }
2189
- let t = K(this.fullSeries ?? this.dataManager.getData(), e);
2310
+ let t = q(this.fullSeries ?? this.dataManager.getData(), e);
2190
2311
  if (t === "stale" || !this.takeBar(e, t)) return;
2191
2312
  let n = this.autoScrollOnNewBar && this.viewport.isAtEnd();
2192
2313
  if (!this.placeStreamBar(e)) return;
@@ -2198,7 +2319,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2198
2319
  return;
2199
2320
  }
2200
2321
  this.currentPriceLine.setPrice(e.close);
2201
- let t = K(this.fullSeries ?? this.dataManager.getData(), e);
2322
+ let t = q(this.fullSeries ?? this.dataManager.getData(), e);
2202
2323
  if (t === "stale" || !this.takeBar(e, t) || !this.placeStreamBar(e)) {
2203
2324
  this.scheduleRender();
2204
2325
  return;
@@ -2227,7 +2348,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2227
2348
  }), this.autoScrollOnNewBar = e.autoScroll !== !1, this.setStreamTarget(e.symbol, e.timeframe), this.streamAdapter = e.adapter;
2228
2349
  let t = this.streamManager;
2229
2350
  if (this.resolveStreamSymbol(e.adapter, e.symbol), await t.connect(e), this.streamManager !== t) return;
2230
- let n = y(e.timeframe);
2351
+ let n = ae(e.timeframe);
2231
2352
  this.barCountdown.setTimeframeMs(n), this.countdownInterval && clearInterval(this.countdownInterval), this.countdownInterval = setInterval(() => {
2232
2353
  this.barCountdown.isVisible() && this.engine.requestRender(r.Hover);
2233
2354
  }, 1e3);
@@ -2245,8 +2366,8 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2245
2366
  async switchStream(e, t) {
2246
2367
  if (!this.streamManager) return;
2247
2368
  let n = this.streamAdapter;
2248
- if (n && !k(n, t)) throw RangeError(`${n.name} cannot serve the ${t} timeframe`);
2249
- this.setStreamTarget(e, t), this.historyFromStream && this.history.setLoader(null), this.barCountdown.setTimeframeMs(y(t)), n && this.resolveStreamSymbol(n, e), await this.streamManager.switchTo(e, t);
2369
+ if (n && !Ot(n, t)) throw RangeError(`${n.name} cannot serve the ${t} timeframe`);
2370
+ this.setStreamTarget(e, t), this.historyFromStream && this.history.setLoader(null), this.barCountdown.setTimeframeMs(ae(t)), n && this.resolveStreamSymbol(n, e), await this.streamManager.switchTo(e, t);
2250
2371
  }
2251
2372
  isTimeframeAllowed(e) {
2252
2373
  let t = this.features.timeframes;
@@ -2261,7 +2382,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2261
2382
  }
2262
2383
  connectExecution(e, t = {}) {
2263
2384
  if (!this.features.trading) throw Error("connectExecution requires features.trading to be enabled");
2264
- this.disconnectExecution(), this.executionAdapter = e, this.execTeardown = yn(e, {
2385
+ this.disconnectExecution(), this.executionAdapter = e, this.execTeardown = Tn(e, {
2265
2386
  onIntent: (e, t) => {
2266
2387
  let n = (e) => t(e.payload);
2267
2388
  return this.eventBus.on(e, n), () => this.eventBus.off(e, n);
@@ -2352,18 +2473,18 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2352
2473
  goToTime(e) {
2353
2474
  let t = this.getDisplayData();
2354
2475
  if (t.length === 0 || !Number.isFinite(e)) return -1;
2355
- let n = Math.max(0, Math.min(t.length - 1, Math.floor(j(e, t)))), r = this.viewport.getState(), i = n * (r.barWidth + r.barSpacing) + r.barWidth / 2 - r.chartRect.width / 2;
2476
+ let n = Math.max(0, Math.min(t.length - 1, Math.floor(O(e, t)))), r = this.viewport.getState(), i = n * (r.barWidth + r.barSpacing) + r.barWidth / 2 - r.chartRect.width / 2;
2356
2477
  return this.viewport.scrollBy(i - r.offset), this.updateViewportAndRender(), n;
2357
2478
  }
2358
2479
  setVisibleRangePreset(e) {
2359
2480
  let t = this.getDisplayData();
2360
2481
  if (t.length === 0) return;
2361
- let n = t.length - 1, r = t[n].time > xn ? 1 : 1e3, i = vt(e, t[n].time * r, this.displayTz), a = i === null ? null : i / r;
2482
+ let n = t.length - 1, r = t[n].time > Dn ? 1 : 1e3, i = Tt(e, t[n].time * r, this.displayTz), a = i === null ? null : i / r;
2362
2483
  if (a === null || a < t[0].time) {
2363
2484
  this.fitContent();
2364
2485
  return;
2365
2486
  }
2366
- let o = j(a, t), s = Math.min(n, e === "YTD" ? Math.ceil(o) : Math.floor(o) + 1);
2487
+ let o = O(a, t), s = Math.min(n, e === "YTD" ? Math.ceil(o) : Math.floor(o) + 1);
2367
2488
  this.viewport.zoomToBarRange(s, n + this.viewport.getRightMargin()), this.viewport.scrollToEnd(), this.updateViewportAndRender();
2368
2489
  }
2369
2490
  scrollToEnd() {
@@ -2377,7 +2498,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2377
2498
  setVisibleRange(e, t) {
2378
2499
  let n = this.dataManager.getData();
2379
2500
  if (n.length === 0) return;
2380
- let r = j(Math.min(e, t), n), i = j(Math.max(e, t), n);
2501
+ let r = O(Math.min(e, t), n), i = O(Math.max(e, t), n);
2381
2502
  this.viewport.zoomToBarRange(r, i), this.updateViewportAndRender();
2382
2503
  }
2383
2504
  setPanLimits(e) {
@@ -2411,10 +2532,41 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2411
2532
  this.eventBus.disableTauriBridge();
2412
2533
  }
2413
2534
  setTheme(e) {
2414
- this.themeManager.setTheme(e), this.syncRenderContext(), this.container.style.backgroundColor = this.themeManager.getTheme().background, this.engine.requestRender(), this.eventBus.emit("themeChange", { theme: e }), this.markStateChanged();
2535
+ this.themeManager.setTheme(e), this.syncRenderContext(), this.container.style.backgroundColor = this.themeManager.getTheme().background, this.lastBackground = this.themeManager.getTheme().background, this.engine.requestRender(), this.eventBus.emit("themeChange", { theme: e }), this.markStateChanged();
2415
2536
  }
2416
2537
  getTheme() {
2417
- return this.themeManager.getTheme();
2538
+ return this.themeManager.getBaseTheme();
2539
+ }
2540
+ applyOverrides(e, t = {}) {
2541
+ this.applyStyle(e, t.layer ?? "host", !0);
2542
+ }
2543
+ setOverrides(e, t = {}) {
2544
+ let n = t.layer ?? "host", { overrides: r, rejected: i } = v(e);
2545
+ i.length > 0 && console.warn(`Style overrides left out (unknown key or value): ${i.join(", ")}`);
2546
+ let a = Object.fromEntries(Object.entries(r).filter(([, e]) => e !== null));
2547
+ this.themeManager.setOverrides(a, n) && this.styleChanged(n);
2548
+ }
2549
+ resetOverrides(e, t = {}) {
2550
+ let n = t.layer ?? "host";
2551
+ this.themeManager.resetOverrides(n, e) && this.styleChanged(n);
2552
+ }
2553
+ getOverrides(e = {}) {
2554
+ return this.themeManager.getOverrides(e.layer ?? "host");
2555
+ }
2556
+ getStyle() {
2557
+ return this.themeManager.getTheme().style;
2558
+ }
2559
+ getStyleValue(e) {
2560
+ return this.themeManager.getStyleValue(e);
2561
+ }
2562
+ applyStyle(e, t, n) {
2563
+ let { overrides: r, rejected: i } = v(e);
2564
+ i.length > 0 && console.warn(`Style overrides left out (unknown key or value): ${i.join(", ")}`), this.themeManager.applyOverrides(r, t) && n && this.styleChanged(t);
2565
+ }
2566
+ styleChanged(e) {
2567
+ this.syncRenderContext();
2568
+ let t = this.themeManager.getTheme().background;
2569
+ t !== this.lastBackground && (this.container.style.backgroundColor = t, this.lastBackground = t), this.engine.requestRender(), this.eventBus.emit("styleChange", { layer: e }), e === "user" && this.markStateChanged();
2418
2570
  }
2419
2571
  setWatermark(e, t) {
2420
2572
  this.watermark.setConfig({
@@ -2438,7 +2590,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2438
2590
  e ? this.crosshairHandler.onPointerMove(e) : this.crosshairHandler.onPointerLeave(), this.engine.requestRender(r.Hover);
2439
2591
  }
2440
2592
  setCrosshairTime(e) {
2441
- let t = this.getDisplayData(), n = e === null || t.length === 0 ? null : Math.floor(j(e, t));
2593
+ let t = this.getDisplayData(), n = e === null || t.length === 0 ? null : Math.floor(O(e, t));
2442
2594
  n !== this.crosshairHandler.getSyncedSlot() && (this.crosshairHandler.setSyncedSlot(n), this.engine.requestRender(r.Hover));
2443
2595
  }
2444
2596
  getData() {
@@ -2500,7 +2652,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2500
2652
  this.periodLevels.setPeriod(e), this.engine.requestRender(r.Main);
2501
2653
  }
2502
2654
  setTimezone(e) {
2503
- Cn(e), this.timezoneSetting = e, this.applyTimezone();
2655
+ kn(e), this.timezoneSetting = e, this.applyTimezone();
2504
2656
  }
2505
2657
  getTimezone() {
2506
2658
  return this.timezoneSetting;
@@ -2509,7 +2661,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2509
2661
  return this.displayTz;
2510
2662
  }
2511
2663
  applyTimezone() {
2512
- let e = this.symbolInfo?.timezone, t = this.timezoneSetting === "exchange" ? e && f(e) ? e : "UTC" : this.timezoneSetting;
2664
+ let e = this.symbolInfo?.timezone, t = this.timezoneSetting === "exchange" ? e && p(e) ? e : "UTC" : this.timezoneSetting;
2513
2665
  this.displayTz = t, this.timeAxis.setTimezoneOffset(t), this.crosshairHandler.setTimezoneOffset(t), this.crosshairTooltip.setTimezoneOffset(t), this.pinnedTooltip.setTimezone(t), this.sessionBreaks.setTimezone(t), this.engine.requestRender();
2514
2666
  }
2515
2667
  setSymbolInfo(e) {
@@ -2518,13 +2670,13 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2518
2670
  sessions: e.sessions?.map((e) => ({ ...e }))
2519
2671
  } : null, this.marketConfig?.pricePrecision === void 0 && this.applyPricePrecision(this.symbolInfo?.pricePrecision ?? null);
2520
2672
  let t = (this.symbolInfo?.sessions ?? []).flatMap((e) => {
2521
- let t = v(e.start), n = v(e.end);
2673
+ let t = x(e.start), n = x(e.end);
2522
2674
  return t === null || n === null ? [] : [{
2523
2675
  startMinute: t,
2524
2676
  endMinute: n
2525
2677
  }];
2526
2678
  }), n = this.symbolInfo?.timezone;
2527
- this.sessionShading.replaceConfig(t.length > 0 && n && f(n) ? {
2679
+ this.sessionShading.replaceConfig(t.length > 0 && n && p(n) ? {
2528
2680
  timeZone: n,
2529
2681
  windows: t,
2530
2682
  startMinute: t[0].startMinute,
@@ -2563,7 +2715,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2563
2715
  return this.sessionShading.isVisible();
2564
2716
  }
2565
2717
  setSessionShadingConfig(e) {
2566
- this.hostSessionHours = _t(this.hostSessionHours, e), this.sessionShading.replaceConfig(this.hostSessionHours), this.engine.requestRender(r.Background);
2718
+ this.hostSessionHours = wt(this.hostSessionHours, e), this.sessionShading.replaceConfig(this.hostSessionHours), this.engine.requestRender(r.Background);
2567
2719
  }
2568
2720
  setTooltipVisible(e) {
2569
2721
  e || this.crosshairTooltip.hide();
@@ -2582,11 +2734,11 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2582
2734
  return this.waitForGpu(null), e === "canvas" ? (this.applyRenderer(null), "canvas") : this.engine.getGpu() ? "webgl" : this.takeGpu(e, t, !0);
2583
2735
  }
2584
2736
  async takeGpu(e, t, n) {
2585
- let { gpu: r, reason: i } = await gt(e);
2586
- return t !== this.rendererToken || this.disposed ? (r?.destroy(), this.getRenderer()) : i === "limit" ? mt() > 0 ? this.takeGpu(e, t, n) : (this.waitForGpu(() => void this.takeGpu(e, t, !1)), n && this.applyRenderer(null, "limit"), this.getRenderer()) : ((r || n) && this.applyRenderer(r, i), this.getRenderer());
2737
+ let { gpu: r, reason: i } = await Ct(e);
2738
+ return t !== this.rendererToken || this.disposed ? (r?.destroy(), this.getRenderer()) : i === "limit" ? xt() > 0 ? this.takeGpu(e, t, n) : (this.waitForGpu(() => void this.takeGpu(e, t, !1)), n && this.applyRenderer(null, "limit"), this.getRenderer()) : ((r || n) && this.applyRenderer(r, i), this.getRenderer());
2587
2739
  }
2588
2740
  waitForGpu(e) {
2589
- this.stopWaitingForGpu?.(), this.stopWaitingForGpu = e ? Et(e) : null;
2741
+ this.stopWaitingForGpu?.(), this.stopWaitingForGpu = e ? Ft(e) : null;
2590
2742
  }
2591
2743
  getRenderer() {
2592
2744
  return this.engine.getGpu() ? "webgl" : "canvas";
@@ -2604,23 +2756,23 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2604
2756
  this.engine.getGpu() && this.engine.renderNow();
2605
2757
  }
2606
2758
  screenshot(e) {
2607
- this.features.screenshot && (this.freshFrame(), D.download(this.container, e, this.themeManager.getTheme().background));
2759
+ this.features.screenshot && (this.freshFrame(), T.download(this.container, e, this.themeManager.getTheme().background));
2608
2760
  }
2609
2761
  async copyScreenshot() {
2610
2762
  if (!this.features.screenshot) return !1;
2611
2763
  try {
2612
2764
  this.freshFrame();
2613
- let e = await D.toBlob(this.container, this.themeManager.getTheme().background), t = globalThis.ClipboardItem;
2765
+ let e = await T.toBlob(this.container, this.themeManager.getTheme().background), t = globalThis.ClipboardItem;
2614
2766
  return !e || !navigator.clipboard?.write || !t ? !1 : (await navigator.clipboard.write([new t({ "image/png": e })]), !0);
2615
2767
  } catch {
2616
2768
  return !1;
2617
2769
  }
2618
2770
  }
2619
2771
  screenshotDataURL() {
2620
- return this.features.screenshot ? (this.freshFrame(), D.toDataURL(this.container, this.themeManager.getTheme().background)) : null;
2772
+ return this.features.screenshot ? (this.freshFrame(), T.toDataURL(this.container, this.themeManager.getTheme().background)) : null;
2621
2773
  }
2622
2774
  async screenshotBlob() {
2623
- return this.features.screenshot ? (this.freshFrame(), D.toBlob(this.container, this.themeManager.getTheme().background)) : null;
2775
+ return this.features.screenshot ? (this.freshFrame(), T.toBlob(this.container, this.themeManager.getTheme().background)) : null;
2624
2776
  }
2625
2777
  addAlert(e, t = "crossing", n, r = "price", i, a = {}) {
2626
2778
  if (!this.features.alerts) return null;
@@ -2744,45 +2896,58 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2744
2896
  }
2745
2897
  replayStart(e) {
2746
2898
  if (!this.features.replay) return;
2747
- if (this.history.reset(), !this.replaySession) {
2899
+ this.history.reset();
2900
+ let t = this.replaySession ? this.replayOffset : 0;
2901
+ if (!this.replaySession) {
2748
2902
  if (this.dataManager.getLength() === 0) return;
2749
- let e = new B();
2903
+ let e = new F();
2750
2904
  e.setData(this.fullSeries ?? this.dataManager.getData()), this.replaySession = {
2751
2905
  live: e,
2752
2906
  price: null,
2753
2907
  fedTime: null
2754
2908
  };
2755
2909
  }
2756
- let t = this.shownBars(this.replaySession.live.getData()), { steps: n, ...r } = e ?? {}, i = n ? Rn(n, t) : null;
2757
- this.replayStepsSeries = i, this.replayCoarse = t, this.options.autoScale = !0, this.replayRestarting = !0;
2910
+ let { steps: n, startTime: r, hideHistory: i, revealMarks: a, ...o } = e ?? {}, s = this.shownBars(this.replaySession.live.getData()), c = t > 0 && r === void 0 && i !== !1, l = o.startIndex;
2911
+ r !== void 0 && l === void 0 ? l = Vn(s, r) : c && l !== void 0 && (l += t);
2912
+ let u = c ? t : i && l !== void 0 && l > 0 ? Math.min(Math.floor(l), s.length - 1) : 0, d = u > 0 ? s.slice(u) : s;
2913
+ l !== void 0 && (o.startIndex = l - u), this.replayOffset = u, this.replayRevealMarks = a !== !1;
2914
+ let f = n ? Gn(n, d) : null;
2915
+ this.replayStepsSeries = f, this.replayCoarse = d, this.options.autoScale = !0, this.replayRestarting = !0;
2758
2916
  try {
2759
- this.replayManager.load(i ?? t);
2917
+ this.replayManager.load(f ?? d);
2760
2918
  } finally {
2761
2919
  this.replayRestarting = !1;
2762
2920
  }
2763
- i && r.startIndex !== void 0 && (r.startIndex = Vn(i, t, r.startIndex)), this.replayBarUnsub?.();
2764
- let a = -1, o = -1, s = null, c = i ?? t;
2921
+ f && o.startIndex !== void 0 && (o.startIndex = Jn(f, d, o.startIndex)), this.replayBarUnsub?.();
2922
+ let p = -1, m = -1, h = null, g = f ?? d;
2765
2923
  this.replayBarUnsub = this.replayManager.on("bar", ({ index: e }) => {
2766
- let n = e, r = t[e];
2767
- if (i) {
2768
- let c = i[e];
2769
- n = Bn(t, c.time), s = s !== null && o === e - 1 && n === a - 1 && s ? Un(s, c) : Hn(t[n], i, e), r = s;
2924
+ let t = e, n = d[e];
2925
+ if (f) {
2926
+ let r = f[e];
2927
+ t = qn(d, r.time), h = h !== null && m === e - 1 && t === p - 1 && h ? Xn(h, r) : Yn(d[t], f, e), n = h;
2770
2928
  }
2771
- o = e;
2772
- let l = n + 1, u = a > 0 && l >= a && this.dataManager.getLength() === a, d = !(u && !this.replaySeeking) || this.autoScrollOnNewBar && this.viewport.isAtEnd();
2773
- if (u) {
2774
- i && l > a && this.dataManager.updateLastBar(t[a - 1]);
2775
- for (let e = a; e < l - 1; e++) this.dataManager.appendBar(t[e]);
2776
- l > a ? this.dataManager.appendBar(r) : this.dataManager.updateLastBar(r), this.recalcIndicatorsFrom(this.dataManager.getData(), Math.max(0, a - 1));
2777
- } else this.dataManager.setData([...t.slice(0, n), r]), this.recalcIndicators(this.dataManager.getData());
2778
- a = l, this.currentPriceLine.setPrice(r.close, n > 0 ? t[n - 1].close : void 0), this.crosshairHandler.setData(this.dataManager.getData()), this.displayDataCache = null, this.updateViewportAndRender(d), this.feedReplaySteps(c, e);
2779
- let f = c[e + 1]?.time ?? c[e].time + (e > 0 ? c[e].time - c[e - 1].time : 0);
2780
- this.eventBus.emit("replayStep", {
2781
- barIndex: n,
2782
- time: t[n].time,
2783
- until: f
2929
+ m = e;
2930
+ let r = t + 1, i = p > 0 && r >= p && this.dataManager.getLength() === p, a = !(i && !this.replaySeeking) || this.autoScrollOnNewBar && this.viewport.isAtEnd();
2931
+ if (i) {
2932
+ f && r > p && this.dataManager.updateLastBar(d[p - 1]);
2933
+ for (let e = p; e < r - 1; e++) this.dataManager.appendBar(d[e]);
2934
+ r > p ? this.dataManager.appendBar(n) : this.dataManager.updateLastBar(n), this.recalcIndicatorsFrom(this.dataManager.getData(), Math.max(0, p - 1));
2935
+ } else this.dataManager.setData([...d.slice(0, t), n]), this.recalcIndicators(this.dataManager.getData());
2936
+ p = r, this.currentPriceLine.setPrice(n.close, t > 0 ? d[t - 1].close : void 0), this.crosshairHandler.setData(this.dataManager.getData());
2937
+ let o = g[e + 1]?.time ?? g[e].time + (e > 0 ? g[e].time - g[e - 1].time : 1);
2938
+ this.replayRevealMarks && this.revealReplayMarks(o), this.displayDataCache = null, this.updateViewportAndRender(a), this.feedReplaySteps(g, e), this.eventBus.emit("replayStep", {
2939
+ barIndex: t,
2940
+ time: d[t].time,
2941
+ until: o,
2942
+ total: d.length
2784
2943
  });
2785
- }), this.replayManager.play(r);
2944
+ });
2945
+ let _ = g[Math.max(0, Math.min(Math.floor(Number(o.startIndex ?? 0)) || 0, g.length - 1))];
2946
+ this.revealReplayMarks(this.replayRevealMarks ? _?.time ?? null : null), !o.paused && o.startIndex !== void 0 && o.startIndex >= 1 && this.replaySeek(o.startIndex - 1), this.replayManager.play(o);
2947
+ }
2948
+ revealReplayMarks(e) {
2949
+ let t = e !== null && this.replayOffset > 0 ? this.replayCoarse?.[0]?.time ?? -Infinity : -Infinity;
2950
+ this.signalMarkerManager.setRevealUntil(e, t), this.tradeZoneManager.setRevealUntil(e, t);
2786
2951
  }
2787
2952
  replaySeekToTime(e) {
2788
2953
  if (!this.replaySession || !this.replayCoarse) return;
@@ -2811,20 +2976,20 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2811
2976
  return;
2812
2977
  }
2813
2978
  if (i.time <= n.fedTime) return;
2814
- let a = e.slice(Fn(e, n.fedTime), t + 1);
2979
+ let a = e.slice(Hn(e, n.fedTime), t + 1);
2815
2980
  n.fedTime = i.time;
2816
- let o = Math.ceil(a.length / Pn);
2817
- for (let e = 0; e < a.length; e += o) for (let [t, n] of In(a.slice(e, e + o))) r.setMarkPrice(t, n);
2981
+ let o = Math.ceil(a.length / Bn);
2982
+ for (let e = 0; e < a.length; e += o) for (let [t, n] of Un(a.slice(e, e + o))) r.setMarkPrice(t, n);
2818
2983
  this.tradingManager.setCurrentPrice(i.close);
2819
2984
  }
2820
2985
  getReplayBarIndex() {
2821
2986
  if (!this.replaySession) return -1;
2822
2987
  let { current: e } = this.replayManager.getProgress(), t = this.replayStepsSeries;
2823
- return t && this.replayCoarse ? Bn(this.replayCoarse, t[e]?.time ?? -Infinity) : e;
2988
+ return t && this.replayCoarse ? qn(this.replayCoarse, t[e]?.time ?? -Infinity) : e;
2824
2989
  }
2825
2990
  replaySeekToBar(e) {
2826
2991
  let t = this.replayStepsSeries;
2827
- this.replaySeek(t && this.replayCoarse ? Vn(t, this.replayCoarse, e) : e);
2992
+ this.replaySeek(t && this.replayCoarse ? Jn(t, this.replayCoarse, e) : e);
2828
2993
  }
2829
2994
  replayPause() {
2830
2995
  this.replayManager.pause();
@@ -2849,7 +3014,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2849
3014
  };
2850
3015
  }
2851
3016
  endReplaySession() {
2852
- this.replaySession && (this.returnMarkToLive(), this.replaySession = null, this.replayStepsSeries = null, this.replayCoarse = null, this.replayBarUnsub?.(), this.replayBarUnsub = null, this.replayManager.stop());
3017
+ this.replaySession && (this.returnMarkToLive(), this.replaySession = null, this.replayStepsSeries = null, this.replayCoarse = null, this.replayBarUnsub?.(), this.replayBarUnsub = null, this.replayManager.stop(), this.replayOffset = 0, this.revealReplayMarks(null));
2853
3018
  }
2854
3019
  replaySeek(e) {
2855
3020
  this.replaySeeking = !0;
@@ -2869,11 +3034,12 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2869
3034
  return this.replayManager.getProgress();
2870
3035
  }
2871
3036
  captureSnapshot() {
2872
- return x.capture({
3037
+ return S.capture({
2873
3038
  getDrawings: () => this.getDrawings(),
2874
- getTheme: () => this.getTheme(),
3039
+ getTheme: () => this.themeManager.getBaseTheme(),
2875
3040
  getAlerts: () => this.getAlerts(),
2876
- getIndicators: () => this.getIndicatorSetup()
3041
+ getIndicators: () => this.getIndicatorSetup(),
3042
+ getOverrides: () => this.themeManager.getUserOverrides()
2877
3043
  }, {
2878
3044
  chartType: this.options.chartType,
2879
3045
  chartTypeOptions: this.getChartTypeOptions(),
@@ -2881,14 +3047,14 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2881
3047
  });
2882
3048
  }
2883
3049
  restoreIndicators(e, t) {
2884
- let n = An(e), r = /* @__PURE__ */ new Map();
3050
+ let n = In(e), r = /* @__PURE__ */ new Map();
2885
3051
  this.unrestoredIndicators = [];
2886
3052
  let i = new Set(this.indicatorEngine.getAvailableIndicators().map((e) => e.id)), a = [], o = /* @__PURE__ */ new Set();
2887
3053
  if (t) {
2888
3054
  let e = new Map(n.map((e) => [e.instanceId, e])), t = this.getIndicatorSetup();
2889
3055
  for (let n of t) {
2890
3056
  let t = e.get(n.instanceId);
2891
- t && jn(n, t) && o.add(n.instanceId);
3057
+ t && Ln(n, t) && o.add(n.instanceId);
2892
3058
  }
2893
3059
  for (let e of t) o.has(e.instanceId) || this.removeIndicator(e.instanceId);
2894
3060
  for (let e of [...o]) this.indicatorEngine.getIndicatorConfig(e) || o.delete(e);
@@ -2896,8 +3062,8 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2896
3062
  let s = (e) => {
2897
3063
  let t = { ...e };
2898
3064
  for (let [e, n] of Object.entries(t)) {
2899
- let i = h(n), a = i && r.get(i.instanceId);
2900
- a && (t[e] = d(a, i.key));
3065
+ let i = g(n), a = i && r.get(i.instanceId);
3066
+ a && (t[e] = f(a, i.key));
2901
3067
  }
2902
3068
  return t;
2903
3069
  };
@@ -2936,15 +3102,19 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2936
3102
  return this.restorePanes(a), this.updateViewportAndRender(), r;
2937
3103
  }
2938
3104
  restoreLooks(e, t) {
2939
- let n = this.indicatorEngine.getIndicatorStyle(e);
3105
+ let { plots: n, ...r } = this.indicatorEngine.getIndicatorStyle(e) ?? {
3106
+ colors: [],
3107
+ lineWidths: [],
3108
+ opacity: 1
3109
+ }, { plots: i, ...a } = t.style ?? {};
2940
3110
  t.style && JSON.stringify({
2941
- ...n,
2942
- ...t.style
2943
- }) !== JSON.stringify(n) && this.updateIndicatorStyle(e, t.style);
2944
- let r = this.indicatorEngine.getIndicatorConfig(e);
2945
- (t.visible ?? !0) !== (r?.visible ?? !0) && this.setIndicatorVisible(e, t.visible ?? !0);
2946
- let i = t.levels ?? null;
2947
- JSON.stringify(i) !== JSON.stringify(r?.levels ?? null) && this.setIndicatorLevels(e, i);
3111
+ ...r,
3112
+ ...a
3113
+ }) !== JSON.stringify(r) && this.updateIndicatorStyle(e, a), JSON.stringify(i ?? {}) !== JSON.stringify(n ?? {}) && (this.indicatorEngine.setPlotStyles(e, i ?? null), this.engine.requestRender());
3114
+ let o = this.indicatorEngine.getIndicatorConfig(e);
3115
+ (t.visible ?? !0) !== (o?.visible ?? !0) && this.setIndicatorVisible(e, t.visible ?? !0);
3116
+ let s = t.levels ?? null;
3117
+ JSON.stringify(s) !== JSON.stringify(o?.levels ?? null) && this.setIndicatorLevels(e, s), this.setPaneStyleNow(e, t.paneStyle ? b(t.paneStyle) : null);
2948
3118
  }
2949
3119
  restorePanes(e) {
2950
3120
  for (let [t, n] of e) t.paneSize !== void 0 && this.layoutManager.setPanelSize(n, t.paneSize), (t.paneSize !== void 0 || t.paneCollapsed) && this.layoutManager.setPanelCollapsed(n, !!t.paneCollapsed), t.paneSize !== void 0 && this.layoutManager.setPanelScale(n, {
@@ -2971,6 +3141,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
2971
3141
  levels: i?.levels?.slice(),
2972
3142
  pane: n.pane,
2973
3143
  scale: i?.scale,
3144
+ ...r && this.paneStyles.has(n.instanceId) ? { paneStyle: { ...this.paneStyles.get(n.instanceId) } } : {},
2974
3145
  ...r ? {
2975
3146
  paneSize: r.size,
2976
3147
  paneOrder: e.indexOf(r),
@@ -3024,7 +3195,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
3024
3195
  if (this.indicatorHistoryDepth > 0 || !this.features.drawingUndoRedo) return t();
3025
3196
  let n = this.getIndicatorSetup(), r = this.withoutIndicatorHistory(t), i = this.getIndicatorSetup();
3026
3197
  if (JSON.stringify(n) === JSON.stringify(i)) return r;
3027
- let a = performance.now(), o = this.undoRedoManager.last(), s = e !== void 0 && o?.type === "indicators" && o.indicators?.subject === e && a - (o.indicators.at ?? 0) < En && JSON.stringify(o.indicators.after) === JSON.stringify(n), c = {
3198
+ let a = performance.now(), o = this.undoRedoManager.last(), s = e !== void 0 && o?.type === "indicators" && o.indicators?.subject === e && a - (o.indicators.at ?? 0) < Mn && JSON.stringify(o.indicators.after) === JSON.stringify(n), c = {
3028
3199
  type: "indicators",
3029
3200
  before: null,
3030
3201
  after: null
@@ -3052,13 +3223,13 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
3052
3223
  }
3053
3224
  saveState(e) {
3054
3225
  if (!this.features.saveLoad) return null;
3055
- let t = this.captureSnapshot(), n = x.serialize(t);
3056
- return e && x.saveToStorage(e, t), n;
3226
+ let t = this.captureSnapshot(), n = S.serialize(t);
3227
+ return e && S.saveToStorage(e, t), n;
3057
3228
  }
3058
3229
  loadState(e) {
3059
3230
  if (!this.features.saveLoad) return;
3060
- let t = x.deserialize(e);
3061
- this.chartTypeOptions = t.chartTypeOptions ?? {}, this.displayDataCache = null, t.chartType && this.setChartType(t.chartType), t.drawings && this.setDrawings(t.drawings), t.theme && this.setTheme(t.theme);
3231
+ let t = S.deserialize(e);
3232
+ this.chartTypeOptions = t.chartTypeOptions ?? {}, this.displayDataCache = null, t.chartType && this.setChartType(t.chartType), t.drawings && this.setDrawings(t.drawings), (t.theme === "dark" || t.theme === "light") && this.setTheme(t.theme), t.version >= 3 && this.themeManager.setUserOverrides(t.overrides ?? {}) && this.styleChanged("user");
3062
3233
  let n = t.version >= 2 && this.features.indicators ? this.withoutIndicatorHistory(() => this.restoreIndicators(t.indicators, !1)) : /* @__PURE__ */ new Map();
3063
3234
  if (this.undoRedoManager.clear(), t.alerts && this.features.alerts) {
3064
3235
  this.alertManager.clearAlerts();
@@ -3068,7 +3239,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
3068
3239
  let t = e.indexOf(":"), r = t > 0 ? n.get(e.slice(0, t)) : void 0;
3069
3240
  return r ? r + e.slice(t) : e;
3070
3241
  }, r = t(e.channel), i = {
3071
- ...yt(e),
3242
+ ...Et(e),
3072
3243
  ...e.target ? { target: t(e.target) } : {}
3073
3244
  };
3074
3245
  if (!e.expired) {
@@ -3088,19 +3259,19 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
3088
3259
  }
3089
3260
  loadStateFromStorage(e) {
3090
3261
  if (!this.features.saveLoad) return !1;
3091
- let t = x.loadFromStorage(e);
3092
- return t ? (this.loadState(x.serialize(t)), !0) : !1;
3262
+ let t = S.loadFromStorage(e);
3263
+ return t ? (this.loadState(S.serialize(t)), !0) : !1;
3093
3264
  }
3094
3265
  downloadState(e) {
3095
- this.features.saveLoad && x.downloadFile(this.captureSnapshot(), e);
3266
+ this.features.saveLoad && S.downloadFile(this.captureSnapshot(), e);
3096
3267
  }
3097
3268
  async loadStateFromFile() {
3098
3269
  if (!this.features.saveLoad) return;
3099
- let e = await x.loadFromFile();
3100
- this.loadState(x.serialize(e));
3270
+ let e = await S.loadFromFile();
3271
+ this.loadState(S.serialize(e));
3101
3272
  }
3102
3273
  setLocale(e) {
3103
- ee(e), this.engine.requestRender();
3274
+ ne(e), this.engine.requestRender();
3104
3275
  }
3105
3276
  setNumberLocale(e) {
3106
3277
  this.numberLocale = e, this.priceAxis.setLocale(e), this.leftPriceAxis.setLocale(e), this.crosshairHandler.setLocale(e), this.chartLegend.setLocale(e), this.crosshairTooltip.setLocale(e), this.sessionBreaks.setLocale(e), this.currentPriceLine.setLocale(e), this.updateViewportAndRender();
@@ -3111,26 +3282,26 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
3111
3282
  setMarket(e) {
3112
3283
  if (this.marketConfig = e, e.colorScheme) {
3113
3284
  let t = {
3114
- ...this.themeManager.getTheme(),
3285
+ ...this.themeManager.getBaseTheme(),
3115
3286
  candleUp: e.colorScheme.up,
3116
3287
  candleDown: e.colorScheme.down,
3117
3288
  candleUpWick: e.colorScheme.up,
3118
3289
  candleDownWick: e.colorScheme.down,
3119
- volumeUp: b(e.colorScheme.up),
3120
- volumeDown: b(e.colorScheme.down)
3290
+ volumeUp: oe(e.colorScheme.up),
3291
+ volumeDown: oe(e.colorScheme.down)
3121
3292
  };
3122
3293
  this.themeManager.setTheme(t);
3123
3294
  }
3124
3295
  e.pricePrecision !== void 0 && this.applyPricePrecision(e.pricePrecision), this.updateViewportAndRender();
3125
3296
  }
3126
3297
  applyPricePrecision(e) {
3127
- this.marketPricePrecision = e, this.tradingManager.setConfig({ pricePrecision: e ?? void 0 }), this.alertManager.setPricePrecision(e ?? wn), this.streamManager?.priceLine.setPricePrecision(e), this.currentPriceLine.setPricePrecision(e), this.crosshairHandler.setPricePrecision(e), this.chartLegend.setPricePrecision(e), this.crosshairTooltip.setPricePrecision(e);
3298
+ this.marketPricePrecision = e, this.tradingManager.setConfig({ pricePrecision: e ?? void 0 }), this.alertManager.setPricePrecision(e ?? An), this.streamManager?.priceLine.setPricePrecision(e), this.currentPriceLine.setPricePrecision(e), this.crosshairHandler.setPricePrecision(e), this.chartLegend.setPricePrecision(e), this.crosshairTooltip.setPricePrecision(e);
3128
3299
  }
3129
3300
  getMarket() {
3130
3301
  return this.marketConfig;
3131
3302
  }
3132
3303
  setPriceLimits(e) {
3133
- this.marketConfig && (c(e, this.marketConfig) && (this.marketConfig.priceLimits = {
3304
+ this.marketConfig && (l(e, this.marketConfig) && (this.marketConfig.priceLimits = {
3134
3305
  ...this.marketConfig.priceLimits,
3135
3306
  referencePrice: e
3136
3307
  }), this.engine.requestRender());
@@ -3154,15 +3325,15 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
3154
3325
  this.disposed = !0, this.waitForGpu(null), this.countdownInterval && clearInterval(this.countdownInterval), this.history.setLoader(null), this.disableAutoSave(), this.disconnectStream(), this.disconnectExecution(), this.onWindowKeyDown &&= (window.removeEventListener("keydown", this.onWindowKeyDown), null), this.keyboardHandler = null, this.a11y?.destroy(), this.a11y = null, this.interactionManager.detach(), this.tradingManager.destroy(), this.animator.dispose(), this.crosshairTooltip.destroy(), this.pinnedTooltip.destroy(), this.replayRestarting = !0, this.replayManager.dispose(), this.alertManager.dispose(), this.undoRedoManager.clear(), this.engine.destroy(), this.eventBus.destroy(), this.container.innerHTML = "";
3155
3326
  }
3156
3327
  createChartRenderer(e) {
3157
- let t = Wt(e, (e) => this.pluginManager.getChartType(e));
3158
- return t instanceof C && t.setPriceText((e) => this.formatPrice(e)), t;
3328
+ let t = tn(e, (e) => this.pluginManager.getChartType(e));
3329
+ return t instanceof w && t.setPriceText((e) => this.formatPrice(e)), t;
3159
3330
  }
3160
3331
  getDisplayData() {
3161
3332
  if (this.displayDataCache) return this.displayDataCache;
3162
3333
  let e = this.dataManager.getData();
3163
3334
  if (e.length === 0) return e;
3164
- let t = Gt(this.options.chartType, e, (e) => this.pluginManager.getChartType(e), this.chartTypeOptions);
3165
- return this.chartRenderer instanceof T && !this.pluginManager.getChartType(this.options.chartType) && this.chartRenderer.setBoxSize(Ht(e, this.chartTypeOptions)), this.displayDataCache = t, t;
3335
+ let t = nn(this.options.chartType, e, (e) => this.pluginManager.getChartType(e), this.chartTypeOptions);
3336
+ return this.chartRenderer instanceof qe && !this.pluginManager.getChartType(this.options.chartType) && this.chartRenderer.setBoxSize(en(e, this.chartTypeOptions)), this.displayDataCache = t, t;
3166
3337
  }
3167
3338
  recalcIndicatorsFrom(e, t) {
3168
3339
  this.indicatorEngine.recalculateFrom(e, t), this.announceIndicatorUpdate(t);
@@ -3194,7 +3365,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
3194
3365
  this.viewport.setScaleBaseline(t[e]?.close);
3195
3366
  }
3196
3367
  if (n) {
3197
- let e = Nn(this.indicatorEngine.getOverlayPriceRange(r.visibleRange.from, Math.min(r.visibleRange.to, t.length - 1)), this.features.compareSymbols ? this.compareRenderer.getPriceRange(t, r) : null);
3368
+ let e = zn(this.indicatorEngine.getOverlayPriceRange(r.visibleRange.from, Math.min(r.visibleRange.to, t.length - 1)), this.features.compareSymbols ? this.compareRenderer.getPriceRange(t, r) : null);
3198
3369
  if (e) {
3199
3370
  let t = r.priceRange, n = Math.min(t.min, e.min), i = Math.max(t.max, e.max);
3200
3371
  if (n < t.min || i > t.max) {
@@ -3218,7 +3389,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
3218
3389
  fitLeftAxisWidth() {
3219
3390
  let e = this.leftViewport;
3220
3391
  if (!e) return !1;
3221
- let t = this.themeManager.getTheme(), n = sn({
3392
+ let t = this.themeManager.getTheme(), n = mn({
3222
3393
  min: e.priceRange.min,
3223
3394
  max: e.priceRange.max,
3224
3395
  lastPrice: null,
@@ -3227,12 +3398,12 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
3227
3398
  fontFamily: t.font.family,
3228
3399
  fontSizeSmall: t.font.sizeSmall,
3229
3400
  measure: (e, t) => this.measureText(e, t)
3230
- }), r = cn(this.leftAxisWidth, n);
3401
+ }), r = hn(this.leftAxisWidth, n);
3231
3402
  return r === this.leftAxisWidth ? !1 : (this.leftAxisWidth = r, this.layoutManager.setLeftAxisWidth(r), this.resolvedLayoutCache = null, this.panelInfoCache = null, this.viewport.setChartRect(this.getResolvedLayout().mainChartRect), !0);
3232
3403
  }
3233
3404
  fitPriceAxisWidth() {
3234
3405
  if (!this.features.priceAxis) return !1;
3235
- let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n = sn({
3406
+ let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n = mn({
3236
3407
  min: e.min,
3237
3408
  max: e.max,
3238
3409
  lastPrice: this.currentPriceLine.getPrice(),
@@ -3242,7 +3413,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
3242
3413
  fontFamily: t.font.family,
3243
3414
  fontSizeSmall: t.font.sizeSmall,
3244
3415
  measure: (e, t) => this.measureText(e, t)
3245
- }), r = cn(this.priceAxisWidth, n);
3416
+ }), r = hn(this.priceAxisWidth, n);
3246
3417
  return r === this.priceAxisWidth ? !1 : (this.priceAxisWidth = r, this.layoutManager.setPriceAxisWidth(r), this.viewport.setPriceAxisWidth(r), this.resolvedLayoutCache = null, this.panelInfoCache = null, this.viewport.setChartRect(this.getResolvedLayout().mainChartRect), !0);
3247
3418
  }
3248
3419
  measureText(e, t) {
@@ -3286,15 +3457,16 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
3286
3457
  buildPanelRenderInfos() {
3287
3458
  if (this.panelInfoCache) return this.panelInfoCache;
3288
3459
  let e = this.getResolvedLayout(), t = this.viewport.getState(), { from: n, to: r } = t.visibleRange, i = e.panels.map((e) => {
3289
- let i = e.config.logScale ? this.indicatorEngine.getPaneValueRange(e.config.id, n, r, !0) : null, a = i ?? this.indicatorEngine.getPaneValueRange(e.config.id, n, r) ?? { ...bn }, o = {
3460
+ let i = e.config.logScale ? this.indicatorEngine.getPaneValueRange(e.config.id, n, r, !0) : null, a = i ?? this.indicatorEngine.getPaneValueRange(e.config.id, n, r) ?? { ...En }, o = {
3290
3461
  x: e.rect.x,
3291
3462
  y: e.rect.y + 20,
3292
3463
  width: e.rect.width,
3293
3464
  height: Math.max(0, e.rect.height - 20)
3294
- };
3465
+ }, s = this.paneStyles.get(e.config.id);
3295
3466
  return {
3296
3467
  instanceId: e.config.id,
3297
3468
  members: this.indicatorEngine.getPaneMembers(e.config.id),
3469
+ ...s ? { style: s } : {},
3298
3470
  rect: e.rect,
3299
3471
  viewport: {
3300
3472
  ...t,
@@ -3367,7 +3539,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
3367
3539
  });
3368
3540
  }
3369
3541
  drawOverlayPlugins(e, t) {
3370
- let n = dn(this.pluginManager.getOverlays(), t);
3542
+ let n = vn(this.pluginManager.getOverlays(), t);
3371
3543
  if (n.length === 0) return;
3372
3544
  let r = {
3373
3545
  viewport: this.viewport.getState(),
@@ -3378,7 +3550,7 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
3378
3550
  }
3379
3551
  buildPriceLimits() {
3380
3552
  if (!this.marketConfig?.priceLimits?.enabled || !this.marketConfig.priceLimits.referencePrice) return null;
3381
- let e = c(this.marketConfig.priceLimits.referencePrice, this.marketConfig);
3553
+ let e = l(this.marketConfig.priceLimits.referencePrice, this.marketConfig);
3382
3554
  return e ? {
3383
3555
  ...e,
3384
3556
  colors: this.marketConfig.colorScheme ? {
@@ -3389,11 +3561,11 @@ var wn = 2, Tn = .08, En = 800, Dn = 20, On = 8, kn = class {
3389
3561
  } : null;
3390
3562
  }
3391
3563
  };
3392
- function An(e) {
3564
+ function In(e) {
3393
3565
  let t = new Map(e.map((e) => [e.instanceId, e])), n = [], r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = (e) => {
3394
3566
  if (r.has(e.instanceId) || i.has(e.instanceId)) return;
3395
3567
  i.add(e.instanceId);
3396
- let o = [e.pane, ...Object.values(e.params).map((e) => h(e)?.instanceId)];
3568
+ let o = [e.pane, ...Object.values(e.params).map((e) => g(e)?.instanceId)];
3397
3569
  for (let e of o) {
3398
3570
  let n = e ? t.get(e) : void 0;
3399
3571
  n && a(n);
@@ -3403,26 +3575,26 @@ function An(e) {
3403
3575
  for (let t of e) a(t);
3404
3576
  return n;
3405
3577
  }
3406
- function jn(e, t) {
3578
+ function Ln(e, t) {
3407
3579
  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);
3408
3580
  }
3409
- function Mn(e) {
3581
+ function Rn(e) {
3410
3582
  let t = e.tagRadius;
3411
3583
  return typeof t == "number" && Number.isFinite(t) && t >= 0 ? { tagRadius: Math.min(t, 999) } : {};
3412
3584
  }
3413
- var W = new Set([
3585
+ var G = new Set([
3414
3586
  "compareSymbol",
3415
3587
  "spread",
3416
3588
  "correlation",
3417
3589
  "correlationlog"
3418
3590
  ]);
3419
- function Nn(e, t) {
3591
+ function zn(e, t) {
3420
3592
  return e ? t ? {
3421
3593
  min: Math.min(e.min, t.min),
3422
3594
  max: Math.max(e.max, t.max)
3423
3595
  } : e : t;
3424
3596
  }
3425
- function G(e) {
3597
+ function K(e) {
3426
3598
  return {
3427
3599
  id: e.id,
3428
3600
  price: e.price,
@@ -3437,8 +3609,16 @@ function G(e) {
3437
3609
  bars: e.bars
3438
3610
  };
3439
3611
  }
3440
- var Pn = 500;
3441
- function Fn(e, t) {
3612
+ var Bn = 500;
3613
+ function Vn(e, t) {
3614
+ let n = 0, r = e.length;
3615
+ for (; n < r;) {
3616
+ let i = n + r >> 1;
3617
+ e[i].time < t ? n = i + 1 : r = i;
3618
+ }
3619
+ return n;
3620
+ }
3621
+ function Hn(e, t) {
3442
3622
  let n = 0, r = e.length;
3443
3623
  for (; n < r;) {
3444
3624
  let i = n + r >> 1;
@@ -3446,20 +3626,20 @@ function Fn(e, t) {
3446
3626
  }
3447
3627
  return n;
3448
3628
  }
3449
- function In(e) {
3629
+ function Un(e) {
3450
3630
  let t = 0, n = 0;
3451
3631
  for (let r = 1; r < e.length; r++) e[r].low < e[t].low && (t = r), e[r].high > e[n].high && (n = r);
3452
3632
  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];
3453
3633
  return [...a ? [r, i] : [i, r], [o.close, o.time]];
3454
3634
  }
3455
- function Ln(e) {
3635
+ function Wn(e) {
3456
3636
  let t = 0;
3457
3637
  for (let n = Math.max(1, e.length - 10); n < e.length; n++) t = Math.max(t, e[n].time - e[n - 1].time);
3458
3638
  return t > 0 ? t : Infinity;
3459
3639
  }
3460
- function Rn(e, t) {
3640
+ function Gn(e, t) {
3461
3641
  if (t.length === 0) return null;
3462
- let n = t[t.length - 1].time + Ln(t), r = e.filter((e) => zn(e) && e.time >= t[0].time && e.time < n).sort((e, t) => e.time - t.time), i = [];
3642
+ let n = t[t.length - 1].time + Wn(t), r = e.filter((e) => Kn(e) && e.time >= t[0].time && e.time < n).sort((e, t) => e.time - t.time), i = [];
3463
3643
  for (let e of r) (i.length === 0 || i[i.length - 1].time !== e.time) && i.push(e);
3464
3644
  if (i.length === 0) return null;
3465
3645
  let a = t.findIndex((e) => e.time >= i[0].time);
@@ -3467,7 +3647,7 @@ function Rn(e, t) {
3467
3647
  let o = t.slice(0, a), s = i.filter((e) => e.time >= t[a].time);
3468
3648
  return [...o, ...s];
3469
3649
  }
3470
- function zn(e) {
3650
+ function Kn(e) {
3471
3651
  return [
3472
3652
  e.time,
3473
3653
  e.open,
@@ -3476,7 +3656,7 @@ function zn(e) {
3476
3656
  e.close
3477
3657
  ].every(Number.isFinite);
3478
3658
  }
3479
- function Bn(e, t) {
3659
+ function qn(e, t) {
3480
3660
  let n = 0, r = e.length - 1;
3481
3661
  for (; n < r;) {
3482
3662
  let i = n + r + 1 >> 1;
@@ -3484,22 +3664,22 @@ function Bn(e, t) {
3484
3664
  }
3485
3665
  return n;
3486
3666
  }
3487
- function Vn(e, t, n) {
3667
+ function Jn(e, t, n) {
3488
3668
  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;
3489
3669
  for (let t = 0; t < e.length && e[t].time < i; t++) a = t;
3490
3670
  return Math.max(0, a);
3491
3671
  }
3492
- function Hn(e, t, n) {
3672
+ function Yn(e, t, n) {
3493
3673
  let r = n;
3494
3674
  for (; r > 0 && t[r - 1].time >= e.time;) r--;
3495
3675
  let i = {
3496
3676
  ...t[r],
3497
3677
  time: e.time
3498
3678
  };
3499
- for (let e = r + 1; e <= n; e++) i = Un(i, t[e]);
3679
+ for (let e = r + 1; e <= n; e++) i = Xn(i, t[e]);
3500
3680
  return i;
3501
3681
  }
3502
- function Un(e, t) {
3682
+ function Xn(e, t) {
3503
3683
  return {
3504
3684
  time: e.time,
3505
3685
  open: e.open,
@@ -3509,34 +3689,34 @@ function Un(e, t) {
3509
3689
  volume: (e.volume ?? 0) + (t.volume ?? 0)
3510
3690
  };
3511
3691
  }
3512
- function K(e, t) {
3692
+ function q(e, t) {
3513
3693
  let n = e[e.length - 1];
3514
3694
  if (!n) return "append";
3515
- let r = m(t.time), i = m(n.time);
3695
+ let r = h(t.time), i = h(n.time);
3516
3696
  return r > i ? "append" : r === i ? "update" : "stale";
3517
3697
  }
3518
3698
  //#endregion
3519
3699
  //#region src/io/parseOHLCV.ts
3520
- var Wn = [
3700
+ var Zn = [
3521
3701
  "time",
3522
3702
  "timestamp",
3523
3703
  "date",
3524
3704
  "datetime",
3525
3705
  "t"
3526
- ], Gn = ["open", "o"], Kn = ["high", "h"], qn = ["low", "l"], Jn = ["close", "c"], Yn = [
3706
+ ], Qn = ["open", "o"], $n = ["high", "h"], er = ["low", "l"], tr = ["close", "c"], nr = [
3527
3707
  "volume",
3528
3708
  "vol",
3529
3709
  "v"
3530
3710
  ];
3531
- function Xn(e) {
3711
+ function rr(e) {
3532
3712
  let t = e.trim();
3533
- return t ? t[0] === "[" || t[0] === "{" ? Zn(t) : Qn(t) : {
3713
+ return t ? t[0] === "[" || t[0] === "{" ? ir(t) : ar(t) : {
3534
3714
  data: [],
3535
3715
  rowCount: 0,
3536
3716
  skipped: 0
3537
3717
  };
3538
3718
  }
3539
- function Zn(e) {
3719
+ function ir(e) {
3540
3720
  let t;
3541
3721
  try {
3542
3722
  t = JSON.parse(e);
@@ -3546,19 +3726,19 @@ function Zn(e) {
3546
3726
  if (!Array.isArray(t)) throw Error("Expected a JSON array of OHLCV rows");
3547
3727
  let n = [], r = 0;
3548
3728
  for (let e of t) {
3549
- let t = Array.isArray(e) ? nr(e) : tr(e);
3729
+ let t = Array.isArray(e) ? ur(e) : lr(e);
3550
3730
  t ? n.push(t) : r++;
3551
3731
  }
3552
- return rr(n, t.length, r);
3732
+ return dr(n, t.length, r);
3553
3733
  }
3554
- function Qn(e) {
3734
+ function ar(e) {
3555
3735
  let t = e.split(/\r?\n/).filter((e) => e.trim().length > 0);
3556
3736
  if (t.length === 0) return {
3557
3737
  data: [],
3558
3738
  rowCount: 0,
3559
3739
  skipped: 0
3560
3740
  };
3561
- let n = $n(t[0]), r = q(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? er(r) : {
3741
+ let n = or(t[0]), r = sr(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? cr(r) : {
3562
3742
  time: 0,
3563
3743
  open: 1,
3564
3744
  high: 2,
@@ -3569,7 +3749,7 @@ function Qn(e) {
3569
3749
  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");
3570
3750
  let o = [], s = 0;
3571
3751
  for (let e = +!!i; e < t.length; e++) {
3572
- let r = q(t[e], n), i = Y(r[a.time]), c = J(r[a.open]), l = J(r[a.high]), u = J(r[a.low]), d = J(r[a.close]), f = a.volume >= 0 ? Number(r[a.volume]) : 0;
3752
+ let r = sr(t[e], n), i = Y(r[a.time]), c = J(r[a.open]), l = J(r[a.high]), u = J(r[a.low]), d = J(r[a.close]), f = a.volume >= 0 ? Number(r[a.volume]) : 0;
3573
3753
  if (i === null || ![
3574
3754
  c,
3575
3755
  l,
@@ -3588,9 +3768,9 @@ function Qn(e) {
3588
3768
  volume: Number.isFinite(f) ? f : 0
3589
3769
  });
3590
3770
  }
3591
- return rr(o, t.length - +!!i, s);
3771
+ return dr(o, t.length - +!!i, s);
3592
3772
  }
3593
- function $n(e) {
3773
+ function or(e) {
3594
3774
  let t = {
3595
3775
  ",": 0,
3596
3776
  ";": 0,
@@ -3602,7 +3782,7 @@ function $n(e) {
3602
3782
  for (let [e, i] of Object.entries(t)) i > r && (n = e, r = i);
3603
3783
  return n;
3604
3784
  }
3605
- function q(e, t) {
3785
+ function sr(e, t) {
3606
3786
  let n = [], r = "", i = !1;
3607
3787
  for (let a = 0; a < e.length; a++) {
3608
3788
  let o = e[a];
@@ -3610,25 +3790,25 @@ function q(e, t) {
3610
3790
  }
3611
3791
  return n.push(r), n;
3612
3792
  }
3613
- function er(e) {
3793
+ function cr(e) {
3614
3794
  let t = (t) => e.findIndex((e) => t.includes(e));
3615
3795
  return {
3616
- time: t(Wn),
3617
- open: t(Gn),
3618
- high: t(Kn),
3619
- low: t(qn),
3620
- close: t(Jn),
3621
- volume: t(Yn)
3796
+ time: t(Zn),
3797
+ open: t(Qn),
3798
+ high: t($n),
3799
+ low: t(er),
3800
+ close: t(tr),
3801
+ volume: t(nr)
3622
3802
  };
3623
3803
  }
3624
- function tr(e) {
3804
+ function lr(e) {
3625
3805
  let t = (t) => {
3626
3806
  for (let n of t) {
3627
3807
  if (e[n] !== void 0) return e[n];
3628
3808
  let t = n.toUpperCase();
3629
3809
  if (e[t] !== void 0) return e[t];
3630
3810
  }
3631
- }, n = Y(String(t(Wn) ?? "")), r = Number(t(Gn)), i = Number(t(Kn)), a = Number(t(qn)), o = Number(t(Jn)), s = Number(t(Yn) ?? 0);
3811
+ }, n = Y(String(t(Zn) ?? "")), r = Number(t(Qn)), i = Number(t($n)), a = Number(t(er)), o = Number(t(tr)), s = Number(t(nr) ?? 0);
3632
3812
  return n === null || ![
3633
3813
  r,
3634
3814
  i,
@@ -3643,7 +3823,7 @@ function tr(e) {
3643
3823
  volume: Number.isFinite(s) ? s : 0
3644
3824
  };
3645
3825
  }
3646
- function nr(e) {
3826
+ function ur(e) {
3647
3827
  if (e.length < 5) return null;
3648
3828
  let t = Y(String(e[0])), n = Number(e[1]), r = Number(e[2]), i = Number(e[3]), a = Number(e[4]), o = e.length >= 6 ? Number(e[5]) : 0;
3649
3829
  return t === null || ![
@@ -3671,7 +3851,7 @@ function Y(e) {
3671
3851
  let r = Date.parse(t);
3672
3852
  return Number.isFinite(r) ? r : null;
3673
3853
  }
3674
- function rr(e, t, n) {
3854
+ function dr(e, t, n) {
3675
3855
  e.sort((e, t) => e.time - t.time);
3676
3856
  let r = [];
3677
3857
  for (let t of e) r.length > 0 && r[r.length - 1].time === t.time ? r[r.length - 1] = t : r.push(t);
@@ -3683,7 +3863,7 @@ function rr(e, t, n) {
3683
3863
  }
3684
3864
  //#endregion
3685
3865
  //#region src/io/DragDropImporter.ts
3686
- var ir = class {
3866
+ var fr = class {
3687
3867
  host;
3688
3868
  overlay = null;
3689
3869
  callbacks;
@@ -3716,7 +3896,7 @@ var ir = class {
3716
3896
  e.preventDefault(), this.depth = 0, this.hideOverlay();
3717
3897
  let t = e.dataTransfer?.files?.[0];
3718
3898
  if (t) try {
3719
- let e = Xn(await t.text());
3899
+ let e = rr(await t.text());
3720
3900
  if (e.data.length === 0) throw Error(`No valid OHLCV rows found in "${t.name}"`);
3721
3901
  this.callbacks.onData(e.data, e, t);
3722
3902
  } catch (e) {
@@ -3760,7 +3940,7 @@ function Z(e) {
3760
3940
  };
3761
3941
  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;
3762
3942
  }
3763
- var ar = (e, t) => t.updatedAt - e.updatedAt;
3943
+ var pr = (e, t) => t.updatedAt - e.updatedAt;
3764
3944
  function Q(e) {
3765
3945
  if (typeof e != "object" || !e) return null;
3766
3946
  let t = e;
@@ -3773,17 +3953,17 @@ function Q(e) {
3773
3953
  kind: typeof t.kind == "string" ? t.kind : void 0
3774
3954
  });
3775
3955
  }
3776
- function or(e) {
3956
+ function mr(e) {
3777
3957
  let t = Q(e), n = t ? e.content : void 0;
3778
3958
  return t && typeof n == "string" ? {
3779
3959
  ...t,
3780
3960
  content: n
3781
3961
  } : null;
3782
3962
  }
3783
- function sr(e = []) {
3963
+ function hr(e = []) {
3784
3964
  let t = new Map(e.map((e) => [e.id, { ...e }]));
3785
3965
  return {
3786
- list: () => [...t.values()].map(Z).sort(ar),
3966
+ list: () => [...t.values()].map(Z).sort(pr),
3787
3967
  load: (e) => {
3788
3968
  let n = t.get(e);
3789
3969
  return n ? { ...n } : null;
@@ -3796,7 +3976,7 @@ function sr(e = []) {
3796
3976
  }
3797
3977
  };
3798
3978
  }
3799
- function cr(e = "tcw:layouts:") {
3979
+ function gr(e = "tcw:layouts:") {
3800
3980
  let t = `${e}index`, n = (t) => `${e}item:${t}`, r = () => {
3801
3981
  let e;
3802
3982
  try {
@@ -3807,7 +3987,7 @@ function cr(e = "tcw:layouts:") {
3807
3987
  return Array.isArray(e) ? e.map(Q).filter((e) => e !== null) : [];
3808
3988
  }, i = (e) => localStorage.setItem(t, JSON.stringify(e));
3809
3989
  return {
3810
- list: () => r().sort(ar),
3990
+ list: () => r().sort(pr),
3811
3991
  load: (e) => {
3812
3992
  let t = r().find((t) => t.id === e), i = t ? localStorage.getItem(n(e)) : null;
3813
3993
  return t && i !== null ? {
@@ -3825,14 +4005,14 @@ function cr(e = "tcw:layouts:") {
3825
4005
  }
3826
4006
  //#endregion
3827
4007
  //#region src/state/LayoutSession.ts
3828
- var lr = 80;
4008
+ var _r = 80;
3829
4009
  function $(e) {
3830
4010
  return e.replace(/\s+/g, " ").trim().slice(0, 80).trim() || null;
3831
4011
  }
3832
- function ur() {
4012
+ function vr() {
3833
4013
  return globalThis.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
3834
4014
  }
3835
- function dr(e) {
4015
+ function yr(e) {
3836
4016
  let { id: t, name: n, symbol: r, timeframe: i, updatedAt: a, kind: o } = e;
3837
4017
  return {
3838
4018
  id: t,
@@ -3843,7 +4023,7 @@ function dr(e) {
3843
4023
  ...o === void 0 ? {} : { kind: o }
3844
4024
  };
3845
4025
  }
3846
- var fr = class {
4026
+ var br = class {
3847
4027
  currentLayout = null;
3848
4028
  savedContent = null;
3849
4029
  dirty = !1;
@@ -3859,7 +4039,7 @@ var fr = class {
3859
4039
  now;
3860
4040
  newId;
3861
4041
  constructor(e, t, n = {}) {
3862
- 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 ?? ur;
4042
+ 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 ?? vr;
3863
4043
  }
3864
4044
  current() {
3865
4045
  return this.currentLayout;
@@ -3889,7 +4069,7 @@ var fr = class {
3889
4069
  }
3890
4070
  open(e) {
3891
4071
  return this.queue(async () => {
3892
- let t = or(await this.storage.load(e));
4072
+ let t = mr(await this.storage.load(e));
3893
4073
  if (!t || t.id !== e || (t.kind ?? "chart") !== this.kind || this.destroyed) return !1;
3894
4074
  this.cancelTimer(), this.applying++;
3895
4075
  try {
@@ -3899,13 +4079,13 @@ var fr = class {
3899
4079
  } finally {
3900
4080
  this.applying--;
3901
4081
  }
3902
- return this.cancelTimer(), this.currentLayout = dr(t), this.savedContent = this.host.capture().content, this.dirty = !1, this.notify(), !0;
4082
+ return this.cancelTimer(), this.currentLayout = yr(t), this.savedContent = this.host.capture().content, this.dirty = !1, this.notify(), !0;
3903
4083
  });
3904
4084
  }
3905
4085
  rename(e, t) {
3906
4086
  let n = $(t);
3907
4087
  return n ? this.queue(async () => {
3908
- let t = or(await this.storage.load(e));
4088
+ let t = mr(await this.storage.load(e));
3909
4089
  !t || t.id !== e || (await this.storage.save({
3910
4090
  ...t,
3911
4091
  name: n
@@ -3983,7 +4163,7 @@ var fr = class {
3983
4163
  content: n.content
3984
4164
  };
3985
4165
  await this.storage.save(r);
3986
- let i = dr(r);
4166
+ let i = yr(r);
3987
4167
  return this.currentLayout = i, this.savedContent = n.content, this.dirty = !1, this.notify(), i;
3988
4168
  }
3989
4169
  forget() {
@@ -4004,6 +4184,6 @@ var fr = class {
4004
4184
  }
4005
4185
  };
4006
4186
  //#endregion
4007
- export { Lt as C, B as S, H as _, sr as a, Xt as b, kn as c, hn as d, mn as f, dn as g, un as h, cr as i, Sn as l, pn as m, lr as n, ir as o, fn as p, $ as r, Xn as s, fr as t, gn as u, tn as v, Jt as x, Qt as y };
4187
+ export { Yt as C, F as S, H as _, hr as a, on as b, Fn as c, xn as d, W as f, vn as g, _n as h, gr as i, On as l, bn as m, _r as n, fr as o, yn as p, $ as r, rr as s, br as t, Sn as u, ln as v, I as x, L as y };
4008
4188
 
4009
- //# sourceMappingURL=LayoutSession-2yRujs2S.js.map
4189
+ //# sourceMappingURL=LayoutSession-BTfv1oBV.js.map