@tradecanvas/core 0.1.3 → 0.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.
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { DEFAULT_BAR_SPACING as e, DEFAULT_BAR_WIDTH as t, DEFAULT_RECONNECT as n, DEFAULT_STREAM_CONFIG as r, DEFAULT_TRADING_CONFIG as i, LayerType as a, PRICE_AXIS_WIDTH as o, TIME_AXIS_HEIGHT as s, clamp as c, computePriceRange as l, computeTickStep as u, formatPrice as d, sliceVisibleData as f, timeframeToMs as p, withAlpha as m } from "@tradecanvas/commons";
1
+ import { DARK_THEME as e, DEFAULT_BAR_SPACING as t, DEFAULT_BAR_WIDTH as n, DEFAULT_RECONNECT as r, DEFAULT_STREAM_CONFIG as i, DEFAULT_TRADING_CONFIG as a, LIGHT_THEME as o, LayerType as s, PRICE_AXIS_WIDTH as c, TIME_AXIS_HEIGHT as l, clamp as u, computePriceRange as d, computeTickStep as f, formatPrice as p, lerpColor as m, sliceVisibleData as h, timeframeToMs as g, withAlpha as _ } from "@tradecanvas/commons";
2
2
  //#region src/engine/CanvasLayer.ts
3
- var h = class {
3
+ var v = class {
4
4
  canvas;
5
5
  ctx;
6
6
  dpr = 1;
@@ -24,7 +24,7 @@ var h = class {
24
24
  destroy() {
25
25
  this.canvas.remove();
26
26
  }
27
- }, g = class {
27
+ }, y = class {
28
28
  layers = /* @__PURE__ */ new Map();
29
29
  constructor(e) {
30
30
  this.container = e;
@@ -32,11 +32,11 @@ var h = class {
32
32
  createLayers() {
33
33
  this.destroy();
34
34
  for (let e of [
35
- a.Background,
36
- a.Main,
37
- a.Overlay,
38
- a.UI
39
- ]) this.layers.set(e, new h(this.container, e));
35
+ s.Background,
36
+ s.Main,
37
+ s.Overlay,
38
+ s.UI
39
+ ]) this.layers.set(e, new v(this.container, e));
40
40
  }
41
41
  getLayer(e) {
42
42
  return this.layers.get(e);
@@ -48,7 +48,7 @@ var h = class {
48
48
  for (let e of this.layers.values()) e.destroy();
49
49
  this.layers.clear();
50
50
  }
51
- }, _ = class {
51
+ }, b = class {
52
52
  animFrameId = 0;
53
53
  running = !1;
54
54
  dirtyLayers = /* @__PURE__ */ new Set();
@@ -61,7 +61,7 @@ var h = class {
61
61
  this.dirtyLayers.add(e), this.running && !this.animFrameId && this.scheduleFrame();
62
62
  }
63
63
  markAllDirty() {
64
- this.dirtyLayers.add(a.Background), this.dirtyLayers.add(a.Main), this.dirtyLayers.add(a.Overlay), this.dirtyLayers.add(a.UI), this.running && !this.animFrameId && this.scheduleFrame();
64
+ this.dirtyLayers.add(s.Background), this.dirtyLayers.add(s.Main), this.dirtyLayers.add(s.Overlay), this.dirtyLayers.add(s.UI), this.running && !this.animFrameId && this.scheduleFrame();
65
65
  }
66
66
  start() {
67
67
  this.running = !0, this.markAllDirty();
@@ -77,7 +77,7 @@ var h = class {
77
77
  }
78
78
  });
79
79
  }
80
- }, v = class {
80
+ }, x = class {
81
81
  observer = null;
82
82
  callback = null;
83
83
  currentDpr = 1;
@@ -120,10 +120,10 @@ var h = class {
120
120
  };
121
121
  //#endregion
122
122
  //#region src/viewport/ScaleMapping.ts
123
- function y(e, t) {
123
+ function S(e, t) {
124
124
  return e * (t.barWidth + t.barSpacing) - t.offset + t.chartRect.x + t.barWidth / 2;
125
125
  }
126
- function b(e, t) {
126
+ function C(e, t) {
127
127
  let { min: n, max: r } = t.priceRange;
128
128
  if (t.logScale && n > 0 && r > 0) {
129
129
  let i = Math.log(n), a = Math.log(r) - i;
@@ -136,11 +136,11 @@ function b(e, t) {
136
136
  let a = (e - n) / i;
137
137
  return t.chartRect.y + t.chartRect.height * (1 - a);
138
138
  }
139
- function x(e, t) {
139
+ function w(e, t) {
140
140
  let n = t.barWidth + t.barSpacing;
141
141
  return Math.round((e - t.chartRect.x - t.barWidth / 2 + t.offset) / n);
142
142
  }
143
- function S(e, t) {
143
+ function T(e, t) {
144
144
  let { min: n, max: r } = t.priceRange, i = 1 - (e - t.chartRect.y) / t.chartRect.height;
145
145
  if (t.logScale && n > 0 && r > 0) {
146
146
  let e = Math.log(n);
@@ -148,7 +148,7 @@ function S(e, t) {
148
148
  }
149
149
  return n + (r - n) * i;
150
150
  }
151
- function C(e, t) {
151
+ function E(e, t) {
152
152
  if (t.length === 0) return -1;
153
153
  if (e <= t[0].time) return 0;
154
154
  if (e >= t[t.length - 1].time) return t.length - 1;
@@ -165,7 +165,7 @@ function C(e, t) {
165
165
  }
166
166
  //#endregion
167
167
  //#region src/engine/RenderEngine.ts
168
- var w = class {
168
+ var D = class {
169
169
  layerManager;
170
170
  renderLoop;
171
171
  dprManager;
@@ -176,14 +176,14 @@ var w = class {
176
176
  uiLayer;
177
177
  onContainerResize = null;
178
178
  constructor(e) {
179
- this.layerManager = new g(e), this.renderLoop = new _(), this.dprManager = new v(e), this.layerManager.createLayers(), this.cacheLayerRefs(), this.renderLoop.setCallback((e) => this.render(e)), this.dprManager.onResize((e, t) => {
179
+ this.layerManager = new y(e), this.renderLoop = new b(), this.dprManager = new x(e), this.layerManager.createLayers(), this.cacheLayerRefs(), this.renderLoop.setCallback((e) => this.render(e)), this.dprManager.onResize((e, t) => {
180
180
  this.layerManager.resize(e, t), this.renderLoop.markAllDirty(), this.onContainerResize?.(e);
181
181
  });
182
182
  let t = this.dprManager.getContainerSize(), n = this.dprManager.getDpr();
183
183
  this.layerManager.resize(t, n);
184
184
  }
185
185
  cacheLayerRefs() {
186
- this.bgLayer = this.layerManager.getLayer(a.Background), this.mainLayer = this.layerManager.getLayer(a.Main), this.overlayLayer = this.layerManager.getLayer(a.Overlay), this.uiLayer = this.layerManager.getLayer(a.UI);
186
+ this.bgLayer = this.layerManager.getLayer(s.Background), this.mainLayer = this.layerManager.getLayer(s.Main), this.overlayLayer = this.layerManager.getLayer(s.Overlay), this.uiLayer = this.layerManager.getLayer(s.UI);
187
187
  }
188
188
  setRenderContext(e) {
189
189
  this.renderCtx = e;
@@ -202,7 +202,7 @@ var w = class {
202
202
  if (!t) return;
203
203
  let { viewport: n, theme: r, data: i } = t;
204
204
  if (!(n.chartRect.width <= 0 || n.chartRect.height <= 0)) {
205
- if (e.has(a.Background) && this.bgLayer && (this.bgLayer.clear(), t.gridRenderer?.render(this.bgLayer.ctx, n, r), t.sessionBreaks?.render(this.bgLayer.ctx, n, r, i), t.watermark?.render(this.bgLayer.ctx, n, r)), e.has(a.Main) && this.mainLayer) {
205
+ if (e.has(s.Background) && this.bgLayer && (this.bgLayer.clear(), t.gridRenderer?.render(this.bgLayer.ctx, n, r), t.sessionBreaks?.render(this.bgLayer.ctx, n, r, i), t.watermark?.render(this.bgLayer.ctx, n, r)), e.has(s.Main) && this.mainLayer) {
206
206
  this.mainLayer.clear();
207
207
  let e = this.mainLayer.ctx;
208
208
  e.save(), e.beginPath(), e.rect(n.chartRect.x, n.chartRect.y, n.chartRect.width, n.chartRect.height), e.clip(), t.volumeRenderer?.render(e, i, n, r), t.chartRenderer?.render(e, i, n, r), t.compareRenderer?.render(e, i, n, r), t.indicatorEngine?.renderOverlays(e, n), e.restore();
@@ -218,7 +218,7 @@ var w = class {
218
218
  }
219
219
  }
220
220
  }
221
- if (e.has(a.Overlay) && this.overlayLayer) {
221
+ if (e.has(s.Overlay) && this.overlayLayer) {
222
222
  this.overlayLayer.clear();
223
223
  let e = this.overlayLayer.ctx;
224
224
  t.priceLimits && this.renderPriceLimits(e, n, r, t.priceLimits), t.drawingRenderer?.render(e, n), t.tradingRenderer?.render(e, n, r), t.crosshairHandler?.render(e, n, r);
@@ -226,43 +226,43 @@ var w = class {
226
226
  if (i && t.panels.length > 0) for (let n of t.panels) {
227
227
  let a = n.rect;
228
228
  if (i.x >= a.x && i.x <= a.x + a.width && i.y >= a.y && i.y <= a.y + a.height) {
229
- let o = n.viewport, s = i.x, c = x(s, o);
230
- s = y(Math.max(0, Math.min((t.data?.length ?? 1) - 1, Math.round(c))), o), e.save(), e.beginPath(), e.rect(a.x, a.y, a.width, a.height), e.clip(), e.setLineDash([4, 4]), e.strokeStyle = r.crosshair, e.lineWidth = 1, e.beginPath(), e.moveTo(Math.round(s) + .5, a.y), e.lineTo(Math.round(s) + .5, a.y + a.height), e.stroke(), e.beginPath(), e.moveTo(a.x, Math.round(i.y) + .5), e.lineTo(a.x + a.width, Math.round(i.y) + .5), e.stroke(), e.setLineDash([]), e.restore();
229
+ let o = n.viewport, s = i.x, c = w(s, o);
230
+ s = S(Math.max(0, Math.min((t.data?.length ?? 1) - 1, Math.round(c))), o), e.save(), e.beginPath(), e.rect(a.x, a.y, a.width, a.height), e.clip(), e.setLineDash([4, 4]), e.strokeStyle = r.crosshair, e.lineWidth = 1, e.beginPath(), e.moveTo(Math.round(s) + .5, a.y), e.lineTo(Math.round(s) + .5, a.y + a.height), e.stroke(), e.beginPath(), e.moveTo(a.x, Math.round(i.y) + .5), e.lineTo(a.x + a.width, Math.round(i.y) + .5), e.stroke(), e.setLineDash([]), e.restore();
231
231
  break;
232
232
  }
233
233
  }
234
234
  }
235
- if (e.has(a.UI) && this.uiLayer) {
235
+ if (e.has(s.UI) && this.uiLayer) {
236
236
  this.uiLayer.clear();
237
237
  let e = this.uiLayer.ctx;
238
238
  if (t.priceAxis?.render(e, n, r), t.tradingRenderer?.renderAxisBadges(e, n, r), t.currentPriceLine?.render(e, n, r), t.timeAxis?.render(e, n, r, i, t.timeAxisY), t.chartLegend?.render(e, n, r, i), t.barCountdown?.render(e, n, r, i), t.panels.length > 0) {
239
- let n = t.crosshairHandler?.getPosition(), a = t.indicatorEngine, s = `${r.font.sizeSmall}px ${r.font.family}`, c;
239
+ let n = t.crosshairHandler?.getPosition(), a = t.indicatorEngine, o = `${r.font.sizeSmall}px ${r.font.family}`, s;
240
240
  if (a) {
241
241
  let e = a.getPanelIndicators();
242
- c = /* @__PURE__ */ new Map();
243
- for (let t of e) c.set(t.instanceId, t);
242
+ s = /* @__PURE__ */ new Map();
243
+ for (let t of e) s.set(t.instanceId, t);
244
244
  }
245
245
  for (let l of t.panels) {
246
- let t = l.viewport, f = l.rect, { min: p, max: m } = t.priceRange;
247
- if (m - p <= 0 || f.height <= 0) continue;
248
- let h = f.x + f.width, g = t.chartRect;
249
- e.strokeStyle = r.axisLine, e.lineWidth = 1, e.beginPath(), e.moveTo(h + .5, f.y), e.lineTo(h + .5, f.y + f.height), e.stroke();
250
- let _ = u(p, m, 4), v = Math.ceil(p / _) * _, y = _ < 1 ? Math.ceil(-Math.log10(_)) + 1 : +(_ < 10);
251
- e.font = s, e.textBaseline = "middle", e.textAlign = "left";
246
+ let t = l.viewport, u = l.rect, { min: d, max: m } = t.priceRange;
247
+ if (m - d <= 0 || u.height <= 0) continue;
248
+ let h = u.x + u.width, g = t.chartRect;
249
+ e.strokeStyle = r.axisLine, e.lineWidth = 1, e.beginPath(), e.moveTo(h + .5, u.y), e.lineTo(h + .5, u.y + u.height), e.stroke();
250
+ let _ = f(d, m, 4), v = Math.ceil(d / _) * _, y = _ < 1 ? Math.ceil(-Math.log10(_)) + 1 : +(_ < 10);
251
+ e.font = o, e.textBaseline = "middle", e.textAlign = "left";
252
252
  for (let n = v; n <= m; n += _) {
253
- let i = b(n, t);
254
- i < g.y || i > g.y + g.height || (e.strokeStyle = r.axisLine, e.beginPath(), e.moveTo(h, Math.round(i) + .5), e.lineTo(h + 4, Math.round(i) + .5), e.stroke(), e.fillStyle = r.axisLabel, e.fillText(d(n, y), h + 6, i));
253
+ let i = C(n, t);
254
+ i < g.y || i > g.y + g.height || (e.strokeStyle = r.axisLine, e.beginPath(), e.moveTo(h, Math.round(i) + .5), e.lineTo(h + 4, Math.round(i) + .5), e.stroke(), e.fillStyle = r.axisLabel, e.fillText(p(n, y), h + 6, i));
255
255
  }
256
- if (n && n.x >= f.x && n.x <= f.x + f.width && n.y >= f.y && n.y <= f.y + f.height) {
257
- let i = d(S(n.y, t), y);
256
+ if (n && n.x >= u.x && n.x <= u.x + u.width && n.y >= u.y && n.y <= u.y + u.height) {
257
+ let i = p(T(n.y, t), y);
258
258
  e.font = `bold ${r.font.sizeSmall}px ${r.font.family}`;
259
- let a = e.measureText(i).width, s = Math.min(a + 10, o - 2);
260
- e.fillStyle = r.crosshair, e.fillRect(h + 1, n.y - 9, s, 18), e.fillStyle = r.background, e.textBaseline = "middle", e.textAlign = "left", e.fillText(i, h + 5, n.y);
259
+ let a = e.measureText(i).width, o = Math.min(a + 10, c - 2);
260
+ e.fillStyle = r.crosshair, e.fillRect(h + 1, n.y - 9, o, 18), e.fillStyle = r.background, e.textBaseline = "middle", e.textAlign = "left", e.fillText(i, h + 5, n.y);
261
261
  }
262
262
  if (n && a) {
263
- let o = x(n.x, t), u = Math.max(0, Math.min((i?.length ?? 1) - 1, Math.round(o))), d = a.getOutput(l.instanceId);
264
- if (d?.series && u < d.series.length) {
265
- let t = d.series[u];
263
+ let c = w(n.x, t), d = Math.max(0, Math.min((i?.length ?? 1) - 1, Math.round(c))), f = a.getOutput(l.instanceId);
264
+ if (f?.series && d < f.series.length) {
265
+ let t = f.series[d];
266
266
  if (t) {
267
267
  let n = [];
268
268
  for (let e in t) {
@@ -270,8 +270,8 @@ var w = class {
270
270
  r !== void 0 && n.push(`${e}: ${r.toFixed(y)}`);
271
271
  }
272
272
  if (n.length > 0) {
273
- let t = c?.get(l.instanceId), i = t ? e.measureText(t.descriptor.name).width + 14 : 10;
274
- e.font = s, e.fillStyle = r.textSecondary, e.textBaseline = "top", e.textAlign = "left", e.fillText(n.join(" "), f.x + i, f.y + 6);
273
+ let t = s?.get(l.instanceId), i = t ? e.measureText(t.descriptor.name).width + 14 : 10;
274
+ e.font = o, e.fillStyle = r.textSecondary, e.textBaseline = "top", e.textAlign = "left", e.fillText(n.join(" "), u.x + i, u.y + 6);
275
275
  }
276
276
  }
277
277
  }
@@ -298,25 +298,25 @@ var w = class {
298
298
  color: r.colors?.reference ?? "#FFD700",
299
299
  label: "REF"
300
300
  }
301
- ], s = `bold 9px ${n.font.family}`, c = `10px ${n.font.family}`;
301
+ ], o = `bold 9px ${n.font.family}`, s = `10px ${n.font.family}`;
302
302
  for (let { price: n, color: r, label: l } of a) {
303
- let a = b(n, t);
303
+ let a = C(n, t);
304
304
  if (a < i.y || a > i.y + i.height) continue;
305
- e.setLineDash([8, 4]), e.strokeStyle = r, e.lineWidth = 1, e.beginPath(), e.moveTo(i.x, Math.round(a) + .5), e.lineTo(i.x + i.width, Math.round(a) + .5), e.stroke(), e.setLineDash([]), e.font = s, e.fillStyle = r, e.textBaseline = "bottom", e.textAlign = "left", e.fillText(`${l} ${n.toFixed(2)}`, i.x + 4, a - 2);
305
+ e.setLineDash([8, 4]), e.strokeStyle = r, e.lineWidth = 1, e.beginPath(), e.moveTo(i.x, Math.round(a) + .5), e.lineTo(i.x + i.width, Math.round(a) + .5), e.stroke(), e.setLineDash([]), e.font = o, e.fillStyle = r, e.textBaseline = "bottom", e.textAlign = "left", e.fillText(`${l} ${n.toFixed(2)}`, i.x + 4, a - 2);
306
306
  let u = i.x + i.width + 1;
307
- e.fillStyle = r, e.fillRect(u, a - 7, o - 2, 14), e.fillStyle = "#000", e.font = c, e.textBaseline = "middle", e.textAlign = "left", e.fillText(n.toFixed(2), u + 4, a);
307
+ e.fillStyle = r, e.fillRect(u, a - 7, c - 2, 14), e.fillStyle = "#000", e.font = s, e.textBaseline = "middle", e.textAlign = "left", e.fillText(n.toFixed(2), u + 4, a);
308
308
  }
309
309
  }
310
310
  destroy() {
311
311
  this.renderLoop.stop(), this.dprManager.destroy(), this.layerManager.destroy();
312
312
  }
313
- }, T = class {
313
+ }, O = class {
314
314
  state;
315
315
  dataLength = 0;
316
316
  minBarWidth;
317
317
  maxBarWidth;
318
318
  rightMarginBars;
319
- constructor(n, r, i = 2, a = 30, o = 5) {
319
+ constructor(e, r, i = 2, a = 30, o = 5) {
320
320
  this.minBarWidth = i, this.maxBarWidth = a, this.rightMarginBars = o, this.state = {
321
321
  visibleRange: {
322
322
  from: 0,
@@ -326,10 +326,10 @@ var w = class {
326
326
  min: 0,
327
327
  max: 1
328
328
  },
329
- barWidth: t,
330
- barSpacing: e,
329
+ barWidth: n,
330
+ barSpacing: t,
331
331
  offset: 0,
332
- chartRect: this.computeChartRect(n, r)
332
+ chartRect: this.computeChartRect(e, r)
333
333
  };
334
334
  }
335
335
  getState() {
@@ -356,8 +356,8 @@ var w = class {
356
356
  return {
357
357
  x: 0,
358
358
  y: 0,
359
- width: Math.max(0, e - o),
360
- height: Math.max(0, t - s)
359
+ width: Math.max(0, e - c),
360
+ height: Math.max(0, t - l)
361
361
  };
362
362
  }
363
363
  resize(e, t) {
@@ -372,7 +372,7 @@ var w = class {
372
372
  }, this.clampOffset(), this.updateVisibleRange();
373
373
  }
374
374
  updateData(e, t) {
375
- this.dataLength = e.length, this.dataLength !== 0 && (this.clampOffset(), this.updateVisibleRange(), t && (this.state.priceRange = l(e, this.state.visibleRange.from, Math.min(this.state.visibleRange.to, this.dataLength - 1), .08)));
375
+ this.dataLength = e.length, this.dataLength !== 0 && (this.clampOffset(), this.updateVisibleRange(), t && (this.state.priceRange = d(e, this.state.visibleRange.from, Math.min(this.state.visibleRange.to, this.dataLength - 1), .08)));
376
376
  }
377
377
  setPriceRange(e, t) {
378
378
  this.state.priceRange = {
@@ -392,7 +392,7 @@ var w = class {
392
392
  this.state.offset = n - this.state.chartRect.width + t, this.updateVisibleRange();
393
393
  }
394
394
  zoom(e, t) {
395
- let n = this.state.barWidth, r = c(n * (1 + e), this.minBarWidth, this.maxBarWidth);
395
+ let n = this.state.barWidth, r = u(n * (1 + e), this.minBarWidth, this.maxBarWidth);
396
396
  if (r === n) return;
397
397
  let i = this.state.barWidth + this.state.barSpacing, a = (this.state.offset + t) / i;
398
398
  this.state.barWidth = r;
@@ -402,7 +402,7 @@ var w = class {
402
402
  clampOffset() {
403
403
  if (this.state.chartRect.width <= 0) return;
404
404
  let e = this.state.barWidth + this.state.barSpacing, t = this.dataLength * e, n = this.rightMarginBars * e, r = t - this.state.chartRect.width + n, i, a;
405
- r > 0 ? (i = -(this.state.chartRect.width * .5), a = r) : (i = r, a = r), this.state.offset = c(this.state.offset, i, a);
405
+ r > 0 ? (i = -(this.state.chartRect.width * .5), a = r) : (i = r, a = r), this.state.offset = u(this.state.offset, i, a);
406
406
  }
407
407
  updateVisibleRange() {
408
408
  let e = this.state.barWidth + this.state.barSpacing;
@@ -416,12 +416,12 @@ var w = class {
416
416
  };
417
417
  //#endregion
418
418
  //#region src/viewport/DataWindow.ts
419
- function E(e, t) {
420
- return f(e, t.visibleRange.from, t.visibleRange.to);
419
+ function k(e, t) {
420
+ return h(e, t.visibleRange.from, t.visibleRange.to);
421
421
  }
422
422
  //#endregion
423
423
  //#region src/charts/CandlestickRenderer.ts
424
- var D = class {
424
+ var A = class {
425
425
  render(e, t, n, r) {
426
426
  let { from: i, to: a } = n.visibleRange, o = n.barWidth, s = o / 2, c = o + n.barSpacing, l = -n.offset + n.chartRect.x + s, { min: u, max: d } = n.priceRange, f = d - u;
427
427
  if (f === 0) return;
@@ -434,7 +434,7 @@ var D = class {
434
434
  }
435
435
  e.strokeStyle = r.candleUpWick, e.lineWidth = 1, e.stroke(_), e.strokeStyle = r.candleDownWick, e.stroke(v), e.fillStyle = r.candleUp, e.fill(y), e.fillStyle = r.candleDown, e.fill(b);
436
436
  }
437
- }, O = class {
437
+ }, ee = class {
438
438
  render(e, t, n, r) {
439
439
  let { from: i, to: a } = n.visibleRange;
440
440
  if (i > a || t.length === 0) return;
@@ -449,7 +449,7 @@ var D = class {
449
449
  }
450
450
  e.stroke();
451
451
  }
452
- }, ee = class {
452
+ }, te = class {
453
453
  render(e, t, n, r) {
454
454
  let { from: i, to: a } = n.visibleRange;
455
455
  if (i > a || t.length === 0) return;
@@ -463,7 +463,7 @@ var D = class {
463
463
  for (let n = i + 1; n <= a && n < t.length; n++) e.lineTo(n * o + s, d + (l - t[n].close) * p);
464
464
  e.stroke();
465
465
  }
466
- }, te = class {
466
+ }, ne = class {
467
467
  render(e, t, n, r) {
468
468
  let { from: i, to: a } = n.visibleRange, o = n.barWidth, s = o / 2, c = o + n.barSpacing, l = -n.offset + n.chartRect.x + s, { min: u, max: d } = n.priceRange, f = d - u;
469
469
  if (f === 0) return;
@@ -474,7 +474,7 @@ var D = class {
474
474
  }
475
475
  e.lineWidth = 1, e.strokeStyle = r.candleUp, e.stroke(_), e.strokeStyle = r.candleDown, e.stroke(v);
476
476
  }
477
- }, ne = class {
477
+ }, re = class {
478
478
  render(e, t, n, r) {
479
479
  let { from: i, to: a } = n.visibleRange, o = n.barWidth, s = o / 2, c = o + n.barSpacing, l = -n.offset + n.chartRect.x + s, { min: u, max: d } = n.priceRange, f = d - u;
480
480
  if (f === 0) return;
@@ -493,7 +493,7 @@ var D = class {
493
493
  e.strokeStyle = r.candleDown;
494
494
  for (let t of b) e.strokeRect(t.x, t.y, t.w, t.h);
495
495
  }
496
- }, re = class {
496
+ }, ie = class {
497
497
  baselinePrice = null;
498
498
  setBaseline(e) {
499
499
  this.baselinePrice = e;
@@ -534,7 +534,7 @@ var D = class {
534
534
  for (let a = t; a <= n && a < e.length; a++) r += e[a].close, i++;
535
535
  return i > 0 ? r / i : 0;
536
536
  }
537
- }, ie = class {
537
+ }, ae = class {
538
538
  render(e, t, n, r) {
539
539
  let { from: i, to: a } = n.visibleRange, o = n.barWidth, s = o / 2, c = o + n.barSpacing, l = -n.offset + n.chartRect.x + s, { min: u, max: d } = n.priceRange, f = d - u;
540
540
  if (f === 0) return;
@@ -545,7 +545,7 @@ var D = class {
545
545
  }
546
546
  e.fillStyle = r.candleUp, e.fill(_), e.fillStyle = r.candleDown, e.fill(v), e.lineWidth = 1, e.strokeStyle = r.candleUp, e.stroke(y), e.strokeStyle = r.candleDown, e.stroke(b);
547
547
  }
548
- }, ae = class {
548
+ }, oe = class {
549
549
  render(e, t, n, r) {
550
550
  let { from: i, to: a } = n.visibleRange, o = n.barWidth, s = o / 2, c = o + n.barSpacing, l = -n.offset + n.chartRect.x + s, { min: u, max: d } = n.priceRange, f = d - u;
551
551
  if (f === 0) return;
@@ -559,7 +559,7 @@ var D = class {
559
559
  }
560
560
  e.strokeStyle = r.candleUp, e.lineWidth = 3, e.stroke(_), e.strokeStyle = r.candleDown, e.lineWidth = 1, e.stroke(v);
561
561
  }
562
- }, oe = class {
562
+ }, se = class {
563
563
  boxSize = 1;
564
564
  setBoxSize(e) {
565
565
  this.boxSize = e;
@@ -577,7 +577,7 @@ var D = class {
577
577
  }
578
578
  e.lineWidth = 1.5, e.strokeStyle = r.candleUp, e.stroke(y), e.strokeStyle = r.candleDown, e.stroke(b);
579
579
  }
580
- }, se = class {
580
+ }, ce = class {
581
581
  visible = !0;
582
582
  heightRatio = .2;
583
583
  setVisible(e) {
@@ -598,7 +598,7 @@ var D = class {
598
598
  }
599
599
  e.globalAlpha = .35, e.fillStyle = r.candleUp, e.fill(h), e.fillStyle = r.candleDown, e.fill(g), e.globalAlpha = 1;
600
600
  }
601
- }, ce = class {
601
+ }, le = class {
602
602
  symbols = /* @__PURE__ */ new Map();
603
603
  mode = "percent";
604
604
  setMode(e) {
@@ -639,21 +639,21 @@ var D = class {
639
639
  e.strokeStyle = t.color, e.lineWidth = t.lineWidth ?? 1.5, e.lineJoin = "round", e.beginPath();
640
640
  let u = !1, d = Math.min(n.length, t.data.length);
641
641
  for (let n = s; n < d; n++) {
642
- let i = y(n, r);
642
+ let i = S(n, r);
643
643
  if (i < a.x - o) continue;
644
644
  if (i > a.x + a.width + o) break;
645
645
  let s;
646
- s = this.mode === "percent" ? b(c * (1 + (t.data[n].close - l) / l), r) : b(t.data[n].close, r), u ? e.lineTo(i, s) : (e.moveTo(i, s), u = !0);
646
+ s = this.mode === "percent" ? C(c * (1 + (t.data[n].close - l) / l), r) : C(t.data[n].close, r), u ? e.lineTo(i, s) : (e.moveTo(i, s), u = !0);
647
647
  }
648
648
  if (e.stroke(), u) {
649
- let n = Math.min(s + 2, d - 1), i = y(n, r) + 4, a;
650
- a = this.mode === "percent" ? b(c * (1 + (t.data[n].close - l) / l), r) - 4 : b(t.data[n].close, r) - 4, e.fillStyle = t.color, e.font = "bold 10px sans-serif", e.textBaseline = "bottom", e.textAlign = "left", e.fillText(t.label, i, a);
649
+ let n = Math.min(s + 2, d - 1), i = S(n, r) + 4, a;
650
+ a = this.mode === "percent" ? C(c * (1 + (t.data[n].close - l) / l), r) - 4 : C(t.data[n].close, r) - 4, e.fillStyle = t.color, e.font = "bold 10px sans-serif", e.textBaseline = "bottom", e.textAlign = "left", e.fillText(t.label, i, a);
651
651
  }
652
652
  }
653
653
  };
654
654
  //#endregion
655
655
  //#region src/charts/transforms/heikinAshi.ts
656
- function le(e) {
656
+ function ue(e) {
657
657
  if (e.length === 0) return [];
658
658
  let t = [], n = e[0].open, r = (e[0].open + e[0].high + e[0].low + e[0].close) / 4;
659
659
  for (let i = 0; i < e.length; i++) {
@@ -671,10 +671,10 @@ function le(e) {
671
671
  }
672
672
  //#endregion
673
673
  //#region src/charts/transforms/renko.ts
674
- function ue(e, t) {
674
+ function de(e, t) {
675
675
  if (e.length === 0) return [];
676
676
  let n = t.brickSize;
677
- t.useATR && e.length > (t.atrPeriod ?? 14) && (n = de(e, t.atrPeriod ?? 14)), n <= 0 && (n = 1);
677
+ t.useATR && e.length > (t.atrPeriod ?? 14) && (n = fe(e, t.atrPeriod ?? 14)), n <= 0 && (n = 1);
678
678
  let r = [], i = Math.round(e[0].close / n) * n, a = e[0].time;
679
679
  for (let t = 1; t < e.length; t++) {
680
680
  let o = e[t].close - i, s = Math.floor(Math.abs(o) / n);
@@ -695,7 +695,7 @@ function ue(e, t) {
695
695
  }
696
696
  return r;
697
697
  }
698
- function de(e, t) {
698
+ function fe(e, t) {
699
699
  let n = 0;
700
700
  for (let r = 1; r <= Math.min(t, e.length - 1); r++) {
701
701
  let t = Math.max(e[r].high - e[r].low, Math.abs(e[r].high - e[r - 1].close), Math.abs(e[r].low - e[r - 1].close));
@@ -705,7 +705,7 @@ function de(e, t) {
705
705
  }
706
706
  //#endregion
707
707
  //#region src/charts/transforms/lineBreak.ts
708
- function fe(e, t = 3) {
708
+ function pe(e, t = 3) {
709
709
  if (e.length === 0) return [];
710
710
  let n = [], r = 0;
711
711
  n.push({
@@ -746,7 +746,7 @@ function fe(e, t = 3) {
746
746
  }
747
747
  //#endregion
748
748
  //#region src/charts/transforms/kagi.ts
749
- function pe(e, t = 4) {
749
+ function me(e, t = 4) {
750
750
  if (e.length < 2) return e.slice();
751
751
  let n = [], r = e[1].close >= e[0].close ? 1 : -1, i = e[0].close, a = e[0].close, o = e[0].close, s = 0;
752
752
  for (let c = 1; c < e.length; c++) {
@@ -785,7 +785,7 @@ function pe(e, t = 4) {
785
785
  }
786
786
  //#endregion
787
787
  //#region src/charts/transforms/pointAndFigure.ts
788
- function me(e, t, n = 3) {
788
+ function he(e, t, n = 3) {
789
789
  if (e.length === 0 || t <= 0) return [];
790
790
  let r = [], i = 0, a = 0, o = 0, s = 0, c = Math.round(e[0].close / t) * t;
791
791
  a = c, o = c, i = 1;
@@ -818,7 +818,7 @@ function me(e, t, n = 3) {
818
818
  }
819
819
  //#endregion
820
820
  //#region src/indicators/IndicatorBase.ts
821
- var k = class {
821
+ var j = class {
822
822
  drawLine(e, t, n, r) {
823
823
  if (!(t.length < 2)) {
824
824
  e.beginPath(), e.strokeStyle = n, e.lineWidth = r, e.lineJoin = "round", e.moveTo(t[0].x, t[0].y);
@@ -847,13 +847,13 @@ var k = class {
847
847
  for (let s = a; s <= o && s < n.length; s++) {
848
848
  let a = e.values.get(n[s].time);
849
849
  a && a[t] !== void 0 && i.push({
850
- x: y(s, r),
851
- y: b(a[t], r)
850
+ x: S(s, r),
851
+ y: C(a[t], r)
852
852
  });
853
853
  }
854
854
  return i;
855
855
  }
856
- }, he = 1, ge = class {
856
+ }, ge = 1, _e = class {
857
857
  registry = /* @__PURE__ */ new Map();
858
858
  instances = /* @__PURE__ */ new Map();
859
859
  register(e) {
@@ -865,7 +865,7 @@ var k = class {
865
865
  addIndicator(e, t = {}, n) {
866
866
  let r = this.registry.get(e);
867
867
  if (!r) throw Error(`Unknown indicator: ${e}`);
868
- let i = `tc_${e}_${he++}`, a = {
868
+ let i = `tc_${e}_${ge++}`, a = {
869
869
  id: e,
870
870
  instanceId: i,
871
871
  params: {
@@ -957,7 +957,7 @@ var k = class {
957
957
  });
958
958
  return e;
959
959
  }
960
- }, _e = class extends k {
960
+ }, M = class extends j {
961
961
  descriptor = {
962
962
  id: "sma",
963
963
  name: "Simple Moving Average",
@@ -984,12 +984,12 @@ var k = class {
984
984
  for (let t = a; t <= o && t < i.length; t++) {
985
985
  let r = i[t];
986
986
  if (!r || r.value === void 0) continue;
987
- let a = y(t, n), o = b(r.value, n);
987
+ let a = S(t, n), o = C(r.value, n);
988
988
  s ? e.lineTo(a, o) : (e.moveTo(a, o), s = !0);
989
989
  }
990
990
  e.stroke();
991
991
  }
992
- }, ve = class extends k {
992
+ }, N = class extends j {
993
993
  descriptor = {
994
994
  id: "ema",
995
995
  name: "Exponential Moving Average",
@@ -1021,12 +1021,12 @@ var k = class {
1021
1021
  for (let t = a; t <= o && t < i.length; t++) {
1022
1022
  let r = i[t];
1023
1023
  if (!r || r.value === void 0) continue;
1024
- let a = y(t, n), o = b(r.value, n);
1024
+ let a = S(t, n), o = C(r.value, n);
1025
1025
  s ? e.lineTo(a, o) : (e.moveTo(a, o), s = !0);
1026
1026
  }
1027
1027
  e.stroke();
1028
1028
  }
1029
- }, ye = class extends k {
1029
+ }, P = class extends j {
1030
1030
  descriptor = {
1031
1031
  id: "bb",
1032
1032
  name: "Bollinger Bands",
@@ -1061,27 +1061,27 @@ var k = class {
1061
1061
  render(e, t, n, r) {
1062
1062
  let i = t.series;
1063
1063
  if (!i) return;
1064
- let { from: a, to: o } = n.visibleRange, s = 0, c = o - a + 1, l = new Float64Array(c), u = new Float64Array(c), d = new Float64Array(c), f = new Float64Array(c), p = new Float64Array(c), h = new Float64Array(c);
1064
+ let { from: a, to: o } = n.visibleRange, s = 0, c = o - a + 1, l = new Float64Array(c), u = new Float64Array(c), d = new Float64Array(c), f = new Float64Array(c), p = new Float64Array(c), m = new Float64Array(c);
1065
1065
  for (let e = a; e <= o && e < i.length; e++) {
1066
1066
  let t = i[e];
1067
1067
  if (!t || t.upper === void 0) continue;
1068
- let r = y(e, n);
1069
- l[s] = r, u[s] = b(t.upper, n), d[s] = r, f[s] = b(t.middle, n), p[s] = r, h[s] = b(t.lower, n), s++;
1068
+ let r = S(e, n);
1069
+ l[s] = r, u[s] = C(t.upper, n), d[s] = r, f[s] = C(t.middle, n), p[s] = r, m[s] = C(t.lower, n), s++;
1070
1070
  }
1071
1071
  if (!(s < 2)) {
1072
1072
  e.beginPath(), e.moveTo(l[0], u[0]);
1073
1073
  for (let t = 1; t < s; t++) e.lineTo(l[t], u[t]);
1074
- for (let t = s - 1; t >= 0; t--) e.lineTo(p[t], h[t]);
1075
- e.closePath(), e.fillStyle = m(r.colors[0], .1), e.fill(), e.beginPath(), e.strokeStyle = r.colors[0], e.lineWidth = r.lineWidths[0], e.lineJoin = "round", e.moveTo(l[0], u[0]);
1074
+ for (let t = s - 1; t >= 0; t--) e.lineTo(p[t], m[t]);
1075
+ e.closePath(), e.fillStyle = _(r.colors[0], .1), e.fill(), e.beginPath(), e.strokeStyle = r.colors[0], e.lineWidth = r.lineWidths[0], e.lineJoin = "round", e.moveTo(l[0], u[0]);
1076
1076
  for (let t = 1; t < s; t++) e.lineTo(l[t], u[t]);
1077
1077
  e.stroke(), e.beginPath(), e.strokeStyle = r.colors[1] ?? r.colors[0], e.moveTo(d[0], f[0]);
1078
1078
  for (let t = 1; t < s; t++) e.lineTo(d[t], f[t]);
1079
- e.stroke(), e.beginPath(), e.strokeStyle = r.colors[0], e.moveTo(p[0], h[0]);
1080
- for (let t = 1; t < s; t++) e.lineTo(p[t], h[t]);
1079
+ e.stroke(), e.beginPath(), e.strokeStyle = r.colors[0], e.moveTo(p[0], m[0]);
1080
+ for (let t = 1; t < s; t++) e.lineTo(p[t], m[t]);
1081
1081
  e.stroke();
1082
1082
  }
1083
1083
  }
1084
- }, be = class extends k {
1084
+ }, F = class extends j {
1085
1085
  descriptor = {
1086
1086
  id: "vwap",
1087
1087
  name: "Volume Weighted Average Price",
@@ -1111,12 +1111,12 @@ var k = class {
1111
1111
  for (let t = a; t <= o && t < i.length; t++) {
1112
1112
  let r = i[t];
1113
1113
  if (!r || r.value === void 0) continue;
1114
- let a = y(t, n), o = b(r.value, n);
1114
+ let a = S(t, n), o = C(r.value, n);
1115
1115
  s ? e.lineTo(a, o) : (e.moveTo(a, o), s = !0);
1116
1116
  }
1117
1117
  e.stroke();
1118
1118
  }
1119
- }, xe = class extends k {
1119
+ }, I = class extends j {
1120
1120
  descriptor = {
1121
1121
  id: "ichimoku",
1122
1122
  name: "Ichimoku Cloud",
@@ -1153,30 +1153,30 @@ var k = class {
1153
1153
  render(e, t, n, r) {
1154
1154
  let i = t.series;
1155
1155
  if (!i) return;
1156
- let { from: a, to: o } = n.visibleRange, s = o - a + 1, c = new Float64Array(s), l = new Float64Array(s), u = 0, d = new Float64Array(s), f = new Float64Array(s), p = 0, h = new Float64Array(s), g = new Float64Array(s), _ = 0, v = new Float64Array(s), x = new Float64Array(s), S = 0;
1156
+ let { from: a, to: o } = n.visibleRange, s = o - a + 1, c = new Float64Array(s), l = new Float64Array(s), u = 0, d = new Float64Array(s), f = new Float64Array(s), p = 0, m = new Float64Array(s), h = new Float64Array(s), g = 0, v = new Float64Array(s), y = new Float64Array(s), b = 0;
1157
1157
  for (let e = a; e <= o && e < i.length; e++) {
1158
1158
  let t = i[e];
1159
1159
  if (!t) continue;
1160
- let r = y(e, n);
1161
- t.tenkan !== void 0 && (c[u] = r, l[u] = b(t.tenkan, n), u++), t.kijun !== void 0 && (d[p] = r, f[p] = b(t.kijun, n), p++), t.senkouA !== void 0 && (h[_] = r, g[_] = b(t.senkouA, n), _++), t.senkouB !== void 0 && (v[S] = r, x[S] = b(t.senkouB, n), S++);
1160
+ let r = S(e, n);
1161
+ t.tenkan !== void 0 && (c[u] = r, l[u] = C(t.tenkan, n), u++), t.kijun !== void 0 && (d[p] = r, f[p] = C(t.kijun, n), p++), t.senkouA !== void 0 && (m[g] = r, h[g] = C(t.senkouA, n), g++), t.senkouB !== void 0 && (v[b] = r, y[b] = C(t.senkouB, n), b++);
1162
1162
  }
1163
- if (_ > 1 && S > 1) {
1164
- let t = Math.min(_, S);
1165
- e.beginPath(), e.moveTo(h[0], g[0]);
1166
- for (let n = 1; n < t; n++) e.lineTo(h[n], g[n]);
1167
- for (let n = t - 1; n >= 0; n--) e.lineTo(v[n], x[n]);
1168
- e.closePath(), e.fillStyle = m(r.colors[2] ?? "#26A69A", .15), e.fill();
1163
+ if (g > 1 && b > 1) {
1164
+ let t = Math.min(g, b);
1165
+ e.beginPath(), e.moveTo(m[0], h[0]);
1166
+ for (let n = 1; n < t; n++) e.lineTo(m[n], h[n]);
1167
+ for (let n = t - 1; n >= 0; n--) e.lineTo(v[n], y[n]);
1168
+ e.closePath(), e.fillStyle = _(r.colors[2] ?? "#26A69A", .15), e.fill();
1169
1169
  }
1170
- let C = (t, n, r, i, a) => {
1170
+ let x = (t, n, r, i, a) => {
1171
1171
  if (!(r < 2)) {
1172
1172
  e.beginPath(), e.strokeStyle = i, e.lineWidth = a, e.lineJoin = "round", e.moveTo(t[0], n[0]);
1173
1173
  for (let i = 1; i < r; i++) e.lineTo(t[i], n[i]);
1174
1174
  e.stroke();
1175
1175
  }
1176
1176
  };
1177
- C(c, l, u, r.colors[0], r.lineWidths[0]), C(d, f, p, r.colors[1] ?? "#FF9800", r.lineWidths[0]), C(h, g, _, r.colors[2] ?? "#26A69A", 1), C(v, x, S, r.colors[3] ?? "#EF5350", 1);
1177
+ x(c, l, u, r.colors[0], r.lineWidths[0]), x(d, f, p, r.colors[1] ?? "#FF9800", r.lineWidths[0]), x(m, h, g, r.colors[2] ?? "#26A69A", 1), x(v, y, b, r.colors[3] ?? "#EF5350", 1);
1178
1178
  }
1179
- }, Se = class extends k {
1179
+ }, L = class extends j {
1180
1180
  descriptor = {
1181
1181
  id: "psar",
1182
1182
  name: "Parabolic SAR",
@@ -1218,11 +1218,11 @@ var k = class {
1218
1218
  for (let t = a; t <= o && t < i.length; t++) {
1219
1219
  let a = i[t];
1220
1220
  if (!a || a.value === void 0) continue;
1221
- let o = y(t, n), c = b(a.value, n);
1221
+ let o = S(t, n), c = C(a.value, n);
1222
1222
  e.beginPath(), e.arc(o, c, s, 0, Math.PI * 2), e.fillStyle = a.trend === 1 ? r.colors[0] : r.colors[1] ?? "#EF5350", e.fill();
1223
1223
  }
1224
1224
  }
1225
- }, Ce = class extends k {
1225
+ }, R = class extends j {
1226
1226
  descriptor = {
1227
1227
  id: "supertrend",
1228
1228
  name: "Supertrend",
@@ -1266,11 +1266,11 @@ var k = class {
1266
1266
  for (let t = a; t <= o && t < i.length; t++) {
1267
1267
  let a = i[t];
1268
1268
  if (!a || a.value === void 0) continue;
1269
- let o = y(t, n), f = b(a.value, n), p = a.trend ?? 1;
1269
+ let o = S(t, n), f = C(a.value, n), p = a.trend ?? 1;
1270
1270
  d !== 0 && (e.beginPath(), e.strokeStyle = p === 1 ? s : c, e.lineWidth = r.lineWidths[0] + .5, e.moveTo(l, u), e.lineTo(o, f), e.stroke()), l = o, u = f, d = p;
1271
1271
  }
1272
1272
  }
1273
- }, A = class extends k {
1273
+ }, z = class extends j {
1274
1274
  descriptor = {
1275
1275
  id: "keltner",
1276
1276
  name: "Keltner Channel",
@@ -1313,21 +1313,21 @@ var k = class {
1313
1313
  for (let e = a; e <= o && e < i.length; e++) {
1314
1314
  let t = i[e];
1315
1315
  if (!t) continue;
1316
- let r = y(e, n);
1316
+ let r = S(e, n);
1317
1317
  t.upper !== void 0 && s.push({
1318
1318
  x: r,
1319
- y: b(t.upper, n)
1319
+ y: C(t.upper, n)
1320
1320
  }), t.middle !== void 0 && c.push({
1321
1321
  x: r,
1322
- y: b(t.middle, n)
1322
+ y: C(t.middle, n)
1323
1323
  }), t.lower !== void 0 && l.push({
1324
1324
  x: r,
1325
- y: b(t.lower, n)
1325
+ y: C(t.lower, n)
1326
1326
  });
1327
1327
  }
1328
- this.drawBand(e, s, l, m(r.colors[0], .08)), this.drawLine(e, s, r.colors[0], r.lineWidths[0]), this.drawLine(e, c, r.colors[1] ?? r.colors[0], r.lineWidths[0]), this.drawLine(e, l, r.colors[0], r.lineWidths[0]);
1328
+ this.drawBand(e, s, l, _(r.colors[0], .08)), this.drawLine(e, s, r.colors[0], r.lineWidths[0]), this.drawLine(e, c, r.colors[1] ?? r.colors[0], r.lineWidths[0]), this.drawLine(e, l, r.colors[0], r.lineWidths[0]);
1329
1329
  }
1330
- }, j = class extends k {
1330
+ }, B = class extends j {
1331
1331
  descriptor = {
1332
1332
  id: "donchian",
1333
1333
  name: "Donchian Channel",
@@ -1358,21 +1358,21 @@ var k = class {
1358
1358
  for (let e = a; e <= o && e < i.length; e++) {
1359
1359
  let t = i[e];
1360
1360
  if (!t) continue;
1361
- let r = y(e, n);
1361
+ let r = S(e, n);
1362
1362
  t.upper !== void 0 && s.push({
1363
1363
  x: r,
1364
- y: b(t.upper, n)
1364
+ y: C(t.upper, n)
1365
1365
  }), t.middle !== void 0 && c.push({
1366
1366
  x: r,
1367
- y: b(t.middle, n)
1367
+ y: C(t.middle, n)
1368
1368
  }), t.lower !== void 0 && l.push({
1369
1369
  x: r,
1370
- y: b(t.lower, n)
1370
+ y: C(t.lower, n)
1371
1371
  });
1372
1372
  }
1373
- this.drawBand(e, s, l, m(r.colors[0], .08)), this.drawLine(e, s, r.colors[0], r.lineWidths[0]), this.drawLine(e, c, r.colors[1] ?? "#787B86", 1), this.drawLine(e, l, r.colors[0], r.lineWidths[0]);
1373
+ this.drawBand(e, s, l, _(r.colors[0], .08)), this.drawLine(e, s, r.colors[0], r.lineWidths[0]), this.drawLine(e, c, r.colors[1] ?? "#787B86", 1), this.drawLine(e, l, r.colors[0], r.lineWidths[0]);
1374
1374
  }
1375
- }, M = class extends k {
1375
+ }, V = class extends j {
1376
1376
  descriptor = {
1377
1377
  id: "rsi",
1378
1378
  name: "Relative Strength Index",
@@ -1418,12 +1418,12 @@ var k = class {
1418
1418
  for (let t = o; t <= s && t < i.length; t++) {
1419
1419
  let r = i[t];
1420
1420
  if (!r || r.value === void 0) continue;
1421
- let a = y(t, n), o = c(r.value);
1421
+ let a = S(t, n), o = c(r.value);
1422
1422
  l ? e.lineTo(a, o) : (e.moveTo(a, o), l = !0);
1423
1423
  }
1424
1424
  e.stroke();
1425
1425
  }
1426
- }, N = class extends k {
1426
+ }, H = class extends j {
1427
1427
  descriptor = {
1428
1428
  id: "macd",
1429
1429
  name: "MACD",
@@ -1470,27 +1470,27 @@ var k = class {
1470
1470
  if (c === Infinity) return;
1471
1471
  let u = l - c || 1, d = (e) => a.y + a.height * (1 - (e - c) / u), f = d(0), p = n.barWidth / 2, m = r.colors[2] ?? "#26A69A", h = r.colors[3] ?? "#EF5350", g = r.colors[0], _ = r.colors[1] ?? "#FF9800";
1472
1472
  e.beginPath();
1473
- let v = new Path2D(), b = new Path2D(), x = !1, S = !1, C = new Path2D(), w = new Path2D();
1473
+ let v = new Path2D(), y = new Path2D(), b = !1, x = !1, C = new Path2D(), w = new Path2D();
1474
1474
  for (let e = o; e <= s && e < i.length; e++) {
1475
1475
  let t = i[e];
1476
1476
  if (!t) continue;
1477
- let r = y(e, n);
1477
+ let r = S(e, n);
1478
1478
  if (t.histogram !== void 0) {
1479
1479
  let e = d(t.histogram), i = Math.min(e, f), a = Math.max(Math.abs(e - f), 1);
1480
- t.histogram >= 0 ? v.rect(r - p, i, n.barWidth, a) : b.rect(r - p, i, n.barWidth, a);
1480
+ t.histogram >= 0 ? v.rect(r - p, i, n.barWidth, a) : y.rect(r - p, i, n.barWidth, a);
1481
1481
  }
1482
1482
  if (t.macd !== void 0) {
1483
1483
  let e = d(t.macd);
1484
- x ? C.lineTo(r, e) : (C.moveTo(r, e), x = !0);
1484
+ b ? C.lineTo(r, e) : (C.moveTo(r, e), b = !0);
1485
1485
  }
1486
1486
  if (t.signal !== void 0) {
1487
1487
  let e = d(t.signal);
1488
- S ? w.lineTo(r, e) : (w.moveTo(r, e), S = !0);
1488
+ x ? w.lineTo(r, e) : (w.moveTo(r, e), x = !0);
1489
1489
  }
1490
1490
  }
1491
- e.fillStyle = m, e.fill(v), e.fillStyle = h, e.fill(b), e.strokeStyle = g, e.lineWidth = r.lineWidths[0], e.lineJoin = "round", e.stroke(C), e.strokeStyle = _, e.stroke(w);
1491
+ e.fillStyle = m, e.fill(v), e.fillStyle = h, e.fill(y), e.strokeStyle = g, e.lineWidth = r.lineWidths[0], e.lineJoin = "round", e.stroke(C), e.strokeStyle = _, e.stroke(w);
1492
1492
  }
1493
- }, P = class extends k {
1493
+ }, ve = class extends j {
1494
1494
  descriptor = {
1495
1495
  id: "stochastic",
1496
1496
  name: "Stochastic Oscillator",
@@ -1558,14 +1558,14 @@ var k = class {
1558
1558
  for (let r = o; r <= s && r < i.length; r++) {
1559
1559
  let a = i[r];
1560
1560
  if (!a || a[t] === void 0) continue;
1561
- let o = y(r, n), s = c(a[t]);
1561
+ let o = S(r, n), s = c(a[t]);
1562
1562
  l ? e.lineTo(o, s) : (e.moveTo(o, s), l = !0);
1563
1563
  }
1564
1564
  e.stroke();
1565
1565
  };
1566
1566
  l("k", r.colors[0]), l("d", r.colors[1] ?? "#FF9800");
1567
1567
  }
1568
- }, F = class extends k {
1568
+ }, ye = class extends j {
1569
1569
  descriptor = {
1570
1570
  id: "atr",
1571
1571
  name: "Average True Range",
@@ -1613,13 +1613,13 @@ var k = class {
1613
1613
  for (let t = o; t <= s && t < i.length; t++) {
1614
1614
  let r = i[t];
1615
1615
  if (r && r.value !== void 0) {
1616
- let i = y(t, n), a = p(r.value);
1616
+ let i = S(t, n), a = p(r.value);
1617
1617
  m ? e.lineTo(i, a) : (e.moveTo(i, a), m = !0);
1618
1618
  }
1619
1619
  }
1620
1620
  e.stroke();
1621
1621
  }
1622
- }, I = class extends k {
1622
+ }, be = class extends j {
1623
1623
  descriptor = {
1624
1624
  id: "adx",
1625
1625
  name: "Average Directional Index",
@@ -1685,14 +1685,14 @@ var k = class {
1685
1685
  for (let r = o; r <= s && r < i.length; r++) {
1686
1686
  let a = i[r];
1687
1687
  if (!a || a[t] === void 0) continue;
1688
- let o = y(r, n), s = c(a[t]);
1688
+ let o = S(r, n), s = c(a[t]);
1689
1689
  l ? e.lineTo(o, s) : (e.moveTo(o, s), l = !0);
1690
1690
  }
1691
1691
  e.stroke();
1692
1692
  };
1693
1693
  l("adx", r.colors[0]), l("plusDI", r.colors[1] ?? "#26A69A"), l("minusDI", r.colors[2] ?? "#EF5350");
1694
1694
  }
1695
- }, L = class extends k {
1695
+ }, xe = class extends j {
1696
1696
  descriptor = {
1697
1697
  id: "obv",
1698
1698
  name: "On Balance Volume",
@@ -1732,13 +1732,13 @@ var k = class {
1732
1732
  for (let t = o; t <= s && t < i.length; t++) {
1733
1733
  let r = i[t];
1734
1734
  if (r && r.value !== void 0) {
1735
- let i = y(t, n), a = p(r.value);
1735
+ let i = S(t, n), a = p(r.value);
1736
1736
  m ? e.lineTo(i, a) : (e.moveTo(i, a), m = !0);
1737
1737
  }
1738
1738
  }
1739
1739
  e.stroke();
1740
1740
  }
1741
- }, R = class extends k {
1741
+ }, Se = class extends j {
1742
1742
  descriptor = {
1743
1743
  id: "williamsR",
1744
1744
  name: "Williams %R",
@@ -1772,13 +1772,13 @@ var k = class {
1772
1772
  for (let t = o; t <= s && t < i.length; t++) {
1773
1773
  let r = i[t];
1774
1774
  if (r && r.value !== void 0) {
1775
- let i = y(t, n), a = c(r.value);
1775
+ let i = S(t, n), a = c(r.value);
1776
1776
  l ? e.lineTo(i, a) : (e.moveTo(i, a), l = !0);
1777
1777
  }
1778
1778
  }
1779
1779
  e.stroke();
1780
1780
  }
1781
- }, z = class extends k {
1781
+ }, Ce = class extends j {
1782
1782
  descriptor = {
1783
1783
  id: "cci",
1784
1784
  name: "Commodity Channel Index",
@@ -1827,13 +1827,13 @@ var k = class {
1827
1827
  for (let t = o; t <= s && t < i.length; t++) {
1828
1828
  let r = i[t];
1829
1829
  if (r && r.value !== void 0) {
1830
- let i = y(t, n), a = m(r.value);
1830
+ let i = S(t, n), a = m(r.value);
1831
1831
  h ? e.lineTo(i, a) : (e.moveTo(i, a), h = !0);
1832
1832
  }
1833
1833
  }
1834
1834
  e.stroke();
1835
1835
  }
1836
- }, B = class extends k {
1836
+ }, we = class extends j {
1837
1837
  descriptor = {
1838
1838
  id: "mfi",
1839
1839
  name: "Money Flow Index",
@@ -1872,13 +1872,13 @@ var k = class {
1872
1872
  for (let t = o; t <= s && t < i.length; t++) {
1873
1873
  let r = i[t];
1874
1874
  if (r && r.value !== void 0) {
1875
- let i = y(t, n), a = c(r.value);
1875
+ let i = S(t, n), a = c(r.value);
1876
1876
  l ? e.lineTo(i, a) : (e.moveTo(i, a), l = !0);
1877
1877
  }
1878
1878
  }
1879
1879
  e.stroke();
1880
1880
  }
1881
- }, V = class extends k {
1881
+ }, Te = class extends j {
1882
1882
  descriptor = {
1883
1883
  id: "aroon",
1884
1884
  name: "Aroon",
@@ -1913,14 +1913,14 @@ var k = class {
1913
1913
  for (let r = o; r <= s && r < i.length; r++) {
1914
1914
  let a = i[r];
1915
1915
  if (!a || a[t] === void 0) continue;
1916
- let o = y(r, n), s = c(a[t]);
1916
+ let o = S(r, n), s = c(a[t]);
1917
1917
  l ? e.lineTo(o, s) : (e.moveTo(o, s), l = !0);
1918
1918
  }
1919
1919
  e.stroke();
1920
1920
  };
1921
1921
  l("up", r.colors[0]), l("down", r.colors[1] ?? "#EF5350");
1922
1922
  }
1923
- }, H = class extends k {
1923
+ }, Ee = class extends j {
1924
1924
  descriptor = {
1925
1925
  id: "roc",
1926
1926
  name: "Rate of Change",
@@ -1958,13 +1958,13 @@ var k = class {
1958
1958
  for (let t = o; t <= s && t < i.length; t++) {
1959
1959
  let r = i[t];
1960
1960
  if (r && r.value !== void 0) {
1961
- let i = y(t, n), a = m(r.value);
1961
+ let i = S(t, n), a = m(r.value);
1962
1962
  h ? e.lineTo(i, a) : (e.moveTo(i, a), h = !0);
1963
1963
  }
1964
1964
  }
1965
1965
  e.stroke();
1966
1966
  }
1967
- }, U = class extends k {
1967
+ }, De = class extends j {
1968
1968
  descriptor = {
1969
1969
  id: "tsi",
1970
1970
  name: "True Strength Index",
@@ -2026,14 +2026,14 @@ var k = class {
2026
2026
  for (let r = o; r <= s && r < i.length; r++) {
2027
2027
  let a = i[r];
2028
2028
  if (!a || a[t] === void 0) continue;
2029
- let o = y(r, n), s = m(a[t]);
2029
+ let o = S(r, n), s = m(a[t]);
2030
2030
  c ? e.lineTo(o, s) : (e.moveTo(o, s), c = !0);
2031
2031
  }
2032
2032
  e.stroke();
2033
2033
  };
2034
2034
  h("tsi", r.colors[0]), h("signal", r.colors[1] ?? "#FF9800");
2035
2035
  }
2036
- }, W = class extends k {
2036
+ }, Oe = class extends j {
2037
2037
  descriptor = {
2038
2038
  id: "cmf",
2039
2039
  name: "Chaikin Money Flow",
@@ -2071,14 +2071,14 @@ var k = class {
2071
2071
  for (let t = o; t <= s && t < i.length; t++) {
2072
2072
  let a = i[t];
2073
2073
  if (a && a.value !== void 0) {
2074
- let i = y(t, n), o = m(a.value), s = m(0);
2074
+ let i = S(t, n), o = m(a.value), s = m(0);
2075
2075
  e.fillStyle = a.value >= 0 ? r.colors[0] : r.colors[1] ?? "#EF5350";
2076
2076
  let c = Math.min(o, s);
2077
2077
  e.fillRect(i - h, c, n.barWidth, Math.max(Math.abs(o - s), 1));
2078
2078
  }
2079
2079
  }
2080
2080
  }
2081
- }, G = class extends k {
2081
+ }, ke = class extends j {
2082
2082
  descriptor = {
2083
2083
  id: "stddev",
2084
2084
  name: "Standard Deviation",
@@ -2118,13 +2118,13 @@ var k = class {
2118
2118
  for (let t = o; t <= s && t < i.length; t++) {
2119
2119
  let r = i[t];
2120
2120
  if (r && r.value !== void 0) {
2121
- let i = y(t, n), a = p(r.value);
2121
+ let i = S(t, n), a = p(r.value);
2122
2122
  m ? e.lineTo(i, a) : (e.moveTo(i, a), m = !0);
2123
2123
  }
2124
2124
  }
2125
2125
  e.stroke();
2126
2126
  }
2127
- }, we = class extends k {
2127
+ }, Ae = class extends j {
2128
2128
  descriptor = {
2129
2129
  id: "volumeProfile",
2130
2130
  name: "Volume Profile",
@@ -2174,7 +2174,7 @@ var k = class {
2174
2174
  e.fillStyle = l[t] > u * .7 ? r.colors[1] ?? "rgba(255, 152, 0, 0.5)" : r.colors[0] ?? "rgba(33, 150, 243, 0.3)", e.fillRect(i.x, s - d / 2, p, Math.max(d - 1, 1));
2175
2175
  }
2176
2176
  }
2177
- }, Te = class extends k {
2177
+ }, je = class extends j {
2178
2178
  descriptor = {
2179
2179
  id: "ad",
2180
2180
  name: "Accumulation/Distribution",
@@ -2214,13 +2214,13 @@ var k = class {
2214
2214
  for (let t = o; t <= s && t < i.length; t++) {
2215
2215
  let r = i[t];
2216
2216
  if (r && r.value !== void 0) {
2217
- let i = y(t, n), a = p(r.value);
2217
+ let i = S(t, n), a = p(r.value);
2218
2218
  m ? e.lineTo(i, a) : (e.moveTo(i, a), m = !0);
2219
2219
  }
2220
2220
  }
2221
2221
  e.stroke();
2222
2222
  }
2223
- }, Ee = class extends k {
2223
+ }, Me = class extends j {
2224
2224
  descriptor = {
2225
2225
  id: "vroc",
2226
2226
  name: "Volume Rate of Change",
@@ -2253,7 +2253,7 @@ var k = class {
2253
2253
  for (let t = o; t <= s && t < i.length; t++) {
2254
2254
  let r = i[t];
2255
2255
  if (r && r.value !== void 0) {
2256
- let i = y(t, n), a = m(r.value);
2256
+ let i = S(t, n), a = m(r.value);
2257
2257
  h ? e.lineTo(i, a) : (e.moveTo(i, a), h = !0);
2258
2258
  }
2259
2259
  }
@@ -2262,12 +2262,12 @@ var k = class {
2262
2262
  };
2263
2263
  //#endregion
2264
2264
  //#region src/indicators/registry.ts
2265
- function De(e) {
2266
- e.register(new _e()), e.register(new ve()), e.register(new ye()), e.register(new be()), e.register(new xe()), e.register(new Se()), e.register(new Ce()), e.register(new A()), e.register(new j()), e.register(new M()), e.register(new N()), e.register(new P()), e.register(new F()), e.register(new I()), e.register(new L()), e.register(new R()), e.register(new z()), e.register(new B()), e.register(new V()), e.register(new H()), e.register(new U()), e.register(new W()), e.register(new G()), e.register(new we()), e.register(new Te()), e.register(new Ee());
2265
+ function Ne(e) {
2266
+ e.register(new M()), e.register(new N()), e.register(new P()), e.register(new F()), e.register(new I()), e.register(new L()), e.register(new R()), e.register(new z()), e.register(new B()), e.register(new V()), e.register(new H()), e.register(new ve()), e.register(new ye()), e.register(new be()), e.register(new xe()), e.register(new Se()), e.register(new Ce()), e.register(new we()), e.register(new Te()), e.register(new Ee()), e.register(new De()), e.register(new Oe()), e.register(new ke()), e.register(new Ae()), e.register(new je()), e.register(new Me());
2267
2267
  }
2268
2268
  //#endregion
2269
2269
  //#region src/axis/GridRenderer.ts
2270
- var Oe = class {
2270
+ var Pe = class {
2271
2271
  visible = !0;
2272
2272
  setVisible(e) {
2273
2273
  this.visible = e;
@@ -2283,39 +2283,39 @@ var Oe = class {
2283
2283
  if (a <= 0) return;
2284
2284
  let o = 1 / a;
2285
2285
  e.beginPath();
2286
- let s = u(i.min, i.max, 8), c = Math.ceil(i.min / s) * s;
2286
+ let s = f(i.min, i.max, 8), c = Math.ceil(i.min / s) * s;
2287
2287
  for (let t = c; t <= i.max; t += s) {
2288
2288
  let n = Math.round(r.y + r.height * (1 - (t - i.min) * o)) + .5;
2289
2289
  e.moveTo(r.x, n), e.lineTo(r.x + r.width, n);
2290
2290
  }
2291
- let l = t.barWidth + t.barSpacing, d = Math.max(1, Math.ceil(80 / l)), { from: f, to: p } = t.visibleRange, m = -t.offset + r.x + t.barWidth / 2;
2292
- for (let t = f; t <= p; t++) {
2293
- if (t % d !== 0) continue;
2291
+ let l = t.barWidth + t.barSpacing, u = Math.max(1, Math.ceil(80 / l)), { from: d, to: p } = t.visibleRange, m = -t.offset + r.x + t.barWidth / 2;
2292
+ for (let t = d; t <= p; t++) {
2293
+ if (t % u !== 0) continue;
2294
2294
  let n = Math.round(t * l + m) + .5;
2295
2295
  e.moveTo(n, r.y), e.lineTo(n, r.y + r.height);
2296
2296
  }
2297
2297
  e.stroke();
2298
2298
  }
2299
- }, ke = class {
2299
+ }, Fe = class {
2300
2300
  render(e, t, n) {
2301
- let { chartRect: r, priceRange: i } = t, a = r.x + r.width, s = i.max - i.min;
2302
- if (s <= 0) return;
2303
- let c = 1 / s;
2301
+ let { chartRect: r, priceRange: i } = t, a = r.x + r.width, o = i.max - i.min;
2302
+ if (o <= 0) return;
2303
+ let s = 1 / o;
2304
2304
  e.strokeStyle = n.axisLine, e.lineWidth = 1, e.beginPath(), e.moveTo(a + .5, r.y), e.lineTo(a + .5, r.y + r.height), e.stroke();
2305
- let l = u(i.min, i.max, 8), f = Math.ceil(i.min / l) * l, p = l < 1 ? Math.ceil(-Math.log10(l)) + 1 : 2, m = `${n.font.sizeSmall}px ${n.font.family}`, h = [];
2306
- for (let e = f; e <= i.max; e += l) {
2307
- let t = r.y + r.height * (1 - (e - i.min) * c);
2305
+ let l = f(i.min, i.max, 8), u = Math.ceil(i.min / l) * l, d = l < 1 ? Math.ceil(-Math.log10(l)) + 1 : 2, m = `${n.font.sizeSmall}px ${n.font.family}`, h = [];
2306
+ for (let e = u; e <= i.max; e += l) {
2307
+ let t = r.y + r.height * (1 - (e - i.min) * s);
2308
2308
  h.push({
2309
2309
  y: t,
2310
- text: d(e, p)
2310
+ text: p(e, d)
2311
2311
  });
2312
2312
  }
2313
2313
  e.font = m, e.textBaseline = "middle", e.textAlign = "left", e.fillStyle = n.axisLabelBackground;
2314
- for (let { y: t } of h) e.fillRect(a + 1, t - 8, o - 2, 16);
2314
+ for (let { y: t } of h) e.fillRect(a + 1, t - 8, c - 2, 16);
2315
2315
  e.fillStyle = n.axisLabel;
2316
2316
  for (let { y: t, text: n } of h) e.fillText(n, a + 5, t);
2317
2317
  }
2318
- }, K = /* @__PURE__ */ new Date(), Ae = (e) => e < 10 ? "0" + e : "" + e, je = -(/* @__PURE__ */ new Date()).getTimezoneOffset() / 60, Me = `UTC${je >= 0 ? "+" : ""}${je}`, Ne = class {
2318
+ }, U = /* @__PURE__ */ new Date(), Ie = (e) => e < 10 ? "0" + e : "" + e, Le = -(/* @__PURE__ */ new Date()).getTimezoneOffset() / 60, Re = `UTC${Le >= 0 ? "+" : ""}${Le}`, ze = class {
2319
2319
  render(e, t, n, r, i) {
2320
2320
  let { chartRect: a } = t, o = i ?? a.y + a.height;
2321
2321
  e.strokeStyle = n.axisLine, e.lineWidth = 1, e.beginPath(), e.moveTo(a.x, o + .5), e.lineTo(a.x + a.width, o + .5), e.stroke();
@@ -2325,14 +2325,14 @@ var Oe = class {
2325
2325
  for (let t = l; t <= u && t < r.length; t++) {
2326
2326
  if (t % c !== 0) continue;
2327
2327
  let n = t * s + d, i = r[t].time, a = i > 0xe8d4a51000 ? i : i * 1e3;
2328
- K.setTime(a);
2329
- let l = K.getDate(), u = K.getMonth() + 1, p = K.getHours(), m = K.getMinutes(), h;
2330
- l === f ? h = `${Ae(p)}:${Ae(m)}` : (h = `${u}/${l}`, f = l), e.fillText(h, n, o + 5);
2328
+ U.setTime(a);
2329
+ let l = U.getDate(), u = U.getMonth() + 1, p = U.getHours(), m = U.getMinutes(), h;
2330
+ l === f ? h = `${Ie(p)}:${Ie(m)}` : (h = `${u}/${l}`, f = l), e.fillText(h, n, o + 5);
2331
2331
  }
2332
2332
  let p = a.x + a.width - 4, m = o + 4;
2333
- e.font = `${n.font.sizeSmall - 1}px ${n.font.family}`, e.textAlign = "right", e.textBaseline = "top", e.fillStyle = n.textSecondary, e.fillText(Me, p, m);
2333
+ e.font = `${n.font.sizeSmall - 1}px ${n.font.family}`, e.textAlign = "right", e.textBaseline = "top", e.fillStyle = n.textSecondary, e.fillText(Re, p, m);
2334
2334
  }
2335
- }, Pe = class {
2335
+ }, Be = class {
2336
2336
  panHandler = null;
2337
2337
  zoomHandler = null;
2338
2338
  crosshairHandler = null;
@@ -2452,7 +2452,7 @@ var Oe = class {
2452
2452
  y: (e.clientY + t.clientY) / 2 - n.top
2453
2453
  };
2454
2454
  }
2455
- }, Fe = class {
2455
+ }, Ve = class {
2456
2456
  dragging = !1;
2457
2457
  lastX = 0;
2458
2458
  lastTime = 0;
@@ -2488,7 +2488,7 @@ var Oe = class {
2488
2488
  stopMomentum() {
2489
2489
  this.momentumId &&= (cancelAnimationFrame(this.momentumId), 0);
2490
2490
  }
2491
- }, Ie = class {
2491
+ }, He = class {
2492
2492
  callback;
2493
2493
  sensitivity;
2494
2494
  pendingDelta = 0;
@@ -2507,7 +2507,7 @@ var Oe = class {
2507
2507
  dispose() {
2508
2508
  this.rafId &&= (cancelAnimationFrame(this.rafId), 0);
2509
2509
  }
2510
- }, Le = class {
2510
+ }, Ue = class {
2511
2511
  position = null;
2512
2512
  callback = null;
2513
2513
  data = [];
@@ -2549,13 +2549,13 @@ var Oe = class {
2549
2549
  if (!this.position || this.mode === "hidden") return;
2550
2550
  let { chartRect: r } = t, { x: i, y: a } = this.position;
2551
2551
  if (i < r.x || i > r.x + r.width || a < r.y || a > r.y + r.height) return;
2552
- let s = x(i, t);
2553
- s = Math.max(0, Math.min(this.data.length - 1, s)), this.magnetMode && s >= 0 && s < this.data.length && (i = y(s, t)), s !== this.lastCallbackBarIndex && (this.pendingBarIndex = s, this.pendingPoint = {
2552
+ let o = w(i, t);
2553
+ o = Math.max(0, Math.min(this.data.length - 1, o)), this.magnetMode && o >= 0 && o < this.data.length && (i = S(o, t)), o !== this.lastCallbackBarIndex && (this.pendingBarIndex = o, this.pendingPoint = {
2554
2554
  x: i,
2555
2555
  y: a
2556
- }, this.lastCallbackBarIndex = s, this.scheduleCallback()), e.setLineDash([4, 4]), e.strokeStyle = n.crosshair, e.lineWidth = 1, e.beginPath(), e.moveTo(Math.round(i) + .5, r.y), e.lineTo(Math.round(i) + .5, r.y + r.height), e.stroke(), e.beginPath(), e.moveTo(r.x, Math.round(a) + .5), e.lineTo(r.x + r.width, Math.round(a) + .5), e.stroke(), e.setLineDash([]);
2557
- let c = d(S(a, t), this.pricePrecision), l = r.x + r.width + 1;
2558
- e.fillStyle = n.axisLabelBackground, e.fillRect(l, a - 10, o - 2, 20), e.fillStyle = n.axisLabel, e.font = `${n.font.sizeSmall}px ${n.font.family}`, e.textBaseline = "middle", e.textAlign = "left", e.fillText(c, l + 5, a);
2556
+ }, this.lastCallbackBarIndex = o, this.scheduleCallback()), e.setLineDash([4, 4]), e.strokeStyle = n.crosshair, e.lineWidth = 1, e.beginPath(), e.moveTo(Math.round(i) + .5, r.y), e.lineTo(Math.round(i) + .5, r.y + r.height), e.stroke(), e.beginPath(), e.moveTo(r.x, Math.round(a) + .5), e.lineTo(r.x + r.width, Math.round(a) + .5), e.stroke(), e.setLineDash([]);
2557
+ let s = p(T(a, t), this.pricePrecision), l = r.x + r.width + 1;
2558
+ e.fillStyle = n.axisLabelBackground, e.fillRect(l, a - 10, c - 2, 20), e.fillStyle = n.axisLabel, e.font = `${n.font.sizeSmall}px ${n.font.family}`, e.textBaseline = "middle", e.textAlign = "left", e.fillText(s, l + 5, a);
2559
2559
  }
2560
2560
  scheduleCallback() {
2561
2561
  this.callbackScheduled || (this.callbackScheduled = !0, queueMicrotask(() => {
@@ -2565,7 +2565,7 @@ var Oe = class {
2565
2565
  flushCallback(e, t) {
2566
2566
  this.callback?.(e, t);
2567
2567
  }
2568
- }, Re = class {
2568
+ }, We = class {
2569
2569
  callbacks;
2570
2570
  enabled = !0;
2571
2571
  constructor(e) {
@@ -2591,7 +2591,7 @@ var Oe = class {
2591
2591
  default: return !1;
2592
2592
  }
2593
2593
  }
2594
- }, ze = class {
2594
+ }, Ge = class {
2595
2595
  el = null;
2596
2596
  visible = !1;
2597
2597
  timeEl;
@@ -2630,8 +2630,8 @@ var Oe = class {
2630
2630
  this.changeEl.textContent = `${l}${a(s)} (${l}${c.toFixed(2)}%)`, this.changeEl.style.color = i;
2631
2631
  let u = t.volume;
2632
2632
  this.volEl.textContent = `Vol ${u >= 1e6 ? (u / 1e6).toFixed(1) + "M" : u >= 1e3 ? (u / 1e3).toFixed(1) + "K" : u.toFixed(0)}`, this.volEl.style.color = n.textSecondary;
2633
- let d = Be(n.background);
2634
- this.el.style.background = d ? Ve(n.background, .95) : Ve(n.background, .97), this.el.style.border = `1px solid ${n.axisLine}`, this.el.style.boxShadow = d ? "0 4px 12px rgba(0,0,0,0.5)" : "0 4px 12px rgba(0,0,0,0.15)", this.el.style.color = n.text, this.el.style.backdropFilter = "blur(8px)", !this.measured && this.visible && (this.measuredWidth = this.el.offsetWidth, this.measuredHeight = this.el.offsetHeight, this.measured = !0);
2633
+ let d = Ke(n.background);
2634
+ this.el.style.background = d ? qe(n.background, .95) : qe(n.background, .97), this.el.style.border = `1px solid ${n.axisLine}`, this.el.style.boxShadow = d ? "0 4px 12px rgba(0,0,0,0.5)" : "0 4px 12px rgba(0,0,0,0.15)", this.el.style.color = n.text, this.el.style.backdropFilter = "blur(8px)", !this.measured && this.visible && (this.measuredWidth = this.el.offsetWidth, this.measuredHeight = this.el.offsetHeight, this.measured = !0);
2635
2635
  let f = e.x + 16, p = e.y - 40;
2636
2636
  f + this.measuredWidth > r.width - 80 && (f = e.x - this.measuredWidth - 16), p < 4 && (p = 4), p + this.measuredHeight > r.height && (p = r.height - this.measuredHeight - 4), this.el.style.transform = `translate(${Math.round(f)}px, ${Math.round(p)}px)`, this.el.style.left = "0", this.el.style.top = "0", this.visible ||= (this.el.style.display = "block", !0);
2637
2637
  }
@@ -2656,7 +2656,7 @@ var Oe = class {
2656
2656
  return document.createElement("span");
2657
2657
  }
2658
2658
  };
2659
- function Be(e) {
2659
+ function Ke(e) {
2660
2660
  if (e.startsWith("#")) {
2661
2661
  let t = e.slice(1), n = t.length === 3 ? t.split("").map((e) => e + e).join("") : t.slice(0, 6), r = parseInt(n.slice(0, 2), 16), i = parseInt(n.slice(2, 4), 16), a = parseInt(n.slice(4, 6), 16);
2662
2662
  return (.299 * r + .587 * i + .114 * a) / 255 < .5;
@@ -2668,7 +2668,7 @@ function Be(e) {
2668
2668
  }
2669
2669
  return !0;
2670
2670
  }
2671
- function Ve(e, t) {
2671
+ function qe(e, t) {
2672
2672
  if (e.startsWith("#")) {
2673
2673
  let n = e.slice(1), r = n.length === 3 ? n.split("").map((e) => e + e).join("") : n.slice(0, 6);
2674
2674
  return `rgba(${parseInt(r.slice(0, 2), 16)}, ${parseInt(r.slice(2, 4), 16)}, ${parseInt(r.slice(4, 6), 16)}, ${t})`;
@@ -2677,7 +2677,7 @@ function Ve(e, t) {
2677
2677
  }
2678
2678
  //#endregion
2679
2679
  //#region src/events/EventBus.ts
2680
- var He = class {
2680
+ var Je = class {
2681
2681
  listeners = /* @__PURE__ */ new Map();
2682
2682
  tauriBridge = null;
2683
2683
  on(e, t) {
@@ -2708,7 +2708,7 @@ var He = class {
2708
2708
  destroy() {
2709
2709
  this.listeners.clear(), this.tauriBridge = null;
2710
2710
  }
2711
- }, q = class {
2711
+ }, W = class {
2712
2712
  hitTestAnchor(e, t, n, r) {
2713
2713
  for (let i = 0; i < t.anchors.length; i++) {
2714
2714
  let a = this.anchorToPixel(t.anchors[i], n);
@@ -2718,14 +2718,14 @@ var He = class {
2718
2718
  }
2719
2719
  anchorToPixel(e, t) {
2720
2720
  return {
2721
- x: y(e.time, t),
2722
- y: b(e.price, t)
2721
+ x: S(e.time, t),
2722
+ y: C(e.price, t)
2723
2723
  };
2724
2724
  }
2725
2725
  pixelToAnchor(e, t) {
2726
2726
  return {
2727
- time: x(e.x, t),
2728
- price: S(e.y, t)
2727
+ time: w(e.x, t),
2728
+ price: T(e.y, t)
2729
2729
  };
2730
2730
  }
2731
2731
  applyLineStyle(e, t) {
@@ -2763,7 +2763,7 @@ var He = class {
2763
2763
  let r = n.x - t.x, i = n.y - t.y, a = Math.hypot(r, i);
2764
2764
  return a === 0 ? Math.hypot(e.x - t.x, e.y - t.y) : Math.abs(r * (t.y - e.y) - i * (t.x - e.x)) / a;
2765
2765
  }
2766
- }, Ue = 1, We = class {
2766
+ }, Ye = 1, Xe = class {
2767
2767
  registry = /* @__PURE__ */ new Map();
2768
2768
  drawings = [];
2769
2769
  state = "idle";
@@ -2922,7 +2922,7 @@ var He = class {
2922
2922
  if (this.state === "creating" && this.creatingDrawing) {
2923
2923
  let n = this.registry.get(this.creatingDrawing.type);
2924
2924
  if (n && this.committedAnchors < n.descriptor.requiredAnchors) {
2925
- let n = x(e.x, t), r = S(e.y, t);
2925
+ let n = w(e.x, t), r = T(e.y, t);
2926
2926
  return this.previewAnchor = this.snapToOHLC(n, r, t), this.requestRender?.(), !0;
2927
2927
  }
2928
2928
  }
@@ -2968,7 +2968,7 @@ var He = class {
2968
2968
  let t = this.drawings.find((t) => t.id === e);
2969
2969
  if (!t) return null;
2970
2970
  let n = structuredClone(t);
2971
- return n.id = `tc_drawing_${Ue++}`, n.anchors = n.anchors.map((e) => ({
2971
+ return n.id = `tc_drawing_${Ye++}`, n.anchors = n.anchors.map((e) => ({
2972
2972
  ...e,
2973
2973
  time: e.time + 3
2974
2974
  })), n.locked = !1, this.drawings.push(n), this.undoRedo?.push({
@@ -3008,9 +3008,9 @@ var He = class {
3008
3008
  if (!this.activeTool) return !1;
3009
3009
  let n = this.registry.get(this.activeTool);
3010
3010
  if (!n) return !1;
3011
- let r = x(e.x, t), i = S(e.y, t), a = this.snapToOHLC(r, i, t);
3011
+ let r = w(e.x, t), i = T(e.y, t), a = this.snapToOHLC(r, i, t);
3012
3012
  return this.creatingDrawing ? (this.creatingDrawing.anchors.push(a), this.committedAnchors++, this.previewAnchor = null, this.committedAnchors >= n.descriptor.requiredAnchors && this.finalizeCreation(), this.requestRender?.(), !0) : (this.creatingDrawing = {
3013
- id: `tc_drawing_${Ue++}`,
3013
+ id: `tc_drawing_${Ye++}`,
3014
3014
  type: this.activeTool,
3015
3015
  anchors: [a],
3016
3016
  style: { ...this.activeStyle },
@@ -3048,7 +3048,7 @@ var He = class {
3048
3048
  handleMove(e, t) {
3049
3049
  let n = this.drawings.find((e) => e.id === this.selectedDrawingId);
3050
3050
  if (!n || !this.dragStartPoint) return !1;
3051
- let r = x(e.x, t) - x(this.dragStartPoint.x, t), i = S(e.y, t) - S(this.dragStartPoint.y, t);
3051
+ let r = w(e.x, t) - w(this.dragStartPoint.x, t), i = T(e.y, t) - T(this.dragStartPoint.y, t);
3052
3052
  return n.anchors = this.dragStartAnchors.map((e) => ({
3053
3053
  time: e.time + r,
3054
3054
  price: e.price + i
@@ -3057,18 +3057,18 @@ var He = class {
3057
3057
  handleResize(e, t) {
3058
3058
  let n = this.drawings.find((e) => e.id === this.selectedDrawingId);
3059
3059
  return !n || this.dragAnchorIndex < 0 ? !1 : (n.anchors[this.dragAnchorIndex] = {
3060
- time: x(e.x, t),
3061
- price: S(e.y, t)
3060
+ time: w(e.x, t),
3061
+ price: T(e.y, t)
3062
3062
  }, this.requestRender?.(), !0);
3063
3063
  }
3064
- }, Ge = class {
3064
+ }, Ze = class {
3065
3065
  constructor(e) {
3066
3066
  this.manager = e;
3067
3067
  }
3068
3068
  render(e, t) {
3069
3069
  this.manager.render(e, t);
3070
3070
  }
3071
- }, Ke = class extends q {
3071
+ }, Qe = class extends W {
3072
3072
  descriptor = {
3073
3073
  type: "trendLine",
3074
3074
  name: "Trend Line",
@@ -3084,7 +3084,7 @@ var He = class {
3084
3084
  let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n);
3085
3085
  return this.distanceToLine(e, i, a) <= r;
3086
3086
  }
3087
- }, qe = class extends q {
3087
+ }, $e = class extends W {
3088
3088
  descriptor = {
3089
3089
  type: "horizontalLine",
3090
3090
  name: "Horizontal Line",
@@ -3092,15 +3092,15 @@ var He = class {
3092
3092
  };
3093
3093
  render(e, t, n, r) {
3094
3094
  if (t.anchors.length < 1) return;
3095
- let i = b(t.anchors[0].price, n), { chartRect: a } = n;
3095
+ let i = C(t.anchors[0].price, n), { chartRect: a } = n;
3096
3096
  this.applyLineStyle(e, t.style), e.beginPath(), e.moveTo(a.x, i), e.lineTo(a.x + a.width, i), e.stroke(), this.resetLineStyle(e), e.fillStyle = t.style.color, e.font = "11px sans-serif", e.textBaseline = "bottom", e.fillText(t.anchors[0].price.toFixed(2), a.x + 4, i - 3), r && this.renderAnchorHandles(e, t, n);
3097
3097
  }
3098
3098
  hitTest(e, t, n, r) {
3099
3099
  if (t.anchors.length < 1) return !1;
3100
- let i = b(t.anchors[0].price, n);
3100
+ let i = C(t.anchors[0].price, n);
3101
3101
  return Math.abs(e.y - i) <= r && e.x >= n.chartRect.x && e.x <= n.chartRect.x + n.chartRect.width;
3102
3102
  }
3103
- }, Je = class extends q {
3103
+ }, et = class extends W {
3104
3104
  descriptor = {
3105
3105
  type: "verticalLine",
3106
3106
  name: "Vertical Line",
@@ -3116,7 +3116,7 @@ var He = class {
3116
3116
  let i = this.anchorToPixel(t.anchors[0], n), { chartRect: a } = n;
3117
3117
  return Math.abs(e.x - i.x) <= r && e.y >= a.y && e.y <= a.y + a.height;
3118
3118
  }
3119
- }, Ye = class extends q {
3119
+ }, tt = class extends W {
3120
3120
  descriptor = {
3121
3121
  type: "ray",
3122
3122
  name: "Ray",
@@ -3134,7 +3134,7 @@ var He = class {
3134
3134
  let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n), o = a.x - i.x, s = a.y - i.y;
3135
3135
  return ((e.x - i.x) * o + (e.y - i.y) * s) / (o * o + s * s) < 0 ? !1 : this.distanceToInfiniteLine(e, i, a) <= r;
3136
3136
  }
3137
- }, Xe = class extends q {
3137
+ }, nt = class extends W {
3138
3138
  descriptor = {
3139
3139
  type: "extendedLine",
3140
3140
  name: "Extended Line",
@@ -3152,7 +3152,7 @@ var He = class {
3152
3152
  let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n);
3153
3153
  return this.distanceToInfiniteLine(e, i, a) <= r;
3154
3154
  }
3155
- }, Ze = class extends q {
3155
+ }, rt = class extends W {
3156
3156
  descriptor = {
3157
3157
  type: "parallelChannel",
3158
3158
  name: "Parallel Channel",
@@ -3189,7 +3189,7 @@ var He = class {
3189
3189
  }
3190
3190
  return !1;
3191
3191
  }
3192
- }, J = class extends q {
3192
+ }, it = class extends W {
3193
3193
  descriptor = {
3194
3194
  type: "regressionChannel",
3195
3195
  name: "Regression Channel",
@@ -3212,7 +3212,7 @@ var He = class {
3212
3212
  let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n), o = Math.hypot(a.x - i.x, a.y - i.y), s = Math.max(10, Math.min(o * .2, 100));
3213
3213
  return this.distanceToLine(e, i, a) <= r + s;
3214
3214
  }
3215
- }, Y = [
3215
+ }, G = [
3216
3216
  0,
3217
3217
  .236,
3218
3218
  .382,
@@ -3220,7 +3220,7 @@ var He = class {
3220
3220
  .618,
3221
3221
  .786,
3222
3222
  1
3223
- ], Qe = class extends q {
3223
+ ], at = class extends W {
3224
3224
  descriptor = {
3225
3225
  type: "fibRetracement",
3226
3226
  name: "Fibonacci Retracement",
@@ -3230,13 +3230,13 @@ var He = class {
3230
3230
  if (t.anchors.length < 2) return;
3231
3231
  let { chartRect: i } = n, a = t.anchors[0].price, o = t.anchors[1].price, s = a - o;
3232
3232
  e.font = "11px sans-serif", e.textBaseline = "middle";
3233
- for (let r of Y) {
3234
- let a = o + s * (1 - r), c = b(a, n);
3233
+ for (let r of G) {
3234
+ let a = o + s * (1 - r), c = C(a, n);
3235
3235
  this.applyLineStyle(e, t.style), e.globalAlpha = r === 0 || r === 1 ? 1 : .7, e.beginPath(), e.moveTo(i.x, c), e.lineTo(i.x + i.width, c), e.stroke(), e.fillStyle = t.style.color, e.textAlign = "left", e.fillText(`${(r * 100).toFixed(1)}% (${a.toFixed(2)})`, i.x + 4, c - 2);
3236
3236
  }
3237
3237
  if (e.globalAlpha = 1, t.style.fillColor) {
3238
- for (let r = 0; r < Y.length - 1; r++) {
3239
- let a = o + s * (1 - Y[r]), c = o + s * (1 - Y[r + 1]), l = b(a, n), u = b(c, n);
3238
+ for (let r = 0; r < G.length - 1; r++) {
3239
+ let a = o + s * (1 - G[r]), c = o + s * (1 - G[r + 1]), l = C(a, n), u = C(c, n);
3240
3240
  e.fillStyle = t.style.fillColor, e.globalAlpha = .05 + r * .02, e.fillRect(i.x, Math.min(l, u), i.width, Math.abs(u - l));
3241
3241
  }
3242
3242
  e.globalAlpha = 1;
@@ -3248,13 +3248,13 @@ var He = class {
3248
3248
  let { chartRect: i } = n;
3249
3249
  if (e.x < i.x - r || e.x > i.x + i.width + r) return !1;
3250
3250
  let a = t.anchors[0].price, o = t.anchors[1].price, s = a - o;
3251
- for (let t of Y) {
3252
- let i = b(o + s * (1 - t), n);
3251
+ for (let t of G) {
3252
+ let i = C(o + s * (1 - t), n);
3253
3253
  if (Math.abs(e.y - i) <= r) return !0;
3254
3254
  }
3255
3255
  return !1;
3256
3256
  }
3257
- }, $e = [
3257
+ }, ot = [
3258
3258
  0,
3259
3259
  .618,
3260
3260
  1,
@@ -3263,7 +3263,7 @@ var He = class {
3263
3263
  2.618,
3264
3264
  3.618,
3265
3265
  4.236
3266
- ], et = class extends q {
3266
+ ], st = class extends W {
3267
3267
  descriptor = {
3268
3268
  type: "fibExtension",
3269
3269
  name: "Fibonacci Extension",
@@ -3279,8 +3279,8 @@ var He = class {
3279
3279
  }
3280
3280
  let { chartRect: i } = n, a = t.anchors[0].price, o = t.anchors[1].price, s = t.anchors[2].price, c = a - o;
3281
3281
  e.font = "11px sans-serif", e.textBaseline = "middle", e.textAlign = "left";
3282
- for (let r of $e) {
3283
- let a = b(s + c * r, n);
3282
+ for (let r of ot) {
3283
+ let a = C(s + c * r, n);
3284
3284
  this.applyLineStyle(e, t.style), e.globalAlpha = r === 0 || r === 1 ? 1 : .6, e.beginPath(), e.moveTo(i.x, a), e.lineTo(i.x + i.width, a), e.stroke(), e.fillStyle = t.style.color, e.fillText(`${(r * 100).toFixed(1)}%`, i.x + 4, a - 2);
3285
3285
  }
3286
3286
  e.globalAlpha = 1, this.resetLineStyle(e), r && this.renderAnchorHandles(e, t, n);
@@ -3290,13 +3290,13 @@ var He = class {
3290
3290
  let { chartRect: i } = n;
3291
3291
  if (e.x < i.x - r || e.x > i.x + i.width + r) return !1;
3292
3292
  let a = t.anchors[0].price - t.anchors[1].price;
3293
- for (let i of $e) {
3294
- let o = b(t.anchors[2].price + a * i, n);
3293
+ for (let i of ot) {
3294
+ let o = C(t.anchors[2].price + a * i, n);
3295
3295
  if (Math.abs(e.y - o) <= r) return !0;
3296
3296
  }
3297
3297
  return !1;
3298
3298
  }
3299
- }, tt = class extends q {
3299
+ }, ct = class extends W {
3300
3300
  descriptor = {
3301
3301
  type: "rectangle",
3302
3302
  name: "Rectangle",
@@ -3314,7 +3314,7 @@ var He = class {
3314
3314
  let u = Math.min(i.x, a.x) + r, d = Math.min(i.y, a.y) + r, f = Math.max(i.x, a.x) - r, p = Math.max(i.y, a.y) - r;
3315
3315
  return !(e.x > u && e.x < f && e.y > d && e.y < p) || !!t.style.fillColor;
3316
3316
  }
3317
- }, nt = class extends q {
3317
+ }, lt = class extends W {
3318
3318
  descriptor = {
3319
3319
  type: "ellipse",
3320
3320
  name: "Ellipse",
@@ -3330,7 +3330,7 @@ var He = class {
3330
3330
  let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n), o = (i.x + a.x) / 2, s = (i.y + a.y) / 2, c = Math.max(Math.abs(a.x - i.x) / 2, 1), l = Math.max(Math.abs(a.y - i.y) / 2, 1), u = (e.x - o) / c, d = (e.y - s) / l, f = Math.sqrt(u * u + d * d), p = r / Math.max(Math.min(c, l), 4);
3331
3331
  return t.style.fillColor ? f <= 1 + p : Math.abs(f - 1) <= p;
3332
3332
  }
3333
- }, rt = class extends q {
3333
+ }, ut = class extends W {
3334
3334
  descriptor = {
3335
3335
  type: "triangle",
3336
3336
  name: "Triangle",
@@ -3356,7 +3356,7 @@ var He = class {
3356
3356
  }
3357
3357
  return !1;
3358
3358
  }
3359
- }, it = class extends q {
3359
+ }, dt = class extends W {
3360
3360
  descriptor = {
3361
3361
  type: "pitchfork",
3362
3362
  name: "Andrews' Pitchfork",
@@ -3392,7 +3392,7 @@ var He = class {
3392
3392
  };
3393
3393
  return this.distanceToInfiniteLine(e, a, u) <= r || this.distanceToInfiniteLine(e, o, d) <= r;
3394
3394
  }
3395
- }, at = [
3395
+ }, ft = [
3396
3396
  "1",
3397
3397
  "2",
3398
3398
  "3",
@@ -3401,7 +3401,7 @@ var He = class {
3401
3401
  "A",
3402
3402
  "B",
3403
3403
  "C"
3404
- ], ot = class extends q {
3404
+ ], pt = class extends W {
3405
3405
  descriptor = {
3406
3406
  type: "elliottWave",
3407
3407
  name: "Elliott Wave",
@@ -3413,9 +3413,9 @@ var He = class {
3413
3413
  this.applyLineStyle(e, t.style), e.beginPath(), e.moveTo(i[0].x, i[0].y);
3414
3414
  for (let t = 1; t < i.length; t++) e.lineTo(i[t].x, i[t].y);
3415
3415
  e.stroke(), this.resetLineStyle(e), e.font = "bold 12px sans-serif", e.fillStyle = t.style.color, e.textAlign = "center";
3416
- for (let t = 0; t < i.length && t < at.length; t++) {
3416
+ for (let t = 0; t < i.length && t < ft.length; t++) {
3417
3417
  let n = t % 2 == 0 ? -12 : 12;
3418
- e.textBaseline = n < 0 ? "bottom" : "top", e.fillText(at[t], i[t].x, i[t].y + n);
3418
+ e.textBaseline = n < 0 ? "bottom" : "top", e.fillText(ft[t], i[t].x, i[t].y + n);
3419
3419
  }
3420
3420
  r && this.renderAnchorHandles(e, t, n);
3421
3421
  }
@@ -3425,7 +3425,7 @@ var He = class {
3425
3425
  for (let t = 0; t < i.length - 1; t++) if (this.distanceToLine(e, i[t], i[t + 1]) <= r) return !0;
3426
3426
  return !1;
3427
3427
  }
3428
- }, st = class extends q {
3428
+ }, mt = class extends W {
3429
3429
  descriptor = {
3430
3430
  type: "priceRange",
3431
3431
  name: "Price Range",
@@ -3443,7 +3443,7 @@ var He = class {
3443
3443
  let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n), o = Math.min(i.x, a.x), s = Math.max(i.x, a.x), c = Math.min(i.y, a.y), l = Math.max(i.y, a.y);
3444
3444
  return e.x >= o - r && e.x <= s + r && e.y >= c - r && e.y <= l + r;
3445
3445
  }
3446
- }, ct = class extends q {
3446
+ }, ht = class extends W {
3447
3447
  descriptor = {
3448
3448
  type: "dateRange",
3449
3449
  name: "Date Range",
@@ -3461,7 +3461,7 @@ var He = class {
3461
3461
  let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n), { chartRect: o } = n, s = Math.min(i.x, a.x), c = Math.max(i.x, a.x);
3462
3462
  return e.x >= s - r && e.x <= c + r && e.y >= o.y && e.y <= o.y + o.height;
3463
3463
  }
3464
- }, lt = class extends q {
3464
+ }, gt = class extends W {
3465
3465
  descriptor = {
3466
3466
  type: "measure",
3467
3467
  name: "Measure",
@@ -3483,7 +3483,7 @@ var He = class {
3483
3483
  let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n);
3484
3484
  return this.distanceToLine(e, i, a) <= r;
3485
3485
  }
3486
- }, ut = class extends q {
3486
+ }, _t = class extends W {
3487
3487
  descriptor = {
3488
3488
  type: "text",
3489
3489
  name: "Text",
@@ -3503,7 +3503,7 @@ var He = class {
3503
3503
  let i = this.anchorToPixel(t.anchors[0], n), a = t.style.fontSize || 14;
3504
3504
  return e.x >= i.x - r && e.x <= i.x + 80 + r && e.y >= i.y - r && e.y <= i.y + a + r;
3505
3505
  }
3506
- }, dt = class extends q {
3506
+ }, vt = class extends W {
3507
3507
  descriptor = {
3508
3508
  type: "arrow",
3509
3509
  name: "Arrow",
@@ -3521,7 +3521,7 @@ var He = class {
3521
3521
  let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n);
3522
3522
  return this.distanceToLine(e, i, a) <= r;
3523
3523
  }
3524
- }, ft = [
3524
+ }, yt = [
3525
3525
  {
3526
3526
  label: "8x1",
3527
3527
  ratio: 8
@@ -3558,7 +3558,7 @@ var He = class {
3558
3558
  label: "1x8",
3559
3559
  ratio: .125
3560
3560
  }
3561
- ], pt = class extends q {
3561
+ ], bt = class extends W {
3562
3562
  descriptor = {
3563
3563
  type: "gannFan",
3564
3564
  name: "Gann Fan",
@@ -3570,7 +3570,7 @@ var He = class {
3570
3570
  if (Math.abs(o) < 1) return;
3571
3571
  let c = s / o, l = o > 0 ? 1 : -1, { chartRect: u } = n, d = l > 0 ? u.x + u.width : u.x;
3572
3572
  this.applyLineStyle(e, t.style);
3573
- for (let { label: n, ratio: r } of ft) {
3573
+ for (let { label: n, ratio: r } of yt) {
3574
3574
  let a = c * r, o = d, s = i.y + a * (o - i.x);
3575
3575
  e.globalAlpha = r === 1 ? 1 : .5, e.lineWidth = r === 1 ? t.style.lineWidth : Math.max(.5, t.style.lineWidth * .7), e.beginPath(), e.moveTo(i.x, i.y), e.lineTo(o, s), e.stroke();
3576
3576
  let f = o - l * 4, p = s;
@@ -3583,7 +3583,7 @@ var He = class {
3583
3583
  let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n), o = a.x - i.x, s = a.y - i.y;
3584
3584
  if (Math.abs(o) < 1) return !1;
3585
3585
  let c = s / o, l = o > 0 ? 1 : -1, { chartRect: u } = n, d = l > 0 ? u.x + u.width : u.x;
3586
- for (let { ratio: t } of ft) {
3586
+ for (let { ratio: t } of yt) {
3587
3587
  let n = c * t, a = d, o = i.y + n * (a - i.x);
3588
3588
  if (this.distanceToLine(e, i, {
3589
3589
  x: a,
@@ -3592,7 +3592,7 @@ var He = class {
3592
3592
  }
3593
3593
  return !1;
3594
3594
  }
3595
- }, X = [
3595
+ }, K = [
3596
3596
  0,
3597
3597
  .25,
3598
3598
  .333,
@@ -3600,7 +3600,7 @@ var He = class {
3600
3600
  .667,
3601
3601
  .75,
3602
3602
  1
3603
- ], mt = class extends q {
3603
+ ], xt = class extends W {
3604
3604
  descriptor = {
3605
3605
  type: "gannBox",
3606
3606
  name: "Gann Box",
@@ -3611,18 +3611,18 @@ var He = class {
3611
3611
  let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n), o = Math.min(i.x, a.x), s = Math.max(i.x, a.x), c = Math.min(i.y, a.y), l = Math.max(i.y, a.y), u = s - o, d = l - c;
3612
3612
  if (!(u < 2 || d < 2)) {
3613
3613
  this.applyLineStyle(e, t.style), e.strokeRect(o, c, u, d), e.save(), e.globalAlpha = .35;
3614
- for (let t of X) {
3614
+ for (let t of K) {
3615
3615
  if (t === 0 || t === 1) continue;
3616
3616
  let n = c + d * t;
3617
3617
  e.beginPath(), e.moveTo(o, n), e.lineTo(s, n), e.stroke();
3618
3618
  }
3619
- for (let t of X) {
3619
+ for (let t of K) {
3620
3620
  if (t === 0 || t === 1) continue;
3621
3621
  let n = o + u * t;
3622
3622
  e.beginPath(), e.moveTo(n, c), e.lineTo(n, l), e.stroke();
3623
3623
  }
3624
3624
  e.globalAlpha = .5, e.setLineDash([4, 3]), e.beginPath(), e.moveTo(o, c), e.lineTo(s, l), e.stroke(), e.beginPath(), e.moveTo(s, c), e.lineTo(o, l), e.stroke(), e.restore(), this.resetLineStyle(e), e.fillStyle = t.style.color, e.font = "8px sans-serif", e.globalAlpha = .6, e.textBaseline = "bottom", e.textAlign = "right";
3625
- for (let t of X) {
3625
+ for (let t of K) {
3626
3626
  if (t === 0 || t === 1) continue;
3627
3627
  let n = c + d * t;
3628
3628
  e.fillText(`${(t * 100).toFixed(0)}%`, o - 3, n);
@@ -3647,7 +3647,7 @@ var He = class {
3647
3647
  y: l
3648
3648
  }) <= r;
3649
3649
  }
3650
- }, ht = class extends q {
3650
+ }, St = class extends W {
3651
3651
  descriptor = {
3652
3652
  type: "anchoredVWAP",
3653
3653
  name: "Anchored VWAP",
@@ -3667,7 +3667,7 @@ var He = class {
3667
3667
  if (a >= i.length) return;
3668
3668
  let { vwap: o, upper1: s, lower1: c, upper2: l, lower2: u } = this.computeVWAP(i, a), { chartRect: d } = n, f = n.barWidth + n.barSpacing;
3669
3669
  if (this.applyLineStyle(e, t.style), e.lineWidth = t.style.lineWidth + .5, this.drawLine(e, o, a, n, d, f), this.showBands && o.length > 1 && (e.globalAlpha = .4, e.lineWidth = Math.max(.5, t.style.lineWidth * .6), e.setLineDash([4, 3]), this.drawLine(e, s, a, n, d, f), this.drawLine(e, c, a, n, d, f), e.globalAlpha = .25, this.drawLine(e, l, a, n, d, f), this.drawLine(e, u, a, n, d, f), e.globalAlpha = 1), this.resetLineStyle(e), o.length > 0) {
3670
- let r = o[o.length - 1], i = y(a + o.length - 1, n), s = b(r, n);
3670
+ let r = o[o.length - 1], i = S(a + o.length - 1, n), s = C(r, n);
3671
3671
  i >= d.x && i <= d.x + d.width && (e.fillStyle = t.style.color, e.font = "bold 9px sans-serif", e.textAlign = "left", e.textBaseline = "middle", e.fillText(`AVWAP ${r.toFixed(2)}`, i + 6, s));
3672
3672
  }
3673
3673
  r && this.renderAnchorHandles(e, t, n);
@@ -3676,10 +3676,10 @@ var He = class {
3676
3676
  e.beginPath();
3677
3677
  let o = !1;
3678
3678
  for (let s = 0; s < t.length; s++) {
3679
- let c = y(n + s, r);
3679
+ let c = S(n + s, r);
3680
3680
  if (c < i.x - a) continue;
3681
3681
  if (c > i.x + i.width + a) break;
3682
- let l = b(t[s], r);
3682
+ let l = C(t[s], r);
3683
3683
  o ? e.lineTo(c, l) : (e.moveTo(c, l), o = !0);
3684
3684
  }
3685
3685
  e.stroke();
@@ -3708,7 +3708,7 @@ var He = class {
3708
3708
  if (a >= i.length) return !1;
3709
3709
  let { vwap: o } = this.computeVWAP(i, a);
3710
3710
  for (let t = 1; t < o.length; t++) {
3711
- let i = y(a + t - 1, n), s = b(o[t - 1], n), c = y(a + t, n), l = b(o[t], n);
3711
+ let i = S(a + t - 1, n), s = C(o[t - 1], n), c = S(a + t, n), l = C(o[t], n);
3712
3712
  if (this.distanceToLine(e, {
3713
3713
  x: i,
3714
3714
  y: s
@@ -3719,7 +3719,7 @@ var He = class {
3719
3719
  }
3720
3720
  return !1;
3721
3721
  }
3722
- }, gt = class extends q {
3722
+ }, Ct = class extends W {
3723
3723
  descriptor = {
3724
3724
  type: "volumeProfileRange",
3725
3725
  name: "Volume Profile (Range)",
@@ -3745,15 +3745,15 @@ var He = class {
3745
3745
  if (d === 0) return;
3746
3746
  let f = 0;
3747
3747
  for (let e = 1; e < this.numBins; e++) u[e] > u[f] && (f = e);
3748
- let p = y(o, n) + n.barWidth, m = t.style.color, h = t.style.fillColor ?? "#FF9800";
3748
+ let p = S(o, n) + n.barWidth, m = t.style.color, h = t.style.fillColor ?? "#FF9800";
3749
3749
  e.save();
3750
3750
  for (let t = 0; t < this.numBins; t++) {
3751
- let r = u[t] / d * 100, i = s + (t + 1) * l, a = s + t * l, o = b(i, n), c = b(a, n), g = Math.abs(c - o);
3751
+ let r = u[t] / d * 100, i = s + (t + 1) * l, a = s + t * l, o = C(i, n), c = C(a, n), g = Math.abs(c - o);
3752
3752
  e.globalAlpha = .35, e.fillStyle = t === f ? h : m, e.fillRect(p, Math.min(o, c), r, Math.max(1, g - .5));
3753
3753
  }
3754
- let g = s + (f + .5) * l, _ = b(g, n);
3754
+ let g = s + (f + .5) * l, _ = C(g, n);
3755
3755
  e.globalAlpha = .7, e.strokeStyle = h, e.lineWidth = 1, e.setLineDash([4, 3]), e.beginPath();
3756
- let v = y(a, n) - n.barWidth / 2;
3756
+ let v = S(a, n) - n.barWidth / 2;
3757
3757
  e.moveTo(v, _), e.lineTo(p + 100, _), e.stroke(), e.fillStyle = h, e.font = "9px sans-serif", e.textAlign = "left", e.textBaseline = "bottom", e.globalAlpha = .8, e.fillText(`POC ${g.toFixed(2)}`, p + 100 + 4, _ - 2), e.restore(), r && this.renderAnchorHandles(e, t, n);
3758
3758
  }
3759
3759
  hitTest(e, t, n, r) {
@@ -3764,16 +3764,16 @@ var He = class {
3764
3764
  };
3765
3765
  //#endregion
3766
3766
  //#region src/drawings/tools/index.ts
3767
- function _t(e) {
3768
- e.register(new Ke()), e.register(new qe()), e.register(new Je()), e.register(new Ye()), e.register(new Xe()), e.register(new Ze()), e.register(new J()), e.register(new Qe()), e.register(new et()), e.register(new tt()), e.register(new nt()), e.register(new rt()), e.register(new it()), e.register(new ot()), e.register(new st()), e.register(new ct()), e.register(new lt()), e.register(new ut()), e.register(new dt()), e.register(new pt()), e.register(new mt()), e.register(new ht()), e.register(new gt());
3767
+ function wt(e) {
3768
+ e.register(new Qe()), e.register(new $e()), e.register(new et()), e.register(new tt()), e.register(new nt()), e.register(new rt()), e.register(new it()), e.register(new at()), e.register(new st()), e.register(new ct()), e.register(new lt()), e.register(new ut()), e.register(new dt()), e.register(new pt()), e.register(new mt()), e.register(new ht()), e.register(new gt()), e.register(new _t()), e.register(new vt()), e.register(new bt()), e.register(new xt()), e.register(new St()), e.register(new Ct());
3769
3769
  }
3770
3770
  //#endregion
3771
3771
  //#region src/trading/OrderRenderer.ts
3772
- var vt = class {
3772
+ var Tt = class {
3773
3773
  render(e, t, n, r, i, a) {
3774
3774
  let o = i.orderColors?.buy ?? "#26A69A", s = i.orderColors?.sell ?? "#EF5350", { chartRect: c } = n;
3775
3775
  for (let i of t) {
3776
- let t = a?.orderId === i.id && a.sourceType === "order", l = b(t ? a.currentPrice : i.price, n);
3776
+ let t = a?.orderId === i.id && a.sourceType === "order", l = C(t ? a.currentPrice : i.price, n);
3777
3777
  if (l < c.y || l > c.y + c.height) continue;
3778
3778
  let u = i.side === "buy" ? o : s;
3779
3779
  e.setLineDash([6, 4]), e.strokeStyle = u, e.lineWidth = 1, e.beginPath(), e.moveTo(c.x, Math.round(l) + .5), e.lineTo(c.x + c.width, Math.round(l) + .5), e.stroke(), e.setLineDash([]);
@@ -3783,37 +3783,37 @@ var vt = class {
3783
3783
  e.fillStyle = u, e.fillRect(c.x + 4, l - 8, f, 16), e.fillStyle = "#FFFFFF", e.textBaseline = "middle", e.textAlign = "left", e.fillText(d, c.x + 8, l);
3784
3784
  let p = c.x + 4 + f + 6;
3785
3785
  if (e.fillStyle = u, e.beginPath(), i.side === "buy" ? (e.moveTo(p, l + 4), e.lineTo(p + 5, l - 2), e.lineTo(p + 10, l + 4)) : (e.moveTo(p, l - 4), e.lineTo(p + 5, l + 2), e.lineTo(p + 10, l - 4)), e.fill(), t) {
3786
- let t = b(a.startPrice, n);
3786
+ let t = C(a.startPrice, n);
3787
3787
  e.setLineDash([2, 4]), e.strokeStyle = u, e.globalAlpha = .3, e.beginPath(), e.moveTo(c.x, Math.round(t) + .5), e.lineTo(c.x + c.width, Math.round(t) + .5), e.stroke(), e.globalAlpha = 1, e.setLineDash([]);
3788
3788
  }
3789
3789
  }
3790
3790
  }
3791
3791
  renderAxisBadges(e, t, n, r, i, a) {
3792
- let s = i.orderColors?.buy ?? "#26A69A", c = i.orderColors?.sell ?? "#EF5350", l = i.pricePrecision ?? 2, { chartRect: u } = n, d = u.x + u.width + 1;
3792
+ let o = i.orderColors?.buy ?? "#26A69A", s = i.orderColors?.sell ?? "#EF5350", l = i.pricePrecision ?? 2, { chartRect: u } = n, d = u.x + u.width + 1;
3793
3793
  for (let i of t) {
3794
- let t = a?.orderId === i.id && a.sourceType === "order" ? a.currentPrice : i.price, f = b(t, n);
3794
+ let t = a?.orderId === i.id && a.sourceType === "order" ? a.currentPrice : i.price, f = C(t, n);
3795
3795
  if (f < u.y || f > u.y + u.height) continue;
3796
- let p = i.side === "buy" ? s : c, m = `${t.toFixed(l)} x ${i.quantity}`;
3796
+ let p = i.side === "buy" ? o : s, m = `${t.toFixed(l)} x ${i.quantity}`;
3797
3797
  e.font = `11px ${r.font.family}`;
3798
3798
  let h = e.measureText(m).width + 10;
3799
- e.fillStyle = p, e.fillRect(d, f - 9, Math.min(h, o - 2), 18), e.fillStyle = "#FFFFFF", e.textAlign = "left", e.textBaseline = "middle", e.fillText(m, d + 5, f);
3799
+ e.fillStyle = p, e.fillRect(d, f - 9, Math.min(h, c - 2), 18), e.fillStyle = "#FFFFFF", e.textAlign = "left", e.textBaseline = "middle", e.fillText(m, d + 5, f);
3800
3800
  }
3801
3801
  }
3802
3802
  hitTest(e, t, n, r) {
3803
3803
  for (let i of t) {
3804
3804
  if (i.draggable === !1) continue;
3805
- let t = b(i.price, n);
3805
+ let t = C(i.price, n);
3806
3806
  if (Math.abs(e - t) <= r) return i;
3807
3807
  }
3808
3808
  return null;
3809
3809
  }
3810
- }, yt = class {
3810
+ }, Et = class {
3811
3811
  render(e, t, n, r, i, a) {
3812
3812
  let { chartRect: o } = r, s = a.positionColors?.profit ?? "#26A69A", c = a.positionColors?.loss ?? "#EF5350", l = a.positionColors?.entry ?? "#2196F3", u = a.pricePrecision ?? 2;
3813
3813
  for (let a of t) {
3814
- let t = b(a.entryPrice, r);
3814
+ let t = C(a.entryPrice, r);
3815
3815
  if (e.strokeStyle = l, e.lineWidth = 1.5, e.setLineDash([]), e.beginPath(), e.moveTo(o.x, Math.round(t) + .5), e.lineTo(o.x + o.width, Math.round(t) + .5), e.stroke(), n !== null) {
3816
- let l = b(n, r), d = (n - a.entryPrice) * a.quantity * (a.side === "buy" ? 1 : -1), f = d >= 0;
3816
+ let l = C(n, r), d = (n - a.entryPrice) * a.quantity * (a.side === "buy" ? 1 : -1), f = d >= 0;
3817
3817
  e.fillStyle = f ? s : c, e.globalAlpha = .08;
3818
3818
  let p = Math.min(t, l), m = Math.abs(l - t);
3819
3819
  e.fillRect(o.x, p, o.width, m), e.globalAlpha = 1;
@@ -3823,24 +3823,24 @@ var vt = class {
3823
3823
  e.fillStyle = f ? s : c, e.globalAlpha = .9, e.fillRect(_, t - 10, g, 20), e.globalAlpha = 1, e.fillStyle = "#FFFFFF", e.textBaseline = "middle", e.textAlign = "left", e.fillText(h, _ + 6, t);
3824
3824
  }
3825
3825
  if (a.stopLoss !== void 0) {
3826
- let t = b(a.stopLoss, r);
3826
+ let t = C(a.stopLoss, r);
3827
3827
  e.setLineDash([4, 4]), e.strokeStyle = c, e.lineWidth = 1, e.beginPath(), e.moveTo(o.x, Math.round(t) + .5), e.lineTo(o.x + o.width, Math.round(t) + .5), e.stroke(), e.font = `bold 10px ${i.font.family}`, e.fillStyle = c, e.fillRect(o.x + 4, t - 8, 24, 16), e.fillStyle = "#FFFFFF", e.textAlign = "left", e.textBaseline = "middle", e.fillText("SL", o.x + 8, t);
3828
3828
  }
3829
3829
  if (a.takeProfit !== void 0) {
3830
- let t = b(a.takeProfit, r);
3830
+ let t = C(a.takeProfit, r);
3831
3831
  e.setLineDash([4, 4]), e.strokeStyle = s, e.lineWidth = 1, e.beginPath(), e.moveTo(o.x, Math.round(t) + .5), e.lineTo(o.x + o.width, Math.round(t) + .5), e.stroke(), e.font = `bold 10px ${i.font.family}`, e.fillStyle = s, e.fillRect(o.x + 4, t - 8, 24, 16), e.fillStyle = "#FFFFFF", e.textAlign = "left", e.textBaseline = "middle", e.fillText("TP", o.x + 8, t);
3832
3832
  }
3833
3833
  e.setLineDash([]);
3834
3834
  }
3835
3835
  }
3836
3836
  renderAxisBadges(e, t, n, r, i) {
3837
- let { chartRect: a } = n, s = i.positionColors?.entry ?? "#2196F3", c = i.pricePrecision ?? 2, l = a.x + a.width + 1;
3837
+ let { chartRect: a } = n, o = i.positionColors?.entry ?? "#2196F3", s = i.pricePrecision ?? 2, l = a.x + a.width + 1;
3838
3838
  for (let i of t) {
3839
- let t = b(i.entryPrice, n);
3840
- e.fillStyle = s, e.fillRect(l, t - 9, o - 2, 18), e.fillStyle = "#FFFFFF", e.font = `11px ${r.font.family}`, e.textAlign = "left", e.textBaseline = "middle", e.fillText(i.entryPrice.toFixed(c), l + 5, t);
3839
+ let t = C(i.entryPrice, n);
3840
+ e.fillStyle = o, e.fillRect(l, t - 9, c - 2, 18), e.fillStyle = "#FFFFFF", e.font = `11px ${r.font.family}`, e.textAlign = "left", e.textBaseline = "middle", e.fillText(i.entryPrice.toFixed(s), l + 5, t);
3841
3841
  }
3842
3842
  }
3843
- }, bt = class {
3843
+ }, Dt = class {
3844
3844
  render(e, t, n, r) {
3845
3845
  if (!r.depthOverlay?.enabled) return;
3846
3846
  let { chartRect: i } = n, a = r.depthOverlay.bidColor ?? "rgba(38,166,154,0.15)", o = r.depthOverlay.askColor ?? "rgba(239,83,80,0.15)", s = r.depthOverlay.maxWidth ?? 100, c = 0, l = [], u = 0;
@@ -3855,23 +3855,23 @@ var vt = class {
3855
3855
  cumVol: u
3856
3856
  }), u > c && (c = u);
3857
3857
  if (c === 0) return;
3858
- let f = Math.max(1, t.bids.length > 1 ? Math.abs(b(t.bids[0].price, n) - b(t.bids[1].price, n)) : 4), p = i.x + i.width;
3858
+ let f = Math.max(1, t.bids.length > 1 ? Math.abs(C(t.bids[0].price, n) - C(t.bids[1].price, n)) : 4), p = i.x + i.width;
3859
3859
  e.fillStyle = a;
3860
3860
  for (let { price: t, cumVol: r } of l) {
3861
- let a = b(t, n);
3861
+ let a = C(t, n);
3862
3862
  if (a < i.y || a > i.y + i.height) continue;
3863
3863
  let o = r / c * s;
3864
3864
  e.fillRect(p - o, a - f / 2, o, f);
3865
3865
  }
3866
3866
  e.fillStyle = o;
3867
3867
  for (let { price: t, cumVol: r } of d) {
3868
- let a = b(t, n);
3868
+ let a = C(t, n);
3869
3869
  if (a < i.y || a > i.y + i.height) continue;
3870
3870
  let o = r / c * s;
3871
3871
  e.fillRect(p - o, a - f / 2, o, f);
3872
3872
  }
3873
3873
  }
3874
- }, xt = class {
3874
+ }, Ot = class {
3875
3875
  dragState = null;
3876
3876
  startY = 0;
3877
3877
  dragging = !1;
@@ -3881,7 +3881,7 @@ var vt = class {
3881
3881
  onPointerDown(e, t, n, r, i) {
3882
3882
  for (let n of t) {
3883
3883
  if (n.draggable === !1) continue;
3884
- let t = b(n.price, r);
3884
+ let t = C(n.price, r);
3885
3885
  if (Math.abs(e.y - t) <= i) return this.dragState = {
3886
3886
  orderId: n.id,
3887
3887
  sourceType: "order",
@@ -3891,7 +3891,7 @@ var vt = class {
3891
3891
  }
3892
3892
  for (let t of n) {
3893
3893
  if (t.stopLoss !== void 0) {
3894
- let n = b(t.stopLoss, r);
3894
+ let n = C(t.stopLoss, r);
3895
3895
  if (Math.abs(e.y - n) <= i) return this.dragState = {
3896
3896
  orderId: t.id,
3897
3897
  sourceType: "stopLoss",
@@ -3900,7 +3900,7 @@ var vt = class {
3900
3900
  }, this.startY = e.y, this.dragging = !1, !0;
3901
3901
  }
3902
3902
  if (t.takeProfit !== void 0) {
3903
- let n = b(t.takeProfit, r);
3903
+ let n = C(t.takeProfit, r);
3904
3904
  if (Math.abs(e.y - n) <= i) return this.dragState = {
3905
3905
  orderId: t.id,
3906
3906
  sourceType: "takeProfit",
@@ -3917,7 +3917,7 @@ var vt = class {
3917
3917
  if (Math.abs(e.y - this.startY) < this.dragThreshold) return !0;
3918
3918
  this.dragging = !0;
3919
3919
  }
3920
- return this.dragState.currentPrice = S(e.y, t), !0;
3920
+ return this.dragState.currentPrice = T(e.y, t), !0;
3921
3921
  }
3922
3922
  onPointerUp() {
3923
3923
  if (!this.dragState) return null;
@@ -3935,7 +3935,7 @@ var vt = class {
3935
3935
  isActive() {
3936
3936
  return this.dragState !== null;
3937
3937
  }
3938
- }, St = class {
3938
+ }, kt = class {
3939
3939
  menuElement = null;
3940
3940
  removeHandler = null;
3941
3941
  onItemSelect = null;
@@ -4019,25 +4019,25 @@ var vt = class {
4019
4019
  destroy() {
4020
4020
  this.hide(), this.onItemSelect = null;
4021
4021
  }
4022
- }, Ct = class {
4022
+ }, At = class {
4023
4023
  orders = [];
4024
4024
  positions = [];
4025
4025
  depthData = null;
4026
4026
  currentPrice = null;
4027
4027
  config;
4028
- orderRenderer = new vt();
4029
- positionRenderer = new yt();
4030
- depthOverlay = new bt();
4028
+ orderRenderer = new Tt();
4029
+ positionRenderer = new Et();
4030
+ depthOverlay = new Dt();
4031
4031
  dragHandler;
4032
- contextMenu = new St();
4032
+ contextMenu = new kt();
4033
4033
  requestRender = null;
4034
4034
  eventCallback = null;
4035
4035
  container = null;
4036
4036
  constructor(e) {
4037
4037
  this.config = {
4038
- ...i,
4038
+ ...a,
4039
4039
  ...e
4040
- }, this.dragHandler = new xt(this.config.dragThreshold), this.contextMenu.onItemSelect = (e) => {
4040
+ }, this.dragHandler = new Ot(this.config.dragThreshold), this.contextMenu.onItemSelect = (e) => {
4041
4041
  this.eventCallback?.("orderPlace", e);
4042
4042
  };
4043
4043
  }
@@ -4086,7 +4086,7 @@ var vt = class {
4086
4086
  }
4087
4087
  onContextMenu(e, t) {
4088
4088
  if (!this.config.enabled || !this.config.contextMenu?.enabled || !this.container) return !1;
4089
- let n = S(e.y, t);
4089
+ let n = T(e.y, t);
4090
4090
  return this.contextMenu.show(e, n, this.container, this.config), !0;
4091
4091
  }
4092
4092
  render(e, t, n) {
@@ -4098,7 +4098,7 @@ var vt = class {
4098
4098
  destroy() {
4099
4099
  this.contextMenu.destroy();
4100
4100
  }
4101
- }, wt = class {
4101
+ }, jt = class {
4102
4102
  constructor(e) {
4103
4103
  this.manager = e;
4104
4104
  }
@@ -4108,7 +4108,7 @@ var vt = class {
4108
4108
  renderAxisBadges(e, t, n) {
4109
4109
  this.manager.renderAxisBadges(e, t, n);
4110
4110
  }
4111
- }, Z = class {
4111
+ }, q = class {
4112
4112
  listeners = /* @__PURE__ */ new Map();
4113
4113
  on(e, t) {
4114
4114
  let n = this.listeners.get(e);
@@ -4130,7 +4130,7 @@ var vt = class {
4130
4130
  removeAllListeners() {
4131
4131
  this.listeners.clear();
4132
4132
  }
4133
- }, Tt = class extends Z {
4133
+ }, Mt = class extends q {
4134
4134
  currentBar = null;
4135
4135
  timeframeMs;
4136
4136
  tickRing;
@@ -4138,10 +4138,10 @@ var vt = class {
4138
4138
  ringCount = 0;
4139
4139
  ringCapacity;
4140
4140
  constructor(e, t = 1e3) {
4141
- super(), this.timeframeMs = p(e), this.ringCapacity = t, this.tickRing = Array(t);
4141
+ super(), this.timeframeMs = g(e), this.ringCapacity = t, this.tickRing = Array(t);
4142
4142
  }
4143
4143
  setTimeframe(e) {
4144
- this.timeframeMs = p(e), this.currentBar = null, this.ringHead = 0, this.ringCount = 0;
4144
+ this.timeframeMs = g(e), this.currentBar = null, this.ringHead = 0, this.ringCount = 0;
4145
4145
  }
4146
4146
  processTick(e) {
4147
4147
  let t = (this.ringHead + this.ringCount) % this.ringCapacity;
@@ -4192,14 +4192,14 @@ var vt = class {
4192
4192
  alignToTimeframe(e) {
4193
4193
  return Math.floor(e / this.timeframeMs) * this.timeframeMs;
4194
4194
  }
4195
- }, Q = class extends Z {
4195
+ }, J = class extends q {
4196
4196
  config;
4197
4197
  attempt = 0;
4198
4198
  timer = null;
4199
4199
  active = !1;
4200
4200
  constructor(e) {
4201
4201
  super(), this.config = {
4202
- ...n,
4202
+ ...r,
4203
4203
  ...e
4204
4204
  };
4205
4205
  }
@@ -4239,7 +4239,7 @@ var vt = class {
4239
4239
  let e = this.config.baseDelay, t = this.config.backoffMultiplier ** (this.attempt - 1), n = Math.min(e * t, this.config.maxDelay), r = n * .25 * (Math.random() * 2 - 1);
4240
4240
  return Math.max(0, Math.round(n + r));
4241
4241
  }
4242
- }, Et = class {
4242
+ }, Nt = class {
4243
4243
  price = null;
4244
4244
  previousClose = null;
4245
4245
  visible = !0;
@@ -4259,23 +4259,23 @@ var vt = class {
4259
4259
  }
4260
4260
  render(e, t, n) {
4261
4261
  if (!this.visible || this.price === null) return;
4262
- let r = b(this.price, t), { chartRect: i } = t;
4262
+ let r = C(this.price, t), { chartRect: i } = t;
4263
4263
  if (r < i.y || r > i.y + i.height) return;
4264
- let a = this.previousClose === null || this.price >= this.previousClose ? n.candleUp ?? "#26A69A" : n.candleDown ?? "#EF5350", s = Date.now() < this.flashUntil;
4265
- e.setLineDash([4, 3]), e.strokeStyle = a, e.lineWidth = 1, e.globalAlpha = s ? 1 : .7, e.beginPath(), e.moveTo(i.x, Math.round(r) + .5), e.lineTo(i.x + i.width, Math.round(r) + .5), e.stroke(), e.setLineDash([]), e.globalAlpha = 1;
4266
- let c = i.x + i.width + 1, l = this.price.toFixed(this.pricePrecision);
4264
+ let a = this.previousClose === null || this.price >= this.previousClose ? n.candleUp ?? "#26A69A" : n.candleDown ?? "#EF5350", o = Date.now() < this.flashUntil;
4265
+ e.setLineDash([4, 3]), e.strokeStyle = a, e.lineWidth = 1, e.globalAlpha = o ? 1 : .7, e.beginPath(), e.moveTo(i.x, Math.round(r) + .5), e.lineTo(i.x + i.width, Math.round(r) + .5), e.stroke(), e.setLineDash([]), e.globalAlpha = 1;
4266
+ let s = i.x + i.width + 1, l = this.price.toFixed(this.pricePrecision);
4267
4267
  e.font = `bold 11px ${n.font.family}`;
4268
- let u = e.measureText(l).width, d = Math.min(u + 12, o - 2);
4269
- e.fillStyle = a, e.fillRect(c, r - 10, d, 20);
4270
- let f = c - 5;
4271
- e.beginPath(), e.moveTo(f, r), e.lineTo(f + 5, r - 5), e.lineTo(f + 5, r + 5), e.closePath(), e.fill(), e.fillStyle = "#FFFFFF", e.textBaseline = "middle", e.textAlign = "left", e.fillText(l, c + 5, r);
4268
+ let u = e.measureText(l).width, d = Math.min(u + 12, c - 2);
4269
+ e.fillStyle = a, e.fillRect(s, r - 10, d, 20);
4270
+ let f = s - 5;
4271
+ e.beginPath(), e.moveTo(f, r), e.lineTo(f + 5, r - 5), e.lineTo(f + 5, r + 5), e.closePath(), e.fill(), e.fillStyle = "#FFFFFF", e.textBaseline = "middle", e.textAlign = "left", e.fillText(l, s + 5, r);
4272
4272
  }
4273
- }, Dt = class extends Z {
4273
+ }, Pt = class extends q {
4274
4274
  config = null;
4275
4275
  adapter = null;
4276
4276
  aggregator = null;
4277
4277
  reconnector;
4278
- priceLine = new Et();
4278
+ priceLine = new Nt();
4279
4279
  state = "disconnected";
4280
4280
  lastPrice = null;
4281
4281
  previousClose = null;
@@ -4283,13 +4283,13 @@ var vt = class {
4283
4283
  heartbeatTimer = null;
4284
4284
  lastMessageTime = 0;
4285
4285
  constructor() {
4286
- super(), this.reconnector = new Q(), this.wireReconnector();
4286
+ super(), this.reconnector = new J(), this.wireReconnector();
4287
4287
  }
4288
4288
  async connect(e) {
4289
4289
  this.disconnect(), this.config = {
4290
- ...r,
4290
+ ...i,
4291
4291
  ...e
4292
- }, this.adapter = e.adapter, this.aggregator = new Tt(e.timeframe), this.reconnector.removeAllListeners(), this.reconnector.stop(), this.reconnector = new Q(e.reconnect ?? n), this.wireReconnector(), this.aggregator.on("bar", (e) => {
4292
+ }, this.adapter = e.adapter, this.aggregator = new Mt(e.timeframe), this.reconnector.removeAllListeners(), this.reconnector.stop(), this.reconnector = new J(e.reconnect ?? r), this.wireReconnector(), this.aggregator.on("bar", (e) => {
4293
4293
  this.emit("barUpdate", e), this.updatePrice(e.close);
4294
4294
  }), this.aggregator.on("barClose", (e) => {
4295
4295
  this.previousClose = e.close, this.emit("barClose", e);
@@ -4391,7 +4391,7 @@ var vt = class {
4391
4391
  dispose() {
4392
4392
  this.disconnect(), this.removeAllListeners();
4393
4393
  }
4394
- }, Ot = {
4394
+ }, Ft = {
4395
4395
  "1s": "1s",
4396
4396
  "1m": "1m",
4397
4397
  "3m": "3m",
@@ -4408,7 +4408,7 @@ var vt = class {
4408
4408
  "3d": "3d",
4409
4409
  "1w": "1w",
4410
4410
  "1M": "1M"
4411
- }, kt = class {
4411
+ }, It = class {
4412
4412
  name = "binance";
4413
4413
  ws = null;
4414
4414
  state = "disconnected";
@@ -4429,7 +4429,7 @@ var vt = class {
4429
4429
  return this.state;
4430
4430
  }
4431
4431
  async fetchHistory(e, t, n = 500) {
4432
- let r = Ot[t] ?? "15m", i = `${this.restBase}/klines?symbol=${e}&interval=${r}&limit=${n}`, a = await fetch(i);
4432
+ let r = Ft[t] ?? "15m", i = `${this.restBase}/klines?symbol=${e}&interval=${r}&limit=${n}`, a = await fetch(i);
4433
4433
  if (!a.ok) throw Error(`Binance REST error: ${a.status}`);
4434
4434
  return (await a.json()).map((e) => ({
4435
4435
  time: e[0],
@@ -4452,7 +4452,7 @@ var vt = class {
4452
4452
  }
4453
4453
  connectWs() {
4454
4454
  if (!this.config) return;
4455
- let e = `${this.config.symbol.toLowerCase()}@kline_${Ot[this.config.timeframe] ?? "15m"}`, t = `${this.wsBase}/${e}`;
4455
+ let e = `${this.config.symbol.toLowerCase()}@kline_${Ft[this.config.timeframe] ?? "15m"}`, t = `${this.wsBase}/${e}`;
4456
4456
  this.setState("connecting");
4457
4457
  try {
4458
4458
  this.ws = new WebSocket(t);
@@ -4505,7 +4505,7 @@ var vt = class {
4505
4505
  for (let e of n) e(r);
4506
4506
  }
4507
4507
  }
4508
- }, At = class {
4508
+ }, Lt = class {
4509
4509
  name = "mock";
4510
4510
  state = "disconnected";
4511
4511
  listeners = /* @__PURE__ */ new Map();
@@ -4545,7 +4545,7 @@ var vt = class {
4545
4545
  this.disconnect(), this.listeners.clear();
4546
4546
  }
4547
4547
  generateHistory(e, t) {
4548
- let n = [], r = Date.now(), i = p(e), a = this.options.basePrice, o = this.options.volatility / 100;
4548
+ let n = [], r = Date.now(), i = g(e), a = this.options.basePrice, o = this.options.volatility / 100;
4549
4549
  for (let e = t - 1; e >= 0; e--) {
4550
4550
  let t = r - e * i, s = (Math.random() - .48) * a * o, c = a;
4551
4551
  a += s;
@@ -4568,7 +4568,7 @@ var vt = class {
4568
4568
  if (this.state !== "connected" || !this.config) return;
4569
4569
  let e = this.options.volatility / 100, t = (Math.random() - .48) * this.currentPrice * e * .3;
4570
4570
  this.currentPrice += t;
4571
- let n = Date.now(), r = p(this.config.timeframe), i = {
4571
+ let n = Date.now(), r = g(this.config.timeframe), i = {
4572
4572
  time: Math.floor(n / r) * r,
4573
4573
  open: this.currentPrice - t,
4574
4574
  high: Math.max(this.currentPrice, this.currentPrice - t) + Math.abs(t) * .2,
@@ -4600,7 +4600,7 @@ var vt = class {
4600
4600
  for (let e of n) e(r);
4601
4601
  }
4602
4602
  }
4603
- }, jt = {
4603
+ }, Rt = {
4604
4604
  visible: !0,
4605
4605
  showSymbol: !0,
4606
4606
  showOHLC: !0,
@@ -4608,8 +4608,8 @@ var vt = class {
4608
4608
  showVolume: !0,
4609
4609
  position: "top-left",
4610
4610
  fontSize: 12
4611
- }, Mt = class {
4612
- config = { ...jt };
4611
+ }, zt = class {
4612
+ config = { ...Rt };
4613
4613
  symbol = "";
4614
4614
  timeframe = "";
4615
4615
  hoverBar = null;
@@ -4696,7 +4696,7 @@ var vt = class {
4696
4696
  }
4697
4697
  }
4698
4698
  }
4699
- }, Nt = class {
4699
+ }, Bt = class {
4700
4700
  static toDataURL(e, t) {
4701
4701
  let n = e.querySelectorAll("canvas");
4702
4702
  if (n.length === 0) return "";
@@ -4718,7 +4718,7 @@ var vt = class {
4718
4718
  let i = document.createElement("a");
4719
4719
  i.href = r, i.download = t, document.body.appendChild(i), i.click(), document.body.removeChild(i);
4720
4720
  }
4721
- }, Pt = class {
4721
+ }, Vt = class {
4722
4722
  config = null;
4723
4723
  setConfig(e) {
4724
4724
  this.config = e;
@@ -4728,7 +4728,7 @@ var vt = class {
4728
4728
  let { chartRect: r } = t, i = this.config.fontSize ?? 48, a = this.config.color ?? n.textSecondary;
4729
4729
  e.save(), e.globalAlpha = .07, e.font = `bold ${i}px ${n.font.family}`, e.fillStyle = a, e.textAlign = "center", e.textBaseline = "middle", e.fillText(this.config.text, r.x + r.width / 2, r.y + r.height / 2), e.restore();
4730
4730
  }
4731
- }, Ft = class {
4731
+ }, Ht = class {
4732
4732
  visible = !0;
4733
4733
  timeframeMs = 0;
4734
4734
  setVisible(e) {
@@ -4744,14 +4744,14 @@ var vt = class {
4744
4744
  if (!this.visible || this.timeframeMs <= 0 || r.length === 0) return;
4745
4745
  let i = r[r.length - 1], a = (i.time > 0xe8d4a51000 ? i.time : i.time * 1e3) + this.timeframeMs - Date.now();
4746
4746
  if (a <= 0) return;
4747
- let o = this.formatRemaining(a), s = y(r.length - 1, t), c = t.chartRect.y + t.chartRect.height - 4;
4747
+ let o = this.formatRemaining(a), s = S(r.length - 1, t), c = t.chartRect.y + t.chartRect.height - 4;
4748
4748
  s < t.chartRect.x || s > t.chartRect.x + t.chartRect.width || (e.font = `${n.font.sizeSmall}px ${n.font.family}`, e.textBaseline = "bottom", e.textAlign = "center", e.fillStyle = n.textSecondary, e.fillText(o, s, c));
4749
4749
  }
4750
4750
  formatRemaining(e) {
4751
4751
  let t = Math.ceil(e / 1e3), n = Math.floor(t / 3600), r = Math.floor(t % 3600 / 60), i = t % 60;
4752
4752
  return n > 0 ? `${n}:${String(r).padStart(2, "0")}:${String(i).padStart(2, "0")}` : `${r}:${String(i).padStart(2, "0")}`;
4753
4753
  }
4754
- }, It = class {
4754
+ }, Ut = class {
4755
4755
  config = { visible: !1 };
4756
4756
  cachedBreaks = [];
4757
4757
  lastDataLength = 0;
@@ -4785,7 +4785,7 @@ var vt = class {
4785
4785
  let { chartRect: a } = t, o = this.config.color ?? n.axisLine, s = this.config.lineWidth ?? 1, c = this.config.lineStyle ?? "dashed";
4786
4786
  e.save(), e.strokeStyle = o, e.lineWidth = s, e.globalAlpha = .4, c === "dashed" ? e.setLineDash([6, 4]) : c === "dotted" && e.setLineDash([2, 3]), e.beginPath();
4787
4787
  for (let n of i) {
4788
- let r = y(n, t) - (t.barWidth + t.barSpacing) / 2;
4788
+ let r = S(n, t) - (t.barWidth + t.barSpacing) / 2;
4789
4789
  if (r < a.x - 1 || r > a.x + a.width + 1) continue;
4790
4790
  let i = Math.round(r) + .5;
4791
4791
  e.moveTo(i, a.y), e.lineTo(i, a.y + a.height);
@@ -4795,7 +4795,7 @@ var vt = class {
4795
4795
  invalidateCache() {
4796
4796
  this.lastDataLength = 0, this.cachedBreaks = [];
4797
4797
  }
4798
- }, Lt = 1, Rt = class extends Z {
4798
+ }, Wt = 1, Gt = class extends q {
4799
4799
  alerts = [];
4800
4800
  lastPrice = null;
4801
4801
  requestRender = null;
@@ -4807,7 +4807,7 @@ var vt = class {
4807
4807
  this.pricePrecision = e;
4808
4808
  }
4809
4809
  addAlert(e, t = "crossing", n, r = !1) {
4810
- let i = `tc_alert_${Lt++}`, a = {
4810
+ let i = `tc_alert_${Wt++}`, a = {
4811
4811
  id: i,
4812
4812
  price: e,
4813
4813
  condition: t,
@@ -4879,7 +4879,7 @@ var vt = class {
4879
4879
  render(e, t, n) {
4880
4880
  let { chartRect: r } = t;
4881
4881
  for (let i of this.alerts) {
4882
- let a = b(i.price, t);
4882
+ let a = C(i.price, t);
4883
4883
  if (a < r.y || a > r.y + r.height) continue;
4884
4884
  let o = i.triggered ? "#FF9800" : "#FFD700";
4885
4885
  e.setLineDash([2, 6]), e.strokeStyle = o, e.lineWidth = 1, e.beginPath(), e.moveTo(r.x, Math.round(a) + .5), e.lineTo(r.x + r.width, Math.round(a) + .5), e.stroke(), e.setLineDash([]), e.font = `10px ${n.font.family}`, e.fillStyle = o, e.textBaseline = "bottom", e.textAlign = "right";
@@ -4887,7 +4887,7 @@ var vt = class {
4887
4887
  e.fillText(s, r.x + r.width - 4, a - 2);
4888
4888
  }
4889
4889
  }
4890
- }, zt = class extends Z {
4890
+ }, Kt = class extends q {
4891
4891
  data = [];
4892
4892
  currentIndex = 0;
4893
4893
  timer = null;
@@ -4941,10 +4941,10 @@ var vt = class {
4941
4941
  dispose() {
4942
4942
  this.stop(), this.removeAllListeners(), this.data = [];
4943
4943
  }
4944
- }, $ = 1, Bt = class {
4944
+ }, Y = 1, qt = class {
4945
4945
  static capture(e, t) {
4946
4946
  return {
4947
- version: $,
4947
+ version: Y,
4948
4948
  timestamp: Date.now(),
4949
4949
  chartType: t?.chartType ?? "candlestick",
4950
4950
  symbol: t?.symbol,
@@ -4967,7 +4967,7 @@ var vt = class {
4967
4967
  }
4968
4968
  static deserialize(e) {
4969
4969
  let t = JSON.parse(e);
4970
- return t.version !== $ && console.warn(`Chart state version mismatch: ${t.version} vs ${$}`), t;
4970
+ return t.version !== Y && console.warn(`Chart state version mismatch: ${t.version} vs ${Y}`), t;
4971
4971
  }
4972
4972
  static saveToStorage(e, t) {
4973
4973
  localStorage.setItem(e, this.serialize(t));
@@ -4994,7 +4994,7 @@ var vt = class {
4994
4994
  }, n.click();
4995
4995
  });
4996
4996
  }
4997
- }, Vt = class {
4997
+ }, Jt = class {
4998
4998
  undoStack = [];
4999
4999
  redoStack = [];
5000
5000
  maxHistory = 50;
@@ -5030,7 +5030,7 @@ var vt = class {
5030
5030
  redoCount: this.redoStack.length
5031
5031
  };
5032
5032
  }
5033
- }, Ht = class {
5033
+ }, Yt = class {
5034
5034
  static toCSV(e) {
5035
5035
  return ["Time,Open,High,Low,Close,Volume", ...e.map((e) => `${new Date(e.time).toISOString()},${e.open},${e.high},${e.low},${e.close},${e.volume}`)].join("\n");
5036
5036
  }
@@ -5048,7 +5048,7 @@ var vt = class {
5048
5048
  let r = new Blob([e], { type: n }), i = URL.createObjectURL(r), a = document.createElement("a");
5049
5049
  a.href = i, a.download = t, document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
5050
5050
  }
5051
- }, Ut = {
5051
+ }, Xt = {
5052
5052
  linear: (e) => e,
5053
5053
  easeOutCubic: (e) => 1 - (1 - e) ** 3,
5054
5054
  easeOutQuart: (e) => 1 - (1 - e) ** 4,
@@ -5056,7 +5056,7 @@ var vt = class {
5056
5056
  easeOutExpo: (e) => e === 1 ? 1 : 1 - 2 ** (-10 * e),
5057
5057
  easeOutElastic: (e) => e === 0 || e === 1 ? e : 2 ** (-10 * e) * Math.sin((e * 10 - .75) * (2 * Math.PI / 3)) + 1,
5058
5058
  spring: (e) => 1 - Math.E ** (-6 * e) * Math.cos(8 * e)
5059
- }, Wt = class {
5059
+ }, Zt = class {
5060
5060
  animations = /* @__PURE__ */ new Map();
5061
5061
  frameId = 0;
5062
5062
  running = !1;
@@ -5064,7 +5064,7 @@ var vt = class {
5064
5064
  this.animations.set(e, {
5065
5065
  startTime: -1,
5066
5066
  duration: t.duration,
5067
- easing: t.easing ?? Ut.easeOutCubic,
5067
+ easing: t.easing ?? Xt.easeOutCubic,
5068
5068
  onUpdate: t.onUpdate,
5069
5069
  onComplete: t.onComplete
5070
5070
  }), this.running || (this.running = !0, this.tick());
@@ -5098,6 +5098,505 @@ var vt = class {
5098
5098
  }
5099
5099
  };
5100
5100
  //#endregion
5101
- export { I as ADXIndicator, F as ATRIndicator, Te as AccumulationDistributionIndicator, Rt as AlertManager, ht as AnchoredVWAPTool, Wt as Animator, ee as AreaRenderer, V as AroonIndicator, dt as ArrowTool, Ft as BarCountdown, te as BarRenderer, re as BaselineRenderer, kt as BinanceAdapter, ye as BollingerBandsIndicator, z as CCIIndicator, W as CMFIndicator, D as CandlestickRenderer, h as CanvasLayer, Mt as ChartLegend, Bt as ChartStateManager, ce as CompareRenderer, Le as CrosshairHandler, ze as CrosshairTooltip, Et as CurrentPriceLine, jt as DEFAULT_LEGEND_CONFIG, v as DPRManager, Ht as DataExporter, ct as DateRangeTool, bt as DepthOverlay, j as DonchianChannelIndicator, q as DrawingBase, We as DrawingManager, Ge as DrawingRenderer, ve as EMAIndicator, Ut as Easing, ot as ElliottWaveTool, nt as EllipseTool, Z as Emitter, He as EventBus, Xe as ExtendedLineTool, et as FibExtensionTool, Qe as FibRetracementTool, mt as GannBoxTool, pt as GannFanTool, Oe as GridRenderer, ne as HollowCandleRenderer, qe as HorizontalLineTool, xe as IchimokuIndicator, k as IndicatorBase, ge as IndicatorEngine, Pe as InteractionManager, ae as KagiRenderer, A as KeltnerChannelIndicator, Re as KeyboardHandler, g as LayerManager, O as LineRenderer, N as MACDIndicator, B as MFIIndicator, lt as MeasureTool, At as MockAdapter, L as OBVIndicator, vt as OrderRenderer, Fe as PanHandler, Se as ParabolicSARIndicator, Ze as ParallelChannelTool, it as PitchforkTool, oe as PointAndFigureRenderer, yt as PositionRenderer, ke as PriceAxis, st as PriceRangeTool, H as ROCIndicator, M as RSIIndicator, Ye as RayTool, Q as ReconnectManager, tt as RectangleTool, J as RegressionChannelTool, w as RenderEngine, _ as RenderLoop, ie as RenkoRenderer, zt as ReplayManager, _e as SMAIndicator, Nt as Screenshot, It as SessionBreaks, G as StdDevIndicator, P as StochasticIndicator, Dt as StreamManager, Ce as SupertrendIndicator, U as TSIIndicator, ut as TextAnnotationTool, Tt as TickAggregator, Ne as TimeAxis, St as TradingContextMenu, xt as TradingDragHandler, Ct as TradingManager, wt as TradingRenderer, Ke as TrendLineTool, rt as TriangleTool, Vt as UndoRedoManager, Ee as VROCIndicator, be as VWAPIndicator, Je as VerticalLineTool, T as Viewport, we as VolumeProfileIndicator, gt as VolumeProfileRangeTool, se as VolumeRenderer, Pt as Watermark, R as WilliamsRIndicator, Ie as ZoomHandler, y as barIndexToX, E as getVisibleData, b as priceToY, _t as registerBuiltInDrawingTools, De as registerBuiltInIndicators, C as timestampToBarIndex, le as toHeikinAshi, pe as toKagi, fe as toLineBreak, me as toPointAndFigure, ue as toRenko, x as xToBarIndex, S as yToPrice };
5101
+ //#region src/finance/BaseFinanceChart.ts
5102
+ function Qt(t) {
5103
+ return !t || t === "dark" ? e : t === "light" ? o : t;
5104
+ }
5105
+ var $t = class {
5106
+ canvas;
5107
+ ctx;
5108
+ container;
5109
+ theme;
5110
+ width = 0;
5111
+ height = 0;
5112
+ dpr = 1;
5113
+ frameId = null;
5114
+ resizeObserver;
5115
+ constructor(e, t) {
5116
+ this.container = e, this.theme = Qt(t), this.canvas = document.createElement("canvas"), this.canvas.style.width = "100%", this.canvas.style.height = "100%", this.canvas.style.display = "block", e.appendChild(this.canvas), this.ctx = this.canvas.getContext("2d"), this.dpr = window.devicePixelRatio || 1, this.updateSize(), this.resizeObserver = new ResizeObserver(() => {
5117
+ this.updateSize(), this.requestRender();
5118
+ }), this.resizeObserver.observe(e);
5119
+ }
5120
+ updateSize() {
5121
+ this.dpr = window.devicePixelRatio || 1, this.width = this.container.clientWidth, this.height = this.container.clientHeight, this.canvas.width = this.width * this.dpr, this.canvas.height = this.height * this.dpr;
5122
+ }
5123
+ requestRender() {
5124
+ this.frameId === null && (this.frameId = requestAnimationFrame(() => {
5125
+ this.frameId = null, (this.width === 0 || this.height === 0) && this.updateSize(), !(this.width === 0 || this.height === 0) && (this.ctx.save(), this.ctx.scale(this.dpr, this.dpr), this.ctx.clearRect(0, 0, this.width, this.height), this.renderChart(this.ctx, this.width, this.height, this.theme), this.ctx.restore());
5126
+ }));
5127
+ }
5128
+ setTheme(e) {
5129
+ this.theme = Qt(e), this.requestRender();
5130
+ }
5131
+ destroy() {
5132
+ this.frameId !== null && cancelAnimationFrame(this.frameId), this.resizeObserver.disconnect(), this.canvas.remove();
5133
+ }
5134
+ }, en = class {
5135
+ pos = null;
5136
+ canvas;
5137
+ onUpdate;
5138
+ handleMove;
5139
+ handleLeave;
5140
+ constructor(e, t) {
5141
+ this.canvas = e, this.onUpdate = t, this.handleMove = (t) => {
5142
+ let n = e.getBoundingClientRect();
5143
+ this.pos = {
5144
+ x: t.clientX - n.left,
5145
+ y: t.clientY - n.top
5146
+ }, this.onUpdate();
5147
+ }, this.handleLeave = () => {
5148
+ this.pos = null, this.onUpdate();
5149
+ }, e.addEventListener("pointermove", this.handleMove), e.addEventListener("pointerleave", this.handleLeave);
5150
+ }
5151
+ getPosition() {
5152
+ return this.pos;
5153
+ }
5154
+ isActive() {
5155
+ return this.pos !== null;
5156
+ }
5157
+ drawCrosshair(e, t, n, r) {
5158
+ this.pos && (e.save(), e.strokeStyle = r, e.lineWidth = .5, e.setLineDash([4, 4]), e.beginPath(), e.moveTo(this.pos.x, 0), e.lineTo(this.pos.x, n), e.stroke(), e.beginPath(), e.moveTo(0, this.pos.y), e.lineTo(t, this.pos.y), e.stroke(), e.restore());
5159
+ }
5160
+ destroy() {
5161
+ this.canvas.removeEventListener("pointermove", this.handleMove), this.canvas.removeEventListener("pointerleave", this.handleLeave);
5162
+ }
5163
+ };
5164
+ //#endregion
5165
+ //#region src/finance/SparklineRenderer.ts
5166
+ function tn(e, t, n, r, i) {
5167
+ let { data: a, mode: o = "area", lineWidth: s = 1.5, showLastPoint: c = !1, showMinMax: l = !1 } = r;
5168
+ if (a.length < 2 || t <= 0 || n <= 0) return;
5169
+ let u = r.color ?? i.lineColor, d = r.fillColor ?? u, f = t - 4, p = n - 4, m = Infinity, h = -Infinity, g = 0, _ = 0;
5170
+ for (let e = 0; e < a.length; e++) a[e] < m && (m = a[e], g = e), a[e] > h && (h = a[e], _ = e);
5171
+ let v = h - m || 1, y = (e) => 2 + e / (a.length - 1) * f, b = (e) => 2 + p - (e - m) / v * p;
5172
+ if (o === "area") {
5173
+ let t = e.createLinearGradient(0, 2, 0, n - 2);
5174
+ t.addColorStop(0, d + (d.startsWith("#") ? "40" : "")), t.addColorStop(1, "transparent"), e.beginPath(), e.moveTo(y(0), b(a[0]));
5175
+ for (let t = 1; t < a.length; t++) e.lineTo(y(t), b(a[t]));
5176
+ e.lineTo(y(a.length - 1), n - 2), e.lineTo(y(0), n - 2), e.closePath(), e.fillStyle = t, e.fill();
5177
+ }
5178
+ e.beginPath(), e.moveTo(y(0), b(a[0]));
5179
+ for (let t = 1; t < a.length; t++) e.lineTo(y(t), b(a[t]));
5180
+ if (e.strokeStyle = u, e.lineWidth = s, e.lineJoin = "round", e.stroke(), c) {
5181
+ let t = r.lastPointColor ?? u, n = y(a.length - 1), i = b(a[a.length - 1]);
5182
+ e.beginPath(), e.arc(n, i, 3, 0, Math.PI * 2), e.fillStyle = t, e.fill();
5183
+ }
5184
+ if (l) {
5185
+ let t = r.minPointColor ?? i.candleDown, n = r.maxPointColor ?? i.candleUp;
5186
+ e.beginPath(), e.arc(y(g), b(m), 2.5, 0, Math.PI * 2), e.fillStyle = t, e.fill(), e.beginPath(), e.arc(y(_), b(h), 2.5, 0, Math.PI * 2), e.fillStyle = n, e.fill();
5187
+ }
5188
+ }
5189
+ //#endregion
5190
+ //#region src/finance/DepthChartRenderer.ts
5191
+ var nn = 50, rn = 60, X = 20, an = .2;
5192
+ function on(e) {
5193
+ let t = [...e].sort((e, t) => t.price - e.price), n = [], r = 0;
5194
+ for (let e of t) r += e.volume, n.push({
5195
+ price: e.price,
5196
+ cumulativeVolume: r
5197
+ });
5198
+ return n;
5199
+ }
5200
+ function sn(e) {
5201
+ let t = [...e].sort((e, t) => e.price - t.price), n = [], r = 0;
5202
+ for (let e of t) r += e.volume, n.push({
5203
+ price: e.price,
5204
+ cumulativeVolume: r
5205
+ });
5206
+ return n;
5207
+ }
5208
+ function cn(e, t) {
5209
+ return {
5210
+ left: nn,
5211
+ right: e - rn,
5212
+ top: X,
5213
+ bottom: t - X,
5214
+ plotWidth: e - nn - rn,
5215
+ plotHeight: t - X * 2
5216
+ };
5217
+ }
5218
+ function ln(e, t, n, r) {
5219
+ e.fillStyle = r, e.fillRect(0, 0, t, n);
5220
+ }
5221
+ function un(e, t, n, r, i, a, o, s) {
5222
+ let { left: c, right: l, top: u, bottom: d, plotWidth: p, plotHeight: m } = t;
5223
+ e.save(), e.strokeStyle = a.grid, e.lineWidth = .5, e.fillStyle = a.axisLabel, e.font = `${a.font.sizeSmall}px ${a.font.family}`;
5224
+ let h = f(0, i, 5);
5225
+ for (let t = 0; t <= i; t += h) {
5226
+ let n = d - t / i * m;
5227
+ e.beginPath(), e.moveTo(c, n), e.lineTo(l, n), e.stroke(), e.textAlign = "right", e.textBaseline = "middle", e.fillText(s(t), c - 4, n);
5228
+ }
5229
+ let g = r - n, _ = f(n, r, 6), v = Math.ceil(n / _) * _;
5230
+ for (let t = v; t <= r; t += _) {
5231
+ let r = c + (t - n) / g * p;
5232
+ e.beginPath(), e.moveTo(r, u), e.lineTo(r, d), e.stroke(), e.textAlign = "center", e.textBaseline = "top", e.fillText(o(t), r, d + 4);
5233
+ }
5234
+ e.restore();
5235
+ }
5236
+ function dn(e, t, n, r, i, a, o, s, c) {
5237
+ if (t.length === 0) return;
5238
+ let { left: l, bottom: u, plotWidth: d, plotHeight: f } = n, p = (e) => l + (e - r) / i * d, m = (e) => u - e / a * f;
5239
+ if (e.beginPath(), c === "bid") {
5240
+ e.moveTo(p(t[0].price), u);
5241
+ for (let n = 0; n < t.length; n++) {
5242
+ let r = p(t[n].price), i = m(t[n].cumulativeVolume);
5243
+ e.lineTo(r, i), n < t.length - 1 && e.lineTo(p(t[n + 1].price), i);
5244
+ }
5245
+ e.lineTo(p(t[t.length - 1].price), u);
5246
+ } else {
5247
+ e.moveTo(p(t[0].price), u);
5248
+ for (let n = 0; n < t.length; n++) {
5249
+ let r = p(t[n].price), i = m(t[n].cumulativeVolume);
5250
+ e.lineTo(r, i), n < t.length - 1 && e.lineTo(p(t[n + 1].price), i);
5251
+ }
5252
+ e.lineTo(p(t[t.length - 1].price), u);
5253
+ }
5254
+ if (e.closePath(), e.fillStyle = o, e.fill(), e.beginPath(), c === "bid") {
5255
+ e.moveTo(p(t[0].price), m(t[0].cumulativeVolume));
5256
+ for (let n = 0; n < t.length; n++) {
5257
+ let r = p(t[n].price), i = m(t[n].cumulativeVolume);
5258
+ n > 0 && e.lineTo(r, m(t[n - 1].cumulativeVolume)), e.lineTo(r, i);
5259
+ }
5260
+ } else {
5261
+ e.moveTo(p(t[0].price), m(t[0].cumulativeVolume));
5262
+ for (let n = 1; n < t.length; n++) {
5263
+ let r = m(t[n - 1].cumulativeVolume), i = p(t[n].price), a = m(t[n].cumulativeVolume);
5264
+ e.lineTo(i, r), e.lineTo(i, a);
5265
+ }
5266
+ }
5267
+ e.strokeStyle = s, e.lineWidth = 1.5, e.stroke();
5268
+ }
5269
+ function fn(e, t, n, r, i, a, o, s, c) {
5270
+ let { left: l, top: u, bottom: d, plotWidth: f } = r, p = l + (t - i) / a * f;
5271
+ if (e.save(), e.strokeStyle = o.textSecondary, e.lineWidth = 1, e.setLineDash([4, 4]), e.beginPath(), e.moveTo(p, u), e.lineTo(p, d), e.stroke(), e.restore(), s) {
5272
+ let t = `Spread: ${c(n)}`;
5273
+ e.save(), e.font = `${o.font.sizeSmall}px ${o.font.family}`, e.fillStyle = o.textSecondary, e.textAlign = "center", e.textBaseline = "bottom", e.fillText(t, p, u - 2), e.restore();
5274
+ }
5275
+ }
5276
+ function pn(e, t, n, r, i, a, o, s, c, l, u) {
5277
+ let { left: d, top: f, bottom: p, plotWidth: m, plotHeight: h } = i, g = t.x;
5278
+ if (g < d || g > i.right) return;
5279
+ let _ = a + (g - d) / m * o, v = 0, y = "";
5280
+ if (n.length > 0 && _ <= n[0].price) {
5281
+ y = "Bid";
5282
+ for (let e of n) if (_ <= e.price) v = e.cumulativeVolume;
5283
+ else break;
5284
+ }
5285
+ if (r.length > 0 && _ >= r[0].price) {
5286
+ y = "Ask";
5287
+ for (let e of r) if (_ >= e.price) v = e.cumulativeVolume;
5288
+ else break;
5289
+ }
5290
+ if (e.save(), e.strokeStyle = c.crosshair, e.lineWidth = .5, e.setLineDash([4, 4]), e.beginPath(), e.moveTo(g, f), e.lineTo(g, p), e.stroke(), v > 0) {
5291
+ let t = p - v / s * h;
5292
+ e.beginPath(), e.moveTo(d, t), e.lineTo(i.right, t), e.stroke();
5293
+ }
5294
+ e.restore();
5295
+ let b = [`Price: ${l(_)}`, y ? `${y} Vol: ${u(v)}` : ""].filter(Boolean);
5296
+ e.save(), e.font = `${c.font.sizeSmall}px ${c.font.family}`;
5297
+ let x = Math.max(...b.map((t) => e.measureText(t).width)) + 16, S = b.length * (c.font.sizeSmall + 4) + 12, C = g + 10, w = t.y - S / 2;
5298
+ C + x > i.right && (C = g - x - 10), w < f && (w = f), w + S > p && (w = p - S), e.fillStyle = c.axisLabelBackground, e.globalAlpha = .9, e.fillRect(C, w, x, S), e.globalAlpha = 1, e.fillStyle = c.text, e.textBaseline = "top", e.textAlign = "left";
5299
+ for (let t = 0; t < b.length; t++) e.fillText(b[t], C + 8, w + 6 + t * (c.font.sizeSmall + 4));
5300
+ e.restore();
5301
+ }
5302
+ function mn(e) {
5303
+ return e.toFixed(2);
5304
+ }
5305
+ function hn(e) {
5306
+ return e >= 1e6 ? (e / 1e6).toFixed(2) + "M" : e >= 1e3 ? (e / 1e3).toFixed(1) + "K" : e.toFixed(0);
5307
+ }
5308
+ function gn(e, t, n, r, i, a) {
5309
+ let { data: o } = r;
5310
+ if (o.bids.length === 0 && o.asks.length === 0 || t <= 0 || n <= 0) return;
5311
+ let s = r.bidColor ?? i.candleUp, c = r.askColor ?? i.candleDown, l = r.bidFillColor ?? s + "40", u = r.askFillColor ?? c + "40", d = r.midPriceLine !== !1, f = r.spreadLabel !== !1, p = r.priceFormat ?? mn, m = r.volumeFormat ?? hn, h = on(o.bids), g = sn(o.asks), _ = h.length > 0 ? h[0].price : 0, v = g.length > 0 ? g[0].price : 0, y = h.length > 0 && g.length > 0 ? (_ + v) / 2 : _ || v, b = g.length > 0 && h.length > 0 ? v - _ : 0, x = h.length > 0 ? h[h.length - 1].price : y, S = g.length > 0 ? g[g.length - 1].price : y, C = Math.max(y - x, S - y) * (1 + an), w = y - C, T = y + C, E = T - w, D = h.length > 0 ? h[h.length - 1].cumulativeVolume : 0, O = g.length > 0 ? g[g.length - 1].cumulativeVolume : 0, k = Math.max(D, O) || 1, A = cn(t, n);
5312
+ ln(e, t, n, i.background), un(e, A, w, T, k, i, p, m), dn(e, h, A, w, E, k, l, s, "bid"), dn(e, g, A, w, E, k, u, c, "ask"), d && fn(e, y, b, A, w, E, i, f, p), a && pn(e, a, h, g, A, w, E, k, i, p, m);
5313
+ }
5314
+ //#endregion
5315
+ //#region src/finance/EquityCurveRenderer.ts
5316
+ var _n = 70, vn = 30, yn = 20, bn = 20, xn = .05;
5317
+ function Sn(e, t) {
5318
+ return {
5319
+ left: _n,
5320
+ right: e - yn,
5321
+ top: bn,
5322
+ bottom: t - vn,
5323
+ plotWidth: e - _n - yn,
5324
+ plotHeight: t - bn - vn
5325
+ };
5326
+ }
5327
+ function Cn(e, t) {
5328
+ let n = Infinity, r = -Infinity;
5329
+ for (let t of e) t.value < n && (n = t.value), t.value > r && (r = t.value);
5330
+ if (t) for (let e of t) e.value < n && (n = e.value), e.value > r && (r = e.value);
5331
+ let i = (r - n) * xn;
5332
+ return {
5333
+ valMin: n - i,
5334
+ valMax: r + i
5335
+ };
5336
+ }
5337
+ function wn(e) {
5338
+ let t = [], n = -Infinity;
5339
+ for (let r of e) r.value > n && (n = r.value), t.push(n);
5340
+ return t;
5341
+ }
5342
+ function Tn(e) {
5343
+ let t = 864e5;
5344
+ if (365.25 * t, e < 7 * t) {
5345
+ let e = new Intl.DateTimeFormat(void 0, {
5346
+ hour: "2-digit",
5347
+ minute: "2-digit"
5348
+ });
5349
+ return (t) => e.format(new Date(t));
5350
+ }
5351
+ if (e < 315576e5) {
5352
+ let e = new Intl.DateTimeFormat(void 0, {
5353
+ month: "short",
5354
+ day: "numeric"
5355
+ });
5356
+ return (t) => e.format(new Date(t));
5357
+ }
5358
+ let n = new Intl.DateTimeFormat(void 0, {
5359
+ month: "short",
5360
+ year: "numeric"
5361
+ });
5362
+ return (e) => n.format(new Date(e));
5363
+ }
5364
+ function En(e) {
5365
+ return Math.abs(e) >= 1e6 ? (e / 1e6).toFixed(2) + "M" : Math.abs(e) >= 1e3 ? (e / 1e3).toFixed(1) + "K" : e.toFixed(2);
5366
+ }
5367
+ function Dn(e, t, n, r) {
5368
+ e.fillStyle = r, e.fillRect(0, 0, t, n);
5369
+ }
5370
+ function On(e, t, n, r, i, a, o, s, c) {
5371
+ let { left: l, right: u, top: d, bottom: p, plotWidth: m, plotHeight: h } = t;
5372
+ e.save(), e.strokeStyle = o.grid, e.lineWidth = .5, e.fillStyle = o.axisLabel, e.font = `${o.font.sizeSmall}px ${o.font.family}`;
5373
+ let g = f(n, r, 6), _ = Math.ceil(n / g) * g;
5374
+ for (let t = _; t <= r; t += g) {
5375
+ let i = p - (t - n) / (r - n) * h;
5376
+ e.beginPath(), e.moveTo(l, i), e.lineTo(u, i), e.stroke(), e.textAlign = "right", e.textBaseline = "middle", e.fillText(s(t), l - 6, i);
5377
+ }
5378
+ let v = a - i, y = f(i, a, 6), b = Math.ceil(i / y) * y;
5379
+ for (let t = b; t <= a; t += y) {
5380
+ let n = l + (t - i) / v * m;
5381
+ e.beginPath(), e.moveTo(n, d), e.lineTo(n, p), e.stroke(), e.textAlign = "center", e.textBaseline = "top", e.fillText(c(t), n, p + 4);
5382
+ }
5383
+ e.restore();
5384
+ }
5385
+ function Z(e, t, n, r, i, a, o, s, c) {
5386
+ if (t.length < 2) return;
5387
+ let { left: l, bottom: u, plotWidth: d, plotHeight: f } = n, p = (e) => l + (e - r) / i * d, m = (e) => u - (e - a) / o * f;
5388
+ e.save(), e.beginPath(), e.moveTo(p(t[0].time), m(t[0].value));
5389
+ for (let n = 1; n < t.length; n++) e.lineTo(p(t[n].time), m(t[n].value));
5390
+ e.strokeStyle = s, e.lineWidth = c, e.lineJoin = "round", e.stroke(), e.restore();
5391
+ }
5392
+ function kn(e, t, n, r, i, a, o, s) {
5393
+ if (t.length < 2) return;
5394
+ let { left: c, bottom: l, plotWidth: u, plotHeight: d } = n, f = (e) => c + (e - r) / i * u, p = (e) => l - (e - a) / o * d, m = e.createLinearGradient(0, n.top, 0, l);
5395
+ m.addColorStop(0, s + "40"), m.addColorStop(1, "transparent"), e.save(), e.beginPath(), e.moveTo(f(t[0].time), p(t[0].value));
5396
+ for (let n = 1; n < t.length; n++) e.lineTo(f(t[n].time), p(t[n].value));
5397
+ e.lineTo(f(t[t.length - 1].time), l), e.lineTo(f(t[0].time), l), e.closePath(), e.fillStyle = m, e.fill(), e.restore();
5398
+ }
5399
+ function An(e, t, n, r, i, a, o, s, c) {
5400
+ if (t.length < 2) return;
5401
+ let { left: l, bottom: u, plotWidth: d, plotHeight: f } = r, p = (e) => l + (e - i) / a * d, m = (e) => u - (e - o) / s * f;
5402
+ e.save(), e.fillStyle = c, e.beginPath(), e.moveTo(p(t[0].time), m(n[0]));
5403
+ for (let r = 1; r < t.length; r++) e.lineTo(p(t[r].time), m(n[r]));
5404
+ for (let n = t.length - 1; n >= 0; n--) e.lineTo(p(t[n].time), m(t[n].value));
5405
+ e.closePath(), e.fill(), e.restore();
5406
+ }
5407
+ function jn(e, t, n, r, i, a, o, s, c, l) {
5408
+ if (t.length === 0) return;
5409
+ let { left: u, bottom: d, plotWidth: f, plotHeight: p } = n, m = t[t.length - 1], h = u + (m.time - r) / i * f, g = d - (m.value - a) / o * p;
5410
+ e.save(), e.font = `${l.font.sizeSmall}px ${l.font.family}`, e.fillStyle = c, e.textAlign = "left", e.textBaseline = "middle", e.fillText(s, h + 4, g), e.restore();
5411
+ }
5412
+ function Mn(e, t, n, r, i, a, o, s, c, l, u, d) {
5413
+ let { left: f, top: p, bottom: m, plotWidth: h, plotHeight: g } = i, _ = t.x;
5414
+ if (_ < f || _ > i.right) return;
5415
+ e.save(), e.strokeStyle = l.crosshair, e.lineWidth = .5, e.setLineDash([4, 4]), e.beginPath(), e.moveTo(_, p), e.lineTo(_, m), e.stroke(), e.restore();
5416
+ let v = a + (_ - f) / h * o, y = 0, b = Infinity;
5417
+ for (let e = 0; e < n.length; e++) {
5418
+ let t = Math.abs(n[e].time - v);
5419
+ t < b && (b = t, y = e);
5420
+ }
5421
+ let x = n[y], S = [u(x.time), `Value: ${d(x.value)}`];
5422
+ r && r.length > y && S.push(`Benchmark: ${d(r[y].value)}`);
5423
+ let C = f + (x.time - a) / o * h, w = m - (x.value - s) / c * g;
5424
+ e.beginPath(), e.arc(C, w, 3, 0, Math.PI * 2), e.fillStyle = l.lineColor, e.fill(), e.save(), e.font = `${l.font.sizeSmall}px ${l.font.family}`;
5425
+ let T = Math.max(...S.map((t) => e.measureText(t).width)) + 16, E = S.length * (l.font.sizeSmall + 4) + 12, D = _ + 10, O = t.y - E / 2;
5426
+ D + T > i.right && (D = _ - T - 10), O < p && (O = p), O + E > m && (O = m - E), e.fillStyle = l.axisLabelBackground, e.globalAlpha = .9, e.fillRect(D, O, T, E), e.globalAlpha = 1, e.fillStyle = l.text, e.textBaseline = "top", e.textAlign = "left";
5427
+ for (let t = 0; t < S.length; t++) e.fillText(S[t], D + 8, O + 6 + t * (l.font.sizeSmall + 4));
5428
+ e.restore();
5429
+ }
5430
+ function Nn(e, t, n, r, i, a) {
5431
+ let { data: o } = r;
5432
+ if (o.length < 2 || t <= 0 || n <= 0) return;
5433
+ let s = r.lineColor ?? i.lineColor, c = r.lineWidth ?? 1.5, l = r.drawdown === !0, u = r.drawdownColor ?? i.candleDown + "30", d = r.fillArea === !0, f = r.benchmark, p = r.benchmarkColor ?? i.textSecondary, m = r.benchmarkLabel ?? "Benchmark", h = r.valueFormat ?? En, { valMin: g, valMax: _ } = Cn(o, f), v = _ - g || 1, y = o[0].time, b = o[o.length - 1].time, x = b - y || 1, S = r.timeFormat ?? Tn(x), C = Sn(t, n);
5434
+ Dn(e, t, n, i.background), On(e, C, g, _, y, b, i, h, S), l && An(e, o, wn(o), C, y, x, g, v, u), d && kn(e, o, C, y, x, g, v, s), Z(e, o, C, y, x, g, v, s, c), f && f.length >= 2 && (Z(e, f, C, y, x, g, v, p, 1), jn(e, f, C, y, x, g, v, m, p, i)), a && Mn(e, a, o, f, C, y, x, g, v, i, S, h);
5435
+ }
5436
+ //#endregion
5437
+ //#region src/finance/HeatmapLayout.ts
5438
+ function Pn(e, t, n) {
5439
+ if (e.length === 0) return [];
5440
+ let r = e.length, i = Math.ceil(Math.sqrt(r)), a = Math.ceil(r / i), o = t.width / i, s = t.height / a, c = [];
5441
+ for (let a = 0; a < r; a++) {
5442
+ let r = a % i, l = Math.floor(a / i);
5443
+ c.push({
5444
+ id: e[a].id,
5445
+ rect: {
5446
+ x: t.x + r * o + n,
5447
+ y: t.y + l * s + n,
5448
+ width: Math.max(0, o - n * 2),
5449
+ height: Math.max(0, s - n * 2)
5450
+ }
5451
+ });
5452
+ }
5453
+ return c;
5454
+ }
5455
+ function Fn(e, t) {
5456
+ let n = e.reduce((e, t) => e + t, 0);
5457
+ if (n === 0 || t === 0) return Infinity;
5458
+ let r = 0;
5459
+ for (let i of e) {
5460
+ let e = n / t, a = i / e, o = e > a ? e / a : a / e;
5461
+ o > r && (r = o);
5462
+ }
5463
+ return r;
5464
+ }
5465
+ function Q(e, t, n, r, i, a) {
5466
+ let o = r ? n.height : n.width, s = e.reduce((e, t) => e + t, 0), c = o > 0 ? s / o : 0, l = 0;
5467
+ for (let o = 0; o < e.length; o++) {
5468
+ let s = c > 0 ? e[o] / c : 0, u;
5469
+ u = r ? {
5470
+ x: n.x + i,
5471
+ y: n.y + l + i,
5472
+ width: Math.max(0, c - i * 2),
5473
+ height: Math.max(0, s - i * 2)
5474
+ } : {
5475
+ x: n.x + l + i,
5476
+ y: n.y + i,
5477
+ width: Math.max(0, s - i * 2),
5478
+ height: Math.max(0, c - i * 2)
5479
+ }, a.push({
5480
+ id: t[o],
5481
+ rect: u
5482
+ }), l += s;
5483
+ }
5484
+ }
5485
+ function In(e, t, n, r, i) {
5486
+ if (e.length === 0) return;
5487
+ let a = n.width >= n.height, o = a ? n.height : n.width;
5488
+ if (e.length === 1) {
5489
+ Q(e, t, n, a, r, i);
5490
+ return;
5491
+ }
5492
+ let s = [], c = [], l = 0;
5493
+ for (; l < e.length;) {
5494
+ let u = [...s, e[l]];
5495
+ if (s.length === 0 || Fn(u, o) <= Fn(s, o)) s.push(e[l]), c.push(t[l]), l++;
5496
+ else {
5497
+ Q(s, c, n, a, r, i);
5498
+ let u = s.reduce((e, t) => e + t, 0), d = o > 0 ? u / o : 0;
5499
+ n = a ? {
5500
+ x: n.x + d,
5501
+ y: n.y,
5502
+ width: n.width - d,
5503
+ height: n.height
5504
+ } : {
5505
+ x: n.x,
5506
+ y: n.y + d,
5507
+ width: n.width,
5508
+ height: n.height - d
5509
+ }, In(e.slice(l), t.slice(l), n, r, i);
5510
+ return;
5511
+ }
5512
+ }
5513
+ s.length > 0 && Q(s, c, n, a, r, i);
5514
+ }
5515
+ function Ln(e, t, n) {
5516
+ if (e.length === 0) return [];
5517
+ let r = [...e].sort((e, t) => t.weight - e.weight), i = r.reduce((e, t) => e + Math.max(0, t.weight), 0);
5518
+ if (i === 0) return [];
5519
+ let a = t.width * t.height, o = r.map((e) => Math.max(0, e.weight) / i * a), s = r.map((e) => e.id), c = [];
5520
+ return In(o, s, { ...t }, n, c), c;
5521
+ }
5522
+ //#endregion
5523
+ //#region src/finance/HeatmapRenderer.ts
5524
+ function Rn(e) {
5525
+ return (e >= 0 ? "+" : "") + e.toFixed(2) + "%";
5526
+ }
5527
+ function zn(e) {
5528
+ return e.label;
5529
+ }
5530
+ function Bn(e, t) {
5531
+ let n = t.min ?? -5, r = t.max ?? 5;
5532
+ if (e <= n) return t.negative;
5533
+ if (e >= r) return t.positive;
5534
+ if (e < 0) {
5535
+ let r = 1 - e / n;
5536
+ return m(t.negative, t.zero, r);
5537
+ }
5538
+ let i = e / r;
5539
+ return m(t.zero, t.positive, i);
5540
+ }
5541
+ function $(e, t, n, r, i, a) {
5542
+ let o = Math.min(a, r / 2, i / 2);
5543
+ e.beginPath(), e.moveTo(t + o, n), e.lineTo(t + r - o, n), e.arcTo(t + r, n, t + r, n + o, o), e.lineTo(t + r, n + i - o), e.arcTo(t + r, n + i, t + r - o, n + i, o), e.lineTo(t + o, n + i), e.arcTo(t, n + i, t, n + i - o, o), e.lineTo(t, n + o), e.arcTo(t, n, t + o, n, o), e.closePath();
5544
+ }
5545
+ function Vn(e, t, n, r, i, a, o, s, c, l, u) {
5546
+ if (i < 40 || a < 30) return;
5547
+ let d = n + i / 2, f = r + a / 2;
5548
+ if (e.save(), e.shadowColor = "rgba(0,0,0,0.6)", e.shadowBlur = 2, e.fillStyle = "#FFFFFF", e.textAlign = "center", s) {
5549
+ let n = l(t), r = Math.min(o.font.sizeMedium, i / n.length * 1.5, a / 4);
5550
+ e.font = "bold " + Math.max(8, r) + "px " + o.font.family, e.textBaseline = c ? "bottom" : "middle", e.fillText(n, d, c ? f - 1 : f, i - 8);
5551
+ }
5552
+ if (c) {
5553
+ let n = u(t.value), r = Math.min(o.font.sizeSmall, i / n.length * 1.5, a / 4);
5554
+ e.font = Math.max(7, r) + "px " + o.font.family, e.textBaseline = s ? "top" : "middle", e.fillText(n, d, s ? f + 1 : f, i - 8);
5555
+ }
5556
+ e.restore();
5557
+ }
5558
+ function Hn(e, t, n, r, i, a, o, s) {
5559
+ let c = [o(t), s(t.value)];
5560
+ if (t.meta) for (let [e, n] of Object.entries(t.meta)) c.push(e + ": " + String(n));
5561
+ e.save(), e.font = a.font.sizeSmall + "px " + a.font.family;
5562
+ let l = Math.max(...c.map((t) => e.measureText(t).width)) + 16, u = a.font.sizeSmall + 4, d = c.length * u + 12, f = n.x + 14, p = n.y - d / 2;
5563
+ f + l > r && (f = n.x - l - 14), p < 0 && (p = 0), p + d > i && (p = i - d), e.fillStyle = a.axisLabelBackground, e.globalAlpha = .92, $(e, f, p, l, d, 4), e.fill(), e.globalAlpha = 1, e.fillStyle = a.text, e.textBaseline = "top", e.textAlign = "left";
5564
+ for (let t = 0; t < c.length; t++) e.fillText(c[t], f + 8, p + 6 + t * u);
5565
+ e.restore();
5566
+ }
5567
+ function Un(e, t, n, r, i, a, o, s) {
5568
+ if (r.length === 0 || i.length === 0 || t <= 0 || n <= 0) return null;
5569
+ let c = a.colorScale ?? {
5570
+ negative: "#EF5350",
5571
+ zero: "#424242",
5572
+ positive: "#26A69A"
5573
+ }, l = a.cellRadius ?? 4, u = a.showLabels !== !1, d = a.showValues !== !1, f = a.valueFormat ?? Rn, p = a.labelFormat ?? zn, m = /* @__PURE__ */ new Map();
5574
+ for (let e of r) m.set(e.id, e);
5575
+ let h = null, g = null;
5576
+ if (s) for (let e of i) {
5577
+ let { x: t, y: n, width: r, height: i } = e.rect;
5578
+ if (s.x >= t && s.x <= t + r && s.y >= n && s.y <= n + i) {
5579
+ h = e.id;
5580
+ let t = m.get(e.id);
5581
+ t && (g = {
5582
+ cell: t,
5583
+ rect: e
5584
+ });
5585
+ break;
5586
+ }
5587
+ }
5588
+ e.fillStyle = o.background, e.fillRect(0, 0, t, n);
5589
+ for (let t of i) {
5590
+ let n = m.get(t.id);
5591
+ if (!n) continue;
5592
+ let { x: r, y: i, width: a, height: s } = t.rect;
5593
+ if (a <= 0 || s <= 0) continue;
5594
+ let g = Bn(n.value, c);
5595
+ $(e, r, i, a, s, l), e.fillStyle = g, e.fill(), Vn(e, n, r, i, a, s, o, u, d, p, f), t.id === h && ($(e, r, i, a, s, l), e.strokeStyle = "#FFFFFF", e.lineWidth = 1.5, e.stroke());
5596
+ }
5597
+ return g && s && Hn(e, g.cell, s, t, n, o, p, f), g;
5598
+ }
5599
+ //#endregion
5600
+ export { be as ADXIndicator, ye as ATRIndicator, je as AccumulationDistributionIndicator, Gt as AlertManager, St as AnchoredVWAPTool, Zt as Animator, te as AreaRenderer, Te as AroonIndicator, vt as ArrowTool, Ht as BarCountdown, ne as BarRenderer, $t as BaseFinanceChart, ie as BaselineRenderer, It as BinanceAdapter, P as BollingerBandsIndicator, Ce as CCIIndicator, Oe as CMFIndicator, A as CandlestickRenderer, v as CanvasLayer, zt as ChartLegend, qt as ChartStateManager, le as CompareRenderer, Ue as CrosshairHandler, Ge as CrosshairTooltip, Nt as CurrentPriceLine, Rt as DEFAULT_LEGEND_CONFIG, x as DPRManager, Yt as DataExporter, ht as DateRangeTool, Dt as DepthOverlay, B as DonchianChannelIndicator, W as DrawingBase, Xe as DrawingManager, Ze as DrawingRenderer, N as EMAIndicator, Xt as Easing, pt as ElliottWaveTool, lt as EllipseTool, q as Emitter, Je as EventBus, nt as ExtendedLineTool, st as FibExtensionTool, at as FibRetracementTool, en as FinanceCrosshair, xt as GannBoxTool, bt as GannFanTool, Pe as GridRenderer, re as HollowCandleRenderer, $e as HorizontalLineTool, I as IchimokuIndicator, j as IndicatorBase, _e as IndicatorEngine, Be as InteractionManager, oe as KagiRenderer, z as KeltnerChannelIndicator, We as KeyboardHandler, y as LayerManager, ee as LineRenderer, H as MACDIndicator, we as MFIIndicator, gt as MeasureTool, Lt as MockAdapter, xe as OBVIndicator, Tt as OrderRenderer, Ve as PanHandler, L as ParabolicSARIndicator, rt as ParallelChannelTool, dt as PitchforkTool, se as PointAndFigureRenderer, Et as PositionRenderer, Fe as PriceAxis, mt as PriceRangeTool, Ee as ROCIndicator, V as RSIIndicator, tt as RayTool, J as ReconnectManager, ct as RectangleTool, it as RegressionChannelTool, D as RenderEngine, b as RenderLoop, ae as RenkoRenderer, Kt as ReplayManager, M as SMAIndicator, Bt as Screenshot, Ut as SessionBreaks, ke as StdDevIndicator, ve as StochasticIndicator, Pt as StreamManager, R as SupertrendIndicator, De as TSIIndicator, _t as TextAnnotationTool, Mt as TickAggregator, ze as TimeAxis, kt as TradingContextMenu, Ot as TradingDragHandler, At as TradingManager, jt as TradingRenderer, Qe as TrendLineTool, ut as TriangleTool, Jt as UndoRedoManager, Me as VROCIndicator, F as VWAPIndicator, et as VerticalLineTool, O as Viewport, Ae as VolumeProfileIndicator, Ct as VolumeProfileRangeTool, ce as VolumeRenderer, Vt as Watermark, Se as WilliamsRIndicator, He as ZoomHandler, S as barIndexToX, k as getVisibleData, Ln as layoutSquarifiedTreemap, Pn as layoutUniformGrid, C as priceToY, wt as registerBuiltInDrawingTools, Ne as registerBuiltInIndicators, gn as renderDepthChart, Nn as renderEquityCurve, Un as renderHeatmap, tn as renderSparkline, E as timestampToBarIndex, ue as toHeikinAshi, me as toKagi, pe as toLineBreak, he as toPointAndFigure, de as toRenko, w as xToBarIndex, T as yToPrice };
5102
5601
 
5103
5602
  //# sourceMappingURL=index.js.map