@tradecanvas/chart 1.24.0 → 1.26.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,10 +1,10 @@
1
- import { DARK_THEME as e, DEFAULT_PANEL_HEIGHT as t, LIGHT_THEME as n, LayerType as r, MIN_PANEL_HEIGHT as i, PRICE_AXIS_WIDTH as a, TIME_AXIS_HEIGHT as o, autoPricePrecision as s, chartStyleValue as c, computePriceLimits as l, formatPrice as u, fractionTick as d, indicatorSource as f, isValidTimeZone as p, mergeBar as m, normalizeBarTime as h, parseIndicatorSource as g, priceFormatterFor as _, priceStepAt as v, readChartStyleOverrides as y, readChartTypeOptions as b, readIndicatorPlotStyles as ee, readPaneStyle as x, resolveChartTheme as te, sessionMinute as S, setLocale as ne, stepDecimals as re, tickBarCount as ie, timeframeToMs as ae, volumeColor as oe, zonedDateFormatter as se } from "@tradecanvas/commons";
2
- import { AlertDragHandler as ce, AlertManager as le, Animator as ue, AreaRenderer as de, AxisDragHandler as fe, BarCountdown as pe, BarRenderer as me, BaselineRenderer as he, CandlestickRenderer as ge, ChartLegend as _e, ChartStateManager as C, CompareRenderer as ve, CompareSymbolIndicator as ye, CorrelationCoefficientIndicator as be, CorrelationLogIndicator as xe, CrosshairHandler as Se, CrosshairTooltip as Ce, CurrentPriceLine as we, DEFAULT_SESSION_HOURS as Te, DataExporter as w, DepthHeatmapRenderer as Ee, DrawingManager as De, DrawingRenderer as Oe, EquivolumeRenderer as ke, EventBus as Ae, GridRenderer as je, HLCAreaRenderer as Me, HiLoRenderer as T, HollowCandleRenderer as Ne, IndicatorEngine as E, InteractionManager as Pe, KagiRenderer as Fe, KeyboardHandler as Ie, LineRenderer as Le, LineWithMarkersRenderer as Re, MarketProfileRenderer as ze, MeasureOverlay as Be, PanHandler as Ve, PaneResizeHandler as He, PeriodLevelsRenderer as Ue, PinnedTooltip as We, PivotMarkersRenderer as Ge, PointAndFigureRenderer as D, PriceAxis as O, PriceAxisAddButton as Ke, PriceLines as qe, RenderEngine as Je, RenkoRenderer as Ye, ReplayManager as Xe, Screenshot as k, SelectionBoxOverlay as Ze, SessionBreaks as Qe, SessionShading as $e, SignalMarkerManager as et, SpreadIndicator as tt, StepLineRenderer as nt, StreamManager as rt, SymbolSeriesStore as it, TimeAxis as at, TradeZoneManager as ot, TradingManager as st, TradingRenderer as ct, UndoRedoManager as lt, Viewport as ut, VolumeCandleRenderer as dt, VolumeProfileRenderer as ft, VolumeRenderer as pt, Watermark as mt, ZoomHandler as ht, barTimeStepMs as gt, findDominantSwing as _t, gpuContextsLeft as vt, isRegularSession as yt, loadWebGL as bt, mergeSessionHours as xt, priceToY as St, rangePresetStart as Ct, readAlertOptions as wt, registerBuiltInDrawingTools as Tt, registerBuiltInIndicators as A, servesTimeframe as j, sourceParam as M, timeToX as Et, timestampToBarIndex as N, toHeikinAshi as Dt, toKagi as Ot, toLineBreak as kt, toPointAndFigure as At, toRangeBars as jt, toRenko as P, whenGpuContextFree as Mt, withResampling as Nt, xToBarIndex as Pt, xToTime as F, yToPrice as Ft } 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, barTimeUnit as c, chartStyleValue as l, computePriceLimits as u, formatPrice as d, fractionTick as f, indicatorSource as p, isValidTimeZone as m, mergeBar as h, normalizeBarTime as g, padPriceRange as _, parseIndicatorSource as v, priceFormatterFor as ee, priceStepAt as te, readChartStyleOverrides as ne, readChartTypeOptions as y, readIndicatorPlotStyles as b, readPaneStyle as x, resolveChartTheme as re, sessionMinute as S, setLocale as ie, stepDecimals as ae, tickBarCount as oe, timeframeToMs as se, volumeColor as ce, zonedDateFormatter as le } from "@tradecanvas/commons";
2
+ import { AlertDragHandler as ue, AlertManager as de, Animator as fe, AreaRenderer as pe, AxisDragHandler as me, BarCountdown as he, BarRenderer as ge, BaselineRenderer as _e, CandlestickRenderer as ve, ChartLegend as ye, ChartStateManager as C, CompareRenderer as be, CompareSymbolIndicator as xe, CorrelationCoefficientIndicator as Se, CorrelationLogIndicator as Ce, CrosshairHandler as we, CrosshairTooltip as Te, CurrentPriceLine as Ee, DEFAULT_SESSION_HOURS as De, DataExporter as w, DepthHeatmapRenderer as Oe, DrawingManager as ke, DrawingRenderer as Ae, EquivolumeRenderer as je, EventBus as Me, GridRenderer as Ne, HLCAreaRenderer as Pe, HiLoRenderer as T, HollowCandleRenderer as Fe, IndicatorEngine as E, InteractionManager as Ie, KagiRenderer as Le, KeyboardHandler as Re, LineRenderer as ze, LineWithMarkersRenderer as Be, MarketProfileRenderer as Ve, MeasureOverlay as He, PanHandler as Ue, PaneResizeHandler as We, PeriodLevelsRenderer as Ge, PinnedTooltip as Ke, PivotMarkersRenderer as qe, PointAndFigureRenderer as D, PriceAxis as O, PriceAxisAddButton as Je, PriceLines as Ye, RenderEngine as Xe, RenkoRenderer as Ze, ReplayManager as Qe, Screenshot as k, SelectionBoxOverlay as $e, SessionBreaks as et, SessionShading as tt, SignalMarkerManager as nt, SpreadIndicator as rt, StepLineRenderer as it, StreamManager as at, SymbolSeriesStore as ot, TimeAxis as st, TradeZoneManager as ct, TradingManager as lt, TradingRenderer as ut, UndoRedoManager as dt, Viewport as ft, VolumeCandleRenderer as pt, VolumeProfileRenderer as mt, VolumeRenderer as ht, Watermark as gt, ZoomHandler as _t, barTimeStepMs as vt, findDominantSwing as yt, gpuContextsLeft as bt, isRegularSession as xt, loadWebGL as St, mergeSessionHours as Ct, priceToY as wt, rangePresetStart as Tt, readAlertOptions as Et, registerBuiltInDrawingTools as Dt, registerBuiltInIndicators as A, servesTimeframe as j, sourceParam as M, timeToX as Ot, timestampToBarIndex as N, toHeikinAshi as kt, toKagi as At, toLineBreak as jt, toPointAndFigure as Mt, toRangeBars as Nt, toRenko as P, whenGpuContextFree as Pt, withResampling as Ft, xToBarIndex as It, xToTime as F, yToPrice as Lt } from "@tradecanvas/core";
3
3
  //#region src/regularHours.ts
