@tradecanvas/chart 1.53.0 → 1.54.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 (81) hide show
  1. package/dist/Chart.d.ts +47 -0
  2. package/dist/Chart.d.ts.map +1 -1
  3. package/dist/LayoutSession-0NYa74h6.cjs +2 -0
  4. package/dist/LayoutSession-0NYa74h6.cjs.map +1 -0
  5. package/dist/{LayoutSession-D7uQq3jX.js → LayoutSession-DAqzoWkF.js} +611 -533
  6. package/dist/LayoutSession-DAqzoWkF.js.map +1 -0
  7. package/dist/charts/ChartTypeStrategy.d.ts +11 -2
  8. package/dist/charts/ChartTypeStrategy.d.ts.map +1 -1
  9. package/dist/{i18n-CwCzRLKW.js → i18n-DGsh8zmc.js} +3 -1
  10. package/dist/i18n-DGsh8zmc.js.map +1 -0
  11. package/dist/i18n-GirmlAsM.cjs +2 -0
  12. package/dist/i18n-GirmlAsM.cjs.map +1 -0
  13. package/dist/index.cjs +1 -1
  14. package/dist/index.d.ts +4 -3
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +72 -72
  17. package/dist/indicatorLabel.d.ts +3 -2
  18. package/dist/indicatorLabel.d.ts.map +1 -1
  19. package/dist/layout/LayoutManager.d.ts +4 -0
  20. package/dist/layout/LayoutManager.d.ts.map +1 -1
  21. package/dist/widget/ChartWidget.d.ts +29 -0
  22. package/dist/widget/ChartWidget.d.ts.map +1 -1
  23. package/dist/widget/WidgetDataWindow.d.ts +4 -0
  24. package/dist/widget/WidgetDataWindow.d.ts.map +1 -1
  25. package/dist/widget/WidgetDrawingSidebar.d.ts +6 -0
  26. package/dist/widget/WidgetDrawingSidebar.d.ts.map +1 -1
  27. package/dist/widget/WidgetIndicatorLegend.d.ts +12 -1
  28. package/dist/widget/WidgetIndicatorLegend.d.ts.map +1 -1
  29. package/dist/widget/WidgetToolbar.d.ts.map +1 -1
  30. package/dist/widget/WidgetWatchlist.d.ts.map +1 -1
  31. package/dist/widget/formControls.d.ts +2 -0
  32. package/dist/widget/formControls.d.ts.map +1 -1
  33. package/dist/widget/index.cjs +37 -29
  34. package/dist/widget/index.cjs.map +1 -1
  35. package/dist/widget/index.js +1771 -1684
  36. package/dist/widget/index.js.map +1 -1
  37. package/dist/widget/legendValues.d.ts +6 -0
  38. package/dist/widget/legendValues.d.ts.map +1 -1
  39. package/dist/widget/locales/ar.d.ts.map +1 -1
  40. package/dist/widget/locales/cs.d.ts.map +1 -1
  41. package/dist/widget/locales/da.d.ts.map +1 -1
  42. package/dist/widget/locales/de.d.ts.map +1 -1
  43. package/dist/widget/locales/el.d.ts.map +1 -1
  44. package/dist/widget/locales/en.d.ts +1 -0
  45. package/dist/widget/locales/en.d.ts.map +1 -1
  46. package/dist/widget/locales/es.d.ts.map +1 -1
  47. package/dist/widget/locales/et.d.ts.map +1 -1
  48. package/dist/widget/locales/fa.d.ts.map +1 -1
  49. package/dist/widget/locales/fr.d.ts.map +1 -1
  50. package/dist/widget/locales/he.d.ts.map +1 -1
  51. package/dist/widget/locales/hu.d.ts.map +1 -1
  52. package/dist/widget/locales/id.d.ts.map +1 -1
  53. package/dist/widget/locales/index.cjs +1 -1
  54. package/dist/widget/locales/index.cjs.map +1 -1
  55. package/dist/widget/locales/index.js +29 -1
  56. package/dist/widget/locales/index.js.map +1 -1
  57. package/dist/widget/locales/it.d.ts.map +1 -1
  58. package/dist/widget/locales/ja.d.ts.map +1 -1
  59. package/dist/widget/locales/ko.d.ts.map +1 -1
  60. package/dist/widget/locales/ms.d.ts.map +1 -1
  61. package/dist/widget/locales/nb.d.ts.map +1 -1
  62. package/dist/widget/locales/nl.d.ts.map +1 -1
  63. package/dist/widget/locales/pl.d.ts.map +1 -1
  64. package/dist/widget/locales/pt.d.ts.map +1 -1
  65. package/dist/widget/locales/ro.d.ts.map +1 -1
  66. package/dist/widget/locales/ru.d.ts.map +1 -1
  67. package/dist/widget/locales/sk.d.ts.map +1 -1
  68. package/dist/widget/locales/sv.d.ts.map +1 -1
  69. package/dist/widget/locales/th.d.ts.map +1 -1
  70. package/dist/widget/locales/tr.d.ts.map +1 -1
  71. package/dist/widget/locales/vi.d.ts.map +1 -1
  72. package/dist/widget/locales/zh.d.ts.map +1 -1
  73. package/dist/widget/locales/zhHant.d.ts.map +1 -1
  74. package/dist/widget/widgetCompare.d.ts.map +1 -1
  75. package/package.json +3 -3
  76. package/dist/LayoutSession-D7uQq3jX.js.map +0 -1
  77. package/dist/LayoutSession-nlhT-EH7.cjs +0 -2
  78. package/dist/LayoutSession-nlhT-EH7.cjs.map +0 -1
  79. package/dist/i18n-CwCzRLKW.js.map +0 -1
  80. package/dist/i18n-D7B7uFrN.cjs +0 -2
  81. package/dist/i18n-D7B7uFrN.cjs.map +0 -1
@@ -1,12 +1,12 @@
1
- import { DARK_THEME as e, DEFAULT_PANEL_HEIGHT as t, LIGHT_THEME as n, LayerType as r, MIN_PANEL_HEIGHT as i, PHI as a, PRICE_AXIS_WIDTH as o, TIME_AXIS_HEIGHT as s, autoPricePrecision as c, barDateZone as l, barTimeUnit as u, barsAreDaily as d, chartStyleValue as f, computePriceLimits as p, computePriceRange as m, formatPrice as h, fractionTick as g, indicatorSource as _, isValidTimeZone as v, mergeBar as ee, niceNumber as te, normalizeBarTime as y, parseIndicatorSource as b, priceFormatterFor as ne, priceStepAt as re, readChartStyleOverrides as ie, readChartTypeOptions as x, readIndicatorPlotStyles as ae, readPaneStyle as oe, resolveChartTheme as se, sessionMinute as S, setLocale as ce, stepDecimals as le, symbolTimeZone as C, tickBarCount as ue, timeframeToMs as w, zonedDateFormatter as de } from "@tradecanvas/commons";
2
- import { AlertDragHandler as fe, AlertManager as pe, Animator as me, AreaRenderer as he, AxisDragHandler as ge, BarCountdown as _e, BarRenderer as ve, BaselineRenderer as ye, CandlestickRenderer as be, ChartLegend as xe, ChartStateManager as T, CompareRenderer as Se, CompareSymbolIndicator as Ce, CorrelationCoefficientIndicator as we, CorrelationLogIndicator as Te, CrosshairHandler as Ee, CrosshairTooltip as De, CurrentPriceLine as Oe, DEFAULT_SESSION_HOURS as ke, DataExporter as E, DepthHeatmapRenderer as Ae, DrawingManager as je, DrawingRenderer as Me, EquivolumeRenderer as Ne, EventBus as Pe, GridRenderer as Fe, HLCAreaRenderer as Ie, HiLoRenderer as Le, HollowCandleRenderer as Re, IndicatorEngine as ze, InteractionManager as Be, KagiRenderer as Ve, KeyboardHandler as He, LineRenderer as Ue, LineWithMarkersRenderer as We, MarketProfileRenderer as Ge, MeasureOverlay as Ke, PRICE_SCALE_MARGIN as D, PanHandler as qe, PaneResizeHandler as Je, PeriodLevelsRenderer as Ye, PinnedTooltip as Xe, PivotMarkersRenderer as Ze, PointAndFigureRenderer as Qe, PriceAxis as $e, PriceAxisAddButton as et, PriceLines as tt, RenderEngine as nt, RenkoRenderer as rt, ReplayManager as it, ResamplingAdapter as at, ReshapeMemo as ot, SYMBOL_INDICATOR_IDS as O, SYMBOL_ZONE_WAIT_MS as st, Screenshot as k, SelectionBoxOverlay as ct, SessionBreaks as lt, SessionShading as ut, SignalMarkerManager as dt, SpreadIndicator as ft, StepLineRenderer as pt, StreamManager as mt, SymbolSeriesStore as ht, TimeAxis as gt, TradeZoneManager as _t, TradingManager as vt, TradingRenderer as yt, UndoRedoManager as bt, Viewport as xt, VolumeCandleRenderer as St, VolumeProfileRenderer as Ct, VolumeRenderer as wt, Watermark as Tt, ZoomHandler as Et, barTimeStepMs as Dt, findDominantSwing as Ot, gpuContextsLeft as kt, isPriceLevelAlert as At, isRegularSession as jt, loadWebGL as Mt, mergeSessionHours as Nt, pointAndFigureColumns as Pt, priceToY as Ft, rangePresetStart as It, readAlertOptions as Lt, registerBuiltInDrawingTools as Rt, registerBuiltInIndicators as zt, servesTimeframe as A, sourceParam as j, timeToX as Bt, timestampToBarIndex as M, toHeikinAshi as Vt, toKagi as Ht, toLineBreak as Ut, toRangeBars as Wt, toRenko as Gt, whenGpuContextFree as Kt, withResampling as N, xToBarIndex as qt, xToTime as P, yToPrice as Jt } from "@tradecanvas/core";
1
+ import { DARK_THEME as e, DEFAULT_PANEL_HEIGHT as t, LIGHT_THEME as n, LayerType as r, MIN_PANEL_HEIGHT as i, PHI as a, PRICE_AXIS_WIDTH as o, TIME_AXIS_HEIGHT as s, autoPricePrecision as c, barDateZone as l, barTimeUnit as u, barsAreDaily as d, chartStyleValue as f, computePriceLimits as p, computePriceRange as m, formatPrice as h, fractionTick as g, indicatorSource as _, isValidTimeZone as v, mergeBar as y, niceNumber as ee, normalizeBarTime as b, parseIndicatorSource as x, priceFormatterFor as te, priceStepAt as ne, readChartStyleOverrides as re, readChartTypeOptions as S, readIndicatorPlotStyles as ie, readPaneStyle as ae, resolveChartTheme as oe, sessionMinute as C, setLocale as se, stepDecimals as ce, symbolTimeZone as w, tickBarCount as le, timeframeToMs as T, zonedDateFormatter as ue } from "@tradecanvas/commons";
2
+ import { AlertDragHandler as de, AlertManager as fe, Animator as pe, AreaRenderer as me, AxisDragHandler as he, BarCountdown as ge, BarRenderer as _e, BaselineRenderer as ve, CandlestickRenderer as ye, ChartLegend as be, ChartStateManager as E, CompareRenderer as xe, CompareSymbolIndicator as Se, CompareSymbolPaneIndicator as Ce, CorrelationCoefficientIndicator as we, CorrelationLogIndicator as Te, CrosshairHandler as Ee, CrosshairTooltip as De, CurrentPriceLine as Oe, DEFAULT_SESSION_HOURS as ke, DataExporter as D, DepthHeatmapRenderer as Ae, DrawingManager as je, DrawingRenderer as Me, EquivolumeRenderer as Ne, EventBus as Pe, GridRenderer as Fe, HLCAreaRenderer as Ie, HiLoRenderer as Le, HollowCandleRenderer as Re, IndicatorEngine as ze, InteractionManager as Be, KagiRenderer as Ve, KeyboardHandler as He, LineRenderer as Ue, LineWithMarkersRenderer as We, MarketProfileRenderer as Ge, MeasureOverlay as Ke, PRICE_SCALE_MARGIN as O, PanHandler as qe, PaneResizeHandler as Je, PeriodLevelsRenderer as Ye, PinnedTooltip as Xe, PivotMarkersRenderer as Ze, PointAndFigureRenderer as Qe, PriceAxis as $e, PriceAxisAddButton as et, PriceLines as tt, RenderEngine as nt, RenkoRenderer as rt, ReplayManager as it, ResamplingAdapter as at, ReshapeMemo as ot, SYMBOL_INDICATOR_IDS as k, SYMBOL_ZONE_WAIT_MS as st, Screenshot as A, SelectionBoxOverlay as ct, SessionBreaks as lt, SessionShading as ut, SignalMarkerManager as dt, SpreadIndicator as ft, StepLineRenderer as pt, StreamManager as mt, SymbolSeriesStore as ht, TimeAxis as gt, TradeZoneManager as _t, TradingManager as vt, TradingRenderer as yt, UndoRedoManager as bt, Viewport as xt, VolumeCandleRenderer as St, VolumeProfileRenderer as Ct, VolumeRenderer as wt, Watermark as Tt, ZoomHandler as Et, axisTimes as Dt, barTimeStepMs as Ot, findDominantSwing as kt, gpuContextsLeft as At, isPriceLevelAlert as jt, isRegularSession as Mt, loadWebGL as Nt, mergeSessionHours as Pt, pointAndFigureColumns as Ft, priceToY as It, rangePresetStart as Lt, readAlertOptions as Rt, registerBuiltInDrawingTools as zt, registerBuiltInIndicators as Bt, servesTimeframe as j, sourceParam as Vt, timeToX as Ht, timestampToBarIndex as M, toHeikinAshi as Ut, toKagi as Wt, toLineBreak as Gt, toRangeBars as Kt, toRenko as qt, whenGpuContextFree as Jt, withResampling as N, xToBarIndex as Yt, xToTime as P, yToPrice as Xt } from "@tradecanvas/core";
3
3
  //#region src/regularHours.ts
