textmode.js 0.2.1-beta.4 → 0.2.1-beta.5

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 (34) hide show
  1. package/dist/textmode.esm.js +2133 -1834
  2. package/dist/textmode.esm.min.js +1849 -1549
  3. package/dist/textmode.umd.js +9 -9
  4. package/dist/textmode.umd.min.js +8 -7
  5. package/dist/types/assets/shaders-minified/frag/image-to-mrt.d.ts +14 -0
  6. package/dist/types/assets/shaders-minified/frag/present.d.ts +14 -0
  7. package/dist/types/assets/shaders-minified/index.d.ts +2 -0
  8. package/dist/types/index.d.ts +1 -0
  9. package/dist/types/rendering/index.d.ts +0 -2
  10. package/dist/types/rendering/webgl/DrawQueue.d.ts +9 -7
  11. package/dist/types/rendering/webgl/InstanceData.d.ts +15 -15
  12. package/dist/types/rendering/webgl/RenderPipeline.d.ts +1 -0
  13. package/dist/types/rendering/webgl/RenderState.d.ts +13 -19
  14. package/dist/types/rendering/webgl/Renderer.d.ts +13 -2
  15. package/dist/types/rendering/webgl/Shader.d.ts +3 -4
  16. package/dist/types/rendering/webgl/ShaderManager.d.ts +12 -11
  17. package/dist/types/rendering/webgl/geometries/BaseGeometry.d.ts +2 -1
  18. package/dist/types/rendering/webgl/types/DrawCommand.d.ts +2 -2
  19. package/dist/types/textmode/Canvas.d.ts +6 -0
  20. package/dist/types/textmode/TextmodeImage.d.ts +92 -0
  21. package/dist/types/textmode/Textmodifier.d.ts +17 -2
  22. package/dist/types/textmode/font/CharacterExtractor.d.ts +14 -14
  23. package/dist/types/textmode/font/MetricsCalculator.d.ts +1 -21
  24. package/dist/types/textmode/font/typr/Typr.d.ts +2 -0
  25. package/dist/types/textmode/font/typr/types.d.ts +6 -0
  26. package/dist/types/textmode/font/utils/index.d.ts +0 -1
  27. package/dist/types/textmode/mixins/AnimationMixin.d.ts +6 -0
  28. package/dist/types/textmode/mixins/FontMixin.d.ts +43 -3
  29. package/dist/types/textmode/mixins/KeyboardMixin.d.ts +2 -3
  30. package/dist/types/textmode/mixins/MouseMixin.d.ts +6 -6
  31. package/dist/types/textmode/mixins/RenderingMixin.d.ts +23 -5
  32. package/package.json +1 -1
  33. package/dist/types/rendering/webgl/types/ShaderTypes.d.ts +0 -35
  34. package/dist/types/textmode/font/utils/CmapParser.d.ts +0 -47
