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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,12 +28,12 @@ ${"↓".repeat(24)}
28
28
  }
29
29
  }
30
30
  var ct = ((a) => (a[a.SILENT = 0] = "SILENT", a[a.WARNING = 1] = "WARNING", a[a.ERROR = 2] = "ERROR", a[a.THROW = 3] = "THROW", a))(ct || {});
31
- const B = class B {
31
+ const S = class S {
32
32
  constructor() {
33
33
  h(this, "u", { globalLevel: 3 });
34
34
  }
35
35
  static _() {
36
- return B.l || (B.l = new B()), B.l;
36
+ return S.l || (S.l = new S()), S.l;
37
37
  }
38
38
  m(t, e) {
39
39
  const i = "%c[textmode.js] Oops! (╯°□°)╯︵ Something went wrong in your code.", s = "color: #f44336; font-weight: bold; background: #ffebee; padding: 2px 6px; border-radius: 3px;";
@@ -55,13 +55,13 @@ const B = class B {
55
55
  this.u.globalLevel = t;
56
56
  }
57
57
  };
58
- h(B, "l", null);
59
- let $ = B;
60
- const z = $._(), et = /* @__PURE__ */ new WeakMap();
61
- function Y(a, t) {
58
+ h(S, "l", null);
59
+ let K = S;
60
+ const k = K._(), et = /* @__PURE__ */ new WeakMap();
61
+ function X(a, t) {
62
62
  et.set(a, t);
63
63
  }
64
- function k(a) {
64
+ function Y(a) {
65
65
  return et.get(a);
66
66
  }
67
67
  class it {
@@ -73,22 +73,22 @@ class it {
73
73
  h(this, "F", [0, 0, 0]);
74
74
  h(this, "S", [1, 1, 1, 1]);
75
75
  h(this, "A", [0, 0, 0, 1]);
76
- h(this, "P", !1);
77
76
  h(this, "k", !1);
77
+ h(this, "P", !1);
78
78
  h(this, "L", !1);
79
79
  h(this, "D", [0, 0]);
80
80
  h(this, "G", [0, 0, 0, 1]);
81
81
  h(this, "I", []);
82
82
  }
83
83
  O() {
84
- this.I.push({ W: this.$, H: this.U, K: this.M, X: this.R, D: [...this.D], N: this.P, Y: this.k, L: this.L, j: [...this.F], V: [...this.S], q: [...this.A] });
84
+ this.I.push({ W: this.$, H: this.U, K: this.M, X: this.R, D: [...this.D], N: this.k, j: this.P, L: this.L, Y: [...this.F], V: [...this.S], q: [...this.A] });
85
85
  }
86
86
  Z() {
87
87
  const t = this.I.pop();
88
- t ? (this.$ = t.W, this.U = t.H, this.M = t.K, this.R = t.X, this.D = t.D, this.P = t.N, this.k = t.Y, this.L = t.L, this.F = t.j, this.S = t.V, this.A = t.q) : console.warn("pop() called without matching push()");
88
+ t ? (this.$ = t.W, this.U = t.H, this.M = t.K, this.R = t.X, this.D = t.D, this.k = t.N, this.P = t.j, this.L = t.L, this.F = t.Y, this.S = t.V, this.A = t.q) : console.warn("pop() called without matching push()");
89
89
  }
90
90
  J(t) {
91
- t.W = this.$, t.H = this.U, t.K = this.M, t.X = this.R, t.j[0] = this.F[0], t.j[1] = this.F[1], t.j[2] = this.F[2], t.V[0] = this.S[0], t.V[1] = this.S[1], t.V[2] = this.S[2], t.V[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.P, t.Y = this.k, t.L = this.L, t.D[0] = this.D[0], t.D[1] = this.D[1];
91
+ t.W = this.$, t.H = this.U, t.K = this.M, t.X = this.R, t.Y[0] = this.F[0], t.Y[1] = this.F[1], t.Y[2] = this.F[2], t.V[0] = this.S[0], t.V[1] = this.S[1], t.V[2] = this.S[2], t.V[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.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.$;
@@ -118,10 +118,10 @@ class it {
118
118
  this.A = [t / 255, e / 255, i / 255, s / 255];
119
119
  }
120
120
  ht(t) {
121
- this.P = t;
121
+ this.k = t;
122
122
  }
123
123
  ct(t) {
124
- this.k = t;
124
+ this.P = t;
125
125
  }
126
126
  lt(t) {
127
127
  this.L = t;
@@ -202,11 +202,11 @@ class q {
202
202
  const t = this.gt;
203
203
  if (this.xt) {
204
204
  const n = ((i = (e = this.xt).At) == null ? void 0 : i.call(e)) ?? null;
205
- n && this.xt.zt(n), this.Mt && this.Rt && ((r = (s = this.xt).Et) == null || r.call(s, this.Rt));
205
+ n && this.xt.zt(n), this.Mt && this.Rt && ((r = (s = this.xt).kt) == null || r.call(s, this.Rt));
206
206
  }
207
207
  this.bt = { framebuffer: t.getParameter(t.FRAMEBUFFER_BINDING), viewport: t.getParameter(t.VIEWPORT) }, t.bindFramebuffer(t.FRAMEBUFFER, this.yt), this.$t = 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), Y(t, [0, 0, this.dt, this._t]);
209
+ t.viewport(0, 0, this.dt, this._t), X(t, [0, 0, this.dt, this._t]);
210
210
  }
211
211
  end() {
212
212
  var e, i, s, r;
@@ -216,9 +216,9 @@ class q {
216
216
  const n = ((i = (e = this.xt).At) == null ? void 0 : i.call(e)) ?? null;
217
217
  n && this.xt.zt(n);
218
218
  }
219
- t.bindFramebuffer(t.FRAMEBUFFER, this.bt.framebuffer), t.viewport(...this.bt.viewport), Y(t, this.bt.viewport), this.bt = null, this.xt && this.Mt && this.Rt && ((r = (s = this.xt).Pt) == null || r.call(s));
219
+ t.bindFramebuffer(t.FRAMEBUFFER, this.bt.framebuffer), t.viewport(...this.bt.viewport), X(t, this.bt.viewport), this.bt = null, this.xt && this.Mt && this.Rt && ((r = (s = this.xt).Et) == null || r.call(s));
220
220
  }
221
- kt() {
221
+ Pt() {
222
222
  const t = this.gt;
223
223
  t.deleteFramebuffer(this.yt);
224
224
  for (const e of this.Ct) t.deleteTexture(e);
@@ -233,7 +233,7 @@ class q {
233
233
  return [...this.Ct];
234
234
  }
235
235
  }
236
- class M {
236
+ class G {
237
237
  constructor(t, e, i) {
238
238
  h(this, "gt");
239
239
  h(this, "Lt");
@@ -280,10 +280,10 @@ class M {
280
280
  Xt(t) {
281
281
  for (const [e, i] of Object.entries(t)) this.Nt(e, i);
282
282
  }
283
- Yt(t) {
283
+ jt(t) {
284
284
  return this.Dt.has(t);
285
285
  }
286
- jt(t) {
286
+ Yt(t) {
287
287
  return this.Bt.get(t) || null;
288
288
  }
289
289
  Vt() {
@@ -358,11 +358,11 @@ class M {
358
358
  get Zt() {
359
359
  return this.Lt;
360
360
  }
361
- kt() {
361
+ Pt() {
362
362
  this.gt.deleteProgram(this.Lt);
363
363
  }
364
364
  }
365
- const W = `#version 300 es
365
+ const z = `#version 300 es
366
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);}`, st = "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
367
  class lt {
368
368
  constructor(t) {
@@ -371,9 +371,9 @@ class lt {
371
371
  h(this, "Qt");
372
372
  h(this, "ts");
373
373
  h(this, "ss");
374
- this.gt = t, this.Qt = new M(this.gt, W, `#version 300 es
375
- precision highp float;in vec2 v_uv;in vec3 v_character;in vec4 v_primaryColor;in vec4 v_secondaryColor;in vec2 v_rotation;in vec3 v_transform;layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;layout(location=3)out vec4 o_rotation;layout(location=4)out vec4 o_transform;void main(){o_character=vec4(v_character,1.);o_primaryColor=v_primaryColor;o_secondaryColor=v_secondaryColor;o_rotation=vec4(v_rotation,0.,1.);o_transform=vec4(v_transform,1.);}`), this.Jt = new M(this.gt, W, `#version 300 es
376
- precision highp float;in vec2 v_uv;uniform sampler2D Ue;uniform sampler2D Uf;uniform sampler2D Ug;uniform sampler2D Uh;uniform sampler2D Ui;uniform vec2 Uj;layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;layout(location=3)out vec4 o_rotation;layout(location=4)out vec4 o_transform;void main(){vec2 A=vec2(v_uv.x,1.-v_uv.y);vec2 B=A*Uj;vec2 C=(floor(B)+0.5f)/Uj;vec4 D=texture(Ue,C);vec4 E=texture(Uf,C);if(E.a==0.){discard;}vec4 F=texture(Ug,C);vec4 G=texture(Uh,C);vec4 H=texture(Ui,C);o_character=D;o_primaryColor=E;o_secondaryColor=F;o_rotation=G;o_transform=H;}`), this.ts = new M(this.gt, st, "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.ss = new M(this.gt, W, `#version 300 es
374
+ this.gt = t, this.Qt = new G(this.gt, z, `#version 300 es
375
+ precision highp float;in vec2 v_uv;in vec3 v_character;in vec4 v_primaryColor;in vec4 v_secondaryColor;in vec2 v_rotation;in vec3 v_transform;layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;layout(location=3)out vec4 o_rotation;layout(location=4)out vec4 o_transform;void main(){o_character=vec4(v_character,1.);o_primaryColor=v_primaryColor;o_secondaryColor=v_secondaryColor;o_rotation=vec4(v_rotation,0.,1.);o_transform=vec4(v_transform,1.);}`), this.Jt = new G(this.gt, z, `#version 300 es
376
+ precision highp float;in vec2 v_uv;uniform sampler2D Ue;uniform sampler2D Uf;uniform sampler2D Ug;uniform sampler2D Uh;uniform sampler2D Ui;uniform vec2 Uj;layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;layout(location=3)out vec4 o_rotation;layout(location=4)out vec4 o_transform;void main(){vec2 A=vec2(v_uv.x,1.-v_uv.y);vec2 B=A*Uj;vec2 C=(floor(B)+0.5f)/Uj;vec4 D=texture(Ue,C);vec4 E=texture(Uf,C);if(E.a==0.){discard;}vec4 F=texture(Ug,C);vec4 G=texture(Uh,C);vec4 H=texture(Ui,C);o_character=D;o_primaryColor=E;o_secondaryColor=F;o_rotation=G;o_transform=H;}`), this.ts = new G(this.gt, st, "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.ss = new G(this.gt, z, `#version 300 es
377
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
  es() {
@@ -389,16 +389,16 @@ precision highp float;in vec2 v_uv;uniform sampler2D Uk;uniform bool Ul;uniform
389
389
  return this.ss;
390
390
  }
391
391
  hs(t) {
392
- return new M(this.gt, W, t);
392
+ return new G(this.gt, z, t);
393
393
  }
394
394
  cs(t, e) {
395
- return new M(this.gt, t, e);
395
+ return new G(this.gt, t, e);
396
396
  }
397
- kt() {
398
- this.Jt.kt(), this.Qt.kt(), this.ts.kt(), this.ss.kt();
397
+ Pt() {
398
+ this.Jt.Pt(), this.Qt.Pt(), this.ts.Pt(), this.ss.Pt();
399
399
  }
400
400
  }
401
- var x = ((a) => (a.RECTANGLE = "rectangle", a.LINE = "line", a.ELLIPSE = "ellipse", a.ARC = "arc", a.TRIANGLE = "triangle", a.BEZIER_CURVE = "bezier_curve", a.CUSTOM = "custom", a))(x || {});
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
402
  class ut {
403
403
  constructor(t) {
404
404
  h(this, "gt");
@@ -422,7 +422,7 @@ class ut {
422
422
  vs() {
423
423
  this.gt.bindVertexArray(null);
424
424
  }
425
- kt() {
425
+ Pt() {
426
426
  for (const [, t] of this.ls) for (const [, e] of t) e && this.gt.deleteVertexArray(e);
427
427
  }
428
428
  }
@@ -436,7 +436,7 @@ class ft {
436
436
  this.gt = t, this.gs = new ut(t), this.xt = e;
437
437
  }
438
438
  bs(t, e, i) {
439
- const { shader: s } = t, r = k(this.gt) || this.gt.getParameter(this.gt.VIEWPORT);
439
+ const { shader: s } = t, r = Y(this.gt) || this.gt.getParameter(this.gt.VIEWPORT);
440
440
  s.Xt({ U9: r[2] / r[3], Uy: [r[2], r[3]] });
441
441
  const n = (l) => {
442
442
  if (!l || !l.$s()) return;
@@ -449,26 +449,26 @@ class ft {
449
449
  };
450
450
  let o = null, c = null;
451
451
  for (const l of e) {
452
- if (l.type === x.CUSTOM) {
453
- c && (n(c), o = null, c = null), this.zs(t, l.params, l.state, i.get(x.RECTANGLE));
452
+ if (l.type === E.CUSTOM) {
453
+ c && (n(c), o = null, c = null), this.zs(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 f = c;
458
- f && l.type === o || (f = i.get(l.type) || null, c = f, o = l.type), f && f.Es(l.params, l.state);
458
+ f && l.type === o || (f = i.get(l.type) || null, c = f, o = l.type), f && f.ks(l.params, l.state);
459
459
  }
460
460
  n(c);
461
461
  }
462
462
  zs(t, e, i, s) {
463
- const { x: r, y: n, width: o, height: c, shader: l, uniforms: f } = e, u = this.Ps(Math.max(1, Math.floor(o)), Math.max(1, Math.floor(c)));
464
- u.begin(), this.ks(s, l, f, 0, 0, u.width, u.height, {}), u.end();
463
+ const { x: r, y: n, width: o, height: c, shader: l, uniforms: f } = e, u = this.Es(Math.max(1, Math.floor(o)), Math.max(1, Math.floor(c)));
464
+ u.begin(), this.Ps(s, l, f, 0, 0, u.width, u.height, {}), u.end();
465
465
  const m = this.Ls(), v = { Ue: u.textures[0], Uf: u.textures[1], Ug: u.textures[2], Uh: u.textures[3], Ui: u.textures[4], Uj: [u.width, u.height] };
466
- this.ks(s, m, v, Math.floor(r), Math.floor(n), Math.max(1, Math.floor(o)), Math.max(1, Math.floor(c)), i), t.shader.Ht();
466
+ this.Ps(s, m, v, Math.floor(r), Math.floor(n), Math.max(1, Math.floor(o)), Math.max(1, Math.floor(c)), i), t.shader.Ht();
467
467
  }
468
- ks(t, e, i, s, r, n, o, c) {
468
+ Ps(t, e, i, s, r, n, o, c) {
469
469
  e.Ht(), e.Xt(i);
470
470
  const l = this.gt.getParameter(this.gt.VIEWPORT);
471
- if (e.Xt({ U9: l[2] / l[3], Uy: [l[2], l[3]] }), t.As(), t.Es({ x: s, y: r, width: n, height: o }, c), t.$s()) {
471
+ if (e.Xt({ U9: l[2] / l[3], Uy: [l[2], l[3]] }), t.As(), t.ks({ x: s, y: r, width: n, height: o }, c), t.$s()) {
472
472
  const f = t.unitGeometry, u = t.unitBuffer;
473
473
  try {
474
474
  this.gs.us(e.Zt, t.type + "", f, u), t.batch.Ms(e), t.batch.Rs(f.Fs, f.Ss);
@@ -480,11 +480,11 @@ class ft {
480
480
  Ls() {
481
481
  return this.xt.es();
482
482
  }
483
- Ps(t, e) {
484
- return this.Cs && this.ws && this.ws.w === t && this.ws.h === e || (this.Cs && this.Cs.kt(), this.Cs = new q(this.gt, t, e, 5), this.ws = { w: t, h: e }), this.Cs;
483
+ Es(t, e) {
484
+ return this.Cs && this.ws && this.ws.w === t && this.ws.h === e || (this.Cs && this.Cs.Pt(), this.Cs = new q(this.gt, t, e, 5), this.ws = { w: t, h: e }), this.Cs;
485
485
  }
486
- kt() {
487
- this.gs.kt(), this.Cs && this.Cs.kt();
486
+ Pt() {
487
+ this.gs.Pt(), this.Cs && this.Cs.Pt();
488
488
  }
489
489
  }
490
490
  class dt {
@@ -495,38 +495,38 @@ class dt {
495
495
  }
496
496
  Is(t) {
497
497
  if (this.Gs >= this.Ds.length) {
498
- const i = { id: this.Bs++, type: t, params: {}, state: { W: 1, H: 0, K: 0, X: 0, j: [0, 0, 0], V: [1, 1, 1, 1], q: [0, 0, 0, 1], N: !1, Y: !1, L: !1, D: [0, 0] } };
498
+ const i = { id: this.Bs++, type: t, params: {}, state: { W: 1, H: 0, K: 0, X: 0, Y: [0, 0, 0], V: [1, 1, 1, 1], q: [0, 0, 0, 1], N: !1, j: !1, L: !1, D: [0, 0] } };
499
499
  this.Ds.push(i);
500
500
  }
501
501
  const e = this.Ds[this.Gs];
502
502
  return e.id = this.Bs++, e.type = t, this.Gs++, e;
503
503
  }
504
504
  Os(t, e, i, s, r) {
505
- const n = this.Is(x.RECTANGLE);
505
+ const n = this.Is(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
508
  Ws(t, e, i, s, r, n, o) {
509
- const c = this.Is(x.CUSTOM);
509
+ const c = this.Is(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
512
  Hs(t, e, i, s, r, n) {
513
- const o = this.Is(x.LINE);
513
+ const o = this.Is(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
516
  Ks(t, e, i, s, r) {
517
- const n = this.Is(x.ELLIPSE);
517
+ const n = this.Is(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
  Xs(t, e, i, s, r, n, o) {
521
- const c = this.Is(x.ARC);
521
+ const c = this.Is(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
524
  Ns(t, e, i, s, r, n, o) {
525
- const c = this.Is(x.TRIANGLE);
525
+ const c = this.Is(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
- Ys(t, e, i, s, r, n, o, c, l, f) {
529
- const u = this.Is(x.BEZIER_CURVE);
528
+ js(t, e, i, s, r, n, o, c, l, f) {
529
+ const u = this.Is(E.BEZIER_CURVE);
530
530
  return u.params.x1 = t, u.params.y1 = e, u.params.cp1x = i, u.params.cp1y = s, u.params.cp2x = r, u.params.cp2y = n, u.params.x2 = o, u.params.y2 = c, u.params.thickness = l, f.J(u.state), u.id;
531
531
  }
532
532
  get length() {
@@ -535,7 +535,7 @@ class dt {
535
535
  get isEmpty() {
536
536
  return this.Gs === 0;
537
537
  }
538
- js() {
538
+ Ys() {
539
539
  this.Gs = 0;
540
540
  }
541
541
  [Symbol.iterator]() {
@@ -544,28 +544,28 @@ class dt {
544
544
  return { next: () => t < e ? { value: i[t++], done: !1 } : { value: void 0, done: !0 } };
545
545
  }
546
546
  }
547
- const F = class F {
547
+ const L = class L {
548
548
  static Vs(t, e, i = 0) {
549
549
  var n, o, c, l, f, u, m, v, g, d;
550
- const s = e || new Float32Array(F.FLOATS_PER_INSTANCE);
550
+ const s = e || new Float32Array(L.FLOATS_PER_INSTANCE);
551
551
  let r = i;
552
- return s[r++] = t.fs[0], s[r++] = t.fs[1], s[r++] = t.Gs[0], s[r++] = t.Gs[1], s[r++] = t.j[0], s[r++] = t.j[1], s[r++] = t.j[2], s[r++] = t.V[0], s[r++] = t.V[1], s[r++] = t.V[2], s[r++] = t.V[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.qs[0], s[r++] = t.qs[1], s[r++] = t.qs[2], s[r++] = t.H, s[r++] = t.K, s[r++] = t.X, s[r++] = t.Zs[0], s[r++] = t.Zs[1], s[r++] = ((n = t.Js) == null ? void 0 : n[0]) || 0, s[r++] = ((o = t.Js) == null ? void 0 : o[1]) || 0, s[r++] = ((c = t.Qs) == null ? void 0 : c[0]) || 0, s[r++] = ((l = t.Qs) == null ? void 0 : l[1]) || 0, s[r++] = ((f = t.te) == null ? void 0 : f[0]) || 0, s[r++] = ((u = t.te) == null ? void 0 : u[1]) || 0, s[r++] = ((m = t.se) == null ? void 0 : m[0]) || 0, s[r++] = ((v = t.se) == null ? void 0 : v[1]) || 0, s[r++] = ((g = t.ee) == null ? void 0 : g[0]) || 0, s[r++] = ((d = t.ee) == null ? void 0 : d[1]) || 0, s;
552
+ return s[r++] = t.fs[0], s[r++] = t.fs[1], s[r++] = t.Gs[0], s[r++] = t.Gs[1], s[r++] = t.Y[0], s[r++] = t.Y[1], s[r++] = t.Y[2], s[r++] = t.V[0], s[r++] = t.V[1], s[r++] = t.V[2], s[r++] = t.V[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.qs[0], s[r++] = t.qs[1], s[r++] = t.qs[2], s[r++] = t.H, s[r++] = t.K, s[r++] = t.X, s[r++] = t.Zs[0], s[r++] = t.Zs[1], s[r++] = ((n = t.Js) == null ? void 0 : n[0]) || 0, s[r++] = ((o = t.Js) == null ? void 0 : o[1]) || 0, s[r++] = ((c = t.Qs) == null ? void 0 : c[0]) || 0, s[r++] = ((l = t.Qs) == null ? void 0 : l[1]) || 0, s[r++] = ((f = t.te) == null ? void 0 : f[0]) || 0, s[r++] = ((u = t.te) == null ? void 0 : u[1]) || 0, s[r++] = ((m = t.se) == null ? void 0 : m[0]) || 0, s[r++] = ((v = t.se) == null ? void 0 : v[1]) || 0, s[r++] = ((g = t.ee) == null ? void 0 : g[0]) || 0, s[r++] = ((d = t.ee) == null ? void 0 : d[1]) || 0, s;
553
553
  }
554
554
  static ie(t) {
555
- const e = t.length * F.FLOATS_PER_INSTANCE, i = new Float32Array(e);
555
+ const e = t.length * L.FLOATS_PER_INSTANCE, i = new Float32Array(e);
556
556
  for (let s = 0; s < t.length; s++) {
557
- const r = s * F.FLOATS_PER_INSTANCE;
558
- F.Vs(t[s], i, r);
557
+ const r = s * L.FLOATS_PER_INSTANCE;
558
+ L.Vs(t[s], i, r);
559
559
  }
560
560
  return i;
561
561
  }
562
562
  };
563
- h(F, "BYTES_PER_INSTANCE", 140), h(F, "FLOATS_PER_INSTANCE", 35);
564
- let S = F;
563
+ h(L, "BYTES_PER_INSTANCE", 140), h(L, "FLOATS_PER_INSTANCE", 35);
564
+ let M = L;
565
565
  const b = class b {
566
566
  };
567
- h(b, "STRIDE", S.BYTES_PER_INSTANCE), h(b, "ATTRIBUTES", { a_instancePosition: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 0, divisor: 1 }, a_instanceSize: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 8, divisor: 1 }, a_instanceCharacter: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 16, divisor: 1 }, a_instancePrimaryColor: { location: -1, size: 4, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 28, divisor: 1 }, a_instanceSecondaryColor: { location: -1, size: 4, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 44, divisor: 1 }, a_instanceRotation: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 60, divisor: 1 }, a_instanceTransform: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 68, divisor: 1 }, a_instanceGlobalRotation: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 80, divisor: 1 }, a_instanceRotationCenter: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 92, divisor: 1 }, a_instanceArcAngles: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 100, divisor: 1 }, a_instanceBezierCP1: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 108, divisor: 1 }, a_instanceBezierCP2: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 116, divisor: 1 }, a_instanceBezierStart: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 124, divisor: 1 }, a_instanceBezierEnd: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 132, divisor: 1 } });
568
- let j = b;
567
+ h(b, "STRIDE", M.BYTES_PER_INSTANCE), h(b, "ATTRIBUTES", { a_instancePosition: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 0, divisor: 1 }, a_instanceSize: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 8, divisor: 1 }, a_instanceCharacter: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 16, divisor: 1 }, a_instancePrimaryColor: { location: -1, size: 4, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 28, divisor: 1 }, a_instanceSecondaryColor: { location: -1, size: 4, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 44, divisor: 1 }, a_instanceRotation: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 60, divisor: 1 }, a_instanceTransform: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 68, divisor: 1 }, a_instanceGlobalRotation: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 80, divisor: 1 }, a_instanceRotationCenter: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 92, divisor: 1 }, a_instanceArcAngles: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 100, divisor: 1 }, a_instanceBezierCP1: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 108, divisor: 1 }, a_instanceBezierCP2: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 116, divisor: 1 }, a_instanceBezierStart: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 124, divisor: 1 }, a_instanceBezierEnd: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 132, divisor: 1 } });
568
+ let H = b;
569
569
  class gt {
570
570
  constructor(t, e = 1e3, i = 1.5) {
571
571
  h(this, "gt");
@@ -579,7 +579,7 @@ class gt {
579
579
  h(this, "ue", null);
580
580
  this.gt = t, this.ne = e, this.oe = i, this.fe();
581
581
  }
582
- Es(t) {
582
+ ks(t) {
583
583
  const e = this.re.length;
584
584
  return this.re.push(t), this.ae = !0, e;
585
585
  }
@@ -600,14 +600,14 @@ class gt {
600
600
  fe() {
601
601
  const t = this.gt;
602
602
  this.he && t.deleteBuffer(this.he), this.he = t.createBuffer();
603
- const e = this.ne * S.BYTES_PER_INSTANCE;
603
+ const e = this.ne * M.BYTES_PER_INSTANCE;
604
604
  t.bindBuffer(t.ARRAY_BUFFER, this.he), t.bufferData(t.ARRAY_BUFFER, e, t.DYNAMIC_DRAW), t.bindBuffer(t.ARRAY_BUFFER, null), this.ae = !0, this.ce = 0;
605
605
  }
606
606
  _e() {
607
607
  if (!this.ae || this.re.length === 0) return;
608
608
  const t = this.gt, e = this.re.length;
609
- this.de(e), (!this.ue || this.ue.length < e * S.FLOATS_PER_INSTANCE) && (this.ue = new Float32Array(e * S.FLOATS_PER_INSTANCE));
610
- const i = S.ie(this.re);
609
+ this.de(e), (!this.ue || this.ue.length < e * M.FLOATS_PER_INSTANCE) && (this.ue = new Float32Array(e * M.FLOATS_PER_INSTANCE));
610
+ const i = M.ie(this.re);
611
611
  t.bindBuffer(t.ARRAY_BUFFER, this.he), e <= this.ce ? t.bufferSubData(t.ARRAY_BUFFER, 0, i) : t.bufferData(t.ARRAY_BUFFER, i, t.DYNAMIC_DRAW), t.bindBuffer(t.ARRAY_BUFFER, null), this.ae = !1, this.ce = e;
612
612
  }
613
613
  pe(t) {
@@ -615,7 +615,7 @@ class gt {
615
615
  if (!e) {
616
616
  e = /* @__PURE__ */ new Map();
617
617
  const i = this.gt;
618
- for (const s in j.ATTRIBUTES) {
618
+ for (const s in H.ATTRIBUTES) {
619
619
  const r = i.getAttribLocation(t, s);
620
620
  r !== -1 && e.set(s, r);
621
621
  }
@@ -630,7 +630,7 @@ class gt {
630
630
  const s = this.pe(i);
631
631
  e.bindBuffer(e.ARRAY_BUFFER, this.he);
632
632
  for (const [r, n] of s) {
633
- const o = j.ATTRIBUTES[r];
633
+ const o = H.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,11 +641,11 @@ class gt {
641
641
  Rs(t, e) {
642
642
  this.re.length !== 0 && this.gt.drawArraysInstanced(t, 0, e, this.re.length);
643
643
  }
644
- kt() {
644
+ Pt() {
645
645
  this.he && this.gt.deleteBuffer(this.he);
646
646
  }
647
647
  }
648
- class I {
648
+ class D {
649
649
  constructor(t, e, i, s) {
650
650
  h(this, "gt");
651
651
  h(this, "me");
@@ -675,15 +675,15 @@ class I {
675
675
  $s() {
676
676
  return !this.me.isEmpty;
677
677
  }
678
- kt() {
679
- this.me.kt(), this.gt.deleteBuffer(this.ye);
678
+ Pt() {
679
+ this.me.Pt(), this.gt.deleteBuffer(this.ye);
680
680
  }
681
681
  we(t, e, i, s, r) {
682
682
  const n = this.be(t, e, i, s, r.H || 0, r.K || 0, r.X || 0);
683
- return { fs: [t, e], Gs: [i, s], j: r.j || [0, 0, 0], V: r.V || [1, 1, 1, 1], q: r.q || [0, 0, 0, 1], D: r.D || [0, 0], qs: [r.L ? 1 : 0, r.N ? 1 : 0, r.Y ? 1 : 0], H: n.radiansX, K: n.radiansY, X: n.radiansZ, Zs: [n.centerX, n.centerY] };
683
+ return { fs: [t, e], Gs: [i, s], Y: r.Y || [0, 0, 0], V: r.V || [1, 1, 1, 1], q: r.q || [0, 0, 0, 1], D: r.D || [0, 0], qs: [r.L ? 1 : 0, r.N ? 1 : 0, r.j ? 1 : 0], H: n.radiansX, K: n.radiansY, X: n.radiansZ, Zs: [n.centerX, n.centerY] };
684
684
  }
685
685
  $e(t, e) {
686
- const i = k(this.gt) || [0, 0, this.gt.canvas.width, this.gt.canvas.height];
686
+ const i = Y(this.gt) || [0, 0, this.gt.canvas.width, this.gt.canvas.height];
687
687
  return { nx: t / i[2] * 2 - 1, ny: 1 - e / i[3] * 2 };
688
688
  }
689
689
  xe(t, e, i) {
@@ -691,31 +691,31 @@ class I {
691
691
  t.Zs = [s.nx, s.ny];
692
692
  }
693
693
  be(t, e, i, s, r, n, o) {
694
- const c = k(this.gt) || [0, 0, this.gt.canvas.width, this.gt.canvas.height], l = c[2], f = c[3];
694
+ const c = Y(this.gt) || [0, 0, this.gt.canvas.width, this.gt.canvas.height], l = c[2], f = c[3];
695
695
  return { centerX: (t + i / 2) / l * 2 - 1, centerY: 1 - (e + s / 2) / f * 2, radiansX: -r * Math.PI / 180, radiansY: -n * Math.PI / 180, radiansZ: -o * Math.PI / 180, aspectRatio: l / f };
696
696
  }
697
697
  }
698
698
  const mt = { Ce: 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]), Ss: 6, Fs: WebGL2RenderingContext.TRIANGLES, _s: 16, ds: { fs: { size: 2, offset: 0 }, ps: { size: 2, offset: 8 } } };
699
- class pt extends I {
699
+ class pt extends D {
700
700
  constructor(t, e) {
701
- super(t, e, x.RECTANGLE, mt);
701
+ super(t, e, E.RECTANGLE, mt);
702
702
  }
703
- Es(t, e) {
703
+ ks(t, e) {
704
704
  const i = this.we(t.x, t.y, t.width, t.height, e);
705
- return this.me.Es(i);
705
+ return this.me.ks(i);
706
706
  }
707
707
  }
708
708
  const vt = { Ce: 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]), Ss: 6, Fs: WebGL2RenderingContext.TRIANGLES, _s: 16, ds: { fs: { size: 2, offset: 0 }, ps: { size: 2, offset: 8 } } };
709
- class Et extends I {
709
+ class yt extends D {
710
710
  constructor(t, e) {
711
- super(t, e, x.LINE, vt);
711
+ super(t, e, E.LINE, vt);
712
712
  }
713
- Es(t, e) {
713
+ ks(t, e) {
714
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, f = c, u = this.we(l, f, r, n, e);
715
- return this.xe(u, o, c), this.me.Es(u);
715
+ return this.xe(u, o, c), this.me.ks(u);
716
716
  }
717
717
  }
718
- const yt = { Ce: function(a = 32) {
718
+ const xt = { Ce: function(a = 32) {
719
719
  const t = [], e = 2 * Math.PI / a;
720
720
  for (let i = 0; i < a; i++) {
721
721
  const s = i * e, r = (i + 1) % a * e, n = Math.cos(s), o = Math.sin(s), c = 0.5 * (n + 1), l = 0.5 * (o + 1), f = Math.cos(r), u = Math.sin(r), m = 0.5 * (f + 1), v = 0.5 * (u + 1);
@@ -723,13 +723,13 @@ const yt = { Ce: function(a = 32) {
723
723
  }
724
724
  return new Float32Array(t);
725
725
  }(32), Ss: 96, Fs: WebGL2RenderingContext.TRIANGLES, _s: 16, ds: { fs: { size: 2, offset: 0 }, ps: { size: 2, offset: 8 } } };
726
- class xt extends I {
726
+ class Et extends D {
727
727
  constructor(t, e) {
728
- super(t, e, x.ELLIPSE, yt);
728
+ super(t, e, E.ELLIPSE, xt);
729
729
  }
730
- Es(t, e) {
730
+ ks(t, e) {
731
731
  const i = this.we(t.x, t.y, t.width, t.height, e);
732
- return this.xe(i, t.x, t.y), this.me.Es(i);
732
+ return this.xe(i, t.x, t.y), this.me.ks(i);
733
733
  }
734
734
  }
735
735
  let wt = { Ce: function(a) {
@@ -740,23 +740,23 @@ let wt = { Ce: function(a) {
740
740
  }
741
741
  return new Float32Array(t);
742
742
  }(32), Ss: 96, Fs: WebGL2RenderingContext.TRIANGLES, _s: 16, ds: { fs: { size: 2, offset: 0 }, ps: { size: 2, offset: 8 } } };
743
- class At extends I {
743
+ class Rt extends D {
744
744
  constructor(t, e) {
745
- super(t, e, x.ARC, wt);
745
+ super(t, e, E.ARC, wt);
746
746
  }
747
- Es(t, e) {
747
+ ks(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.we(i, s, t.width, t.height, e);
749
- return this.xe(o, t.x, t.y), o.Js = [r, n], this.me.Es(o);
749
+ return this.xe(o, t.x, t.y), o.Js = [r, n], this.me.ks(o);
750
750
  }
751
751
  }
752
- const Rt = { Ce: new Float32Array([0, 0, 0, 0, 1, 0, 1, 0, 0.5, 1, 0.5, 1]), Ss: 3, Fs: WebGL2RenderingContext.TRIANGLES, _s: 16, ds: { fs: { size: 2, offset: 0 }, ps: { size: 2, offset: 8 } } };
753
- class Tt extends I {
752
+ const At = { Ce: new Float32Array([0, 0, 0, 0, 1, 0, 1, 0, 0.5, 1, 0.5, 1]), Ss: 3, Fs: WebGL2RenderingContext.TRIANGLES, _s: 16, ds: { fs: { size: 2, offset: 0 }, ps: { size: 2, offset: 8 } } };
753
+ class Tt extends D {
754
754
  constructor(t, e) {
755
- super(t, e, x.TRIANGLE, Rt);
755
+ super(t, e, E.TRIANGLE, At);
756
756
  }
757
- Es(t, e) {
757
+ ks(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.we(i, r, n, o, e), l = i + 0.5 * n, f = r + o * (1 / 3);
759
- return this.xe(c, l, f), this.me.Es(c);
759
+ return this.xe(c, l, f), this.me.ks(c);
760
760
  }
761
761
  }
762
762
  function Q(a, t, e, i, s) {
@@ -771,13 +771,13 @@ const bt = { Ce: function(a = 16) {
771
771
  }
772
772
  return new Float32Array(t);
773
773
  }(16), Ss: 96, Fs: WebGL2RenderingContext.TRIANGLES, _s: 16, ds: { fs: { size: 2, offset: 0 }, ps: { size: 2, offset: 8 } } };
774
- class Ct extends I {
774
+ class Ct extends D {
775
775
  constructor(t, e) {
776
- super(t, e, x.BEZIER_CURVE, bt);
776
+ super(t, e, E.BEZIER_CURVE, bt);
777
777
  }
778
- Es(t, e) {
778
+ ks(t, e) {
779
779
  const i = e.W || 1, s = Q(0.5, t.x1, t.cp1x, t.cp2x, t.x2), r = Q(0.5, t.y1, t.cp1y, t.cp2y, t.y2), n = this.we(0, 0, 1, i, e);
780
- return this.xe(n, s, r), n.se = [t.x1, t.y1], n.Qs = [t.cp1x, t.cp1y], n.te = [t.cp2x, t.cp2y], n.ee = [t.x2, t.y2], this.me.Es(n);
780
+ return this.xe(n, s, r), n.se = [t.x1, t.y1], n.Qs = [t.cp1x, t.cp1y], n.te = [t.cp2x, t.cp2y], n.ee = [t.x2, t.y2], this.me.ks(n);
781
781
  }
782
782
  }
783
783
  class _t {
@@ -790,16 +790,16 @@ class _t {
790
790
  h(this, "Te", null);
791
791
  h(this, "Ae", /* @__PURE__ */ new Map());
792
792
  h(this, "ze");
793
+ h(this, "ke");
793
794
  h(this, "Ee");
794
- h(this, "Pe");
795
795
  h(this, "I", []);
796
- this.gt = t, this.Re = new lt(t), this.Pe = new it(), this.ze = new ft(t, this), this.Ee = new dt(), this.Te = t.createBuffer(), Y(this.gt, [0, 0, this.gt.canvas.width, this.gt.canvas.height]);
796
+ this.gt = t, this.Re = new lt(t), this.Ee = new it(), this.ze = new ft(t, this), this.ke = new dt(), this.Te = t.createBuffer(), X(this.gt, [0, 0, this.gt.canvas.width, this.gt.canvas.height]);
797
797
  }
798
- ke(t) {
798
+ Pe(t) {
799
799
  let e = this.Ae.get(t);
800
800
  if (e) return e;
801
801
  const i = new gt(this.gt);
802
- return e = (0, { [x.RECTANGLE]: () => new pt(this.gt, i), [x.LINE]: () => new Et(this.gt, i), [x.ELLIPSE]: () => new xt(this.gt, i), [x.ARC]: () => new At(this.gt, i), [x.TRIANGLE]: () => new Tt(this.gt, i), [x.BEZIER_CURVE]: () => new Ct(this.gt, i) }[t])(), this.Ae.set(t, e), e;
802
+ return e = (0, { [E.RECTANGLE]: () => new pt(this.gt, i), [E.LINE]: () => new yt(this.gt, i), [E.ELLIPSE]: () => new Et(this.gt, i), [E.ARC]: () => new Rt(this.gt, i), [E.TRIANGLE]: () => new Tt(this.gt, i), [E.BEZIER_CURVE]: () => new Ct(this.gt, i) }[t])(), this.Ae.set(t, e), e;
803
803
  }
804
804
  Le(t) {
805
805
  this.Me !== t && (this.Me = t, t.Ht());
@@ -833,11 +833,11 @@ class _t {
833
833
  }
834
834
  Ge(t, e, i, s, r) {
835
835
  const n = this.es(), 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.Ee.Ws(e, i, s, r, n, o, this.Pe);
836
+ this.ke.Ws(e, i, s, r, n, o, this.Ee);
837
837
  }
838
838
  Ie(t, e, i, s, r) {
839
839
  const n = this.ns(), o = t.Oe(), 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.Ee.Ws(e, i, s, r, n, c, this.Pe);
840
+ this.ke.Ws(e, i, s, r, n, c, this.Ee);
841
841
  }
842
842
  We(t, e, i, s) {
843
843
  var d;
@@ -847,70 +847,70 @@ class _t {
847
847
  g !== -1 && (r.enableVertexAttribArray(g), r.vertexAttribPointer(g, 2, r.FLOAT, !1, 8, 0)), r.drawArrays(r.TRIANGLES, 0, 6), g !== -1 && r.disableVertexAttribArray(g);
848
848
  }
849
849
  He(t, e, i, s) {
850
- this.Fe ? (this.Ee.Ws(t, e, i, s, this.Fe, { ...this.Se }, this.Pe), this.Fe = null, this.Se = {}) : this.Ee.Os(t, e, i, s, this.Pe);
850
+ this.Fe ? (this.ke.Ws(t, e, i, s, this.Fe, { ...this.Se }, this.Ee), this.Fe = null, this.Se = {}) : this.ke.Os(t, e, i, s, this.Ee);
851
851
  }
852
852
  Ke(t, e, i, s) {
853
- this.Ee.Hs(t, e, i, s, this.Pe.lineWeight, this.Pe);
853
+ this.ke.Hs(t, e, i, s, this.Ee.lineWeight, this.Ee);
854
854
  }
855
855
  Xe(t, e, i, s) {
856
- this.Ee.Ks(t, e, i, s, this.Pe);
856
+ this.ke.Ks(t, e, i, s, this.Ee);
857
857
  }
858
858
  Ne(t, e, i, s, r, n) {
859
- this.Ee.Ns(t, e, i, s, r, n, this.Pe);
859
+ this.ke.Ns(t, e, i, s, r, n, this.Ee);
860
860
  }
861
- Ye(t, e, i, s, r, n, o, c) {
862
- const l = this.Pe.lineWeight;
863
- this.Ee.Ys(t, e, i, s, r, n, o, c, l, this.Pe);
861
+ je(t, e, i, s, r, n, o, c) {
862
+ const l = this.Ee.lineWeight;
863
+ this.ke.js(t, e, i, s, r, n, o, c, l, this.Ee);
864
864
  }
865
- je(t, e, i = 1, s = {}) {
865
+ Ye(t, e, i = 1, s = {}) {
866
866
  return new q(this.gt, t, e, i, s, this, !0);
867
867
  }
868
868
  Ve(t, e, i, s, r, n) {
869
- this.Ee.Xs(t, e, i, s, r, n, this.Pe);
869
+ this.ke.Xs(t, e, i, s, r, n, this.Ee);
870
870
  }
871
871
  qe(t, e = t, i = t, s = 255) {
872
- this.Pe.ft(t, e, i, s), this.js(t / 255, e / 255, i / 255, s / 255);
872
+ this.Ee.ft(t, e, i, s), this.Ys(t / 255, e / 255, i / 255, s / 255);
873
873
  }
874
- js(t = 0, e = 0, i = 0, s = 0) {
874
+ Ys(t = 0, e = 0, i = 0, s = 0) {
875
875
  this.gt.clearColor(t, e, i, s), this.gt.clear(this.gt.COLOR_BUFFER_BIT);
876
876
  }
877
877
  Ze() {
878
- this.gt.viewport(0, 0, this.gt.canvas.width, this.gt.canvas.height), Y(this.gt, [0, 0, this.gt.canvas.width, this.gt.canvas.height]);
878
+ this.gt.viewport(0, 0, this.gt.canvas.width, this.gt.canvas.height), X(this.gt, [0, 0, this.gt.canvas.width, this.gt.canvas.height]);
879
879
  }
880
880
  get context() {
881
881
  return this.gt;
882
882
  }
883
883
  get state() {
884
- return this.Pe;
884
+ return this.Ee;
885
885
  }
886
- Et(t) {
887
- this.I.push(this.Pe), this.Pe = t;
886
+ kt(t) {
887
+ this.I.push(this.Ee), this.Ee = t;
888
888
  }
889
- Pt() {
889
+ Et() {
890
890
  const t = this.I.pop();
891
- t && (this.Pe = t);
891
+ t && (this.Ee = t);
892
892
  }
893
893
  zt(t) {
894
- const e = t, i = k(this.gt) ?? this.gt.getParameter(this.gt.VIEWPORT), s = { shader: e, gl: this.gt, viewport: i };
894
+ const e = t, i = Y(this.gt) ?? this.gt.getParameter(this.gt.VIEWPORT), s = { shader: e, gl: this.gt, viewport: i };
895
895
  this.Le(e);
896
896
  const r = /* @__PURE__ */ new Set();
897
- for (const n of this.Ee) n.type === x.CUSTOM ? r.add(x.RECTANGLE) : r.add(n.type);
898
- for (const n of r) n !== x.CUSTOM && this.ke(n);
899
- this.ze.bs(s, this.Ee, this.Ae), this.Ee.js();
897
+ for (const n of this.ke) n.type === E.CUSTOM ? r.add(E.RECTANGLE) : r.add(n.type);
898
+ for (const n of r) n !== E.CUSTOM && this.Pe(n);
899
+ this.ze.bs(s, this.ke, this.Ae), this.ke.Ys();
900
900
  }
901
- kt() {
902
- this.gt.deleteBuffer(this.Te), this.Ee.js();
903
- for (const t of this.Ae.values()) t.kt();
904
- this.Re.kt(), this.ze.kt();
901
+ Pt() {
902
+ this.gt.deleteBuffer(this.Te), this.ke.Ys();
903
+ for (const t of this.Ae.values()) t.Pt();
904
+ this.Re.Pt(), this.ze.Pt();
905
905
  }
906
906
  }
907
- const A = { readShort: (a, t) => (A.t.uint16[0] = a[t] << 8 | a[t + 1], A.t.int16[0]), readUshort: (a, t) => a[t] << 8 | a[t + 1], readUshorts(a, 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(A.readUshort(a, t + 2 * s));
909
+ for (let s = 0; s < e; s++) i.push(R.readUshort(a, t + 2 * s));
910
910
  return i;
911
911
  }, readUint(a, t) {
912
- const e = A.t.uint8;
913
- return e[3] = a[t], e[2] = a[t + 1], e[1] = a[t + 2], e[0] = a[t + 3], A.t.uint32[0];
912
+ const e = R.t.uint8;
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
914
  }, readASCII(a, t, e) {
915
915
  let i = "";
916
916
  for (let s = 0; s < e; s++) i += String.fromCharCode(a[t + s]);
@@ -925,13 +925,13 @@ const A = { readShort: (a, t) => (A.t.uint16[0] = a[t] << 8 | a[t + 1], A.t.int1
925
925
  const a = new ArrayBuffer(8);
926
926
  return { uint8: new Uint8Array(a), int16: new Int16Array(a), uint16: new Uint16Array(a), uint32: new Uint32Array(a) };
927
927
  })() };
928
- function X(a) {
928
+ function W(a) {
929
929
  return a + 3 & -4;
930
930
  }
931
- function H(a, t, e) {
931
+ function V(a, t, e) {
932
932
  const i = t + e;
933
933
  let s = 0;
934
- const r = A.t;
934
+ const r = R.t;
935
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
  }
@@ -974,11 +974,11 @@ function O(a) {
974
974
  if (!c) continue;
975
975
  const l = s[c]++;
976
976
  let f = n.get(c);
977
- f || (f = [], n.set(c, f)), f[Dt(l, c)] = o;
977
+ f || (f = [], n.set(c, f)), f[Ft(l, c)] = o;
978
978
  }
979
979
  return { min: t, max: e, table: n };
980
980
  }
981
- function V(a, t) {
981
+ function $(a, t) {
982
982
  let e = 0;
983
983
  for (let i = 1; i <= t.max; i++) {
984
984
  e |= a.readBits(1) << i - 1;
@@ -990,12 +990,12 @@ function V(a, t) {
990
990
  }
991
991
  throw Error("Invalid Huffman code");
992
992
  }
993
- function Dt(a, t) {
993
+ function Ft(a, t) {
994
994
  let e = 0;
995
995
  for (let i = 0; i < t; i++) e = e << 1 | 1 & a, a >>>= 1;
996
996
  return e >>> 0;
997
997
  }
998
- function Ft(a) {
998
+ function Pt(a) {
999
999
  if (a.length < 2) throw Error("ZLIB data too short");
1000
1000
  const t = a[0], e = a[1];
1001
1001
  if ((15 & t) != 8) throw Error("Unsupported ZLIB compression method");
@@ -1020,53 +1020,53 @@ function Ft(a) {
1020
1020
  let v, g;
1021
1021
  if (m === 1) {
1022
1022
  const d = Array(288).fill(0);
1023
- for (let E = 0; E <= 143; E++) d[E] = 8;
1024
- for (let E = 144; E <= 255; E++) d[E] = 9;
1025
- for (let E = 256; E <= 279; E++) d[E] = 7;
1026
- for (let E = 280; E <= 287; E++) d[E] = 8;
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
1027
  v = O(d), g = O(Array(32).fill(5));
1028
1028
  } else {
1029
- const d = r.readBits(5) + 257, E = r.readBits(5) + 1, p = r.readBits(4) + 4, w = [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[w[U]] = r.readBits(3);
1031
- const _ = O(y), R = [];
1032
- for (; R.length < d + E; ) {
1033
- const U = V(r, _);
1034
- if (U <= 15) R.push(U);
1029
+ const d = r.readBits(5) + 257, y = r.readBits(5) + 1, p = 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 < p; U++) x[w[U]] = r.readBits(3);
1031
+ const _ = O(x), A = [];
1032
+ for (; A.length < d + y; ) {
1033
+ const U = $(r, _);
1034
+ if (U <= 15) A.push(U);
1035
1035
  else if (U === 16) {
1036
- const G = r.readBits(2) + 3, P = R[R.length - 1] || 0;
1037
- for (let J = 0; J < G; J++) R.push(P);
1036
+ const B = r.readBits(2) + 3, I = A[A.length - 1] || 0;
1037
+ for (let Z = 0; Z < B; Z++) A.push(I);
1038
1038
  } else if (U === 17) {
1039
- const G = r.readBits(3) + 3;
1040
- for (let P = 0; P < G; P++) R.push(0);
1039
+ const B = r.readBits(3) + 3;
1040
+ for (let I = 0; I < B; I++) A.push(0);
1041
1041
  } else {
1042
1042
  if (U !== 18) throw Error("Invalid code length symbol");
1043
1043
  {
1044
- const G = r.readBits(7) + 11;
1045
- for (let P = 0; P < G; P++) R.push(0);
1044
+ const B = r.readBits(7) + 11;
1045
+ for (let I = 0; I < B; I++) A.push(0);
1046
1046
  }
1047
1047
  }
1048
1048
  }
1049
- const T = R.slice(0, d), D = R.slice(d, d + E);
1050
- v = O(T), g = O(D);
1049
+ const T = A.slice(0, d), F = A.slice(d, d + y);
1050
+ v = O(T), g = O(F);
1051
1051
  }
1052
1052
  for (; ; ) {
1053
- const d = V(r, v);
1053
+ const d = $(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 E = d - 257;
1059
- let p = o[E];
1060
- const w = c[E];
1058
+ const y = d - 257;
1059
+ let p = o[y];
1060
+ const w = c[y];
1061
1061
  w && (p += r.readBits(w));
1062
- const y = V(r, g);
1063
- if (y >= 30) throw Error("Invalid distance symbol");
1064
- let _ = l[y];
1065
- const R = f[y];
1066
- R && (_ += r.readBits(R));
1062
+ const x = $(r, g);
1063
+ if (x >= 30) throw Error("Invalid distance symbol");
1064
+ let _ = l[x];
1065
+ const A = f[x];
1066
+ A && (_ += r.readBits(A));
1067
1067
  const T = n.length - _;
1068
1068
  if (T < 0) throw Error("Invalid distance");
1069
- for (let D = 0; D < p; D++) n.push(n[T + D] || 0);
1069
+ for (let F = 0; F < p; F++) n.push(n[T + F] || 0);
1070
1070
  } else if (d === 286 || d === 287) throw Error("Reserved length symbol");
1071
1071
  }
1072
1072
  }
@@ -1076,20 +1076,20 @@ function Ft(a) {
1076
1076
  }(new Ut(a.subarray(i)), s), new Uint8Array(s);
1077
1077
  }
1078
1078
  function Lt(a) {
1079
- const t = A, e = new Uint8Array(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
1083
  for (let p = 0; p < s; p++) {
1084
- const w = t.readASCII(e, o, 4), y = t.readUint(e, o + 4), _ = t.readUint(e, o + 8), R = t.readUint(e, o + 12), T = t.readUint(e, o + 16);
1085
- n.push({ tag: w, offset: y, compLength: _, origLength: R, checksum: T }), o += 20;
1084
+ const w = t.readASCII(e, o, 4), x = t.readUint(e, o + 4), _ = t.readUint(e, o + 8), A = t.readUint(e, o + 12), T = t.readUint(e, o + 16);
1085
+ n.push({ tag: w, offset: x, compLength: _, origLength: A, checksum: T }), o += 20;
1086
1086
  }
1087
1087
  for (const p of n) {
1088
1088
  const w = new Uint8Array(e.buffer, p.offset, p.compLength);
1089
1089
  if (p.compLength === p.origLength) p.data = new Uint8Array(w);
1090
- else if (p.data = Ft(w), 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;
1090
+ else if (p.data = Pt(w), p.data.length !== p.origLength) if (p.data.length < p.origLength) {
1091
+ const x = new Uint8Array(p.origLength);
1092
+ x.set(p.data), p.data = x;
1093
1093
  } else p.data = p.data.subarray(0, p.origLength);
1094
1094
  }
1095
1095
  const c = s;
@@ -1098,43 +1098,43 @@ function Lt(a) {
1098
1098
  const u = 16 * l, m = 16 * c - u;
1099
1099
  let v = 12 + 16 * c;
1100
1100
  const g = {};
1101
- for (const p of n) g[p.tag] = v, v = X(v + p.data.length);
1101
+ for (const p of n) g[p.tag] = v, v = W(v + p.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, u), t.writeUshort(d, 8, f), t.writeUshort(d, 10, m);
1104
- let E = 12;
1104
+ let y = 12;
1105
1105
  for (const p of n) {
1106
- t.writeASCII(d, E, p.tag), E += 4;
1106
+ t.writeASCII(d, y, p.tag), y += 4;
1107
1107
  let w = p.data;
1108
1108
  if (p.tag === "head" && w.length >= 12) {
1109
- const y = new Uint8Array(w);
1110
- t.writeUint(y, 8, 0);
1111
- const _ = H(y, 0, X(y.length));
1112
- t.writeUint(d, E, _), E += 4;
1109
+ const x = new Uint8Array(w);
1110
+ t.writeUint(x, 8, 0);
1111
+ const _ = V(x, 0, W(x.length));
1112
+ t.writeUint(d, y, _), y += 4;
1113
1113
  } else {
1114
- const y = H(w, 0, X(w.length));
1115
- t.writeUint(d, E, y), E += 4;
1114
+ const x = V(w, 0, W(w.length));
1115
+ t.writeUint(d, y, x), y += 4;
1116
1116
  }
1117
- t.writeUint(d, E, g[p.tag]), E += 4, t.writeUint(d, E, p.data.length), E += 4;
1117
+ t.writeUint(d, y, g[p.tag]), y += 4, t.writeUint(d, y, p.data.length), y += 4;
1118
1118
  }
1119
1119
  for (const p of n) {
1120
1120
  const w = g[p.tag];
1121
1121
  d.set(p.data, w);
1122
1122
  }
1123
1123
  if (n.find((p) => p.tag === "head")) {
1124
- const p = g.head, w = function(y, _) {
1125
- const R = A, T = _ + 8, D = [y[T], y[T + 1], y[T + 2], y[T + 3]];
1126
- R.writeUint(y, T, 0);
1127
- const U = 2981146554 - (H(y, 0, X(y.length)) >>> 0) >>> 0;
1128
- return y[T] = D[0], y[T + 1] = D[1], y[T + 2] = D[2], y[T + 3] = D[3], U >>> 0;
1124
+ const p = g.head, w = function(x, _) {
1125
+ const A = R, T = _ + 8, F = [x[T], x[T + 1], x[T + 2], x[T + 3]];
1126
+ A.writeUint(x, T, 0);
1127
+ const U = 2981146554 - (V(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
1129
  }(d, p);
1130
1130
  t.writeUint(d, p + 8, w);
1131
1131
  }
1132
1132
  return d.buffer;
1133
1133
  }
1134
- const Pt = { parseTab(a, t, e) {
1134
+ const It = { parseTab(a, t, e) {
1135
1135
  const i = { tables: [], ids: {}, off: t };
1136
1136
  a = new Uint8Array(a.buffer, t, e), t = 0;
1137
- const s = A, r = s.readUshort, n = r(a, t += 2);
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++) {
@@ -1154,22 +1154,22 @@ const Pt = { parseTab(a, t, e) {
1154
1154
  }
1155
1155
  return i;
1156
1156
  }, parse4(a, t) {
1157
- const e = A, i = e.readUshort, s = e.readUshorts, r = t, n = i(a, t += 2);
1157
+ const e = R, i = e.readUshort, s = e.readUshorts, r = t, n = i(a, t += 2);
1158
1158
  t += 2;
1159
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
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
1161
  for (let l = 0; l < o; l++) c.idDelta.push(e.readShort(a, t)), t += 2;
1162
1162
  return c.idRangeOffset = s(a, t, o), t += 2 * o, c.glyphIdArray = s(a, t, r + n - t >> 1), c;
1163
1163
  }, parse12(a, t) {
1164
- const e = A.readUint;
1164
+ const e = R.readUint;
1165
1165
  e(a, t += 4), e(a, t += 4);
1166
1166
  const i = e(a, t += 4);
1167
1167
  t += 4;
1168
1168
  const s = new Uint32Array(3 * i);
1169
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
- } }, Bt = { parseTab(a, t, e) {
1172
- const i = A;
1171
+ } }, St = { parseTab(a, t, e) {
1172
+ const i = R;
1173
1173
  t += 18;
1174
1174
  const s = i.readUshort(a, t);
1175
1175
  t += 2, t += 16;
@@ -1181,8 +1181,8 @@ const Pt = { parseTab(a, t, e) {
1181
1181
  t += 2;
1182
1182
  const c = i.readShort(a, t);
1183
1183
  return t += 2, t += 6, { unitsPerEm: s, xMin: r, yMin: n, xMax: o, yMax: c, indexToLocFormat: i.readShort(a, t) };
1184
- } }, St = { parseTab(a, t, e) {
1185
- const i = A;
1184
+ } }, Mt = { parseTab(a, t, e) {
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++) {
@@ -1190,17 +1190,17 @@ const Pt = { parseTab(a, t, e) {
1190
1190
  r[o] = c(a, t + 2 * n);
1191
1191
  }
1192
1192
  return r;
1193
- } }, Mt = { parseTab(a, t, e, i) {
1194
- const s = A, r = [], n = [], o = i.maxp.numGlyphs, c = i.hhea.numberOfHMetrics;
1193
+ } }, Gt = { parseTab(a, t, e, i) {
1194
+ const s = R, r = [], n = [], o = i.maxp.numGlyphs, c = i.hhea.numberOfHMetrics;
1195
1195
  let l = 0, f = 0, u = 0;
1196
1196
  for (; u < c; ) l = s.readUshort(a, t + (u << 2)), f = s.readShort(a, t + (u << 2) + 2), r.push(l), n.push(f), u++;
1197
1197
  for (; u < o; ) r.push(l), n.push(f), u++;
1198
1198
  return { aWidth: r, lsBearing: n };
1199
- } }, tt = { cmap: Pt, head: Bt, hhea: St, maxp: { parseTab(a, t, e) {
1200
- const i = A;
1199
+ } }, tt = { cmap: It, head: St, hhea: Mt, maxp: { parseTab(a, t, e) {
1200
+ const i = R;
1201
1201
  return i.readUint(a, t), t += 4, { numGlyphs: i.readUshort(a, t) };
1202
- } }, hmtx: Mt, loca: { parseTab(a, t, e, i) {
1203
- const s = A, r = [], n = i.head.indexToLocFormat, o = i.maxp.numGlyphs + 1;
1202
+ } }, hmtx: Gt, loca: { parseTab(a, t, e, i) {
1203
+ const s = R, r = [], n = i.head.indexToLocFormat, o = i.maxp.numGlyphs + 1;
1204
1204
  if (n === 0) for (let c = 0; c < o; c++) r.push(s.readUshort(a, t + (c << 1)) << 1);
1205
1205
  else if (n === 1) for (let c = 0; c < o; c++) r.push(s.readUint(a, t + (c << 2)));
1206
1206
  return r;
@@ -1209,9 +1209,9 @@ const Pt = { parseTab(a, t, e) {
1209
1209
  for (let n = 0; n < r; n++) s.push(null);
1210
1210
  return s;
1211
1211
  }, Je(a, t) {
1212
- const e = A, i = a.Qe, s = a.loca;
1212
+ const e = R, i = a.Qe, s = a.loca;
1213
1213
  if (s[t] === s[t + 1]) return null;
1214
- const r = L.findTable(i, "glyf", a.ti);
1214
+ const r = P.findTable(i, "glyf", a.ti);
1215
1215
  if (!r) return null;
1216
1216
  let n = r[0] + s[t];
1217
1217
  const o = {};
@@ -1246,14 +1246,14 @@ const Pt = { parseTab(a, t, e) {
1246
1246
  for (let m = 0; m < l; m++) f += o.xs[m], u += o.ys[m], o.xs[m] = f, o.ys[m] = u;
1247
1247
  } else o.parts = [], o.endPts = [], o.flags = [], o.xs = [], o.ys = [];
1248
1248
  return o;
1249
- } } }, L = { parse(a) {
1250
- const t = new Uint8Array(a), e = A.readASCII(t, 0, 4);
1249
+ } } }, P = { parse(a) {
1250
+ const t = new Uint8Array(a), e = R.readASCII(t, 0, 4);
1251
1251
  if (e === "wOFF") a = Lt(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 = tt, c = { Qe: i, si: s, ti: r };
1255
1255
  for (const l in o) {
1256
- const f = l, u = L.findTable(i, f, r);
1256
+ const f = l, u = P.findTable(i, f, r);
1257
1257
  if (u) {
1258
1258
  const [m, v] = u;
1259
1259
  let g = n[m];
@@ -1263,7 +1263,7 @@ const Pt = { parseTab(a, t, e) {
1263
1263
  return c;
1264
1264
  })(new Uint8Array(a), 0, 0, {})];
1265
1265
  }, findTable(a, t, e) {
1266
- const i = A, s = i.readUshort(a, e + 4);
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
1269
  const o = i.readASCII(a, r, 4);
@@ -1273,8 +1273,8 @@ const Pt = { parseTab(a, t, e) {
1273
1273
  r += 16;
1274
1274
  }
1275
1275
  return null;
1276
- }, T: tt, B: A };
1277
- class It {
1276
+ }, T: tt, B: R };
1277
+ class Dt {
1278
1278
  ei(t) {
1279
1279
  var i;
1280
1280
  const e = [];
@@ -1337,7 +1337,7 @@ class It {
1337
1337
  return !(e >= 0 && e <= 31 && e !== 9 && e !== 10 && e !== 13 || e >= 127 && e <= 159);
1338
1338
  }
1339
1339
  }
1340
- class K {
1340
+ class j {
1341
1341
  constructor() {
1342
1342
  h(this, "ai", /* @__PURE__ */ new Map());
1343
1343
  h(this, "ci", /* @__PURE__ */ new Map());
@@ -1396,18 +1396,18 @@ class K {
1396
1396
  return 0;
1397
1397
  }
1398
1398
  }
1399
- class Gt {
1399
+ class Bt {
1400
1400
  constructor(t) {
1401
1401
  h(this, "yi");
1402
1402
  h(this, "Ci");
1403
1403
  h(this, "xt");
1404
1404
  h(this, "wi");
1405
- this.xt = t, this.wi = new K(), this.yi = document.createElement("canvas"), this.Ci = this.yi.getContext("2d", { willReadFrequently: !0, alpha: !0 });
1405
+ this.xt = t, this.wi = new j(), this.yi = document.createElement("canvas"), this.Ci = this.yi.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, f = typeof s == "object" ? s : null;
1409
1409
  this.bi(c, l), this.$i(t, e, n, i, f);
1410
- const u = this.xt.je(c, l, 1, { filter: "nearest" });
1410
+ const u = this.xt.Ye(c, l, 1, { filter: "nearest" });
1411
1411
  return u.Tt(this.yi), { framebuffer: u, columns: n, rows: o };
1412
1412
  }
1413
1413
  bi(t, e) {
@@ -1418,16 +1418,16 @@ class Gt {
1418
1418
  for (let o = 0; o < t.length; o++) {
1419
1419
  const c = o % i, l = Math.floor(o / i), f = t[o].character, u = this.xi(r, f);
1420
1420
  if (!u) continue;
1421
- const m = f.codePointAt(0) || 0, v = this.wi.li(r, m), g = this.Mi(r, v) * n, d = c * e.width, E = l * e.height, p = d + 0.5 * e.width, w = E + 0.5 * e.height, y = Math.round(p - 0.5 * e.width), _ = Math.round(w - 0.5 * s), R = y + 0.5 * (e.width - g), T = _ + r.hhea.ascender * n;
1422
- this.Ri(u, R, T, n);
1421
+ const m = f.codePointAt(0) || 0, v = this.wi.li(r, m), g = this.Mi(r, v) * n, d = c * e.width, y = l * e.height, p = d + 0.5 * e.width, w = y + 0.5 * e.height, x = Math.round(p - 0.5 * e.width), _ = Math.round(w - 0.5 * s), A = x + 0.5 * (e.width - g), T = _ + r.hhea.ascender * n;
1422
+ this.Ri(u, A, T, n);
1423
1423
  }
1424
1424
  }
1425
1425
  xi(t, e) {
1426
1426
  const i = e.codePointAt(0) || 0, s = this.wi.li(t, i);
1427
1427
  if (s === 0) return null;
1428
1428
  if (t.glyf && t.glyf[s] !== null) return t.glyf[s];
1429
- if (L && L.T && L.T.glyf) {
1430
- const r = L.T.glyf.Je(t, s);
1429
+ if (P && P.T && P.T.glyf) {
1430
+ const r = P.T.glyf.Je(t, s);
1431
1431
  return t.glyf && r && (t.glyf[s] = r), r;
1432
1432
  }
1433
1433
  return null;
@@ -1451,17 +1451,17 @@ class Gt {
1451
1451
  let g = l + 1;
1452
1452
  for (; g <= u; )
1453
1453
  if (1 & c[g]) {
1454
- const d = e + r[g] * s, E = i - n[g] * s;
1455
- this.Ci.lineTo(d, E), g++;
1454
+ const d = e + r[g] * s, y = i - n[g] * s;
1455
+ this.Ci.lineTo(d, y), g++;
1456
1456
  } else {
1457
- const d = e + r[g] * s, E = i - n[g] * s;
1457
+ const d = e + r[g] * s, y = i - n[g] * s;
1458
1458
  let p = g + 1 > u ? l : g + 1;
1459
1459
  if (1 & c[p]) {
1460
- const w = e + r[p] * s, y = i - n[p] * s;
1461
- this.Ci.quadraticCurveTo(d, E, w, y), g = p + 1;
1460
+ const w = e + r[p] * s, x = i - n[p] * s;
1461
+ this.Ci.quadraticCurveTo(d, y, w, x), g = p + 1;
1462
1462
  } else {
1463
- const w = (d + (e + r[p] * s)) / 2, y = (E + (i - n[p] * s)) / 2;
1464
- this.Ci.quadraticCurveTo(d, E, w, y), g = p;
1463
+ const w = (d + (e + r[p] * s)) / 2, x = (y + (i - n[p] * s)) / 2;
1464
+ this.Ci.quadraticCurveTo(d, y, w, x), g = p;
1465
1465
  }
1466
1466
  }
1467
1467
  this.Ci.closePath();
@@ -1475,7 +1475,7 @@ class Gt {
1475
1475
  class Ot {
1476
1476
  constructor() {
1477
1477
  h(this, "Fi");
1478
- this.Fi = new K();
1478
+ this.Fi = new j();
1479
1479
  }
1480
1480
  Si(t, e, i) {
1481
1481
  let s = 0;
@@ -1492,10 +1492,10 @@ class Ot {
1492
1492
  this.Fi.gi();
1493
1493
  }
1494
1494
  }
1495
- class zt {
1495
+ class kt {
1496
1496
  constructor() {
1497
1497
  h(this, "wi");
1498
- this.wi = new K();
1498
+ this.wi = new j();
1499
1499
  }
1500
1500
  createCharacterObjects(t, e) {
1501
1501
  return t.map((i, s) => {
@@ -1512,31 +1512,32 @@ class zt {
1512
1512
  return [t % 256 / 255, Math.floor(t / 256) % 256 / 255, Math.floor(t / 65536) % 256 / 255];
1513
1513
  }
1514
1514
  Ai(t, e) {
1515
- if (!z.v(typeof t == "string", "Character must be a string.", { method: "getCharacterColor", providedValue: t })) return [0, 0, 0];
1515
+ if (!k.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
1519
  zi(t, e) {
1520
- return z.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.Ai(i, e) || [0, 0, 0]) : [[0, 0, 0]];
1520
+ return k.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.Ai(i, e) || [0, 0, 0]) : [[0, 0, 0]];
1521
1521
  }
1522
1522
  }
1523
1523
  class Nt {
1524
1524
  constructor(t, e = 16) {
1525
- h(this, "Ei");
1526
- h(this, "Pi", []);
1527
1525
  h(this, "ki");
1526
+ h(this, "Ei", []);
1527
+ h(this, "Pi");
1528
1528
  h(this, "Li", 16);
1529
1529
  h(this, "Di", 0);
1530
1530
  h(this, "Bi", 0);
1531
1531
  h(this, "Gi", { width: 0, height: 0 });
1532
1532
  h(this, "Ii");
1533
- h(this, "Oi");
1533
+ h(this, "Oi", /* @__PURE__ */ new Map());
1534
1534
  h(this, "Wi");
1535
1535
  h(this, "Hi");
1536
1536
  h(this, "Ki");
1537
- this.Li = e, this.Oi = new It(), this.Wi = new Gt(t), this.Hi = new Ot(), this.Ki = new zt();
1537
+ h(this, "Xi");
1538
+ this.Li = e, this.Wi = new Dt(), this.Hi = new Bt(t), this.Ki = new Ot(), this.Xi = new kt();
1538
1539
  }
1539
- async Xi(t) {
1540
+ async Ni(t) {
1540
1541
  let e;
1541
1542
  if (!t) throw new C("Embedded font not available. This appears to be a minified build - please provide `fontSource`.");
1542
1543
  {
@@ -1544,51 +1545,85 @@ class Nt {
1544
1545
  if (!i.ok) throw new C(`Failed to load font file: ${i.status} ${i.statusText}`);
1545
1546
  e = await i.arrayBuffer();
1546
1547
  }
1547
- await this.Ni(e), this.Ei = L.parse(e)[0], await this.Yi();
1548
+ await this.ji(e), this.ki = P.parse(e)[0], await this.Yi();
1548
1549
  }
1549
- ji(t) {
1550
+ Vi(t) {
1550
1551
  if (t === void 0) return this.Li;
1551
- this.Li = t, this.Gi = this.Hi.Si(this.Pi.map((i) => i.character), this.Li, this.Ei);
1552
- const e = this.Wi.createTextureAtlas(this.Pi, this.Gi, this.Li, this.Ei);
1553
- this.ki = e.framebuffer, this.Di = e.columns, this.Bi = e.rows;
1552
+ this.Li = t, this.Gi = this.Ki.Si(this.Ei.map((i) => i.character), this.Li, this.ki);
1553
+ const e = this.Hi.createTextureAtlas(this.Ei, this.Gi, this.Li, this.ki);
1554
+ this.Pi = e.framebuffer, this.Di = e.columns, this.Bi = e.rows;
1554
1555
  }
1555
- async Vi(t) {
1556
+ async qi(t) {
1556
1557
  try {
1557
1558
  const e = await fetch(t);
1558
1559
  if (!e.ok) throw new C(`Failed to load font file: ${e.status} ${e.statusText}`);
1559
1560
  const i = await e.arrayBuffer();
1560
- await this.Ni(i);
1561
- const s = L.parse(i);
1561
+ await this.ji(i);
1562
+ const s = P.parse(i);
1562
1563
  if (!s || s.length === 0) throw Error("Failed to parse font file");
1563
- this.Ei = s[0], await this.Yi();
1564
+ this.ki = s[0], await this.Yi();
1564
1565
  } catch (e) {
1565
1566
  throw new C("Failed to load font: " + (e instanceof Error ? e.message : "Unknown error"), e);
1566
1567
  }
1567
1568
  }
1568
- async Ni(t) {
1569
+ async ji(t) {
1569
1570
  const e = Date.now();
1570
1571
  this.Ii = new FontFace("CustomFont_" + e, t), await this.Ii.load(), document.fonts.add(this.Ii);
1571
1572
  }
1572
1573
  async Yi() {
1573
- const t = this.Oi.ei(this.Ei), e = this.Oi.ni(t);
1574
- this.Pi = this.Ki.createCharacterObjects(e, this.Ei), this.Gi = this.Hi.Si(e, this.Li, this.Ei);
1575
- const i = this.Wi.createTextureAtlas(this.Pi, this.Gi, this.Li, this.Ei);
1576
- this.ki = i.framebuffer, this.Di = i.columns, this.Bi = i.rows;
1574
+ const t = this.Wi.ei(this.ki), e = this.Wi.ni(t);
1575
+ this.Oi.clear(), this.Ei = this.Xi.createCharacterObjects(e, this.ki), this.Gi = this.Ki.Si(e, this.Li, this.ki);
1576
+ const i = this.Hi.createTextureAtlas(this.Ei, this.Gi, this.Li, this.ki);
1577
+ this.Pi = i.framebuffer, this.Di = i.columns, this.Bi = i.rows;
1577
1578
  }
1578
1579
  Ai(t) {
1579
- return this.Ki.Ai(t, this.Pi);
1580
+ return this.Xi.Ai(t, this.Ei);
1580
1581
  }
1581
1582
  zi(t) {
1582
- return this.Ki.zi(t, this.Pi);
1583
+ return this.Xi.zi(t, this.Ei);
1584
+ }
1585
+ getGlyphData(t) {
1586
+ if (!Number.isFinite(t)) return null;
1587
+ const e = this.Oi.get(t);
1588
+ if (e !== void 0) return e;
1589
+ const i = this.Zi(t);
1590
+ if (i < 0) return this.Oi.set(t, null), null;
1591
+ const s = this.ki.glyf;
1592
+ if (!s) return this.Oi.set(t, null), null;
1593
+ let r = s[i] ?? null;
1594
+ return r == null && (r = P.T.glyf.Je(this.ki, i) ?? null, s[i] = r), this.Oi.set(t, r), r;
1595
+ }
1596
+ Zi(t) {
1597
+ const e = this.ki.cmap;
1598
+ for (const i of e.tables) if (i.format === 4) {
1599
+ const s = i;
1600
+ for (let r = 0; r < s.startCount.length; r++) if (t >= s.startCount[r] && t <= s.endCount[r]) {
1601
+ if (s.idRangeOffset[r] === 0) return t + s.idDelta[r] & 65535;
1602
+ {
1603
+ const n = s.idRangeOffset[r] / 2 + (t - s.startCount[r]) - (s.startCount.length - r);
1604
+ if (n >= 0 && n < s.glyphIdArray.length) {
1605
+ const o = s.glyphIdArray[n];
1606
+ if (o !== 0) return o + s.idDelta[r] & 65535;
1607
+ }
1608
+ }
1609
+ }
1610
+ } else if (i.format === 12) {
1611
+ const s = i;
1612
+ for (let r = 0; r < s.groups.length; r += 3) {
1613
+ const n = s.groups[r], o = s.groups[r + 1], c = s.groups[r + 2];
1614
+ if (t >= n && t <= o) return c + (t - n);
1615
+ }
1616
+ }
1617
+ return 0;
1583
1618
  }
1584
- kt() {
1585
- this.ki.kt(), document.fonts.delete(this.Ii);
1619
+ Pt() {
1620
+ this.Pi.Pt(), document.fonts.delete(this.Ii);
1586
1621
  }
1587
1622
  get fontFramebuffer() {
1588
- return this.ki;
1623
+ return this.Pi;
1589
1624
  }
1590
1625
  get characters() {
1591
- return this.Pi;
1626
+ return this.Ei;
1592
1627
  }
1593
1628
  get textureColumns() {
1594
1629
  return this.Di;
@@ -1603,39 +1638,39 @@ class Nt {
1603
1638
  return this.Li;
1604
1639
  }
1605
1640
  get font() {
1606
- return this.Ei;
1641
+ return this.ki;
1607
1642
  }
1608
1643
  }
1609
- class Wt {
1644
+ class zt {
1610
1645
  constructor(t, e, i) {
1611
- h(this, "qi");
1612
- h(this, "Zi");
1613
- h(this, "dt");
1614
- h(this, "_t");
1615
1646
  h(this, "Ji");
1616
1647
  h(this, "Qi");
1648
+ h(this, "dt");
1649
+ h(this, "_t");
1617
1650
  h(this, "tr");
1618
1651
  h(this, "sr");
1619
1652
  h(this, "er");
1620
- this.tr = t, this.sr = e, this.er = i, this.ir();
1653
+ h(this, "ir");
1654
+ h(this, "rr");
1655
+ this.er = t, this.ir = e, this.rr = i, this.nr();
1621
1656
  }
1622
- ir() {
1623
- this.qi = Math.floor(this.tr.width / this.sr), this.Zi = Math.floor(this.tr.height / this.er), this.dt = this.qi * this.sr, this._t = this.Zi * this.er, this.Ji = Math.floor((this.tr.width - this.dt) / 2), this.Qi = Math.floor((this.tr.height - this._t) / 2);
1657
+ nr() {
1658
+ this.Ji = Math.floor(this.er.width / this.ir), this.Qi = Math.floor(this.er.height / this.rr), this.dt = this.Ji * this.ir, this._t = this.Qi * this.rr, this.tr = Math.floor((this.er.width - this.dt) / 2), this.sr = Math.floor((this.er.height - this._t) / 2);
1624
1659
  }
1625
- rr(t, e) {
1626
- this.sr = t, this.er = e, this.ir();
1660
+ hr(t, e) {
1661
+ this.ir = t, this.rr = e, this.nr();
1627
1662
  }
1628
1663
  get cellWidth() {
1629
- return this.sr;
1664
+ return this.ir;
1630
1665
  }
1631
1666
  get cellHeight() {
1632
- return this.er;
1667
+ return this.rr;
1633
1668
  }
1634
1669
  get cols() {
1635
- return this.qi;
1670
+ return this.Ji;
1636
1671
  }
1637
1672
  get rows() {
1638
- return this.Zi;
1673
+ return this.Qi;
1639
1674
  }
1640
1675
  get width() {
1641
1676
  return this.dt;
@@ -1644,140 +1679,140 @@ class Wt {
1644
1679
  return this._t;
1645
1680
  }
1646
1681
  get offsetX() {
1647
- return this.Ji;
1682
+ return this.tr;
1648
1683
  }
1649
1684
  get offsetY() {
1650
- return this.Qi;
1685
+ return this.sr;
1651
1686
  }
1652
1687
  }
1653
- class Xt {
1688
+ class Wt {
1654
1689
  constructor(t = {}) {
1655
- h(this, "tr");
1656
- h(this, "nr", null);
1657
- h(this, "hr", !1);
1658
- h(this, "ar");
1659
- h(this, "cr");
1660
- this.hr = t.overlay ?? !1, this.hr && t.canvas ? (this.nr = t.canvas, this.tr = this.lr(), this.cr = !0, this.ur()) : t.canvas ? (this.tr = t.canvas, this.cr = !1) : (this.tr = this.dr(t.width, t.height), this.cr = !0), this.tr.style.imageRendering = "pixelated";
1690
+ h(this, "er");
1691
+ h(this, "ar", null);
1692
+ h(this, "cr", !1);
1693
+ h(this, "lr");
1694
+ h(this, "ur");
1695
+ this.cr = t.overlay ?? !1, this.cr && t.canvas ? (this.ar = t.canvas, this.er = this.dr(), this.ur = !0, this._r()) : t.canvas ? (this.er = t.canvas, this.ur = !1) : (this.er = this.pr(t.width, t.height), this.ur = !0), this.er.style.imageRendering = "pixelated";
1661
1696
  }
1662
- dr(t, e) {
1697
+ pr(t, e) {
1663
1698
  const i = document.createElement("canvas");
1664
1699
  return i.className = "textmodeCanvas", i.style.imageRendering = "pixelated", i.width = t || 800, i.height = e || 600, document.body.appendChild(i), i;
1665
1700
  }
1666
- lr() {
1701
+ dr() {
1667
1702
  const t = document.createElement("canvas");
1668
1703
  t.className = "textmodeCanvas", t.style.imageRendering = "pixelated";
1669
- const e = this.nr.getBoundingClientRect();
1704
+ const e = this.ar.getBoundingClientRect();
1670
1705
  let i = Math.round(e.width), s = Math.round(e.height);
1671
- if (this.nr instanceof HTMLVideoElement) {
1672
- const o = this.nr;
1706
+ if (this.ar instanceof HTMLVideoElement) {
1707
+ const o = this.ar;
1673
1708
  (i === 0 || s === 0) && o.videoWidth > 0 && o.videoHeight > 0 && (i = o.videoWidth, s = o.videoHeight);
1674
1709
  }
1675
1710
  t.width = i, t.height = s, t.style.position = "absolute", t.style.pointerEvents = "none";
1676
- const r = window.getComputedStyle(this.nr);
1711
+ const r = window.getComputedStyle(this.ar);
1677
1712
  let n = parseInt(r.zIndex || "0", 10);
1678
1713
  return isNaN(n) && (n = 0), t.style.zIndex = "" + (n + 1), t;
1679
1714
  }
1680
- ur() {
1715
+ _r() {
1681
1716
  var t;
1682
- this._r(), (t = this.nr.parentNode) == null || t.insertBefore(this.tr, this.nr.nextSibling), window.ResizeObserver && (this.ar = new ResizeObserver(() => {
1683
- this.pr();
1684
- }), this.ar.observe(this.nr)), window.addEventListener("resize", () => {
1685
- this.pr();
1717
+ this.mr(), (t = this.ar.parentNode) == null || t.insertBefore(this.er, this.ar.nextSibling), window.ResizeObserver && (this.lr = new ResizeObserver(() => {
1718
+ this.vr();
1719
+ }), this.lr.observe(this.ar)), window.addEventListener("resize", () => {
1720
+ this.vr();
1686
1721
  });
1687
1722
  }
1688
- _r() {
1689
- if (!this.nr) return;
1690
- const t = this.nr.getBoundingClientRect();
1691
- let e = this.nr.offsetParent;
1723
+ mr() {
1724
+ if (!this.ar) return;
1725
+ const t = this.ar.getBoundingClientRect();
1726
+ let e = this.ar.offsetParent;
1692
1727
  if (e && e !== document.body) {
1693
1728
  const i = e.getBoundingClientRect();
1694
- this.tr.style.top = t.top - i.top + "px", this.tr.style.left = t.left - i.left + "px";
1695
- } else this.tr.style.top = t.top + window.scrollY + "px", this.tr.style.left = t.left + window.scrollX + "px";
1729
+ this.er.style.top = t.top - i.top + "px", this.er.style.left = t.left - i.left + "px";
1730
+ } else this.er.style.top = t.top + window.scrollY + "px", this.er.style.left = t.left + window.scrollX + "px";
1696
1731
  }
1697
- pr(t, e) {
1698
- if (this.hr) {
1699
- const i = this.nr.getBoundingClientRect();
1732
+ vr(t, e) {
1733
+ if (this.cr) {
1734
+ const i = this.ar.getBoundingClientRect();
1700
1735
  let s = Math.round(i.width), r = Math.round(i.height);
1701
- if (this.nr instanceof HTMLVideoElement) {
1702
- const n = this.nr;
1736
+ if (this.ar instanceof HTMLVideoElement) {
1737
+ const n = this.ar;
1703
1738
  (s === 0 || r === 0) && n.videoWidth > 0 && n.videoHeight > 0 && (s = n.videoWidth, r = n.videoHeight);
1704
1739
  }
1705
- this.tr.width = s, this.tr.height = r, this._r();
1706
- } else this.tr.width = t ?? this.tr.width, this.tr.height = e ?? this.tr.height;
1740
+ this.er.width = s, this.er.height = r, this.mr();
1741
+ } else this.er.width = t ?? this.er.width, this.er.height = e ?? this.er.height;
1707
1742
  }
1708
- mr() {
1709
- const t = this.tr.getContext("webgl2", { alpha: !0, premultipliedAlpha: !1, preserveDrawingBuffer: !0, antialias: !1, depth: !1, stencil: !1, powerPreference: "high-performance" });
1743
+ gr() {
1744
+ const t = this.er.getContext("webgl2", { alpha: !0, premultipliedAlpha: !1, preserveDrawingBuffer: !0, antialias: !1, depth: !1, stencil: !1, powerPreference: "high-performance" });
1710
1745
  if (!t) throw new C("`textmode.js` requires WebGL2 support.");
1711
1746
  return t;
1712
1747
  }
1713
- kt() {
1714
- this.ar && this.ar.disconnect();
1715
- const t = this.tr.getContext("webgl") || this.tr.getContext("webgl2");
1748
+ Pt() {
1749
+ this.lr && this.lr.disconnect();
1750
+ const t = this.er.getContext("webgl") || this.er.getContext("webgl2");
1716
1751
  if (t) {
1717
1752
  const e = t.getExtension("WEBGL_lose_context");
1718
1753
  e && e.loseContext();
1719
1754
  }
1720
- this.cr && this.tr.parentNode && this.tr.parentNode.removeChild(this.tr);
1755
+ this.ur && this.er.parentNode && this.er.parentNode.removeChild(this.er);
1721
1756
  }
1722
1757
  get canvas() {
1723
- return this.tr;
1758
+ return this.er;
1724
1759
  }
1725
1760
  get targetCanvas() {
1726
- return this.nr;
1761
+ return this.ar;
1727
1762
  }
1728
1763
  get width() {
1729
- return this.tr.width;
1764
+ return this.er.width;
1730
1765
  }
1731
1766
  get height() {
1732
- return this.tr.height;
1767
+ return this.er.height;
1733
1768
  }
1734
1769
  }
1735
1770
  class N {
1736
1771
  constructor(t, e, i, s) {
1737
- h(this, "vr");
1772
+ h(this, "yr");
1738
1773
  h(this, "dt");
1739
1774
  h(this, "_t");
1740
1775
  h(this, "gt");
1741
1776
  h(this, "L", 0);
1742
1777
  h(this, "N", 0);
1743
- h(this, "Y", 0);
1778
+ h(this, "j", 0);
1744
1779
  h(this, "D", [0, 0]);
1745
- h(this, "gr", "sampled");
1746
- h(this, "yr", "fixed");
1780
+ h(this, "Cr", "sampled");
1781
+ h(this, "wr", "fixed");
1747
1782
  h(this, "V", [1, 1, 1, 1]);
1748
1783
  h(this, "q", [0, 0, 0, 1]);
1749
- h(this, "Cr", [0, 0, 0, 1]);
1750
- h(this, "wr", [[0.1, 0, 0]]);
1751
- h(this, "br");
1752
- this.gt = t, this.vr = e, this.dt = i, this._t = s;
1784
+ h(this, "br", [0, 0, 0, 1]);
1785
+ h(this, "$r", [[0.1, 0, 0]]);
1786
+ h(this, "Mr");
1787
+ this.gt = t, this.yr = e, this.dt = i, this._t = s;
1753
1788
  }
1754
- kt() {
1755
- this.gt.deleteTexture(this.vr);
1789
+ Pt() {
1790
+ this.gt.deleteTexture(this.yr);
1756
1791
  }
1757
- $r(t) {
1792
+ Rr(t) {
1758
1793
  return typeof t == "boolean" ? t ? 1 : 0 : (t == null ? 0 : Number(t)) > 0 ? 1 : 0;
1759
1794
  }
1760
1795
  invert(t = !0) {
1761
- return this.L = this.$r(t), this;
1796
+ return this.L = this.Rr(t), this;
1762
1797
  }
1763
1798
  flipX(t = !0) {
1764
- return this.N = this.$r(t), this;
1799
+ return this.N = this.Rr(t), this;
1765
1800
  }
1766
1801
  flipY(t = !0) {
1767
- return this.Y = this.$r(t), this;
1802
+ return this.j = this.Rr(t), this;
1768
1803
  }
1769
1804
  charRotation(t) {
1770
1805
  const e = 255 * t / 360, i = Math.floor(e) / 255, s = Math.round(e - Math.floor(e));
1771
1806
  return this.D = [i, s], this;
1772
1807
  }
1773
1808
  Oe() {
1774
- return { texture: this.vr, invert: this.L, flipX: this.N, flipY: this.Y, charRotation: this.D, charColorFixed: this.gr === "fixed", charColor: this.V, cellColorFixed: this.yr === "fixed", cellColor: this.q, backgroundColor: this.Cr, charCount: this.wr.length, charList: this.wr };
1809
+ return { texture: this.yr, invert: this.L, flipX: this.N, flipY: this.j, charRotation: this.D, charColorFixed: this.Cr === "fixed", charColor: this.V, cellColorFixed: this.wr === "fixed", cellColor: this.q, backgroundColor: this.br, charCount: this.$r.length, charList: this.$r };
1775
1810
  }
1776
1811
  charColorMode(t) {
1777
- return this.gr = t, this;
1812
+ return this.Cr = t, this;
1778
1813
  }
1779
1814
  cellColorMode(t) {
1780
- return this.yr = t, this;
1815
+ return this.wr = t, this;
1781
1816
  }
1782
1817
  charColor(t, e, i, s) {
1783
1818
  return this.V = [(t ?? 0) / 255, (e ?? t ?? 0) / 255, (i ?? t ?? 0) / 255, (s ?? 255) / 255], this;
@@ -1786,20 +1821,20 @@ class N {
1786
1821
  return this.q = [(t ?? 0) / 255, (e ?? t ?? 0) / 255, (i ?? t ?? 0) / 255, (s ?? 255) / 255], this;
1787
1822
  }
1788
1823
  background(t, e, i, s) {
1789
- return this.Cr = [(t ?? 0) / 255, (e ?? t ?? 0) / 255, (i ?? t ?? 0) / 255, (s ?? 255) / 255], this;
1824
+ return this.br = [(t ?? 0) / 255, (e ?? t ?? 0) / 255, (i ?? t ?? 0) / 255, (s ?? 255) / 255], this;
1790
1825
  }
1791
1826
  characters(t) {
1792
- const e = this.br(t).filter((i) => Array.isArray(i)).slice(0, 64);
1793
- return this.wr = e, this;
1827
+ const e = this.Mr(t).filter((i) => Array.isArray(i)).slice(0, 64);
1828
+ return this.$r = e, this;
1794
1829
  }
1795
- static Mr(t, e, i) {
1830
+ static Fr(t, e, i) {
1796
1831
  const s = t.context, r = s.createTexture();
1797
1832
  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
1833
  const n = e.naturalWidth ?? e.width ?? e.videoWidth ?? 0, o = e.naturalHeight ?? e.height ?? e.videoHeight ?? 0, c = new N(s, r, n, o);
1799
- return c.br = i, c;
1834
+ return c.Mr = i, c;
1800
1835
  }
1801
1836
  get texture() {
1802
- return this.vr;
1837
+ return this.yr;
1803
1838
  }
1804
1839
  get width() {
1805
1840
  return this.dt;
@@ -1808,149 +1843,143 @@ class N {
1808
1843
  return this._t;
1809
1844
  }
1810
1845
  }
1811
- class Yt {
1846
+ class Xt {
1812
1847
  constructor(t = 60) {
1813
- h(this, "Rr");
1814
- h(this, "Fr");
1815
- h(this, "Sr", null);
1816
- h(this, "Tr", 0);
1817
- h(this, "Ar", !0);
1848
+ h(this, "Sr");
1849
+ h(this, "Tr");
1850
+ h(this, "Ar", null);
1818
1851
  h(this, "zr", 0);
1852
+ h(this, "kr", !0);
1819
1853
  h(this, "Er", 0);
1820
- h(this, "Pr", []);
1821
- h(this, "kr", 10);
1822
- h(this, "Lr", 0);
1823
- this.Rr = t, this.Fr = 1e3 / t;
1854
+ h(this, "Pr", 0);
1855
+ h(this, "Lr", []);
1856
+ h(this, "Dr", 10);
1857
+ h(this, "Br", 0);
1858
+ this.Sr = t, this.Tr = 1e3 / t;
1824
1859
  }
1825
1860
  start(t) {
1826
- if (!this.Ar) return;
1827
- this.Tr = performance.now();
1861
+ if (!this.kr) return;
1862
+ this.zr = performance.now();
1828
1863
  const e = (i) => {
1829
- if (!this.Ar) return void (this.Sr = null);
1830
- const s = i - this.Tr;
1831
- s >= this.Fr && (t(), this.Tr = i - s % this.Fr), this.Ar && (this.Sr = requestAnimationFrame(e));
1864
+ if (!this.kr) return void (this.Ar = null);
1865
+ const s = i - this.zr;
1866
+ s >= this.Tr && (t(), this.zr = i - s % this.Tr), this.kr && (this.Ar = requestAnimationFrame(e));
1832
1867
  };
1833
- this.Sr = requestAnimationFrame(e);
1868
+ this.Ar = requestAnimationFrame(e);
1834
1869
  }
1835
1870
  stop() {
1836
- this.Sr && (cancelAnimationFrame(this.Sr), this.Sr = null);
1871
+ this.Ar && (cancelAnimationFrame(this.Ar), this.Ar = null);
1837
1872
  }
1838
1873
  pause() {
1839
- this.Ar && (this.Ar = !1, this.stop());
1874
+ this.kr && (this.kr = !1, this.stop());
1840
1875
  }
1841
1876
  resume(t) {
1842
- this.Ar || (this.Ar = !0, this.start(t));
1877
+ this.kr || (this.kr = !0, this.start(t));
1843
1878
  }
1844
1879
  frameRate(t, e) {
1845
- if (t === void 0) return this.zr;
1846
- this.Rr = t, this.Fr = 1e3 / t, this.Ar && e && (this.stop(), this.start(e));
1880
+ if (t === void 0) return this.Er;
1881
+ this.Sr = t, this.Tr = 1e3 / t, this.kr && e && (this.stop(), this.start(e));
1847
1882
  }
1848
1883
  measureFrameRate() {
1849
1884
  const t = performance.now();
1850
- if (this.Er > 0) {
1851
- const e = t - this.Er;
1852
- this.Pr.push(e), this.Pr.length > this.kr && this.Pr.shift();
1853
- const i = this.Pr.reduce((s, r) => s + r, 0) / this.Pr.length;
1854
- this.zr = 1e3 / i;
1885
+ if (this.Pr > 0) {
1886
+ const e = t - this.Pr;
1887
+ this.Lr.push(e), this.Lr.length > this.Dr && this.Lr.shift();
1888
+ const i = this.Lr.reduce((s, r) => s + r, 0) / this.Lr.length;
1889
+ this.Er = 1e3 / i;
1855
1890
  }
1856
- this.Er = t;
1891
+ this.Pr = t;
1857
1892
  }
1858
1893
  get isLooping() {
1859
- return this.Ar;
1894
+ return this.kr;
1860
1895
  }
1861
1896
  get frameRateLimit() {
1862
- return this.Rr;
1897
+ return this.Sr;
1863
1898
  }
1864
1899
  get currentFrameRate() {
1865
- return this.zr;
1900
+ return this.Er;
1866
1901
  }
1867
1902
  get frameCount() {
1868
- return this.Lr;
1903
+ return this.Br;
1869
1904
  }
1870
1905
  set frameCount(t) {
1871
- this.Lr = t;
1906
+ this.Br = t;
1872
1907
  }
1873
1908
  incrementFrame() {
1874
- this.Lr++;
1909
+ this.Br++;
1875
1910
  }
1876
1911
  resetFrameCount() {
1877
- this.Lr = 0;
1912
+ this.Br = 0;
1878
1913
  }
1879
1914
  }
1880
1915
  class rt {
1881
1916
  constructor(t) {
1882
- h(this, "tr");
1883
- h(this, "Dr");
1884
- h(this, "Br", { x: -1, y: -1 });
1885
- h(this, "Gr", { x: -1, y: -1 });
1886
- h(this, "Ir", null);
1887
- h(this, "Or", 0);
1888
- h(this, "Wr");
1889
- h(this, "Hr");
1917
+ h(this, "er");
1918
+ h(this, "Gr");
1919
+ h(this, "Ir", { x: -1, y: -1 });
1920
+ h(this, "Or", { x: -1, y: -1 });
1921
+ h(this, "Wr", null);
1922
+ h(this, "Hr", 0);
1890
1923
  h(this, "Kr");
1891
1924
  h(this, "Xr");
1892
1925
  h(this, "Nr");
1926
+ h(this, "jr");
1893
1927
  h(this, "Yr");
1894
- h(this, "jr", !1);
1895
1928
  h(this, "Vr");
1896
- h(this, "qr");
1929
+ h(this, "qr", !1);
1897
1930
  h(this, "Zr");
1898
1931
  h(this, "Jr");
1899
1932
  h(this, "Qr");
1900
- this.tr = t;
1933
+ h(this, "tn");
1934
+ h(this, "sn");
1935
+ this.er = t;
1901
1936
  }
1902
- tn(t) {
1937
+ en(t) {
1903
1938
  const e = performance.now() + Math.max(0, t);
1904
- e > this.Or && (this.Or = e);
1939
+ e > this.Hr && (this.Hr = e);
1905
1940
  }
1906
- sn() {
1907
- return performance.now() < this.Or;
1941
+ rn() {
1942
+ return performance.now() < this.Hr;
1908
1943
  }
1909
- en(t) {
1910
- const e = this.tr.canvas;
1944
+ nn(t) {
1945
+ const e = this.er.canvas;
1911
1946
  e.style.cursor = t == null || t === "" ? "" : t;
1912
1947
  }
1913
- Xi(t) {
1914
- this.Dr = t, this.rn();
1915
- }
1916
- nn() {
1917
- if (this.jr) return;
1918
- const t = this.tr.canvas;
1919
- this.Wr = (e) => {
1920
- this.hn(e), this.an(e);
1921
- }, this.Hr = () => {
1922
- this.Gr = { ...this.Br }, this.Br.x = -1, this.Br.y = -1, this.Ir = null;
1923
- }, this.Kr = (e) => {
1924
- this.hn(e), this.cn(e);
1925
- }, this.Xr = (e) => {
1926
- this.hn(e), this.ln(e);
1948
+ Ni(t) {
1949
+ this.Gr = t, this.hn();
1950
+ }
1951
+ an() {
1952
+ if (this.qr) return;
1953
+ const t = this.er.canvas;
1954
+ this.Kr = (e) => {
1955
+ this.cn(e), this.ln(e);
1956
+ }, this.Xr = () => {
1957
+ this.Or = { ...this.Ir }, this.Ir.x = -1, this.Ir.y = -1, this.Wr = null;
1927
1958
  }, this.Nr = (e) => {
1928
- this.hn(e), this.un(e);
1959
+ this.cn(e), this.un(e);
1960
+ }, this.jr = (e) => {
1961
+ this.cn(e), this.fn(e);
1929
1962
  }, this.Yr = (e) => {
1930
- this.hn(e), this.fn(e);
1931
- }, t.addEventListener("mousemove", this.Wr, { passive: !0 }), t.addEventListener("mouseleave", this.Hr, { passive: !0 }), t.addEventListener("mousedown", this.Kr, { passive: !0 }), t.addEventListener("mouseup", this.Xr, { passive: !0 }), t.addEventListener("click", this.Nr, { passive: !0 }), t.addEventListener("wheel", this.Yr, { passive: !1 }), this.jr = !0;
1932
- }
1933
- dn() {
1934
- if (!this.jr) return;
1935
- const t = this.tr.canvas;
1936
- t.removeEventListener("mousemove", this.Wr), t.removeEventListener("mouseleave", this.Hr), t.removeEventListener("mousedown", this.Kr), t.removeEventListener("mouseup", this.Xr), t.removeEventListener("click", this.Nr), t.removeEventListener("wheel", this.Yr), this.jr = !1;
1937
- }
1938
- rn() {
1939
- if (this.jr) try {
1940
- if (this.Ir) {
1941
- const t = new MouseEvent("mousemove", { clientX: this.Ir.x, clientY: this.Ir.y, bubbles: !1, cancelable: !1 });
1942
- this.hn(t);
1943
- } else this.Br.x !== -1 && this.Br.y !== -1 && (this.Br.x >= this.Dr.cols || this.Br.y >= this.Dr.rows) && (this.Br.x = -1, this.Br.y = -1);
1963
+ this.cn(e), this.dn(e);
1964
+ }, this.Vr = (e) => {
1965
+ this.cn(e), this._n(e);
1966
+ }, t.addEventListener("mousemove", this.Kr, { passive: !0 }), t.addEventListener("mouseleave", this.Xr, { passive: !0 }), t.addEventListener("mousedown", this.Nr, { passive: !0 }), t.addEventListener("mouseup", this.jr, { passive: !0 }), t.addEventListener("click", this.Yr, { passive: !0 }), t.addEventListener("wheel", this.Vr, { passive: !1 }), this.qr = !0;
1967
+ }
1968
+ pn() {
1969
+ if (!this.qr) return;
1970
+ const t = this.er.canvas;
1971
+ t.removeEventListener("mousemove", this.Kr), t.removeEventListener("mouseleave", this.Xr), t.removeEventListener("mousedown", this.Nr), t.removeEventListener("mouseup", this.jr), t.removeEventListener("click", this.Yr), t.removeEventListener("wheel", this.Vr), this.qr = !1;
1972
+ }
1973
+ hn() {
1974
+ if (this.qr) try {
1975
+ if (this.Wr) {
1976
+ const t = new MouseEvent("mousemove", { clientX: this.Wr.x, clientY: this.Wr.y, bubbles: !1, cancelable: !1 });
1977
+ this.cn(t);
1978
+ } else this.Ir.x !== -1 && this.Ir.y !== -1 && (this.Ir.x >= this.Gr.cols || this.Ir.y >= this.Gr.rows) && (this.Ir.x = -1, this.Ir.y = -1);
1944
1979
  } catch {
1945
- this.Br.x = -1, this.Br.y = -1;
1980
+ this.Ir.x = -1, this.Ir.y = -1;
1946
1981
  }
1947
1982
  }
1948
- _n(t) {
1949
- this.Vr = t;
1950
- }
1951
- pn(t) {
1952
- this.qr = t;
1953
- }
1954
1983
  mn(t) {
1955
1984
  this.Zr = t;
1956
1985
  }
@@ -1960,137 +1989,141 @@ class rt {
1960
1989
  gn(t) {
1961
1990
  this.Qr = t;
1962
1991
  }
1963
- yn() {
1964
- return { x: this.Br.x, y: this.Br.y };
1992
+ yn(t) {
1993
+ this.tn = t;
1965
1994
  }
1966
- an(t) {
1967
- if (this.Jr && !this.sn()) {
1968
- const e = { position: { ...this.Br }, previousPosition: { ...this.Gr }, originalEvent: t };
1969
- this.Jr(e);
1970
- }
1995
+ Cn(t) {
1996
+ this.sn = t;
1971
1997
  }
1972
- cn(t) {
1973
- if (this.qr && !this.sn()) {
1974
- const e = { position: { ...this.Br }, previousPosition: { ...this.Gr }, button: t.button, originalEvent: t };
1975
- this.qr(e);
1976
- }
1998
+ wn() {
1999
+ return { x: this.Ir.x, y: this.Ir.y };
1977
2000
  }
1978
2001
  ln(t) {
1979
- if (this.Zr && !this.sn()) {
1980
- const e = { position: { ...this.Br }, previousPosition: { ...this.Gr }, button: t.button, originalEvent: t };
1981
- this.Zr(e);
2002
+ if (this.tn && !this.rn()) {
2003
+ const e = { position: { ...this.Ir }, previousPosition: { ...this.Or }, originalEvent: t };
2004
+ this.tn(e);
1982
2005
  }
1983
2006
  }
1984
2007
  un(t) {
1985
- if (this.Vr && !this.sn()) {
1986
- const e = { position: { ...this.Br }, previousPosition: { ...this.Gr }, button: t.button, originalEvent: t };
1987
- this.Vr(e);
2008
+ if (this.Jr && !this.rn()) {
2009
+ const e = { position: { ...this.Ir }, previousPosition: { ...this.Or }, button: t.button, originalEvent: t };
2010
+ this.Jr(e);
1988
2011
  }
1989
2012
  }
1990
2013
  fn(t) {
1991
- if (this.Qr && !this.sn()) {
1992
- const e = { position: { ...this.Br }, previousPosition: { ...this.Gr }, delta: { x: t.deltaX, y: t.deltaY }, originalEvent: t };
2014
+ if (this.Qr && !this.rn()) {
2015
+ const e = { position: { ...this.Ir }, previousPosition: { ...this.Or }, button: t.button, originalEvent: t };
1993
2016
  this.Qr(e);
1994
2017
  }
1995
2018
  }
1996
- hn(t) {
1997
- const e = this.tr.canvas;
1998
- this.Gr = { ...this.Br }, this.Ir = { 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.Dr.offsetX, l = o - this.Dr.offsetY, f = Math.floor(c / this.Dr.cellWidth), u = Math.floor(l / this.Dr.cellHeight);
2000
- f >= 0 && f < this.Dr.cols && u >= 0 && u < this.Dr.rows ? (this.Br.x = f, this.Br.y = u) : (this.Br.x = -1, this.Br.y = -1);
2019
+ dn(t) {
2020
+ if (this.Zr && !this.rn()) {
2021
+ const e = { position: { ...this.Ir }, previousPosition: { ...this.Or }, button: t.button, originalEvent: t };
2022
+ this.Zr(e);
2023
+ }
2024
+ }
2025
+ _n(t) {
2026
+ if (this.sn && !this.rn()) {
2027
+ const e = { position: { ...this.Ir }, previousPosition: { ...this.Or }, delta: { x: t.deltaX, y: t.deltaY }, originalEvent: t };
2028
+ this.sn(e);
2029
+ }
2030
+ }
2031
+ cn(t) {
2032
+ const e = this.er.canvas;
2033
+ this.Or = { ...this.Ir }, this.Wr = { x: t.clientX, y: t.clientY };
2034
+ 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, f = Math.floor(c / this.Gr.cellWidth), u = Math.floor(l / this.Gr.cellHeight);
2035
+ f >= 0 && f < this.Gr.cols && u >= 0 && u < this.Gr.rows ? (this.Ir.x = f, this.Ir.y = u) : (this.Ir.x = -1, this.Ir.y = -1);
2001
2036
  }
2002
2037
  }
2003
- const kt = Object.freeze(Object.defineProperty({ __proto__: null, MouseManager: rt }, Symbol.toStringTag, { value: "Module" }));
2038
+ const Yt = Object.freeze(Object.defineProperty({ __proto__: null, MouseManager: rt }, Symbol.toStringTag, { value: "Module" }));
2004
2039
  class nt {
2005
2040
  constructor() {
2006
- h(this, "Cn", /* @__PURE__ */ new Map());
2007
- h(this, "wn", null);
2008
- h(this, "bn", null);
2009
- h(this, "$n");
2010
- h(this, "xn");
2011
- h(this, "jr", !1);
2041
+ h(this, "bn", /* @__PURE__ */ new Map());
2042
+ h(this, "$n", null);
2043
+ h(this, "xn", null);
2012
2044
  h(this, "Mn");
2013
2045
  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" });
2046
+ h(this, "qr", !1);
2047
+ h(this, "Fn");
2048
+ h(this, "Sn");
2049
+ h(this, "Tn", { 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
2050
  }
2016
- nn() {
2017
- this.jr || (this.$n = (t) => {
2018
- this.Sn(t);
2019
- }, this.xn = (t) => {
2020
- this.Tn(t);
2021
- }, window.addEventListener("keydown", this.$n, { passive: !1 }), window.addEventListener("keyup", this.xn, { passive: !1 }), this.jr = !0);
2051
+ an() {
2052
+ this.qr || (this.Mn = (t) => {
2053
+ this.An(t);
2054
+ }, this.Rn = (t) => {
2055
+ this.zn(t);
2056
+ }, window.addEventListener("keydown", this.Mn, { passive: !1 }), window.addEventListener("keyup", this.Rn, { passive: !1 }), this.qr = !0);
2022
2057
  }
2023
- dn() {
2024
- this.jr && (window.removeEventListener("keydown", this.$n), window.removeEventListener("keyup", this.xn), this.jr = !1, this.Cn.clear(), this.wn = null, this.bn = null);
2058
+ pn() {
2059
+ this.qr && (window.removeEventListener("keydown", this.Mn), window.removeEventListener("keyup", this.Rn), this.qr = !1, this.bn.clear(), this.$n = null, this.xn = null);
2025
2060
  }
2026
- pn(t) {
2027
- this.Mn = t;
2061
+ vn(t) {
2062
+ this.Fn = t;
2028
2063
  }
2029
- mn(t) {
2030
- this.Rn = t;
2064
+ gn(t) {
2065
+ this.Sn = t;
2031
2066
  }
2032
- An(t) {
2033
- const e = this.zn(t), i = this.Cn.get(t) || this.Cn.get(e);
2067
+ kn(t) {
2068
+ const e = this.En(t), i = this.bn.get(t) || this.bn.get(e);
2034
2069
  return (i == null ? void 0 : i.isPressed) || !1;
2035
2070
  }
2036
- En() {
2037
- return this.wn;
2038
- }
2039
2071
  Pn() {
2040
- return this.bn;
2072
+ return this.$n;
2073
+ }
2074
+ Ln() {
2075
+ return this.xn;
2041
2076
  }
2042
- kn() {
2077
+ Dn() {
2043
2078
  const t = [];
2044
- for (const [e, i] of this.Cn) i.isPressed && t.push(e);
2079
+ for (const [e, i] of this.bn) i.isPressed && t.push(e);
2045
2080
  return t;
2046
2081
  }
2047
- Ln() {
2048
- return { ctrl: this.An("Control"), shift: this.An("Shift"), alt: this.An("Alt"), meta: this.An("Meta") };
2082
+ Bn() {
2083
+ return { ctrl: this.kn("Control"), shift: this.kn("Shift"), alt: this.kn("Alt"), meta: this.kn("Meta") };
2049
2084
  }
2050
- Dn() {
2051
- this.Cn.clear(), this.wn = null, this.bn = null;
2085
+ Gn() {
2086
+ this.bn.clear(), this.$n = null, this.xn = null;
2052
2087
  }
2053
- Sn(t) {
2088
+ An(t) {
2054
2089
  const e = t.key, i = Date.now();
2055
- this.Cn.has(e) || this.Cn.set(e, { isPressed: !1, lastPressTime: 0, lastReleaseTime: 0 });
2056
- const s = this.Cn.get(e);
2057
- if (!s.isPressed && (s.isPressed = !0, s.lastPressTime = i, this.wn = e, this.Mn)) {
2090
+ this.bn.has(e) || this.bn.set(e, { isPressed: !1, lastPressTime: 0, lastReleaseTime: 0 });
2091
+ const s = this.bn.get(e);
2092
+ if (!s.isPressed && (s.isPressed = !0, s.lastPressTime = i, this.$n = e, this.Fn)) {
2058
2093
  const r = { key: e, keyCode: t.keyCode, ctrlKey: t.ctrlKey, shiftKey: t.shiftKey, altKey: t.altKey, metaKey: t.metaKey, isPressed: !0, originalEvent: t };
2059
- this.Mn(r);
2094
+ this.Fn(r);
2060
2095
  }
2061
2096
  }
2062
- Tn(t) {
2097
+ zn(t) {
2063
2098
  const e = t.key, i = Date.now();
2064
- this.Cn.has(e) || this.Cn.set(e, { isPressed: !1, lastPressTime: 0, lastReleaseTime: 0 });
2065
- const s = this.Cn.get(e);
2066
- if (s.isPressed = !1, s.lastReleaseTime = i, this.bn = e, this.Rn) {
2099
+ this.bn.has(e) || this.bn.set(e, { isPressed: !1, lastPressTime: 0, lastReleaseTime: 0 });
2100
+ const s = this.bn.get(e);
2101
+ if (s.isPressed = !1, s.lastReleaseTime = i, this.xn = e, this.Sn) {
2067
2102
  const r = { key: e, keyCode: t.keyCode, ctrlKey: t.ctrlKey, shiftKey: t.shiftKey, altKey: t.altKey, metaKey: t.metaKey, isPressed: !1, originalEvent: t };
2068
- this.Rn(r);
2103
+ this.Sn(r);
2069
2104
  }
2070
2105
  }
2071
- zn(t) {
2072
- return this.Fn[t] || t.toLowerCase();
2106
+ En(t) {
2107
+ return this.Tn[t] || t.toLowerCase();
2073
2108
  }
2074
2109
  }
2075
- const jt = Object.freeze(Object.defineProperty({ __proto__: null, KeyboardManager: nt }, Symbol.toStringTag, { value: "Module" }));
2110
+ const Ht = Object.freeze(Object.defineProperty({ __proto__: null, KeyboardManager: nt }, Symbol.toStringTag, { value: "Module" }));
2076
2111
  class ot {
2077
2112
  constructor(t, e) {
2078
- h(this, "tr");
2079
- h(this, "Bn");
2080
- h(this, "Dr");
2081
- h(this, "Gn", /* @__PURE__ */ new Map());
2082
- h(this, "In", /* @__PURE__ */ new Map());
2113
+ h(this, "er");
2114
+ h(this, "In");
2115
+ h(this, "Gr");
2083
2116
  h(this, "On", /* @__PURE__ */ new Map());
2084
- h(this, "Wn", null);
2085
- h(this, "Hn");
2086
- h(this, "Kn");
2117
+ h(this, "Wn", /* @__PURE__ */ new Map());
2118
+ h(this, "Hn", /* @__PURE__ */ new Map());
2119
+ h(this, "Kn", null);
2087
2120
  h(this, "Xn");
2088
2121
  h(this, "Nn");
2089
- h(this, "Yn");
2090
2122
  h(this, "jn");
2091
- h(this, "jr", !1);
2123
+ h(this, "Yn");
2092
2124
  h(this, "Vn");
2093
2125
  h(this, "qn");
2126
+ h(this, "qr", !1);
2094
2127
  h(this, "Zn");
2095
2128
  h(this, "Jn");
2096
2129
  h(this, "Qn");
@@ -2099,67 +2132,63 @@ class ot {
2099
2132
  h(this, "io");
2100
2133
  h(this, "ro");
2101
2134
  h(this, "no");
2102
- h(this, "oo", 320);
2103
- h(this, "ho", 350);
2104
- h(this, "ao", 10);
2105
- h(this, "co", 550);
2106
- h(this, "lo", 14);
2107
- h(this, "uo", 48);
2108
- h(this, "fo", 650);
2109
- h(this, "do", 0.02);
2110
- h(this, "_o", 2);
2111
- h(this, "po", 600);
2112
- h(this, "mo", 0);
2113
- h(this, "vo", null);
2114
- this.tr = t, this.Bn = e;
2115
- const i = this.tr.canvas;
2116
- this.Hn = i.style.touchAction, this.Kn = i.style.userSelect, i.style.touchAction || (i.style.touchAction = "none"), i.style.userSelect || (i.style.userSelect = "none");
2117
- }
2118
- Xi(t) {
2119
- this.Dr = t, this.yo();
2120
- }
2121
- nn() {
2122
- if (this.jr) return;
2123
- const t = this.tr.canvas;
2124
- this.Xn = (e) => {
2125
- this.Co(e);
2126
- }, this.Nn = (e) => {
2127
- this.wo(e);
2128
- }, this.Yn = (e) => {
2135
+ h(this, "oo");
2136
+ h(this, "ho");
2137
+ h(this, "ao", 320);
2138
+ h(this, "co", 350);
2139
+ h(this, "lo", 10);
2140
+ h(this, "uo", 550);
2141
+ h(this, "fo", 14);
2142
+ h(this, "do", 48);
2143
+ h(this, "_o", 650);
2144
+ h(this, "po", 0.02);
2145
+ h(this, "mo", 2);
2146
+ h(this, "vo", 600);
2147
+ h(this, "yo", 0);
2148
+ h(this, "Co", null);
2149
+ this.er = t, this.In = e;
2150
+ const i = this.er.canvas;
2151
+ this.Xn = i.style.touchAction, this.Nn = i.style.userSelect, i.style.touchAction || (i.style.touchAction = "none"), i.style.userSelect || (i.style.userSelect = "none");
2152
+ }
2153
+ Ni(t) {
2154
+ this.Gr = t, this.wo();
2155
+ }
2156
+ an() {
2157
+ if (this.qr) return;
2158
+ const t = this.er.canvas;
2159
+ this.jn = (e) => {
2129
2160
  this.bo(e);
2130
- }, this.jn = (e) => {
2161
+ }, this.Yn = (e) => {
2131
2162
  this.$o(e);
2132
- }, t.addEventListener("touchstart", this.Xn, { passive: !1 }), t.addEventListener("touchmove", this.Nn, { passive: !1 }), t.addEventListener("touchend", this.Yn, { passive: !1 }), t.addEventListener("touchcancel", this.jn, { passive: !1 }), this.jr = !0;
2133
- }
2134
- dn() {
2135
- if (!this.jr) return;
2136
- const t = this.tr.canvas;
2137
- t.removeEventListener("touchstart", this.Xn), t.removeEventListener("touchmove", this.Nn), t.removeEventListener("touchend", this.Yn), t.removeEventListener("touchcancel", this.jn), this.jr = !1, this.Wn = null, this.Gn.clear(), this.In.clear(), this.On.forEach((e) => {
2163
+ }, this.Vn = (e) => {
2164
+ this.xo(e);
2165
+ }, this.qn = (e) => {
2166
+ this.Mo(e);
2167
+ }, t.addEventListener("touchstart", this.jn, { passive: !1 }), t.addEventListener("touchmove", this.Yn, { passive: !1 }), t.addEventListener("touchend", this.Vn, { passive: !1 }), t.addEventListener("touchcancel", this.qn, { passive: !1 }), this.qr = !0;
2168
+ }
2169
+ pn() {
2170
+ if (!this.qr) return;
2171
+ const t = this.er.canvas;
2172
+ t.removeEventListener("touchstart", this.jn), t.removeEventListener("touchmove", this.Yn), t.removeEventListener("touchend", this.Vn), t.removeEventListener("touchcancel", this.qn), this.qr = !1, this.Kn = null, this.On.clear(), this.Wn.clear(), this.Hn.forEach((e) => {
2138
2173
  e.longPressTimer !== null && window.clearTimeout(e.longPressTimer);
2139
- }), this.On.clear(), this.vo = null, this.mo = 0, t.style.touchAction = this.Hn, t.style.userSelect = this.Kn;
2174
+ }), this.Hn.clear(), this.Co = null, this.yo = 0, t.style.touchAction = this.Xn, t.style.userSelect = this.Nn;
2140
2175
  }
2141
- yo() {
2142
- if (!this.Dr || this.Gn.size === 0) return;
2176
+ wo() {
2177
+ if (!this.Gr || this.On.size === 0) return;
2143
2178
  const t = /* @__PURE__ */ new Map();
2144
- for (const e of this.Gn.values()) {
2145
- const i = this.xo(e.clientX, e.clientY, e.id, e);
2179
+ for (const e of this.On.values()) {
2180
+ const i = this.Ro(e.clientX, e.clientY, e.id, e);
2146
2181
  t.set(e.id, i);
2147
2182
  }
2148
- this.Gn = t;
2149
- }
2150
- Mo() {
2151
- return Array.from(this.Gn.values()).map((t) => ({ ...t }));
2183
+ this.On = t;
2152
2184
  }
2153
- Ro(t) {
2154
- this.Vn = t;
2185
+ Fo() {
2186
+ return Array.from(this.On.values()).map((t) => ({ ...t }));
2155
2187
  }
2156
- vn(t) {
2157
- this.qn = t;
2158
- }
2159
- Fo(t) {
2188
+ So(t) {
2160
2189
  this.Zn = t;
2161
2190
  }
2162
- So(t) {
2191
+ yn(t) {
2163
2192
  this.Jn = t;
2164
2193
  }
2165
2194
  To(t) {
@@ -2171,127 +2200,133 @@ class ot {
2171
2200
  zo(t) {
2172
2201
  this.eo = t;
2173
2202
  }
2174
- Eo(t) {
2203
+ ko(t) {
2175
2204
  this.io = t;
2176
2205
  }
2177
- Po(t) {
2206
+ Eo(t) {
2178
2207
  this.ro = t;
2179
2208
  }
2180
- ko(t) {
2209
+ Po(t) {
2181
2210
  this.no = t;
2182
2211
  }
2183
- Co(t) {
2212
+ Lo(t) {
2213
+ this.oo = t;
2214
+ }
2215
+ Do(t) {
2216
+ this.ho = t;
2217
+ }
2218
+ bo(t) {
2184
2219
  var s;
2185
- if (!this.Dr) return;
2186
- t.preventDefault(), (s = this.Bn) == null || s.tn(this.po);
2187
- const e = performance.now(), i = this.Lo(t.changedTouches);
2220
+ if (!this.Gr) return;
2221
+ t.preventDefault(), (s = this.In) == null || s.en(this.vo);
2222
+ const e = performance.now(), i = this.Bo(t.changedTouches);
2188
2223
  for (const r of i) {
2189
- const n = this.Gn.get(r.id);
2190
- n && this.In.set(r.id, this.Do(n)), this.Gn.set(r.id, r);
2224
+ const n = this.On.get(r.id);
2225
+ n && this.Wn.set(r.id, this.Go(n)), this.On.set(r.id, r);
2191
2226
  const o = { id: r.id, startPosition: r, lastPosition: r, startTime: e, lastTime: e, longPressTimer: null, longPressFired: !1 };
2192
- this.eo && (o.longPressTimer = window.setTimeout(() => {
2193
- const c = this.Gn.get(r.id);
2194
- c && (o.longPressFired = !0, this.eo({ touch: this.Do(c), duration: performance.now() - o.startTime, originalEvent: t }));
2195
- }, this.co)), this.On.set(r.id, o), this.Vn && this.Vn(this.Bo(r, t, void 0, e));
2227
+ this.ro && (o.longPressTimer = window.setTimeout(() => {
2228
+ const c = this.On.get(r.id);
2229
+ c && (o.longPressFired = !0, this.ro({ touch: this.Go(c), duration: performance.now() - o.startTime, originalEvent: t }));
2230
+ }, this.uo)), this.Hn.set(r.id, o), this.Zn && this.Zn(this.Io(r, t, void 0, e));
2196
2231
  }
2197
- this.Gn.size === 2 && this.Go();
2232
+ this.On.size === 2 && this.Oo();
2198
2233
  }
2199
- wo(t) {
2234
+ $o(t) {
2200
2235
  var s;
2201
- if (!this.Dr) return;
2202
- t.preventDefault(), (s = this.Bn) == null || s.tn(this.po);
2203
- const e = performance.now(), i = this.Lo(t.changedTouches);
2236
+ if (!this.Gr) return;
2237
+ t.preventDefault(), (s = this.In) == null || s.en(this.vo);
2238
+ const e = performance.now(), i = this.Bo(t.changedTouches);
2204
2239
  for (const r of i) {
2205
- const n = this.Gn.get(r.id), o = n ? this.Do(n) : void 0;
2206
- o && this.In.set(r.id, o), this.Gn.set(r.id, r);
2207
- const c = this.On.get(r.id);
2208
- c && (c.lastPosition = r, c.lastTime = e, o) && this.Io(o, r, !0) > this.lo && c.longPressTimer !== null && (window.clearTimeout(c.longPressTimer), c.longPressTimer = null), this.qn && this.qn(this.Bo(r, t, o, e));
2240
+ const n = this.On.get(r.id), o = n ? this.Go(n) : void 0;
2241
+ o && this.Wn.set(r.id, o), this.On.set(r.id, r);
2242
+ const c = this.Hn.get(r.id);
2243
+ c && (c.lastPosition = r, c.lastTime = e, o) && this.Wo(o, r, !0) > this.fo && c.longPressTimer !== null && (window.clearTimeout(c.longPressTimer), c.longPressTimer = null), this.Jn && this.Jn(this.Io(r, t, o, e));
2209
2244
  }
2210
- this.Gn.size === 2 ? this.Oo(t) : this.Wn = null;
2245
+ this.On.size === 2 ? this.Ho(t) : this.Kn = null;
2211
2246
  }
2212
- bo(t) {
2213
- if (!this.Dr) return;
2247
+ xo(t) {
2248
+ if (!this.Gr) return;
2214
2249
  t.preventDefault();
2215
- const e = performance.now(), i = this.Lo(t.changedTouches);
2250
+ const e = performance.now(), i = this.Bo(t.changedTouches);
2216
2251
  for (const s of i) {
2217
- const r = this.Gn.get(s.id), n = r ? this.Do(r) : void 0, o = this.On.get(s.id);
2218
- o && o.longPressTimer !== null && (window.clearTimeout(o.longPressTimer), o.longPressTimer = null), this.Zn && this.Zn(this.Bo(s, t, n, e)), o && this.Wo(o, t), this.On.delete(s.id), this.In.delete(s.id), this.Gn.delete(s.id);
2252
+ const r = this.On.get(s.id), n = r ? this.Go(r) : void 0, o = this.Hn.get(s.id);
2253
+ o && o.longPressTimer !== null && (window.clearTimeout(o.longPressTimer), o.longPressTimer = null), this.Qn && this.Qn(this.Io(s, t, n, e)), o && this.Ko(o, t), this.Hn.delete(s.id), this.Wn.delete(s.id), this.On.delete(s.id);
2219
2254
  }
2220
- this.Gn.size < 2 && (this.Wn = null);
2255
+ this.On.size < 2 && (this.Kn = null);
2221
2256
  }
2222
- $o(t) {
2223
- if (!this.Dr) return;
2257
+ Mo(t) {
2258
+ if (!this.Gr) return;
2224
2259
  t.preventDefault();
2225
- const e = performance.now(), i = this.Lo(t.changedTouches);
2260
+ const e = performance.now(), i = this.Bo(t.changedTouches);
2226
2261
  for (const s of i) {
2227
- const r = this.Gn.get(s.id), n = r ? this.Do(r) : void 0, o = this.On.get(s.id);
2228
- o && o.longPressTimer !== null && (window.clearTimeout(o.longPressTimer), o.longPressTimer = null), this.Jn && this.Jn(this.Bo(s, t, n, e)), this.On.delete(s.id), this.In.delete(s.id), this.Gn.delete(s.id);
2262
+ const r = this.On.get(s.id), n = r ? this.Go(r) : void 0, o = this.Hn.get(s.id);
2263
+ o && o.longPressTimer !== null && (window.clearTimeout(o.longPressTimer), o.longPressTimer = null), this.so && this.so(this.Io(s, t, n, e)), this.Hn.delete(s.id), this.Wn.delete(s.id), this.On.delete(s.id);
2229
2264
  }
2230
- this.Gn.size < 2 && (this.Wn = null);
2265
+ this.On.size < 2 && (this.Kn = null);
2231
2266
  }
2232
- Lo(t) {
2267
+ Bo(t) {
2233
2268
  const e = [];
2234
2269
  for (let i = 0; i < t.length; i += 1) {
2235
2270
  const s = t.item(i);
2236
- s && e.push(this.Ho(s));
2271
+ s && e.push(this.Xo(s));
2237
2272
  }
2238
2273
  return e;
2239
2274
  }
2240
- Ho(t) {
2241
- return this.xo(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 });
2275
+ Xo(t) {
2276
+ return this.Ro(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
2277
  }
2243
- xo(t, e, i, s) {
2244
- const r = this.tr.canvas, n = r.getBoundingClientRect(), o = t - n.left, c = e - n.top, l = r.width / n.width, f = c * (r.height / n.height), u = o * l - this.Dr.offsetX, m = f - this.Dr.offsetY, v = Math.floor(u / this.Dr.cellWidth), g = Math.floor(m / this.Dr.cellHeight), d = v >= 0 && v < this.Dr.cols && g >= 0 && g < this.Dr.rows;
2278
+ Ro(t, e, i, s) {
2279
+ const r = this.er.canvas, n = r.getBoundingClientRect(), o = t - n.left, c = e - n.top, l = r.width / n.width, f = c * (r.height / n.height), u = o * l - this.Gr.offsetX, m = f - this.Gr.offsetY, v = Math.floor(u / this.Gr.cellWidth), g = Math.floor(m / this.Gr.cellHeight), d = v >= 0 && v < this.Gr.cols && g >= 0 && g < this.Gr.rows;
2245
2280
  return { id: i, x: d ? v : -1, y: d ? g : -1, clientX: t, clientY: e, pressure: s.pressure, radiusX: s.radiusX, radiusY: s.radiusY, rotationAngle: s.rotationAngle };
2246
2281
  }
2247
- Bo(t, e, i, s) {
2248
- const r = this.On.get(t.id), n = Array.from(this.In.values()).map((l) => this.Do(l)), o = Array.from(this.Gn.values()).map((l) => this.Do(l)), c = this.Lo(e.changedTouches);
2249
- return { touch: this.Do(t), previousTouch: i ? this.Do(i) : void 0, touches: o, previousTouches: n, changedTouches: c, deltaTime: r ? s - r.lastTime : 0, originalEvent: e };
2282
+ Io(t, e, i, s) {
2283
+ const r = this.Hn.get(t.id), n = Array.from(this.Wn.values()).map((l) => this.Go(l)), o = Array.from(this.On.values()).map((l) => this.Go(l)), c = this.Bo(e.changedTouches);
2284
+ 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
2285
  }
2251
- Go() {
2252
- if (this.Gn.size !== 2) return void (this.Wn = null);
2253
- const t = Array.from(this.Gn.values()), [e, i] = t, s = this.Io(e, i, !1), r = this.Ko(e, i);
2254
- this.Wn = { ids: [e.id, i.id], initialDistance: Math.max(s, 1e-4), initialAngle: r, lastScale: 1, lastRotation: 0 };
2286
+ Oo() {
2287
+ if (this.On.size !== 2) return void (this.Kn = null);
2288
+ const t = Array.from(this.On.values()), [e, i] = t, s = this.Wo(e, i, !1), r = this.No(e, i);
2289
+ this.Kn = { ids: [e.id, i.id], initialDistance: Math.max(s, 1e-4), initialAngle: r, lastScale: 1, lastRotation: 0 };
2255
2290
  }
2256
- Oo(t) {
2257
- if (this.Wn || this.Go(), !this.Wn) return;
2258
- const [e, i] = this.Wn.ids, s = this.Gn.get(e), r = this.Gn.get(i);
2291
+ Ho(t) {
2292
+ if (this.Kn || this.Oo(), !this.Kn) return;
2293
+ const [e, i] = this.Kn.ids, s = this.On.get(e), r = this.On.get(i);
2259
2294
  if (!s || !r) return;
2260
- const n = this.Io(s, r, !1) / this.Wn.initialDistance, o = n - this.Wn.lastScale;
2261
- this.ro && Math.abs(o) > this.do && (this.ro({ touches: [this.Do(s), this.Do(r)], scale: n, deltaScale: o, center: this.Xo(s, r), originalEvent: t }), this.Wn.lastScale = n);
2262
- let c = this.Ko(s, r) - this.Wn.initialAngle;
2295
+ const n = this.Wo(s, r, !1) / this.Kn.initialDistance, o = n - this.Kn.lastScale;
2296
+ this.oo && Math.abs(o) > this.po && (this.oo({ touches: [this.Go(s), this.Go(r)], scale: n, deltaScale: o, center: this.jo(s, r), originalEvent: t }), this.Kn.lastScale = n);
2297
+ let c = this.No(s, r) - this.Kn.initialAngle;
2263
2298
  c = (c + 180) % 360 - 180;
2264
- const l = c - this.Wn.lastRotation;
2265
- this.no && Math.abs(l) > this._o && (this.no({ touches: [this.Do(s), this.Do(r)], rotation: c, deltaRotation: l, center: this.Xo(s, r), originalEvent: t }), this.Wn.lastRotation = c);
2299
+ const l = c - this.Kn.lastRotation;
2300
+ this.ho && Math.abs(l) > this.mo && (this.ho({ touches: [this.Go(s), this.Go(r)], rotation: c, deltaRotation: l, center: this.jo(s, r), originalEvent: t }), this.Kn.lastRotation = c);
2266
2301
  }
2267
- Xo(t, e) {
2268
- const i = (t.clientX + e.clientX) / 2, s = (t.clientY + e.clientY) / 2, r = this.xo(i, s, -1, { id: -1, x: -1, y: -1, clientX: i, clientY: s });
2302
+ jo(t, e) {
2303
+ const i = (t.clientX + e.clientX) / 2, s = (t.clientY + e.clientY) / 2, r = this.Ro(i, s, -1, { id: -1, x: -1, y: -1, clientX: i, clientY: s });
2269
2304
  return { x: r.x, y: r.y };
2270
2305
  }
2271
- Wo(t, e) {
2272
- const i = performance.now(), s = i - t.startTime, r = this.Io(t.startPosition, t.lastPosition, !0);
2273
- if (!t.longPressFired && s <= this.oo && r <= this.ao)
2274
- this.No(t.lastPosition, i) && this.so ? this.so({ touch: this.Do(t.lastPosition), taps: 2, originalEvent: e }) : this.Qn && this.Qn({ touch: this.Do(t.lastPosition), taps: 1, originalEvent: e });
2275
- else if (!t.longPressFired && s <= this.fo && r >= this.uo) {
2306
+ Ko(t, e) {
2307
+ const i = performance.now(), s = i - t.startTime, r = this.Wo(t.startPosition, t.lastPosition, !0);
2308
+ if (!t.longPressFired && s <= this.ao && r <= this.lo)
2309
+ this.Yo(t.lastPosition, i) && this.io ? this.io({ touch: this.Go(t.lastPosition), taps: 2, originalEvent: e }) : this.eo && this.eo({ touch: this.Go(t.lastPosition), taps: 1, originalEvent: e });
2310
+ else if (!t.longPressFired && s <= this._o && r >= this.do) {
2276
2311
  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.io && this.io({ touch: this.Do(t.lastPosition), direction: c, distance: o, velocity: l, originalEvent: e });
2312
+ this.no && this.no({ touch: this.Go(t.lastPosition), direction: c, distance: o, velocity: l, originalEvent: e });
2278
2313
  }
2279
- this.mo = i, this.vo = this.Do(t.lastPosition);
2314
+ this.yo = i, this.Co = this.Go(t.lastPosition);
2280
2315
  }
2281
- No(t, e) {
2282
- return !this.vo || e - this.mo > this.ho ? !1 : this.Io(t, this.vo, !0) <= this.ao;
2316
+ Yo(t, e) {
2317
+ return !this.Co || e - this.yo > this.co ? !1 : this.Wo(t, this.Co, !0) <= this.lo;
2283
2318
  }
2284
- Do(t) {
2319
+ Go(t) {
2285
2320
  return { ...t };
2286
2321
  }
2287
- Io(t, e, i) {
2322
+ Wo(t, e, i) {
2288
2323
  return i ? Math.hypot(t.clientX - e.clientX, t.clientY - e.clientY) : Math.hypot(t.x - e.x, t.y - e.y);
2289
2324
  }
2290
- Ko(t, e) {
2325
+ No(t, e) {
2291
2326
  return 180 * Math.atan2(e.clientY - t.clientY, e.clientX - t.clientX) / Math.PI;
2292
2327
  }
2293
2328
  }
2294
- const Ht = Object.freeze(Object.defineProperty({ __proto__: null, TouchManager: ot }, Symbol.toStringTag, { value: "Module" })), Vt = (a) => class extends a {
2329
+ const Vt = Object.freeze(Object.defineProperty({ __proto__: null, TouchManager: ot }, Symbol.toStringTag, { value: "Module" })), $t = (a) => class extends a {
2295
2330
  rotate(t = 0, e = 0, i = 0) {
2296
2331
  this.xt.state.st(t), this.xt.state.et(e), this.xt.state.it(i);
2297
2332
  }
@@ -2326,7 +2361,7 @@ const Ht = Object.freeze(Object.defineProperty({ __proto__: null, TouchManager:
2326
2361
  this.xt.qe(t, e, i, s);
2327
2362
  }
2328
2363
  char(t) {
2329
- this.xt.state.rt(this.Ei.Ai(t));
2364
+ this.xt.state.rt(this.ki.Ai(t));
2330
2365
  }
2331
2366
  charColor(t, e, i, s = 255) {
2332
2367
  this.xt.state.nt(t, e, i, s);
@@ -2356,7 +2391,7 @@ const Ht = Object.freeze(Object.defineProperty({ __proto__: null, TouchManager:
2356
2391
  this.xt.Ne(t, e, i, s, r, n);
2357
2392
  }
2358
2393
  bezierCurve(t, e, i, s, r, n, o, c) {
2359
- this.xt.Ye(t, e, i, s, r, n, o, c);
2394
+ this.xt.je(t, e, i, s, r, n, o, c);
2360
2395
  }
2361
2396
  arc(t, e, i, s, r, n) {
2362
2397
  this.xt.Ve(t, e, i, s, r, n);
@@ -2374,7 +2409,7 @@ const Ht = Object.freeze(Object.defineProperty({ __proto__: null, TouchManager:
2374
2409
  return this.xt.hs(t);
2375
2410
  }
2376
2411
  createFramebuffer(t) {
2377
- return this.xt.je(t.width, t.height, 5, { filter: "nearest", wrap: "clamp", format: "rgba", type: "unsigned_byte" });
2412
+ return this.xt.Ye(t.width, t.height, 5, { filter: "nearest", wrap: "clamp", format: "rgba", type: "unsigned_byte" });
2378
2413
  }
2379
2414
  image(t, e, i, s, r) {
2380
2415
  if (t.textures) {
@@ -2382,295 +2417,364 @@ const Ht = Object.freeze(Object.defineProperty({ __proto__: null, TouchManager:
2382
2417
  this.xt.Ge(n, e, i, s ?? n.width, r ?? n.height);
2383
2418
  } else {
2384
2419
  const n = t;
2385
- this.xt.Ie(n, e, i, s ?? Math.floor(this.Dr.cols / 2), r ?? Math.floor(this.Dr.rows / 2));
2420
+ this.xt.Ie(n, e, i, s ?? Math.floor(this.Gr.cols / 2), r ?? Math.floor(this.Gr.rows / 2));
2386
2421
  }
2387
2422
  }
2388
2423
  async loadImage(t) {
2389
- if (typeof t != "string") return N.Mr(this.xt, t, (s) => this.Ei.zi(s));
2424
+ if (typeof t != "string") return N.Fr(this.xt, t, (s) => this.ki.zi(s));
2390
2425
  const e = t, i = await new Promise((s, r) => {
2391
2426
  const n = new Image();
2392
2427
  n.crossOrigin = "anonymous", n.onload = () => s(n), n.onerror = (o) => r(o), n.src = e;
2393
2428
  });
2394
- return N.Mr(this.xt, i, (s) => this.Ei.zi(s));
2429
+ return N.Fr(this.xt, i, (s) => this.ki.zi(s));
2395
2430
  }
2396
- }, $t = (a) => class extends a {
2431
+ }, Kt = (a) => class extends a {
2397
2432
  async loadFont(t) {
2398
- return this.Ei.Vi(t).then(() => {
2399
- const e = this.Ei.maxGlyphDimensions;
2400
- this.Dr.rr(e.width, e.height), this.Yo.resize(this.Dr.cols, this.Dr.rows), this.xt.Ze(), this.Bn.rn();
2433
+ return this.ki.qi(t).then(() => {
2434
+ const e = this.ki.maxGlyphDimensions;
2435
+ this.Gr.hr(e.width, e.height), this.Vo.resize(this.Gr.cols, this.Gr.rows), this.xt.Ze(), this.In.hn();
2401
2436
  });
2402
2437
  }
2403
2438
  fontSize(t) {
2404
- if (!z.v(typeof t == "number" && t > 0, "Font size must be a positive number greater than 0.", { method: "fontSize", providedValue: t }) || this.Ei.fontSize === t) return;
2405
- this.Ei.ji(t);
2406
- const e = this.Ei.maxGlyphDimensions;
2407
- this.Dr.rr(e.width, e.height), this.Yo.resize(this.Dr.cols, this.Dr.rows), this.xt.Ze(), this.Bn.rn();
2439
+ if (!k.v(typeof t == "number" && t > 0, "Font size must be a positive number greater than 0.", { method: "fontSize", providedValue: t }) || this.ki.fontSize === t) return;
2440
+ this.ki.Vi(t);
2441
+ const e = this.ki.maxGlyphDimensions;
2442
+ this.Gr.hr(e.width, e.height), this.Vo.resize(this.Gr.cols, this.Gr.rows), this.xt.Ze(), this.In.hn();
2408
2443
  }
2409
2444
  glyphColor(t) {
2410
- return this.Ei.Ai(t);
2445
+ return this.ki.Ai(t);
2411
2446
  }
2412
2447
  glyphColors(t) {
2413
- return this.Ei.zi(t);
2448
+ return this.ki.zi(t);
2414
2449
  }
2415
2450
  }, qt = (a) => class extends a {
2416
2451
  get frameCount() {
2417
- return this.jo.frameCount;
2452
+ return this.qo.frameCount;
2418
2453
  }
2419
2454
  set frameCount(t) {
2420
- this.jo.frameCount = t;
2455
+ this.qo.frameCount = t;
2421
2456
  }
2422
2457
  frameRate(t) {
2423
- return t === void 0 ? this.jo.currentFrameRate : this.jo.frameRate(t, () => this.Vo());
2458
+ return t === void 0 ? this.qo.currentFrameRate : this.qo.frameRate(t, () => this.Zo());
2424
2459
  }
2425
2460
  noLoop() {
2426
- this.jo.pause();
2461
+ this.qo.pause();
2427
2462
  }
2428
2463
  loop() {
2429
- this.jo.resume(() => this.Vo());
2464
+ this.qo.resume(() => this.Zo());
2430
2465
  }
2431
2466
  redraw(t = 1) {
2432
- if (z.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.Vo();
2467
+ if (k.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.Zo();
2433
2468
  }
2434
2469
  isLooping() {
2435
- return this.jo.isLooping;
2470
+ return this.qo.isLooping;
2436
2471
  }
2437
- }, Kt = (a) => class extends a {
2472
+ }, jt = (a) => class extends a {
2438
2473
  constructor(...t) {
2439
2474
  super(...t);
2440
2475
  }
2441
2476
  mouseClicked(t) {
2442
- this.Bn._n(t);
2477
+ this.In.mn(t);
2443
2478
  }
2444
2479
  mousePressed(t) {
2445
- this.Bn.pn(t);
2480
+ this.In.vn(t);
2446
2481
  }
2447
2482
  mouseReleased(t) {
2448
- this.Bn.mn(t);
2483
+ this.In.gn(t);
2449
2484
  }
2450
2485
  mouseMoved(t) {
2451
- this.Bn.vn(t);
2486
+ this.In.yn(t);
2452
2487
  }
2453
2488
  mouseScrolled(t) {
2454
- this.Bn.gn(t);
2489
+ this.In.Cn(t);
2455
2490
  }
2456
2491
  get mouse() {
2457
- return this.Bn.yn();
2492
+ return this.In.wn();
2458
2493
  }
2459
2494
  cursor(t) {
2460
- this.Bn.en(t);
2495
+ this.In.nn(t);
2461
2496
  }
2462
- }, Zt = (a) => class extends a {
2497
+ }, Jt = (a) => class extends a {
2463
2498
  constructor(...t) {
2464
2499
  super(...t);
2465
2500
  }
2466
2501
  touchStarted(t) {
2467
- this.qo.Ro(t);
2502
+ this.Jo.So(t);
2468
2503
  }
2469
2504
  touchMoved(t) {
2470
- this.qo.vn(t);
2505
+ this.Jo.yn(t);
2471
2506
  }
2472
2507
  touchEnded(t) {
2473
- this.qo.Fo(t);
2508
+ this.Jo.To(t);
2474
2509
  }
2475
2510
  touchCancelled(t) {
2476
- this.qo.So(t);
2511
+ this.Jo.Ao(t);
2477
2512
  }
2478
2513
  tap(t) {
2479
- this.qo.To(t);
2514
+ this.Jo.zo(t);
2480
2515
  }
2481
2516
  doubleTap(t) {
2482
- this.qo.Ao(t);
2517
+ this.Jo.ko(t);
2483
2518
  }
2484
2519
  longPress(t) {
2485
- this.qo.zo(t);
2520
+ this.Jo.Eo(t);
2486
2521
  }
2487
2522
  swipe(t) {
2488
- this.qo.Eo(t);
2523
+ this.Jo.Po(t);
2489
2524
  }
2490
2525
  pinch(t) {
2491
- this.qo.Po(t);
2526
+ this.Jo.Lo(t);
2492
2527
  }
2493
2528
  rotateGesture(t) {
2494
- this.qo.ko(t);
2529
+ this.Jo.Do(t);
2495
2530
  }
2496
2531
  get touches() {
2497
- return this.qo.Mo();
2532
+ return this.Jo.Fo();
2498
2533
  }
2499
- }, Jt = (a) => class extends a {
2534
+ }, Zt = (a) => class extends a {
2500
2535
  constructor(...t) {
2501
2536
  super(...t);
2502
2537
  }
2503
2538
  keyPressed(t) {
2504
- this.Zo.pn(t);
2539
+ this.Qo.vn(t);
2505
2540
  }
2506
2541
  keyReleased(t) {
2507
- this.Zo.mn(t);
2542
+ this.Qo.gn(t);
2508
2543
  }
2509
2544
  isKeyPressed(t) {
2510
- return this.Zo.An(t);
2545
+ return this.Qo.kn(t);
2511
2546
  }
2512
2547
  get lastKeyPressed() {
2513
- return this.Zo.En();
2548
+ return this.Qo.Pn();
2514
2549
  }
2515
2550
  get lastKeyReleased() {
2516
- return this.Zo.Pn();
2551
+ return this.Qo.Ln();
2517
2552
  }
2518
2553
  get pressedKeys() {
2519
- return this.Zo.kn();
2554
+ return this.Qo.Dn();
2520
2555
  }
2521
2556
  get modifierState() {
2522
- return this.Zo.Ln();
2557
+ return this.Qo.Bn();
2523
2558
  }
2524
2559
  };
2525
2560
  class Qt {
2561
+ constructor(t) {
2562
+ h(this, "th");
2563
+ h(this, "sh", /* @__PURE__ */ new Map());
2564
+ h(this, "eh", []);
2565
+ h(this, "ih", /* @__PURE__ */ new Map());
2566
+ h(this, "rh", /* @__PURE__ */ new Map());
2567
+ this.th = t;
2568
+ }
2569
+ async installMany(t) {
2570
+ for (const e of t) await this.use(e);
2571
+ }
2572
+ async use(t) {
2573
+ if (this.sh.has(t.name)) return void console.warn(`[textmode.js] Plugin "${t.name}" is already installed.`);
2574
+ const e = this.nh(t.name);
2575
+ try {
2576
+ await t.install(this.th, e);
2577
+ } catch (i) {
2578
+ throw this.oh(t.name), i;
2579
+ }
2580
+ this.sh.set(t.name, t), this.eh.push(t.name);
2581
+ }
2582
+ async unuse(t) {
2583
+ const e = this.sh.get(t);
2584
+ if (!e) return;
2585
+ const i = this.nh(t);
2586
+ if (e.uninstall) try {
2587
+ await e.uninstall(this.th, i);
2588
+ } catch (s) {
2589
+ console.error(`[textmode.js] Error while uninstalling plugin "${t}":`, s);
2590
+ }
2591
+ this.sh.delete(t), this.eh.splice(this.eh.indexOf(t), 1), this.oh(t);
2592
+ }
2593
+ has(t) {
2594
+ return this.sh.has(t);
2595
+ }
2596
+ runPreDrawHooks() {
2597
+ this.hh(this.ih, "preDraw");
2598
+ }
2599
+ runPostDrawHooks() {
2600
+ this.hh(this.rh, "postDraw");
2601
+ }
2602
+ async disposeAll() {
2603
+ const t = [...this.sh.keys()];
2604
+ for (const e of t) await this.unuse(e);
2605
+ }
2606
+ nh(t) {
2607
+ return { ...this.th.ah(), registerPreDrawHook: (e) => this.uh(this.ih, t, e), registerPostDrawHook: (e) => this.uh(this.rh, t, e) };
2608
+ }
2609
+ uh(t, e, i) {
2610
+ const s = t.get(e) ?? /* @__PURE__ */ new Set();
2611
+ return s.add(i), t.set(e, s), () => {
2612
+ const r = t.get(e);
2613
+ r && (r.delete(i), r.size === 0 && t.delete(e));
2614
+ };
2615
+ }
2616
+ oh(t) {
2617
+ this.ih.delete(t), this.rh.delete(t);
2618
+ }
2619
+ hh(t, e) {
2620
+ for (const i of this.eh) {
2621
+ const s = t.get(i);
2622
+ if (s) for (const r of s) try {
2623
+ r();
2624
+ } catch (n) {
2625
+ console.error(`[textmode.js] Plugin "${i}" ${e} hook failed:`, n);
2626
+ }
2627
+ }
2628
+ }
2629
+ }
2630
+ class te {
2526
2631
  constructor() {
2527
2632
  h(this, "xt");
2528
- h(this, "Ei");
2529
- h(this, "tr");
2530
- h(this, "Dr");
2531
- h(this, "jo");
2532
- h(this, "Bn");
2633
+ h(this, "ki");
2634
+ h(this, "er");
2635
+ h(this, "Gr");
2533
2636
  h(this, "qo");
2534
- h(this, "Zo");
2637
+ h(this, "In");
2535
2638
  h(this, "Jo");
2536
- h(this, "Yo");
2537
2639
  h(this, "Qo");
2538
- h(this, "th");
2539
- h(this, "sh");
2640
+ h(this, "fh");
2641
+ h(this, "Vo");
2642
+ h(this, "dh");
2643
+ h(this, "_h");
2644
+ h(this, "ph");
2540
2645
  }
2541
- Vo() {
2646
+ Zo() {
2542
2647
  }
2543
2648
  }
2544
- class te extends function(e, ...i) {
2649
+ class ee extends function(e, ...i) {
2545
2650
  return i.reduce((s, r) => r(s), e);
2546
- }(Qt, Vt, $t, qt, Kt, Zt, Jt) {
2651
+ }(te, $t, Kt, qt, jt, Jt, Zt) {
2547
2652
  constructor(e = {}) {
2548
2653
  var i;
2549
2654
  super();
2550
- h(this, "eh", /* @__PURE__ */ new Map());
2551
- h(this, "ih");
2552
- h(this, "rh", !1);
2553
- h(this, "nh", !1);
2554
- h(this, "oh", () => {
2655
+ h(this, "mh");
2656
+ h(this, "gh");
2657
+ h(this, "yh", !1);
2658
+ h(this, "Ch", !1);
2659
+ h(this, "wh", () => {
2555
2660
  });
2556
- h(this, "hh", () => {
2661
+ h(this, "bh", () => {
2557
2662
  });
2558
- h(this, "ah", () => {
2663
+ h(this, "$h", () => {
2559
2664
  });
2560
- h(this, "uh");
2561
- h(this, "ar");
2562
- h(this, "hr", !1);
2563
- h(this, "fh");
2564
- this.ih = ((i = e.plugins) == null ? void 0 : i.slice()) ?? [], this.hr = e.overlay ?? !1, this.tr = new Xt(e), this.xt = new _t(this.tr.mr()), this.Ei = new Nt(this.xt, e.fontSize ?? 16), this.jo = new Yt(e.frameRate ?? 60), this.Bn = new rt(this.tr), this.qo = new ot(this.tr, this.Bn), this.Zo = new nt(), this.Jo = this.xt.At(), this.Qo = this.xt.rs(), this.dh(e);
2665
+ h(this, "xh");
2666
+ h(this, "lr");
2667
+ h(this, "cr", !1);
2668
+ h(this, "Mh");
2669
+ this.mh = new Qt(this), this.gh = ((i = e.plugins) == null ? void 0 : i.slice()) ?? [], this.cr = e.overlay ?? !1, this.er = new Wt(e), this.xt = new _t(this.er.gr()), this.ki = new Nt(this.xt, e.fontSize ?? 16), this.qo = new Xt(e.frameRate ?? 60), this.In = new rt(this.er), this.Jo = new ot(this.er, this.In), this.Qo = new nt(), this.fh = this.xt.At(), this.dh = this.xt.rs(), this.Rh(e);
2565
2670
  }
2566
- async dh(e) {
2567
- await this.Ei.Xi(e.fontSource);
2568
- const i = this.Ei.maxGlyphDimensions;
2569
- this.Dr = new Wt(this.tr.canvas, i.width, i.height), this.Bn.Xi(this.Dr), this.qo.Xi(this.Dr), this.Yo = this.xt.je(this.Dr.cols, this.Dr.rows, 5), this.th = this.xt.je(this.Dr.width, this.Dr.height, 1), this.hr && (this.fh = N.Mr(this.xt, this.tr.targetCanvas, (s) => this.Ei.zi(s))), this.sh = this.xt.cs(st, "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._h(), await this.ph(this.ih), this.ih = [], this.rh = !0, this.oh(), this.jo.start(() => this.Vo());
2570
- }
2571
- async ph(e) {
2572
- if (e.length) for (const i of e) this.eh.has(i.name) ? console.warn(`[textmode.js] Plugin "${i.name}" is already installed.`) : (await i.install(this, this.mh()), this.eh.set(i.name, i));
2573
- }
2574
- async gh(e) {
2575
- const i = this.eh.get(e);
2576
- i && (i.uninstall && await i.uninstall(this, this.mh()), this.eh.delete(e));
2671
+ async Rh(e) {
2672
+ await this.ki.Ni(e.fontSource);
2673
+ const i = this.ki.maxGlyphDimensions;
2674
+ this.Gr = new zt(this.er.canvas, i.width, i.height), this.In.Ni(this.Gr), this.Jo.Ni(this.Gr), this.Vo = this.xt.Ye(this.Gr.cols, this.Gr.rows, 5), this._h = this.xt.Ye(this.Gr.width, this.Gr.height, 1), this.cr && (this.Mh = N.Fr(this.xt, this.er.targetCanvas, (s) => this.ki.zi(s))), this.ph = this.xt.cs(st, "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.Fh(), await this.mh.installMany(this.gh), this.gh = [], this.yh = !0, this.wh(), this.qo.start(() => this.Zo());
2577
2675
  }
2578
2676
  async use(e) {
2579
- return this.rh ? await this.ph([e]) : this.ih.push(e), this;
2677
+ return this.yh ? await this.mh.use(e) : this.gh.push(e), this;
2580
2678
  }
2581
2679
  async unuse(e) {
2582
- return this.rh ? (await this.gh(e), this) : (this.ih = this.ih.filter((i) => i.name !== e), this);
2680
+ return this.yh ? (await this.mh.unuse(e), this) : (this.gh = this.gh.filter((i) => i.name !== e), this);
2583
2681
  }
2584
2682
  hasPlugin(e) {
2585
- return this.rh ? this.eh.has(e) : this.ih.some((i) => i.name === e) || this.eh.has(e);
2683
+ return this.yh ? this.mh.has(e) : this.gh.some((i) => i.name === e);
2586
2684
  }
2587
- mh() {
2588
- return { renderer: this.xt, font: this.Ei, grid: this.Dr, canvas: this.tr, drawFramebuffer: this.Yo, asciiFramebuffer: this.th, flushDrawCommands: () => {
2589
- this.xt.zt(this.Jo);
2685
+ ah() {
2686
+ return { renderer: this.xt, font: this.ki, grid: this.Gr, canvas: this.er, drawFramebuffer: this.Vo, asciiFramebuffer: this._h, flushDrawCommands: () => {
2687
+ this.xt.zt(this.fh);
2590
2688
  } };
2591
2689
  }
2592
- _h() {
2593
- this.uh = () => {
2594
- this.hr && this.resizeCanvas(this.tr.targetCanvas.width, this.tr.targetCanvas.height), this.ah();
2595
- }, window.addEventListener("resize", this.uh), this.Bn.nn(), this.qo.nn(), this.Zo.nn(), window.addEventListener("blur", () => {
2596
- this.Zo.Dn();
2597
- }), window.ResizeObserver && this.hr && (this.ar = new ResizeObserver(() => {
2598
- this.resizeCanvas(this.tr.targetCanvas.width, this.tr.targetCanvas.height);
2599
- }), this.ar.observe(this.tr.targetCanvas));
2600
- }
2601
- Vo() {
2602
- if (this.jo.measureFrameRate(), this.jo.incrementFrame(), this.nh) return;
2603
- if (this.hr) {
2690
+ Fh() {
2691
+ this.xh = () => {
2692
+ this.cr && this.resizeCanvas(this.er.targetCanvas.width, this.er.targetCanvas.height), this.$h();
2693
+ }, window.addEventListener("resize", this.xh), this.In.an(), this.Jo.an(), this.Qo.an(), window.addEventListener("blur", () => {
2694
+ this.Qo.Gn();
2695
+ }), window.ResizeObserver && this.cr && (this.lr = new ResizeObserver(() => {
2696
+ this.resizeCanvas(this.er.targetCanvas.width, this.er.targetCanvas.height);
2697
+ }), this.lr.observe(this.er.targetCanvas));
2698
+ }
2699
+ Zo() {
2700
+ if (this.qo.measureFrameRate(), this.qo.incrementFrame(), this.Ch) return;
2701
+ if (this.cr) {
2604
2702
  const i = this.xt.context;
2605
- i.bindTexture(i.TEXTURE_2D, this.fh.texture), i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, 1), i.texImage2D(i.TEXTURE_2D, 0, i.RGBA, i.RGBA, i.UNSIGNED_BYTE, this.tr.targetCanvas), i.bindTexture(i.TEXTURE_2D, null);
2703
+ i.bindTexture(i.TEXTURE_2D, this.Mh.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);
2606
2704
  }
2607
- this.Yo.begin(), this.xt.Le(this.Jo), this.hh(), this.xt.zt(this.Jo), this.Yo.end(), this.th.begin(), this.xt.Le(this.Qo), this.Qo.Xt({ U0: this.Ei.fontFramebuffer, U1: [this.Ei.textureColumns, this.Ei.textureRows], U2: this.Yo.textures[0], U3: this.Yo.textures[1], U4: this.Yo.textures[2], U5: this.Yo.textures[4], U6: this.Yo.textures[3], U7: [this.Dr.cols, this.Dr.rows], U8: [this.th.width, this.th.height], U9: this.th.width / this.th.height }), this.xt.We(0, 0, this.tr.width, this.tr.height), this.th.end();
2705
+ this.mh.runPreDrawHooks(), this.Vo.begin(), this.xt.Le(this.fh), this.bh(), this.xt.zt(this.fh), this.Vo.end(), this._h.begin(), this.xt.Le(this.dh), this.dh.Xt({ U0: this.ki.fontFramebuffer, U1: [this.ki.textureColumns, this.ki.textureRows], U2: this.Vo.textures[0], U3: this.Vo.textures[1], U4: this.Vo.textures[2], U5: this.Vo.textures[4], U6: this.Vo.textures[3], U7: [this.Gr.cols, this.Gr.rows], U8: [this._h.width, this._h.height], U9: this._h.width / this._h.height }), this.xt.We(0, 0, this.er.width, this.er.height), this._h.end();
2608
2706
  const e = this.xt.state.canvasBackgroundColor;
2609
- this.xt.js(e[0], e[1], e[2], e[3]), this.xt.Le(this.sh), this.sh.Xt({ Ua: this.th.textures[0], Ub: [this.th.width, this.th.height], Uc: [this.Dr.offsetX, this.Dr.offsetY], Ud: [this.Dr.width, this.Dr.height] }), this.xt.We(this.Dr.offsetX, this.Dr.offsetY, this.Dr.width, this.Dr.height);
2707
+ this.xt.Ys(e[0], e[1], e[2], e[3]), this.xt.Le(this.ph), this.ph.Xt({ Ua: this._h.textures[0], Ub: [this._h.width, this._h.height], Uc: [this.Gr.offsetX, this.Gr.offsetY], Ud: [this.Gr.width, this.Gr.height] }), this.xt.We(this.Gr.offsetX, this.Gr.offsetY, this.Gr.width, this.Gr.height), this.mh.runPostDrawHooks();
2610
2708
  }
2611
2709
  setup(e) {
2612
- this.oh = e;
2710
+ this.wh = e;
2613
2711
  }
2614
2712
  draw(e) {
2615
- this.hh = e;
2713
+ this.bh = e;
2616
2714
  }
2617
2715
  windowResized(e) {
2618
- this.ah = e;
2716
+ this.$h = e;
2619
2717
  }
2620
2718
  resizeCanvas(e, i) {
2621
- this.tr.pr(e, i), this.Dr.ir(), this.Yo.resize(this.Dr.cols, this.Dr.rows), this.th.resize(this.Dr.width, this.Dr.height), this.xt.Ze(), this.Bn.rn(), this.qo.yo(), this.Vo();
2719
+ this.er.vr(e, i), this.Gr.nr(), this.Vo.resize(this.Gr.cols, this.Gr.rows), this._h.resize(this.Gr.width, this.Gr.height), this.xt.Ze(), this.In.hn(), this.Jo.wo(), this.Zo();
2622
2720
  }
2623
2721
  destroy() {
2624
- this.nh || (this.jo.stop(), window.removeEventListener("resize", this.uh), this.Bn.dn(), this.qo.dn(), this.Zo.dn(), this.Ei.kt(), this.xt.kt(), this.th.kt(), this.sh.kt(), this.fh && this.fh.kt(), this.nh = !0);
2722
+ this.Ch || (this.qo.stop(), this.mh.disposeAll().catch((e) => {
2723
+ console.error("[textmode.js] Error while disposing plugins:", e);
2724
+ }), window.removeEventListener("resize", this.xh), this.In.pn(), this.Jo.pn(), this.Qo.pn(), this.ki.Pt(), this.xt.Pt(), this._h.Pt(), this.ph.Pt(), this.Mh && this.Mh.Pt(), this.Ch = !0);
2625
2725
  }
2626
2726
  get grid() {
2627
- return this.Dr;
2727
+ return this.Gr;
2628
2728
  }
2629
2729
  get font() {
2630
- return this.Ei;
2730
+ return this.ki;
2631
2731
  }
2632
2732
  get width() {
2633
- return this.tr.width;
2733
+ return this.er.width;
2634
2734
  }
2635
2735
  get height() {
2636
- return this.tr.height;
2736
+ return this.er.height;
2637
2737
  }
2638
2738
  get canvas() {
2639
- return this.tr.canvas;
2739
+ return this.er.canvas;
2740
+ }
2741
+ get drawFramebuffer() {
2742
+ return this.Vo;
2640
2743
  }
2641
2744
  get isDisposed() {
2642
- return this.nh;
2745
+ return this.Ch;
2643
2746
  }
2644
2747
  get overlay() {
2645
- return this.fh;
2748
+ return this.Mh;
2646
2749
  }
2647
2750
  }
2648
- class Z {
2751
+ class J {
2649
2752
  constructor() {
2650
2753
  }
2651
2754
  static create(t = {}) {
2652
- return new te(t);
2755
+ return new ee(t);
2653
2756
  }
2654
2757
  static setErrorLevel(t) {
2655
- z.C(t);
2758
+ k.C(t);
2656
2759
  }
2657
2760
  static get version() {
2658
- return "0.3.2-beta.2";
2761
+ return "0.3.2-beta.3";
2659
2762
  }
2660
2763
  }
2661
- const ie = Object.freeze(Object.defineProperty({ __proto__: null }, Symbol.toStringTag, { value: "Module" })), se = Object.freeze(Object.defineProperty({ __proto__: null, keyboard: jt, mouse: kt, touch: Ht }, Symbol.toStringTag, { value: "Module" })), re = Z.create, ne = Z.setErrorLevel, oe = Z.version;
2764
+ const se = Object.freeze(Object.defineProperty({ __proto__: null }, Symbol.toStringTag, { value: "Module" })), re = Object.freeze(Object.defineProperty({ __proto__: null, keyboard: Ht, mouse: Yt, touch: Vt }, Symbol.toStringTag, { value: "Module" })), ne = J.create, oe = J.setErrorLevel, he = J.version;
2662
2765
  export {
2663
- Xt as TextmodeCanvas,
2766
+ Qt as PluginManager,
2767
+ Wt as TextmodeCanvas,
2664
2768
  ct as TextmodeErrorLevel,
2665
2769
  Nt as TextmodeFont,
2666
2770
  q as TextmodeFramebuffer,
2667
- Wt as TextmodeGrid,
2771
+ zt as TextmodeGrid,
2668
2772
  N as TextmodeImage,
2669
- te as Textmodifier,
2670
- re as create,
2671
- ie as export,
2672
- se as input,
2673
- ne as setErrorLevel,
2674
- Z as textmode,
2675
- oe as version
2773
+ ee as Textmodifier,
2774
+ ne as create,
2775
+ se as export,
2776
+ re as input,
2777
+ oe as setErrorLevel,
2778
+ J as textmode,
2779
+ he as version
2676
2780
  };