4
- var Yt = 864e5, Xt = 10;
5
- function Zt(e, t) {
6
- let n = C(e);
4
+ var Zt = 864e5, Qt = 10;
5
+ function $t(e, t) {
6
+ let n = w(e);
7
7
  if (!n || !v(n) || t.length < 2) return null;
8
8
  let r = (e?.sessions ?? []).flatMap((e) => {
9
- let t = S(e.start), n = S(e.end);
9
+ let t = C(e.start), n = C(e.end);
10
10
  return t === null || n === null ? [] : [{
11
11
  startMinute: t,
12
12
  endMinute: n
@@ -14,34 +14,34 @@ function Zt(e, t) {
14
14
  });
15
15
  if (r.length === 0) return null;
16
16
  let i = u(t), a = Infinity;
17
- for (let e = Math.max(1, t.length - Xt); e < t.length; e++) {
17
+ for (let e = Math.max(1, t.length - Qt); e < t.length; e++) {
18
18
  let n = (t[e].time - t[e - 1].time) * i;
19
19
  n > 0 && n < a && (a = n);
20
20
  }
21
- if (!(a < Yt)) return null;
21
+ if (!(a < Zt)) return null;
22
22
  let o = {
23
23
  timeZone: n,
24
24
  windows: r,
25
25
  startMinute: r[0].startMinute,
26
26
  endMinute: r[r.length - 1].endMinute
27
27
  };
28
- return (e) => jt(e * i, o);
28
+ return (e) => Mt(e * i, o);
29
29
  }
30
30
  //#endregion
31
31
  //#region src/chartA11y.ts
32
- var Qt = {
32
+ var en = {
33
33
  role: "chart",
34
34
  summary: "{what}. Last price {close}.",
35
35
  empty: "Chart, no data.",
36
36
  view: "Showing {count} bars, {from} to {to}. High {high}, low {low}.",
37
37
  bar: "{time}: open {open}, high {high}, low {low}, close {close}, volume {volume}.",
38
38
  keys: "Arrow keys scroll and zoom, Home and End go to the start and the end. Comma and period read the bars one at a time."
39
- }, F = (e, t) => e.replace(/\{(\w+)\}/g, (e, n) => n in t ? String(t[n]) : e), $t = [
39
+ }, F = (e, t) => e.replace(/\{(\w+)\}/g, (e, n) => n in t ? String(t[n]) : e), tn = [
40
40
  "role",
41
41
  "aria-roledescription",
42
42
  "aria-label",
43
43
  "aria-describedby"
44
- ], en = 400, tn = 1e3, nn = class {
44
+ ], nn = 400, rn = 1e3, an = class {
45
45
  live;
46
46
  help;
47
47
  labels;
@@ -55,20 +55,20 @@ var Qt = {
55
55
  };
56
56
  constructor(e, t, n = {}) {
57
57
  this.container = e, this.source = t, this.labels = {
58
- ...Qt,
58
+ ...en,
59
59
  ...n
60
60
  };
61
- for (let t of $t) this.before.set(t, e.getAttribute(t));
62
- e.setAttribute("role", "application"), this.help = rn("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 = rn("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 tn) this.before.set(t, e.getAttribute(t));
62
+ e.setAttribute("role", "application"), this.help = on("div", "tc-sr-only"), this.help.id = `tc-chart-keys-${Math.random().toString(36).slice(2, 10)}`, e.setAttribute("aria-describedby", this.help.id), this.live = on("div", "tc-sr-only tc-sr-live"), this.live.setAttribute("aria-live", "polite"), this.live.setAttribute("aria-atomic", "true"), e.append(this.help, this.live), e.addEventListener("blur", this.onBlur), this.applyLabels();
63
63
  }
64
64
  setLabels(e) {
65
65
  this.labels = {
66
- ...Qt,
66
+ ...en,
67
67
  ...e
68
68
  }, this.applyLabels();
69
69
  }
70
70
  refresh(e = !1) {
71
- let t = tn - (Date.now() - this.summaryAt);
71
+ let t = rn - (Date.now() - this.summaryAt);
72
72
  if (e || t <= 0 || this.container.getAttribute("aria-label") === this.labels.empty) {
73
73
  this.summaryTimer && clearTimeout(this.summaryTimer), this.summaryTimer = null, this.summaryAt = Date.now(), this.container.setAttribute("aria-label", this.summary());
74
74
  return;
@@ -80,7 +80,7 @@ var Qt = {
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
- }, en);
83
+ }, nn);
84
84
  }
85
85
  readBar(e) {
86
86
  let t = this.source.bars();
@@ -99,7 +99,7 @@ var Qt = {
99
99
  high: a(i.high),
100
100
  low: a(i.low),
101
101
  close: a(i.close),
102
- volume: an(i.volume ?? 0)
102
+ volume: sn(i.volume ?? 0)
103
103
  }));
104
104
  }
105
105
  destroy() {
@@ -140,7 +140,7 @@ var Qt = {
140
140
  this.live.textContent = e;
141
141
  }
142
142
  };
143
- function rn(e, t) {
143
+ function on(e, t) {
144
144
  let n = document.createElement(e);
145
145
  return n.className = t, Object.assign(n.style, {
146
146
  position: "absolute",
@@ -154,13 +154,14 @@ function rn(e, t) {
154
154
  border: "0"
155
155
  }), n;
156
156
  }
157
- function an(e) {
157
+ function sn(e) {
158
158
  return Number.isInteger(e) ? String(e) : e.toFixed(2);
159
159
  }
160
160
  //#endregion
161
161
  //#region src/indicatorLabel.ts
162
- function on(e, t, n, r) {
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] : [];
162
+ var cn = 3, ln = { stochrsi: 4 };
163
+ function un(e, t, n, r) {
164
+ let i = Object.keys(n || t).map((e) => t[e]).filter((e) => typeof e == "number" && Number.isFinite(e)).slice(0, ln[e] ?? cn).map((e) => String(Number(e.toFixed(4)))), a = typeof t.symbol == "string" && t.symbol ? [t.symbol] : [];
164
165
  return [
165
166
  e === "spread" && t.mode === "ratio" ? "Ratio" : r ?? e.toUpperCase(),
166
167
  ...a,
@@ -169,17 +170,17 @@ function on(e, t, n, r) {
169
170
  }
170
171
  //#endregion
171
172
  //#region src/charts/ChartTypeStrategy.ts
172
- function sn(e) {
173
+ function dn(e) {
173
174
  switch (e) {
174
175
  case "candlestick":
175
176
  case "heikinAshi":
176
177
  case "lineBreak":
177
- case "rangeBars": return new be();
178
+ case "rangeBars": return new ye();
178
179
  case "line": return new Ue();
179
- case "area": return new he();
180
- case "bar": return new ve();
180
+ case "area": return new me();
181
+ case "bar": return new _e();
181
182
  case "hollowCandle": return new Re();
182
- case "baseline": return new ye();
183
+ case "baseline": return new ve();
183
184
  case "renko": return new rt();
184
185
  case "kagi": return new Ve();
185
186
  case "pointAndFigure": return new Qe();
@@ -189,32 +190,32 @@ function sn(e) {
189
190
  case "stepLine": return new pt();
190
191
  case "lineWithMarkers": return new We();
191
192
  case "hiLo": return new Le();
192
- default: return new be();
193
+ default: return new ye();
193
194
  }
194
195
  }
195
- function cn(e, t, n = {}, r, i) {
196
+ function fn(e, t, n = {}, r, i) {
196
197
  if (t.length === 0) return t;
197
198
  switch (e) {
198
- case "heikinAshi": return Vt(t);
199
+ case "heikinAshi": return Ut(t);
199
200
  case "renko": {
200
201
  let e = n.renko?.boxSize;
201
- return typeof e == "number" ? Gt(t, { brickSize: e }, i) : Gt(t, {
202
+ return typeof e == "number" ? qt(t, { brickSize: e }, i) : qt(t, {
202
203
  brickSize: 0,
203
204
  useATR: !0,
204
205
  atrPeriod: n.renko?.atrPeriod ?? 14
205
206
  }, i);
206
207
  }
207
- case "lineBreak": return Ut(t, n.lineBreak?.lines ?? 3);
208
- case "kagi": return Ht(t, n.kagi?.reversal ?? 4, n.kagi?.reversalType ?? "percent", i);
209
- case "pointAndFigure": return un(t, n, i).columns;
210
- case "rangeBars": return Wt(t, {
211
- rangeSize: _n(t, n, r),
208
+ case "lineBreak": return Gt(t, n.lineBreak?.lines ?? 3);
209
+ case "kagi": return Wt(t, n.kagi?.reversal ?? 4, n.kagi?.reversalType ?? "percent", i);
210
+ case "pointAndFigure": return mn(t, n, i).columns;
211
+ case "rangeBars": return Kt(t, {
212
+ rangeSize: Cn(t, n, r),
212
213
  includeForming: !0
213
214
  }, i);
214
215
  default: return t;
215
216
  }
216
217
  }
217
- function ln(e) {
218
+ function pn(e) {
218
219
  switch (e) {
219
220
  case "heikinAshi":
220
221
  case "renko":
@@ -226,64 +227,71 @@ function ln(e) {
226
227
  }
227
228
  }
228
229
  function I(e) {
229
- return e !== "heikinAshi" && ln(e);
230
+ return e !== "heikinAshi" && pn(e);
230
231
  }
231
- function un(e, t = {}, n) {
232
- let r = t.pointAndFigure?.boxSize;
233
- return Pt(e, typeof r == "number" ? r : dn(e) * .01, t.pointAndFigure?.reversal ?? 3, n);
232
+ function mn(e, t = {}, n) {
233
+ return Ft(e, _n(e, t), t.pointAndFigure?.reversal ?? 3, n);
234
234
  }
235
- function dn(e) {
236
- let t = 0;
237
- for (let n of e) t += n.close;
238
- return t / e.length;
235
+ var hn = 50, gn = .01;
236
+ function _n(e, t = {}) {
237
+ let n = t.pointAndFigure?.boxSize;
238
+ if (typeof n == "number") return n;
239
+ let r = vn(e, e.length > 1 ? e.length - 1 : e.length);
240
+ return r > 0 ? L(ee(r / hn, !0)) : Math.abs(e[e.length - 1]?.close ?? 0) * gn || 1;
241
+ }
242
+ function vn(e, t) {
243
+ let n = -Infinity, r = Infinity;
244
+ for (let i = 0; i < t; i++) e[i].high > n && (n = e[i].high), e[i].low < r && (r = e[i].low);
245
+ let i = n - r;
246
+ return Number.isFinite(i) ? i : 0;
239
247
  }
240
- var fn = 100, pn = 3, mn = .01, hn = 15, gn = (e) => Number(e.toPrecision(hn));
241
- function _n(e, t = {}, n) {
248
+ var yn = 100, bn = 3, xn = .01, Sn = 15, L = (e) => Number(e.toPrecision(Sn));
249
+ function Cn(e, t = {}, n) {
242
250
  let r = t.rangeBars?.range;
243
251
  if (typeof r == "number") return r;
244
- let i = e.length >= pn ? yn(e) : 0, a = Math.abs(e[e.length - 1]?.close ?? 0);
245
- return Sn(gn(te(i > 0 ? i : a * mn || 1, !0)), n);
252
+ let i = e.length >= bn ? Tn(e) : 0, a = Math.abs(e[e.length - 1]?.close ?? 0);
253
+ return On(L(ee(i > 0 ? i : a * xn || 1, !0)), n);
246
254
  }
247
- function vn(e) {
255
+ function wn(e) {
248
256
  let t = e.length - 1;
249
257
  return {
250
- from: Math.max(0, t - fn),
258
+ from: Math.max(0, t - yn),
251
259
  end: t
252
260
  };
253
261
  }
254
- function yn(e) {
255
- let { from: t, end: n } = vn(e), r = 0;
262
+ function Tn(e) {
263
+ let { from: t, end: n } = wn(e), r = 0;
256
264
  for (let i = t; i < n; i++) {
257
265
  let { high: t, low: n } = e[i], a = i > 0 ? e[i - 1].close : n;
258
266
  r += Math.max(t - n, Math.abs(t - a), Math.abs(n - a));
259
267
  }
260
268
  return n > t ? r / (n - t) : 0;
261
269
  }
262
- function bn(e, t) {
263
- let { from: n, end: r } = vn(e);
270
+ function En(e, t) {
271
+ let { from: n, end: r } = wn(e);
264
272
  if (r <= n) return t(e[e.length - 1]?.close ?? 0);
265
273
  let i = -Infinity, a = Infinity;
266
274
  for (let t = n; t < r; t++) i = Math.max(i, e[t].high), a = Math.min(a, e[t].low);
267
- return xn(t(i), t(a));
275
+ return Dn(t(i), t(a));
268
276
  }
269
- function xn(e, t) {
277
+ function Dn(e, t) {
270
278
  return e === void 0 ? t : t === void 0 ? e : Math.max(e, t);
271
279
  }
272
- function Sn(e, t) {
273
- return t === void 0 || !(t > 0) ? e : gn(Math.max(1, Math.round(e / t)) * t);
280
+ function On(e, t) {
281
+ return t === void 0 || !(t > 0) ? e : L(Math.max(1, Math.round(e / t)) * t);
274
282
  }
275
- function Cn(e, t) {
283
+ function kn(e, t) {
276
284
  let n = t?.(e);
277
- return n ? n.createRenderer() : sn(e);
285
+ return n ? n.createRenderer() : dn(e);
278
286
  }
279
- function wn(e, t, n, r, i, a) {
287
+ function An(e, t, n, r, i, a) {
280
288
  if (t.length === 0) return t;
281
289
  let o = n?.(e);
282
- return o?.transform ? o.transform(t) : cn(e, t, r, i, a);
290
+ return o?.transform ? o.transform(t) : fn(e, t, r, i, a);
283
291
  }
284
292
  //#endregion
285
293
  //#region src/state/AutoSaveScheduler.ts
286
- var Tn = class {
294
+ var jn = class {
287
295
  timer = null;
288
296
  delayMs = 0;
289
297
  key = null;
@@ -313,15 +321,15 @@ var Tn = class {
313
321
  };
314
322
  //#endregion
315
323
  //#region src/DataManager.ts
316
- function L(e) {
324
+ function R(e) {
317
325
  if (!e || typeof e.time != "number" || !Number.isFinite(e.time)) return !1;
318
326
  let { open: t, high: n, low: r, close: i } = e;
319
327
  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));
320
328
  }
321
- function En(e) {
329
+ function Mn(e) {
322
330
  return e.volume !== void 0 && e.high >= e.open && e.high >= e.close && e.low <= e.open && e.low <= e.close;
323
331
  }
324
- function R(e) {
332
+ function z(e) {
325
333
  return {
326
334
  ...e,
327
335
  high: Math.max(e.open, e.high, e.low, e.close),
@@ -329,36 +337,36 @@ function R(e) {
329
337
  volume: e.volume === void 0 ? 0 : Math.max(0, e.volume)
330
338
  };
331
339
  }
332
- function z(e, t) {
340
+ function B(e, t) {
333
341
  return e === t || e.time === t.time && e.open === t.open && e.high === t.high && e.low === t.low && e.close === t.close && e.volume === t.volume;
334
342
  }
335
- function Dn(e, t) {
343
+ function Nn(e, t) {
336
344
  for (let n = e.length - 1; n >= 0; n--) {
337
345
  if (e[n].time === t) return n;
338
346
  if (e[n].time < t) return -1;
339
347
  }
340
348
  return -1;
341
349
  }
342
- var On = {
350
+ var Pn = {
343
351
  index: -1,
344
352
  changed: !1
345
353
  };
346
- function kn(e, t) {
354
+ function Fn(e, t) {
347
355
  if (e.length === 0) return t;
348
- let n = y(t);
356
+ let n = b(t);
349
357
  return u(e) === 1 ? n : n / 1e3;
350
358
  }
351
- function An(e, t) {
352
- let n = kn(e, t.time);
359
+ function In(e, t) {
360
+ let n = Fn(e, t.time);
353
361
  return n === t.time ? t : {
354
362
  ...t,
355
363
  time: n
356
364
  };
357
365
  }
358
- var B = class {
366
+ var V = class {
359
367
  data = [];
360
368
  withSeriesTime(e) {
361
- return An(this.data, e);
369
+ return In(this.data, e);
362
370
  }
363
371
  getData() {
364
372
  return this.data;
@@ -367,16 +375,16 @@ var B = class {
367
375
  let t = [];
368
376
  for (let n = 0; n < e.length; n++) {
369
377
  let r = e[n];
370
- L(r) && t.push(En(r) ? r : R(r));
378
+ R(r) && t.push(Mn(r) ? r : z(r));
371
379
  }
372
380
  this.data = t;
373
381
  }
374
382
  prependBars(e) {
375
383
  let t = this.data.length > 0 ? this.data[0].time : Infinity, n = [];
376
384
  for (let r = 0; r < e.length; r++) {
377
- if (!L(e[r])) continue;
385
+ if (!R(e[r])) continue;
378
386
  let i = this.withSeriesTime(e[r]);
379
- i.time >= t || n.push(En(i) ? i : R(i));
387
+ i.time >= t || n.push(Mn(i) ? i : z(i));
380
388
  }
381
389
  if (n.length === 0) return 0;
382
390
  n.sort((e, t) => e.time - t.time);
@@ -385,11 +393,11 @@ var B = class {
385
393
  return n.length = r, this.data = n.concat(this.data), r;
386
394
  }
387
395
  appendBar(e) {
388
- L(e) && this.data.push(R(this.withSeriesTime(e)));
396
+ R(e) && this.data.push(z(this.withSeriesTime(e)));
389
397
  }
390
398
  updateLastBar(e) {
391
- if (!L(e)) return;
392
- let t = R(this.withSeriesTime(e));
399
+ if (!R(e)) return;
400
+ let t = z(this.withSeriesTime(e));
393
401
  if (this.data.length === 0) {
394
402
  this.data.push(t);
395
403
  return;
@@ -397,11 +405,11 @@ var B = class {
397
405
  this.data[this.data.length - 1] = t;
398
406
  }
399
407
  replaceBar(e) {
400
- if (!L(e)) return On;
401
- let t = this.withSeriesTime(e), n = Dn(this.data, t.time);
402
- if (n < 0) return On;
403
- let r = R(t);
404
- return z(this.data[n], r) ? {
408
+ if (!R(e)) return Pn;
409
+ let t = this.withSeriesTime(e), n = Nn(this.data, t.time);
410
+ if (n < 0) return Pn;
411
+ let r = z(t);
412
+ return B(this.data[n], r) ? {
405
413
  index: n,
406
414
  changed: !1
407
415
  } : (this.data[n] = r, {
@@ -410,7 +418,7 @@ var B = class {
410
418
  });
411
419
  }
412
420
  updateLastBarFromTick(e) {
413
- 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] = ee(this.data[this.data.length - 1], this.withSeriesTime(e))));
421
+ 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] = y(this.data[this.data.length - 1], this.withSeriesTime(e))));
414
422
  }
415
423
  getLength() {
416
424
  return this.data.length;
@@ -418,18 +426,18 @@ var B = class {
418
426
  clear() {
419
427
  this.data = [];
420
428
  }
421
- }, V = {
429
+ }, H = {
422
430
  to: "none",
423
431
  index: -1,
424
432
  changed: !1
425
433
  };
426
- function H(e, t) {
434
+ function U(e, t) {
427
435
  let n = e[e.length - 1];
428
436
  if (!n) return "append";
429
- let r = y(t.time), i = y(n.time);
437
+ let r = b(t.time), i = b(n.time);
430
438
  return r > i ? "append" : r === i ? "update" : "stale";
431
439
  }
432
- function jn(e) {
440
+ function Ln(e) {
433
441
  return [
434
442
  e.time,
435
443
  e.open,
@@ -438,8 +446,8 @@ function jn(e) {
438
446
  e.close
439
447
  ].every(Number.isFinite);
440
448
  }
441
- var Mn = class {
442
- shown = new B();
449
+ var Rn = class {
450
+ shown = new V();
443
451
  whole = null;
444
452
  aside = null;
445
453
  shownRevision = 0;
@@ -478,7 +486,7 @@ var Mn = class {
478
486
  }
479
487
  let t = null, n = e;
480
488
  if (this.whole) {
481
- let r = this.whole[0]?.time, i = /* @__PURE__ */ new Set(), a = e.filter(jn).map((e) => this.inSeriesUnit(e)).filter((e) => (r === void 0 || e.time < r) && !i.has(e.time) && i.add(e.time)).sort((e, t) => e.time - t.time);
489
+ let r = this.whole[0]?.time, i = /* @__PURE__ */ new Set(), a = e.filter(Ln).map((e) => this.inSeriesUnit(e)).filter((e) => (r === void 0 || e.time < r) && !i.has(e.time) && i.add(e.time)).sort((e, t) => e.time - t.time);
482
490
  this.whole = [...a, ...this.whole];
483
491
  let o = this.hoursFilter(this.whole);
484
492
  t = a.length, n = o ? a.filter((e) => o(e.time)) : a;
@@ -490,8 +498,8 @@ var Mn = class {
490
498
  };
491
499
  }
492
500
  mergeSnapshot(e) {
493
- if (this.aside) return this.aside.setData(Nn(this.aside.getData(), e) ?? e), this.onLiveChange({ kind: "series" }), !0;
494
- let t = Nn(this.whole ?? this.shown.getData(), e);
501
+ if (this.aside) return this.aside.setData(zn(this.aside.getData(), e) ?? e), this.onLiveChange({ kind: "series" }), !0;
502
+ let t = zn(this.whole ?? this.shown.getData(), e);
495
503
  return t ? (this.shown.setData(this.regularOnly(t)), !0) : !1;
496
504
  }
497
505
  refilter() {
@@ -548,7 +556,7 @@ var Mn = class {
548
556
  mergeTick(e) {
549
557
  if (this.aside) return this.aside.updateLastBarFromTick(e), this.wrote("aside", !1);
550
558
  let t = this.whole ? this.hoursFilter(this.whole) : null;
551
- if (t && this.whole && !t(kn(this.whole, e.time))) return this.wrote("hidden", !1);
559
+ if (t && this.whole && !t(Fn(this.whole, e.time))) return this.wrote("hidden", !1);
552
560
  let n = this.shown.getLength();
553
561
  this.shown.updateLastBarFromTick(e);
554
562
  let r = this.whole, i = this.shown.getData()[this.shown.getLength() - 1];
@@ -560,14 +568,14 @@ var Mn = class {
560
568
  }
561
569
  placeStreamBar(e) {
562
570
  if (this.aside) {
563
- let t = H(this.aside.getData(), e);
571
+ let t = U(this.aside.getData(), e);
564
572
  return t === "append" ? this.aside.appendBar(e) : t === "update" && this.aside.updateLastBar(e), this.wrote(t === "stale" ? "none" : "aside", !1);
565
573
  }
566
- let t = this.inSeriesUnit(e), n = H(this.whole ?? this.shown.getData(), t);
574
+ let t = this.inSeriesUnit(e), n = U(this.whole ?? this.shown.getData(), t);
567
575
  if (n === "stale") return this.wrote("none", !1);
568
576
  let r = this.startWholeSeries(t, n);
569
577
  if (!this.take(t, n)) return this.wrote("hidden", r);
570
- let i = this.shown.getLength(), a = H(this.shown.getData(), t);
578
+ let i = this.shown.getLength(), a = U(this.shown.getData(), t);
571
579
  return a === "stale" ? {
572
580
  to: "none",
573
581
  before: i,
@@ -581,7 +589,7 @@ var Mn = class {
581
589
  replace(e) {
582
590
  if (this.aside) {
583
591
  let { index: t, changed: n } = this.aside.replaceBar(e);
584
- return t < 0 ? V : (n && this.onLiveChange({
592
+ return t < 0 ? H : (n && this.onLiveChange({
585
593
  kind: "bar",
586
594
  time: this.aside.getData()[t].time
587
595
  }), {
@@ -590,22 +598,22 @@ var Mn = class {
590
598
  changed: n
591
599
  });
592
600
  }
593
- if (!L(e)) return V;
594
- let t = this.inSeriesUnit(e), n = this.whole, r = n ? Dn(n, t.time) : -1;
601
+ if (!R(e)) return H;
602
+ let t = this.inSeriesUnit(e), n = this.whole, r = n ? Nn(n, t.time) : -1;
595
603
  if (n) {
596
- if (r < 0 || !L(n[r])) return V;
604
+ if (r < 0 || !R(n[r])) return H;
597
605
  let e = this.hoursFilter(n);
598
606
  if (e && !e(t.time)) return this.replaceHidden(n, r, t);
599
607
  }
600
608
  let { index: i, changed: a } = this.shown.replaceBar(t);
601
- return i < 0 ? V : (a && (n && (n[r] = this.shown.getData()[i]), this.shownRevision++), {
609
+ return i < 0 ? H : (a && (n && (n[r] = this.shown.getData()[i]), this.shownRevision++), {
602
610
  to: "shown",
603
611
  index: i,
604
612
  changed: a
605
613
  });
606
614
  }
607
615
  beginReplay() {
608
- this.aside || (this.aside = new B(), this.aside.setData(this.whole ?? this.shown.getData()));
616
+ this.aside || (this.aside = new V(), this.aside.setData(this.whole ?? this.shown.getData()));
609
617
  }
610
618
  endReplay() {
611
619
  let e = this.aside;
@@ -625,10 +633,10 @@ var Mn = class {
625
633
  this.shown.updateLastBar(e);
626
634
  }
627
635
  inSeriesUnit(e) {
628
- return An(this.whole ?? this.shown.getData(), e);
636
+ return In(this.whole ?? this.shown.getData(), e);
629
637
  }
630
638
  replaceHidden(e, t, n) {
631
- let r = R(n), i = !z(e[t], r);
639
+ let r = z(n), i = !B(e[t], r);
632
640
  return i && (e[t] = r), {
633
641
  to: "hidden",
634
642
  index: -1,
@@ -662,14 +670,14 @@ var Mn = class {
662
670
  return !r || r(e.time);
663
671
  }
664
672
  };
665
- function Nn(e, t) {
673
+ function zn(e, t) {
666
674
  let n = t[0]?.time, r = 0;
667
675
  for (; n !== void 0 && r < e.length && e[r].time < n;) r++;
668
676
  return r === 0 || r === e.length ? null : e.slice(0, r).concat(t);
669
677
  }
670
678
  //#endregion
671
679
  //#region src/HistoryPager.ts
672
- var Pn = 5e3, Fn = 6e4, In = 500, Ln = class {
680
+ var Bn = 5e3, Vn = 6e4, Hn = 500, Un = class {
673
681
  loader = null;
674
682
  pageSize = 500;
675
683
  loading = !1;
@@ -721,7 +729,7 @@ var Pn = 5e3, Fn = 6e4, In = 500, Ln = class {
721
729
  try {
722
730
  r = await e(t, this.pageSize);
723
731
  } catch (e) {
724
- return n === this.seq ? (this.loading = !1, this.failures++, this.retryAt = this.now() + Math.min(Fn, Pn * 2 ** (this.failures - 1)), this.emit({
732
+ return n === this.seq ? (this.loading = !1, this.failures++, this.retryAt = this.now() + Math.min(Vn, Bn * 2 ** (this.failures - 1)), this.emit({
725
733
  state: "error",
726
734
  count: 0,
727
735
  error: e instanceof Error ? e.message : String(e)
@@ -754,10 +762,10 @@ var Pn = 5e3, Fn = 6e4, In = 500, Ln = class {
754
762
  };
755
763
  //#endregion
756
764
  //#region src/ThemeManager.ts
757
- function Rn(e, t) {
765
+ function Wn(e, t) {
758
766
  return e.family === t.family && e.sizeSmall === t.sizeSmall && e.sizeMedium === t.sizeMedium && e.sizeLarge === t.sizeLarge;
759
767
  }
760
- var zn = class t {
768
+ var Gn = class t {
761
769
  base;
762
770
  shape = null;
763
771
  font = null;
@@ -776,13 +784,13 @@ var zn = class t {
776
784
  return i;
777
785
  }
778
786
  getTheme() {
779
- return this.effective ??= se(this.base, this.chartType, this.merged()), this.effective;
787
+ return this.effective ??= oe(this.base, this.chartType, this.merged()), this.effective;
780
788
  }
781
789
  getBaseTheme() {
782
790
  return this.base;
783
791
  }
784
792
  setTheme(e) {
785
- let n = t.read(e), r = this.font !== null && Rn(n.font, this.base.font);
793
+ let n = t.read(e), r = this.font !== null && Wn(n.font, this.base.font);
786
794
  this.base = n, r || (this.themeFont = n.font), this.shape && (this.base = {
787
795
  ...this.base,
788
796
  shape: {
@@ -864,7 +872,7 @@ var zn = class t {
864
872
  };
865
873
  //#endregion
866
874
  //#region src/style/styleOptions.ts
867
- function Bn(e, t) {
875
+ function Kn(e, t) {
868
876
  return t ? {
869
877
  ...t.visible === void 0 ? {} : { [`crosshair.${e}.visible`]: t.visible },
870
878
  ...t.color === void 0 ? {} : { [`crosshair.${e}.color`]: t.color },
@@ -872,28 +880,29 @@ function Bn(e, t) {
872
880
  ...t.width === void 0 ? {} : { [`crosshair.${e}.width`]: t.width }
873
881
  } : {};
874
882
  }
875
- function Vn(e) {
883
+ function qn(e) {
876
884
  let { grid: t, crosshair: n } = e, r = n?.vLine?.labelBackground ?? n?.hLine?.labelBackground;
877
885
  return {
878
886
  ...t?.hLineColor === void 0 ? {} : { "grid.horizontal.color": t.hLineColor },
879
887
  ...t?.hLineStyle === void 0 ? {} : { "grid.horizontal.style": t.hLineStyle },
880
888
  ...t?.vLineColor === void 0 ? {} : { "grid.vertical.color": t.vLineColor },
881
889
  ...t?.vLineStyle === void 0 ? {} : { "grid.vertical.style": t.vLineStyle },
882
- ...Bn("horizontal", n?.hLine),
883
- ...Bn("vertical", n?.vLine),
890
+ ...Kn("horizontal", n?.hLine),
891
+ ...Kn("vertical", n?.vLine),
884
892
  ...r === void 0 ? {} : { "crosshair.labelBackground": r },
885
893
  ...e.overrides
886
894
  };
887
895
  }
888
896
  //#endregion
889
897
  //#region src/layout/LayoutManager.ts
890
- var Hn = 200, Un = 80, U = (e) => e.position === "top" || e.position === "bottom", Wn = class {
898
+ var Jn = 200, Yn = 80, W = (e) => e.position === "top" || e.position === "bottom", Xn = class {
891
899
  panels = [];
892
900
  containerWidth = 0;
893
901
  containerHeight = 0;
894
902
  priceAxisWidth = o;
895
903
  leftAxisWidth = 0;
896
904
  maximized = null;
905
+ aside = /* @__PURE__ */ new Set();
897
906
  resize(e, t) {
898
907
  this.containerWidth = e, this.containerHeight = t;
899
908
  }
@@ -903,8 +912,8 @@ var Hn = 200, Un = 80, U = (e) => e.position === "top" || e.position === "bottom
903
912
  this.panels.push({
904
913
  id: e,
905
914
  position: n,
906
- size: r ?? (a ? Hn : t),
907
- minSize: a ? Un : i,
915
+ size: r ?? (a ? Jn : t),
916
+ minSize: a ? Yn : i,
908
917
  content: {
909
918
  type: "indicator",
910
919
  indicatorInstanceId: e
@@ -923,14 +932,14 @@ var Hn = 200, Un = 80, U = (e) => e.position === "top" || e.position === "bottom
923
932
  }
924
933
  setPanelCollapsed(e, t) {
925
934
  let n = this.panels.find((t) => t.id === e);
926
- return !n || !U(n) || this.maximized === null && !!n.collapsed === t ? !1 : (this.maximized = null, n.collapsed = t || void 0, !0);
935
+ return !n || !W(n) || this.maximized === null && !!n.collapsed === t ? !1 : (this.maximized = null, n.collapsed = t || void 0, !0);
927
936
  }
928
937
  isPanelCollapsed(e) {
929
938
  return !!this.panels.find((t) => t.id === e)?.collapsed;
930
939
  }
931
940
  isPanelShownCollapsed(e) {
932
941
  let t = this.panels.find((t) => t.id === e);
933
- return !t || !U(t) ? !1 : this.maximized === null ? !!t.collapsed : this.maximized !== e;
942
+ return !t || !W(t) ? !1 : this.maximized === null ? !!t.collapsed : this.maximized !== e;
934
943
  }
935
944
  setPanelScale(e, t) {
936
945
  let n = this.panels.find((t) => t.id === e);
@@ -946,7 +955,7 @@ var Hn = 200, Un = 80, U = (e) => e.position === "top" || e.position === "bottom
946
955
  }
947
956
  setMaximizedPanel(e) {
948
957
  let t = e === null ? null : this.panels.find((t) => t.id === e);
949
- return e !== null && (!t || !U(t)) || this.maximized === e ? !1 : (this.maximized = e, t && (t.collapsed = void 0), !0);
958
+ return e !== null && (!t || !W(t)) || this.maximized === e ? !1 : (this.maximized = e, t && (t.collapsed = void 0), !0);
950
959
  }
951
960
  getMaximizedPanel() {
952
961
  return this.maximized;
@@ -967,19 +976,19 @@ var Hn = 200, Un = 80, U = (e) => e.position === "top" || e.position === "bottom
967
976
  this.panels = [...this.panels].sort((e, n) => t(e) - t(n));
968
977
  }
969
978
  shownSize(e, t) {
970
- return U(e) ? this.maximized ? e.id === this.maximized ? t : 20 : e.collapsed ? 20 : e.size : e.size;
979
+ return W(e) ? this.maximized ? e.id === this.maximized ? t : 20 : e.collapsed ? 20 : e.size : e.size;
971
980
  }
972
981
  setPanelPosition(e, n) {
973
982
  let r = this.panels.find((t) => t.id === e);
974
983
  if (r) {
975
984
  let a = r.position === "left" || r.position === "right", o = n === "left" || n === "right";
976
- r.position = n, a !== o && (r.size = o ? Hn : t, r.minSize = o ? Un : i), o && (r.collapsed = void 0, this.maximized === e && (this.maximized = null));
985
+ r.position = n, a !== o && (r.size = o ? Jn : t, r.minSize = o ? Yn : i), o && (r.collapsed = void 0, this.maximized === e && (this.maximized = null));
977
986
  }
978
987
  }
979
988
  setPanelSize(e, t) {
980
989
  let n = this.panels.find((t) => t.id === e);
981
990
  if (n) {
982
- let e = U(n) ? this.containerHeight - s - 48 : this.containerWidth / 2, r = e > n.minSize ? Math.min(t, e) : t;
991
+ let e = W(n) ? this.containerHeight - s - 48 : this.containerWidth / 2, r = e > n.minSize ? Math.min(t, e) : t;
983
992
  n.size = Math.max(n.minSize, r), n.collapsed = void 0, this.maximized = null;
984
993
  }
985
994
  }
@@ -992,105 +1001,109 @@ var Hn = 200, Un = 80, U = (e) => e.position === "top" || e.position === "bottom
992
1001
  getPanels() {
993
1002
  return this.panels;
994
1003
  }
1004
+ setPanelsAside(e) {
1005
+ let t = e.size !== this.aside.size || [...e].some((e) => !this.aside.has(e));
1006
+ return this.aside = new Set(e), t;
1007
+ }
995
1008
  resolve() {
996
- let e = this.panels.filter((e) => e.position === "left"), t = this.panels.filter((e) => e.position === "right"), n = this.panels.filter((e) => e.position === "top"), r = this.panels.filter((e) => e.position === "bottom"), i = (n.length + r.length - 1) * 20, a = this.maximized ? this.panels.find((e) => e.id === this.maximized) : void 0, o = Math.max(a?.minSize ?? 0, this.containerHeight - s - 48 - i), c = (e) => this.shownSize(e, o), l = e.reduce((e, t) => e + t.size, 0), u = t.reduce((e, t) => e + t.size, 0), d = n.reduce((e, t) => e + c(t), 0), f = r.reduce((e, t) => e + c(t), 0), p = l + this.leftAxisWidth, m = {
997
- x: p,
998
- y: d,
999
- width: Math.max(0, this.containerWidth - p - u - this.priceAxisWidth),
1000
- height: Math.max(0, this.containerHeight - d - f - s)
1001
- }, h = [], g = [], _ = 0;
1002
- for (let t of e) h.push({
1003
- config: t,
1009
+ let e = this.panels.filter((e) => !this.aside.has(e.id)), t = e.filter((e) => e.position === "left"), n = e.filter((e) => e.position === "right"), r = e.filter((e) => e.position === "top"), i = e.filter((e) => e.position === "bottom"), a = (r.length + i.length - 1) * 20, o = this.maximized ? e.find((e) => e.id === this.maximized) : void 0, c = Math.max(o?.minSize ?? 0, this.containerHeight - s - 48 - a), l = (e) => this.shownSize(e, c), u = t.reduce((e, t) => e + t.size, 0), d = n.reduce((e, t) => e + t.size, 0), f = r.reduce((e, t) => e + l(t), 0), p = i.reduce((e, t) => e + l(t), 0), m = u + this.leftAxisWidth, h = {
1010
+ x: m,
1011
+ y: f,
1012
+ width: Math.max(0, this.containerWidth - m - d - this.priceAxisWidth),
1013
+ height: Math.max(0, this.containerHeight - f - p - s)
1014
+ }, g = [], _ = [], v = 0;
1015
+ for (let e of t) g.push({
1016
+ config: e,
1004
1017
  rect: {
1005
- x: _,
1018
+ x: v,
1006
1019
  y: 0,
1007
- width: t.size,
1020
+ width: e.size,
1008
1021
  height: this.containerHeight - s
1009
1022
  }
1010
- }), g.push({
1011
- panelId: t.id,
1023
+ }), _.push({
1024
+ panelId: e.id,
1012
1025
  rect: {
1013
- x: _ + t.size - 2,
1026
+ x: v + e.size - 2,
1014
1027
  y: 0,
1015
1028
  width: 4,
1016
1029
  height: this.containerHeight
1017
1030
  },
1018
1031
  orientation: "vertical"
1019
- }), _ += t.size;
1020
- let v = 0;
1021
- for (let e of n) {
1022
- let t = c(e);
1023
- h.push({
1032
+ }), v += e.size;
1033
+ let y = 0;
1034
+ for (let e of r) {
1035
+ let t = l(e);
1036
+ g.push({
1024
1037
  config: e,
1025
1038
  rect: {
1026
- x: p,
1027
- y: v,
1028
- width: m.width,
1039
+ x: m,
1040
+ y,
1041
+ width: h.width,
1029
1042
  height: t
1030
1043
  }
1031
- }), g.push({
1044
+ }), _.push({
1032
1045
  panelId: e.id,
1033
1046
  rect: {
1034
- x: p,
1035
- y: v + t - 2,
1036
- width: m.width,
1047
+ x: m,
1048
+ y: y + t - 2,
1049
+ width: h.width,
1037
1050
  height: 4
1038
1051
  },
1039
1052
  orientation: "horizontal"
1040
- }), v += t;
1053
+ }), y += t;
1041
1054
  }
1042
- v = m.y + m.height;
1043
- for (let e of r) {
1044
- let t = c(e);
1045
- h.push({
1055
+ y = h.y + h.height;
1056
+ for (let e of i) {
1057
+ let t = l(e);
1058
+ g.push({
1046
1059
  config: e,
1047
1060
  rect: {
1048
- x: p,
1049
- y: v,
1050
- width: m.width,
1061
+ x: m,
1062
+ y,
1063
+ width: h.width,
1051
1064
  height: t
1052
1065
  }
1053
- }), g.push({
1066
+ }), _.push({
1054
1067
  panelId: e.id,
1055
1068
  rect: {
1056
- x: p,
1057
- y: v - 2,
1058
- width: m.width,
1069
+ x: m,
1070
+ y: y - 2,
1071
+ width: h.width,
1059
1072
  height: 4
1060
1073
  },
1061
1074
  orientation: "horizontal"
1062
- }), v += t;
1075
+ }), y += t;
1063
1076
  }
1064
- _ = p + m.width + this.priceAxisWidth;
1065
- for (let e of t) h.push({
1077
+ v = m + h.width + this.priceAxisWidth;
1078
+ for (let e of n) g.push({
1066
1079
  config: e,
1067
1080
  rect: {
1068
- x: _,
1081
+ x: v,
1069
1082
  y: 0,
1070
1083
  width: e.size,
1071
1084
  height: this.containerHeight - s
1072
1085
  }
1073
- }), g.push({
1086
+ }), _.push({
1074
1087
  panelId: e.id,
1075
1088
  rect: {
1076
- x: _ - 2,
1089
+ x: v - 2,
1077
1090
  y: 0,
1078
1091
  width: 4,
1079
1092
  height: this.containerHeight
1080
1093
  },
1081
1094
  orientation: "vertical"
1082
- }), _ += e.size;
1095
+ }), v += e.size;
1083
1096
  return {
1084
- mainChartRect: m,
1085
- panels: h,
1086
- dividers: g
1097
+ mainChartRect: h,
1098
+ panels: g,
1099
+ dividers: _
1087
1100
  };
1088
1101
  }
1089
1102
  getMainChartRect() {
1090
1103
  return this.resolve().mainChartRect;
1091
1104
  }
1092
- }, Gn = 14, Kn = 14, qn = 22, Jn = 4;
1093
- function Yn(e) {
1105
+ }, Zn = 14, Qn = 14, $n = 22, er = 4;
1106
+ function tr(e) {
1094
1107
  let { min: t, max: n, lastPrice: r, locale: i, fontFamily: a, fontSizeSmall: s, measure: l } = e, u = e.tagPrecision ?? c(t, n), d = u, f = r === null ? [t, n] : [
1095
1108
  t,
1096
1109
  n,
@@ -1099,16 +1112,16 @@ function Yn(e) {
1099
1112
  for (let t of f) {
1100
1113
  if (!Number.isFinite(t)) continue;
1101
1114
  let n = e.scaleLabel ? e.scaleLabel(t) : e.format ? e.format(t) : h(t, u, i), r = e.format ? n : h(t, d, i);
1102
- p = Math.max(p, l(n, `500 ${s}px ${a}`) + Gn, l(r, `bold 11px ${a}`) + Kn, l(r, `600 ${s}px ${a}`) + qn);
1115
+ p = Math.max(p, l(n, `500 ${s}px ${a}`) + Zn, l(r, `bold 11px ${a}`) + Qn, l(r, `600 ${s}px ${a}`) + $n);
1103
1116
  }
1104
- return p <= o ? o : Math.ceil(p / Jn) * Jn;
1117
+ return p <= o ? o : Math.ceil(p / er) * er;
1105
1118
  }
1106
- function Xn(e, t) {
1119
+ function nr(e, t) {
1107
1120
  return t > e || t <= e - 12 ? t : e;
1108
1121
  }
1109
1122
  //#endregion
1110
1123
  //#region src/layout/labelWidths.ts
1111
- var Zn = 512, Qn = class {
1124
+ var rr = 512, ir = class {
1112
1125
  widths = /* @__PURE__ */ new Map();
1113
1126
  fonts;
1114
1127
  forget = () => this.widths.clear();
@@ -1119,12 +1132,12 @@ var Zn = 512, Qn = class {
1119
1132
  let r = `${t}\n${e}`, i = this.widths.get(r);
1120
1133
  if (i !== void 0) return i;
1121
1134
  let a = n();
1122
- return this.widths.size >= Zn && this.widths.clear(), this.widths.set(r, a), a;
1135
+ return this.widths.size >= rr && this.widths.clear(), this.widths.set(r, a), a;
1123
1136
  }
1124
1137
  destroy() {
1125
1138
  this.fonts?.removeEventListener("loadingdone", this.forget), this.widths.clear();
1126
1139
  }
1127
- }, $n = class {
1140
+ }, ar = class {
1128
1141
  netY = 0;
1129
1142
  travelX = 0;
1130
1143
  engaged = !1;
@@ -1140,11 +1153,11 @@ var Zn = 512, Qn = class {
1140
1153
  }
1141
1154
  return this.engaged;
1142
1155
  }
1143
- }, er = 1;
1144
- function tr(e, t) {
1156
+ }, or = 1;
1157
+ function sr(e, t) {
1145
1158
  return e.filter((e) => e.enabled !== !1 && (e.descriptor.layer ?? "overlay") === t);
1146
1159
  }
1147
- function W(e) {
1160
+ function G(e) {
1148
1161
  switch (e.kind) {
1149
1162
  case "indicator": return `indicator:${e.plugin.descriptor.id}`;
1150
1163
  case "drawing": return `drawing:${e.plugin.descriptor.type}`;
@@ -1154,25 +1167,25 @@ function W(e) {
1154
1167
  }
1155
1168
  //#endregion
1156
1169
  //#region src/plugins/registry.ts
1157
- var G = /* @__PURE__ */ new Map();
1158
- function nr(e) {
1159
- G.set(W(e), e);
1170
+ var K = /* @__PURE__ */ new Map();
1171
+ function cr(e) {
1172
+ K.set(G(e), e);
1160
1173
  }
1161
- function rr(e) {
1162
- return G.delete(e);
1174
+ function lr(e) {
1175
+ return K.delete(e);
1163
1176
  }
1164
- function ir() {
1165
- return [...G.values()];
1177
+ function ur() {
1178
+ return [...K.values()];
1166
1179
  }
1167
- function ar() {
1168
- G.clear();
1180
+ function dr() {
1181
+ K.clear();
1169
1182
  }
1170
1183
  //#endregion
1171
1184
  //#region src/plugins/PluginManager.ts
1172
- var or = class {
1185
+ var fr = class {
1173
1186
  plugins = /* @__PURE__ */ new Map();
1174
1187
  constructor(e, t = {}) {
1175
- if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of ir()) this.add(e);
1188
+ if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of ur()) this.add(e);
1176
1189
  for (let e of t.plugins ?? []) this.add(e);
1177
1190
  }
1178
1191
  register(e) {
@@ -1200,17 +1213,17 @@ var or = class {
1200
1213
  return e;
1201
1214
  }
1202
1215
  add(e) {
1203
- this.plugins.set(W(e), e), e.kind === "indicator" && this.indicatorEngine.register(e.plugin);
1216
+ this.plugins.set(G(e), e), e.kind === "indicator" && this.indicatorEngine.register(e.plugin);
1204
1217
  }
1205
- }, sr = {
1218
+ }, pr = {
1206
1219
  orderPlace: (e, t) => e.placeOrder(t),
1207
1220
  orderModify: (e, t) => e.modifyOrder(t),
1208
1221
  orderCancel: (e, t) => e.cancelOrder(t),
1209
1222
  positionModify: (e, t) => e.modifyPosition(t),
1210
1223
  positionClose: (e, t) => e.closePosition(t),
1211
- positionReverse: (e, t, n) => cr(e, t, n)
1224
+ positionReverse: (e, t, n) => mr(e, t, n)
1212
1225
  };
1213
- async function cr(e, t, n) {
1226
+ async function mr(e, t, n) {
1214
1227
  let { reversing: r } = n;
1215
1228
  if (!r.has(t.positionId)) {
1216
1229
  r.add(t.positionId);
@@ -1239,7 +1252,7 @@ async function cr(e, t, n) {
1239
1252
  }
1240
1253
  }
1241
1254
  }
1242
- function lr(e, t) {
1255
+ function hr(e, t) {
1243
1256
  let n = [], r = null, i = {
1244
1257
  positions: () => r ?? t.getPositions?.() ?? [],
1245
1258
  reversing: /* @__PURE__ */ new Set()
@@ -1249,8 +1262,8 @@ function lr(e, t) {
1249
1262
  e.data && t.onFill?.(e.data);
1250
1263
  };
1251
1264
  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));
1252
- for (let r of Object.keys(sr)) {
1253
- let a = sr[r], o = t.onIntent(r, (n) => {
1265
+ for (let r of Object.keys(pr)) {
1266
+ let a = pr[r], o = t.onIntent(r, (n) => {
1254
1267
  Promise.resolve(a(e, n, i)).catch((e) => t.onError({
1255
1268
  message: `Execution command failed: ${r}`,
1256
1269
  cause: e
@@ -1264,7 +1277,7 @@ function lr(e, t) {
1264
1277
  }
1265
1278
  //#endregion
1266
1279
  //#region src/replay/ReplayStepLoader.ts
1267
- var ur = 1e3, dr = class {
1280
+ var gr = 1e3, _r = class {
1268
1281
  pieces = /* @__PURE__ */ new Map();
1269
1282
  asked = /* @__PURE__ */ new Set();
1270
1283
  inFlight = !1;
@@ -1297,7 +1310,7 @@ var ur = 1e3, dr = class {
1297
1310
  this.done = !0;
1298
1311
  }
1299
1312
  ask(e, t) {
1300
- let { ratio: n, barMs: r, step: i, report: a } = this.options, o = Math.max(1, Math.floor(ur / n)), s = Math.min(e.length, t + o), c = s < e.length ? e[s].time : e[e.length - 1].time + r, l = e.slice(t, s);
1313
+ let { ratio: n, barMs: r, step: i, report: a } = this.options, o = Math.max(1, Math.floor(gr / n)), s = Math.min(e.length, t + o), c = s < e.length ? e[s].time : e[e.length - 1].time + r, l = e.slice(t, s);
1301
1314
  for (let e of l) this.asked.add(e.time);
1302
1315
  this.inFlight = !0, a({
1303
1316
  state: "loading",
@@ -1338,12 +1351,12 @@ var ur = 1e3, dr = class {
1338
1351
  ...n === void 0 ? {} : { error: n }
1339
1352
  });
1340
1353
  }
1341
- }, fr = 1 / 3, pr = .25, mr = .5;
1342
- function hr(e, t) {
1343
- let n = (e.high - e.low) * pr;
1344
- return t.filter((t) => t.close > e.high + n || t.close < e.low - n).length <= t.length * mr;
1354
+ }, vr = 1 / 3, yr = .25, br = .5;
1355
+ function xr(e, t) {
1356
+ let n = (e.high - e.low) * yr;
1357
+ return t.filter((t) => t.close > e.high + n || t.close < e.low - n).length <= t.length * br;
1345
1358
  }
1346
- function gr(e) {
1359
+ function Sr(e) {
1347
1360
  return e.close >= e.open ? [
1348
1361
  e.open,
1349
1362
  e.low,
@@ -1356,22 +1369,22 @@ function gr(e) {
1356
1369
  e.close
1357
1370
  ];
1358
1371
  }
1359
- function _r(e, t, n) {
1360
- let r = gr(e), i = [
1372
+ function Cr(e, t, n) {
1373
+ let r = Sr(e), i = [
1361
1374
  1,
1362
1375
  2,
1363
1376
  3
1364
1377
  ].map((e) => Math.abs(r[e] - r[e - 1])), a = i[0] + i[1] + i[2], o = [], s = 0;
1365
1378
  return r.forEach((r, c) => {
1366
- c > 0 && (s += a > 0 ? i[c - 1] / a : fr), !(c === 0 && t > 0) && o.push({
1379
+ c > 0 && (s += a > 0 ? i[c - 1] / a : vr), !(c === 0 && t > 0) && o.push({
1367
1380
  price: r,
1368
1381
  time: e.time,
1369
1382
  at: (t + s) / n
1370
1383
  });
1371
1384
  }), o;
1372
1385
  }
1373
- function vr(e, t = []) {
1374
- let n = t.length > 0 && hr(e, t) ? t : [e], r = n.length, i = yr(n.flatMap((e, t) => _r(e, t, r)), e), a = n.reduce((e, t) => e + (t.volume ?? 0), 0), o = 0;
1386
+ function wr(e, t = []) {
1387
+ let n = t.length > 0 && xr(e, t) ? t : [e], r = n.length, i = Tr(n.flatMap((e, t) => Cr(e, t, r)), e), a = n.reduce((e, t) => e + (t.volume ?? 0), 0), o = 0;
1375
1388
  return {
1376
1389
  bar: e,
1377
1390
  points: i,
@@ -1381,7 +1394,7 @@ function vr(e, t = []) {
1381
1394
  }))
1382
1395
  };
1383
1396
  }
1384
- function yr(e, t) {
1397
+ function Tr(e, t) {
1385
1398
  let n = e.length - 1, r = e.map((e, r) => ({
1386
1399
  ...e,
1387
1400
  price: r === 0 ? t.open : r === n ? t.close : Math.min(t.high, Math.max(t.low, e.price))
@@ -1396,7 +1409,7 @@ function yr(e, t) {
1396
1409
  };
1397
1410
  return i(t.high, (e, t) => e > t), i(t.low, (e, t) => e < t), r;
1398
1411
  }
1399
- function br(e, t) {
1412
+ function Er(e, t) {
1400
1413
  let n = e.points;
1401
1414
  if (t <= n[0].at) return n[0].price;
1402
1415
  for (let e = 1; e < n.length; e++) if (t <= n[e].at) {
@@ -1405,8 +1418,8 @@ function br(e, t) {
1405
1418
  }
1406
1419
  return n[n.length - 1].price;
1407
1420
  }
1408
- var xr = (e) => Number.isFinite(e) ? Math.min(1, Math.max(0, e)) : 0;
1409
- function Sr(e, t) {
1421
+ var Dr = (e) => Number.isFinite(e) ? Math.min(1, Math.max(0, e)) : 0;
1422
+ function Or(e, t) {
1410
1423
  let n = 0, r = 0;
1411
1424
  for (let i of e.volumeAt) {
1412
1425
  if (t >= i.at) {
@@ -1417,10 +1430,10 @@ function Sr(e, t) {
1417
1430
  }
1418
1431
  return n;
1419
1432
  }
1420
- function Cr(e, t) {
1421
- let n = xr(t);
1433
+ function kr(e, t) {
1434
+ let n = Dr(t);
1422
1435
  if (n >= 1) return { ...e.bar };
1423
- let r = br(e, n), i = Math.max(e.points[0].price, r), a = Math.min(e.points[0].price, r);
1436
+ let r = Er(e, n), i = Math.max(e.points[0].price, r), a = Math.min(e.points[0].price, r);
1424
1437
  for (let t of e.points) {
1425
1438
  if (t.at > n) break;
1426
1439
  i = Math.max(i, t.price), a = Math.min(a, t.price);
@@ -1431,29 +1444,29 @@ function Cr(e, t) {
1431
1444
  high: i,
1432
1445
  low: a,
1433
1446
  close: r,
1434
- volume: Sr(e, n)
1447
+ volume: Or(e, n)
1435
1448
  };
1436
1449
  }
1437
- function wr(e, t) {
1438
- let n = xr(t), r = 0;
1450
+ function Ar(e, t) {
1451
+ let n = Dr(t), r = 0;
1439
1452
  for (let t of e.points) {
1440
1453
  if (t.at > n) break;
1441
1454
  r = t.at;
1442
1455
  }
1443
1456
  return r;
1444
1457
  }
1445
- function K(e, t, n) {
1458
+ function q(e, t, n) {
1446
1459
  let r = [], i = e.bar.time;
1447
1460
  for (let a of e.points) {
1448
1461
  if (a.at > n) break;
1449
1462
  i = a.time, a.at > t && r.push([a.price, a.time]);
1450
1463
  }
1451
- let a = br(e, n);
1464
+ let a = Er(e, n);
1452
1465
  return (r.length === 0 || r[r.length - 1][0] !== a) && r.push([a, i]), r;
1453
1466
  }
1454
1467
  //#endregion
1455
1468
  //#region src/replay/replayStep.ts
1456
- var Tr = [
1469
+ var jr = [
1457
1470
  "1m",
1458
1471
  "3m",
1459
1472
  "5m",
@@ -1464,42 +1477,42 @@ var Tr = [
1464
1477
  "4h",
1465
1478
  "1d"
1466
1479
  ];
1467
- function Er(e, t) {
1468
- let n = w(e);
1469
- return n > 0 ? Tr.filter((e) => {
1470
- let r = w(e);
1480
+ function Mr(e, t) {
1481
+ let n = T(e);
1482
+ return n > 0 ? jr.filter((e) => {
1483
+ let r = T(e);
1471
1484
  return r < n && n % r === 0 && t(e);
1472
1485
  }) : [];
1473
1486
  }
1474
- function Dr(e, t, n) {
1475
- let r = Er(t, n);
1487
+ function Nr(e, t, n) {
1488
+ let r = Mr(t, n);
1476
1489
  if (e !== "auto") return r.includes(e) ? e : null;
1477
- let i = w(t);
1478
- return r.find((e) => i / w(e) <= 60) ?? null;
1490
+ let i = T(t);
1491
+ return r.find((e) => i / T(e) <= 60) ?? null;
1479
1492
  }
1480
1493
  //#endregion
1481
1494
  //#region src/Chart.ts
1482
- var Or = {
1495
+ var Pr = {
1483
1496
  min: 0,
1484
1497
  max: 100
1485
- }, kr = "exchange", Ar = kr;
1486
- function jr(e) {
1498
+ }, Fr = "exchange", Ir = Fr;
1499
+ function Lr(e) {
1487
1500
  if (typeof e == "string" && e !== "exchange" && !v(e)) throw RangeError(`Unknown time zone: ${e}`);
1488
1501
  if (typeof e == "number" && !Number.isFinite(e)) throw RangeError(`Invalid UTC offset: ${e}`);
1489
1502
  }
1490
- function Mr(e, t) {
1491
- let { timeZone: n, timezone: r } = e, i = n !== void 0 && r !== void 0 && n !== r && n === t ? r : C(e);
1503
+ function Rr(e, t) {
1504
+ let { timeZone: n, timezone: r } = e, i = n !== void 0 && r !== void 0 && n !== r && n === t ? r : w(e);
1492
1505
  return i === void 0 ? e : {
1493
1506
  ...e,
1494
1507
  timeZone: i,
1495
1508
  timezone: i
1496
1509
  };
1497
1510
  }
1498
- var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontalLine", "crossLine"]), zr = new Set(["verticalLine", "crossLine"]), Br = class {
1499
- static version = "1.53.0";
1511
+ var zr = .08, Br = a ** -7, Vr = 800, Hr = 20, Ur = 8, Wr = new Set(["horizontalLine", "crossLine"]), Gr = new Set(["verticalLine", "crossLine"]), Kr = class {
1512
+ static version = "1.54.0";
1500
1513
  engine;
1501
1514
  viewport;
1502
- series = new Mn((e) => this.sessionKeep(e), (e) => this.followLiveChange(e));
1515
+ series = new Rn((e) => this.sessionKeep(e), (e) => this.followLiveChange(e));
1503
1516
  themeManager;
1504
1517
  layoutManager;
1505
1518
  pluginManager;
@@ -1514,6 +1527,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
1514
1527
  execTeardown = null;
1515
1528
  autoScrollOnNewBar = !0;
1516
1529
  displayDataCache = null;
1530
+ indicatorsOnDrawn = null;
1517
1531
  reshapeMemo = new ot();
1518
1532
  displayDataStep;
1519
1533
  indicatorUpdateFrom = null;
@@ -1525,13 +1539,14 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
1525
1539
  renderDeferred = !1;
1526
1540
  priceAxisWidth = o;
1527
1541
  measureCtx;
1528
- labelWidths = new Qn();
1542
+ labelWidths = new ir();
1529
1543
  containerSizeCache = null;
1530
1544
  containerSizeCacheTime = 0;
1531
1545
  lastEmittedRange = null;
1532
1546
  lastEmittedPriceRange = null;
1533
1547
  lastEmittedBarWidth = null;
1534
1548
  chartLegend;
1549
+ legendStack = null;
1535
1550
  watermark;
1536
1551
  barCountdown;
1537
1552
  unrestoredIndicators = [];
@@ -1584,7 +1599,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
1584
1599
  replayForming = null;
1585
1600
  replayPhaseUnsub = null;
1586
1601
  undoRedoManager;
1587
- autoSaveScheduler = new Tn((e) => this.saveState(e));
1602
+ autoSaveScheduler = new jn((e) => this.saveState(e));
1588
1603
  animator;
1589
1604
  crosshairTooltip;
1590
1605
  pinnedTooltip;
@@ -1636,7 +1651,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
1636
1651
  snapshotKey = null;
1637
1652
  historyCheckQueued = !1;
1638
1653
  constructor(e, t) {
1639
- t.timeZone != null && jr(t.timeZone), this.container = e, this.options = {
1654
+ t.timeZone != null && Lr(t.timeZone), this.container = e, this.options = {
1640
1655
  ...t,
1641
1656
  chartType: t.chartType ?? "candlestick"
1642
1657
  }, this.numberLocale = t.numberLocale ?? "en-US", this.defaultAutoScale = t.autoScale !== !1;
@@ -1674,11 +1689,11 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
1674
1689
  logScale: n.logScale ?? !0,
1675
1690
  timeframes: n.timeframes ?? [],
1676
1691
  defaultTimeframeFavorites: n.defaultTimeframeFavorites ?? []
1677
- }, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", e.style.userSelect = "none", e.style.webkitUserSelect = "none", this.history = new Ln({
1692
+ }, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", e.style.userSelect = "none", e.style.webkitUserSelect = "none", this.history = new Un({
1678
1693
  oldestTime: () => (this.replaySession ? this.series.liveBars() : this.series.bars())[0]?.time ?? null,
1679
1694
  prepend: (e) => this.prependBars(e),
1680
1695
  emit: (e) => this.eventBus.emit("historyLoad", e)
1681
- }), this.themeManager = new zn(t.theme), this.themeManager.setChartType(this.options.chartType ?? "candlestick"), this.applyStyle(Vn(t), "host", !1), this.layoutManager = new Wn(), this.indicatorEngine = new ze(), this.pluginManager = new or(this.indicatorEngine, { plugins: t.plugins }), this.eventBus = new Pe(), zt(this.indicatorEngine), this.indicatorEngine.register(new Ce(this.symbolSeries)), this.indicatorEngine.register(new ft(this.symbolSeries)), this.indicatorEngine.register(new we(this.symbolSeries)), this.indicatorEngine.register(new Te(this.symbolSeries)), this.drawingManager = new je(), Rt(this.drawingManager), this.drawingRenderer = new Me(this.drawingManager), this.drawingManager.setRequestRender(() => {
1696
+ }), this.themeManager = new Gn(t.theme), this.themeManager.setChartType(this.options.chartType ?? "candlestick"), this.applyStyle(qn(t), "host", !1), this.layoutManager = new Xn(), this.indicatorEngine = new ze(), this.pluginManager = new fr(this.indicatorEngine, { plugins: t.plugins }), this.eventBus = new Pe(), Bt(this.indicatorEngine), this.indicatorEngine.register(new Se(this.symbolSeries)), this.indicatorEngine.register(new Ce(this.symbolSeries)), this.indicatorEngine.register(new ft(this.symbolSeries)), this.indicatorEngine.register(new we(this.symbolSeries)), this.indicatorEngine.register(new Te(this.symbolSeries)), this.drawingManager = new je(), zt(this.drawingManager), this.drawingRenderer = new Me(this.drawingManager), this.drawingRenderer.setKeepOut(() => this.legendKeepOut()), this.drawingManager.setRequestRender(() => {
1682
1697
  this.syncRenderContext(), this.engine.requestRender(r.Overlay), this.scheduleAutoSave();
1683
1698
  }), this.drawingManager.setEventCallback((e, t) => {
1684
1699
  this.followDrawingAlerts(e, t?.id), this.eventBus.emit(e, t), (e === "drawingCreate" || e === "drawingUpdate" || e === "drawingRemove") && this.announceStateChange();
@@ -1711,27 +1726,38 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
1711
1726
  this.viewport.resize(e.width, e.height), this.layoutManager.resize(e.width, e.height), this.updateViewportAndRender(t), this.eventBus.emit("resize", e);
1712
1727
  }, this.chartRenderer = this.createChartRenderer(this.options.chartType), this.gridRenderer = new Fe(), t.grid?.visible === !1 && this.gridRenderer.setVisible(!1), this.priceAxis = new $e(), this.priceAxis.setLocale(this.numberLocale), this.leftPriceAxis.setLocale(this.numberLocale), this.viewport.setNumberLocale(this.numberLocale), this.timeAxis = new gt(), this.timeAxis.setLocale(this.numberLocale), this.crosshairHandler = new Ee(), this.crosshairHandler.setLocale(this.numberLocale), this.applyTimeSpacing(), t.crosshair?.mode && this.crosshairHandler.setMode(t.crosshair.mode), this.crosshairHandler.setDataSource(() => this.crosshairSeries()), this.crosshairHandler.setCallback((e, t) => {
1713
1728
  if (e !== null && t) {
1714
- let n = this.crosshairSeries(), r = e >= 0 && e < n.length ? n[e] : void 0;
1715
- this.chartLegend.setHoverBar(r ?? null, e > 0 ? n[e - 1] ?? null : null);
1716
- let i = this.viewport.getState(), a = t.y >= i.chartRect.y && t.y <= i.chartRect.y + i.chartRect.height;
1717
- r && a && this.features.crosshairTooltip ? this.crosshairTooltip.show(t, r, this.themeManager.getTheme(), this.cachedContainerSize(), {
1718
- prevClose: e > 0 ? n[e - 1]?.close : void 0,
1719
- priceRange: i.priceRange,
1720
- plot: i.chartRect,
1721
- barStepMs: Dt(n),
1722
- timeUnit: u(n)
1723
- }) : this.crosshairTooltip.hide(), this.pinnedTooltip.isPinned() && this.pinnedTooltip.reposition(this.viewport.getState(), r ?? null, e, this.themeManager.getTheme()), this.eventBus.emit("crosshairMove", {
1729
+ let n = this.crosshairSeries(), i = e >= 0 && e < n.length ? n[e] : void 0, a = e > 0 ? n[e - 1]?.close : void 0, o = Dt(n), s = i ? o[e]?.time ?? i.time : void 0;
1730
+ this.chartLegend.setHoverBar(i ?? null, e > 0 ? n[e - 1] ?? null : null), this.features.legend && this.engine.requestRender(r.Hover);
1731
+ let c = this.viewport.getState(), l = t.y >= c.chartRect.y && t.y <= c.chartRect.y + c.chartRect.height;
1732
+ if (i && l && this.features.crosshairTooltip) {
1733
+ let e = s === i.time ? i : {
1734
+ ...i,
1735
+ time: s ?? i.time
1736
+ };
1737
+ this.crosshairTooltip.show(t, e, this.themeManager.getTheme(), this.cachedContainerSize(), {
1738
+ prevClose: a,
1739
+ priceRange: c.priceRange,
1740
+ plot: c.chartRect,
1741
+ barStepMs: Ot(o),
1742
+ timeUnit: u(o)
1743
+ });
1744
+ } else this.crosshairTooltip.hide();
1745
+ this.pinnedTooltip.isPinned() && this.pinnedTooltip.reposition(this.viewport.getState(), i ?? null, e, this.themeManager.getTheme()), this.eventBus.emit("crosshairMove", {
1724
1746
  point: t,
1725
- bar: r,
1726
- barIndex: e
1747
+ bar: i,
1748
+ barIndex: e,
1749
+ ...s === void 0 ? {} : { time: s },
1750
+ ...a === void 0 ? {} : { prevClose: a }
1727
1751
  });
1728
- } else this.crosshairTooltip.hide(), this.chartLegend.setHoverBar(null), this.eventBus.emit("crosshairLeave", {});
1729
- }), this.chartLegend = new xe(), this.chartLegend.setChartType(this.options.chartType), this.chartLegend.setLocale(this.numberLocale), this.watermark = new Tt(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new wt(), this.volumeProfile = new Ct(), this.marketProfile = new Ge(), this.depthHeatmap = new Ae(), this.periodLevels = new Ye(), this.pivotMarkers = new Ze(), this.barCountdown = new _e(), this.barCountdown.setVisible(this.features.barCountdown), this.sessionBreaks = new lt(), this.sessionShading = new ut(), this.compareRenderer = new Se(), t.sessionBreaks ? this.sessionBreaks.setConfig({
1752
+ } else this.crosshairTooltip.hide(), this.chartLegend.setHoverBar(null), this.features.legend && this.engine.requestRender(r.Hover), this.eventBus.emit("crosshairLeave", {});
1753
+ }), this.chartLegend = new be(), this.chartLegend.setChartType(this.options.chartType), this.chartLegend.setLocale(this.numberLocale), this.chartLegend.setResizeListener(() => {
1754
+ this.eventBus.emit("legendResize", { bottom: this.getLegendBottom() }), this.engine.requestRender();
1755
+ }), this.watermark = new Tt(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new wt(), this.volumeProfile = new Ct(), this.marketProfile = new Ge(), this.depthHeatmap = new Ae(), this.periodLevels = new Ye(), this.pivotMarkers = new Ze(), this.barCountdown = new ge(), this.barCountdown.setVisible(this.features.barCountdown), this.sessionBreaks = new lt(), this.sessionShading = new ut(), this.compareRenderer = new xe(), t.sessionBreaks ? this.sessionBreaks.setConfig({
1730
1756
  visible: t.sessionBreaks.visible ?? !0,
1731
1757
  color: t.sessionBreaks.color,
1732
1758
  lineStyle: t.sessionBreaks.lineStyle,
1733
1759
  lineWidth: t.sessionBreaks.lineWidth
1734
- }) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new me(), this.crosshairTooltip = new De(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new Xe(), this.pinnedTooltip.create(e), this.pinnedTooltip.setLocale(this.numberLocale), t.priceFormat && this.applyPriceFormat(t.priceFormat), t.chartTypeOptions && (this.chartTypeOptions = x(t.chartTypeOptions)), t.highLowLines && this.priceLines.setHighLow(!0), t.shapes && this.themeManager.setShape(Kr(t.shapes)), t.font && this.themeManager.setFont(Gr(t.font)), this.priceLines.setPriceText((e) => this.formatPrice(e)), t.extendedHours === !1 && (this.extendedHours = !1), t.timeFormatter && this.applyTimeFormatter(t.timeFormatter), this.keyboardHandler = new He({
1760
+ }) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new pe(), this.crosshairTooltip = new De(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new Xe(), this.pinnedTooltip.create(e), this.pinnedTooltip.setLocale(this.numberLocale), t.priceFormat && this.applyPriceFormat(t.priceFormat), t.chartTypeOptions && (this.chartTypeOptions = S(t.chartTypeOptions)), t.highLowLines && this.priceLines.setHighLow(!0), t.shapes && this.themeManager.setShape(Qr(t.shapes)), t.font && this.themeManager.setFont(Zr(t.font)), this.priceLines.setPriceText((e) => this.formatPrice(e)), t.extendedHours === !1 && (this.extendedHours = !1), t.timeFormatter && this.applyTimeFormatter(t.timeFormatter), this.keyboardHandler = new He({
1735
1761
  scrollBars: (e) => {
1736
1762
  let t = this.viewport.getState().barWidth + this.viewport.getState().barSpacing;
1737
1763
  this.viewport.scrollBy(e * t), this.updateViewportAndRender();
@@ -1748,7 +1774,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
1748
1774
  },
1749
1775
  fitContent: () => this.fitContent()
1750
1776
  }), this.keyboardHandler.setEnabled(this.features.keyboard), t.a11y !== !1) {
1751
- this.a11y = new nn(e, {
1777
+ this.a11y = new an(e, {
1752
1778
  symbol: () => this.currentSymbol || this.symbolInfo?.symbol || "",
1753
1779
  timeframe: () => this.streamTimeframe ?? "",
1754
1780
  chartType: () => this.options.chartType ?? "candlestick",
@@ -1775,8 +1801,8 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
1775
1801
  }
1776
1802
  this.keyboardHandler.handleKey(e) && (e.preventDefault(), this.a11y?.viewMoved());
1777
1803
  }
1778
- }, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new Oe(), this.currentPriceLine.setLocale(this.numberLocale), this.priceAxis.setReservedPriceProvider(() => this.currentPriceLine.isVisible() ? this.currentPriceLine.getPrice() : null), this.alertManager = new pe(), this.alertManager.setDrawingLevels((e) => this.drawingLevelsNow(e)), this.alertManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.compareRenderer.setReservedLevels(() => this.alertManager.getAlerts().filter(At).map((e) => e.price)), this.alertManager.on("triggered", (e) => {
1779
- this.eventBus.emit("alertTriggered", q(e)), this.eventBus.emit("dataUpdate", {
1804
+ }, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new Oe(), this.currentPriceLine.setLocale(this.numberLocale), this.priceAxis.setReservedPriceProvider(() => this.currentPriceLine.isVisible() ? this.currentPriceLine.getPrice() : null), this.alertManager = new fe(), this.alertManager.setDrawingLevels((e) => this.drawingLevelsNow(e)), this.alertManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.compareRenderer.setReservedLevels(() => this.alertManager.getAlerts().filter(jt).map((e) => e.price)), this.alertManager.on("triggered", (e) => {
1805
+ this.eventBus.emit("alertTriggered", J(e)), this.eventBus.emit("dataUpdate", {
1780
1806
  kind: "alert",
1781
1807
  alert: "triggered",
1782
1808
  alertId: e.id,
@@ -1784,13 +1810,13 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
1784
1810
  message: e.message
1785
1811
  });
1786
1812
  }), this.alertManager.on("added", (e) => {
1787
- this.eventBus.emit("alertAdd", q(e));
1813
+ this.eventBus.emit("alertAdd", J(e));
1788
1814
  }), this.alertManager.on("removed", (e) => {
1789
1815
  this.eventBus.emit("alertRemove", { id: e });
1790
1816
  }), this.alertManager.on("expired", (e) => {
1791
- this.eventBus.emit("alertExpired", q(e));
1817
+ this.eventBus.emit("alertExpired", J(e));
1792
1818
  }), this.alertManager.on("updated", (e) => {
1793
- this.eventBus.emit("alertUpdate", q(e));
1819
+ this.eventBus.emit("alertUpdate", J(e));
1794
1820
  }), this.signalMarkerManager = new dt(), this.signalMarkerManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.signalMarkerManager.setDataGetter(() => this.series.bars()), this.signalMarkerManager.on("added", (e) => {
1795
1821
  this.eventBus.emit("signalMarkerAdd", {
1796
1822
  id: e.id,
@@ -1815,7 +1841,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
1815
1841
  }), this.replayManager.on("stateChange", (e) => {
1816
1842
  this.replayRestarting || this.eventBus.emit("replayState", { state: e });
1817
1843
  }), this.measureOverlay = new Ke(), this.interactionManager = new Be(e), this.features.panning) {
1818
- let e = new $n();
1844
+ let e = new ar();
1819
1845
  this.interactionManager.setPanHandler(new qe((t, n) => {
1820
1846
  t && this.viewport.scrollBy(t), e.step(t, n, this.options.autoScale !== !1) && n && (this.holdPriceScale(), this.viewport.panPriceRange(n)), this.updateViewportAndRender();
1821
1847
  }, () => e.reset()));
@@ -1831,7 +1857,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
1831
1857
  this.interactionManager.setZoomHandler(new Et((e, t) => {
1832
1858
  this.viewport.zoom(e, t - this.viewport.getState().chartRect.x), this.updateViewportAndRender();
1833
1859
  }));
1834
- let e = new ge((e) => {
1860
+ let e = new he((e) => {
1835
1861
  this.holdPriceScale(), this.viewport.scalePriceRange(e), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents();
1836
1862
  }, (e) => {
1837
1863
  let t = this.viewport.getState().chartRect.width;
@@ -1851,7 +1877,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
1851
1877
  y: t.y
1852
1878
  });
1853
1879
  })), 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) => {
1854
- let t = Jt(e.y, this.viewport.getState());
1880
+ let t = Xt(e.y, this.viewport.getState());
1855
1881
  Number.isFinite(t) && this.eventBus.emit("priceAxisAdd", {
1856
1882
  price: t,
1857
1883
  x: e.x,
@@ -1861,7 +1887,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
1861
1887
  ...this.viewport.getState(),
1862
1888
  data: this.getDisplayData()
1863
1889
  })), this.features.alerts) {
1864
- let e = new fe(this.alertManager, () => this.viewport.getState());
1890
+ let e = new de(this.alertManager, () => this.viewport.getState());
1865
1891
  this.interactionManager.setAlertDragHandler(e);
1866
1892
  }
1867
1893
  let o = new Je();
@@ -1888,7 +1914,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
1888
1914
  x: e.x,
1889
1915
  y: e.y
1890
1916
  }), t.length === 0) return;
1891
- let r = qt(e.x, this.viewport.getState());
1917
+ let r = Yt(e.x, this.viewport.getState());
1892
1918
  r < 0 || r >= t.length || this.eventBus.emit("barClick", {
1893
1919
  bar: t[r],
1894
1920
  barIndex: r,
@@ -1931,7 +1957,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
1931
1957
  end: () => {
1932
1958
  let e = this.selectionBoxOverlay.end();
1933
1959
  if (e && this.zoomAreaMode) {
1934
- if (e.x1 - e.x0 < Lr) return;
1960
+ if (e.x1 - e.x0 < Ur) return;
1935
1961
  this.zoomToBox(e), this.setZoomAreaMode(!1);
1936
1962
  return;
1937
1963
  }
@@ -1970,12 +1996,12 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
1970
1996
  let n = this.series.bars();
1971
1997
  this.seriesArriving = n.length === 0;
1972
1998
  let r = n[n.length - 1];
1973
- t || (this.alertManager.clearLastValues(), r && this.alertManager.seedLastValue("price", r.close)), this.recalcIndicators(n), r && this.currentPriceLine.setPrice(r.close), this.updateViewportAndRender(!0), this.emitBars(n.length);
1999
+ t || (this.alertManager.clearLastValues(), r && this.alertManager.seedLastValue("price", r.close)), this.recalcIndicators(n), r && this.currentPriceLine.setPrice(r.close), this.updateViewportAndRender(!0), this.fitFewColumns(), this.emitBars(n.length);
1974
2000
  }
1975
2001
  loadDuringReplay(e) {
1976
2002
  this.snapshotKey = null, this.history.reset(), this.alertManager.clearLastValues();
1977
2003
  let t = e[e.length - 1];
1978
- t && L(t) && this.alertManager.seedLastValue("price", t.close), this.replaySession && (this.replaySession.price = null), this.series.load(e);
2004
+ t && R(t) && this.alertManager.seedLastValue("price", t.close), this.replaySession && (this.replaySession.price = null), this.series.load(e);
1979
2005
  }
1980
2006
  prependBars(e) {
1981
2007
  if (this.replaySession) return this.series.prepend(e).taken;
@@ -2015,13 +2041,13 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2015
2041
  let { visibleRange: e, chartRect: t } = this.viewport.getState();
2016
2042
  if (t.width <= 0) return;
2017
2043
  let { from: n, to: r } = e;
2018
- this.history.maybeLoad(Math.max(0, Math.floor(n)), Math.max(Ir, r - n));
2044
+ this.history.maybeLoad(Math.max(0, Math.floor(n)), Math.max(Hr, r - n));
2019
2045
  }));
2020
2046
  }
2021
2047
  useStreamHistory(e, t, n = !0) {
2022
2048
  if (this.hostHistoryLoader) return;
2023
2049
  let r = N(e), i = r.fetchHistoryBefore, a = this.streamTimeframe;
2024
- if (!i || a === null || ue(a) !== null) {
2050
+ if (!i || a === null || le(a) !== null) {
2025
2051
  this.historyFromStream && this.history.setLoader(null), this.historyFromStream = !1;
2026
2052
  return;
2027
2053
  }
@@ -2029,7 +2055,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2029
2055
  this.history.setLoader((e, t) => i.call(r, o, a, e, t), t), this.historyFromStream = !0, n && this.checkHistory();
2030
2056
  }
2031
2057
  appendBar(e) {
2032
- if (!L(e)) return;
2058
+ if (!R(e)) return;
2033
2059
  let t = this.series.append(e);
2034
2060
  if (t.refiltered && (this.displayDataCache = null), t.to !== "shown") {
2035
2061
  this.takeLivePrice(e.close), t.to === "hidden" && this.scheduleRender();
@@ -2039,7 +2065,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2039
2065
  this.crosshairHandler.setData(i), this.displayDataCache = null, this.recalcIndicatorsFrom(i, i.length - 2), this.currentPriceLine.setPrice(e.close, i[i.length - 2]?.close), this.updateViewportAndRender(n), i.length !== r && this.emitBars(i.length), this.followLivePrice(e.close);
2040
2066
  }
2041
2067
  appendBars(e) {
2042
- if (e = e.filter(L), e.length === 0) return;
2068
+ if (e = e.filter(R), e.length === 0) return;
2043
2069
  let t = e[e.length - 1].close, n = this.series.appendMany(e);
2044
2070
  if (n.refiltered && (this.displayDataCache = null), n.shown === 0) {
2045
2071
  this.takeLivePrice(t), n.aside || this.scheduleRender();
@@ -2051,7 +2077,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2051
2077
  this.recalcIndicatorsFrom(a, i - 1), this.crosshairHandler.setData(a), this.currentPriceLine.setPrice(t, a[a.length - 2]?.close), this.updateViewportAndRender(r), a.length !== i && this.emitBars(a.length), this.followLivePrice(t);
2052
2078
  }
2053
2079
  updateLastBar(e) {
2054
- if (!L(e)) return;
2080
+ if (!R(e)) return;
2055
2081
  let t = this.series.updateLast(e);
2056
2082
  if (t.refiltered && (this.displayDataCache = null), t.to !== "shown") {
2057
2083
  this.takeLivePrice(e.close), t.to === "hidden" && this.scheduleRender();
@@ -2073,7 +2099,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2073
2099
  this.recalcIndicatorsFrom(n, n.length - 1), this.followLivePrice(e.price), this.scheduleRender();
2074
2100
  }
2075
2101
  updateBar(e) {
2076
- if (!L(e)) return !1;
2102
+ if (!R(e)) return !1;
2077
2103
  let t = this.series.replace(e);
2078
2104
  return t.to === "none" ? !1 : (t.to === "shown" && t.changed && this.showCorrection(t.index), !0);
2079
2105
  }
@@ -2100,11 +2126,17 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2100
2126
  }
2101
2127
  setChartType(e) {
2102
2128
  let t = this.options.chartType ?? "candlestick";
2103
- this.options.chartType = e, this.themeManager.setChartType(e), this.chartRenderer = this.createChartRenderer(e), this.chartLegend.setChartType(e), this.displayDataCache = null, this.applyTimeSpacing(), this.updateViewportAndRender(!0), this.markStateChanged(), e !== t && this.eventBus.emit("chartTypeChange", {
2129
+ this.options.chartType = e, this.themeManager.setChartType(e), this.chartRenderer = this.createChartRenderer(e), this.chartLegend.setChartType(e), this.displayDataCache = null, this.applyTimeSpacing(), this.updateViewportAndRender(!0), this.fitFewColumns(), this.markStateChanged(), e !== t && this.eventBus.emit("chartTypeChange", {
2104
2130
  type: e,
2105
2131
  previous: t
2106
2132
  });
2107
2133
  }
2134
+ fitFewColumns() {
2135
+ let e = this.options.chartType;
2136
+ if (!I(e) || this.pluginManager.getChartType(e)) return;
2137
+ let t = this.getDisplayData().length, { chartRect: n, barWidth: r, barSpacing: i } = this.viewport.getState(), a = n.width / (r + i);
2138
+ t > 0 && a > t + this.viewport.getRightMargin() && this.fitContent();
2139
+ }
2108
2140
  applyTimeSpacing() {
2109
2141
  let e = !this.tickStream && !I(this.options.chartType);
2110
2142
  this.timeAxis.setTimesPastData(e), this.crosshairHandler.setTimesPastData(e);
@@ -2112,11 +2144,11 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2112
2144
  setChartTypeOptions(e) {
2113
2145
  this.chartTypeOptions = {
2114
2146
  ...this.chartTypeOptions,
2115
- ...x(e)
2116
- }, this.displayDataCache = null, this.updateViewportAndRender(!0), this.a11y?.refresh(!0), this.markStateChanged();
2147
+ ...S(e)
2148
+ }, this.displayDataCache = null, this.updateViewportAndRender(!0), this.fitFewColumns(), this.a11y?.refresh(!0), this.markStateChanged();
2117
2149
  }
2118
2150
  getChartTypeOptions() {
2119
- return x(this.chartTypeOptions);
2151
+ return S(this.chartTypeOptions);
2120
2152
  }
2121
2153
  setExtendedHours(e) {
2122
2154
  e !== this.extendedHours && (this.extendedHours = e, this.reapplyExtendedHours(), this.markStateChanged());
@@ -2125,7 +2157,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2125
2157
  return this.extendedHours;
2126
2158
  }
2127
2159
  sessionKeep(e) {
2128
- return this.extendedHours ? null : Zt(this.symbolInfo, e);
2160
+ return this.extendedHours ? null : $t(this.symbolInfo, e);
2129
2161
  }
2130
2162
  reapplyExtendedHours() {
2131
2163
  if (!this.series.refilter()) return;
@@ -2136,7 +2168,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2136
2168
  return this.priceLines.setQuoteShown(this.replaySession === null), this.priceLines;
2137
2169
  }
2138
2170
  setShapes(e) {
2139
- let t = Kr(e);
2171
+ let t = Qr(e);
2140
2172
  t.tagRadius !== void 0 && (this.themeManager.setShape({
2141
2173
  ...this.themeManager.getTheme().shape,
2142
2174
  ...t
@@ -2148,7 +2180,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2148
2180
  setFont(e) {
2149
2181
  if (e === null) this.themeManager.setFont(null);
2150
2182
  else {
2151
- let t = Gr(e);
2183
+ let t = Zr(e);
2152
2184
  if (Object.keys(t).length === 0) return;
2153
2185
  this.themeManager.setFont(t);
2154
2186
  }
@@ -2186,7 +2218,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2186
2218
  }
2187
2219
  addIndicatorNow(e, t, n, r) {
2188
2220
  if (!this.isIndicatorAllowed(e)) return null;
2189
- let i = this.indicatorEngine.getAvailableIndicators().find((t) => t.id === e), a = i ? this.paneFor(i, t, r.pane) : null, o = this.indicatorEngine.addIndicator(e, t, this.series.bars(), {
2221
+ let i = this.indicatorEngine.getAvailableIndicators().find((t) => t.id === e), a = i ? this.paneFor(i, t, r.pane) : null, o = this.indicatorEngine.addIndicator(e, t, this.indicatorBars(), {
2190
2222
  ...a ? { pane: a } : {},
2191
2223
  ...r.scale === "left" ? { scale: "left" } : {},
2192
2224
  ...r.instanceId ? { instanceId: r.instanceId } : {}
@@ -2198,8 +2230,8 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2198
2230
  }
2199
2231
  setSymbolSeries(e, t) {
2200
2232
  e = e.trim(), this.symbolSeries.set(e, t), this.requestedSymbols.delete(e);
2201
- let n = this.series.bars(), r = !1;
2202
- for (let t of this.indicatorEngine.getActiveIndicators()) !O.has(t.id) || String(t.params.symbol ?? "").trim() !== e.trim() || (this.indicatorEngine.updateIndicator(t.instanceId, {}, n), r = !0);
2233
+ let n = this.indicatorBars(), r = !1;
2234
+ for (let t of this.indicatorEngine.getActiveIndicators()) !k.has(t.id) || String(t.params.symbol ?? "").trim() !== e.trim() || (this.indicatorEngine.updateIndicator(t.instanceId, {}, n), r = !0);
2203
2235
  r && (this.announceIndicatorUpdate(0), this.updateViewportAndRender());
2204
2236
  }
2205
2237
  forgetUnreadSymbols() {
@@ -2213,27 +2245,27 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2213
2245
  let e = /* @__PURE__ */ new Set();
2214
2246
  for (let t of this.indicatorEngine.getActiveIndicators()) {
2215
2247
  let n = t.params.symbol;
2216
- O.has(t.id) && typeof n == "string" && n.trim() && e.add(n.trim());
2248
+ k.has(t.id) && typeof n == "string" && n.trim() && e.add(n.trim());
2217
2249
  }
2218
2250
  return [...e];
2219
2251
  }
2220
2252
  requestMissingSymbols(e) {
2221
2253
  this.forgetUnreadSymbols();
2222
- let t = this.indicatorEngine.getIndicatorConfig(e), n = t && O.has(t.id) && typeof t.params.symbol == "string" ? t.params.symbol.trim() : "";
2254
+ let t = this.indicatorEngine.getIndicatorConfig(e), n = t && k.has(t.id) && typeof t.params.symbol == "string" ? t.params.symbol.trim() : "";
2223
2255
  !n || this.symbolSeries.has(n) || this.requestedSymbols.has(n) || (this.requestedSymbols.add(n), this.eventBus.emit("symbolSeriesRequest", { symbol: n }));
2224
2256
  }
2225
2257
  updateIndicator(e, t) {
2226
2258
  this.recordIndicators(e, () => this.updateIndicatorNow(e, t));
2227
2259
  }
2228
2260
  updateIndicatorNow(e, t) {
2229
- let n = this.indicatorEngine.getIndicatorDescriptor(e), r = n ? j(n) : null, i = r ? this.indicatorEngine.getIndicatorConfig(e)?.params[r] : void 0;
2230
- this.indicatorEngine.updateIndicator(e, t, this.series.bars()), this.announceIndicatorUpdate(0), this.markStateChanged(), this.eventBus.emit("indicatorChange", {
2261
+ let n = this.indicatorEngine.getIndicatorDescriptor(e), r = n ? Vt(n) : null, i = r ? this.indicatorEngine.getIndicatorConfig(e)?.params[r] : void 0;
2262
+ this.indicatorEngine.updateIndicator(e, t, this.indicatorBars()), this.announceIndicatorUpdate(0), this.markStateChanged(), this.eventBus.emit("indicatorChange", {
2231
2263
  instanceId: e,
2232
2264
  change: "params"
2233
2265
  }), this.requestMissingSymbols(e);
2234
2266
  let a = this.indicatorEngine.getIndicatorConfig(e);
2235
2267
  if (n?.placement === "overlay" && a && r && a.params[r] !== i) {
2236
- let t = b(a.params[r]), n = t ? this.paneHostOf(t.instanceId, e) : b(i) ? null : a.pane ?? null;
2268
+ let t = x(a.params[r]), n = t ? this.paneHostOf(t.instanceId, e) : x(i) ? null : a.pane ?? null;
2237
2269
  (n ?? void 0) !== a.pane && (this.indicatorEngine.setPane(e, n), this.eventBus.emit("indicatorChange", {
2238
2270
  instanceId: e,
2239
2271
  change: "pane"
@@ -2244,7 +2276,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2244
2276
  paneFor(e, t, n, r) {
2245
2277
  if (n) return this.paneHostOf(n, r);
2246
2278
  if (e.placement !== "overlay") return null;
2247
- let i = j(e), a = i ? b(t[i]) : null;
2279
+ let i = Vt(e), a = i ? x(t[i]) : null;
2248
2280
  return a ? this.paneHostOf(a.instanceId, r) : null;
2249
2281
  }
2250
2282
  paneHostOf(e, t) {
@@ -2290,8 +2322,8 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2290
2322
  return {
2291
2323
  ...e,
2292
2324
  priceRange: {
2293
- min: t.min - n * Nr,
2294
- max: t.max + n * Nr
2325
+ min: t.min - n * zr,
2326
+ max: t.max + n * zr
2295
2327
  },
2296
2328
  logScale: !1,
2297
2329
  scaleMode: "regular",
@@ -2344,7 +2376,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2344
2376
  this.indicatorEngine.setStyleDefaults(e, null);
2345
2377
  return;
2346
2378
  }
2347
- let { plots: n, ...r } = t, i = n === void 0 ? void 0 : ae(n);
2379
+ let { plots: n, ...r } = t, i = n === void 0 ? void 0 : ie(n);
2348
2380
  this.indicatorEngine.setStyleDefaults(e, {
2349
2381
  ...r,
2350
2382
  ...i ? { plots: i } : {}
@@ -2352,7 +2384,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2352
2384
  }
2353
2385
  setPaneStyle(e, t) {
2354
2386
  let n = this.paneOf(e);
2355
- this.layoutManager.getPanels().some((e) => e.id === n) && this.recordIndicators(n, () => this.setPaneStyleNow(n, t ? oe(t) : null));
2387
+ this.layoutManager.getPanels().some((e) => e.id === n) && this.recordIndicators(n, () => this.setPaneStyleNow(n, t ? ae(t) : null));
2356
2388
  }
2357
2389
  setPaneStyleNow(e, t) {
2358
2390
  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());
@@ -2372,7 +2404,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2372
2404
  }
2373
2405
  static indicators() {
2374
2406
  let e = new ze();
2375
- return zt(e), e.getAvailableIndicators();
2407
+ return Bt(e), e.getAvailableIndicators();
2376
2408
  }
2377
2409
  setPanelPosition(e, t) {
2378
2410
  this.layoutManager.setPanelPosition(e, t), this.updateViewportAndRender(), this.eventBus.emit("indicatorChange", {
@@ -2395,8 +2427,8 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2395
2427
  paneMoveHost(e, t) {
2396
2428
  let n = this.indicatorEngine.getIndicatorConfig(e), r = this.indicatorEngine.getIndicatorDescriptor(e);
2397
2429
  if (!n || !r) return;
2398
- let i = j(r);
2399
- if (r.placement === "overlay" && i && b(n.params[i])) return;
2430
+ let i = Vt(r);
2431
+ if (r.placement === "overlay" && i && x(n.params[i])) return;
2400
2432
  if (t === "price") return r.placement === "overlay" && n.pane ? null : void 0;
2401
2433
  if (t === "new") {
2402
2434
  let t = this.layoutManager.getPanels().some((t) => t.id === e);
@@ -2504,13 +2536,33 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2504
2536
  let e = this.viewport.getState().chartRect.y;
2505
2537
  return this.features.legend ? e + this.chartLegend.getHeight() : e;
2506
2538
  }
2539
+ setLegendStack(e) {
2540
+ let t = e && e.width > 0 && e.height > 0 ? {
2541
+ width: e.width,
2542
+ height: e.height
2543
+ } : null;
2544
+ t === this.legendStack || t !== null && this.legendStack !== null && t.width === this.legendStack.width && t.height === this.legendStack.height || (this.legendStack = t, this.engine.requestRender());
2545
+ }
2546
+ legendKeepOut() {
2547
+ let e = this.viewport.getState().chartRect, t = this.getLegendBottom(), n = [], r = this.features.legend ? this.chartLegend.getWidth() : 0;
2548
+ return r > 0 && t > e.y && n.push({
2549
+ x: e.x,
2550
+ y: e.y,
2551
+ width: r,
2552
+ height: t - e.y
2553
+ }), this.legendStack && n.push({
2554
+ x: e.x,
2555
+ y: t,
2556
+ ...this.legendStack
2557
+ }), n;
2558
+ }
2507
2559
  isTimeAligned() {
2508
2560
  return I(this.options.chartType) ? !1 : this.getDisplayData().length === this.series.length();
2509
2561
  }
2510
2562
  roundPrice(e) {
2511
2563
  if (!Number.isFinite(e)) return e;
2512
2564
  let t = this.stepAt(e);
2513
- if (t !== void 0) return Number((Math.round(e / t) * t).toFixed(le(t)));
2565
+ if (t !== void 0) return Number((Math.round(e / t) * t).toFixed(ce(t)));
2514
2566
  let { min: n, max: r } = this.viewport.getState().priceRange;
2515
2567
  return Number(e.toFixed(this.marketPricePrecision ?? c(n, r)));
2516
2568
  }
@@ -2520,7 +2572,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2520
2572
  }
2521
2573
  stepAt(e) {
2522
2574
  let t = this.symbolInfo?.minTick ?? this.priceUnit ?? void 0;
2523
- return t !== void 0 && t > 0 ? t : this.marketConfig ? re(e, this.marketConfig) : void 0;
2575
+ return t !== void 0 && t > 0 ? t : this.marketConfig ? ne(e, this.marketConfig) : void 0;
2524
2576
  }
2525
2577
  getPriceStep(e) {
2526
2578
  let t = this.stepAt(e ?? this.lastClose());
@@ -2535,7 +2587,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2535
2587
  return this.priceFormatter;
2536
2588
  }
2537
2589
  applyPriceFormat(e) {
2538
- this.priceFormatter = ne(e), this.priceUnit = e && typeof e != "function" ? g(e) : null, this.viewport.setPriceFormat(this.priceFormatter, this.priceUnit), this.crosshairTooltip.setPriceFormatter(this.priceFormatter), this.pinnedTooltip.setPriceFormatter(this.priceFormatter);
2590
+ this.priceFormatter = te(e), this.priceUnit = e && typeof e != "function" ? g(e) : null, this.viewport.setPriceFormat(this.priceFormatter, this.priceUnit), this.crosshairTooltip.setPriceFormatter(this.priceFormatter), this.pinnedTooltip.setPriceFormatter(this.priceFormatter);
2539
2591
  }
2540
2592
  setTimeFormatter(e) {
2541
2593
  this.applyTimeFormatter(e), this.engine.requestRender();
@@ -2594,7 +2646,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2594
2646
  }
2595
2647
  autoFib() {
2596
2648
  if (!this.features.drawings) return null;
2597
- let e = this.getDisplayData(), t = this.viewport.getState(), n = Ot(e, t.visibleRange.from, t.visibleRange.to);
2649
+ let e = this.getDisplayData(), t = this.viewport.getState(), n = kt(e, t.visibleRange.from, t.visibleRange.to);
2598
2650
  return n ? this.addDrawing({
2599
2651
  type: "fibRetracement",
2600
2652
  anchors: [n[0], n[1]]
@@ -2672,7 +2724,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2672
2724
  recordUndo(e) {
2673
2725
  if (!this.features.drawingUndoRedo || typeof e?.undo != "function" || typeof e.redo != "function") return;
2674
2726
  let t = performance.now(), n = this.undoRedoManager.last();
2675
- if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at < Fr) {
2727
+ if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at < Vr) {
2676
2728
  this.undoRedoManager.replaceLast({
2677
2729
  ...n,
2678
2730
  custom: {
@@ -2719,7 +2771,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2719
2771
  x: t.x,
2720
2772
  y: t.y
2721
2773
  };
2722
- if ((e === "plot" || e === "priceAxis") && (r.price = Jt(t.y, n)), (e === "plot" || e === "timeAxis") && n.data.length > 0 && (r.time = P(t.x, n)), e === "pane") {
2774
+ if ((e === "plot" || e === "priceAxis") && (r.price = Xt(t.y, n)), (e === "plot" || e === "timeAxis") && n.data.length > 0 && (r.time = P(t.x, n)), e === "pane") {
2723
2775
  let e = this.getIndicatorPanes().find((e) => t.y >= e.rect.y && t.y <= e.rect.y + e.rect.height);
2724
2776
  e && (r.pane = e.instanceId);
2725
2777
  }
@@ -2776,7 +2828,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2776
2828
  });
2777
2829
  }
2778
2830
  getExportData(e = {}) {
2779
- let t = this.series.bars(), n = 0, r = t.length - 1;
2831
+ let t = this.exportBars(), n = 0, r = t.length - 1;
2780
2832
  if (e.range === "visible") {
2781
2833
  let { visibleRange: e } = this.viewport.getState();
2782
2834
  n = Math.max(0, e.from), r = Math.min(t.length - 1, e.to);
@@ -2790,7 +2842,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2790
2842
  for (let e of this.indicatorEngine.getActiveIndicators()) {
2791
2843
  let t = this.indicatorEngine.getOutput(e.instanceId)?.series;
2792
2844
  if (!t) continue;
2793
- let r = on(e.id, e.params, e.descriptor.defaultConfig, e.descriptor.shortName), o = e.descriptor.plots ?? Object.keys(t.find((e) => e) ?? {}).map((e) => ({
2845
+ let r = un(e.id, e.params, e.descriptor.defaultConfig, e.descriptor.shortName), o = e.descriptor.plots ?? Object.keys(t.find((e) => e) ?? {}).map((e) => ({
2794
2846
  key: e,
2795
2847
  title: e
2796
2848
  }));
@@ -2814,11 +2866,11 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2814
2866
  }
2815
2867
  getExportText(e = "csv", t = {}) {
2816
2868
  let { bars: n, columns: r } = this.getExportData(t);
2817
- return e === "json" ? E.toJSON(n, r) : E.toCSV(n, r);
2869
+ return e === "json" ? D.toJSON(n, r) : D.toCSV(n, r);
2818
2870
  }
2819
2871
  download(e, t, n) {
2820
2872
  let r = this.getExportText(e, n);
2821
- e === "json" ? E.download(r, t ?? "chart-data.json", "application/json") : E.download(r, t ?? "chart-data.csv", "text/csv");
2873
+ e === "json" ? D.download(r, t ?? "chart-data.json", "application/json") : D.download(r, t ?? "chart-data.csv", "text/csv");
2822
2874
  }
2823
2875
  setAutoSave(e, t = 5e3) {
2824
2876
  this.autoSaveScheduler.enable(e, t);
@@ -2880,7 +2932,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2880
2932
  this.recordIndicators(e, () => this.updateIndicatorStyleNow(e, t));
2881
2933
  }
2882
2934
  updateIndicatorStyleNow(e, t) {
2883
- let { plots: n, ...r } = t, i = n === void 0 ? void 0 : ae(n);
2935
+ let { plots: n, ...r } = t, i = n === void 0 ? void 0 : ie(n);
2884
2936
  this.indicatorEngine.updateIndicatorStyle(e, {
2885
2937
  ...r,
2886
2938
  ...i ? { plots: i } : {}
@@ -2984,27 +3036,26 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
2984
3036
  this.replaySession || this.collectIndicatorValues(n), this.alertManager.checkChannels(n, { together: !0 }), this.alertManager.checkDrawings(e);
2985
3037
  }
2986
3038
  collectIndicatorValues(e) {
2987
- let t = this.series.bars();
2988
- if (t.length === 0) return;
2989
- let n = t.length - 1, r = this.alertManager.getAlerts().flatMap((e) => e.target ? [e.channel, e.target] : [e.channel]);
2990
- for (let t of r) {
2991
- if (e.has(t)) continue;
2992
- let r = t.indexOf(":");
2993
- if (r < 0) continue;
2994
- let i = this.indicatorEngine.getOutput(t.slice(0, r))?.series?.[n]?.[t.slice(r + 1)];
2995
- typeof i == "number" && Number.isFinite(i) && e.set(t, i);
3039
+ if (this.series.length() === 0) return;
3040
+ let t = this.alertManager.getAlerts().flatMap((e) => e.target ? [e.channel, e.target] : [e.channel]);
3041
+ for (let n of t) {
3042
+ if (e.has(n)) continue;
3043
+ let t = n.indexOf(":");
3044
+ if (t < 0) continue;
3045
+ let r = this.indicatorEngine.getOutput(n.slice(0, t))?.series, i = r?.[r.length - 1]?.[n.slice(t + 1)];
3046
+ typeof i == "number" && Number.isFinite(i) && e.set(n, i);
2996
3047
  }
2997
3048
  }
2998
3049
  setTradingConfig(e) {
2999
3050
  this.features.trading && this.tradingManager.setConfig(e);
3000
3051
  }
3001
3052
  async connect(e) {
3002
- if (!A(e.adapter, e.timeframe)) throw RangeError(`${e.adapter.name} cannot serve the ${e.timeframe} timeframe`);
3053
+ if (!j(e.adapter, e.timeframe)) throw RangeError(`${e.adapter.name} cannot serve the ${e.timeframe} timeframe`);
3003
3054
  this.snapshotKey = null, this.holdReplayFor(e.symbol), this.disconnectStream(), this.streamManager = new mt(), this.streamManager.setTimeZone(this.studyZoneHeld ? this.studyZone : this.getExchangeTimeZone()), this.streamManager.on("snapshot", (t) => {
3004
3055
  let n = this.streamSeriesKey(e.adapter);
3005
3056
  n === this.snapshotKey && this.replaySession ? this.series.mergeSnapshot(t) : n === this.snapshotKey && this.series.length() > 0 ? this.mergeSnapshot(t) : (this.replaySession && this.useStreamHistory(e.adapter, e.historyPageSize, !1), this.setData(t)), this.snapshotKey = n, this.useStreamHistory(e.adapter, e.historyPageSize);
3006
3057
  }), this.streamManager.on("barClose", (e) => {
3007
- if (!L(e)) return;
3058
+ if (!R(e)) return;
3008
3059
  let t = this.series.placeStreamBar(e);
3009
3060
  if (t.refiltered && (this.displayDataCache = null), t.to === "none") {
3010
3061
  this.updateBar(e);
@@ -3016,7 +3067,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3016
3067
  }), this.streamManager.on("barCorrection", (e) => {
3017
3068
  this.updateBar(e);
3018
3069
  }), this.streamManager.on("barUpdate", (e) => {
3019
- if (!L(e)) return;
3070
+ if (!R(e)) return;
3020
3071
  let t = this.series.placeStreamBar(e);
3021
3072
  if (t.refiltered && (this.displayDataCache = null), t.to === "none" || (this.replaySession || this.currentPriceLine.setPrice(e.close), this.replaySession)) return;
3022
3073
  let n = t.before;
@@ -3056,7 +3107,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3056
3107
  }), this.streamManager.on("symbolInfo", (e) => this.applyFeedSymbolInfo(e)), this.autoScrollOnNewBar = e.autoScroll !== !1, this.setStreamTarget(e.symbol, e.timeframe), this.streamAdapter = e.adapter;
3057
3108
  let t = this.streamManager;
3058
3109
  if (this.resolveStreamSymbol(e.adapter, e.symbol), await t.connect(e), this.streamManager !== t) return;
3059
- let n = w(e.timeframe);
3110
+ let n = T(e.timeframe);
3060
3111
  this.barCountdown.setTimeframeMs(n), this.countdownInterval && clearInterval(this.countdownInterval), this.countdownInterval = setInterval(() => {
3061
3112
  this.barCountdown.isVisible() && this.engine.requestRender(r.Hover);
3062
3113
  }, 1e3);
@@ -3067,7 +3118,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3067
3118
  }
3068
3119
  setStreamTarget(e, t) {
3069
3120
  let n = this.announcedSymbol;
3070
- this.currentSymbol = e, this.streamTimeframe = t, this.tickStream = ue(t) !== null, this.applyTimeSpacing(), e !== n && this.chartLegend.setSymbol(e), e !== n && (this.announcedSymbol = e, this.eventBus.emit("symbolChange", {
3121
+ this.currentSymbol = e, this.streamTimeframe = t, this.tickStream = le(t) !== null, this.applyTimeSpacing(), e !== n && this.chartLegend.setSymbol(e), e !== n && (this.announcedSymbol = e, this.eventBus.emit("symbolChange", {
3071
3122
  symbol: e,
3072
3123
  previous: n
3073
3124
  })), this.useTimeframe(t);
@@ -3085,8 +3136,8 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3085
3136
  async switchStream(e, t) {
3086
3137
  if (!this.streamManager) return;
3087
3138
  let n = this.streamAdapter;
3088
- if (n && !A(n, t)) throw RangeError(`${n.name} cannot serve the ${t} timeframe`);
3089
- this.holdReplayFor(e), this.setStreamTarget(e, t), this.historyFromStream && this.history.setLoader(null), this.barCountdown.setTimeframeMs(w(t)), n && this.resolveStreamSymbol(n, e), await this.streamManager.switchTo(e, t);
3139
+ if (n && !j(n, t)) throw RangeError(`${n.name} cannot serve the ${t} timeframe`);
3140
+ this.holdReplayFor(e), this.setStreamTarget(e, t), this.historyFromStream && this.history.setLoader(null), this.barCountdown.setTimeframeMs(T(t)), n && this.resolveStreamSymbol(n, e), await this.streamManager.switchTo(e, t);
3090
3141
  }
3091
3142
  isIndicatorAllowed(e) {
3092
3143
  let t = this.features.indicatorIds;
@@ -3105,7 +3156,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3105
3156
  }
3106
3157
  connectExecution(e, t = {}) {
3107
3158
  if (!this.features.trading) throw Error("connectExecution requires features.trading to be enabled");
3108
- this.disconnectExecution(), this.executionAdapter = e, this.execTeardown = lr(e, {
3159
+ this.disconnectExecution(), this.executionAdapter = e, this.execTeardown = hr(e, {
3109
3160
  onIntent: (e, t) => {
3110
3161
  let n = (e) => t(e.payload);
3111
3162
  return this.eventBus.on(e, n), () => this.eventBus.off(e, n);
@@ -3181,6 +3232,14 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3181
3232
  comparesDrawn() {
3182
3233
  return this.isTimeAligned();
3183
3234
  }
3235
+ panesOffChartType() {
3236
+ let e = this.indicatorEngine.getActiveIndicators(), t = new Set(e.filter((e) => e.offChartType).map((e) => e.instanceId)), n = /* @__PURE__ */ new Set();
3237
+ for (let r of this.layoutManager.getPanels()) {
3238
+ let i = e.filter((e) => e.instanceId === r.id || e.pane === r.id);
3239
+ i.length > 0 && i.every((e) => t.has(e.instanceId)) && n.add(r.id);
3240
+ }
3241
+ return n;
3242
+ }
3184
3243
  clearCompareSymbols() {
3185
3244
  let e = this.compareRenderer.getSymbols().map((e) => e.id);
3186
3245
  this.compareRenderer.clear(), this.updateViewportAndRender();
@@ -3236,7 +3295,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3236
3295
  setVisibleRangePreset(e) {
3237
3296
  let t = this.getDisplayData();
3238
3297
  if (t.length === 0) return;
3239
- let n = t.length - 1, r = u(t), i = It(e, t[n].time * r, this.displayTz), a = i === null ? null : i / r;
3298
+ let n = t.length - 1, r = u(t), i = Lt(e, t[n].time * r, this.displayTz), a = i === null ? null : i / r;
3240
3299
  if (a === null || a < t[0].time) {
3241
3300
  this.fitContent();
3242
3301
  return;
@@ -3372,7 +3431,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3372
3431
  this.applyStyle(e, t.layer ?? "host", !0);
3373
3432
  }
3374
3433
  setOverrides(e, t = {}) {
3375
- let n = t.layer ?? "host", { overrides: r, rejected: i } = ie(e);
3434
+ let n = t.layer ?? "host", { overrides: r, rejected: i } = re(e);
3376
3435
  i.length > 0 && console.warn(`Style overrides left out (unknown key or value): ${i.join(", ")}`);
3377
3436
  let a = Object.fromEntries(Object.entries(r).filter(([, e]) => e !== null));
3378
3437
  this.themeManager.setOverrides(a, n) && this.styleChanged(n);
@@ -3391,7 +3450,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3391
3450
  return this.themeManager.getStyleValue(e);
3392
3451
  }
3393
3452
  applyStyle(e, t, n) {
3394
- let { overrides: r, rejected: i } = ie(e);
3453
+ let { overrides: r, rejected: i } = re(e);
3395
3454
  i.length > 0 && console.warn(`Style overrides left out (unknown key or value): ${i.join(", ")}`), this.themeManager.applyOverrides(r, t) && n && this.styleChanged(t);
3396
3455
  }
3397
3456
  styleChanged(e) {
@@ -3498,7 +3557,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3498
3557
  return this.periodLevels.getPeriod();
3499
3558
  }
3500
3559
  setTimeZone(e) {
3501
- jr(e), this.timeZoneSetting = e, this.applyTimeZone();
3560
+ Lr(e), this.timeZoneSetting = e, this.applyTimeZone();
3502
3561
  }
3503
3562
  getTimeZone() {
3504
3563
  return this.timeZoneSetting;
@@ -3507,7 +3566,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3507
3566
  return this.displayTz;
3508
3567
  }
3509
3568
  getExchangeTimeZone() {
3510
- return [C(this.symbolInfo), this.marketConfig?.timeZone].find((e) => e && v(e)) ?? null;
3569
+ return [w(this.symbolInfo), this.marketConfig?.timeZone].find((e) => e && v(e)) ?? null;
3511
3570
  }
3512
3571
  setTimezone(e) {
3513
3572
  this.setTimeZone(e);
@@ -3549,7 +3608,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3549
3608
  }
3550
3609
  spokenBarTime(e) {
3551
3610
  let t = this.getDisplayData(), n = e * u(t), r = this.numberLocale || "en-US";
3552
- return d(t) === !0 ? de(r, { dateStyle: "medium" }, l(n, this.displayTz, this.getExchangeTimeZone()))(n) : de(r, {
3611
+ return d(t) === !0 ? ue(r, { dateStyle: "medium" }, l(n, this.displayTz, this.getExchangeTimeZone()))(n) : ue(r, {
3553
3612
  dateStyle: "medium",
3554
3613
  timeStyle: "short"
3555
3614
  }, this.displayTz)(n);
@@ -3562,18 +3621,18 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3562
3621
  this.studyZoneHeld = !1, this.endStudyZoneWait(), this.useSymbolInfo(e);
3563
3622
  }
3564
3623
  useSymbolInfo(e) {
3565
- let t = e && this.symbolInfo?.symbol === e.symbol ? C(this.symbolInfo) : void 0;
3566
- this.symbolInfo = e ? Mr({
3624
+ let t = e && this.symbolInfo?.symbol === e.symbol ? w(this.symbolInfo) : void 0;
3625
+ this.symbolInfo = e ? Rr({
3567
3626
  ...e,
3568
3627
  sessions: e.sessions?.map((e) => ({ ...e }))
3569
3628
  }, t) : null, this.chartLegend.setExchange(this.symbolInfo?.exchange ?? ""), this.engine.requestRender(r.Hover), this.priceAxis.setPriceTick(this.symbolInfo?.minTick ?? null), this.marketConfig?.pricePrecision === void 0 && this.applyPricePrecision(this.symbolInfo?.pricePrecision ?? null);
3570
3629
  let n = (this.symbolInfo?.sessions ?? []).flatMap((e) => {
3571
- let t = S(e.start), n = S(e.end);
3630
+ let t = C(e.start), n = C(e.end);
3572
3631
  return t === null || n === null ? [] : [{
3573
3632
  startMinute: t,
3574
3633
  endMinute: n
3575
3634
  }];
3576
- }), i = C(this.symbolInfo);
3635
+ }), i = w(this.symbolInfo);
3577
3636
  this.sessionShading.replaceConfig(n.length > 0 && i && v(i) ? {
3578
3637
  timeZone: i,
3579
3638
  windows: n,
@@ -3588,11 +3647,11 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3588
3647
  if (!e || typeof e != "object") return;
3589
3648
  let t = this.currentSymbol, n = (e) => !e || e.toUpperCase() === t.toUpperCase();
3590
3649
  if (!n(e.symbol)) return;
3591
- let r = this.symbolInfo && n(this.symbolInfo.symbol) ? this.symbolInfo : null, i = Mr({
3650
+ let r = this.symbolInfo && n(this.symbolInfo.symbol) ? this.symbolInfo : null, i = Rr({
3592
3651
  ...r,
3593
3652
  ...e,
3594
3653
  symbol: e.symbol || r?.symbol || t
3595
- }, C(r));
3654
+ }, w(r));
3596
3655
  r && JSON.stringify(i) === JSON.stringify(r) || (this.symbolInfoSeq++, this.setSymbolInfo(i));
3597
3656
  }
3598
3657
  resolveStreamSymbol(e, t) {
@@ -3627,7 +3686,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3627
3686
  return this.sessionShading.isVisible();
3628
3687
  }
3629
3688
  setSessionShadingConfig(e) {
3630
- this.hostSessionHours = Nt(this.hostSessionHours, e), this.sessionShading.replaceConfig(this.hostSessionHours), this.engine.requestRender(r.Background);
3689
+ this.hostSessionHours = Pt(this.hostSessionHours, e), this.sessionShading.replaceConfig(this.hostSessionHours), this.engine.requestRender(r.Background);
3631
3690
  }
3632
3691
  setTooltipVisible(e) {
3633
3692
  e || this.crosshairTooltip.hide();
@@ -3649,11 +3708,11 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3649
3708
  return this.waitForGpu(null), e === "canvas" ? (this.applyRenderer(null), "canvas") : this.engine.getGpu() ? "webgl" : this.takeGpu(e, t, !0);
3650
3709
  }
3651
3710
  async takeGpu(e, t, n) {
3652
- let { gpu: r, reason: i } = await Mt(e);
3653
- return t !== this.rendererToken || this.disposed ? (r?.destroy(), this.getRenderer()) : i === "limit" ? kt() > 0 ? this.takeGpu(e, t, n) : (this.waitForGpu(() => void this.takeGpu(e, t, !1)), n && this.applyRenderer(null, "limit"), this.getRenderer()) : ((r || n) && this.applyRenderer(r, i), this.getRenderer());
3711
+ let { gpu: r, reason: i } = await Nt(e);
3712
+ return t !== this.rendererToken || this.disposed ? (r?.destroy(), this.getRenderer()) : i === "limit" ? At() > 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());
3654
3713
  }
3655
3714
  waitForGpu(e) {
3656
- this.stopWaitingForGpu?.(), this.stopWaitingForGpu = e ? Kt(e) : null;
3715
+ this.stopWaitingForGpu?.(), this.stopWaitingForGpu = e ? Jt(e) : null;
3657
3716
  }
3658
3717
  getRenderer() {
3659
3718
  return this.engine.getGpu() ? "webgl" : "canvas";
@@ -3675,7 +3734,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3675
3734
  this.engine.getGpu() && this.engine.renderNow();
3676
3735
  }
3677
3736
  screenshot(e) {
3678
- this.features.screenshot && (this.freshFrame(), k.download(this.container, e, this.themeManager.getTheme().background));
3737
+ this.features.screenshot && (this.freshFrame(), A.download(this.container, e, this.themeManager.getTheme().background));
3679
3738
  }
3680
3739
  async copyScreenshot() {
3681
3740
  if (!this.features.screenshot) return !1;
@@ -3683,7 +3742,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3683
3742
  if (!t?.write || !e) return !1;
3684
3743
  try {
3685
3744
  this.freshFrame();
3686
- let n = k.toBlob(this.container, this.themeManager.getTheme().background).then((e) => {
3745
+ let n = A.toBlob(this.container, this.themeManager.getTheme().background).then((e) => {
3687
3746
  if (!e) throw Error("No chart image to copy");
3688
3747
  return e;
3689
3748
  });
@@ -3701,10 +3760,10 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3701
3760
  }
3702
3761
  }
3703
3762
  screenshotDataURL() {
3704
- return this.features.screenshot ? (this.freshFrame(), k.toDataURL(this.container, this.themeManager.getTheme().background)) : null;
3763
+ return this.features.screenshot ? (this.freshFrame(), A.toDataURL(this.container, this.themeManager.getTheme().background)) : null;
3705
3764
  }
3706
3765
  async screenshotBlob() {
3707
- return this.features.screenshot ? (this.freshFrame(), k.toBlob(this.container, this.themeManager.getTheme().background)) : null;
3766
+ return this.features.screenshot ? (this.freshFrame(), A.toBlob(this.container, this.themeManager.getTheme().background)) : null;
3708
3767
  }
3709
3768
  addAlert(e, t = "crossing", n, r = "price", i, a = {}) {
3710
3769
  if (!this.features.alerts) return null;
@@ -3831,24 +3890,24 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3831
3890
  let t = this.replaySession ? this.replayOffset : 0;
3832
3891
  if (!this.replaySession) {
3833
3892
  if (this.series.length() === 0) return;
3834
- this.series.beginReplay(), this.replaySession = ei(this.currentSymbol);
3893
+ this.series.beginReplay(), this.replaySession = oi(this.currentSymbol);
3835
3894
  }
3836
3895
  let n = this.replaySession, { steps: r, startTime: i, hideHistory: a, revealMarks: o, step: s, ...c } = e ?? {};
3837
3896
  c.animate = c.animate === !0;
3838
3897
  let l = this.series.inHoursShown(this.series.liveBars()), u = t > 0 && i === void 0 && a !== !1, d = c.startIndex;
3839
- i !== void 0 && d === void 0 ? d = J(l, i) : u && d !== void 0 && (d += t);
3898
+ i !== void 0 && d === void 0 ? d = Y(l, i) : u && d !== void 0 && (d += t);
3840
3899
  let f = u ? t : a && d !== void 0 && d > 0 ? Math.min(Math.floor(d), l.length - 1) : 0, p = f > 0 ? l.slice(f) : l;
3841
3900
  d !== void 0 && (c.startIndex = d - f), n.windowTime = f > 0 ? p[0]?.time ?? null : null, n.steps = r ?? null, n.stepsSymbol = this.currentSymbol, n.until = null, n.animate = c.animate, n.step = c.animate ? s ?? null : null, this.replayRevealMarks = o !== !1, this.useReplayLoader(n, !0);
3842
3901
  let m = r ? this.replayStepsOver(n, p, !0) : null;
3843
3902
  this.options.autoScale = !0, this.buildReplay(p, m, f);
3844
3903
  let h = this.replayStepsSeries;
3845
- h && c.startIndex !== void 0 && (c.startIndex = li(h, p, c.startIndex));
3904
+ h && c.startIndex !== void 0 && (c.startIndex = hi(h, p, c.startIndex));
3846
3905
  let g = h ?? p, _ = g[Math.max(0, Math.min(Math.floor(Number(c.startIndex ?? 0)) || 0, g.length - 1))];
3847
3906
  this.revealReplayMarks(this.replayRevealMarks ? _?.time ?? null : null), n.held && (n.held.state = c.paused ? "paused" : "playing", c.paused = !0), !c.paused && c.startIndex !== void 0 && c.startIndex >= 1 && this.replaySeek(c.startIndex - 1), this.replayManager.play(c);
3848
3907
  }
3849
3908
  buildReplay(e, t, n) {
3850
3909
  let r = this.replaySession?.animate === !0, i = r ? null : t;
3851
- this.replayPieces = r && t ? fi(t, e) : null, this.replayForming = null, this.replayOffset = n, this.replayStepsSeries = i, this.replayCoarse = e;
3910
+ this.replayPieces = r && t ? vi(t, e) : null, this.replayForming = null, this.replayOffset = n, this.replayStepsSeries = i, this.replayCoarse = e;
3852
3911
  let a = this.replayRestarting;
3853
3912
  this.replayRestarting = !0;
3854
3913
  try {
@@ -3862,7 +3921,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3862
3921
  let n = t, a = e[t];
3863
3922
  if (i) {
3864
3923
  let r = i[t];
3865
- n = Z(e, r.time), c = c !== null && s === t - 1 && n === o - 1 && c ? mi(c, r) : ui(e[n], i, t), a = di(i, e, t, n) ? e[n] : c;
3924
+ n = Q(e, r.time), c = c !== null && s === t - 1 && n === o - 1 && c ? bi(c, r) : gi(e[n], i, t), a = _i(i, e, t, n) ? e[n] : c;
3866
3925
  }
3867
3926
  let u = this.replayForming;
3868
3927
  this.replayForming = null, s = t;
@@ -3886,7 +3945,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3886
3945
  });
3887
3946
  }), r && (this.replayPhaseUnsub = this.replayManager.on("phase", ({ index: t, fraction: n }) => {
3888
3947
  if (!e[t] || this.series.length() !== o || o !== t && o !== t + 1) return;
3889
- let r = this.replayForming?.index === t ? this.replayForming.path : this.replayPathOf(e, t), i = pi() ? wr(r, n) : n, a = o === t, s = a && this.autoScrollOnNewBar && this.viewport.isAtEnd(), c = Cr(r, i);
3948
+ let r = this.replayForming?.index === t ? this.replayForming.path : this.replayPathOf(e, t), i = yi() ? Ar(r, n) : n, a = o === t, s = a && this.autoScrollOnNewBar && this.viewport.isAtEnd(), c = kr(r, i);
3890
3949
  a ? this.series.appendReplayed(c) : this.series.updateReplayed(c), o = t + 1, this.replayForming = {
3891
3950
  index: t,
3892
3951
  path: r
@@ -3896,7 +3955,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3896
3955
  drawFormingBar(e, t, n, r) {
3897
3956
  this.currentPriceLine.setPrice(e.close, t);
3898
3957
  let i = this.series.bars();
3899
- if (this.recalcIndicatorsFrom(i, i.length - 1), (n || !Xr.has(this.options.chartType)) && (this.displayDataCache = null), !n) {
3958
+ if (this.recalcIndicatorsFrom(i, i.length - 1), (n || !ni.has(this.options.chartType)) && (this.displayDataCache = null), !n) {
3900
3959
  this.scheduleRender();
3901
3960
  return;
3902
3961
  }
@@ -3904,22 +3963,22 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3904
3963
  }
3905
3964
  replayPathOf(e, t) {
3906
3965
  let n = e[t];
3907
- return vr(n, this.replayPieces?.get(n.time) ?? this.replayLoader?.loader.piecesOf(n.time) ?? []);
3966
+ return wr(n, this.replayPieces?.get(n.time) ?? this.replayLoader?.loader.piecesOf(n.time) ?? []);
3908
3967
  }
3909
3968
  loadReplaySteps(e, t) {
3910
3969
  let n = this.replayLoader?.loader;
3911
3970
  if (!n) return;
3912
3971
  n.evictBefore(e[t].time);
3913
3972
  let r = this.replayManager.getStepMs();
3914
- n.ensure(e, t, Number.isFinite(r) && r > 0 ? Math.ceil(Yr / r) : 1);
3973
+ n.ensure(e, t, Number.isFinite(r) && r > 0 ? Math.ceil(ti / r) : 1);
3915
3974
  }
3916
3975
  useReplayLoader(e, t) {
3917
- let n = this.streamAdapter, r = this.streamTimeframe, i = e.step && n && r !== null ? Dr(e.step, r, (e) => A(n, e)) : null, a = `${this.currentSymbol}|${r}|${i}`;
3976
+ let n = this.streamAdapter, r = this.streamTimeframe, i = e.step && n && r !== null ? Nr(e.step, r, (e) => j(n, e)) : null, a = `${this.currentSymbol}|${r}|${i}`;
3918
3977
  if (!t && this.replayLoader?.key === a || (this.replayLoader?.loader.dispose(), this.replayLoader = null, !i || !n || r === null)) return;
3919
- let o = N(n), s = o.fetchHistoryBefore, c = this.currentSymbol, l = w(r), u = new dr({
3978
+ let o = N(n), s = o.fetchHistoryBefore, c = this.currentSymbol, l = T(r), u = new _r({
3920
3979
  source: s ? (e, t) => s.call(o, c, i, e, t) : null,
3921
3980
  step: i,
3922
- ratio: Math.max(1, Math.round(l / w(i))),
3981
+ ratio: Math.max(1, Math.round(l / T(i))),
3923
3982
  barMs: l,
3924
3983
  keep: (e) => this.series.inHoursShown(e),
3925
3984
  report: (e) => this.eventBus.emit("replayStepsLoad", e)
@@ -3934,18 +3993,18 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3934
3993
  if (!i || !a?.setMarkPrice || !o) return;
3935
3994
  let s = i.fedTime;
3936
3995
  if (s === null) {
3937
- i.fedTime = o.time, i.fedFraction = r, this.feedReplayPrice(Cr(n, r).close, o.time);
3996
+ i.fedTime = o.time, i.fedFraction = r, this.feedReplayPrice(kr(n, r).close, o.time);
3938
3997
  return;
3939
3998
  }
3940
3999
  if (o.time < s || o.time === s && r <= i.fedFraction) return;
3941
4000
  let c = [];
3942
4001
  if (o.time > s) {
3943
- let a = J(e, s);
3944
- e[a]?.time === s && i.fedFraction < 1 && c.push(...K(this.replayPathOf(e, a), i.fedFraction, 1));
3945
- let o = e.slice(Y(e, s), t), l = Math.ceil(o.length / oi);
3946
- for (let e = 0; e < o.length; e += l) c.push(...si(o.slice(e, e + l)));
3947
- c.push(...K(n, -1, r));
3948
- } else c.push(...K(n, i.fedFraction, r));
4002
+ let a = Y(e, s);
4003
+ e[a]?.time === s && i.fedFraction < 1 && c.push(...q(this.replayPathOf(e, a), i.fedFraction, 1));
4004
+ let o = e.slice(X(e, s), t), l = Math.ceil(o.length / fi);
4005
+ for (let e = 0; e < o.length; e += l) c.push(...pi(o.slice(e, e + l)));
4006
+ c.push(...q(n, -1, r));
4007
+ } else c.push(...q(n, i.fedFraction, r));
3949
4008
  i.fedTime = o.time, i.fedFraction = r;
3950
4009
  for (let [e, t] of c) a.setMarkPrice(e, t);
3951
4010
  let l = c[c.length - 1]?.[0];
@@ -3960,9 +4019,9 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3960
4019
  if (!t) return;
3961
4020
  let n = this.series.inHoursShown(this.series.liveBars());
3962
4021
  if (n.length === 0) return;
3963
- let r = t.windowTime === null ? 0 : Math.min(J(n, t.windowTime), n.length - 1), i = r > 0 ? n.slice(r) : n;
4022
+ let r = t.windowTime === null ? 0 : Math.min(Y(n, t.windowTime), n.length - 1), i = r > 0 ? n.slice(r) : n;
3964
4023
  this.useReplayLoader(t, !1);
3965
- let a = this.replayStepsOver(t, i), o = t.animate ? null : a, s = t.until === null ? 0 : ri(o ?? i, t.until);
4024
+ let a = this.replayStepsOver(t, i), o = t.animate ? null : a, s = t.until === null ? 0 : li(o ?? i, t.until);
3966
4025
  if (s < 0 && this.canPageBackForReplay(t)) {
3967
4026
  this.holdReplay(), t.held && t.held.pagesBack++, queueMicrotask(() => void this.pageBackForReplay(t));
3968
4027
  return;
@@ -3970,7 +4029,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3970
4029
  let c = this.getReplayState(), l = t.held !== null && (e === "hours" || e === "bar"), u = t.held?.state ?? c;
3971
4030
  l || (t.held = null), t.symbol = this.currentSymbol;
3972
4031
  let d = this.replayManager.remainingMs();
3973
- this.clearBarHolders(), t.animate && ni(t, this.replayCoarse, i);
4032
+ this.clearBarHolders(), t.animate && ci(t, this.replayCoarse, i);
3974
4033
  let f = this.replayRestarting;
3975
4034
  this.replayRestarting = !0, this.replayCause = e === "older" ? "older" : "series";
3976
4035
  try {
@@ -3993,14 +4052,14 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
3993
4052
  }
3994
4053
  replayStepsOver(e, t, n = !1) {
3995
4054
  if (!e.steps || e.stepsSymbol !== this.currentSymbol) return null;
3996
- let r = ci(this.series.inHoursShown(e.steps), t);
3997
- return r && (n || ai(r, t)) ? r : null;
4055
+ let r = mi(this.series.inHoursShown(e.steps), t);
4056
+ return r && (n || di(r, t)) ? r : null;
3998
4057
  }
3999
4058
  canPageBackForReplay(e) {
4000
- return this.history.hasLoader() && this.history.hasMore() && (e.held?.pagesBack ?? 0) < Zr;
4059
+ return this.history.hasLoader() && this.history.hasMore() && (e.held?.pagesBack ?? 0) < ri;
4001
4060
  }
4002
4061
  async pageBackForReplay(e) {
4003
- this.replaySession !== e || !e.held || await this.history.loadMore() > 0 || this.replaySession !== e || !e.held || (e.held.pagesBack = Zr, this.rebaseReplay("older"));
4062
+ this.replaySession !== e || !e.held || await this.history.loadMore() > 0 || this.replaySession !== e || !e.held || (e.held.pagesBack = ri, this.rebaseReplay("older"));
4004
4063
  }
4005
4064
  holdReplay() {
4006
4065
  let e = this.replaySession;
@@ -4033,7 +4092,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4033
4092
  this.signalMarkerManager.setRevealUntil(e, t), this.tradeZoneManager.setRevealUntil(e, t);
4034
4093
  }
4035
4094
  replaySeekToTime(e) {
4036
- !this.replaySession || !this.replayCoarse || this.replaySeek(Math.max(0, ri(this.replayStepsSeries ?? this.replayCoarse, e)));
4095
+ !this.replaySession || !this.replayCoarse || this.replaySeek(Math.max(0, li(this.replayStepsSeries ?? this.replayCoarse, e)));
4037
4096
  }
4038
4097
  feedReplayPrice(e, t) {
4039
4098
  let n = this.executionAdapter;
@@ -4053,21 +4112,21 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4053
4112
  return;
4054
4113
  }
4055
4114
  if (i.time <= n.fedTime) return;
4056
- let a = e.slice(Y(e, n.fedTime), t + 1);
4115
+ let a = e.slice(X(e, n.fedTime), t + 1);
4057
4116
  n.fedTime = i.time;
4058
- let o = Math.ceil(a.length / oi);
4059
- for (let e = 0; e < a.length; e += o) for (let [t, n] of si(a.slice(e, e + o))) r.setMarkPrice(t, n);
4117
+ let o = Math.ceil(a.length / fi);
4118
+ for (let e = 0; e < a.length; e += o) for (let [t, n] of pi(a.slice(e, e + o))) r.setMarkPrice(t, n);
4060
4119
  this.tradingManager.setCurrentPrice(i.close);
4061
4120
  }
4062
4121
  getReplayBarIndex() {
4063
4122
  if (!this.replaySession) return -1;
4064
4123
  if (this.replayForming) return this.replayForming.index;
4065
4124
  let { current: e } = this.replayManager.getProgress(), t = this.replayStepsSeries;
4066
- return t && this.replayCoarse ? Z(this.replayCoarse, t[e]?.time ?? -Infinity) : e;
4125
+ return t && this.replayCoarse ? Q(this.replayCoarse, t[e]?.time ?? -Infinity) : e;
4067
4126
  }
4068
4127
  replaySeekToBar(e) {
4069
4128
  let t = this.replayStepsSeries;
4070
- this.replaySeek(t && this.replayCoarse ? li(t, this.replayCoarse, e) : e);
4129
+ this.replaySeek(t && this.replayCoarse ? hi(t, this.replayCoarse, e) : e);
4071
4130
  }
4072
4131
  replayPause() {
4073
4132
  this.setHeldState("paused") || this.replayManager.pause();
@@ -4103,10 +4162,10 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4103
4162
  data: this.getDisplayData()
4104
4163
  }, r = n.chartRect, i = Infinity, a = -Infinity, o = Infinity, s = -Infinity;
4105
4164
  for (let e of t.anchors) {
4106
- let t = Bt(e.time, n), r = Ft(e.price, n);
4165
+ let t = Ht(e.time, n), r = It(e.price, n);
4107
4166
  i = Math.min(i, t), a = Math.max(a, t), o = Math.min(o, r), s = Math.max(s, r);
4108
4167
  }
4109
- return Rr.has(t.type) ? [i, a] = [r.x, r.x + r.width] : t.type === "horizontalRay" && (a = r.x + r.width), zr.has(t.type) && ([o, s] = [r.y, r.y + r.height]), i = Math.max(i, r.x), a = Math.min(a, r.x + r.width), o = Math.max(o, r.y), s = Math.min(s, r.y + r.height), i <= a && o <= s ? {
4168
+ return Wr.has(t.type) ? [i, a] = [r.x, r.x + r.width] : t.type === "horizontalRay" && (a = r.x + r.width), Gr.has(t.type) && ([o, s] = [r.y, r.y + r.height]), i = Math.max(i, r.x), a = Math.min(a, r.x + r.width), o = Math.max(o, r.y), s = Math.min(s, r.y + r.height), i <= a && o <= s ? {
4110
4169
  x: i,
4111
4170
  y: o,
4112
4171
  width: a - i,
@@ -4142,7 +4201,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4142
4201
  };
4143
4202
  }
4144
4203
  captureSnapshot() {
4145
- return T.capture({
4204
+ return E.capture({
4146
4205
  getDrawings: () => this.getDrawings(),
4147
4206
  getTheme: () => this.themeManager.getBaseTheme(),
4148
4207
  getAlerts: () => this.getAlerts(),
@@ -4155,14 +4214,14 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4155
4214
  });
4156
4215
  }
4157
4216
  restoreIndicators(e, t) {
4158
- let n = Vr(e), r = /* @__PURE__ */ new Map();
4217
+ let n = qr(e), r = /* @__PURE__ */ new Map();
4159
4218
  this.unrestoredIndicators = [];
4160
4219
  let i = new Set(this.indicatorEngine.getAvailableIndicators().map((e) => e.id)), a = [], o = /* @__PURE__ */ new Set();
4161
4220
  if (t) {
4162
4221
  let e = new Map(n.map((e) => [e.instanceId, e])), t = this.getIndicatorSetup();
4163
4222
  for (let n of t) {
4164
4223
  let t = e.get(n.instanceId);
4165
- t && Hr(n, t) && o.add(n.instanceId);
4224
+ t && Jr(n, t) && o.add(n.instanceId);
4166
4225
  }
4167
4226
  for (let e of t) o.has(e.instanceId) || this.removeIndicator(e.instanceId);
4168
4227
  for (let e of [...o]) this.indicatorEngine.getIndicatorConfig(e) || o.delete(e);
@@ -4170,7 +4229,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4170
4229
  let s = (e) => {
4171
4230
  let t = { ...e };
4172
4231
  for (let [e, n] of Object.entries(t)) {
4173
- let i = b(n), a = i && r.get(i.instanceId);
4232
+ let i = x(n), a = i && r.get(i.instanceId);
4174
4233
  a && (t[e] = _(a, i.key));
4175
4234
  }
4176
4235
  return t;
@@ -4224,7 +4283,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4224
4283
  let s = t.levels ?? null;
4225
4284
  JSON.stringify(s) !== JSON.stringify(o?.levels ?? null) && this.setIndicatorLevels(e, s);
4226
4285
  let c = t.intervals ?? null;
4227
- JSON.stringify(c) !== JSON.stringify(o?.intervals ?? null) && this.setIndicatorIntervalsNow(e, c), this.setPaneStyleNow(e, t.paneStyle ? oe(t.paneStyle) : null);
4286
+ JSON.stringify(c) !== JSON.stringify(o?.intervals ?? null) && this.setIndicatorIntervalsNow(e, c), this.setPaneStyleNow(e, t.paneStyle ? ae(t.paneStyle) : null);
4228
4287
  }
4229
4288
  restorePanes(e) {
4230
4289
  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, {
@@ -4329,7 +4388,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4329
4388
  if (this.indicatorHistoryDepth > 0 || !this.features.drawingUndoRedo) return t();
4330
4389
  let n = this.getIndicatorSetup(), r = this.withoutIndicatorHistory(t), i = this.getIndicatorSetup();
4331
4390
  if (JSON.stringify(n) === JSON.stringify(i)) return r;
4332
- let a = performance.now(), o = this.undoRedoManager.last(), s = e !== void 0 && o?.type === "indicators" && o.indicators?.subject === e && a - (o.indicators.at ?? 0) < Fr && JSON.stringify(o.indicators.after) === JSON.stringify(n), c = {
4391
+ let a = performance.now(), o = this.undoRedoManager.last(), s = e !== void 0 && o?.type === "indicators" && o.indicators?.subject === e && a - (o.indicators.at ?? 0) < Vr && JSON.stringify(o.indicators.after) === JSON.stringify(n), c = {
4333
4392
  type: "indicators",
4334
4393
  before: null,
4335
4394
  after: null
@@ -4357,12 +4416,12 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4357
4416
  }
4358
4417
  saveState(e) {
4359
4418
  if (!this.features.saveLoad) return null;
4360
- let t = this.captureSnapshot(), n = T.serialize(t);
4361
- return e && T.saveToStorage(e, t), n;
4419
+ let t = this.captureSnapshot(), n = E.serialize(t);
4420
+ return e && E.saveToStorage(e, t), n;
4362
4421
  }
4363
4422
  loadState(e) {
4364
4423
  if (!this.features.saveLoad) return;
4365
- let t = T.deserialize(e);
4424
+ let t = E.deserialize(e);
4366
4425
  this.chartTypeOptions = t.chartTypeOptions ?? {}, this.displayDataCache = null, this.reshapeMemo.clear(), 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");
4367
4426
  let n = t.version >= 2 && this.features.indicators ? this.withoutIndicatorHistory(() => this.restoreIndicators(t.indicators, !1)) : /* @__PURE__ */ new Map();
4368
4427
  if (this.undoRedoManager.clear(), t.alerts && this.features.alerts) {
@@ -4373,7 +4432,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4373
4432
  let t = e.indexOf(":"), r = t > 0 ? n.get(e.slice(0, t)) : void 0;
4374
4433
  return r ? r + e.slice(t) : e;
4375
4434
  }, r = t(e.channel), i = {
4376
- ...Lt(e),
4435
+ ...Rt(e),
4377
4436
  ...e.target ? { target: t(e.target) } : {}
4378
4437
  };
4379
4438
  if (!e.expired) {
@@ -4393,19 +4452,19 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4393
4452
  }
4394
4453
  loadStateFromStorage(e) {
4395
4454
  if (!this.features.saveLoad) return !1;
4396
- let t = T.loadFromStorage(e);
4397
- return t ? (this.loadState(T.serialize(t)), !0) : !1;
4455
+ let t = E.loadFromStorage(e);
4456
+ return t ? (this.loadState(E.serialize(t)), !0) : !1;
4398
4457
  }
4399
4458
  downloadState(e) {
4400
- this.features.saveLoad && T.downloadFile(this.captureSnapshot(), e);
4459
+ this.features.saveLoad && E.downloadFile(this.captureSnapshot(), e);
4401
4460
  }
4402
4461
  async loadStateFromFile() {
4403
4462
  if (!this.features.saveLoad) return;
4404
- let e = await T.loadFromFile();
4405
- this.loadState(T.serialize(e));
4463
+ let e = await E.loadFromFile();
4464
+ this.loadState(E.serialize(e));
4406
4465
  }
4407
4466
  setLocale(e) {
4408
- ce(e), this.engine.requestRender();
4467
+ se(e), this.engine.requestRender();
4409
4468
  }
4410
4469
  setNumberLocale(e) {
4411
4470
  this.numberLocale = e, this.viewport.setNumberLocale(e), this.priceAxis.setLocale(e), this.leftPriceAxis.setLocale(e), this.crosshairHandler.setLocale(e), this.timeAxis.setLocale(e), this.chartLegend.setLocale(e), this.crosshairTooltip.setLocale(e), this.pinnedTooltip.setLocale(e), this.currentPriceLine.setLocale(e), this.updateViewportAndRender();
@@ -4443,13 +4502,14 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4443
4502
  ...this.marketConfig.priceLimits,
4444
4503
  referencePrice: e
4445
4504
  }
4446
- }, this.engine.requestRender());
4505
+ }, this.syncRenderContext(), this.engine.requestRender());
4447
4506
  }
4448
4507
  getFeatures() {
4449
4508
  return this.features;
4450
4509
  }
4451
4510
  setFeatures(e) {
4452
- Object.assign(this.features, e), (e.crosshair === !1 || e.crosshairTooltip === !1) && this.crosshairTooltip.hide(), e.grid !== void 0 && this.engine.requestRender(r.Background), e.volume !== void 0 && (this.volumeRenderer.setVisible(e.volume), this.updateViewportAndRender()), e.drawings === !1 && this.drawingManager.setActiveTool(null), e.trading === !1 && (this.tradingManager.setOrders([]), this.tradingManager.setPositions([])), e.keyboard !== void 0 && this.keyboardHandler?.setEnabled(e.keyboard), this.engine.requestRender();
4511
+ let t = this.getLegendBottom();
4512
+ Object.assign(this.features, e), e.legend !== void 0 && this.getLegendBottom() !== t && this.eventBus.emit("legendResize", { bottom: this.getLegendBottom() }), (e.crosshair === !1 || e.crosshairTooltip === !1) && this.crosshairTooltip.hide(), e.grid !== void 0 && this.engine.requestRender(r.Background), e.volume !== void 0 && (this.volumeRenderer.setVisible(e.volume), this.updateViewportAndRender()), e.drawings === !1 && this.drawingManager.setActiveTool(null), e.trading === !1 && (this.tradingManager.setOrders([]), this.tradingManager.setPositions([])), e.keyboard !== void 0 && this.keyboardHandler?.setEnabled(e.keyboard), this.engine.requestRender();
4453
4513
  }
4454
4514
  resize() {
4455
4515
  let e = this.engine.dprManager.readContainerSize();
@@ -4464,14 +4524,14 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4464
4524
  this.disposed = !0, this.stopWatchingVisibility?.(), this.stopWatchingVisibility = null, this.waitForGpu(null), this.countdownInterval && clearInterval(this.countdownInterval), this.history.setLoader(null), this.disableAutoSave(), this.disconnectStream(), this.disconnectExecution(), this.onWindowKeyDown &&= (window.removeEventListener("keydown", this.onWindowKeyDown), null), this.keyboardHandler = null, this.a11y?.destroy(), this.a11y = null, this.interactionManager.detach(), this.tradingManager.destroy(), this.animator.dispose(), this.crosshairTooltip.destroy(), this.pinnedTooltip.destroy(), this.replayRestarting = !0, this.replayManager.dispose(), this.alertManager.dispose(), this.undoRedoManager.clear(), this.engine.destroy(), this.eventBus.destroy(), this.labelWidths.destroy(), this.container.innerHTML = "";
4465
4525
  }
4466
4526
  createChartRenderer(e) {
4467
- let t = Cn(e, (e) => this.pluginManager.getChartType(e));
4527
+ let t = kn(e, (e) => this.pluginManager.getChartType(e));
4468
4528
  return t instanceof Le && t.setPriceText((e) => this.formatPrice(e)), t;
4469
4529
  }
4470
4530
  crosshairSeries() {
4471
4531
  return this.isTimeAligned() ? this.series.bars() : this.getDisplayData();
4472
4532
  }
4473
4533
  getDisplayData() {
4474
- let e = this.series.bars(), t = this.options.chartType === "rangeBars" ? bn(e, (e) => this.stepAt(e)) : void 0;
4534
+ let e = this.series.bars(), t = this.options.chartType === "rangeBars" ? En(e, (e) => this.stepAt(e)) : void 0;
4475
4535
  if (this.displayDataCache && t === this.displayDataStep) return this.displayDataCache;
4476
4536
  if (e.length === 0) return e;
4477
4537
  let n = this.displaySeries(e, t);
@@ -4479,15 +4539,31 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4479
4539
  }
4480
4540
  displaySeries(e, t) {
4481
4541
  let n = this.options.chartType, r = (e) => this.pluginManager.getChartType(e);
4482
- if (n !== "pointAndFigure" || r(n)) return wn(n, e, r, this.chartTypeOptions, t, this.reshapeMemo);
4483
- let { columns: i, boxSize: a } = un(e, this.chartTypeOptions, this.reshapeMemo);
4542
+ if (n !== "pointAndFigure" || r(n)) return An(n, e, r, this.chartTypeOptions, t, this.reshapeMemo);
4543
+ let { columns: i, boxSize: a } = mn(e, this.chartTypeOptions, this.reshapeMemo);
4484
4544
  return this.chartRenderer instanceof Qe && this.chartRenderer.setBoxSize(a), i;
4485
4545
  }
4486
4546
  recalcIndicatorsFrom(e, t) {
4487
- this.indicatorEngine.recalculateFrom(e, t), this.announceIndicatorUpdate(t);
4547
+ if (!this.isTimeAligned()) return this.recalcIndicators(e);
4548
+ this.indicatorEngine.recalculateFrom(e, t), this.indicatorsOnDrawn = null, this.announceIndicatorUpdate(t);
4488
4549
  }
4489
4550
  recalcIndicators(e) {
4490
- this.indicatorEngine.recalculateAll(e), this.announceIndicatorUpdate(0);
4551
+ let t = this.indicatorBars(e);
4552
+ this.indicatorEngine.recalculateAll(t), this.indicatorsOnDrawn = t === e ? null : t, this.announceIndicatorUpdate(0);
4553
+ }
4554
+ exportBars() {
4555
+ if (this.isTimeAligned()) return this.series.bars();
4556
+ let e = this.getDisplayData(), t = Dt(e);
4557
+ return e.map((e, n) => ({
4558
+ ...e,
4559
+ time: t[n]?.time ?? e.time
4560
+ }));
4561
+ }
4562
+ indicatorBars(e = this.series.bars()) {
4563
+ return this.isTimeAligned() ? e : this.getDisplayData();
4564
+ }
4565
+ syncIndicatorBars(e) {
4566
+ (this.isTimeAligned() ? this.indicatorsOnDrawn === null : this.indicatorsOnDrawn === e) || this.recalcIndicators(this.series.bars());
4491
4567
  }
4492
4568
  announceIndicatorUpdate(e) {
4493
4569
  if (this.indicatorUpdateFrom !== null) {
@@ -4523,7 +4599,9 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4523
4599
  this.panelInfoCache = null, this.fitDataAndAxes(), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents();
4524
4600
  }
4525
4601
  applyDataToViewport(e = !1) {
4526
- let t = this.getDisplayData(), n = this.options.autoScale !== !1 || this.priceFitPending;
4602
+ let t = this.getDisplayData();
4603
+ this.syncIndicatorBars(t);
4604
+ let n = this.options.autoScale !== !1 || this.priceFitPending;
4527
4605
  this.viewport.updateData(t, !1), e && (this.viewport.scrollToEnd(), this.viewport.updateData(t, !1));
4528
4606
  let r = this.viewport.getState();
4529
4607
  if (t.length > 0) {
@@ -4534,17 +4612,17 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4534
4612
  }
4535
4613
  fitPriceScale(e, t) {
4536
4614
  if (e.length === 0) return;
4537
- let n = Math.max(0, t.visibleRange.from), r = Math.min(t.visibleRange.to, e.length - 1), i = Jr(Jr(m(e, n, r, 0), this.indicatorEngine.getOverlayPriceRange(n, r)), this.features.compareSymbols && this.comparesDrawn() ? this.compareRenderer.getPriceRange(e, t) : null), a = this.features.volume && this.volumeRenderer.isVisible() && qr(e, n, r) ? this.volumeRenderer.getHeightRatio() + Pr : D;
4615
+ let n = Math.max(0, t.visibleRange.from), r = Math.min(t.visibleRange.to, e.length - 1), i = ei(ei(m(e, n, r, 0), this.indicatorEngine.getOverlayPriceRange(n, r)), this.features.compareSymbols && this.comparesDrawn() ? this.compareRenderer.getPriceRange(e, t) : null), a = this.features.volume && this.volumeRenderer.isVisible() && $r(e, n, r) ? this.volumeRenderer.getHeightRatio() + Br : O;
4538
4616
  this.viewport.setScaleMargins(this.viewport.isInvertScale() ? {
4539
4617
  top: a,
4540
- bottom: D
4618
+ bottom: O
4541
4619
  } : {
4542
- top: D,
4620
+ top: O,
4543
4621
  bottom: a
4544
4622
  }), this.viewport.fitToPrices(i.min, i.max);
4545
4623
  }
4546
4624
  updateViewportAndRender(e = !1) {
4547
- this.resolvedLayoutCache = null, this.panelInfoCache = null, this.layoutManager.setLeftAxisWidth(this.isLeftPriceScaleShown() ? this.leftAxisWidth : 0);
4625
+ this.indicatorEngine.setBarsTimed(this.comparesDrawn()), this.layoutManager.setPanelsAside(this.panesOffChartType()), this.resolvedLayoutCache = null, this.panelInfoCache = null, this.layoutManager.setLeftAxisWidth(this.isLeftPriceScaleShown() ? this.leftAxisWidth : 0);
4548
4626
  let t = this.getResolvedLayout();
4549
4627
  this.viewport.setChartRect(t.mainChartRect), this.fitDataAndAxes(e), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents();
4550
4628
  }
@@ -4561,7 +4639,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4561
4639
  fitLeftAxisWidth() {
4562
4640
  let e = this.leftViewport;
4563
4641
  if (!e) return !1;
4564
- let t = this.themeManager.getTheme(), n = Yn({
4642
+ let t = this.themeManager.getTheme(), n = tr({
4565
4643
  min: e.priceRange.min,
4566
4644
  max: e.priceRange.max,
4567
4645
  lastPrice: null,
@@ -4570,12 +4648,12 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4570
4648
  fontFamily: t.font.family,
4571
4649
  fontSizeSmall: t.font.sizeSmall,
4572
4650
  measure: (e, t) => this.measureText(e, t)
4573
- }), r = Xn(this.leftAxisWidth, n);
4651
+ }), r = nr(this.leftAxisWidth, n);
4574
4652
  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);
4575
4653
  }
4576
4654
  fitPriceAxisWidth() {
4577
4655
  if (!this.features.priceAxis) return !1;
4578
- let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n = Yn({
4656
+ let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n = tr({
4579
4657
  min: e.min,
4580
4658
  max: e.max,
4581
4659
  lastPrice: this.currentPriceLine.getPrice(),
@@ -4586,14 +4664,14 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4586
4664
  fontFamily: t.font.family,
4587
4665
  fontSizeSmall: t.font.sizeSmall,
4588
4666
  measure: (e, t) => this.measureText(e, t)
4589
- }), r = Xn(this.priceAxisWidth, n);
4667
+ }), r = nr(this.priceAxisWidth, n);
4590
4668
  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);
4591
4669
  }
4592
4670
  measureText(e, t) {
4593
4671
  let n = this.engine.layerManager.getLayer(r.Main)?.ctx;
4594
- if (n?.canvas.isConnected) return this.labelWidths.get(e, t, () => Ur(n, e, t));
4672
+ if (n?.canvas.isConnected) return this.labelWidths.get(e, t, () => Yr(n, e, t));
4595
4673
  let i = n ?? this.detachedMeasureContext();
4596
- return i ? Ur(i, e, t) : e.length * 7;
4674
+ return i ? Yr(i, e, t) : e.length * 7;
4597
4675
  }
4598
4676
  detachedMeasureContext() {
4599
4677
  return this.measureCtx === void 0 && (this.measureCtx = typeof document < "u" ? document.createElement("canvas").getContext("2d") : null), this.measureCtx;
@@ -4634,7 +4712,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4634
4712
  buildPanelRenderInfos() {
4635
4713
  if (this.panelInfoCache) return this.panelInfoCache;
4636
4714
  let e = this.getResolvedLayout(), t = this.viewport.getState(), { from: n, to: r } = t.visibleRange, i = e.panels.map((e) => {
4637
- let i = e.config.logScale ? this.indicatorEngine.getPaneValueRange(e.config.id, n, r, !0) : null, a = i ?? this.indicatorEngine.getPaneValueRange(e.config.id, n, r) ?? { ...Or }, o = {
4715
+ 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) ?? { ...Pr }, o = {
4638
4716
  x: e.rect.x,
4639
4717
  y: e.rect.y + 20,
4640
4718
  width: e.rect.width,
@@ -4718,7 +4796,7 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4718
4796
  });
4719
4797
  }
4720
4798
  drawOverlayPlugins(e, t) {
4721
- let n = tr(this.pluginManager.getOverlays(), t);
4799
+ let n = sr(this.pluginManager.getOverlays(), t);
4722
4800
  if (n.length === 0) return;
4723
4801
  let r = {
4724
4802
  viewport: this.viewport.getState(),
@@ -4739,11 +4817,11 @@ var Nr = .08, Pr = a ** -7, Fr = 800, Ir = 20, Lr = 8, Rr = new Set(["horizontal
4739
4817
  };
4740
4818
  }
4741
4819
  };
4742
- function Vr(e) {
4820
+ function qr(e) {
4743
4821
  let t = new Map(e.map((e) => [e.instanceId, e])), n = [], r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = (e) => {
4744
4822
  if (r.has(e.instanceId) || i.has(e.instanceId)) return;
4745
4823
  i.add(e.instanceId);
4746
- let o = [e.pane, ...Object.values(e.params).map((e) => b(e)?.instanceId)];
4824
+ let o = [e.pane, ...Object.values(e.params).map((e) => x(e)?.instanceId)];
4747
4825
  for (let e of o) {
4748
4826
  let n = e ? t.get(e) : void 0;
4749
4827
  n && a(n);
@@ -4753,19 +4831,19 @@ function Vr(e) {
4753
4831
  for (let t of e) a(t);
4754
4832
  return n;
4755
4833
  }
4756
- function Hr(e, t) {
4834
+ function Jr(e, t) {
4757
4835
  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);
4758
4836
  }
4759
- function Ur(e, t, n) {
4837
+ function Yr(e, t, n) {
4760
4838
  let r = e.font;
4761
4839
  e.font = n;
4762
4840
  let i = e.measureText(t).width;
4763
4841
  return e.font = r, i;
4764
4842
  }
4765
- var Wr = 300;
4766
- function Gr(e) {
4843
+ var Xr = 300;
4844
+ function Zr(e) {
4767
4845
  let t = {}, n = e.family;
4768
- typeof n == "string" && n.trim() !== "" && n.length <= Wr && !/[;{}<>\\]|\/\*/.test(n) && (t.family = n);
4846
+ typeof n == "string" && n.trim() !== "" && n.length <= Xr && !/[;{}<>\\]|\/\*/.test(n) && (t.family = n);
4769
4847
  for (let n of [
4770
4848
  "sizeSmall",
4771
4849
  "sizeMedium",
@@ -4776,21 +4854,21 @@ function Gr(e) {
4776
4854
  }
4777
4855
  return t;
4778
4856
  }
4779
- function Kr(e) {
4857
+ function Qr(e) {
4780
4858
  let t = e.tagRadius;
4781
4859
  return typeof t == "number" && Number.isFinite(t) && t >= 0 ? { tagRadius: Math.min(t, 999) } : {};
4782
4860
  }
4783
- function qr(e, t, n) {
4861
+ function $r(e, t, n) {
4784
4862
  for (let r = t; r <= n; r++) if (e[r].volume > 0) return !0;
4785
4863
  return !1;
4786
4864
  }
4787
- function Jr(e, t) {
4865
+ function ei(e, t) {
4788
4866
  return e ? t ? {
4789
4867
  min: Math.min(e.min, t.min),
4790
4868
  max: Math.max(e.max, t.max)
4791
4869
  } : e : t;
4792
4870
  }
4793
- function q(e) {
4871
+ function J(e) {
4794
4872
  return {
4795
4873
  id: e.id,
4796
4874
  price: e.price,
@@ -4805,14 +4883,14 @@ function q(e) {
4805
4883
  bars: e.bars
4806
4884
  };
4807
4885
  }
4808
- var Yr = 8e3, Xr = new Set([
4886
+ var ti = 8e3, ni = new Set([
4809
4887
  "candlestick",
4810
4888
  "line",
4811
4889
  "area",
4812
4890
  "bar",
4813
4891
  "hollowCandle"
4814
- ]), Zr = 10, Qr = 50, $r = .001;
4815
- function ei(e) {
4892
+ ]), ri = 10, ii = 50, ai = .001;
4893
+ function oi(e) {
4816
4894
  return {
4817
4895
  price: null,
4818
4896
  fedTime: null,
@@ -4827,42 +4905,42 @@ function ei(e) {
4827
4905
  held: null
4828
4906
  };
4829
4907
  }
4830
- function ti(e, t) {
4908
+ function si(e, t) {
4831
4909
  let n = e[t + 1];
4832
- return n ? n.time - e[t].time : X(e);
4910
+ return n ? n.time - e[t].time : Z(e);
4833
4911
  }
4834
- function ni(e, t, n) {
4912
+ function ci(e, t, n) {
4835
4913
  let r = e.fedTime;
4836
4914
  if (r === null || !t || t.length === 0 || n.length === 0) return;
4837
- let i = ti(t, Z(t, r)), a = r + (Number.isFinite(i) ? e.fedFraction * i : 0), o = Z(n, a), s = n[o].time;
4915
+ let i = si(t, Q(t, r)), a = r + (Number.isFinite(i) ? e.fedFraction * i : 0), o = Q(n, a), s = n[o].time;
4838
4916
  if (s > a) return;
4839
- let c = ti(n, o);
4917
+ let c = si(n, o);
4840
4918
  if (a === s && o > 0) {
4841
4919
  e.fedTime = n[o - 1].time, e.fedFraction = 1;
4842
4920
  return;
4843
4921
  }
4844
4922
  e.fedTime = s, e.fedFraction = Number.isFinite(c) && c > 0 ? Math.min(1, (a - s) / c) : 0;
4845
4923
  }
4846
- function ri(e, t) {
4847
- let n = Y(e, t), r = e.length - 1;
4848
- return n > r && r >= 0 && e[r].time + X(e) <= t ? r : Math.max(-1, n - 2);
4924
+ function li(e, t) {
4925
+ let n = X(e, t), r = e.length - 1;
4926
+ return n > r && r >= 0 && e[r].time + Z(e) <= t ? r : Math.max(-1, n - 2);
4849
4927
  }
4850
- function ii(e) {
4928
+ function ui(e) {
4851
4929
  let t = Infinity;
4852
4930
  for (let n = Math.max(1, e.length - 10); n < e.length; n++) t = Math.min(t, e[n].time - e[n - 1].time);
4853
4931
  return t;
4854
4932
  }
4855
- function ai(e, t) {
4856
- if (!(ii(e) < ii(t))) return !1;
4857
- let n = Math.max(0, e.length - Qr);
4933
+ function di(e, t) {
4934
+ if (!(ui(e) < ui(t))) return !1;
4935
+ let n = Math.max(0, e.length - ii);
4858
4936
  for (let r = n; r < e.length; r++) {
4859
- let n = t[Z(t, e[r].time)], i = (n.high - n.low) * $r + 2 ** -52;
4937
+ let n = t[Q(t, e[r].time)], i = (n.high - n.low) * ai + 2 ** -52;
4860
4938
  if (e[r].close > n.high + i || e[r].close < n.low - i) return !1;
4861
4939
  }
4862
4940
  return !0;
4863
4941
  }
4864
- var oi = 500;
4865
- function J(e, t) {
4942
+ var fi = 500;
4943
+ function Y(e, t) {
4866
4944
  let n = 0, r = e.length;
4867
4945
  for (; n < r;) {
4868
4946
  let i = n + r >> 1;
@@ -4870,7 +4948,7 @@ function J(e, t) {
4870
4948
  }
4871
4949
  return n;
4872
4950
  }
4873
- function Y(e, t) {
4951
+ function X(e, t) {
4874
4952
  let n = 0, r = e.length;
4875
4953
  for (; n < r;) {
4876
4954
  let i = n + r >> 1;
@@ -4878,20 +4956,20 @@ function Y(e, t) {
4878
4956
  }
4879
4957
  return n;
4880
4958
  }
4881
- function si(e) {
4959
+ function pi(e) {
4882
4960
  let t = 0, n = 0;
4883
4961
  for (let r = 1; r < e.length; r++) e[r].low < e[t].low && (t = r), e[r].high > e[n].high && (n = r);
4884
4962
  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];
4885
4963
  return [...a ? [r, i] : [i, r], [o.close, o.time]];
4886
4964
  }
4887
- function X(e) {
4965
+ function Z(e) {
4888
4966
  let t = 0;
4889
4967
  for (let n = Math.max(1, e.length - 10); n < e.length; n++) t = Math.max(t, e[n].time - e[n - 1].time);
4890
4968
  return t > 0 ? t : Infinity;
4891
4969
  }
4892
- function ci(e, t) {
4970
+ function mi(e, t) {
4893
4971
  if (t.length === 0) return null;
4894
- let n = t[t.length - 1].time + X(t), r = e.filter((e) => jn(e) && e.time >= t[0].time && e.time < n).sort((e, t) => e.time - t.time), i = [];
4972
+ let n = t[t.length - 1].time + Z(t), r = e.filter((e) => Ln(e) && e.time >= t[0].time && e.time < n).sort((e, t) => e.time - t.time), i = [];
4895
4973
  for (let e of r) (i.length === 0 || i[i.length - 1].time !== e.time) && i.push(e);
4896
4974
  if (i.length === 0) return null;
4897
4975
  let a = t.findIndex((e) => e.time >= i[0].time);
@@ -4899,7 +4977,7 @@ function ci(e, t) {
4899
4977
  let o = t.slice(0, a), s = i.filter((e) => e.time >= t[a].time);
4900
4978
  return [...o, ...s];
4901
4979
  }
4902
- function Z(e, t) {
4980
+ function Q(e, t) {
4903
4981
  let n = 0, r = e.length - 1;
4904
4982
  for (; n < r;) {
4905
4983
  let i = n + r + 1 >> 1;
@@ -4907,37 +4985,37 @@ function Z(e, t) {
4907
4985
  }
4908
4986
  return n;
4909
4987
  }
4910
- function li(e, t, n) {
4988
+ function hi(e, t, n) {
4911
4989
  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;
4912
4990
  for (let t = 0; t < e.length && e[t].time < i; t++) a = t;
4913
4991
  return Math.max(0, a);
4914
4992
  }
4915
- function ui(e, t, n) {
4993
+ function gi(e, t, n) {
4916
4994
  let r = n;
4917
4995
  for (; r > 0 && t[r - 1].time >= e.time;) r--;
4918
4996
  let i = {
4919
4997
  ...t[r],
4920
4998
  time: e.time
4921
4999
  };
4922
- for (let e = r + 1; e <= n; e++) i = mi(i, t[e]);
5000
+ for (let e = r + 1; e <= n; e++) i = bi(i, t[e]);
4923
5001
  return i;
4924
5002
  }
4925
- function di(e, t, n, r) {
5003
+ function _i(e, t, n, r) {
4926
5004
  let i = e[n + 1], a = t[r + 1];
4927
5005
  return i !== void 0 && a !== void 0 && i.time >= a.time;
4928
5006
  }
4929
- function fi(e, t) {
5007
+ function vi(e, t) {
4930
5008
  let n = /* @__PURE__ */ new Map();
4931
5009
  for (let r of e) {
4932
- let e = t[Z(t, r.time)].time, i = n.get(e);
5010
+ let e = t[Q(t, r.time)].time, i = n.get(e);
4933
5011
  i ? i.push(r) : n.set(e, [r]);
4934
5012
  }
4935
5013
  return n;
4936
5014
  }
4937
- function pi() {
5015
+ function yi() {
4938
5016
  return typeof matchMedia == "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
4939
5017
  }
4940
- function mi(e, t) {
5018
+ function bi(e, t) {
4941
5019
  return {
4942
5020
  time: e.time,
4943
5021
  open: e.open,
@@ -4949,26 +5027,26 @@ function mi(e, t) {
4949
5027
  }
4950
5028
  //#endregion
4951
5029
  //#region src/io/parseOHLCV.ts
4952
- var hi = [
5030
+ var xi = [
4953
5031
  "time",
4954
5032
  "timestamp",
4955
5033
  "date",
4956
5034
  "datetime",
4957
5035
  "t"
4958
- ], gi = ["open", "o"], _i = ["high", "h"], vi = ["low", "l"], yi = ["close", "c"], bi = [
5036
+ ], Si = ["open", "o"], Ci = ["high", "h"], wi = ["low", "l"], Ti = ["close", "c"], Ei = [
4959
5037
  "volume",
4960
5038
  "vol",
4961
5039
  "v"
4962
5040
  ];
4963
- function xi(e) {
5041
+ function Di(e) {
4964
5042
  let t = e.trim();
4965
- return t ? t[0] === "[" || t[0] === "{" ? Si(t) : Ci(t) : {
5043
+ return t ? t[0] === "[" || t[0] === "{" ? Oi(t) : ki(t) : {
4966
5044
  data: [],
4967
5045
  rowCount: 0,
4968
5046
  skipped: 0
4969
5047
  };
4970
5048
  }
4971
- function Si(e) {
5049
+ function Oi(e) {
4972
5050
  let t;
4973
5051
  try {
4974
5052
  t = JSON.parse(e);
@@ -4978,19 +5056,19 @@ function Si(e) {
4978
5056
  if (!Array.isArray(t)) throw Error("Expected a JSON array of OHLCV rows");
4979
5057
  let n = [], r = 0;
4980
5058
  for (let e of t) {
4981
- let t = Array.isArray(e) ? Oi(e) : Di(e);
5059
+ let t = Array.isArray(e) ? Pi(e) : Ni(e);
4982
5060
  t ? n.push(t) : r++;
4983
5061
  }
4984
- return Ai(n, t.length, r);
5062
+ return Ii(n, t.length, r);
4985
5063
  }
4986
- function Ci(e) {
5064
+ function ki(e) {
4987
5065
  let t = e.split(/\r?\n/).filter((e) => e.trim().length > 0);
4988
5066
  if (t.length === 0) return {
4989
5067
  data: [],
4990
5068
  rowCount: 0,
4991
5069
  skipped: 0
4992
5070
  };
4993
- let n = wi(t[0]), r = Ti(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? Ei(r) : {
5071
+ let n = Ai(t[0]), r = ji(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? Mi(r) : {
4994
5072
  time: 0,
4995
5073
  open: 1,
4996
5074
  high: 2,
@@ -5001,7 +5079,7 @@ function Ci(e) {
5001
5079
  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");
5002
5080
  let o = [], s = 0;
5003
5081
  for (let e = +!!i; e < t.length; e++) {
5004
- let r = Ti(t[e], n), i = ki(r[a.time]), c = Q(r[a.open]), l = Q(r[a.high]), u = Q(r[a.low]), d = Q(r[a.close]), f = a.volume >= 0 ? Number(r[a.volume]) : 0;
5082
+ let r = ji(t[e], n), i = Fi(r[a.time]), c = $(r[a.open]), l = $(r[a.high]), u = $(r[a.low]), d = $(r[a.close]), f = a.volume >= 0 ? Number(r[a.volume]) : 0;
5005
5083
  if (i === null || ![
5006
5084
  c,
5007
5085
  l,
@@ -5020,9 +5098,9 @@ function Ci(e) {
5020
5098
  volume: Number.isFinite(f) ? f : 0
5021
5099
  });
5022
5100
  }
5023
- return Ai(o, t.length - +!!i, s);
5101
+ return Ii(o, t.length - +!!i, s);
5024
5102
  }
5025
- function wi(e) {
5103
+ function Ai(e) {
5026
5104
  let t = {
5027
5105
  ",": 0,
5028
5106
  ";": 0,
@@ -5034,7 +5112,7 @@ function wi(e) {
5034
5112
  for (let [e, i] of Object.entries(t)) i > r && (n = e, r = i);
5035
5113
  return n;
5036
5114
  }
5037
- function Ti(e, t) {
5115
+ function ji(e, t) {
5038
5116
  let n = [], r = "", i = !1;
5039
5117
  for (let a = 0; a < e.length; a++) {
5040
5118
  let o = e[a];
@@ -5042,25 +5120,25 @@ function Ti(e, t) {
5042
5120
  }
5043
5121
  return n.push(r), n;
5044
5122
  }
5045
- function Ei(e) {
5123
+ function Mi(e) {
5046
5124
  let t = (t) => e.findIndex((e) => t.includes(e));
5047
5125
  return {
5048
- time: t(hi),
5049
- open: t(gi),
5050
- high: t(_i),
5051
- low: t(vi),
5052
- close: t(yi),
5053
- volume: t(bi)
5126
+ time: t(xi),
5127
+ open: t(Si),
5128
+ high: t(Ci),
5129
+ low: t(wi),
5130
+ close: t(Ti),
5131
+ volume: t(Ei)
5054
5132
  };
5055
5133
  }
5056
- function Di(e) {
5134
+ function Ni(e) {
5057
5135
  let t = (t) => {
5058
5136
  for (let n of t) {
5059
5137
  if (e[n] !== void 0) return e[n];
5060
5138
  let t = n.toUpperCase();
5061
5139
  if (e[t] !== void 0) return e[t];
5062
5140
  }
5063
- }, n = ki(String(t(hi) ?? "")), r = Number(t(gi)), i = Number(t(_i)), a = Number(t(vi)), o = Number(t(yi)), s = Number(t(bi) ?? 0);
5141
+ }, n = Fi(String(t(xi) ?? "")), r = Number(t(Si)), i = Number(t(Ci)), a = Number(t(wi)), o = Number(t(Ti)), s = Number(t(Ei) ?? 0);
5064
5142
  return n === null || ![
5065
5143
  r,
5066
5144
  i,
@@ -5075,9 +5153,9 @@ function Di(e) {
5075
5153
  volume: Number.isFinite(s) ? s : 0
5076
5154
  };
5077
5155
  }
5078
- function Oi(e) {
5156
+ function Pi(e) {
5079
5157
  if (e.length < 5) return null;
5080
- let t = ki(String(e[0])), n = Number(e[1]), r = Number(e[2]), i = Number(e[3]), a = Number(e[4]), o = e.length >= 6 ? Number(e[5]) : 0;
5158
+ let t = Fi(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;
5081
5159
  return t === null || ![
5082
5160
  n,
5083
5161
  r,
@@ -5092,18 +5170,18 @@ function Oi(e) {
5092
5170
  volume: Number.isFinite(o) ? o : 0
5093
5171
  };
5094
5172
  }
5095
- function Q(e) {
5173
+ function $(e) {
5096
5174
  return e === void 0 || e.trim() === "" ? NaN : Number(e);
5097
5175
  }
5098
- function ki(e) {
5176
+ function Fi(e) {
5099
5177
  let t = e.trim();
5100
5178
  if (!t) return null;
5101
5179
  let n = Number(t);
5102
- if (Number.isFinite(n) && n > 0) return y(n);
5180
+ if (Number.isFinite(n) && n > 0) return b(n);
5103
5181
  let r = Date.parse(t);
5104
5182
  return Number.isFinite(r) ? r : null;
5105
5183
  }
5106
- function Ai(e, t, n) {
5184
+ function Ii(e, t, n) {
5107
5185
  e.sort((e, t) => e.time - t.time);
5108
5186
  let r = [];
5109
5187
  for (let t of e) r.length > 0 && r[r.length - 1].time === t.time ? r[r.length - 1] = t : r.push(t);
@@ -5115,7 +5193,7 @@ function Ai(e, t, n) {
5115
5193
  }
5116
5194
  //#endregion
5117
5195
  //#region src/io/DragDropImporter.ts
5118
- var ji = class {
5196
+ var Li = class {
5119
5197
  host;
5120
5198
  overlay = null;
5121
5199
  callbacks;
@@ -5136,19 +5214,19 @@ var ji = class {
5136
5214
  this.host.removeEventListener("dragenter", this.bound.dragenter), this.host.removeEventListener("dragover", this.bound.dragover), this.host.removeEventListener("dragleave", this.bound.dragleave), this.host.removeEventListener("drop", this.bound.drop), this.hideOverlay();
5137
5215
  }
5138
5216
  onDragEnter(e) {
5139
- Mi(e) && (e.preventDefault(), this.depth++, this.showOverlay());
5217
+ Ri(e) && (e.preventDefault(), this.depth++, this.showOverlay());
5140
5218
  }
5141
5219
  onDragOver(e) {
5142
- Mi(e) && (e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = "copy"));
5220
+ Ri(e) && (e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = "copy"));
5143
5221
  }
5144
5222
  onDragLeave(e) {
5145
- Mi(e) && (this.depth = Math.max(0, this.depth - 1), this.depth === 0 && this.hideOverlay());
5223
+ Ri(e) && (this.depth = Math.max(0, this.depth - 1), this.depth === 0 && this.hideOverlay());
5146
5224
  }
5147
5225
  async onDrop(e) {
5148
5226
  e.preventDefault(), this.depth = 0, this.hideOverlay();
5149
5227
  let t = e.dataTransfer?.files?.[0];
5150
5228
  if (t) try {
5151
- let e = xi(await t.text());
5229
+ let e = Di(await t.text());
5152
5230
  if (e.data.length === 0) throw Error(`No valid OHLCV rows found in "${t.name}"`);
5153
5231
  this.callbacks.onData(e.data, e, t);
5154
5232
  } catch (e) {
@@ -5179,12 +5257,12 @@ var ji = class {
5179
5257
  this.overlay?.remove(), this.overlay = null;
5180
5258
  }
5181
5259
  };
5182
- function Mi(e) {
5260
+ function Ri(e) {
5183
5261
  return e.dataTransfer?.types?.includes("Files") ?? !1;
5184
5262
  }
5185
5263
  //#endregion
5186
5264
  //#region src/state/layoutStorage.ts
5187
- function Ni(e) {
5265
+ function zi(e) {
5188
5266
  let t = {
5189
5267
  id: e.id,
5190
5268
  name: e.name,
@@ -5192,11 +5270,11 @@ function Ni(e) {
5192
5270
  };
5193
5271
  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;
5194
5272
  }
5195
- var Pi = (e, t) => t.updatedAt - e.updatedAt;
5196
- function Fi(e) {
5273
+ var Bi = (e, t) => t.updatedAt - e.updatedAt;
5274
+ function Vi(e) {
5197
5275
  if (typeof e != "object" || !e) return null;
5198
5276
  let t = e;
5199
- return typeof t.id != "string" || !t.id || typeof t.name != "string" || typeof t.updatedAt != "number" || !Number.isFinite(t.updatedAt) ? null : Ni({
5277
+ return typeof t.id != "string" || !t.id || typeof t.name != "string" || typeof t.updatedAt != "number" || !Number.isFinite(t.updatedAt) ? null : zi({
5200
5278
  id: t.id,
5201
5279
  name: t.name,
5202
5280
  updatedAt: t.updatedAt,
@@ -5205,17 +5283,17 @@ function Fi(e) {
5205
5283
  kind: typeof t.kind == "string" ? t.kind : void 0
5206
5284
  });
5207
5285
  }
5208
- function Ii(e) {
5209
- let t = Fi(e), n = t ? e.content : void 0;
5286
+ function Hi(e) {
5287
+ let t = Vi(e), n = t ? e.content : void 0;
5210
5288
  return t && typeof n == "string" ? {
5211
5289
  ...t,
5212
5290
  content: n
5213
5291
  } : null;
5214
5292
  }
5215
- function Li(e = []) {
5293
+ function Ui(e = []) {
5216
5294
  let t = new Map(e.map((e) => [e.id, { ...e }]));
5217
5295
  return {
5218
- list: () => [...t.values()].map(Ni).sort(Pi),
5296
+ list: () => [...t.values()].map(zi).sort(Bi),
5219
5297
  load: (e) => {
5220
5298
  let n = t.get(e);
5221
5299
  return n ? { ...n } : null;
@@ -5228,7 +5306,7 @@ function Li(e = []) {
5228
5306
  }
5229
5307
  };
5230
5308
  }
5231
- function Ri(e = "tcw:layouts:") {
5309
+ function Wi(e = "tcw:layouts:") {
5232
5310
  let t = `${e}index`, n = (t) => `${e}item:${t}`, r = () => {
5233
5311
  let e;
5234
5312
  try {
@@ -5236,10 +5314,10 @@ function Ri(e = "tcw:layouts:") {
5236
5314
  } catch {
5237
5315
  return [];
5238
5316
  }
5239
- return Array.isArray(e) ? e.map(Fi).filter((e) => e !== null) : [];
5317
+ return Array.isArray(e) ? e.map(Vi).filter((e) => e !== null) : [];
5240
5318
  }, i = (e) => localStorage.setItem(t, JSON.stringify(e));
5241
5319
  return {
5242
- list: () => r().sort(Pi),
5320
+ list: () => r().sort(Bi),
5243
5321
  load: (e) => {
5244
5322
  let t = r().find((t) => t.id === e), i = t ? localStorage.getItem(n(e)) : null;
5245
5323
  return t && i !== null ? {
@@ -5248,7 +5326,7 @@ function Ri(e = "tcw:layouts:") {
5248
5326
  } : null;
5249
5327
  },
5250
5328
  save: (e) => {
5251
- localStorage.setItem(n(e.id), e.content), i([...r().filter((t) => t.id !== e.id), Ni(e)]);
5329
+ localStorage.setItem(n(e.id), e.content), i([...r().filter((t) => t.id !== e.id), zi(e)]);
5252
5330
  },
5253
5331
  remove: (e) => {
5254
5332
  i(r().filter((t) => t.id !== e)), localStorage.removeItem(n(e));
@@ -5257,14 +5335,14 @@ function Ri(e = "tcw:layouts:") {
5257
5335
  }
5258
5336
  //#endregion
5259
5337
  //#region src/state/LayoutSession.ts
5260
- var zi = 80;
5261
- function $(e) {
5338
+ var Gi = 80;
5339
+ function Ki(e) {
5262
5340
  return e.replace(/\s+/g, " ").trim().slice(0, 80).trim() || null;
5263
5341
  }
5264
- function Bi() {
5342
+ function qi() {
5265
5343
  return globalThis.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
5266
5344
  }
5267
- function Vi(e) {
5345
+ function Ji(e) {
5268
5346
  let { id: t, name: n, symbol: r, timeframe: i, updatedAt: a, kind: o } = e;
5269
5347
  return {
5270
5348
  id: t,
@@ -5275,7 +5353,7 @@ function Vi(e) {
5275
5353
  ...o === void 0 ? {} : { kind: o }
5276
5354
  };
5277
5355
  }
5278
- var Hi = class {
5356
+ var Yi = class {
5279
5357
  currentLayout = null;
5280
5358
  savedContent = null;
5281
5359
  dirty = !1;
@@ -5291,7 +5369,7 @@ var Hi = class {
5291
5369
  now;
5292
5370
  newId;
5293
5371
  constructor(e, t, n = {}) {
5294
- this.storage = e, this.host = t, this.options = n, this.autoSave = n.autoSave ?? !0, this.debounceMs = n.debounceMs ?? 1500, this.kind = n.kind ?? "chart", this.now = n.now ?? Date.now, this.newId = n.newId ?? Bi;
5372
+ this.storage = e, this.host = t, this.options = n, this.autoSave = n.autoSave ?? !0, this.debounceMs = n.debounceMs ?? 1500, this.kind = n.kind ?? "chart", this.now = n.now ?? Date.now, this.newId = n.newId ?? qi;
5295
5373
  }
5296
5374
  current() {
5297
5375
  return this.currentLayout;
@@ -5307,7 +5385,7 @@ var Hi = class {
5307
5385
  }
5308
5386
  async list() {
5309
5387
  let e = await this.storage.list();
5310
- return Array.isArray(e) ? e.map(Fi).filter((e) => e !== null && (e.kind ?? "chart") === this.kind).sort((e, t) => t.updatedAt - e.updatedAt) : [];
5388
+ return Array.isArray(e) ? e.map(Vi).filter((e) => e !== null && (e.kind ?? "chart") === this.kind).sort((e, t) => t.updatedAt - e.updatedAt) : [];
5311
5389
  }
5312
5390
  save() {
5313
5391
  return this.queue(() => {
@@ -5316,12 +5394,12 @@ var Hi = class {
5316
5394
  });
5317
5395
  }
5318
5396
  saveAs(e) {
5319
- let t = $(e);
5397
+ let t = Ki(e);
5320
5398
  return t ? this.queue(() => this.write(this.newId(), t)) : Promise.reject(/* @__PURE__ */ Error("A layout needs a name"));
5321
5399
  }
5322
5400
  open(e) {
5323
5401
  return this.queue(async () => {
5324
- let t = Ii(await this.storage.load(e));
5402
+ let t = Hi(await this.storage.load(e));
5325
5403
  if (!t || t.id !== e || (t.kind ?? "chart") !== this.kind || this.destroyed) return !1;
5326
5404
  this.cancelTimer(), this.applying++;
5327
5405
  try {
@@ -5331,13 +5409,13 @@ var Hi = class {
5331
5409
  } finally {
5332
5410
  this.applying--;
5333
5411
  }
5334
- return this.cancelTimer(), this.currentLayout = Vi(t), this.savedContent = this.host.capture().content, this.dirty = !1, this.notify(), !0;
5412
+ return this.cancelTimer(), this.currentLayout = Ji(t), this.savedContent = this.host.capture().content, this.dirty = !1, this.notify(), !0;
5335
5413
  });
5336
5414
  }
5337
5415
  rename(e, t) {
5338
- let n = $(t);
5416
+ let n = Ki(t);
5339
5417
  return n ? this.queue(async () => {
5340
- let t = Ii(await this.storage.load(e));
5418
+ let t = Hi(await this.storage.load(e));
5341
5419
  !t || t.id !== e || (await this.storage.save({
5342
5420
  ...t,
5343
5421
  name: n
@@ -5415,7 +5493,7 @@ var Hi = class {
5415
5493
  content: n.content
5416
5494
  };
5417
5495
  await this.storage.save(r);
5418
- let i = Vi(r);
5496
+ let i = Ji(r);
5419
5497
  return this.currentLayout = i, this.savedContent = n.content, this.dirty = !1, this.notify(), i;
5420
5498
  }
5421
5499
  forget() {
@@ -5436,6 +5514,6 @@ var Hi = class {
5436
5514
  }
5437
5515
  };
5438
5516
  //#endregion
5439
- export { In as C, z as D, L as E, on as O, zn as S, B as T, rr as _, Li as a, W as b, Br as c, Er as d, Dr as f, nr as g, ir as h, Ri as i, Ar as l, ar as m, zi as n, ji as o, or as p, $ as r, xi as s, Hi as t, kr as u, er as v, Pn as w, Wn as x, tr as y };
5517
+ export { Hn as C, B as D, R as E, un as O, Gn as S, V as T, lr as _, Ui as a, G as b, Kr as c, Mr as d, Nr as f, cr as g, ur as h, Wi as i, Ir as l, dr as m, Gi as n, Li as o, fr as p, Ki as r, Di as s, Yi as t, Fr as u, or as v, Bn as w, Xn as x, sr as y };
5440
5518
 
5441
- //# sourceMappingURL=LayoutSession-D7uQq3jX.js.map
5519
+ //# sourceMappingURL=LayoutSession-DAqzoWkF.js.map