@tradecanvas/chart 1.0.3 → 1.2.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 (49) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +79 -9
  3. package/dist/Chart.d.ts +33 -1
  4. package/dist/Chart.d.ts.map +1 -1
  5. package/dist/DataManager.d.ts.map +1 -1
  6. package/dist/{DragDropImporter-BGNGtnk4.js → DragDropImporter-BcTzFeRP.js} +312 -223
  7. package/dist/DragDropImporter-BcTzFeRP.js.map +1 -0
  8. package/dist/DragDropImporter-DZBrretS.cjs +2 -0
  9. package/dist/DragDropImporter-DZBrretS.cjs.map +1 -0
  10. package/dist/charts/IndicatorPriceRange.d.ts +7 -3
  11. package/dist/charts/IndicatorPriceRange.d.ts.map +1 -1
  12. package/dist/index.cjs +1 -1
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.ts +3 -3
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +24 -24
  17. package/dist/index.js.map +1 -1
  18. package/dist/layout/LayoutManager.d.ts +3 -0
  19. package/dist/layout/LayoutManager.d.ts.map +1 -1
  20. package/dist/layout/priceAxisWidth.d.ts +22 -0
  21. package/dist/layout/priceAxisWidth.d.ts.map +1 -0
  22. package/dist/widget/ChartWidget.d.ts +24 -1
  23. package/dist/widget/ChartWidget.d.ts.map +1 -1
  24. package/dist/widget/WidgetDrawingSidebar.d.ts.map +1 -1
  25. package/dist/widget/WidgetHotkeySheet.d.ts +3 -1
  26. package/dist/widget/WidgetHotkeySheet.d.ts.map +1 -1
  27. package/dist/widget/WidgetLoadingOverlay.d.ts +41 -0
  28. package/dist/widget/WidgetLoadingOverlay.d.ts.map +1 -0
  29. package/dist/widget/WidgetObjectTree.d.ts.map +1 -1
  30. package/dist/widget/WidgetSettings.d.ts +3 -1
  31. package/dist/widget/WidgetSettings.d.ts.map +1 -1
  32. package/dist/widget/WidgetToolbar.d.ts +4 -1
  33. package/dist/widget/WidgetToolbar.d.ts.map +1 -1
  34. package/dist/widget/WidgetWatchlist.d.ts +4 -1
  35. package/dist/widget/WidgetWatchlist.d.ts.map +1 -1
  36. package/dist/widget/i18n.d.ts +70 -0
  37. package/dist/widget/i18n.d.ts.map +1 -0
  38. package/dist/widget/icons.d.ts.map +1 -1
  39. package/dist/widget/index.cjs +2458 -2380
  40. package/dist/widget/index.cjs.map +1 -1
  41. package/dist/widget/index.js +635 -237
  42. package/dist/widget/index.js.map +1 -1
  43. package/dist/widget/types.d.ts +10 -0
  44. package/dist/widget/types.d.ts.map +1 -1
  45. package/dist/widget/widgetConfig.d.ts.map +1 -1
  46. package/package.json +6 -3
  47. package/dist/DragDropImporter-BGNGtnk4.js.map +0 -1
  48. package/dist/DragDropImporter-DvQin-m-.cjs +0 -2
  49. package/dist/DragDropImporter-DvQin-m-.cjs.map +0 -1
@@ -1,41 +1,41 @@
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, computePriceLimits as s, mergeBar as c, setLocale as l, timeframeToMs as u } from "@tradecanvas/commons";
2
- import { AlertDragHandler as d, AlertManager as f, Animator as p, AreaRenderer as m, AxisDragHandler as h, BarCountdown as ee, BarRenderer as te, BaselineRenderer as ne, CandlestickRenderer as g, ChartLegend as re, ChartStateManager as _, CompareRenderer as ie, CrosshairHandler as ae, CrosshairTooltip as oe, CurrentPriceLine as se, DataExporter as v, DepthHeatmapRenderer as ce, DrawingManager as le, DrawingRenderer as ue, EquivolumeRenderer as de, EventBus as fe, GridRenderer as pe, HLCAreaRenderer as me, HollowCandleRenderer as he, IndicatorEngine as y, InteractionManager as ge, KagiRenderer as _e, KeyboardHandler as ve, LineRenderer as ye, LineWithMarkersRenderer as be, MarketProfileRenderer as xe, MeasureOverlay as Se, PanHandler as Ce, PaneResizeHandler as we, PeriodLevelsRenderer as Te, PinnedTooltip as Ee, PivotMarkersRenderer as De, PointAndFigureRenderer as Oe, PriceAxis as ke, RenderEngine as Ae, RenkoRenderer as b, ReplayManager as x, Screenshot as S, SessionBreaks as C, SessionShading as je, SignalMarkerManager as Me, StepLineRenderer as Ne, StreamManager as Pe, TimeAxis as Fe, TradeZoneManager as Ie, TradingManager as Le, TradingRenderer as Re, UndoRedoManager as ze, Viewport as Be, VolumeCandleRenderer as Ve, VolumeProfileRenderer as He, VolumeRenderer as Ue, Watermark as We, ZoomHandler as Ge, findDominantSwing as Ke, registerBuiltInDrawingTools as qe, registerBuiltInIndicators as w, toHeikinAshi as Je, toKagi as Ye, toLineBreak as Xe, toPointAndFigure as Ze, toRangeBars as Qe, toRenko as $e, xToBarIndex as et } from "@tradecanvas/core";
1
+ import { DARK_THEME as e, DEFAULT_PANEL_HEIGHT as t, LIGHT_THEME as n, LayerType as r, MIN_PANEL_HEIGHT as i, PRICE_AXIS_WIDTH as a, TIME_AXIS_HEIGHT as o, autoPricePrecision as s, computePriceLimits as c, formatPrice as l, 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 y, RenkoRenderer as b, ReplayManager as x, Screenshot as S, SessionBreaks as Ne, SessionShading as Pe, SignalMarkerManager as Fe, StepLineRenderer as Ie, StreamManager as Le, TimeAxis as Re, TradeZoneManager as ze, TradingManager as Be, TradingRenderer as Ve, UndoRedoManager as He, Viewport as Ue, VolumeCandleRenderer as We, VolumeProfileRenderer as Ge, VolumeRenderer as Ke, Watermark as qe, ZoomHandler as Je, findDominantSwing as Ye, registerBuiltInDrawingTools as Xe, registerBuiltInIndicators as C, toHeikinAshi as Ze, toKagi as Qe, toLineBreak as $e, toPointAndFigure as et, toRangeBars as tt, toRenko as nt, xToBarIndex as rt } from "@tradecanvas/core";
3
3
  //#region src/charts/ChartTypeStrategy.ts
