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

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