@tradecanvas/chart 1.49.1 → 1.50.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.
@@ -619,15 +619,23 @@ var un = class {
619
619
  now() {
620
620
  return this.host.now ? this.host.now() : Date.now();
621
621
  }
622
- }, hn = class t {
622
+ };
623
+ //#endregion
624
+ //#region src/ThemeManager.ts
625
+ function hn(e, t) {
626
+ return e.family === t.family && e.sizeSmall === t.sizeSmall && e.sizeMedium === t.sizeMedium && e.sizeLarge === t.sizeLarge;
627
+ }
628
+ var gn = class t {
623
629
  base;
624
630
  shape = null;
631
+ font = null;
632
+ themeFont;
625
633
  chartType = "candlestick";
626
634
  host = {};
627
635
  user = /* @__PURE__ */ new Map();
628
636
  effective = null;
629
637
  constructor(e) {
630
- this.base = t.read(e);
638
+ this.base = t.read(e), this.themeFont = this.base.font;
631
639
  }
632
640
  static read(t) {
633
641
  if (!t || t === "dark") return { ...e };
@@ -642,14 +650,33 @@ var un = class {
642
650
  return this.base;
643
651
  }
644
652
  setTheme(e) {
645
- this.base = t.read(e), this.shape && (this.base = {
653
+ let n = t.read(e), r = this.font !== null && hn(n.font, this.base.font);
654
+ this.base = n, r || (this.themeFont = n.font), this.shape && (this.base = {
646
655
  ...this.base,
647
656
  shape: {
648
657
  ...this.base.shape,
649
658
  ...this.shape
650
659
  }
660
+ }), this.font && (this.base = {
661
+ ...this.base,
662
+ font: {
663
+ ...this.themeFont,
664
+ ...this.font
665
+ }
651
666
  }), this.effective = null;
652
667
  }
668
+ setFont(e) {
669
+ this.font = e ? {
670
+ ...this.font,
671
+ ...e
672
+ } : null, this.base = {
673
+ ...this.base,
674
+ font: this.font ? {
675
+ ...this.themeFont,
676
+ ...this.font
677
+ } : this.themeFont
678
+ }, this.effective = null;
679
+ }
653
680
  setShape(e) {
654
681
  this.shape = e ? { ...e } : null, this.base = {
655
682
  ...this.base,
@@ -705,7 +732,7 @@ var un = class {
705
732
  };
706
733
  //#endregion
707
734
  //#region src/style/styleOptions.ts
708
- function gn(e, t) {
735
+ function _n(e, t) {
709
736
  return t ? {
710
737
  ...t.visible === void 0 ? {} : { [`crosshair.${e}.visible`]: t.visible },
711
738
  ...t.color === void 0 ? {} : { [`crosshair.${e}.color`]: t.color },
@@ -713,22 +740,22 @@ function gn(e, t) {
713
740
  ...t.width === void 0 ? {} : { [`crosshair.${e}.width`]: t.width }
714
741
  } : {};
715
742
  }
716
- function _n(e) {
743
+ function vn(e) {
717
744
  let { grid: t, crosshair: n } = e, r = n?.vLine?.labelBackground ?? n?.hLine?.labelBackground;
718
745
  return {
719
746
  ...t?.hLineColor === void 0 ? {} : { "grid.horizontal.color": t.hLineColor },
720
747
  ...t?.hLineStyle === void 0 ? {} : { "grid.horizontal.style": t.hLineStyle },
721
748
  ...t?.vLineColor === void 0 ? {} : { "grid.vertical.color": t.vLineColor },
722
749
  ...t?.vLineStyle === void 0 ? {} : { "grid.vertical.style": t.vLineStyle },
723
- ...gn("horizontal", n?.hLine),
724
- ...gn("vertical", n?.vLine),
750
+ ..._n("horizontal", n?.hLine),
751
+ ..._n("vertical", n?.vLine),
725
752
  ...r === void 0 ? {} : { "crosshair.labelBackground": r },
726
753
  ...e.overrides
727
754
  };
728
755
  }
729
756
  //#endregion
730
757
  //#region src/layout/LayoutManager.ts
731
- var vn = 200, yn = 80, U = (e) => e.position === "top" || e.position === "bottom", bn = class {
758
+ var yn = 200, bn = 80, U = (e) => e.position === "top" || e.position === "bottom", xn = class {
732
759
  panels = [];
733
760
  containerWidth = 0;
734
761
  containerHeight = 0;
@@ -744,8 +771,8 @@ var vn = 200, yn = 80, U = (e) => e.position === "top" || e.position === "bottom
744
771
  this.panels.push({
745
772
  id: e,
746
773
  position: n,
747
- size: r ?? (a ? vn : t),
748
- minSize: a ? yn : i,
774
+ size: r ?? (a ? yn : t),
775
+ minSize: a ? bn : i,
749
776
  content: {
750
777
  type: "indicator",
751
778
  indicatorInstanceId: e
@@ -814,7 +841,7 @@ var vn = 200, yn = 80, U = (e) => e.position === "top" || e.position === "bottom
814
841
  let r = this.panels.find((t) => t.id === e);
815
842
  if (r) {
816
843
  let a = r.position === "left" || r.position === "right", o = n === "left" || n === "right";
817
- r.position = n, a !== o && (r.size = o ? vn : t, r.minSize = o ? yn : i), o && (r.collapsed = void 0, this.maximized === e && (this.maximized = null));
844
+ r.position = n, a !== o && (r.size = o ? yn : t, r.minSize = o ? bn : i), o && (r.collapsed = void 0, this.maximized === e && (this.maximized = null));
818
845
  }
819
846
  }
820
847
  setPanelSize(e, t) {
@@ -930,8 +957,8 @@ var vn = 200, yn = 80, U = (e) => e.position === "top" || e.position === "bottom
930
957
  getMainChartRect() {
931
958
  return this.resolve().mainChartRect;
932
959
  }
933
- }, xn = 14, Sn = 14, Cn = 22, wn = 4;
934
- function Tn(e) {
960
+ }, Sn = 14, Cn = 14, wn = 22, Tn = 4;
961
+ function En(e) {
935
962
  let { min: t, max: n, lastPrice: r, locale: i, fontFamily: a, fontSizeSmall: s, measure: l } = e, u = e.tagPrecision ?? c(t, n), d = u, f = r === null ? [t, n] : [
936
963
  t,
937
964
  n,
@@ -940,14 +967,14 @@ function Tn(e) {
940
967
  for (let t of f) {
941
968
  if (!Number.isFinite(t)) continue;
942
969
  let n = e.scaleLabel ? e.scaleLabel(t) : e.format ? e.format(t) : p(t, u, i), r = e.format ? n : p(t, d, i);
943
- m = Math.max(m, l(n, `500 ${s}px ${a}`) + xn, l(r, `bold 11px ${a}`) + Sn, l(r, `600 ${s}px ${a}`) + Cn);
970
+ m = Math.max(m, l(n, `500 ${s}px ${a}`) + Sn, l(r, `bold 11px ${a}`) + Cn, l(r, `600 ${s}px ${a}`) + wn);
944
971
  }
945
- return m <= o ? o : Math.ceil(m / wn) * wn;
972
+ return m <= o ? o : Math.ceil(m / Tn) * Tn;
946
973
  }
947
- function En(e, t) {
974
+ function Dn(e, t) {
948
975
  return t > e || t <= e - 12 ? t : e;
949
976
  }
950
- var Dn = class {
977
+ var On = class {
951
978
  netY = 0;
952
979
  travelX = 0;
953
980
  engaged = !1;
@@ -963,8 +990,8 @@ var Dn = class {
963
990
  }
964
991
  return this.engaged;
965
992
  }
966
- }, On = 1;
967
- function kn(e, t) {
993
+ }, kn = 1;
994
+ function An(e, t) {
968
995
  return e.filter((e) => e.enabled !== !1 && (e.descriptor.layer ?? "overlay") === t);
969
996
  }
970
997
  function W(e) {
@@ -978,24 +1005,24 @@ function W(e) {
978
1005
  //#endregion
979
1006
  //#region src/plugins/registry.ts
980
1007
  var G = /* @__PURE__ */ new Map();
981
- function An(e) {
1008
+ function jn(e) {
982
1009
  G.set(W(e), e);
983
1010
  }
984
- function jn(e) {
1011
+ function Mn(e) {
985
1012
  return G.delete(e);
986
1013
  }
987
- function Mn() {
1014
+ function Nn() {
988
1015
  return [...G.values()];
989
1016
  }
990
- function Nn() {
1017
+ function Pn() {
991
1018
  G.clear();
992
1019
  }
993
1020
  //#endregion
994
1021
  //#region src/plugins/PluginManager.ts
995
- var Pn = class {
1022
+ var Fn = class {
996
1023
  plugins = /* @__PURE__ */ new Map();
997
1024
  constructor(e, t = {}) {
998
- if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of Mn()) this.add(e);
1025
+ if (this.indicatorEngine = e, t.inheritGlobal !== !1) for (let e of Nn()) this.add(e);
999
1026
  for (let e of t.plugins ?? []) this.add(e);
1000
1027
  }
1001
1028
  register(e) {
@@ -1025,15 +1052,15 @@ var Pn = class {
1025
1052
  add(e) {
1026
1053
  this.plugins.set(W(e), e), e.kind === "indicator" && this.indicatorEngine.register(e.plugin);
1027
1054
  }
1028
- }, Fn = {
1055
+ }, In = {
1029
1056
  orderPlace: (e, t) => e.placeOrder(t),
1030
1057
  orderModify: (e, t) => e.modifyOrder(t),
1031
1058
  orderCancel: (e, t) => e.cancelOrder(t),
1032
1059
  positionModify: (e, t) => e.modifyPosition(t),
1033
1060
  positionClose: (e, t) => e.closePosition(t),
1034
- positionReverse: (e, t, n) => In(e, t, n)
1061
+ positionReverse: (e, t, n) => Ln(e, t, n)
1035
1062
  };
1036
- async function In(e, t, n) {
1063
+ async function Ln(e, t, n) {
1037
1064
  let { reversing: r } = n;
1038
1065
  if (!r.has(t.positionId)) {
1039
1066
  r.add(t.positionId);
@@ -1062,7 +1089,7 @@ async function In(e, t, n) {
1062
1089
  }
1063
1090
  }
1064
1091
  }
1065
- function Ln(e, t) {
1092
+ function Rn(e, t) {
1066
1093
  let n = [], r = null, i = {
1067
1094
  positions: () => r ?? t.getPositions?.() ?? [],
1068
1095
  reversing: /* @__PURE__ */ new Set()
@@ -1072,8 +1099,8 @@ function Ln(e, t) {
1072
1099
  e.data && t.onFill?.(e.data);
1073
1100
  };
1074
1101
  e.on("orders", a), e.on("positions", o), e.on("error", s), e.on("fill", c), n.push(() => e.off("orders", a), () => e.off("positions", o), () => e.off("error", s), () => e.off("fill", c));
1075
- for (let r of Object.keys(Fn)) {
1076
- let a = Fn[r], o = t.onIntent(r, (n) => {
1102
+ for (let r of Object.keys(In)) {
1103
+ let a = In[r], o = t.onIntent(r, (n) => {
1077
1104
  Promise.resolve(a(e, n, i)).catch((e) => t.onError({
1078
1105
  message: `Execution command failed: ${r}`,
1079
1106
  cause: e
@@ -1087,15 +1114,15 @@ function Ln(e, t) {
1087
1114
  }
1088
1115
  //#endregion
1089
1116
  //#region src/Chart.ts
1090
- var Rn = {
1117
+ var zn = {
1091
1118
  min: 0,
1092
1119
  max: 100
1093
- }, zn = "exchange", Bn = zn;
1094
- function Vn(e) {
1120
+ }, Bn = "exchange", Vn = Bn;
1121
+ function Hn(e) {
1095
1122
  if (typeof e == "string" && e !== "exchange" && !g(e)) throw RangeError(`Unknown time zone: ${e}`);
1096
1123
  if (typeof e == "number" && !Number.isFinite(e)) throw RangeError(`Invalid UTC offset: ${e}`);
1097
1124
  }
1098
- function Hn(e, t) {
1125
+ function Un(e, t) {
1099
1126
  let { timeZone: n, timezone: r } = e, i = n !== void 0 && r !== void 0 && n !== r && n === t ? r : w(e);
1100
1127
  return i === void 0 ? e : {
1101
1128
  ...e,
@@ -1103,8 +1130,8 @@ function Hn(e, t) {
1103
1130
  timezone: i
1104
1131
  };
1105
1132
  }
1106
- var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontalLine", "crossLine"]), Yn = new Set(["verticalLine", "crossLine"]), Xn = class {
1107
- static version = "1.49.1";
1133
+ var Wn = .08, Gn = a ** -7, Kn = 800, qn = 20, Jn = 8, Yn = new Set(["horizontalLine", "crossLine"]), Xn = new Set(["verticalLine", "crossLine"]), Zn = class {
1134
+ static version = "1.50.0";
1108
1135
  engine;
1109
1136
  viewport;
1110
1137
  series = new un((e) => this.sessionKeep(e));
@@ -1230,7 +1257,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
1230
1257
  snapshotKey = null;
1231
1258
  historyCheckQueued = !1;
1232
1259
  constructor(e, t) {
1233
- t.timeZone != null && Vn(t.timeZone), this.container = e, this.options = {
1260
+ t.timeZone != null && Hn(t.timeZone), this.container = e, this.options = {
1234
1261
  ...t,
1235
1262
  chartType: t.chartType ?? "candlestick"
1236
1263
  }, this.numberLocale = t.numberLocale ?? "en-US", this.defaultAutoScale = t.autoScale !== !1;
@@ -1272,7 +1299,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
1272
1299
  oldestTime: () => this.series.bars()[0]?.time ?? null,
1273
1300
  prepend: (e) => this.prependBars(e),
1274
1301
  emit: (e) => this.eventBus.emit("historyLoad", e)
1275
- }), this.themeManager = new hn(t.theme), this.themeManager.setChartType(this.options.chartType ?? "candlestick"), this.applyStyle(_n(t), "host", !1), this.layoutManager = new bn(), this.indicatorEngine = new O(), this.pluginManager = new Pn(this.indicatorEngine, { plugins: t.plugins }), this.eventBus = new je(), Dt(this.indicatorEngine), this.indicatorEngine.register(new be(this.symbolSeries)), this.indicatorEngine.register(new nt(this.symbolSeries)), this.indicatorEngine.register(new xe(this.symbolSeries)), this.indicatorEngine.register(new Se(this.symbolSeries)), this.drawingManager = new Oe(), Et(this.drawingManager), this.drawingRenderer = new ke(this.drawingManager), this.drawingManager.setRequestRender(() => {
1302
+ }), this.themeManager = new gn(t.theme), this.themeManager.setChartType(this.options.chartType ?? "candlestick"), this.applyStyle(vn(t), "host", !1), this.layoutManager = new xn(), this.indicatorEngine = new O(), this.pluginManager = new Fn(this.indicatorEngine, { plugins: t.plugins }), this.eventBus = new je(), Dt(this.indicatorEngine), this.indicatorEngine.register(new be(this.symbolSeries)), this.indicatorEngine.register(new nt(this.symbolSeries)), this.indicatorEngine.register(new xe(this.symbolSeries)), this.indicatorEngine.register(new Se(this.symbolSeries)), this.drawingManager = new Oe(), Et(this.drawingManager), this.drawingRenderer = new ke(this.drawingManager), this.drawingManager.setRequestRender(() => {
1276
1303
  this.syncRenderContext(), this.engine.requestRender(r.Overlay), this.scheduleAutoSave();
1277
1304
  }), this.drawingManager.setEventCallback((e, t) => {
1278
1305
  this.followDrawingAlerts(e, t?.id), this.eventBus.emit(e, t), (e === "drawingCreate" || e === "drawingUpdate" || e === "drawingRemove") && this.announceStateChange();
@@ -1296,7 +1323,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
1296
1323
  this.eventBus.emit(e, t);
1297
1324
  }), this.engine = new Ye(e, t.maxPixelRatio);
1298
1325
  let a = this.engine.dprManager.getContainerSize();
1299
- if (this.viewport = new dt(a.width, a.height, t.minBarSpacing ?? 2, t.maxBarSpacing ?? 30, t.rightMargin ?? 5), this.viewport.setPanLimits({
1326
+ if (this.viewport = new dt(a.width, a.height, t.minBarSpacing ?? 2, t.maxBarSpacing ?? 30, t.rightMargin ?? 5), t.barLayout && this.viewport.setBarLayout(t.barLayout), this.viewport.setPanLimits({
1300
1327
  freePan: t.freePan ?? !0,
1301
1328
  minVisibleBars: t.panLimits?.minVisibleBars ?? 3
1302
1329
  }), t.minBarUnit !== void 0 && this.viewport.setMinBarUnit(t.minBarUnit), this.layoutManager.resize(a.width, a.height), this.engine.onContainerResize = (e) => {
@@ -1325,7 +1352,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
1325
1352
  color: t.sessionBreaks.color,
1326
1353
  lineStyle: t.sessionBreaks.lineStyle,
1327
1354
  lineWidth: t.sessionBreaks.lineWidth
1328
- }) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new de(), this.crosshairTooltip = new we(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new Ge(), this.pinnedTooltip.create(e), t.priceFormat && this.applyPriceFormat(t.priceFormat), t.chartTypeOptions && (this.chartTypeOptions = b(t.chartTypeOptions)), t.highLowLines && this.priceLines.setHighLow(!0), t.shapes && this.themeManager.setShape($n(t.shapes)), this.priceLines.setPriceText((e) => this.formatPrice(e)), t.extendedHours === !1 && (this.extendedHours = !1), t.timeFormatter && this.applyTimeFormatter(t.timeFormatter), this.keyboardHandler = new Le({
1355
+ }) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new de(), this.crosshairTooltip = new we(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new Ge(), this.pinnedTooltip.create(e), t.priceFormat && this.applyPriceFormat(t.priceFormat), t.chartTypeOptions && (this.chartTypeOptions = b(t.chartTypeOptions)), t.highLowLines && this.priceLines.setHighLow(!0), t.shapes && this.themeManager.setShape(nr(t.shapes)), t.font && this.themeManager.setFont(tr(t.font)), this.priceLines.setPriceText((e) => this.formatPrice(e)), t.extendedHours === !1 && (this.extendedHours = !1), t.timeFormatter && this.applyTimeFormatter(t.timeFormatter), this.keyboardHandler = new Le({
1329
1356
  scrollBars: (e) => {
1330
1357
  let t = this.viewport.getState().barWidth + this.viewport.getState().barSpacing;
1331
1358
  this.viewport.scrollBy(e * t), this.updateViewportAndRender();
@@ -1412,7 +1439,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
1412
1439
  }), this.replayManager.on("stateChange", (e) => {
1413
1440
  this.replayRestarting || this.eventBus.emit("replayState", { state: e });
1414
1441
  }), this.measureOverlay = new Ve(), this.interactionManager = new Fe(e), this.features.panning) {
1415
- let e = new Dn();
1442
+ let e = new On();
1416
1443
  this.interactionManager.setPanHandler(new He((t, n) => {
1417
1444
  t && this.viewport.scrollBy(t), e.step(t, n, this.options.autoScale !== !1) && n && (this.options.autoScale = !1, this.viewport.panPriceRange(n)), this.updateViewportAndRender();
1418
1445
  }, () => e.reset()));
@@ -1528,7 +1555,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
1528
1555
  end: () => {
1529
1556
  let e = this.selectionBoxOverlay.end();
1530
1557
  if (e && this.zoomAreaMode) {
1531
- if (e.x1 - e.x0 < qn) return;
1558
+ if (e.x1 - e.x0 < Jn) return;
1532
1559
  this.zoomToBox(e), this.setZoomAreaMode(!1);
1533
1560
  return;
1534
1561
  }
@@ -1601,7 +1628,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
1601
1628
  let { visibleRange: e, chartRect: t } = this.viewport.getState();
1602
1629
  if (t.width <= 0) return;
1603
1630
  let { from: n, to: r } = e;
1604
- this.history.maybeLoad(Math.max(0, Math.floor(n)), Math.max(Kn, r - n));
1631
+ this.history.maybeLoad(Math.max(0, Math.floor(n)), Math.max(qn, r - n));
1605
1632
  }));
1606
1633
  }
1607
1634
  useStreamHistory(e, t) {
@@ -1699,7 +1726,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
1699
1726
  return this.priceLines.setQuoteShown(this.replaySession === null), this.priceLines;
1700
1727
  }
1701
1728
  setShapes(e) {
1702
- let t = $n(e);
1729
+ let t = nr(e);
1703
1730
  t.tagRadius !== void 0 && (this.themeManager.setShape({
1704
1731
  ...this.themeManager.getTheme().shape,
1705
1732
  ...t
@@ -1708,6 +1735,24 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
1708
1735
  getShapes() {
1709
1736
  return { ...this.themeManager.getTheme().shape };
1710
1737
  }
1738
+ setFont(e) {
1739
+ if (e === null) this.themeManager.setFont(null);
1740
+ else {
1741
+ let t = tr(e);
1742
+ if (Object.keys(t).length === 0) return;
1743
+ this.themeManager.setFont(t);
1744
+ }
1745
+ this.updateViewportAndRender();
1746
+ }
1747
+ getFont() {
1748
+ return { ...this.themeManager.getTheme().font };
1749
+ }
1750
+ setBarLayout(e) {
1751
+ e !== "golden" && e !== "classic" || e === this.viewport.getBarLayout() || (this.viewport.setBarLayout(e), this.updateViewportAndRender());
1752
+ }
1753
+ getBarLayout() {
1754
+ return this.viewport.getBarLayout();
1755
+ }
1711
1756
  setMainSeriesVisible(e) {
1712
1757
  this.mainSeriesVisible = e, this.syncRenderContext(), this.engine.requestRender();
1713
1758
  }
@@ -1832,8 +1877,8 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
1832
1877
  return {
1833
1878
  ...e,
1834
1879
  priceRange: {
1835
- min: t.min - n * Un,
1836
- max: t.max + n * Un
1880
+ min: t.min - n * Wn,
1881
+ max: t.max + n * Wn
1837
1882
  },
1838
1883
  logScale: !1,
1839
1884
  scaleMode: "regular",
@@ -2210,7 +2255,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
2210
2255
  recordUndo(e) {
2211
2256
  if (!this.features.drawingUndoRedo || typeof e?.undo != "function" || typeof e.redo != "function") return;
2212
2257
  let t = performance.now(), n = this.undoRedoManager.last();
2213
- if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at < Gn) {
2258
+ if (e.subject !== void 0 && n?.type === "custom" && n.custom?.subject === e.subject && t - n.custom.at < Kn) {
2214
2259
  this.undoRedoManager.replaceLast({
2215
2260
  ...n,
2216
2261
  custom: {
@@ -2634,7 +2679,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
2634
2679
  }
2635
2680
  connectExecution(e, t = {}) {
2636
2681
  if (!this.features.trading) throw Error("connectExecution requires features.trading to be enabled");
2637
- this.disconnectExecution(), this.executionAdapter = e, this.execTeardown = Ln(e, {
2682
+ this.disconnectExecution(), this.executionAdapter = e, this.execTeardown = Rn(e, {
2638
2683
  onIntent: (e, t) => {
2639
2684
  let n = (e) => t(e.payload);
2640
2685
  return this.eventBus.on(e, n), () => this.eventBus.off(e, n);
@@ -2978,7 +3023,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
2978
3023
  this.periodLevels.setPeriod(e), this.engine.requestRender(r.Main);
2979
3024
  }
2980
3025
  setTimeZone(e) {
2981
- Vn(e), this.timeZoneSetting = e, this.applyTimeZone();
3026
+ Hn(e), this.timeZoneSetting = e, this.applyTimeZone();
2982
3027
  }
2983
3028
  getTimeZone() {
2984
3029
  return this.timeZoneSetting;
@@ -3010,7 +3055,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
3010
3055
  }
3011
3056
  setSymbolInfo(e) {
3012
3057
  let t = e && this.symbolInfo?.symbol === e.symbol ? w(this.symbolInfo) : void 0;
3013
- this.symbolInfo = e ? Hn({
3058
+ this.symbolInfo = e ? Un({
3014
3059
  ...e,
3015
3060
  sessions: e.sessions?.map((e) => ({ ...e }))
3016
3061
  }, t) : null, this.chartLegend.setExchange(this.symbolInfo?.exchange ?? ""), this.engine.requestRender(r.Hover), this.priceAxis.setPriceTick(this.symbolInfo?.minTick ?? null), this.marketConfig?.pricePrecision === void 0 && this.applyPricePrecision(this.symbolInfo?.pricePrecision ?? null);
@@ -3035,7 +3080,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
3035
3080
  if (!e || typeof e != "object") return;
3036
3081
  let t = this.currentSymbol, n = (e) => !e || e.toUpperCase() === t.toUpperCase();
3037
3082
  if (!n(e.symbol)) return;
3038
- let r = this.symbolInfo && n(this.symbolInfo.symbol) ? this.symbolInfo : null, i = Hn({
3083
+ let r = this.symbolInfo && n(this.symbolInfo.symbol) ? this.symbolInfo : null, i = Un({
3039
3084
  ...r,
3040
3085
  ...e,
3041
3086
  symbol: e.symbol || r?.symbol || t
@@ -3264,23 +3309,23 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
3264
3309
  };
3265
3310
  }
3266
3311
  let { steps: n, startTime: r, hideHistory: i, revealMarks: a, ...o } = e ?? {}, s = this.series.inHoursShown(this.series.liveBars()), c = t > 0 && r === void 0 && i !== !1, l = o.startIndex;
3267
- r !== void 0 && l === void 0 ? l = rr(s, r) : c && l !== void 0 && (l += t);
3312
+ r !== void 0 && l === void 0 ? l = or(s, r) : c && l !== void 0 && (l += t);
3268
3313
  let u = c ? t : i && l !== void 0 && l > 0 ? Math.min(Math.floor(l), s.length - 1) : 0, d = u > 0 ? s.slice(u) : s;
3269
3314
  l !== void 0 && (o.startIndex = l - u), this.replayOffset = u, this.replayRevealMarks = a !== !1;
3270
- let f = n ? sr(n, d) : null;
3315
+ let f = n ? ur(n, d) : null;
3271
3316
  this.replayStepsSeries = f, this.replayCoarse = d, this.options.autoScale = !0, this.replayRestarting = !0;
3272
3317
  try {
3273
3318
  this.replayManager.load(f ?? d);
3274
3319
  } finally {
3275
3320
  this.replayRestarting = !1;
3276
3321
  }
3277
- f && o.startIndex !== void 0 && (o.startIndex = q(f, d, o.startIndex)), this.replayBarUnsub?.();
3322
+ f && o.startIndex !== void 0 && (o.startIndex = fr(f, d, o.startIndex)), this.replayBarUnsub?.();
3278
3323
  let p = -1, m = -1, h = null, g = f ?? d;
3279
3324
  this.replayBarUnsub = this.replayManager.on("bar", ({ index: e }) => {
3280
3325
  let t = e, n = d[e];
3281
3326
  if (f) {
3282
3327
  let r = f[e];
3283
- t = cr(d, r.time), h = h !== null && m === e - 1 && t === p - 1 && h ? ur(h, r) : lr(d[t], f, e), n = h;
3328
+ t = dr(d, r.time), h = h !== null && m === e - 1 && t === p - 1 && h ? mr(h, r) : pr(d[t], f, e), n = h;
3284
3329
  }
3285
3330
  m = e;
3286
3331
  let r = t + 1, i = p > 0 && r >= p && this.series.length() === p, a = !(i && !this.replaySeeking) || this.autoScrollOnNewBar && this.viewport.isAtEnd();
@@ -3332,20 +3377,20 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
3332
3377
  return;
3333
3378
  }
3334
3379
  if (i.time <= n.fedTime) return;
3335
- let a = e.slice(ir(e, n.fedTime), t + 1);
3380
+ let a = e.slice(sr(e, n.fedTime), t + 1);
3336
3381
  n.fedTime = i.time;
3337
- let o = Math.ceil(a.length / nr);
3338
- for (let e = 0; e < a.length; e += o) for (let [t, n] of ar(a.slice(e, e + o))) r.setMarkPrice(t, n);
3382
+ let o = Math.ceil(a.length / ar);
3383
+ for (let e = 0; e < a.length; e += o) for (let [t, n] of cr(a.slice(e, e + o))) r.setMarkPrice(t, n);
3339
3384
  this.tradingManager.setCurrentPrice(i.close);
3340
3385
  }
3341
3386
  getReplayBarIndex() {
3342
3387
  if (!this.replaySession) return -1;
3343
3388
  let { current: e } = this.replayManager.getProgress(), t = this.replayStepsSeries;
3344
- return t && this.replayCoarse ? cr(this.replayCoarse, t[e]?.time ?? -Infinity) : e;
3389
+ return t && this.replayCoarse ? dr(this.replayCoarse, t[e]?.time ?? -Infinity) : e;
3345
3390
  }
3346
3391
  replaySeekToBar(e) {
3347
3392
  let t = this.replayStepsSeries;
3348
- this.replaySeek(t && this.replayCoarse ? q(t, this.replayCoarse, e) : e);
3393
+ this.replaySeek(t && this.replayCoarse ? fr(t, this.replayCoarse, e) : e);
3349
3394
  }
3350
3395
  replayPause() {
3351
3396
  this.replayManager.pause();
@@ -3380,7 +3425,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
3380
3425
  let t = kt(e.time, n), r = Ct(e.price, n);
3381
3426
  i = Math.min(i, t), a = Math.max(a, t), o = Math.min(o, r), s = Math.max(s, r);
3382
3427
  }
3383
- return Jn.has(t.type) ? [i, a] = [r.x, r.x + r.width] : t.type === "horizontalRay" && (a = r.x + r.width), Yn.has(t.type) && ([o, s] = [r.y, r.y + r.height]), i = Math.max(i, r.x), a = Math.min(a, r.x + r.width), o = Math.max(o, r.y), s = Math.min(s, r.y + r.height), i <= a && o <= s ? {
3428
+ return Yn.has(t.type) ? [i, a] = [r.x, r.x + r.width] : t.type === "horizontalRay" && (a = r.x + r.width), Xn.has(t.type) && ([o, s] = [r.y, r.y + r.height]), i = Math.max(i, r.x), a = Math.min(a, r.x + r.width), o = Math.max(o, r.y), s = Math.min(s, r.y + r.height), i <= a && o <= s ? {
3384
3429
  x: i,
3385
3430
  y: o,
3386
3431
  width: a - i,
@@ -3424,14 +3469,14 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
3424
3469
  });
3425
3470
  }
3426
3471
  restoreIndicators(e, t) {
3427
- let n = Zn(e), r = /* @__PURE__ */ new Map();
3472
+ let n = Qn(e), r = /* @__PURE__ */ new Map();
3428
3473
  this.unrestoredIndicators = [];
3429
3474
  let i = new Set(this.indicatorEngine.getAvailableIndicators().map((e) => e.id)), a = [], o = /* @__PURE__ */ new Set();
3430
3475
  if (t) {
3431
3476
  let e = new Map(n.map((e) => [e.instanceId, e])), t = this.getIndicatorSetup();
3432
3477
  for (let n of t) {
3433
3478
  let t = e.get(n.instanceId);
3434
- t && Qn(n, t) && o.add(n.instanceId);
3479
+ t && $n(n, t) && o.add(n.instanceId);
3435
3480
  }
3436
3481
  for (let e of t) o.has(e.instanceId) || this.removeIndicator(e.instanceId);
3437
3482
  for (let e of [...o]) this.indicatorEngine.getIndicatorConfig(e) || o.delete(e);
@@ -3598,7 +3643,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
3598
3643
  if (this.indicatorHistoryDepth > 0 || !this.features.drawingUndoRedo) return t();
3599
3644
  let n = this.getIndicatorSetup(), r = this.withoutIndicatorHistory(t), i = this.getIndicatorSetup();
3600
3645
  if (JSON.stringify(n) === JSON.stringify(i)) return r;
3601
- let a = performance.now(), o = this.undoRedoManager.last(), s = e !== void 0 && o?.type === "indicators" && o.indicators?.subject === e && a - (o.indicators.at ?? 0) < Gn && JSON.stringify(o.indicators.after) === JSON.stringify(n), c = {
3646
+ let a = performance.now(), o = this.undoRedoManager.last(), s = e !== void 0 && o?.type === "indicators" && o.indicators?.subject === e && a - (o.indicators.at ?? 0) < Kn && JSON.stringify(o.indicators.after) === JSON.stringify(n), c = {
3602
3647
  type: "indicators",
3603
3648
  before: null,
3604
3649
  after: null
@@ -3797,7 +3842,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
3797
3842
  }
3798
3843
  fitPriceScale(e, t) {
3799
3844
  if (e.length === 0) return;
3800
- let n = Math.max(0, t.visibleRange.from), r = Math.min(t.visibleRange.to, e.length - 1), i = tr(tr(f(e, n, r, 0), this.indicatorEngine.getOverlayPriceRange(n, r)), this.features.compareSymbols ? this.compareRenderer.getPriceRange(e, t) : null), a = this.features.volume && this.volumeRenderer.isVisible() && er(e, n, r) ? this.volumeRenderer.getHeightRatio() + Wn : k;
3845
+ let n = Math.max(0, t.visibleRange.from), r = Math.min(t.visibleRange.to, e.length - 1), i = ir(ir(f(e, n, r, 0), this.indicatorEngine.getOverlayPriceRange(n, r)), this.features.compareSymbols ? this.compareRenderer.getPriceRange(e, t) : null), a = this.features.volume && this.volumeRenderer.isVisible() && rr(e, n, r) ? this.volumeRenderer.getHeightRatio() + Gn : k;
3801
3846
  this.viewport.setScaleMargins(this.viewport.isInvertScale() ? {
3802
3847
  top: a,
3803
3848
  bottom: k
@@ -3819,7 +3864,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
3819
3864
  fitLeftAxisWidth() {
3820
3865
  let e = this.leftViewport;
3821
3866
  if (!e) return !1;
3822
- let t = this.themeManager.getTheme(), n = Tn({
3867
+ let t = this.themeManager.getTheme(), n = En({
3823
3868
  min: e.priceRange.min,
3824
3869
  max: e.priceRange.max,
3825
3870
  lastPrice: null,
@@ -3828,12 +3873,12 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
3828
3873
  fontFamily: t.font.family,
3829
3874
  fontSizeSmall: t.font.sizeSmall,
3830
3875
  measure: (e, t) => this.measureText(e, t)
3831
- }), r = En(this.leftAxisWidth, n);
3876
+ }), r = Dn(this.leftAxisWidth, n);
3832
3877
  return r === this.leftAxisWidth ? !1 : (this.leftAxisWidth = r, this.layoutManager.setLeftAxisWidth(r), this.resolvedLayoutCache = null, this.panelInfoCache = null, this.viewport.setChartRect(this.getResolvedLayout().mainChartRect), !0);
3833
3878
  }
3834
3879
  fitPriceAxisWidth() {
3835
3880
  if (!this.features.priceAxis) return !1;
3836
- let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n = Tn({
3881
+ let { priceRange: e } = this.viewport.getState(), t = this.themeManager.getTheme(), n = En({
3837
3882
  min: e.min,
3838
3883
  max: e.max,
3839
3884
  lastPrice: this.currentPriceLine.getPrice(),
@@ -3844,7 +3889,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
3844
3889
  fontFamily: t.font.family,
3845
3890
  fontSizeSmall: t.font.sizeSmall,
3846
3891
  measure: (e, t) => this.measureText(e, t)
3847
- }), r = En(this.priceAxisWidth, n);
3892
+ }), r = Dn(this.priceAxisWidth, n);
3848
3893
  return r === this.priceAxisWidth ? !1 : (this.priceAxisWidth = r, this.layoutManager.setPriceAxisWidth(r), this.viewport.setPriceAxisWidth(r), this.resolvedLayoutCache = null, this.panelInfoCache = null, this.viewport.setChartRect(this.getResolvedLayout().mainChartRect), !0);
3849
3894
  }
3850
3895
  measureText(e, t) {
@@ -3888,7 +3933,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
3888
3933
  buildPanelRenderInfos() {
3889
3934
  if (this.panelInfoCache) return this.panelInfoCache;
3890
3935
  let e = this.getResolvedLayout(), t = this.viewport.getState(), { from: n, to: r } = t.visibleRange, i = e.panels.map((e) => {
3891
- let i = e.config.logScale ? this.indicatorEngine.getPaneValueRange(e.config.id, n, r, !0) : null, a = i ?? this.indicatorEngine.getPaneValueRange(e.config.id, n, r) ?? { ...Rn }, o = {
3936
+ let i = e.config.logScale ? this.indicatorEngine.getPaneValueRange(e.config.id, n, r, !0) : null, a = i ?? this.indicatorEngine.getPaneValueRange(e.config.id, n, r) ?? { ...zn }, o = {
3892
3937
  x: e.rect.x,
3893
3938
  y: e.rect.y + 20,
3894
3939
  width: e.rect.width,
@@ -3970,7 +4015,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
3970
4015
  });
3971
4016
  }
3972
4017
  drawOverlayPlugins(e, t) {
3973
- let n = kn(this.pluginManager.getOverlays(), t);
4018
+ let n = An(this.pluginManager.getOverlays(), t);
3974
4019
  if (n.length === 0) return;
3975
4020
  let r = {
3976
4021
  viewport: this.viewport.getState(),
@@ -3991,7 +4036,7 @@ var Un = .08, Wn = a ** -7, Gn = 800, Kn = 20, qn = 8, Jn = new Set(["horizontal
3991
4036
  };
3992
4037
  }
3993
4038
  };
3994
- function Zn(e) {
4039
+ function Qn(e) {
3995
4040
  let t = new Map(e.map((e) => [e.instanceId, e])), n = [], r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = (e) => {
3996
4041
  if (r.has(e.instanceId) || i.has(e.instanceId)) return;
3997
4042
  i.add(e.instanceId);
@@ -4005,18 +4050,32 @@ function Zn(e) {
4005
4050
  for (let t of e) a(t);
4006
4051
  return n;
4007
4052
  }
4008
- function Qn(e, t) {
4053
+ function $n(e, t) {
4009
4054
  return e.id === t.id && (e.pane ?? null) === (t.pane ?? null) && (e.scale ?? null) === (t.scale ?? null) && e.position === void 0 == (t.position === void 0);
4010
4055
  }
4011
- function $n(e) {
4056
+ var er = 300;
4057
+ function tr(e) {
4058
+ let t = {}, n = e.family;
4059
+ typeof n == "string" && n.trim() !== "" && n.length <= er && !/[;{}<>\\]|\/\*/.test(n) && (t.family = n);
4060
+ for (let n of [
4061
+ "sizeSmall",
4062
+ "sizeMedium",
4063
+ "sizeLarge"
4064
+ ]) {
4065
+ let r = e[n];
4066
+ typeof r == "number" && Number.isFinite(r) && r > 0 && (t[n] = r);
4067
+ }
4068
+ return t;
4069
+ }
4070
+ function nr(e) {
4012
4071
  let t = e.tagRadius;
4013
4072
  return typeof t == "number" && Number.isFinite(t) && t >= 0 ? { tagRadius: Math.min(t, 999) } : {};
4014
4073
  }
4015
- function er(e, t, n) {
4074
+ function rr(e, t, n) {
4016
4075
  for (let r = t; r <= n; r++) if (e[r].volume > 0) return !0;
4017
4076
  return !1;
4018
4077
  }
4019
- function tr(e, t) {
4078
+ function ir(e, t) {
4020
4079
  return e ? t ? {
4021
4080
  min: Math.min(e.min, t.min),
4022
4081
  max: Math.max(e.max, t.max)
@@ -4037,8 +4096,8 @@ function K(e) {
4037
4096
  bars: e.bars
4038
4097
  };
4039
4098
  }
4040
- var nr = 500;
4041
- function rr(e, t) {
4099
+ var ar = 500;
4100
+ function or(e, t) {
4042
4101
  let n = 0, r = e.length;
4043
4102
  for (; n < r;) {
4044
4103
  let i = n + r >> 1;
@@ -4046,7 +4105,7 @@ function rr(e, t) {
4046
4105
  }
4047
4106
  return n;
4048
4107
  }
4049
- function ir(e, t) {
4108
+ function sr(e, t) {
4050
4109
  let n = 0, r = e.length;
4051
4110
  for (; n < r;) {
4052
4111
  let i = n + r >> 1;
@@ -4054,20 +4113,20 @@ function ir(e, t) {
4054
4113
  }
4055
4114
  return n;
4056
4115
  }
4057
- function ar(e) {
4116
+ function cr(e) {
4058
4117
  let t = 0, n = 0;
4059
4118
  for (let r = 1; r < e.length; r++) e[r].low < e[t].low && (t = r), e[r].high > e[n].high && (n = r);
4060
4119
  let r = [e[t].low, e[t].time], i = [e[n].high, e[n].time], a = t === n ? e[t].close >= e[t].open : t < n, o = e[e.length - 1];
4061
4120
  return [...a ? [r, i] : [i, r], [o.close, o.time]];
4062
4121
  }
4063
- function or(e) {
4122
+ function lr(e) {
4064
4123
  let t = 0;
4065
4124
  for (let n = Math.max(1, e.length - 10); n < e.length; n++) t = Math.max(t, e[n].time - e[n - 1].time);
4066
4125
  return t > 0 ? t : Infinity;
4067
4126
  }
4068
- function sr(e, t) {
4127
+ function ur(e, t) {
4069
4128
  if (t.length === 0) return null;
4070
- let n = t[t.length - 1].time + or(t), r = e.filter((e) => ln(e) && e.time >= t[0].time && e.time < n).sort((e, t) => e.time - t.time), i = [];
4129
+ let n = t[t.length - 1].time + lr(t), r = e.filter((e) => ln(e) && e.time >= t[0].time && e.time < n).sort((e, t) => e.time - t.time), i = [];
4071
4130
  for (let e of r) (i.length === 0 || i[i.length - 1].time !== e.time) && i.push(e);
4072
4131
  if (i.length === 0) return null;
4073
4132
  let a = t.findIndex((e) => e.time >= i[0].time);
@@ -4075,7 +4134,7 @@ function sr(e, t) {
4075
4134
  let o = t.slice(0, a), s = i.filter((e) => e.time >= t[a].time);
4076
4135
  return [...o, ...s];
4077
4136
  }
4078
- function cr(e, t) {
4137
+ function dr(e, t) {
4079
4138
  let n = 0, r = e.length - 1;
4080
4139
  for (; n < r;) {
4081
4140
  let i = n + r + 1 >> 1;
@@ -4083,22 +4142,22 @@ function cr(e, t) {
4083
4142
  }
4084
4143
  return n;
4085
4144
  }
4086
- function q(e, t, n) {
4145
+ function fr(e, t, n) {
4087
4146
  let r = Math.max(0, Math.min(Math.floor(Number.isFinite(n) ? n : 0), t.length - 1)), i = r + 1 < t.length ? t[r + 1].time : Infinity, a = -1;
4088
4147
  for (let t = 0; t < e.length && e[t].time < i; t++) a = t;
4089
4148
  return Math.max(0, a);
4090
4149
  }
4091
- function lr(e, t, n) {
4150
+ function pr(e, t, n) {
4092
4151
  let r = n;
4093
4152
  for (; r > 0 && t[r - 1].time >= e.time;) r--;
4094
4153
  let i = {
4095
4154
  ...t[r],
4096
4155
  time: e.time
4097
4156
  };
4098
- for (let e = r + 1; e <= n; e++) i = ur(i, t[e]);
4157
+ for (let e = r + 1; e <= n; e++) i = mr(i, t[e]);
4099
4158
  return i;
4100
4159
  }
4101
- function ur(e, t) {
4160
+ function mr(e, t) {
4102
4161
  return {
4103
4162
  time: e.time,
4104
4163
  open: e.open,
@@ -4110,26 +4169,26 @@ function ur(e, t) {
4110
4169
  }
4111
4170
  //#endregion
4112
4171
  //#region src/io/parseOHLCV.ts
4113
- var dr = [
4172
+ var hr = [
4114
4173
  "time",
4115
4174
  "timestamp",
4116
4175
  "date",
4117
4176
  "datetime",
4118
4177
  "t"
4119
- ], fr = ["open", "o"], pr = ["high", "h"], mr = ["low", "l"], hr = ["close", "c"], gr = [
4178
+ ], gr = ["open", "o"], _r = ["high", "h"], vr = ["low", "l"], yr = ["close", "c"], br = [
4120
4179
  "volume",
4121
4180
  "vol",
4122
4181
  "v"
4123
4182
  ];
4124
- function _r(e) {
4183
+ function q(e) {
4125
4184
  let t = e.trim();
4126
- return t ? t[0] === "[" || t[0] === "{" ? vr(t) : yr(t) : {
4185
+ return t ? t[0] === "[" || t[0] === "{" ? xr(t) : Sr(t) : {
4127
4186
  data: [],
4128
4187
  rowCount: 0,
4129
4188
  skipped: 0
4130
4189
  };
4131
4190
  }
4132
- function vr(e) {
4191
+ function xr(e) {
4133
4192
  let t;
4134
4193
  try {
4135
4194
  t = JSON.parse(e);
@@ -4139,19 +4198,19 @@ function vr(e) {
4139
4198
  if (!Array.isArray(t)) throw Error("Expected a JSON array of OHLCV rows");
4140
4199
  let n = [], r = 0;
4141
4200
  for (let e of t) {
4142
- let t = Array.isArray(e) ? wr(e) : Cr(e);
4201
+ let t = Array.isArray(e) ? Dr(e) : Er(e);
4143
4202
  t ? n.push(t) : r++;
4144
4203
  }
4145
- return Tr(n, t.length, r);
4204
+ return Or(n, t.length, r);
4146
4205
  }
4147
- function yr(e) {
4206
+ function Sr(e) {
4148
4207
  let t = e.split(/\r?\n/).filter((e) => e.trim().length > 0);
4149
4208
  if (t.length === 0) return {
4150
4209
  data: [],
4151
4210
  rowCount: 0,
4152
4211
  skipped: 0
4153
4212
  };
4154
- let n = br(t[0]), r = xr(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? Sr(r) : {
4213
+ let n = Cr(t[0]), r = wr(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? Tr(r) : {
4155
4214
  time: 0,
4156
4215
  open: 1,
4157
4216
  high: 2,
@@ -4162,7 +4221,7 @@ function yr(e) {
4162
4221
  if (a.time < 0 || a.open < 0 || a.high < 0 || a.low < 0 || a.close < 0) throw Error("CSV is missing required column(s): time, open, high, low, close");
4163
4222
  let o = [], s = 0;
4164
4223
  for (let e = +!!i; e < t.length; e++) {
4165
- let r = xr(t[e], n), i = Y(r[a.time]), c = J(r[a.open]), l = J(r[a.high]), u = J(r[a.low]), d = J(r[a.close]), f = a.volume >= 0 ? Number(r[a.volume]) : 0;
4224
+ let r = wr(t[e], n), i = Y(r[a.time]), c = J(r[a.open]), l = J(r[a.high]), u = J(r[a.low]), d = J(r[a.close]), f = a.volume >= 0 ? Number(r[a.volume]) : 0;
4166
4225
  if (i === null || ![
4167
4226
  c,
4168
4227
  l,
@@ -4181,9 +4240,9 @@ function yr(e) {
4181
4240
  volume: Number.isFinite(f) ? f : 0
4182
4241
  });
4183
4242
  }
4184
- return Tr(o, t.length - +!!i, s);
4243
+ return Or(o, t.length - +!!i, s);
4185
4244
  }
4186
- function br(e) {
4245
+ function Cr(e) {
4187
4246
  let t = {
4188
4247
  ",": 0,
4189
4248
  ";": 0,
@@ -4195,7 +4254,7 @@ function br(e) {
4195
4254
  for (let [e, i] of Object.entries(t)) i > r && (n = e, r = i);
4196
4255
  return n;
4197
4256
  }
4198
- function xr(e, t) {
4257
+ function wr(e, t) {
4199
4258
  let n = [], r = "", i = !1;
4200
4259
  for (let a = 0; a < e.length; a++) {
4201
4260
  let o = e[a];
@@ -4203,25 +4262,25 @@ function xr(e, t) {
4203
4262
  }
4204
4263
  return n.push(r), n;
4205
4264
  }
4206
- function Sr(e) {
4265
+ function Tr(e) {
4207
4266
  let t = (t) => e.findIndex((e) => t.includes(e));
4208
4267
  return {
4209
- time: t(dr),
4210
- open: t(fr),
4211
- high: t(pr),
4212
- low: t(mr),
4213
- close: t(hr),
4214
- volume: t(gr)
4268
+ time: t(hr),
4269
+ open: t(gr),
4270
+ high: t(_r),
4271
+ low: t(vr),
4272
+ close: t(yr),
4273
+ volume: t(br)
4215
4274
  };
4216
4275
  }
4217
- function Cr(e) {
4276
+ function Er(e) {
4218
4277
  let t = (t) => {
4219
4278
  for (let n of t) {
4220
4279
  if (e[n] !== void 0) return e[n];
4221
4280
  let t = n.toUpperCase();
4222
4281
  if (e[t] !== void 0) return e[t];
4223
4282
  }
4224
- }, n = Y(String(t(dr) ?? "")), r = Number(t(fr)), i = Number(t(pr)), a = Number(t(mr)), o = Number(t(hr)), s = Number(t(gr) ?? 0);
4283
+ }, n = Y(String(t(hr) ?? "")), r = Number(t(gr)), i = Number(t(_r)), a = Number(t(vr)), o = Number(t(yr)), s = Number(t(br) ?? 0);
4225
4284
  return n === null || ![
4226
4285
  r,
4227
4286
  i,
@@ -4236,7 +4295,7 @@ function Cr(e) {
4236
4295
  volume: Number.isFinite(s) ? s : 0
4237
4296
  };
4238
4297
  }
4239
- function wr(e) {
4298
+ function Dr(e) {
4240
4299
  if (e.length < 5) return null;
4241
4300
  let t = Y(String(e[0])), n = Number(e[1]), r = Number(e[2]), i = Number(e[3]), a = Number(e[4]), o = e.length >= 6 ? Number(e[5]) : 0;
4242
4301
  return t === null || ![
@@ -4264,7 +4323,7 @@ function Y(e) {
4264
4323
  let r = Date.parse(t);
4265
4324
  return Number.isFinite(r) ? r : null;
4266
4325
  }
4267
- function Tr(e, t, n) {
4326
+ function Or(e, t, n) {
4268
4327
  e.sort((e, t) => e.time - t.time);
4269
4328
  let r = [];
4270
4329
  for (let t of e) r.length > 0 && r[r.length - 1].time === t.time ? r[r.length - 1] = t : r.push(t);
@@ -4276,7 +4335,7 @@ function Tr(e, t, n) {
4276
4335
  }
4277
4336
  //#endregion
4278
4337
  //#region src/io/DragDropImporter.ts
4279
- var Er = class {
4338
+ var kr = class {
4280
4339
  host;
4281
4340
  overlay = null;
4282
4341
  callbacks;
@@ -4309,7 +4368,7 @@ var Er = class {
4309
4368
  e.preventDefault(), this.depth = 0, this.hideOverlay();
4310
4369
  let t = e.dataTransfer?.files?.[0];
4311
4370
  if (t) try {
4312
- let e = _r(await t.text());
4371
+ let e = q(await t.text());
4313
4372
  if (e.data.length === 0) throw Error(`No valid OHLCV rows found in "${t.name}"`);
4314
4373
  this.callbacks.onData(e.data, e, t);
4315
4374
  } catch (e) {
@@ -4353,7 +4412,7 @@ function Z(e) {
4353
4412
  };
4354
4413
  return e.symbol !== void 0 && (t.symbol = e.symbol), e.timeframe !== void 0 && (t.timeframe = e.timeframe), e.kind !== void 0 && (t.kind = e.kind), t;
4355
4414
  }
4356
- var Dr = (e, t) => t.updatedAt - e.updatedAt;
4415
+ var Ar = (e, t) => t.updatedAt - e.updatedAt;
4357
4416
  function Q(e) {
4358
4417
  if (typeof e != "object" || !e) return null;
4359
4418
  let t = e;
@@ -4366,17 +4425,17 @@ function Q(e) {
4366
4425
  kind: typeof t.kind == "string" ? t.kind : void 0
4367
4426
  });
4368
4427
  }
4369
- function Or(e) {
4428
+ function jr(e) {
4370
4429
  let t = Q(e), n = t ? e.content : void 0;
4371
4430
  return t && typeof n == "string" ? {
4372
4431
  ...t,
4373
4432
  content: n
4374
4433
  } : null;
4375
4434
  }
4376
- function kr(e = []) {
4435
+ function Mr(e = []) {
4377
4436
  let t = new Map(e.map((e) => [e.id, { ...e }]));
4378
4437
  return {
4379
- list: () => [...t.values()].map(Z).sort(Dr),
4438
+ list: () => [...t.values()].map(Z).sort(Ar),
4380
4439
  load: (e) => {
4381
4440
  let n = t.get(e);
4382
4441
  return n ? { ...n } : null;
@@ -4389,7 +4448,7 @@ function kr(e = []) {
4389
4448
  }
4390
4449
  };
4391
4450
  }
4392
- function Ar(e = "tcw:layouts:") {
4451
+ function Nr(e = "tcw:layouts:") {
4393
4452
  let t = `${e}index`, n = (t) => `${e}item:${t}`, r = () => {
4394
4453
  let e;
4395
4454
  try {
@@ -4400,7 +4459,7 @@ function Ar(e = "tcw:layouts:") {
4400
4459
  return Array.isArray(e) ? e.map(Q).filter((e) => e !== null) : [];
4401
4460
  }, i = (e) => localStorage.setItem(t, JSON.stringify(e));
4402
4461
  return {
4403
- list: () => r().sort(Dr),
4462
+ list: () => r().sort(Ar),
4404
4463
  load: (e) => {
4405
4464
  let t = r().find((t) => t.id === e), i = t ? localStorage.getItem(n(e)) : null;
4406
4465
  return t && i !== null ? {
@@ -4418,14 +4477,14 @@ function Ar(e = "tcw:layouts:") {
4418
4477
  }
4419
4478
  //#endregion
4420
4479
  //#region src/state/LayoutSession.ts
4421
- var jr = 80;
4480
+ var Pr = 80;
4422
4481
  function $(e) {
4423
4482
  return e.replace(/\s+/g, " ").trim().slice(0, 80).trim() || null;
4424
4483
  }
4425
- function Mr() {
4484
+ function Fr() {
4426
4485
  return globalThis.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
4427
4486
  }
4428
- function Nr(e) {
4487
+ function Ir(e) {
4429
4488
  let { id: t, name: n, symbol: r, timeframe: i, updatedAt: a, kind: o } = e;
4430
4489
  return {
4431
4490
  id: t,
@@ -4436,7 +4495,7 @@ function Nr(e) {
4436
4495
  ...o === void 0 ? {} : { kind: o }
4437
4496
  };
4438
4497
  }
4439
- var Pr = class {
4498
+ var Lr = class {
4440
4499
  currentLayout = null;
4441
4500
  savedContent = null;
4442
4501
  dirty = !1;
@@ -4452,7 +4511,7 @@ var Pr = class {
4452
4511
  now;
4453
4512
  newId;
4454
4513
  constructor(e, t, n = {}) {
4455
- this.storage = e, this.host = t, this.options = n, this.autoSave = n.autoSave ?? !0, this.debounceMs = n.debounceMs ?? 1500, this.kind = n.kind ?? "chart", this.now = n.now ?? Date.now, this.newId = n.newId ?? Mr;
4514
+ this.storage = e, this.host = t, this.options = n, this.autoSave = n.autoSave ?? !0, this.debounceMs = n.debounceMs ?? 1500, this.kind = n.kind ?? "chart", this.now = n.now ?? Date.now, this.newId = n.newId ?? Fr;
4456
4515
  }
4457
4516
  current() {
4458
4517
  return this.currentLayout;
@@ -4482,7 +4541,7 @@ var Pr = class {
4482
4541
  }
4483
4542
  open(e) {
4484
4543
  return this.queue(async () => {
4485
- let t = Or(await this.storage.load(e));
4544
+ let t = jr(await this.storage.load(e));
4486
4545
  if (!t || t.id !== e || (t.kind ?? "chart") !== this.kind || this.destroyed) return !1;
4487
4546
  this.cancelTimer(), this.applying++;
4488
4547
  try {
@@ -4492,13 +4551,13 @@ var Pr = class {
4492
4551
  } finally {
4493
4552
  this.applying--;
4494
4553
  }
4495
- return this.cancelTimer(), this.currentLayout = Nr(t), this.savedContent = this.host.capture().content, this.dirty = !1, this.notify(), !0;
4554
+ return this.cancelTimer(), this.currentLayout = Ir(t), this.savedContent = this.host.capture().content, this.dirty = !1, this.notify(), !0;
4496
4555
  });
4497
4556
  }
4498
4557
  rename(e, t) {
4499
4558
  let n = $(t);
4500
4559
  return n ? this.queue(async () => {
4501
- let t = Or(await this.storage.load(e));
4560
+ let t = jr(await this.storage.load(e));
4502
4561
  !t || t.id !== e || (await this.storage.save({
4503
4562
  ...t,
4504
4563
  name: n
@@ -4576,7 +4635,7 @@ var Pr = class {
4576
4635
  content: n.content
4577
4636
  };
4578
4637
  await this.storage.save(r);
4579
- let i = Nr(r);
4638
+ let i = Ir(r);
4580
4639
  return this.currentLayout = i, this.savedContent = n.content, this.dirty = !1, this.notify(), i;
4581
4640
  }
4582
4641
  forget() {
@@ -4597,6 +4656,6 @@ var Pr = class {
4597
4656
  }
4598
4657
  };
4599
4658
  //#endregion
4600
- export { V as C, dn as S, Xt as T, kn as _, kr as a, hn as b, Xn as c, Pn as d, Nn as f, On as g, jn as h, Ar as i, Bn as l, An as m, jr as n, Er as o, Mn as p, $ as r, _r as s, Pr as t, zn as u, W as v, z as w, pn as x, bn as y };
4659
+ export { V as C, dn as S, Xt as T, An as _, Mr as a, gn as b, Zn as c, Fn as d, Pn as f, kn as g, Mn as h, Nr as i, Vn as l, jn as m, Pr as n, kr as o, Nn as p, $ as r, q as s, Lr as t, Bn as u, W as v, z as w, pn as x, xn as y };
4601
4660
 
4602
- //# sourceMappingURL=LayoutSession-BlSkHp80.js.map
4661
+ //# sourceMappingURL=LayoutSession-Dcvn5KMK.js.map