4
- var It = 864e5, Lt = 10;
5
- function Rt(e, t) {
4
+ var Rt = 864e5, zt = 10;
5
+ function Bt(e, t) {
6
6
  let n = e?.timezone;
7
- if (!n || !p(n) || t.length < 2) return null;
7
+ if (!n || !m(n) || t.length < 2) return null;
8
8
  let r = (e?.sessions ?? []).flatMap((e) => {
9
9
  let t = S(e.start), n = S(e.end);
10
10
  return t === null || n === null ? [] : [{
@@ -13,35 +13,35 @@ function Rt(e, t) {
13
13
  }];
14
14
  });
15
15
  if (r.length === 0) return null;
16
- let i = Infinity;
17
- for (let e = Math.max(1, t.length - Lt); e < t.length; e++) {
18
- let n = h(t[e].time) - h(t[e - 1].time);
19
- n > 0 && n < i && (i = n);
16
+ let i = c(t), a = Infinity;
17
+ for (let e = Math.max(1, t.length - zt); e < t.length; e++) {
18
+ let n = (t[e].time - t[e - 1].time) * i;
19
+ n > 0 && n < a && (a = n);
20
20
  }
21
- if (!(i < It)) return null;
22
- let a = {
21
+ if (!(a < Rt)) return null;
22
+ let o = {
23
23
  timeZone: n,
24
24
  windows: r,
25
25
  startMinute: r[0].startMinute,
26
26
  endMinute: r[r.length - 1].endMinute
27
27
  };
28
- return (e) => yt(h(e), a);
28
+ return (e) => xt(e * i, o);
29
29
  }
30
30
  //#endregion
31
31
  //#region src/chartA11y.ts
32
- var zt = {
32
+ var Vt = {
33
33
  role: "chart",
34
34
  summary: "{what}. Last price {close}.",
35
35
  empty: "Chart, no data.",
36
36
  view: "Showing {count} bars, {from} to {to}. High {high}, low {low}.",
37
37
  bar: "{time}: open {open}, high {high}, low {low}, close {close}, volume {volume}.",
38
38
  keys: "Arrow keys scroll and zoom, Home and End go to the start and the end. Comma and period read the bars one at a time."
39
- }, I = (e, t) => e.replace(/\{(\w+)\}/g, (e, n) => n in t ? String(t[n]) : e), Bt = [
39
+ }, I = (e, t) => e.replace(/\{(\w+)\}/g, (e, n) => n in t ? String(t[n]) : e), Ht = [
40
40
  "role",
41
41
  "aria-roledescription",
42
42
  "aria-label",
43
43
  "aria-describedby"
44
- ], Vt = 400, Ht = 1e3, Ut = class {
44
+ ], Ut = 400, Wt = 1e3, Gt = class {
45
45
  live;
46
46
  help;
47
47
  labels;
@@ -55,20 +55,20 @@ var zt = {
55
55
  };
56
56
  constructor(e, t, n = {}) {
57
57
  this.container = e, this.source = t, this.labels = {
58
- ...zt,
58
+ ...Vt,
59
59
  ...n
60
60
  };
61
- for (let t of Bt) this.before.set(t, e.getAttribute(t));
62
- e.setAttribute("role", "application"), this.help = Wt("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 = Wt("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 Ht) this.before.set(t, e.getAttribute(t));
62
+ e.setAttribute("role", "application"), this.help = Kt("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 = Kt("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
- ...zt,
66
+ ...Vt,
67
67
  ...e
68
68
  }, this.applyLabels();
69
69
  }
70
70
  refresh(e = !1) {
71
- let t = Ht - (Date.now() - this.summaryAt);
71
+ let t = Wt - (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 zt = {
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
- }, Vt);
83
+ }, Ut);
84
84
  }
85
85
  readBar(e) {
86
86
  let t = this.source.bars();
@@ -99,7 +99,7 @@ var zt = {
99
99
  high: a(i.high),
100
100
  low: a(i.low),
101
101
  close: a(i.close),
102
- volume: Gt(i.volume ?? 0)
102
+ volume: qt(i.volume ?? 0)
103
103
  }));
104
104
  }
105
105
  destroy() {
@@ -140,7 +140,7 @@ var zt = {
140
140
  this.live.textContent = e;
141
141
  }
142
142
  };
143
- function Wt(e, t) {
143
+ function Kt(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 Wt(e, t) {
154
154
  border: "0"
155
155
  }), n;
156
156
  }
157
- function Gt(e) {
157
+ function qt(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 Kt(e, t, n, r) {
162
+ function Jt(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,33 +169,33 @@ function Kt(e, t, n, r) {
169
169
  }
170
170
  //#endregion
171
171
  //#region src/charts/ChartTypeStrategy.ts
172
- function qt(e) {
172
+ function Yt(e) {
173
173
  switch (e) {
174
174
  case "candlestick":
175
175
  case "heikinAshi":
176
176
  case "lineBreak":
177
- case "rangeBars": return new ge();
178
- case "line": return new Le();
179
- case "area": return new de();
180
- case "bar": return new me();
181
- case "hollowCandle": return new Ne();
182
- case "baseline": return new he();
183
- case "renko": return new Ye();
184
- case "kagi": return new Fe();
177
+ case "rangeBars": return new ve();
178
+ case "line": return new ze();
179
+ case "area": return new pe();
180
+ case "bar": return new ge();
181
+ case "hollowCandle": return new Fe();
182
+ case "baseline": return new _e();
183
+ case "renko": return new Ze();
184
+ case "kagi": return new Le();
185
185
  case "pointAndFigure": return new D();
186
- case "volumeCandles": return new dt();
187
- case "equivolume": return new ke();
188
- case "hlcArea": return new Me();
189
- case "stepLine": return new nt();
190
- case "lineWithMarkers": return new Re();
186
+ case "volumeCandles": return new pt();
187
+ case "equivolume": return new je();
188
+ case "hlcArea": return new Pe();
189
+ case "stepLine": return new it();
190
+ case "lineWithMarkers": return new Be();
191
191
  case "hiLo": return new T();
192
- default: return new ge();
192
+ default: return new ve();
193
193
  }
194
194
  }
195
- function Jt(e, t, n = {}) {
195
+ function Xt(e, t, n = {}) {
196
196
  if (t.length === 0) return t;
197
197
  switch (e) {
198
- case "heikinAshi": return Dt(t);
198
+ case "heikinAshi": return kt(t);
199
199
  case "renko": {
200
200
  let e = n.renko?.boxSize;
201
201
  return typeof e == "number" ? P(t, { brickSize: e }) : P(t, {
@@ -204,17 +204,17 @@ function Jt(e, t, n = {}) {
204
204
  atrPeriod: n.renko?.atrPeriod ?? 14
205
205
  });
206
206
  }
207
- case "lineBreak": return kt(t, n.lineBreak?.lines ?? 3);
208
- case "kagi": return Ot(t, n.kagi?.reversal ?? 4, n.kagi?.reversalType ?? "percent");
209
- case "pointAndFigure": return At(t, Xt(t, n), n.pointAndFigure?.reversal ?? 3);
207
+ case "lineBreak": return jt(t, n.lineBreak?.lines ?? 3);
208
+ case "kagi": return At(t, n.kagi?.reversal ?? 4, n.kagi?.reversalType ?? "percent");
209
+ case "pointAndFigure": return Mt(t, Qt(t, n), n.pointAndFigure?.reversal ?? 3);
210
210
  case "rangeBars": {
211
211
  let e = n.rangeBars?.range;
212
- return jt(t, { rangeSize: typeof e == "number" ? e : Zt(t) * .005 });
212
+ return Nt(t, { rangeSize: typeof e == "number" ? e : $t(t) * .005 });
213
213
  }
214
214
  default: return t;
215
215
  }
216
216
  }
217
- function Yt(e) {
217
+ function Zt(e) {
218
218
  switch (e) {
219
219
  case "heikinAshi":
220
220
  case "renko":
@@ -226,29 +226,29 @@ function Yt(e) {
226
226
  }
227
227
  }
228
228
  function L(e) {
229
- return e !== "heikinAshi" && Yt(e);
229
+ return e !== "heikinAshi" && Zt(e);
230
230
  }
231
- function Xt(e, t = {}) {
231
+ function Qt(e, t = {}) {
232
232
  let n = t.pointAndFigure?.boxSize;
233
- return typeof n == "number" ? n : Zt(e) * .01;
233
+ return typeof n == "number" ? n : $t(e) * .01;
234
234
  }
235
- function Zt(e) {
235
+ function $t(e) {
236
236
  let t = 0;
237
237
  for (let n of e) t += n.close;
238
238
  return t / e.length;
239
239
  }
240
- function Qt(e, t) {
240
+ function en(e, t) {
241
241
  let n = t?.(e);
242
- return n ? n.createRenderer() : qt(e);
242
+ return n ? n.createRenderer() : Yt(e);
243
243
  }
244
- function $t(e, t, n, r) {
244
+ function tn(e, t, n, r) {
245
245
  if (t.length === 0) return t;
246
246
  let i = n?.(e);
247
- return i?.transform ? i.transform(t) : Jt(e, t, r);
247
+ return i?.transform ? i.transform(t) : Xt(e, t, r);
248
248
  }
249
249
  //#endregion
250
250
  //#region src/state/AutoSaveScheduler.ts
251
- var en = class {
251
+ var nn = class {
252
252
  timer = null;
253
253
  delayMs = 0;
254
254
  key = null;
@@ -283,7 +283,7 @@ function R(e) {
283
283
  let { open: t, high: n, low: r, close: i } = e;
284
284
  return !(!isFinite(t) || !isFinite(n) || !isFinite(r) || !isFinite(i) || t < 0 || n < 0 || r < 0 || i < 0 || n < r || e.volume !== void 0 && (!isFinite(e.volume) || e.volume < 0));
285
285
  }
286
- function tn(e) {
286
+ function rn(e) {
287
287
  return e.volume !== void 0 && e.high >= e.open && e.high >= e.close && e.low <= e.open && e.low <= e.close;
288
288
  }
289
289
  function z(e) {
@@ -296,6 +296,18 @@ function z(e) {
296
296
  }
297
297
  var B = class {
298
298
  data = [];
299
+ inSeriesUnit(e) {
300
+ if (this.data.length === 0) return e;
301
+ let t = g(e);
302
+ return c(this.data) === 1 ? t : t / 1e3;
303
+ }
304
+ withSeriesTime(e) {
305
+ let t = this.inSeriesUnit(e.time);
306
+ return t === e.time ? e : {
307
+ ...e,
308
+ time: t
309
+ };
310
+ }
299
311
  getData() {
300
312
  return this.data;
301
313
  }
@@ -303,15 +315,16 @@ var B = class {
303
315
  let t = [];
304
316
  for (let n = 0; n < e.length; n++) {
305
317
  let r = e[n];
306
- R(r) && t.push(tn(r) ? r : z(r));
318
+ R(r) && t.push(rn(r) ? r : z(r));
307
319
  }
308
320
  this.data = t;
309
321
  }
310
322
  prependBars(e) {
311
323
  let t = this.data.length > 0 ? this.data[0].time : Infinity, n = [];
312
324
  for (let r = 0; r < e.length; r++) {
313
- let i = e[r];
314
- !R(i) || i.time >= t || n.push(tn(i) ? i : z(i));
325
+ if (!R(e[r])) continue;
326
+ let i = this.withSeriesTime(e[r]);
327
+ i.time >= t || n.push(rn(i) ? i : z(i));
315
328
  }
316
329
  if (n.length === 0) return 0;
317
330
  n.sort((e, t) => e.time - t.time);
@@ -320,11 +333,11 @@ var B = class {
320
333
  return n.length = r, this.data = n.concat(this.data), r;
321
334
  }
322
335
  appendBar(e) {
323
- R(e) && this.data.push(z(e));
336
+ R(e) && this.data.push(z(this.withSeriesTime(e)));
324
337
  }
325
338
  updateLastBar(e) {
326
339
  if (!R(e)) return;
327
- let t = z(e);
340
+ let t = z(this.withSeriesTime(e));
328
341
  if (this.data.length === 0) {
329
342
  this.data.push(t);
330
343
  return;
@@ -332,7 +345,7 @@ var B = class {
332
345
  this.data[this.data.length - 1] = t;
333
346
  }
334
347
  updateLastBarFromTick(e) {
335
- this.data.length !== 0 && (!isFinite(e.price) || e.price < 0 || e.volume !== void 0 && (!isFinite(e.volume) || e.volume < 0) || (this.data[this.data.length - 1] = m(this.data[this.data.length - 1], e)));
348
+ this.data.length !== 0 && (!isFinite(e.price) || e.price < 0 || e.volume !== void 0 && (!isFinite(e.volume) || e.volume < 0) || (this.data[this.data.length - 1] = h(this.data[this.data.length - 1], this.withSeriesTime(e))));
336
349
  }
337
350
  getLength() {
338
351
  return this.data.length;
@@ -340,7 +353,7 @@ var B = class {
340
353
  clear() {
341
354
  this.data = [];
342
355
  }
343
- }, nn = 5e3, rn = 6e4, an = 500, on = class {
356
+ }, an = 5e3, on = 6e4, sn = 500, cn = class {
344
357
  loader = null;
345
358
  pageSize = 500;
346
359
  loading = !1;
@@ -381,7 +394,7 @@ var B = class {
381
394
  try {
382
395
  r = await e(t, this.pageSize);
383
396
  } catch (e) {
384
- return n === this.seq ? (this.loading = !1, this.failures++, this.retryAt = this.now() + Math.min(rn, nn * 2 ** (this.failures - 1)), this.emit({
397
+ return n === this.seq ? (this.loading = !1, this.failures++, this.retryAt = this.now() + Math.min(on, an * 2 ** (this.failures - 1)), this.emit({
385
398
  state: "error",
386
399
  count: 0,
387
400
  error: e instanceof Error ? e.message : String(e)
@@ -411,7 +424,7 @@ var B = class {
411
424
  now() {
412
425
  return this.host.now ? this.host.now() : Date.now();
413
426
  }
414
- }, sn = class t {
427
+ }, ln = class t {
415
428
  base;
416
429
  shape = null;
417
430
  chartType = "candlestick";
@@ -428,7 +441,7 @@ var B = class {
428
441
  return i;
429
442
  }
430
443
  getTheme() {
431
- return this.effective ??= te(this.base, this.chartType, this.merged()), this.effective;
444
+ return this.effective ??= re(this.base, this.chartType, this.merged()), this.effective;
432
445
  }
433
446
  getBaseTheme() {
434
447
  return this.base;
@@ -480,7 +493,7 @@ var B = class {
480
493
  return JSON.stringify(e) === JSON.stringify(this.getUserOverrides()) ? !1 : (this.user = new Map(Object.entries(e).map(([e, t]) => [e, { ...t }])), this.effective = null, !0);
481
494
  }
482
495
  getStyleValue(e) {
483
- return c(this.base, this.merged(), e, this.chartType);
496
+ return l(this.base, this.merged(), e, this.chartType);
484
497
  }
485
498
  layer(e) {
486
499
  return e === "host" ? this.host : this.user.get(this.base.name) ?? {};
@@ -497,7 +510,7 @@ var B = class {
497
510
  };
498
511
  //#endregion
499
512
  //#region src/style/styleOptions.ts
500
- function cn(e, t) {
513
+ function un(e, t) {
501
514
  return t ? {
502
515
  ...t.visible === void 0 ? {} : { [`crosshair.${e}.visible`]: t.visible },
503
516
  ...t.color === void 0 ? {} : { [`crosshair.${e}.color`]: t.color },
@@ -505,22 +518,22 @@ function cn(e, t) {
505
518
  ...t.width === void 0 ? {} : { [`crosshair.${e}.width`]: t.width }
506
519
  } : {};
507
520
  }
508
- function ln(e) {
521
+ function dn(e) {
509
522
  let { grid: t, crosshair: n } = e, r = n?.vLine?.labelBackground ?? n?.hLine?.labelBackground;
510
523
  return {
511
524
  ...t?.hLineColor === void 0 ? {} : { "grid.horizontal.color": t.hLineColor },
512
525
  ...t?.hLineStyle === void 0 ? {} : { "grid.horizontal.style": t.hLineStyle },
513
526
  ...t?.vLineColor === void 0 ? {} : { "grid.vertical.color": t.vLineColor },
514
527
  ...t?.vLineStyle === void 0 ? {} : { "grid.vertical.style": t.vLineStyle },
515
- ...cn("horizontal", n?.hLine),
516
- ...cn("vertical", n?.vLine),
528
+ ...un("horizontal", n?.hLine),
529
+ ...un("vertical", n?.vLine),
517
530
  ...r === void 0 ? {} : { "crosshair.labelBackground": r },
518
531
  ...e.overrides
519
532
  };
520
533
  }
521
534
  //#endregion
522
535
  //#region src/layout/LayoutManager.ts
523
- var un = 200, dn = 80, V = (e) => e.position === "top" || e.position === "bottom", fn = class {
536
+ var fn = 200, pn = 80, V = (e) => e.position === "top" || e.position === "bottom", mn = class {
524
537
  panels = [];
525
538
  containerWidth = 0;
526
539
  containerHeight = 0;
@@ -536,8 +549,8 @@ var un = 200, dn = 80, V = (e) => e.position === "top" || e.position === "bottom
536
549
  this.panels.push({
537
550
  id: e,
538
551
  position: n,
539
- size: r ?? (a ? un : t),
540
- minSize: a ? dn : i,
552
+ size: r ?? (a ? fn : t),
553
+ minSize: a ? pn : i,
541
554
  content: {
542
555
  type: "indicator",
543
556
  indicatorInstanceId: e
@@ -606,7 +619,7 @@ var un = 200, dn = 80, V = (e) => e.position === "top" || e.position === "bottom
606
619
  let r = this.panels.find((t) => t.id === e);
607
620
  if (r) {
608
621
  let a = r.position === "left" || r.position === "right", o = n === "left" || n === "right";
609
- r.position = n, a !== o && (r.size = o ? un : t, r.minSize = o ? dn : i), o && (r.collapsed = void 0, this.maximized === e && (this.maximized = null));
622
+ r.position = n, a !== o && (r.size = o ? fn : t, r.minSize = o ? pn : i), o && (r.collapsed = void 0, this.maximized === e && (this.maximized = null));
610
623
  }
611
624
  }
612
625
  setPanelSize(e, t) {
@@ -722,24 +735,24 @@ var un = 200, dn = 80, V = (e) => e.position === "top" || e.position === "bottom
722
735
  getMainChartRect() {
723
736
  return this.resolve().mainChartRect;
724
737
  }
725
- }, pn = 14, mn = 14, hn = 22, gn = 4;
726
- function _n(e) {
727
- let { min: t, max: n, lastPrice: r, locale: i, fontFamily: o, fontSizeSmall: c, measure: l } = e, d = e.tagPrecision ?? s(t, n), f = d, p = r === null ? [t, n] : [
738
+ }, hn = 14, gn = 14, _n = 22, vn = 4;
739
+ function yn(e) {
740
+ let { min: t, max: n, lastPrice: r, locale: i, fontFamily: o, fontSizeSmall: c, measure: l } = e, u = e.tagPrecision ?? s(t, n), f = u, p = r === null ? [t, n] : [
728
741
  t,
729
742
  n,
730
743
  r
731
744
  ], m = a;
732
745
  for (let t of p) {
733
746
  if (!Number.isFinite(t)) continue;
734
- let n = e.scaleLabel ? e.scaleLabel(t) : e.format ? e.format(t) : u(t, d, i), r = e.format ? n : u(t, f, i);
735
- m = Math.max(m, l(n, `500 ${c}px ${o}`) + pn, l(r, `bold 11px ${o}`) + mn, l(r, `600 ${c}px ${o}`) + hn);
747
+ let n = e.scaleLabel ? e.scaleLabel(t) : e.format ? e.format(t) : d(t, u, i), r = e.format ? n : d(t, f, i);
748
+ m = Math.max(m, l(n, `500 ${c}px ${o}`) + hn, l(r, `bold 11px ${o}`) + gn, l(r, `600 ${c}px ${o}`) + _n);
736
749
  }
737
- return m <= a ? a : Math.ceil(m / gn) * gn;
750
+ return m <= a ? a : Math.ceil(m / vn) * vn;
738
751
  }
739
- function vn(e, t) {
752
+ function bn(e, t) {
740
753
  return t > e || t <= e - 12 ? t : e;
741
754
  }
742
- var yn = class {
755
+ var xn = class {
743
756
  netY = 0;
744
757
  travelX = 0;
745
758
  engaged = !1;
@@ -755,8 +768,8 @@ var yn = class {
755
768
  }
756
769
  return this.engaged;
757
770
  }
758
- }, bn = 1;
759
- function xn(e, t) {
771
+ }, Sn = 1;
772
+ function Cn(e, t) {
760
773
  return e.filter((e) => e.enabled !== !1 && (e.descriptor.layer ?? "overlay") === t);
761
774
  }
762
775
  function H(e) {
@@ -770,24 +783,24 @@ function H(e) {
770
783
  //#endregion
771
784
  //#region src/plugins/registry.ts
772
785
  var U = /* @__PURE__ */ new Map();
773
- function Sn(e) {
786
+ function wn(e) {
774
787
  U.set(H(e), e);
775
788
  }
776
- function Cn(e) {
789
+ function Tn(e) {
777
790
  return U.delete(e);
778
791
  }
779
- function wn() {
792
+ function En() {
780
793
  return [...U.values()];
781
794
  }
782
- function Tn() {
795
+ function Dn() {
783
796
  U.clear();
784
797
  }
785
798
  //#endregion
786
799
  //#region src/plugins/PluginManager.ts
787
- var En = class {
800
+ var On = class {
788
801
  plugins = /* @__PURE__ */ new Map();
789
802
  constructor(e, t = {}) {
790
- if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of wn()) this.add(e);
803
+ if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of En()) this.add(e);
791
804
  for (let e of t.plugins ?? []) this.add(e);
792
805
  }
793
806
  register(e) {
@@ -817,15 +830,15 @@ var En = class {
817
830
  add(e) {
818
831
  this.plugins.set(H(e), e), e.kind === "indicator" && this.indicatorEngine.register(e.plugin);
819
832
  }
820
- }, Dn = {
833
+ }, kn = {
821
834
  orderPlace: (e, t) => e.placeOrder(t),
822
835
  orderModify: (e, t) => e.modifyOrder(t),
823
836
  orderCancel: (e, t) => e.cancelOrder(t),
824
837
  positionModify: (e, t) => e.modifyPosition(t),
825
838
  positionClose: (e, t) => e.closePosition(t),
826
- positionReverse: (e, t, n) => On(e, t, n)
839
+ positionReverse: (e, t, n) => An(e, t, n)
827
840
  };
828
- async function On(e, t, n) {
841
+ async function An(e, t, n) {
829
842
  let { reversing: r } = n;
830
843
  if (!r.has(t.positionId)) {
831
844
  r.add(t.positionId);
@@ -854,7 +867,7 @@ async function On(e, t, n) {
854
867
  }
855
868
  }
856
869
  }
857
- function kn(e, t) {
870
+ function jn(e, t) {
858
871
  let n = [], r = null, i = {
859
872
  positions: () => r ?? t.getPositions?.() ?? [],
860
873
  reversing: /* @__PURE__ */ new Set()
@@ -864,8 +877,8 @@ function kn(e, t) {
864
877
  e.data && t.onFill?.(e.data);
865
878
  };
866
879
  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));
867
- for (let r of Object.keys(Dn)) {
868
- let a = Dn[r], o = t.onIntent(r, (n) => {
880
+ for (let r of Object.keys(kn)) {
881
+ let a = kn[r], o = t.onIntent(r, (n) => {
869
882
  Promise.resolve(a(e, n, i)).catch((e) => t.onError({
870
883
  message: `Execution command failed: ${r}`,
871
884
  cause: e
@@ -879,16 +892,16 @@ function kn(e, t) {
879
892
  }
880
893
  //#endregion
881
894
  //#region src/Chart.ts
882
- var An = {
895
+ var Mn = {
883
896
  min: 0,
884
897
  max: 100
885
- }, jn = 0xe8d4a51000, Mn = "exchange";
886
- function Nn(e) {
887
- if (typeof e == "string" && e !== "exchange" && !p(e)) throw RangeError(`Unknown time zone: ${e}`);
898
+ }, Nn = "exchange";
899
+ function Pn(e) {
900
+ if (typeof e == "string" && e !== "exchange" && !m(e)) throw RangeError(`Unknown time zone: ${e}`);
888
901
  if (typeof e == "number" && !Number.isFinite(e)) throw RangeError(`Invalid UTC offset: ${e}`);
889
902
  }
890
- var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine", "crossLine"]), Bn = new Set(["verticalLine", "crossLine"]), Vn = class {
891
- static version = "1.24.0";
903
+ var Fn = 2, In = .08, Ln = 800, Rn = 20, zn = 8, Bn = new Set(["horizontalLine", "crossLine"]), Vn = new Set(["verticalLine", "crossLine"]), Hn = class {
904
+ static version = "1.26.0";
892
905
  engine;
893
906
  viewport;
894
907
  dataManager;
@@ -926,14 +939,14 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
926
939
  indicatorHistoryDepth = 0;
927
940
  removedDrawingAlerts = /* @__PURE__ */ new Map();
928
941
  zoomAreaMode = !1;
929
- priceAxisAddButton = new Ke();
942
+ priceAxisAddButton = new Je();
930
943
  displayTz = null;
931
944
  timezoneSetting = null;
932
945
  symbolInfo = null;
933
946
  symbolInfoSeq = 0;
934
947
  sessionBreaks;
935
948
  sessionShading;
936
- hostSessionHours = { ...Te };
949
+ hostSessionHours = { ...De };
937
950
  compareRenderer;
938
951
  countdownInterval = null;
939
952
  volumeRenderer;
@@ -946,7 +959,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
946
959
  signalMarkerManager;
947
960
  tradeZoneManager;
948
961
  measureOverlay;
949
- selectionBoxOverlay = new Ze();
962
+ selectionBoxOverlay = new $e();
950
963
  replayManager;
951
964
  replayBarUnsub = null;
952
965
  replaySeeking = !1;
@@ -956,7 +969,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
956
969
  replayRevealMarks = !0;
957
970
  replayOffset = 0;
958
971
  undoRedoManager;
959
- autoSaveScheduler = new en((e) => this.saveState(e));
972
+ autoSaveScheduler = new nn((e) => this.saveState(e));
960
973
  animator;
961
974
  crosshairTooltip;
962
975
  pinnedTooltip;
@@ -968,8 +981,8 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
968
981
  disposed = !1;
969
982
  chartTypeOptions = {};
970
983
  mainSeriesVisible = !0;
971
- priceLines = new qe();
972
- symbolSeries = new it();
984
+ priceLines = new Ye();
985
+ symbolSeries = new ot();
973
986
  extendedHours = !0;
974
987
  replayRestarting = !1;
975
988
  fullSeries = null;
@@ -1007,7 +1020,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
1007
1020
  snapshotKey = null;
1008
1021
  historyCheckQueued = !1;
1009
1022
  constructor(e, t) {
1010
- t.timeZone != null && Nn(t.timeZone), this.container = e, this.options = {
1023
+ t.timeZone != null && Pn(t.timeZone), this.container = e, this.options = {
1011
1024
  ...t,
1012
1025
  chartType: t.chartType ?? "candlestick"
1013
1026
  }, this.numberLocale = t.numberLocale ?? "en-US", this.defaultAutoScale = t.autoScale !== !1;
@@ -1045,15 +1058,15 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
1045
1058
  logScale: n.logScale ?? !0,
1046
1059
  timeframes: n.timeframes ?? [],
1047
1060
  defaultTimeframeFavorites: n.defaultTimeframeFavorites ?? []
1048
- }, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", e.style.userSelect = "none", e.style.webkitUserSelect = "none", this.dataManager = new B(), this.history = new on({
1061
+ }, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", e.style.userSelect = "none", e.style.webkitUserSelect = "none", this.dataManager = new B(), this.history = new cn({
1049
1062
  oldestTime: () => this.dataManager.getData()[0]?.time ?? null,
1050
1063
  prepend: (e) => this.prependBars(e),
1051
1064
  emit: (e) => this.eventBus.emit("historyLoad", e)
1052
- }), this.themeManager = new sn(t.theme), this.themeManager.setChartType(this.options.chartType ?? "candlestick"), this.applyStyle(ln(t), "host", !1), this.layoutManager = new fn(), this.indicatorEngine = new E(), this.pluginManager = new En(this.indicatorEngine, { plugins: t.plugins }), this.eventBus = new Ae(), A(this.indicatorEngine), this.indicatorEngine.register(new ye(this.symbolSeries)), this.indicatorEngine.register(new tt(this.symbolSeries)), this.indicatorEngine.register(new be(this.symbolSeries)), this.indicatorEngine.register(new xe(this.symbolSeries)), this.drawingManager = new De(), Tt(this.drawingManager), this.drawingRenderer = new Oe(this.drawingManager), this.drawingManager.setRequestRender(() => {
1065
+ }), this.themeManager = new ln(t.theme), this.themeManager.setChartType(this.options.chartType ?? "candlestick"), this.applyStyle(dn(t), "host", !1), this.layoutManager = new mn(), this.indicatorEngine = new E(), this.pluginManager = new On(this.indicatorEngine, { plugins: t.plugins }), this.eventBus = new Me(), A(this.indicatorEngine), this.indicatorEngine.register(new xe(this.symbolSeries)), this.indicatorEngine.register(new rt(this.symbolSeries)), this.indicatorEngine.register(new Se(this.symbolSeries)), this.indicatorEngine.register(new Ce(this.symbolSeries)), this.drawingManager = new ke(), Dt(this.drawingManager), this.drawingRenderer = new Ae(this.drawingManager), this.drawingManager.setRequestRender(() => {
1053
1066
  this.syncRenderContext(), this.engine.requestRender(r.Overlay), this.scheduleAutoSave();
1054
1067
  }), this.drawingManager.setEventCallback((e, t) => {
1055
1068
  this.followDrawingAlerts(e, t?.id), this.eventBus.emit(e, t), (e === "drawingCreate" || e === "drawingUpdate" || e === "drawingRemove") && this.announceStateChange();
1056
- }), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new lt();
1069
+ }), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new dt();
1057
1070
  let i = "";
1058
1071
  this.undoRedoManager.setOnChange(() => {
1059
1072
  let { canUndo: e, canRedo: t } = this.undoRedoManager.getState(), n = `${e}|${t}`;
@@ -1066,42 +1079,43 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
1066
1079
  primary: e[0] ?? null
1067
1080
  })), this.drawingManager.setForeignHistory((e, t) => {
1068
1081
  e.type === "custom" ? e.custom?.[t]() : this.applyIndicatorStep(e, t);
1069
- }), this.drawingManager.setDataGetter(() => this.dataManager.getData()), this.drawingManager.setDisplayDataGetter(() => this.getDisplayData()), t.crosshair?.mode === "magnet" && this.features.drawingMagnet && this.drawingManager.setMagnetMode("magnet"), this.tradingManager = new st({
1082
+ }), 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 lt({
1070
1083
  enabled: this.features.trading,
1071
1084
  contextMenu: { enabled: this.features.tradingContextMenu }
1072
- }), this.tradingRenderer = new ct(this.tradingManager), this.tradingManager.setContainer(e), this.tradingManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradingManager.setEventCallback((e, t) => {
1085
+ }), this.tradingRenderer = new ut(this.tradingManager), this.tradingManager.setContainer(e), this.tradingManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradingManager.setEventCallback((e, t) => {
1073
1086
  this.eventBus.emit(e, t);
1074
- }), this.engine = new Je(e);
1087
+ }), this.engine = new Xe(e);
1075
1088
  let a = this.engine.dprManager.getContainerSize();
1076
- if (this.viewport = new ut(a.width, a.height, t.minBarSpacing ?? 2, t.maxBarSpacing ?? 30, t.rightMargin ?? 5), this.viewport.setPanLimits({
1089
+ if (this.viewport = new ft(a.width, a.height, t.minBarSpacing ?? 2, t.maxBarSpacing ?? 30, t.rightMargin ?? 5), this.viewport.setPanLimits({
1077
1090
  freePan: t.freePan ?? !0,
1078
1091
  minVisibleBars: t.panLimits?.minVisibleBars ?? 3
1079
1092
  }), this.layoutManager.resize(a.width, a.height), this.engine.onContainerResize = (e) => {
1080
1093
  if (e.width <= 0 || e.height <= 0) return;
1081
1094
  let t = this.viewport.isAtEnd();
1082
1095
  this.viewport.resize(e.width, e.height), this.layoutManager.resize(e.width, e.height), this.updateViewportAndRender(t);
1083
- }, this.chartRenderer = this.createChartRenderer(this.options.chartType), this.gridRenderer = new je(), t.grid?.visible === !1 && this.gridRenderer.setVisible(!1), this.priceAxis = new O(), this.priceAxis.setLocale(this.numberLocale), this.leftPriceAxis.setLocale(this.numberLocale), this.timeAxis = new at(), this.crosshairHandler = new Se(), this.crosshairHandler.setLocale(this.numberLocale), this.applyTimeSpacing(), t.crosshair?.mode && this.crosshairHandler.setMode(t.crosshair.mode), this.crosshairHandler.setCallback((e, t) => {
1096
+ }, this.chartRenderer = this.createChartRenderer(this.options.chartType), this.gridRenderer = new Ne(), t.grid?.visible === !1 && this.gridRenderer.setVisible(!1), this.priceAxis = new O(), this.priceAxis.setLocale(this.numberLocale), this.leftPriceAxis.setLocale(this.numberLocale), this.timeAxis = new st(), this.timeAxis.setLocale(this.numberLocale), this.crosshairHandler = new we(), this.crosshairHandler.setLocale(this.numberLocale), this.applyTimeSpacing(), t.crosshair?.mode && this.crosshairHandler.setMode(t.crosshair.mode), this.crosshairHandler.setDataSource(() => this.crosshairSeries()), this.crosshairHandler.setCallback((e, t) => {
1084
1097
  if (e !== null && t) {
1085
- let n = this.dataManager.getData(), r = e < n.length ? n[e] : void 0;
1086
- this.chartLegend.setHoverBar(r ?? null);
1098
+ let n = this.crosshairSeries(), r = e >= 0 && e < n.length ? n[e] : void 0;
1099
+ this.chartLegend.setHoverBar(r ?? null, e > 0 ? n[e - 1] ?? null : null);
1087
1100
  let i = this.viewport.getState(), a = t.y >= i.chartRect.y && t.y <= i.chartRect.y + i.chartRect.height;
1088
1101
  r && a && this.features.crosshairTooltip ? this.crosshairTooltip.show(t, r, this.themeManager.getTheme(), this.cachedContainerSize(), {
1089
1102
  prevClose: e > 0 ? n[e - 1]?.close : void 0,
1090
1103
  priceRange: i.priceRange,
1091
1104
  plot: i.chartRect,
1092
- barStepMs: gt(n)
1105
+ barStepMs: vt(n),
1106
+ timeUnit: c(n)
1093
1107
  }) : this.crosshairTooltip.hide(), this.pinnedTooltip.isPinned() && this.pinnedTooltip.reposition(this.viewport.getState(), r ?? null, e, this.themeManager.getTheme()), this.eventBus.emit("crosshairMove", {
1094
1108
  point: t,
1095
1109
  bar: r,
1096
1110
  barIndex: e
1097
1111
  });
1098
1112
  } else this.crosshairTooltip.hide(), this.chartLegend.setHoverBar(null), this.eventBus.emit("crosshairLeave", {});
1099
- }), this.chartLegend = new _e(), this.chartLegend.setChartType(this.options.chartType), this.chartLegend.setLocale(this.numberLocale), this.watermark = new mt(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new pt(), this.volumeProfile = new ft(), this.marketProfile = new ze(), this.depthHeatmap = new Ee(), this.periodLevels = new Ue(), this.pivotMarkers = new Ge(), this.barCountdown = new pe(), this.barCountdown.setVisible(this.features.barCountdown), this.sessionBreaks = new Qe(), this.sessionBreaks.setLocale(this.numberLocale), this.sessionShading = new $e(), this.compareRenderer = new ve(), t.sessionBreaks ? this.sessionBreaks.setConfig({
1113
+ }), this.chartLegend = new ye(), this.chartLegend.setChartType(this.options.chartType), this.chartLegend.setLocale(this.numberLocale), this.watermark = new gt(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new ht(), this.volumeProfile = new mt(), this.marketProfile = new Ve(), this.depthHeatmap = new Oe(), this.periodLevels = new Ge(), this.pivotMarkers = new qe(), this.barCountdown = new he(), this.barCountdown.setVisible(this.features.barCountdown), this.sessionBreaks = new et(), this.sessionBreaks.setLocale(this.numberLocale), this.sessionShading = new tt(), this.compareRenderer = new be(), t.sessionBreaks ? this.sessionBreaks.setConfig({
1100
1114
  visible: t.sessionBreaks.visible ?? !0,
1101
1115
  color: t.sessionBreaks.color,
1102
1116
  lineStyle: t.sessionBreaks.lineStyle,
1103
1117
  lineWidth: t.sessionBreaks.lineWidth
1104
- }) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new ue(), this.crosshairTooltip = new Ce(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new We(), this.pinnedTooltip.create(e), t.priceFormat && this.applyPriceFormat(t.priceFormat), t.chartTypeOptions && (this.chartTypeOptions = b(t.chartTypeOptions)), t.highLowLines && this.priceLines.setHighLow(!0), t.shapes && this.themeManager.setShape(Wn(t.shapes)), this.priceLines.setPriceText((e) => this.formatPrice(e)), t.extendedHours === !1 && (this.extendedHours = !1), t.timeFormatter && this.applyTimeFormatter(t.timeFormatter), this.keyboardHandler = new Ie({
1118
+ }) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new fe(), this.crosshairTooltip = new Te(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new Ke(), this.pinnedTooltip.create(e), t.priceFormat && this.applyPriceFormat(t.priceFormat), t.chartTypeOptions && (this.chartTypeOptions = y(t.chartTypeOptions)), t.highLowLines && this.priceLines.setHighLow(!0), t.shapes && this.themeManager.setShape(Gn(t.shapes)), this.priceLines.setPriceText((e) => this.formatPrice(e)), t.extendedHours === !1 && (this.extendedHours = !1), t.timeFormatter && this.applyTimeFormatter(t.timeFormatter), this.keyboardHandler = new Re({
1105
1119
  scrollBars: (e) => {
1106
1120
  let t = this.viewport.getState().barWidth + this.viewport.getState().barSpacing;
1107
1121
  this.viewport.scrollBy(e * t), this.updateViewportAndRender();
@@ -1118,17 +1132,17 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
1118
1132
  },
1119
1133
  fitContent: () => this.fitContent()
1120
1134
  }), this.keyboardHandler.setEnabled(this.features.keyboard), t.a11y !== !1) {
1121
- this.a11y = new Ut(e, {
1135
+ this.a11y = new Gt(e, {
1122
1136
  symbol: () => this.currentSymbol || this.symbolInfo?.symbol || "",
1123
1137
  timeframe: () => this.streamTimeframe ?? "",
1124
1138
  chartType: () => this.options.chartType ?? "candlestick",
1125
1139
  bars: () => this.getDisplayData(),
1126
1140
  visibleRange: () => this.viewport.getState().visibleRange,
1127
1141
  formatPrice: (e) => this.formatPrice(e),
1128
- formatTime: (e) => se(this.numberLocale || "en-US", {
1142
+ formatTime: (e) => le(this.numberLocale || "en-US", {
1129
1143
  dateStyle: "medium",
1130
1144
  timeStyle: "short"
1131
- }, this.displayTz)(e > jn ? e : e * 1e3),
1145
+ }, this.displayTz)(e * c(this.getDisplayData())),
1132
1146
  showBar: (e) => this.setCrosshairTime(e)
1133
1147
  }, t.a11y?.labels);
1134
1148
  for (let e of [
@@ -1148,7 +1162,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
1148
1162
  }
1149
1163
  this.keyboardHandler.handleKey(e) && (e.preventDefault(), this.a11y?.viewMoved());
1150
1164
  }
1151
- }, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new we(), this.currentPriceLine.setLocale(this.numberLocale), this.priceAxis.setReservedPriceProvider(() => this.currentPriceLine.isVisible() ? this.currentPriceLine.getPrice() : null), this.alertManager = new le(), this.alertManager.setDrawingLevels((e) => this.drawingLevelsNow(e)), this.alertManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.alertManager.on("triggered", (e) => {
1165
+ }, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new Ee(), this.currentPriceLine.setLocale(this.numberLocale), this.priceAxis.setReservedPriceProvider(() => this.currentPriceLine.isVisible() ? this.currentPriceLine.getPrice() : null), this.alertManager = new de(), this.alertManager.setDrawingLevels((e) => this.drawingLevelsNow(e)), this.alertManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.alertManager.on("triggered", (e) => {
1152
1166
  this.eventBus.emit("alertTriggered", G(e)), this.eventBus.emit("dataUpdate", {
1153
1167
  alert: "triggered",
1154
1168
  alertId: e.id,
@@ -1163,7 +1177,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
1163
1177
  this.eventBus.emit("alertExpired", G(e));
1164
1178
  }), this.alertManager.on("updated", (e) => {
1165
1179
  this.eventBus.emit("alertUpdate", G(e));
1166
- }), this.signalMarkerManager = new et(), this.signalMarkerManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.signalMarkerManager.setDataGetter(() => this.dataManager.getData()), this.signalMarkerManager.on("added", (e) => {
1180
+ }), this.signalMarkerManager = new nt(), this.signalMarkerManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.signalMarkerManager.setDataGetter(() => this.dataManager.getData()), this.signalMarkerManager.on("added", (e) => {
1167
1181
  this.eventBus.emit("signalMarkerAdd", {
1168
1182
  id: e.id,
1169
1183
  source: e.source,
@@ -1171,14 +1185,14 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
1171
1185
  });
1172
1186
  }), this.signalMarkerManager.on("removed", (e) => {
1173
1187
  this.eventBus.emit("signalMarkerRemove", { id: e });
1174
- }), this.tradeZoneManager = new ot(), this.tradeZoneManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradeZoneManager.setDataGetter(() => this.dataManager.getData()), this.tradeZoneManager.on("added", (e) => {
1188
+ }), this.tradeZoneManager = new ct(), this.tradeZoneManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradeZoneManager.setDataGetter(() => this.dataManager.getData()), this.tradeZoneManager.on("added", (e) => {
1175
1189
  this.eventBus.emit("tradeZoneAdd", {
1176
1190
  id: e.id,
1177
1191
  direction: e.direction
1178
1192
  });
1179
1193
  }), this.tradeZoneManager.on("removed", (e) => {
1180
1194
  this.eventBus.emit("tradeZoneRemove", { id: e });
1181
- }), this.replayManager = new Xe(), this.replayManager.on("complete", () => {
1195
+ }), this.replayManager = new Qe(), this.replayManager.on("complete", () => {
1182
1196
  let e = this.getReplayBarIndex(), t = this.replayCoarse?.[e];
1183
1197
  t && this.eventBus.emit("replayComplete", {
1184
1198
  barIndex: e,
@@ -1186,9 +1200,9 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
1186
1200
  });
1187
1201
  }), this.replayManager.on("stateChange", (e) => {
1188
1202
  this.replayRestarting || this.eventBus.emit("replayState", { state: e });
1189
- }), this.measureOverlay = new Be(), this.interactionManager = new Pe(e), this.features.panning) {
1190
- let e = new yn();
1191
- this.interactionManager.setPanHandler(new Ve((t, n) => {
1203
+ }), this.measureOverlay = new He(), this.interactionManager = new Ie(e), this.features.panning) {
1204
+ let e = new xn();
1205
+ this.interactionManager.setPanHandler(new Ue((t, n) => {
1192
1206
  t && this.viewport.scrollBy(t), e.step(t, n, this.options.autoScale !== !1) && n && (this.options.autoScale = !1, this.viewport.panPriceRange(n)), this.updateViewportAndRender();
1193
1207
  }, () => e.reset()));
1194
1208
  }
@@ -1200,10 +1214,10 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
1200
1214
  scales: !this.indicatorEngine.hasLeftScaleOverlays()
1201
1215
  }
1202
1216
  })), this.features.zooming) {
1203
- this.interactionManager.setZoomHandler(new ht((e, t) => {
1217
+ this.interactionManager.setZoomHandler(new _t((e, t) => {
1204
1218
  this.viewport.zoom(e, t - this.viewport.getState().chartRect.x), this.updateViewportAndRender();
1205
1219
  }));
1206
- let e = new fe((e) => {
1220
+ let e = new me((e) => {
1207
1221
  this.options.autoScale = !1, this.viewport.scalePriceRange(e), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents();
1208
1222
  }, (e) => {
1209
1223
  let t = this.viewport.getState().chartRect.width;
@@ -1223,7 +1237,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
1223
1237
  y: t.y
1224
1238
  });
1225
1239
  })), 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) => {
1226
- let t = Ft(e.y, this.viewport.getState());
1240
+ let t = Lt(e.y, this.viewport.getState());
1227
1241
  Number.isFinite(t) && this.eventBus.emit("priceAxisAdd", {
1228
1242
  price: t,
1229
1243
  x: e.x,
@@ -1233,15 +1247,15 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
1233
1247
  ...this.viewport.getState(),
1234
1248
  data: this.getDisplayData()
1235
1249
  })), this.features.alerts) {
1236
- let e = new ce(this.alertManager, () => this.viewport.getState());
1250
+ let e = new ue(this.alertManager, () => this.viewport.getState());
1237
1251
  this.interactionManager.setAlertDragHandler(e);
1238
1252
  }
1239
- let o = new He();
1253
+ let o = new We();
1240
1254
  o.configure(() => this.getResolvedLayout(), (e, t) => this.setPanelSize(e, t)), this.interactionManager.setPaneResizeHandler(o), this.interactionManager.setAltClickHandler((e) => {
1241
1255
  let t = this.getDisplayData();
1242
1256
  if (t.length === 0) return;
1243
1257
  let n = this.viewport.getState(), i = n.barWidth + n.barSpacing, a = Math.round((n.offset + e.x) / i);
1244
- a < 0 || a >= t.length || (this.pinnedTooltip.isPinned() && this.pinnedTooltip.getPinnedIndex() === a ? this.pinnedTooltip.unpin() : this.pinnedTooltip.pin(t[a], a, this.themeManager.getTheme()), this.pinnedTooltip.reposition(this.viewport.getState(), this.dataManager.getData()[a] ?? null, a, this.themeManager.getTheme()), this.engine.requestRender(r.Overlay));
1258
+ a < 0 || a >= t.length || (this.pinnedTooltip.isPinned() && this.pinnedTooltip.getPinnedIndex() === a ? this.pinnedTooltip.unpin() : this.pinnedTooltip.pin(t[a], a, this.themeManager.getTheme(), c(t)), this.pinnedTooltip.reposition(this.viewport.getState(), this.dataManager.getData()[a] ?? null, a, this.themeManager.getTheme()), this.engine.requestRender(r.Overlay));
1245
1259
  }), this.interactionManager.setSignalMarkerHitTest((e) => this.eventBus.hasListeners("signalMarkerHover") || this.eventBus.hasListeners("signalMarkerClick") ? this.signalMarkerManager.markerAt(e, this.viewport.getState()) : null, (e, t) => this.eventBus.emit("signalMarkerHover", {
1246
1260
  marker: e,
1247
1261
  x: t.x,
@@ -1260,7 +1274,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
1260
1274
  x: e.x,
1261
1275
  y: e.y
1262
1276
  }), t.length === 0) return;
1263
- let r = Pt(e.x, this.viewport.getState());
1277
+ let r = It(e.x, this.viewport.getState());
1264
1278
  r < 0 || r >= t.length || this.eventBus.emit("barClick", {
1265
1279
  bar: t[r],
1266
1280
  barIndex: r,
@@ -1300,7 +1314,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
1300
1314
  end: () => {
1301
1315
  let e = this.selectionBoxOverlay.end();
1302
1316
  if (e && this.zoomAreaMode) {
1303
- if (e.x1 - e.x0 < Rn) return;
1317
+ if (e.x1 - e.x0 < zn) return;
1304
1318
  this.zoomToBox(e), this.setZoomAreaMode(!1);
1305
1319
  return;
1306
1320
  }
@@ -1337,7 +1351,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
1337
1351
  if (this.replaySession) return 0;
1338
1352
  let t = null;
1339
1353
  if (this.fullSeries) {
1340
- let n = this.fullSeries[0]?.time, r = /* @__PURE__ */ new Set(), i = e.filter((e) => Qn(e) && (n === void 0 || e.time < n) && !r.has(e.time) && r.add(e.time)).sort((e, t) => e.time - t.time);
1354
+ let n = this.fullSeries[0]?.time, r = /* @__PURE__ */ new Set(), i = e.filter((e) => $n(e) && (n === void 0 || e.time < n) && !r.has(e.time) && r.add(e.time)).sort((e, t) => e.time - t.time);
1341
1355
  this.fullSeries = [...i, ...this.fullSeries];
1342
1356
  let a = this.sessionKeep(this.fullSeries);
1343
1357
  t = i.length, e = a ? i.filter((e) => a(e.time)) : i;
@@ -1379,13 +1393,13 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
1379
1393
  this.historyCheckQueued || !this.history.hasLoader() || (this.historyCheckQueued = !0, queueMicrotask(() => {
1380
1394
  if (this.historyCheckQueued = !1, this.replaySession || !this.history.hasLoader() || L(this.options.chartType)) return;
1381
1395
  let { from: e, to: t } = this.viewport.getState().visibleRange;
1382
- this.history.maybeLoad(Math.max(0, Math.floor(e)), Math.max(Ln, t - e));
1396
+ this.history.maybeLoad(Math.max(0, Math.floor(e)), Math.max(Rn, t - e));
1383
1397
  }));
1384
1398
  }
1385
1399
  useStreamHistory(e, t) {
1386
1400
  if (this.hostHistoryLoader) return;
1387
- let n = Nt(e), r = n.fetchHistoryBefore, i = this.streamTimeframe;
1388
- if (!r || i === null || ie(i) !== null) {
1401
+ let n = Ft(e), r = n.fetchHistoryBefore, i = this.streamTimeframe;
1402
+ if (!r || i === null || oe(i) !== null) {
1389
1403
  this.historyFromStream && this.history.setLoader(null), this.historyFromStream = !1;
1390
1404
  return;
1391
1405
  }
@@ -1457,11 +1471,11 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
1457
1471
  setChartTypeOptions(e) {
1458
1472
  this.chartTypeOptions = {
1459
1473
  ...this.chartTypeOptions,
1460
- ...b(e)
1474
+ ...y(e)
1461
1475
  }, this.displayDataCache = null, this.updateViewportAndRender(!0), this.markStateChanged();
1462
1476
  }
1463
1477
  getChartTypeOptions() {
1464
- return b(this.chartTypeOptions);
1478
+ return y(this.chartTypeOptions);
1465
1479
  }
1466
1480
  setExtendedHours(e) {
1467
1481
  e !== this.extendedHours && (this.extendedHours = e, this.reapplyExtendedHours(), this.markStateChanged());
@@ -1470,7 +1484,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
1470
1484
  return this.extendedHours;
1471
1485
  }
1472
1486
  sessionKeep(e) {
1473
- return this.extendedHours ? null : Rt(this.symbolInfo, e);
1487
+ return this.extendedHours ? null : Bt(this.symbolInfo, e);
1474
1488
  }
1475
1489
  shownBars(e) {
1476
1490
  let t = this.sessionKeep(e);
@@ -1511,7 +1525,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
1511
1525
  return this.priceLines.setQuoteShown(this.replaySession === null), this.priceLines;
1512
1526
  }
1513
1527
  setShapes(e) {
1514
- let t = Wn(e);
1528
+ let t = Gn(e);
1515
1529
  t.tagRadius !== void 0 && (this.themeManager.setShape({
1516
1530
  ...this.themeManager.getTheme().shape,
1517
1531
  ...t
@@ -1590,7 +1604,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
1590
1604
  }), this.requestMissingSymbols(e);
1591
1605
  let a = this.indicatorEngine.getIndicatorConfig(e);
1592
1606
  if (n?.placement === "overlay" && a && r && a.params[r] !== i) {
1593
- let t = g(a.params[r]), n = t ? this.paneHostOf(t.instanceId, e) : g(i) ? null : a.pane ?? null;
1607
+ let t = v(a.params[r]), n = t ? this.paneHostOf(t.instanceId, e) : v(i) ? null : a.pane ?? null;
1594
1608
  (n ?? void 0) !== a.pane && (this.indicatorEngine.setPane(e, n), this.eventBus.emit("indicatorChange", {
1595
1609
  instanceId: e,
1596
1610
  change: "pane"
@@ -1601,7 +1615,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
1601
1615
  paneFor(e, t, n, r) {
1602
1616
  if (n) return this.paneHostOf(n, r);
1603
1617
  if (e.placement !== "overlay") return null;
1604
- let i = M(e), a = i ? g(t[i]) : null;
1618
+ let i = M(e), a = i ? v(t[i]) : null;
1605
1619
  return a ? this.paneHostOf(a.instanceId, r) : null;
1606
1620
  }
1607
1621
  paneHostOf(e, t) {
@@ -1644,8 +1658,8 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
1644
1658
  return {
1645
1659
  ...e,
1646
1660
  priceRange: {
1647
- min: t.min - n * Fn,
1648
- max: t.max + n * Fn
1661
+ min: t.min - n * In,
1662
+ max: t.max + n * In
1649
1663
  },
1650
1664
  logScale: !1,
1651
1665
  scaleMode: "regular",
@@ -1692,7 +1706,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
1692
1706
  this.indicatorEngine.setStyleDefaults(e, null);
1693
1707
  return;
1694
1708
  }
1695
- let { plots: n, ...r } = t, i = n === void 0 ? void 0 : ee(n);
1709
+ let { plots: n, ...r } = t, i = n === void 0 ? void 0 : b(n);
1696
1710
  this.indicatorEngine.setStyleDefaults(e, {
1697
1711
  ...r,
1698
1712
  ...i ? { plots: i } : {}
@@ -1744,7 +1758,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
1744
1758
  let n = this.indicatorEngine.getIndicatorConfig(e), r = this.indicatorEngine.getIndicatorDescriptor(e);
1745
1759
  if (!n || !r) return;
1746
1760
  let i = M(r);
1747
- if (r.placement === "overlay" && i && g(n.params[i])) return;
1761
+ if (r.placement === "overlay" && i && v(n.params[i])) return;
1748
1762
  if (t === "price") return r.placement === "overlay" && n.pane ? null : void 0;
1749
1763
  if (t === "new") {
1750
1764
  let t = this.layoutManager.getPanels().some((t) => t.id === e);
@@ -1855,7 +1869,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
1855
1869
  roundPrice(e) {
1856
1870
  if (!Number.isFinite(e)) return e;
1857
1871
  let t = this.stepAt(e);
1858
- if (t !== void 0) return Number((Math.round(e / t) * t).toFixed(re(t)));
1872
+ if (t !== void 0) return Number((Math.round(e / t) * t).toFixed(ae(t)));
1859
1873
  let { min: n, max: r } = this.viewport.getState().priceRange;
1860
1874
  return Number(e.toFixed(this.marketPricePrecision ?? s(n, r)));
1861
1875
  }
@@ -1865,7 +1879,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
1865
1879
  }
1866
1880
  stepAt(e) {
1867
1881
  let t = this.symbolInfo?.minTick ?? this.priceUnit ?? void 0;
1868
- return t !== void 0 && t > 0 ? t : this.marketConfig ? v(e, this.marketConfig) : void 0;
1882
+ return t !== void 0 && t > 0 ? t : this.marketConfig ? te(e, this.marketConfig) : void 0;
1869
1883
  }
1870
1884
  getPriceStep(e) {
1871
1885
  let t = this.stepAt(e ?? this.lastClose());
@@ -1880,7 +1894,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
1880
1894
  return this.priceFormatter;
1881
1895
  }
1882
1896
  applyPriceFormat(e) {
1883
- this.priceFormatter = _(e), this.priceUnit = e && typeof e != "function" ? d(e) : null, this.viewport.setPriceFormat(this.priceFormatter, this.priceUnit), this.crosshairTooltip.setPriceFormatter(this.priceFormatter), this.pinnedTooltip.setPriceFormatter(this.priceFormatter);
1897
+ this.priceFormatter = ee(e), this.priceUnit = e && typeof e != "function" ? f(e) : null, this.viewport.setPriceFormat(this.priceFormatter, this.priceUnit), this.crosshairTooltip.setPriceFormatter(this.priceFormatter), this.pinnedTooltip.setPriceFormatter(this.priceFormatter);
1884
1898
  }
1885
1899
  setTimeFormatter(e) {
1886
1900
  this.applyTimeFormatter(e), this.engine.requestRender();
@@ -1891,7 +1905,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
1891
1905
  formatPrice(e) {
1892
1906
  if (this.priceFormatter) return this.priceFormatter(e);
1893
1907
  let { min: t, max: n } = this.viewport.getState().priceRange;
1894
- return u(e, this.marketPricePrecision ?? s(t, n), this.numberLocale);
1908
+ return d(e, this.marketPricePrecision ?? s(t, n), this.numberLocale);
1895
1909
  }
1896
1910
  setDrawingTool(e) {
1897
1911
  this.features.drawings && (e && this.features.drawingTools.length > 0 && !this.features.drawingTools.includes(e) || (e && this.setZoomAreaMode(!1), this.drawingManager.setActiveTool(e)));
@@ -1936,7 +1950,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
1936
1950
  }
1937
1951
  autoFib() {
1938
1952
  if (!this.features.drawings) return null;
1939
- let e = this.getDisplayData(), t = this.viewport.getState(), n = _t(e, t.visibleRange.from, t.visibleRange.to);
1953
+ let e = this.getDisplayData(), t = this.viewport.getState(), n = yt(e, t.visibleRange.from, t.visibleRange.to);
1940
1954
  return n ? this.addDrawing({
1941
1955
  type: "fibRetracement",
1942
1956
  anchors: [n[0], n[1]]
@@ -2011,7 +2025,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
2011
2025
  recordUndo(e) {
2012
2026
  if (!this.features.drawingUndoRedo || typeof e?.undo != "function" || typeof e.redo != "function") return;
2013
2027
  let t = performance.now(), n = this.undoRedoManager.last();
2014
- if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at < In) {
2028
+ if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at < Ln) {
2015
2029
  this.undoRedoManager.replaceLast({
2016
2030
  ...n,
2017
2031
  custom: {
@@ -2058,7 +2072,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
2058
2072
  x: t.x,
2059
2073
  y: t.y
2060
2074
  };
2061
- if ((e === "plot" || e === "priceAxis") && (r.price = Ft(t.y, n)), (e === "plot" || e === "timeAxis") && n.data.length > 0 && (r.time = F(t.x, n)), e === "pane") {
2075
+ if ((e === "plot" || e === "priceAxis") && (r.price = Lt(t.y, n)), (e === "plot" || e === "timeAxis") && n.data.length > 0 && (r.time = F(t.x, n)), e === "pane") {
2062
2076
  let e = this.getIndicatorPanes().find((e) => t.y >= e.rect.y && t.y <= e.rect.y + e.rect.height);
2063
2077
  e && (r.pane = e.instanceId);
2064
2078
  }
@@ -2129,7 +2143,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
2129
2143
  for (let e of this.indicatorEngine.getActiveIndicators()) {
2130
2144
  let t = this.indicatorEngine.getOutput(e.instanceId)?.series;
2131
2145
  if (!t) continue;
2132
- let r = Kt(e.id, e.params, e.descriptor.defaultConfig, e.descriptor.shortName), o = e.descriptor.plots ?? Object.keys(t.find((e) => e) ?? {}).map((e) => ({
2146
+ let r = Jt(e.id, e.params, e.descriptor.defaultConfig, e.descriptor.shortName), o = e.descriptor.plots ?? Object.keys(t.find((e) => e) ?? {}).map((e) => ({
2133
2147
  key: e,
2134
2148
  title: e
2135
2149
  }));
@@ -2207,7 +2221,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
2207
2221
  this.recordIndicators(e, () => this.updateIndicatorStyleNow(e, t));
2208
2222
  }
2209
2223
  updateIndicatorStyleNow(e, t) {
2210
- let { plots: n, ...r } = t, i = n === void 0 ? void 0 : ee(n);
2224
+ let { plots: n, ...r } = t, i = n === void 0 ? void 0 : b(n);
2211
2225
  this.indicatorEngine.updateIndicatorStyle(e, {
2212
2226
  ...r,
2213
2227
  ...i ? { plots: i } : {}
@@ -2318,7 +2332,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
2318
2332
  }
2319
2333
  async connect(e) {
2320
2334
  if (!j(e.adapter, e.timeframe)) throw RangeError(`${e.adapter.name} cannot serve the ${e.timeframe} timeframe`);
2321
- this.snapshotKey = null, this.replayStop(), this.disconnectStream(), this.streamManager = new rt(), this.streamManager.on("snapshot", (t) => {
2335
+ this.snapshotKey = null, this.replayStop(), this.disconnectStream(), this.streamManager = new at(), this.streamManager.on("snapshot", (t) => {
2322
2336
  let n = `${this.currentSymbol}|${this.streamTimeframe}`;
2323
2337
  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);
2324
2338
  }), this.streamManager.on("barClose", (e) => {
@@ -2367,14 +2381,14 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
2367
2381
  }), this.streamManager.on("symbolInfo", (e) => this.applyFeedSymbolInfo(e)), this.autoScrollOnNewBar = e.autoScroll !== !1, this.setStreamTarget(e.symbol, e.timeframe), this.streamAdapter = e.adapter;
2368
2382
  let t = this.streamManager;
2369
2383
  if (this.resolveStreamSymbol(e.adapter, e.symbol), await t.connect(e), this.streamManager !== t) return;
2370
- let n = ae(e.timeframe);
2384
+ let n = se(e.timeframe);
2371
2385
  this.barCountdown.setTimeframeMs(n), this.countdownInterval && clearInterval(this.countdownInterval), this.countdownInterval = setInterval(() => {
2372
2386
  this.barCountdown.isVisible() && this.engine.requestRender(r.Hover);
2373
2387
  }, 1e3);
2374
2388
  }
2375
2389
  setStreamTarget(e, t) {
2376
2390
  let n = this.announcedSymbol, r = this.announcedTimeframe;
2377
- this.currentSymbol = e, this.streamTimeframe = t, this.tickStream = ie(t) !== null, this.applyTimeSpacing(), e !== n && (this.announcedSymbol = e, this.eventBus.emit("symbolChange", {
2391
+ this.currentSymbol = e, this.streamTimeframe = t, this.tickStream = oe(t) !== null, this.applyTimeSpacing(), e !== n && (this.announcedSymbol = e, this.eventBus.emit("symbolChange", {
2378
2392
  symbol: e,
2379
2393
  previous: n
2380
2394
  })), t !== r && (this.announcedTimeframe = t, this.eventBus.emit("timeframeChange", {
@@ -2386,7 +2400,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
2386
2400
  if (!this.streamManager) return;
2387
2401
  let n = this.streamAdapter;
2388
2402
  if (n && !j(n, t)) throw RangeError(`${n.name} cannot serve the ${t} timeframe`);
2389
- this.setStreamTarget(e, t), this.historyFromStream && this.history.setLoader(null), this.barCountdown.setTimeframeMs(ae(t)), n && this.resolveStreamSymbol(n, e), await this.streamManager.switchTo(e, t);
2403
+ this.setStreamTarget(e, t), this.historyFromStream && this.history.setLoader(null), this.barCountdown.setTimeframeMs(se(t)), n && this.resolveStreamSymbol(n, e), await this.streamManager.switchTo(e, t);
2390
2404
  }
2391
2405
  isTimeframeAllowed(e) {
2392
2406
  let t = this.features.timeframes;
@@ -2401,7 +2415,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
2401
2415
  }
2402
2416
  connectExecution(e, t = {}) {
2403
2417
  if (!this.features.trading) throw Error("connectExecution requires features.trading to be enabled");
2404
- this.disconnectExecution(), this.executionAdapter = e, this.execTeardown = kn(e, {
2418
+ this.disconnectExecution(), this.executionAdapter = e, this.execTeardown = jn(e, {
2405
2419
  onIntent: (e, t) => {
2406
2420
  let n = (e) => t(e.payload);
2407
2421
  return this.eventBus.on(e, n), () => this.eventBus.off(e, n);
@@ -2498,7 +2512,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
2498
2512
  setVisibleRangePreset(e) {
2499
2513
  let t = this.getDisplayData();
2500
2514
  if (t.length === 0) return;
2501
- let n = t.length - 1, r = t[n].time > jn ? 1 : 1e3, i = Ct(e, t[n].time * r, this.displayTz), a = i === null ? null : i / r;
2515
+ let n = t.length - 1, r = c(t), i = Tt(e, t[n].time * r, this.displayTz), a = i === null ? null : i / r;
2502
2516
  if (a === null || a < t[0].time) {
2503
2517
  this.fitContent();
2504
2518
  return;
@@ -2515,7 +2529,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
2515
2529
  this.viewport.scrollBy(e * (t + n)), this.updateViewportAndRender();
2516
2530
  }
2517
2531
  setVisibleRange(e, t) {
2518
- let n = this.dataManager.getData();
2532
+ let n = this.getDisplayData();
2519
2533
  if (n.length === 0) return;
2520
2534
  let r = N(Math.min(e, t), n), i = N(Math.max(e, t), n);
2521
2535
  this.viewport.zoomToBarRange(r, i), this.updateViewportAndRender();
@@ -2532,7 +2546,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
2532
2546
  this.viewport.zoom(-.2, e / 2), this.updateViewportAndRender();
2533
2547
  }
2534
2548
  fitContent() {
2535
- let e = this.dataManager.getLength();
2549
+ let e = this.getDisplayData().length;
2536
2550
  e !== 0 && (this.viewport.zoomToBarRange(0, e - 1 + this.viewport.getRightMargin()), this.viewport.scrollToEnd(), this.updateViewportAndRender());
2537
2551
  }
2538
2552
  on(e, t) {
@@ -2560,7 +2574,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
2560
2574
  this.applyStyle(e, t.layer ?? "host", !0);
2561
2575
  }
2562
2576
  setOverrides(e, t = {}) {
2563
- let n = t.layer ?? "host", { overrides: r, rejected: i } = y(e);
2577
+ let n = t.layer ?? "host", { overrides: r, rejected: i } = ne(e);
2564
2578
  i.length > 0 && console.warn(`Style overrides left out (unknown key or value): ${i.join(", ")}`);
2565
2579
  let a = Object.fromEntries(Object.entries(r).filter(([, e]) => e !== null));
2566
2580
  this.themeManager.setOverrides(a, n) && this.styleChanged(n);
@@ -2579,7 +2593,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
2579
2593
  return this.themeManager.getStyleValue(e);
2580
2594
  }
2581
2595
  applyStyle(e, t, n) {
2582
- let { overrides: r, rejected: i } = y(e);
2596
+ let { overrides: r, rejected: i } = ne(e);
2583
2597
  i.length > 0 && console.warn(`Style overrides left out (unknown key or value): ${i.join(", ")}`), this.themeManager.applyOverrides(r, t) && n && this.styleChanged(t);
2584
2598
  }
2585
2599
  styleChanged(e) {
@@ -2671,7 +2685,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
2671
2685
  this.periodLevels.setPeriod(e), this.engine.requestRender(r.Main);
2672
2686
  }
2673
2687
  setTimezone(e) {
2674
- Nn(e), this.timezoneSetting = e, this.applyTimezone();
2688
+ Pn(e), this.timezoneSetting = e, this.applyTimezone();
2675
2689
  }
2676
2690
  getTimezone() {
2677
2691
  return this.timezoneSetting;
@@ -2680,7 +2694,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
2680
2694
  return this.displayTz;
2681
2695
  }
2682
2696
  applyTimezone() {
2683
- let e = this.symbolInfo?.timezone, t = this.timezoneSetting === "exchange" ? e && p(e) ? e : "UTC" : this.timezoneSetting;
2697
+ let e = this.symbolInfo?.timezone, t = this.timezoneSetting === "exchange" ? e && m(e) ? e : "UTC" : this.timezoneSetting;
2684
2698
  this.displayTz = t, this.timeAxis.setTimezoneOffset(t), this.crosshairHandler.setTimezoneOffset(t), this.crosshairTooltip.setTimezoneOffset(t), this.pinnedTooltip.setTimezone(t), this.sessionBreaks.setTimezone(t), this.engine.requestRender();
2685
2699
  }
2686
2700
  setSymbolInfo(e) {
@@ -2695,7 +2709,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
2695
2709
  endMinute: n
2696
2710
  }];
2697
2711
  }), n = this.symbolInfo?.timezone;
2698
- this.sessionShading.replaceConfig(t.length > 0 && n && p(n) ? {
2712
+ this.sessionShading.replaceConfig(t.length > 0 && n && m(n) ? {
2699
2713
  timeZone: n,
2700
2714
  windows: t,
2701
2715
  startMinute: t[0].startMinute,
@@ -2746,7 +2760,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
2746
2760
  return this.sessionShading.isVisible();
2747
2761
  }
2748
2762
  setSessionShadingConfig(e) {
2749
- this.hostSessionHours = xt(this.hostSessionHours, e), this.sessionShading.replaceConfig(this.hostSessionHours), this.engine.requestRender(r.Background);
2763
+ this.hostSessionHours = Ct(this.hostSessionHours, e), this.sessionShading.replaceConfig(this.hostSessionHours), this.engine.requestRender(r.Background);
2750
2764
  }
2751
2765
  setTooltipVisible(e) {
2752
2766
  e || this.crosshairTooltip.hide();
@@ -2765,11 +2779,11 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
2765
2779
  return this.waitForGpu(null), e === "canvas" ? (this.applyRenderer(null), "canvas") : this.engine.getGpu() ? "webgl" : this.takeGpu(e, t, !0);
2766
2780
  }
2767
2781
  async takeGpu(e, t, n) {
2768
- let { gpu: r, reason: i } = await bt(e);
2769
- return t !== this.rendererToken || this.disposed ? (r?.destroy(), this.getRenderer()) : i === "limit" ? vt() > 0 ? this.takeGpu(e, t, n) : (this.waitForGpu(() => void this.takeGpu(e, t, !1)), n && this.applyRenderer(null, "limit"), this.getRenderer()) : ((r || n) && this.applyRenderer(r, i), this.getRenderer());
2782
+ let { gpu: r, reason: i } = await St(e);
2783
+ return t !== this.rendererToken || this.disposed ? (r?.destroy(), this.getRenderer()) : i === "limit" ? bt() > 0 ? this.takeGpu(e, t, n) : (this.waitForGpu(() => void this.takeGpu(e, t, !1)), n && this.applyRenderer(null, "limit"), this.getRenderer()) : ((r || n) && this.applyRenderer(r, i), this.getRenderer());
2770
2784
  }
2771
2785
  waitForGpu(e) {
2772
- this.stopWaitingForGpu?.(), this.stopWaitingForGpu = e ? Mt(e) : null;
2786
+ this.stopWaitingForGpu?.(), this.stopWaitingForGpu = e ? Pt(e) : null;
2773
2787
  }
2774
2788
  getRenderer() {
2775
2789
  return this.engine.getGpu() ? "webgl" : "canvas";
@@ -2939,23 +2953,23 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
2939
2953
  };
2940
2954
  }
2941
2955
  let { steps: n, startTime: r, hideHistory: i, revealMarks: a, ...o } = e ?? {}, s = this.shownBars(this.replaySession.live.getData()), c = t > 0 && r === void 0 && i !== !1, l = o.startIndex;
2942
- r !== void 0 && l === void 0 ? l = qn(s, r) : c && l !== void 0 && (l += t);
2956
+ r !== void 0 && l === void 0 ? l = Jn(s, r) : c && l !== void 0 && (l += t);
2943
2957
  let u = c ? t : i && l !== void 0 && l > 0 ? Math.min(Math.floor(l), s.length - 1) : 0, d = u > 0 ? s.slice(u) : s;
2944
2958
  l !== void 0 && (o.startIndex = l - u), this.replayOffset = u, this.replayRevealMarks = a !== !1;
2945
- let f = n ? Zn(n, d) : null;
2959
+ let f = n ? Qn(n, d) : null;
2946
2960
  this.replayStepsSeries = f, this.replayCoarse = d, this.options.autoScale = !0, this.replayRestarting = !0;
2947
2961
  try {
2948
2962
  this.replayManager.load(f ?? d);
2949
2963
  } finally {
2950
2964
  this.replayRestarting = !1;
2951
2965
  }
2952
- f && o.startIndex !== void 0 && (o.startIndex = er(f, d, o.startIndex)), this.replayBarUnsub?.();
2966
+ f && o.startIndex !== void 0 && (o.startIndex = tr(f, d, o.startIndex)), this.replayBarUnsub?.();
2953
2967
  let p = -1, m = -1, h = null, g = f ?? d;
2954
2968
  this.replayBarUnsub = this.replayManager.on("bar", ({ index: e }) => {
2955
2969
  let t = e, n = d[e];
2956
2970
  if (f) {
2957
2971
  let r = f[e];
2958
- t = $n(d, r.time), h = h !== null && m === e - 1 && t === p - 1 && h ? nr(h, r) : tr(d[t], f, e), n = h;
2972
+ t = er(d, r.time), h = h !== null && m === e - 1 && t === p - 1 && h ? rr(h, r) : nr(d[t], f, e), n = h;
2959
2973
  }
2960
2974
  m = e;
2961
2975
  let r = t + 1, i = p > 0 && r >= p && this.dataManager.getLength() === p, a = !(i && !this.replaySeeking) || this.autoScrollOnNewBar && this.viewport.isAtEnd();
@@ -3007,20 +3021,20 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
3007
3021
  return;
3008
3022
  }
3009
3023
  if (i.time <= n.fedTime) return;
3010
- let a = e.slice(Jn(e, n.fedTime), t + 1);
3024
+ let a = e.slice(Yn(e, n.fedTime), t + 1);
3011
3025
  n.fedTime = i.time;
3012
- let o = Math.ceil(a.length / Kn);
3013
- for (let e = 0; e < a.length; e += o) for (let [t, n] of Yn(a.slice(e, e + o))) r.setMarkPrice(t, n);
3026
+ let o = Math.ceil(a.length / qn);
3027
+ for (let e = 0; e < a.length; e += o) for (let [t, n] of Xn(a.slice(e, e + o))) r.setMarkPrice(t, n);
3014
3028
  this.tradingManager.setCurrentPrice(i.close);
3015
3029
  }
3016
3030
  getReplayBarIndex() {
3017
3031
  if (!this.replaySession) return -1;
3018
3032
  let { current: e } = this.replayManager.getProgress(), t = this.replayStepsSeries;
3019
- return t && this.replayCoarse ? $n(this.replayCoarse, t[e]?.time ?? -Infinity) : e;
3033
+ return t && this.replayCoarse ? er(this.replayCoarse, t[e]?.time ?? -Infinity) : e;
3020
3034
  }
3021
3035
  replaySeekToBar(e) {
3022
3036
  let t = this.replayStepsSeries;
3023
- this.replaySeek(t && this.replayCoarse ? er(t, this.replayCoarse, e) : e);
3037
+ this.replaySeek(t && this.replayCoarse ? tr(t, this.replayCoarse, e) : e);
3024
3038
  }
3025
3039
  replayPause() {
3026
3040
  this.replayManager.pause();
@@ -3052,10 +3066,10 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
3052
3066
  data: this.getDisplayData()
3053
3067
  }, r = n.chartRect, i = Infinity, a = -Infinity, o = Infinity, s = -Infinity;
3054
3068
  for (let e of t.anchors) {
3055
- let t = Et(e.time, n), r = St(e.price, n);
3069
+ let t = Ot(e.time, n), r = wt(e.price, n);
3056
3070
  i = Math.min(i, t), a = Math.max(a, t), o = Math.min(o, r), s = Math.max(s, r);
3057
3071
  }
3058
- return zn.has(t.type) ? [i, a] = [r.x, r.x + r.width] : t.type === "horizontalRay" && (a = r.x + r.width), Bn.has(t.type) && ([o, s] = [r.y, r.y + r.height]), i = Math.max(i, r.x), a = Math.min(a, r.x + r.width), o = Math.max(o, r.y), s = Math.min(s, r.y + r.height), i <= a && o <= s ? {
3072
+ return Bn.has(t.type) ? [i, a] = [r.x, r.x + r.width] : t.type === "horizontalRay" && (a = r.x + r.width), Vn.has(t.type) && ([o, s] = [r.y, r.y + r.height]), i = Math.max(i, r.x), a = Math.min(a, r.x + r.width), o = Math.max(o, r.y), s = Math.min(s, r.y + r.height), i <= a && o <= s ? {
3059
3073
  x: i,
3060
3074
  y: o,
3061
3075
  width: a - i,
@@ -3096,14 +3110,14 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
3096
3110
  });
3097
3111
  }
3098
3112
  restoreIndicators(e, t) {
3099
- let n = Hn(e), r = /* @__PURE__ */ new Map();
3113
+ let n = Un(e), r = /* @__PURE__ */ new Map();
3100
3114
  this.unrestoredIndicators = [];
3101
3115
  let i = new Set(this.indicatorEngine.getAvailableIndicators().map((e) => e.id)), a = [], o = /* @__PURE__ */ new Set();
3102
3116
  if (t) {
3103
3117
  let e = new Map(n.map((e) => [e.instanceId, e])), t = this.getIndicatorSetup();
3104
3118
  for (let n of t) {
3105
3119
  let t = e.get(n.instanceId);
3106
- t && Un(n, t) && o.add(n.instanceId);
3120
+ t && Wn(n, t) && o.add(n.instanceId);
3107
3121
  }
3108
3122
  for (let e of t) o.has(e.instanceId) || this.removeIndicator(e.instanceId);
3109
3123
  for (let e of [...o]) this.indicatorEngine.getIndicatorConfig(e) || o.delete(e);
@@ -3111,8 +3125,8 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
3111
3125
  let s = (e) => {
3112
3126
  let t = { ...e };
3113
3127
  for (let [e, n] of Object.entries(t)) {
3114
- let i = g(n), a = i && r.get(i.instanceId);
3115
- a && (t[e] = f(a, i.key));
3128
+ let i = v(n), a = i && r.get(i.instanceId);
3129
+ a && (t[e] = p(a, i.key));
3116
3130
  }
3117
3131
  return t;
3118
3132
  };
@@ -3244,7 +3258,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
3244
3258
  if (this.indicatorHistoryDepth > 0 || !this.features.drawingUndoRedo) return t();
3245
3259
  let n = this.getIndicatorSetup(), r = this.withoutIndicatorHistory(t), i = this.getIndicatorSetup();
3246
3260
  if (JSON.stringify(n) === JSON.stringify(i)) return r;
3247
- let a = performance.now(), o = this.undoRedoManager.last(), s = e !== void 0 && o?.type === "indicators" && o.indicators?.subject === e && a - (o.indicators.at ?? 0) < In && JSON.stringify(o.indicators.after) === JSON.stringify(n), c = {
3261
+ let a = performance.now(), o = this.undoRedoManager.last(), s = e !== void 0 && o?.type === "indicators" && o.indicators?.subject === e && a - (o.indicators.at ?? 0) < Ln && JSON.stringify(o.indicators.after) === JSON.stringify(n), c = {
3248
3262
  type: "indicators",
3249
3263
  before: null,
3250
3264
  after: null
@@ -3288,7 +3302,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
3288
3302
  let t = e.indexOf(":"), r = t > 0 ? n.get(e.slice(0, t)) : void 0;
3289
3303
  return r ? r + e.slice(t) : e;
3290
3304
  }, r = t(e.channel), i = {
3291
- ...wt(e),
3305
+ ...Et(e),
3292
3306
  ...e.target ? { target: t(e.target) } : {}
3293
3307
  };
3294
3308
  if (!e.expired) {
@@ -3320,10 +3334,10 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
3320
3334
  this.loadState(C.serialize(e));
3321
3335
  }
3322
3336
  setLocale(e) {
3323
- ne(e), this.engine.requestRender();
3337
+ ie(e), this.engine.requestRender();
3324
3338
  }
3325
3339
  setNumberLocale(e) {
3326
- this.numberLocale = e, this.priceAxis.setLocale(e), this.leftPriceAxis.setLocale(e), this.crosshairHandler.setLocale(e), this.chartLegend.setLocale(e), this.crosshairTooltip.setLocale(e), this.sessionBreaks.setLocale(e), this.currentPriceLine.setLocale(e), this.updateViewportAndRender();
3340
+ this.numberLocale = e, this.priceAxis.setLocale(e), this.leftPriceAxis.setLocale(e), this.crosshairHandler.setLocale(e), this.timeAxis.setLocale(e), this.chartLegend.setLocale(e), this.crosshairTooltip.setLocale(e), this.sessionBreaks.setLocale(e), this.currentPriceLine.setLocale(e), this.updateViewportAndRender();
3327
3341
  }
3328
3342
  getNumberLocale() {
3329
3343
  return this.numberLocale;
@@ -3336,22 +3350,22 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
3336
3350
  candleDown: e.colorScheme.down,
3337
3351
  candleUpWick: e.colorScheme.up,
3338
3352
  candleDownWick: e.colorScheme.down,
3339
- volumeUp: oe(e.colorScheme.up),
3340
- volumeDown: oe(e.colorScheme.down)
3353
+ volumeUp: ce(e.colorScheme.up),
3354
+ volumeDown: ce(e.colorScheme.down)
3341
3355
  };
3342
3356
  this.themeManager.setTheme(t);
3343
3357
  }
3344
3358
  e.pricePrecision !== void 0 && this.applyPricePrecision(e.pricePrecision), this.updateViewportAndRender();
3345
3359
  }
3346
3360
  applyPricePrecision(e) {
3347
- this.marketPricePrecision = e, this.priceAxis.setPricePrecision(e), this.tradingManager.setConfig({ pricePrecision: e ?? void 0 }), this.alertManager.setPricePrecision(e ?? Pn), this.streamManager?.priceLine.setPricePrecision(e), this.currentPriceLine.setPricePrecision(e), this.crosshairHandler.setPricePrecision(e), this.chartLegend.setPricePrecision(e), this.crosshairTooltip.setPricePrecision(e);
3361
+ this.marketPricePrecision = e, this.priceAxis.setPricePrecision(e), this.tradingManager.setConfig({ pricePrecision: e ?? void 0 }), this.alertManager.setPricePrecision(e ?? Fn), this.streamManager?.priceLine.setPricePrecision(e), this.currentPriceLine.setPricePrecision(e), this.crosshairHandler.setPricePrecision(e), this.chartLegend.setPricePrecision(e), this.crosshairTooltip.setPricePrecision(e);
3348
3362
  }
3349
3363
  getMarket() {
3350
3364
  return this.marketConfig;
3351
3365
  }
3352
3366
  getPriceLimits() {
3353
3367
  let e = this.marketConfig;
3354
- return !e?.priceLimits?.enabled || !e.priceLimits.referencePrice ? null : l(e.priceLimits.referencePrice, e);
3368
+ return !e?.priceLimits?.enabled || !e.priceLimits.referencePrice ? null : u(e.priceLimits.referencePrice, e);
3355
3369
  }
3356
3370
  setPriceLimits(e) {
3357
3371
  this.marketConfig?.priceLimits && (this.marketConfig = {
@@ -3381,15 +3395,18 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
3381
3395
  this.disposed = !0, this.waitForGpu(null), this.countdownInterval && clearInterval(this.countdownInterval), this.history.setLoader(null), this.disableAutoSave(), this.disconnectStream(), this.disconnectExecution(), this.onWindowKeyDown &&= (window.removeEventListener("keydown", this.onWindowKeyDown), null), this.keyboardHandler = null, this.a11y?.destroy(), this.a11y = null, this.interactionManager.detach(), this.tradingManager.destroy(), this.animator.dispose(), this.crosshairTooltip.destroy(), this.pinnedTooltip.destroy(), this.replayRestarting = !0, this.replayManager.dispose(), this.alertManager.dispose(), this.undoRedoManager.clear(), this.engine.destroy(), this.eventBus.destroy(), this.container.innerHTML = "";
3382
3396
  }
3383
3397
  createChartRenderer(e) {
3384
- let t = Qt(e, (e) => this.pluginManager.getChartType(e));
3398
+ let t = en(e, (e) => this.pluginManager.getChartType(e));
3385
3399
  return t instanceof T && t.setPriceText((e) => this.formatPrice(e)), t;
3386
3400
  }
3401
+ crosshairSeries() {
3402
+ return this.isTimeAligned() ? this.dataManager.getData() : this.getDisplayData();
3403
+ }
3387
3404
  getDisplayData() {
3388
3405
  if (this.displayDataCache) return this.displayDataCache;
3389
3406
  let e = this.dataManager.getData();
3390
3407
  if (e.length === 0) return e;
3391
- let t = $t(this.options.chartType, e, (e) => this.pluginManager.getChartType(e), this.chartTypeOptions);
3392
- return this.chartRenderer instanceof D && !this.pluginManager.getChartType(this.options.chartType) && this.chartRenderer.setBoxSize(Xt(e, this.chartTypeOptions)), this.displayDataCache = t, t;
3408
+ let t = tn(this.options.chartType, e, (e) => this.pluginManager.getChartType(e), this.chartTypeOptions);
3409
+ return this.chartRenderer instanceof D && !this.pluginManager.getChartType(this.options.chartType) && this.chartRenderer.setBoxSize(Qt(e, this.chartTypeOptions)), this.displayDataCache = t, t;
3393
3410
  }
3394
3411
  recalcIndicatorsFrom(e, t) {
3395
3412
  this.indicatorEngine.recalculateFrom(e, t), this.announceIndicatorUpdate(t);
@@ -3424,12 +3441,12 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
3424
3441
  this.viewport.setScaleBaseline(t[e]?.close);
3425
3442
  }
3426
3443
  if (n) {
3427
- let e = Gn(this.indicatorEngine.getOverlayPriceRange(r.visibleRange.from, Math.min(r.visibleRange.to, t.length - 1)), this.features.compareSymbols ? this.compareRenderer.getPriceRange(t, r) : null);
3444
+ let e = Kn(this.indicatorEngine.getOverlayPriceRange(r.visibleRange.from, Math.min(r.visibleRange.to, t.length - 1)), this.features.compareSymbols ? this.compareRenderer.getPriceRange(t, r) : null);
3428
3445
  if (e) {
3429
3446
  let t = r.priceRange, n = Math.min(t.min, e.min), i = Math.max(t.max, e.max);
3430
3447
  if (n < t.min || i > t.max) {
3431
- let e = i - n || 1;
3432
- this.viewport.setPriceRange(n - e * .02, i + e * .02);
3448
+ let e = _(n, i, .02, this.viewport.isLogScale());
3449
+ this.viewport.setPriceRange(e.min, e.max);
3433
3450
  }
3434
3451
  }
3435
3452
  }
@@ -3448,7 +3465,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
3448
3465
  fitLeftAxisWidth() {
3449
3466
  let e = this.leftViewport;
3450
3467
  if (!e) return !1;
3451
- let t = this.themeManager.getTheme(), n = _n({
3468
+ let t = this.themeManager.getTheme(), n = yn({
3452
3469
  min: e.priceRange.min,
3453
3470
  max: e.priceRange.max,
3454
3471
  lastPrice: null,
@@ -3457,12 +3474,12 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
3457
3474
  fontFamily: t.font.family,
3458
3475
  fontSizeSmall: t.font.sizeSmall,
3459
3476
  measure: (e, t) => this.measureText(e, t)
3460
- }), r = vn(this.leftAxisWidth, n);
3477
+ }), r = bn(this.leftAxisWidth, n);
3461
3478
  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);
3462
3479
  }
3463
3480
  fitPriceAxisWidth() {
3464
3481
  if (!this.features.priceAxis) return !1;
3465
- let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n = _n({
3482
+ let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n = yn({
3466
3483
  min: e.min,
3467
3484
  max: e.max,
3468
3485
  lastPrice: this.currentPriceLine.getPrice(),
@@ -3473,7 +3490,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
3473
3490
  fontFamily: t.font.family,
3474
3491
  fontSizeSmall: t.font.sizeSmall,
3475
3492
  measure: (e, t) => this.measureText(e, t)
3476
- }), r = vn(this.priceAxisWidth, n);
3493
+ }), r = bn(this.priceAxisWidth, n);
3477
3494
  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);
3478
3495
  }
3479
3496
  measureText(e, t) {
@@ -3517,7 +3534,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
3517
3534
  buildPanelRenderInfos() {
3518
3535
  if (this.panelInfoCache) return this.panelInfoCache;
3519
3536
  let e = this.getResolvedLayout(), t = this.viewport.getState(), { from: n, to: r } = t.visibleRange, i = e.panels.map((e) => {
3520
- 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) ?? { ...An }, o = {
3537
+ 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) ?? { ...Mn }, o = {
3521
3538
  x: e.rect.x,
3522
3539
  y: e.rect.y + 20,
3523
3540
  width: e.rect.width,
@@ -3599,7 +3616,7 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
3599
3616
  });
3600
3617
  }
3601
3618
  drawOverlayPlugins(e, t) {
3602
- let n = xn(this.pluginManager.getOverlays(), t);
3619
+ let n = Cn(this.pluginManager.getOverlays(), t);
3603
3620
  if (n.length === 0) return;
3604
3621
  let r = {
3605
3622
  viewport: this.viewport.getState(),
@@ -3620,11 +3637,11 @@ var Pn = 2, Fn = .08, In = 800, Ln = 20, Rn = 8, zn = new Set(["horizontalLine",
3620
3637
  };
3621
3638
  }
3622
3639
  };
3623
- function Hn(e) {
3640
+ function Un(e) {
3624
3641
  let t = new Map(e.map((e) => [e.instanceId, e])), n = [], r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = (e) => {
3625
3642
  if (r.has(e.instanceId) || i.has(e.instanceId)) return;
3626
3643
  i.add(e.instanceId);
3627
- let o = [e.pane, ...Object.values(e.params).map((e) => g(e)?.instanceId)];
3644
+ let o = [e.pane, ...Object.values(e.params).map((e) => v(e)?.instanceId)];
3628
3645
  for (let e of o) {
3629
3646
  let n = e ? t.get(e) : void 0;
3630
3647
  n && a(n);
@@ -3634,10 +3651,10 @@ function Hn(e) {
3634
3651
  for (let t of e) a(t);
3635
3652
  return n;
3636
3653
  }
3637
- function Un(e, t) {
3654
+ function Wn(e, t) {
3638
3655
  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);
3639
3656
  }
3640
- function Wn(e) {
3657
+ function Gn(e) {
3641
3658
  let t = e.tagRadius;
3642
3659
  return typeof t == "number" && Number.isFinite(t) && t >= 0 ? { tagRadius: Math.min(t, 999) } : {};
3643
3660
  }
@@ -3647,7 +3664,7 @@ var W = new Set([
3647
3664
  "correlation",
3648
3665
  "correlationlog"
3649
3666
  ]);
3650
- function Gn(e, t) {
3667
+ function Kn(e, t) {
3651
3668
  return e ? t ? {
3652
3669
  min: Math.min(e.min, t.min),
3653
3670
  max: Math.max(e.max, t.max)
@@ -3668,8 +3685,8 @@ function G(e) {
3668
3685
  bars: e.bars
3669
3686
  };
3670
3687
  }
3671
- var Kn = 500;
3672
- function qn(e, t) {
3688
+ var qn = 500;
3689
+ function Jn(e, t) {
3673
3690
  let n = 0, r = e.length;
3674
3691
  for (; n < r;) {
3675
3692
  let i = n + r >> 1;
@@ -3677,7 +3694,7 @@ function qn(e, t) {
3677
3694
  }
3678
3695
  return n;
3679
3696
  }
3680
- function Jn(e, t) {
3697
+ function Yn(e, t) {
3681
3698
  let n = 0, r = e.length;
3682
3699
  for (; n < r;) {
3683
3700
  let i = n + r >> 1;
@@ -3685,20 +3702,20 @@ function Jn(e, t) {
3685
3702
  }
3686
3703
  return n;
3687
3704
  }
3688
- function Yn(e) {
3705
+ function Xn(e) {
3689
3706
  let t = 0, n = 0;
3690
3707
  for (let r = 1; r < e.length; r++) e[r].low < e[t].low && (t = r), e[r].high > e[n].high && (n = r);
3691
3708
  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];
3692
3709
  return [...a ? [r, i] : [i, r], [o.close, o.time]];
3693
3710
  }
3694
- function Xn(e) {
3711
+ function Zn(e) {
3695
3712
  let t = 0;
3696
3713
  for (let n = Math.max(1, e.length - 10); n < e.length; n++) t = Math.max(t, e[n].time - e[n - 1].time);
3697
3714
  return t > 0 ? t : Infinity;
3698
3715
  }
3699
- function Zn(e, t) {
3716
+ function Qn(e, t) {
3700
3717
  if (t.length === 0) return null;
3701
- let n = t[t.length - 1].time + Xn(t), r = e.filter((e) => Qn(e) && e.time >= t[0].time && e.time < n).sort((e, t) => e.time - t.time), i = [];
3718
+ let n = t[t.length - 1].time + Zn(t), r = e.filter((e) => $n(e) && e.time >= t[0].time && e.time < n).sort((e, t) => e.time - t.time), i = [];
3702
3719
  for (let e of r) (i.length === 0 || i[i.length - 1].time !== e.time) && i.push(e);
3703
3720
  if (i.length === 0) return null;
3704
3721
  let a = t.findIndex((e) => e.time >= i[0].time);
@@ -3706,7 +3723,7 @@ function Zn(e, t) {
3706
3723
  let o = t.slice(0, a), s = i.filter((e) => e.time >= t[a].time);
3707
3724
  return [...o, ...s];
3708
3725
  }
3709
- function Qn(e) {
3726
+ function $n(e) {
3710
3727
  return [
3711
3728
  e.time,
3712
3729
  e.open,
@@ -3715,7 +3732,7 @@ function Qn(e) {
3715
3732
  e.close
3716
3733
  ].every(Number.isFinite);
3717
3734
  }
3718
- function $n(e, t) {
3735
+ function er(e, t) {
3719
3736
  let n = 0, r = e.length - 1;
3720
3737
  for (; n < r;) {
3721
3738
  let i = n + r + 1 >> 1;
@@ -3723,22 +3740,22 @@ function $n(e, t) {
3723
3740
  }
3724
3741
  return n;
3725
3742
  }
3726
- function er(e, t, n) {
3743
+ function tr(e, t, n) {
3727
3744
  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;
3728
3745
  for (let t = 0; t < e.length && e[t].time < i; t++) a = t;
3729
3746
  return Math.max(0, a);
3730
3747
  }
3731
- function tr(e, t, n) {
3748
+ function nr(e, t, n) {
3732
3749
  let r = n;
3733
3750
  for (; r > 0 && t[r - 1].time >= e.time;) r--;
3734
3751
  let i = {
3735
3752
  ...t[r],
3736
3753
  time: e.time
3737
3754
  };
3738
- for (let e = r + 1; e <= n; e++) i = nr(i, t[e]);
3755
+ for (let e = r + 1; e <= n; e++) i = rr(i, t[e]);
3739
3756
  return i;
3740
3757
  }
3741
- function nr(e, t) {
3758
+ function rr(e, t) {
3742
3759
  return {
3743
3760
  time: e.time,
3744
3761
  open: e.open,
@@ -3751,31 +3768,31 @@ function nr(e, t) {
3751
3768
  function K(e, t) {
3752
3769
  let n = e[e.length - 1];
3753
3770
  if (!n) return "append";
3754
- let r = h(t.time), i = h(n.time);
3771
+ let r = g(t.time), i = g(n.time);
3755
3772
  return r > i ? "append" : r === i ? "update" : "stale";
3756
3773
  }
3757
3774
  //#endregion
3758
3775
  //#region src/io/parseOHLCV.ts
3759
- var rr = [
3776
+ var ir = [
3760
3777
  "time",
3761
3778
  "timestamp",
3762
3779
  "date",
3763
3780
  "datetime",
3764
3781
  "t"
3765
- ], ir = ["open", "o"], ar = ["high", "h"], or = ["low", "l"], sr = ["close", "c"], cr = [
3782
+ ], ar = ["open", "o"], or = ["high", "h"], sr = ["low", "l"], cr = ["close", "c"], lr = [
3766
3783
  "volume",
3767
3784
  "vol",
3768
3785
  "v"
3769
3786
  ];
3770
- function lr(e) {
3787
+ function ur(e) {
3771
3788
  let t = e.trim();
3772
- return t ? t[0] === "[" || t[0] === "{" ? ur(t) : dr(t) : {
3789
+ return t ? t[0] === "[" || t[0] === "{" ? dr(t) : fr(t) : {
3773
3790
  data: [],
3774
3791
  rowCount: 0,
3775
3792
  skipped: 0
3776
3793
  };
3777
3794
  }
3778
- function ur(e) {
3795
+ function dr(e) {
3779
3796
  let t;
3780
3797
  try {
3781
3798
  t = JSON.parse(e);
@@ -3790,14 +3807,14 @@ function ur(e) {
3790
3807
  }
3791
3808
  return _r(n, t.length, r);
3792
3809
  }
3793
- function dr(e) {
3810
+ function fr(e) {
3794
3811
  let t = e.split(/\r?\n/).filter((e) => e.trim().length > 0);
3795
3812
  if (t.length === 0) return {
3796
3813
  data: [],
3797
3814
  rowCount: 0,
3798
3815
  skipped: 0
3799
3816
  };
3800
- let n = fr(t[0]), r = pr(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? mr(r) : {
3817
+ let n = pr(t[0]), r = q(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? mr(r) : {
3801
3818
  time: 0,
3802
3819
  open: 1,
3803
3820
  high: 2,
@@ -3808,7 +3825,7 @@ function dr(e) {
3808
3825
  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");
3809
3826
  let o = [], s = 0;
3810
3827
  for (let e = +!!i; e < t.length; e++) {
3811
- let r = pr(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;
3828
+ 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;
3812
3829
  if (i === null || ![
3813
3830
  c,
3814
3831
  l,
@@ -3829,7 +3846,7 @@ function dr(e) {
3829
3846
  }
3830
3847
  return _r(o, t.length - +!!i, s);
3831
3848
  }
3832
- function fr(e) {
3849
+ function pr(e) {
3833
3850
  let t = {
3834
3851
  ",": 0,
3835
3852
  ";": 0,
@@ -3841,7 +3858,7 @@ function fr(e) {
3841
3858
  for (let [e, i] of Object.entries(t)) i > r && (n = e, r = i);
3842
3859
  return n;
3843
3860
  }
3844
- function pr(e, t) {
3861
+ function q(e, t) {
3845
3862
  let n = [], r = "", i = !1;
3846
3863
  for (let a = 0; a < e.length; a++) {
3847
3864
  let o = e[a];
@@ -3852,12 +3869,12 @@ function pr(e, t) {
3852
3869
  function mr(e) {
3853
3870
  let t = (t) => e.findIndex((e) => t.includes(e));
3854
3871
  return {
3855
- time: t(rr),
3856
- open: t(ir),
3857
- high: t(ar),
3858
- low: t(or),
3859
- close: t(sr),
3860
- volume: t(cr)
3872
+ time: t(ir),
3873
+ open: t(ar),
3874
+ high: t(or),
3875
+ low: t(sr),
3876
+ close: t(cr),
3877
+ volume: t(lr)
3861
3878
  };
3862
3879
  }
3863
3880
  function hr(e) {
@@ -3867,7 +3884,7 @@ function hr(e) {
3867
3884
  let t = n.toUpperCase();
3868
3885
  if (e[t] !== void 0) return e[t];
3869
3886
  }
3870
- }, n = J(String(t(rr) ?? "")), r = Number(t(ir)), i = Number(t(ar)), a = Number(t(or)), o = Number(t(sr)), s = Number(t(cr) ?? 0);
3887
+ }, n = Y(String(t(ir) ?? "")), r = Number(t(ar)), i = Number(t(or)), a = Number(t(sr)), o = Number(t(cr)), s = Number(t(lr) ?? 0);
3871
3888
  return n === null || ![
3872
3889
  r,
3873
3890
  i,
@@ -3884,7 +3901,7 @@ function hr(e) {
3884
3901
  }
3885
3902
  function gr(e) {
3886
3903
  if (e.length < 5) return null;
3887
- 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;
3904
+ 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;
3888
3905
  return t === null || ![
3889
3906
  n,
3890
3907
  r,
@@ -3899,14 +3916,14 @@ function gr(e) {
3899
3916
  volume: Number.isFinite(o) ? o : 0
3900
3917
  };
3901
3918
  }
3902
- function q(e) {
3919
+ function J(e) {
3903
3920
  return e === void 0 || e.trim() === "" ? NaN : Number(e);
3904
3921
  }
3905
- function J(e) {
3922
+ function Y(e) {
3906
3923
  let t = e.trim();
3907
3924
  if (!t) return null;
3908
3925
  let n = Number(t);
3909
- if (Number.isFinite(n) && n > 0) return n < 0xe8d4a51000 ? n * 1e3 : n;
3926
+ if (Number.isFinite(n) && n > 0) return g(n);
3910
3927
  let r = Date.parse(t);
3911
3928
  return Number.isFinite(r) ? r : null;
3912
3929
  }
@@ -3943,19 +3960,19 @@ var vr = class {
3943
3960
  this.host.removeEventListener("dragenter", this.bound.dragenter), this.host.removeEventListener("dragover", this.bound.dragover), this.host.removeEventListener("dragleave", this.bound.dragleave), this.host.removeEventListener("drop", this.bound.drop), this.hideOverlay();
3944
3961
  }
3945
3962
  onDragEnter(e) {
3946
- Y(e) && (e.preventDefault(), this.depth++, this.showOverlay());
3963
+ X(e) && (e.preventDefault(), this.depth++, this.showOverlay());
3947
3964
  }
3948
3965
  onDragOver(e) {
3949
- Y(e) && (e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = "copy"));
3966
+ X(e) && (e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = "copy"));
3950
3967
  }
3951
3968
  onDragLeave(e) {
3952
- Y(e) && (this.depth = Math.max(0, this.depth - 1), this.depth === 0 && this.hideOverlay());
3969
+ X(e) && (this.depth = Math.max(0, this.depth - 1), this.depth === 0 && this.hideOverlay());
3953
3970
  }
3954
3971
  async onDrop(e) {
3955
3972
  e.preventDefault(), this.depth = 0, this.hideOverlay();
3956
3973
  let t = e.dataTransfer?.files?.[0];
3957
3974
  if (t) try {
3958
- let e = lr(await t.text());
3975
+ let e = ur(await t.text());
3959
3976
  if (e.data.length === 0) throw Error(`No valid OHLCV rows found in "${t.name}"`);
3960
3977
  this.callbacks.onData(e.data, e, t);
3961
3978
  } catch (e) {
@@ -3986,12 +4003,12 @@ var vr = class {
3986
4003
  this.overlay?.remove(), this.overlay = null;
3987
4004
  }
3988
4005
  };
3989
- function Y(e) {
4006
+ function X(e) {
3990
4007
  return e.dataTransfer?.types?.includes("Files") ?? !1;
3991
4008
  }
3992
4009
  //#endregion
3993
4010
  //#region src/state/layoutStorage.ts
3994
- function X(e) {
4011
+ function Z(e) {
3995
4012
  let t = {
3996
4013
  id: e.id,
3997
4014
  name: e.name,
@@ -3999,11 +4016,11 @@ function X(e) {
3999
4016
  };
4000
4017
  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;
4001
4018
  }
4002
- var Z = (e, t) => t.updatedAt - e.updatedAt;
4019
+ var yr = (e, t) => t.updatedAt - e.updatedAt;
4003
4020
  function Q(e) {
4004
4021
  if (typeof e != "object" || !e) return null;
4005
4022
  let t = e;
4006
- return typeof t.id != "string" || !t.id || typeof t.name != "string" || typeof t.updatedAt != "number" || !Number.isFinite(t.updatedAt) ? null : X({
4023
+ return typeof t.id != "string" || !t.id || typeof t.name != "string" || typeof t.updatedAt != "number" || !Number.isFinite(t.updatedAt) ? null : Z({
4007
4024
  id: t.id,
4008
4025
  name: t.name,
4009
4026
  updatedAt: t.updatedAt,
@@ -4012,17 +4029,17 @@ function Q(e) {
4012
4029
  kind: typeof t.kind == "string" ? t.kind : void 0
4013
4030
  });
4014
4031
  }
4015
- function yr(e) {
4032
+ function br(e) {
4016
4033
  let t = Q(e), n = t ? e.content : void 0;
4017
4034
  return t && typeof n == "string" ? {
4018
4035
  ...t,
4019
4036
  content: n
4020
4037
  } : null;
4021
4038
  }
4022
- function br(e = []) {
4039
+ function xr(e = []) {
4023
4040
  let t = new Map(e.map((e) => [e.id, { ...e }]));
4024
4041
  return {
4025
- list: () => [...t.values()].map(X).sort(Z),
4042
+ list: () => [...t.values()].map(Z).sort(yr),
4026
4043
  load: (e) => {
4027
4044
  let n = t.get(e);
4028
4045
  return n ? { ...n } : null;
@@ -4035,7 +4052,7 @@ function br(e = []) {
4035
4052
  }
4036
4053
  };
4037
4054
  }
4038
- function xr(e = "tcw:layouts:") {
4055
+ function Sr(e = "tcw:layouts:") {
4039
4056
  let t = `${e}index`, n = (t) => `${e}item:${t}`, r = () => {
4040
4057
  let e;
4041
4058
  try {
@@ -4046,7 +4063,7 @@ function xr(e = "tcw:layouts:") {
4046
4063
  return Array.isArray(e) ? e.map(Q).filter((e) => e !== null) : [];
4047
4064
  }, i = (e) => localStorage.setItem(t, JSON.stringify(e));
4048
4065
  return {
4049
- list: () => r().sort(Z),
4066
+ list: () => r().sort(yr),
4050
4067
  load: (e) => {
4051
4068
  let t = r().find((t) => t.id === e), i = t ? localStorage.getItem(n(e)) : null;
4052
4069
  return t && i !== null ? {
@@ -4055,7 +4072,7 @@ function xr(e = "tcw:layouts:") {
4055
4072
  } : null;
4056
4073
  },
4057
4074
  save: (e) => {
4058
- localStorage.setItem(n(e.id), e.content), i([...r().filter((t) => t.id !== e.id), X(e)]);
4075
+ localStorage.setItem(n(e.id), e.content), i([...r().filter((t) => t.id !== e.id), Z(e)]);
4059
4076
  },
4060
4077
  remove: (e) => {
4061
4078
  i(r().filter((t) => t.id !== e)), localStorage.removeItem(n(e));
@@ -4064,14 +4081,14 @@ function xr(e = "tcw:layouts:") {
4064
4081
  }
4065
4082
  //#endregion
4066
4083
  //#region src/state/LayoutSession.ts
4067
- var Sr = 80;
4084
+ var Cr = 80;
4068
4085
  function $(e) {
4069
4086
  return e.replace(/\s+/g, " ").trim().slice(0, 80).trim() || null;
4070
4087
  }
4071
- function Cr() {
4088
+ function wr() {
4072
4089
  return globalThis.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
4073
4090
  }
4074
- function wr(e) {
4091
+ function Tr(e) {
4075
4092
  let { id: t, name: n, symbol: r, timeframe: i, updatedAt: a, kind: o } = e;
4076
4093
  return {
4077
4094
  id: t,
@@ -4082,7 +4099,7 @@ function wr(e) {
4082
4099
  ...o === void 0 ? {} : { kind: o }
4083
4100
  };
4084
4101
  }
4085
- var Tr = class {
4102
+ var Er = class {
4086
4103
  currentLayout = null;
4087
4104
  savedContent = null;
4088
4105
  dirty = !1;
@@ -4098,7 +4115,7 @@ var Tr = class {
4098
4115
  now;
4099
4116
  newId;
4100
4117
  constructor(e, t, n = {}) {
4101
- 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 ?? Cr;
4118
+ 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 ?? wr;
4102
4119
  }
4103
4120
  current() {
4104
4121
  return this.currentLayout;
@@ -4128,7 +4145,7 @@ var Tr = class {
4128
4145
  }
4129
4146
  open(e) {
4130
4147
  return this.queue(async () => {
4131
- let t = yr(await this.storage.load(e));
4148
+ let t = br(await this.storage.load(e));
4132
4149
  if (!t || t.id !== e || (t.kind ?? "chart") !== this.kind || this.destroyed) return !1;
4133
4150
  this.cancelTimer(), this.applying++;
4134
4151
  try {
@@ -4138,13 +4155,13 @@ var Tr = class {
4138
4155
  } finally {
4139
4156
  this.applying--;
4140
4157
  }
4141
- return this.cancelTimer(), this.currentLayout = wr(t), this.savedContent = this.host.capture().content, this.dirty = !1, this.notify(), !0;
4158
+ return this.cancelTimer(), this.currentLayout = Tr(t), this.savedContent = this.host.capture().content, this.dirty = !1, this.notify(), !0;
4142
4159
  });
4143
4160
  }
4144
4161
  rename(e, t) {
4145
4162
  let n = $(t);
4146
4163
  return n ? this.queue(async () => {
4147
- let t = yr(await this.storage.load(e));
4164
+ let t = br(await this.storage.load(e));
4148
4165
  !t || t.id !== e || (await this.storage.save({
4149
4166
  ...t,
4150
4167
  name: n
@@ -4222,7 +4239,7 @@ var Tr = class {
4222
4239
  content: n.content
4223
4240
  };
4224
4241
  await this.storage.save(r);
4225
- let i = wr(r);
4242
+ let i = Tr(r);
4226
4243
  return this.currentLayout = i, this.savedContent = n.content, this.dirty = !1, this.notify(), i;
4227
4244
  }
4228
4245
  forget() {
@@ -4243,6 +4260,6 @@ var Tr = class {
4243
4260
  }
4244
4261
  };
4245
4262
  //#endregion
4246
- export { Kt as C, B as S, H as _, br as a, an as b, Vn as c, Tn as d, wn as f, xn as g, bn as h, xr as i, Mn as l, Cn as m, Sr as n, vr as o, Sn as p, $ as r, lr as s, Tr as t, En as u, fn as v, nn as x, sn as y };
4263
+ export { Jt as C, B as S, H as _, xr as a, sn as b, Hn as c, Dn as d, En as f, Cn as g, Sn as h, Sr as i, Nn as l, Tn as m, Cr as n, vr as o, wn as p, $ as r, ur as s, Er as t, On as u, mn as v, an as x, ln as y };
4247
4264
 
4248
- //# sourceMappingURL=LayoutSession-CrMUvvtP.js.map
4265
+ //# sourceMappingURL=LayoutSession-BE7ZZGLi.js.map