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

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