@tradecanvas/chart 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +858 -828
  3. package/dist/Chart.d.ts +124 -1
  4. package/dist/Chart.d.ts.map +1 -1
  5. package/dist/DragDropImporter-C5kgfbET.cjs +2 -0
  6. package/dist/DragDropImporter-C5kgfbET.cjs.map +1 -0
  7. package/dist/{DragDropImporter-cURSpfUb.js → DragDropImporter-Dd9Mud5J.js} +376 -160
  8. package/dist/DragDropImporter-Dd9Mud5J.js.map +1 -0
  9. package/dist/PaneManager.d.ts.map +1 -1
  10. package/dist/charts/ChartTypeStrategy.d.ts +6 -0
  11. package/dist/charts/ChartTypeStrategy.d.ts.map +1 -1
  12. package/dist/grid/ChartGrid.d.ts +1 -0
  13. package/dist/grid/ChartGrid.d.ts.map +1 -1
  14. package/dist/index.cjs +1 -1
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.d.ts +2 -0
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +70 -85
  19. package/dist/index.js.map +1 -1
  20. package/dist/widget/ChartWidget.d.ts +71 -7
  21. package/dist/widget/ChartWidget.d.ts.map +1 -1
  22. package/dist/widget/WidgetCommandPalette.d.ts +3 -1
  23. package/dist/widget/WidgetCommandPalette.d.ts.map +1 -1
  24. package/dist/widget/WidgetDrawingSidebar.d.ts +12 -0
  25. package/dist/widget/WidgetDrawingSidebar.d.ts.map +1 -1
  26. package/dist/widget/WidgetGoToDate.d.ts +45 -0
  27. package/dist/widget/WidgetGoToDate.d.ts.map +1 -0
  28. package/dist/widget/WidgetHotkeySheet.d.ts +3 -1
  29. package/dist/widget/WidgetHotkeySheet.d.ts.map +1 -1
  30. package/dist/widget/WidgetIndicatorLegend.d.ts +68 -0
  31. package/dist/widget/WidgetIndicatorLegend.d.ts.map +1 -0
  32. package/dist/widget/WidgetLoadingOverlay.d.ts.map +1 -1
  33. package/dist/widget/WidgetReplayBar.d.ts +37 -7
  34. package/dist/widget/WidgetReplayBar.d.ts.map +1 -1
  35. package/dist/widget/WidgetSettings.d.ts +13 -1
  36. package/dist/widget/WidgetSettings.d.ts.map +1 -1
  37. package/dist/widget/WidgetStatusBar.d.ts +16 -1
  38. package/dist/widget/WidgetStatusBar.d.ts.map +1 -1
  39. package/dist/widget/WidgetSymbolSearch.d.ts +3 -1
  40. package/dist/widget/WidgetSymbolSearch.d.ts.map +1 -1
  41. package/dist/widget/WidgetToolbar.d.ts +12 -3
  42. package/dist/widget/WidgetToolbar.d.ts.map +1 -1
  43. package/dist/widget/WidgetTooltip.d.ts +43 -0
  44. package/dist/widget/WidgetTooltip.d.ts.map +1 -0
  45. package/dist/widget/escapeHtml.d.ts +3 -0
  46. package/dist/widget/escapeHtml.d.ts.map +1 -0
  47. package/dist/widget/i18n.d.ts +26 -0
  48. package/dist/widget/i18n.d.ts.map +1 -1
  49. package/dist/widget/iconSet.d.ts +26 -0
  50. package/dist/widget/iconSet.d.ts.map +1 -0
  51. package/dist/widget/icons.d.ts +5 -0
  52. package/dist/widget/icons.d.ts.map +1 -1
  53. package/dist/widget/index.cjs +3035 -2561
  54. package/dist/widget/index.cjs.map +1 -1
  55. package/dist/widget/index.d.ts +3 -0
  56. package/dist/widget/index.d.ts.map +1 -1
  57. package/dist/widget/index.js +1546 -585
  58. package/dist/widget/index.js.map +1 -1
  59. package/dist/widget/legendValues.d.ts +14 -0
  60. package/dist/widget/legendValues.d.ts.map +1 -0
  61. package/dist/widget/types.d.ts +34 -8
  62. package/dist/widget/types.d.ts.map +1 -1
  63. package/dist/widget/widgetConfig.d.ts +1 -5
  64. package/dist/widget/widgetConfig.d.ts.map +1 -1
  65. package/dist/widget/widgetTimeframes.d.ts +20 -0
  66. package/dist/widget/widgetTimeframes.d.ts.map +1 -0
  67. package/package.json +3 -3
  68. package/dist/DragDropImporter-BazeSQPD.cjs +0 -2
  69. package/dist/DragDropImporter-BazeSQPD.cjs.map +0 -1
  70. package/dist/DragDropImporter-cURSpfUb.js.map +0 -1
@@ -1,7 +1,7 @@
1
1
  import { DARK_THEME as e, DEFAULT_PANEL_HEIGHT as t, LIGHT_THEME as n, LayerType as r, MIN_PANEL_HEIGHT as i, PRICE_AXIS_WIDTH as a, TIME_AXIS_HEIGHT as o, autoPricePrecision as s, computePriceLimits as c, formatPrice as l, mergeBar as u, setLocale as d, timeframeToMs as f } from "@tradecanvas/commons";
2
- import { AlertDragHandler as p, AlertManager as m, Animator as ee, AreaRenderer as te, AxisDragHandler as ne, BarCountdown as re, BarRenderer as ie, BaselineRenderer as ae, CandlestickRenderer as h, ChartLegend as oe, ChartStateManager as g, CompareRenderer as se, CrosshairHandler as ce, CrosshairTooltip as le, CurrentPriceLine as ue, DataExporter as _, DepthHeatmapRenderer as de, DrawingManager as fe, DrawingRenderer as pe, EquivolumeRenderer as me, EventBus as he, GridRenderer as ge, HLCAreaRenderer as _e, HollowCandleRenderer as ve, IndicatorEngine as v, InteractionManager as ye, KagiRenderer as be, KeyboardHandler as xe, LineRenderer as Se, LineWithMarkersRenderer as Ce, MarketProfileRenderer as we, MeasureOverlay as Te, PanHandler as Ee, PaneResizeHandler as De, PeriodLevelsRenderer as Oe, PinnedTooltip as ke, PivotMarkersRenderer as Ae, PointAndFigureRenderer as je, PriceAxis as Me, RenderEngine as Ne, RenkoRenderer as y, ReplayManager as b, Screenshot as x, SelectionBoxOverlay as Pe, SessionBreaks as Fe, SessionShading as Ie, SignalMarkerManager as Le, StepLineRenderer as Re, StreamManager as ze, TimeAxis as Be, TradeZoneManager as Ve, TradingManager as He, TradingRenderer as Ue, UndoRedoManager as We, Viewport as Ge, VolumeCandleRenderer as Ke, VolumeProfileRenderer as qe, VolumeRenderer as Je, Watermark as Ye, ZoomHandler as Xe, barTimeStep as Ze, findDominantSwing as Qe, registerBuiltInDrawingTools as $e, registerBuiltInIndicators as S, timestampToBarIndex as C, toHeikinAshi as et, toKagi as tt, toLineBreak as nt, toPointAndFigure as rt, toRangeBars as it, toRenko as at, xToBarIndex as ot } from "@tradecanvas/core";
2
+ import { AlertDragHandler as p, AlertManager as m, Animator as ee, AreaRenderer as te, AxisDragHandler as ne, BarCountdown as re, BarRenderer as ie, BaselineRenderer as ae, CandlestickRenderer as h, ChartLegend as oe, ChartStateManager as g, CompareRenderer as se, CrosshairHandler as ce, CrosshairTooltip as le, CurrentPriceLine as ue, DataExporter as _, DepthHeatmapRenderer as de, DrawingManager as fe, DrawingRenderer as pe, EquivolumeRenderer as me, EventBus as he, GridRenderer as ge, HLCAreaRenderer as _e, HollowCandleRenderer as ve, IndicatorEngine as v, InteractionManager as ye, KagiRenderer as be, KeyboardHandler as xe, LineRenderer as Se, LineWithMarkersRenderer as Ce, MarketProfileRenderer as we, MeasureOverlay as Te, PanHandler as Ee, PaneResizeHandler as De, PeriodLevelsRenderer as Oe, PinnedTooltip as ke, PivotMarkersRenderer as Ae, PointAndFigureRenderer as je, PriceAxis as Me, RenderEngine as Ne, RenkoRenderer as y, ReplayManager as b, Screenshot as x, SelectionBoxOverlay as Pe, SessionBreaks as Fe, SessionShading as Ie, SignalMarkerManager as Le, StepLineRenderer as Re, StreamManager as ze, TimeAxis as Be, TradeZoneManager as Ve, TradingManager as He, TradingRenderer as Ue, UndoRedoManager as We, Viewport as Ge, VolumeCandleRenderer as Ke, VolumeProfileRenderer as qe, VolumeRenderer as Je, Watermark as Ye, ZoomHandler as Xe, barTimeStepMs as Ze, findDominantSwing as Qe, rangePresetStart as $e, registerBuiltInDrawingTools as et, registerBuiltInIndicators as S, timestampToBarIndex as C, toHeikinAshi as tt, toKagi as nt, toLineBreak as rt, toPointAndFigure as it, toRangeBars as at, toRenko as ot, xToBarIndex as st } from "@tradecanvas/core";
3
3
  //#region src/charts/ChartTypeStrategy.ts
