@tradecanvas/chart 1.7.0 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
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, zonedDateFormatter as re } from "@tradecanvas/commons";
2
- import { AlertDragHandler as ie, AlertManager as ae, Animator as oe, AreaRenderer as se, AxisDragHandler as ce, BarCountdown as le, BarRenderer as ue, BaselineRenderer as de, CandlestickRenderer as fe, ChartLegend as pe, ChartStateManager as b, CompareRenderer as me, CompareSymbolIndicator as he, CrosshairHandler as ge, CrosshairTooltip as _e, CurrentPriceLine as ve, DEFAULT_SESSION_HOURS as ye, DataExporter as x, DepthHeatmapRenderer as be, DrawingManager as xe, DrawingRenderer as Se, EquivolumeRenderer as Ce, EventBus as we, GridRenderer as Te, HLCAreaRenderer as Ee, HiLoRenderer as S, HollowCandleRenderer as De, IndicatorEngine as C, InteractionManager as Oe, KagiRenderer as ke, KeyboardHandler as Ae, LineRenderer as je, LineWithMarkersRenderer as Me, MarketProfileRenderer as Ne, MeasureOverlay as Pe, PanHandler as Fe, PaneResizeHandler as Ie, PeriodLevelsRenderer as Le, PinnedTooltip as Re, PivotMarkersRenderer as ze, PointAndFigureRenderer as Be, PriceAxis as w, PriceAxisAddButton as Ve, PriceLines as He, RenderEngine as Ue, RenkoRenderer as We, ReplayManager as Ge, Screenshot as T, SelectionBoxOverlay as Ke, SessionBreaks as qe, SessionShading as Je, SignalMarkerManager as Ye, SpreadIndicator as Xe, StepLineRenderer as Ze, StreamManager as Qe, SymbolSeriesStore as $e, TimeAxis as et, TradeZoneManager as tt, TradingManager as nt, TradingRenderer as rt, UndoRedoManager as it, Viewport as at, VolumeCandleRenderer as ot, VolumeProfileRenderer as st, VolumeRenderer as ct, Watermark as lt, ZoomHandler as ut, barTimeStepMs as dt, findDominantSwing as ft, isRegularSession as pt, mergeSessionHours as mt, rangePresetStart as ht, readAlertOptions as gt, registerBuiltInDrawingTools as _t, registerBuiltInIndicators as E, servesTimeframe as D, sourceParam as O, timestampToBarIndex as k, toHeikinAshi as vt, toKagi as yt, toLineBreak as bt, toPointAndFigure as xt, toRangeBars as St, toRenko as A, withResampling as Ct, xToBarIndex as wt, xToTime as j, yToPrice as M } 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, 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";
3
3
  //#region src/regularHours.ts
