@tradecanvas/chart 1.62.0 → 1.63.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/Chart.d.ts +6 -0
  2. package/dist/Chart.d.ts.map +1 -1
  3. package/dist/{LayoutSession-D1OOl-zS.js → LayoutSession-B65QLG6S.js} +139 -121
  4. package/dist/LayoutSession-B65QLG6S.js.map +1 -0
  5. package/dist/LayoutSession-K38h-AF0.cjs +2 -0
  6. package/dist/LayoutSession-K38h-AF0.cjs.map +1 -0
  7. package/dist/{i18n-CbKY8gH2.js → i18n-D5fU6Iwy.js} +9 -1
  8. package/dist/i18n-D5fU6Iwy.js.map +1 -0
  9. package/dist/i18n-DxRoJCYV.cjs +2 -0
  10. package/dist/i18n-DxRoJCYV.cjs.map +1 -0
  11. package/dist/index.cjs +1 -1
  12. package/dist/index.js +1 -1
  13. package/dist/widget/WidgetHotkeySheet.d.ts.map +1 -1
  14. package/dist/widget/index.cjs +2 -2
  15. package/dist/widget/index.cjs.map +1 -1
  16. package/dist/widget/index.js +23 -2
  17. package/dist/widget/index.js.map +1 -1
  18. package/dist/widget/locales/ar.d.ts.map +1 -1
  19. package/dist/widget/locales/cs.d.ts.map +1 -1
  20. package/dist/widget/locales/da.d.ts.map +1 -1
  21. package/dist/widget/locales/de.d.ts.map +1 -1
  22. package/dist/widget/locales/el.d.ts.map +1 -1
  23. package/dist/widget/locales/en.d.ts +4 -0
  24. package/dist/widget/locales/en.d.ts.map +1 -1
  25. package/dist/widget/locales/es.d.ts.map +1 -1
  26. package/dist/widget/locales/et.d.ts.map +1 -1
  27. package/dist/widget/locales/fa.d.ts.map +1 -1
  28. package/dist/widget/locales/fr.d.ts.map +1 -1
  29. package/dist/widget/locales/he.d.ts.map +1 -1
  30. package/dist/widget/locales/hu.d.ts.map +1 -1
  31. package/dist/widget/locales/id.d.ts.map +1 -1
  32. package/dist/widget/locales/index.cjs +1 -1
  33. package/dist/widget/locales/index.cjs.map +1 -1
  34. package/dist/widget/locales/index.js +113 -1
  35. package/dist/widget/locales/index.js.map +1 -1
  36. package/dist/widget/locales/it.d.ts.map +1 -1
  37. package/dist/widget/locales/ja.d.ts.map +1 -1
  38. package/dist/widget/locales/ko.d.ts.map +1 -1
  39. package/dist/widget/locales/ms.d.ts.map +1 -1
  40. package/dist/widget/locales/nb.d.ts.map +1 -1
  41. package/dist/widget/locales/nl.d.ts.map +1 -1
  42. package/dist/widget/locales/pl.d.ts.map +1 -1
  43. package/dist/widget/locales/pt.d.ts.map +1 -1
  44. package/dist/widget/locales/ro.d.ts.map +1 -1
  45. package/dist/widget/locales/ru.d.ts.map +1 -1
  46. package/dist/widget/locales/sk.d.ts.map +1 -1
  47. package/dist/widget/locales/sv.d.ts.map +1 -1
  48. package/dist/widget/locales/th.d.ts.map +1 -1
  49. package/dist/widget/locales/tr.d.ts.map +1 -1
  50. package/dist/widget/locales/vi.d.ts.map +1 -1
  51. package/dist/widget/locales/zh.d.ts.map +1 -1
  52. package/dist/widget/locales/zhHant.d.ts.map +1 -1
  53. package/package.json +3 -3
  54. package/dist/LayoutSession-D1OOl-zS.js.map +0 -1
  55. package/dist/LayoutSession-D4mWBj_P.cjs +0 -2
  56. package/dist/LayoutSession-D4mWBj_P.cjs.map +0 -1
  57. package/dist/i18n-BISr49ZU.cjs +0 -2
  58. package/dist/i18n-BISr49ZU.cjs.map +0 -1
  59. package/dist/i18n-CbKY8gH2.js.map +0 -1
@@ -1515,8 +1515,13 @@ var Vr = .08, Hr = a ** -7, Ur = 800, Wr = 24;
1515
1515
  function Gr(e) {
1516
1516
  return e.length > 0 ? { renames: e } : {};
1517
1517
  }