4
- function st(e) {
4
+ function ct(e) {
5
5
  switch (e) {
6
6
  case "candlestick":
7
7
  case "heikinAshi":
@@ -23,44 +23,58 @@ function st(e) {
23
23
  default: return new h();
24
24
  }
25
25
  }
26
- function ct(e, t) {
26
+ function lt(e, t) {
27
27
  if (t.length === 0) return t;
28
28
  switch (e) {
29
- case "heikinAshi": return et(t);
30
- case "renko": return at(t, {
29
+ case "heikinAshi": return tt(t);
30
+ case "renko": return ot(t, {
31
31
  brickSize: 0,
32
32
  useATR: !0,
33
33
  atrPeriod: 14
34
34
  });
35
- case "lineBreak": return nt(t, 3);
36
- case "kagi": return tt(t, 4);
37
- case "pointAndFigure": return rt(t, w(t) * .01, 3);
38
- case "rangeBars": return it(t, { rangeSize: w(t) * .005 });
35
+ case "lineBreak": return rt(t, 3);
36
+ case "kagi": return nt(t, 4);
37
+ case "pointAndFigure": return it(t, T(t) * .01, 3);
38
+ case "rangeBars": return at(t, { rangeSize: T(t) * .005 });
39
39
  default: return t;
40
40
  }
41
41
  }
42
42
  function w(e) {
43
+ switch (e) {
44
+ case "heikinAshi":
45
+ case "renko":
46
+ case "lineBreak":
47
+ case "kagi":
48
+ case "pointAndFigure":
49
+ case "rangeBars": return !0;
50
+ default: return !1;
51
+ }
52
+ }
53
+ function ut(e) {
54
+ return e !== "heikinAshi" && w(e);
55
+ }
56
+ function T(e) {
43
57
  let t = 0;
44
58
  for (let n of e) t += n.close;
45
59
  return t / e.length;
46
60
  }
47
- function lt(e, t) {
61
+ function dt(e, t) {
48
62
  let n = t?.(e);
49
- return n ? n.createRenderer() : st(e);
63
+ return n ? n.createRenderer() : ct(e);
50
64
  }
51
- function ut(e, t, n) {
65
+ function ft(e, t, n) {
52
66
  if (t.length === 0) return t;
53
67
  let r = n?.(e);
54
- return r?.transform ? r.transform(t) : ct(e, t);
68
+ return r?.transform ? r.transform(t) : lt(e, t);
55
69
  }
56
70
  //#endregion
57
71
  //#region src/charts/IndicatorPriceRange.ts
58
- var T = {
72
+ var E = {
59
73
  min: 0,
60
74
  max: 100
61
- }, E = .1;
62
- function dt(e, t, n) {
63
- if (!e) return { ...T };
75
+ }, D = .1;
76
+ function pt(e, t, n) {
77
+ if (!e) return { ...E };
64
78
  let r = Infinity, i = -Infinity;
65
79
  if (e.series) {
66
80
  let a = Math.min(n, e.series.length - 1);
@@ -81,16 +95,16 @@ function dt(e, t, n) {
81
95
  a++;
82
96
  }
83
97
  }
84
- if (r === Infinity) return { ...T };
98
+ if (r === Infinity) return { ...E };
85
99
  let a = i - r || 1;
86
100
  return {
87
- min: r - a * E,
88
- max: i + a * E
101
+ min: r - a * D,
102
+ max: i + a * D
89
103
  };
90
104
  }
91
105
  //#endregion
92
106
  //#region src/state/AutoSaveScheduler.ts
93
- var ft = class {
107
+ var mt = class {
94
108
  timer = null;
95
109
  delayMs = 0;
96
110
  key = null;
@@ -120,15 +134,15 @@ var ft = class {
120
134
  };
121
135
  //#endregion
122
136
  //#region src/DataManager.ts
123
- function D(e) {
137
+ function O(e) {
124
138
  if (!e || typeof e.time != "number") return !1;
125
139
  let { open: t, high: n, low: r, close: i } = e;
126
140
  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));
127
141
  }
128
- function pt(e) {
142
+ function ht(e) {
129
143
  return e.volume !== void 0 && e.high >= e.open && e.high >= e.close && e.low <= e.open && e.low <= e.close;
130
144
  }
131
- function O(e) {
145
+ function k(e) {
132
146
  return {
133
147
  ...e,
134
148
  high: Math.max(e.open, e.high, e.low, e.close),
@@ -136,7 +150,7 @@ function O(e) {
136
150
  volume: e.volume === void 0 ? 0 : Math.max(0, e.volume)
137
151
  };
138
152
  }
139
- var k = class {
153
+ var A = class {
140
154
  data = [];
141
155
  getData() {
142
156
  return this.data;
@@ -145,16 +159,16 @@ var k = class {
145
159
  let t = [];
146
160
  for (let n = 0; n < e.length; n++) {
147
161
  let r = e[n];
148
- D(r) && t.push(pt(r) ? r : O(r));
162
+ O(r) && t.push(ht(r) ? r : k(r));
149
163
  }
150
164
  this.data = t;
151
165
  }
152
166
  appendBar(e) {
153
- D(e) && this.data.push(O(e));
167
+ O(e) && this.data.push(k(e));
154
168
  }
155
169
  updateLastBar(e) {
156
- if (!D(e)) return;
157
- let t = O(e);
170
+ if (!O(e)) return;
171
+ let t = k(e);
158
172
  if (this.data.length === 0) {
159
173
  this.data.push(t);
160
174
  return;
@@ -170,7 +184,7 @@ var k = class {
170
184
  clear() {
171
185
  this.data = [];
172
186
  }
173
- }, A = class {
187
+ }, j = class {
174
188
  theme;
175
189
  constructor(t) {
176
190
  !t || t === "dark" ? this.theme = { ...e } : t === "light" ? this.theme = { ...n } : this.theme = { ...t };
@@ -181,7 +195,7 @@ var k = class {
181
195
  setTheme(t) {
182
196
  t === "dark" ? this.theme = { ...e } : t === "light" ? this.theme = { ...n } : this.theme = { ...t };
183
197
  }
184
- }, j = 200, M = 80, N = class {
198
+ }, M = 200, N = 80, P = class {
185
199
  panels = [];
186
200
  containerWidth = 0;
187
201
  containerHeight = 0;
@@ -194,8 +208,8 @@ var k = class {
194
208
  this.panels.push({
195
209
  id: e,
196
210
  position: n,
197
- size: r ?? (a ? j : t),
198
- minSize: a ? M : i,
211
+ size: r ?? (a ? M : t),
212
+ minSize: a ? N : i,
199
213
  content: {
200
214
  type: "indicator",
201
215
  indicatorInstanceId: e
@@ -209,7 +223,7 @@ var k = class {
209
223
  let r = this.panels.find((t) => t.id === e);
210
224
  if (r) {
211
225
  let e = r.position === "left" || r.position === "right", a = n === "left" || n === "right";
212
- r.position = n, e !== a && (r.size = a ? j : t, r.minSize = a ? M : i);
226
+ r.position = n, e !== a && (r.size = a ? M : t, r.minSize = a ? N : i);
213
227
  }
214
228
  }
215
229
  setPanelSize(e, t) {
@@ -313,8 +327,8 @@ var k = class {
313
327
  getMainChartRect() {
314
328
  return this.resolve().mainChartRect;
315
329
  }
316
- }, mt = 14, ht = 14, gt = 22, P = 4;
317
- function _t(e) {
330
+ }, gt = 14, _t = 14, vt = 22, F = 4;
331
+ function yt(e) {
318
332
  let { min: t, max: n, lastPrice: r, locale: i, fontFamily: o, fontSizeSmall: c, measure: u } = e, d = s(t, n), f = e.tagPrecision ?? d, p = r === null ? [t, n] : [
319
333
  t,
320
334
  n,
@@ -323,14 +337,14 @@ function _t(e) {
323
337
  for (let e of p) {
324
338
  if (!Number.isFinite(e)) continue;
325
339
  let t = l(e, d, i), n = l(e, f, i);
326
- m = Math.max(m, u(t, `500 ${c}px ${o}`) + mt, u(n, `bold 11px ${o}`) + ht, u(n, `600 ${c}px ${o}`) + gt);
340
+ m = Math.max(m, u(t, `500 ${c}px ${o}`) + gt, u(n, `bold 11px ${o}`) + _t, u(n, `600 ${c}px ${o}`) + vt);
327
341
  }
328
- return m <= a ? a : Math.ceil(m / P) * P;
342
+ return m <= a ? a : Math.ceil(m / F) * F;
329
343
  }
330
- function vt(e, t) {
344
+ function bt(e, t) {
331
345
  return t > e || t <= e - 12 ? t : e;
332
346
  }
333
- var yt = class {
347
+ var xt = class {
334
348
  netY = 0;
335
349
  travelX = 0;
336
350
  engaged = !1;
@@ -346,11 +360,11 @@ var yt = class {
346
360
  }
347
361
  return this.engaged;
348
362
  }
349
- }, bt = 1;
350
- function F(e, t) {
363
+ }, St = 1;
364
+ function I(e, t) {
351
365
  return e.filter((e) => (e.descriptor.layer ?? "overlay") === t);
352
366
  }
353
- function I(e) {
367
+ function L(e) {
354
368
  switch (e.kind) {
355
369
  case "indicator": return `indicator:${e.plugin.descriptor.id}`;
356
370
  case "drawing": return `drawing:${e.plugin.descriptor.type}`;
@@ -360,25 +374,25 @@ function I(e) {
360
374
  }
361
375
  //#endregion
362
376
  //#region src/plugins/registry.ts
363
- var L = /* @__PURE__ */ new Map();
364
- function xt(e) {
365
- L.set(I(e), e);
377
+ var R = /* @__PURE__ */ new Map();
378
+ function Ct(e) {
379
+ R.set(L(e), e);
366
380
  }
367
- function St(e) {
368
- return L.delete(e);
381
+ function wt(e) {
382
+ return R.delete(e);
369
383
  }
370
- function R() {
371
- return [...L.values()];
384
+ function z() {
385
+ return [...R.values()];
372
386
  }
373
- function Ct() {
374
- L.clear();
387
+ function Tt() {
388
+ R.clear();
375
389
  }
376
390
  //#endregion
377
391
  //#region src/plugins/PluginManager.ts
378
- var z = class {
392
+ var B = class {
379
393
  plugins = /* @__PURE__ */ new Map();
380
394
  constructor(e, t = {}) {
381
- if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of R()) this.add(e);
395
+ if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of z()) this.add(e);
382
396
  for (let e of t.plugins ?? []) this.add(e);
383
397
  }
384
398
  register(e) {
@@ -406,20 +420,20 @@ var z = class {
406
420
  return e;
407
421
  }
408
422
  add(e) {
409
- this.plugins.set(I(e), e), e.kind === "indicator" && this.indicatorEngine.register(e.plugin);
423
+ this.plugins.set(L(e), e), e.kind === "indicator" && this.indicatorEngine.register(e.plugin);
410
424
  }
411
- }, B = {
425
+ }, V = {
412
426
  orderPlace: (e, t) => e.placeOrder(t),
413
427
  orderModify: (e, t) => e.modifyOrder(t),
414
428
  orderCancel: (e, t) => e.cancelOrder(t),
415
429
  positionModify: (e, t) => e.modifyPosition(t),
416
430
  positionClose: (e, t) => e.closePosition(t)
417
431
  };
418
- function wt(e, t) {
432
+ function Et(e, t) {
419
433
  let n = [], r = (e) => t.setOrders(e.data ?? []), i = (e) => t.setPositions(e.data ?? []), a = (e) => t.onError(e.data ?? { message: "Execution error" });
420
434
  e.on("orders", r), e.on("positions", i), e.on("error", a), n.push(() => e.off("orders", r), () => e.off("positions", i), () => e.off("error", a));
421
- for (let r of Object.keys(B)) {
422
- let i = B[r], a = t.onIntent(r, (n) => {
435
+ for (let r of Object.keys(V)) {
436
+ let i = V[r], a = t.onIntent(r, (n) => {
423
437
  Promise.resolve(i(e, n)).catch((e) => t.onError({
424
438
  message: `Execution command failed: ${r}`,
425
439
  cause: e
@@ -433,8 +447,8 @@ function wt(e, t) {
433
447
  }
434
448
  //#endregion
435
449
  //#region src/Chart.ts
436
- var Tt = class {
437
- static version = "1.3.0";
450
+ var Dt = 0xe8d4a51000, Ot = class {
451
+ static version = "1.4.0";
438
452
  engine;
439
453
  viewport;
440
454
  dataManager;
@@ -452,6 +466,7 @@ var Tt = class {
452
466
  execTeardown = null;
453
467
  autoScrollOnNewBar = !0;
454
468
  displayDataCache = null;
469
+ indicatorUpdateFrom = null;
455
470
  resolvedLayoutCache = null;
456
471
  panelInfoCache = null;
457
472
  renderScheduled = !1;
@@ -465,6 +480,8 @@ var Tt = class {
465
480
  chartLegend;
466
481
  watermark;
467
482
  barCountdown;
483
+ unrestoredIndicators = [];
484
+ displayTzOffset = null;
468
485
  sessionBreaks;
469
486
  sessionShading;
470
487
  compareRenderer;
@@ -483,8 +500,9 @@ var Tt = class {
483
500
  replayManager;
484
501
  replayBarUnsub = null;
485
502
  replaySeeking = !1;
503
+ replaySession = null;
486
504
  undoRedoManager;
487
- autoSaveScheduler = new ft((e) => this.saveState(e));
505
+ autoSaveScheduler = new mt((e) => this.saveState(e));
488
506
  animator;
489
507
  crosshairTooltip;
490
508
  pinnedTooltip;
@@ -500,6 +518,8 @@ var Tt = class {
500
518
  container;
501
519
  currentPriceLine;
502
520
  numberLocale;
521
+ marketPricePrecision = null;
522
+ paneTitles = !0;
503
523
  defaultAutoScale;
504
524
  keyboardHandler = null;
505
525
  onWindowKeyDown = null;
@@ -538,11 +558,11 @@ var Tt = class {
538
558
  logScale: n.logScale ?? !0,
539
559
  timeframes: n.timeframes ?? [],
540
560
  defaultTimeframeFavorites: n.defaultTimeframeFavorites ?? []
541
- }, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", this.dataManager = new k(), this.themeManager = new A(t.theme), this.layoutManager = new N(), this.indicatorEngine = new v(), this.pluginManager = new z(this.indicatorEngine, { plugins: t.plugins }), this.eventBus = new he(), S(this.indicatorEngine), this.drawingManager = new fe(), $e(this.drawingManager), this.drawingRenderer = new pe(this.drawingManager), this.drawingManager.setRequestRender(() => {
561
+ }, e.style.position = "relative", e.style.overflow = "hidden", e.tabIndex = 0, e.style.outline = "none", this.dataManager = new A(), this.themeManager = new j(t.theme), this.layoutManager = new P(), this.indicatorEngine = new v(), this.pluginManager = new B(this.indicatorEngine, { plugins: t.plugins }), this.eventBus = new he(), S(this.indicatorEngine), this.drawingManager = new fe(), et(this.drawingManager), this.drawingRenderer = new pe(this.drawingManager), this.drawingManager.setRequestRender(() => {
542
562
  this.syncRenderContext(), this.engine.requestRender(r.Overlay), this.scheduleAutoSave();
543
563
  }), this.drawingManager.setEventCallback((e, t) => {
544
564
  this.eventBus.emit(e, t);
545
- }), this.undoRedoManager = new We(), this.drawingManager.setUndoRedoManager(this.undoRedoManager), this.drawingManager.setDataGetter(() => this.dataManager.getData()), this.drawingManager.setDisplayDataGetter(() => this.getDisplayData()), t.crosshair?.mode === "magnet" && this.drawingManager.setMagnetMode("magnet"), this.tradingManager = new He({
565
+ }), this.drawingManager.setToolFilter((e) => this.features.drawings && (this.features.drawingTools.length === 0 || this.features.drawingTools.includes(e))), this.undoRedoManager = new We(), this.drawingManager.setUndoRedoManager(this.undoRedoManager), 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 He({
546
566
  enabled: this.features.trading,
547
567
  contextMenu: { enabled: this.features.tradingContextMenu }
548
568
  }), this.tradingRenderer = new Ue(this.tradingManager), this.tradingManager.setContainer(e), this.tradingManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradingManager.setEventCallback((e, t) => {
@@ -559,27 +579,25 @@ var Tt = class {
559
579
  }, this.chartRenderer = this.createChartRenderer(t.chartType), this.gridRenderer = new ge(), t.grid?.visible === !1 && this.gridRenderer.setVisible(!1), this.priceAxis = new Me(), this.priceAxis.setLocale(this.numberLocale), this.timeAxis = new Be(), this.crosshairHandler = new ce(), this.crosshairHandler.setLocale(this.numberLocale), t.crosshair?.mode && this.crosshairHandler.setMode(t.crosshair.mode), this.crosshairHandler.setCallback((e, t) => {
560
580
  if (e !== null && t) {
561
581
  let n = this.dataManager.getData(), r = e < n.length ? n[e] : void 0;
562
- if (this.chartLegend.setHoverBar(r ?? null), r && this.features.crosshairTooltip) {
563
- let i = this.viewport.getState();
564
- this.crosshairTooltip.show(t, r, this.themeManager.getTheme(), this.cachedContainerSize(), {
565
- prevClose: e > 0 ? n[e - 1]?.close : void 0,
566
- priceRange: i.priceRange,
567
- plot: i.chartRect,
568
- barStepMs: Ze(n)
569
- });
570
- }
571
- this.pinnedTooltip.isPinned() && this.pinnedTooltip.reposition(this.viewport.getState(), r ?? null, e, this.themeManager.getTheme()), this.eventBus.emit("crosshairMove", {
582
+ this.chartLegend.setHoverBar(r ?? null);
583
+ let i = this.viewport.getState(), a = t.y >= i.chartRect.y && t.y <= i.chartRect.y + i.chartRect.height;
584
+ r && a && this.features.crosshairTooltip ? this.crosshairTooltip.show(t, r, this.themeManager.getTheme(), this.cachedContainerSize(), {
585
+ prevClose: e > 0 ? n[e - 1]?.close : void 0,
586
+ priceRange: i.priceRange,
587
+ plot: i.chartRect,
588
+ barStepMs: Ze(n)
589
+ }) : this.crosshairTooltip.hide(), this.pinnedTooltip.isPinned() && this.pinnedTooltip.reposition(this.viewport.getState(), r ?? null, e, this.themeManager.getTheme()), this.eventBus.emit("crosshairMove", {
572
590
  point: t,
573
591
  bar: r,
574
592
  barIndex: e
575
593
  });
576
- } else this.crosshairTooltip.hide(), this.chartLegend.setHoverBar(null);
577
- }), this.chartLegend = new oe(), this.chartLegend.setChartType(t.chartType), this.chartLegend.setLocale(this.numberLocale), this.watermark = new Ye(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new Je(), this.volumeProfile = new qe(), this.marketProfile = new we(), this.depthHeatmap = new de(), this.periodLevels = new Oe(), this.pivotMarkers = new Ae(), this.barCountdown = new re(), this.sessionBreaks = new Fe(), this.sessionBreaks.setLocale(this.numberLocale), this.sessionShading = new Ie(), this.compareRenderer = new se(), t.sessionBreaks ? this.sessionBreaks.setConfig({
594
+ } else this.crosshairTooltip.hide(), this.chartLegend.setHoverBar(null), this.eventBus.emit("crosshairLeave", {});
595
+ }), this.chartLegend = new oe(), this.chartLegend.setChartType(t.chartType), this.chartLegend.setLocale(this.numberLocale), this.watermark = new Ye(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new Je(), this.volumeProfile = new qe(), this.marketProfile = new we(), this.depthHeatmap = new de(), this.periodLevels = new Oe(), this.pivotMarkers = new Ae(), this.barCountdown = new re(), this.barCountdown.setVisible(this.features.barCountdown), this.sessionBreaks = new Fe(), this.sessionBreaks.setLocale(this.numberLocale), this.sessionShading = new Ie(), this.compareRenderer = new se(), t.sessionBreaks ? this.sessionBreaks.setConfig({
578
596
  visible: t.sessionBreaks.visible ?? !0,
579
597
  color: t.sessionBreaks.color,
580
598
  lineStyle: t.sessionBreaks.lineStyle,
581
599
  lineWidth: t.sessionBreaks.lineWidth
582
- }) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.viewport.setLogScale(!0), this.animator = new ee(), this.crosshairTooltip = new le(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new ke(), this.pinnedTooltip.create(e), this.keyboardHandler = new xe({
600
+ }) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new ee(), this.crosshairTooltip = new le(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new ke(), this.pinnedTooltip.create(e), this.keyboardHandler = new xe({
583
601
  scrollBars: (e) => {
584
602
  let t = this.viewport.getState().barWidth + this.viewport.getState().barSpacing;
585
603
  this.viewport.scrollBy(e * t), this.updateViewportAndRender();
@@ -647,7 +665,7 @@ var Tt = class {
647
665
  }), this.tradeZoneManager.on("removed", (e) => {
648
666
  this.eventBus.emit("tradeZoneRemove", { id: e });
649
667
  }), this.replayManager = new b(), this.measureOverlay = new Te(), this.interactionManager = new ye(e), this.features.panning) {
650
- let e = new yt();
668
+ let e = new xt();
651
669
  this.interactionManager.setPanHandler(new Ee((t, n) => {
652
670
  t && this.viewport.scrollBy(t), e.step(t, n, this.options.autoScale !== !1) && n && (this.options.autoScale = !1, this.viewport.panPriceRange(n)), this.updateViewportAndRender();
653
671
  }, () => e.reset()));
@@ -688,7 +706,7 @@ var Tt = class {
688
706
  x: e.x,
689
707
  y: e.y
690
708
  }), t.length === 0) return;
691
- let n = ot(e.x, this.viewport.getState());
709
+ let n = st(e.x, this.viewport.getState());
692
710
  n < 0 || n >= t.length || this.eventBus.emit("barClick", {
693
711
  bar: t[n],
694
712
  barIndex: n,
@@ -739,29 +757,45 @@ var Tt = class {
739
757
  }), this.interactionManager.attach(), this.syncRenderContext(), this.engine.start();
740
758
  }
741
759
  setData(e) {
742
- this.dataManager.setData(e), this.crosshairHandler.setData(this.dataManager.getData()), this.displayDataCache = null, this.sessionBreaks.invalidateCache(), this.options.autoScale = this.defaultAutoScale, this.alertManager.clearLastValues(), this.indicatorEngine.recalculateAll(this.dataManager.getData()), e.length > 0 && this.currentPriceLine.setPrice(e[e.length - 1].close), this.updateViewportAndRender(!0), this.eventBus.emit("dataUpdate", { length: e.length });
760
+ this.endReplaySession(), this.dataManager.setData(e), this.crosshairHandler.setData(this.dataManager.getData()), this.displayDataCache = null, this.sessionBreaks.invalidateCache(), this.options.autoScale = this.defaultAutoScale, this.alertManager.clearLastValues(), this.recalcIndicators(this.dataManager.getData()), e.length > 0 && this.currentPriceLine.setPrice(e[e.length - 1].close), this.updateViewportAndRender(!0), this.eventBus.emit("dataUpdate", { length: e.length });
743
761
  }
744
762
  appendBar(e) {
763
+ if (this.replaySession) {
764
+ this.replaySession.live.appendBar(e);
765
+ return;
766
+ }
745
767
  let t = this.autoScrollOnNewBar && this.viewport.isAtEnd();
746
768
  this.dataManager.appendBar(e);
747
769
  let n = this.dataManager.getData();
748
- this.crosshairHandler.setData(n), this.displayDataCache = null, this.indicatorEngine.recalculateFrom(n, n.length - 2), this.updateViewportAndRender(t);
770
+ this.crosshairHandler.setData(n), this.displayDataCache = null, this.recalcIndicatorsFrom(n, n.length - 2), this.updateViewportAndRender(t);
749
771
  }
750
772
  appendBars(e) {
751
773
  if (e.length === 0) return;
774
+ if (this.replaySession) {
775
+ for (let t of e) this.replaySession.live.appendBar(t);
776
+ return;
777
+ }
752
778
  let t = this.viewport.isAtEnd(), n = this.dataManager.getLength() - 1;
753
779
  for (let t of e) this.dataManager.appendBar(t);
754
- this.displayDataCache = null, this.indicatorEngine.recalculateFrom(this.dataManager.getData(), n), this.crosshairHandler.setData(this.dataManager.getData()), this.updateViewportAndRender(t);
780
+ this.displayDataCache = null, this.recalcIndicatorsFrom(this.dataManager.getData(), n), this.crosshairHandler.setData(this.dataManager.getData()), this.updateViewportAndRender(t);
755
781
  }
756
782
  updateLastBar(e) {
783
+ if (this.replaySession) {
784
+ this.replaySession.live.updateLastBar(e);
785
+ return;
786
+ }
757
787
  this.dataManager.updateLastBar(e), this.currentPriceLine.setPrice(e.close), this.options.chartType !== "candlestick" && this.options.chartType !== "line" && this.options.chartType !== "area" && this.options.chartType !== "bar" && this.options.chartType !== "hollowCandle" && (this.displayDataCache = null);
758
788
  let t = this.dataManager.getData();
759
- this.indicatorEngine.recalculateFrom(t, t.length - 1), this.scheduleRender();
789
+ this.recalcIndicatorsFrom(t, t.length - 1), this.scheduleRender();
760
790
  }
761
791
  updateLastBarFromTick(e) {
792
+ if (this.replaySession) {
793
+ this.replaySession.live.updateLastBarFromTick(e), Number.isFinite(e.price) && (this.replaySession.price = { price: e.price });
794
+ return;
795
+ }
762
796
  this.dataManager.updateLastBarFromTick(e), this.currentPriceLine.setPrice(e.price), this.options.chartType !== "candlestick" && this.options.chartType !== "line" && this.options.chartType !== "area" && this.options.chartType !== "bar" && this.options.chartType !== "hollowCandle" && (this.displayDataCache = null);
763
797
  let t = this.dataManager.getData();
764
- this.indicatorEngine.recalculateFrom(t, t.length - 1), this.scheduleRender();
798
+ this.recalcIndicatorsFrom(t, t.length - 1), this.scheduleRender();
765
799
  }
766
800
  setChartType(e) {
767
801
  this.options.chartType = e, this.chartRenderer = this.createChartRenderer(e), this.chartLegend.setChartType(e), this.displayDataCache = null, this.updateViewportAndRender(!0);
@@ -772,14 +806,17 @@ var Tt = class {
772
806
  return this.indicatorEngine.getAvailableIndicators().find((t) => t.id === e)?.placement === "panel" ? (this.layoutManager.addPanel(r, n), this.updateViewportAndRender()) : this.engine.requestRender(), this.eventBus.emit("indicatorAdd", {
773
807
  instanceId: r,
774
808
  id: e
775
- }), r;
809
+ }), this.scheduleAutoSave(), r;
776
810
  }
777
811
  updateIndicator(e, t) {
778
- this.indicatorEngine.updateIndicator(e, t, this.dataManager.getData()), this.engine.requestRender();
812
+ this.indicatorEngine.updateIndicator(e, t, this.dataManager.getData()), this.announceIndicatorUpdate(0), this.engine.requestRender(), this.scheduleAutoSave();
779
813
  }
780
814
  removeIndicator(e) {
781
815
  let t = this.layoutManager.getPanels().some((t) => t.id === e);
782
- this.indicatorEngine.removeIndicator(e), this.layoutManager.removePanel(e), this.eventBus.emit("indicatorRemove", { instanceId: e }), t ? this.updateViewportAndRender() : this.engine.requestRender();
816
+ this.indicatorEngine.removeIndicator(e), this.layoutManager.removePanel(e), this.eventBus.emit("indicatorRemove", { instanceId: e }), this.scheduleAutoSave(), t ? this.updateViewportAndRender() : this.engine.requestRender();
817
+ }
818
+ getIndicatorStyle(e) {
819
+ return this.indicatorEngine.getIndicatorStyle(e);
783
820
  }
784
821
  getIndicatorOutput(e) {
785
822
  return this.indicatorEngine.getOutput(e);
@@ -798,7 +835,30 @@ var Tt = class {
798
835
  this.layoutManager.setPanelPosition(e, t), this.engine.requestRender();
799
836
  }
800
837
  setPanelSize(e, t) {
801
- this.layoutManager.setPanelSize(e, t), this.updateViewportAndRender();
838
+ this.layoutManager.setPanelSize(e, t), this.updateViewportAndRender(), this.eventBus.emit("paneResize", {
839
+ instanceId: e,
840
+ size: t
841
+ });
842
+ }
843
+ getIndicatorPanes() {
844
+ return this.buildPanelRenderInfos().map((e) => ({
845
+ instanceId: e.instanceId,
846
+ rect: { ...e.rect }
847
+ }));
848
+ }
849
+ setPaneTitlesVisible(e) {
850
+ this.paneTitles = e, this.engine.requestRender();
851
+ }
852
+ getLegendBottom() {
853
+ let e = this.viewport.getState().chartRect.y;
854
+ return this.features.legend ? e + this.chartLegend.getHeight() : e;
855
+ }
856
+ isTimeAligned() {
857
+ return ut(this.options.chartType) ? !1 : this.getDisplayData().length === this.dataManager.getLength();
858
+ }
859
+ formatPrice(e) {
860
+ let { min: t, max: n } = this.viewport.getState().priceRange;
861
+ return l(e, this.marketPricePrecision ?? s(t, n), this.numberLocale);
802
862
  }
803
863
  setDrawingTool(e) {
804
864
  this.features.drawings && (e && this.features.drawingTools.length > 0 && !this.features.drawingTools.includes(e) || this.drawingManager.setActiveTool(e));
@@ -806,6 +866,18 @@ var Tt = class {
806
866
  getDrawingTool() {
807
867
  return this.drawingManager.getActiveTool();
808
868
  }
869
+ setStayInDrawingMode(e) {
870
+ this.drawingManager.setStayInDrawingMode(e);
871
+ }
872
+ isStayInDrawingMode() {
873
+ return this.drawingManager.isStayInDrawingMode();
874
+ }
875
+ copyDrawings() {
876
+ return this.drawingManager.copySelection();
877
+ }
878
+ pasteDrawings() {
879
+ return this.features.drawings ? this.drawingManager.paste() : [];
880
+ }
809
881
  setDrawingStyle(e) {
810
882
  this.drawingManager.setStyle(e);
811
883
  }
@@ -862,7 +934,7 @@ var Tt = class {
862
934
  return this.undoRedoManager.getState();
863
935
  }
864
936
  setDrawingMagnet(e) {
865
- this.drawingManager.setMagnetMode(e ? "magnet" : "none");
937
+ this.drawingManager.setMagnetMode(e && this.features.drawingMagnet ? "magnet" : "none");
866
938
  }
867
939
  getDrawingMagnet() {
868
940
  return this.drawingManager.getMagnetMode() === "magnet";
@@ -884,6 +956,7 @@ var Tt = class {
884
956
  return t ? this.drawingManager.duplicateDrawing(t) : null;
885
957
  }
886
958
  exportVisibleData(e = "csv", t) {
959
+ if (!this.features.dataExport) return;
887
960
  let n = this.viewport.getState(), r = this.dataManager.getData(), i = Math.max(0, n.visibleRange.from), a = Math.min(r.length - 1, n.visibleRange.to), o = r.slice(i, a + 1);
888
961
  if (e === "json") {
889
962
  let e = _.toJSON(o);
@@ -894,6 +967,7 @@ var Tt = class {
894
967
  }
895
968
  }
896
969
  exportAllData(e = "csv", t) {
970
+ if (!this.features.dataExport) return;
897
971
  let n = this.dataManager.getData();
898
972
  if (e === "json") {
899
973
  let e = _.toJSON(n);
@@ -926,7 +1000,7 @@ var Tt = class {
926
1000
  return this.indicatorEngine.getActiveIndicators();
927
1001
  }
928
1002
  setIndicatorVisible(e, t) {
929
- this.indicatorEngine.setVisible(e, t) !== null && this.updateViewportAndRender();
1003
+ this.indicatorEngine.setVisible(e, t) !== null && (this.updateViewportAndRender(), this.scheduleAutoSave());
930
1004
  }
931
1005
  getIndicatorConfig(e) {
932
1006
  let t = this.indicatorEngine.getIndicatorConfig(e);
@@ -936,7 +1010,7 @@ var Tt = class {
936
1010
  } : null;
937
1011
  }
938
1012
  updateIndicatorStyle(e, t) {
939
- this.indicatorEngine.updateIndicatorStyle(e, t), this.engine.requestRender();
1013
+ this.indicatorEngine.updateIndicatorStyle(e, t), this.engine.requestRender(), this.scheduleAutoSave();
940
1014
  }
941
1015
  setOrders(e) {
942
1016
  this.features.trading && this.tradingManager.setOrders(e);
@@ -979,7 +1053,7 @@ var Tt = class {
979
1053
  this.features.trading && this.tradingManager.setDepthData(e);
980
1054
  }
981
1055
  setCurrentPrice(e, t) {
982
- this.tradingManager.setCurrentPrice(e), this.currentPriceLine.setPrice(e), this.scheduleRender(), this.features.alerts && (this.alertManager.checkPrice(e), this.feedIndicatorAlerts());
1056
+ this.tradingManager.setCurrentPrice(e), this.replaySession ? this.replaySession.price = { price: e } : (this.currentPriceLine.setPrice(e), this.scheduleRender()), this.features.alerts && (this.alertManager.checkPrice(e), this.feedIndicatorAlerts());
983
1057
  }
984
1058
  feedIndicatorAlerts() {
985
1059
  let e = this.alertManager.getAlerts(), t = this.dataManager.getData();
@@ -998,19 +1072,38 @@ var Tt = class {
998
1072
  this.features.trading && this.tradingManager.setConfig(e);
999
1073
  }
1000
1074
  async connect(e) {
1001
- this.disconnectStream(), this.streamManager = new ze(), this.streamManager.on("snapshot", (e) => {
1075
+ this.replayStop(), this.disconnectStream(), this.streamManager = new ze(), this.streamManager.on("snapshot", (e) => {
1076
+ if (this.replaySession) {
1077
+ this.replaySession.live.setData(e);
1078
+ return;
1079
+ }
1002
1080
  this.setData(e);
1003
1081
  }), this.streamManager.on("barClose", (e) => {
1082
+ if (this.replaySession) {
1083
+ this.replaySession.live.appendBar(e);
1084
+ return;
1085
+ }
1004
1086
  let t = this.autoScrollOnNewBar && this.viewport.isAtEnd();
1005
1087
  this.dataManager.appendBar(e);
1006
1088
  let n = this.dataManager.getData();
1007
- this.crosshairHandler.setData(n), this.displayDataCache = null, this.indicatorEngine.recalculateFrom(n, n.length - 2), this.updateViewportAndRender(t);
1089
+ this.crosshairHandler.setData(n), this.displayDataCache = null, this.recalcIndicatorsFrom(n, n.length - 2), this.updateViewportAndRender(t);
1008
1090
  }), this.streamManager.on("barUpdate", (e) => {
1091
+ if (this.replaySession) {
1092
+ this.replaySession.live.updateLastBar(e);
1093
+ return;
1094
+ }
1009
1095
  this.dataManager.updateLastBar(e), this.currentPriceLine.setPrice(e.close);
1010
1096
  let t = this.dataManager.getData();
1011
- this.indicatorEngine.recalculateFrom(t, t.length - 1), this.scheduleRender();
1097
+ this.recalcIndicatorsFrom(t, t.length - 1), this.scheduleRender();
1012
1098
  }), this.streamManager.on("priceChange", ({ price: e, previousClose: t }) => {
1013
- this.tradingManager.setCurrentPrice(e), this.currentPriceLine.setPrice(e, t ?? void 0), this.engine.requestRender(r.Overlay);
1099
+ if (this.tradingManager.setCurrentPrice(e), this.replaySession) {
1100
+ this.replaySession.price = {
1101
+ price: e,
1102
+ previousClose: t ?? void 0
1103
+ };
1104
+ return;
1105
+ }
1106
+ this.currentPriceLine.setPrice(e, t ?? void 0), this.engine.requestRender(r.Overlay);
1014
1107
  }), this.streamManager.on("connectionChange", (e) => {
1015
1108
  this.eventBus.emit("dataUpdate", { connection: e });
1016
1109
  }), this.streamManager.on("error", (e) => {
@@ -1026,16 +1119,20 @@ var Tt = class {
1026
1119
  async switchStream(e, t) {
1027
1120
  this.streamManager && (this.currentSymbol = e, this.barCountdown.setTimeframeMs(f(t)), await this.streamManager.switchTo(e, t));
1028
1121
  }
1122
+ isTimeframeAllowed(e) {
1123
+ let t = this.features.timeframes;
1124
+ return t.length === 0 || t.includes(e);
1125
+ }
1029
1126
  async setTimeframe(e) {
1030
1127
  if (!this.streamManager) throw Error("No active stream. Call connect() first.");
1031
- await this.switchStream(this.currentSymbol, e);
1128
+ this.isTimeframeAllowed(e) && await this.switchStream(this.currentSymbol, e);
1032
1129
  }
1033
1130
  disconnectStream() {
1034
1131
  this.streamManager &&= (this.streamManager.dispose(), null);
1035
1132
  }
1036
1133
  connectExecution(e, t = {}) {
1037
1134
  if (!this.features.trading) throw Error("connectExecution requires features.trading to be enabled");
1038
- this.disconnectExecution(), this.executionAdapter = e, this.execTeardown = wt(e, {
1135
+ this.disconnectExecution(), this.executionAdapter = e, this.execTeardown = Et(e, {
1039
1136
  onIntent: (e, t) => {
1040
1137
  let n = (e) => t(e.payload);
1041
1138
  return this.eventBus.on(e, n), () => this.eventBus.off(e, n);
@@ -1055,19 +1152,19 @@ var Tt = class {
1055
1152
  return this.executionAdapter;
1056
1153
  }
1057
1154
  setBarCountdownVisible(e) {
1058
- this.barCountdown.setVisible(e), this.engine.requestRender(r.Hover);
1155
+ this.barCountdown.setVisible(e && this.features.barCountdown), this.engine.requestRender(r.Hover);
1059
1156
  }
1060
1157
  setSessionBreaksVisible(e) {
1061
1158
  this.sessionBreaks.setVisible(e), this.engine.requestRender(r.Background);
1062
1159
  }
1063
1160
  addCompareSymbol(e, t, n, i) {
1064
- this.compareRenderer.addSymbol({
1161
+ this.features.compareSymbols && (this.compareRenderer.addSymbol({
1065
1162
  id: e,
1066
1163
  label: t,
1067
1164
  data: n,
1068
1165
  color: i,
1069
1166
  visible: !0
1070
- }), this.engine.requestRender(r.Main);
1167
+ }), this.engine.requestRender(r.Main));
1071
1168
  }
1072
1169
  removeCompareSymbol(e) {
1073
1170
  this.compareRenderer.removeSymbol(e), this.engine.requestRender(r.Main);
@@ -1082,13 +1179,19 @@ var Tt = class {
1082
1179
  this.compareRenderer.clear(), this.engine.requestRender(r.Main);
1083
1180
  }
1084
1181
  setLogScale(e) {
1085
- this.viewport.setLogScale(e), this.updateViewportAndRender();
1182
+ e && !this.features.logScale || (this.viewport.setLogScale(e), this.updateViewportAndRender());
1086
1183
  }
1087
1184
  isLogScale() {
1088
1185
  return this.viewport.isLogScale();
1089
1186
  }
1187
+ setInvertScale(e) {
1188
+ this.viewport.setInvertScale(e), this.updateViewportAndRender();
1189
+ }
1190
+ isInvertScale() {
1191
+ return this.viewport.isInvertScale();
1192
+ }
1090
1193
  setScaleMode(e) {
1091
- this.viewport.setScaleMode(e), this.updateViewportAndRender();
1194
+ e === "logarithmic" && !this.features.logScale || (this.viewport.setScaleMode(e), this.updateViewportAndRender());
1092
1195
  }
1093
1196
  getScaleMode() {
1094
1197
  return this.viewport.getScaleMode();
@@ -1113,6 +1216,23 @@ var Tt = class {
1113
1216
  return;
1114
1217
  }
1115
1218
  }
1219
+ goToTime(e) {
1220
+ let t = this.getDisplayData();
1221
+ if (t.length === 0 || !Number.isFinite(e)) return -1;
1222
+ let n = Math.max(0, Math.min(t.length - 1, Math.floor(C(e, t)))), r = this.viewport.getState(), i = n * (r.barWidth + r.barSpacing) + r.barWidth / 2 - r.chartRect.width / 2;
1223
+ return this.viewport.scrollBy(i - r.offset), this.updateViewportAndRender(), n;
1224
+ }
1225
+ setVisibleRangePreset(e) {
1226
+ let t = this.getDisplayData();
1227
+ if (t.length === 0) return;
1228
+ let n = t.length - 1, r = t[n].time > Dt ? 1 : 1e3, i = $e(e, t[n].time * r, this.displayTzOffset), a = i === null ? null : i / r;
1229
+ if (a === null || a < t[0].time) {
1230
+ this.fitContent();
1231
+ return;
1232
+ }
1233
+ let o = Math.min(n, Math.floor(C(a, t)) + 1);
1234
+ this.viewport.zoomToBarRange(o, n + this.viewport.getRightMargin()), this.viewport.scrollToEnd(), this.updateViewportAndRender();
1235
+ }
1116
1236
  scrollToEnd() {
1117
1237
  this.viewport.scrollToEnd(), this.updateViewportAndRender();
1118
1238
  }
@@ -1177,7 +1297,11 @@ var Tt = class {
1177
1297
  return this.crosshairHandler.getMode();
1178
1298
  }
1179
1299
  setCrosshairPosition(e) {
1180
- e && this.crosshairHandler.onPointerMove(e), this.engine.requestRender(r.Hover);
1300
+ e ? this.crosshairHandler.onPointerMove(e) : this.crosshairHandler.onPointerLeave(), this.engine.requestRender(r.Hover);
1301
+ }
1302
+ setCrosshairTime(e) {
1303
+ let t = this.getDisplayData(), n = e === null || t.length === 0 ? null : Math.floor(C(e, t));
1304
+ n !== this.crosshairHandler.getSyncedSlot() && (this.crosshairHandler.setSyncedSlot(n), this.engine.requestRender(r.Hover));
1181
1305
  }
1182
1306
  getData() {
1183
1307
  return this.dataManager.getData();
@@ -1238,7 +1362,7 @@ var Tt = class {
1238
1362
  this.periodLevels.setPeriod(e), this.engine.requestRender(r.Main);
1239
1363
  }
1240
1364
  setTimezoneOffset(e) {
1241
- this.timeAxis.setTimezoneOffset(e), this.crosshairHandler.setTimezoneOffset(e), this.crosshairTooltip.setTimezoneOffset(e), this.engine.requestRender(r.UI);
1365
+ this.displayTzOffset = e, this.timeAxis.setTimezoneOffset(e), this.crosshairHandler.setTimezoneOffset(e), this.crosshairTooltip.setTimezoneOffset(e), this.engine.requestRender(r.UI);
1242
1366
  }
1243
1367
  setPivotMarkersVisible(e) {
1244
1368
  this.pivotMarkers.setVisible(e), this.engine.requestRender(r.Overlay);
@@ -1349,16 +1473,24 @@ var Tt = class {
1349
1473
  }
1350
1474
  replayStart(e) {
1351
1475
  if (!this.features.replay) return;
1352
- let t = this.dataManager.getData();
1353
- this.replayManager.load(t);
1476
+ if (!this.replaySession) {
1477
+ if (this.dataManager.getLength() === 0) return;
1478
+ let e = new A();
1479
+ e.setData(this.dataManager.getData()), this.replaySession = {
1480
+ live: e,
1481
+ price: null
1482
+ };
1483
+ }
1484
+ let t = this.replaySession.live.getData().slice();
1485
+ this.options.autoScale = !0, this.replayManager.load(t);
1354
1486
  let n = -1;
1355
1487
  this.replayBarUnsub?.(), this.replayBarUnsub = this.replayManager.on("bar", ({ bar: e, index: r }) => {
1356
1488
  let i = r + 1, a = n > 0 && i > n && this.dataManager.getLength() === n, o = !(a && !this.replaySeeking) || this.autoScrollOnNewBar && this.viewport.isAtEnd();
1357
1489
  if (a) {
1358
1490
  for (let e = n; e < i; e++) this.dataManager.appendBar(t[e]);
1359
- this.indicatorEngine.recalculateFrom(this.dataManager.getData(), n);
1360
- } else this.dataManager.setData(t.slice(0, i)), this.indicatorEngine.recalculateAll(this.dataManager.getData());
1361
- n = i, this.crosshairHandler.setData(this.dataManager.getData()), this.displayDataCache = null, this.updateViewportAndRender(o);
1491
+ this.recalcIndicatorsFrom(this.dataManager.getData(), n);
1492
+ } else this.dataManager.setData(t.slice(0, i)), this.recalcIndicators(this.dataManager.getData());
1493
+ n = i, this.currentPriceLine.setPrice(t[r].close, r > 0 ? t[r - 1].close : void 0), this.crosshairHandler.setData(this.dataManager.getData()), this.displayDataCache = null, this.updateViewportAndRender(o);
1362
1494
  }), this.replayManager.play(e);
1363
1495
  }
1364
1496
  replayPause() {
@@ -1368,7 +1500,23 @@ var Tt = class {
1368
1500
  this.replayManager.resume();
1369
1501
  }
1370
1502
  replayStop() {
1371
- this.replayManager.stop();
1503
+ let e = this.replaySession;
1504
+ this.endReplaySession(), e && (this.setData(e.live.getData()), e.price && this.currentPriceLine.setPrice(e.price.price, e.price.previousClose));
1505
+ }
1506
+ isReplayActive() {
1507
+ return this.replaySession !== null;
1508
+ }
1509
+ getPlotRect() {
1510
+ let { x: e, y: t, width: n, height: r } = this.viewport.getState().chartRect;
1511
+ return {
1512
+ x: e,
1513
+ y: t,
1514
+ width: n,
1515
+ height: r
1516
+ };
1517
+ }
1518
+ endReplaySession() {
1519
+ this.replaySession && (this.replaySession = null, this.replayBarUnsub?.(), this.replayBarUnsub = null, this.replayManager.stop());
1372
1520
  }
1373
1521
  replaySeek(e) {
1374
1522
  this.replaySeeking = !0;
@@ -1387,22 +1535,68 @@ var Tt = class {
1387
1535
  getReplayProgress() {
1388
1536
  return this.replayManager.getProgress();
1389
1537
  }
1390
- saveState(e) {
1391
- if (!this.features.saveLoad) return null;
1392
- let t = g.capture({
1538
+ captureSnapshot() {
1539
+ let e = this.layoutManager.getPanels();
1540
+ return g.capture({
1393
1541
  getDrawings: () => this.getDrawings(),
1394
1542
  getTheme: () => this.getTheme(),
1395
- getAlerts: () => this.getAlerts()
1396
- }, { chartType: this.options.chartType }), n = g.serialize(t);
1543
+ getAlerts: () => this.getAlerts(),
1544
+ getIndicators: () => [...this.indicatorEngine.getActiveIndicators().map((t) => ({
1545
+ id: t.id,
1546
+ instanceId: t.instanceId,
1547
+ params: t.params,
1548
+ position: e.find((e) => e.id === t.instanceId)?.position,
1549
+ style: this.indicatorEngine.getIndicatorStyle(t.instanceId) ?? void 0,
1550
+ visible: t.visible
1551
+ })), ...this.unrestoredIndicators]
1552
+ }, {
1553
+ chartType: this.options.chartType,
1554
+ symbol: this.currentSymbol || void 0
1555
+ });
1556
+ }
1557
+ saveState(e) {
1558
+ if (!this.features.saveLoad) return null;
1559
+ let t = this.captureSnapshot(), n = g.serialize(t);
1397
1560
  return e && g.saveToStorage(e, t), n;
1398
1561
  }
1399
1562
  loadState(e) {
1400
1563
  if (!this.features.saveLoad) return;
1401
1564
  let t = g.deserialize(e);
1402
- if (t.chartType && this.setChartType(t.chartType), t.drawings && this.setDrawings(t.drawings), t.theme && this.setTheme(t.theme), t.alerts) {
1403
- this.clearAlerts();
1404
- for (let e of t.alerts) this.addAlert(e.price, e.condition, e.message);
1565
+ t.chartType && this.setChartType(t.chartType), t.drawings && this.setDrawings(t.drawings), t.theme && this.setTheme(t.theme);
1566
+ let n = /* @__PURE__ */ new Map();
1567
+ if (t.version >= 2 && this.features.indicators) {
1568
+ this.unrestoredIndicators = [];
1569
+ let e = new Set(this.indicatorEngine.getAvailableIndicators().map((e) => e.id));
1570
+ for (let e of this.indicatorEngine.getActiveIndicators()) this.removeIndicator(e.instanceId);
1571
+ for (let r of t.indicators) {
1572
+ let t = [
1573
+ "top",
1574
+ "bottom",
1575
+ "left",
1576
+ "right"
1577
+ ].find((e) => e === r.position) ?? "bottom", i = null;
1578
+ try {
1579
+ if (!e.has(r.id)) throw Error("no such indicator is registered");
1580
+ i = this.addIndicator(r.id, r.params, t);
1581
+ } catch (e) {
1582
+ console.warn(`Layout indicator "${r.id}" kept but not shown:`, e);
1583
+ }
1584
+ if (!i) {
1585
+ this.unrestoredIndicators.push(r);
1586
+ continue;
1587
+ }
1588
+ n.set(r.instanceId, i), r.style && this.updateIndicatorStyle(i, r.style), r.visible === !1 && this.setIndicatorVisible(i, !1);
1589
+ }
1590
+ }
1591
+ if (t.alerts && this.features.alerts) {
1592
+ this.alertManager.clearAlerts();
1593
+ for (let e of t.alerts) {
1594
+ if (e.triggered && !e.repeating) continue;
1595
+ let t = e.channel.indexOf(":"), r = t > 0 ? n.get(e.channel.slice(0, t)) : void 0, i = r ? r + e.channel.slice(t) : e.channel;
1596
+ this.alertManager.addAlert(e.price, e.condition, e.message, e.repeating, i, e.label);
1597
+ }
1405
1598
  }
1599
+ this.scheduleAutoSave();
1406
1600
  }
1407
1601
  loadStateFromStorage(e) {
1408
1602
  if (!this.features.saveLoad) return !1;
@@ -1410,13 +1604,7 @@ var Tt = class {
1410
1604
  return t ? (this.loadState(g.serialize(t)), !0) : !1;
1411
1605
  }
1412
1606
  downloadState(e) {
1413
- if (!this.features.saveLoad) return;
1414
- let t = g.capture({
1415
- getDrawings: () => this.getDrawings(),
1416
- getTheme: () => this.getTheme(),
1417
- getAlerts: () => this.getAlerts()
1418
- }, { chartType: this.options.chartType });
1419
- g.downloadFile(t, e);
1607
+ this.features.saveLoad && g.downloadFile(this.captureSnapshot(), e);
1420
1608
  }
1421
1609
  async loadStateFromFile() {
1422
1610
  if (!this.features.saveLoad) return;
@@ -1445,7 +1633,7 @@ var Tt = class {
1445
1633
  };
1446
1634
  this.themeManager.setTheme(t);
1447
1635
  }
1448
- e.pricePrecision !== void 0 && (this.tradingManager.setConfig({ pricePrecision: e.pricePrecision }), this.alertManager.setPricePrecision(e.pricePrecision), this.streamManager?.priceLine.setPricePrecision(e.pricePrecision), this.currentPriceLine.setPricePrecision(e.pricePrecision), this.crosshairHandler.setPricePrecision(e.pricePrecision), this.chartLegend.setPricePrecision(e.pricePrecision), this.crosshairTooltip.setPricePrecision(e.pricePrecision)), this.updateViewportAndRender();
1636
+ e.pricePrecision !== void 0 && (this.marketPricePrecision = e.pricePrecision, this.tradingManager.setConfig({ pricePrecision: e.pricePrecision }), this.alertManager.setPricePrecision(e.pricePrecision), this.streamManager?.priceLine.setPricePrecision(e.pricePrecision), this.currentPriceLine.setPricePrecision(e.pricePrecision), this.crosshairHandler.setPricePrecision(e.pricePrecision), this.chartLegend.setPricePrecision(e.pricePrecision), this.crosshairTooltip.setPricePrecision(e.pricePrecision)), this.updateViewportAndRender();
1449
1637
  }
1450
1638
  getMarket() {
1451
1639
  return this.marketConfig;
@@ -1475,15 +1663,31 @@ var Tt = class {
1475
1663
  this.countdownInterval && clearInterval(this.countdownInterval), this.disableAutoSave(), this.disconnectStream(), this.disconnectExecution(), this.onWindowKeyDown &&= (window.removeEventListener("keydown", this.onWindowKeyDown), null), this.keyboardHandler = null, this.interactionManager.detach(), this.tradingManager.destroy(), this.animator.dispose(), this.crosshairTooltip.destroy(), this.pinnedTooltip.destroy(), this.replayManager.dispose(), this.undoRedoManager.clear(), this.engine.destroy(), this.eventBus.destroy(), this.container.innerHTML = "";
1476
1664
  }
1477
1665
  createChartRenderer(e) {
1478
- return lt(e, (e) => this.pluginManager.getChartType(e));
1666
+ return dt(e, (e) => this.pluginManager.getChartType(e));
1479
1667
  }
1480
1668
  getDisplayData() {
1481
1669
  if (this.displayDataCache) return this.displayDataCache;
1482
1670
  let e = this.dataManager.getData();
1483
1671
  if (e.length === 0) return e;
1484
- let t = ut(this.options.chartType, e, (e) => this.pluginManager.getChartType(e));
1672
+ let t = ft(this.options.chartType, e, (e) => this.pluginManager.getChartType(e));
1485
1673
  return this.displayDataCache = t, t;
1486
1674
  }
1675
+ recalcIndicatorsFrom(e, t) {
1676
+ this.indicatorEngine.recalculateFrom(e, t), this.announceIndicatorUpdate(t);
1677
+ }
1678
+ recalcIndicators(e) {
1679
+ this.indicatorEngine.recalculateAll(e), this.announceIndicatorUpdate(0);
1680
+ }
1681
+ announceIndicatorUpdate(e) {
1682
+ if (this.indicatorUpdateFrom !== null) {
1683
+ this.indicatorUpdateFrom = Math.min(this.indicatorUpdateFrom, e);
1684
+ return;
1685
+ }
1686
+ this.indicatorUpdateFrom = e, queueMicrotask(() => {
1687
+ let e = this.indicatorUpdateFrom;
1688
+ this.indicatorUpdateFrom = null, e !== null && this.eventBus.emit("indicatorUpdate", { from: e });
1689
+ });
1690
+ }
1487
1691
  scheduleRender() {
1488
1692
  this.renderScheduled || (this.renderScheduled = !0, requestAnimationFrame(() => {
1489
1693
  this.renderScheduled = !1, this.applyDataToViewport(), this.fitPriceAxisWidth() && this.applyDataToViewport(), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents();
@@ -1516,7 +1720,7 @@ var Tt = class {
1516
1720
  }
1517
1721
  fitPriceAxisWidth() {
1518
1722
  if (!this.features.priceAxis) return !1;
1519
- let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n = _t({
1723
+ let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n = yt({
1520
1724
  min: e.min,
1521
1725
  max: e.max,
1522
1726
  lastPrice: this.currentPriceLine.getPrice(),
@@ -1525,7 +1729,7 @@ var Tt = class {
1525
1729
  fontFamily: t.font.family,
1526
1730
  fontSizeSmall: t.font.sizeSmall,
1527
1731
  measure: (e, t) => this.measureText(e, t)
1528
- }), r = vt(this.priceAxisWidth, n);
1732
+ }), r = bt(this.priceAxisWidth, n);
1529
1733
  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);
1530
1734
  }
1531
1735
  measureText(e, t) {
@@ -1552,7 +1756,15 @@ var Tt = class {
1552
1756
  })), this.lastEmittedBarWidth !== e.barWidth && (this.lastEmittedBarWidth = e.barWidth, this.eventBus.emit("zoomChange", { barWidth: e.barWidth }));
1553
1757
  }
1554
1758
  getResolvedLayout() {
1555
- return this.resolvedLayoutCache ||= this.layoutManager.resolve(), this.resolvedLayoutCache;
1759
+ return this.resolvedLayoutCache || (this.resolvedLayoutCache = this.layoutManager.resolve(), this.syncCrosshairBounds(this.resolvedLayoutCache)), this.resolvedLayoutCache;
1760
+ }
1761
+ syncCrosshairBounds(e) {
1762
+ let t = e.mainChartRect, n = t.y, r = t.y + t.height;
1763
+ for (let t of e.panels) t.config.position !== "top" && t.config.position !== "bottom" || (n = Math.min(n, t.rect.y), r = Math.max(r, t.rect.y + t.rect.height));
1764
+ this.crosshairHandler.setReportBounds({
1765
+ top: n,
1766
+ bottom: r
1767
+ });
1556
1768
  }
1557
1769
  cachedContainerSize() {
1558
1770
  let e = Date.now();
@@ -1561,7 +1773,7 @@ var Tt = class {
1561
1773
  buildPanelRenderInfos() {
1562
1774
  if (this.panelInfoCache) return this.panelInfoCache;
1563
1775
  let e = this.getResolvedLayout(), t = this.viewport.getState(), { from: n, to: r } = t.visibleRange, i = e.panels.map((e) => {
1564
- let i = dt(this.indicatorEngine.getOutput(e.config.id), n, r), a = {
1776
+ let i = pt(this.indicatorEngine.getOutput(e.config.id), n, r), a = {
1565
1777
  x: e.rect.x,
1566
1778
  y: e.rect.y + 20,
1567
1779
  width: e.rect.width,
@@ -1573,7 +1785,10 @@ var Tt = class {
1573
1785
  viewport: {
1574
1786
  ...t,
1575
1787
  chartRect: a,
1576
- priceRange: i
1788
+ priceRange: i,
1789
+ logScale: !1,
1790
+ scaleMode: "regular",
1791
+ invertScale: !1
1577
1792
  }
1578
1793
  };
1579
1794
  });
@@ -1619,11 +1834,12 @@ var Tt = class {
1619
1834
  theme: this.themeManager.getTheme(),
1620
1835
  data: i,
1621
1836
  numberLocale: this.numberLocale,
1837
+ paneTitles: this.paneTitles,
1622
1838
  renderOverlayPlugins: (e, t) => this.drawOverlayPlugins(e, t)
1623
1839
  });
1624
1840
  }
1625
1841
  drawOverlayPlugins(e, t) {
1626
- let n = F(this.pluginManager.getOverlays(), t);
1842
+ let n = I(this.pluginManager.getOverlays(), t);
1627
1843
  if (n.length === 0) return;
1628
1844
  let r = {
1629
1845
  viewport: this.viewport.getState(),
@@ -1644,26 +1860,26 @@ var Tt = class {
1644
1860
  } : void 0
1645
1861
  } : null;
1646
1862
  }
1647
- }, V = [
1863
+ }, H = [
1648
1864
  "time",
1649
1865
  "timestamp",
1650
1866
  "date",
1651
1867
  "datetime",
1652
1868
  "t"
1653
- ], H = ["open", "o"], U = ["high", "h"], W = ["low", "l"], G = ["close", "c"], K = [
1869
+ ], U = ["open", "o"], W = ["high", "h"], G = ["low", "l"], K = ["close", "c"], q = [
1654
1870
  "volume",
1655
1871
  "vol",
1656
1872
  "v"
1657
1873
  ];
1658
- function q(e) {
1874
+ function J(e) {
1659
1875
  let t = e.trim();
1660
- return t ? t[0] === "[" || t[0] === "{" ? Et(t) : Dt(t) : {
1876
+ return t ? t[0] === "[" || t[0] === "{" ? kt(t) : At(t) : {
1661
1877
  data: [],
1662
1878
  rowCount: 0,
1663
1879
  skipped: 0
1664
1880
  };
1665
1881
  }
1666
- function Et(e) {
1882
+ function kt(e) {
1667
1883
  let t;
1668
1884
  try {
1669
1885
  t = JSON.parse(e);
@@ -1673,19 +1889,19 @@ function Et(e) {
1673
1889
  if (!Array.isArray(t)) throw Error("Expected a JSON array of OHLCV rows");
1674
1890
  let n = [], r = 0;
1675
1891
  for (let e of t) {
1676
- let t = Array.isArray(e) ? At(e) : Y(e);
1892
+ let t = Array.isArray(e) ? Pt(e) : Nt(e);
1677
1893
  t ? n.push(t) : r++;
1678
1894
  }
1679
1895
  return Q(n, t.length, r);
1680
1896
  }
1681
- function Dt(e) {
1897
+ function At(e) {
1682
1898
  let t = e.split(/\r?\n/).filter((e) => e.trim().length > 0);
1683
1899
  if (t.length === 0) return {
1684
1900
  data: [],
1685
1901
  rowCount: 0,
1686
1902
  skipped: 0
1687
1903
  };
1688
- let n = Ot(t[0]), r = J(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? kt(r) : {
1904
+ let n = jt(t[0]), r = Y(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? Mt(r) : {
1689
1905
  time: 0,
1690
1906
  open: 1,
1691
1907
  high: 2,
@@ -1696,7 +1912,7 @@ function Dt(e) {
1696
1912
  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");
1697
1913
  let o = [], s = 0;
1698
1914
  for (let e = +!!i; e < t.length; e++) {
1699
- let r = J(t[e], n), i = Z(r[a.time]), c = X(r[a.open]), l = X(r[a.high]), u = X(r[a.low]), d = X(r[a.close]), f = a.volume >= 0 ? Number(r[a.volume]) : 0;
1915
+ let r = Y(t[e], n), i = Z(r[a.time]), c = X(r[a.open]), l = X(r[a.high]), u = X(r[a.low]), d = X(r[a.close]), f = a.volume >= 0 ? Number(r[a.volume]) : 0;
1700
1916
  if (i === null || ![
1701
1917
  c,
1702
1918
  l,
@@ -1717,7 +1933,7 @@ function Dt(e) {
1717
1933
  }
1718
1934
  return Q(o, t.length - +!!i, s);
1719
1935
  }
1720
- function Ot(e) {
1936
+ function jt(e) {
1721
1937
  let t = {
1722
1938
  ",": 0,
1723
1939
  ";": 0,
@@ -1729,7 +1945,7 @@ function Ot(e) {
1729
1945
  for (let [e, i] of Object.entries(t)) i > r && (n = e, r = i);
1730
1946
  return n;
1731
1947
  }
1732
- function J(e, t) {
1948
+ function Y(e, t) {
1733
1949
  let n = [], r = "", i = !1;
1734
1950
  for (let a = 0; a < e.length; a++) {
1735
1951
  let o = e[a];
@@ -1737,25 +1953,25 @@ function J(e, t) {
1737
1953
  }
1738
1954
  return n.push(r), n;
1739
1955
  }
1740
- function kt(e) {
1956
+ function Mt(e) {
1741
1957
  let t = (t) => e.findIndex((e) => t.includes(e));
1742
1958
  return {
1743
- time: t(V),
1744
- open: t(H),
1745
- high: t(U),
1746
- low: t(W),
1747
- close: t(G),
1748
- volume: t(K)
1959
+ time: t(H),
1960
+ open: t(U),
1961
+ high: t(W),
1962
+ low: t(G),
1963
+ close: t(K),
1964
+ volume: t(q)
1749
1965
  };
1750
1966
  }
1751
- function Y(e) {
1967
+ function Nt(e) {
1752
1968
  let t = (t) => {
1753
1969
  for (let n of t) {
1754
1970
  if (e[n] !== void 0) return e[n];
1755
1971
  let t = n.toUpperCase();
1756
1972
  if (e[t] !== void 0) return e[t];
1757
1973
  }
1758
- }, n = Z(String(t(V) ?? "")), r = Number(t(H)), i = Number(t(U)), a = Number(t(W)), o = Number(t(G)), s = Number(t(K) ?? 0);
1974
+ }, n = Z(String(t(H) ?? "")), r = Number(t(U)), i = Number(t(W)), a = Number(t(G)), o = Number(t(K)), s = Number(t(q) ?? 0);
1759
1975
  return n === null || ![
1760
1976
  r,
1761
1977
  i,
@@ -1770,7 +1986,7 @@ function Y(e) {
1770
1986
  volume: Number.isFinite(s) ? s : 0
1771
1987
  };
1772
1988
  }
1773
- function At(e) {
1989
+ function Pt(e) {
1774
1990
  if (e.length < 5) return null;
1775
1991
  let t = Z(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;
1776
1992
  return t === null || ![
@@ -1810,7 +2026,7 @@ function Q(e, t, n) {
1810
2026
  }
1811
2027
  //#endregion
1812
2028
  //#region src/io/DragDropImporter.ts
1813
- var jt = class {
2029
+ var Ft = class {
1814
2030
  host;
1815
2031
  overlay = null;
1816
2032
  callbacks;
@@ -1843,7 +2059,7 @@ var jt = class {
1843
2059
  e.preventDefault(), this.depth = 0, this.hideOverlay();
1844
2060
  let t = e.dataTransfer?.files?.[0];
1845
2061
  if (t) try {
1846
- let e = q(await t.text());
2062
+ let e = J(await t.text());
1847
2063
  if (e.data.length === 0) throw Error(`No valid OHLCV rows found in "${t.name}"`);
1848
2064
  this.callbacks.onData(e.data, e, t);
1849
2065
  } catch (e) {
@@ -1878,6 +2094,6 @@ function $(e) {
1878
2094
  return e.dataTransfer?.types?.includes("Files") ?? !1;
1879
2095
  }
1880
2096
  //#endregion
1881
- export { Ct as a, St as c, I as d, N as f, z as i, bt as l, k as m, q as n, R as o, A as p, Tt as r, xt as s, jt as t, F as u };
2097
+ export { Tt as a, wt as c, L as d, P as f, B as i, St as l, A as m, J as n, z as o, j as p, Ot as r, Ct as s, Ft as t, I as u };
1882
2098
 
1883
- //# sourceMappingURL=DragDropImporter-cURSpfUb.js.map
2099
+ //# sourceMappingURL=DragDropImporter-Dd9Mud5J.js.map