@alphacharts/core 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { C as e, S as t, _ as n, a as r, b as i, c as a, d as o, f as s, g as c, h as l, l as u, m as d, n as f, o as p, p as m, s as h, t as g, u as _, v, x as y, y as ee } from "./window-uK2QNvv5.js";
1
+ import { C as e, S as t, T as n, _ as r, a as i, b as a, c as o, d as s, f as c, g as l, h as u, l as d, m as f, n as p, o as m, p as h, s as g, t as _, u as v, v as y, w as ee, x as te, y as ne } from "./window-WvcPCDkK.js";
2
2
  //#region src/data/tz.ts
3
- var b = 216e5, te = NaN, x = 864e5, S = class {
3
+ var re = 216e5, ie = NaN, b = 864e5, x = class {
4
4
  id;
5
5
  fmt;
6
6
  cache = /* @__PURE__ */ new Map();
@@ -18,10 +18,10 @@ var b = 216e5, te = NaN, x = 864e5, S = class {
18
18
  }
19
19
  offset(e) {
20
20
  if (this.fmt === null) return 0;
21
- let t = Math.floor(e / b), n = this.cache.get(t);
21
+ let t = Math.floor(e / re), n = this.cache.get(t);
22
22
  if (n === void 0) {
23
- let e = this.exactOffset(t * b);
24
- n = e === this.exactOffset((t + 1) * b - 1) ? e : te, this.cache.set(t, n);
23
+ let e = this.exactOffset(t * re);
24
+ n = e === this.exactOffset((t + 1) * re - 1) ? e : ie, this.cache.set(t, n);
25
25
  }
26
26
  return Number.isNaN(n) ? this.exactOffset(e) : n;
27
27
  }
@@ -30,7 +30,7 @@ var b = 216e5, te = NaN, x = 864e5, S = class {
30
30
  return e - this.offset(t);
31
31
  }
32
32
  civil(e) {
33
- return C(e + this.offset(e));
33
+ return S(e + this.offset(e));
34
34
  }
35
35
  exactOffset(e) {
36
36
  let t = this.fmt.formatToParts(e), n = 0, r = 0, i = 0, a = 0, o = 0, s = 0;
@@ -55,8 +55,8 @@ var b = 216e5, te = NaN, x = 864e5, S = class {
55
55
  return Date.UTC(n, r - 1, i, a, o, s) - (e - (e % 1e3 + 1e3) % 1e3);
56
56
  }
57
57
  };
58
- function C(e) {
59
- let t = Math.floor(e / x), n = e - t * x, r = Math.floor(n / 36e5);
58
+ function S(e) {
59
+ let t = Math.floor(e / b), n = e - t * b, r = Math.floor(n / 36e5);
60
60
  n -= r * 36e5;
61
61
  let i = Math.floor(n / 6e4);
62
62
  n -= i * 6e4;
@@ -71,46 +71,46 @@ function C(e) {
71
71
  ms: o
72
72
  };
73
73
  }
74
- function ne(e, t, n) {
74
+ function ae(e, t, n) {
75
75
  return Date.UTC(e, t - 1, n);
76
76
  }
77
- var re = 0, ie = {
77
+ var oe = 0, se = {
78
78
  antialias: !1,
79
79
  premultipliedAlpha: !0,
80
80
  alpha: !0,
81
81
  preserveDrawingBuffer: !1,
82
82
  powerPreference: "high-performance"
83
- }, ae = 8, oe = 1e4, w = /* @__PURE__ */ new Map();
84
- function se(e, t) {
83
+ }, ce = 8, le = 1e4, C = /* @__PURE__ */ new Map();
84
+ function ue(e, t) {
85
85
  t.isContextLost() || t.getExtension("WEBGL_lose_context")?.loseContext(), e.width = 0, e.height = 0;
86
86
  }
87
- function ce() {
88
- for (let [e, t] of w) {
87
+ function de() {
88
+ for (let [e, t] of C) {
89
89
  if (!t.gl.isContextLost()) return e;
90
- le(e);
90
+ fe(e);
91
91
  }
92
92
  }
93
- function le(e) {
94
- let t = w.get(e);
95
- t && (w.delete(e), clearTimeout(t.timer), e.removeEventListener("webglcontextlost", t.onLost), se(e, t.gl));
93
+ function fe(e) {
94
+ let t = C.get(e);
95
+ t && (C.delete(e), clearTimeout(t.timer), e.removeEventListener("webglcontextlost", t.onLost), ue(e, t.gl));
96
96
  }
97
- function ue(e, t, n, r = {}) {
98
- let i = w.get(t);
97
+ function pe(e, t, n, r = {}) {
98
+ let i = C.get(t);
99
99
  if (i) {
100
- if (w.delete(t), clearTimeout(i.timer), t.removeEventListener("webglcontextlost", i.onLost), !i.gl.isContextLost() && e !== "canvas2d") return new de(t, i.gl, n, i.glctx);
101
- se(t, i.gl), t = document.createElement("canvas");
100
+ if (C.delete(t), clearTimeout(i.timer), t.removeEventListener("webglcontextlost", i.onLost), !i.gl.isContextLost() && e !== "canvas2d") return new me(t, i.gl, n, i.glctx);
101
+ ue(t, i.gl), t = document.createElement("canvas");
102
102
  }
103
- if (e === "webgl" || e === "auto" && re < 8) {
103
+ if (e === "webgl" || e === "auto" && oe < 8) {
104
104
  let i = t.getContext("webgl2", r.preserveDrawingBuffer ? {
105
- ...ie,
105
+ ...se,
106
106
  preserveDrawingBuffer: !0
107
- } : ie);
108
- if (i) return new de(t, i, n);
107
+ } : se);
108
+ if (i) return new me(t, i, n);
109
109
  if (e === "webgl") throw Error("alphacharts: WebGL2 is not available (renderer: \"webgl\" was requested)");
110
110
  }
111
- return new fe(t);
111
+ return new he(t);
112
112
  }
113
- var de = class {
113
+ var me = class {
114
114
  canvas;
115
115
  gl;
116
116
  events;
@@ -119,7 +119,7 @@ var de = class {
119
119
  ctx2d = null;
120
120
  disposed = !1;
121
121
  constructor(e, t, n, r) {
122
- this.canvas = e, this.gl = t, this.events = n, re++, this.glctx = r ?? new p(t), e.addEventListener("webglcontextlost", this.onLost), e.addEventListener("webglcontextrestored", this.onRestored);
122
+ this.canvas = e, this.gl = t, this.events = n, oe++, this.glctx = r ?? new m(t), e.addEventListener("webglcontextlost", this.onLost), e.addEventListener("webglcontextrestored", this.onRestored);
123
123
  }
124
124
  ox = 0;
125
125
  oy = 0;
@@ -136,26 +136,34 @@ var de = class {
136
136
  }
137
137
  dispose() {
138
138
  if (this.disposed) return;
139
- this.disposed = !0, re--, this.canvas.removeEventListener("webglcontextlost", this.onLost), this.canvas.removeEventListener("webglcontextrestored", this.onRestored);
139
+ this.disposed = !0, oe--, this.canvas.removeEventListener("webglcontextlost", this.onLost), this.canvas.removeEventListener("webglcontextrestored", this.onRestored);
140
140
  let { canvas: e, gl: t } = this;
141
- if (this.glctx && !t.isContextLost() && w.size < ae) {
141
+ if (this.glctx && !t.isContextLost() && C.size < ce) {
142
142
  t.bindVertexArray(null), e.width = 1, e.height = 1;
143
- let n = setTimeout(() => le(e), oe), r = () => le(e);
144
- e.addEventListener("webglcontextlost", r), w.set(e, {
143
+ let n = setTimeout(() => fe(e), le), r = () => fe(e);
144
+ e.addEventListener("webglcontextlost", r), C.set(e, {
145
145
  gl: t,
146
146
  glctx: this.glctx,
147
147
  timer: n,
148
148
  onLost: r
149
149
  });
150
- } else se(e, t);
150
+ } else ue(e, t);
151
151
  }
152
152
  onLost = (e) => {
153
- e.preventDefault(), this.glctx?.lost(), this.glctx = null, this.events.lost();
153
+ e.preventDefault(), this.glctx?.lost(), this.glctx = null, n({
154
+ source: "context-lost",
155
+ error: void 0,
156
+ renderer: "webgl"
157
+ }), this.events.lost();
154
158
  };
155
159
  onRestored = () => {
156
- this.glctx = new p(this.gl), this.events.restored();
160
+ this.glctx = new m(this.gl), n({
161
+ source: "context-restored",
162
+ error: void 0,
163
+ renderer: "webgl"
164
+ }), this.events.restored();
157
165
  };
158
- }, fe = class {
166
+ }, he = class {
159
167
  kind = "canvas2d";
160
168
  gl = null;
161
169
  glctx = null;
@@ -180,19 +188,19 @@ var de = class {
180
188
  };
181
189
  //#endregion
182
190
  //#region src/chart/layers.ts
183
- function T(e, t = "") {
191
+ function w(e, t = "") {
184
192
  let n = document.createElement("canvas");
185
193
  return n.style.cssText = `position:absolute;left:0;top:0;width:100%;height:100%;display:block;${t}`, n.setAttribute("aria-hidden", "true"), e.appendChild(n), n;
186
194
  }
187
- function pe(e, t) {
195
+ function ge(e, t) {
188
196
  return e.style.cssText = "position:absolute;left:0;top:0;width:100%;height:100%;display:block;", t.appendChild(e), e;
189
197
  }
190
- function E(e) {
198
+ function T(e) {
191
199
  let t = e.getContext("2d");
192
200
  if (!t) throw Error("alphacharts: no 2D canvas context available");
193
201
  return t;
194
202
  }
195
- var me = class {
203
+ var _e = class {
196
204
  bg;
197
205
  overlay;
198
206
  surface;
@@ -200,12 +208,12 @@ var me = class {
200
208
  oy = 0;
201
209
  canvases;
202
210
  constructor(e, t, n) {
203
- let r = T(e), i = t === "canvas2d" ? void 0 : ce(), a = i ? pe(i, e) : T(e), o = T(e);
211
+ let r = w(e), i = t === "canvas2d" ? void 0 : de(), a = i ? ge(i, e) : w(e), o = w(e);
204
212
  this.canvases = [
205
213
  r,
206
214
  a,
207
215
  o
208
- ], this.bg = E(r), this.surface = ue(t, a, n), this.overlay = E(o);
216
+ ], this.bg = T(r), this.surface = pe(t, a, n), this.overlay = T(o);
209
217
  }
210
218
  fit(e, t, n) {
211
219
  for (let r of this.canvases) r.width = Math.max(1, Math.round(e * n)), r.height = Math.max(1, Math.round(t * n));
@@ -214,7 +222,7 @@ var me = class {
214
222
  this.surface.dispose();
215
223
  for (let e of this.canvases) e.remove(), (e !== this.canvases[1] || this.surface.kind !== "webgl") && (e.width = 0, e.height = 0);
216
224
  }
217
- }, he = class {
225
+ }, ve = class {
218
226
  dash;
219
227
  cell;
220
228
  ox = 0;
@@ -239,7 +247,7 @@ var me = class {
239
247
  (a !== this.ox || o !== this.oy) && (this.ox = a, this.oy = o, this.dash.layoutChanged());
240
248
  }
241
249
  dispose() {}
242
- }, ge = class {
250
+ }, ye = class {
243
251
  container;
244
252
  onLayout;
245
253
  members;
@@ -252,12 +260,12 @@ var me = class {
252
260
  flushing = !1;
253
261
  constructor(e, t, n, r, i) {
254
262
  this.container = e, this.onLayout = r, this.members = i;
255
- let a = T(e, "pointer-events:none"), o = T(e, "pointer-events:none"), s = T(e, "pointer-events:none");
263
+ let a = w(e, "pointer-events:none"), o = w(e, "pointer-events:none"), s = w(e, "pointer-events:none");
256
264
  this.canvases = [
257
265
  a,
258
266
  o,
259
267
  s
260
- ], this.bg = E(a), this.surface = ue(t, o, n), this.overlay = E(s);
268
+ ], this.bg = T(a), this.surface = pe(t, o, n), this.overlay = T(s);
261
269
  }
262
270
  noteGLDraw(e) {
263
271
  this.drawn.add(e), !(this.flushing || this.flushQueued) && (this.flushQueued = !0, queueMicrotask(() => {
@@ -284,18 +292,18 @@ var me = class {
284
292
  this.surface.dispose();
285
293
  for (let e of this.canvases) e.remove();
286
294
  }
287
- }, _e = 1;
288
- function ve(e, t) {
295
+ }, be = 1;
296
+ function xe(e, t) {
289
297
  for (let n of e.customOptions ?? []) if (typeof t[n] != "function") throw Error(`alphacharts: the layout was saved with a custom ${n}, which is a function and not in the JSON; pass it to restoreState({ ${n} })`);
290
298
  }
291
- var ye = {};
292
- function be(e) {
299
+ var Se = {};
300
+ function Ce(e) {
293
301
  if (typeof e != "object" || !e) throw TypeError("layout: expected an object");
294
302
  let t = e, n = t.version;
295
303
  if (typeof n != "number" || !Number.isInteger(n) || n < 1) throw TypeError(`layout: invalid version ${String(n)}`);
296
304
  if (n > 1) throw RangeError(`layout: version ${n} is newer than this library understands (1)`);
297
305
  for (; n < 1;) {
298
- let e = ye[n];
306
+ let e = Se[n];
299
307
  if (!e) throw Error(`layout: no migration from version ${n}`);
300
308
  t = e(t), n++;
301
309
  }
@@ -308,7 +316,7 @@ function be(e) {
308
316
  ]) if (!(e in t)) throw TypeError(`layout: missing "${e}"`);
309
317
  return t;
310
318
  }
311
- var xe = class {
319
+ var we = class {
312
320
  map = /* @__PURE__ */ new Map();
313
321
  async load(e) {
314
322
  let t = this.map.get(e);
@@ -323,7 +331,7 @@ var xe = class {
323
331
  async keys() {
324
332
  return [...this.map.keys()];
325
333
  }
326
- }, Se = class {
334
+ }, Te = class {
327
335
  prefix;
328
336
  constructor(e = "alphacharts:") {
329
337
  this.prefix = e;
@@ -347,7 +355,7 @@ var xe = class {
347
355
  return e;
348
356
  }
349
357
  };
350
- function Ce(e) {
358
+ function E(e) {
351
359
  return JSON.parse(JSON.stringify(e, (e, t) => typeof t == "function" ? void 0 : t));
352
360
  }
353
361
  //#endregion
@@ -355,7 +363,7 @@ function Ce(e) {
355
363
  function D(e) {
356
364
  if (e.minWidth !== void 0 && !(typeof e.minWidth == "number" && Number.isFinite(e.minWidth) && e.minWidth >= 0)) throw RangeError(`alphacharts: price scale minWidth must be a non-negative number of CSS px, got ${e.minWidth}`);
357
365
  }
358
- var we = {
366
+ var Ee = {
359
367
  marginTop: .1,
360
368
  marginBottom: .1,
361
369
  autoScale: !0,
@@ -363,7 +371,7 @@ var we = {
363
371
  invert: !1,
364
372
  position: "right",
365
373
  visible: !0
366
- }, Te = class {
374
+ }, De = class {
367
375
  id;
368
376
  options;
369
377
  min = 0;
@@ -463,23 +471,23 @@ var we = {
463
471
  };
464
472
  //#endregion
465
473
  //#region src/scale/ticks.ts
466
- function Ee(e, t, n, r, i) {
467
- let a = Math.max(1, n / r), o = Oe((t - e) / a, i), s = [];
474
+ function Oe(e, t, n, r, i) {
475
+ let a = Math.max(1, n / r), o = Ae((t - e) / a, i), s = [];
468
476
  if (!(o > 0) || !Number.isFinite(e) || !Number.isFinite(t)) return {
469
477
  step: o,
470
478
  ticks: s
471
479
  };
472
480
  let c = Math.ceil(e / o), l = Math.floor(t / o);
473
- for (let e = c; e <= l && s.length < 200; e++) s.push(ke(e * o, o));
481
+ for (let e = c; e <= l && s.length < 200; e++) s.push(je(e * o, o));
474
482
  return {
475
483
  step: o,
476
484
  ticks: s
477
485
  };
478
486
  }
479
- function De(e, t, n) {
480
- return Ee(e, t, Math.max(1, n), 1, 0);
487
+ function ke(e, t, n) {
488
+ return Oe(e, t, Math.max(1, n), 1, 0);
481
489
  }
482
- function Oe(e, t) {
490
+ function Ae(e, t) {
483
491
  if (!(e > 0) || !Number.isFinite(e)) return t > 0 ? t : 0;
484
492
  let n = (e) => !(t > 0) || e >= t * (1 - 1e-9) && Math.abs(e / t - Math.round(e / t)) < 1e-6;
485
493
  for (let t = Math.floor(Math.log10(e)); t < 400; t++) {
@@ -496,7 +504,7 @@ function Oe(e, t) {
496
504
  }
497
505
  return t;
498
506
  }
499
- function ke(e, t) {
507
+ function je(e, t) {
500
508
  let n = Math.max(0, -Math.floor(Math.log10(t)) + 2);
501
509
  return +e.toFixed(Math.min(n, 15));
502
510
  }
@@ -507,19 +515,19 @@ function O(e, t, n) {
507
515
  default: return t ? t.format(n) : String(n);
508
516
  }
509
517
  }
510
- function Ae(e, t, n) {
518
+ function Me(e, t, n) {
511
519
  let r = e.height;
512
520
  if (!(r > 0) || !(e.max > e.min)) return [];
513
521
  let i = (n) => ({
514
522
  price: n,
515
523
  label: O(e, t, n)
516
524
  });
517
- if (e.mode === "percent" || e.mode === "indexed") return Ee(e.min, e.max, r, n, .01).ticks.map((t) => i(e.fromDisplay(t)));
518
- if (e.mode === "log" && e.max - e.min > .3) return je(e, n).map(i);
525
+ if (e.mode === "percent" || e.mode === "indexed") return Oe(e.min, e.max, r, n, .01).ticks.map((t) => i(e.fromDisplay(t)));
526
+ if (e.mode === "log" && e.max - e.min > .3) return Ne(e, n).map(i);
519
527
  let a = e.price(0), o = e.price(r);
520
- return Ee(Math.min(a, o), Math.max(a, o), r, n, t?.minMove ?? 0).ticks.map(i);
528
+ return Oe(Math.min(a, o), Math.max(a, o), r, n, t?.minMove ?? 0).ticks.map(i);
521
529
  }
522
- function je(e, t) {
530
+ function Ne(e, t) {
523
531
  let n = e.pxPerUnit, r = n >= t * 9 ? [
524
532
  1,
525
533
  2,
@@ -557,12 +565,12 @@ var k = [
557
565
  [7, 5e3],
558
566
  [6, 1e3]
559
567
  ];
560
- function Me(e, t, n) {
561
- return t === t ? Ne(t + e.offset(t), n + e.offset(n)) : 20;
568
+ function Pe(e, t, n) {
569
+ return t === t ? Fe(t + e.offset(t), n + e.offset(n)) : 20;
562
570
  }
563
- function Ne(e, t, n = 0) {
571
+ function Fe(e, t, n = 0) {
564
572
  if (Math.floor(e / 864e5) !== Math.floor(t / 864e5)) {
565
- let n = C(e), r = C(t);
573
+ let n = S(e), r = S(t);
566
574
  return n.year === r.year ? n.month === r.month ? 18 : 19 : 20;
567
575
  }
568
576
  for (let [r, i] of k) {
@@ -571,25 +579,25 @@ function Ne(e, t, n = 0) {
571
579
  }
572
580
  return 0;
573
581
  }
574
- function Pe(e, t, n) {
582
+ function Ie(e, t, n) {
575
583
  let r = e * n / t / 2, i = 18;
576
584
  for (let [e, t] of k) t >= r && (i = e);
577
585
  return r > k[0][1] ? 18 : i;
578
586
  }
579
- function Fe(e, t, n, r, i, a, o) {
587
+ function Le(e, t, n, r, i, a, o) {
580
588
  if (r < n || e.length === 0) return [];
581
- let s = [], c = (t) => t > e.first ? e.timeAt(t - 1) : NaN, l = e.timeAt(n), u = e.timeAt(r), d = r > n ? (u - l) / (r - n) : 0, f = d > 0 ? Pe(d, a, o) : 0, p = d > 0 ? d * o / a / 2 : 1e3, m = /* @__PURE__ */ new Set(), h = (a) => {
589
+ let s = [], c = (t) => t > e.first ? e.timeAt(t - 1) : NaN, l = e.timeAt(n), u = e.timeAt(r), d = r > n ? (u - l) / (r - n) : 0, f = d > 0 ? Ie(d, a, o) : 0, p = d > 0 ? d * o / a / 2 : 1e3, m = /* @__PURE__ */ new Set(), h = (a) => {
582
590
  let o = e.lowerBound(a);
583
591
  if (o < n || o > r || m.has(o)) return;
584
592
  m.add(o);
585
- let l = Me(t, c(o), e.timeAt(o));
593
+ let l = Pe(t, c(o), e.timeAt(o));
586
594
  l > 0 && l >= f && s.push({
587
595
  index: o,
588
596
  weight: l,
589
597
  x: i(o)
590
598
  });
591
599
  };
592
- h(l), Ie(t, l, u, p, h), s.sort((e, t) => t.weight - e.weight || e.index - t.index);
600
+ h(l), Re(t, l, u, p, h), s.sort((e, t) => t.weight - e.weight || e.index - t.index);
593
601
  let g = [];
594
602
  for (let e of s) {
595
603
  let t = !0;
@@ -601,26 +609,26 @@ function Fe(e, t, n, r, i, a, o) {
601
609
  }
602
610
  return g.sort((e, t) => e.index - t.index), g;
603
611
  }
604
- function Ie(e, t, n, r, i) {
612
+ function Re(e, t, n, r, i) {
605
613
  let a = e.civil(t), o = e.civil(n);
606
- for (let t = a.year + 1; t <= o.year; t++) i(e.fromLocal(ne(t, 1, 1)));
614
+ for (let t = a.year + 1; t <= o.year; t++) i(e.fromLocal(ae(t, 1, 1)));
607
615
  if (r >= 2592e7) return;
608
616
  let s = r >= 7776e6 ? 3 : 1;
609
- for (let t = a.year, n = a.month; t < o.year || t === o.year && n <= o.month;) n += 1, n > 12 && (n = 1, t += 1), (n - 1) % s == 0 && i(e.fromLocal(ne(t, n, 1)));
617
+ for (let t = a.year, n = a.month; t < o.year || t === o.year && n <= o.month;) n += 1, n > 12 && (n = 1, t += 1), (n - 1) % s == 0 && i(e.fromLocal(ae(t, n, 1)));
610
618
  if (r >= 216e7) return;
611
- let c = x;
619
+ let c = b;
612
620
  for (let [, e] of k) e >= r && (c = e);
613
- r > 864e5 && (c = x * Math.min(7, Math.ceil(r / x)));
621
+ r > 864e5 && (c = b * Math.min(7, Math.ceil(r / b)));
614
622
  let l = t + e.offset(t), u = n + e.offset(n), d = 0;
615
623
  for (let t = Math.ceil(l / c) * c; t <= u && d < 2e3; t += c, d++) i(e.fromLocal(t));
616
624
  }
617
- function Le(e, t, n, r) {
625
+ function ze(e, t, n, r) {
618
626
  if (!e) return r();
619
627
  let i = e(n, t);
620
628
  if (typeof i != "string") throw TypeError(`alphacharts: timeLabel(${n}, "${t}") returned ${typeof i}, not a string`);
621
629
  return i;
622
630
  }
623
- var Re = class {
631
+ var Be = class {
624
632
  year;
625
633
  month;
626
634
  day;
@@ -695,11 +703,11 @@ var Re = class {
695
703
  format(e) {
696
704
  return e.toFixed(this.decimals);
697
705
  }
698
- }, ze = {
706
+ }, Ve = {
699
707
  barSpacing: 8,
700
708
  maxBarSpacing: 80,
701
709
  rightOffset: 4
702
- }, Be = class {
710
+ }, He = class {
703
711
  options;
704
712
  spacing;
705
713
  rightOffset;
@@ -778,28 +786,31 @@ function j(e, t, n) {
778
786
  }
779
787
  //#endregion
780
788
  //#region src/chart/scheduler.ts
781
- var M = /* @__PURE__ */ new Map(), Ve = 0;
782
- function He(e, t) {
783
- M.set(e, (M.get(e) ?? 0) | t), Ve === 0 && (Ve = requestAnimationFrame(We));
789
+ var M = /* @__PURE__ */ new Map(), Ue = 0;
790
+ function We(e, t) {
791
+ M.set(e, (M.get(e) ?? 0) | t), Ue === 0 && (Ue = requestAnimationFrame(Ke));
784
792
  }
785
- function Ue(e) {
793
+ function Ge(e) {
786
794
  M.delete(e);
787
795
  }
788
- function We(e) {
789
- Ve = 0;
796
+ function Ke(e) {
797
+ Ue = 0;
790
798
  let t = [...M];
791
799
  M.clear();
792
- let n = null;
793
- for (let [r, i] of t) try {
794
- r.render(i, e);
800
+ let r = null;
801
+ for (let [n, i] of t) try {
802
+ n.render(i, e);
795
803
  } catch (e) {
796
- n ??= { error: e };
804
+ r ??= { error: e };
797
805
  }
798
- if (n) throw n.error;
806
+ if (r) throw n({
807
+ source: "draw-loop",
808
+ error: r.error
809
+ }), r.error;
799
810
  }
800
811
  //#endregion
801
812
  //#region src/interaction/input.ts
802
- var Ge = 3, Ke = .15, qe = .02, Je = class {
813
+ var qe = 3, Je = .15, Ye = .02, Xe = class {
803
814
  chart;
804
815
  root;
805
816
  surface;
@@ -940,7 +951,7 @@ var Ge = 3, Ke = .15, qe = .02, Je = class {
940
951
  break;
941
952
  case "pan": {
942
953
  let n = t.x - i.x, a = t.y - i.y;
943
- if (!i.moved && Math.hypot(n, a) < Ge) return;
954
+ if (!i.moved && Math.hypot(n, a) < qe) return;
944
955
  i.moved = !0, this.cancelLongPress(), r.pan && (this.chart.viewChanged(() => this.chart.time.pan(n)), this.chart.panPrice(i.pane, a)), i.x = t.x, i.y = t.y, this.samples.push({
945
956
  t: e.timeStamp,
946
957
  x: t.x
@@ -1108,17 +1119,17 @@ var Ge = 3, Ke = .15, qe = .02, Je = class {
1108
1119
  let t = this.samples, n = t.find((t) => e - t.t < 100) ?? t[0], r = t[t.length - 1];
1109
1120
  if (!n || !r || r.t === n.t) return;
1110
1121
  let i = (r.x - n.x) / (r.t - n.t);
1111
- if (Math.abs(i) < Ke) return;
1122
+ if (Math.abs(i) < Je) return;
1112
1123
  let a = performance.now(), o = (e) => {
1113
1124
  let t = Math.min(64, e - a);
1114
- a = e, this.chart.viewChanged(() => this.chart.time.pan(i * t)), i *= .95 ** (t / 16), this.kinetic = Math.abs(i) > qe ? requestAnimationFrame(o) : 0;
1125
+ a = e, this.chart.viewChanged(() => this.chart.time.pan(i * t)), i *= .95 ** (t / 16), this.kinetic = Math.abs(i) > Ye ? requestAnimationFrame(o) : 0;
1115
1126
  };
1116
1127
  this.kinetic = requestAnimationFrame(o), this.chart.invalidate(4);
1117
1128
  }
1118
1129
  stopKinetic() {
1119
1130
  this.kinetic && cancelAnimationFrame(this.kinetic), this.kinetic = 0;
1120
1131
  }
1121
- }, Ye = class {
1132
+ }, Ze = class {
1122
1133
  map = /* @__PURE__ */ new Map();
1123
1134
  on(e, t) {
1124
1135
  let n = this.map.get(e);
@@ -1140,7 +1151,7 @@ var Ge = 3, Ke = .15, qe = .02, Je = class {
1140
1151
  };
1141
1152
  //#endregion
1142
1153
  //#region src/chart/primitives.ts
1143
- function Xe(e, t) {
1154
+ function Qe(e, t) {
1144
1155
  switch (e) {
1145
1156
  case "solid": return [];
1146
1157
  case "dashed": return [4 * t, 3 * t];
@@ -1149,16 +1160,16 @@ function Xe(e, t) {
1149
1160
  case "sparse-dotted": return [t, 6 * t];
1150
1161
  }
1151
1162
  }
1152
- function Ze(e) {
1153
- if (e.lineWidth !== 1 && e.lineWidth !== 2) throw RangeError(`alphacharts: price line lineWidth must be 1 or 2, got ${e.lineWidth}`);
1154
- if (e.lineStyle !== "solid" && e.lineStyle !== "dashed" && e.lineStyle !== "dotted" && e.lineStyle !== "large-dashed" && e.lineStyle !== "sparse-dotted") throw RangeError(`alphacharts: unknown price line lineStyle "${String(e.lineStyle)}"`);
1155
- e.axisLabelColor !== void 0 && t(e.axisLabelColor);
1163
+ function $e(t) {
1164
+ if (t.lineWidth !== 1 && t.lineWidth !== 2) throw RangeError(`alphacharts: price line lineWidth must be 1 or 2, got ${t.lineWidth}`);
1165
+ if (t.lineStyle !== "solid" && t.lineStyle !== "dashed" && t.lineStyle !== "dotted" && t.lineStyle !== "large-dashed" && t.lineStyle !== "sparse-dotted") throw RangeError(`alphacharts: unknown price line lineStyle "${String(t.lineStyle)}"`);
1166
+ t.axisLabelColor !== void 0 && e(t.axisLabelColor);
1156
1167
  }
1157
1168
  function N(e, t, n = 1) {
1158
1169
  let r = Math.max(1, Math.round(n * t));
1159
1170
  return (Math.round(e * t) + (r % 2 ? .5 : 0)) / t;
1160
1171
  }
1161
- var Qe = class {
1172
+ var et = class {
1162
1173
  host = null;
1163
1174
  opts;
1164
1175
  constructor(e) {
@@ -1171,7 +1182,7 @@ var Qe = class {
1171
1182
  labelTextColor: "#ffffff",
1172
1183
  ...e
1173
1184
  };
1174
- Ze(t), this.opts = t;
1185
+ $e(t), this.opts = t;
1175
1186
  }
1176
1187
  options() {
1177
1188
  return this.opts;
@@ -1181,7 +1192,7 @@ var Qe = class {
1181
1192
  ...this.opts,
1182
1193
  ...e
1183
1194
  };
1184
- Ze(t), this.opts = t, this.host?.requestRender();
1195
+ $e(t), this.opts = t, this.host?.requestRender();
1185
1196
  }
1186
1197
  attached(e) {
1187
1198
  this.host = e;
@@ -1191,7 +1202,7 @@ var Qe = class {
1191
1202
  }
1192
1203
  draw(e, t) {
1193
1204
  let n = this.opts, r = N(t.y(n.price), t.dpr, n.lineWidth);
1194
- r < -n.lineWidth || r > t.height + n.lineWidth || (e.strokeStyle = n.color, e.lineWidth = Math.max(1, Math.round(n.lineWidth * t.dpr)) / t.dpr, e.setLineDash(Xe(n.lineStyle, n.lineWidth)), e.beginPath(), e.moveTo(0, r), e.lineTo(t.width, r), e.stroke(), e.setLineDash([]), n.title && (e.fillStyle = n.color, e.textBaseline = "bottom", e.textAlign = "right", e.fillText(n.title, t.width - 6, r - 2)));
1205
+ r < -n.lineWidth || r > t.height + n.lineWidth || (e.strokeStyle = n.color, e.lineWidth = Math.max(1, Math.round(n.lineWidth * t.dpr)) / t.dpr, e.setLineDash(Qe(n.lineStyle, n.lineWidth)), e.beginPath(), e.moveTo(0, r), e.lineTo(t.width, r), e.stroke(), e.setLineDash([]), n.title && (e.fillStyle = n.color, e.textBaseline = "bottom", e.textAlign = "right", e.fillText(n.title, t.width - 6, r - 2)));
1195
1206
  }
1196
1207
  axisLabels(e) {
1197
1208
  let t = this.opts;
@@ -1202,35 +1213,99 @@ var Qe = class {
1202
1213
  color: t.labelTextColor
1203
1214
  }] : [];
1204
1215
  }
1205
- }, $e = [
1216
+ }, tt = class {
1217
+ host = null;
1218
+ times = /* @__PURE__ */ new Float64Array();
1219
+ colors = /* @__PURE__ */ new Uint32Array();
1220
+ n = 0;
1221
+ shown = !0;
1222
+ any = !1;
1223
+ set(e, t) {
1224
+ if (e.length !== t.length) throw RangeError(`BarShading.set: ${t.length} colours for ${e.length} times`);
1225
+ this.times = e.slice(), this.colors = t.slice(), this.n = e.length, this.any = this.colors.some((e) => e !== 0), this.host?.requestRender("background");
1226
+ }
1227
+ setAt(e, t) {
1228
+ let n = this.n, r = n;
1229
+ if (n > 0 && e <= this.times[n - 1] && (r = nt(this.times, n, e), this.times[r] !== e)) throw RangeError(`BarShading.setAt: time ${e} is neither the last bar nor a later one`);
1230
+ if (r === n) {
1231
+ if (n === this.times.length) {
1232
+ let e = Math.max(64, n * 2), t = new Float64Array(e), r = new Uint32Array(e);
1233
+ t.set(this.times.subarray(0, n)), r.set(this.colors.subarray(0, n)), this.times = t, this.colors = r;
1234
+ }
1235
+ this.times[n] = e, this.n = n + 1;
1236
+ } else if (this.colors[r] === t) return;
1237
+ this.colors[r] = t, t !== 0 && (this.any = !0), this.host?.requestRender("background");
1238
+ }
1239
+ clear() {
1240
+ this.n = 0, this.any = !1, this.host?.requestRender("background");
1241
+ }
1242
+ setVisible(e) {
1243
+ e !== this.shown && (this.shown = e, this.host?.requestRender("background"));
1244
+ }
1245
+ attached(e) {
1246
+ this.host = e;
1247
+ }
1248
+ detached() {
1249
+ this.host = null;
1250
+ }
1251
+ drawBackground(e, n) {
1252
+ if (!this.shown || !this.any || this.n === 0) return;
1253
+ let r = this.times, i = this.colors, a = this.n, o = n.barSpacing / 2, s = 0, c = a;
1254
+ for (; s < c;) {
1255
+ let e = s + c >>> 1;
1256
+ n.timeToX(r[e]) + o < 0 ? s = e + 1 : c = e;
1257
+ }
1258
+ let l = s, u = -1, d = -1, f = 0, p = () => {
1259
+ f === 0 || u < 0 || (e.fillStyle = t(f), e.fillRect(u, 0, d - u, n.height));
1260
+ };
1261
+ for (; l < a && !(n.timeToX(r[l]) - o > n.width); l++) {
1262
+ let e = i[l], t = n.timeToIndex(r[l]);
1263
+ if (t === void 0) continue;
1264
+ let a = n.x(t);
1265
+ e === f && e !== 0 && Math.abs(a - o - d) < .5 || (p(), f = e, u = a - o), d = a + o;
1266
+ }
1267
+ p();
1268
+ }
1269
+ };
1270
+ function nt(e, t, n) {
1271
+ let r = 0, i = t;
1272
+ for (; r < i;) {
1273
+ let t = r + i >>> 1;
1274
+ e[t] < n ? r = t + 1 : i = t;
1275
+ }
1276
+ return r;
1277
+ }
1278
+ //#endregion
1279
+ //#region src/chart/markers.ts
1280
+ var rt = [
1206
1281
  "arrowUp",
1207
1282
  "arrowDown",
1208
1283
  "circle"
1209
- ], et = ["aboveBar", "belowBar"], P = (e, t) => `marker ${e.id === void 0 ? `#${t}` : `"${e.id}"`} (time ${e.time})`;
1210
- function tt(e, n) {
1284
+ ], it = ["aboveBar", "belowBar"], P = (e, t) => `marker ${e.id === void 0 ? `#${t}` : `"${e.id}"`} (time ${e.time})`;
1285
+ function at(t, n) {
1211
1286
  let r = /* @__PURE__ */ new Set();
1212
- return e.forEach((e, i) => {
1213
- if (!Number.isFinite(e.time)) throw RangeError(`alphacharts: ${P(e, i)} has a non-finite time`);
1214
- if (!et.includes(e.position)) throw RangeError(`alphacharts: ${P(e, i)} has unknown position "${String(e.position)}"`);
1215
- if (!$e.includes(e.shape)) throw RangeError(`alphacharts: ${P(e, i)} has unknown shape "${String(e.shape)}"`);
1216
- if (e.size !== void 0 && !(e.size > 0 && Number.isFinite(e.size))) throw RangeError(`alphacharts: ${P(e, i)} has size ${e.size}; it must be positive`);
1217
- if (e.id !== void 0) {
1218
- if (e.id === "") throw RangeError(`alphacharts: ${P(e, i)} has an empty id`);
1219
- if (r.has(e.id)) throw Error(`alphacharts: ${P(e, i)}: the id is used by another marker`);
1220
- r.add(e.id);
1287
+ return t.forEach((t, i) => {
1288
+ if (!Number.isFinite(t.time)) throw RangeError(`alphacharts: ${P(t, i)} has a non-finite time`);
1289
+ if (!it.includes(t.position)) throw RangeError(`alphacharts: ${P(t, i)} has unknown position "${String(t.position)}"`);
1290
+ if (!rt.includes(t.shape)) throw RangeError(`alphacharts: ${P(t, i)} has unknown shape "${String(t.shape)}"`);
1291
+ if (t.size !== void 0 && !(t.size > 0 && Number.isFinite(t.size))) throw RangeError(`alphacharts: ${P(t, i)} has size ${t.size}; it must be positive`);
1292
+ if (t.id !== void 0) {
1293
+ if (t.id === "") throw RangeError(`alphacharts: ${P(t, i)} has an empty id`);
1294
+ if (r.has(t.id)) throw Error(`alphacharts: ${P(t, i)}: the id is used by another marker`);
1295
+ r.add(t.id);
1221
1296
  }
1222
1297
  try {
1223
- t(e.color);
1224
- } catch (t) {
1225
- throw Error(`alphacharts: ${P(e, i)} has a bad colour: ${t.message}`);
1298
+ e(t.color);
1299
+ } catch (e) {
1300
+ throw Error(`alphacharts: ${P(t, i)} has a bad colour: ${e.message}`);
1226
1301
  }
1227
- if (!n(e.time)) throw RangeError(`alphacharts: ${P(e, i)} is not on a bar of the series`);
1228
- }), e.map((e, t) => ({
1302
+ if (!n(t.time)) throw RangeError(`alphacharts: ${P(t, i)} is not on a bar of the series`);
1303
+ }), t.map((e, t) => ({
1229
1304
  m: e,
1230
1305
  i: t
1231
1306
  })).sort((e, t) => e.m.time - t.m.time || e.i - t.i).map((e) => ({ ...e.m }));
1232
1307
  }
1233
- function nt(e, t) {
1308
+ function ot(e, t) {
1234
1309
  let n = 0, r = e.length;
1235
1310
  for (; n < r;) {
1236
1311
  let i = n + r >> 1;
@@ -1238,18 +1313,18 @@ function nt(e, t) {
1238
1313
  }
1239
1314
  return n;
1240
1315
  }
1241
- var rt = 4, it = 2;
1242
- function at(e, t = 1) {
1316
+ var st = 4, ct = 2;
1317
+ function lt(e, t = 1) {
1243
1318
  return Math.round(Math.min(20, Math.max(8, e * .8)) * t);
1244
1319
  }
1245
- function ot(e) {
1320
+ function ut(e) {
1246
1321
  let t = [], n = NaN, r = 0, i = 0;
1247
1322
  for (let a = e.from; a < e.to; a++) {
1248
1323
  let o = e.markers[a];
1249
1324
  o.time !== n && (n = o.time, r = i = 0);
1250
1325
  let s = e.bar(o);
1251
1326
  if (!s) continue;
1252
- let c = at(e.barSpacing, o.size), l = o.text ? e.fontSize + 2 : 0, u = c + l + it, d = o.position === "aboveBar", f = d ? r : i, p = d ? s.yHigh - rt - f : s.yLow + rt + f, m = d ? p - c / 2 : p + c / 2, h = d ? p - c - l : p, g = o.text ? Math.max(c, e.textWidth(o.text)) : c;
1327
+ let c = lt(e.barSpacing, o.size), l = o.text ? e.fontSize + 2 : 0, u = c + l + ct, d = o.position === "aboveBar", f = d ? r : i, p = d ? s.yHigh - st - f : s.yLow + st + f, m = d ? p - c / 2 : p + c / 2, h = d ? p - c - l : p, g = o.text ? Math.max(c, e.textWidth(o.text)) : c;
1253
1328
  t.push({
1254
1329
  marker: o,
1255
1330
  cx: s.x,
@@ -1265,7 +1340,7 @@ function ot(e) {
1265
1340
  }
1266
1341
  return t;
1267
1342
  }
1268
- function st(e, t) {
1343
+ function dt(e, t) {
1269
1344
  e.textAlign = "center";
1270
1345
  for (let n of t) {
1271
1346
  let t = n.marker, r = n.size / 2;
@@ -1286,20 +1361,20 @@ function st(e, t) {
1286
1361
  }
1287
1362
  //#endregion
1288
1363
  //#region src/scale/format.ts
1289
- var ct = 10;
1290
- function lt(e) {
1364
+ var ft = 10;
1365
+ function pt(e) {
1291
1366
  let t = Math.abs(e);
1292
- for (let e = 0; e < ct; e++) {
1367
+ for (let e = 0; e < ft; e++) {
1293
1368
  let n = t * 10 ** e;
1294
1369
  if (Math.abs(n - Math.round(n)) <= 1e-9 * Math.max(1, n)) return e;
1295
1370
  }
1296
- return ct;
1371
+ return ft;
1297
1372
  }
1298
- function ut(e) {
1373
+ function mt(e) {
1299
1374
  let t = (e ?? (typeof navigator < "u" ? navigator.language : "en")).toLowerCase();
1300
1375
  return t.endsWith("-in") || t === "hi" || t.startsWith("hi-");
1301
1376
  }
1302
- function dt(e, t, n) {
1377
+ function ht(e, t, n) {
1303
1378
  switch (e.type) {
1304
1379
  case "custom":
1305
1380
  if (!(e.minMove > 0)) throw RangeError(`custom priceFormat needs a positive minMove, got ${e.minMove}`);
@@ -1322,7 +1397,7 @@ function dt(e, t, n) {
1322
1397
  };
1323
1398
  }
1324
1399
  case "volume": {
1325
- let t = e.minMove ?? 1, r = ut(n) ? [
1400
+ let t = e.minMove ?? 1, r = mt(n) ? [
1326
1401
  [1e7, "Cr"],
1327
1402
  [1e5, "L"],
1328
1403
  [1e3, "K"]
@@ -1345,14 +1420,14 @@ function dt(e, t, n) {
1345
1420
  }
1346
1421
  //#endregion
1347
1422
  //#region src/render/renderers.ts
1348
- var ft = "#version 300 es\nprecision highp float;\nin vec4 v_color;\nout vec4 o_color;\nvoid main() { o_color = vec4(v_color.rgb * v_color.a, v_color.a); }\n", F = "gl_Position = vec4(2.0, 2.0, 2.0, 1.0); return;", I = class {
1423
+ var gt = "#version 300 es\nprecision highp float;\nin vec4 v_color;\nout vec4 o_color;\nvoid main() { o_color = vec4(v_color.rgb * v_color.a, v_color.a); }\n", F = "gl_Position = vec4(2.0, 2.0, 2.0, 1.0); return;", I = class {
1349
1424
  gl;
1350
1425
  win;
1351
1426
  vao;
1352
1427
  prog;
1353
1428
  level = 0;
1354
1429
  constructor(e, t, n, r, i, a) {
1355
- this.gl = e, this.prog = i, this.win = new f(e, n, r, a), this.vao = e.createVertexArray(), e.bindVertexArray(this.vao), e.bindBuffer(e.ARRAY_BUFFER, this.win.buffer), pt(e, i, "a_r", "a_c", "a_color", 0), a && pt(e, i, "a_r1", "a_c1", "a_color1", 24), e.bindVertexArray(null);
1430
+ this.gl = e, this.prog = i, this.win = new p(e, n, r, a), this.vao = e.createVertexArray(), e.bindVertexArray(this.vao), e.bindBuffer(e.ARRAY_BUFFER, this.win.buffer), _t(e, i, "a_r", "a_c", "a_color", 0), a && _t(e, i, "a_r1", "a_c1", "a_color1", 24), e.bindVertexArray(null);
1356
1431
  }
1357
1432
  dataChanged(e) {
1358
1433
  this.win.dataChanged(e);
@@ -1362,9 +1437,9 @@ var ft = "#version 300 es\nprecision highp float;\nin vec4 v_color;\nout vec4 o_
1362
1437
  }
1363
1438
  prepare(e) {
1364
1439
  let t = this.gl, n = e.time.spacing * e.dpr;
1365
- this.level = r(e.data, n), this.win.setLog(e.price.logCoords), this.win.ensure(this.level, e.lo, e.hi), t.useProgram(this.prog.program), t.bindVertexArray(this.vao);
1366
- let i = this.prog.uniforms;
1367
- return t.uniform2f(i.u_view, e.width, e.height), t.uniform2f(i.u_x, n, e.time.x(this.win.base) * e.dpr), t.uniform2f(i.u_y, -e.price.pxPerCoord * e.dpr, e.price.yOfCoord(this.win.priceBase) * e.dpr), this.win.count;
1440
+ this.level = i(e.data, n), this.win.setLog(e.price.logCoords), this.win.ensure(this.level, e.lo, e.hi), t.useProgram(this.prog.program), t.bindVertexArray(this.vao);
1441
+ let r = this.prog.uniforms;
1442
+ return t.uniform2f(r.u_view, e.width, e.height), t.uniform2f(r.u_x, n, e.time.x(this.win.base) * e.dpr), t.uniform2f(r.u_y, -e.price.pxPerCoord * e.dpr, e.price.yOfCoord(this.win.priceBase) * e.dpr), this.win.count;
1368
1443
  }
1369
1444
  widths(e, t) {
1370
1445
  return L(e.time.spacing, e.dpr, this.level, t);
@@ -1374,23 +1449,23 @@ function L(e, t, n, r) {
1374
1449
  let i = e * t * (1 << n), a = Math.max(1, Math.floor(t)), o = Math.max(1, Math.floor(i * r));
1375
1450
  return o > a && (o - a) % 2 != 0 && --o, [o, Math.min(a, o)];
1376
1451
  }
1377
- function pt(e, t, n, r, i, a) {
1452
+ function _t(e, t, n, r, i, a) {
1378
1453
  let o = t.attribs;
1379
1454
  o[n] >= 0 && (e.enableVertexAttribArray(o[n]), e.vertexAttribPointer(o[n], 4, e.FLOAT, !1, 24, a), e.vertexAttribDivisor(o[n], 1)), o[r] >= 0 && (e.enableVertexAttribArray(o[r]), e.vertexAttribPointer(o[r], 1, e.FLOAT, !1, 24, a + 16), e.vertexAttribDivisor(o[r], 1)), o[i] !== void 0 && o[i] >= 0 && (e.enableVertexAttribArray(o[i]), e.vertexAttribIPointer(o[i], 1, e.UNSIGNED_INT, 24, a + 20), e.vertexAttribDivisor(o[i], 1));
1380
1455
  }
1381
1456
  var R = class {
1382
1457
  keys = [];
1383
1458
  vals = [];
1384
- get(n, r) {
1385
- return this.keys[n] !== r && (this.keys[n] = r, this.vals[n] = e(t(r))), this.vals[n];
1459
+ get(t, n) {
1460
+ return this.keys[t] !== n && (this.keys[t] = n, this.vals[t] = ee(e(n))), this.vals[t];
1386
1461
  }
1387
- }, mt = h + `
1388
- in vec4 a_r; in float a_c;
1462
+ }, vt = g + `
1463
+ in vec4 a_r; in float a_c; in uint a_color;
1389
1464
  uniform vec2 u_w;
1390
1465
  uniform vec4 u_up, u_down, u_wup, u_wdown;
1391
1466
  out vec4 v_color;
1392
1467
  void main() {
1393
- if (a_r.x < ${g}) { ${F} }
1468
+ if (a_r.x < ${_}) { ${F} }
1394
1469
  bool wick = gl_VertexID < 6;
1395
1470
  vec2 cr = corner(gl_VertexID % 6);
1396
1471
  float o = a_r.y, h = a_r.z, l = a_r.w, c = a_c;
@@ -1408,17 +1483,21 @@ void main() {
1408
1483
  }
1409
1484
  gl_Position = vec4(toClip(vec2(mix(x0, x1, cr.x), mix(y0, y1, cr.y))), 0.0, 1.0);
1410
1485
  bool up = c >= o;
1411
- v_color = wick ? (up ? u_wup : u_wdown) : (up ? u_up : u_down);
1412
- }`, ht = class extends I {
1486
+ v_color = a_color != 0u ? unpack(a_color) : wick ? (up ? u_wup : u_wdown) : (up ? u_up : u_down);
1487
+ }`, yt = class extends I {
1413
1488
  colors = new R();
1414
1489
  constructor(e, t, n) {
1415
- super(e, t, n, !1, t.program("candles", mt, ft, [
1490
+ super(e, t, n, !1, t.program("candles", vt, gt, [
1416
1491
  "u_w",
1417
1492
  "u_up",
1418
1493
  "u_down",
1419
1494
  "u_wup",
1420
1495
  "u_wdown"
1421
- ], ["a_r", "a_c"]), !1);
1496
+ ], [
1497
+ "a_r",
1498
+ "a_c",
1499
+ "a_color"
1500
+ ]), !1);
1422
1501
  }
1423
1502
  draw(e, t) {
1424
1503
  let n = this.prepare(e);
@@ -1426,13 +1505,13 @@ void main() {
1426
1505
  let r = this.gl, i = this.prog.uniforms, [a, o] = this.widths(e, .8);
1427
1506
  r.uniform2f(i.u_w, a, o), r.uniform4fv(i.u_up, this.colors.get(0, t.upColor)), r.uniform4fv(i.u_down, this.colors.get(1, t.downColor)), r.uniform4fv(i.u_wup, this.colors.get(2, t.wickUpColor)), r.uniform4fv(i.u_wdown, this.colors.get(3, t.wickDownColor)), r.drawArraysInstanced(r.TRIANGLES, 0, 12, n);
1428
1507
  }
1429
- }, gt = h + `
1430
- in vec4 a_r; in float a_c;
1508
+ }, bt = g + `
1509
+ in vec4 a_r; in float a_c; in uint a_color;
1431
1510
  uniform vec2 u_w;
1432
1511
  uniform vec4 u_up, u_down;
1433
1512
  out vec4 v_color;
1434
1513
  void main() {
1435
- if (a_r.x < ${g}) { ${F} }
1514
+ if (a_r.x < ${_}) { ${F} }
1436
1515
  int seg = gl_VertexID / 6;
1437
1516
  vec2 cr = corner(gl_VertexID % 6);
1438
1517
  float o = a_r.y, h = a_r.z, l = a_r.w, c = a_c, t = u_w.y;
@@ -1449,15 +1528,19 @@ void main() {
1449
1528
  if (seg == 1) { x0 = left; x1 = mid; } else { x0 = mid + t; x1 = left + u_w.x; }
1450
1529
  }
1451
1530
  gl_Position = vec4(toClip(vec2(mix(x0, x1, cr.x), mix(y0, y1, cr.y))), 0.0, 1.0);
1452
- v_color = c >= o ? u_up : u_down;
1453
- }`, _t = class extends I {
1531
+ v_color = a_color != 0u ? unpack(a_color) : c >= o ? u_up : u_down;
1532
+ }`, xt = class extends I {
1454
1533
  colors = new R();
1455
1534
  constructor(e, t, n) {
1456
- super(e, t, n, !1, t.program("bars", gt, ft, [
1535
+ super(e, t, n, !1, t.program("bars", bt, gt, [
1457
1536
  "u_w",
1458
1537
  "u_up",
1459
1538
  "u_down"
1460
- ], ["a_r", "a_c"]), !1);
1539
+ ], [
1540
+ "a_r",
1541
+ "a_c",
1542
+ "a_color"
1543
+ ]), !1);
1461
1544
  }
1462
1545
  draw(e, t) {
1463
1546
  let n = this.prepare(e);
@@ -1465,14 +1548,14 @@ void main() {
1465
1548
  let r = this.gl, i = this.prog.uniforms, [a, o] = this.widths(e, .8);
1466
1549
  r.uniform2f(i.u_w, a, o), r.uniform4fv(i.u_up, this.colors.get(0, t.upColor)), r.uniform4fv(i.u_down, this.colors.get(1, t.downColor)), r.drawArraysInstanced(r.TRIANGLES, 0, 18, n);
1467
1550
  }
1468
- }, vt = h + `
1551
+ }, St = g + `
1469
1552
  in vec4 a_r; in uint a_color;
1470
1553
  uniform float u_w;
1471
1554
  uniform float u_base;
1472
1555
  uniform vec4 u_color;
1473
1556
  out vec4 v_color;
1474
1557
  void main() {
1475
- if (a_r.x < ${g}) { ${F} }
1558
+ if (a_r.x < ${_}) { ${F} }
1476
1559
  vec2 cr = corner(gl_VertexID);
1477
1560
  float left = floor(xDev(a_r.x) - u_w * 0.5 + 0.5);
1478
1561
  // Zoomed out, a bucket spans bars on both sides of the base: draw the
@@ -1482,10 +1565,10 @@ void main() {
1482
1565
  float y0 = min(yv, yb), y1 = max(max(yv, yb), y0 + 1.0);
1483
1566
  gl_Position = vec4(toClip(vec2(mix(left, left + u_w, cr.x), mix(y0, y1, cr.y))), 0.0, 1.0);
1484
1567
  v_color = a_color != 0u ? unpack(a_color) : u_color;
1485
- }`, yt = class extends I {
1568
+ }`, Ct = class extends I {
1486
1569
  colors = new R();
1487
1570
  constructor(e, t, n) {
1488
- super(e, t, n, !0, t.program("histogram", vt, ft, [
1571
+ super(e, t, n, !0, t.program("histogram", St, gt, [
1489
1572
  "u_w",
1490
1573
  "u_base",
1491
1574
  "u_color"
@@ -1499,16 +1582,17 @@ void main() {
1499
1582
  let a = e.price.logCoords && !(t.base > 0) ? e.price.min : e.price.coord(t.base);
1500
1583
  r.uniform1f(i.u_base, a - this.win.priceBase), r.uniform4fv(i.u_color, this.colors.get(0, t.color)), r.drawArraysInstanced(r.TRIANGLES, 0, 6, n);
1501
1584
  }
1502
- }, bt = h + `
1585
+ }, wt = g + `
1503
1586
  in vec4 a_r; in float a_c;
1504
- in vec4 a_r1;
1587
+ in vec4 a_r1; in uint a_color1;
1505
1588
  uniform float u_half;
1506
1589
  uniform int u_env;
1507
1590
  out vec2 v_pos;
1508
1591
  flat out vec2 v_a;
1509
1592
  flat out vec2 v_b;
1593
+ flat out vec4 v_seg;
1510
1594
  void main() {
1511
- if (a_r.x < ${g} || a_r1.x < ${g}) { ${F} }
1595
+ if (a_r.x < ${_} || a_r1.x < ${_}) { ${F} }
1512
1596
  bool env = gl_VertexID >= 6;
1513
1597
  if (env && u_env == 0) { ${F} }
1514
1598
  vec2 a = env ? vec2(xDev(a_r1.x), yDev(a_r1.w)) : vec2(xDev(a_r.x), yDev(a_c));
@@ -1521,18 +1605,20 @@ void main() {
1521
1605
  vec2 cr = corner(gl_VertexID % 6);
1522
1606
  vec2 p = mix(a - dir * r, b + dir * r, cr.x) + nrm * mix(-r, r, cr.y);
1523
1607
  v_pos = p; v_a = a; v_b = b;
1608
+ v_seg = a_color1 != 0u ? unpack(a_color1) : vec4(0.0, 0.0, 0.0, -1.0);
1524
1609
  gl_Position = vec4(toClip(p), 0.0, 1.0);
1525
- }`, xt = "#version 300 es\nprecision highp float;\nin vec2 v_pos;\nflat in vec2 v_a;\nflat in vec2 v_b;\nuniform float u_half;\nuniform vec4 u_color;\nout vec4 o_color;\nvoid main() {\n vec2 pa = v_pos - v_a, ba = v_b - v_a;\n float t = clamp(dot(pa, ba) / max(dot(ba, ba), 1e-6), 0.0, 1.0);\n float dist = length(pa - ba * t);\n float cov = clamp(u_half + 0.5 - dist, 0.0, 1.0);\n if (cov <= 0.0) discard;\n float a = u_color.a * cov;\n o_color = vec4(u_color.rgb * a, a);\n}", St = class extends I {
1610
+ }`, Tt = "#version 300 es\nprecision highp float;\nin vec2 v_pos;\nflat in vec2 v_a;\nflat in vec2 v_b;\nflat in vec4 v_seg;\nuniform float u_half;\nuniform vec4 u_color;\nout vec4 o_color;\nvoid main() {\n vec2 pa = v_pos - v_a, ba = v_b - v_a;\n float t = clamp(dot(pa, ba) / max(dot(ba, ba), 1e-6), 0.0, 1.0);\n float dist = length(pa - ba * t);\n float cov = clamp(u_half + 0.5 - dist, 0.0, 1.0);\n if (cov <= 0.0) discard;\n vec4 col = v_seg.a < 0.0 ? u_color : v_seg;\n float a = col.a * cov;\n o_color = vec4(col.rgb * a, a);\n}", Et = class extends I {
1526
1611
  colors = new R();
1527
1612
  constructor(e, t, n) {
1528
- super(e, t, n, !1, t.program("line", bt, xt, [
1613
+ super(e, t, n, !1, t.program("line", wt, Tt, [
1529
1614
  "u_half",
1530
1615
  "u_env",
1531
1616
  "u_color"
1532
1617
  ], [
1533
1618
  "a_r",
1534
1619
  "a_c",
1535
- "a_r1"
1620
+ "a_r1",
1621
+ "a_color1"
1536
1622
  ]), !0);
1537
1623
  }
1538
1624
  draw(e, t) {
@@ -1543,22 +1629,22 @@ void main() {
1543
1629
  let i = this.gl, a = this.prog.uniforms;
1544
1630
  i.uniform1f(a.u_half, Math.max(.5, n * e.dpr / 2)), i.uniform1i(a.u_env, +(this.level > 0)), i.uniform4fv(a.u_color, this.colors.get(0, t)), i.drawArraysInstanced(i.TRIANGLES, 0, 12, r - 1);
1545
1631
  }
1546
- }, Ct = h + `
1632
+ }, Dt = g + `
1547
1633
  in vec4 a_r; in vec4 a_r1;
1548
1634
  out float v_t;
1549
1635
  void main() {
1550
- if (a_r.x < ${g} || a_r1.x < ${g}) { ${F} }
1636
+ if (a_r.x < ${_} || a_r1.x < ${_}) { ${F} }
1551
1637
  vec2 cr = corner(gl_VertexID);
1552
1638
  float x = mix(xDev(a_r.x), xDev(a_r1.x), cr.x);
1553
1639
  float top = mix(yDev(a_r.z), yDev(a_r1.z), cr.x);
1554
1640
  float y = mix(top, u_view.y, cr.y);
1555
1641
  v_t = y / u_view.y;
1556
1642
  gl_Position = vec4(toClip(vec2(x, y)), 0.0, 1.0);
1557
- }`, wt = "#version 300 es\nprecision highp float;\nin float v_t;\nuniform vec4 u_top, u_bottom;\nout vec4 o_color;\nvoid main() {\n vec4 c = mix(u_top, u_bottom, clamp(v_t, 0.0, 1.0));\n o_color = vec4(c.rgb * c.a, c.a);\n}", Tt = class {
1643
+ }`, Ot = "#version 300 es\nprecision highp float;\nin float v_t;\nuniform vec4 u_top, u_bottom;\nout vec4 o_color;\nvoid main() {\n vec4 c = mix(u_top, u_bottom, clamp(v_t, 0.0, 1.0));\n o_color = vec4(c.rgb * c.a, c.a);\n}", kt = class {
1558
1644
  fill;
1559
1645
  line;
1560
1646
  constructor(e, t, n) {
1561
- this.fill = new Et(e, t, n), this.line = new St(e, t, n);
1647
+ this.fill = new At(e, t, n), this.line = new Et(e, t, n);
1562
1648
  }
1563
1649
  draw(e, t) {
1564
1650
  this.fill.draw(e, t), this.line.draw(e, {
@@ -1572,10 +1658,10 @@ void main() {
1572
1658
  dispose() {
1573
1659
  this.fill.dispose(), this.line.dispose();
1574
1660
  }
1575
- }, Et = class extends I {
1661
+ }, At = class extends I {
1576
1662
  colors = new R();
1577
1663
  constructor(e, t, n) {
1578
- super(e, t, n, !1, t.program("area", Ct, wt, ["u_top", "u_bottom"], ["a_r", "a_r1"]), !0);
1664
+ super(e, t, n, !1, t.program("area", Dt, Ot, ["u_top", "u_bottom"], ["a_r", "a_r1"]), !0);
1579
1665
  }
1580
1666
  draw(e, t) {
1581
1667
  let n = this.prepare(e);
@@ -1589,7 +1675,7 @@ void main() {
1589
1675
  function z(e, t, n) {
1590
1676
  let r = e.data, i = e.dpr, a = e.time;
1591
1677
  if (t === 0) {
1592
- let t = r.store, o = r.shape === "ohlc", s = t.cols[0], c = t.cols[+!!o], l = t.cols[o ? 2 : 0], u = t.cols[o ? 3 : 0], d = o ? void 0 : t.cols[1], f = Math.max(e.lo - 1, t.first), p = Math.min(e.hi + 1, t.end - 1);
1678
+ let t = r.store, o = r.shape === "ohlc", s = t.cols[0], c = t.cols[+!!o], l = t.cols[o ? 2 : 0], u = t.cols[o ? 3 : 0], d = o ? t.cols[4] : t.cols[1], f = Math.max(e.lo - 1, t.first), p = Math.min(e.hi + 1, t.end - 1);
1593
1679
  for (let e = f; e <= p; e++) {
1594
1680
  let r = t.head + (e - t.first), o = s[r];
1595
1681
  o === o && n(a.x(e) * i, o, c[r], l[r], u[r], d ? d[r] : 0);
@@ -1604,40 +1690,43 @@ function z(e, t, n) {
1604
1690
  p === p && n(a.x((e << t) + f) * i, p, c[r], l[r], u[r], d ? d[r] : 0);
1605
1691
  }
1606
1692
  }
1607
- var B = (e) => r(e.data, e.time.spacing * e.dpr), V = (e, t) => e.price.y(t) * e.dpr, H = (e) => Math.floor(e + .5), U = class {
1693
+ var B = (e) => i(e.data, e.time.spacing * e.dpr), V = (e, t) => e.price.y(t) * e.dpr, H = (e) => Math.floor(e + .5), U = class {
1608
1694
  dataChanged() {}
1609
1695
  dispose() {}
1610
- }, Dt = class extends U {
1611
- draw(e, t) {
1612
- let n = B(e), [r, i] = L(e.time.spacing, e.dpr, n, .8), a = new Path2D(), o = new Path2D(), s = new Path2D(), c = new Path2D();
1613
- z(e, n, (t, n, l, u, d) => {
1614
- let f = Math.floor(t - r / 2 + .5), p = d >= n, m = H(V(e, l)), h = Math.max(H(V(e, u)), m + 1);
1615
- (p ? s : c).rect(f + (r - i) / 2, m, i, h - m);
1616
- let g = H(V(e, Math.max(n, d))), _ = Math.max(H(V(e, Math.min(n, d))), g + 1);
1617
- (p ? a : o).rect(f, g, r, _ - g);
1696
+ }, jt = class extends U {
1697
+ draw(e, n) {
1698
+ let r = B(e), [i, a] = L(e.time.spacing, e.dpr, r, .8), o = new Path2D(), s = new Path2D(), c = new Path2D(), l = new Path2D(), u;
1699
+ z(e, r, (t, n, r, d, f, p) => {
1700
+ let m = Math.floor(t - i / 2 + .5), h = f >= n, g = H(V(e, r)), _ = Math.max(H(V(e, d)), g + 1), v = H(V(e, Math.max(n, f))), y = Math.max(H(V(e, Math.min(n, f))), v + 1);
1701
+ if (p !== 0) {
1702
+ let e = (u ??= /* @__PURE__ */ new Map()).get(p);
1703
+ e || u.set(p, e = new Path2D()), e.rect(m + (i - a) / 2, g, a, _ - g), e.rect(m, v, i, y - v);
1704
+ } else (h ? c : l).rect(m + (i - a) / 2, g, a, _ - g), (h ? o : s).rect(m, v, i, y - v);
1618
1705
  });
1619
- let l = e.ctx;
1620
- l.fillStyle = t.wickUpColor, l.fill(s), l.fillStyle = t.wickDownColor, l.fill(c), l.fillStyle = t.upColor, l.fill(a), l.fillStyle = t.downColor, l.fill(o);
1706
+ let d = e.ctx;
1707
+ if (d.fillStyle = n.wickUpColor, d.fill(c), d.fillStyle = n.wickDownColor, d.fill(l), d.fillStyle = n.upColor, d.fill(o), d.fillStyle = n.downColor, d.fill(s), u) for (let [e, n] of u) d.fillStyle = t(e), d.fill(n);
1708
+ }
1709
+ }, Mt = class extends U {
1710
+ draw(e, n) {
1711
+ let r = B(e), [i, a] = L(e.time.spacing, e.dpr, r, .8), o = new Path2D(), s = new Path2D(), c;
1712
+ if (z(e, r, (t, n, r, l, u, d) => {
1713
+ let f = u >= n ? o : s;
1714
+ d !== 0 && (f = (c ??= /* @__PURE__ */ new Map()).get(d) ?? new Path2D(), c.set(d, f));
1715
+ let p = Math.floor(t - i / 2 + .5), m = p + (i - a) / 2, h = H(V(e, r)), g = Math.max(H(V(e, l)), h + 1);
1716
+ f.rect(m, h, a, g - h), f.rect(p, Math.floor(V(e, n) - a / 2 + .5), m - p, a), f.rect(m + a, Math.floor(V(e, u) - a / 2 + .5), p + i - m - a, a);
1717
+ }), e.ctx.fillStyle = n.upColor, e.ctx.fill(o), e.ctx.fillStyle = n.downColor, e.ctx.fill(s), c) for (let [n, r] of c) e.ctx.fillStyle = t(n), e.ctx.fill(r);
1621
1718
  }
1622
- }, Ot = class extends U {
1623
- draw(e, t) {
1624
- let n = B(e), [r, i] = L(e.time.spacing, e.dpr, n, .8), a = new Path2D(), o = new Path2D();
1625
- z(e, n, (t, n, s, c, l) => {
1626
- let u = l >= n ? a : o, d = Math.floor(t - r / 2 + .5), f = d + (r - i) / 2, p = H(V(e, s)), m = Math.max(H(V(e, c)), p + 1);
1627
- u.rect(f, p, i, m - p), u.rect(d, Math.floor(V(e, n) - i / 2 + .5), f - d, i), u.rect(f + i, Math.floor(V(e, l) - i / 2 + .5), d + r - f - i, i);
1628
- }), e.ctx.fillStyle = t.upColor, e.ctx.fill(a), e.ctx.fillStyle = t.downColor, e.ctx.fill(o);
1629
- }
1630
- }, kt = class extends U {
1631
- draw(e, t) {
1632
- let n = B(e), [r] = L(e.time.spacing, e.dpr, n, .8), i = /* @__PURE__ */ new Map(), a = H((e.price.logCoords && !(t.base > 0) ? e.price.yOfDisplay(e.price.min) : e.price.y(t.base)) * e.dpr);
1633
- z(e, n, (n, o, s, c, l, u) => {
1634
- let d = H(V(e, Math.abs(s - t.base) >= Math.abs(c - t.base) ? s : c)), f = Math.min(d, a), p = Math.max(Math.max(d, a), f + 1), m = i.get(u);
1635
- m || i.set(u, m = new Path2D()), m.rect(Math.floor(n - r / 2 + .5), f, r, p - f);
1719
+ }, Nt = class extends U {
1720
+ draw(e, n) {
1721
+ let r = B(e), [i] = L(e.time.spacing, e.dpr, r, .8), a = /* @__PURE__ */ new Map(), o = H((e.price.logCoords && !(n.base > 0) ? e.price.yOfDisplay(e.price.min) : e.price.y(n.base)) * e.dpr);
1722
+ z(e, r, (t, r, s, c, l, u) => {
1723
+ let d = H(V(e, Math.abs(s - n.base) >= Math.abs(c - n.base) ? s : c)), f = Math.min(d, o), p = Math.max(Math.max(d, o), f + 1), m = a.get(u);
1724
+ m || a.set(u, m = new Path2D()), m.rect(Math.floor(t - i / 2 + .5), f, i, p - f);
1636
1725
  });
1637
- for (let [n, r] of i) e.ctx.fillStyle = n === 0 ? t.color : y(n), e.ctx.fill(r);
1726
+ for (let [r, i] of a) e.ctx.fillStyle = r === 0 ? n.color : t(r), e.ctx.fill(i);
1638
1727
  }
1639
1728
  };
1640
- function At(e, t, n) {
1729
+ function Pt(e, t, n) {
1641
1730
  let r = new Path2D(), i = !1, a = 0, o = 0;
1642
1731
  return z(e, t, (s, c, l, u, d) => {
1643
1732
  if (t === 0 || n === "h") {
@@ -1651,36 +1740,53 @@ function At(e, t, n) {
1651
1740
  last: o
1652
1741
  };
1653
1742
  }
1654
- function jt(e, t, n, r) {
1743
+ function Ft(e, t, n, r) {
1655
1744
  let i = e.ctx;
1656
1745
  i.strokeStyle = n, i.lineWidth = Math.max(1, r * e.dpr), i.lineJoin = "round", i.lineCap = "round", i.stroke(t);
1657
1746
  }
1658
- var Mt = class extends U {
1747
+ function It(e, n, r, i) {
1748
+ let a = /* @__PURE__ */ new Map(), o = 0, s = 0, c = !1;
1749
+ z(e, n, (t, r, i, l, u, d) => {
1750
+ let f = a.get(d);
1751
+ f || a.set(d, f = new Path2D());
1752
+ let p = n === 0 ? [V(e, u)] : [
1753
+ V(e, r),
1754
+ V(e, i),
1755
+ V(e, l),
1756
+ V(e, u)
1757
+ ];
1758
+ if (c && (f.moveTo(o, s), f.lineTo(t, p[0])), n !== 0) for (let e = 1; e < p.length; e++) e === 1 && f.moveTo(t, p[0]), f.lineTo(t, p[e]);
1759
+ o = t, s = p[p.length - 1], c = !0;
1760
+ });
1761
+ for (let [n, o] of a) Ft(e, o, n === 0 ? r : t(n), i);
1762
+ }
1763
+ var Lt = class extends U {
1659
1764
  draw(e, t) {
1660
- jt(e, At(e, B(e), "c").path, t.color, t.lineWidth);
1765
+ let n = B(e);
1766
+ e.data.pointColors ? It(e, n, t.color, t.lineWidth) : Ft(e, Pt(e, n, "c").path, t.color, t.lineWidth);
1661
1767
  }
1662
- }, Nt = class extends U {
1768
+ }, Rt = class extends U {
1663
1769
  draw(e, t) {
1664
- let n = B(e), r = At(e, n, "h"), i = new Path2D(r.path);
1770
+ let n = B(e), r = Pt(e, n, "h"), i = new Path2D(r.path);
1665
1771
  i.lineTo(r.last, e.height), i.lineTo(r.first, e.height), i.closePath();
1666
1772
  let a = e.ctx.createLinearGradient(0, 0, 0, e.height);
1667
- a.addColorStop(0, t.topColor), a.addColorStop(1, t.bottomColor), e.ctx.fillStyle = a, e.ctx.fill(i), jt(e, At(e, n, "c").path, t.lineColor, t.lineWidth);
1773
+ a.addColorStop(0, t.topColor), a.addColorStop(1, t.bottomColor), e.ctx.fillStyle = a, e.ctx.fill(i), e.data.pointColors ? It(e, n, t.lineColor, t.lineWidth) : Ft(e, Pt(e, n, "c").path, t.lineColor, t.lineWidth);
1668
1774
  }
1669
- }, Pt = /* @__PURE__ */ new Map();
1775
+ }, zt = /* @__PURE__ */ new Map();
1670
1776
  function W(e, t) {
1671
- let n = Pt.get(e);
1777
+ let n = zt.get(e);
1672
1778
  if (n !== t) {
1673
1779
  if (n) throw Error(`alphacharts: series type "${e}" is already registered with a different definition`);
1674
- Pt.set(e, t);
1780
+ zt.set(e, t);
1675
1781
  }
1676
1782
  }
1677
- function Ft(e) {
1678
- let t = Pt.get(e);
1783
+ function Bt(e) {
1784
+ let t = zt.get(e);
1679
1785
  if (!t) throw Error(`alphacharts: unknown series type "${e}"`);
1680
1786
  return t;
1681
1787
  }
1682
1788
  var G = (e, t, n, r, i) => void e.lod.minMax(n, r, i);
1683
- function It(e, t, n, r) {
1789
+ function Vt(e, t, n, r) {
1684
1790
  if (!e.has(t)) return;
1685
1791
  let i = e.get(t, 3);
1686
1792
  return {
@@ -1696,28 +1802,28 @@ W("candles", {
1696
1802
  wickUpColor: e.up,
1697
1803
  wickDownColor: e.down
1698
1804
  }),
1699
- createRenderer: (e, t, n) => new ht(e, t, n),
1700
- createRenderer2D: () => new Dt(),
1805
+ createRenderer: (e, t, n) => new yt(e, t, n),
1806
+ createRenderer2D: () => new jt(),
1701
1807
  autoscale: G,
1702
- valueAt: (e, t, n) => It(e, n, t.upColor, t.downColor)
1808
+ valueAt: (e, t, n) => Vt(e, n, t.upColor, t.downColor)
1703
1809
  }), W("bars", {
1704
1810
  shape: "ohlc",
1705
1811
  defaults: (e) => ({
1706
1812
  upColor: e.up,
1707
1813
  downColor: e.down
1708
1814
  }),
1709
- createRenderer: (e, t, n) => new _t(e, t, n),
1710
- createRenderer2D: () => new Ot(),
1815
+ createRenderer: (e, t, n) => new xt(e, t, n),
1816
+ createRenderer2D: () => new Mt(),
1711
1817
  autoscale: G,
1712
- valueAt: (e, t, n) => It(e, n, t.upColor, t.downColor)
1818
+ valueAt: (e, t, n) => Vt(e, n, t.upColor, t.downColor)
1713
1819
  }), W("line", {
1714
1820
  shape: "value",
1715
1821
  defaults: (e) => ({
1716
1822
  color: e.accent,
1717
1823
  lineWidth: 2
1718
1824
  }),
1719
- createRenderer: (e, t, n) => new St(e, t, n),
1720
- createRenderer2D: () => new Mt(),
1825
+ createRenderer: (e, t, n) => new Et(e, t, n),
1826
+ createRenderer2D: () => new Lt(),
1721
1827
  autoscale: G,
1722
1828
  valueAt: (e, t, n) => e.has(n) ? {
1723
1829
  value: e.get(n, 0),
@@ -1731,8 +1837,8 @@ W("candles", {
1731
1837
  bottomColor: "rgba(41,98,255,0.02)",
1732
1838
  lineWidth: 2
1733
1839
  }),
1734
- createRenderer: (e, t, n) => new Tt(e, t, n),
1735
- createRenderer2D: () => new Nt(),
1840
+ createRenderer: (e, t, n) => new kt(e, t, n),
1841
+ createRenderer2D: () => new Rt(),
1736
1842
  autoscale: G,
1737
1843
  valueAt: (e, t, n) => e.has(n) ? {
1738
1844
  value: e.get(n, 0),
@@ -1744,29 +1850,29 @@ W("candles", {
1744
1850
  color: e.accent,
1745
1851
  base: 0
1746
1852
  }),
1747
- createRenderer: (e, t, n) => new yt(e, t, n),
1748
- createRenderer2D: () => new kt(),
1853
+ createRenderer: (e, t, n) => new Ct(e, t, n),
1854
+ createRenderer2D: () => new Nt(),
1749
1855
  autoscale: (e, t, n, r, i) => {
1750
1856
  e.lod.minMax(n, r, i), i[0] === i[0] && (i[0] = Math.min(i[0], t.base), i[1] = Math.max(i[1], t.base));
1751
1857
  },
1752
- valueAt: (e, t, n) => {
1753
- if (!e.has(n)) return;
1754
- let r = e.get(n, 1);
1858
+ valueAt: (e, n, r) => {
1859
+ if (!e.has(r)) return;
1860
+ let i = e.get(r, 1);
1755
1861
  return {
1756
- value: e.get(n, 0),
1757
- color: r === 0 ? t.color : y(r)
1862
+ value: e.get(r, 0),
1863
+ color: i === 0 ? n.color : t(i)
1758
1864
  };
1759
1865
  }
1760
1866
  });
1761
1867
  //#endregion
1762
1868
  //#region src/chart/series.ts
1763
- var Lt = 2048;
1764
- function Rt(e) {
1765
- let n = e.autoscale;
1869
+ var Ht = 2048;
1870
+ function Ut(t) {
1871
+ let n = t.autoscale;
1766
1872
  if (n !== void 0 && typeof n != "function") throw TypeError(`alphacharts: series option autoscale must be a function, got ${typeof n}`);
1767
- for (let [n, r] of Object.entries(e)) /color$/i.test(n) && r !== void 0 && t(r);
1873
+ for (let [n, r] of Object.entries(t)) /color$/i.test(n) && r !== void 0 && e(r);
1768
1874
  }
1769
- var zt = {
1875
+ var Wt = {
1770
1876
  id: "",
1771
1877
  priceScaleId: "right",
1772
1878
  pane: 0,
@@ -1776,7 +1882,7 @@ var zt = {
1776
1882
  lastValueVisible: !0,
1777
1883
  priceLineVisible: !0,
1778
1884
  title: ""
1779
- }, Bt = class {
1885
+ }, Gt = class {
1780
1886
  type;
1781
1887
  data;
1782
1888
  host;
@@ -1789,13 +1895,13 @@ var zt = {
1789
1895
  user;
1790
1896
  effective;
1791
1897
  constructor(e, t, n, r, i) {
1792
- this.type = e, this.data = t, this.host = n, this.def = Ft(e), Rt(r), this.user = { ...r }, this.effective = this.resolve(i), this.formatter = this.makeFormatter();
1898
+ this.type = e, this.data = t, this.host = n, this.def = Bt(e), Ut(r), this.user = { ...r }, this.effective = this.resolve(i), this.formatter = this.makeFormatter();
1793
1899
  }
1794
1900
  options() {
1795
1901
  return this.effective;
1796
1902
  }
1797
1903
  applyOptions(e) {
1798
- Rt(e);
1904
+ Ut(e);
1799
1905
  let t = this.effective;
1800
1906
  this.user = {
1801
1907
  ...this.user,
@@ -1811,6 +1917,12 @@ var zt = {
1811
1917
  update(e) {
1812
1918
  this.host.update(this, e);
1813
1919
  }
1920
+ setBarColors(e) {
1921
+ this.host.setColors(this, e);
1922
+ }
1923
+ clearBarColors() {
1924
+ this.host.clearColors(this);
1925
+ }
1814
1926
  barAt(e) {
1815
1927
  let t = this.host.indexOf(e);
1816
1928
  return t === void 0 ? void 0 : this.barAtIndex(t);
@@ -1838,7 +1950,7 @@ var zt = {
1838
1950
  };
1839
1951
  }
1840
1952
  setMarkers(e) {
1841
- this.markerList = tt(e, (e) => {
1953
+ this.markerList = at(e, (e) => {
1842
1954
  let t = this.host.indexOf(e);
1843
1955
  return t !== void 0 && this.data.has(t);
1844
1956
  }), this.host.markersChanged(this);
@@ -1868,19 +1980,19 @@ var zt = {
1868
1980
  2,
1869
1981
  3
1870
1982
  ] : [r], a = this.dataDecimals, o = (e, t) => {
1871
- for (let r = e; r < t; r++) if (n.has(r)) for (let e of i) a = Math.max(a, lt(n.get(r, e)));
1983
+ for (let r = e; r < t; r++) if (n.has(r)) for (let e of i) a = Math.max(a, pt(n.get(r, e)));
1872
1984
  };
1873
- t - e <= Lt * 2 ? o(e, t) : (o(e, e + Lt), o(t - Lt, t)), a !== this.dataDecimals && (this.dataDecimals = a, this.formatter = this.makeFormatter());
1985
+ t - e <= Ht * 2 ? o(e, t) : (o(e, e + Ht), o(t - Ht, t)), a !== this.dataDecimals && (this.dataDecimals = a, this.formatter = this.makeFormatter());
1874
1986
  }
1875
1987
  makeFormatter() {
1876
- return dt(this.effective.priceFormat, 10 ** -this.dataDecimals, this.host.locale);
1988
+ return ht(this.effective.priceFormat, 10 ** -this.dataDecimals, this.host.locale);
1877
1989
  }
1878
1990
  themeChanged(e) {
1879
1991
  this.effective = this.resolve(e);
1880
1992
  }
1881
1993
  resolve(e) {
1882
1994
  return {
1883
- ...zt,
1995
+ ...Wt,
1884
1996
  ...this.def.defaults(e),
1885
1997
  ...this.user
1886
1998
  };
@@ -1906,7 +2018,7 @@ var zt = {
1906
2018
  down: "#ef5350",
1907
2019
  accent: "#2962ff",
1908
2020
  extendedHours: "rgba(41,98,255,0.06)"
1909
- }, Vt = {
2021
+ }, Kt = {
1910
2022
  background: "#ffffff",
1911
2023
  text: "#131722",
1912
2024
  textMuted: "#5d606b",
@@ -1921,7 +2033,7 @@ var zt = {
1921
2033
  down: "#f23645",
1922
2034
  accent: "#2962ff",
1923
2035
  extendedHours: "rgba(41,98,255,0.05)"
1924
- }, Ht = {
2036
+ }, qt = {
1925
2037
  background: "#000000",
1926
2038
  text: "#ffffff",
1927
2039
  textMuted: "#ffffff",
@@ -1937,12 +2049,12 @@ var zt = {
1937
2049
  accent: "#4da3ff",
1938
2050
  extendedHours: "rgba(255,255,255,0.12)"
1939
2051
  };
1940
- function Ut() {
1941
- return typeof matchMedia > "u" ? K : matchMedia("(prefers-contrast: more)").matches ? Ht : matchMedia("(prefers-color-scheme: light)").matches ? Vt : K;
2052
+ function Jt() {
2053
+ return typeof matchMedia > "u" ? K : matchMedia("(prefers-contrast: more)").matches ? qt : matchMedia("(prefers-color-scheme: light)").matches ? Kt : K;
1942
2054
  }
1943
2055
  //#endregion
1944
2056
  //#region src/chart/messages.ts
1945
- var Wt = {
2057
+ var Yt = {
1946
2058
  "chart.ariaLabel": "Price chart",
1947
2059
  "chart.readout.ohlc": "{name} open {open} high {high} low {low} close {close}",
1948
2060
  "chart.readout.value": "{name} {value}",
@@ -1954,15 +2066,15 @@ var Wt = {
1954
2066
  "chart.table.value": "Value",
1955
2067
  "chart.table.caption": "{label}: {name}, visible bars, newest first",
1956
2068
  "chart.countdown.days": "{n}d"
1957
- }, Gt = (e, t = {}) => {
1958
- let n = Wt[e];
2069
+ }, Xt = (e, t = {}) => {
2070
+ let n = Yt[e];
1959
2071
  if (n === void 0) throw Error(`alphacharts: unknown chart message key "${e}"`);
1960
2072
  return n.replace(/\{(\w+)\}/g, (n, r) => {
1961
2073
  let i = t[r];
1962
2074
  if (i === void 0) throw Error(`alphacharts: chart message "${e}" needs a value for "${r}"`);
1963
2075
  return String(i);
1964
2076
  });
1965
- }, Kt = {
2077
+ }, Zt = {
1966
2078
  timeZone: "UTC",
1967
2079
  regular: ((e) => [
1968
2080
  e,
@@ -1974,7 +2086,7 @@ var Wt = {
1974
2086
  e
1975
2087
  ])([[0, 1440]])
1976
2088
  };
1977
- function qt(e, t, n, r) {
2089
+ function Qt(e, t, n, r) {
1978
2090
  let i = (e) => [
1979
2091
  [],
1980
2092
  e,
@@ -1991,7 +2103,7 @@ function qt(e, t, n, r) {
1991
2103
  ...r ? { holidays: r } : {}
1992
2104
  };
1993
2105
  }
1994
- var Jt = (e = []) => qt("Asia/Kolkata", [[555, 930]], [[540, 555]], e), Yt = (e = []) => qt("America/New_York", [[570, 960]], [[240, 570], [960, 1200]], e), q = class {
2106
+ var $t = (e = []) => Qt("Asia/Kolkata", [[555, 930]], [[540, 555]], e), en = (e = []) => Qt("America/New_York", [[570, 960]], [[240, 570], [960, 1200]], e), q = class {
1995
2107
  spec;
1996
2108
  tz;
1997
2109
  holidays;
@@ -2000,23 +2112,23 @@ var Jt = (e = []) => qt("Asia/Kolkata", [[555, 930]], [[540, 555]], e), Yt = (e
2000
2112
  if (e.extended && e.extended.length !== 7) throw RangeError("sessions: extended needs 7 weekdays (Sunday first)");
2001
2113
  for (let t of [...e.regular, ...e.extended ?? []]) for (let [e, n] of t) if (!(e >= 0 && n > e && n - e <= 1440)) throw RangeError(`sessions: bad window [${e}, ${n})`);
2002
2114
  for (let t of e.holidays ?? []) if (!/^\d{4}-\d{2}-\d{2}$/.test(t)) throw RangeError(`sessions: holiday "${t}" is not YYYY-MM-DD`);
2003
- this.tz = new S(e.timeZone), this.holidays = new Set(e.holidays ?? []);
2115
+ this.tz = new x(e.timeZone), this.holidays = new Set(e.holidays ?? []);
2004
2116
  }
2005
2117
  state(e) {
2006
2118
  let t = e + this.tz.offset(e);
2007
2119
  for (let e of [0, 1]) {
2008
- let n = Math.floor(t / x) - e;
2120
+ let n = Math.floor(t / b) - e;
2009
2121
  if (this.isHolidayDay(n)) continue;
2010
- let r = (t - n * x) / 6e4, i = Xt(n);
2011
- if (Zt(this.spec.regular[i], r)) return "regular";
2012
- if (this.spec.extended && Zt(this.spec.extended[i], r)) return "extended";
2122
+ let r = (t - n * b) / 6e4, i = tn(n);
2123
+ if (nn(this.spec.regular[i], r)) return "regular";
2124
+ if (this.spec.extended && nn(this.spec.extended[i], r)) return "extended";
2013
2125
  }
2014
2126
  return "closed";
2015
2127
  }
2016
2128
  sessionStart(e) {
2017
- let t = e + this.tz.offset(e), n = Math.floor(t / x);
2018
- for (let t = n - 1; t <= n + 14; t++) if (!this.isHolidayDay(t)) for (let [r, i] of this.spec.regular[Xt(t)]) {
2019
- let a = this.tz.fromLocal(t * x + r * 6e4);
2129
+ let t = e + this.tz.offset(e), n = Math.floor(t / b);
2130
+ for (let t = n - 1; t <= n + 14; t++) if (!this.isHolidayDay(t)) for (let [r, i] of this.spec.regular[tn(t)]) {
2131
+ let a = this.tz.fromLocal(t * b + r * 6e4);
2020
2132
  if (e < this.tz.fromLocal(t * 864e5 + i * 6e4) && (e >= a || t >= n)) return a;
2021
2133
  }
2022
2134
  throw RangeError("sessions: no regular session within two weeks (is every weekday closed?)");
@@ -2027,20 +2139,20 @@ var Jt = (e = []) => qt("Asia/Kolkata", [[555, 930]], [[540, 555]], e), Yt = (e
2027
2139
  }
2028
2140
  isHolidayDay(e) {
2029
2141
  if (this.holidays.size === 0) return !1;
2030
- let t = this.tz.civil(this.tz.fromLocal(e * x + 432e5));
2142
+ let t = this.tz.civil(this.tz.fromLocal(e * b + 432e5));
2031
2143
  return this.holidays.has(`${t.year}-${String(t.month).padStart(2, "0")}-${String(t.day).padStart(2, "0")}`);
2032
2144
  }
2033
2145
  };
2034
- function Xt(e) {
2146
+ function tn(e) {
2035
2147
  return ((e + 4) % 7 + 7) % 7;
2036
2148
  }
2037
- function Zt(e, t) {
2149
+ function nn(e, t) {
2038
2150
  for (let [n, r] of e) if (t >= n && t < r) return !0;
2039
2151
  return !1;
2040
2152
  }
2041
2153
  //#endregion
2042
2154
  //#region src/data/resample.ts
2043
- function Qt(e) {
2155
+ function rn(e) {
2044
2156
  let t = /^(\d+)?([smhDWM])?$/.exec(e.trim());
2045
2157
  if (!t || !t[1] && !t[2]) throw RangeError(`resolution "${e}": expected e.g. 30s, 5m, 4h, 1D, 1W, 3M`);
2046
2158
  let n = t[1] ? Number(t[1]) : 1;
@@ -2050,11 +2162,11 @@ function Qt(e) {
2050
2162
  n
2051
2163
  };
2052
2164
  }
2053
- var $t = {
2165
+ var an = {
2054
2166
  s: 1e3,
2055
2167
  m: 6e4,
2056
2168
  h: 36e5
2057
- }, en = class e {
2169
+ }, on = class e {
2058
2170
  res;
2059
2171
  tz;
2060
2172
  sessions;
@@ -2063,23 +2175,23 @@ var $t = {
2063
2175
  bucket = NaN;
2064
2176
  constructor(e, t = {}) {
2065
2177
  if (this.res = e, !(e.n >= 1) || !Number.isInteger(e.n)) throw RangeError(`resolution count must be a positive integer, got ${e.n}`);
2066
- this.sessions = t.sessions ? new q(t.sessions) : null, this.tz = this.sessions ? this.sessions.tz : new S(t.timeZone ?? "UTC");
2178
+ this.sessions = t.sessions ? new q(t.sessions) : null, this.tz = this.sessions ? this.sessions.tz : new x(t.timeZone ?? "UTC");
2067
2179
  }
2068
2180
  bucketStart(e) {
2069
2181
  let { unit: t, n } = this.res, r = this.tz;
2070
2182
  if (t === "s" || t === "m" || t === "h") {
2071
- let i = $t[t] * n, a = this.sessions ? this.sessions.sessionStart(e) : r.fromLocal(Math.floor((e + r.offset(e)) / x) * x);
2183
+ let i = an[t] * n, a = this.sessions ? this.sessions.sessionStart(e) : r.fromLocal(Math.floor((e + r.offset(e)) / b) * b);
2072
2184
  return a + Math.floor((e - a) / i) * i;
2073
2185
  }
2074
2186
  let i = e + r.offset(e);
2075
2187
  if (t === "D") {
2076
2188
  if (this.sessions && n === 1) return this.sessions.sessionStart(e);
2077
- let t = Math.floor(i / x);
2078
- return r.fromLocal(Math.floor(t / n) * n * x);
2189
+ let t = Math.floor(i / b);
2190
+ return r.fromLocal(Math.floor(t / n) * n * b);
2079
2191
  }
2080
2192
  if (t === "W") {
2081
- let e = Math.floor(i / x), t = Math.floor((e - 4) / 7);
2082
- return r.fromLocal((4 + Math.floor(t / n) * n * 7) * x);
2193
+ let e = Math.floor(i / b), t = Math.floor((e - 4) / 7);
2194
+ return r.fromLocal((4 + Math.floor(t / n) * n * 7) * b);
2083
2195
  }
2084
2196
  let a = r.civil(e), o = Math.floor((a.year * 12 + (a.month - 1)) / n) * n;
2085
2197
  return r.fromLocal(Date.UTC(Math.floor(o / 12), o % 12, 1));
@@ -2095,12 +2207,12 @@ var $t = {
2095
2207
  };
2096
2208
  if (this.last && e.time < this.last.time) throw RangeError(`resample: source time ${e.time} is before the previous ${this.last.time}`);
2097
2209
  let n = this.bucketStart(e.time);
2098
- return n === this.bucket ? (this.last && this.last.time === e.time || (this.base = this.base ? tn(this.base, this.last.bar) : this.last.bar), this.last = {
2210
+ return n === this.bucket ? (this.last && this.last.time === e.time || (this.base = this.base ? sn(this.base, this.last.bar) : this.last.bar), this.last = {
2099
2211
  time: e.time,
2100
2212
  bar: t
2101
2213
  }, {
2102
2214
  bar: {
2103
- ...this.base ? tn(this.base, t) : t,
2215
+ ...this.base ? sn(this.base, t) : t,
2104
2216
  time: n
2105
2217
  },
2106
2218
  replaced: !0
@@ -2131,7 +2243,7 @@ var $t = {
2131
2243
  return a;
2132
2244
  }
2133
2245
  };
2134
- function tn(e, t) {
2246
+ function sn(e, t) {
2135
2247
  return {
2136
2248
  time: e.time,
2137
2249
  open: e.open,
@@ -2143,7 +2255,7 @@ function tn(e, t) {
2143
2255
  }
2144
2256
  //#endregion
2145
2257
  //#region src/chart/watermark.ts
2146
- var nn = {
2258
+ var cn = {
2147
2259
  visible: !0,
2148
2260
  opacity: 1
2149
2261
  };
@@ -2151,16 +2263,16 @@ function J(e) {
2151
2263
  if (typeof e.visible != "boolean") throw TypeError(`alphacharts: watermark.visible must be a boolean, got ${String(e.visible)}`);
2152
2264
  if (!(e.opacity >= 0 && e.opacity <= 1)) throw RangeError(`alphacharts: watermark.opacity must be between 0 and 1, got ${String(e.opacity)}`);
2153
2265
  }
2154
- var rn = "M4405 7778 c-217 -11 -387 -42 -589 -109 -702 -233 -1309 -862 -1563 -1619 -85 -253 -124 -451 -148 -755 -18 -227 -18 -329 0 -531 30 -337 82 -568 190 -849 144 -372 337 -670 614 -945 354 -351 734 -551 1231 -649 209 -41 591 -41 800 0 267 52 453 119 660 237 306 175 558 411 729 685 33 51 48 67 66 67 18 0 25 -8 35 -47 70 -268 197 -492 353 -624 102 -85 277 -168 452 -214 151 -40 248 -49 500 -49 254 0 342 9 450 47 l40 14 3 417 c1 288 -1 416 -8 416 -6 0 -23 -6 -38 -14 -15 -7 -70 -28 -122 -46 -80 -28 -113 -34 -213 -38 -212 -8 -343 32 -454 141 -86 83 -139 201 -174 382 -18 96 -19 169 -19 2012 l0 1913 -415 0 -415 0 0 -380 c0 -447 4 -436 -100 -288 -134 191 -398 428 -606 544 -27 15 -63 35 -80 44 -44 26 -208 95 -289 123 -280 97 -554 132 -890 115z m485 -789 c412 -60 800 -291 1064 -634 189 -244 314 -515 371 -800 38 -191 40 -223 40 -520 0 -297 -3 -332 -41 -520 -137 -681 -658 -1252 -1279 -1402 -243 -58 -527 -58 -770 0 -586 141 -1091 664 -1254 1297 -58 227 -74 368 -74 630 0 478 97 835 320 1179 243 375 598 635 1012 741 169 44 425 56 611 29z", an = 560, on = 20, sn = 12, cn = 10, ln = 3.5, un = 160, dn = 120, fn;
2155
- function pn(e, t, n, r, i) {
2156
- if (!i.visible || i.opacity === 0 || t < un || n < dn) return;
2157
- fn ??= new Path2D(rn);
2158
- let a = on / an;
2159
- e.save(), e.globalAlpha = i.opacity, e.translate(sn, n - cn - on), e.scale(a, a), e.translate(-200, -240), e.translate(0, 1024), e.scale(.1, -.1), e.lineJoin = "round", e.lineWidth = ln / (a * .1), e.strokeStyle = r.background, e.stroke(fn), e.fillStyle = r.text, e.fill(fn), e.restore();
2266
+ var ln = "M4405 7778 c-217 -11 -387 -42 -589 -109 -702 -233 -1309 -862 -1563 -1619 -85 -253 -124 -451 -148 -755 -18 -227 -18 -329 0 -531 30 -337 82 -568 190 -849 144 -372 337 -670 614 -945 354 -351 734 -551 1231 -649 209 -41 591 -41 800 0 267 52 453 119 660 237 306 175 558 411 729 685 33 51 48 67 66 67 18 0 25 -8 35 -47 70 -268 197 -492 353 -624 102 -85 277 -168 452 -214 151 -40 248 -49 500 -49 254 0 342 9 450 47 l40 14 3 417 c1 288 -1 416 -8 416 -6 0 -23 -6 -38 -14 -15 -7 -70 -28 -122 -46 -80 -28 -113 -34 -213 -38 -212 -8 -343 32 -454 141 -86 83 -139 201 -174 382 -18 96 -19 169 -19 2012 l0 1913 -415 0 -415 0 0 -380 c0 -447 4 -436 -100 -288 -134 191 -398 428 -606 544 -27 15 -63 35 -80 44 -44 26 -208 95 -289 123 -280 97 -554 132 -890 115z m485 -789 c412 -60 800 -291 1064 -634 189 -244 314 -515 371 -800 38 -191 40 -223 40 -520 0 -297 -3 -332 -41 -520 -137 -681 -658 -1252 -1279 -1402 -243 -58 -527 -58 -770 0 -586 141 -1091 664 -1254 1297 -58 227 -74 368 -74 630 0 478 97 835 320 1179 243 375 598 635 1012 741 169 44 425 56 611 29z", un = 560, dn = 20, fn = 12, pn = 10, mn = 3.5, hn = 160, gn = 120, _n;
2267
+ function vn(e, t, n, r, i) {
2268
+ if (!i.visible || i.opacity === 0 || t < hn || n < gn) return;
2269
+ _n ??= new Path2D(ln);
2270
+ let a = dn / un;
2271
+ e.save(), e.globalAlpha = i.opacity, e.translate(fn, n - pn - dn), e.scale(a, a), e.translate(-200, -240), e.translate(0, 1024), e.scale(.1, -.1), e.lineJoin = "round", e.lineWidth = mn / (a * .1), e.strokeStyle = r.background, e.stroke(_n), e.fillStyle = r.text, e.fill(_n), e.restore();
2160
2272
  }
2161
2273
  //#endregion
2162
2274
  //#region src/chart/chart.ts
2163
- var mn = {
2275
+ var yn = {
2164
2276
  panLeft: ["ArrowLeft"],
2165
2277
  panRight: ["ArrowRight"],
2166
2278
  zoomIn: [
@@ -2180,28 +2292,28 @@ var mn = {
2180
2292
  crosshairRight: ["Shift+ArrowRight"],
2181
2293
  hideCrosshair: ["Escape"],
2182
2294
  resetChart: ["Alt+R", "Alt+r"]
2183
- }, Y = 1, X = 6, hn = 48;
2184
- function gn(e, n) {
2185
- if (e === void 0) return n;
2186
- if (e === "dark") return K;
2187
- if (e === "light") return Vt;
2188
- if (e === "high-contrast") return Ht;
2189
- if (e === "auto") return Ut();
2295
+ }, Y = 1, X = 6, bn = 48;
2296
+ function xn(t, n) {
2297
+ if (t === void 0) return n;
2298
+ if (t === "dark") return K;
2299
+ if (t === "light") return Kt;
2300
+ if (t === "high-contrast") return qt;
2301
+ if (t === "auto") return Jt();
2190
2302
  let r = {
2191
2303
  ...n,
2192
- ...e
2304
+ ...t
2193
2305
  };
2194
- for (let e of Object.keys(r)) e !== "fontFamily" && e !== "fontSize" && t(r[e]);
2306
+ for (let t of Object.keys(r)) t !== "fontFamily" && t !== "fontSize" && e(r[t]);
2195
2307
  return r;
2196
2308
  }
2197
- var _n = class {
2309
+ var Sn = class {
2198
2310
  element;
2199
2311
  live;
2200
2312
  layers;
2201
- model = new d();
2313
+ model = new u();
2202
2314
  time;
2203
2315
  panes = [];
2204
- events = new Ye();
2316
+ events = new Ze();
2205
2317
  primitives = /* @__PURE__ */ new Map();
2206
2318
  plugins = /* @__PURE__ */ new Map();
2207
2319
  pluginInitial = /* @__PURE__ */ new Map();
@@ -2255,74 +2367,81 @@ var _n = class {
2255
2367
  syncIndex = null;
2256
2368
  crosshairSource = "pointer";
2257
2369
  lastAnnounce = 0;
2258
- constructor(e, t = {}, n) {
2259
- this.opts = {
2260
- theme: gn(t.theme, K),
2261
- timeZone: t.timeZone ?? "UTC",
2262
- locale: t.locale,
2263
- timeScale: {
2264
- ...ze,
2265
- ...t.timeScale
2266
- },
2267
- crosshair: {
2268
- mode: "magnet",
2269
- visible: !0,
2270
- priceLabel: !0,
2271
- ...t.crosshair
2272
- },
2273
- grid: {
2274
- vertLines: !0,
2275
- horzLines: !0,
2276
- ...t.grid
2277
- },
2278
- timeFormat: t.timeFormat,
2279
- timeVisible: t.timeVisible ?? "auto",
2280
- timeLabel: t.timeLabel,
2281
- rightPriceScale: {
2282
- ...we,
2283
- ...t.rightPriceScale,
2284
- position: "right"
2285
- },
2286
- leftPriceScale: {
2287
- ...we,
2288
- ...t.leftPriceScale,
2289
- position: "left"
2290
- },
2291
- interaction: {
2292
- pan: !0,
2293
- zoom: !0,
2294
- kinetic: !0,
2295
- keyboard: !0,
2296
- ...t.interaction
2297
- },
2298
- watermark: {
2299
- ...nn,
2300
- ...t.watermark
2301
- },
2302
- messages: t.messages ?? Gt,
2303
- ariaLabel: t.ariaLabel ?? (t.messages ?? Gt)("chart.ariaLabel"),
2304
- renderer: t.renderer ?? "auto",
2305
- sessions: t.sessions ?? null,
2306
- resolution: t.resolution ?? null,
2307
- countdown: t.countdown ?? !0,
2308
- keymap: {
2309
- ...mn,
2310
- ...t.keymap
2311
- },
2312
- a11yTable: t.a11yTable ?? !0
2313
- }, this.ariaLabelFixed = t.ariaLabel !== void 0, this.autoTheme = t.theme === "auto", this.sessions = this.opts.sessions ? new q(this.opts.sessions) : null, this.resampler = this.opts.resolution ? new en(Qt(this.opts.resolution), this.opts.sessions ? { sessions: this.opts.sessions } : { timeZone: this.opts.timeZone }) : null, D(this.opts.rightPriceScale), D(this.opts.leftPriceScale), J(this.opts.watermark), this.tz = new S(this.opts.timeZone), this.fmt = new Re(this.opts.locale, this.tz, this.opts.timeFormat), this.time = new Be(this.opts.timeScale);
2314
- let r = document.createElement("div");
2315
- r.style.cssText = "position:relative;width:100%;height:100%;overflow:hidden;user-select:none;-webkit-user-select:none;touch-action:none;outline:none", r.tabIndex = 0, r.setAttribute("role", "application"), r.setAttribute("aria-roledescription", "chart"), r.setAttribute("aria-label", this.opts.ariaLabel), this.live = document.createElement("div"), this.live.setAttribute("aria-live", "polite"), this.live.style.cssText = "position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap", r.appendChild(this.live), e.appendChild(r), this.element = r;
2316
- let i = {
2317
- lost: () => this.dropRenderers(),
2318
- restored: () => this.invalidate(7)
2319
- };
2320
- this.layers = n ? n(r, i) : new me(r, this.opts.renderer, i), this.model.onChange(this.onData), this.interaction = new Je(this, r, r), this.resizeObs = new ResizeObserver(() => this.measure()), this.resizeObs.observe(r), this.watchDpr(), this.watchSystem(), this.syncCountdown(), this.measure();
2370
+ constructor(e, t = {}, r) {
2371
+ try {
2372
+ this.opts = {
2373
+ theme: xn(t.theme, K),
2374
+ timeZone: t.timeZone ?? "UTC",
2375
+ locale: t.locale,
2376
+ timeScale: {
2377
+ ...Ve,
2378
+ ...t.timeScale
2379
+ },
2380
+ crosshair: {
2381
+ mode: "magnet",
2382
+ visible: !0,
2383
+ priceLabel: !0,
2384
+ ...t.crosshair
2385
+ },
2386
+ grid: {
2387
+ vertLines: !0,
2388
+ horzLines: !0,
2389
+ ...t.grid
2390
+ },
2391
+ timeFormat: t.timeFormat,
2392
+ timeVisible: t.timeVisible ?? "auto",
2393
+ timeLabel: t.timeLabel,
2394
+ rightPriceScale: {
2395
+ ...Ee,
2396
+ ...t.rightPriceScale,
2397
+ position: "right"
2398
+ },
2399
+ leftPriceScale: {
2400
+ ...Ee,
2401
+ ...t.leftPriceScale,
2402
+ position: "left"
2403
+ },
2404
+ interaction: {
2405
+ pan: !0,
2406
+ zoom: !0,
2407
+ kinetic: !0,
2408
+ keyboard: !0,
2409
+ ...t.interaction
2410
+ },
2411
+ watermark: {
2412
+ ...cn,
2413
+ ...t.watermark
2414
+ },
2415
+ messages: t.messages ?? Xt,
2416
+ ariaLabel: t.ariaLabel ?? (t.messages ?? Xt)("chart.ariaLabel"),
2417
+ renderer: t.renderer ?? "auto",
2418
+ sessions: t.sessions ?? null,
2419
+ resolution: t.resolution ?? null,
2420
+ countdown: t.countdown ?? !0,
2421
+ keymap: {
2422
+ ...yn,
2423
+ ...t.keymap
2424
+ },
2425
+ a11yTable: t.a11yTable ?? !0
2426
+ }, this.ariaLabelFixed = t.ariaLabel !== void 0, this.autoTheme = t.theme === "auto", this.sessions = this.opts.sessions ? new q(this.opts.sessions) : null, this.resampler = this.opts.resolution ? new on(rn(this.opts.resolution), this.opts.sessions ? { sessions: this.opts.sessions } : { timeZone: this.opts.timeZone }) : null, D(this.opts.rightPriceScale), D(this.opts.leftPriceScale), J(this.opts.watermark), this.tz = new x(this.opts.timeZone), this.fmt = new Be(this.opts.locale, this.tz, this.opts.timeFormat), this.time = new He(this.opts.timeScale);
2427
+ let n = document.createElement("div");
2428
+ n.style.cssText = "position:relative;width:100%;height:100%;overflow:hidden;user-select:none;-webkit-user-select:none;touch-action:none;outline:none", n.tabIndex = 0, n.setAttribute("role", "application"), n.setAttribute("aria-roledescription", "chart"), n.setAttribute("aria-label", this.opts.ariaLabel), this.live = document.createElement("div"), this.live.setAttribute("aria-live", "polite"), this.live.style.cssText = "position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap", n.appendChild(this.live), e.appendChild(n), this.element = n;
2429
+ let i = {
2430
+ lost: () => this.dropRenderers(),
2431
+ restored: () => this.invalidate(7)
2432
+ };
2433
+ this.layers = r ? r(n, i) : new _e(n, this.opts.renderer, i), this.model.onChange(this.onData), this.interaction = new Xe(this, n, n), this.resizeObs = new ResizeObserver(() => this.measure()), this.resizeObs.observe(n), this.watchDpr(), this.watchSystem(), this.syncCountdown(), this.measure();
2434
+ } catch (e) {
2435
+ throw n({
2436
+ source: "ctor",
2437
+ error: e
2438
+ }), e;
2439
+ }
2321
2440
  }
2322
2441
  addSeries(e, t = {}) {
2323
2442
  let n = t.id || this.nextSeriesId();
2324
2443
  if (this.allSeries().some((e) => e.options().id === n)) throw Error(`alphacharts: a series with id "${n}" already exists`);
2325
- let r = new Bt(e, this.model.add(Ft(e).shape), this, {
2444
+ let r = new Gt(e, this.model.add(Bt(e).shape), this, {
2326
2445
  ...t,
2327
2446
  id: n
2328
2447
  }, this.opts.theme);
@@ -2341,7 +2460,7 @@ var _n = class {
2341
2460
  this.primitives.delete(t), t.renderer?.dispose(), t.renderer = null, t.renderer2d?.dispose(), t.renderer2d = null, this.model.remove(t.data), this.prunePanes(), this.invalidate(7);
2342
2461
  }
2343
2462
  createPriceLine(e, t) {
2344
- let n = new Qe({
2463
+ let n = new et({
2345
2464
  labelTextColor: this.opts.theme.labelText,
2346
2465
  ...t
2347
2466
  });
@@ -2357,14 +2476,14 @@ var _n = class {
2357
2476
  return this.removed;
2358
2477
  }
2359
2478
  applyOptions(e) {
2360
- let t = this.opts, n = e.timeZone === void 0 ? this.tz : new S(e.timeZone), r = gn(e.theme, t.theme);
2479
+ let t = this.opts, n = e.timeZone === void 0 ? this.tz : new x(e.timeZone), r = xn(e.theme, t.theme);
2361
2480
  e.rightPriceScale && D(e.rightPriceScale), e.leftPriceScale && D(e.leftPriceScale);
2362
2481
  let i = {
2363
2482
  ...t.watermark,
2364
2483
  ...e.watermark
2365
2484
  };
2366
2485
  J(i);
2367
- let a = e.timeZone !== void 0 || e.locale !== void 0 || "timeFormat" in e, o = a ? new Re("locale" in e ? e.locale : t.locale, n, "timeFormat" in e ? e.timeFormat : t.timeFormat) : this.fmt;
2486
+ let a = e.timeZone !== void 0 || e.locale !== void 0 || "timeFormat" in e, o = a ? new Be("locale" in e ? e.locale : t.locale, n, "timeFormat" in e ? e.timeFormat : t.timeFormat) : this.fmt;
2368
2487
  if (this.opts = {
2369
2488
  ...t,
2370
2489
  ...e,
@@ -2399,7 +2518,7 @@ var _n = class {
2399
2518
  }, Object.assign(this.time.options, this.opts.timeScale), e.keymap && (this.opts.keymap = {
2400
2519
  ...t.keymap,
2401
2520
  ...e.keymap
2402
- }), e.theme !== void 0 && (this.autoTheme = e.theme === "auto"), e.sessions !== void 0 && (this.sessions = e.sessions ? new q(e.sessions) : null), (e.resolution !== void 0 || e.sessions !== void 0 || e.timeZone !== void 0) && (this.resampler = this.opts.resolution ? new en(Qt(this.opts.resolution), this.opts.sessions ? { sessions: this.opts.sessions } : { timeZone: this.opts.timeZone }) : null), this.syncCountdown(), a && (this.tz = n, this.fmt = o, this.tticksKey = ""), e.rightPriceScale && "minWidth" in e.rightPriceScale && (this.axisCols.right = []), e.leftPriceScale && "minWidth" in e.leftPriceScale && (this.axisCols.left = []), e.theme !== void 0) for (let e of this.panes) for (let t of e.series) t.themeChanged(this.opts.theme);
2521
+ }), e.theme !== void 0 && (this.autoTheme = e.theme === "auto"), e.sessions !== void 0 && (this.sessions = e.sessions ? new q(e.sessions) : null), (e.resolution !== void 0 || e.sessions !== void 0 || e.timeZone !== void 0) && (this.resampler = this.opts.resolution ? new on(rn(this.opts.resolution), this.opts.sessions ? { sessions: this.opts.sessions } : { timeZone: this.opts.timeZone }) : null), this.syncCountdown(), a && (this.tz = n, this.fmt = o, this.tticksKey = ""), e.rightPriceScale && "minWidth" in e.rightPriceScale && (this.axisCols.right = []), e.leftPriceScale && "minWidth" in e.leftPriceScale && (this.axisCols.left = []), e.theme !== void 0) for (let e of this.panes) for (let t of e.series) t.themeChanged(this.opts.theme);
2403
2522
  for (let t of this.panes) for (let [n, r] of t.scales) n === "right" && e.rightPriceScale && (r.options = { ...this.opts.rightPriceScale }), n === "left" && e.leftPriceScale && (r.options = { ...this.opts.leftPriceScale });
2404
2523
  e.ariaLabel !== void 0 && (this.ariaLabelFixed = !0), this.ariaLabelFixed || (this.opts.ariaLabel = this.opts.messages("chart.ariaLabel")), this.element.setAttribute("aria-label", this.opts.ariaLabel), (e.messages !== void 0 || e.locale !== void 0 || e.ariaLabel !== void 0 || e.timeZone !== void 0) && this.scheduleTable(), this.invalidate(7);
2405
2524
  }
@@ -2467,7 +2586,7 @@ var _n = class {
2467
2586
  }
2468
2587
  this.plugins.delete(t);
2469
2588
  }
2470
- this.pluginInitial.clear(), Ue(this), this.interaction.dispose(), this.resizeObs.disconnect(), this.dprQuery?.removeEventListener("change", this.onDpr);
2589
+ this.pluginInitial.clear(), Ge(this), this.interaction.dispose(), this.resizeObs.disconnect(), this.dprQuery?.removeEventListener("change", this.onDpr);
2471
2590
  for (let e of this.mediaQueries) e.removeEventListener("change", this.onSystem);
2472
2591
  clearInterval(this.countdownTimer), clearTimeout(this.tableTimer);
2473
2592
  for (let e of this.panes) for (let t of e.series) t.renderer?.dispose();
@@ -2491,11 +2610,11 @@ var _n = class {
2491
2610
  for (let [t, n] of this.plugins) n.toJSON && (e[t] = n.toJSON());
2492
2611
  return {
2493
2612
  version: 1,
2494
- options: Ce({ ...this.opts }),
2613
+ options: E({ ...this.opts }),
2495
2614
  panes: this.panes.map((e) => ({
2496
2615
  stretch: e.stretch,
2497
- scales: Object.fromEntries([...e.scales].map(([e, t]) => [e, t.options.autoScale ? { options: Ce(t.options) } : {
2498
- options: Ce(t.options),
2616
+ scales: Object.fromEntries([...e.scales].map(([e, t]) => [e, t.options.autoScale ? { options: E(t.options) } : {
2617
+ options: E(t.options),
2499
2618
  range: {
2500
2619
  min: t.min,
2501
2620
  max: t.max
@@ -2505,7 +2624,7 @@ var _n = class {
2505
2624
  series: this.allSeries().map((e) => ({
2506
2625
  id: e.options().id,
2507
2626
  type: e.type,
2508
- options: Ce(e.options())
2627
+ options: E(e.options())
2509
2628
  })),
2510
2629
  view: {
2511
2630
  spacing: this.time.spacing,
@@ -2516,15 +2635,15 @@ var _n = class {
2516
2635
  };
2517
2636
  }
2518
2637
  restoreState(e, t = {}) {
2519
- let n = be(e);
2520
- ve(n, { timeLabel: t.timeLabel });
2638
+ let n = Ce(e);
2639
+ xe(n, { timeLabel: t.timeLabel });
2521
2640
  let r = Object.keys(n.plugins).filter((e) => !this.plugins.has(e));
2522
2641
  if (r.length) throw Error(`alphacharts: layout needs plugins that are not installed: ${r.join(", ")}`);
2523
2642
  for (let e of n.series) if ((e.options.priceFormat ?? {}).type === "custom" && !t.formatters?.[e.id]) throw Error(`alphacharts: series "${e.id}" has a custom price format; pass its formatter to restoreState`);
2524
2643
  let i = n.series.map((e) => e.id);
2525
2644
  for (let [e, t] of Object.entries(n.plugins)) this.plugins.get(e).validateState?.(t, { seriesIds: i });
2526
2645
  let a = n.options;
2527
- new Re(a.locale ?? this.opts.locale, new S(a.timeZone ?? this.opts.timeZone), a.timeFormat), D(a.rightPriceScale ?? {}), D(a.leftPriceScale ?? {}), J({
2646
+ new Be(a.locale ?? this.opts.locale, new x(a.timeZone ?? this.opts.timeZone), a.timeFormat), D(a.rightPriceScale ?? {}), D(a.leftPriceScale ?? {}), J({
2528
2647
  ...this.opts.watermark,
2529
2648
  ...n.options.watermark
2530
2649
  });
@@ -2681,6 +2800,12 @@ var _n = class {
2681
2800
  update(e, t) {
2682
2801
  this.model.update(e.data, t);
2683
2802
  }
2803
+ setColors(e, t) {
2804
+ this.model.setColors(e.data, t);
2805
+ }
2806
+ clearColors(e) {
2807
+ this.model.clearColors(e.data);
2808
+ }
2684
2809
  optionsChanged(e, t) {
2685
2810
  if (t) {
2686
2811
  for (let t of this.panes) {
@@ -2831,9 +2956,14 @@ var _n = class {
2831
2956
  };
2832
2957
  }
2833
2958
  invalidate(e) {
2834
- this.removed || He(this, e);
2959
+ this.removed || We(this, e);
2835
2960
  }
2836
2961
  onData = (e) => {
2962
+ if (e.kind === "color") {
2963
+ for (let t of this.panes) for (let n of t.series) n.renderer?.dataChanged(e), n.renderer2d?.dataChanged(e);
2964
+ this.invalidate(2);
2965
+ return;
2966
+ }
2837
2967
  let t = this.time, n = this.model.timeline, r = t.end <= t.first;
2838
2968
  e.kind === "update" && e.appended && !r && (t.following || --t.rightOffset), t.first = n.first, t.end = n.end, r && n.length > 0 && t.reset();
2839
2969
  for (let t of this.panes) for (let n of t.series) n.renderer?.dataChanged(e), n.renderer2d?.dataChanged(e), n.data === e.series && n.observeData(e.lo, e.hi);
@@ -2854,10 +2984,10 @@ var _n = class {
2854
2984
  let n = this.panes[t.pane];
2855
2985
  if (!n.scales.has(t.priceScaleId)) {
2856
2986
  let e = t.priceScaleId === "left" ? this.opts.leftPriceScale : t.priceScaleId === "right" ? this.opts.rightPriceScale : {
2857
- ...we,
2987
+ ...Ee,
2858
2988
  position: "none"
2859
2989
  };
2860
- n.scales.set(t.priceScaleId, new Te(t.priceScaleId, { ...e }));
2990
+ n.scales.set(t.priceScaleId, new De(t.priceScaleId, { ...e }));
2861
2991
  }
2862
2992
  n.series.push(e);
2863
2993
  }
@@ -2885,7 +3015,7 @@ var _n = class {
2885
3015
  if (r !== this.tticksKey) {
2886
3016
  this.tticksKey = r;
2887
3017
  let n = this.measureText("00:00:00") + 24;
2888
- this.tticks = Fe(this.model.timeline, this.tz, this.vis.lo, this.vis.hi, (e) => t.x(e), t.spacing, n), e |= 1;
3018
+ this.tticks = Le(this.model.timeline, this.tz, this.vis.lo, this.vis.hi, (e) => t.x(e), t.spacing, n), e |= 1;
2889
3019
  }
2890
3020
  if (t.left !== this.lastRange.from || t.right !== this.lastRange.to) {
2891
3021
  this.lastRange = {
@@ -2920,7 +3050,7 @@ var _n = class {
2920
3050
  let a = NaN, c = NaN;
2921
3051
  if (r >= n) t.def.autoscale(t.data, e, n, r, this.minmax), a = this.minmax[0], c = this.minmax[1];
2922
3052
  else if (!e.autoscale) continue;
2923
- e.autoscale && ([a, c] = vn(e.id, e.autoscale, a, c)), a < o && (o = a), c > s && (s = c);
3053
+ e.autoscale && ([a, c] = Cn(e.id, e.autoscale, a, c)), a < o && (o = a), c > s && (s = c);
2924
3054
  }
2925
3055
  if (o === Infinity) continue;
2926
3056
  let c = a.min, l = a.max;
@@ -2946,7 +3076,7 @@ var _n = class {
2946
3076
  right: []
2947
3077
  }, t = this.opts.theme.fontSize * 3.2;
2948
3078
  for (let n of this.panes) for (let r of ["left", "right"]) $(n, r).forEach((i, a) => {
2949
- i.ticks = Ae(i, this.formatterFor(n, i.id), t);
3079
+ i.ticks = Me(i, this.formatterFor(n, i.id), t);
2950
3080
  let o = 0;
2951
3081
  for (let e of i.ticks) o = Math.max(o, this.measureText(e.label));
2952
3082
  for (let e of n.series) {
@@ -2955,7 +3085,7 @@ var _n = class {
2955
3085
  let n = e.data.lastIndex(), r = n === void 0 ? void 0 : e.def.valueAt(e.data, t, n);
2956
3086
  r && (o = Math.max(o, this.measureText(O(i, e.formatter, r.value))));
2957
3087
  }
2958
- e[r][a] = Math.max(e[r][a] ?? 0, hn, i.options.minWidth ?? 0, Math.ceil(o + 12 + 4));
3088
+ e[r][a] = Math.max(e[r][a] ?? 0, bn, i.options.minWidth ?? 0, Math.ceil(o + 12 + 4));
2959
3089
  });
2960
3090
  let n = (e, t) => e === void 0 || t > e || t < e - 12 ? t : e;
2961
3091
  for (let t of ["left", "right"]) this.axisCols[t] = e[t].map((e, r) => n(this.axisCols[t][r], e));
@@ -3031,7 +3161,7 @@ var _n = class {
3031
3161
  if (r < a + 4 || r > a + o - 4) continue;
3032
3162
  e.fillStyle = n.weight >= 18 ? t.text : t.textMuted;
3033
3163
  let i = l.timeAt(n.index);
3034
- e.fillText(Le(this.opts.timeLabel, "tick", i, () => this.fmt.tick(i, n.weight)), r, c + this.timeH / 2);
3164
+ e.fillText(ze(this.opts.timeLabel, "tick", i, () => this.fmt.tick(i, n.weight)), r, c + this.timeH / 2);
3035
3165
  }
3036
3166
  e.restore();
3037
3167
  }
@@ -3099,7 +3229,7 @@ var _n = class {
3099
3229
  e.save(), e.setTransform(1, 0, 0, 1, 0, 0), e.beginPath(), e.rect(r, i, this.devW, this.devH), e.clip(), e.clearRect(r, i, this.devW, this.devH), e.font = this.font();
3100
3230
  let a = this.leftW, o = this.time.width, s = [], c;
3101
3231
  for (let l of this.panes) {
3102
- e.save(), e.setTransform(n, 0, 0, n, r + a * n, i + l.top * n), e.beginPath(), e.rect(0, 0, o, l.height), e.clip(), e.font = this.font(), l === this.panes[0] && pn(e, o, l.height, t, this.opts.watermark);
3232
+ e.save(), e.setTransform(n, 0, 0, n, r + a * n, i + l.top * n), e.beginPath(), e.rect(0, 0, o, l.height), e.clip(), e.font = this.font(), l === this.panes[0] && vn(e, o, l.height, t, this.opts.watermark);
3103
3233
  for (let t of l.series) {
3104
3234
  let r = t.options(), i = l.scales.get(r.priceScaleId);
3105
3235
  if (!r.visible || !i) continue;
@@ -3116,11 +3246,11 @@ var _n = class {
3116
3246
  price: u.value,
3117
3247
  text: O(i, t.formatter, u.value),
3118
3248
  background: u.color,
3119
- color: yn(u.color)
3249
+ color: wn(u.color)
3120
3250
  }
3121
3251
  }), r.title && this.drawTitleTag(e, r.title, i, u, l.height, o), !c && l === this.panes[0] && t === this.mainSeries(l, i.id) && (c = s[s.length - 1]));
3122
3252
  }
3123
- t.markers().length > 0 && st(e, this.markerLayout(l, t, i));
3253
+ t.markers().length > 0 && dt(e, this.markerLayout(l, t, i));
3124
3254
  let d = this.primitives.get(t);
3125
3255
  if (d && d.size > 0) {
3126
3256
  let n = this.paneView(l, t);
@@ -3165,7 +3295,7 @@ var _n = class {
3165
3295
  });
3166
3296
  }
3167
3297
  if (c) {
3168
- let n = this.model.timeline.timeAt(u), r = Le(this.opts.timeLabel, "crosshair", n, () => this.fmt.crosshair(n, this.timeVisible())), i = this.measureText(r) + 16, s = Math.max(a, Math.min(a + o - i, d - i / 2));
3298
+ let n = this.model.timeline.timeAt(u), r = ze(this.opts.timeLabel, "crosshair", n, () => this.fmt.crosshair(n, this.timeVisible())), i = this.measureText(r) + 16, s = Math.max(a, Math.min(a + o - i, d - i / 2));
3169
3299
  e.fillStyle = t.labelBackground, e.fillRect(s, this.cssH - this.timeH, i, this.timeH), e.fillStyle = t.labelText, e.textAlign = "center", e.textBaseline = "middle", e.fillText(r, s + i / 2, this.cssH - this.timeH / 2);
3170
3300
  }
3171
3301
  }
@@ -3191,7 +3321,7 @@ var _n = class {
3191
3321
  let o = n.y(r.value);
3192
3322
  if (!(o >= 0 && o <= i)) return;
3193
3323
  let s = Math.round(this.opts.theme.fontSize * 1.8), c = Math.ceil(this.measureText(t)) + 10, l = Math.max(0, Math.min(i - s, o - s / 2)), u = n.options.position === "left" ? 0 : a - c;
3194
- e.fillStyle = r.color, e.fillRect(u, l, c, s), e.fillStyle = yn(r.color), e.textBaseline = "middle", e.textAlign = "left", e.fillText(t, u + 5, l + s / 2);
3324
+ e.fillStyle = r.color, e.fillRect(u, l, c, s), e.fillStyle = wn(r.color), e.textBaseline = "middle", e.textAlign = "left", e.fillText(t, u + 5, l + s / 2);
3195
3325
  }
3196
3326
  markerLayout(e, t, n) {
3197
3327
  let r = t.markers(), i = this.model.timeline;
@@ -3199,10 +3329,10 @@ var _n = class {
3199
3329
  let a = this.time, o = t.data, s = o.shape === "ohlc", c = Math.max(i.first, this.vis.lo - 1), l = Math.min(i.end - 1, this.vis.hi + 1);
3200
3330
  if (c > l) return [];
3201
3331
  let u = i.timeAt(c), d = i.timeAt(l);
3202
- return ot({
3332
+ return ut({
3203
3333
  markers: r,
3204
- from: nt(r, u),
3205
- to: nt(r, d + 1),
3334
+ from: ot(r, u),
3335
+ to: ot(r, d + 1),
3206
3336
  barSpacing: a.spacing,
3207
3337
  fontSize: this.opts.theme.fontSize,
3208
3338
  textWidth: (e) => this.measureText(e),
@@ -3287,7 +3417,7 @@ var _n = class {
3287
3417
  this.lastAnnounce = e;
3288
3418
  let t = this.crosshairIndex();
3289
3419
  if (t === void 0) return;
3290
- let n = this.opts.messages, r = this.model.timeline.timeAt(t), i = [Le(this.opts.timeLabel, "crosshair", r, () => this.fmt.crosshair(r, this.timeVisible()))];
3420
+ let n = this.opts.messages, r = this.model.timeline.timeAt(t), i = [ze(this.opts.timeLabel, "crosshair", r, () => this.fmt.crosshair(r, this.timeVisible()))];
3291
3421
  for (let e of this.panes) for (let r of e.series) {
3292
3422
  let e = r.barAtIndex(t);
3293
3423
  if (!e) continue;
@@ -3353,7 +3483,7 @@ var _n = class {
3353
3483
  if (this.autoTheme) {
3354
3484
  this.opts = {
3355
3485
  ...this.opts,
3356
- theme: Ut()
3486
+ theme: Jt()
3357
3487
  };
3358
3488
  for (let e of this.panes) for (let t of e.series) t.themeChanged(this.opts.theme);
3359
3489
  this.invalidate(7);
@@ -3444,7 +3574,7 @@ function Z(e) {
3444
3574
  "\"": "&quot;"
3445
3575
  })[e]);
3446
3576
  }
3447
- function vn(e, t, n, r) {
3577
+ function Cn(e, t, n, r) {
3448
3578
  let i = t(n === n && r === r ? {
3449
3579
  low: n,
3450
3580
  high: r
@@ -3461,20 +3591,20 @@ function $(e, t) {
3461
3591
  for (let r of e.scales.values()) r.options.position === t && r.options.visible && n.push(r);
3462
3592
  return n;
3463
3593
  }
3464
- function yn(e) {
3465
- let n = t(e), r = n >>> 24 & 255, i = n >>> 16 & 255, a = n >>> 8 & 255;
3594
+ function wn(t) {
3595
+ let n = e(t), r = n >>> 24 & 255, i = n >>> 16 & 255, a = n >>> 8 & 255;
3466
3596
  return .299 * r + .587 * i + .114 * a > 150 ? "#000000" : "#ffffff";
3467
3597
  }
3468
3598
  //#endregion
3469
3599
  //#region src/chart/dashboard.ts
3470
- var bn = class {
3600
+ var Tn = class {
3471
3601
  container;
3472
3602
  canvases;
3473
3603
  charts = /* @__PURE__ */ new Set();
3474
3604
  resizeObs;
3475
3605
  removed = !1;
3476
3606
  constructor(e, t = {}) {
3477
- this.container = e, getComputedStyle(e).position === "static" && (e.style.position = "relative"), this.canvases = new ge(e, t.renderer ?? "auto", {
3607
+ this.container = e, getComputedStyle(e).position === "static" && (e.style.position = "relative"), this.canvases = new ye(e, t.renderer ?? "auto", {
3478
3608
  lost: () => {
3479
3609
  for (let e of this.charts) e.surfaceLost();
3480
3610
  },
@@ -3484,7 +3614,7 @@ var bn = class {
3484
3614
  addChart(e, t = {}) {
3485
3615
  if (this.removed) throw Error("alphacharts: this dashboard was removed");
3486
3616
  if (!this.container.contains(e)) throw Error("alphacharts: a dashboard cell must be inside the dashboard container");
3487
- let n = new _n(e, t, () => new he(this.canvases, e));
3617
+ let n = new Sn(e, t, () => new ve(this.canvases, e));
3488
3618
  return this.charts.add(n), n.onRemove(() => {
3489
3619
  this.charts.delete(n), this.relayout();
3490
3620
  }), n;
@@ -3506,7 +3636,7 @@ var bn = class {
3506
3636
  this.canvases.clear();
3507
3637
  for (let e of this.charts) e.remeasure(), e.invalidate(7);
3508
3638
  }
3509
- }, xn = class {
3639
+ }, En = class {
3510
3640
  members = /* @__PURE__ */ new Map();
3511
3641
  opts;
3512
3642
  constructor(e = {}) {
@@ -3547,7 +3677,7 @@ var bn = class {
3547
3677
  }, "sync");
3548
3678
  }
3549
3679
  }
3550
- }, Sn = (e) => {
3680
+ }, Dn = (e) => {
3551
3681
  if (Array.isArray(e)) {
3552
3682
  let t = e;
3553
3683
  return t.length ? {
@@ -3561,7 +3691,7 @@ var bn = class {
3561
3691
  last: t[t.length - 1]
3562
3692
  } : void 0;
3563
3693
  };
3564
- function Cn(e, t, n, r) {
3694
+ function On(e, t, n, r) {
3565
3695
  let i = r.pageSize ?? 2e3, a = r.prefetchBars ?? 300, o = new AbortController(), s = !0, c = !1, l = !1, u = NaN, d = NaN, f = [], p, m, h = (e) => {
3566
3696
  o.signal.aborted || r.onError(e);
3567
3697
  }, g = r.maxEarlyBars ?? 1e4, _ = !1, v = !1, y = (e) => {
@@ -3581,14 +3711,14 @@ function Cn(e, t, n, r) {
3581
3711
  countBack: i
3582
3712
  }, o.signal).then((e) => {
3583
3713
  if (o.signal.aborted) return;
3584
- let n = Sn(e.bars);
3714
+ let n = Dn(e.bars);
3585
3715
  n && (t.prepend(e.bars), u = n.first), c = e.noMoreData || !n;
3586
3716
  }).catch(h).finally(() => {
3587
3717
  s = !1;
3588
3718
  }));
3589
3719
  };
3590
3720
  n.subscribeBars && (p = n.subscribeBars(r.symbol, r.resolution, y));
3591
- let b = () => {
3721
+ let te = () => {
3592
3722
  s = !0, v = !1, n.getBars({
3593
3723
  symbol: r.symbol,
3594
3724
  resolution: r.resolution,
@@ -3597,7 +3727,7 @@ function Cn(e, t, n, r) {
3597
3727
  }, o.signal).then((n) => {
3598
3728
  if (o.signal.aborted) return;
3599
3729
  t.setData(n.bars);
3600
- let r = Sn(n.bars);
3730
+ let r = Dn(n.bars);
3601
3731
  u = r?.first ?? NaN, d = r?.last ?? NaN, c = n.noMoreData || !r, l = !0;
3602
3732
  for (let e of f) (Number.isNaN(d) || e.time >= d) && y(e);
3603
3733
  f.length = 0, m = e.on("visibleRangeChange", (e) => {
@@ -3610,7 +3740,7 @@ function Cn(e, t, n, r) {
3610
3740
  s = !1;
3611
3741
  });
3612
3742
  };
3613
- return b(), {
3743
+ return te(), {
3614
3744
  get loading() {
3615
3745
  return s;
3616
3746
  },
@@ -3621,7 +3751,7 @@ function Cn(e, t, n, r) {
3621
3751
  return v;
3622
3752
  },
3623
3753
  retry() {
3624
- v && !s && !o.signal.aborted && b();
3754
+ v && !s && !o.signal.aborted && te();
3625
3755
  },
3626
3756
  dispose() {
3627
3757
  o.abort(), p?.(), m?.();
@@ -3630,10 +3760,10 @@ function Cn(e, t, n, r) {
3630
3760
  }
3631
3761
  //#endregion
3632
3762
  //#region src/index.ts
3633
- function wn(e, t) {
3634
- return new _n(e, t);
3763
+ function kn(e, t) {
3764
+ return new Sn(e, t);
3635
3765
  }
3636
3766
  //#endregion
3637
- export { Kt as ALWAYS_OPEN, Wt as CHART_MESSAGES, a as COL_C, u as COL_COLOR, _ as COL_H, o as COL_L, s as COL_O, m as COL_V, _n as Chart, K as DARK, x as DAY_MS, mn as DEFAULT_KEYMAP, nn as DEFAULT_WATERMARK, bn as Dashboard, Ht as HIGH_CONTRAST, _e as LAYOUT_VERSION, Vt as LIGHT, l as LOD_BASE, c as LOD_C, n as LOD_COLOR, v as LOD_H, ee as LOD_L, i as LOD_O, Se as LocalStorageStore, xe as MemoryStore, Jt as NSE, A as PriceFormatter, Qe as PriceLine, en as Resampler, Bt as Series, q as Sessions, xn as SyncGroup, S as TimeZone, Yt as US_EQUITY, L as barWidths, J as checkWatermarkOptions, C as civilFromLocal, Cn as connectDatafeed, wn as createChart, dt as createFormatter, N as crisp, y as cssColor, Xe as dashPattern, lt as decimalsOf, Gt as defaultMessages, pn as drawWatermark, ut as isIndianLocale, ne as localFromCivil, be as migrate, Oe as niceStep, De as niceTicks, t as parseColor, Qt as parseResolution, W as registerSeriesType, e as rgba, Ut as systemTheme, qt as weekdays };
3767
+ export { Zt as ALWAYS_OPEN, tt as BarShading, Yt as CHART_MESSAGES, o as COL_BAR_COLOR, d as COL_C, v as COL_COLOR, s as COL_H, c as COL_L, h as COL_O, f as COL_V, Sn as Chart, K as DARK, b as DAY_MS, yn as DEFAULT_KEYMAP, cn as DEFAULT_WATERMARK, Tn as Dashboard, qt as HIGH_CONTRAST, be as LAYOUT_VERSION, Kt as LIGHT, l as LOD_BASE, r as LOD_C, y as LOD_COLOR, ne as LOD_H, a as LOD_L, te as LOD_O, Te as LocalStorageStore, we as MemoryStore, $t as NSE, A as PriceFormatter, et as PriceLine, on as Resampler, Gt as Series, q as Sessions, En as SyncGroup, x as TimeZone, en as US_EQUITY, L as barWidths, J as checkWatermarkOptions, S as civilFromLocal, On as connectDatafeed, kn as createChart, ht as createFormatter, N as crisp, t as cssColor, Qe as dashPattern, pt as decimalsOf, Xt as defaultMessages, vn as drawWatermark, mt as isIndianLocale, ae as localFromCivil, Ce as migrate, Ae as niceStep, ke as niceTicks, e as parseColor, rn as parseResolution, W as registerSeriesType, ee as rgba, Jt as systemTheme, Qt as weekdays };
3638
3768
 
3639
3769
  //# sourceMappingURL=index.js.map