4
- var Tt = 864e5, Et = 10;
5
- function Dt(e, t) {
4
+ var Mt = 864e5, Nt = 10;
5
+ function Pt(e, t) {
6
6
  let n = e?.timezone;
7
7
  if (!n || !f(n) || t.length < 2) return null;
8
8
  let r = (e?.sessions ?? []).flatMap((e) => {
@@ -14,34 +14,34 @@ function Dt(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 - Et); e < t.length; e++) {
17
+ for (let e = Math.max(1, t.length - Nt); e < t.length; e++) {
18
18
  let n = m(t[e].time) - m(t[e - 1].time);
19
19
  n > 0 && n < i && (i = n);
20
20
  }
21
- if (!(i < Tt)) return null;
21
+ if (!(i < Mt)) 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) => pt(m(e), a);
28
+ return (e) => _t(m(e), a);
29
29
  }
30
30
  //#endregion
31
31
  //#region src/chartA11y.ts
32
- var N = {
32
+ var Ft = {
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
- }, P = (e, t) => e.replace(/\{(\w+)\}/g, (e, n) => n in t ? String(t[n]) : e), Ot = [
39
+ }, O = (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",
43
43
  "aria-describedby"
44
- ], kt = 400, At = 1e3, jt = class {
44
+ ], Lt = 400, Rt = 1e3, zt = class {
45
45
  live;
46
46
  help;
47
47
  labels;
@@ -55,20 +55,20 @@ var N = {
55
55
  };
56
56
  constructor(e, t, n = {}) {
57
57
  this.container = e, this.source = t, this.labels = {
58
- ...N,
58
+ ...Ft,
59
59
  ...n
60
60
  };
61
- for (let t of Ot) this.before.set(t, e.getAttribute(t));
62
- e.setAttribute("role", "application"), this.help = F("div", "tc-sr-only"), this.help.id = `tc-chart-keys-${Math.random().toString(36).slice(2, 10)}`, e.setAttribute("aria-describedby", this.help.id), this.live = F("div", "tc-sr-only tc-sr-live"), this.live.setAttribute("aria-live", "polite"), this.live.setAttribute("aria-atomic", "true"), e.append(this.help, this.live), e.addEventListener("blur", this.onBlur), this.applyLabels();
61
+ for (let t of It) this.before.set(t, e.getAttribute(t));
62
+ e.setAttribute("role", "application"), this.help = Bt("div", "tc-sr-only"), this.help.id = `tc-chart-keys-${Math.random().toString(36).slice(2, 10)}`, e.setAttribute("aria-describedby", this.help.id), this.live = Bt("div", "tc-sr-only tc-sr-live"), this.live.setAttribute("aria-live", "polite"), this.live.setAttribute("aria-atomic", "true"), e.append(this.help, this.live), e.addEventListener("blur", this.onBlur), this.applyLabels();
63
63
  }
64
64
  setLabels(e) {
65
65
  this.labels = {
66
- ...N,
66
+ ...Ft,
67
67
  ...e
68
68
  }, this.applyLabels();
69
69
  }
70
70
  refresh(e = !1) {
71
- let t = At - (Date.now() - this.summaryAt);
71
+ let t = Rt - (Date.now() - this.summaryAt);
72
72
  if (e || t <= 0 || this.container.getAttribute("aria-label") === this.labels.empty) {
73
73
  this.summaryTimer && clearTimeout(this.summaryTimer), this.summaryTimer = null, this.summaryAt = Date.now(), this.container.setAttribute("aria-label", this.summary());
74
74
  return;
@@ -80,7 +80,7 @@ var N = {
80
80
  viewMoved() {
81
81
  this.cursor = null, this.viewTimer && clearTimeout(this.viewTimer), this.viewTimer = setTimeout(() => {
82
82
  this.viewTimer = null, this.say(this.viewText());
83
- }, kt);
83
+ }, Lt);
84
84
  }
85
85
  readBar(e) {
86
86
  let t = this.source.bars();
@@ -93,13 +93,13 @@ var N = {
93
93
  let i = t[this.cursor];
94
94
  this.source.showBar(i.time);
95
95
  let a = this.source.formatPrice;
96
- this.say(P(this.labels.bar, {
96
+ this.say(O(this.labels.bar, {
97
97
  time: this.source.formatTime(i.time),
98
98
  open: a(i.open),
99
99
  high: a(i.high),
100
100
  low: a(i.low),
101
101
  close: a(i.close),
102
- volume: Mt(i.volume ?? 0)
102
+ volume: Vt(i.volume ?? 0)
103
103
  }));
104
104
  }
105
105
  destroy() {
@@ -118,7 +118,7 @@ var N = {
118
118
  this.labels.typeName ? this.labels.typeName(t) : t,
119
119
  this.source.timeframe()
120
120
  ].filter(Boolean).join(", ");
121
- return P(this.labels.summary, {
121
+ return O(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 N = {
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 P(this.labels.view, {
131
+ return O(this.labels.view, {
132
132
  count: r - n + 1,
133
133
  from: this.source.formatTime(e[n].time),
134
134
  to: this.source.formatTime(e[r].time),
@@ -140,7 +140,7 @@ var N = {
140
140
  this.live.textContent = e;
141
141
  }
142
142
  };
143
- function F(e, t) {
143
+ function Bt(e, t) {
144
144
  let n = document.createElement(e);
145
145
  return n.className = t, Object.assign(n.style, {
146
146
  position: "absolute",
@@ -154,12 +154,12 @@ function F(e, t) {
154
154
  border: "0"
155
155
  }), n;
156
156
  }
157
- function Mt(e) {
157
+ function Vt(e) {
158
158
  return Number.isInteger(e) ? String(e) : e.toFixed(2);
159
159
  }
160
160
  //#endregion
161
161
  //#region src/indicatorLabel.ts
162
- function I(e, t, n, r) {
162
+ function Ht(e, t, n, r) {
163
163
  let i = Object.keys(n || t).map((e) => t[e]).filter((e) => typeof e == "number" && Number.isFinite(e)).slice(0, 3).map((e) => String(Number(e.toFixed(4)))), a = typeof t.symbol == "string" && t.symbol ? [t.symbol] : [];
164
164
  return [
165
165
  e === "spread" && t.mode === "ratio" ? "Ratio" : r ?? e.toUpperCase(),
@@ -169,55 +169,55 @@ function I(e, t, n, r) {
169
169
  }
170
170
  //#endregion
171
171
  //#region src/charts/ChartTypeStrategy.ts
172
- function Nt(e) {
172
+ function Ut(e) {
173
173
  switch (e) {
174
174
  case "candlestick":
175
175
  case "heikinAshi":
176
176
  case "lineBreak":
177
- case "rangeBars": return new fe();
178
- case "line": return new je();
179
- case "area": return new se();
180
- case "bar": return new ue();
181
- case "hollowCandle": return new De();
182
- case "baseline": return new de();
183
- case "renko": return new We();
184
- case "kagi": return new ke();
185
- case "pointAndFigure": return new Be();
186
- case "volumeCandles": return new ot();
187
- case "equivolume": return new Ce();
188
- case "hlcArea": return new Ee();
189
- case "stepLine": return new Ze();
190
- case "lineWithMarkers": return new Me();
191
- case "hiLo": return new S();
192
- default: return new fe();
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();
193
193
  }
194
194
  }
195
- function Pt(e, t, n = {}) {
195
+ function Wt(e, t, n = {}) {
196
196
  if (t.length === 0) return t;
197
197
  switch (e) {
198
- case "heikinAshi": return vt(t);
198
+ case "heikinAshi": return Ct(t);
199
199
  case "renko": {
200
200
  let e = n.renko?.boxSize;
201
- return typeof e == "number" ? A(t, { brickSize: e }) : A(t, {
201
+ return typeof e == "number" ? Ot(t, { brickSize: e }) : Ot(t, {
202
202
  brickSize: 0,
203
203
  useATR: !0,
204
204
  atrPeriod: n.renko?.atrPeriod ?? 14
205
205
  });
206
206
  }
207
- case "lineBreak": return bt(t, n.lineBreak?.lines ?? 3);
208
- case "kagi": return yt(t, n.kagi?.reversal ?? 4, n.kagi?.reversalType ?? "percent");
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
209
  case "pointAndFigure": {
210
210
  let e = n.pointAndFigure?.boxSize;
211
- return xt(t, typeof e == "number" ? e : It(t) * .01, n.pointAndFigure?.reversal ?? 3);
211
+ return Et(t, typeof e == "number" ? e : qt(t) * .01, n.pointAndFigure?.reversal ?? 3);
212
212
  }
213
213
  case "rangeBars": {
214
214
  let e = n.rangeBars?.range;
215
- return St(t, { rangeSize: typeof e == "number" ? e : It(t) * .005 });
215
+ return Dt(t, { rangeSize: typeof e == "number" ? e : qt(t) * .005 });
216
216
  }
217
217
  default: return t;
218
218
  }
219
219
  }
220
- function Ft(e) {
220
+ function Gt(e) {
221
221
  switch (e) {
222
222
  case "heikinAshi":
223
223
  case "renko":
@@ -228,26 +228,26 @@ function Ft(e) {
228
228
  default: return !1;
229
229
  }
230
230
  }
231
- function L(e) {
232
- return e !== "heikinAshi" && Ft(e);
231
+ function Kt(e) {
232
+ return e !== "heikinAshi" && Gt(e);
233
233
  }
234
- function It(e) {
234
+ function qt(e) {
235
235
  let t = 0;
236
236
  for (let n of e) t += n.close;
237
237
  return t / e.length;
238
238
  }
239
- function Lt(e, t) {
239
+ function Jt(e, t) {
240
240
  let n = t?.(e);
241
- return n ? n.createRenderer() : Nt(e);
241
+ return n ? n.createRenderer() : Ut(e);
242
242
  }
243
- function Rt(e, t, n, r) {
243
+ function Yt(e, t, n, r) {
244
244
  if (t.length === 0) return t;
245
245
  let i = n?.(e);
246
- return i?.transform ? i.transform(t) : Pt(e, t, r);
246
+ return i?.transform ? i.transform(t) : Wt(e, t, r);
247
247
  }
248
248
  //#endregion
249
249
  //#region src/state/AutoSaveScheduler.ts
250
- var zt = class {
250
+ var Xt = class {
251
251
  timer = null;
252
252
  delayMs = 0;
253
253
  key = null;
@@ -277,15 +277,15 @@ var zt = class {
277
277
  };
278
278
  //#endregion
279
279
  //#region src/DataManager.ts
280
- function R(e) {
280
+ function k(e) {
281
281
  if (!e || typeof e.time != "number" || !Number.isFinite(e.time)) return !1;
282
282
  let { open: t, high: n, low: r, close: i } = e;
283
283
  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
284
  }
285
- function Bt(e) {
285
+ function Zt(e) {
286
286
  return e.volume !== void 0 && e.high >= e.open && e.high >= e.close && e.low <= e.open && e.low <= e.close;
287
287
  }
288
- function z(e) {
288
+ function A(e) {
289
289
  return {
290
290
  ...e,
291
291
  high: Math.max(e.open, e.high, e.low, e.close),
@@ -293,7 +293,7 @@ function z(e) {
293
293
  volume: e.volume === void 0 ? 0 : Math.max(0, e.volume)
294
294
  };
295
295
  }
296
- var B = class {
296
+ var j = class {
297
297
  data = [];
298
298
  getData() {
299
299
  return this.data;
@@ -302,7 +302,7 @@ var B = class {
302
302
  let t = [];
303
303
  for (let n = 0; n < e.length; n++) {
304
304
  let r = e[n];
305
- R(r) && t.push(Bt(r) ? r : z(r));
305
+ k(r) && t.push(Zt(r) ? r : A(r));
306
306
  }
307
307
  this.data = t;
308
308
  }
@@ -310,7 +310,7 @@ var B = class {
310
310
  let t = this.data.length > 0 ? this.data[0].time : Infinity, n = [];
311
311
  for (let r = 0; r < e.length; r++) {
312
312
  let i = e[r];
313
- !R(i) || i.time >= t || n.push(Bt(i) ? i : z(i));
313
+ !k(i) || i.time >= t || n.push(Zt(i) ? i : A(i));
314
314
  }
315
315
  if (n.length === 0) return 0;
316
316
  n.sort((e, t) => e.time - t.time);
@@ -319,11 +319,11 @@ var B = class {
319
319
  return n.length = r, this.data = n.concat(this.data), r;
320
320
  }
321
321
  appendBar(e) {
322
- R(e) && this.data.push(z(e));
322
+ k(e) && this.data.push(A(e));
323
323
  }
324
324
  updateLastBar(e) {
325
- if (!R(e)) return;
326
- let t = z(e);
325
+ if (!k(e)) return;
326
+ let t = A(e);
327
327
  if (this.data.length === 0) {
328
328
  this.data.push(t);
329
329
  return;
@@ -339,7 +339,7 @@ var B = class {
339
339
  clear() {
340
340
  this.data = [];
341
341
  }
342
- }, Vt = 5e3, Ht = 6e4, Ut = 500, Wt = class {
342
+ }, M = 5e3, Qt = 6e4, $t = 500, en = class {
343
343
  loader = null;
344
344
  pageSize = 500;
345
345
  loading = !1;
@@ -380,7 +380,7 @@ var B = class {
380
380
  try {
381
381
  r = await e(t, this.pageSize);
382
382
  } catch (e) {
383
- return n === this.seq ? (this.loading = !1, this.failures++, this.retryAt = this.now() + Math.min(Ht, Vt * 2 ** (this.failures - 1)), this.emit({
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
384
  state: "error",
385
385
  count: 0,
386
386
  error: e instanceof Error ? e.message : String(e)
@@ -410,7 +410,7 @@ var B = class {
410
410
  now() {
411
411
  return this.host.now ? this.host.now() : Date.now();
412
412
  }
413
- }, Gt = class {
413
+ }, N = class {
414
414
  theme;
415
415
  shape = null;
416
416
  constructor(t) {
@@ -437,7 +437,7 @@ var B = class {
437
437
  } : this.theme.shape
438
438
  };
439
439
  }
440
- }, Kt = 200, qt = 80, V = (e) => e.position === "top" || e.position === "bottom", Jt = class {
440
+ }, P = 200, F = 80, I = (e) => e.position === "top" || e.position === "bottom", L = class {
441
441
  panels = [];
442
442
  containerWidth = 0;
443
443
  containerHeight = 0;
@@ -453,8 +453,8 @@ var B = class {
453
453
  this.panels.push({
454
454
  id: e,
455
455
  position: n,
456
- size: r ?? (a ? Kt : t),
457
- minSize: a ? qt : i,
456
+ size: r ?? (a ? P : t),
457
+ minSize: a ? F : i,
458
458
  content: {
459
459
  type: "indicator",
460
460
  indicatorInstanceId: e
@@ -473,14 +473,14 @@ var B = class {
473
473
  }
474
474
  setPanelCollapsed(e, t) {
475
475
  let n = this.panels.find((t) => t.id === e);
476
- return !n || !V(n) || this.maximized === null && !!n.collapsed === t ? !1 : (this.maximized = null, n.collapsed = t || void 0, !0);
476
+ return !n || !I(n) || this.maximized === null && !!n.collapsed === t ? !1 : (this.maximized = null, n.collapsed = t || void 0, !0);
477
477
  }
478
478
  isPanelCollapsed(e) {
479
479
  return !!this.panels.find((t) => t.id === e)?.collapsed;
480
480
  }
481
481
  isPanelShownCollapsed(e) {
482
482
  let t = this.panels.find((t) => t.id === e);
483
- return !t || !V(t) ? !1 : this.maximized === null ? !!t.collapsed : this.maximized !== e;
483
+ return !t || !I(t) ? !1 : this.maximized === null ? !!t.collapsed : this.maximized !== e;
484
484
  }
485
485
  setPanelScale(e, t) {
486
486
  let n = this.panels.find((t) => t.id === e);
@@ -496,7 +496,7 @@ var B = class {
496
496
  }
497
497
  setMaximizedPanel(e) {
498
498
  let t = e === null ? null : this.panels.find((t) => t.id === e);
499
- return e !== null && (!t || !V(t)) || this.maximized === e ? !1 : (this.maximized = e, t && (t.collapsed = void 0), !0);
499
+ return e !== null && (!t || !I(t)) || this.maximized === e ? !1 : (this.maximized = e, t && (t.collapsed = void 0), !0);
500
500
  }
501
501
  getMaximizedPanel() {
502
502
  return this.maximized;
@@ -517,19 +517,19 @@ var B = class {
517
517
  this.panels = [...this.panels].sort((e, n) => t(e) - t(n));
518
518
  }
519
519
  shownSize(e, t) {
520
- return V(e) ? this.maximized ? e.id === this.maximized ? t : 20 : e.collapsed ? 20 : e.size : e.size;
520
+ return I(e) ? this.maximized ? e.id === this.maximized ? t : 20 : e.collapsed ? 20 : e.size : e.size;
521
521
  }
522
522
  setPanelPosition(e, n) {
523
523
  let r = this.panels.find((t) => t.id === e);
524
524
  if (r) {
525
525
  let a = r.position === "left" || r.position === "right", o = n === "left" || n === "right";
526
- r.position = n, a !== o && (r.size = o ? Kt : t, r.minSize = o ? qt : i), o && (r.collapsed = void 0, this.maximized === e && (this.maximized = null));
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));
527
527
  }
528
528
  }
529
529
  setPanelSize(e, t) {
530
530
  let n = this.panels.find((t) => t.id === e);
531
531
  if (n) {
532
- let e = V(n) ? this.containerHeight - o - 48 : this.containerWidth / 2, r = e > n.minSize ? Math.min(t, e) : t;
532
+ let e = I(n) ? this.containerHeight - o - 48 : this.containerWidth / 2, r = e > n.minSize ? Math.min(t, e) : t;
533
533
  n.size = Math.max(n.minSize, r), n.collapsed = void 0, this.maximized = null;
534
534
  }
535
535
  }
@@ -639,8 +639,8 @@ var B = class {
639
639
  getMainChartRect() {
640
640
  return this.resolve().mainChartRect;
641
641
  }
642
- }, Yt = 14, Xt = 14, Zt = 22, Qt = 4;
643
- function $t(e) {
642
+ }, tn = 14, nn = 14, rn = 22, R = 4;
643
+ function z(e) {
644
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] : [
645
645
  t,
646
646
  n,
@@ -649,14 +649,14 @@ function $t(e) {
649
649
  for (let t of p) {
650
650
  if (!Number.isFinite(t)) continue;
651
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}`) + Yt, u(r, `bold 11px ${o}`) + Xt, u(r, `600 ${c}px ${o}`) + Zt);
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);
653
653
  }
654
- return m <= a ? a : Math.ceil(m / Qt) * Qt;
654
+ return m <= a ? a : Math.ceil(m / R) * R;
655
655
  }
656
- function en(e, t) {
656
+ function B(e, t) {
657
657
  return t > e || t <= e - 12 ? t : e;
658
658
  }
659
- var tn = class {
659
+ var an = class {
660
660
  netY = 0;
661
661
  travelX = 0;
662
662
  engaged = !1;
@@ -672,8 +672,8 @@ var tn = class {
672
672
  }
673
673
  return this.engaged;
674
674
  }
675
- }, nn = 1;
676
- function rn(e, t) {
675
+ }, on = 1;
676
+ function V(e, t) {
677
677
  return e.filter((e) => (e.descriptor.layer ?? "overlay") === t);
678
678
  }
679
679
  function H(e) {
@@ -687,24 +687,24 @@ function H(e) {
687
687
  //#endregion
688
688
  //#region src/plugins/registry.ts
689
689
  var U = /* @__PURE__ */ new Map();
690
- function an(e) {
690
+ function sn(e) {
691
691
  U.set(H(e), e);
692
692
  }
693
- function on(e) {
693
+ function cn(e) {
694
694
  return U.delete(e);
695
695
  }
696
- function sn() {
696
+ function ln() {
697
697
  return [...U.values()];
698
698
  }
699
- function cn() {
699
+ function un() {
700
700
  U.clear();
701
701
  }
702
702
  //#endregion
703
703
  //#region src/plugins/PluginManager.ts
704
- var ln = class {
704
+ var dn = class {
705
705
  plugins = /* @__PURE__ */ new Map();
706
706
  constructor(e, t = {}) {
707
- if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of sn()) this.add(e);
707
+ if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of ln()) this.add(e);
708
708
  for (let e of t.plugins ?? []) this.add(e);
709
709
  }
710
710
  register(e) {
@@ -734,15 +734,15 @@ var ln = class {
734
734
  add(e) {
735
735
  this.plugins.set(H(e), e), e.kind === "indicator" && this.indicatorEngine.register(e.plugin);
736
736
  }
737
- }, un = {
737
+ }, fn = {
738
738
  orderPlace: (e, t) => e.placeOrder(t),
739
739
  orderModify: (e, t) => e.modifyOrder(t),
740
740
  orderCancel: (e, t) => e.cancelOrder(t),
741
741
  positionModify: (e, t) => e.modifyPosition(t),
742
742
  positionClose: (e, t) => e.closePosition(t),
743
- positionReverse: (e, t, n) => dn(e, t, n)
743
+ positionReverse: (e, t, n) => pn(e, t, n)
744
744
  };
745
- async function dn(e, t, n) {
745
+ async function pn(e, t, n) {
746
746
  let { reversing: r } = n;
747
747
  if (!r.has(t.positionId)) {
748
748
  r.add(t.positionId);
@@ -771,7 +771,7 @@ async function dn(e, t, n) {
771
771
  }
772
772
  }
773
773
  }
774
- function fn(e, t) {
774
+ function mn(e, t) {
775
775
  let n = [], r = null, i = {
776
776
  positions: () => r ?? t.getPositions?.() ?? [],
777
777
  reversing: /* @__PURE__ */ new Set()
@@ -781,8 +781,8 @@ function fn(e, t) {
781
781
  e.data && t.onFill?.(e.data);
782
782
  };
783
783
  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(un)) {
785
- let a = un[r], o = t.onIntent(r, (n) => {
784
+ for (let r of Object.keys(fn)) {
785
+ let a = fn[r], o = t.onIntent(r, (n) => {
786
786
  Promise.resolve(a(e, n, i)).catch((e) => t.onError({
787
787
  message: `Execution command failed: ${r}`,
788
788
  cause: e
@@ -796,16 +796,16 @@ function fn(e, t) {
796
796
  }
797
797
  //#endregion
798
798
  //#region src/Chart.ts
799
- var pn = {
799
+ var hn = {
800
800
  min: 0,
801
801
  max: 100
802
- }, mn = 0xe8d4a51000, hn = "exchange";
803
- function gn(e) {
802
+ }, gn = 0xe8d4a51000, _n = "exchange";
803
+ function vn(e) {
804
804
  if (typeof e == "string" && e !== "exchange" && !f(e)) throw RangeError(`Unknown time zone: ${e}`);
805
805
  if (typeof e == "number" && !Number.isFinite(e)) throw RangeError(`Invalid UTC offset: ${e}`);
806
806
  }
807
- var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
808
- static version = "1.7.0";
807
+ var yn = 2, bn = .08, xn = 800, Sn = 20, Cn = 8, wn = class {
808
+ static version = "1.11.0";
809
809
  engine;
810
810
  viewport;
811
811
  dataManager;
@@ -841,14 +841,14 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
841
841
  indicatorHistoryDepth = 0;
842
842
  removedDrawingAlerts = /* @__PURE__ */ new Map();
843
843
  zoomAreaMode = !1;
844
- priceAxisAddButton = new Ve();
844
+ priceAxisAddButton = new Ge();
845
845
  displayTz = null;
846
846
  timezoneSetting = null;
847
847
  symbolInfo = null;
848
848
  symbolInfoSeq = 0;
849
849
  sessionBreaks;
850
850
  sessionShading;
851
- hostSessionHours = { ...ye };
851
+ hostSessionHours = { ...be };
852
852
  compareRenderer;
853
853
  countdownInterval = null;
854
854
  volumeRenderer;
@@ -861,7 +861,7 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
861
861
  signalMarkerManager;
862
862
  tradeZoneManager;
863
863
  measureOverlay;
864
- selectionBoxOverlay = new Ke();
864
+ selectionBoxOverlay = new Xe();
865
865
  replayManager;
866
866
  replayBarUnsub = null;
867
867
  replaySeeking = !1;
@@ -869,24 +869,26 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
869
869
  replayStepsSeries = null;
870
870
  replayCoarse = null;
871
871
  undoRedoManager;
872
- autoSaveScheduler = new zt((e) => this.saveState(e));
872
+ autoSaveScheduler = new Xt((e) => this.saveState(e));
873
873
  animator;
874
874
  crosshairTooltip;
875
875
  pinnedTooltip;
876
876
  interactionManager;
877
877
  crosshairHandler;
878
878
  chartRenderer;
879
+ rendererToken = 0;
880
+ disposed = !1;
879
881
  chartTypeOptions = {};
880
882
  mainSeriesVisible = !0;
881
- priceLines = new He();
882
- symbolSeries = new $e();
883
+ priceLines = new Ke();
884
+ symbolSeries = new rt();
883
885
  extendedHours = !0;
884
886
  replayRestarting = !1;
885
887
  fullSeries = null;
886
888
  requestedSymbols = /* @__PURE__ */ new Set();
887
889
  gridRenderer;
888
890
  priceAxis;
889
- leftPriceAxis = new w();
891
+ leftPriceAxis = new We();
890
892
  leftScaleRequested = !1;
891
893
  leftAxisWidth = a;
892
894
  leftViewport = null;
@@ -916,7 +918,7 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
916
918
  snapshotKey = null;
917
919
  historyCheckQueued = !1;
918
920
  constructor(e, t) {
919
- t.timeZone != null && gn(t.timeZone), this.container = e, this.options = {
921
+ t.timeZone != null && vn(t.timeZone), this.container = e, this.options = {
920
922
  ...t,
921
923
  chartType: t.chartType ?? "candlestick"
922
924
  }, this.numberLocale = t.numberLocale ?? "en-US", this.defaultAutoScale = t.autoScale !== !1;
@@ -954,15 +956,15 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
954
956
  logScale: n.logScale ?? !0,
955
957
  timeframes: n.timeframes ?? [],
956
958
  defaultTimeframeFavorites: n.defaultTimeframeFavorites ?? []
957
- }, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", this.dataManager = new B(), this.history = new Wt({
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({
958
960
  oldestTime: () => this.dataManager.getData()[0]?.time ?? null,
959
961
  prepend: (e) => this.prependBars(e),
960
962
  emit: (e) => this.eventBus.emit("historyLoad", e)
961
- }), this.themeManager = new Gt(t.theme), this.layoutManager = new Jt(), this.indicatorEngine = new C(), this.pluginManager = new ln(this.indicatorEngine, { plugins: t.plugins }), this.eventBus = new we(), E(this.indicatorEngine), this.indicatorEngine.register(new he(this.symbolSeries)), this.indicatorEngine.register(new Xe(this.symbolSeries)), this.drawingManager = new xe(), _t(this.drawingManager), this.drawingRenderer = new Se(this.drawingManager), this.drawingManager.setRequestRender(() => {
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(() => {
962
964
  this.syncRenderContext(), this.engine.requestRender(r.Overlay), this.scheduleAutoSave();
963
965
  }), this.drawingManager.setEventCallback((e, t) => {
964
966
  this.followDrawingAlerts(e, t?.id), this.eventBus.emit(e, t), (e === "drawingCreate" || e === "drawingUpdate" || e === "drawingRemove") && this.announceStateChange();
965
- }), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new it();
967
+ }), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new ct();
966
968
  let i = "";
967
969
  this.undoRedoManager.setOnChange(() => {
968
970
  let { canUndo: e, canRedo: t } = this.undoRedoManager.getState(), n = `${e}|${t}`;
@@ -975,21 +977,21 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
975
977
  primary: e[0] ?? null
976
978
  })), this.drawingManager.setForeignHistory((e, t) => {
977
979
  e.type === "custom" ? e.custom?.[t]() : this.applyIndicatorStep(e, t);
978
- }), 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 nt({
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({
979
981
  enabled: this.features.trading,
980
982
  contextMenu: { enabled: this.features.tradingContextMenu }
981
- }), this.tradingRenderer = new rt(this.tradingManager), this.tradingManager.setContainer(e), this.tradingManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradingManager.setEventCallback((e, t) => {
983
+ }), this.tradingRenderer = new st(this.tradingManager), this.tradingManager.setContainer(e), this.tradingManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradingManager.setEventCallback((e, t) => {
982
984
  this.eventBus.emit(e, t);
983
- }), this.engine = new Ue(e);
985
+ }), this.engine = new qe(e);
984
986
  let a = this.engine.dprManager.getContainerSize();
985
- if (this.viewport = new at(a.width, a.height, t.minBarSpacing ?? 2, t.maxBarSpacing ?? 30, t.rightMargin ?? 5), this.viewport.setPanLimits({
987
+ if (this.viewport = new lt(a.width, a.height, t.minBarSpacing ?? 2, t.maxBarSpacing ?? 30, t.rightMargin ?? 5), this.viewport.setPanLimits({
986
988
  freePan: t.freePan ?? !0,
987
989
  minVisibleBars: t.panLimits?.minVisibleBars ?? 3
988
990
  }), this.layoutManager.resize(a.width, a.height), this.engine.onContainerResize = (e) => {
989
991
  if (e.width <= 0 || e.height <= 0) return;
990
992
  let t = this.viewport.isAtEnd();
991
993
  this.viewport.resize(e.width, e.height), this.layoutManager.resize(e.width, e.height), this.updateViewportAndRender(t);
992
- }, this.chartRenderer = this.createChartRenderer(this.options.chartType), this.gridRenderer = new Te(), t.grid?.visible === !1 && this.gridRenderer.setVisible(!1), this.priceAxis = new w(), this.priceAxis.setLocale(this.numberLocale), this.leftPriceAxis.setLocale(this.numberLocale), this.timeAxis = new et(), this.crosshairHandler = new ge(), this.crosshairHandler.setLocale(this.numberLocale), t.crosshair?.mode && this.crosshairHandler.setMode(t.crosshair.mode), this.crosshairHandler.setCallback((e, 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) => {
993
995
  if (e !== null && t) {
994
996
  let n = this.dataManager.getData(), r = e < n.length ? n[e] : void 0;
995
997
  this.chartLegend.setHoverBar(r ?? null);
@@ -998,19 +1000,19 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
998
1000
  prevClose: e > 0 ? n[e - 1]?.close : void 0,
999
1001
  priceRange: i.priceRange,
1000
1002
  plot: i.chartRect,
1001
- barStepMs: dt(n)
1003
+ barStepMs: ht(n)
1002
1004
  }) : this.crosshairTooltip.hide(), this.pinnedTooltip.isPinned() && this.pinnedTooltip.reposition(this.viewport.getState(), r ?? null, e, this.themeManager.getTheme()), this.eventBus.emit("crosshairMove", {
1003
1005
  point: t,
1004
1006
  bar: r,
1005
1007
  barIndex: e
1006
1008
  });
1007
1009
  } else this.crosshairTooltip.hide(), this.chartLegend.setHoverBar(null), this.eventBus.emit("crosshairLeave", {});
1008
- }), this.chartLegend = new pe(), this.chartLegend.setChartType(this.options.chartType), this.chartLegend.setLocale(this.numberLocale), this.watermark = new lt(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new ct(), this.volumeProfile = new st(), this.marketProfile = new Ne(), this.depthHeatmap = new be(), this.periodLevels = new Le(), this.pivotMarkers = new ze(), this.barCountdown = new le(), this.barCountdown.setVisible(this.features.barCountdown), this.sessionBreaks = new qe(), this.sessionBreaks.setLocale(this.numberLocale), this.sessionShading = new Je(), this.compareRenderer = new me(), t.sessionBreaks ? this.sessionBreaks.setConfig({
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({
1009
1011
  visible: t.sessionBreaks.visible ?? !0,
1010
1012
  color: t.sessionBreaks.color,
1011
1013
  lineStyle: t.sessionBreaks.lineStyle,
1012
1014
  lineWidth: t.sessionBreaks.lineWidth
1013
- }) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new oe(), this.crosshairTooltip = new _e(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new Re(), 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(Tn(t.shapes)), this.priceLines.setPriceText((e) => this.formatPrice(e)), t.extendedHours === !1 && (this.extendedHours = !1), t.timeFormatter && this.applyTimeFormatter(t.timeFormatter), this.keyboardHandler = new Ae({
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({
1014
1016
  scrollBars: (e) => {
1015
1017
  let t = this.viewport.getState().barWidth + this.viewport.getState().barSpacing;
1016
1018
  this.viewport.scrollBy(e * t), this.updateViewportAndRender();
@@ -1027,17 +1029,17 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
1027
1029
  },
1028
1030
  fitContent: () => this.fitContent()
1029
1031
  }), this.keyboardHandler.setEnabled(this.features.keyboard), t.a11y !== !1) {
1030
- this.a11y = new jt(e, {
1032
+ this.a11y = new zt(e, {
1031
1033
  symbol: () => this.currentSymbol || this.symbolInfo?.symbol || "",
1032
1034
  timeframe: () => this.streamTimeframe ?? "",
1033
1035
  chartType: () => this.options.chartType ?? "candlestick",
1034
1036
  bars: () => this.getDisplayData(),
1035
1037
  visibleRange: () => this.viewport.getState().visibleRange,
1036
1038
  formatPrice: (e) => this.formatPrice(e),
1037
- formatTime: (e) => re(this.numberLocale || "en-US", {
1039
+ formatTime: (e) => ie(this.numberLocale || "en-US", {
1038
1040
  dateStyle: "medium",
1039
1041
  timeStyle: "short"
1040
- }, this.displayTz)(e > mn ? e : e * 1e3),
1042
+ }, this.displayTz)(e > gn ? e : e * 1e3),
1041
1043
  showBar: (e) => this.setCrosshairTime(e)
1042
1044
  }, t.a11y?.labels);
1043
1045
  for (let e of [
@@ -1057,7 +1059,7 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
1057
1059
  }
1058
1060
  this.keyboardHandler.handleKey(e) && (e.preventDefault(), this.a11y?.viewMoved());
1059
1061
  }
1060
- }, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new ve(), this.currentPriceLine.setLocale(this.numberLocale), this.priceAxis.setReservedPriceProvider(() => this.currentPriceLine.isVisible() ? this.currentPriceLine.getPrice() : null), this.alertManager = new ae(), this.alertManager.setDrawingLevels((e) => this.drawingLevelsNow(e)), this.alertManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.alertManager.on("triggered", (e) => {
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) => {
1061
1063
  this.eventBus.emit("alertTriggered", G(e)), this.eventBus.emit("dataUpdate", {
1062
1064
  alert: "triggered",
1063
1065
  alertId: e.id,
@@ -1072,7 +1074,7 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
1072
1074
  this.eventBus.emit("alertExpired", G(e));
1073
1075
  }), this.alertManager.on("updated", (e) => {
1074
1076
  this.eventBus.emit("alertUpdate", G(e));
1075
- }), this.signalMarkerManager = new Ye(), this.signalMarkerManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.signalMarkerManager.setDataGetter(() => this.dataManager.getData()), this.signalMarkerManager.on("added", (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) => {
1076
1078
  this.eventBus.emit("signalMarkerAdd", {
1077
1079
  id: e.id,
1078
1080
  source: e.source,
@@ -1080,18 +1082,18 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
1080
1082
  });
1081
1083
  }), this.signalMarkerManager.on("removed", (e) => {
1082
1084
  this.eventBus.emit("signalMarkerRemove", { id: e });
1083
- }), this.tradeZoneManager = new tt(), this.tradeZoneManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradeZoneManager.setDataGetter(() => this.dataManager.getData()), this.tradeZoneManager.on("added", (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) => {
1084
1086
  this.eventBus.emit("tradeZoneAdd", {
1085
1087
  id: e.id,
1086
1088
  direction: e.direction
1087
1089
  });
1088
1090
  }), this.tradeZoneManager.on("removed", (e) => {
1089
1091
  this.eventBus.emit("tradeZoneRemove", { id: e });
1090
- }), this.replayManager = new Ge(), this.replayManager.on("stateChange", (e) => {
1092
+ }), this.replayManager = new Ye(), this.replayManager.on("stateChange", (e) => {
1091
1093
  this.replayRestarting || this.eventBus.emit("replayState", { state: e });
1092
- }), this.measureOverlay = new Pe(), this.interactionManager = new Oe(e), this.features.panning) {
1093
- let e = new tn();
1094
- this.interactionManager.setPanHandler(new Fe((t, n) => {
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) => {
1095
1097
  t && this.viewport.scrollBy(t), e.step(t, n, this.options.autoScale !== !1) && n && (this.options.autoScale = !1, this.viewport.panPriceRange(n)), this.updateViewportAndRender();
1096
1098
  }, () => e.reset()));
1097
1099
  }
@@ -1103,10 +1105,10 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
1103
1105
  scales: !this.indicatorEngine.hasLeftScaleOverlays()
1104
1106
  }
1105
1107
  })), this.features.zooming) {
1106
- this.interactionManager.setZoomHandler(new ut((e, t) => {
1108
+ this.interactionManager.setZoomHandler(new mt((e, t) => {
1107
1109
  this.viewport.zoom(e, t - this.viewport.getState().chartRect.x), this.updateViewportAndRender();
1108
1110
  }));
1109
- let e = new ce((e) => {
1111
+ let e = new le((e) => {
1110
1112
  this.options.autoScale = !1, this.viewport.scalePriceRange(e), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents();
1111
1113
  }, (e) => {
1112
1114
  let t = this.viewport.getState().chartRect.width;
@@ -1126,7 +1128,7 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
1126
1128
  y: t.y
1127
1129
  });
1128
1130
  })), 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) => {
1129
- let t = M(e.y, this.viewport.getState());
1131
+ let t = jt(e.y, this.viewport.getState());
1130
1132
  Number.isFinite(t) && this.eventBus.emit("priceAxisAdd", {
1131
1133
  price: t,
1132
1134
  x: e.x,
@@ -1136,10 +1138,10 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
1136
1138
  ...this.viewport.getState(),
1137
1139
  data: this.getDisplayData()
1138
1140
  })), this.features.alerts) {
1139
- let e = new ie(this.alertManager, () => this.viewport.getState());
1141
+ let e = new ae(this.alertManager, () => this.viewport.getState());
1140
1142
  this.interactionManager.setAlertDragHandler(e);
1141
1143
  }
1142
- let o = new Ie();
1144
+ let o = new ze();
1143
1145
  o.configure(() => this.getResolvedLayout(), (e, t) => this.setPanelSize(e, t)), this.interactionManager.setPaneResizeHandler(o), this.interactionManager.setAltClickHandler((e) => {
1144
1146
  let t = this.getDisplayData();
1145
1147
  if (t.length === 0) return;
@@ -1163,7 +1165,7 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
1163
1165
  x: e.x,
1164
1166
  y: e.y
1165
1167
  }), t.length === 0) return;
1166
- let r = wt(e.x, this.viewport.getState());
1168
+ let r = At(e.x, this.viewport.getState());
1167
1169
  r < 0 || r >= t.length || this.eventBus.emit("barClick", {
1168
1170
  bar: t[r],
1169
1171
  barIndex: r,
@@ -1203,7 +1205,7 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
1203
1205
  end: () => {
1204
1206
  let e = this.selectionBoxOverlay.end();
1205
1207
  if (e && this.zoomAreaMode) {
1206
- if (e.x1 - e.x0 < xn) return;
1208
+ if (e.x1 - e.x0 < Cn) return;
1207
1209
  this.zoomToBox(e), this.setZoomAreaMode(!1);
1208
1210
  return;
1209
1211
  }
@@ -1222,7 +1224,10 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
1222
1224
  }
1223
1225
  }), this.interactionManager.setOverlayDirtyCallback((e) => {
1224
1226
  this.engine.requestRender(e ? r.Hover : r.Overlay);
1225
- }), this.interactionManager.attach(), t.timeZone !== void 0 && t.timeZone !== null && this.setTimezone(t.timeZone), t.leftPriceScale && (this.leftScaleRequested = !0), this.syncRenderContext(), this.engine.start();
1227
+ }), 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
+ renderer: "canvas",
1229
+ reason: "contextLost"
1230
+ }), this.options.renderer && this.options.renderer !== "canvas" && this.setRenderer(this.options.renderer);
1226
1231
  }
1227
1232
  setData(e) {
1228
1233
  this.loadSeries(e, !1);
@@ -1234,7 +1239,7 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
1234
1239
  if (this.replaySession) return 0;
1235
1240
  let t = null;
1236
1241
  if (this.fullSeries) {
1237
- let n = this.fullSeries[0]?.time, r = /* @__PURE__ */ new Set(), i = e.filter((e) => Mn(e) && (n === void 0 || e.time < n) && !r.has(e.time) && r.add(e.time)).sort((e, t) => e.time - t.time);
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);
1238
1243
  this.fullSeries = [...i, ...this.fullSeries];
1239
1244
  let a = this.sessionKeep(this.fullSeries);
1240
1245
  t = i.length, e = a ? i.filter((e) => a(e.time)) : i;
@@ -1243,7 +1248,7 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
1243
1248
  if (a === 0) return t ?? 0;
1244
1249
  let o = this.dataManager.getData();
1245
1250
  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) {
1246
- let e = Math.round(k(i, this.getDisplayData()));
1251
+ let e = Math.round(E(i, this.getDisplayData()));
1247
1252
  this.viewport.prependBars(e - r);
1248
1253
  }
1249
1254
  return this.updateViewportAndRender(), t ?? a;
@@ -1274,14 +1279,14 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
1274
1279
  }
1275
1280
  checkHistory() {
1276
1281
  this.historyCheckQueued || !this.history.hasLoader() || (this.historyCheckQueued = !0, queueMicrotask(() => {
1277
- if (this.historyCheckQueued = !1, this.replaySession || !this.history.hasLoader() || L(this.options.chartType)) return;
1282
+ if (this.historyCheckQueued = !1, this.replaySession || !this.history.hasLoader() || Kt(this.options.chartType)) return;
1278
1283
  let { from: e, to: t } = this.viewport.getState().visibleRange;
1279
- this.history.maybeLoad(Math.max(0, Math.floor(e)), Math.max(bn, t - e));
1284
+ this.history.maybeLoad(Math.max(0, Math.floor(e)), Math.max(Sn, t - e));
1280
1285
  }));
1281
1286
  }
1282
1287
  useStreamHistory(e, t) {
1283
1288
  if (this.hostHistoryLoader) return;
1284
- let n = Ct(e), r = n.fetchHistoryBefore, i = this.streamTimeframe;
1289
+ let n = kt(e), r = n.fetchHistoryBefore, i = this.streamTimeframe;
1285
1290
  if (!r || i === null || ne(i) !== null) {
1286
1291
  this.historyFromStream && this.history.setLoader(null), this.historyFromStream = !1;
1287
1292
  return;
@@ -1363,7 +1368,7 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
1363
1368
  return this.extendedHours;
1364
1369
  }
1365
1370
  sessionKeep(e) {
1366
- return this.extendedHours ? null : Dt(this.symbolInfo, e);
1371
+ return this.extendedHours ? null : Pt(this.symbolInfo, e);
1367
1372
  }
1368
1373
  shownBars(e) {
1369
1374
  let t = this.sessionKeep(e);
@@ -1404,7 +1409,7 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
1404
1409
  return this.priceLines.setQuoteShown(this.replaySession === null), this.priceLines;
1405
1410
  }
1406
1411
  setShapes(e) {
1407
- let t = Tn(e);
1412
+ let t = Dn(e);
1408
1413
  t.tagRadius !== void 0 && (this.themeManager.setShape({
1409
1414
  ...this.themeManager.getTheme().shape,
1410
1415
  ...t
@@ -1476,7 +1481,7 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
1476
1481
  this.recordIndicators(e, () => this.updateIndicatorNow(e, t));
1477
1482
  }
1478
1483
  updateIndicatorNow(e, t) {
1479
- let n = this.indicatorEngine.getIndicatorDescriptor(e), r = n ? O(n) : null, i = r ? this.indicatorEngine.getIndicatorConfig(e)?.params[r] : void 0;
1484
+ let n = this.indicatorEngine.getIndicatorDescriptor(e), r = n ? T(n) : null, i = r ? this.indicatorEngine.getIndicatorConfig(e)?.params[r] : void 0;
1480
1485
  this.indicatorEngine.updateIndicator(e, t, this.dataManager.getData()), this.announceIndicatorUpdate(0), this.markStateChanged(), this.eventBus.emit("indicatorChange", {
1481
1486
  instanceId: e,
1482
1487
  change: "params"
@@ -1494,7 +1499,7 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
1494
1499
  paneFor(e, t, n, r) {
1495
1500
  if (n) return this.paneHostOf(n, r);
1496
1501
  if (e.placement !== "overlay") return null;
1497
- let i = O(e), a = i ? h(t[i]) : null;
1502
+ let i = T(e), a = i ? h(t[i]) : null;
1498
1503
  return a ? this.paneHostOf(a.instanceId, r) : null;
1499
1504
  }
1500
1505
  paneHostOf(e, t) {
@@ -1537,8 +1542,8 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
1537
1542
  return {
1538
1543
  ...e,
1539
1544
  priceRange: {
1540
- min: t.min - n * vn,
1541
- max: t.max + n * vn
1545
+ min: t.min - n * bn,
1546
+ max: t.max + n * bn
1542
1547
  },
1543
1548
  logScale: !1,
1544
1549
  scaleMode: "regular",
@@ -1588,8 +1593,8 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
1588
1593
  return this.pluginManager;
1589
1594
  }
1590
1595
  static indicators() {
1591
- let e = new C();
1592
- return E(e), e.getAvailableIndicators();
1596
+ let e = new Ae();
1597
+ return C(e), e.getAvailableIndicators();
1593
1598
  }
1594
1599
  setPanelPosition(e, t) {
1595
1600
  this.layoutManager.setPanelPosition(e, t), this.updateViewportAndRender(), this.eventBus.emit("indicatorChange", {
@@ -1612,7 +1617,7 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
1612
1617
  paneMoveHost(e, t) {
1613
1618
  let n = this.indicatorEngine.getIndicatorConfig(e), r = this.indicatorEngine.getIndicatorDescriptor(e);
1614
1619
  if (!n || !r) return;
1615
- let i = O(r);
1620
+ let i = T(r);
1616
1621
  if (r.placement === "overlay" && i && h(n.params[i])) return;
1617
1622
  if (t === "price") return r.placement === "overlay" && n.pane ? null : void 0;
1618
1623
  if (t === "new") {
@@ -1718,7 +1723,7 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
1718
1723
  return this.features.legend ? e + this.chartLegend.getHeight() : e;
1719
1724
  }
1720
1725
  isTimeAligned() {
1721
- return L(this.options.chartType) ? !1 : this.getDisplayData().length === this.dataManager.getLength();
1726
+ return Kt(this.options.chartType) ? !1 : this.getDisplayData().length === this.dataManager.getLength();
1722
1727
  }
1723
1728
  roundPrice(e) {
1724
1729
  if (!Number.isFinite(e)) return e;
@@ -1790,7 +1795,7 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
1790
1795
  }
1791
1796
  autoFib() {
1792
1797
  if (!this.features.drawings) return null;
1793
- let e = this.getDisplayData(), t = this.viewport.getState(), n = ft(e, t.visibleRange.from, t.visibleRange.to);
1798
+ let e = this.getDisplayData(), t = this.viewport.getState(), n = gt(e, t.visibleRange.from, t.visibleRange.to);
1794
1799
  return n ? this.addDrawing({
1795
1800
  type: "fibRetracement",
1796
1801
  anchors: [n[0], n[1]]
@@ -1865,7 +1870,7 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
1865
1870
  recordUndo(e) {
1866
1871
  if (!this.features.drawingUndoRedo || typeof e?.undo != "function" || typeof e.redo != "function") return;
1867
1872
  let t = performance.now(), n = this.undoRedoManager.last();
1868
- if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at < yn) {
1873
+ if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at < xn) {
1869
1874
  this.undoRedoManager.replaceLast({
1870
1875
  ...n,
1871
1876
  custom: {
@@ -1912,7 +1917,7 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
1912
1917
  x: t.x,
1913
1918
  y: t.y
1914
1919
  };
1915
- if ((e === "plot" || e === "priceAxis") && (r.price = M(t.y, n)), (e === "plot" || e === "timeAxis") && n.data.length > 0 && (r.time = j(t.x, n)), e === "pane") {
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") {
1916
1921
  let e = this.getIndicatorPanes().find((e) => t.y >= e.rect.y && t.y <= e.rect.y + e.rect.height);
1917
1922
  e && (r.pane = e.instanceId);
1918
1923
  }
@@ -1938,7 +1943,7 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
1938
1943
  ...this.viewport.getState(),
1939
1944
  data: this.getDisplayData()
1940
1945
  };
1941
- this.setVisibleRange(j(e.x0, t), j(e.x1, t));
1946
+ this.setVisibleRange(D(e.x0, t), D(e.x1, t));
1942
1947
  }
1943
1948
  lockAllDrawings() {
1944
1949
  this.drawingManager.lockAllDrawings();
@@ -1983,7 +1988,7 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
1983
1988
  for (let e of this.indicatorEngine.getActiveIndicators()) {
1984
1989
  let t = this.indicatorEngine.getOutput(e.instanceId)?.series;
1985
1990
  if (!t) continue;
1986
- let r = I(e.id, e.params, e.descriptor.defaultConfig, e.descriptor.shortName), o = e.descriptor.plots ?? Object.keys(t.find((e) => e) ?? {}).map((e) => ({
1991
+ let r = Ht(e.id, e.params, e.descriptor.defaultConfig, e.descriptor.shortName), o = e.descriptor.plots ?? Object.keys(t.find((e) => e) ?? {}).map((e) => ({
1987
1992
  key: e,
1988
1993
  title: e
1989
1994
  }));
@@ -2167,8 +2172,8 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
2167
2172
  this.features.trading && this.tradingManager.setConfig(e);
2168
2173
  }
2169
2174
  async connect(e) {
2170
- if (!D(e.adapter, e.timeframe)) throw RangeError(`${e.adapter.name} cannot serve the ${e.timeframe} timeframe`);
2171
- this.snapshotKey = null, this.replayStop(), this.disconnectStream(), this.streamManager = new Qe(), this.streamManager.on("snapshot", (t) => {
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) => {
2172
2177
  let n = `${this.currentSymbol}|${this.streamTimeframe}`;
2173
2178
  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);
2174
2179
  }), this.streamManager.on("barClose", (e) => {
@@ -2235,7 +2240,7 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
2235
2240
  async switchStream(e, t) {
2236
2241
  if (!this.streamManager) return;
2237
2242
  let n = this.streamAdapter;
2238
- if (n && !D(n, t)) throw RangeError(`${n.name} cannot serve the ${t} timeframe`);
2243
+ if (n && !w(n, t)) throw RangeError(`${n.name} cannot serve the ${t} timeframe`);
2239
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);
2240
2245
  }
2241
2246
  isTimeframeAllowed(e) {
@@ -2251,7 +2256,7 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
2251
2256
  }
2252
2257
  connectExecution(e, t = {}) {
2253
2258
  if (!this.features.trading) throw Error("connectExecution requires features.trading to be enabled");
2254
- this.disconnectExecution(), this.executionAdapter = e, this.execTeardown = fn(e, {
2259
+ this.disconnectExecution(), this.executionAdapter = e, this.execTeardown = mn(e, {
2255
2260
  onIntent: (e, t) => {
2256
2261
  let n = (e) => t(e.payload);
2257
2262
  return this.eventBus.on(e, n), () => this.eventBus.off(e, n);
@@ -2342,18 +2347,18 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
2342
2347
  goToTime(e) {
2343
2348
  let t = this.getDisplayData();
2344
2349
  if (t.length === 0 || !Number.isFinite(e)) return -1;
2345
- let n = Math.max(0, Math.min(t.length - 1, Math.floor(k(e, t)))), r = this.viewport.getState(), i = n * (r.barWidth + r.barSpacing) + r.barWidth / 2 - r.chartRect.width / 2;
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;
2346
2351
  return this.viewport.scrollBy(i - r.offset), this.updateViewportAndRender(), n;
2347
2352
  }
2348
2353
  setVisibleRangePreset(e) {
2349
2354
  let t = this.getDisplayData();
2350
2355
  if (t.length === 0) return;
2351
- let n = t.length - 1, r = t[n].time > mn ? 1 : 1e3, i = ht(e, t[n].time * r, this.displayTz), a = i === null ? null : i / r;
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;
2352
2357
  if (a === null || a < t[0].time) {
2353
2358
  this.fitContent();
2354
2359
  return;
2355
2360
  }
2356
- let o = k(a, t), s = Math.min(n, e === "YTD" ? Math.ceil(o) : Math.floor(o) + 1);
2361
+ let o = E(a, t), s = Math.min(n, e === "YTD" ? Math.ceil(o) : Math.floor(o) + 1);
2357
2362
  this.viewport.zoomToBarRange(s, n + this.viewport.getRightMargin()), this.viewport.scrollToEnd(), this.updateViewportAndRender();
2358
2363
  }
2359
2364
  scrollToEnd() {
@@ -2367,7 +2372,7 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
2367
2372
  setVisibleRange(e, t) {
2368
2373
  let n = this.dataManager.getData();
2369
2374
  if (n.length === 0) return;
2370
- let r = k(Math.min(e, t), n), i = k(Math.max(e, t), n);
2375
+ let r = E(Math.min(e, t), n), i = E(Math.max(e, t), n);
2371
2376
  this.viewport.zoomToBarRange(r, i), this.updateViewportAndRender();
2372
2377
  }
2373
2378
  setPanLimits(e) {
@@ -2428,7 +2433,7 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
2428
2433
  e ? this.crosshairHandler.onPointerMove(e) : this.crosshairHandler.onPointerLeave(), this.engine.requestRender(r.Hover);
2429
2434
  }
2430
2435
  setCrosshairTime(e) {
2431
- let t = this.getDisplayData(), n = e === null || t.length === 0 ? null : Math.floor(k(e, t));
2436
+ let t = this.getDisplayData(), n = e === null || t.length === 0 ? null : Math.floor(E(e, t));
2432
2437
  n !== this.crosshairHandler.getSyncedSlot() && (this.crosshairHandler.setSyncedSlot(n), this.engine.requestRender(r.Hover));
2433
2438
  }
2434
2439
  getData() {
@@ -2473,9 +2478,9 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
2473
2478
  setDepthHeatmapConfig(e) {
2474
2479
  e.opacity !== void 0 && this.depthHeatmap.setOpacity(e.opacity), e.capacity !== void 0 && this.depthHeatmap.setCapacity(e.capacity), this.engine.requestRender(r.Main);
2475
2480
  }
2476
- pushDepthSnapshot(e) {
2477
- let t = this.dataManager.getData();
2478
- t.length !== 0 && (this.depthHeatmap.push(t[t.length - 1].time, e), this.depthHeatmap.isVisible() && this.engine.requestRender(r.Main));
2481
+ pushDepthSnapshot(e, t) {
2482
+ let n = this.dataManager.getData(), i = t ?? n[n.length - 1]?.time;
2483
+ i === void 0 || !Number.isFinite(i) || (this.depthHeatmap.push(i, e), this.depthHeatmap.isVisible() && this.engine.requestRender(r.Main));
2479
2484
  }
2480
2485
  clearDepthHeatmap() {
2481
2486
  this.depthHeatmap.clear(), this.engine.requestRender(r.Main);
@@ -2490,7 +2495,7 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
2490
2495
  this.periodLevels.setPeriod(e), this.engine.requestRender(r.Main);
2491
2496
  }
2492
2497
  setTimezone(e) {
2493
- gn(e), this.timezoneSetting = e, this.applyTimezone();
2498
+ vn(e), this.timezoneSetting = e, this.applyTimezone();
2494
2499
  }
2495
2500
  getTimezone() {
2496
2501
  return this.timezoneSetting;
@@ -2553,7 +2558,7 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
2553
2558
  return this.sessionShading.isVisible();
2554
2559
  }
2555
2560
  setSessionShadingConfig(e) {
2556
- this.hostSessionHours = mt(this.hostSessionHours, e), this.sessionShading.replaceConfig(this.hostSessionHours), this.engine.requestRender(r.Background);
2561
+ this.hostSessionHours = yt(this.hostSessionHours, e), this.sessionShading.replaceConfig(this.hostSessionHours), this.engine.requestRender(r.Background);
2557
2562
  }
2558
2563
  setTooltipVisible(e) {
2559
2564
  e || this.crosshairTooltip.hide();
@@ -2567,23 +2572,46 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
2567
2572
  setStatusText(e) {
2568
2573
  this.chartLegend.setStatusText(e), this.engine.requestRender(r.Hover);
2569
2574
  }
2575
+ async setRenderer(e) {
2576
+ 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());
2581
+ }
2582
+ getRenderer() {
2583
+ return this.engine.getGpu() ? "webgl" : "canvas";
2584
+ }
2585
+ applyRenderer(e, t) {
2586
+ let n = this.getRenderer();
2587
+ e ? this.engine.attachGpu(e) : this.engine.detachGpu();
2588
+ let r = this.getRenderer();
2589
+ (r !== n || t) && this.eventBus.emit("rendererChange", t ? {
2590
+ renderer: r,
2591
+ reason: t
2592
+ } : { renderer: r });
2593
+ }
2594
+ freshFrame() {
2595
+ this.engine.getGpu() && this.engine.renderNow();
2596
+ }
2570
2597
  screenshot(e) {
2571
- this.features.screenshot && T.download(this.container, e, this.themeManager.getTheme().background);
2598
+ this.features.screenshot && (this.freshFrame(), S.download(this.container, e, this.themeManager.getTheme().background));
2572
2599
  }
2573
2600
  async copyScreenshot() {
2574
2601
  if (!this.features.screenshot) return !1;
2575
2602
  try {
2576
- let e = await T.toBlob(this.container, this.themeManager.getTheme().background), t = globalThis.ClipboardItem;
2603
+ this.freshFrame();
2604
+ let e = await S.toBlob(this.container, this.themeManager.getTheme().background), t = globalThis.ClipboardItem;
2577
2605
  return !e || !navigator.clipboard?.write || !t ? !1 : (await navigator.clipboard.write([new t({ "image/png": e })]), !0);
2578
2606
  } catch {
2579
2607
  return !1;
2580
2608
  }
2581
2609
  }
2582
2610
  screenshotDataURL() {
2583
- return this.features.screenshot ? T.toDataURL(this.container, this.themeManager.getTheme().background) : null;
2611
+ return this.features.screenshot ? (this.freshFrame(), S.toDataURL(this.container, this.themeManager.getTheme().background)) : null;
2584
2612
  }
2585
2613
  async screenshotBlob() {
2586
- return this.features.screenshot ? T.toBlob(this.container, this.themeManager.getTheme().background) : null;
2614
+ return this.features.screenshot ? (this.freshFrame(), S.toBlob(this.container, this.themeManager.getTheme().background)) : null;
2587
2615
  }
2588
2616
  addAlert(e, t = "crossing", n, r = "price", i, a = {}) {
2589
2617
  if (!this.features.alerts) return null;
@@ -2709,27 +2737,27 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
2709
2737
  if (!this.features.replay) return;
2710
2738
  if (this.history.reset(), !this.replaySession) {
2711
2739
  if (this.dataManager.getLength() === 0) return;
2712
- let e = new B();
2740
+ let e = new j();
2713
2741
  e.setData(this.fullSeries ?? this.dataManager.getData()), this.replaySession = {
2714
2742
  live: e,
2715
2743
  price: null,
2716
2744
  fedTime: null
2717
2745
  };
2718
2746
  }
2719
- let t = this.shownBars(this.replaySession.live.getData()), { steps: n, ...r } = e ?? {}, i = n ? jn(n, t) : null;
2747
+ let t = this.shownBars(this.replaySession.live.getData()), { steps: n, ...r } = e ?? {}, i = n ? Nn(n, t) : null;
2720
2748
  this.replayStepsSeries = i, this.replayCoarse = t, this.options.autoScale = !0, this.replayRestarting = !0;
2721
2749
  try {
2722
2750
  this.replayManager.load(i ?? t);
2723
2751
  } finally {
2724
2752
  this.replayRestarting = !1;
2725
2753
  }
2726
- i && r.startIndex !== void 0 && (r.startIndex = Pn(i, t, r.startIndex)), this.replayBarUnsub?.();
2754
+ i && r.startIndex !== void 0 && (r.startIndex = In(i, t, r.startIndex)), this.replayBarUnsub?.();
2727
2755
  let a = -1, o = -1, s = null, c = i ?? t;
2728
2756
  this.replayBarUnsub = this.replayManager.on("bar", ({ index: e }) => {
2729
2757
  let n = e, r = t[e];
2730
2758
  if (i) {
2731
2759
  let c = i[e];
2732
- n = Nn(t, c.time), s = s !== null && o === e - 1 && n === a - 1 && s ? In(s, c) : Fn(t[n], i, e), r = s;
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;
2733
2761
  }
2734
2762
  o = e;
2735
2763
  let l = n + 1, u = a > 0 && l >= a && this.dataManager.getLength() === a, d = !(u && !this.replaySeeking) || this.autoScrollOnNewBar && this.viewport.isAtEnd();
@@ -2774,20 +2802,20 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
2774
2802
  return;
2775
2803
  }
2776
2804
  if (i.time <= n.fedTime) return;
2777
- let a = e.slice(On(e, n.fedTime), t + 1);
2805
+ let a = e.slice(An(e, n.fedTime), t + 1);
2778
2806
  n.fedTime = i.time;
2779
- let o = Math.ceil(a.length / Dn);
2780
- for (let e = 0; e < a.length; e += o) for (let [t, n] of kn(a.slice(e, e + o))) r.setMarkPrice(t, n);
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);
2781
2809
  this.tradingManager.setCurrentPrice(i.close);
2782
2810
  }
2783
2811
  getReplayBarIndex() {
2784
2812
  if (!this.replaySession) return -1;
2785
2813
  let { current: e } = this.replayManager.getProgress(), t = this.replayStepsSeries;
2786
- return t && this.replayCoarse ? Nn(this.replayCoarse, t[e]?.time ?? -Infinity) : e;
2814
+ return t && this.replayCoarse ? Fn(this.replayCoarse, t[e]?.time ?? -Infinity) : e;
2787
2815
  }
2788
2816
  replaySeekToBar(e) {
2789
2817
  let t = this.replayStepsSeries;
2790
- this.replaySeek(t && this.replayCoarse ? Pn(t, this.replayCoarse, e) : e);
2818
+ this.replaySeek(t && this.replayCoarse ? In(t, this.replayCoarse, e) : e);
2791
2819
  }
2792
2820
  replayPause() {
2793
2821
  this.replayManager.pause();
@@ -2844,14 +2872,14 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
2844
2872
  });
2845
2873
  }
2846
2874
  restoreIndicators(e, t) {
2847
- let n = Cn(e), r = /* @__PURE__ */ new Map();
2875
+ let n = Tn(e), r = /* @__PURE__ */ new Map();
2848
2876
  this.unrestoredIndicators = [];
2849
2877
  let i = new Set(this.indicatorEngine.getAvailableIndicators().map((e) => e.id)), a = [], o = /* @__PURE__ */ new Set();
2850
2878
  if (t) {
2851
2879
  let e = new Map(n.map((e) => [e.instanceId, e])), t = this.getIndicatorSetup();
2852
2880
  for (let n of t) {
2853
2881
  let t = e.get(n.instanceId);
2854
- t && wn(n, t) && o.add(n.instanceId);
2882
+ t && En(n, t) && o.add(n.instanceId);
2855
2883
  }
2856
2884
  for (let e of t) o.has(e.instanceId) || this.removeIndicator(e.instanceId);
2857
2885
  for (let e of [...o]) this.indicatorEngine.getIndicatorConfig(e) || o.delete(e);
@@ -2987,7 +3015,7 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
2987
3015
  if (this.indicatorHistoryDepth > 0 || !this.features.drawingUndoRedo) return t();
2988
3016
  let n = this.getIndicatorSetup(), r = this.withoutIndicatorHistory(t), i = this.getIndicatorSetup();
2989
3017
  if (JSON.stringify(n) === JSON.stringify(i)) return r;
2990
- let a = performance.now(), o = this.undoRedoManager.last(), s = e !== void 0 && o?.type === "indicators" && o.indicators?.subject === e && a - (o.indicators.at ?? 0) < yn && JSON.stringify(o.indicators.after) === JSON.stringify(n), c = {
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 = {
2991
3019
  type: "indicators",
2992
3020
  before: null,
2993
3021
  after: null
@@ -3031,7 +3059,7 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
3031
3059
  let t = e.indexOf(":"), r = t > 0 ? n.get(e.slice(0, t)) : void 0;
3032
3060
  return r ? r + e.slice(t) : e;
3033
3061
  }, r = t(e.channel), i = {
3034
- ...gt(e),
3062
+ ...xt(e),
3035
3063
  ...e.target ? { target: t(e.target) } : {}
3036
3064
  };
3037
3065
  if (!e.expired) {
@@ -3079,15 +3107,15 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
3079
3107
  candleDown: e.colorScheme.down,
3080
3108
  candleUpWick: e.colorScheme.up,
3081
3109
  candleDownWick: e.colorScheme.down,
3082
- volumeUp: e.colorScheme.up.replace(")", ", 0.3)").replace("rgb(", "rgba(") || `${e.colorScheme.up}4D`,
3083
- volumeDown: e.colorScheme.down.replace(")", ", 0.3)").replace("rgb(", "rgba(") || `${e.colorScheme.down}4D`
3110
+ volumeUp: re(e.colorScheme.up),
3111
+ volumeDown: re(e.colorScheme.down)
3084
3112
  };
3085
3113
  this.themeManager.setTheme(t);
3086
3114
  }
3087
3115
  e.pricePrecision !== void 0 && this.applyPricePrecision(e.pricePrecision), this.updateViewportAndRender();
3088
3116
  }
3089
3117
  applyPricePrecision(e) {
3090
- this.marketPricePrecision = e, this.tradingManager.setConfig({ pricePrecision: e ?? void 0 }), this.alertManager.setPricePrecision(e ?? _n), this.streamManager?.priceLine.setPricePrecision(e), this.currentPriceLine.setPricePrecision(e), this.crosshairHandler.setPricePrecision(e), this.chartLegend.setPricePrecision(e), this.crosshairTooltip.setPricePrecision(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);
3091
3119
  }
3092
3120
  getMarket() {
3093
3121
  return this.marketConfig;
@@ -3114,17 +3142,17 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
3114
3142
  this.viewport.resize(e.width, e.height), this.layoutManager.resize(e.width, e.height), this.updateViewportAndRender(n), this.eventBus.emit("resize", e);
3115
3143
  }
3116
3144
  destroy() {
3117
- 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 = "";
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 = "";
3118
3146
  }
3119
3147
  createChartRenderer(e) {
3120
- let t = Lt(e, (e) => this.pluginManager.getChartType(e));
3121
- return t instanceof S && t.setPriceText((e) => this.formatPrice(e)), t;
3148
+ let t = Jt(e, (e) => this.pluginManager.getChartType(e));
3149
+ return t instanceof Oe && t.setPriceText((e) => this.formatPrice(e)), t;
3122
3150
  }
3123
3151
  getDisplayData() {
3124
3152
  if (this.displayDataCache) return this.displayDataCache;
3125
3153
  let e = this.dataManager.getData();
3126
3154
  if (e.length === 0) return e;
3127
- let t = Rt(this.options.chartType, e, (e) => this.pluginManager.getChartType(e), this.chartTypeOptions);
3155
+ let t = Yt(this.options.chartType, e, (e) => this.pluginManager.getChartType(e), this.chartTypeOptions);
3128
3156
  return this.displayDataCache = t, t;
3129
3157
  }
3130
3158
  recalcIndicatorsFrom(e, t) {
@@ -3157,7 +3185,7 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
3157
3185
  this.viewport.setScaleBaseline(t[e]?.close);
3158
3186
  }
3159
3187
  if (n) {
3160
- let e = En(this.indicatorEngine.getOverlayPriceRange(r.visibleRange.from, Math.min(r.visibleRange.to, t.length - 1)), this.features.compareSymbols ? this.compareRenderer.getPriceRange(t, r) : null);
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);
3161
3189
  if (e) {
3162
3190
  let t = r.priceRange, n = Math.min(t.min, e.min), i = Math.max(t.max, e.max);
3163
3191
  if (n < t.min || i > t.max) {
@@ -3181,7 +3209,7 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
3181
3209
  fitLeftAxisWidth() {
3182
3210
  let e = this.leftViewport;
3183
3211
  if (!e) return !1;
3184
- let t = this.themeManager.getTheme(), n = $t({
3212
+ let t = this.themeManager.getTheme(), n = z({
3185
3213
  min: e.priceRange.min,
3186
3214
  max: e.priceRange.max,
3187
3215
  lastPrice: null,
@@ -3190,12 +3218,12 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
3190
3218
  fontFamily: t.font.family,
3191
3219
  fontSizeSmall: t.font.sizeSmall,
3192
3220
  measure: (e, t) => this.measureText(e, t)
3193
- }), r = en(this.leftAxisWidth, n);
3221
+ }), r = B(this.leftAxisWidth, n);
3194
3222
  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);
3195
3223
  }
3196
3224
  fitPriceAxisWidth() {
3197
3225
  if (!this.features.priceAxis) return !1;
3198
- let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n = $t({
3226
+ let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n = z({
3199
3227
  min: e.min,
3200
3228
  max: e.max,
3201
3229
  lastPrice: this.currentPriceLine.getPrice(),
@@ -3205,7 +3233,7 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
3205
3233
  fontFamily: t.font.family,
3206
3234
  fontSizeSmall: t.font.sizeSmall,
3207
3235
  measure: (e, t) => this.measureText(e, t)
3208
- }), r = en(this.priceAxisWidth, n);
3236
+ }), r = B(this.priceAxisWidth, n);
3209
3237
  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);
3210
3238
  }
3211
3239
  measureText(e, t) {
@@ -3249,7 +3277,7 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
3249
3277
  buildPanelRenderInfos() {
3250
3278
  if (this.panelInfoCache) return this.panelInfoCache;
3251
3279
  let e = this.getResolvedLayout(), t = this.viewport.getState(), { from: n, to: r } = t.visibleRange, i = e.panels.map((e) => {
3252
- 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) ?? { ...pn }, o = {
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 = {
3253
3281
  x: e.rect.x,
3254
3282
  y: e.rect.y + 20,
3255
3283
  width: e.rect.width,
@@ -3330,7 +3358,7 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
3330
3358
  });
3331
3359
  }
3332
3360
  drawOverlayPlugins(e, t) {
3333
- let n = rn(this.pluginManager.getOverlays(), t);
3361
+ let n = V(this.pluginManager.getOverlays(), t);
3334
3362
  if (n.length === 0) return;
3335
3363
  let r = {
3336
3364
  viewport: this.viewport.getState(),
@@ -3352,7 +3380,7 @@ var _n = 2, vn = .08, yn = 800, bn = 20, xn = 8, Sn = class {
3352
3380
  } : null;
3353
3381
  }
3354
3382
  };
3355
- function Cn(e) {
3383
+ function Tn(e) {
3356
3384
  let t = new Map(e.map((e) => [e.instanceId, e])), n = [], r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = (e) => {
3357
3385
  if (r.has(e.instanceId) || i.has(e.instanceId)) return;
3358
3386
  i.add(e.instanceId);
@@ -3366,15 +3394,15 @@ function Cn(e) {
3366
3394
  for (let t of e) a(t);
3367
3395
  return n;
3368
3396
  }
3369
- function wn(e, t) {
3397
+ function En(e, t) {
3370
3398
  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);
3371
3399
  }
3372
- function Tn(e) {
3400
+ function Dn(e) {
3373
3401
  let t = e.tagRadius;
3374
3402
  return typeof t == "number" && Number.isFinite(t) && t >= 0 ? { tagRadius: Math.min(t, 999) } : {};
3375
3403
  }
3376
3404
  var W = new Set(["compareSymbol", "spread"]);
3377
- function En(e, t) {
3405
+ function On(e, t) {
3378
3406
  return e ? t ? {
3379
3407
  min: Math.min(e.min, t.min),
3380
3408
  max: Math.max(e.max, t.max)
@@ -3395,8 +3423,8 @@ function G(e) {
3395
3423
  bars: e.bars
3396
3424
  };
3397
3425
  }
3398
- var Dn = 500;
3399
- function On(e, t) {
3426
+ var kn = 500;
3427
+ function An(e, t) {
3400
3428
  let n = 0, r = e.length;
3401
3429
  for (; n < r;) {
3402
3430
  let i = n + r >> 1;
@@ -3404,20 +3432,20 @@ function On(e, t) {
3404
3432
  }
3405
3433
  return n;
3406
3434
  }
3407
- function kn(e) {
3435
+ function jn(e) {
3408
3436
  let t = 0, n = 0;
3409
3437
  for (let r = 1; r < e.length; r++) e[r].low < e[t].low && (t = r), e[r].high > e[n].high && (n = r);
3410
3438
  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];
3411
3439
  return [...a ? [r, i] : [i, r], [o.close, o.time]];
3412
3440
  }
3413
- function An(e) {
3441
+ function Mn(e) {
3414
3442
  let t = 0;
3415
3443
  for (let n = Math.max(1, e.length - 10); n < e.length; n++) t = Math.max(t, e[n].time - e[n - 1].time);
3416
3444
  return t > 0 ? t : Infinity;
3417
3445
  }
3418
- function jn(e, t) {
3446
+ function Nn(e, t) {
3419
3447
  if (t.length === 0) return null;
3420
- let n = t[t.length - 1].time + An(t), r = e.filter((e) => Mn(e) && e.time >= t[0].time && e.time < n).sort((e, t) => e.time - t.time), i = [];
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 = [];
3421
3449
  for (let e of r) (i.length === 0 || i[i.length - 1].time !== e.time) && i.push(e);
3422
3450
  if (i.length === 0) return null;
3423
3451
  let a = t.findIndex((e) => e.time >= i[0].time);
@@ -3425,7 +3453,7 @@ function jn(e, t) {
3425
3453
  let o = t.slice(0, a), s = i.filter((e) => e.time >= t[a].time);
3426
3454
  return [...o, ...s];
3427
3455
  }
3428
- function Mn(e) {
3456
+ function Pn(e) {
3429
3457
  return [
3430
3458
  e.time,
3431
3459
  e.open,
@@ -3434,7 +3462,7 @@ function Mn(e) {
3434
3462
  e.close
3435
3463
  ].every(Number.isFinite);
3436
3464
  }
3437
- function Nn(e, t) {
3465
+ function Fn(e, t) {
3438
3466
  let n = 0, r = e.length - 1;
3439
3467
  for (; n < r;) {
3440
3468
  let i = n + r + 1 >> 1;
@@ -3442,22 +3470,22 @@ function Nn(e, t) {
3442
3470
  }
3443
3471
  return n;
3444
3472
  }
3445
- function Pn(e, t, n) {
3473
+ function In(e, t, n) {
3446
3474
  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;
3447
3475
  for (let t = 0; t < e.length && e[t].time < i; t++) a = t;
3448
3476
  return Math.max(0, a);
3449
3477
  }
3450
- function Fn(e, t, n) {
3478
+ function Ln(e, t, n) {
3451
3479
  let r = n;
3452
3480
  for (; r > 0 && t[r - 1].time >= e.time;) r--;
3453
3481
  let i = {
3454
3482
  ...t[r],
3455
3483
  time: e.time
3456
3484
  };
3457
- for (let e = r + 1; e <= n; e++) i = In(i, t[e]);
3485
+ for (let e = r + 1; e <= n; e++) i = Rn(i, t[e]);
3458
3486
  return i;
3459
3487
  }
3460
- function In(e, t) {
3488
+ function Rn(e, t) {
3461
3489
  return {
3462
3490
  time: e.time,
3463
3491
  open: e.open,
@@ -3475,26 +3503,26 @@ function K(e, t) {
3475
3503
  }
3476
3504
  //#endregion
3477
3505
  //#region src/io/parseOHLCV.ts
3478
- var Ln = [
3506
+ var zn = [
3479
3507
  "time",
3480
3508
  "timestamp",
3481
3509
  "date",
3482
3510
  "datetime",
3483
3511
  "t"
3484
- ], Rn = ["open", "o"], zn = ["high", "h"], Bn = ["low", "l"], Vn = ["close", "c"], Hn = [
3512
+ ], Bn = ["open", "o"], Vn = ["high", "h"], Hn = ["low", "l"], Un = ["close", "c"], Wn = [
3485
3513
  "volume",
3486
3514
  "vol",
3487
3515
  "v"
3488
3516
  ];
3489
- function Un(e) {
3517
+ function Gn(e) {
3490
3518
  let t = e.trim();
3491
- return t ? t[0] === "[" || t[0] === "{" ? Wn(t) : Gn(t) : {
3519
+ return t ? t[0] === "[" || t[0] === "{" ? Kn(t) : qn(t) : {
3492
3520
  data: [],
3493
3521
  rowCount: 0,
3494
3522
  skipped: 0
3495
3523
  };
3496
3524
  }
3497
- function Wn(e) {
3525
+ function Kn(e) {
3498
3526
  let t;
3499
3527
  try {
3500
3528
  t = JSON.parse(e);
@@ -3504,19 +3532,19 @@ function Wn(e) {
3504
3532
  if (!Array.isArray(t)) throw Error("Expected a JSON array of OHLCV rows");
3505
3533
  let n = [], r = 0;
3506
3534
  for (let e of t) {
3507
- let t = Array.isArray(e) ? Yn(e) : Jn(e);
3535
+ let t = Array.isArray(e) ? Qn(e) : Zn(e);
3508
3536
  t ? n.push(t) : r++;
3509
3537
  }
3510
- return Xn(n, t.length, r);
3538
+ return Y(n, t.length, r);
3511
3539
  }
3512
- function Gn(e) {
3540
+ function qn(e) {
3513
3541
  let t = e.split(/\r?\n/).filter((e) => e.trim().length > 0);
3514
3542
  if (t.length === 0) return {
3515
3543
  data: [],
3516
3544
  rowCount: 0,
3517
3545
  skipped: 0
3518
3546
  };
3519
- let n = Kn(t[0]), r = q(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? qn(r) : {
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) : {
3520
3548
  time: 0,
3521
3549
  open: 1,
3522
3550
  high: 2,
@@ -3527,7 +3555,7 @@ function Gn(e) {
3527
3555
  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");
3528
3556
  let o = [], s = 0;
3529
3557
  for (let e = +!!i; e < t.length; e++) {
3530
- 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;
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;
3531
3559
  if (i === null || ![
3532
3560
  c,
3533
3561
  l,
@@ -3546,9 +3574,9 @@ function Gn(e) {
3546
3574
  volume: Number.isFinite(f) ? f : 0
3547
3575
  });
3548
3576
  }
3549
- return Xn(o, t.length - +!!i, s);
3577
+ return Y(o, t.length - +!!i, s);
3550
3578
  }
3551
- function Kn(e) {
3579
+ function Jn(e) {
3552
3580
  let t = {
3553
3581
  ",": 0,
3554
3582
  ";": 0,
@@ -3560,7 +3588,7 @@ function Kn(e) {
3560
3588
  for (let [e, i] of Object.entries(t)) i > r && (n = e, r = i);
3561
3589
  return n;
3562
3590
  }
3563
- function q(e, t) {
3591
+ function Yn(e, t) {
3564
3592
  let n = [], r = "", i = !1;
3565
3593
  for (let a = 0; a < e.length; a++) {
3566
3594
  let o = e[a];
@@ -3568,25 +3596,25 @@ function q(e, t) {
3568
3596
  }
3569
3597
  return n.push(r), n;
3570
3598
  }
3571
- function qn(e) {
3599
+ function Xn(e) {
3572
3600
  let t = (t) => e.findIndex((e) => t.includes(e));
3573
3601
  return {
3574
- time: t(Ln),
3575
- open: t(Rn),
3576
- high: t(zn),
3577
- low: t(Bn),
3578
- close: t(Vn),
3579
- volume: t(Hn)
3602
+ time: t(zn),
3603
+ open: t(Bn),
3604
+ high: t(Vn),
3605
+ low: t(Hn),
3606
+ close: t(Un),
3607
+ volume: t(Wn)
3580
3608
  };
3581
3609
  }
3582
- function Jn(e) {
3610
+ function Zn(e) {
3583
3611
  let t = (t) => {
3584
3612
  for (let n of t) {
3585
3613
  if (e[n] !== void 0) return e[n];
3586
3614
  let t = n.toUpperCase();
3587
3615
  if (e[t] !== void 0) return e[t];
3588
3616
  }
3589
- }, n = Y(String(t(Ln) ?? "")), r = Number(t(Rn)), i = Number(t(zn)), a = Number(t(Bn)), o = Number(t(Vn)), s = Number(t(Hn) ?? 0);
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);
3590
3618
  return n === null || ![
3591
3619
  r,
3592
3620
  i,
@@ -3601,9 +3629,9 @@ function Jn(e) {
3601
3629
  volume: Number.isFinite(s) ? s : 0
3602
3630
  };
3603
3631
  }
3604
- function Yn(e) {
3632
+ function Qn(e) {
3605
3633
  if (e.length < 5) return null;
3606
- 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;
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;
3607
3635
  return t === null || ![
3608
3636
  n,
3609
3637
  r,
@@ -3618,10 +3646,10 @@ function Yn(e) {
3618
3646
  volume: Number.isFinite(o) ? o : 0
3619
3647
  };
3620
3648
  }
3621
- function J(e) {
3649
+ function q(e) {
3622
3650
  return e === void 0 || e.trim() === "" ? NaN : Number(e);
3623
3651
  }
3624
- function Y(e) {
3652
+ function J(e) {
3625
3653
  let t = e.trim();
3626
3654
  if (!t) return null;
3627
3655
  let n = Number(t);
@@ -3629,7 +3657,7 @@ function Y(e) {
3629
3657
  let r = Date.parse(t);
3630
3658
  return Number.isFinite(r) ? r : null;
3631
3659
  }
3632
- function Xn(e, t, n) {
3660
+ function Y(e, t, n) {
3633
3661
  e.sort((e, t) => e.time - t.time);
3634
3662
  let r = [];
3635
3663
  for (let t of e) r.length > 0 && r[r.length - 1].time === t.time ? r[r.length - 1] = t : r.push(t);
@@ -3641,7 +3669,7 @@ function Xn(e, t, n) {
3641
3669
  }
3642
3670
  //#endregion
3643
3671
  //#region src/io/DragDropImporter.ts
3644
- var Zn = class {
3672
+ var $n = class {
3645
3673
  host;
3646
3674
  overlay = null;
3647
3675
  callbacks;
@@ -3674,7 +3702,7 @@ var Zn = class {
3674
3702
  e.preventDefault(), this.depth = 0, this.hideOverlay();
3675
3703
  let t = e.dataTransfer?.files?.[0];
3676
3704
  if (t) try {
3677
- let e = Un(await t.text());
3705
+ let e = Gn(await t.text());
3678
3706
  if (e.data.length === 0) throw Error(`No valid OHLCV rows found in "${t.name}"`);
3679
3707
  this.callbacks.onData(e.data, e, t);
3680
3708
  } catch (e) {
@@ -3718,7 +3746,7 @@ function Z(e) {
3718
3746
  };
3719
3747
  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;
3720
3748
  }
3721
- var Qn = (e, t) => t.updatedAt - e.updatedAt;
3749
+ var er = (e, t) => t.updatedAt - e.updatedAt;
3722
3750
  function Q(e) {
3723
3751
  if (typeof e != "object" || !e) return null;
3724
3752
  let t = e;
@@ -3731,17 +3759,17 @@ function Q(e) {
3731
3759
  kind: typeof t.kind == "string" ? t.kind : void 0
3732
3760
  });
3733
3761
  }
3734
- function $n(e) {
3762
+ function tr(e) {
3735
3763
  let t = Q(e), n = t ? e.content : void 0;
3736
3764
  return t && typeof n == "string" ? {
3737
3765
  ...t,
3738
3766
  content: n
3739
3767
  } : null;
3740
3768
  }
3741
- function er(e = []) {
3769
+ function nr(e = []) {
3742
3770
  let t = new Map(e.map((e) => [e.id, { ...e }]));
3743
3771
  return {
3744
- list: () => [...t.values()].map(Z).sort(Qn),
3772
+ list: () => [...t.values()].map(Z).sort(er),
3745
3773
  load: (e) => {
3746
3774
  let n = t.get(e);
3747
3775
  return n ? { ...n } : null;
@@ -3754,7 +3782,7 @@ function er(e = []) {
3754
3782
  }
3755
3783
  };
3756
3784
  }
3757
- function tr(e = "tcw:layouts:") {
3785
+ function rr(e = "tcw:layouts:") {
3758
3786
  let t = `${e}index`, n = (t) => `${e}item:${t}`, r = () => {
3759
3787
  let e;
3760
3788
  try {
@@ -3765,7 +3793,7 @@ function tr(e = "tcw:layouts:") {
3765
3793
  return Array.isArray(e) ? e.map(Q).filter((e) => e !== null) : [];
3766
3794
  }, i = (e) => localStorage.setItem(t, JSON.stringify(e));
3767
3795
  return {
3768
- list: () => r().sort(Qn),
3796
+ list: () => r().sort(er),
3769
3797
  load: (e) => {
3770
3798
  let t = r().find((t) => t.id === e), i = t ? localStorage.getItem(n(e)) : null;
3771
3799
  return t && i !== null ? {
@@ -3783,14 +3811,14 @@ function tr(e = "tcw:layouts:") {
3783
3811
  }
3784
3812
  //#endregion
3785
3813
  //#region src/state/LayoutSession.ts
3786
- var nr = 80;
3814
+ var ir = 80;
3787
3815
  function $(e) {
3788
3816
  return e.replace(/\s+/g, " ").trim().slice(0, 80).trim() || null;
3789
3817
  }
3790
- function rr() {
3818
+ function ar() {
3791
3819
  return globalThis.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
3792
3820
  }
3793
- function ir(e) {
3821
+ function or(e) {
3794
3822
  let { id: t, name: n, symbol: r, timeframe: i, updatedAt: a, kind: o } = e;
3795
3823
  return {
3796
3824
  id: t,
@@ -3801,7 +3829,7 @@ function ir(e) {
3801
3829
  ...o === void 0 ? {} : { kind: o }
3802
3830
  };
3803
3831
  }
3804
- var ar = class {
3832
+ var sr = class {
3805
3833
  currentLayout = null;
3806
3834
  savedContent = null;
3807
3835
  dirty = !1;
@@ -3817,7 +3845,7 @@ var ar = class {
3817
3845
  now;
3818
3846
  newId;
3819
3847
  constructor(e, t, n = {}) {
3820
- 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 ?? rr;
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;
3821
3849
  }
3822
3850
  current() {
3823
3851
  return this.currentLayout;
@@ -3847,7 +3875,7 @@ var ar = class {
3847
3875
  }
3848
3876
  open(e) {
3849
3877
  return this.queue(async () => {
3850
- let t = $n(await this.storage.load(e));
3878
+ let t = tr(await this.storage.load(e));
3851
3879
  if (!t || t.id !== e || (t.kind ?? "chart") !== this.kind || this.destroyed) return !1;
3852
3880
  this.cancelTimer(), this.applying++;
3853
3881
  try {
@@ -3857,13 +3885,13 @@ var ar = class {
3857
3885
  } finally {
3858
3886
  this.applying--;
3859
3887
  }
3860
- return this.cancelTimer(), this.currentLayout = ir(t), this.savedContent = this.host.capture().content, this.dirty = !1, this.notify(), !0;
3888
+ return this.cancelTimer(), this.currentLayout = or(t), this.savedContent = this.host.capture().content, this.dirty = !1, this.notify(), !0;
3861
3889
  });
3862
3890
  }
3863
3891
  rename(e, t) {
3864
3892
  let n = $(t);
3865
3893
  return n ? this.queue(async () => {
3866
- let t = $n(await this.storage.load(e));
3894
+ let t = tr(await this.storage.load(e));
3867
3895
  !t || t.id !== e || (await this.storage.save({
3868
3896
  ...t,
3869
3897
  name: n
@@ -3941,7 +3969,7 @@ var ar = class {
3941
3969
  content: n.content
3942
3970
  };
3943
3971
  await this.storage.save(r);
3944
- let i = ir(r);
3972
+ let i = or(r);
3945
3973
  return this.currentLayout = i, this.savedContent = n.content, this.dirty = !1, this.notify(), i;
3946
3974
  }
3947
3975
  forget() {
@@ -3962,6 +3990,6 @@ var ar = class {
3962
3990
  }
3963
3991
  };
3964
3992
  //#endregion
3965
- export { I as C, B as S, H as _, er as a, Ut as b, Sn as c, cn as d, sn as f, rn as g, nn as h, tr as i, hn as l, on as m, nr as n, Zn as o, an as p, $ as r, Un as s, ar as t, ln as u, Jt as v, Vt as x, Gt as y };
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 };
3966
3994
 
3967
- //# sourceMappingURL=LayoutSession-CWn3sdbs.js.map
3995
+ //# sourceMappingURL=LayoutSession-BF1iuUrs.js.map