@pradeepjadhav/trading-reload-chart 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -39,7 +39,7 @@ var h = {
39
39
  midLineOpacity: 0.9,
40
40
  midLineWidth: 0.5,
41
41
  midLineStyle: "solid"
42
- }, Xt = {
42
+ }, At = {
43
43
  trendline: {
44
44
  lineWidth: 1,
45
45
  lineColor: y.blue,
@@ -129,7 +129,7 @@ var h = {
129
129
  paddingX: 6
130
130
  }
131
131
  }
132
- }, I = { default: "12px Arial" }, nt = {
132
+ }, X = { default: "12px Arial" }, nt = {
133
133
  width: 1,
134
134
  opacity: 0.9,
135
135
  style: "dashed",
@@ -172,7 +172,7 @@ var h = {
172
172
  backgroundOpacity: 0.1,
173
173
  textColor: h.white,
174
174
  textOpacity: 0.6,
175
- font: I.default
175
+ font: X.default
176
176
  }, ot = {
177
177
  height: 22,
178
178
  widthPNL: 80,
@@ -188,7 +188,7 @@ var h = {
188
188
  paddingX: 10,
189
189
  textColor: h.white,
190
190
  textOpacity: 0.85,
191
- font: I.default
191
+ font: X.default
192
192
  }, c = {
193
193
  zoom: {
194
194
  x: {
@@ -240,6 +240,16 @@ var h = {
240
240
  thickness: 1,
241
241
  style: "dashed"
242
242
  },
243
+ watermark: {
244
+ text: "",
245
+ position: "center",
246
+ fontSize: 48,
247
+ fontWeight: 700,
248
+ fontFamily: "Inter, system-ui, -apple-system, sans-serif",
249
+ color: h.white,
250
+ opacity: 0.25,
251
+ padding: 16
252
+ },
243
253
  axis: {
244
254
  axisX: {
245
255
  height: 30,
@@ -247,7 +257,7 @@ var h = {
247
257
  borderColor: h.axisBorder,
248
258
  borderWidth: 1,
249
259
  textColor: h.axisText,
250
- font: I.default,
260
+ font: X.default,
251
261
  textAlign: "center",
252
262
  tickColor: h.axisTick,
253
263
  tickWidth: 1,
@@ -259,7 +269,7 @@ var h = {
259
269
  borderColor: h.crosshairLabelBackground,
260
270
  borderWidth: 1,
261
271
  textColor: h.white,
262
- font: I.default,
272
+ font: X.default,
263
273
  paddingX: 8,
264
274
  height: 26
265
275
  }
@@ -270,7 +280,7 @@ var h = {
270
280
  borderColor: h.axisBorder,
271
281
  borderWidth: 1,
272
282
  textColor: h.axisText,
273
- font: I.default,
283
+ font: X.default,
274
284
  textAlign: "left",
275
285
  tickCount: 12,
276
286
  tickColor: h.axisYTick,
@@ -283,14 +293,14 @@ var h = {
283
293
  borderColor: h.crosshairLabelBackground,
284
294
  borderWidth: 1,
285
295
  textColor: h.white,
286
- font: I.default,
296
+ font: X.default,
287
297
  paddingX: 8,
288
298
  height: 20
289
299
  }
290
300
  }
291
301
  },
292
302
  tradeHandles: {
293
- font: I.default,
303
+ font: X.default,
294
304
  textColor: h.white,
295
305
  textOpacity: 0.8,
296
306
  pnlTextColors: {
@@ -397,7 +407,7 @@ var h = {
397
407
  bearish: h.red,
398
408
  background: h.background
399
409
  },
400
- shapes: Xt
410
+ shapes: At
401
411
  }, lt = [
402
412
  300 * 1e3,
403
413
  900 * 1e3,
@@ -408,12 +418,12 @@ var h = {
408
418
  360 * 60 * 1e3,
409
419
  720 * 60 * 1e3,
410
420
  1440 * 60 * 1e3
411
- ], It = (t) => {
421
+ ], Xt = (t) => {
412
422
  if (t.length < 2) return 900 * 1e3;
413
423
  const e = [];
414
424
  for (let i = 1; i < Math.min(t.length, 10); i++) e.push(t[i].time - t[i - 1].time);
415
425
  return e.sort((i, s) => i - s), e[Math.floor(e.length / 2)];
416
- }, At = ({ candleSpacing: t, candleTimeframeMs: e, labelWidth: i, minLabelGap: s }) => {
426
+ }, It = ({ candleSpacing: t, candleTimeframeMs: e, labelWidth: i, minLabelGap: s }) => {
417
427
  if (t <= 0 || e <= 0) return lt[0];
418
428
  const r = i + s;
419
429
  for (const o of lt) if (o / e * t >= r) return o;
@@ -479,9 +489,9 @@ var h = {
479
489
  }
480
490
  drawAxisLabels() {
481
491
  if (!this.viewport) return;
482
- const t = this.#e, e = c.axis.axisX, i = this.#t.width, s = It(this.candles);
492
+ const t = this.#e, e = c.axis.axisX, i = this.#t.width, s = Xt(this.candles);
483
493
  t.save(), t.font = e.font, t.fillStyle = e.textColor, t.textAlign = e.textAlign, t.textBaseline = "middle";
484
- const r = t.measureText("00:00").width, n = At({
494
+ const r = t.measureText("00:00").width, n = It({
485
495
  candleSpacing: this.viewport.candleSpacing,
486
496
  candleTimeframeMs: s,
487
497
  labelWidth: r,
@@ -490,8 +500,8 @@ var h = {
490
500
  for (let l = a; l <= o; l += 1) {
491
501
  const d = this.getSlotTime(l, s);
492
502
  if (d === null || !Bt(d, n)) continue;
493
- const u = this.getCandleCenterX(l), g = Wt(d), v = t.measureText(g).width;
494
- this.isLabelOutsideCanvas(u, v, i) || (this.drawTick(u), this.drawLabel(g, u));
503
+ const u = this.getCandleCenterX(l), g = Wt(d), p = t.measureText(g).width;
504
+ this.isLabelOutsideCanvas(u, p, i) || (this.drawTick(u), this.drawLabel(g, u));
495
505
  }
496
506
  t.restore();
497
507
  }
@@ -535,7 +545,7 @@ var h = {
535
545
  getCrosshairLabelX(t, e) {
536
546
  return Math.max(120, Math.min(e - t, this.crosshair.x - t / 2));
537
547
  }
538
- }, p = (t, e = 5) => Number(t.toFixed(e)), Y = ({ price: t, minPrice: e, priceRange: i, chartHeight: s }) => s - (t - e) / i * s, mt = ({ y: t, minPrice: e, priceRange: i, chartHeight: s }) => e + (1 - t / s) * i, Yt = ({ priceRange: t, canvasHeight: e }) => {
548
+ }, m = (t, e = 5) => Number(t.toFixed(e)), Y = ({ price: t, minPrice: e, priceRange: i, chartHeight: s }) => s - (t - e) / i * s, mt = ({ y: t, minPrice: e, priceRange: i, chartHeight: s }) => e + (1 - t / s) * i, Yt = ({ priceRange: t, canvasHeight: e }) => {
539
549
  const i = t / (e / c.axis.axisY.tickGap), s = 10 ** Math.floor(Math.log10(i));
540
550
  for (const r of [
541
551
  1,
@@ -576,7 +586,7 @@ var h = {
576
586
  }
577
587
  drawCrosshairPriceLabel() {
578
588
  if (!this.crosshair.visible) return;
579
- const t = this.#e, e = this.#t.width, i = this.#t.height, s = c.axis.axisY.crosshairLabel, r = p(this.crosshair.price).toFixed(5), n = s.height, a = this.getCrosshairLabelY(n, i);
589
+ const t = this.#e, e = this.#t.width, i = this.#t.height, s = c.axis.axisY.crosshairLabel, r = m(this.crosshair.price).toFixed(5), n = s.height, a = this.getCrosshairLabelY(n, i);
580
590
  t.save(), t.fillStyle = s.backgroundColor, t.fillRect(0, a, e, n), t.strokeStyle = s.borderColor, t.lineWidth = s.borderWidth, t.strokeRect(0, a, e, n), t.font = s.font, t.fillStyle = s.textColor, t.textAlign = "left", t.textBaseline = "middle", t.fillText(r, s.paddingX, a + n / 2), t.restore();
581
591
  }
582
592
  clearCanvas() {
@@ -630,7 +640,7 @@ var h = {
630
640
  }
631
641
  drawPriceLabel(t, e) {
632
642
  const i = this.#e, s = c.axis.axisY;
633
- i.fillStyle = s.textColor, i.fillText(p(t).toFixed(5), s.labelOffsetX, e);
643
+ i.fillStyle = s.textColor, i.fillText(m(t).toFixed(5), s.labelOffsetX, e);
634
644
  }
635
645
  getCrosshairLabelY(t, e) {
636
646
  return Math.max(0, Math.min(e - t, this.crosshair.y - t / 2));
@@ -834,7 +844,7 @@ var h = {
834
844
  return this.getCandleCenterX(e);
835
845
  }
836
846
  getPriceAtY(t) {
837
- return p(mt({
847
+ return m(mt({
838
848
  y: t,
839
849
  minPrice: this.minPrice,
840
850
  priceRange: this.priceRange,
@@ -894,7 +904,7 @@ var h = {
894
904
  t.fillRect(e, l, this.candleWidth, d);
895
905
  }
896
906
  drawPriceLine({ ctx: t, chartWidth: e, chartHeight: i, price: s, color: r, opacity: n, lineWidth: a, dash: o }) {
897
- const l = this.getPriceY(p(s), i);
907
+ const l = this.getPriceY(m(s), i);
898
908
  t.save(), t.globalAlpha = n, t.strokeStyle = r, t.lineWidth = a, t.setLineDash(o), t.beginPath(), t.moveTo(0, l), t.lineTo(e, l), t.stroke(), t.restore();
899
909
  }
900
910
  drawBidPriceLine({ ctx: t, chartWidth: e, chartHeight: i }) {
@@ -912,11 +922,11 @@ var h = {
912
922
  }
913
923
  drawAskPriceLine({ ctx: t, chartWidth: e, chartHeight: i }) {
914
924
  const s = this.candles.at(-1);
915
- !s || !c.candles.liveAskPriceLine.visible || s.ask == null || this.drawPriceLine({
925
+ !s || !c.candles.liveAskPriceLine.visible || this.drawPriceLine({
916
926
  ctx: t,
917
927
  chartWidth: e,
918
928
  chartHeight: i,
919
- price: s.ask,
929
+ price: s.ask ?? s.close,
920
930
  color: this.getAskPriceLineColor(s),
921
931
  opacity: c.candles.liveAskPriceLine.opacity,
922
932
  lineWidth: c.candles.liveAskPriceLine.width,
@@ -953,7 +963,7 @@ var h = {
953
963
  };
954
964
  }
955
965
  getInitialPriceRange(t, e) {
956
- const i = this.getInitialFallbackPercent(), s = p(e - t), r = Math.max(Math.abs((t + e) / 2) * i, 1e-5), n = Math.max(s, r);
966
+ const i = this.getInitialFallbackPercent(), s = m(e - t), r = Math.max(Math.abs((t + e) / 2) * i, 1e-5), n = Math.max(s, r);
957
967
  return n + n * 0.2;
958
968
  }
959
969
  getInitialFallbackPercent() {
@@ -1071,31 +1081,31 @@ var h = {
1071
1081
  }, _t = class {
1072
1082
  #t;
1073
1083
  #e;
1074
- #r = null;
1075
- #s = null;
1084
+ #n = null;
1085
+ #i = null;
1076
1086
  constructor({ ctx: t, config: e }) {
1077
1087
  this.#t = t, this.#e = e;
1078
1088
  }
1079
1089
  setViewport(t) {
1080
- this.#r = t;
1090
+ this.#n = t;
1081
1091
  }
1082
1092
  setConfig(t) {
1083
1093
  this.#e = t;
1084
1094
  }
1085
1095
  setPreviousDay(t) {
1086
- this.#s = t ?? null;
1096
+ this.#i = t ?? null;
1087
1097
  }
1088
1098
  render() {
1089
- if (!this.#r || !this.#s) return;
1090
- const { high: t, low: e } = this.#s;
1091
- Number.isFinite(t) && t > 0 && this.#u(t, "PDH"), Number.isFinite(e) && e > 0 && this.#u(e, "PDL");
1099
+ if (!this.#n || !this.#i) return;
1100
+ const { high: t, low: e } = this.#i;
1101
+ Number.isFinite(t) && t > 0 && this.#h(t, "PDH"), Number.isFinite(e) && e > 0 && this.#h(e, "PDL");
1092
1102
  }
1093
- #u(t, e) {
1094
- if (!this.#r || !this.#e) return;
1103
+ #h(t, e) {
1104
+ if (!this.#n || !this.#e) return;
1095
1105
  const i = this.#t, s = i.canvas, r = Y({
1096
1106
  price: t,
1097
- minPrice: this.#r.minPrice,
1098
- priceRange: this.#r.priceRange,
1107
+ minPrice: this.#n.minPrice,
1108
+ priceRange: this.#n.priceRange,
1099
1109
  chartHeight: s.height
1100
1110
  });
1101
1111
  if (r < 0 || r > s.height) return;
@@ -1104,6 +1114,11 @@ var h = {
1104
1114
  const l = i.measureText(e).width, d = o / 2, u = l / 2 + a.paddingX;
1105
1115
  i.globalAlpha = n.opacity, i.strokeStyle = n.color, i.lineWidth = n.width, i.setLineDash(n.dash), i.beginPath(), i.moveTo(0, r), i.lineTo(d - u, r), i.stroke(), i.beginPath(), i.moveTo(d + u, r), i.lineTo(o, r), i.stroke(), i.setLineDash([]), i.globalAlpha = 1, i.fillStyle = a.color, i.textAlign = "center", i.textBaseline = "middle", i.fillText(e, d, r), i.restore();
1106
1116
  }
1117
+ }, f = {
1118
+ handleColor: h.background,
1119
+ handleBorderColor: h.blue,
1120
+ handleBorderThickness: 1.5,
1121
+ handleRadius: 5
1107
1122
  }, vt = (t, e) => {
1108
1123
  const i = t.getBoundingClientRect(), s = t.width / i.width, r = t.height / i.height;
1109
1124
  return {
@@ -1114,7 +1129,7 @@ var h = {
1114
1129
  var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID() : `shape-${Date.now()}-${Math.random().toString(16).slice(2)}`, q = (t, e) => vt(t, e), ht = (t, e) => ({
1115
1130
  time: e.getNearestCandleTimeForX(t.x),
1116
1131
  price: e.getPriceForY(t.y)
1117
- }), C = (t, e) => ({
1132
+ }), v = (t, e) => ({
1118
1133
  x: e.getXForTime(t.time),
1119
1134
  y: e.getYForPrice(t.price)
1120
1135
  }), Gt = (t, e) => {
@@ -1127,7 +1142,7 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1127
1142
  width: s - i,
1128
1143
  height: n - r
1129
1144
  };
1130
- }, K = (t, e, i) => Gt(C(t, i), C(e, i)), J = (t, e) => {
1145
+ }, K = (t, e, i) => Gt(v(t, i), v(e, i)), J = (t, e) => {
1131
1146
  const i = t.x - e.x, s = t.y - e.y;
1132
1147
  return Math.sqrt(i * i + s * s);
1133
1148
  }, yt = (t, e, i) => {
@@ -1142,7 +1157,7 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1142
1157
  if (!wt(t, e, i)) return !1;
1143
1158
  const s = Math.abs(t.x - e.left) <= i, r = Math.abs(t.x - e.right) <= i, n = Math.abs(t.y - e.top) <= i, a = Math.abs(t.y - e.bottom) <= i, o = t.x >= e.left - i && t.x <= e.right + i, l = t.y >= e.top - i && t.y <= e.bottom + i;
1144
1159
  return (s || r) && l || (n || a) && o;
1145
- }, x = ({ shapeId: t, type: e, point: i, radius: s = 5, cursor: r, index: n }) => ({
1160
+ }, P = ({ shapeId: t, type: e, point: i, radius: s = 5, cursor: r, index: n }) => ({
1146
1161
  shapeId: t,
1147
1162
  type: e,
1148
1163
  x: i.x,
@@ -1151,8 +1166,8 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1151
1166
  cursor: r,
1152
1167
  index: n
1153
1168
  }), j = (t, e) => J(t, e) <= e.radius + 2, z = (t, e = 1) => t === "dashed" ? [e * 6, e * 4] : t === "dotted" ? [e, e * 3] : [], tt = (t, e, i) => {
1154
- t.strokeStyle = P(e.lineColor, e.lineOpacity), t.lineWidth = i ?? e.lineWidth, t.setLineDash(z(e.lineStyle, t.lineWidth));
1155
- }, bt = (t, e, i) => !e || i === void 0 || i <= 0 ? !1 : (t.fillStyle = P(e, i), !0), E = (t) => {
1169
+ t.strokeStyle = x(e.lineColor, e.lineOpacity), t.lineWidth = i ?? e.lineWidth, t.setLineDash(z(e.lineStyle, t.lineWidth));
1170
+ }, bt = (t, e, i) => !e || i === void 0 || i <= 0 ? !1 : (t.fillStyle = x(e, i), !0), E = (t) => {
1156
1171
  t.setLineDash([]);
1157
1172
  }, $t = (t, e, i = {
1158
1173
  fillColor: "#ffffff",
@@ -1164,7 +1179,7 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1164
1179
  e.forEach((s) => {
1165
1180
  $t(t, s, i);
1166
1181
  });
1167
- }, P = (t, e) => {
1182
+ }, x = (t, e) => {
1168
1183
  const i = Kt(e, 0, 1);
1169
1184
  return t.startsWith("rgba(") ? t : t.startsWith("rgb(") ? t.replace("rgb(", "rgba(").replace(")", `, ${i})`) : t.startsWith("#") ? qt(t, i) : t;
1170
1185
  }, qt = (t, e) => {
@@ -1189,12 +1204,7 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1189
1204
  }, Jt = (t, e, i) => {
1190
1205
  const s = Z(t, e), r = s + i;
1191
1206
  return s >= 0 && r >= 0 && r < t.length ? t[r].time : e + Q(t) * i;
1192
- }, ct = (t) => t instanceof MouseEvent && t.type === "contextmenu" ? !1 : "button" in t && t.type === "pointerdown" ? t.button === 0 : !0, f = {
1193
- handleColor: h.background,
1194
- handleBorderColor: h.blue,
1195
- handleBorderThickness: 1.5,
1196
- handleRadius: 5
1197
- }, L = class A {
1207
+ }, ct = (t) => t instanceof MouseEvent && t.type === "contextmenu" ? !1 : "button" in t && t.type === "pointerdown" ? t.button === 0 : !0, L = class I {
1198
1208
  static defaultConfig = {
1199
1209
  levels: [
1200
1210
  {
@@ -1241,21 +1251,21 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1241
1251
  fillColor: "#808080",
1242
1252
  fillOpacity: 0.04
1243
1253
  };
1244
- static draw({ ctx: e, shape: i, converter: s, config: r = A.defaultConfig, selected: n = !1, hovered: a = !1 }) {
1245
- const [o, l] = i.vertices, d = C(o, s), u = C(l, s), g = K(o, l, s), v = Math.min(d.x, u.x), w = Math.max(d.x, u.x);
1254
+ static draw({ ctx: e, shape: i, converter: s, config: r = I.defaultConfig, selected: n = !1, hovered: a = !1 }) {
1255
+ const [o, l] = i.vertices, d = v(o, s), u = v(l, s), g = K(o, l, s), p = Math.min(d.x, u.x), w = Math.max(d.x, u.x);
1246
1256
  e.save(), bt(e, r.fillColor, r.fillOpacity) && e.fillRect(g.left, g.top, g.width, g.height);
1247
- for (const m of r.levels) {
1248
- const S = dt(o.price, l.price, m.level), T = s.getYForPrice(S), M = m.lineWidth;
1249
- e.beginPath(), e.strokeStyle = P(m.color, m.opacity), e.lineWidth = M, e.setLineDash(z(m.lineStyle, M)), e.moveTo(v, T), e.lineTo(w, T), e.stroke(), m.label && (e.setLineDash([]), e.fillStyle = P(m.color, m.opacity), e.font = "11px sans-serif", e.textBaseline = "middle", e.fillText(Number(m.label).toFixed(2).toString(), w + 12, T));
1257
+ for (const C of r.levels) {
1258
+ const S = dt(o.price, l.price, C.level), T = s.getYForPrice(S), k = C.lineWidth;
1259
+ e.beginPath(), e.strokeStyle = x(C.color, C.opacity), e.lineWidth = k, e.setLineDash(z(C.lineStyle, k)), e.moveTo(p, T), e.lineTo(w, T), e.stroke(), C.label && (e.setLineDash([]), e.fillStyle = x(C.color, C.opacity), e.font = "11px sans-serif", e.textBaseline = "middle", e.fillText(Number(C.label).toFixed(2).toString(), w + 12, T));
1250
1260
  }
1251
- E(e), (n || a) && O(e, A.getHandles(i, s), {
1261
+ E(e), (n || a) && O(e, I.getHandles(i, s), {
1252
1262
  fillColor: f.handleColor,
1253
1263
  borderColor: f.handleBorderColor,
1254
1264
  borderThickness: f.handleBorderThickness
1255
1265
  }), e.restore();
1256
1266
  }
1257
- static drawDraft({ ctx: e, vertices: i, converter: s, config: r = A.defaultConfig }) {
1258
- A.draw({
1267
+ static drawDraft({ ctx: e, vertices: i, converter: s, config: r = I.defaultConfig }) {
1268
+ I.draw({
1259
1269
  ctx: e,
1260
1270
  shape: {
1261
1271
  id: "__draft_fib_retracement__",
@@ -1268,14 +1278,14 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1268
1278
  });
1269
1279
  }
1270
1280
  static getHandles(e, i) {
1271
- const [s, r] = e.vertices, n = C(s, i), a = C(r, i);
1272
- return [x({
1281
+ const [s, r] = e.vertices, n = v(s, i), a = v(r, i);
1282
+ return [P({
1273
1283
  shapeId: e.id,
1274
1284
  type: "start",
1275
1285
  point: n,
1276
1286
  radius: f.handleRadius,
1277
1287
  cursor: "grab"
1278
- }), x({
1288
+ }), P({
1279
1289
  shapeId: e.id,
1280
1290
  type: "end",
1281
1291
  point: a,
@@ -1283,12 +1293,12 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1283
1293
  cursor: "grab"
1284
1294
  })];
1285
1295
  }
1286
- static hitTest({ point: e, shape: i, converter: s, tolerance: r = 8, config: n = A.defaultConfig }) {
1287
- const [a, o] = i.vertices, l = C(a, s), d = C(o, s), u = Math.min(l.x, d.x), g = Math.max(l.x, d.x);
1296
+ static hitTest({ point: e, shape: i, converter: s, tolerance: r = 8, config: n = I.defaultConfig }) {
1297
+ const [a, o] = i.vertices, l = v(a, s), d = v(o, s), u = Math.min(l.x, d.x), g = Math.max(l.x, d.x);
1288
1298
  if (e.x < u - r || e.x > g + r) return !1;
1289
- for (const v of n.levels) {
1290
- const w = dt(a.price, o.price, v.level), m = s.getYForPrice(w);
1291
- if (Math.abs(e.y - m) <= r) return !0;
1299
+ for (const p of n.levels) {
1300
+ const w = dt(a.price, o.price, p.level), C = s.getYForPrice(w);
1301
+ if (Math.abs(e.y - C) <= r) return !0;
1292
1302
  }
1293
1303
  return !1;
1294
1304
  }
@@ -1313,7 +1323,7 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1313
1323
  vertices: [e.vertices[0], s]
1314
1324
  } : e;
1315
1325
  }
1316
- }, k = class V {
1326
+ }, R = class V {
1317
1327
  static defaultConfig = {
1318
1328
  lineWidth: 2,
1319
1329
  lineColor: "#2962ff",
@@ -1321,7 +1331,7 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1321
1331
  lineStyle: "solid"
1322
1332
  };
1323
1333
  static draw({ ctx: e, shape: i, converter: s, config: r = V.defaultConfig, selected: n = !1, hovered: a = !1 }) {
1324
- const [o, l] = i.vertices, d = C(o, s), u = C(l, s);
1334
+ const [o, l] = i.vertices, d = v(o, s), u = v(l, s);
1325
1335
  e.save(), tt(e, r), e.beginPath(), e.moveTo(d.x, d.y), e.lineTo(u.x, u.y), e.stroke(), E(e), (n || a) && O(e, V.getHandles(i, s), {
1326
1336
  fillColor: f.handleColor,
1327
1337
  borderColor: f.handleBorderColor,
@@ -1342,14 +1352,14 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1342
1352
  });
1343
1353
  }
1344
1354
  static getHandles(e, i) {
1345
- const [s, r] = e.vertices, n = C(s, i), a = C(r, i);
1346
- return [x({
1355
+ const [s, r] = e.vertices, n = v(s, i), a = v(r, i);
1356
+ return [P({
1347
1357
  shapeId: e.id,
1348
1358
  type: "start",
1349
1359
  point: n,
1350
1360
  radius: f.handleRadius,
1351
1361
  cursor: "grab"
1352
- }), x({
1362
+ }), P({
1353
1363
  shapeId: e.id,
1354
1364
  type: "end",
1355
1365
  point: a,
@@ -1359,7 +1369,7 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1359
1369
  }
1360
1370
  static hitTest({ point: e, shape: i, converter: s, tolerance: r = 8 }) {
1361
1371
  const [n, a] = i.vertices;
1362
- return yt(e, C(n, s), C(a, s)) <= r;
1372
+ return yt(e, v(n, s), v(a, s)) <= r;
1363
1373
  }
1364
1374
  static move(e, i) {
1365
1375
  return {
@@ -1382,7 +1392,7 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1382
1392
  vertices: [e.vertices[0], s]
1383
1393
  } : e;
1384
1394
  }
1385
- }, R = class B {
1395
+ }, D = class B {
1386
1396
  static defaultConfig = {
1387
1397
  lineWidth: 2,
1388
1398
  lineColor: "#2962ff",
@@ -1392,7 +1402,7 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1392
1402
  fillOpacity: 0
1393
1403
  };
1394
1404
  static draw({ ctx: e, shape: i, converter: s, config: r = B.defaultConfig, selected: n = !1, hovered: a = !1 }) {
1395
- const o = i.vertices.map((l) => C(l, s));
1405
+ const o = i.vertices.map((l) => v(l, s));
1396
1406
  if (o.length !== 0) {
1397
1407
  e.save(), tt(e, r), e.beginPath(), e.moveTo(o[0].x, o[0].y);
1398
1408
  for (let l = 1; l < o.length; l += 1) e.lineTo(o[l].x, o[l].y);
@@ -1425,17 +1435,17 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1425
1435
  });
1426
1436
  }
1427
1437
  static getHandles(e, i) {
1428
- return e.vertices.map((s, r) => x({
1438
+ return e.vertices.map((s, r) => P({
1429
1439
  shapeId: e.id,
1430
1440
  type: r === 0 ? "start" : r === e.vertices.length - 1 ? "end" : "move",
1431
- point: C(s, i),
1441
+ point: v(s, i),
1432
1442
  radius: f.handleRadius,
1433
1443
  cursor: "grab",
1434
1444
  index: r
1435
1445
  }));
1436
1446
  }
1437
1447
  static hitTest({ point: e, shape: i, converter: s, tolerance: r = 8 }) {
1438
- const n = i.vertices.map((a) => C(a, s));
1448
+ const n = i.vertices.map((a) => v(a, s));
1439
1449
  if (n.length === 1) {
1440
1450
  const a = n[0], o = e.x - a.x, l = e.y - a.y;
1441
1451
  return Math.sqrt(o * o + l * l) <= r;
@@ -1460,9 +1470,9 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1460
1470
  }
1461
1471
  static drawEndArrow({ ctx: e, previousPoint: i, endPoint: s, color: r, opacity: n, lineWidth: a }) {
1462
1472
  const o = Math.atan2(s.y - i.y, s.x - i.x), l = 12, d = Math.PI / 7;
1463
- e.save(), e.beginPath(), e.strokeStyle = P(r, n), e.fillStyle = P(r, n), e.lineWidth = a, e.setLineDash([]), e.moveTo(s.x, s.y), e.lineTo(s.x - l * Math.cos(o - d), s.y - l * Math.sin(o - d)), e.lineTo(s.x - l * Math.cos(o + d), s.y - l * Math.sin(o + d)), e.closePath(), e.fill(), e.stroke(), e.restore();
1473
+ e.save(), e.beginPath(), e.strokeStyle = x(r, n), e.fillStyle = x(r, n), e.lineWidth = a, e.setLineDash([]), e.moveTo(s.x, s.y), e.lineTo(s.x - l * Math.cos(o - d), s.y - l * Math.sin(o - d)), e.lineTo(s.x - l * Math.cos(o + d), s.y - l * Math.sin(o + d)), e.closePath(), e.fill(), e.stroke(), e.restore();
1464
1474
  }
1465
- }, D = class W {
1475
+ }, A = class W {
1466
1476
  static defaultConfig = {
1467
1477
  lineWidth: 2,
1468
1478
  lineColor: "#2962ff",
@@ -1497,14 +1507,14 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1497
1507
  });
1498
1508
  }
1499
1509
  static getHandles(e, i) {
1500
- const [s, r] = e.vertices, n = C(s, i), a = C(r, i), o = n.x <= a.x, l = n.y <= a.y, d = o === l ? "nwse-resize" : "nesw-resize", u = o === l ? "nwse-resize" : "nesw-resize";
1501
- return [x({
1510
+ const [s, r] = e.vertices, n = v(s, i), a = v(r, i), o = n.x <= a.x, l = n.y <= a.y, d = o === l ? "nwse-resize" : "nesw-resize", u = o === l ? "nwse-resize" : "nesw-resize";
1511
+ return [P({
1502
1512
  shapeId: e.id,
1503
1513
  type: "start",
1504
1514
  point: n,
1505
1515
  radius: f.handleRadius,
1506
1516
  cursor: d
1507
- }), x({
1517
+ }), P({
1508
1518
  shapeId: e.id,
1509
1519
  type: "end",
1510
1520
  point: a,
@@ -1541,19 +1551,19 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1541
1551
  const n = s?.trim();
1542
1552
  n && (e.save(), e.beginPath(), e.rect(i.left, i.top, i.width, i.height), e.clip(), e.font = `${r.textFontSize}px ${r.textFontFamily}`, e.globalAlpha = r.textOpacity, e.fillStyle = r.textColor, e.textAlign = "center", e.textBaseline = "middle", e.fillText(n, i.left + i.width / 2, i.top + i.height / 2), e.restore());
1543
1553
  }
1544
- }, Pt = [
1554
+ }, xt = [
1545
1555
  "USDJPY",
1546
1556
  "GBPJPY",
1547
1557
  "AUDJPY",
1548
1558
  "EURJPY",
1549
1559
  "NZDJPY",
1550
1560
  "CADJPY"
1551
- ], xt = ["BTCUSD", "ETHUSD"], St = [
1561
+ ], Pt = ["BTCUSD", "ETHUSD"], St = [
1552
1562
  "XAUUSD",
1553
1563
  "USOIL",
1554
1564
  "UKOIL",
1555
1565
  "XAGUSD"
1556
- ], Tt = (t) => Pt.some((e) => t.includes(e.slice(3))) ? 0.01 : xt.includes(t) ? 1 : St.includes(t) ? 0.01 : 1e-4, jt = (t, e) => Pt.includes(t) ? e * 6.33806 : xt.includes(t) ? e * 1 : (St.includes(t), e * 10), ut = (t, e, i, s, r) => {
1566
+ ], Tt = (t) => xt.some((e) => t.includes(e.slice(3))) ? 0.01 : Pt.includes(t) ? 1 : St.includes(t) ? 0.01 : 1e-4, jt = (t, e) => xt.includes(t) ? e * 6.33806 : Pt.includes(t) ? e * 1 : (St.includes(t), e * 10), ut = (t, e, i, s, r) => {
1557
1567
  const n = r.split(".")[0], a = Tt(n), o = jt(n, s);
1558
1568
  return (t === "buy" ? i - e : e - i) / a * o;
1559
1569
  }, H = class b {
@@ -1577,9 +1587,9 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1577
1587
  static defaultShortConfig = { ...b.defaultLongConfig };
1578
1588
  static draw({ ctx: e, activeSymbol: i, shape: s, converter: r, config: n = s.type === "longPosition" ? b.defaultLongConfig : b.defaultShortConfig, selected: a = !1, hovered: o = !1 }) {
1579
1589
  const l = b.getGeometry(s, r);
1580
- e.save(), e.fillStyle = P(n.profitFillColor, n.profitFillOpacity), e.fillRect(l.profitBox.left, l.profitBox.top, l.profitBox.width, l.profitBox.height), e.fillStyle = P(n.lossFillColor, n.lossFillOpacity), e.fillRect(l.lossBox.left, l.lossBox.top, l.lossBox.width, l.lossBox.height);
1590
+ e.save(), e.fillStyle = x(n.profitFillColor, n.profitFillOpacity), e.fillRect(l.profitBox.left, l.profitBox.top, l.profitBox.width, l.profitBox.height), e.fillStyle = x(n.lossFillColor, n.lossFillOpacity), e.fillRect(l.lossBox.left, l.lossBox.top, l.lossBox.width, l.lossBox.height);
1581
1591
  const d = n.borderWidth;
1582
- e.strokeStyle = P(n.borderColor, n.borderOpacity), e.lineWidth = d, e.setLineDash(z(n.borderStyle, d)), e.strokeRect(l.box.left, l.box.top, l.box.width, l.box.height), e.beginPath(), e.strokeStyle = P(n.midLineColor, n.midLineOpacity), e.lineWidth = n.midLineWidth, e.setLineDash(z(n.midLineStyle, n.midLineWidth)), e.moveTo(l.box.left, l.entryY), e.lineTo(l.box.right, l.entryY), e.stroke(), E(e), b.drawLabels({
1592
+ e.strokeStyle = x(n.borderColor, n.borderOpacity), e.lineWidth = d, e.setLineDash(z(n.borderStyle, d)), e.strokeRect(l.box.left, l.box.top, l.box.width, l.box.height), e.beginPath(), e.strokeStyle = x(n.midLineColor, n.midLineOpacity), e.lineWidth = n.midLineWidth, e.setLineDash(z(n.midLineStyle, n.midLineWidth)), e.moveTo(l.box.left, l.entryY), e.lineTo(l.box.right, l.entryY), e.stroke(), E(e), b.drawLabels({
1583
1593
  ctx: e,
1584
1594
  activeSymbol: i,
1585
1595
  shape: s,
@@ -1603,14 +1613,14 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1603
1613
  };
1604
1614
  }
1605
1615
  static getGeometry(e, i) {
1606
- const s = C(e.entry, i), r = i.getXForTime(e.endTime), n = Math.min(s.x, r), a = Math.max(s.x, r), o = e.type === "longPosition", l = o ? e.takeProfitPercent : e.stopLossPercent, d = o ? e.stopLossPercent : e.takeProfitPercent, u = e.entry.price * (1 + l / 100), g = e.entry.price * (1 - d / 100), v = i.getYForPrice(u), w = i.getYForPrice(g), m = Math.min(v, w, s.y), S = Math.max(v, w, s.y), T = {
1616
+ const s = v(e.entry, i), r = i.getXForTime(e.endTime), n = Math.min(s.x, r), a = Math.max(s.x, r), o = e.type === "longPosition", l = o ? e.takeProfitPercent : e.stopLossPercent, d = o ? e.stopLossPercent : e.takeProfitPercent, u = e.entry.price * (1 + l / 100), g = e.entry.price * (1 - d / 100), p = i.getYForPrice(u), w = i.getYForPrice(g), C = Math.min(p, w, s.y), S = Math.max(p, w, s.y), T = {
1607
1617
  left: n,
1608
- top: m,
1618
+ top: C,
1609
1619
  right: a,
1610
1620
  bottom: s.y,
1611
1621
  width: a - n,
1612
- height: Math.abs(s.y - m)
1613
- }, M = {
1622
+ height: Math.abs(s.y - C)
1623
+ }, k = {
1614
1624
  left: n,
1615
1625
  top: s.y,
1616
1626
  right: a,
@@ -1626,20 +1636,20 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1626
1636
  lowerPrice: g,
1627
1637
  box: {
1628
1638
  left: n,
1629
- top: m,
1639
+ top: C,
1630
1640
  right: a,
1631
1641
  bottom: S,
1632
1642
  width: a - n,
1633
- height: S - m
1643
+ height: S - C
1634
1644
  },
1635
- profitBox: o ? T : M,
1636
- lossBox: o ? M : T
1645
+ profitBox: o ? T : k,
1646
+ lossBox: o ? k : T
1637
1647
  };
1638
1648
  }
1639
1649
  static getHandles(e, i) {
1640
1650
  const s = b.getGeometry(e, i);
1641
1651
  return [
1642
- x({
1652
+ P({
1643
1653
  shapeId: e.id,
1644
1654
  type: "upperHeight",
1645
1655
  point: {
@@ -1649,7 +1659,7 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1649
1659
  radius: f.handleRadius,
1650
1660
  cursor: "ns-resize"
1651
1661
  }),
1652
- x({
1662
+ P({
1653
1663
  shapeId: e.id,
1654
1664
  type: "lowerHeight",
1655
1665
  point: {
@@ -1659,7 +1669,7 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1659
1669
  radius: f.handleRadius,
1660
1670
  cursor: "ns-resize"
1661
1671
  }),
1662
- x({
1672
+ P({
1663
1673
  shapeId: e.id,
1664
1674
  type: "start",
1665
1675
  point: {
@@ -1669,7 +1679,7 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1669
1679
  radius: f.handleRadius,
1670
1680
  cursor: "ns-resize"
1671
1681
  }),
1672
- x({
1682
+ P({
1673
1683
  shapeId: e.id,
1674
1684
  type: "end",
1675
1685
  point: {
@@ -1732,9 +1742,9 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
1732
1742
  static drawLabels({ ctx: e, activeSymbol: i, shape: s, geometry: r, config: n }) {
1733
1743
  e.save(), e.font = "11px sans-serif", e.textBaseline = "middle";
1734
1744
  const a = s.type, o = Tt(i), l = s.entry.price * (s.takeProfitPercent / 100) / o, d = s.entry.price * (s.stopLossPercent / 100) / o, u = r.box.left + 6, g = l / d;
1735
- e.fillStyle = P(n.profitFillColor, 0.95);
1736
- const v = a === "longPosition" ? r.profitBox.top + r.profitBox.height / 10 : r.profitBox.bottom - r.profitBox.height / 10;
1737
- e.fillText(`${l.toFixed(2)} (${g.toFixed(2)})`, u, v), e.fillStyle = P(n.lossFillColor, 0.95);
1745
+ e.fillStyle = x(n.profitFillColor, 0.95);
1746
+ const p = a === "longPosition" ? r.profitBox.top + r.profitBox.height / 10 : r.profitBox.bottom - r.profitBox.height / 10;
1747
+ e.fillText(`${l.toFixed(2)} (${g.toFixed(2)})`, u, p), e.fillStyle = x(n.lossFillColor, 0.95);
1738
1748
  const w = a === "shortPosition" ? r.lossBox.top + r.lossBox.height / 10 : r.lossBox.bottom - r.lossBox.height / 10;
1739
1749
  e.fillText(d.toFixed(1), u, w);
1740
1750
  }
@@ -2029,10 +2039,10 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2029
2039
  return this.resizeShape(e.shape, e.handleType, t, e.handleIndex);
2030
2040
  }
2031
2041
  moveShape(t, e) {
2032
- return t.type === "trendline" ? k.move(t, e) : t.type === "rectangle" ? D.move(t, e) : t.type === "path" ? R.move(t, e) : t.type === "fibRetracement" ? L.move(t, e) : H.move(t, e);
2042
+ return t.type === "trendline" ? R.move(t, e) : t.type === "rectangle" ? A.move(t, e) : t.type === "path" ? D.move(t, e) : t.type === "fibRetracement" ? L.move(t, e) : H.move(t, e);
2033
2043
  }
2034
2044
  resizeShape(t, e, i, s) {
2035
- return t.type === "trendline" ? k.resize(t, e, i) : t.type === "rectangle" ? D.resize(t, e, i) : t.type === "fibRetracement" ? L.resize(t, e, i) : t.type === "path" ? R.resize(t, s ?? -1, i) : H.resize({
2045
+ return t.type === "trendline" ? R.resize(t, e, i) : t.type === "rectangle" ? A.resize(t, e, i) : t.type === "fibRetracement" ? L.resize(t, e, i) : t.type === "path" ? D.resize(t, s ?? -1, i) : H.resize({
2036
2046
  shape: t,
2037
2047
  handleType: e,
2038
2048
  vertex: i,
@@ -2042,7 +2052,7 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2042
2052
  drawShape({ shape: t, converter: e, selected: i, hovered: s }) {
2043
2053
  if (t.type === "trendline") {
2044
2054
  const n = this.getTrendlineConfig(t);
2045
- k.draw({
2055
+ R.draw({
2046
2056
  ctx: this.ctx,
2047
2057
  shape: t,
2048
2058
  converter: e,
@@ -2054,7 +2064,7 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2054
2064
  }
2055
2065
  if (t.type === "rectangle") {
2056
2066
  const n = this.getRectangleConfig(t);
2057
- D.draw({
2067
+ A.draw({
2058
2068
  ctx: this.ctx,
2059
2069
  shape: t,
2060
2070
  converter: e,
@@ -2066,7 +2076,7 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2066
2076
  }
2067
2077
  if (t.type === "path") {
2068
2078
  const n = this.getPathConfig(t);
2069
- R.draw({
2079
+ D.draw({
2070
2080
  ctx: this.ctx,
2071
2081
  shape: t,
2072
2082
  converter: e,
@@ -2102,7 +2112,7 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2102
2112
  drawDraft(t) {
2103
2113
  if (this.draft) {
2104
2114
  if (this.draft.type === "trendline") {
2105
- k.drawDraft({
2115
+ R.drawDraft({
2106
2116
  ctx: this.ctx,
2107
2117
  vertices: this.draft.vertices,
2108
2118
  converter: t,
@@ -2111,7 +2121,7 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2111
2121
  return;
2112
2122
  }
2113
2123
  if (this.draft.type === "rectangle") {
2114
- D.drawDraft({
2124
+ A.drawDraft({
2115
2125
  ctx: this.ctx,
2116
2126
  vertices: this.draft.vertices,
2117
2127
  converter: t,
@@ -2128,7 +2138,7 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2128
2138
  });
2129
2139
  return;
2130
2140
  }
2131
- this.draft.type === "path" && R.drawDraft({
2141
+ this.draft.type === "path" && D.drawDraft({
2132
2142
  ctx: this.ctx,
2133
2143
  vertices: this.draft.vertices,
2134
2144
  previewVertex: this.draft.previewVertex,
@@ -2146,7 +2156,7 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2146
2156
  i && e.push(i), s && e.push(s), this.handleHitboxes = e.flatMap((r) => this.getShapeHandles(r, t));
2147
2157
  }
2148
2158
  getShapeHandles(t, e) {
2149
- return t.type === "trendline" ? k.getHandles(t, e) : t.type === "rectangle" ? D.getHandles(t, e) : t.type === "path" ? R.getHandles(t, e) : t.type === "fibRetracement" ? L.getHandles(t, e) : H.getHandles(t, e);
2159
+ return t.type === "trendline" ? R.getHandles(t, e) : t.type === "rectangle" ? A.getHandles(t, e) : t.type === "path" ? D.getHandles(t, e) : t.type === "fibRetracement" ? L.getHandles(t, e) : H.getHandles(t, e);
2150
2160
  }
2151
2161
  findHandleAtPoint(t) {
2152
2162
  for (let e = this.handleHitboxes.length - 1; e >= 0; e -= 1) {
@@ -2169,15 +2179,15 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2169
2179
  return null;
2170
2180
  }
2171
2181
  isShapeHit(t, e, i) {
2172
- return t.type === "trendline" ? k.hitTest({
2182
+ return t.type === "trendline" ? R.hitTest({
2173
2183
  point: e,
2174
2184
  shape: t,
2175
2185
  converter: i
2176
- }) : t.type === "rectangle" ? D.hitTest({
2186
+ }) : t.type === "rectangle" ? A.hitTest({
2177
2187
  point: e,
2178
2188
  shape: t,
2179
2189
  converter: i
2180
- }) : t.type === "path" ? R.hitTest({
2190
+ }) : t.type === "path" ? D.hitTest({
2181
2191
  point: e,
2182
2192
  shape: t,
2183
2193
  converter: i
@@ -2316,15 +2326,15 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2316
2326
  mergeConfig(t) {
2317
2327
  return {
2318
2328
  trendline: {
2319
- ...k.defaultConfig,
2329
+ ...R.defaultConfig,
2320
2330
  ...t?.trendline ?? {}
2321
2331
  },
2322
2332
  rectangle: {
2323
- ...D.defaultConfig,
2333
+ ...A.defaultConfig,
2324
2334
  ...t?.rectangle ?? {}
2325
2335
  },
2326
2336
  path: {
2327
- ...R.defaultConfig,
2337
+ ...D.defaultConfig,
2328
2338
  ...t?.path ?? {}
2329
2339
  },
2330
2340
  fibRetracement: {
@@ -2392,10 +2402,10 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2392
2402
  this.drawTemporaryProtectionDrag();
2393
2403
  }
2394
2404
  createHitBox = ({ price: t, trade: e, type: i, x: s, y: r, width: n, height: a, viewport: o }) => {
2395
- const { showCloseSection: l, widthClose: d } = this.getHandleStyleConfig(i).handle, u = l ? d : 0, g = n - u, v = s + n - u;
2405
+ const { showCloseSection: l, widthClose: d } = this.getHandleStyleConfig(i).handle, u = l ? d : 0, g = n - u, p = s + n - u;
2396
2406
  return {
2397
2407
  kind: "existingHandle",
2398
- price: p(t),
2408
+ price: m(t),
2399
2409
  trade: e,
2400
2410
  type: i,
2401
2411
  x: s,
@@ -2410,7 +2420,7 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2410
2420
  height: a
2411
2421
  },
2412
2422
  closeButtonArea: {
2413
- x: v,
2423
+ x: p,
2414
2424
  y: r,
2415
2425
  width: u,
2416
2426
  height: a
@@ -2419,7 +2429,7 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2419
2429
  };
2420
2430
  createMissingProtectionHitBox = ({ price: t, trade: e, type: i, x: s, y: r, width: n, height: a, viewport: o }) => ({
2421
2431
  kind: "missingProtectionHandle",
2422
- price: p(t),
2432
+ price: m(t),
2423
2433
  trade: e,
2424
2434
  type: i,
2425
2435
  x: s,
@@ -2526,12 +2536,12 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2526
2536
  });
2527
2537
  let g = e;
2528
2538
  l.save(), l.font = d.font, l.textBaseline = "middle", l.globalAlpha = d.textOpacity;
2529
- for (const v of u)
2530
- v.visible && (this.drawHandleSectionLabel({
2531
- section: v,
2539
+ for (const p of u)
2540
+ p.visible && (this.drawHandleSectionLabel({
2541
+ section: p,
2532
2542
  currentX: g,
2533
2543
  y: o
2534
- }), g += v.width, g < e + s && this.drawHandleSectionDivider({
2544
+ }), g += p.width, g < e + s && this.drawHandleSectionDivider({
2535
2545
  x: g,
2536
2546
  y1: i + 4,
2537
2547
  y2: i + r - 4,
@@ -2580,7 +2590,7 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2580
2590
  return this.getProtectionDirection({
2581
2591
  trade: e,
2582
2592
  type: i
2583
- }) > 0 ? p(Math.max(t, e.openPrice)) : p(Math.min(t, e.openPrice));
2593
+ }) > 0 ? m(Math.max(t, e.openPrice)) : m(Math.min(t, e.openPrice));
2584
2594
  }
2585
2595
  clearCanvas() {
2586
2596
  this.#e.clearRect(0, 0, this.#t.width, this.#t.height);
@@ -2650,10 +2660,10 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2650
2660
  }
2651
2661
  drawClosedTradeArrow({ x: t, y: e, type: i, width: s, height: r, config: n }) {
2652
2662
  if (s <= 0 || r <= 0) return;
2653
- const a = this.#e, o = i === "buy", l = o ? n.buyColor : n.sellColor, d = o ? n.buyBorderColor : n.sellBorderColor, u = o ? 1 : -1, g = Math.max(1, s / n.shaftWidthRatio), v = g + n.borderWidth * 2, w = t, m = e + u * (v / 2), S = t, T = m + u * r, M = r * n.headHeightRatio, et = s / 2, Ht = w - et, Mt = w + et, N = m + u * M, it = () => {
2654
- a.beginPath(), a.moveTo(S, T), a.lineTo(w, N), a.moveTo(w, m), a.lineTo(Ht, N), a.moveTo(w, m), a.lineTo(Mt, N), a.stroke();
2663
+ const a = this.#e, o = i === "buy", l = o ? n.buyColor : n.sellColor, d = o ? n.buyBorderColor : n.sellBorderColor, u = o ? 1 : -1, g = Math.max(1, s / n.shaftWidthRatio), p = g + n.borderWidth * 2, w = t, C = e + u * (p / 2), S = t, T = C + u * r, k = r * n.headHeightRatio, et = s / 2, Ht = w - et, Mt = w + et, N = C + u * k, it = () => {
2664
+ a.beginPath(), a.moveTo(S, T), a.lineTo(w, N), a.moveTo(w, C), a.lineTo(Ht, N), a.moveTo(w, C), a.lineTo(Mt, N), a.stroke();
2655
2665
  };
2656
- a.save(), a.globalAlpha = n.opacity, a.lineCap = "round", a.lineJoin = "round", a.strokeStyle = d, a.lineWidth = v, it(), a.strokeStyle = l, a.lineWidth = g, it(), a.restore();
2666
+ a.save(), a.globalAlpha = n.opacity, a.lineCap = "round", a.lineJoin = "round", a.strokeStyle = d, a.lineWidth = p, it(), a.strokeStyle = l, a.lineWidth = g, it(), a.restore();
2657
2667
  }
2658
2668
  getTimeX(t) {
2659
2669
  if (!this.viewport || this.candles.length === 0 || !Number.isFinite(t)) return null;
@@ -2915,7 +2925,7 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2915
2925
  }
2916
2926
  getTemporaryProtectionRenderState() {
2917
2927
  if (!this.temporaryProtectionDrag) return null;
2918
- const { trade: t, type: e, viewport: i } = this.temporaryProtectionDrag, s = p(this.temporaryProtectionDrag.price), r = this.getPriceY(s, i), n = this.getTemporaryProtectionHandleConfig(e), a = this.getTemporaryProtectionLineConfig(e), o = n.widthPNL, l = n.height;
2928
+ const { trade: t, type: e, viewport: i } = this.temporaryProtectionDrag, s = m(this.temporaryProtectionDrag.price), r = this.getPriceY(s, i), n = this.getTemporaryProtectionHandleConfig(e), a = this.getTemporaryProtectionLineConfig(e), o = n.widthPNL, l = n.height;
2919
2929
  return {
2920
2930
  price: s,
2921
2931
  type: e,
@@ -2988,29 +2998,29 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
2988
2998
  ], ee = class {
2989
2999
  #t;
2990
3000
  #e;
2991
- #r;
2992
- #s;
2993
- #u;
3001
+ #n;
2994
3002
  #i;
2995
3003
  #h;
2996
3004
  #g;
2997
- #n;
2998
- #o = null;
3005
+ #s;
3006
+ #o;
3007
+ #f;
3008
+ #r = null;
2999
3009
  #a = null;
3000
3010
  #d = !1;
3011
+ #u = 0;
3001
3012
  #l = 0;
3002
- #C = 0;
3003
3013
  constructor(t) {
3004
- this.#t = t.canvas, this.#e = t.getHandleHitboxes, this.#r = t.getCurrentPrice, this.#s = t.onDrag, this.#u = t.onMissingProtectionDrag, this.#i = t.onMissingProtectionDragEnd, this.#h = t.onMissingProtectionDragCancel, this.#g = t.onTradeModified, this.#n = t.onTradeCloseClicked;
3014
+ this.#t = t.canvas, this.#e = t.getHandleHitboxes, this.#n = t.getCurrentPrice, this.#i = t.onDrag, this.#h = t.onMissingProtectionDrag, this.#g = t.onMissingProtectionDragEnd, this.#s = t.onMissingProtectionDragCancel, this.#o = t.onTradeModified, this.#f = t.onTradeCloseClicked;
3005
3015
  }
3006
3016
  cancelActiveInteraction() {
3007
- this.#a && this.#h?.(), this.#o = null, this.#a = null, this.#d = !1, this.#l = 0, this.#C = 0;
3017
+ this.#a && this.#s?.(), this.#r = null, this.#a = null, this.#d = !1, this.#u = 0, this.#l = 0;
3008
3018
  }
3009
3019
  handlePointerEvent(t) {
3010
3020
  if (!this.isSupportedEventType(t.type)) return !1;
3011
3021
  const e = this.getCanvasMousePoint(t);
3012
3022
  if (t.type === "pointermove" && this.#a) return this.handleActiveMissingProtectionDrag(t, e);
3013
- if (t.type === "pointermove" && this.#o) return this.handleActiveDrag(t, e);
3023
+ if (t.type === "pointermove" && this.#r) return this.handleActiveDrag(t, e);
3014
3024
  if (t.type === "pointerup")
3015
3025
  return this.#a ? this.handleMissingProtectionDragEnd() : this.handleDragEnd();
3016
3026
  const i = this.getHoveredHitbox(e);
@@ -3027,39 +3037,39 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3027
3037
  };
3028
3038
  }
3029
3039
  handleActiveDrag(t, e) {
3030
- if (!this.#o) return !1;
3040
+ if (!this.#r) return !1;
3031
3041
  const i = this.getNextDragPrice(e.y);
3032
- return this.#o.price = i, this.#s?.({
3033
- trade: this.#o.trade,
3034
- type: this.#o.type,
3042
+ return this.#r.price = i, this.#i?.({
3043
+ trade: this.#r.trade,
3044
+ type: this.#r.type,
3035
3045
  price: i
3036
3046
  }), this.consumeEvent(t), !0;
3037
3047
  }
3038
3048
  handleActiveMissingProtectionDrag(t, e) {
3039
3049
  if (!this.#a || !this.isProtectionHandleType(this.#a.type)) return !1;
3040
- const i = e.y - this.#l, s = c.tradeHandles.missingProtectionHandles.dragActivationThresholdPx;
3050
+ const i = e.y - this.#u, s = c.tradeHandles.missingProtectionHandles.dragActivationThresholdPx;
3041
3051
  if (!this.#d && Math.abs(i) < s)
3042
3052
  return this.consumeEvent(t), !0;
3043
3053
  this.#d = !0;
3044
3054
  const r = this.getNextMissingProtectionPrice(e.y);
3045
- return this.#a.price = r, this.#u?.({
3055
+ return this.#a.price = r, this.#h?.({
3046
3056
  trade: this.#a.trade,
3047
3057
  type: this.#a.type,
3048
3058
  price: r
3049
3059
  }), this.consumeEvent(t), !0;
3050
3060
  }
3051
3061
  getNextDragPrice(t) {
3052
- if (!this.#o) return 0;
3053
- const e = t - this.#l, i = this.#o.viewport.priceRange / this.#t.height, s = p(this.#C - e * i);
3054
- return this.isProtectionHandleType(this.#o.type) ? this.constrainExistingProtectionPrice({
3062
+ if (!this.#r) return 0;
3063
+ const e = t - this.#u, i = this.#r.viewport.priceRange / this.#t.height, s = m(this.#l - e * i);
3064
+ return this.isProtectionHandleType(this.#r.type) ? this.constrainExistingProtectionPrice({
3055
3065
  price: s,
3056
- hitbox: this.#o,
3057
- type: this.#o.type
3066
+ hitbox: this.#r,
3067
+ type: this.#r.type
3058
3068
  }) : s;
3059
3069
  }
3060
3070
  getNextMissingProtectionPrice(t) {
3061
3071
  if (!this.#a || !this.isProtectionHandleType(this.#a.type)) return 0;
3062
- const e = p(this.#a.viewport.minPrice + (this.#t.height - t) / this.#t.height * this.#a.viewport.priceRange);
3072
+ const e = m(this.#a.viewport.minPrice + (this.#t.height - t) / this.#t.height * this.#a.viewport.priceRange);
3063
3073
  return this.constrainProtectionPrice({
3064
3074
  price: e,
3065
3075
  hitbox: this.#a,
@@ -3067,27 +3077,27 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3067
3077
  });
3068
3078
  }
3069
3079
  handleDragEnd() {
3070
- return this.#o && this.modifyActiveDragTrade(), this.#o = null, !1;
3080
+ return this.#r && this.modifyActiveDragTrade(), this.#r = null, !1;
3071
3081
  }
3072
3082
  handleMissingProtectionDragEnd() {
3073
- return this.#a && this.#d && this.isProtectionHandleType(this.#a.type) ? this.#i?.({
3083
+ return this.#a && this.#d && this.isProtectionHandleType(this.#a.type) ? this.#g?.({
3074
3084
  trade: this.#a.trade,
3075
3085
  type: this.#a.type,
3076
- price: p(this.#a.price)
3077
- }) : this.#h?.(), this.#a = null, this.#d = !1, !1;
3086
+ price: m(this.#a.price)
3087
+ }) : this.#s?.(), this.#a = null, this.#d = !1, !1;
3078
3088
  }
3079
3089
  modifyActiveDragTrade() {
3080
- if (!this.#o) return;
3081
- const t = p(this.#o.price);
3082
- if (this.#o.type === "stopLoss") {
3083
- this.#g?.({
3084
- ticket: this.#o.trade.ticket,
3090
+ if (!this.#r) return;
3091
+ const t = m(this.#r.price);
3092
+ if (this.#r.type === "stopLoss") {
3093
+ this.#o?.({
3094
+ ticket: this.#r.trade.ticket,
3085
3095
  sl: t
3086
3096
  });
3087
3097
  return;
3088
3098
  }
3089
- this.#g?.({
3090
- ticket: this.#o.trade.ticket,
3099
+ this.#o?.({
3100
+ ticket: this.#r.trade.ticket,
3091
3101
  tp: t
3092
3102
  });
3093
3103
  }
@@ -3107,10 +3117,10 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3107
3117
  }
3108
3118
  handleCloseButtonClick(t) {
3109
3119
  if (t.type === "startPrice") {
3110
- this.#n?.({ ticket: t.trade.ticket });
3120
+ this.#f?.({ ticket: t.trade.ticket });
3111
3121
  return;
3112
3122
  }
3113
- this.#g?.({
3123
+ this.#o?.({
3114
3124
  ticket: t.trade.ticket,
3115
3125
  ...t.type === "stopLoss" ? { sl: null } : {},
3116
3126
  ...t.type === "takeProfit" ? { tp: null } : {}
@@ -3120,13 +3130,13 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3120
3130
  document.body.style.cursor = t.type === "startPrice" ? "crosshair" : "ns-resize";
3121
3131
  }
3122
3132
  startDrag(t, e) {
3123
- this.#o = t, this.#l = e, this.#C = t.price;
3133
+ this.#r = t, this.#u = e, this.#l = t.price;
3124
3134
  }
3125
3135
  startMissingProtectionDrag(t, e) {
3126
- this.#a = t, this.#l = e, this.#d = !1;
3136
+ this.#a = t, this.#u = e, this.#d = !1;
3127
3137
  }
3128
3138
  resetCursorIfIdle() {
3129
- !this.#o && !this.#a && (document.body.style.cursor = "crosshair");
3139
+ !this.#r && !this.#a && (document.body.style.cursor = "crosshair");
3130
3140
  }
3131
3141
  isPointInsideArea(t, e) {
3132
3142
  const i = t.x >= e.x && t.x <= e.x + e.width, s = t.y >= e.y && t.y <= e.y + e.height;
@@ -3136,12 +3146,12 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3136
3146
  return t === "stopLoss" || t === "takeProfit";
3137
3147
  }
3138
3148
  constrainExistingProtectionPrice({ price: t, hitbox: e, type: i }) {
3139
- const s = this.isBuyTrade(e), r = e.trade.openPrice, n = this.#r?.() ?? 0;
3140
- return p(i === "takeProfit" ? s ? Math.max(t, r, n) : Math.min(t, r, n) : s ? Math.min(t, n) : Math.max(t, n));
3149
+ const s = this.isBuyTrade(e), r = e.trade.openPrice, n = this.#n?.() ?? 0;
3150
+ return m(i === "takeProfit" ? s ? Math.max(t, r, n) : Math.min(t, r, n) : s ? Math.min(t, n) : Math.max(t, n));
3141
3151
  }
3142
3152
  constrainProtectionPrice({ price: t, hitbox: e, type: i }) {
3143
- const s = this.isBuyTrade(e), r = e.trade.openPrice, n = this.#r?.() ?? 0;
3144
- return p(i === "takeProfit" ? s ? Math.max(t, r, n) : Math.min(t, r, n) : s ? Math.min(t, n) : Math.max(t, n));
3153
+ const s = this.isBuyTrade(e), r = e.trade.openPrice, n = this.#n?.() ?? 0;
3154
+ return m(i === "takeProfit" ? s ? Math.max(t, r, n) : Math.min(t, r, n) : s ? Math.min(t, n) : Math.max(t, n));
3145
3155
  }
3146
3156
  isBuyTrade(t) {
3147
3157
  return String(t.trade.type).toLowerCase().includes("buy");
@@ -3235,30 +3245,107 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3235
3245
  clearCanvas() {
3236
3246
  this.#e.clearRect(0, 0, this.#t.width, this.#t.height);
3237
3247
  }
3238
- }, X = (t) => {
3248
+ }, se = {
3249
+ center: {
3250
+ textAlign: "center",
3251
+ textBaseline: "middle"
3252
+ },
3253
+ "top-center": {
3254
+ textAlign: "center",
3255
+ textBaseline: "top"
3256
+ },
3257
+ "bottom-center": {
3258
+ textAlign: "center",
3259
+ textBaseline: "bottom"
3260
+ },
3261
+ "left-center": {
3262
+ textAlign: "left",
3263
+ textBaseline: "middle"
3264
+ },
3265
+ "right-center": {
3266
+ textAlign: "right",
3267
+ textBaseline: "middle"
3268
+ }
3269
+ }, re = ({ position: t, width: e, padding: i }) => {
3270
+ switch (t) {
3271
+ case "left-center":
3272
+ return i;
3273
+ case "right-center":
3274
+ return e - i;
3275
+ default:
3276
+ return e / 2;
3277
+ }
3278
+ }, ne = ({ position: t, height: e, padding: i }) => {
3279
+ switch (t) {
3280
+ case "top-center":
3281
+ return i;
3282
+ case "bottom-center":
3283
+ return e - i;
3284
+ default:
3285
+ return e / 2;
3286
+ }
3287
+ }, ae = (t) => ({
3288
+ ...se[t.position],
3289
+ x: re(t),
3290
+ y: ne(t)
3291
+ }), oe = (t) => Number.isFinite(t) ? Math.min(Math.max(t, 0), 1) : 1, le = class {
3292
+ #t;
3293
+ #e;
3294
+ #n;
3295
+ #i = 0;
3296
+ #h = 0;
3297
+ constructor(t) {
3298
+ this.#t = t.canvas, this.#n = t.config;
3299
+ const e = this.#t.getContext("2d");
3300
+ if (!e) throw new Error("Canvas 2D context not supported");
3301
+ this.#e = e;
3302
+ }
3303
+ setConfig(t) {
3304
+ this.#n = t;
3305
+ }
3306
+ resize(t, e) {
3307
+ this.#i = t, this.#h = e;
3308
+ }
3309
+ render() {
3310
+ const t = this.#e, { text: e } = this.#n;
3311
+ if (t.setTransform(1, 0, 0, 1, 0, 0), t.clearRect(0, 0, this.#t.width, this.#t.height), !e || this.#i <= 0 || this.#h <= 0) return;
3312
+ const { x: i, y: s, textAlign: r, textBaseline: n } = ae({
3313
+ position: this.#n.position,
3314
+ width: this.#i,
3315
+ height: this.#h,
3316
+ padding: this.#n.padding
3317
+ });
3318
+ t.save(), t.font = this.#g(), t.textAlign = r, t.textBaseline = n, t.fillStyle = this.#n.color, t.globalAlpha = oe(this.#n.opacity), t.fillText(e, i, s), t.restore();
3319
+ }
3320
+ #g() {
3321
+ const { fontSize: t, fontWeight: e, fontFamily: i } = this.#n;
3322
+ return `${e} ${t}px ${i}`;
3323
+ }
3324
+ }, M = (t) => {
3239
3325
  const e = document.createElement("canvas");
3240
3326
  return e.className = t, e;
3241
- }, se = (t, e) => {
3327
+ }, he = (t, e) => {
3242
3328
  const i = document.createElement("div");
3243
3329
  i.className = "trading-reload-chart", i.style.backgroundColor = e, i.tabIndex = 0;
3244
3330
  const s = document.createElement("div");
3245
3331
  s.className = "trading-reload-chart__layout";
3246
3332
  const r = document.createElement("div");
3247
3333
  r.className = "trading-reload-chart__stack";
3248
- const n = X("trading-reload-chart__volume"), a = X("trading-reload-chart__plot"), o = X("trading-reload-chart__shapes"), l = X("trading-reload-chart__trades"), d = X("trading-reload-chart__overlay"), u = X("trading-reload-chart__axis-x");
3249
- r.append(n, a, o, l, d, u);
3250
- const g = X("trading-reload-chart__axis-y");
3251
- return s.append(r, g), i.append(s), t.append(i), {
3334
+ const n = M("trading-reload-chart__volume"), a = M("trading-reload-chart__watermark"), o = M("trading-reload-chart__plot"), l = M("trading-reload-chart__shapes"), d = M("trading-reload-chart__trades"), u = M("trading-reload-chart__overlay"), g = M("trading-reload-chart__axis-x");
3335
+ r.append(n, a, o, l, d, u, g);
3336
+ const p = M("trading-reload-chart__axis-y");
3337
+ return s.append(r, p), i.append(s), t.append(i), {
3252
3338
  root: i,
3253
3339
  layout: s,
3254
3340
  stack: r,
3255
3341
  volumeCanvas: n,
3256
- candleCanvas: a,
3257
- shapesCanvas: o,
3258
- tradesCanvas: l,
3259
- overlayCanvas: d,
3260
- axisXCanvas: u,
3261
- axisYCanvas: g,
3342
+ watermarkCanvas: a,
3343
+ candleCanvas: o,
3344
+ shapesCanvas: l,
3345
+ tradesCanvas: d,
3346
+ overlayCanvas: u,
3347
+ axisXCanvas: g,
3348
+ axisYCanvas: p,
3262
3349
  interactionTarget: s
3263
3350
  };
3264
3351
  }, gt = (t) => typeof t == "object" && t !== null && !Array.isArray(t), Lt = (t, e) => {
@@ -3277,70 +3364,74 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3277
3364
  }, ft = (t) => Lt(c, t ?? {}), pt = (t, e) => e === void 0 || t.time >= 1e12 ? t : {
3278
3365
  ...t,
3279
3366
  time: t.time * 1e3 - e
3280
- }, re = 12, ne = class {
3367
+ }, de = 0, ce = 50, ue = (t) => !t.ctrlKey && !t.metaKey || t.deltaMode === de && Math.abs(t.deltaY) < ce ? "x" : "y", ge = 12, fe = class {
3281
3368
  #t;
3282
3369
  #e;
3283
- #r;
3284
- #s = null;
3285
- #u = null;
3370
+ #n;
3286
3371
  #i = null;
3287
3372
  #h = null;
3288
3373
  #g = null;
3289
- #n = null;
3374
+ #s = null;
3290
3375
  #o = null;
3376
+ #f = null;
3377
+ #r = null;
3291
3378
  #a = null;
3292
3379
  #d = null;
3380
+ #u = null;
3293
3381
  #l = null;
3294
- #C = !1;
3295
- #P = 0;
3296
3382
  #x = !1;
3297
- #R = 0;
3383
+ #P = 0;
3384
+ #S = !1;
3298
3385
  #D = 0;
3299
- #f = null;
3386
+ #A = 0;
3387
+ #p = null;
3300
3388
  #v = null;
3301
- #S = null;
3302
3389
  #T = null;
3390
+ #L = null;
3303
3391
  #X = !1;
3304
3392
  #b = !1;
3305
3393
  #I = null;
3306
3394
  #y = null;
3307
3395
  constructor(t, e) {
3308
- this.#t = t, this.#e = e, this.#r = ft(e.config), this.#s = se(t, this.#r.colors.background), this.#l = new Ot({
3309
- canvas: this.#s.overlayCanvas,
3310
- crosshairColor: this.#r.crosshair.color,
3311
- crosshairThickness: this.#r.crosshair.thickness,
3312
- crosshairStyle: this.#r.crosshair.style
3313
- }), this.#z(), this.#N(), this.#B(), this.updateProps(e);
3396
+ this.#t = t, this.#e = e, this.#n = ft(e.config), this.#i = he(t, this.#n.colors.background), this.#l = new Ot({
3397
+ canvas: this.#i.overlayCanvas,
3398
+ crosshairColor: this.#n.crosshair.color,
3399
+ crosshairThickness: this.#n.crosshair.thickness,
3400
+ crosshairStyle: this.#n.crosshair.style
3401
+ }), this.#g = new le({
3402
+ canvas: this.#i.watermarkCanvas,
3403
+ config: this.#n.watermark
3404
+ }), this.#N(), this.#_(), this.#W(), this.updateProps(e);
3314
3405
  }
3315
3406
  updateProps(t) {
3316
3407
  const e = this.#e.activeShapeTool;
3317
- this.#e = t, this.#r = ft(t.config), this.#s && (this.#s.root.style.backgroundColor = this.#r.colors.background, this.#s.layout.style.setProperty("--axis-x-height", `${this.#r.axis.axisX.height}px`)), !this.#C && t.candles.length > 0 && this.#O(t.candles), this.#i && (t.activeShapeTool !== e && this.#U(t.activeShapeTool), this.#h?.setConfig(this.#r.shapes), this.#h?.setShapes(t.shapes), this.#h?.setActiveTool(t.activeShapeTool), this.#g?.setConfig(this.#r.shapes.previousDayHighLow ?? null), this.#g?.setPreviousDay(t.previousDay), this.#n?.setClosedTrades(t.closedTrades ?? []), this.#M(), this.#q(), this.#c(), this.#m());
3408
+ this.#e = t, this.#n = ft(t.config), this.#i && (this.#i.root.style.backgroundColor = this.#n.colors.background, this.#i.layout.style.setProperty("--axis-x-height", `${this.#n.axis.axisX.height}px`)), !this.#x && t.candles.length > 0 && this.#z(t.candles), this.#s && (t.activeShapeTool !== e && this.#$(t.activeShapeTool), this.#o?.setConfig(this.#n.shapes), this.#o?.setShapes(t.shapes), this.#o?.setActiveTool(t.activeShapeTool), this.#g?.setConfig(this.#n.watermark), this.#f?.setConfig(this.#n.shapes.previousDayHighLow ?? null), this.#f?.setPreviousDay(t.previousDay), this.#r?.setClosedTrades(t.closedTrades ?? []), this.#k(), this.#K(), this.#c(), this.#C());
3318
3409
  }
3319
3410
  resetChartView() {
3320
- this.#i?.resetView(), this.#c(), this.#m();
3411
+ this.#s?.resetView(), this.#c(), this.#C();
3321
3412
  }
3322
3413
  setView(t) {
3323
- this.#i && (this.#X = !0, this.#i.setViewState(t), this.#X = !1, this.#I = this.#i.getViewState(), this.#c());
3414
+ this.#s && (this.#X = !0, this.#s.setViewState(t), this.#X = !1, this.#I = this.#s.getViewState(), this.#c());
3324
3415
  }
3325
3416
  getView() {
3326
- return this.#i?.getViewState() ?? null;
3417
+ return this.#s?.getViewState() ?? null;
3327
3418
  }
3328
3419
  setCursor(t) {
3329
3420
  if (!t) {
3330
- this.#b = !0, this.#F(), this.#b = !1, this.#y = null;
3421
+ this.#b = !0, this.#V(), this.#b = !1, this.#y = null;
3331
3422
  return;
3332
3423
  }
3333
- if (!this.#i || !this.#l || !this.#s) return;
3334
- const e = this.#i.setCursorState(t);
3335
- e && (this.#b = !0, this.#l.setPosition(e.x, e.y), this.#a?.setCrosshair({
3424
+ if (!this.#s || !this.#l || !this.#i) return;
3425
+ const e = this.#s.setCursorState(t);
3426
+ e && (this.#b = !0, this.#l.setPosition(e.x, e.y), this.#d?.setCrosshair({
3336
3427
  visible: !0,
3337
3428
  x: e.x,
3338
3429
  candle: e.candle
3339
- }), this.#d?.setCrosshair({
3430
+ }), this.#u?.setCrosshair({
3340
3431
  visible: !0,
3341
3432
  y: e.y,
3342
3433
  price: t.price
3343
- }), this.#L(), this.#l.render(), this.#b = !1, this.#y = {
3434
+ }), this.#H(), this.#l.render(), this.#b = !1, this.#y = {
3344
3435
  ...t,
3345
3436
  time: e.candle.time
3346
3437
  });
@@ -3349,37 +3440,37 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3349
3440
  this.setCursor(null);
3350
3441
  }
3351
3442
  destroy() {
3352
- this.#T?.abort(), this.#T = null, this.#S?.disconnect(), this.#S = null, this.#s?.root.remove(), this.#s = null, this.#u = null, this.#i = null, this.#h = null, this.#g = null, this.#n = null, this.#o = null, this.#a = null, this.#d = null, this.#l = null, this.#f = null, this.#C = !1;
3443
+ this.#L?.abort(), this.#L = null, this.#T?.disconnect(), this.#T = null, this.#i?.root.remove(), this.#i = null, this.#h = null, this.#g = null, this.#s = null, this.#o = null, this.#f = null, this.#r = null, this.#a = null, this.#d = null, this.#u = null, this.#l = null, this.#p = null, this.#x = !1;
3353
3444
  }
3354
- #O(t) {
3355
- if (!this.#s || this.#C) return;
3445
+ #z(t) {
3446
+ if (!this.#i || this.#x) return;
3356
3447
  const e = t.map((s) => pt(s, this.#e.brokerTimezoneOffsetMs));
3357
- this.#u = new ie({
3358
- canvas: this.#s.volumeCanvas,
3448
+ this.#h = new ie({
3449
+ canvas: this.#i.volumeCanvas,
3359
3450
  candles: e,
3360
- bullishColor: this.#r.volume.bullishColor,
3361
- bearishColor: this.#r.volume.bearishColor,
3362
- opacity: this.#r.volume.opacity,
3363
- height: this.#r.volume.height,
3364
- bottomOffset: this.#r.volume.bottomOffset,
3365
- minBarHeight: this.#r.volume.minBarHeight
3366
- }), this.#i = new Nt({
3367
- canvas: this.#s.candleCanvas,
3451
+ bullishColor: this.#n.volume.bullishColor,
3452
+ bearishColor: this.#n.volume.bearishColor,
3453
+ opacity: this.#n.volume.opacity,
3454
+ height: this.#n.volume.height,
3455
+ bottomOffset: this.#n.volume.bottomOffset,
3456
+ minBarHeight: this.#n.volume.minBarHeight
3457
+ }), this.#s = new Nt({
3458
+ canvas: this.#i.candleCanvas,
3368
3459
  candles: e,
3369
- baseCandleWidth: this.#r.candles.defaultWidth,
3370
- baseCandleGap: this.#r.candles.defaultGap,
3371
- bullishColor: this.#r.colors.bullish,
3372
- bearishColor: this.#r.colors.bearish,
3373
- autoFollowLatestCandle: this.#r.candles.autoFollowLatestCandle,
3374
- autoFollowThresholdCandles: this.#r.candles.autoFollowThresholdCandles,
3375
- rightOffsetCandles: this.#r.candles.rightOffsetCandles
3376
- }), this.#h = new Zt({
3377
- canvas: this.#s.shapesCanvas,
3460
+ baseCandleWidth: this.#n.candles.defaultWidth,
3461
+ baseCandleGap: this.#n.candles.defaultGap,
3462
+ bullishColor: this.#n.colors.bullish,
3463
+ bearishColor: this.#n.colors.bearish,
3464
+ autoFollowLatestCandle: this.#n.candles.autoFollowLatestCandle,
3465
+ autoFollowThresholdCandles: this.#n.candles.autoFollowThresholdCandles,
3466
+ rightOffsetCandles: this.#n.candles.rightOffsetCandles
3467
+ }), this.#o = new Zt({
3468
+ canvas: this.#i.shapesCanvas,
3378
3469
  activeSymbol: this.#e.activeSymbol,
3379
3470
  candles: e,
3380
3471
  shapes: this.#e.shapes,
3381
3472
  activeTool: this.#e.activeShapeTool,
3382
- config: this.#r.shapes,
3473
+ config: this.#n.shapes,
3383
3474
  onShapeAdded: (s) => {
3384
3475
  this.#e.onShapeAdded?.(s);
3385
3476
  },
@@ -3399,44 +3490,44 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3399
3490
  this.#e.onActiveShapeToolChange?.(s);
3400
3491
  }
3401
3492
  });
3402
- const i = this.#s.shapesCanvas.getContext("2d");
3403
- i && (this.#g = new _t({
3493
+ const i = this.#i.shapesCanvas.getContext("2d");
3494
+ i && (this.#f = new _t({
3404
3495
  ctx: i,
3405
- config: this.#r.shapes.previousDayHighLow ?? null
3406
- }), this.#g.setPreviousDay(this.#e.previousDay)), this.#n = new Qt({ canvas: this.#s.tradesCanvas }), this.#n.setCandles(e), this.#n.setClosedTrades(this.#e.closedTrades ?? []), this.#M(), this.#a = new Vt({
3407
- canvas: this.#s.axisXCanvas,
3496
+ config: this.#n.shapes.previousDayHighLow ?? null
3497
+ }), this.#f.setPreviousDay(this.#e.previousDay)), this.#r = new Qt({ canvas: this.#i.tradesCanvas }), this.#r.setCandles(e), this.#r.setClosedTrades(this.#e.closedTrades ?? []), this.#k(), this.#d = new Vt({
3498
+ canvas: this.#i.axisXCanvas,
3408
3499
  candles: e
3409
- }), this.#d = new Et({ canvas: this.#s.axisYCanvas }), this.#o = new ee({
3410
- canvas: this.#s.tradesCanvas,
3411
- getHandleHitboxes: () => this.#p() ? [] : this.#n?.handleHitboxes ?? [],
3412
- getCurrentPrice: () => this.#i?.liveCandle?.close ?? 0,
3413
- onDrag: (s) => this.#K(s),
3414
- onMissingProtectionDrag: (s) => this.#J(s),
3415
- onMissingProtectionDragEnd: (s) => this.#j(s),
3416
- onMissingProtectionDragCancel: () => this.#Z(),
3417
- onTradeModified: (s) => this.#W(s),
3500
+ }), this.#u = new Et({ canvas: this.#i.axisYCanvas }), this.#a = new ee({
3501
+ canvas: this.#i.tradesCanvas,
3502
+ getHandleHitboxes: () => this.#m() ? [] : this.#r?.handleHitboxes ?? [],
3503
+ getCurrentPrice: () => this.#s?.liveCandle?.close ?? 0,
3504
+ onDrag: (s) => this.#J(s),
3505
+ onMissingProtectionDrag: (s) => this.#j(s),
3506
+ onMissingProtectionDragEnd: (s) => this.#Z(s),
3507
+ onMissingProtectionDragCancel: () => this.#Q(),
3508
+ onTradeModified: (s) => this.#F(s),
3418
3509
  onTradeCloseClicked: (s) => this.#e.onTradeClose?.(s)
3419
- }), this.#C = !0, this.#c();
3510
+ }), this.#x = !0, this.#c();
3420
3511
  }
3421
- #z() {
3422
- if (!this.#s) return;
3423
- this.#T = new AbortController();
3424
- const { signal: t } = this.#T, e = this.#s.interactionTarget;
3425
- e.addEventListener("pointerdown", (i) => this.#et(i), { signal: t }), e.addEventListener("pointerup", (i) => this.#st(i), { signal: t }), e.addEventListener("pointermove", (i) => this.#it(i), { signal: t }), e.addEventListener("pointerenter", (i) => this.#rt(i), { signal: t }), e.addEventListener("pointerleave", () => this.#nt(), { signal: t }), e.addEventListener("contextmenu", (i) => this.#at(i), { signal: t }), e.addEventListener("dblclick", (i) => this.#ot(i), { signal: t }), e.addEventListener("wheel", (i) => this.#Q(i), {
3512
+ #N() {
3513
+ if (!this.#i) return;
3514
+ this.#L = new AbortController();
3515
+ const { signal: t } = this.#L, e = this.#i.interactionTarget;
3516
+ e.addEventListener("pointerdown", (i) => this.#it(i), { signal: t }), e.addEventListener("pointerup", (i) => this.#rt(i), { signal: t }), e.addEventListener("pointermove", (i) => this.#st(i), { signal: t }), e.addEventListener("pointerenter", (i) => this.#nt(i), { signal: t }), e.addEventListener("pointerleave", () => this.#at(), { signal: t }), e.addEventListener("contextmenu", (i) => this.#ot(i), { signal: t }), e.addEventListener("dblclick", (i) => this.#lt(i), { signal: t }), e.addEventListener("wheel", (i) => this.#tt(i), {
3426
3517
  passive: !1,
3427
3518
  signal: t
3428
- }), this.#s.axisXCanvas.addEventListener("pointerenter", (i) => this.#V(i), { signal: t }), this.#s.axisXCanvas.addEventListener("pointerdown", (i) => this.#Y(i, "x"), { signal: t }), this.#s.axisXCanvas.addEventListener("pointermove", (i) => this.#E(i), { signal: t }), this.#s.axisXCanvas.addEventListener("pointerup", (i) => this.#k(i), { signal: t }), this.#s.axisXCanvas.addEventListener("pointercancel", (i) => this.#k(i), { signal: t }), this.#s.axisYCanvas.addEventListener("pointerenter", (i) => this.#V(i), { signal: t }), this.#s.axisYCanvas.addEventListener("pointerdown", (i) => this.#Y(i, "y"), { signal: t }), this.#s.axisYCanvas.addEventListener("pointermove", (i) => this.#E(i), { signal: t }), this.#s.axisYCanvas.addEventListener("pointerup", (i) => this.#k(i), { signal: t }), this.#s.axisYCanvas.addEventListener("pointercancel", (i) => this.#k(i), { signal: t }), this.#s.axisYCanvas.addEventListener("wheel", (i) => this.#tt(i), {
3519
+ }), this.#i.axisXCanvas.addEventListener("pointerenter", (i) => this.#Y(i), { signal: t }), this.#i.axisXCanvas.addEventListener("pointerdown", (i) => this.#E(i, "x"), { signal: t }), this.#i.axisXCanvas.addEventListener("pointermove", (i) => this.#O(i), { signal: t }), this.#i.axisXCanvas.addEventListener("pointerup", (i) => this.#R(i), { signal: t }), this.#i.axisXCanvas.addEventListener("pointercancel", (i) => this.#R(i), { signal: t }), this.#i.axisYCanvas.addEventListener("pointerenter", (i) => this.#Y(i), { signal: t }), this.#i.axisYCanvas.addEventListener("pointerdown", (i) => this.#E(i, "y"), { signal: t }), this.#i.axisYCanvas.addEventListener("pointermove", (i) => this.#O(i), { signal: t }), this.#i.axisYCanvas.addEventListener("pointerup", (i) => this.#R(i), { signal: t }), this.#i.axisYCanvas.addEventListener("pointercancel", (i) => this.#R(i), { signal: t }), this.#i.axisYCanvas.addEventListener("wheel", (i) => this.#et(i), {
3429
3520
  passive: !1,
3430
3521
  signal: t
3431
- }), document.addEventListener("keydown", (i) => this.#lt(i), { signal: t });
3432
- }
3433
- #N() {
3434
- this.#S = new ResizeObserver(() => {
3435
- this.#B(), this.#c(), this.#m();
3436
- }), this.#S.observe(this.#t);
3522
+ }), document.addEventListener("keydown", (i) => this.#ht(i), { signal: t });
3437
3523
  }
3438
3524
  #_() {
3439
- const t = this.#r.axis.axisY.width, e = this.#r.axis.axisX.height, i = this.#t.clientWidth, s = this.#t.clientHeight;
3525
+ this.#T = new ResizeObserver(() => {
3526
+ this.#W(), this.#c(), this.#C();
3527
+ }), this.#T.observe(this.#t);
3528
+ }
3529
+ #G() {
3530
+ const t = this.#n.axis.axisY.width, e = this.#n.axis.axisX.height, i = this.#t.clientWidth, s = this.#t.clientHeight;
3440
3531
  return {
3441
3532
  axisYWidth: t,
3442
3533
  axisXHeight: e,
@@ -3447,30 +3538,30 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3447
3538
  #w(t, e, i) {
3448
3539
  t.width = e, t.height = i;
3449
3540
  }
3450
- #B() {
3451
- if (!this.#s) return;
3452
- const { plotWidth: t, plotHeight: e, axisYWidth: i, axisXHeight: s } = this.#_();
3453
- if (this.#i && this.#P > 0 && t !== this.#P) {
3541
+ #W() {
3542
+ if (!this.#i) return;
3543
+ const { plotWidth: t, plotHeight: e, axisYWidth: i, axisXHeight: s } = this.#G();
3544
+ if (this.#s && this.#P > 0 && t !== this.#P) {
3454
3545
  const r = t - this.#P;
3455
- this.#i.panHorizontally(r);
3546
+ this.#s.panHorizontally(r);
3456
3547
  }
3457
- this.#P = t, this.#w(this.#s.volumeCanvas, t, e), this.#w(this.#s.candleCanvas, t, e), this.#w(this.#s.shapesCanvas, t, e), this.#w(this.#s.overlayCanvas, t, e), this.#w(this.#s.tradesCanvas, t, e), this.#w(this.#s.axisXCanvas, t, s), this.#w(this.#s.axisYCanvas, i, e);
3548
+ this.#P = t, this.#w(this.#i.volumeCanvas, t, e), this.#w(this.#i.watermarkCanvas, t, e), this.#w(this.#i.candleCanvas, t, e), this.#w(this.#i.shapesCanvas, t, e), this.#w(this.#i.overlayCanvas, t, e), this.#w(this.#i.tradesCanvas, t, e), this.#w(this.#i.axisXCanvas, t, s), this.#w(this.#i.axisYCanvas, i, e), this.#g?.resize(t, e);
3458
3549
  }
3459
- #L() {
3460
- this.#i && (this.#a?.setCandles(this.#i.candles), this.#a?.setViewport(this.#i.viewport), this.#a?.render(), this.#d?.setViewport(this.#i.viewport), this.#d?.render());
3550
+ #H() {
3551
+ this.#s && (this.#d?.setCandles(this.#s.candles), this.#d?.setViewport(this.#s.viewport), this.#d?.render(), this.#u?.setViewport(this.#s.viewport), this.#u?.render());
3461
3552
  }
3462
3553
  #c() {
3463
- this.#i && (this.#u?.setCandles(this.#i.candles), this.#u?.setLiveCandle(this.#i.liveCandle), this.#u?.setViewport(this.#i.viewport), this.#u?.render(), this.#i.render(), this.#h?.setCandles(this.#i.candles), this.#h?.setViewport(this.#i.viewport), this.#h?.render(), this.#g?.setViewport(this.#i.viewport), this.#g?.render(), this.#n?.setCandles(this.#i.candles), this.#n?.setViewport(this.#i.viewport), this.#n?.isDragging ? this.#n.renderLiveFeed() : this.#n?.render(), this.#L(), this.#l?.render());
3554
+ this.#s && (this.#h?.setCandles(this.#s.candles), this.#h?.setLiveCandle(this.#s.liveCandle), this.#h?.setViewport(this.#s.viewport), this.#h?.render(), this.#g?.render(), this.#s.render(), this.#o?.setCandles(this.#s.candles), this.#o?.setViewport(this.#s.viewport), this.#o?.render(), this.#f?.setViewport(this.#s.viewport), this.#f?.render(), this.#r?.setCandles(this.#s.candles), this.#r?.setViewport(this.#s.viewport), this.#r?.isDragging ? this.#r.renderLiveFeed() : this.#r?.render(), this.#H(), this.#l?.render());
3464
3555
  }
3465
- #p() {
3556
+ #m() {
3466
3557
  return this.#e.activeShapeTool !== null;
3467
3558
  }
3468
- #m() {
3559
+ #C() {
3469
3560
  if (this.#X) return;
3470
- const t = this.#i?.getViewState() ?? null;
3471
- !t || this.#G(this.#I, t) || (this.#I = t, this.#e.onViewChange?.(t));
3561
+ const t = this.#s?.getViewState() ?? null;
3562
+ !t || this.#U(this.#I, t) || (this.#I = t, this.#e.onViewChange?.(t));
3472
3563
  }
3473
- #H(t) {
3564
+ #M(t) {
3474
3565
  if (!this.#b) {
3475
3566
  if (!t) {
3476
3567
  if (this.#y === null) return;
@@ -3480,13 +3571,13 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3480
3571
  this.#y !== null && this.#y.time === t.time && this.#y.price === t.price || (this.#y = t, this.#e.onCursorMove?.(t));
3481
3572
  }
3482
3573
  }
3483
- #G(t, e) {
3574
+ #U(t, e) {
3484
3575
  return t !== null && Math.abs(t.rightmostVisibleTime - e.rightmostVisibleTime) < 0.5 && Math.abs(t.rightmostVisibleX - e.rightmostVisibleX) < 1e-4 && Math.abs(t.rightEdgeTime - e.rightEdgeTime) < 0.5 && Math.abs(t.visibleDurationMs - e.visibleDurationMs) < 0.5;
3485
3576
  }
3486
- #U(t) {
3487
- t !== null && (this.#x = !1, this.#n?.setIsDragging(!1), this.#o?.cancelActiveInteraction()), this.#h?.setActiveTool(t);
3577
+ #$(t) {
3578
+ t !== null && (this.#S = !1, this.#r?.setIsDragging(!1), this.#a?.cancelActiveInteraction()), this.#o?.setActiveTool(t);
3488
3579
  }
3489
- #$() {
3580
+ #q() {
3490
3581
  const t = this.#e.openTrades ?? [];
3491
3582
  return this.#v ? t.map((e) => e.ticket !== this.#v?.ticket ? e : {
3492
3583
  ...e,
@@ -3494,154 +3585,154 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3494
3585
  ...this.#v.tp !== void 0 ? { tp: this.#v.tp } : {}
3495
3586
  }) : t;
3496
3587
  }
3497
- #M() {
3498
- this.#n?.setTrades(this.#$());
3588
+ #k() {
3589
+ this.#r?.setTrades(this.#q());
3499
3590
  }
3500
- #q() {
3591
+ #K() {
3501
3592
  const t = this.#e.liveCandle;
3502
- if (!t || !this.#i) return;
3593
+ if (!t || !this.#s) return;
3503
3594
  const e = pt(t, this.#e.brokerTimezoneOffsetMs);
3504
- this.#i.updateLiveCandle(e), this.#n?.setLiveCandle(this.#i.liveCandle), this.#n?.setCandles(this.#i.candles);
3595
+ this.#s.updateLiveCandle(e), this.#r?.setLiveCandle(this.#s.liveCandle), this.#r?.setCandles(this.#s.candles);
3505
3596
  }
3506
- #K({ trade: t, type: e, price: i }) {
3507
- this.#n && (this.#n.setIsDragging(!0), this.#v = {
3597
+ #J({ trade: t, type: e, price: i }) {
3598
+ this.#r && (this.#r.setIsDragging(!0), this.#v = {
3508
3599
  ticket: t.ticket,
3509
3600
  ...e === "stopLoss" ? { sl: i } : {},
3510
3601
  ...e === "takeProfit" ? { tp: i } : {}
3511
- }, this.#M(), this.#n.render());
3602
+ }, this.#k(), this.#r.render());
3512
3603
  }
3513
- #J({ trade: t, type: e, price: i }) {
3514
- this.#n?.viewport && (this.#n.setIsDragging(!0), this.#n.setTemporaryProtectionDrag({
3604
+ #j({ trade: t, type: e, price: i }) {
3605
+ this.#r?.viewport && (this.#r.setIsDragging(!0), this.#r.setTemporaryProtectionDrag({
3515
3606
  visible: !0,
3516
3607
  trade: t,
3517
3608
  type: e,
3518
3609
  price: i,
3519
- viewport: this.#n.viewport
3520
- }), this.#n.render());
3610
+ viewport: this.#r.viewport
3611
+ }), this.#r.render());
3521
3612
  }
3522
- #j({ trade: t, type: e, price: i }) {
3523
- this.#n?.setIsDragging(!1), this.#W({
3613
+ #Z({ trade: t, type: e, price: i }) {
3614
+ this.#r?.setIsDragging(!1), this.#F({
3524
3615
  ticket: t.ticket,
3525
3616
  ...e === "stopLoss" ? { sl: i } : {},
3526
3617
  ...e === "takeProfit" ? { tp: i } : {}
3527
3618
  });
3528
3619
  }
3529
- #Z() {
3530
- this.#n?.setIsDragging(!1), this.#n?.clearTemporaryProtectionDrag(), this.#n?.render();
3620
+ #Q() {
3621
+ this.#r?.setIsDragging(!1), this.#r?.clearTemporaryProtectionDrag(), this.#r?.render();
3531
3622
  }
3532
- #W(t) {
3533
- this.#n?.setIsDragging(!1), this.#v = null, this.#n?.clearTemporaryProtectionDrag(), this.#e.onTradeModify?.(t), this.#M(), this.#n?.render();
3623
+ #F(t) {
3624
+ this.#r?.setIsDragging(!1), this.#v = null, this.#r?.clearTemporaryProtectionDrag(), this.#e.onTradeModify?.(t), this.#k(), this.#r?.render();
3534
3625
  }
3535
- #A(t) {
3536
- if (!this.#l || !this.#s) return null;
3537
- if (!this.#i)
3626
+ #B(t) {
3627
+ if (!this.#l || !this.#i) return null;
3628
+ if (!this.#s)
3538
3629
  return this.#l.updateMousePosition(t.clientX, t.clientY), this.#l.render(), null;
3539
- const e = vt(this.#s.overlayCanvas, t), i = this.#i.getNearestCandleIndexByX(e.x), s = i === null ? null : this.#i.candles[i] ?? null, r = i === null ? e.x : this.#i.getRawCandleSnapX(e.x);
3630
+ const e = vt(this.#i.overlayCanvas, t), i = this.#s.getNearestCandleIndexByX(e.x), s = i === null ? null : this.#s.candles[i] ?? null, r = i === null ? e.x : this.#s.getRawCandleSnapX(e.x);
3540
3631
  this.#l.updateMousePosition(t.clientX, t.clientY, { snapX: r });
3541
- const n = this.#i.getPriceAtY(this.#l.mouseY);
3542
- return this.#d?.setCrosshair({
3632
+ const n = this.#s.getPriceAtY(this.#l.mouseY);
3633
+ return this.#u?.setCrosshair({
3543
3634
  visible: !0,
3544
3635
  y: this.#l.mouseY,
3545
3636
  price: n
3546
- }), this.#a?.setCrosshair({
3637
+ }), this.#d?.setCrosshair({
3547
3638
  visible: !0,
3548
3639
  x: this.#l.mouseX,
3549
3640
  candle: s
3550
- }), this.#L(), this.#l.render(), s ? {
3641
+ }), this.#H(), this.#l.render(), s ? {
3551
3642
  time: s.time,
3552
3643
  price: n
3553
3644
  } : null;
3554
3645
  }
3555
- #F() {
3556
- this.#l?.hide(), this.#a?.hideCrosshair(), this.#d?.hideCrosshair(), this.#L(), this.#l?.render();
3646
+ #V() {
3647
+ this.#l?.hide(), this.#d?.hideCrosshair(), this.#u?.hideCrosshair(), this.#H(), this.#l?.render();
3557
3648
  }
3558
- #Q(t) {
3559
- if (!this.#i || !this.#n) return;
3560
- this.#p() || this.#o?.handlePointerEvent(t), t.preventDefault();
3649
+ #tt(t) {
3650
+ if (!this.#s || !this.#r) return;
3651
+ this.#m() || this.#a?.handlePointerEvent(t), t.preventDefault();
3561
3652
  const e = t.deltaY < 0 ? 1 : -1;
3562
- t.ctrlKey || t.metaKey ? this.#i.zoomVertically(e) : this.#i.zoomHorizontally(e), this.#c(), this.#m();
3653
+ ue(t) === "y" ? this.#s.zoomVertically(e) : this.#s.zoomHorizontally(e), this.#c(), this.#C();
3563
3654
  }
3564
- #tt(t) {
3565
- if (!this.#i) return;
3655
+ #et(t) {
3656
+ if (!this.#s) return;
3566
3657
  t.preventDefault(), t.stopPropagation();
3567
3658
  const e = t.deltaY < 0 ? 1 : -1;
3568
- this.#i.zoomVertically(e), this.#c(), this.#m();
3659
+ this.#s.zoomVertically(e), this.#c(), this.#C();
3569
3660
  }
3570
- #V(t) {
3661
+ #Y(t) {
3571
3662
  const e = t.currentTarget;
3572
- e.style.cursor = e === this.#s?.axisXCanvas ? "ew-resize" : "ns-resize";
3663
+ e.style.cursor = e === this.#i?.axisXCanvas ? "ew-resize" : "ns-resize";
3573
3664
  }
3574
- #Y(t, e) {
3575
- t.stopPropagation(), t.button === 0 && (t.currentTarget.setPointerCapture(t.pointerId), this.#f = {
3665
+ #E(t, e) {
3666
+ t.stopPropagation(), t.button === 0 && (t.currentTarget.setPointerCapture(t.pointerId), this.#p = {
3576
3667
  axis: e,
3577
3668
  lastClientPosition: e === "x" ? t.clientX : t.clientY,
3578
3669
  pointerId: t.pointerId
3579
3670
  }, t.preventDefault());
3580
3671
  }
3581
- #E(t) {
3672
+ #O(t) {
3582
3673
  t.stopPropagation();
3583
- const e = t.currentTarget, i = e === this.#s?.axisXCanvas ? "x" : "y";
3584
- if (e.style.cursor = i === "x" ? "ew-resize" : "ns-resize", !this.#f || this.#f.pointerId !== t.pointerId || this.#f.axis !== i) return;
3585
- const s = i === "x" ? t.clientX : t.clientY, r = s - this.#f.lastClientPosition;
3586
- if (this.#f.lastClientPosition = s, !this.#i || r === 0) return;
3587
- const n = -r / re;
3588
- i === "x" ? this.#i.zoomHorizontally(n) : this.#i.zoomVertically(n), t.preventDefault(), this.#c(), this.#m();
3589
- }
3590
- #k(t) {
3591
- if (t.stopPropagation(), this.#f?.pointerId !== t.pointerId) return;
3674
+ const e = t.currentTarget, i = e === this.#i?.axisXCanvas ? "x" : "y";
3675
+ if (e.style.cursor = i === "x" ? "ew-resize" : "ns-resize", !this.#p || this.#p.pointerId !== t.pointerId || this.#p.axis !== i) return;
3676
+ const s = i === "x" ? t.clientX : t.clientY, r = s - this.#p.lastClientPosition;
3677
+ if (this.#p.lastClientPosition = s, !this.#s || r === 0) return;
3678
+ const n = -r / ge;
3679
+ i === "x" ? this.#s.zoomHorizontally(n) : this.#s.zoomVertically(n), t.preventDefault(), this.#c(), this.#C();
3680
+ }
3681
+ #R(t) {
3682
+ if (t.stopPropagation(), this.#p?.pointerId !== t.pointerId) return;
3592
3683
  const e = t.currentTarget;
3593
- e.hasPointerCapture(t.pointerId) && e.releasePointerCapture(t.pointerId), this.#f = null, t.preventDefault();
3684
+ e.hasPointerCapture(t.pointerId) && e.releasePointerCapture(t.pointerId), this.#p = null, t.preventDefault();
3594
3685
  }
3595
- #et(t) {
3596
- if (!(!this.#p() && this.#o?.handlePointerEvent(t))) {
3597
- if (this.#h?.handlePointerEvent(t) ?? !1) {
3686
+ #it(t) {
3687
+ if (!(!this.#m() && this.#a?.handlePointerEvent(t))) {
3688
+ if (this.#o?.handlePointerEvent(t) ?? !1) {
3598
3689
  this.#c();
3599
3690
  return;
3600
3691
  }
3601
- this.#p() || (this.#x = !0, this.#R = t.clientX, this.#D = t.clientY);
3692
+ this.#m() || (this.#S = !0, this.#D = t.clientX, this.#A = t.clientY);
3602
3693
  }
3603
3694
  }
3604
- #it(t) {
3605
- const e = this.#h?.handlePointerEvent(t) ?? !1;
3606
- this.#p() || this.#o?.handlePointerEvent(t);
3607
- let i = this.#A(t);
3695
+ #st(t) {
3696
+ const e = this.#o?.handlePointerEvent(t) ?? !1;
3697
+ this.#m() || this.#a?.handlePointerEvent(t);
3698
+ let i = this.#B(t);
3608
3699
  if (e) {
3609
- this.#c(), i = this.#A(t), this.#H(i);
3700
+ this.#c(), i = this.#B(t), this.#M(i);
3610
3701
  return;
3611
3702
  }
3612
- if (!this.#x || !this.#i || this.#p()) {
3613
- this.#H(i);
3703
+ if (!this.#S || !this.#s || this.#m()) {
3704
+ this.#M(i);
3614
3705
  return;
3615
3706
  }
3616
- const s = t.clientX - this.#R, r = t.clientY - this.#D;
3617
- this.#R = t.clientX, this.#D = t.clientY, this.#i.panHorizontally(s), this.#i.panVertically(r), this.#c(), i = this.#A(t), this.#H(i), this.#m();
3707
+ const s = t.clientX - this.#D, r = t.clientY - this.#A;
3708
+ this.#D = t.clientX, this.#A = t.clientY, this.#s.panHorizontally(s), this.#s.panVertically(r), this.#c(), i = this.#B(t), this.#M(i), this.#C();
3618
3709
  }
3619
- #st(t) {
3620
- if (this.#x = !1, this.#h?.handlePointerEvent(t) ?? !1) {
3621
- this.#c(), this.#m();
3710
+ #rt(t) {
3711
+ if (this.#S = !1, this.#o?.handlePointerEvent(t) ?? !1) {
3712
+ this.#c(), this.#C();
3622
3713
  return;
3623
3714
  }
3624
- this.#p() || this.#o?.handlePointerEvent(t), this.#m();
3715
+ this.#m() || this.#a?.handlePointerEvent(t), this.#C();
3625
3716
  }
3626
- #rt(t) {
3627
- document.body.style.cursor = "crosshair", this.#h?.handlePointerEvent(t), this.#p() || this.#o?.handlePointerEvent(t);
3717
+ #nt(t) {
3718
+ document.body.style.cursor = "crosshair", this.#o?.handlePointerEvent(t), this.#m() || this.#a?.handlePointerEvent(t);
3628
3719
  }
3629
- #nt() {
3630
- this.#h?.clearHoverState(), document.body.style.cursor = "", this.#F(), this.#H(null);
3631
- }
3632
- #at(t) {
3633
- ((this.#h?.handlePointerEvent(t) ?? !1) || this.#p()) && (t.preventDefault(), t.stopPropagation(), this.#c());
3720
+ #at() {
3721
+ this.#o?.clearHoverState(), document.body.style.cursor = "", this.#V(), this.#M(null);
3634
3722
  }
3635
3723
  #ot(t) {
3636
- this.#h?.handlePointerEvent(t);
3724
+ ((this.#o?.handlePointerEvent(t) ?? !1) || this.#m()) && (t.preventDefault(), t.stopPropagation(), this.#c());
3637
3725
  }
3638
3726
  #lt(t) {
3639
- this.#ht(t.target) || (this.#h?.handleKeyboardEvent(t) ?? !1) && (t.preventDefault(), this.#c());
3727
+ this.#o?.handlePointerEvent(t);
3640
3728
  }
3641
3729
  #ht(t) {
3730
+ this.#dt(t.target) || (this.#o?.handleKeyboardEvent(t) ?? !1) && (t.preventDefault(), this.#c());
3731
+ }
3732
+ #dt(t) {
3642
3733
  return t instanceof HTMLInputElement || t instanceof HTMLTextAreaElement || t instanceof HTMLSelectElement || t instanceof HTMLElement && t.isContentEditable;
3643
3734
  }
3644
- }, le = kt(({ className: t, style: e, ...i }, s) => {
3735
+ }, Ce = kt(({ className: t, style: e, ...i }, s) => {
3645
3736
  const r = _(null), n = _(null), a = _(i);
3646
3737
  return a.current = i, Rt(s, () => ({
3647
3738
  resetChartView() {
@@ -3662,7 +3753,7 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3662
3753
  })), st(() => {
3663
3754
  const o = r.current;
3664
3755
  if (!o) return;
3665
- const l = new ne(o, a.current);
3756
+ const l = new fe(o, a.current);
3666
3757
  return n.current = l, () => {
3667
3758
  l.destroy(), n.current = null;
3668
3759
  };
@@ -3680,5 +3771,5 @@ var $ = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
3680
3771
  });
3681
3772
  export {
3682
3773
  c as CHART_CONFIG,
3683
- le as TradingReload
3774
+ Ce as TradingReload
3684
3775
  };