@tradecanvas/core 0.3.0 → 0.5.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
@@ -200,7 +200,7 @@ var D = class {
200
200
  render(e) {
201
201
  let t = this.renderCtx;
202
202
  if (!t) return;
203
- let { viewport: n, theme: r, data: i } = t;
203
+ let { viewport: n, theme: r, data: i } = t, a = t.numberLocale ?? "en-US";
204
204
  if (!(n.chartRect.width <= 0 || n.chartRect.height <= 0)) {
205
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();
@@ -236,42 +236,42 @@ var D = class {
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, o = `${r.font.sizeSmall}px ${r.font.family}`, s;
240
- if (a) {
241
- let e = a.getPanelIndicators();
242
- s = /* @__PURE__ */ new Map();
243
- for (let t of e) s.set(t.instanceId, t);
239
+ let n = t.crosshairHandler?.getPosition(), o = t.indicatorEngine, s = `${r.font.sizeSmall}px ${r.font.family}`, l;
240
+ if (o) {
241
+ let e = o.getPanelIndicators();
242
+ l = /* @__PURE__ */ new Map();
243
+ for (let t of e) l.set(t.instanceId, t);
244
244
  }
245
- for (let l of t.panels) {
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
- for (let n = v; n <= m; n += _) {
245
+ for (let u of t.panels) {
246
+ let t = u.viewport, d = u.rect, { min: m, max: h } = t.priceRange;
247
+ if (h - m <= 0 || d.height <= 0) continue;
248
+ let g = d.x + d.width, _ = t.chartRect;
249
+ e.strokeStyle = r.axisLine, e.lineWidth = 1, e.beginPath(), e.moveTo(g + .5, d.y), e.lineTo(g + .5, d.y + d.height), e.stroke();
250
+ let v = f(m, h, 4), y = Math.ceil(m / v) * v, b = v < 1 ? Math.ceil(-Math.log10(v)) + 1 : +(v < 10);
251
+ e.font = s, e.textBaseline = "middle", e.textAlign = "left";
252
+ for (let n = y; n <= h; n += v) {
253
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));
254
+ i < _.y || i > _.y + _.height || (e.strokeStyle = r.axisLine, e.beginPath(), e.moveTo(g, Math.round(i) + .5), e.lineTo(g + 4, Math.round(i) + .5), e.stroke(), e.fillStyle = r.axisLabel, e.fillText(p(n, b, a), g + 6, i));
255
255
  }
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);
256
+ if (n && n.x >= d.x && n.x <= d.x + d.width && n.y >= d.y && n.y <= d.y + d.height) {
257
+ let i = p(T(n.y, t), b, a);
258
258
  e.font = `bold ${r.font.sizeSmall}px ${r.font.family}`;
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);
259
+ let o = e.measureText(i).width, s = Math.min(o + 10, c - 2);
260
+ e.fillStyle = r.crosshair, e.fillRect(g + 1, n.y - 9, s, 18), e.fillStyle = r.background, e.textBaseline = "middle", e.textAlign = "left", e.fillText(i, g + 5, n.y);
261
261
  }
262
- if (n && a) {
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];
262
+ if (n && o) {
263
+ let a = w(n.x, t), c = Math.max(0, Math.min((i?.length ?? 1) - 1, Math.round(a))), f = o.getOutput(u.instanceId);
264
+ if (f?.series && c < f.series.length) {
265
+ let t = f.series[c];
266
266
  if (t) {
267
267
  let n = [];
268
268
  for (let e in t) {
269
269
  let r = t[e];
270
- r !== void 0 && n.push(`${e}: ${r.toFixed(y)}`);
270
+ r !== void 0 && n.push(`${e}: ${r.toFixed(b)}`);
271
271
  }
272
272
  if (n.length > 0) {
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);
273
+ let t = l?.get(u.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(" "), d.x + i, d.y + 6);
275
275
  }
276
276
  }
277
277
  }
@@ -957,7 +957,7 @@ var j = class {
957
957
  });
958
958
  return e;
959
959
  }
960
- }, M = class extends j {
960
+ }, ve = class extends j {
961
961
  descriptor = {
962
962
  id: "sma",
963
963
  name: "Simple Moving Average",
@@ -989,7 +989,7 @@ var j = class {
989
989
  }
990
990
  e.stroke();
991
991
  }
992
- }, N = class extends j {
992
+ }, ye = class extends j {
993
993
  descriptor = {
994
994
  id: "ema",
995
995
  name: "Exponential Moving Average",
@@ -1026,7 +1026,7 @@ var j = class {
1026
1026
  }
1027
1027
  e.stroke();
1028
1028
  }
1029
- }, P = class extends j {
1029
+ }, be = class extends j {
1030
1030
  descriptor = {
1031
1031
  id: "bb",
1032
1032
  name: "Bollinger Bands",
@@ -1081,7 +1081,7 @@ var j = class {
1081
1081
  e.stroke();
1082
1082
  }
1083
1083
  }
1084
- }, F = class extends j {
1084
+ }, xe = class extends j {
1085
1085
  descriptor = {
1086
1086
  id: "vwap",
1087
1087
  name: "Volume Weighted Average Price",
@@ -1116,7 +1116,7 @@ var j = class {
1116
1116
  }
1117
1117
  e.stroke();
1118
1118
  }
1119
- }, I = class extends j {
1119
+ }, Se = class extends j {
1120
1120
  descriptor = {
1121
1121
  id: "ichimoku",
1122
1122
  name: "Ichimoku Cloud",
@@ -1176,7 +1176,7 @@ var j = class {
1176
1176
  };
1177
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
- }, L = class extends j {
1179
+ }, Ce = class extends j {
1180
1180
  descriptor = {
1181
1181
  id: "psar",
1182
1182
  name: "Parabolic SAR",
@@ -1222,7 +1222,7 @@ var j = class {
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
- }, R = class extends j {
1225
+ }, we = class extends j {
1226
1226
  descriptor = {
1227
1227
  id: "supertrend",
1228
1228
  name: "Supertrend",
@@ -1270,7 +1270,7 @@ var j = class {
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
- }, z = class extends j {
1273
+ }, Te = class extends j {
1274
1274
  descriptor = {
1275
1275
  id: "keltner",
1276
1276
  name: "Keltner Channel",
@@ -1327,7 +1327,7 @@ var j = class {
1327
1327
  }
1328
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
- }, B = class extends j {
1330
+ }, Ee = class extends j {
1331
1331
  descriptor = {
1332
1332
  id: "donchian",
1333
1333
  name: "Donchian Channel",
@@ -1372,7 +1372,7 @@ var j = class {
1372
1372
  }
1373
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
- }, ve = class extends j {
1375
+ }, De = class extends j {
1376
1376
  descriptor = {
1377
1377
  id: "rsi",
1378
1378
  name: "Relative Strength Index",
@@ -1423,7 +1423,7 @@ var j = class {
1423
1423
  }
1424
1424
  e.stroke();
1425
1425
  }
1426
- }, ye = class extends j {
1426
+ }, Oe = class extends j {
1427
1427
  descriptor = {
1428
1428
  id: "macd",
1429
1429
  name: "MACD",
@@ -1490,7 +1490,7 @@ var j = class {
1490
1490
  }
1491
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
- }, be = class extends j {
1493
+ }, ke = class extends j {
1494
1494
  descriptor = {
1495
1495
  id: "stochastic",
1496
1496
  name: "Stochastic Oscillator",
@@ -1565,7 +1565,7 @@ var j = class {
1565
1565
  };
1566
1566
  l("k", r.colors[0]), l("d", r.colors[1] ?? "#FF9800");
1567
1567
  }
1568
- }, xe = class extends j {
1568
+ }, Ae = class extends j {
1569
1569
  descriptor = {
1570
1570
  id: "atr",
1571
1571
  name: "Average True Range",
@@ -1619,7 +1619,7 @@ var j = class {
1619
1619
  }
1620
1620
  e.stroke();
1621
1621
  }
1622
- }, Se = class extends j {
1622
+ }, je = class extends j {
1623
1623
  descriptor = {
1624
1624
  id: "adx",
1625
1625
  name: "Average Directional Index",
@@ -1692,7 +1692,7 @@ var j = class {
1692
1692
  };
1693
1693
  l("adx", r.colors[0]), l("plusDI", r.colors[1] ?? "#26A69A"), l("minusDI", r.colors[2] ?? "#EF5350");
1694
1694
  }
1695
- }, Ce = class extends j {
1695
+ }, Me = class extends j {
1696
1696
  descriptor = {
1697
1697
  id: "obv",
1698
1698
  name: "On Balance Volume",
@@ -1738,7 +1738,7 @@ var j = class {
1738
1738
  }
1739
1739
  e.stroke();
1740
1740
  }
1741
- }, we = class extends j {
1741
+ }, Ne = class extends j {
1742
1742
  descriptor = {
1743
1743
  id: "williamsR",
1744
1744
  name: "Williams %R",
@@ -1778,7 +1778,7 @@ var j = class {
1778
1778
  }
1779
1779
  e.stroke();
1780
1780
  }
1781
- }, Te = class extends j {
1781
+ }, M = class extends j {
1782
1782
  descriptor = {
1783
1783
  id: "cci",
1784
1784
  name: "Commodity Channel Index",
@@ -1833,7 +1833,7 @@ var j = class {
1833
1833
  }
1834
1834
  e.stroke();
1835
1835
  }
1836
- }, Ee = class extends j {
1836
+ }, N = class extends j {
1837
1837
  descriptor = {
1838
1838
  id: "mfi",
1839
1839
  name: "Money Flow Index",
@@ -1878,7 +1878,7 @@ var j = class {
1878
1878
  }
1879
1879
  e.stroke();
1880
1880
  }
1881
- }, De = class extends j {
1881
+ }, P = class extends j {
1882
1882
  descriptor = {
1883
1883
  id: "aroon",
1884
1884
  name: "Aroon",
@@ -1920,7 +1920,7 @@ var j = class {
1920
1920
  };
1921
1921
  l("up", r.colors[0]), l("down", r.colors[1] ?? "#EF5350");
1922
1922
  }
1923
- }, Oe = class extends j {
1923
+ }, F = class extends j {
1924
1924
  descriptor = {
1925
1925
  id: "roc",
1926
1926
  name: "Rate of Change",
@@ -1964,7 +1964,7 @@ var j = class {
1964
1964
  }
1965
1965
  e.stroke();
1966
1966
  }
1967
- }, ke = class extends j {
1967
+ }, I = class extends j {
1968
1968
  descriptor = {
1969
1969
  id: "tsi",
1970
1970
  name: "True Strength Index",
@@ -2033,7 +2033,7 @@ var j = class {
2033
2033
  };
2034
2034
  h("tsi", r.colors[0]), h("signal", r.colors[1] ?? "#FF9800");
2035
2035
  }
2036
- }, Ae = class extends j {
2036
+ }, L = class extends j {
2037
2037
  descriptor = {
2038
2038
  id: "cmf",
2039
2039
  name: "Chaikin Money Flow",
@@ -2078,7 +2078,7 @@ var j = class {
2078
2078
  }
2079
2079
  }
2080
2080
  }
2081
- }, je = class extends j {
2081
+ }, R = class extends j {
2082
2082
  descriptor = {
2083
2083
  id: "stddev",
2084
2084
  name: "Standard Deviation",
@@ -2124,7 +2124,7 @@ var j = class {
2124
2124
  }
2125
2125
  e.stroke();
2126
2126
  }
2127
- }, Me = class extends j {
2127
+ }, z = class extends j {
2128
2128
  descriptor = {
2129
2129
  id: "volumeProfile",
2130
2130
  name: "Volume Profile",
@@ -2174,7 +2174,7 @@ var j = 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
- }, Ne = class extends j {
2177
+ }, Pe = class extends j {
2178
2178
  descriptor = {
2179
2179
  id: "ad",
2180
2180
  name: "Accumulation/Distribution",
@@ -2220,7 +2220,7 @@ var j = class {
2220
2220
  }
2221
2221
  e.stroke();
2222
2222
  }
2223
- }, Pe = class extends j {
2223
+ }, Fe = class extends j {
2224
2224
  descriptor = {
2225
2225
  id: "vroc",
2226
2226
  name: "Volume Rate of Change",
@@ -2262,12 +2262,12 @@ var j = class {
2262
2262
  };
2263
2263
  //#endregion
2264
2264
  //#region src/indicators/registry.ts
2265
- function Fe(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 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()), e.register(new Ne()), e.register(new Pe());
2265
+ function Ie(e) {
2266
+ 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()), e.register(new Ne()), 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 Pe()), e.register(new Fe());
2267
2267
  }
2268
2268
  //#endregion
2269
2269
  //#region src/axis/GridRenderer.ts
2270
- var Ie = class {
2270
+ var Le = class {
2271
2271
  visible = !0;
2272
2272
  setVisible(e) {
2273
2273
  this.visible = e;
@@ -2296,7 +2296,11 @@ var Ie = class {
2296
2296
  }
2297
2297
  e.stroke();
2298
2298
  }
2299
- }, Le = class {
2299
+ }, Re = class {
2300
+ locale = "en-US";
2301
+ setLocale(e) {
2302
+ this.locale = e;
2303
+ }
2300
2304
  render(e, t, n) {
2301
2305
  let { chartRect: r, priceRange: i } = t, a = r.x + r.width, o = i.max - i.min;
2302
2306
  if (o <= 0) return;
@@ -2307,7 +2311,7 @@ var Ie = class {
2307
2311
  let t = r.y + r.height * (1 - (e - i.min) * s);
2308
2312
  h.push({
2309
2313
  y: t,
2310
- text: p(e, d)
2314
+ text: p(e, d, this.locale)
2311
2315
  });
2312
2316
  }
2313
2317
  e.font = m, e.textBaseline = "middle", e.textAlign = "left", e.fillStyle = n.axisLabelBackground;
@@ -2315,7 +2319,7 @@ var Ie = class {
2315
2319
  e.fillStyle = n.axisLabel;
2316
2320
  for (let { y: t, text: n } of h) e.fillText(n, a + 5, t);
2317
2321
  }
2318
- }, V = /* @__PURE__ */ new Date(), Re = (e) => e < 10 ? "0" + e : "" + e, ze = -(/* @__PURE__ */ new Date()).getTimezoneOffset() / 60, Be = `UTC${ze >= 0 ? "+" : ""}${ze}`, Ve = class {
2322
+ }, B = /* @__PURE__ */ new Date(), ze = (e) => e < 10 ? "0" + e : "" + e, Be = -(/* @__PURE__ */ new Date()).getTimezoneOffset() / 60, Ve = `UTC${Be >= 0 ? "+" : ""}${Be}`, He = class {
2319
2323
  render(e, t, n, r, i) {
2320
2324
  let { chartRect: a } = t, o = i ?? a.y + a.height;
2321
2325
  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 +2329,14 @@ var Ie = class {
2325
2329
  for (let t = l; t <= u && t < r.length; t++) {
2326
2330
  if (t % c !== 0) continue;
2327
2331
  let n = t * s + d, i = r[t].time, a = i > 0xe8d4a51000 ? i : i * 1e3;
2328
- V.setTime(a);
2329
- let l = V.getDate(), u = V.getMonth() + 1, p = V.getHours(), m = V.getMinutes(), h;
2330
- l === f ? h = `${Re(p)}:${Re(m)}` : (h = `${u}/${l}`, f = l), e.fillText(h, n, o + 5);
2332
+ B.setTime(a);
2333
+ let l = B.getDate(), u = B.getMonth() + 1, p = B.getHours(), m = B.getMinutes(), h;
2334
+ l === f ? h = `${ze(p)}:${ze(m)}` : (h = `${u}/${l}`, f = l), e.fillText(h, n, o + 5);
2331
2335
  }
2332
2336
  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(Be, p, m);
2337
+ e.font = `${n.font.sizeSmall - 1}px ${n.font.family}`, e.textAlign = "right", e.textBaseline = "top", e.fillStyle = n.textSecondary, e.fillText(Ve, p, m);
2334
2338
  }
2335
- }, He = class {
2339
+ }, Ue = class {
2336
2340
  panHandler = null;
2337
2341
  zoomHandler = null;
2338
2342
  crosshairHandler = null;
@@ -2347,6 +2351,7 @@ var Ie = class {
2347
2351
  y: 0
2348
2352
  };
2349
2353
  touchActive = !1;
2354
+ cachedRect = null;
2350
2355
  constructor(e) {
2351
2356
  this.element = e;
2352
2357
  }
@@ -2370,6 +2375,7 @@ var Ie = class {
2370
2375
  }
2371
2376
  attach() {
2372
2377
  let e = () => this.viewportGetter?.() ?? null, t = (t) => {
2378
+ this.invalidateRect();
2373
2379
  let n = this.getMousePos(t), r = e();
2374
2380
  this.tradingManager && r && this.tradingManager.onPointerDown(n, r) || this.drawingManager && r && this.drawingManager.onPointerDown(n, r) || this.panHandler?.onPointerDown(n);
2375
2381
  }, n = (t) => {
@@ -2397,7 +2403,7 @@ var Ie = class {
2397
2403
  let n = e();
2398
2404
  this.tradingManager && n && (t.preventDefault(), this.tradingManager.onContextMenu(this.getMousePos(t), n));
2399
2405
  }, c = (e) => {
2400
- if (e.preventDefault(), e.touches.length === 1) {
2406
+ if (e.preventDefault(), this.invalidateRect(), e.touches.length === 1) {
2401
2407
  let t = this.getTouchPos(e.touches[0]);
2402
2408
  this.panHandler?.onPointerDown(t), this.crosshairHandler?.onPointerMove(t), this.touchActive = !0;
2403
2409
  } else e.touches.length === 2 && (this.panHandler?.onPointerUp(), this.lastTouchDist = this.getTouchDistance(e.touches[0], e.touches[1]), this.lastTouchMid = this.getTouchMidpoint(e.touches[0], e.touches[1]), this.touchActive = !0);
@@ -2421,22 +2427,28 @@ var Ie = class {
2421
2427
  let t = this.getTouchPos(e.touches[0]);
2422
2428
  this.panHandler?.onPointerDown(t);
2423
2429
  }
2424
- };
2425
- this.element.addEventListener("mousedown", t), this.element.addEventListener("mousemove", n), document.addEventListener("mouseup", r), this.element.addEventListener("mouseleave", i), this.element.addEventListener("wheel", a, { passive: !1 }), this.element.addEventListener("contextmenu", s), this.element.addEventListener("touchstart", c, { passive: !1 }), this.element.addEventListener("touchmove", l, { passive: !1 }), this.element.addEventListener("touchend", u), document.addEventListener("keydown", o), this.boundHandlers.push(() => this.element.removeEventListener("mousedown", t), () => this.element.removeEventListener("mousemove", n), () => document.removeEventListener("mouseup", r), () => this.element.removeEventListener("mouseleave", i), () => this.element.removeEventListener("wheel", a), () => this.element.removeEventListener("contextmenu", s), () => this.element.removeEventListener("touchstart", c), () => this.element.removeEventListener("touchmove", l), () => this.element.removeEventListener("touchend", u), () => document.removeEventListener("keydown", o));
2430
+ }, d = () => this.invalidateRect(), f = () => this.invalidateRect();
2431
+ this.element.addEventListener("mousedown", t), this.element.addEventListener("mousemove", n), document.addEventListener("mouseup", r), this.element.addEventListener("mouseleave", i), this.element.addEventListener("wheel", a, { passive: !1 }), this.element.addEventListener("contextmenu", s), this.element.addEventListener("touchstart", c, { passive: !1 }), this.element.addEventListener("touchmove", l, { passive: !1 }), this.element.addEventListener("touchend", u), document.addEventListener("keydown", o), window.addEventListener("resize", d), this.element.addEventListener("scroll", f, { passive: !0 }), this.boundHandlers.push(() => this.element.removeEventListener("mousedown", t), () => this.element.removeEventListener("mousemove", n), () => document.removeEventListener("mouseup", r), () => this.element.removeEventListener("mouseleave", i), () => this.element.removeEventListener("wheel", a), () => this.element.removeEventListener("contextmenu", s), () => this.element.removeEventListener("touchstart", c), () => this.element.removeEventListener("touchmove", l), () => this.element.removeEventListener("touchend", u), () => document.removeEventListener("keydown", o), () => window.removeEventListener("resize", d), () => this.element.removeEventListener("scroll", f));
2426
2432
  }
2427
2433
  detach() {
2428
2434
  for (let e of this.boundHandlers) e();
2429
- this.boundHandlers = [];
2435
+ this.boundHandlers = [], this.cachedRect = null;
2436
+ }
2437
+ invalidateRect() {
2438
+ this.cachedRect = null;
2439
+ }
2440
+ getRect() {
2441
+ return this.cachedRect ||= this.element.getBoundingClientRect(), this.cachedRect;
2430
2442
  }
2431
2443
  getMousePos(e) {
2432
- let t = this.element.getBoundingClientRect();
2444
+ let t = this.getRect();
2433
2445
  return {
2434
2446
  x: e.clientX - t.left,
2435
2447
  y: e.clientY - t.top
2436
2448
  };
2437
2449
  }
2438
2450
  getTouchPos(e) {
2439
- let t = this.element.getBoundingClientRect();
2451
+ let t = this.getRect();
2440
2452
  return {
2441
2453
  x: e.clientX - t.left,
2442
2454
  y: e.clientY - t.top
@@ -2446,13 +2458,13 @@ var Ie = class {
2446
2458
  return Math.hypot(t.clientX - e.clientX, t.clientY - e.clientY);
2447
2459
  }
2448
2460
  getTouchMidpoint(e, t) {
2449
- let n = this.element.getBoundingClientRect();
2461
+ let n = this.getRect();
2450
2462
  return {
2451
2463
  x: (e.clientX + t.clientX) / 2 - n.left,
2452
2464
  y: (e.clientY + t.clientY) / 2 - n.top
2453
2465
  };
2454
2466
  }
2455
- }, Ue = class {
2467
+ }, We = class {
2456
2468
  dragging = !1;
2457
2469
  lastX = 0;
2458
2470
  lastTime = 0;
@@ -2488,7 +2500,7 @@ var Ie = class {
2488
2500
  stopMomentum() {
2489
2501
  this.momentumId &&= (cancelAnimationFrame(this.momentumId), 0);
2490
2502
  }
2491
- }, We = class {
2503
+ }, Ge = class {
2492
2504
  callback;
2493
2505
  sensitivity;
2494
2506
  pendingDelta = 0;
@@ -2507,13 +2519,14 @@ var Ie = class {
2507
2519
  dispose() {
2508
2520
  this.rafId &&= (cancelAnimationFrame(this.rafId), 0);
2509
2521
  }
2510
- }, Ge = class {
2522
+ }, Ke = class {
2511
2523
  position = null;
2512
2524
  callback = null;
2513
2525
  data = [];
2514
2526
  magnetMode = !0;
2515
2527
  mode = "magnet";
2516
2528
  pricePrecision = 2;
2529
+ locale = "en-US";
2517
2530
  pendingBarIndex = null;
2518
2531
  pendingPoint = null;
2519
2532
  callbackScheduled = !1;
@@ -2536,6 +2549,9 @@ var Ie = class {
2536
2549
  setPricePrecision(e) {
2537
2550
  this.pricePrecision = e;
2538
2551
  }
2552
+ setLocale(e) {
2553
+ this.locale = e;
2554
+ }
2539
2555
  getPosition() {
2540
2556
  return this.position;
2541
2557
  }
@@ -2554,7 +2570,7 @@ var Ie = class {
2554
2570
  x: i,
2555
2571
  y: a
2556
2572
  }, 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;
2573
+ let s = p(T(a, t), this.pricePrecision, this.locale), l = r.x + r.width + 1;
2558
2574
  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
2575
  }
2560
2576
  scheduleCallback() {
@@ -2565,7 +2581,7 @@ var Ie = class {
2565
2581
  flushCallback(e, t) {
2566
2582
  this.callback?.(e, t);
2567
2583
  }
2568
- }, Ke = class {
2584
+ }, qe = class {
2569
2585
  callbacks;
2570
2586
  enabled = !0;
2571
2587
  constructor(e) {
@@ -2591,7 +2607,7 @@ var Ie = class {
2591
2607
  default: return !1;
2592
2608
  }
2593
2609
  }
2594
- }, qe = class {
2610
+ }, Je = class {
2595
2611
  el = null;
2596
2612
  visible = !1;
2597
2613
  timeEl;
@@ -2630,8 +2646,8 @@ var Ie = class {
2630
2646
  this.changeEl.textContent = `${l}${a(s)} (${l}${c.toFixed(2)}%)`, this.changeEl.style.color = i;
2631
2647
  let u = t.volume;
2632
2648
  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 = Je(n.background);
2634
- this.el.style.background = d ? Ye(n.background, .95) : Ye(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);
2649
+ let d = Ye(n.background);
2650
+ this.el.style.background = d ? Xe(n.background, .95) : Xe(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
2651
  let f = e.x + 16, p = e.y - 40;
2636
2652
  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
2653
  }
@@ -2656,7 +2672,7 @@ var Ie = class {
2656
2672
  return document.createElement("span");
2657
2673
  }
2658
2674
  };
2659
- function Je(e) {
2675
+ function Ye(e) {
2660
2676
  if (e.startsWith("#")) {
2661
2677
  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
2678
  return (.299 * r + .587 * i + .114 * a) / 255 < .5;
@@ -2668,7 +2684,7 @@ function Je(e) {
2668
2684
  }
2669
2685
  return !0;
2670
2686
  }
2671
- function Ye(e, t) {
2687
+ function Xe(e, t) {
2672
2688
  if (e.startsWith("#")) {
2673
2689
  let n = e.slice(1), r = n.length === 3 ? n.split("").map((e) => e + e).join("") : n.slice(0, 6);
2674
2690
  return `rgba(${parseInt(r.slice(0, 2), 16)}, ${parseInt(r.slice(2, 4), 16)}, ${parseInt(r.slice(4, 6), 16)}, ${t})`;
@@ -2677,7 +2693,7 @@ function Ye(e, t) {
2677
2693
  }
2678
2694
  //#endregion
2679
2695
  //#region src/events/EventBus.ts
2680
- var Xe = class {
2696
+ var Ze = class {
2681
2697
  listeners = /* @__PURE__ */ new Map();
2682
2698
  tauriBridge = null;
2683
2699
  on(e, t) {
@@ -2708,7 +2724,7 @@ var Xe = class {
2708
2724
  destroy() {
2709
2725
  this.listeners.clear(), this.tauriBridge = null;
2710
2726
  }
2711
- }, H = class {
2727
+ }, V = class {
2712
2728
  hitTestAnchor(e, t, n, r) {
2713
2729
  for (let i = 0; i < t.anchors.length; i++) {
2714
2730
  let a = this.anchorToPixel(t.anchors[i], n);
@@ -2763,7 +2779,16 @@ var Xe = class {
2763
2779
  let r = n.x - t.x, i = n.y - t.y, a = Math.hypot(r, i);
2764
2780
  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
2781
  }
2766
- }, Ze = 1, Qe = class {
2782
+ }, Qe = 1;
2783
+ function H(e) {
2784
+ return {
2785
+ ...e,
2786
+ anchors: e.anchors.map((e) => ({ ...e })),
2787
+ style: { ...e.style },
2788
+ meta: e.meta ? { ...e.meta } : void 0
2789
+ };
2790
+ }
2791
+ var $e = class {
2767
2792
  registry = /* @__PURE__ */ new Map();
2768
2793
  drawings = [];
2769
2794
  state = "idle";
@@ -2935,7 +2960,7 @@ var Xe = class {
2935
2960
  e && this.undoRedo?.push({
2936
2961
  type: "drawingModify",
2937
2962
  before: this.dragBeforeState,
2938
- after: structuredClone(e)
2963
+ after: H(e)
2939
2964
  });
2940
2965
  }
2941
2966
  return this.state = "selected", this.dragStartPoint = null, this.dragStartAnchors = [], this.dragAnchorIndex = -1, this.dragBeforeState = null, !0;
@@ -2968,7 +2993,7 @@ var Xe = class {
2968
2993
  let t = this.drawings.find((t) => t.id === e);
2969
2994
  if (!t) return null;
2970
2995
  let n = structuredClone(t);
2971
- return n.id = `tc_drawing_${Ze++}`, n.anchors = n.anchors.map((e) => ({
2996
+ return n.id = `tc_drawing_${Qe++}`, n.anchors = n.anchors.map((e) => ({
2972
2997
  ...e,
2973
2998
  time: e.time + 3
2974
2999
  })), n.locked = !1, this.drawings.push(n), this.undoRedo?.push({
@@ -3010,7 +3035,7 @@ var Xe = class {
3010
3035
  if (!n) return !1;
3011
3036
  let r = w(e.x, t), i = T(e.y, t), a = this.snapToOHLC(r, i, t);
3012
3037
  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_${Ze++}`,
3038
+ id: `tc_drawing_${Qe++}`,
3014
3039
  type: this.activeTool,
3015
3040
  anchors: [a],
3016
3041
  style: { ...this.activeStyle },
@@ -3032,8 +3057,8 @@ var Xe = class {
3032
3057
  let r = this.registry.get(n.type);
3033
3058
  if (r) {
3034
3059
  let i = r.hitTestAnchor(e, n, t, 8);
3035
- if (i >= 0) return this.state = "resizing", this.dragAnchorIndex = i, this.dragStartPoint = e, this.dragBeforeState = structuredClone(n), !0;
3036
- if (r.hitTest(e, n, t, 8)) return this.state = "moving", this.dragStartPoint = e, this.dragStartAnchors = n.anchors.map((e) => ({ ...e })), this.dragBeforeState = structuredClone(n), !0;
3060
+ if (i >= 0) return this.state = "resizing", this.dragAnchorIndex = i, this.dragStartPoint = e, this.dragBeforeState = H(n), !0;
3061
+ if (r.hitTest(e, n, t, 8)) return this.state = "moving", this.dragStartPoint = e, this.dragStartAnchors = n.anchors.map((e) => ({ ...e })), this.dragBeforeState = H(n), !0;
3037
3062
  }
3038
3063
  }
3039
3064
  }
@@ -3061,14 +3086,14 @@ var Xe = class {
3061
3086
  price: T(e.y, t)
3062
3087
  }, this.requestRender?.(), !0);
3063
3088
  }
3064
- }, $e = class {
3089
+ }, et = class {
3065
3090
  constructor(e) {
3066
3091
  this.manager = e;
3067
3092
  }
3068
3093
  render(e, t) {
3069
3094
  this.manager.render(e, t);
3070
3095
  }
3071
- }, et = class extends H {
3096
+ }, tt = class extends V {
3072
3097
  descriptor = {
3073
3098
  type: "trendLine",
3074
3099
  name: "Trend Line",
@@ -3084,7 +3109,7 @@ var Xe = class {
3084
3109
  let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n);
3085
3110
  return this.distanceToLine(e, i, a) <= r;
3086
3111
  }
3087
- }, tt = class extends H {
3112
+ }, nt = class extends V {
3088
3113
  descriptor = {
3089
3114
  type: "horizontalLine",
3090
3115
  name: "Horizontal Line",
@@ -3100,7 +3125,7 @@ var Xe = class {
3100
3125
  let i = C(t.anchors[0].price, n);
3101
3126
  return Math.abs(e.y - i) <= r && e.x >= n.chartRect.x && e.x <= n.chartRect.x + n.chartRect.width;
3102
3127
  }
3103
- }, nt = class extends H {
3128
+ }, rt = class extends V {
3104
3129
  descriptor = {
3105
3130
  type: "verticalLine",
3106
3131
  name: "Vertical Line",
@@ -3116,7 +3141,7 @@ var Xe = class {
3116
3141
  let i = this.anchorToPixel(t.anchors[0], n), { chartRect: a } = n;
3117
3142
  return Math.abs(e.x - i.x) <= r && e.y >= a.y && e.y <= a.y + a.height;
3118
3143
  }
3119
- }, rt = class extends H {
3144
+ }, it = class extends V {
3120
3145
  descriptor = {
3121
3146
  type: "ray",
3122
3147
  name: "Ray",
@@ -3134,7 +3159,7 @@ var Xe = class {
3134
3159
  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
3160
  return ((e.x - i.x) * o + (e.y - i.y) * s) / (o * o + s * s) < 0 ? !1 : this.distanceToInfiniteLine(e, i, a) <= r;
3136
3161
  }
3137
- }, it = class extends H {
3162
+ }, at = class extends V {
3138
3163
  descriptor = {
3139
3164
  type: "extendedLine",
3140
3165
  name: "Extended Line",
@@ -3152,7 +3177,7 @@ var Xe = class {
3152
3177
  let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n);
3153
3178
  return this.distanceToInfiniteLine(e, i, a) <= r;
3154
3179
  }
3155
- }, at = class extends H {
3180
+ }, ot = class extends V {
3156
3181
  descriptor = {
3157
3182
  type: "parallelChannel",
3158
3183
  name: "Parallel Channel",
@@ -3189,7 +3214,7 @@ var Xe = class {
3189
3214
  }
3190
3215
  return !1;
3191
3216
  }
3192
- }, ot = class extends H {
3217
+ }, st = class extends V {
3193
3218
  descriptor = {
3194
3219
  type: "regressionChannel",
3195
3220
  name: "Regression Channel",
@@ -3220,7 +3245,7 @@ var Xe = class {
3220
3245
  .618,
3221
3246
  .786,
3222
3247
  1
3223
- ], st = class extends H {
3248
+ ], ct = class extends V {
3224
3249
  descriptor = {
3225
3250
  type: "fibRetracement",
3226
3251
  name: "Fibonacci Retracement",
@@ -3254,7 +3279,7 @@ var Xe = class {
3254
3279
  }
3255
3280
  return !1;
3256
3281
  }
3257
- }, ct = [
3282
+ }, lt = [
3258
3283
  0,
3259
3284
  .618,
3260
3285
  1,
@@ -3263,7 +3288,7 @@ var Xe = class {
3263
3288
  2.618,
3264
3289
  3.618,
3265
3290
  4.236
3266
- ], lt = class extends H {
3291
+ ], ut = class extends V {
3267
3292
  descriptor = {
3268
3293
  type: "fibExtension",
3269
3294
  name: "Fibonacci Extension",
@@ -3279,7 +3304,7 @@ var Xe = class {
3279
3304
  }
3280
3305
  let { chartRect: i } = n, a = t.anchors[0].price, o = t.anchors[1].price, s = t.anchors[2].price, c = a - o;
3281
3306
  e.font = "11px sans-serif", e.textBaseline = "middle", e.textAlign = "left";
3282
- for (let r of ct) {
3307
+ for (let r of lt) {
3283
3308
  let a = C(s + c * r, n);
3284
3309
  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
3310
  }
@@ -3290,13 +3315,13 @@ var Xe = class {
3290
3315
  let { chartRect: i } = n;
3291
3316
  if (e.x < i.x - r || e.x > i.x + i.width + r) return !1;
3292
3317
  let a = t.anchors[0].price - t.anchors[1].price;
3293
- for (let i of ct) {
3318
+ for (let i of lt) {
3294
3319
  let o = C(t.anchors[2].price + a * i, n);
3295
3320
  if (Math.abs(e.y - o) <= r) return !0;
3296
3321
  }
3297
3322
  return !1;
3298
3323
  }
3299
- }, ut = class extends H {
3324
+ }, dt = class extends V {
3300
3325
  descriptor = {
3301
3326
  type: "rectangle",
3302
3327
  name: "Rectangle",
@@ -3314,7 +3339,7 @@ var Xe = class {
3314
3339
  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
3340
  return !(e.x > u && e.x < f && e.y > d && e.y < p) || !!t.style.fillColor;
3316
3341
  }
3317
- }, dt = class extends H {
3342
+ }, ft = class extends V {
3318
3343
  descriptor = {
3319
3344
  type: "ellipse",
3320
3345
  name: "Ellipse",
@@ -3330,7 +3355,7 @@ var Xe = class {
3330
3355
  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
3356
  return t.style.fillColor ? f <= 1 + p : Math.abs(f - 1) <= p;
3332
3357
  }
3333
- }, ft = class extends H {
3358
+ }, pt = class extends V {
3334
3359
  descriptor = {
3335
3360
  type: "triangle",
3336
3361
  name: "Triangle",
@@ -3356,7 +3381,7 @@ var Xe = class {
3356
3381
  }
3357
3382
  return !1;
3358
3383
  }
3359
- }, pt = class extends H {
3384
+ }, mt = class extends V {
3360
3385
  descriptor = {
3361
3386
  type: "pitchfork",
3362
3387
  name: "Andrews' Pitchfork",
@@ -3392,7 +3417,7 @@ var Xe = class {
3392
3417
  };
3393
3418
  return this.distanceToInfiniteLine(e, a, u) <= r || this.distanceToInfiniteLine(e, o, d) <= r;
3394
3419
  }
3395
- }, mt = [
3420
+ }, ht = [
3396
3421
  "1",
3397
3422
  "2",
3398
3423
  "3",
@@ -3401,7 +3426,7 @@ var Xe = class {
3401
3426
  "A",
3402
3427
  "B",
3403
3428
  "C"
3404
- ], ht = class extends H {
3429
+ ], gt = class extends V {
3405
3430
  descriptor = {
3406
3431
  type: "elliottWave",
3407
3432
  name: "Elliott Wave",
@@ -3413,9 +3438,9 @@ var Xe = class {
3413
3438
  this.applyLineStyle(e, t.style), e.beginPath(), e.moveTo(i[0].x, i[0].y);
3414
3439
  for (let t = 1; t < i.length; t++) e.lineTo(i[t].x, i[t].y);
3415
3440
  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 < mt.length; t++) {
3441
+ for (let t = 0; t < i.length && t < ht.length; t++) {
3417
3442
  let n = t % 2 == 0 ? -12 : 12;
3418
- e.textBaseline = n < 0 ? "bottom" : "top", e.fillText(mt[t], i[t].x, i[t].y + n);
3443
+ e.textBaseline = n < 0 ? "bottom" : "top", e.fillText(ht[t], i[t].x, i[t].y + n);
3419
3444
  }
3420
3445
  r && this.renderAnchorHandles(e, t, n);
3421
3446
  }
@@ -3425,7 +3450,7 @@ var Xe = class {
3425
3450
  for (let t = 0; t < i.length - 1; t++) if (this.distanceToLine(e, i[t], i[t + 1]) <= r) return !0;
3426
3451
  return !1;
3427
3452
  }
3428
- }, gt = class extends H {
3453
+ }, _t = class extends V {
3429
3454
  descriptor = {
3430
3455
  type: "priceRange",
3431
3456
  name: "Price Range",
@@ -3443,7 +3468,7 @@ var Xe = class {
3443
3468
  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
3469
  return e.x >= o - r && e.x <= s + r && e.y >= c - r && e.y <= l + r;
3445
3470
  }
3446
- }, _t = class extends H {
3471
+ }, vt = class extends V {
3447
3472
  descriptor = {
3448
3473
  type: "dateRange",
3449
3474
  name: "Date Range",
@@ -3461,7 +3486,7 @@ var Xe = class {
3461
3486
  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
3487
  return e.x >= s - r && e.x <= c + r && e.y >= o.y && e.y <= o.y + o.height;
3463
3488
  }
3464
- }, vt = class extends H {
3489
+ }, yt = class extends V {
3465
3490
  descriptor = {
3466
3491
  type: "measure",
3467
3492
  name: "Measure",
@@ -3483,7 +3508,7 @@ var Xe = class {
3483
3508
  let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n);
3484
3509
  return this.distanceToLine(e, i, a) <= r;
3485
3510
  }
3486
- }, yt = class extends H {
3511
+ }, bt = class extends V {
3487
3512
  descriptor = {
3488
3513
  type: "text",
3489
3514
  name: "Text",
@@ -3503,7 +3528,7 @@ var Xe = class {
3503
3528
  let i = this.anchorToPixel(t.anchors[0], n), a = t.style.fontSize || 14;
3504
3529
  return e.x >= i.x - r && e.x <= i.x + 80 + r && e.y >= i.y - r && e.y <= i.y + a + r;
3505
3530
  }
3506
- }, bt = class extends H {
3531
+ }, xt = class extends V {
3507
3532
  descriptor = {
3508
3533
  type: "arrow",
3509
3534
  name: "Arrow",
@@ -3521,7 +3546,7 @@ var Xe = class {
3521
3546
  let i = this.anchorToPixel(t.anchors[0], n), a = this.anchorToPixel(t.anchors[1], n);
3522
3547
  return this.distanceToLine(e, i, a) <= r;
3523
3548
  }
3524
- }, xt = [
3549
+ }, St = [
3525
3550
  {
3526
3551
  label: "8x1",
3527
3552
  ratio: 8
@@ -3558,7 +3583,7 @@ var Xe = class {
3558
3583
  label: "1x8",
3559
3584
  ratio: .125
3560
3585
  }
3561
- ], W = class extends H {
3586
+ ], Ct = class extends V {
3562
3587
  descriptor = {
3563
3588
  type: "gannFan",
3564
3589
  name: "Gann Fan",
@@ -3570,7 +3595,7 @@ var Xe = class {
3570
3595
  if (Math.abs(o) < 1) return;
3571
3596
  let c = s / o, l = o > 0 ? 1 : -1, { chartRect: u } = n, d = l > 0 ? u.x + u.width : u.x;
3572
3597
  this.applyLineStyle(e, t.style);
3573
- for (let { label: n, ratio: r } of xt) {
3598
+ for (let { label: n, ratio: r } of St) {
3574
3599
  let a = c * r, o = d, s = i.y + a * (o - i.x);
3575
3600
  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
3601
  let f = o - l * 4, p = s;
@@ -3583,7 +3608,7 @@ var Xe = class {
3583
3608
  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
3609
  if (Math.abs(o) < 1) return !1;
3585
3610
  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 xt) {
3611
+ for (let { ratio: t } of St) {
3587
3612
  let n = c * t, a = d, o = i.y + n * (a - i.x);
3588
3613
  if (this.distanceToLine(e, i, {
3589
3614
  x: a,
@@ -3592,7 +3617,7 @@ var Xe = class {
3592
3617
  }
3593
3618
  return !1;
3594
3619
  }
3595
- }, G = [
3620
+ }, W = [
3596
3621
  0,
3597
3622
  .25,
3598
3623
  .333,
@@ -3600,7 +3625,7 @@ var Xe = class {
3600
3625
  .667,
3601
3626
  .75,
3602
3627
  1
3603
- ], St = class extends H {
3628
+ ], wt = class extends V {
3604
3629
  descriptor = {
3605
3630
  type: "gannBox",
3606
3631
  name: "Gann Box",
@@ -3611,18 +3636,18 @@ var Xe = class {
3611
3636
  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
3637
  if (!(u < 2 || d < 2)) {
3613
3638
  this.applyLineStyle(e, t.style), e.strokeRect(o, c, u, d), e.save(), e.globalAlpha = .35;
3614
- for (let t of G) {
3639
+ for (let t of W) {
3615
3640
  if (t === 0 || t === 1) continue;
3616
3641
  let n = c + d * t;
3617
3642
  e.beginPath(), e.moveTo(o, n), e.lineTo(s, n), e.stroke();
3618
3643
  }
3619
- for (let t of G) {
3644
+ for (let t of W) {
3620
3645
  if (t === 0 || t === 1) continue;
3621
3646
  let n = o + u * t;
3622
3647
  e.beginPath(), e.moveTo(n, c), e.lineTo(n, l), e.stroke();
3623
3648
  }
3624
3649
  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 G) {
3650
+ for (let t of W) {
3626
3651
  if (t === 0 || t === 1) continue;
3627
3652
  let n = c + d * t;
3628
3653
  e.fillText(`${(t * 100).toFixed(0)}%`, o - 3, n);
@@ -3647,7 +3672,7 @@ var Xe = class {
3647
3672
  y: l
3648
3673
  }) <= r;
3649
3674
  }
3650
- }, Ct = class extends H {
3675
+ }, Tt = class extends V {
3651
3676
  descriptor = {
3652
3677
  type: "anchoredVWAP",
3653
3678
  name: "Anchored VWAP",
@@ -3719,7 +3744,7 @@ var Xe = class {
3719
3744
  }
3720
3745
  return !1;
3721
3746
  }
3722
- }, wt = class extends H {
3747
+ }, Et = class extends V {
3723
3748
  descriptor = {
3724
3749
  type: "volumeProfileRange",
3725
3750
  name: "Volume Profile (Range)",
@@ -3764,12 +3789,12 @@ var Xe = class {
3764
3789
  };
3765
3790
  //#endregion
3766
3791
  //#region src/drawings/tools/index.ts
3767
- function Tt(e) {
3768
- 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 ot()), e.register(new st()), e.register(new lt()), e.register(new ut()), e.register(new dt()), e.register(new ft()), e.register(new pt()), e.register(new ht()), e.register(new gt()), e.register(new _t()), e.register(new vt()), e.register(new yt()), e.register(new bt()), e.register(new W()), e.register(new St()), e.register(new Ct()), e.register(new wt());
3792
+ function Dt(e) {
3793
+ e.register(new tt()), e.register(new nt()), e.register(new rt()), e.register(new it()), e.register(new at()), e.register(new ot()), e.register(new st()), e.register(new ct()), e.register(new ut()), e.register(new dt()), e.register(new ft()), e.register(new pt()), e.register(new mt()), e.register(new gt()), e.register(new _t()), e.register(new vt()), e.register(new yt()), e.register(new bt()), e.register(new xt()), e.register(new Ct()), e.register(new wt()), e.register(new Tt()), e.register(new Et());
3769
3794
  }
3770
3795
  //#endregion
3771
3796
  //#region src/trading/OrderRenderer.ts
3772
- var Et = class {
3797
+ var Ot = class {
3773
3798
  render(e, t, n, r, i, a) {
3774
3799
  let o = i.orderColors?.buy ?? "#26A69A", s = i.orderColors?.sell ?? "#EF5350", { chartRect: c } = n;
3775
3800
  for (let i of t) {
@@ -3807,7 +3832,7 @@ var Et = class {
3807
3832
  }
3808
3833
  return null;
3809
3834
  }
3810
- }, Dt = class {
3835
+ }, kt = class {
3811
3836
  render(e, t, n, r, i, a) {
3812
3837
  let { chartRect: o } = r, s = a.positionColors?.profit ?? "#26A69A", c = a.positionColors?.loss ?? "#EF5350", l = a.positionColors?.entry ?? "#2196F3", u = a.pricePrecision ?? 2;
3813
3838
  for (let a of t) {
@@ -3840,7 +3865,7 @@ var Et = class {
3840
3865
  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
3866
  }
3842
3867
  }
3843
- }, Ot = class {
3868
+ }, At = class {
3844
3869
  render(e, t, n, r) {
3845
3870
  if (!r.depthOverlay?.enabled) return;
3846
3871
  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;
@@ -3871,7 +3896,7 @@ var Et = class {
3871
3896
  e.fillRect(p - o, a - f / 2, o, f);
3872
3897
  }
3873
3898
  }
3874
- }, kt = class {
3899
+ }, jt = class {
3875
3900
  dragState = null;
3876
3901
  startY = 0;
3877
3902
  dragging = !1;
@@ -3935,7 +3960,7 @@ var Et = class {
3935
3960
  isActive() {
3936
3961
  return this.dragState !== null;
3937
3962
  }
3938
- }, At = class {
3963
+ }, Mt = class {
3939
3964
  menuElement = null;
3940
3965
  removeHandler = null;
3941
3966
  onItemSelect = null;
@@ -4019,17 +4044,17 @@ var Et = class {
4019
4044
  destroy() {
4020
4045
  this.hide(), this.onItemSelect = null;
4021
4046
  }
4022
- }, jt = class {
4047
+ }, Nt = class {
4023
4048
  orders = [];
4024
4049
  positions = [];
4025
4050
  depthData = null;
4026
4051
  currentPrice = null;
4027
4052
  config;
4028
- orderRenderer = new Et();
4029
- positionRenderer = new Dt();
4030
- depthOverlay = new Ot();
4053
+ orderRenderer = new Ot();
4054
+ positionRenderer = new kt();
4055
+ depthOverlay = new At();
4031
4056
  dragHandler;
4032
- contextMenu = new At();
4057
+ contextMenu = new Mt();
4033
4058
  requestRender = null;
4034
4059
  eventCallback = null;
4035
4060
  container = null;
@@ -4037,7 +4062,7 @@ var Et = class {
4037
4062
  this.config = {
4038
4063
  ...a,
4039
4064
  ...e
4040
- }, this.dragHandler = new kt(this.config.dragThreshold), this.contextMenu.onItemSelect = (e) => {
4065
+ }, this.dragHandler = new jt(this.config.dragThreshold), this.contextMenu.onItemSelect = (e) => {
4041
4066
  this.eventCallback?.("orderPlace", e);
4042
4067
  };
4043
4068
  }
@@ -4098,7 +4123,7 @@ var Et = class {
4098
4123
  destroy() {
4099
4124
  this.contextMenu.destroy();
4100
4125
  }
4101
- }, Mt = class {
4126
+ }, Pt = class {
4102
4127
  constructor(e) {
4103
4128
  this.manager = e;
4104
4129
  }
@@ -4108,7 +4133,7 @@ var Et = class {
4108
4133
  renderAxisBadges(e, t, n) {
4109
4134
  this.manager.renderAxisBadges(e, t, n);
4110
4135
  }
4111
- }, K = class {
4136
+ }, G = class {
4112
4137
  listeners = /* @__PURE__ */ new Map();
4113
4138
  on(e, t) {
4114
4139
  let n = this.listeners.get(e);
@@ -4130,7 +4155,7 @@ var Et = class {
4130
4155
  removeAllListeners() {
4131
4156
  this.listeners.clear();
4132
4157
  }
4133
- }, Nt = class extends K {
4158
+ }, Ft = class extends G {
4134
4159
  currentBar = null;
4135
4160
  timeframeMs;
4136
4161
  tickRing;
@@ -4192,7 +4217,7 @@ var Et = class {
4192
4217
  alignToTimeframe(e) {
4193
4218
  return Math.floor(e / this.timeframeMs) * this.timeframeMs;
4194
4219
  }
4195
- }, q = class extends K {
4220
+ }, K = class extends G {
4196
4221
  config;
4197
4222
  attempt = 0;
4198
4223
  timer = null;
@@ -4239,7 +4264,7 @@ var Et = class {
4239
4264
  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
4265
  return Math.max(0, Math.round(n + r));
4241
4266
  }
4242
- }, Pt = class {
4267
+ }, It = class {
4243
4268
  price = null;
4244
4269
  previousClose = null;
4245
4270
  visible = !0;
@@ -4270,12 +4295,12 @@ var Et = class {
4270
4295
  let f = s - 5;
4271
4296
  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
4297
  }
4273
- }, Ft = class extends K {
4298
+ }, Lt = class extends G {
4274
4299
  config = null;
4275
4300
  adapter = null;
4276
4301
  aggregator = null;
4277
4302
  reconnector;
4278
- priceLine = new Pt();
4303
+ priceLine = new It();
4279
4304
  state = "disconnected";
4280
4305
  lastPrice = null;
4281
4306
  previousClose = null;
@@ -4283,13 +4308,13 @@ var Et = class {
4283
4308
  heartbeatTimer = null;
4284
4309
  lastMessageTime = 0;
4285
4310
  constructor() {
4286
- super(), this.reconnector = new q(), this.wireReconnector();
4311
+ super(), this.reconnector = new K(), this.wireReconnector();
4287
4312
  }
4288
4313
  async connect(e) {
4289
4314
  this.disconnect(), this.config = {
4290
4315
  ...i,
4291
4316
  ...e
4292
- }, this.adapter = e.adapter, this.aggregator = new Nt(e.timeframe), this.reconnector.removeAllListeners(), this.reconnector.stop(), this.reconnector = new q(e.reconnect ?? r), this.wireReconnector(), this.aggregator.on("bar", (e) => {
4317
+ }, this.adapter = e.adapter, this.aggregator = new Ft(e.timeframe), this.reconnector.removeAllListeners(), this.reconnector.stop(), this.reconnector = new K(e.reconnect ?? r), this.wireReconnector(), this.aggregator.on("bar", (e) => {
4293
4318
  this.emit("barUpdate", e), this.updatePrice(e.close);
4294
4319
  }), this.aggregator.on("barClose", (e) => {
4295
4320
  this.previousClose = e.close, this.emit("barClose", e);
@@ -4349,20 +4374,28 @@ var Et = class {
4349
4374
  });
4350
4375
  }
4351
4376
  wireAdapter() {
4352
- this.adapter && (this.adapter.on("connectionChange", ((e) => {
4377
+ if (!this.adapter) return;
4378
+ let e = this.adapter, t = (e) => {
4353
4379
  let t = e.data;
4354
4380
  this.lastMessageTime = Date.now(), t === "connected" ? (this.reconnector.onConnected(), this.setState("connected")) : (t === "disconnected" || t === "error") && this.reconnector.schedule(() => this.doConnect());
4355
- })), this.adapter.on("tick", ((e) => {
4381
+ };
4382
+ e.on("connectionChange", t), this.unsubscribers.push(() => e.off("connectionChange", t));
4383
+ let n = (e) => {
4356
4384
  this.lastMessageTime = Date.now();
4357
4385
  let t = e.data;
4358
4386
  this.emit("tick", t), this.config?.aggregateTicks && this.aggregator ? this.aggregator.processTick(t) : this.updatePrice(t.price);
4359
- })), this.adapter.on("bar", ((e) => {
4387
+ };
4388
+ e.on("tick", n), this.unsubscribers.push(() => e.off("tick", n));
4389
+ let r = (e) => {
4360
4390
  this.lastMessageTime = Date.now();
4361
4391
  let { bar: t, closed: n } = e.data;
4362
4392
  this.aggregator && this.aggregator.processBar(t, n);
4363
- })), this.adapter.on("error", ((e) => {
4393
+ };
4394
+ e.on("bar", r), this.unsubscribers.push(() => e.off("bar", r));
4395
+ let i = (e) => {
4364
4396
  this.emit("error", { message: e.data?.message ?? "Adapter error" });
4365
- })));
4397
+ };
4398
+ e.on("error", i), this.unsubscribers.push(() => e.off("error", i));
4366
4399
  }
4367
4400
  updatePrice(e) {
4368
4401
  e !== this.lastPrice && (this.lastPrice = e, this.priceLine.setPrice(e, this.previousClose ?? void 0), this.emit("priceChange", {
@@ -4391,7 +4424,7 @@ var Et = class {
4391
4424
  dispose() {
4392
4425
  this.disconnect(), this.removeAllListeners();
4393
4426
  }
4394
- }, It = {
4427
+ }, Rt = {
4395
4428
  "1s": "1s",
4396
4429
  "1m": "1m",
4397
4430
  "3m": "3m",
@@ -4408,7 +4441,7 @@ var Et = class {
4408
4441
  "3d": "3d",
4409
4442
  "1w": "1w",
4410
4443
  "1M": "1M"
4411
- }, Lt = class {
4444
+ }, zt = class {
4412
4445
  name = "binance";
4413
4446
  ws = null;
4414
4447
  state = "disconnected";
@@ -4429,7 +4462,7 @@ var Et = class {
4429
4462
  return this.state;
4430
4463
  }
4431
4464
  async fetchHistory(e, t, n = 500) {
4432
- let r = It[t] ?? "15m", i = `${this.restBase}/klines?symbol=${e}&interval=${r}&limit=${n}`, a = await fetch(i);
4465
+ let r = Rt[t] ?? "15m", i = `${this.restBase}/klines?symbol=${e}&interval=${r}&limit=${n}`, a = await fetch(i);
4433
4466
  if (!a.ok) throw Error(`Binance REST error: ${a.status}`);
4434
4467
  return (await a.json()).map((e) => ({
4435
4468
  time: e[0],
@@ -4452,7 +4485,7 @@ var Et = class {
4452
4485
  }
4453
4486
  connectWs() {
4454
4487
  if (!this.config) return;
4455
- let e = `${this.config.symbol.toLowerCase()}@kline_${It[this.config.timeframe] ?? "15m"}`, t = `${this.wsBase}/${e}`;
4488
+ let e = `${this.config.symbol.toLowerCase()}@kline_${Rt[this.config.timeframe] ?? "15m"}`, t = `${this.wsBase}/${e}`;
4456
4489
  this.setState("connecting");
4457
4490
  try {
4458
4491
  this.ws = new WebSocket(t);
@@ -4505,7 +4538,7 @@ var Et = class {
4505
4538
  for (let e of n) e(r);
4506
4539
  }
4507
4540
  }
4508
- }, Rt = class {
4541
+ }, Bt = class {
4509
4542
  name = "mock";
4510
4543
  state = "disconnected";
4511
4544
  listeners = /* @__PURE__ */ new Map();
@@ -4600,7 +4633,7 @@ var Et = class {
4600
4633
  for (let e of n) e(r);
4601
4634
  }
4602
4635
  }
4603
- }, zt = {
4636
+ }, Vt = {
4604
4637
  visible: !0,
4605
4638
  showSymbol: !0,
4606
4639
  showOHLC: !0,
@@ -4608,12 +4641,13 @@ var Et = class {
4608
4641
  showVolume: !0,
4609
4642
  position: "top-left",
4610
4643
  fontSize: 12
4611
- }, Bt = class {
4612
- config = { ...zt };
4644
+ }, Ht = class {
4645
+ config = { ...Vt };
4613
4646
  symbol = "";
4614
4647
  timeframe = "";
4615
4648
  hoverBar = null;
4616
4649
  indicators = [];
4650
+ statusText = null;
4617
4651
  setConfig(e) {
4618
4652
  Object.assign(this.config, e);
4619
4653
  }
@@ -4630,14 +4664,17 @@ var Et = class {
4630
4664
  setIndicatorValues(e) {
4631
4665
  this.indicators = e;
4632
4666
  }
4667
+ setStatusText(e) {
4668
+ this.statusText = e;
4669
+ }
4633
4670
  render(e, t, n, r) {
4634
4671
  if (!this.config.visible || r.length === 0) return;
4635
4672
  let i = this.hoverBar ?? r[r.length - 1], a = r.length > 1 ? r[r.length - 2] : i, { chartRect: o } = t, s = this.config.fontSize, c = this.config.position === "top-left", l = c ? o.x + 8 : o.x + o.width - 8, u = o.y + 6;
4636
4673
  if (e.textAlign = c ? "left" : "right", e.textBaseline = "top", this.config.showSymbol) {
4637
4674
  e.font = `bold ${s + 2}px ${n.font.family}`, e.fillStyle = n.text;
4638
- let t = [this.symbol, this.timeframe].filter(Boolean).join(" · ");
4639
- e.fillText(t, l, u), u += s + 6;
4640
- }
4675
+ let t = [this.symbol, this.timeframe].filter(Boolean).join(" · "), r = this.statusText ? `${t} ${this.statusText}` : t;
4676
+ e.fillText(r, l, u), u += s + 6;
4677
+ } else this.statusText && (e.font = `${s}px ${n.font.family}`, e.fillStyle = n.textSecondary, e.fillText(this.statusText, l, u), u += s + 4);
4641
4678
  if (this.config.showOHLC) {
4642
4679
  e.font = `${s}px ${n.font.family}`;
4643
4680
  let t = i.close >= i.open, r = (e) => e.toLocaleString(void 0, {
@@ -4696,7 +4733,7 @@ var Et = class {
4696
4733
  }
4697
4734
  }
4698
4735
  }
4699
- }, Vt = class {
4736
+ }, Ut = class {
4700
4737
  static toDataURL(e, t) {
4701
4738
  let n = e.querySelectorAll("canvas");
4702
4739
  if (n.length === 0) return "";
@@ -4718,7 +4755,7 @@ var Et = class {
4718
4755
  let i = document.createElement("a");
4719
4756
  i.href = r, i.download = t, document.body.appendChild(i), i.click(), document.body.removeChild(i);
4720
4757
  }
4721
- }, Ht = class {
4758
+ }, Wt = class {
4722
4759
  config = null;
4723
4760
  setConfig(e) {
4724
4761
  this.config = e;
@@ -4728,7 +4765,7 @@ var Et = class {
4728
4765
  let { chartRect: r } = t, i = this.config.fontSize ?? 48, a = this.config.color ?? n.textSecondary;
4729
4766
  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
4767
  }
4731
- }, Ut = class {
4768
+ }, Gt = class {
4732
4769
  visible = !0;
4733
4770
  timeframeMs = 0;
4734
4771
  setVisible(e) {
@@ -4751,7 +4788,7 @@ var Et = class {
4751
4788
  let t = Math.ceil(e / 1e3), n = Math.floor(t / 3600), r = Math.floor(t % 3600 / 60), i = t % 60;
4752
4789
  return n > 0 ? `${n}:${String(r).padStart(2, "0")}:${String(i).padStart(2, "0")}` : `${r}:${String(i).padStart(2, "0")}`;
4753
4790
  }
4754
- }, Wt = class {
4791
+ }, Kt = class {
4755
4792
  config = { visible: !1 };
4756
4793
  cachedBreaks = [];
4757
4794
  lastDataLength = 0;
@@ -4795,7 +4832,7 @@ var Et = class {
4795
4832
  invalidateCache() {
4796
4833
  this.lastDataLength = 0, this.cachedBreaks = [];
4797
4834
  }
4798
- }, Gt = 1, Kt = class extends K {
4835
+ }, qt = 1, Jt = class extends G {
4799
4836
  alerts = [];
4800
4837
  lastPrice = null;
4801
4838
  requestRender = null;
@@ -4807,7 +4844,7 @@ var Et = class {
4807
4844
  this.pricePrecision = e;
4808
4845
  }
4809
4846
  addAlert(e, t = "crossing", n, r = !1) {
4810
- let i = `tc_alert_${Gt++}`, a = {
4847
+ let i = `tc_alert_${qt++}`, a = {
4811
4848
  id: i,
4812
4849
  price: e,
4813
4850
  condition: t,
@@ -4887,7 +4924,7 @@ var Et = class {
4887
4924
  e.fillText(s, r.x + r.width - 4, a - 2);
4888
4925
  }
4889
4926
  }
4890
- }, qt = class extends K {
4927
+ }, Yt = class extends G {
4891
4928
  data = [];
4892
4929
  currentIndex = 0;
4893
4930
  timer = null;
@@ -4941,10 +4978,10 @@ var Et = class {
4941
4978
  dispose() {
4942
4979
  this.stop(), this.removeAllListeners(), this.data = [];
4943
4980
  }
4944
- }, J = 1, Jt = class {
4981
+ }, q = 1, Xt = class {
4945
4982
  static capture(e, t) {
4946
4983
  return {
4947
- version: J,
4984
+ version: q,
4948
4985
  timestamp: Date.now(),
4949
4986
  chartType: t?.chartType ?? "candlestick",
4950
4987
  symbol: t?.symbol,
@@ -4967,7 +5004,7 @@ var Et = class {
4967
5004
  }
4968
5005
  static deserialize(e) {
4969
5006
  let t = JSON.parse(e);
4970
- return t.version !== J && console.warn(`Chart state version mismatch: ${t.version} vs ${J}`), t;
5007
+ return t.version !== q && console.warn(`Chart state version mismatch: ${t.version} vs ${q}`), t;
4971
5008
  }
4972
5009
  static saveToStorage(e, t) {
4973
5010
  localStorage.setItem(e, this.serialize(t));
@@ -4994,7 +5031,7 @@ var Et = class {
4994
5031
  }, n.click();
4995
5032
  });
4996
5033
  }
4997
- }, Yt = class {
5034
+ }, Zt = class {
4998
5035
  undoStack = [];
4999
5036
  redoStack = [];
5000
5037
  maxHistory = 50;
@@ -5030,7 +5067,7 @@ var Et = class {
5030
5067
  redoCount: this.redoStack.length
5031
5068
  };
5032
5069
  }
5033
- }, Xt = class {
5070
+ }, Qt = class {
5034
5071
  static toCSV(e) {
5035
5072
  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
5073
  }
@@ -5048,7 +5085,7 @@ var Et = class {
5048
5085
  let r = new Blob([e], { type: n }), i = URL.createObjectURL(r), a = document.createElement("a");
5049
5086
  a.href = i, a.download = t, document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
5050
5087
  }
5051
- }, Zt = {
5088
+ }, $t = {
5052
5089
  linear: (e) => e,
5053
5090
  easeOutCubic: (e) => 1 - (1 - e) ** 3,
5054
5091
  easeOutQuart: (e) => 1 - (1 - e) ** 4,
@@ -5056,7 +5093,7 @@ var Et = class {
5056
5093
  easeOutExpo: (e) => e === 1 ? 1 : 1 - 2 ** (-10 * e),
5057
5094
  easeOutElastic: (e) => e === 0 || e === 1 ? e : 2 ** (-10 * e) * Math.sin((e * 10 - .75) * (2 * Math.PI / 3)) + 1,
5058
5095
  spring: (e) => 1 - Math.E ** (-6 * e) * Math.cos(8 * e)
5059
- }, Qt = class {
5096
+ }, en = class {
5060
5097
  animations = /* @__PURE__ */ new Map();
5061
5098
  frameId = 0;
5062
5099
  running = !1;
@@ -5064,7 +5101,7 @@ var Et = class {
5064
5101
  this.animations.set(e, {
5065
5102
  startTime: -1,
5066
5103
  duration: t.duration,
5067
- easing: t.easing ?? Zt.easeOutCubic,
5104
+ easing: t.easing ?? $t.easeOutCubic,
5068
5105
  onUpdate: t.onUpdate,
5069
5106
  onComplete: t.onComplete
5070
5107
  }), this.running || (this.running = !0, this.tick());
@@ -5099,10 +5136,10 @@ var Et = class {
5099
5136
  };
5100
5137
  //#endregion
5101
5138
  //#region src/finance/BaseFinanceChart.ts
5102
- function $t(t) {
5139
+ function tn(t) {
5103
5140
  return !t || t === "dark" ? e : t === "light" ? o : t;
5104
5141
  }
5105
- var en = class {
5142
+ var nn = class {
5106
5143
  canvas;
5107
5144
  ctx;
5108
5145
  container;
@@ -5113,7 +5150,7 @@ var en = class {
5113
5150
  frameId = null;
5114
5151
  resizeObserver;
5115
5152
  constructor(e, t) {
5116
- this.container = e, this.theme = $t(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(() => {
5153
+ this.container = e, this.theme = tn(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
5154
  this.updateSize(), this.requestRender();
5118
5155
  }), this.resizeObserver.observe(e);
5119
5156
  }
@@ -5128,12 +5165,12 @@ var en = class {
5128
5165
  }));
5129
5166
  }
5130
5167
  setTheme(e) {
5131
- this.theme = $t(e), this.requestRender();
5168
+ this.theme = tn(e), this.requestRender();
5132
5169
  }
5133
5170
  destroy() {
5134
5171
  this.frameId !== null && cancelAnimationFrame(this.frameId), this.resizeObserver.disconnect(), this.canvas.remove();
5135
5172
  }
5136
- }, tn = class {
5173
+ }, rn = class {
5137
5174
  pos = null;
5138
5175
  canvas;
5139
5176
  onUpdate;
@@ -5165,7 +5202,7 @@ var en = class {
5165
5202
  };
5166
5203
  //#endregion
5167
5204
  //#region src/finance/SparklineRenderer.ts
5168
- function nn(e, t, n, r, i) {
5205
+ function an(e, t, n, r, i) {
5169
5206
  let { data: a, mode: o = "area", lineWidth: s = 1.5, showLastPoint: c = !1, showMinMax: l = !1 } = r;
5170
5207
  if (a.length < 2 || t <= 0 || n <= 0) return;
5171
5208
  let u = r.color ?? i.lineColor, d = r.fillColor ?? u, f = t - 4, p = n - 4, m = Infinity, h = -Infinity, g = 0, _ = 0;
@@ -5190,8 +5227,8 @@ function nn(e, t, n, r, i) {
5190
5227
  }
5191
5228
  //#endregion
5192
5229
  //#region src/finance/DepthChartRenderer.ts
5193
- var rn = 50, an = 60, Y = 20, on = .2;
5194
- function sn(e) {
5230
+ var on = 50, sn = 60, J = 20, cn = .2;
5231
+ function ln(e) {
5195
5232
  let t = [...e].sort((e, t) => t.price - e.price), n = [], r = 0;
5196
5233
  for (let e of t) r += e.volume, n.push({
5197
5234
  price: e.price,
@@ -5199,7 +5236,7 @@ function sn(e) {
5199
5236
  });
5200
5237
  return n;
5201
5238
  }
5202
- function cn(e) {
5239
+ function un(e) {
5203
5240
  let t = [...e].sort((e, t) => e.price - t.price), n = [], r = 0;
5204
5241
  for (let e of t) r += e.volume, n.push({
5205
5242
  price: e.price,
@@ -5207,20 +5244,20 @@ function cn(e) {
5207
5244
  });
5208
5245
  return n;
5209
5246
  }
5210
- function ln(e, t) {
5247
+ function dn(e, t) {
5211
5248
  return {
5212
- left: rn,
5213
- right: e - an,
5214
- top: Y,
5215
- bottom: t - Y,
5216
- plotWidth: e - rn - an,
5217
- plotHeight: t - Y * 2
5249
+ left: on,
5250
+ right: e - sn,
5251
+ top: J,
5252
+ bottom: t - J,
5253
+ plotWidth: e - on - sn,
5254
+ plotHeight: t - J * 2
5218
5255
  };
5219
5256
  }
5220
- function un(e, t, n, r) {
5257
+ function fn(e, t, n, r) {
5221
5258
  e.fillStyle = r, e.fillRect(0, 0, t, n);
5222
5259
  }
5223
- function dn(e, t, n, r, i, a, o, s) {
5260
+ function pn(e, t, n, r, i, a, o, s) {
5224
5261
  let { left: c, right: l, top: u, bottom: d, plotWidth: p, plotHeight: m } = t;
5225
5262
  e.save(), e.strokeStyle = a.grid, e.lineWidth = .5, e.fillStyle = a.axisLabel, e.font = `${a.font.sizeSmall}px ${a.font.family}`;
5226
5263
  let h = f(0, i, 5);
@@ -5235,7 +5272,7 @@ function dn(e, t, n, r, i, a, o, s) {
5235
5272
  }
5236
5273
  e.restore();
5237
5274
  }
5238
- function fn(e, t, n, r, i, a, o, s, c) {
5275
+ function mn(e, t, n, r, i, a, o, s, c) {
5239
5276
  if (t.length === 0) return;
5240
5277
  let { left: l, bottom: u, plotWidth: d, plotHeight: f } = n, p = (e) => l + (e - r) / i * d, m = (e) => u - e / a * f;
5241
5278
  if (e.beginPath(), c === "bid") {
@@ -5268,14 +5305,14 @@ function fn(e, t, n, r, i, a, o, s, c) {
5268
5305
  }
5269
5306
  e.strokeStyle = s, e.lineWidth = 1.5, e.stroke();
5270
5307
  }
5271
- function pn(e, t, n, r, i, a, o, s, c) {
5308
+ function hn(e, t, n, r, i, a, o, s, c) {
5272
5309
  let { left: l, top: u, bottom: d, plotWidth: f } = r, p = l + (t - i) / a * f;
5273
5310
  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) {
5274
5311
  let t = `Spread: ${c(n)}`;
5275
5312
  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();
5276
5313
  }
5277
5314
  }
5278
- function mn(e, t, n, r, i, a, o, s, c, l, u) {
5315
+ function gn(e, t, n, r, i, a, o, s, c, l, u) {
5279
5316
  let { left: d, top: f, bottom: p, plotWidth: m, plotHeight: h } = i, g = t.x;
5280
5317
  if (g < d || g > i.right) return;
5281
5318
  let _ = a + (g - d) / m * o, v = 0, y = "";
@@ -5301,47 +5338,47 @@ function mn(e, t, n, r, i, a, o, s, c, l, u) {
5301
5338
  for (let t = 0; t < b.length; t++) e.fillText(b[t], C + 8, w + 6 + t * (c.font.sizeSmall + 4));
5302
5339
  e.restore();
5303
5340
  }
5304
- function hn(e) {
5341
+ function _n(e) {
5305
5342
  return e.toFixed(2);
5306
5343
  }
5307
- function gn(e) {
5344
+ function vn(e) {
5308
5345
  return e >= 1e6 ? (e / 1e6).toFixed(2) + "M" : e >= 1e3 ? (e / 1e3).toFixed(1) + "K" : e.toFixed(0);
5309
5346
  }
5310
- function _n(e, t, n, r, i, a) {
5347
+ function yn(e, t, n, r, i, a) {
5311
5348
  let { data: o } = r;
5312
5349
  if (o.bids.length === 0 && o.asks.length === 0 || t <= 0 || n <= 0) return;
5313
- 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 ?? hn, m = r.volumeFormat ?? gn, h = sn(o.bids), g = cn(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 + on), 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 = ln(t, n);
5314
- un(e, t, n, i.background), dn(e, A, w, T, k, i, p, m), fn(e, h, A, w, E, k, l, s, "bid"), fn(e, g, A, w, E, k, u, c, "ask"), d && pn(e, y, b, A, w, E, i, f, p), a && mn(e, a, h, g, A, w, E, k, i, p, m);
5350
+ 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 ?? _n, m = r.volumeFormat ?? vn, h = ln(o.bids), g = un(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 + cn), 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 = dn(t, n);
5351
+ fn(e, t, n, i.background), pn(e, A, w, T, k, i, p, m), mn(e, h, A, w, E, k, l, s, "bid"), mn(e, g, A, w, E, k, u, c, "ask"), d && hn(e, y, b, A, w, E, i, f, p), a && gn(e, a, h, g, A, w, E, k, i, p, m);
5315
5352
  }
5316
5353
  //#endregion
5317
5354
  //#region src/finance/EquityCurveRenderer.ts
5318
- var vn = 70, yn = 30, bn = 20, xn = 20, Sn = .05;
5319
- function Cn(e, t) {
5355
+ var bn = 70, xn = 30, Sn = 20, Cn = 20, wn = .05;
5356
+ function Tn(e, t) {
5320
5357
  return {
5321
- left: vn,
5322
- right: e - bn,
5323
- top: xn,
5324
- bottom: t - yn,
5325
- plotWidth: e - vn - bn,
5326
- plotHeight: t - xn - yn
5358
+ left: bn,
5359
+ right: e - Sn,
5360
+ top: Cn,
5361
+ bottom: t - xn,
5362
+ plotWidth: e - bn - Sn,
5363
+ plotHeight: t - Cn - xn
5327
5364
  };
5328
5365
  }
5329
- function wn(e, t) {
5366
+ function En(e, t) {
5330
5367
  let n = Infinity, r = -Infinity;
5331
5368
  for (let t of e) t.value < n && (n = t.value), t.value > r && (r = t.value);
5332
5369
  if (t) for (let e of t) e.value < n && (n = e.value), e.value > r && (r = e.value);
5333
- let i = (r - n) * Sn;
5370
+ let i = (r - n) * wn;
5334
5371
  return {
5335
5372
  valMin: n - i,
5336
5373
  valMax: r + i
5337
5374
  };
5338
5375
  }
5339
- function Tn(e) {
5376
+ function Dn(e) {
5340
5377
  let t = [], n = -Infinity;
5341
5378
  for (let r of e) r.value > n && (n = r.value), t.push(n);
5342
5379
  return t;
5343
5380
  }
5344
- function En(e) {
5381
+ function On(e) {
5345
5382
  let t = 864e5;
5346
5383
  if (365.25 * t, e < 7 * t) {
5347
5384
  let e = new Intl.DateTimeFormat(void 0, {
@@ -5363,13 +5400,13 @@ function En(e) {
5363
5400
  });
5364
5401
  return (e) => n.format(new Date(e));
5365
5402
  }
5366
- function Dn(e) {
5403
+ function kn(e) {
5367
5404
  return Math.abs(e) >= 1e6 ? (e / 1e6).toFixed(2) + "M" : Math.abs(e) >= 1e3 ? (e / 1e3).toFixed(1) + "K" : e.toFixed(2);
5368
5405
  }
5369
- function On(e, t, n, r) {
5406
+ function An(e, t, n, r) {
5370
5407
  e.fillStyle = r, e.fillRect(0, 0, t, n);
5371
5408
  }
5372
- function kn(e, t, n, r, i, a, o, s, c) {
5409
+ function jn(e, t, n, r, i, a, o, s, c) {
5373
5410
  let { left: l, right: u, top: d, bottom: p, plotWidth: m, plotHeight: h } = t;
5374
5411
  e.save(), e.strokeStyle = o.grid, e.lineWidth = .5, e.fillStyle = o.axisLabel, e.font = `${o.font.sizeSmall}px ${o.font.family}`;
5375
5412
  let g = f(n, r, 6), _ = Math.ceil(n / g) * g;
@@ -5384,21 +5421,21 @@ function kn(e, t, n, r, i, a, o, s, c) {
5384
5421
  }
5385
5422
  e.restore();
5386
5423
  }
5387
- function An(e, t, n, r, i, a, o, s, c) {
5424
+ function Mn(e, t, n, r, i, a, o, s, c) {
5388
5425
  if (t.length < 2) return;
5389
5426
  let { left: l, bottom: u, plotWidth: d, plotHeight: f } = n, p = (e) => l + (e - r) / i * d, m = (e) => u - (e - a) / o * f;
5390
5427
  e.save(), e.beginPath(), e.moveTo(p(t[0].time), m(t[0].value));
5391
5428
  for (let n = 1; n < t.length; n++) e.lineTo(p(t[n].time), m(t[n].value));
5392
5429
  e.strokeStyle = s, e.lineWidth = c, e.lineJoin = "round", e.stroke(), e.restore();
5393
5430
  }
5394
- function jn(e, t, n, r, i, a, o, s) {
5431
+ function Nn(e, t, n, r, i, a, o, s) {
5395
5432
  if (t.length < 2) return;
5396
5433
  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);
5397
5434
  m.addColorStop(0, s + "40"), m.addColorStop(1, "transparent"), e.save(), e.beginPath(), e.moveTo(f(t[0].time), p(t[0].value));
5398
5435
  for (let n = 1; n < t.length; n++) e.lineTo(f(t[n].time), p(t[n].value));
5399
5436
  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();
5400
5437
  }
5401
- function Mn(e, t, n, r, i, a, o, s, c) {
5438
+ function Pn(e, t, n, r, i, a, o, s, c) {
5402
5439
  if (t.length < 2) return;
5403
5440
  let { left: l, bottom: u, plotWidth: d, plotHeight: f } = r, p = (e) => l + (e - i) / a * d, m = (e) => u - (e - o) / s * f;
5404
5441
  e.save(), e.fillStyle = c, e.beginPath(), e.moveTo(p(t[0].time), m(n[0]));
@@ -5406,12 +5443,12 @@ function Mn(e, t, n, r, i, a, o, s, c) {
5406
5443
  for (let n = t.length - 1; n >= 0; n--) e.lineTo(p(t[n].time), m(t[n].value));
5407
5444
  e.closePath(), e.fill(), e.restore();
5408
5445
  }
5409
- function Nn(e, t, n, r, i, a, o, s, c, l) {
5446
+ function Fn(e, t, n, r, i, a, o, s, c, l) {
5410
5447
  if (t.length === 0) return;
5411
5448
  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;
5412
5449
  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();
5413
5450
  }
5414
- function Pn(e, t, n, r, i, a, o, s, c, l, u, d) {
5451
+ function In(e, t, n, r, i, a, o, s, c, l, u, d) {
5415
5452
  let { left: f, top: p, bottom: m, plotWidth: h, plotHeight: g } = i, _ = t.x;
5416
5453
  if (_ < f || _ > i.right) return;
5417
5454
  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();
@@ -5429,15 +5466,15 @@ function Pn(e, t, n, r, i, a, o, s, c, l, u, d) {
5429
5466
  for (let t = 0; t < S.length; t++) e.fillText(S[t], D + 8, O + 6 + t * (l.font.sizeSmall + 4));
5430
5467
  e.restore();
5431
5468
  }
5432
- function Fn(e, t, n, r, i, a) {
5469
+ function Ln(e, t, n, r, i, a) {
5433
5470
  let { data: o } = r;
5434
5471
  if (o.length < 2 || t <= 0 || n <= 0) return;
5435
- 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 ?? Dn, { valMin: g, valMax: _ } = wn(o, f), v = _ - g || 1, y = o[0].time, b = o[o.length - 1].time, x = b - y || 1, S = r.timeFormat ?? En(x), C = Cn(t, n);
5436
- On(e, t, n, i.background), kn(e, C, g, _, y, b, i, h, S), l && Mn(e, o, Tn(o), C, y, x, g, v, u), d && jn(e, o, C, y, x, g, v, s), An(e, o, C, y, x, g, v, s, c), f && f.length >= 2 && (An(e, f, C, y, x, g, v, p, 1), Nn(e, f, C, y, x, g, v, m, p, i)), a && Pn(e, a, o, f, C, y, x, g, v, i, S, h);
5472
+ 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 ?? kn, { valMin: g, valMax: _ } = En(o, f), v = _ - g || 1, y = o[0].time, b = o[o.length - 1].time, x = b - y || 1, S = r.timeFormat ?? On(x), C = Tn(t, n);
5473
+ An(e, t, n, i.background), jn(e, C, g, _, y, b, i, h, S), l && Pn(e, o, Dn(o), C, y, x, g, v, u), d && Nn(e, o, C, y, x, g, v, s), Mn(e, o, C, y, x, g, v, s, c), f && f.length >= 2 && (Mn(e, f, C, y, x, g, v, p, 1), Fn(e, f, C, y, x, g, v, m, p, i)), a && In(e, a, o, f, C, y, x, g, v, i, S, h);
5437
5474
  }
5438
5475
  //#endregion
5439
5476
  //#region src/finance/HeatmapLayout.ts
5440
- function In(e, t, n) {
5477
+ function Rn(e, t, n) {
5441
5478
  if (e.length === 0) return [];
5442
5479
  let r = e.length, i = Math.ceil(Math.sqrt(r)), a = Math.ceil(r / i), o = t.width / i, s = t.height / a, c = [];
5443
5480
  for (let a = 0; a < r; a++) {
@@ -5454,7 +5491,7 @@ function In(e, t, n) {
5454
5491
  }
5455
5492
  return c;
5456
5493
  }
5457
- function Ln(e, t) {
5494
+ function zn(e, t) {
5458
5495
  let n = e.reduce((e, t) => e + t, 0);
5459
5496
  if (n === 0 || t === 0) return Infinity;
5460
5497
  let r = 0;
@@ -5464,7 +5501,7 @@ function Ln(e, t) {
5464
5501
  }
5465
5502
  return r;
5466
5503
  }
5467
- function X(e, t, n, r, i, a) {
5504
+ function Y(e, t, n, r, i, a) {
5468
5505
  let o = r ? n.height : n.width, s = e.reduce((e, t) => e + t, 0), c = o > 0 ? s / o : 0, l = 0;
5469
5506
  for (let o = 0; o < e.length; o++) {
5470
5507
  let s = c > 0 ? e[o] / c : 0, u;
@@ -5484,19 +5521,19 @@ function X(e, t, n, r, i, a) {
5484
5521
  }), l += s;
5485
5522
  }
5486
5523
  }
5487
- function Rn(e, t, n, r, i) {
5524
+ function Bn(e, t, n, r, i) {
5488
5525
  if (e.length === 0) return;
5489
5526
  let a = n.width >= n.height, o = a ? n.height : n.width;
5490
5527
  if (e.length === 1) {
5491
- X(e, t, n, a, r, i);
5528
+ Y(e, t, n, a, r, i);
5492
5529
  return;
5493
5530
  }
5494
5531
  let s = [], c = [], l = 0;
5495
5532
  for (; l < e.length;) {
5496
5533
  let u = [...s, e[l]];
5497
- if (s.length === 0 || Ln(u, o) <= Ln(s, o)) s.push(e[l]), c.push(t[l]), l++;
5534
+ if (s.length === 0 || zn(u, o) <= zn(s, o)) s.push(e[l]), c.push(t[l]), l++;
5498
5535
  else {
5499
- X(s, c, n, a, r, i);
5536
+ Y(s, c, n, a, r, i);
5500
5537
  let u = s.reduce((e, t) => e + t, 0), d = o > 0 ? u / o : 0;
5501
5538
  n = a ? {
5502
5539
  x: n.x + d,
@@ -5508,28 +5545,28 @@ function Rn(e, t, n, r, i) {
5508
5545
  y: n.y + d,
5509
5546
  width: n.width,
5510
5547
  height: n.height - d
5511
- }, Rn(e.slice(l), t.slice(l), n, r, i);
5548
+ }, Bn(e.slice(l), t.slice(l), n, r, i);
5512
5549
  return;
5513
5550
  }
5514
5551
  }
5515
- s.length > 0 && X(s, c, n, a, r, i);
5552
+ s.length > 0 && Y(s, c, n, a, r, i);
5516
5553
  }
5517
- function zn(e, t, n) {
5554
+ function Vn(e, t, n) {
5518
5555
  if (e.length === 0) return [];
5519
5556
  let r = [...e].sort((e, t) => t.weight - e.weight), i = r.reduce((e, t) => e + Math.max(0, t.weight), 0);
5520
5557
  if (i === 0) return [];
5521
5558
  let a = t.width * t.height, o = r.map((e) => Math.max(0, e.weight) / i * a), s = r.map((e) => e.id), c = [];
5522
- return Rn(o, s, { ...t }, n, c), c;
5559
+ return Bn(o, s, { ...t }, n, c), c;
5523
5560
  }
5524
5561
  //#endregion
5525
5562
  //#region src/finance/HeatmapRenderer.ts
5526
- function Bn(e) {
5563
+ function Hn(e) {
5527
5564
  return (e >= 0 ? "+" : "") + e.toFixed(2) + "%";
5528
5565
  }
5529
- function Vn(e) {
5566
+ function Un(e) {
5530
5567
  return e.label;
5531
5568
  }
5532
- function Hn(e, t) {
5569
+ function Wn(e, t) {
5533
5570
  let n = t.min ?? -5, r = t.max ?? 5;
5534
5571
  if (e <= n) return t.negative;
5535
5572
  if (e >= r) return t.positive;
@@ -5540,11 +5577,11 @@ function Hn(e, t) {
5540
5577
  let i = e / r;
5541
5578
  return m(t.zero, t.positive, i);
5542
5579
  }
5543
- function Z(e, t, n, r, i, a) {
5580
+ function X(e, t, n, r, i, a) {
5544
5581
  let o = Math.min(a, r / 2, i / 2);
5545
5582
  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();
5546
5583
  }
5547
- function Un(e, t, n, r, i, a, o, s, c, l, u) {
5584
+ function Gn(e, t, n, r, i, a, o, s, c, l, u) {
5548
5585
  if (i < 40 || a < 30) return;
5549
5586
  let d = n + i / 2, f = r + a / 2;
5550
5587
  if (e.save(), e.shadowColor = "rgba(0,0,0,0.6)", e.shadowBlur = 2, e.fillStyle = "#FFFFFF", e.textAlign = "center", s) {
@@ -5557,22 +5594,22 @@ function Un(e, t, n, r, i, a, o, s, c, l, u) {
5557
5594
  }
5558
5595
  e.restore();
5559
5596
  }
5560
- function Wn(e, t, n, r, i, a, o, s) {
5597
+ function Kn(e, t, n, r, i, a, o, s) {
5561
5598
  let c = [o(t), s(t.value)];
5562
5599
  if (t.meta) for (let [e, n] of Object.entries(t.meta)) c.push(e + ": " + String(n));
5563
5600
  e.save(), e.font = a.font.sizeSmall + "px " + a.font.family;
5564
5601
  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;
5565
- 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, Z(e, f, p, l, d, 4), e.fill(), e.globalAlpha = 1, e.fillStyle = a.text, e.textBaseline = "top", e.textAlign = "left";
5602
+ 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, X(e, f, p, l, d, 4), e.fill(), e.globalAlpha = 1, e.fillStyle = a.text, e.textBaseline = "top", e.textAlign = "left";
5566
5603
  for (let t = 0; t < c.length; t++) e.fillText(c[t], f + 8, p + 6 + t * u);
5567
5604
  e.restore();
5568
5605
  }
5569
- function Gn(e, t, n, r, i, a, o, s) {
5606
+ function qn(e, t, n, r, i, a, o, s) {
5570
5607
  if (r.length === 0 || i.length === 0 || t <= 0 || n <= 0) return null;
5571
5608
  let c = a.colorScale ?? {
5572
5609
  negative: "#EF5350",
5573
5610
  zero: "#424242",
5574
5611
  positive: "#26A69A"
5575
- }, l = a.cellRadius ?? 4, u = a.showLabels !== !1, d = a.showValues !== !1, f = a.valueFormat ?? Bn, p = a.labelFormat ?? Vn, m = /* @__PURE__ */ new Map();
5612
+ }, l = a.cellRadius ?? 4, u = a.showLabels !== !1, d = a.showValues !== !1, f = a.valueFormat ?? Hn, p = a.labelFormat ?? Un, m = /* @__PURE__ */ new Map();
5576
5613
  for (let e of r) m.set(e.id, e);
5577
5614
  let h = null, g = null;
5578
5615
  if (s) for (let e of i) {
@@ -5593,37 +5630,37 @@ function Gn(e, t, n, r, i, a, o, s) {
5593
5630
  if (!n) continue;
5594
5631
  let { x: r, y: i, width: a, height: s } = t.rect;
5595
5632
  if (a <= 0 || s <= 0) continue;
5596
- let g = Hn(n.value, c);
5597
- Z(e, r, i, a, s, l), e.fillStyle = g, e.fill(), Un(e, n, r, i, a, s, o, u, d, p, f), t.id === h && (Z(e, r, i, a, s, l), e.strokeStyle = "#FFFFFF", e.lineWidth = 1.5, e.stroke());
5633
+ let g = Wn(n.value, c);
5634
+ X(e, r, i, a, s, l), e.fillStyle = g, e.fill(), Gn(e, n, r, i, a, s, o, u, d, p, f), t.id === h && (X(e, r, i, a, s, l), e.strokeStyle = "#FFFFFF", e.lineWidth = 1.5, e.stroke());
5598
5635
  }
5599
- return g && s && Wn(e, g.cell, s, t, n, o, p, f), g;
5636
+ return g && s && Kn(e, g.cell, s, t, n, o, p, f), g;
5600
5637
  }
5601
5638
  //#endregion
5602
5639
  //#region src/finance/WaterfallRenderer.ts
5603
- var Kn = 60, qn = 12, Jn = 24, Yn = 40, Xn = .7, Zn = 1;
5604
- function Qn(e) {
5640
+ var Jn = 60, Z = 12, Yn = 24, Xn = 40, Zn = .7, Qn = 1;
5641
+ function $n(e) {
5605
5642
  return e.type ? e.type : e.value > 0 ? "positive" : e.value < 0 ? "negative" : "subtotal";
5606
5643
  }
5607
- function $n(e) {
5644
+ function er(e) {
5608
5645
  let t = Math.abs(e);
5609
5646
  return t >= 1e6 ? (e / 1e6).toFixed(2) + "M" : t >= 1e3 ? (e / 1e3).toFixed(1) + "K" : e.toFixed(2);
5610
5647
  }
5611
- function er(e, t) {
5648
+ function tr(e, t) {
5612
5649
  return {
5613
- left: Kn,
5614
- right: e - qn,
5615
- top: Jn,
5616
- bottom: t - Yn,
5617
- plotWidth: e - Kn - qn,
5618
- plotHeight: t - Jn - Yn
5650
+ left: Jn,
5651
+ right: e - Z,
5652
+ top: Yn,
5653
+ bottom: t - Xn,
5654
+ plotWidth: e - Jn - Z,
5655
+ plotHeight: t - Yn - Xn
5619
5656
  };
5620
5657
  }
5621
- function tr(e, t, n, r, i) {
5658
+ function nr(e, t, n, r, i) {
5622
5659
  let a = Array(e.length), o = Array(e.length), s = t.plotWidth / e.length, c = s * n, l = (s - c) / 2, { left: u, bottom: d, plotHeight: f } = t, p = 0;
5623
5660
  for (let t = 0; t < e.length; t++) {
5624
- let n = e[t], m = Qn(n), h, g;
5661
+ let n = e[t], m = $n(n), h, g;
5625
5662
  m === "total" || m === "subtotal" ? (h = 0, g = n.value, p = n.value) : (h = p, g = p + n.value, p = g);
5626
- let _ = Math.min(h, g), v = Math.max(h, g), y = d - (_ - r) / i * f, b = d - (v - r) / i * f, x = Math.min(y, b), S = Math.max(Math.abs(b - y), Zn), C = u + t * s, w = C + l;
5663
+ let _ = Math.min(h, g), v = Math.max(h, g), y = d - (_ - r) / i * f, b = d - (v - r) / i * f, x = Math.min(y, b), S = Math.max(Math.abs(b - y), Qn), C = u + t * s, w = C + l;
5627
5664
  a[t] = {
5628
5665
  label: n.label,
5629
5666
  value: n.value,
@@ -5643,14 +5680,14 @@ function tr(e, t, n, r, i) {
5643
5680
  cumulatives: o
5644
5681
  };
5645
5682
  }
5646
- function nr(e) {
5683
+ function rr(e) {
5647
5684
  if (e.length === 0) return {
5648
5685
  valMin: 0,
5649
5686
  valMax: 1
5650
5687
  };
5651
5688
  let t = 0, n = 0, r = 0;
5652
5689
  for (let i = 0; i < e.length; i++) {
5653
- let a = e[i], o = Qn(a), s, c;
5690
+ let a = e[i], o = $n(a), s, c;
5654
5691
  o === "total" || o === "subtotal" ? (s = 0, c = a.value, r = a.value) : (s = r, c = r + a.value, r = c), s < t && (t = s), c < t && (t = c), s > n && (n = s), c > n && (n = c);
5655
5692
  }
5656
5693
  let i = (n - t || 1) * .1;
@@ -5659,10 +5696,10 @@ function nr(e) {
5659
5696
  valMax: n + i
5660
5697
  };
5661
5698
  }
5662
- function rr(e, t, n, r) {
5699
+ function ir(e, t, n, r) {
5663
5700
  e.fillStyle = r, e.fillRect(0, 0, t, n);
5664
5701
  }
5665
- function ir(e, t, n, r, i, a) {
5702
+ function ar(e, t, n, r, i, a) {
5666
5703
  let { left: o, right: s, top: c, bottom: l, plotHeight: u } = t, d = r - n || 1;
5667
5704
  e.strokeStyle = i.grid, e.lineWidth = .5, e.fillStyle = i.axisLabel, e.font = `${i.font.sizeSmall}px ${i.font.family}`, e.textAlign = "right", e.textBaseline = "middle";
5668
5705
  let p = f(n, r, 5), m = Math.ceil(n / p) * p;
@@ -5681,7 +5718,7 @@ function ir(e, t, n, r, i, a) {
5681
5718
  e.strokeStyle = i.axisLine, e.lineWidth = 1, e.beginPath(), e.moveTo(o, t), e.lineTo(s, t), e.stroke();
5682
5719
  }
5683
5720
  }
5684
- function ar(e, t, n) {
5721
+ function or(e, t, n) {
5685
5722
  let r = [
5686
5723
  "positive",
5687
5724
  "negative",
@@ -5700,7 +5737,7 @@ function ar(e, t, n) {
5700
5737
  s && (e.fillStyle = o, e.fill());
5701
5738
  }
5702
5739
  }
5703
- function or(e, t, n, r, i, a, o) {
5740
+ function sr(e, t, n, r, i, a, o) {
5704
5741
  if (o === "none" || t.length < 2) return;
5705
5742
  let { bottom: s, plotHeight: c } = n;
5706
5743
  e.strokeStyle = a, e.lineWidth = 1, o === "dashed" ? e.setLineDash([4, 4]) : e.setLineDash([]), e.beginPath();
@@ -5710,7 +5747,7 @@ function or(e, t, n, r, i, a, o) {
5710
5747
  }
5711
5748
  e.stroke(), e.setLineDash([]);
5712
5749
  }
5713
- function sr(e, t, n, r, i, a) {
5750
+ function cr(e, t, n, r, i, a) {
5714
5751
  e.fillStyle = r.text, e.font = `${r.font.sizeSmall}px ${r.font.family}`, e.textAlign = "center";
5715
5752
  for (let r = 0; r < t.length; r++) {
5716
5753
  let o = t[r], s;
@@ -5719,7 +5756,7 @@ function sr(e, t, n, r, i, a) {
5719
5756
  o.end < o.start ? (e.textBaseline = "top", e.fillText(s, c, o.rectY + o.rectH + 4)) : (e.textBaseline = "bottom", e.fillText(s, c, o.rectY - 4));
5720
5757
  }
5721
5758
  }
5722
- function cr(e, t, n, r, i) {
5759
+ function lr(e, t, n, r, i) {
5723
5760
  e.fillStyle = r.axisLabel, e.font = `${r.font.sizeSmall}px ${r.font.family}`, e.textAlign = "center", e.textBaseline = "top";
5724
5761
  let a = n.bottom + 6, o = t.length > 0 ? t[0].slotW - 4 : 0, s = !1;
5725
5762
  for (let n = 0; n < t.length; n++) if (e.measureText(i(t[n].label)).width > o) {
@@ -5740,7 +5777,7 @@ function cr(e, t, n, r, i) {
5740
5777
  }
5741
5778
  e.setTransform(1, 0, 0, 1, 0, 0), e.restore();
5742
5779
  }
5743
- function lr(e, t, n) {
5780
+ function ur(e, t, n) {
5744
5781
  if (t < n.left || t > n.right) return null;
5745
5782
  for (let n = 0; n < e.length; n++) {
5746
5783
  let r = e[n];
@@ -5748,7 +5785,7 @@ function lr(e, t, n) {
5748
5785
  }
5749
5786
  return null;
5750
5787
  }
5751
- function ur(e, t, n, r, i, a, o, s) {
5788
+ function dr(e, t, n, r, i, a, o, s) {
5752
5789
  let c = t[r], l = n[r], u = Math.round(c.slotX + c.slotW / 2) + .5;
5753
5790
  e.strokeStyle = o.crosshair, e.lineWidth = .5, e.setLineDash([4, 4]), e.beginPath(), e.moveTo(u, a.top), e.lineTo(u, a.bottom), e.stroke(), e.setLineDash([]);
5754
5791
  let d = [
@@ -5767,31 +5804,31 @@ function ur(e, t, n, r, i, a, o, s) {
5767
5804
  let _ = o.font.sizeSmall + 4;
5768
5805
  for (let t = 0; t < d.length; t++) e.fillText(d[t], h + 8, g + 6 + t * _);
5769
5806
  }
5770
- function dr(e, t, n, r, i, a) {
5807
+ function fr(e, t, n, r, i, a) {
5771
5808
  let { data: o } = r;
5772
5809
  if (!o || o.length === 0 || t <= 0 || n <= 0) return { hitBar: null };
5773
- let s = r.positiveColor ?? i.candleUp, c = r.negativeColor ?? i.candleDown, l = r.totalColor ?? i.lineColor, u = r.subtotalColor ?? i.textSecondary, d = r.connectorColor ?? i.textSecondary, f = r.connectorStyle ?? "dashed", p = r.barWidth ?? Xn, m = r.showValues !== !1, h = r.showDelta !== !1, g = r.valueFormat ?? $n, _ = r.labelFormat ?? ((e) => e), { valMin: v, valMax: y } = nr(o), b = y - v || 1, x = er(t, n), { bars: S, cumulatives: C } = tr(o, x, p, v, b);
5774
- rr(e, t, n, i.background), ir(e, x, v, y, i, g), or(e, S, x, v, b, d, f), ar(e, S, {
5810
+ let s = r.positiveColor ?? i.candleUp, c = r.negativeColor ?? i.candleDown, l = r.totalColor ?? i.lineColor, u = r.subtotalColor ?? i.textSecondary, d = r.connectorColor ?? i.textSecondary, f = r.connectorStyle ?? "dashed", p = r.barWidth ?? Zn, m = r.showValues !== !1, h = r.showDelta !== !1, g = r.valueFormat ?? er, _ = r.labelFormat ?? ((e) => e), { valMin: v, valMax: y } = rr(o), b = y - v || 1, x = tr(t, n), { bars: S, cumulatives: C } = nr(o, x, p, v, b);
5811
+ ir(e, t, n, i.background), ar(e, x, v, y, i, g), sr(e, S, x, v, b, d, f), or(e, S, {
5775
5812
  positive: s,
5776
5813
  negative: c,
5777
5814
  total: l,
5778
5815
  subtotal: u
5779
- }), m && sr(e, S, C, i, g, h), cr(e, S, x, i, _);
5780
- let w = a ? lr(S, a.x, x) : null;
5781
- return a && w !== null && ur(e, S, C, w, a, x, i, g), { hitBar: w };
5816
+ }), m && cr(e, S, C, i, g, h), lr(e, S, x, i, _);
5817
+ let w = a ? ur(S, a.x, x) : null;
5818
+ return a && w !== null && dr(e, S, C, w, a, x, i, g), { hitBar: w };
5782
5819
  }
5783
5820
  //#endregion
5784
5821
  //#region src/finance/GaugeRenderer.ts
5785
- var fr = Math.PI / 180, pr = 135, mr = 405, hr = .25;
5786
- function gr(e) {
5822
+ var pr = Math.PI / 180, mr = 135, hr = 405, gr = .25;
5823
+ function _r(e) {
5787
5824
  let t = Math.abs(e);
5788
5825
  return t >= 1e6 ? (e / 1e6).toFixed(2) + "M" : t >= 1e3 ? (e / 1e3).toFixed(1) + "K" : Number.isInteger(e) ? e.toFixed(0) : e.toFixed(1);
5789
5826
  }
5790
5827
  function Q(e, t, n) {
5791
5828
  return e < t ? t : e > n ? n : e;
5792
5829
  }
5793
- function _r(e, t, n) {
5794
- let r = n.min ?? 0, i = n.max ?? 100, a = i - r || 1, o = (n.startAngle ?? pr) * fr, s = (n.endAngle ?? mr) * fr, c = n.thickness ?? hr, l = e / 2, u = t / 2 + t * .05, d = Math.max(10, Math.min(e, t) / 2 - 24);
5830
+ function vr(e, t, n) {
5831
+ let r = n.min ?? 0, i = n.max ?? 100, a = i - r || 1, o = (n.startAngle ?? mr) * pr, s = (n.endAngle ?? hr) * pr, c = n.thickness ?? gr, l = e / 2, u = t / 2 + t * .05, d = Math.max(10, Math.min(e, t) / 2 - 24);
5795
5832
  return {
5796
5833
  cx: l,
5797
5834
  cy: u,
@@ -5809,38 +5846,38 @@ function $(e, t) {
5809
5846
  let n = Q((e - t.min) / t.range, 0, 1);
5810
5847
  return t.startAngle + t.angleRange * n;
5811
5848
  }
5812
- function vr(e, t, n, r) {
5849
+ function yr(e, t, n, r) {
5813
5850
  e.fillStyle = r, e.fillRect(0, 0, t, n);
5814
5851
  }
5815
- function yr(e, t, n) {
5852
+ function br(e, t, n) {
5816
5853
  e.beginPath(), e.arc(t.cx, t.cy, t.radius, t.startAngle, t.endAngle, !1), e.arc(t.cx, t.cy, t.innerRadius, t.endAngle, t.startAngle, !0), e.closePath(), e.fillStyle = n, e.fill();
5817
5854
  }
5818
- function br(e, t, n) {
5855
+ function xr(e, t, n) {
5819
5856
  let r = Q(n.from, t.min, t.max), i = Q(n.to, t.min, t.max);
5820
5857
  if (i <= r) return;
5821
5858
  let a = $(r, t), o = $(i, t);
5822
5859
  e.beginPath(), e.arc(t.cx, t.cy, t.radius, a, o, !1), e.arc(t.cx, t.cy, t.innerRadius, o, a, !0), e.closePath(), e.fillStyle = n.color, e.fill();
5823
5860
  }
5824
- function xr(e, t, n, r, i) {
5861
+ function Sr(e, t, n, r, i) {
5825
5862
  let a = $(n, t);
5826
5863
  a <= t.startAngle || (e.globalAlpha = i, e.beginPath(), e.arc(t.cx, t.cy, t.radius, t.startAngle, a, !1), e.arc(t.cx, t.cy, t.innerRadius, a, t.startAngle, !0), e.closePath(), e.fillStyle = r, e.fill(), e.globalAlpha = 1);
5827
5864
  }
5828
- function Sr(e, t, n, r) {
5865
+ function Cr(e, t, n, r) {
5829
5866
  let i = $(n, t), a = Math.cos(i), o = Math.sin(i), s = t.radius - 2, c = t.innerRadius * .25, l = -o, u = a, d = t.cx + a * s, f = t.cy + o * s, p = t.cx + l * 4 - a * c, m = t.cy + u * 4 - o * c, h = t.cx - l * 4 - a * c, g = t.cy - u * 4 - o * c;
5830
5867
  e.beginPath(), e.moveTo(d, f), e.lineTo(p, m), e.lineTo(h, g), e.closePath(), e.fillStyle = r, e.fill(), e.beginPath(), e.arc(t.cx, t.cy, Math.max(4, t.innerRadius * .12), 0, Math.PI * 2), e.fill();
5831
5868
  }
5832
- function Cr(e, t, n, r, i) {
5869
+ function wr(e, t, n, r, i) {
5833
5870
  let a = Math.round(t.innerRadius * .55), o = Math.round(i.font.sizeMedium);
5834
5871
  e.fillStyle = i.text, e.textAlign = "center", e.textBaseline = "middle", e.font = `600 ${a}px ${i.font.family}`;
5835
5872
  let s = !!r, c = s ? t.cy - o * .6 : t.cy - a * .1;
5836
5873
  e.fillText(n, t.cx, c), s && (e.fillStyle = i.textSecondary, e.font = `${o}px ${i.font.family}`, e.fillText(r, t.cx, t.cy + a * .55));
5837
5874
  }
5838
- function wr(e, t, n, r) {
5875
+ function Tr(e, t, n, r) {
5839
5876
  e.fillStyle = r.textSecondary, e.font = `${r.font.sizeSmall}px ${r.font.family}`;
5840
5877
  let i = t.radius + 10, a = Math.cos(t.startAngle), o = Math.sin(t.startAngle), s = Math.cos(t.endAngle), c = Math.sin(t.endAngle), l = t.cx + a * i, u = t.cy + o * i, d = t.cx + s * i, f = t.cy + c * i;
5841
5878
  e.textBaseline = "middle", e.textAlign = a < -.2 ? "right" : a > .2 ? "left" : "center", e.fillText(n(t.min), l, u), e.textAlign = s < -.2 ? "right" : s > .2 ? "left" : "center", e.fillText(n(t.max), d, f);
5842
5879
  }
5843
- function Tr(e, t, n, r) {
5880
+ function Er(e, t, n, r) {
5844
5881
  e.fillStyle = r.textSecondary, e.font = `${r.font.sizeSmall}px ${r.font.family}`, e.textAlign = "center", e.textBaseline = "middle";
5845
5882
  let i = (t.radius + t.innerRadius) / 2;
5846
5883
  for (let r = 0; r < n.length; r++) {
@@ -5850,15 +5887,15 @@ function Tr(e, t, n, r) {
5850
5887
  e.fillText(a.label, s, c);
5851
5888
  }
5852
5889
  }
5853
- function Er(e, t, n, r, i, a) {
5890
+ function Dr(e, t, n, r, i, a) {
5854
5891
  if (t <= 0 || n <= 0) return;
5855
- let o = _r(t, n, r), s = r.trackColor ?? i.grid, c = r.needleColor ?? i.text, l = r.showValue !== !1, u = r.showZoneLabels === !0, d = r.valueFormat ?? gr, f = Q(a, o.min, o.max);
5856
- vr(e, t, n, i.background), yr(e, o, s);
5892
+ let o = vr(t, n, r), s = r.trackColor ?? i.grid, c = r.needleColor ?? i.text, l = r.showValue !== !1, u = r.showZoneLabels === !0, d = r.valueFormat ?? _r, f = Q(a, o.min, o.max);
5893
+ yr(e, t, n, i.background), br(e, o, s);
5857
5894
  let p = r.zones;
5858
- if (p && p.length > 0) for (let t = 0; t < p.length; t++) br(e, o, p[t]);
5859
- xr(e, o, f, c, .12), Sr(e, o, f, c), l && Cr(e, o, d(f), r.label, i), wr(e, o, d, i), u && p && p.length > 0 && Tr(e, o, p, i);
5895
+ if (p && p.length > 0) for (let t = 0; t < p.length; t++) xr(e, o, p[t]);
5896
+ Sr(e, o, f, c, .12), Cr(e, o, f, c), l && wr(e, o, d(f), r.label, i), Tr(e, o, d, i), u && p && p.length > 0 && Er(e, o, p, i);
5860
5897
  }
5861
5898
  //#endregion
5862
- export { Se as ADXIndicator, xe as ATRIndicator, Ne as AccumulationDistributionIndicator, Kt as AlertManager, Ct as AnchoredVWAPTool, Qt as Animator, te as AreaRenderer, De as AroonIndicator, bt as ArrowTool, Ut as BarCountdown, ne as BarRenderer, en as BaseFinanceChart, ie as BaselineRenderer, Lt as BinanceAdapter, P as BollingerBandsIndicator, Te as CCIIndicator, Ae as CMFIndicator, A as CandlestickRenderer, v as CanvasLayer, Bt as ChartLegend, Jt as ChartStateManager, le as CompareRenderer, Ge as CrosshairHandler, qe as CrosshairTooltip, Pt as CurrentPriceLine, zt as DEFAULT_LEGEND_CONFIG, x as DPRManager, Xt as DataExporter, _t as DateRangeTool, Ot as DepthOverlay, B as DonchianChannelIndicator, H as DrawingBase, Qe as DrawingManager, $e as DrawingRenderer, N as EMAIndicator, Zt as Easing, ht as ElliottWaveTool, dt as EllipseTool, K as Emitter, Xe as EventBus, it as ExtendedLineTool, lt as FibExtensionTool, st as FibRetracementTool, tn as FinanceCrosshair, St as GannBoxTool, W as GannFanTool, Ie as GridRenderer, re as HollowCandleRenderer, tt as HorizontalLineTool, I as IchimokuIndicator, j as IndicatorBase, _e as IndicatorEngine, He as InteractionManager, oe as KagiRenderer, z as KeltnerChannelIndicator, Ke as KeyboardHandler, y as LayerManager, ee as LineRenderer, ye as MACDIndicator, Ee as MFIIndicator, vt as MeasureTool, Rt as MockAdapter, Ce as OBVIndicator, Et as OrderRenderer, Ue as PanHandler, L as ParabolicSARIndicator, at as ParallelChannelTool, pt as PitchforkTool, se as PointAndFigureRenderer, Dt as PositionRenderer, Le as PriceAxis, gt as PriceRangeTool, Oe as ROCIndicator, ve as RSIIndicator, rt as RayTool, q as ReconnectManager, ut as RectangleTool, ot as RegressionChannelTool, D as RenderEngine, b as RenderLoop, ae as RenkoRenderer, qt as ReplayManager, M as SMAIndicator, Vt as Screenshot, Wt as SessionBreaks, je as StdDevIndicator, be as StochasticIndicator, Ft as StreamManager, R as SupertrendIndicator, ke as TSIIndicator, yt as TextAnnotationTool, Nt as TickAggregator, Ve as TimeAxis, At as TradingContextMenu, kt as TradingDragHandler, jt as TradingManager, Mt as TradingRenderer, et as TrendLineTool, ft as TriangleTool, Yt as UndoRedoManager, Pe as VROCIndicator, F as VWAPIndicator, nt as VerticalLineTool, O as Viewport, Me as VolumeProfileIndicator, wt as VolumeProfileRangeTool, ce as VolumeRenderer, Ht as Watermark, we as WilliamsRIndicator, We as ZoomHandler, S as barIndexToX, k as getVisibleData, zn as layoutSquarifiedTreemap, In as layoutUniformGrid, C as priceToY, Tt as registerBuiltInDrawingTools, Fe as registerBuiltInIndicators, _n as renderDepthChart, Fn as renderEquityCurve, Er as renderGauge, Gn as renderHeatmap, nn as renderSparkline, dr as renderWaterfall, E as timestampToBarIndex, ue as toHeikinAshi, me as toKagi, pe as toLineBreak, he as toPointAndFigure, de as toRenko, w as xToBarIndex, T as yToPrice };
5899
+ export { je as ADXIndicator, Ae as ATRIndicator, Pe as AccumulationDistributionIndicator, Jt as AlertManager, Tt as AnchoredVWAPTool, en as Animator, te as AreaRenderer, P as AroonIndicator, xt as ArrowTool, Gt as BarCountdown, ne as BarRenderer, nn as BaseFinanceChart, ie as BaselineRenderer, zt as BinanceAdapter, be as BollingerBandsIndicator, M as CCIIndicator, L as CMFIndicator, A as CandlestickRenderer, v as CanvasLayer, Ht as ChartLegend, Xt as ChartStateManager, le as CompareRenderer, Ke as CrosshairHandler, Je as CrosshairTooltip, It as CurrentPriceLine, Vt as DEFAULT_LEGEND_CONFIG, x as DPRManager, Qt as DataExporter, vt as DateRangeTool, At as DepthOverlay, Ee as DonchianChannelIndicator, V as DrawingBase, $e as DrawingManager, et as DrawingRenderer, ye as EMAIndicator, $t as Easing, gt as ElliottWaveTool, ft as EllipseTool, G as Emitter, Ze as EventBus, at as ExtendedLineTool, ut as FibExtensionTool, ct as FibRetracementTool, rn as FinanceCrosshair, wt as GannBoxTool, Ct as GannFanTool, Le as GridRenderer, re as HollowCandleRenderer, nt as HorizontalLineTool, Se as IchimokuIndicator, j as IndicatorBase, _e as IndicatorEngine, Ue as InteractionManager, oe as KagiRenderer, Te as KeltnerChannelIndicator, qe as KeyboardHandler, y as LayerManager, ee as LineRenderer, Oe as MACDIndicator, N as MFIIndicator, yt as MeasureTool, Bt as MockAdapter, Me as OBVIndicator, Ot as OrderRenderer, We as PanHandler, Ce as ParabolicSARIndicator, ot as ParallelChannelTool, mt as PitchforkTool, se as PointAndFigureRenderer, kt as PositionRenderer, Re as PriceAxis, _t as PriceRangeTool, F as ROCIndicator, De as RSIIndicator, it as RayTool, K as ReconnectManager, dt as RectangleTool, st as RegressionChannelTool, D as RenderEngine, b as RenderLoop, ae as RenkoRenderer, Yt as ReplayManager, ve as SMAIndicator, Ut as Screenshot, Kt as SessionBreaks, R as StdDevIndicator, ke as StochasticIndicator, Lt as StreamManager, we as SupertrendIndicator, I as TSIIndicator, bt as TextAnnotationTool, Ft as TickAggregator, He as TimeAxis, Mt as TradingContextMenu, jt as TradingDragHandler, Nt as TradingManager, Pt as TradingRenderer, tt as TrendLineTool, pt as TriangleTool, Zt as UndoRedoManager, Fe as VROCIndicator, xe as VWAPIndicator, rt as VerticalLineTool, O as Viewport, z as VolumeProfileIndicator, Et as VolumeProfileRangeTool, ce as VolumeRenderer, Wt as Watermark, Ne as WilliamsRIndicator, Ge as ZoomHandler, S as barIndexToX, k as getVisibleData, Vn as layoutSquarifiedTreemap, Rn as layoutUniformGrid, C as priceToY, Dt as registerBuiltInDrawingTools, Ie as registerBuiltInIndicators, yn as renderDepthChart, Ln as renderEquityCurve, Dr as renderGauge, qn as renderHeatmap, an as renderSparkline, fr as renderWaterfall, E as timestampToBarIndex, ue as toHeikinAshi, me as toKagi, pe as toLineBreak, he as toPointAndFigure, de as toRenko, w as xToBarIndex, T as yToPrice };
5863
5900
 
5864
5901
  //# sourceMappingURL=index.js.map