@tradecanvas/chart 1.11.0 → 1.13.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 (121) hide show
  1. package/README.md +60 -14
  2. package/dist/Chart.d.ts +77 -10
  3. package/dist/Chart.d.ts.map +1 -1
  4. package/dist/LayoutSession-BOUFA2gH.cjs +2 -0
  5. package/dist/LayoutSession-BOUFA2gH.cjs.map +1 -0
  6. package/dist/{LayoutSession-BF1iuUrs.js → LayoutSession-CiDh-H9-.js} +488 -323
  7. package/dist/LayoutSession-CiDh-H9-.js.map +1 -0
  8. package/dist/ThemeManager.d.ts +36 -2
  9. package/dist/ThemeManager.d.ts.map +1 -1
  10. package/dist/charts/ChartTypeStrategy.d.ts +2 -0
  11. package/dist/charts/ChartTypeStrategy.d.ts.map +1 -1
  12. package/dist/{i18n-CiQ8EDVs.js → i18n-BU-BoBDZ.js} +6 -2
  13. package/dist/i18n-BU-BoBDZ.js.map +1 -0
  14. package/dist/{i18n-WsLA9SmD.cjs → i18n-DkzAxytR.cjs} +2 -2
  15. package/dist/i18n-DkzAxytR.cjs.map +1 -0
  16. package/dist/index.cjs +1 -1
  17. package/dist/index.d.ts +3 -2
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +30 -30
  20. package/dist/index.js.map +1 -1
  21. package/dist/style/styleOptions.d.ts +8 -0
  22. package/dist/style/styleOptions.d.ts.map +1 -0
  23. package/dist/widget/ChartWidget.d.ts +63 -4
  24. package/dist/widget/ChartWidget.d.ts.map +1 -1
  25. package/dist/widget/ChartWidgetGrid.d.ts +16 -1
  26. package/dist/widget/ChartWidgetGrid.d.ts.map +1 -1
  27. package/dist/widget/WidgetAccountPanel.d.ts.map +1 -1
  28. package/dist/widget/WidgetAlertsPanel.d.ts.map +1 -1
  29. package/dist/widget/WidgetChartNav.d.ts.map +1 -1
  30. package/dist/widget/WidgetContextMenu.d.ts.map +1 -1
  31. package/dist/widget/WidgetDataWindow.d.ts.map +1 -1
  32. package/dist/widget/WidgetDepthLadder.d.ts.map +1 -1
  33. package/dist/widget/WidgetDrawingSettings.d.ts.map +1 -1
  34. package/dist/widget/WidgetDrawingSidebar.d.ts +9 -1
  35. package/dist/widget/WidgetDrawingSidebar.d.ts.map +1 -1
  36. package/dist/widget/WidgetGoToDate.d.ts.map +1 -1
  37. package/dist/widget/WidgetIndicatorLegend.d.ts.map +1 -1
  38. package/dist/widget/WidgetObjectTree.d.ts.map +1 -1
  39. package/dist/widget/WidgetReplayBar.d.ts.map +1 -1
  40. package/dist/widget/WidgetStatusBar.d.ts +10 -1
  41. package/dist/widget/WidgetStatusBar.d.ts.map +1 -1
  42. package/dist/widget/WidgetStyles.d.ts.map +1 -1
  43. package/dist/widget/WidgetSymbolInfo.d.ts.map +1 -1
  44. package/dist/widget/WidgetToolbar.d.ts +6 -0
  45. package/dist/widget/WidgetToolbar.d.ts.map +1 -1
  46. package/dist/widget/hostButtons.d.ts +5 -0
  47. package/dist/widget/hostButtons.d.ts.map +1 -0
  48. package/dist/widget/hostMenus.d.ts +7 -0
  49. package/dist/widget/hostMenus.d.ts.map +1 -0
  50. package/dist/widget/i18n.d.ts.map +1 -1
  51. package/dist/widget/index.cjs +45 -12
  52. package/dist/widget/index.cjs.map +1 -1
  53. package/dist/widget/index.d.ts +3 -1
  54. package/dist/widget/index.d.ts.map +1 -1
  55. package/dist/widget/index.js +1677 -1136
  56. package/dist/widget/index.js.map +1 -1
  57. package/dist/widget/legendValues.d.ts +4 -2
  58. package/dist/widget/legendValues.d.ts.map +1 -1
  59. package/dist/widget/locales/ar.d.ts.map +1 -1
  60. package/dist/widget/locales/cs.d.ts +4 -0
  61. package/dist/widget/locales/cs.d.ts.map +1 -0
  62. package/dist/widget/locales/da.d.ts +4 -0
  63. package/dist/widget/locales/da.d.ts.map +1 -0
  64. package/dist/widget/locales/de.d.ts.map +1 -1
  65. package/dist/widget/locales/el.d.ts +4 -0
  66. package/dist/widget/locales/el.d.ts.map +1 -0
  67. package/dist/widget/locales/en.d.ts +2 -0
  68. package/dist/widget/locales/en.d.ts.map +1 -1
  69. package/dist/widget/locales/es.d.ts.map +1 -1
  70. package/dist/widget/locales/et.d.ts +4 -0
  71. package/dist/widget/locales/et.d.ts.map +1 -0
  72. package/dist/widget/locales/fa.d.ts +4 -0
  73. package/dist/widget/locales/fa.d.ts.map +1 -0
  74. package/dist/widget/locales/fr.d.ts.map +1 -1
  75. package/dist/widget/locales/he.d.ts.map +1 -1
  76. package/dist/widget/locales/hu.d.ts +4 -0
  77. package/dist/widget/locales/hu.d.ts.map +1 -0
  78. package/dist/widget/locales/id.d.ts.map +1 -1
  79. package/dist/widget/locales/index.cjs +1 -1
  80. package/dist/widget/locales/index.cjs.map +1 -1
  81. package/dist/widget/locales/index.d.ts +15 -1
  82. package/dist/widget/locales/index.d.ts.map +1 -1
  83. package/dist/widget/locales/index.js +10127 -5
  84. package/dist/widget/locales/index.js.map +1 -1
  85. package/dist/widget/locales/it.d.ts +4 -0
  86. package/dist/widget/locales/it.d.ts.map +1 -0
  87. package/dist/widget/locales/ja.d.ts.map +1 -1
  88. package/dist/widget/locales/ko.d.ts.map +1 -1
  89. package/dist/widget/locales/ms.d.ts +4 -0
  90. package/dist/widget/locales/ms.d.ts.map +1 -0
  91. package/dist/widget/locales/nb.d.ts +4 -0
  92. package/dist/widget/locales/nb.d.ts.map +1 -0
  93. package/dist/widget/locales/nl.d.ts +4 -0
  94. package/dist/widget/locales/nl.d.ts.map +1 -0
  95. package/dist/widget/locales/pl.d.ts +4 -0
  96. package/dist/widget/locales/pl.d.ts.map +1 -0
  97. package/dist/widget/locales/pt.d.ts.map +1 -1
  98. package/dist/widget/locales/ro.d.ts +4 -0
  99. package/dist/widget/locales/ro.d.ts.map +1 -0
  100. package/dist/widget/locales/ru.d.ts.map +1 -1
  101. package/dist/widget/locales/sk.d.ts +4 -0
  102. package/dist/widget/locales/sk.d.ts.map +1 -0
  103. package/dist/widget/locales/sv.d.ts +4 -0
  104. package/dist/widget/locales/sv.d.ts.map +1 -0
  105. package/dist/widget/locales/th.d.ts.map +1 -1
  106. package/dist/widget/locales/tr.d.ts.map +1 -1
  107. package/dist/widget/locales/vi.d.ts.map +1 -1
  108. package/dist/widget/locales/zh.d.ts.map +1 -1
  109. package/dist/widget/locales/zhHant.d.ts.map +1 -1
  110. package/dist/widget/types.d.ts +90 -0
  111. package/dist/widget/types.d.ts.map +1 -1
  112. package/dist/widget/widgetConfig.d.ts +12 -0
  113. package/dist/widget/widgetConfig.d.ts.map +1 -1
  114. package/dist/widget/widgetFeatures.d.ts +74 -0
  115. package/dist/widget/widgetFeatures.d.ts.map +1 -0
  116. package/package.json +3 -3
  117. package/dist/LayoutSession-BF1iuUrs.js.map +0 -1
  118. package/dist/LayoutSession-BRw64EVI.cjs +0 -2
  119. package/dist/LayoutSession-BRw64EVI.cjs.map +0 -1
  120. package/dist/i18n-CiQ8EDVs.js.map +0 -1
  121. package/dist/i18n-WsLA9SmD.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, PRICE_AXIS_WIDTH as a, TIME_AXIS_HEIGHT as o, autoPricePrecision as s, computePriceLimits as c, formatPrice as l, fractionTick as u, indicatorSource as d, isValidTimeZone as f, mergeBar as p, normalizeBarTime as m, parseIndicatorSource as h, priceFormatterFor as g, readChartTypeOptions as _, sessionMinute as v, setLocale as ee, stepDecimals as te, tickBarCount as ne, timeframeToMs as y, volumeColor as re, zonedDateFormatter as ie } from "@tradecanvas/commons";
2
- import { AlertDragHandler as ae, AlertManager as oe, Animator as se, AreaRenderer as ce, AxisDragHandler as le, BarCountdown as ue, BarRenderer as de, BaselineRenderer as fe, CandlestickRenderer as pe, ChartLegend as me, ChartStateManager as b, CompareRenderer as he, CompareSymbolIndicator as ge, CrosshairHandler as _e, CrosshairTooltip as ve, CurrentPriceLine as ye, DEFAULT_SESSION_HOURS as be, DataExporter as x, DepthHeatmapRenderer as xe, DrawingManager as Se, DrawingRenderer as Ce, EquivolumeRenderer as we, EventBus as Te, GridRenderer as Ee, HLCAreaRenderer as De, HiLoRenderer as Oe, HollowCandleRenderer as ke, IndicatorEngine as Ae, InteractionManager as je, KagiRenderer as Me, KeyboardHandler as Ne, LineRenderer as Pe, LineWithMarkersRenderer as Fe, MarketProfileRenderer as Ie, MeasureOverlay as Le, PanHandler as Re, PaneResizeHandler as ze, PeriodLevelsRenderer as Be, PinnedTooltip as Ve, PivotMarkersRenderer as He, PointAndFigureRenderer as Ue, PriceAxis as We, PriceAxisAddButton as Ge, PriceLines as Ke, RenderEngine as qe, RenkoRenderer as Je, ReplayManager as Ye, Screenshot as S, SelectionBoxOverlay as Xe, SessionBreaks as Ze, SessionShading as Qe, SignalMarkerManager as $e, SpreadIndicator as et, StepLineRenderer as tt, StreamManager as nt, SymbolSeriesStore as rt, TimeAxis as it, TradeZoneManager as at, TradingManager as ot, TradingRenderer as st, UndoRedoManager as ct, Viewport as lt, VolumeCandleRenderer as ut, VolumeProfileRenderer as dt, VolumeRenderer as ft, Watermark as pt, ZoomHandler as mt, barTimeStepMs as ht, findDominantSwing as gt, isRegularSession as _t, loadWebGLRenderer as vt, mergeSessionHours as yt, rangePresetStart as bt, readAlertOptions as xt, registerBuiltInDrawingTools as St, registerBuiltInIndicators as C, servesTimeframe as w, sourceParam as T, timestampToBarIndex as E, toHeikinAshi as Ct, toKagi as wt, toLineBreak as Tt, toPointAndFigure as Et, toRangeBars as Dt, toRenko as Ot, withResampling as kt, xToBarIndex as At, xToTime as D, 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, PRICE_AXIS_WIDTH as a, TIME_AXIS_HEIGHT as o, autoPricePrecision as s, chartStyleValue as c, computePriceLimits as l, formatPrice as u, fractionTick as d, indicatorSource as f, isValidTimeZone as p, mergeBar as m, normalizeBarTime as h, parseIndicatorSource as g, priceFormatterFor as _, readChartStyleOverrides as v, readChartTypeOptions as y, readIndicatorPlotStyles as b, readPaneStyle as ee, resolveChartTheme as te, sessionMinute as x, setLocale as ne, stepDecimals as re, tickBarCount as ie, timeframeToMs as ae, volumeColor as oe, zonedDateFormatter as se } from "@tradecanvas/commons";
2
+ import { AlertDragHandler as ce, AlertManager as le, Animator as ue, AreaRenderer as de, AxisDragHandler as fe, BarCountdown as pe, BarRenderer as me, BaselineRenderer as he, CandlestickRenderer as ge, ChartLegend as _e, ChartStateManager as S, CompareRenderer as ve, CompareSymbolIndicator as ye, CorrelationCoefficientIndicator as be, CorrelationLogIndicator as xe, CrosshairHandler as Se, CrosshairTooltip as Ce, CurrentPriceLine as we, DEFAULT_SESSION_HOURS as Te, DataExporter as C, DepthHeatmapRenderer as Ee, DrawingManager as De, DrawingRenderer as Oe, EquivolumeRenderer as ke, EventBus as Ae, GridRenderer as je, HLCAreaRenderer as Me, HiLoRenderer as w, HollowCandleRenderer as Ne, IndicatorEngine as T, InteractionManager as Pe, KagiRenderer as Fe, KeyboardHandler as Ie, LineRenderer as Le, LineWithMarkersRenderer as Re, MarketProfileRenderer as ze, MeasureOverlay as Be, PanHandler as Ve, PaneResizeHandler as He, PeriodLevelsRenderer as Ue, PinnedTooltip as We, PivotMarkersRenderer as Ge, PointAndFigureRenderer as E, PriceAxis as D, PriceAxisAddButton as Ke, PriceLines as qe, RenderEngine as Je, RenkoRenderer as Ye, ReplayManager as Xe, Screenshot as O, SelectionBoxOverlay as Ze, SessionBreaks as Qe, SessionShading as $e, SignalMarkerManager as et, SpreadIndicator as tt, StepLineRenderer as nt, StreamManager as rt, SymbolSeriesStore as it, TimeAxis as at, TradeZoneManager as ot, TradingManager as st, TradingRenderer as ct, UndoRedoManager as lt, Viewport as ut, VolumeCandleRenderer as dt, VolumeProfileRenderer as ft, VolumeRenderer as pt, Watermark as mt, ZoomHandler as ht, barTimeStepMs as gt, findDominantSwing as _t, gpuContextsLeft as vt, isRegularSession as yt, loadWebGL as bt, mergeSessionHours as xt, rangePresetStart as St, readAlertOptions as Ct, registerBuiltInDrawingTools as wt, registerBuiltInIndicators as k, servesTimeframe as A, sourceParam as j, timestampToBarIndex as M, toHeikinAshi as Tt, toKagi as Et, toLineBreak as Dt, toPointAndFigure as Ot, toRangeBars as kt, toRenko as N, whenGpuContextFree as At, withResampling as jt, xToBarIndex as Mt, xToTime as P, yToPrice as F } from "@tradecanvas/core";
3
3
  //#region src/regularHours.ts