@@ -1,310 +1,304 @@
1
- var Q = Object.defineProperty;
2
- var tt = (a, t, e) => t in a ? Q(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e;
3
- var c = (a, t, e) => tt(a, typeof t != "symbol" ? t + "" : t, e);
4
- class E extends Error {
1
+ var ct = Object.defineProperty;
2
+ var lt = (h, t, e) => t in h ? ct(h, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : h[t] = e;
3
+ var a = (h, t, e) => lt(h, typeof t != "symbol" ? t + "" : t, e);
4
+ class U extends Error {
5
5
  constructor(t, e = {}) {
6
- super(E.u(t, e)), this.name = "TextmodeError";
6
+ super(U.i(t, e)), this.name = "TextmodeError";
7
7
  }
8
- static u(t, e) {
8
+ static i(t, e) {
9
9
  return `${t}${e && Object.keys(e).length > 0 ? `
10
10
 
11
- 📋 Context:` + Object.entries(e).map(([i, r]) => `
12
- - ${i}: ${E._(r)}`).join("") : ""}
11
+ 📋 Context:` + Object.entries(e).map(([i, s]) => `
12
+ - ${i}: ${U.o(s)}`).join("") : ""}
13
13
 
14
14
  ${"↓".repeat(24)}
15
15
  `;
16
16
  }
17
- static _(t) {
17
+ static o(t) {
18
18
  if (t === null) return "null";
19
19
  if (t === void 0) return "undefined";
20
20
  if (typeof t == "string") return `"${t}"`;
21
21
  if (typeof t == "number" || typeof t == "boolean") return t + "";
22
- if (Array.isArray(t)) return t.length === 0 ? "[]" : t.length <= 5 ? `[${t.map((e) => E._(e)).join(", ")}]` : `[${t.slice(0, 3).map((e) => E._(e)).join(", ")}, ... +${t.length - 3} more]`;
22
+ if (Array.isArray(t)) return t.length === 0 ? "[]" : t.length <= 5 ? `[${t.map((e) => U.o(e)).join(", ")}]` : `[${t.slice(0, 3).map((e) => U.o(e)).join(", ")}, ... +${t.length - 3} more]`;
23
23
  if (typeof t == "object") {
24
24
  const e = Object.keys(t);
25
- return e.length === 0 ? "{}" : e.length <= 3 ? `{ ${e.map((i) => `${i}: ${E._(t[i])}`).join(", ")} }` : `{ ${e.slice(0, 2).map((i) => `${i}: ${E._(t[i])}`).join(", ")}, ... +${e.length - 2} more }`;
25
+ return e.length === 0 ? "{}" : e.length <= 3 ? `{ ${e.map((i) => `${i}: ${U.o(t[i])}`).join(", ")} }` : `{ ${e.slice(0, 2).map((i) => `${i}: ${U.o(t[i])}`).join(", ")}, ... +${e.length - 2} more }`;
26
26
  }
27
27
  return t + "";
28
28
  }
29
29
  }
30
- var et = ((a) => (a[a.SILENT = 0] = "SILENT", a[a.WARNING = 1] = "WARNING", a[a.ERROR = 2] = "ERROR", a[a.THROW = 3] = "THROW", a))(et || {});
31
- const F = class F {
30
+ var ut = ((h) => (h[h.SILENT = 0] = "SILENT", h[h.WARNING = 1] = "WARNING", h[h.ERROR = 2] = "ERROR", h[h.THROW = 3] = "THROW", h))(ut || {});
31
+ const I = class I {
32
32
  constructor() {
33
- c(this, "$", { globalLevel: 3 });
33
+ a(this, "u", { globalLevel: 3 });
34
34
  }
35
- static C() {
36
- return F.v || (F.v = new F()), F.v;
35
+ static _() {
36
+ return I.l || (I.l = new I()), I.l;
37
37
  }
38
- R(t, e) {
39
- const i = "%c[textmode.js] Oops! (╯°□°)╯︵ Something went wrong in your code.", r = "color: #f44336; font-weight: bold; background: #ffebee; padding: 2px 6px; border-radius: 3px;";
40
- switch (this.$.globalLevel) {
38
+ m(t, e) {
39
+ const i = "%c[textmode.js] Oops! (╯°□°)╯︵ Something went wrong in your code.", s = "color: #f44336; font-weight: bold; background: #ffebee; padding: 2px 6px; border-radius: 3px;";
40
+ switch (this.u.globalLevel) {
41
41
  case 0:
42
42
  return !1;
43
43
  case 1:
44
- return console.group(i, r), console.warn(E.u(t, e)), console.groupEnd(), !1;
44
+ return console.group(i, s), console.warn(U.i(t, e)), console.groupEnd(), !1;
45
45
  case 2:
46
- return console.group(i, r), console.error(E.u(t, e)), console.groupEnd(), !1;
46
+ return console.group(i, s), console.error(U.i(t, e)), console.groupEnd(), !1;
47
47
  default:
48
- throw new E(t, e);
48
+ throw new U(t, e);
49
49
  }
50
50
  }
51
- M(t, e, i) {
52
- return !!t || (this.R(e, i), !1);
51
+ v(t, e, i) {
52
+ return !!t || (this.m(e, i), !1);
53
53
  }
54
- S(t) {
55
- this.$.globalLevel = t;
54
+ C(t) {
55
+ this.u.globalLevel = t;
56
56
  }
57
57
  };
58
- c(F, "v", null);
59
- let B = F;
60
- const M = B.C(), Z = /* @__PURE__ */ new WeakMap();
61
- function U(a, t) {
62
- Z.set(a, t);
58
+ a(I, "l", null);
59
+ let j = I;
60
+ const $ = j._(), ot = /* @__PURE__ */ new WeakMap();
61
+ function W(h, t) {
62
+ ot.set(h, t);
63
63
  }
64
- function I(a) {
65
- return Z.get(a);
64
+ function X(h) {
65
+ return ot.get(h);
66
66
  }
67
- class j {
67
+ class ht {
68
68
  constructor() {
69
- c(this, "F", 1);
70
- c(this, "P", 0);
71
- c(this, "A", 0);
72
- c(this, "G", 0);
73
- c(this, "L", [0, 0, 0]);
74
- c(this, "D", [1, 1, 1, 1]);
75
- c(this, "W", [0, 0, 0, 1]);
76
- c(this, "I", !1);
77
- c(this, "U", !1);
78
- c(this, "V", !1);
79
- c(this, "O", [0, 0]);
80
- c(this, "H", [0, 0, 0, 1]);
81
- c(this, "K", []);
82
- }
83
- N() {
84
- this.K.push({ X: this.F, Y: this.P, Z: this.A, J: this.G, O: [...this.O], I: this.I, U: this.U, V: this.V, tt: [...this.L], et: [...this.D], st: [...this.W] });
85
- }
86
- it() {
87
- const t = this.K.pop();
88
- t ? (this.F = t.X, this.P = t.Y, this.A = t.Z, this.G = t.J, this.O = t.O, this.I = t.I, this.U = t.U, this.V = t.V, this.L = t.tt, this.D = t.et, this.W = t.st) : console.warn("pop() called without matching push()");
89
- }
90
- rt() {
91
- this.K = [], this.P = 0, this.A = 0, this.G = 0;
92
- }
93
- nt(t) {
94
- t.lineWeight = this.F, t.rotationX = this.P, t.rotationY = this.A, t.rotationZ = this.G, t.character[0] = this.L[0], t.character[1] = this.L[1], t.character[2] = this.L[2], t.charColor[0] = this.D[0], t.charColor[1] = this.D[1], t.charColor[2] = this.D[2], t.charColor[3] = this.D[3], t.bgColor[0] = this.W[0], t.bgColor[1] = this.W[1], t.bgColor[2] = this.W[2], t.bgColor[3] = this.W[3], t.flipHorizontally = this.I, t.flipVertically = this.U, t.invert = this.V, t.charRotation[0] = this.O[0], t.charRotation[1] = this.O[1];
69
+ a(this, "$", 1);
70
+ a(this, "U", 0);
71
+ a(this, "F", 0);
72
+ a(this, "M", 0);
73
+ a(this, "R", [0, 0, 0]);
74
+ a(this, "S", [1, 1, 1, 1]);
75
+ a(this, "A", [0, 0, 0, 1]);
76
+ a(this, "L", !1);
77
+ a(this, "k", !1);
78
+ a(this, "P", !1);
79
+ a(this, "G", [0, 0]);
80
+ a(this, "D", [0, 0, 0, 1]);
81
+ a(this, "I", []);
82
+ }
83
+ W() {
84
+ this.I.push({ O: this.$, H: this.U, V: this.F, K: this.M, G: [...this.G], N: this.L, X: this.k, P: this.P, j: [...this.R], Y: [...this.S], q: [...this.A] });
85
+ }
86
+ Z() {
87
+ const t = this.I.pop();
88
+ t ? (this.$ = t.O, this.U = t.H, this.F = t.V, this.M = t.K, this.G = t.G, this.L = t.N, this.k = t.X, this.P = t.P, this.R = t.j, this.S = t.Y, this.A = t.q) : console.warn("pop() called without matching push()");
89
+ }
90
+ J(t) {
91
+ t.O = this.$, t.H = this.U, t.V = this.F, t.K = this.M, t.j[0] = this.R[0], t.j[1] = this.R[1], t.j[2] = this.R[2], t.Y[0] = this.S[0], t.Y[1] = this.S[1], t.Y[2] = this.S[2], t.Y[3] = this.S[3], t.q[0] = this.A[0], t.q[1] = this.A[1], t.q[2] = this.A[2], t.q[3] = this.A[3], t.N = this.L, t.X = this.k, t.P = this.P, t.G[0] = this.G[0], t.G[1] = this.G[1];
95
92
  }
96
93
  get lineWeight() {
97
- return this.F;
94
+ return this.$;
98
95
  }
99
96
  get canvasBackgroundColor() {
100
- return this.H;
97
+ return this.D;
101
98
  }
102
- ot(t) {
103
- this.F = Math.abs(t);
99
+ tt(t) {
100
+ this.$ = Math.abs(t);
104
101
  }
105
- ht(t) {
106
- this.P = t;
102
+ et(t) {
103
+ this.U = t;
107
104
  }
108
- ct(t) {
109
- this.A = t;
105
+ st(t) {
106
+ this.F = t;
110
107
  }
111
- lt(t) {
112
- this.G = t;
108
+ it(t) {
109
+ this.M = t;
113
110
  }
114
- ut(t) {
115
- this.L = t;
111
+ rt(t) {
112
+ this.R = t;
116
113
  }
117
- ft(t, e, i, r = 255) {
118
- this.D = [t / 255, e / 255, i / 255, r / 255];
114
+ nt(t, e, i, s = 255) {
115
+ this.S = [t / 255, e / 255, i / 255, s / 255];
119
116
  }
120
- dt(t, e, i, r = 255) {
121
- this.W = [t / 255, e / 255, i / 255, r / 255];
117
+ ot(t, e, i, s = 255) {
118
+ this.A = [t / 255, e / 255, i / 255, s / 255];
122
119
  }
123
- _t(t) {
124
- this.I = t;
120
+ ht(t) {
121
+ this.L = t;
125
122
  }
126
- gt(t) {
127
- this.U = t;
123
+ ct(t) {
124
+ this.k = t;
128
125
  }
129
- vt(t) {
130
- this.V = t;
126
+ lt(t) {
127
+ this.P = t;
131
128
  }
132
- yt(t) {
133
- const e = 255 * t / 360, i = Math.floor(e) / 255, r = Math.round(e - Math.floor(e));
134
- this.O = [i, r];
129
+ ut(t) {
130
+ const e = 255 * t / 360, i = Math.floor(e) / 255, s = Math.round(e - Math.floor(e));
131
+ this.G = [i, s];
135
132
  }
136
- $t(t, e, i, r) {
137
- this.H = [t / 255, e / 255, i / 255, r / 255];
133
+ ft(t, e, i, s) {
134
+ this.D = [t / 255, e / 255, i / 255, s / 255];
138
135
  }
139
136
  }
140
- class D {
141
- constructor(t, e, i = e, r = 1, s = {}, n = null, o = !1) {
142
- c(this, "Ct");
143
- c(this, "wt");
144
- c(this, "$");
145
- c(this, "xt", null);
146
- c(this, "bt");
147
- c(this, "Rt");
148
- c(this, "Mt", []);
149
- c(this, "St");
150
- c(this, "Ft", null);
151
- c(this, "zt", []);
152
- c(this, "kt", null);
153
- c(this, "Pt", !1);
154
- c(this, "Tt", null);
155
- this.Ct = e, this.wt = i, this.$ = { filter: "nearest", wrap: "clamp", format: "rgba", type: "unsigned_byte", ...s }, this.bt = t, this.St = Math.min(Math.max(1, r), 8), this.kt = n, this.Pt = !!o, this.Tt = this.Pt ? new j() : null;
156
- const h = t.getParameter(t.MAX_DRAW_BUFFERS), l = t.getParameter(t.MAX_COLOR_ATTACHMENTS);
157
- this.St = Math.min(this.St, h, l), this.Rt = t.createFramebuffer(), this.At(), this.Gt(), this.zt = Array(this.St).fill(null);
158
- }
159
- At() {
160
- const t = this.bt, e = this.$.filter === "linear" ? t.LINEAR : t.NEAREST, i = this.$.wrap === "repeat" ? t.REPEAT : t.CLAMP_TO_EDGE, r = this.$.type === "float" ? t.FLOAT : t.UNSIGNED_BYTE;
161
- for (let s = 0; s < this.St; s++) {
137
+ class K {
138
+ constructor(t, e, i = e, s = 1, r = {}, n = null, o = !1) {
139
+ a(this, "dt");
140
+ a(this, "_t");
141
+ a(this, "u");
142
+ a(this, "gt", null);
143
+ a(this, "vt");
144
+ a(this, "yt");
145
+ a(this, "Ct", []);
146
+ a(this, "wt");
147
+ a(this, "$t", null);
148
+ a(this, "bt", []);
149
+ a(this, "xt", null);
150
+ a(this, "Ft", !1);
151
+ a(this, "Mt", null);
152
+ this.dt = e, this._t = i, this.u = { filter: "nearest", wrap: "clamp", format: "rgba", type: "unsigned_byte", ...r }, this.vt = t, this.wt = Math.min(Math.max(1, s), 8), this.xt = n, this.Ft = !!o, this.Mt = this.Ft ? new ht() : null;
153
+ const c = t.getParameter(t.MAX_DRAW_BUFFERS), l = t.getParameter(t.MAX_COLOR_ATTACHMENTS);
154
+ this.wt = Math.min(this.wt, c, l), this.yt = t.createFramebuffer(), this.Rt(), this.St(), this.bt = Array(this.wt).fill(null);
155
+ }
156
+ Rt() {
157
+ const t = this.vt, e = this.u.filter === "linear" ? t.LINEAR : t.NEAREST, i = this.u.wrap === "repeat" ? t.REPEAT : t.CLAMP_TO_EDGE, s = this.u.type === "float" ? t.FLOAT : t.UNSIGNED_BYTE;
158
+ for (let r = 0; r < this.wt; r++) {
162
159
  const n = t.createTexture();
163
- t.bindTexture(t.TEXTURE_2D, n), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, e), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, e), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, i), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, i), t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, this.Ct, this.wt, 0, t.RGBA, r, null), this.Mt.push(n);
160
+ t.bindTexture(t.TEXTURE_2D, n), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, e), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, e), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, i), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, i), t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, this.dt, this._t, 0, t.RGBA, s, null), this.Ct.push(n);
164
161
  }
165
162
  t.bindTexture(t.TEXTURE_2D, null);
166
163
  }
167
- Gt() {
168
- const t = this.bt;
169
- if (t.bindFramebuffer(t.FRAMEBUFFER, this.Rt), this.St === 1) t.framebufferTexture2D(t.FRAMEBUFFER, t.COLOR_ATTACHMENT0, t.TEXTURE_2D, this.Mt[0], 0);
164
+ St() {
165
+ const t = this.vt;
166
+ if (t.bindFramebuffer(t.FRAMEBUFFER, this.yt), this.wt === 1) t.framebufferTexture2D(t.FRAMEBUFFER, t.COLOR_ATTACHMENT0, t.TEXTURE_2D, this.Ct[0], 0);
170
167
  else {
171
168
  const i = [];
172
- for (let r = 0; r < this.St; r++) {
173
- const s = t.COLOR_ATTACHMENT0 + r;
174
- t.framebufferTexture2D(t.FRAMEBUFFER, s, t.TEXTURE_2D, this.Mt[r], 0), i.push(s);
169
+ for (let s = 0; s < this.wt; s++) {
170
+ const r = t.COLOR_ATTACHMENT0 + s;
171
+ t.framebufferTexture2D(t.FRAMEBUFFER, r, t.TEXTURE_2D, this.Ct[s], 0), i.push(r);
175
172
  }
176
173
  t.drawBuffers(i);
177
174
  }
178
175
  const e = t.checkFramebufferStatus(t.FRAMEBUFFER);
179
176
  e !== t.FRAMEBUFFER_COMPLETE && console.error("GLFramebuffer is not complete:", e), t.bindFramebuffer(t.FRAMEBUFFER, null);
180
177
  }
181
- Lt(t) {
182
- const e = this.bt;
183
- e.bindTexture(e.TEXTURE_2D, this.Mt[0]), e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL, 1), e.texImage2D(e.TEXTURE_2D, 0, e.RGBA, e.RGBA, e.UNSIGNED_BYTE, t), e.bindTexture(e.TEXTURE_2D, null);
178
+ At(t) {
179
+ const e = this.vt;
180
+ e.bindTexture(e.TEXTURE_2D, this.Ct[0]), e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL, 1), e.texImage2D(e.TEXTURE_2D, 0, e.RGBA, e.RGBA, e.UNSIGNED_BYTE, t), e.bindTexture(e.TEXTURE_2D, null);
184
181
  }
185
182
  resize(t, e) {
186
- this.Ct = t, this.wt = e, this.xt = null, this.zt = Array(this.St).fill(null);
187
- const i = this.bt, r = this.$.type === "float" ? i.FLOAT : i.UNSIGNED_BYTE;
188
- for (const s of this.Mt) i.bindTexture(i.TEXTURE_2D, s), i.texImage2D(i.TEXTURE_2D, 0, i.RGBA, this.Ct, this.wt, 0, i.RGBA, r, null);
183
+ this.dt = t, this._t = e, this.gt = null, this.bt = Array(this.wt).fill(null);
184
+ const i = this.vt, s = this.u.type === "float" ? i.FLOAT : i.UNSIGNED_BYTE;
185
+ for (const r of this.Ct) i.bindTexture(i.TEXTURE_2D, r), i.texImage2D(i.TEXTURE_2D, 0, i.RGBA, this.dt, this._t, 0, i.RGBA, s, null);
189
186
  i.bindTexture(i.TEXTURE_2D, null);
190
187
  }
191
- Et(t) {
192
- const e = this.bt, i = this.zt[t];
188
+ zt(t) {
189
+ const e = this.vt, i = this.bt[t];
193
190
  if (i) return i;
194
- const r = this.Ct, s = this.wt, n = new Uint8Array(r * s * 4), o = e.getParameter(e.READ_FRAMEBUFFER_BINDING);
195
- e.bindFramebuffer(e.READ_FRAMEBUFFER, this.Rt), e.readBuffer(e.COLOR_ATTACHMENT0 + t), e.readPixels(0, 0, r, s, e.RGBA, e.UNSIGNED_BYTE, n), e.bindFramebuffer(e.READ_FRAMEBUFFER, o);
196
- const h = 4 * r, l = new Uint8Array(n.length);
197
- for (let u = 0; u < s; u++) {
198
- const f = (s - 1 - u) * h, d = u * h;
199
- l.set(n.subarray(f, f + h), d);
191
+ const s = this.dt, r = this._t, n = new Uint8Array(s * r * 4), o = e.getParameter(e.READ_FRAMEBUFFER_BINDING);
192
+ e.bindFramebuffer(e.READ_FRAMEBUFFER, this.yt), e.readBuffer(e.COLOR_ATTACHMENT0 + t), e.readPixels(0, 0, s, r, e.RGBA, e.UNSIGNED_BYTE, n), e.bindFramebuffer(e.READ_FRAMEBUFFER, o);
193
+ const c = 4 * s, l = new Uint8Array(n.length);
194
+ for (let f = 0; f < r; f++) {
195
+ const u = (r - 1 - f) * c, g = f * c;
196
+ l.set(n.subarray(u, u + c), g);
200
197
  }
201
- return this.zt[t] = l, l;
198
+ return this.bt[t] = l, l;
202
199
  }
203
200
  begin() {
204
- var e, i, r, s;
205
- const t = this.bt;
206
- if (this.kt) {
207
- const n = ((i = (e = this.kt).Bt) == null ? void 0 : i.call(e)) ?? null;
208
- n && this.kt.Dt(n), this.Pt && this.Tt && ((s = (r = this.kt).Wt) == null || s.call(r, this.Tt));
201
+ var e, i, s, r;
202
+ const t = this.vt;
203
+ if (this.xt) {
204
+ const n = ((i = (e = this.xt).Tt) == null ? void 0 : i.call(e)) ?? null;
205
+ n && this.xt.Et(n), this.Ft && this.Mt && ((r = (s = this.xt).Lt) == null || r.call(s, this.Mt));
209
206
  }
210
- this.Ft = { framebuffer: t.getParameter(t.FRAMEBUFFER_BINDING), viewport: t.getParameter(t.VIEWPORT) }, t.bindFramebuffer(t.FRAMEBUFFER, this.Rt), this.zt = Array(this.St).fill(null);
211
- for (let n = 0; n < this.St; n++) t.clearBufferfv(t.COLOR, n, new Float32Array([0, 0, 0, 0]));
212
- t.viewport(0, 0, this.Ct, this.wt), U(t, [0, 0, this.Ct, this.wt]);
207
+ this.$t = { framebuffer: t.getParameter(t.FRAMEBUFFER_BINDING), viewport: t.getParameter(t.VIEWPORT) }, t.bindFramebuffer(t.FRAMEBUFFER, this.yt), this.bt = Array(this.wt).fill(null);
208
+ for (let n = 0; n < this.wt; n++) t.clearBufferfv(t.COLOR, n, new Float32Array([0, 0, 0, 0]));
209
+ t.viewport(0, 0, this.dt, this._t), W(t, [0, 0, this.dt, this._t]);
213
210
  }
214
211
  end() {
215
- var e, i, r, s;
216
- if (!this.Ft) return;
217
- const t = this.bt;
218
- if (this.kt) {
219
- const n = ((i = (e = this.kt).Bt) == null ? void 0 : i.call(e)) ?? null;
220
- n && this.kt.Dt(n);
212
+ var e, i, s, r;
213
+ if (!this.$t) return;
214
+ const t = this.vt;
215
+ if (this.xt) {
216
+ const n = ((i = (e = this.xt).Tt) == null ? void 0 : i.call(e)) ?? null;
217
+ n && this.xt.Et(n);
221
218
  }
222
- t.bindFramebuffer(t.FRAMEBUFFER, this.Ft.framebuffer), t.viewport(...this.Ft.viewport), U(t, this.Ft.viewport), this.Ft = null, this.kt && this.Pt && this.Tt && ((s = (r = this.kt).It) == null || s.call(r));
219
+ t.bindFramebuffer(t.FRAMEBUFFER, this.$t.framebuffer), t.viewport(...this.$t.viewport), W(t, this.$t.viewport), this.$t = null, this.xt && this.Ft && this.Mt && ((r = (s = this.xt).kt) == null || r.call(s));
223
220
  }
224
- Ut() {
225
- const t = this.bt;
226
- t.deleteFramebuffer(this.Rt);
227
- for (const e of this.Mt) t.deleteTexture(e);
221
+ Pt() {
222
+ const t = this.vt;
223
+ t.deleteFramebuffer(this.yt);
224
+ for (const e of this.Ct) t.deleteTexture(e);
228
225
  }
229
226
  get width() {
230
- return this.Ct;
227
+ return this.dt;
231
228
  }
232
229
  get height() {
233
- return this.wt;
230
+ return this._t;
234
231
  }
235
232
  get textures() {
236
- return [...this.Mt];
233
+ return [...this.Ct];
237
234
  }
238
235
  }
239
- function Y(a) {
240
- return typeof a == "string" ? a : a.sourceCode;
241
- }
242
- class P {
236
+ class M {
243
237
  constructor(t, e, i) {
244
- c(this, "bt");
245
- c(this, "Vt");
246
- c(this, "Ot", /* @__PURE__ */ new Map());
247
- c(this, "Ht", /* @__PURE__ */ new Map());
248
- c(this, "Kt", 0);
249
- this.bt = t, this.Vt = this.Nt(Y(e), Y(i)), this.Xt();
250
- }
251
- Xt() {
252
- const t = this.bt.getProgramParameter(this.Vt, this.bt.ACTIVE_UNIFORMS);
238
+ a(this, "vt");
239
+ a(this, "Gt");
240
+ a(this, "Bt", /* @__PURE__ */ new Map());
241
+ a(this, "Dt", /* @__PURE__ */ new Map());
242
+ a(this, "It", 0);
243
+ this.vt = t, this.Gt = this.Wt(e, i), this.Ot();
244
+ }
245
+ Ot() {
246
+ const t = this.vt.getProgramParameter(this.Gt, this.vt.ACTIVE_UNIFORMS);
253
247
  for (let e = 0; e < t; e++) {
254
- const i = this.bt.getActiveUniform(this.Vt, e);
248
+ const i = this.vt.getActiveUniform(this.Gt, e);
255
249
  if (i) {
256
- const r = this.bt.getUniformLocation(this.Vt, i.name);
257
- if (r && (this.Ot.set(i.name, r), this.Ht.set(i.name, { type: i.type, size: i.size }), i.size > 1)) {
258
- const s = i.name.replace(/\[.*\]$/, "");
259
- this.Ot.has(s) || (this.Ot.set(s, r), this.Ht.set(s, { type: i.type, size: i.size }));
250
+ const s = this.vt.getUniformLocation(this.Gt, i.name);
251
+ if (s && (this.Bt.set(i.name, s), this.Dt.set(i.name, { type: i.type, size: i.size }), i.size > 1)) {
252
+ const r = i.name.replace(/\[.*\]$/, "");
253
+ this.Bt.has(r) || (this.Bt.set(r, s), this.Dt.set(r, { type: i.type, size: i.size }));
260
254
  }
261
255
  }
262
256
  }
263
257
  }
264
- Nt(t, e) {
265
- const i = this.jt(this.bt.VERTEX_SHADER, t), r = this.jt(this.bt.FRAGMENT_SHADER, e), s = this.bt.createProgram();
266
- if (this.bt.attachShader(s, i), this.bt.attachShader(s, r), this.bt.linkProgram(s), !this.bt.getProgramParameter(s, this.bt.LINK_STATUS)) {
267
- const n = this.bt.getProgramInfoLog(s);
258
+ Wt(t, e) {
259
+ const i = this.Ht(this.vt.VERTEX_SHADER, t), s = this.Ht(this.vt.FRAGMENT_SHADER, e), r = this.vt.createProgram();
260
+ if (this.vt.attachShader(r, i), this.vt.attachShader(r, s), this.vt.linkProgram(r), !this.vt.getProgramParameter(r, this.vt.LINK_STATUS)) {
261
+ const n = this.vt.getProgramInfoLog(r);
268
262
  throw Error("Shader program link error: " + n);
269
263
  }
270
- return this.bt.deleteShader(i), this.bt.deleteShader(r), s;
264
+ return this.vt.deleteShader(i), this.vt.deleteShader(s), r;
271
265
  }
272
- jt(t, e) {
273
- const i = this.bt.createShader(t);
274
- if (this.bt.shaderSource(i, e), this.bt.compileShader(i), !this.bt.getShaderParameter(i, this.bt.COMPILE_STATUS)) {
275
- const r = this.bt.getShaderInfoLog(i);
276
- throw this.bt.deleteShader(i), Error("Shader compilation error: " + r);
266
+ Ht(t, e) {
267
+ const i = this.vt.createShader(t);
268
+ if (this.vt.shaderSource(i, e), this.vt.compileShader(i), !this.vt.getShaderParameter(i, this.vt.COMPILE_STATUS)) {
269
+ const s = this.vt.getShaderInfoLog(i);
270
+ throw this.vt.deleteShader(i), Error("Shader compilation error: " + s);
277
271
  }
278
272
  return i;
279
273
  }
280
- Yt() {
281
- this.bt.useProgram(this.Vt), this.qt();
274
+ Vt() {
275
+ this.vt.useProgram(this.Gt), this.Kt();
282
276
  }
283
- qt() {
284
- this.Kt = 0;
277
+ Kt() {
278
+ this.It = 0;
285
279
  }
286
- Zt(t) {
287
- for (const [e, i] of Object.entries(t)) this.Jt(e, i);
280
+ Nt(t) {
281
+ for (const [e, i] of Object.entries(t)) this.Xt(e, i);
288
282
  }
289
- Qt(t) {
290
- return this.Ot.has(t);
283
+ jt(t) {
284
+ return this.Bt.has(t);
291
285
  }
292
- te(t) {
293
- return this.Ht.get(t) || null;
286
+ Yt(t) {
287
+ return this.Dt.get(t) || null;
294
288
  }
295
- ee() {
289
+ qt() {
296
290
  const t = [];
297
- for (const [e, i] of this.Ht.entries()) t.push({ name: e, ...i });
291
+ for (const [e, i] of this.Dt.entries()) t.push({ name: e, ...i });
298
292
  return t;
299
293
  }
300
- Jt(t, e) {
301
- var h;
302
- const i = this.Ot.get(t);
294
+ Xt(t, e) {
295
+ var c;
296
+ const i = this.Bt.get(t);
303
297
  if (!i) return;
304
- const r = this.Ht.get(t);
305
- if (!r) return void console.warn(`No type information found for uniform '${t}'`);
306
- const { type: s, size: n } = r, o = this.bt;
307
- if (typeof e == "number") switch (s) {
298
+ const s = this.Dt.get(t);
299
+ if (!s) return void console.warn(`No type information found for uniform '${t}'`);
300
+ const { type: r, size: n } = s, o = this.vt;
301
+ if (typeof e == "number") switch (r) {
308
302
  case o.INT:
309
303
  case o.BOOL:
310
304
  o.uniform1i(i, e);
@@ -313,25 +307,25 @@ class P {
313
307
  o.uniform1f(i, e);
314
308
  break;
315
309
  default:
316
- console.warn(`Unexpected uniform type for scalar '${t}': ${s}`), o.uniform1f(i, e);
310
+ console.warn(`Unexpected uniform type for scalar '${t}': ${r}`), o.uniform1f(i, e);
317
311
  }
318
312
  else if (typeof e == "boolean") o.uniform1i(i, e ? 1 : 0);
319
313
  else if (Array.isArray(e)) if (Array.isArray(e[0])) {
320
- const l = e, u = ((h = l[0]) == null ? void 0 : h.length) || 0, f = l.flat();
321
- switch (s) {
314
+ const l = e, f = ((c = l[0]) == null ? void 0 : c.length) || 0, u = l.flat();
315
+ switch (r) {
322
316
  case o.FLOAT_VEC2:
323
- u === 2 ? o.uniform2fv(i, f) : console.warn(`Vector length mismatch for '${t}': expected 2, got ${u}`);
317
+ f === 2 ? o.uniform2fv(i, u) : console.warn(`Vector length mismatch for '${t}': expected 2, got ${f}`);
324
318
  break;
325
319
  case o.FLOAT_VEC3:
326
- u === 3 ? o.uniform3fv(i, f) : console.warn(`Vector length mismatch for '${t}': expected 3, got ${u}`);
320
+ f === 3 ? o.uniform3fv(i, u) : console.warn(`Vector length mismatch for '${t}': expected 3, got ${f}`);
327
321
  break;
328
322
  case o.FLOAT_VEC4:
329
- u === 4 ? o.uniform4fv(i, f) : console.warn(`Vector length mismatch for '${t}': expected 4, got ${u}`);
323
+ f === 4 ? o.uniform4fv(i, u) : console.warn(`Vector length mismatch for '${t}': expected 4, got ${f}`);
330
324
  break;
331
325
  default:
332
- console.warn(`Unsupported uniform type for vector array '${t}': ${s}`);
326
+ console.warn(`Unsupported uniform type for vector array '${t}': ${r}`);
333
327
  }
334
- } else switch (s) {
328
+ } else switch (r) {
335
329
  case o.FLOAT_VEC2:
336
330
  e.length === 2 ? o.uniform2f(i, e[0], e[1]) : console.warn(`Vector length mismatch for '${t}': expected 2, got ${e.length}`);
337
331
  break;
@@ -348,217 +342,192 @@ class P {
348
342
  n > 1 ? o.uniform1fv(i, e) : console.warn(`Array provided for scalar uniform '${t}'`);
349
343
  break;
350
344
  default:
351
- console.warn(`Unsupported uniform type for array '${t}': ${s}`);
345
+ console.warn(`Unsupported uniform type for array '${t}': ${r}`);
352
346
  }
353
347
  else if (e instanceof WebGLTexture) {
354
- const l = this.se();
348
+ const l = this.Zt();
355
349
  o.uniform1i(i, l), o.activeTexture(o.TEXTURE0 + l), o.bindTexture(o.TEXTURE_2D, e);
356
- } else if (e instanceof D) {
357
- const l = this.se();
350
+ } else if (e instanceof K) {
351
+ const l = this.Zt();
358
352
  o.uniform1i(i, l), o.activeTexture(o.TEXTURE0 + l), o.bindTexture(o.TEXTURE_2D, e.textures[0]);
359
353
  } else console.warn(`Unsupported uniform type for '${t}':`, typeof e);
360
354
  }
361
- se() {
362
- return this.Kt++;
355
+ Zt() {
356
+ return this.It++;
363
357
  }
364
- get ie() {
365
- return this.Vt;
358
+ get Jt() {
359
+ return this.Gt;
366
360
  }
367
- Ut() {
368
- this.bt.deleteProgram(this.Vt);
361
+ Pt() {
362
+ this.vt.deleteProgram(this.Gt);
369
363
  }
370
364
  }
371
- const W = `#version 300 es
372
- in vec2 a_position;in vec2 a_texCoord;in vec2 a_instancePosition;in vec2 a_instanceSize;in vec3 a_instanceCharacter;in vec4 a_instancePrimaryColor;in vec4 a_instanceSecondaryColor;in vec2 a_instanceRotation;in vec3 a_instanceTransform;in vec3 a_instanceGlobalRotation;in vec2 a_instanceRotationCenter;in vec2 a_instanceBezierCP1;in vec2 a_instanceBezierCP2;in vec2 a_instanceBezierStart;in vec2 a_instanceBezierEnd;in vec2 a_instanceArcAngles;uniform float k;uniform vec2 t;out vec2 v_uv;out vec3 v_character;out vec4 v_primaryColor;out vec4 v_secondaryColor;out vec2 v_rotation;out vec3 v_transform;mat3 A(float B){float C=sin(B),D=cos(B);return mat3(1,0,0,0,D,-C,0,C,D);}mat3 E(float B){float C=sin(B),D=cos(B);return mat3(D,0,C,0,1,0,-C,0,D);}mat3 F(float B){float C=sin(B),D=cos(B);return mat3(D,-C,0,C,D,0,0,0,1);}vec2 G(float t,vec2 H,vec2 I,vec2 J,vec2 K){float L=1.-t,M=L*L,N=t*t;return M*L*H+3.*M*t*I+3.*L*N*J+N*t*K;}vec2 O(float t,vec2 H,vec2 I,vec2 J,vec2 K){float L=1.-t,M=L*L,N=t*t;return-3.*M*H+3.*M*I-6.*L*t*I+6.*L*t*J-3.*N*J+3.*N*K;}void main(){v_uv=a_texCoord;v_character=a_instanceCharacter;v_primaryColor=a_instancePrimaryColor;v_secondaryColor=a_instanceSecondaryColor;v_rotation=a_instanceRotation;v_transform=a_instanceTransform;vec2 P;bool Q=length(a_instanceBezierCP1)+length(a_instanceBezierCP2)+length(a_instanceBezierStart)+length(a_instanceBezierEnd)>0.;bool R=a_instanceArcAngles.x!=0.||a_instanceArcAngles.y!=0.;if(Q){float t=a_position.x;vec2 S=G(t,a_instanceBezierStart,a_instanceBezierCP1,a_instanceBezierCP2,a_instanceBezierEnd);vec2 T=O(t,a_instanceBezierStart,a_instanceBezierCP1,a_instanceBezierCP2,a_instanceBezierEnd);float U=length(T);T=U>0.?T/U:vec2(1,0);P=S+vec2(-T.y,T.x)*a_position.y*a_instanceSize.y;}else if(R){float C=a_instanceArcAngles.x,V=a_instanceArcAngles.y;C=mod(C,6.28318530718);if(C<0.)C+=6.28318530718;V=mod(V,6.28318530718);if(V<0.)V+=6.28318530718;float W=C-V;if(W<=0.)W+=6.28318530718;float X=C-a_position.x*W;vec2 Y=vec2(cos(X),sin(X))*a_position.y;P=Y*a_instanceSize*.5+a_instanceSize*.5+a_instancePosition;}else{P=a_position*a_instanceSize+a_instancePosition;}vec2 Z=(P/t)*2.-1.;Z.y=-Z.y;if(length(a_instanceGlobalRotation)>0.){vec3 a=vec3(Z-a_instanceRotationCenter,0);a.x*=k;if(a_instanceGlobalRotation.x!=0.)a=A(-a_instanceGlobalRotation.x)*a;if(a_instanceGlobalRotation.y!=0.)a=E(-a_instanceGlobalRotation.y)*a;if(a_instanceGlobalRotation.z!=0.)a=F(-a_instanceGlobalRotation.z)*a;a.x/=k;Z=a.xy+a_instanceRotationCenter;}gl_Position=vec4(Z,0,1);}`;
373
- class it {
365
+ const k = `#version 300 es
366
+ in vec2 a_position;in vec2 a_texCoord;in vec2 a_instancePosition;in vec2 a_instanceSize;in vec3 a_instanceCharacter;in vec4 a_instancePrimaryColor;in vec4 a_instanceSecondaryColor;in vec2 a_instanceRotation;in vec3 a_instanceTransform;in vec3 a_instanceGlobalRotation;in vec2 a_instanceRotationCenter;in vec2 a_instanceBezierCP1;in vec2 a_instanceBezierCP2;in vec2 a_instanceBezierStart;in vec2 a_instanceBezierEnd;in vec2 a_instanceArcAngles;uniform float U9;uniform vec2 Uw;out vec2 v_uv;out vec3 v_character;out vec4 v_primaryColor;out vec4 v_secondaryColor;out vec2 v_rotation;out vec3 v_transform;mat3 A(float B){float C=sin(B),D=cos(B);return mat3(1,0,0,0,D,-C,0,C,D);}mat3 E(float B){float C=sin(B),D=cos(B);return mat3(D,0,C,0,1,0,-C,0,D);}mat3 F(float B){float C=sin(B),D=cos(B);return mat3(D,-C,0,C,D,0,0,0,1);}vec2 G(float H,vec2 I,vec2 J,vec2 K,vec2 L){float M=1.-H,N=M*M,O=H*H;return N*M*I+3.*N*H*J+3.*M*O*K+O*H*L;}vec2 P(float H,vec2 I,vec2 J,vec2 K,vec2 L){float M=1.-H,N=M*M,O=H*H;return-3.*N*I+3.*N*J-6.*M*H*J+6.*M*H*K-3.*O*K+3.*O*L;}void main(){v_uv=a_texCoord;v_character=a_instanceCharacter;v_primaryColor=a_instancePrimaryColor;v_secondaryColor=a_instanceSecondaryColor;v_rotation=a_instanceRotation;v_transform=a_instanceTransform;vec2 Q;bool R=length(a_instanceBezierCP1)+length(a_instanceBezierCP2)+length(a_instanceBezierStart)+length(a_instanceBezierEnd)>0.;bool S=a_instanceArcAngles.x!=0.||a_instanceArcAngles.y!=0.;if(R){float H=a_position.x;vec2 T=G(H,a_instanceBezierStart,a_instanceBezierCP1,a_instanceBezierCP2,a_instanceBezierEnd);vec2 U=P(H,a_instanceBezierStart,a_instanceBezierCP1,a_instanceBezierCP2,a_instanceBezierEnd);float V=length(U);U=V>0.?U/V:vec2(1,0);Q=T+vec2(-U.y,U.x)*a_position.y*a_instanceSize.y;}else if(S){float C=a_instanceArcAngles.x,W=a_instanceArcAngles.y;C=mod(C,6.28318530718);if(C<0.)C+=6.28318530718;W=mod(W,6.28318530718);if(W<0.)W+=6.28318530718;float X=C-W;if(X<=0.)X+=6.28318530718;float Y=C-a_position.x*X;vec2 Z=vec2(cos(Y),sin(Y))*a_position.y;Q=Z*a_instanceSize*.5+a_instanceSize*.5+a_instancePosition;}else{Q=a_position*a_instanceSize+a_instancePosition;}vec2 a=(Q/Uw)*2.-1.;a.y=-a.y;if(length(a_instanceGlobalRotation)>0.){vec3 b=vec3(a-a_instanceRotationCenter,0);b.x*=U9;if(a_instanceGlobalRotation.x!=0.)b=A(-a_instanceGlobalRotation.x)*b;if(a_instanceGlobalRotation.y!=0.)b=E(-a_instanceGlobalRotation.y)*b;if(a_instanceGlobalRotation.z!=0.)b=F(-a_instanceGlobalRotation.z)*b;b.x/=U9;a=b.xy+a_instanceRotationCenter;}gl_Position=vec4(a,0,1);}`, at = "attribute vec2 a_position;attribute vec2 a_texCoord;varying vec2 v_uv;void main(){v_uv=a_texCoord;gl_Position=vec4(a_position,0.,1.);}";
367
+ class ft {
374
368
  constructor(t) {
375
- c(this, "re", /* @__PURE__ */ new Map());
376
- c(this, "bt");
377
- this.bt = t;
378
- }
379
- ne(t, e) {
380
- if (!this.re.has(t)) {
381
- const i = e();
382
- this.re.set(t, i);
383
- }
384
- return this.re.get(t);
369
+ a(this, "vt");
370
+ a(this, "Qt");
371
+ a(this, "te");
372
+ a(this, "ee");
373
+ a(this, "se");
374
+ this.vt = t, this.te = new M(this.vt, k, `#version 300 es
375
+ precision highp float;in vec2 v_uv;in vec3 v_character;in vec4 v_primaryColor;in vec4 v_secondaryColor;in vec2 v_rotation;in vec3 v_transform;layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;layout(location=3)out vec4 o_rotation;layout(location=4)out vec4 o_transform;void main(){o_character=vec4(v_character,1.);o_primaryColor=v_primaryColor;o_secondaryColor=v_secondaryColor;o_rotation=vec4(v_rotation,0.,1.);o_transform=vec4(v_transform,1.);}`), this.Qt = new M(this.vt, k, `#version 300 es
376
+ precision highp float;in vec2 v_uv;uniform sampler2D Ue;uniform sampler2D Uf;uniform sampler2D Ug;uniform sampler2D Uh;uniform sampler2D Ui;uniform vec2 Uj;layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;layout(location=3)out vec4 o_rotation;layout(location=4)out vec4 o_transform;void main(){vec2 A=vec2(v_uv.x,1.-v_uv.y);vec2 B=A*Uj;vec2 C=(floor(B)+0.5f)/Uj;vec4 D=texture(Ue,C);vec4 E=texture(Uf,C);if(E.a==0.){discard;}vec4 F=texture(Ug,C);vec4 G=texture(Uh,C);vec4 H=texture(Ui,C);o_character=D;o_primaryColor=E;o_secondaryColor=F;o_rotation=G;o_transform=H;}`), this.ee = new M(this.vt, at, "precision mediump float;uniform sampler2D U0;uniform vec2 U1;uniform sampler2D U3;uniform sampler2D U4;uniform sampler2D U5;uniform sampler2D U2;uniform sampler2D U6;uniform vec2 U7;uniform vec2 U8;mat2 A(float B){float C=sin(B);float D=cos(B);return mat2(D,-C,C,D);}void main(){vec2 E=gl_FragCoord.xy/U8;vec2 F=E*U7;vec2 G=floor(F);vec2 H=(G+0.5)/U7;vec4 I=texture2D(U3,H);vec4 J=texture2D(U4,H);vec4 K=texture2D(U5,H);bool L=K.r>0.5;bool M=K.g>0.5;bool N=K.b>0.5;vec4 O=texture2D(U2,H);int P=int(O.r*255.+0.5)+int(O.g*255.+0.5)*256;int Q=int(mod(float(P),U1.x));int R=P/int(U1.x);float S=(U1.y-1.)-float(R);vec2 T=vec2(float(Q),S)/U1;vec4 U=texture2D(U6,H);float V=U.r*255.+U.g;float W=-(V*360./255.)*0.017453292;vec2 X=fract(F)-0.5;if(M)X.x=-X.x;if(N)X.y=-X.y;X=A(W)*X+0.5;vec2 Y=1./U1;vec2 Z=T+X*Y;vec2 a=T+Y;if(any(lessThan(Z,T))||any(greaterThan(Z,a))){gl_FragColor=L?I:J;return;}vec4 b=texture2D(U0,Z);if(L)b.rgb=1.-b.rgb;gl_FragColor=mix(J,I,b);}"), this.se = new M(this.vt, k, `#version 300 es
377
+ precision highp float;in vec2 v_uv;uniform sampler2D Uk;uniform bool Ul;uniform bool Um;uniform bool Un;uniform vec2 Uo;uniform bool Up;uniform vec3 Uq;uniform bool Ur;uniform vec3 Us;uniform vec4 Ut;uniform int Uu;uniform vec3 Uv[64];layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;layout(location=3)out vec4 o_rotation;layout(location=4)out vec4 o_transform;float A(vec3 B){return dot(B,vec3(0.299,0.587,0.114));}void main(){vec2 C=vec2(v_uv.x,1.-v_uv.y);vec4 D=texture(Uk,C);float E=A(D.rgb);if(Uu>0){float F=float(Uu);float G=clamp(E*(F-1.),0.,F-1.);int H=int(floor(G+0.5));vec3 I=Uv[H];o_character=vec4(I,1.);}else{o_character=vec4(E,0.,0.,1.);}vec3 J=D.rgb;vec3 K=Up?Uq:J;vec3 L=Ur?Us:J;float M=Up?1.:D.a;float N;if(D.a<0.01){K=Ut.rgb;L=Ut.rgb;M=Ut.a;N=Ut.a;}else{N=Ur?1.:D.a;}o_primaryColor=vec4(K,M);o_secondaryColor=vec4(L,N);o_rotation=vec4(Uo.xy,0.,1.);o_transform=vec4(float(Ul),float(Um),float(Un),1.);}`);
378
+ }
379
+ ie() {
380
+ return this.Qt;
385
381
  }
386
- oe() {
387
- return this.ne("mrt-copy", () => new P(this.bt, W, `#version 300 es
388
- precision highp float;in vec2 v_uv;uniform sampler2D l;uniform sampler2D m;uniform sampler2D n;uniform sampler2D o;uniform sampler2D p;uniform vec2 q;layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;layout(location=3)out vec4 o_rotation;layout(location=4)out vec4 o_transform;void main(){vec2 A=vec2(v_uv.x,1.-v_uv.y);vec2 B=A*q;vec2 C=(floor(B)+0.5f)/q;vec4 D=texture(l,C);vec4 E=texture(m,C);if(E.a==0.){discard;}vec4 F=texture(n,C);vec4 G=texture(o,C);vec4 H=texture(p,C);o_character=D;o_primaryColor=E;o_secondaryColor=F;o_rotation=G;o_transform=H;}`));
382
+ Tt() {
383
+ return this.te;
389
384
  }
390
- Bt() {
391
- return this.ne("mrt-draw", () => new P(this.bt, W, `#version 300 es
392
- precision highp float;in vec2 v_uv;in vec3 v_character;in vec4 v_primaryColor;in vec4 v_secondaryColor;in vec2 v_rotation;in vec3 v_transform;layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;layout(location=3)out vec4 o_rotation;layout(location=4)out vec4 o_transform;void main(){o_character=vec4(v_character,1.);o_primaryColor=v_primaryColor;o_secondaryColor=v_secondaryColor;o_rotation=vec4(v_rotation,0.,1.);o_transform=vec4(v_transform,1.);}`));
385
+ re() {
386
+ return this.ee;
393
387
  }
394
- ae() {
395
- return this.ne("ascii-conversion", () => new P(this.bt, "attribute vec2 a_position;attribute vec2 a_texCoord;varying vec2 v_uv;void main(){v_uv=a_texCoord;gl_Position=vec4(a_position,0.,1.);}", "precision mediump float;uniform sampler2D a;uniform vec2 b;uniform sampler2D d;uniform sampler2D e;uniform sampler2D f;uniform sampler2D c;uniform sampler2D g;uniform vec2 h;uniform vec2 i;uniform vec2 j;mat2 A(float B){float C=sin(B);float c=cos(B);return mat2(c,-C,C,c);}void main(){vec2 D=(gl_FragCoord.xy-j)/i;vec2 E=D*h;vec2 F=floor(E);vec2 G=(F+0.5)/h;vec4 H=texture2D(d,G);vec4 I=texture2D(e,G);vec4 J=texture2D(f,G);bool K=J.r>0.5;bool L=J.g>0.5;bool M=J.b>0.5;vec4 N=texture2D(c,G);int O=int(N.r*255.+0.5)+int(N.g*255.+0.5)*256;int P=int(mod(float(O),b.x));int Q=O/int(b.x);float R=(b.y-1.)-float(Q);vec2 S=vec2(float(P),R)/b;vec4 T=texture2D(g,G);float U=T.r*255.+T.g;float V=-(U*360./255.)*0.017453292;vec2 W=fract(E)-0.5;if(L)W.x=-W.x;if(M)W.y=-W.y;W=A(V)*W+0.5;vec2 X=1./b;vec2 Y=S+W*X;vec2 Z=S+X;if(any(lessThan(Y,S))||any(greaterThan(Y,Z))){gl_FragColor=K?H:I;return;}vec4 a=texture2D(a,Y);if(K)a.rgb=1.-a.rgb;gl_FragColor=mix(I,H,a);}"));
388
+ ne() {
389
+ return this.se;
396
390
  }
397
- he(t) {
398
- return new P(this.bt, W, t);
391
+ oe(t) {
392
+ return new M(this.vt, k, t);
399
393
  }
400
- ce(t, e) {
401
- return new P(this.bt, t, e);
394
+ ae(t, e) {
395
+ return new M(this.vt, t, e);
402
396
  }
403
- Ut() {
404
- for (const t of this.re.values()) t.Ut();
405
- this.re.clear();
397
+ Pt() {
398
+ this.Qt.Pt(), this.te.Pt(), this.ee.Pt(), this.se.Pt();
406
399
  }
407
400
  }
408
- var b = ((a) => (a.RECTANGLE = "rectangle", a.LINE = "line", a.ELLIPSE = "ellipse", a.ARC = "arc", a.TRIANGLE = "triangle", a.BEZIER_CURVE = "bezier_curve", a.CUSTOM = "custom", a))(b || {});
409
- class rt {
401
+ var w = ((h) => (h.RECTANGLE = "rectangle", h.LINE = "line", h.ELLIPSE = "ellipse", h.ARC = "arc", h.TRIANGLE = "triangle", h.BEZIER_CURVE = "bezier_curve", h.CUSTOM = "custom", h))(w || {});
402
+ class dt {
410
403
  constructor(t) {
411
- c(this, "bt");
412
- c(this, "le", /* @__PURE__ */ new Map());
413
- this.bt = t;
414
- }
415
- ue(t, e, i, r) {
416
- const s = this.bt;
417
- let n = this.le.get(t);
418
- n || (n = /* @__PURE__ */ new Map(), this.le.set(t, n));
404
+ a(this, "vt");
405
+ a(this, "he", /* @__PURE__ */ new Map());
406
+ this.vt = t;
407
+ }
408
+ ce(t, e, i, s) {
409
+ const r = this.vt;
410
+ let n = this.he.get(t);
411
+ n || (n = /* @__PURE__ */ new Map(), this.he.set(t, n));
419
412
  let o = n.get(e) || null;
420
413
  if (!o) {
421
- o = s.createVertexArray(), n.set(e, o), s.bindVertexArray(o), s.bindBuffer(s.ARRAY_BUFFER, r);
422
- const h = s.getAttribLocation(t, "a_position");
423
- h !== -1 && (s.enableVertexAttribArray(h), s.vertexAttribPointer(h, i.de.fe.size, s.FLOAT, !1, i._e, i.de.fe.offset), s.vertexAttribDivisor(h, 0));
424
- const l = s.getAttribLocation(t, "a_texCoord");
425
- l !== -1 && (s.enableVertexAttribArray(l), s.vertexAttribPointer(l, i.de.pe.size, s.FLOAT, !1, i._e, i.de.pe.offset), s.vertexAttribDivisor(l, 0));
414
+ o = r.createVertexArray(), n.set(e, o), r.bindVertexArray(o), r.bindBuffer(r.ARRAY_BUFFER, s);
415
+ const c = r.getAttribLocation(t, "a_position");
416
+ c !== -1 && (r.enableVertexAttribArray(c), r.vertexAttribPointer(c, i.ue.le.size, r.FLOAT, !1, i.fe, i.ue.le.offset), r.vertexAttribDivisor(c, 0));
417
+ const l = r.getAttribLocation(t, "a_texCoord");
418
+ l !== -1 && (r.enableVertexAttribArray(l), r.vertexAttribPointer(l, i.ue.de.size, r.FLOAT, !1, i.fe, i.ue.de.offset), r.vertexAttribDivisor(l, 0));
426
419
  }
427
- s.bindVertexArray(o);
420
+ r.bindVertexArray(o);
428
421
  }
429
- ge() {
430
- this.bt.bindVertexArray(null);
422
+ _e() {
423
+ this.vt.bindVertexArray(null);
431
424
  }
432
- Ut() {
433
- const t = this.bt;
434
- for (const [, e] of this.le) for (const [, i] of e) i && t.deleteVertexArray(i);
435
- this.le.clear();
425
+ Pt() {
426
+ for (const [, t] of this.he) for (const [, e] of t) e && this.vt.deleteVertexArray(e);
436
427
  }
437
428
  }
438
- class st {
429
+ class gt {
439
430
  constructor(t, e) {
440
- c(this, "me");
441
- c(this, "bt");
442
- c(this, "kt");
443
- c(this, "ve", null);
444
- c(this, "ye", null);
445
- this.bt = t, this.me = new rt(t), this.kt = e;
446
- }
447
- $e(t, e, i) {
448
- const { shader: r } = t, s = I(this.bt) || this.bt.getParameter(this.bt.VIEWPORT);
449
- r.Zt({ k: s[2] / s[3], t: [s[2], s[3]] });
431
+ a(this, "pe");
432
+ a(this, "vt");
433
+ a(this, "xt");
434
+ a(this, "me", null);
435
+ a(this, "ge", null);
436
+ this.vt = t, this.pe = new dt(t), this.xt = e;
437
+ }
438
+ ve(t, e, i) {
439
+ const { shader: s } = t, r = X(this.vt) || this.vt.getParameter(this.vt.VIEWPORT);
440
+ s.Nt({ U9: r[2] / r[3], Uw: [r[2], r[3]] });
450
441
  const n = (l) => {
451
- if (!l || !l.Ce()) return;
452
- const u = l.unitGeometry, f = l.unitBuffer;
442
+ if (!l || !l.ye()) return;
443
+ const f = l.unitGeometry, u = l.unitBuffer;
453
444
  try {
454
- this.me.ue(r.ie, l.type + "", u, f), l.batch.we(r), l.batch.xe(u.be, u.Re);
445
+ this.pe.ce(s.Jt, l.type + "", f, u), l.batch.Ce(s), l.batch.we(f.$e, f.be);
455
446
  } finally {
456
- l.batch.Me(r), this.me.ge(), l.Se();
447
+ l.batch.xe(s), this.pe._e(), l.Fe();
457
448
  }
458
449
  };
459
- let o = null, h = null;
450
+ let o = null, c = null;
460
451
  for (const l of e) {
461
- if (l.type === b.CUSTOM) {
462
- h && (n(h), o = null, h = null), this.Fe(t, l.params, l.state, i.get(b.RECTANGLE));
452
+ if (l.type === w.CUSTOM) {
453
+ c && (n(c), o = null, c = null), this.Me(t, l.params, l.state, i.get(w.RECTANGLE));
463
454
  continue;
464
455
  }
465
- o !== null && l.type !== o && (n(h), o = null, h = null);
466
- let u = h;
467
- u && l.type === o || (u = i.get(l.type) || null, h = u, o = l.type), u && u.ze(l.params, l.state);
456
+ o !== null && l.type !== o && (n(c), o = null, c = null);
457
+ let f = c;
458
+ f && l.type === o || (f = i.get(l.type) || null, c = f, o = l.type), f && f.Re(l.params, l.state);
468
459
  }
469
- n(h);
470
- }
471
- Fe(t, e, i, r) {
472
- const { x: s, y: n, width: o, height: h, shader: l, uniforms: u } = e;
473
- if (l === this.ke()) return this.Pe(r, l, u, Math.floor(s), Math.floor(n), Math.max(1, Math.floor(o)), Math.max(1, Math.floor(h)), i), void t.shader.Yt();
474
- const f = this.Te(Math.max(1, Math.floor(o)), Math.max(1, Math.floor(h)));
475
- f.begin(), this.Pe(r, l, u, 0, 0, f.width, f.height, {}), f.end();
476
- const d = this.ke(), p = { l: f.textures[0], m: f.textures[1], n: f.textures[2], o: f.textures[3], p: f.textures[4], q: [f.width, f.height] };
477
- this.Pe(r, d, p, Math.floor(s), Math.floor(n), Math.max(1, Math.floor(o)), Math.max(1, Math.floor(h)), i), t.shader.Yt();
478
- }
479
- Pe(t, e, i, r, s, n, o, h) {
480
- e.Yt(), e.Zt(i);
481
- const l = this.bt.getParameter(this.bt.VIEWPORT);
482
- if (e.Zt({ k: l[2] / l[3], t: [l[2], l[3]] }), t.Se(), t.ze({ x: r, y: s, width: n, height: o }, h), t.Ce()) {
483
- const u = t.unitGeometry, f = t.unitBuffer;
460
+ n(c);
461
+ }
462
+ Me(t, e, i, s) {
463
+ const { x: r, y: n, width: o, height: c, shader: l, uniforms: f } = e, u = this.Se(Math.max(1, Math.floor(o)), Math.max(1, Math.floor(c)));
464
+ u.begin(), this.Ae(s, l, f, 0, 0, u.width, u.height, {}), u.end();
465
+ const g = this.ze(), v = { Ue: u.textures[0], Uf: u.textures[1], Ug: u.textures[2], Uh: u.textures[3], Ui: u.textures[4], Uj: [u.width, u.height] };
466
+ this.Ae(s, g, v, Math.floor(r), Math.floor(n), Math.max(1, Math.floor(o)), Math.max(1, Math.floor(c)), i), t.shader.Vt();
467
+ }
468
+ Ae(t, e, i, s, r, n, o, c) {
469
+ e.Vt(), e.Nt(i);
470
+ const l = this.vt.getParameter(this.vt.VIEWPORT);
471
+ if (e.Nt({ U9: l[2] / l[3], Uw: [l[2], l[3]] }), t.Fe(), t.Re({ x: s, y: r, width: n, height: o }, c), t.ye()) {
472
+ const f = t.unitGeometry, u = t.unitBuffer;
484
473
  try {
485
- this.me.ue(e.ie, t.type + "", u, f), t.batch.we(e), t.batch.xe(u.be, u.Re);
474
+ this.pe.ce(e.Jt, t.type + "", f, u), t.batch.Ce(e), t.batch.we(f.$e, f.be);
486
475
  } finally {
487
- t.batch.Me(e), this.me.ge(), t.Se();
476
+ t.batch.xe(e), this.pe._e(), t.Fe();
488
477
  }
489
478
  }
490
479
  }
491
- ke() {
492
- return this.kt.oe();
480
+ ze() {
481
+ return this.xt.ie();
482
+ }
483
+ Se(t, e) {
484
+ return this.me && this.ge && this.ge.w === t && this.ge.h === e || (this.me && this.me.Pt(), this.me = new K(this.vt, t, e, 5), this.ge = { w: t, h: e }), this.me;
493
485
  }
494
- Te(t, e) {
495
- return this.ve && this.ye && this.ye.w === t && this.ye.h === e || (this.ve && this.ve.Ut(), this.ve = new D(this.bt, t, e, 5), this.ye = { w: t, h: e }), this.ve;
486
+ Pt() {
487
+ this.pe.Pt(), this.me && this.me.Pt();
496
488
  }
497
489
  }
498
- class nt {
490
+ class pt {
499
491
  constructor() {
500
- c(this, "Ae", []);
501
- c(this, "Ge", 1);
502
- c(this, "Le", 0);
503
- }
504
- Ee(t) {
505
- if (this.Le >= this.Ae.length) {
506
- const i = { id: this.Ge++, type: t, params: {}, state: { X: 1, Y: 0, Z: 0, J: 0, character: [0, 0, 0], charColor: [1, 1, 1, 1], bgColor: [0, 0, 0, 1], flipHorizontally: !1, flipVertically: !1, invert: !1, charRotation: [0, 0] } };
507
- this.Ae.push(i);
492
+ a(this, "Te", []);
493
+ a(this, "Ee", 1);
494
+ a(this, "Le", 0);
495
+ }
496
+ ke(t) {
497
+ if (this.Le >= this.Te.length) {
498
+ const i = { id: this.Ee++, type: t, params: {}, state: { O: 1, H: 0, V: 0, K: 0, j: [0, 0, 0], Y: [1, 1, 1, 1], q: [0, 0, 0, 1], N: !1, X: !1, P: !1, G: [0, 0] } };
499
+ this.Te.push(i);
508
500
  }
509
- const e = this.Ae[this.Le];
510
- switch (e.id = this.Ge++, e.type = t, t) {
511
- case b.RECTANGLE:
512
- case b.ELLIPSE:
513
- e.params && "width" in e.params || (e.params = { x: 0, y: 0, width: 0, height: 0 });
514
- break;
515
- case b.CUSTOM:
516
- e.params && "shader" in e.params || (e.params = { x: 0, y: 0, width: 0, height: 0, shader: void 0, uniforms: {} });
517
- break;
518
- case b.ARC:
519
- e.params && "start" in e.params || (e.params = { x: 0, y: 0, width: 0, height: 0, start: 0, stop: 0 });
520
- break;
521
- case b.LINE:
522
- e.params && "x2" in e.params || (e.params = { x1: 0, y1: 0, x2: 0, y2: 0, thickness: void 0 });
523
- break;
524
- case b.TRIANGLE:
525
- e.params && "x3" in e.params || (e.params = { x1: 0, y1: 0, x2: 0, y2: 0, x3: 0, y3: 0 });
526
- break;
527
- case b.BEZIER_CURVE:
528
- e.params && "cp2y" in e.params || (e.params = { x1: 0, y1: 0, cp1x: 0, cp1y: 0, cp2x: 0, cp2y: 0, x2: 0, y2: 0, thickness: void 0 });
529
- break;
530
- default:
531
- e.params || (e.params = {});
532
- }
533
- return this.Le++, e;
501
+ const e = this.Te[this.Le];
502
+ return e.id = this.Ee++, e.type = t, this.Le++, e;
534
503
  }
535
- Be(t, e, i, r, s) {
536
- const n = this.Ee(b.RECTANGLE);
537
- return n.params.x = t, n.params.y = e, n.params.width = i, n.params.height = r, s.nt(n.state), n.id;
504
+ Pe(t, e, i, s, r) {
505
+ const n = this.ke(w.RECTANGLE);
506
+ return n.params.x = t, n.params.y = e, n.params.width = i, n.params.height = s, r.J(n.state), n.id;
538
507
  }
539
- De(t, e, i, r, s, n, o) {
540
- const h = this.Ee(b.CUSTOM);
541
- return h.params.x = t, h.params.y = e, h.params.width = i, h.params.height = r, h.params.shader = s, h.params.uniforms = n, o.nt(h.state), h.id;
508
+ Ge(t, e, i, s, r, n, o) {
509
+ const c = this.ke(w.CUSTOM);
510
+ return c.params.x = t, c.params.y = e, c.params.width = i, c.params.height = s, c.params.shader = r, c.params.uniforms = n, o.J(c.state), c.id;
542
511
  }
543
- We(t, e, i, r, s, n) {
544
- const o = this.Ee(b.LINE);
545
- return o.params.x1 = t, o.params.y1 = e, o.params.x2 = i, o.params.y2 = r, o.params.thickness = s, n.nt(o.state), o.id;
512
+ Be(t, e, i, s, r, n) {
513
+ const o = this.ke(w.LINE);
514
+ return o.params.x1 = t, o.params.y1 = e, o.params.x2 = i, o.params.y2 = s, o.params.thickness = r, n.J(o.state), o.id;
546
515
  }
547
- Ie(t, e, i, r, s) {
548
- const n = this.Ee(b.ELLIPSE);
549
- return n.params.x = t, n.params.y = e, n.params.width = i, n.params.height = r, s.nt(n.state), n.id;
516
+ De(t, e, i, s, r) {
517
+ const n = this.ke(w.ELLIPSE);
518
+ return n.params.x = t, n.params.y = e, n.params.width = i, n.params.height = s, r.J(n.state), n.id;
550
519
  }
551
- Ue(t, e, i, r, s, n, o) {
552
- const h = this.Ee(b.ARC);
553
- return h.params.x = t, h.params.y = e, h.params.width = i, h.params.height = r, h.params.start = s, h.params.stop = n, o.nt(h.state), h.id;
520
+ Ie(t, e, i, s, r, n, o) {
521
+ const c = this.ke(w.ARC);
522
+ return c.params.x = t, c.params.y = e, c.params.width = i, c.params.height = s, c.params.start = r, c.params.stop = n, o.J(c.state), c.id;
554
523
  }
555
- Ve(t, e, i, r, s, n, o) {
556
- const h = this.Ee(b.TRIANGLE);
557
- return h.params.x1 = t, h.params.y1 = e, h.params.x2 = i, h.params.y2 = r, h.params.x3 = s, h.params.y3 = n, o.nt(h.state), h.id;
524
+ We(t, e, i, s, r, n, o) {
525
+ const c = this.ke(w.TRIANGLE);
526
+ return c.params.x1 = t, c.params.y1 = e, c.params.x2 = i, c.params.y2 = s, c.params.x3 = r, c.params.y3 = n, o.J(c.state), c.id;
558
527
  }
559
- Oe(t, e, i, r, s, n, o, h, l, u) {
560
- const f = this.Ee(b.BEZIER_CURVE);
561
- return f.params.x1 = t, f.params.y1 = e, f.params.cp1x = i, f.params.cp1y = r, f.params.cp2x = s, f.params.cp2y = n, f.params.x2 = o, f.params.y2 = h, f.params.thickness = l, u.nt(f.state), f.id;
528
+ Oe(t, e, i, s, r, n, o, c, l, f) {
529
+ const u = this.ke(w.BEZIER_CURVE);
530
+ return u.params.x1 = t, u.params.y1 = e, u.params.cp1x = i, u.params.cp1y = s, u.params.cp2x = r, u.params.cp2y = n, u.params.x2 = o, u.params.y2 = c, u.params.thickness = l, f.J(u.state), u.id;
562
531
  }
563
532
  get length() {
564
533
  return this.Le;
@@ -571,614 +540,765 @@ class nt {
571
540
  }
572
541
  [Symbol.iterator]() {
573
542
  let t = 0;
574
- const e = this.Le, i = this.Ae;
543
+ const e = this.Le, i = this.Te;
575
544
  return { next: () => t < e ? { value: i[t++], done: !1 } : { value: void 0, done: !0 } };
576
545
  }
577
546
  }
578
- const T = class T {
579
- static Ke(t, e, i = 0) {
580
- var n, o, h, l, u, f, d, p, g, m;
581
- const r = e || new Float32Array(T.FLOATS_PER_INSTANCE);
582
- let s = i;
583
- return r[s++] = t.position[0], r[s++] = t.position[1], r[s++] = t.size[0], r[s++] = t.size[1], r[s++] = t.tt[0], r[s++] = t.tt[1], r[s++] = t.tt[2], r[s++] = t.primaryColor[0], r[s++] = t.primaryColor[1], r[s++] = t.primaryColor[2], r[s++] = t.primaryColor[3], r[s++] = t.secondaryColor[0], r[s++] = t.secondaryColor[1], r[s++] = t.secondaryColor[2], r[s++] = t.secondaryColor[3], r[s++] = t.rotation[0], r[s++] = t.rotation[1], r[s++] = t.transform[0], r[s++] = t.transform[1], r[s++] = t.transform[2], r[s++] = t.globalRotationX, r[s++] = t.globalRotationY, r[s++] = t.globalRotationZ, r[s++] = t.rotationCenter[0], r[s++] = t.rotationCenter[1], r[s++] = ((n = t.arcAngles) == null ? void 0 : n[0]) || 0, r[s++] = ((o = t.arcAngles) == null ? void 0 : o[1]) || 0, r[s++] = ((h = t.bezierControlPoint1) == null ? void 0 : h[0]) || 0, r[s++] = ((l = t.bezierControlPoint1) == null ? void 0 : l[1]) || 0, r[s++] = ((u = t.bezierControlPoint2) == null ? void 0 : u[0]) || 0, r[s++] = ((f = t.bezierControlPoint2) == null ? void 0 : f[1]) || 0, r[s++] = ((d = t.bezierStartPoint) == null ? void 0 : d[0]) || 0, r[s++] = ((p = t.bezierStartPoint) == null ? void 0 : p[1]) || 0, r[s++] = ((g = t.bezierEndPoint) == null ? void 0 : g[0]) || 0, r[s++] = ((m = t.bezierEndPoint) == null ? void 0 : m[1]) || 0, r;
584
- }
585
- static Ne(t) {
586
- const e = t.length * T.FLOATS_PER_INSTANCE, i = new Float32Array(e);
587
- for (let r = 0; r < t.length; r++) {
588
- const s = r * T.FLOATS_PER_INSTANCE;
589
- T.Ke(t[r], i, s);
547
+ const P = class P {
548
+ static Ve(t, e, i = 0) {
549
+ var n, o, c, l, f, u, g, v, m, d;
550
+ const s = e || new Float32Array(P.FLOATS_PER_INSTANCE);
551
+ let r = i;
552
+ return s[r++] = t.le[0], s[r++] = t.le[1], s[r++] = t.Le[0], s[r++] = t.Le[1], s[r++] = t.j[0], s[r++] = t.j[1], s[r++] = t.j[2], s[r++] = t.Y[0], s[r++] = t.Y[1], s[r++] = t.Y[2], s[r++] = t.Y[3], s[r++] = t.q[0], s[r++] = t.q[1], s[r++] = t.q[2], s[r++] = t.q[3], s[r++] = t.G[0], s[r++] = t.G[1], s[r++] = t.Ke[0], s[r++] = t.Ke[1], s[r++] = t.Ke[2], s[r++] = t.H, s[r++] = t.V, s[r++] = t.K, s[r++] = t.Ne[0], s[r++] = t.Ne[1], s[r++] = ((n = t.Xe) == null ? void 0 : n[0]) || 0, s[r++] = ((o = t.Xe) == null ? void 0 : o[1]) || 0, s[r++] = ((c = t.je) == null ? void 0 : c[0]) || 0, s[r++] = ((l = t.je) == null ? void 0 : l[1]) || 0, s[r++] = ((f = t.Ye) == null ? void 0 : f[0]) || 0, s[r++] = ((u = t.Ye) == null ? void 0 : u[1]) || 0, s[r++] = ((g = t.qe) == null ? void 0 : g[0]) || 0, s[r++] = ((v = t.qe) == null ? void 0 : v[1]) || 0, s[r++] = ((m = t.Ze) == null ? void 0 : m[0]) || 0, s[r++] = ((d = t.Ze) == null ? void 0 : d[1]) || 0, s;
553
+ }
554
+ static Je(t) {
555
+ const e = t.length * P.FLOATS_PER_INSTANCE, i = new Float32Array(e);
556
+ for (let s = 0; s < t.length; s++) {
557
+ const r = s * P.FLOATS_PER_INSTANCE;
558
+ P.Ve(t[s], i, r);
590
559
  }
591
560
  return i;
592
561
  }
593
562
  };
594
- c(T, "BYTES_PER_INSTANCE", 140), c(T, "FLOATS_PER_INSTANCE", 35);
595
- let _ = T;
596
- const y = class y {
563
+ a(P, "BYTES_PER_INSTANCE", 140), a(P, "FLOATS_PER_INSTANCE", 35);
564
+ let B = P;
565
+ const T = class T {
597
566
  };
598
- c(y, "STRIDE", _.BYTES_PER_INSTANCE), c(y, "ATTRIBUTES", { a_instancePosition: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: y.STRIDE, offset: 0, divisor: 1 }, a_instanceSize: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: y.STRIDE, offset: 8, divisor: 1 }, a_instanceCharacter: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: y.STRIDE, offset: 16, divisor: 1 }, a_instancePrimaryColor: { location: -1, size: 4, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: y.STRIDE, offset: 28, divisor: 1 }, a_instanceSecondaryColor: { location: -1, size: 4, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: y.STRIDE, offset: 44, divisor: 1 }, a_instanceRotation: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: y.STRIDE, offset: 60, divisor: 1 }, a_instanceTransform: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: y.STRIDE, offset: 68, divisor: 1 }, a_instanceGlobalRotation: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: y.STRIDE, offset: 80, divisor: 1 }, a_instanceRotationCenter: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: y.STRIDE, offset: 92, divisor: 1 }, a_instanceArcAngles: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: y.STRIDE, offset: 100, divisor: 1 }, a_instanceBezierCP1: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: y.STRIDE, offset: 108, divisor: 1 }, a_instanceBezierCP2: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: y.STRIDE, offset: 116, divisor: 1 }, a_instanceBezierStart: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: y.STRIDE, offset: 124, divisor: 1 }, a_instanceBezierEnd: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: y.STRIDE, offset: 132, divisor: 1 } });
599
- let k = y;
600
- class ot {
567
+ a(T, "STRIDE", B.BYTES_PER_INSTANCE), a(T, "ATTRIBUTES", { a_instancePosition: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: T.STRIDE, offset: 0, divisor: 1 }, a_instanceSize: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: T.STRIDE, offset: 8, divisor: 1 }, a_instanceCharacter: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: T.STRIDE, offset: 16, divisor: 1 }, a_instancePrimaryColor: { location: -1, size: 4, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: T.STRIDE, offset: 28, divisor: 1 }, a_instanceSecondaryColor: { location: -1, size: 4, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: T.STRIDE, offset: 44, divisor: 1 }, a_instanceRotation: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: T.STRIDE, offset: 60, divisor: 1 }, a_instanceTransform: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: T.STRIDE, offset: 68, divisor: 1 }, a_instanceGlobalRotation: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: T.STRIDE, offset: 80, divisor: 1 }, a_instanceRotationCenter: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: T.STRIDE, offset: 92, divisor: 1 }, a_instanceArcAngles: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: T.STRIDE, offset: 100, divisor: 1 }, a_instanceBezierCP1: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: T.STRIDE, offset: 108, divisor: 1 }, a_instanceBezierCP2: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: T.STRIDE, offset: 116, divisor: 1 }, a_instanceBezierStart: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: T.STRIDE, offset: 124, divisor: 1 }, a_instanceBezierEnd: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: T.STRIDE, offset: 132, divisor: 1 } });
568
+ let H = T;
569
+ class mt {
601
570
  constructor(t, e = 1e3, i = 1.5) {
602
- c(this, "bt");
603
- c(this, "Xe", []);
604
- c(this, "je");
605
- c(this, "Ye");
606
- c(this, "qe", null);
607
- c(this, "Ze", !0);
608
- c(this, "Je", 0);
609
- c(this, "Qe", /* @__PURE__ */ new Map());
610
- c(this, "ts", null);
611
- this.bt = t, this.je = e, this.Ye = i, this.es();
612
- }
613
- ze(t) {
614
- const e = this.Xe.length;
615
- return this.Xe.push(t), this.Ze = !0, e;
571
+ a(this, "vt");
572
+ a(this, "Qe", []);
573
+ a(this, "ts");
574
+ a(this, "es");
575
+ a(this, "ss", null);
576
+ a(this, "rs", !0);
577
+ a(this, "ns", 0);
578
+ a(this, "hs", /* @__PURE__ */ new Map());
579
+ a(this, "cs", null);
580
+ this.vt = t, this.ts = e, this.es = i, this.ls();
581
+ }
582
+ Re(t) {
583
+ const e = this.Qe.length;
584
+ return this.Qe.push(t), this.rs = !0, e;
616
585
  }
617
586
  get count() {
618
- return this.Xe.length;
587
+ return this.Qe.length;
619
588
  }
620
589
  get isEmpty() {
621
- return this.Xe.length === 0;
590
+ return this.Qe.length === 0;
622
591
  }
623
592
  clear() {
624
- this.Xe.length = 0, this.Ze = !0;
625
- }
626
- ss(t) {
627
- if (t <= this.je) return;
628
- const e = Math.ceil(t * this.Ye);
629
- this.je = e, this.es();
630
- }
631
- es() {
632
- const t = this.bt;
633
- this.qe && t.deleteBuffer(this.qe), this.qe = t.createBuffer();
634
- const e = this.je * _.BYTES_PER_INSTANCE;
635
- t.bindBuffer(t.ARRAY_BUFFER, this.qe), t.bufferData(t.ARRAY_BUFFER, e, t.DYNAMIC_DRAW), t.bindBuffer(t.ARRAY_BUFFER, null), this.Ze = !0, this.Je = 0;
636
- }
637
- rs() {
638
- if (!this.Ze || this.Xe.length === 0) return;
639
- const t = this.bt, e = this.Xe.length;
640
- this.ss(e), (!this.ts || this.ts.length < e * _.FLOATS_PER_INSTANCE) && (this.ts = new Float32Array(e * _.FLOATS_PER_INSTANCE));
641
- const i = _.Ne(this.Xe);
642
- t.bindBuffer(t.ARRAY_BUFFER, this.qe), e <= this.Je ? t.bufferSubData(t.ARRAY_BUFFER, 0, i) : t.bufferData(t.ARRAY_BUFFER, i, t.DYNAMIC_DRAW), t.bindBuffer(t.ARRAY_BUFFER, null), this.Ze = !1, this.Je = e;
643
- }
644
- ns(t) {
645
- let e = this.Qe.get(t);
593
+ this.Qe.length = 0, this.rs = !0;
594
+ }
595
+ us(t) {
596
+ if (t <= this.ts) return;
597
+ const e = Math.ceil(t * this.es);
598
+ this.ts = e, this.ls();
599
+ }
600
+ ls() {
601
+ const t = this.vt;
602
+ this.ss && t.deleteBuffer(this.ss), this.ss = t.createBuffer();
603
+ const e = this.ts * B.BYTES_PER_INSTANCE;
604
+ t.bindBuffer(t.ARRAY_BUFFER, this.ss), t.bufferData(t.ARRAY_BUFFER, e, t.DYNAMIC_DRAW), t.bindBuffer(t.ARRAY_BUFFER, null), this.rs = !0, this.ns = 0;
605
+ }
606
+ fs() {
607
+ if (!this.rs || this.Qe.length === 0) return;
608
+ const t = this.vt, e = this.Qe.length;
609
+ this.us(e), (!this.cs || this.cs.length < e * B.FLOATS_PER_INSTANCE) && (this.cs = new Float32Array(e * B.FLOATS_PER_INSTANCE));
610
+ const i = B.Je(this.Qe);
611
+ t.bindBuffer(t.ARRAY_BUFFER, this.ss), e <= this.ns ? t.bufferSubData(t.ARRAY_BUFFER, 0, i) : t.bufferData(t.ARRAY_BUFFER, i, t.DYNAMIC_DRAW), t.bindBuffer(t.ARRAY_BUFFER, null), this.rs = !1, this.ns = e;
612
+ }
613
+ ds(t) {
614
+ let e = this.hs.get(t);
646
615
  if (!e) {
647
616
  e = /* @__PURE__ */ new Map();
648
- const i = this.bt;
649
- for (const r in k.ATTRIBUTES) {
650
- const s = i.getAttribLocation(t, r);
651
- s !== -1 && e.set(r, s);
617
+ const i = this.vt;
618
+ for (const s in H.ATTRIBUTES) {
619
+ const r = i.getAttribLocation(t, s);
620
+ r !== -1 && e.set(s, r);
652
621
  }
653
- this.Qe.set(t, e);
622
+ this.hs.set(t, e);
654
623
  }
655
624
  return e;
656
625
  }
657
- we(t) {
658
- if (!this.qe || this.Xe.length === 0) return;
659
- const e = this.bt, i = t.ie;
660
- this.rs();
661
- const r = this.ns(i);
662
- e.bindBuffer(e.ARRAY_BUFFER, this.qe);
663
- for (const [s, n] of r) {
664
- const o = k.ATTRIBUTES[s];
626
+ Ce(t) {
627
+ if (!this.ss || this.Qe.length === 0) return;
628
+ const e = this.vt, i = t.Jt;
629
+ this.fs();
630
+ const s = this.ds(i);
631
+ e.bindBuffer(e.ARRAY_BUFFER, this.ss);
632
+ for (const [r, n] of s) {
633
+ const o = H.ATTRIBUTES[r];
665
634
  o && (e.enableVertexAttribArray(n), e.vertexAttribPointer(n, o.size, o.type, o.normalized, o.stride, o.offset), e.vertexAttribDivisor(n, o.divisor));
666
635
  }
667
636
  }
668
- Me(t) {
669
- const e = this.bt, i = this.ns(t.ie);
670
- for (const [, r] of i) e.disableVertexAttribArray(r), e.vertexAttribDivisor(r, 0);
637
+ xe(t) {
638
+ const e = this.vt, i = this.ds(t.Jt);
639
+ for (const [, s] of i) e.disableVertexAttribArray(s), e.vertexAttribDivisor(s, 0);
671
640
  }
672
- xe(t, e) {
673
- this.Xe.length !== 0 && this.bt.drawArraysInstanced(t, 0, e, this.Xe.length);
641
+ we(t, e) {
642
+ this.Qe.length !== 0 && this.vt.drawArraysInstanced(t, 0, e, this.Qe.length);
674
643
  }
675
- Ut() {
676
- const t = this.bt;
677
- this.qe && (t.deleteBuffer(this.qe), this.qe = null), this.Xe.length = 0, this.Qe.clear(), this.ts = null;
644
+ Pt() {
645
+ this.ss && this.vt.deleteBuffer(this.ss);
678
646
  }
679
647
  }
680
- class S {
681
- constructor(t, e, i, r) {
682
- c(this, "bt");
683
- c(this, "hs");
684
- c(this, "cs");
685
- c(this, "ls");
686
- c(this, "us", null);
687
- this.bt = t, this.hs = e, this.cs = i, this.ls = r;
688
- const s = this.bt.createBuffer();
689
- if (!s) throw Error("Failed to create unit geometry buffer");
690
- this.bt.bindBuffer(this.bt.ARRAY_BUFFER, s), this.bt.bufferData(this.bt.ARRAY_BUFFER, this.ls.fs, this.bt.STATIC_DRAW), this.bt.bindBuffer(this.bt.ARRAY_BUFFER, null), this.us = s;
648
+ class D {
649
+ constructor(t, e, i, s) {
650
+ a(this, "vt");
651
+ a(this, "_s");
652
+ a(this, "ps");
653
+ a(this, "gs");
654
+ a(this, "vs", null);
655
+ this.vt = t, this._s = e, this.ps = i, this.gs = s;
656
+ const r = this.vt.createBuffer();
657
+ if (!r) throw Error("Failed to create unit geometry buffer");
658
+ this.vt.bindBuffer(this.vt.ARRAY_BUFFER, r), this.vt.bufferData(this.vt.ARRAY_BUFFER, this.gs.Cs, this.vt.STATIC_DRAW), this.vt.bindBuffer(this.vt.ARRAY_BUFFER, null), this.vs = r;
691
659
  }
692
660
  get type() {
693
- return this.cs;
661
+ return this.ps;
694
662
  }
695
663
  get unitGeometry() {
696
- return this.ls;
664
+ return this.gs;
697
665
  }
698
666
  get unitBuffer() {
699
- return this.us;
667
+ return this.vs;
700
668
  }
701
669
  get batch() {
702
- return this.hs;
670
+ return this._s;
703
671
  }
704
- Se() {
705
- this.hs.clear();
672
+ Fe() {
673
+ this._s.clear();
706
674
  }
707
- Ce() {
708
- return !this.hs.isEmpty;
675
+ ye() {
676
+ return !this._s.isEmpty;
709
677
  }
710
- Ut() {
711
- this.hs.Ut(), this.us && (this.bt.deleteBuffer(this.us), this.us = null);
678
+ Pt() {
679
+ this._s.Pt(), this.vt.deleteBuffer(this.vs);
712
680
  }
713
- ds(t, e, i, r, s) {
714
- const n = this._s(t, e, i, r, s.rotationX || 0, s.rotationY || 0, s.rotationZ || 0);
715
- return { position: [t, e], size: [i, r], tt: s.character || [0, 0, 0], primaryColor: s.charColor || [1, 1, 1, 1], secondaryColor: s.bgColor || [0, 0, 0, 1], rotation: s.charRotation || [0, 0], transform: [s.invert ? 1 : 0, s.flipHorizontally ? 1 : 0, s.flipVertically ? 1 : 0], globalRotationX: n.radiansX, globalRotationY: n.radiansY, globalRotationZ: n.radiansZ, rotationCenter: [n.centerX, n.centerY] };
681
+ ws(t, e, i, s, r) {
682
+ const n = this.$s(t, e, i, s, r.H || 0, r.V || 0, r.K || 0);
683
+ return { le: [t, e], Le: [i, s], j: r.j || [0, 0, 0], Y: r.Y || [1, 1, 1, 1], q: r.q || [0, 0, 0, 1], G: r.G || [0, 0], Ke: [r.P ? 1 : 0, r.N ? 1 : 0, r.X ? 1 : 0], H: n.radiansX, V: n.radiansY, K: n.radiansZ, Ne: [n.centerX, n.centerY] };
716
684
  }
717
- ps(t, e) {
718
- const i = I(this.bt) || [0, 0, this.bt.canvas.width, this.bt.canvas.height];
685
+ bs(t, e) {
686
+ const i = X(this.vt) || [0, 0, this.vt.canvas.width, this.vt.canvas.height];
719
687
  return { nx: t / i[2] * 2 - 1, ny: 1 - e / i[3] * 2 };
720
688
  }
721
- gs(t, e, i) {
722
- const r = this.ps(e, i);
723
- t.rotationCenter = [r.nx, r.ny];
689
+ Fs(t, e, i) {
690
+ const s = this.bs(e, i);
691
+ t.Ne = [s.nx, s.ny];
724
692
  }
725
- _s(t, e, i, r, s, n, o) {
726
- const h = I(this.bt) || [0, 0, this.bt.canvas.width, this.bt.canvas.height], l = h[2], u = h[3];
727
- return { centerX: (t + i / 2) / l * 2 - 1, centerY: 1 - (e + r / 2) / u * 2, radiansX: -s * Math.PI / 180, radiansY: -n * Math.PI / 180, radiansZ: -o * Math.PI / 180, aspectRatio: l / u };
693
+ $s(t, e, i, s, r, n, o) {
694
+ const c = X(this.vt) || [0, 0, this.vt.canvas.width, this.vt.canvas.height], l = c[2], f = c[3];
695
+ return { centerX: (t + i / 2) / l * 2 - 1, centerY: 1 - (e + s / 2) / f * 2, radiansX: -r * Math.PI / 180, radiansY: -n * Math.PI / 180, radiansZ: -o * Math.PI / 180, aspectRatio: l / f };
728
696
  }
729
697
  }
730
- const at = { fs: new Float32Array([0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1]), Re: 6, be: WebGL2RenderingContext.TRIANGLES, _e: 16, de: { fe: { size: 2, offset: 0 }, pe: { size: 2, offset: 8 } } };
731
- class ht extends S {
698
+ const vt = { Cs: new Float32Array([0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1]), be: 6, $e: WebGL2RenderingContext.TRIANGLES, fe: 16, ue: { le: { size: 2, offset: 0 }, de: { size: 2, offset: 8 } } };
699
+ class xt extends D {
732
700
  constructor(t, e) {
733
- super(t, e, b.RECTANGLE, at);
701
+ super(t, e, w.RECTANGLE, vt);
734
702
  }
735
- ze(t, e) {
736
- const i = this.ds(t.x, t.y, t.width, t.height, e);
737
- return this.hs.ze(i);
703
+ Re(t, e) {
704
+ const i = this.ws(t.x, t.y, t.width, t.height, e);
705
+ return this._s.Re(i);
738
706
  }
739
707
  }
740
- const ct = { fs: new Float32Array([0, -0.5, 0, 0, 1, -0.5, 1, 0, 0, 0.5, 0, 1, 0, 0.5, 0, 1, 1, -0.5, 1, 0, 1, 0.5, 1, 1]), Re: 6, be: WebGL2RenderingContext.TRIANGLES, _e: 16, de: { fe: { size: 2, offset: 0 }, pe: { size: 2, offset: 8 } } };
741
- class lt extends S {
708
+ const yt = { Cs: new Float32Array([0, -0.5, 0, 0, 1, -0.5, 1, 0, 0, 0.5, 0, 1, 0, 0.5, 0, 1, 1, -0.5, 1, 0, 1, 0.5, 1, 1]), be: 6, $e: WebGL2RenderingContext.TRIANGLES, fe: 16, ue: { le: { size: 2, offset: 0 }, de: { size: 2, offset: 8 } } };
709
+ class Et extends D {
742
710
  constructor(t, e) {
743
- super(t, e, b.LINE, ct);
711
+ super(t, e, w.LINE, yt);
744
712
  }
745
- ze(t, e) {
746
- const i = t.x2 - t.x1, r = t.y2 - t.y1, s = Math.hypot(i, r), n = Math.atan2(r, i), o = t.thickness || e.lineWeight || 1, h = t.x1 + i / 2, l = t.y1 + r / 2, u = h - s / 2, f = l, d = { character: e.character, charColor: e.charColor, bgColor: e.bgColor, charRotation: e.charRotation, flipHorizontally: e.flipHorizontally, flipVertically: e.flipVertically, invert: e.invert, rotationX: e.rotationX || 0, rotationY: e.rotationY || 0, rotationZ: (e.rotationZ || 0) + 180 * n / Math.PI, lineWeight: o }, p = this.ds(u, f, s, o, d);
747
- return this.gs(p, h, l), this.hs.ze(p);
713
+ Re(t, e) {
714
+ const i = t.x2 - t.x1, s = t.y2 - t.y1, r = Math.hypot(i, s), n = t.thickness || e.O || 1, o = t.x1 + i / 2, c = t.y1 + s / 2, l = o - r / 2, f = c, u = this.ws(l, f, r, n, e);
715
+ return this.Fs(u, o, c), this._s.Re(u);
748
716
  }
749
717
  }
750
- const ut = { fs: function(a = 32) {
751
- const t = [], e = 2 * Math.PI / a;
752
- for (let i = 0; i < a; i++) {
753
- const r = i * e, s = (i + 1) % a * e, n = Math.cos(r), o = Math.sin(r), h = 0.5 * (n + 1), l = 0.5 * (o + 1), u = Math.cos(s), f = Math.sin(s), d = 0.5 * (u + 1), p = 0.5 * (f + 1);
754
- t.push(0, 0, 0.5, 0.5, n, o, h, l, u, f, d, p);
718
+ const wt = { Cs: function(h = 32) {
719
+ const t = [], e = 2 * Math.PI / h;
720
+ for (let i = 0; i < h; i++) {
721
+ const s = i * e, r = (i + 1) % h * e, n = Math.cos(s), o = Math.sin(s), c = 0.5 * (n + 1), l = 0.5 * (o + 1), f = Math.cos(r), u = Math.sin(r), g = 0.5 * (f + 1), v = 0.5 * (u + 1);
722
+ t.push(0, 0, 0.5, 0.5, n, o, c, l, f, u, g, v);
755
723
  }
756
724
  return new Float32Array(t);
757
- }(32), Re: 96, be: WebGL2RenderingContext.TRIANGLES, _e: 16, de: { fe: { size: 2, offset: 0 }, pe: { size: 2, offset: 8 } } };
758
- class ft extends S {
725
+ }(32), be: 96, $e: WebGL2RenderingContext.TRIANGLES, fe: 16, ue: { le: { size: 2, offset: 0 }, de: { size: 2, offset: 8 } } };
726
+ class Rt extends D {
759
727
  constructor(t, e) {
760
- super(t, e, b.ELLIPSE, ut);
728
+ super(t, e, w.ELLIPSE, wt);
761
729
  }
762
- ze(t, e) {
763
- const i = this.ds(t.x, t.y, t.width, t.height, e);
764
- return this.gs(i, t.x, t.y), this.hs.ze(i);
730
+ Re(t, e) {
731
+ const i = this.ws(t.x, t.y, t.width, t.height, e);
732
+ return this.Fs(i, t.x, t.y), this._s.Re(i);
765
733
  }
766
734
  }
767
- let dt = { fs: function(a) {
735
+ let bt = { Cs: function(h) {
768
736
  const t = [];
769
- for (let e = 0; e < a; e++) {
770
- const i = e / a, r = (e + 1) / a;
771
- t.push(i, 0, i, 0, i, 1, i, 1, r, 1, r, 1);
737
+ for (let e = 0; e < h; e++) {
738
+ const i = e / h, s = (e + 1) / h;
739
+ t.push(i, 0, i, 0, i, 1, i, 1, s, 1, s, 1);
772
740
  }
773
741
  return new Float32Array(t);
774
- }(32), Re: 96, be: WebGL2RenderingContext.TRIANGLES, _e: 16, de: { fe: { size: 2, offset: 0 }, pe: { size: 2, offset: 8 } } };
775
- class pt extends S {
742
+ }(32), be: 96, $e: WebGL2RenderingContext.TRIANGLES, fe: 16, ue: { le: { size: 2, offset: 0 }, de: { size: 2, offset: 8 } } };
743
+ class At extends D {
776
744
  constructor(t, e) {
777
- super(t, e, b.ARC, dt);
745
+ super(t, e, w.ARC, bt);
778
746
  }
779
- ze(t, e) {
780
- const i = t.x - t.width / 2, r = t.y - t.height / 2, s = t.start * Math.PI / 180, n = t.stop * Math.PI / 180, o = this.ds(i, r, t.width, t.height, e);
781
- return this.gs(o, t.x, t.y), o.arcAngles = [s, n], this.hs.ze(o);
747
+ Re(t, e) {
748
+ const i = t.x - t.width / 2, s = t.y - t.height / 2, r = t.start * Math.PI / 180, n = t.stop * Math.PI / 180, o = this.ws(i, s, t.width, t.height, e);
749
+ return this.Fs(o, t.x, t.y), o.Xe = [r, n], this._s.Re(o);
782
750
  }
783
751
  }
784
- const gt = { fs: new Float32Array([0, 0, 0, 0, 1, 0, 1, 0, 0.5, 1, 0.5, 1]), Re: 3, be: WebGL2RenderingContext.TRIANGLES, _e: 16, de: { fe: { size: 2, offset: 0 }, pe: { size: 2, offset: 8 } } };
785
- class mt extends S {
752
+ const Tt = { Cs: new Float32Array([0, 0, 0, 0, 1, 0, 1, 0, 0.5, 1, 0.5, 1]), be: 3, $e: WebGL2RenderingContext.TRIANGLES, fe: 16, ue: { le: { size: 2, offset: 0 }, de: { size: 2, offset: 8 } } };
753
+ class Ct extends D {
786
754
  constructor(t, e) {
787
- super(t, e, b.TRIANGLE, gt);
755
+ super(t, e, w.TRIANGLE, Tt);
788
756
  }
789
- ze(t, e) {
790
- const i = Math.min(t.x1, t.x2, t.x3), r = Math.max(t.x1, t.x2, t.x3), s = Math.min(t.y1, t.y2, t.y3), n = r - i, o = Math.max(t.y1, t.y2, t.y3) - s, h = this.ds(i, s, n, o, e), l = i + 0.5 * n, u = s + o * (1 / 3);
791
- return this.gs(h, l, u), this.hs.ze(h);
757
+ Re(t, e) {
758
+ const i = Math.min(t.x1, t.x2, t.x3), s = Math.max(t.x1, t.x2, t.x3), r = Math.min(t.y1, t.y2, t.y3), n = s - i, o = Math.max(t.y1, t.y2, t.y3) - r, c = this.ws(i, r, n, o, e), l = i + 0.5 * n, f = r + o * (1 / 3);
759
+ return this.Fs(c, l, f), this._s.Re(c);
792
760
  }
793
761
  }
794
- function N(a, t, e, i, r) {
795
- const s = 1 - a, n = s * s, o = a * a;
796
- return n * s * t + 3 * n * a * e + 3 * s * o * i + o * a * r;
762
+ function et(h, t, e, i, s) {
763
+ const r = 1 - h, n = r * r, o = h * h;
764
+ return n * r * t + 3 * n * h * e + 3 * r * o * i + o * h * s;
797
765
  }
798
- const bt = { fs: function(a = 16) {
766
+ const Ut = { Cs: function(h = 16) {
799
767
  const t = [];
800
- for (let e = 0; e < a; e++) {
801
- const i = e / a, r = (e + 1) / a;
802
- t.push(i, -0.5, i, 0), t.push(r, -0.5, r, 0), t.push(i, 0.5, i, 1), t.push(i, 0.5, i, 1), t.push(r, -0.5, r, 0), t.push(r, 0.5, r, 1);
768
+ for (let e = 0; e < h; e++) {
769
+ const i = e / h, s = (e + 1) / h;
770
+ t.push(i, -0.5, i, 0), t.push(s, -0.5, s, 0), t.push(i, 0.5, i, 1), t.push(i, 0.5, i, 1), t.push(s, -0.5, s, 0), t.push(s, 0.5, s, 1);
803
771
  }
804
772
  return new Float32Array(t);
805
- }(16), Re: 96, be: WebGL2RenderingContext.TRIANGLES, _e: 16, de: { fe: { size: 2, offset: 0 }, pe: { size: 2, offset: 8 } } };
806
- class yt extends S {
773
+ }(16), be: 96, $e: WebGL2RenderingContext.TRIANGLES, fe: 16, ue: { le: { size: 2, offset: 0 }, de: { size: 2, offset: 8 } } };
774
+ class _t extends D {
807
775
  constructor(t, e) {
808
- super(t, e, b.BEZIER_CURVE, bt);
776
+ super(t, e, w.BEZIER_CURVE, Ut);
809
777
  }
810
- ze(t, e) {
811
- const i = e.lineWeight || 1, r = N(0.5, t.x1, t.cp1x, t.cp2x, t.x2), s = N(0.5, t.y1, t.cp1y, t.cp2y, t.y2), n = { character: e.character, charColor: e.charColor, bgColor: e.bgColor, charRotation: e.charRotation, flipHorizontally: e.flipHorizontally, flipVertically: e.flipVertically, invert: e.invert, rotationX: e.rotationX || 0, rotationY: e.rotationY || 0, rotationZ: e.rotationZ || 0, lineWeight: i }, o = this.ds(0, 0, 1, i, n);
812
- return this.gs(o, r, s), o.bezierStartPoint = [t.x1, t.y1], o.bezierControlPoint1 = [t.cp1x, t.cp1y], o.bezierControlPoint2 = [t.cp2x, t.cp2y], o.bezierEndPoint = [t.x2, t.y2], this.hs.ze(o);
778
+ Re(t, e) {
779
+ const i = e.O || 1, s = et(0.5, t.x1, t.cp1x, t.cp2x, t.x2), r = et(0.5, t.y1, t.cp1y, t.cp2y, t.y2), n = this.ws(0, 0, 1, i, e);
780
+ return this.Fs(n, s, r), n.qe = [t.x1, t.y1], n.je = [t.cp1x, t.cp1y], n.Ye = [t.cp2x, t.cp2y], n.Ze = [t.x2, t.y2], this._s.Re(n);
813
781
  }
814
782
  }
815
- class vt {
783
+ class Ft {
816
784
  constructor(t) {
817
- c(this, "bt");
818
- c(this, "vs", null);
819
- c(this, "$s");
820
- c(this, "Cs", null);
821
- c(this, "ws", {});
822
- c(this, "bs", null);
823
- c(this, "Rs", /* @__PURE__ */ new Map());
824
- c(this, "Ms");
825
- c(this, "Ss");
826
- c(this, "Fs");
827
- c(this, "K", []);
828
- this.bt = t, this.$s = new it(t), this.Fs = new j(), this.Ms = new st(t, this), this.Ss = new nt(), this.bs = t.createBuffer(), U(this.bt, [0, 0, this.bt.canvas.width, this.bt.canvas.height]);
829
- }
830
- zs(t) {
831
- let e = this.Rs.get(t);
785
+ a(this, "vt");
786
+ a(this, "Ms", null);
787
+ a(this, "Rs");
788
+ a(this, "Ss", null);
789
+ a(this, "As", {});
790
+ a(this, "zs", null);
791
+ a(this, "Ts", /* @__PURE__ */ new Map());
792
+ a(this, "Es");
793
+ a(this, "Ls");
794
+ a(this, "ks");
795
+ a(this, "I", []);
796
+ this.vt = t, this.Rs = new ft(t), this.ks = new ht(), this.Es = new gt(t, this), this.Ls = new pt(), this.zs = t.createBuffer(), W(this.vt, [0, 0, this.vt.canvas.width, this.vt.canvas.height]);
797
+ }
798
+ Ps(t) {
799
+ let e = this.Ts.get(t);
832
800
  if (e) return e;
833
- const i = new ot(this.bt);
834
- return e = (0, { [b.RECTANGLE]: () => new ht(this.bt, i), [b.LINE]: () => new lt(this.bt, i), [b.ELLIPSE]: () => new ft(this.bt, i), [b.ARC]: () => new pt(this.bt, i), [b.TRIANGLE]: () => new mt(this.bt, i), [b.BEZIER_CURVE]: () => new yt(this.bt, i) }[t])(), this.Rs.set(t, e), e;
801
+ const i = new mt(this.vt);
802
+ return e = (0, { [w.RECTANGLE]: () => new xt(this.vt, i), [w.LINE]: () => new Et(this.vt, i), [w.ELLIPSE]: () => new Rt(this.vt, i), [w.ARC]: () => new At(this.vt, i), [w.TRIANGLE]: () => new Ct(this.vt, i), [w.BEZIER_CURVE]: () => new _t(this.vt, i) }[t])(), this.Ts.set(t, e), e;
803
+ }
804
+ Gs(t) {
805
+ this.Ms !== t && (this.Ms = t, t.Vt());
806
+ }
807
+ ae(t, e) {
808
+ return this.Rs.ae(t, e);
835
809
  }
836
- ks(t) {
837
- this.vs !== t && (this.vs = t, t.Yt());
810
+ ie() {
811
+ return this.Rs.ie();
838
812
  }
839
- Ps(t, e) {
840
- return this.$s.ce(t, e);
813
+ Tt() {
814
+ return this.Rs.Tt();
841
815
  }
842
- oe() {
843
- return this.$s.oe();
816
+ re() {
817
+ return this.Rs.re();
844
818
  }
845
- Bt() {
846
- return this.$s.Bt();
819
+ ne() {
820
+ return this.Rs.ne();
847
821
  }
848
- ae() {
849
- return this.$s.ae();
822
+ Bs(t) {
823
+ this.Ss = t, t && (this.As = {});
850
824
  }
851
- Ts(t) {
852
- this.Cs = t, t && (this.ws = {});
825
+ Xt(t, e) {
826
+ this.As[t] = e;
853
827
  }
854
- Jt(t, e) {
855
- this.ws[t] = e;
828
+ Ds(t) {
829
+ Object.assign(this.As, t);
856
830
  }
857
- As(t) {
858
- Object.assign(this.ws, t);
831
+ oe(t) {
832
+ return this.Rs.oe(t);
859
833
  }
860
- he(t) {
861
- return this.$s.he(t);
834
+ Is(t, e, i, s, r) {
835
+ const n = this.ie(), o = { Ue: t.textures[0], Uf: t.textures[1], Ug: t.textures[2], Uh: t.textures[3], Ui: t.textures[4], Uj: [t.width, t.height] };
836
+ this.Ls.Ge(e, i, s, r, n, o, this.ks);
862
837
  }
863
- Gs(t, e, i, r, s) {
864
- const n = this.oe(), o = { l: t.textures[0], m: t.textures[1], n: t.textures[2], o: t.textures[3], p: t.textures[4], q: [t.width, t.height] };
865
- this.Ss.De(e, i, r, s, n, o, this.Fs);
838
+ Ws(t, e, i, s, r) {
839
+ const n = this.ne(), o = t.texture, c = t.flags, l = t.charRotationRG, f = [l[0], l[1]], u = t.colorUniforms ?? { charColorFixed: !1, Y: [1, 1, 1], cellColorFixed: !1, cellColor: [0, 0, 0], backgroundColor: [0, 0, 0, 1] }, g = t.characterListUniforms, v = { Uk: o, Ul: !!c.invert, Um: !!c.flipX, Un: !!c.flipY, Uo: f, Up: !!u.charColorFixed, Uq: u.Y, Ur: !!u.cellColorFixed, Us: u.cellColor, Ut: u.backgroundColor, Uu: g.count, Uv: g.list };
840
+ this.Ls.Ge(e, i, s, r, n, v, this.ks);
866
841
  }
867
- Ls(t, e, i, r) {
868
- var m;
869
- const s = this.bt, n = s.canvas.width, o = s.canvas.height, h = t / n * 2 - 1, l = (t + i) / n * 2 - 1, u = 1 - e / o * 2, f = 1 - (e + r) / o * 2, d = new Float32Array([h, f, l, f, h, u, l, f, l, u, h, u]);
870
- s.bindBuffer(s.ARRAY_BUFFER, this.bs), s.bufferData(s.ARRAY_BUFFER, d, s.DYNAMIC_DRAW);
871
- const p = ((m = this.vs) == null ? void 0 : m.ie) || s.getParameter(s.CURRENT_PROGRAM), g = p ? s.getAttribLocation(p, "a_position") : -1;
872
- g !== -1 && (s.enableVertexAttribArray(g), s.vertexAttribPointer(g, 2, s.FLOAT, !1, 8, 0)), s.drawArrays(s.TRIANGLES, 0, 6), g !== -1 && s.disableVertexAttribArray(g);
842
+ Os(t, e, i, s) {
843
+ var d;
844
+ const r = this.vt, n = r.canvas.width, o = r.canvas.height, c = t / n * 2 - 1, l = (t + i) / n * 2 - 1, f = 1 - e / o * 2, u = 1 - (e + s) / o * 2, g = new Float32Array([c, u, l, u, c, f, l, u, l, f, c, f]);
845
+ r.bindBuffer(r.ARRAY_BUFFER, this.zs), r.bufferData(r.ARRAY_BUFFER, g, r.DYNAMIC_DRAW);
846
+ const v = ((d = this.Ms) == null ? void 0 : d.Jt) || r.getParameter(r.CURRENT_PROGRAM), m = v ? r.getAttribLocation(v, "a_position") : -1;
847
+ m !== -1 && (r.enableVertexAttribArray(m), r.vertexAttribPointer(m, 2, r.FLOAT, !1, 8, 0)), r.drawArrays(r.TRIANGLES, 0, 6), m !== -1 && r.disableVertexAttribArray(m);
873
848
  }
874
- Es(t, e, i, r) {
875
- this.Cs ? (this.Ss.De(t, e, i, r, this.Cs, { ...this.ws }, this.Fs), this.Cs = null, this.ws = {}) : this.Ss.Be(t, e, i, r, this.Fs);
849
+ Hs(t, e, i, s) {
850
+ this.Ss ? (this.Ls.Ge(t, e, i, s, this.Ss, { ...this.As }, this.ks), this.Ss = null, this.As = {}) : this.Ls.Pe(t, e, i, s, this.ks);
876
851
  }
877
- Bs(t, e, i, r) {
878
- this.Ss.We(t, e, i, r, this.Fs.lineWeight, this.Fs);
852
+ Vs(t, e, i, s) {
853
+ this.Ls.Be(t, e, i, s, this.ks.lineWeight, this.ks);
879
854
  }
880
- Ds(t, e, i, r) {
881
- this.Ss.Ie(t, e, i, r, this.Fs);
855
+ Ks(t, e, i, s) {
856
+ this.Ls.De(t, e, i, s, this.ks);
882
857
  }
883
- Ws(t, e, i, r, s, n) {
884
- this.Ss.Ve(t, e, i, r, s, n, this.Fs);
858
+ Ns(t, e, i, s, r, n) {
859
+ this.Ls.We(t, e, i, s, r, n, this.ks);
885
860
  }
886
- Is(t, e, i, r, s, n, o, h) {
887
- const l = this.Fs.lineWeight;
888
- this.Ss.Oe(t, e, i, r, s, n, o, h, l, this.Fs);
861
+ Xs(t, e, i, s, r, n, o, c) {
862
+ const l = this.ks.lineWeight;
863
+ this.Ls.Oe(t, e, i, s, r, n, o, c, l, this.ks);
889
864
  }
890
- Us(t, e, i = 1, r = {}) {
891
- return new D(this.bt, t, e, i, r, this, !0);
865
+ js(t, e, i = 1, s = {}) {
866
+ return new K(this.vt, t, e, i, s, this, !0);
892
867
  }
893
- Vs(t, e, i, r, s, n) {
894
- this.Ss.Ue(t, e, i, r, s, n, this.Fs);
868
+ Ys(t, e, i, s, r, n) {
869
+ this.Ls.Ie(t, e, i, s, r, n, this.ks);
895
870
  }
896
- Os(t, e = t, i = t, r = 255) {
897
- this.state.$t(t, e, i, r), this.He(t / 255, e / 255, i / 255, r / 255);
871
+ qs(t, e = t, i = t, s = 255) {
872
+ this.state.ft(t, e, i, s), this.He(t / 255, e / 255, i / 255, s / 255);
898
873
  }
899
- He(t = 0, e = 0, i = 0, r = 0) {
900
- this.bt.clearColor(t, e, i, r), this.bt.clear(this.bt.COLOR_BUFFER_BIT);
874
+ He(t = 0, e = 0, i = 0, s = 0) {
875
+ this.vt.clearColor(t, e, i, s), this.vt.clear(this.vt.COLOR_BUFFER_BIT);
901
876
  }
902
- Hs() {
903
- this.bt.viewport(0, 0, this.bt.canvas.width, this.bt.canvas.height), U(this.bt, [0, 0, this.bt.canvas.width, this.bt.canvas.height]);
877
+ Zs() {
878
+ this.vt.viewport(0, 0, this.vt.canvas.width, this.vt.canvas.height), W(this.vt, [0, 0, this.vt.canvas.width, this.vt.canvas.height]);
904
879
  }
905
880
  get context() {
906
- return this.bt;
881
+ return this.vt;
907
882
  }
908
883
  get state() {
909
- return this.Fs;
884
+ return this.ks;
910
885
  }
911
- Wt(t) {
912
- this.K.push(this.Fs), this.Fs = t;
913
- }
914
- It() {
915
- const t = this.K.pop();
916
- t && (this.Fs = t);
886
+ Lt(t) {
887
+ this.I.push(this.ks), this.ks = t;
917
888
  }
918
- Dt(t) {
919
- const e = t, i = I(this.bt) ?? this.bt.getParameter(this.bt.VIEWPORT), r = { shader: e, gl: this.bt, viewport: i };
920
- this.ks(e);
921
- const s = /* @__PURE__ */ new Set();
922
- for (const n of this.Ss) n.type === b.CUSTOM ? s.add(b.RECTANGLE) : s.add(n.type);
923
- for (const n of s) n !== b.CUSTOM && this.zs(n);
924
- this.Ms.$e(r, this.Ss, this.Rs), this.Ss.He();
889
+ kt() {
890
+ const t = this.I.pop();
891
+ t && (this.ks = t);
925
892
  }
926
- Ut() {
927
- this.bt.deleteBuffer(this.bs), this.Ss.He();
928
- for (const t of this.Rs.values()) t.Ut();
929
- this.$s.Ut();
893
+ Et(t) {
894
+ const e = t, i = X(this.vt) ?? this.vt.getParameter(this.vt.VIEWPORT), s = { shader: e, gl: this.vt, viewport: i };
895
+ this.Gs(e);
896
+ const r = /* @__PURE__ */ new Set();
897
+ for (const n of this.Ls) n.type === w.CUSTOM ? r.add(w.RECTANGLE) : r.add(n.type);
898
+ for (const n of r) n !== w.CUSTOM && this.Ps(n);
899
+ this.Es.ve(s, this.Ls, this.Ts), this.Ls.He();
900
+ }
901
+ Pt() {
902
+ this.vt.deleteBuffer(this.zs), this.Ls.He();
903
+ for (const t of this.Ts.values()) t.Pt();
904
+ this.Rs.Pt(), this.Es.Pt();
930
905
  }
931
906
  }
932
- const v = { readShort: (a, t) => (v.t.uint16[0] = a[t] << 8 | a[t + 1], v.t.int16[0]), readUshort: (a, t) => a[t] << 8 | a[t + 1], readUshorts(a, t, e) {
907
+ const R = { readShort: (h, t) => (R.t.uint16[0] = h[t] << 8 | h[t + 1], R.t.int16[0]), readUshort: (h, t) => h[t] << 8 | h[t + 1], readUshorts(h, t, e) {
933
908
  const i = [];
934
- for (let r = 0; r < e; r++) i.push(v.readUshort(a, t + 2 * r));
909
+ for (let s = 0; s < e; s++) i.push(R.readUshort(h, t + 2 * s));
935
910
  return i;
936
- }, readUint(a, t) {
937
- const e = v.t.uint8;
938
- return e[3] = a[t], e[2] = a[t + 1], e[1] = a[t + 2], e[0] = a[t + 3], v.t.uint32[0];
939
- }, readASCII(a, t, e) {
911
+ }, readUint(h, t) {
912
+ const e = R.t.uint8;
913
+ return e[3] = h[t], e[2] = h[t + 1], e[1] = h[t + 2], e[0] = h[t + 3], R.t.uint32[0];
914
+ }, readASCII(h, t, e) {
940
915
  let i = "";
941
- for (let r = 0; r < e; r++) i += String.fromCharCode(a[t + r]);
916
+ for (let s = 0; s < e; s++) i += String.fromCharCode(h[t + s]);
942
917
  return i;
918
+ }, writeUshort(h, t, e) {
919
+ h[t] = e >>> 8 & 255, h[t + 1] = 255 & e;
920
+ }, writeUint(h, t, e) {
921
+ h[t] = e >>> 24 & 255, h[t + 1] = e >>> 16 & 255, h[t + 2] = e >>> 8 & 255, h[t + 3] = 255 & e;
922
+ }, writeASCII(h, t, e) {
923
+ for (let i = 0; i < e.length; i++) h[t + i] = 255 & e.charCodeAt(i);
943
924
  }, t: (() => {
944
- const a = new ArrayBuffer(8);
945
- return { uint8: new Uint8Array(a), int16: new Int16Array(a), uint16: new Uint16Array(a), uint32: new Uint32Array(a) };
946
- })() }, xt = { parseTab(a, t, e) {
925
+ const h = new ArrayBuffer(8);
926
+ return { uint8: new Uint8Array(h), int16: new Int16Array(h), uint16: new Uint16Array(h), uint32: new Uint32Array(h) };
927
+ })() };
928
+ function N(h) {
929
+ return h + 3 & -4;
930
+ }
931
+ function Y(h, t, e) {
932
+ const i = t + e;
933
+ let s = 0;
934
+ const r = R.t;
935
+ for (let n = t; n < i; n += 4) r.uint8[3] = h[n] || 0, r.uint8[2] = h[n + 1] || 0, r.uint8[1] = h[n + 2] || 0, r.uint8[0] = h[n + 3] || 0, s = s + (r.uint32[0] >>> 0) >>> 0;
936
+ return s >>> 0;
937
+ }
938
+ class Lt {
939
+ constructor(t) {
940
+ a(this, "b");
941
+ a(this, "p", 0);
942
+ a(this, "bitbuf", 0);
943
+ a(this, "bitcnt", 0);
944
+ this.b = t;
945
+ }
946
+ readBits(t) {
947
+ for (; this.bitcnt < t; ) {
948
+ const i = this.b[this.p++] || 0;
949
+ this.bitbuf |= i << this.bitcnt, this.bitcnt += 8;
950
+ }
951
+ const e = this.bitbuf & (1 << t) - 1;
952
+ return this.bitbuf >>>= t, this.bitcnt -= t, e;
953
+ }
954
+ alignToByte() {
955
+ this.bitbuf = 0, this.bitcnt = 0;
956
+ }
957
+ get offset() {
958
+ return this.p;
959
+ }
960
+ }
961
+ function O(h) {
962
+ let t = 32, e = 0;
963
+ for (const o of h) o && (o < t && (t = o), o > e && (e = o));
964
+ if (e === 0) return { min: 0, max: 0, table: /* @__PURE__ */ new Map() };
965
+ const i = new Uint32Array(e + 1);
966
+ for (const o of h) o && i[o]++;
967
+ const s = new Uint32Array(e + 1);
968
+ let r = 0;
969
+ i[0] = 0;
970
+ for (let o = 1; o <= e; o++) r = r + i[o - 1] << 1, s[o] = r;
971
+ const n = /* @__PURE__ */ new Map();
972
+ for (let o = 0; o < h.length; o++) {
973
+ const c = h[o];
974
+ if (!c) continue;
975
+ const l = s[c]++;
976
+ let f = n.get(c);
977
+ f || (f = [], n.set(c, f)), f[Pt(l, c)] = o;
978
+ }
979
+ return { min: t, max: e, table: n };
980
+ }
981
+ function V(h, t) {
982
+ let e = 0;
983
+ for (let i = 1; i <= t.max; i++) {
984
+ e |= h.readBits(1) << i - 1;
985
+ const s = t.table.get(i);
986
+ if (s && e < s.length) {
987
+ const r = s[e];
988
+ if (r !== void 0) return r;
989
+ }
990
+ }
991
+ throw Error("Invalid Huffman code");
992
+ }
993
+ function Pt(h, t) {
994
+ let e = 0;
995
+ for (let i = 0; i < t; i++) e = e << 1 | 1 & h, h >>>= 1;
996
+ return e >>> 0;
997
+ }
998
+ function St(h) {
999
+ if (h.length < 2) throw Error("ZLIB data too short");
1000
+ const t = h[0], e = h[1];
1001
+ if ((15 & t) != 8) throw Error("Unsupported ZLIB compression method");
1002
+ if (((t << 8) + e) % 31 != 0) throw Error("Bad ZLIB header check");
1003
+ let i = 2;
1004
+ 32 & e && (i += 4);
1005
+ const s = [];
1006
+ return function(r, n) {
1007
+ const o = [3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258], c = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0], l = [1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577], f = [0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13];
1008
+ let u = 0;
1009
+ for (; !u; ) {
1010
+ u = r.readBits(1);
1011
+ const g = r.readBits(2);
1012
+ if (g === 0) {
1013
+ r.alignToByte();
1014
+ const v = r.readBits(16);
1015
+ if ((65535 & (65535 ^ v)) !== r.readBits(16)) throw Error("DEFLATE uncompressed LEN/NLEN mismatch");
1016
+ for (let m = 0; m < v; m++) n.push(r.readBits(8));
1017
+ } else {
1018
+ if (g !== 1 && g !== 2) throw Error("Unsupported DEFLATE type");
1019
+ {
1020
+ let v, m;
1021
+ if (g === 1) {
1022
+ const d = Array(288).fill(0);
1023
+ for (let x = 0; x <= 143; x++) d[x] = 8;
1024
+ for (let x = 144; x <= 255; x++) d[x] = 9;
1025
+ for (let x = 256; x <= 279; x++) d[x] = 7;
1026
+ for (let x = 280; x <= 287; x++) d[x] = 8;
1027
+ v = O(d), m = O(Array(32).fill(5));
1028
+ } else {
1029
+ const d = r.readBits(5) + 257, x = r.readBits(5) + 1, p = r.readBits(4) + 4, E = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15], y = Array(19).fill(0);
1030
+ for (let _ = 0; _ < p; _++) y[E[_]] = r.readBits(3);
1031
+ const C = O(y), b = [];
1032
+ for (; b.length < d + x; ) {
1033
+ const _ = V(r, C);
1034
+ if (_ <= 15) b.push(_);
1035
+ else if (_ === 16) {
1036
+ const G = r.readBits(2) + 3, S = b[b.length - 1] || 0;
1037
+ for (let tt = 0; tt < G; tt++) b.push(S);
1038
+ } else if (_ === 17) {
1039
+ const G = r.readBits(3) + 3;
1040
+ for (let S = 0; S < G; S++) b.push(0);
1041
+ } else {
1042
+ if (_ !== 18) throw Error("Invalid code length symbol");
1043
+ {
1044
+ const G = r.readBits(7) + 11;
1045
+ for (let S = 0; S < G; S++) b.push(0);
1046
+ }
1047
+ }
1048
+ }
1049
+ const A = b.slice(0, d), F = b.slice(d, d + x);
1050
+ v = O(A), m = O(F);
1051
+ }
1052
+ for (; ; ) {
1053
+ const d = V(r, v);
1054
+ if (d < 256) n.push(d);
1055
+ else {
1056
+ if (d === 256) break;
1057
+ if (d > 256 && d < 286) {
1058
+ const x = d - 257;
1059
+ let p = o[x];
1060
+ const E = c[x];
1061
+ E && (p += r.readBits(E));
1062
+ const y = V(r, m);
1063
+ if (y >= 30) throw Error("Invalid distance symbol");
1064
+ let C = l[y];
1065
+ const b = f[y];
1066
+ b && (C += r.readBits(b));
1067
+ const A = n.length - C;
1068
+ if (A < 0) throw Error("Invalid distance");
1069
+ for (let F = 0; F < p; F++) n.push(n[A + F] || 0);
1070
+ } else if (d === 286 || d === 287) throw Error("Reserved length symbol");
1071
+ }
1072
+ }
1073
+ }
1074
+ }
1075
+ }
1076
+ }(new Lt(h.subarray(i)), s), new Uint8Array(s);
1077
+ }
1078
+ function It(h) {
1079
+ const t = R, e = new Uint8Array(h);
1080
+ if (t.readASCII(e, 0, 4) !== "wOFF") throw Error("Invalid WOFF signature");
1081
+ const i = t.readUint(e, 4), s = t.readUshort(e, 12), r = t.readUint(e, 16), n = [];
1082
+ let o = 44;
1083
+ for (let p = 0; p < s; p++) {
1084
+ const E = t.readASCII(e, o, 4), y = t.readUint(e, o + 4), C = t.readUint(e, o + 8), b = t.readUint(e, o + 12), A = t.readUint(e, o + 16);
1085
+ n.push({ tag: E, offset: y, compLength: C, origLength: b, checksum: A }), o += 20;
1086
+ }
1087
+ for (const p of n) {
1088
+ const E = new Uint8Array(e.buffer, p.offset, p.compLength);
1089
+ if (p.compLength === p.origLength) p.data = new Uint8Array(E);
1090
+ else if (p.data = St(E), p.data.length !== p.origLength) if (p.data.length < p.origLength) {
1091
+ const y = new Uint8Array(p.origLength);
1092
+ y.set(p.data), p.data = y;
1093
+ } else p.data = p.data.subarray(0, p.origLength);
1094
+ }
1095
+ const c = s;
1096
+ let l = 1, f = 0;
1097
+ for (; l << 1 <= c; ) l <<= 1, f++;
1098
+ const u = 16 * l, g = 16 * c - u;
1099
+ let v = 12 + 16 * c;
1100
+ const m = {};
1101
+ for (const p of n) m[p.tag] = v, v = N(v + p.data.length);
1102
+ const d = new Uint8Array(Math.max(r || 0, v));
1103
+ t.writeUint(d, 0, i), t.writeUshort(d, 4, c), t.writeUshort(d, 6, u), t.writeUshort(d, 8, f), t.writeUshort(d, 10, g);
1104
+ let x = 12;
1105
+ for (const p of n) {
1106
+ t.writeASCII(d, x, p.tag), x += 4;
1107
+ let E = p.data;
1108
+ if (p.tag === "head" && E.length >= 12) {
1109
+ const y = new Uint8Array(E);
1110
+ t.writeUint(y, 8, 0);
1111
+ const C = Y(y, 0, N(y.length));
1112
+ t.writeUint(d, x, C), x += 4;
1113
+ } else {
1114
+ const y = Y(E, 0, N(E.length));
1115
+ t.writeUint(d, x, y), x += 4;
1116
+ }
1117
+ t.writeUint(d, x, m[p.tag]), x += 4, t.writeUint(d, x, p.data.length), x += 4;
1118
+ }
1119
+ for (const p of n) {
1120
+ const E = m[p.tag];
1121
+ d.set(p.data, E);
1122
+ }
1123
+ if (n.find((p) => p.tag === "head")) {
1124
+ const p = m.head, E = function(y, C) {
1125
+ const b = R, A = C + 8, F = [y[A], y[A + 1], y[A + 2], y[A + 3]];
1126
+ b.writeUint(y, A, 0);
1127
+ const _ = 2981146554 - (Y(y, 0, N(y.length)) >>> 0) >>> 0;
1128
+ return y[A] = F[0], y[A + 1] = F[1], y[A + 2] = F[2], y[A + 3] = F[3], _ >>> 0;
1129
+ }(d, p);
1130
+ t.writeUint(d, p + 8, E);
1131
+ }
1132
+ return d.buffer;
1133
+ }
1134
+ const Bt = { parseTab(h, t, e) {
947
1135
  const i = { tables: [], ids: {}, off: t };
948
- a = new Uint8Array(a.buffer, t, e), t = 0;
949
- const r = v, s = r.readUshort, n = s(a, t += 2);
1136
+ h = new Uint8Array(h.buffer, t, e), t = 0;
1137
+ const s = R, r = s.readUshort, n = r(h, t += 2);
950
1138
  t += 2;
951
1139
  const o = [];
952
- for (let h = 0; h < n; h++) {
953
- const l = s(a, t), u = s(a, t += 2);
1140
+ for (let c = 0; c < n; c++) {
1141
+ const l = r(h, t), f = r(h, t += 2);
954
1142
  t += 2;
955
- const f = r.readUint(a, t);
1143
+ const u = s.readUint(h, t);
956
1144
  t += 4;
957
- const d = `p${l}e${u}`;
958
- let p = o.indexOf(f);
959
- if (p === -1) {
960
- let g;
961
- p = i.tables.length, o.push(f);
962
- const m = s(a, f);
963
- g = m === 4 ? this.parse4(a, f) : m === 12 ? this.parse12(a, f) : { format: m }, i.tables.push(g);
1145
+ const g = `p${l}e${f}`;
1146
+ let v = o.indexOf(u);
1147
+ if (v === -1) {
1148
+ let m;
1149
+ v = i.tables.length, o.push(u);
1150
+ const d = r(h, u);
1151
+ m = d === 4 ? this.parse4(h, u) : d === 12 ? this.parse12(h, u) : { format: d }, i.tables.push(m);
964
1152
  }
965
- i.ids[d] = p;
1153
+ i.ids[g] = v;
966
1154
  }
967
1155
  return i;
968
- }, parse4(a, t) {
969
- const e = v, i = e.readUshort, r = e.readUshorts, s = t, n = i(a, t += 2);
1156
+ }, parse4(h, t) {
1157
+ const e = R, i = e.readUshort, s = e.readUshorts, r = t, n = i(h, t += 2);
970
1158
  t += 2;
971
- const o = i(a, t += 2) >>> 1, h = { format: 4, searchRange: i(a, t += 2), entrySelector: 0, rangeShift: 0, endCount: [], startCount: [], idDelta: [], idRangeOffset: [], glyphIdArray: [] };
972
- t += 2, h.entrySelector = i(a, t), t += 2, h.rangeShift = i(a, t), t += 2, h.endCount = r(a, t, o), t += 2 * o, t += 2, h.startCount = r(a, t, o), t += 2 * o;
973
- for (let l = 0; l < o; l++) h.idDelta.push(e.readShort(a, t)), t += 2;
974
- return h.idRangeOffset = r(a, t, o), t += 2 * o, h.glyphIdArray = r(a, t, s + n - t >> 1), h;
975
- }, parse12(a, t) {
976
- const e = v.readUint;
977
- e(a, t += 4), e(a, t += 4);
978
- const i = e(a, t += 4);
1159
+ const o = i(h, t += 2) >>> 1, c = { format: 4, searchRange: i(h, t += 2), entrySelector: 0, rangeShift: 0, endCount: [], startCount: [], idDelta: [], idRangeOffset: [], glyphIdArray: [] };
1160
+ t += 2, c.entrySelector = i(h, t), t += 2, c.rangeShift = i(h, t), t += 2, c.endCount = s(h, t, o), t += 2 * o, t += 2, c.startCount = s(h, t, o), t += 2 * o;
1161
+ for (let l = 0; l < o; l++) c.idDelta.push(e.readShort(h, t)), t += 2;
1162
+ return c.idRangeOffset = s(h, t, o), t += 2 * o, c.glyphIdArray = s(h, t, r + n - t >> 1), c;
1163
+ }, parse12(h, t) {
1164
+ const e = R.readUint;
1165
+ e(h, t += 4), e(h, t += 4);
1166
+ const i = e(h, t += 4);
979
1167
  t += 4;
980
- const r = new Uint32Array(3 * i);
981
- for (let s = 0; s < 3 * i; s += 3) r[s] = e(a, t + (s << 2)), r[s + 1] = e(a, t + (s << 2) + 4), r[s + 2] = e(a, t + (s << 2) + 8);
982
- return { format: 12, groups: r };
983
- } }, Et = { parseTab(a, t, e) {
984
- const i = v;
1168
+ const s = new Uint32Array(3 * i);
1169
+ for (let r = 0; r < 3 * i; r += 3) s[r] = e(h, t + (r << 2)), s[r + 1] = e(h, t + (r << 2) + 4), s[r + 2] = e(h, t + (r << 2) + 8);
1170
+ return { format: 12, groups: s };
1171
+ } }, Mt = { parseTab(h, t, e) {
1172
+ const i = R;
985
1173
  t += 18;
986
- const r = i.readUshort(a, t);
1174
+ const s = i.readUshort(h, t);
987
1175
  t += 2, t += 16;
988
- const s = i.readShort(a, t);
1176
+ const r = i.readShort(h, t);
989
1177
  t += 2;
990
- const n = i.readShort(a, t);
1178
+ const n = i.readShort(h, t);
991
1179
  t += 2;
992
- const o = i.readShort(a, t);
1180
+ const o = i.readShort(h, t);
993
1181
  t += 2;
994
- const h = i.readShort(a, t);
995
- return t += 2, t += 6, { unitsPerEm: r, xMin: s, yMin: n, xMax: o, yMax: h, indexToLocFormat: i.readShort(a, t) };
996
- } }, Rt = { parseTab(a, t, e) {
997
- const i = v;
1182
+ const c = i.readShort(h, t);
1183
+ return t += 2, t += 6, { unitsPerEm: s, xMin: r, yMin: n, xMax: o, yMax: c, indexToLocFormat: i.readShort(h, t) };
1184
+ } }, Dt = { parseTab(h, t, e) {
1185
+ const i = R;
998
1186
  t += 4;
999
- const r = ["ascender", "descender", "lineGap", "advanceWidthMax", "minLeftSideBearing", "minRightSideBearing", "xMaxExtent", "caretSlopeRise", "caretSlopeRun", "caretOffset", "res0", "res1", "res2", "res3", "metricDataFormat", "numberOfHMetrics"], s = {};
1000
- for (let n = 0; n < r.length; n++) {
1001
- const o = r[n], h = o === "advanceWidthMax" || o === "numberOfHMetrics" ? i.readUshort : i.readShort;
1002
- s[o] = h(a, t + 2 * n);
1187
+ const s = ["ascender", "descender", "lineGap", "advanceWidthMax", "minLeftSideBearing", "minRightSideBearing", "xMaxExtent", "caretSlopeRise", "caretSlopeRun", "caretOffset", "res0", "res1", "res2", "res3", "metricDataFormat", "numberOfHMetrics"], r = {};
1188
+ for (let n = 0; n < s.length; n++) {
1189
+ const o = s[n], c = o === "advanceWidthMax" || o === "numberOfHMetrics" ? i.readUshort : i.readShort;
1190
+ r[o] = c(h, t + 2 * n);
1003
1191
  }
1004
- return s;
1005
- } }, wt = { parseTab(a, t, e, i) {
1006
- const r = v, s = [], n = [], o = i.maxp.numGlyphs, h = i.hhea.numberOfHMetrics;
1007
- let l = 0, u = 0, f = 0;
1008
- for (; f < h; ) l = r.readUshort(a, t + (f << 2)), u = r.readShort(a, t + (f << 2) + 2), s.push(l), n.push(u), f++;
1009
- for (; f < o; ) s.push(l), n.push(u), f++;
1010
- return { aWidth: s, lsBearing: n };
1011
- } }, V = { cmap: xt, head: Et, hhea: Rt, maxp: { parseTab(a, t, e) {
1012
- const i = v;
1013
- return i.readUint(a, t), t += 4, { numGlyphs: i.readUshort(a, t) };
1014
- } }, hmtx: wt, loca: { parseTab(a, t, e, i) {
1015
- const r = v, s = [], n = i.head.indexToLocFormat, o = i.maxp.numGlyphs + 1;
1016
- if (n === 0) for (let h = 0; h < o; h++) s.push(r.readUshort(a, t + (h << 1)) << 1);
1017
- else if (n === 1) for (let h = 0; h < o; h++) s.push(r.readUint(a, t + (h << 2)));
1018
- return s;
1019
- } }, glyf: { parseTab(a, t, e, i) {
1020
- const r = [], s = i.maxp.numGlyphs;
1021
- for (let n = 0; n < s; n++) r.push(null);
1022
1192
  return r;
1023
- }, Ks(a, t) {
1024
- const e = v, i = a.Ns, r = a.loca;
1025
- if (r[t] === r[t + 1]) return null;
1026
- const s = A.findTable(i, "glyf", a.Xs);
1027
- if (!s) return null;
1028
- let n = s[0] + r[t];
1193
+ } }, Gt = { parseTab(h, t, e, i) {
1194
+ const s = R, r = [], n = [], o = i.maxp.numGlyphs, c = i.hhea.numberOfHMetrics;
1195
+ let l = 0, f = 0, u = 0;
1196
+ for (; u < c; ) l = s.readUshort(h, t + (u << 2)), f = s.readShort(h, t + (u << 2) + 2), r.push(l), n.push(f), u++;
1197
+ for (; u < o; ) r.push(l), n.push(f), u++;
1198
+ return { aWidth: r, lsBearing: n };
1199
+ } }, it = { cmap: Bt, head: Mt, hhea: Dt, maxp: { parseTab(h, t, e) {
1200
+ const i = R;
1201
+ return i.readUint(h, t), t += 4, { numGlyphs: i.readUshort(h, t) };
1202
+ } }, hmtx: Gt, loca: { parseTab(h, t, e, i) {
1203
+ const s = R, r = [], n = i.head.indexToLocFormat, o = i.maxp.numGlyphs + 1;
1204
+ if (n === 0) for (let c = 0; c < o; c++) r.push(s.readUshort(h, t + (c << 1)) << 1);
1205
+ else if (n === 1) for (let c = 0; c < o; c++) r.push(s.readUint(h, t + (c << 2)));
1206
+ return r;
1207
+ } }, glyf: { parseTab(h, t, e, i) {
1208
+ const s = [], r = i.maxp.numGlyphs;
1209
+ for (let n = 0; n < r; n++) s.push(null);
1210
+ return s;
1211
+ }, Js(h, t) {
1212
+ const e = R, i = h.Qs, s = h.loca;
1213
+ if (s[t] === s[t + 1]) return null;
1214
+ const r = L.findTable(i, "glyf", h.ti);
1215
+ if (!r) return null;
1216
+ let n = r[0] + s[t];
1029
1217
  const o = {};
1030
1218
  if (o.noc = e.readShort(i, n), n += 2, o.xMin = e.readShort(i, n), n += 2, o.yMin = e.readShort(i, n), n += 2, o.xMax = e.readShort(i, n), n += 2, o.yMax = e.readShort(i, n), n += 2, o.xMin >= o.xMax || o.yMin >= o.yMax) return null;
1031
1219
  if (o.noc > 0) {
1032
1220
  o.endPts = [];
1033
- for (let d = 0; d < o.noc; d++) o.endPts.push(e.readUshort(i, n)), n += 2;
1034
- const h = e.readUshort(i, n);
1035
- if (n += 2, i.length - n < h) return null;
1036
- n += h;
1221
+ for (let g = 0; g < o.noc; g++) o.endPts.push(e.readUshort(i, n)), n += 2;
1222
+ const c = e.readUshort(i, n);
1223
+ if (n += 2, i.length - n < c) return null;
1224
+ n += c;
1037
1225
  const l = o.endPts[o.noc - 1] + 1;
1038
1226
  o.flags = [];
1039
- for (let d = 0; d < l; d++) {
1040
- const p = i[n];
1041
- if (n++, o.flags.push(p), 8 & p) {
1042
- const g = i[n];
1227
+ for (let g = 0; g < l; g++) {
1228
+ const v = i[n];
1229
+ if (n++, o.flags.push(v), 8 & v) {
1230
+ const m = i[n];
1043
1231
  n++;
1044
- for (let m = 0; m < g; m++) o.flags.push(p), d++;
1232
+ for (let d = 0; d < m; d++) o.flags.push(v), g++;
1045
1233
  }
1046
1234
  }
1047
1235
  o.xs = [];
1048
- for (let d = 0; d < l; d++) {
1049
- const p = o.flags[d], g = !!(16 & p);
1050
- 2 & p ? (o.xs.push(g ? i[n] : -i[n]), n++) : g ? o.xs.push(0) : (o.xs.push(e.readShort(i, n)), n += 2);
1236
+ for (let g = 0; g < l; g++) {
1237
+ const v = o.flags[g], m = !!(16 & v);
1238
+ 2 & v ? (o.xs.push(m ? i[n] : -i[n]), n++) : m ? o.xs.push(0) : (o.xs.push(e.readShort(i, n)), n += 2);
1051
1239
  }
1052
1240
  o.ys = [];
1053
- for (let d = 0; d < l; d++) {
1054
- const p = o.flags[d], g = !!(32 & p);
1055
- 4 & p ? (o.ys.push(g ? i[n] : -i[n]), n++) : g ? o.ys.push(0) : (o.ys.push(e.readShort(i, n)), n += 2);
1241
+ for (let g = 0; g < l; g++) {
1242
+ const v = o.flags[g], m = !!(32 & v);
1243
+ 4 & v ? (o.ys.push(m ? i[n] : -i[n]), n++) : m ? o.ys.push(0) : (o.ys.push(e.readShort(i, n)), n += 2);
1056
1244
  }
1057
- let u = 0, f = 0;
1058
- for (let d = 0; d < l; d++) u += o.xs[d], f += o.ys[d], o.xs[d] = u, o.ys[d] = f;
1245
+ let f = 0, u = 0;
1246
+ for (let g = 0; g < l; g++) f += o.xs[g], u += o.ys[g], o.xs[g] = f, o.ys[g] = u;
1059
1247
  } else o.parts = [], o.endPts = [], o.flags = [], o.xs = [], o.ys = [];
1060
1248
  return o;
1061
- } } }, A = { parse: (a) => [((t, e, i, r) => {
1062
- const s = V, n = { Ns: t, js: e, Xs: i };
1063
- for (const o in s) {
1064
- const h = o, l = A.findTable(t, h, i);
1065
- if (l) {
1066
- const [u, f] = l;
1067
- let d = r[u];
1068
- d == null && (d = s[h].parseTab(t, u, f, n), r[u] = d), n[h] = d;
1069
- }
1070
- }
1071
- return n;
1072
- })(new Uint8Array(a), 0, 0, {})], findTable(a, t, e) {
1073
- const i = v, r = i.readUshort(a, e + 4);
1074
- let s = e + 12;
1075
- for (let n = 0; n < r; n++) {
1076
- const o = i.readASCII(a, s, 4);
1077
- i.readUint(a, s + 4);
1078
- const h = i.readUint(a, s + 8), l = i.readUint(a, s + 12);
1079
- if (o === t) return [h, l];
1080
- s += 16;
1081
- }
1082
- return null;
1083
- }, T: V, B: v };
1084
- class z {
1085
- constructor() {
1086
- c(this, "Ys", /* @__PURE__ */ new Map());
1087
- c(this, "qs", /* @__PURE__ */ new Map());
1088
- }
1089
- Zs(t, e) {
1090
- const i = `${this.Js(t)}_${e}`;
1091
- if (this.Ys.has(i)) return this.Ys.get(i);
1092
- const r = t.cmap;
1093
- if (!r || !r.tables) return this.Ys.set(i, 0), 0;
1094
- let s = 0;
1095
- for (const n of r.tables) if (n.format === 4 ? s = this.Qs(e, n) : n.format === 12 && (s = this.ti(e, n)), s > 0) break;
1096
- return this.Ys.set(i, s), s;
1097
- }
1098
- ei(t, e) {
1099
- const i = e.codePointAt(0);
1100
- return i === void 0 ? 0 : this.Zs(t, i);
1101
- }
1102
- si(t, e) {
1103
- const i = t.hmtx;
1104
- return i && i.aWidth && i.aWidth.length !== 0 ? e < i.aWidth.length ? i.aWidth[e] : i.aWidth[i.aWidth.length - 1] : 0;
1105
- }
1106
- ii(t, e) {
1107
- const i = e / t.head.unitsPerEm, r = t.hhea.ascender * i, s = t.hhea.descender * i, n = t.hhea.lineGap * i;
1108
- return { ascender: r, descender: s, lineGap: n, lineHeight: r - s + n, unitsPerEm: t.head.unitsPerEm, scale: i };
1109
- }
1110
- ri() {
1111
- this.Ys.clear(), this.qs.clear();
1112
- }
1113
- Js(t) {
1114
- return `${t.Xs}_${t.Ns.length}`;
1115
- }
1116
- Qs(t, e) {
1117
- const i = e.endCount.length;
1118
- let r = -1;
1119
- for (let s = 0; s < i; s++) if (t <= e.endCount[s]) {
1120
- r = s;
1121
- break;
1122
- }
1123
- if (r === -1 || t < e.startCount[r]) return 0;
1124
- if (e.idRangeOffset[r] === 0) return t + e.idDelta[r] & 65535;
1125
- {
1126
- const s = e.idRangeOffset[r] / 2 + (t - e.startCount[r]) - (i - r);
1127
- if (s >= 0 && s < e.glyphIdArray.length) {
1128
- const n = e.glyphIdArray[s];
1129
- return n === 0 ? 0 : n + e.idDelta[r] & 65535;
1249
+ } } }, L = { parse(h) {
1250
+ const t = new Uint8Array(h), e = R.readASCII(t, 0, 4);
1251
+ if (e === "wOFF") h = It(h);
1252
+ else if (e === "wOF2") throw Error("WOFF2 is not supported in this build (Brotli + WOFF2 transforms required)");
1253
+ return [((i, s, r, n) => {
1254
+ const o = it, c = { Qs: i, ei: s, ti: r };
1255
+ for (const l in o) {
1256
+ const f = l, u = L.findTable(i, f, r);
1257
+ if (u) {
1258
+ const [g, v] = u;
1259
+ let m = n[g];
1260
+ m == null && (m = o[f].parseTab(i, g, v, c), n[g] = m), c[f] = m;
1130
1261
  }
1131
1262
  }
1132
- return 0;
1133
- }
1134
- ti(t, e) {
1135
- const i = e.groups.length / 3;
1136
- for (let r = 0; r < i; r++) {
1137
- const s = e.groups[3 * r], n = e.groups[3 * r + 1], o = e.groups[3 * r + 2];
1138
- if (t >= s && t <= n) return o + (t - s);
1139
- }
1140
- return 0;
1141
- }
1142
- }
1143
- class Ct {
1144
- constructor(t) {
1145
- c(this, "ni");
1146
- this.ni = t;
1263
+ return c;
1264
+ })(new Uint8Array(h), 0, 0, {})];
1265
+ }, findTable(h, t, e) {
1266
+ const i = R, s = i.readUshort(h, e + 4);
1267
+ let r = e + 12;
1268
+ for (let n = 0; n < s; n++) {
1269
+ const o = i.readASCII(h, r, 4);
1270
+ i.readUint(h, r + 4);
1271
+ const c = i.readUint(h, r + 8), l = i.readUint(h, r + 12);
1272
+ if (o === t) return [c, l];
1273
+ r += 16;
1147
1274
  }
1148
- oi(t) {
1275
+ return null;
1276
+ }, T: it, B: R };
1277
+ class Ot {
1278
+ si(t) {
1149
1279
  var i;
1150
1280
  const e = [];
1151
- return (i = t.cmap) != null && i.tables ? (t.cmap.tables.forEach((r) => {
1152
- if (r.format === 4) {
1153
- const s = this.ai(r);
1154
- e.push(...s);
1155
- } else if (r.format === 12) {
1156
- const s = this.hi(r);
1157
- e.push(...s);
1281
+ return (i = t.cmap) != null && i.tables ? (t.cmap.tables.forEach((s) => {
1282
+ if (s.format === 4) {
1283
+ const r = this.ii(s);
1284
+ e.push(...r);
1285
+ } else if (s.format === 12) {
1286
+ const r = this.ri(s);
1287
+ e.push(...r);
1158
1288
  }
1159
1289
  }), [...new Set(e)]) : [];
1160
1290
  }
1161
- ci(t, e) {
1162
- return this.ni.ei(t, e) > 0;
1163
- }
1164
- li(t, e) {
1165
- for (const i of e) if (!this.ci(t, i)) return !1;
1166
- return !0;
1167
- }
1168
- ui(t, e) {
1169
- return e.filter((i) => this.ci(t, i));
1170
- }
1171
- fi(t) {
1172
- return t.filter((e) => this.di(e));
1291
+ ni(t) {
1292
+ return t.filter((e) => this.oi(e));
1173
1293
  }
1174
- ai(t) {
1294
+ ii(t) {
1175
1295
  const e = [];
1176
1296
  if (!(t.startCount && t.endCount && t.idRangeOffset && t.idDelta)) return e;
1177
1297
  for (let i = 0; i < t.startCount.length; i++) {
1178
- const r = t.startCount[i], s = t.endCount[i];
1179
- if (r !== 65535 || s !== 65535) {
1180
- for (let n = r; n <= s; n++)
1181
- if (this._i(t, n, i) > 0) try {
1298
+ const s = t.startCount[i], r = t.endCount[i];
1299
+ if (s !== 65535 || r !== 65535) {
1300
+ for (let n = s; n <= r; n++)
1301
+ if (this.ai(t, n, i) > 0) try {
1182
1302
  const o = String.fromCodePoint(n);
1183
1303
  e.push(o);
1184
1304
  } catch {
@@ -1187,996 +1307,1167 @@ class Ct {
1187
1307
  }
1188
1308
  return e;
1189
1309
  }
1190
- hi(t) {
1310
+ ri(t) {
1191
1311
  const e = [];
1192
1312
  if (!t.groups) return e;
1193
1313
  for (let i = 0; i < t.groups.length; i += 3) {
1194
- const r = t.groups[i], s = t.groups[i + 1], n = t.groups[i + 2];
1195
- for (let o = r; o <= s; o++)
1196
- if (n + (o - r) > 0) try {
1197
- const h = String.fromCodePoint(o);
1198
- e.push(h);
1314
+ const s = t.groups[i], r = t.groups[i + 1], n = t.groups[i + 2];
1315
+ for (let o = s; o <= r; o++)
1316
+ if (n + (o - s) > 0) try {
1317
+ const c = String.fromCodePoint(o);
1318
+ e.push(c);
1199
1319
  } catch {
1200
1320
  }
1201
1321
  }
1202
1322
  return e;
1203
1323
  }
1204
- _i(t, e, i) {
1324
+ ai(t, e, i) {
1205
1325
  if (t.idRangeOffset[i] === 0) return e + t.idDelta[i] & 65535;
1206
1326
  {
1207
- const r = t.idRangeOffset[i] / 2 + (e - t.startCount[i]) - (t.startCount.length - i);
1208
- if (r >= 0 && t.glyphIdArray && r < t.glyphIdArray.length) {
1209
- const s = t.glyphIdArray[r];
1210
- if (s !== 0) return s + t.idDelta[i] & 65535;
1327
+ const s = t.idRangeOffset[i] / 2 + (e - t.startCount[i]) - (t.startCount.length - i);
1328
+ if (s >= 0 && t.glyphIdArray && s < t.glyphIdArray.length) {
1329
+ const r = t.glyphIdArray[s];
1330
+ if (r !== 0) return r + t.idDelta[i] & 65535;
1211
1331
  }
1212
1332
  }
1213
1333
  return 0;
1214
1334
  }
1215
- di(t) {
1335
+ oi(t) {
1216
1336
  const e = t.codePointAt(0) || 0;
1217
1337
  return !(e >= 0 && e <= 31 && e !== 9 && e !== 10 && e !== 13 || e >= 127 && e <= 159);
1218
1338
  }
1219
1339
  }
1220
- class At {
1340
+ class q {
1221
1341
  constructor() {
1222
- c(this, "pi");
1223
- const t = new z();
1224
- this.pi = new Ct(t);
1342
+ a(this, "hi", /* @__PURE__ */ new Map());
1343
+ a(this, "ci", /* @__PURE__ */ new Map());
1344
+ }
1345
+ li(t, e) {
1346
+ const i = `${this.ui(t)}_${e}`;
1347
+ if (this.hi.has(i)) return this.hi.get(i);
1348
+ const s = t.cmap;
1349
+ if (!s || !s.tables) return this.hi.set(i, 0), 0;
1350
+ let r = 0;
1351
+ for (const n of s.tables) if (n.format === 4 ? r = this.fi(e, n) : n.format === 12 && (r = this.di(e, n)), r > 0) break;
1352
+ return this.hi.set(i, r), r;
1353
+ }
1354
+ _i(t, e) {
1355
+ const i = e.codePointAt(0);
1356
+ return i === void 0 ? 0 : this.li(t, i);
1225
1357
  }
1226
- extractCharacters(t) {
1227
- return this.pi.oi(t);
1358
+ pi(t, e) {
1359
+ const i = t.hmtx;
1360
+ return i && i.aWidth && i.aWidth.length !== 0 ? e < i.aWidth.length ? i.aWidth[e] : i.aWidth[i.aWidth.length - 1] : 0;
1228
1361
  }
1229
- filterProblematicCharacters(t) {
1230
- return this.pi.fi(t);
1362
+ mi(t, e) {
1363
+ const i = e / t.head.unitsPerEm, s = t.hhea.ascender * i, r = t.hhea.descender * i, n = t.hhea.lineGap * i;
1364
+ return { ascender: s, descender: r, lineGap: n, lineHeight: s - r + n, unitsPerEm: t.head.unitsPerEm, scale: i };
1231
1365
  }
1232
- characterExists(t, e) {
1233
- return this.pi.ci(t, e);
1366
+ gi() {
1367
+ this.hi.clear(), this.ci.clear();
1234
1368
  }
1235
- allCharactersExist(t, e) {
1236
- return this.pi.li(t, e);
1369
+ ui(t) {
1370
+ return `${t.ti}_${t.Qs.length}`;
1371
+ }
1372
+ fi(t, e) {
1373
+ const i = e.endCount.length;
1374
+ let s = -1;
1375
+ for (let r = 0; r < i; r++) if (t <= e.endCount[r]) {
1376
+ s = r;
1377
+ break;
1378
+ }
1379
+ if (s === -1 || t < e.startCount[s]) return 0;
1380
+ if (e.idRangeOffset[s] === 0) return t + e.idDelta[s] & 65535;
1381
+ {
1382
+ const r = e.idRangeOffset[s] / 2 + (t - e.startCount[s]) - (i - s);
1383
+ if (r >= 0 && r < e.glyphIdArray.length) {
1384
+ const n = e.glyphIdArray[r];
1385
+ return n === 0 ? 0 : n + e.idDelta[s] & 65535;
1386
+ }
1387
+ }
1388
+ return 0;
1389
+ }
1390
+ di(t, e) {
1391
+ const i = e.groups.length / 3;
1392
+ for (let s = 0; s < i; s++) {
1393
+ const r = e.groups[3 * s], n = e.groups[3 * s + 1], o = e.groups[3 * s + 2];
1394
+ if (t >= r && t <= n) return o + (t - r);
1395
+ }
1396
+ return 0;
1237
1397
  }
1238
1398
  }
1239
- class Tt {
1399
+ class $t {
1240
1400
  constructor(t) {
1241
- c(this, "gi");
1242
- c(this, "mi");
1243
- c(this, "kt");
1244
- c(this, "yi");
1245
- this.kt = t, this.yi = new z(), this.gi = document.createElement("canvas"), this.mi = this.gi.getContext("2d", { willReadFrequently: !0, alpha: !1 });
1246
- }
1247
- createTextureAtlas(t, e, i, r) {
1248
- const s = t.length, n = Math.ceil(Math.sqrt(s)), o = Math.ceil(s / n), h = e.width * n, l = e.height * o, u = typeof r == "object" ? r : null;
1249
- this.$i(h, l), this.Ci(t, e, n, i, u);
1250
- const f = this.kt.Us(h, l, 1, { filter: "nearest" });
1251
- return f.Lt(this.gi), { framebuffer: f, columns: n, rows: o };
1401
+ a(this, "yi");
1402
+ a(this, "Ci");
1403
+ a(this, "xt");
1404
+ a(this, "wi");
1405
+ this.xt = t, this.wi = new q(), this.yi = document.createElement("canvas"), this.Ci = this.yi.getContext("2d", { willReadFrequently: !0, alpha: !1 });
1406
+ }
1407
+ createTextureAtlas(t, e, i, s) {
1408
+ const r = t.length, n = Math.ceil(Math.sqrt(r)), o = Math.ceil(r / n), c = e.width * n, l = e.height * o, f = typeof s == "object" ? s : null;
1409
+ this.$i(c, l), this.bi(t, e, n, i, f);
1410
+ const u = this.xt.js(c, l, 1, { filter: "nearest" });
1411
+ return u.At(this.yi), { framebuffer: u, columns: n, rows: o };
1252
1412
  }
1253
1413
  $i(t, e) {
1254
- this.gi.width = t, this.gi.height = e, this.gi.style.width = t + "px", this.gi.style.height = t + "px", this.mi.imageSmoothingEnabled = !1, this.gi.style.imageRendering = "pixelated", this.mi.fillStyle = "black", this.mi.fillRect(0, 0, t, e), this.mi.textBaseline = "top", this.mi.textAlign = "left", this.mi.fillStyle = "white";
1414
+ this.yi.width = t, this.yi.height = e, this.yi.style.width = t + "px", this.yi.style.height = t + "px", this.Ci.imageSmoothingEnabled = !1, this.yi.style.imageRendering = "pixelated", this.Ci.fillStyle = "black", this.Ci.fillRect(0, 0, t, e), this.Ci.textBaseline = "top", this.Ci.textAlign = "left", this.Ci.fillStyle = "white";
1255
1415
  }
1256
- Ci(t, e, i, r, s) {
1257
- const n = r / s.head.unitsPerEm;
1416
+ bi(t, e, i, s, r) {
1417
+ const n = s / r.head.unitsPerEm;
1258
1418
  for (let o = 0; o < t.length; o++) {
1259
- const h = o % i, l = Math.floor(o / i), u = t[o].character, f = this.wi(s, u);
1260
- if (!f) continue;
1261
- const d = u.codePointAt(0) || 0, p = this.yi.Zs(s, d), g = this.xi(s, p) * n, m = h * e.width, R = l * e.height, x = m + 0.5 * e.width, w = R + 0.5 * e.height, C = Math.round(x - 0.5 * e.width), L = Math.round(w - 0.5 * r), q = C + 0.5 * (e.width - g), J = L + s.hhea.ascender * n;
1262
- this.bi(f, q, J, n);
1419
+ const c = o % i, l = Math.floor(o / i), f = t[o].character, u = this.xi(r, f);
1420
+ if (!u) continue;
1421
+ const g = f.codePointAt(0) || 0, v = this.wi.li(r, g), m = this.Fi(r, v) * n, d = c * e.width, x = l * e.height, p = d + 0.5 * e.width, E = x + 0.5 * e.height, y = Math.round(p - 0.5 * e.width), C = Math.round(E - 0.5 * s), b = y + 0.5 * (e.width - m), A = C + r.hhea.ascender * n;
1422
+ this.Mi(u, b, A, n);
1263
1423
  }
1264
1424
  }
1265
- wi(t, e) {
1266
- const i = e.codePointAt(0) || 0, r = this.yi.Zs(t, i);
1267
- if (r === 0) return null;
1268
- if (t.glyf && t.glyf[r] !== null) return t.glyf[r];
1269
- if (A && A.T && A.T.glyf) {
1270
- const s = A.T.glyf.Ks(t, r);
1271
- return t.glyf && s && (t.glyf[r] = s), s;
1425
+ xi(t, e) {
1426
+ const i = e.codePointAt(0) || 0, s = this.wi.li(t, i);
1427
+ if (s === 0) return null;
1428
+ if (t.glyf && t.glyf[s] !== null) return t.glyf[s];
1429
+ if (L && L.T && L.T.glyf) {
1430
+ const r = L.T.glyf.Js(t, s);
1431
+ return t.glyf && r && (t.glyf[s] = r), r;
1272
1432
  }
1273
1433
  return null;
1274
1434
  }
1275
- xi(t, e) {
1435
+ Fi(t, e) {
1276
1436
  const i = t.hmtx;
1277
1437
  return i && i.aWidth ? e < i.aWidth.length ? i.aWidth[e] : i.aWidth[i.aWidth.length - 1] : 0;
1278
1438
  }
1279
- bi(t, e, i, r) {
1439
+ Mi(t, e, i, s) {
1280
1440
  if (!t || !t.xs || t.noc === 0) return;
1281
- const { xs: s, ys: n, endPts: o, flags: h } = t;
1282
- if (!(s && n && o && h)) return;
1283
- this.mi.beginPath();
1441
+ const { xs: r, ys: n, endPts: o, flags: c } = t;
1442
+ if (!(r && n && o && c)) return;
1443
+ this.Ci.beginPath();
1284
1444
  let l = 0;
1285
- for (let u = 0; u < o.length; u++) {
1286
- const f = o[u];
1287
- if (!(f < l)) {
1288
- if (f >= l) {
1289
- const d = e + s[l] * r, p = i - n[l] * r;
1290
- this.mi.moveTo(d, p);
1291
- let g = l + 1;
1292
- for (; g <= f; )
1293
- if (1 & h[g]) {
1294
- const m = e + s[g] * r, R = i - n[g] * r;
1295
- this.mi.lineTo(m, R), g++;
1445
+ for (let f = 0; f < o.length; f++) {
1446
+ const u = o[f];
1447
+ if (!(u < l)) {
1448
+ if (u >= l) {
1449
+ const g = e + r[l] * s, v = i - n[l] * s;
1450
+ this.Ci.moveTo(g, v);
1451
+ let m = l + 1;
1452
+ for (; m <= u; )
1453
+ if (1 & c[m]) {
1454
+ const d = e + r[m] * s, x = i - n[m] * s;
1455
+ this.Ci.lineTo(d, x), m++;
1296
1456
  } else {
1297
- const m = e + s[g] * r, R = i - n[g] * r;
1298
- let x = g + 1 > f ? l : g + 1;
1299
- if (1 & h[x]) {
1300
- const w = e + s[x] * r, C = i - n[x] * r;
1301
- this.mi.quadraticCurveTo(m, R, w, C), g = x + 1;
1457
+ const d = e + r[m] * s, x = i - n[m] * s;
1458
+ let p = m + 1 > u ? l : m + 1;
1459
+ if (1 & c[p]) {
1460
+ const E = e + r[p] * s, y = i - n[p] * s;
1461
+ this.Ci.quadraticCurveTo(d, x, E, y), m = p + 1;
1302
1462
  } else {
1303
- const w = (m + (e + s[x] * r)) / 2, C = (R + (i - n[x] * r)) / 2;
1304
- this.mi.quadraticCurveTo(m, R, w, C), g = x;
1463
+ const E = (d + (e + r[p] * s)) / 2, y = (x + (i - n[p] * s)) / 2;
1464
+ this.Ci.quadraticCurveTo(d, x, E, y), m = p;
1305
1465
  }
1306
1466
  }
1307
- this.mi.closePath();
1467
+ this.Ci.closePath();
1308
1468
  }
1309
- l = f + 1;
1469
+ l = u + 1;
1310
1470
  }
1311
1471
  }
1312
- this.mi.fill();
1472
+ this.Ci.fill();
1313
1473
  }
1314
1474
  }
1315
- class Ft {
1475
+ class zt {
1316
1476
  constructor() {
1317
- c(this, "ni");
1318
- this.ni = new z();
1477
+ a(this, "Ri");
1478
+ this.Ri = new q();
1319
1479
  }
1320
- calculateMaxGlyphDimensions(t, e, i) {
1321
- let r = 0;
1322
- const s = this.ni.ii(i, e), n = s.lineHeight;
1480
+ Si(t, e, i) {
1481
+ let s = 0;
1482
+ const r = this.Ri.mi(i, e), n = r.lineHeight;
1323
1483
  for (const o of t) {
1324
- const h = this.ni.ei(i, o);
1325
- if (h === 0) continue;
1326
- const l = this.ni.si(i, h) * s.scale;
1327
- r = Math.max(r, l);
1484
+ const c = this.Ri._i(i, o);
1485
+ if (c === 0) continue;
1486
+ const l = this.Ri.pi(i, c) * r.scale;
1487
+ s = Math.max(s, l);
1328
1488
  }
1329
- return { width: Math.ceil(r), height: Math.ceil(n) };
1330
- }
1331
- getCharacterAdvanceWidth(t, e, i) {
1332
- const r = this.ni.ii(i, e), s = this.ni.ei(i, t);
1333
- return this.ni.si(i, s) * r.scale;
1334
- }
1335
- getFontMetrics(t, e) {
1336
- return this.ni.ii(e, t);
1489
+ return { width: Math.ceil(s), height: Math.ceil(n) };
1337
1490
  }
1338
- ri() {
1339
- this.ni.ri();
1491
+ gi() {
1492
+ this.Ri.gi();
1340
1493
  }
1341
1494
  }
1342
- class _t {
1495
+ class kt {
1343
1496
  constructor() {
1344
- c(this, "yi");
1345
- this.yi = new z();
1497
+ a(this, "wi");
1498
+ this.wi = new q();
1346
1499
  }
1347
1500
  createCharacterObjects(t, e) {
1348
- return t.map((i, r) => {
1349
- const s = i.codePointAt(0) || 0, n = this.Ri(r);
1501
+ return t.map((i, s) => {
1502
+ const r = i.codePointAt(0) || 0, n = this.Ai(s);
1350
1503
  let o = 0;
1351
1504
  if (e.hmtx && e.hmtx.aWidth) {
1352
- const h = this.yi.Zs(e, s);
1353
- h > 0 && e.hmtx.aWidth[h] !== void 0 && (o = e.hmtx.aWidth[h]);
1505
+ const c = this.wi.li(e, r);
1506
+ c > 0 && e.hmtx.aWidth[c] !== void 0 && (o = e.hmtx.aWidth[c]);
1354
1507
  }
1355
- return { character: i, unicode: s, color: n, advanceWidth: o };
1508
+ return { character: i, unicode: r, color: n, advanceWidth: o };
1356
1509
  });
1357
1510
  }
1358
- Ri(t) {
1511
+ Ai(t) {
1359
1512
  return [t % 256 / 255, Math.floor(t / 256) % 256 / 255, Math.floor(t / 65536) % 256 / 255];
1360
1513
  }
1361
- Mi(t, e) {
1362
- if (!M.M(typeof t == "string", "Character must be a string.", { method: "getCharacterColor", providedValue: t })) return [0, 0, 0];
1363
- const i = e.find((r) => r.character === t);
1514
+ zi(t, e) {
1515
+ if (!$.v(typeof t == "string", "Character must be a string.", { method: "getCharacterColor", providedValue: t })) return [0, 0, 0];
1516
+ const i = e.find((s) => s.character === t);
1364
1517
  return i ? i.color : [0, 0, 0];
1365
1518
  }
1366
- Si(t, e) {
1367
- return M.M(typeof t == "string" && t.length > 0, "Characters must be a string with at least one character.", { method: "getCharacterColors", providedValue: t }) ? Array.from(t).map((i) => this.Mi(i, e) || [0, 0, 0]) : [[0, 0, 0]];
1519
+ Ti(t, e) {
1520
+ return $.v(typeof t == "string" && t.length > 0, "Characters must be a string with at least one character.", { method: "getCharacterColors", providedValue: t }) ? Array.from(t).map((i) => this.zi(i, e) || [0, 0, 0]) : [[0, 0, 0]];
1368
1521
  }
1369
1522
  }
1370
- class St {
1523
+ class Nt {
1371
1524
  constructor(t, e = 16) {
1372
- c(this, "Fi");
1373
- c(this, "zi", []);
1374
- c(this, "ki");
1375
- c(this, "Pi", 16);
1376
- c(this, "Ti", 0);
1377
- c(this, "Ai", 0);
1378
- c(this, "Gi", { width: 0, height: 0 });
1379
- c(this, "Li");
1380
- c(this, "Ei");
1381
- c(this, "Bi");
1382
- c(this, "Di");
1383
- c(this, "Wi");
1384
- this.Pi = e, this.Ei = new At(), this.Bi = new Tt(t), this.Di = new Ft(), this.Wi = new _t();
1385
- }
1386
- async Ii(t) {
1525
+ a(this, "Ei");
1526
+ a(this, "Li", []);
1527
+ a(this, "ki");
1528
+ a(this, "Pi", 16);
1529
+ a(this, "Gi", 0);
1530
+ a(this, "Bi", 0);
1531
+ a(this, "Di", { width: 0, height: 0 });
1532
+ a(this, "Ii");
1533
+ a(this, "Wi");
1534
+ a(this, "Oi");
1535
+ a(this, "Hi");
1536
+ a(this, "Vi");
1537
+ this.Pi = e, this.Wi = new Ot(), this.Oi = new $t(t), this.Hi = new zt(), this.Vi = new kt();
1538
+ }
1539
+ async Ki(t) {
1387
1540
  let e;
1388
- if (!t) throw new E("Embedded font not available. This appears to be a minified build - please provide `fontSource`.");
1541
+ if (!t) throw new U("Embedded font not available. This appears to be a minified build - please provide `fontSource`.");
1389
1542
  {
1390
1543
  const i = await fetch(t);
1391
- if (!i.ok) throw new E(`Failed to load font file: ${i.status} ${i.statusText}`);
1544
+ if (!i.ok) throw new U(`Failed to load font file: ${i.status} ${i.statusText}`);
1392
1545
  e = await i.arrayBuffer();
1393
1546
  }
1394
- await this.Ui(e), this.Fi = A.parse(e)[0], await this.Vi();
1547
+ await this.Ni(e), this.Ei = L.parse(e)[0], await this.Xi();
1395
1548
  }
1396
- Oi(t) {
1549
+ ji(t) {
1397
1550
  if (t === void 0) return this.Pi;
1398
- this.Pi = t, this.Gi = this.Di.calculateMaxGlyphDimensions(this.zi.map((i) => i.character), this.Pi, this.Fi);
1399
- const e = this.Bi.createTextureAtlas(this.zi, this.Gi, this.Pi, this.Fi);
1400
- this.ki = e.framebuffer, this.Ti = e.columns, this.Ai = e.rows;
1551
+ this.Pi = t, this.Di = this.Hi.Si(this.Li.map((i) => i.character), this.Pi, this.Ei);
1552
+ const e = this.Oi.createTextureAtlas(this.Li, this.Di, this.Pi, this.Ei);
1553
+ this.ki = e.framebuffer, this.Gi = e.columns, this.Bi = e.rows;
1401
1554
  }
1402
- async Hi(t) {
1555
+ async Yi(t) {
1403
1556
  try {
1404
1557
  const e = await fetch(t);
1405
- if (!e.ok) throw new E(`Failed to load font file: ${e.status} ${e.statusText}`);
1558
+ if (!e.ok) throw new U(`Failed to load font file: ${e.status} ${e.statusText}`);
1406
1559
  const i = await e.arrayBuffer();
1407
- await this.Ui(i);
1408
- const r = A.parse(i);
1409
- if (!r || r.length === 0) throw Error("Failed to parse font file");
1410
- this.Fi = r[0], await this.Vi();
1560
+ await this.Ni(i);
1561
+ const s = L.parse(i);
1562
+ if (!s || s.length === 0) throw Error("Failed to parse font file");
1563
+ this.Ei = s[0], await this.Xi();
1411
1564
  } catch (e) {
1412
- throw new E("Failed to load font: " + (e instanceof Error ? e.message : "Unknown error"), e);
1565
+ throw new U("Failed to load font: " + (e instanceof Error ? e.message : "Unknown error"), e);
1413
1566
  }
1414
1567
  }
1415
- async Ui(t) {
1568
+ async Ni(t) {
1416
1569
  const e = Date.now();
1417
- this.Li = new FontFace("CustomFont_" + e, t), await this.Li.load(), document.fonts.add(this.Li);
1570
+ this.Ii = new FontFace("CustomFont_" + e, t), await this.Ii.load(), document.fonts.add(this.Ii);
1418
1571
  }
1419
- async Vi() {
1420
- const t = this.Ei.extractCharacters(this.Fi), e = this.Ei.filterProblematicCharacters(t);
1421
- this.zi = this.Wi.createCharacterObjects(e, this.Fi), this.Gi = this.Di.calculateMaxGlyphDimensions(e, this.Pi, this.Fi);
1422
- const i = this.Bi.createTextureAtlas(this.zi, this.Gi, this.Pi, this.Fi);
1423
- this.ki = i.framebuffer, this.Ti = i.columns, this.Ai = i.rows;
1572
+ async Xi() {
1573
+ const t = this.Wi.si(this.Ei), e = this.Wi.ni(t);
1574
+ this.Li = this.Vi.createCharacterObjects(e, this.Ei), this.Di = this.Hi.Si(e, this.Pi, this.Ei);
1575
+ const i = this.Oi.createTextureAtlas(this.Li, this.Di, this.Pi, this.Ei);
1576
+ this.ki = i.framebuffer, this.Gi = i.columns, this.Bi = i.rows;
1424
1577
  }
1425
- Mi(t) {
1426
- return this.Wi.Mi(t, this.zi);
1578
+ zi(t) {
1579
+ return this.Vi.zi(t, this.Li);
1427
1580
  }
1428
- Si(t) {
1429
- return this.Wi.Si(t, this.zi);
1581
+ Ti(t) {
1582
+ return this.Vi.Ti(t, this.Li);
1430
1583
  }
1431
- Ut() {
1432
- this.ki.Ut(), document.fonts.delete(this.Li);
1584
+ Pt() {
1585
+ this.ki.Pt(), document.fonts.delete(this.Ii);
1433
1586
  }
1434
1587
  get fontFramebuffer() {
1435
1588
  return this.ki;
1436
1589
  }
1437
1590
  get characters() {
1438
- return this.zi;
1591
+ return this.Li;
1439
1592
  }
1440
1593
  get textureColumns() {
1441
- return this.Ti;
1594
+ return this.Gi;
1442
1595
  }
1443
1596
  get textureRows() {
1444
- return this.Ai;
1597
+ return this.Bi;
1445
1598
  }
1446
1599
  get maxGlyphDimensions() {
1447
- return this.Gi;
1600
+ return this.Di;
1448
1601
  }
1449
1602
  get fontSize() {
1450
1603
  return this.Pi;
1451
1604
  }
1452
1605
  get font() {
1453
- return this.Fi;
1606
+ return this.Ei;
1454
1607
  }
1455
1608
  }
1456
- class Lt {
1609
+ class Wt {
1457
1610
  constructor(t, e, i) {
1458
- c(this, "Ki");
1459
- c(this, "Ni");
1460
- c(this, "Ct");
1461
- c(this, "wt");
1462
- c(this, "Xi");
1463
- c(this, "ji");
1464
- c(this, "Yi");
1465
- c(this, "qi");
1466
- c(this, "Zi");
1467
- this.Yi = t, this.qi = e, this.Zi = i, this.rt();
1468
- }
1469
- rt() {
1470
- this.Ki = Math.floor(this.Yi.width / this.qi), this.Ni = Math.floor(this.Yi.height / this.Zi), this.Ct = this.Ki * this.qi, this.wt = this.Ni * this.Zi, this.Xi = Math.floor((this.Yi.width - this.Ct) / 2), this.ji = Math.floor((this.Yi.height - this.wt) / 2);
1471
- }
1472
- Ji(t, e) {
1473
- this.qi = t, this.Zi = e, this.rt();
1611
+ a(this, "qi");
1612
+ a(this, "Zi");
1613
+ a(this, "dt");
1614
+ a(this, "_t");
1615
+ a(this, "Ji");
1616
+ a(this, "Qi");
1617
+ a(this, "tr");
1618
+ a(this, "er");
1619
+ a(this, "sr");
1620
+ this.tr = t, this.er = e, this.sr = i, this.ir();
1621
+ }
1622
+ ir() {
1623
+ this.qi = Math.floor(this.tr.width / this.er), this.Zi = Math.floor(this.tr.height / this.sr), this.dt = this.qi * this.er, this._t = this.Zi * this.sr, this.Ji = Math.floor((this.tr.width - this.dt) / 2), this.Qi = Math.floor((this.tr.height - this._t) / 2);
1624
+ }
1625
+ rr(t, e) {
1626
+ this.er = t, this.sr = e, this.ir();
1474
1627
  }
1475
1628
  get cellWidth() {
1476
- return this.qi;
1629
+ return this.er;
1477
1630
  }
1478
1631
  get cellHeight() {
1479
- return this.Zi;
1632
+ return this.sr;
1480
1633
  }
1481
1634
  get cols() {
1482
- return this.Ki;
1635
+ return this.qi;
1483
1636
  }
1484
1637
  get rows() {
1485
- return this.Ni;
1638
+ return this.Zi;
1486
1639
  }
1487
1640
  get width() {
1488
- return this.Ct;
1641
+ return this.dt;
1489
1642
  }
1490
1643
  get height() {
1491
- return this.wt;
1644
+ return this._t;
1492
1645
  }
1493
1646
  get offsetX() {
1494
- return this.Xi;
1647
+ return this.Ji;
1495
1648
  }
1496
1649
  get offsetY() {
1497
- return this.ji;
1650
+ return this.Qi;
1498
1651
  }
1499
1652
  }
1500
- class Pt {
1653
+ class Xt {
1501
1654
  constructor(t = {}) {
1502
- c(this, "Yi");
1503
- c(this, "Qi");
1504
- c(this, "tr");
1505
- t.canvas ? (this.Yi = t.canvas, this.tr = !1) : (this.Yi = this.er(t.width, t.height), this.tr = !0), this.Yi.style.imageRendering = "pixelated";
1506
- }
1507
- er(t, e) {
1655
+ a(this, "tr");
1656
+ a(this, "nr", null);
1657
+ a(this, "ar", !1);
1658
+ a(this, "hr");
1659
+ a(this, "cr");
1660
+ this.ar = t.overlay ?? !1, this.ar && t.canvas ? (this.nr = t.canvas, this.tr = this.lr(), this.cr = !0, this.ur()) : t.canvas ? (this.tr = t.canvas, this.cr = !1) : (this.tr = this.dr(t.width, t.height), this.cr = !0), this.tr.style.imageRendering = "pixelated";
1661
+ }
1662
+ dr(t, e) {
1508
1663
  const i = document.createElement("canvas");
1509
1664
  return i.className = "textmodeCanvas", i.style.imageRendering = "pixelated", i.width = t || 800, i.height = e || 600, document.body.appendChild(i), i;
1510
1665
  }
1511
- sr(t, e) {
1512
- this.Yi.width = t ?? this.Yi.width, this.Yi.height = e ?? this.Yi.height;
1666
+ lr() {
1667
+ const t = document.createElement("canvas");
1668
+ t.className = "textmodeCanvas", t.style.imageRendering = "pixelated";
1669
+ const e = this.nr.getBoundingClientRect();
1670
+ let i = Math.round(e.width), s = Math.round(e.height);
1671
+ if (this.nr instanceof HTMLVideoElement) {
1672
+ const o = this.nr;
1673
+ (i === 0 || s === 0) && o.videoWidth > 0 && o.videoHeight > 0 && (i = o.videoWidth, s = o.videoHeight);
1674
+ }
1675
+ t.width = i, t.height = s, t.style.position = "absolute", t.style.pointerEvents = "none";
1676
+ const r = window.getComputedStyle(this.nr);
1677
+ let n = parseInt(r.zIndex || "0", 10);
1678
+ return isNaN(n) && (n = 0), t.style.zIndex = "" + (n + 1), t;
1679
+ }
1680
+ ur() {
1681
+ var t;
1682
+ this._r(), (t = this.nr.parentNode) == null || t.insertBefore(this.tr, this.nr.nextSibling), window.ResizeObserver && (this.hr = new ResizeObserver(() => {
1683
+ this.pr();
1684
+ }), this.hr.observe(this.nr)), window.addEventListener("resize", () => {
1685
+ this.pr();
1686
+ });
1513
1687
  }
1514
- ir() {
1515
- const t = this.Yi.getContext("webgl2", { alpha: !0, premultipliedAlpha: !1, preserveDrawingBuffer: !0, antialias: !1, depth: !1, stencil: !1, powerPreference: "high-performance" });
1516
- if (!t) throw new E("`textmode.js` requires WebGL2 support.");
1688
+ _r() {
1689
+ if (!this.nr) return;
1690
+ const t = this.nr.getBoundingClientRect();
1691
+ let e = this.nr.offsetParent;
1692
+ if (e && e !== document.body) {
1693
+ const i = e.getBoundingClientRect();
1694
+ this.tr.style.top = t.top - i.top + "px", this.tr.style.left = t.left - i.left + "px";
1695
+ } else this.tr.style.top = t.top + window.scrollY + "px", this.tr.style.left = t.left + window.scrollX + "px";
1696
+ }
1697
+ pr(t, e) {
1698
+ if (this.ar) {
1699
+ const i = this.nr.getBoundingClientRect();
1700
+ let s = Math.round(i.width), r = Math.round(i.height);
1701
+ if (this.nr instanceof HTMLVideoElement) {
1702
+ const n = this.nr;
1703
+ (s === 0 || r === 0) && n.videoWidth > 0 && n.videoHeight > 0 && (s = n.videoWidth, r = n.videoHeight);
1704
+ }
1705
+ this.tr.width = s, this.tr.height = r, this._r();
1706
+ } else this.tr.width = t ?? this.tr.width, this.tr.height = e ?? this.tr.height;
1707
+ }
1708
+ mr() {
1709
+ const t = this.tr.getContext("webgl2", { alpha: !0, premultipliedAlpha: !1, preserveDrawingBuffer: !0, antialias: !1, depth: !1, stencil: !1, powerPreference: "high-performance" });
1710
+ if (!t) throw new U("`textmode.js` requires WebGL2 support.");
1517
1711
  return t;
1518
1712
  }
1519
- Ut() {
1520
- this.Qi && this.Qi.disconnect();
1521
- const t = this.Yi.getContext("webgl") || this.Yi.getContext("webgl2");
1713
+ Pt() {
1714
+ this.hr && this.hr.disconnect();
1715
+ const t = this.tr.getContext("webgl") || this.tr.getContext("webgl2");
1522
1716
  if (t) {
1523
1717
  const e = t.getExtension("WEBGL_lose_context");
1524
1718
  e && e.loseContext();
1525
1719
  }
1526
- this.tr && this.Yi.parentNode && this.Yi.parentNode.removeChild(this.Yi);
1720
+ this.cr && this.tr.parentNode && this.tr.parentNode.removeChild(this.tr);
1527
1721
  }
1528
1722
  get canvas() {
1529
- return this.Yi;
1723
+ return this.tr;
1724
+ }
1725
+ get targetCanvas() {
1726
+ return this.nr;
1530
1727
  }
1531
1728
  get width() {
1532
- return this.Yi.width;
1729
+ return this.tr.width;
1533
1730
  }
1534
1731
  get height() {
1535
- return this.Yi.height;
1732
+ return this.tr.height;
1536
1733
  }
1537
1734
  }
1538
- class Mt {
1735
+ class z {
1736
+ constructor(t, e, i, s) {
1737
+ a(this, "texture");
1738
+ a(this, "width");
1739
+ a(this, "height");
1740
+ a(this, "vt");
1741
+ a(this, "P", 0);
1742
+ a(this, "N", 0);
1743
+ a(this, "X", 0);
1744
+ a(this, "G", [0, 0]);
1745
+ a(this, "gr", "sampled");
1746
+ a(this, "vr", "fixed");
1747
+ a(this, "Y", [1, 1, 1]);
1748
+ a(this, "q", [0, 0, 0]);
1749
+ a(this, "yr", [0, 0, 0, 1]);
1750
+ a(this, "Cr", [[0.1, 0, 0]]);
1751
+ a(this, "wr");
1752
+ this.vt = t, this.texture = e, this.width = i, this.height = s;
1753
+ }
1754
+ Pt() {
1755
+ this.vt.deleteTexture(this.texture);
1756
+ }
1757
+ $r(t) {
1758
+ return typeof t == "boolean" ? t ? 1 : 0 : (t == null ? 0 : Number(t)) > 0 ? 1 : 0;
1759
+ }
1760
+ invert(t = !0) {
1761
+ return this.P = this.$r(t), this;
1762
+ }
1763
+ flipX(t = !0) {
1764
+ return this.N = this.$r(t), this;
1765
+ }
1766
+ flipY(t = !0) {
1767
+ return this.X = this.$r(t), this;
1768
+ }
1769
+ charRotation(t) {
1770
+ const e = 255 * t / 360, i = Math.floor(e) / 255, s = Math.round(e - Math.floor(e));
1771
+ return this.G = [i, s], this;
1772
+ }
1773
+ get flags() {
1774
+ return { invert: this.P, flipX: this.N, flipY: this.X };
1775
+ }
1776
+ get charRotationRG() {
1777
+ return this.G;
1778
+ }
1779
+ charColorMode(t) {
1780
+ return this.gr = t, this;
1781
+ }
1782
+ cellColorMode(t) {
1783
+ return this.vr = t, this;
1784
+ }
1785
+ charColor(t, e, i) {
1786
+ return this.Y = [(t ?? 0) / 255, (e ?? t ?? 0) / 255, (i ?? t ?? 0) / 255], this;
1787
+ }
1788
+ cellColor(t, e, i) {
1789
+ return this.q = [(t ?? 0) / 255, (e ?? t ?? 0) / 255, (i ?? t ?? 0) / 255], this;
1790
+ }
1791
+ background(t, e, i, s) {
1792
+ return this.yr = [(t ?? 0) / 255, (e ?? t ?? 0) / 255, (i ?? t ?? 0) / 255, (s ?? 255) / 255], this;
1793
+ }
1794
+ charactersFromColors(t) {
1795
+ const e = t.filter((i) => Array.isArray(i)).slice(0, 64);
1796
+ return this.Cr = e, this;
1797
+ }
1798
+ characters(t) {
1799
+ const e = this.wr(t);
1800
+ return this.charactersFromColors(e), this;
1801
+ }
1802
+ get characterListUniforms() {
1803
+ return { count: this.Cr.length, list: this.Cr };
1804
+ }
1805
+ get colorUniforms() {
1806
+ return { charColorFixed: this.gr === "fixed", Y: this.Y, cellColorFixed: this.vr === "fixed", cellColor: this.q, backgroundColor: this.yr };
1807
+ }
1808
+ static fromSource(t, e, i) {
1809
+ const s = t.context, r = s.createTexture();
1810
+ s.bindTexture(s.TEXTURE_2D, r), s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL, 1), s.texParameteri(s.TEXTURE_2D, s.TEXTURE_MIN_FILTER, s.NEAREST), s.texParameteri(s.TEXTURE_2D, s.TEXTURE_MAG_FILTER, s.NEAREST), s.texParameteri(s.TEXTURE_2D, s.TEXTURE_WRAP_S, s.CLAMP_TO_EDGE), s.texParameteri(s.TEXTURE_2D, s.TEXTURE_WRAP_T, s.CLAMP_TO_EDGE), s.texImage2D(s.TEXTURE_2D, 0, s.RGBA, s.RGBA, s.UNSIGNED_BYTE, e), s.bindTexture(s.TEXTURE_2D, null);
1811
+ const n = e.naturalWidth ?? e.width ?? e.videoWidth ?? 0, o = e.naturalHeight ?? e.height ?? e.videoHeight ?? 0, c = new z(s, r, n, o);
1812
+ return c.wr = i, c;
1813
+ }
1814
+ }
1815
+ class Ht {
1539
1816
  constructor(t = 60) {
1540
- c(this, "rr");
1541
- c(this, "nr");
1542
- c(this, "ar", null);
1543
- c(this, "hr", 0);
1544
- c(this, "cr", !0);
1545
- c(this, "lr", 0);
1546
- c(this, "ur", 0);
1547
- c(this, "dr", []);
1548
- c(this, "_r", 10);
1549
- c(this, "pr", 0);
1550
- this.rr = t, this.nr = 1e3 / t;
1817
+ a(this, "br");
1818
+ a(this, "Fr");
1819
+ a(this, "Mr", null);
1820
+ a(this, "Rr", 0);
1821
+ a(this, "Sr", !0);
1822
+ a(this, "Ar", 0);
1823
+ a(this, "zr", 0);
1824
+ a(this, "Tr", []);
1825
+ a(this, "Er", 10);
1826
+ a(this, "Lr", 0);
1827
+ this.br = t, this.Fr = 1e3 / t;
1551
1828
  }
1552
1829
  start(t) {
1553
- if (!this.cr) return;
1554
- this.hr = performance.now();
1830
+ if (!this.Sr) return;
1831
+ this.Rr = performance.now();
1555
1832
  const e = (i) => {
1556
- if (!this.cr) return void (this.ar = null);
1557
- const r = i - this.hr;
1558
- r >= this.nr && (t(), this.hr = i - r % this.nr), this.cr && (this.ar = requestAnimationFrame(e));
1833
+ if (!this.Sr) return void (this.Mr = null);
1834
+ const s = i - this.Rr;
1835
+ s >= this.Fr && (t(), this.Rr = i - s % this.Fr), this.Sr && (this.Mr = requestAnimationFrame(e));
1559
1836
  };
1560
- this.ar = requestAnimationFrame(e);
1837
+ this.Mr = requestAnimationFrame(e);
1561
1838
  }
1562
1839
  stop() {
1563
- this.ar && (cancelAnimationFrame(this.ar), this.ar = null);
1840
+ this.Mr && (cancelAnimationFrame(this.Mr), this.Mr = null);
1564
1841
  }
1565
1842
  pause() {
1566
- this.cr && (this.cr = !1, this.stop());
1843
+ this.Sr && (this.Sr = !1, this.stop());
1567
1844
  }
1568
1845
  resume(t) {
1569
- this.cr || (this.cr = !0, this.start(t));
1846
+ this.Sr || (this.Sr = !0, this.start(t));
1570
1847
  }
1571
1848
  frameRate(t, e) {
1572
- if (t === void 0) return this.lr;
1573
- this.rr = t, this.nr = 1e3 / t, this.cr && e && (this.stop(), this.start(e));
1849
+ if (t === void 0) return this.Ar;
1850
+ this.br = t, this.Fr = 1e3 / t, this.Sr && e && (this.stop(), this.start(e));
1574
1851
  }
1575
1852
  measureFrameRate() {
1576
1853
  const t = performance.now();
1577
- if (this.ur > 0) {
1578
- const e = t - this.ur;
1579
- this.dr.push(e), this.dr.length > this._r && this.dr.shift();
1580
- const i = this.dr.reduce((r, s) => r + s, 0) / this.dr.length;
1581
- this.lr = 1e3 / i;
1854
+ if (this.zr > 0) {
1855
+ const e = t - this.zr;
1856
+ this.Tr.push(e), this.Tr.length > this.Er && this.Tr.shift();
1857
+ const i = this.Tr.reduce((s, r) => s + r, 0) / this.Tr.length;
1858
+ this.Ar = 1e3 / i;
1582
1859
  }
1583
- this.ur = t;
1860
+ this.zr = t;
1584
1861
  }
1585
1862
  get isLooping() {
1586
- return this.cr;
1863
+ return this.Sr;
1587
1864
  }
1588
1865
  get frameRateLimit() {
1589
- return this.rr;
1866
+ return this.br;
1590
1867
  }
1591
1868
  get currentFrameRate() {
1592
- return this.lr;
1869
+ return this.Ar;
1593
1870
  }
1594
1871
  get frameCount() {
1595
- return this.pr;
1872
+ return this.Lr;
1596
1873
  }
1597
1874
  set frameCount(t) {
1598
- this.pr = t;
1875
+ this.Lr = t;
1599
1876
  }
1600
1877
  incrementFrame() {
1601
- this.pr++;
1878
+ this.Lr++;
1602
1879
  }
1603
1880
  resetFrameCount() {
1604
- this.pr = 0;
1881
+ this.Lr = 0;
1605
1882
  }
1606
1883
  }
1607
- class Ut {
1884
+ class Yt {
1608
1885
  constructor() {
1609
- c(this, "gr", /* @__PURE__ */ new Map());
1610
- c(this, "mr", null);
1611
- c(this, "vr", null);
1612
- c(this, "yr");
1613
- c(this, "$r");
1614
- c(this, "Cr", !1);
1615
- c(this, "wr");
1616
- c(this, "br");
1617
- c(this, "Rr", { ArrowUp: "UP_ARROW", ArrowDown: "DOWN_ARROW", ArrowLeft: "LEFT_ARROW", ArrowRight: "RIGHT_ARROW", F1: "F1", F2: "F2", F3: "F3", F4: "F4", F5: "F5", F6: "F6", F7: "F7", F8: "F8", F9: "F9", F10: "F10", F11: "F11", F12: "F12", Enter: "ENTER", Return: "RETURN", Tab: "TAB", Escape: "ESCAPE", Backspace: "BACKSPACE", Delete: "DELETE", Insert: "INSERT", Home: "HOME", End: "END", PageUp: "PAGE_UP", PageDown: "PAGE_DOWN", Shift: "SHIFT", Control: "CONTROL", Alt: "ALT", Meta: "META", " ": "SPACE" });
1618
- }
1619
- Mr() {
1620
- this.Cr || (this.yr = (t) => {
1621
- this.Sr(t);
1622
- }, this.$r = (t) => {
1623
- this.Fr(t);
1624
- }, window.addEventListener("keydown", this.yr, { passive: !1 }), window.addEventListener("keyup", this.$r, { passive: !1 }), this.Cr = !0);
1625
- }
1626
- zr() {
1627
- this.Cr && (window.removeEventListener("keydown", this.yr), window.removeEventListener("keyup", this.$r), this.Cr = !1, this.gr.clear(), this.mr = null, this.vr = null);
1628
- }
1629
- kr(t) {
1630
- this.wr = t;
1631
- }
1632
- Pr(t) {
1633
- this.br = t;
1634
- }
1635
- Tr(t) {
1636
- const e = this.Ar(t), i = this.gr.get(t) || this.gr.get(e);
1886
+ a(this, "kr", /* @__PURE__ */ new Map());
1887
+ a(this, "Pr", null);
1888
+ a(this, "Gr", null);
1889
+ a(this, "Br");
1890
+ a(this, "Dr");
1891
+ a(this, "Ir", !1);
1892
+ a(this, "Wr");
1893
+ a(this, "Or");
1894
+ a(this, "Hr", { ArrowUp: "UP_ARROW", ArrowDown: "DOWN_ARROW", ArrowLeft: "LEFT_ARROW", ArrowRight: "RIGHT_ARROW", F1: "F1", F2: "F2", F3: "F3", F4: "F4", F5: "F5", F6: "F6", F7: "F7", F8: "F8", F9: "F9", F10: "F10", F11: "F11", F12: "F12", Enter: "ENTER", Return: "RETURN", Tab: "TAB", Escape: "ESCAPE", Backspace: "BACKSPACE", Delete: "DELETE", Insert: "INSERT", Home: "HOME", End: "END", PageUp: "PAGE_UP", PageDown: "PAGE_DOWN", Shift: "SHIFT", Control: "CONTROL", Alt: "ALT", Meta: "META", " ": "SPACE" });
1895
+ }
1896
+ Vr() {
1897
+ this.Ir || (this.Br = (t) => {
1898
+ this.Kr(t);
1899
+ }, this.Dr = (t) => {
1900
+ this.Nr(t);
1901
+ }, window.addEventListener("keydown", this.Br, { passive: !1 }), window.addEventListener("keyup", this.Dr, { passive: !1 }), this.Ir = !0);
1902
+ }
1903
+ Xr() {
1904
+ this.Ir && (window.removeEventListener("keydown", this.Br), window.removeEventListener("keyup", this.Dr), this.Ir = !1, this.kr.clear(), this.Pr = null, this.Gr = null);
1905
+ }
1906
+ jr(t) {
1907
+ this.Wr = t;
1908
+ }
1909
+ Yr(t) {
1910
+ this.Or = t;
1911
+ }
1912
+ qr(t) {
1913
+ const e = this.Zr(t), i = this.kr.get(t) || this.kr.get(e);
1637
1914
  return (i == null ? void 0 : i.isPressed) || !1;
1638
1915
  }
1639
- Gr() {
1640
- return this.mr;
1916
+ Jr() {
1917
+ return this.Pr;
1641
1918
  }
1642
- Lr() {
1643
- return this.vr;
1919
+ Qr() {
1920
+ return this.Gr;
1644
1921
  }
1645
- Er() {
1922
+ tn() {
1646
1923
  const t = [];
1647
- for (const [e, i] of this.gr) i.isPressed && t.push(e);
1924
+ for (const [e, i] of this.kr) i.isPressed && t.push(e);
1648
1925
  return t;
1649
1926
  }
1650
- Br() {
1651
- return { ctrl: this.Tr("Control"), shift: this.Tr("Shift"), alt: this.Tr("Alt"), meta: this.Tr("Meta") };
1927
+ en() {
1928
+ return { ctrl: this.qr("Control"), shift: this.qr("Shift"), alt: this.qr("Alt"), meta: this.qr("Meta") };
1652
1929
  }
1653
- Dr() {
1654
- this.gr.clear(), this.mr = null, this.vr = null;
1930
+ sn() {
1931
+ this.kr.clear(), this.Pr = null, this.Gr = null;
1655
1932
  }
1656
- Sr(t) {
1933
+ Kr(t) {
1657
1934
  const e = t.key, i = Date.now();
1658
- this.gr.has(e) || this.gr.set(e, { isPressed: !1, lastPressTime: 0, lastReleaseTime: 0 });
1659
- const r = this.gr.get(e);
1660
- if (!r.isPressed && (r.isPressed = !0, r.lastPressTime = i, this.mr = e, this.wr)) {
1661
- const s = { key: e, keyCode: t.keyCode, ctrlKey: t.ctrlKey, shiftKey: t.shiftKey, altKey: t.altKey, metaKey: t.metaKey, isPressed: !0, originalEvent: t };
1662
- this.wr(s);
1935
+ this.kr.has(e) || this.kr.set(e, { isPressed: !1, lastPressTime: 0, lastReleaseTime: 0 });
1936
+ const s = this.kr.get(e);
1937
+ if (!s.isPressed && (s.isPressed = !0, s.lastPressTime = i, this.Pr = e, this.Wr)) {
1938
+ const r = { key: e, keyCode: t.keyCode, ctrlKey: t.ctrlKey, shiftKey: t.shiftKey, altKey: t.altKey, metaKey: t.metaKey, isPressed: !0, originalEvent: t };
1939
+ this.Wr(r);
1663
1940
  }
1664
1941
  }
1665
- Fr(t) {
1942
+ Nr(t) {
1666
1943
  const e = t.key, i = Date.now();
1667
- this.gr.has(e) || this.gr.set(e, { isPressed: !1, lastPressTime: 0, lastReleaseTime: 0 });
1668
- const r = this.gr.get(e);
1669
- if (r.isPressed = !1, r.lastReleaseTime = i, this.vr = e, this.br) {
1670
- const s = { key: e, keyCode: t.keyCode, ctrlKey: t.ctrlKey, shiftKey: t.shiftKey, altKey: t.altKey, metaKey: t.metaKey, isPressed: !1, originalEvent: t };
1671
- this.br(s);
1944
+ this.kr.has(e) || this.kr.set(e, { isPressed: !1, lastPressTime: 0, lastReleaseTime: 0 });
1945
+ const s = this.kr.get(e);
1946
+ if (s.isPressed = !1, s.lastReleaseTime = i, this.Gr = e, this.Or) {
1947
+ const r = { key: e, keyCode: t.keyCode, ctrlKey: t.ctrlKey, shiftKey: t.shiftKey, altKey: t.altKey, metaKey: t.metaKey, isPressed: !1, originalEvent: t };
1948
+ this.Or(r);
1672
1949
  }
1673
1950
  }
1674
- Ar(t) {
1675
- return this.Rr[t] || t.toLowerCase();
1951
+ Zr(t) {
1952
+ return this.Hr[t] || t.toLowerCase();
1676
1953
  }
1677
1954
  }
1678
- class It {
1955
+ class Vt {
1679
1956
  constructor(t) {
1680
- c(this, "Yi");
1681
- c(this, "Wr");
1682
- c(this, "Ir", { x: -1, y: -1 });
1683
- c(this, "Ur", { x: -1, y: -1 });
1684
- c(this, "Vr", null);
1685
- c(this, "Or");
1686
- c(this, "Hr");
1687
- c(this, "Kr");
1688
- c(this, "Nr");
1689
- c(this, "Xr");
1690
- c(this, "jr");
1691
- c(this, "Cr", !1);
1692
- c(this, "Yr");
1693
- c(this, "qr");
1694
- c(this, "Zr");
1695
- c(this, "Jr");
1696
- c(this, "Qr");
1697
- this.Yi = t;
1698
- }
1699
- Ii(t) {
1700
- this.Wr = t, this.tn();
1701
- }
1702
- Mr() {
1703
- if (this.Cr) return;
1704
- const t = this.Yi.canvas;
1705
- this.Or = (e) => {
1706
- this.en(e), this.sn(e);
1707
- }, this.Hr = () => {
1708
- this.Ur = { ...this.Ir }, this.Ir.x = -1, this.Ir.y = -1, this.Vr = null;
1709
- }, this.Kr = (e) => {
1710
- this.en(e), this.rn(e);
1711
- }, this.Nr = (e) => {
1712
- this.en(e), this.nn(e);
1713
- }, this.Xr = (e) => {
1714
- this.en(e), this.an(e);
1715
- }, this.jr = (e) => {
1716
- this.en(e), this.hn(e);
1717
- }, t.addEventListener("mousemove", this.Or, { passive: !0 }), t.addEventListener("mouseleave", this.Hr, { passive: !0 }), t.addEventListener("mousedown", this.Kr, { passive: !0 }), t.addEventListener("mouseup", this.Nr, { passive: !0 }), t.addEventListener("click", this.Xr, { passive: !0 }), t.addEventListener("wheel", this.jr, { passive: !1 }), this.Cr = !0;
1718
- }
1719
- zr() {
1720
- if (!this.Cr) return;
1721
- const t = this.Yi.canvas;
1722
- t.removeEventListener("mousemove", this.Or), t.removeEventListener("mouseleave", this.Hr), t.removeEventListener("mousedown", this.Kr), t.removeEventListener("mouseup", this.Nr), t.removeEventListener("click", this.Xr), t.removeEventListener("wheel", this.jr), this.Cr = !1;
1957
+ a(this, "tr");
1958
+ a(this, "rn");
1959
+ a(this, "nn", { x: -1, y: -1 });
1960
+ a(this, "an", { x: -1, y: -1 });
1961
+ a(this, "hn", null);
1962
+ a(this, "cn");
1963
+ a(this, "ln");
1964
+ a(this, "un");
1965
+ a(this, "fn");
1966
+ a(this, "dn");
1967
+ a(this, "_n");
1968
+ a(this, "Ir", !1);
1969
+ a(this, "pn");
1970
+ a(this, "mn");
1971
+ a(this, "gn");
1972
+ a(this, "vn");
1973
+ a(this, "yn");
1974
+ this.tr = t;
1975
+ }
1976
+ Ki(t) {
1977
+ this.rn = t, this.Cn();
1978
+ }
1979
+ Vr() {
1980
+ if (this.Ir) return;
1981
+ const t = this.tr.canvas;
1982
+ this.cn = (e) => {
1983
+ this.wn(e), this.$n(e);
1984
+ }, this.ln = () => {
1985
+ this.an = { ...this.nn }, this.nn.x = -1, this.nn.y = -1, this.hn = null;
1986
+ }, this.un = (e) => {
1987
+ this.wn(e), this.bn(e);
1988
+ }, this.fn = (e) => {
1989
+ this.wn(e), this.xn(e);
1990
+ }, this.dn = (e) => {
1991
+ this.wn(e), this.Fn(e);
1992
+ }, this._n = (e) => {
1993
+ this.wn(e), this.Mn(e);
1994
+ }, t.addEventListener("mousemove", this.cn, { passive: !0 }), t.addEventListener("mouseleave", this.ln, { passive: !0 }), t.addEventListener("mousedown", this.un, { passive: !0 }), t.addEventListener("mouseup", this.fn, { passive: !0 }), t.addEventListener("click", this.dn, { passive: !0 }), t.addEventListener("wheel", this._n, { passive: !1 }), this.Ir = !0;
1995
+ }
1996
+ Xr() {
1997
+ if (!this.Ir) return;
1998
+ const t = this.tr.canvas;
1999
+ t.removeEventListener("mousemove", this.cn), t.removeEventListener("mouseleave", this.ln), t.removeEventListener("mousedown", this.un), t.removeEventListener("mouseup", this.fn), t.removeEventListener("click", this.dn), t.removeEventListener("wheel", this._n), this.Ir = !1;
1723
2000
  }
1724
- tn() {
1725
- if (this.Cr) try {
1726
- if (this.Vr) {
1727
- const t = new MouseEvent("mousemove", { clientX: this.Vr.x, clientY: this.Vr.y, bubbles: !1, cancelable: !1 });
1728
- this.en(t);
1729
- } else this.Ir.x !== -1 && this.Ir.y !== -1 && (this.Ir.x >= this.Wr.cols || this.Ir.y >= this.Wr.rows) && (this.Ir.x = -1, this.Ir.y = -1);
2001
+ Cn() {
2002
+ if (this.Ir) try {
2003
+ if (this.hn) {
2004
+ const t = new MouseEvent("mousemove", { clientX: this.hn.x, clientY: this.hn.y, bubbles: !1, cancelable: !1 });
2005
+ this.wn(t);
2006
+ } else this.nn.x !== -1 && this.nn.y !== -1 && (this.nn.x >= this.rn.cols || this.nn.y >= this.rn.rows) && (this.nn.x = -1, this.nn.y = -1);
1730
2007
  } catch {
1731
- this.Ir.x = -1, this.Ir.y = -1;
2008
+ this.nn.x = -1, this.nn.y = -1;
1732
2009
  }
1733
2010
  }
1734
- cn(t) {
1735
- this.Yr = t;
2011
+ Rn(t) {
2012
+ this.pn = t;
1736
2013
  }
1737
- kr(t) {
1738
- this.qr = t;
2014
+ jr(t) {
2015
+ this.mn = t;
1739
2016
  }
1740
- Pr(t) {
1741
- this.Zr = t;
2017
+ Yr(t) {
2018
+ this.gn = t;
1742
2019
  }
1743
- ln(t) {
1744
- this.Jr = t;
2020
+ Sn(t) {
2021
+ this.vn = t;
1745
2022
  }
1746
- un(t) {
1747
- this.Qr = t;
2023
+ An(t) {
2024
+ this.yn = t;
1748
2025
  }
1749
- fn() {
1750
- return { x: this.Ir.x, y: this.Ir.y };
2026
+ zn() {
2027
+ return { x: this.nn.x, y: this.nn.y };
1751
2028
  }
1752
- sn(t) {
1753
- if (this.Jr) {
1754
- const e = { position: { ...this.Ir }, previousPosition: { ...this.Ur }, originalEvent: t };
1755
- this.Jr(e);
2029
+ $n(t) {
2030
+ if (this.vn) {
2031
+ const e = { position: { ...this.nn }, previousPosition: { ...this.an }, originalEvent: t };
2032
+ this.vn(e);
1756
2033
  }
1757
2034
  }
1758
- rn(t) {
1759
- if (this.qr) {
1760
- const e = { position: { ...this.Ir }, previousPosition: { ...this.Ur }, button: t.button, originalEvent: t };
1761
- this.qr(e);
2035
+ bn(t) {
2036
+ if (this.mn) {
2037
+ const e = { position: { ...this.nn }, previousPosition: { ...this.an }, button: t.button, originalEvent: t };
2038
+ this.mn(e);
1762
2039
  }
1763
2040
  }
1764
- nn(t) {
1765
- if (this.Zr) {
1766
- const e = { position: { ...this.Ir }, previousPosition: { ...this.Ur }, button: t.button, originalEvent: t };
1767
- this.Zr(e);
2041
+ xn(t) {
2042
+ if (this.gn) {
2043
+ const e = { position: { ...this.nn }, previousPosition: { ...this.an }, button: t.button, originalEvent: t };
2044
+ this.gn(e);
1768
2045
  }
1769
2046
  }
1770
- an(t) {
1771
- if (this.Yr) {
1772
- const e = { position: { ...this.Ir }, previousPosition: { ...this.Ur }, button: t.button, originalEvent: t };
1773
- this.Yr(e);
2047
+ Fn(t) {
2048
+ if (this.pn) {
2049
+ const e = { position: { ...this.nn }, previousPosition: { ...this.an }, button: t.button, originalEvent: t };
2050
+ this.pn(e);
1774
2051
  }
1775
2052
  }
1776
- hn(t) {
1777
- if (this.Qr) {
1778
- const e = { position: { ...this.Ir }, previousPosition: { ...this.Ur }, delta: { x: t.deltaX, y: t.deltaY }, originalEvent: t };
1779
- this.Qr(e);
2053
+ Mn(t) {
2054
+ if (this.yn) {
2055
+ const e = { position: { ...this.nn }, previousPosition: { ...this.an }, delta: { x: t.deltaX, y: t.deltaY }, originalEvent: t };
2056
+ this.yn(e);
1780
2057
  }
1781
2058
  }
1782
- en(t) {
1783
- const e = this.Yi.canvas;
1784
- this.Ur = { ...this.Ir }, this.Vr = { x: t.clientX, y: t.clientY };
1785
- const i = e.getBoundingClientRect(), r = t.clientX - i.left, s = t.clientY - i.top, n = e.width / i.width, o = s * (e.height / i.height), h = r * n - this.Wr.offsetX, l = o - this.Wr.offsetY, u = Math.floor(h / this.Wr.cellWidth), f = Math.floor(l / this.Wr.cellHeight);
1786
- u >= 0 && u < this.Wr.cols && f >= 0 && f < this.Wr.rows ? (this.Ir.x = u, this.Ir.y = f) : (this.Ir.x = -1, this.Ir.y = -1);
2059
+ wn(t) {
2060
+ const e = this.tr.canvas;
2061
+ this.an = { ...this.nn }, this.hn = { x: t.clientX, y: t.clientY };
2062
+ const i = e.getBoundingClientRect(), s = t.clientX - i.left, r = t.clientY - i.top, n = e.width / i.width, o = r * (e.height / i.height), c = s * n - this.rn.offsetX, l = o - this.rn.offsetY, f = Math.floor(c / this.rn.cellWidth), u = Math.floor(l / this.rn.cellHeight);
2063
+ f >= 0 && f < this.rn.cols && u >= 0 && u < this.rn.rows ? (this.nn.x = f, this.nn.y = u) : (this.nn.x = -1, this.nn.y = -1);
1787
2064
  }
1788
2065
  }
1789
- const kt = (a) => class extends a {
2066
+ const jt = (h) => class extends h {
1790
2067
  rotate(t = 0, e = 0, i = 0) {
1791
- this.kt.state.ht(t), this.kt.state.ct(e), this.kt.state.lt(i);
2068
+ this.xt.state.et(t), this.xt.state.st(e), this.xt.state.it(i);
1792
2069
  }
1793
2070
  rotateX(t) {
1794
- this.kt.state.ht(t);
2071
+ this.xt.state.et(t);
1795
2072
  }
1796
2073
  rotateY(t) {
1797
- this.kt.state.ct(t);
2074
+ this.xt.state.st(t);
1798
2075
  }
1799
2076
  rotateZ(t) {
1800
- this.kt.state.lt(t);
2077
+ this.xt.state.it(t);
1801
2078
  }
1802
2079
  push() {
1803
- this.kt.state.N();
2080
+ this.xt.state.W();
1804
2081
  }
1805
2082
  pop() {
1806
- this.kt.state.it();
2083
+ this.xt.state.Z();
1807
2084
  }
1808
- rect(t, e, i = 1, r = 1) {
1809
- this.kt.Es(t, e, i, r);
2085
+ rect(t, e, i = 1, s = 1) {
2086
+ this.xt.Hs(t, e, i, s);
1810
2087
  }
1811
2088
  point(t, e) {
1812
- this.kt.Es(t, e, 1, 1);
2089
+ this.xt.Hs(t, e, 1, 1);
1813
2090
  }
1814
- line(t, e, i, r) {
1815
- this.kt.Bs(t, e, i, r);
2091
+ line(t, e, i, s) {
2092
+ this.xt.Vs(t, e, i, s);
1816
2093
  }
1817
2094
  lineWeight(t) {
1818
- this.kt.state.ot(t);
2095
+ this.xt.state.tt(t);
1819
2096
  }
1820
- background(t, e = t, i = t, r = 255) {
1821
- this.kt.Os(t, e, i, r);
2097
+ background(t, e = t, i = t, s = 255) {
2098
+ this.xt.qs(t, e, i, s);
1822
2099
  }
1823
2100
  char(t) {
1824
- this.kt.state.ut(this.Fi.Mi(t));
2101
+ this.xt.state.rt(this.Ei.zi(t));
1825
2102
  }
1826
2103
  charColor(t, e, i) {
1827
- this.kt.state.ft(t, e, i);
2104
+ this.xt.state.nt(t, e, i);
1828
2105
  }
1829
2106
  cellColor(t, e, i) {
1830
- this.kt.state.dt(t, e, i);
2107
+ this.xt.state.ot(t, e, i);
1831
2108
  }
1832
2109
  flipX(t) {
1833
- this.kt.state._t(t);
2110
+ this.xt.state.ht(t);
1834
2111
  }
1835
2112
  flipY(t) {
1836
- this.kt.state.gt(t);
2113
+ this.xt.state.ct(t);
1837
2114
  }
1838
2115
  charRotation(t) {
1839
- this.kt.state.yt(t);
2116
+ this.xt.state.ut(t);
1840
2117
  }
1841
2118
  invert(t) {
1842
- this.kt.state.vt(t);
2119
+ this.xt.state.lt(t);
1843
2120
  }
1844
2121
  clear() {
1845
- this.kt.Os(0, 0, 0, 0);
2122
+ this.xt.qs(0, 0, 0, 0);
1846
2123
  }
1847
- ellipse(t, e, i, r) {
1848
- this.kt.Ds(t, e, i / 2, r / 2);
2124
+ ellipse(t, e, i, s) {
2125
+ this.xt.Ks(t, e, i / 2, s / 2);
1849
2126
  }
1850
- triangle(t, e, i, r, s, n) {
1851
- this.kt.Ws(t, e, i, r, s, n);
2127
+ triangle(t, e, i, s, r, n) {
2128
+ this.xt.Ns(t, e, i, s, r, n);
1852
2129
  }
1853
- bezierCurve(t, e, i, r, s, n, o, h) {
1854
- this.kt.Is(t, e, i, r, s, n, o, h);
2130
+ bezierCurve(t, e, i, s, r, n, o, c) {
2131
+ this.xt.Xs(t, e, i, s, r, n, o, c);
1855
2132
  }
1856
- arc(t, e, i, r, s, n) {
1857
- this.kt.Vs(t, e, i, r, s, n);
2133
+ arc(t, e, i, s, r, n) {
2134
+ this.xt.Ys(t, e, i, s, r, n);
1858
2135
  }
1859
2136
  shader(t) {
1860
- this.kt.Ts(t);
2137
+ this.xt.Bs(t);
1861
2138
  }
1862
2139
  setUniform(t, e) {
1863
- this.kt.Jt(t, e);
2140
+ this.xt.Xt(t, e);
1864
2141
  }
1865
2142
  setUniforms(t) {
1866
- this.kt.As(t);
2143
+ this.xt.Ds(t);
1867
2144
  }
1868
2145
  createFilterShader(t) {
1869
- return this.kt.he(t);
2146
+ return this.xt.oe(t);
1870
2147
  }
1871
2148
  createFramebuffer(t) {
1872
- return this.kt.Us(t.width, t.height, 5, { filter: "nearest", wrap: "clamp", format: "rgba", type: "unsigned_byte" });
2149
+ return this.xt.js(t.width, t.height, 5, { filter: "nearest", wrap: "clamp", format: "rgba", type: "unsigned_byte" });
2150
+ }
2151
+ image(t, e, i, s, r) {
2152
+ if (t.textures) {
2153
+ const n = t;
2154
+ this.xt.Is(n, e, i, s ?? n.width, r ?? n.height);
2155
+ } else {
2156
+ const n = t;
2157
+ this.xt.Ws(n, e, i, s ?? n.width, r ?? n.height);
2158
+ }
1873
2159
  }
1874
- image(t, e, i, r, s) {
1875
- this.kt.Gs(t, e, i, r ?? t.width, s ?? t.height);
2160
+ async loadImage(t) {
2161
+ if (typeof t != "string") return z.fromSource(this.xt, t, (s) => this.Ei.Ti(s));
2162
+ const e = t, i = await new Promise((s, r) => {
2163
+ const n = new Image();
2164
+ n.crossOrigin = "anonymous", n.onload = () => s(n), n.onerror = (o) => r(o), n.src = e;
2165
+ });
2166
+ return z.fromSource(this.xt, i, (s) => this.Ei.Ti(s));
1876
2167
  }
1877
2168
  };
1878
- class $ {
1879
- dn(t) {
1880
- const e = t.Et(0), i = t.Et(1), r = t.Et(2), s = t.Et(3);
1881
- return { characterPixels: e, primaryColorPixels: i, secondaryColorPixels: r, transformPixels: t.Et(4), rotationPixels: s };
2169
+ class J {
2170
+ Tn(t) {
2171
+ const e = t.zt(0), i = t.zt(1), s = t.zt(2), r = t.zt(3);
2172
+ return { characterPixels: e, primaryColorPixels: i, secondaryColorPixels: s, transformPixels: t.zt(4), rotationPixels: r };
1882
2173
  }
1883
- _n(t, e) {
2174
+ En(t, e) {
1884
2175
  return t[e] + (t[e + 1] << 8);
1885
2176
  }
1886
- pn(t, e) {
2177
+ Ln(t, e) {
1887
2178
  return { r: t[e], g: t[e + 1], b: t[e + 2], a: t[e + 3] };
1888
2179
  }
1889
2180
  }
1890
- class O {
1891
- gn(t, e) {
2181
+ class Z {
2182
+ kn(t, e) {
1892
2183
  return new Blob([t], { type: e });
1893
2184
  }
1894
- mn(t, e, i) {
2185
+ Pn(t, e, i) {
1895
2186
  try {
1896
- const r = this.gn(t, i), s = URL.createObjectURL(r), n = document.createElement("a");
1897
- n.href = s, n.download = e, n.style.display = "none", n.rel = "noopener", document.body.appendChild(n), n.click(), document.body.removeChild(n), URL.revokeObjectURL(s);
1898
- } catch (r) {
1899
- throw console.error("Failed to download file:", r), Error("File download failed: " + (r instanceof Error ? r.message : "Unknown error"));
2187
+ const s = this.kn(t, i), r = URL.createObjectURL(s), n = document.createElement("a");
2188
+ n.href = r, n.download = e, n.style.display = "none", n.rel = "noopener", document.body.appendChild(n), n.click(), document.body.removeChild(n), URL.revokeObjectURL(r);
2189
+ } catch (s) {
2190
+ console.error("Failed to download file:", s);
1900
2191
  }
1901
2192
  }
1902
- vn() {
2193
+ Gn() {
1903
2194
  return (/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace(/:/g, "-");
1904
2195
  }
1905
- yn() {
2196
+ Bn() {
1906
2197
  const t = /* @__PURE__ */ new Date();
1907
2198
  return { date: t.toISOString().split("T")[0], time: t.toTimeString().split(" ")[0].replace(/:/g, "-") };
1908
2199
  }
1909
- $n(t) {
2200
+ Dn(t) {
1910
2201
  return t.replace(/[<>:"/\\|?*]/g, "_").replace(/\s+/g, "_").replace(/_{2,}/g, "_").replace(/^_+|_+$/g, "").substring(0, 255);
1911
2202
  }
1912
- Cn() {
1913
- return "textmode-export-" + this.vn();
2203
+ In() {
2204
+ return "textmode-export-" + this.Gn();
1914
2205
  }
1915
2206
  }
1916
- class zt extends $ {
1917
- wn(t, e, i) {
1918
- const r = t[i] === 255, s = t[i + 1] === 255, n = t[i + 2] === 255, o = e[i], h = e[i + 1];
1919
- return { isInverted: r, flipHorizontal: s, flipVertical: n, rotation: Math.round(360 * (o + h / 255) / 255 * 100) / 100 };
2207
+ class Kt extends J {
2208
+ Wn(t, e, i) {
2209
+ const s = t[i] === 255, r = t[i + 1] === 255, n = t[i + 2] === 255, o = e[i], c = e[i + 1];
2210
+ return { isInverted: s, flipHorizontal: r, flipVertical: n, rotation: Math.round(360 * (o + c / 255) / 255 * 100) / 100 };
1920
2211
  }
1921
- xn(t, e, i) {
2212
+ On(t, e, i) {
1922
2213
  return { x: t, y: e, cellX: t * i.cellWidth, cellY: e * i.cellHeight };
1923
2214
  }
1924
- bn(t, e) {
2215
+ Hn(t, e) {
1925
2216
  const i = [];
1926
- let r = 0;
1927
- for (let s = 0; s < e.rows; s++) for (let n = 0; n < e.cols; n++) {
1928
- const o = 4 * r, h = this._n(t.characterPixels, o);
1929
- let l = this.pn(t.primaryColorPixels, o), u = this.pn(t.secondaryColorPixels, o);
1930
- const f = this.wn(t.transformPixels, t.rotationPixels, o);
1931
- if (f.isInverted) {
1932
- const p = l;
1933
- l = u, u = p;
2217
+ let s = 0;
2218
+ for (let r = 0; r < e.rows; r++) for (let n = 0; n < e.cols; n++) {
2219
+ const o = 4 * s, c = this.En(t.characterPixels, o);
2220
+ let l = this.Ln(t.primaryColorPixels, o), f = this.Ln(t.secondaryColorPixels, o);
2221
+ const u = this.Wn(t.transformPixels, t.rotationPixels, o);
2222
+ if (u.isInverted) {
2223
+ const v = l;
2224
+ l = f, f = v;
1934
2225
  }
1935
- const d = this.xn(n, s, e);
1936
- i.push({ charIndex: h, primaryColor: l, secondaryColor: u, transform: f, position: d }), r++;
2226
+ const g = this.On(n, r, e);
2227
+ i.push({ charIndex: c, primaryColor: l, secondaryColor: f, transform: u, position: g }), s++;
1937
2228
  }
1938
2229
  return i;
1939
2230
  }
1940
2231
  }
1941
- class Wt {
1942
- Rn(t, e) {
2232
+ class qt {
2233
+ Vn(t, e) {
1943
2234
  const i = t.cmap;
1944
- for (const r of i.tables) if (r.format === 4) {
1945
- const s = r;
1946
- for (let n = 0; n < s.startCount.length; n++) if (e >= s.startCount[n] && e <= s.endCount[n]) {
1947
- if (s.idRangeOffset[n] === 0) return e + s.idDelta[n] & 65535;
2235
+ for (const s of i.tables) if (s.format === 4) {
2236
+ const r = s;
2237
+ for (let n = 0; n < r.startCount.length; n++) if (e >= r.startCount[n] && e <= r.endCount[n]) {
2238
+ if (r.idRangeOffset[n] === 0) return e + r.idDelta[n] & 65535;
1948
2239
  {
1949
- const o = s.idRangeOffset[n] / 2 + (e - s.startCount[n]) - (s.startCount.length - n);
1950
- if (o >= 0 && o < s.glyphIdArray.length) {
1951
- const h = s.glyphIdArray[o];
1952
- if (h !== 0) return h + s.idDelta[n] & 65535;
2240
+ const o = r.idRangeOffset[n] / 2 + (e - r.startCount[n]) - (r.startCount.length - n);
2241
+ if (o >= 0 && o < r.glyphIdArray.length) {
2242
+ const c = r.glyphIdArray[o];
2243
+ if (c !== 0) return c + r.idDelta[n] & 65535;
1953
2244
  }
1954
2245
  }
1955
2246
  }
1956
- } else if (r.format === 12) {
1957
- const s = r;
1958
- for (let n = 0; n < s.groups.length; n += 3) {
1959
- const o = s.groups[n], h = s.groups[n + 1], l = s.groups[n + 2];
1960
- if (e >= o && e <= h) return l + (e - o);
2247
+ } else if (s.format === 12) {
2248
+ const r = s;
2249
+ for (let n = 0; n < r.groups.length; n += 3) {
2250
+ const o = r.groups[n], c = r.groups[n + 1], l = r.groups[n + 2];
2251
+ if (e >= o && e <= c) return l + (e - o);
1961
2252
  }
1962
2253
  }
1963
2254
  return 0;
1964
2255
  }
1965
- Mn(t, e, i, r, s) {
1966
- const n = s / t.head.unitsPerEm;
1967
- return { getBoundingBox: () => ({ x1: i + e.xMin * n, y1: r + -e.yMax * n, x2: i + e.xMax * n, y2: r + -e.yMin * n }), toSVG: () => this.Sn(e, i, r, n) };
2256
+ Kn(t, e, i, s, r) {
2257
+ const n = r / t.head.unitsPerEm;
2258
+ return { getBoundingBox: () => ({ x1: i + e.xMin * n, y1: s + -e.yMax * n, x2: i + e.xMax * n, y2: s + -e.yMin * n }), toSVG: () => this.Nn(e, i, s, n) };
1968
2259
  }
1969
- Sn(t, e, i, r) {
2260
+ Nn(t, e, i, s) {
1970
2261
  if (!t || !t.xs) return "";
1971
- const { xs: s, ys: n, endPts: o, flags: h } = t;
1972
- if (!(s && n && o && h)) return "";
1973
- let l = "", u = 0;
1974
- for (let f = 0; f < o.length; f++) {
1975
- const d = o[f];
1976
- if (!(d < u)) {
1977
- if (d >= u) {
1978
- const p = e + s[u] * r, g = i - n[u] * r;
1979
- l += `M${p.toFixed(2)},${g.toFixed(2)}`;
1980
- let m = u + 1;
1981
- for (; m <= d; )
1982
- if (1 & h[m]) {
1983
- const R = e + s[m] * r, x = i - n[m] * r;
1984
- l += `L${R.toFixed(2)},${x.toFixed(2)}`, m++;
2262
+ const { xs: r, ys: n, endPts: o, flags: c } = t;
2263
+ if (!(r && n && o && c)) return "";
2264
+ let l = "", f = 0;
2265
+ for (let u = 0; u < o.length; u++) {
2266
+ const g = o[u];
2267
+ if (!(g < f)) {
2268
+ if (g >= f) {
2269
+ const v = e + r[f] * s, m = i - n[f] * s;
2270
+ l += `M${v.toFixed(2)},${m.toFixed(2)}`;
2271
+ let d = f + 1;
2272
+ for (; d <= g; )
2273
+ if (1 & c[d]) {
2274
+ const x = e + r[d] * s, p = i - n[d] * s;
2275
+ l += `L${x.toFixed(2)},${p.toFixed(2)}`, d++;
1985
2276
  } else {
1986
- const R = e + s[m] * r, x = i - n[m] * r;
1987
- let w = m + 1 > d ? u : m + 1;
1988
- if (1 & h[w]) {
1989
- const C = e + s[w] * r, L = i - n[w] * r;
1990
- l += `Q${R.toFixed(2)},${x.toFixed(2)} ${C.toFixed(2)},${L.toFixed(2)}`, m = w + 1;
2277
+ const x = e + r[d] * s, p = i - n[d] * s;
2278
+ let E = d + 1 > g ? f : d + 1;
2279
+ if (1 & c[E]) {
2280
+ const y = e + r[E] * s, C = i - n[E] * s;
2281
+ l += `Q${x.toFixed(2)},${p.toFixed(2)} ${y.toFixed(2)},${C.toFixed(2)}`, d = E + 1;
1991
2282
  } else {
1992
- const C = (R + (e + s[w] * r)) / 2, L = (x + (i - n[w] * r)) / 2;
1993
- l += `Q${R.toFixed(2)},${x.toFixed(2)} ${C.toFixed(2)},${L.toFixed(2)}`, m = w;
2283
+ const y = (x + (e + r[E] * s)) / 2, C = (p + (i - n[E] * s)) / 2;
2284
+ l += `Q${x.toFixed(2)},${p.toFixed(2)} ${y.toFixed(2)},${C.toFixed(2)}`, d = E;
1994
2285
  }
1995
2286
  }
1996
2287
  l += "Z";
1997
2288
  }
1998
- u = d + 1;
2289
+ f = g + 1;
1999
2290
  }
2000
2291
  }
2001
2292
  return l;
2002
2293
  }
2003
- Fn(t, e, i, r, s) {
2004
- const n = t.codePointAt(0) || 0, o = this.Rn(e, n);
2005
- let h = null;
2006
- return e.glyf && e.glyf[o] !== null ? h = e.glyf[o] : (h = A.T.glyf.Ks(e, o), e.glyf[o] = h), this.Mn(e, h, i, r, s);
2294
+ Xn(t, e, i, s, r) {
2295
+ const n = t.codePointAt(0) || 0, o = this.Vn(e, n);
2296
+ let c = null;
2297
+ return e.glyf && e.glyf[o] !== null ? c = e.glyf[o] : (c = L.T.glyf.Js(e, o), e.glyf[o] = c), this.Kn(e, c, i, s, r);
2007
2298
  }
2008
- zn(t, e, i, r, s, n, o, h) {
2009
- const l = i + (s - h * (o / e.head.unitsPerEm)) / 2, u = r + (n + 0.7 * o) / 2;
2010
- return this.Fn(t, e, l, u, o).toSVG() || null;
2299
+ jn(t, e, i, s, r, n, o, c) {
2300
+ const l = i + (r - c * (o / e.head.unitsPerEm)) / 2, f = s + (n + 0.7 * o) / 2;
2301
+ return this.Xn(t, e, l, f, o).toSVG() || null;
2011
2302
  }
2012
2303
  }
2013
- class Bt {
2304
+ class Jt {
2014
2305
  constructor() {
2015
- c(this, "kn");
2016
- this.kn = new Wt();
2306
+ a(this, "Yn");
2307
+ this.Yn = new qt();
2017
2308
  }
2018
- Pn(t) {
2309
+ qn(t) {
2019
2310
  const { width: e, height: i } = t;
2020
2311
  return `<?xml version="1.0" encoding="UTF-8"?><svg width="${e}" height="${i}" viewBox="0 0 ${e} ${i}" xmlns="http://www.w3.org/2000/svg"><title>textmode.js sketch</title>`;
2021
2312
  }
2022
- Tn() {
2313
+ Zn() {
2023
2314
  return "</g></svg>";
2024
2315
  }
2025
- An(t, e) {
2316
+ Jn(t, e) {
2026
2317
  if (!e.includeBackgroundRectangles) return "";
2027
- const [i, r, s, n] = e.backgroundColor;
2028
- return `<rect width="${t.width}" height="${t.height}" fill="rgba(${i},${r},${s},${n / 255})"/>`;
2318
+ const [i, s, r, n] = e.backgroundColor;
2319
+ return `<rect width="${t.width}" height="${t.height}" fill="rgba(${i},${s},${r},${n / 255})"/>`;
2029
2320
  }
2030
- Gn(t, e) {
2031
- const { transform: i, position: r } = t;
2321
+ Qn(t, e) {
2322
+ const { transform: i, position: s } = t;
2032
2323
  if (!i.flipHorizontal && !i.flipVertical && !i.rotation) return "";
2033
- const s = r.cellX + e.cellWidth / 2, n = r.cellY + e.cellHeight / 2, o = [];
2324
+ const r = s.cellX + e.cellWidth / 2, n = s.cellY + e.cellHeight / 2, o = [];
2034
2325
  if (i.flipHorizontal || i.flipVertical) {
2035
- const h = i.flipHorizontal ? -1 : 1, l = i.flipVertical ? -1 : 1;
2036
- o.push(`translate(${s} ${n})scale(${h} ${l})translate(${-s} ${-n})`);
2326
+ const c = i.flipHorizontal ? -1 : 1, l = i.flipVertical ? -1 : 1;
2327
+ o.push(`translate(${r} ${n})scale(${c} ${l})translate(${-r} ${-n})`);
2037
2328
  }
2038
- return i.rotation && o.push(`rotate(${i.rotation} ${s} ${n})`), ` transform="${o.join(" ")}"`;
2329
+ return i.rotation && o.push(`rotate(${i.rotation} ${r} ${n})`), ` transform="${o.join(" ")}"`;
2039
2330
  }
2040
- Ln(t, e, i) {
2331
+ eo(t, e, i) {
2041
2332
  if (!i.includeBackgroundRectangles || t.secondaryColor.a === 0) return "";
2042
- const { position: r } = t, { r: s, g: n, b: o, a: h } = t.secondaryColor, l = `rgba(${s},${n},${o},${h / 255})`;
2043
- return i.drawMode === "stroke" ? `<rect x="${r.cellX}" y="${r.cellY}" width="${e.cellWidth}" height="${e.cellHeight}" stroke="${l}" fill="none" stroke-width="${i.strokeWidth}"/>` : `<rect x="${r.cellX}" y="${r.cellY}" width="${e.cellWidth}" height="${e.cellHeight}" fill="${l}"/>`;
2333
+ const { position: s } = t, { r, g: n, b: o, a: c } = t.secondaryColor, l = `rgba(${r},${n},${o},${c / 255})`;
2334
+ return i.drawMode === "stroke" ? `<rect x="${s.cellX}" y="${s.cellY}" width="${e.cellWidth}" height="${e.cellHeight}" stroke="${l}" fill="none" stroke-width="${i.strokeWidth}"/>` : `<rect x="${s.cellX}" y="${s.cellY}" width="${e.cellWidth}" height="${e.cellHeight}" fill="${l}"/>`;
2044
2335
  }
2045
- Fn(t, e, i, r) {
2046
- const s = i.characters[t.charIndex];
2047
- if (!s) return "";
2048
- const n = this.kn.zn(s.character, i.font, t.position.cellX, t.position.cellY, e.cellWidth, e.cellHeight, i.fontSize, s.advanceWidth);
2336
+ Xn(t, e, i, s) {
2337
+ const r = i.characters[t.charIndex];
2338
+ if (!r) return "";
2339
+ const n = this.Yn.jn(r.character, i.font, t.position.cellX, t.position.cellY, e.cellWidth, e.cellHeight, i.fontSize, r.advanceWidth);
2049
2340
  if (!n) return "";
2050
- const { r: o, g: h, b: l, a: u } = t.primaryColor, f = `rgba(${o},${h},${l},${u / 255})`;
2051
- return r.drawMode === "stroke" ? `<path d="${n}" stroke="${f}" stroke-width="${r.strokeWidth}" fill="none"/>` : `<path d="${n}" fill="${f}"/>`;
2341
+ const { r: o, g: c, b: l, a: f } = t.primaryColor, u = `rgba(${o},${c},${l},${f / 255})`;
2342
+ return s.drawMode === "stroke" ? `<path d="${n}" stroke="${u}" stroke-width="${s.strokeWidth}" fill="none"/>` : `<path d="${n}" fill="${u}"/>`;
2052
2343
  }
2053
- En(t, e, i, r) {
2054
- const s = [], n = this.Ln(t, e, r);
2055
- n && s.push(n);
2056
- const o = this.Fn(t, e, i, r);
2344
+ so(t, e, i, s) {
2345
+ const r = [], n = this.eo(t, e, s);
2346
+ n && r.push(n);
2347
+ const o = this.Xn(t, e, i, s);
2057
2348
  if (o) {
2058
- const h = this.Gn(t, e);
2059
- s.push(h ? `<g${h}>${o}</g>` : o);
2349
+ const c = this.Qn(t, e);
2350
+ r.push(c ? `<g${c}>${o}</g>` : o);
2060
2351
  }
2061
- return s.join("");
2352
+ return r.join("");
2062
2353
  }
2063
- Bn(t, e, i, r) {
2064
- const s = [this.Pn(e), this.An(e, r), '<g id="ascii-cells">'];
2065
- for (const n of t) s.push(this.En(n, e, i, r));
2066
- return s.push(this.Tn()), s.join("");
2354
+ io(t, e, i, s) {
2355
+ const r = [this.qn(e), this.Jn(e, s), '<g id="ascii-cells">'];
2356
+ for (const n of t) r.push(this.so(n, e, i, s));
2357
+ return r.push(this.Zn()), r.join("");
2067
2358
  }
2068
- Dn(t) {
2359
+ ro(t) {
2069
2360
  return t.replace(/<path[^>]*d=""[^>]*\/>/g, "").replace(/\s+/g, " ").replace(/> </g, "><");
2070
2361
  }
2071
2362
  }
2072
- class Dt extends O {
2073
- Wn(t) {
2074
- return this.gn(t, "image/svg+xml;charset=utf-8");
2363
+ class Zt extends Z {
2364
+ no(t) {
2365
+ return this.kn(t, "image/svg+xml;charset=utf-8");
2075
2366
  }
2076
- In(t, e) {
2077
- this.mn(t, this.$n(e) + ".svg", "image/svg+xml;charset=utf-8");
2367
+ oo(t, e) {
2368
+ this.Pn(t, this.Dn(e) + ".svg", "image/svg+xml;charset=utf-8");
2078
2369
  }
2079
- Un(t, e) {
2080
- this.In(t, e || this.Cn());
2370
+ ao(t, e) {
2371
+ this.oo(t, e || this.In());
2081
2372
  }
2082
2373
  }
2083
- class X {
2374
+ class st {
2084
2375
  constructor() {
2085
- c(this, "Vn");
2086
- c(this, "On");
2087
- c(this, "Hn");
2088
- this.Vn = new zt(), this.On = new Bt(), this.Hn = new Dt();
2376
+ a(this, "ho");
2377
+ a(this, "co");
2378
+ a(this, "lo");
2379
+ this.ho = new Kt(), this.co = new Jt(), this.lo = new Zt();
2089
2380
  }
2090
- Kn(t) {
2091
- return { includeBackgroundRectangles: t.includeBackgroundRectangles ?? !0, drawMode: t.drawMode ?? "fill", strokeWidth: t.strokeWidth ?? 1, backgroundColor: t.backgroundColor ?? [0, 0, 0, 0], filename: t.filename || this.Hn.Cn() };
2381
+ uo(t) {
2382
+ return { includeBackgroundRectangles: t.includeBackgroundRectangles ?? !0, drawMode: t.drawMode ?? "fill", strokeWidth: t.strokeWidth ?? 1, backgroundColor: t.backgroundColor ?? [0, 0, 0, 0], filename: t.filename || this.lo.In() };
2092
2383
  }
2093
- Nn(t, e = {}) {
2094
- const i = this.Vn.bn(this.Vn.dn(t.pipeline), t.grid), r = this.On.Bn(i, t.grid, t.font, this.Kn(e));
2095
- return this.On.Dn(r);
2384
+ fo(t, e = {}) {
2385
+ const i = this.ho.Hn(this.ho.Tn(t.pipeline), t.grid), s = this.co.io(i, t.grid, t.font, this.uo(e));
2386
+ return this.co.ro(s);
2096
2387
  }
2097
- Un(t, e = {}) {
2098
- this.Hn.Un(this.Nn(t, e), e.filename);
2388
+ ao(t, e = {}) {
2389
+ this.lo.ao(this.fo(t, e), e.filename);
2099
2390
  }
2100
2391
  }
2101
- class $t extends $ {
2102
- Xn(t, e, i, r = " ") {
2392
+ class Qt extends J {
2393
+ do(t, e, i, s = " ") {
2103
2394
  var o;
2104
- const s = [];
2395
+ const r = [];
2105
2396
  let n = 0;
2106
- for (let h = 0; h < e.rows; h++) {
2397
+ for (let c = 0; c < e.rows; c++) {
2107
2398
  const l = [];
2108
- for (let u = 0; u < e.cols; u++) {
2109
- const f = 4 * n, d = this._n(t.characterPixels, f), p = ((o = i.characters[d]) == null ? void 0 : o.character) || r;
2110
- l.push(p), n++;
2399
+ for (let f = 0; f < e.cols; f++) {
2400
+ const u = 4 * n, g = this.En(t.characterPixels, u), v = ((o = i.characters[g]) == null ? void 0 : o.character) || s;
2401
+ l.push(v), n++;
2111
2402
  }
2112
- s.push(l);
2403
+ r.push(l);
2113
2404
  }
2114
- return s;
2405
+ return r;
2115
2406
  }
2116
2407
  }
2117
- class Ot {
2118
- jn(t, e) {
2408
+ class te {
2409
+ _o(t, e) {
2119
2410
  const i = [];
2120
- for (const s of t) {
2121
- let n = s.join("");
2411
+ for (const r of t) {
2412
+ let n = r.join("");
2122
2413
  e.preserveTrailingSpaces || (n = n.replace(/\s+$/, "")), i.push(n);
2123
2414
  }
2124
- const r = e.lineEnding === "crlf" ? `\r
2415
+ const s = e.lineEnding === "crlf" ? `\r
2125
2416
  ` : `
2126
2417
  `;
2127
- return i.join(r);
2418
+ return i.join(s);
2128
2419
  }
2129
2420
  }
2130
- class Gt extends O {
2131
- Yn(t, e) {
2132
- const i = this.qn(e);
2133
- this.mn(t, i, "text/plain;charset=utf-8");
2421
+ class ee extends Z {
2422
+ po(t, e) {
2423
+ const i = this.mo(e);
2424
+ this.Pn(t, i, "text/plain;charset=utf-8");
2134
2425
  }
2135
- qn(t) {
2136
- let e = this.$n(t);
2137
- return e === ".txt" || e.length <= 4 ? this.Cn() : e;
2426
+ mo(t) {
2427
+ let e = this.Dn(t);
2428
+ return e === ".txt" || e.length <= 4 ? this.In() : e;
2138
2429
  }
2139
2430
  }
2140
- class H {
2431
+ class rt {
2141
2432
  constructor() {
2142
- c(this, "Vn");
2143
- c(this, "On");
2144
- c(this, "Hn");
2145
- this.Vn = new $t(), this.On = new Ot(), this.Hn = new Gt();
2433
+ a(this, "ho");
2434
+ a(this, "co");
2435
+ a(this, "lo");
2436
+ this.ho = new Qt(), this.co = new te(), this.lo = new ee();
2146
2437
  }
2147
- Kn(t) {
2148
- return { preserveTrailingSpaces: t.preserveTrailingSpaces ?? !1, lineEnding: t.lineEnding ?? "lf", emptyCharacter: t.emptyCharacter ?? " ", filename: t.filename || this.Hn.Cn() };
2438
+ uo(t) {
2439
+ return { preserveTrailingSpaces: t.preserveTrailingSpaces ?? !1, lineEnding: t.lineEnding ?? "lf", emptyCharacter: t.emptyCharacter ?? " ", filename: t.filename || this.lo.In() };
2149
2440
  }
2150
- Zn(t, e = {}) {
2151
- const i = this.Kn(e), r = this.Vn.Xn(this.Vn.dn(t.pipeline), t.grid, t.font, i.emptyCharacter);
2152
- return this.On.jn(r, i);
2441
+ vo(t, e = {}) {
2442
+ const i = this.uo(e), s = this.ho.do(this.ho.Tn(t.pipeline), t.grid, t.font, i.emptyCharacter);
2443
+ return this.co._o(s, i);
2153
2444
  }
2154
- Yn(t, e = {}) {
2155
- this.Hn.Yn(this.Zn(t, e), e.filename);
2445
+ po(t, e = {}) {
2446
+ this.lo.po(this.vo(t, e), e.filename);
2156
2447
  }
2157
2448
  }
2158
- class Yt extends $ {
2159
- Jn(t, e = 1, i = "transparent") {
2160
- const r = t.canvas;
2161
- if (e === 1 && i === "transparent") return r;
2162
- const s = document.createElement("canvas"), n = s.getContext("2d"), o = Math.round(r.width * e), h = Math.round(r.height * e);
2163
- return s.width = o, s.height = h, i !== "transparent" && (n.fillStyle = i, n.fillRect(0, 0, o, h)), n.imageSmoothingEnabled = !1, n.drawImage(r, 0, 0, r.width, r.height, 0, 0, o, h), s;
2449
+ class ie extends J {
2450
+ yo(t, e = 1, i = "transparent") {
2451
+ const s = t.canvas;
2452
+ if (e === 1 && i === "transparent") return s;
2453
+ const r = document.createElement("canvas"), n = r.getContext("2d"), o = Math.round(s.width * e), c = Math.round(s.height * e);
2454
+ return r.width = o, r.height = c, i !== "transparent" && (n.fillStyle = i, n.fillRect(0, 0, o, c)), n.imageSmoothingEnabled = !1, n.drawImage(s, 0, 0, s.width, s.height, 0, 0, o, c), r;
2164
2455
  }
2165
2456
  }
2166
- class Nt {
2167
- Qn(t, e) {
2168
- const i = this.eo(e.format);
2457
+ class se {
2458
+ Co(t, e) {
2459
+ const i = this.wo(e.format);
2169
2460
  return e.format === "png" ? t.toDataURL(i) : t.toDataURL(i, e.quality);
2170
2461
  }
2171
- async so(t, e) {
2172
- return new Promise((i, r) => {
2173
- const s = this.eo(e.format), n = (o) => {
2174
- o ? i(o) : r(Error(`Failed to generate ${e.format.toUpperCase()} blob`));
2462
+ async $o(t, e) {
2463
+ return new Promise((i, s) => {
2464
+ const r = this.wo(e.format), n = (o) => {
2465
+ o ? i(o) : s(Error(`Failed to generate ${e.format.toUpperCase()} blob`));
2175
2466
  };
2176
- e.format === "png" ? t.toBlob(n, s) : t.toBlob(n, s, e.quality);
2467
+ e.format === "png" ? t.toBlob(n, r) : t.toBlob(n, r, e.quality);
2177
2468
  });
2178
2469
  }
2179
- eo(t) {
2470
+ wo(t) {
2180
2471
  switch (t) {
2181
2472
  case "png":
2182
2473
  return "image/png";
@@ -2189,270 +2480,279 @@ class Nt {
2189
2480
  }
2190
2481
  }
2191
2482
  }
2192
- const Vt = { png: "image/png", jpg: "image/jpeg", webp: "image/webp" }, K = { png: ".png", jpg: ".jpg", webp: ".webp" };
2193
- class Xt extends O {
2194
- io(t, e, i) {
2195
- this.ro(t, this.$n(e) + K[i]);
2483
+ const re = { png: "image/png", jpg: "image/jpeg", webp: "image/webp" }, nt = { png: ".png", jpg: ".jpg", webp: ".webp" };
2484
+ class ne extends Z {
2485
+ bo(t, e, i) {
2486
+ this.xo(t, this.Dn(e) + nt[i]);
2196
2487
  }
2197
- ro(t, e) {
2488
+ xo(t, e) {
2198
2489
  const i = URL.createObjectURL(t);
2199
2490
  try {
2200
- const r = document.createElement("a");
2201
- r.href = i, r.download = e, r.style.display = "none", r.rel = "noopener", document.body.appendChild(r), r.click(), document.body.removeChild(r);
2491
+ const s = document.createElement("a");
2492
+ s.href = i, s.download = e, s.style.display = "none", s.rel = "noopener", document.body.appendChild(s), s.click(), document.body.removeChild(s);
2202
2493
  } finally {
2203
2494
  URL.revokeObjectURL(i);
2204
2495
  }
2205
2496
  }
2206
- no(t) {
2207
- return t in Vt && t in K;
2497
+ Fo(t) {
2498
+ return t in re && t in nt;
2208
2499
  }
2209
2500
  }
2210
- class Ht {
2501
+ class oe {
2211
2502
  constructor() {
2212
- c(this, "Vn");
2213
- c(this, "On");
2214
- c(this, "Hn");
2215
- this.Vn = new Yt(), this.On = new Nt(), this.Hn = new Xt();
2503
+ a(this, "ho");
2504
+ a(this, "co");
2505
+ a(this, "lo");
2506
+ this.ho = new ie(), this.co = new se(), this.lo = new ne();
2216
2507
  }
2217
- Kn(t) {
2218
- return { format: t.format ?? "png", quality: t.quality ?? 1, scale: t.scale ?? 1, backgroundColor: t.backgroundColor ?? "transparent", filename: t.filename || this.Hn.Cn() };
2508
+ uo(t) {
2509
+ return { format: t.format ?? "png", quality: t.quality ?? 1, scale: t.scale ?? 1, backgroundColor: t.backgroundColor ?? "transparent", filename: t.filename || this.lo.In() };
2219
2510
  }
2220
- oo(t) {
2221
- if (!this.Hn.no(t.format)) throw Error(`Saving '${t.format}' files is not supported`);
2511
+ Mo(t) {
2512
+ if (!this.lo.Fo(t.format)) throw Error(`Saving '${t.format}' files is not supported`);
2222
2513
  if (t.quality < 0 || t.quality > 1) throw Error("Image quality must be between 0.0 and 1.0");
2223
2514
  if (t.scale <= 0) throw Error("Scale factor must be greater than 0");
2224
2515
  t.format === "jpg" && t.backgroundColor === "transparent" && (t.backgroundColor = "black");
2225
2516
  }
2226
- async so(t, e) {
2227
- if (e.scale === 1 && e.backgroundColor === "transparent") return await this.On.so(t.canvas, e);
2228
- const i = this.Vn.Jn(t, e.scale, e.backgroundColor);
2229
- return await this.On.so(i, e);
2517
+ async $o(t, e) {
2518
+ if (e.scale === 1 && e.backgroundColor === "transparent") return await this.co.$o(t.canvas, e);
2519
+ const i = this.ho.yo(t, e.scale, e.backgroundColor);
2520
+ return await this.co.$o(i, e);
2230
2521
  }
2231
- async io(t, e = {}) {
2232
- const i = this.Kn(e);
2233
- this.oo(i);
2234
- const r = await this.so(t, i);
2235
- this.Hn.io(r, i.filename, i.format);
2522
+ async bo(t, e = {}) {
2523
+ const i = this.uo(e);
2524
+ this.Mo(i);
2525
+ const s = await this.$o(t, i);
2526
+ this.lo.bo(s, i.filename, i.format);
2236
2527
  }
2237
2528
  }
2238
- const Kt = (a) => class extends a {
2239
- ao() {
2240
- this.kt.Dt(this.ho);
2529
+ const he = (h) => class extends h {
2530
+ Ro() {
2531
+ this.xt.Et(this.So);
2241
2532
  }
2242
2533
  toString(t = {}) {
2243
- return this.ao(), new H().Zn({ pipeline: this.co, grid: this.Wr, font: this.Fi }, t);
2534
+ return this.Ro(), new rt().vo({ pipeline: this.Ao, grid: this.rn, font: this.Ei }, t);
2244
2535
  }
2245
2536
  saveStrings(t = {}) {
2246
- this.ao(), new H().Yn({ pipeline: this.co, grid: this.Wr, font: this.Fi }, t);
2537
+ this.Ro(), new rt().po({ pipeline: this.Ao, grid: this.rn, font: this.Ei }, t);
2247
2538
  }
2248
2539
  toSVG(t = {}) {
2249
- return this.ao(), new X().Nn({ pipeline: this.co, grid: this.Wr, font: this.Fi }, t);
2540
+ return this.Ro(), new st().fo({ pipeline: this.Ao, grid: this.rn, font: this.Ei }, t);
2250
2541
  }
2251
2542
  saveSVG(t = {}) {
2252
- this.ao(), new X().Un({ pipeline: this.co, grid: this.Wr, font: this.Fi }, t);
2543
+ this.Ro(), new st().ao({ pipeline: this.Ao, grid: this.rn, font: this.Ei }, t);
2253
2544
  }
2254
2545
  async saveCanvas(t = {}) {
2255
- await new Ht().io(this.Yi, t);
2546
+ await new oe().bo(this.tr, t);
2256
2547
  }
2257
- }, Zt = (a) => class extends a {
2548
+ }, ae = (h) => class extends h {
2258
2549
  async loadFont(t) {
2259
- return this.Fi.Hi(t).then(() => {
2260
- const e = this.Fi.maxGlyphDimensions;
2261
- this.Wr.Ji(e.width, e.height), this.co.resize(this.Wr.cols, this.Wr.rows), this.kt.Hs(), this.lo.tn();
2550
+ return this.Ei.Yi(t).then(() => {
2551
+ const e = this.Ei.maxGlyphDimensions;
2552
+ this.rn.rr(e.width, e.height), this.Ao.resize(this.rn.cols, this.rn.rows), this.xt.Zs(), this.zo.Cn();
2262
2553
  });
2263
2554
  }
2264
2555
  fontSize(t) {
2265
- if (!M.M(typeof t == "number" && t > 0, "Font size must be a positive number greater than 0.", { method: "fontSize", providedValue: t }) || this.Fi.fontSize === t) return;
2266
- this.Fi.Oi(t);
2267
- const e = this.Fi.maxGlyphDimensions;
2268
- this.Wr.Ji(e.width, e.height), this.co.resize(this.Wr.cols, this.Wr.rows), this.kt.Hs(), this.lo.tn();
2556
+ if (!$.v(typeof t == "number" && t > 0, "Font size must be a positive number greater than 0.", { method: "fontSize", providedValue: t }) || this.Ei.fontSize === t) return;
2557
+ this.Ei.ji(t);
2558
+ const e = this.Ei.maxGlyphDimensions;
2559
+ this.rn.rr(e.width, e.height), this.Ao.resize(this.rn.cols, this.rn.rows), this.xt.Zs(), this.zo.Cn();
2269
2560
  }
2270
2561
  glyphColor(t) {
2271
- return this.Fi.Mi(t);
2562
+ return this.Ei.zi(t);
2272
2563
  }
2273
2564
  glyphColors(t) {
2274
- return this.Fi.Si(t);
2565
+ return this.Ei.Ti(t);
2275
2566
  }
2276
- }, jt = (a) => class extends a {
2567
+ }, ce = (h) => class extends h {
2277
2568
  get frameCount() {
2278
- return this.uo.frameCount;
2569
+ return this.To.frameCount;
2279
2570
  }
2280
2571
  set frameCount(t) {
2281
- this.uo.frameCount = t;
2572
+ this.To.frameCount = t;
2282
2573
  }
2283
2574
  frameRate(t) {
2284
- return t === void 0 ? this.uo.currentFrameRate : this.uo.frameRate(t, () => this.fo());
2575
+ return t === void 0 ? this.To.currentFrameRate : this.To.frameRate(t, () => this.Eo());
2285
2576
  }
2286
2577
  noLoop() {
2287
- this.uo.pause();
2578
+ this.To.pause();
2288
2579
  }
2289
2580
  loop() {
2290
- this.uo.resume(() => this.fo());
2581
+ this.To.resume(() => this.Eo());
2291
2582
  }
2292
2583
  redraw(t = 1) {
2293
- if (M.M(typeof t == "number" && t > 0 && Number.isInteger(t), "Redraw count must be a positive integer.", { method: "redraw", providedValue: t })) for (let e = 0; e < t; e++) this.fo();
2584
+ if ($.v(typeof t == "number" && t > 0 && Number.isInteger(t), "Redraw count must be a positive integer.", { method: "redraw", providedValue: t })) for (let e = 0; e < t; e++) this.Eo();
2294
2585
  }
2295
2586
  isLooping() {
2296
- return this.uo.isLooping;
2587
+ return this.To.isLooping;
2297
2588
  }
2298
- }, qt = (a) => class extends a {
2589
+ }, le = (h) => class extends h {
2299
2590
  constructor(...t) {
2300
2591
  super(...t);
2301
2592
  }
2302
2593
  mouseClicked(t) {
2303
- this.lo.cn(t);
2594
+ this.zo.Rn(t);
2304
2595
  }
2305
2596
  mousePressed(t) {
2306
- this.lo.kr(t);
2597
+ this.zo.jr(t);
2307
2598
  }
2308
2599
  mouseReleased(t) {
2309
- this.lo.Pr(t);
2600
+ this.zo.Yr(t);
2310
2601
  }
2311
2602
  mouseMoved(t) {
2312
- this.lo.ln(t);
2603
+ this.zo.Sn(t);
2313
2604
  }
2314
2605
  mouseScrolled(t) {
2315
- this.lo.un(t);
2606
+ this.zo.An(t);
2316
2607
  }
2317
2608
  get mouse() {
2318
- return this.lo.fn();
2609
+ return this.zo.zn();
2319
2610
  }
2320
- }, Jt = (a) => class extends a {
2611
+ }, ue = (h) => class extends h {
2321
2612
  constructor(...t) {
2322
2613
  super(...t);
2323
2614
  }
2324
2615
  keyPressed(t) {
2325
- this.do.kr(t);
2616
+ this.Lo.jr(t);
2326
2617
  }
2327
2618
  keyReleased(t) {
2328
- this.do.Pr(t);
2619
+ this.Lo.Yr(t);
2329
2620
  }
2330
2621
  isKeyPressed(t) {
2331
- return this.do.Tr(t);
2622
+ return this.Lo.qr(t);
2332
2623
  }
2333
2624
  get lastKeyPressed() {
2334
- return this.do.Gr();
2625
+ return this.Lo.Jr();
2335
2626
  }
2336
2627
  get lastKeyReleased() {
2337
- return this.do.Lr();
2628
+ return this.Lo.Qr();
2338
2629
  }
2339
2630
  get pressedKeys() {
2340
- return this.do.Er();
2631
+ return this.Lo.tn();
2341
2632
  }
2342
2633
  get modifierState() {
2343
- return this.do.Br();
2634
+ return this.Lo.en();
2344
2635
  }
2345
2636
  };
2346
- class Qt {
2637
+ class fe {
2347
2638
  constructor() {
2348
- c(this, "kt");
2349
- c(this, "Fi");
2350
- c(this, "Yi");
2351
- c(this, "Wr");
2352
- c(this, "uo");
2353
- c(this, "lo");
2354
- c(this, "do");
2355
- c(this, "ho");
2356
- c(this, "co");
2357
- c(this, "_o");
2358
- }
2359
- fo() {
2639
+ a(this, "xt");
2640
+ a(this, "Ei");
2641
+ a(this, "tr");
2642
+ a(this, "rn");
2643
+ a(this, "To");
2644
+ a(this, "zo");
2645
+ a(this, "Lo");
2646
+ a(this, "So");
2647
+ a(this, "Ao");
2648
+ a(this, "ko");
2649
+ a(this, "Po");
2650
+ a(this, "Go");
2651
+ }
2652
+ Eo() {
2360
2653
  }
2361
2654
  }
2362
- class te extends function(e, ...i) {
2363
- return i.reduce((r, s) => s(r), e);
2364
- }(Qt, kt, Kt, Zt, jt, qt, Jt) {
2655
+ class de extends function(e, ...i) {
2656
+ return i.reduce((s, r) => r(s), e);
2657
+ }(fe, jt, he, ae, ce, le, ue) {
2365
2658
  constructor(e = {}) {
2366
2659
  super();
2367
- c(this, "po", !1);
2368
- c(this, "mo", () => {
2660
+ a(this, "Bo", !1);
2661
+ a(this, "Do", () => {
2369
2662
  });
2370
- c(this, "vo", () => {
2663
+ a(this, "Io", () => {
2371
2664
  });
2372
- c(this, "yo", () => {
2665
+ a(this, "Wo", () => {
2373
2666
  });
2374
- c(this, "$o");
2375
- this.Yi = new Pt(e), this.kt = new vt(this.Yi.ir()), this.Fi = new St(this.kt, e.fontSize ?? 16), this.uo = new Mt(e.frameRate ?? 60), this.lo = new It(this.Yi), this.do = new Ut(), this.ho = this.kt.Bt(), this._o = this.kt.ae(), this.Co(e);
2376
- }
2377
- async Co(e) {
2378
- await this.Fi.Ii(e.fontSource);
2379
- const i = this.Fi.maxGlyphDimensions;
2380
- this.Wr = new Lt(this.Yi.canvas, i.width, i.height), this.lo.Ii(this.Wr), this.co = this.kt.Us(this.Wr.cols, this.Wr.rows, 5), this.wo(), this.mo(), this.uo.start(() => this.fo());
2381
- }
2382
- wo() {
2383
- this.$o = () => {
2384
- this.yo();
2385
- }, window.addEventListener("resize", this.$o), this.lo.Mr(), this.do.Mr(), window.addEventListener("blur", () => {
2386
- this.do.Dr();
2667
+ a(this, "Oo");
2668
+ a(this, "ar", !1);
2669
+ a(this, "Ho");
2670
+ this.ar = e.overlay ?? !1, this.tr = new Xt(e), this.xt = new Ft(this.tr.mr()), this.Ei = new Nt(this.xt, e.fontSize ?? 16), this.To = new Ht(e.frameRate ?? 60), this.zo = new Vt(this.tr), this.Lo = new Yt(), this.So = this.xt.Tt(), this.ko = this.xt.re(), this.Vo(e);
2671
+ }
2672
+ async Vo(e) {
2673
+ await this.Ei.Ki(e.fontSource);
2674
+ const i = this.Ei.maxGlyphDimensions;
2675
+ this.rn = new Wt(this.tr.canvas, i.width, i.height), this.zo.Ki(this.rn), this.Ao = this.xt.js(this.rn.cols, this.rn.rows, 5), this.Po = this.xt.js(this.rn.width, this.rn.height, 1), this.ar && (this.Ho = z.fromSource(this.xt, this.tr.targetCanvas, (s) => this.Ei.Ti(s))), this.Go = this.xt.ae(at, "precision mediump float;uniform sampler2D Ua;uniform vec2 Ub;uniform vec2 Uc;uniform vec2 Ud;void main(){vec2 A=gl_FragCoord.xy-Uc;vec2 B=A*(Ub/Ud);vec2 C=(floor(B)+0.5)/Ub;gl_FragColor=texture2D(Ua,C);}"), this.Ko(), this.Do(), this.To.start(() => this.Eo());
2676
+ }
2677
+ Ko() {
2678
+ this.Oo = () => {
2679
+ this.ar && this.resizeCanvas(this.tr.width, this.tr.height), this.Wo();
2680
+ }, window.addEventListener("resize", this.Oo), this.zo.Vr(), this.Lo.Vr(), window.addEventListener("blur", () => {
2681
+ this.Lo.sn();
2387
2682
  });
2388
2683
  }
2389
- fo() {
2390
- if (this.uo.measureFrameRate(), this.uo.incrementFrame(), this.po) return;
2391
- this.co.begin(), this.kt.ks(this.ho), this.vo(), this.kt.Dt(this.ho), this.co.end();
2392
- const e = this.kt.state.canvasBackgroundColor;
2393
- this.kt.He(e[0], e[1], e[2], e[3]), this.kt.ks(this._o), this._o.Zt({ a: this.Fi.fontFramebuffer, b: [this.Fi.textureColumns, this.Fi.textureRows], c: this.co.textures[0], d: this.co.textures[1], e: this.co.textures[2], f: this.co.textures[4], g: this.co.textures[3], h: [this.Wr.cols, this.Wr.rows], i: [this.Wr.width, this.Wr.height], j: [this.Wr.offsetX, this.Wr.offsetY], k: this.Wr.width / this.Wr.height }), this.kt.Ls(this.Wr.offsetX, this.Wr.offsetY, this.Wr.width, this.Wr.height);
2684
+ Eo() {
2685
+ if (this.To.measureFrameRate(), this.To.incrementFrame(), this.Bo) return;
2686
+ if (this.ar) {
2687
+ const i = this.xt.context;
2688
+ i.bindTexture(i.TEXTURE_2D, this.Ho.texture), i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, 1), i.texImage2D(i.TEXTURE_2D, 0, i.RGBA, i.RGBA, i.UNSIGNED_BYTE, this.tr.targetCanvas), i.bindTexture(i.TEXTURE_2D, null), this.Ao.begin(), this.xt.Ws(this.Ho, 0, 0, this.rn.cols, this.rn.rows), this.xt.Gs(this.So), this.Io(), this.xt.Et(this.So), this.Ao.end();
2689
+ } else this.Ao.begin(), this.xt.Gs(this.So), this.Io(), this.xt.Et(this.So), this.Ao.end();
2690
+ this.Po.begin(), this.xt.Gs(this.ko), this.ko.Nt({ U0: this.Ei.fontFramebuffer, U1: [this.Ei.textureColumns, this.Ei.textureRows], U2: this.Ao.textures[0], U3: this.Ao.textures[1], U4: this.Ao.textures[2], U5: this.Ao.textures[4], U6: this.Ao.textures[3], U7: [this.rn.cols, this.rn.rows], U8: [this.Po.width, this.Po.height], U9: this.Po.width / this.Po.height }), this.xt.Os(0, 0, this.tr.width, this.tr.height), this.Po.end();
2691
+ const e = this.xt.state.canvasBackgroundColor;
2692
+ this.xt.He(e[0], e[1], e[2], e[3]), this.xt.Gs(this.Go), this.Go.Nt({ Ua: this.Po.textures[0], Ub: [this.Po.width, this.Po.height], Uc: [this.rn.offsetX, this.rn.offsetY], Ud: [this.rn.width, this.rn.height] }), this.xt.Os(this.rn.offsetX, this.rn.offsetY, this.rn.width, this.rn.height);
2394
2693
  }
2395
2694
  setup(e) {
2396
- this.mo = e;
2695
+ this.Do = e;
2397
2696
  }
2398
2697
  draw(e) {
2399
- this.vo = e;
2698
+ this.Io = e;
2400
2699
  }
2401
2700
  windowResized(e) {
2402
- this.yo = e;
2701
+ this.Wo = e;
2403
2702
  }
2404
2703
  resizeCanvas(e, i) {
2405
- this.Yi.sr(e, i), this.Wr.rt(), this.co.resize(this.Wr.cols, this.Wr.rows), this.kt.Hs(), this.lo.tn(), this.fo();
2704
+ this.tr.pr(e, i), this.rn.ir(), this.Ao.resize(this.rn.cols, this.rn.rows), this.Po.resize(this.rn.width, this.rn.height), this.xt.Zs(), this.zo.Cn(), this.Eo();
2406
2705
  }
2407
2706
  destroy() {
2408
- this.po || (this.uo.stop(), window.removeEventListener("resize", this.$o), this.lo.zr(), this.do.zr(), this.Fi.Ut(), this.kt.Ut(), this.po = !0);
2707
+ this.Bo || (this.To.stop(), window.removeEventListener("resize", this.Oo), this.zo.Xr(), this.Lo.Xr(), this.Ei.Pt(), this.xt.Pt(), this.Po.Pt(), this.Go.Pt(), this.Ho && this.Ho.Pt(), this.Bo = !0);
2409
2708
  }
2410
2709
  get grid() {
2411
- return this.Wr;
2710
+ return this.rn;
2412
2711
  }
2413
2712
  get font() {
2414
- return this.Fi;
2713
+ return this.Ei;
2415
2714
  }
2416
2715
  get width() {
2417
- return this.Yi.width;
2716
+ return this.tr.width;
2418
2717
  }
2419
2718
  get height() {
2420
- return this.Yi.height;
2719
+ return this.tr.height;
2421
2720
  }
2422
2721
  get canvas() {
2423
- return this.Yi.canvas;
2722
+ return this.tr.canvas;
2424
2723
  }
2425
2724
  get isDisposed() {
2426
- return this.po;
2725
+ return this.Bo;
2427
2726
  }
2428
- get drawFramebuffer() {
2429
- return this.co;
2727
+ get overlay() {
2728
+ return this.Ho;
2430
2729
  }
2431
2730
  }
2432
- class G {
2731
+ class Q {
2433
2732
  constructor() {
2434
2733
  }
2435
2734
  static create(t = {}) {
2436
- return new te(t);
2735
+ return new de(t);
2437
2736
  }
2438
2737
  static setErrorLevel(t) {
2439
- M.S(t);
2738
+ $.C(t);
2440
2739
  }
2441
2740
  static get version() {
2442
- return "0.2.1-beta.4";
2741
+ return "0.2.1-beta.5";
2443
2742
  }
2444
2743
  }
2445
- const ie = Object.freeze(Object.defineProperty({ __proto__: null }, Symbol.toStringTag, { value: "Module" })), re = G.create, se = G.setErrorLevel, ne = G.version;
2744
+ const pe = Object.freeze(Object.defineProperty({ __proto__: null }, Symbol.toStringTag, { value: "Module" })), me = Q.create, ve = Q.setErrorLevel, xe = Q.version;
2446
2745
  export {
2447
- Pt as TextmodeCanvas,
2448
- et as TextmodeErrorLevel,
2449
- St as TextmodeFont,
2450
- D as TextmodeFramebuffer,
2451
- Lt as TextmodeGrid,
2452
- te as Textmodifier,
2453
- re as create,
2454
- ie as export,
2455
- se as setErrorLevel,
2456
- G as textmode,
2457
- ne as version
2746
+ Xt as TextmodeCanvas,
2747
+ ut as TextmodeErrorLevel,
2748
+ Nt as TextmodeFont,
2749
+ K as TextmodeFramebuffer,
2750
+ Wt as TextmodeGrid,
2751
+ z as TextmodeImage,
2752
+ de as Textmodifier,
2753
+ me as create,
2754
+ pe as export,
2755
+ ve as setErrorLevel,
2756
+ Q as textmode,
2757
+ xe as version
2458
2758
  };