@tradecanvas/core 1.7.0 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +107 -107
  3. package/dist/WebGLSeriesRenderer-DVJBHdfm.js +1740 -0
  4. package/dist/WebGLSeriesRenderer-DVJBHdfm.js.map +1 -0
  5. package/dist/WebGLSeriesRenderer-DjkYvHPQ.cjs +429 -0
  6. package/dist/WebGLSeriesRenderer-DjkYvHPQ.cjs.map +1 -0
  7. package/dist/axis/GridRenderer.d.ts.map +1 -1
  8. package/dist/axis/PriceAxis.d.ts +3 -1
  9. package/dist/axis/PriceAxis.d.ts.map +1 -1
  10. package/dist/axis/TimeAxis.d.ts.map +1 -1
  11. package/dist/axis/gridLines.d.ts +9 -0
  12. package/dist/axis/gridLines.d.ts.map +1 -0
  13. package/dist/charts/BarRenderer.d.ts.map +1 -1
  14. package/dist/charts/CandlestickRenderer.d.ts.map +1 -1
  15. package/dist/charts/DepthHeatmapBuffer.d.ts +6 -3
  16. package/dist/charts/DepthHeatmapBuffer.d.ts.map +1 -1
  17. package/dist/charts/HollowCandleRenderer.d.ts.map +1 -1
  18. package/dist/charts/MarketProfileRenderer.d.ts +2 -0
  19. package/dist/charts/MarketProfileRenderer.d.ts.map +1 -1
  20. package/dist/charts/VolumeCandleRenderer.d.ts.map +1 -1
  21. package/dist/charts/VolumeRenderer.d.ts +6 -3
  22. package/dist/charts/VolumeRenderer.d.ts.map +1 -1
  23. package/dist/charts/denseBars.d.ts.map +1 -1
  24. package/dist/charts/pixelGrid.d.ts +59 -0
  25. package/dist/charts/pixelGrid.d.ts.map +1 -0
  26. package/dist/drawings/DrawingBase.d.ts +4 -0
  27. package/dist/drawings/DrawingBase.d.ts.map +1 -1
  28. package/dist/drawings/DrawingRenderer.d.ts +2 -2
  29. package/dist/drawings/DrawingRenderer.d.ts.map +1 -1
  30. package/dist/drawings/tools/CrossLine.d.ts.map +1 -1
  31. package/dist/drawings/tools/DateRange.d.ts.map +1 -1
  32. package/dist/drawings/tools/ElliottWave.d.ts.map +1 -1
  33. package/dist/drawings/tools/FibChannel.d.ts.map +1 -1
  34. package/dist/drawings/tools/FibExtension.d.ts.map +1 -1
  35. package/dist/drawings/tools/FibRetracement.d.ts.map +1 -1
  36. package/dist/drawings/tools/FibSpeedResistanceFan.d.ts.map +1 -1
  37. package/dist/drawings/tools/FibTimeZones.d.ts.map +1 -1
  38. package/dist/drawings/tools/GannBox.d.ts.map +1 -1
  39. package/dist/drawings/tools/GannFan.d.ts.map +1 -1
  40. package/dist/drawings/tools/HorizontalLine.d.ts.map +1 -1
  41. package/dist/drawings/tools/HorizontalRay.d.ts.map +1 -1
  42. package/dist/drawings/tools/RiskReward.d.ts.map +1 -1
  43. package/dist/drawings/tools/TextAnnotation.d.ts.map +1 -1
  44. package/dist/drawings/tools/TrendAngle.d.ts.map +1 -1
  45. package/dist/drawings/tools/VerticalLine.d.ts.map +1 -1
  46. package/dist/drawings/tools/annotations.d.ts.map +1 -1
  47. package/dist/drawings/tools/fibGeometry.d.ts.map +1 -1
  48. package/dist/drawings/tools/labels.d.ts +26 -0
  49. package/dist/drawings/tools/labels.d.ts.map +1 -1
  50. package/dist/drawings/tools/options.d.ts +8 -0
  51. package/dist/drawings/tools/options.d.ts.map +1 -1
  52. package/dist/drawings/tools/priceLevels.d.ts.map +1 -1
  53. package/dist/drawings/tools/textBox.d.ts.map +1 -1
  54. package/dist/engine/LayerManager.d.ts +23 -0
  55. package/dist/engine/LayerManager.d.ts.map +1 -1
  56. package/dist/engine/RenderEngine.d.ts +38 -3
  57. package/dist/engine/RenderEngine.d.ts.map +1 -1
  58. package/dist/engine/gpu.d.ts +96 -0
  59. package/dist/engine/gpu.d.ts.map +1 -0
  60. package/dist/engine/index.d.ts +2 -0
  61. package/dist/engine/index.d.ts.map +1 -1
  62. package/dist/engine/loadWebGL.d.ts +9 -0
  63. package/dist/engine/loadWebGL.d.ts.map +1 -0
  64. package/dist/engine/plotSteps.d.ts +39 -0
  65. package/dist/engine/plotSteps.d.ts.map +1 -0
  66. package/dist/gridLines-BJLaM2d7.js +222 -0
  67. package/dist/gridLines-BJLaM2d7.js.map +1 -0
  68. package/dist/gridLines-CBmfrSCE.cjs +2 -0
  69. package/dist/gridLines-CBmfrSCE.cjs.map +1 -0
  70. package/dist/index.cjs +10 -10
  71. package/dist/index.cjs.map +1 -1
  72. package/dist/index.js +3010 -2685
  73. package/dist/index.js.map +1 -1
  74. package/dist/indicators/IndicatorBase.d.ts.map +1 -1
  75. package/dist/indicators/IndicatorEngine.d.ts +2 -0
  76. package/dist/indicators/IndicatorEngine.d.ts.map +1 -1
  77. package/dist/indicators/linePen.d.ts +38 -0
  78. package/dist/indicators/linePen.d.ts.map +1 -0
  79. package/dist/indicators/overlay/Alligator.d.ts.map +1 -1
  80. package/dist/indicators/overlay/AnchoredVWAP.d.ts.map +1 -1
  81. package/dist/indicators/overlay/BollingerBands.d.ts.map +1 -1
  82. package/dist/indicators/overlay/EMA.d.ts.map +1 -1
  83. package/dist/indicators/overlay/HullMA.d.ts.map +1 -1
  84. package/dist/indicators/overlay/MTFMovingAverage.d.ts.map +1 -1
  85. package/dist/indicators/overlay/SMA.d.ts.map +1 -1
  86. package/dist/indicators/overlay/SessionVWAP.d.ts.map +1 -1
  87. package/dist/indicators/overlay/Supertrend.d.ts.map +1 -1
  88. package/dist/indicators/overlay/TEMA.d.ts.map +1 -1
  89. package/dist/indicators/overlay/VWAP.d.ts.map +1 -1
  90. package/dist/indicators/overlay/VWMA.d.ts.map +1 -1
  91. package/dist/indicators/overlay/WMA.d.ts.map +1 -1
  92. package/dist/indicators/plots.d.ts.map +1 -1
  93. package/dist/interaction/CrosshairHandler.d.ts.map +1 -1
  94. package/dist/interaction/InteractionManager.d.ts.map +1 -1
  95. package/dist/trading/PositionRenderer.d.ts.map +1 -1
  96. package/dist/trading/TradingDragHandler.d.ts.map +1 -1
  97. package/dist/trading/TradingManager.d.ts +3 -0
  98. package/dist/trading/TradingManager.d.ts.map +1 -1
  99. package/dist/trading/TradingRenderer.d.ts +2 -0
  100. package/dist/trading/TradingRenderer.d.ts.map +1 -1
  101. package/dist/trading/plot.d.ts +4 -0
  102. package/dist/trading/plot.d.ts.map +1 -0
  103. package/dist/ui/SessionBreaks.d.ts +10 -0
  104. package/dist/ui/SessionBreaks.d.ts.map +1 -1
  105. package/dist/ui/SessionShading.d.ts +3 -0
  106. package/dist/ui/SessionShading.d.ts.map +1 -1
  107. package/dist/ui/Watermark.d.ts +2 -0
  108. package/dist/ui/Watermark.d.ts.map +1 -1
  109. package/dist/ui/axisValueLabels.d.ts +17 -0
  110. package/dist/ui/axisValueLabels.d.ts.map +1 -1
  111. package/dist/ui/index.d.ts +2 -1
  112. package/dist/ui/index.d.ts.map +1 -1
  113. package/dist/webgl/WebGLSeriesRenderer.d.ts +71 -0
  114. package/dist/webgl/WebGLSeriesRenderer.d.ts.map +1 -0
  115. package/dist/webgl/commandDrawer.d.ts +31 -0
  116. package/dist/webgl/commandDrawer.d.ts.map +1 -0
  117. package/dist/webgl/glColor.d.ts +13 -0
  118. package/dist/webgl/glColor.d.ts.map +1 -0
  119. package/dist/webgl/glKit.d.ts +26 -0
  120. package/dist/webgl/glKit.d.ts.map +1 -0
  121. package/dist/webgl/index.d.ts +5 -0
  122. package/dist/webgl/index.d.ts.map +1 -0
  123. package/dist/webgl/polygonSpans.d.ts +20 -0
  124. package/dist/webgl/polygonSpans.d.ts.map +1 -0
  125. package/dist/webgl/recordedCommands.d.ts +75 -0
  126. package/dist/webgl/recordedCommands.d.ts.map +1 -0
  127. package/dist/webgl/recordedPath.d.ts +51 -0
  128. package/dist/webgl/recordedPath.d.ts.map +1 -0
  129. package/dist/webgl/recordedShaders.d.ts +38 -0
  130. package/dist/webgl/recordedShaders.d.ts.map +1 -0
  131. package/dist/webgl/recorder.d.ts +84 -0
  132. package/dist/webgl/recorder.d.ts.map +1 -0
  133. package/dist/webgl/seriesUploads.d.ts +40 -0
  134. package/dist/webgl/seriesUploads.d.ts.map +1 -0
  135. package/dist/webgl/shaders.d.ts +40 -0
  136. package/dist/webgl/shaders.d.ts.map +1 -0
  137. package/dist/webgl/strokeGeometry.d.ts +28 -0
  138. package/dist/webgl/strokeGeometry.d.ts.map +1 -0
  139. package/dist/webgl/yMapping.d.ts +32 -0
  140. package/dist/webgl/yMapping.d.ts.map +1 -0
  141. package/package.json +2 -2