4
- function tt(e) {
4
+ function w(e) {
5
5
  switch (e) {
6
6
  case "candlestick":
7
7
  case "heikinAshi":
8
8
  case "lineBreak":
9
- case "rangeBars": return new g();
10
- case "line": return new ye();
11
- case "area": return new m();
12
- case "bar": return new te();
13
- case "hollowCandle": return new he();
14
- case "baseline": return new ne();
9
+ case "rangeBars": return new h();
10
+ case "line": return new Se();
11
+ case "area": return new te();
12
+ case "bar": return new ie();
13
+ case "hollowCandle": return new ve();
14
+ case "baseline": return new ae();
15
15
  case "renko": return new b();
16
- case "kagi": return new _e();
17
- case "pointAndFigure": return new Oe();
18
- case "volumeCandles": return new Ve();
19
- case "equivolume": return new de();
20
- case "hlcArea": return new me();
21
- case "stepLine": return new Ne();
22
- case "lineWithMarkers": return new be();
23
- default: return new g();
16
+ case "kagi": return new be();
17
+ case "pointAndFigure": return new je();
18
+ case "volumeCandles": return new We();
19
+ case "equivolume": return new me();
20
+ case "hlcArea": return new _e();
21
+ case "stepLine": return new Ie();
22
+ case "lineWithMarkers": return new Ce();
23
+ default: return new h();
24
24
  }
25
25
  }
26
- function nt(e, t) {
26
+ function it(e, t) {
27
27
  if (t.length === 0) return t;
28
28
  switch (e) {
29
- case "heikinAshi": return Je(t);
30
- case "renko": return $e(t, {
29
+ case "heikinAshi": return Ze(t);
30
+ case "renko": return nt(t, {
31
31
  brickSize: 0,
32
32
  useATR: !0,
33
33
  atrPeriod: 14
34
34
  });
35
- case "lineBreak": return Xe(t, 3);
36
- case "kagi": return Ye(t, 4);
37
- case "pointAndFigure": return Ze(t, T(t) * .01, 3);
38
- case "rangeBars": return Qe(t, { rangeSize: T(t) * .005 });
35
+ case "lineBreak": return $e(t, 3);
36
+ case "kagi": return Qe(t, 4);
37
+ case "pointAndFigure": return et(t, T(t) * .01, 3);
38
+ case "rangeBars": return tt(t, { rangeSize: T(t) * .005 });
39
39
  default: return t;
40
40
  }
41
41
  }
@@ -44,14 +44,14 @@ function T(e) {
44
44
  for (let n of e) t += n.close;
45
45
  return t / e.length;
46
46
  }
47
- function rt(e, t) {
47
+ function at(e, t) {
48
48
  let n = t?.(e);
49
- return n ? n.createRenderer() : tt(e);
49
+ return n ? n.createRenderer() : w(e);
50
50
  }
51
- function it(e, t, n) {
51
+ function ot(e, t, n) {
52
52
  if (t.length === 0) return t;
53
53
  let r = n?.(e);
54
- return r?.transform ? r.transform(t) : nt(e, t);
54
+ return r?.transform ? r.transform(t) : it(e, t);
55
55
  }
56
56
  //#endregion
57
57
  //#region src/charts/IndicatorPriceRange.ts
@@ -59,26 +59,38 @@ var E = {
59
59
  min: 0,
60
60
  max: 100
61
61
  }, D = .1;
62
- function at(e, t, n) {
62
+ function st(e, t, n) {
63
63
  if (!e) return { ...E };
64
- let r = Infinity, i = -Infinity, a = 0;
65
- for (let [, o] of e.values) {
66
- if (a >= t && a <= n) for (let e in o) {
67
- let t = o[e];
68
- t !== void 0 && Number.isFinite(t) && (t < r && (r = t), t > i && (i = t));
64
+ let r = Infinity, i = -Infinity;
65
+ if (e.series) {
66
+ let a = Math.min(n, e.series.length - 1);
67
+ for (let n = Math.max(0, t); n <= a; n++) {
68
+ let t = e.series[n];
69
+ if (t) for (let e in t) {
70
+ let n = t[e];
71
+ n !== void 0 && Number.isFinite(n) && (n < r && (r = n), n > i && (i = n));
72
+ }
73
+ }
74
+ } else {
75
+ let a = 0;
76
+ for (let [, o] of e.values) {
77
+ if (a >= t && a <= n) for (let e in o) {
78
+ let t = o[e];
79
+ t !== void 0 && Number.isFinite(t) && (t < r && (r = t), t > i && (i = t));
80
+ }
81
+ a++;
69
82
  }
70
- a++;
71
83
  }
72
84
  if (r === Infinity) return { ...E };
73
- let o = i - r || 1;
85
+ let a = i - r || 1;
74
86
  return {
75
- min: r - o * D,
76
- max: i + o * D
87
+ min: r - a * D,
88
+ max: i + a * D
77
89
  };
78
90
  }
79
91
  //#endregion
80
92
  //#region src/state/AutoSaveScheduler.ts
81
- var ot = class {
93
+ var ct = class {
82
94
  timer = null;
83
95
  delayMs = 0;
84
96
  key = null;
@@ -113,6 +125,9 @@ function O(e) {
113
125
  let { open: t, high: n, low: r, close: i } = e;
114
126
  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));
115
127
  }
128
+ function lt(e) {
129
+ return e.volume !== void 0 && e.high >= e.open && e.high >= e.close && e.low <= e.open && e.low <= e.close;
130
+ }
116
131
  function k(e) {
117
132
  return {
118
133
  ...e,
@@ -127,7 +142,12 @@ var A = class {
127
142
  return this.data;
128
143
  }
129
144
  setData(e) {
130
- this.data = e.filter(O).map(k);
145
+ let t = [];
146
+ for (let n = 0; n < e.length; n++) {
147
+ let r = e[n];
148
+ O(r) && t.push(lt(r) ? r : k(r));
149
+ }
150
+ this.data = t;
131
151
  }
132
152
  appendBar(e) {
133
153
  O(e) && this.data.push(k(e));
@@ -142,7 +162,7 @@ var A = class {
142
162
  this.data[this.data.length - 1] = t;
143
163
  }
144
164
  updateLastBarFromTick(e) {
145
- 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] = c(this.data[this.data.length - 1], e)));
165
+ 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] = u(this.data[this.data.length - 1], e)));
146
166
  }
147
167
  getLength() {
148
168
  return this.data.length;
@@ -165,6 +185,7 @@ var A = class {
165
185
  panels = [];
166
186
  containerWidth = 0;
167
187
  containerHeight = 0;
188
+ priceAxisWidth = a;
168
189
  resize(e, t) {
169
190
  this.containerWidth = e, this.containerHeight = t;
170
191
  }
@@ -195,105 +216,127 @@ var A = class {
195
216
  let n = this.panels.find((t) => t.id === e);
196
217
  n && (n.size = Math.max(n.minSize, t));
197
218
  }
219
+ setPriceAxisWidth(e) {
220
+ this.priceAxisWidth = e;
221
+ }
198
222
  getPanels() {
199
223
  return this.panels;
200
224
  }
201
225
  resolve() {
202
- let e = this.panels.filter((e) => e.position === "left"), t = this.panels.filter((e) => e.position === "right"), n = this.panels.filter((e) => e.position === "top"), r = this.panels.filter((e) => e.position === "bottom"), i = e.reduce((e, t) => e + t.size, 0), s = t.reduce((e, t) => e + t.size, 0), c = n.reduce((e, t) => e + t.size, 0), l = r.reduce((e, t) => e + t.size, 0), u = {
226
+ let e = this.panels.filter((e) => e.position === "left"), t = this.panels.filter((e) => e.position === "right"), n = this.panels.filter((e) => e.position === "top"), r = this.panels.filter((e) => e.position === "bottom"), i = e.reduce((e, t) => e + t.size, 0), a = t.reduce((e, t) => e + t.size, 0), s = n.reduce((e, t) => e + t.size, 0), c = r.reduce((e, t) => e + t.size, 0), l = {
203
227
  x: i,
204
- y: c,
205
- width: Math.max(0, this.containerWidth - i - s - a),
206
- height: Math.max(0, this.containerHeight - c - l - o)
207
- }, d = [], f = [], p = 0;
208
- for (let t of e) d.push({
228
+ y: s,
229
+ width: Math.max(0, this.containerWidth - i - a - this.priceAxisWidth),
230
+ height: Math.max(0, this.containerHeight - s - c - o)
231
+ }, u = [], d = [], f = 0;
232
+ for (let t of e) u.push({
209
233
  config: t,
210
234
  rect: {
211
- x: p,
235
+ x: f,
212
236
  y: 0,
213
237
  width: t.size,
214
238
  height: this.containerHeight - o
215
239
  }
216
- }), f.push({
240
+ }), d.push({
217
241
  panelId: t.id,
218
242
  rect: {
219
- x: p + t.size - 2,
243
+ x: f + t.size - 2,
220
244
  y: 0,
221
245
  width: 4,
222
246
  height: this.containerHeight
223
247
  },
224
248
  orientation: "vertical"
225
- }), p += t.size;
226
- let m = 0;
227
- for (let e of n) d.push({
249
+ }), f += t.size;
250
+ let p = 0;
251
+ for (let e of n) u.push({
228
252
  config: e,
229
253
  rect: {
230
254
  x: i,
231
- y: m,
232
- width: u.width,
255
+ y: p,
256
+ width: l.width,
233
257
  height: e.size
234
258
  }
235
- }), f.push({
259
+ }), d.push({
236
260
  panelId: e.id,
237
261
  rect: {
238
262
  x: i,
239
- y: m + e.size - 2,
240
- width: u.width,
263
+ y: p + e.size - 2,
264
+ width: l.width,
241
265
  height: 4
242
266
  },
243
267
  orientation: "horizontal"
244
- }), m += e.size;
245
- m = u.y + u.height;
246
- for (let e of r) d.push({
268
+ }), p += e.size;
269
+ p = l.y + l.height;
270
+ for (let e of r) u.push({
247
271
  config: e,
248
272
  rect: {
249
273
  x: i,
250
- y: m,
251
- width: u.width,
274
+ y: p,
275
+ width: l.width,
252
276
  height: e.size
253
277
  }
254
- }), f.push({
278
+ }), d.push({
255
279
  panelId: e.id,
256
280
  rect: {
257
281
  x: i,
258
- y: m - 2,
259
- width: u.width,
282
+ y: p - 2,
283
+ width: l.width,
260
284
  height: 4
261
285
  },
262
286
  orientation: "horizontal"
263
- }), m += e.size;
264
- p = i + u.width + a;
265
- for (let e of t) d.push({
287
+ }), p += e.size;
288
+ f = i + l.width + this.priceAxisWidth;
289
+ for (let e of t) u.push({
266
290
  config: e,
267
291
  rect: {
268
- x: p,
292
+ x: f,
269
293
  y: 0,
270
294
  width: e.size,
271
295
  height: this.containerHeight - o
272
296
  }
273
- }), f.push({
297
+ }), d.push({
274
298
  panelId: e.id,
275
299
  rect: {
276
- x: p - 2,
300
+ x: f - 2,
277
301
  y: 0,
278
302
  width: 4,
279
303
  height: this.containerHeight
280
304
  },
281
305
  orientation: "vertical"
282
- }), p += e.size;
306
+ }), f += e.size;
283
307
  return {
284
- mainChartRect: u,
285
- panels: d,
286
- dividers: f
308
+ mainChartRect: l,
309
+ panels: u,
310
+ dividers: d
287
311
  };
288
312
  }
289
313
  getMainChartRect() {
290
314
  return this.resolve().mainChartRect;
291
315
  }
292
- }, st = 1;
293
- function F(e, t) {
316
+ }, ut = 14, dt = 14, ft = 22, F = 4;
317
+ function pt(e) {
318
+ 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
+ t,
320
+ n,
321
+ r
322
+ ], m = a;
323
+ for (let e of p) {
324
+ if (!Number.isFinite(e)) continue;
325
+ let t = l(e, d, i), n = l(e, f, i);
326
+ m = Math.max(m, u(t, `500 ${c}px ${o}`) + ut, u(n, `bold 11px ${o}`) + dt, u(n, `600 ${c}px ${o}`) + ft);
327
+ }
328
+ return m <= a ? a : Math.ceil(m / F) * F;
329
+ }
330
+ function mt(e, t) {
331
+ return t > e || t <= e - 12 ? t : e;
332
+ }
333
+ //#endregion
334
+ //#region src/plugins/contracts.ts
335
+ var ht = 1;
336
+ function I(e, t) {
294
337
  return e.filter((e) => (e.descriptor.layer ?? "overlay") === t);
295
338
  }
296
- function I(e) {
339
+ function L(e) {
297
340
  switch (e.kind) {
298
341
  case "indicator": return `indicator:${e.plugin.descriptor.id}`;
299
342
  case "drawing": return `drawing:${e.plugin.descriptor.type}`;
@@ -303,25 +346,25 @@ function I(e) {
303
346
  }
304
347
  //#endregion
305
348
  //#region src/plugins/registry.ts
306
- var L = /* @__PURE__ */ new Map();
307
- function ct(e) {
308
- L.set(I(e), e);
349
+ var R = /* @__PURE__ */ new Map();
350
+ function gt(e) {
351
+ R.set(L(e), e);
309
352
  }
310
- function lt(e) {
311
- return L.delete(e);
353
+ function _t(e) {
354
+ return R.delete(e);
312
355
  }
313
- function R() {
314
- return [...L.values()];
356
+ function z() {
357
+ return [...R.values()];
315
358
  }
316
- function ut() {
317
- L.clear();
359
+ function vt() {
360
+ R.clear();
318
361
  }
319
362
  //#endregion
320
363
  //#region src/plugins/PluginManager.ts
321
- var z = class {
364
+ var B = class {
322
365
  plugins = /* @__PURE__ */ new Map();
323
366
  constructor(e, t = {}) {
324
- if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of R()) this.add(e);
367
+ if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of z()) this.add(e);
325
368
  for (let e of t.plugins ?? []) this.add(e);
326
369
  }
327
370
  register(e) {
@@ -349,20 +392,20 @@ var z = class {
349
392
  return e;
350
393
  }
351
394
  add(e) {
352
- this.plugins.set(I(e), e), e.kind === "indicator" && this.indicatorEngine.register(e.plugin);
395
+ this.plugins.set(L(e), e), e.kind === "indicator" && this.indicatorEngine.register(e.plugin);
353
396
  }
354
- }, B = {
397
+ }, V = {
355
398
  orderPlace: (e, t) => e.placeOrder(t),
356
399
  orderModify: (e, t) => e.modifyOrder(t),
357
400
  orderCancel: (e, t) => e.cancelOrder(t),
358
401
  positionModify: (e, t) => e.modifyPosition(t),
359
402
  positionClose: (e, t) => e.closePosition(t)
360
403
  };
361
- function dt(e, t) {
404
+ function yt(e, t) {
362
405
  let n = [], r = (e) => t.setOrders(e.data ?? []), i = (e) => t.setPositions(e.data ?? []), a = (e) => t.onError(e.data ?? { message: "Execution error" });
363
406
  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));
364
- for (let r of Object.keys(B)) {
365
- let i = B[r], a = t.onIntent(r, (n) => {
407
+ for (let r of Object.keys(V)) {
408
+ let i = V[r], a = t.onIntent(r, (n) => {
366
409
  Promise.resolve(i(e, n)).catch((e) => t.onError({
367
410
  message: `Execution command failed: ${r}`,
368
411
  cause: e
@@ -376,8 +419,8 @@ function dt(e, t) {
376
419
  }
377
420
  //#endregion
378
421
  //#region src/Chart.ts
379
- var ft = 6, pt = class {
380
- static version = "1.0.3";
422
+ var bt = 6, xt = class {
423
+ static version = "1.2.0";
381
424
  engine;
382
425
  viewport;
383
426
  dataManager;
@@ -398,6 +441,8 @@ var ft = 6, pt = class {
398
441
  resolvedLayoutCache = null;
399
442
  panelInfoCache = null;
400
443
  renderScheduled = !1;
444
+ priceAxisWidth = a;
445
+ measureCtx;
401
446
  containerSizeCache = null;
402
447
  containerSizeCacheTime = 0;
403
448
  lastEmittedRange = null;
@@ -421,8 +466,9 @@ var ft = 6, pt = class {
421
466
  tradeZoneManager;
422
467
  measureOverlay;
423
468
  replayManager;
469
+ replayBarUnsub = null;
424
470
  undoRedoManager;
425
- autoSaveScheduler = new ot((e) => this.saveState(e));
471
+ autoSaveScheduler = new ct((e) => this.saveState(e));
426
472
  animator;
427
473
  crosshairTooltip;
428
474
  pinnedTooltip;
@@ -438,11 +484,12 @@ var ft = 6, pt = class {
438
484
  container;
439
485
  currentPriceLine;
440
486
  numberLocale;
487
+ defaultAutoScale;
441
488
  keyboardHandler = null;
442
489
  onWindowKeyDown = null;
443
490
  currentSymbol = "";
444
491
  constructor(e, t) {
445
- this.container = e, this.options = t, this.numberLocale = t.numberLocale ?? "en-US";
492
+ this.container = e, this.options = t, this.numberLocale = t.numberLocale ?? "en-US", this.defaultAutoScale = t.autoScale !== !1;
446
493
  let n = t.features ?? {};
447
494
  this.features = {
448
495
  drawings: n.drawings ?? !0,
@@ -456,6 +503,7 @@ var ft = 6, pt = class {
456
503
  panning: n.panning ?? !0,
457
504
  zooming: n.zooming ?? !0,
458
505
  crosshair: n.crosshair ?? !0,
506
+ crosshairTooltip: n.crosshairTooltip ?? !0,
459
507
  keyboard: n.keyboard ?? !0,
460
508
  priceAxis: n.priceAxis ?? !0,
461
509
  timeAxis: n.timeAxis ?? !0,
@@ -474,36 +522,36 @@ var ft = 6, pt = class {
474
522
  logScale: n.logScale ?? !0,
475
523
  timeframes: n.timeframes ?? [],
476
524
  defaultTimeframeFavorites: n.defaultTimeframeFavorites ?? []
477
- }, 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 y(), this.pluginManager = new z(this.indicatorEngine, { plugins: t.plugins }), this.eventBus = new fe(), w(this.indicatorEngine), this.drawingManager = new le(), qe(this.drawingManager), this.drawingRenderer = new ue(this.drawingManager), this.drawingManager.setRequestRender(() => {
525
+ }, 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(), C(this.indicatorEngine), this.drawingManager = new fe(), Xe(this.drawingManager), this.drawingRenderer = new pe(this.drawingManager), this.drawingManager.setRequestRender(() => {
478
526
  this.syncRenderContext(), this.engine.requestRender(r.Overlay), this.scheduleAutoSave();
479
527
  }), this.drawingManager.setEventCallback((e, t) => {
480
528
  this.eventBus.emit(e, t);
481
- }), this.undoRedoManager = new ze(), 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 Le({
529
+ }), this.undoRedoManager = new He(), 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 Be({
482
530
  enabled: this.features.trading,
483
531
  contextMenu: { enabled: this.features.tradingContextMenu }
484
- }), this.tradingRenderer = new Re(this.tradingManager), this.tradingManager.setContainer(e), this.tradingManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradingManager.setEventCallback((e, t) => {
532
+ }), this.tradingRenderer = new Ve(this.tradingManager), this.tradingManager.setContainer(e), this.tradingManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradingManager.setEventCallback((e, t) => {
485
533
  this.eventBus.emit(e, t);
486
- }), this.engine = new Ae(e);
534
+ }), this.engine = new y(e);
487
535
  let i = this.engine.dprManager.getContainerSize();
488
- if (this.viewport = new Be(i.width, i.height, t.minBarSpacing ?? 2, t.maxBarSpacing ?? 30, t.rightMargin ?? 5), this.layoutManager.resize(i.width, i.height), this.engine.onContainerResize = (e) => {
536
+ if (this.viewport = new Ue(i.width, i.height, t.minBarSpacing ?? 2, t.maxBarSpacing ?? 30, t.rightMargin ?? 5), this.layoutManager.resize(i.width, i.height), this.engine.onContainerResize = (e) => {
489
537
  if (e.width <= 0 || e.height <= 0) return;
490
538
  let t = this.viewport.isAtEnd();
491
539
  this.viewport.resize(e.width, e.height), this.layoutManager.resize(e.width, e.height), this.updateViewportAndRender(t);
492
- }, this.chartRenderer = this.createChartRenderer(t.chartType), this.gridRenderer = new pe(), t.grid?.visible === !1 && this.gridRenderer.setVisible(!1), this.priceAxis = new ke(), this.priceAxis.setLocale(this.numberLocale), this.timeAxis = new Fe(), this.crosshairHandler = new ae(), this.crosshairHandler.setLocale(this.numberLocale), t.crosshair?.mode && this.crosshairHandler.setMode(t.crosshair.mode), this.crosshairHandler.setCallback((e, t) => {
540
+ }, 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 Re(), this.crosshairHandler = new ce(), this.crosshairHandler.setLocale(this.numberLocale), t.crosshair?.mode && this.crosshairHandler.setMode(t.crosshair.mode), this.crosshairHandler.setCallback((e, t) => {
493
541
  if (e !== null && t) {
494
542
  let n = this.dataManager.getData(), r = e < n.length ? n[e] : void 0;
495
- this.chartLegend.setHoverBar(r ?? null), r && this.crosshairTooltip.show(t, r, this.themeManager.getTheme(), this.cachedContainerSize()), this.pinnedTooltip.isPinned() && this.pinnedTooltip.reposition(this.viewport.getState(), r ?? null, e, this.themeManager.getTheme()), this.eventBus.emit("crosshairMove", {
543
+ this.chartLegend.setHoverBar(r ?? null), r && this.features.crosshairTooltip && this.crosshairTooltip.show(t, r, this.themeManager.getTheme(), this.cachedContainerSize()), this.pinnedTooltip.isPinned() && this.pinnedTooltip.reposition(this.viewport.getState(), r ?? null, e, this.themeManager.getTheme()), this.eventBus.emit("crosshairMove", {
496
544
  point: t,
497
545
  bar: r,
498
546
  barIndex: e
499
547
  });
500
548
  } else this.crosshairTooltip.hide(), this.chartLegend.setHoverBar(null);
501
- }), this.chartLegend = new re(), this.chartLegend.setChartType(t.chartType), this.watermark = new We(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new Ue(), this.volumeProfile = new He(), this.marketProfile = new xe(), this.depthHeatmap = new ce(), this.periodLevels = new Te(), this.pivotMarkers = new De(), this.barCountdown = new ee(), this.sessionBreaks = new C(), this.sessionShading = new je(), this.compareRenderer = new ie(), t.sessionBreaks ? this.sessionBreaks.setConfig({
549
+ }), this.chartLegend = new oe(), this.chartLegend.setChartType(t.chartType), this.chartLegend.setLocale(this.numberLocale), this.watermark = new qe(), t.watermark && this.watermark.setConfig(t.watermark), this.volumeRenderer = new Ke(), this.volumeProfile = new Ge(), this.marketProfile = new we(), this.depthHeatmap = new de(), this.periodLevels = new Oe(), this.pivotMarkers = new Ae(), this.barCountdown = new re(), this.sessionBreaks = new Ne(), this.sessionBreaks.setLocale(this.numberLocale), this.sessionShading = new Pe(), this.compareRenderer = new se(), t.sessionBreaks ? this.sessionBreaks.setConfig({
502
550
  visible: t.sessionBreaks.visible ?? !0,
503
551
  color: t.sessionBreaks.color,
504
552
  lineStyle: t.sessionBreaks.lineStyle,
505
553
  lineWidth: t.sessionBreaks.lineWidth
506
- }) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.viewport.setLogScale(!0), this.animator = new p(), this.crosshairTooltip = new oe(), this.crosshairTooltip.create(e), this.pinnedTooltip = new Ee(), this.pinnedTooltip.create(e), this.keyboardHandler = new ve({
554
+ }) : 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.pinnedTooltip = new ke(), this.pinnedTooltip.create(e), this.keyboardHandler = new xe({
507
555
  scrollBars: (e) => {
508
556
  let t = this.viewport.getState().barWidth + this.viewport.getState().barSpacing;
509
557
  this.viewport.scrollBy(e * t), this.updateViewportAndRender();
@@ -523,7 +571,7 @@ var ft = 6, pt = class {
523
571
  if (!this.keyboardHandler) return;
524
572
  let t = document.activeElement;
525
573
  t && t !== this.container && !this.container.contains(t) || t && (t.tagName === "INPUT" || t.tagName === "TEXTAREA" || t.isContentEditable) || this.keyboardHandler.handleKey(e) && e.preventDefault();
526
- }, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new se(), this.alertManager = new f(), this.alertManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.alertManager.on("triggered", (e) => {
574
+ }, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new ue(), this.currentPriceLine.setLocale(this.numberLocale), this.alertManager = new m(), this.alertManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.alertManager.on("triggered", (e) => {
527
575
  let t = {
528
576
  id: e.id,
529
577
  price: e.price,
@@ -555,7 +603,7 @@ var ft = 6, pt = class {
555
603
  message: e.message,
556
604
  triggered: e.triggered
557
605
  });
558
- }), this.signalMarkerManager = new Me(), this.signalMarkerManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.signalMarkerManager.setDataGetter(() => this.dataManager.getData()), this.signalMarkerManager.on("added", (e) => {
606
+ }), this.signalMarkerManager = new Fe(), this.signalMarkerManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.signalMarkerManager.setDataGetter(() => this.dataManager.getData()), this.signalMarkerManager.on("added", (e) => {
559
607
  this.eventBus.emit("signalMarkerAdd", {
560
608
  id: e.id,
561
609
  source: e.source,
@@ -563,26 +611,26 @@ var ft = 6, pt = class {
563
611
  });
564
612
  }), this.signalMarkerManager.on("removed", (e) => {
565
613
  this.eventBus.emit("signalMarkerRemove", { id: e });
566
- }), this.tradeZoneManager = new Ie(), this.tradeZoneManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradeZoneManager.setDataGetter(() => this.dataManager.getData()), this.tradeZoneManager.on("added", (e) => {
614
+ }), this.tradeZoneManager = new ze(), this.tradeZoneManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.tradeZoneManager.setDataGetter(() => this.dataManager.getData()), this.tradeZoneManager.on("added", (e) => {
567
615
  this.eventBus.emit("tradeZoneAdd", {
568
616
  id: e.id,
569
617
  direction: e.direction
570
618
  });
571
619
  }), this.tradeZoneManager.on("removed", (e) => {
572
620
  this.eventBus.emit("tradeZoneRemove", { id: e });
573
- }), this.replayManager = new x(), this.measureOverlay = new Se(), this.interactionManager = new ge(e), this.features.panning) {
621
+ }), this.replayManager = new x(), this.measureOverlay = new Te(), this.interactionManager = new ye(e), this.features.panning) {
574
622
  let e = 0;
575
- this.interactionManager.setPanHandler(new Ce((t, n) => {
576
- t && this.viewport.scrollBy(t), n && (e += n, (this.options.autoScale === !1 || Math.abs(e) > ft) && (this.options.autoScale = !1, this.viewport.panPriceRange(n))), this.updateViewportAndRender();
623
+ this.interactionManager.setPanHandler(new Ee((t, n) => {
624
+ t && this.viewport.scrollBy(t), n && (e += n, (this.options.autoScale === !1 || Math.abs(e) > bt) && (this.options.autoScale = !1, this.viewport.panPriceRange(n))), this.updateViewportAndRender();
577
625
  }, () => {
578
626
  e = 0;
579
627
  }));
580
628
  }
581
629
  if (this.features.zooming) {
582
- this.interactionManager.setZoomHandler(new Ge((e, t) => {
630
+ this.interactionManager.setZoomHandler(new Je((e, t) => {
583
631
  this.viewport.zoom(e, t), this.updateViewportAndRender();
584
632
  }));
585
- let e = new h((e) => {
633
+ let e = new ne((e) => {
586
634
  this.options.autoScale = !1, this.viewport.scalePriceRange(e), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents();
587
635
  }, (e) => {
588
636
  let t = this.viewport.getState().chartRect.width;
@@ -599,10 +647,10 @@ var ft = 6, pt = class {
599
647
  ...this.viewport.getState(),
600
648
  data: this.getDisplayData()
601
649
  })), this.features.alerts) {
602
- let e = new d(this.alertManager, () => this.viewport.getState());
650
+ let e = new p(this.alertManager, () => this.viewport.getState());
603
651
  this.interactionManager.setAlertDragHandler(e);
604
652
  }
605
- let a = new we();
653
+ let a = new De();
606
654
  a.configure(() => this.getResolvedLayout(), (e, t) => this.setPanelSize(e, t)), this.interactionManager.setPaneResizeHandler(a), this.interactionManager.setAltClickHandler((e) => {
607
655
  let t = this.getDisplayData();
608
656
  if (t.length === 0) return;
@@ -614,7 +662,7 @@ var ft = 6, pt = class {
614
662
  x: e.x,
615
663
  y: e.y
616
664
  }), t.length === 0) return;
617
- let n = et(e.x, this.viewport.getState());
665
+ let n = rt(e.x, this.viewport.getState());
618
666
  n < 0 || n >= t.length || this.eventBus.emit("barClick", {
619
667
  bar: t[n],
620
668
  barIndex: n,
@@ -641,22 +689,29 @@ var ft = 6, pt = class {
641
689
  }), this.interactionManager.attach(), this.syncRenderContext(), this.engine.start();
642
690
  }
643
691
  setData(e) {
644
- this.dataManager.setData(e), this.crosshairHandler.setData(this.dataManager.getData()), this.displayDataCache = null, this.sessionBreaks.invalidateCache(), 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 });
692
+ 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 });
645
693
  }
646
694
  appendBar(e) {
647
- this.dataManager.appendBar(e), this.crosshairHandler.setData(this.dataManager.getData()), this.displayDataCache = null, this.autoScrollOnNewBar && this.viewport.scrollToEnd(), this.indicatorEngine.recalculateAll(this.dataManager.getData()), this.updateViewportAndRender();
695
+ let t = this.autoScrollOnNewBar && this.viewport.isAtEnd();
696
+ this.dataManager.appendBar(e);
697
+ let n = this.dataManager.getData();
698
+ this.crosshairHandler.setData(n), this.displayDataCache = null, this.indicatorEngine.recalculateFrom(n, n.length - 2), this.updateViewportAndRender(t);
648
699
  }
649
700
  appendBars(e) {
650
- if (e.length !== 0) {
651
- for (let t of e) this.dataManager.appendBar(t);
652
- this.displayDataCache = null, this.indicatorEngine.recalculateAll(this.dataManager.getData()), this.crosshairHandler.setData(this.dataManager.getData()), this.updateViewportAndRender(this.viewport.isAtEnd());
653
- }
701
+ if (e.length === 0) return;
702
+ let t = this.viewport.isAtEnd(), n = this.dataManager.getLength() - 1;
703
+ for (let t of e) this.dataManager.appendBar(t);
704
+ this.displayDataCache = null, this.indicatorEngine.recalculateFrom(this.dataManager.getData(), n), this.crosshairHandler.setData(this.dataManager.getData()), this.updateViewportAndRender(t);
654
705
  }
655
706
  updateLastBar(e) {
656
- 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), this.indicatorEngine.recalculateAll(this.dataManager.getData()), this.scheduleRender();
707
+ 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);
708
+ let t = this.dataManager.getData();
709
+ this.indicatorEngine.recalculateFrom(t, t.length - 1), this.scheduleRender();
657
710
  }
658
711
  updateLastBarFromTick(e) {
659
- 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), this.indicatorEngine.recalculateAll(this.dataManager.getData()), this.scheduleRender();
712
+ 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);
713
+ let t = this.dataManager.getData();
714
+ this.indicatorEngine.recalculateFrom(t, t.length - 1), this.scheduleRender();
660
715
  }
661
716
  setChartType(e) {
662
717
  this.options.chartType = e, this.chartRenderer = this.createChartRenderer(e), this.chartLegend.setChartType(e), this.displayDataCache = null, this.updateViewportAndRender(!0);
@@ -686,8 +741,8 @@ var ft = 6, pt = class {
686
741
  return this.pluginManager;
687
742
  }
688
743
  static indicators() {
689
- let e = new y();
690
- return w(e), e.getAvailableIndicators();
744
+ let e = new v();
745
+ return C(e), e.getAvailableIndicators();
691
746
  }
692
747
  setPanelPosition(e, t) {
693
748
  this.layoutManager.setPanelPosition(e, t), this.engine.requestRender();
@@ -726,7 +781,7 @@ var ft = 6, pt = class {
726
781
  }
727
782
  autoFib() {
728
783
  if (!this.features.drawings) return null;
729
- let e = this.getDisplayData(), t = this.viewport.getState(), n = Ke(e, t.visibleRange.from, t.visibleRange.to);
784
+ let e = this.getDisplayData(), t = this.viewport.getState(), n = Ye(e, t.visibleRange.from, t.visibleRange.to);
730
785
  return n ? this.addDrawing({
731
786
  type: "fibRetracement",
732
787
  anchors: [n[0], n[1]]
@@ -781,21 +836,21 @@ var ft = 6, pt = class {
781
836
  exportVisibleData(e = "csv", t) {
782
837
  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);
783
838
  if (e === "json") {
784
- let e = v.toJSON(o);
785
- v.download(e, t ?? "chart-data.json", "application/json");
839
+ let e = _.toJSON(o);
840
+ _.download(e, t ?? "chart-data.json", "application/json");
786
841
  } else {
787
- let e = v.toCSV(o);
788
- v.download(e, t ?? "chart-data.csv", "text/csv");
842
+ let e = _.toCSV(o);
843
+ _.download(e, t ?? "chart-data.csv", "text/csv");
789
844
  }
790
845
  }
791
846
  exportAllData(e = "csv", t) {
792
847
  let n = this.dataManager.getData();
793
848
  if (e === "json") {
794
- let e = v.toJSON(n);
795
- v.download(e, t ?? "chart-data.json", "application/json");
849
+ let e = _.toJSON(n);
850
+ _.download(e, t ?? "chart-data.json", "application/json");
796
851
  } else {
797
- let e = v.toCSV(n);
798
- v.download(e, t ?? "chart-data.csv", "text/csv");
852
+ let e = _.toCSV(n);
853
+ _.download(e, t ?? "chart-data.csv", "text/csv");
799
854
  }
800
855
  }
801
856
  setAutoSave(e, t = 5e3) {
@@ -893,26 +948,33 @@ var ft = 6, pt = class {
893
948
  this.features.trading && this.tradingManager.setConfig(e);
894
949
  }
895
950
  async connect(e) {
896
- this.disconnectStream(), this.streamManager = new Pe(), this.streamManager.on("snapshot", (e) => {
951
+ this.disconnectStream(), this.streamManager = new Le(), this.streamManager.on("snapshot", (e) => {
897
952
  this.setData(e);
898
953
  }), this.streamManager.on("barClose", (e) => {
899
- this.dataManager.appendBar(e), this.crosshairHandler.setData(this.dataManager.getData()), this.autoScrollOnNewBar && this.viewport.scrollToEnd(), this.indicatorEngine.recalculateAll(this.dataManager.getData()), this.updateViewportAndRender();
954
+ let t = this.autoScrollOnNewBar && this.viewport.isAtEnd();
955
+ this.dataManager.appendBar(e);
956
+ let n = this.dataManager.getData();
957
+ this.crosshairHandler.setData(n), this.displayDataCache = null, this.indicatorEngine.recalculateFrom(n, n.length - 2), this.updateViewportAndRender(t);
900
958
  }), this.streamManager.on("barUpdate", (e) => {
901
- this.dataManager.updateLastBar(e), this.currentPriceLine.setPrice(e.close), this.indicatorEngine.recalculateAll(this.dataManager.getData()), this.scheduleRender();
902
- }), this.streamManager.on("priceChange", ({ price: e }) => {
903
- this.tradingManager.setCurrentPrice(e), this.currentPriceLine.setPrice(e), this.engine.requestRender(r.Overlay), this.engine.requestRender(r.UI);
959
+ this.dataManager.updateLastBar(e), this.currentPriceLine.setPrice(e.close);
960
+ let t = this.dataManager.getData();
961
+ this.indicatorEngine.recalculateFrom(t, t.length - 1), this.scheduleRender();
962
+ }), this.streamManager.on("priceChange", ({ price: e, previousClose: t }) => {
963
+ this.tradingManager.setCurrentPrice(e), this.currentPriceLine.setPrice(e, t ?? void 0), this.engine.requestRender(r.Overlay), this.engine.requestRender(r.UI);
904
964
  }), this.streamManager.on("connectionChange", (e) => {
905
965
  this.eventBus.emit("dataUpdate", { connection: e });
906
966
  }), this.streamManager.on("error", (e) => {
907
967
  this.eventBus.emit("dataUpdate", { error: e.message });
908
- }), this.autoScrollOnNewBar = e.autoScroll !== !1, this.currentSymbol = e.symbol, await this.streamManager.connect(e);
909
- let t = u(e.timeframe);
910
- this.barCountdown.setTimeframeMs(t), this.countdownInterval && clearInterval(this.countdownInterval), this.countdownInterval = setInterval(() => {
968
+ }), this.autoScrollOnNewBar = e.autoScroll !== !1, this.currentSymbol = e.symbol;
969
+ let t = this.streamManager;
970
+ if (await t.connect(e), this.streamManager !== t) return;
971
+ let n = f(e.timeframe);
972
+ this.barCountdown.setTimeframeMs(n), this.countdownInterval && clearInterval(this.countdownInterval), this.countdownInterval = setInterval(() => {
911
973
  this.barCountdown.isVisible() && this.engine.requestRender(r.UI);
912
974
  }, 1e3);
913
975
  }
914
976
  async switchStream(e, t) {
915
- this.streamManager && (this.currentSymbol = e, await this.streamManager.switchTo(e, t));
977
+ this.streamManager && (this.currentSymbol = e, this.barCountdown.setTimeframeMs(f(t)), await this.streamManager.switchTo(e, t));
916
978
  }
917
979
  async setTimeframe(e) {
918
980
  if (!this.streamManager) throw Error("No active stream. Call connect() first.");
@@ -923,7 +985,7 @@ var ft = 6, pt = class {
923
985
  }
924
986
  connectExecution(e, t = {}) {
925
987
  if (!this.features.trading) throw Error("connectExecution requires features.trading to be enabled");
926
- this.disconnectExecution(), this.executionAdapter = e, this.execTeardown = dt(e, {
988
+ this.disconnectExecution(), this.executionAdapter = e, this.execTeardown = yt(e, {
927
989
  onIntent: (e, t) => {
928
990
  let n = (e) => t(e.payload);
929
991
  return this.eventBus.on(e, n), () => this.eventBus.off(e, n);
@@ -1061,7 +1123,7 @@ var ft = 6, pt = class {
1061
1123
  }), this.engine.requestRender(r.Background);
1062
1124
  }
1063
1125
  setAutoScale(e) {
1064
- this.options.autoScale = e, this.updateViewportAndRender();
1126
+ this.options.autoScale = e, this.defaultAutoScale = e, this.updateViewportAndRender();
1065
1127
  }
1066
1128
  isAutoScale() {
1067
1129
  return this.options.autoScale !== !1;
@@ -1246,9 +1308,15 @@ var ft = 6, pt = class {
1246
1308
  replayStart(e) {
1247
1309
  if (!this.features.replay) return;
1248
1310
  let t = this.dataManager.getData();
1249
- this.replayManager.load(t), this.replayManager.on("bar", ({ bar: e, index: n }) => {
1250
- let r = t.slice(0, n + 1);
1251
- this.dataManager.setData(r), this.crosshairHandler.setData(r), this.indicatorEngine.recalculateAll(r), this.updateViewportAndRender();
1311
+ this.replayManager.load(t);
1312
+ let n = -1;
1313
+ this.replayBarUnsub?.(), this.replayBarUnsub = this.replayManager.on("bar", ({ bar: e, index: r }) => {
1314
+ let i = r + 1;
1315
+ if (n > 0 && i > n && this.dataManager.getLength() === n) {
1316
+ for (let e = n; e < i; e++) this.dataManager.appendBar(t[e]);
1317
+ this.indicatorEngine.recalculateFrom(this.dataManager.getData(), n);
1318
+ } else this.dataManager.setData(t.slice(0, i)), this.indicatorEngine.recalculateAll(this.dataManager.getData());
1319
+ n = i, this.crosshairHandler.setData(this.dataManager.getData()), this.displayDataCache = null, this.updateViewportAndRender();
1252
1320
  }), this.replayManager.play(e);
1253
1321
  }
1254
1322
  replayPause() {
@@ -1274,16 +1342,16 @@ var ft = 6, pt = class {
1274
1342
  }
1275
1343
  saveState(e) {
1276
1344
  if (!this.features.saveLoad) return null;
1277
- let t = _.capture({
1345
+ let t = g.capture({
1278
1346
  getDrawings: () => this.getDrawings(),
1279
1347
  getTheme: () => this.getTheme(),
1280
1348
  getAlerts: () => this.getAlerts()
1281
- }, { chartType: this.options.chartType }), n = _.serialize(t);
1282
- return e && _.saveToStorage(e, t), n;
1349
+ }, { chartType: this.options.chartType }), n = g.serialize(t);
1350
+ return e && g.saveToStorage(e, t), n;
1283
1351
  }
1284
1352
  loadState(e) {
1285
1353
  if (!this.features.saveLoad) return;
1286
- let t = _.deserialize(e);
1354
+ let t = g.deserialize(e);
1287
1355
  if (t.chartType && this.setChartType(t.chartType), t.drawings && this.setDrawings(t.drawings), t.theme && this.setTheme(t.theme), t.alerts) {
1288
1356
  this.clearAlerts();
1289
1357
  for (let e of t.alerts) this.addAlert(e.price, e.condition, e.message);
@@ -1291,28 +1359,28 @@ var ft = 6, pt = class {
1291
1359
  }
1292
1360
  loadStateFromStorage(e) {
1293
1361
  if (!this.features.saveLoad) return !1;
1294
- let t = _.loadFromStorage(e);
1295
- return t ? (this.loadState(_.serialize(t)), !0) : !1;
1362
+ let t = g.loadFromStorage(e);
1363
+ return t ? (this.loadState(g.serialize(t)), !0) : !1;
1296
1364
  }
1297
1365
  downloadState(e) {
1298
1366
  if (!this.features.saveLoad) return;
1299
- let t = _.capture({
1367
+ let t = g.capture({
1300
1368
  getDrawings: () => this.getDrawings(),
1301
1369
  getTheme: () => this.getTheme(),
1302
1370
  getAlerts: () => this.getAlerts()
1303
1371
  }, { chartType: this.options.chartType });
1304
- _.downloadFile(t, e);
1372
+ g.downloadFile(t, e);
1305
1373
  }
1306
1374
  async loadStateFromFile() {
1307
1375
  if (!this.features.saveLoad) return;
1308
- let e = await _.loadFromFile();
1309
- this.loadState(_.serialize(e));
1376
+ let e = await g.loadFromFile();
1377
+ this.loadState(g.serialize(e));
1310
1378
  }
1311
1379
  setLocale(e) {
1312
- l(e), this.engine.requestRender();
1380
+ d(e), this.engine.requestRender();
1313
1381
  }
1314
1382
  setNumberLocale(e) {
1315
- this.numberLocale = e, this.priceAxis.setLocale(e), this.crosshairHandler.setLocale(e), this.syncRenderContext(), this.engine.requestRender();
1383
+ this.numberLocale = e, this.priceAxis.setLocale(e), this.crosshairHandler.setLocale(e), this.chartLegend.setLocale(e), this.sessionBreaks.setLocale(e), this.currentPriceLine.setLocale(e), this.updateViewportAndRender();
1316
1384
  }
1317
1385
  getNumberLocale() {
1318
1386
  return this.numberLocale;
@@ -1330,13 +1398,13 @@ var ft = 6, pt = class {
1330
1398
  };
1331
1399
  this.themeManager.setTheme(t);
1332
1400
  }
1333
- e.pricePrecision !== void 0 && (this.tradingManager.setConfig({ pricePrecision: e.pricePrecision }), this.alertManager.setPricePrecision(e.pricePrecision), this.streamManager?.priceLine.setPricePrecision(e.pricePrecision), this.crosshairHandler.setPricePrecision(e.pricePrecision)), this.syncRenderContext(), this.engine.requestRender();
1401
+ 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.updateViewportAndRender();
1334
1402
  }
1335
1403
  getMarket() {
1336
1404
  return this.marketConfig;
1337
1405
  }
1338
1406
  setPriceLimits(e) {
1339
- this.marketConfig && (s(e, this.marketConfig) && (this.marketConfig.priceLimits = {
1407
+ this.marketConfig && (c(e, this.marketConfig) && (this.marketConfig.priceLimits = {
1340
1408
  ...this.marketConfig.priceLimits,
1341
1409
  referencePrice: e
1342
1410
  }), this.engine.requestRender());
@@ -1345,7 +1413,7 @@ var ft = 6, pt = class {
1345
1413
  return this.features;
1346
1414
  }
1347
1415
  setFeatures(e) {
1348
- Object.assign(this.features, e), e.crosshair === !1 && this.crosshairTooltip.hide(), e.grid !== void 0 && this.engine.requestRender(r.Background), e.volume !== void 0 && (this.volumeRenderer.setVisible(e.volume), this.engine.requestRender(r.Main)), e.drawings === !1 && this.drawingManager.setActiveTool(null), e.trading === !1 && (this.tradingManager.setOrders([]), this.tradingManager.setPositions([])), e.keyboard !== void 0 && this.keyboardHandler?.setEnabled(e.keyboard), this.engine.requestRender();
1416
+ Object.assign(this.features, e), (e.crosshair === !1 || e.crosshairTooltip === !1) && this.crosshairTooltip.hide(), e.grid !== void 0 && this.engine.requestRender(r.Background), e.volume !== void 0 && (this.volumeRenderer.setVisible(e.volume), this.engine.requestRender(r.Main)), e.drawings === !1 && this.drawingManager.setActiveTool(null), e.trading === !1 && (this.tradingManager.setOrders([]), this.tradingManager.setPositions([])), e.keyboard !== void 0 && this.keyboardHandler?.setEnabled(e.keyboard), this.engine.requestRender();
1349
1417
  }
1350
1418
  resize() {
1351
1419
  let e = this.engine.dprManager.readContainerSize();
@@ -1360,42 +1428,63 @@ var ft = 6, pt = class {
1360
1428
  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 = "";
1361
1429
  }
1362
1430
  createChartRenderer(e) {
1363
- return rt(e, (e) => this.pluginManager.getChartType(e));
1431
+ return at(e, (e) => this.pluginManager.getChartType(e));
1364
1432
  }
1365
1433
  getDisplayData() {
1366
1434
  if (this.displayDataCache) return this.displayDataCache;
1367
1435
  let e = this.dataManager.getData();
1368
1436
  if (e.length === 0) return e;
1369
- let t = it(this.options.chartType, e, (e) => this.pluginManager.getChartType(e));
1437
+ let t = ot(this.options.chartType, e, (e) => this.pluginManager.getChartType(e));
1370
1438
  return this.displayDataCache = t, t;
1371
1439
  }
1372
1440
  scheduleRender() {
1373
1441
  this.renderScheduled || (this.renderScheduled = !0, requestAnimationFrame(() => {
1374
- this.renderScheduled = !1;
1375
- let e = this.getDisplayData();
1376
- this.viewport.updateData(e, this.options.autoScale !== !1), this.syncRenderContext(), this.engine.requestRender();
1442
+ this.renderScheduled = !1, this.applyDataToViewport(), this.fitPriceAxisWidth() && this.applyDataToViewport(), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents();
1377
1443
  }));
1378
1444
  }
1379
- updateViewportAndRender(e = !1) {
1380
- this.resolvedLayoutCache = null, this.panelInfoCache = null;
1381
- let t = this.getResolvedLayout();
1382
- this.viewport.setChartRect(t.mainChartRect);
1383
- let n = this.getDisplayData();
1384
- if (this.viewport.updateData(n, this.options.autoScale !== !1), n.length > 0) {
1385
- let e = this.viewport.getState(), t = Math.max(0, Math.min(e.visibleRange.from, n.length - 1));
1386
- this.viewport.setScaleBaseline(n[t]?.close);
1445
+ applyDataToViewport(e = !1) {
1446
+ let t = this.getDisplayData(), n = this.options.autoScale !== !1;
1447
+ this.viewport.updateData(t, n && !e), e && (this.viewport.scrollToEnd(), n && this.viewport.updateData(t, !0));
1448
+ let r = this.viewport.getState();
1449
+ if (t.length > 0) {
1450
+ let e = Math.max(0, Math.min(r.visibleRange.from, t.length - 1));
1451
+ this.viewport.setScaleBaseline(t[e]?.close);
1387
1452
  }
1388
- if (this.options.autoScale !== !1) {
1389
- let e = this.viewport.getState(), t = this.indicatorEngine.getOverlayPriceRange(e.visibleRange.from, Math.min(e.visibleRange.to, n.length - 1));
1390
- if (t) {
1391
- let n = e.priceRange, r = Math.min(n.min, t.min), i = Math.max(n.max, t.max);
1392
- if (r < n.min || i > n.max) {
1393
- let e = i - r || 1;
1394
- this.viewport.setPriceRange(r - e * .02, i + e * .02);
1453
+ if (n) {
1454
+ let e = this.indicatorEngine.getOverlayPriceRange(r.visibleRange.from, Math.min(r.visibleRange.to, t.length - 1));
1455
+ if (e) {
1456
+ let t = r.priceRange, n = Math.min(t.min, e.min), i = Math.max(t.max, e.max);
1457
+ if (n < t.min || i > t.max) {
1458
+ let e = i - n || 1;
1459
+ this.viewport.setPriceRange(n - e * .02, i + e * .02);
1395
1460
  }
1396
1461
  }
1397
1462
  }
1398
- e && this.viewport.scrollToEnd(), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents();
1463
+ return t;
1464
+ }
1465
+ updateViewportAndRender(e = !1) {
1466
+ this.resolvedLayoutCache = null, this.panelInfoCache = null;
1467
+ let t = this.getResolvedLayout();
1468
+ this.viewport.setChartRect(t.mainChartRect), this.applyDataToViewport(e), this.fitPriceAxisWidth() && this.applyDataToViewport(e), this.syncRenderContext(), this.engine.requestRender(), this.emitViewportEvents();
1469
+ }
1470
+ fitPriceAxisWidth() {
1471
+ if (!this.features.priceAxis) return !1;
1472
+ let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n = pt({
1473
+ min: e.min,
1474
+ max: e.max,
1475
+ lastPrice: this.currentPriceLine.getPrice(),
1476
+ tagPrecision: this.marketConfig?.pricePrecision ?? null,
1477
+ locale: this.numberLocale,
1478
+ fontFamily: t.font.family,
1479
+ fontSizeSmall: t.font.sizeSmall,
1480
+ measure: (e, t) => this.measureText(e, t)
1481
+ }), r = mt(this.priceAxisWidth, n);
1482
+ 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);
1483
+ }
1484
+ measureText(e, t) {
1485
+ this.measureCtx === void 0 && (this.measureCtx = typeof document < "u" ? document.createElement("canvas").getContext("2d") : null);
1486
+ let n = this.measureCtx;
1487
+ return n ? (n.font = t, n.measureText(e).width) : e.length * 7;
1399
1488
  }
1400
1489
  emitViewportEvents() {
1401
1490
  let e = this.viewport.getState(), t = Math.max(0, Math.floor(e.visibleRange.from)), n = Math.max(t, Math.ceil(e.visibleRange.to));
@@ -1425,7 +1514,7 @@ var ft = 6, pt = class {
1425
1514
  buildPanelRenderInfos() {
1426
1515
  if (this.panelInfoCache) return this.panelInfoCache;
1427
1516
  let e = this.getResolvedLayout(), t = this.viewport.getState(), { from: n, to: r } = t.visibleRange, i = e.panels.map((e) => {
1428
- let i = at(this.indicatorEngine.getOutput(e.config.id), n, r), a = {
1517
+ let i = st(this.indicatorEngine.getOutput(e.config.id), n, r), a = {
1429
1518
  x: e.rect.x,
1430
1519
  y: e.rect.y + 20,
1431
1520
  width: e.rect.width,
@@ -1455,7 +1544,7 @@ var ft = 6, pt = class {
1455
1544
  indicatorEngine: this.features.indicators ? this.indicatorEngine : null,
1456
1545
  drawingRenderer: this.features.drawings ? this.drawingRenderer : null,
1457
1546
  tradingRenderer: this.features.trading ? this.tradingRenderer : null,
1458
- currentPriceLine: this.streamManager?.priceLine ?? this.currentPriceLine,
1547
+ currentPriceLine: this.currentPriceLine,
1459
1548
  chartLegend: this.features.legend ? this.chartLegend : null,
1460
1549
  volumeRenderer: this.features.volume ? this.volumeRenderer : null,
1461
1550
  volumeProfile: this.volumeProfile,
@@ -1486,7 +1575,7 @@ var ft = 6, pt = class {
1486
1575
  });
1487
1576
  }
1488
1577
  drawOverlayPlugins(e, t) {
1489
- let n = F(this.pluginManager.getOverlays(), t);
1578
+ let n = I(this.pluginManager.getOverlays(), t);
1490
1579
  if (n.length === 0) return;
1491
1580
  let r = {
1492
1581
  viewport: this.viewport.getState(),
@@ -1497,7 +1586,7 @@ var ft = 6, pt = class {
1497
1586
  }
1498
1587
  buildPriceLimits() {
1499
1588
  if (!this.marketConfig?.priceLimits?.enabled || !this.marketConfig.priceLimits.referencePrice) return null;
1500
- let e = s(this.marketConfig.priceLimits.referencePrice, this.marketConfig);
1589
+ let e = c(this.marketConfig.priceLimits.referencePrice, this.marketConfig);
1501
1590
  return e ? {
1502
1591
  ...e,
1503
1592
  colors: this.marketConfig.colorScheme ? {
@@ -1507,26 +1596,26 @@ var ft = 6, pt = class {
1507
1596
  } : void 0
1508
1597
  } : null;
1509
1598
  }
1510
- }, V = [
1599
+ }, H = [
1511
1600
  "time",
1512
1601
  "timestamp",
1513
1602
  "date",
1514
1603
  "datetime",
1515
1604
  "t"
1516
- ], H = ["open", "o"], U = ["high", "h"], W = ["low", "l"], G = ["close", "c"], K = [
1605
+ ], U = ["open", "o"], W = ["high", "h"], G = ["low", "l"], K = ["close", "c"], q = [
1517
1606
  "volume",
1518
1607
  "vol",
1519
1608
  "v"
1520
1609
  ];
1521
- function q(e) {
1610
+ function J(e) {
1522
1611
  let t = e.trim();
1523
- return t ? t[0] === "[" || t[0] === "{" ? mt(t) : ht(t) : {
1612
+ return t ? t[0] === "[" || t[0] === "{" ? St(t) : Ct(t) : {
1524
1613
  data: [],
1525
1614
  rowCount: 0,
1526
1615
  skipped: 0
1527
1616
  };
1528
1617
  }
1529
- function mt(e) {
1618
+ function St(e) {
1530
1619
  let t;
1531
1620
  try {
1532
1621
  t = JSON.parse(e);
@@ -1536,19 +1625,19 @@ function mt(e) {
1536
1625
  if (!Array.isArray(t)) throw Error("Expected a JSON array of OHLCV rows");
1537
1626
  let n = [], r = 0;
1538
1627
  for (let e of t) {
1539
- let t = Array.isArray(e) ? yt(e) : vt(e);
1628
+ let t = Array.isArray(e) ? Dt(e) : Et(e);
1540
1629
  t ? n.push(t) : r++;
1541
1630
  }
1542
- return Z(n, t.length, r);
1631
+ return Q(n, t.length, r);
1543
1632
  }
1544
- function ht(e) {
1633
+ function Ct(e) {
1545
1634
  let t = e.split(/\r?\n/).filter((e) => e.trim().length > 0);
1546
1635
  if (t.length === 0) return {
1547
1636
  data: [],
1548
1637
  rowCount: 0,
1549
1638
  skipped: 0
1550
1639
  };
1551
- let n = gt(t[0]), r = J(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? _t(r) : {
1640
+ let n = wt(t[0]), r = Y(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? Tt(r) : {
1552
1641
  time: 0,
1553
1642
  open: 1,
1554
1643
  high: 2,
@@ -1559,7 +1648,7 @@ function ht(e) {
1559
1648
  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");
1560
1649
  let o = [], s = 0;
1561
1650
  for (let e = +!!i; e < t.length; e++) {
1562
- let r = J(t[e], n), i = X(r[a.time]), c = Y(r[a.open]), l = Y(r[a.high]), u = Y(r[a.low]), d = Y(r[a.close]), f = a.volume >= 0 ? Number(r[a.volume]) : 0;
1651
+ 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;
1563
1652
  if (i === null || ![
1564
1653
  c,
1565
1654
  l,
@@ -1578,9 +1667,9 @@ function ht(e) {
1578
1667
  volume: Number.isFinite(f) ? f : 0
1579
1668
  });
1580
1669
  }
1581
- return Z(o, t.length - +!!i, s);
1670
+ return Q(o, t.length - +!!i, s);
1582
1671
  }
1583
- function gt(e) {
1672
+ function wt(e) {
1584
1673
  let t = {
1585
1674
  ",": 0,
1586
1675
  ";": 0,
@@ -1592,7 +1681,7 @@ function gt(e) {
1592
1681
  for (let [e, i] of Object.entries(t)) i > r && (n = e, r = i);
1593
1682
  return n;
1594
1683
  }
1595
- function J(e, t) {
1684
+ function Y(e, t) {
1596
1685
  let n = [], r = "", i = !1;
1597
1686
  for (let a = 0; a < e.length; a++) {
1598
1687
  let o = e[a];
@@ -1600,25 +1689,25 @@ function J(e, t) {
1600
1689
  }
1601
1690
  return n.push(r), n;
1602
1691
  }
1603
- function _t(e) {
1692
+ function Tt(e) {
1604
1693
  let t = (t) => e.findIndex((e) => t.includes(e));
1605
1694
  return {
1606
- time: t(V),
1607
- open: t(H),
1608
- high: t(U),
1609
- low: t(W),
1610
- close: t(G),
1611
- volume: t(K)
1695
+ time: t(H),
1696
+ open: t(U),
1697
+ high: t(W),
1698
+ low: t(G),
1699
+ close: t(K),
1700
+ volume: t(q)
1612
1701
  };
1613
1702
  }
1614
- function vt(e) {
1703
+ function Et(e) {
1615
1704
  let t = (t) => {
1616
1705
  for (let n of t) {
1617
1706
  if (e[n] !== void 0) return e[n];
1618
1707
  let t = n.toUpperCase();
1619
1708
  if (e[t] !== void 0) return e[t];
1620
1709
  }
1621
- }, n = X(String(t(V) ?? "")), r = Number(t(H)), i = Number(t(U)), a = Number(t(W)), o = Number(t(G)), s = Number(t(K) ?? 0);
1710
+ }, 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);
1622
1711
  return n === null || ![
1623
1712
  r,
1624
1713
  i,
@@ -1633,9 +1722,9 @@ function vt(e) {
1633
1722
  volume: Number.isFinite(s) ? s : 0
1634
1723
  };
1635
1724
  }
1636
- function yt(e) {
1725
+ function Dt(e) {
1637
1726
  if (e.length < 5) return null;
1638
- let t = X(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;
1727
+ 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;
1639
1728
  return t === null || ![
1640
1729
  n,
1641
1730
  r,
@@ -1650,10 +1739,10 @@ function yt(e) {
1650
1739
  volume: Number.isFinite(o) ? o : 0
1651
1740
  };
1652
1741
  }
1653
- function Y(e) {
1742
+ function X(e) {
1654
1743
  return e === void 0 || e.trim() === "" ? NaN : Number(e);
1655
1744
  }
1656
- function X(e) {
1745
+ function Z(e) {
1657
1746
  let t = e.trim();
1658
1747
  if (!t) return null;
1659
1748
  let n = Number(t);
@@ -1661,7 +1750,7 @@ function X(e) {
1661
1750
  let r = Date.parse(t);
1662
1751
  return Number.isFinite(r) ? r : null;
1663
1752
  }
1664
- function Z(e, t, n) {
1753
+ function Q(e, t, n) {
1665
1754
  e.sort((e, t) => e.time - t.time);
1666
1755
  let r = [];
1667
1756
  for (let t of e) r.length > 0 && r[r.length - 1].time === t.time ? r[r.length - 1] = t : r.push(t);
@@ -1673,7 +1762,7 @@ function Z(e, t, n) {
1673
1762
  }
1674
1763
  //#endregion
1675
1764
  //#region src/io/DragDropImporter.ts
1676
- var Q = class {
1765
+ var Ot = class {
1677
1766
  host;
1678
1767
  overlay = null;
1679
1768
  callbacks;
@@ -1706,7 +1795,7 @@ var Q = class {
1706
1795
  e.preventDefault(), this.depth = 0, this.hideOverlay();
1707
1796
  let t = e.dataTransfer?.files?.[0];
1708
1797
  if (t) try {
1709
- let e = q(await t.text());
1798
+ let e = J(await t.text());
1710
1799
  if (e.data.length === 0) throw Error(`No valid OHLCV rows found in "${t.name}"`);
1711
1800
  this.callbacks.onData(e.data, e, t);
1712
1801
  } catch (e) {
@@ -1741,6 +1830,6 @@ function $(e) {
1741
1830
  return e.dataTransfer?.types?.includes("Files") ?? !1;
1742
1831
  }
1743
1832
  //#endregion
1744
- export { ut as a, lt as c, I as d, P as f, z as i, st as l, A as m, q as n, R as o, j as p, pt as r, ct as s, Q as t, F as u };
1833
+ export { vt as a, _t as c, L as d, P as f, B as i, ht as l, A as m, J as n, z as o, j as p, xt as r, gt as s, Ot as t, I as u };
1745
1834
 
1746
- //# sourceMappingURL=DragDropImporter-BGNGtnk4.js.map
1835
+ //# sourceMappingURL=DragDropImporter-BcTzFeRP.js.map