4
- var Mt = 864e5, Nt = 10;
5
- function Pt(e, t) {
4
+ var Nt = 864e5, Pt = 10;
5
+ function Ft(e, t) {
6
6
  let n = e?.timezone;
7
- if (!n || !f(n) || t.length < 2) return null;
7
+ if (!n || !p(n) || t.length < 2) return null;
8
8
  let r = (e?.sessions ?? []).flatMap((e) => {
9
- let t = v(e.start), n = v(e.end);
9
+ let t = x(e.start), n = x(e.end);
10
10
  return t === null || n === null ? [] : [{
11
11
  startMinute: t,
12
12
  endMinute: n
@@ -14,29 +14,29 @@ function Pt(e, t) {
14
14
  });
15
15
  if (r.length === 0) return null;
16
16
  let i = Infinity;
17
- for (let e = Math.max(1, t.length - Nt); e < t.length; e++) {
18
- let n = m(t[e].time) - m(t[e - 1].time);
17
+ for (let e = Math.max(1, t.length - Pt); e < t.length; e++) {
18
+ let n = h(t[e].time) - h(t[e - 1].time);
19
19
  n > 0 && n < i && (i = n);
20
20
  }
21
- if (!(i < Mt)) return null;
21
+ if (!(i < Nt)) return null;
22
22
  let a = {
23
23
  timeZone: n,
24
24
  windows: r,
25
25
  startMinute: r[0].startMinute,
26
26
  endMinute: r[r.length - 1].endMinute
27
27
  };
28
- return (e) => _t(m(e), a);
28
+ return (e) => yt(h(e), a);
29
29
  }
30
30
  //#endregion
31
31
  //#region src/chartA11y.ts
32
- var Ft = {
32
+ var I = {
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
- }, O = (e, t) => e.replace(/\{(\w+)\}/g, (e, n) => n in t ? String(t[n]) : e), It = [
39
+ }, L = (e, t) => e.replace(/\{(\w+)\}/g, (e, n) => n in t ? String(t[n]) : e), It = [
40
40
  "role",
41
41
  "aria-roledescription",
42
42
  "aria-label",
@@ -55,7 +55,7 @@ var Ft = {
55
55
  };
56
56
  constructor(e, t, n = {}) {
57
57
  this.container = e, this.source = t, this.labels = {
58
- ...Ft,
58
+ ...I,
59
59
  ...n
60
60
  };
61
61
  for (let t of It) this.before.set(t, e.getAttribute(t));
@@ -63,7 +63,7 @@ var Ft = {
63
63
  }
64
64
  setLabels(e) {
65
65
  this.labels = {
66
- ...Ft,
66
+ ...I,
67
67
  ...e
68
68
  }, this.applyLabels();
69
69
  }
@@ -93,7 +93,7 @@ var Ft = {
93
93
  let i = t[this.cursor];
94
94
  this.source.showBar(i.time);
95
95
  let a = this.source.formatPrice;
96
- this.say(O(this.labels.bar, {
96
+ this.say(L(this.labels.bar, {
97
97
  time: this.source.formatTime(i.time),
98
98
  open: a(i.open),
99
99
  high: a(i.high),
@@ -118,7 +118,7 @@ var Ft = {
118
118
  this.labels.typeName ? this.labels.typeName(t) : t,
119
119
  this.source.timeframe()
120
120
  ].filter(Boolean).join(", ");
121
- return O(this.labels.summary, {
121
+ return L(this.labels.summary, {
122
122
  what: n,
123
123
  close: this.source.formatPrice(e[e.length - 1].close)
124
124
  });
@@ -128,7 +128,7 @@ var Ft = {
128
128
  if (e.length === 0) return this.labels.empty;
129
129
  let t = this.source.visibleRange(), n = Math.max(0, Math.min(e.length - 1, Math.ceil(t.from))), r = Math.max(n, Math.min(e.length - 1, Math.floor(t.to))), i = -Infinity, a = Infinity;
130
130
  for (let t = n; t <= r; t++) i = Math.max(i, e[t].high), a = Math.min(a, e[t].low);
131
- return O(this.labels.view, {
131
+ return L(this.labels.view, {
132
132
  count: r - n + 1,
133
133
  from: this.source.formatTime(e[n].time),
134
134
  to: this.source.formatTime(e[r].time),
@@ -174,45 +174,42 @@ function Ut(e) {
174
174
  case "candlestick":
175
175
  case "heikinAshi":
176
176
  case "lineBreak":
177
- case "rangeBars": return new pe();
178
- case "line": return new Pe();
179
- case "area": return new ce();
180
- case "bar": return new de();
181
- case "hollowCandle": return new ke();
182
- case "baseline": return new fe();
183
- case "renko": return new Je();
184
- case "kagi": return new Me();
185
- case "pointAndFigure": return new Ue();
186
- case "volumeCandles": return new ut();
187
- case "equivolume": return new we();
188
- case "hlcArea": return new De();
189
- case "stepLine": return new tt();
190
- case "lineWithMarkers": return new Fe();
191
- case "hiLo": return new Oe();
192
- default: return new pe();
177
+ case "rangeBars": return new ge();
178
+ case "line": return new Le();
179
+ case "area": return new de();
180
+ case "bar": return new me();
181
+ case "hollowCandle": return new Ne();
182
+ case "baseline": return new he();
183
+ case "renko": return new Ye();
184
+ case "kagi": return new Fe();
185
+ case "pointAndFigure": return new E();
186
+ case "volumeCandles": return new dt();
187
+ case "equivolume": return new ke();
188
+ case "hlcArea": return new Me();
189
+ case "stepLine": return new nt();
190
+ case "lineWithMarkers": return new Re();
191
+ case "hiLo": return new w();
192
+ default: return new ge();
193
193
  }
194
194
  }
195
195
  function Wt(e, t, n = {}) {
196
196
  if (t.length === 0) return t;
197
197
  switch (e) {
198
- case "heikinAshi": return Ct(t);
198
+ case "heikinAshi": return Tt(t);
199
199
  case "renko": {
200
200
  let e = n.renko?.boxSize;
201
- return typeof e == "number" ? Ot(t, { brickSize: e }) : Ot(t, {
201
+ return typeof e == "number" ? N(t, { brickSize: e }) : N(t, {
202
202
  brickSize: 0,
203
203
  useATR: !0,
204
204
  atrPeriod: n.renko?.atrPeriod ?? 14
205
205
  });
206
206
  }
207
- case "lineBreak": return Tt(t, n.lineBreak?.lines ?? 3);
208
- case "kagi": return wt(t, n.kagi?.reversal ?? 4, n.kagi?.reversalType ?? "percent");
209
- case "pointAndFigure": {
210
- let e = n.pointAndFigure?.boxSize;
211
- return Et(t, typeof e == "number" ? e : qt(t) * .01, n.pointAndFigure?.reversal ?? 3);
212
- }
207
+ case "lineBreak": return Dt(t, n.lineBreak?.lines ?? 3);
208
+ case "kagi": return Et(t, n.kagi?.reversal ?? 4, n.kagi?.reversalType ?? "percent");
209
+ case "pointAndFigure": return Ot(t, qt(t, n), n.pointAndFigure?.reversal ?? 3);
213
210
  case "rangeBars": {
214
211
  let e = n.rangeBars?.range;
215
- return Dt(t, { rangeSize: typeof e == "number" ? e : qt(t) * .005 });
212
+ return kt(t, { rangeSize: typeof e == "number" ? e : Jt(t) * .005 });
216
213
  }
217
214
  default: return t;
218
215
  }
@@ -231,23 +228,27 @@ function Gt(e) {
231
228
  function Kt(e) {
232
229
  return e !== "heikinAshi" && Gt(e);
233
230
  }
234
- function qt(e) {
231
+ function qt(e, t = {}) {
232
+ let n = t.pointAndFigure?.boxSize;
233
+ return typeof n == "number" ? n : Jt(e) * .01;
234
+ }
235
+ function Jt(e) {
235
236
  let t = 0;
236
237
  for (let n of e) t += n.close;
237
238
  return t / e.length;
238
239
  }
239
- function Jt(e, t) {
240
+ function Yt(e, t) {
240
241
  let n = t?.(e);
241
242
  return n ? n.createRenderer() : Ut(e);
242
243
  }
243
- function Yt(e, t, n, r) {
244
+ function Xt(e, t, n, r) {
244
245
  if (t.length === 0) return t;
245
246
  let i = n?.(e);
246
247
  return i?.transform ? i.transform(t) : Wt(e, t, r);
247
248
  }
248
249
  //#endregion
249
250
  //#region src/state/AutoSaveScheduler.ts
250
- var Xt = class {
251
+ var Zt = class {
251
252
  timer = null;
252
253
  delayMs = 0;
253
254
  key = null;
@@ -277,15 +278,15 @@ var Xt = class {
277
278
  };
278
279
  //#endregion
279
280
  //#region src/DataManager.ts
280
- function k(e) {
281
+ function R(e) {
281
282
  if (!e || typeof e.time != "number" || !Number.isFinite(e.time)) return !1;
282
283
  let { open: t, high: n, low: r, close: i } = e;
283
284
  return !(!isFinite(t) || !isFinite(n) || !isFinite(r) || !isFinite(i) || t < 0 || n < 0 || r < 0 || i < 0 || n < r || e.volume !== void 0 && (!isFinite(e.volume) || e.volume < 0));
284
285
  }
285
- function Zt(e) {
286
+ function Qt(e) {
286
287
  return e.volume !== void 0 && e.high >= e.open && e.high >= e.close && e.low <= e.open && e.low <= e.close;
287
288
  }
288
- function A(e) {
289
+ function z(e) {
289
290
  return {
290
291
  ...e,
291
292
  high: Math.max(e.open, e.high, e.low, e.close),
@@ -293,7 +294,7 @@ function A(e) {
293
294
  volume: e.volume === void 0 ? 0 : Math.max(0, e.volume)
294
295
  };
295
296
  }
296
- var j = class {
297
+ var B = class {
297
298
  data = [];
298
299
  getData() {
299
300
  return this.data;
@@ -302,7 +303,7 @@ var j = class {
302
303
  let t = [];
303
304
  for (let n = 0; n < e.length; n++) {
304
305
  let r = e[n];
305
- k(r) && t.push(Zt(r) ? r : A(r));
306
+ R(r) && t.push(Qt(r) ? r : z(r));
306
307
  }
307
308
  this.data = t;
308
309
  }
@@ -310,7 +311,7 @@ var j = class {
310
311
  let t = this.data.length > 0 ? this.data[0].time : Infinity, n = [];
311
312
  for (let r = 0; r < e.length; r++) {
312
313
  let i = e[r];
313
- !k(i) || i.time >= t || n.push(Zt(i) ? i : A(i));
314
+ !R(i) || i.time >= t || n.push(Qt(i) ? i : z(i));
314
315
  }
315
316
  if (n.length === 0) return 0;
316
317
  n.sort((e, t) => e.time - t.time);
@@ -319,11 +320,11 @@ var j = class {
319
320
  return n.length = r, this.data = n.concat(this.data), r;
320
321
  }
321
322
  appendBar(e) {
322
- k(e) && this.data.push(A(e));
323
+ R(e) && this.data.push(z(e));
323
324
  }
324
325
  updateLastBar(e) {
325
- if (!k(e)) return;
326
- let t = A(e);
326
+ if (!R(e)) return;
327
+ let t = z(e);
327
328
  if (this.data.length === 0) {
328
329
  this.data.push(t);
329
330
  return;
@@ -331,7 +332,7 @@ var j = class {
331
332
  this.data[this.data.length - 1] = t;
332
333
  }
333
334
  updateLastBarFromTick(e) {
334
- this.data.length !== 0 && (!isFinite(e.price) || e.price < 0 || e.volume !== void 0 && (!isFinite(e.volume) || e.volume < 0) || (this.data[this.data.length - 1] = p(this.data[this.data.length - 1], e)));
335
+ this.data.length !== 0 && (!isFinite(e.price) || e.price < 0 || e.volume !== void 0 && (!isFinite(e.volume) || e.volume < 0) || (this.data[this.data.length - 1] = m(this.data[this.data.length - 1], e)));
335
336
  }
336
337
  getLength() {
337
338
  return this.data.length;
@@ -339,7 +340,7 @@ var j = class {
339
340
  clear() {
340
341
  this.data = [];
341
342
  }
342
- }, M = 5e3, Qt = 6e4, $t = 500, en = class {
343
+ }, $t = 5e3, en = 6e4, tn = 500, nn = class {
343
344
  loader = null;
344
345
  pageSize = 500;
345
346
  loading = !1;
@@ -380,7 +381,7 @@ var j = class {
380
381
  try {
381
382
  r = await e(t, this.pageSize);
382
383
  } catch (e) {
383
- return n === this.seq ? (this.loading = !1, this.failures++, this.retryAt = this.now() + Math.min(Qt, M * 2 ** (this.failures - 1)), this.emit({
384
+ return n === this.seq ? (this.loading = !1, this.failures++, this.retryAt = this.now() + Math.min(en, $t * 2 ** (this.failures - 1)), this.emit({
384
385
  state: "error",
385
386
  count: 0,
386
387
  error: e instanceof Error ? e.message : String(e)
@@ -410,34 +411,116 @@ var j = class {
410
411
  now() {
411
412
  return this.host.now ? this.host.now() : Date.now();
412
413
  }
413
- }, N = class {
414
- theme;
414
+ }, rn = class t {
415
+ base;
415
416
  shape = null;
416
- constructor(t) {
417
- !t || t === "dark" ? this.theme = { ...e } : t === "light" ? this.theme = { ...n } : this.theme = { ...t };
417
+ chartType = "candlestick";
418
+ host = {};
419
+ user = /* @__PURE__ */ new Map();
420
+ effective = null;
421
+ constructor(e) {
422
+ this.base = t.read(e);
423
+ }
424
+ static read(t) {
425
+ if (!t || t === "dark") return { ...e };
426
+ if (t === "light") return { ...n };
427
+ let { style: r, ...i } = t;
428
+ return i;
418
429
  }
419
430
  getTheme() {
420
- return this.theme;
431
+ return this.effective ??= te(this.base, this.chartType, this.merged()), this.effective;
432
+ }
433
+ getBaseTheme() {
434
+ return this.base;
421
435
  }
422
- setTheme(t) {
423
- t === "dark" ? this.theme = { ...e } : t === "light" ? this.theme = { ...n } : this.theme = { ...t }, this.shape && (this.theme = {
424
- ...this.theme,
436
+ setTheme(e) {
437
+ this.base = t.read(e), this.shape && (this.base = {
438
+ ...this.base,
425
439
  shape: {
426
- ...this.theme.shape,
440
+ ...this.base.shape,
427
441
  ...this.shape
428
442
  }
429
- });
443
+ }), this.effective = null;
430
444
  }
431
445
  setShape(e) {
432
- this.shape = e ? { ...e } : null, this.theme = {
433
- ...this.theme,
446
+ this.shape = e ? { ...e } : null, this.base = {
447
+ ...this.base,
434
448
  shape: e ? {
435
- ...this.theme.shape,
449
+ ...this.base.shape,
436
450
  ...e
437
- } : this.theme.shape
451
+ } : this.base.shape
452
+ }, this.effective = null;
453
+ }
454
+ setChartType(e) {
455
+ e !== this.chartType && (this.chartType = e, this.effective = null);
456
+ }
457
+ applyOverrides(e, t) {
458
+ let n = { ...this.layer(t) };
459
+ for (let [t, r] of Object.entries(e)) r == null ? delete n[t] : n[t] = r;
460
+ return this.setLayer(t, n);
461
+ }
462
+ setOverrides(e, t) {
463
+ return this.setLayer(t, { ...e });
464
+ }
465
+ resetOverrides(e, t) {
466
+ if (!t) return this.setLayer(e, {});
467
+ let n = { ...this.layer(e) };
468
+ for (let e of t) delete n[e];
469
+ return this.setLayer(e, n);
470
+ }
471
+ getOverrides(e) {
472
+ return { ...this.layer(e) };
473
+ }
474
+ getUserOverrides() {
475
+ let e = {};
476
+ for (let [t, n] of this.user) Object.keys(n).length > 0 && (e[t] = { ...n });
477
+ return e;
478
+ }
479
+ setUserOverrides(e) {
480
+ return JSON.stringify(e) === JSON.stringify(this.getUserOverrides()) ? !1 : (this.user = new Map(Object.entries(e).map(([e, t]) => [e, { ...t }])), this.effective = null, !0);
481
+ }
482
+ getStyleValue(e) {
483
+ return c(this.base, this.merged(), e, this.chartType);
484
+ }
485
+ layer(e) {
486
+ return e === "host" ? this.host : this.user.get(this.base.name) ?? {};
487
+ }
488
+ setLayer(e, t) {
489
+ return JSON.stringify(t) === JSON.stringify(this.layer(e)) ? !1 : (e === "host" ? this.host = t : Object.keys(t).length > 0 ? this.user.set(this.base.name, t) : this.user.delete(this.base.name), this.effective = null, !0);
490
+ }
491
+ merged() {
492
+ return {
493
+ ...this.host,
494
+ ...this.user.get(this.base.name)
438
495
  };
439
496
  }
440
- }, P = 200, F = 80, I = (e) => e.position === "top" || e.position === "bottom", L = class {
497
+ };
498
+ //#endregion
499
+ //#region src/style/styleOptions.ts
500
+ function an(e, t) {
501
+ return t ? {
502
+ ...t.visible === void 0 ? {} : { [`crosshair.${e}.visible`]: t.visible },
503
+ ...t.color === void 0 ? {} : { [`crosshair.${e}.color`]: t.color },
504
+ ...t.style === void 0 ? {} : { [`crosshair.${e}.style`]: t.style },
505
+ ...t.width === void 0 ? {} : { [`crosshair.${e}.width`]: t.width }
506
+ } : {};
507
+ }
508
+ function on(e) {
509
+ let { grid: t, crosshair: n } = e, r = n?.vLine?.labelBackground ?? n?.hLine?.labelBackground;
510
+ return {
511
+ ...t?.hLineColor === void 0 ? {} : { "grid.horizontal.color": t.hLineColor },
512
+ ...t?.hLineStyle === void 0 ? {} : { "grid.horizontal.style": t.hLineStyle },
513
+ ...t?.vLineColor === void 0 ? {} : { "grid.vertical.color": t.vLineColor },
514
+ ...t?.vLineStyle === void 0 ? {} : { "grid.vertical.style": t.vLineStyle },
515
+ ...an("horizontal", n?.hLine),
516
+ ...an("vertical", n?.vLine),
517
+ ...r === void 0 ? {} : { "crosshair.labelBackground": r },
518
+ ...e.overrides
519
+ };
520
+ }
521
+ //#endregion
522
+ //#region src/layout/LayoutManager.ts
523
+ var sn = 200, cn = 80, V = (e) => e.position === "top" || e.position === "bottom", ln = class {
441
524
  panels = [];
442
525
  containerWidth = 0;
443
526
  containerHeight = 0;
@@ -453,8 +536,8 @@ var j = class {
453
536
  this.panels.push({
454
537
  id: e,
455
538
  position: n,
456
- size: r ?? (a ? P : t),
457
- minSize: a ? F : i,
539
+ size: r ?? (a ? sn : t),
540
+ minSize: a ? cn : i,
458
541
  content: {
459
542
  type: "indicator",
460
543
  indicatorInstanceId: e
@@ -473,14 +556,14 @@ var j = class {
473
556
  }
474
557
  setPanelCollapsed(e, t) {
475
558
  let n = this.panels.find((t) => t.id === e);
476
- return !n || !I(n) || this.maximized === null && !!n.collapsed === t ? !1 : (this.maximized = null, n.collapsed = t || void 0, !0);
559
+ return !n || !V(n) || this.maximized === null && !!n.collapsed === t ? !1 : (this.maximized = null, n.collapsed = t || void 0, !0);
477
560
  }
478
561
  isPanelCollapsed(e) {
479
562
  return !!this.panels.find((t) => t.id === e)?.collapsed;
480
563
  }
481
564
  isPanelShownCollapsed(e) {
482
565
  let t = this.panels.find((t) => t.id === e);
483
- return !t || !I(t) ? !1 : this.maximized === null ? !!t.collapsed : this.maximized !== e;
566
+ return !t || !V(t) ? !1 : this.maximized === null ? !!t.collapsed : this.maximized !== e;
484
567
  }
485
568
  setPanelScale(e, t) {
486
569
  let n = this.panels.find((t) => t.id === e);
@@ -496,7 +579,7 @@ var j = class {
496
579
  }
497
580
  setMaximizedPanel(e) {
498
581
  let t = e === null ? null : this.panels.find((t) => t.id === e);
499
- return e !== null && (!t || !I(t)) || this.maximized === e ? !1 : (this.maximized = e, t && (t.collapsed = void 0), !0);
582
+ return e !== null && (!t || !V(t)) || this.maximized === e ? !1 : (this.maximized = e, t && (t.collapsed = void 0), !0);
500
583
  }
501
584
  getMaximizedPanel() {
502
585
  return this.maximized;
@@ -517,19 +600,19 @@ var j = class {
517
600
  this.panels = [...this.panels].sort((e, n) => t(e) - t(n));
518
601
  }
519
602
  shownSize(e, t) {
520
- return I(e) ? this.maximized ? e.id === this.maximized ? t : 20 : e.collapsed ? 20 : e.size : e.size;
603
+ return V(e) ? this.maximized ? e.id === this.maximized ? t : 20 : e.collapsed ? 20 : e.size : e.size;
521
604
  }
522
605
  setPanelPosition(e, n) {
523
606
  let r = this.panels.find((t) => t.id === e);
524
607
  if (r) {
525
608
  let a = r.position === "left" || r.position === "right", o = n === "left" || n === "right";
526
- r.position = n, a !== o && (r.size = o ? P : t, r.minSize = o ? F : i), o && (r.collapsed = void 0, this.maximized === e && (this.maximized = null));
609
+ r.position = n, a !== o && (r.size = o ? sn : t, r.minSize = o ? cn : i), o && (r.collapsed = void 0, this.maximized === e && (this.maximized = null));
527
610
  }
528
611
  }
529
612
  setPanelSize(e, t) {
530
613
  let n = this.panels.find((t) => t.id === e);
531
614
  if (n) {
532
- let e = I(n) ? this.containerHeight - o - 48 : this.containerWidth / 2, r = e > n.minSize ? Math.min(t, e) : t;
615
+ let e = V(n) ? this.containerHeight - o - 48 : this.containerWidth / 2, r = e > n.minSize ? Math.min(t, e) : t;
533
616
  n.size = Math.max(n.minSize, r), n.collapsed = void 0, this.maximized = null;
534
617
  }
535
618
  }
@@ -639,24 +722,24 @@ var j = class {
639
722
  getMainChartRect() {
640
723
  return this.resolve().mainChartRect;
641
724
  }
642
- }, tn = 14, nn = 14, rn = 22, R = 4;
643
- function z(e) {
644
- let { min: t, max: n, lastPrice: r, locale: i, fontFamily: o, fontSizeSmall: c, measure: u } = e, d = s(t, n), f = e.tagPrecision ?? d, p = r === null ? [t, n] : [
725
+ }, un = 14, dn = 14, fn = 22, pn = 4;
726
+ function mn(e) {
727
+ let { min: t, max: n, lastPrice: r, locale: i, fontFamily: o, fontSizeSmall: c, measure: l } = e, d = s(t, n), f = e.tagPrecision ?? d, p = r === null ? [t, n] : [
645
728
  t,
646
729
  n,
647
730
  r
648
731
  ], m = a;
649
732
  for (let t of p) {
650
733
  if (!Number.isFinite(t)) continue;
651
- let n = e.format ? e.format(t) : l(t, d, i), r = e.format ? n : l(t, f, i);
652
- m = Math.max(m, u(n, `500 ${c}px ${o}`) + tn, u(r, `bold 11px ${o}`) + nn, u(r, `600 ${c}px ${o}`) + rn);
734
+ let n = e.format ? e.format(t) : u(t, d, i), r = e.format ? n : u(t, f, i);
735
+ m = Math.max(m, l(n, `500 ${c}px ${o}`) + un, l(r, `bold 11px ${o}`) + dn, l(r, `600 ${c}px ${o}`) + fn);
653
736
  }
654
- return m <= a ? a : Math.ceil(m / R) * R;
737
+ return m <= a ? a : Math.ceil(m / pn) * pn;
655
738
  }
656
- function B(e, t) {
739
+ function hn(e, t) {
657
740
  return t > e || t <= e - 12 ? t : e;
658
741
  }
659
- var an = class {
742
+ var gn = class {
660
743
  netY = 0;
661
744
  travelX = 0;
662
745
  engaged = !1;
@@ -672,8 +755,8 @@ var an = class {
672
755
  }
673
756
  return this.engaged;
674
757
  }
675
- }, on = 1;
676
- function V(e, t) {
758
+ }, _n = 1;
759
+ function vn(e, t) {
677
760
  return e.filter((e) => (e.descriptor.layer ?? "overlay") === t);
678
761
  }
679
762
  function H(e) {
@@ -687,24 +770,24 @@ function H(e) {
687
770
  //#endregion
688
771
  //#region src/plugins/registry.ts
689
772
  var U = /* @__PURE__ */ new Map();
690
- function sn(e) {
773
+ function yn(e) {
691
774
  U.set(H(e), e);
692
775
  }
693
- function cn(e) {
776
+ function bn(e) {
694
777
  return U.delete(e);
695
778
  }
696
- function ln() {
779
+ function xn() {
697
780
  return [...U.values()];
698
781
  }
699
- function un() {
782
+ function Sn() {
700
783
  U.clear();
701
784
  }
702
785
  //#endregion
703
786
  //#region src/plugins/PluginManager.ts
704
- var dn = class {
787
+ var Cn = class {
705
788
  plugins = /* @__PURE__ */ new Map();
706
789
  constructor(e, t = {}) {
707
- if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of ln()) this.add(e);
790
+ if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of xn()) this.add(e);
708
791
  for (let e of t.plugins ?? []) this.add(e);
709
792
  }
710
793
  register(e) {
@@ -734,15 +817,15 @@ var dn = class {
734
817
  add(e) {
735
818
  this.plugins.set(H(e), e), e.kind === "indicator" && this.indicatorEngine.register(e.plugin);
736
819
  }
737
- }, fn = {
820
+ }, wn = {
738
821
  orderPlace: (e, t) => e.placeOrder(t),
739
822
  orderModify: (e, t) => e.modifyOrder(t),
740
823
  orderCancel: (e, t) => e.cancelOrder(t),
741
824
  positionModify: (e, t) => e.modifyPosition(t),
742
825
  positionClose: (e, t) => e.closePosition(t),
743
- positionReverse: (e, t, n) => pn(e, t, n)
826
+ positionReverse: (e, t, n) => Tn(e, t, n)
744
827
  };
745
- async function pn(e, t, n) {
828
+ async function Tn(e, t, n) {
746
829
  let { reversing: r } = n;
747
830
  if (!r.has(t.positionId)) {
748
831
  r.add(t.positionId);
@@ -771,7 +854,7 @@ async function pn(e, t, n) {
771
854
  }
772
855
  }
773
856
  }
774
- function mn(e, t) {
857
+ function En(e, t) {
775
858
  let n = [], r = null, i = {
776
859
  positions: () => r ?? t.getPositions?.() ?? [],
777
860
  reversing: /* @__PURE__ */ new Set()
@@ -781,8 +864,8 @@ function mn(e, t) {
781
864
  e.data && t.onFill?.(e.data);
782
865
  };
783
866
  e.on("orders", a), e.on("positions", o), e.on("error", s), e.on("fill", c), n.push(() => e.off("orders", a), () => e.off("positions", o), () => e.off("error", s), () => e.off("fill", c));
784
- for (let r of Object.keys(fn)) {
785
- let a = fn[r], o = t.onIntent(r, (n) => {
867
+ for (let r of Object.keys(wn)) {
868
+ let a = wn[r], o = t.onIntent(r, (n) => {
786
869
  Promise.resolve(a(e, n, i)).catch((e) => t.onError({
787
870
  message: `Execution command failed: ${r}`,
788
871
  cause: e
@@ -796,16 +879,16 @@ function mn(e, t) {
796
879
  }
797
880
  //#endregion
798
881
  //#region src/Chart.ts
799
- var hn = {
882
+ var Dn = {
800
883
  min: 0,
801
884
  max: 100
802
- }, gn = 0xe8d4a51000, _n = "exchange";
803
- function vn(e) {
804
- if (typeof e == "string" && e !== "exchange" && !f(e)) throw RangeError(`Unknown time zone: ${e}`);
885
+ }, On = 0xe8d4a51000, kn = "exchange";
886
+ function An(e) {
887
+ if (typeof e == "string" && e !== "exchange" && !p(e)) throw RangeError(`Unknown time zone: ${e}`);
805
888
  if (typeof e == "number" && !Number.isFinite(e)) throw RangeError(`Invalid UTC offset: ${e}`);
806
889
  }
807
- var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
808
- static version = "1.11.0";
890
+ var jn = 2, Mn = .08, Nn = 800, Pn = 20, Fn = 8, In = class {
891
+ static version = "1.13.0";
809
892
  engine;
810
893
  viewport;
811
894
  dataManager;
@@ -826,6 +909,8 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
826
909
  indicatorUpdateFrom = null;
827
910
  resolvedLayoutCache = null;
828
911
  panelInfoCache = null;
912
+ paneStyles = /* @__PURE__ */ new Map();
913
+ lastBackground = null;
829
914
  renderScheduled = !1;
830
915
  priceAxisWidth = a;
831
916
  measureCtx;
@@ -841,14 +926,14 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
841
926
  indicatorHistoryDepth = 0;
842
927
  removedDrawingAlerts = /* @__PURE__ */ new Map();
843
928
  zoomAreaMode = !1;
844
- priceAxisAddButton = new Ge();
929
+ priceAxisAddButton = new Ke();
845
930
  displayTz = null;
846
931
  timezoneSetting = null;
847
932
  symbolInfo = null;
848
933
  symbolInfoSeq = 0;
849
934
  sessionBreaks;
850
935
  sessionShading;
851
- hostSessionHours = { ...be };
936
+ hostSessionHours = { ...Te };
852
937
  compareRenderer;
853
938
  countdownInterval = null;
854
939
  volumeRenderer;
@@ -861,7 +946,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
861
946
  signalMarkerManager;
862
947
  tradeZoneManager;
863
948
  measureOverlay;
864
- selectionBoxOverlay = new Xe();
949
+ selectionBoxOverlay = new Ze();
865
950
  replayManager;
866
951
  replayBarUnsub = null;
867
952
  replaySeeking = !1;
@@ -869,7 +954,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
869
954
  replayStepsSeries = null;
870
955
  replayCoarse = null;
871
956
  undoRedoManager;
872
- autoSaveScheduler = new Xt((e) => this.saveState(e));
957
+ autoSaveScheduler = new Zt((e) => this.saveState(e));
873
958
  animator;
874
959
  crosshairTooltip;
875
960
  pinnedTooltip;
@@ -877,18 +962,19 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
877
962
  crosshairHandler;
878
963
  chartRenderer;
879
964
  rendererToken = 0;
965
+ stopWaitingForGpu = null;
880
966
  disposed = !1;
881
967
  chartTypeOptions = {};
882
968
  mainSeriesVisible = !0;
883
- priceLines = new Ke();
884
- symbolSeries = new rt();
969
+ priceLines = new qe();
970
+ symbolSeries = new it();
885
971
  extendedHours = !0;
886
972
  replayRestarting = !1;
887
973
  fullSeries = null;
888
974
  requestedSymbols = /* @__PURE__ */ new Set();
889
975
  gridRenderer;
890
976
  priceAxis;
891
- leftPriceAxis = new We();
977
+ leftPriceAxis = new D();
892
978
  leftScaleRequested = !1;
893
979
  leftAxisWidth = a;
894
980
  leftViewport = null;
@@ -918,7 +1004,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
918
1004
  snapshotKey = null;
919
1005
  historyCheckQueued = !1;
920
1006
  constructor(e, t) {
921
- t.timeZone != null && vn(t.timeZone), this.container = e, this.options = {
1007
+ t.timeZone != null && An(t.timeZone), this.container = e, this.options = {
922
1008
  ...t,
923
1009
  chartType: t.chartType ?? "candlestick"
924
1010
  }, this.numberLocale = t.numberLocale ?? "en-US", this.defaultAutoScale = t.autoScale !== !1;
@@ -956,15 +1042,15 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
956
1042
  logScale: n.logScale ?? !0,
957
1043
  timeframes: n.timeframes ?? [],
958
1044
  defaultTimeframeFavorites: n.defaultTimeframeFavorites ?? []
959
- }, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", e.style.userSelect = "none", e.style.webkitUserSelect = "none", this.dataManager = new j(), this.history = new en({
1045
+ }, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", e.style.userSelect = "none", e.style.webkitUserSelect = "none", this.dataManager = new B(), this.history = new nn({
960
1046
  oldestTime: () => this.dataManager.getData()[0]?.time ?? null,
961
1047
  prepend: (e) => this.prependBars(e),
962
1048
  emit: (e) => this.eventBus.emit("historyLoad", e)
963
- }), this.themeManager = new N(t.theme), this.layoutManager = new L(), this.indicatorEngine = new Ae(), this.pluginManager = new dn(this.indicatorEngine, { plugins: t.plugins }), this.eventBus = new Te(), C(this.indicatorEngine), this.indicatorEngine.register(new ge(this.symbolSeries)), this.indicatorEngine.register(new et(this.symbolSeries)), this.drawingManager = new Se(), St(this.drawingManager), this.drawingRenderer = new Ce(this.drawingManager), this.drawingManager.setRequestRender(() => {
1049
+ }), this.themeManager = new rn(t.theme), this.themeManager.setChartType(this.options.chartType ?? "candlestick"), this.applyStyle(on(t), "host", !1), this.layoutManager = new ln(), this.indicatorEngine = new T(), this.pluginManager = new Cn(this.indicatorEngine, { plugins: t.plugins }), this.eventBus = new Ae(), k(this.indicatorEngine), this.indicatorEngine.register(new ye(this.symbolSeries)), this.indicatorEngine.register(new tt(this.symbolSeries)), this.indicatorEngine.register(new be(this.symbolSeries)), this.indicatorEngine.register(new xe(this.symbolSeries)), this.drawingManager = new De(), wt(this.drawingManager), this.drawingRenderer = new Oe(this.drawingManager), this.drawingManager.setRequestRender(() => {
964
1050
  this.syncRenderContext(), this.engine.requestRender(r.Overlay), this.scheduleAutoSave();
965
1051
  }), this.drawingManager.setEventCallback((e, t) => {
966
1052
  this.followDrawingAlerts(e, t?.id), this.eventBus.emit(e, t), (e === "drawingCreate" || e === "drawingUpdate" || e === "drawingRemove") && this.announceStateChange();
967
- }), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new ct();
1053
+ }), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new lt();
968
1054
  let i = "";
969
1055
  this.undoRedoManager.setOnChange(() => {
970
1056
  let { canUndo: e, canRedo: t } = this.undoRedoManager.getState(), n = `${e}|${t}`;
@@ -977,21 +1063,21 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
977
1063
  primary: e[0] ?? null
978
1064
  })), this.drawingManager.setForeignHistory((e, t) => {
979
1065
  e.type === "custom" ? e.custom?.[t]() : this.applyIndicatorStep(e, t);
980
- }), this.drawingManager.setDataGetter(() => this.dataManager.getData()), this.drawingManager.setDisplayDataGetter(() => this.getDisplayData()), t.crosshair?.mode === "magnet" && this.features.drawingMagnet && this.drawingManager.setMagnetMode("magnet"), this.tradingManager = new ot({
1066
+ }), this.drawingManager.setDataGetter(() => this.dataManager.getData()), this.drawingManager.setDisplayDataGetter(() => this.getDisplayData()), t.crosshair?.mode === "magnet" && this.features.drawingMagnet && this.drawingManager.setMagnetMode("magnet"), this.tradingManager = new st({
981
1067
  enabled: this.features.trading,
982
1068
  contextMenu: { enabled: this.features.tradingContextMenu }
983
- }), this.tradingRenderer = new st(this.tradingManager), this.tradingManager.setContainer(e), this.tradingManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradingManager.setEventCallback((e, t) => {
1069
+ }), this.tradingRenderer = new ct(this.tradingManager), this.tradingManager.setContainer(e), this.tradingManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradingManager.setEventCallback((e, t) => {
984
1070
  this.eventBus.emit(e, t);
985
- }), this.engine = new qe(e);
1071
+ }), this.engine = new Je(e);
986
1072
  let a = this.engine.dprManager.getContainerSize();
987
- if (this.viewport = new lt(a.width, a.height, t.minBarSpacing ?? 2, t.maxBarSpacing ?? 30, t.rightMargin ?? 5), this.viewport.setPanLimits({
1073
+ if (this.viewport = new ut(a.width, a.height, t.minBarSpacing ?? 2, t.maxBarSpacing ?? 30, t.rightMargin ?? 5), this.viewport.setPanLimits({
988
1074
  freePan: t.freePan ?? !0,
989
1075
  minVisibleBars: t.panLimits?.minVisibleBars ?? 3
990
1076
  }), this.layoutManager.resize(a.width, a.height), this.engine.onContainerResize = (e) => {
991
1077
  if (e.width <= 0 || e.height <= 0) return;
992
1078
  let t = this.viewport.isAtEnd();
993
1079
  this.viewport.resize(e.width, e.height), this.layoutManager.resize(e.width, e.height), this.updateViewportAndRender(t);
994
- }, this.chartRenderer = this.createChartRenderer(this.options.chartType), this.gridRenderer = new Ee(), t.grid?.visible === !1 && this.gridRenderer.setVisible(!1), this.priceAxis = new We(), this.priceAxis.setLocale(this.numberLocale), this.leftPriceAxis.setLocale(this.numberLocale), this.timeAxis = new it(), this.crosshairHandler = new _e(), this.crosshairHandler.setLocale(this.numberLocale), t.crosshair?.mode && this.crosshairHandler.setMode(t.crosshair.mode), this.crosshairHandler.setCallback((e, t) => {
1080
+ }, this.chartRenderer = this.createChartRenderer(this.options.chartType), this.gridRenderer = new je(), t.grid?.visible === !1 && this.gridRenderer.setVisible(!1), this.priceAxis = new D(), this.priceAxis.setLocale(this.numberLocale), this.leftPriceAxis.setLocale(this.numberLocale), this.timeAxis = new at(), this.crosshairHandler = new Se(), this.crosshairHandler.setLocale(this.numberLocale), t.crosshair?.mode && this.crosshairHandler.setMode(t.crosshair.mode), this.crosshairHandler.setCallback((e, t) => {
995
1081
  if (e !== null && t) {
996
1082
  let n = this.dataManager.getData(), r = e < n.length ? n[e] : void 0;
997
1083
  this.chartLegend.setHoverBar(r ?? null);
@@ -1000,19 +1086,19 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
1000
1086
  prevClose: e > 0 ? n[e - 1]?.close : void 0,
1001
1087
  priceRange: i.priceRange,
1002
1088
  plot: i.chartRect,
1003
- barStepMs: ht(n)
1089
+ barStepMs: gt(n)
1004
1090
  }) : this.crosshairTooltip.hide(), this.pinnedTooltip.isPinned() && this.pinnedTooltip.reposition(this.viewport.getState(), r ?? null, e, this.themeManager.getTheme()), this.eventBus.emit("crosshairMove", {
1005
1091
  point: t,
1006
1092
  bar: r,
1007
1093
  barIndex: e
1008
1094
  });
1009
1095
  } else this.crosshairTooltip.hide(), this.chartLegend.setHoverBar(null), this.eventBus.emit("crosshairLeave", {});
1010
- }), this.chartLegend = new me(), this.chartLegend.setChartType(this.options.chartType), this.chartLegend.setLocale(this.numberLocale), this.watermark = new pt(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new ft(), this.volumeProfile = new dt(), this.marketProfile = new Ie(), this.depthHeatmap = new xe(), this.periodLevels = new Be(), this.pivotMarkers = new He(), this.barCountdown = new ue(), this.barCountdown.setVisible(this.features.barCountdown), this.sessionBreaks = new Ze(), this.sessionBreaks.setLocale(this.numberLocale), this.sessionShading = new Qe(), this.compareRenderer = new he(), t.sessionBreaks ? this.sessionBreaks.setConfig({
1096
+ }), this.chartLegend = new _e(), this.chartLegend.setChartType(this.options.chartType), this.chartLegend.setLocale(this.numberLocale), this.watermark = new mt(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new pt(), this.volumeProfile = new ft(), this.marketProfile = new ze(), this.depthHeatmap = new Ee(), this.periodLevels = new Ue(), this.pivotMarkers = new Ge(), this.barCountdown = new pe(), this.barCountdown.setVisible(this.features.barCountdown), this.sessionBreaks = new Qe(), this.sessionBreaks.setLocale(this.numberLocale), this.sessionShading = new $e(), this.compareRenderer = new ve(), t.sessionBreaks ? this.sessionBreaks.setConfig({
1011
1097
  visible: t.sessionBreaks.visible ?? !0,
1012
1098
  color: t.sessionBreaks.color,
1013
1099
  lineStyle: t.sessionBreaks.lineStyle,
1014
1100
  lineWidth: t.sessionBreaks.lineWidth
1015
- }) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new se(), this.crosshairTooltip = new ve(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new Ve(), this.pinnedTooltip.create(e), t.priceFormat && this.applyPriceFormat(t.priceFormat), t.chartTypeOptions && (this.chartTypeOptions = _(t.chartTypeOptions)), t.highLowLines && this.priceLines.setHighLow(!0), t.shapes && this.themeManager.setShape(Dn(t.shapes)), this.priceLines.setPriceText((e) => this.formatPrice(e)), t.extendedHours === !1 && (this.extendedHours = !1), t.timeFormatter && this.applyTimeFormatter(t.timeFormatter), this.keyboardHandler = new Ne({
1101
+ }) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new ue(), this.crosshairTooltip = new Ce(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new We(), this.pinnedTooltip.create(e), t.priceFormat && this.applyPriceFormat(t.priceFormat), t.chartTypeOptions && (this.chartTypeOptions = y(t.chartTypeOptions)), t.highLowLines && this.priceLines.setHighLow(!0), t.shapes && this.themeManager.setShape(zn(t.shapes)), this.priceLines.setPriceText((e) => this.formatPrice(e)), t.extendedHours === !1 && (this.extendedHours = !1), t.timeFormatter && this.applyTimeFormatter(t.timeFormatter), this.keyboardHandler = new Ie({
1016
1102
  scrollBars: (e) => {
1017
1103
  let t = this.viewport.getState().barWidth + this.viewport.getState().barSpacing;
1018
1104
  this.viewport.scrollBy(e * t), this.updateViewportAndRender();
@@ -1036,10 +1122,10 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
1036
1122
  bars: () => this.getDisplayData(),
1037
1123
  visibleRange: () => this.viewport.getState().visibleRange,
1038
1124
  formatPrice: (e) => this.formatPrice(e),
1039
- formatTime: (e) => ie(this.numberLocale || "en-US", {
1125
+ formatTime: (e) => se(this.numberLocale || "en-US", {
1040
1126
  dateStyle: "medium",
1041
1127
  timeStyle: "short"
1042
- }, this.displayTz)(e > gn ? e : e * 1e3),
1128
+ }, this.displayTz)(e > On ? e : e * 1e3),
1043
1129
  showBar: (e) => this.setCrosshairTime(e)
1044
1130
  }, t.a11y?.labels);
1045
1131
  for (let e of [
@@ -1059,7 +1145,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
1059
1145
  }
1060
1146
  this.keyboardHandler.handleKey(e) && (e.preventDefault(), this.a11y?.viewMoved());
1061
1147
  }
1062
- }, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new ye(), this.currentPriceLine.setLocale(this.numberLocale), this.priceAxis.setReservedPriceProvider(() => this.currentPriceLine.isVisible() ? this.currentPriceLine.getPrice() : null), this.alertManager = new oe(), this.alertManager.setDrawingLevels((e) => this.drawingLevelsNow(e)), this.alertManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.alertManager.on("triggered", (e) => {
1148
+ }, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new we(), this.currentPriceLine.setLocale(this.numberLocale), this.priceAxis.setReservedPriceProvider(() => this.currentPriceLine.isVisible() ? this.currentPriceLine.getPrice() : null), this.alertManager = new le(), this.alertManager.setDrawingLevels((e) => this.drawingLevelsNow(e)), this.alertManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.alertManager.on("triggered", (e) => {
1063
1149
  this.eventBus.emit("alertTriggered", G(e)), this.eventBus.emit("dataUpdate", {
1064
1150
  alert: "triggered",
1065
1151
  alertId: e.id,
@@ -1074,7 +1160,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
1074
1160
  this.eventBus.emit("alertExpired", G(e));
1075
1161
  }), this.alertManager.on("updated", (e) => {
1076
1162
  this.eventBus.emit("alertUpdate", G(e));
1077
- }), this.signalMarkerManager = new $e(), this.signalMarkerManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.signalMarkerManager.setDataGetter(() => this.dataManager.getData()), this.signalMarkerManager.on("added", (e) => {
1163
+ }), this.signalMarkerManager = new et(), this.signalMarkerManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.signalMarkerManager.setDataGetter(() => this.dataManager.getData()), this.signalMarkerManager.on("added", (e) => {
1078
1164
  this.eventBus.emit("signalMarkerAdd", {
1079
1165
  id: e.id,
1080
1166
  source: e.source,
@@ -1082,18 +1168,18 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
1082
1168
  });
1083
1169
  }), this.signalMarkerManager.on("removed", (e) => {
1084
1170
  this.eventBus.emit("signalMarkerRemove", { id: e });
1085
- }), this.tradeZoneManager = new at(), this.tradeZoneManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradeZoneManager.setDataGetter(() => this.dataManager.getData()), this.tradeZoneManager.on("added", (e) => {
1171
+ }), this.tradeZoneManager = new ot(), this.tradeZoneManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradeZoneManager.setDataGetter(() => this.dataManager.getData()), this.tradeZoneManager.on("added", (e) => {
1086
1172
  this.eventBus.emit("tradeZoneAdd", {
1087
1173
  id: e.id,
1088
1174
  direction: e.direction
1089
1175
  });
1090
1176
  }), this.tradeZoneManager.on("removed", (e) => {
1091
1177
  this.eventBus.emit("tradeZoneRemove", { id: e });
1092
- }), this.replayManager = new Ye(), this.replayManager.on("stateChange", (e) => {
1178
+ }), this.replayManager = new Xe(), this.replayManager.on("stateChange", (e) => {
1093
1179
  this.replayRestarting || this.eventBus.emit("replayState", { state: e });
1094
- }), this.measureOverlay = new Le(), this.interactionManager = new je(e), this.features.panning) {
1095
- let e = new an();
1096
- this.interactionManager.setPanHandler(new Re((t, n) => {
1180
+ }), this.measureOverlay = new Be(), this.interactionManager = new Pe(e), this.features.panning) {
1181
+ let e = new gn();
1182
+ this.interactionManager.setPanHandler(new Ve((t, n) => {
1097
1183
  t && this.viewport.scrollBy(t), e.step(t, n, this.options.autoScale !== !1) && n && (this.options.autoScale = !1, this.viewport.panPriceRange(n)), this.updateViewportAndRender();
1098
1184
  }, () => e.reset()));
1099
1185
  }
@@ -1105,10 +1191,10 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
1105
1191
  scales: !this.indicatorEngine.hasLeftScaleOverlays()
1106
1192
  }
1107
1193
  })), this.features.zooming) {
1108
- this.interactionManager.setZoomHandler(new mt((e, t) => {
1194
+ this.interactionManager.setZoomHandler(new ht((e, t) => {
1109
1195
  this.viewport.zoom(e, t - this.viewport.getState().chartRect.x), this.updateViewportAndRender();
1110
1196
  }));
1111
- let e = new le((e) => {
1197
+ let e = new fe((e) => {
1112
1198
  this.options.autoScale = !1, this.viewport.scalePriceRange(e), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents();
1113
1199
  }, (e) => {
1114
1200
  let t = this.viewport.getState().chartRect.width;
@@ -1128,7 +1214,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
1128
1214
  y: t.y
1129
1215
  });
1130
1216
  })), 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) => {
1131
- let t = jt(e.y, this.viewport.getState());
1217
+ let t = F(e.y, this.viewport.getState());
1132
1218
  Number.isFinite(t) && this.eventBus.emit("priceAxisAdd", {
1133
1219
  price: t,
1134
1220
  x: e.x,
@@ -1138,10 +1224,10 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
1138
1224
  ...this.viewport.getState(),
1139
1225
  data: this.getDisplayData()
1140
1226
  })), this.features.alerts) {
1141
- let e = new ae(this.alertManager, () => this.viewport.getState());
1227
+ let e = new ce(this.alertManager, () => this.viewport.getState());
1142
1228
  this.interactionManager.setAlertDragHandler(e);
1143
1229
  }
1144
- let o = new ze();
1230
+ let o = new He();
1145
1231
  o.configure(() => this.getResolvedLayout(), (e, t) => this.setPanelSize(e, t)), this.interactionManager.setPaneResizeHandler(o), this.interactionManager.setAltClickHandler((e) => {
1146
1232
  let t = this.getDisplayData();
1147
1233
  if (t.length === 0) return;
@@ -1165,7 +1251,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
1165
1251
  x: e.x,
1166
1252
  y: e.y
1167
1253
  }), t.length === 0) return;
1168
- let r = At(e.x, this.viewport.getState());
1254
+ let r = Mt(e.x, this.viewport.getState());
1169
1255
  r < 0 || r >= t.length || this.eventBus.emit("barClick", {
1170
1256
  bar: t[r],
1171
1257
  barIndex: r,
@@ -1205,7 +1291,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
1205
1291
  end: () => {
1206
1292
  let e = this.selectionBoxOverlay.end();
1207
1293
  if (e && this.zoomAreaMode) {
1208
- if (e.x1 - e.x0 < Cn) return;
1294
+ if (e.x1 - e.x0 < Fn) return;
1209
1295
  this.zoomToBox(e), this.setZoomAreaMode(!1);
1210
1296
  return;
1211
1297
  }
@@ -1227,6 +1313,9 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
1227
1313
  }), this.interactionManager.attach(), t.timeZone !== void 0 && t.timeZone !== null && this.setTimezone(t.timeZone), t.leftPriceScale && (this.leftScaleRequested = !0), this.syncRenderContext(), this.engine.start(), this.engine.onGpuLost = () => this.eventBus.emit("rendererChange", {
1228
1314
  renderer: "canvas",
1229
1315
  reason: "contextLost"
1316
+ }), this.engine.onGpuRestored = () => this.eventBus.emit("rendererChange", {
1317
+ renderer: "webgl",
1318
+ reason: "contextRestored"
1230
1319
  }), this.options.renderer && this.options.renderer !== "canvas" && this.setRenderer(this.options.renderer);
1231
1320
  }
1232
1321
  setData(e) {
@@ -1239,7 +1328,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
1239
1328
  if (this.replaySession) return 0;
1240
1329
  let t = null;
1241
1330
  if (this.fullSeries) {
1242
- let n = this.fullSeries[0]?.time, r = /* @__PURE__ */ new Set(), i = e.filter((e) => Pn(e) && (n === void 0 || e.time < n) && !r.has(e.time) && r.add(e.time)).sort((e, t) => e.time - t.time);
1331
+ let n = this.fullSeries[0]?.time, r = /* @__PURE__ */ new Set(), i = e.filter((e) => Kn(e) && (n === void 0 || e.time < n) && !r.has(e.time) && r.add(e.time)).sort((e, t) => e.time - t.time);
1243
1332
  this.fullSeries = [...i, ...this.fullSeries];
1244
1333
  let a = this.sessionKeep(this.fullSeries);
1245
1334
  t = i.length, e = a ? i.filter((e) => a(e.time)) : i;
@@ -1248,7 +1337,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
1248
1337
  if (a === 0) return t ?? 0;
1249
1338
  let o = this.dataManager.getData();
1250
1339
  if (this.crosshairHandler.setData(o), this.displayDataCache = null, this.sessionBreaks.invalidateCache(), this.pinnedTooltip.isPinned() && this.pinnedTooltip.unpin(), this.measureOverlay.end(), this.recalcIndicators(o), i !== void 0) {
1251
- let e = Math.round(E(i, this.getDisplayData()));
1340
+ let e = Math.round(M(i, this.getDisplayData()));
1252
1341
  this.viewport.prependBars(e - r);
1253
1342
  }
1254
1343
  return this.updateViewportAndRender(), t ?? a;
@@ -1281,13 +1370,13 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
1281
1370
  this.historyCheckQueued || !this.history.hasLoader() || (this.historyCheckQueued = !0, queueMicrotask(() => {
1282
1371
  if (this.historyCheckQueued = !1, this.replaySession || !this.history.hasLoader() || Kt(this.options.chartType)) return;
1283
1372
  let { from: e, to: t } = this.viewport.getState().visibleRange;
1284
- this.history.maybeLoad(Math.max(0, Math.floor(e)), Math.max(Sn, t - e));
1373
+ this.history.maybeLoad(Math.max(0, Math.floor(e)), Math.max(Pn, t - e));
1285
1374
  }));
1286
1375
  }
1287
1376
  useStreamHistory(e, t) {
1288
1377
  if (this.hostHistoryLoader) return;
1289
- let n = kt(e), r = n.fetchHistoryBefore, i = this.streamTimeframe;
1290
- if (!r || i === null || ne(i) !== null) {
1378
+ let n = jt(e), r = n.fetchHistoryBefore, i = this.streamTimeframe;
1379
+ if (!r || i === null || ie(i) !== null) {
1291
1380
  this.historyFromStream && this.history.setLoader(null), this.historyFromStream = !1;
1292
1381
  return;
1293
1382
  }
@@ -1347,7 +1436,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
1347
1436
  }
1348
1437
  setChartType(e) {
1349
1438
  let t = this.options.chartType ?? "candlestick";
1350
- this.options.chartType = e, this.chartRenderer = this.createChartRenderer(e), this.chartLegend.setChartType(e), this.displayDataCache = null, this.updateViewportAndRender(!0), this.markStateChanged(), e !== t && this.eventBus.emit("chartTypeChange", {
1439
+ this.options.chartType = e, this.themeManager.setChartType(e), this.chartRenderer = this.createChartRenderer(e), this.chartLegend.setChartType(e), this.displayDataCache = null, this.updateViewportAndRender(!0), this.markStateChanged(), e !== t && this.eventBus.emit("chartTypeChange", {
1351
1440
  type: e,
1352
1441
  previous: t
1353
1442
  });
@@ -1355,11 +1444,11 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
1355
1444
  setChartTypeOptions(e) {
1356
1445
  this.chartTypeOptions = {
1357
1446
  ...this.chartTypeOptions,
1358
- ..._(e)
1447
+ ...y(e)
1359
1448
  }, this.displayDataCache = null, this.updateViewportAndRender(!0), this.markStateChanged();
1360
1449
  }
1361
1450
  getChartTypeOptions() {
1362
- return _(this.chartTypeOptions);
1451
+ return y(this.chartTypeOptions);
1363
1452
  }
1364
1453
  setExtendedHours(e) {
1365
1454
  e !== this.extendedHours && (this.extendedHours = e, this.reapplyExtendedHours(), this.markStateChanged());
@@ -1368,7 +1457,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
1368
1457
  return this.extendedHours;
1369
1458
  }
1370
1459
  sessionKeep(e) {
1371
- return this.extendedHours ? null : Pt(this.symbolInfo, e);
1460
+ return this.extendedHours ? null : Ft(this.symbolInfo, e);
1372
1461
  }
1373
1462
  shownBars(e) {
1374
1463
  let t = this.sessionKeep(e);
@@ -1409,7 +1498,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
1409
1498
  return this.priceLines.setQuoteShown(this.replaySession === null), this.priceLines;
1410
1499
  }
1411
1500
  setShapes(e) {
1412
- let t = Dn(e);
1501
+ let t = zn(e);
1413
1502
  t.tagRadius !== void 0 && (this.themeManager.setShape({
1414
1503
  ...this.themeManager.getTheme().shape,
1415
1504
  ...t
@@ -1481,14 +1570,14 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
1481
1570
  this.recordIndicators(e, () => this.updateIndicatorNow(e, t));
1482
1571
  }
1483
1572
  updateIndicatorNow(e, t) {
1484
- let n = this.indicatorEngine.getIndicatorDescriptor(e), r = n ? T(n) : null, i = r ? this.indicatorEngine.getIndicatorConfig(e)?.params[r] : void 0;
1573
+ let n = this.indicatorEngine.getIndicatorDescriptor(e), r = n ? j(n) : null, i = r ? this.indicatorEngine.getIndicatorConfig(e)?.params[r] : void 0;
1485
1574
  this.indicatorEngine.updateIndicator(e, t, this.dataManager.getData()), this.announceIndicatorUpdate(0), this.markStateChanged(), this.eventBus.emit("indicatorChange", {
1486
1575
  instanceId: e,
1487
1576
  change: "params"
1488
1577
  }), this.requestMissingSymbols(e);
1489
1578
  let a = this.indicatorEngine.getIndicatorConfig(e);
1490
1579
  if (n?.placement === "overlay" && a && r && a.params[r] !== i) {
1491
- let t = h(a.params[r]), n = t ? this.paneHostOf(t.instanceId, e) : h(i) ? null : a.pane ?? null;
1580
+ let t = g(a.params[r]), n = t ? this.paneHostOf(t.instanceId, e) : g(i) ? null : a.pane ?? null;
1492
1581
  (n ?? void 0) !== a.pane && (this.indicatorEngine.setPane(e, n), this.eventBus.emit("indicatorChange", {
1493
1582
  instanceId: e,
1494
1583
  change: "pane"
@@ -1499,7 +1588,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
1499
1588
  paneFor(e, t, n, r) {
1500
1589
  if (n) return this.paneHostOf(n, r);
1501
1590
  if (e.placement !== "overlay") return null;
1502
- let i = T(e), a = i ? h(t[i]) : null;
1591
+ let i = j(e), a = i ? g(t[i]) : null;
1503
1592
  return a ? this.paneHostOf(a.instanceId, r) : null;
1504
1593
  }
1505
1594
  paneHostOf(e, t) {
@@ -1542,8 +1631,8 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
1542
1631
  return {
1543
1632
  ...e,
1544
1633
  priceRange: {
1545
- min: t.min - n * bn,
1546
- max: t.max + n * bn
1634
+ min: t.min - n * Mn,
1635
+ max: t.max + n * Mn
1547
1636
  },
1548
1637
  logScale: !1,
1549
1638
  scaleMode: "regular",
@@ -1573,7 +1662,9 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
1573
1662
  detachIndicator(e) {
1574
1663
  if (!this.indicatorEngine.getIndicatorConfig(e)) return;
1575
1664
  let t = this.layoutManager.getPanels().find((t) => t.id === e), n = this.indicatorEngine.getPaneMembers(e), r = t ? n.find((e) => this.indicatorEngine.getIndicatorDescriptor(e)?.placement === "panel") ?? null : null;
1576
- this.indicatorEngine.removeIndicator(e), r ? (this.indicatorEngine.setPane(r, null), this.layoutManager.renamePanel(e, r)) : this.layoutManager.removePanel(e);
1665
+ this.indicatorEngine.removeIndicator(e);
1666
+ let i = this.paneStyles.get(e);
1667
+ this.paneStyles.delete(e), r ? (this.indicatorEngine.setPane(r, null), this.layoutManager.renamePanel(e, r), i && this.paneStyles.set(r, i)) : this.layoutManager.removePanel(e);
1577
1668
  for (let e of n) e !== r && this.indicatorEngine.setPane(e, r), this.eventBus.emit("indicatorChange", {
1578
1669
  instanceId: e,
1579
1670
  change: "pane"
@@ -1583,6 +1674,28 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
1583
1674
  getIndicatorStyle(e) {
1584
1675
  return this.indicatorEngine.getIndicatorStyle(e);
1585
1676
  }
1677
+ setIndicatorDefaults(e, t) {
1678
+ if (!t) {
1679
+ this.indicatorEngine.setStyleDefaults(e, null);
1680
+ return;
1681
+ }
1682
+ let { plots: n, ...r } = t, i = n === void 0 ? void 0 : b(n);
1683
+ this.indicatorEngine.setStyleDefaults(e, {
1684
+ ...r,
1685
+ ...i ? { plots: i } : {}
1686
+ });
1687
+ }
1688
+ setPaneStyle(e, t) {
1689
+ let n = this.paneOf(e);
1690
+ this.layoutManager.getPanels().some((e) => e.id === n) && this.recordIndicators(n, () => this.setPaneStyleNow(n, t ? ee(t) : null));
1691
+ }
1692
+ setPaneStyleNow(e, t) {
1693
+ 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());
1694
+ }
1695
+ getPaneStyle(e) {
1696
+ let t = this.paneStyles.get(this.paneOf(e));
1697
+ return t ? { ...t } : null;
1698
+ }
1586
1699
  getIndicatorOutput(e) {
1587
1700
  return this.indicatorEngine.getOutput(e);
1588
1701
  }
@@ -1593,8 +1706,8 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
1593
1706
  return this.pluginManager;
1594
1707
  }
1595
1708
  static indicators() {
1596
- let e = new Ae();
1597
- return C(e), e.getAvailableIndicators();
1709
+ let e = new T();
1710
+ return k(e), e.getAvailableIndicators();
1598
1711
  }
1599
1712
  setPanelPosition(e, t) {
1600
1713
  this.layoutManager.setPanelPosition(e, t), this.updateViewportAndRender(), this.eventBus.emit("indicatorChange", {
@@ -1617,8 +1730,8 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
1617
1730
  paneMoveHost(e, t) {
1618
1731
  let n = this.indicatorEngine.getIndicatorConfig(e), r = this.indicatorEngine.getIndicatorDescriptor(e);
1619
1732
  if (!n || !r) return;
1620
- let i = T(r);
1621
- if (r.placement === "overlay" && i && h(n.params[i])) return;
1733
+ let i = j(r);
1734
+ if (r.placement === "overlay" && i && g(n.params[i])) return;
1622
1735
  if (t === "price") return r.placement === "overlay" && n.pane ? null : void 0;
1623
1736
  if (t === "new") {
1624
1737
  let t = this.layoutManager.getPanels().some((t) => t.id === e);
@@ -1632,14 +1745,15 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
1632
1745
  if (n === void 0 || !r) return !1;
1633
1746
  let i = r.pane, a = this.layoutManager.getPanels().some((t) => t.id === e), o = new Set([e]);
1634
1747
  if (a) {
1635
- let t = this.indicatorEngine.getPaneMembers(e), r = new Set(this.indicatorEngine.getDependents(e)), i = t.filter((e) => !r.has(e)), a = i.find((e) => this.indicatorEngine.getIndicatorDescriptor(e)?.placement === "panel") ?? null;
1636
- if (a) {
1637
- this.indicatorEngine.setPane(a, null), this.layoutManager.renamePanel(e, a);
1748
+ let t = this.indicatorEngine.getPaneMembers(e), r = new Set(this.indicatorEngine.getDependents(e)), i = t.filter((e) => !r.has(e)), a = i.find((e) => this.indicatorEngine.getIndicatorDescriptor(e)?.placement === "panel") ?? null, s = this.paneStyles.get(e);
1749
+ if (this.paneStyles.delete(e), a) {
1750
+ this.indicatorEngine.setPane(a, null), this.layoutManager.renamePanel(e, a), s && this.paneStyles.set(a, s);
1638
1751
  for (let e of i) e !== a && this.indicatorEngine.setPane(e, a);
1639
1752
  } else {
1640
1753
  this.layoutManager.removePanel(e);
1641
1754
  for (let e of i) this.indicatorEngine.setPane(e, null);
1642
1755
  }
1756
+ this.panelInfoCache = null;
1643
1757
  for (let i of t) r.has(i) && this.indicatorEngine.setPane(i, n ?? e), o.add(i);
1644
1758
  }
1645
1759
  if (this.indicatorEngine.setPane(e, n), t === "new") {
@@ -1728,7 +1842,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
1728
1842
  roundPrice(e) {
1729
1843
  if (!Number.isFinite(e)) return e;
1730
1844
  let t = this.symbolInfo?.minTick ?? this.priceUnit ?? void 0;
1731
- if (t !== void 0 && t > 0) return Number((Math.round(e / t) * t).toFixed(te(t)));
1845
+ if (t !== void 0 && t > 0) return Number((Math.round(e / t) * t).toFixed(re(t)));
1732
1846
  let { min: n, max: r } = this.viewport.getState().priceRange;
1733
1847
  return Number(e.toFixed(this.marketPricePrecision ?? s(n, r)));
1734
1848
  }
@@ -1739,7 +1853,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
1739
1853
  return this.priceFormatter;
1740
1854
  }
1741
1855
  applyPriceFormat(e) {
1742
- this.priceFormatter = g(e), this.priceUnit = e && typeof e != "function" ? u(e) : null, this.viewport.setPriceFormat(this.priceFormatter, this.priceUnit), this.crosshairTooltip.setPriceFormatter(this.priceFormatter), this.pinnedTooltip.setPriceFormatter(this.priceFormatter);
1856
+ this.priceFormatter = _(e), this.priceUnit = e && typeof e != "function" ? d(e) : null, this.viewport.setPriceFormat(this.priceFormatter, this.priceUnit), this.crosshairTooltip.setPriceFormatter(this.priceFormatter), this.pinnedTooltip.setPriceFormatter(this.priceFormatter);
1743
1857
  }
1744
1858
  setTimeFormatter(e) {
1745
1859
  this.applyTimeFormatter(e), this.engine.requestRender();
@@ -1750,7 +1864,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
1750
1864
  formatPrice(e) {
1751
1865
  if (this.priceFormatter) return this.priceFormatter(e);
1752
1866
  let { min: t, max: n } = this.viewport.getState().priceRange;
1753
- return l(e, this.marketPricePrecision ?? s(t, n), this.numberLocale);
1867
+ return u(e, this.marketPricePrecision ?? s(t, n), this.numberLocale);
1754
1868
  }
1755
1869
  setDrawingTool(e) {
1756
1870
  this.features.drawings && (e && this.features.drawingTools.length > 0 && !this.features.drawingTools.includes(e) || (e && this.setZoomAreaMode(!1), this.drawingManager.setActiveTool(e)));
@@ -1795,7 +1909,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
1795
1909
  }
1796
1910
  autoFib() {
1797
1911
  if (!this.features.drawings) return null;
1798
- let e = this.getDisplayData(), t = this.viewport.getState(), n = gt(e, t.visibleRange.from, t.visibleRange.to);
1912
+ let e = this.getDisplayData(), t = this.viewport.getState(), n = _t(e, t.visibleRange.from, t.visibleRange.to);
1799
1913
  return n ? this.addDrawing({
1800
1914
  type: "fibRetracement",
1801
1915
  anchors: [n[0], n[1]]
@@ -1870,7 +1984,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
1870
1984
  recordUndo(e) {
1871
1985
  if (!this.features.drawingUndoRedo || typeof e?.undo != "function" || typeof e.redo != "function") return;
1872
1986
  let t = performance.now(), n = this.undoRedoManager.last();
1873
- if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at < xn) {
1987
+ if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at < Nn) {
1874
1988
  this.undoRedoManager.replaceLast({
1875
1989
  ...n,
1876
1990
  custom: {
@@ -1917,7 +2031,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
1917
2031
  x: t.x,
1918
2032
  y: t.y
1919
2033
  };
1920
- if ((e === "plot" || e === "priceAxis") && (r.price = jt(t.y, n)), (e === "plot" || e === "timeAxis") && n.data.length > 0 && (r.time = D(t.x, n)), e === "pane") {
2034
+ if ((e === "plot" || e === "priceAxis") && (r.price = F(t.y, n)), (e === "plot" || e === "timeAxis") && n.data.length > 0 && (r.time = P(t.x, n)), e === "pane") {
1921
2035
  let e = this.getIndicatorPanes().find((e) => t.y >= e.rect.y && t.y <= e.rect.y + e.rect.height);
1922
2036
  e && (r.pane = e.instanceId);
1923
2037
  }
@@ -1943,7 +2057,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
1943
2057
  ...this.viewport.getState(),
1944
2058
  data: this.getDisplayData()
1945
2059
  };
1946
- this.setVisibleRange(D(e.x0, t), D(e.x1, t));
2060
+ this.setVisibleRange(P(e.x0, t), P(e.x1, t));
1947
2061
  }
1948
2062
  lockAllDrawings() {
1949
2063
  this.drawingManager.lockAllDrawings();
@@ -2012,11 +2126,11 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
2012
2126
  }
2013
2127
  getExportText(e = "csv", t = {}) {
2014
2128
  let { bars: n, columns: r } = this.getExportData(t);
2015
- return e === "json" ? x.toJSON(n, r) : x.toCSV(n, r);
2129
+ return e === "json" ? C.toJSON(n, r) : C.toCSV(n, r);
2016
2130
  }
2017
2131
  download(e, t, n) {
2018
2132
  let r = this.getExportText(e, n);
2019
- e === "json" ? x.download(r, t ?? "chart-data.json", "application/json") : x.download(r, t ?? "chart-data.csv", "text/csv");
2133
+ e === "json" ? C.download(r, t ?? "chart-data.json", "application/json") : C.download(r, t ?? "chart-data.csv", "text/csv");
2020
2134
  }
2021
2135
  setAutoSave(e, t = 5e3) {
2022
2136
  this.autoSaveScheduler.enable(e, t);
@@ -2066,7 +2180,11 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
2066
2180
  this.recordIndicators(e, () => this.updateIndicatorStyleNow(e, t));
2067
2181
  }
2068
2182
  updateIndicatorStyleNow(e, t) {
2069
- this.indicatorEngine.updateIndicatorStyle(e, t), this.engine.requestRender(), this.markStateChanged(), this.eventBus.emit("indicatorChange", {
2183
+ let { plots: n, ...r } = t, i = n === void 0 ? void 0 : b(n);
2184
+ this.indicatorEngine.updateIndicatorStyle(e, {
2185
+ ...r,
2186
+ ...i ? { plots: i } : {}
2187
+ }), this.engine.requestRender(), this.markStateChanged(), this.eventBus.emit("indicatorChange", {
2070
2188
  instanceId: e,
2071
2189
  change: "style"
2072
2190
  });
@@ -2172,8 +2290,8 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
2172
2290
  this.features.trading && this.tradingManager.setConfig(e);
2173
2291
  }
2174
2292
  async connect(e) {
2175
- if (!w(e.adapter, e.timeframe)) throw RangeError(`${e.adapter.name} cannot serve the ${e.timeframe} timeframe`);
2176
- this.snapshotKey = null, this.replayStop(), this.disconnectStream(), this.streamManager = new nt(), this.streamManager.on("snapshot", (t) => {
2293
+ if (!A(e.adapter, e.timeframe)) throw RangeError(`${e.adapter.name} cannot serve the ${e.timeframe} timeframe`);
2294
+ this.snapshotKey = null, this.replayStop(), this.disconnectStream(), this.streamManager = new rt(), this.streamManager.on("snapshot", (t) => {
2177
2295
  let n = `${this.currentSymbol}|${this.streamTimeframe}`;
2178
2296
  this.replaySession ? this.replaySession.live.setData(t) : n === this.snapshotKey && this.dataManager.getLength() > 0 ? this.mergeSnapshot(t) : this.setData(t), this.snapshotKey = n, this.useStreamHistory(e.adapter, e.historyPageSize);
2179
2297
  }), this.streamManager.on("barClose", (e) => {
@@ -2222,7 +2340,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
2222
2340
  }), this.autoScrollOnNewBar = e.autoScroll !== !1, this.setStreamTarget(e.symbol, e.timeframe), this.streamAdapter = e.adapter;
2223
2341
  let t = this.streamManager;
2224
2342
  if (this.resolveStreamSymbol(e.adapter, e.symbol), await t.connect(e), this.streamManager !== t) return;
2225
- let n = y(e.timeframe);
2343
+ let n = ae(e.timeframe);
2226
2344
  this.barCountdown.setTimeframeMs(n), this.countdownInterval && clearInterval(this.countdownInterval), this.countdownInterval = setInterval(() => {
2227
2345
  this.barCountdown.isVisible() && this.engine.requestRender(r.Hover);
2228
2346
  }, 1e3);
@@ -2240,8 +2358,8 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
2240
2358
  async switchStream(e, t) {
2241
2359
  if (!this.streamManager) return;
2242
2360
  let n = this.streamAdapter;
2243
- if (n && !w(n, t)) throw RangeError(`${n.name} cannot serve the ${t} timeframe`);
2244
- this.setStreamTarget(e, t), this.historyFromStream && this.history.setLoader(null), this.barCountdown.setTimeframeMs(y(t)), n && this.resolveStreamSymbol(n, e), await this.streamManager.switchTo(e, t);
2361
+ if (n && !A(n, t)) throw RangeError(`${n.name} cannot serve the ${t} timeframe`);
2362
+ this.setStreamTarget(e, t), this.historyFromStream && this.history.setLoader(null), this.barCountdown.setTimeframeMs(ae(t)), n && this.resolveStreamSymbol(n, e), await this.streamManager.switchTo(e, t);
2245
2363
  }
2246
2364
  isTimeframeAllowed(e) {
2247
2365
  let t = this.features.timeframes;
@@ -2256,7 +2374,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
2256
2374
  }
2257
2375
  connectExecution(e, t = {}) {
2258
2376
  if (!this.features.trading) throw Error("connectExecution requires features.trading to be enabled");
2259
- this.disconnectExecution(), this.executionAdapter = e, this.execTeardown = mn(e, {
2377
+ this.disconnectExecution(), this.executionAdapter = e, this.execTeardown = En(e, {
2260
2378
  onIntent: (e, t) => {
2261
2379
  let n = (e) => t(e.payload);
2262
2380
  return this.eventBus.on(e, n), () => this.eventBus.off(e, n);
@@ -2347,18 +2465,18 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
2347
2465
  goToTime(e) {
2348
2466
  let t = this.getDisplayData();
2349
2467
  if (t.length === 0 || !Number.isFinite(e)) return -1;
2350
- let n = Math.max(0, Math.min(t.length - 1, Math.floor(E(e, t)))), r = this.viewport.getState(), i = n * (r.barWidth + r.barSpacing) + r.barWidth / 2 - r.chartRect.width / 2;
2468
+ let n = Math.max(0, Math.min(t.length - 1, Math.floor(M(e, t)))), r = this.viewport.getState(), i = n * (r.barWidth + r.barSpacing) + r.barWidth / 2 - r.chartRect.width / 2;
2351
2469
  return this.viewport.scrollBy(i - r.offset), this.updateViewportAndRender(), n;
2352
2470
  }
2353
2471
  setVisibleRangePreset(e) {
2354
2472
  let t = this.getDisplayData();
2355
2473
  if (t.length === 0) return;
2356
- let n = t.length - 1, r = t[n].time > gn ? 1 : 1e3, i = bt(e, t[n].time * r, this.displayTz), a = i === null ? null : i / r;
2474
+ let n = t.length - 1, r = t[n].time > On ? 1 : 1e3, i = St(e, t[n].time * r, this.displayTz), a = i === null ? null : i / r;
2357
2475
  if (a === null || a < t[0].time) {
2358
2476
  this.fitContent();
2359
2477
  return;
2360
2478
  }
2361
- let o = E(a, t), s = Math.min(n, e === "YTD" ? Math.ceil(o) : Math.floor(o) + 1);
2479
+ let o = M(a, t), s = Math.min(n, e === "YTD" ? Math.ceil(o) : Math.floor(o) + 1);
2362
2480
  this.viewport.zoomToBarRange(s, n + this.viewport.getRightMargin()), this.viewport.scrollToEnd(), this.updateViewportAndRender();
2363
2481
  }
2364
2482
  scrollToEnd() {
@@ -2372,7 +2490,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
2372
2490
  setVisibleRange(e, t) {
2373
2491
  let n = this.dataManager.getData();
2374
2492
  if (n.length === 0) return;
2375
- let r = E(Math.min(e, t), n), i = E(Math.max(e, t), n);
2493
+ let r = M(Math.min(e, t), n), i = M(Math.max(e, t), n);
2376
2494
  this.viewport.zoomToBarRange(r, i), this.updateViewportAndRender();
2377
2495
  }
2378
2496
  setPanLimits(e) {
@@ -2406,10 +2524,41 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
2406
2524
  this.eventBus.disableTauriBridge();
2407
2525
  }
2408
2526
  setTheme(e) {
2409
- this.themeManager.setTheme(e), this.syncRenderContext(), this.container.style.backgroundColor = this.themeManager.getTheme().background, this.engine.requestRender(), this.eventBus.emit("themeChange", { theme: e }), this.markStateChanged();
2527
+ this.themeManager.setTheme(e), this.syncRenderContext(), this.container.style.backgroundColor = this.themeManager.getTheme().background, this.lastBackground = this.themeManager.getTheme().background, this.engine.requestRender(), this.eventBus.emit("themeChange", { theme: e }), this.markStateChanged();
2410
2528
  }
2411
2529
  getTheme() {
2412
- return this.themeManager.getTheme();
2530
+ return this.themeManager.getBaseTheme();
2531
+ }
2532
+ applyOverrides(e, t = {}) {
2533
+ this.applyStyle(e, t.layer ?? "host", !0);
2534
+ }
2535
+ setOverrides(e, t = {}) {
2536
+ let n = t.layer ?? "host", { overrides: r, rejected: i } = v(e);
2537
+ i.length > 0 && console.warn(`Style overrides left out (unknown key or value): ${i.join(", ")}`);
2538
+ let a = Object.fromEntries(Object.entries(r).filter(([, e]) => e !== null));
2539
+ this.themeManager.setOverrides(a, n) && this.styleChanged(n);
2540
+ }
2541
+ resetOverrides(e, t = {}) {
2542
+ let n = t.layer ?? "host";
2543
+ this.themeManager.resetOverrides(n, e) && this.styleChanged(n);
2544
+ }
2545
+ getOverrides(e = {}) {
2546
+ return this.themeManager.getOverrides(e.layer ?? "host");
2547
+ }
2548
+ getStyle() {
2549
+ return this.themeManager.getTheme().style;
2550
+ }
2551
+ getStyleValue(e) {
2552
+ return this.themeManager.getStyleValue(e);
2553
+ }
2554
+ applyStyle(e, t, n) {
2555
+ let { overrides: r, rejected: i } = v(e);
2556
+ i.length > 0 && console.warn(`Style overrides left out (unknown key or value): ${i.join(", ")}`), this.themeManager.applyOverrides(r, t) && n && this.styleChanged(t);
2557
+ }
2558
+ styleChanged(e) {
2559
+ this.syncRenderContext();
2560
+ let t = this.themeManager.getTheme().background;
2561
+ t !== this.lastBackground && (this.container.style.backgroundColor = t, this.lastBackground = t), this.engine.requestRender(), this.eventBus.emit("styleChange", { layer: e }), e === "user" && this.markStateChanged();
2413
2562
  }
2414
2563
  setWatermark(e, t) {
2415
2564
  this.watermark.setConfig({
@@ -2433,7 +2582,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
2433
2582
  e ? this.crosshairHandler.onPointerMove(e) : this.crosshairHandler.onPointerLeave(), this.engine.requestRender(r.Hover);
2434
2583
  }
2435
2584
  setCrosshairTime(e) {
2436
- let t = this.getDisplayData(), n = e === null || t.length === 0 ? null : Math.floor(E(e, t));
2585
+ let t = this.getDisplayData(), n = e === null || t.length === 0 ? null : Math.floor(M(e, t));
2437
2586
  n !== this.crosshairHandler.getSyncedSlot() && (this.crosshairHandler.setSyncedSlot(n), this.engine.requestRender(r.Hover));
2438
2587
  }
2439
2588
  getData() {
@@ -2495,7 +2644,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
2495
2644
  this.periodLevels.setPeriod(e), this.engine.requestRender(r.Main);
2496
2645
  }
2497
2646
  setTimezone(e) {
2498
- vn(e), this.timezoneSetting = e, this.applyTimezone();
2647
+ An(e), this.timezoneSetting = e, this.applyTimezone();
2499
2648
  }
2500
2649
  getTimezone() {
2501
2650
  return this.timezoneSetting;
@@ -2504,7 +2653,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
2504
2653
  return this.displayTz;
2505
2654
  }
2506
2655
  applyTimezone() {
2507
- let e = this.symbolInfo?.timezone, t = this.timezoneSetting === "exchange" ? e && f(e) ? e : "UTC" : this.timezoneSetting;
2656
+ let e = this.symbolInfo?.timezone, t = this.timezoneSetting === "exchange" ? e && p(e) ? e : "UTC" : this.timezoneSetting;
2508
2657
  this.displayTz = t, this.timeAxis.setTimezoneOffset(t), this.crosshairHandler.setTimezoneOffset(t), this.crosshairTooltip.setTimezoneOffset(t), this.pinnedTooltip.setTimezone(t), this.sessionBreaks.setTimezone(t), this.engine.requestRender();
2509
2658
  }
2510
2659
  setSymbolInfo(e) {
@@ -2513,13 +2662,13 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
2513
2662
  sessions: e.sessions?.map((e) => ({ ...e }))
2514
2663
  } : null, this.marketConfig?.pricePrecision === void 0 && this.applyPricePrecision(this.symbolInfo?.pricePrecision ?? null);
2515
2664
  let t = (this.symbolInfo?.sessions ?? []).flatMap((e) => {
2516
- let t = v(e.start), n = v(e.end);
2665
+ let t = x(e.start), n = x(e.end);
2517
2666
  return t === null || n === null ? [] : [{
2518
2667
  startMinute: t,
2519
2668
  endMinute: n
2520
2669
  }];
2521
2670
  }), n = this.symbolInfo?.timezone;
2522
- this.sessionShading.replaceConfig(t.length > 0 && n && f(n) ? {
2671
+ this.sessionShading.replaceConfig(t.length > 0 && n && p(n) ? {
2523
2672
  timeZone: n,
2524
2673
  windows: t,
2525
2674
  startMinute: t[0].startMinute,
@@ -2558,7 +2707,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
2558
2707
  return this.sessionShading.isVisible();
2559
2708
  }
2560
2709
  setSessionShadingConfig(e) {
2561
- this.hostSessionHours = yt(this.hostSessionHours, e), this.sessionShading.replaceConfig(this.hostSessionHours), this.engine.requestRender(r.Background);
2710
+ this.hostSessionHours = xt(this.hostSessionHours, e), this.sessionShading.replaceConfig(this.hostSessionHours), this.engine.requestRender(r.Background);
2562
2711
  }
2563
2712
  setTooltipVisible(e) {
2564
2713
  e || this.crosshairTooltip.hide();
@@ -2574,10 +2723,14 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
2574
2723
  }
2575
2724
  async setRenderer(e) {
2576
2725
  let t = ++this.rendererToken;
2577
- if (e === "canvas") return this.applyRenderer(null), "canvas";
2578
- if (this.engine.getGpu()) return "webgl";
2579
- let n = await vt(e);
2580
- return t !== this.rendererToken || this.disposed ? (n?.destroy(), this.getRenderer()) : (this.applyRenderer(n, n ? void 0 : "unsupported"), this.getRenderer());
2726
+ return this.waitForGpu(null), e === "canvas" ? (this.applyRenderer(null), "canvas") : this.engine.getGpu() ? "webgl" : this.takeGpu(e, t, !0);
2727
+ }
2728
+ async takeGpu(e, t, n) {
2729
+ let { gpu: r, reason: i } = await bt(e);
2730
+ return t !== this.rendererToken || this.disposed ? (r?.destroy(), this.getRenderer()) : i === "limit" ? vt() > 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());
2731
+ }
2732
+ waitForGpu(e) {
2733
+ this.stopWaitingForGpu?.(), this.stopWaitingForGpu = e ? At(e) : null;
2581
2734
  }
2582
2735
  getRenderer() {
2583
2736
  return this.engine.getGpu() ? "webgl" : "canvas";
@@ -2595,23 +2748,23 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
2595
2748
  this.engine.getGpu() && this.engine.renderNow();
2596
2749
  }
2597
2750
  screenshot(e) {
2598
- this.features.screenshot && (this.freshFrame(), S.download(this.container, e, this.themeManager.getTheme().background));
2751
+ this.features.screenshot && (this.freshFrame(), O.download(this.container, e, this.themeManager.getTheme().background));
2599
2752
  }
2600
2753
  async copyScreenshot() {
2601
2754
  if (!this.features.screenshot) return !1;
2602
2755
  try {
2603
2756
  this.freshFrame();
2604
- let e = await S.toBlob(this.container, this.themeManager.getTheme().background), t = globalThis.ClipboardItem;
2757
+ let e = await O.toBlob(this.container, this.themeManager.getTheme().background), t = globalThis.ClipboardItem;
2605
2758
  return !e || !navigator.clipboard?.write || !t ? !1 : (await navigator.clipboard.write([new t({ "image/png": e })]), !0);
2606
2759
  } catch {
2607
2760
  return !1;
2608
2761
  }
2609
2762
  }
2610
2763
  screenshotDataURL() {
2611
- return this.features.screenshot ? (this.freshFrame(), S.toDataURL(this.container, this.themeManager.getTheme().background)) : null;
2764
+ return this.features.screenshot ? (this.freshFrame(), O.toDataURL(this.container, this.themeManager.getTheme().background)) : null;
2612
2765
  }
2613
2766
  async screenshotBlob() {
2614
- return this.features.screenshot ? (this.freshFrame(), S.toBlob(this.container, this.themeManager.getTheme().background)) : null;
2767
+ return this.features.screenshot ? (this.freshFrame(), O.toBlob(this.container, this.themeManager.getTheme().background)) : null;
2615
2768
  }
2616
2769
  addAlert(e, t = "crossing", n, r = "price", i, a = {}) {
2617
2770
  if (!this.features.alerts) return null;
@@ -2737,27 +2890,27 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
2737
2890
  if (!this.features.replay) return;
2738
2891
  if (this.history.reset(), !this.replaySession) {
2739
2892
  if (this.dataManager.getLength() === 0) return;
2740
- let e = new j();
2893
+ let e = new B();
2741
2894
  e.setData(this.fullSeries ?? this.dataManager.getData()), this.replaySession = {
2742
2895
  live: e,
2743
2896
  price: null,
2744
2897
  fedTime: null
2745
2898
  };
2746
2899
  }
2747
- let t = this.shownBars(this.replaySession.live.getData()), { steps: n, ...r } = e ?? {}, i = n ? Nn(n, t) : null;
2900
+ let t = this.shownBars(this.replaySession.live.getData()), { steps: n, ...r } = e ?? {}, i = n ? Gn(n, t) : null;
2748
2901
  this.replayStepsSeries = i, this.replayCoarse = t, this.options.autoScale = !0, this.replayRestarting = !0;
2749
2902
  try {
2750
2903
  this.replayManager.load(i ?? t);
2751
2904
  } finally {
2752
2905
  this.replayRestarting = !1;
2753
2906
  }
2754
- i && r.startIndex !== void 0 && (r.startIndex = In(i, t, r.startIndex)), this.replayBarUnsub?.();
2907
+ i && r.startIndex !== void 0 && (r.startIndex = Jn(i, t, r.startIndex)), this.replayBarUnsub?.();
2755
2908
  let a = -1, o = -1, s = null, c = i ?? t;
2756
2909
  this.replayBarUnsub = this.replayManager.on("bar", ({ index: e }) => {
2757
2910
  let n = e, r = t[e];
2758
2911
  if (i) {
2759
2912
  let c = i[e];
2760
- n = Fn(t, c.time), s = s !== null && o === e - 1 && n === a - 1 && s ? Rn(s, c) : Ln(t[n], i, e), r = s;
2913
+ n = qn(t, c.time), s = s !== null && o === e - 1 && n === a - 1 && s ? Xn(s, c) : Yn(t[n], i, e), r = s;
2761
2914
  }
2762
2915
  o = e;
2763
2916
  let l = n + 1, u = a > 0 && l >= a && this.dataManager.getLength() === a, d = !(u && !this.replaySeeking) || this.autoScrollOnNewBar && this.viewport.isAtEnd();
@@ -2802,20 +2955,20 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
2802
2955
  return;
2803
2956
  }
2804
2957
  if (i.time <= n.fedTime) return;
2805
- let a = e.slice(An(e, n.fedTime), t + 1);
2958
+ let a = e.slice(Hn(e, n.fedTime), t + 1);
2806
2959
  n.fedTime = i.time;
2807
- let o = Math.ceil(a.length / kn);
2808
- for (let e = 0; e < a.length; e += o) for (let [t, n] of jn(a.slice(e, e + o))) r.setMarkPrice(t, n);
2960
+ let o = Math.ceil(a.length / Vn);
2961
+ for (let e = 0; e < a.length; e += o) for (let [t, n] of Un(a.slice(e, e + o))) r.setMarkPrice(t, n);
2809
2962
  this.tradingManager.setCurrentPrice(i.close);
2810
2963
  }
2811
2964
  getReplayBarIndex() {
2812
2965
  if (!this.replaySession) return -1;
2813
2966
  let { current: e } = this.replayManager.getProgress(), t = this.replayStepsSeries;
2814
- return t && this.replayCoarse ? Fn(this.replayCoarse, t[e]?.time ?? -Infinity) : e;
2967
+ return t && this.replayCoarse ? qn(this.replayCoarse, t[e]?.time ?? -Infinity) : e;
2815
2968
  }
2816
2969
  replaySeekToBar(e) {
2817
2970
  let t = this.replayStepsSeries;
2818
- this.replaySeek(t && this.replayCoarse ? In(t, this.replayCoarse, e) : e);
2971
+ this.replaySeek(t && this.replayCoarse ? Jn(t, this.replayCoarse, e) : e);
2819
2972
  }
2820
2973
  replayPause() {
2821
2974
  this.replayManager.pause();
@@ -2860,11 +3013,12 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
2860
3013
  return this.replayManager.getProgress();
2861
3014
  }
2862
3015
  captureSnapshot() {
2863
- return b.capture({
3016
+ return S.capture({
2864
3017
  getDrawings: () => this.getDrawings(),
2865
- getTheme: () => this.getTheme(),
3018
+ getTheme: () => this.themeManager.getBaseTheme(),
2866
3019
  getAlerts: () => this.getAlerts(),
2867
- getIndicators: () => this.getIndicatorSetup()
3020
+ getIndicators: () => this.getIndicatorSetup(),
3021
+ getOverrides: () => this.themeManager.getUserOverrides()
2868
3022
  }, {
2869
3023
  chartType: this.options.chartType,
2870
3024
  chartTypeOptions: this.getChartTypeOptions(),
@@ -2872,14 +3026,14 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
2872
3026
  });
2873
3027
  }
2874
3028
  restoreIndicators(e, t) {
2875
- let n = Tn(e), r = /* @__PURE__ */ new Map();
3029
+ let n = Ln(e), r = /* @__PURE__ */ new Map();
2876
3030
  this.unrestoredIndicators = [];
2877
3031
  let i = new Set(this.indicatorEngine.getAvailableIndicators().map((e) => e.id)), a = [], o = /* @__PURE__ */ new Set();
2878
3032
  if (t) {
2879
3033
  let e = new Map(n.map((e) => [e.instanceId, e])), t = this.getIndicatorSetup();
2880
3034
  for (let n of t) {
2881
3035
  let t = e.get(n.instanceId);
2882
- t && En(n, t) && o.add(n.instanceId);
3036
+ t && Rn(n, t) && o.add(n.instanceId);
2883
3037
  }
2884
3038
  for (let e of t) o.has(e.instanceId) || this.removeIndicator(e.instanceId);
2885
3039
  for (let e of [...o]) this.indicatorEngine.getIndicatorConfig(e) || o.delete(e);
@@ -2887,8 +3041,8 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
2887
3041
  let s = (e) => {
2888
3042
  let t = { ...e };
2889
3043
  for (let [e, n] of Object.entries(t)) {
2890
- let i = h(n), a = i && r.get(i.instanceId);
2891
- a && (t[e] = d(a, i.key));
3044
+ let i = g(n), a = i && r.get(i.instanceId);
3045
+ a && (t[e] = f(a, i.key));
2892
3046
  }
2893
3047
  return t;
2894
3048
  };
@@ -2927,15 +3081,19 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
2927
3081
  return this.restorePanes(a), this.updateViewportAndRender(), r;
2928
3082
  }
2929
3083
  restoreLooks(e, t) {
2930
- let n = this.indicatorEngine.getIndicatorStyle(e);
3084
+ let { plots: n, ...r } = this.indicatorEngine.getIndicatorStyle(e) ?? {
3085
+ colors: [],
3086
+ lineWidths: [],
3087
+ opacity: 1
3088
+ }, { plots: i, ...a } = t.style ?? {};
2931
3089
  t.style && JSON.stringify({
2932
- ...n,
2933
- ...t.style
2934
- }) !== JSON.stringify(n) && this.updateIndicatorStyle(e, t.style);
2935
- let r = this.indicatorEngine.getIndicatorConfig(e);
2936
- (t.visible ?? !0) !== (r?.visible ?? !0) && this.setIndicatorVisible(e, t.visible ?? !0);
2937
- let i = t.levels ?? null;
2938
- JSON.stringify(i) !== JSON.stringify(r?.levels ?? null) && this.setIndicatorLevels(e, i);
3090
+ ...r,
3091
+ ...a
3092
+ }) !== JSON.stringify(r) && this.updateIndicatorStyle(e, a), JSON.stringify(i ?? {}) !== JSON.stringify(n ?? {}) && (this.indicatorEngine.setPlotStyles(e, i ?? null), this.engine.requestRender());
3093
+ let o = this.indicatorEngine.getIndicatorConfig(e);
3094
+ (t.visible ?? !0) !== (o?.visible ?? !0) && this.setIndicatorVisible(e, t.visible ?? !0);
3095
+ let s = t.levels ?? null;
3096
+ JSON.stringify(s) !== JSON.stringify(o?.levels ?? null) && this.setIndicatorLevels(e, s), this.setPaneStyleNow(e, t.paneStyle ? ee(t.paneStyle) : null);
2939
3097
  }
2940
3098
  restorePanes(e) {
2941
3099
  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, {
@@ -2962,6 +3120,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
2962
3120
  levels: i?.levels?.slice(),
2963
3121
  pane: n.pane,
2964
3122
  scale: i?.scale,
3123
+ ...r && this.paneStyles.has(n.instanceId) ? { paneStyle: { ...this.paneStyles.get(n.instanceId) } } : {},
2965
3124
  ...r ? {
2966
3125
  paneSize: r.size,
2967
3126
  paneOrder: e.indexOf(r),
@@ -3015,7 +3174,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
3015
3174
  if (this.indicatorHistoryDepth > 0 || !this.features.drawingUndoRedo) return t();
3016
3175
  let n = this.getIndicatorSetup(), r = this.withoutIndicatorHistory(t), i = this.getIndicatorSetup();
3017
3176
  if (JSON.stringify(n) === JSON.stringify(i)) return r;
3018
- let a = performance.now(), o = this.undoRedoManager.last(), s = e !== void 0 && o?.type === "indicators" && o.indicators?.subject === e && a - (o.indicators.at ?? 0) < xn && JSON.stringify(o.indicators.after) === JSON.stringify(n), c = {
3177
+ let a = performance.now(), o = this.undoRedoManager.last(), s = e !== void 0 && o?.type === "indicators" && o.indicators?.subject === e && a - (o.indicators.at ?? 0) < Nn && JSON.stringify(o.indicators.after) === JSON.stringify(n), c = {
3019
3178
  type: "indicators",
3020
3179
  before: null,
3021
3180
  after: null
@@ -3043,13 +3202,13 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
3043
3202
  }
3044
3203
  saveState(e) {
3045
3204
  if (!this.features.saveLoad) return null;
3046
- let t = this.captureSnapshot(), n = b.serialize(t);
3047
- return e && b.saveToStorage(e, t), n;
3205
+ let t = this.captureSnapshot(), n = S.serialize(t);
3206
+ return e && S.saveToStorage(e, t), n;
3048
3207
  }
3049
3208
  loadState(e) {
3050
3209
  if (!this.features.saveLoad) return;
3051
- let t = b.deserialize(e);
3052
- this.chartTypeOptions = t.chartTypeOptions ?? {}, this.displayDataCache = null, t.chartType && this.setChartType(t.chartType), t.drawings && this.setDrawings(t.drawings), t.theme && this.setTheme(t.theme);
3210
+ let t = S.deserialize(e);
3211
+ this.chartTypeOptions = t.chartTypeOptions ?? {}, this.displayDataCache = null, t.chartType && this.setChartType(t.chartType), t.drawings && this.setDrawings(t.drawings), (t.theme === "dark" || t.theme === "light") && this.setTheme(t.theme), t.version >= 3 && this.themeManager.setUserOverrides(t.overrides ?? {}) && this.styleChanged("user");
3053
3212
  let n = t.version >= 2 && this.features.indicators ? this.withoutIndicatorHistory(() => this.restoreIndicators(t.indicators, !1)) : /* @__PURE__ */ new Map();
3054
3213
  if (this.undoRedoManager.clear(), t.alerts && this.features.alerts) {
3055
3214
  this.alertManager.clearAlerts();
@@ -3059,7 +3218,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
3059
3218
  let t = e.indexOf(":"), r = t > 0 ? n.get(e.slice(0, t)) : void 0;
3060
3219
  return r ? r + e.slice(t) : e;
3061
3220
  }, r = t(e.channel), i = {
3062
- ...xt(e),
3221
+ ...Ct(e),
3063
3222
  ...e.target ? { target: t(e.target) } : {}
3064
3223
  };
3065
3224
  if (!e.expired) {
@@ -3079,19 +3238,19 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
3079
3238
  }
3080
3239
  loadStateFromStorage(e) {
3081
3240
  if (!this.features.saveLoad) return !1;
3082
- let t = b.loadFromStorage(e);
3083
- return t ? (this.loadState(b.serialize(t)), !0) : !1;
3241
+ let t = S.loadFromStorage(e);
3242
+ return t ? (this.loadState(S.serialize(t)), !0) : !1;
3084
3243
  }
3085
3244
  downloadState(e) {
3086
- this.features.saveLoad && b.downloadFile(this.captureSnapshot(), e);
3245
+ this.features.saveLoad && S.downloadFile(this.captureSnapshot(), e);
3087
3246
  }
3088
3247
  async loadStateFromFile() {
3089
3248
  if (!this.features.saveLoad) return;
3090
- let e = await b.loadFromFile();
3091
- this.loadState(b.serialize(e));
3249
+ let e = await S.loadFromFile();
3250
+ this.loadState(S.serialize(e));
3092
3251
  }
3093
3252
  setLocale(e) {
3094
- ee(e), this.engine.requestRender();
3253
+ ne(e), this.engine.requestRender();
3095
3254
  }
3096
3255
  setNumberLocale(e) {
3097
3256
  this.numberLocale = e, this.priceAxis.setLocale(e), this.leftPriceAxis.setLocale(e), this.crosshairHandler.setLocale(e), this.chartLegend.setLocale(e), this.crosshairTooltip.setLocale(e), this.sessionBreaks.setLocale(e), this.currentPriceLine.setLocale(e), this.updateViewportAndRender();
@@ -3102,26 +3261,26 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
3102
3261
  setMarket(e) {
3103
3262
  if (this.marketConfig = e, e.colorScheme) {
3104
3263
  let t = {
3105
- ...this.themeManager.getTheme(),
3264
+ ...this.themeManager.getBaseTheme(),
3106
3265
  candleUp: e.colorScheme.up,
3107
3266
  candleDown: e.colorScheme.down,
3108
3267
  candleUpWick: e.colorScheme.up,
3109
3268
  candleDownWick: e.colorScheme.down,
3110
- volumeUp: re(e.colorScheme.up),
3111
- volumeDown: re(e.colorScheme.down)
3269
+ volumeUp: oe(e.colorScheme.up),
3270
+ volumeDown: oe(e.colorScheme.down)
3112
3271
  };
3113
3272
  this.themeManager.setTheme(t);
3114
3273
  }
3115
3274
  e.pricePrecision !== void 0 && this.applyPricePrecision(e.pricePrecision), this.updateViewportAndRender();
3116
3275
  }
3117
3276
  applyPricePrecision(e) {
3118
- this.marketPricePrecision = e, this.tradingManager.setConfig({ pricePrecision: e ?? void 0 }), this.alertManager.setPricePrecision(e ?? yn), this.streamManager?.priceLine.setPricePrecision(e), this.currentPriceLine.setPricePrecision(e), this.crosshairHandler.setPricePrecision(e), this.chartLegend.setPricePrecision(e), this.crosshairTooltip.setPricePrecision(e);
3277
+ this.marketPricePrecision = e, this.tradingManager.setConfig({ pricePrecision: e ?? void 0 }), this.alertManager.setPricePrecision(e ?? jn), this.streamManager?.priceLine.setPricePrecision(e), this.currentPriceLine.setPricePrecision(e), this.crosshairHandler.setPricePrecision(e), this.chartLegend.setPricePrecision(e), this.crosshairTooltip.setPricePrecision(e);
3119
3278
  }
3120
3279
  getMarket() {
3121
3280
  return this.marketConfig;
3122
3281
  }
3123
3282
  setPriceLimits(e) {
3124
- this.marketConfig && (c(e, this.marketConfig) && (this.marketConfig.priceLimits = {
3283
+ this.marketConfig && (l(e, this.marketConfig) && (this.marketConfig.priceLimits = {
3125
3284
  ...this.marketConfig.priceLimits,
3126
3285
  referencePrice: e
3127
3286
  }), this.engine.requestRender());
@@ -3142,18 +3301,18 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
3142
3301
  this.viewport.resize(e.width, e.height), this.layoutManager.resize(e.width, e.height), this.updateViewportAndRender(n), this.eventBus.emit("resize", e);
3143
3302
  }
3144
3303
  destroy() {
3145
- this.disposed = !0, this.countdownInterval && clearInterval(this.countdownInterval), this.history.setLoader(null), this.disableAutoSave(), this.disconnectStream(), this.disconnectExecution(), this.onWindowKeyDown &&= (window.removeEventListener("keydown", this.onWindowKeyDown), null), this.keyboardHandler = null, this.a11y?.destroy(), this.a11y = null, this.interactionManager.detach(), this.tradingManager.destroy(), this.animator.dispose(), this.crosshairTooltip.destroy(), this.pinnedTooltip.destroy(), this.replayRestarting = !0, this.replayManager.dispose(), this.alertManager.dispose(), this.undoRedoManager.clear(), this.engine.destroy(), this.eventBus.destroy(), this.container.innerHTML = "";
3304
+ this.disposed = !0, this.waitForGpu(null), this.countdownInterval && clearInterval(this.countdownInterval), this.history.setLoader(null), this.disableAutoSave(), this.disconnectStream(), this.disconnectExecution(), this.onWindowKeyDown &&= (window.removeEventListener("keydown", this.onWindowKeyDown), null), this.keyboardHandler = null, this.a11y?.destroy(), this.a11y = null, this.interactionManager.detach(), this.tradingManager.destroy(), this.animator.dispose(), this.crosshairTooltip.destroy(), this.pinnedTooltip.destroy(), this.replayRestarting = !0, this.replayManager.dispose(), this.alertManager.dispose(), this.undoRedoManager.clear(), this.engine.destroy(), this.eventBus.destroy(), this.container.innerHTML = "";
3146
3305
  }
3147
3306
  createChartRenderer(e) {
3148
- let t = Jt(e, (e) => this.pluginManager.getChartType(e));
3149
- return t instanceof Oe && t.setPriceText((e) => this.formatPrice(e)), t;
3307
+ let t = Yt(e, (e) => this.pluginManager.getChartType(e));
3308
+ return t instanceof w && t.setPriceText((e) => this.formatPrice(e)), t;
3150
3309
  }
3151
3310
  getDisplayData() {
3152
3311
  if (this.displayDataCache) return this.displayDataCache;
3153
3312
  let e = this.dataManager.getData();
3154
3313
  if (e.length === 0) return e;
3155
- let t = Yt(this.options.chartType, e, (e) => this.pluginManager.getChartType(e), this.chartTypeOptions);
3156
- return this.displayDataCache = t, t;
3314
+ let t = Xt(this.options.chartType, e, (e) => this.pluginManager.getChartType(e), this.chartTypeOptions);
3315
+ return this.chartRenderer instanceof E && !this.pluginManager.getChartType(this.options.chartType) && this.chartRenderer.setBoxSize(qt(e, this.chartTypeOptions)), this.displayDataCache = t, t;
3157
3316
  }
3158
3317
  recalcIndicatorsFrom(e, t) {
3159
3318
  this.indicatorEngine.recalculateFrom(e, t), this.announceIndicatorUpdate(t);
@@ -3185,7 +3344,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
3185
3344
  this.viewport.setScaleBaseline(t[e]?.close);
3186
3345
  }
3187
3346
  if (n) {
3188
- let e = On(this.indicatorEngine.getOverlayPriceRange(r.visibleRange.from, Math.min(r.visibleRange.to, t.length - 1)), this.features.compareSymbols ? this.compareRenderer.getPriceRange(t, r) : null);
3347
+ let e = Bn(this.indicatorEngine.getOverlayPriceRange(r.visibleRange.from, Math.min(r.visibleRange.to, t.length - 1)), this.features.compareSymbols ? this.compareRenderer.getPriceRange(t, r) : null);
3189
3348
  if (e) {
3190
3349
  let t = r.priceRange, n = Math.min(t.min, e.min), i = Math.max(t.max, e.max);
3191
3350
  if (n < t.min || i > t.max) {
@@ -3209,7 +3368,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
3209
3368
  fitLeftAxisWidth() {
3210
3369
  let e = this.leftViewport;
3211
3370
  if (!e) return !1;
3212
- let t = this.themeManager.getTheme(), n = z({
3371
+ let t = this.themeManager.getTheme(), n = mn({
3213
3372
  min: e.priceRange.min,
3214
3373
  max: e.priceRange.max,
3215
3374
  lastPrice: null,
@@ -3218,12 +3377,12 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
3218
3377
  fontFamily: t.font.family,
3219
3378
  fontSizeSmall: t.font.sizeSmall,
3220
3379
  measure: (e, t) => this.measureText(e, t)
3221
- }), r = B(this.leftAxisWidth, n);
3380
+ }), r = hn(this.leftAxisWidth, n);
3222
3381
  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);
3223
3382
  }
3224
3383
  fitPriceAxisWidth() {
3225
3384
  if (!this.features.priceAxis) return !1;
3226
- let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n = z({
3385
+ let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n = mn({
3227
3386
  min: e.min,
3228
3387
  max: e.max,
3229
3388
  lastPrice: this.currentPriceLine.getPrice(),
@@ -3233,7 +3392,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
3233
3392
  fontFamily: t.font.family,
3234
3393
  fontSizeSmall: t.font.sizeSmall,
3235
3394
  measure: (e, t) => this.measureText(e, t)
3236
- }), r = B(this.priceAxisWidth, n);
3395
+ }), r = hn(this.priceAxisWidth, n);
3237
3396
  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);
3238
3397
  }
3239
3398
  measureText(e, t) {
@@ -3277,15 +3436,16 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
3277
3436
  buildPanelRenderInfos() {
3278
3437
  if (this.panelInfoCache) return this.panelInfoCache;
3279
3438
  let e = this.getResolvedLayout(), t = this.viewport.getState(), { from: n, to: r } = t.visibleRange, i = e.panels.map((e) => {
3280
- 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) ?? { ...hn }, o = {
3439
+ 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) ?? { ...Dn }, o = {
3281
3440
  x: e.rect.x,
3282
3441
  y: e.rect.y + 20,
3283
3442
  width: e.rect.width,
3284
3443
  height: Math.max(0, e.rect.height - 20)
3285
- };
3444
+ }, s = this.paneStyles.get(e.config.id);
3286
3445
  return {
3287
3446
  instanceId: e.config.id,
3288
3447
  members: this.indicatorEngine.getPaneMembers(e.config.id),
3448
+ ...s ? { style: s } : {},
3289
3449
  rect: e.rect,
3290
3450
  viewport: {
3291
3451
  ...t,
@@ -3358,7 +3518,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
3358
3518
  });
3359
3519
  }
3360
3520
  drawOverlayPlugins(e, t) {
3361
- let n = V(this.pluginManager.getOverlays(), t);
3521
+ let n = vn(this.pluginManager.getOverlays(), t);
3362
3522
  if (n.length === 0) return;
3363
3523
  let r = {
3364
3524
  viewport: this.viewport.getState(),
@@ -3369,7 +3529,7 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
3369
3529
  }
3370
3530
  buildPriceLimits() {
3371
3531
  if (!this.marketConfig?.priceLimits?.enabled || !this.marketConfig.priceLimits.referencePrice) return null;
3372
- let e = c(this.marketConfig.priceLimits.referencePrice, this.marketConfig);
3532
+ let e = l(this.marketConfig.priceLimits.referencePrice, this.marketConfig);
3373
3533
  return e ? {
3374
3534
  ...e,
3375
3535
  colors: this.marketConfig.colorScheme ? {
@@ -3380,11 +3540,11 @@ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
3380
3540
  } : null;
3381
3541
  }
3382
3542
  };
3383
- function Tn(e) {
3543
+ function Ln(e) {
3384
3544
  let t = new Map(e.map((e) => [e.instanceId, e])), n = [], r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = (e) => {
3385
3545
  if (r.has(e.instanceId) || i.has(e.instanceId)) return;
3386
3546
  i.add(e.instanceId);
3387
- let o = [e.pane, ...Object.values(e.params).map((e) => h(e)?.instanceId)];
3547
+ let o = [e.pane, ...Object.values(e.params).map((e) => g(e)?.instanceId)];
3388
3548
  for (let e of o) {
3389
3549
  let n = e ? t.get(e) : void 0;
3390
3550
  n && a(n);
@@ -3394,15 +3554,20 @@ function Tn(e) {
3394
3554
  for (let t of e) a(t);
3395
3555
  return n;
3396
3556
  }
3397
- function En(e, t) {
3557
+ function Rn(e, t) {
3398
3558
  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);
3399
3559
  }
3400
- function Dn(e) {
3560
+ function zn(e) {
3401
3561
  let t = e.tagRadius;
3402
3562
  return typeof t == "number" && Number.isFinite(t) && t >= 0 ? { tagRadius: Math.min(t, 999) } : {};
3403
3563
  }
3404
- var W = new Set(["compareSymbol", "spread"]);
3405
- function On(e, t) {
3564
+ var W = new Set([
3565
+ "compareSymbol",
3566
+ "spread",
3567
+ "correlation",
3568
+ "correlationlog"
3569
+ ]);
3570
+ function Bn(e, t) {
3406
3571
  return e ? t ? {
3407
3572
  min: Math.min(e.min, t.min),
3408
3573
  max: Math.max(e.max, t.max)
@@ -3423,8 +3588,8 @@ function G(e) {
3423
3588
  bars: e.bars
3424
3589
  };
3425
3590
  }
3426
- var kn = 500;
3427
- function An(e, t) {
3591
+ var Vn = 500;
3592
+ function Hn(e, t) {
3428
3593
  let n = 0, r = e.length;
3429
3594
  for (; n < r;) {
3430
3595
  let i = n + r >> 1;
@@ -3432,20 +3597,20 @@ function An(e, t) {
3432
3597
  }
3433
3598
  return n;
3434
3599
  }
3435
- function jn(e) {
3600
+ function Un(e) {
3436
3601
  let t = 0, n = 0;
3437
3602
  for (let r = 1; r < e.length; r++) e[r].low < e[t].low && (t = r), e[r].high > e[n].high && (n = r);
3438
3603
  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];
3439
3604
  return [...a ? [r, i] : [i, r], [o.close, o.time]];
3440
3605
  }
3441
- function Mn(e) {
3606
+ function Wn(e) {
3442
3607
  let t = 0;
3443
3608
  for (let n = Math.max(1, e.length - 10); n < e.length; n++) t = Math.max(t, e[n].time - e[n - 1].time);
3444
3609
  return t > 0 ? t : Infinity;
3445
3610
  }
3446
- function Nn(e, t) {
3611
+ function Gn(e, t) {
3447
3612
  if (t.length === 0) return null;
3448
- let n = t[t.length - 1].time + Mn(t), r = e.filter((e) => Pn(e) && e.time >= t[0].time && e.time < n).sort((e, t) => e.time - t.time), i = [];
3613
+ let n = t[t.length - 1].time + Wn(t), r = e.filter((e) => Kn(e) && e.time >= t[0].time && e.time < n).sort((e, t) => e.time - t.time), i = [];
3449
3614
  for (let e of r) (i.length === 0 || i[i.length - 1].time !== e.time) && i.push(e);
3450
3615
  if (i.length === 0) return null;
3451
3616
  let a = t.findIndex((e) => e.time >= i[0].time);
@@ -3453,7 +3618,7 @@ function Nn(e, t) {
3453
3618
  let o = t.slice(0, a), s = i.filter((e) => e.time >= t[a].time);
3454
3619
  return [...o, ...s];
3455
3620
  }
3456
- function Pn(e) {
3621
+ function Kn(e) {
3457
3622
  return [
3458
3623
  e.time,
3459
3624
  e.open,
@@ -3462,7 +3627,7 @@ function Pn(e) {
3462
3627
  e.close
3463
3628
  ].every(Number.isFinite);
3464
3629
  }
3465
- function Fn(e, t) {
3630
+ function qn(e, t) {
3466
3631
  let n = 0, r = e.length - 1;
3467
3632
  for (; n < r;) {
3468
3633
  let i = n + r + 1 >> 1;
@@ -3470,22 +3635,22 @@ function Fn(e, t) {
3470
3635
  }
3471
3636
  return n;
3472
3637
  }
3473
- function In(e, t, n) {
3638
+ function Jn(e, t, n) {
3474
3639
  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;
3475
3640
  for (let t = 0; t < e.length && e[t].time < i; t++) a = t;
3476
3641
  return Math.max(0, a);
3477
3642
  }
3478
- function Ln(e, t, n) {
3643
+ function Yn(e, t, n) {
3479
3644
  let r = n;
3480
3645
  for (; r > 0 && t[r - 1].time >= e.time;) r--;
3481
3646
  let i = {
3482
3647
  ...t[r],
3483
3648
  time: e.time
3484
3649
  };
3485
- for (let e = r + 1; e <= n; e++) i = Rn(i, t[e]);
3650
+ for (let e = r + 1; e <= n; e++) i = Xn(i, t[e]);
3486
3651
  return i;
3487
3652
  }
3488
- function Rn(e, t) {
3653
+ function Xn(e, t) {
3489
3654
  return {
3490
3655
  time: e.time,
3491
3656
  open: e.open,
@@ -3498,31 +3663,31 @@ function Rn(e, t) {
3498
3663
  function K(e, t) {
3499
3664
  let n = e[e.length - 1];
3500
3665
  if (!n) return "append";
3501
- let r = m(t.time), i = m(n.time);
3666
+ let r = h(t.time), i = h(n.time);
3502
3667
  return r > i ? "append" : r === i ? "update" : "stale";
3503
3668
  }
3504
3669
  //#endregion
3505
3670
  //#region src/io/parseOHLCV.ts
3506
- var zn = [
3671
+ var Zn = [
3507
3672
  "time",
3508
3673
  "timestamp",
3509
3674
  "date",
3510
3675
  "datetime",
3511
3676
  "t"
3512
- ], Bn = ["open", "o"], Vn = ["high", "h"], Hn = ["low", "l"], Un = ["close", "c"], Wn = [
3677
+ ], Qn = ["open", "o"], $n = ["high", "h"], er = ["low", "l"], tr = ["close", "c"], nr = [
3513
3678
  "volume",
3514
3679
  "vol",
3515
3680
  "v"
3516
3681
  ];
3517
- function Gn(e) {
3682
+ function rr(e) {
3518
3683
  let t = e.trim();
3519
- return t ? t[0] === "[" || t[0] === "{" ? Kn(t) : qn(t) : {
3684
+ return t ? t[0] === "[" || t[0] === "{" ? ir(t) : ar(t) : {
3520
3685
  data: [],
3521
3686
  rowCount: 0,
3522
3687
  skipped: 0
3523
3688
  };
3524
3689
  }
3525
- function Kn(e) {
3690
+ function ir(e) {
3526
3691
  let t;
3527
3692
  try {
3528
3693
  t = JSON.parse(e);
@@ -3532,19 +3697,19 @@ function Kn(e) {
3532
3697
  if (!Array.isArray(t)) throw Error("Expected a JSON array of OHLCV rows");
3533
3698
  let n = [], r = 0;
3534
3699
  for (let e of t) {
3535
- let t = Array.isArray(e) ? Qn(e) : Zn(e);
3700
+ let t = Array.isArray(e) ? lr(e) : cr(e);
3536
3701
  t ? n.push(t) : r++;
3537
3702
  }
3538
- return Y(n, t.length, r);
3703
+ return ur(n, t.length, r);
3539
3704
  }
3540
- function qn(e) {
3705
+ function ar(e) {
3541
3706
  let t = e.split(/\r?\n/).filter((e) => e.trim().length > 0);
3542
3707
  if (t.length === 0) return {
3543
3708
  data: [],
3544
3709
  rowCount: 0,
3545
3710
  skipped: 0
3546
3711
  };
3547
- let n = Jn(t[0]), r = Yn(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? Xn(r) : {
3712
+ let n = or(t[0]), r = q(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? sr(r) : {
3548
3713
  time: 0,
3549
3714
  open: 1,
3550
3715
  high: 2,
@@ -3555,7 +3720,7 @@ function qn(e) {
3555
3720
  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");
3556
3721
  let o = [], s = 0;
3557
3722
  for (let e = +!!i; e < t.length; e++) {
3558
- let r = Yn(t[e], n), i = J(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;
3723
+ let r = q(t[e], n), i = Y(r[a.time]), c = J(r[a.open]), l = J(r[a.high]), u = J(r[a.low]), d = J(r[a.close]), f = a.volume >= 0 ? Number(r[a.volume]) : 0;
3559
3724
  if (i === null || ![
3560
3725
  c,
3561
3726
  l,
@@ -3574,9 +3739,9 @@ function qn(e) {
3574
3739
  volume: Number.isFinite(f) ? f : 0
3575
3740
  });
3576
3741
  }
3577
- return Y(o, t.length - +!!i, s);
3742
+ return ur(o, t.length - +!!i, s);
3578
3743
  }
3579
- function Jn(e) {
3744
+ function or(e) {
3580
3745
  let t = {
3581
3746
  ",": 0,
3582
3747
  ";": 0,
@@ -3588,7 +3753,7 @@ function Jn(e) {
3588
3753
  for (let [e, i] of Object.entries(t)) i > r && (n = e, r = i);
3589
3754
  return n;
3590
3755
  }
3591
- function Yn(e, t) {
3756
+ function q(e, t) {
3592
3757
  let n = [], r = "", i = !1;
3593
3758
  for (let a = 0; a < e.length; a++) {
3594
3759
  let o = e[a];
@@ -3596,25 +3761,25 @@ function Yn(e, t) {
3596
3761
  }
3597
3762
  return n.push(r), n;
3598
3763
  }
3599
- function Xn(e) {
3764
+ function sr(e) {
3600
3765
  let t = (t) => e.findIndex((e) => t.includes(e));
3601
3766
  return {
3602
- time: t(zn),
3603
- open: t(Bn),
3604
- high: t(Vn),
3605
- low: t(Hn),
3606
- close: t(Un),
3607
- volume: t(Wn)
3767
+ time: t(Zn),
3768
+ open: t(Qn),
3769
+ high: t($n),
3770
+ low: t(er),
3771
+ close: t(tr),
3772
+ volume: t(nr)
3608
3773
  };
3609
3774
  }
3610
- function Zn(e) {
3775
+ function cr(e) {
3611
3776
  let t = (t) => {
3612
3777
  for (let n of t) {
3613
3778
  if (e[n] !== void 0) return e[n];
3614
3779
  let t = n.toUpperCase();
3615
3780
  if (e[t] !== void 0) return e[t];
3616
3781
  }
3617
- }, n = J(String(t(zn) ?? "")), r = Number(t(Bn)), i = Number(t(Vn)), a = Number(t(Hn)), o = Number(t(Un)), s = Number(t(Wn) ?? 0);
3782
+ }, n = Y(String(t(Zn) ?? "")), r = Number(t(Qn)), i = Number(t($n)), a = Number(t(er)), o = Number(t(tr)), s = Number(t(nr) ?? 0);
3618
3783
  return n === null || ![
3619
3784
  r,
3620
3785
  i,
@@ -3629,9 +3794,9 @@ function Zn(e) {
3629
3794
  volume: Number.isFinite(s) ? s : 0
3630
3795
  };
3631
3796
  }
3632
- function Qn(e) {
3797
+ function lr(e) {
3633
3798
  if (e.length < 5) return null;
3634
- let t = J(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;
3799
+ let t = Y(String(e[0])), n = Number(e[1]), r = Number(e[2]), i = Number(e[3]), a = Number(e[4]), o = e.length >= 6 ? Number(e[5]) : 0;
3635
3800
  return t === null || ![
3636
3801
  n,
3637
3802
  r,
@@ -3646,10 +3811,10 @@ function Qn(e) {
3646
3811
  volume: Number.isFinite(o) ? o : 0
3647
3812
  };
3648
3813
  }
3649
- function q(e) {
3814
+ function J(e) {
3650
3815
  return e === void 0 || e.trim() === "" ? NaN : Number(e);
3651
3816
  }
3652
- function J(e) {
3817
+ function Y(e) {
3653
3818
  let t = e.trim();
3654
3819
  if (!t) return null;
3655
3820
  let n = Number(t);
@@ -3657,7 +3822,7 @@ function J(e) {
3657
3822
  let r = Date.parse(t);
3658
3823
  return Number.isFinite(r) ? r : null;
3659
3824
  }
3660
- function Y(e, t, n) {
3825
+ function ur(e, t, n) {
3661
3826
  e.sort((e, t) => e.time - t.time);
3662
3827
  let r = [];
3663
3828
  for (let t of e) r.length > 0 && r[r.length - 1].time === t.time ? r[r.length - 1] = t : r.push(t);
@@ -3669,7 +3834,7 @@ function Y(e, t, n) {
3669
3834
  }
3670
3835
  //#endregion
3671
3836
  //#region src/io/DragDropImporter.ts
3672
- var $n = class {
3837
+ var dr = class {
3673
3838
  host;
3674
3839
  overlay = null;
3675
3840
  callbacks;
@@ -3702,7 +3867,7 @@ var $n = class {
3702
3867
  e.preventDefault(), this.depth = 0, this.hideOverlay();
3703
3868
  let t = e.dataTransfer?.files?.[0];
3704
3869
  if (t) try {
3705
- let e = Gn(await t.text());
3870
+ let e = rr(await t.text());
3706
3871
  if (e.data.length === 0) throw Error(`No valid OHLCV rows found in "${t.name}"`);
3707
3872
  this.callbacks.onData(e.data, e, t);
3708
3873
  } catch (e) {
@@ -3746,7 +3911,7 @@ function Z(e) {
3746
3911
  };
3747
3912
  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;
3748
3913
  }
3749
- var er = (e, t) => t.updatedAt - e.updatedAt;
3914
+ var fr = (e, t) => t.updatedAt - e.updatedAt;
3750
3915
  function Q(e) {
3751
3916
  if (typeof e != "object" || !e) return null;
3752
3917
  let t = e;
@@ -3759,17 +3924,17 @@ function Q(e) {
3759
3924
  kind: typeof t.kind == "string" ? t.kind : void 0
3760
3925
  });
3761
3926
  }
3762
- function tr(e) {
3927
+ function pr(e) {
3763
3928
  let t = Q(e), n = t ? e.content : void 0;
3764
3929
  return t && typeof n == "string" ? {
3765
3930
  ...t,
3766
3931
  content: n
3767
3932
  } : null;
3768
3933
  }
3769
- function nr(e = []) {
3934
+ function mr(e = []) {
3770
3935
  let t = new Map(e.map((e) => [e.id, { ...e }]));
3771
3936
  return {
3772
- list: () => [...t.values()].map(Z).sort(er),
3937
+ list: () => [...t.values()].map(Z).sort(fr),
3773
3938
  load: (e) => {
3774
3939
  let n = t.get(e);
3775
3940
  return n ? { ...n } : null;
@@ -3782,7 +3947,7 @@ function nr(e = []) {
3782
3947
  }
3783
3948
  };
3784
3949
  }
3785
- function rr(e = "tcw:layouts:") {
3950
+ function hr(e = "tcw:layouts:") {
3786
3951
  let t = `${e}index`, n = (t) => `${e}item:${t}`, r = () => {
3787
3952
  let e;
3788
3953
  try {
@@ -3793,7 +3958,7 @@ function rr(e = "tcw:layouts:") {
3793
3958
  return Array.isArray(e) ? e.map(Q).filter((e) => e !== null) : [];
3794
3959
  }, i = (e) => localStorage.setItem(t, JSON.stringify(e));
3795
3960
  return {
3796
- list: () => r().sort(er),
3961
+ list: () => r().sort(fr),
3797
3962
  load: (e) => {
3798
3963
  let t = r().find((t) => t.id === e), i = t ? localStorage.getItem(n(e)) : null;
3799
3964
  return t && i !== null ? {
@@ -3811,14 +3976,14 @@ function rr(e = "tcw:layouts:") {
3811
3976
  }
3812
3977
  //#endregion
3813
3978
  //#region src/state/LayoutSession.ts
3814
- var ir = 80;
3979
+ var gr = 80;
3815
3980
  function $(e) {
3816
3981
  return e.replace(/\s+/g, " ").trim().slice(0, 80).trim() || null;
3817
3982
  }
3818
- function ar() {
3983
+ function _r() {
3819
3984
  return globalThis.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
3820
3985
  }
3821
- function or(e) {
3986
+ function vr(e) {
3822
3987
  let { id: t, name: n, symbol: r, timeframe: i, updatedAt: a, kind: o } = e;
3823
3988
  return {
3824
3989
  id: t,
@@ -3829,7 +3994,7 @@ function or(e) {
3829
3994
  ...o === void 0 ? {} : { kind: o }
3830
3995
  };
3831
3996
  }
3832
- var sr = class {
3997
+ var yr = class {
3833
3998
  currentLayout = null;
3834
3999
  savedContent = null;
3835
4000
  dirty = !1;
@@ -3845,7 +4010,7 @@ var sr = class {
3845
4010
  now;
3846
4011
  newId;
3847
4012
  constructor(e, t, n = {}) {
3848
- 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 ?? ar;
4013
+ 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 ?? _r;
3849
4014
  }
3850
4015
  current() {
3851
4016
  return this.currentLayout;
@@ -3875,7 +4040,7 @@ var sr = class {
3875
4040
  }
3876
4041
  open(e) {
3877
4042
  return this.queue(async () => {
3878
- let t = tr(await this.storage.load(e));
4043
+ let t = pr(await this.storage.load(e));
3879
4044
  if (!t || t.id !== e || (t.kind ?? "chart") !== this.kind || this.destroyed) return !1;
3880
4045
  this.cancelTimer(), this.applying++;
3881
4046
  try {
@@ -3885,13 +4050,13 @@ var sr = class {
3885
4050
  } finally {
3886
4051
  this.applying--;
3887
4052
  }
3888
- return this.cancelTimer(), this.currentLayout = or(t), this.savedContent = this.host.capture().content, this.dirty = !1, this.notify(), !0;
4053
+ return this.cancelTimer(), this.currentLayout = vr(t), this.savedContent = this.host.capture().content, this.dirty = !1, this.notify(), !0;
3889
4054
  });
3890
4055
  }
3891
4056
  rename(e, t) {
3892
4057
  let n = $(t);
3893
4058
  return n ? this.queue(async () => {
3894
- let t = tr(await this.storage.load(e));
4059
+ let t = pr(await this.storage.load(e));
3895
4060
  !t || t.id !== e || (await this.storage.save({
3896
4061
  ...t,
3897
4062
  name: n
@@ -3969,7 +4134,7 @@ var sr = class {
3969
4134
  content: n.content
3970
4135
  };
3971
4136
  await this.storage.save(r);
3972
- let i = or(r);
4137
+ let i = vr(r);
3973
4138
  return this.currentLayout = i, this.savedContent = n.content, this.dirty = !1, this.notify(), i;
3974
4139
  }
3975
4140
  forget() {
@@ -3990,6 +4155,6 @@ var sr = class {
3990
4155
  }
3991
4156
  };
3992
4157
  //#endregion
3993
- export { Ht as C, j as S, H as _, nr as a, $t as b, wn as c, un as d, ln as f, V as g, on as h, rr as i, _n as l, cn as m, ir as n, $n as o, sn as p, $ as r, Gn as s, sr as t, dn as u, L as v, M as x, N as y };
4158
+ export { Ht as C, B as S, H as _, mr as a, tn as b, In as c, Sn as d, xn as f, vn as g, _n as h, hr as i, kn as l, bn as m, gr as n, dr as o, yn as p, $ as r, rr as s, yr as t, Cn as u, ln as v, $t as x, rn as y };
3994
4159
 
3995
- //# sourceMappingURL=LayoutSession-BF1iuUrs.js.map
4160
+ //# sourceMappingURL=LayoutSession-CiDh-H9-.js.map