1518
- var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set(["verticalLine", "crossLine"]), Xr = class {
1519
- static version = "1.62.0";
1518
+ var Kr = 20, qr = 8, Jr = 10, Yr = {
1519
+ ArrowLeft: [-1, 0],
1520
+ ArrowRight: [1, 0],
1521
+ ArrowUp: [0, -1],
1522
+ ArrowDown: [0, 1]
1523
+ }, Xr = new Set(["horizontalLine", "crossLine"]), Zr = new Set(["verticalLine", "crossLine"]), Qr = class {
1524
+ static version = "1.63.0";
1520
1525
  engine;
1521
1526
  viewport;
1522
1527
  series = new Bn((e) => this.sessionKeep(e), (e) => this.followLiveChange(e));
@@ -1769,7 +1774,7 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
1769
1774
  color: t.sessionBreaks.color,
1770
1775
  lineStyle: t.sessionBreaks.lineStyle,
1771
1776
  lineWidth: t.sessionBreaks.lineWidth
1772
- }) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new me(), this.crosshairTooltip = new Oe(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new Qe(), this.pinnedTooltip.create(e), this.pinnedTooltip.setLocale(this.numberLocale), t.priceFormat && this.applyPriceFormat(t.priceFormat), t.chartTypeOptions && (this.chartTypeOptions = S(t.chartTypeOptions)), t.highLowLines && this.priceLines.setHighLow(!0), t.shapes && this.themeManager.setShape(ni(t.shapes)), t.font && this.themeManager.setFont(ti(t.font)), this.priceLines.setPriceText((e) => this.formatPrice(e)), t.extendedHours === !1 && (this.extendedHours = !1), t.timeFormatter && this.applyTimeFormatter(t.timeFormatter), this.keyboardHandler = new Ue({
1777
+ }) : t.features?.sessionBreaks !== !1 && this.sessionBreaks.setVisible(!0), t.logScale && this.features.logScale && this.viewport.setLogScale(!0), this.animator = new me(), this.crosshairTooltip = new Oe(), this.crosshairTooltip.create(e), this.crosshairTooltip.setLocale(this.numberLocale), this.pinnedTooltip = new Qe(), this.pinnedTooltip.create(e), this.pinnedTooltip.setLocale(this.numberLocale), t.priceFormat && this.applyPriceFormat(t.priceFormat), t.chartTypeOptions && (this.chartTypeOptions = S(t.chartTypeOptions)), t.highLowLines && this.priceLines.setHighLow(!0), t.shapes && this.themeManager.setShape(ii(t.shapes)), t.font && this.themeManager.setFont(ri(t.font)), this.priceLines.setPriceText((e) => this.formatPrice(e)), t.extendedHours === !1 && (this.extendedHours = !1), t.timeFormatter && this.applyTimeFormatter(t.timeFormatter), this.keyboardHandler = new Ue({
1773
1778
  scrollBars: (e) => {
1774
1779
  let t = this.viewport.getState().barWidth + this.viewport.getState().barSpacing;
1775
1780
  this.viewport.scrollBy(e * t), this.updateViewportAndRender();
@@ -1811,6 +1816,10 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
1811
1816
  e.preventDefault(), this.a11y.readBar(e.key === "." ? 1 : -1);
1812
1817
  return;
1813
1818
  }
1819
+ if (this.nudgeSelectedDrawings(e)) {
1820
+ e.preventDefault();
1821
+ return;
1822
+ }
1814
1823
  this.keyboardHandler.handleKey(e) && (e.preventDefault(), this.a11y?.viewMoved());
1815
1824
  }
1816
1825
  }, window.addEventListener("keydown", this.onWindowKeyDown), this.currentPriceLine = new ke(), this.currentPriceLine.setLocale(this.numberLocale), this.priceAxis.setReservedPriceProvider(() => this.currentPriceLine.isVisible() ? this.currentPriceLine.getPrice() : null), this.alertManager = new pe(), this.alertManager.setDrawingLevels((e) => this.drawingLevelsNow(e)), this.alertManager.setRequestRender(() => this.engine.requestRender(r.Overlay)), this.compareRenderer.setReservedLevels(() => this.alertManager.getAlerts().filter(Nt).map((e) => e.price)), this.alertManager.on("triggered", (e) => {
@@ -2187,7 +2196,7 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
2187
2196
  return this.priceLines.setQuoteShown(this.replaySession === null), this.priceLines;
2188
2197
  }
2189
2198
  setShapes(e) {
2190
- let t = ni(e);
2199
+ let t = ii(e);
2191
2200
  t.tagRadius !== void 0 && (this.themeManager.setShape({
2192
2201
  ...this.themeManager.getTheme().shape,
2193
2202
  ...t
@@ -2199,7 +2208,7 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
2199
2208
  setFont(e) {
2200
2209
  if (e === null) this.themeManager.setFont(null);
2201
2210
  else {
2202
- let t = ti(e);
2211
+ let t = ri(e);
2203
2212
  if (Object.keys(t).length === 0) return;
2204
2213
  this.themeManager.setFont(t);
2205
2214
  }
@@ -2683,6 +2692,15 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
2683
2692
  removeDrawings(e) {
2684
2693
  return this.drawingManager.removeDrawings(e);
2685
2694
  }
2695
+ nudgeSelectedDrawings(e) {
2696
+ let t = Yr[e.key];
2697
+ if (!t || !this.features.drawings || e.ctrlKey || e.metaKey || e.altKey) return !1;
2698
+ let n = e.shiftKey ? Jr : 1, r = {
2699
+ ...this.viewport.getState(),
2700
+ data: this.getDisplayData()
2701
+ };
2702
+ return this.drawingManager.nudge(t[0] * n, t[1] * n, r);
2703
+ }
2686
2704
  takeBackDrawing(e) {
2687
2705
  this.features.drawings && (this.drawingManager.takeBack(e), this.markStateChanged());
2688
2706
  }
@@ -3949,7 +3967,7 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
3949
3967
  let t = this.replaySession ? this.replayOffset : 0;
3950
3968
  if (!this.replaySession) {
3951
3969
  if (this.series.length() === 0) return;
3952
- this.series.beginReplay(), this.replaySession = ui(this.currentSymbol);
3970
+ this.series.beginReplay(), this.replaySession = fi(this.currentSymbol);
3953
3971
  }
3954
3972
  let n = this.replaySession, { steps: r, startTime: i, hideHistory: a, revealMarks: o, step: s, ...c } = e ?? {};
3955
3973
  c.animate = c.animate === !0;
@@ -3960,13 +3978,13 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
3960
3978
  let m = r ? this.replayStepsOver(n, p, !0) : null;
3961
3979
  this.options.autoScale = !0, this.buildReplay(p, m, f);
3962
3980
  let h = this.replayStepsSeries;
3963
- h && c.startIndex !== void 0 && (c.startIndex = yi(h, p, c.startIndex));
3981
+ h && c.startIndex !== void 0 && (c.startIndex = xi(h, p, c.startIndex));
3964
3982
  let g = h ?? p, _ = g[Math.max(0, Math.min(Math.floor(Number(c.startIndex ?? 0)) || 0, g.length - 1))];
3965
3983
  this.revealReplayMarks(this.replayRevealMarks ? _?.time ?? null : null), n.held && (n.held.state = c.paused ? "paused" : "playing", c.paused = !0), !c.paused && c.startIndex !== void 0 && c.startIndex >= 1 && this.replaySeek(c.startIndex - 1), this.replayManager.play(c);
3966
3984
  }
3967
3985
  buildReplay(e, t, n) {
3968
3986
  let r = this.replaySession?.animate === !0, i = r ? null : t;
3969
- this.replayPieces = r && t ? Si(t, e) : null, this.replayForming = null, this.replayOffset = n, this.replayStepsSeries = i, this.replayCoarse = e;
3987
+ this.replayPieces = r && t ? wi(t, e) : null, this.replayForming = null, this.replayOffset = n, this.replayStepsSeries = i, this.replayCoarse = e;
3970
3988
  let a = this.replayRestarting;
3971
3989
  this.replayRestarting = !0;
3972
3990
  try {
@@ -3980,7 +3998,7 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
3980
3998
  let n = t, a = e[t];
3981
3999
  if (i) {
3982
4000
  let r = i[t];
3983
- n = Q(e, r.time), c = c !== null && s === t - 1 && n === o - 1 && c ? wi(c, r) : bi(e[n], i, t), a = xi(i, e, t, n) ? e[n] : c;
4001
+ n = Q(e, r.time), c = c !== null && s === t - 1 && n === o - 1 && c ? Ei(c, r) : Si(e[n], i, t), a = Ci(i, e, t, n) ? e[n] : c;
3984
4002
  }
3985
4003
  let u = this.replayForming;
3986
4004
  this.replayForming = null, s = t;
@@ -4004,7 +4022,7 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
4004
4022
  });
4005
4023
  }), r && (this.replayPhaseUnsub = this.replayManager.on("phase", ({ index: t, fraction: n }) => {
4006
4024
  if (!e[t] || this.series.length() !== o || o !== t && o !== t + 1) return;
4007
- let r = this.replayForming?.index === t ? this.replayForming.path : this.replayPathOf(e, t), i = Ci() ? Mr(r, n) : n, a = o === t, s = a && this.autoScrollOnNewBar && this.viewport.isAtEnd(), c = jr(r, i);
4025
+ let r = this.replayForming?.index === t ? this.replayForming.path : this.replayPathOf(e, t), i = Ti() ? Mr(r, n) : n, a = o === t, s = a && this.autoScrollOnNewBar && this.viewport.isAtEnd(), c = jr(r, i);
4008
4026
  a ? this.series.appendReplayed(c) : this.series.updateReplayed(c), o = t + 1, this.replayForming = {
4009
4027
  index: t,
4010
4028
  path: r
@@ -4014,7 +4032,7 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
4014
4032
  drawFormingBar(e, t, n, r) {
4015
4033
  this.currentPriceLine.setPrice(e.close, t);
4016
4034
  let i = this.series.bars();
4017
- if (this.recalcIndicatorsFrom(i, i.length - 1), (n || !oi.has(this.options.chartType)) && (this.displayDataCache = null), !n) {
4035
+ if (this.recalcIndicatorsFrom(i, i.length - 1), (n || !ci.has(this.options.chartType)) && (this.displayDataCache = null), !n) {
4018
4036
  this.scheduleRender();
4019
4037
  return;
4020
4038
  }
@@ -4029,7 +4047,7 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
4029
4047
  if (!n) return;
4030
4048
  n.evictBefore(e[t].time);
4031
4049
  let r = this.replayManager.getStepMs();
4032
- n.ensure(e, t, Number.isFinite(r) && r > 0 ? Math.ceil(ai / r) : 1);
4050
+ n.ensure(e, t, Number.isFinite(r) && r > 0 ? Math.ceil(si / r) : 1);
4033
4051
  }
4034
4052
  useReplayLoader(e, t) {
4035
4053
  let n = this.streamAdapter, r = this.streamTimeframe, i = e.step && n && r !== null ? Fr(e.step, r, (e) => j(n, e)) : null, a = `${this.currentSymbol}|${r}|${i}`;
@@ -4060,8 +4078,8 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
4060
4078
  if (o.time > s) {
4061
4079
  let a = Y(e, s);
4062
4080
  e[a]?.time === s && i.fedFraction < 1 && c.push(...q(this.replayPathOf(e, a), i.fedFraction, 1));
4063
- let o = e.slice(X(e, s), t), l = Math.ceil(o.length / gi);
4064
- for (let e = 0; e < o.length; e += l) c.push(..._i(o.slice(e, e + l)));
4081
+ let o = e.slice(X(e, s), t), l = Math.ceil(o.length / vi);
4082
+ for (let e = 0; e < o.length; e += l) c.push(...yi(o.slice(e, e + l)));
4065
4083
  c.push(...q(n, -1, r));
4066
4084
  } else c.push(...q(n, i.fedFraction, r));
4067
4085
  i.fedTime = o.time, i.fedFraction = r;
@@ -4080,7 +4098,7 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
4080
4098
  if (n.length === 0) return;
4081
4099
  let r = t.windowTime === null ? 0 : Math.min(Y(n, t.windowTime), n.length - 1), i = r > 0 ? n.slice(r) : n;
4082
4100
  this.useReplayLoader(t, !1);
4083
- let a = this.replayStepsOver(t, i), o = t.animate ? null : a, s = t.until === null ? 0 : pi(o ?? i, t.until);
4101
+ let a = this.replayStepsOver(t, i), o = t.animate ? null : a, s = t.until === null ? 0 : hi(o ?? i, t.until);
4084
4102
  if (s < 0 && this.canPageBackForReplay(t)) {
4085
4103
  this.holdReplay(), t.held && t.held.pagesBack++, queueMicrotask(() => void this.pageBackForReplay(t));
4086
4104
  return;
@@ -4088,7 +4106,7 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
4088
4106
  let c = this.getReplayState(), l = t.held !== null && (e === "hours" || e === "bar"), u = t.held?.state ?? c;
4089
4107
  l || (t.held = null), t.symbol = this.currentSymbol;
4090
4108
  let d = this.replayManager.remainingMs();
4091
- this.clearBarHolders(), t.animate && fi(t, this.replayCoarse, i);
4109
+ this.clearBarHolders(), t.animate && mi(t, this.replayCoarse, i);
4092
4110
  let f = this.replayRestarting;
4093
4111
  this.replayRestarting = !0, this.replayCause = e === "older" ? "older" : "series";
4094
4112
  try {
@@ -4111,14 +4129,14 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
4111
4129
  }
4112
4130
  replayStepsOver(e, t, n = !1) {
4113
4131
  if (!e.steps || e.stepsSymbol !== this.currentSymbol) return null;
4114
- let r = vi(this.series.inHoursShown(e.steps), t);
4115
- return r && (n || hi(r, t)) ? r : null;
4132
+ let r = bi(this.series.inHoursShown(e.steps), t);
4133
+ return r && (n || _i(r, t)) ? r : null;
4116
4134
  }
4117
4135
  canPageBackForReplay(e) {
4118
- return this.history.hasLoader() && this.history.hasMore() && (e.held?.pagesBack ?? 0) < si;
4136
+ return this.history.hasLoader() && this.history.hasMore() && (e.held?.pagesBack ?? 0) < li;
4119
4137
  }
4120
4138
  async pageBackForReplay(e) {
4121
- this.replaySession !== e || !e.held || await this.history.loadMore() > 0 || this.replaySession !== e || !e.held || (e.held.pagesBack = si, this.rebaseReplay("older"));
4139
+ this.replaySession !== e || !e.held || await this.history.loadMore() > 0 || this.replaySession !== e || !e.held || (e.held.pagesBack = li, this.rebaseReplay("older"));
4122
4140
  }
4123
4141
  holdReplay() {
4124
4142
  let e = this.replaySession;
@@ -4151,7 +4169,7 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
4151
4169
  this.signalMarkerManager.setRevealUntil(e, t), this.tradeZoneManager.setRevealUntil(e, t);
4152
4170
  }
4153
4171
  replaySeekToTime(e) {
4154
- !this.replaySession || !this.replayCoarse || this.replaySeek(Math.max(0, pi(this.replayStepsSeries ?? this.replayCoarse, e)));
4172
+ !this.replaySession || !this.replayCoarse || this.replaySeek(Math.max(0, hi(this.replayStepsSeries ?? this.replayCoarse, e)));
4155
4173
  }
4156
4174
  feedReplayPrice(e, t) {
4157
4175
  let n = this.executionAdapter;
@@ -4173,8 +4191,8 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
4173
4191
  if (i.time <= n.fedTime) return;
4174
4192
  let a = e.slice(X(e, n.fedTime), t + 1);
4175
4193
  n.fedTime = i.time;
4176
- let o = Math.ceil(a.length / gi);
4177
- for (let e = 0; e < a.length; e += o) for (let [t, n] of _i(a.slice(e, e + o))) r.setMarkPrice(t, n);
4194
+ let o = Math.ceil(a.length / vi);
4195
+ for (let e = 0; e < a.length; e += o) for (let [t, n] of yi(a.slice(e, e + o))) r.setMarkPrice(t, n);
4178
4196
  this.tradingManager.setCurrentPrice(i.close);
4179
4197
  }
4180
4198
  getReplayBarIndex() {
@@ -4185,7 +4203,7 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
4185
4203
  }
4186
4204
  replaySeekToBar(e) {
4187
4205
  let t = this.replayStepsSeries;
4188
- this.replaySeek(t && this.replayCoarse ? yi(t, this.replayCoarse, e) : e);
4206
+ this.replaySeek(t && this.replayCoarse ? xi(t, this.replayCoarse, e) : e);
4189
4207
  }
4190
4208
  replayPause() {
4191
4209
  this.setHeldState("paused") || this.replayManager.pause();
@@ -4226,7 +4244,7 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
4226
4244
  let t = Ut(e.time, n), r = Rt(e.price, n);
4227
4245
  i = Math.min(i, t), a = Math.max(a, t), o = Math.min(o, r), s = Math.max(s, r);
4228
4246
  }
4229
- return Jr.has(t.type) ? [i, a] = [r.x, r.x + r.width] : t.type === "horizontalRay" && (a = r.x + r.width), Yr.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 ? {
4247
+ return Xr.has(t.type) ? [i, a] = [r.x, r.x + r.width] : t.type === "horizontalRay" && (a = r.x + r.width), Zr.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 ? {
4230
4248
  x: i,
4231
4249
  y: o,
4232
4250
  width: a - i,
@@ -4275,14 +4293,14 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
4275
4293
  });
4276
4294
  }
4277
4295
  restoreIndicators(e, t) {
4278
- let n = Zr(e), r = /* @__PURE__ */ new Map();
4296
+ let n = $r(e), r = /* @__PURE__ */ new Map();
4279
4297
  this.unrestoredIndicators = [];
4280
4298
  let i = new Set(this.indicatorEngine.getAvailableIndicators().map((e) => e.id)), a = [], o = /* @__PURE__ */ new Set();
4281
4299
  if (t) {
4282
4300
  let e = new Map(n.map((e) => [e.instanceId, e])), t = this.getIndicatorSetup();
4283
4301
  for (let n of t) {
4284
4302
  let t = e.get(n.instanceId);
4285
- t && Qr(n, t) && o.add(n.instanceId);
4303
+ t && ei(n, t) && o.add(n.instanceId);
4286
4304
  }
4287
4305
  for (let e of t) o.has(e.instanceId) || this.removeIndicator(e.instanceId);
4288
4306
  for (let e of [...o]) this.indicatorEngine.getIndicatorConfig(e) || o.delete(e);
@@ -4706,7 +4724,7 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
4706
4724
  }
4707
4725
  fitPriceScale(e, t) {
4708
4726
  if (e.length === 0) return;
4709
- let n = Math.max(0, t.visibleRange.from), r = Math.min(t.visibleRange.to, e.length - 1), i = ii(ii(m(e, n, r, 0), this.indicatorEngine.getOverlayPriceRange(n, r)), this.features.compareSymbols && this.comparesDrawn() ? this.compareRenderer.getPriceRange(e, t) : null), a = this.features.volume && this.volumeRenderer.isVisible() && ri(e, n, r) ? this.volumeRenderer.getHeightRatio() + Hr : O;
4727
+ let n = Math.max(0, t.visibleRange.from), r = Math.min(t.visibleRange.to, e.length - 1), i = oi(oi(m(e, n, r, 0), this.indicatorEngine.getOverlayPriceRange(n, r)), this.features.compareSymbols && this.comparesDrawn() ? this.compareRenderer.getPriceRange(e, t) : null), a = this.features.volume && this.volumeRenderer.isVisible() && ai(e, n, r) ? this.volumeRenderer.getHeightRatio() + Hr : O;
4710
4728
  this.viewport.setScaleMargins(this.viewport.isInvertScale() ? {
4711
4729
  top: a,
4712
4730
  bottom: O
@@ -4763,9 +4781,9 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
4763
4781
  }
4764
4782
  measureText(e, t) {
4765
4783
  let n = this.engine.layerManager.getLayer(r.Main)?.ctx;
4766
- if (n?.canvas.isConnected) return this.labelWidths.get(e, t, () => $r(n, e, t));
4784
+ if (n?.canvas.isConnected) return this.labelWidths.get(e, t, () => ti(n, e, t));
4767
4785
  let i = n ?? this.detachedMeasureContext();
4768
- return i ? $r(i, e, t) : e.length * 7;
4786
+ return i ? ti(i, e, t) : e.length * 7;
4769
4787
  }
4770
4788
  detachedMeasureContext() {
4771
4789
  return this.measureCtx === void 0 && (this.measureCtx = typeof document < "u" ? document.createElement("canvas").getContext("2d") : null), this.measureCtx;
@@ -4912,7 +4930,7 @@ var Kr = 20, qr = 8, Jr = new Set(["horizontalLine", "crossLine"]), Yr = new Set
4912
4930
  };
4913
4931
  }
4914
4932
  };
4915
- function Zr(e) {
4933
+ function $r(e) {
4916
4934
  let t = new Map(e.map((e) => [e.instanceId, e])), n = [], r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = (e) => {
4917
4935
  if (r.has(e.instanceId) || i.has(e.instanceId)) return;
4918
4936
  i.add(e.instanceId);
@@ -4926,19 +4944,19 @@ function Zr(e) {
4926
4944
  for (let t of e) a(t);
4927
4945
  return n;
4928
4946
  }
4929
- function Qr(e, t) {
4947
+ function ei(e, t) {
4930
4948
  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);
4931
4949
  }
4932
- function $r(e, t, n) {
4950
+ function ti(e, t, n) {
4933
4951
  let r = e.font;
4934
4952
  e.font = n;
4935
4953
  let i = e.measureText(t).width;
4936
4954
  return e.font = r, i;
4937
4955
  }
4938
- var ei = 300;
4939
- function ti(e) {
4956
+ var ni = 300;
4957
+ function ri(e) {
4940
4958
  let t = {}, n = e.family;
4941
- typeof n == "string" && n.trim() !== "" && n.length <= ei && !/[;{}<>\\]|\/\*/.test(n) && (t.family = n);
4959
+ typeof n == "string" && n.trim() !== "" && n.length <= ni && !/[;{}<>\\]|\/\*/.test(n) && (t.family = n);
4942
4960
  for (let n of [
4943
4961
  "sizeSmall",
4944
4962
  "sizeMedium",
@@ -4949,15 +4967,15 @@ function ti(e) {
4949
4967
  }
4950
4968
  return t;
4951
4969
  }
4952
- function ni(e) {
4970
+ function ii(e) {
4953
4971
  let t = e.tagRadius;
4954
4972
  return typeof t == "number" && Number.isFinite(t) && t >= 0 ? { tagRadius: Math.min(t, 999) } : {};
4955
4973
  }
4956
- function ri(e, t, n) {
4974
+ function ai(e, t, n) {
4957
4975
  for (let r = t; r <= n; r++) if (e[r].volume > 0) return !0;
4958
4976
  return !1;
4959
4977
  }
4960
- function ii(e, t) {
4978
+ function oi(e, t) {
4961
4979
  return e ? t ? {
4962
4980
  min: Math.min(e.min, t.min),
4963
4981
  max: Math.max(e.max, t.max)
@@ -4978,14 +4996,14 @@ function J(e) {
4978
4996
  bars: e.bars
4979
4997
  };
4980
4998
  }
4981
- var ai = 8e3, oi = new Set([
4999
+ var si = 8e3, ci = new Set([
4982
5000
  "candlestick",
4983
5001
  "line",
4984
5002
  "area",
4985
5003
  "bar",
4986
5004
  "hollowCandle"
4987
- ]), si = 10, ci = 50, li = .001;
4988
- function ui(e) {
5005
+ ]), li = 10, ui = 50, di = .001;
5006
+ function fi(e) {
4989
5007
  return {
4990
5008
  price: null,
4991
5009
  fedTime: null,
@@ -5000,41 +5018,41 @@ function ui(e) {
5000
5018
  held: null
5001
5019
  };
5002
5020
  }
5003
- function di(e, t) {
5021
+ function pi(e, t) {
5004
5022
  let n = e[t + 1];
5005
5023
  return n ? n.time - e[t].time : Z(e);
5006
5024
  }
5007
- function fi(e, t, n) {
5025
+ function mi(e, t, n) {
5008
5026
  let r = e.fedTime;
5009
5027
  if (r === null || !t || t.length === 0 || n.length === 0) return;
5010
- let i = di(t, Q(t, r)), a = r + (Number.isFinite(i) ? e.fedFraction * i : 0), o = Q(n, a), s = n[o].time;
5028
+ let i = pi(t, Q(t, r)), a = r + (Number.isFinite(i) ? e.fedFraction * i : 0), o = Q(n, a), s = n[o].time;
5011
5029
  if (s > a) return;
5012
- let c = di(n, o);
5030
+ let c = pi(n, o);
5013
5031
  if (a === s && o > 0) {
5014
5032
  e.fedTime = n[o - 1].time, e.fedFraction = 1;
5015
5033
  return;
5016
5034
  }
5017
5035
  e.fedTime = s, e.fedFraction = Number.isFinite(c) && c > 0 ? Math.min(1, (a - s) / c) : 0;
5018
5036
  }
5019
- function pi(e, t) {
5037
+ function hi(e, t) {
5020
5038
  let n = X(e, t), r = e.length - 1;
5021
5039
  return n > r && r >= 0 && e[r].time + Z(e) <= t ? r : Math.max(-1, n - 2);
5022
5040
  }
5023
- function mi(e) {
5041
+ function gi(e) {
5024
5042
  let t = Infinity;
5025
5043
  for (let n = Math.max(1, e.length - 10); n < e.length; n++) t = Math.min(t, e[n].time - e[n - 1].time);
5026
5044
  return t;
5027
5045
  }
5028
- function hi(e, t) {
5029
- if (!(mi(e) < mi(t))) return !1;
5030
- let n = Math.max(0, e.length - ci);
5046
+ function _i(e, t) {
5047
+ if (!(gi(e) < gi(t))) return !1;
5048
+ let n = Math.max(0, e.length - ui);
5031
5049
  for (let r = n; r < e.length; r++) {
5032
- let n = t[Q(t, e[r].time)], i = (n.high - n.low) * li + 2 ** -52;
5050
+ let n = t[Q(t, e[r].time)], i = (n.high - n.low) * di + 2 ** -52;
5033
5051
  if (e[r].close > n.high + i || e[r].close < n.low - i) return !1;
5034
5052
  }
5035
5053
  return !0;
5036
5054
  }
5037
- var gi = 500;
5055
+ var vi = 500;
5038
5056
  function Y(e, t) {
5039
5057
  let n = 0, r = e.length;
5040
5058
  for (; n < r;) {
@@ -5051,7 +5069,7 @@ function X(e, t) {
5051
5069
  }
5052
5070
  return n;
5053
5071
  }
5054
- function _i(e) {
5072
+ function yi(e) {
5055
5073
  let t = 0, n = 0;
5056
5074
  for (let r = 1; r < e.length; r++) e[r].low < e[t].low && (t = r), e[r].high > e[n].high && (n = r);
5057
5075
  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];
@@ -5062,7 +5080,7 @@ function Z(e) {
5062
5080
  for (let n = Math.max(1, e.length - 10); n < e.length; n++) t = Math.max(t, e[n].time - e[n - 1].time);
5063
5081
  return t > 0 ? t : Infinity;
5064
5082
  }
5065
- function vi(e, t) {
5083
+ function bi(e, t) {
5066
5084
  if (t.length === 0) return null;
5067
5085
  let n = t[t.length - 1].time + Z(t), r = e.filter((e) => zn(e) && e.time >= t[0].time && e.time < n).sort((e, t) => e.time - t.time), i = [];
5068
5086
  for (let e of r) (i.length === 0 || i[i.length - 1].time !== e.time) && i.push(e);
@@ -5080,26 +5098,26 @@ function Q(e, t) {
5080
5098
  }
5081
5099
  return n;
5082
5100
  }
5083
- function yi(e, t, n) {
5101
+ function xi(e, t, n) {
5084
5102
  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;
5085
5103
  for (let t = 0; t < e.length && e[t].time < i; t++) a = t;
5086
5104
  return Math.max(0, a);
5087
5105
  }
5088
- function bi(e, t, n) {
5106
+ function Si(e, t, n) {
5089
5107
  let r = n;
5090
5108
  for (; r > 0 && t[r - 1].time >= e.time;) r--;
5091
5109
  let i = {
5092
5110
  ...t[r],
5093
5111
  time: e.time
5094
5112
  };
5095
- for (let e = r + 1; e <= n; e++) i = wi(i, t[e]);
5113
+ for (let e = r + 1; e <= n; e++) i = Ei(i, t[e]);
5096
5114
  return i;
5097
5115
  }
5098
- function xi(e, t, n, r) {
5116
+ function Ci(e, t, n, r) {
5099
5117
  let i = e[n + 1], a = t[r + 1];
5100
5118
  return i !== void 0 && a !== void 0 && i.time >= a.time;
5101
5119
  }
5102
- function Si(e, t) {
5120
+ function wi(e, t) {
5103
5121
  let n = /* @__PURE__ */ new Map();
5104
5122
  for (let r of e) {
5105
5123
  let e = t[Q(t, r.time)].time, i = n.get(e);
@@ -5107,10 +5125,10 @@ function Si(e, t) {
5107
5125
  }
5108
5126
  return n;
5109
5127
  }
5110
- function Ci() {
5128
+ function Ti() {
5111
5129
  return typeof matchMedia == "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
5112
5130
  }
5113
- function wi(e, t) {
5131
+ function Ei(e, t) {
5114
5132
  return {
5115
5133
  time: e.time,
5116
5134
  open: e.open,
@@ -5122,26 +5140,26 @@ function wi(e, t) {
5122
5140
  }
5123
5141
  //#endregion
5124
5142
  //#region src/io/parseOHLCV.ts
5125
- var Ti = [
5143
+ var Di = [
5126
5144
  "time",
5127
5145
  "timestamp",
5128
5146
  "date",
5129
5147
  "datetime",
5130
5148
  "t"
5131
- ], Ei = ["open", "o"], Di = ["high", "h"], Oi = ["low", "l"], ki = ["close", "c"], Ai = [
5149
+ ], Oi = ["open", "o"], ki = ["high", "h"], Ai = ["low", "l"], ji = ["close", "c"], Mi = [
5132
5150
  "volume",
5133
5151
  "vol",
5134
5152
  "v"
5135
5153
  ];
5136
- function ji(e) {
5154
+ function Ni(e) {
5137
5155
  let t = e.trim();
5138
- return t ? t[0] === "[" || t[0] === "{" ? Mi(t) : Ni(t) : {
5156
+ return t ? t[0] === "[" || t[0] === "{" ? Pi(t) : Fi(t) : {
5139
5157
  data: [],
5140
5158
  rowCount: 0,
5141
5159
  skipped: 0
5142
5160
  };
5143
5161
  }
5144
- function Mi(e) {
5162
+ function Pi(e) {
5145
5163
  let t;
5146
5164
  try {
5147
5165
  t = JSON.parse(e);
@@ -5151,19 +5169,19 @@ function Mi(e) {
5151
5169
  if (!Array.isArray(t)) throw Error("Expected a JSON array of OHLCV rows");
5152
5170
  let n = [], r = 0;
5153
5171
  for (let e of t) {
5154
- let t = Array.isArray(e) ? Ri(e) : Li(e);
5172
+ let t = Array.isArray(e) ? Bi(e) : zi(e);
5155
5173
  t ? n.push(t) : r++;
5156
5174
  }
5157
- return Bi(n, t.length, r);
5175
+ return Hi(n, t.length, r);
5158
5176
  }
5159
- function Ni(e) {
5177
+ function Fi(e) {
5160
5178
  let t = e.split(/\r?\n/).filter((e) => e.trim().length > 0);
5161
5179
  if (t.length === 0) return {
5162
5180
  data: [],
5163
5181
  rowCount: 0,
5164
5182
  skipped: 0
5165
5183
  };
5166
- let n = Pi(t[0]), r = Fi(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? Ii(r) : {
5184
+ let n = Ii(t[0]), r = Li(t[0], n).map((e) => e.trim().toLowerCase()), i = r.some((e) => isNaN(Number(e)) && e.length > 0), a = i ? Ri(r) : {
5167
5185
  time: 0,
5168
5186
  open: 1,
5169
5187
  high: 2,
@@ -5174,7 +5192,7 @@ function Ni(e) {
5174
5192
  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");
5175
5193
  let o = [], s = 0;
5176
5194
  for (let e = +!!i; e < t.length; e++) {
5177
- let r = Fi(t[e], n), i = zi(r[a.time]), c = $(r[a.open]), l = $(r[a.high]), u = $(r[a.low]), d = $(r[a.close]), f = a.volume >= 0 ? Number(r[a.volume]) : 0;
5195
+ let r = Li(t[e], n), i = Vi(r[a.time]), c = $(r[a.open]), l = $(r[a.high]), u = $(r[a.low]), d = $(r[a.close]), f = a.volume >= 0 ? Number(r[a.volume]) : 0;
5178
5196
  if (i === null || ![
5179
5197
  c,
5180
5198
  l,
@@ -5193,9 +5211,9 @@ function Ni(e) {
5193
5211
  volume: Number.isFinite(f) ? f : 0
5194
5212
  });
5195
5213
  }
5196
- return Bi(o, t.length - +!!i, s);
5214
+ return Hi(o, t.length - +!!i, s);
5197
5215
  }
5198
- function Pi(e) {
5216
+ function Ii(e) {
5199
5217
  let t = {
5200
5218
  ",": 0,
5201
5219
  ";": 0,
@@ -5207,7 +5225,7 @@ function Pi(e) {
5207
5225
  for (let [e, i] of Object.entries(t)) i > r && (n = e, r = i);
5208
5226
  return n;
5209
5227
  }
5210
- function Fi(e, t) {
5228
+ function Li(e, t) {
5211
5229
  let n = [], r = "", i = !1;
5212
5230
  for (let a = 0; a < e.length; a++) {
5213
5231
  let o = e[a];
@@ -5215,25 +5233,25 @@ function Fi(e, t) {
5215
5233
  }
5216
5234
  return n.push(r), n;
5217
5235
  }
5218
- function Ii(e) {
5236
+ function Ri(e) {
5219
5237
  let t = (t) => e.findIndex((e) => t.includes(e));
5220
5238
  return {
5221
- time: t(Ti),
5222
- open: t(Ei),
5223
- high: t(Di),
5224
- low: t(Oi),
5225
- close: t(ki),
5226
- volume: t(Ai)
5239
+ time: t(Di),
5240
+ open: t(Oi),
5241
+ high: t(ki),
5242
+ low: t(Ai),
5243
+ close: t(ji),
5244
+ volume: t(Mi)
5227
5245
  };
5228
5246
  }
5229
- function Li(e) {
5247
+ function zi(e) {
5230
5248
  let t = (t) => {
5231
5249
  for (let n of t) {
5232
5250
  if (e[n] !== void 0) return e[n];
5233
5251
  let t = n.toUpperCase();
5234
5252
  if (e[t] !== void 0) return e[t];
5235
5253
  }
5236
- }, n = zi(String(t(Ti) ?? "")), r = Number(t(Ei)), i = Number(t(Di)), a = Number(t(Oi)), o = Number(t(ki)), s = Number(t(Ai) ?? 0);
5254
+ }, n = Vi(String(t(Di) ?? "")), r = Number(t(Oi)), i = Number(t(ki)), a = Number(t(Ai)), o = Number(t(ji)), s = Number(t(Mi) ?? 0);
5237
5255
  return n === null || ![
5238
5256
  r,
5239
5257
  i,
@@ -5248,9 +5266,9 @@ function Li(e) {
5248
5266
  volume: Number.isFinite(s) ? s : 0
5249
5267
  };
5250
5268
  }
5251
- function Ri(e) {
5269
+ function Bi(e) {
5252
5270
  if (e.length < 5) return null;
5253
- let t = zi(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;
5271
+ let t = Vi(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;
5254
5272
  return t === null || ![
5255
5273
  n,
5256
5274
  r,
@@ -5268,7 +5286,7 @@ function Ri(e) {
5268
5286
  function $(e) {
5269
5287
  return e === void 0 || e.trim() === "" ? NaN : Number(e);
5270
5288
  }
5271
- function zi(e) {
5289
+ function Vi(e) {
5272
5290
  let t = e.trim();
5273
5291
  if (!t) return null;
5274
5292
  let n = Number(t);
@@ -5276,7 +5294,7 @@ function zi(e) {
5276
5294
  let r = Date.parse(t);
5277
5295
  return Number.isFinite(r) ? r : null;
5278
5296
  }
5279
- function Bi(e, t, n) {
5297
+ function Hi(e, t, n) {
5280
5298
  e.sort((e, t) => e.time - t.time);
5281
5299
  let r = [];
5282
5300
  for (let t of e) r.length > 0 && r[r.length - 1].time === t.time ? r[r.length - 1] = t : r.push(t);
@@ -5288,7 +5306,7 @@ function Bi(e, t, n) {
5288
5306
  }
5289
5307
  //#endregion
5290
5308
  //#region src/io/DragDropImporter.ts
5291
- var Vi = class {
5309
+ var Ui = class {
5292
5310
  host;
5293
5311
  overlay = null;
5294
5312
  callbacks;
@@ -5309,19 +5327,19 @@ var Vi = class {
5309
5327
  this.host.removeEventListener("dragenter", this.bound.dragenter), this.host.removeEventListener("dragover", this.bound.dragover), this.host.removeEventListener("dragleave", this.bound.dragleave), this.host.removeEventListener("drop", this.bound.drop), this.hideOverlay();
5310
5328
  }
5311
5329
  onDragEnter(e) {
5312
- Hi(e) && (e.preventDefault(), this.depth++, this.showOverlay());
5330
+ Wi(e) && (e.preventDefault(), this.depth++, this.showOverlay());
5313
5331
  }
5314
5332
  onDragOver(e) {
5315
- Hi(e) && (e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = "copy"));
5333
+ Wi(e) && (e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = "copy"));
5316
5334
  }
5317
5335
  onDragLeave(e) {
5318
- Hi(e) && (this.depth = Math.max(0, this.depth - 1), this.depth === 0 && this.hideOverlay());
5336
+ Wi(e) && (this.depth = Math.max(0, this.depth - 1), this.depth === 0 && this.hideOverlay());
5319
5337
  }
5320
5338
  async onDrop(e) {
5321
5339
  e.preventDefault(), this.depth = 0, this.hideOverlay();
5322
5340
  let t = e.dataTransfer?.files?.[0];
5323
5341
  if (t) try {
5324
- let e = ji(await t.text());
5342
+ let e = Ni(await t.text());
5325
5343
  if (e.data.length === 0) throw Error(`No valid OHLCV rows found in "${t.name}"`);
5326
5344
  this.callbacks.onData(e.data, e, t);
5327
5345
  } catch (e) {
@@ -5352,12 +5370,12 @@ var Vi = class {
5352
5370
  this.overlay?.remove(), this.overlay = null;
5353
5371
  }
5354
5372
  };
5355
- function Hi(e) {
5373
+ function Wi(e) {
5356
5374
  return e.dataTransfer?.types?.includes("Files") ?? !1;
5357
5375
  }
5358
5376
  //#endregion
5359
5377
  //#region src/state/layoutStorage.ts
5360
- function Ui(e) {
5378
+ function Gi(e) {
5361
5379
  let t = {
5362
5380
  id: e.id,
5363
5381
  name: e.name,
@@ -5365,11 +5383,11 @@ function Ui(e) {
5365
5383
  };
5366
5384
  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;
5367
5385
  }
5368
- var Wi = (e, t) => t.updatedAt - e.updatedAt;
5369
- function Gi(e) {
5386
+ var Ki = (e, t) => t.updatedAt - e.updatedAt;
5387
+ function qi(e) {
5370
5388
  if (typeof e != "object" || !e) return null;
5371
5389
  let t = e;
5372
- return typeof t.id != "string" || !t.id || typeof t.name != "string" || typeof t.updatedAt != "number" || !Number.isFinite(t.updatedAt) ? null : Ui({
5390
+ return typeof t.id != "string" || !t.id || typeof t.name != "string" || typeof t.updatedAt != "number" || !Number.isFinite(t.updatedAt) ? null : Gi({
5373
5391
  id: t.id,
5374
5392
  name: t.name,
5375
5393
  updatedAt: t.updatedAt,
@@ -5378,17 +5396,17 @@ function Gi(e) {
5378
5396
  kind: typeof t.kind == "string" ? t.kind : void 0
5379
5397
  });
5380
5398
  }
5381
- function Ki(e) {
5382
- let t = Gi(e), n = t ? e.content : void 0;
5399
+ function Ji(e) {
5400
+ let t = qi(e), n = t ? e.content : void 0;
5383
5401
  return t && typeof n == "string" ? {
5384
5402
  ...t,
5385
5403
  content: n
5386
5404
  } : null;
5387
5405
  }
5388
- function qi(e = []) {
5406
+ function Yi(e = []) {
5389
5407
  let t = new Map(e.map((e) => [e.id, { ...e }]));
5390
5408
  return {
5391
- list: () => [...t.values()].map(Ui).sort(Wi),
5409
+ list: () => [...t.values()].map(Gi).sort(Ki),
5392
5410
  load: (e) => {
5393
5411
  let n = t.get(e);
5394
5412
  return n ? { ...n } : null;
@@ -5401,7 +5419,7 @@ function qi(e = []) {
5401
5419
  }
5402
5420
  };
5403
5421
  }
5404
- function Ji(e = "tcw:layouts:") {
5422
+ function Xi(e = "tcw:layouts:") {
5405
5423
  let t = `${e}index`, n = (t) => `${e}item:${t}`, r = () => {
5406
5424
  let e;
5407
5425
  try {
@@ -5409,10 +5427,10 @@ function Ji(e = "tcw:layouts:") {
5409
5427
  } catch {
5410
5428
  return [];
5411
5429
  }
5412
- return Array.isArray(e) ? e.map(Gi).filter((e) => e !== null) : [];
5430
+ return Array.isArray(e) ? e.map(qi).filter((e) => e !== null) : [];
5413
5431
  }, i = (e) => localStorage.setItem(t, JSON.stringify(e));
5414
5432
  return {
5415
- list: () => r().sort(Wi),
5433
+ list: () => r().sort(Ki),
5416
5434
  load: (e) => {
5417
5435
  let t = r().find((t) => t.id === e), i = t ? localStorage.getItem(n(e)) : null;
5418
5436
  return t && i !== null ? {
@@ -5421,7 +5439,7 @@ function Ji(e = "tcw:layouts:") {
5421
5439
  } : null;
5422
5440
  },
5423
5441
  save: (e) => {
5424
- localStorage.setItem(n(e.id), e.content), i([...r().filter((t) => t.id !== e.id), Ui(e)]);
5442
+ localStorage.setItem(n(e.id), e.content), i([...r().filter((t) => t.id !== e.id), Gi(e)]);
5425
5443
  },
5426
5444
  remove: (e) => {
5427
5445
  i(r().filter((t) => t.id !== e)), localStorage.removeItem(n(e));
@@ -5430,14 +5448,14 @@ function Ji(e = "tcw:layouts:") {
5430
5448
  }
5431
5449
  //#endregion
5432
5450
  //#region src/state/LayoutSession.ts
5433
- var Yi = 80;
5434
- function Xi(e) {
5451
+ var Zi = 80;
5452
+ function Qi(e) {
5435
5453
  return e.replace(/\s+/g, " ").trim().slice(0, 80).trim() || null;
5436
5454
  }
5437
- function Zi() {
5455
+ function $i() {
5438
5456
  return globalThis.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
5439
5457
  }
5440
- function Qi(e) {
5458
+ function ea(e) {
5441
5459
  let { id: t, name: n, symbol: r, timeframe: i, updatedAt: a, kind: o } = e;
5442
5460
  return {
5443
5461
  id: t,
@@ -5448,7 +5466,7 @@ function Qi(e) {
5448
5466
  ...o === void 0 ? {} : { kind: o }
5449
5467
  };
5450
5468
  }
5451
- var $i = class {
5469
+ var ta = class {
5452
5470
  currentLayout = null;
5453
5471
  savedContent = null;
5454
5472
  dirty = !1;
@@ -5464,7 +5482,7 @@ var $i = class {
5464
5482
  now;
5465
5483
  newId;
5466
5484
  constructor(e, t, n = {}) {
5467
- 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 ?? Zi;
5485
+ 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 ?? $i;
5468
5486
  }
5469
5487
  current() {
5470
5488
  return this.currentLayout;
@@ -5480,7 +5498,7 @@ var $i = class {
5480
5498
  }
5481
5499
  async list() {
5482
5500
  let e = await this.storage.list();
5483
- return Array.isArray(e) ? e.map(Gi).filter((e) => e !== null && (e.kind ?? "chart") === this.kind).sort((e, t) => t.updatedAt - e.updatedAt) : [];
5501
+ return Array.isArray(e) ? e.map(qi).filter((e) => e !== null && (e.kind ?? "chart") === this.kind).sort((e, t) => t.updatedAt - e.updatedAt) : [];
5484
5502
  }
5485
5503
  save() {
5486
5504
  return this.queue(() => {
@@ -5489,12 +5507,12 @@ var $i = class {
5489
5507
  });
5490
5508
  }
5491
5509
  saveAs(e) {
5492
- let t = Xi(e);
5510
+ let t = Qi(e);
5493
5511
  return t ? this.queue(() => this.write(this.newId(), t)) : Promise.reject(/* @__PURE__ */ Error("A layout needs a name"));
5494
5512
  }
5495
5513
  open(e) {
5496
5514
  return this.queue(async () => {
5497
- let t = Ki(await this.storage.load(e));
5515
+ let t = Ji(await this.storage.load(e));
5498
5516
  if (!t || t.id !== e || (t.kind ?? "chart") !== this.kind || this.destroyed) return !1;
5499
5517
  this.cancelTimer(), this.applying++;
5500
5518
  try {
@@ -5504,13 +5522,13 @@ var $i = class {
5504
5522
  } finally {
5505
5523
  this.applying--;
5506
5524
  }
5507
- return this.cancelTimer(), this.currentLayout = Qi(t), this.savedContent = this.host.capture().content, this.dirty = !1, this.notify(), !0;
5525
+ return this.cancelTimer(), this.currentLayout = ea(t), this.savedContent = this.host.capture().content, this.dirty = !1, this.notify(), !0;
5508
5526
  });
5509
5527
  }
5510
5528
  rename(e, t) {
5511
- let n = Xi(t);
5529
+ let n = Qi(t);
5512
5530
  return n ? this.queue(async () => {
5513
- let t = Ki(await this.storage.load(e));
5531
+ let t = Ji(await this.storage.load(e));
5514
5532
  !t || t.id !== e || (await this.storage.save({
5515
5533
  ...t,
5516
5534
  name: n
@@ -5588,7 +5606,7 @@ var $i = class {
5588
5606
  content: n.content
5589
5607
  };
5590
5608
  await this.storage.save(r);
5591
- let i = Qi(r);
5609
+ let i = ea(r);
5592
5610
  return this.currentLayout = i, this.savedContent = n.content, this.dirty = !1, this.notify(), i;
5593
5611
  }
5594
5612
  forget() {
@@ -5609,6 +5627,6 @@ var $i = class {
5609
5627
  }
5610
5628
  };
5611
5629
  //#endregion
5612
- export { Wn as C, B as D, R as E, dn as O, qn as S, V as T, dr as _, qi as a, G as b, Xr as c, Pr as d, Fr as f, ur as g, fr as h, Ji as i, Rr as l, pr as m, Yi as n, Vi as o, mr as p, Xi as r, ji as s, $i as t, Lr as u, cr as v, Hn as w, Qn as x, lr as y };
5630
+ export { Wn as C, B as D, R as E, dn as O, qn as S, V as T, dr as _, Yi as a, G as b, Qr as c, Pr as d, Fr as f, ur as g, fr as h, Xi as i, Rr as l, pr as m, Zi as n, Ui as o, mr as p, Qi as r, Ni as s, ta as t, Lr as u, cr as v, Hn as w, Qn as x, lr as y };
5613
5631
 
5614
- //# sourceMappingURL=LayoutSession-D1OOl-zS.js.map
5632
+ //# sourceMappingURL=LayoutSession-B65QLG6S.js.map