@@ -0,0 +1,1740 @@
1
+ import { i as e, o as t, r as n, s as r, t as i } from "./gridLines-BJLaM2d7.js";
2
+ import { resolveVolumeColors as a } from "@tradecanvas/commons";
3
+ var o = (e, t) => e.time === t.time && e.open === t.open && e.high === t.high && e.low === t.low && e.close === t.close && e.volume === t.volume, s = class {
4
+ buffer = new Float32Array();
5
+ count = 0;
6
+ basePrice = 0;
7
+ samples = [];
8
+ last = null;
9
+ source = null;
10
+ get values() {
11
+ return this.buffer;
12
+ }
13
+ get length() {
14
+ return this.count;
15
+ }
16
+ get base() {
17
+ return this.basePrice;
18
+ }
19
+ sync(e) {
20
+ let t = e.length;
21
+ if (t === 0) return this.reset(), {
22
+ full: !0,
23
+ from: 0,
24
+ to: 0
25
+ };
26
+ let n = this.count;
27
+ if (!(e === this.source && n > 0 && t >= n && this.samples.every(({ index: t, bar: n }) => o(e[t], n)))) return this.basePrice = e[t - 1].close, this.ensure(t), this.write(e, 0, t), this.remember(e), {
28
+ full: !0,
29
+ from: 0,
30
+ to: t
31
+ };
32
+ let r = this.last !== null && o(e[n - 1], this.last) ? n : n - 1;
33
+ return t > this.buffer.length / 6 ? (this.ensure(t), this.write(e, 0, t), this.remember(e), {
34
+ full: !0,
35
+ from: 0,
36
+ to: t
37
+ }) : (this.write(e, r, t), this.remember(e), {
38
+ full: !1,
39
+ from: r,
40
+ to: t
41
+ });
42
+ }
43
+ reset() {
44
+ this.count = 0, this.samples = [], this.last = null, this.source = null;
45
+ }
46
+ ensure(e) {
47
+ e * 6 <= this.buffer.length || (this.buffer = new Float32Array(Math.max(e + 1024, Math.ceil(e * 1.25)) * 6));
48
+ }
49
+ write(e, t, n) {
50
+ let r = this.buffer, i = this.basePrice;
51
+ for (let a = t; a < n; a++) {
52
+ let t = e[a], n = a * 6;
53
+ r[n] = t.open - i, r[n + 1] = t.high - i, r[n + 2] = t.low - i, r[n + 3] = t.close - i, r[n + 4] = t.volume, r[n + 5] = +(t.close >= t.open);
54
+ }
55
+ this.count = n;
56
+ }
57
+ remember(e) {
58
+ let t = e.length, n = t - 1, r = /* @__PURE__ */ new Set();
59
+ if (n > 0) for (let e = 0; e < 16; e++) r.add(Math.min(n - 1, Math.round(e * (n - 1) / 15)));
60
+ this.samples = [...r].map((t) => ({
61
+ index: t,
62
+ bar: { ...e[t] }
63
+ })), this.last = { ...e[t - 1] }, this.source = e;
64
+ }
65
+ }, c = /* @__PURE__ */ new Map(), l;
66
+ function u(e, t) {
67
+ return e.endsWith("%") ? parseFloat(e) / 100 : parseFloat(e) / t;
68
+ }
69
+ function d(e) {
70
+ let t = e.trim();
71
+ if (t.toLowerCase() === "transparent") return [
72
+ 0,
73
+ 0,
74
+ 0,
75
+ 0
76
+ ];
77
+ let n = /^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec(t);
78
+ if (n) {
79
+ let e = n[1];
80
+ e.length <= 4 && (e = [...e].map((e) => e + e).join(""));
81
+ let t = (t) => parseInt(e.slice(t, t + 2), 16) / 255;
82
+ return [
83
+ t(0),
84
+ t(2),
85
+ t(4),
86
+ e.length === 8 ? t(6) : 1
87
+ ];
88
+ }
89
+ let r = /^rgba?\(\s*([\d.]+%?)[\s,]+([\d.]+%?)[\s,]+([\d.]+%?)(?:\s*[,/]\s*([\d.]+%?))?\s*\)$/i.exec(t);
90
+ return r ? [
91
+ u(r[1], 255),
92
+ u(r[2], 255),
93
+ u(r[3], 255),
94
+ r[4] === void 0 ? 1 : u(r[4], 1)
95
+ ] : null;
96
+ }
97
+ function f() {
98
+ if (l !== void 0) return l;
99
+ try {
100
+ l = typeof OffscreenCanvas < "u" ? new OffscreenCanvas(1, 1).getContext("2d") : typeof document < "u" ? document.createElement("canvas").getContext("2d") : null;
101
+ } catch {
102
+ l = null;
103
+ }
104
+ return l;
105
+ }
106
+ function p(e) {
107
+ let t = f();
108
+ if (!t) return null;
109
+ t.fillStyle = "#000", t.fillStyle = e;
110
+ let n = String(t.fillStyle);
111
+ if (t.fillStyle = "#fff", t.fillStyle = e, String(t.fillStyle) !== n) return null;
112
+ let r = d(n);
113
+ if (r) return r;
114
+ t.clearRect(0, 0, 1, 1), t.fillRect(0, 0, 1, 1);
115
+ let i = t.getImageData(0, 0, 1, 1).data;
116
+ return [
117
+ i[0] / 255,
118
+ i[1] / 255,
119
+ i[2] / 255,
120
+ i[3] / 255
121
+ ];
122
+ }
123
+ var m = /* @__PURE__ */ new Set();
124
+ function h(e) {
125
+ let t = c.get(e);
126
+ if (t) return t;
127
+ if (m.has(e)) return null;
128
+ let n = d(e) ?? p(e);
129
+ return c.size > 256 && c.clear(), m.size > 256 && m.clear(), n ? c.set(e, n) : m.add(e), n;
130
+ }
131
+ function g(e) {
132
+ return h(e) ?? [
133
+ 0,
134
+ 0,
135
+ 0,
136
+ 0
137
+ ];
138
+ }
139
+ function _([e, t, n, r]) {
140
+ return [
141
+ e * r,
142
+ t * r,
143
+ n * r,
144
+ r
145
+ ];
146
+ }
147
+ //#endregion
148
+ //#region src/webgl/yMapping.ts
149
+ function v(e, t) {
150
+ let { min: n, max: r } = e.priceRange, { y: i, height: a } = e.chartRect, o = +(e.invertScale === !0), s = {
151
+ log: 0,
152
+ invert: o,
153
+ yA: i + a / 2,
154
+ yB: 0,
155
+ logOffset: 0,
156
+ min: 1,
157
+ logFloor: 0,
158
+ logK: 0,
159
+ top: i,
160
+ bottom: i + a
161
+ };
162
+ if (e.logScale && n > 0 && r > 0) {
163
+ let e = Math.log(r) - Math.log(n);
164
+ return e === 0 ? s : {
165
+ ...s,
166
+ log: 1,
167
+ logOffset: t - n,
168
+ min: n,
169
+ logFloor: 2 ** -52 / n,
170
+ logK: a / e
171
+ };
172
+ }
173
+ let c = r - n;
174
+ if (c === 0) return s;
175
+ let l = a / c;
176
+ return o ? {
177
+ ...s,
178
+ yA: i + (t - n) * l,
179
+ yB: l
180
+ } : {
181
+ ...s,
182
+ yA: i + (r - t) * l,
183
+ yB: -l
184
+ };
185
+ }
186
+ //#endregion
187
+ //#region src/webgl/glKit.ts
188
+ var ee = class {
189
+ constructor(e) {
190
+ this.gl = e;
191
+ }
192
+ program(e, t, n) {
193
+ let r = this.gl, i = (e, t) => {
194
+ let n = r.createShader(e);
195
+ if (!n) throw Error("WebGL: no shader");
196
+ if (r.shaderSource(n, t), r.compileShader(n), !r.getShaderParameter(n, r.COMPILE_STATUS)) {
197
+ let e = r.getShaderInfoLog(n);
198
+ throw r.deleteShader(n), Error(`WebGL shader: ${e}`);
199
+ }
200
+ return n;
201
+ }, a = i(r.VERTEX_SHADER, e), o = i(r.FRAGMENT_SHADER, t), s = r.createProgram();
202
+ if (!s) throw Error("WebGL: no program");
203
+ if (r.attachShader(s, a), r.attachShader(s, o), r.linkProgram(s), r.deleteShader(a), r.deleteShader(o), !r.getProgramParameter(s, r.LINK_STATUS)) throw Error(`WebGL program: ${r.getProgramInfoLog(s)}`);
204
+ let c = r.createVertexArray();
205
+ if (!c) throw Error("WebGL: no vertex array");
206
+ let l = /* @__PURE__ */ new Map();
207
+ for (let e of n) l.set(e, r.getAttribLocation(s, e));
208
+ return {
209
+ program: s,
210
+ vao: c,
211
+ uniforms: /* @__PURE__ */ new Map(),
212
+ attribs: l
213
+ };
214
+ }
215
+ buffer() {
216
+ let e = this.gl.createBuffer();
217
+ if (!e) throw Error("WebGL: no buffer");
218
+ return e;
219
+ }
220
+ use(e) {
221
+ return this.gl.useProgram(e.program), this.gl.bindVertexArray(e.vao), e;
222
+ }
223
+ attrib(e, t, n, r, i, a = 1) {
224
+ let o = e.attribs.get(t);
225
+ if (o === void 0 || o < 0) return;
226
+ let s = this.gl;
227
+ s.enableVertexAttribArray(o), s.vertexAttribPointer(o, n, s.FLOAT, !1, r, i), s.vertexAttribDivisor(o, a);
228
+ }
229
+ int(e, t, n) {
230
+ this.gl.uniform1i(this.loc(e, t), n);
231
+ }
232
+ float(e, t, n) {
233
+ this.gl.uniform1f(this.loc(e, t), n);
234
+ }
235
+ vec2(e, t, n, r) {
236
+ this.gl.uniform2f(this.loc(e, t), n, r);
237
+ }
238
+ vec4(e, t, n) {
239
+ this.gl.uniform4f(this.loc(e, t), n[0], n[1], n[2], n[3]);
240
+ }
241
+ loc(e, t) {
242
+ return e.uniforms.has(t) || e.uniforms.set(t, this.gl.getUniformLocation(e.program, t)), e.uniforms.get(t) ?? null;
243
+ }
244
+ deleteProgram(e) {
245
+ this.gl.deleteVertexArray(e.vao), this.gl.deleteProgram(e.program);
246
+ }
247
+ scissor(e, t, n, r, i, a) {
248
+ let o = Math.max(0, Math.floor(e)), s = Math.max(0, Math.floor(t)), c = Math.min(i, Math.ceil(n)), l = Math.min(a, Math.ceil(r));
249
+ if (!(c > o && l > s)) return !1;
250
+ let u = this.gl;
251
+ return u.enable(u.SCISSOR_TEST), u.scissor(o, a - l, c - o, l - s), !0;
252
+ }
253
+ };
254
+ //#endregion
255
+ //#region src/webgl/polygonSpans.ts
256
+ function te(e) {
257
+ let t = e.length / 2;
258
+ if (t < 3) return [];
259
+ let n = 0, r = 0;
260
+ for (let i = 1; i < t; i++) e[2 * i] < e[2 * n] && (n = i), e[2 * i] > e[2 * r] && (r = i);
261
+ if (e[2 * n] === e[2 * r]) return [];
262
+ let i = b(e, n, r, 1, t), a = b(e, n, r, -1, t);
263
+ return !i || !a ? null : ne(i, a);
264
+ }
265
+ function y(e) {
266
+ let t = 0, n = e.length / 2;
267
+ for (let r = 0; r < n; r++) {
268
+ let i = (r + 1) % n;
269
+ t += e[2 * r] * e[2 * i + 1] - e[2 * i] * e[2 * r + 1];
270
+ }
271
+ return t / 2;
272
+ }
273
+ function b(e, t, n, r, i) {
274
+ let a = [e[2 * t], e[2 * t + 1]];
275
+ for (let o = t; o !== n;) {
276
+ if (o = (o + r + i) % i, e[2 * o] < a[a.length - 2]) return null;
277
+ a.push(e[2 * o], e[2 * o + 1]);
278
+ }
279
+ return a;
280
+ }
281
+ var x = class {
282
+ i = 0;
283
+ constructor(e) {
284
+ this.c = e;
285
+ }
286
+ at(e, t) {
287
+ let n = this.c;
288
+ for (; this.i + 5 < n.length && (n[this.i + 2] < t || n[this.i + 2] === n[this.i]);) this.i += 2;
289
+ let r = n[this.i], i = n[this.i + 1], a = n[this.i + 2], o = n[this.i + 3], s = (e) => a === r ? i : i + (o - i) * (e - r) / (a - r);
290
+ return [s(e), s(t)];
291
+ }
292
+ };
293
+ function ne(e, t) {
294
+ let n = /* @__PURE__ */ new Set();
295
+ for (let t = 0; t < e.length; t += 2) n.add(e[t]);
296
+ for (let e = 0; e < t.length; e += 2) n.add(t[e]);
297
+ let r = [...n].sort((e, t) => e - t), i = new x(e), a = new x(t), o = [], s = r.length - 2;
298
+ for (let e = 0; e <= s; e++) {
299
+ let t = r[e], n = r[e + 1], [c, l] = i.at(t, n), [u, d] = a.at(t, n);
300
+ c === u && l === d || o.push(t, n, c, l, u, d, +(e === 0), +(e === s));
301
+ }
302
+ return o;
303
+ }
304
+ //#endregion
305
+ //#region src/webgl/recordedShaders.ts
306
+ var S = "#version 300 es\nprecision highp float;\nuniform vec2 u_canvas;\nuniform vec4 u_clip;\n\nvec4 toClip(vec2 dev) {\n return vec4(dev.x / u_canvas.x * 2.0 - 1.0, 1.0 - dev.y / u_canvas.y * 2.0, 0.0, 1.0);\n}\n", C = "\nvec2 corner(int k) {\n if (k == 0) return vec2(0.0, 0.0);\n if (k == 1 || k == 4) return vec2(1.0, 0.0);\n if (k == 2 || k == 3) return vec2(0.0, 1.0);\n return vec2(1.0, 1.0);\n}\nconst vec4 NOWHERE = vec4(-2.0, -2.0, 0.0, 1.0);\n", w = "\n// This fragment's pixel centre in device pixels, y down.\nvec2 pixelCentre() { return vec2(gl_FragCoord.x, u_canvas.y - gl_FragCoord.y); }\n\n// The share of the pixel centred at p inside the clip.\nfloat clipCoverage(vec2 p) {\n vec2 lo = p - 0.5;\n vec2 c = clamp(min(lo + 1.0, u_clip.zw) - max(lo, u_clip.xy), 0.0, 1.0);\n return c.x * c.y;\n}\n", re = `${S}${C}
307
+ uniform float u_hw;
308
+ in vec4 a_p0;
309
+ in vec4 a_p1;
310
+ in vec4 a_p2;
311
+ in vec4 a_p3;
312
+ in vec4 a_p4;
313
+ in vec4 a_p5;
314
+ flat out vec4 v_p0;
315
+ flat out vec4 v_p1;
316
+ flat out vec4 v_p2;
317
+ flat out vec4 v_p3;
318
+ flat out vec4 v_p4;
319
+ flat out vec4 v_p5;
320
+
321
+ void main() {
322
+ v_p0 = a_p0; v_p1 = a_p1; v_p2 = a_p2; v_p3 = a_p3; v_p4 = a_p4; v_p5 = a_p5;
323
+ if (a_p2.z < 0.5 || a_p3.z < 0.5) { gl_Position = NOWHERE; return; }
324
+ vec2 a = a_p2.xy;
325
+ vec2 b = a_p3.xy;
326
+ vec2 d = b - a;
327
+ float len = length(d);
328
+ vec2 dir = len > 0.0 ? d / len : vec2(1.0, 0.0);
329
+ vec2 n = vec2(-dir.y, dir.x);
330
+ float m = u_hw + 1.0;
331
+ vec2 cr = corner(gl_VertexID % 6);
332
+ vec2 pos = mix(a - dir * m, b + dir * m, cr.x) + n * mix(-m, m, cr.y);
333
+ gl_Position = toClip(pos);
334
+ }
335
+ `, ie = `${S}${w}
336
+ uniform vec4 u_color;
337
+ uniform float u_hw;
338
+ uniform int u_cap;
339
+ uniform vec4 u_dash;
340
+ flat in vec4 v_p0;
341
+ flat in vec4 v_p1;
342
+ flat in vec4 v_p2;
343
+ flat in vec4 v_p3;
344
+ flat in vec4 v_p4;
345
+ flat in vec4 v_p5;
346
+ out vec4 outColor;
347
+
348
+ float segDist(vec2 p, vec2 a, vec2 b) {
349
+ vec2 ab = b - a;
350
+ float l2 = dot(ab, ab);
351
+ float t = l2 > 0.0 ? clamp(dot(p - a, ab) / l2, 0.0, 1.0) : 0.0;
352
+ return length(p - a - t * ab);
353
+ }
354
+
355
+ bool joined(vec4 a, vec4 b) { return a.z > -0.5 && b.z > -0.5; }
356
+
357
+ // The share of a pixel at distance d from the centre line inside a line hw either side.
358
+ float across(float d) { return clamp(min(u_hw, d + 0.5) - max(-u_hw, d - 0.5), 0.0, 1.0); }
359
+
360
+ // The share of [s - 0.5, s + 0.5] inside [lo, hi].
361
+ float span(float s, float lo, float hi) { return clamp(min(s + 0.5, hi) - max(s - 0.5, lo), 0.0, 1.0); }
362
+
363
+ // The share of [s - 0.5, s + 0.5] on a dash.
364
+ float onDash(float s) {
365
+ float period = u_dash.x + u_dash.y + u_dash.z + u_dash.w;
366
+ float base = s - mod(s, period);
367
+ float on = 0.0;
368
+ for (int k = -1; k <= 1; k++) {
369
+ float p0 = base + float(k) * period;
370
+ on += span(s, p0, p0 + u_dash.x);
371
+ on += span(s, p0 + u_dash.x + u_dash.y, p0 + u_dash.x + u_dash.y + u_dash.z);
372
+ }
373
+ return min(on, 1.0);
374
+ }
375
+
376
+ void main() {
377
+ vec2 p = pixelCentre();
378
+ float clipCov = clipCoverage(p);
379
+ if (clipCov <= 0.0) discard;
380
+ vec2 a = v_p2.xy;
381
+ vec2 b = v_p3.xy;
382
+ vec2 ab = b - a;
383
+ float len = length(ab);
384
+ vec2 dir = len > 0.0 ? ab / len : vec2(1.0, 0.0);
385
+ float along = dot(p - a, dir);
386
+ float perp = abs(dot(p - a, vec2(-dir.y, dir.x)));
387
+ bool startEnd = v_p1.z < -0.5;
388
+ bool finalEnd = v_p4.z < -0.5;
389
+
390
+ float cov;
391
+ if (u_dash.x + u_dash.y > 0.0) {
392
+ cov = across(perp) * onDash(v_p2.w + along) * span(along, 0.0, len);
393
+ } else {
394
+ float self = segDist(p, a, b);
395
+ float nearest = self;
396
+ if (joined(v_p0, v_p1)) { float d = segDist(p, v_p0.xy, v_p1.xy); if (d <= self) discard; nearest = min(nearest, d); }
397
+ if (joined(v_p1, v_p2)) { float d = segDist(p, v_p1.xy, v_p2.xy); if (d <= self) discard; nearest = min(nearest, d); }
398
+ if (joined(v_p3, v_p4)) { float d = segDist(p, v_p3.xy, v_p4.xy); if (d < self) discard; nearest = min(nearest, d); }
399
+ if (joined(v_p4, v_p5)) { float d = segDist(p, v_p4.xy, v_p5.xy); if (d < self) discard; nearest = min(nearest, d); }
400
+ cov = across(nearest);
401
+ // Past an end of the line: its cap, square-ended (butt or square) or round.
402
+ float before = startEnd ? -along : -1e9;
403
+ float after = finalEnd ? along - len : -1e9;
404
+ if (u_cap != 1 && (before > -0.5 || after > -0.5)) {
405
+ float reach = u_cap == 2 ? u_hw : 0.0;
406
+ float lo = startEnd ? -reach : -1e9;
407
+ float hi = finalEnd ? len + reach : 1e9;
408
+ cov = across(perp) * span(along, lo, hi);
409
+ }
410
+ }
411
+ if (cov <= 0.0) discard;
412
+ outColor = u_color * (cov * clipCov);
413
+ }
414
+ `, ae = `${S}${C}
415
+ in vec2 a_x;
416
+ in vec4 a_ab;
417
+ in vec2 a_ends;
418
+ flat out vec2 v_x;
419
+ flat out vec4 v_ab;
420
+ flat out vec2 v_ends;
421
+
422
+ void main() {
423
+ v_x = a_x;
424
+ v_ab = a_ab;
425
+ v_ends = a_ends;
426
+ float lo = min(min(a_ab.x, a_ab.y), min(a_ab.z, a_ab.w));
427
+ float hi = max(max(a_ab.x, a_ab.y), max(a_ab.z, a_ab.w));
428
+ vec2 cr = corner(gl_VertexID % 6);
429
+ gl_Position = toClip(mix(vec2(floor(a_x.x), floor(lo) - 1.0), vec2(ceil(a_x.y), ceil(hi) + 1.0), cr));
430
+ }
431
+ `, oe = `${S}${w}
432
+ uniform int u_kind;
433
+ uniform vec4 u_color;
434
+ uniform vec4 u_line;
435
+ uniform vec4 u_offsets;
436
+ uniform int u_stops;
437
+ uniform vec4 u_stop0;
438
+ uniform vec4 u_stop1;
439
+ uniform vec4 u_stop2;
440
+ uniform vec4 u_stop3;
441
+ flat in vec2 v_x;
442
+ flat in vec4 v_ab;
443
+ flat in vec2 v_ends;
444
+ out vec4 outColor;
445
+
446
+ vec4 stopColor(int i) {
447
+ if (i == 0) return u_stop0;
448
+ if (i == 1) return u_stop1;
449
+ if (i == 2) return u_stop2;
450
+ return u_stop3;
451
+ }
452
+
453
+ vec4 gradient(vec2 p) {
454
+ vec2 g = u_line.zw - u_line.xy;
455
+ float l2 = dot(g, g);
456
+ // A gradient of no length paints nothing.
457
+ if (l2 <= 0.0) return vec4(0.0);
458
+ float t = dot(p - u_line.xy, g) / l2;
459
+ vec4 c = stopColor(0);
460
+ for (int i = 1; i < 4; i++) {
461
+ if (i >= u_stops) break;
462
+ float o0 = u_offsets[i - 1];
463
+ float o1 = u_offsets[i];
464
+ if (t >= o1) c = stopColor(i);
465
+ else if (t > o0) { c = mix(stopColor(i - 1), stopColor(i), (t - o0) / max(o1 - o0, 1e-6)); break; }
466
+ else break;
467
+ }
468
+ return vec4(c.rgb * c.a, c.a);
469
+ }
470
+
471
+ void main() {
472
+ vec2 p = pixelCentre();
473
+ float x0 = v_x.x;
474
+ float x1 = v_x.y;
475
+ float left = v_ends.x > 0.5 ? clamp(p.x + 0.5 - x0, 0.0, 1.0) : (p.x >= x0 ? 1.0 : 0.0);
476
+ float right = v_ends.y > 0.5 ? clamp(x1 - (p.x - 0.5), 0.0, 1.0) : (p.x < x1 ? 1.0 : 0.0);
477
+ float along = v_ends.x > 0.5 && v_ends.y > 0.5
478
+ ? clamp(min(p.x + 0.5, x1) - max(p.x - 0.5, x0), 0.0, 1.0)
479
+ : min(left, right);
480
+ float t = clamp((clamp(p.x, x0, x1) - x0) / max(x1 - x0, 1e-6), 0.0, 1.0);
481
+ float ya = mix(v_ab.x, v_ab.y, t);
482
+ float yb = mix(v_ab.z, v_ab.w, t);
483
+ float across = clamp(min(p.y + 0.5, max(ya, yb)) - max(p.y - 0.5, min(ya, yb)), 0.0, 1.0);
484
+ float cov = along * across * clipCoverage(p);
485
+ if (cov <= 0.0) discard;
486
+ vec4 color = u_kind == 1 ? gradient(p) : u_color;
487
+ outColor = color * cov;
488
+ }
489
+ `, se = `${S}${C}
490
+ in vec3 a_disc;
491
+ in vec4 a_color;
492
+ flat out vec3 v_disc;
493
+ flat out vec4 v_color;
494
+ void main() {
495
+ v_disc = a_disc;
496
+ v_color = a_color;
497
+ float m = a_disc.z + 1.0;
498
+ gl_Position = toClip(mix(a_disc.xy - m, a_disc.xy + m, corner(gl_VertexID % 6)));
499
+ }
500
+ `, ce = `${S}${w}
501
+ flat in vec3 v_disc;
502
+ flat in vec4 v_color;
503
+ out vec4 outColor;
504
+ void main() {
505
+ vec2 p = pixelCentre();
506
+ float cov = clamp(v_disc.z + 0.5 - length(p - v_disc.xy), 0.0, 1.0) * clipCoverage(p);
507
+ if (cov <= 0.0) discard;
508
+ outColor = v_color * cov;
509
+ }
510
+ `, T = 4, E = T * 4, D = 32, O = 7, k = O * 4, le = class {
511
+ stroke;
512
+ span;
513
+ disc;
514
+ buffer;
515
+ constructor(e) {
516
+ this.kit = e, this.stroke = e.program(re, ie, [
517
+ "a_p0",
518
+ "a_p1",
519
+ "a_p2",
520
+ "a_p3",
521
+ "a_p4",
522
+ "a_p5"
523
+ ]), this.span = e.program(ae, oe, [
524
+ "a_x",
525
+ "a_ab",
526
+ "a_ends"
527
+ ]), this.disc = e.program(se, ce, ["a_disc", "a_color"]), this.buffer = e.buffer();
528
+ }
529
+ draw(e, t, n, r) {
530
+ let i = this.kit.gl;
531
+ i.enable(i.BLEND);
532
+ for (let a = 0; a < e.length; a++) {
533
+ let o = e[a];
534
+ if (i.blendFunc(i.ONE, i.ONE_MINUS_SRC_ALPHA), i.disable(i.SCISSOR_TEST), o.type === "rects") {
535
+ let t = [o.values];
536
+ for (; e[a + 1]?.type === "rects";) t.push(e[++a].values);
537
+ this.drawRects(t, r);
538
+ } else o.type === "stroke" ? this.drawStroke(o, t, n) : o.type === "fill" ? this.drawFill(o, t, n) : this.drawDiscs(o.values, o.clip, t, n);
539
+ }
540
+ i.disable(i.SCISSOR_TEST);
541
+ }
542
+ destroy() {
543
+ for (let e of [
544
+ this.stroke,
545
+ this.span,
546
+ this.disc
547
+ ]) this.kit.deleteProgram(e);
548
+ this.kit.gl.deleteBuffer(this.buffer);
549
+ }
550
+ upload(e) {
551
+ let t = this.kit.gl;
552
+ t.bindBuffer(t.ARRAY_BUFFER, this.buffer), t.bufferData(t.ARRAY_BUFFER, e, t.STREAM_DRAW);
553
+ }
554
+ common(e, t, n, r) {
555
+ let i = this.kit;
556
+ return i.scissor(t.x0, t.y0, t.x1, t.y1, n, r) ? (i.use(e), i.vec2(e, "u_canvas", n, r), i.vec4(e, "u_clip", [
557
+ t.x0,
558
+ t.y0,
559
+ Math.min(t.x1, n),
560
+ Math.min(t.y1, r)
561
+ ]), !0) : !1;
562
+ }
563
+ drawRects(e, t) {
564
+ let n = 0;
565
+ for (let t of e) n += t.length / 8;
566
+ let r = new Float32Array(n * 10), i = 0;
567
+ for (let t of e) for (let e = 0; e < t.length; e += 8, i++) for (let n = 0; n < 8; n++) r[i * 10 + n] = t[e + n];
568
+ t(r, n);
569
+ }
570
+ drawStroke(e, t, n) {
571
+ let r = this.stroke;
572
+ if (!this.common(r, e.clip, t, n)) return;
573
+ let i = this.kit;
574
+ i.vec4(r, "u_color", e.color), i.float(r, "u_hw", e.width / 2), i.int(r, "u_cap", e.cap), i.vec4(r, "u_dash", e.dash ?? [
575
+ 0,
576
+ 0,
577
+ 0,
578
+ 0
579
+ ]), this.upload(new Float32Array(e.points));
580
+ for (let e = 0; e < 6; e++) i.attrib(r, `a_p${e}`, 4, E, e * E);
581
+ let a = e.points.length / T - 5;
582
+ a > 0 && i.gl.drawArraysInstanced(i.gl.TRIANGLES, 0, 6, a);
583
+ }
584
+ drawFill(e, t, n) {
585
+ let r = this.kit, i = e.bounds;
586
+ if (!r.scissor(i.x0, i.y0, i.x1, i.y1, t, n)) return;
587
+ let a = r.use(this.span);
588
+ r.vec2(a, "u_canvas", t, n), r.vec4(a, "u_clip", [
589
+ e.clip.x0,
590
+ e.clip.y0,
591
+ Math.min(e.clip.x1, t),
592
+ Math.min(e.clip.y1, n)
593
+ ]), this.upload(new Float32Array(e.spans)), r.attrib(a, "a_x", 2, D, 0), r.attrib(a, "a_ab", 4, D, 8), r.attrib(a, "a_ends", 2, D, 24), this.paint(a, e.paint), r.gl.drawArraysInstanced(r.gl.TRIANGLES, 0, 6, e.spans.length / 8);
594
+ }
595
+ paint(e, t) {
596
+ let n = this.kit;
597
+ if (t.kind === "solid") {
598
+ n.int(e, "u_kind", 0), n.vec4(e, "u_color", t.color);
599
+ return;
600
+ }
601
+ n.int(e, "u_kind", 1), n.vec4(e, "u_line", [
602
+ t.x0,
603
+ t.y0,
604
+ t.x1,
605
+ t.y1
606
+ ]);
607
+ let r = [
608
+ 0,
609
+ 0,
610
+ 0,
611
+ 0
612
+ ];
613
+ t.stops.forEach((e, t) => {
614
+ r[t] = e.offset;
615
+ }), n.vec4(e, "u_offsets", r), n.int(e, "u_stops", t.stops.length);
616
+ for (let r = 0; r < 4; r++) n.vec4(e, `u_stop${r}`, (t.stops[r] ?? t.stops[t.stops.length - 1]).color);
617
+ }
618
+ drawDiscs(e, t, n, r) {
619
+ let i = this.disc;
620
+ this.common(i, t, n, r) && (this.upload(new Float32Array(e)), this.kit.attrib(i, "a_disc", 3, k, 0), this.kit.attrib(i, "a_color", 4, k, 12), this.kit.gl.drawArraysInstanced(this.kit.gl.TRIANGLES, 0, 6, e.length / O));
621
+ }
622
+ }, A = (e, t) => ({
623
+ x0: Math.max(e.x0, t.x0),
624
+ y0: Math.max(e.y0, t.y0),
625
+ x1: Math.min(e.x1, t.x1),
626
+ y1: Math.min(e.y1, t.y1)
627
+ }), j = (e) => !(e.x1 > e.x0 && e.y1 > e.y0);
628
+ function M(e, t = 0) {
629
+ let n = Infinity, r = Infinity, i = -Infinity, a = -Infinity;
630
+ for (let t = 0; t < e.length; t += 2) {
631
+ let o = e[t], s = e[t + 1];
632
+ o < n && (n = o), o > i && (i = o), s < r && (r = s), s > a && (a = s);
633
+ }
634
+ return {
635
+ x0: n - t,
636
+ y0: r - t,
637
+ x1: i + t,
638
+ y1: a + t
639
+ };
640
+ }
641
+ function N(e) {
642
+ let t = [...e].sort((e, t) => e.x0 - t.x0), n = [];
643
+ for (let e of t) {
644
+ for (let t = n.length - 1; t >= 0; t--) n[t].x1 <= e.x0 && n.splice(t, 1);
645
+ for (let t of n) if (t.y0 < e.y1 && e.y0 < t.y1) return !0;
646
+ n.push(e);
647
+ }
648
+ return !1;
649
+ }
650
+ //#endregion
651
+ //#region src/webgl/recordedPath.ts
652
+ var P = class {
653
+ stops = [];
654
+ constructor(e, t, n, r) {
655
+ this.x0 = e, this.y0 = t, this.x1 = n, this.y1 = r;
656
+ }
657
+ addColorStop(e, t) {
658
+ if (!(e >= 0 && e <= 1)) throw RangeError("offset out of range");
659
+ this.stops.push({
660
+ offset: e,
661
+ color: t
662
+ });
663
+ }
664
+ }, F = typeof Path2D == "function" ? Path2D : class {}, I = class e extends F {
665
+ calls = [];
666
+ unsupported = !1;
667
+ constructor(t) {
668
+ super(t), t instanceof e ? (this.calls.push(...t.calls), this.unsupported = t.unsupported) : t !== void 0 && (this.unsupported = !0);
669
+ }
670
+ note(e, t, n = t) {
671
+ this.calls.push([e, t]), F.prototype[e]?.apply(this, n);
672
+ }
673
+ unfollowed(e, t) {
674
+ this.unsupported = !0, this.note(e, [], t);
675
+ }
676
+ moveTo(e, t) {
677
+ this.note("moveTo", [e, t]);
678
+ }
679
+ lineTo(e, t) {
680
+ this.note("lineTo", [e, t]);
681
+ }
682
+ closePath() {
683
+ this.note("closePath", []);
684
+ }
685
+ rect(e, t, n, r) {
686
+ this.note("rect", [
687
+ e,
688
+ t,
689
+ n,
690
+ r
691
+ ]);
692
+ }
693
+ arc(e, t, n, r, i, a) {
694
+ this.note("arc", [
695
+ e,
696
+ t,
697
+ n,
698
+ r,
699
+ i,
700
+ +!!a
701
+ ]);
702
+ }
703
+ quadraticCurveTo(e, t, n, r) {
704
+ this.note("quadraticCurveTo", [
705
+ e,
706
+ t,
707
+ n,
708
+ r
709
+ ]);
710
+ }
711
+ bezierCurveTo(e, t, n, r, i, a) {
712
+ this.note("bezierCurveTo", [
713
+ e,
714
+ t,
715
+ n,
716
+ r,
717
+ i,
718
+ a
719
+ ]);
720
+ }
721
+ arcTo(...e) {
722
+ this.unfollowed("arcTo", e);
723
+ }
724
+ ellipse(...e) {
725
+ this.unfollowed("ellipse", e);
726
+ }
727
+ roundRect(...e) {
728
+ this.unfollowed("roundRect", e);
729
+ }
730
+ addPath(t, n) {
731
+ !(t instanceof e) || n !== void 0 ? this.unsupported = !0 : (this.calls.push(...t.calls), this.unsupported ||= t.unsupported), F.prototype.addPath?.call(this, t, n);
732
+ }
733
+ };
734
+ function ue(e) {
735
+ let t = globalThis, n = Object.prototype.hasOwnProperty.call(t, "Path2D"), r = t.Path2D;
736
+ t.Path2D = I;
737
+ try {
738
+ e();
739
+ } finally {
740
+ n ? t.Path2D = r : delete t.Path2D;
741
+ }
742
+ }
743
+ //#endregion
744
+ //#region src/webgl/strokeGeometry.ts
745
+ var de = .25;
746
+ function fe(e, t, n, r) {
747
+ if (n === "round") return !1;
748
+ let i = e.points, a = i.length / 2, o = +!e.closed, s = e.closed ? a : a - 1;
749
+ for (let e = o; e < s; e++) {
750
+ let o = (e - 1 + a) % a, s = (e + 1) % a, c = i[2 * e] - i[2 * o], l = i[2 * e + 1] - i[2 * o + 1], u = i[2 * s] - i[2 * e], d = i[2 * s + 1] - i[2 * e + 1], f = Math.hypot(c, l), p = Math.hypot(u, d);
751
+ if (f === 0 || p === 0) continue;
752
+ let m = Math.max(-1, Math.min(1, (c * u + l * d) / (f * p))), h = Math.sqrt((1 + m) / 2);
753
+ if ((n === "miter" && h > 0 && 1 / h <= r ? t * (1 / h - 1) : t * (1 - h)) > de) return !0;
754
+ }
755
+ return !1;
756
+ }
757
+ function pe(e, t) {
758
+ let n = e.points;
759
+ for (let e = 2; e < n.length; e += 2) if (Math.hypot(n[e] - n[e - 2], n[e + 1] - n[e - 1]) < t) return !0;
760
+ return !1;
761
+ }
762
+ function me(e) {
763
+ let t = [], n = () => t.push(0, 0, -1, 0);
764
+ n(), n();
765
+ for (let { points: r, closed: i } of e) {
766
+ let e = r.length / 2, a = i && e >= 3;
767
+ a && t.push(r[2 * (e - 2)], r[2 * (e - 2) + 1], 0, 0, r[2 * (e - 1)], r[2 * (e - 1) + 1], 0, 0);
768
+ let o = 0;
769
+ for (let n = 0; n < e; n++) n > 0 && (o += Math.hypot(r[2 * n] - r[2 * n - 2], r[2 * n + 1] - r[2 * n - 1])), t.push(r[2 * n], r[2 * n + 1], 1, o);
770
+ a && (o += Math.hypot(r[0] - r[2 * (e - 1)], r[1] - r[2 * (e - 1) + 1]), t.push(r[0], r[1], 1, o), t.push(r[2], r[3], 0, 0, r[4], r[5], 0, 0)), n();
771
+ }
772
+ return n(), t;
773
+ }
774
+ //#endregion
775
+ //#region src/webgl/recorder.ts
776
+ var L = Math.PI * 2;
777
+ function R(e, t) {
778
+ let n = 2 * Math.sqrt(Math.max(.2 / Math.max(e, .1), 1e-6));
779
+ return Math.min(512, Math.max(4, Math.ceil(Math.abs(t) / Math.min(n, Math.PI / 4))));
780
+ }
781
+ var z = new Set([
782
+ "fillStyle",
783
+ "strokeStyle",
784
+ "lineWidth",
785
+ "lineCap",
786
+ "lineJoin",
787
+ "miterLimit",
788
+ "globalAlpha",
789
+ "globalCompositeOperation",
790
+ "lineDashOffset",
791
+ "font",
792
+ "textAlign",
793
+ "textBaseline",
794
+ "direction",
795
+ "shadowBlur",
796
+ "shadowColor",
797
+ "shadowOffsetX",
798
+ "shadowOffsetY",
799
+ "filter"
800
+ ]), B = new Set([
801
+ "fontKerning",
802
+ "fontStretch",
803
+ "fontVariantCaps",
804
+ "letterSpacing",
805
+ "wordSpacing",
806
+ "textRendering"
807
+ ]), V = new Set(["imageSmoothingEnabled", "imageSmoothingQuality"]), H = (e) => !!(e.rect || e.circle) || e.points.length >= 6, he = class {
808
+ commands = [];
809
+ ctx;
810
+ texts = [];
811
+ takesText = !0;
812
+ state;
813
+ stack = [];
814
+ path = [];
815
+ ok = !0;
816
+ stepStart = 0;
817
+ solid = null;
818
+ constructor(e, t) {
819
+ this.dpr = e, this.measure = t, this.reset({
820
+ x0: 0,
821
+ y0: 0,
822
+ x1: Infinity,
823
+ y1: Infinity
824
+ }), this.ctx = this.proxy();
825
+ }
826
+ region(e, t) {
827
+ let n = this.dpr, r = {
828
+ x0: e.x * n,
829
+ y0: e.y * n,
830
+ x1: (e.x + e.width) * n,
831
+ y1: (e.y + e.height) * n
832
+ }, i = [], a = t?.text !== !1;
833
+ return {
834
+ step: (e) => {
835
+ this.reset(r), this.texts = i, this.takesText = a;
836
+ let t = {
837
+ commands: this.commands.length,
838
+ texts: i.length
839
+ };
840
+ this.stepStart = t.commands, this.ok = !0;
841
+ try {
842
+ ue(() => e(this.ctx));
843
+ } catch {
844
+ this.ok = !1;
845
+ }
846
+ return this.ok ? !0 : (this.commands.length = t.commands, i.length = t.texts, !1);
847
+ },
848
+ drawText: (e) => ge(e, i)
849
+ };
850
+ }
851
+ reset(e) {
852
+ this.state = {
853
+ fillStyle: "#000000",
854
+ strokeStyle: "#000000",
855
+ lineWidth: 1,
856
+ lineCap: "butt",
857
+ lineJoin: "miter",
858
+ miterLimit: 10,
859
+ globalAlpha: 1,
860
+ globalCompositeOperation: "source-over",
861
+ lineDash: [],
862
+ lineDashOffset: 0,
863
+ font: "10px sans-serif",
864
+ textAlign: "start",
865
+ textBaseline: "alphabetic",
866
+ direction: "inherit",
867
+ shadowBlur: 0,
868
+ shadowColor: "rgba(0, 0, 0, 0)",
869
+ shadowOffsetX: 0,
870
+ shadowOffsetY: 0,
871
+ filter: "none",
872
+ textExtras: {},
873
+ transform: [
874
+ this.dpr,
875
+ 0,
876
+ 0,
877
+ this.dpr,
878
+ 0,
879
+ 0
880
+ ],
881
+ clip: e
882
+ }, this.stack = [], this.path = [];
883
+ }
884
+ unsupported() {
885
+ this.ok = !1;
886
+ }
887
+ copyState() {
888
+ let e = this.state;
889
+ return {
890
+ ...e,
891
+ lineDash: [...e.lineDash],
892
+ textExtras: { ...e.textExtras }
893
+ };
894
+ }
895
+ axisAligned() {
896
+ let e = this.state.transform;
897
+ return e[1] === 0 && e[2] === 0;
898
+ }
899
+ uniform() {
900
+ let e = this.state.transform;
901
+ return this.axisAligned() && Math.abs(e[0]) === Math.abs(e[3]);
902
+ }
903
+ setMatrix(e) {
904
+ e.every(Number.isFinite) && (this.state.transform = e);
905
+ }
906
+ multiply(e, t, n, r, i, a) {
907
+ let [o, s, c, l, u, d] = this.state.transform;
908
+ this.setMatrix([
909
+ o * e + c * t,
910
+ s * e + l * t,
911
+ o * n + c * r,
912
+ s * n + l * r,
913
+ o * i + c * a + u,
914
+ s * i + l * a + d
915
+ ]);
916
+ }
917
+ current() {
918
+ return this.path[this.path.length - 1];
919
+ }
920
+ moveTo(e, t) {
921
+ if (!Number.isFinite(e) || !Number.isFinite(t)) return;
922
+ let n = this.state.transform;
923
+ this.path.push({
924
+ points: [n[0] * e + n[2] * t + n[4], n[1] * e + n[3] * t + n[5]],
925
+ closed: !1
926
+ });
927
+ }
928
+ lineTo(e, t) {
929
+ if (!Number.isFinite(e) || !Number.isFinite(t)) return;
930
+ let n = this.current();
931
+ if (!n || n.closed) return this.moveTo(e, t);
932
+ let r = this.state.transform;
933
+ n.points.push(r[0] * e + r[2] * t + r[4], r[1] * e + r[3] * t + r[5]), n.rect = void 0, n.circle = void 0;
934
+ }
935
+ closePath() {
936
+ let e = this.current();
937
+ !e || e.closed || (e.closed = !0, this.path.push({
938
+ points: [e.points[0], e.points[1]],
939
+ closed: !1
940
+ }));
941
+ }
942
+ rect(e, t, n, r) {
943
+ if (![
944
+ e,
945
+ t,
946
+ n,
947
+ r
948
+ ].every(Number.isFinite)) return;
949
+ let i = this.state.transform, a = i[0] * e + i[2] * t + i[4], o = i[1] * e + i[3] * t + i[5], s = i[0] * (e + n) + i[2] * t + i[4], c = i[1] * (e + n) + i[3] * t + i[5], l = i[0] * (e + n) + i[2] * (t + r) + i[4], u = i[1] * (e + n) + i[3] * (t + r) + i[5], d = {
950
+ points: [
951
+ a,
952
+ o,
953
+ s,
954
+ c,
955
+ l,
956
+ u,
957
+ i[0] * e + i[2] * (t + r) + i[4],
958
+ i[1] * e + i[3] * (t + r) + i[5]
959
+ ],
960
+ closed: !0
961
+ };
962
+ this.axisAligned() && (d.rect = {
963
+ x0: Math.min(a, l),
964
+ y0: Math.min(o, u),
965
+ x1: Math.max(a, l),
966
+ y1: Math.max(o, u)
967
+ }), this.path.push(d), this.path.push({
968
+ points: [a, o],
969
+ closed: !1
970
+ });
971
+ }
972
+ arc(e, t, n, r, i, a = !1) {
973
+ if (![
974
+ e,
975
+ t,
976
+ n,
977
+ r,
978
+ i
979
+ ].every(Number.isFinite)) return;
980
+ if (n < 0) throw new DOMException("negative radius", "IndexSizeError");
981
+ let o = i - r;
982
+ o = !a && o >= L ? L : a && -o >= L ? -L : a ? -(((r - i) % L + L) % L) : (o % L + L) % L;
983
+ let s = this.current(), c = this.state.transform, l = e + n * Math.cos(r), u = t + n * Math.sin(r), d = !s || s.closed || s.points.length === 2 && Math.abs(s.points[0] - (c[0] * l + c[2] * u + c[4])) < 1e-6 && Math.abs(s.points[1] - (c[1] * l + c[3] * u + c[5])) < 1e-6, f = R(n * Math.abs(c[0]), o);
984
+ for (let i = 0; i <= f; i++) {
985
+ let a = r + o * i / f;
986
+ this.lineTo(e + n * Math.cos(a), t + n * Math.sin(a));
987
+ }
988
+ let p = this.current();
989
+ Math.abs(o) >= L - 1e-9 && d && this.uniform() && p && (p.circle = {
990
+ x: c[0] * e + c[4],
991
+ y: c[3] * t + c[5],
992
+ r: n * Math.abs(c[0])
993
+ });
994
+ }
995
+ curve(e, t) {
996
+ (!this.current() || this.current().closed) && this.moveTo(e[0], e[1]);
997
+ let n = this.current(), r = this.state.transform;
998
+ if (!n || !this.axisAligned() || r[0] === 0 || r[3] === 0) return this.unsupported();
999
+ let i = [
1000
+ (n.points[n.points.length - 2] - r[4]) / r[0],
1001
+ (n.points[n.points.length - 1] - r[5]) / r[3],
1002
+ ...e,
1003
+ ...t
1004
+ ], a = 0;
1005
+ for (let e = 2; e < i.length; e += 2) a += Math.hypot((i[e] - i[e - 2]) * r[0], (i[e + 1] - i[e - 1]) * r[3]);
1006
+ let o = Math.max(4, Math.min(64, Math.ceil(a / 3)));
1007
+ for (let e = 1; e <= o; e++) {
1008
+ let t = e / o, n = i.length === 6 ? [
1009
+ (1 - t) ** 2,
1010
+ 2 * t * (1 - t),
1011
+ t * t
1012
+ ] : [
1013
+ (1 - t) ** 3,
1014
+ 3 * t * (1 - t) ** 2,
1015
+ 3 * t * t * (1 - t),
1016
+ t ** 3
1017
+ ], r = 0, a = 0;
1018
+ n.forEach((e, t) => {
1019
+ r += e * i[2 * t], a += e * i[2 * t + 1];
1020
+ }), this.lineTo(r, a);
1021
+ }
1022
+ }
1023
+ withPath(e, t) {
1024
+ let n = this.path;
1025
+ this.path = [], e(), t(), this.path = n;
1026
+ }
1027
+ onPath(e, t) {
1028
+ if (!(e instanceof I) || e.unsupported) return this.unsupported();
1029
+ this.withPath(() => {
1030
+ for (let [t, n] of e.calls) t === "moveTo" ? this.moveTo(n[0], n[1]) : t === "lineTo" ? this.lineTo(n[0], n[1]) : t === "closePath" ? this.closePath() : t === "rect" ? this.rect(n[0], n[1], n[2], n[3]) : t === "arc" ? this.arc(n[0], n[1], n[2], n[3], n[4], !!n[5]) : t === "quadraticCurveTo" ? this.curve([n[0], n[1]], [n[2], n[3]]) : t === "bezierCurveTo" && this.curve([
1031
+ n[0],
1032
+ n[1],
1033
+ n[2],
1034
+ n[3]
1035
+ ], [n[4], n[5]]);
1036
+ }, t);
1037
+ }
1038
+ baseColor(e) {
1039
+ let t = this.solid;
1040
+ if (t && t.style === e) return t.color;
1041
+ let n = _(g(e));
1042
+ return this.solid = {
1043
+ style: e,
1044
+ color: n
1045
+ }, n;
1046
+ }
1047
+ alpha() {
1048
+ return Math.max(0, Math.min(1, this.state.globalAlpha));
1049
+ }
1050
+ solidColor(e) {
1051
+ let t = this.baseColor(e), n = this.alpha();
1052
+ return [
1053
+ t[0] * n,
1054
+ t[1] * n,
1055
+ t[2] * n,
1056
+ t[3] * n
1057
+ ];
1058
+ }
1059
+ paint(e) {
1060
+ let t = this.alpha();
1061
+ if (typeof e == "string") return {
1062
+ kind: "solid",
1063
+ color: this.solidColor(e)
1064
+ };
1065
+ if (!(e instanceof P)) return null;
1066
+ if (e.stops.length === 0) return {
1067
+ kind: "solid",
1068
+ color: [
1069
+ 0,
1070
+ 0,
1071
+ 0,
1072
+ 0
1073
+ ]
1074
+ };
1075
+ if (e.stops.length > 4) return null;
1076
+ let n = this.state.transform, r = e.x0 === e.x1 || e.y0 === e.y1;
1077
+ if (!this.axisAligned() || !this.uniform() && !r) return null;
1078
+ let i = [...e.stops].sort((e, t) => e.offset - t.offset).map((e) => {
1079
+ let n = g(e.color);
1080
+ return {
1081
+ offset: e.offset,
1082
+ color: [
1083
+ n[0],
1084
+ n[1],
1085
+ n[2],
1086
+ n[3] * t
1087
+ ]
1088
+ };
1089
+ });
1090
+ return {
1091
+ kind: "linear",
1092
+ x0: n[0] * e.x0 + n[4],
1093
+ y0: n[3] * e.y0 + n[5],
1094
+ x1: n[0] * e.x1 + n[4],
1095
+ y1: n[3] * e.y1 + n[5],
1096
+ stops: i
1097
+ };
1098
+ }
1099
+ plain() {
1100
+ let e = this.state;
1101
+ return e.globalCompositeOperation !== "source-over" || e.filter !== "none" ? !1 : e.shadowBlur === 0 && e.shadowOffsetX === 0 && e.shadowOffsetY === 0 ? !0 : !(g(e.shadowColor)[3] > 0);
1102
+ }
1103
+ fill(e = "nonzero") {
1104
+ if (!this.plain()) return this.unsupported();
1105
+ let t = this.paint(this.state.fillStyle);
1106
+ if (!t) return this.unsupported();
1107
+ let n = this.path.filter(H);
1108
+ if (n.length === 0 || t.kind === "solid" && t.color[3] === 0) return;
1109
+ if (n.length > 1 && N(n.map((e) => M(e.points)))) {
1110
+ let r = t.kind === "solid" && t.color[3] >= 1, i = Math.sign(y(n[0].points));
1111
+ if (!r || e !== "nonzero" || n.some((e) => Math.sign(y(e.points)) !== i)) return this.unsupported();
1112
+ }
1113
+ if (t.kind === "solid" && n.every((e) => e.rect)) return this.fillRects(n, t.color);
1114
+ if (t.kind === "solid" && n.every((e) => e.circle)) {
1115
+ let e = [];
1116
+ for (let r of n) e.push(r.circle.x, r.circle.y, r.circle.r, ...t.color);
1117
+ this.commands.push({
1118
+ type: "circles",
1119
+ values: e,
1120
+ clip: this.state.clip
1121
+ });
1122
+ return;
1123
+ }
1124
+ let r = [];
1125
+ for (let e of n) {
1126
+ let t = te(e.points);
1127
+ if (!t) return this.unsupported();
1128
+ for (let e of t) r.push(e);
1129
+ }
1130
+ let i = M(n.flatMap((e) => e.points)), a = A({
1131
+ x0: Math.floor(i.x0),
1132
+ y0: Math.floor(i.y0),
1133
+ x1: Math.ceil(i.x1),
1134
+ y1: Math.ceil(i.y1)
1135
+ }, this.state.clip);
1136
+ r.length > 0 && !j(a) && this.commands.push({
1137
+ type: "fill",
1138
+ spans: r,
1139
+ bounds: a,
1140
+ paint: t,
1141
+ clip: this.state.clip
1142
+ });
1143
+ }
1144
+ fillRects(e, t) {
1145
+ for (let n of e) this.pushRect(n.rect, t);
1146
+ }
1147
+ pushRect(e, t, n = 1) {
1148
+ let r = this.state.clip, i = Math.max(e.x0, r.x0), a = Math.max(e.y0, r.y0), o = Math.min(e.x1, r.x1), s = Math.min(e.y1, r.y1);
1149
+ if (!(o > i && s > a)) return;
1150
+ let c = this.commands[this.commands.length - 1], l = c && c.type === "rects" && this.commands.length > this.stepStart ? c.values : null, u = t[0] * n, d = t[1] * n, f = t[2] * n, p = t[3] * n;
1151
+ l ? l.push(i, a, o, s, u, d, f, p) : this.commands.push({
1152
+ type: "rects",
1153
+ values: [
1154
+ i,
1155
+ a,
1156
+ o,
1157
+ s,
1158
+ u,
1159
+ d,
1160
+ f,
1161
+ p
1162
+ ]
1163
+ });
1164
+ }
1165
+ fillRect(e, t, n, r) {
1166
+ let i = this.state.fillStyle;
1167
+ if (typeof i != "string" || !this.axisAligned() || !this.plain()) return this.withPath(() => this.rect(e, t, n, r), () => this.fill());
1168
+ if (!(Number.isFinite(e) && Number.isFinite(t) && Number.isFinite(n) && Number.isFinite(r))) return;
1169
+ let a = this.baseColor(i), o = this.alpha();
1170
+ if (a[3] * o === 0) return;
1171
+ let s = this.state.transform, c = s[0] * e + s[4], l = s[0] * (e + n) + s[4], u = s[3] * t + s[5], d = s[3] * (t + r) + s[5];
1172
+ this.pushRect({
1173
+ x0: Math.min(c, l),
1174
+ y0: Math.min(u, d),
1175
+ x1: Math.max(c, l),
1176
+ y1: Math.max(u, d)
1177
+ }, a, o);
1178
+ }
1179
+ stroke() {
1180
+ if (!this.plain()) return this.unsupported();
1181
+ let e = this.paint(this.state.strokeStyle);
1182
+ if (!e || e.kind !== "solid" || !this.uniform()) return this.unsupported();
1183
+ if (e.color[3] === 0) return;
1184
+ let t = this.state, n = Math.abs(t.transform[0]), r = t.lineWidth * n, i = this.path.filter((e) => e.points.length >= 4 && (t.lineCap !== "butt" || e.points.some((t, n) => t !== e.points[n % 2])));
1185
+ if (i.length === 0) return;
1186
+ let a = this.dash(i, n);
1187
+ if (a === void 0 || !this.drawsAlike(i, r, e.color[3])) return this.unsupported();
1188
+ let o = t.lineCap === "round" ? 1 : t.lineCap === "square" ? 2 : 0;
1189
+ this.commands.push({
1190
+ type: "stroke",
1191
+ points: me(i),
1192
+ color: e.color,
1193
+ width: r,
1194
+ cap: o,
1195
+ dash: a,
1196
+ clip: t.clip
1197
+ });
1198
+ }
1199
+ dash(e, t) {
1200
+ let n = this.state;
1201
+ if (n.lineDash.length === 0) return null;
1202
+ if (n.lineDash.length > 4 || n.lineDashOffset !== 0 || n.lineCap !== "butt" || e.some((e) => e.closed || e.points.length !== 4)) return;
1203
+ let r = n.lineDash.map((e) => e * t);
1204
+ for (; r.length < 4;) r.push(...r.slice(0, 4 - r.length));
1205
+ return r;
1206
+ }
1207
+ drawsAlike(e, t, n) {
1208
+ let r = this.state, i = t / 2;
1209
+ if (t > 1 && e.some((e) => fe(e, i, r.lineJoin, r.miterLimit))) return !1;
1210
+ let a = i + (r.lineCap === "butt" ? 0 : i);
1211
+ return !(e.length > 1 && N(e.map((e) => M(e.points, a))) || n < 1 && e.some((e) => pe(e, t)));
1212
+ }
1213
+ clip() {
1214
+ let e = this.path.filter(H);
1215
+ if (e.length !== 1 || !e[0].rect) return this.unsupported();
1216
+ this.state.clip = A(this.state.clip, e[0].rect);
1217
+ }
1218
+ text(e, t, n, r, i) {
1219
+ let a = e ? this.state.strokeStyle : this.state.fillStyle;
1220
+ if (!this.takesText || typeof a != "string" || !this.plain()) return this.unsupported();
1221
+ this.texts.push({
1222
+ stroke: e,
1223
+ text: String(t),
1224
+ x: n,
1225
+ y: r,
1226
+ maxWidth: i,
1227
+ state: this.copyState()
1228
+ });
1229
+ }
1230
+ measureText(e) {
1231
+ let t = this.measure;
1232
+ if (!t) return { width: String(e).length * 6 };
1233
+ let n = t.font;
1234
+ t.font = this.state.font;
1235
+ let r = t.measureText(e);
1236
+ return t.font = n, r;
1237
+ }
1238
+ methods() {
1239
+ let e = () => this.state, t = Object.create(null);
1240
+ return Object.assign(t, {
1241
+ save: () => {
1242
+ this.stack.push(this.copyState());
1243
+ },
1244
+ restore: () => {
1245
+ let e = this.stack.pop();
1246
+ e && (this.state = e);
1247
+ },
1248
+ beginPath: () => {
1249
+ this.path = [];
1250
+ },
1251
+ moveTo: (e, t) => this.moveTo(e, t),
1252
+ lineTo: (e, t) => this.lineTo(e, t),
1253
+ closePath: () => this.closePath(),
1254
+ rect: (e, t, n, r) => this.rect(e, t, n, r),
1255
+ arc: (e, t, n, r, i, a) => this.arc(e, t, n, r, i, a),
1256
+ quadraticCurveTo: (e, t, n, r) => this.curve([e, t], [n, r]),
1257
+ bezierCurveTo: (e, t, n, r, i, a) => this.curve([
1258
+ e,
1259
+ t,
1260
+ n,
1261
+ r
1262
+ ], [i, a]),
1263
+ fill: (e, t) => typeof e == "object" ? this.onPath(e, () => this.fill(t)) : this.fill(e),
1264
+ stroke: (e) => e ? this.onPath(e, () => this.stroke()) : this.stroke(),
1265
+ clip: (e) => typeof e == "object" ? this.onPath(e, () => this.clip()) : this.clip(),
1266
+ fillRect: (e, t, n, r) => this.fillRect(e, t, n, r),
1267
+ strokeRect: (e, t, n, r) => this.withPath(() => this.rect(e, t, n, r), () => this.stroke()),
1268
+ fillText: (e, t, n, r) => this.text(!1, e, t, n, r),
1269
+ strokeText: (e, t, n, r) => this.text(!0, e, t, n, r),
1270
+ measureText: (e) => this.measureText(e),
1271
+ setLineDash: (t) => {
1272
+ t.every((e) => Number.isFinite(e) && e >= 0) && (e().lineDash = t.length % 2 ? [...t, ...t] : [...t]);
1273
+ },
1274
+ getLineDash: () => [...e().lineDash],
1275
+ translate: (e, t) => this.multiply(1, 0, 0, 1, e, t),
1276
+ scale: (e, t) => this.multiply(e, 0, 0, t, 0, 0),
1277
+ rotate: (e) => this.multiply(Math.cos(e), Math.sin(e), -Math.sin(e), Math.cos(e), 0, 0),
1278
+ transform: (e, t, n, r, i, a) => this.multiply(e, t, n, r, i, a),
1279
+ setTransform: (e, t, n, r, i, a) => typeof e == "number" ? this.setMatrix([
1280
+ e,
1281
+ t ?? 0,
1282
+ n ?? 0,
1283
+ r ?? 1,
1284
+ i ?? 0,
1285
+ a ?? 0
1286
+ ]) : this.unsupported(),
1287
+ resetTransform: () => this.setMatrix([
1288
+ 1,
1289
+ 0,
1290
+ 0,
1291
+ 1,
1292
+ 0,
1293
+ 0
1294
+ ]),
1295
+ getTransform: () => {
1296
+ let [t, n, r, i, a, o] = e().transform;
1297
+ return {
1298
+ a: t,
1299
+ b: n,
1300
+ c: r,
1301
+ d: i,
1302
+ e: a,
1303
+ f: o,
1304
+ m11: t,
1305
+ m12: n,
1306
+ m21: r,
1307
+ m22: i,
1308
+ m41: a,
1309
+ m42: o,
1310
+ is2D: !0,
1311
+ isIdentity: t === 1 && n === 0 && r === 0 && i === 1 && a === 0 && o === 0
1312
+ };
1313
+ },
1314
+ createLinearGradient: (e, t, n, r) => new P(e, t, n, r)
1315
+ }), t;
1316
+ }
1317
+ proxy() {
1318
+ let e = this.methods();
1319
+ return new Proxy({}, {
1320
+ get: (t, n) => {
1321
+ if (typeof n == "string") {
1322
+ if (n in e) return e[n];
1323
+ if (z.has(n)) return this.state[n];
1324
+ if (B.has(n)) return this.state.textExtras[n];
1325
+ if (n === "canvas") return this.measure?.canvas;
1326
+ if (!V.has(n)) return this.unsupported(), () => void 0;
1327
+ }
1328
+ },
1329
+ set: (e, t, n) => (typeof t == "string" && this.setProp(t, n), !0)
1330
+ });
1331
+ }
1332
+ setProp(e, t) {
1333
+ let n = this.state;
1334
+ e === "lineWidth" || e === "miterLimit" ? typeof t == "number" && Number.isFinite(t) && t > 0 && (n[e] = t) : e === "globalAlpha" ? typeof t == "number" && Number.isFinite(t) && t >= 0 && t <= 1 && (n.globalAlpha = t) : e === "fillStyle" || e === "strokeStyle" ? t instanceof P ? n[e] = t : typeof t == "string" ? h(t) && (n[e] = t) : this.unsupported() : z.has(e) ? n[e] = t : B.has(e) ? this.state.textExtras[e] = t : V.has(e) || this.unsupported();
1335
+ }
1336
+ };
1337
+ function ge(e, t) {
1338
+ for (let n of t) {
1339
+ let t = n.state;
1340
+ if (j(t.clip)) continue;
1341
+ e.save(), e.setTransform(1, 0, 0, 1, 0, 0), Number.isFinite(t.clip.x1) && Number.isFinite(t.clip.y1) && (e.beginPath(), e.rect(t.clip.x0, t.clip.y0, t.clip.x1 - t.clip.x0, t.clip.y1 - t.clip.y0), e.clip());
1342
+ let [r, i, a, o, s, c] = t.transform;
1343
+ e.setTransform(r, i, a, o, s, c), e.font = t.font, e.textAlign = t.textAlign, e.textBaseline = t.textBaseline, e.direction = t.direction, e.globalAlpha = t.globalAlpha, Object.assign(e, t.textExtras), n.stroke ? (e.strokeStyle = t.strokeStyle, e.lineWidth = t.lineWidth, e.strokeText(n.text, n.x, n.y, n.maxWidth)) : (e.fillStyle = t.fillStyle, e.fillText(n.text, n.x, n.y, n.maxWidth)), e.restore();
1344
+ }
1345
+ }
1346
+ function _e(e, t) {
1347
+ return new he(e, t);
1348
+ }
1349
+ //#endregion
1350
+ //#region src/webgl/shaders.ts
1351
+ var U = `#version 300 es
1352
+ precision highp float;
1353
+ uniform vec2 u_canvas;
1354
+ uniform float u_dpr;
1355
+ uniform int u_log;
1356
+ uniform int u_invert;
1357
+ uniform float u_yA;
1358
+ uniform float u_yB;
1359
+ uniform float u_logOffset;
1360
+ uniform float u_min;
1361
+ uniform float u_logFloor;
1362
+ uniform float u_logK;
1363
+ uniform float u_top;
1364
+ uniform float u_bottom;
1365
+ out vec4 v_color;
1366
+
1367
+ // A price (relative to the base price) to a CSS-pixel y, as priceToYMapper
1368
+ // does; mappedY in yMapping.ts is the same steps in TypeScript.
1369
+ float cssY(float rel) {
1370
+ if (u_log == 1) {
1371
+ float v = log(max(1.0 + (rel + u_logOffset) / u_min, u_logFloor)) * u_logK;
1372
+ return u_invert == 1 ? u_top + v : u_bottom - v;
1373
+ }
1374
+ return u_yA + rel * u_yB;
1375
+ }
1376
+
1377
+ float snap(float v) { return floor(v + ${t.toFixed(4)}); }
1378
+
1379
+ vec4 toClip(vec2 dev) {
1380
+ return vec4(dev.x / u_canvas.x * 2.0 - 1.0, 1.0 - dev.y / u_canvas.y * 2.0, 0.0, 1.0);
1381
+ }
1382
+
1383
+ // The corners of a quad as two triangles.
1384
+ vec2 corner(int k) {
1385
+ if (k == 0) return vec2(0.0, 0.0);
1386
+ if (k == 1 || k == 4) return vec2(1.0, 0.0);
1387
+ if (k == 2 || k == 3) return vec2(0.0, 1.0);
1388
+ return vec2(1.0, 1.0);
1389
+ }
1390
+
1391
+ // Nothing to draw: every vertex at one point off the canvas.
1392
+ const vec4 NOWHERE = vec4(-2.0, -2.0, 0.0, 1.0);
1393
+ `, ve = `${U}
1394
+ in vec4 a_ohlc;
1395
+ in vec2 a_vd;
1396
+ uniform float u_x0;
1397
+ uniform float u_unit;
1398
+ uniform float u_wick;
1399
+ uniform float u_body;
1400
+ uniform vec4 u_upBody;
1401
+ uniform vec4 u_downBody;
1402
+ uniform vec4 u_upWick;
1403
+ uniform vec4 u_downWick;
1404
+
1405
+ void main() {
1406
+ int vid = gl_VertexID % 12;
1407
+ vec2 cr = corner(vid % 6);
1408
+ bool up = a_vd.y > 0.5;
1409
+ float cx = (u_x0 + float(gl_InstanceID) * u_unit) * u_dpr;
1410
+ float wickLeft = snap(cx - u_wick * 0.5);
1411
+ float left;
1412
+ float width;
1413
+ float top;
1414
+ float height;
1415
+ if (vid < 6) {
1416
+ float h = snap(cssY(a_ohlc.y) * u_dpr);
1417
+ float l = snap(cssY(a_ohlc.z) * u_dpr);
1418
+ left = wickLeft;
1419
+ width = u_wick;
1420
+ top = min(h, l);
1421
+ height = max(abs(l - h), 1.0);
1422
+ v_color = up ? u_upWick : u_downWick;
1423
+ } else {
1424
+ float o = snap(cssY(a_ohlc.x) * u_dpr);
1425
+ float c = snap(cssY(a_ohlc.w) * u_dpr);
1426
+ left = wickLeft - (u_body - u_wick) * 0.5;
1427
+ width = u_body;
1428
+ top = min(o, c);
1429
+ height = max(abs(c - o), u_wick);
1430
+ v_color = up ? u_upBody : u_downBody;
1431
+ }
1432
+ gl_Position = toClip(vec2(left + cr.x * width, top + cr.y * height));
1433
+ }
1434
+ `, ye = `${U}
1435
+ in vec4 a_ohlc;
1436
+ in vec2 a_vd;
1437
+ uniform float u_x0;
1438
+ uniform float u_unit;
1439
+ uniform float u_wick;
1440
+ uniform float u_body;
1441
+ uniform float u_volBottom;
1442
+ uniform float u_volScale;
1443
+ uniform vec4 u_volUp;
1444
+ uniform vec4 u_volDown;
1445
+
1446
+ void main() {
1447
+ vec2 cr = corner(gl_VertexID % 6);
1448
+ float cx = (u_x0 + float(gl_InstanceID) * u_unit) * u_dpr;
1449
+ float left = snap(cx - u_wick * 0.5) - (u_body - u_wick) * 0.5;
1450
+ float bottom = snap(u_volBottom * u_dpr);
1451
+ float top = snap((u_volBottom - a_vd.x * u_volScale) * u_dpr);
1452
+ if (bottom - top < 1.0) { gl_Position = NOWHERE; v_color = vec4(0.0); return; }
1453
+ v_color = a_vd.y > 0.5 ? u_volUp : u_volDown;
1454
+ gl_Position = toClip(vec2(left + cr.x * u_body, top + cr.y * (bottom - top)));
1455
+ }
1456
+ `, be = `${U}
1457
+ in vec4 a_col;
1458
+ in float a_up;
1459
+ uniform vec4 u_upBody;
1460
+ uniform vec4 u_downBody;
1461
+
1462
+ void main() {
1463
+ vec2 cr = corner(gl_VertexID % 6);
1464
+ float left = snap(a_col.x * u_dpr);
1465
+ float width = max(1.0, snap((a_col.x + 1.0) * u_dpr) - left);
1466
+ float t = snap(cssY(a_col.y) * u_dpr);
1467
+ float b = snap(cssY(a_col.z) * u_dpr);
1468
+ v_color = a_up > 0.5 ? u_upBody : u_downBody;
1469
+ gl_Position = toClip(vec2(left + cr.x * width, min(t, b) + cr.y * max(abs(b - t), 1.0)));
1470
+ }
1471
+ `, xe = `${U}
1472
+ in vec4 a_col;
1473
+ in float a_up;
1474
+ uniform float u_volBottom;
1475
+ uniform float u_volScale;
1476
+ uniform vec4 u_volUp;
1477
+ uniform vec4 u_volDown;
1478
+
1479
+ void main() {
1480
+ vec2 cr = corner(gl_VertexID % 6);
1481
+ float left = snap(a_col.x * u_dpr);
1482
+ float width = max(1.0, snap((a_col.x + 1.0) * u_dpr) - left);
1483
+ float bottom = snap(u_volBottom * u_dpr);
1484
+ float top = snap((u_volBottom - a_col.w * u_volScale) * u_dpr);
1485
+ if (bottom - top < 1.0) { gl_Position = NOWHERE; v_color = vec4(0.0); return; }
1486
+ v_color = a_up > 0.5 ? u_volUp : u_volDown;
1487
+ gl_Position = toClip(vec2(left + cr.x * width, top + cr.y * (bottom - top)));
1488
+ }
1489
+ `, Se = `${U}
1490
+ in vec4 a_rect;
1491
+ in vec4 a_color;
1492
+ in vec2 a_dash;
1493
+ flat out vec4 v_rect;
1494
+ flat out vec2 v_dash;
1495
+
1496
+ void main() {
1497
+ vec2 cr = corner(gl_VertexID % 6);
1498
+ v_rect = a_rect * u_dpr;
1499
+ v_dash = a_dash * u_dpr;
1500
+ v_color = a_color;
1501
+ gl_Position = toClip(mix(floor(v_rect.xy), ceil(v_rect.zw), cr));
1502
+ }
1503
+ `, Ce = "#version 300 es\nprecision highp float;\nuniform vec2 u_canvas;\nuniform int u_union;\nin vec4 v_color;\nflat in vec4 v_rect;\nflat in vec2 v_dash;\nout vec4 outColor;\n\n// The share of rows [y, y + 1] inside the rectangle and, dashed, on a dash.\nfloat rows(float y) {\n float lo = max(y, v_rect.y);\n float hi = min(y + 1.0, v_rect.w);\n if (hi <= lo) return 0.0;\n if (v_dash.x <= 0.0) return hi - lo;\n // A dash period is longer than a device pixel, so the row meets the dash\n // of the period it starts in and the next (a third to spare).\n float period = v_dash.x + v_dash.y;\n float first = v_rect.y + floor((lo - v_rect.y) / period) * period;\n float on = 0.0;\n for (int i = 0; i < 3; i++) {\n float start = first + float(i) * period;\n on += max(0.0, min(hi, start + v_dash.x) - max(lo, start));\n }\n return on;\n}\n\nvoid main() {\n // This pixel's top-left corner in device pixels, y down.\n vec2 p = vec2(floor(gl_FragCoord.x), u_canvas.y - floor(gl_FragCoord.y) - 1.0);\n float coverage = clamp(min(p.x + 1.0, v_rect.z) - max(p.x, v_rect.x), 0.0, 1.0) * rows(p.y);\n outColor = u_union == 1 ? vec4(v_color.rgb * coverage, coverage) : v_color * coverage;\n}\n", W = "#version 300 es\nprecision highp float;\nuniform vec2 u_canvas;\nuniform vec4 u_clip;\nin vec4 v_color;\nout vec4 outColor;\n\nvoid main() {\n vec2 p = vec2(floor(gl_FragCoord.x), u_canvas.y - floor(gl_FragCoord.y) - 1.0);\n vec2 c = clamp(min(p + 1.0, u_clip.zw) - max(p, u_clip.xy), 0.0, 1.0);\n outColor = v_color * (c.x * c.y);\n}\n", G = 24, K = 5, q = K * 4, J = 10, Y = J * 4, X = [
1504
+ "a_ohlc",
1505
+ "a_vd",
1506
+ "a_col",
1507
+ "a_up",
1508
+ "a_rect",
1509
+ "a_color",
1510
+ "a_dash"
1511
+ ], we = class t {
1512
+ label;
1513
+ gl;
1514
+ kit;
1515
+ drawer;
1516
+ candleBars;
1517
+ volumeBars;
1518
+ candleColumns;
1519
+ volumeColumns;
1520
+ rects;
1521
+ seriesBuffer;
1522
+ columnBuffer;
1523
+ rectBuffer;
1524
+ uploads = new s();
1525
+ gpuFloats = 0;
1526
+ columns = new Float32Array(4096 * K);
1527
+ rectValues = new Float32Array(64 * J);
1528
+ clip = [
1529
+ 0,
1530
+ 0,
1531
+ 0,
1532
+ 0
1533
+ ];
1534
+ lost = !1;
1535
+ lostCallback = null;
1536
+ static create(e = {}) {
1537
+ if (typeof document > "u") return null;
1538
+ let n = document.createElement("canvas"), r = null;
1539
+ try {
1540
+ r = n.getContext("webgl2", {
1541
+ alpha: !0,
1542
+ premultipliedAlpha: !0,
1543
+ antialias: !1,
1544
+ depth: !1,
1545
+ stencil: !1,
1546
+ preserveDrawingBuffer: !1,
1547
+ failIfMajorPerformanceCaveat: e.failIfMajorPerformanceCaveat ?? !1
1548
+ });
1549
+ } catch (e) {
1550
+ return $(e), null;
1551
+ }
1552
+ if (!r) return null;
1553
+ try {
1554
+ return new t(n, r);
1555
+ } catch (e) {
1556
+ return $(e), Q(r), null;
1557
+ }
1558
+ }
1559
+ constructor(e, t) {
1560
+ this.canvas = e, this.gl = t, this.kit = new ee(t);
1561
+ let n = t.getExtension("WEBGL_debug_renderer_info");
1562
+ this.label = String(n ? t.getParameter(n.UNMASKED_RENDERER_WEBGL) : t.getParameter(t.RENDERER));
1563
+ let r = this.kit;
1564
+ this.candleBars = r.program(ve, W, X), this.volumeBars = r.program(ye, W, X), this.candleColumns = r.program(be, W, X), this.volumeColumns = r.program(xe, W, X), this.rects = r.program(Se, Ce, X), this.seriesBuffer = r.buffer(), this.columnBuffer = r.buffer(), this.rectBuffer = r.buffer(), this.drawer = new le(r), e.addEventListener("webglcontextlost", this.handleLost);
1565
+ }
1566
+ onLost(e) {
1567
+ this.lostCallback = e, (this.lost || this.gl.isContextLost()) && (this.lost = !0, queueMicrotask(() => {
1568
+ this.lostCallback === e && e();
1569
+ }));
1570
+ }
1571
+ recorder(e, t) {
1572
+ return _e(e, t);
1573
+ }
1574
+ render(e) {
1575
+ let t = this.gl;
1576
+ if (this.lost || t.isContextLost()) return {
1577
+ series: !1,
1578
+ volume: !1,
1579
+ background: !1,
1580
+ recorded: !1,
1581
+ under: !1
1582
+ };
1583
+ let n = Z(e.recorded) ? e.recorded : null, r = Z(e.under) ? e.under : null, i = {
1584
+ series: e.candles,
1585
+ volume: e.volume !== null,
1586
+ background: e.background !== null,
1587
+ recorded: n !== null,
1588
+ under: r !== null
1589
+ };
1590
+ return t.viewport(0, 0, this.canvas.width, this.canvas.height), t.disable(t.SCISSOR_TEST), t.clearColor(0, 0, 0, 0), t.clear(t.COLOR_BUFFER_BIT), t.enable(t.BLEND), e.background && this.drawBackground(e, e.background), r && this.drawRecorded(e, r), this.drawSeries(e), n && this.drawRecorded(e, n), i;
1591
+ }
1592
+ drawSeries(t) {
1593
+ let n = this.gl, { data: r, viewport: i, dpr: a } = t;
1594
+ if (r.length === 0 || !t.candles && !t.volume) return;
1595
+ this.syncSeries(t);
1596
+ let o = Math.max(0, i.visibleRange.from), s = Math.min(i.visibleRange.to, r.length - 1);
1597
+ if (s < o) return;
1598
+ let { chartRect: c } = i;
1599
+ this.clip = [
1600
+ c.x * a,
1601
+ c.y * a,
1602
+ (c.x + c.width) * a,
1603
+ (c.y + c.height) * a
1604
+ ];
1605
+ let l = Math.floor(this.clip[0]), u = Math.floor(this.clip[1]), d = Math.ceil(this.clip[2]) - l, f = Math.ceil(this.clip[3]) - u;
1606
+ n.enable(n.SCISSOR_TEST), n.scissor(l, this.canvas.height - u - f, Math.max(0, d), Math.max(0, f)), n.blendFunc(n.ONE, n.ONE_MINUS_SRC_ALPHA);
1607
+ let p = e(i), m = p ? this.buildColumns(t, o, s) : 0;
1608
+ t.volume && this.drawVolume(t, o, s, p, m);
1609
+ let { min: h, max: g } = i.priceRange;
1610
+ t.candles && g - h !== 0 && this.drawCandles(t, o, s, p, m), n.disable(n.SCISSOR_TEST);
1611
+ }
1612
+ drawRecorded(e, t) {
1613
+ t.commands.length !== 0 && this.drawer.draw(t.commands, this.canvas.width, this.canvas.height, (t, n) => this.drawRecordedRects(e, t, n));
1614
+ }
1615
+ drawRecordedRects(e, t, n) {
1616
+ let r = this.gl, i = this.use(this.rects, e);
1617
+ this.kit.float(i, "u_dpr", 1), this.kit.int(i, "u_union", 0), r.bindBuffer(r.ARRAY_BUFFER, this.rectBuffer), r.bufferData(r.ARRAY_BUFFER, t, r.STREAM_DRAW), this.bindRects(i, 0), r.drawArraysInstanced(r.TRIANGLES, 0, 6, n);
1618
+ }
1619
+ destroy() {
1620
+ this.canvas.removeEventListener("webglcontextlost", this.handleLost), this.lostCallback = null;
1621
+ let e = this.gl;
1622
+ if (!e.isContextLost()) {
1623
+ for (let e of [
1624
+ this.candleBars,
1625
+ this.volumeBars,
1626
+ this.candleColumns,
1627
+ this.volumeColumns,
1628
+ this.rects
1629
+ ]) this.kit.deleteProgram(e);
1630
+ this.drawer.destroy(), e.deleteBuffer(this.seriesBuffer), e.deleteBuffer(this.columnBuffer), e.deleteBuffer(this.rectBuffer), Q(e);
1631
+ }
1632
+ this.canvas.remove();
1633
+ }
1634
+ handleLost = (e) => {
1635
+ e.preventDefault(), !this.lost && (this.lost = !0, this.lostCallback?.());
1636
+ };
1637
+ syncSeries(e) {
1638
+ let t = this.gl, n = this.uploads.sync(e.data), r = this.uploads.values;
1639
+ t.bindBuffer(t.ARRAY_BUFFER, this.seriesBuffer), n.full || r.length !== this.gpuFloats ? (t.bufferData(t.ARRAY_BUFFER, r, t.DYNAMIC_DRAW), this.gpuFloats = r.length) : n.to > n.from && t.bufferSubData(t.ARRAY_BUFFER, n.from * G, r, n.from * 6, (n.to - n.from) * 6);
1640
+ }
1641
+ buildColumns(e, t, r) {
1642
+ let { viewport: i, data: a } = e, o = i.barWidth + i.barSpacing, s = -i.offset + i.chartRect.x + i.barWidth / 2, c = this.uploads.base, l = 0;
1643
+ n(a, t, r, (e) => e * o + s, (e) => {
1644
+ if ((l + 1) * K > this.columns.length) {
1645
+ let e = new Float32Array(this.columns.length * 2);
1646
+ e.set(this.columns), this.columns = e;
1647
+ }
1648
+ let t = l * K;
1649
+ this.columns[t] = e.x, this.columns[t + 1] = e.high - c, this.columns[t + 2] = e.low - c, this.columns[t + 3] = e.volume, this.columns[t + 4] = +(e.close >= e.open), l++;
1650
+ });
1651
+ let u = this.gl;
1652
+ return u.bindBuffer(u.ARRAY_BUFFER, this.columnBuffer), u.bufferData(u.ARRAY_BUFFER, this.columns.subarray(0, l * K), u.STREAM_DRAW), l;
1653
+ }
1654
+ drawBackground(e, t) {
1655
+ let { viewport: n, theme: r } = e, a = t.grid ? i(n) : {
1656
+ horizontal: [],
1657
+ vertical: []
1658
+ }, o = a.horizontal.length + a.vertical.length, s = o + t.rects.length;
1659
+ if (s === 0) return;
1660
+ this.rectValues.length < s * J && (this.rectValues = new Float32Array(s * J * 2));
1661
+ let c = this.rectValues, l = 0, u = (e, t, n, r, i, a, o) => {
1662
+ c[l++] = e, c[l++] = t, c[l++] = n, c[l++] = r;
1663
+ for (let e = 0; e < 4; e++) c[l++] = i[e] * a;
1664
+ c[l++] = o ? o[0] : 0, c[l++] = o ? o[1] : 0;
1665
+ }, d = _(g(r.grid)), { chartRect: f } = n;
1666
+ for (let e of a.horizontal) u(f.x, e - .5, f.x + f.width, e + .5, d, 1);
1667
+ for (let e of a.vertical) u(e - .5, f.y, e + .5, f.y + f.height, d, 1);
1668
+ let p = "", m = d;
1669
+ for (let e of t.rects) e.color !== p && (p = e.color, m = _(g(e.color))), u(e.x, e.y, e.x + e.width, e.y + e.height, m, e.alpha, e.dash);
1670
+ let h = this.gl, v = this.use(this.rects, e);
1671
+ h.bindBuffer(h.ARRAY_BUFFER, this.rectBuffer), h.bufferData(h.ARRAY_BUFFER, c.subarray(0, l), h.STREAM_DRAW), o > 0 && (h.uniform1i(this.loc(v, "u_union"), 1), h.blendColor(0, 0, 0, d[3]), h.blendFuncSeparate(h.ONE, h.ONE_MINUS_SRC_ALPHA, h.CONSTANT_ALPHA, h.ONE_MINUS_SRC_ALPHA), this.bindRects(v, 0), h.drawArraysInstanced(h.TRIANGLES, 0, 6, o)), t.rects.length > 0 && (h.uniform1i(this.loc(v, "u_union"), 0), h.blendFunc(h.ONE, h.ONE_MINUS_SRC_ALPHA), this.bindRects(v, o), h.drawArraysInstanced(h.TRIANGLES, 0, 6, t.rects.length));
1672
+ }
1673
+ drawCandles(e, t, n, r, i) {
1674
+ let { theme: a, viewport: o, dpr: s } = e, c = _(g(a.candleUp)), l = _(g(a.candleDown));
1675
+ if (r) {
1676
+ let t = this.use(this.candleColumns, e);
1677
+ this.vec4(t, "u_upBody", c), this.vec4(t, "u_downBody", l), this.bindColumns(t), this.gl.drawArraysInstanced(this.gl.TRIANGLES, 0, 6, i);
1678
+ return;
1679
+ }
1680
+ let u = this.use(this.candleBars, e);
1681
+ this.barUniforms(u, o, t, s), this.vec4(u, "u_upBody", c), this.vec4(u, "u_downBody", l), this.vec4(u, "u_upWick", _(g(a.candleUpWick))), this.vec4(u, "u_downWick", _(g(a.candleDownWick))), this.bindBars(u, t), this.gl.drawArraysInstanced(this.gl.TRIANGLES, 0, 12, n - t + 1);
1682
+ }
1683
+ drawVolume(e, t, n, r, i) {
1684
+ let { data: o, viewport: s, theme: c, dpr: l } = e, u = 0;
1685
+ for (let e = t; e <= n; e++) o[e].volume > u && (u = o[e].volume);
1686
+ if (u === 0) return;
1687
+ let { chartRect: d } = s, f = a(c), p = this.use(r ? this.volumeColumns : this.volumeBars, e);
1688
+ if (this.float(p, "u_volBottom", d.y + d.height), this.float(p, "u_volScale", d.height * (e.volume?.heightRatio ?? .15) / u), this.vec4(p, "u_volUp", _(g(f.up))), this.vec4(p, "u_volDown", _(g(f.down))), r) {
1689
+ this.bindColumns(p), this.gl.drawArraysInstanced(this.gl.TRIANGLES, 0, 6, i);
1690
+ return;
1691
+ }
1692
+ this.barUniforms(p, s, t, l), this.bindBars(p, t), this.gl.drawArraysInstanced(this.gl.TRIANGLES, 0, 6, n - t + 1);
1693
+ }
1694
+ barUniforms(e, t, n, i) {
1695
+ let a = t.barWidth + t.barSpacing, o = -t.offset + t.chartRect.x + t.barWidth / 2, { body: s, wick: c } = r(t.barWidth, i);
1696
+ this.float(e, "u_x0", n * a + o), this.float(e, "u_unit", a), this.float(e, "u_wick", c), this.float(e, "u_body", s);
1697
+ }
1698
+ use(e, t) {
1699
+ let n = this.gl;
1700
+ this.kit.use(e), n.uniform2f(this.loc(e, "u_canvas"), this.canvas.width, this.canvas.height), this.vec4(e, "u_clip", this.clip), this.float(e, "u_dpr", t.dpr);
1701
+ let r = v(t.viewport, this.uploads.base);
1702
+ return n.uniform1i(this.loc(e, "u_log"), r.log), n.uniform1i(this.loc(e, "u_invert"), r.invert), this.float(e, "u_yA", r.yA), this.float(e, "u_yB", r.yB), this.float(e, "u_logOffset", r.logOffset), this.float(e, "u_min", r.min), this.float(e, "u_logFloor", r.logFloor), this.float(e, "u_logK", r.logK), this.float(e, "u_top", r.top), this.float(e, "u_bottom", r.bottom), e;
1703
+ }
1704
+ bindBars(e, t) {
1705
+ let n = this.gl;
1706
+ n.bindBuffer(n.ARRAY_BUFFER, this.seriesBuffer), this.attrib(e, "a_ohlc", 4, G, t * G), this.attrib(e, "a_vd", 2, G, t * G + 16);
1707
+ }
1708
+ bindRects(e, t) {
1709
+ this.attrib(e, "a_rect", 4, Y, t * Y), this.attrib(e, "a_color", 4, Y, t * Y + 16), this.attrib(e, "a_dash", 2, Y, t * Y + 32);
1710
+ }
1711
+ bindColumns(e) {
1712
+ let t = this.gl;
1713
+ t.bindBuffer(t.ARRAY_BUFFER, this.columnBuffer), this.attrib(e, "a_col", 4, q, 0), this.attrib(e, "a_up", 1, q, 16);
1714
+ }
1715
+ attrib(e, t, n, r, i) {
1716
+ this.kit.attrib(e, t, n, r, i);
1717
+ }
1718
+ float(e, t, n) {
1719
+ this.kit.float(e, t, n);
1720
+ }
1721
+ vec4(e, t, n) {
1722
+ this.kit.vec4(e, t, n);
1723
+ }
1724
+ loc(e, t) {
1725
+ return this.kit.loc(e, t);
1726
+ }
1727
+ };
1728
+ function Z(e) {
1729
+ return typeof e == "object" && !!e && Array.isArray(e.commands);
1730
+ }
1731
+ function Q(e) {
1732
+ e.getExtension("WEBGL_lose_context")?.loseContext();
1733
+ }
1734
+ function $(e) {
1735
+ console.warn("TradeCanvas: WebGL renderer unavailable, drawing with Canvas 2D.", e);
1736
+ }
1737
+ //#endregion
1738
+ export { we as WebGLSeriesRenderer };
1739
+
1740
+ //# sourceMappingURL=WebGLSeriesRenderer-DVJBHdfm.js.map