textmode.js 0.3.0 → 0.3.1

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 ct = Object.defineProperty;
2
- var lt = (h, t, e) => t in h ? ct(h, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : h[t] = e;
3
- var a = (h, t, e) => lt(h, typeof t != "symbol" ? t + "" : t, e);
1
+ var ft = Object.defineProperty;
2
+ var dt = (a, t, e) => t in a ? ft(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e;
3
+ var h = (a, t, e) => dt(a, typeof t != "symbol" ? t + "" : t, e);
4
4
  class _ extends Error {
5
5
  constructor(t, e = {}) {
6
6
  super(_.i(t, e)), this.name = "TextmodeError";
@@ -27,10 +27,10 @@ ${"↓".repeat(24)}
27
27
  return t + "";
28
28
  }
29
29
  }
30
- var ut = ((h) => (h[h.SILENT = 0] = "SILENT", h[h.WARNING = 1] = "WARNING", h[h.ERROR = 2] = "ERROR", h[h.THROW = 3] = "THROW", h))(ut || {});
30
+ var gt = ((a) => (a[a.SILENT = 0] = "SILENT", a[a.WARNING = 1] = "WARNING", a[a.ERROR = 2] = "ERROR", a[a.THROW = 3] = "THROW", a))(gt || {});
31
31
  const B = class B {
32
32
  constructor() {
33
- a(this, "u", { globalLevel: 3 });
33
+ h(this, "u", { globalLevel: 3 });
34
34
  }
35
35
  static _() {
36
36
  return B.l || (B.l = new B()), B.l;
@@ -55,46 +55,46 @@ const B = class B {
55
55
  this.u.globalLevel = t;
56
56
  }
57
57
  };
58
- a(B, "l", null);
59
- let K = B;
60
- const $ = K._(), ot = /* @__PURE__ */ new WeakMap();
61
- function W(h, t) {
62
- ot.set(h, t);
58
+ h(B, "l", null);
59
+ let V = B;
60
+ const O = V._(), ot = /* @__PURE__ */ new WeakMap();
61
+ function Y(a, t) {
62
+ ot.set(a, t);
63
63
  }
64
- function H(h) {
65
- return ot.get(h);
64
+ function X(a) {
65
+ return ot.get(a);
66
66
  }
67
67
  class ht {
68
68
  constructor() {
69
- a(this, "$", 1);
70
- a(this, "U", 0);
71
- a(this, "M", 0);
72
- a(this, "R", 0);
73
- a(this, "F", [0, 0, 0]);
74
- a(this, "S", [1, 1, 1, 1]);
75
- a(this, "A", [0, 0, 0, 1]);
76
- a(this, "L", !1);
77
- a(this, "P", !1);
78
- a(this, "k", !1);
79
- a(this, "G", [0, 0]);
80
- a(this, "D", [0, 0, 0, 1]);
81
- a(this, "I", []);
82
- }
83
- W() {
84
- this.I.push({ O: this.$, H: this.U, V: this.M, K: this.R, G: [...this.G], N: this.L, X: this.P, k: this.k, j: [...this.F], Y: [...this.S], q: [...this.A] });
69
+ h(this, "$", 1);
70
+ h(this, "U", 0);
71
+ h(this, "M", 0);
72
+ h(this, "S", 0);
73
+ h(this, "R", [0, 0, 0]);
74
+ h(this, "F", [1, 1, 1, 1]);
75
+ h(this, "A", [0, 0, 0, 1]);
76
+ h(this, "k", !1);
77
+ h(this, "P", !1);
78
+ h(this, "L", !1);
79
+ h(this, "D", [0, 0]);
80
+ h(this, "G", [0, 0, 0, 1]);
81
+ h(this, "I", []);
82
+ }
83
+ O() {
84
+ this.I.push({ W: this.$, H: this.U, X: this.M, V: this.S, D: [...this.D], K: this.k, j: this.P, L: this.L, N: [...this.R], Y: [...this.F], q: [...this.A] });
85
85
  }
86
86
  Z() {
87
87
  const t = this.I.pop();
88
- t ? (this.$ = t.O, this.U = t.H, this.M = t.V, this.R = t.K, this.G = t.G, this.L = t.N, this.P = t.X, this.k = t.k, this.F = t.j, this.S = t.Y, this.A = t.q) : console.warn("pop() called without matching push()");
88
+ t ? (this.$ = t.W, this.U = t.H, this.M = t.X, this.S = t.V, this.D = t.D, this.k = t.K, this.P = t.j, this.L = t.L, this.R = t.N, this.F = t.Y, this.A = t.q) : console.warn("pop() called without matching push()");
89
89
  }
90
90
  J(t) {
91
- t.O = this.$, t.H = this.U, t.V = this.M, t.K = this.R, t.j[0] = this.F[0], t.j[1] = this.F[1], t.j[2] = this.F[2], t.Y[0] = this.S[0], t.Y[1] = this.S[1], t.Y[2] = this.S[2], t.Y[3] = this.S[3], t.q[0] = this.A[0], t.q[1] = this.A[1], t.q[2] = this.A[2], t.q[3] = this.A[3], t.N = this.L, t.X = this.P, t.k = this.k, t.G[0] = this.G[0], t.G[1] = this.G[1];
91
+ t.W = this.$, t.H = this.U, t.X = this.M, t.V = this.S, t.N[0] = this.R[0], t.N[1] = this.R[1], t.N[2] = this.R[2], t.Y[0] = this.F[0], t.Y[1] = this.F[1], t.Y[2] = this.F[2], t.Y[3] = this.F[3], t.q[0] = this.A[0], t.q[1] = this.A[1], t.q[2] = this.A[2], t.q[3] = this.A[3], t.K = this.k, t.j = this.P, t.L = this.L, t.D[0] = this.D[0], t.D[1] = this.D[1];
92
92
  }
93
93
  get lineWeight() {
94
94
  return this.$;
95
95
  }
96
96
  get canvasBackgroundColor() {
97
- return this.D;
97
+ return this.G;
98
98
  }
99
99
  tt(t) {
100
100
  this.$ = Math.abs(t);
@@ -106,54 +106,54 @@ class ht {
106
106
  this.M = t;
107
107
  }
108
108
  it(t) {
109
- this.R = t;
109
+ this.S = t;
110
110
  }
111
111
  rt(t) {
112
- this.F = t;
112
+ this.R = t;
113
113
  }
114
114
  nt(t, e, i, s = 255) {
115
- this.S = [t / 255, e / 255, i / 255, s / 255];
115
+ this.F = [t / 255, e / 255, i / 255, s / 255];
116
116
  }
117
117
  ot(t, e, i, s = 255) {
118
118
  this.A = [t / 255, e / 255, i / 255, s / 255];
119
119
  }
120
120
  ht(t) {
121
- this.L = t;
121
+ this.k = t;
122
122
  }
123
123
  ct(t) {
124
124
  this.P = t;
125
125
  }
126
126
  lt(t) {
127
- this.k = t;
127
+ this.L = t;
128
128
  }
129
129
  ut(t) {
130
130
  const e = 255 * t / 360, i = Math.floor(e) / 255, s = Math.round(e - Math.floor(e));
131
- this.G = [i, s];
131
+ this.D = [i, s];
132
132
  }
133
133
  ft(t, e, i, s) {
134
- this.D = [t / 255, e / 255, i / 255, s / 255];
134
+ this.G = [t / 255, e / 255, i / 255, s / 255];
135
135
  }
136
136
  }
137
- class j {
137
+ class K {
138
138
  constructor(t, e, i = e, s = 1, r = {}, n = null, o = !1) {
139
- a(this, "dt");
140
- a(this, "_t");
141
- a(this, "u");
142
- a(this, "gt", null);
143
- a(this, "vt");
144
- a(this, "yt");
145
- a(this, "Ct", []);
146
- a(this, "wt");
147
- a(this, "$t", null);
148
- a(this, "bt", []);
149
- a(this, "xt", null);
150
- a(this, "Mt", !1);
151
- a(this, "Rt", null);
152
- this.dt = e, this._t = i, this.u = { filter: "nearest", wrap: "clamp", format: "rgba", type: "unsigned_byte", ...r }, this.vt = t, this.wt = Math.min(Math.max(1, s), 8), this.xt = n, this.Mt = !!o, this.Rt = this.Mt ? new ht() : null;
139
+ h(this, "dt");
140
+ h(this, "_t");
141
+ h(this, "u");
142
+ h(this, "gt", null);
143
+ h(this, "vt");
144
+ h(this, "yt");
145
+ h(this, "Ct", []);
146
+ h(this, "wt");
147
+ h(this, "$t", null);
148
+ h(this, "bt", []);
149
+ h(this, "xt", null);
150
+ h(this, "Mt", !1);
151
+ h(this, "St", null);
152
+ this.dt = e, this._t = i, this.u = { filter: "nearest", wrap: "clamp", format: "rgba", type: "unsigned_byte", ...r }, this.vt = t, this.wt = Math.min(Math.max(1, s), 8), this.xt = n, this.Mt = !!o, this.St = this.Mt ? new ht() : null;
153
153
  const c = t.getParameter(t.MAX_DRAW_BUFFERS), l = t.getParameter(t.MAX_COLOR_ATTACHMENTS);
154
- this.wt = Math.min(this.wt, c, l), this.yt = t.createFramebuffer(), this.Ft(), this.St(), this.bt = Array(this.wt).fill(null);
154
+ this.wt = Math.min(this.wt, c, l), this.yt = t.createFramebuffer(), this.Rt(), this.Ft(), this.bt = Array(this.wt).fill(null);
155
155
  }
156
- Ft() {
156
+ Rt() {
157
157
  const t = this.vt, e = this.u.filter === "linear" ? t.LINEAR : t.NEAREST, i = this.u.wrap === "repeat" ? t.REPEAT : t.CLAMP_TO_EDGE, s = this.u.type === "float" ? t.FLOAT : t.UNSIGNED_BYTE;
158
158
  for (let r = 0; r < this.wt; r++) {
159
159
  const n = t.createTexture();
@@ -161,7 +161,7 @@ class j {
161
161
  }
162
162
  t.bindTexture(t.TEXTURE_2D, null);
163
163
  }
164
- St() {
164
+ Ft() {
165
165
  const t = this.vt;
166
166
  if (t.bindFramebuffer(t.FRAMEBUFFER, this.yt), this.wt === 1) t.framebufferTexture2D(t.FRAMEBUFFER, t.COLOR_ATTACHMENT0, t.TEXTURE_2D, this.Ct[0], 0);
167
167
  else {
@@ -175,7 +175,7 @@ class j {
175
175
  const e = t.checkFramebufferStatus(t.FRAMEBUFFER);
176
176
  e !== t.FRAMEBUFFER_COMPLETE && console.error("GLFramebuffer is not complete:", e), t.bindFramebuffer(t.FRAMEBUFFER, null);
177
177
  }
178
- At(t) {
178
+ Tt(t) {
179
179
  const e = this.vt;
180
180
  e.bindTexture(e.TEXTURE_2D, this.Ct[0]), e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL, 1), e.texImage2D(e.TEXTURE_2D, 0, e.RGBA, e.RGBA, e.UNSIGNED_BYTE, t), e.bindTexture(e.TEXTURE_2D, null);
181
181
  }
@@ -185,7 +185,7 @@ class j {
185
185
  for (const r of this.Ct) i.bindTexture(i.TEXTURE_2D, r), i.texImage2D(i.TEXTURE_2D, 0, i.RGBA, this.dt, this._t, 0, i.RGBA, s, null);
186
186
  i.bindTexture(i.TEXTURE_2D, null);
187
187
  }
188
- zt(t) {
188
+ At(t) {
189
189
  const e = this.vt, i = this.bt[t];
190
190
  if (i) return i;
191
191
  const s = this.dt, r = this._t, n = new Uint8Array(s * r * 4), o = e.getParameter(e.READ_FRAMEBUFFER_BINDING);
@@ -201,24 +201,24 @@ class j {
201
201
  var e, i, s, r;
202
202
  const t = this.vt;
203
203
  if (this.xt) {
204
- const n = ((i = (e = this.xt).Tt) == null ? void 0 : i.call(e)) ?? null;
205
- n && this.xt.Et(n), this.Mt && this.Rt && ((r = (s = this.xt).Lt) == null || r.call(s, this.Rt));
204
+ const n = ((i = (e = this.xt).Et) == null ? void 0 : i.call(e)) ?? null;
205
+ n && this.xt.kt(n), this.Mt && this.St && ((r = (s = this.xt).zt) == null || r.call(s, this.St));
206
206
  }
207
207
  this.$t = { framebuffer: t.getParameter(t.FRAMEBUFFER_BINDING), viewport: t.getParameter(t.VIEWPORT) }, t.bindFramebuffer(t.FRAMEBUFFER, this.yt), this.bt = Array(this.wt).fill(null);
208
208
  for (let n = 0; n < this.wt; n++) t.clearBufferfv(t.COLOR, n, new Float32Array([0, 0, 0, 0]));
209
- t.viewport(0, 0, this.dt, this._t), W(t, [0, 0, this.dt, this._t]);
209
+ t.viewport(0, 0, this.dt, this._t), Y(t, [0, 0, this.dt, this._t]);
210
210
  }
211
211
  end() {
212
212
  var e, i, s, r;
213
213
  if (!this.$t) return;
214
214
  const t = this.vt;
215
215
  if (this.xt) {
216
- const n = ((i = (e = this.xt).Tt) == null ? void 0 : i.call(e)) ?? null;
217
- n && this.xt.Et(n);
216
+ const n = ((i = (e = this.xt).Et) == null ? void 0 : i.call(e)) ?? null;
217
+ n && this.xt.kt(n);
218
218
  }
219
- t.bindFramebuffer(t.FRAMEBUFFER, this.$t.framebuffer), t.viewport(...this.$t.viewport), W(t, this.$t.viewport), this.$t = null, this.xt && this.Mt && this.Rt && ((r = (s = this.xt).Pt) == null || r.call(s));
219
+ t.bindFramebuffer(t.FRAMEBUFFER, this.$t.framebuffer), t.viewport(...this.$t.viewport), Y(t, this.$t.viewport), this.$t = null, this.xt && this.Mt && this.St && ((r = (s = this.xt).Pt) == null || r.call(s));
220
220
  }
221
- kt() {
221
+ Lt() {
222
222
  const t = this.vt;
223
223
  t.deleteFramebuffer(this.yt);
224
224
  for (const e of this.Ct) t.deleteTexture(e);
@@ -235,27 +235,27 @@ class j {
235
235
  }
236
236
  class I {
237
237
  constructor(t, e, i) {
238
- a(this, "vt");
239
- a(this, "Gt");
240
- a(this, "Bt", /* @__PURE__ */ new Map());
241
- a(this, "Dt", /* @__PURE__ */ new Map());
242
- a(this, "It", 0);
243
- this.vt = t, this.Gt = this.Wt(e, i), this.Ot();
244
- }
245
- Ot() {
246
- const t = this.vt.getProgramParameter(this.Gt, this.vt.ACTIVE_UNIFORMS);
238
+ h(this, "vt");
239
+ h(this, "Dt");
240
+ h(this, "Gt", /* @__PURE__ */ new Map());
241
+ h(this, "Bt", /* @__PURE__ */ new Map());
242
+ h(this, "It", 0);
243
+ this.vt = t, this.Dt = this.Ot(e, i), this.Wt();
244
+ }
245
+ Wt() {
246
+ const t = this.vt.getProgramParameter(this.Dt, this.vt.ACTIVE_UNIFORMS);
247
247
  for (let e = 0; e < t; e++) {
248
- const i = this.vt.getActiveUniform(this.Gt, e);
248
+ const i = this.vt.getActiveUniform(this.Dt, e);
249
249
  if (i) {
250
- const s = this.vt.getUniformLocation(this.Gt, i.name);
251
- if (s && (this.Bt.set(i.name, s), this.Dt.set(i.name, { type: i.type, size: i.size }), i.size > 1)) {
250
+ const s = this.vt.getUniformLocation(this.Dt, i.name);
251
+ if (s && (this.Gt.set(i.name, s), this.Bt.set(i.name, { type: i.type, size: i.size }), i.size > 1)) {
252
252
  const r = i.name.replace(/\[.*\]$/, "");
253
- this.Bt.has(r) || (this.Bt.set(r, s), this.Dt.set(r, { type: i.type, size: i.size }));
253
+ this.Gt.has(r) || (this.Gt.set(r, s), this.Bt.set(r, { type: i.type, size: i.size }));
254
254
  }
255
255
  }
256
256
  }
257
257
  }
258
- Wt(t, e) {
258
+ Ot(t, e) {
259
259
  const i = this.Ht(this.vt.VERTEX_SHADER, t), s = this.Ht(this.vt.FRAGMENT_SHADER, e), r = this.vt.createProgram();
260
260
  if (this.vt.attachShader(r, i), this.vt.attachShader(r, s), this.vt.linkProgram(r), !this.vt.getProgramParameter(r, this.vt.LINK_STATUS)) {
261
261
  const n = this.vt.getProgramInfoLog(r);
@@ -271,31 +271,31 @@ class I {
271
271
  }
272
272
  return i;
273
273
  }
274
- Vt() {
275
- this.vt.useProgram(this.Gt), this.Kt();
274
+ Xt() {
275
+ this.vt.useProgram(this.Dt), this.Vt();
276
276
  }
277
- Kt() {
277
+ Vt() {
278
278
  this.It = 0;
279
279
  }
280
- Nt(t) {
281
- for (const [e, i] of Object.entries(t)) this.Xt(e, i);
280
+ Kt(t) {
281
+ for (const [e, i] of Object.entries(t)) this.jt(e, i);
282
282
  }
283
- jt(t) {
284
- return this.Bt.has(t);
283
+ Nt(t) {
284
+ return this.Gt.has(t);
285
285
  }
286
286
  Yt(t) {
287
- return this.Dt.get(t) || null;
287
+ return this.Bt.get(t) || null;
288
288
  }
289
289
  qt() {
290
290
  const t = [];
291
- for (const [e, i] of this.Dt.entries()) t.push({ name: e, ...i });
291
+ for (const [e, i] of this.Bt.entries()) t.push({ name: e, ...i });
292
292
  return t;
293
293
  }
294
- Xt(t, e) {
294
+ jt(t, e) {
295
295
  var c;
296
- const i = this.Bt.get(t);
296
+ const i = this.Gt.get(t);
297
297
  if (!i) return;
298
- const s = this.Dt.get(t);
298
+ const s = this.Bt.get(t);
299
299
  if (!s) return void console.warn(`No type information found for uniform '${t}'`);
300
300
  const { type: r, size: n } = s, o = this.vt;
301
301
  if (typeof e == "number") switch (r) {
@@ -347,7 +347,7 @@ class I {
347
347
  else if (e instanceof WebGLTexture) {
348
348
  const l = this.Zt();
349
349
  o.uniform1i(i, l), o.activeTexture(o.TEXTURE0 + l), o.bindTexture(o.TEXTURE_2D, e);
350
- } else if (e instanceof j) {
350
+ } else if (e instanceof K) {
351
351
  const l = this.Zt();
352
352
  o.uniform1i(i, l), o.activeTexture(o.TEXTURE0 + l), o.bindTexture(o.TEXTURE_2D, e.textures[0]);
353
353
  } else console.warn(`Unsupported uniform type for '${t}':`, typeof e);
@@ -356,30 +356,30 @@ class I {
356
356
  return this.It++;
357
357
  }
358
358
  get Jt() {
359
- return this.Gt;
359
+ return this.Dt;
360
360
  }
361
- kt() {
362
- this.vt.deleteProgram(this.Gt);
361
+ Lt() {
362
+ this.vt.deleteProgram(this.Dt);
363
363
  }
364
364
  }
365
365
  const N = `#version 300 es
366
- in vec2 a_position;in vec2 a_texCoord;in vec2 a_instancePosition;in vec2 a_instanceSize;in vec3 a_instanceCharacter;in vec4 a_instancePrimaryColor;in vec4 a_instanceSecondaryColor;in vec2 a_instanceRotation;in vec3 a_instanceTransform;in vec3 a_instanceGlobalRotation;in vec2 a_instanceRotationCenter;in vec2 a_instanceBezierCP1;in vec2 a_instanceBezierCP2;in vec2 a_instanceBezierStart;in vec2 a_instanceBezierEnd;in vec2 a_instanceArcAngles;uniform float U9;uniform vec2 Uy;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/Uy)*2.-1.;a.y=-a.y;if(length(a_instanceGlobalRotation)>0.){vec3 b=vec3(a-a_instanceRotationCenter,0);b.x*=U9;if(a_instanceGlobalRotation.x!=0.)b=A(-a_instanceGlobalRotation.x)*b;if(a_instanceGlobalRotation.y!=0.)b=E(-a_instanceGlobalRotation.y)*b;if(a_instanceGlobalRotation.z!=0.)b=F(-a_instanceGlobalRotation.z)*b;b.x/=U9;a=b.xy+a_instanceRotationCenter;}gl_Position=vec4(a,0,1);}`, at = "attribute vec2 a_position;attribute vec2 a_texCoord;varying vec2 v_uv;void main(){v_uv=a_texCoord;gl_Position=vec4(a_position,0.,1.);}";
367
- class ft {
366
+ in vec2 a_position;in vec2 a_texCoord;in vec2 a_instancePosition;in vec2 a_instanceSize;in vec3 a_instanceCharacter;in vec4 a_instancePrimaryColor;in vec4 a_instanceSecondaryColor;in vec2 a_instanceRotation;in vec3 a_instanceTransform;in vec3 a_instanceGlobalRotation;in vec2 a_instanceRotationCenter;in vec2 a_instanceBezierCP1;in vec2 a_instanceBezierCP2;in vec2 a_instanceBezierStart;in vec2 a_instanceBezierEnd;in vec2 a_instanceArcAngles;uniform float U9;uniform vec2 Uw;out vec2 v_uv;out vec3 v_character;out vec4 v_primaryColor;out vec4 v_secondaryColor;out vec2 v_rotation;out vec3 v_transform;mat3 A(float B){float C=sin(B),D=cos(B);return mat3(1,0,0,0,D,-C,0,C,D);}mat3 E(float B){float C=sin(B),D=cos(B);return mat3(D,0,C,0,1,0,-C,0,D);}mat3 F(float B){float C=sin(B),D=cos(B);return mat3(D,-C,0,C,D,0,0,0,1);}vec2 G(float H,vec2 I,vec2 J,vec2 K,vec2 L){float M=1.-H,N=M*M,O=H*H;return N*M*I+3.*N*H*J+3.*M*O*K+O*H*L;}vec2 P(float H,vec2 I,vec2 J,vec2 K,vec2 L){float M=1.-H,N=M*M,O=H*H;return-3.*N*I+3.*N*J-6.*M*H*J+6.*M*H*K-3.*O*K+3.*O*L;}void main(){v_uv=a_texCoord;v_character=a_instanceCharacter;v_primaryColor=a_instancePrimaryColor;v_secondaryColor=a_instanceSecondaryColor;v_rotation=a_instanceRotation;v_transform=a_instanceTransform;vec2 Q;bool R=length(a_instanceBezierCP1)+length(a_instanceBezierCP2)+length(a_instanceBezierStart)+length(a_instanceBezierEnd)>0.;bool S=a_instanceArcAngles.x!=0.||a_instanceArcAngles.y!=0.;if(R){float H=a_position.x;vec2 T=G(H,a_instanceBezierStart,a_instanceBezierCP1,a_instanceBezierCP2,a_instanceBezierEnd);vec2 U=P(H,a_instanceBezierStart,a_instanceBezierCP1,a_instanceBezierCP2,a_instanceBezierEnd);float V=length(U);U=V>0.?U/V:vec2(1,0);Q=T+vec2(-U.y,U.x)*a_position.y*a_instanceSize.y;}else if(S){float C=a_instanceArcAngles.x,W=a_instanceArcAngles.y;C=mod(C,6.28318530718);if(C<0.)C+=6.28318530718;W=mod(W,6.28318530718);if(W<0.)W+=6.28318530718;float X=C-W;if(X<=0.)X+=6.28318530718;float Y=C-a_position.x*X;vec2 Z=vec2(cos(Y),sin(Y))*a_position.y;Q=Z*a_instanceSize*.5+a_instanceSize*.5+a_instancePosition;}else{Q=a_position*a_instanceSize+a_instancePosition;}vec2 a=(Q/Uw)*2.-1.;a.y=-a.y;if(length(a_instanceGlobalRotation)>0.){vec3 b=vec3(a-a_instanceRotationCenter,0);b.x*=U9;if(a_instanceGlobalRotation.x!=0.)b=A(-a_instanceGlobalRotation.x)*b;if(a_instanceGlobalRotation.y!=0.)b=E(-a_instanceGlobalRotation.y)*b;if(a_instanceGlobalRotation.z!=0.)b=F(-a_instanceGlobalRotation.z)*b;b.x/=U9;a=b.xy+a_instanceRotationCenter;}gl_Position=vec4(a,0,1);}`, at = "attribute vec2 a_position;attribute vec2 a_texCoord;varying vec2 v_uv;void main(){v_uv=a_texCoord;gl_Position=vec4(a_position,0.,1.);}";
367
+ class mt {
368
368
  constructor(t) {
369
- a(this, "vt");
370
- a(this, "Qt");
371
- a(this, "te");
372
- a(this, "ee");
373
- a(this, "se");
369
+ h(this, "vt");
370
+ h(this, "Qt");
371
+ h(this, "te");
372
+ h(this, "ee");
373
+ h(this, "se");
374
374
  this.vt = t, this.te = new I(this.vt, N, `#version 300 es
375
375
  precision highp float;in vec2 v_uv;in vec3 v_character;in vec4 v_primaryColor;in vec4 v_secondaryColor;in vec2 v_rotation;in vec3 v_transform;layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;layout(location=3)out vec4 o_rotation;layout(location=4)out vec4 o_transform;void main(){o_character=vec4(v_character,1.);o_primaryColor=v_primaryColor;o_secondaryColor=v_secondaryColor;o_rotation=vec4(v_rotation,0.,1.);o_transform=vec4(v_transform,1.);}`), this.Qt = new I(this.vt, N, `#version 300 es
376
376
  precision highp float;in vec2 v_uv;uniform sampler2D Ue;uniform sampler2D Uf;uniform sampler2D Ug;uniform sampler2D Uh;uniform sampler2D Ui;uniform vec2 Uj;layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;layout(location=3)out vec4 o_rotation;layout(location=4)out vec4 o_transform;void main(){vec2 A=vec2(v_uv.x,1.-v_uv.y);vec2 B=A*Uj;vec2 C=(floor(B)+0.5f)/Uj;vec4 D=texture(Ue,C);vec4 E=texture(Uf,C);if(E.a==0.){discard;}vec4 F=texture(Ug,C);vec4 G=texture(Uh,C);vec4 H=texture(Ui,C);o_character=D;o_primaryColor=E;o_secondaryColor=F;o_rotation=G;o_transform=H;}`), this.ee = new I(this.vt, at, "precision mediump float;uniform sampler2D U0;uniform vec2 U1;uniform sampler2D U3;uniform sampler2D U4;uniform sampler2D U5;uniform sampler2D U2;uniform sampler2D U6;uniform vec2 U7;uniform vec2 U8;mat2 A(float B){float C=sin(B);float D=cos(B);return mat2(D,-C,C,D);}void main(){vec2 E=gl_FragCoord.xy/U8;vec2 F=E*U7;vec2 G=floor(F);vec2 H=(G+0.5)/U7;vec4 I=texture2D(U3,H);vec4 J=texture2D(U4,H);vec4 K=texture2D(U5,H);bool L=K.r>0.5;bool M=K.g>0.5;bool N=K.b>0.5;vec4 O=texture2D(U2,H);int P=int(O.r*255.+0.5)+int(O.g*255.+0.5)*256;int Q=int(mod(float(P),U1.x));int R=P/int(U1.x);float S=(U1.y-1.)-float(R);vec2 T=vec2(float(Q),S)/U1;vec4 U=texture2D(U6,H);float V=U.r*255.+U.g;float W=-(V*360./255.)*0.017453292;vec2 X=fract(F)-0.5;if(M)X.x=-X.x;if(N)X.y=-X.y;X=A(W)*X+0.5;vec2 Y=1./U1;vec2 Z=T+X*Y;vec2 a=T+Y;if(any(lessThan(Z,T))||any(greaterThan(Z,a))){gl_FragColor=L?I:J;return;}vec4 b=texture2D(U0,Z);if(L)b.rgb=1.-b.rgb;gl_FragColor=mix(J,I,b);}"), this.se = new I(this.vt, N, `#version 300 es
377
- precision highp float;in vec2 v_uv;uniform sampler2D Uk;uniform bool Ul;uniform bool Um;uniform bool Un;uniform vec2 Uo;uniform bool Up;uniform vec3 Uq;uniform bool Ur;uniform vec3 Us;uniform vec4 Ut;uniform int Uu;uniform vec3 Uv[64];layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;layout(location=3)out vec4 o_rotation;layout(location=4)out vec4 o_transform;float A(vec3 B){return dot(B,vec3(0.299f,0.587f,0.114f));}void main(){vec2 C=vec2(v_uv.x,1.0f-v_uv.y);vec4 D=texture(Uk,C);float E=A(D.rgb);if(Uu>0){float F=float(Uu);float G=clamp(E*(F-1.0f),0.0f,F-1.0f);int H=int(floor(G+0.5f));vec3 I=Uv[H];o_character=vec4(I,1.0f);}else{o_character=vec4(E,0.0f,0.0f,1.0f);}vec3 J=D.rgb;vec3 K=Up?Uq:J;vec3 L=Ur?Us:J;float M=1.0f;float N=1.0f;if(D.a<0.01f){K=Ut.rgb;L=Ut.rgb;}o_primaryColor=vec4(K,M);o_secondaryColor=vec4(L,N);o_rotation=vec4(Uo.xy,0.0f,1.0f);o_transform=vec4(float(Ul),float(Um),float(Un),1.0f);}`);
377
+ precision highp float;in vec2 v_uv;uniform sampler2D Uk;uniform bool Ul;uniform bool Um;uniform bool Un;uniform vec2 Uo;uniform bool Up;uniform vec4 Uq;uniform bool Ur;uniform vec4 Us;uniform vec4 Ut;uniform int Uu;uniform vec3 Uv[64];layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;layout(location=3)out vec4 o_rotation;layout(location=4)out vec4 o_transform;float A(vec3 B){return dot(B,vec3(0.299f,0.587f,0.114f));}void main(){vec2 C=vec2(v_uv.x,1.0f-v_uv.y);vec4 D=texture(Uk,C);float E=A(D.rgb);if(Uu>0){float F=float(Uu);float G=clamp(E*(F-1.0f),0.0f,F-1.0f);int H=int(floor(G+0.5f));vec3 I=Uv[H];o_character=vec4(I,1.0f);}else{o_character=vec4(E,0.0f,0.0f,1.0f);}vec4 J=Up?Uq:D;vec4 K=Ur?Us:D;if(D.a<0.01f){J=Ut;K=Ut;}else{}o_primaryColor=vec4(J);o_secondaryColor=vec4(K);o_rotation=vec4(Uo.xy,0.0f,1.0f);o_transform=vec4(float(Ul),float(Um),float(Un),1.0f);}`);
378
378
  }
379
379
  ie() {
380
380
  return this.Qt;
381
381
  }
382
- Tt() {
382
+ Et() {
383
383
  return this.te;
384
384
  }
385
385
  re() {
@@ -391,24 +391,24 @@ precision highp float;in vec2 v_uv;uniform sampler2D Uk;uniform bool Ul;uniform
391
391
  oe(t) {
392
392
  return new I(this.vt, N, t);
393
393
  }
394
- ae(t, e) {
394
+ he(t, e) {
395
395
  return new I(this.vt, t, e);
396
396
  }
397
- kt() {
398
- this.Qt.kt(), this.te.kt(), this.ee.kt(), this.se.kt();
397
+ Lt() {
398
+ this.Qt.Lt(), this.te.Lt(), this.ee.Lt(), this.se.Lt();
399
399
  }
400
400
  }
401
- var w = ((h) => (h.RECTANGLE = "rectangle", h.LINE = "line", h.ELLIPSE = "ellipse", h.ARC = "arc", h.TRIANGLE = "triangle", h.BEZIER_CURVE = "bezier_curve", h.CUSTOM = "custom", h))(w || {});
402
- class dt {
401
+ var E = ((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))(E || {});
402
+ class pt {
403
403
  constructor(t) {
404
- a(this, "vt");
405
- a(this, "he", /* @__PURE__ */ new Map());
404
+ h(this, "vt");
405
+ h(this, "ae", /* @__PURE__ */ new Map());
406
406
  this.vt = t;
407
407
  }
408
408
  ce(t, e, i, s) {
409
409
  const r = this.vt;
410
- let n = this.he.get(t);
411
- n || (n = /* @__PURE__ */ new Map(), this.he.set(t, n));
410
+ let n = this.ae.get(t);
411
+ n || (n = /* @__PURE__ */ new Map(), this.ae.set(t, n));
412
412
  let o = n.get(e) || null;
413
413
  if (!o) {
414
414
  o = r.createVertexArray(), n.set(e, o), r.bindVertexArray(o), r.bindBuffer(r.ARRAY_BUFFER, s);
@@ -422,22 +422,22 @@ class dt {
422
422
  _e() {
423
423
  this.vt.bindVertexArray(null);
424
424
  }
425
- kt() {
426
- for (const [, t] of this.he) for (const [, e] of t) e && this.vt.deleteVertexArray(e);
425
+ Lt() {
426
+ for (const [, t] of this.ae) for (const [, e] of t) e && this.vt.deleteVertexArray(e);
427
427
  }
428
428
  }
429
- class gt {
429
+ class vt {
430
430
  constructor(t, e) {
431
- a(this, "pe");
432
- a(this, "vt");
433
- a(this, "xt");
434
- a(this, "me", null);
435
- a(this, "ge", null);
436
- this.vt = t, this.pe = new dt(t), this.xt = e;
431
+ h(this, "pe");
432
+ h(this, "vt");
433
+ h(this, "xt");
434
+ h(this, "me", null);
435
+ h(this, "ge", null);
436
+ this.vt = t, this.pe = new pt(t), this.xt = e;
437
437
  }
438
438
  ve(t, e, i) {
439
- const { shader: s } = t, r = H(this.vt) || this.vt.getParameter(this.vt.VIEWPORT);
440
- s.Nt({ U9: r[2] / r[3], Uy: [r[2], r[3]] });
439
+ const { shader: s } = t, r = X(this.vt) || this.vt.getParameter(this.vt.VIEWPORT);
440
+ s.Kt({ U9: r[2] / r[3], Uw: [r[2], r[3]] });
441
441
  const n = (l) => {
442
442
  if (!l || !l.ye()) return;
443
443
  const u = l.unitGeometry, f = l.unitBuffer;
@@ -449,26 +449,26 @@ class gt {
449
449
  };
450
450
  let o = null, c = null;
451
451
  for (const l of e) {
452
- if (l.type === w.CUSTOM) {
453
- c && (n(c), o = null, c = null), this.Re(t, l.params, l.state, i.get(w.RECTANGLE));
452
+ if (l.type === E.CUSTOM) {
453
+ c && (n(c), o = null, c = null), this.Se(t, l.params, l.state, i.get(E.RECTANGLE));
454
454
  continue;
455
455
  }
456
456
  o !== null && l.type !== o && (n(c), o = null, c = null);
457
457
  let u = c;
458
- u && l.type === o || (u = i.get(l.type) || null, c = u, o = l.type), u && u.Fe(l.params, l.state);
458
+ u && l.type === o || (u = i.get(l.type) || null, c = u, o = l.type), u && u.Re(l.params, l.state);
459
459
  }
460
460
  n(c);
461
461
  }
462
- Re(t, e, i, s) {
463
- const { x: r, y: n, width: o, height: c, shader: l, uniforms: u } = e, f = this.Se(Math.max(1, Math.floor(o)), Math.max(1, Math.floor(c)));
464
- f.begin(), this.Ae(s, l, u, 0, 0, f.width, f.height, {}), f.end();
465
- const g = this.ze(), v = { Ue: f.textures[0], Uf: f.textures[1], Ug: f.textures[2], Uh: f.textures[3], Ui: f.textures[4], Uj: [f.width, f.height] };
466
- this.Ae(s, g, v, Math.floor(r), Math.floor(n), Math.max(1, Math.floor(o)), Math.max(1, Math.floor(c)), i), t.shader.Vt();
462
+ Se(t, e, i, s) {
463
+ const { x: r, y: n, width: o, height: c, shader: l, uniforms: u } = e, f = this.Fe(Math.max(1, Math.floor(o)), Math.max(1, Math.floor(c)));
464
+ f.begin(), this.Te(s, l, u, 0, 0, f.width, f.height, {}), f.end();
465
+ const g = this.Ae(), v = { Ue: f.textures[0], Uf: f.textures[1], Ug: f.textures[2], Uh: f.textures[3], Ui: f.textures[4], Uj: [f.width, f.height] };
466
+ this.Te(s, g, v, Math.floor(r), Math.floor(n), Math.max(1, Math.floor(o)), Math.max(1, Math.floor(c)), i), t.shader.Xt();
467
467
  }
468
- Ae(t, e, i, s, r, n, o, c) {
469
- e.Vt(), e.Nt(i);
468
+ Te(t, e, i, s, r, n, o, c) {
469
+ e.Xt(), e.Kt(i);
470
470
  const l = this.vt.getParameter(this.vt.VIEWPORT);
471
- if (e.Nt({ U9: l[2] / l[3], Uy: [l[2], l[3]] }), t.Me(), t.Fe({ x: s, y: r, width: n, height: o }, c), t.ye()) {
471
+ if (e.Kt({ U9: l[2] / l[3], Uw: [l[2], l[3]] }), t.Me(), t.Re({ x: s, y: r, width: n, height: o }, c), t.ye()) {
472
472
  const u = t.unitGeometry, f = t.unitBuffer;
473
473
  try {
474
474
  this.pe.ce(e.Jt, t.type + "", u, f), t.batch.Ce(e), t.batch.we(u.$e, u.be);
@@ -477,109 +477,109 @@ class gt {
477
477
  }
478
478
  }
479
479
  }
480
- ze() {
480
+ Ae() {
481
481
  return this.xt.ie();
482
482
  }
483
- Se(t, e) {
484
- return this.me && this.ge && this.ge.w === t && this.ge.h === e || (this.me && this.me.kt(), this.me = new j(this.vt, t, e, 5), this.ge = { w: t, h: e }), this.me;
483
+ Fe(t, e) {
484
+ return this.me && this.ge && this.ge.w === t && this.ge.h === e || (this.me && this.me.Lt(), this.me = new K(this.vt, t, e, 5), this.ge = { w: t, h: e }), this.me;
485
485
  }
486
- kt() {
487
- this.pe.kt(), this.me && this.me.kt();
486
+ Lt() {
487
+ this.pe.Lt(), this.me && this.me.Lt();
488
488
  }
489
489
  }
490
- class pt {
490
+ class yt {
491
491
  constructor() {
492
- a(this, "Te", []);
493
- a(this, "Ee", 1);
494
- a(this, "Le", 0);
492
+ h(this, "Ee", []);
493
+ h(this, "ke", 1);
494
+ h(this, "ze", 0);
495
495
  }
496
496
  Pe(t) {
497
- if (this.Le >= this.Te.length) {
498
- const i = { id: this.Ee++, type: t, params: {}, state: { O: 1, H: 0, V: 0, K: 0, j: [0, 0, 0], Y: [1, 1, 1, 1], q: [0, 0, 0, 1], N: !1, X: !1, k: !1, G: [0, 0] } };
499
- this.Te.push(i);
497
+ if (this.ze >= this.Ee.length) {
498
+ const i = { id: this.ke++, type: t, params: {}, state: { W: 1, H: 0, X: 0, V: 0, N: [0, 0, 0], Y: [1, 1, 1, 1], q: [0, 0, 0, 1], K: !1, j: !1, L: !1, D: [0, 0] } };
499
+ this.Ee.push(i);
500
500
  }
501
- const e = this.Te[this.Le];
502
- return e.id = this.Ee++, e.type = t, this.Le++, e;
501
+ const e = this.Ee[this.ze];
502
+ return e.id = this.ke++, e.type = t, this.ze++, e;
503
503
  }
504
- ke(t, e, i, s, r) {
505
- const n = this.Pe(w.RECTANGLE);
504
+ Le(t, e, i, s, r) {
505
+ const n = this.Pe(E.RECTANGLE);
506
506
  return n.params.x = t, n.params.y = e, n.params.width = i, n.params.height = s, r.J(n.state), n.id;
507
507
  }
508
- Ge(t, e, i, s, r, n, o) {
509
- const c = this.Pe(w.CUSTOM);
508
+ De(t, e, i, s, r, n, o) {
509
+ const c = this.Pe(E.CUSTOM);
510
510
  return c.params.x = t, c.params.y = e, c.params.width = i, c.params.height = s, c.params.shader = r, c.params.uniforms = n, o.J(c.state), c.id;
511
511
  }
512
- Be(t, e, i, s, r, n) {
513
- const o = this.Pe(w.LINE);
512
+ Ge(t, e, i, s, r, n) {
513
+ const o = this.Pe(E.LINE);
514
514
  return o.params.x1 = t, o.params.y1 = e, o.params.x2 = i, o.params.y2 = s, o.params.thickness = r, n.J(o.state), o.id;
515
515
  }
516
- De(t, e, i, s, r) {
517
- const n = this.Pe(w.ELLIPSE);
516
+ Be(t, e, i, s, r) {
517
+ const n = this.Pe(E.ELLIPSE);
518
518
  return n.params.x = t, n.params.y = e, n.params.width = i, n.params.height = s, r.J(n.state), n.id;
519
519
  }
520
520
  Ie(t, e, i, s, r, n, o) {
521
- const c = this.Pe(w.ARC);
521
+ const c = this.Pe(E.ARC);
522
522
  return c.params.x = t, c.params.y = e, c.params.width = i, c.params.height = s, c.params.start = r, c.params.stop = n, o.J(c.state), c.id;
523
523
  }
524
- We(t, e, i, s, r, n, o) {
525
- const c = this.Pe(w.TRIANGLE);
524
+ Oe(t, e, i, s, r, n, o) {
525
+ const c = this.Pe(E.TRIANGLE);
526
526
  return c.params.x1 = t, c.params.y1 = e, c.params.x2 = i, c.params.y2 = s, c.params.x3 = r, c.params.y3 = n, o.J(c.state), c.id;
527
527
  }
528
- Oe(t, e, i, s, r, n, o, c, l, u) {
529
- const f = this.Pe(w.BEZIER_CURVE);
528
+ We(t, e, i, s, r, n, o, c, l, u) {
529
+ const f = this.Pe(E.BEZIER_CURVE);
530
530
  return f.params.x1 = t, f.params.y1 = e, f.params.cp1x = i, f.params.cp1y = s, f.params.cp2x = r, f.params.cp2y = n, f.params.x2 = o, f.params.y2 = c, f.params.thickness = l, u.J(f.state), f.id;
531
531
  }
532
532
  get length() {
533
- return this.Le;
533
+ return this.ze;
534
534
  }
535
535
  get isEmpty() {
536
- return this.Le === 0;
536
+ return this.ze === 0;
537
537
  }
538
538
  He() {
539
- this.Le = 0;
539
+ this.ze = 0;
540
540
  }
541
541
  [Symbol.iterator]() {
542
542
  let t = 0;
543
- const e = this.Le, i = this.Te;
543
+ const e = this.ze, i = this.Ee;
544
544
  return { next: () => t < e ? { value: i[t++], done: !1 } : { value: void 0, done: !0 } };
545
545
  }
546
546
  }
547
547
  const P = class P {
548
- static Ve(t, e, i = 0) {
549
- var n, o, c, l, u, f, g, v, m, d;
548
+ static Xe(t, e, i = 0) {
549
+ var n, o, c, l, u, f, g, v, p, d;
550
550
  const s = e || new Float32Array(P.FLOATS_PER_INSTANCE);
551
551
  let r = i;
552
- return s[r++] = t.le[0], s[r++] = t.le[1], s[r++] = t.Le[0], s[r++] = t.Le[1], s[r++] = t.j[0], s[r++] = t.j[1], s[r++] = t.j[2], s[r++] = t.Y[0], s[r++] = t.Y[1], s[r++] = t.Y[2], s[r++] = t.Y[3], s[r++] = t.q[0], s[r++] = t.q[1], s[r++] = t.q[2], s[r++] = t.q[3], s[r++] = t.G[0], s[r++] = t.G[1], s[r++] = t.Ke[0], s[r++] = t.Ke[1], s[r++] = t.Ke[2], s[r++] = t.H, s[r++] = t.V, s[r++] = t.K, s[r++] = t.Ne[0], s[r++] = t.Ne[1], s[r++] = ((n = t.Xe) == null ? void 0 : n[0]) || 0, s[r++] = ((o = t.Xe) == null ? void 0 : o[1]) || 0, s[r++] = ((c = t.je) == null ? void 0 : c[0]) || 0, s[r++] = ((l = t.je) == null ? void 0 : l[1]) || 0, s[r++] = ((u = t.Ye) == null ? void 0 : u[0]) || 0, s[r++] = ((f = t.Ye) == null ? void 0 : f[1]) || 0, s[r++] = ((g = t.qe) == null ? void 0 : g[0]) || 0, s[r++] = ((v = t.qe) == null ? void 0 : v[1]) || 0, s[r++] = ((m = t.Ze) == null ? void 0 : m[0]) || 0, s[r++] = ((d = t.Ze) == null ? void 0 : d[1]) || 0, s;
552
+ return s[r++] = t.le[0], s[r++] = t.le[1], s[r++] = t.ze[0], s[r++] = t.ze[1], s[r++] = t.N[0], s[r++] = t.N[1], s[r++] = t.N[2], s[r++] = t.Y[0], s[r++] = t.Y[1], s[r++] = t.Y[2], s[r++] = t.Y[3], s[r++] = t.q[0], s[r++] = t.q[1], s[r++] = t.q[2], s[r++] = t.q[3], s[r++] = t.D[0], s[r++] = t.D[1], s[r++] = t.Ve[0], s[r++] = t.Ve[1], s[r++] = t.Ve[2], s[r++] = t.H, s[r++] = t.X, s[r++] = t.V, s[r++] = t.Ke[0], s[r++] = t.Ke[1], s[r++] = ((n = t.je) == null ? void 0 : n[0]) || 0, s[r++] = ((o = t.je) == null ? void 0 : o[1]) || 0, s[r++] = ((c = t.Ne) == null ? void 0 : c[0]) || 0, s[r++] = ((l = t.Ne) == null ? void 0 : l[1]) || 0, s[r++] = ((u = t.Ye) == null ? void 0 : u[0]) || 0, s[r++] = ((f = t.Ye) == null ? void 0 : f[1]) || 0, s[r++] = ((g = t.qe) == null ? void 0 : g[0]) || 0, s[r++] = ((v = t.qe) == null ? void 0 : v[1]) || 0, s[r++] = ((p = t.Ze) == null ? void 0 : p[0]) || 0, s[r++] = ((d = t.Ze) == null ? void 0 : d[1]) || 0, s;
553
553
  }
554
554
  static Je(t) {
555
555
  const e = t.length * P.FLOATS_PER_INSTANCE, i = new Float32Array(e);
556
556
  for (let s = 0; s < t.length; s++) {
557
557
  const r = s * P.FLOATS_PER_INSTANCE;
558
- P.Ve(t[s], i, r);
558
+ P.Xe(t[s], i, r);
559
559
  }
560
560
  return i;
561
561
  }
562
562
  };
563
- a(P, "BYTES_PER_INSTANCE", 140), a(P, "FLOATS_PER_INSTANCE", 35);
563
+ h(P, "BYTES_PER_INSTANCE", 140), h(P, "FLOATS_PER_INSTANCE", 35);
564
564
  let M = P;
565
565
  const A = class A {
566
566
  };
567
- a(A, "STRIDE", M.BYTES_PER_INSTANCE), a(A, "ATTRIBUTES", { a_instancePosition: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: A.STRIDE, offset: 0, divisor: 1 }, a_instanceSize: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: A.STRIDE, offset: 8, divisor: 1 }, a_instanceCharacter: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: A.STRIDE, offset: 16, divisor: 1 }, a_instancePrimaryColor: { location: -1, size: 4, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: A.STRIDE, offset: 28, divisor: 1 }, a_instanceSecondaryColor: { location: -1, size: 4, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: A.STRIDE, offset: 44, divisor: 1 }, a_instanceRotation: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: A.STRIDE, offset: 60, divisor: 1 }, a_instanceTransform: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: A.STRIDE, offset: 68, divisor: 1 }, a_instanceGlobalRotation: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: A.STRIDE, offset: 80, divisor: 1 }, a_instanceRotationCenter: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: A.STRIDE, offset: 92, divisor: 1 }, a_instanceArcAngles: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: A.STRIDE, offset: 100, divisor: 1 }, a_instanceBezierCP1: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: A.STRIDE, offset: 108, divisor: 1 }, a_instanceBezierCP2: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: A.STRIDE, offset: 116, divisor: 1 }, a_instanceBezierStart: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: A.STRIDE, offset: 124, divisor: 1 }, a_instanceBezierEnd: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: A.STRIDE, offset: 132, divisor: 1 } });
568
- let X = A;
569
- class mt {
567
+ h(A, "STRIDE", M.BYTES_PER_INSTANCE), h(A, "ATTRIBUTES", { a_instancePosition: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: A.STRIDE, offset: 0, divisor: 1 }, a_instanceSize: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: A.STRIDE, offset: 8, divisor: 1 }, a_instanceCharacter: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: A.STRIDE, offset: 16, divisor: 1 }, a_instancePrimaryColor: { location: -1, size: 4, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: A.STRIDE, offset: 28, divisor: 1 }, a_instanceSecondaryColor: { location: -1, size: 4, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: A.STRIDE, offset: 44, divisor: 1 }, a_instanceRotation: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: A.STRIDE, offset: 60, divisor: 1 }, a_instanceTransform: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: A.STRIDE, offset: 68, divisor: 1 }, a_instanceGlobalRotation: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: A.STRIDE, offset: 80, divisor: 1 }, a_instanceRotationCenter: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: A.STRIDE, offset: 92, divisor: 1 }, a_instanceArcAngles: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: A.STRIDE, offset: 100, divisor: 1 }, a_instanceBezierCP1: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: A.STRIDE, offset: 108, divisor: 1 }, a_instanceBezierCP2: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: A.STRIDE, offset: 116, divisor: 1 }, a_instanceBezierStart: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: A.STRIDE, offset: 124, divisor: 1 }, a_instanceBezierEnd: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: A.STRIDE, offset: 132, divisor: 1 } });
568
+ let k = A;
569
+ class xt {
570
570
  constructor(t, e = 1e3, i = 1.5) {
571
- a(this, "vt");
572
- a(this, "Qe", []);
573
- a(this, "ts");
574
- a(this, "es");
575
- a(this, "ss", null);
576
- a(this, "rs", !0);
577
- a(this, "ns", 0);
578
- a(this, "hs", /* @__PURE__ */ new Map());
579
- a(this, "cs", null);
571
+ h(this, "vt");
572
+ h(this, "Qe", []);
573
+ h(this, "ts");
574
+ h(this, "es");
575
+ h(this, "ss", null);
576
+ h(this, "rs", !0);
577
+ h(this, "ns", 0);
578
+ h(this, "hs", /* @__PURE__ */ new Map());
579
+ h(this, "cs", null);
580
580
  this.vt = t, this.ts = e, this.es = i, this.ls();
581
581
  }
582
- Fe(t) {
582
+ Re(t) {
583
583
  const e = this.Qe.length;
584
584
  return this.Qe.push(t), this.rs = !0, e;
585
585
  }
@@ -615,7 +615,7 @@ class mt {
615
615
  if (!e) {
616
616
  e = /* @__PURE__ */ new Map();
617
617
  const i = this.vt;
618
- for (const s in X.ATTRIBUTES) {
618
+ for (const s in k.ATTRIBUTES) {
619
619
  const r = i.getAttribLocation(t, s);
620
620
  r !== -1 && e.set(s, r);
621
621
  }
@@ -630,7 +630,7 @@ class mt {
630
630
  const s = this.ds(i);
631
631
  e.bindBuffer(e.ARRAY_BUFFER, this.ss);
632
632
  for (const [r, n] of s) {
633
- const o = X.ATTRIBUTES[r];
633
+ const o = k.ATTRIBUTES[r];
634
634
  o && (e.enableVertexAttribArray(n), e.vertexAttribPointer(n, o.size, o.type, o.normalized, o.stride, o.offset), e.vertexAttribDivisor(n, o.divisor));
635
635
  }
636
636
  }
@@ -641,17 +641,17 @@ class mt {
641
641
  we(t, e) {
642
642
  this.Qe.length !== 0 && this.vt.drawArraysInstanced(t, 0, e, this.Qe.length);
643
643
  }
644
- kt() {
644
+ Lt() {
645
645
  this.ss && this.vt.deleteBuffer(this.ss);
646
646
  }
647
647
  }
648
648
  class D {
649
649
  constructor(t, e, i, s) {
650
- a(this, "vt");
651
- a(this, "_s");
652
- a(this, "ps");
653
- a(this, "gs");
654
- a(this, "vs", null);
650
+ h(this, "vt");
651
+ h(this, "_s");
652
+ h(this, "ps");
653
+ h(this, "gs");
654
+ h(this, "vs", null);
655
655
  this.vt = t, this._s = e, this.ps = i, this.gs = s;
656
656
  const r = this.vt.createBuffer();
657
657
  if (!r) throw Error("Failed to create unit geometry buffer");
@@ -675,207 +675,207 @@ class D {
675
675
  ye() {
676
676
  return !this._s.isEmpty;
677
677
  }
678
- kt() {
679
- this._s.kt(), this.vt.deleteBuffer(this.vs);
678
+ Lt() {
679
+ this._s.Lt(), this.vt.deleteBuffer(this.vs);
680
680
  }
681
681
  ws(t, e, i, s, r) {
682
- const n = this.$s(t, e, i, s, r.H || 0, r.V || 0, r.K || 0);
683
- return { le: [t, e], Le: [i, s], j: r.j || [0, 0, 0], Y: r.Y || [1, 1, 1, 1], q: r.q || [0, 0, 0, 1], G: r.G || [0, 0], Ke: [r.k ? 1 : 0, r.N ? 1 : 0, r.X ? 1 : 0], H: n.radiansX, V: n.radiansY, K: n.radiansZ, Ne: [n.centerX, n.centerY] };
682
+ const n = this.$s(t, e, i, s, r.H || 0, r.X || 0, r.V || 0);
683
+ return { le: [t, e], ze: [i, s], N: r.N || [0, 0, 0], Y: r.Y || [1, 1, 1, 1], q: r.q || [0, 0, 0, 1], D: r.D || [0, 0], Ve: [r.L ? 1 : 0, r.K ? 1 : 0, r.j ? 1 : 0], H: n.radiansX, X: n.radiansY, V: n.radiansZ, Ke: [n.centerX, n.centerY] };
684
684
  }
685
685
  bs(t, e) {
686
- const i = H(this.vt) || [0, 0, this.vt.canvas.width, this.vt.canvas.height];
686
+ const i = X(this.vt) || [0, 0, this.vt.canvas.width, this.vt.canvas.height];
687
687
  return { nx: t / i[2] * 2 - 1, ny: 1 - e / i[3] * 2 };
688
688
  }
689
689
  Ms(t, e, i) {
690
690
  const s = this.bs(e, i);
691
- t.Ne = [s.nx, s.ny];
691
+ t.Ke = [s.nx, s.ny];
692
692
  }
693
693
  $s(t, e, i, s, r, n, o) {
694
- const c = H(this.vt) || [0, 0, this.vt.canvas.width, this.vt.canvas.height], l = c[2], u = c[3];
694
+ const c = X(this.vt) || [0, 0, this.vt.canvas.width, this.vt.canvas.height], l = c[2], u = c[3];
695
695
  return { centerX: (t + i / 2) / l * 2 - 1, centerY: 1 - (e + s / 2) / u * 2, radiansX: -r * Math.PI / 180, radiansY: -n * Math.PI / 180, radiansZ: -o * Math.PI / 180, aspectRatio: l / u };
696
696
  }
697
697
  }
698
- const vt = { Cs: new Float32Array([0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1]), be: 6, $e: WebGL2RenderingContext.TRIANGLES, fe: 16, ue: { le: { size: 2, offset: 0 }, de: { size: 2, offset: 8 } } };
699
- class xt extends D {
698
+ const wt = { Cs: new Float32Array([0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1]), be: 6, $e: WebGL2RenderingContext.TRIANGLES, fe: 16, ue: { le: { size: 2, offset: 0 }, de: { size: 2, offset: 8 } } };
699
+ class Et extends D {
700
700
  constructor(t, e) {
701
- super(t, e, w.RECTANGLE, vt);
701
+ super(t, e, E.RECTANGLE, wt);
702
702
  }
703
- Fe(t, e) {
703
+ Re(t, e) {
704
704
  const i = this.ws(t.x, t.y, t.width, t.height, e);
705
- return this._s.Fe(i);
705
+ return this._s.Re(i);
706
706
  }
707
707
  }
708
- const yt = { Cs: new Float32Array([0, -0.5, 0, 0, 1, -0.5, 1, 0, 0, 0.5, 0, 1, 0, 0.5, 0, 1, 1, -0.5, 1, 0, 1, 0.5, 1, 1]), be: 6, $e: WebGL2RenderingContext.TRIANGLES, fe: 16, ue: { le: { size: 2, offset: 0 }, de: { size: 2, offset: 8 } } };
709
- class Et extends D {
708
+ const Rt = { Cs: new Float32Array([0, -0.5, 0, 0, 1, -0.5, 1, 0, 0, 0.5, 0, 1, 0, 0.5, 0, 1, 1, -0.5, 1, 0, 1, 0.5, 1, 1]), be: 6, $e: WebGL2RenderingContext.TRIANGLES, fe: 16, ue: { le: { size: 2, offset: 0 }, de: { size: 2, offset: 8 } } };
709
+ class bt extends D {
710
710
  constructor(t, e) {
711
- super(t, e, w.LINE, yt);
711
+ super(t, e, E.LINE, Rt);
712
712
  }
713
- Fe(t, e) {
714
- const i = t.x2 - t.x1, s = t.y2 - t.y1, r = Math.hypot(i, s), n = t.thickness || e.O || 1, o = t.x1 + i / 2, c = t.y1 + s / 2, l = o - r / 2, u = c, f = this.ws(l, u, r, n, e);
715
- return this.Ms(f, o, c), this._s.Fe(f);
713
+ Re(t, e) {
714
+ const i = t.x2 - t.x1, s = t.y2 - t.y1, r = Math.hypot(i, s), n = t.thickness || e.W || 1, o = t.x1 + i / 2, c = t.y1 + s / 2, l = o - r / 2, u = c, f = this.ws(l, u, r, n, e);
715
+ return this.Ms(f, o, c), this._s.Re(f);
716
716
  }
717
717
  }
718
- const wt = { Cs: function(h = 32) {
719
- const t = [], e = 2 * Math.PI / h;
720
- for (let i = 0; i < h; i++) {
721
- const s = i * e, r = (i + 1) % h * e, n = Math.cos(s), o = Math.sin(s), c = 0.5 * (n + 1), l = 0.5 * (o + 1), u = Math.cos(r), f = Math.sin(r), g = 0.5 * (u + 1), v = 0.5 * (f + 1);
718
+ const Tt = { Cs: function(a = 32) {
719
+ const t = [], e = 2 * Math.PI / a;
720
+ for (let i = 0; i < a; i++) {
721
+ const s = i * e, r = (i + 1) % a * e, n = Math.cos(s), o = Math.sin(s), c = 0.5 * (n + 1), l = 0.5 * (o + 1), u = Math.cos(r), f = Math.sin(r), g = 0.5 * (u + 1), v = 0.5 * (f + 1);
722
722
  t.push(0, 0, 0.5, 0.5, n, o, c, l, u, f, g, v);
723
723
  }
724
724
  return new Float32Array(t);
725
725
  }(32), be: 96, $e: WebGL2RenderingContext.TRIANGLES, fe: 16, ue: { le: { size: 2, offset: 0 }, de: { size: 2, offset: 8 } } };
726
- class Rt extends D {
726
+ class At extends D {
727
727
  constructor(t, e) {
728
- super(t, e, w.ELLIPSE, wt);
728
+ super(t, e, E.ELLIPSE, Tt);
729
729
  }
730
- Fe(t, e) {
730
+ Re(t, e) {
731
731
  const i = this.ws(t.x, t.y, t.width, t.height, e);
732
- return this.Ms(i, t.x, t.y), this._s.Fe(i);
732
+ return this.Ms(i, t.x, t.y), this._s.Re(i);
733
733
  }
734
734
  }
735
- let bt = { Cs: function(h) {
735
+ let Ct = { Cs: function(a) {
736
736
  const t = [];
737
- for (let e = 0; e < h; e++) {
738
- const i = e / h, s = (e + 1) / h;
737
+ for (let e = 0; e < a; e++) {
738
+ const i = e / a, s = (e + 1) / a;
739
739
  t.push(i, 0, i, 0, i, 1, i, 1, s, 1, s, 1);
740
740
  }
741
741
  return new Float32Array(t);
742
742
  }(32), be: 96, $e: WebGL2RenderingContext.TRIANGLES, fe: 16, ue: { le: { size: 2, offset: 0 }, de: { size: 2, offset: 8 } } };
743
- class Tt extends D {
743
+ class _t extends D {
744
744
  constructor(t, e) {
745
- super(t, e, w.ARC, bt);
745
+ super(t, e, E.ARC, Ct);
746
746
  }
747
- Fe(t, e) {
747
+ Re(t, e) {
748
748
  const i = t.x - t.width / 2, s = t.y - t.height / 2, r = t.start * Math.PI / 180, n = t.stop * Math.PI / 180, o = this.ws(i, s, t.width, t.height, e);
749
- return this.Ms(o, t.x, t.y), o.Xe = [r, n], this._s.Fe(o);
749
+ return this.Ms(o, t.x, t.y), o.je = [r, n], this._s.Re(o);
750
750
  }
751
751
  }
752
- const At = { Cs: new Float32Array([0, 0, 0, 0, 1, 0, 1, 0, 0.5, 1, 0.5, 1]), be: 3, $e: WebGL2RenderingContext.TRIANGLES, fe: 16, ue: { le: { size: 2, offset: 0 }, de: { size: 2, offset: 8 } } };
753
- class Ct extends D {
752
+ const Ut = { Cs: new Float32Array([0, 0, 0, 0, 1, 0, 1, 0, 0.5, 1, 0.5, 1]), be: 3, $e: WebGL2RenderingContext.TRIANGLES, fe: 16, ue: { le: { size: 2, offset: 0 }, de: { size: 2, offset: 8 } } };
753
+ class Ft extends D {
754
754
  constructor(t, e) {
755
- super(t, e, w.TRIANGLE, At);
755
+ super(t, e, E.TRIANGLE, Ut);
756
756
  }
757
- Fe(t, e) {
757
+ Re(t, e) {
758
758
  const i = Math.min(t.x1, t.x2, t.x3), s = Math.max(t.x1, t.x2, t.x3), r = Math.min(t.y1, t.y2, t.y3), n = s - i, o = Math.max(t.y1, t.y2, t.y3) - r, c = this.ws(i, r, n, o, e), l = i + 0.5 * n, u = r + o * (1 / 3);
759
- return this.Ms(c, l, u), this._s.Fe(c);
759
+ return this.Ms(c, l, u), this._s.Re(c);
760
760
  }
761
761
  }
762
- function et(h, t, e, i, s) {
763
- const r = 1 - h, n = r * r, o = h * h;
764
- return n * r * t + 3 * n * h * e + 3 * r * o * i + o * h * s;
762
+ function et(a, t, e, i, s) {
763
+ const r = 1 - a, n = r * r, o = a * a;
764
+ return n * r * t + 3 * n * a * e + 3 * r * o * i + o * a * s;
765
765
  }
766
- const _t = { Cs: function(h = 16) {
766
+ const Lt = { Cs: function(a = 16) {
767
767
  const t = [];
768
- for (let e = 0; e < h; e++) {
769
- const i = e / h, s = (e + 1) / h;
768
+ for (let e = 0; e < a; e++) {
769
+ const i = e / a, s = (e + 1) / a;
770
770
  t.push(i, -0.5, i, 0), t.push(s, -0.5, s, 0), t.push(i, 0.5, i, 1), t.push(i, 0.5, i, 1), t.push(s, -0.5, s, 0), t.push(s, 0.5, s, 1);
771
771
  }
772
772
  return new Float32Array(t);
773
773
  }(16), be: 96, $e: WebGL2RenderingContext.TRIANGLES, fe: 16, ue: { le: { size: 2, offset: 0 }, de: { size: 2, offset: 8 } } };
774
- class Ut extends D {
774
+ class Pt extends D {
775
775
  constructor(t, e) {
776
- super(t, e, w.BEZIER_CURVE, _t);
776
+ super(t, e, E.BEZIER_CURVE, Lt);
777
777
  }
778
- Fe(t, e) {
779
- const i = e.O || 1, s = et(0.5, t.x1, t.cp1x, t.cp2x, t.x2), r = et(0.5, t.y1, t.cp1y, t.cp2y, t.y2), n = this.ws(0, 0, 1, i, e);
780
- return this.Ms(n, s, r), n.qe = [t.x1, t.y1], n.je = [t.cp1x, t.cp1y], n.Ye = [t.cp2x, t.cp2y], n.Ze = [t.x2, t.y2], this._s.Fe(n);
778
+ Re(t, e) {
779
+ const i = e.W || 1, s = et(0.5, t.x1, t.cp1x, t.cp2x, t.x2), r = et(0.5, t.y1, t.cp1y, t.cp2y, t.y2), n = this.ws(0, 0, 1, i, e);
780
+ return this.Ms(n, s, r), n.qe = [t.x1, t.y1], n.Ne = [t.cp1x, t.cp1y], n.Ye = [t.cp2x, t.cp2y], n.Ze = [t.x2, t.y2], this._s.Re(n);
781
781
  }
782
782
  }
783
- class Lt {
783
+ class St {
784
784
  constructor(t) {
785
- a(this, "vt");
786
- a(this, "Rs", null);
787
- a(this, "Fs");
788
- a(this, "Ss", null);
789
- a(this, "As", {});
790
- a(this, "zs", null);
791
- a(this, "Ts", /* @__PURE__ */ new Map());
792
- a(this, "Es");
793
- a(this, "Ls");
794
- a(this, "Ps");
795
- a(this, "I", []);
796
- this.vt = t, this.Fs = new ft(t), this.Ps = new ht(), this.Es = new gt(t, this), this.Ls = new pt(), this.zs = t.createBuffer(), W(this.vt, [0, 0, this.vt.canvas.width, this.vt.canvas.height]);
797
- }
798
- ks(t) {
799
- let e = this.Ts.get(t);
785
+ h(this, "vt");
786
+ h(this, "Ss", null);
787
+ h(this, "Rs");
788
+ h(this, "Fs", null);
789
+ h(this, "Ts", {});
790
+ h(this, "As", null);
791
+ h(this, "Es", /* @__PURE__ */ new Map());
792
+ h(this, "ks");
793
+ h(this, "zs");
794
+ h(this, "Ps");
795
+ h(this, "I", []);
796
+ this.vt = t, this.Rs = new mt(t), this.Ps = new ht(), this.ks = new vt(t, this), this.zs = new yt(), this.As = t.createBuffer(), Y(this.vt, [0, 0, this.vt.canvas.width, this.vt.canvas.height]);
797
+ }
798
+ Ls(t) {
799
+ let e = this.Es.get(t);
800
800
  if (e) return e;
801
- const i = new mt(this.vt);
802
- return e = (0, { [w.RECTANGLE]: () => new xt(this.vt, i), [w.LINE]: () => new Et(this.vt, i), [w.ELLIPSE]: () => new Rt(this.vt, i), [w.ARC]: () => new Tt(this.vt, i), [w.TRIANGLE]: () => new Ct(this.vt, i), [w.BEZIER_CURVE]: () => new Ut(this.vt, i) }[t])(), this.Ts.set(t, e), e;
801
+ const i = new xt(this.vt);
802
+ return e = (0, { [E.RECTANGLE]: () => new Et(this.vt, i), [E.LINE]: () => new bt(this.vt, i), [E.ELLIPSE]: () => new At(this.vt, i), [E.ARC]: () => new _t(this.vt, i), [E.TRIANGLE]: () => new Ft(this.vt, i), [E.BEZIER_CURVE]: () => new Pt(this.vt, i) }[t])(), this.Es.set(t, e), e;
803
803
  }
804
- Gs(t) {
805
- this.Rs !== t && (this.Rs = t, t.Vt());
804
+ Ds(t) {
805
+ this.Ss !== t && (this.Ss = t, t.Xt());
806
806
  }
807
- ae(t, e) {
808
- return this.Fs.ae(t, e);
807
+ he(t, e) {
808
+ return this.Rs.he(t, e);
809
809
  }
810
810
  ie() {
811
- return this.Fs.ie();
811
+ return this.Rs.ie();
812
812
  }
813
- Tt() {
814
- return this.Fs.Tt();
813
+ Et() {
814
+ return this.Rs.Et();
815
815
  }
816
816
  re() {
817
- return this.Fs.re();
817
+ return this.Rs.re();
818
818
  }
819
819
  ne() {
820
- return this.Fs.ne();
820
+ return this.Rs.ne();
821
821
  }
822
- Bs(t) {
823
- this.Ss = t, t && (this.As = {});
822
+ Gs(t) {
823
+ this.Fs = t, t && (this.Ts = {});
824
824
  }
825
- Xt(t, e) {
826
- this.As[t] = e;
825
+ jt(t, e) {
826
+ this.Ts[t] = e;
827
827
  }
828
- Ds(t) {
829
- Object.assign(this.As, t);
828
+ Bs(t) {
829
+ Object.assign(this.Ts, t);
830
830
  }
831
831
  oe(t) {
832
- return this.Fs.oe(t);
832
+ return this.Rs.oe(t);
833
833
  }
834
834
  Is(t, e, i, s, r) {
835
835
  const n = this.ie(), o = { Ue: t.textures[0], Uf: t.textures[1], Ug: t.textures[2], Uh: t.textures[3], Ui: t.textures[4], Uj: [t.width, t.height] };
836
- this.Ls.Ge(e, i, s, r, n, o, this.Ps);
836
+ this.zs.De(e, i, s, r, n, o, this.Ps);
837
837
  }
838
- Ws(t, e, i, s, r) {
839
- const n = this.ne(), o = t.Os(), c = { Uk: o.texture, Ul: !!o.invert, Um: !!o.flipX, Un: !!o.flipY, Uo: o.charRotation, Up: o.charColorFixed, Uq: o.charColor, Ur: o.cellColorFixed, Us: o.cellColor, Ut: o.backgroundColor, Uu: o.charCount, Uv: o.charList };
840
- this.Ls.Ge(e, i, s, r, n, c, this.Ps);
838
+ Os(t, e, i, s, r) {
839
+ const n = this.ne(), o = t.Ws(), c = { Uk: o.texture, Ul: !!o.invert, Um: !!o.flipX, Un: !!o.flipY, Uo: o.charRotation, Up: o.charColorFixed, Uq: o.charColor, Ur: o.cellColorFixed, Us: o.cellColor, Ut: o.backgroundColor, Uu: o.charCount, Uv: o.charList };
840
+ this.zs.De(e, i, s, r, n, c, this.Ps);
841
841
  }
842
842
  Hs(t, e, i, s) {
843
843
  var d;
844
844
  const r = this.vt, n = r.canvas.width, o = r.canvas.height, c = t / n * 2 - 1, l = (t + i) / n * 2 - 1, u = 1 - e / o * 2, f = 1 - (e + s) / o * 2, g = new Float32Array([c, f, l, f, c, u, l, f, l, u, c, u]);
845
- r.bindBuffer(r.ARRAY_BUFFER, this.zs), r.bufferData(r.ARRAY_BUFFER, g, r.DYNAMIC_DRAW);
846
- const v = ((d = this.Rs) == null ? void 0 : d.Jt) || r.getParameter(r.CURRENT_PROGRAM), m = v ? r.getAttribLocation(v, "a_position") : -1;
847
- m !== -1 && (r.enableVertexAttribArray(m), r.vertexAttribPointer(m, 2, r.FLOAT, !1, 8, 0)), r.drawArrays(r.TRIANGLES, 0, 6), m !== -1 && r.disableVertexAttribArray(m);
845
+ r.bindBuffer(r.ARRAY_BUFFER, this.As), r.bufferData(r.ARRAY_BUFFER, g, r.DYNAMIC_DRAW);
846
+ const v = ((d = this.Ss) == null ? void 0 : d.Jt) || r.getParameter(r.CURRENT_PROGRAM), p = v ? r.getAttribLocation(v, "a_position") : -1;
847
+ p !== -1 && (r.enableVertexAttribArray(p), r.vertexAttribPointer(p, 2, r.FLOAT, !1, 8, 0)), r.drawArrays(r.TRIANGLES, 0, 6), p !== -1 && r.disableVertexAttribArray(p);
848
+ }
849
+ Xs(t, e, i, s) {
850
+ this.Fs ? (this.zs.De(t, e, i, s, this.Fs, { ...this.Ts }, this.Ps), this.Fs = null, this.Ts = {}) : this.zs.Le(t, e, i, s, this.Ps);
848
851
  }
849
852
  Vs(t, e, i, s) {
850
- this.Ss ? (this.Ls.Ge(t, e, i, s, this.Ss, { ...this.As }, this.Ps), this.Ss = null, this.As = {}) : this.Ls.ke(t, e, i, s, this.Ps);
853
+ this.zs.Ge(t, e, i, s, this.Ps.lineWeight, this.Ps);
851
854
  }
852
855
  Ks(t, e, i, s) {
853
- this.Ls.Be(t, e, i, s, this.Ps.lineWeight, this.Ps);
854
- }
855
- Ns(t, e, i, s) {
856
- this.Ls.De(t, e, i, s, this.Ps);
856
+ this.zs.Be(t, e, i, s, this.Ps);
857
857
  }
858
- Xs(t, e, i, s, r, n) {
859
- this.Ls.We(t, e, i, s, r, n, this.Ps);
858
+ js(t, e, i, s, r, n) {
859
+ this.zs.Oe(t, e, i, s, r, n, this.Ps);
860
860
  }
861
- js(t, e, i, s, r, n, o, c) {
861
+ Ns(t, e, i, s, r, n, o, c) {
862
862
  const l = this.Ps.lineWeight;
863
- this.Ls.Oe(t, e, i, s, r, n, o, c, l, this.Ps);
863
+ this.zs.We(t, e, i, s, r, n, o, c, l, this.Ps);
864
864
  }
865
865
  Ys(t, e, i = 1, s = {}) {
866
- return new j(this.vt, t, e, i, s, this, !0);
866
+ return new K(this.vt, t, e, i, s, this, !0);
867
867
  }
868
868
  qs(t, e, i, s, r, n) {
869
- this.Ls.Ie(t, e, i, s, r, n, this.Ps);
869
+ this.zs.Ie(t, e, i, s, r, n, this.Ps);
870
870
  }
871
871
  Zs(t, e = t, i = t, s = 255) {
872
- this.state.ft(t, e, i, s), this.He(t / 255, e / 255, i / 255, s / 255);
872
+ this.Ps.ft(t, e, i, s), this.He(t / 255, e / 255, i / 255, s / 255);
873
873
  }
874
874
  He(t = 0, e = 0, i = 0, s = 0) {
875
875
  this.vt.clearColor(t, e, i, s), this.vt.clear(this.vt.COLOR_BUFFER_BIT);
876
876
  }
877
877
  Js() {
878
- this.vt.viewport(0, 0, this.vt.canvas.width, this.vt.canvas.height), W(this.vt, [0, 0, this.vt.canvas.width, this.vt.canvas.height]);
878
+ this.vt.viewport(0, 0, this.vt.canvas.width, this.vt.canvas.height), Y(this.vt, [0, 0, this.vt.canvas.width, this.vt.canvas.height]);
879
879
  }
880
880
  get context() {
881
881
  return this.vt;
@@ -883,64 +883,64 @@ class Lt {
883
883
  get state() {
884
884
  return this.Ps;
885
885
  }
886
- Lt(t) {
886
+ zt(t) {
887
887
  this.I.push(this.Ps), this.Ps = t;
888
888
  }
889
889
  Pt() {
890
890
  const t = this.I.pop();
891
891
  t && (this.Ps = t);
892
892
  }
893
- Et(t) {
894
- const e = t, i = H(this.vt) ?? this.vt.getParameter(this.vt.VIEWPORT), s = { shader: e, gl: this.vt, viewport: i };
895
- this.Gs(e);
893
+ kt(t) {
894
+ const e = t, i = X(this.vt) ?? this.vt.getParameter(this.vt.VIEWPORT), s = { shader: e, gl: this.vt, viewport: i };
895
+ this.Ds(e);
896
896
  const r = /* @__PURE__ */ new Set();
897
- for (const n of this.Ls) n.type === w.CUSTOM ? r.add(w.RECTANGLE) : r.add(n.type);
898
- for (const n of r) n !== w.CUSTOM && this.ks(n);
899
- this.Es.ve(s, this.Ls, this.Ts), this.Ls.He();
897
+ for (const n of this.zs) n.type === E.CUSTOM ? r.add(E.RECTANGLE) : r.add(n.type);
898
+ for (const n of r) n !== E.CUSTOM && this.Ls(n);
899
+ this.ks.ve(s, this.zs, this.Es), this.zs.He();
900
900
  }
901
- kt() {
902
- this.vt.deleteBuffer(this.zs), this.Ls.He();
903
- for (const t of this.Ts.values()) t.kt();
904
- this.Fs.kt(), this.Es.kt();
901
+ Lt() {
902
+ this.vt.deleteBuffer(this.As), this.zs.He();
903
+ for (const t of this.Es.values()) t.Lt();
904
+ this.Rs.Lt(), this.ks.Lt();
905
905
  }
906
906
  }
907
- const R = { readShort: (h, t) => (R.t.uint16[0] = h[t] << 8 | h[t + 1], R.t.int16[0]), readUshort: (h, t) => h[t] << 8 | h[t + 1], readUshorts(h, t, e) {
907
+ 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) {
908
908
  const i = [];
909
- for (let s = 0; s < e; s++) i.push(R.readUshort(h, t + 2 * s));
909
+ for (let s = 0; s < e; s++) i.push(R.readUshort(a, t + 2 * s));
910
910
  return i;
911
- }, readUint(h, t) {
911
+ }, readUint(a, t) {
912
912
  const e = R.t.uint8;
913
- return e[3] = h[t], e[2] = h[t + 1], e[1] = h[t + 2], e[0] = h[t + 3], R.t.uint32[0];
914
- }, readASCII(h, t, e) {
913
+ return e[3] = a[t], e[2] = a[t + 1], e[1] = a[t + 2], e[0] = a[t + 3], R.t.uint32[0];
914
+ }, readASCII(a, t, e) {
915
915
  let i = "";
916
- for (let s = 0; s < e; s++) i += String.fromCharCode(h[t + s]);
916
+ for (let s = 0; s < e; s++) i += String.fromCharCode(a[t + s]);
917
917
  return i;
918
- }, writeUshort(h, t, e) {
919
- h[t] = e >>> 8 & 255, h[t + 1] = 255 & e;
920
- }, writeUint(h, t, e) {
921
- h[t] = e >>> 24 & 255, h[t + 1] = e >>> 16 & 255, h[t + 2] = e >>> 8 & 255, h[t + 3] = 255 & e;
922
- }, writeASCII(h, t, e) {
923
- for (let i = 0; i < e.length; i++) h[t + i] = 255 & e.charCodeAt(i);
918
+ }, writeUshort(a, t, e) {
919
+ a[t] = e >>> 8 & 255, a[t + 1] = 255 & e;
920
+ }, writeUint(a, t, e) {
921
+ a[t] = e >>> 24 & 255, a[t + 1] = e >>> 16 & 255, a[t + 2] = e >>> 8 & 255, a[t + 3] = 255 & e;
922
+ }, writeASCII(a, t, e) {
923
+ for (let i = 0; i < e.length; i++) a[t + i] = 255 & e.charCodeAt(i);
924
924
  }, t: (() => {
925
- const h = new ArrayBuffer(8);
926
- return { uint8: new Uint8Array(h), int16: new Int16Array(h), uint16: new Uint16Array(h), uint32: new Uint32Array(h) };
925
+ const a = new ArrayBuffer(8);
926
+ return { uint8: new Uint8Array(a), int16: new Int16Array(a), uint16: new Uint16Array(a), uint32: new Uint32Array(a) };
927
927
  })() };
928
- function z(h) {
929
- return h + 3 & -4;
928
+ function W(a) {
929
+ return a + 3 & -4;
930
930
  }
931
- function Y(h, t, e) {
931
+ function H(a, t, e) {
932
932
  const i = t + e;
933
933
  let s = 0;
934
934
  const r = R.t;
935
- for (let n = t; n < i; n += 4) r.uint8[3] = h[n] || 0, r.uint8[2] = h[n + 1] || 0, r.uint8[1] = h[n + 2] || 0, r.uint8[0] = h[n + 3] || 0, s = s + (r.uint32[0] >>> 0) >>> 0;
935
+ for (let n = t; n < i; n += 4) r.uint8[3] = a[n] || 0, r.uint8[2] = a[n + 1] || 0, r.uint8[1] = a[n + 2] || 0, r.uint8[0] = a[n + 3] || 0, s = s + (r.uint32[0] >>> 0) >>> 0;
936
936
  return s >>> 0;
937
937
  }
938
- class Ft {
938
+ class Bt {
939
939
  constructor(t) {
940
- a(this, "b");
941
- a(this, "p", 0);
942
- a(this, "bitbuf", 0);
943
- a(this, "bitcnt", 0);
940
+ h(this, "b");
941
+ h(this, "p", 0);
942
+ h(this, "bitbuf", 0);
943
+ h(this, "bitcnt", 0);
944
944
  this.b = t;
945
945
  }
946
946
  readBits(t) {
@@ -958,30 +958,30 @@ class Ft {
958
958
  return this.p;
959
959
  }
960
960
  }
961
- function O(h) {
961
+ function z(a) {
962
962
  let t = 32, e = 0;
963
- for (const o of h) o && (o < t && (t = o), o > e && (e = o));
963
+ for (const o of a) o && (o < t && (t = o), o > e && (e = o));
964
964
  if (e === 0) return { min: 0, max: 0, table: /* @__PURE__ */ new Map() };
965
965
  const i = new Uint32Array(e + 1);
966
- for (const o of h) o && i[o]++;
966
+ for (const o of a) o && i[o]++;
967
967
  const s = new Uint32Array(e + 1);
968
968
  let r = 0;
969
969
  i[0] = 0;
970
970
  for (let o = 1; o <= e; o++) r = r + i[o - 1] << 1, s[o] = r;
971
971
  const n = /* @__PURE__ */ new Map();
972
- for (let o = 0; o < h.length; o++) {
973
- const c = h[o];
972
+ for (let o = 0; o < a.length; o++) {
973
+ const c = a[o];
974
974
  if (!c) continue;
975
975
  const l = s[c]++;
976
976
  let u = n.get(c);
977
- u || (u = [], n.set(c, u)), u[Pt(l, c)] = o;
977
+ u || (u = [], n.set(c, u)), u[Mt(l, c)] = o;
978
978
  }
979
979
  return { min: t, max: e, table: n };
980
980
  }
981
- function V(h, t) {
981
+ function j(a, t) {
982
982
  let e = 0;
983
983
  for (let i = 1; i <= t.max; i++) {
984
- e |= h.readBits(1) << i - 1;
984
+ e |= a.readBits(1) << i - 1;
985
985
  const s = t.table.get(i);
986
986
  if (s && e < s.length) {
987
987
  const r = s[e];
@@ -990,14 +990,14 @@ function V(h, t) {
990
990
  }
991
991
  throw Error("Invalid Huffman code");
992
992
  }
993
- function Pt(h, t) {
993
+ function Mt(a, t) {
994
994
  let e = 0;
995
- for (let i = 0; i < t; i++) e = e << 1 | 1 & h, h >>>= 1;
995
+ for (let i = 0; i < t; i++) e = e << 1 | 1 & a, a >>>= 1;
996
996
  return e >>> 0;
997
997
  }
998
- function St(h) {
999
- if (h.length < 2) throw Error("ZLIB data too short");
1000
- const t = h[0], e = h[1];
998
+ function It(a) {
999
+ if (a.length < 2) throw Error("ZLIB data too short");
1000
+ const t = a[0], e = a[1];
1001
1001
  if ((15 & t) != 8) throw Error("Unsupported ZLIB compression method");
1002
1002
  if (((t << 8) + e) % 31 != 0) throw Error("Bad ZLIB header check");
1003
1003
  let i = 2;
@@ -1013,24 +1013,24 @@ function St(h) {
1013
1013
  r.alignToByte();
1014
1014
  const v = r.readBits(16);
1015
1015
  if ((65535 & (65535 ^ v)) !== r.readBits(16)) throw Error("DEFLATE uncompressed LEN/NLEN mismatch");
1016
- for (let m = 0; m < v; m++) n.push(r.readBits(8));
1016
+ for (let p = 0; p < v; p++) n.push(r.readBits(8));
1017
1017
  } else {
1018
1018
  if (g !== 1 && g !== 2) throw Error("Unsupported DEFLATE type");
1019
1019
  {
1020
- let v, m;
1020
+ let v, p;
1021
1021
  if (g === 1) {
1022
1022
  const d = Array(288).fill(0);
1023
- for (let x = 0; x <= 143; x++) d[x] = 8;
1024
- for (let x = 144; x <= 255; x++) d[x] = 9;
1025
- for (let x = 256; x <= 279; x++) d[x] = 7;
1026
- for (let x = 280; x <= 287; x++) d[x] = 8;
1027
- v = O(d), m = O(Array(32).fill(5));
1023
+ for (let y = 0; y <= 143; y++) d[y] = 8;
1024
+ for (let y = 144; y <= 255; y++) d[y] = 9;
1025
+ for (let y = 256; y <= 279; y++) d[y] = 7;
1026
+ for (let y = 280; y <= 287; y++) d[y] = 8;
1027
+ v = z(d), p = z(Array(32).fill(5));
1028
1028
  } else {
1029
- const d = r.readBits(5) + 257, x = r.readBits(5) + 1, p = r.readBits(4) + 4, E = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15], y = Array(19).fill(0);
1030
- for (let U = 0; U < p; U++) y[E[U]] = r.readBits(3);
1031
- const C = O(y), b = [];
1032
- for (; b.length < d + x; ) {
1033
- const U = V(r, C);
1029
+ const d = r.readBits(5) + 257, y = r.readBits(5) + 1, m = r.readBits(4) + 4, w = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15], x = Array(19).fill(0);
1030
+ for (let U = 0; U < m; U++) x[w[U]] = r.readBits(3);
1031
+ const C = z(x), b = [];
1032
+ for (; b.length < d + y; ) {
1033
+ const U = j(r, C);
1034
1034
  if (U <= 15) b.push(U);
1035
1035
  else if (U === 16) {
1036
1036
  const G = r.readBits(2) + 3, S = b[b.length - 1] || 0;
@@ -1046,172 +1046,172 @@ function St(h) {
1046
1046
  }
1047
1047
  }
1048
1048
  }
1049
- const T = b.slice(0, d), L = b.slice(d, d + x);
1050
- v = O(T), m = O(L);
1049
+ const T = b.slice(0, d), F = b.slice(d, d + y);
1050
+ v = z(T), p = z(F);
1051
1051
  }
1052
1052
  for (; ; ) {
1053
- const d = V(r, v);
1053
+ const d = j(r, v);
1054
1054
  if (d < 256) n.push(d);
1055
1055
  else {
1056
1056
  if (d === 256) break;
1057
1057
  if (d > 256 && d < 286) {
1058
- const x = d - 257;
1059
- let p = o[x];
1060
- const E = c[x];
1061
- E && (p += r.readBits(E));
1062
- const y = V(r, m);
1063
- if (y >= 30) throw Error("Invalid distance symbol");
1064
- let C = l[y];
1065
- const b = u[y];
1058
+ const y = d - 257;
1059
+ let m = o[y];
1060
+ const w = c[y];
1061
+ w && (m += r.readBits(w));
1062
+ const x = j(r, p);
1063
+ if (x >= 30) throw Error("Invalid distance symbol");
1064
+ let C = l[x];
1065
+ const b = u[x];
1066
1066
  b && (C += r.readBits(b));
1067
1067
  const T = n.length - C;
1068
1068
  if (T < 0) throw Error("Invalid distance");
1069
- for (let L = 0; L < p; L++) n.push(n[T + L] || 0);
1069
+ for (let F = 0; F < m; F++) n.push(n[T + F] || 0);
1070
1070
  } else if (d === 286 || d === 287) throw Error("Reserved length symbol");
1071
1071
  }
1072
1072
  }
1073
1073
  }
1074
1074
  }
1075
1075
  }
1076
- }(new Ft(h.subarray(i)), s), new Uint8Array(s);
1076
+ }(new Bt(a.subarray(i)), s), new Uint8Array(s);
1077
1077
  }
1078
- function Bt(h) {
1079
- const t = R, e = new Uint8Array(h);
1078
+ function Dt(a) {
1079
+ const t = R, e = new Uint8Array(a);
1080
1080
  if (t.readASCII(e, 0, 4) !== "wOFF") throw Error("Invalid WOFF signature");
1081
1081
  const i = t.readUint(e, 4), s = t.readUshort(e, 12), r = t.readUint(e, 16), n = [];
1082
1082
  let o = 44;
1083
- for (let p = 0; p < s; p++) {
1084
- const E = t.readASCII(e, o, 4), y = t.readUint(e, o + 4), C = t.readUint(e, o + 8), b = t.readUint(e, o + 12), T = t.readUint(e, o + 16);
1085
- n.push({ tag: E, offset: y, compLength: C, origLength: b, checksum: T }), o += 20;
1086
- }
1087
- for (const p of n) {
1088
- const E = new Uint8Array(e.buffer, p.offset, p.compLength);
1089
- if (p.compLength === p.origLength) p.data = new Uint8Array(E);
1090
- else if (p.data = St(E), p.data.length !== p.origLength) if (p.data.length < p.origLength) {
1091
- const y = new Uint8Array(p.origLength);
1092
- y.set(p.data), p.data = y;
1093
- } else p.data = p.data.subarray(0, p.origLength);
1083
+ for (let m = 0; m < s; m++) {
1084
+ const w = t.readASCII(e, o, 4), x = t.readUint(e, o + 4), C = t.readUint(e, o + 8), b = t.readUint(e, o + 12), T = t.readUint(e, o + 16);
1085
+ n.push({ tag: w, offset: x, compLength: C, origLength: b, checksum: T }), o += 20;
1086
+ }
1087
+ for (const m of n) {
1088
+ const w = new Uint8Array(e.buffer, m.offset, m.compLength);
1089
+ if (m.compLength === m.origLength) m.data = new Uint8Array(w);
1090
+ else if (m.data = It(w), m.data.length !== m.origLength) if (m.data.length < m.origLength) {
1091
+ const x = new Uint8Array(m.origLength);
1092
+ x.set(m.data), m.data = x;
1093
+ } else m.data = m.data.subarray(0, m.origLength);
1094
1094
  }
1095
1095
  const c = s;
1096
1096
  let l = 1, u = 0;
1097
1097
  for (; l << 1 <= c; ) l <<= 1, u++;
1098
1098
  const f = 16 * l, g = 16 * c - f;
1099
1099
  let v = 12 + 16 * c;
1100
- const m = {};
1101
- for (const p of n) m[p.tag] = v, v = z(v + p.data.length);
1100
+ const p = {};
1101
+ for (const m of n) p[m.tag] = v, v = W(v + m.data.length);
1102
1102
  const d = new Uint8Array(Math.max(r || 0, v));
1103
1103
  t.writeUint(d, 0, i), t.writeUshort(d, 4, c), t.writeUshort(d, 6, f), t.writeUshort(d, 8, u), t.writeUshort(d, 10, g);
1104
- let x = 12;
1105
- for (const p of n) {
1106
- t.writeASCII(d, x, p.tag), x += 4;
1107
- let E = p.data;
1108
- if (p.tag === "head" && E.length >= 12) {
1109
- const y = new Uint8Array(E);
1110
- t.writeUint(y, 8, 0);
1111
- const C = Y(y, 0, z(y.length));
1112
- t.writeUint(d, x, C), x += 4;
1104
+ let y = 12;
1105
+ for (const m of n) {
1106
+ t.writeASCII(d, y, m.tag), y += 4;
1107
+ let w = m.data;
1108
+ if (m.tag === "head" && w.length >= 12) {
1109
+ const x = new Uint8Array(w);
1110
+ t.writeUint(x, 8, 0);
1111
+ const C = H(x, 0, W(x.length));
1112
+ t.writeUint(d, y, C), y += 4;
1113
1113
  } else {
1114
- const y = Y(E, 0, z(E.length));
1115
- t.writeUint(d, x, y), x += 4;
1114
+ const x = H(w, 0, W(w.length));
1115
+ t.writeUint(d, y, x), y += 4;
1116
1116
  }
1117
- t.writeUint(d, x, m[p.tag]), x += 4, t.writeUint(d, x, p.data.length), x += 4;
1117
+ t.writeUint(d, y, p[m.tag]), y += 4, t.writeUint(d, y, m.data.length), y += 4;
1118
1118
  }
1119
- for (const p of n) {
1120
- const E = m[p.tag];
1121
- d.set(p.data, E);
1119
+ for (const m of n) {
1120
+ const w = p[m.tag];
1121
+ d.set(m.data, w);
1122
1122
  }
1123
- if (n.find((p) => p.tag === "head")) {
1124
- const p = m.head, E = function(y, C) {
1125
- const b = R, T = C + 8, L = [y[T], y[T + 1], y[T + 2], y[T + 3]];
1126
- b.writeUint(y, T, 0);
1127
- const U = 2981146554 - (Y(y, 0, z(y.length)) >>> 0) >>> 0;
1128
- return y[T] = L[0], y[T + 1] = L[1], y[T + 2] = L[2], y[T + 3] = L[3], U >>> 0;
1129
- }(d, p);
1130
- t.writeUint(d, p + 8, E);
1123
+ if (n.find((m) => m.tag === "head")) {
1124
+ const m = p.head, w = function(x, C) {
1125
+ const b = R, T = C + 8, F = [x[T], x[T + 1], x[T + 2], x[T + 3]];
1126
+ b.writeUint(x, T, 0);
1127
+ const U = 2981146554 - (H(x, 0, W(x.length)) >>> 0) >>> 0;
1128
+ return x[T] = F[0], x[T + 1] = F[1], x[T + 2] = F[2], x[T + 3] = F[3], U >>> 0;
1129
+ }(d, m);
1130
+ t.writeUint(d, m + 8, w);
1131
1131
  }
1132
1132
  return d.buffer;
1133
1133
  }
1134
- const Mt = { parseTab(h, t, e) {
1134
+ const Gt = { parseTab(a, t, e) {
1135
1135
  const i = { tables: [], ids: {}, off: t };
1136
- h = new Uint8Array(h.buffer, t, e), t = 0;
1137
- const s = R, r = s.readUshort, n = r(h, t += 2);
1136
+ a = new Uint8Array(a.buffer, t, e), t = 0;
1137
+ const s = R, r = s.readUshort, n = r(a, t += 2);
1138
1138
  t += 2;
1139
1139
  const o = [];
1140
1140
  for (let c = 0; c < n; c++) {
1141
- const l = r(h, t), u = r(h, t += 2);
1141
+ const l = r(a, t), u = r(a, t += 2);
1142
1142
  t += 2;
1143
- const f = s.readUint(h, t);
1143
+ const f = s.readUint(a, t);
1144
1144
  t += 4;
1145
1145
  const g = `p${l}e${u}`;
1146
1146
  let v = o.indexOf(f);
1147
1147
  if (v === -1) {
1148
- let m;
1148
+ let p;
1149
1149
  v = i.tables.length, o.push(f);
1150
- const d = r(h, f);
1151
- m = d === 4 ? this.parse4(h, f) : d === 12 ? this.parse12(h, f) : { format: d }, i.tables.push(m);
1150
+ const d = r(a, f);
1151
+ p = d === 4 ? this.parse4(a, f) : d === 12 ? this.parse12(a, f) : { format: d }, i.tables.push(p);
1152
1152
  }
1153
1153
  i.ids[g] = v;
1154
1154
  }
1155
1155
  return i;
1156
- }, parse4(h, t) {
1157
- const e = R, i = e.readUshort, s = e.readUshorts, r = t, n = i(h, t += 2);
1156
+ }, parse4(a, t) {
1157
+ const e = R, i = e.readUshort, s = e.readUshorts, r = t, n = i(a, t += 2);
1158
1158
  t += 2;
1159
- const o = i(h, t += 2) >>> 1, c = { format: 4, searchRange: i(h, t += 2), entrySelector: 0, rangeShift: 0, endCount: [], startCount: [], idDelta: [], idRangeOffset: [], glyphIdArray: [] };
1160
- t += 2, c.entrySelector = i(h, t), t += 2, c.rangeShift = i(h, t), t += 2, c.endCount = s(h, t, o), t += 2 * o, t += 2, c.startCount = s(h, t, o), t += 2 * o;
1161
- for (let l = 0; l < o; l++) c.idDelta.push(e.readShort(h, t)), t += 2;
1162
- return c.idRangeOffset = s(h, t, o), t += 2 * o, c.glyphIdArray = s(h, t, r + n - t >> 1), c;
1163
- }, parse12(h, t) {
1159
+ const o = i(a, t += 2) >>> 1, c = { format: 4, searchRange: i(a, t += 2), entrySelector: 0, rangeShift: 0, endCount: [], startCount: [], idDelta: [], idRangeOffset: [], glyphIdArray: [] };
1160
+ 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;
1161
+ for (let l = 0; l < o; l++) c.idDelta.push(e.readShort(a, t)), t += 2;
1162
+ return c.idRangeOffset = s(a, t, o), t += 2 * o, c.glyphIdArray = s(a, t, r + n - t >> 1), c;
1163
+ }, parse12(a, t) {
1164
1164
  const e = R.readUint;
1165
- e(h, t += 4), e(h, t += 4);
1166
- const i = e(h, t += 4);
1165
+ e(a, t += 4), e(a, t += 4);
1166
+ const i = e(a, t += 4);
1167
1167
  t += 4;
1168
1168
  const s = new Uint32Array(3 * i);
1169
- for (let r = 0; r < 3 * i; r += 3) s[r] = e(h, t + (r << 2)), s[r + 1] = e(h, t + (r << 2) + 4), s[r + 2] = e(h, t + (r << 2) + 8);
1169
+ 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);
1170
1170
  return { format: 12, groups: s };
1171
- } }, It = { parseTab(h, t, e) {
1171
+ } }, zt = { parseTab(a, t, e) {
1172
1172
  const i = R;
1173
1173
  t += 18;
1174
- const s = i.readUshort(h, t);
1174
+ const s = i.readUshort(a, t);
1175
1175
  t += 2, t += 16;
1176
- const r = i.readShort(h, t);
1176
+ const r = i.readShort(a, t);
1177
1177
  t += 2;
1178
- const n = i.readShort(h, t);
1178
+ const n = i.readShort(a, t);
1179
1179
  t += 2;
1180
- const o = i.readShort(h, t);
1180
+ const o = i.readShort(a, t);
1181
1181
  t += 2;
1182
- const c = i.readShort(h, t);
1183
- return t += 2, t += 6, { unitsPerEm: s, xMin: r, yMin: n, xMax: o, yMax: c, indexToLocFormat: i.readShort(h, t) };
1184
- } }, Dt = { parseTab(h, t, e) {
1182
+ const c = i.readShort(a, t);
1183
+ return t += 2, t += 6, { unitsPerEm: s, xMin: r, yMin: n, xMax: o, yMax: c, indexToLocFormat: i.readShort(a, t) };
1184
+ } }, Ot = { parseTab(a, t, e) {
1185
1185
  const i = R;
1186
1186
  t += 4;
1187
1187
  const s = ["ascender", "descender", "lineGap", "advanceWidthMax", "minLeftSideBearing", "minRightSideBearing", "xMaxExtent", "caretSlopeRise", "caretSlopeRun", "caretOffset", "res0", "res1", "res2", "res3", "metricDataFormat", "numberOfHMetrics"], r = {};
1188
1188
  for (let n = 0; n < s.length; n++) {
1189
1189
  const o = s[n], c = o === "advanceWidthMax" || o === "numberOfHMetrics" ? i.readUshort : i.readShort;
1190
- r[o] = c(h, t + 2 * n);
1190
+ r[o] = c(a, t + 2 * n);
1191
1191
  }
1192
1192
  return r;
1193
- } }, Gt = { parseTab(h, t, e, i) {
1193
+ } }, $t = { parseTab(a, t, e, i) {
1194
1194
  const s = R, r = [], n = [], o = i.maxp.numGlyphs, c = i.hhea.numberOfHMetrics;
1195
1195
  let l = 0, u = 0, f = 0;
1196
- for (; f < c; ) l = s.readUshort(h, t + (f << 2)), u = s.readShort(h, t + (f << 2) + 2), r.push(l), n.push(u), f++;
1196
+ for (; f < c; ) l = s.readUshort(a, t + (f << 2)), u = s.readShort(a, t + (f << 2) + 2), r.push(l), n.push(u), f++;
1197
1197
  for (; f < o; ) r.push(l), n.push(u), f++;
1198
1198
  return { aWidth: r, lsBearing: n };
1199
- } }, it = { cmap: Mt, head: It, hhea: Dt, maxp: { parseTab(h, t, e) {
1199
+ } }, it = { cmap: Gt, head: zt, hhea: Ot, maxp: { parseTab(a, t, e) {
1200
1200
  const i = R;
1201
- return i.readUint(h, t), t += 4, { numGlyphs: i.readUshort(h, t) };
1202
- } }, hmtx: Gt, loca: { parseTab(h, t, e, i) {
1201
+ return i.readUint(a, t), t += 4, { numGlyphs: i.readUshort(a, t) };
1202
+ } }, hmtx: $t, loca: { parseTab(a, t, e, i) {
1203
1203
  const s = R, r = [], n = i.head.indexToLocFormat, o = i.maxp.numGlyphs + 1;
1204
- if (n === 0) for (let c = 0; c < o; c++) r.push(s.readUshort(h, t + (c << 1)) << 1);
1205
- else if (n === 1) for (let c = 0; c < o; c++) r.push(s.readUint(h, t + (c << 2)));
1204
+ if (n === 0) for (let c = 0; c < o; c++) r.push(s.readUshort(a, t + (c << 1)) << 1);
1205
+ else if (n === 1) for (let c = 0; c < o; c++) r.push(s.readUint(a, t + (c << 2)));
1206
1206
  return r;
1207
- } }, glyf: { parseTab(h, t, e, i) {
1207
+ } }, glyf: { parseTab(a, t, e, i) {
1208
1208
  const s = [], r = i.maxp.numGlyphs;
1209
1209
  for (let n = 0; n < r; n++) s.push(null);
1210
1210
  return s;
1211
- }, Qs(h, t) {
1212
- const e = R, i = h.ti, s = h.loca;
1211
+ }, Qs(a, t) {
1212
+ const e = R, i = a.ti, s = a.loca;
1213
1213
  if (s[t] === s[t + 1]) return null;
1214
- const r = F.findTable(i, "glyf", h.ei);
1214
+ const r = L.findTable(i, "glyf", a.ei);
1215
1215
  if (!r) return null;
1216
1216
  let n = r[0] + s[t];
1217
1217
  const o = {};
@@ -1227,54 +1227,54 @@ const Mt = { parseTab(h, t, e) {
1227
1227
  for (let g = 0; g < l; g++) {
1228
1228
  const v = i[n];
1229
1229
  if (n++, o.flags.push(v), 8 & v) {
1230
- const m = i[n];
1230
+ const p = i[n];
1231
1231
  n++;
1232
- for (let d = 0; d < m; d++) o.flags.push(v), g++;
1232
+ for (let d = 0; d < p; d++) o.flags.push(v), g++;
1233
1233
  }
1234
1234
  }
1235
1235
  o.xs = [];
1236
1236
  for (let g = 0; g < l; g++) {
1237
- const v = o.flags[g], m = !!(16 & v);
1238
- 2 & v ? (o.xs.push(m ? i[n] : -i[n]), n++) : m ? o.xs.push(0) : (o.xs.push(e.readShort(i, n)), n += 2);
1237
+ const v = o.flags[g], p = !!(16 & v);
1238
+ 2 & v ? (o.xs.push(p ? i[n] : -i[n]), n++) : p ? o.xs.push(0) : (o.xs.push(e.readShort(i, n)), n += 2);
1239
1239
  }
1240
1240
  o.ys = [];
1241
1241
  for (let g = 0; g < l; g++) {
1242
- const v = o.flags[g], m = !!(32 & v);
1243
- 4 & v ? (o.ys.push(m ? i[n] : -i[n]), n++) : m ? o.ys.push(0) : (o.ys.push(e.readShort(i, n)), n += 2);
1242
+ const v = o.flags[g], p = !!(32 & v);
1243
+ 4 & v ? (o.ys.push(p ? i[n] : -i[n]), n++) : p ? o.ys.push(0) : (o.ys.push(e.readShort(i, n)), n += 2);
1244
1244
  }
1245
1245
  let u = 0, f = 0;
1246
1246
  for (let g = 0; g < l; g++) u += o.xs[g], f += o.ys[g], o.xs[g] = u, o.ys[g] = f;
1247
1247
  } else o.parts = [], o.endPts = [], o.flags = [], o.xs = [], o.ys = [];
1248
1248
  return o;
1249
- } } }, F = { parse(h) {
1250
- const t = new Uint8Array(h), e = R.readASCII(t, 0, 4);
1251
- if (e === "wOFF") h = Bt(h);
1249
+ } } }, L = { parse(a) {
1250
+ const t = new Uint8Array(a), e = R.readASCII(t, 0, 4);
1251
+ if (e === "wOFF") a = Dt(a);
1252
1252
  else if (e === "wOF2") throw Error("WOFF2 is not supported in this build (Brotli + WOFF2 transforms required)");
1253
1253
  return [((i, s, r, n) => {
1254
1254
  const o = it, c = { ti: i, si: s, ei: r };
1255
1255
  for (const l in o) {
1256
- const u = l, f = F.findTable(i, u, r);
1256
+ const u = l, f = L.findTable(i, u, r);
1257
1257
  if (f) {
1258
1258
  const [g, v] = f;
1259
- let m = n[g];
1260
- m == null && (m = o[u].parseTab(i, g, v, c), n[g] = m), c[u] = m;
1259
+ let p = n[g];
1260
+ p == null && (p = o[u].parseTab(i, g, v, c), n[g] = p), c[u] = p;
1261
1261
  }
1262
1262
  }
1263
1263
  return c;
1264
- })(new Uint8Array(h), 0, 0, {})];
1265
- }, findTable(h, t, e) {
1266
- const i = R, s = i.readUshort(h, e + 4);
1264
+ })(new Uint8Array(a), 0, 0, {})];
1265
+ }, findTable(a, t, e) {
1266
+ const i = R, s = i.readUshort(a, e + 4);
1267
1267
  let r = e + 12;
1268
1268
  for (let n = 0; n < s; n++) {
1269
- const o = i.readASCII(h, r, 4);
1270
- i.readUint(h, r + 4);
1271
- const c = i.readUint(h, r + 8), l = i.readUint(h, r + 12);
1269
+ const o = i.readASCII(a, r, 4);
1270
+ i.readUint(a, r + 4);
1271
+ const c = i.readUint(a, r + 8), l = i.readUint(a, r + 12);
1272
1272
  if (o === t) return [c, l];
1273
1273
  r += 16;
1274
1274
  }
1275
1275
  return null;
1276
1276
  }, T: it, B: R };
1277
- class Ot {
1277
+ class Nt {
1278
1278
  ii(t) {
1279
1279
  var i;
1280
1280
  const e = [];
@@ -1289,7 +1289,7 @@ class Ot {
1289
1289
  }), [...new Set(e)]) : [];
1290
1290
  }
1291
1291
  oi(t) {
1292
- return t.filter((e) => this.ai(e));
1292
+ return t.filter((e) => this.hi(e));
1293
1293
  }
1294
1294
  ri(t) {
1295
1295
  const e = [];
@@ -1298,7 +1298,7 @@ class Ot {
1298
1298
  const s = t.startCount[i], r = t.endCount[i];
1299
1299
  if (s !== 65535 || r !== 65535) {
1300
1300
  for (let n = s; n <= r; n++)
1301
- if (this.hi(t, n, i) > 0) try {
1301
+ if (this.ai(t, n, i) > 0) try {
1302
1302
  const o = String.fromCodePoint(n);
1303
1303
  e.push(o);
1304
1304
  } catch {
@@ -1321,7 +1321,7 @@ class Ot {
1321
1321
  }
1322
1322
  return e;
1323
1323
  }
1324
- hi(t, e, i) {
1324
+ ai(t, e, i) {
1325
1325
  if (t.idRangeOffset[i] === 0) return e + t.idDelta[i] & 65535;
1326
1326
  {
1327
1327
  const s = t.idRangeOffset[i] / 2 + (e - t.startCount[i]) - (t.startCount.length - i);
@@ -1332,15 +1332,15 @@ class Ot {
1332
1332
  }
1333
1333
  return 0;
1334
1334
  }
1335
- ai(t) {
1335
+ hi(t) {
1336
1336
  const e = t.codePointAt(0) || 0;
1337
1337
  return !(e >= 0 && e <= 31 && e !== 9 && e !== 10 && e !== 13 || e >= 127 && e <= 159);
1338
1338
  }
1339
1339
  }
1340
1340
  class q {
1341
1341
  constructor() {
1342
- a(this, "ci", /* @__PURE__ */ new Map());
1343
- a(this, "li", /* @__PURE__ */ new Map());
1342
+ h(this, "ci", /* @__PURE__ */ new Map());
1343
+ h(this, "li", /* @__PURE__ */ new Map());
1344
1344
  }
1345
1345
  ui(t, e) {
1346
1346
  const i = `${this.fi(t)}_${e}`;
@@ -1396,47 +1396,47 @@ class q {
1396
1396
  return 0;
1397
1397
  }
1398
1398
  }
1399
- class $t {
1399
+ class Wt {
1400
1400
  constructor(t) {
1401
- a(this, "Ci");
1402
- a(this, "wi");
1403
- a(this, "xt");
1404
- a(this, "$i");
1405
- this.xt = t, this.$i = new q(), this.Ci = document.createElement("canvas"), this.wi = this.Ci.getContext("2d", { willReadFrequently: !0, alpha: !1 });
1401
+ h(this, "Ci");
1402
+ h(this, "wi");
1403
+ h(this, "xt");
1404
+ h(this, "$i");
1405
+ this.xt = t, this.$i = new q(), this.Ci = document.createElement("canvas"), this.wi = this.Ci.getContext("2d", { willReadFrequently: !0, alpha: !0 });
1406
1406
  }
1407
1407
  createTextureAtlas(t, e, i, s) {
1408
1408
  const r = t.length, n = Math.ceil(Math.sqrt(r)), o = Math.ceil(r / n), c = e.width * n, l = e.height * o, u = typeof s == "object" ? s : null;
1409
1409
  this.bi(c, l), this.xi(t, e, n, i, u);
1410
1410
  const f = this.xt.Ys(c, l, 1, { filter: "nearest" });
1411
- return f.At(this.Ci), { framebuffer: f, columns: n, rows: o };
1411
+ return f.Tt(this.Ci), { framebuffer: f, columns: n, rows: o };
1412
1412
  }
1413
1413
  bi(t, e) {
1414
- this.Ci.width = t, this.Ci.height = e, this.Ci.style.width = t + "px", this.Ci.style.height = t + "px", this.wi.imageSmoothingEnabled = !1, this.Ci.style.imageRendering = "pixelated", this.wi.fillStyle = "black", this.wi.fillRect(0, 0, t, e), this.wi.textBaseline = "top", this.wi.textAlign = "left", this.wi.fillStyle = "white";
1414
+ this.Ci.width = t, this.Ci.height = e, this.Ci.style.width = t + "px", this.Ci.style.height = e + "px", this.wi.imageSmoothingEnabled = !1, this.Ci.style.imageRendering = "pixelated", this.wi.clearRect(0, 0, t, e), this.wi.textBaseline = "top", this.wi.textAlign = "left", this.wi.fillStyle = "white";
1415
1415
  }
1416
1416
  xi(t, e, i, s, r) {
1417
1417
  const n = s / r.head.unitsPerEm;
1418
1418
  for (let o = 0; o < t.length; o++) {
1419
1419
  const c = o % i, l = Math.floor(o / i), u = t[o].character, f = this.Mi(r, u);
1420
1420
  if (!f) continue;
1421
- const g = u.codePointAt(0) || 0, v = this.$i.ui(r, g), m = this.Ri(r, v) * n, d = c * e.width, x = l * e.height, p = d + 0.5 * e.width, E = x + 0.5 * e.height, y = Math.round(p - 0.5 * e.width), C = Math.round(E - 0.5 * s), b = y + 0.5 * (e.width - m), T = C + r.hhea.ascender * n;
1422
- this.Fi(f, b, T, n);
1421
+ const g = u.codePointAt(0) || 0, v = this.$i.ui(r, g), p = this.Si(r, v) * n, d = c * e.width, y = l * e.height, m = d + 0.5 * e.width, w = y + 0.5 * e.height, x = Math.round(m - 0.5 * e.width), C = Math.round(w - 0.5 * s), b = x + 0.5 * (e.width - p), T = C + r.hhea.ascender * n;
1422
+ this.Ri(f, b, T, n);
1423
1423
  }
1424
1424
  }
1425
1425
  Mi(t, e) {
1426
1426
  const i = e.codePointAt(0) || 0, s = this.$i.ui(t, i);
1427
1427
  if (s === 0) return null;
1428
1428
  if (t.glyf && t.glyf[s] !== null) return t.glyf[s];
1429
- if (F && F.T && F.T.glyf) {
1430
- const r = F.T.glyf.Qs(t, s);
1429
+ if (L && L.T && L.T.glyf) {
1430
+ const r = L.T.glyf.Qs(t, s);
1431
1431
  return t.glyf && r && (t.glyf[s] = r), r;
1432
1432
  }
1433
1433
  return null;
1434
1434
  }
1435
- Ri(t, e) {
1435
+ Si(t, e) {
1436
1436
  const i = t.hmtx;
1437
1437
  return i && i.aWidth ? e < i.aWidth.length ? i.aWidth[e] : i.aWidth[i.aWidth.length - 1] : 0;
1438
1438
  }
1439
- Fi(t, e, i, s) {
1439
+ Ri(t, e, i, s) {
1440
1440
  if (!t || !t.xs || t.noc === 0) return;
1441
1441
  const { xs: r, ys: n, endPts: o, flags: c } = t;
1442
1442
  if (!(r && n && o && c)) return;
@@ -1448,20 +1448,20 @@ class $t {
1448
1448
  if (f >= l) {
1449
1449
  const g = e + r[l] * s, v = i - n[l] * s;
1450
1450
  this.wi.moveTo(g, v);
1451
- let m = l + 1;
1452
- for (; m <= f; )
1453
- if (1 & c[m]) {
1454
- const d = e + r[m] * s, x = i - n[m] * s;
1455
- this.wi.lineTo(d, x), m++;
1451
+ let p = l + 1;
1452
+ for (; p <= f; )
1453
+ if (1 & c[p]) {
1454
+ const d = e + r[p] * s, y = i - n[p] * s;
1455
+ this.wi.lineTo(d, y), p++;
1456
1456
  } else {
1457
- const d = e + r[m] * s, x = i - n[m] * s;
1458
- let p = m + 1 > f ? l : m + 1;
1459
- if (1 & c[p]) {
1460
- const E = e + r[p] * s, y = i - n[p] * s;
1461
- this.wi.quadraticCurveTo(d, x, E, y), m = p + 1;
1457
+ const d = e + r[p] * s, y = i - n[p] * s;
1458
+ let m = p + 1 > f ? l : p + 1;
1459
+ if (1 & c[m]) {
1460
+ const w = e + r[m] * s, x = i - n[m] * s;
1461
+ this.wi.quadraticCurveTo(d, y, w, x), p = m + 1;
1462
1462
  } else {
1463
- const E = (d + (e + r[p] * s)) / 2, y = (x + (i - n[p] * s)) / 2;
1464
- this.wi.quadraticCurveTo(d, x, E, y), m = p;
1463
+ const w = (d + (e + r[m] * s)) / 2, x = (y + (i - n[m] * s)) / 2;
1464
+ this.wi.quadraticCurveTo(d, y, w, x), p = m;
1465
1465
  }
1466
1466
  }
1467
1467
  this.wi.closePath();
@@ -1472,34 +1472,34 @@ class $t {
1472
1472
  this.wi.fill();
1473
1473
  }
1474
1474
  }
1475
- class kt {
1475
+ class Yt {
1476
1476
  constructor() {
1477
- a(this, "Si");
1478
- this.Si = new q();
1477
+ h(this, "Fi");
1478
+ this.Fi = new q();
1479
1479
  }
1480
- Ai(t, e, i) {
1480
+ Ti(t, e, i) {
1481
1481
  let s = 0;
1482
- const r = this.Si.gi(i, e), n = r.lineHeight;
1482
+ const r = this.Fi.gi(i, e), n = r.lineHeight;
1483
1483
  for (const o of t) {
1484
- const c = this.Si.pi(i, o);
1484
+ const c = this.Fi.pi(i, o);
1485
1485
  if (c === 0) continue;
1486
- const l = this.Si.mi(i, c) * r.scale;
1486
+ const l = this.Fi.mi(i, c) * r.scale;
1487
1487
  s = Math.max(s, l);
1488
1488
  }
1489
1489
  return { width: Math.ceil(s), height: Math.ceil(n) };
1490
1490
  }
1491
1491
  yi() {
1492
- this.Si.yi();
1492
+ this.Fi.yi();
1493
1493
  }
1494
1494
  }
1495
- class Nt {
1495
+ class Xt {
1496
1496
  constructor() {
1497
- a(this, "$i");
1497
+ h(this, "$i");
1498
1498
  this.$i = new q();
1499
1499
  }
1500
1500
  createCharacterObjects(t, e) {
1501
1501
  return t.map((i, s) => {
1502
- const r = i.codePointAt(0) || 0, n = this.zi(s);
1502
+ const r = i.codePointAt(0) || 0, n = this.Ai(s);
1503
1503
  let o = 0;
1504
1504
  if (e.hmtx && e.hmtx.aWidth) {
1505
1505
  const c = this.$i.ui(e, r);
@@ -1508,35 +1508,35 @@ class Nt {
1508
1508
  return { character: i, unicode: r, color: n, advanceWidth: o };
1509
1509
  });
1510
1510
  }
1511
- zi(t) {
1511
+ Ai(t) {
1512
1512
  return [t % 256 / 255, Math.floor(t / 256) % 256 / 255, Math.floor(t / 65536) % 256 / 255];
1513
1513
  }
1514
- Ti(t, e) {
1515
- if (!$.v(typeof t == "string", "Character must be a string.", { method: "getCharacterColor", providedValue: t })) return [0, 0, 0];
1514
+ Ei(t, e) {
1515
+ if (!O.v(typeof t == "string", "Character must be a string.", { method: "getCharacterColor", providedValue: t })) return [0, 0, 0];
1516
1516
  const i = e.find((s) => s.character === t);
1517
1517
  return i ? i.color : [0, 0, 0];
1518
1518
  }
1519
- Ei(t, e) {
1520
- return $.v(typeof t == "string" && t.length > 0, "Characters must be a string with at least one character.", { method: "getCharacterColors", providedValue: t }) ? Array.from(t).map((i) => this.Ti(i, e) || [0, 0, 0]) : [[0, 0, 0]];
1519
+ ki(t, e) {
1520
+ return O.v(typeof t == "string" && t.length > 0, "Characters must be a string with at least one character.", { method: "getCharacterColors", providedValue: t }) ? Array.from(t).map((i) => this.Ei(i, e) || [0, 0, 0]) : [[0, 0, 0]];
1521
1521
  }
1522
1522
  }
1523
- class zt {
1523
+ class kt {
1524
1524
  constructor(t, e = 16) {
1525
- a(this, "Li");
1526
- a(this, "Pi", []);
1527
- a(this, "ki");
1528
- a(this, "Gi", 16);
1529
- a(this, "Bi", 0);
1530
- a(this, "Di", 0);
1531
- a(this, "Ii", { width: 0, height: 0 });
1532
- a(this, "Wi");
1533
- a(this, "Oi");
1534
- a(this, "Hi");
1535
- a(this, "Vi");
1536
- a(this, "Ki");
1537
- this.Gi = e, this.Oi = new Ot(), this.Hi = new $t(t), this.Vi = new kt(), this.Ki = new Nt();
1538
- }
1539
- async Ni(t) {
1525
+ h(this, "zi");
1526
+ h(this, "Pi", []);
1527
+ h(this, "Li");
1528
+ h(this, "Di", 16);
1529
+ h(this, "Gi", 0);
1530
+ h(this, "Bi", 0);
1531
+ h(this, "Ii", { width: 0, height: 0 });
1532
+ h(this, "Oi");
1533
+ h(this, "Wi");
1534
+ h(this, "Hi");
1535
+ h(this, "Xi");
1536
+ h(this, "Vi");
1537
+ this.Di = e, this.Wi = new Nt(), this.Hi = new Wt(t), this.Xi = new Yt(), this.Vi = new Xt();
1538
+ }
1539
+ async Ki(t) {
1540
1540
  let e;
1541
1541
  if (!t) throw new _("Embedded font not available. This appears to be a minified build - please provide `fontSource`.");
1542
1542
  {
@@ -1544,79 +1544,79 @@ class zt {
1544
1544
  if (!i.ok) throw new _(`Failed to load font file: ${i.status} ${i.statusText}`);
1545
1545
  e = await i.arrayBuffer();
1546
1546
  }
1547
- await this.Xi(e), this.Li = F.parse(e)[0], await this.ji();
1547
+ await this.ji(e), this.zi = L.parse(e)[0], await this.Ni();
1548
1548
  }
1549
1549
  Yi(t) {
1550
- if (t === void 0) return this.Gi;
1551
- this.Gi = t, this.Ii = this.Vi.Ai(this.Pi.map((i) => i.character), this.Gi, this.Li);
1552
- const e = this.Hi.createTextureAtlas(this.Pi, this.Ii, this.Gi, this.Li);
1553
- this.ki = e.framebuffer, this.Bi = e.columns, this.Di = e.rows;
1550
+ if (t === void 0) return this.Di;
1551
+ this.Di = t, this.Ii = this.Xi.Ti(this.Pi.map((i) => i.character), this.Di, this.zi);
1552
+ const e = this.Hi.createTextureAtlas(this.Pi, this.Ii, this.Di, this.zi);
1553
+ this.Li = e.framebuffer, this.Gi = e.columns, this.Bi = e.rows;
1554
1554
  }
1555
1555
  async qi(t) {
1556
1556
  try {
1557
1557
  const e = await fetch(t);
1558
1558
  if (!e.ok) throw new _(`Failed to load font file: ${e.status} ${e.statusText}`);
1559
1559
  const i = await e.arrayBuffer();
1560
- await this.Xi(i);
1561
- const s = F.parse(i);
1560
+ await this.ji(i);
1561
+ const s = L.parse(i);
1562
1562
  if (!s || s.length === 0) throw Error("Failed to parse font file");
1563
- this.Li = s[0], await this.ji();
1563
+ this.zi = s[0], await this.Ni();
1564
1564
  } catch (e) {
1565
1565
  throw new _("Failed to load font: " + (e instanceof Error ? e.message : "Unknown error"), e);
1566
1566
  }
1567
1567
  }
1568
- async Xi(t) {
1568
+ async ji(t) {
1569
1569
  const e = Date.now();
1570
- this.Wi = new FontFace("CustomFont_" + e, t), await this.Wi.load(), document.fonts.add(this.Wi);
1570
+ this.Oi = new FontFace("CustomFont_" + e, t), await this.Oi.load(), document.fonts.add(this.Oi);
1571
1571
  }
1572
- async ji() {
1573
- const t = this.Oi.ii(this.Li), e = this.Oi.oi(t);
1574
- this.Pi = this.Ki.createCharacterObjects(e, this.Li), this.Ii = this.Vi.Ai(e, this.Gi, this.Li);
1575
- const i = this.Hi.createTextureAtlas(this.Pi, this.Ii, this.Gi, this.Li);
1576
- this.ki = i.framebuffer, this.Bi = i.columns, this.Di = i.rows;
1577
- }
1578
- Ti(t) {
1579
- return this.Ki.Ti(t, this.Pi);
1572
+ async Ni() {
1573
+ const t = this.Wi.ii(this.zi), e = this.Wi.oi(t);
1574
+ this.Pi = this.Vi.createCharacterObjects(e, this.zi), this.Ii = this.Xi.Ti(e, this.Di, this.zi);
1575
+ const i = this.Hi.createTextureAtlas(this.Pi, this.Ii, this.Di, this.zi);
1576
+ this.Li = i.framebuffer, this.Gi = i.columns, this.Bi = i.rows;
1580
1577
  }
1581
1578
  Ei(t) {
1582
- return this.Ki.Ei(t, this.Pi);
1579
+ return this.Vi.Ei(t, this.Pi);
1580
+ }
1581
+ ki(t) {
1582
+ return this.Vi.ki(t, this.Pi);
1583
1583
  }
1584
- kt() {
1585
- this.ki.kt(), document.fonts.delete(this.Wi);
1584
+ Lt() {
1585
+ this.Li.Lt(), document.fonts.delete(this.Oi);
1586
1586
  }
1587
1587
  get fontFramebuffer() {
1588
- return this.ki;
1588
+ return this.Li;
1589
1589
  }
1590
1590
  get characters() {
1591
1591
  return this.Pi;
1592
1592
  }
1593
1593
  get textureColumns() {
1594
- return this.Bi;
1594
+ return this.Gi;
1595
1595
  }
1596
1596
  get textureRows() {
1597
- return this.Di;
1597
+ return this.Bi;
1598
1598
  }
1599
1599
  get maxGlyphDimensions() {
1600
1600
  return this.Ii;
1601
1601
  }
1602
1602
  get fontSize() {
1603
- return this.Gi;
1603
+ return this.Di;
1604
1604
  }
1605
1605
  get font() {
1606
- return this.Li;
1606
+ return this.zi;
1607
1607
  }
1608
1608
  }
1609
- class Wt {
1609
+ class Ht {
1610
1610
  constructor(t, e, i) {
1611
- a(this, "Zi");
1612
- a(this, "Ji");
1613
- a(this, "dt");
1614
- a(this, "_t");
1615
- a(this, "Qi");
1616
- a(this, "tr");
1617
- a(this, "er");
1618
- a(this, "sr");
1619
- a(this, "ir");
1611
+ h(this, "Zi");
1612
+ h(this, "Ji");
1613
+ h(this, "dt");
1614
+ h(this, "_t");
1615
+ h(this, "Qi");
1616
+ h(this, "tr");
1617
+ h(this, "er");
1618
+ h(this, "sr");
1619
+ h(this, "ir");
1620
1620
  this.er = t, this.sr = e, this.ir = i, this.rr();
1621
1621
  }
1622
1622
  rr() {
@@ -1650,14 +1650,14 @@ class Wt {
1650
1650
  return this.tr;
1651
1651
  }
1652
1652
  }
1653
- class Ht {
1653
+ class jt {
1654
1654
  constructor(t = {}) {
1655
- a(this, "er");
1656
- a(this, "ar", null);
1657
- a(this, "hr", !1);
1658
- a(this, "cr");
1659
- a(this, "lr");
1660
- this.hr = t.overlay ?? !1, this.hr && t.canvas ? (this.ar = t.canvas, this.er = this.ur(), this.lr = !0, this.dr()) : t.canvas ? (this.er = t.canvas, this.lr = !1) : (this.er = this._r(t.width, t.height), this.lr = !0), this.er.style.imageRendering = "pixelated";
1655
+ h(this, "er");
1656
+ h(this, "hr", null);
1657
+ h(this, "ar", !1);
1658
+ h(this, "cr");
1659
+ h(this, "lr");
1660
+ this.ar = t.overlay ?? !1, this.ar && t.canvas ? (this.hr = t.canvas, this.er = this.ur(), this.lr = !0, this.dr()) : t.canvas ? (this.er = t.canvas, this.lr = !1) : (this.er = this._r(t.width, t.height), this.lr = !0), this.er.style.imageRendering = "pixelated";
1661
1661
  }
1662
1662
  _r(t, e) {
1663
1663
  const i = document.createElement("canvas");
@@ -1666,40 +1666,40 @@ class Ht {
1666
1666
  ur() {
1667
1667
  const t = document.createElement("canvas");
1668
1668
  t.className = "textmodeCanvas", t.style.imageRendering = "pixelated";
1669
- const e = this.ar.getBoundingClientRect();
1669
+ const e = this.hr.getBoundingClientRect();
1670
1670
  let i = Math.round(e.width), s = Math.round(e.height);
1671
- if (this.ar instanceof HTMLVideoElement) {
1672
- const o = this.ar;
1671
+ if (this.hr instanceof HTMLVideoElement) {
1672
+ const o = this.hr;
1673
1673
  (i === 0 || s === 0) && o.videoWidth > 0 && o.videoHeight > 0 && (i = o.videoWidth, s = o.videoHeight);
1674
1674
  }
1675
1675
  t.width = i, t.height = s, t.style.position = "absolute", t.style.pointerEvents = "none";
1676
- const r = window.getComputedStyle(this.ar);
1676
+ const r = window.getComputedStyle(this.hr);
1677
1677
  let n = parseInt(r.zIndex || "0", 10);
1678
1678
  return isNaN(n) && (n = 0), t.style.zIndex = "" + (n + 1), t;
1679
1679
  }
1680
1680
  dr() {
1681
1681
  var t;
1682
- this.pr(), (t = this.ar.parentNode) == null || t.insertBefore(this.er, this.ar.nextSibling), window.ResizeObserver && (this.cr = new ResizeObserver(() => {
1682
+ this.pr(), (t = this.hr.parentNode) == null || t.insertBefore(this.er, this.hr.nextSibling), window.ResizeObserver && (this.cr = new ResizeObserver(() => {
1683
1683
  this.mr();
1684
- }), this.cr.observe(this.ar)), window.addEventListener("resize", () => {
1684
+ }), this.cr.observe(this.hr)), window.addEventListener("resize", () => {
1685
1685
  this.mr();
1686
1686
  });
1687
1687
  }
1688
1688
  pr() {
1689
- if (!this.ar) return;
1690
- const t = this.ar.getBoundingClientRect();
1691
- let e = this.ar.offsetParent;
1689
+ if (!this.hr) return;
1690
+ const t = this.hr.getBoundingClientRect();
1691
+ let e = this.hr.offsetParent;
1692
1692
  if (e && e !== document.body) {
1693
1693
  const i = e.getBoundingClientRect();
1694
1694
  this.er.style.top = t.top - i.top + "px", this.er.style.left = t.left - i.left + "px";
1695
1695
  } else this.er.style.top = t.top + window.scrollY + "px", this.er.style.left = t.left + window.scrollX + "px";
1696
1696
  }
1697
1697
  mr(t, e) {
1698
- if (this.hr) {
1699
- const i = this.ar.getBoundingClientRect();
1698
+ if (this.ar) {
1699
+ const i = this.hr.getBoundingClientRect();
1700
1700
  let s = Math.round(i.width), r = Math.round(i.height);
1701
- if (this.ar instanceof HTMLVideoElement) {
1702
- const n = this.ar;
1701
+ if (this.hr instanceof HTMLVideoElement) {
1702
+ const n = this.hr;
1703
1703
  (s === 0 || r === 0) && n.videoWidth > 0 && n.videoHeight > 0 && (s = n.videoWidth, r = n.videoHeight);
1704
1704
  }
1705
1705
  this.er.width = s, this.er.height = r, this.pr();
@@ -1710,7 +1710,7 @@ class Ht {
1710
1710
  if (!t) throw new _("`textmode.js` requires WebGL2 support.");
1711
1711
  return t;
1712
1712
  }
1713
- kt() {
1713
+ Lt() {
1714
1714
  this.cr && this.cr.disconnect();
1715
1715
  const t = this.er.getContext("webgl") || this.er.getContext("webgl2");
1716
1716
  if (t) {
@@ -1723,7 +1723,7 @@ class Ht {
1723
1723
  return this.er;
1724
1724
  }
1725
1725
  get targetCanvas() {
1726
- return this.ar;
1726
+ return this.hr;
1727
1727
  }
1728
1728
  get width() {
1729
1729
  return this.er.width;
@@ -1732,46 +1732,46 @@ class Ht {
1732
1732
  return this.er.height;
1733
1733
  }
1734
1734
  }
1735
- class k {
1735
+ class $ {
1736
1736
  constructor(t, e, i, s) {
1737
- a(this, "vr");
1738
- a(this, "dt");
1739
- a(this, "_t");
1740
- a(this, "vt");
1741
- a(this, "k", 0);
1742
- a(this, "N", 0);
1743
- a(this, "X", 0);
1744
- a(this, "G", [0, 0]);
1745
- a(this, "yr", "sampled");
1746
- a(this, "Cr", "fixed");
1747
- a(this, "Y", [1, 1, 1]);
1748
- a(this, "q", [0, 0, 0]);
1749
- a(this, "wr", [0, 0, 0, 1]);
1750
- a(this, "$r", [[0.1, 0, 0]]);
1751
- a(this, "br");
1737
+ h(this, "vr");
1738
+ h(this, "dt");
1739
+ h(this, "_t");
1740
+ h(this, "vt");
1741
+ h(this, "L", 0);
1742
+ h(this, "K", 0);
1743
+ h(this, "j", 0);
1744
+ h(this, "D", [0, 0]);
1745
+ h(this, "yr", "sampled");
1746
+ h(this, "Cr", "fixed");
1747
+ h(this, "Y", [1, 1, 1, 1]);
1748
+ h(this, "q", [0, 0, 0, 1]);
1749
+ h(this, "wr", [0, 0, 0, 1]);
1750
+ h(this, "$r", [[0.1, 0, 0]]);
1751
+ h(this, "br");
1752
1752
  this.vt = t, this.vr = e, this.dt = i, this._t = s;
1753
1753
  }
1754
- kt() {
1754
+ Lt() {
1755
1755
  this.vt.deleteTexture(this.vr);
1756
1756
  }
1757
1757
  Mr(t) {
1758
1758
  return typeof t == "boolean" ? t ? 1 : 0 : (t == null ? 0 : Number(t)) > 0 ? 1 : 0;
1759
1759
  }
1760
1760
  invert(t = !0) {
1761
- return this.k = this.Mr(t), this;
1761
+ return this.L = this.Mr(t), this;
1762
1762
  }
1763
1763
  flipX(t = !0) {
1764
- return this.N = this.Mr(t), this;
1764
+ return this.K = this.Mr(t), this;
1765
1765
  }
1766
1766
  flipY(t = !0) {
1767
- return this.X = this.Mr(t), this;
1767
+ return this.j = this.Mr(t), this;
1768
1768
  }
1769
1769
  charRotation(t) {
1770
1770
  const e = 255 * t / 360, i = Math.floor(e) / 255, s = Math.round(e - Math.floor(e));
1771
- return this.G = [i, s], this;
1771
+ return this.D = [i, s], this;
1772
1772
  }
1773
- Os() {
1774
- return { texture: this.vr, invert: this.k, flipX: this.N, flipY: this.X, charRotation: this.G, charColorFixed: this.yr === "fixed", charColor: this.Y, cellColorFixed: this.Cr === "fixed", cellColor: this.q, backgroundColor: this.wr, charCount: this.$r.length, charList: this.$r };
1773
+ Ws() {
1774
+ return { texture: this.vr, invert: this.L, flipX: this.K, flipY: this.j, charRotation: this.D, charColorFixed: this.yr === "fixed", charColor: this.Y, cellColorFixed: this.Cr === "fixed", cellColor: this.q, backgroundColor: this.wr, charCount: this.$r.length, charList: this.$r };
1775
1775
  }
1776
1776
  charColorMode(t) {
1777
1777
  return this.yr = t, this;
@@ -1779,11 +1779,11 @@ class k {
1779
1779
  cellColorMode(t) {
1780
1780
  return this.Cr = t, this;
1781
1781
  }
1782
- charColor(t, e, i) {
1783
- return this.Y = [(t ?? 0) / 255, (e ?? t ?? 0) / 255, (i ?? t ?? 0) / 255], this;
1782
+ charColor(t, e, i, s) {
1783
+ return this.Y = [(t ?? 0) / 255, (e ?? t ?? 0) / 255, (i ?? t ?? 0) / 255, (s ?? 255) / 255], this;
1784
1784
  }
1785
- cellColor(t, e, i) {
1786
- return this.q = [(t ?? 0) / 255, (e ?? t ?? 0) / 255, (i ?? t ?? 0) / 255], this;
1785
+ cellColor(t, e, i, s) {
1786
+ return this.q = [(t ?? 0) / 255, (e ?? t ?? 0) / 255, (i ?? t ?? 0) / 255, (s ?? 255) / 255], this;
1787
1787
  }
1788
1788
  background(t, e, i, s) {
1789
1789
  return this.wr = [(t ?? 0) / 255, (e ?? t ?? 0) / 255, (i ?? t ?? 0) / 255, (s ?? 255) / 255], this;
@@ -1792,10 +1792,10 @@ class k {
1792
1792
  const e = this.br(t).filter((i) => Array.isArray(i)).slice(0, 64);
1793
1793
  return this.$r = e, this;
1794
1794
  }
1795
- static Rr(t, e, i) {
1795
+ static Sr(t, e, i) {
1796
1796
  const s = t.context, r = s.createTexture();
1797
1797
  s.bindTexture(s.TEXTURE_2D, r), s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL, 1), s.texParameteri(s.TEXTURE_2D, s.TEXTURE_MIN_FILTER, s.NEAREST), s.texParameteri(s.TEXTURE_2D, s.TEXTURE_MAG_FILTER, s.NEAREST), s.texParameteri(s.TEXTURE_2D, s.TEXTURE_WRAP_S, s.CLAMP_TO_EDGE), s.texParameteri(s.TEXTURE_2D, s.TEXTURE_WRAP_T, s.CLAMP_TO_EDGE), s.texImage2D(s.TEXTURE_2D, 0, s.RGBA, s.RGBA, s.UNSIGNED_BYTE, e), s.bindTexture(s.TEXTURE_2D, null);
1798
- const n = e.naturalWidth ?? e.width ?? e.videoWidth ?? 0, o = e.naturalHeight ?? e.height ?? e.videoHeight ?? 0, c = new k(s, r, n, o);
1798
+ const n = e.naturalWidth ?? e.width ?? e.videoWidth ?? 0, o = e.naturalHeight ?? e.height ?? e.videoHeight ?? 0, c = new $(s, r, n, o);
1799
1799
  return c.br = i, c;
1800
1800
  }
1801
1801
  get texture() {
@@ -1808,258 +1808,490 @@ class k {
1808
1808
  return this._t;
1809
1809
  }
1810
1810
  }
1811
- class Xt {
1811
+ class Vt {
1812
1812
  constructor(t = 60) {
1813
- a(this, "Fr");
1814
- a(this, "Sr");
1815
- a(this, "Ar", null);
1816
- a(this, "zr", 0);
1817
- a(this, "Tr", !0);
1818
- a(this, "Er", 0);
1819
- a(this, "Lr", 0);
1820
- a(this, "Pr", []);
1821
- a(this, "kr", 10);
1822
- a(this, "Gr", 0);
1823
- this.Fr = t, this.Sr = 1e3 / t;
1813
+ h(this, "Rr");
1814
+ h(this, "Fr");
1815
+ h(this, "Tr", null);
1816
+ h(this, "Ar", 0);
1817
+ h(this, "Er", !0);
1818
+ h(this, "kr", 0);
1819
+ h(this, "zr", 0);
1820
+ h(this, "Pr", []);
1821
+ h(this, "Lr", 10);
1822
+ h(this, "Dr", 0);
1823
+ this.Rr = t, this.Fr = 1e3 / t;
1824
1824
  }
1825
1825
  start(t) {
1826
- if (!this.Tr) return;
1827
- this.zr = performance.now();
1826
+ if (!this.Er) return;
1827
+ this.Ar = performance.now();
1828
1828
  const e = (i) => {
1829
- if (!this.Tr) return void (this.Ar = null);
1830
- const s = i - this.zr;
1831
- s >= this.Sr && (t(), this.zr = i - s % this.Sr), this.Tr && (this.Ar = requestAnimationFrame(e));
1829
+ if (!this.Er) return void (this.Tr = null);
1830
+ const s = i - this.Ar;
1831
+ s >= this.Fr && (t(), this.Ar = i - s % this.Fr), this.Er && (this.Tr = requestAnimationFrame(e));
1832
1832
  };
1833
- this.Ar = requestAnimationFrame(e);
1833
+ this.Tr = requestAnimationFrame(e);
1834
1834
  }
1835
1835
  stop() {
1836
- this.Ar && (cancelAnimationFrame(this.Ar), this.Ar = null);
1836
+ this.Tr && (cancelAnimationFrame(this.Tr), this.Tr = null);
1837
1837
  }
1838
1838
  pause() {
1839
- this.Tr && (this.Tr = !1, this.stop());
1839
+ this.Er && (this.Er = !1, this.stop());
1840
1840
  }
1841
1841
  resume(t) {
1842
- this.Tr || (this.Tr = !0, this.start(t));
1842
+ this.Er || (this.Er = !0, this.start(t));
1843
1843
  }
1844
1844
  frameRate(t, e) {
1845
- if (t === void 0) return this.Er;
1846
- this.Fr = t, this.Sr = 1e3 / t, this.Tr && e && (this.stop(), this.start(e));
1845
+ if (t === void 0) return this.kr;
1846
+ this.Rr = t, this.Fr = 1e3 / t, this.Er && e && (this.stop(), this.start(e));
1847
1847
  }
1848
1848
  measureFrameRate() {
1849
1849
  const t = performance.now();
1850
- if (this.Lr > 0) {
1851
- const e = t - this.Lr;
1852
- this.Pr.push(e), this.Pr.length > this.kr && this.Pr.shift();
1850
+ if (this.zr > 0) {
1851
+ const e = t - this.zr;
1852
+ this.Pr.push(e), this.Pr.length > this.Lr && this.Pr.shift();
1853
1853
  const i = this.Pr.reduce((s, r) => s + r, 0) / this.Pr.length;
1854
- this.Er = 1e3 / i;
1854
+ this.kr = 1e3 / i;
1855
1855
  }
1856
- this.Lr = t;
1856
+ this.zr = t;
1857
1857
  }
1858
1858
  get isLooping() {
1859
- return this.Tr;
1859
+ return this.Er;
1860
1860
  }
1861
1861
  get frameRateLimit() {
1862
- return this.Fr;
1862
+ return this.Rr;
1863
1863
  }
1864
1864
  get currentFrameRate() {
1865
- return this.Er;
1865
+ return this.kr;
1866
1866
  }
1867
1867
  get frameCount() {
1868
- return this.Gr;
1868
+ return this.Dr;
1869
1869
  }
1870
1870
  set frameCount(t) {
1871
- this.Gr = t;
1871
+ this.Dr = t;
1872
1872
  }
1873
1873
  incrementFrame() {
1874
- this.Gr++;
1874
+ this.Dr++;
1875
1875
  }
1876
1876
  resetFrameCount() {
1877
- this.Gr = 0;
1877
+ this.Dr = 0;
1878
1878
  }
1879
1879
  }
1880
- class Yt {
1880
+ class ct {
1881
+ constructor(t) {
1882
+ h(this, "er");
1883
+ h(this, "Gr");
1884
+ h(this, "Br", { x: -1, y: -1 });
1885
+ h(this, "Ir", { x: -1, y: -1 });
1886
+ h(this, "Or", null);
1887
+ h(this, "Wr", 0);
1888
+ h(this, "Hr");
1889
+ h(this, "Xr");
1890
+ h(this, "Vr");
1891
+ h(this, "Kr");
1892
+ h(this, "jr");
1893
+ h(this, "Nr");
1894
+ h(this, "Yr", !1);
1895
+ h(this, "qr");
1896
+ h(this, "Zr");
1897
+ h(this, "Jr");
1898
+ h(this, "Qr");
1899
+ h(this, "tn");
1900
+ this.er = t;
1901
+ }
1902
+ en(t) {
1903
+ const e = performance.now() + Math.max(0, t);
1904
+ e > this.Wr && (this.Wr = e);
1905
+ }
1906
+ sn() {
1907
+ return performance.now() < this.Wr;
1908
+ }
1909
+ rn(t) {
1910
+ const e = this.er.canvas;
1911
+ e.style.cursor = t == null || t === "" ? "" : t;
1912
+ }
1913
+ Ki(t) {
1914
+ this.Gr = t, this.nn();
1915
+ }
1916
+ hn() {
1917
+ if (this.Yr) return;
1918
+ const t = this.er.canvas;
1919
+ this.Hr = (e) => {
1920
+ this.an(e), this.cn(e);
1921
+ }, this.Xr = () => {
1922
+ this.Ir = { ...this.Br }, this.Br.x = -1, this.Br.y = -1, this.Or = null;
1923
+ }, this.Vr = (e) => {
1924
+ this.an(e), this.ln(e);
1925
+ }, this.Kr = (e) => {
1926
+ this.an(e), this.un(e);
1927
+ }, this.jr = (e) => {
1928
+ this.an(e), this.fn(e);
1929
+ }, this.Nr = (e) => {
1930
+ this.an(e), this.dn(e);
1931
+ }, t.addEventListener("mousemove", this.Hr, { passive: !0 }), t.addEventListener("mouseleave", this.Xr, { passive: !0 }), t.addEventListener("mousedown", this.Vr, { passive: !0 }), t.addEventListener("mouseup", this.Kr, { passive: !0 }), t.addEventListener("click", this.jr, { passive: !0 }), t.addEventListener("wheel", this.Nr, { passive: !1 }), this.Yr = !0;
1932
+ }
1933
+ _n() {
1934
+ if (!this.Yr) return;
1935
+ const t = this.er.canvas;
1936
+ t.removeEventListener("mousemove", this.Hr), t.removeEventListener("mouseleave", this.Xr), t.removeEventListener("mousedown", this.Vr), t.removeEventListener("mouseup", this.Kr), t.removeEventListener("click", this.jr), t.removeEventListener("wheel", this.Nr), this.Yr = !1;
1937
+ }
1938
+ nn() {
1939
+ if (this.Yr) try {
1940
+ if (this.Or) {
1941
+ const t = new MouseEvent("mousemove", { clientX: this.Or.x, clientY: this.Or.y, bubbles: !1, cancelable: !1 });
1942
+ this.an(t);
1943
+ } else this.Br.x !== -1 && this.Br.y !== -1 && (this.Br.x >= this.Gr.cols || this.Br.y >= this.Gr.rows) && (this.Br.x = -1, this.Br.y = -1);
1944
+ } catch {
1945
+ this.Br.x = -1, this.Br.y = -1;
1946
+ }
1947
+ }
1948
+ pn(t) {
1949
+ this.qr = t;
1950
+ }
1951
+ mn(t) {
1952
+ this.Zr = t;
1953
+ }
1954
+ gn(t) {
1955
+ this.Jr = t;
1956
+ }
1957
+ vn(t) {
1958
+ this.Qr = t;
1959
+ }
1960
+ yn(t) {
1961
+ this.tn = t;
1962
+ }
1963
+ Cn() {
1964
+ return { x: this.Br.x, y: this.Br.y };
1965
+ }
1966
+ cn(t) {
1967
+ if (this.Qr && !this.sn()) {
1968
+ const e = { position: { ...this.Br }, previousPosition: { ...this.Ir }, originalEvent: t };
1969
+ this.Qr(e);
1970
+ }
1971
+ }
1972
+ ln(t) {
1973
+ if (this.Zr && !this.sn()) {
1974
+ const e = { position: { ...this.Br }, previousPosition: { ...this.Ir }, button: t.button, originalEvent: t };
1975
+ this.Zr(e);
1976
+ }
1977
+ }
1978
+ un(t) {
1979
+ if (this.Jr && !this.sn()) {
1980
+ const e = { position: { ...this.Br }, previousPosition: { ...this.Ir }, button: t.button, originalEvent: t };
1981
+ this.Jr(e);
1982
+ }
1983
+ }
1984
+ fn(t) {
1985
+ if (this.qr && !this.sn()) {
1986
+ const e = { position: { ...this.Br }, previousPosition: { ...this.Ir }, button: t.button, originalEvent: t };
1987
+ this.qr(e);
1988
+ }
1989
+ }
1990
+ dn(t) {
1991
+ if (this.tn && !this.sn()) {
1992
+ const e = { position: { ...this.Br }, previousPosition: { ...this.Ir }, delta: { x: t.deltaX, y: t.deltaY }, originalEvent: t };
1993
+ this.tn(e);
1994
+ }
1995
+ }
1996
+ an(t) {
1997
+ const e = this.er.canvas;
1998
+ this.Ir = { ...this.Br }, this.Or = { x: t.clientX, y: t.clientY };
1999
+ 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.Gr.offsetX, l = o - this.Gr.offsetY, u = Math.floor(c / this.Gr.cellWidth), f = Math.floor(l / this.Gr.cellHeight);
2000
+ u >= 0 && u < this.Gr.cols && f >= 0 && f < this.Gr.rows ? (this.Br.x = u, this.Br.y = f) : (this.Br.x = -1, this.Br.y = -1);
2001
+ }
2002
+ }
2003
+ const Kt = Object.freeze(Object.defineProperty({ __proto__: null, MouseManager: ct }, Symbol.toStringTag, { value: "Module" }));
2004
+ class lt {
1881
2005
  constructor() {
1882
- a(this, "Br", /* @__PURE__ */ new Map());
1883
- a(this, "Dr", null);
1884
- a(this, "Ir", null);
1885
- a(this, "Wr");
1886
- a(this, "Or");
1887
- a(this, "Hr", !1);
1888
- a(this, "Vr");
1889
- a(this, "Kr");
1890
- a(this, "Nr", { 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" });
1891
- }
1892
- Xr() {
1893
- this.Hr || (this.Wr = (t) => {
1894
- this.jr(t);
1895
- }, this.Or = (t) => {
1896
- this.Yr(t);
1897
- }, window.addEventListener("keydown", this.Wr, { passive: !1 }), window.addEventListener("keyup", this.Or, { passive: !1 }), this.Hr = !0);
1898
- }
1899
- qr() {
1900
- this.Hr && (window.removeEventListener("keydown", this.Wr), window.removeEventListener("keyup", this.Or), this.Hr = !1, this.Br.clear(), this.Dr = null, this.Ir = null);
1901
- }
1902
- Zr(t) {
1903
- this.Vr = t;
1904
- }
1905
- Jr(t) {
1906
- this.Kr = t;
1907
- }
1908
- Qr(t) {
1909
- const e = this.tn(t), i = this.Br.get(t) || this.Br.get(e);
2006
+ h(this, "wn", /* @__PURE__ */ new Map());
2007
+ h(this, "$n", null);
2008
+ h(this, "bn", null);
2009
+ h(this, "xn");
2010
+ h(this, "Mn");
2011
+ h(this, "Yr", !1);
2012
+ h(this, "Sn");
2013
+ h(this, "Rn");
2014
+ h(this, "Fn", { 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" });
2015
+ }
2016
+ hn() {
2017
+ this.Yr || (this.xn = (t) => {
2018
+ this.Tn(t);
2019
+ }, this.Mn = (t) => {
2020
+ this.An(t);
2021
+ }, window.addEventListener("keydown", this.xn, { passive: !1 }), window.addEventListener("keyup", this.Mn, { passive: !1 }), this.Yr = !0);
2022
+ }
2023
+ _n() {
2024
+ this.Yr && (window.removeEventListener("keydown", this.xn), window.removeEventListener("keyup", this.Mn), this.Yr = !1, this.wn.clear(), this.$n = null, this.bn = null);
2025
+ }
2026
+ mn(t) {
2027
+ this.Sn = t;
2028
+ }
2029
+ gn(t) {
2030
+ this.Rn = t;
2031
+ }
2032
+ En(t) {
2033
+ const e = this.kn(t), i = this.wn.get(t) || this.wn.get(e);
1910
2034
  return (i == null ? void 0 : i.isPressed) || !1;
1911
2035
  }
1912
- en() {
1913
- return this.Dr;
2036
+ zn() {
2037
+ return this.$n;
1914
2038
  }
1915
- sn() {
1916
- return this.Ir;
2039
+ Pn() {
2040
+ return this.bn;
1917
2041
  }
1918
- rn() {
2042
+ Ln() {
1919
2043
  const t = [];
1920
- for (const [e, i] of this.Br) i.isPressed && t.push(e);
2044
+ for (const [e, i] of this.wn) i.isPressed && t.push(e);
1921
2045
  return t;
1922
2046
  }
1923
- nn() {
1924
- return { ctrl: this.Qr("Control"), shift: this.Qr("Shift"), alt: this.Qr("Alt"), meta: this.Qr("Meta") };
2047
+ Dn() {
2048
+ return { ctrl: this.En("Control"), shift: this.En("Shift"), alt: this.En("Alt"), meta: this.En("Meta") };
1925
2049
  }
1926
- an() {
1927
- this.Br.clear(), this.Dr = null, this.Ir = null;
2050
+ Gn() {
2051
+ this.wn.clear(), this.$n = null, this.bn = null;
1928
2052
  }
1929
- jr(t) {
2053
+ Tn(t) {
1930
2054
  const e = t.key, i = Date.now();
1931
- this.Br.has(e) || this.Br.set(e, { isPressed: !1, lastPressTime: 0, lastReleaseTime: 0 });
1932
- const s = this.Br.get(e);
1933
- if (!s.isPressed && (s.isPressed = !0, s.lastPressTime = i, this.Dr = e, this.Vr)) {
2055
+ this.wn.has(e) || this.wn.set(e, { isPressed: !1, lastPressTime: 0, lastReleaseTime: 0 });
2056
+ const s = this.wn.get(e);
2057
+ if (!s.isPressed && (s.isPressed = !0, s.lastPressTime = i, this.$n = e, this.Sn)) {
1934
2058
  const r = { key: e, keyCode: t.keyCode, ctrlKey: t.ctrlKey, shiftKey: t.shiftKey, altKey: t.altKey, metaKey: t.metaKey, isPressed: !0, originalEvent: t };
1935
- this.Vr(r);
2059
+ this.Sn(r);
1936
2060
  }
1937
2061
  }
1938
- Yr(t) {
2062
+ An(t) {
1939
2063
  const e = t.key, i = Date.now();
1940
- this.Br.has(e) || this.Br.set(e, { isPressed: !1, lastPressTime: 0, lastReleaseTime: 0 });
1941
- const s = this.Br.get(e);
1942
- if (s.isPressed = !1, s.lastReleaseTime = i, this.Ir = e, this.Kr) {
2064
+ this.wn.has(e) || this.wn.set(e, { isPressed: !1, lastPressTime: 0, lastReleaseTime: 0 });
2065
+ const s = this.wn.get(e);
2066
+ if (s.isPressed = !1, s.lastReleaseTime = i, this.bn = e, this.Rn) {
1943
2067
  const r = { key: e, keyCode: t.keyCode, ctrlKey: t.ctrlKey, shiftKey: t.shiftKey, altKey: t.altKey, metaKey: t.metaKey, isPressed: !1, originalEvent: t };
1944
- this.Kr(r);
2068
+ this.Rn(r);
1945
2069
  }
1946
2070
  }
1947
- tn(t) {
1948
- return this.Nr[t] || t.toLowerCase();
2071
+ kn(t) {
2072
+ return this.Fn[t] || t.toLowerCase();
1949
2073
  }
1950
2074
  }
1951
- class Vt {
1952
- constructor(t) {
1953
- a(this, "er");
1954
- a(this, "hn");
1955
- a(this, "cn", { x: -1, y: -1 });
1956
- a(this, "ln", { x: -1, y: -1 });
1957
- a(this, "un", null);
1958
- a(this, "fn");
1959
- a(this, "dn");
1960
- a(this, "_n");
1961
- a(this, "pn");
1962
- a(this, "mn");
1963
- a(this, "gn");
1964
- a(this, "Hr", !1);
1965
- a(this, "vn");
1966
- a(this, "yn");
1967
- a(this, "Cn");
1968
- a(this, "wn");
1969
- a(this, "$n");
1970
- this.er = t;
1971
- }
1972
- Ni(t) {
1973
- this.hn = t, this.bn();
1974
- }
1975
- Xr() {
1976
- if (this.Hr) return;
2075
+ const qt = Object.freeze(Object.defineProperty({ __proto__: null, KeyboardManager: lt }, Symbol.toStringTag, { value: "Module" }));
2076
+ class ut {
2077
+ constructor(t, e) {
2078
+ h(this, "er");
2079
+ h(this, "Bn");
2080
+ h(this, "Gr");
2081
+ h(this, "In", /* @__PURE__ */ new Map());
2082
+ h(this, "On", /* @__PURE__ */ new Map());
2083
+ h(this, "Wn", /* @__PURE__ */ new Map());
2084
+ h(this, "Hn", null);
2085
+ h(this, "Xn");
2086
+ h(this, "Vn");
2087
+ h(this, "Kn");
2088
+ h(this, "jn");
2089
+ h(this, "Nn");
2090
+ h(this, "Yn");
2091
+ h(this, "Yr", !1);
2092
+ h(this, "qn");
2093
+ h(this, "Zn");
2094
+ h(this, "Jn");
2095
+ h(this, "Qn");
2096
+ h(this, "eo");
2097
+ h(this, "so");
2098
+ h(this, "io");
2099
+ h(this, "ro");
2100
+ h(this, "no");
2101
+ h(this, "oo");
2102
+ h(this, "ho", 320);
2103
+ h(this, "ao", 350);
2104
+ h(this, "co", 10);
2105
+ h(this, "lo", 550);
2106
+ h(this, "uo", 14);
2107
+ h(this, "fo", 48);
2108
+ h(this, "do", 650);
2109
+ h(this, "_o", 0.02);
2110
+ h(this, "po", 2);
2111
+ h(this, "mo", 600);
2112
+ h(this, "vo", 0);
2113
+ h(this, "yo", null);
2114
+ this.er = t, this.Bn = e;
2115
+ const i = this.er.canvas;
2116
+ this.Xn = i.style.touchAction, this.Vn = i.style.userSelect, i.style.touchAction || (i.style.touchAction = "none"), i.style.userSelect || (i.style.userSelect = "none");
2117
+ }
2118
+ Ki(t) {
2119
+ this.Gr = t, this.Co();
2120
+ }
2121
+ hn() {
2122
+ if (this.Yr) return;
1977
2123
  const t = this.er.canvas;
1978
- this.fn = (e) => {
1979
- this.xn(e), this.Mn(e);
1980
- }, this.dn = () => {
1981
- this.ln = { ...this.cn }, this.cn.x = -1, this.cn.y = -1, this.un = null;
1982
- }, this._n = (e) => {
1983
- this.xn(e), this.Rn(e);
1984
- }, this.pn = (e) => {
1985
- this.xn(e), this.Fn(e);
1986
- }, this.mn = (e) => {
1987
- this.xn(e), this.Sn(e);
1988
- }, this.gn = (e) => {
1989
- this.xn(e), this.An(e);
1990
- }, t.addEventListener("mousemove", this.fn, { passive: !0 }), t.addEventListener("mouseleave", this.dn, { passive: !0 }), t.addEventListener("mousedown", this._n, { passive: !0 }), t.addEventListener("mouseup", this.pn, { passive: !0 }), t.addEventListener("click", this.mn, { passive: !0 }), t.addEventListener("wheel", this.gn, { passive: !1 }), this.Hr = !0;
1991
- }
1992
- qr() {
1993
- if (!this.Hr) return;
2124
+ this.Kn = (e) => {
2125
+ this.wo(e);
2126
+ }, this.jn = (e) => {
2127
+ this.$o(e);
2128
+ }, this.Nn = (e) => {
2129
+ this.bo(e);
2130
+ }, this.Yn = (e) => {
2131
+ this.xo(e);
2132
+ }, t.addEventListener("touchstart", this.Kn, { passive: !1 }), t.addEventListener("touchmove", this.jn, { passive: !1 }), t.addEventListener("touchend", this.Nn, { passive: !1 }), t.addEventListener("touchcancel", this.Yn, { passive: !1 }), this.Yr = !0;
2133
+ }
2134
+ _n() {
2135
+ if (!this.Yr) return;
1994
2136
  const t = this.er.canvas;
1995
- t.removeEventListener("mousemove", this.fn), t.removeEventListener("mouseleave", this.dn), t.removeEventListener("mousedown", this._n), t.removeEventListener("mouseup", this.pn), t.removeEventListener("click", this.mn), t.removeEventListener("wheel", this.gn), this.Hr = !1;
1996
- }
1997
- bn() {
1998
- if (this.Hr) try {
1999
- if (this.un) {
2000
- const t = new MouseEvent("mousemove", { clientX: this.un.x, clientY: this.un.y, bubbles: !1, cancelable: !1 });
2001
- this.xn(t);
2002
- } else this.cn.x !== -1 && this.cn.y !== -1 && (this.cn.x >= this.hn.cols || this.cn.y >= this.hn.rows) && (this.cn.x = -1, this.cn.y = -1);
2003
- } catch {
2004
- this.cn.x = -1, this.cn.y = -1;
2137
+ t.removeEventListener("touchstart", this.Kn), t.removeEventListener("touchmove", this.jn), t.removeEventListener("touchend", this.Nn), t.removeEventListener("touchcancel", this.Yn), this.Yr = !1, this.Hn = null, this.In.clear(), this.On.clear(), this.Wn.forEach((e) => {
2138
+ e.longPressTimer !== null && window.clearTimeout(e.longPressTimer);
2139
+ }), this.Wn.clear(), this.yo = null, this.vo = 0, t.style.touchAction = this.Xn, t.style.userSelect = this.Vn;
2140
+ }
2141
+ Co() {
2142
+ if (!this.Gr || this.In.size === 0) return;
2143
+ const t = /* @__PURE__ */ new Map();
2144
+ for (const e of this.In.values()) {
2145
+ const i = this.Mo(e.clientX, e.clientY, e.id, e);
2146
+ t.set(e.id, i);
2005
2147
  }
2148
+ this.In = t;
2006
2149
  }
2007
- zn(t) {
2008
- this.vn = t;
2009
- }
2010
- Zr(t) {
2011
- this.yn = t;
2150
+ So() {
2151
+ return Array.from(this.In.values()).map((t) => ({ ...t }));
2012
2152
  }
2013
- Jr(t) {
2014
- this.Cn = t;
2153
+ Ro(t) {
2154
+ this.qn = t;
2015
2155
  }
2016
- Tn(t) {
2017
- this.wn = t;
2156
+ vn(t) {
2157
+ this.Zn = t;
2018
2158
  }
2019
- En(t) {
2020
- this.$n = t;
2159
+ Fo(t) {
2160
+ this.Jn = t;
2021
2161
  }
2022
- Ln() {
2023
- return { x: this.cn.x, y: this.cn.y };
2162
+ To(t) {
2163
+ this.Qn = t;
2024
2164
  }
2025
- Mn(t) {
2026
- if (this.wn) {
2027
- const e = { position: { ...this.cn }, previousPosition: { ...this.ln }, originalEvent: t };
2028
- this.wn(e);
2165
+ Ao(t) {
2166
+ this.eo = t;
2167
+ }
2168
+ Eo(t) {
2169
+ this.so = t;
2170
+ }
2171
+ ko(t) {
2172
+ this.io = t;
2173
+ }
2174
+ zo(t) {
2175
+ this.ro = t;
2176
+ }
2177
+ Po(t) {
2178
+ this.no = t;
2179
+ }
2180
+ Lo(t) {
2181
+ this.oo = t;
2182
+ }
2183
+ wo(t) {
2184
+ var s;
2185
+ if (!this.Gr) return;
2186
+ t.preventDefault(), (s = this.Bn) == null || s.en(this.mo);
2187
+ const e = performance.now(), i = this.Do(t.changedTouches);
2188
+ for (const r of i) {
2189
+ const n = this.In.get(r.id);
2190
+ n && this.On.set(r.id, this.Go(n)), this.In.set(r.id, r);
2191
+ const o = { id: r.id, startPosition: r, lastPosition: r, startTime: e, lastTime: e, longPressTimer: null, longPressFired: !1 };
2192
+ this.io && (o.longPressTimer = window.setTimeout(() => {
2193
+ const c = this.In.get(r.id);
2194
+ c && (o.longPressFired = !0, this.io({ touch: this.Go(c), duration: performance.now() - o.startTime, originalEvent: t }));
2195
+ }, this.lo)), this.Wn.set(r.id, o), this.qn && this.qn(this.Bo(r, t, void 0, e));
2029
2196
  }
2030
- }
2031
- Rn(t) {
2032
- if (this.yn) {
2033
- const e = { position: { ...this.cn }, previousPosition: { ...this.ln }, button: t.button, originalEvent: t };
2034
- this.yn(e);
2197
+ this.In.size === 2 && this.Io();
2198
+ }
2199
+ $o(t) {
2200
+ var s;
2201
+ if (!this.Gr) return;
2202
+ t.preventDefault(), (s = this.Bn) == null || s.en(this.mo);
2203
+ const e = performance.now(), i = this.Do(t.changedTouches);
2204
+ for (const r of i) {
2205
+ const n = this.In.get(r.id), o = n ? this.Go(n) : void 0;
2206
+ o && this.On.set(r.id, o), this.In.set(r.id, r);
2207
+ const c = this.Wn.get(r.id);
2208
+ c && (c.lastPosition = r, c.lastTime = e, o) && this.Oo(o, r, !0) > this.uo && c.longPressTimer !== null && (window.clearTimeout(c.longPressTimer), c.longPressTimer = null), this.Zn && this.Zn(this.Bo(r, t, o, e));
2035
2209
  }
2210
+ this.In.size === 2 ? this.Wo(t) : this.Hn = null;
2211
+ }
2212
+ bo(t) {
2213
+ if (!this.Gr) return;
2214
+ t.preventDefault();
2215
+ const e = performance.now(), i = this.Do(t.changedTouches);
2216
+ for (const s of i) {
2217
+ const r = this.In.get(s.id), n = r ? this.Go(r) : void 0, o = this.Wn.get(s.id);
2218
+ o && o.longPressTimer !== null && (window.clearTimeout(o.longPressTimer), o.longPressTimer = null), this.Jn && this.Jn(this.Bo(s, t, n, e)), o && this.Ho(o, t), this.Wn.delete(s.id), this.On.delete(s.id), this.In.delete(s.id);
2219
+ }
2220
+ this.In.size < 2 && (this.Hn = null);
2036
2221
  }
2037
- Fn(t) {
2038
- if (this.Cn) {
2039
- const e = { position: { ...this.cn }, previousPosition: { ...this.ln }, button: t.button, originalEvent: t };
2040
- this.Cn(e);
2222
+ xo(t) {
2223
+ if (!this.Gr) return;
2224
+ t.preventDefault();
2225
+ const e = performance.now(), i = this.Do(t.changedTouches);
2226
+ for (const s of i) {
2227
+ const r = this.In.get(s.id), n = r ? this.Go(r) : void 0, o = this.Wn.get(s.id);
2228
+ o && o.longPressTimer !== null && (window.clearTimeout(o.longPressTimer), o.longPressTimer = null), this.Qn && this.Qn(this.Bo(s, t, n, e)), this.Wn.delete(s.id), this.On.delete(s.id), this.In.delete(s.id);
2041
2229
  }
2230
+ this.In.size < 2 && (this.Hn = null);
2042
2231
  }
2043
- Sn(t) {
2044
- if (this.vn) {
2045
- const e = { position: { ...this.cn }, previousPosition: { ...this.ln }, button: t.button, originalEvent: t };
2046
- this.vn(e);
2232
+ Do(t) {
2233
+ const e = [];
2234
+ for (let i = 0; i < t.length; i += 1) {
2235
+ const s = t.item(i);
2236
+ s && e.push(this.Xo(s));
2047
2237
  }
2238
+ return e;
2048
2239
  }
2049
- An(t) {
2050
- if (this.$n) {
2051
- const e = { position: { ...this.cn }, previousPosition: { ...this.ln }, delta: { x: t.deltaX, y: t.deltaY }, originalEvent: t };
2052
- this.$n(e);
2240
+ Xo(t) {
2241
+ return this.Mo(t.clientX, t.clientY, t.identifier, { id: t.identifier, x: -1, y: -1, clientX: t.clientX, clientY: t.clientY, pressure: t.force, radiusX: t.radiusX, radiusY: t.radiusY, rotationAngle: t.rotationAngle });
2242
+ }
2243
+ Mo(t, e, i, s) {
2244
+ const r = this.er.canvas, n = r.getBoundingClientRect(), o = t - n.left, c = e - n.top, l = r.width / n.width, u = c * (r.height / n.height), f = o * l - this.Gr.offsetX, g = u - this.Gr.offsetY, v = Math.floor(f / this.Gr.cellWidth), p = Math.floor(g / this.Gr.cellHeight), d = v >= 0 && v < this.Gr.cols && p >= 0 && p < this.Gr.rows;
2245
+ return { id: i, x: d ? v : -1, y: d ? p : -1, clientX: t, clientY: e, pressure: s.pressure, radiusX: s.radiusX, radiusY: s.radiusY, rotationAngle: s.rotationAngle };
2246
+ }
2247
+ Bo(t, e, i, s) {
2248
+ const r = this.Wn.get(t.id), n = Array.from(this.On.values()).map((l) => this.Go(l)), o = Array.from(this.In.values()).map((l) => this.Go(l)), c = this.Do(e.changedTouches);
2249
+ return { touch: this.Go(t), previousTouch: i ? this.Go(i) : void 0, touches: o, previousTouches: n, changedTouches: c, deltaTime: r ? s - r.lastTime : 0, originalEvent: e };
2250
+ }
2251
+ Io() {
2252
+ if (this.In.size !== 2) return void (this.Hn = null);
2253
+ const t = Array.from(this.In.values()), [e, i] = t, s = this.Oo(e, i, !1), r = this.Vo(e, i);
2254
+ this.Hn = { ids: [e.id, i.id], initialDistance: Math.max(s, 1e-4), initialAngle: r, lastScale: 1, lastRotation: 0 };
2255
+ }
2256
+ Wo(t) {
2257
+ if (this.Hn || this.Io(), !this.Hn) return;
2258
+ const [e, i] = this.Hn.ids, s = this.In.get(e), r = this.In.get(i);
2259
+ if (!s || !r) return;
2260
+ const n = this.Oo(s, r, !1) / this.Hn.initialDistance, o = n - this.Hn.lastScale;
2261
+ this.no && Math.abs(o) > this._o && (this.no({ touches: [this.Go(s), this.Go(r)], scale: n, deltaScale: o, center: this.Ko(s, r), originalEvent: t }), this.Hn.lastScale = n);
2262
+ let c = this.Vo(s, r) - this.Hn.initialAngle;
2263
+ c = (c + 180) % 360 - 180;
2264
+ const l = c - this.Hn.lastRotation;
2265
+ this.oo && Math.abs(l) > this.po && (this.oo({ touches: [this.Go(s), this.Go(r)], rotation: c, deltaRotation: l, center: this.Ko(s, r), originalEvent: t }), this.Hn.lastRotation = c);
2266
+ }
2267
+ Ko(t, e) {
2268
+ const i = (t.clientX + e.clientX) / 2, s = (t.clientY + e.clientY) / 2, r = this.Mo(i, s, -1, { id: -1, x: -1, y: -1, clientX: i, clientY: s });
2269
+ return { x: r.x, y: r.y };
2270
+ }
2271
+ Ho(t, e) {
2272
+ const i = performance.now(), s = i - t.startTime, r = this.Oo(t.startPosition, t.lastPosition, !0);
2273
+ if (!t.longPressFired && s <= this.ho && r <= this.co)
2274
+ this.jo(t.lastPosition, i) && this.so ? this.so({ touch: this.Go(t.lastPosition), taps: 2, originalEvent: e }) : this.eo && this.eo({ touch: this.Go(t.lastPosition), taps: 1, originalEvent: e });
2275
+ else if (!t.longPressFired && s <= this.do && r >= this.fo) {
2276
+ const n = { x: t.lastPosition.clientX - t.startPosition.clientX, y: t.lastPosition.clientY - t.startPosition.clientY }, o = Math.max(Math.hypot(n.x, n.y), 1e-4), c = { x: n.x / o, y: n.y / o }, l = { x: n.x / s, y: n.y / s };
2277
+ this.ro && this.ro({ touch: this.Go(t.lastPosition), direction: c, distance: o, velocity: l, originalEvent: e });
2053
2278
  }
2279
+ this.vo = i, this.yo = this.Go(t.lastPosition);
2054
2280
  }
2055
- xn(t) {
2056
- const e = this.er.canvas;
2057
- this.ln = { ...this.cn }, this.un = { x: t.clientX, y: t.clientY };
2058
- 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.hn.offsetX, l = o - this.hn.offsetY, u = Math.floor(c / this.hn.cellWidth), f = Math.floor(l / this.hn.cellHeight);
2059
- u >= 0 && u < this.hn.cols && f >= 0 && f < this.hn.rows ? (this.cn.x = u, this.cn.y = f) : (this.cn.x = -1, this.cn.y = -1);
2281
+ jo(t, e) {
2282
+ return !this.yo || e - this.vo > this.ao ? !1 : this.Oo(t, this.yo, !0) <= this.co;
2283
+ }
2284
+ Go(t) {
2285
+ return { ...t };
2286
+ }
2287
+ Oo(t, e, i) {
2288
+ return i ? Math.hypot(t.clientX - e.clientX, t.clientY - e.clientY) : Math.hypot(t.x - e.x, t.y - e.y);
2289
+ }
2290
+ Vo(t, e) {
2291
+ return 180 * Math.atan2(e.clientY - t.clientY, e.clientX - t.clientX) / Math.PI;
2060
2292
  }
2061
2293
  }
2062
- const Kt = (h) => class extends h {
2294
+ const Zt = Object.freeze(Object.defineProperty({ __proto__: null, TouchManager: ut }, Symbol.toStringTag, { value: "Module" })), Qt = (a) => class extends a {
2063
2295
  rotate(t = 0, e = 0, i = 0) {
2064
2296
  this.xt.state.et(t), this.xt.state.st(e), this.xt.state.it(i);
2065
2297
  }
@@ -2073,19 +2305,19 @@ const Kt = (h) => class extends h {
2073
2305
  this.xt.state.it(t);
2074
2306
  }
2075
2307
  push() {
2076
- this.xt.state.W();
2308
+ this.xt.state.O();
2077
2309
  }
2078
2310
  pop() {
2079
2311
  this.xt.state.Z();
2080
2312
  }
2081
2313
  rect(t, e, i = 1, s = 1) {
2082
- this.xt.Vs(t, e, i, s);
2314
+ this.xt.Xs(t, e, i, s);
2083
2315
  }
2084
2316
  point(t, e) {
2085
- this.xt.Vs(t, e, 1, 1);
2317
+ this.xt.Xs(t, e, 1, 1);
2086
2318
  }
2087
2319
  line(t, e, i, s) {
2088
- this.xt.Ks(t, e, i, s);
2320
+ this.xt.Vs(t, e, i, s);
2089
2321
  }
2090
2322
  lineWeight(t) {
2091
2323
  this.xt.state.tt(t);
@@ -2094,13 +2326,13 @@ const Kt = (h) => class extends h {
2094
2326
  this.xt.Zs(t, e, i, s);
2095
2327
  }
2096
2328
  char(t) {
2097
- this.xt.state.rt(this.Li.Ti(t));
2329
+ this.xt.state.rt(this.zi.Ei(t));
2098
2330
  }
2099
- charColor(t, e, i) {
2100
- this.xt.state.nt(t, e, i);
2331
+ charColor(t, e, i, s = 255) {
2332
+ this.xt.state.nt(t, e, i, s);
2101
2333
  }
2102
- cellColor(t, e, i) {
2103
- this.xt.state.ot(t, e, i);
2334
+ cellColor(t, e, i, s = 255) {
2335
+ this.xt.state.ot(t, e, i, s);
2104
2336
  }
2105
2337
  flipX(t) {
2106
2338
  this.xt.state.ht(t);
@@ -2118,25 +2350,25 @@ const Kt = (h) => class extends h {
2118
2350
  this.xt.Zs(0, 0, 0, 0);
2119
2351
  }
2120
2352
  ellipse(t, e, i, s) {
2121
- this.xt.Ns(t, e, i / 2, s / 2);
2353
+ this.xt.Ks(t, e, i / 2, s / 2);
2122
2354
  }
2123
2355
  triangle(t, e, i, s, r, n) {
2124
- this.xt.Xs(t, e, i, s, r, n);
2356
+ this.xt.js(t, e, i, s, r, n);
2125
2357
  }
2126
2358
  bezierCurve(t, e, i, s, r, n, o, c) {
2127
- this.xt.js(t, e, i, s, r, n, o, c);
2359
+ this.xt.Ns(t, e, i, s, r, n, o, c);
2128
2360
  }
2129
2361
  arc(t, e, i, s, r, n) {
2130
2362
  this.xt.qs(t, e, i, s, r, n);
2131
2363
  }
2132
2364
  shader(t) {
2133
- this.xt.Bs(t);
2365
+ this.xt.Gs(t);
2134
2366
  }
2135
2367
  setUniform(t, e) {
2136
- this.xt.Xt(t, e);
2368
+ this.xt.jt(t, e);
2137
2369
  }
2138
2370
  setUniforms(t) {
2139
- this.xt.Ds(t);
2371
+ this.xt.Bs(t);
2140
2372
  }
2141
2373
  createFilterShader(t) {
2142
2374
  return this.xt.oe(t);
@@ -2150,83 +2382,83 @@ const Kt = (h) => class extends h {
2150
2382
  this.xt.Is(n, e, i, s ?? n.width, r ?? n.height);
2151
2383
  } else {
2152
2384
  const n = t;
2153
- this.xt.Ws(n, e, i, s ?? Math.floor(this.hn.cols / 2), r ?? Math.floor(this.hn.rows / 2));
2385
+ this.xt.Os(n, e, i, s ?? Math.floor(this.Gr.cols / 2), r ?? Math.floor(this.Gr.rows / 2));
2154
2386
  }
2155
2387
  }
2156
2388
  async loadImage(t) {
2157
- if (typeof t != "string") return k.Rr(this.xt, t, (s) => this.Li.Ei(s));
2389
+ if (typeof t != "string") return $.Sr(this.xt, t, (s) => this.zi.ki(s));
2158
2390
  const e = t, i = await new Promise((s, r) => {
2159
2391
  const n = new Image();
2160
2392
  n.crossOrigin = "anonymous", n.onload = () => s(n), n.onerror = (o) => r(o), n.src = e;
2161
2393
  });
2162
- return k.Rr(this.xt, i, (s) => this.Li.Ei(s));
2394
+ return $.Sr(this.xt, i, (s) => this.zi.ki(s));
2163
2395
  }
2164
2396
  };
2165
- class J {
2166
- Pn(t) {
2167
- const e = t.zt(0), i = t.zt(1), s = t.zt(2), r = t.zt(3);
2168
- return { characterPixels: e, primaryColorPixels: i, secondaryColorPixels: s, transformPixels: t.zt(4), rotationPixels: r };
2397
+ class Z {
2398
+ No(t) {
2399
+ const e = t.At(0), i = t.At(1), s = t.At(2), r = t.At(3);
2400
+ return { characterPixels: e, primaryColorPixels: i, secondaryColorPixels: s, transformPixels: t.At(4), rotationPixels: r };
2169
2401
  }
2170
- kn(t, e) {
2402
+ Yo(t, e) {
2171
2403
  return t[e] + (t[e + 1] << 8);
2172
2404
  }
2173
- Gn(t, e) {
2405
+ qo(t, e) {
2174
2406
  return { r: t[e], g: t[e + 1], b: t[e + 2], a: t[e + 3] };
2175
2407
  }
2176
2408
  }
2177
2409
  class Q {
2178
- Bn(t, e) {
2410
+ Zo(t, e) {
2179
2411
  return new Blob([t], { type: e });
2180
2412
  }
2181
- Dn(t, e, i) {
2413
+ Jo(t, e, i) {
2182
2414
  try {
2183
- const s = this.Bn(t, i), r = URL.createObjectURL(s), n = document.createElement("a");
2415
+ const s = this.Zo(t, i), r = URL.createObjectURL(s), n = document.createElement("a");
2184
2416
  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);
2185
2417
  } catch (s) {
2186
2418
  console.error("Failed to download file:", s);
2187
2419
  }
2188
2420
  }
2189
- In() {
2421
+ Qo() {
2190
2422
  return (/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace(/:/g, "-");
2191
2423
  }
2192
- Wn() {
2424
+ th() {
2193
2425
  const t = /* @__PURE__ */ new Date();
2194
2426
  return { date: t.toISOString().split("T")[0], time: t.toTimeString().split(" ")[0].replace(/:/g, "-") };
2195
2427
  }
2196
- On(t) {
2428
+ eh(t) {
2197
2429
  return t.replace(/[<>:"/\\|?*]/g, "_").replace(/\s+/g, "_").replace(/_{2,}/g, "_").replace(/^_+|_+$/g, "").substring(0, 255);
2198
2430
  }
2199
- Hn() {
2200
- return "textmode-export-" + this.In();
2431
+ sh() {
2432
+ return "textmode-export-" + this.Qo();
2201
2433
  }
2202
2434
  }
2203
- class jt extends J {
2204
- Vn(t, e, i) {
2435
+ class Jt extends Z {
2436
+ ih(t, e, i) {
2205
2437
  const s = t[i] === 255, r = t[i + 1] === 255, n = t[i + 2] === 255, o = e[i], c = e[i + 1];
2206
2438
  return { isInverted: s, flipHorizontal: r, flipVertical: n, rotation: Math.round(360 * (o + c / 255) / 255 * 100) / 100 };
2207
2439
  }
2208
- Kn(t, e, i) {
2440
+ rh(t, e, i) {
2209
2441
  return { x: t, y: e, cellX: t * i.cellWidth, cellY: e * i.cellHeight };
2210
2442
  }
2211
- Nn(t, e) {
2443
+ nh(t, e) {
2212
2444
  const i = [];
2213
2445
  let s = 0;
2214
2446
  for (let r = 0; r < e.rows; r++) for (let n = 0; n < e.cols; n++) {
2215
- const o = 4 * s, c = this.kn(t.characterPixels, o);
2216
- let l = this.Gn(t.primaryColorPixels, o), u = this.Gn(t.secondaryColorPixels, o);
2217
- const f = this.Vn(t.transformPixels, t.rotationPixels, o);
2447
+ const o = 4 * s, c = this.Yo(t.characterPixels, o);
2448
+ let l = this.qo(t.primaryColorPixels, o), u = this.qo(t.secondaryColorPixels, o);
2449
+ const f = this.ih(t.transformPixels, t.rotationPixels, o);
2218
2450
  if (f.isInverted) {
2219
2451
  const v = l;
2220
2452
  l = u, u = v;
2221
2453
  }
2222
- const g = this.Kn(n, r, e);
2454
+ const g = this.rh(n, r, e);
2223
2455
  i.push({ charIndex: c, primaryColor: l, secondaryColor: u, transform: f, position: g }), s++;
2224
2456
  }
2225
2457
  return i;
2226
2458
  }
2227
2459
  }
2228
- class qt {
2229
- Xn(t, e) {
2460
+ class te {
2461
+ oh(t, e) {
2230
2462
  const i = t.cmap;
2231
2463
  for (const s of i.tables) if (s.format === 4) {
2232
2464
  const r = s;
@@ -2249,11 +2481,11 @@ class qt {
2249
2481
  }
2250
2482
  return 0;
2251
2483
  }
2252
- jn(t, e, i, s, r) {
2484
+ hh(t, e, i, s, r) {
2253
2485
  const n = r / t.head.unitsPerEm;
2254
- return { getBoundingBox: () => ({ x1: i + e.xMin * n, y1: s + -e.yMax * n, x2: i + e.xMax * n, y2: s + -e.yMin * n }), toSVG: () => this.Yn(e, i, s, n) };
2486
+ return { getBoundingBox: () => ({ x1: i + e.xMin * n, y1: s + -e.yMax * n, x2: i + e.xMax * n, y2: s + -e.yMin * n }), toSVG: () => this.ah(e, i, s, n) };
2255
2487
  }
2256
- Yn(t, e, i, s) {
2488
+ ah(t, e, i, s) {
2257
2489
  if (!t || !t.xs) return "";
2258
2490
  const { xs: r, ys: n, endPts: o, flags: c } = t;
2259
2491
  if (!(r && n && o && c)) return "";
@@ -2262,22 +2494,22 @@ class qt {
2262
2494
  const g = o[f];
2263
2495
  if (!(g < u)) {
2264
2496
  if (g >= u) {
2265
- const v = e + r[u] * s, m = i - n[u] * s;
2266
- l += `M${v.toFixed(2)},${m.toFixed(2)}`;
2497
+ const v = e + r[u] * s, p = i - n[u] * s;
2498
+ l += `M${v.toFixed(2)},${p.toFixed(2)}`;
2267
2499
  let d = u + 1;
2268
2500
  for (; d <= g; )
2269
2501
  if (1 & c[d]) {
2270
- const x = e + r[d] * s, p = i - n[d] * s;
2271
- l += `L${x.toFixed(2)},${p.toFixed(2)}`, d++;
2502
+ const y = e + r[d] * s, m = i - n[d] * s;
2503
+ l += `L${y.toFixed(2)},${m.toFixed(2)}`, d++;
2272
2504
  } else {
2273
- const x = e + r[d] * s, p = i - n[d] * s;
2274
- let E = d + 1 > g ? u : d + 1;
2275
- if (1 & c[E]) {
2276
- const y = e + r[E] * s, C = i - n[E] * s;
2277
- l += `Q${x.toFixed(2)},${p.toFixed(2)} ${y.toFixed(2)},${C.toFixed(2)}`, d = E + 1;
2505
+ const y = e + r[d] * s, m = i - n[d] * s;
2506
+ let w = d + 1 > g ? u : d + 1;
2507
+ if (1 & c[w]) {
2508
+ const x = e + r[w] * s, C = i - n[w] * s;
2509
+ l += `Q${y.toFixed(2)},${m.toFixed(2)} ${x.toFixed(2)},${C.toFixed(2)}`, d = w + 1;
2278
2510
  } else {
2279
- const y = (x + (e + r[E] * s)) / 2, C = (p + (i - n[E] * s)) / 2;
2280
- l += `Q${x.toFixed(2)},${p.toFixed(2)} ${y.toFixed(2)},${C.toFixed(2)}`, d = E;
2511
+ const x = (y + (e + r[w] * s)) / 2, C = (m + (i - n[w] * s)) / 2;
2512
+ l += `Q${y.toFixed(2)},${m.toFixed(2)} ${x.toFixed(2)},${C.toFixed(2)}`, d = w;
2281
2513
  }
2282
2514
  }
2283
2515
  l += "Z";
@@ -2287,34 +2519,34 @@ class qt {
2287
2519
  }
2288
2520
  return l;
2289
2521
  }
2290
- qn(t, e, i, s, r) {
2291
- const n = t.codePointAt(0) || 0, o = this.Xn(e, n);
2522
+ uh(t, e, i, s, r) {
2523
+ const n = t.codePointAt(0) || 0, o = this.oh(e, n);
2292
2524
  let c = null;
2293
- return e.glyf && e.glyf[o] !== null ? c = e.glyf[o] : (c = F.T.glyf.Qs(e, o), e.glyf[o] = c), this.jn(e, c, i, s, r);
2525
+ return e.glyf && e.glyf[o] !== null ? c = e.glyf[o] : (c = L.T.glyf.Qs(e, o), e.glyf[o] = c), this.hh(e, c, i, s, r);
2294
2526
  }
2295
- Zn(t, e, i, s, r, n, o, c) {
2527
+ fh(t, e, i, s, r, n, o, c) {
2296
2528
  const l = i + (r - c * (o / e.head.unitsPerEm)) / 2, u = s + (n + 0.7 * o) / 2;
2297
- return this.qn(t, e, l, u, o).toSVG() || null;
2529
+ return this.uh(t, e, l, u, o).toSVG() || null;
2298
2530
  }
2299
2531
  }
2300
- class Jt {
2532
+ class ee {
2301
2533
  constructor() {
2302
- a(this, "Jn");
2303
- this.Jn = new qt();
2534
+ h(this, "dh");
2535
+ this.dh = new te();
2304
2536
  }
2305
- Qn(t) {
2537
+ _h(t) {
2306
2538
  const { width: e, height: i } = t;
2307
2539
  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>`;
2308
2540
  }
2309
- eo() {
2541
+ ph() {
2310
2542
  return "</g></svg>";
2311
2543
  }
2312
- so(t, e) {
2544
+ mh(t, e) {
2313
2545
  if (!e.includeBackgroundRectangles) return "";
2314
2546
  const [i, s, r, n] = e.backgroundColor;
2315
2547
  return `<rect width="${t.width}" height="${t.height}" fill="rgba(${i},${s},${r},${n / 255})"/>`;
2316
2548
  }
2317
- io(t, e) {
2549
+ gh(t, e) {
2318
2550
  const { transform: i, position: s } = t;
2319
2551
  if (!i.flipHorizontal && !i.flipVertical && !i.rotation) return "";
2320
2552
  const r = s.cellX + e.cellWidth / 2, n = s.cellY + e.cellHeight / 2, o = [];
@@ -2324,76 +2556,76 @@ class Jt {
2324
2556
  }
2325
2557
  return i.rotation && o.push(`rotate(${i.rotation} ${r} ${n})`), ` transform="${o.join(" ")}"`;
2326
2558
  }
2327
- ro(t, e, i) {
2559
+ yh(t, e, i) {
2328
2560
  if (!i.includeBackgroundRectangles || t.secondaryColor.a === 0) return "";
2329
2561
  const { position: s } = t, { r, g: n, b: o, a: c } = t.secondaryColor, l = `rgba(${r},${n},${o},${c / 255})`;
2330
2562
  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}"/>`;
2331
2563
  }
2332
- qn(t, e, i, s) {
2564
+ uh(t, e, i, s) {
2333
2565
  const r = i.characters[t.charIndex];
2334
2566
  if (!r) return "";
2335
- const n = this.Jn.Zn(r.character, i.font, t.position.cellX, t.position.cellY, e.cellWidth, e.cellHeight, i.fontSize, r.advanceWidth);
2567
+ const n = this.dh.fh(r.character, i.font, t.position.cellX, t.position.cellY, e.cellWidth, e.cellHeight, i.fontSize, r.advanceWidth);
2336
2568
  if (!n) return "";
2337
2569
  const { r: o, g: c, b: l, a: u } = t.primaryColor, f = `rgba(${o},${c},${l},${u / 255})`;
2338
2570
  return s.drawMode === "stroke" ? `<path d="${n}" stroke="${f}" stroke-width="${s.strokeWidth}" fill="none"/>` : `<path d="${n}" fill="${f}"/>`;
2339
2571
  }
2340
- no(t, e, i, s) {
2341
- const r = [], n = this.ro(t, e, s);
2572
+ Ch(t, e, i, s) {
2573
+ const r = [], n = this.yh(t, e, s);
2342
2574
  n && r.push(n);
2343
- const o = this.qn(t, e, i, s);
2575
+ const o = this.uh(t, e, i, s);
2344
2576
  if (o) {
2345
- const c = this.io(t, e);
2577
+ const c = this.gh(t, e);
2346
2578
  r.push(c ? `<g${c}>${o}</g>` : o);
2347
2579
  }
2348
2580
  return r.join("");
2349
2581
  }
2350
- oo(t, e, i, s) {
2351
- const r = [this.Qn(e), this.so(e, s), '<g id="ascii-cells">'];
2352
- for (const n of t) r.push(this.no(n, e, i, s));
2353
- return r.push(this.eo()), r.join("");
2582
+ wh(t, e, i, s) {
2583
+ const r = [this._h(e), this.mh(e, s), '<g id="ascii-cells">'];
2584
+ for (const n of t) r.push(this.Ch(n, e, i, s));
2585
+ return r.push(this.ph()), r.join("");
2354
2586
  }
2355
- ao(t) {
2587
+ $h(t) {
2356
2588
  return t.replace(/<path[^>]*d=""[^>]*\/>/g, "").replace(/\s+/g, " ").replace(/> </g, "><");
2357
2589
  }
2358
2590
  }
2359
- class Qt extends Q {
2360
- ho(t) {
2361
- return this.Bn(t, "image/svg+xml;charset=utf-8");
2591
+ class ie extends Q {
2592
+ bh(t) {
2593
+ return this.Zo(t, "image/svg+xml;charset=utf-8");
2362
2594
  }
2363
- co(t, e) {
2364
- this.Dn(t, this.On(e) + ".svg", "image/svg+xml;charset=utf-8");
2595
+ xh(t, e) {
2596
+ this.Jo(t, this.eh(e) + ".svg", "image/svg+xml;charset=utf-8");
2365
2597
  }
2366
- lo(t, e) {
2367
- this.co(t, e || this.Hn());
2598
+ Mh(t, e) {
2599
+ this.xh(t, e || this.sh());
2368
2600
  }
2369
2601
  }
2370
2602
  class st {
2371
2603
  constructor() {
2372
- a(this, "uo");
2373
- a(this, "fo");
2374
- a(this, "do");
2375
- this.uo = new jt(), this.fo = new Jt(), this.do = new Qt();
2604
+ h(this, "Sh");
2605
+ h(this, "Rh");
2606
+ h(this, "Fh");
2607
+ this.Sh = new Jt(), this.Rh = new ee(), this.Fh = new ie();
2376
2608
  }
2377
- _o(t) {
2378
- return { includeBackgroundRectangles: t.includeBackgroundRectangles ?? !0, drawMode: t.drawMode ?? "fill", strokeWidth: t.strokeWidth ?? 1, backgroundColor: t.backgroundColor ?? [0, 0, 0, 0], filename: t.filename || this.do.Hn() };
2609
+ Th(t) {
2610
+ return { includeBackgroundRectangles: t.includeBackgroundRectangles ?? !0, drawMode: t.drawMode ?? "fill", strokeWidth: t.strokeWidth ?? 1, backgroundColor: t.backgroundColor ?? [0, 0, 0, 0], filename: t.filename || this.Fh.sh() };
2379
2611
  }
2380
- po(t, e = {}) {
2381
- const i = this.uo.Nn(this.uo.Pn(t.pipeline), t.grid), s = this.fo.oo(i, t.grid, t.font, this._o(e));
2382
- return this.fo.ao(s);
2612
+ Ah(t, e = {}) {
2613
+ const i = this.Sh.nh(this.Sh.No(t.pipeline), t.grid), s = this.Rh.wh(i, t.grid, t.font, this.Th(e));
2614
+ return this.Rh.$h(s);
2383
2615
  }
2384
- lo(t, e = {}) {
2385
- this.do.lo(this.po(t, e), e.filename);
2616
+ Mh(t, e = {}) {
2617
+ this.Fh.Mh(this.Ah(t, e), e.filename);
2386
2618
  }
2387
2619
  }
2388
- class Zt extends J {
2389
- mo(t, e, i, s = " ") {
2620
+ class se extends Z {
2621
+ Eh(t, e, i, s = " ") {
2390
2622
  var o;
2391
2623
  const r = [];
2392
2624
  let n = 0;
2393
2625
  for (let c = 0; c < e.rows; c++) {
2394
2626
  const l = [];
2395
2627
  for (let u = 0; u < e.cols; u++) {
2396
- const f = 4 * n, g = this.kn(t.characterPixels, f), v = ((o = i.characters[g]) == null ? void 0 : o.character) || s;
2628
+ const f = 4 * n, g = this.Yo(t.characterPixels, f), v = ((o = i.characters[g]) == null ? void 0 : o.character) || s;
2397
2629
  l.push(v), n++;
2398
2630
  }
2399
2631
  r.push(l);
@@ -2401,8 +2633,8 @@ class Zt extends J {
2401
2633
  return r;
2402
2634
  }
2403
2635
  }
2404
- class te {
2405
- vo(t, e) {
2636
+ class re {
2637
+ kh(t, e) {
2406
2638
  const i = [];
2407
2639
  for (const r of t) {
2408
2640
  let n = r.join("");
@@ -2414,56 +2646,56 @@ class te {
2414
2646
  return i.join(s);
2415
2647
  }
2416
2648
  }
2417
- class ee extends Q {
2418
- yo(t, e) {
2419
- const i = this.Co(e);
2420
- this.Dn(t, i, "text/plain;charset=utf-8");
2649
+ class ne extends Q {
2650
+ zh(t, e) {
2651
+ const i = this.Ph(e);
2652
+ this.Jo(t, i, "text/plain;charset=utf-8");
2421
2653
  }
2422
- Co(t) {
2423
- let e = this.On(t);
2424
- return e === ".txt" || e.length <= 4 ? this.Hn() : e;
2654
+ Ph(t) {
2655
+ let e = this.eh(t);
2656
+ return e === ".txt" || e.length <= 4 ? this.sh() : e;
2425
2657
  }
2426
2658
  }
2427
2659
  class rt {
2428
2660
  constructor() {
2429
- a(this, "uo");
2430
- a(this, "fo");
2431
- a(this, "do");
2432
- this.uo = new Zt(), this.fo = new te(), this.do = new ee();
2661
+ h(this, "Sh");
2662
+ h(this, "Rh");
2663
+ h(this, "Fh");
2664
+ this.Sh = new se(), this.Rh = new re(), this.Fh = new ne();
2433
2665
  }
2434
- _o(t) {
2435
- return { preserveTrailingSpaces: t.preserveTrailingSpaces ?? !1, lineEnding: t.lineEnding ?? "lf", emptyCharacter: t.emptyCharacter ?? " ", filename: t.filename || this.do.Hn() };
2666
+ Th(t) {
2667
+ return { preserveTrailingSpaces: t.preserveTrailingSpaces ?? !1, lineEnding: t.lineEnding ?? "lf", emptyCharacter: t.emptyCharacter ?? " ", filename: t.filename || this.Fh.sh() };
2436
2668
  }
2437
- wo(t, e = {}) {
2438
- const i = this._o(e), s = this.uo.mo(this.uo.Pn(t.pipeline), t.grid, t.font, i.emptyCharacter);
2439
- return this.fo.vo(s, i);
2669
+ Lh(t, e = {}) {
2670
+ const i = this.Th(e), s = this.Sh.Eh(this.Sh.No(t.pipeline), t.grid, t.font, i.emptyCharacter);
2671
+ return this.Rh.kh(s, i);
2440
2672
  }
2441
- yo(t, e = {}) {
2442
- this.do.yo(this.wo(t, e), e.filename);
2673
+ zh(t, e = {}) {
2674
+ this.Fh.zh(this.Lh(t, e), e.filename);
2443
2675
  }
2444
2676
  }
2445
- class ie extends J {
2446
- $o(t, e = 1, i = "transparent") {
2677
+ class oe extends Z {
2678
+ Dh(t, e = 1, i = "transparent") {
2447
2679
  const s = t.canvas;
2448
2680
  if (e === 1 && i === "transparent") return s;
2449
2681
  const r = document.createElement("canvas"), n = r.getContext("2d"), o = Math.round(s.width * e), c = Math.round(s.height * e);
2450
2682
  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;
2451
2683
  }
2452
2684
  }
2453
- class se {
2454
- bo(t, e) {
2455
- const i = this.xo(e.format);
2685
+ class he {
2686
+ Gh(t, e) {
2687
+ const i = this.Bh(e.format);
2456
2688
  return e.format === "png" ? t.toDataURL(i) : t.toDataURL(i, e.quality);
2457
2689
  }
2458
- async Mo(t, e) {
2690
+ async Ih(t, e) {
2459
2691
  return new Promise((i, s) => {
2460
- const r = this.xo(e.format), n = (o) => {
2692
+ const r = this.Bh(e.format), n = (o) => {
2461
2693
  o ? i(o) : s(Error(`Failed to generate ${e.format.toUpperCase()} blob`));
2462
2694
  };
2463
2695
  e.format === "png" ? t.toBlob(n, r) : t.toBlob(n, r, e.quality);
2464
2696
  });
2465
2697
  }
2466
- xo(t) {
2698
+ Bh(t) {
2467
2699
  switch (t) {
2468
2700
  case "png":
2469
2701
  return "image/png";
@@ -2476,12 +2708,12 @@ class se {
2476
2708
  }
2477
2709
  }
2478
2710
  }
2479
- const re = { png: "image/png", jpg: "image/jpeg", webp: "image/webp" }, nt = { png: ".png", jpg: ".jpg", webp: ".webp" };
2480
- class ne extends Q {
2481
- Ro(t, e, i) {
2482
- this.Fo(t, this.On(e) + nt[i]);
2711
+ const ae = { png: "image/png", jpg: "image/jpeg", webp: "image/webp" }, nt = { png: ".png", jpg: ".jpg", webp: ".webp" };
2712
+ class ce extends Q {
2713
+ Oh(t, e, i) {
2714
+ this.Wh(t, this.eh(e) + nt[i]);
2483
2715
  }
2484
- Fo(t, e) {
2716
+ Wh(t, e) {
2485
2717
  const i = URL.createObjectURL(t);
2486
2718
  try {
2487
2719
  const s = document.createElement("a");
@@ -2490,226 +2722,267 @@ class ne extends Q {
2490
2722
  URL.revokeObjectURL(i);
2491
2723
  }
2492
2724
  }
2493
- So(t) {
2494
- return t in re && t in nt;
2725
+ Hh(t) {
2726
+ return t in ae && t in nt;
2495
2727
  }
2496
2728
  }
2497
- class oe {
2729
+ class le {
2498
2730
  constructor() {
2499
- a(this, "uo");
2500
- a(this, "fo");
2501
- a(this, "do");
2502
- this.uo = new ie(), this.fo = new se(), this.do = new ne();
2731
+ h(this, "Sh");
2732
+ h(this, "Rh");
2733
+ h(this, "Fh");
2734
+ this.Sh = new oe(), this.Rh = new he(), this.Fh = new ce();
2503
2735
  }
2504
- _o(t) {
2505
- return { format: t.format ?? "png", quality: t.quality ?? 1, scale: t.scale ?? 1, backgroundColor: t.backgroundColor ?? "transparent", filename: t.filename || this.do.Hn() };
2736
+ Th(t) {
2737
+ return { format: t.format ?? "png", quality: t.quality ?? 1, scale: t.scale ?? 1, backgroundColor: t.backgroundColor ?? "transparent", filename: t.filename || this.Fh.sh() };
2506
2738
  }
2507
- Ao(t) {
2508
- if (!this.do.So(t.format)) throw Error(`Saving '${t.format}' files is not supported`);
2739
+ Xh(t) {
2740
+ if (!this.Fh.Hh(t.format)) throw Error(`Saving '${t.format}' files is not supported`);
2509
2741
  if (t.quality < 0 || t.quality > 1) throw Error("Image quality must be between 0.0 and 1.0");
2510
2742
  if (t.scale <= 0) throw Error("Scale factor must be greater than 0");
2511
2743
  t.format === "jpg" && t.backgroundColor === "transparent" && (t.backgroundColor = "black");
2512
2744
  }
2513
- async Mo(t, e) {
2514
- if (e.scale === 1 && e.backgroundColor === "transparent") return await this.fo.Mo(t.canvas, e);
2515
- const i = this.uo.$o(t, e.scale, e.backgroundColor);
2516
- return await this.fo.Mo(i, e);
2745
+ async Ih(t, e) {
2746
+ if (e.scale === 1 && e.backgroundColor === "transparent") return await this.Rh.Ih(t.canvas, e);
2747
+ const i = this.Sh.Dh(t, e.scale, e.backgroundColor);
2748
+ return await this.Rh.Ih(i, e);
2517
2749
  }
2518
- async Ro(t, e = {}) {
2519
- const i = this._o(e);
2520
- this.Ao(i);
2521
- const s = await this.Mo(t, i);
2522
- this.do.Ro(s, i.filename, i.format);
2750
+ async Oh(t, e = {}) {
2751
+ const i = this.Th(e);
2752
+ this.Xh(i);
2753
+ const s = await this.Ih(t, i);
2754
+ this.Fh.Oh(s, i.filename, i.format);
2523
2755
  }
2524
2756
  }
2525
- const he = (h) => class extends h {
2526
- zo() {
2527
- this.xt.Et(this.To);
2757
+ const ue = (a) => class extends a {
2758
+ Vh() {
2759
+ this.xt.kt(this.Kh);
2528
2760
  }
2529
2761
  toString(t = {}) {
2530
- return this.zo(), new rt().wo({ pipeline: this.Eo, grid: this.hn, font: this.Li }, t);
2762
+ return this.Vh(), new rt().Lh({ pipeline: this.jh, grid: this.Gr, font: this.zi }, t);
2531
2763
  }
2532
2764
  saveStrings(t = {}) {
2533
- this.zo(), new rt().yo({ pipeline: this.Eo, grid: this.hn, font: this.Li }, t);
2765
+ this.Vh(), new rt().zh({ pipeline: this.jh, grid: this.Gr, font: this.zi }, t);
2534
2766
  }
2535
2767
  toSVG(t = {}) {
2536
- return this.zo(), new st().po({ pipeline: this.Eo, grid: this.hn, font: this.Li }, t);
2768
+ return this.Vh(), new st().Ah({ pipeline: this.jh, grid: this.Gr, font: this.zi }, t);
2537
2769
  }
2538
2770
  saveSVG(t = {}) {
2539
- this.zo(), new st().lo({ pipeline: this.Eo, grid: this.hn, font: this.Li }, t);
2771
+ this.Vh(), new st().Mh({ pipeline: this.jh, grid: this.Gr, font: this.zi }, t);
2540
2772
  }
2541
2773
  async saveCanvas(t = {}) {
2542
- await new oe().Ro(this.er, t);
2774
+ await new le().Oh(this.er, t);
2543
2775
  }
2544
- }, ae = (h) => class extends h {
2776
+ }, fe = (a) => class extends a {
2545
2777
  async loadFont(t) {
2546
- return this.Li.qi(t).then(() => {
2547
- const e = this.Li.maxGlyphDimensions;
2548
- this.hn.nr(e.width, e.height), this.Eo.resize(this.hn.cols, this.hn.rows), this.xt.Js(), this.Lo.bn();
2778
+ return this.zi.qi(t).then(() => {
2779
+ const e = this.zi.maxGlyphDimensions;
2780
+ this.Gr.nr(e.width, e.height), this.jh.resize(this.Gr.cols, this.Gr.rows), this.xt.Js(), this.Bn.nn();
2549
2781
  });
2550
2782
  }
2551
2783
  fontSize(t) {
2552
- if (!$.v(typeof t == "number" && t > 0, "Font size must be a positive number greater than 0.", { method: "fontSize", providedValue: t }) || this.Li.fontSize === t) return;
2553
- this.Li.Yi(t);
2554
- const e = this.Li.maxGlyphDimensions;
2555
- this.hn.nr(e.width, e.height), this.Eo.resize(this.hn.cols, this.hn.rows), this.xt.Js(), this.Lo.bn();
2784
+ if (!O.v(typeof t == "number" && t > 0, "Font size must be a positive number greater than 0.", { method: "fontSize", providedValue: t }) || this.zi.fontSize === t) return;
2785
+ this.zi.Yi(t);
2786
+ const e = this.zi.maxGlyphDimensions;
2787
+ this.Gr.nr(e.width, e.height), this.jh.resize(this.Gr.cols, this.Gr.rows), this.xt.Js(), this.Bn.nn();
2556
2788
  }
2557
2789
  glyphColor(t) {
2558
- return this.Li.Ti(t);
2790
+ return this.zi.Ei(t);
2559
2791
  }
2560
2792
  glyphColors(t) {
2561
- return this.Li.Ei(t);
2793
+ return this.zi.ki(t);
2562
2794
  }
2563
- }, ce = (h) => class extends h {
2795
+ }, de = (a) => class extends a {
2564
2796
  get frameCount() {
2565
- return this.Po.frameCount;
2797
+ return this.Nh.frameCount;
2566
2798
  }
2567
2799
  set frameCount(t) {
2568
- this.Po.frameCount = t;
2800
+ this.Nh.frameCount = t;
2569
2801
  }
2570
2802
  frameRate(t) {
2571
- return t === void 0 ? this.Po.currentFrameRate : this.Po.frameRate(t, () => this.ko());
2803
+ return t === void 0 ? this.Nh.currentFrameRate : this.Nh.frameRate(t, () => this.Yh());
2572
2804
  }
2573
2805
  noLoop() {
2574
- this.Po.pause();
2806
+ this.Nh.pause();
2575
2807
  }
2576
2808
  loop() {
2577
- this.Po.resume(() => this.ko());
2809
+ this.Nh.resume(() => this.Yh());
2578
2810
  }
2579
2811
  redraw(t = 1) {
2580
- if ($.v(typeof t == "number" && t > 0 && Number.isInteger(t), "Redraw count must be a positive integer.", { method: "redraw", providedValue: t })) for (let e = 0; e < t; e++) this.ko();
2812
+ if (O.v(typeof t == "number" && t > 0 && Number.isInteger(t), "Redraw count must be a positive integer.", { method: "redraw", providedValue: t })) for (let e = 0; e < t; e++) this.Yh();
2581
2813
  }
2582
2814
  isLooping() {
2583
- return this.Po.isLooping;
2815
+ return this.Nh.isLooping;
2584
2816
  }
2585
- }, le = (h) => class extends h {
2817
+ }, ge = (a) => class extends a {
2586
2818
  constructor(...t) {
2587
2819
  super(...t);
2588
2820
  }
2589
2821
  mouseClicked(t) {
2590
- this.Lo.zn(t);
2822
+ this.Bn.pn(t);
2591
2823
  }
2592
2824
  mousePressed(t) {
2593
- this.Lo.Zr(t);
2825
+ this.Bn.mn(t);
2594
2826
  }
2595
2827
  mouseReleased(t) {
2596
- this.Lo.Jr(t);
2828
+ this.Bn.gn(t);
2597
2829
  }
2598
2830
  mouseMoved(t) {
2599
- this.Lo.Tn(t);
2831
+ this.Bn.vn(t);
2600
2832
  }
2601
2833
  mouseScrolled(t) {
2602
- this.Lo.En(t);
2834
+ this.Bn.yn(t);
2603
2835
  }
2604
2836
  get mouse() {
2605
- return this.Lo.Ln();
2837
+ return this.Bn.Cn();
2838
+ }
2839
+ cursor(t) {
2840
+ this.Bn.rn(t);
2841
+ }
2842
+ }, me = (a) => class extends a {
2843
+ constructor(...t) {
2844
+ super(...t);
2845
+ }
2846
+ touchStarted(t) {
2847
+ this.qh.Ro(t);
2848
+ }
2849
+ touchMoved(t) {
2850
+ this.qh.vn(t);
2851
+ }
2852
+ touchEnded(t) {
2853
+ this.qh.Fo(t);
2854
+ }
2855
+ touchCancelled(t) {
2856
+ this.qh.To(t);
2857
+ }
2858
+ tap(t) {
2859
+ this.qh.Ao(t);
2606
2860
  }
2607
- }, ue = (h) => class extends h {
2861
+ doubleTap(t) {
2862
+ this.qh.Eo(t);
2863
+ }
2864
+ longPress(t) {
2865
+ this.qh.ko(t);
2866
+ }
2867
+ swipe(t) {
2868
+ this.qh.zo(t);
2869
+ }
2870
+ pinch(t) {
2871
+ this.qh.Po(t);
2872
+ }
2873
+ rotateGesture(t) {
2874
+ this.qh.Lo(t);
2875
+ }
2876
+ get touches() {
2877
+ return this.qh.So();
2878
+ }
2879
+ }, pe = (a) => class extends a {
2608
2880
  constructor(...t) {
2609
2881
  super(...t);
2610
2882
  }
2611
2883
  keyPressed(t) {
2612
- this.Go.Zr(t);
2884
+ this.Zh.mn(t);
2613
2885
  }
2614
2886
  keyReleased(t) {
2615
- this.Go.Jr(t);
2887
+ this.Zh.gn(t);
2616
2888
  }
2617
2889
  isKeyPressed(t) {
2618
- return this.Go.Qr(t);
2890
+ return this.Zh.En(t);
2619
2891
  }
2620
2892
  get lastKeyPressed() {
2621
- return this.Go.en();
2893
+ return this.Zh.zn();
2622
2894
  }
2623
2895
  get lastKeyReleased() {
2624
- return this.Go.sn();
2896
+ return this.Zh.Pn();
2625
2897
  }
2626
2898
  get pressedKeys() {
2627
- return this.Go.rn();
2899
+ return this.Zh.Ln();
2628
2900
  }
2629
2901
  get modifierState() {
2630
- return this.Go.nn();
2902
+ return this.Zh.Dn();
2631
2903
  }
2632
2904
  };
2633
- class fe {
2905
+ class ve {
2634
2906
  constructor() {
2635
- a(this, "xt");
2636
- a(this, "Li");
2637
- a(this, "er");
2638
- a(this, "hn");
2639
- a(this, "Po");
2640
- a(this, "Lo");
2641
- a(this, "Go");
2642
- a(this, "To");
2643
- a(this, "Eo");
2644
- a(this, "Bo");
2645
- a(this, "Do");
2646
- a(this, "Io");
2647
- }
2648
- ko() {
2907
+ h(this, "xt");
2908
+ h(this, "zi");
2909
+ h(this, "er");
2910
+ h(this, "Gr");
2911
+ h(this, "Nh");
2912
+ h(this, "Bn");
2913
+ h(this, "qh");
2914
+ h(this, "Zh");
2915
+ h(this, "Kh");
2916
+ h(this, "jh");
2917
+ h(this, "Jh");
2918
+ h(this, "Qh");
2919
+ h(this, "ta");
2920
+ }
2921
+ Yh() {
2649
2922
  }
2650
2923
  }
2651
- class de extends function(e, ...i) {
2924
+ class ye extends function(e, ...i) {
2652
2925
  return i.reduce((s, r) => r(s), e);
2653
- }(fe, Kt, he, ae, ce, le, ue) {
2926
+ }(ve, Qt, ue, fe, de, ge, me, pe) {
2654
2927
  constructor(e = {}) {
2655
2928
  super();
2656
- a(this, "Wo", !1);
2657
- a(this, "Oo", () => {
2929
+ h(this, "ea", !1);
2930
+ h(this, "sa", () => {
2658
2931
  });
2659
- a(this, "Ho", () => {
2932
+ h(this, "ia", () => {
2660
2933
  });
2661
- a(this, "Vo", () => {
2934
+ h(this, "ra", () => {
2662
2935
  });
2663
- a(this, "Ko");
2664
- a(this, "cr");
2665
- a(this, "hr", !1);
2666
- a(this, "No");
2667
- this.hr = e.overlay ?? !1, this.er = new Ht(e), this.xt = new Lt(this.er.gr()), this.Li = new zt(this.xt, e.fontSize ?? 16), this.Po = new Xt(e.frameRate ?? 60), this.Lo = new Vt(this.er), this.Go = new Yt(), this.To = this.xt.Tt(), this.Bo = this.xt.re(), this.Xo(e);
2668
- }
2669
- async Xo(e) {
2670
- await this.Li.Ni(e.fontSource);
2671
- const i = this.Li.maxGlyphDimensions;
2672
- this.hn = new Wt(this.er.canvas, i.width, i.height), this.Lo.Ni(this.hn), this.Eo = this.xt.Ys(this.hn.cols, this.hn.rows, 5), this.Do = this.xt.Ys(this.hn.width, this.hn.height, 1), this.hr && (this.No = k.Rr(this.xt, this.er.targetCanvas, (s) => this.Li.Ei(s))), this.Io = this.xt.ae(at, "precision mediump float;uniform sampler2D Ua;uniform vec2 Ub;uniform vec2 Uc;uniform vec2 Ud;void main(){vec2 A=gl_FragCoord.xy-Uc;vec2 B=A*(Ub/Ud);vec2 C=(floor(B)+0.5)/Ub;gl_FragColor=texture2D(Ua,C);}"), this.jo(), this.Oo(), this.Po.start(() => this.ko());
2673
- }
2674
- jo() {
2675
- this.Ko = () => {
2676
- this.hr && this.resizeCanvas(this.er.targetCanvas.width, this.er.targetCanvas.height), this.Vo();
2677
- }, window.addEventListener("resize", this.Ko), this.Lo.Xr(), this.Go.Xr(), window.addEventListener("blur", () => {
2678
- this.Go.an();
2679
- }), window.ResizeObserver && this.hr && (this.cr = new ResizeObserver(() => {
2936
+ h(this, "na");
2937
+ h(this, "cr");
2938
+ h(this, "ar", !1);
2939
+ h(this, "oa");
2940
+ this.ar = e.overlay ?? !1, this.er = new jt(e), this.xt = new St(this.er.gr()), this.zi = new kt(this.xt, e.fontSize ?? 16), this.Nh = new Vt(e.frameRate ?? 60), this.Bn = new ct(this.er), this.qh = new ut(this.er, this.Bn), this.Zh = new lt(), this.Kh = this.xt.Et(), this.Jh = this.xt.re(), this.ha(e);
2941
+ }
2942
+ async ha(e) {
2943
+ await this.zi.Ki(e.fontSource);
2944
+ const i = this.zi.maxGlyphDimensions;
2945
+ this.Gr = new Ht(this.er.canvas, i.width, i.height), this.Bn.Ki(this.Gr), this.qh.Ki(this.Gr), this.jh = this.xt.Ys(this.Gr.cols, this.Gr.rows, 5), this.Qh = this.xt.Ys(this.Gr.width, this.Gr.height, 1), this.ar && (this.oa = $.Sr(this.xt, this.er.targetCanvas, (s) => this.zi.ki(s))), this.ta = this.xt.he(at, "precision mediump float;uniform sampler2D Ua;uniform vec2 Ub;uniform vec2 Uc;uniform vec2 Ud;void main(){vec2 A=gl_FragCoord.xy-Uc;vec2 B=A*(Ub/Ud);vec2 C=(floor(B)+0.5)/Ub;gl_FragColor=texture2D(Ua,C);}"), this.aa(), this.sa(), this.Nh.start(() => this.Yh());
2946
+ }
2947
+ aa() {
2948
+ this.na = () => {
2949
+ this.ar && this.resizeCanvas(this.er.targetCanvas.width, this.er.targetCanvas.height), this.ra();
2950
+ }, window.addEventListener("resize", this.na), this.Bn.hn(), this.qh.hn(), this.Zh.hn(), window.addEventListener("blur", () => {
2951
+ this.Zh.Gn();
2952
+ }), window.ResizeObserver && this.ar && (this.cr = new ResizeObserver(() => {
2680
2953
  this.resizeCanvas(this.er.targetCanvas.width, this.er.targetCanvas.height);
2681
2954
  }), this.cr.observe(this.er.targetCanvas));
2682
2955
  }
2683
- ko() {
2684
- if (this.Po.measureFrameRate(), this.Po.incrementFrame(), this.Wo) return;
2685
- if (this.hr) {
2956
+ Yh() {
2957
+ if (this.Nh.measureFrameRate(), this.Nh.incrementFrame(), this.ea) return;
2958
+ if (this.ar) {
2686
2959
  const i = this.xt.context;
2687
- i.bindTexture(i.TEXTURE_2D, this.No.texture), i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, 1), i.texImage2D(i.TEXTURE_2D, 0, i.RGBA, i.RGBA, i.UNSIGNED_BYTE, this.er.targetCanvas), i.bindTexture(i.TEXTURE_2D, null);
2960
+ i.bindTexture(i.TEXTURE_2D, this.oa.texture), i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, 1), i.texImage2D(i.TEXTURE_2D, 0, i.RGBA, i.RGBA, i.UNSIGNED_BYTE, this.er.targetCanvas), i.bindTexture(i.TEXTURE_2D, null);
2688
2961
  }
2689
- this.Eo.begin(), this.xt.Gs(this.To), this.Ho(), this.xt.Et(this.To), this.Eo.end(), this.Do.begin(), this.xt.Gs(this.Bo), this.Bo.Nt({ U0: this.Li.fontFramebuffer, U1: [this.Li.textureColumns, this.Li.textureRows], U2: this.Eo.textures[0], U3: this.Eo.textures[1], U4: this.Eo.textures[2], U5: this.Eo.textures[4], U6: this.Eo.textures[3], U7: [this.hn.cols, this.hn.rows], U8: [this.Do.width, this.Do.height], U9: this.Do.width / this.Do.height }), this.xt.Hs(0, 0, this.er.width, this.er.height), this.Do.end();
2962
+ this.jh.begin(), this.xt.Ds(this.Kh), this.ia(), this.xt.kt(this.Kh), this.jh.end(), this.Qh.begin(), this.xt.Ds(this.Jh), this.Jh.Kt({ U0: this.zi.fontFramebuffer, U1: [this.zi.textureColumns, this.zi.textureRows], U2: this.jh.textures[0], U3: this.jh.textures[1], U4: this.jh.textures[2], U5: this.jh.textures[4], U6: this.jh.textures[3], U7: [this.Gr.cols, this.Gr.rows], U8: [this.Qh.width, this.Qh.height], U9: this.Qh.width / this.Qh.height }), this.xt.Hs(0, 0, this.er.width, this.er.height), this.Qh.end();
2690
2963
  const e = this.xt.state.canvasBackgroundColor;
2691
- this.xt.He(e[0], e[1], e[2], e[3]), this.xt.Gs(this.Io), this.Io.Nt({ Ua: this.Do.textures[0], Ub: [this.Do.width, this.Do.height], Uc: [this.hn.offsetX, this.hn.offsetY], Ud: [this.hn.width, this.hn.height] }), this.xt.Hs(this.hn.offsetX, this.hn.offsetY, this.hn.width, this.hn.height);
2964
+ this.xt.He(e[0], e[1], e[2], e[3]), this.xt.Ds(this.ta), this.ta.Kt({ Ua: this.Qh.textures[0], Ub: [this.Qh.width, this.Qh.height], Uc: [this.Gr.offsetX, this.Gr.offsetY], Ud: [this.Gr.width, this.Gr.height] }), this.xt.Hs(this.Gr.offsetX, this.Gr.offsetY, this.Gr.width, this.Gr.height);
2692
2965
  }
2693
2966
  setup(e) {
2694
- this.Oo = e;
2967
+ this.sa = e;
2695
2968
  }
2696
2969
  draw(e) {
2697
- this.Ho = e;
2970
+ this.ia = e;
2698
2971
  }
2699
2972
  windowResized(e) {
2700
- this.Vo = e;
2973
+ this.ra = e;
2701
2974
  }
2702
2975
  resizeCanvas(e, i) {
2703
- this.er.mr(e, i), this.hn.rr(), this.Eo.resize(this.hn.cols, this.hn.rows), this.Do.resize(this.hn.width, this.hn.height), this.xt.Js(), this.Lo.bn(), this.ko();
2976
+ this.er.mr(e, i), this.Gr.rr(), this.jh.resize(this.Gr.cols, this.Gr.rows), this.Qh.resize(this.Gr.width, this.Gr.height), this.xt.Js(), this.Bn.nn(), this.qh.Co(), this.Yh();
2704
2977
  }
2705
2978
  destroy() {
2706
- this.Wo || (this.Po.stop(), window.removeEventListener("resize", this.Ko), this.Lo.qr(), this.Go.qr(), this.Li.kt(), this.xt.kt(), this.Do.kt(), this.Io.kt(), this.No && this.No.kt(), this.Wo = !0);
2979
+ this.ea || (this.Nh.stop(), window.removeEventListener("resize", this.na), this.Bn._n(), this.qh._n(), this.Zh._n(), this.zi.Lt(), this.xt.Lt(), this.Qh.Lt(), this.ta.Lt(), this.oa && this.oa.Lt(), this.ea = !0);
2707
2980
  }
2708
2981
  get grid() {
2709
- return this.hn;
2982
+ return this.Gr;
2710
2983
  }
2711
2984
  get font() {
2712
- return this.Li;
2985
+ return this.zi;
2713
2986
  }
2714
2987
  get width() {
2715
2988
  return this.er.width;
@@ -2721,37 +2994,38 @@ class de extends function(e, ...i) {
2721
2994
  return this.er.canvas;
2722
2995
  }
2723
2996
  get isDisposed() {
2724
- return this.Wo;
2997
+ return this.ea;
2725
2998
  }
2726
2999
  get overlay() {
2727
- return this.No;
3000
+ return this.oa;
2728
3001
  }
2729
3002
  }
2730
- class Z {
3003
+ class J {
2731
3004
  constructor() {
2732
3005
  }
2733
3006
  static create(t = {}) {
2734
- return new de(t);
3007
+ return new ye(t);
2735
3008
  }
2736
3009
  static setErrorLevel(t) {
2737
- $.C(t);
3010
+ O.C(t);
2738
3011
  }
2739
3012
  static get version() {
2740
- return "0.3.0";
3013
+ return "0.3.1";
2741
3014
  }
2742
3015
  }
2743
- const pe = Object.freeze(Object.defineProperty({ __proto__: null }, Symbol.toStringTag, { value: "Module" })), me = Z.create, ve = Z.setErrorLevel, xe = Z.version;
3016
+ const we = Object.freeze(Object.defineProperty({ __proto__: null }, Symbol.toStringTag, { value: "Module" })), Ee = Object.freeze(Object.defineProperty({ __proto__: null, keyboard: qt, mouse: Kt, touch: Zt }, Symbol.toStringTag, { value: "Module" })), Re = J.create, be = J.setErrorLevel, Te = J.version;
2744
3017
  export {
2745
- Ht as TextmodeCanvas,
2746
- ut as TextmodeErrorLevel,
2747
- zt as TextmodeFont,
2748
- j as TextmodeFramebuffer,
2749
- Wt as TextmodeGrid,
2750
- k as TextmodeImage,
2751
- de as Textmodifier,
2752
- me as create,
2753
- pe as export,
2754
- ve as setErrorLevel,
2755
- Z as textmode,
2756
- xe as version
3018
+ jt as TextmodeCanvas,
3019
+ gt as TextmodeErrorLevel,
3020
+ kt as TextmodeFont,
3021
+ K as TextmodeFramebuffer,
3022
+ Ht as TextmodeGrid,
3023
+ $ as TextmodeImage,
3024
+ ye as Textmodifier,
3025
+ Re as create,
3026
+ we as export,
3027
+ Ee as input,
3028
+ be as setErrorLevel,
3029
+ J as textmode,
3030
+ Te as version
2757
3031
  };