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

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
- var J = Object.defineProperty;
2
- var tt = (a, t, e) => t in a ? J(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e;
1
+ var Q = Object.defineProperty;
2
+ var tt = (a, t, e) => t in a ? Q(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e;
3
3
  var h = (a, t, e) => tt(a, typeof t != "symbol" ? t + "" : t, e);
4
- class E extends Error {
4
+ class v extends Error {
5
5
  constructor(t, e = {}) {
6
- super(E.u(t, e)), this.name = "TextmodeError";
6
+ super(v.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
11
  📋 Context:` + Object.entries(e).map(([i, s]) => `
12
- - ${i}: ${E._(s)}`).join("") : ""}
12
+ - ${i}: ${v._(s)}`).join("") : ""}
13
13
 
14
14
  ${"↓".repeat(24)}
15
15
  `;
@@ -19,10 +19,10 @@ ${"↓".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) => E._(e)).join(", ")}]` : `[${t.slice(0, 3).map((e) => E._(e)).join(", ")}, ... +${t.length - 3} more]`;
22
+ if (Array.isArray(t)) return t.length === 0 ? "[]" : t.length <= 5 ? `[${t.map((e) => v._(e)).join(", ")}]` : `[${t.slice(0, 3).map((e) => v._(e)).join(", ")}, ... +${t.length - 3} more]`;
23
23
  if (typeof t == "object") {
24
24
  const e = Object.keys(t);
25
- return e.length === 0 ? "{}" : e.length <= 3 ? `{ ${e.map((i) => `${i}: ${E._(t[i])}`).join(", ")} }` : `{ ${e.slice(0, 2).map((i) => `${i}: ${E._(t[i])}`).join(", ")}, ... +${e.length - 2} more }`;
25
+ return e.length === 0 ? "{}" : e.length <= 3 ? `{ ${e.map((i) => `${i}: ${v._(t[i])}`).join(", ")} }` : `{ ${e.slice(0, 2).map((i) => `${i}: ${v._(t[i])}`).join(", ")}, ... +${e.length - 2} more }`;
26
26
  }
27
27
  return t + "";
28
28
  }
@@ -41,11 +41,11 @@ const _ = class _ {
41
41
  case 0:
42
42
  return !1;
43
43
  case 1:
44
- return console.group(i, s), console.warn(E.u(t, e)), console.groupEnd(), !1;
44
+ return console.group(i, s), console.warn(v.u(t, e)), console.groupEnd(), !1;
45
45
  case 2:
46
- return console.group(i, s), console.error(E.u(t, e)), console.groupEnd(), !1;
46
+ return console.group(i, s), console.error(v.u(t, e)), console.groupEnd(), !1;
47
47
  default:
48
- throw new E(t, e);
48
+ throw new v(t, e);
49
49
  }
50
50
  }
51
51
  M(t, e, i) {
@@ -57,7 +57,7 @@ const _ = class _ {
57
57
  };
58
58
  h(_, "v", null);
59
59
  let z = _;
60
- const M = z.$(), K = /* @__PURE__ */ new WeakMap();
60
+ const L = z.$(), K = /* @__PURE__ */ new WeakMap();
61
61
  function U(a, t) {
62
62
  K.set(a, t);
63
63
  }
@@ -76,28 +76,28 @@ class Z {
76
76
  h(this, "I", !1);
77
77
  h(this, "U", !1);
78
78
  h(this, "O", !1);
79
- h(this, "H", [0, 0]);
80
- h(this, "V", [0, 0, 0, 1]);
79
+ h(this, "V", [0, 0]);
80
+ h(this, "H", [0, 0, 0, 1]);
81
81
  h(this, "K", []);
82
82
  }
83
83
  N() {
84
- this.K.push({ X: this.F, Y: this.P, Z: this.G, J: this.A, H: [...this.H], 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.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] });
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.H = t.H, 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.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()");
89
89
  }
90
90
  rt() {
91
91
  this.K = [], this.P = 0, this.G = 0, this.A = 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.H[0], t.charRotation[1] = this.H[1];
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];
95
95
  }
96
96
  get lineWeight() {
97
97
  return this.F;
98
98
  }
99
99
  get canvasBackgroundColor() {
100
- return this.V;
100
+ return this.H;
101
101
  }
102
102
  ot(t) {
103
103
  this.F = Math.abs(t);
@@ -131,10 +131,10 @@ class Z {
131
131
  }
132
132
  yt(t) {
133
133
  const e = 255 * t / 360, i = Math.floor(e) / 255, s = Math.round(e - Math.floor(e));
134
- this.H = [i, s];
134
+ this.V = [i, s];
135
135
  }
136
136
  Ct(t, e, i, s) {
137
- this.V = [t / 255, e / 255, i / 255, s / 255];
137
+ this.H = [t / 255, e / 255, i / 255, s / 255];
138
138
  }
139
139
  }
140
140
  class G {
@@ -142,8 +142,8 @@ class G {
142
142
  h(this, "$t");
143
143
  h(this, "wt");
144
144
  h(this, "C");
145
- h(this, "bt", null);
146
- h(this, "xt");
145
+ h(this, "xt", null);
146
+ h(this, "bt");
147
147
  h(this, "Rt");
148
148
  h(this, "Mt", []);
149
149
  h(this, "St");
@@ -151,21 +151,21 @@ class G {
151
151
  h(this, "zt", []);
152
152
  h(this, "Pt", null);
153
153
  h(this, "kt", !1);
154
- h(this, "Gt", null);
155
- this.$t = e, this.wt = i, this.C = { filter: "nearest", wrap: "clamp", format: "rgba", type: "unsigned_byte", ...r }, this.xt = t, this.St = Math.min(Math.max(1, s), 8), this.Pt = n, this.kt = !!o, this.Gt = this.kt ? new Z() : null;
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
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.At(), this.Tt(), this.zt = Array(this.St).fill(null);
157
+ this.St = Math.min(this.St, c, l), this.Rt = t.createFramebuffer(), this.Gt(), this.At(), this.zt = Array(this.St).fill(null);
158
158
  }
159
- At() {
160
- const t = this.xt, 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;
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
161
  for (let r = 0; r < this.St; r++) {
162
162
  const n = t.createTexture();
163
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);
164
164
  }
165
165
  t.bindTexture(t.TEXTURE_2D, null);
166
166
  }
167
- Tt() {
168
- const t = this.xt;
167
+ At() {
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 = [];
@@ -178,18 +178,18 @@ class G {
178
178
  const e = t.checkFramebufferStatus(t.FRAMEBUFFER);
179
179
  e !== t.FRAMEBUFFER_COMPLETE && console.error("GLFramebuffer is not complete:", e), t.bindFramebuffer(t.FRAMEBUFFER, null);
180
180
  }
181
- Et(t) {
182
- const e = this.xt;
181
+ Lt(t) {
182
+ const e = this.bt;
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.bt = null, this.zt = Array(this.St).fill(null);
187
- const i = this.xt, s = this.C.type === "float" ? i.FLOAT : i.UNSIGNED_BYTE;
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
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);
189
189
  i.bindTexture(i.TEXTURE_2D, null);
190
190
  }
191
- Lt(t) {
192
- const e = this.xt, i = this.zt[t];
191
+ Et(t) {
192
+ const e = this.bt, i = this.zt[t];
193
193
  if (i) return i;
194
194
  const s = this.$t, r = this.wt, n = new Uint8Array(s * r * 4), o = e.getParameter(e.READ_FRAMEBUFFER_BINDING);
195
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);
@@ -202,10 +202,10 @@ class G {
202
202
  }
203
203
  begin() {
204
204
  var e, i, s, r;
205
- const t = this.xt;
205
+ const t = this.bt;
206
206
  if (this.Pt) {
207
207
  const n = ((i = (e = this.Pt).Bt) == null ? void 0 : i.call(e)) ?? null;
208
- n && this.Pt.Dt(n), this.kt && this.Gt && ((r = (s = this.Pt).Wt) == null || r.call(s, this.Gt));
208
+ n && this.Pt.Dt(n), this.kt && this.Tt && ((r = (s = this.Pt).Wt) == null || r.call(s, 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]));
@@ -214,15 +214,15 @@ class G {
214
214
  end() {
215
215
  var e, i, s, r;
216
216
  if (!this.Ft) return;
217
- const t = this.xt;
217
+ const t = this.bt;
218
218
  if (this.Pt) {
219
219
  const n = ((i = (e = this.Pt).Bt) == null ? void 0 : i.call(e)) ?? null;
220
220
  n && this.Pt.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.Gt && ((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.Pt && this.kt && this.Tt && ((r = (s = this.Pt).It) == null || r.call(s));
223
223
  }
224
224
  Ut() {
225
- const t = this.xt;
225
+ const t = this.bt;
226
226
  t.deleteFramebuffer(this.Rt);
227
227
  for (const e of this.Mt) t.deleteTexture(e);
228
228
  }
@@ -232,119 +232,117 @@ class G {
232
232
  get height() {
233
233
  return this.wt;
234
234
  }
235
- get pixels() {
236
- return this.bt;
237
- }
238
- get options() {
239
- return { ...this.C };
240
- }
241
- get framebuffer() {
242
- return this.Rt;
243
- }
244
- get texture() {
245
- return this.Mt[0];
246
- }
247
235
  get textures() {
248
236
  return [...this.Mt];
249
237
  }
250
- get attachmentCount() {
251
- return this.St;
252
- }
253
238
  }
254
239
  function k(a) {
255
240
  return typeof a == "string" ? a : a.sourceCode;
256
241
  }
257
- class S {
242
+ class M {
258
243
  constructor(t, e, i) {
259
- h(this, "xt");
244
+ h(this, "bt");
260
245
  h(this, "Ot");
261
- h(this, "Ht", /* @__PURE__ */ new Map());
262
- h(this, "Vt", 0);
263
- this.xt = t, this.Ot = this.Kt(k(e), k(i)), this.Nt();
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();
264
249
  }
265
250
  Nt() {
266
- const t = this.xt.getProgramParameter(this.Ot, this.xt.ACTIVE_UNIFORMS);
251
+ const t = this.bt.getProgramParameter(this.Ot, this.bt.ACTIVE_UNIFORMS);
267
252
  for (let e = 0; e < t; e++) {
268
- const i = this.xt.getActiveUniform(this.Ot, e);
253
+ const i = this.bt.getActiveUniform(this.Ot, e);
269
254
  if (i) {
270
- const s = this.xt.getUniformLocation(this.Ot, i.name);
271
- s && this.Ht.set(i.name, s);
255
+ const s = this.bt.getUniformLocation(this.Ot, i.name);
256
+ s && this.Vt.set(i.name, s);
272
257
  }
273
258
  }
274
259
  }
275
260
  Kt(t, e) {
276
- const i = this.Xt(this.xt.VERTEX_SHADER, t), s = this.Xt(this.xt.FRAGMENT_SHADER, e), r = this.xt.createProgram();
277
- if (this.xt.attachShader(r, i), this.xt.attachShader(r, s), this.xt.linkProgram(r), !this.xt.getProgramParameter(r, this.xt.LINK_STATUS)) {
278
- const n = this.xt.getProgramInfoLog(r);
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);
279
264
  throw Error("Shader program link error: " + n);
280
265
  }
281
- return this.xt.deleteShader(i), this.xt.deleteShader(s), r;
266
+ return this.bt.deleteShader(i), this.bt.deleteShader(s), r;
282
267
  }
283
268
  Xt(t, e) {
284
- const i = this.xt.createShader(t);
285
- if (this.xt.shaderSource(i, e), this.xt.compileShader(i), !this.xt.getShaderParameter(i, this.xt.COMPILE_STATUS)) {
286
- const s = this.xt.getShaderInfoLog(i);
287
- throw this.xt.deleteShader(i), Error("Shader compilation error: " + s);
269
+ const i = this.bt.createShader(t);
270
+ 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);
288
273
  }
289
274
  return i;
290
275
  }
291
276
  jt() {
292
- this.xt.useProgram(this.Ot), this.Yt();
277
+ this.bt.useProgram(this.Ot), this.Yt();
293
278
  }
294
279
  Yt() {
295
- this.Vt = 0;
280
+ this.Ht = 0;
296
281
  }
297
282
  qt(t) {
298
283
  for (const [e, i] of Object.entries(t)) this.Zt(e, i);
299
284
  }
300
- Qt(t) {
301
- return this.Ht.has(t);
285
+ Jt(t) {
286
+ return this.Vt.has(t);
302
287
  }
303
288
  Zt(t, e) {
304
- const i = this.Ht.get(t);
305
- if (i) if (typeof e == "number") this.xt.uniform1f(i, e);
306
- else if (typeof e == "boolean") this.xt.uniform1i(i, e ? 1 : 0);
307
- else if (Array.isArray(e)) switch (e.length) {
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);
293
+ 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);
298
+ break;
299
+ case 3:
300
+ this.bt.uniform3fv(i, o);
301
+ break;
302
+ case 4:
303
+ this.bt.uniform4fv(i, o);
304
+ break;
305
+ default:
306
+ return void console.warn(`Unsupported vector array length for '${t}': ${n}`);
307
+ }
308
+ } else switch (e.length) {
308
309
  case 2:
309
- this.xt.uniform2f(i, e[0], e[1]);
310
+ this.bt.uniform2f(i, e[0], e[1]);
310
311
  break;
311
312
  case 3:
312
- this.xt.uniform3f(i, e[0], e[1], e[2]);
313
+ this.bt.uniform3f(i, e[0], e[1], e[2]);
313
314
  break;
314
315
  case 4:
315
- this.xt.uniform4f(i, e[0], e[1], e[2], e[3]);
316
+ this.bt.uniform4f(i, e[0], e[1], e[2], e[3]);
316
317
  break;
317
318
  default:
318
319
  return;
319
320
  }
320
321
  else if (e instanceof WebGLTexture) {
321
- const s = this.Jt();
322
- this.xt.uniform1i(i, s), this.xt.activeTexture(this.xt.TEXTURE0 + s), this.xt.bindTexture(this.xt.TEXTURE_2D, e);
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);
323
324
  } else if (e instanceof G) {
324
- const s = this.Jt();
325
- this.xt.uniform1i(i, s), this.xt.activeTexture(this.xt.TEXTURE0 + s), this.xt.bindTexture(this.xt.TEXTURE_2D, e.texture);
326
- } else if (typeof e == "object" && "texture" in e) {
327
- const s = this.Jt();
328
- this.xt.uniform1i(i, s), this.xt.activeTexture(this.xt.TEXTURE0 + s), this.xt.bindTexture(this.xt.TEXTURE_2D, e.texture);
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]);
329
327
  } else console.warn(`Unsupported uniform type for '${t}':`, typeof e);
330
328
  }
331
- Jt() {
332
- return this.Vt++;
329
+ Qt() {
330
+ return this.Ht++;
333
331
  }
334
332
  get te() {
335
333
  return this.Ot;
336
334
  }
337
335
  Ut() {
338
- this.xt.deleteProgram(this.Ot);
336
+ this.bt.deleteProgram(this.Ot);
339
337
  }
340
338
  }
341
339
  const N = `#version 300 es
342
- 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 r;out vec2 v_uv;out vec3 v_character;out vec4 v_primaryColor;out vec4 v_secondaryColor;out vec2 v_rotation;out vec3 v_transform;mat3 A(float B){float C=sin(B),D=cos(B);return mat3(1,0,0,0,D,-C,0,C,D);}mat3 E(float B){float C=sin(B),D=cos(B);return mat3(D,0,C,0,1,0,-C,0,D);}mat3 F(float B){float C=sin(B),D=cos(B);return mat3(D,-C,0,C,D,0,0,0,1);}vec2 G(float H,vec2 I,vec2 J,vec2 K,vec2 L){float M=1.-H,N=M*M,O=H*H;return N*M*I+3.*N*H*J+3.*M*O*K+O*H*L;}vec2 P(float H,vec2 I,vec2 J,vec2 K,vec2 L){float M=1.-H,N=M*M,O=H*H;return-3.*N*I+3.*N*J-6.*M*H*J+6.*M*H*K-3.*O*K+3.*O*L;}void main(){v_uv=a_texCoord;v_character=a_instanceCharacter;v_primaryColor=a_instancePrimaryColor;v_secondaryColor=a_instanceSecondaryColor;v_rotation=a_instanceRotation;v_transform=a_instanceTransform;vec2 Q;bool R=length(a_instanceBezierCP1)+length(a_instanceBezierCP2)+length(a_instanceBezierStart)+length(a_instanceBezierEnd)>0.;bool S=a_instanceArcAngles.x!=0.||a_instanceArcAngles.y!=0.;if(R){float H=a_position.x;vec2 T=G(H,a_instanceBezierStart,a_instanceBezierCP1,a_instanceBezierCP2,a_instanceBezierEnd);vec2 U=P(H,a_instanceBezierStart,a_instanceBezierCP1,a_instanceBezierCP2,a_instanceBezierEnd);float V=length(U);U=V>0.?U/V:vec2(1,0);Q=T+vec2(-U.y,U.x)*a_position.y*a_instanceSize.y;}else if(S){float C=a_instanceArcAngles.x,W=a_instanceArcAngles.y;C=mod(C,6.28318530718);if(C<0.)C+=6.28318530718;W=mod(W,6.28318530718);if(W<0.)W+=6.28318530718;float X=C-W;if(X<=0.)X+=6.28318530718;float Y=C-a_position.x*X;vec2 Z=vec2(cos(Y),sin(Y))*a_position.y;Q=Z*a_instanceSize*.5+a_instanceSize*.5+a_instancePosition;}else{Q=a_position*a_instanceSize+a_instancePosition;}vec2 a=(Q/r)*2.-1.;a.y=-a.y;if(length(a_instanceGlobalRotation)>0.){vec3 b=vec3(a-a_instanceRotationCenter,0);b.x*=k;if(a_instanceGlobalRotation.x!=0.)b=A(-a_instanceGlobalRotation.x)*b;if(a_instanceGlobalRotation.y!=0.)b=E(-a_instanceGlobalRotation.y)*b;if(a_instanceGlobalRotation.z!=0.)b=F(-a_instanceGlobalRotation.z)*b;b.x/=k;a=b.xy+a_instanceRotationCenter;}gl_Position=vec4(a,0,1);}`;
340
+ 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);}`;
343
341
  class it {
344
342
  constructor(t) {
345
343
  h(this, "ee", /* @__PURE__ */ new Map());
346
- h(this, "xt");
347
- this.xt = t;
344
+ h(this, "bt");
345
+ this.bt = t;
348
346
  }
349
347
  se(t, e) {
350
348
  if (!this.ee.has(t)) {
@@ -354,36 +352,36 @@ class it {
354
352
  return this.ee.get(t);
355
353
  }
356
354
  ie() {
357
- return this.se("mrt-copy", () => new S(this.xt, N, `#version 300 es
355
+ return this.se("mrt-copy", () => new M(this.bt, N, `#version 300 es
358
356
  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;}`));
359
357
  }
360
358
  Bt() {
361
- return this.se("mrt-draw", () => new S(this.xt, N, `#version 300 es
359
+ return this.se("mrt-draw", () => new M(this.bt, N, `#version 300 es
362
360
  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.);}`));
363
361
  }
364
362
  re() {
365
- return this.se("ascii-conversion", () => new S(this.xt, "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);}"));
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);}"));
366
364
  }
367
365
  ne(t) {
368
- return new S(this.xt, N, t);
366
+ return new M(this.bt, N, t);
369
367
  }
370
368
  oe(t, e) {
371
- return new S(this.xt, t, e);
369
+ return new M(this.bt, t, e);
372
370
  }
373
371
  Ut() {
374
372
  for (const t of this.ee.values()) t.Ut();
375
373
  this.ee.clear();
376
374
  }
377
375
  }
378
- var x = ((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))(x || {});
376
+ 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 || {});
379
377
  class st {
380
378
  constructor(t) {
381
- h(this, "xt");
379
+ h(this, "bt");
382
380
  h(this, "ae", /* @__PURE__ */ new Map());
383
- this.xt = t;
381
+ this.bt = t;
384
382
  }
385
383
  he(t, e, i, s) {
386
- const r = this.xt;
384
+ const r = this.bt;
387
385
  let n = this.ae.get(t);
388
386
  n || (n = /* @__PURE__ */ new Map(), this.ae.set(t, n));
389
387
  let o = n.get(e) || null;
@@ -397,10 +395,10 @@ class st {
397
395
  r.bindVertexArray(o);
398
396
  }
399
397
  de() {
400
- this.xt.bindVertexArray(null);
398
+ this.bt.bindVertexArray(null);
401
399
  }
402
400
  Ut() {
403
- const t = this.xt;
401
+ const t = this.bt;
404
402
  for (const [, e] of this.ae) for (const [, i] of e) i && t.deleteVertexArray(i);
405
403
  this.ae.clear();
406
404
  }
@@ -408,28 +406,28 @@ class st {
408
406
  class rt {
409
407
  constructor(t, e) {
410
408
  h(this, "_e");
411
- h(this, "xt");
409
+ h(this, "bt");
412
410
  h(this, "Pt");
413
411
  h(this, "pe", null);
414
412
  h(this, "ge", null);
415
- this.xt = t, this._e = new st(t), this.Pt = e;
413
+ this.bt = t, this._e = new st(t), this.Pt = e;
416
414
  }
417
415
  me(t, e, i) {
418
- const { shader: s } = t, r = B(this.xt) || this.xt.getParameter(this.xt.VIEWPORT);
419
- s.qt({ k: r[2] / r[3], r: [r[2], r[3]] });
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]] });
420
418
  const n = (l) => {
421
419
  if (!l || !l.ve()) return;
422
420
  const f = l.unitGeometry, u = l.unitBuffer;
423
421
  try {
424
422
  this._e.he(s.te, l.type + "", f, u), l.batch.ye(s), l.batch.Ce(f.$e, f.we);
425
423
  } finally {
426
- l.batch.be(s), this._e.de(), l.xe();
424
+ l.batch.xe(s), this._e.de(), l.be();
427
425
  }
428
426
  };
429
427
  let o = null, c = null;
430
428
  for (const l of e) {
431
- if (l.type === x.CUSTOM) {
432
- c && (n(c), o = null, c = null), this.Re(t, l.params, l.state, i.get(x.RECTANGLE));
429
+ if (l.type === b.CUSTOM) {
430
+ c && (n(c), o = null, c = null), this.Re(t, l.params, l.state, i.get(b.RECTANGLE));
433
431
  continue;
434
432
  }
435
433
  o !== null && l.type !== o && (n(c), o = null, c = null);
@@ -448,13 +446,13 @@ class rt {
448
446
  }
449
447
  Fe(t, e, i, s, r, n, o, c) {
450
448
  e.jt(), e.qt(i);
451
- const l = this.xt.getParameter(this.xt.VIEWPORT);
452
- if (e.qt({ k: l[2] / l[3], r: [l[2], l[3]] }), t.xe(), t.Me({ x: s, y: r, width: n, height: o }, c), t.ve()) {
449
+ 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()) {
453
451
  const f = t.unitGeometry, u = t.unitBuffer;
454
452
  try {
455
453
  this._e.he(e.te, t.type + "", f, u), t.batch.ye(e), t.batch.Ce(f.$e, f.we);
456
454
  } finally {
457
- t.batch.be(e), this._e.de(), t.xe();
455
+ t.batch.xe(e), this._e.de(), t.be();
458
456
  }
459
457
  }
460
458
  }
@@ -462,86 +460,86 @@ class rt {
462
460
  return this.Pt.ie();
463
461
  }
464
462
  ze(t, e) {
465
- return this.pe && this.ge && this.ge.w === t && this.ge.h === e || (this.pe && this.pe.Ut(), this.pe = new G(this.xt, t, e, 5), this.ge = { w: t, h: e }), this.pe;
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;
466
464
  }
467
465
  }
468
466
  class nt {
469
467
  constructor() {
470
468
  h(this, "Pe", []);
471
469
  h(this, "ke", 1);
472
- h(this, "Ge", 0);
470
+ h(this, "Te", 0);
473
471
  }
474
- Ae(t) {
475
- if (this.Ge >= this.Pe.length) {
472
+ Ge(t) {
473
+ if (this.Te >= this.Pe.length) {
476
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] } };
477
475
  this.Pe.push(i);
478
476
  }
479
- const e = this.Pe[this.Ge];
477
+ const e = this.Pe[this.Te];
480
478
  switch (e.id = this.ke++, e.type = t, t) {
481
- case x.RECTANGLE:
482
- case x.ELLIPSE:
479
+ case b.RECTANGLE:
480
+ case b.ELLIPSE:
483
481
  e.params && "width" in e.params || (e.params = { x: 0, y: 0, width: 0, height: 0 });
484
482
  break;
485
- case x.CUSTOM:
483
+ case b.CUSTOM:
486
484
  e.params && "shader" in e.params || (e.params = { x: 0, y: 0, width: 0, height: 0, shader: void 0, uniforms: {} });
487
485
  break;
488
- case x.ARC:
486
+ case b.ARC:
489
487
  e.params && "start" in e.params || (e.params = { x: 0, y: 0, width: 0, height: 0, start: 0, stop: 0 });
490
488
  break;
491
- case x.LINE:
489
+ case b.LINE:
492
490
  e.params && "x2" in e.params || (e.params = { x1: 0, y1: 0, x2: 0, y2: 0, thickness: void 0 });
493
491
  break;
494
- case x.TRIANGLE:
492
+ case b.TRIANGLE:
495
493
  e.params && "x3" in e.params || (e.params = { x1: 0, y1: 0, x2: 0, y2: 0, x3: 0, y3: 0 });
496
494
  break;
497
- case x.BEZIER_CURVE:
495
+ case b.BEZIER_CURVE:
498
496
  e.params && "cp2y" in e.params || (e.params = { x1: 0, y1: 0, cp1x: 0, cp1y: 0, cp2x: 0, cp2y: 0, x2: 0, y2: 0, thickness: void 0 });
499
497
  break;
500
498
  default:
501
499
  e.params || (e.params = {});
502
500
  }
503
- return this.Ge++, e;
501
+ return this.Te++, e;
504
502
  }
505
- Te(t, e, i, s, r) {
506
- const n = this.Ae(x.RECTANGLE);
503
+ Ae(t, e, i, s, r) {
504
+ const n = this.Ge(b.RECTANGLE);
507
505
  return n.params.x = t, n.params.y = e, n.params.width = i, n.params.height = s, r.nt(n.state), n.id;
508
506
  }
509
- Ee(t, e, i, s, r, n, o) {
510
- const c = this.Ae(x.CUSTOM);
507
+ Le(t, e, i, s, r, n, o) {
508
+ const c = this.Ge(b.CUSTOM);
511
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;
512
510
  }
513
- Le(t, e, i, s, r, n) {
514
- const o = this.Ae(x.LINE);
511
+ Ee(t, e, i, s, r, n) {
512
+ const o = this.Ge(b.LINE);
515
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;
516
514
  }
517
515
  Be(t, e, i, s, r) {
518
- const n = this.Ae(x.ELLIPSE);
516
+ const n = this.Ge(b.ELLIPSE);
519
517
  return n.params.x = t, n.params.y = e, n.params.width = i, n.params.height = s, r.nt(n.state), n.id;
520
518
  }
521
519
  De(t, e, i, s, r, n, o) {
522
- const c = this.Ae(x.ARC);
520
+ const c = this.Ge(b.ARC);
523
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;
524
522
  }
525
523
  We(t, e, i, s, r, n, o) {
526
- const c = this.Ae(x.TRIANGLE);
524
+ const c = this.Ge(b.TRIANGLE);
527
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;
528
526
  }
529
527
  Ie(t, e, i, s, r, n, o, c, l, f) {
530
- const u = this.Ae(x.BEZIER_CURVE);
528
+ const u = this.Ge(b.BEZIER_CURVE);
531
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;
532
530
  }
533
531
  get length() {
534
- return this.Ge;
532
+ return this.Te;
535
533
  }
536
534
  get isEmpty() {
537
- return this.Ge === 0;
535
+ return this.Te === 0;
538
536
  }
539
537
  Ue() {
540
- this.Ge = 0;
538
+ this.Te = 0;
541
539
  }
542
540
  [Symbol.iterator]() {
543
541
  let t = 0;
544
- const e = this.Ge, i = this.Pe;
542
+ const e = this.Te, i = this.Pe;
545
543
  return { next: () => t < e ? { value: i[t++], done: !1 } : { value: void 0, done: !0 } };
546
544
  }
547
545
  }
@@ -552,7 +550,7 @@ const T = class T {
552
550
  let r = i;
553
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;
554
552
  }
555
- static He(t) {
553
+ static Ve(t) {
556
554
  const e = t.length * T.FLOATS_PER_INSTANCE, i = new Float32Array(e);
557
555
  for (let s = 0; s < t.length; s++) {
558
556
  const r = s * T.FLOATS_PER_INSTANCE;
@@ -569,8 +567,8 @@ h(y, "STRIDE", P.BYTES_PER_INSTANCE), h(y, "ATTRIBUTES", { a_instancePosition: {
569
567
  let D = y;
570
568
  class ot {
571
569
  constructor(t, e = 1e3, i = 1.5) {
572
- h(this, "xt");
573
- h(this, "Ve", []);
570
+ h(this, "bt");
571
+ h(this, "He", []);
574
572
  h(this, "Ke");
575
573
  h(this, "Ne");
576
574
  h(this, "Xe", null);
@@ -578,44 +576,44 @@ class ot {
578
576
  h(this, "Ye", 0);
579
577
  h(this, "qe", /* @__PURE__ */ new Map());
580
578
  h(this, "Ze", null);
581
- this.xt = t, this.Ke = e, this.Ne = i, this.Qe();
579
+ this.bt = t, this.Ke = e, this.Ne = i, this.Je();
582
580
  }
583
581
  Me(t) {
584
- const e = this.Ve.length;
585
- return this.Ve.push(t), this.je = !0, e;
582
+ const e = this.He.length;
583
+ return this.He.push(t), this.je = !0, e;
586
584
  }
587
585
  get count() {
588
- return this.Ve.length;
586
+ return this.He.length;
589
587
  }
590
588
  get isEmpty() {
591
- return this.Ve.length === 0;
589
+ return this.He.length === 0;
592
590
  }
593
591
  clear() {
594
- this.Ve.length = 0, this.je = !0;
592
+ this.He.length = 0, this.je = !0;
595
593
  }
596
- Je(t) {
594
+ Qe(t) {
597
595
  if (t <= this.Ke) return;
598
596
  const e = Math.ceil(t * this.Ne);
599
- this.Ke = e, this.Qe();
597
+ this.Ke = e, this.Je();
600
598
  }
601
- Qe() {
602
- const t = this.xt;
599
+ Je() {
600
+ const t = this.bt;
603
601
  this.Xe && t.deleteBuffer(this.Xe), this.Xe = t.createBuffer();
604
602
  const e = this.Ke * P.BYTES_PER_INSTANCE;
605
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;
606
604
  }
607
605
  ts() {
608
- if (!this.je || this.Ve.length === 0) return;
609
- const t = this.xt, e = this.Ve.length;
610
- this.Je(e), (!this.Ze || this.Ze.length < e * P.FLOATS_PER_INSTANCE) && (this.Ze = new Float32Array(e * P.FLOATS_PER_INSTANCE));
611
- const i = P.He(this.Ve);
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);
612
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;
613
611
  }
614
612
  es(t) {
615
613
  let e = this.qe.get(t);
616
614
  if (!e) {
617
615
  e = /* @__PURE__ */ new Map();
618
- const i = this.xt;
616
+ const i = this.bt;
619
617
  for (const s in D.ATTRIBUTES) {
620
618
  const r = i.getAttribLocation(t, s);
621
619
  r !== -1 && e.set(s, r);
@@ -625,8 +623,8 @@ class ot {
625
623
  return e;
626
624
  }
627
625
  ye(t) {
628
- if (!this.Xe || this.Ve.length === 0) return;
629
- const e = this.xt, i = t.te;
626
+ if (!this.Xe || this.He.length === 0) return;
627
+ const e = this.bt, i = t.te;
630
628
  this.ts();
631
629
  const s = this.es(i);
632
630
  e.bindBuffer(e.ARRAY_BUFFER, this.Xe);
@@ -635,29 +633,29 @@ class ot {
635
633
  o && (e.enableVertexAttribArray(n), e.vertexAttribPointer(n, o.size, o.type, o.normalized, o.stride, o.offset), e.vertexAttribDivisor(n, o.divisor));
636
634
  }
637
635
  }
638
- be(t) {
639
- const e = this.xt, i = this.es(t.te);
636
+ xe(t) {
637
+ const e = this.bt, i = this.es(t.te);
640
638
  for (const [, s] of i) e.disableVertexAttribArray(s), e.vertexAttribDivisor(s, 0);
641
639
  }
642
640
  Ce(t, e) {
643
- this.Ve.length !== 0 && this.xt.drawArraysInstanced(t, 0, e, this.Ve.length);
641
+ this.He.length !== 0 && this.bt.drawArraysInstanced(t, 0, e, this.He.length);
644
642
  }
645
643
  Ut() {
646
- const t = this.xt;
647
- this.Xe && (t.deleteBuffer(this.Xe), this.Xe = null), this.Ve.length = 0, this.qe.clear(), this.Ze = null;
644
+ const t = this.bt;
645
+ this.Xe && (t.deleteBuffer(this.Xe), this.Xe = null), this.He.length = 0, this.qe.clear(), this.Ze = null;
648
646
  }
649
647
  }
650
648
  class F {
651
649
  constructor(t, e, i, s) {
652
- h(this, "xt");
650
+ h(this, "bt");
653
651
  h(this, "ss");
654
652
  h(this, "rs");
655
653
  h(this, "ns");
656
654
  h(this, "hs", null);
657
- this.xt = t, this.ss = e, this.rs = i, this.ns = s;
658
- const r = this.xt.createBuffer();
655
+ this.bt = t, this.ss = e, this.rs = i, this.ns = s;
656
+ const r = this.bt.createBuffer();
659
657
  if (!r) throw Error("Failed to create unit geometry buffer");
660
- this.xt.bindBuffer(this.xt.ARRAY_BUFFER, r), this.xt.bufferData(this.xt.ARRAY_BUFFER, this.ns.cs, this.xt.STATIC_DRAW), this.xt.bindBuffer(this.xt.ARRAY_BUFFER, null), this.hs = r;
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;
661
659
  }
662
660
  get type() {
663
661
  return this.rs;
@@ -671,21 +669,21 @@ class F {
671
669
  get batch() {
672
670
  return this.ss;
673
671
  }
674
- xe() {
672
+ be() {
675
673
  this.ss.clear();
676
674
  }
677
675
  ve() {
678
676
  return !this.ss.isEmpty;
679
677
  }
680
678
  Ut() {
681
- this.ss.Ut(), this.hs && (this.xt.deleteBuffer(this.hs), this.hs = null);
679
+ this.ss.Ut(), this.hs && (this.bt.deleteBuffer(this.hs), this.hs = null);
682
680
  }
683
681
  ls(t, e, i, s, r) {
684
682
  const n = this.us(t, e, i, s, r.rotationX || 0, r.rotationY || 0, r.rotationZ || 0);
685
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] };
686
684
  }
687
685
  fs(t, e) {
688
- const i = B(this.xt) || [0, 0, this.xt.canvas.width, this.xt.canvas.height];
686
+ const i = B(this.bt) || [0, 0, this.bt.canvas.width, this.bt.canvas.height];
689
687
  return { nx: t / i[2] * 2 - 1, ny: 1 - e / i[3] * 2 };
690
688
  }
691
689
  ds(t, e, i) {
@@ -693,14 +691,14 @@ class F {
693
691
  t.rotationCenter = [s.nx, s.ny];
694
692
  }
695
693
  us(t, e, i, s, r, n, o) {
696
- const c = B(this.xt) || [0, 0, this.xt.canvas.width, this.xt.canvas.height], l = c[2], f = c[3];
694
+ const c = B(this.bt) || [0, 0, this.bt.canvas.width, this.bt.canvas.height], l = c[2], f = c[3];
697
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 };
698
696
  }
699
697
  }
700
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 } } };
701
699
  class ht extends F {
702
700
  constructor(t, e) {
703
- super(t, e, x.RECTANGLE, at);
701
+ super(t, e, b.RECTANGLE, at);
704
702
  }
705
703
  Me(t, e) {
706
704
  const i = this.ls(t.x, t.y, t.width, t.height, e);
@@ -710,7 +708,7 @@ class ht extends F {
710
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 } } };
711
709
  class lt extends F {
712
710
  constructor(t, e) {
713
- super(t, e, x.LINE, ct);
711
+ super(t, e, b.LINE, ct);
714
712
  }
715
713
  Me(t, e) {
716
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);
@@ -727,7 +725,7 @@ const ut = { cs: function(a = 32) {
727
725
  }(32), we: 96, $e: WebGL2RenderingContext.TRIANGLES, ue: 16, le: { ce: { size: 2, offset: 0 }, fe: { size: 2, offset: 8 } } };
728
726
  class ft extends F {
729
727
  constructor(t, e) {
730
- super(t, e, x.ELLIPSE, ut);
728
+ super(t, e, b.ELLIPSE, ut);
731
729
  }
732
730
  Me(t, e) {
733
731
  const i = this.ls(t.x, t.y, t.width, t.height, e);
@@ -744,7 +742,7 @@ let dt = { cs: function(a) {
744
742
  }(32), we: 96, $e: WebGL2RenderingContext.TRIANGLES, ue: 16, le: { ce: { size: 2, offset: 0 }, fe: { size: 2, offset: 8 } } };
745
743
  class pt extends F {
746
744
  constructor(t, e) {
747
- super(t, e, x.ARC, dt);
745
+ super(t, e, b.ARC, dt);
748
746
  }
749
747
  Me(t, e) {
750
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);
@@ -754,7 +752,7 @@ class pt extends F {
754
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 } } };
755
753
  class mt extends F {
756
754
  constructor(t, e) {
757
- super(t, e, x.TRIANGLE, gt);
755
+ super(t, e, b.TRIANGLE, gt);
758
756
  }
759
757
  Me(t, e) {
760
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);
@@ -765,7 +763,7 @@ function X(a, t, e, i, s) {
765
763
  const r = 1 - a, n = r * r, o = a * a;
766
764
  return n * r * t + 3 * n * a * e + 3 * r * o * i + o * a * s;
767
765
  }
768
- const xt = { cs: function(a = 16) {
766
+ const bt = { cs: function(a = 16) {
769
767
  const t = [];
770
768
  for (let e = 0; e < a; e++) {
771
769
  const i = e / a, s = (e + 1) / a;
@@ -775,16 +773,16 @@ const xt = { cs: function(a = 16) {
775
773
  }(16), we: 96, $e: WebGL2RenderingContext.TRIANGLES, ue: 16, le: { ce: { size: 2, offset: 0 }, fe: { size: 2, offset: 8 } } };
776
774
  class yt extends F {
777
775
  constructor(t, e) {
778
- super(t, e, x.BEZIER_CURVE, xt);
776
+ super(t, e, b.BEZIER_CURVE, bt);
779
777
  }
780
778
  Me(t, e) {
781
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);
782
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);
783
781
  }
784
782
  }
785
- class Rt {
783
+ class Et {
786
784
  constructor(t) {
787
- h(this, "xt");
785
+ h(this, "bt");
788
786
  h(this, "_s", null);
789
787
  h(this, "ps");
790
788
  h(this, "gs", null);
@@ -795,13 +793,13 @@ class Rt {
795
793
  h(this, "bs");
796
794
  h(this, "Rs");
797
795
  h(this, "K", []);
798
- this.xt = 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.xt, [0, 0, this.xt.canvas.width, this.xt.canvas.height]);
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]);
799
797
  }
800
798
  Ms(t) {
801
799
  let e = this.$s.get(t);
802
800
  if (e) return e;
803
- const i = new ot(this.xt);
804
- return e = (0, { [x.RECTANGLE]: () => new ht(this.xt, i), [x.LINE]: () => new lt(this.xt, i), [x.ELLIPSE]: () => new ft(this.xt, i), [x.ARC]: () => new pt(this.xt, i), [x.TRIANGLE]: () => new mt(this.xt, i), [x.BEZIER_CURVE]: () => new yt(this.xt, i) }[t])(), this.$s.set(t, e), e;
801
+ 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;
805
803
  }
806
804
  Ss(t) {
807
805
  this._s !== t && (this._s = t, t.jt());
@@ -832,25 +830,25 @@ class Rt {
832
830
  }
833
831
  ks(t, e, i, s, r) {
834
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] };
835
- this.bs.Ee(e, i, s, r, n, o, this.Rs);
833
+ this.bs.Le(e, i, s, r, n, o, this.Rs);
836
834
  }
837
- Gs(t, e, i, s) {
835
+ Ts(t, e, i, s) {
838
836
  var m;
839
- const r = this.xt, 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]);
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]);
840
838
  r.bindBuffer(r.ARRAY_BUFFER, this.Cs), r.bufferData(r.ARRAY_BUFFER, d, r.DYNAMIC_DRAW);
841
839
  const p = ((m = this._s) == null ? void 0 : m.te) || r.getParameter(r.CURRENT_PROGRAM), g = p ? r.getAttribLocation(p, "a_position") : -1;
842
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);
843
841
  }
844
- As(t, e, i, s) {
845
- this.gs ? (this.bs.Ee(t, e, i, s, this.gs, { ...this.vs }, this.Rs), this.gs = null, this.vs = {}) : this.bs.Te(t, e, i, s, this.Rs);
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);
846
844
  }
847
- Ts(t, e, i, s) {
848
- this.bs.Le(t, e, i, s, this.Rs.lineWeight, this.Rs);
845
+ As(t, e, i, s) {
846
+ this.bs.Ee(t, e, i, s, this.Rs.lineWeight, this.Rs);
849
847
  }
850
- Es(t, e, i, s) {
848
+ Ls(t, e, i, s) {
851
849
  this.bs.Be(t, e, i, s, this.Rs);
852
850
  }
853
- Ls(t, e, i, s, r, n) {
851
+ Es(t, e, i, s, r, n) {
854
852
  this.bs.We(t, e, i, s, r, n, this.Rs);
855
853
  }
856
854
  Bs(t, e, i, s, r, n, o, c) {
@@ -858,7 +856,7 @@ class Rt {
858
856
  this.bs.Ie(t, e, i, s, r, n, o, c, l, this.Rs);
859
857
  }
860
858
  Ds(t, e, i = 1, s = {}) {
861
- return new G(this.xt, t, e, i, s, this, !0);
859
+ return new G(this.bt, t, e, i, s, this, !0);
862
860
  }
863
861
  Ws(t, e, i, s, r, n) {
864
862
  this.bs.De(t, e, i, s, r, n, this.Rs);
@@ -867,13 +865,13 @@ class Rt {
867
865
  this.state.Ct(t, e, i, s), this.Ue(t / 255, e / 255, i / 255, s / 255);
868
866
  }
869
867
  Ue(t = 0, e = 0, i = 0, s = 0) {
870
- this.xt.clearColor(t, e, i, s), this.xt.clear(this.xt.COLOR_BUFFER_BIT);
868
+ this.bt.clearColor(t, e, i, s), this.bt.clear(this.bt.COLOR_BUFFER_BIT);
871
869
  }
872
870
  Us() {
873
- this.xt.viewport(0, 0, this.xt.canvas.width, this.xt.canvas.height), U(this.xt, [0, 0, this.xt.canvas.width, this.xt.canvas.height]);
871
+ 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]);
874
872
  }
875
873
  get context() {
876
- return this.xt;
874
+ return this.bt;
877
875
  }
878
876
  get state() {
879
877
  return this.Rs;
@@ -886,26 +884,26 @@ class Rt {
886
884
  t && (this.Rs = t);
887
885
  }
888
886
  Dt(t) {
889
- const e = t, i = B(this.xt) ?? this.xt.getParameter(this.xt.VIEWPORT), s = { shader: e, gl: this.xt, viewport: i };
887
+ const e = t, i = B(this.bt) ?? this.bt.getParameter(this.bt.VIEWPORT), s = { shader: e, gl: this.bt, viewport: i };
890
888
  this.Ss(e);
891
889
  const r = /* @__PURE__ */ new Set();
892
- for (const n of this.bs) n.type === x.CUSTOM ? r.add(x.RECTANGLE) : r.add(n.type);
893
- for (const n of r) n !== x.CUSTOM && this.Ms(n);
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);
894
892
  this.ws.me(s, this.bs, this.$s), this.bs.Ue();
895
893
  }
896
894
  Ut() {
897
- this.xt.deleteBuffer(this.Cs), this.bs.Ue();
895
+ this.bt.deleteBuffer(this.Cs), this.bs.Ue();
898
896
  for (const t of this.$s.values()) t.Ut();
899
897
  this.ps.Ut();
900
898
  }
901
899
  }
902
- const R = { readShort: (a, t) => (R.t.uint16[0] = a[t] << 8 | a[t + 1], R.t.int16[0]), readUshort: (a, t) => a[t] << 8 | a[t + 1], readUshorts(a, t, e) {
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) {
903
901
  const i = [];
904
- for (let s = 0; s < e; s++) i.push(R.readUshort(a, t + 2 * s));
902
+ for (let s = 0; s < e; s++) i.push(E.readUshort(a, t + 2 * s));
905
903
  return i;
906
904
  }, readUint(a, t) {
907
- const e = R.t.uint8;
908
- return e[3] = a[t], e[2] = a[t + 1], e[1] = a[t + 2], e[0] = a[t + 3], R.t.uint32[0];
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];
909
907
  }, readASCII(a, t, e) {
910
908
  let i = "";
911
909
  for (let s = 0; s < e; s++) i += String.fromCharCode(a[t + s]);
@@ -913,10 +911,10 @@ const R = { readShort: (a, t) => (R.t.uint16[0] = a[t] << 8 | a[t + 1], R.t.int1
913
911
  }, t: (() => {
914
912
  const a = new ArrayBuffer(8);
915
913
  return { uint8: new Uint8Array(a), int16: new Int16Array(a), uint16: new Uint16Array(a), uint32: new Uint32Array(a) };
916
- })() }, vt = { parseTab(a, t, e) {
914
+ })() }, Rt = { parseTab(a, t, e) {
917
915
  const i = { tables: [], ids: {}, off: t };
918
916
  a = new Uint8Array(a.buffer, t, e), t = 0;
919
- const s = R, r = s.readUshort, n = r(a, t += 2);
917
+ const s = E, r = s.readUshort, n = r(a, t += 2);
920
918
  t += 2;
921
919
  const o = [];
922
920
  for (let c = 0; c < n; c++) {
@@ -936,22 +934,22 @@ const R = { readShort: (a, t) => (R.t.uint16[0] = a[t] << 8 | a[t + 1], R.t.int1
936
934
  }
937
935
  return i;
938
936
  }, parse4(a, t) {
939
- const e = R, i = e.readUshort, s = e.readUshorts, r = t, n = i(a, t += 2);
937
+ const e = E, i = e.readUshort, s = e.readUshorts, r = t, n = i(a, t += 2);
940
938
  t += 2;
941
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: [] };
942
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;
943
941
  for (let l = 0; l < o; l++) c.idDelta.push(e.readShort(a, t)), t += 2;
944
942
  return c.idRangeOffset = s(a, t, o), t += 2 * o, c.glyphIdArray = s(a, t, r + n - t >> 1), c;
945
943
  }, parse12(a, t) {
946
- const e = R.readUint;
944
+ const e = E.readUint;
947
945
  e(a, t += 4), e(a, t += 4);
948
946
  const i = e(a, t += 4);
949
947
  t += 4;
950
948
  const s = new Uint32Array(3 * i);
951
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);
952
950
  return { format: 12, groups: s };
953
- } }, Et = { parseTab(a, t, e) {
954
- const i = R;
951
+ } }, vt = { parseTab(a, t, e) {
952
+ const i = E;
955
953
  t += 18;
956
954
  const s = i.readUshort(a, t);
957
955
  t += 2, t += 16;
@@ -963,8 +961,8 @@ const R = { readShort: (a, t) => (R.t.uint16[0] = a[t] << 8 | a[t + 1], R.t.int1
963
961
  t += 2;
964
962
  const c = i.readShort(a, t);
965
963
  return t += 2, t += 6, { unitsPerEm: s, xMin: r, yMin: n, xMax: o, yMax: c, indexToLocFormat: i.readShort(a, t) };
966
- } }, bt = { parseTab(a, t, e) {
967
- const i = R;
964
+ } }, xt = { parseTab(a, t, e) {
965
+ const i = E;
968
966
  t += 4;
969
967
  const s = ["ascender", "descender", "lineGap", "advanceWidthMax", "minLeftSideBearing", "minRightSideBearing", "xMaxExtent", "caretSlopeRise", "caretSlopeRun", "caretOffset", "res0", "res1", "res2", "res3", "metricDataFormat", "numberOfHMetrics"], r = {};
970
968
  for (let n = 0; n < s.length; n++) {
@@ -973,16 +971,16 @@ const R = { readShort: (a, t) => (R.t.uint16[0] = a[t] << 8 | a[t + 1], R.t.int1
973
971
  }
974
972
  return r;
975
973
  } }, wt = { parseTab(a, t, e, i) {
976
- const s = R, r = [], n = [], o = i.maxp.numGlyphs, c = i.hhea.numberOfHMetrics;
974
+ const s = E, r = [], n = [], o = i.maxp.numGlyphs, c = i.hhea.numberOfHMetrics;
977
975
  let l = 0, f = 0, u = 0;
978
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++;
979
977
  for (; u < o; ) r.push(l), n.push(f), u++;
980
978
  return { aWidth: r, lsBearing: n };
981
- } }, H = { cmap: vt, head: Et, hhea: bt, maxp: { parseTab(a, t, e) {
982
- const i = R;
979
+ } }, Y = { cmap: Rt, head: vt, hhea: xt, maxp: { parseTab(a, t, e) {
980
+ const i = E;
983
981
  return i.readUint(a, t), t += 4, { numGlyphs: i.readUshort(a, t) };
984
982
  } }, hmtx: wt, loca: { parseTab(a, t, e, i) {
985
- const s = R, r = [], n = i.head.indexToLocFormat, o = i.maxp.numGlyphs + 1;
983
+ const s = E, r = [], n = i.head.indexToLocFormat, o = i.maxp.numGlyphs + 1;
986
984
  if (n === 0) for (let c = 0; c < o; c++) r.push(s.readUshort(a, t + (c << 1)) << 1);
987
985
  else if (n === 1) for (let c = 0; c < o; c++) r.push(s.readUint(a, t + (c << 2)));
988
986
  return r;
@@ -991,9 +989,9 @@ const R = { readShort: (a, t) => (R.t.uint16[0] = a[t] << 8 | a[t + 1], R.t.int1
991
989
  for (let n = 0; n < r; n++) s.push(null);
992
990
  return s;
993
991
  }, Os(a, t) {
994
- const e = R, i = a.Hs, s = a.loca;
992
+ const e = E, i = a.Vs, s = a.loca;
995
993
  if (s[t] === s[t + 1]) return null;
996
- const r = A.findTable(i, "glyf", a.Vs);
994
+ const r = A.findTable(i, "glyf", a.Hs);
997
995
  if (!r) return null;
998
996
  let n = r[0] + s[t];
999
997
  const o = {};
@@ -1029,7 +1027,7 @@ const R = { readShort: (a, t) => (R.t.uint16[0] = a[t] << 8 | a[t + 1], R.t.int1
1029
1027
  } else o.parts = [], o.endPts = [], o.flags = [], o.xs = [], o.ys = [];
1030
1028
  return o;
1031
1029
  } } }, A = { parse: (a) => [((t, e, i, s) => {
1032
- const r = H, n = { Hs: t, Ks: e, Vs: i };
1030
+ const r = Y, n = { Vs: t, Ks: e, Hs: i };
1033
1031
  for (const o in r) {
1034
1032
  const c = o, l = A.findTable(t, c, i);
1035
1033
  if (l) {
@@ -1040,7 +1038,7 @@ const R = { readShort: (a, t) => (R.t.uint16[0] = a[t] << 8 | a[t + 1], R.t.int1
1040
1038
  }
1041
1039
  return n;
1042
1040
  })(new Uint8Array(a), 0, 0, {})], findTable(a, t, e) {
1043
- const i = R, s = i.readUshort(a, e + 4);
1041
+ const i = E, s = i.readUshort(a, e + 4);
1044
1042
  let r = e + 12;
1045
1043
  for (let n = 0; n < s; n++) {
1046
1044
  const o = i.readASCII(a, r, 4);
@@ -1050,7 +1048,7 @@ const R = { readShort: (a, t) => (R.t.uint16[0] = a[t] << 8 | a[t + 1], R.t.int1
1050
1048
  r += 16;
1051
1049
  }
1052
1050
  return null;
1053
- }, T: H, B: R };
1051
+ }, T: Y, B: E };
1054
1052
  class I {
1055
1053
  constructor() {
1056
1054
  h(this, "Ns", /* @__PURE__ */ new Map());
@@ -1065,11 +1063,11 @@ class I {
1065
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;
1066
1064
  return this.Ns.set(i, r), r;
1067
1065
  }
1068
- Qs(t, e) {
1066
+ Js(t, e) {
1069
1067
  const i = e.codePointAt(0);
1070
1068
  return i === void 0 ? 0 : this.js(t, i);
1071
1069
  }
1072
- Js(t, e) {
1070
+ Qs(t, e) {
1073
1071
  const i = t.hmtx;
1074
1072
  return i && i.aWidth && i.aWidth.length !== 0 ? e < i.aWidth.length ? i.aWidth[e] : i.aWidth[i.aWidth.length - 1] : 0;
1075
1073
  }
@@ -1081,7 +1079,7 @@ class I {
1081
1079
  this.Ns.clear(), this.Xs.clear();
1082
1080
  }
1083
1081
  Ys(t) {
1084
- return `${t.Vs}_${t.Hs.length}`;
1082
+ return `${t.Hs}_${t.Vs.length}`;
1085
1083
  }
1086
1084
  qs(t, e) {
1087
1085
  const i = e.endCount.length;
@@ -1129,7 +1127,7 @@ class Ct {
1129
1127
  }), [...new Set(e)]) : [];
1130
1128
  }
1131
1129
  oi(t, e) {
1132
- return this.si.Qs(t, e) > 0;
1130
+ return this.si.Js(t, e) > 0;
1133
1131
  }
1134
1132
  ai(t, e) {
1135
1133
  for (const i of e) if (!this.oi(t, i)) return !1;
@@ -1218,7 +1216,7 @@ class Tt {
1218
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;
1219
1217
  this.gi(c, l), this.mi(t, e, n, i, f);
1220
1218
  const u = this.Pt.Ds(c, l, 1, { filter: "nearest" });
1221
- return u.Et(this.di), { framebuffer: u, columns: n, rows: o };
1219
+ return u.Lt(this.di), { framebuffer: u, columns: n, rows: o };
1222
1220
  }
1223
1221
  gi(t, e) {
1224
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";
@@ -1228,8 +1226,8 @@ class Tt {
1228
1226
  for (let o = 0; o < t.length; o++) {
1229
1227
  const c = o % i, l = Math.floor(o / i), f = t[o].character, u = this.yi(r, f);
1230
1228
  if (!u) continue;
1231
- const d = f.codePointAt(0) || 0, p = this.pi.js(r, d), g = this.Ci(r, p) * n, m = c * e.width, b = l * e.height, v = m + 0.5 * e.width, w = b + 0.5 * e.height, C = Math.round(v - 0.5 * e.width), L = Math.round(w - 0.5 * s), q = C + 0.5 * (e.width - g), Q = L + r.hhea.ascender * n;
1232
- this.$i(u, q, Q, n);
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);
1233
1231
  }
1234
1232
  }
1235
1233
  yi(t, e) {
@@ -1261,17 +1259,17 @@ class Tt {
1261
1259
  let g = l + 1;
1262
1260
  for (; g <= u; )
1263
1261
  if (1 & c[g]) {
1264
- const m = e + r[g] * s, b = i - n[g] * s;
1265
- this._i.lineTo(m, b), g++;
1262
+ const m = e + r[g] * s, x = i - n[g] * s;
1263
+ this._i.lineTo(m, x), g++;
1266
1264
  } else {
1267
- const m = e + r[g] * s, b = i - n[g] * s;
1268
- let v = g + 1 > u ? l : g + 1;
1269
- if (1 & c[v]) {
1270
- const w = e + r[v] * s, C = i - n[v] * s;
1271
- this._i.quadraticCurveTo(m, b, w, C), g = v + 1;
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;
1272
1270
  } else {
1273
- const w = (m + (e + r[v] * s)) / 2, C = (b + (i - n[v] * s)) / 2;
1274
- this._i.quadraticCurveTo(m, b, w, C), g = v;
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;
1275
1273
  }
1276
1274
  }
1277
1275
  this._i.closePath();
@@ -1291,16 +1289,16 @@ class _t {
1291
1289
  let s = 0;
1292
1290
  const r = this.si.ti(i, e), n = r.lineHeight;
1293
1291
  for (const o of t) {
1294
- const c = this.si.Qs(i, o);
1292
+ const c = this.si.Js(i, o);
1295
1293
  if (c === 0) continue;
1296
- const l = this.si.Js(i, c) * r.scale;
1294
+ const l = this.si.Qs(i, c) * r.scale;
1297
1295
  s = Math.max(s, l);
1298
1296
  }
1299
1297
  return { width: Math.ceil(s), height: Math.ceil(n) };
1300
1298
  }
1301
1299
  getCharacterAdvanceWidth(t, e, i) {
1302
- const s = this.si.ti(i, e), r = this.si.Qs(i, t);
1303
- return this.si.Js(i, r) * s.scale;
1300
+ const s = this.si.ti(i, e), r = this.si.Js(i, t);
1301
+ return this.si.Qs(i, r) * s.scale;
1304
1302
  }
1305
1303
  getFontMetrics(t, e) {
1306
1304
  return this.si.ti(e, t);
@@ -1328,13 +1326,13 @@ class Pt {
1328
1326
  wi(t) {
1329
1327
  return [t % 256 / 255, Math.floor(t / 256) % 256 / 255, Math.floor(t / 65536) % 256 / 255];
1330
1328
  }
1331
- bi(t, e) {
1332
- if (!M.M(typeof t == "string", "Character must be a string.", { method: "getCharacterColor", providedValue: t })) return [0, 0, 0];
1329
+ xi(t, e) {
1330
+ if (!L.M(typeof t == "string", "Character must be a string.", { method: "getCharacterColor", providedValue: t })) return [0, 0, 0];
1333
1331
  const i = e.find((s) => s.character === t);
1334
1332
  return i ? i.color : [0, 0, 0];
1335
1333
  }
1336
- xi(t, e) {
1337
- 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.bi(i, e) || [0, 0, 0]) : [[0, 0, 0]];
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]];
1338
1336
  }
1339
1337
  }
1340
1338
  class Ft {
@@ -1346,60 +1344,60 @@ class Ft {
1346
1344
  h(this, "zi", 0);
1347
1345
  h(this, "Pi", 0);
1348
1346
  h(this, "ki", { width: 0, height: 0 });
1347
+ h(this, "Ti");
1349
1348
  h(this, "Gi");
1350
1349
  h(this, "Ai");
1351
- h(this, "Ti");
1352
- h(this, "Ei");
1353
1350
  h(this, "Li");
1354
- this.Fi = e, this.Ai = new At(), this.Ti = new Tt(t), this.Ei = new _t(), this.Li = new Pt();
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();
1355
1353
  }
1356
1354
  async Bi(t) {
1357
1355
  let e;
1358
- if (!t) throw new E("Embedded font not available. This appears to be a minified build - please provide `fontSource`.");
1356
+ if (!t) throw new v("Embedded font not available. This appears to be a minified build - please provide `fontSource`.");
1359
1357
  {
1360
1358
  const i = await fetch(t);
1361
- if (!i.ok) throw new E(`Failed to load font file: ${i.status} ${i.statusText}`);
1359
+ if (!i.ok) throw new v(`Failed to load font file: ${i.status} ${i.statusText}`);
1362
1360
  e = await i.arrayBuffer();
1363
1361
  }
1364
1362
  await this.Di(e), this.Ri = A.parse(e)[0], await this.Wi();
1365
1363
  }
1366
1364
  Ii(t) {
1367
1365
  if (t === void 0) return this.Fi;
1368
- this.Fi = t, this.ki = this.Ei.calculateMaxGlyphDimensions(this.Mi.map((i) => i.character), this.Fi, this.Ri);
1369
- const e = this.Ti.createTextureAtlas(this.Mi, this.ki, this.Fi, this.Ri);
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);
1370
1368
  this.Si = e.framebuffer, this.zi = e.columns, this.Pi = e.rows;
1371
1369
  }
1372
1370
  async Ui(t) {
1373
1371
  try {
1374
1372
  const e = await fetch(t);
1375
- if (!e.ok) throw new E(`Failed to load font file: ${e.status} ${e.statusText}`);
1373
+ if (!e.ok) throw new v(`Failed to load font file: ${e.status} ${e.statusText}`);
1376
1374
  const i = await e.arrayBuffer();
1377
1375
  await this.Di(i);
1378
1376
  const s = A.parse(i);
1379
1377
  if (!s || s.length === 0) throw Error("Failed to parse font file");
1380
1378
  this.Ri = s[0], await this.Wi();
1381
1379
  } catch (e) {
1382
- throw new E("Failed to load font: " + (e instanceof Error ? e.message : "Unknown error"), e);
1380
+ throw new v("Failed to load font: " + (e instanceof Error ? e.message : "Unknown error"), e);
1383
1381
  }
1384
1382
  }
1385
1383
  async Di(t) {
1386
1384
  const e = Date.now();
1387
- this.Gi = new FontFace("CustomFont_" + e, t), await this.Gi.load(), document.fonts.add(this.Gi);
1385
+ this.Ti = new FontFace("CustomFont_" + e, t), await this.Ti.load(), document.fonts.add(this.Ti);
1388
1386
  }
1389
1387
  async Wi() {
1390
- const t = this.Ai.extractCharacters(this.Ri), e = this.Ai.filterProblematicCharacters(t);
1391
- this.Mi = this.Li.createCharacterObjects(e, this.Ri), this.ki = this.Ei.calculateMaxGlyphDimensions(e, this.Fi, this.Ri);
1392
- const i = this.Ti.createTextureAtlas(this.Mi, this.ki, this.Fi, this.Ri);
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);
1393
1391
  this.Si = i.framebuffer, this.zi = i.columns, this.Pi = i.rows;
1394
1392
  }
1395
- bi(t) {
1396
- return this.Li.bi(t, this.Mi);
1397
- }
1398
1393
  xi(t) {
1399
- return this.Li.xi(t, this.Mi);
1394
+ return this.Ei.xi(t, this.Mi);
1395
+ }
1396
+ bi(t) {
1397
+ return this.Ei.bi(t, this.Mi);
1400
1398
  }
1401
1399
  Ut() {
1402
- this.Si.Ut(), document.fonts.delete(this.Gi);
1400
+ this.Si.Ut(), document.fonts.delete(this.Ti);
1403
1401
  }
1404
1402
  get fontFramebuffer() {
1405
1403
  return this.Si;
@@ -1423,13 +1421,13 @@ class Ft {
1423
1421
  return this.Ri;
1424
1422
  }
1425
1423
  }
1426
- class Lt {
1424
+ class St {
1427
1425
  constructor(t, e, i) {
1428
1426
  h(this, "Oi");
1429
- h(this, "Hi");
1427
+ h(this, "Vi");
1430
1428
  h(this, "$t");
1431
1429
  h(this, "wt");
1432
- h(this, "Vi");
1430
+ h(this, "Hi");
1433
1431
  h(this, "Ki");
1434
1432
  h(this, "Ni");
1435
1433
  h(this, "Xi");
@@ -1437,7 +1435,7 @@ class Lt {
1437
1435
  this.Ni = t, this.Xi = e, this.ji = i, this.rt();
1438
1436
  }
1439
1437
  rt() {
1440
- this.Oi = Math.floor(this.Ni.width / this.Xi), this.Hi = Math.floor(this.Ni.height / this.ji), this.$t = this.Oi * this.Xi, this.wt = this.Hi * this.ji, this.Vi = Math.floor((this.Ni.width - this.$t) / 2), this.Ki = Math.floor((this.Ni.height - this.wt) / 2);
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);
1441
1439
  }
1442
1440
  Yi(t, e) {
1443
1441
  this.Xi = t, this.ji = e, this.rt();
@@ -1452,7 +1450,7 @@ class Lt {
1452
1450
  return this.Oi;
1453
1451
  }
1454
1452
  get rows() {
1455
- return this.Hi;
1453
+ return this.Vi;
1456
1454
  }
1457
1455
  get width() {
1458
1456
  return this.$t;
@@ -1461,29 +1459,29 @@ class Lt {
1461
1459
  return this.wt;
1462
1460
  }
1463
1461
  get offsetX() {
1464
- return this.Vi;
1462
+ return this.Hi;
1465
1463
  }
1466
1464
  get offsetY() {
1467
1465
  return this.Ki;
1468
1466
  }
1469
1467
  }
1470
- class St {
1468
+ class Mt {
1471
1469
  constructor(t = {}) {
1472
1470
  h(this, "Ni");
1473
1471
  h(this, "qi");
1474
1472
  h(this, "Zi");
1475
- t.canvas ? (this.Ni = t.canvas, this.Zi = !1) : (this.Ni = this.Qi(t.width, t.height), this.Zi = !0), this.Ni.style.imageRendering = "pixelated";
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";
1476
1474
  }
1477
- Qi(t, e) {
1475
+ Ji(t, e) {
1478
1476
  const i = document.createElement("canvas");
1479
1477
  return i.className = "textmodeCanvas", i.style.imageRendering = "pixelated", i.width = t || 800, i.height = e || 600, document.body.appendChild(i), i;
1480
1478
  }
1481
- Ji(t, e) {
1479
+ Qi(t, e) {
1482
1480
  this.Ni.width = t ?? this.Ni.width, this.Ni.height = e ?? this.Ni.height;
1483
1481
  }
1484
1482
  tr() {
1485
1483
  const t = this.Ni.getContext("webgl2", { alpha: !0, premultipliedAlpha: !1, preserveDrawingBuffer: !0, antialias: !1, depth: !1, stencil: !1, powerPreference: "high-performance" });
1486
- if (!t) throw new E("`textmode.js` requires WebGL2 support.");
1484
+ if (!t) throw new v("`textmode.js` requires WebGL2 support.");
1487
1485
  return t;
1488
1486
  }
1489
1487
  Ut() {
@@ -1505,7 +1503,7 @@ class St {
1505
1503
  return this.Ni.height;
1506
1504
  }
1507
1505
  }
1508
- class Mt {
1506
+ class Lt {
1509
1507
  constructor(t = 60) {
1510
1508
  h(this, "er");
1511
1509
  h(this, "sr");
@@ -1609,18 +1607,18 @@ class Ut {
1609
1607
  kr() {
1610
1608
  return this._r;
1611
1609
  }
1612
- Gr() {
1610
+ Tr() {
1613
1611
  return this.pr;
1614
1612
  }
1615
- Ar() {
1613
+ Gr() {
1616
1614
  const t = [];
1617
1615
  for (const [e, i] of this.dr) i.isPressed && t.push(e);
1618
1616
  return t;
1619
1617
  }
1620
- Tr() {
1618
+ Ar() {
1621
1619
  return { ctrl: this.zr("Control"), shift: this.zr("Shift"), alt: this.zr("Alt"), meta: this.zr("Meta") };
1622
1620
  }
1623
- Er() {
1621
+ Lr() {
1624
1622
  this.dr.clear(), this._r = null, this.pr = null;
1625
1623
  }
1626
1624
  br(t) {
@@ -1648,15 +1646,15 @@ class Ut {
1648
1646
  class Bt {
1649
1647
  constructor(t) {
1650
1648
  h(this, "Ni");
1651
- h(this, "Lr");
1649
+ h(this, "Er");
1652
1650
  h(this, "Br", { x: -1, y: -1 });
1653
1651
  h(this, "Dr", { x: -1, y: -1 });
1654
1652
  h(this, "Wr", null);
1655
1653
  h(this, "Ir");
1656
1654
  h(this, "Ur");
1657
1655
  h(this, "Or");
1658
- h(this, "Hr");
1659
1656
  h(this, "Vr");
1657
+ h(this, "Hr");
1660
1658
  h(this, "Kr");
1661
1659
  h(this, "vr", !1);
1662
1660
  h(this, "Nr");
@@ -1667,36 +1665,36 @@ class Bt {
1667
1665
  this.Ni = t;
1668
1666
  }
1669
1667
  Bi(t) {
1670
- this.Lr = t, this.Zr();
1668
+ this.Er = t, this.Zr();
1671
1669
  }
1672
1670
  wr() {
1673
1671
  if (this.vr) return;
1674
1672
  const t = this.Ni.canvas;
1675
1673
  this.Ir = (e) => {
1676
- this.Qr(e), this.Jr(e);
1674
+ this.Jr(e), this.Qr(e);
1677
1675
  }, this.Ur = () => {
1678
1676
  this.Dr = { ...this.Br }, this.Br.x = -1, this.Br.y = -1, this.Wr = null;
1679
1677
  }, this.Or = (e) => {
1680
- this.Qr(e), this.tn(e);
1681
- }, this.Hr = (e) => {
1682
- this.Qr(e), this.en(e);
1678
+ this.Jr(e), this.tn(e);
1683
1679
  }, this.Vr = (e) => {
1684
- this.Qr(e), this.sn(e);
1680
+ this.Jr(e), this.en(e);
1681
+ }, this.Hr = (e) => {
1682
+ this.Jr(e), this.sn(e);
1685
1683
  }, this.Kr = (e) => {
1686
- this.Qr(e), this.rn(e);
1687
- }, 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.Hr, { passive: !0 }), t.addEventListener("click", this.Vr, { passive: !0 }), t.addEventListener("wheel", this.Kr, { passive: !1 }), this.vr = !0;
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;
1688
1686
  }
1689
1687
  Mr() {
1690
1688
  if (!this.vr) return;
1691
1689
  const t = this.Ni.canvas;
1692
- t.removeEventListener("mousemove", this.Ir), t.removeEventListener("mouseleave", this.Ur), t.removeEventListener("mousedown", this.Or), t.removeEventListener("mouseup", this.Hr), t.removeEventListener("click", this.Vr), t.removeEventListener("wheel", this.Kr), this.vr = !1;
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;
1693
1691
  }
1694
1692
  Zr() {
1695
1693
  if (this.vr) try {
1696
1694
  if (this.Wr) {
1697
1695
  const t = new MouseEvent("mousemove", { clientX: this.Wr.x, clientY: this.Wr.y, bubbles: !1, cancelable: !1 });
1698
- this.Qr(t);
1699
- } else this.Br.x !== -1 && this.Br.y !== -1 && (this.Br.x >= this.Lr.cols || this.Br.y >= this.Lr.rows) && (this.Br.x = -1, this.Br.y = -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);
1700
1698
  } catch {
1701
1699
  this.Br.x = -1, this.Br.y = -1;
1702
1700
  }
@@ -1719,7 +1717,7 @@ class Bt {
1719
1717
  cn() {
1720
1718
  return { x: this.Br.x, y: this.Br.y };
1721
1719
  }
1722
- Jr(t) {
1720
+ Qr(t) {
1723
1721
  if (this.Yr) {
1724
1722
  const e = { position: { ...this.Br }, previousPosition: { ...this.Dr }, originalEvent: t };
1725
1723
  this.Yr(e);
@@ -1749,11 +1747,11 @@ class Bt {
1749
1747
  this.qr(e);
1750
1748
  }
1751
1749
  }
1752
- Qr(t) {
1750
+ Jr(t) {
1753
1751
  const e = this.Ni.canvas;
1754
1752
  this.Dr = { ...this.Br }, this.Wr = { x: t.clientX, y: t.clientY };
1755
- 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.Lr.offsetX, l = o - this.Lr.offsetY, f = Math.floor(c / this.Lr.cellWidth), u = Math.floor(l / this.Lr.cellHeight);
1756
- f >= 0 && f < this.Lr.cols && u >= 0 && u < this.Lr.rows ? (this.Br.x = f, this.Br.y = u) : (this.Br.x = -1, this.Br.y = -1);
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);
1757
1755
  }
1758
1756
  }
1759
1757
  const Dt = (a) => class extends a {
@@ -1776,13 +1774,13 @@ const Dt = (a) => class extends a {
1776
1774
  this.Pt.state.it();
1777
1775
  }
1778
1776
  rect(t, e, i = 1, s = 1) {
1779
- this.Pt.As(t, e, i, s);
1777
+ this.Pt.Gs(t, e, i, s);
1780
1778
  }
1781
1779
  point(t, e) {
1782
- this.Pt.As(t, e, 1, 1);
1780
+ this.Pt.Gs(t, e, 1, 1);
1783
1781
  }
1784
1782
  line(t, e, i, s) {
1785
- this.Pt.Ts(t, e, i, s);
1783
+ this.Pt.As(t, e, i, s);
1786
1784
  }
1787
1785
  lineWeight(t) {
1788
1786
  this.Pt.state.ot(t);
@@ -1791,7 +1789,7 @@ const Dt = (a) => class extends a {
1791
1789
  this.Pt.Is(t, e, i, s);
1792
1790
  }
1793
1791
  char(t) {
1794
- this.Pt.state.ut(this.Ri.bi(t));
1792
+ this.Pt.state.ut(this.Ri.xi(t));
1795
1793
  }
1796
1794
  charColor(t, e, i) {
1797
1795
  this.Pt.state.ft(t, e, i);
@@ -1815,10 +1813,10 @@ const Dt = (a) => class extends a {
1815
1813
  this.Pt.Is(0, 0, 0, 0);
1816
1814
  }
1817
1815
  ellipse(t, e, i, s) {
1818
- this.Pt.Es(t, e, i / 2, s / 2);
1816
+ this.Pt.Ls(t, e, i / 2, s / 2);
1819
1817
  }
1820
1818
  triangle(t, e, i, s, r, n) {
1821
- this.Pt.Ls(t, e, i, s, r, n);
1819
+ this.Pt.Es(t, e, i, s, r, n);
1822
1820
  }
1823
1821
  bezierCurve(t, e, i, s, r, n, o, c) {
1824
1822
  this.Pt.Bs(t, e, i, s, r, n, o, c);
@@ -1847,8 +1845,8 @@ const Dt = (a) => class extends a {
1847
1845
  };
1848
1846
  class O {
1849
1847
  ln(t) {
1850
- const e = t.Lt(0), i = t.Lt(1), s = t.Lt(2), r = t.Lt(3);
1851
- return { characterPixels: e, primaryColorPixels: i, secondaryColorPixels: s, transformPixels: t.Lt(4), rotationPixels: r };
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 };
1852
1850
  }
1853
1851
  un(t, e) {
1854
1852
  return t[e] + (t[e + 1] << 8);
@@ -1932,11 +1930,11 @@ class Nt {
1932
1930
  }
1933
1931
  return 0;
1934
1932
  }
1935
- bn(t, e, i, s, r) {
1933
+ xn(t, e, i, s, r) {
1936
1934
  const n = r / t.head.unitsPerEm;
1937
- return { getBoundingBox: () => ({ x1: i + e.xMin * n, y1: s + -e.yMax * n, x2: i + e.xMax * n, y2: s + -e.yMin * n }), toSVG: () => this.xn(e, i, s, n) };
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) };
1938
1936
  }
1939
- xn(t, e, i, s) {
1937
+ bn(t, e, i, s) {
1940
1938
  if (!t || !t.xs) return "";
1941
1939
  const { xs: r, ys: n, endPts: o, flags: c } = t;
1942
1940
  if (!(r && n && o && c)) return "";
@@ -1950,17 +1948,17 @@ class Nt {
1950
1948
  let m = f + 1;
1951
1949
  for (; m <= d; )
1952
1950
  if (1 & c[m]) {
1953
- const b = e + r[m] * s, v = i - n[m] * s;
1954
- l += `L${b.toFixed(2)},${v.toFixed(2)}`, m++;
1951
+ const x = e + r[m] * s, R = i - n[m] * s;
1952
+ l += `L${x.toFixed(2)},${R.toFixed(2)}`, m++;
1955
1953
  } else {
1956
- const b = e + r[m] * s, v = i - n[m] * s;
1954
+ const x = e + r[m] * s, R = i - n[m] * s;
1957
1955
  let w = m + 1 > d ? f : m + 1;
1958
1956
  if (1 & c[w]) {
1959
- const C = e + r[w] * s, L = i - n[w] * s;
1960
- l += `Q${b.toFixed(2)},${v.toFixed(2)} ${C.toFixed(2)},${L.toFixed(2)}`, m = w + 1;
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;
1961
1959
  } else {
1962
- const C = (b + (e + r[w] * s)) / 2, L = (v + (i - n[w] * s)) / 2;
1963
- l += `Q${b.toFixed(2)},${v.toFixed(2)} ${C.toFixed(2)},${L.toFixed(2)}`, m = w;
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;
1964
1962
  }
1965
1963
  }
1966
1964
  l += "Z";
@@ -1973,7 +1971,7 @@ class Nt {
1973
1971
  Rn(t, e, i, s, r) {
1974
1972
  const n = t.codePointAt(0) || 0, o = this.wn(e, n);
1975
1973
  let c = null;
1976
- return e.glyf && e.glyf[o] !== null ? c = e.glyf[o] : (c = A.T.glyf.Os(e, o), e.glyf[o] = c), this.bn(e, c, i, s, r);
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);
1977
1975
  }
1978
1976
  Mn(t, e, i, s, r, n, o, c) {
1979
1977
  const l = i + (r - c * (o / e.head.unitsPerEm)) / 2, f = s + (n + 0.7 * o) / 2;
@@ -2007,7 +2005,7 @@ class zt {
2007
2005
  }
2008
2006
  return i.rotation && o.push(`rotate(${i.rotation} ${r} ${n})`), ` transform="${o.join(" ")}"`;
2009
2007
  }
2010
- Gn(t, e, i) {
2008
+ Tn(t, e, i) {
2011
2009
  if (!i.includeBackgroundRectangles || t.secondaryColor.a === 0) return "";
2012
2010
  const { position: s } = t, { r, g: n, b: o, a: c } = t.secondaryColor, l = `rgba(${r},${n},${o},${c / 255})`;
2013
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}"/>`;
@@ -2020,8 +2018,8 @@ class zt {
2020
2018
  const { r: o, g: c, b: l, a: f } = t.primaryColor, u = `rgba(${o},${c},${l},${f / 255})`;
2021
2019
  return s.drawMode === "stroke" ? `<path d="${n}" stroke="${u}" stroke-width="${s.strokeWidth}" fill="none"/>` : `<path d="${n}" fill="${u}"/>`;
2022
2020
  }
2023
- An(t, e, i, s) {
2024
- const r = [], n = this.Gn(t, e, s);
2021
+ Gn(t, e, i, s) {
2022
+ const r = [], n = this.Tn(t, e, s);
2025
2023
  n && r.push(n);
2026
2024
  const o = this.Rn(t, e, i, s);
2027
2025
  if (o) {
@@ -2030,17 +2028,17 @@ class zt {
2030
2028
  }
2031
2029
  return r.join("");
2032
2030
  }
2033
- Tn(t, e, i, s) {
2031
+ An(t, e, i, s) {
2034
2032
  const r = [this.Fn(e), this.Pn(e, s), '<g id="ascii-cells">'];
2035
- for (const n of t) r.push(this.An(n, e, i, s));
2033
+ for (const n of t) r.push(this.Gn(n, e, i, s));
2036
2034
  return r.push(this.zn()), r.join("");
2037
2035
  }
2038
- En(t) {
2036
+ Ln(t) {
2039
2037
  return t.replace(/<path[^>]*d=""[^>]*\/>/g, "").replace(/\s+/g, " ").replace(/> </g, "><");
2040
2038
  }
2041
2039
  }
2042
2040
  class Gt extends W {
2043
- Ln(t) {
2041
+ En(t) {
2044
2042
  return this.dn(t, "image/svg+xml;charset=utf-8");
2045
2043
  }
2046
2044
  Bn(t, e) {
@@ -2050,7 +2048,7 @@ class Gt extends W {
2050
2048
  this.Bn(t, e || this.vn());
2051
2049
  }
2052
2050
  }
2053
- class Y {
2051
+ class V {
2054
2052
  constructor() {
2055
2053
  h(this, "Wn");
2056
2054
  h(this, "In");
@@ -2060,16 +2058,16 @@ class Y {
2060
2058
  On(t) {
2061
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() };
2062
2060
  }
2063
- Hn(t, e = {}) {
2064
- const i = this.Wn.$n(this.Wn.ln(t.pipeline), t.grid), s = this.In.Tn(i, t.grid, t.font, this.On(e));
2065
- return this.In.En(s);
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);
2066
2064
  }
2067
2065
  Dn(t, e = {}) {
2068
- this.Un.Dn(this.Hn(t, e), e.filename);
2066
+ this.Un.Dn(this.Vn(t, e), e.filename);
2069
2067
  }
2070
2068
  }
2071
2069
  class Ot extends O {
2072
- Vn(t, e, i, s = " ") {
2070
+ Hn(t, e, i, s = " ") {
2073
2071
  var o;
2074
2072
  const r = [];
2075
2073
  let n = 0;
@@ -2107,7 +2105,7 @@ class $t extends W {
2107
2105
  return e === ".txt" || e.length <= 4 ? this.vn() : e;
2108
2106
  }
2109
2107
  }
2110
- class V {
2108
+ class H {
2111
2109
  constructor() {
2112
2110
  h(this, "Wn");
2113
2111
  h(this, "In");
@@ -2118,7 +2116,7 @@ class V {
2118
2116
  return { preserveTrailingSpaces: t.preserveTrailingSpaces ?? !1, lineEnding: t.lineEnding ?? "lf", emptyCharacter: t.emptyCharacter ?? " ", filename: t.filename || this.Un.vn() };
2119
2117
  }
2120
2118
  jn(t, e = {}) {
2121
- const i = this.On(e), s = this.Wn.Vn(this.Wn.ln(t.pipeline), t.grid, t.font, i.emptyCharacter);
2119
+ const i = this.On(e), s = this.Wn.Hn(this.Wn.ln(t.pipeline), t.grid, t.font, i.emptyCharacter);
2122
2120
  return this.In.Kn(s, i);
2123
2121
  }
2124
2122
  Nn(t, e = {}) {
@@ -2138,7 +2136,7 @@ class Xt {
2138
2136
  const i = this.Zn(e.format);
2139
2137
  return e.format === "png" ? t.toDataURL(i) : t.toDataURL(i, e.quality);
2140
2138
  }
2141
- async Qn(t, e) {
2139
+ async Jn(t, e) {
2142
2140
  return new Promise((i, s) => {
2143
2141
  const r = this.Zn(e.format), n = (o) => {
2144
2142
  o ? i(o) : s(Error(`Failed to generate ${e.format.toUpperCase()} blob`));
@@ -2159,9 +2157,9 @@ class Xt {
2159
2157
  }
2160
2158
  }
2161
2159
  }
2162
- const Ht = { png: "image/png", jpg: "image/jpeg", webp: "image/webp" }, j = { png: ".png", jpg: ".jpg", webp: ".webp" };
2163
- class Yt extends W {
2164
- Jn(t, e, i) {
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) {
2165
2163
  this.eo(t, this.mn(e) + j[i]);
2166
2164
  }
2167
2165
  eo(t, e) {
@@ -2174,15 +2172,15 @@ class Yt extends W {
2174
2172
  }
2175
2173
  }
2176
2174
  so(t) {
2177
- return t in Ht && t in j;
2175
+ return t in Yt && t in j;
2178
2176
  }
2179
2177
  }
2180
- class Vt {
2178
+ class Ht {
2181
2179
  constructor() {
2182
2180
  h(this, "Wn");
2183
2181
  h(this, "In");
2184
2182
  h(this, "Un");
2185
- this.Wn = new kt(), this.In = new Xt(), this.Un = new Yt();
2183
+ this.Wn = new kt(), this.In = new Xt(), this.Un = new Vt();
2186
2184
  }
2187
2185
  On(t) {
2188
2186
  return { format: t.format ?? "png", quality: t.quality ?? 1, scale: t.scale ?? 1, backgroundColor: t.backgroundColor ?? "transparent", filename: t.filename || this.Un.vn() };
@@ -2193,16 +2191,16 @@ class Vt {
2193
2191
  if (t.scale <= 0) throw Error("Scale factor must be greater than 0");
2194
2192
  t.format === "jpg" && t.backgroundColor === "transparent" && (t.backgroundColor = "black");
2195
2193
  }
2196
- async Qn(t, e) {
2197
- if (e.scale === 1 && e.backgroundColor === "transparent") return await this.In.Qn(t.canvas, e);
2194
+ async Jn(t, e) {
2195
+ if (e.scale === 1 && e.backgroundColor === "transparent") return await this.In.Jn(t.canvas, e);
2198
2196
  const i = this.Wn.Yn(t, e.scale, e.backgroundColor);
2199
- return await this.In.Qn(i, e);
2197
+ return await this.In.Jn(i, e);
2200
2198
  }
2201
- async Jn(t, e = {}) {
2199
+ async Qn(t, e = {}) {
2202
2200
  const i = this.On(e);
2203
2201
  this.io(i);
2204
- const s = await this.Qn(t, i);
2205
- this.Un.Jn(s, i.filename, i.format);
2202
+ const s = await this.Jn(t, i);
2203
+ this.Un.Qn(s, i.filename, i.format);
2206
2204
  }
2207
2205
  }
2208
2206
  const jt = (a) => class extends a {
@@ -2210,32 +2208,32 @@ const jt = (a) => class extends a {
2210
2208
  this.Pt.Dt(this.no);
2211
2209
  }
2212
2210
  toString(t = {}) {
2213
- return this.ro(), new V().jn({ pipeline: this.oo, grid: this.Lr, font: this.Ri }, t);
2211
+ return this.ro(), new H().jn({ pipeline: this.oo, grid: this.Er, font: this.Ri }, t);
2214
2212
  }
2215
2213
  saveStrings(t = {}) {
2216
- this.ro(), new V().Nn({ pipeline: this.oo, grid: this.Lr, font: this.Ri }, t);
2214
+ this.ro(), new H().Nn({ pipeline: this.oo, grid: this.Er, font: this.Ri }, t);
2217
2215
  }
2218
2216
  toSVG(t = {}) {
2219
- return this.ro(), new Y().Hn({ pipeline: this.oo, grid: this.Lr, font: this.Ri }, t);
2217
+ return this.ro(), new V().Vn({ pipeline: this.oo, grid: this.Er, font: this.Ri }, t);
2220
2218
  }
2221
2219
  saveSVG(t = {}) {
2222
- this.ro(), new Y().Dn({ pipeline: this.oo, grid: this.Lr, font: this.Ri }, t);
2220
+ this.ro(), new V().Dn({ pipeline: this.oo, grid: this.Er, font: this.Ri }, t);
2223
2221
  }
2224
2222
  async saveCanvas(t = {}) {
2225
- await new Vt().Jn(this.Ni, t);
2223
+ await new Ht().Qn(this.Ni, t);
2226
2224
  }
2227
2225
  }, Kt = (a) => class extends a {
2228
2226
  async loadFont(t) {
2229
2227
  return this.Ri.Ui(t).then(() => {
2230
2228
  const e = this.Ri.maxGlyphDimensions;
2231
- this.Lr.Yi(e.width, e.height), this.oo.resize(this.Lr.cols, this.Lr.rows), this.Pt.Us(), this.ao.Zr();
2229
+ this.Er.Yi(e.width, e.height), this.oo.resize(this.Er.cols, this.Er.rows), this.Pt.Us(), this.ao.Zr();
2232
2230
  });
2233
2231
  }
2234
2232
  fontSize(t) {
2235
- if (!M.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;
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;
2236
2234
  this.Ri.Ii(t);
2237
2235
  const e = this.Ri.maxGlyphDimensions;
2238
- this.Lr.Yi(e.width, e.height), this.oo.resize(this.Lr.cols, this.Lr.rows), this.Pt.Us(), this.ao.Zr();
2236
+ this.Er.Yi(e.width, e.height), this.oo.resize(this.Er.cols, this.Er.rows), this.Pt.Us(), this.ao.Zr();
2239
2237
  }
2240
2238
  }, Zt = (a) => class extends a {
2241
2239
  get frameCount() {
@@ -2254,7 +2252,7 @@ const jt = (a) => class extends a {
2254
2252
  this.ho.resume(() => this.co());
2255
2253
  }
2256
2254
  redraw(t = 1) {
2257
- 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.co();
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();
2258
2256
  }
2259
2257
  isLooping() {
2260
2258
  return this.ho.isLooping;
@@ -2281,7 +2279,7 @@ const jt = (a) => class extends a {
2281
2279
  get mouse() {
2282
2280
  return this.ao.cn();
2283
2281
  }
2284
- }, Qt = (a) => class extends a {
2282
+ }, Jt = (a) => class extends a {
2285
2283
  constructor(...t) {
2286
2284
  super(...t);
2287
2285
  }
@@ -2294,28 +2292,25 @@ const jt = (a) => class extends a {
2294
2292
  isKeyPressed(t) {
2295
2293
  return this.lo.zr(t);
2296
2294
  }
2297
- clearKeyStates() {
2298
- this.lo.Er();
2299
- }
2300
2295
  get lastKeyPressed() {
2301
2296
  return this.lo.kr();
2302
2297
  }
2303
2298
  get lastKeyReleased() {
2304
- return this.lo.Gr();
2299
+ return this.lo.Tr();
2305
2300
  }
2306
2301
  get pressedKeys() {
2307
- return this.lo.Ar();
2302
+ return this.lo.Gr();
2308
2303
  }
2309
2304
  get modifierState() {
2310
- return this.lo.Tr();
2305
+ return this.lo.Ar();
2311
2306
  }
2312
2307
  };
2313
- class Jt {
2308
+ class Qt {
2314
2309
  constructor() {
2315
2310
  h(this, "Pt");
2316
2311
  h(this, "Ri");
2317
2312
  h(this, "Ni");
2318
- h(this, "Lr");
2313
+ h(this, "Er");
2319
2314
  h(this, "ho");
2320
2315
  h(this, "ao");
2321
2316
  h(this, "lo");
@@ -2328,7 +2323,7 @@ class Jt {
2328
2323
  }
2329
2324
  class te extends function(e, ...i) {
2330
2325
  return i.reduce((s, r) => r(s), e);
2331
- }(Jt, Dt, jt, Kt, Zt, qt, Qt) {
2326
+ }(Qt, Dt, jt, Kt, Zt, qt, Jt) {
2332
2327
  constructor(e = {}) {
2333
2328
  super();
2334
2329
  h(this, "fo", !1);
@@ -2339,25 +2334,25 @@ class te extends function(e, ...i) {
2339
2334
  h(this, "po", () => {
2340
2335
  });
2341
2336
  h(this, "mo");
2342
- this.Ni = new St(e), this.Pt = new Rt(this.Ni.tr()), this.Ri = new Ft(this.Pt, e.fontSize ?? 16), this.ho = new Mt(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);
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);
2343
2338
  }
2344
2339
  async vo(e) {
2345
2340
  await this.Ri.Bi(e.fontSource);
2346
2341
  const i = this.Ri.maxGlyphDimensions;
2347
- this.Lr = new Lt(this.Ni.canvas, i.width, i.height), this.ao.Bi(this.Lr), this.oo = this.Pt.Ds(this.Lr.cols, this.Lr.rows, 5), this.yo(), this.do(), this.ho.start(() => this.co());
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());
2348
2343
  }
2349
2344
  yo() {
2350
2345
  this.mo = () => {
2351
2346
  this.po();
2352
2347
  }, window.addEventListener("resize", this.mo), this.ao.wr(), this.lo.wr(), window.addEventListener("blur", () => {
2353
- this.lo.Er();
2348
+ this.lo.Lr();
2354
2349
  });
2355
2350
  }
2356
2351
  co() {
2357
2352
  if (this.ho.measureFrameRate(), this.ho.incrementFrame(), this.fo) return;
2358
2353
  this.oo.begin(), this.Pt.Ss(this.no), this._o(), this.Pt.Dt(this.no), this.oo.end();
2359
2354
  const e = this.Pt.state.canvasBackgroundColor;
2360
- 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.Lr.cols, this.Lr.rows], i: [this.Lr.width, this.Lr.height], j: [this.Lr.offsetX, this.Lr.offsetY], k: this.Lr.width / this.Lr.height }), this.Pt.Gs(this.Lr.offsetX, this.Lr.offsetY, this.Lr.width, this.Lr.height);
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);
2361
2356
  }
2362
2357
  setup(e) {
2363
2358
  this.do = e;
@@ -2369,13 +2364,13 @@ class te extends function(e, ...i) {
2369
2364
  this.po = e;
2370
2365
  }
2371
2366
  resizeCanvas(e, i) {
2372
- this.Ni.Ji(e, i), this.Lr.rt(), this.oo.resize(this.Lr.cols, this.Lr.rows), this.Pt.Us(), this.ao.Zr(), this.co();
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();
2373
2368
  }
2374
2369
  destroy() {
2375
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);
2376
2371
  }
2377
2372
  get grid() {
2378
- return this.Lr;
2373
+ return this.Er;
2379
2374
  }
2380
2375
  get font() {
2381
2376
  return this.Ri;
@@ -2403,19 +2398,19 @@ class $ {
2403
2398
  return new te(t);
2404
2399
  }
2405
2400
  static setErrorLevel(t) {
2406
- M.S(t);
2401
+ L.S(t);
2407
2402
  }
2408
2403
  static get version() {
2409
- return "0.2.1-beta.2";
2404
+ return "0.2.1-beta.3";
2410
2405
  }
2411
2406
  }
2412
2407
  const ie = Object.freeze(Object.defineProperty({ __proto__: null }, Symbol.toStringTag, { value: "Module" })), se = $.create, re = $.setErrorLevel, ne = $.version;
2413
2408
  export {
2414
- G as GLFramebuffer,
2415
- St as TextmodeCanvas,
2409
+ Mt as TextmodeCanvas,
2416
2410
  et as TextmodeErrorLevel,
2417
2411
  Ft as TextmodeFont,
2418
- Lt as TextmodeGrid,
2412
+ G as TextmodeFramebuffer,
2413
+ St as TextmodeGrid,
2419
2414
  te as Textmodifier,
2420
2415
  se as create,
2421
2416
  ie as export,